commit f51c4ef6dc0cdc268cced221c1c08a1599fcb079 Author: Cola-Echo Date: Wed Jan 21 18:11:33 2026 +0800 Update memory-manager-concurrent diff --git a/flow-configs/default.json b/flow-configs/default.json new file mode 100644 index 0000000..db53c99 --- /dev/null +++ b/flow-configs/default.json @@ -0,0 +1,56 @@ +{ + "version": 1, + "name": "默认流程配置", + "description": "系统默认的流程配置,定义了各个功能的来源顺序", + "configs": { + "记忆世界书": { + "description": "记忆世界书功能的来源顺序配置", + "sources": [ + "jailbreak", + "main", + "worldbook", + "context", + "auxiliary", + "user" + ] + }, + "总结世界书": { + "description": "总结世界书功能的来源顺序配置", + "sources": [ + "jailbreak", + "main", + "worldbook", + "context", + "auxiliary", + "user" + ] + }, + "索引合并": { + "description": "索引合并功能的来源顺序配置", + "sources": [ + "jailbreak", + "main", + "worldbook", + "context", + "auxiliary", + "user" + ] + }, + "剧情优化": { + "description": "剧情优化功能的来源顺序配置", + "sources": [ + "jailbreak", + "main", + "plot_worldbooks", + "plot_char_desc", + "plot_context", + "plot_historical", + "plot_user_msg", + "auxiliary", + "plot_history", + "plot_panel_worldbooks", + "plot_input" + ] + } + } +} diff --git a/games/3dcity/.gitignore b/games/3dcity/.gitignore new file mode 100644 index 0000000..2677bf5 --- /dev/null +++ b/games/3dcity/.gitignore @@ -0,0 +1,8 @@ +desktop.ini +dev.html +node_modules +package-lock.json +package-lock.json +npm-debug.log +prepa +*.sh \ No newline at end of file diff --git a/games/3dcity/COPYING b/games/3dcity/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/games/3dcity/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/games/3dcity/LICENSE b/games/3dcity/LICENSE new file mode 100644 index 0000000..d82ed9a --- /dev/null +++ b/games/3dcity/LICENSE @@ -0,0 +1,47 @@ +micropolisJS. + +Copyright (C) Graeme McCutcheon, 2013. + +Adapted from the original Micropolis source code release, and so released +under the GNU General Public License V3. + +ADDITIONAL TERMS per GNU GPL Section 7 + +No trademark or publicity rights are granted. This license does NOT +give you any right, title or interest in the trademark SimCity or any +other Electronic Arts trademark. You may not distribute any +modification of this program using the trademark SimCity or claim any +affliation or association with Electronic Arts Inc. or its employees. + +Any propagation or conveyance of this program must include this +copyright notice and these terms. + +If you convey this program (or any modifications of it) and assume +contractual liability for the program to recipients of it, you agree +to indemnify Electronic Arts for any liability that those contractual +assumptions impose on Electronic Arts. + +You may not misrepresent the origins of this program; modified +versions of the program must be marked as such and not identified as +the original program. + +This disclaimer supplements the one included in the General Public +License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS +PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY +OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF +SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS +DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES, +INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY +RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING, +USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST +INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL +MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE +UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE +WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE +CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR +ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME +JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED +WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A +CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY +NOT APPLY TO YOU. diff --git a/games/3dcity/README.md b/games/3dcity/README.md new file mode 100644 index 0000000..40d734c --- /dev/null +++ b/games/3dcity/README.md @@ -0,0 +1,24 @@ +3d.city v 0.8.0 +======= + +3d city builder [LAUNCH](http://lo-th.github.io/3d.city/index.html)
+ +The goal is create 3d city builder to test performance for three.js webgl games
+With minimum size impact and maximum speed.
+3d side use [Three.js](https://github.com/mrdoob/three.js), GLSL 3d model made by me.
+ +This game use simulation source micropolisJS by Graememcc, full convert to ES6
+[https://github.com/graememcc/micropolisJS](https://github.com/graememcc/micropolisJS)
+ +Game simulation work in a web worker. + +Work in progress + +
+
+
+ +Feature improvements + +add different envmap, add snow, destruct ...
+correct message display. diff --git a/games/3dcity/assets/img/preview01.jpg b/games/3dcity/assets/img/preview01.jpg new file mode 100644 index 0000000..1edf02e Binary files /dev/null and b/games/3dcity/assets/img/preview01.jpg differ diff --git a/games/3dcity/assets/img/preview02.jpg b/games/3dcity/assets/img/preview02.jpg new file mode 100644 index 0000000..dcf5ab6 Binary files /dev/null and b/games/3dcity/assets/img/preview02.jpg differ diff --git a/games/3dcity/assets/img/preview03.jpg b/games/3dcity/assets/img/preview03.jpg new file mode 100644 index 0000000..cb78a5f Binary files /dev/null and b/games/3dcity/assets/img/preview03.jpg differ diff --git a/games/3dcity/assets/loader.svg b/games/3dcity/assets/loader.svg new file mode 100644 index 0000000..2471ba9 --- /dev/null +++ b/games/3dcity/assets/loader.svg @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/games/3dcity/assets/models/cars.glb b/games/3dcity/assets/models/cars.glb new file mode 100644 index 0000000..3462576 Binary files /dev/null and b/games/3dcity/assets/models/cars.glb differ diff --git a/games/3dcity/assets/models/world.glb b/games/3dcity/assets/models/world.glb new file mode 100644 index 0000000..a19229f Binary files /dev/null and b/games/3dcity/assets/models/world.glb differ diff --git a/games/3dcity/assets/textures/basemenu.png b/games/3dcity/assets/textures/basemenu.png new file mode 100644 index 0000000..29921fc Binary files /dev/null and b/games/3dcity/assets/textures/basemenu.png differ diff --git a/games/3dcity/assets/textures/border.jpg b/games/3dcity/assets/textures/border.jpg new file mode 100644 index 0000000..6d66f1c Binary files /dev/null and b/games/3dcity/assets/textures/border.jpg differ diff --git a/games/3dcity/assets/textures/border_a.jpg b/games/3dcity/assets/textures/border_a.jpg new file mode 100644 index 0000000..c53af3d Binary files /dev/null and b/games/3dcity/assets/textures/border_a.jpg differ diff --git a/games/3dcity/assets/textures/building.png b/games/3dcity/assets/textures/building.png new file mode 100644 index 0000000..d4c358f Binary files /dev/null and b/games/3dcity/assets/textures/building.png differ diff --git a/games/3dcity/assets/textures/building_n.png b/games/3dcity/assets/textures/building_n.png new file mode 100644 index 0000000..8d6e9e4 Binary files /dev/null and b/games/3dcity/assets/textures/building_n.png differ diff --git a/games/3dcity/assets/textures/building_r.png b/games/3dcity/assets/textures/building_r.png new file mode 100644 index 0000000..0c8d955 Binary files /dev/null and b/games/3dcity/assets/textures/building_r.png differ diff --git a/games/3dcity/assets/textures/building_win.png b/games/3dcity/assets/textures/building_win.png new file mode 100644 index 0000000..5df7469 Binary files /dev/null and b/games/3dcity/assets/textures/building_win.png differ diff --git a/games/3dcity/assets/textures/cars.png b/games/3dcity/assets/textures/cars.png new file mode 100644 index 0000000..0c31202 Binary files /dev/null and b/games/3dcity/assets/textures/cars.png differ diff --git a/games/3dcity/assets/textures/day.hdr b/games/3dcity/assets/textures/day.hdr new file mode 100644 index 0000000..0f5e22d Binary files /dev/null and b/games/3dcity/assets/textures/day.hdr differ diff --git a/games/3dcity/assets/textures/env.jpg b/games/3dcity/assets/textures/env.jpg new file mode 100644 index 0000000..d0cc06c Binary files /dev/null and b/games/3dcity/assets/textures/env.jpg differ diff --git a/games/3dcity/assets/textures/interface.png b/games/3dcity/assets/textures/interface.png new file mode 100644 index 0000000..dfb3104 Binary files /dev/null and b/games/3dcity/assets/textures/interface.png differ diff --git a/games/3dcity/assets/textures/night.hdr b/games/3dcity/assets/textures/night.hdr new file mode 100644 index 0000000..6918e83 Binary files /dev/null and b/games/3dcity/assets/textures/night.hdr differ diff --git a/games/3dcity/assets/textures/road.png b/games/3dcity/assets/textures/road.png new file mode 100644 index 0000000..0248e75 Binary files /dev/null and b/games/3dcity/assets/textures/road.png differ diff --git a/games/3dcity/assets/textures/roadx.png b/games/3dcity/assets/textures/roadx.png new file mode 100644 index 0000000..a5f0d35 Binary files /dev/null and b/games/3dcity/assets/textures/roadx.png differ diff --git a/games/3dcity/assets/textures/sunset.hdr b/games/3dcity/assets/textures/sunset.hdr new file mode 100644 index 0000000..9852978 Binary files /dev/null and b/games/3dcity/assets/textures/sunset.hdr differ diff --git a/games/3dcity/assets/textures/tiles.png b/games/3dcity/assets/textures/tiles.png new file mode 100644 index 0000000..263a3db Binary files /dev/null and b/games/3dcity/assets/textures/tiles.png differ diff --git a/games/3dcity/assets/textures/tiles_n.png b/games/3dcity/assets/textures/tiles_n.png new file mode 100644 index 0000000..19d9b33 Binary files /dev/null and b/games/3dcity/assets/textures/tiles_n.png differ diff --git a/games/3dcity/assets/textures/tiles_r.png b/games/3dcity/assets/textures/tiles_r.png new file mode 100644 index 0000000..dd3f3ce Binary files /dev/null and b/games/3dcity/assets/textures/tiles_r.png differ diff --git a/games/3dcity/assets/textures/tokyo.hdr b/games/3dcity/assets/textures/tokyo.hdr new file mode 100644 index 0000000..2aa2f02 Binary files /dev/null and b/games/3dcity/assets/textures/tokyo.hdr differ diff --git a/games/3dcity/assets/textures/town.png b/games/3dcity/assets/textures/town.png new file mode 100644 index 0000000..7791b9a Binary files /dev/null and b/games/3dcity/assets/textures/town.png differ diff --git a/games/3dcity/assets/textures/town_n.png b/games/3dcity/assets/textures/town_n.png new file mode 100644 index 0000000..debfc4d Binary files /dev/null and b/games/3dcity/assets/textures/town_n.png differ diff --git a/games/3dcity/assets/textures/town_r.png b/games/3dcity/assets/textures/town_r.png new file mode 100644 index 0000000..2466641 Binary files /dev/null and b/games/3dcity/assets/textures/town_r.png differ diff --git a/games/3dcity/assets/textures/town_win.png b/games/3dcity/assets/textures/town_win.png new file mode 100644 index 0000000..4d120a8 Binary files /dev/null and b/games/3dcity/assets/textures/town_win.png differ diff --git a/games/3dcity/build/MainGame.module.js b/games/3dcity/build/MainGame.module.js new file mode 100644 index 0000000..d9132a6 --- /dev/null +++ b/games/3dcity/build/MainGame.module.js @@ -0,0 +1,57057 @@ +/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +/** + * @license + * Copyright 2010-2021 Uil.js Authors + * SPDX-License-Identifier: MIT + */ +/** + * @author lth / https://github.com/lo-th + */ + +// INTENAL FUNCTION + +const R = { + + ui: [], + + dom:null, + + ID: null, + lock:false, + wlock:false, + current:-1, + + needReZone: true, + isEventsInit: false, + isLeave:false, + + downTime:0, + prevTime:0, + + prevDefault: ['contextmenu', 'wheel'], + pointerEvent: ['pointerdown', 'pointermove', 'pointerup'], + eventOut: ['pointercancel', 'pointerout', 'pointerleave'], + + xmlserializer: null, + tmpTime: null, + tmpImage: null, + + oldCursor:'auto', + + input: null, + parent: null, + firstImput: true, + + hiddenImput:null, + hiddenSizer:null, + hasFocus:false, + startInput:false, + inputRange : [0,0], + cursorId : 0, + str:'', + pos:0, + startX:-1, + moveX:-1, + + debugInput:false, + + isLoop: false, + listens: [], + + e:{ + type:null, + clientX:0, + clientY:0, + keyCode:NaN, + key:null, + delta:0, + }, + + isMobile: false, + + now: null, + + getTime: function() { + return ( self.performance && self.performance.now ) ? self.performance.now.bind( performance ) : Date.now; + }, + + add: function ( o ) { + + R.ui.push( o ); + R.getZone( o ); + + if( !R.isEventsInit ) R.initEvents(); + + }, + + testMobile: function () { + + let n = navigator.userAgent; + if (n.match(/Android/i) || n.match(/webOS/i) || n.match(/iPhone/i) || n.match(/iPad/i) || n.match(/iPod/i) || n.match(/BlackBerry/i) || n.match(/Windows Phone/i)) return true; + else return false; + + }, + + remove: function ( o ) { + + let i = R.ui.indexOf( o ); + + if ( i !== -1 ) { + R.removeListen( o ); + R.ui.splice( i, 1 ); + } + + if( R.ui.length === 0 ){ + R.removeEvents(); + } + + }, + + // ---------------------- + // EVENTS + // ---------------------- + + initEvents: function () { + + if( R.isEventsInit ) return; + + let dom = document.body; + + R.isMobile = R.testMobile(); + R.now = R.getTime(); + + + if(!R.isMobile){ + dom.addEventListener( 'wheel', R, { passive: false } ); + } else { + dom.style.touchAction = 'none'; + } + + + dom.addEventListener( 'pointercancel', R ); + dom.addEventListener( 'pointerleave', R ); + //dom.addEventListener( 'pointerout', R ) + + dom.addEventListener( 'pointermove', R ); + dom.addEventListener( 'pointerdown', R ); + dom.addEventListener( 'pointerup', R ); + + + dom.addEventListener( 'keydown', R, false ); + dom.addEventListener( 'keyup', R, false ); + window.addEventListener( 'resize', R.resize , false ); + + //window.onblur = R.out; + //window.onfocus = R.in; + + + R.isEventsInit = true; + R.dom = dom; + + }, + + removeEvents: function () { + + if( !R.isEventsInit ) return; + + let dom = document.body; + + if(!R.isMobile){ + dom.removeEventListener( 'wheel', R ); + } + + + dom.removeEventListener( 'pointercancel', R ); + dom.removeEventListener( 'pointerleave', R ); + //dom.removeEventListener( 'pointerout', R ); + + dom.removeEventListener( 'pointermove', R ); + dom.removeEventListener( 'pointerdown', R ); + dom.removeEventListener( 'pointerup', R ); + + + dom.removeEventListener( 'keydown', R ); + dom.removeEventListener( 'keyup', R ); + window.removeEventListener( 'resize', R.resize ); + + R.isEventsInit = false; + + }, + + resize: function () { + + R.needReZone = true; + + let i = R.ui.length, u; + + while( i-- ){ + + u = R.ui[i]; + if( u.isGui && !u.isCanvasOnly && u.autoResize ) u.calc(); + + } + + }, + + out: function () { + + console.log('im am out'); + R.clearOldID(); + + }, + + in: function () { + + console.log('im am in'); + // R.clearOldID(); + + }, + + // ---------------------- + // HANDLE EVENTS + // ---------------------- + + fakeUp: function(){ + + this.handleEvent( {type:'pointerup'} ); + + }, + + + handleEvent: function ( event ) { + + //if(!event.type) return; + + if( R.prevDefault.indexOf( event.type ) !== -1 ) event.preventDefault(); + + R.findZone(); + + let e = R.e; + let leave = false; + + if( event.type === 'keydown') R.keydown( event ); + if( event.type === 'keyup') R.keyup( event ); + + if( event.type === 'wheel' ) e.delta = event.deltaY > 0 ? 1 : -1; + else e.delta = 0; + + let ptype = event.pointerType; // mouse, pen, touch + + e.clientX = ( ptype === 'touch' ? event.pageX : event.clientX ) || 0; + e.clientY = ( ptype === 'touch' ? event.pageY : event.clientY ) || 0; + + e.type = event.type; + + if( R.eventOut.indexOf( event.type ) !== -1 ){ + leave = true; + e.type = 'mouseup'; + } + + if( event.type === 'pointerleave'){ R.isLeave = true; } + + if( event.type === 'pointerdown') e.type = 'mousedown'; + if( event.type === 'pointerup') e.type = 'mouseup'; + if( event.type === 'pointermove'){ + if( R.isLeave ){ + // if user resize outside this document + R.isLeave = false; + R.resize(); + } + e.type = 'mousemove'; + } + + // double click test + if( e.type === 'mousedown' ) { + R.downTime = R.now(); + let time = R.downTime - R.prevTime; + + // double click on imput + if( time < 200 ) { R.selectAll(); return false } + + R.prevTime = R.downTime; + } + + // for imput + if( e.type === 'mousedown' ) R.clearInput(); + + // mouse lock + if( e.type === 'mousedown' ) R.lock = true; + if( e.type === 'mouseup' ) R.lock = false; + + //if( R.current !== null && R.current.neverlock ) R.lock = false; + + /*if( e.type === 'mousedown' && event.button === 1){ + R.cursor() + e.preventDefault(); + e.stopPropagation(); + }*/ + + if( R.isMobile && e.type === 'mousedown' ) R.findID( e ); + if( e.type === 'mousemove' && !R.lock ) R.findID( e ); + + if( R.ID !== null ){ + + if( R.ID.isCanvasOnly ) { + + e.clientX = R.ID.mouse.x; + e.clientY = R.ID.mouse.y; + + } + + R.ID.handleEvent( e ); + + } + + if( R.isMobile && e.type === 'mouseup' ) R.clearOldID(); + if( leave ) R.clearOldID(); + + + }, + + // ---------------------- + // ID + // ---------------------- + + findID: function ( e ) { + + let i = R.ui.length, next = -1, u, x, y; + + while( i-- ){ + + u = R.ui[i]; + + if( u.isCanvasOnly ) { + + x = u.mouse.x; + y = u.mouse.y; + + } else { + + x = e.clientX; + y = e.clientY; + + } + + if( R.onZone( u, x, y ) ){ + + next = i; + + if( next !== R.current ){ + R.clearOldID(); + R.current = next; + R.ID = u; + } + break; + } + + } + + if( next === -1 ) R.clearOldID(); + + }, + + clearOldID: function () { + + if( !R.ID ) return; + R.current = -1; + R.ID.reset(); + R.ID = null; + R.cursor(); + + }, + + // ---------------------- + // GUI / GROUP FUNCTION + // ---------------------- + + calcUis: function ( uis, zone, py ) { + + //console.log('calc_uis') + + let i = uis.length, u, px = 0, n = 0, tw; + let height = 0; + let m = 1; + + while( i-- ){ + + u = uis[n]; + n++; + + if( u.isGroup ) u.calcUis(); + + u.zone.w = u.w; + u.zone.h = u.h; + m = u.margin; + + if( !u.autoWidth ){ + + if( px===0 ){ + height += u.h + m; + + } + + u.zone.x = zone.x + px; + u.zone.y = py; + + tw = R.getWidth(u); + if( tw ) u.zone.w = u.w = tw; + // focrce width if content is canvas + else if( u.fw ) u.zone.w = u.w = u.fw; + + + //console.log( u.name, u.zone.w, u.w, zone, tw ) + //console.log( tw ) + px += u.zone.w; + + if( px >= zone.w ) { + py += u.h + m; + px = 0; + } + + } else { + + px = 0; + + u.zone.x = zone.x; + u.zone.y = py; + py += u.h + m; + + height += u.h + m; + + } + + } + + return height + + }, + + + findTarget: function ( uis, e ) { + + let i = uis.length; + + while( i-- ){ + if( R.onZone( uis[i], e.clientX, e.clientY ) ) return i + } + + return -1; + + }, + + // ---------------------- + // ZONE + // ---------------------- + + findZone: function ( force ) { + + if( !R.needReZone && !force ) return; + + var i = R.ui.length, u; + + while( i-- ){ + + u = R.ui[i]; + R.getZone( u ); + if( u.isGui ) u.calcUis(); + + } + + R.needReZone = false; + + }, + + onZone: function ( o, x, y ) { + + if( x === undefined || y === undefined ) return false; + + let z = o.zone; + let mx = x - z.x; + let my = y - z.y; + + let over = ( mx >= 0 ) && ( my >= 0 ) && ( mx <= z.w ) && ( my <= z.h ); + + if( over ) o.local.set( mx, my ); + else o.local.neg(); + + return over; + + }, + + getWidth: function ( o ) { + + + + //return o.getDom().offsetWidth + return o.getDom().clientWidth + + //let r = o.getDom().getBoundingClientRect(); + //return (r.width) + //return Math.floor(r.width) + + }, + + getZone: function ( o ) { + + if( o.isCanvasOnly ) return; + let r = o.getDom().getBoundingClientRect(); + + //if( !r.width ) return + //o.zone = { x:Math.floor(r.left), y:Math.floor(r.top), w:Math.floor(r.width), h:Math.floor(r.height) }; + //o.zone = { x:Math.round(r.left), y:Math.round(r.top), w:Math.round(r.width), h:Math.round(r.height) }; + o.zone = { x:r.left, y:r.top, w:r.width, h:r.height }; + + //console.log(o.name, o.zone) + + }, + + // ---------------------- + // CURSOR + // ---------------------- + + cursor: function ( name ) { + + name = name ? name : 'auto'; + if( name !== R.oldCursor ){ + document.body.style.cursor = name; + R.oldCursor = name; + } + + }, + + // ---------------------- + // CANVAS + // ---------------------- + + toCanvas: function ( o, w, h, force ) { + + if( !R.xmlserializer ) R.xmlserializer = new XMLSerializer(); + + // prevent exesive redraw + + if( force && R.tmpTime !== null ) { clearTimeout(R.tmpTime); R.tmpTime = null; } + + if( R.tmpTime !== null ) return; + + if( R.lock ) R.tmpTime = setTimeout( function(){ R.tmpTime = null; }, 10 ); + + /// + + let isNewSize = false; + if( w !== o.canvas.width || h !== o.canvas.height ) isNewSize = true; + + if( R.tmpImage === null ) R.tmpImage = new Image(); + + let img = R.tmpImage; //new Image(); + + let htmlString = R.xmlserializer.serializeToString( o.content ); + + let svg = ''+ htmlString +''; + + img.onload = function() { + + let ctx = o.canvas.getContext("2d"); + + if( isNewSize ){ + o.canvas.width = w; + o.canvas.height = h; + }else { + ctx.clearRect( 0, 0, w, h ); + } + ctx.drawImage( this, 0, 0 ); + + o.onDraw(); + + }; + + img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg); + //img.src = 'data:image/svg+xml;base64,'+ window.btoa( svg ); + img.crossOrigin = ''; + + + }, + + // ---------------------- + // INPUT + // ---------------------- + + setHidden: function () { + + + if( R.hiddenImput === null ){ + + //let css = R.parent.css.txtselect + 'padding:0; width:auto; height:auto; ' + //let css = R.parent.css.txt + 'padding:0; width:auto; height:auto; text-shadow:none;' + //css += 'left:10px; top:auto; border:none; color:#FFF; background:#000;' + hide; + + R.hiddenImput = document.createElement('input'); + R.hiddenImput.type = 'text'; + //R.hiddenImput.style.cssText = css + 'bottom:30px;' + (R.debugInput ? '' : 'transform:scale(0);'); + + R.hiddenSizer = document.createElement('div'); + //R.hiddenSizer.style.cssText = css + 'bottom:60px;'; + + document.body.appendChild( R.hiddenImput ); + document.body.appendChild( R.hiddenSizer ); + + } + + let hide = R.debugInput ? '' : 'opacity:0; zIndex:0;'; + let css = R.parent.css.txtselect + 'padding:0; width:auto; height:auto; left:10px; top:auto; color:#FFF; background:#000;'+ hide; + R.hiddenImput.style.cssText = css + 'bottom:10px;' + (R.debugInput ? '' : 'transform:scale(0);'); + R.hiddenSizer.style.cssText = css + 'bottom:40px;'; + + R.hiddenImput.style.width = R.input.clientWidth + 'px'; + R.hiddenImput.value = R.str; + R.hiddenSizer.innerHTML = R.str; + + R.hasFocus = true; + + }, + + clearHidden: function ( p ) { + + if( R.hiddenImput === null ) return; + R.hasFocus = false; + + }, + + clickPos: function( x ){ + + let i = R.str.length, l = 0, n = 0; + while( i-- ){ + l += R.textWidth( R.str[n] ); + if( l >= x ) break; + n++; + } + return n; + + }, + + upInput: function ( x, down ) { + + if( R.parent === null ) return false; + + let up = false; + + if( down ){ + + let id = R.clickPos( x ); + + R.moveX = id; + + if( R.startX === -1 ){ + + R.startX = id; + R.cursorId = id; + R.inputRange = [ R.startX, R.startX ]; + + } else { + + let isSelection = R.moveX !== R.startX; + + if( isSelection ){ + if( R.startX > R.moveX ) R.inputRange = [ R.moveX, R.startX ]; + else R.inputRange = [ R.startX, R.moveX ]; + } + } + + up = true; + + } else { + + if( R.startX !== -1 ){ + + R.hasFocus = true; + R.hiddenImput.focus(); + R.hiddenImput.selectionStart = R.inputRange[0]; + R.hiddenImput.selectionEnd = R.inputRange[1]; + R.startX = -1; + + up = true; + + } + + } + + if( up ) R.selectParent(); + + return up; + + }, + + selectAll: function (){ + + if(!R.parent) return + + R.str = R.input.textContent; + R.inputRange = [0, R.str.length ]; + R.hasFocus = true; + R.hiddenImput.focus(); + R.hiddenImput.selectionStart = R.inputRange[0]; + R.hiddenImput.selectionEnd = R.inputRange[1]; + R.cursorId = R.inputRange[1]; + R.selectParent(); + + }, + + selectParent: function (){ + + var c = R.textWidth( R.str.substring( 0, R.cursorId )); + var e = R.textWidth( R.str.substring( 0, R.inputRange[0] )); + var s = R.textWidth( R.str.substring( R.inputRange[0], R.inputRange[1] )); + + R.parent.select( c, e, s, R.hiddenSizer.innerHTML ); + + }, + + textWidth: function ( text ){ + + if( R.hiddenSizer === null ) return 0; + text = text.replace(/ /g, ' '); + R.hiddenSizer.innerHTML = text; + return R.hiddenSizer.clientWidth; + + }, + + + clearInput: function () { + + if( R.parent === null ) return; + if( !R.firstImput ) R.parent.validate( true ); + + R.clearHidden(); + R.parent.unselect(); + + //R.input.style.background = 'none'; + R.input.style.background = R.parent.colors.back; + R.input.style.borderColor = R.parent.colors.border; + //R.input.style.color = R.parent.colors.text; + R.parent.isEdit = false; + + R.input = null; + R.parent = null; + R.str = '', + R.firstImput = true; + + }, + + setInput: function ( Input, parent ) { + + R.clearInput(); + + R.input = Input; + R.parent = parent; + + R.input.style.background = R.parent.colors.backoff; + R.input.style.borderColor = R.parent.colors.select; + //R.input.style.color = R.parent.colors.textSelect; + R.str = R.input.textContent; + + R.setHidden(); + + }, + + keydown: function ( e ) { + + if( R.parent === null ) return; + + let keyCode = e.which; e.shiftKey; + + //console.log( keyCode ) + + R.firstImput = false; + + + if (R.hasFocus) { + // hack to fix touch event bug in iOS Safari + window.focus(); + R.hiddenImput.focus(); + + } + + + R.parent.isEdit = true; + + // e.preventDefault(); + + // add support for Ctrl/Cmd+A selection + //if ( keyCode === 65 && (e.ctrlKey || e.metaKey )) { + //R.selectText(); + //e.preventDefault(); + //return self.render(); + //} + + if( keyCode === 13 ){ //enter + + R.clearInput(); + + //} else if( keyCode === 9 ){ //tab key + + // R.input.textContent = ''; + + } else { + + if( R.input.isNum ){ + if ( ((e.keyCode > 47) && (e.keyCode < 58)) || ((e.keyCode > 95) && (e.keyCode < 106)) || e.keyCode === 190 || e.keyCode === 110 || e.keyCode === 8 || e.keyCode === 109 ){ + R.hiddenImput.readOnly = false; + } else { + R.hiddenImput.readOnly = true; + } + } else { + R.hiddenImput.readOnly = false; + } + + } + + }, + + keyup: function ( e ) { + + if( R.parent === null ) return; + + R.str = R.hiddenImput.value; + + if( R.parent.allEqual ) R.parent.sameStr( R.str );// numeric samùe value + else R.input.textContent = R.str; + + R.cursorId = R.hiddenImput.selectionStart; + R.inputRange = [ R.hiddenImput.selectionStart, R.hiddenImput.selectionEnd ]; + + R.selectParent(); + + //if( R.parent.allway ) + R.parent.validate(); + + }, + + // ---------------------- + // + // LISTENING + // + // ---------------------- + + loop: function () { + + if( R.isLoop ) requestAnimationFrame( R.loop ); + R.update(); + + }, + + update: function () { + + let i = R.listens.length; + while( i-- ) R.listens[i].listening(); + + }, + + removeListen: function ( proto ) { + + let id = R.listens.indexOf( proto ); + if( id !== -1 ) R.listens.splice(id, 1); + if( R.listens.length === 0 ) R.isLoop = false; + + }, + + addListen: function ( proto ) { + + let id = R.listens.indexOf( proto ); + + if( id !== -1 ) return false; + + R.listens.push( proto ); + + if( !R.isLoop ){ + R.isLoop = true; + R.loop(); + } + + return true; + + }, + +}; + +const Roots = R; + +/** + * @author lth / https://github.com/lo-th + */ + +const T = { + + transition: 0.2, + + frag: document.createDocumentFragment(), + + colorRing: null, + joystick_0: null, + joystick_1: null, + circular: null, + knob: null, + pad2d: null, + + svgns: "http://www.w3.org/2000/svg", + links: "http://www.w3.org/1999/xlink", + htmls: "http://www.w3.org/1999/xhtml", + + DOM_SIZE: [ 'height', 'width', 'top', 'left', 'bottom', 'right', 'margin-left', 'margin-right', 'margin-top', 'margin-bottom'], + SVG_TYPE_D: [ 'pattern', 'defs', 'transform', 'stop', 'animate', 'radialGradient', 'linearGradient', 'animateMotion', 'use', 'filter', 'feColorMatrix' ], + SVG_TYPE_G: [ 'svg', 'rect', 'circle', 'path', 'polygon', 'text', 'g', 'line', 'foreignObject' ], + + PI: Math.PI, + TwoPI: Math.PI*2, + pi90: Math.PI * 0.5, + pi60: Math.PI/3, + + torad: Math.PI / 180, + todeg: 180 / Math.PI, + + clamp: function (v, min, max) { + + v = v < min ? min : v; + v = v > max ? max : v; + return v; + + }, + + size: { w: 240, h: 20, p: 30, s: 8 }, + + // ---------------------- + // COLOR + // ---------------------- + + defineColor: function( o, cc = T.colors ) { + + let color = { ...cc }; + + let textChange = ['fontFamily', 'fontWeight', 'fontShadow', 'fontSize' ]; + let changeText = false; + + if( o.font ) o.fontFamily = o.font; + if( o.shadow ) o.fontShadow = o.shadow; + if( o.weight ) o.fontWeight = o.weight; + + if( o.fontColor ) o.text = o.fontColor; + if( o.color ) o.text = o.color; + + if( o.text ){ + color.text = o.text; + if( !o.fontColor && !o.color ){ + color.title = T.ColorLuma( o.text, -0.25 ); + color.titleoff = T.ColorLuma( o.text, -0.5 ); + } + color.textOver = T.ColorLuma( o.text, 0.25 ); + color.textSelect = T.ColorLuma( o.text, 0.5 ); + } + + if( o.button ){ + color.button = o.button; + color.border = T.ColorLuma( o.button, 0.1 ); + color.overoff = T.ColorLuma( o.button, 0.2 ); + } + + if( o.select ){ + color.select = o.select; + color.over = T.ColorLuma( o.select, -0.1 ); + } + + if( o.itemBg ) o.back = o.itemBg; + + if( o.back ){ + color.back = o.back; + color.backoff = T.ColorLuma( o.back, -0.1 ); + } + + if( o.fontSelect ) color.textSelect = o.fontSelect; + if( o.groupBorder ) color.gborder = o.groupBorder; + + if( o.transparent ) o.bg = 'none'; + if( o.bg ) color.background = color.backgroundOver = o.bg; + if( o.bgOver ) color.backgroundOver = o.bgOver; + + for( let m in color ){ + if(o[m]) color[m] = o[m]; + } + + for( let m in o ){ + if( textChange.indexOf(m) !== -1 ) changeText = true; + } + + if( changeText ) T.defineText( color ); + + return color + + }, + + colors: { + + content:'none', + background: 'rgba(50,50,50,0.3)', + backgroundOver: 'rgba(50,50,50,0.4)', + + title : '#CCC', + titleoff : '#BBB', + text : '#DDD', + textOver : '#EEE', + textSelect : '#FFF', + + //inputBg: 'rgba(0,0,0,0.25)', + //itemBg:'rgba(0,0,0,0.25)', + + back:'rgba(0,0,0,0.2)', + backoff:'rgba(0,0,0,0.3)', + //inputOver: 'rgba(0,0,0,0.2)', + + // input and button border + border : '#4c4c4c', + borderSize : 1, + gborder : 'none', + + button : '#3c3c3c', + overoff : '#5c5c5c', + over : '#024699', + select : '#308AFF', + action: '#FF3300', + + + //fontFamily: 'Tahoma', + fontFamily: 'Consolas,monaco,monospace', + fontWeight: 'normal', + fontShadow: '#000', + fontSize:12, + + + radius:4, + hide: 'rgba(0,0,0,0)', + + }, + + // style css + + css : { + + //unselect: '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;', + basic: 'position:absolute; pointer-events:none; box-sizing:border-box; margin:0; padding:0; overflow:hidden; ' + '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;', + button:'display:flex; justify-content:center; align-items:center; text-align:center;', + + /*txt: T.css.basic + 'font-family:'+ T.colors.fontFamily +'; font-size:'+T.colors.fontSize+'px; color:'+T.colors.text+'; padding:2px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;', + txtselect: T.css.txt + 'display:flex; justify-content:left; align-items:center; text-align:left;' +'padding:2px 5px; border:1px dashed ' + T.colors.border + '; background:'+ T.colors.txtselectbg+';', + item: T.css.txt + 'position:relative; background:rgba(0,0,0,0.2); margin-bottom:1px;',*/ + }, + + // svg path + + svgs: { + + group:'M 7 7 L 7 8 8 8 8 7 7 7 M 5 7 L 5 8 6 8 6 7 5 7 M 3 7 L 3 8 4 8 4 7 3 7 M 7 5 L 7 6 8 6 8 5 7 5 M 6 6 L 6 5 5 5 5 6 6 6 M 7 3 L 7 4 8 4 8 3 7 3 M 6 4 L 6 3 5 3 5 4 6 4 M 3 5 L 3 6 4 6 4 5 3 5 M 3 3 L 3 4 4 4 4 3 3 3 Z', + arrow:'M 3 8 L 8 5 3 2 3 8 Z', + arrowDown:'M 5 8 L 8 3 2 3 5 8 Z', + arrowUp:'M 5 2 L 2 7 8 7 5 2 Z', + + solid:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 Z', + body:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 M 5 4 L 4 5 4 10 9 10 10 9 10 4 5 4 Z', + vehicle:'M 13 6 L 11 1 3 1 1 6 1 13 3 13 3 11 11 11 11 13 13 13 13 6 M 2.4 6 L 4 2 10 2 11.6 6 2.4 6 M 12 8 L 12 10 10 10 10 8 12 8 M 4 8 L 4 10 2 10 2 8 4 8 Z', + articulation:'M 13 9 L 12 9 9 2 9 1 5 1 5 2 2 9 1 9 1 13 5 13 5 9 4 9 6 5 8 5 10 9 9 9 9 13 13 13 13 9 Z', + character:'M 13 4 L 12 3 9 4 5 4 2 3 1 4 5 6 5 8 4 13 6 13 7 9 8 13 10 13 9 8 9 6 13 4 M 6 1 L 6 3 8 3 8 1 6 1 Z', + terrain:'M 13 8 L 12 7 Q 9.06 -3.67 5.95 4.85 4.04 3.27 2 7 L 1 8 7 13 13 8 M 3 8 Q 3.78 5.420 5.4 6.6 5.20 7.25 5 8 L 7 8 Q 8.39 -0.16 11 8 L 7 11 3 8 Z', + joint:'M 7.7 7.7 Q 8 7.45 8 7 8 6.6 7.7 6.3 7.45 6 7 6 6.6 6 6.3 6.3 6 6.6 6 7 6 7.45 6.3 7.7 6.6 8 7 8 7.45 8 7.7 7.7 M 3.35 8.65 L 1 11 3 13 5.35 10.65 Q 6.1 11 7 11 8.28 11 9.25 10.25 L 7.8 8.8 Q 7.45 9 7 9 6.15 9 5.55 8.4 5 7.85 5 7 5 6.54 5.15 6.15 L 3.7 4.7 Q 3 5.712 3 7 3 7.9 3.35 8.65 M 10.25 9.25 Q 11 8.28 11 7 11 6.1 10.65 5.35 L 13 3 11 1 8.65 3.35 Q 7.9 3 7 3 5.7 3 4.7 3.7 L 6.15 5.15 Q 6.54 5 7 5 7.85 5 8.4 5.55 9 6.15 9 7 9 7.45 8.8 7.8 L 10.25 9.25 Z', + ray:'M 9 11 L 5 11 5 12 9 12 9 11 M 12 5 L 11 5 11 9 12 9 12 5 M 11.5 10 Q 10.9 10 10.45 10.45 10 10.9 10 11.5 10 12.2 10.45 12.55 10.9 13 11.5 13 12.2 13 12.55 12.55 13 12.2 13 11.5 13 10.9 12.55 10.45 12.2 10 11.5 10 M 9 10 L 10 9 2 1 1 2 9 10 Z', + collision:'M 11 12 L 13 10 10 7 13 4 11 2 7.5 5.5 9 7 7.5 8.5 11 12 M 3 2 L 1 4 4 7 1 10 3 12 8 7 3 2 Z', + map:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z', + material:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z', + texture:'M 13 4 L 13 1 1 1 1 4 5 4 5 13 9 13 9 4 13 4 Z', + object:'M 10 1 L 7 4 4 1 1 1 1 13 4 13 4 5 7 8 10 5 10 13 13 13 13 1 10 1 Z', + none:'M 9 5 L 5 5 5 9 9 9 9 5 Z', + cursor:'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z', + + }, + + + getImput: function(){ + + return Roots.input ? true : false + + }, + + setStyle : function ( data ){ + + for ( var o in data ){ + if( T.colors[o] ) T.colors[o] = data[o]; + } + + T.setText(); + + }, + + // ---------------------- + // custom text + // ---------------------- + + defineText: function( o ){ + + T.setText( o.fontSize, o.text, o.fontFamily, o.fontShadow, o.fontWeight ); + + }, + + setText: function( size, color, font, shadow, weight ){ + + let cc = T.colors; + + if( font === undefined ) font = cc.fontFamily; + if( size === undefined ) size = cc.fontSize; + if( shadow === undefined ) shadow = cc.fontShadow; + if( weight === undefined ) weight = cc.fontWeight; + if( color === undefined ) color = cc.text; + + + let align = 'display:flex; justify-content:left; align-items:center; text-align:left;'; + + T.css.txt = T.css.basic + align + 'font-family:'+ font +'; font-weight:'+weight+'; font-size:'+size+'px; color:'+cc.text+'; padding:0px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;'; + if( shadow !== 'none' ) T.css.txt += ' text-shadow: 1px 1px 1px '+shadow+';'; + + T.css.txtselect = T.css.txt + 'padding:0px 4px; border:1px dashed ' + cc.border + ';'; + //T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; '//display:block; padding:4px 4px;';// + T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; display:block; padding:2px 4px;';// + + }, + + + // note + + //https://developer.mozilla.org/fr/docs/Web/CSS/css_flexible_box_layout/aligning_items_in_a_flex_container + + /*cloneColor: function () { + + let cc = Object.assign({}, T.colors ); + return cc; + + },*/ + + // intern function + + cloneCss: function () { + + //let cc = Object.assign({}, T.css ); + return { ...T.css }; + + }, + + clone: function ( o ) { + + return o.cloneNode( true ); + + }, + + setSvg: function( dom, type, value, id, id2 ){ + + if( id === -1 ) dom.setAttributeNS( null, type, value ); + else if( id2 !== undefined ) dom.childNodes[ id || 0 ].childNodes[ id2 || 0 ].setAttributeNS( null, type, value ); + else dom.childNodes[ id || 0 ].setAttributeNS( null, type, value ); + + }, + + setCss: function( dom, css ){ + + for( let r in css ){ + if( T.DOM_SIZE.indexOf(r) !== -1 ) dom.style[r] = css[r] + 'px'; + else dom.style[r] = css[r]; + } + + }, + + set: function( g, o ){ + + for( let att in o ){ + if( att === 'txt' ) g.textContent = o[ att ]; + if( att === 'link' ) g.setAttributeNS( T.links, 'xlink:href', o[ att ] ); + else g.setAttributeNS( null, att, o[ att ] ); + } + + }, + + get: function( dom, id ){ + + if( id === undefined ) return dom; // root + else if( !isNaN( id ) ) return dom.childNodes[ id ]; // first child + else if( id instanceof Array ){ + if(id.length === 2) return dom.childNodes[ id[0] ].childNodes[ id[1] ]; + if(id.length === 3) return dom.childNodes[ id[0] ].childNodes[ id[1] ].childNodes[ id[2] ]; + } + + }, + + dom : function ( type, css, obj, dom, id ) { + + type = type || 'div'; + + if( T.SVG_TYPE_D.indexOf(type) !== -1 || T.SVG_TYPE_G.indexOf(type) !== -1 ){ // is svg element + + if( type ==='svg' ){ + + dom = document.createElementNS( T.svgns, 'svg' ); + T.set( dom, obj ); + + /* } else if ( type === 'use' ) { + + dom = document.createElementNS( T.svgns, 'use' ); + T.set( dom, obj ); +*/ + } else { + // create new svg if not def + if( dom === undefined ) dom = document.createElementNS( T.svgns, 'svg' ); + T.addAttributes( dom, type, obj, id ); + + } + + } else { // is html element + + if( dom === undefined ) dom = document.createElementNS( T.htmls, type ); + else dom = dom.appendChild( document.createElementNS( T.htmls, type ) ); + + } + + if( css ) dom.style.cssText = css; + + if( id === undefined ) return dom; + else return dom.childNodes[ id || 0 ]; + + }, + + addAttributes : function( dom, type, o, id ){ + + let g = document.createElementNS( T.svgns, type ); + T.set( g, o ); + T.get( dom, id ).appendChild( g ); + if( T.SVG_TYPE_G.indexOf(type) !== -1 ) g.style.pointerEvents = 'none'; + return g; + + }, + + clear : function( dom ){ + + T.purge( dom ); + while (dom.firstChild) { + if ( dom.firstChild.firstChild ) T.clear( dom.firstChild ); + dom.removeChild( dom.firstChild ); + } + + }, + + purge : function ( dom ) { + + let a = dom.attributes, i, n; + if (a) { + i = a.length; + while(i--){ + n = a[i].name; + if (typeof dom[n] === 'function') dom[n] = null; + } + } + a = dom.childNodes; + if (a) { + i = a.length; + while(i--){ + T.purge( dom.childNodes[i] ); + } + } + + }, + + // ---------------------- + // SVG Effects function + // ---------------------- + + addSVGGlowEffect: function () { + + if ( document.getElementById( 'UILGlow') !== null ) return; + + let svgFilter = T.initUILEffects(); + + let filter = T.addAttributes( svgFilter, 'filter', { id: 'UILGlow', x: '-20%', y: '-20%', width: '140%', height: '140%' } ); + T.addAttributes( filter, 'feGaussianBlur', { in: 'SourceGraphic', stdDeviation: '3', result: 'uilBlur' } ); + let feMerge = T.addAttributes( filter, 'feMerge', { } ); + + for( let i = 0; i <= 3; i++ ) { + + T.addAttributes( feMerge, 'feMergeNode', { in: 'uilBlur' } ); + + } + + T.addAttributes( feMerge, 'feMergeNode', { in: 'SourceGraphic' } ); + + }, + + initUILEffects: function () { + + let svgFilter = document.getElementById( 'UILSVGEffects'); + + if ( svgFilter === null ) { + + svgFilter = T.dom( 'svg', undefined , { id: 'UILSVGEffects', width: '0', height: '0' } ); + document.body.appendChild( svgFilter ); + + } + + return svgFilter; + + }, + + // ---------------------- + // Color function + // ---------------------- + + ColorLuma : function ( hex, l ) { + + if( hex === 'n' ) hex = '#000'; + + // validate hex string + hex = String(hex).replace(/[^0-9a-f]/gi, ''); + if (hex.length < 6) { + hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; + } + l = l || 0; + + // convert to decimal and change luminosity + let rgb = "#", c, i; + for (i = 0; i < 3; i++) { + c = parseInt(hex.substr(i*2,2), 16); + c = Math.round(Math.min(Math.max(0, c + (c * l)), 255)).toString(16); + rgb += ("00"+c).substr(c.length); + } + + return rgb; + + }, + + findDeepInver: function ( c ) { + + return (c[0] * 0.3 + c[1] * .59 + c[2] * .11) <= 0.6; + + }, + + lerpColor: function( c1, c2, factor ) { + let newColor = {}; + for ( let i = 0; i < 3; i++ ) { + newColor[i] = c1[ i ] + ( c2[ i ] - c1[ i ] ) * factor; + } + return newColor; + }, + + hexToHtml: function ( v ) { + v = v === undefined ? 0x000000 : v; + return "#" + ("000000" + v.toString(16)).substr(-6); + + }, + + htmlToHex: function ( v ) { + + return v.toUpperCase().replace("#", "0x"); + + }, + + u255: function (c, i) { + + return parseInt(c.substring(i, i + 2), 16) / 255; + + }, + + u16: function ( c, i ) { + + return parseInt(c.substring(i, i + 1), 16) / 15; + + }, + + unpack: function( c ){ + + if (c.length == 7) return [ T.u255(c, 1), T.u255(c, 3), T.u255(c, 5) ]; + else if (c.length == 4) return [ T.u16(c,1), T.u16(c,2), T.u16(c,3) ]; + + }, + + p255: function ( c ) { + let h = Math.round( ( c * 255 ) ).toString( 16 ); + if ( h.length < 2 ) h = '0' + h; + return h; + }, + + pack: function ( c ) { + + return '#' + T.p255( c[ 0 ] ) + T.p255( c[ 1 ] ) + T.p255( c[ 2 ] ); + + }, + + htmlRgb: function( c ){ + + return 'rgb(' + Math.round(c[0] * 255) + ','+ Math.round(c[1] * 255) + ','+ Math.round(c[2] * 255) + ')'; + + }, + + pad: function( n ){ + if(n.length == 1)n = '0' + n; + return n; + }, + + rgbToHex : function( c ){ + + let r = Math.round(c[0] * 255).toString(16); + let g = Math.round(c[1] * 255).toString(16); + let b = Math.round(c[2] * 255).toString(16); + return '#' + T.pad(r) + T.pad(g) + T.pad(b); + + // return '#' + ( '000000' + ( ( c[0] * 255 ) << 16 ^ ( c[1] * 255 ) << 8 ^ ( c[2] * 255 ) << 0 ).toString( 16 ) ).slice( - 6 ); + + }, + + hueToRgb: function( p, q, t ){ + + if ( t < 0 ) t += 1; + if ( t > 1 ) t -= 1; + if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t; + if ( t < 1 / 2 ) return q; + if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t ); + return p; + + }, + + rgbToHsl: function ( c ) { + + let r = c[0], g = c[1], b = c[2], min = Math.min(r, g, b), max = Math.max(r, g, b), delta = max - min, h = 0, s = 0, l = (min + max) / 2; + if (l > 0 && l < 1) s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); + if (delta > 0) { + if (max == r && max != g) h += (g - b) / delta; + if (max == g && max != b) h += (2 + (b - r) / delta); + if (max == b && max != r) h += (4 + (r - g) / delta); + h /= 6; + } + return [ h, s, l ]; + + }, + + hslToRgb: function ( c ) { + + let p, q, h = c[0], s = c[1], l = c[2]; + + if ( s === 0 ) return [ l, l, l ]; + else { + q = l <= 0.5 ? l * (s + 1) : l + s - ( l * s ); + p = l * 2 - q; + return [ T.hueToRgb(p, q, h + 0.33333), T.hueToRgb(p, q, h), T.hueToRgb(p, q, h - 0.33333) ]; + } + + }, + + // ---------------------- + // SVG MODEL + // ---------------------- + + makeGradiant: function ( type, settings, parent, colors ) { + + T.dom( type, null, settings, parent, 0 ); + + let n = parent.childNodes[0].childNodes.length - 1, c; + + for( let i = 0; i < colors.length; i++ ){ + + c = colors[i]; + //T.dom( 'stop', null, { offset:c[0]+'%', style:'stop-color:'+c[1]+'; stop-opacity:'+c[2]+';' }, parent, [0,n] ); + T.dom( 'stop', null, { offset:c[0]+'%', 'stop-color':c[1], 'stop-opacity':c[2] }, parent, [0,n] ); + + } + + }, + + /*makeGraph: function () { + + let w = 128; + let radius = 34; + let svg = T.dom( 'svg', T.css.basic , { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'butt' }, svg );//0 + //T.dom( 'rect', '', { x:10, y:10, width:108, height:108, stroke:'rgba(0,0,0,0.3)', 'stroke-width':2 , fill:'none'}, svg );//1 + //T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0 + + //T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.3)', 'stroke-width':7 , fill:'none'}, svg );//2 + //T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3 + T.graph = svg; + + },*/ + + makePad: function ( model ) { + + let ww = 256; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+ww+' '+ww, width:ww, height:ww, preserveAspectRatio:'none' } ); + let w = 200; + let d = (ww-w)*0.5, m = 20; + Tools.dom( 'rect', '', { x: d, y: d, width: w, height: w, fill:T.colors.back }, svg ); // 0 + Tools.dom( 'rect', '', { x: d+m*0.5, y: d+m*0.5, width: w - m , height: w - m, fill:T.colors.button }, svg ); // 1 + // Pointer + Tools.dom( 'line', '', { x1: d+(m*0.5), y1: ww *0.5, x2: d+(w-m*0.5), y2: ww * 0.5, stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 2 + Tools.dom( 'line', '', { x1: ww * 0.5, x2: ww * 0.5, y1: d+(m*0.5), y2: d+(w-m*0.5), stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 3 + Tools.dom( 'circle', '', { cx: ww * 0.5, cy: ww * 0.5, r:5, stroke: T.colors.text, 'stroke-width': 5, fill:'none' }, svg ); // 4 + T.pad2d = svg; + + }, + + makeKnob: function ( model ) { + + let w = 128; + let radius = 34; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0 + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'round' }, svg );//1 + T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.1)', 'stroke-width':7 , fill:'none'}, svg );//2 + T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3 + T.knob = svg; + + }, + + makeCircular: function ( model ) { + + let w = 128; + let radius = 40; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'circle', '', { cx:64, cy:64, r:radius, stroke:'rgba(0,0,0,0.1)', 'stroke-width':10, fill:'none' }, svg );//0 + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':7, fill:'none', 'stroke-linecap':'butt' }, svg );//1 + T.circular = svg; + + }, + + makeJoystick: function ( model ) { + + //+' background:#f00;' + + let w = 128, ccc; + let radius = Math.floor((w-30)*0.5); + let innerRadius = Math.floor(radius*0.6); + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'defs', null, {}, svg ); + T.dom( 'g', null, {}, svg ); + + if( model === 0 ){ + + + + // gradian background + ccc = [ [40, 'rgb(0,0,0)', 0.3], [80, 'rgb(0,0,0)', 0], [90, 'rgb(50,50,50)', 0.4], [100, 'rgb(50,50,50)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'grad', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // gradian shadow + ccc = [ [60, 'rgb(0,0,0)', 0.5], [100, 'rgb(0,0,0)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'gradS', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // gradian stick + let cc0 = ['rgb(40,40,40)', 'rgb(48,48,48)', 'rgb(30,30,30)']; + let cc1 = ['rgb(1,90,197)', 'rgb(3,95,207)', 'rgb(0,65,167)']; + + ccc = [ [30, cc0[0], 1], [60, cc0[1], 1], [80, cc0[1], 1], [100, cc0[2], 1] ]; + T.makeGradiant( 'radialGradient', { id:'gradIn', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + ccc = [ [30, cc1[0], 1], [60, cc1[1], 1], [80, cc1[1], 1], [100, cc1[2], 1] ]; + T.makeGradiant( 'radialGradient', { id:'gradIn2', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // graph + + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'url(#grad)' }, svg );//2 + T.dom( 'circle', '', { cx:64+5, cy:64+10, r:innerRadius+10, fill:'url(#gradS)' }, svg );//3 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'url(#gradIn)' }, svg );//4 + + T.joystick_0 = svg; + + } else { + // gradian shadow + ccc = [ [69, 'rgb(0,0,0)', 0],[70, 'rgb(0,0,0)', 0.3], [100, 'rgb(0,0,0)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'gradX', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'none', stroke:'rgba(100,100,100,0.25)', 'stroke-width':'4' }, svg );//2 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius+14, fill:'url(#gradX)' }, svg );//3 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'none', stroke:'rgb(100,100,100)', 'stroke-width':'4' }, svg );//4 + + T.joystick_1 = svg; + } + + + + }, + + makeColorRing: function () { + + let w = 256; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'defs', null, {}, svg ); + T.dom( 'g', null, {}, svg ); + + let s = 30;//stroke + let r =( w-s )*0.5; + let mid = w*0.5; + let n = 24, nudge = 8 / r / n * Math.PI, a1 = 0; + let am, tan, d2, a2, ar, i, j, path, ccc; + let color = []; + + for ( i = 0; i <= n; ++i) { + + d2 = i / n; + a2 = d2 * T.TwoPI; + am = (a1 + a2) * 0.5; + tan = 1 / Math.cos((a2 - a1) * 0.5); + + ar = [ + Math.sin(a1), -Math.cos(a1), + Math.sin(am) * tan, -Math.cos(am) * tan, + Math.sin(a2), -Math.cos(a2) + ]; + + color[1] = T.rgbToHex( T.hslToRgb([d2, 1, 0.5]) ); + + if (i > 0) { + + j = 6; + while(j--){ + ar[j] = ((ar[j]*r)+mid).toFixed(2); + } + + path = ' M' + ar[0] + ' ' + ar[1] + ' Q' + ar[2] + ' ' + ar[3] + ' ' + ar[4] + ' ' + ar[5]; + + ccc = [ [0,color[0],1], [100,color[1],1] ]; + T.makeGradiant( 'linearGradient', { id:'G'+i, x1:ar[0], y1:ar[1], x2:ar[4], y2:ar[5], gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + T.dom( 'path', '', { d:path, 'stroke-width':s, stroke:'url(#G'+i+')', 'stroke-linecap':"butt" }, svg, 1 ); + + } + a1 = a2 - nudge; + color[0] = color[1]; + } + + let tw = 84.90; + + // black / white + ccc = [ [0, '#FFFFFF', 1], [50, '#FFFFFF', 0], [50, '#000000', 0], [100, '#000000', 1] ]; + T.makeGradiant( 'linearGradient', { id:'GL0', x1:0, y1:mid-tw, x2:0, y2:mid+tw, gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + ccc = [ [0, '#7f7f7f', 1], [50, '#7f7f7f', 0.5], [100, '#7f7f7f', 0] ]; + T.makeGradiant( 'linearGradient', { id:'GL1', x1:mid-49.05, y1:0, x2:mid+98, y2:0, gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + T.dom( 'g', null, { 'transform-origin': '128px 128px', 'transform':'rotate(0)' }, svg );//2 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'red' }, svg, 2 );// 2,0 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL1)','stroke-width':1, stroke:'url(#GL1)' }, svg, 2 );//2,1 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL0)','stroke-width':1, stroke:'url(#GL0)' }, svg, 2 );//2,2 + T.dom( 'path', '', { d:'M 255.75 136.5 Q 256 132.3 256 128 256 123.7 255.75 119.5 L 241 128 255.75 136.5 Z', fill:'none','stroke-width':2, stroke:'#000' }, svg, 2 );//2,3 + //T.dom( 'circle', '', { cx:128+113, cy:128, r:6, 'stroke-width':3, stroke:'#000', fill:'none' }, svg, 2 );//2.3 + + T.dom( 'circle', '', { cx:128, cy:128, r:6, 'stroke-width':2, stroke:'#000', fill:'none' }, svg );//3 + + T.colorRing = svg; + + }, + + icon: function ( type, color, w ){ + + w = w || 40; + //color = color || '#DEDEDE'; + let viewBox = '0 0 256 256'; + //let viewBox = '0 0 '+ w +' '+ w; + let t = [""]; + switch(type){ + case 'logo': + t[1]=""; + break; + case 'donate': + t[1]=""; + break; + case 'neo': + t[1]=""; + break; + case 'github': + t[1]=""; + break; + case 'save': + t[1]=""; + break; + } + t[2] = ""; + return t.join("\n"); + + }, + + logoFill_d:` + M 171 150.75 L 171 33.25 155.5 33.25 155.5 150.75 Q 155.5 162.2 147.45 170.2 139.45 178.25 128 178.25 116.6 178.25 108.55 170.2 100.5 162.2 100.5 150.75 + L 100.5 33.25 85 33.25 85 150.75 Q 85 168.65 97.55 181.15 110.15 193.75 128 193.75 145.9 193.75 158.4 181.15 171 168.65 171 150.75 + M 200 33.25 L 184 33.25 184 150.8 Q 184 174.1 167.6 190.4 151.3 206.8 128 206.8 104.75 206.8 88.3 190.4 72 174.1 72 150.8 L 72 33.25 56 33.25 56 150.75 + Q 56 180.55 77.05 201.6 98.2 222.75 128 222.75 157.8 222.75 178.9 201.6 200 180.55 200 150.75 L 200 33.25 Z + `, + + logo_github:` + M 180.5 70 Q 186.3 82.4 181.55 96.55 196.5 111.5 189.7 140.65 183.65 168.35 146 172.7 152.5 178.7 152.55 185.9 L 152.55 218.15 Q 152.84 224.56 159.15 223.3 + 159.21 223.3 159.25 223.3 181.14 216.25 198.7 198.7 228 169.4 228 128 228 86.6 198.7 57.3 169.4 28 128 28 86.6 28 57.3 57.3 28 86.6 28 128 28 169.4 57.3 198.7 74.85 + 216.25 96.75 223.3 96.78 223.3 96.8 223.3 103.16 224.54 103.45 218.15 L 103.45 200 Q 82.97 203.1 75.1 196.35 69.85 191.65 68.4 185.45 64.27 177.055 59.4 174.15 49.20 + 166.87 60.8 167.8 69.85 169.61 75.7 180 81.13 188.09 90 188.55 98.18 188.86 103.45 185.9 103.49 178.67 110 172.7 72.33 168.33 66.3 140.65 59.48 111.49 74.45 96.55 69.7 + 82.41 75.5 70 84.87 68.74 103.15 80 115.125 76.635 128 76.85 140.85 76.65 152.85 80 171.1 68.75 180.5 70 Z + `, + + logo_neo:` + M 219 52 L 206 52 206 166 Q 206 183.4 193.75 195.65 181.4 208 164 208 146.6 208 134.35 195.65 122 183.4 122 166 L 122 90 Q 122 77.6 113.15 68.85 104.4 60 92 60 79.55 + 60 70.75 68.85 62 77.6 62 90 L 62 204 75 204 75 90 Q 75 83 79.95 78 84.95 73 92 73 99 73 104 78 109 83 109 90 L 109 166 Q 109 188.8 125.15 204.85 141.2 221 164 221 + 186.75 221 202.95 204.85 219 188.8 219 166 L 219 52 M 194 52 L 181 52 181 166 Q 181 173 176.05 178 171.05 183 164 183 157 183 152 178 147 173 147 166 L 147 90 Q 147 + 67.2 130.85 51.15 114.8 35 92 35 69.25 35 53.05 51.15 37 67.2 37 90 L 37 204 50 204 50 90 Q 50 72.6 62.25 60.35 74.6 48 92 48 109.4 48 121.65 60.35 134 72.6 134 90 L + 134 166 Q 134 178.4 142.85 187.15 151.6 196 164 196 176.45 196 185.25 187.15 194 178.4 194 166 L 194 52 Z + `, + + logo_donate:` + M 171.3 80.3 Q 179.5 62.15 171.3 45.8 164.1 32.5 141.35 30.1 L 94.35 30.1 Q 89.35 30.4 88.3 35.15 L 70.5 148.05 Q 70.2 152.5 73.7 152.6 L 100.95 152.6 107 111.6 Q 108.75 + 106.55 112.6 106.45 130.45 108.05 145.3 103.9 163.35 98.75 171.3 80.3 M 179.8 71.5 Q 178.6 79.75 174.9 87.85 168.45 102.9 151.9 109.15 140.65 113.95 117.55 113 113.15 + 112.75 111 117.45 L 102.7 169.95 Q 102.45 173.8 105.5 173.85 L 128.95 173.85 Q 132.2 174.2 133.35 169.65 L 138.3 139.95 Q 139.75 135.6 143.1 135.5 146.6 135.75 150.6 135.65 + 154.55 135.5 157.35 135.1 160.15 134.7 166.75 132.35 181.35 127.4 187.9 111.2 194.25 95.75 189.5 81.95 186.75 74.85 179.8 71.5 M 103.5 209.9 Q 103.5 202.85 99.7 198.85 95.95 + 194.75 89.4 194.75 82.8 194.75 79.05 198.85 75.3 202.9 75.3 209.9 75.3 216.85 79.05 220.95 82.8 225.05 89.4 225.05 95.95 225.05 99.7 221 103.5 216.95 103.5 209.9 M 95.45 205.5 + Q 95.95 207.3 95.95 209.9 95.95 212.65 95.45 214.35 94.95 216 94 217.3 93.1 218.45 91.9 219 90.7 219.55 89.4 219.55 88.15 219.55 86.95 219.05 85.75 218.55 84.8 217.3 83.9 216.15 + 83.4 214.35 82.85 212.6 82.85 209.9 82.85 207.3 83.4 205.45 83.95 203.55 84.85 202.45 85.9 201.2 86.95 200.75 88.05 200.25 89.4 200.25 90.7 200.25 91.85 200.8 93.05 201.3 94 202.5 + 94.9 203.65 95.45 205.5 M 153.3 195.35 L 145.3 195.35 135.5 224.45 142.8 224.45 144.6 218.5 153.75 218.5 155.6 224.45 163.1 224.45 153.3 195.35 M 152.15 213.25 L 146.25 213.25 + 149.2 203.65 152.15 213.25 M 116.75 195.35 L 107.8 195.35 107.8 224.45 114.5 224.45 114.5 204.2 125.7 224.45 132.75 224.45 132.75 195.35 126.05 195.35 126.05 212.05 116.75 195.35 M + 66.5 197.65 Q 64.15 196.15 61.45 195.75 58.8 195.35 55.75 195.35 L 46.7 195.35 46.7 224.45 55.8 224.45 Q 58.8 224.45 61.5 224.05 64.15 223.6 66.4 222.15 69.15 220.45 70.9 217.2 + 72.7 214 72.7 209.95 72.7 205.7 71 202.6 69.35 199.5 66.5 197.65 M 64.2 205 Q 65.2 207 65.2 209.9 65.2 212.75 64.25 214.75 63.3 216.75 61.5 217.85 60 218.85 58.3 218.9 56.6 219 + 54.15 219 L 54 219 54 200.8 54.15 200.8 Q 56.4 200.8 58.05 200.9 59.7 200.95 61.15 201.75 63.2 202.95 64.2 205 M 210.2 195.35 L 190.5 195.35 190.5 224.45 210.2 224.45 210.2 218.9 + 197.75 218.9 197.75 211.55 209.2 211.55 209.2 206 197.75 206 197.75 200.9 210.2 200.9 210.2 195.35 M 187.5 195.35 L 163 195.35 163 200.9 171.6 200.9 171.6 224.45 178.9 224.45 178.9 + 200.9 187.5 200.9 187.5 195.35 Z + `, + +}; + +T.setText(); + +const Tools = T; + +class V2 { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + set ( x, y ) { + + this.x = x; + this.y = y; + return this; + + } + + divide ( v ) { + + this.x /= v.x; + this.y /= v.y; + return this; + + } + + multiply ( v ) { + + this.x *= v.x; + this.y *= v.y; + return this; + + } + + multiplyScalar ( scalar ) { + + this.x *= scalar; + this.y *= scalar; + return this; + + } + + divideScalar ( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + length () { + + return Math.sqrt( this.x * this.x + this.y * this.y ); + + } + + angle () { + + // computes the angle in radians with respect to the positive x-axis + + var angle = Math.atan2( this.y, this.x ); + + if ( angle < 0 ) angle += 2 * Math.PI; + + return angle; + + } + + addScalar ( s ) { + + this.x += s; + this.y += s; + return this; + + } + + negate () { + + this.x *= -1; + this.y *= -1; + return this; + + } + + neg () { + + this.x = -1; + this.y = -1; + return this; + + } + + isZero () { + + return ( this.x === 0 && this.y === 0 ); + + } + + copy ( v ) { + + this.x = v.x; + this.y = v.y; + + return this; + + } + + equals ( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) ); + + } + + nearEquals ( v, n ) { + + return ( ( v.x.toFixed(n) === this.x.toFixed(n) ) && ( v.y.toFixed(n) === this.y.toFixed(n) ) ); + + } + + lerp ( v, alpha ) { + + if( v === null ){ + this.x -= this.x * alpha; + this.y -= this.y * alpha; + } else { + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + } + + return this; + + } + +} + +/** + * @author lth / https://github.com/lo-th + */ + +class Proto { + + constructor( o = {} ) { + + + + // disable mouse controle + this.lock = o.lock || false; + + // for button + this.neverlock = false; + + // only simple space + this.isSpace = o.isSpace || false; + + // if is on gui or group + this.main = o.main || null; + this.isUI = o.isUI || false; + this.group = o.group || null; + + this.isListen = false; + + this.isSelectable = o.selectable !== undefined ? o.selectable : false; + this.unselectable = o.unselect !== undefined ? o.unselect : this.isSelectable; + + this.ontop = o.ontop ? o.ontop : false; // 'beforebegin' 'afterbegin' 'beforeend' 'afterend' + + this.css = this.main ? this.main.css : Tools.css; + + this.colors = Tools.defineColor( o, this.main ? ( this.group ? this.group.colors : this.main.colors ) : Tools.colors ); + + this.svgs = Tools.svgs; + + this.zone = { x:0, y:0, w:0, h:0 }; + this.local = new V2().neg(); + + this.isCanvasOnly = false; + this.isSelect = false; + + // percent of title + this.p = o.p !== undefined ? o.p : Tools.size.p; + + this.w = this.isUI ? this.main.size.w : Tools.size.w; + if( o.w !== undefined ) this.w = o.w; + + this.h = this.isUI ? this.main.size.h : Tools.size.h; + if( o.h !== undefined ) this.h = o.h; + if( !this.isSpace ) this.h = this.h < 11 ? 11 : this.h; + else this.lock = true; + + + // decale for canvas only + this.fw = o.fw || 0; + + this.autoWidth = o.auto || true;// auto width or flex + this.isOpen = false;// open statu + + // radius for toolbox + this.radius = o.radius || this.colors.radius; + + this.transition = o.transition || Tools.transition; + + // only for number + this.isNumber = false; + this.noNeg = o.noNeg || false; + this.allEqual = o.allEqual || false; + + // only most simple + this.mono = false; + + // stop listening for edit slide text + this.isEdit = false; + + // no title + this.simple = o.simple || false; + if( this.simple ) this.sa = 0; + + + // define obj size + this.setSize( this.w ); + + // title size + if( o.sa !== undefined ) this.sa = o.sa; + if( o.sb !== undefined ) this.sb = o.sb; + if( this.simple ) this.sb = this.w - this.sa; + + // last number size for slide + this.sc = o.sc === undefined ? 47 : o.sc; + + // for listening object + this.objectLink = null; + this.isSend = false; + this.val = null; + + this.txt = o.name || ''; + this.name = o.rename || this.txt; + this.target = o.target || null; + + // callback + this.callback = o.callback === undefined ? null : o.callback; + this.endCallback = null; + this.openCallback = o.openCallback === undefined ? null : o.openCallback; + this.closeCallback = o.closeCallback === undefined ? null : o.closeCallback; + + // if no callback take one from group or gui + if( this.callback === null && this.isUI && this.main.callback !== null ){ + this.callback = this.group ? this.group.callback : this.main.callback; + } + + // elements + this.c = []; + + // style + this.s = []; + + + this.useFlex = this.isUI ? this.main.useFlex : false; + let flexible = this.useFlex ? 'display:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;'; + + this.c[0] = Tools.dom( 'div', this.css.basic + flexible + 'position:relative; height:20px;'); + + + this.s[0] = this.c[0].style; + + // bottom margin + this.margin = o.margin || 1; + if( this.isUI && this.margin ){ + this.s[0].boxSizing = 'content-box'; + //this.s[0].marginBottom = this.margin + 'px'; + if( this.margin*0.5===Math.floor(this.margin*0.5) ){ + this.s[0].borderTop = (this.margin*0.5) + 'px solid transparent'; + this.s[0].borderBottom = (this.margin*0.5) + 'px solid transparent'; + } else { + this.s[0].borderBottom = this.margin + 'px solid transparent'; + } + + } + + // with title + if( !this.simple ){ + this.c[1] = Tools.dom( 'div', this.css.txt ); + this.s[1] = this.c[1].style; + this.c[1].textContent = this.name; + this.s[1].color = this.lock ? this.colors.titleoff : this.colors.title; + } + + if( o.pos ){ + this.s[0].position = 'absolute'; + for(let p in o.pos){ + this.s[0][p] = o.pos[p]; + } + this.mono = true; + } + + + + + if( o.css ) this.s[0].cssText = o.css; + + + } + + // ---------------------- + // make the node + // ---------------------- + + init() { + + this.zone.h = this.h; + this.zone.w = this.w; + + let s = this.s; // style cache + let c = this.c; // div cach + + s[0].height = this.h + 'px'; + + if( this.isUI ) s[0].background = this.colors.background; + + if(!this.autoWidth && this.useFlex ){ + s[0].flex = '1 0 auto'; + s[0].minWidth = this.minw+'px'; + s[0].textAlign = 'center'; + } else { + if( this.isUI ) s[0].width = '100%'; + } + + //if( this.autoHeight ) s[0].transition = 'height 0.01s ease-out'; + if( c[1] !== undefined && this.autoWidth ){ + s[1] = c[1].style; + s[1].height = (this.h-4) + 'px'; + s[1].lineHeight = (this.h-8) + 'px'; + } + + let frag = Tools.frag; + + for( let i = 1, lng = c.length; i !== lng; i++ ){ + if( c[i] !== undefined ) { + frag.appendChild( c[i] ); + s[i] = c[i].style; + } + } + + let pp = this.target !== null ? this.target : ( this.isUI ? this.main.inner : document.body ); + + if( this.ontop ) pp.insertAdjacentElement( 'afterbegin', c[0] ); + else pp.appendChild( c[0] ); + + c[0].appendChild( frag ); + + this.rSize(); + + // ! solo proto + if( !this.isUI ){ + + this.c[0].style.pointerEvents = 'auto'; + Roots.add( this ); + + } + + + if( this.baseH && this.transition && this.isUI ){ + this.c[0].style.transition = 'height '+this.transition+'s ease-out'; + } + + } + + // from Tools + + dom( type, css, obj, dom, id ) { + + return Tools.dom( type, css, obj, dom, id ); + + } + + setSvg( dom, type, value, id, id2 ) { + + Tools.setSvg( dom, type, value, id, id2 ); + + } + + setCss( dom, css ) { + + Tools.setCss( dom, css ); + + } + + clamp( value, min, max ) { + + return Tools.clamp( value, min, max ); + + } + + getColorRing() { + + if( !Tools.colorRing ) Tools.makeColorRing(); + return Tools.clone( Tools.colorRing ); + + } + + getJoystick( model ) { + + if( !Tools[ 'joystick_'+ model ] ) Tools.makeJoystick( model ); + return Tools.clone( Tools[ 'joystick_'+ model ] ) + + } + + getCircular( model ) { + + if( !Tools.circular ) Tools.makeCircular( model ); + return Tools.clone( Tools.circular ) + + } + + getKnob( model ) { + + if( !Tools.knob ) Tools.makeKnob( model ); + return Tools.clone( Tools.knob ) + + } + + getPad2d( model ) { + + if( !Tools.pad2d ) Tools.makePad( model ); + return Tools.clone( Tools.pad2d ) + + } + + // from Roots + + cursor( name ) { + + Roots.cursor( name ); + + } + + + + ///////// + + update() {} + + reset() {} + + ///////// + + getDom() { + + return this.c[0] + + } + + uiout() { + + if( this.lock ) return; + + if(this.s) this.s[0].background = this.colors.background; + + } + + uiover() { + + if( this.lock ) return; + + if(this.s) this.s[0].background = this.colors.backgroundOver; + + } + + rename( s ) { + + if( this.c[1] !== undefined) this.c[1].textContent = s; + + } + + listen() { + + this.isListen = Roots.addListen( this ); + return this; + + } + + listening() { + + if( this.objectLink === null ) return; + if( this.isSend ) return; + if( this.isEdit ) return; + + this.setValue( this.objectLink[ this.val ] ); + + } + + setValue( v ) { + + if( this.isNumber ) this.value = this.numValue( v ); + //else if( v instanceof Array && v.length === 1 ) v = v[0]; + else this.value = v; + this.update(); + + } + + // ---------------------- + // update every change + // ---------------------- + + onChange( f ) { + + if( this.isSpace ) return + this.callback = f || null; + return this + + } + + // ---------------------- + // update only on end + // ---------------------- + + onFinishChange( f ) { + + if( this.isSpace ) return; + this.callback = null; + this.endCallback = f; + return this + + } + + // ---------------------- + // event on open close + // ---------------------- + + onOpen( f ) { + + this.openCallback = f; + return this + + } + + onClose( f ) { + + this.closeCallback = f; + return this + + } + + // ---------------------- + // send back value + // ---------------------- + + send( v ) { + + v = v || this.value; + if( v instanceof Array && v.length === 1 ) v = v[0]; + + this.isSend = true; + if( this.objectLink !== null ) this.objectLink[ this.val ] = v; + if( this.callback ) this.callback( v, this.val ); + this.isSend = false; + + } + + sendEnd( v ) { + + v = v || this.value; + if( v instanceof Array && v.length === 1 ) v = v[0]; + + if( this.endCallback ) this.endCallback( v ); + if( this.objectLink !== null ) this.objectLink[ this.val ] = v; + + } + + // ---------------------- + // clear node + // ---------------------- + + dispose(){ + + if( this.isListen ) Roots.removeListen( this ); + + Tools.clear( this.c[0] ); + + if( this.target !== null ){ + + if( this.group !== null ) this.group.clearOne( this ); + else this.target.removeChild( this.c[0] ); + + } else { + + if( this.isUI ) this.main.clearOne( this ); + else document.body.removeChild( this.c[0] ); + + } + + if( !this.isUI ) Roots.remove( this ); + + this.c = null; + this.s = null; + this.callback = null; + this.target = null; + this.isListen = false; + + } + + clear() { + + } + + // ---------------------- + // change size + // ---------------------- + + getWidth() { + + let nw = Roots.getWidth( this ); + if(nw) this.w = nw; + + } + + setSize( sx ) { + + if( !this.autoWidth ) return; + + this.w = sx; + + if( this.simple ){ + this.sb = this.w - this.sa; + } else { + let pp = this.w * ( this.p / 100 ); + this.sa = Math.floor( pp + 10 ); + this.sb = Math.floor( this.w - pp - 20 ); + } + + } + + rSize() { + + if( !this.autoWidth ) return; + + if( !this.isUI ) this.s[0].width = this.w + 'px'; + if( !this.simple ) this.s[1].width = this.sa + 'px'; + + } + + // ---------------------- + // for numeric value + // ---------------------- + + setTypeNumber( o ) { + + this.isNumber = true; + + this.value = 0; + if( o.value !== undefined ){ + if( typeof o.value === 'string' ) this.value = o.value * 1; + else this.value = o.value; + } + + this.min = o.min === undefined ? -Infinity : o.min; + this.max = o.max === undefined ? Infinity : o.max; + this.precision = o.precision === undefined ? 2 : o.precision; + + let s; + + switch(this.precision){ + case 0: s = 1; break; + case 1: s = 0.1; break; + case 2: s = 0.01; break; + case 3: s = 0.001; break; + case 4: s = 0.0001; break; + case 5: s = 0.00001; break; + } + + this.step = o.step === undefined ? s : o.step; + this.range = this.max - this.min; + this.value = this.numValue( this.value ); + + } + + numValue( n ) { + + if( this.noNeg ) n = Math.abs( n ); + return Math.min( this.max, Math.max( this.min, n ) ).toFixed( this.precision ) * 1; + + } + + + // ---------------------- + // EVENTS DEFAULT + // ---------------------- + + handleEvent( e ) { + + if( this.lock ) return + + if( this.neverlock ) Roots.lock = false; + + if( !this[e.type] ) return console.error(e.type, 'this type of event no existe !') + + return this[e.type](e) + + } + + wheel( e ) { return false; } + mousedown( e ) { return false; } + mousemove( e ) { return false; } + mouseup( e ) { return false; } + keydown( e ) { return false; } + keyup( e ) { return false; } + + + // ---------------------- + // object referency + // ---------------------- + + setReferency( obj, val ) { + + this.objectLink = obj; + this.val = val; + + } + + display( v = false ) { + this.s[0].visibility = v ? 'visible' : 'hidden'; + } + + // ---------------------- + // resize height + // ---------------------- + + open () { + + if( this.isOpen ) return; + this.isOpen = true; + if( this.openCallback ) this.openCallback(); + + } + + close () { + + if( !this.isOpen ) return + this.isOpen = false; + if( this.closeCallback ) this.closeCallback(); + + } + + needZone() { + + Roots.needReZone = true; + + } + + rezone() { + + Roots.needReZone = true; + + } + + // ---------------------- + // INPUT + // ---------------------- + + select() { + + } + + unselect() { + + } + + setInput( Input ) { + + Roots.setInput( Input, this ); + + } + + upInput( x, down ) { + + return Roots.upInput( x, down ); + + } + + // ---------------------- + // special item + // ---------------------- + + selected( b ){ + + this.isSelect = b || false; + + } + +} + +class Bool extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || false; + this.model = o.mode !== undefined ? o.mode : 0; + + this.onName = o.rename || this.txt; + if( o.onName ) o.onname = o.onName; + if( o.onname ) this.onName = o.onname; + + this.inh = o.inh || Math.floor( this.h*0.8 ); + this.inw = o.inw || 36; + + let cc = this.colors; + + if( this.model === 0 ){ + let t = Math.floor(this.h*0.5)-((this.inh-2)*0.5); + this.c[2] = this.dom( 'div', this.css.basic + 'background:'+ cc.inputBg +'; height:'+(this.inh-2)+'px; width:'+this.inw+'px; top:'+t+'px; border-radius:10px; border:2px solid '+ cc.back ); + this.c[3] = this.dom( 'div', this.css.basic + 'height:'+(this.inh-6)+'px; width:16px; top:'+(t+2)+'px; border-radius:10px; background:'+ cc.button+';' ); + } else { + this.p = 0; + if( this.c[1] !== undefined ) this.c[1].textContent = ''; + this.c[2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; background:'+cc.button+'; height:'+(this.h-2)+'px; border:1px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + } + + this.stat = -1; + + this.init(); + this.update(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousedown ( e ) { + + this.value = !this.value; + this.update( true ); + return this.mousemove( e ) + + } + + mousemove ( e ) { + + this.cursor('pointer'); + return this.mode( true ) + + } + + reset () { + + this.cursor(); + return this.mode() + + } + + // ---------------------- + // MODE + // ---------------------- + + mode ( over ) { + + let change = false; + let cc = this.colors, s, s2, n, v = this.value; + + if( over ) n = v ? 4 : 3; + else n = v ? 2 : 1; + + if( this.stat !== n ){ + + this.stat = n; + + if( this.model !== 0 ){ + + s = this.s[2]; + + switch( n ){ + + case 1: s.color = cc.text; s.background = cc.button; break; + case 2: s.color = cc.textSelect; s.background = cc.select; break; + case 3: s.color = cc.textOver; s.background = cc.overoff; break; + case 4: s.color = cc.textOver; s.background = cc.over; break; + + } + + this.c[2].innerHTML = v ? this.onName : this.name; + + } else { + + s = this.s[2]; + s2 = this.s[3]; + + switch( n ){ + + case 1: s.background = s.borderColor = cc.back; s2.background = cc.button; break; + case 2: s.background = s.borderColor = cc.select; s2.background = cc.button; break; + case 3: s.background = s.borderColor = cc.back; s2.background = cc.overoff; break; + case 4: s.background = s.borderColor = cc.select; s2.background = cc.over; break; + + } + + this.s[3].marginLeft = v ? '17px' : '2px'; + this.c[1].textContent = v ? this.onName : this.name; + + } + + change = true; + + } + + return change + + } + + // ---------------------- + + update ( up ) { + + this.mode(); + if( up ) this.send(); + + } + + rSize () { + + super.rSize(); + + let s = this.s; + let w = (this.w - 10 ) - this.inw; + if( this.model === 0 ){ + s[2].left = w + 'px'; + s[3].left = w + 'px'; + } else { + s[2].left = this.sa + 'px'; + s[2].width = (this.w- 20) + 'px'; + } + + } + +} + +class Button extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || ''; + + this.values = o.value || this.txt; + if( o.values ) this.values = o.values; + + + + this.onName = o.onName || null; + + this.on = false; + + // force button width + this.bw = o.forceWidth || 0; + if(o.bw) this.bw = o.bw; + this.space = o.space || 3; + + if( typeof this.values === 'string' ) this.values = [ this.values ]; + + this.isDown = false; + this.neverlock = true; + this.res = 0; + + this.lng = this.values.length; + this.tmp = []; + this.stat = []; + + let sel, cc = this.colors; + + for( let i = 0; i < this.lng; i++ ){ + + sel = false; + if( this.values[i] === this.value && this.isSelectable ) sel = true; + + this.c[i+2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; height:'+(this.h-2)+'px; border:'+cc.borderSize+'px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[i+2].style.background = sel ? cc.select : cc.button; + this.c[i+2].style.color = sel ? cc.textSelect : cc.text; + this.c[i+2].innerHTML = this.values[i]; + this.stat[i] = sel ? 3:1; + + } + + if( !o.value && !o.values ){ + if( this.c[1] !== undefined ) { + this.c[1].textContent = ''; + this.txt = ''; + } + } + if( !this.txt ) this.p = 0; + + this.init(); + + } + + onOff() { + + this.on = !this.on; + this.label( this.on ? this.onName : this.txt ); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return -1 + + let i = this.lng; + let t = this.tmp; + + while( i-- ){ + if( l.x>t[i][0] && l.x 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.text; + this.setSvg( this.c[3], 'stroke', color, 1 ); + + break; + case 1: // down + + this.s[2].color = cc.textOver; + this.setSvg( this.c[3], 'stroke', cc.backoff, 0); + color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.textOver; + this.setSvg( this.c[3], 'stroke', color, 1 ); + + break; + } + + this.cmode = mode; + return true; + + } + + reset () { + + this.isDown = false; + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'circular'; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.sendEnd(); + return this.mode(0); + + } + + mousedown ( e ) { + + this.isDown = true; + this.old = this.value; + this.oldr = null; + this.mousemove( e ); + return this.mode(1); + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + //console.log('over') + + let off = this.offset; + off.x = (this.w*0.5) - ( e.clientX - this.zone.x ); + off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + + this.r = off.angle() - this.pi90; + this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi); + + if( this.oldr !== null ){ + + let dif = this.r - this.oldr; + this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r; + + if( dif > 6 ) this.r = 0; + if( dif < -6 ) this.r = this.twoPi; + + } + + let steps = 1 / this.twoPi; + let value = this.r * steps; + + let n = ( ( this.range * value ) + this.min ) - this.old; + + if(n >= this.step || n <= this.step){ + n = ~~ ( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + this.oldr = this.r; + } + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'circular' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue( v ); + this.old = v; + this.update( true ); + + return true; + + } + return false; + + } + + // ---------------------- + + makePath () { + + let r = 40; + let d = 24; + let a = this.percent * this.twoPi - 0.001; + let x2 = (r + r * Math.sin(a)) + d; + let y2 = (r - r * Math.cos(a)) + d; + let big = a > Math.PI ? 1 : 0; + return "M " + (r+d) + "," + d + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2; + + } + + update ( up ) { + + this.c[2].textContent = this.value; + this.percent = ( this.value - this.min ) / this.range; + + this.setSvg( this.c[3], 'd', this.makePath(), 1 ); + + if ( this.model > 0 ) { + + let cc = this.colors; + let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ); + this.setSvg( this.c[3], 'stroke', color, 1 ); + + } + + if( up ) this.send(); + + } + +} + +class Color extends Proto { + + constructor( o = {} ) { + + super( o ); + + //this.autoHeight = true; + + this.ctype = o.ctype || 'hex'; + + this.wfixe = 256; + + this.cw = this.sb > 256 ? 256 : this.sb; + if(o.cw != undefined ) this.cw = o.cw; + + // color up or down + this.side = o.side || 'down'; + this.up = this.side === 'down' ? 0 : 1; + + this.baseH = this.h; + + this.offset = new V2(); + this.decal = new V2(); + this.pp = new V2(); + + this.c[2] = this.dom( 'div', this.css.txt + 'height:'+(this.h-4)+'px;' + 'border-radius:'+this.radius+'px; line-height:'+(this.h-8)+'px;' ); + this.s[2] = this.c[2].style; + + this.s[2].textShadow = 'none'; + + if( this.up ){ + this.s[2].top = 'auto'; + this.s[2].bottom = '2px'; + } + + //this.c[0].style.textAlign = 'center'; + //this.c[0].style.flex = '1 0 auto' + + this.c[3] = this.getColorRing(); + this.c[3].style.visibility = 'hidden'; + + this.hsl = null; + this.value = '#ffffff'; + if( o.value !== undefined ){ + if( o.value instanceof Array ) this.value = Tools.rgbToHex( o.value ); + else if(!isNaN(o.value)) this.value = Tools.hexToHtml( o.value ); + else this.value = o.value; + } + + this.bcolor = null; + this.isDown = false; + this.fistDown = false; + + this.notext = o.notext || false; + + this.tr = 98; + this.tsl = Math.sqrt(3) * this.tr; + + this.hue = 0; + this.d = 256; + + this.setColor( this.value ); + + this.init(); + + if( o.open !== undefined ) this.open(); + + } + + testZone ( mx, my ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + + + if( this.up && this.isOpen ){ + + if( l.y > this.wfixe ) return 'title'; + else return 'color'; + + } else { + + if( l.y < this.baseH+2 ) return 'title'; + else if( this.isOpen ) return 'color'; + + + } + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.d = 256; + + } + + mousedown ( e ) { + + + let name = this.testZone( e.clientX, e.clientY ); + + + //if( !name ) return; + if(name === 'title'){ + if( !this.isOpen ) this.open(); + else this.close(); + return true; + } + + + if( name === 'color' ){ + + this.isDown = true; + this.fistDown = true; + this.mousemove( e ); + } + } + + mousemove ( e ) { + + let name = this.testZone( e.clientX, e.clientY ); + + let off, d, hue, sat, lum, rad, x, y, rr, T = Tools; + + if( name === 'title' ) this.cursor('pointer'); + + if( name === 'color' ){ + + off = this.offset; + off.x = e.clientX - ( this.zone.x + this.decal.x + this.mid ); + off.y = e.clientY - ( this.zone.y + this.decal.y + this.mid ); + d = off.length() * this.ratio; + rr = off.angle(); + if(rr < 0) rr += 2 * T.PI; + + + if ( d < 128 ) this.cursor('crosshair'); + else if( !this.isDown ) this.cursor(); + + if( this.isDown ){ + + if( this.fistDown ){ + this.d = d; + this.fistDown = false; + } + + if ( this.d < 128 ) { + + if ( this.d > this.tr ) { // outside hue + + hue = ( rr + T.pi90 ) / T.TwoPI; + this.hue = (hue + 1) % 1; + this.setHSL([(hue + 1) % 1, this.hsl[1], this.hsl[2]]); + + } else { // triangle + + x = off.x * this.ratio; + y = off.y * this.ratio; + + let rr = (this.hue * T.TwoPI) + T.PI; + if(rr < 0) rr += 2 * T.PI; + + rad = Math.atan2(-y, x); + if(rad < 0) rad += 2 * T.PI; + + let rad0 = ( rad + T.pi90 + T.TwoPI + rr ) % (T.TwoPI), + rad1 = rad0 % ((2/3) * T.PI) - (T.pi60), + a = 0.5 * this.tr, + b = Math.tan(rad1) * a, + r = Math.sqrt(x*x + y*y), + maxR = Math.sqrt(a*a + b*b); + + if( r > maxR ) { + let dx = Math.tan(rad1) * r; + let rad2 = Math.atan(dx / maxR); + if(rad2 > T.pi60) rad2 = T.pi60; + else if( rad2 < -T.pi60 ) rad2 = -T.pi60; + + rad += rad2 - rad1; + + rad0 = (rad + T.pi90 + T.TwoPI + rr) % (T.TwoPI), + rad1 = rad0 % ((2/3) * T.PI) - (T.pi60); + b = Math.tan(rad1) * a; + r = maxR = Math.sqrt(a*a + b*b); + } + + lum = ((Math.sin(rad0) * r) / this.tsl) + 0.5; + + let w = 1 - (Math.abs(lum - 0.5) * 2); + sat = (((Math.cos(rad0) * r) + (this.tr / 2)) / (1.5 * this.tr)) / w; + sat = T.clamp( sat, 0, 1 ); + + this.setHSL([this.hsl[0], sat, lum]); + + } + } + } + } + + } + + // ---------------------- + + setHeight () { + + this.h = this.isOpen ? this.wfixe + this.baseH + 5 : this.baseH; + this.s[0].height = this.h + 'px'; + this.zone.h = this.h; + + } + + parentHeight ( t ) { + + if ( this.group !== null ) this.group.calc( t ); + else if ( this.isUI ) this.main.calc( t ); + + } + + open () { + + super.open(); + + this.setHeight(); + + if( this.up ) this.zone.y -= this.wfixe + 5; + + let t = this.h - this.baseH; + + this.s[3].visibility = 'visible'; + //this.s[3].display = 'block'; + this.parentHeight( t ); + + } + + close () { + + super.close(); + + if( this.up ) this.zone.y += this.wfixe + 5; + + let t = this.h - this.baseH; + + this.setHeight(); + + this.s[3].visibility = 'hidden'; + //this.s[3].display = 'none'; + this.parentHeight( -t ); + + } + + update ( up ) { + + let cc = Tools.rgbToHex( Tools.hslToRgb([ this.hsl[0], 1, 0.5 ]) ); + + this.moveMarkers(); + + this.value = this.bcolor; + + this.setSvg( this.c[3], 'fill', cc, 2, 0 ); + + + this.s[2].background = this.bcolor; + if(!this.notext) this.c[2].textContent = Tools.htmlToHex( this.bcolor ); + + this.invert = Tools.findDeepInver( this.rgb ); + this.s[2].color = this.invert ? '#fff' : '#000'; + + if(!up) return; + + if( this.ctype === 'array' ) this.send( this.rgb ); + if( this.ctype === 'rgb' ) this.send( Tools.htmlRgb( this.rgb ) ); + if( this.ctype === 'hex' ) this.send( Tools.htmlToHex( this.value ) ); + if( this.ctype === 'html' ) this.send(); + + } + + setValue ( v ){ + + if( v instanceof Array ) this.value = Tools.rgbToHex( v ); + else if(!isNaN(v)) this.value = Tools.hexToHtml( v ); + else this.value = v; + + this.setColor( this.value ); + this.update(); + + } + + setColor ( color ) { + + let unpack = Tools.unpack(color); + if (this.bcolor !== color && unpack) { + + this.bcolor = color; + this.rgb = unpack; + this.hsl = Tools.rgbToHsl( this.rgb ); + + this.hue = this.hsl[0]; + + this.update(); + } + return this; + + } + + setHSL ( hsl ) { + + this.hsl = hsl; + this.rgb = Tools.hslToRgb( hsl ); + this.bcolor = Tools.rgbToHex( this.rgb ); + this.update( true ); + return this; + + } + + moveMarkers () { + + let p = this.pp; + let T = Tools; + + this.invert ? '#fff' : '#000'; + let a = this.hsl[0] * T.TwoPI; + let third = (2/3) * T.PI; + let r = this.tr; + let h = this.hsl[0]; + let s = this.hsl[1]; + let l = this.hsl[2]; + + let angle = ( a - T.pi90 ) * T.todeg; + + h = - a + T.pi90; + + let hx = Math.cos(h) * r; + let hy = -Math.sin(h) * r; + let sx = Math.cos(h - third) * r; + let sy = -Math.sin(h - third) * r; + let vx = Math.cos(h + third) * r; + let vy = -Math.sin(h + third) * r; + let mx = (sx + vx) / 2, my = (sy + vy) / 2; + a = (1 - 2 * Math.abs(l - .5)) * s; + let x = sx + (vx - sx) * l + (hx - mx) * a; + let y = sy + (vy - sy) * l + (hy - my) * a; + + p.set( x, y ).addScalar(128); + + //let ff = (1-l)*255; + // this.setSvg( this.c[3], 'stroke', 'rgb('+ff+','+ff+','+ff+')', 3 ); + + this.setSvg( this.c[3], 'transform', 'rotate('+angle+' )', 2 ); + + this.setSvg( this.c[3], 'cx', p.x, 3 ); + this.setSvg( this.c[3], 'cy', p.y, 3 ); + + this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 2, 3 ); + this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 3 ); + this.setSvg( this.c[3], 'fill',this.bcolor, 3 ); + + } + + rSize () { + + //Proto.prototype.rSize.call( this ); + super.rSize(); + + let s = this.s; + + s[2].width = this.sb + 'px'; + s[2].left = this.sa + 'px'; + + this.rSizeColor( this.cw ); + + this.decal.x = Math.floor((this.w - this.wfixe) * 0.5); + //s[3].left = this.decal.x + 'px'; + + } + + rSizeColor ( w ) { + + if( w === this.wfixe ) return; + + this.wfixe = w; + + let s = this.s; + + //this.decal.x = Math.floor((this.w - this.wfixe) * 0.5); + this.decal.y = this.side === 'up' ? 2 : this.baseH + 2; + this.mid = Math.floor( this.wfixe * 0.5 ); + + this.setSvg( this.c[3], 'viewBox', '0 0 '+ this.wfixe + ' '+ this.wfixe ); + s[3].width = this.wfixe + 'px'; + s[3].height = this.wfixe + 'px'; + //s[3].left = this.decal.x + 'px'; + s[3].top = this.decal.y + 'px'; + + this.ratio = 256 / this.wfixe; + this.square = 1 / (60*(this.wfixe/256)); + this.setHeight(); + + } + + +} + +class Fps extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.round = Math.round; + + //this.autoHeight = true; + + this.baseH = this.h; + this.hplus = o.hplus || 50; + + this.res = o.res || 40; + this.l = 1; + + this.precision = o.precision || 0; + + + this.custom = o.custom || false; + this.names = o.names || ['FPS', 'MS']; + let cc = o.cc || ['220,220,220', '255,255,0']; + + // this.divid = [ 100, 100, 100 ]; + // this.multy = [ 30, 30, 30 ]; + + this.adding = o.adding || false; + + this.range = o.range || [ 165, 100, 100 ]; + + this.alpha = o.alpha || 0.25; + + this.values = []; + this.points = []; + this.textDisplay = []; + + if(!this.custom){ + + this.now = Roots.getTime(); + this.startTime = 0;//this.now() + this.prevTime = 0;//this.startTime; + this.frames = 0; + + this.ms = 0; + this.fps = 0; + this.mem = 0; + this.mm = 0; + + this.isMem = ( self.performance && self.performance.memory ) ? true : false; + + // this.divid = [ 100, 200, 1 ]; + // this.multy = [ 30, 30, 30 ]; + + if( this.isMem ){ + + this.names.push('MEM'); + cc.push('0,255,255'); + + } + + this.txt = o.name || 'Fps'; + + } + + + let fltop = Math.floor(this.h*0.5)-6; + + this.c[1].textContent = this.txt; + this.c[0].style.cursor = 'pointer'; + this.c[0].style.pointerEvents = 'auto'; + + let panelCss = 'display:none; left:10px; top:'+ this.h + 'px; height:'+(this.hplus - 8)+'px; box-sizing:border-box; background: rgba(0, 0, 0, 0.2); border:1px solid '+ this.colors.border +';'; + + if( this.radius !== 0 ) panelCss += 'border-radius:' + this.radius+'px;'; + + this.c[2] = this.dom( 'path', this.css.basic + panelCss , {} ); + + this.c[2].setAttribute('viewBox', '0 0 '+this.res+' 50' ); + this.c[2].setAttribute('height', '100%' ); + this.c[2].setAttribute('width', '100%' ); + this.c[2].setAttribute('preserveAspectRatio', 'none' ); + + + //this.dom( 'path', null, { fill:'rgba(255,255,0,0.3)', 'stroke-width':1, stroke:'#FF0', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + //this.dom( 'path', null, { fill:'rgba(0,255,255,0.3)', 'stroke-width':1, stroke:'#0FF', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + + // arrow + this.c[3] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; left:4px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:this.colors.text, stroke:'none'}); + + // result test + this.c[4] = this.dom( 'div', this.css.txt + 'position:absolute; left:10px; top:'+(this.h+2) +'px; display:none; width:100%; text-align:center;' ); + + // bottom line + if( o.bottomLine ) this.c[4] = this.dom( 'div', this.css.basic + 'width:100%; bottom:0px; height:1px; background: rgba(255, 255, 255, 0.2);'); + + this.isShow = false; + + let s = this.s; + + s[1].marginLeft = '10px'; + s[1].lineHeight = this.h-4; + s[1].color = this.colors.text; + s[1].fontWeight = 'bold'; + + if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px'; + if( this.colors.gborder!=='none') s[0].border = '1px solid ' + this.colors.gborder; + + + + + let j = 0; + + for( j=0; j " + this.names[j] +" "); + + } + + j = this.names.length; + while(j--){ + this.dom( 'path', null, { fill:'rgba('+cc[j]+','+this.alpha+')', 'stroke-width':1, stroke:'rgba('+cc[j]+',1)', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + } + + + this.init(); + + //if( this.isShow ) this.show(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousedown ( e ) { + + if( this.isShow ) this.close(); + else this.open(); + + } + + // ---------------------- + + /*mode: function ( mode ) { + + let s = this.s; + + switch(mode){ + case 0: // base + s[1].color = this.colors.text; + //s[1].background = 'none'; + break; + case 1: // over + s[1].color = '#FFF'; + //s[1].background = UIL.SELECT; + break; + case 2: // edit / down + s[1].color = this.colors.text; + //s[1].background = UIL.SELECTDOWN; + break; + + } + },*/ + + tick ( v ) { + + this.values = v; + if( !this.isShow ) return; + this.drawGraph(); + this.upText(); + + } + + makePath ( point ) { + + let p = ''; + p += 'M ' + (-1) + ' ' + 50; + for ( let i = 0; i < this.res + 1; i ++ ) { p += ' L ' + i + ' ' + point[i]; } + p += ' L ' + (this.res + 1) + ' ' + 50; + return p; + + } + + upText ( val ) { + + let v = val || this.values, t = ''; + for( let j=0, lng =this.names.length; j'; + this.c[4].innerHTML = t; + + } + + drawGraph () { + + let svg = this.c[2]; + let i = this.names.length, v, old = 0, n = 0; + + while( i-- ){ + if( this.adding ) v = (this.values[n]+old) * this.range[n]; + else v = (this.values[n] * this.range[n]); + this.points[n].shift(); + this.points[n].push( 50 - v ); + this.setSvg( svg, 'd', this.makePath( this.points[n] ), i+1 ); + old += this.values[n]; + n++; + + } + + } + + open () { + + super.open(); + + this.h = this.hplus + this.baseH; + + this.setSvg( this.c[3], 'd', this.svgs.arrowDown ); + + if( this.group !== null ){ this.group.calc( this.hplus );} + else if( this.isUI ) this.main.calc( this.hplus ); + + this.s[0].height = this.h +'px'; + this.s[2].display = 'block'; + this.s[4].display = 'block'; + this.isShow = true; + + if( !this.custom ) Roots.addListen( this ); + + } + + close () { + + super.close(); + + this.h = this.baseH; + + this.setSvg( this.c[3], 'd', this.svgs.arrow ); + + if( this.group !== null ){ this.group.calc( -this.hplus );} + else if( this.isUI ) this.main.calc( -this.hplus ); + + this.s[0].height = this.h +'px'; + this.s[2].display = 'none'; + this.s[4].display = 'none'; + this.isShow = false; + + if( !this.custom ) Roots.removeListen( this ); + + this.c[4].innerHTML = ''; + + } + + + ///// AUTO FPS ////// + + begin () { + + this.startTime = this.now(); + + } + + end () { + + let time = this.now(); + this.ms = time - this.startTime; + + this.frames ++; + + if ( time > this.prevTime + 1000 ) { + + this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) ); + + this.prevTime = time; + this.frames = 0; + + if ( this.isMem ) { + + let heapSize = performance.memory.usedJSHeapSize; + let heapSizeLimit = performance.memory.jsHeapSizeLimit; + + this.mem = this.round( heapSize * 0.000000954 ); + this.mm = heapSize / heapSizeLimit; + + } + + } + + this.values = [ this.fps, this.ms , this.mm ]; + + this.drawGraph(); + this.upText( [ this.fps, this.ms, this.mem ] ); + + return time; + + } + + listening () { + + if( !this.custom ) this.startTime = this.end(); + + } + + rSize () { + + let s = this.s; + let w = this.w; + + s[0].width = w + 'px'; + s[1].width = w + 'px'; + s[2].left = 10 + 'px'; + s[2].width = (w-20) + 'px'; + s[4].width = (w-20) + 'px'; + + } + +} + +class Graph extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value !== undefined ? o.value : [0,0,0]; + this.lng = this.value.length; + + this.precision = o.precision !== undefined ? o.precision : 2; + this.multiplicator = o.multiplicator || 1; + this.neg = o.neg || false; + + this.line = o.line !== undefined ? o.line : true; + + //if(this.neg)this.multiplicator*=2; + + this.autoWidth = o.autoWidth !== undefined ? o.autoWidth : true; + this.isNumber = false; + + this.isDown = false; + + this.h = o.h || 128 + 10; + this.rh = this.h - 10; + this.top = 0; + + this.c[0].style.width = this.w +'px'; + + if( this.c[1] !== undefined ) { // with title + + this.c[1].style.width = this.w +'px'; + + if(!this.autoWidth){ + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + } + + + //this.c[1].style.background = '#ff0000'; + //this.c[1].style.textAlign = 'center'; + this.top = 10; + this.h += 10; + + } + + this.gh = this.rh - 28; + this.gw = this.w - 28; + + //this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; text-align: justify; column-count:'+this.lng+'; top:'+(this.h-20)+'px; width:100%; color:'+ this.colors.text ); + + //let colum = 'column-count:'+this.lng+'; column:'+this.lng+'; break-inside: column; top:' + this.c[2] = this.dom( 'div', this.css.txt + 'display:block; text-align:center; padding:0px 0px; top:'+(this.h-20)+'px; left:14px; width:'+this.gw+'px; color:'+ this.colors.text ); + + //this.c[2].textContent = this.value; + this.c[2].innerHTML = this.valueToHtml(); + + let svg = this.dom( 'svg', this.css.basic , { viewBox:'0 0 '+this.w+' '+this.rh, width:this.w, height:this.rh, preserveAspectRatio:'none' } ); + this.setCss( svg, { width:this.w, height:this.rh, left:0, top:this.top }); + + this.dom( 'path', '', { d:'', stroke:this.colors.text, 'stroke-width':2, fill:'none', 'stroke-linecap':'butt' }, svg ); + this.dom( 'rect', '', { x:10, y:10, width:this.gw+8, height:this.gh+8, stroke:'rgba(0,0,0,0.3)', 'stroke-width':1 , fill:'none'}, svg ); + + this.iw = ((this.gw-(4*(this.lng-1)))/this.lng); + let t = []; + this.cMode = []; + + this.v = []; + + for( let i = 0; i < this.lng; i++ ){ + + t[i] = [ 14 + (i*this.iw) + (i*4), this.iw ]; + t[i][2] = t[i][0] + t[i][1]; + this.cMode[i] = 0; + + if( this.neg ) this.v[i] = ((1+(this.value[i] / this.multiplicator))*0.5); + else this.v[i] = this.value[i] / this.multiplicator; + + this.dom( 'rect', '', { x:t[i][0], y:14, width:t[i][1], height:1, fill:this.colors.text, 'fill-opacity':0.3 }, svg ); + + } + + this.tmp = t; + this.c[3] = svg; + + //console.log(this.w) + + this.init(); + + if( this.c[1] !== undefined ){ + this.c[1].style.top = 0 +'px'; + this.c[1].style.height = 20 +'px'; + this.s[1].lineHeight = (20-5)+'px'; + } + + this.update( false ); + + } + + setValue ( value ) { + + this.value = value; + this.lng = this.value.length; + for (var i = 0; i < this.lng; i++) { + if (this.neg) this.v[i] = (1 + value[i] / this.multiplicator) * 0.5; + else this.v[i] = value[i] / this.multiplicator; + } + this.update(); + + } + + valueToHtml() { + + let i = this.lng, n=0, r = ''; + let w = 100 / this.lng; + let style = 'width:'+ w +'%;';//' text-align:center;' + while(i--){ + if(n===this.lng-1) r += '
' + this.value[n] + '
'; + else r += '' + this.value[n] + ''; + n++; + } + return r + } + + updateSVG () { + + if( this.line ) this.setSvg( this.c[3], 'd', this.makePath(), 0 ); + + for(let i = 0; ithis.top && l.yt[i][0] && l.x this.distance ) { + let angle = Math.atan2(this.tmp.x, this.tmp.y); + this.tmp.x = Math.sin( angle ) * this.distance; + this.tmp.y = Math.cos( angle ) * this.distance; + } + + this.pos.copy( this.tmp ).divideScalar( this.distance ).negate(); + + this.update(); + + } + + setValue ( v ) { + + if(v===undefined) v=[0,0]; + + this.pos.set( v[0] || 0, v[1] || 0 ); + this.updateSVG(); + + } + + update ( up ) { + + if( up === undefined ) up = true; + + if( this.interval !== null ){ + + if( !this.isDown ){ + + this.pos.lerp( null, 0.3 ); + + this.pos.x = Math.abs( this.pos.x ) < 0.01 ? 0 : this.pos.x; + this.pos.y = Math.abs( this.pos.y ) < 0.01 ? 0 : this.pos.y; + + if( this.isUI && this.main.isCanvas ) this.main.draw(); + + } + + } + + this.updateSVG(); + + if( up ) this.send(); + + + if( this.pos.isZero() ) this.stopInterval(); + + } + + updateSVG () { + + //let x = this.radius - ( -this.pos.x * this.distance ); + //let y = this.radius - ( -this.pos.y * this.distance ); + + let x = (this.diam*0.5) - ( -this.pos.x * this.distance ); + let y = (this.diam*0.5) - ( -this.pos.y * this.distance ); + + if(this.model === 0){ + + let sx = x + ((this.pos.x)*5) + 5; + let sy = y + ((this.pos.y)*5) + 10; + + this.setSvg( this.c[3], 'cx', sx*this.ratio, 3 ); + this.setSvg( this.c[3], 'cy', sy*this.ratio, 3 ); + } else { + this.setSvg( this.c[3], 'cx', x*this.ratio, 3 ); + this.setSvg( this.c[3], 'cy', y*this.ratio, 3 ); + } + + + + this.setSvg( this.c[3], 'cx', x*this.ratio, 4 ); + this.setSvg( this.c[3], 'cy', y*this.ratio, 4 ); + + this.value[0] = ( this.pos.x * this.multiplicator ).toFixed( this.precision ) * 1; + this.value[1] = ( this.pos.y * this.multiplicator ).toFixed( this.precision ) * 1; + + this.c[2].textContent = this.value; + + } + + clear () { + + this.stopInterval(); + super.clear(); + + } + +} + +class Knob extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.isCyclic = o.cyclic || false; + this.model = o.stype || 0; + if( o.mode !== undefined ) this.model = o.mode; + + this.autoWidth = false; + + this.setTypeNumber( o ); + + this.minw = this.w; + this.diam = o.diam || this.w; + + this.mPI = Math.PI * 0.8; + this.toDeg = 180 / Math.PI; + this.cirRange = this.mPI * 2; + + this.offset = new V2(); + + this.h = o.h || this.w + 10; + this.top = 0; + + this.c[0].style.width = this.w +'px'; + + if(this.c[1] !== undefined) { + + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + this.top = 10; + this.h += 10; + + } + + this.percent = 0; + + this.cmode = 0; + let cc = this.colors; + + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text ); + + this.c[3] = this.getKnob(); + this.setSvg( this.c[3], 'fill', cc.button, 0 ); + this.setSvg( this.c[3], 'stroke', cc.text, 1 ); + this.setSvg( this.c[3], 'stroke', cc.text, 3 ); + this.setSvg( this.c[3], 'd', this.makeGrad(), 3 ); + + this.setSvg( this.c[3], 'viewBox', '0 0 ' + this.diam + ' ' + this.diam ); + this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top }); + + if ( this.model > 0 ) { + + Tools.dom( 'path', '', { d: '', stroke:cc.text, 'stroke-width': 2, fill: 'none', 'stroke-linecap': 'round' }, this.c[3] ); //4 + + if ( this.model == 2) { + + Tools.addSVGGlowEffect(); + this.setSvg( this.c[3], 'style', 'filter: url("#UILGlow");', 4 ); + + } + + } + + this.r = 0; + + this.init(); + + this.update(); + + } + + mode ( mode ) { + + let cc = this.colors; + + if( this.cmode === mode ) return false; + + switch( mode ) { + case 0: // base + this.s[2].color = cc.text; + this.setSvg( this.c[3], 'fill', cc.button, 0); + //this.setSvg( this.c[3], 'stroke','rgba(255,0,0,0.2)', 2); + this.setSvg( this.c[3], 'stroke', cc.text, 1 ); + break; + case 1: // down + this.s[2].color = cc.textOver; + this.setSvg( this.c[3], 'fill', cc.select, 0); + //this.setSvg( this.c[3], 'stroke','rgba(0,0,0,0.6)', 2); + this.setSvg( this.c[3], 'stroke', cc.textOver, 1 ); + break; + } + + this.cmode = mode; + return true; + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'knob'; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.sendEnd(); + return this.mode(0) + + } + + mousedown ( e ) { + + this.isDown = true; + this.old = this.value; + this.oldr = null; + this.mousemove( e ); + return this.mode(1) + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + let off = this.offset; + + //off.x = this.radius - ( e.clientX - this.zone.x ); + //off.y = this.radius - ( e.clientY - this.zone.y - this.top ); + + off.x = (this.w*0.5) - ( e.clientX - this.zone.x ); + off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + + this.r = - Math.atan2( off.x, off.y ); + + if( this.oldr !== null ) this.r = Math.abs(this.r - this.oldr) > Math.PI ? this.oldr : this.r; + + this.r = this.r > this.mPI ? this.mPI : this.r; + this.r = this.r < -this.mPI ? -this.mPI : this.r; + + let steps = 1 / this.cirRange; + let value = (this.r + this.mPI) * steps; + + let n = ( ( this.range * value ) + this.min ) - this.old; + + if(n >= this.step || n <= this.step){ + n = Math.floor( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + this.oldr = this.r; + } + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'knob' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue( v ); + this.old = v; + this.update( true ); + + return true; + + } + return false; + + } + + makeGrad () { + + let d = '', step, range, a, x, y, x2, y2, r = 64; + let startangle = Math.PI + this.mPI; + let endangle = Math.PI - this.mPI; + //let step = this.step>5 ? this.step : 1; + + if(this.step>5){ + range = this.range / this.step; + step = ( startangle - endangle ) / range; + } else { + step = (( startangle - endangle ) / r)*2; + range = r*0.5; + } + + for ( let i = 0; i <= range; ++i ) { + + a = startangle - ( step * i ); + x = r + Math.sin( a ) * ( r - 20 ); + y = r + Math.cos( a ) * ( r - 20 ); + x2 = r + Math.sin( a ) * ( r - 24 ); + y2 = r + Math.cos( a ) * ( r - 24 ); + d += 'M' + x + ' ' + y + ' L' + x2 + ' '+y2 + ' '; + + } + + return d; + + } + + update ( up ) { + + this.c[2].textContent = this.value; + this.percent = (this.value - this.min) / this.range; + + let sa = Math.PI + this.mPI; + let ea = ( ( this.percent * this.cirRange ) - ( this.mPI ) ); + + let sin = Math.sin( ea ); + let cos = Math.cos( ea ); + + let x1 = ( 25 * sin ) + 64; + let y1 = -( 25 * cos ) + 64; + let x2 = ( 20 * sin ) + 64; + let y2 = -( 20 * cos ) + 64; + + this.setSvg( this.c[3], 'd', 'M ' + x1 +' ' + y1 + ' L ' + x2 +' ' + y2, 1 ); + + if ( this.model > 0 ) { + + let x1 = 36 * Math.sin( sa ) + 64; + let y1 = 36 * Math.cos( sa ) + 64; + let x2 = 36 * sin + 64; + let y2 = -36 * cos + 64; + let big = ea <= Math.PI - this.mPI ? 0 : 1; + this.setSvg( this.c[3], 'd', 'M ' + x1 + ',' + y1 + ' A ' + 36 + ',' + 36 + ' 1 ' + big + ' 1 ' + x2 + ',' + y2, 4 ); + + let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( this.colors.text, -0.75) ), Tools.unpack( this.colors.text ), this.percent ) ); + this.setSvg( this.c[3], 'stroke', color, 4 ); + + } + + if( up ) this.send(); + + } + +} + +class List extends Proto { + + constructor( o = {} ) { + + super( o ); + + // images + this.path = o.path || ''; + this.format = o.format || ''; + + + this.isWithImage = this.path !== '' ? true:false; + this.preLoadComplete = false; + + this.tmpImage = {}; + this.tmpUrl = []; + + //this.autoHeight = false; + + let align = o.align || 'center'; + + // scroll size + let ss = o.scrollSize || 10; + this.ss = ss+1; + + this.sMode = 0; + this.tMode = 0; + + this.listOnly = o.listOnly || false; + this.staticTop = o.staticTop || false; + + this.isSelectable = this.listOnly; + if( o.select !== undefined ) o.selectable = o.select; + if( o.selectable !== undefined ) this.isSelectable = o.selectable; + + if( this.txt === '' ) this.p = 0; + + + let fltop = Math.floor(this.h*0.5)-5; + let cc = this.colors; + + + + this.c[2] = this.dom( 'div', this.css.basic + 'top:0; display:none; border-radius:'+this.radius+'px;' ); + this.c[3] = this.dom( 'div', this.css.item + 'position:absolute; text-align:'+align+'; line-height:'+(this.h-4)+'px; top:1px; background:'+cc.button+'; height:'+(this.h-2)+'px; border:1px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:cc.text, stroke:'none'}); + + this.scrollerBack = this.dom( 'div', this.css.basic + 'right:0px; width:'+ss+'px; background:'+cc.back+'; display:none;'); + this.scroller = this.dom( 'div', this.css.basic + 'right:'+((ss-(ss*0.25))*0.5)+'px; width:'+(ss*0.25)+'px; background:'+cc.text+'; display:none; '); + + this.c[3].style.color = cc.text; + + + this.list = []; + this.refObject = null; + + if(o.list){ + if( o.list instanceof Array ){ + this.list = o.list; + } else { + this.refObject = o.list; + for( let g in this.refObject ) this.list.push(g); + } + } + + this.items = []; + + this.prevName = ''; + + this.baseH = this.h; + + this.itemHeight = o.itemHeight || (this.h-3); + + // force full list + this.full = o.full || false; + + this.py = 0; + this.ww = this.sb; + this.scroll = false; + this.isDown = false; + + this.current = null; + + // list up or down + this.side = o.side || 'down'; + this.up = this.side === 'down' ? 0 : 1; + + if( this.up ){ + + this.c[2].style.top = 'auto'; + this.c[3].style.top = 'auto'; + this.c[4].style.top = 'auto'; + //this.c[5].style.top = 'auto'; + + this.c[2].style.bottom = this.h-2 + 'px'; + this.c[3].style.bottom = '1px'; + this.c[4].style.bottom = fltop + 'px'; + + } else { + this.c[2].style.top = this.baseH + 'px'; + } + + this.listIn = this.dom( 'div', this.css.basic + 'left:0; top:0; width:100%; background:none;'); + this.listIn.name = 'list'; + + + + this.topList = 0; + + this.c[2].appendChild( this.listIn ); + this.c[2].appendChild( this.scrollerBack ); + this.c[2].appendChild( this.scroller ); + + if( o.value !== undefined ){ + if(!isNaN(o.value)) this.value = this.list[ o.value ]; + else this.value = o.value; + }else { + this.value = this.list[0]; + } + + this.isOpenOnStart = o.open || false; + + if( this.listOnly ){ + this.baseH = 5; + this.c[3].style.display = 'none'; + this.c[4].style.display = 'none'; + this.c[2].style.top = this.baseH+'px'; + this.isOpenOnStart = true; + } + + + this.miniCanvas = o.miniCanvas || false; + this.canvasBg = o.canvasBg || 'rgba(0,0,0,0)'; + this.imageSize = o.imageSize || [20,20]; + + // dragout function + this.drag = o.drag || false; + this.dragout = o.dragout || false; + this.dragstart = o.dragstart || null; + this.dragend = o.dragend || null; + + + + //this.c[0].style.background = '#FF0000' + if( this.isWithImage ) this.preloadImage(); + // } else { + // populate list + this.setList( this.list ); + this.init(); + if( this.isOpenOnStart ) this.open( true ); + // } + + } + + /*send ( v ) { + + super.send( v ); + + //Proto.prototype.send.call( this, v ); + }*/ + + // image list + + preloadImage () { + + this.preLoadComplete = false; + + this.tmpImage = {}; + for( let i=0; i this.h - this.baseH ) return 'title'; + else { + if( this.scroll && ( l.x > (this.sa+this.sb-this.ss)) ) return 'scroll'; + if(l.x > this.sa) return this.testItems( l.y-this.baseH ); + } + + } else { + if( l.y < this.baseH+2 ) return 'title'; + else { + if( this.isOpen ){ + if( this.scroll && ( l.x > (this.sa+this.sb-this.ss)) ) return 'scroll'; + if(l.x > this.sa) return this.testItems( l.y-this.baseH ); + } + } + + } + + return ''; + + } + + testItems ( y ) { + + let name = ''; + + let i = this.items.length, item, a, b; + while(i--){ + item = this.items[i]; + a = item.posy + this.topList; + b = item.posy + this.itemHeight + 1 + this.topList; + if( y >= a && y <= b ){ + name = 'item' + i; + this.modeItem(0); + this.current = item; + this.modeItem(1); + return name; + } + + } + + return name; + + } + + modeItem ( mode ) { + + if( !this.current ) return + + if( this.current.select && mode===0) mode = 2; + let cc = this.colors; + + switch( mode ){ + + case 0: // base + this.current.style.background = cc.back; + this.current.style.color = cc.text; + break; + case 1: // over + this.current.style.background = cc.over; + this.current.style.color = cc.textOver; + break; + case 2: // edit / down + this.current.style.background = cc.select; + this.current.style.color = cc.textSelect; + break; + + } + } + + unSelected() { + + if( !this.current ) return + this.modeItem(0); + this.current = null; + + } + + selected() { + + if( !this.current ) return + this.resetItems(); + this.modeItem(2); + this.current.select = true; + + } + + resetItems() { + + let i = this.items.length; + while(i--){ + this.items[i].select = false; + this.items[i].style.background = this.colors.back; + this.items[i].style.color = this.colors.text; + } + + } + + // ---------------------- + // EVENTS + // ---------------------- + + + mouseup ( e ) { + + this.isDown = false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + if( name === 'scroll' ){ + + this.isDown = true; + this.mousemove( e ); + + } else if( name === 'title' ){ + + this.modeTitle(2); + if( !this.listOnly ){ + if( !this.isOpen ) this.open(); + else this.close(); + } + } else { + // is item + if( this.current ){ + + this.value = this.list[ this.current.id ]; + + if( this.isSelectable ) this.selected(); + //this.value = this.refObject !== null ? this.refObject[this.list[this.current.id]] : this.list[this.current.id] + //this.value = this.current.textContent; + this.send( this.refObject !== null ? this.refObject[this.list[this.current.id]] : this.value ); + + if( !this.listOnly ) { + this.close(); + this.setTopItem(); + } + } + + } + + return true; + + } + + mousemove ( e ) { + + let nup = false; + let name = this.testZone( e ); + + if( !name ) return nup; + + if( name === 'title' ){ + this.unSelected(); + this.modeTitle(1); + this.cursor('pointer'); + + } else if( name === 'scroll' ){ + + this.cursor('s-resize'); + this.modeScroll(1); + if( this.isDown ){ + this.modeScroll(2); + let top = this.zone.y+this.baseH-2; + this.update( ( e.clientY - top ) - ( this.sh*0.5 ) ); + } + //if(this.isDown) this.listmove(e); + } else { + + // is item + this.modeTitle(0); + this.modeScroll(0); + this.cursor('pointer'); + + } + + if( name !== this.prevName ) nup = true; + this.prevName = name; + + return nup; + + } + + wheel ( e ) { + + let name = this.testZone( e ); + if( name === 'title' ) return false; + this.py += e.delta*10; + this.update(this.py); + return true; + + } + + + + // ---------------------- + + reset () { + + this.prevName = ''; + this.unSelected(); + this.modeTitle(0); + this.modeScroll(0); + + //console.log('this is reset') + + } + + modeScroll ( mode ) { + + if( mode === this.sMode ) return; + + let s = this.scroller.style; + let cc = this.colors; + + switch(mode){ + case 0: // base + s.background = cc.text; + break; + case 1: // over + s.background = cc.select; + break; + case 2: // edit / down + s.background = cc.select; + break; + + } + + this.sMode = mode; + } + + modeTitle ( mode ) { + + if( mode === this.tMode ) return; + + let s = this.s; + let cc = this.colors; + + switch(mode){ + case 0: // base + s[3].color = cc.text; + s[3].background = cc.button; + break; + case 1: // over + s[3].color = cc.textOver; + s[3].background = cc.overoff; + break; + case 2: // edit / down + s[3].color = cc.textSelect; + s[3].background = cc.overoff; + break; + + } + + this.tMode = mode; + + } + + clearList () { + + while ( this.listIn.children.length ) this.listIn.removeChild( this.listIn.lastChild ); + this.items = []; + + } + + setList ( list ) { + + this.clearList(); + + this.list = list; + this.length = this.list.length; + + this.maxItem = this.full ? this.length : 5; + this.maxItem = this.length < this.maxItem ? this.length : this.maxItem; + + this.maxHeight = this.maxItem * (this.itemHeight+1) + 2; + + this.max = this.length * (this.itemHeight+1) + 2; + this.ratio = this.maxHeight / this.max; + this.sh = this.maxHeight * this.ratio; + this.range = this.maxHeight - this.sh; + + this.c[2].style.height = this.maxHeight + 'px'; + this.scrollerBack.style.height = this.maxHeight + 'px'; + this.scroller.style.height = this.sh + 'px'; + + if( this.max > this.maxHeight ){ + this.ww = this.sb - this.ss; + this.scroll = true; + } + + if( this.miniCanvas ) { + + this.tmpCanvas = document.createElement('canvas'); + this.tmpCanvas.width = this.imageSize[0]; + this.tmpCanvas.height = this.imageSize[1]; + this.tmpCtx = this.tmpCanvas.getContext("2d"); + this.tmpCtx.fillStyle = this.canvasBg; + this.tmpCtx.fillRect(0, 0, this.imageSize[0], this.imageSize[1]); + + } + + let item, n;//, l = this.sb; + for( let i=0; i this.range ? this.range : y; + + this.topList = -Math.floor( y / this.ratio ); + + this.listIn.style.top = this.topList+'px'; + this.scroller.style.top = Math.floor( y ) + 'px'; + + this.py = y; + + } + + parentHeight ( t ) { + + if ( this.group !== null ) this.group.calc( t ); + else if ( this.isUI ) this.main.calc( t ); + + } + + open ( first ) { + + super.open(); + + this.update( 0 ); + + this.h = this.maxHeight + this.baseH + 5; + if( !this.scroll ){ + this.topList = 0; + this.h = this.baseH + 5 + this.max; + this.scroller.style.display = 'none'; + this.scrollerBack.style.display = 'none'; + } else { + this.scroller.style.display = 'block'; + this.scrollerBack.style.display = 'block'; + } + this.s[0].height = this.h + 'px'; + this.s[2].display = 'block'; + + if( this.up ){ + this.zone.y -= this.h - (this.baseH-10); + this.setSvg( this.c[4], 'd', this.svgs.arrowUp ); + } else { + this.setSvg( this.c[4], 'd', this.svgs.arrowDown ); + } + + this.rSizeContent(); + + let t = this.h - this.baseH; + + this.zone.h = this.h; + + if(!first) this.parentHeight( t ); + + } + + close () { + + super.close(); + + if( this.up ) this.zone.y += this.h - (this.baseH-10); + + let t = this.h - this.baseH; + + this.h = this.baseH; + this.s[0].height = this.h + 'px'; + this.s[2].display = 'none'; + this.setSvg( this.c[4], 'd', this.svgs.arrow ); + + this.zone.h = this.h; + + this.parentHeight( -t ); + + } + + // ----- + + text ( txt ) { + + this.c[3].textContent = txt; + + } + + rSizeContent () { + + let i = this.length; + while(i--) this.listIn.children[i].style.width = this.ww + 'px'; + + } + + rSize () { + + super.rSize(); + + //Proto.prototype.rSize.call( this ); + + let s = this.s; + let w = this.sb; + let d = this.sa; + + if(s[2]=== undefined) return; + + s[2].width = w + 'px'; + s[2].left = d +'px'; + + s[3].width = w + 'px'; + s[3].left = d + 'px'; + + s[4].left = d + w - 17 + 'px'; + + this.ww = w; + if( this.max > this.maxHeight ) this.ww = w-this.ss; + if(this.isOpen) this.rSizeContent(); + + } + +} + +class Numeric extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.setTypeNumber( o ); + + this.allway = o.allway || false; + + this.isDown = false; + + this.value = [0]; + this.multy = 1; + this.invmulty = 1; + this.isSingle = true; + this.isAngle = false; + this.isVector = false; + + if( o.isAngle ){ + this.isAngle = true; + this.multy = Tools.torad; + this.invmulty = Tools.todeg; + } + + this.isDrag = o.drag || false; + + if( o.value !== undefined ){ + if(!isNaN(o.value)){ + this.value = [o.value]; + } else if( o.value instanceof Array ){ + this.value = o.value; + this.isSingle = false; + } else if( o.value instanceof Object ){ + this.value = []; + if( o.value.x !== undefined ) this.value[0] = o.value.x; + if( o.value.y !== undefined ) this.value[1] = o.value.y; + if( o.value.z !== undefined ) this.value[2] = o.value.z; + if( o.value.w !== undefined ) this.value[3] = o.value.w; + this.isVector = true; + this.isSingle = false; + } + } + + this.lng = this.value.length; + this.tmp = []; + + + + this.current = -1; + this.prev = { x:0, y:0, d:0, v:0 }; + + let cc = this.colors; + + // bg + this.c[2] = this.dom( 'div', this.css.basic + ' background:' + cc.select + '; top:4px; width:0px; height:' + (this.h-8) + 'px;' ); + + this.cMode = []; + + let i = this.lng; + while(i--){ + + if(this.isAngle) this.value[i] = (this.value[i] * 180 / Math.PI).toFixed( this.precision ); + this.c[3+i] = this.dom( 'div', this.css.txtselect + ' height:'+(this.h-4)+'px; color:' + cc.text + '; background:' + cc.back + '; borderColor:' + cc.border+'; border-radius:'+this.radius+'px;'); + if(o.center) this.c[2+i].style.textAlign = 'center'; + this.c[3+i].textContent = this.value[i]; + this.c[3+i].style.color = this.colors.text; + this.c[3+i].isNum = true; + + this.cMode[i] = 0; + + } + + // selection + this.selectId = 3 + this.lng; + this.c[this.selectId] = this.dom( 'div', this.css.txtselect + 'position:absolute; top:4px; height:' + (this.h-8) + 'px; padding:0px 0px; width:0px; color:' + cc.textSelect + '; background:' + cc.select + '; border:none; border-radius:0px;'); + + // cursor + this.cursorId = 4 + this.lng; + this.c[ this.cursorId ] = this.dom( 'div', this.css.basic + 'top:4px; height:' + (this.h-8) + 'px; width:0px; background:'+cc.text+';' ); + + this.init(); + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + let i = this.lng; + let t = this.tmp; + + + while( i-- ){ + if( l.x>t[i][0] && l.x= this.txl ) return 'text'; + else if( l.x >= this.sa ) return 'scroll'; + else return ''; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( this.isDown ) this.isDown = false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + if( name === 'scroll' ){ + this.isDown = true; + this.old = this.value; + this.mousemove( e ); + + } + + /*if( name === 'text' ){ + this.setInput( this.c[2], function(){ this.validate() }.bind(this) ); + }*/ + + return true; + + } + + mousemove ( e ) { + + let nup = false; + + let name = this.testZone( e ); + + if( name === 'scroll' ) { + this.mode(1); + this.cursor('w-resize'); + //} else if(name === 'text'){ + //this.cursor('pointer'); + } else { + this.cursor(); + } + + if( this.isDown ){ + + let n = ((( e.clientX - (this.zone.x+this.sa) - 3 ) / this.ww ) * this.range + this.min ) - this.old; + if(n >= this.step || n <= this.step){ + n = Math.floor( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + } + nup = true; + } + + return nup; + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'scroll' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue(v); + this.old = v; + this.update( true ); + + return true; + + } + + return false; + + } + + //keydown: function ( e ) { return true; }, + + // ---------------------- + + validate () { + + let n = this.c[2].textContent; + + if(!isNaN( n )){ + this.value = this.numValue( n ); + this.update(true); + } + + else this.c[2].textContent = this.value + (this.isDeg ? '°':''); + + } + + + reset () { + + //this.clearInput(); + this.isDown = false; + this.mode(0); + + } + + mode ( mode ) { + + let s = this.s; + let cc = this.colors; + + switch(mode){ + case 0: // base + // s[2].border = '1px solid ' + this.colors.hide; + s[2].color = cc.text; + s[4].background = cc.back; + s[5].background = cc.text; + break; + case 1: // scroll over + //s[2].border = '1px dashed ' + this.colors.hide; + s[2].color = cc.textOver; + s[4].background = cc.back; + s[5].background = cc.textOver; + break; + /* case 2: + s[2].border = '1px solid ' + this.colors.borderSelect; + break; + case 3: + s[2].border = '1px dashed ' + this.colors.text;//this.colors.borderSelect; + break; + case 4: + s[2].border = '1px dashed ' + this.colors.hide; + break;*/ + + + } + } + + update ( up ) { + + let ww = Math.floor( this.ww * (( this.value - this.min ) / this.range )); + + if(this.model !== 3) this.s[5].width = ww + 'px'; + if(this.s[6]) this.s[6].left = ( this.sa + ww + 3 ) + 'px'; + this.c[2].textContent = this.value + (this.isDeg ? '°':''); + + if( up ) this.send(); + + } + + rSize () { + + super.rSize(); + + let w = this.sb - this.sc; + this.ww = w - 6; + + let tx = this.sc; + if(this.isUI || !this.simple) tx = this.sc+10; + this.txl = this.w - tx + 2; + + //let ty = Math.floor(this.h * 0.5) - 8; + + let s = this.s; + + s[2].width = (this.sc -6 )+ 'px'; + s[2].left = (this.txl +4) + 'px'; + //s[2].top = ty + 'px'; + s[3].left = this.sa + 'px'; + s[3].width = w + 'px'; + s[4].left = this.sa + 'px'; + s[4].width = w + 'px'; + s[5].left = (this.sa + 3) + 'px'; + + this.update(); + + } + +} + +class TextInput extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.cmode = 0; + + this.value = o.value || ''; + this.placeHolder = o.placeHolder || ''; + + this.allway = o.allway || false; + this.editable = o.edit !== undefined ? o.edit : true; + + this.isDown = false; + + let cc = this.colors; + + // text + this.c[2] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; color:' + cc.text + '; background:' + cc.back + '; borderColor:' + cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[2].textContent = this.value; + + // selection + this.c[3] = this.dom( 'div', this.css.txtselect + 'position:absolute; top:4px; height:' + (this.h-8) + 'px; padding:0px 0px; width:0px; color:' + cc.textSelect + '; background:' + cc.select + '; border:none; border-radius:0px;'); + + // cursor + this.c[4] = this.dom( 'div', this.css.basic + 'top:4px; height:' + (this.h-8) + 'px; width:0px; background:'+cc.text+';' ); + + // fake + this.c[5] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; justify-content: center; font-style: italic; color:'+cc.border+';' ); + if( this.value === '' ) this.c[5].textContent = this.placeHolder; + + + + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.x >= this.sa ) return 'text'; + return ''; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if(!this.editable) return; + + if( this.isDown ){ + this.isDown = false; + return this.mousemove( e ); + } + + return false; + + } + + mousedown ( e ) { + + if(!this.editable) return; + + let name = this.testZone( e ); + + if( !this.isDown ){ + this.isDown = true; + if( name === 'text' ) this.setInput( this.c[2] ); + return this.mousemove( e ); + } + + return false; + + } + + mousemove ( e ) { + + if(!this.editable) return; + + let name = this.testZone( e ); + + //let l = this.local; + //if( l.x === -1 && l.y === -1 ){ return;} + + //if( l.x >= this.sa ) this.cursor('text'); + //else this.cursor(); + + let x = 0; + + if( name === 'text' ) this.cursor('text'); + else this.cursor(); + + if( this.isDown ) x = e.clientX - this.zone.x; + + return this.upInput( x - this.sa -3, this.isDown ); + + } + + update ( ) { + + this.c[2].textContent = this.value; + + } + + // ---------------------- + + reset () { + + this.cursor(); + + } + + // ---------------------- + // INPUT + // ---------------------- + + select ( c, e, w, t ) { + + let s = this.s; + let d = this.sa + 5; + s[4].width = '1px'; + s[4].left = ( d + e ) + 'px'; + + s[3].left = ( d + e ) + 'px'; + s[3].width = w + 'px'; + this.c[3].innerHTML = t; + + } + + unselect () { + + let s = this.s; + if(!s) return; + s[3].width = 0 + 'px'; + this.c[3].innerHTML = 't'; + s[4].width = 0 + 'px'; + + } + + validate ( force ) { + + if( this.allway ) force = true; + + this.value = this.c[2].textContent; + + if(this.value !== '') this.c[5].textContent = ''; + else this.c[5].textContent = this.placeHolder; + + if( !force ) return; + + this.send(); + + } + + // ---------------------- + // REZISE + // ---------------------- + + rSize () { + + super.rSize(); + + let s = this.s; + s[2].left = this.sa + 'px'; + s[2].width = this.sb + 'px'; + + s[5].left = this.sa + 'px'; + s[5].width = this.sb + 'px'; + + } + + +} + +class Title extends Proto { + + constructor( o = {} ) { + + super( o ); + + let prefix = o.prefix || ''; + + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:right; width:60px; line-height:'+ (this.h-8) + 'px; color:' + this.colors.text ); + + if( this.h === 31 ){ + + this.s[0].height = this.h + 'px'; + this.s[1].top = 8 + 'px'; + this.c[2].style.top = 8 + 'px'; + + } + + let s = this.s; + + s[1].justifyContent = o.align || 'left'; + //s[1].textAlign = o.align || 'left'; + s[1].fontWeight = o.fontWeight || 'bold'; + + + this.c[1].textContent = this.txt.substring(0,1).toUpperCase() + this.txt.substring(1).replace("-", " "); + this.c[2].textContent = prefix; + + this.init(); + + } + + text( txt ) { + + this.c[1].textContent = txt; + + } + + text2( txt ) { + + this.c[2].textContent = txt; + + } + + rSize() { + + super.rSize(); + this.s[1].width = this.w + 'px'; //- 50 + 'px'; + this.s[2].left = this.w + 'px';//- ( 50 + 26 ) + 'px'; + + } + + setColor( c ) { + this.s[1].color = c; + this.s[2].color = c; + } + +} + +class Select extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || ''; + + this.isDown = false; + + this.onActif = o.onActif || function(){}; + + o.prefix || ''; + + this.c[2] = this.dom( 'div', this.css.txt + this.css.button + ' top:1px; background:'+this.colors.button+'; height:'+(this.h-2)+'px; border:'+this.colors.buttonBorder+'; border-radius:15px; width:30px; left:10px;' ); + this.c[2].style.color = this.fontColor; + + this.c[3] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; background:' + this.colors.inputBg + '; borderColor:' + this.colors.inputBorder+'; border-radius:'+this.radius+'px;' ); + this.c[3].textContent = this.value; + + let fltop = Math.floor(this.h*0.5)-7; + this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.svgs[ 'cursor' ], fill:this.fontColor, stroke:'none'}); + + this.stat = 1; + this.isActif = false; + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.x > this.sa && l.x < this.sa+30 ) return 'over'; + return '0' + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( this.isDown ){ + //this.value = false; + this.isDown = false; + //this.send(); + return this.mousemove( e ); + } + + return false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + this.isDown = true; + //this.value = this.values[ name-2 ]; + //this.send(); + return this.mousemove( e ); + + } + + mousemove ( e ) { + + let up = false; + + let name = this.testZone( e ); + //let sel = false; + + + + //console.log(name) + + if( name === 'over' ){ + this.cursor('pointer'); + up = this.mode( this.isDown ? 3 : 2 ); + } else { + up = this.reset(); + } + + return up; + + } + + // ---------------------- + + apply ( v ) { + + v = v || ''; + + if( v !== this.value ) { + this.value = v; + this.c[3].textContent = this.value; + this.send(); + } + + this.mode(1); + + } + + update () { + + this.mode( 3 ); + + } + + mode ( n ) { + + let change = false; + let cc = this.colors; + + if( this.stat !== n ){ + + if( n===1 ) this.isActif = false; + if( n===3 ){ + if( !this.isActif ){ this.isActif = true; n=4; this.onActif( this ); } + else { this.isActif = false; } + } + + if( n===2 && this.isActif ) n = 4; + + this.stat = n; + + switch( n ){ + + case 1: this.s[ 2 ].color = cc.text; this.s[ 2 ].background = cc.button; break; // base + case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.over; break; // over + case 3: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.select; break; // down + case 4: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.action; break; // actif + + } + + change = true; + + } + + return change; + + + + } + + reset () { + + this.cursor(); + return this.mode( this.isActif ? 4 : 1 ); + + } + + text ( txt ) { + + this.c[3].textContent = txt; + + } + + rSize () { + + super.rSize(); + + let s = this.s; + s[2].left = this.sa + 'px'; + s[3].left = (this.sa + 40) + 'px'; + s[3].width = (this.sb - 40) + 'px'; + s[4].left = (this.sa+8) + 'px'; + + } + +} + +//import { Proto } from '../core/Proto.js'; + +class Selector extends Button { + + constructor( o = {} ) { + + if( o.selectable === undefined ) o.selectable = true; + super( o ); + + } + +} + +class Empty extends Proto { + + constructor( o = {} ) { + + o.isSpace = true; + o.margin = 0; + if(!o.h) o.h = 10; + super( o ); + this.init(); + + } + +} + +class Item extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.p = 100; + this.value = this.txt; + this.status = 1; + + this.itype = o.itype || 'none'; + this.val = this.itype; + + this.graph = this.svgs[ this.itype ]; + + let fltop = Math.floor(this.h*0.5)-7; + + this.c[2] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.graph, fill:this.colors.text, stroke:'none'}); + + this.s[1].marginLeft = 20 + 'px'; + + this.init(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousemove ( e ) { + + this.cursor('pointer'); + + //up = this.modes( this.isDown ? 3 : 2, name ); + + } + + mousedown ( e ) { + + if( this.isUI ) this.main.resetItem(); + + this.selected( true ); + + this.send(); + + return true; + + } + + uiout () { + + if( this.isSelect ) this.mode(3); + else this.mode(1); + + } + + uiover () { + + if( this.isSelect ) this.mode(4); + else this.mode(2); + + } + + update () { + + } + + /*rSize () { + + super.rSize(); + + }*/ + + mode ( n ) { + + let change = false; + + if( this.status !== n ){ + + this.status = n; + let s = this.s, cc = this.colors; + + switch( n ){ + + case 1: this.status = 1; s[1].color = cc.text; s[0].background = 'none'; break; + case 2: this.status = 2; s[1].color = cc.textOver; s[0].background = cc.back; break; + case 3: this.status = 3; s[1].color = cc.textSelect; s[0].background = cc.select; break; + case 4: this.status = 4; s[1].color = cc.textOver; s[0].background = cc.over; break; + + } + + change = true; + + } + + return change; + + } + + reset () { + + this.cursor(); + // return this.mode( 1 ); + + } + + selected ( b ){ + + if( this.isSelect ) this.mode(1); + + this.isSelect = b || false; + + if( this.isSelect ) this.mode(3); + + } + + +} + +class Grid extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.values = o.values || []; + + if( typeof this.values === 'string' ) this.values = [ this.values ]; + this.lng = this.values.length; + + this.value = o.value || null; + + + this.isSelectable = o.selectable || false; + this.spaces = o.spaces || [5,3]; + this.bsize = o.bsize || [90,20]; + + if(o.h) this.bsize[1] = o.h; + this.bsizeMax = this.bsize[0]; + + + this.tmp = []; + this.stat = []; + this.grid = [ 2, Math.round( this.lng * 0.5 ) ]; + this.h = this.grid[1] * ( this.bsize[1] + this.spaces[1] ) + this.spaces[1]; + + this.c[1].textContent = ''; + this.c[2] = this.dom( 'table', this.css.basic + 'width:100%; top:'+(this.spaces[1]-2)+'px; height:auto; border-collapse:separate; border:none; border-spacing: '+(this.spaces[0]-2)+'px '+(this.spaces[1]-2)+'px;' ); + + let n = 0, b, td, tr, sel; + + this.res = -1; + this.isDown = false; + this.neverlock = true; + + this.buttons = []; + this.stat = []; + this.tmpX = []; + this.tmpY = []; + + let cc = this.colors; + + for( let i = 0; i < this.grid[1]; i++ ){ + + tr = this.c[2].insertRow(); + tr.style.cssText = 'pointer-events:none;'; + for( let j = 0; j < this.grid[0]; j++ ){ + + td = tr.insertCell(); + td.style.cssText = 'pointer-events:none;'; + + if( this.values[n] ){ + + sel = false; + if( this.values[n] === this.value && this.isSelectable ) sel = true; + + b = document.createElement( 'div' ); + b.style.cssText = this.css.txt + this.css.button + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; border:'+cc.borderSize+'px solid '+cc.border+'; left:auto; right:auto; border-radius:'+this.radius+'px;'; + b.style.background = sel ? cc.select : cc.button; + b.style.color = sel ? cc.textSelect : cc.text; + b.innerHTML = this.values[n]; + td.appendChild( b ); + + this.buttons.push(b); + this.stat.push(1); + + } else { + + b = document.createElement( 'div' ); + b.style.cssText = this.css.txt + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; text-align:center; left:auto; right:auto; background:none;'; + td.appendChild( b ); + + } + + if(j===0) b.style.cssText += 'float:right;'; + else b.style.cssText += 'float:left;'; + + n++; + + } + } + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return -1; + + let tx = this.tmpX; + let ty = this.tmpY; + + let id = -1; + let c = -1; + let line = -1; + let i = this.grid[0]; + while( i-- ){ + if( l.x > tx[i][0] && l.x < tx[i][1] ) c = i; + } + + i = this.grid[1]; + while( i-- ){ + if( l.y > ty[i][0] && l.y < ty[i][1] ) line = i; + } + + if(c!==-1 && line!==-1){ + id = c + (line*2); + if(id>this.lng-1) id = -1; + } + + return id; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( !this.isDown ) return false + + this.isDown = false; + if( this.res !== -1 ){ + this.value = this.values[this.res]; + this.send(); + } + + return this.mousemove( e ) + + } + + mousedown ( e ) { + + if( this.isDown ) return false + this.isDown = true; + return this.mousemove( e ) + + } + + mousemove ( e ) { + + let up = false; + this.res = this.testZone( e ); + + if( this.res !== -1 ){ + this.cursor('pointer'); + up = this.modes( this.isDown ? 3 : 2, this.res ); + } else { + up = this.reset(); + } + + return up; + + } + + // ---------------------- + // MODE + // ----------------------- + + modes ( N = 1, id = -1 ) { + + let i = this.lng, w, n, r = false; + + while( i-- ){ + + n = N; + w = this.isSelectable ? this.values[ i ] === this.value : false; + + if( i === id ){ + if( w && n === 2 ) n = 3; + } else { + n = 1; + if( w ) n = 4; + } + + if( this.mode( n, i ) ) r = true; + + } + + return r + + } + + mode ( n, id ) { + + let change = false; + let cc = this.colors, s = this.buttons; + let i = id; + + if( this.stat[id] !== n ){ + + this.stat[id] = n; + + switch( n ){ + + case 1: s[i].style.color = cc.text; s[i].style.background = cc.button; break; + case 2: s[i].style.color = cc.textOver; s[i].style.background = cc.overoff; break; + case 3: s[i].style.color = cc.textOver; s[i].style.background = cc.over; break; + case 4: s[i].style.color = cc.textSelect; s[i].style.background = cc.select; break; + + } + + change = true; + + } + + return change; + + } + + // ---------------------- + + reset () { + + this.res = -1; + this.cursor(); + return this.modes() + + } + + + label ( string, n ) { + + this.buttons[n].textContent = string; + + } + + icon ( string, y, n ) { + + this.buttons[n].style.padding = ( y || 0 ) +'px 0px'; + this.buttons[n].innerHTML = string; + + } + + testW () { + + let vw = this.spaces[0]*3 + this.bsizeMax*2, rz = false; + if( vw > this.w ) { + this.bsize[0] = ( this.w-(this.spaces[0]*3) ) * 0.5; + rz = true; + } else { + if( this.bsize[0] !== this.bsizeMax ) { + this.bsize[0] = this.bsizeMax; + rz = true; + } + } + + if( !rz ) return; + + let i = this.buttons.length; + while(i--) this.buttons[i].style.width = this.bsize[0] + 'px'; + + } + + rSize () { + + super.rSize(); + + this.testW(); + + let mid; + + this.tmpX = []; + this.tmpY = []; + + for( let j = 0; j < this.grid[0]; j++ ){ + + if(j===0){ + mid = ( this.w*0.5 ) - ( this.spaces[0]*0.5 ); + this.tmpX.push( [ mid-this.bsize[0], mid ] ); + } else { + mid = ( this.w*0.5 ) + ( this.spaces[0]*0.5 ); + this.tmpX.push( [ mid, mid+this.bsize[0] ] ); + } + + } + + mid = this.spaces[1]; + + for( let i = 0; i < this.grid[1]; i++ ){ + + this.tmpY.push( [ mid, mid + this.bsize[1] ] ); + mid += this.bsize[1] + this.spaces[1]; + + } + + } + +} + +class Pad2D extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.autoWidth = false; + this.minw = this.w; + this.diam = o.diam || this.w; + + //this.margin = 15; + this.pos = new V2(0,0); + this.maxPos = 90; + + this.model = o.stype || 0; + if( o.mode !== undefined ) this.model = o.mode; + + this.min = o.min === undefined ? -1 : o.min; + this.max = o.max === undefined ? 1 : o.max; + + this.range = (this.max - this.min)*0.5; + + this.cmode = 0; + + + //console.log(this.range) + + + + + + this.precision = o.precision === undefined ? 2 : o.precision; + + /*this.bounds = {}; + this.bounds.x1 = o.x1 || -1; + this.bounds.x2 = o.x2 || 1; + this.bounds.y1 = o.y1 || -1; + this.bounds.y2 = o.y2 || 1; + + this.lerpX = this.lerp( this.margin, this.w - this.margin , this.bounds.x1, this.bounds.x2 ); + this.lerpY = this.lerp( this.margin, this.w - this.margin , this.bounds.y1, this.bounds.y2 ); + + this.alerpX = this.lerp( this.bounds.x1, this.bounds.x2, this.margin, this.w - this.margin ); + this.alerpY = this.lerp( this.bounds.y1, this.bounds.y2, this.margin, this.w - this.margin );*/ + + this.value = ( Array.isArray( o.value ) && o.value.length == 2 ) ? o.value : [ 0, 0 ]; + + + this.h = o.h || this.w + 10; + this.top = 0; + + this.c[0].style.width = this.w + 'px'; + + // Title + if( this.c[1] !== undefined ) { // with title + + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + this.top = 10; + this.h += 10; + + } + + let cc = this.colors; + + + // Value + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+ ( this.h - 20 ) + 'px; width:100%; color:' + cc.text ); + this.c[2].textContent = this.value; + + // Pad + + let pad = this.getPad2d(); + + this.setSvg( pad, 'fill', cc.back, 0 ); + this.setSvg( pad, 'fill', cc.button, 1 ); + this.setSvg( pad, 'stroke', cc.back, 2 ); + this.setSvg( pad, 'stroke', cc.back, 3 ); + this.setSvg( pad, 'stroke', cc.text, 4 ); + + this.setSvg( pad, 'viewBox', '0 0 '+this.diam+' '+this.diam ); + this.setCss( pad, { width:this.diam, height:this.diam, left:0, top:this.top }); + + this.c[3] = pad; + + this.init(); + this.setValue(); + + } + + testZone ( e ) { + + let l = this.local; + + if( l.x === -1 && l.y === -1 ) return ''; + + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'pad'; + + /*if( ( l.x >= this.margin ) && ( l.x <= this.w - this.margin ) && ( l.y >= this.top + this.margin ) && ( l.y <= this.top + this.w - this.margin ) ) { + return 'pad'; + }*/ + + //return ''; + + } + + mouseup ( e ) { + + this.isDown = false; + return this.mode(0); + + } + + mousedown ( e ) { + + if ( this.testZone(e) === 'pad' ) { + + this.isDown = true; + this.mousemove( e ); + return this.mode(1); + } + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + let x = (this.w*0.5) - ( e.clientX - this.zone.x ); + let y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + let r = 256 / this.diam; + + x = -(x*r); + y = -(y*r); + + x = Tools.clamp( x, -this.maxPos, this.maxPos ); + y = Tools.clamp( y, -this.maxPos, this.maxPos ); + + //let x = e.clientX - this.zone.x; + //let y = e.clientY - this.zone.y - this.top; + + /*if( x < this.margin ) x = this.margin; + if( x > this.w - this.margin ) x = this.w - this.margin; + if( y < this.margin ) y = this.margin; + if( y > this.w - this.margin ) y = this.w - this.margin;*/ + + //console.log(x,y) + + this.setPos( [ x , y ] ); + + this.update( true ); + + } + + mode ( mode ) { + + if( this.cmode === mode ) return false; + + let cc = this.colors; + + switch( mode ){ + case 0: // base + + this.s[2].color = cc.text; + this.setSvg( this.c[3], 'fill', cc.back, 0); + this.setSvg( this.c[3], 'fill', cc.button, 1); + this.setSvg( this.c[3], 'stroke', cc.back, 2); + this.setSvg( this.c[3], 'stroke', cc.back, 3); + this.setSvg( this.c[3], 'stroke', cc.text, 4 ); + + break; + case 1: // down + + this.s[2].color = cc.textSelect; + this.setSvg( this.c[3], 'fill', cc.backoff, 0); + this.setSvg( this.c[3], 'fill', cc.overoff, 1); + this.setSvg( this.c[3], 'stroke', cc.backoff, 2); + this.setSvg( this.c[3], 'stroke', cc.backoff, 3); + this.setSvg( this.c[3], 'stroke', cc.textSelect, 4 ); + + break; + } + + this.cmode = mode; + return true; + + + + } + + update ( up ) { + + //if( up === undefined ) up = true; + + this.c[2].textContent = this.value; + + this.updateSVG(); + + if( up ) this.send(); + + } + + updateSVG() { + + if ( this.model == 1 ) { + + this.setSvg( this.c[3], 'y1', this.pos.y, 2 ); + this.setSvg( this.c[3], 'y2', this.pos.y, 2 ); + + this.setSvg( this.c[3], 'x1', this.pos.x, 3 ); + this.setSvg( this.c[3], 'x2', this.pos.x, 3 ); + + } + + this.setSvg( this.c[3], 'cx', this.pos.x, 4 ); + this.setSvg( this.c[3], 'cy', this.pos.y, 4 ); + + } + + setPos ( p ) { + + //if( p === undefined ) p = [ this.w / 2, this.w / 2 ]; + + this.pos.set( p[0]+128 , p[1]+128 ); + + let r = 1/this.maxPos; + + this.value[0] = ((p[0]*r)*this.range).toFixed( this.precision ); + this.value[1] = ((p[1]*r)*this.range).toFixed( this.precision ); + + } + + setValue ( v, up = false ) { + + if( v === undefined ) v = this.value; + + /*if ( v[0] < this.bounds.x1 ) v[0] = this.bounds.x1; + if ( v[0] > this.bounds.x2 ) v[0] = this.bounds.x2; + if ( v[1] < this.bounds.y1 ) v[1] = this.bounds.y1; + if ( v[1] > this.bounds.y2 ) v[1] = this.bounds.y2;*/ + + this.value[0] = Math.min( this.max, Math.max( this.min, v[0] ) ).toFixed( this.precision ) * 1; + this.value[1] = Math.min( this.max, Math.max( this.min, v[1] ) ).toFixed( this.precision ) * 1; + + this.pos.set( ((this.value[0]/this.range)*this.maxPos)+128 , ((this.value[1]/this.range)*this.maxPos)+128 ); + + //console.log(this.pos) + + this.update( up ); + + } + + /*lerp( s1, s2, d1, d2, c = true ) { + + let s = ( d2 - d1 ) / ( s2 - s1 ); + + return c ? ( v ) => { + return ( ( v < s1 ? s1 : v > s2 ? s2 : v ) - s1 ) * s + d1 + } : ( v ) => { + return ( v - s1 ) * s + d1 + } + + }*/ + +} + +const add = function () { + + let a = arguments; + + let type, o, ref = false, n = null; + + if( typeof a[0] === 'string' ){ + + type = a[0]; + o = a[1] || {}; + + } else if ( typeof a[0] === 'object' ){ // like dat gui + + ref = true; + if( a[2] === undefined ) [].push.call(a, {}); + + type = a[2].type ? a[2].type : autoType( a[0][a[1]], a[2] ); + + o = a[2]; + o.name = a[1]; + if( type === 'list' ){ o.list = a[0][a[1]]; } + else o.value = a[0][a[1]]; + + } + + + + let name = type.toLowerCase(); + + if( name === 'group' ) o.add = add; + + switch( name ){ + + case 'bool': case 'boolean': n = new Bool(o); break; + case 'button': n = new Button(o); break; + case 'circular': n = new Circular(o); break; + case 'color': n = new Color(o); break; + case 'fps': n = new Fps(o); break; + case 'graph': n = new Graph(o); break; + case 'group': n = new Group(o); break; + case 'joystick': n = new Joystick(o); break; + case 'knob': n = new Knob(o); break; + case 'list': n = new List(o); break; + case 'numeric': case 'number': n = new Numeric(o); break; + case 'slide': n = new Slide(o); break; + case 'textInput': case 'string': n = new TextInput(o); break; + case 'title': case 'text': n = new Title(o); break; + case 'select': n = new Select(o); break; + case 'selector': n = new Selector(o); break; + case 'empty': case 'space': n = new Empty(o); break; + case 'item': n = new Item(o); break; + case 'grid': n = new Grid(o); break; + case 'pad2d': case 'pad': n = new Pad2D(o); break; + + } + + if( n !== null ){ + + if( ref ) n.setReferency( a[0], a[1] ); + return n; + + } + +}; + +const autoType = function ( v, o ) { + + let type = 'slide'; + + if( typeof v === 'boolean' ) type = 'bool'; + else if( typeof v === 'string' ){ + + if( v.substring(0,1) === '#' ) type = 'color'; + else type = 'string'; + + } else if( typeof v === 'number' ){ + + if( o.ctype ) type = 'color'; + else type = 'slide'; + + } else if( typeof v === 'array' && v instanceof Array ){ + + if( typeof v[0] === 'number' ) type = 'number'; + else if( typeof v[0] === 'string' ) type = 'list'; + + } else if( typeof v === 'object' && v instanceof Object ){ + + if( v.x !== undefined ) type = 'number'; + else type = 'list'; + + } + + return type + +}; + +/** + * @author lth / https://github.com/lo-th + */ + +class Gui { + + constructor( o = {} ) { + + this.isGui = true; + + this.name = 'gui'; + + // for 3d + this.canvas = null; + this.screen = null; + this.plane = o.plane || null; + + + + // color + if( o.config ) o.colors = o.config; + + if ( o.colors ) this.setConfig( o.colors ); + else this.colors = Tools.defineColor( o ); + + // style + this.css = Tools.cloneCss(); + + this.isReset = true; + this.tmpAdd = null; + //this.tmpH = 0 + + this.isCanvas = o.isCanvas || false; + this.isCanvasOnly = false; + + this.callback = o.callback === undefined ? null : o.callback; + + this.forceHeight = o.maxHeight || 0; + this.lockHeight = o.lockHeight || false; + + this.isItemMode = o.itemMode !== undefined ? o.itemMode : false; + + this.cn = ''; + + // size define + this.size = Tools.size; + if( o.p !== undefined ) this.size.p = o.p; + if( o.w !== undefined ) this.size.w = o.w; + if( o.h !== undefined ) this.size.h = o.h; + if( o.s !== undefined ) this.size.s = o.s; + + this.size.h = this.size.h < 11 ? 11 : this.size.h; + + // local mouse and zone + this.local = new V2().neg(); + this.zone = { x:0, y:0, w:this.size.w, h:0 }; + + // virtual mouse + this.mouse = new V2().neg(); + + this.h = 0; + //this.prevY = -1; + this.sw = 0; + + + + // bottom and close height + this.isWithClose = o.close !== undefined ? o.close : true; + this.bh = !this.isWithClose ? 0 : this.size.h; + + this.autoResize = o.autoResize === undefined ? true : o.autoResize; + + // default position + this.isCenter = o.center || false; + this.cssGui = o.css !== undefined ? o.css : (this.isCenter ? '' : 'right:10px;'); + + this.isOpen = o.open !== undefined ? o.open : true; + this.isDown = false; + this.isScroll = false; + + this.uis = []; + this.current = -1; + this.proto = null; + this.isEmpty = true; + this.decal = 0; + this.ratio = 1; + this.oy = 0; + + + this.isNewTarget = false; + + let cc = this.colors; + + this.content = Tools.dom( 'div', this.css.basic + ' width:0px; height:auto; top:0px; background:'+cc.content+'; ' + this.cssGui ); + + this.innerContent = Tools.dom( 'div', this.css.basic + 'width:100%; top:0; left:0; height:auto; overflow:hidden;'); + //this.innerContent = Tools.dom( 'div', this.css.basic + this.css.button + 'width:100%; top:0; left:0; height:auto; overflow:hidden;'); + this.content.appendChild( this.innerContent ); + + //this.inner = Tools.dom( 'div', this.css.basic + 'width:100%; left:0; ') + this.useFlex = true; + let flexible = this.useFlex ? 'display:flex; flex-flow: row wrap;' : ''; //' display:flex; justify-content:start; align-items:start;flex-direction: column; justify-content: center; align-items: center;'; + this.inner = Tools.dom( 'div', this.css.basic + flexible + 'width:100%; left:0; '); + this.innerContent.appendChild(this.inner); + + // scroll + this.scrollBG = Tools.dom( 'div', this.css.basic + 'right:0; top:0; width:'+ (this.size.s - 1) +'px; height:10px; display:none; background:'+cc.background+';'); + this.content.appendChild( this.scrollBG ); + + this.scroll = Tools.dom( 'div', this.css.basic + 'background:'+cc.button+'; right:2px; top:0; width:'+(this.size.s-4)+'px; height:10px;'); + this.scrollBG.appendChild( this.scroll ); + + // bottom button + this.bottomText = o.bottomText || ['open', 'close']; + + let r = cc.radius; + this.bottom = Tools.dom( 'div', this.css.txt + 'width:100%; top:auto; bottom:0; left:0; border-bottom-right-radius:'+r+'px; border-bottom-left-radius:'+r+'px; justify-content:center; height:'+this.bh+'px; line-height:'+(this.bh-5)+'px; color:' + cc.text+';' );// border-top:1px solid '+Tools.colors.stroke+';'); + this.content.appendChild( this.bottom ); + this.bottom.textContent = this.isOpen ? this.bottomText[1] : this.bottomText[0]; + this.bottom.style.background = cc.background; + + // + + this.parent = o.parent !== undefined ? o.parent : null; + this.parent = o.target !== undefined ? o.target : this.parent; + + if( this.parent === null && !this.isCanvas ){ + this.parent = document.body; + } + + if( this.parent !== null ) this.parent.appendChild( this.content ); + + if( this.isCanvas && this.parent === null ) this.isCanvasOnly = true; + + if( !this.isCanvasOnly ){ + this.content.style.pointerEvents = 'auto'; + } else { + this.content.style.left = '0px'; + this.content.style.right = 'auto'; + o.transition = 0; + } + + + // height transition + this.transition = o.transition || Tools.transition; + if( this.transition ) setTimeout( this.addTransition.bind( this ), 0 ); + + + this.setWidth(); + + if( this.isCanvas ) this.makeCanvas(); + + Roots.add( this ); + + } + + setTop( t, h ) { + + this.content.style.top = t + 'px'; + if( h !== undefined ) this.forceHeight = h; + this.calc(); + + Roots.needReZone = true; + + } + + addTransition(){ + + if( this.transition && !this.isCanvas ){ + this.innerContent.style.transition = 'height '+this.transition+'s ease-out'; + this.content.style.transition = 'height '+this.transition+'s ease-out'; + this.bottom.style.transition = 'top '+this.transition+'s ease-out'; + //this.bottom.addEventListener("transitionend", Roots.resize, true); + } + + } + + // ---------------------- + // CANVAS + // ---------------------- + + onDraw () {} + + makeCanvas () { + + this.canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', "canvas" ); + this.canvas.width = this.zone.w; + this.canvas.height = this.forceHeight ? this.forceHeight : this.zone.h; + + //console.log( this.canvas.width, this.canvas.height ) + + } + + draw ( force ) { + + if( this.canvas === null ) return; + + let w = this.zone.w; + let h = this.forceHeight ? this.forceHeight : this.zone.h; + Roots.toCanvas( this, w, h, force ); + + } + + ////// + + getDom () { + + return this.content; + + } + + noMouse () { + + this.mouse.neg(); + + } + + setMouse ( uv, flip = true ) { + + if(flip) this.mouse.set( Math.round( uv.x * this.canvas.width ), this.canvas.height - Math.round( uv.y * this.canvas.height ) ); + else this.mouse.set( Math.round( uv.x * this.canvas.width ), Math.round( uv.y * this.canvas.height ) ); + //this.mouse.set( m.x, m.y ); + + } + + setConfig ( o ) { + + // reset to default text + Tools.setText(); + this.colors = Tools.defineColor( o ); + + } + + setColors ( o ) { + + for( let c in o ){ + if( this.colors[c] ) this.colors[c] = o[c]; + } + + } + + setText ( size, color, font, shadow ) { + + Tools.setText( size, color, font, shadow ); + + } + + hide ( b ) { + this.content.style.visibility = b ? 'hidden' : 'visible'; + } + + display( v = false ) { + this.content.style.visibility = v ? 'visible' : 'hidden'; + } + + onChange ( f ) { + + this.callback = f || null; + return this; + + } + + // ---------------------- + // STYLES + // ---------------------- + + mode ( n ) { + + let needChange = false; + let cc = this.colors; + + if( n !== this.cn ){ + + this.cn = n; + + switch( n ){ + + case 'def': + Roots.cursor(); + this.scroll.style.background = cc.button; + this.bottom.style.background = cc.background; + this.bottom.style.color = cc.text; + break; + + //case 'scrollDef': this.scroll.style.background = this.colors.scroll; break; + case 'scrollOver': + Roots.cursor('ns-resize'); + this.scroll.style.background = cc.select; + break; + case 'scrollDown': + this.scroll.style.background = cc.select; + break; + + //case 'bottomDef': this.bottom.style.background = this.colors.background; break; + case 'bottomOver': + Roots.cursor('pointer'); + this.bottom.style.background = cc.backgroundOver; + this.bottom.style.color = cc.textOver; + break; + //case 'bottomDown': this.bottom.style.background = this.colors.select; this.bottom.style.color = '#000'; break; + + } + + needChange = true; + + } + + return needChange; + + } + + // ---------------------- + // TARGET + // ---------------------- + + clearTarget () { + + if( this.current === -1 ) return false; + if( this.proto.s ){ + // if no s target is delete !! + this.proto.uiout(); + this.proto.reset(); + } + + this.proto = null; + this.current = -1; + + ///console.log(this.isDown)//if(this.isDown)Roots.clearInput(); + + + + Roots.cursor(); + return true; + + } + + // ---------------------- + // ZONE TEST + // ---------------------- + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + this.isReset = false; + + let name = ''; + + let s = this.isScroll ? this.zone.w - this.size.s : this.zone.w; + + if( l.y > this.zone.h - this.bh && l.y < this.zone.h ) name = 'bottom'; + else name = l.x > s ? 'scroll' : 'content'; + + return name; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + handleEvent ( e ) { + + let type = e.type; + + let change = false; + let protoChange = false; + + let name = this.testZone( e ); + + if( type === 'mouseup' && this.isDown ) this.isDown = false; + if( type === 'mousedown' && !this.isDown ) this.isDown = true; + + if( this.isDown && this.isNewTarget ){ Roots.clearInput(); this.isNewTarget=false; } + + if( !name ) return; + + switch( name ){ + + case 'content': + + e.clientY = this.isScroll ? e.clientY + this.decal : e.clientY; + + if( Roots.isMobile && type === 'mousedown' ) this.getNext( e, change ); + + if( this.proto ) protoChange = this.proto.handleEvent( e ); + + if( type === 'mousemove' ) change = this.mode('def'); + if( type === 'wheel' && !protoChange && this.isScroll ) change = this.onWheel( e ); + + if( !Roots.lock ) { + this.getNext( e, change ); + } + + break; + case 'bottom': + + this.clearTarget(); + if( type === 'mousemove' ) change = this.mode('bottomOver'); + if( type === 'mousedown' ) { + this.isOpen = this.isOpen ? false : true; + this.bottom.textContent = this.isOpen ? this.bottomText[1] : this.bottomText[0]; + //this.setHeight(); + this.calc(); + this.mode('def'); + change = true; + } + + break; + case 'scroll': + + this.clearTarget(); + if( type === 'mousemove' ) change = this.mode('scrollOver'); + if( type === 'mousedown' ) change = this.mode('scrollDown'); + if( type === 'wheel' ) change = this.onWheel( e ); + if( this.isDown ) this.update( (e.clientY-this.zone.y)-(this.sh*0.5) ); + + break; + + + } + + if( this.isDown ) change = true; + if( protoChange ) change = true; + + if( type === 'keyup' ) change = true; + if( type === 'keydown' ) change = true; + + if( change ) this.draw(); + + } + + getNext ( e, change ) { + + + + let next = Roots.findTarget( this.uis, e ); + + if( next !== this.current ){ + this.clearTarget(); + this.current = next; + + this.isNewTarget = true; + + } + + if( next !== -1 ){ + this.proto = this.uis[ this.current ]; + this.proto.uiover(); + } + + } + + onWheel ( e ) { + + this.oy += 20*e.delta; + this.update( this.oy ); + return true; + + } + + // ---------------------- + // RESET + // ---------------------- + + reset ( force ) { + + if( this.isReset ) return; + + //this.resetItem(); + + this.mouse.neg(); + this.isDown = false; + + //Roots.clearInput(); + let r = this.mode('def'); + let r2 = this.clearTarget(); + + if( r || r2 ) this.draw( true ); + + this.isReset = true; + + //Roots.lock = false; + + } + + // ---------------------- + // ADD NODE + // ---------------------- + + add () { + + let a = arguments; + let ontop = false; + + if( typeof a[1] === 'object' ){ + + a[1].isUI = true; + a[1].main = this; + + ontop = a[1].ontop ? a[1].ontop : false; + + } else if( typeof a[1] === 'string' ){ + + if( a[2] === undefined ) [].push.call(a, { isUI:true, main:this }); + else { + a[2].isUI = true; + a[2].main = this; + //ontop = a[1].ontop ? a[1].ontop : false; + ontop = a[2].ontop ? a[2].ontop : false; + } + + } + + let u = add.apply( this, a ); + + if( u === null ) return; + + if( ontop ) this.uis.unshift( u ); + else this.uis.push( u ); + + this.calc(); + + this.isEmpty = false; + + return u + + } + + // remove one node + + remove ( n ) { + + if( n.dispose ) n.dispose(); + + } + + // call after uis clear + + clearOne ( n ) { + + let id = this.uis.indexOf( n ); + if ( id !== -1 ) { + //this.calc( - (this.uis[ id ].h + 1 ) ); + this.inner.removeChild( this.uis[ id ].c[0] ); + this.uis.splice( id, 1 ); + this.calc(); + } + + } + + // clear all gui + + empty() { + + //this.close(); + + let i = this.uis.length, item; + + while( i-- ){ + item = this.uis.pop(); + this.inner.removeChild( item.c[0] ); + item.dispose(); + } + + this.uis = []; + this.isEmpty = true; + this.calc(); + + } + + clear() { + + this.empty(); + + } + + dispose() { + + this.clear(); + if( this.parent !== null ) this.parent.removeChild( this.content ); + Roots.remove( this ); + + } + + + // ---------------------- + // ITEMS SPECIAL + // ---------------------- + + resetItem () { + + if( !this.isItemMode ) return; + + let i = this.uis.length; + while(i--) this.uis[i].selected(); + + } + + setItem ( name ) { + + if( !this.isItemMode ) return; + + name = name || ''; + this.resetItem(); + + if( !name ){ + this.update(0); + return + } + + let i = this.uis.length; + while(i--){ + if( this.uis[i].value === name ){ + this.uis[i].selected( true ); + if( this.isScroll ) this.update( ( i*(this.uis[i].h+1) )*this.ratio ); + } + } + + } + + + + // ---------------------- + // SCROLL + // ---------------------- + + upScroll ( b ) { + + this.sw = b ? this.size.s : 0; + this.oy = b ? this.oy : 0; + this.scrollBG.style.display = b ? 'block' : 'none'; + + if( b ){ + + this.total = this.h; + + this.maxView = this.maxHeight; + + this.ratio = this.maxView / this.total; + this.sh = this.maxView * this.ratio; + + this.range = this.maxView - this.sh; + + this.oy = Tools.clamp( this.oy, 0, this.range ); + + this.scrollBG.style.height = this.maxView + 'px'; + this.scroll.style.height = this.sh + 'px'; + + } + + this.setItemWidth( this.zone.w - this.sw ); + this.update( this.oy ); + + } + + update ( y ) { + + y = Tools.clamp( y, 0, this.range ); + + this.decal = Math.floor( y / this.ratio ); + this.inner.style.top = - this.decal + 'px'; + this.scroll.style.top = Math.floor( y ) + 'px'; + this.oy = y; + + } + + // ---------------------- + // RESIZE FUNCTION + // ---------------------- + + calcUis() { + + return Roots.calcUis( this.uis, this.zone, this.zone.y ) + } + + calc() { + + clearTimeout( this.tmp ); + this.tmp = setTimeout( this.setHeight.bind( this ), 10 ); + + } + + setHeight() { + + if( this.tmp ) clearTimeout( this.tmp ); + + this.zone.h = this.bh; + this.isScroll = false; + + if( this.isOpen ){ + + this.h = this.calcUis(); + + let hhh = this.forceHeight ? this.forceHeight + this.zone.y : window.innerHeight; + + this.maxHeight = hhh - this.zone.y - this.bh; + + let diff = this.h - this.maxHeight; + + if( diff > 1 ){ + + this.isScroll = true; + this.zone.h = this.maxHeight + this.bh; + + } else { + + this.zone.h = this.h + this.bh; + + } + + } + + this.upScroll( this.isScroll ); + + this.innerContent.style.height = this.zone.h - this.bh + 'px'; + this.content.style.height = this.zone.h + 'px'; + this.bottom.style.top = this.zone.h - this.bh + 'px'; + + + if( this.forceHeight && this.lockHeight ) this.content.style.height = this.forceHeight + 'px'; + + if( this.isCanvas ) this.draw( true ); + + } + + rezone () { + Roots.needReZone = true; + } + + setWidth ( w ) { + + if( w ) this.zone.w = w; + + this.zone.w = Math.floor( this.zone.w ); + + this.content.style.width = this.zone.w + 'px'; + + if( this.isCenter ) this.content.style.marginLeft = -(Math.floor(this.zone.w*0.5)) + 'px'; + + this.setItemWidth( this.zone.w - this.sw ); + + } + + setItemWidth ( w ) { + + let i = this.uis.length; + while(i--){ + this.uis[i].setSize( w ); + this.uis[i].rSize(); + } + + } + +} + +const Base = { + + version: '0.8.0', + + toolSet: [ + {id:0, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 }, + {id:1, tool:'residential', geo:1, name:'R', build:1, size:3, sy:0.2, price:100, color:'lime' ,drag:1 }, + {id:2, tool:'commercial', geo:2, name:'C', build:1, size:3, sy:0.2, price:100, color:'blue' ,drag:1 }, + {id:3, tool:'industrial', geo:3, name:'I', build:1, size:3, sy:0.2, price:100, color:'yellow' ,drag:1 }, + + {id:4, tool:'police', geo:4, name:'', build:1, size:3, sy:1.2, price:500, color:'blue' ,drag:0 }, + {id:5, tool:'park', geo:5, name:'', build:1, size:1, sy:0.02, price:10, color:'darkgreen' ,drag:0 }, + {id:6, tool:'fire', geo:7, name:'', build:1, size:3, sy:1.2, price:500, color:'red' ,drag:0 }, + + {id:7, tool:'road', geo:0, name:'', build:0, size:1, sy:0.1, price:10, color:'black' ,drag:1 }, + {id:8, tool:'bulldozer', geo:0, name:'', build:0, size:1, sy:0, price:1, color:'deeppink' ,drag:1 }, + {id:9, tool:'rail', geo:0, name:'', build:0, size:1, sy:0.15, price:20, color:'brown' ,drag:1 }, + + {id:10, tool:'coal', geo:8, name:'', build:1, size:4, sy:2, price:3000, color:'gray' ,drag:0 }, + {id:11, tool:'wire', geo:0, name:'', build:0, size:1, sy:0.05, price:5 , color:'khaki' ,drag:1 }, + {id:12, tool:'nuclear', geo:9, name:'', build:1, size:4, sy:2, price:5000, color:'orange' ,drag:0 }, + + {id:13, tool:'port', geo:10, name:'', build:1, size:4, sy:0.5, price:3000, color:'dodgerblue' ,drag:0 }, + {id:14, tool:'stadium', geo:11, name:'', build:1, size:4, sy:2, price:5000, color:'yellowgreen',drag:0 }, + {id:15, tool:'airport', geo:12, name:'', build:1, size:6, sy:0.5, price:10000, color:'lightblue' ,drag:0 }, + + {id:16, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 }, + {id:17, tool:'query', geo:0, name:'?', build:0, size:1, sy:0, price:0, color:'cyan' ,drag:0 }, + {id:18, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 } + ], + + H: [ 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260 ], + R: [ 244, 265, 274, 283, 292, 301, 310, 319, 328, 337, 346, 355, 364, 373, 382, 391, 400, 409, 418 ], + C: [ 427, 436, 445, 454, 463, 475, 481, 490, 499, 508, 517, 526, 535, 544, 553, 562, 571, 580, 589, 598, 607 ], + I: [ 616, 625, 634, 643, 652, 661, 670, 679, 688 ], + +}; + +//------------------------------------------------------// +// HUB INTERFACE // +//------------------------------------------------------// + + +class Hub { + + constructor () { + + this.mapPath = './assets/textures/'; + + this.round = [ + '', + '', + '' + ].join("\n"); + + this.roundSelected = [ + '', + '', + '' + ].join("\n"); + + this.roundSelect = [ + '', + '', + '' + ].join("\n"); + + this.hub = document.getElementById('hub'); + this.full = null; + this.title = null; + + this.isIntro = true; + + this.timer = null; + this.bg = 1; + + this.R=null; + this.C=null; + this.I=null; + + this.isGen = false; + + //this.rrr= null; + + //this.colors = ['#ffffff', '#338099']; + this.colors = ['rgba(255,255,255,1)', 'rgba(0,0,0,0.2)', 'rgba(0,0,0,1)', 'rgba(0,0,0,0.5)', 'rgba(0,0,0,0.8)', 'rgba(255,255,255,0.5)']; + + //this.radius = "-moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px;"; + this.radius = "-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;"; + this.radiusL = "-moz-border-top-left-radius: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px;"; + this.radiusL += "-moz-border-bottom-left-radius: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;"; + this.radiusR = "-moz-border-top-right-radius: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px;"; + this.radiusR += "-moz-border-bottom-right-radius: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px;"; + + this.radiusB = "-moz-border-bottom-left-radius: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;"; + this.radiusB += "-moz-border-bottom-right-radius: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px;"; + + this.windowsStyle = ' top:40px; left:10px; border:1px solid '+this.colors[1]+'; background:'+this.colors[3]+';'; + + + this.budgetWindow = null; + this.evaluationWindow = null; + this.disasterWindow = null; + this.exitWindow = null; + this.queryWindow = null; + this.overlaysWindow = null; + this.aboutWindow = null; + + + this.selector = null; + this.select = null; + + this.currentToolName = 0; + + this.disasterTypes = ['None', 'Monster', 'Fire', 'Flood', 'Crash', 'Meltdown', 'Tornado']; + this.disasterButtons = []; + + this.overlaysTypes = ['None', 'Density', 'Growth', 'Land value', 'Crime Rate', 'Pollution', 'Traffic', 'Power Grid', 'Fire', 'Police']; + this.overlaysButtons = []; + + + //this.intro(); + + + + this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:0px; left:0px; width:100%; height:100%; pointer-events:none; display:block; background:rgba(144,163,183,1); '; //+ this.degrade(); + + this.text = document.createElement('div'); + this.text.style.cssText = 'position:absolute; font-size:18px; left:calc(50% - 150px); top:calc(50% + 80px); width:300px; height:80px; pointer-events:none; text-align:center; font-weight: bold;'; + this.text.innerHTML = "欢迎"; + + + this.loader = document.getElementById('loader'); + this.loader.style.cssText = 'pointer-events:none; position:absolute; left:calc(50% - 100px); top:calc(50% - 100px); width:200px; height:200px;'; + + + /*this.link = document.createElement('div'); + this.link.style.cssText = 'position:absolute; left:10px; bottom:10px; width:50px; height:50px; pointer-events:auto; display:block;'; + this.link.innerHTML = '' + UIL.Tools.icon('github', '#DEDEDE', 50) + ''; + this.hub.appendChild( this.link )*/ + + this.link = add('button', { + target:this.hub, w:64, h:64, pos:{left:'10px', bottom:'10px'}, simple:true, + button:'#8397ac' + }).icon( Tools.icon('github', '#DEDEDE', 50) ).onChange( function(v){ window.open('https://github.com/lo-th/3d.city','_blank'); } ); + + this.donate = add('button', { + target:this.hub, w:64, h:64, pos:{left:'84px', bottom:'10px'}, simple:true, + button:'#8397ac' + }).icon( Tools.icon('donate', '#DEDEDE', 50) ).onChange( function(v){ window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8KTXA987XHYNQ','_blank'); } ); + + + + this.version = document.createElement('div'); + this.version.style.cssText = 'position:absolute; font-size:14px; right:10px; bottom:10px; text-align:right; width:100px; pointer-events:none; display:block;'; + this.version.innerHTML = "v " + Base.version; + this.hub.appendChild( this.version ); + + + + /*this.fullMid.appendChild( this.logo ); + this.fullMid.appendChild( this.title ); + this.fullMid.appendChild( this.subtitle );*/ + + this.hub.appendChild( this.full ); + this.hub.appendChild( this.loader ); + this.hub.appendChild( this.text ); + } + + message ( s ){ + + if( this.text ) this.text.innerHTML = s; + + } + + /*intro (){ + + this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:0px; left:0px; width:100%; height:100%; pointer-events:none; display:block; background:rgba(102,102,230,1); ' //+ this.degrade(); + + this.fullMid = document.createElement('div'); + this.fullMid.style.cssText ='position:absolute; top:10px; left:50%; width:300px; height:300px; margin-left:-150px; pointer-events:none; display:block;'; + + this.title = document.createElement('div'); + this.title.innerHTML = "3D.CITY"; + this.title.style.cssText = 'position:absolute; font-size:44px; top:50%; left:0; margin-top:-30px; width:300px; height:60px; pointer-events:none; text-align:center;'; + + this.subtitle = document.createElement('div'); + this.subtitle.style.cssText = 'position:absolute; font-size:14px; top:50%; left:0; margin-top:20px; width:300px; height:80px; pointer-events:none; text-align:center;'; + this.subtitle.innerHTML = "Generating world..."; + + this.logo = document.getElementById('logo'); + this.logo.style.display = 'block'; + + this.full.appendChild( this.fullMid ); + + this.fullMid.appendChild( this.logo ); + this.fullMid.appendChild( this.title ); + this.fullMid.appendChild( this.subtitle ); + + this.hub.appendChild( this.full ); + + }*/ + + start (){ + if(this.isIntro){ + this.timer = setInterval(this.fadding, 100, this); + } + } + + fadding (t){ + t.bg -= 0.1; + t.full.style.background = 'rgba(144,163,183,'+t.bg+')'; + // background-image:linear-gradient(60deg, white, black); + if(t.bg<=0){ + clearInterval(t.timer); + t.hub.removeChild(t.loader); + t.hub.removeChild(t.text); + t.hub.removeChild(t.full); + + console.log('done'); + + //t.initPrevHub(); + t.isIntro = false; + } + } + + generate( b ) { + + if( b ){ + if(!this.isGen) { + this.hub.appendChild( this.loader ); + this.hub.appendChild( this.text ); + this.text.innerHTML = '正在生成地图...'; + this.isGen = true; + } + } else { + if( this.isGen ){ + this.hub.removeChild( this.loader ); + this.hub.removeChild( this.text ); + this.isGen = false; + } + } + + } + + + + /*degrade (){ + var a = -160; + var p = [0, 30, 100] + var c0 = '#BFDDFF'; + var c1 = '#3C89CD'; + var c2 = '#214F77'; + var deg = [ + 'background:-webkit-gradient(linear, top, bottom, color-stop('+p[0]+'%,'+c0+'), color-stop('+p[1]+'%,'+c1+'), color-stop('+p[2]+'%,'+c2+'));', + 'background:-moz-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:-webkit-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:-o-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);' + ].join("\n"); + return deg; + },*/ + + initPrevHub() { + + /*this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:10px; left:50%; margin-left:-150px; width:300px; height:300px; pointer-events:none;'; + this.full.id = 'fullStart';*/ + + //this.hub.appendChild( this.full ); + //var b1 = this.addButton(this.full, 'Play Game', [276,48,40], 'position:absolute; top:10px; left:0px;'); + //let b2 = this.addButton(this.full, 'New Map', [276, 26, 22], 'position:absolute; top:150px; left:0px;'); + //var b3 = this.addButton(this.full, 'Height Map', [120, 26, 22], 'position:absolute; top:150px; right:0px;'); + //let b4 = this.addButton(this.full, 'Load Map', [276, 26, 22], 'position:absolute; top:90px; left:0px;'); + //this.addSelector("DIFFICULTY", ['LOW', 'MEDIUM', 'HARD'], Main.setDifficulty, 0); + + //b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.playMap(); }, false); + //b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.newMap(); }, false); + // b3.addEventListener('click', function ( e ) { e.preventDefault(); Main.newHeightMap(); }, false); + //b4.addEventListener('click', function ( e ) { e.preventDefault(); Main.loadGame(true); }, false); + + } + + //--------------------------------------start hub + + initStartHub() { + + /* this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:10px; left:50%; margin-left:-150px; width:300px; height:300px; pointer-events:none;'; + this.full.id = 'fullStart'; + + this.hub.appendChild( this.full ); + var b1 = this.addButton(this.full, 'Play Game', [276,48,40], 'position:absolute; top:10px; left:0px;'); + var b2 = this.addButton(this.full, 'New Map', [120, 26, 22], 'position:absolute; top:150px; left:0px;'); + var b3 = this.addButton(this.full, 'Height Map', [120, 26, 22], 'position:absolute; top:150px; right:0px;'); + var b4 = this.addButton(this.full, 'Load Map', [276, 26, 22], 'position:absolute; top:90px; left:0px;'); + this.addSelector("DIFFICULTY", ['LOW', 'MEDIUM', 'HARD'], Main.setDifficulty, 0); + + b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.playMap(); }, false); + b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.newMap(); }, false); + b3.addEventListener('click', function ( e ) { e.preventDefault(); Main.newHeightMap(); }, false); + b4.addEventListener('click', function ( e ) { e.preventDefault(); Main.loadGame(true); }, false);*/ + + } + + + //--------------------------------------game hub + + initGameHub (){ + + this.link.dispose(); + this.donate.dispose(); + + var _this = this; + //this.removeSelector("DIFFICULTY"); + //this.clearElement('fullStart'); + + this.toolScroll = document.createElement('div'); + this.toolScroll.style.cssText = 'position:absolute; margin:0px; padding:0px; top:60px; right:12px; width:198px; max-height:calc(100% - 80px); overflow-y:auto; overflow-x:hidden; pointer-events:auto; touch-action:pan-y; -webkit-overflow-scrolling:touch;'; + this.hub.appendChild( this.toolScroll ); + + // prevent camera gestures when scrolling tools on mobile + this.toolScroll.addEventListener('touchstart', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('touchmove', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('pointerdown', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('pointermove', (e) => e.stopPropagation(), { passive: true }); + + this.toolSet = document.createElement('div'); + this.toolSet.style.cssText ='position:relative; margin:0px; padding:0px; width:198px; height:456px; pointer-events:none;'; + this.toolScroll.appendChild( this.toolSet ); + this.toolInfo = document.createElement('div'); + this.toolInfo.style.cssText ='position:absolute; top:15px; right:12px; width:198px; height:50px; pointer-events:none; font-size:16px;'; + this.hub.appendChild( this.toolInfo ); + this.toolInfo.innerHTML = "选择
工具"; + + var b; + for(var i = 0; i<18; i++){ + b = this.addSVGButton(this.toolSet); + b.name = i+1; + } + + this.selector = document.createElement('div'); + this.selector.style.cssText = "position:absolute; top:0px; left:0px; pointer-events:none; display:none;"; + this.selector.innerHTML = this.roundSelected; + this.toolSet.appendChild( this.selector ); + + this.select = document.createElement('div'); + this.select.style.cssText = "position:absolute; top:0px; left:0px; pointer-events:none; display:none;"; + this.select.innerHTML = this.roundSelect; + this.toolSet.appendChild( this.select ); + + var img = document.createElement("img"); + img.src = this.mapPath + "interface.png"; + this.toolSet.appendChild(img); + img.style.cssText ='position:absolute; margin:0px; padding:0px; top:0px; right:0px; width:198px; height:396px; pointer-events:none;'; + + this.addSelector("Speed", ['II', '>', '>>', '>>>', '>>>'], Main.setSpeed, 2, [20,20,20,20,20]); + + var b1 = this.addButton(this.hub, '预算', [75,16,14], 'position:absolute; left:10px; top:-7px; font-weight:bold;', true); + b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.getBudjet(); }, false); + + var b2 = this.addButton(this.hub, '评估', [75,16,14], 'position:absolute; left:110px; top:-7px; font-weight:bold;', true); + b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.getEval(); }, false); + + /*var b3 = this.addButton(this.hub, 'Disaster', [75,16,14], 'position:absolute; left:210px; top:-7px; font-weight:bold;', true); + b3.addEventListener('click', function ( e ) { e.preventDefault(); _this.openDisaster(); }, false);*/ + + var b4 = this.addButton(this.hub, '退出', [75,16,14], 'position:absolute; left:310px; top:-7px; font-weight:bold;', true); + b4.addEventListener('click', function ( e ) { e.preventDefault(); _this.openExit(); }, false); + + var b5 = this.addButton(this.hub, '关于', [75,16,14], 'position:absolute; left:410px; top:-7px; font-weight:bold;', true); + b5.addEventListener('click', function ( e ) { e.preventDefault(); _this.openAbout(); }, false); + + + this.H = []; + + + this.roo = document.createElement('div'); + this.roo.style.cssText = "position:absolute; bottom:11px; left:10px; width:60px; height:60px; pointer-events:none; transform:rotate(45deg); "; + this.roo.style.cssText += "-moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; overflow:hidden; "; + this.hub.appendChild( this.roo ); + + var dd; + for(i = 0; i<4; i++){ + dd = document.createElement('div'); + if(i==0)dd.style.cssText = "position:absolute; top:0px; left:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer; background:#ffffff;"; + if(i==1)dd.style.cssText = "position:absolute; top:0px; right:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + if(i==2)dd.style.cssText = "position:absolute; bottom:0px; right:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + if(i==3)dd.style.cssText = "position:absolute; bottom:0px; left:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + dd.name = i; + this.roo.appendChild( dd ); + dd.addEventListener('click', function ( e ) { + e.preventDefault(); + _this.hideoldSel(); + _this.H[this.name].style.background = '#ffffff'; + Main.setTimeColors(this.name); + }, false); + this.H[i]=dd; + } + + + var winter = document.createElement("div"); + winter.style.cssText = "position:absolute; bottom:80px; left:25px; width:30px; height:30px; pointer-events:auto; cursor:pointer; background:rgba(0,0,0,0); "; + winter.style.cssText += "-moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; "; + this.hub.appendChild(winter); + + winter.addEventListener('click', function ( e ) { + view3d.winterSwitch(); + if(view3d.isWinter) this.style.background = 'rgba(255,255,255,0.5);'; + else this.style.background = 'rgba(0,0,0,0);'; + }, false); + + this.bottomMenuImg = document.createElement("img"); + this.bottomMenuImg.src = this.mapPath + "basemenu.png"; + this.hub.appendChild(this.bottomMenuImg); + this.bottomMenuImg.style.cssText ='position:absolute; margin:0px; padding:0px; bottom:0px; left:0px; width:630px; height:120px; pointer-events:none;'; + + this.initCITYinfo(); + + // Apply responsive layout + if( this.updateLayout ) this.updateLayout(); + } + + hideoldSel (){ + for(var i = 0; i<4; i++){ + this.H[i].style.background = 'none'; + } + } + + //-----------------------------------CITY INFO + + initCITYinfo (){ + + this.date = document.createElement('div'); + this.date.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:65px; text-align:right; font-weight:bold;'; + + this.money = document.createElement('div'); + this.money.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:295px; text-align:right; font-weight:bold;'; + + this.population = document.createElement('div'); + this.population.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:180px; text-align:right; font-weight:bold;'; + + this.score = document.createElement('div'); + this.score.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:410px; text-align:right; font-weight:bold;'; + + this.msg = document.createElement('div'); + this.msg.style.cssText = 'font-size:14px; letter-spacing:0.02em; position:absolute; width:420px; height:20px; bottom:44px; left:76px; text-align:left; color:'+this.colors[4]+'; font-weight:bold;'; + + this.hub.appendChild( this.date ); + this.hub.appendChild( this.money ); + this.hub.appendChild( this.population ); + this.hub.appendChild( this.score ); + this.hub.appendChild( this.msg ); + + this.initRCI(); + } + + updateLayout() { + if (!this.toolSet && !this.toolScroll) return; + + const w = window.innerWidth; + const h = window.innerHeight; + + // Tool list: keep buttons large, scroll vertically when space is limited + if (this.toolScroll) { + const top = w < 600 ? 40 : w < 768 ? 50 : 60; + this.toolScroll.style.top = `${top}px`; + this.toolScroll.style.maxHeight = `${Math.max(240, h - top - 20)}px`; + } + + // Update tool info + if (this.toolInfo) { + if (w < 600) { + this.toolInfo.style.transform = 'scale(0.6)'; + this.toolInfo.style.transformOrigin = 'top right'; + } else if (w < 768) { + this.toolInfo.style.transform = 'scale(0.75)'; + this.toolInfo.style.transformOrigin = 'top right'; + } else { + this.toolInfo.style.transform = 'scale(1)'; + } + } + + // Update bottom menu image + if (this.bottomMenuImg) { + if (w < 630) { + const menuScale = w / 630; + this.bottomMenuImg.style.transform = `scale(${menuScale})`; + this.bottomMenuImg.style.transformOrigin = 'bottom left'; + } else { + this.bottomMenuImg.style.transform = 'scale(1)'; + } + } + + // Update city info positions for small screens + this.updateCityInfoLayout(w); + } + + updateCityInfoLayout(w) { + if (!this.date) return; + + if (w < 480) { + const scale = w / 480; + if (this.date) this.date.style.transform = `scale(${scale})`; + if (this.money) this.money.style.transform = `scale(${scale})`; + if (this.population) this.population.style.transform = `scale(${scale})`; + if (this.score) this.score.style.transform = `scale(${scale})`; + if (this.msg) { + this.msg.style.width = (w - 80) + 'px'; + this.msg.style.fontSize = '12px'; + } + } else if (w < 630) { + const scale = w / 630; + if (this.date) { + this.date.style.transform = `scale(${scale})`; + this.date.style.transformOrigin = 'bottom left'; + } + if (this.money) { + this.money.style.transform = `scale(${scale})`; + this.money.style.transformOrigin = 'bottom left'; + } + if (this.population) { + this.population.style.transform = `scale(${scale})`; + this.population.style.transformOrigin = 'bottom left'; + } + if (this.score) { + this.score.style.transform = `scale(${scale})`; + this.score.style.transformOrigin = 'bottom left'; + } + if (this.msg) { + this.msg.style.width = (w - 80) + 'px'; + } + } else { + if (this.date) this.date.style.transform = 'scale(1)'; + if (this.money) this.money.style.transform = 'scale(1)'; + if (this.population) this.population.style.transform = 'scale(1)'; + if (this.score) this.score.style.transform = 'scale(1)'; + if (this.msg) this.msg.style.width = '420px'; + } + } + + updateCITYinfo (infos){ + this.date.innerHTML = infos[0]; + this.money.innerHTML = infos[4]; + this.population.innerHTML = infos[3]; + this.score.innerHTML = infos[2]; + + this.msg.innerHTML = infos[8]; + + this.updateRCI( infos[5], infos[6], infos[7] ); + } + + //-----------------------------------QUERY + + //-----------------------------------ALL WINDOW + + testOpen (){ + var t = ""; + if(this.budgetWindow !== null && this.budgetWindow.className == "open"){ + this.closeBudget(); + t = 'budget'; + } + if(this.evaluationWindow !== null && this.evaluationWindow.className == "open"){ + this.closeEval(); + t = 'evaluation'; + } + if(this.disasterWindow !== null && this.disasterWindow.className == "open"){ + this.closeDisaster(); + t = 'disaster'; + } + if(this.exitWindow !== null && this.exitWindow.className == "open"){ + this.closeExit(); + t = 'exit'; + } + if(this.queryWindow !== null && this.queryWindow.className == "open"){ + this.closeQuery(); + t = 'query'; + } + if(this.overlaysWindow !== null && this.overlaysWindow.className == "open"){ + this.closeOverlays(); + t = 'overlays'; + } + if(this.aboutWindow !== null && this.aboutWindow.className == "open"){ + this.closeAbout(); + t = 'about'; + } + + return t; + + } + + //-----------------------------------ABOUT WINDOW + + openAbout (data){ + var _this = this; + + var test = this.testOpen(); + if(test == 'about') return; + + if(this.aboutWindow == null){ + this.aboutWindow = document.createElement('div'); + this.aboutWindow.style.cssText = this.radius+ 'position:absolute; width:200px; height:210px; pointer-events:none; display:block;'+ this.windowsStyle; + this.hub.appendChild( this.aboutWindow ); + var bg1 = this.addButton(this.aboutWindow, 'X', [16,16,14], 'position:absolute; left:10px; top:10px;'); + bg1.addEventListener('click', function(e){ e.preventDefault(); _this.closeAbout(); }, false); + + this.fps = document.createElement('div'); + this.fps.style.cssText ='position:absolute; top:20px; left:60px; width:120px; height:20px; pointer-events:none; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.fps ); + this.abb = document.createElement('div'); + this.abb.style.cssText ='position:absolute; top:60px; left:10px; width:180px; height:180px; pointer-events:none; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.abb ); + this.linke = document.createElement('div'); + this.linke.style.cssText ='position:absolute; top:160px; left:10px; width:180px; height:20px; pointer-events:auto; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.linke ); + + this.abb.innerHTML = "3D 城市

3D 部分:Lo.th
模拟核心:MicropolisJS


更多信息与源码:
"; + this.linke.innerHTML = "https://github.com/lo-th/3d.city"; + + + + } else { + this.aboutWindow.style.display = 'block'; + } + + Main.showStats(); + + this.aboutWindow.className = "open"; + + } + + upStats (fps, memory){ + this.fps.innerHTML = '帧率:'+ fps + '
几何体:' + memory; + } + + closeAbout (){ + Main.hideStats(); + + this.aboutWindow.style.display = 'none'; + this.aboutWindow.className = "close"; + } + + + //-----------------------------------OVERLAYS WINDOW + + openOverlays (data){ + + var test = this.testOpen(); + if(test == 'overlays') return; + + if(this.overlaysWindow == null){ + this.overlaysWindow = document.createElement('div'); + this.overlaysWindow.style.cssText = this.radius+ 'position:absolute; width:140px; height:420px; pointer-events:none; display:block;'+ this.windowsStyle; this.hub.appendChild( this.overlaysWindow ); + + //var bg1 = this.addButton(this.overlaysWindow, 'X', [16,16,14], 'position:absolute; left:50px; top:10px;'); + //bg1.addEventListener('click', function(e){ e.preventDefault(); _this.closeQuery(); }, false); + + var overlayLabelMap = { None:'无', Density:'密度', Growth:'增长', 'Land value':'地价', 'Crime Rate':'犯罪率', Pollution:'污染', Traffic:'交通', 'Power Grid':'电网', Fire:'消防', Police:'警察' }; + for(var i=0; i税收:" + taxesCollected + "¥"; + + this.budgetWindow.className = "open"; + + } + + applyBudget (){ + this.budgetWindow.style.display = 'none'; + this.budgetWindow.className = "close"; + + Main.setBudjet([this.taxRate, this.roadRate, this.fireRate, this.policeRate ]); + } + + closeBudget (){ + this.budgetWindow.style.display = 'none'; + this.budgetWindow.className = "close"; + } + + setBudgetValue (){ + this.setSliderValue('Tax', this.taxRate, 20, null); + this.setSliderValue('Roads', this.roadRate, 100, this.roadFund); + this.setSliderValue('Fire', this.fireRate, 100, this.fireFund); + this.setSliderValue('Police', this.policeRate, 100, this.policeFund); + } + + //-----------------------------------DISASTER WINDOW + + openDisaster (){ + var test = this.testOpen(); + if(test == 'disaster') return; + if(this.disasterWindow == null){ + this.disasterWindow = document.createElement('div'); + this.disasterWindow.style.cssText =this.radius+ 'position:absolute; width:140px; height:300px; pointer-events:none; display:block;'+ this.windowsStyle; this.hub.appendChild( this.disasterWindow ); + + var disasterLabelMap = { None:'无', Monster:'怪兽', Fire:'火灾', Flood:'洪水', Crash:'坠机', Meltdown:'核泄漏', Tornado:'龙卷风' }; + for(var i=0; imax) value = max; + children[0].style.width = 170*(value/max)+'px'; + var labelMap = { Tax:'税率', Roads:'道路', Fire:'消防', Police:'警察' }; + var label = labelMap[t.name] || t.name; + + switch(t.name){ + case 'Tax': children[1].innerHTML = label+" "+value+'%'; this.taxRate = value; break; + case 'Roads': children[1].innerHTML = label+" "+value+'%('+this.roadFund+"¥ × "+value+"% = " + Math.floor(this.roadFund * (value / 100))+"¥)"; this.roadRate = value; break; + case 'Fire': children[1].innerHTML = label+" "+value+'%('+this.fireFund+"¥ × "+value+"% = " + Math.floor(this.fireFund * (value / 100))+"¥)"; this.fireRate = value; break; + case 'Police': children[1].innerHTML = label+" "+value+'%('+this.policeFund+"¥ × "+value+"% = " + Math.floor(this.policeFund * (value / 100))+"¥)"; this.policeRate = value; break; + } + } + } + + + //-----------------------------------RCI + + initRCI (){ + + var cont = document.createElement('div'); + cont.id = 'RCI'; + cont.style.cssText = 'font-size:10px; position:absolute; width:70px; height:70px; bottom:20px; right:20px;'; + + var txt = document.createElement('div'); + txt.style.cssText = 'font-size:10px; position:absolute; width:46px; height:14px; bottom:28px; left:10px; background:#cccccc; padding:0px 2px; letter-spacing:12px; text-align:center; color:#000000;'; + txt.innerHTML = "RCI"; + + this.R = document.createElement('div'); + this.R.id = 'R'; + this.R.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:10px; background:#30ff30;'; + cont.appendChild( this.R ); + + this.C = document.createElement('div'); + this.C.id = 'C'; + this.C.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:30px; background:#3030ff;'; + cont.appendChild( this.C ); + + this.I = document.createElement('div'); + this.I.id = 'I'; + this.I.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:50px; background:#ffff30;'; + cont.appendChild( this.I ); + + cont.appendChild( txt ); + this.hub.appendChild( cont ); + } + + updateRCI (r,c,i){ + this.R.style.height = r/100+'px'; + this.C.style.height = c/100+'px'; + this.I.style.height = i/100+'px'; + //console.log(r/100) + if(r>0){ this.R.style.bottom ='42px';} + else { this.R.style.bottom =28+(r/100)+'px';} + + if(c>0){ this.C.style.bottom ='42px';} + else { this.C.style.bottom =28+(c/100)+'px'; } + + if(i>0){ this.I.style.bottom ='42px';} + else { this.I.style.bottom =28+(i/100)+'px'; } + } + + //---------------------------------- SELECTOR + + addSelector ( type, names, fun, current, size){ + var _this = this; + var cont = document.createElement('div'); + //cont.style.cssText = 'position:absolute; width:300px; height:50px; font-size:16px; top:0; left:webkit-clac(50% -150px);'; + cont.style.cssText = 'font-size:14px; margin-top:10px; color:'+this.colors[0]+';'; + if(type=='Speed') cont.style.cssText = 'font-size:20px; position:absolute; bottom:8px; left:497px; '; + else cont.innerHTML = type+"
"; + cont.id = type; + var t = []; + for(var i=0; i!==names.length; i++){ + t[i] = document.createElement( 'div' ); + // t[i].style.cssText = 'font-size:14px; border:4px solid '+this.colors[1]+'; background:'+this.colors[1]+';' + // t[i].style.cssText +=' width:70px; height:16px; margin:4px; padding:4px; pointer-events:auto; cursor:pointer; display:inline-block; font-weight:bold;' + this.radius; + t[i].style.cssText = 'font-size:14px; border:1px solid '+this.colors[5]+'; background:'+this.colors[1]+'; color:'+this.colors[0]+';'; + if(type=='Speed')t[i].style.cssText +=' width:70px; height:16px; margin-left:2px; padding:6px; pointer-events:auto; cursor:pointer; display:inline-block; '; + else t[i].style.cssText +=' width:70px; height:16px; margin:2px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; '; + + if(i==0) t[i].style.cssText += this.radiusL; + if(i==names.length-1)t[i].style.cssText += this.radiusR; + // if(type=='Speed'){ if(i>0) t[i].style.width = '16px'; else t[i].style.width = '60px'; } + if(size){if(size[i]){t[i].style.width = size[i] + 'px'; t[i].style.height = size[i] + 'px'; t[i].style.padding ='0px'; } else t[i].style.width = '60px';} + else t[i].style.width = '60px'; + t[i].className = "none"; + if(type!=='Speed')t[i].textContent = names[i]; + if(i==current){ + //t[i].style.border = '4px solid '+this.colors[0]; + t[i].style.backgroundColor = this.colors[5]; + t[i].style.color = this.colors[2]; + t[i].className = "select"; + } + t[i].name = i; + t[i].id = type+i; + cont.appendChild( t[i] ); + //t[i].addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[0]; }, false ); + //t[i].addEventListener( 'mouseout', function ( e ) { e.preventDefault(); if(this.className == 'none')this.style.border = '4px solid '+_this.colors[1]; }, false ); + + t[i].addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '1px solid '+_this.colors[0]; }, false ); + t[i].addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.border = '1px solid '+_this.colors[5]; }, false ); + + t[i].addEventListener( 'click', function ( e ) { e.preventDefault(); fun( this.name ); _this.setActiveSelector(this.name, type); }, false ); + } + //this.hub.appendChild( cont ); + if(type=='DIFFICULTY'){this.full.appendChild( cont ); cont.style.position = 'absolute'; cont.style.top = '200px';cont.style.width = '300px';} + else this.hub.appendChild( cont ); + } + + setActiveSelector (n, type) { + var h = 10, def; + while(h--){ + if(document.getElementById(type+h)){ + def = document.getElementById(type+h); + def.style.color = this.colors[0]; + // def.style.border = '4px solid '+_this.colors[1]; + def.style.backgroundColor = this.colors[1]; + def.className = "none"; + } + } + var select = document.getElementById(type+n); + //select.style.border = '4px solid '+_this.colors[0]; + select.style.backgroundColor = this.colors[5]; + select.style.color = this.colors[2]; + select.className = "select"; + } + + removeSelector (type){ + var h = 10, def; + var target = document.getElementById(type); + while(h--){ + if(document.getElementById(type+h)){ + def = document.getElementById(type+h); + target.removeChild(def); + } + } + this.full.removeChild(target); + } + + //------------------------------------------ TOOLS MENU + + showToolSelect (id){ + if(id.name !== this.currentToolName){ + this.currentToolName = id.name; + // var px = (id.getBoundingClientRect().left - _this.toolSet.getBoundingClientRect().left ); + //var py= (id.getBoundingClientRect().top - _this.toolSet.getBoundingClientRect().top ); + var px = (id.getBoundingClientRect().left - this.toolSet.getBoundingClientRect().left ); + var py= (id.getBoundingClientRect().top - this.toolSet.getBoundingClientRect().top ); + this.select.style.left = px + 'px'; + this.select.style.top = py + 'px'; + this.select.style.display = 'block'; + } else { + this.select.style.display = 'none'; + this.currentToolName = 0; + } + + Main.selectTool(this.currentToolName); + + } + + showToolInfo (id, t){ + const toolNameMap = { + none: '无', + residential: '住宅区', + commercial: '商业区', + industrial: '工业区', + police: '警察局', + park: '公园', + fire: '消防局', + road: '道路', + bulldozer: '推土机', + rail: '铁路', + coal: '煤电厂', + wire: '电线', + nuclear: '核电站', + port: '港口', + stadium: '体育场', + airport: '机场', + query: '查询', + }; + + const toolKey = Base.toolSet[id.name]?.tool; + const name = toolNameMap[toolKey] || toolKey || ''; + + if(id.name===16) t.toolInfo.innerHTML = '拖拽视角'; + else if(id.name===17) t.toolInfo.innerHTML = '查询信息'; + else if(id.name===18) t.toolInfo.innerHTML = '旋转视角'; + else t.toolInfo.innerHTML = name + '
价格:' + Base.toolSet[id.name].price + "¥"; + } + + addSVGButton (target){ + var _this = this; + var b = document.createElement( 'div' ); + b.style.cssText =" margin:0px; padding:0px; width:66px; height:66px; pointer-events:auto; cursor:pointer; display:inline-block; line-height:0px; vertical-align: top;"; + b.innerHTML = this.round; + b.addEventListener( 'mouseover', function ( e ) { + e.preventDefault(); + var px = (this.getBoundingClientRect().left - _this.toolSet.getBoundingClientRect().left ); + var py= (this.getBoundingClientRect().top - _this.toolSet.getBoundingClientRect().top ); + _this.selector.style.left = px+ 'px'; + _this.selector.style.top = py + 'px'; + _this.selector.style.display = 'block'; + _this.showToolInfo(this, _this); + }, false ); + b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); _this.selector.style.display = 'none';}, false ); + b.addEventListener('click', function(e){ e.preventDefault(); _this.showToolSelect(this); }, false); + target.appendChild( b ); + return b; + } + + //------------------------------------------ DEF BUTTON + + addButton (target, name, size, style, top){ + var _this = this; + if(!size) size = [128, 30, 22]; + //var b = this.createLabel(name, size, true); + var b = document.createElement( 'div' ); + + //var defStyle = 'font-size:'+size[2]+'px; border:4px solid '+this.colors[1]+'; background:'+this.colors[1]+'; width:'+size[0]+'px; height:'+size[1]+'px;' + //defStyle += 'margin:4px; padding:4px; pointer-events:auto; cursor:pointer; display:inline-block; font-weight:bold;' + this.radius; + + var defStyle = 'font-size:'+size[2]+'px; border:1px solid '+this.colors[5]+'; background:'+this.colors[1]+'; width:'+size[0]+'px; height:'+size[1]+'px; color:'+this.colors[0]+';'; + if(top)defStyle += 'margin:4px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; ' + this.radiusB; + else defStyle += 'margin:4px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; ' + this.radius; + + b.textContent = name; + if(style) b.style.cssText = defStyle+ style; + else b.style.cssText = defStyle+ 'margin-top:20px;'; + + // b.addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[0]; this.style.backgroundColor = _this.colors[0]; this.style.color = _this.colors[1]; }, false ); + // b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[1]; this.style.backgroundColor = _this.colors[1]; this.style.color = _this.colors[0]; }, false ); + + b.addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.backgroundColor = _this.colors[5];this.style.color = _this.colors[2]; }, false ); + b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.backgroundColor = _this.colors[1];this.style.color = _this.colors[0]; }, false ); + + target.appendChild( b ); + + return b; + } + + clearElement (id){ + var el = document.getElementById(id); + var children = el.childNodes; + var i = children.length; + while(i--) el.removeChild( children[i] ); + this.hub.removeChild( el ); + } +} + +/** + * @license + * Copyright 2010-2021 Three.js Authors + * SPDX-License-Identifier: MIT + */ +const REVISION = '137dev'; +const CullFaceNone = 0; +const CullFaceBack = 1; +const CullFaceFront = 2; +const PCFShadowMap = 1; +const PCFSoftShadowMap = 2; +const VSMShadowMap = 3; +const FrontSide = 0; +const BackSide = 1; +const DoubleSide = 2; +const FlatShading = 1; +const NoBlending = 0; +const NormalBlending = 1; +const AdditiveBlending = 2; +const SubtractiveBlending = 3; +const MultiplyBlending = 4; +const CustomBlending = 5; +const AddEquation = 100; +const SubtractEquation = 101; +const ReverseSubtractEquation = 102; +const MinEquation = 103; +const MaxEquation = 104; +const ZeroFactor = 200; +const OneFactor = 201; +const SrcColorFactor = 202; +const OneMinusSrcColorFactor = 203; +const SrcAlphaFactor = 204; +const OneMinusSrcAlphaFactor = 205; +const DstAlphaFactor = 206; +const OneMinusDstAlphaFactor = 207; +const DstColorFactor = 208; +const OneMinusDstColorFactor = 209; +const SrcAlphaSaturateFactor = 210; +const NeverDepth = 0; +const AlwaysDepth = 1; +const LessDepth = 2; +const LessEqualDepth = 3; +const EqualDepth = 4; +const GreaterEqualDepth = 5; +const GreaterDepth = 6; +const NotEqualDepth = 7; +const MultiplyOperation = 0; +const MixOperation = 1; +const AddOperation = 2; +const NoToneMapping = 0; +const LinearToneMapping = 1; +const ReinhardToneMapping = 2; +const CineonToneMapping = 3; +const ACESFilmicToneMapping = 4; +const CustomToneMapping = 5; + +const UVMapping = 300; +const CubeReflectionMapping = 301; +const CubeRefractionMapping = 302; +const EquirectangularReflectionMapping = 303; +const EquirectangularRefractionMapping = 304; +const CubeUVReflectionMapping = 306; +const CubeUVRefractionMapping = 307; +const RepeatWrapping = 1000; +const ClampToEdgeWrapping = 1001; +const MirroredRepeatWrapping = 1002; +const NearestFilter = 1003; +const NearestMipmapNearestFilter = 1004; +const NearestMipmapLinearFilter = 1005; +const LinearFilter = 1006; +const LinearMipmapNearestFilter = 1007; +const LinearMipmapLinearFilter = 1008; +const LinearMipMapLinearFilter = 1008; +const UnsignedByteType = 1009; +const ByteType = 1010; +const ShortType = 1011; +const UnsignedShortType = 1012; +const IntType = 1013; +const UnsignedIntType = 1014; +const FloatType = 1015; +const HalfFloatType = 1016; +const UnsignedShort4444Type = 1017; +const UnsignedShort5551Type = 1018; +const UnsignedShort565Type = 1019; +const UnsignedInt248Type = 1020; +const AlphaFormat = 1021; +const RGBAFormat = 1023; +const LuminanceFormat = 1024; +const LuminanceAlphaFormat = 1025; +const DepthFormat = 1026; +const DepthStencilFormat = 1027; +const RedFormat = 1028; +const RedIntegerFormat = 1029; +const RGFormat = 1030; +const RGIntegerFormat = 1031; +const RGBIntegerFormat = 1032; +const RGBAIntegerFormat = 1033; + +const RGB_S3TC_DXT1_Format = 33776; +const RGBA_S3TC_DXT1_Format = 33777; +const RGBA_S3TC_DXT3_Format = 33778; +const RGBA_S3TC_DXT5_Format = 33779; +const RGB_PVRTC_4BPPV1_Format = 35840; +const RGB_PVRTC_2BPPV1_Format = 35841; +const RGBA_PVRTC_4BPPV1_Format = 35842; +const RGBA_PVRTC_2BPPV1_Format = 35843; +const RGB_ETC1_Format = 36196; +const RGB_ETC2_Format = 37492; +const RGBA_ETC2_EAC_Format = 37496; +const RGBA_ASTC_4x4_Format = 37808; +const RGBA_ASTC_5x4_Format = 37809; +const RGBA_ASTC_5x5_Format = 37810; +const RGBA_ASTC_6x5_Format = 37811; +const RGBA_ASTC_6x6_Format = 37812; +const RGBA_ASTC_8x5_Format = 37813; +const RGBA_ASTC_8x6_Format = 37814; +const RGBA_ASTC_8x8_Format = 37815; +const RGBA_ASTC_10x5_Format = 37816; +const RGBA_ASTC_10x6_Format = 37817; +const RGBA_ASTC_10x8_Format = 37818; +const RGBA_ASTC_10x10_Format = 37819; +const RGBA_ASTC_12x10_Format = 37820; +const RGBA_ASTC_12x12_Format = 37821; +const RGBA_BPTC_Format = 36492; +const InterpolateDiscrete = 2300; +const InterpolateLinear = 2301; +const InterpolateSmooth = 2302; +const ZeroCurvatureEnding = 2400; +const ZeroSlopeEnding = 2401; +const WrapAroundEnding = 2402; +const NormalAnimationBlendMode = 2500; +const AdditiveAnimationBlendMode = 2501; +const TrianglesDrawMode = 0; +const TriangleStripDrawMode = 1; +const TriangleFanDrawMode = 2; +const LinearEncoding = 3000; +const sRGBEncoding = 3001; +const BasicDepthPacking = 3200; +const RGBADepthPacking = 3201; +const TangentSpaceNormalMap = 0; +const ObjectSpaceNormalMap = 1; +const KeepStencilOp = 7680; +const AlwaysStencilFunc = 519; + +const StaticDrawUsage = 35044; +const DynamicDrawUsage = 35048; +const GLSL3 = '300 es'; + +const _SRGBAFormat = 1035; // fallback for WebGL 1 + +/** + * https://github.com/mrdoob/eventdispatcher.js/ + */ + +class EventDispatcher { + + addEventListener( type, listener ) { + + if ( this._listeners === undefined ) this._listeners = {}; + + const listeners = this._listeners; + + if ( listeners[ type ] === undefined ) { + + listeners[ type ] = []; + + } + + if ( listeners[ type ].indexOf( listener ) === - 1 ) { + + listeners[ type ].push( listener ); + + } + + } + + hasEventListener( type, listener ) { + + if ( this._listeners === undefined ) return false; + + const listeners = this._listeners; + + return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1; + + } + + removeEventListener( type, listener ) { + + if ( this._listeners === undefined ) return; + + const listeners = this._listeners; + const listenerArray = listeners[ type ]; + + if ( listenerArray !== undefined ) { + + const index = listenerArray.indexOf( listener ); + + if ( index !== - 1 ) { + + listenerArray.splice( index, 1 ); + + } + + } + + } + + dispatchEvent( event ) { + + if ( this._listeners === undefined ) return; + + const listeners = this._listeners; + const listenerArray = listeners[ event.type ]; + + if ( listenerArray !== undefined ) { + + event.target = this; + + // Make a copy, in case listeners are removed while iterating. + const array = listenerArray.slice( 0 ); + + for ( let i = 0, l = array.length; i < l; i ++ ) { + + array[ i ].call( this, event ); + + } + + event.target = null; + + } + + } + +} + +const _lut = []; + +for ( let i = 0; i < 256; i ++ ) { + + _lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 ); + +} + +let _seed = 1234567; + + +const DEG2RAD = Math.PI / 180; +const RAD2DEG = 180 / Math.PI; + +// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136 +function generateUUID() { + + const d0 = Math.random() * 0xffffffff | 0; + const d1 = Math.random() * 0xffffffff | 0; + const d2 = Math.random() * 0xffffffff | 0; + const d3 = Math.random() * 0xffffffff | 0; + const uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' + + _lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' + + _lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] + + _lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ]; + + // .toUpperCase() here flattens concatenated strings to save heap memory space. + return uuid.toUpperCase(); + +} + +function clamp( value, min, max ) { + + return Math.max( min, Math.min( max, value ) ); + +} + +// compute euclidian modulo of m % n +// https://en.wikipedia.org/wiki/Modulo_operation +function euclideanModulo( n, m ) { + + return ( ( n % m ) + m ) % m; + +} + +// Linear mapping from range to range +function mapLinear( x, a1, a2, b1, b2 ) { + + return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); + +} + +// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/ +function inverseLerp( x, y, value ) { + + if ( x !== y ) { + + return ( value - x ) / ( y - x ); + + } else { + + return 0; + + } + +} + +// https://en.wikipedia.org/wiki/Linear_interpolation +function lerp( x, y, t ) { + + return ( 1 - t ) * x + t * y; + +} + +// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/ +function damp( x, y, lambda, dt ) { + + return lerp( x, y, 1 - Math.exp( - lambda * dt ) ); + +} + +// https://www.desmos.com/calculator/vcsjnyz7x4 +function pingpong( x, length = 1 ) { + + return length - Math.abs( euclideanModulo( x, length * 2 ) - length ); + +} + +// http://en.wikipedia.org/wiki/Smoothstep +function smoothstep( x, min, max ) { + + if ( x <= min ) return 0; + if ( x >= max ) return 1; + + x = ( x - min ) / ( max - min ); + + return x * x * ( 3 - 2 * x ); + +} + +function smootherstep( x, min, max ) { + + if ( x <= min ) return 0; + if ( x >= max ) return 1; + + x = ( x - min ) / ( max - min ); + + return x * x * x * ( x * ( x * 6 - 15 ) + 10 ); + +} + +// Random integer from interval +function randInt( low, high ) { + + return low + Math.floor( Math.random() * ( high - low + 1 ) ); + +} + +// Random float from interval +function randFloat( low, high ) { + + return low + Math.random() * ( high - low ); + +} + +// Random float from <-range/2, range/2> interval +function randFloatSpread( range ) { + + return range * ( 0.5 - Math.random() ); + +} + +// Deterministic pseudo-random float in the interval [ 0, 1 ] +function seededRandom( s ) { + + if ( s !== undefined ) _seed = s % 2147483647; + + // Park-Miller algorithm + + _seed = _seed * 16807 % 2147483647; + + return ( _seed - 1 ) / 2147483646; + +} + +function degToRad( degrees ) { + + return degrees * DEG2RAD; + +} + +function radToDeg( radians ) { + + return radians * RAD2DEG; + +} + +function isPowerOfTwo( value ) { + + return ( value & ( value - 1 ) ) === 0 && value !== 0; + +} + +function ceilPowerOfTwo( value ) { + + return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) ); + +} + +function floorPowerOfTwo( value ) { + + return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) ); + +} + +function setQuaternionFromProperEuler( q, a, b, c, order ) { + + // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles + + // rotations are applied to the axes in the order specified by 'order' + // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c' + // angles are in radians + + const cos = Math.cos; + const sin = Math.sin; + + const c2 = cos( b / 2 ); + const s2 = sin( b / 2 ); + + const c13 = cos( ( a + c ) / 2 ); + const s13 = sin( ( a + c ) / 2 ); + + const c1_3 = cos( ( a - c ) / 2 ); + const s1_3 = sin( ( a - c ) / 2 ); + + const c3_1 = cos( ( c - a ) / 2 ); + const s3_1 = sin( ( c - a ) / 2 ); + + switch ( order ) { + + case 'XYX': + q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 ); + break; + + case 'YZY': + q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 ); + break; + + case 'ZXZ': + q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 ); + break; + + case 'XZX': + q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 ); + break; + + case 'YXY': + q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 ); + break; + + case 'ZYZ': + q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 ); + break; + + default: + console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order ); + + } + +} + +var MathUtils = /*#__PURE__*/Object.freeze({ + __proto__: null, + DEG2RAD: DEG2RAD, + RAD2DEG: RAD2DEG, + generateUUID: generateUUID, + clamp: clamp, + euclideanModulo: euclideanModulo, + mapLinear: mapLinear, + inverseLerp: inverseLerp, + lerp: lerp, + damp: damp, + pingpong: pingpong, + smoothstep: smoothstep, + smootherstep: smootherstep, + randInt: randInt, + randFloat: randFloat, + randFloatSpread: randFloatSpread, + seededRandom: seededRandom, + degToRad: degToRad, + radToDeg: radToDeg, + isPowerOfTwo: isPowerOfTwo, + ceilPowerOfTwo: ceilPowerOfTwo, + floorPowerOfTwo: floorPowerOfTwo, + setQuaternionFromProperEuler: setQuaternionFromProperEuler +}); + +class Vector2 { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + get width() { + + return this.x; + + } + + set width( value ) { + + this.x = value; + + } + + get height() { + + return this.y; + + } + + set height( value ) { + + this.y = value; + + } + + set( x, y ) { + + this.x = x; + this.y = y; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + + return this; + + } + + multiply( v ) { + + this.x *= v.x; + this.y *= v.y; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + + return this; + + } + + divide( v ) { + + this.x /= v.x; + this.y /= v.y; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + applyMatrix3( m ) { + + const x = this.x, y = this.y; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ]; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ]; + + return this; + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y; + + } + + cross( v ) { + + return this.x * v.y - this.y * v.x; + + } + + lengthSq() { + + return this.x * this.x + this.y * this.y; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + angle() { + + // computes the angle in radians with respect to the positive x-axis + + const angle = Math.atan2( - this.y, - this.x ) + Math.PI; + + return angle; + + } + + distanceTo( v ) { + + return Math.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y; + return dx * dx + dy * dy; + + } + + manhattanDistanceTo( v ) { + + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + + return this; + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + + return this; + + } + + rotateAround( center, angle ) { + + const c = Math.cos( angle ), s = Math.sin( angle ); + + const x = this.x - center.x; + const y = this.y - center.y; + + this.x = x * c - y * s + center.x; + this.y = x * s + y * c + center.y; + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + + } + +} + +Vector2.prototype.isVector2 = true; + +class Matrix3 { + + constructor() { + + this.elements = [ + + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + + ]; + + if ( arguments.length > 0 ) { + + console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); + + } + + } + + set( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { + + const te = this.elements; + + te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; + te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; + te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; + + return this; + + } + + identity() { + + this.set( + + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + + ); + + return this; + + } + + copy( m ) { + + const te = this.elements; + const me = m.elements; + + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; + te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; + te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; + + return this; + + } + + extractBasis( xAxis, yAxis, zAxis ) { + + xAxis.setFromMatrix3Column( this, 0 ); + yAxis.setFromMatrix3Column( this, 1 ); + zAxis.setFromMatrix3Column( this, 2 ); + + return this; + + } + + setFromMatrix4( m ) { + + const me = m.elements; + + this.set( + + me[ 0 ], me[ 4 ], me[ 8 ], + me[ 1 ], me[ 5 ], me[ 9 ], + me[ 2 ], me[ 6 ], me[ 10 ] + + ); + + return this; + + } + + multiply( m ) { + + return this.multiplyMatrices( this, m ); + + } + + premultiply( m ) { + + return this.multiplyMatrices( m, this ); + + } + + multiplyMatrices( a, b ) { + + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; + const a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; + const a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; + + const b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; + const b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; + const b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; + + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; + te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; + te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; + + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; + te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; + te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; + + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; + te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; + te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + + return this; + + } + + multiplyScalar( s ) { + + const te = this.elements; + + te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; + te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; + te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; + + return this; + + } + + determinant() { + + const te = this.elements; + + const a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], + d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], + g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; + + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; + + } + + invert() { + + const te = this.elements, + + n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], + n12 = te[ 3 ], n22 = te[ 4 ], n32 = te[ 5 ], + n13 = te[ 6 ], n23 = te[ 7 ], n33 = te[ 8 ], + + t11 = n33 * n22 - n32 * n23, + t12 = n32 * n13 - n33 * n12, + t13 = n23 * n12 - n22 * n13, + + det = n11 * t11 + n21 * t12 + n31 * t13; + + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 ); + + const detInv = 1 / det; + + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; + te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; + + te[ 3 ] = t12 * detInv; + te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; + te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + + te[ 6 ] = t13 * detInv; + te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; + te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; + + return this; + + } + + transpose() { + + let tmp; + const m = this.elements; + + tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; + tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; + tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; + + return this; + + } + + getNormalMatrix( matrix4 ) { + + return this.setFromMatrix4( matrix4 ).invert().transpose(); + + } + + transposeIntoArray( r ) { + + const m = this.elements; + + r[ 0 ] = m[ 0 ]; + r[ 1 ] = m[ 3 ]; + r[ 2 ] = m[ 6 ]; + r[ 3 ] = m[ 1 ]; + r[ 4 ] = m[ 4 ]; + r[ 5 ] = m[ 7 ]; + r[ 6 ] = m[ 2 ]; + r[ 7 ] = m[ 5 ]; + r[ 8 ] = m[ 8 ]; + + return this; + + } + + setUvTransform( tx, ty, sx, sy, rotation, cx, cy ) { + + const c = Math.cos( rotation ); + const s = Math.sin( rotation ); + + this.set( + sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, + - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, + 0, 0, 1 + ); + + return this; + + } + + scale( sx, sy ) { + + const te = this.elements; + + te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; + te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; + + return this; + + } + + rotate( theta ) { + + const c = Math.cos( theta ); + const s = Math.sin( theta ); + + const te = this.elements; + + const a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; + const a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; + + te[ 0 ] = c * a11 + s * a21; + te[ 3 ] = c * a12 + s * a22; + te[ 6 ] = c * a13 + s * a23; + + te[ 1 ] = - s * a11 + c * a21; + te[ 4 ] = - s * a12 + c * a22; + te[ 7 ] = - s * a13 + c * a23; + + return this; + + } + + translate( tx, ty ) { + + const te = this.elements; + + te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; + te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; + + return this; + + } + + equals( matrix ) { + + const te = this.elements; + const me = matrix.elements; + + for ( let i = 0; i < 9; i ++ ) { + + if ( te[ i ] !== me[ i ] ) return false; + + } + + return true; + + } + + fromArray( array, offset = 0 ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.elements[ i ] = array[ i + offset ]; + + } + + return this; + + } + + toArray( array = [], offset = 0 ) { + + const te = this.elements; + + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + + array[ offset + 3 ] = te[ 3 ]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + array[ offset + 8 ] = te[ 8 ]; + + return array; + + } + + clone() { + + return new this.constructor().fromArray( this.elements ); + + } + +} + +Matrix3.prototype.isMatrix3 = true; + +function arrayMax( array ) { + + if ( array.length === 0 ) return - Infinity; + + let max = array[ 0 ]; + + for ( let i = 1, l = array.length; i < l; ++ i ) { + + if ( array[ i ] > max ) max = array[ i ]; + + } + + return max; + +} + +function createElementNS( name ) { + + return document.createElementNS( 'http://www.w3.org/1999/xhtml', name ); + +} + +const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF, + 'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2, + 'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50, + 'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B, + 'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B, + 'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F, + 'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3, + 'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222, + 'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700, + 'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4, + 'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00, + 'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3, + 'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA, + 'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32, + 'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3, + 'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC, + 'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD, + 'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6, + 'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9, + 'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F, + 'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE, + 'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA, + 'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0, + 'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 }; + +const _hslA = { h: 0, s: 0, l: 0 }; +const _hslB = { h: 0, s: 0, l: 0 }; + +function hue2rgb( p, q, t ) { + + if ( t < 0 ) t += 1; + if ( t > 1 ) t -= 1; + if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t; + if ( t < 1 / 2 ) return q; + if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t ); + return p; + +} + +function SRGBToLinear( c ) { + + return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 ); + +} + +function LinearToSRGB( c ) { + + return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055; + +} + +class Color$1 { + + constructor( r, g, b ) { + + if ( g === undefined && b === undefined ) { + + // r is THREE.Color, hex or string + return this.set( r ); + + } + + return this.setRGB( r, g, b ); + + } + + set( value ) { + + if ( value && value.isColor ) { + + this.copy( value ); + + } else if ( typeof value === 'number' ) { + + this.setHex( value ); + + } else if ( typeof value === 'string' ) { + + this.setStyle( value ); + + } + + return this; + + } + + setScalar( scalar ) { + + this.r = scalar; + this.g = scalar; + this.b = scalar; + + return this; + + } + + setHex( hex ) { + + hex = Math.floor( hex ); + + this.r = ( hex >> 16 & 255 ) / 255; + this.g = ( hex >> 8 & 255 ) / 255; + this.b = ( hex & 255 ) / 255; + + return this; + + } + + setRGB( r, g, b ) { + + this.r = r; + this.g = g; + this.b = b; + + return this; + + } + + setHSL( h, s, l ) { + + // h,s,l ranges are in 0.0 - 1.0 + h = euclideanModulo( h, 1 ); + s = clamp( s, 0, 1 ); + l = clamp( l, 0, 1 ); + + if ( s === 0 ) { + + this.r = this.g = this.b = l; + + } else { + + const p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s ); + const q = ( 2 * l ) - p; + + this.r = hue2rgb( q, p, h + 1 / 3 ); + this.g = hue2rgb( q, p, h ); + this.b = hue2rgb( q, p, h - 1 / 3 ); + + } + + return this; + + } + + setStyle( style ) { + + function handleAlpha( string ) { + + if ( string === undefined ) return; + + if ( parseFloat( string ) < 1 ) { + + console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' ); + + } + + } + + + let m; + + if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) { + + // rgb / hsl + + let color; + const name = m[ 1 ]; + const components = m[ 2 ]; + + switch ( name ) { + + case 'rgb': + case 'rgba': + + if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // rgb(255,0,0) rgba(255,0,0,0.5) + this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255; + this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255; + this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255; + + handleAlpha( color[ 4 ] ); + + return this; + + } + + if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5) + this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100; + this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100; + this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100; + + handleAlpha( color[ 4 ] ); + + return this; + + } + + break; + + case 'hsl': + case 'hsla': + + if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // hsl(120,50%,50%) hsla(120,50%,50%,0.5) + const h = parseFloat( color[ 1 ] ) / 360; + const s = parseInt( color[ 2 ], 10 ) / 100; + const l = parseInt( color[ 3 ], 10 ) / 100; + + handleAlpha( color[ 4 ] ); + + return this.setHSL( h, s, l ); + + } + + break; + + } + + } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) { + + // hex color + + const hex = m[ 1 ]; + const size = hex.length; + + if ( size === 3 ) { + + // #ff0 + this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255; + this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255; + this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255; + + return this; + + } else if ( size === 6 ) { + + // #ff0000 + this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255; + this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255; + this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255; + + return this; + + } + + } + + if ( style && style.length > 0 ) { + + return this.setColorName( style ); + + } + + return this; + + } + + setColorName( style ) { + + // color keywords + const hex = _colorKeywords[ style.toLowerCase() ]; + + if ( hex !== undefined ) { + + // red + this.setHex( hex ); + + } else { + + // unknown color + console.warn( 'THREE.Color: Unknown color ' + style ); + + } + + return this; + + } + + clone() { + + return new this.constructor( this.r, this.g, this.b ); + + } + + copy( color ) { + + this.r = color.r; + this.g = color.g; + this.b = color.b; + + return this; + + } + + copySRGBToLinear( color ) { + + this.r = SRGBToLinear( color.r ); + this.g = SRGBToLinear( color.g ); + this.b = SRGBToLinear( color.b ); + + return this; + + } + + copyLinearToSRGB( color ) { + + this.r = LinearToSRGB( color.r ); + this.g = LinearToSRGB( color.g ); + this.b = LinearToSRGB( color.b ); + + return this; + + } + + convertSRGBToLinear() { + + this.copySRGBToLinear( this ); + + return this; + + } + + convertLinearToSRGB() { + + this.copyLinearToSRGB( this ); + + return this; + + } + + getHex() { + + return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0; + + } + + getHexString() { + + return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 ); + + } + + getHSL( target ) { + + // h,s,l ranges are in 0.0 - 1.0 + + const r = this.r, g = this.g, b = this.b; + + const max = Math.max( r, g, b ); + const min = Math.min( r, g, b ); + + let hue, saturation; + const lightness = ( min + max ) / 2.0; + + if ( min === max ) { + + hue = 0; + saturation = 0; + + } else { + + const delta = max - min; + + saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min ); + + switch ( max ) { + + case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break; + case g: hue = ( b - r ) / delta + 2; break; + case b: hue = ( r - g ) / delta + 4; break; + + } + + hue /= 6; + + } + + target.h = hue; + target.s = saturation; + target.l = lightness; + + return target; + + } + + getStyle() { + + return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')'; + + } + + offsetHSL( h, s, l ) { + + this.getHSL( _hslA ); + + _hslA.h += h; _hslA.s += s; _hslA.l += l; + + this.setHSL( _hslA.h, _hslA.s, _hslA.l ); + + return this; + + } + + add( color ) { + + this.r += color.r; + this.g += color.g; + this.b += color.b; + + return this; + + } + + addColors( color1, color2 ) { + + this.r = color1.r + color2.r; + this.g = color1.g + color2.g; + this.b = color1.b + color2.b; + + return this; + + } + + addScalar( s ) { + + this.r += s; + this.g += s; + this.b += s; + + return this; + + } + + sub( color ) { + + this.r = Math.max( 0, this.r - color.r ); + this.g = Math.max( 0, this.g - color.g ); + this.b = Math.max( 0, this.b - color.b ); + + return this; + + } + + multiply( color ) { + + this.r *= color.r; + this.g *= color.g; + this.b *= color.b; + + return this; + + } + + multiplyScalar( s ) { + + this.r *= s; + this.g *= s; + this.b *= s; + + return this; + + } + + lerp( color, alpha ) { + + this.r += ( color.r - this.r ) * alpha; + this.g += ( color.g - this.g ) * alpha; + this.b += ( color.b - this.b ) * alpha; + + return this; + + } + + lerpColors( color1, color2, alpha ) { + + this.r = color1.r + ( color2.r - color1.r ) * alpha; + this.g = color1.g + ( color2.g - color1.g ) * alpha; + this.b = color1.b + ( color2.b - color1.b ) * alpha; + + return this; + + } + + lerpHSL( color, alpha ) { + + this.getHSL( _hslA ); + color.getHSL( _hslB ); + + const h = lerp( _hslA.h, _hslB.h, alpha ); + const s = lerp( _hslA.s, _hslB.s, alpha ); + const l = lerp( _hslA.l, _hslB.l, alpha ); + + this.setHSL( h, s, l ); + + return this; + + } + + equals( c ) { + + return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b ); + + } + + fromArray( array, offset = 0 ) { + + this.r = array[ offset ]; + this.g = array[ offset + 1 ]; + this.b = array[ offset + 2 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.r; + array[ offset + 1 ] = this.g; + array[ offset + 2 ] = this.b; + + return array; + + } + + fromBufferAttribute( attribute, index ) { + + this.r = attribute.getX( index ); + this.g = attribute.getY( index ); + this.b = attribute.getZ( index ); + + if ( attribute.normalized === true ) { + + // assuming Uint8Array + + this.r /= 255; + this.g /= 255; + this.b /= 255; + + } + + return this; + + } + + toJSON() { + + return this.getHex(); + + } + +} + +Color$1.NAMES = _colorKeywords; + +Color$1.prototype.isColor = true; +Color$1.prototype.r = 1; +Color$1.prototype.g = 1; +Color$1.prototype.b = 1; + +let _canvas; + +class ImageUtils { + + static getDataURL( image ) { + + if ( /^data:/i.test( image.src ) ) { + + return image.src; + + } + + if ( typeof HTMLCanvasElement == 'undefined' ) { + + return image.src; + + } + + let canvas; + + if ( image instanceof HTMLCanvasElement ) { + + canvas = image; + + } else { + + if ( _canvas === undefined ) _canvas = createElementNS( 'canvas' ); + + _canvas.width = image.width; + _canvas.height = image.height; + + const context = _canvas.getContext( '2d' ); + + if ( image instanceof ImageData ) { + + context.putImageData( image, 0, 0 ); + + } else { + + context.drawImage( image, 0, 0, image.width, image.height ); + + } + + canvas = _canvas; + + } + + if ( canvas.width > 2048 || canvas.height > 2048 ) { + + console.warn( 'THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image ); + + return canvas.toDataURL( 'image/jpeg', 0.6 ); + + } else { + + return canvas.toDataURL( 'image/png' ); + + } + + } + + static sRGBToLinear( image ) { + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + const canvas = createElementNS( 'canvas' ); + + canvas.width = image.width; + canvas.height = image.height; + + const context = canvas.getContext( '2d' ); + context.drawImage( image, 0, 0, image.width, image.height ); + + const imageData = context.getImageData( 0, 0, image.width, image.height ); + const data = imageData.data; + + for ( let i = 0; i < data.length; i ++ ) { + + data[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255; + + } + + context.putImageData( imageData, 0, 0 ); + + return canvas; + + } else if ( image.data ) { + + const data = image.data.slice( 0 ); + + for ( let i = 0; i < data.length; i ++ ) { + + if ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) { + + data[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 ); + + } else { + + // assuming float + + data[ i ] = SRGBToLinear( data[ i ] ); + + } + + } + + return { + data: data, + width: image.width, + height: image.height + }; + + } else { + + console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' ); + return image; + + } + + } + +} + +let textureId = 0; + +class Texture extends EventDispatcher { + + constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) { + + super(); + + Object.defineProperty( this, 'id', { value: textureId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + + this.image = image; + this.mipmaps = []; + + this.mapping = mapping; + + this.wrapS = wrapS; + this.wrapT = wrapT; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.anisotropy = anisotropy; + + this.format = format; + this.internalFormat = null; + this.type = type; + + this.offset = new Vector2( 0, 0 ); + this.repeat = new Vector2( 1, 1 ); + this.center = new Vector2( 0, 0 ); + this.rotation = 0; + + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); + + this.generateMipmaps = true; + this.premultiplyAlpha = false; + this.flipY = true; + this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) + + // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. + // + // Also changing the encoding after already used by a Material will not automatically make the Material + // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. + this.encoding = encoding; + + this.userData = {}; + + this.version = 0; + this.onUpdate = null; + + this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not + this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures) + + } + + updateMatrix() { + + this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.name = source.name; + + this.image = source.image; + this.mipmaps = source.mipmaps.slice( 0 ); + + this.mapping = source.mapping; + + this.wrapS = source.wrapS; + this.wrapT = source.wrapT; + + this.magFilter = source.magFilter; + this.minFilter = source.minFilter; + + this.anisotropy = source.anisotropy; + + this.format = source.format; + this.internalFormat = source.internalFormat; + this.type = source.type; + + this.offset.copy( source.offset ); + this.repeat.copy( source.repeat ); + this.center.copy( source.center ); + this.rotation = source.rotation; + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrix.copy( source.matrix ); + + this.generateMipmaps = source.generateMipmaps; + this.premultiplyAlpha = source.premultiplyAlpha; + this.flipY = source.flipY; + this.unpackAlignment = source.unpackAlignment; + this.encoding = source.encoding; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + return this; + + } + + toJSON( meta ) { + + const isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { + + return meta.textures[ this.uuid ]; + + } + + const output = { + + metadata: { + version: 4.5, + type: 'Texture', + generator: 'Texture.toJSON' + }, + + uuid: this.uuid, + name: this.name, + + mapping: this.mapping, + + repeat: [ this.repeat.x, this.repeat.y ], + offset: [ this.offset.x, this.offset.y ], + center: [ this.center.x, this.center.y ], + rotation: this.rotation, + + wrap: [ this.wrapS, this.wrapT ], + + format: this.format, + type: this.type, + encoding: this.encoding, + + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, + + flipY: this.flipY, + + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment + + }; + + if ( this.image !== undefined ) { + + // TODO: Move to THREE.Image + + const image = this.image; + + if ( image.uuid === undefined ) { + + image.uuid = generateUUID(); // UGH + + } + + if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + + let url; + + if ( Array.isArray( image ) ) { + + // process array of images e.g. CubeTexture + + url = []; + + for ( let i = 0, l = image.length; i < l; i ++ ) { + + // check cube texture with data textures + + if ( image[ i ].isDataTexture ) { + + url.push( serializeImage( image[ i ].image ) ); + + } else { + + url.push( serializeImage( image[ i ] ) ); + + } + + } + + } else { + + // process single image + + url = serializeImage( image ); + + } + + meta.images[ image.uuid ] = { + uuid: image.uuid, + url: url + }; + + } + + output.image = image.uuid; + + } + + if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData; + + if ( ! isRootObject ) { + + meta.textures[ this.uuid ] = output; + + } + + return output; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + + transformUv( uv ) { + + if ( this.mapping !== UVMapping ) return uv; + + uv.applyMatrix3( this.matrix ); + + if ( uv.x < 0 || uv.x > 1 ) { + + switch ( this.wrapS ) { + + case RepeatWrapping: + + uv.x = uv.x - Math.floor( uv.x ); + break; + + case ClampToEdgeWrapping: + + uv.x = uv.x < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + + if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) { + + uv.x = Math.ceil( uv.x ) - uv.x; + + } else { + + uv.x = uv.x - Math.floor( uv.x ); + + } + + break; + + } + + } + + if ( uv.y < 0 || uv.y > 1 ) { + + switch ( this.wrapT ) { + + case RepeatWrapping: + + uv.y = uv.y - Math.floor( uv.y ); + break; + + case ClampToEdgeWrapping: + + uv.y = uv.y < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + + if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) { + + uv.y = Math.ceil( uv.y ) - uv.y; + + } else { + + uv.y = uv.y - Math.floor( uv.y ); + + } + + break; + + } + + } + + if ( this.flipY ) { + + uv.y = 1 - uv.y; + + } + + return uv; + + } + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + +} + +Texture.DEFAULT_IMAGE = undefined; +Texture.DEFAULT_MAPPING = UVMapping; + +Texture.prototype.isTexture = true; + +function serializeImage( image ) { + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + // default images + + return ImageUtils.getDataURL( image ); + + } else { + + if ( image.data ) { + + // images of DataTexture + + return { + data: Array.prototype.slice.call( image.data ), + width: image.width, + height: image.height, + type: image.data.constructor.name + }; + + } else { + + console.warn( 'THREE.Texture: Unable to serialize Texture.' ); + return {}; + + } + + } + +} + +class Vector4 { + + constructor( x = 0, y = 0, z = 0, w = 1 ) { + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + } + + get width() { + + return this.z; + + } + + set width( value ) { + + this.z = value; + + } + + get height() { + + return this.w; + + } + + set height( value ) { + + this.w = value; + + } + + set( x, y, z, w ) { + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + this.z = scalar; + this.w = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setZ( z ) { + + this.z = z; + + return this; + + } + + setW( w ) { + + this.w = w; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + case 2: this.z = value; break; + case 3: this.w = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + case 2: return this.z; + case 3: return this.w; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y, this.z, this.w ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this.z = v.z; + this.w = ( v.w !== undefined ) ? v.w : 1; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + this.z += s; + this.w += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + this.w = a.w + b.w; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + this.w += v.w * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + this.z -= s; + this.w -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + this.w = a.w - b.w; + + return this; + + } + + multiply( v ) { + + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + this.w *= v.w; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + this.w *= scalar; + + return this; + + } + + applyMatrix4( m ) { + + const x = this.x, y = this.y, z = this.z, w = this.w; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w; + this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + setAxisAngleFromQuaternion( q ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + + // q is assumed to be normalized + + this.w = 2 * Math.acos( q.w ); + + const s = Math.sqrt( 1 - q.w * q.w ); + + if ( s < 0.0001 ) { + + this.x = 1; + this.y = 0; + this.z = 0; + + } else { + + this.x = q.x / s; + this.y = q.y / s; + this.z = q.z / s; + + } + + return this; + + } + + setAxisAngleFromRotationMatrix( m ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + let angle, x, y, z; // variables for result + const epsilon = 0.01, // margin to allow for rounding errors + epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees + + te = m.elements, + + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; + + if ( ( Math.abs( m12 - m21 ) < epsilon ) && + ( Math.abs( m13 - m31 ) < epsilon ) && + ( Math.abs( m23 - m32 ) < epsilon ) ) { + + // singularity found + // first check for identity matrix which must have +1 for all terms + // in leading diagonal and zero in other terms + + if ( ( Math.abs( m12 + m21 ) < epsilon2 ) && + ( Math.abs( m13 + m31 ) < epsilon2 ) && + ( Math.abs( m23 + m32 ) < epsilon2 ) && + ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { + + // this singularity is identity matrix so angle = 0 + + this.set( 1, 0, 0, 0 ); + + return this; // zero angle, arbitrary axis + + } + + // otherwise this singularity is angle = 180 + + angle = Math.PI; + + const xx = ( m11 + 1 ) / 2; + const yy = ( m22 + 1 ) / 2; + const zz = ( m33 + 1 ) / 2; + const xy = ( m12 + m21 ) / 4; + const xz = ( m13 + m31 ) / 4; + const yz = ( m23 + m32 ) / 4; + + if ( ( xx > yy ) && ( xx > zz ) ) { + + // m11 is the largest diagonal term + + if ( xx < epsilon ) { + + x = 0; + y = 0.707106781; + z = 0.707106781; + + } else { + + x = Math.sqrt( xx ); + y = xy / x; + z = xz / x; + + } + + } else if ( yy > zz ) { + + // m22 is the largest diagonal term + + if ( yy < epsilon ) { + + x = 0.707106781; + y = 0; + z = 0.707106781; + + } else { + + y = Math.sqrt( yy ); + x = xy / y; + z = yz / y; + + } + + } else { + + // m33 is the largest diagonal term so base result on this + + if ( zz < epsilon ) { + + x = 0.707106781; + y = 0.707106781; + z = 0; + + } else { + + z = Math.sqrt( zz ); + x = xz / z; + y = yz / z; + + } + + } + + this.set( x, y, z, angle ); + + return this; // return 180 deg rotation + + } + + // as we have reached here there are no singularities so we can handle normally + + let s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) + + ( m13 - m31 ) * ( m13 - m31 ) + + ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize + + if ( Math.abs( s ) < 0.001 ) s = 1; + + // prevent divide by zero, should not happen if matrix is orthogonal and should be + // caught by singularity test above, but I've left it in just in case + + this.x = ( m32 - m23 ) / s; + this.y = ( m13 - m31 ) / s; + this.z = ( m21 - m12 ) / s; + this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 ); + + return this; + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + this.z = Math.min( this.z, v.z ); + this.w = Math.min( this.w, v.w ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + this.z = Math.max( this.z, v.z ); + this.w = Math.max( this.w, v.w ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + this.z = Math.max( min.z, Math.min( max.z, this.z ) ); + this.w = Math.max( min.w, Math.min( max.w, this.w ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + this.z = Math.floor( this.z ); + this.w = Math.floor( this.w ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + this.z = Math.ceil( this.z ); + this.w = Math.ceil( this.w ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + this.z = Math.round( this.z ); + this.w = Math.round( this.w ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + this.z = - this.z; + this.w = - this.w; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + + } + + lengthSq() { + + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + this.z += ( v.z - this.z ) * alpha; + this.w += ( v.w - this.w ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + this.z = v1.z + ( v2.z - v1.z ) * alpha; + this.w = v1.w + ( v2.w - v1.w ) * alpha; + + return this; + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + this.w = array[ offset + 3 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + array[ offset + 3 ] = this.w; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + this.w = attribute.getW( index ); + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + this.w = Math.random(); + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + yield this.z; + yield this.w; + + } + +} + +Vector4.prototype.isVector4 = true; + +/* + In options, we can specify: + * Texture parameters for an auto-generated target texture + * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers +*/ +class WebGLRenderTarget extends EventDispatcher { + + constructor( width, height, options = {} ) { + + super(); + + this.width = width; + this.height = height; + this.depth = 1; + + this.scissor = new Vector4( 0, 0, width, height ); + this.scissorTest = false; + + this.viewport = new Vector4( 0, 0, width, height ); + + this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + this.texture.isRenderTargetTexture = true; + + this.texture.image = { width: width, height: height, depth: 1 }; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + + this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; + this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false; + this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + + } + + setTexture( texture ) { + + texture.image = { + width: this.width, + height: this.height, + depth: this.depth + }; + + this.texture = texture; + + } + + setSize( width, height, depth = 1 ) { + + if ( this.width !== width || this.height !== height || this.depth !== depth ) { + + this.width = width; + this.height = height; + this.depth = depth; + + this.texture.image.width = width; + this.texture.image.height = height; + this.texture.image.depth = depth; + + this.dispose(); + + } + + this.viewport.set( 0, 0, width, height ); + this.scissor.set( 0, 0, width, height ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.width = source.width; + this.height = source.height; + this.depth = source.depth; + + this.viewport.copy( source.viewport ); + + this.texture = source.texture.clone(); + + // ensure image object is not shared, see #20328 + + this.texture.image = Object.assign( {}, source.texture.image ); + + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + +} + +WebGLRenderTarget.prototype.isWebGLRenderTarget = true; + +class WebGLMultisampleRenderTarget extends WebGLRenderTarget { + + constructor( width, height, options = {} ) { + + super( width, height, options ); + + this.samples = 4; + + this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true; + this.useRenderToTexture = ( options.useRenderToTexture !== undefined ) ? options.useRenderToTexture : false; + this.useRenderbuffer = this.useRenderToTexture === false; + + } + + copy( source ) { + + super.copy.call( this, source ); + + this.samples = source.samples; + this.useRenderToTexture = source.useRenderToTexture; + this.useRenderbuffer = source.useRenderbuffer; + + return this; + + } + +} + +WebGLMultisampleRenderTarget.prototype.isWebGLMultisampleRenderTarget = true; + +class Quaternion { + + constructor( x = 0, y = 0, z = 0, w = 1 ) { + + this._x = x; + this._y = y; + this._z = z; + this._w = w; + + } + + static slerp( qa, qb, qm, t ) { + + console.warn( 'THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.' ); + return qm.slerpQuaternions( qa, qb, t ); + + } + + static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { + + // fuzz-free, array-based Quaternion SLERP operation + + let x0 = src0[ srcOffset0 + 0 ], + y0 = src0[ srcOffset0 + 1 ], + z0 = src0[ srcOffset0 + 2 ], + w0 = src0[ srcOffset0 + 3 ]; + + const x1 = src1[ srcOffset1 + 0 ], + y1 = src1[ srcOffset1 + 1 ], + z1 = src1[ srcOffset1 + 2 ], + w1 = src1[ srcOffset1 + 3 ]; + + if ( t === 0 ) { + + dst[ dstOffset + 0 ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; + return; + + } + + if ( t === 1 ) { + + dst[ dstOffset + 0 ] = x1; + dst[ dstOffset + 1 ] = y1; + dst[ dstOffset + 2 ] = z1; + dst[ dstOffset + 3 ] = w1; + return; + + } + + if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { + + let s = 1 - t; + const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, + dir = ( cos >= 0 ? 1 : - 1 ), + sqrSin = 1 - cos * cos; + + // Skip the Slerp for tiny steps to avoid numeric problems: + if ( sqrSin > Number.EPSILON ) { + + const sin = Math.sqrt( sqrSin ), + len = Math.atan2( sin, cos * dir ); + + s = Math.sin( s * len ) / sin; + t = Math.sin( t * len ) / sin; + + } + + const tDir = t * dir; + + x0 = x0 * s + x1 * tDir; + y0 = y0 * s + y1 * tDir; + z0 = z0 * s + z1 * tDir; + w0 = w0 * s + w1 * tDir; + + // Normalize in case we just did a lerp: + if ( s === 1 - t ) { + + const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); + + x0 *= f; + y0 *= f; + z0 *= f; + w0 *= f; + + } + + } + + dst[ dstOffset ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; + + } + + static multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) { + + const x0 = src0[ srcOffset0 ]; + const y0 = src0[ srcOffset0 + 1 ]; + const z0 = src0[ srcOffset0 + 2 ]; + const w0 = src0[ srcOffset0 + 3 ]; + + const x1 = src1[ srcOffset1 ]; + const y1 = src1[ srcOffset1 + 1 ]; + const z1 = src1[ srcOffset1 + 2 ]; + const w1 = src1[ srcOffset1 + 3 ]; + + dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1; + dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1; + dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1; + dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1; + + return dst; + + } + + get x() { + + return this._x; + + } + + set x( value ) { + + this._x = value; + this._onChangeCallback(); + + } + + get y() { + + return this._y; + + } + + set y( value ) { + + this._y = value; + this._onChangeCallback(); + + } + + get z() { + + return this._z; + + } + + set z( value ) { + + this._z = value; + this._onChangeCallback(); + + } + + get w() { + + return this._w; + + } + + set w( value ) { + + this._w = value; + this._onChangeCallback(); + + } + + set( x, y, z, w ) { + + this._x = x; + this._y = y; + this._z = z; + this._w = w; + + this._onChangeCallback(); + + return this; + + } + + clone() { + + return new this.constructor( this._x, this._y, this._z, this._w ); + + } + + copy( quaternion ) { + + this._x = quaternion.x; + this._y = quaternion.y; + this._z = quaternion.z; + this._w = quaternion.w; + + this._onChangeCallback(); + + return this; + + } + + setFromEuler( euler, update ) { + + if ( ! ( euler && euler.isEuler ) ) { + + throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + + } + + const x = euler._x, y = euler._y, z = euler._z, order = euler._order; + + // http://www.mathworks.com/matlabcentral/fileexchange/ + // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ + // content/SpinCalc.m + + const cos = Math.cos; + const sin = Math.sin; + + const c1 = cos( x / 2 ); + const c2 = cos( y / 2 ); + const c3 = cos( z / 2 ); + + const s1 = sin( x / 2 ); + const s2 = sin( y / 2 ); + const s3 = sin( z / 2 ); + + switch ( order ) { + + case 'XYZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'YXZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'ZXY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'ZYX': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'YZX': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'XZY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + default: + console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order ); + + } + + if ( update !== false ) this._onChangeCallback(); + + return this; + + } + + setFromAxisAngle( axis, angle ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + + // assumes axis is normalized + + const halfAngle = angle / 2, s = Math.sin( halfAngle ); + + this._x = axis.x * s; + this._y = axis.y * s; + this._z = axis.z * s; + this._w = Math.cos( halfAngle ); + + this._onChangeCallback(); + + return this; + + } + + setFromRotationMatrix( m ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements, + + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ], + + trace = m11 + m22 + m33; + + if ( trace > 0 ) { + + const s = 0.5 / Math.sqrt( trace + 1.0 ); + + this._w = 0.25 / s; + this._x = ( m32 - m23 ) * s; + this._y = ( m13 - m31 ) * s; + this._z = ( m21 - m12 ) * s; + + } else if ( m11 > m22 && m11 > m33 ) { + + const s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); + + this._w = ( m32 - m23 ) / s; + this._x = 0.25 * s; + this._y = ( m12 + m21 ) / s; + this._z = ( m13 + m31 ) / s; + + } else if ( m22 > m33 ) { + + const s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); + + this._w = ( m13 - m31 ) / s; + this._x = ( m12 + m21 ) / s; + this._y = 0.25 * s; + this._z = ( m23 + m32 ) / s; + + } else { + + const s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + + this._w = ( m21 - m12 ) / s; + this._x = ( m13 + m31 ) / s; + this._y = ( m23 + m32 ) / s; + this._z = 0.25 * s; + + } + + this._onChangeCallback(); + + return this; + + } + + setFromUnitVectors( vFrom, vTo ) { + + // assumes direction vectors vFrom and vTo are normalized + + let r = vFrom.dot( vTo ) + 1; + + if ( r < Number.EPSILON ) { + + // vFrom and vTo point in opposite directions + + r = 0; + + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + + this._x = - vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; + + } else { + + this._x = 0; + this._y = - vFrom.z; + this._z = vFrom.y; + this._w = r; + + } + + } else { + + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 + + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; + + } + + return this.normalize(); + + } + + angleTo( q ) { + + return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) ); + + } + + rotateTowards( q, step ) { + + const angle = this.angleTo( q ); + + if ( angle === 0 ) return this; + + const t = Math.min( 1, step / angle ); + + this.slerp( q, t ); + + return this; + + } + + identity() { + + return this.set( 0, 0, 0, 1 ); + + } + + invert() { + + // quaternion is assumed to have unit length + + return this.conjugate(); + + } + + conjugate() { + + this._x *= - 1; + this._y *= - 1; + this._z *= - 1; + + this._onChangeCallback(); + + return this; + + } + + dot( v ) { + + return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; + + } + + lengthSq() { + + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + + } + + length() { + + return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); + + } + + normalize() { + + let l = this.length(); + + if ( l === 0 ) { + + this._x = 0; + this._y = 0; + this._z = 0; + this._w = 1; + + } else { + + l = 1 / l; + + this._x = this._x * l; + this._y = this._y * l; + this._z = this._z * l; + this._w = this._w * l; + + } + + this._onChangeCallback(); + + return this; + + } + + multiply( q, p ) { + + if ( p !== undefined ) { + + console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); + return this.multiplyQuaternions( q, p ); + + } + + return this.multiplyQuaternions( this, q ); + + } + + premultiply( q ) { + + return this.multiplyQuaternions( q, this ); + + } + + multiplyQuaternions( a, b ) { + + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + + const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; + const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; + + this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + + this._onChangeCallback(); + + return this; + + } + + slerp( qb, t ) { + + if ( t === 0 ) return this; + if ( t === 1 ) return this.copy( qb ); + + const x = this._x, y = this._y, z = this._z, w = this._w; + + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + + let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; + + if ( cosHalfTheta < 0 ) { + + this._w = - qb._w; + this._x = - qb._x; + this._y = - qb._y; + this._z = - qb._z; + + cosHalfTheta = - cosHalfTheta; + + } else { + + this.copy( qb ); + + } + + if ( cosHalfTheta >= 1.0 ) { + + this._w = w; + this._x = x; + this._y = y; + this._z = z; + + return this; + + } + + const sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; + + if ( sqrSinHalfTheta <= Number.EPSILON ) { + + const s = 1 - t; + this._w = s * w + t * this._w; + this._x = s * x + t * this._x; + this._y = s * y + t * this._y; + this._z = s * z + t * this._z; + + this.normalize(); + this._onChangeCallback(); + + return this; + + } + + const sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); + const halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); + const ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + + this._w = ( w * ratioA + this._w * ratioB ); + this._x = ( x * ratioA + this._x * ratioB ); + this._y = ( y * ratioA + this._y * ratioB ); + this._z = ( z * ratioA + this._z * ratioB ); + + this._onChangeCallback(); + + return this; + + } + + slerpQuaternions( qa, qb, t ) { + + return this.copy( qa ).slerp( qb, t ); + + } + + random() { + + // Derived from http://planning.cs.uiuc.edu/node198.html + // Note, this source uses w, x, y, z ordering, + // so we swap the order below. + + const u1 = Math.random(); + const sqrt1u1 = Math.sqrt( 1 - u1 ); + const sqrtu1 = Math.sqrt( u1 ); + + const u2 = 2 * Math.PI * Math.random(); + + const u3 = 2 * Math.PI * Math.random(); + + return this.set( + sqrt1u1 * Math.cos( u2 ), + sqrtu1 * Math.sin( u3 ), + sqrtu1 * Math.cos( u3 ), + sqrt1u1 * Math.sin( u2 ), + ); + + } + + equals( quaternion ) { + + return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); + + } + + fromArray( array, offset = 0 ) { + + this._x = array[ offset ]; + this._y = array[ offset + 1 ]; + this._z = array[ offset + 2 ]; + this._w = array[ offset + 3 ]; + + this._onChangeCallback(); + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._w; + + return array; + + } + + fromBufferAttribute( attribute, index ) { + + this._x = attribute.getX( index ); + this._y = attribute.getY( index ); + this._z = attribute.getZ( index ); + this._w = attribute.getW( index ); + + return this; + + } + + _onChange( callback ) { + + this._onChangeCallback = callback; + + return this; + + } + + _onChangeCallback() {} + +} + +Quaternion.prototype.isQuaternion = true; + +class Vector3 { + + constructor( x = 0, y = 0, z = 0 ) { + + this.x = x; + this.y = y; + this.z = z; + + } + + set( x, y, z ) { + + if ( z === undefined ) z = this.z; // sprite.scale.set(x,y) + + this.x = x; + this.y = y; + this.z = z; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + this.z = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setZ( z ) { + + this.z = z; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + case 2: this.z = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + case 2: return this.z; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y, this.z ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this.z = v.z; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + this.z += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + this.z -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + + return this; + + } + + multiply( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); + return this.multiplyVectors( v, w ); + + } + + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + + return this; + + } + + multiplyVectors( a, b ) { + + this.x = a.x * b.x; + this.y = a.y * b.y; + this.z = a.z * b.z; + + return this; + + } + + applyEuler( euler ) { + + if ( ! ( euler && euler.isEuler ) ) { + + console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + + } + + return this.applyQuaternion( _quaternion$4.setFromEuler( euler ) ); + + } + + applyAxisAngle( axis, angle ) { + + return this.applyQuaternion( _quaternion$4.setFromAxisAngle( axis, angle ) ); + + } + + applyMatrix3( m ) { + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; + this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; + + return this; + + } + + applyNormalMatrix( m ) { + + return this.applyMatrix3( m ).normalize(); + + } + + applyMatrix4( m ) { + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + const w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); + + this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w; + this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w; + this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w; + + return this; + + } + + applyQuaternion( q ) { + + const x = this.x, y = this.y, z = this.z; + const qx = q.x, qy = q.y, qz = q.z, qw = q.w; + + // calculate quat * vector + + const ix = qw * x + qy * z - qz * y; + const iy = qw * y + qz * x - qx * z; + const iz = qw * z + qx * y - qy * x; + const iw = - qx * x - qy * y - qz * z; + + // calculate result * inverse quat + + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; + + return this; + + } + + project( camera ) { + + return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); + + } + + unproject( camera ) { + + return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); + + } + + transformDirection( m ) { + + // input: THREE.Matrix4 affine matrix + // vector interpreted as a direction + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; + + return this.normalize(); + + } + + divide( v ) { + + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + this.z = Math.min( this.z, v.z ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + this.z = Math.max( this.z, v.z ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + this.z = Math.max( min.z, Math.min( max.z, this.z ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + this.z = Math.floor( this.z ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + this.z = Math.ceil( this.z ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + this.z = Math.round( this.z ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + this.z = - this.z; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y + this.z * v.z; + + } + + // TODO lengthSquared? + + lengthSq() { + + return this.x * this.x + this.y * this.y + this.z * this.z; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + this.z += ( v.z - this.z ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + this.z = v1.z + ( v2.z - v1.z ) * alpha; + + return this; + + } + + cross( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); + return this.crossVectors( v, w ); + + } + + return this.crossVectors( this, v ); + + } + + crossVectors( a, b ) { + + const ax = a.x, ay = a.y, az = a.z; + const bx = b.x, by = b.y, bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + + } + + projectOnVector( v ) { + + const denominator = v.lengthSq(); + + if ( denominator === 0 ) return this.set( 0, 0, 0 ); + + const scalar = v.dot( this ) / denominator; + + return this.copy( v ).multiplyScalar( scalar ); + + } + + projectOnPlane( planeNormal ) { + + _vector$c.copy( this ).projectOnVector( planeNormal ); + + return this.sub( _vector$c ); + + } + + reflect( normal ) { + + // reflect incident vector off plane orthogonal to normal + // normal is assumed to have unit length + + return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); + + } + + angleTo( v ) { + + const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); + + if ( denominator === 0 ) return Math.PI / 2; + + const theta = this.dot( v ) / denominator; + + // clamp, to handle numerical problems + + return Math.acos( clamp( theta, - 1, 1 ) ); + + } + + distanceTo( v ) { + + return Math.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + + return dx * dx + dy * dy + dz * dz; + + } + + manhattanDistanceTo( v ) { + + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); + + } + + setFromSpherical( s ) { + + return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); + + } + + setFromSphericalCoords( radius, phi, theta ) { + + const sinPhiRadius = Math.sin( phi ) * radius; + + this.x = sinPhiRadius * Math.sin( theta ); + this.y = Math.cos( phi ) * radius; + this.z = sinPhiRadius * Math.cos( theta ); + + return this; + + } + + setFromCylindrical( c ) { + + return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); + + } + + setFromCylindricalCoords( radius, theta, y ) { + + this.x = radius * Math.sin( theta ); + this.y = y; + this.z = radius * Math.cos( theta ); + + return this; + + } + + setFromMatrixPosition( m ) { + + const e = m.elements; + + this.x = e[ 12 ]; + this.y = e[ 13 ]; + this.z = e[ 14 ]; + + return this; + + } + + setFromMatrixScale( m ) { + + const sx = this.setFromMatrixColumn( m, 0 ).length(); + const sy = this.setFromMatrixColumn( m, 1 ).length(); + const sz = this.setFromMatrixColumn( m, 2 ).length(); + + this.x = sx; + this.y = sy; + this.z = sz; + + return this; + + } + + setFromMatrixColumn( m, index ) { + + return this.fromArray( m.elements, index * 4 ); + + } + + setFromMatrix3Column( m, index ) { + + return this.fromArray( m.elements, index * 3 ); + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + + return this; + + } + + randomDirection() { + + // Derived from https://mathworld.wolfram.com/SpherePointPicking.html + + const u = ( Math.random() - 0.5 ) * 2; + const t = Math.random() * Math.PI * 2; + const f = Math.sqrt( 1 - u ** 2 ); + + this.x = f * Math.cos( t ); + this.y = f * Math.sin( t ); + this.z = u; + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + yield this.z; + + } + +} + +Vector3.prototype.isVector3 = true; + +const _vector$c = /*@__PURE__*/ new Vector3(); +const _quaternion$4 = /*@__PURE__*/ new Quaternion(); + +class Box3 { + + constructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) { + + this.min = min; + this.max = max; + + } + + set( min, max ) { + + this.min.copy( min ); + this.max.copy( max ); + + return this; + + } + + setFromArray( array ) { + + let minX = + Infinity; + let minY = + Infinity; + let minZ = + Infinity; + + let maxX = - Infinity; + let maxY = - Infinity; + let maxZ = - Infinity; + + for ( let i = 0, l = array.length; i < l; i += 3 ) { + + const x = array[ i ]; + const y = array[ i + 1 ]; + const z = array[ i + 2 ]; + + if ( x < minX ) minX = x; + if ( y < minY ) minY = y; + if ( z < minZ ) minZ = z; + + if ( x > maxX ) maxX = x; + if ( y > maxY ) maxY = y; + if ( z > maxZ ) maxZ = z; + + } + + this.min.set( minX, minY, minZ ); + this.max.set( maxX, maxY, maxZ ); + + return this; + + } + + setFromBufferAttribute( attribute ) { + + let minX = + Infinity; + let minY = + Infinity; + let minZ = + Infinity; + + let maxX = - Infinity; + let maxY = - Infinity; + let maxZ = - Infinity; + + for ( let i = 0, l = attribute.count; i < l; i ++ ) { + + const x = attribute.getX( i ); + const y = attribute.getY( i ); + const z = attribute.getZ( i ); + + if ( x < minX ) minX = x; + if ( y < minY ) minY = y; + if ( z < minZ ) minZ = z; + + if ( x > maxX ) maxX = x; + if ( y > maxY ) maxY = y; + if ( z > maxZ ) maxZ = z; + + } + + this.min.set( minX, minY, minZ ); + this.max.set( maxX, maxY, maxZ ); + + return this; + + } + + setFromPoints( points ) { + + this.makeEmpty(); + + for ( let i = 0, il = points.length; i < il; i ++ ) { + + this.expandByPoint( points[ i ] ); + + } + + return this; + + } + + setFromCenterAndSize( center, size ) { + + const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 ); + + this.min.copy( center ).sub( halfSize ); + this.max.copy( center ).add( halfSize ); + + return this; + + } + + setFromObject( object ) { + + this.makeEmpty(); + + return this.expandByObject( object ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( box ) { + + this.min.copy( box.min ); + this.max.copy( box.max ); + + return this; + + } + + makeEmpty() { + + this.min.x = this.min.y = this.min.z = + Infinity; + this.max.x = this.max.y = this.max.z = - Infinity; + + return this; + + } + + isEmpty() { + + // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes + + return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z ); + + } + + getCenter( target ) { + + return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 ); + + } + + getSize( target ) { + + return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min ); + + } + + expandByPoint( point ) { + + this.min.min( point ); + this.max.max( point ); + + return this; + + } + + expandByVector( vector ) { + + this.min.sub( vector ); + this.max.add( vector ); + + return this; + + } + + expandByScalar( scalar ) { + + this.min.addScalar( - scalar ); + this.max.addScalar( scalar ); + + return this; + + } + + expandByObject( object ) { + + // Computes the world-axis-aligned bounding box of an object (including its children), + // accounting for both the object's, and children's, world transforms + + object.updateWorldMatrix( false, false ); + + const geometry = object.geometry; + + if ( geometry !== undefined ) { + + if ( geometry.boundingBox === null ) { + + geometry.computeBoundingBox(); + + } + + _box$3.copy( geometry.boundingBox ); + _box$3.applyMatrix4( object.matrixWorld ); + + this.union( _box$3 ); + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + this.expandByObject( children[ i ] ); + + } + + return this; + + } + + containsPoint( point ) { + + return point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y || + point.z < this.min.z || point.z > this.max.z ? false : true; + + } + + containsBox( box ) { + + return this.min.x <= box.min.x && box.max.x <= this.max.x && + this.min.y <= box.min.y && box.max.y <= this.max.y && + this.min.z <= box.min.z && box.max.z <= this.max.z; + + } + + getParameter( point, target ) { + + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + + return target.set( + ( point.x - this.min.x ) / ( this.max.x - this.min.x ), + ( point.y - this.min.y ) / ( this.max.y - this.min.y ), + ( point.z - this.min.z ) / ( this.max.z - this.min.z ) + ); + + } + + intersectsBox( box ) { + + // using 6 splitting planes to rule out intersections. + return box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y || + box.max.z < this.min.z || box.min.z > this.max.z ? false : true; + + } + + intersectsSphere( sphere ) { + + // Find the point on the AABB closest to the sphere center. + this.clampPoint( sphere.center, _vector$b ); + + // If that point is inside the sphere, the AABB and sphere intersect. + return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + + } + + intersectsPlane( plane ) { + + // We compute the minimum and maximum dot product values. If those values + // are on the same side (back or front) of the plane, then there is no intersection. + + let min, max; + + if ( plane.normal.x > 0 ) { + + min = plane.normal.x * this.min.x; + max = plane.normal.x * this.max.x; + + } else { + + min = plane.normal.x * this.max.x; + max = plane.normal.x * this.min.x; + + } + + if ( plane.normal.y > 0 ) { + + min += plane.normal.y * this.min.y; + max += plane.normal.y * this.max.y; + + } else { + + min += plane.normal.y * this.max.y; + max += plane.normal.y * this.min.y; + + } + + if ( plane.normal.z > 0 ) { + + min += plane.normal.z * this.min.z; + max += plane.normal.z * this.max.z; + + } else { + + min += plane.normal.z * this.max.z; + max += plane.normal.z * this.min.z; + + } + + return ( min <= - plane.constant && max >= - plane.constant ); + + } + + intersectsTriangle( triangle ) { + + if ( this.isEmpty() ) { + + return false; + + } + + // compute box center and extents + this.getCenter( _center ); + _extents.subVectors( this.max, _center ); + + // translate triangle to aabb origin + _v0$2.subVectors( triangle.a, _center ); + _v1$7.subVectors( triangle.b, _center ); + _v2$3.subVectors( triangle.c, _center ); + + // compute edge vectors for triangle + _f0.subVectors( _v1$7, _v0$2 ); + _f1.subVectors( _v2$3, _v1$7 ); + _f2.subVectors( _v0$2, _v2$3 ); + + // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb + // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation + // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned) + let axes = [ + 0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y, + _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x, + - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0 + ]; + if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) { + + return false; + + } + + // test 3 face normals from the aabb + axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ]; + if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) { + + return false; + + } + + // finally testing the face normal of the triangle + // use already existing triangle edge vectors here + _triangleNormal.crossVectors( _f0, _f1 ); + axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ]; + + return satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ); + + } + + clampPoint( point, target ) { + + return target.copy( point ).clamp( this.min, this.max ); + + } + + distanceToPoint( point ) { + + const clampedPoint = _vector$b.copy( point ).clamp( this.min, this.max ); + + return clampedPoint.sub( point ).length(); + + } + + getBoundingSphere( target ) { + + this.getCenter( target.center ); + + target.radius = this.getSize( _vector$b ).length() * 0.5; + + return target; + + } + + intersect( box ) { + + this.min.max( box.min ); + this.max.min( box.max ); + + // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values. + if ( this.isEmpty() ) this.makeEmpty(); + + return this; + + } + + union( box ) { + + this.min.min( box.min ); + this.max.max( box.max ); + + return this; + + } + + applyMatrix4( matrix ) { + + // transform of empty box is an empty box. + if ( this.isEmpty() ) return this; + + // NOTE: I am using a binary pattern to specify all 2^3 combinations below + _points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000 + _points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001 + _points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010 + _points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011 + _points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100 + _points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101 + _points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110 + _points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111 + + this.setFromPoints( _points ); + + return this; + + } + + translate( offset ) { + + this.min.add( offset ); + this.max.add( offset ); + + return this; + + } + + equals( box ) { + + return box.min.equals( this.min ) && box.max.equals( this.max ); + + } + +} + +Box3.prototype.isBox3 = true; + +const _points = [ + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3() +]; + +const _vector$b = /*@__PURE__*/ new Vector3(); + +const _box$3 = /*@__PURE__*/ new Box3(); + +// triangle centered vertices + +const _v0$2 = /*@__PURE__*/ new Vector3(); +const _v1$7 = /*@__PURE__*/ new Vector3(); +const _v2$3 = /*@__PURE__*/ new Vector3(); + +// triangle edge vectors + +const _f0 = /*@__PURE__*/ new Vector3(); +const _f1 = /*@__PURE__*/ new Vector3(); +const _f2 = /*@__PURE__*/ new Vector3(); + +const _center = /*@__PURE__*/ new Vector3(); +const _extents = /*@__PURE__*/ new Vector3(); +const _triangleNormal = /*@__PURE__*/ new Vector3(); +const _testAxis = /*@__PURE__*/ new Vector3(); + +function satForAxes( axes, v0, v1, v2, extents ) { + + for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) { + + _testAxis.fromArray( axes, i ); + // project the aabb onto the seperating axis + const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z ); + // project all 3 vertices of the triangle onto the seperating axis + const p0 = v0.dot( _testAxis ); + const p1 = v1.dot( _testAxis ); + const p2 = v2.dot( _testAxis ); + // actual test, basically see if either of the most extreme of the triangle points intersects r + if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) { + + // points of the projected triangle are outside the projected half-length of the aabb + // the axis is seperating and we can exit + return false; + + } + + } + + return true; + +} + +const _box$2 = /*@__PURE__*/ new Box3(); +const _v1$6 = /*@__PURE__*/ new Vector3(); +const _toFarthestPoint = /*@__PURE__*/ new Vector3(); +const _toPoint = /*@__PURE__*/ new Vector3(); + +class Sphere { + + constructor( center = new Vector3(), radius = - 1 ) { + + this.center = center; + this.radius = radius; + + } + + set( center, radius ) { + + this.center.copy( center ); + this.radius = radius; + + return this; + + } + + setFromPoints( points, optionalCenter ) { + + const center = this.center; + + if ( optionalCenter !== undefined ) { + + center.copy( optionalCenter ); + + } else { + + _box$2.setFromPoints( points ).getCenter( center ); + + } + + let maxRadiusSq = 0; + + for ( let i = 0, il = points.length; i < il; i ++ ) { + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) ); + + } + + this.radius = Math.sqrt( maxRadiusSq ); + + return this; + + } + + copy( sphere ) { + + this.center.copy( sphere.center ); + this.radius = sphere.radius; + + return this; + + } + + isEmpty() { + + return ( this.radius < 0 ); + + } + + makeEmpty() { + + this.center.set( 0, 0, 0 ); + this.radius = - 1; + + return this; + + } + + containsPoint( point ) { + + return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) ); + + } + + distanceToPoint( point ) { + + return ( point.distanceTo( this.center ) - this.radius ); + + } + + intersectsSphere( sphere ) { + + const radiusSum = this.radius + sphere.radius; + + return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum ); + + } + + intersectsBox( box ) { + + return box.intersectsSphere( this ); + + } + + intersectsPlane( plane ) { + + return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius; + + } + + clampPoint( point, target ) { + + const deltaLengthSq = this.center.distanceToSquared( point ); + + target.copy( point ); + + if ( deltaLengthSq > ( this.radius * this.radius ) ) { + + target.sub( this.center ).normalize(); + target.multiplyScalar( this.radius ).add( this.center ); + + } + + return target; + + } + + getBoundingBox( target ) { + + if ( this.isEmpty() ) { + + // Empty sphere produces empty bounding box + target.makeEmpty(); + return target; + + } + + target.set( this.center, this.center ); + target.expandByScalar( this.radius ); + + return target; + + } + + applyMatrix4( matrix ) { + + this.center.applyMatrix4( matrix ); + this.radius = this.radius * matrix.getMaxScaleOnAxis(); + + return this; + + } + + translate( offset ) { + + this.center.add( offset ); + + return this; + + } + + expandByPoint( point ) { + + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671 + + _toPoint.subVectors( point, this.center ); + + const lengthSq = _toPoint.lengthSq(); + + if ( lengthSq > ( this.radius * this.radius ) ) { + + const length = Math.sqrt( lengthSq ); + const missingRadiusHalf = ( length - this.radius ) * 0.5; + + // Nudge this sphere towards the target point. Add half the missing distance to radius, + // and the other half to position. This gives a tighter enclosure, instead of if + // the whole missing distance were just added to radius. + + this.center.add( _toPoint.multiplyScalar( missingRadiusHalf / length ) ); + this.radius += missingRadiusHalf; + + } + + return this; + + } + + union( sphere ) { + + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769 + + // To enclose another sphere into this sphere, we only need to enclose two points: + // 1) Enclose the farthest point on the other sphere into this sphere. + // 2) Enclose the opposite point of the farthest point into this sphere. + + if ( this.center.equals( sphere.center ) === true ) { + + _toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius ); + + + } else { + + _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius ); + + } + + this.expandByPoint( _v1$6.copy( sphere.center ).add( _toFarthestPoint ) ); + this.expandByPoint( _v1$6.copy( sphere.center ).sub( _toFarthestPoint ) ); + + return this; + + } + + equals( sphere ) { + + return sphere.center.equals( this.center ) && ( sphere.radius === this.radius ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +const _vector$a = /*@__PURE__*/ new Vector3(); +const _segCenter = /*@__PURE__*/ new Vector3(); +const _segDir = /*@__PURE__*/ new Vector3(); +const _diff = /*@__PURE__*/ new Vector3(); + +const _edge1 = /*@__PURE__*/ new Vector3(); +const _edge2 = /*@__PURE__*/ new Vector3(); +const _normal$1 = /*@__PURE__*/ new Vector3(); + +class Ray { + + constructor( origin = new Vector3(), direction = new Vector3( 0, 0, - 1 ) ) { + + this.origin = origin; + this.direction = direction; + + } + + set( origin, direction ) { + + this.origin.copy( origin ); + this.direction.copy( direction ); + + return this; + + } + + copy( ray ) { + + this.origin.copy( ray.origin ); + this.direction.copy( ray.direction ); + + return this; + + } + + at( t, target ) { + + return target.copy( this.direction ).multiplyScalar( t ).add( this.origin ); + + } + + lookAt( v ) { + + this.direction.copy( v ).sub( this.origin ).normalize(); + + return this; + + } + + recast( t ) { + + this.origin.copy( this.at( t, _vector$a ) ); + + return this; + + } + + closestPointToPoint( point, target ) { + + target.subVectors( point, this.origin ); + + const directionDistance = target.dot( this.direction ); + + if ( directionDistance < 0 ) { + + return target.copy( this.origin ); + + } + + return target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + + } + + distanceToPoint( point ) { + + return Math.sqrt( this.distanceSqToPoint( point ) ); + + } + + distanceSqToPoint( point ) { + + const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction ); + + // point behind the ray + + if ( directionDistance < 0 ) { + + return this.origin.distanceToSquared( point ); + + } + + _vector$a.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + + return _vector$a.distanceToSquared( point ); + + } + + distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { + + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h + // It returns the min distance between the ray and the segment + // defined by v0 and v1 + // It can also set two optional targets : + // - The closest point on the ray + // - The closest point on the segment + + _segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 ); + _segDir.copy( v1 ).sub( v0 ).normalize(); + _diff.copy( this.origin ).sub( _segCenter ); + + const segExtent = v0.distanceTo( v1 ) * 0.5; + const a01 = - this.direction.dot( _segDir ); + const b0 = _diff.dot( this.direction ); + const b1 = - _diff.dot( _segDir ); + const c = _diff.lengthSq(); + const det = Math.abs( 1 - a01 * a01 ); + let s0, s1, sqrDist, extDet; + + if ( det > 0 ) { + + // The ray and segment are not parallel. + + s0 = a01 * b1 - b0; + s1 = a01 * b0 - b1; + extDet = segExtent * det; + + if ( s0 >= 0 ) { + + if ( s1 >= - extDet ) { + + if ( s1 <= extDet ) { + + // region 0 + // Minimum at interior points of ray and segment. + + const invDet = 1 / det; + s0 *= invDet; + s1 *= invDet; + sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c; + + } else { + + // region 1 + + s1 = segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } else { + + // region 5 + + s1 = - segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } else { + + if ( s1 <= - extDet ) { + + // region 4 + + s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) ); + s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } else if ( s1 <= extDet ) { + + // region 3 + + s0 = 0; + s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = s1 * ( s1 + 2 * b1 ) + c; + + } else { + + // region 2 + + s0 = Math.max( 0, - ( a01 * segExtent + b0 ) ); + s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } + + } else { + + // Ray and segment are parallel. + + s1 = ( a01 > 0 ) ? - segExtent : segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + if ( optionalPointOnRay ) { + + optionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin ); + + } + + if ( optionalPointOnSegment ) { + + optionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter ); + + } + + return sqrDist; + + } + + intersectSphere( sphere, target ) { + + _vector$a.subVectors( sphere.center, this.origin ); + const tca = _vector$a.dot( this.direction ); + const d2 = _vector$a.dot( _vector$a ) - tca * tca; + const radius2 = sphere.radius * sphere.radius; + + if ( d2 > radius2 ) return null; + + const thc = Math.sqrt( radius2 - d2 ); + + // t0 = first intersect point - entrance on front of sphere + const t0 = tca - thc; + + // t1 = second intersect point - exit point on back of sphere + const t1 = tca + thc; + + // test to see if both t0 and t1 are behind the ray - if so, return null + if ( t0 < 0 && t1 < 0 ) return null; + + // test to see if t0 is behind the ray: + // if it is, the ray is inside the sphere, so return the second exit point scaled by t1, + // in order to always return an intersect point that is in front of the ray. + if ( t0 < 0 ) return this.at( t1, target ); + + // else t0 is in front of the ray, so return the first collision point scaled by t0 + return this.at( t0, target ); + + } + + intersectsSphere( sphere ) { + + return this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius ); + + } + + distanceToPlane( plane ) { + + const denominator = plane.normal.dot( this.direction ); + + if ( denominator === 0 ) { + + // line is coplanar, return origin + if ( plane.distanceToPoint( this.origin ) === 0 ) { + + return 0; + + } + + // Null is preferable to undefined since undefined means.... it is undefined + + return null; + + } + + const t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator; + + // Return if the ray never intersects the plane + + return t >= 0 ? t : null; + + } + + intersectPlane( plane, target ) { + + const t = this.distanceToPlane( plane ); + + if ( t === null ) { + + return null; + + } + + return this.at( t, target ); + + } + + intersectsPlane( plane ) { + + // check if the ray lies on the plane first + + const distToPoint = plane.distanceToPoint( this.origin ); + + if ( distToPoint === 0 ) { + + return true; + + } + + const denominator = plane.normal.dot( this.direction ); + + if ( denominator * distToPoint < 0 ) { + + return true; + + } + + // ray origin is behind the plane (and is pointing behind it) + + return false; + + } + + intersectBox( box, target ) { + + let tmin, tmax, tymin, tymax, tzmin, tzmax; + + const invdirx = 1 / this.direction.x, + invdiry = 1 / this.direction.y, + invdirz = 1 / this.direction.z; + + const origin = this.origin; + + if ( invdirx >= 0 ) { + + tmin = ( box.min.x - origin.x ) * invdirx; + tmax = ( box.max.x - origin.x ) * invdirx; + + } else { + + tmin = ( box.max.x - origin.x ) * invdirx; + tmax = ( box.min.x - origin.x ) * invdirx; + + } + + if ( invdiry >= 0 ) { + + tymin = ( box.min.y - origin.y ) * invdiry; + tymax = ( box.max.y - origin.y ) * invdiry; + + } else { + + tymin = ( box.max.y - origin.y ) * invdiry; + tymax = ( box.min.y - origin.y ) * invdiry; + + } + + if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null; + + // These lines also handle the case where tmin or tmax is NaN + // (result of 0 * Infinity). x !== x returns true if x is NaN + + if ( tymin > tmin || tmin !== tmin ) tmin = tymin; + + if ( tymax < tmax || tmax !== tmax ) tmax = tymax; + + if ( invdirz >= 0 ) { + + tzmin = ( box.min.z - origin.z ) * invdirz; + tzmax = ( box.max.z - origin.z ) * invdirz; + + } else { + + tzmin = ( box.max.z - origin.z ) * invdirz; + tzmax = ( box.min.z - origin.z ) * invdirz; + + } + + if ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null; + + if ( tzmin > tmin || tmin !== tmin ) tmin = tzmin; + + if ( tzmax < tmax || tmax !== tmax ) tmax = tzmax; + + //return point closest to the ray (positive side) + + if ( tmax < 0 ) return null; + + return this.at( tmin >= 0 ? tmin : tmax, target ); + + } + + intersectsBox( box ) { + + return this.intersectBox( box, _vector$a ) !== null; + + } + + intersectTriangle( a, b, c, backfaceCulling, target ) { + + // Compute the offset origin, edges, and normal. + + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h + + _edge1.subVectors( b, a ); + _edge2.subVectors( c, a ); + _normal$1.crossVectors( _edge1, _edge2 ); + + // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction, + // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by + // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2)) + // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q)) + // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N) + let DdN = this.direction.dot( _normal$1 ); + let sign; + + if ( DdN > 0 ) { + + if ( backfaceCulling ) return null; + sign = 1; + + } else if ( DdN < 0 ) { + + sign = - 1; + DdN = - DdN; + + } else { + + return null; + + } + + _diff.subVectors( this.origin, a ); + const DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) ); + + // b1 < 0, no intersection + if ( DdQxE2 < 0 ) { + + return null; + + } + + const DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) ); + + // b2 < 0, no intersection + if ( DdE1xQ < 0 ) { + + return null; + + } + + // b1+b2 > 1, no intersection + if ( DdQxE2 + DdE1xQ > DdN ) { + + return null; + + } + + // Line intersects triangle, check if ray does. + const QdN = - sign * _diff.dot( _normal$1 ); + + // t < 0, no intersection + if ( QdN < 0 ) { + + return null; + + } + + // Ray intersects triangle. + return this.at( QdN / DdN, target ); + + } + + applyMatrix4( matrix4 ) { + + this.origin.applyMatrix4( matrix4 ); + this.direction.transformDirection( matrix4 ); + + return this; + + } + + equals( ray ) { + + return ray.origin.equals( this.origin ) && ray.direction.equals( this.direction ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +class Matrix4 { + + constructor() { + + this.elements = [ + + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ]; + + if ( arguments.length > 0 ) { + + console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' ); + + } + + } + + set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { + + const te = this.elements; + + te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14; + te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24; + te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34; + te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44; + + return this; + + } + + identity() { + + this.set( + + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + clone() { + + return new Matrix4().fromArray( this.elements ); + + } + + copy( m ) { + + const te = this.elements; + const me = m.elements; + + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ]; + te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; + te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ]; + te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ]; + + return this; + + } + + copyPosition( m ) { + + const te = this.elements, me = m.elements; + + te[ 12 ] = me[ 12 ]; + te[ 13 ] = me[ 13 ]; + te[ 14 ] = me[ 14 ]; + + return this; + + } + + setFromMatrix3( m ) { + + const me = m.elements; + + this.set( + + me[ 0 ], me[ 3 ], me[ 6 ], 0, + me[ 1 ], me[ 4 ], me[ 7 ], 0, + me[ 2 ], me[ 5 ], me[ 8 ], 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + extractBasis( xAxis, yAxis, zAxis ) { + + xAxis.setFromMatrixColumn( this, 0 ); + yAxis.setFromMatrixColumn( this, 1 ); + zAxis.setFromMatrixColumn( this, 2 ); + + return this; + + } + + makeBasis( xAxis, yAxis, zAxis ) { + + this.set( + xAxis.x, yAxis.x, zAxis.x, 0, + xAxis.y, yAxis.y, zAxis.y, 0, + xAxis.z, yAxis.z, zAxis.z, 0, + 0, 0, 0, 1 + ); + + return this; + + } + + extractRotation( m ) { + + // this method does not support reflection matrices + + const te = this.elements; + const me = m.elements; + + const scaleX = 1 / _v1$5.setFromMatrixColumn( m, 0 ).length(); + const scaleY = 1 / _v1$5.setFromMatrixColumn( m, 1 ).length(); + const scaleZ = 1 / _v1$5.setFromMatrixColumn( m, 2 ).length(); + + te[ 0 ] = me[ 0 ] * scaleX; + te[ 1 ] = me[ 1 ] * scaleX; + te[ 2 ] = me[ 2 ] * scaleX; + te[ 3 ] = 0; + + te[ 4 ] = me[ 4 ] * scaleY; + te[ 5 ] = me[ 5 ] * scaleY; + te[ 6 ] = me[ 6 ] * scaleY; + te[ 7 ] = 0; + + te[ 8 ] = me[ 8 ] * scaleZ; + te[ 9 ] = me[ 9 ] * scaleZ; + te[ 10 ] = me[ 10 ] * scaleZ; + te[ 11 ] = 0; + + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; + + return this; + + } + + makeRotationFromEuler( euler ) { + + if ( ! ( euler && euler.isEuler ) ) { + + console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' ); + + } + + const te = this.elements; + + const x = euler.x, y = euler.y, z = euler.z; + const a = Math.cos( x ), b = Math.sin( x ); + const c = Math.cos( y ), d = Math.sin( y ); + const e = Math.cos( z ), f = Math.sin( z ); + + if ( euler.order === 'XYZ' ) { + + const ae = a * e, af = a * f, be = b * e, bf = b * f; + + te[ 0 ] = c * e; + te[ 4 ] = - c * f; + te[ 8 ] = d; + + te[ 1 ] = af + be * d; + te[ 5 ] = ae - bf * d; + te[ 9 ] = - b * c; + + te[ 2 ] = bf - ae * d; + te[ 6 ] = be + af * d; + te[ 10 ] = a * c; + + } else if ( euler.order === 'YXZ' ) { + + const ce = c * e, cf = c * f, de = d * e, df = d * f; + + te[ 0 ] = ce + df * b; + te[ 4 ] = de * b - cf; + te[ 8 ] = a * d; + + te[ 1 ] = a * f; + te[ 5 ] = a * e; + te[ 9 ] = - b; + + te[ 2 ] = cf * b - de; + te[ 6 ] = df + ce * b; + te[ 10 ] = a * c; + + } else if ( euler.order === 'ZXY' ) { + + const ce = c * e, cf = c * f, de = d * e, df = d * f; + + te[ 0 ] = ce - df * b; + te[ 4 ] = - a * f; + te[ 8 ] = de + cf * b; + + te[ 1 ] = cf + de * b; + te[ 5 ] = a * e; + te[ 9 ] = df - ce * b; + + te[ 2 ] = - a * d; + te[ 6 ] = b; + te[ 10 ] = a * c; + + } else if ( euler.order === 'ZYX' ) { + + const ae = a * e, af = a * f, be = b * e, bf = b * f; + + te[ 0 ] = c * e; + te[ 4 ] = be * d - af; + te[ 8 ] = ae * d + bf; + + te[ 1 ] = c * f; + te[ 5 ] = bf * d + ae; + te[ 9 ] = af * d - be; + + te[ 2 ] = - d; + te[ 6 ] = b * c; + te[ 10 ] = a * c; + + } else if ( euler.order === 'YZX' ) { + + const ac = a * c, ad = a * d, bc = b * c, bd = b * d; + + te[ 0 ] = c * e; + te[ 4 ] = bd - ac * f; + te[ 8 ] = bc * f + ad; + + te[ 1 ] = f; + te[ 5 ] = a * e; + te[ 9 ] = - b * e; + + te[ 2 ] = - d * e; + te[ 6 ] = ad * f + bc; + te[ 10 ] = ac - bd * f; + + } else if ( euler.order === 'XZY' ) { + + const ac = a * c, ad = a * d, bc = b * c, bd = b * d; + + te[ 0 ] = c * e; + te[ 4 ] = - f; + te[ 8 ] = d * e; + + te[ 1 ] = ac * f + bd; + te[ 5 ] = a * e; + te[ 9 ] = ad * f - bc; + + te[ 2 ] = bc * f - ad; + te[ 6 ] = b * e; + te[ 10 ] = bd * f + ac; + + } + + // bottom row + te[ 3 ] = 0; + te[ 7 ] = 0; + te[ 11 ] = 0; + + // last column + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; + + return this; + + } + + makeRotationFromQuaternion( q ) { + + return this.compose( _zero, q, _one ); + + } + + lookAt( eye, target, up ) { + + const te = this.elements; + + _z.subVectors( eye, target ); + + if ( _z.lengthSq() === 0 ) { + + // eye and target are in the same position + + _z.z = 1; + + } + + _z.normalize(); + _x.crossVectors( up, _z ); + + if ( _x.lengthSq() === 0 ) { + + // up and z are parallel + + if ( Math.abs( up.z ) === 1 ) { + + _z.x += 0.0001; + + } else { + + _z.z += 0.0001; + + } + + _z.normalize(); + _x.crossVectors( up, _z ); + + } + + _x.normalize(); + _y.crossVectors( _z, _x ); + + te[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x; + te[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y; + te[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z; + + return this; + + } + + multiply( m, n ) { + + if ( n !== undefined ) { + + console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' ); + return this.multiplyMatrices( m, n ); + + } + + return this.multiplyMatrices( this, m ); + + } + + premultiply( m ) { + + return this.multiplyMatrices( m, this ); + + } + + multiplyMatrices( a, b ) { + + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ]; + const a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ]; + const a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ]; + const a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ]; + + const b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ]; + const b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ]; + const b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ]; + const b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ]; + + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; + te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; + te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; + te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; + + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; + te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; + te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; + te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; + + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; + te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; + te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; + te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; + + te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; + te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; + te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; + te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + + return this; + + } + + multiplyScalar( s ) { + + const te = this.elements; + + te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s; + te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s; + te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s; + te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s; + + return this; + + } + + determinant() { + + const te = this.elements; + + const n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ]; + const n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ]; + const n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ]; + const n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ]; + + //TODO: make this more efficient + //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm ) + + return ( + n41 * ( + + n14 * n23 * n32 + - n13 * n24 * n32 + - n14 * n22 * n33 + + n12 * n24 * n33 + + n13 * n22 * n34 + - n12 * n23 * n34 + ) + + n42 * ( + + n11 * n23 * n34 + - n11 * n24 * n33 + + n14 * n21 * n33 + - n13 * n21 * n34 + + n13 * n24 * n31 + - n14 * n23 * n31 + ) + + n43 * ( + + n11 * n24 * n32 + - n11 * n22 * n34 + - n14 * n21 * n32 + + n12 * n21 * n34 + + n14 * n22 * n31 + - n12 * n24 * n31 + ) + + n44 * ( + - n13 * n22 * n31 + - n11 * n23 * n32 + + n11 * n22 * n33 + + n13 * n21 * n32 + - n12 * n21 * n33 + + n12 * n23 * n31 + ) + + ); + + } + + transpose() { + + const te = this.elements; + let tmp; + + tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp; + tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp; + tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp; + + tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp; + tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp; + tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp; + + return this; + + } + + setPosition( x, y, z ) { + + const te = this.elements; + + if ( x.isVector3 ) { + + te[ 12 ] = x.x; + te[ 13 ] = x.y; + te[ 14 ] = x.z; + + } else { + + te[ 12 ] = x; + te[ 13 ] = y; + te[ 14 ] = z; + + } + + return this; + + } + + invert() { + + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + const te = this.elements, + + n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], n41 = te[ 3 ], + n12 = te[ 4 ], n22 = te[ 5 ], n32 = te[ 6 ], n42 = te[ 7 ], + n13 = te[ 8 ], n23 = te[ 9 ], n33 = te[ 10 ], n43 = te[ 11 ], + n14 = te[ 12 ], n24 = te[ 13 ], n34 = te[ 14 ], n44 = te[ 15 ], + + t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, + t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, + t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, + t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34; + + const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14; + + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); + + const detInv = 1 / det; + + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv; + te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv; + te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv; + + te[ 4 ] = t12 * detInv; + te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv; + te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv; + te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv; + + te[ 8 ] = t13 * detInv; + te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv; + te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv; + te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv; + + te[ 12 ] = t14 * detInv; + te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv; + te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv; + te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv; + + return this; + + } + + scale( v ) { + + const te = this.elements; + const x = v.x, y = v.y, z = v.z; + + te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z; + te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z; + te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z; + te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z; + + return this; + + } + + getMaxScaleOnAxis() { + + const te = this.elements; + + const scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ]; + const scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ]; + const scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ]; + + return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) ); + + } + + makeTranslation( x, y, z ) { + + this.set( + + 1, 0, 0, x, + 0, 1, 0, y, + 0, 0, 1, z, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationX( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + 1, 0, 0, 0, + 0, c, - s, 0, + 0, s, c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationY( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + c, 0, s, 0, + 0, 1, 0, 0, + - s, 0, c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationZ( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + c, - s, 0, 0, + s, c, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationAxis( axis, angle ) { + + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + const c = Math.cos( angle ); + const s = Math.sin( angle ); + const t = 1 - c; + const x = axis.x, y = axis.y, z = axis.z; + const tx = t * x, ty = t * y; + + this.set( + + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeScale( x, y, z ) { + + this.set( + + x, 0, 0, 0, + 0, y, 0, 0, + 0, 0, z, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeShear( xy, xz, yx, yz, zx, zy ) { + + this.set( + + 1, yx, zx, 0, + xy, 1, zy, 0, + xz, yz, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + compose( position, quaternion, scale ) { + + const te = this.elements; + + const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w; + const x2 = x + x, y2 = y + y, z2 = z + z; + const xx = x * x2, xy = x * y2, xz = x * z2; + const yy = y * y2, yz = y * z2, zz = z * z2; + const wx = w * x2, wy = w * y2, wz = w * z2; + + const sx = scale.x, sy = scale.y, sz = scale.z; + + te[ 0 ] = ( 1 - ( yy + zz ) ) * sx; + te[ 1 ] = ( xy + wz ) * sx; + te[ 2 ] = ( xz - wy ) * sx; + te[ 3 ] = 0; + + te[ 4 ] = ( xy - wz ) * sy; + te[ 5 ] = ( 1 - ( xx + zz ) ) * sy; + te[ 6 ] = ( yz + wx ) * sy; + te[ 7 ] = 0; + + te[ 8 ] = ( xz + wy ) * sz; + te[ 9 ] = ( yz - wx ) * sz; + te[ 10 ] = ( 1 - ( xx + yy ) ) * sz; + te[ 11 ] = 0; + + te[ 12 ] = position.x; + te[ 13 ] = position.y; + te[ 14 ] = position.z; + te[ 15 ] = 1; + + return this; + + } + + decompose( position, quaternion, scale ) { + + const te = this.elements; + + let sx = _v1$5.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length(); + const sy = _v1$5.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length(); + const sz = _v1$5.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length(); + + // if determine is negative, we need to invert one scale + const det = this.determinant(); + if ( det < 0 ) sx = - sx; + + position.x = te[ 12 ]; + position.y = te[ 13 ]; + position.z = te[ 14 ]; + + // scale the rotation part + _m1$2.copy( this ); + + const invSX = 1 / sx; + const invSY = 1 / sy; + const invSZ = 1 / sz; + + _m1$2.elements[ 0 ] *= invSX; + _m1$2.elements[ 1 ] *= invSX; + _m1$2.elements[ 2 ] *= invSX; + + _m1$2.elements[ 4 ] *= invSY; + _m1$2.elements[ 5 ] *= invSY; + _m1$2.elements[ 6 ] *= invSY; + + _m1$2.elements[ 8 ] *= invSZ; + _m1$2.elements[ 9 ] *= invSZ; + _m1$2.elements[ 10 ] *= invSZ; + + quaternion.setFromRotationMatrix( _m1$2 ); + + scale.x = sx; + scale.y = sy; + scale.z = sz; + + return this; + + } + + makePerspective( left, right, top, bottom, near, far ) { + + if ( far === undefined ) { + + console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' ); + + } + + const te = this.elements; + const x = 2 * near / ( right - left ); + const y = 2 * near / ( top - bottom ); + + const a = ( right + left ) / ( right - left ); + const b = ( top + bottom ) / ( top - bottom ); + const c = - ( far + near ) / ( far - near ); + const d = - 2 * far * near / ( far - near ); + + te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0; + te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0; + + return this; + + } + + makeOrthographic( left, right, top, bottom, near, far ) { + + const te = this.elements; + const w = 1.0 / ( right - left ); + const h = 1.0 / ( top - bottom ); + const p = 1.0 / ( far - near ); + + const x = ( right + left ) * w; + const y = ( top + bottom ) * h; + const z = ( far + near ) * p; + + te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x; + te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1; + + return this; + + } + + equals( matrix ) { + + const te = this.elements; + const me = matrix.elements; + + for ( let i = 0; i < 16; i ++ ) { + + if ( te[ i ] !== me[ i ] ) return false; + + } + + return true; + + } + + fromArray( array, offset = 0 ) { + + for ( let i = 0; i < 16; i ++ ) { + + this.elements[ i ] = array[ i + offset ]; + + } + + return this; + + } + + toArray( array = [], offset = 0 ) { + + const te = this.elements; + + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + array[ offset + 3 ] = te[ 3 ]; + + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + + array[ offset + 8 ] = te[ 8 ]; + array[ offset + 9 ] = te[ 9 ]; + array[ offset + 10 ] = te[ 10 ]; + array[ offset + 11 ] = te[ 11 ]; + + array[ offset + 12 ] = te[ 12 ]; + array[ offset + 13 ] = te[ 13 ]; + array[ offset + 14 ] = te[ 14 ]; + array[ offset + 15 ] = te[ 15 ]; + + return array; + + } + +} + +Matrix4.prototype.isMatrix4 = true; + +const _v1$5 = /*@__PURE__*/ new Vector3(); +const _m1$2 = /*@__PURE__*/ new Matrix4(); +const _zero = /*@__PURE__*/ new Vector3( 0, 0, 0 ); +const _one = /*@__PURE__*/ new Vector3( 1, 1, 1 ); +const _x = /*@__PURE__*/ new Vector3(); +const _y = /*@__PURE__*/ new Vector3(); +const _z = /*@__PURE__*/ new Vector3(); + +const _matrix$1 = /*@__PURE__*/ new Matrix4(); +const _quaternion$3 = /*@__PURE__*/ new Quaternion(); + +class Euler { + + constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) { + + this._x = x; + this._y = y; + this._z = z; + this._order = order; + + } + + get x() { + + return this._x; + + } + + set x( value ) { + + this._x = value; + this._onChangeCallback(); + + } + + get y() { + + return this._y; + + } + + set y( value ) { + + this._y = value; + this._onChangeCallback(); + + } + + get z() { + + return this._z; + + } + + set z( value ) { + + this._z = value; + this._onChangeCallback(); + + } + + get order() { + + return this._order; + + } + + set order( value ) { + + this._order = value; + this._onChangeCallback(); + + } + + set( x, y, z, order = this._order ) { + + this._x = x; + this._y = y; + this._z = z; + this._order = order; + + this._onChangeCallback(); + + return this; + + } + + clone() { + + return new this.constructor( this._x, this._y, this._z, this._order ); + + } + + copy( euler ) { + + this._x = euler._x; + this._y = euler._y; + this._z = euler._z; + this._order = euler._order; + + this._onChangeCallback(); + + return this; + + } + + setFromRotationMatrix( m, order = this._order, update = true ) { + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements; + const m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ]; + const m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ]; + const m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; + + switch ( order ) { + + case 'XYZ': + + this._y = Math.asin( clamp( m13, - 1, 1 ) ); + + if ( Math.abs( m13 ) < 0.9999999 ) { + + this._x = Math.atan2( - m23, m33 ); + this._z = Math.atan2( - m12, m11 ); + + } else { + + this._x = Math.atan2( m32, m22 ); + this._z = 0; + + } + + break; + + case 'YXZ': + + this._x = Math.asin( - clamp( m23, - 1, 1 ) ); + + if ( Math.abs( m23 ) < 0.9999999 ) { + + this._y = Math.atan2( m13, m33 ); + this._z = Math.atan2( m21, m22 ); + + } else { + + this._y = Math.atan2( - m31, m11 ); + this._z = 0; + + } + + break; + + case 'ZXY': + + this._x = Math.asin( clamp( m32, - 1, 1 ) ); + + if ( Math.abs( m32 ) < 0.9999999 ) { + + this._y = Math.atan2( - m31, m33 ); + this._z = Math.atan2( - m12, m22 ); + + } else { + + this._y = 0; + this._z = Math.atan2( m21, m11 ); + + } + + break; + + case 'ZYX': + + this._y = Math.asin( - clamp( m31, - 1, 1 ) ); + + if ( Math.abs( m31 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m33 ); + this._z = Math.atan2( m21, m11 ); + + } else { + + this._x = 0; + this._z = Math.atan2( - m12, m22 ); + + } + + break; + + case 'YZX': + + this._z = Math.asin( clamp( m21, - 1, 1 ) ); + + if ( Math.abs( m21 ) < 0.9999999 ) { + + this._x = Math.atan2( - m23, m22 ); + this._y = Math.atan2( - m31, m11 ); + + } else { + + this._x = 0; + this._y = Math.atan2( m13, m33 ); + + } + + break; + + case 'XZY': + + this._z = Math.asin( - clamp( m12, - 1, 1 ) ); + + if ( Math.abs( m12 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m22 ); + this._y = Math.atan2( m13, m11 ); + + } else { + + this._x = Math.atan2( - m23, m33 ); + this._y = 0; + + } + + break; + + default: + + console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order ); + + } + + this._order = order; + + if ( update === true ) this._onChangeCallback(); + + return this; + + } + + setFromQuaternion( q, order, update ) { + + _matrix$1.makeRotationFromQuaternion( q ); + + return this.setFromRotationMatrix( _matrix$1, order, update ); + + } + + setFromVector3( v, order = this._order ) { + + return this.set( v.x, v.y, v.z, order ); + + } + + reorder( newOrder ) { + + // WARNING: this discards revolution information -bhouston + + _quaternion$3.setFromEuler( this ); + + return this.setFromQuaternion( _quaternion$3, newOrder ); + + } + + equals( euler ) { + + return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order ); + + } + + fromArray( array ) { + + this._x = array[ 0 ]; + this._y = array[ 1 ]; + this._z = array[ 2 ]; + if ( array[ 3 ] !== undefined ) this._order = array[ 3 ]; + + this._onChangeCallback(); + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._order; + + return array; + + } + + toVector3( optionalResult ) { + + if ( optionalResult ) { + + return optionalResult.set( this._x, this._y, this._z ); + + } else { + + return new Vector3( this._x, this._y, this._z ); + + } + + } + + _onChange( callback ) { + + this._onChangeCallback = callback; + + return this; + + } + + _onChangeCallback() {} + +} + +Euler.prototype.isEuler = true; + +Euler.DefaultOrder = 'XYZ'; +Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ]; + +class Layers { + + constructor() { + + this.mask = 1 | 0; + + } + + set( channel ) { + + this.mask = ( 1 << channel | 0 ) >>> 0; + + } + + enable( channel ) { + + this.mask |= 1 << channel | 0; + + } + + enableAll() { + + this.mask = 0xffffffff | 0; + + } + + toggle( channel ) { + + this.mask ^= 1 << channel | 0; + + } + + disable( channel ) { + + this.mask &= ~ ( 1 << channel | 0 ); + + } + + disableAll() { + + this.mask = 0; + + } + + test( layers ) { + + return ( this.mask & layers.mask ) !== 0; + + } + + isEnabled( channel ) { + + return ( this.mask & ( 1 << channel | 0 ) ) !== 0; + + } + +} + +let _object3DId = 0; + +const _v1$4 = /*@__PURE__*/ new Vector3(); +const _q1 = /*@__PURE__*/ new Quaternion(); +const _m1$1 = /*@__PURE__*/ new Matrix4(); +const _target = /*@__PURE__*/ new Vector3(); + +const _position$3 = /*@__PURE__*/ new Vector3(); +const _scale$2 = /*@__PURE__*/ new Vector3(); +const _quaternion$2 = /*@__PURE__*/ new Quaternion(); + +const _xAxis = /*@__PURE__*/ new Vector3( 1, 0, 0 ); +const _yAxis = /*@__PURE__*/ new Vector3( 0, 1, 0 ); +const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 ); + +const _addedEvent = { type: 'added' }; +const _removedEvent = { type: 'removed' }; + +class Object3D extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: _object3DId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'Object3D'; + + this.parent = null; + this.children = []; + + this.up = Object3D.DefaultUp.clone(); + + const position = new Vector3(); + const rotation = new Euler(); + const quaternion = new Quaternion(); + const scale = new Vector3( 1, 1, 1 ); + + function onRotationChange() { + + quaternion.setFromEuler( rotation, false ); + + } + + function onQuaternionChange() { + + rotation.setFromQuaternion( quaternion, undefined, false ); + + } + + rotation._onChange( onRotationChange ); + quaternion._onChange( onQuaternionChange ); + + Object.defineProperties( this, { + position: { + configurable: true, + enumerable: true, + value: position + }, + rotation: { + configurable: true, + enumerable: true, + value: rotation + }, + quaternion: { + configurable: true, + enumerable: true, + value: quaternion + }, + scale: { + configurable: true, + enumerable: true, + value: scale + }, + modelViewMatrix: { + value: new Matrix4() + }, + normalMatrix: { + value: new Matrix3() + } + } ); + + this.matrix = new Matrix4(); + this.matrixWorld = new Matrix4(); + + this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate; + this.matrixWorldNeedsUpdate = false; + + this.layers = new Layers(); + this.visible = true; + + this.castShadow = false; + this.receiveShadow = false; + + this.frustumCulled = true; + this.renderOrder = 0; + + this.animations = []; + + this.userData = {}; + + } + + onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {} + + onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {} + + applyMatrix4( matrix ) { + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + this.matrix.premultiply( matrix ); + + this.matrix.decompose( this.position, this.quaternion, this.scale ); + + } + + applyQuaternion( q ) { + + this.quaternion.premultiply( q ); + + return this; + + } + + setRotationFromAxisAngle( axis, angle ) { + + // assumes axis is normalized + + this.quaternion.setFromAxisAngle( axis, angle ); + + } + + setRotationFromEuler( euler ) { + + this.quaternion.setFromEuler( euler, true ); + + } + + setRotationFromMatrix( m ) { + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + this.quaternion.setFromRotationMatrix( m ); + + } + + setRotationFromQuaternion( q ) { + + // assumes q is normalized + + this.quaternion.copy( q ); + + } + + rotateOnAxis( axis, angle ) { + + // rotate object on axis in object space + // axis is assumed to be normalized + + _q1.setFromAxisAngle( axis, angle ); + + this.quaternion.multiply( _q1 ); + + return this; + + } + + rotateOnWorldAxis( axis, angle ) { + + // rotate object on axis in world space + // axis is assumed to be normalized + // method assumes no rotated parent + + _q1.setFromAxisAngle( axis, angle ); + + this.quaternion.premultiply( _q1 ); + + return this; + + } + + rotateX( angle ) { + + return this.rotateOnAxis( _xAxis, angle ); + + } + + rotateY( angle ) { + + return this.rotateOnAxis( _yAxis, angle ); + + } + + rotateZ( angle ) { + + return this.rotateOnAxis( _zAxis, angle ); + + } + + translateOnAxis( axis, distance ) { + + // translate object by distance along axis in object space + // axis is assumed to be normalized + + _v1$4.copy( axis ).applyQuaternion( this.quaternion ); + + this.position.add( _v1$4.multiplyScalar( distance ) ); + + return this; + + } + + translateX( distance ) { + + return this.translateOnAxis( _xAxis, distance ); + + } + + translateY( distance ) { + + return this.translateOnAxis( _yAxis, distance ); + + } + + translateZ( distance ) { + + return this.translateOnAxis( _zAxis, distance ); + + } + + localToWorld( vector ) { + + return vector.applyMatrix4( this.matrixWorld ); + + } + + worldToLocal( vector ) { + + return vector.applyMatrix4( _m1$1.copy( this.matrixWorld ).invert() ); + + } + + lookAt( x, y, z ) { + + // This method does not support objects having non-uniformly-scaled parent(s) + + if ( x.isVector3 ) { + + _target.copy( x ); + + } else { + + _target.set( x, y, z ); + + } + + const parent = this.parent; + + this.updateWorldMatrix( true, false ); + + _position$3.setFromMatrixPosition( this.matrixWorld ); + + if ( this.isCamera || this.isLight ) { + + _m1$1.lookAt( _position$3, _target, this.up ); + + } else { + + _m1$1.lookAt( _target, _position$3, this.up ); + + } + + this.quaternion.setFromRotationMatrix( _m1$1 ); + + if ( parent ) { + + _m1$1.extractRotation( parent.matrixWorld ); + _q1.setFromRotationMatrix( _m1$1 ); + this.quaternion.premultiply( _q1.invert() ); + + } + + } + + add( object ) { + + if ( arguments.length > 1 ) { + + for ( let i = 0; i < arguments.length; i ++ ) { + + this.add( arguments[ i ] ); + + } + + return this; + + } + + if ( object === this ) { + + console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object ); + return this; + + } + + if ( object && object.isObject3D ) { + + if ( object.parent !== null ) { + + object.parent.remove( object ); + + } + + object.parent = this; + this.children.push( object ); + + object.dispatchEvent( _addedEvent ); + + } else { + + console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object ); + + } + + return this; + + } + + remove( object ) { + + if ( arguments.length > 1 ) { + + for ( let i = 0; i < arguments.length; i ++ ) { + + this.remove( arguments[ i ] ); + + } + + return this; + + } + + const index = this.children.indexOf( object ); + + if ( index !== - 1 ) { + + object.parent = null; + this.children.splice( index, 1 ); + + object.dispatchEvent( _removedEvent ); + + } + + return this; + + } + + removeFromParent() { + + const parent = this.parent; + + if ( parent !== null ) { + + parent.remove( this ); + + } + + return this; + + } + + clear() { + + for ( let i = 0; i < this.children.length; i ++ ) { + + const object = this.children[ i ]; + + object.parent = null; + + object.dispatchEvent( _removedEvent ); + + } + + this.children.length = 0; + + return this; + + + } + + attach( object ) { + + // adds object as a child of this, while maintaining the object's world transform + + // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s) + + this.updateWorldMatrix( true, false ); + + _m1$1.copy( this.matrixWorld ).invert(); + + if ( object.parent !== null ) { + + object.parent.updateWorldMatrix( true, false ); + + _m1$1.multiply( object.parent.matrixWorld ); + + } + + object.applyMatrix4( _m1$1 ); + + this.add( object ); + + object.updateWorldMatrix( false, true ); + + return this; + + } + + getObjectById( id ) { + + return this.getObjectByProperty( 'id', id ); + + } + + getObjectByName( name ) { + + return this.getObjectByProperty( 'name', name ); + + } + + getObjectByProperty( name, value ) { + + if ( this[ name ] === value ) return this; + + for ( let i = 0, l = this.children.length; i < l; i ++ ) { + + const child = this.children[ i ]; + const object = child.getObjectByProperty( name, value ); + + if ( object !== undefined ) { + + return object; + + } + + } + + return undefined; + + } + + getWorldPosition( target ) { + + this.updateWorldMatrix( true, false ); + + return target.setFromMatrixPosition( this.matrixWorld ); + + } + + getWorldQuaternion( target ) { + + this.updateWorldMatrix( true, false ); + + this.matrixWorld.decompose( _position$3, target, _scale$2 ); + + return target; + + } + + getWorldScale( target ) { + + this.updateWorldMatrix( true, false ); + + this.matrixWorld.decompose( _position$3, _quaternion$2, target ); + + return target; + + } + + getWorldDirection( target ) { + + this.updateWorldMatrix( true, false ); + + const e = this.matrixWorld.elements; + + return target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize(); + + } + + raycast( /* raycaster, intersects */ ) {} + + traverse( callback ) { + + callback( this ); + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].traverse( callback ); + + } + + } + + traverseVisible( callback ) { + + if ( this.visible === false ) return; + + callback( this ); + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].traverseVisible( callback ); + + } + + } + + traverseAncestors( callback ) { + + const parent = this.parent; + + if ( parent !== null ) { + + callback( parent ); + + parent.traverseAncestors( callback ); + + } + + } + + updateMatrix() { + + this.matrix.compose( this.position, this.quaternion, this.scale ); + + this.matrixWorldNeedsUpdate = true; + + } + + updateMatrixWorld( force ) { + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + if ( this.matrixWorldNeedsUpdate || force ) { + + if ( this.parent === null ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + this.matrixWorldNeedsUpdate = false; + + force = true; + + } + + // update children + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateMatrixWorld( force ); + + } + + } + + updateWorldMatrix( updateParents, updateChildren ) { + + const parent = this.parent; + + if ( updateParents === true && parent !== null ) { + + parent.updateWorldMatrix( true, false ); + + } + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + if ( this.parent === null ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + // update children + + if ( updateChildren === true ) { + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateWorldMatrix( false, true ); + + } + + } + + } + + toJSON( meta ) { + + // meta is a string when called from JSON.stringify + const isRootObject = ( meta === undefined || typeof meta === 'string' ); + + const output = {}; + + // meta is a hash used to collect geometries, materials. + // not providing it implies that this is the root object + // being serialized. + if ( isRootObject ) { + + // initialize meta obj + meta = { + geometries: {}, + materials: {}, + textures: {}, + images: {}, + shapes: {}, + skeletons: {}, + animations: {} + }; + + output.metadata = { + version: 4.5, + type: 'Object', + generator: 'Object3D.toJSON' + }; + + } + + // standard Object3D serialization + + const object = {}; + + object.uuid = this.uuid; + object.type = this.type; + + if ( this.name !== '' ) object.name = this.name; + if ( this.castShadow === true ) object.castShadow = true; + if ( this.receiveShadow === true ) object.receiveShadow = true; + if ( this.visible === false ) object.visible = false; + if ( this.frustumCulled === false ) object.frustumCulled = false; + if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder; + if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData; + + object.layers = this.layers.mask; + object.matrix = this.matrix.toArray(); + + if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false; + + // object specific properties + + if ( this.isInstancedMesh ) { + + object.type = 'InstancedMesh'; + object.count = this.count; + object.instanceMatrix = this.instanceMatrix.toJSON(); + if ( this.instanceColor !== null ) object.instanceColor = this.instanceColor.toJSON(); + + } + + // + + function serialize( library, element ) { + + if ( library[ element.uuid ] === undefined ) { + + library[ element.uuid ] = element.toJSON( meta ); + + } + + return element.uuid; + + } + + if ( this.isScene ) { + + if ( this.background ) { + + if ( this.background.isColor ) { + + object.background = this.background.toJSON(); + + } else if ( this.background.isTexture ) { + + object.background = this.background.toJSON( meta ).uuid; + + } + + } + + if ( this.environment && this.environment.isTexture ) { + + object.environment = this.environment.toJSON( meta ).uuid; + + } + + } else if ( this.isMesh || this.isLine || this.isPoints ) { + + object.geometry = serialize( meta.geometries, this.geometry ); + + const parameters = this.geometry.parameters; + + if ( parameters !== undefined && parameters.shapes !== undefined ) { + + const shapes = parameters.shapes; + + if ( Array.isArray( shapes ) ) { + + for ( let i = 0, l = shapes.length; i < l; i ++ ) { + + const shape = shapes[ i ]; + + serialize( meta.shapes, shape ); + + } + + } else { + + serialize( meta.shapes, shapes ); + + } + + } + + } + + if ( this.isSkinnedMesh ) { + + object.bindMode = this.bindMode; + object.bindMatrix = this.bindMatrix.toArray(); + + if ( this.skeleton !== undefined ) { + + serialize( meta.skeletons, this.skeleton ); + + object.skeleton = this.skeleton.uuid; + + } + + } + + if ( this.material !== undefined ) { + + if ( Array.isArray( this.material ) ) { + + const uuids = []; + + for ( let i = 0, l = this.material.length; i < l; i ++ ) { + + uuids.push( serialize( meta.materials, this.material[ i ] ) ); + + } + + object.material = uuids; + + } else { + + object.material = serialize( meta.materials, this.material ); + + } + + } + + // + + if ( this.children.length > 0 ) { + + object.children = []; + + for ( let i = 0; i < this.children.length; i ++ ) { + + object.children.push( this.children[ i ].toJSON( meta ).object ); + + } + + } + + // + + if ( this.animations.length > 0 ) { + + object.animations = []; + + for ( let i = 0; i < this.animations.length; i ++ ) { + + const animation = this.animations[ i ]; + + object.animations.push( serialize( meta.animations, animation ) ); + + } + + } + + if ( isRootObject ) { + + const geometries = extractFromCache( meta.geometries ); + const materials = extractFromCache( meta.materials ); + const textures = extractFromCache( meta.textures ); + const images = extractFromCache( meta.images ); + const shapes = extractFromCache( meta.shapes ); + const skeletons = extractFromCache( meta.skeletons ); + const animations = extractFromCache( meta.animations ); + + if ( geometries.length > 0 ) output.geometries = geometries; + if ( materials.length > 0 ) output.materials = materials; + if ( textures.length > 0 ) output.textures = textures; + if ( images.length > 0 ) output.images = images; + if ( shapes.length > 0 ) output.shapes = shapes; + if ( skeletons.length > 0 ) output.skeletons = skeletons; + if ( animations.length > 0 ) output.animations = animations; + + } + + output.object = object; + + return output; + + // extract data from the cache hash + // remove metadata on each item + // and return as array + function extractFromCache( cache ) { + + const values = []; + for ( const key in cache ) { + + const data = cache[ key ]; + delete data.metadata; + values.push( data ); + + } + + return values; + + } + + } + + clone( recursive ) { + + return new this.constructor().copy( this, recursive ); + + } + + copy( source, recursive = true ) { + + this.name = source.name; + + this.up.copy( source.up ); + + this.position.copy( source.position ); + this.rotation.order = source.rotation.order; + this.quaternion.copy( source.quaternion ); + this.scale.copy( source.scale ); + + this.matrix.copy( source.matrix ); + this.matrixWorld.copy( source.matrixWorld ); + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate; + + this.layers.mask = source.layers.mask; + this.visible = source.visible; + + this.castShadow = source.castShadow; + this.receiveShadow = source.receiveShadow; + + this.frustumCulled = source.frustumCulled; + this.renderOrder = source.renderOrder; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + if ( recursive === true ) { + + for ( let i = 0; i < source.children.length; i ++ ) { + + const child = source.children[ i ]; + this.add( child.clone() ); + + } + + } + + return this; + + } + +} + +Object3D.DefaultUp = new Vector3( 0, 1, 0 ); +Object3D.DefaultMatrixAutoUpdate = true; + +Object3D.prototype.isObject3D = true; + +const _v0$1 = /*@__PURE__*/ new Vector3(); +const _v1$3 = /*@__PURE__*/ new Vector3(); +const _v2$2 = /*@__PURE__*/ new Vector3(); +const _v3$1 = /*@__PURE__*/ new Vector3(); + +const _vab = /*@__PURE__*/ new Vector3(); +const _vac = /*@__PURE__*/ new Vector3(); +const _vbc = /*@__PURE__*/ new Vector3(); +const _vap = /*@__PURE__*/ new Vector3(); +const _vbp = /*@__PURE__*/ new Vector3(); +const _vcp = /*@__PURE__*/ new Vector3(); + +class Triangle { + + constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) { + + this.a = a; + this.b = b; + this.c = c; + + } + + static getNormal( a, b, c, target ) { + + target.subVectors( c, b ); + _v0$1.subVectors( a, b ); + target.cross( _v0$1 ); + + const targetLengthSq = target.lengthSq(); + if ( targetLengthSq > 0 ) { + + return target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) ); + + } + + return target.set( 0, 0, 0 ); + + } + + // static/instance method to calculate barycentric coordinates + // based on: http://www.blackpawn.com/texts/pointinpoly/default.html + static getBarycoord( point, a, b, c, target ) { + + _v0$1.subVectors( c, a ); + _v1$3.subVectors( b, a ); + _v2$2.subVectors( point, a ); + + const dot00 = _v0$1.dot( _v0$1 ); + const dot01 = _v0$1.dot( _v1$3 ); + const dot02 = _v0$1.dot( _v2$2 ); + const dot11 = _v1$3.dot( _v1$3 ); + const dot12 = _v1$3.dot( _v2$2 ); + + const denom = ( dot00 * dot11 - dot01 * dot01 ); + + // collinear or singular triangle + if ( denom === 0 ) { + + // arbitrary location outside of triangle? + // not sure if this is the best idea, maybe should be returning undefined + return target.set( - 2, - 1, - 1 ); + + } + + const invDenom = 1 / denom; + const u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom; + const v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom; + + // barycentric coordinates must always sum to 1 + return target.set( 1 - u - v, v, u ); + + } + + static containsPoint( point, a, b, c ) { + + this.getBarycoord( point, a, b, c, _v3$1 ); + + return ( _v3$1.x >= 0 ) && ( _v3$1.y >= 0 ) && ( ( _v3$1.x + _v3$1.y ) <= 1 ); + + } + + static getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) { + + this.getBarycoord( point, p1, p2, p3, _v3$1 ); + + target.set( 0, 0 ); + target.addScaledVector( uv1, _v3$1.x ); + target.addScaledVector( uv2, _v3$1.y ); + target.addScaledVector( uv3, _v3$1.z ); + + return target; + + } + + static isFrontFacing( a, b, c, direction ) { + + _v0$1.subVectors( c, b ); + _v1$3.subVectors( a, b ); + + // strictly front facing + return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false; + + } + + set( a, b, c ) { + + this.a.copy( a ); + this.b.copy( b ); + this.c.copy( c ); + + return this; + + } + + setFromPointsAndIndices( points, i0, i1, i2 ) { + + this.a.copy( points[ i0 ] ); + this.b.copy( points[ i1 ] ); + this.c.copy( points[ i2 ] ); + + return this; + + } + + setFromAttributeAndIndices( attribute, i0, i1, i2 ) { + + this.a.fromBufferAttribute( attribute, i0 ); + this.b.fromBufferAttribute( attribute, i1 ); + this.c.fromBufferAttribute( attribute, i2 ); + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( triangle ) { + + this.a.copy( triangle.a ); + this.b.copy( triangle.b ); + this.c.copy( triangle.c ); + + return this; + + } + + getArea() { + + _v0$1.subVectors( this.c, this.b ); + _v1$3.subVectors( this.a, this.b ); + + return _v0$1.cross( _v1$3 ).length() * 0.5; + + } + + getMidpoint( target ) { + + return target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 ); + + } + + getNormal( target ) { + + return Triangle.getNormal( this.a, this.b, this.c, target ); + + } + + getPlane( target ) { + + return target.setFromCoplanarPoints( this.a, this.b, this.c ); + + } + + getBarycoord( point, target ) { + + return Triangle.getBarycoord( point, this.a, this.b, this.c, target ); + + } + + getUV( point, uv1, uv2, uv3, target ) { + + return Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target ); + + } + + containsPoint( point ) { + + return Triangle.containsPoint( point, this.a, this.b, this.c ); + + } + + isFrontFacing( direction ) { + + return Triangle.isFrontFacing( this.a, this.b, this.c, direction ); + + } + + intersectsBox( box ) { + + return box.intersectsTriangle( this ); + + } + + closestPointToPoint( p, target ) { + + const a = this.a, b = this.b, c = this.c; + let v, w; + + // algorithm thanks to Real-Time Collision Detection by Christer Ericson, + // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc., + // under the accompanying license; see chapter 5.1.5 for detailed explanation. + // basically, we're distinguishing which of the voronoi regions of the triangle + // the point lies in with the minimum amount of redundant computation. + + _vab.subVectors( b, a ); + _vac.subVectors( c, a ); + _vap.subVectors( p, a ); + const d1 = _vab.dot( _vap ); + const d2 = _vac.dot( _vap ); + if ( d1 <= 0 && d2 <= 0 ) { + + // vertex region of A; barycentric coords (1, 0, 0) + return target.copy( a ); + + } + + _vbp.subVectors( p, b ); + const d3 = _vab.dot( _vbp ); + const d4 = _vac.dot( _vbp ); + if ( d3 >= 0 && d4 <= d3 ) { + + // vertex region of B; barycentric coords (0, 1, 0) + return target.copy( b ); + + } + + const vc = d1 * d4 - d3 * d2; + if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) { + + v = d1 / ( d1 - d3 ); + // edge region of AB; barycentric coords (1-v, v, 0) + return target.copy( a ).addScaledVector( _vab, v ); + + } + + _vcp.subVectors( p, c ); + const d5 = _vab.dot( _vcp ); + const d6 = _vac.dot( _vcp ); + if ( d6 >= 0 && d5 <= d6 ) { + + // vertex region of C; barycentric coords (0, 0, 1) + return target.copy( c ); + + } + + const vb = d5 * d2 - d1 * d6; + if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) { + + w = d2 / ( d2 - d6 ); + // edge region of AC; barycentric coords (1-w, 0, w) + return target.copy( a ).addScaledVector( _vac, w ); + + } + + const va = d3 * d6 - d5 * d4; + if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) { + + _vbc.subVectors( c, b ); + w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) ); + // edge region of BC; barycentric coords (0, 1-w, w) + return target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC + + } + + // face region + const denom = 1 / ( va + vb + vc ); + // u = va * denom + v = vb * denom; + w = vc * denom; + + return target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w ); + + } + + equals( triangle ) { + + return triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c ); + + } + +} + +let materialId = 0; + +class Material extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: materialId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'Material'; + + this.fog = true; + + this.blending = NormalBlending; + this.side = FrontSide; + this.vertexColors = false; + + this.opacity = 1; + this.transparent = false; + + this.blendSrc = SrcAlphaFactor; + this.blendDst = OneMinusSrcAlphaFactor; + this.blendEquation = AddEquation; + this.blendSrcAlpha = null; + this.blendDstAlpha = null; + this.blendEquationAlpha = null; + + this.depthFunc = LessEqualDepth; + this.depthTest = true; + this.depthWrite = true; + + this.stencilWriteMask = 0xff; + this.stencilFunc = AlwaysStencilFunc; + this.stencilRef = 0; + this.stencilFuncMask = 0xff; + this.stencilFail = KeepStencilOp; + this.stencilZFail = KeepStencilOp; + this.stencilZPass = KeepStencilOp; + this.stencilWrite = false; + + this.clippingPlanes = null; + this.clipIntersection = false; + this.clipShadows = false; + + this.shadowSide = null; + + this.colorWrite = true; + this.alphaWrite = true; + + this.precision = null; // override the renderer's default precision for this material + + this.polygonOffset = false; + this.polygonOffsetFactor = 0; + this.polygonOffsetUnits = 0; + + this.dithering = false; + + this.alphaToCoverage = false; + this.premultipliedAlpha = false; + + this.visible = true; + + this.toneMapped = true; + + this.userData = {}; + + this.version = 0; + + this._alphaTest = 0; + + } + + get alphaTest() { + + return this._alphaTest; + + } + + set alphaTest( value ) { + + if ( this._alphaTest > 0 !== value > 0 ) { + + this.version ++; + + } + + this._alphaTest = value; + + } + + onBuild( /* shaderobject, renderer */ ) {} + + onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {} + + onBeforeCompile( /* shaderobject, renderer */ ) {} + + customProgramCacheKey() { + + return this.onBeforeCompile.toString(); + + } + + setValues( values ) { + + if ( values === undefined ) return; + + for ( const key in values ) { + + const newValue = values[ key ]; + + if ( newValue === undefined ) { + + console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' ); + continue; + + } + + // for backward compatability if shading is set in the constructor + if ( key === 'shading' ) { + + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( newValue === FlatShading ) ? true : false; + continue; + + } + + const currentValue = this[ key ]; + + if ( currentValue === undefined ) { + + console.warn( 'THREE.' + this.type + ': \'' + key + '\' is not a property of this material.' ); + continue; + + } + + if ( currentValue && currentValue.isColor ) { + + currentValue.set( newValue ); + + } else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) { + + currentValue.copy( newValue ); + + } else { + + this[ key ] = newValue; + + } + + } + + } + + toJSON( meta ) { + + const isRoot = ( meta === undefined || typeof meta === 'string' ); + + if ( isRoot ) { + + meta = { + textures: {}, + images: {} + }; + + } + + const data = { + metadata: { + version: 4.5, + type: 'Material', + generator: 'Material.toJSON' + } + }; + + // standard Material serialization + data.uuid = this.uuid; + data.type = this.type; + + if ( this.name !== '' ) data.name = this.name; + + if ( this.color && this.color.isColor ) data.color = this.color.getHex(); + + if ( this.roughness !== undefined ) data.roughness = this.roughness; + if ( this.metalness !== undefined ) data.metalness = this.metalness; + + if ( this.sheen !== undefined ) data.sheen = this.sheen; + if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex(); + if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness; + if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex(); + if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity; + + if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex(); + if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity; + if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex(); + if ( this.shininess !== undefined ) data.shininess = this.shininess; + if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat; + if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness; + + if ( this.clearcoatMap && this.clearcoatMap.isTexture ) { + + data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) { + + data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) { + + data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid; + data.clearcoatNormalScale = this.clearcoatNormalScale.toArray(); + + } + + if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid; + if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid; + if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; + + if ( this.lightMap && this.lightMap.isTexture ) { + + data.lightMap = this.lightMap.toJSON( meta ).uuid; + data.lightMapIntensity = this.lightMapIntensity; + + } + + if ( this.aoMap && this.aoMap.isTexture ) { + + data.aoMap = this.aoMap.toJSON( meta ).uuid; + data.aoMapIntensity = this.aoMapIntensity; + + } + + if ( this.bumpMap && this.bumpMap.isTexture ) { + + data.bumpMap = this.bumpMap.toJSON( meta ).uuid; + data.bumpScale = this.bumpScale; + + } + + if ( this.normalMap && this.normalMap.isTexture ) { + + data.normalMap = this.normalMap.toJSON( meta ).uuid; + data.normalMapType = this.normalMapType; + data.normalScale = this.normalScale.toArray(); + + } + + if ( this.displacementMap && this.displacementMap.isTexture ) { + + data.displacementMap = this.displacementMap.toJSON( meta ).uuid; + data.displacementScale = this.displacementScale; + data.displacementBias = this.displacementBias; + + } + + if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid; + if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid; + + if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid; + if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid; + if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid; + if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid; + + if ( this.envMap && this.envMap.isTexture ) { + + data.envMap = this.envMap.toJSON( meta ).uuid; + + if ( this.combine !== undefined ) data.combine = this.combine; + + } + + if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity; + if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity; + if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio; + + if ( this.gradientMap && this.gradientMap.isTexture ) { + + data.gradientMap = this.gradientMap.toJSON( meta ).uuid; + + } + + if ( this.transmission !== undefined ) data.transmission = this.transmission; + if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid; + if ( this.thickness !== undefined ) data.thickness = this.thickness; + if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid; + if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance; + if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex(); + + if ( this.size !== undefined ) data.size = this.size; + if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide; + if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; + + if ( this.blending !== NormalBlending ) data.blending = this.blending; + if ( this.side !== FrontSide ) data.side = this.side; + if ( this.vertexColors ) data.vertexColors = true; + + if ( this.opacity < 1 ) data.opacity = this.opacity; + if ( this.transparent === true ) data.transparent = this.transparent; + + data.depthFunc = this.depthFunc; + data.depthTest = this.depthTest; + data.depthWrite = this.depthWrite; + data.colorWrite = this.colorWrite; + data.alphaWrite = this.alphaWrite; + + data.stencilWrite = this.stencilWrite; + data.stencilWriteMask = this.stencilWriteMask; + data.stencilFunc = this.stencilFunc; + data.stencilRef = this.stencilRef; + data.stencilFuncMask = this.stencilFuncMask; + data.stencilFail = this.stencilFail; + data.stencilZFail = this.stencilZFail; + data.stencilZPass = this.stencilZPass; + + // rotation (SpriteMaterial) + if ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation; + + if ( this.polygonOffset === true ) data.polygonOffset = true; + if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor; + if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits; + + if ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth; + if ( this.dashSize !== undefined ) data.dashSize = this.dashSize; + if ( this.gapSize !== undefined ) data.gapSize = this.gapSize; + if ( this.scale !== undefined ) data.scale = this.scale; + + if ( this.dithering === true ) data.dithering = true; + + if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest; + if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage; + if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha; + + if ( this.wireframe === true ) data.wireframe = this.wireframe; + if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth; + if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap; + if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin; + + if ( this.flatShading === true ) data.flatShading = this.flatShading; + + if ( this.visible === false ) data.visible = false; + + if ( this.toneMapped === false ) data.toneMapped = false; + + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + // TODO: Copied from Object3D.toJSON + + function extractFromCache( cache ) { + + const values = []; + + for ( const key in cache ) { + + const data = cache[ key ]; + delete data.metadata; + values.push( data ); + + } + + return values; + + } + + if ( isRoot ) { + + const textures = extractFromCache( meta.textures ); + const images = extractFromCache( meta.images ); + + if ( textures.length > 0 ) data.textures = textures; + if ( images.length > 0 ) data.images = images; + + } + + return data; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.name = source.name; + + this.fog = source.fog; + + this.blending = source.blending; + this.side = source.side; + this.vertexColors = source.vertexColors; + + this.opacity = source.opacity; + this.transparent = source.transparent; + + this.blendSrc = source.blendSrc; + this.blendDst = source.blendDst; + this.blendEquation = source.blendEquation; + this.blendSrcAlpha = source.blendSrcAlpha; + this.blendDstAlpha = source.blendDstAlpha; + this.blendEquationAlpha = source.blendEquationAlpha; + + this.depthFunc = source.depthFunc; + this.depthTest = source.depthTest; + this.depthWrite = source.depthWrite; + + this.stencilWriteMask = source.stencilWriteMask; + this.stencilFunc = source.stencilFunc; + this.stencilRef = source.stencilRef; + this.stencilFuncMask = source.stencilFuncMask; + this.stencilFail = source.stencilFail; + this.stencilZFail = source.stencilZFail; + this.stencilZPass = source.stencilZPass; + this.stencilWrite = source.stencilWrite; + + const srcPlanes = source.clippingPlanes; + let dstPlanes = null; + + if ( srcPlanes !== null ) { + + const n = srcPlanes.length; + dstPlanes = new Array( n ); + + for ( let i = 0; i !== n; ++ i ) { + + dstPlanes[ i ] = srcPlanes[ i ].clone(); + + } + + } + + this.clippingPlanes = dstPlanes; + this.clipIntersection = source.clipIntersection; + this.clipShadows = source.clipShadows; + + this.shadowSide = source.shadowSide; + + this.colorWrite = source.colorWrite; + this.alphaWrite = source.alphaWrite; + + this.precision = source.precision; + + this.polygonOffset = source.polygonOffset; + this.polygonOffsetFactor = source.polygonOffsetFactor; + this.polygonOffsetUnits = source.polygonOffsetUnits; + + this.dithering = source.dithering; + + this.alphaTest = source.alphaTest; + this.alphaToCoverage = source.alphaToCoverage; + this.premultipliedAlpha = source.premultipliedAlpha; + + this.visible = source.visible; + + this.toneMapped = source.toneMapped; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + +} + +Material.prototype.isMaterial = true; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + * + * depthTest: , + * depthWrite: , + * + * wireframe: , + * wireframeLinewidth: , + * } + */ + +class MeshBasicMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshBasicMaterial'; + + this.color = new Color$1( 0xffffff ); // emissive + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + + } + +} + +MeshBasicMaterial.prototype.isMeshBasicMaterial = true; + +const _vector$9 = /*@__PURE__*/ new Vector3(); +const _vector2$1 = /*@__PURE__*/ new Vector2(); + +class BufferAttribute { + + constructor( array, itemSize, normalized ) { + + if ( Array.isArray( array ) ) { + + throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' ); + + } + + this.name = ''; + + this.array = array; + this.itemSize = itemSize; + this.count = array !== undefined ? array.length / itemSize : 0; + this.normalized = normalized === true; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: - 1 }; + + this.version = 0; + + } + + onUploadCallback() {} + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + + setUsage( value ) { + + this.usage = value; + + return this; + + } + + copy( source ) { + + this.name = source.name; + this.array = new source.array.constructor( source.array ); + this.itemSize = source.itemSize; + this.count = source.count; + this.normalized = source.normalized; + + this.usage = source.usage; + + return this; + + } + + copyAt( index1, attribute, index2 ) { + + index1 *= this.itemSize; + index2 *= attribute.itemSize; + + for ( let i = 0, l = this.itemSize; i < l; i ++ ) { + + this.array[ index1 + i ] = attribute.array[ index2 + i ]; + + } + + return this; + + } + + copyArray( array ) { + + this.array.set( array ); + + return this; + + } + + copyColorsArray( colors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = colors.length; i < l; i ++ ) { + + let color = colors[ i ]; + + if ( color === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i ); + color = new Color$1(); + + } + + array[ offset ++ ] = color.r; + array[ offset ++ ] = color.g; + array[ offset ++ ] = color.b; + + } + + return this; + + } + + copyVector2sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i ); + vector = new Vector2(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + + } + + return this; + + } + + copyVector3sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i ); + vector = new Vector3(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + array[ offset ++ ] = vector.z; + + } + + return this; + + } + + copyVector4sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i ); + vector = new Vector4(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + array[ offset ++ ] = vector.z; + array[ offset ++ ] = vector.w; + + } + + return this; + + } + + applyMatrix3( m ) { + + if ( this.itemSize === 2 ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector2$1.fromBufferAttribute( this, i ); + _vector2$1.applyMatrix3( m ); + + this.setXY( i, _vector2$1.x, _vector2$1.y ); + + } + + } else if ( this.itemSize === 3 ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.fromBufferAttribute( this, i ); + _vector$9.applyMatrix3( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + } + + return this; + + } + + applyMatrix4( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.applyMatrix4( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + applyNormalMatrix( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.applyNormalMatrix( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + transformDirection( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.transformDirection( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + set( value, offset = 0 ) { + + this.array.set( value, offset ); + + return this; + + } + + getX( index ) { + + return this.array[ index * this.itemSize ]; + + } + + setX( index, x ) { + + this.array[ index * this.itemSize ] = x; + + return this; + + } + + getY( index ) { + + return this.array[ index * this.itemSize + 1 ]; + + } + + setY( index, y ) { + + this.array[ index * this.itemSize + 1 ] = y; + + return this; + + } + + getZ( index ) { + + return this.array[ index * this.itemSize + 2 ]; + + } + + setZ( index, z ) { + + this.array[ index * this.itemSize + 2 ] = z; + + return this; + + } + + getW( index ) { + + return this.array[ index * this.itemSize + 3 ]; + + } + + setW( index, w ) { + + this.array[ index * this.itemSize + 3 ] = w; + + return this; + + } + + setXY( index, x, y ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + + return this; + + } + + setXYZ( index, x, y, z ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + this.array[ index + 2 ] = z; + + return this; + + } + + setXYZW( index, x, y, z, w ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + this.array[ index + 2 ] = z; + this.array[ index + 3 ] = w; + + return this; + + } + + onUpload( callback ) { + + this.onUploadCallback = callback; + + return this; + + } + + clone() { + + return new this.constructor( this.array, this.itemSize ).copy( this ); + + } + + toJSON() { + + const data = { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: Array.prototype.slice.call( this.array ), + normalized: this.normalized + }; + + if ( this.name !== '' ) data.name = this.name; + if ( this.usage !== StaticDrawUsage ) data.usage = this.usage; + if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange; + + return data; + + } + +} + +BufferAttribute.prototype.isBufferAttribute = true; + +class Uint16BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint16Array( array ), itemSize, normalized ); + + } + +} + +class Uint32BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint32Array( array ), itemSize, normalized ); + + } + +} + +class Float32BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Float32Array( array ), itemSize, normalized ); + + } + +} + +let _id$1 = 0; + +const _m1 = /*@__PURE__*/ new Matrix4(); +const _obj = /*@__PURE__*/ new Object3D(); +const _offset = /*@__PURE__*/ new Vector3(); +const _box$1 = /*@__PURE__*/ new Box3(); +const _boxMorphTargets = /*@__PURE__*/ new Box3(); +const _vector$8 = /*@__PURE__*/ new Vector3(); + +class BufferGeometry extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: _id$1 ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'BufferGeometry'; + + this.index = null; + this.attributes = {}; + + this.morphAttributes = {}; + this.morphTargetsRelative = false; + + this.groups = []; + + this.boundingBox = null; + this.boundingSphere = null; + + this.drawRange = { start: 0, count: Infinity }; + + this.userData = {}; + + } + + getIndex() { + + return this.index; + + } + + setIndex( index ) { + + if ( Array.isArray( index ) ) { + + this.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 ); + + } else { + + this.index = index; + + } + + return this; + + } + + getAttribute( name ) { + + return this.attributes[ name ]; + + } + + setAttribute( name, attribute ) { + + this.attributes[ name ] = attribute; + + return this; + + } + + deleteAttribute( name ) { + + delete this.attributes[ name ]; + + return this; + + } + + hasAttribute( name ) { + + return this.attributes[ name ] !== undefined; + + } + + addGroup( start, count, materialIndex = 0 ) { + + this.groups.push( { + + start: start, + count: count, + materialIndex: materialIndex + + } ); + + } + + clearGroups() { + + this.groups = []; + + } + + setDrawRange( start, count ) { + + this.drawRange.start = start; + this.drawRange.count = count; + + } + + applyMatrix4( matrix ) { + + const position = this.attributes.position; + + if ( position !== undefined ) { + + position.applyMatrix4( matrix ); + + position.needsUpdate = true; + + } + + const normal = this.attributes.normal; + + if ( normal !== undefined ) { + + const normalMatrix = new Matrix3().getNormalMatrix( matrix ); + + normal.applyNormalMatrix( normalMatrix ); + + normal.needsUpdate = true; + + } + + const tangent = this.attributes.tangent; + + if ( tangent !== undefined ) { + + tangent.transformDirection( matrix ); + + tangent.needsUpdate = true; + + } + + if ( this.boundingBox !== null ) { + + this.computeBoundingBox(); + + } + + if ( this.boundingSphere !== null ) { + + this.computeBoundingSphere(); + + } + + return this; + + } + + applyQuaternion( q ) { + + _m1.makeRotationFromQuaternion( q ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateX( angle ) { + + // rotate geometry around world x-axis + + _m1.makeRotationX( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateY( angle ) { + + // rotate geometry around world y-axis + + _m1.makeRotationY( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateZ( angle ) { + + // rotate geometry around world z-axis + + _m1.makeRotationZ( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + translate( x, y, z ) { + + // translate geometry + + _m1.makeTranslation( x, y, z ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + scale( x, y, z ) { + + // scale geometry + + _m1.makeScale( x, y, z ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + lookAt( vector ) { + + _obj.lookAt( vector ); + + _obj.updateMatrix(); + + this.applyMatrix4( _obj.matrix ); + + return this; + + } + + center() { + + this.computeBoundingBox(); + + this.boundingBox.getCenter( _offset ).negate(); + + this.translate( _offset.x, _offset.y, _offset.z ); + + return this; + + } + + setFromPoints( points ) { + + const position = []; + + for ( let i = 0, l = points.length; i < l; i ++ ) { + + const point = points[ i ]; + position.push( point.x, point.y, point.z || 0 ); + + } + + this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) ); + + return this; + + } + + computeBoundingBox() { + + if ( this.boundingBox === null ) { + + this.boundingBox = new Box3(); + + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if ( position && position.isGLBufferAttribute ) { + + console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this ); + + this.boundingBox.set( + new Vector3( - Infinity, - Infinity, - Infinity ), + new Vector3( + Infinity, + Infinity, + Infinity ) + ); + + return; + + } + + if ( position !== undefined ) { + + this.boundingBox.setFromBufferAttribute( position ); + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + _box$1.setFromBufferAttribute( morphAttribute ); + + if ( this.morphTargetsRelative ) { + + _vector$8.addVectors( this.boundingBox.min, _box$1.min ); + this.boundingBox.expandByPoint( _vector$8 ); + + _vector$8.addVectors( this.boundingBox.max, _box$1.max ); + this.boundingBox.expandByPoint( _vector$8 ); + + } else { + + this.boundingBox.expandByPoint( _box$1.min ); + this.boundingBox.expandByPoint( _box$1.max ); + + } + + } + + } + + } else { + + this.boundingBox.makeEmpty(); + + } + + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { + + console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); + + } + + } + + computeBoundingSphere() { + + if ( this.boundingSphere === null ) { + + this.boundingSphere = new Sphere(); + + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if ( position && position.isGLBufferAttribute ) { + + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this ); + + this.boundingSphere.set( new Vector3(), Infinity ); + + return; + + } + + if ( position ) { + + // first, find the center of the bounding sphere + + const center = this.boundingSphere.center; + + _box$1.setFromBufferAttribute( position ); + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + _boxMorphTargets.setFromBufferAttribute( morphAttribute ); + + if ( this.morphTargetsRelative ) { + + _vector$8.addVectors( _box$1.min, _boxMorphTargets.min ); + _box$1.expandByPoint( _vector$8 ); + + _vector$8.addVectors( _box$1.max, _boxMorphTargets.max ); + _box$1.expandByPoint( _vector$8 ); + + } else { + + _box$1.expandByPoint( _boxMorphTargets.min ); + _box$1.expandByPoint( _boxMorphTargets.max ); + + } + + } + + } + + _box$1.getCenter( center ); + + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + + let maxRadiusSq = 0; + + for ( let i = 0, il = position.count; i < il; i ++ ) { + + _vector$8.fromBufferAttribute( position, i ); + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) ); + + } + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + const morphTargetsRelative = this.morphTargetsRelative; + + for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) { + + _vector$8.fromBufferAttribute( morphAttribute, j ); + + if ( morphTargetsRelative ) { + + _offset.fromBufferAttribute( position, j ); + _vector$8.add( _offset ); + + } + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) ); + + } + + } + + } + + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + + if ( isNaN( this.boundingSphere.radius ) ) { + + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); + + } + + } + + } + + computeTangents() { + + const index = this.index; + const attributes = this.attributes; + + // based on http://www.terathon.com/code/tangent.html + // (per vertex tangents) + + if ( index === null || + attributes.position === undefined || + attributes.normal === undefined || + attributes.uv === undefined ) { + + console.error( 'THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' ); + return; + + } + + const indices = index.array; + const positions = attributes.position.array; + const normals = attributes.normal.array; + const uvs = attributes.uv.array; + + const nVertices = positions.length / 3; + + if ( attributes.tangent === undefined ) { + + this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) ); + + } + + const tangents = attributes.tangent.array; + + const tan1 = [], tan2 = []; + + for ( let i = 0; i < nVertices; i ++ ) { + + tan1[ i ] = new Vector3(); + tan2[ i ] = new Vector3(); + + } + + const vA = new Vector3(), + vB = new Vector3(), + vC = new Vector3(), + + uvA = new Vector2(), + uvB = new Vector2(), + uvC = new Vector2(), + + sdir = new Vector3(), + tdir = new Vector3(); + + function handleTriangle( a, b, c ) { + + vA.fromArray( positions, a * 3 ); + vB.fromArray( positions, b * 3 ); + vC.fromArray( positions, c * 3 ); + + uvA.fromArray( uvs, a * 2 ); + uvB.fromArray( uvs, b * 2 ); + uvC.fromArray( uvs, c * 2 ); + + vB.sub( vA ); + vC.sub( vA ); + + uvB.sub( uvA ); + uvC.sub( uvA ); + + const r = 1.0 / ( uvB.x * uvC.y - uvC.x * uvB.y ); + + // silently ignore degenerate uv triangles having coincident or colinear vertices + + if ( ! isFinite( r ) ) return; + + sdir.copy( vB ).multiplyScalar( uvC.y ).addScaledVector( vC, - uvB.y ).multiplyScalar( r ); + tdir.copy( vC ).multiplyScalar( uvB.x ).addScaledVector( vB, - uvC.x ).multiplyScalar( r ); + + tan1[ a ].add( sdir ); + tan1[ b ].add( sdir ); + tan1[ c ].add( sdir ); + + tan2[ a ].add( tdir ); + tan2[ b ].add( tdir ); + tan2[ c ].add( tdir ); + + } + + let groups = this.groups; + + if ( groups.length === 0 ) { + + groups = [ { + start: 0, + count: indices.length + } ]; + + } + + for ( let i = 0, il = groups.length; i < il; ++ i ) { + + const group = groups[ i ]; + + const start = group.start; + const count = group.count; + + for ( let j = start, jl = start + count; j < jl; j += 3 ) { + + handleTriangle( + indices[ j + 0 ], + indices[ j + 1 ], + indices[ j + 2 ] + ); + + } + + } + + const tmp = new Vector3(), tmp2 = new Vector3(); + const n = new Vector3(), n2 = new Vector3(); + + function handleVertex( v ) { + + n.fromArray( normals, v * 3 ); + n2.copy( n ); + + const t = tan1[ v ]; + + // Gram-Schmidt orthogonalize + + tmp.copy( t ); + tmp.sub( n.multiplyScalar( n.dot( t ) ) ).normalize(); + + // Calculate handedness + + tmp2.crossVectors( n2, t ); + const test = tmp2.dot( tan2[ v ] ); + const w = ( test < 0.0 ) ? - 1.0 : 1.0; + + tangents[ v * 4 ] = tmp.x; + tangents[ v * 4 + 1 ] = tmp.y; + tangents[ v * 4 + 2 ] = tmp.z; + tangents[ v * 4 + 3 ] = w; + + } + + for ( let i = 0, il = groups.length; i < il; ++ i ) { + + const group = groups[ i ]; + + const start = group.start; + const count = group.count; + + for ( let j = start, jl = start + count; j < jl; j += 3 ) { + + handleVertex( indices[ j + 0 ] ); + handleVertex( indices[ j + 1 ] ); + handleVertex( indices[ j + 2 ] ); + + } + + } + + } + + computeVertexNormals() { + + const index = this.index; + const positionAttribute = this.getAttribute( 'position' ); + + if ( positionAttribute !== undefined ) { + + let normalAttribute = this.getAttribute( 'normal' ); + + if ( normalAttribute === undefined ) { + + normalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 ); + this.setAttribute( 'normal', normalAttribute ); + + } else { + + // reset existing normals to zero + + for ( let i = 0, il = normalAttribute.count; i < il; i ++ ) { + + normalAttribute.setXYZ( i, 0, 0, 0 ); + + } + + } + + const pA = new Vector3(), pB = new Vector3(), pC = new Vector3(); + const nA = new Vector3(), nB = new Vector3(), nC = new Vector3(); + const cb = new Vector3(), ab = new Vector3(); + + // indexed elements + + if ( index ) { + + for ( let i = 0, il = index.count; i < il; i += 3 ) { + + const vA = index.getX( i + 0 ); + const vB = index.getX( i + 1 ); + const vC = index.getX( i + 2 ); + + pA.fromBufferAttribute( positionAttribute, vA ); + pB.fromBufferAttribute( positionAttribute, vB ); + pC.fromBufferAttribute( positionAttribute, vC ); + + cb.subVectors( pC, pB ); + ab.subVectors( pA, pB ); + cb.cross( ab ); + + nA.fromBufferAttribute( normalAttribute, vA ); + nB.fromBufferAttribute( normalAttribute, vB ); + nC.fromBufferAttribute( normalAttribute, vC ); + + nA.add( cb ); + nB.add( cb ); + nC.add( cb ); + + normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z ); + normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z ); + normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z ); + + } + + } else { + + // non-indexed elements (unconnected triangle soup) + + for ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) { + + pA.fromBufferAttribute( positionAttribute, i + 0 ); + pB.fromBufferAttribute( positionAttribute, i + 1 ); + pC.fromBufferAttribute( positionAttribute, i + 2 ); + + cb.subVectors( pC, pB ); + ab.subVectors( pA, pB ); + cb.cross( ab ); + + normalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z ); + normalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z ); + normalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z ); + + } + + } + + this.normalizeNormals(); + + normalAttribute.needsUpdate = true; + + } + + } + + merge( geometry, offset ) { + + if ( ! ( geometry && geometry.isBufferGeometry ) ) { + + console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry ); + return; + + } + + if ( offset === undefined ) { + + offset = 0; + + console.warn( + 'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. ' + + 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.' + ); + + } + + const attributes = this.attributes; + + for ( const key in attributes ) { + + if ( geometry.attributes[ key ] === undefined ) continue; + + const attribute1 = attributes[ key ]; + const attributeArray1 = attribute1.array; + + const attribute2 = geometry.attributes[ key ]; + const attributeArray2 = attribute2.array; + + const attributeOffset = attribute2.itemSize * offset; + const length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset ); + + for ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) { + + attributeArray1[ j ] = attributeArray2[ i ]; + + } + + } + + return this; + + } + + normalizeNormals() { + + const normals = this.attributes.normal; + + for ( let i = 0, il = normals.count; i < il; i ++ ) { + + _vector$8.fromBufferAttribute( normals, i ); + + _vector$8.normalize(); + + normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z ); + + } + + } + + toNonIndexed() { + + function convertBufferAttribute( attribute, indices ) { + + const array = attribute.array; + const itemSize = attribute.itemSize; + const normalized = attribute.normalized; + + const array2 = new array.constructor( indices.length * itemSize ); + + let index = 0, index2 = 0; + + for ( let i = 0, l = indices.length; i < l; i ++ ) { + + if ( attribute.isInterleavedBufferAttribute ) { + + index = indices[ i ] * attribute.data.stride + attribute.offset; + + } else { + + index = indices[ i ] * itemSize; + + } + + for ( let j = 0; j < itemSize; j ++ ) { + + array2[ index2 ++ ] = array[ index ++ ]; + + } + + } + + return new BufferAttribute( array2, itemSize, normalized ); + + } + + // + + if ( this.index === null ) { + + console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' ); + return this; + + } + + const geometry2 = new BufferGeometry(); + + const indices = this.index.array; + const attributes = this.attributes; + + // attributes + + for ( const name in attributes ) { + + const attribute = attributes[ name ]; + + const newAttribute = convertBufferAttribute( attribute, indices ); + + geometry2.setAttribute( name, newAttribute ); + + } + + // morph attributes + + const morphAttributes = this.morphAttributes; + + for ( const name in morphAttributes ) { + + const morphArray = []; + const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes + + for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) { + + const attribute = morphAttribute[ i ]; + + const newAttribute = convertBufferAttribute( attribute, indices ); + + morphArray.push( newAttribute ); + + } + + geometry2.morphAttributes[ name ] = morphArray; + + } + + geometry2.morphTargetsRelative = this.morphTargetsRelative; + + // groups + + const groups = this.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + geometry2.addGroup( group.start, group.count, group.materialIndex ); + + } + + return geometry2; + + } + + toJSON() { + + const data = { + metadata: { + version: 4.5, + type: 'BufferGeometry', + generator: 'BufferGeometry.toJSON' + } + }; + + // standard BufferGeometry serialization + + data.uuid = this.uuid; + data.type = this.type; + if ( this.name !== '' ) data.name = this.name; + if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData; + + if ( this.parameters !== undefined ) { + + const parameters = this.parameters; + + for ( const key in parameters ) { + + if ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ]; + + } + + return data; + + } + + // for simplicity the code assumes attributes are not shared across geometries, see #15811 + + data.data = { attributes: {} }; + + const index = this.index; + + if ( index !== null ) { + + data.data.index = { + type: index.array.constructor.name, + array: Array.prototype.slice.call( index.array ) + }; + + } + + const attributes = this.attributes; + + for ( const key in attributes ) { + + const attribute = attributes[ key ]; + + data.data.attributes[ key ] = attribute.toJSON( data.data ); + + } + + const morphAttributes = {}; + let hasMorphAttributes = false; + + for ( const key in this.morphAttributes ) { + + const attributeArray = this.morphAttributes[ key ]; + + const array = []; + + for ( let i = 0, il = attributeArray.length; i < il; i ++ ) { + + const attribute = attributeArray[ i ]; + + array.push( attribute.toJSON( data.data ) ); + + } + + if ( array.length > 0 ) { + + morphAttributes[ key ] = array; + + hasMorphAttributes = true; + + } + + } + + if ( hasMorphAttributes ) { + + data.data.morphAttributes = morphAttributes; + data.data.morphTargetsRelative = this.morphTargetsRelative; + + } + + const groups = this.groups; + + if ( groups.length > 0 ) { + + data.data.groups = JSON.parse( JSON.stringify( groups ) ); + + } + + const boundingSphere = this.boundingSphere; + + if ( boundingSphere !== null ) { + + data.data.boundingSphere = { + center: boundingSphere.center.toArray(), + radius: boundingSphere.radius + }; + + } + + return data; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + // reset + + this.index = null; + this.attributes = {}; + this.morphAttributes = {}; + this.groups = []; + this.boundingBox = null; + this.boundingSphere = null; + + // used for storing cloned, shared data + + const data = {}; + + // name + + this.name = source.name; + + // index + + const index = source.index; + + if ( index !== null ) { + + this.setIndex( index.clone( data ) ); + + } + + // attributes + + const attributes = source.attributes; + + for ( const name in attributes ) { + + const attribute = attributes[ name ]; + this.setAttribute( name, attribute.clone( data ) ); + + } + + // morph attributes + + const morphAttributes = source.morphAttributes; + + for ( const name in morphAttributes ) { + + const array = []; + const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes + + for ( let i = 0, l = morphAttribute.length; i < l; i ++ ) { + + array.push( morphAttribute[ i ].clone( data ) ); + + } + + this.morphAttributes[ name ] = array; + + } + + this.morphTargetsRelative = source.morphTargetsRelative; + + // groups + + const groups = source.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + this.addGroup( group.start, group.count, group.materialIndex ); + + } + + // bounding box + + const boundingBox = source.boundingBox; + + if ( boundingBox !== null ) { + + this.boundingBox = boundingBox.clone(); + + } + + // bounding sphere + + const boundingSphere = source.boundingSphere; + + if ( boundingSphere !== null ) { + + this.boundingSphere = boundingSphere.clone(); + + } + + // draw range + + this.drawRange.start = source.drawRange.start; + this.drawRange.count = source.drawRange.count; + + // user data + + this.userData = source.userData; + + // geometry generator parameters + + if ( source.parameters !== undefined ) this.parameters = Object.assign( {}, source.parameters ); + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + +} + +BufferGeometry.prototype.isBufferGeometry = true; + +const _inverseMatrix$2 = /*@__PURE__*/ new Matrix4(); +const _ray$2 = /*@__PURE__*/ new Ray(); +const _sphere$3 = /*@__PURE__*/ new Sphere(); + +const _vA$1 = /*@__PURE__*/ new Vector3(); +const _vB$1 = /*@__PURE__*/ new Vector3(); +const _vC$1 = /*@__PURE__*/ new Vector3(); + +const _tempA = /*@__PURE__*/ new Vector3(); +const _tempB = /*@__PURE__*/ new Vector3(); +const _tempC = /*@__PURE__*/ new Vector3(); + +const _morphA = /*@__PURE__*/ new Vector3(); +const _morphB = /*@__PURE__*/ new Vector3(); +const _morphC = /*@__PURE__*/ new Vector3(); + +const _uvA$1 = /*@__PURE__*/ new Vector2(); +const _uvB$1 = /*@__PURE__*/ new Vector2(); +const _uvC$1 = /*@__PURE__*/ new Vector2(); + +const _intersectionPoint = /*@__PURE__*/ new Vector3(); +const _intersectionPointWorld = /*@__PURE__*/ new Vector3(); + +class Mesh extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) { + + super(); + + this.type = 'Mesh'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + if ( source.morphTargetInfluences !== undefined ) { + + this.morphTargetInfluences = source.morphTargetInfluences.slice(); + + } + + if ( source.morphTargetDictionary !== undefined ) { + + this.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary ); + + } + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const material = this.material; + const matrixWorld = this.matrixWorld; + + if ( material === undefined ) return; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$3.copy( geometry.boundingSphere ); + _sphere$3.applyMatrix4( matrixWorld ); + + if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return; + + // + + _inverseMatrix$2.copy( matrixWorld ).invert(); + _ray$2.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$2 ); + + // Check boundingBox before continuing + + if ( geometry.boundingBox !== null ) { + + if ( _ray$2.intersectsBox( geometry.boundingBox ) === false ) return; + + } + + let intersection; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const position = geometry.attributes.position; + const morphPosition = geometry.morphAttributes.position; + const morphTargetsRelative = geometry.morphTargetsRelative; + const uv = geometry.attributes.uv; + const uv2 = geometry.attributes.uv2; + const groups = geometry.groups; + const drawRange = geometry.drawRange; + + if ( index !== null ) { + + // indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( let i = 0, il = groups.length; i < il; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + const start = Math.max( group.start, drawRange.start ); + const end = Math.min( index.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) ); + + for ( let j = start, jl = end; j < jl; j += 3 ) { + + const a = index.getX( j ); + const b = index.getX( j + 1 ); + const c = index.getX( j + 2 ); + + intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push( intersection ); + + } + + } + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i += 3 ) { + + const a = index.getX( i ); + const b = index.getX( i + 1 ); + const c = index.getX( i + 2 ); + + intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics + intersects.push( intersection ); + + } + + } + + } + + } else if ( position !== undefined ) { + + // non-indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( let i = 0, il = groups.length; i < il; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + const start = Math.max( group.start, drawRange.start ); + const end = Math.min( position.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) ); + + for ( let j = start, jl = end; j < jl; j += 3 ) { + + const a = j; + const b = j + 1; + const c = j + 2; + + intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push( intersection ); + + } + + } + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( position.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i += 3 ) { + + const a = i; + const b = i + 1; + const c = i + 2; + + intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics + intersects.push( intersection ); + + } + + } + + } + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + +} + +Mesh.prototype.isMesh = true; + +function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) { + + let intersect; + + if ( material.side === BackSide ) { + + intersect = ray.intersectTriangle( pC, pB, pA, true, point ); + + } else { + + intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point ); + + } + + if ( intersect === null ) return null; + + _intersectionPointWorld.copy( point ); + _intersectionPointWorld.applyMatrix4( object.matrixWorld ); + + const distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld ); + + if ( distance < raycaster.near || distance > raycaster.far ) return null; + + return { + distance: distance, + point: _intersectionPointWorld.clone(), + object: object + }; + +} + +function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) { + + _vA$1.fromBufferAttribute( position, a ); + _vB$1.fromBufferAttribute( position, b ); + _vC$1.fromBufferAttribute( position, c ); + + const morphInfluences = object.morphTargetInfluences; + + if ( morphPosition && morphInfluences ) { + + _morphA.set( 0, 0, 0 ); + _morphB.set( 0, 0, 0 ); + _morphC.set( 0, 0, 0 ); + + for ( let i = 0, il = morphPosition.length; i < il; i ++ ) { + + const influence = morphInfluences[ i ]; + const morphAttribute = morphPosition[ i ]; + + if ( influence === 0 ) continue; + + _tempA.fromBufferAttribute( morphAttribute, a ); + _tempB.fromBufferAttribute( morphAttribute, b ); + _tempC.fromBufferAttribute( morphAttribute, c ); + + if ( morphTargetsRelative ) { + + _morphA.addScaledVector( _tempA, influence ); + _morphB.addScaledVector( _tempB, influence ); + _morphC.addScaledVector( _tempC, influence ); + + } else { + + _morphA.addScaledVector( _tempA.sub( _vA$1 ), influence ); + _morphB.addScaledVector( _tempB.sub( _vB$1 ), influence ); + _morphC.addScaledVector( _tempC.sub( _vC$1 ), influence ); + + } + + } + + _vA$1.add( _morphA ); + _vB$1.add( _morphB ); + _vC$1.add( _morphC ); + + } + + if ( object.isSkinnedMesh ) { + + object.boneTransform( a, _vA$1 ); + object.boneTransform( b, _vB$1 ); + object.boneTransform( c, _vC$1 ); + + } + + const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint ); + + if ( intersection ) { + + if ( uv ) { + + _uvA$1.fromBufferAttribute( uv, a ); + _uvB$1.fromBufferAttribute( uv, b ); + _uvC$1.fromBufferAttribute( uv, c ); + + intersection.uv = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + + } + + if ( uv2 ) { + + _uvA$1.fromBufferAttribute( uv2, a ); + _uvB$1.fromBufferAttribute( uv2, b ); + _uvC$1.fromBufferAttribute( uv2, c ); + + intersection.uv2 = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + + } + + const face = { + a: a, + b: b, + c: c, + normal: new Vector3(), + materialIndex: 0 + }; + + Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal ); + + intersection.face = face; + + } + + return intersection; + +} + +class BoxGeometry extends BufferGeometry { + + constructor( width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1 ) { + + super(); + + this.type = 'BoxGeometry'; + + this.parameters = { + width: width, + height: height, + depth: depth, + widthSegments: widthSegments, + heightSegments: heightSegments, + depthSegments: depthSegments + }; + + const scope = this; + + // segments + + widthSegments = Math.floor( widthSegments ); + heightSegments = Math.floor( heightSegments ); + depthSegments = Math.floor( depthSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let numberOfVertices = 0; + let groupStart = 0; + + // build each side of the box geometry + + buildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px + buildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx + buildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py + buildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny + buildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz + buildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + function buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) { + + const segmentWidth = width / gridX; + const segmentHeight = height / gridY; + + const widthHalf = width / 2; + const heightHalf = height / 2; + const depthHalf = depth / 2; + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + let vertexCounter = 0; + let groupCount = 0; + + const vector = new Vector3(); + + // generate vertices, normals and uvs + + for ( let iy = 0; iy < gridY1; iy ++ ) { + + const y = iy * segmentHeight - heightHalf; + + for ( let ix = 0; ix < gridX1; ix ++ ) { + + const x = ix * segmentWidth - widthHalf; + + // set values to correct vector component + + vector[ u ] = x * udir; + vector[ v ] = y * vdir; + vector[ w ] = depthHalf; + + // now apply vector to vertex buffer + + vertices.push( vector.x, vector.y, vector.z ); + + // set values to correct vector component + + vector[ u ] = 0; + vector[ v ] = 0; + vector[ w ] = depth > 0 ? 1 : - 1; + + // now apply vector to normal buffer + + normals.push( vector.x, vector.y, vector.z ); + + // uvs + + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); + + // counters + + vertexCounter += 1; + + } + + } + + // indices + + // 1. you need three indices to draw a single face + // 2. a single segment consists of two faces + // 3. so we need to generate six (2*3) indices per segment + + for ( let iy = 0; iy < gridY; iy ++ ) { + + for ( let ix = 0; ix < gridX; ix ++ ) { + + const a = numberOfVertices + ix + gridX1 * iy; + const b = numberOfVertices + ix + gridX1 * ( iy + 1 ); + const c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 ); + const d = numberOfVertices + ( ix + 1 ) + gridX1 * iy; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + // increase counter + + groupCount += 6; + + } + + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup( groupStart, groupCount, materialIndex ); + + // calculate new start value for groups + + groupStart += groupCount; + + // update total number of vertices + + numberOfVertices += vertexCounter; + + } + + } + + static fromJSON( data ) { + + return new BoxGeometry( data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments ); + + } + +} + +/** + * Uniform Utilities + */ + +function cloneUniforms( src ) { + + const dst = {}; + + for ( const u in src ) { + + dst[ u ] = {}; + + for ( const p in src[ u ] ) { + + const property = src[ u ][ p ]; + + if ( property && ( property.isColor || + property.isMatrix3 || property.isMatrix4 || + property.isVector2 || property.isVector3 || property.isVector4 || + property.isTexture || property.isQuaternion ) ) { + + dst[ u ][ p ] = property.clone(); + + } else if ( Array.isArray( property ) ) { + + dst[ u ][ p ] = property.slice(); + + } else { + + dst[ u ][ p ] = property; + + } + + } + + } + + return dst; + +} + +function mergeUniforms( uniforms ) { + + const merged = {}; + + for ( let u = 0; u < uniforms.length; u ++ ) { + + const tmp = cloneUniforms( uniforms[ u ] ); + + for ( const p in tmp ) { + + merged[ p ] = tmp[ p ]; + + } + + } + + return merged; + +} + +// Legacy + +const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms }; + +var default_vertex = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"; + +var default_fragment = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}"; + +/** + * parameters = { + * defines: { "label" : "value" }, + * uniforms: { "parameter1": { value: 1.0 }, "parameter2": { value2: 2 } }, + * + * fragmentShader: , + * vertexShader: , + * + * wireframe: , + * wireframeLinewidth: , + * + * lights: + * } + */ + +class ShaderMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'ShaderMaterial'; + + this.defines = {}; + this.uniforms = {}; + + this.vertexShader = default_vertex; + this.fragmentShader = default_fragment; + + this.linewidth = 1; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; // set to use scene fog + this.lights = false; // set to use scene lights + this.clipping = false; // set to use user-defined clipping planes + + this.extensions = { + derivatives: false, // set to use derivatives + fragDepth: false, // set to use fragment depth values + drawBuffers: false, // set to use draw buffers + shaderTextureLOD: false // set to use shader texture LOD + }; + + // When rendered geometry doesn't include these attributes but the material does, + // use these default values in WebGL. This avoids errors when buffer data is missing. + this.defaultAttributeValues = { + 'color': [ 1, 1, 1 ], + 'uv': [ 0, 0 ], + 'uv2': [ 0, 0 ] + }; + + this.index0AttributeName = undefined; + this.uniformsNeedUpdate = false; + + this.glslVersion = null; + + if ( parameters !== undefined ) { + + if ( parameters.attributes !== undefined ) { + + console.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' ); + + } + + this.setValues( parameters ); + + } + + } + + copy( source ) { + + super.copy( source ); + + this.fragmentShader = source.fragmentShader; + this.vertexShader = source.vertexShader; + + this.uniforms = cloneUniforms( source.uniforms ); + + this.defines = Object.assign( {}, source.defines ); + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + this.lights = source.lights; + this.clipping = source.clipping; + + this.extensions = Object.assign( {}, source.extensions ); + + this.glslVersion = source.glslVersion; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.glslVersion = this.glslVersion; + data.uniforms = {}; + + for ( const name in this.uniforms ) { + + const uniform = this.uniforms[ name ]; + const value = uniform.value; + + if ( value && value.isTexture ) { + + data.uniforms[ name ] = { + type: 't', + value: value.toJSON( meta ).uuid + }; + + } else if ( value && value.isColor ) { + + data.uniforms[ name ] = { + type: 'c', + value: value.getHex() + }; + + } else if ( value && value.isVector2 ) { + + data.uniforms[ name ] = { + type: 'v2', + value: value.toArray() + }; + + } else if ( value && value.isVector3 ) { + + data.uniforms[ name ] = { + type: 'v3', + value: value.toArray() + }; + + } else if ( value && value.isVector4 ) { + + data.uniforms[ name ] = { + type: 'v4', + value: value.toArray() + }; + + } else if ( value && value.isMatrix3 ) { + + data.uniforms[ name ] = { + type: 'm3', + value: value.toArray() + }; + + } else if ( value && value.isMatrix4 ) { + + data.uniforms[ name ] = { + type: 'm4', + value: value.toArray() + }; + + } else { + + data.uniforms[ name ] = { + value: value + }; + + // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far + + } + + } + + if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines; + + data.vertexShader = this.vertexShader; + data.fragmentShader = this.fragmentShader; + + const extensions = {}; + + for ( const key in this.extensions ) { + + if ( this.extensions[ key ] === true ) extensions[ key ] = true; + + } + + if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions; + + return data; + + } + +} + +ShaderMaterial.prototype.isShaderMaterial = true; + +class Camera extends Object3D { + + constructor() { + + super(); + + this.type = 'Camera'; + + this.matrixWorldInverse = new Matrix4(); + + this.projectionMatrix = new Matrix4(); + this.projectionMatrixInverse = new Matrix4(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.matrixWorldInverse.copy( source.matrixWorldInverse ); + + this.projectionMatrix.copy( source.projectionMatrix ); + this.projectionMatrixInverse.copy( source.projectionMatrixInverse ); + + return this; + + } + + getWorldDirection( target ) { + + this.updateWorldMatrix( true, false ); + + const e = this.matrixWorld.elements; + + return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize(); + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + this.matrixWorldInverse.copy( this.matrixWorld ).invert(); + + } + + updateWorldMatrix( updateParents, updateChildren ) { + + super.updateWorldMatrix( updateParents, updateChildren ); + + this.matrixWorldInverse.copy( this.matrixWorld ).invert(); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +Camera.prototype.isCamera = true; + +class PerspectiveCamera extends Camera { + + constructor( fov = 50, aspect = 1, near = 0.1, far = 2000 ) { + + super(); + + this.type = 'PerspectiveCamera'; + + this.fov = fov; + this.zoom = 1; + + this.near = near; + this.far = far; + this.focus = 10; + + this.aspect = aspect; + this.view = null; + + this.filmGauge = 35; // width of the film (default in millimeters) + this.filmOffset = 0; // horizontal film offset (same unit as gauge) + + this.updateProjectionMatrix(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.fov = source.fov; + this.zoom = source.zoom; + + this.near = source.near; + this.far = source.far; + this.focus = source.focus; + + this.aspect = source.aspect; + this.view = source.view === null ? null : Object.assign( {}, source.view ); + + this.filmGauge = source.filmGauge; + this.filmOffset = source.filmOffset; + + return this; + + } + + /** + * Sets the FOV by focal length in respect to the current .filmGauge. + * + * The default film gauge is 35, so that the focal length can be specified for + * a 35mm (full frame) camera. + * + * Values for focal length and film gauge must have the same unit. + */ + setFocalLength( focalLength ) { + + /** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */ + const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength; + + this.fov = RAD2DEG * 2 * Math.atan( vExtentSlope ); + this.updateProjectionMatrix(); + + } + + /** + * Calculates the focal length from the current .fov and .filmGauge. + */ + getFocalLength() { + + const vExtentSlope = Math.tan( DEG2RAD * 0.5 * this.fov ); + + return 0.5 * this.getFilmHeight() / vExtentSlope; + + } + + getEffectiveFOV() { + + return RAD2DEG * 2 * Math.atan( + Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom ); + + } + + getFilmWidth() { + + // film not completely covered in portrait format (aspect < 1) + return this.filmGauge * Math.min( this.aspect, 1 ); + + } + + getFilmHeight() { + + // film not completely covered in landscape format (aspect > 1) + return this.filmGauge / Math.max( this.aspect, 1 ); + + } + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. + * + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and + * the monitors are in grid like this + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this + * + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * --A-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * --B-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * --C-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * --D-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * --E-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * --F-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); + * + * Note there is no reason monitors have to be the same size or in a grid. + */ + setViewOffset( fullWidth, fullHeight, x, y, width, height ) { + + this.aspect = fullWidth / fullHeight; + + if ( this.view === null ) { + + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }; + + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + + } + + clearViewOffset() { + + if ( this.view !== null ) { + + this.view.enabled = false; + + } + + this.updateProjectionMatrix(); + + } + + updateProjectionMatrix() { + + const near = this.near; + let top = near * Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom; + let height = 2 * top; + let width = this.aspect * height; + let left = - 0.5 * width; + const view = this.view; + + if ( this.view !== null && this.view.enabled ) { + + const fullWidth = view.fullWidth, + fullHeight = view.fullHeight; + + left += view.offsetX * width / fullWidth; + top -= view.offsetY * height / fullHeight; + width *= view.width / fullWidth; + height *= view.height / fullHeight; + + } + + const skew = this.filmOffset; + if ( skew !== 0 ) left += near * skew / this.getFilmWidth(); + + this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far ); + + this.projectionMatrixInverse.copy( this.projectionMatrix ).invert(); + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.fov = this.fov; + data.object.zoom = this.zoom; + + data.object.near = this.near; + data.object.far = this.far; + data.object.focus = this.focus; + + data.object.aspect = this.aspect; + + if ( this.view !== null ) data.object.view = Object.assign( {}, this.view ); + + data.object.filmGauge = this.filmGauge; + data.object.filmOffset = this.filmOffset; + + return data; + + } + +} + +PerspectiveCamera.prototype.isPerspectiveCamera = true; + +const fov = 90, aspect = 1; + +class CubeCamera extends Object3D { + + constructor( near, far, renderTarget ) { + + super(); + + this.type = 'CubeCamera'; + + if ( renderTarget.isWebGLCubeRenderTarget !== true ) { + + console.error( 'THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.' ); + return; + + } + + this.renderTarget = renderTarget; + + const cameraPX = new PerspectiveCamera( fov, aspect, near, far ); + cameraPX.layers = this.layers; + cameraPX.up.set( 0, - 1, 0 ); + cameraPX.lookAt( new Vector3( 1, 0, 0 ) ); + this.add( cameraPX ); + + const cameraNX = new PerspectiveCamera( fov, aspect, near, far ); + cameraNX.layers = this.layers; + cameraNX.up.set( 0, - 1, 0 ); + cameraNX.lookAt( new Vector3( - 1, 0, 0 ) ); + this.add( cameraNX ); + + const cameraPY = new PerspectiveCamera( fov, aspect, near, far ); + cameraPY.layers = this.layers; + cameraPY.up.set( 0, 0, 1 ); + cameraPY.lookAt( new Vector3( 0, 1, 0 ) ); + this.add( cameraPY ); + + const cameraNY = new PerspectiveCamera( fov, aspect, near, far ); + cameraNY.layers = this.layers; + cameraNY.up.set( 0, 0, - 1 ); + cameraNY.lookAt( new Vector3( 0, - 1, 0 ) ); + this.add( cameraNY ); + + const cameraPZ = new PerspectiveCamera( fov, aspect, near, far ); + cameraPZ.layers = this.layers; + cameraPZ.up.set( 0, - 1, 0 ); + cameraPZ.lookAt( new Vector3( 0, 0, 1 ) ); + this.add( cameraPZ ); + + const cameraNZ = new PerspectiveCamera( fov, aspect, near, far ); + cameraNZ.layers = this.layers; + cameraNZ.up.set( 0, - 1, 0 ); + cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) ); + this.add( cameraNZ ); + + } + + update( renderer, scene ) { + + if ( this.parent === null ) this.updateMatrixWorld(); + + const renderTarget = this.renderTarget; + + const [ cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ ] = this.children; + + const currentXrEnabled = renderer.xr.enabled; + const currentRenderTarget = renderer.getRenderTarget(); + + renderer.xr.enabled = false; + + const generateMipmaps = renderTarget.texture.generateMipmaps; + + renderTarget.texture.generateMipmaps = false; + + renderer.setRenderTarget( renderTarget, 0 ); + renderer.render( scene, cameraPX ); + + renderer.setRenderTarget( renderTarget, 1 ); + renderer.render( scene, cameraNX ); + + renderer.setRenderTarget( renderTarget, 2 ); + renderer.render( scene, cameraPY ); + + renderer.setRenderTarget( renderTarget, 3 ); + renderer.render( scene, cameraNY ); + + renderer.setRenderTarget( renderTarget, 4 ); + renderer.render( scene, cameraPZ ); + + renderTarget.texture.generateMipmaps = generateMipmaps; + + renderer.setRenderTarget( renderTarget, 5 ); + renderer.render( scene, cameraNZ ); + + renderer.setRenderTarget( currentRenderTarget ); + + renderer.xr.enabled = currentXrEnabled; + + renderTarget.texture.needsPMREMUpdate = true; + + } + +} + +class CubeTexture extends Texture { + + constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { + + images = images !== undefined ? images : []; + mapping = mapping !== undefined ? mapping : CubeReflectionMapping; + + super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + + this.flipY = false; + + } + + get images() { + + return this.image; + + } + + set images( value ) { + + this.image = value; + + } + +} + +CubeTexture.prototype.isCubeTexture = true; + +class WebGLCubeRenderTarget extends WebGLRenderTarget { + + constructor( size, options, dummy ) { + + if ( Number.isInteger( options ) ) { + + console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' ); + + options = dummy; + + } + + super( size, size, options ); + + options = options || {}; + + // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) + // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words, + // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly. + + // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped + // and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture + // as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures). + + this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + this.texture.isRenderTargetTexture = true; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + + } + + fromEquirectangularTexture( renderer, texture ) { + + this.texture.type = texture.type; + this.texture.format = RGBAFormat; // see #18859 + this.texture.encoding = texture.encoding; + + this.texture.generateMipmaps = texture.generateMipmaps; + this.texture.minFilter = texture.minFilter; + this.texture.magFilter = texture.magFilter; + + const shader = { + + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: /* glsl */` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `, + + fragmentShader: /* glsl */` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + ` + }; + + const geometry = new BoxGeometry( 5, 5, 5 ); + + const material = new ShaderMaterial( { + + name: 'CubemapFromEquirect', + + uniforms: cloneUniforms( shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + side: BackSide, + blending: NoBlending + + } ); + + material.uniforms.tEquirect.value = texture; + + const mesh = new Mesh( geometry, material ); + + const currentMinFilter = texture.minFilter; + + // Avoid blurred poles + if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter; + + const camera = new CubeCamera( 1, 10, this ); + camera.update( renderer, mesh ); + + texture.minFilter = currentMinFilter; + + mesh.geometry.dispose(); + mesh.material.dispose(); + + return this; + + } + + clear( renderer, color, depth, stencil ) { + + const currentRenderTarget = renderer.getRenderTarget(); + + for ( let i = 0; i < 6; i ++ ) { + + renderer.setRenderTarget( this, i ); + + renderer.clear( color, depth, stencil ); + + } + + renderer.setRenderTarget( currentRenderTarget ); + + } + +} + +WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true; + +const _vector1 = /*@__PURE__*/ new Vector3(); +const _vector2 = /*@__PURE__*/ new Vector3(); +const _normalMatrix = /*@__PURE__*/ new Matrix3(); + +class Plane { + + constructor( normal = new Vector3( 1, 0, 0 ), constant = 0 ) { + + // normal is assumed to be normalized + + this.normal = normal; + this.constant = constant; + + } + + set( normal, constant ) { + + this.normal.copy( normal ); + this.constant = constant; + + return this; + + } + + setComponents( x, y, z, w ) { + + this.normal.set( x, y, z ); + this.constant = w; + + return this; + + } + + setFromNormalAndCoplanarPoint( normal, point ) { + + this.normal.copy( normal ); + this.constant = - point.dot( this.normal ); + + return this; + + } + + setFromCoplanarPoints( a, b, c ) { + + const normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize(); + + // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? + + this.setFromNormalAndCoplanarPoint( normal, a ); + + return this; + + } + + copy( plane ) { + + this.normal.copy( plane.normal ); + this.constant = plane.constant; + + return this; + + } + + normalize() { + + // Note: will lead to a divide by zero if the plane is invalid. + + const inverseNormalLength = 1.0 / this.normal.length(); + this.normal.multiplyScalar( inverseNormalLength ); + this.constant *= inverseNormalLength; + + return this; + + } + + negate() { + + this.constant *= - 1; + this.normal.negate(); + + return this; + + } + + distanceToPoint( point ) { + + return this.normal.dot( point ) + this.constant; + + } + + distanceToSphere( sphere ) { + + return this.distanceToPoint( sphere.center ) - sphere.radius; + + } + + projectPoint( point, target ) { + + return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point ); + + } + + intersectLine( line, target ) { + + const direction = line.delta( _vector1 ); + + const denominator = this.normal.dot( direction ); + + if ( denominator === 0 ) { + + // line is coplanar, return origin + if ( this.distanceToPoint( line.start ) === 0 ) { + + return target.copy( line.start ); + + } + + // Unsure if this is the correct method to handle this case. + return null; + + } + + const t = - ( line.start.dot( this.normal ) + this.constant ) / denominator; + + if ( t < 0 || t > 1 ) { + + return null; + + } + + return target.copy( direction ).multiplyScalar( t ).add( line.start ); + + } + + intersectsLine( line ) { + + // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it. + + const startSign = this.distanceToPoint( line.start ); + const endSign = this.distanceToPoint( line.end ); + + return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 ); + + } + + intersectsBox( box ) { + + return box.intersectsPlane( this ); + + } + + intersectsSphere( sphere ) { + + return sphere.intersectsPlane( this ); + + } + + coplanarPoint( target ) { + + return target.copy( this.normal ).multiplyScalar( - this.constant ); + + } + + applyMatrix4( matrix, optionalNormalMatrix ) { + + const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix ); + + const referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix ); + + const normal = this.normal.applyMatrix3( normalMatrix ).normalize(); + + this.constant = - referencePoint.dot( normal ); + + return this; + + } + + translate( offset ) { + + this.constant -= offset.dot( this.normal ); + + return this; + + } + + equals( plane ) { + + return plane.normal.equals( this.normal ) && ( plane.constant === this.constant ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +Plane.prototype.isPlane = true; + +const _sphere$2 = /*@__PURE__*/ new Sphere(); +const _vector$7 = /*@__PURE__*/ new Vector3(); + +class Frustum { + + constructor( p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane() ) { + + this.planes = [ p0, p1, p2, p3, p4, p5 ]; + + } + + set( p0, p1, p2, p3, p4, p5 ) { + + const planes = this.planes; + + planes[ 0 ].copy( p0 ); + planes[ 1 ].copy( p1 ); + planes[ 2 ].copy( p2 ); + planes[ 3 ].copy( p3 ); + planes[ 4 ].copy( p4 ); + planes[ 5 ].copy( p5 ); + + return this; + + } + + copy( frustum ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + planes[ i ].copy( frustum.planes[ i ] ); + + } + + return this; + + } + + setFromProjectionMatrix( m ) { + + const planes = this.planes; + const me = m.elements; + const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ]; + const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ]; + const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ]; + const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ]; + + planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize(); + planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize(); + planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize(); + planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize(); + planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); + planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); + + return this; + + } + + intersectsObject( object ) { + + const geometry = object.geometry; + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$2.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld ); + + return this.intersectsSphere( _sphere$2 ); + + } + + intersectsSprite( sprite ) { + + _sphere$2.center.set( 0, 0, 0 ); + _sphere$2.radius = 0.7071067811865476; + _sphere$2.applyMatrix4( sprite.matrixWorld ); + + return this.intersectsSphere( _sphere$2 ); + + } + + intersectsSphere( sphere ) { + + const planes = this.planes; + const center = sphere.center; + const negRadius = - sphere.radius; + + for ( let i = 0; i < 6; i ++ ) { + + const distance = planes[ i ].distanceToPoint( center ); + + if ( distance < negRadius ) { + + return false; + + } + + } + + return true; + + } + + intersectsBox( box ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + const plane = planes[ i ]; + + // corner at max distance + + _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z; + + if ( plane.distanceToPoint( _vector$7 ) < 0 ) { + + return false; + + } + + } + + return true; + + } + + containsPoint( point ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + if ( planes[ i ].distanceToPoint( point ) < 0 ) { + + return false; + + } + + } + + return true; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +function WebGLAnimation() { + + let context = null; + let isAnimating = false; + let animationLoop = null; + let requestId = null; + + function onAnimationFrame( time, frame ) { + + animationLoop( time, frame ); + + requestId = context.requestAnimationFrame( onAnimationFrame ); + + } + + return { + + start: function () { + + if ( isAnimating === true ) return; + if ( animationLoop === null ) return; + + requestId = context.requestAnimationFrame( onAnimationFrame ); + + isAnimating = true; + + }, + + stop: function () { + + context.cancelAnimationFrame( requestId ); + + isAnimating = false; + + }, + + setAnimationLoop: function ( callback ) { + + animationLoop = callback; + + }, + + setContext: function ( value ) { + + context = value; + + } + + }; + +} + +function WebGLAttributes( gl, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + const buffers = new WeakMap(); + + function createBuffer( attribute, bufferType ) { + + const array = attribute.array; + const usage = attribute.usage; + + const buffer = gl.createBuffer(); + + gl.bindBuffer( bufferType, buffer ); + gl.bufferData( bufferType, array, usage ); + + attribute.onUploadCallback(); + + let type = 5126; + + if ( array instanceof Float32Array ) { + + type = 5126; + + } else if ( array instanceof Float64Array ) { + + console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); + + } else if ( array instanceof Uint16Array ) { + + if ( attribute.isFloat16BufferAttribute ) { + + if ( isWebGL2 ) { + + type = 5131; + + } else { + + console.warn( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' ); + + } + + } else { + + type = 5123; + + } + + } else if ( array instanceof Int16Array ) { + + type = 5122; + + } else if ( array instanceof Uint32Array ) { + + type = 5125; + + } else if ( array instanceof Int32Array ) { + + type = 5124; + + } else if ( array instanceof Int8Array ) { + + type = 5120; + + } else if ( array instanceof Uint8Array ) { + + type = 5121; + + } else if ( array instanceof Uint8ClampedArray ) { + + type = 5121; + + } + + return { + buffer: buffer, + type: type, + bytesPerElement: array.BYTES_PER_ELEMENT, + version: attribute.version + }; + + } + + function updateBuffer( buffer, attribute, bufferType ) { + + const array = attribute.array; + const updateRange = attribute.updateRange; + + gl.bindBuffer( bufferType, buffer ); + + if ( updateRange.count === - 1 ) { + + // Not using update ranges + + gl.bufferSubData( bufferType, 0, array ); + + } else { + + if ( isWebGL2 ) { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array, updateRange.offset, updateRange.count ); + + } else { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); + + } + + updateRange.count = - 1; // reset range + + } + + } + + // + + function get( attribute ) { + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + return buffers.get( attribute ); + + } + + function remove( attribute ) { + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + const data = buffers.get( attribute ); + + if ( data ) { + + gl.deleteBuffer( data.buffer ); + + buffers.delete( attribute ); + + } + + } + + function update( attribute, bufferType ) { + + if ( attribute.isGLBufferAttribute ) { + + const cached = buffers.get( attribute ); + + if ( ! cached || cached.version < attribute.version ) { + + buffers.set( attribute, { + buffer: attribute.buffer, + type: attribute.type, + bytesPerElement: attribute.elementSize, + version: attribute.version + } ); + + } + + return; + + } + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + const data = buffers.get( attribute ); + + if ( data === undefined ) { + + buffers.set( attribute, createBuffer( attribute, bufferType ) ); + + } else if ( data.version < attribute.version ) { + + updateBuffer( data.buffer, attribute, bufferType ); + + data.version = attribute.version; + + } + + } + + return { + + get: get, + remove: remove, + update: update + + }; + +} + +class PlaneGeometry extends BufferGeometry { + + constructor( width = 1, height = 1, widthSegments = 1, heightSegments = 1 ) { + + super(); + this.type = 'PlaneGeometry'; + + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; + + const width_half = width / 2; + const height_half = height / 2; + + const gridX = Math.floor( widthSegments ); + const gridY = Math.floor( heightSegments ); + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + const segment_width = width / gridX; + const segment_height = height / gridY; + + // + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + for ( let iy = 0; iy < gridY1; iy ++ ) { + + const y = iy * segment_height - height_half; + + for ( let ix = 0; ix < gridX1; ix ++ ) { + + const x = ix * segment_width - width_half; + + vertices.push( x, - y, 0 ); + + normals.push( 0, 0, 1 ); + + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); + + } + + } + + for ( let iy = 0; iy < gridY; iy ++ ) { + + for ( let ix = 0; ix < gridX; ix ++ ) { + + const a = ix + gridX1 * iy; + const b = ix + gridX1 * ( iy + 1 ); + const c = ( ix + 1 ) + gridX1 * ( iy + 1 ); + const d = ( ix + 1 ) + gridX1 * iy; + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new PlaneGeometry( data.width, data.height, data.widthSegments, data.heightSegments ); + + } + +} + +var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; + +var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + +var alphatest_fragment = "#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif"; + +var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif"; + +var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif"; + +var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; + +var begin_vertex = "vec3 transformed = vec3( position );"; + +var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; + +var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif"; + +var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; + +var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; + +var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; + +var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif"; + +var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif"; + +var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif"; + +var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif"; + +var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif"; + +var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif"; + +var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}"; + +var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif"; + +var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; + +var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; + +var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; + +var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; + +var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; + +var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; + +var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}"; + +var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; + +var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; + +var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; + +var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; + +var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; + +var fog_vertex = "#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif"; + +var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif"; + +var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; + +var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; + +var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; + +var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif"; + +var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; + +var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif"; + +var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif"; + +var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif"; + +var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;"; + +var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; + +var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + +var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; + +var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif"; + +var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; + +var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; + +var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif"; + +var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; + +var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; + +var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; + +var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; + +var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; + +var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif"; + +var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; + +var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; + +var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + +var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; + +var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; + +var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif"; + +var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif"; + +var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif"; + +var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; + +var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif"; + +var normal_pars_fragment = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif"; + +var normal_pars_vertex = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif"; + +var normal_vertex = "#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif"; + +var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif"; + +var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; + +var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif"; + +var clearcoat_pars_fragment = "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; + +var output_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );"; + +var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; + +var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; + +var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; + +var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; + +var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; + +var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; + +var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; + +var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; + +var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; + +var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif"; + +var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}"; + +var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; + +var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; + +var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; + +var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; + +var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; + +var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; + +var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; + +var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }"; + +var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif"; + +var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif"; + +var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; + +var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; + +var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; + +var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; + +var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; + +var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; + +var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; + +const vertex$g = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; + +const fragment$g = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#include \n\t#include \n}"; + +const vertex$f = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; + +const fragment$f = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; + +const vertex$e = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}"; + +const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}"; + +const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; + +const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; + +const vertex$c = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; + +const fragment$c = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}"; + +const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$a = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$9 = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$9 = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; + +const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; + +const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; + +const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}"; + +const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + +const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$3 = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$2 = "#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}"; + +const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + +const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const ShaderChunk = { + alphamap_fragment: alphamap_fragment, + alphamap_pars_fragment: alphamap_pars_fragment, + alphatest_fragment: alphatest_fragment, + alphatest_pars_fragment: alphatest_pars_fragment, + aomap_fragment: aomap_fragment, + aomap_pars_fragment: aomap_pars_fragment, + begin_vertex: begin_vertex, + beginnormal_vertex: beginnormal_vertex, + bsdfs: bsdfs, + bumpmap_pars_fragment: bumpmap_pars_fragment, + clipping_planes_fragment: clipping_planes_fragment, + clipping_planes_pars_fragment: clipping_planes_pars_fragment, + clipping_planes_pars_vertex: clipping_planes_pars_vertex, + clipping_planes_vertex: clipping_planes_vertex, + color_fragment: color_fragment, + color_pars_fragment: color_pars_fragment, + color_pars_vertex: color_pars_vertex, + color_vertex: color_vertex, + common: common, + cube_uv_reflection_fragment: cube_uv_reflection_fragment, + defaultnormal_vertex: defaultnormal_vertex, + displacementmap_pars_vertex: displacementmap_pars_vertex, + displacementmap_vertex: displacementmap_vertex, + emissivemap_fragment: emissivemap_fragment, + emissivemap_pars_fragment: emissivemap_pars_fragment, + encodings_fragment: encodings_fragment, + encodings_pars_fragment: encodings_pars_fragment, + envmap_fragment: envmap_fragment, + envmap_common_pars_fragment: envmap_common_pars_fragment, + envmap_pars_fragment: envmap_pars_fragment, + envmap_pars_vertex: envmap_pars_vertex, + envmap_physical_pars_fragment: envmap_physical_pars_fragment, + envmap_vertex: envmap_vertex, + fog_vertex: fog_vertex, + fog_pars_vertex: fog_pars_vertex, + fog_fragment: fog_fragment, + fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, + lightmap_fragment: lightmap_fragment, + lightmap_pars_fragment: lightmap_pars_fragment, + lights_lambert_vertex: lights_lambert_vertex, + lights_pars_begin: lights_pars_begin, + lights_toon_fragment: lights_toon_fragment, + lights_toon_pars_fragment: lights_toon_pars_fragment, + lights_phong_fragment: lights_phong_fragment, + lights_phong_pars_fragment: lights_phong_pars_fragment, + lights_physical_fragment: lights_physical_fragment, + lights_physical_pars_fragment: lights_physical_pars_fragment, + lights_fragment_begin: lights_fragment_begin, + lights_fragment_maps: lights_fragment_maps, + lights_fragment_end: lights_fragment_end, + logdepthbuf_fragment: logdepthbuf_fragment, + logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, + logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, + logdepthbuf_vertex: logdepthbuf_vertex, + map_fragment: map_fragment, + map_pars_fragment: map_pars_fragment, + map_particle_fragment: map_particle_fragment, + map_particle_pars_fragment: map_particle_pars_fragment, + metalnessmap_fragment: metalnessmap_fragment, + metalnessmap_pars_fragment: metalnessmap_pars_fragment, + morphnormal_vertex: morphnormal_vertex, + morphtarget_pars_vertex: morphtarget_pars_vertex, + morphtarget_vertex: morphtarget_vertex, + normal_fragment_begin: normal_fragment_begin, + normal_fragment_maps: normal_fragment_maps, + normal_pars_fragment: normal_pars_fragment, + normal_pars_vertex: normal_pars_vertex, + normal_vertex: normal_vertex, + normalmap_pars_fragment: normalmap_pars_fragment, + clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, + clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, + clearcoat_pars_fragment: clearcoat_pars_fragment, + output_fragment: output_fragment, + packing: packing, + premultiplied_alpha_fragment: premultiplied_alpha_fragment, + project_vertex: project_vertex, + dithering_fragment: dithering_fragment, + dithering_pars_fragment: dithering_pars_fragment, + roughnessmap_fragment: roughnessmap_fragment, + roughnessmap_pars_fragment: roughnessmap_pars_fragment, + shadowmap_pars_fragment: shadowmap_pars_fragment, + shadowmap_pars_vertex: shadowmap_pars_vertex, + shadowmap_vertex: shadowmap_vertex, + shadowmask_pars_fragment: shadowmask_pars_fragment, + skinbase_vertex: skinbase_vertex, + skinning_pars_vertex: skinning_pars_vertex, + skinning_vertex: skinning_vertex, + skinnormal_vertex: skinnormal_vertex, + specularmap_fragment: specularmap_fragment, + specularmap_pars_fragment: specularmap_pars_fragment, + tonemapping_fragment: tonemapping_fragment, + tonemapping_pars_fragment: tonemapping_pars_fragment, + transmission_fragment: transmission_fragment, + transmission_pars_fragment: transmission_pars_fragment, + uv_pars_fragment: uv_pars_fragment, + uv_pars_vertex: uv_pars_vertex, + uv_vertex: uv_vertex, + uv2_pars_fragment: uv2_pars_fragment, + uv2_pars_vertex: uv2_pars_vertex, + uv2_vertex: uv2_vertex, + worldpos_vertex: worldpos_vertex, + + background_vert: vertex$g, + background_frag: fragment$g, + cube_vert: vertex$f, + cube_frag: fragment$f, + depth_vert: vertex$e, + depth_frag: fragment$e, + distanceRGBA_vert: vertex$d, + distanceRGBA_frag: fragment$d, + equirect_vert: vertex$c, + equirect_frag: fragment$c, + linedashed_vert: vertex$b, + linedashed_frag: fragment$b, + meshbasic_vert: vertex$a, + meshbasic_frag: fragment$a, + meshlambert_vert: vertex$9, + meshlambert_frag: fragment$9, + meshmatcap_vert: vertex$8, + meshmatcap_frag: fragment$8, + meshnormal_vert: vertex$7, + meshnormal_frag: fragment$7, + meshphong_vert: vertex$6, + meshphong_frag: fragment$6, + meshphysical_vert: vertex$5, + meshphysical_frag: fragment$5, + meshtoon_vert: vertex$4, + meshtoon_frag: fragment$4, + points_vert: vertex$3, + points_frag: fragment$3, + shadow_vert: vertex$2, + shadow_frag: fragment$2, + sprite_vert: vertex$1, + sprite_frag: fragment$1 +}; + +/** + * Uniforms library for shared webgl shaders + */ + +const UniformsLib = { + + common: { + + diffuse: { value: new Color$1( 0xffffff ) }, + opacity: { value: 1.0 }, + + map: { value: null }, + uvTransform: { value: new Matrix3() }, + uv2Transform: { value: new Matrix3() }, + + alphaMap: { value: null }, + alphaTest: { value: 0 } + + }, + + specularmap: { + + specularMap: { value: null }, + + }, + + envmap: { + + envMap: { value: null }, + flipEnvMap: { value: - 1 }, + reflectivity: { value: 1.0 }, // basic, lambert, phong + ior: { value: 1.5 }, // standard, physical + refractionRatio: { value: 0.98 } + + }, + + aomap: { + + aoMap: { value: null }, + aoMapIntensity: { value: 1 } + + }, + + lightmap: { + + lightMap: { value: null }, + lightMapIntensity: { value: 1 } + + }, + + emissivemap: { + + emissiveMap: { value: null } + + }, + + bumpmap: { + + bumpMap: { value: null }, + bumpScale: { value: 1 } + + }, + + normalmap: { + + normalMap: { value: null }, + normalScale: { value: new Vector2( 1, 1 ) } + + }, + + displacementmap: { + + displacementMap: { value: null }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 } + + }, + + roughnessmap: { + + roughnessMap: { value: null } + + }, + + metalnessmap: { + + metalnessMap: { value: null } + + }, + + gradientmap: { + + gradientMap: { value: null } + + }, + + fog: { + + fogDensity: { value: 0.00025 }, + fogNear: { value: 1 }, + fogFar: { value: 2000 }, + fogColor: { value: new Color$1( 0xffffff ) } + + }, + + lights: { + + ambientLightColor: { value: [] }, + + lightProbe: { value: [] }, + + directionalLights: { value: [], properties: { + direction: {}, + color: {} + } }, + + directionalLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, + + spotLights: { value: [], properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } }, + + spotLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + + spotShadowMap: { value: [] }, + spotShadowMatrix: { value: [] }, + + pointLights: { value: [], properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } }, + + pointLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } }, + + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, + + hemisphereLights: { value: [], properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } }, + + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {} + } }, + + ltc_1: { value: null }, + ltc_2: { value: null } + + }, + + points: { + + diffuse: { value: new Color$1( 0xffffff ) }, + opacity: { value: 1.0 }, + size: { value: 1.0 }, + scale: { value: 1.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() } + + }, + + sprite: { + + diffuse: { value: new Color$1( 0xffffff ) }, + opacity: { value: 1.0 }, + center: { value: new Vector2( 0.5, 0.5 ) }, + rotation: { value: 0.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() } + + } + +}; + +const ShaderLib = { + + basic: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.meshbasic_vert, + fragmentShader: ShaderChunk.meshbasic_frag + + }, + + lambert: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color$1( 0x000000 ) } + } + ] ), + + vertexShader: ShaderChunk.meshlambert_vert, + fragmentShader: ShaderChunk.meshlambert_frag + + }, + + phong: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color$1( 0x000000 ) }, + specular: { value: new Color$1( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), + + vertexShader: ShaderChunk.meshphong_vert, + fragmentShader: ShaderChunk.meshphong_frag + + }, + + standard: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.roughnessmap, + UniformsLib.metalnessmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color$1( 0x000000 ) }, + roughness: { value: 1.0 }, + metalness: { value: 0.0 }, + envMapIntensity: { value: 1 } // temporary + } + ] ), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + + }, + + toon: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.gradientmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color$1( 0x000000 ) } + } + ] ), + + vertexShader: ShaderChunk.meshtoon_vert, + fragmentShader: ShaderChunk.meshtoon_frag + + }, + + matcap: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + { + matcap: { value: null } + } + ] ), + + vertexShader: ShaderChunk.meshmatcap_vert, + fragmentShader: ShaderChunk.meshmatcap_frag + + }, + + points: { + + uniforms: mergeUniforms( [ + UniformsLib.points, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.points_vert, + fragmentShader: ShaderChunk.points_frag + + }, + + dashed: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 } + } + ] ), + + vertexShader: ShaderChunk.linedashed_vert, + fragmentShader: ShaderChunk.linedashed_frag + + }, + + depth: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap + ] ), + + vertexShader: ShaderChunk.depth_vert, + fragmentShader: ShaderChunk.depth_frag + + }, + + normal: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + { + opacity: { value: 1.0 } + } + ] ), + + vertexShader: ShaderChunk.meshnormal_vert, + fragmentShader: ShaderChunk.meshnormal_frag + + }, + + sprite: { + + uniforms: mergeUniforms( [ + UniformsLib.sprite, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.sprite_vert, + fragmentShader: ShaderChunk.sprite_frag + + }, + + background: { + + uniforms: { + uvTransform: { value: new Matrix3() }, + t2D: { value: null }, + }, + + vertexShader: ShaderChunk.background_vert, + fragmentShader: ShaderChunk.background_frag + + }, + /* ------------------------------------------------------------------------- + // Cube map shader + ------------------------------------------------------------------------- */ + + cube: { + + uniforms: mergeUniforms( [ + UniformsLib.envmap, + { + opacity: { value: 1.0 } + } + ] ), + + vertexShader: ShaderChunk.cube_vert, + fragmentShader: ShaderChunk.cube_frag + + }, + + equirect: { + + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: ShaderChunk.equirect_vert, + fragmentShader: ShaderChunk.equirect_frag + + }, + + distanceRGBA: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap, + { + referencePosition: { value: new Vector3() }, + nearDistance: { value: 1 }, + farDistance: { value: 1000 } + } + ] ), + + vertexShader: ShaderChunk.distanceRGBA_vert, + fragmentShader: ShaderChunk.distanceRGBA_frag + + }, + + shadow: { + + uniforms: mergeUniforms( [ + UniformsLib.lights, + UniformsLib.fog, + { + color: { value: new Color$1( 0x00000 ) }, + opacity: { value: 1.0 } + }, + ] ), + + vertexShader: ShaderChunk.shadow_vert, + fragmentShader: ShaderChunk.shadow_frag + + } + +}; + +ShaderLib.physical = { + + uniforms: mergeUniforms( [ + ShaderLib.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, + clearcoatNormalMap: { value: null }, + sheen: { value: 0 }, + sheenColor: { value: new Color$1( 0x000000 ) }, + sheenColorMap: { value: null }, + sheenRoughness: { value: 1 }, + sheenRoughnessMap: { value: null }, + transmission: { value: 0 }, + transmissionMap: { value: null }, + transmissionSamplerSize: { value: new Vector2() }, + transmissionSamplerMap: { value: null }, + thickness: { value: 0 }, + thicknessMap: { value: null }, + attenuationDistance: { value: 0 }, + attenuationColor: { value: new Color$1( 0x000000 ) }, + specularIntensity: { value: 1 }, + specularIntensityMap: { value: null }, + specularColor: { value: new Color$1( 1, 1, 1 ) }, + specularColorMap: { value: null }, + } + ] ), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + +}; + +function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipliedAlpha ) { + + const clearColor = new Color$1( 0x000000 ); + let clearAlpha = alpha === true ? 0 : 1; + + let planeMesh; + let boxMesh; + + let currentBackground = null; + let currentBackgroundVersion = 0; + let currentTonemapping = null; + + function render( renderList, scene ) { + + let forceClear = false; + let background = scene.isScene === true ? scene.background : null; + + if ( background && background.isTexture ) { + + background = cubemaps.get( background ); + + } + + // Ignore background in AR + // TODO: Reconsider this. + + const xr = renderer.xr; + const session = xr.getSession && xr.getSession(); + + if ( session && session.environmentBlendMode === 'additive' ) { + + background = null; + + } + + if ( background === null ) { + + setClear( clearColor, clearAlpha ); + + } else if ( background && background.isColor ) { + + setClear( background, 1 ); + forceClear = true; + + } + + if ( renderer.autoClear || forceClear ) { + + renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil ); + + } + + if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) { + + if ( boxMesh === undefined ) { + + boxMesh = new Mesh( + new BoxGeometry( 1, 1, 1 ), + new ShaderMaterial( { + name: 'BackgroundCubeMaterial', + uniforms: cloneUniforms( ShaderLib.cube.uniforms ), + vertexShader: ShaderLib.cube.vertexShader, + fragmentShader: ShaderLib.cube.fragmentShader, + side: BackSide, + depthTest: false, + depthWrite: false, + fog: false + } ) + ); + + boxMesh.geometry.deleteAttribute( 'normal' ); + boxMesh.geometry.deleteAttribute( 'uv' ); + + boxMesh.onBeforeRender = function ( renderer, scene, camera ) { + + this.matrixWorld.copyPosition( camera.matrixWorld ); + + }; + + // enable code injection for non-built-in material + Object.defineProperty( boxMesh.material, 'envMap', { + + get: function () { + + return this.uniforms.envMap.value; + + } + + } ); + + objects.update( boxMesh ); + + } + + boxMesh.material.uniforms.envMap.value = background; + boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1; + + if ( currentBackground !== background || + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { + + boxMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + + } + + // push to the pre-sorted opaque render list + renderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null ); + + } else if ( background && background.isTexture ) { + + if ( planeMesh === undefined ) { + + planeMesh = new Mesh( + new PlaneGeometry( 2, 2 ), + new ShaderMaterial( { + name: 'BackgroundMaterial', + uniforms: cloneUniforms( ShaderLib.background.uniforms ), + vertexShader: ShaderLib.background.vertexShader, + fragmentShader: ShaderLib.background.fragmentShader, + side: FrontSide, + depthTest: false, + depthWrite: false, + fog: false + } ) + ); + + planeMesh.geometry.deleteAttribute( 'normal' ); + + // enable code injection for non-built-in material + Object.defineProperty( planeMesh.material, 'map', { + + get: function () { + + return this.uniforms.t2D.value; + + } + + } ); + + objects.update( planeMesh ); + + } + + planeMesh.material.uniforms.t2D.value = background; + + if ( background.matrixAutoUpdate === true ) { + + background.updateMatrix(); + + } + + planeMesh.material.uniforms.uvTransform.value.copy( background.matrix ); + + if ( currentBackground !== background || + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { + + planeMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + + } + + + // push to the pre-sorted opaque render list + renderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null ); + + } + + } + + function setClear( color, alpha ) { + + state.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha ); + + } + + return { + + getClearColor: function () { + + return clearColor; + + }, + setClearColor: function ( color, alpha = 1 ) { + + clearColor.set( color ); + clearAlpha = alpha; + setClear( clearColor, clearAlpha ); + + }, + getClearAlpha: function () { + + return clearAlpha; + + }, + setClearAlpha: function ( alpha ) { + + clearAlpha = alpha; + setClear( clearColor, clearAlpha ); + + }, + render: render + + }; + +} + +function WebGLBindingStates( gl, extensions, attributes, capabilities ) { + + const maxVertexAttributes = gl.getParameter( 34921 ); + + const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' ); + const vaoAvailable = capabilities.isWebGL2 || extension !== null; + + const bindingStates = {}; + + const defaultState = createBindingState( null ); + let currentState = defaultState; + + function setup( object, material, program, geometry, index ) { + + let updateBuffers = false; + + if ( vaoAvailable ) { + + const state = getBindingState( geometry, program, material ); + + if ( currentState !== state ) { + + currentState = state; + bindVertexArrayObject( currentState.object ); + + } + + updateBuffers = needsUpdate( geometry, index ); + + if ( updateBuffers ) saveCache( geometry, index ); + + } else { + + const wireframe = ( material.wireframe === true ); + + if ( currentState.geometry !== geometry.id || + currentState.program !== program.id || + currentState.wireframe !== wireframe ) { + + currentState.geometry = geometry.id; + currentState.program = program.id; + currentState.wireframe = wireframe; + + updateBuffers = true; + + } + + } + + if ( object.isInstancedMesh === true ) { + + updateBuffers = true; + + } + + if ( index !== null ) { + + attributes.update( index, 34963 ); + + } + + if ( updateBuffers ) { + + setupVertexAttributes( object, material, program, geometry ); + + if ( index !== null ) { + + gl.bindBuffer( 34963, attributes.get( index ).buffer ); + + } + + } + + } + + function createVertexArrayObject() { + + if ( capabilities.isWebGL2 ) return gl.createVertexArray(); + + return extension.createVertexArrayOES(); + + } + + function bindVertexArrayObject( vao ) { + + if ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao ); + + return extension.bindVertexArrayOES( vao ); + + } + + function deleteVertexArrayObject( vao ) { + + if ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao ); + + return extension.deleteVertexArrayOES( vao ); + + } + + function getBindingState( geometry, program, material ) { + + const wireframe = ( material.wireframe === true ); + + let programMap = bindingStates[ geometry.id ]; + + if ( programMap === undefined ) { + + programMap = {}; + bindingStates[ geometry.id ] = programMap; + + } + + let stateMap = programMap[ program.id ]; + + if ( stateMap === undefined ) { + + stateMap = {}; + programMap[ program.id ] = stateMap; + + } + + let state = stateMap[ wireframe ]; + + if ( state === undefined ) { + + state = createBindingState( createVertexArrayObject() ); + stateMap[ wireframe ] = state; + + } + + return state; + + } + + function createBindingState( vao ) { + + const newAttributes = []; + const enabledAttributes = []; + const attributeDivisors = []; + + for ( let i = 0; i < maxVertexAttributes; i ++ ) { + + newAttributes[ i ] = 0; + enabledAttributes[ i ] = 0; + attributeDivisors[ i ] = 0; + + } + + return { + + // for backward compatibility on non-VAO support browser + geometry: null, + program: null, + wireframe: false, + + newAttributes: newAttributes, + enabledAttributes: enabledAttributes, + attributeDivisors: attributeDivisors, + object: vao, + attributes: {}, + index: null + + }; + + } + + function needsUpdate( geometry, index ) { + + const cachedAttributes = currentState.attributes; + const geometryAttributes = geometry.attributes; + + let attributesNum = 0; + + for ( const key in geometryAttributes ) { + + const cachedAttribute = cachedAttributes[ key ]; + const geometryAttribute = geometryAttributes[ key ]; + + if ( cachedAttribute === undefined ) return true; + + if ( cachedAttribute.attribute !== geometryAttribute ) return true; + + if ( cachedAttribute.data !== geometryAttribute.data ) return true; + + attributesNum ++; + + } + + if ( currentState.attributesNum !== attributesNum ) return true; + + if ( currentState.index !== index ) return true; + + return false; + + } + + function saveCache( geometry, index ) { + + const cache = {}; + const attributes = geometry.attributes; + let attributesNum = 0; + + for ( const key in attributes ) { + + const attribute = attributes[ key ]; + + const data = {}; + data.attribute = attribute; + + if ( attribute.data ) { + + data.data = attribute.data; + + } + + cache[ key ] = data; + + attributesNum ++; + + } + + currentState.attributes = cache; + currentState.attributesNum = attributesNum; + + currentState.index = index; + + } + + function initAttributes() { + + const newAttributes = currentState.newAttributes; + + for ( let i = 0, il = newAttributes.length; i < il; i ++ ) { + + newAttributes[ i ] = 0; + + } + + } + + function enableAttribute( attribute ) { + + enableAttributeAndDivisor( attribute, 0 ); + + } + + function enableAttributeAndDivisor( attribute, meshPerAttribute ) { + + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + const attributeDivisors = currentState.attributeDivisors; + + newAttributes[ attribute ] = 1; + + if ( enabledAttributes[ attribute ] === 0 ) { + + gl.enableVertexAttribArray( attribute ); + enabledAttributes[ attribute ] = 1; + + } + + if ( attributeDivisors[ attribute ] !== meshPerAttribute ) { + + const extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' ); + + extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute ); + attributeDivisors[ attribute ] = meshPerAttribute; + + } + + } + + function disableUnusedAttributes() { + + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + + for ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) { + + if ( enabledAttributes[ i ] !== newAttributes[ i ] ) { + + gl.disableVertexAttribArray( i ); + enabledAttributes[ i ] = 0; + + } + + } + + } + + function vertexAttribPointer( index, size, type, normalized, stride, offset ) { + + if ( capabilities.isWebGL2 === true && ( type === 5124 || type === 5125 ) ) { + + gl.vertexAttribIPointer( index, size, type, stride, offset ); + + } else { + + gl.vertexAttribPointer( index, size, type, normalized, stride, offset ); + + } + + } + + function setupVertexAttributes( object, material, program, geometry ) { + + if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) { + + if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return; + + } + + initAttributes(); + + const geometryAttributes = geometry.attributes; + + const programAttributes = program.getAttributes(); + + const materialDefaultAttributeValues = material.defaultAttributeValues; + + for ( const name in programAttributes ) { + + const programAttribute = programAttributes[ name ]; + + if ( programAttribute.location >= 0 ) { + + let geometryAttribute = geometryAttributes[ name ]; + + if ( geometryAttribute === undefined ) { + + if ( name === 'instanceMatrix' && object.instanceMatrix ) geometryAttribute = object.instanceMatrix; + if ( name === 'instanceColor' && object.instanceColor ) geometryAttribute = object.instanceColor; + + } + + if ( geometryAttribute !== undefined ) { + + const normalized = geometryAttribute.normalized; + const size = geometryAttribute.itemSize; + + const attribute = attributes.get( geometryAttribute ); + + // TODO Attribute may not be available on context restore + + if ( attribute === undefined ) continue; + + const buffer = attribute.buffer; + const type = attribute.type; + const bytesPerElement = attribute.bytesPerElement; + + if ( geometryAttribute.isInterleavedBufferAttribute ) { + + const data = geometryAttribute.data; + const stride = data.stride; + const offset = geometryAttribute.offset; + + if ( data && data.isInstancedInterleavedBuffer ) { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttributeAndDivisor( programAttribute.location + i, data.meshPerAttribute ); + + } + + if ( object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined ) { + + geometry._maxInstanceCount = data.meshPerAttribute * data.count; + + } + + } else { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttribute( programAttribute.location + i ); + + } + + } + + gl.bindBuffer( 34962, buffer ); + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + stride * bytesPerElement, + ( offset + ( size / programAttribute.locationSize ) * i ) * bytesPerElement + ); + + } + + } else { + + if ( geometryAttribute.isInstancedBufferAttribute ) { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttributeAndDivisor( programAttribute.location + i, geometryAttribute.meshPerAttribute ); + + } + + if ( object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined ) { + + geometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count; + + } + + } else { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttribute( programAttribute.location + i ); + + } + + } + + gl.bindBuffer( 34962, buffer ); + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + size * bytesPerElement, + ( size / programAttribute.locationSize ) * i * bytesPerElement + ); + + } + + } + + } else if ( materialDefaultAttributeValues !== undefined ) { + + const value = materialDefaultAttributeValues[ name ]; + + if ( value !== undefined ) { + + switch ( value.length ) { + + case 2: + gl.vertexAttrib2fv( programAttribute.location, value ); + break; + + case 3: + gl.vertexAttrib3fv( programAttribute.location, value ); + break; + + case 4: + gl.vertexAttrib4fv( programAttribute.location, value ); + break; + + default: + gl.vertexAttrib1fv( programAttribute.location, value ); + + } + + } + + } + + } + + } + + disableUnusedAttributes(); + + } + + function dispose() { + + reset(); + + for ( const geometryId in bindingStates ) { + + const programMap = bindingStates[ geometryId ]; + + for ( const programId in programMap ) { + + const stateMap = programMap[ programId ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ programId ]; + + } + + delete bindingStates[ geometryId ]; + + } + + } + + function releaseStatesOfGeometry( geometry ) { + + if ( bindingStates[ geometry.id ] === undefined ) return; + + const programMap = bindingStates[ geometry.id ]; + + for ( const programId in programMap ) { + + const stateMap = programMap[ programId ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ programId ]; + + } + + delete bindingStates[ geometry.id ]; + + } + + function releaseStatesOfProgram( program ) { + + for ( const geometryId in bindingStates ) { + + const programMap = bindingStates[ geometryId ]; + + if ( programMap[ program.id ] === undefined ) continue; + + const stateMap = programMap[ program.id ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ program.id ]; + + } + + } + + function reset() { + + resetDefaultState(); + + if ( currentState === defaultState ) return; + + currentState = defaultState; + bindVertexArrayObject( currentState.object ); + + } + + // for backward-compatilibity + + function resetDefaultState() { + + defaultState.geometry = null; + defaultState.program = null; + defaultState.wireframe = false; + + } + + return { + + setup: setup, + reset: reset, + resetDefaultState: resetDefaultState, + dispose: dispose, + releaseStatesOfGeometry: releaseStatesOfGeometry, + releaseStatesOfProgram: releaseStatesOfProgram, + + initAttributes: initAttributes, + enableAttribute: enableAttribute, + disableUnusedAttributes: disableUnusedAttributes + + }; + +} + +function WebGLBufferRenderer( gl, extensions, info, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode( value ) { + + mode = value; + + } + + function render( start, count ) { + + gl.drawArrays( mode, start, count ); + + info.update( count, mode, 1 ); + + } + + function renderInstances( start, count, primcount ) { + + if ( primcount === 0 ) return; + + let extension, methodName; + + if ( isWebGL2 ) { + + extension = gl; + methodName = 'drawArraysInstanced'; + + } else { + + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawArraysInstancedANGLE'; + + if ( extension === null ) { + + console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); + return; + + } + + } + + extension[ methodName ]( mode, start, count, primcount ); + + info.update( count, mode, primcount ); + + } + + // + + this.setMode = setMode; + this.render = render; + this.renderInstances = renderInstances; + +} + +function WebGLCapabilities( gl, extensions, parameters ) { + + let maxAnisotropy; + + function getMaxAnisotropy() { + + if ( maxAnisotropy !== undefined ) return maxAnisotropy; + + if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) { + + const extension = extensions.get( 'EXT_texture_filter_anisotropic' ); + + maxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT ); + + } else { + + maxAnisotropy = 0; + + } + + return maxAnisotropy; + + } + + function getMaxPrecision( precision ) { + + if ( precision === 'highp' ) { + + if ( gl.getShaderPrecisionFormat( 35633, 36338 ).precision > 0 && + gl.getShaderPrecisionFormat( 35632, 36338 ).precision > 0 ) { + + return 'highp'; + + } + + precision = 'mediump'; + + } + + if ( precision === 'mediump' ) { + + if ( gl.getShaderPrecisionFormat( 35633, 36337 ).precision > 0 && + gl.getShaderPrecisionFormat( 35632, 36337 ).precision > 0 ) { + + return 'mediump'; + + } + + } + + return 'lowp'; + + } + + const isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) || + ( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext ); + + let precision = parameters.precision !== undefined ? parameters.precision : 'highp'; + const maxPrecision = getMaxPrecision( precision ); + + if ( maxPrecision !== precision ) { + + console.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' ); + precision = maxPrecision; + + } + + const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' ); + + const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true; + + const maxTextures = gl.getParameter( 34930 ); + const maxVertexTextures = gl.getParameter( 35660 ); + const maxTextureSize = gl.getParameter( 3379 ); + const maxCubemapSize = gl.getParameter( 34076 ); + + const maxAttributes = gl.getParameter( 34921 ); + const maxVertexUniforms = gl.getParameter( 36347 ); + const maxVaryings = gl.getParameter( 36348 ); + const maxFragmentUniforms = gl.getParameter( 36349 ); + + const vertexTextures = maxVertexTextures > 0; + const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' ); + const floatVertexTextures = vertexTextures && floatFragmentTextures; + + const maxSamples = isWebGL2 ? gl.getParameter( 36183 ) : 0; + + return { + + isWebGL2: isWebGL2, + + drawBuffers: drawBuffers, + + getMaxAnisotropy: getMaxAnisotropy, + getMaxPrecision: getMaxPrecision, + + precision: precision, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + maxTextures: maxTextures, + maxVertexTextures: maxVertexTextures, + maxTextureSize: maxTextureSize, + maxCubemapSize: maxCubemapSize, + + maxAttributes: maxAttributes, + maxVertexUniforms: maxVertexUniforms, + maxVaryings: maxVaryings, + maxFragmentUniforms: maxFragmentUniforms, + + vertexTextures: vertexTextures, + floatFragmentTextures: floatFragmentTextures, + floatVertexTextures: floatVertexTextures, + + maxSamples: maxSamples + + }; + +} + +function WebGLClipping( properties ) { + + const scope = this; + + let globalState = null, + numGlobalPlanes = 0, + localClippingEnabled = false, + renderingShadows = false; + + const plane = new Plane(), + viewNormalMatrix = new Matrix3(), + + uniform = { value: null, needsUpdate: false }; + + this.uniform = uniform; + this.numPlanes = 0; + this.numIntersection = 0; + + this.init = function ( planes, enableLocalClipping, camera ) { + + const enabled = + planes.length !== 0 || + enableLocalClipping || + // enable state of previous frame - the clipping code has to + // run another frame in order to reset the state: + numGlobalPlanes !== 0 || + localClippingEnabled; + + localClippingEnabled = enableLocalClipping; + + globalState = projectPlanes( planes, camera, 0 ); + numGlobalPlanes = planes.length; + + return enabled; + + }; + + this.beginShadows = function () { + + renderingShadows = true; + projectPlanes( null ); + + }; + + this.endShadows = function () { + + renderingShadows = false; + resetGlobalState(); + + }; + + this.setState = function ( material, camera, useCache ) { + + const planes = material.clippingPlanes, + clipIntersection = material.clipIntersection, + clipShadows = material.clipShadows; + + const materialProperties = properties.get( material ); + + if ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) { + + // there's no local clipping + + if ( renderingShadows ) { + + // there's no global clipping + + projectPlanes( null ); + + } else { + + resetGlobalState(); + + } + + } else { + + const nGlobal = renderingShadows ? 0 : numGlobalPlanes, + lGlobal = nGlobal * 4; + + let dstArray = materialProperties.clippingState || null; + + uniform.value = dstArray; // ensure unique state + + dstArray = projectPlanes( planes, camera, lGlobal, useCache ); + + for ( let i = 0; i !== lGlobal; ++ i ) { + + dstArray[ i ] = globalState[ i ]; + + } + + materialProperties.clippingState = dstArray; + this.numIntersection = clipIntersection ? this.numPlanes : 0; + this.numPlanes += nGlobal; + + } + + + }; + + function resetGlobalState() { + + if ( uniform.value !== globalState ) { + + uniform.value = globalState; + uniform.needsUpdate = numGlobalPlanes > 0; + + } + + scope.numPlanes = numGlobalPlanes; + scope.numIntersection = 0; + + } + + function projectPlanes( planes, camera, dstOffset, skipTransform ) { + + const nPlanes = planes !== null ? planes.length : 0; + let dstArray = null; + + if ( nPlanes !== 0 ) { + + dstArray = uniform.value; + + if ( skipTransform !== true || dstArray === null ) { + + const flatSize = dstOffset + nPlanes * 4, + viewMatrix = camera.matrixWorldInverse; + + viewNormalMatrix.getNormalMatrix( viewMatrix ); + + if ( dstArray === null || dstArray.length < flatSize ) { + + dstArray = new Float32Array( flatSize ); + + } + + for ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) { + + plane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix ); + + plane.normal.toArray( dstArray, i4 ); + dstArray[ i4 + 3 ] = plane.constant; + + } + + } + + uniform.value = dstArray; + uniform.needsUpdate = true; + + } + + scope.numPlanes = nPlanes; + scope.numIntersection = 0; + + return dstArray; + + } + +} + +function WebGLCubeMaps( renderer ) { + + let cubemaps = new WeakMap(); + + function mapTextureMapping( texture, mapping ) { + + if ( mapping === EquirectangularReflectionMapping ) { + + texture.mapping = CubeReflectionMapping; + + } else if ( mapping === EquirectangularRefractionMapping ) { + + texture.mapping = CubeRefractionMapping; + + } + + return texture; + + } + + function get( texture ) { + + if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) { + + const mapping = texture.mapping; + + if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) { + + if ( cubemaps.has( texture ) ) { + + const cubemap = cubemaps.get( texture ).texture; + return mapTextureMapping( cubemap, texture.mapping ); + + } else { + + const image = texture.image; + + if ( image && image.height > 0 ) { + + const renderTarget = new WebGLCubeRenderTarget( image.height / 2 ); + renderTarget.fromEquirectangularTexture( renderer, texture ); + cubemaps.set( texture, renderTarget ); + + texture.addEventListener( 'dispose', onTextureDispose ); + + return mapTextureMapping( renderTarget.texture, texture.mapping ); + + } else { + + // image not yet ready. try the conversion next frame + + return null; + + } + + } + + } + + } + + return texture; + + } + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + const cubemap = cubemaps.get( texture ); + + if ( cubemap !== undefined ) { + + cubemaps.delete( texture ); + cubemap.dispose(); + + } + + } + + function dispose() { + + cubemaps = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +class OrthographicCamera extends Camera { + + constructor( left = - 1, right = 1, top = 1, bottom = - 1, near = 0.1, far = 2000 ) { + + super(); + + this.type = 'OrthographicCamera'; + + this.zoom = 1; + this.view = null; + + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + + this.near = near; + this.far = far; + + this.updateProjectionMatrix(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.left = source.left; + this.right = source.right; + this.top = source.top; + this.bottom = source.bottom; + this.near = source.near; + this.far = source.far; + + this.zoom = source.zoom; + this.view = source.view === null ? null : Object.assign( {}, source.view ); + + return this; + + } + + setViewOffset( fullWidth, fullHeight, x, y, width, height ) { + + if ( this.view === null ) { + + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }; + + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + + } + + clearViewOffset() { + + if ( this.view !== null ) { + + this.view.enabled = false; + + } + + this.updateProjectionMatrix(); + + } + + updateProjectionMatrix() { + + const dx = ( this.right - this.left ) / ( 2 * this.zoom ); + const dy = ( this.top - this.bottom ) / ( 2 * this.zoom ); + const cx = ( this.right + this.left ) / 2; + const cy = ( this.top + this.bottom ) / 2; + + let left = cx - dx; + let right = cx + dx; + let top = cy + dy; + let bottom = cy - dy; + + if ( this.view !== null && this.view.enabled ) { + + const scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom; + const scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom; + + left += scaleW * this.view.offsetX; + right = left + scaleW * this.view.width; + top -= scaleH * this.view.offsetY; + bottom = top - scaleH * this.view.height; + + } + + this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far ); + + this.projectionMatrixInverse.copy( this.projectionMatrix ).invert(); + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.zoom = this.zoom; + data.object.left = this.left; + data.object.right = this.right; + data.object.top = this.top; + data.object.bottom = this.bottom; + data.object.near = this.near; + data.object.far = this.far; + + if ( this.view !== null ) data.object.view = Object.assign( {}, this.view ); + + return data; + + } + +} + +OrthographicCamera.prototype.isOrthographicCamera = true; + +class RawShaderMaterial extends ShaderMaterial { + + constructor( parameters ) { + + super( parameters ); + + this.type = 'RawShaderMaterial'; + + } + +} + +RawShaderMaterial.prototype.isRawShaderMaterial = true; + +const LOD_MIN = 4; +const LOD_MAX = 8; +const SIZE_MAX = Math.pow( 2, LOD_MAX ); + +// The standard deviations (radians) associated with the extra mips. These are +// chosen to approximate a Trowbridge-Reitz distribution function times the +// geometric shadowing function. These sigma values squared must match the +// variance #defines in cube_uv_reflection_fragment.glsl.js. +const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ]; + +const TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; + +// The maximum length of the blur for loop. Smaller sigmas will use fewer +// samples and exit early, but not recompile the shader. +const MAX_SAMPLES = 20; + +const _flatCamera = /*@__PURE__*/ new OrthographicCamera(); +const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes(); +const _clearColor = /*@__PURE__*/ new Color$1(); +let _oldTarget = null; + +// Golden Ratio +const PHI = ( 1 + Math.sqrt( 5 ) ) / 2; +const INV_PHI = 1 / PHI; + +// Vertices of a dodecahedron (except the opposites, which represent the +// same axis), used as axis directions evenly spread on a sphere. +const _axisDirections = [ + /*@__PURE__*/ new Vector3( 1, 1, 1 ), + /*@__PURE__*/ new Vector3( - 1, 1, 1 ), + /*@__PURE__*/ new Vector3( 1, 1, - 1 ), + /*@__PURE__*/ new Vector3( - 1, 1, - 1 ), + /*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ), + /*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ), + /*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ), + /*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ), + /*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ), + /*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ) ]; + +/** + * This class generates a Prefiltered, Mipmapped Radiance Environment Map + * (PMREM) from a cubeMap environment texture. This allows different levels of + * blur to be quickly accessed based on material roughness. It is packed into a + * special CubeUV format that allows us to perform custom interpolation so that + * we can support nonlinear formats such as RGBE. Unlike a traditional mipmap + * chain, it only goes down to the LOD_MIN level (above), and then creates extra + * even more filtered 'mips' at the same LOD_MIN resolution, associated with + * higher roughness levels. In this way we maintain resolution to smoothly + * interpolate diffuse lighting while limiting sampling computation. + * + * Paper: Fast, Accurate Image-Based Lighting + * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view +*/ + +class PMREMGenerator { + + constructor( renderer ) { + + this._renderer = renderer; + this._pingPongRenderTarget = null; + + this._blurMaterial = _getBlurShader( MAX_SAMPLES ); + this._equirectShader = null; + this._cubemapShader = null; + + this._compileMaterial( this._blurMaterial ); + + } + + /** + * Generates a PMREM from a supplied Scene, which can be faster than using an + * image if networking bandwidth is low. Optional sigma specifies a blur radius + * in radians to be applied to the scene before PMREM generation. Optional near + * and far planes ensure the scene is rendered in its entirety (the cubeCamera + * is placed at the origin). + */ + fromScene( scene, sigma = 0, near = 0.1, far = 100 ) { + + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = this._allocateTargets(); + + this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); + if ( sigma > 0 ) { + + this._blur( cubeUVRenderTarget, 0, 0, sigma ); + + } + + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); + + return cubeUVRenderTarget; + + } + + /** + * Generates a PMREM from an equirectangular texture, which can be either LDR + * or HDR. The ideal input image size is 1k (1024 x 512), + * as this matches best with the 256 x 256 cubemap output. + */ + fromEquirectangular( equirectangular, renderTarget = null ) { + + return this._fromTexture( equirectangular, renderTarget ); + + } + + /** + * Generates a PMREM from an cubemap texture, which can be either LDR + * or HDR. The ideal input cube size is 256 x 256, + * as this matches best with the 256 x 256 cubemap output. + */ + fromCubemap( cubemap, renderTarget = null ) { + + return this._fromTexture( cubemap, renderTarget ); + + } + + /** + * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileCubemapShader() { + + if ( this._cubemapShader === null ) { + + this._cubemapShader = _getCubemapShader(); + this._compileMaterial( this._cubemapShader ); + + } + + } + + /** + * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileEquirectangularShader() { + + if ( this._equirectShader === null ) { + + this._equirectShader = _getEquirectShader(); + this._compileMaterial( this._equirectShader ); + + } + + } + + /** + * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, + * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on + * one of them will cause any others to also become unusable. + */ + dispose() { + + this._blurMaterial.dispose(); + + if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose(); + + if ( this._cubemapShader !== null ) this._cubemapShader.dispose(); + if ( this._equirectShader !== null ) this._equirectShader.dispose(); + + for ( let i = 0; i < _lodPlanes.length; i ++ ) { + + _lodPlanes[ i ].dispose(); + + } + + } + + // private interface + + _cleanup( outputTarget ) { + + this._renderer.setRenderTarget( _oldTarget ); + outputTarget.scissorTest = false; + _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height ); + + } + + _fromTexture( texture, renderTarget ) { + + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = renderTarget || this._allocateTargets( texture ); + this._textureToCubeUV( texture, cubeUVRenderTarget ); + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); + + return cubeUVRenderTarget; + + } + + _allocateTargets( texture ) { // warning: null texture is valid + + const params = { + magFilter: LinearFilter, + minFilter: LinearFilter, + generateMipmaps: false, + type: HalfFloatType, + format: RGBAFormat, + encoding: LinearEncoding, + depthBuffer: false + }; + + const cubeUVRenderTarget = _createRenderTarget( params ); + cubeUVRenderTarget.depthBuffer = texture ? false : true; + + if ( this._pingPongRenderTarget === null ) { + + this._pingPongRenderTarget = _createRenderTarget( params ); + + } + + return cubeUVRenderTarget; + + } + + _compileMaterial( material ) { + + const tmpMesh = new Mesh( _lodPlanes[ 0 ], material ); + this._renderer.compile( tmpMesh, _flatCamera ); + + } + + _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ) { + + const fov = 90; + const aspect = 1; + const cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); + const upSign = [ 1, - 1, 1, 1, 1, 1 ]; + const forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ]; + const renderer = this._renderer; + + const originalAutoClear = renderer.autoClear; + const toneMapping = renderer.toneMapping; + renderer.getClearColor( _clearColor ); + + renderer.toneMapping = NoToneMapping; + renderer.autoClear = false; + + const backgroundMaterial = new MeshBasicMaterial( { + name: 'PMREM.Background', + side: BackSide, + depthWrite: false, + depthTest: false, + } ); + + const backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial ); + + let useSolidColor = false; + const background = scene.background; + + if ( background ) { + + if ( background.isColor ) { + + backgroundMaterial.color.copy( background ); + scene.background = null; + useSolidColor = true; + + } + + } else { + + backgroundMaterial.color.copy( _clearColor ); + useSolidColor = true; + + } + + for ( let i = 0; i < 6; i ++ ) { + + const col = i % 3; + if ( col === 0 ) { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + + } else if ( col === 1 ) { + + cubeCamera.up.set( 0, 0, upSign[ i ] ); + cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + + } else { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + + } + + _setViewport( cubeUVRenderTarget, + col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); + renderer.setRenderTarget( cubeUVRenderTarget ); + + if ( useSolidColor ) { + + renderer.render( backgroundBox, cubeCamera ); + + } + + renderer.render( scene, cubeCamera ); + + } + + backgroundBox.geometry.dispose(); + backgroundBox.material.dispose(); + + renderer.toneMapping = toneMapping; + renderer.autoClear = originalAutoClear; + scene.background = background; + + } + + _textureToCubeUV( texture, cubeUVRenderTarget ) { + + const renderer = this._renderer; + + const isCubeTexture = ( texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping ); + + if ( isCubeTexture ) { + + if ( this._cubemapShader === null ) { + + this._cubemapShader = _getCubemapShader(); + + } + + this._cubemapShader.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? - 1 : 1; + + } else { + + if ( this._equirectShader === null ) { + + this._equirectShader = _getEquirectShader(); + + } + + } + + const material = isCubeTexture ? this._cubemapShader : this._equirectShader; + const mesh = new Mesh( _lodPlanes[ 0 ], material ); + + const uniforms = material.uniforms; + + uniforms[ 'envMap' ].value = texture; + + if ( ! isCubeTexture ) { + + uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); + + } + + _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); + + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( mesh, _flatCamera ); + + } + + _applyPMREM( cubeUVRenderTarget ) { + + const renderer = this._renderer; + const autoClear = renderer.autoClear; + renderer.autoClear = false; + + for ( let i = 1; i < TOTAL_LODS; i ++ ) { + + const sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); + + const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ]; + + this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); + + } + + renderer.autoClear = autoClear; + + } + + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { + + const pingPongRenderTarget = this._pingPongRenderTarget; + + this._halfBlur( + cubeUVRenderTarget, + pingPongRenderTarget, + lodIn, + lodOut, + sigma, + 'latitudinal', + poleAxis ); + + this._halfBlur( + pingPongRenderTarget, + cubeUVRenderTarget, + lodOut, + lodOut, + sigma, + 'longitudinal', + poleAxis ); + + } + + _halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { + + const renderer = this._renderer; + const blurMaterial = this._blurMaterial; + + if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { + + console.error( + 'blur direction must be either latitudinal or longitudinal!' ); + + } + + // Number of standard deviations at which to cut off the discrete approximation. + const STANDARD_DEVIATIONS = 3; + + const blurMesh = new Mesh( _lodPlanes[ lodOut ], blurMaterial ); + const blurUniforms = blurMaterial.uniforms; + + const pixels = _sizeLods[ lodIn ] - 1; + const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); + const sigmaPixels = sigmaRadians / radiansPerPixel; + const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; + + if ( samples > MAX_SAMPLES ) { + + console.warn( `sigmaRadians, ${ + sigmaRadians}, is too large and will clip, as it requested ${ + samples} samples when the maximum is set to ${MAX_SAMPLES}` ); + + } + + const weights = []; + let sum = 0; + + for ( let i = 0; i < MAX_SAMPLES; ++ i ) { + + const x = i / sigmaPixels; + const weight = Math.exp( - x * x / 2 ); + weights.push( weight ); + + if ( i === 0 ) { + + sum += weight; + + } else if ( i < samples ) { + + sum += 2 * weight; + + } + + } + + for ( let i = 0; i < weights.length; i ++ ) { + + weights[ i ] = weights[ i ] / sum; + + } + + blurUniforms[ 'envMap' ].value = targetIn.texture; + blurUniforms[ 'samples' ].value = samples; + blurUniforms[ 'weights' ].value = weights; + blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; + + if ( poleAxis ) { + + blurUniforms[ 'poleAxis' ].value = poleAxis; + + } + + blurUniforms[ 'dTheta' ].value = radiansPerPixel; + blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; + + const outputSize = _sizeLods[ lodOut ]; + const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); + const y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); + + _setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize ); + renderer.setRenderTarget( targetOut ); + renderer.render( blurMesh, _flatCamera ); + + } + +} + +function _createPlanes() { + + const _lodPlanes = []; + const _sizeLods = []; + const _sigmas = []; + + let lod = LOD_MAX; + + for ( let i = 0; i < TOTAL_LODS; i ++ ) { + + const sizeLod = Math.pow( 2, lod ); + _sizeLods.push( sizeLod ); + let sigma = 1.0 / sizeLod; + + if ( i > LOD_MAX - LOD_MIN ) { + + sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; + + } else if ( i === 0 ) { + + sigma = 0; + + } + + _sigmas.push( sigma ); + + const texelSize = 1.0 / ( sizeLod - 1 ); + const min = - texelSize / 2; + const max = 1 + texelSize / 2; + const uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; + + const cubeFaces = 6; + const vertices = 6; + const positionSize = 3; + const uvSize = 2; + const faceIndexSize = 1; + + const position = new Float32Array( positionSize * vertices * cubeFaces ); + const uv = new Float32Array( uvSize * vertices * cubeFaces ); + const faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); + + for ( let face = 0; face < cubeFaces; face ++ ) { + + const x = ( face % 3 ) * 2 / 3 - 1; + const y = face > 2 ? 0 : - 1; + const coordinates = [ + x, y, 0, + x + 2 / 3, y, 0, + x + 2 / 3, y + 1, 0, + x, y, 0, + x + 2 / 3, y + 1, 0, + x, y + 1, 0 + ]; + position.set( coordinates, positionSize * vertices * face ); + uv.set( uv1, uvSize * vertices * face ); + const fill = [ face, face, face, face, face, face ]; + faceIndex.set( fill, faceIndexSize * vertices * face ); + + } + + const planes = new BufferGeometry(); + planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); + planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); + planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); + _lodPlanes.push( planes ); + + if ( lod > LOD_MIN ) { + + lod --; + + } + + } + + return { _lodPlanes, _sizeLods, _sigmas }; + +} + +function _createRenderTarget( params ) { + + const cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); + cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; + cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; + cubeUVRenderTarget.scissorTest = true; + return cubeUVRenderTarget; + +} + +function _setViewport( target, x, y, width, height ) { + + target.viewport.set( x, y, width, height ); + target.scissor.set( x, y, width, height ); + +} + +function _getBlurShader( maxSamples ) { + + const weights = new Float32Array( maxSamples ); + const poleAxis = new Vector3( 0, 1, 0 ); + const shaderMaterial = new RawShaderMaterial( { + + name: 'SphericalGaussianBlur', + + defines: { 'n': maxSamples }, + + uniforms: { + 'envMap': { value: null }, + 'samples': { value: 1 }, + 'weights': { value: weights }, + 'latitudinal': { value: false }, + 'dTheta': { value: 0 }, + 'mipInt': { value: 0 }, + 'poleAxis': { value: poleAxis } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getEquirectShader() { + + const texelSize = new Vector2( 1, 1 ); + const shaderMaterial = new RawShaderMaterial( { + + name: 'EquirectangularToCubeUV', + + uniforms: { + 'envMap': { value: null }, + 'texelSize': { value: texelSize } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform vec2 texelSize; + + #include + + void main() { + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + vec2 f = fract( uv / texelSize - 0.5 ); + uv -= f * texelSize; + vec3 tl = texture2D ( envMap, uv ).rgb; + uv.x += texelSize.x; + vec3 tr = texture2D ( envMap, uv ).rgb; + uv.y += texelSize.y; + vec3 br = texture2D ( envMap, uv ).rgb; + uv.x -= texelSize.x; + vec3 bl = texture2D ( envMap, uv ).rgb; + + vec3 tm = mix( tl, tr, f.x ); + vec3 bm = mix( bl, br, f.x ); + gl_FragColor.rgb = mix( tm, bm, f.y ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getCubemapShader() { + + const shaderMaterial = new RawShaderMaterial( { + + name: 'CubemapToCubeUV', + + uniforms: { + 'envMap': { value: null }, + 'flipEnvMap': { value: - 1 } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getCommonVertexShader() { + + return /* glsl */` + + precision mediump float; + precision mediump int; + + attribute vec3 position; + attribute vec2 uv; + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `; + +} + +function WebGLCubeUVMaps( renderer ) { + + let cubeUVmaps = new WeakMap(); + + let pmremGenerator = null; + + function get( texture ) { + + if ( texture && texture.isTexture ) { + + const mapping = texture.mapping; + + const isEquirectMap = ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ); + const isCubeMap = ( mapping === CubeReflectionMapping || mapping === CubeRefractionMapping ); + + // equirect/cube map to cubeUV conversion + + if ( isEquirectMap || isCubeMap ) { + + if ( texture.isRenderTargetTexture && texture.needsPMREMUpdate === true ) { + + texture.needsPMREMUpdate = false; + + let renderTarget = cubeUVmaps.get( texture ); + + if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer ); + + renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget ); + cubeUVmaps.set( texture, renderTarget ); + + return renderTarget.texture; + + } else { + + if ( cubeUVmaps.has( texture ) ) { + + return cubeUVmaps.get( texture ).texture; + + } else { + + const image = texture.image; + + if ( ( isEquirectMap && image && image.height > 0 ) || ( isCubeMap && image && isCubeTextureComplete( image ) ) ) { + + if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer ); + + const renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture ); + cubeUVmaps.set( texture, renderTarget ); + + texture.addEventListener( 'dispose', onTextureDispose ); + + return renderTarget.texture; + + } else { + + // image not yet ready. try the conversion next frame + + return null; + + } + + } + + } + + } + + } + + return texture; + + } + + function isCubeTextureComplete( image ) { + + let count = 0; + const length = 6; + + for ( let i = 0; i < length; i ++ ) { + + if ( image[ i ] !== undefined ) count ++; + + } + + return count === length; + + + } + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + const cubemapUV = cubeUVmaps.get( texture ); + + if ( cubemapUV !== undefined ) { + + cubeUVmaps.delete( texture ); + cubemapUV.dispose(); + + } + + } + + function dispose() { + + cubeUVmaps = new WeakMap(); + + if ( pmremGenerator !== null ) { + + pmremGenerator.dispose(); + pmremGenerator = null; + + } + + } + + return { + get: get, + dispose: dispose + }; + +} + +function WebGLExtensions( gl ) { + + const extensions = {}; + + function getExtension( name ) { + + if ( extensions[ name ] !== undefined ) { + + return extensions[ name ]; + + } + + let extension; + + switch ( name ) { + + case 'WEBGL_depth_texture': + extension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' ); + break; + + case 'EXT_texture_filter_anisotropic': + extension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' ); + break; + + case 'WEBGL_compressed_texture_s3tc': + extension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' ); + break; + + case 'WEBGL_compressed_texture_pvrtc': + extension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' ); + break; + + default: + extension = gl.getExtension( name ); + + } + + extensions[ name ] = extension; + + return extension; + + } + + return { + + has: function ( name ) { + + return getExtension( name ) !== null; + + }, + + init: function ( capabilities ) { + + if ( capabilities.isWebGL2 ) { + + getExtension( 'EXT_color_buffer_float' ); + + } else { + + getExtension( 'WEBGL_depth_texture' ); + getExtension( 'OES_texture_float' ); + getExtension( 'OES_texture_half_float' ); + getExtension( 'OES_texture_half_float_linear' ); + getExtension( 'OES_standard_derivatives' ); + getExtension( 'OES_element_index_uint' ); + getExtension( 'OES_vertex_array_object' ); + getExtension( 'ANGLE_instanced_arrays' ); + + } + + getExtension( 'OES_texture_float_linear' ); + getExtension( 'EXT_color_buffer_half_float' ); + getExtension( 'WEBGL_multisampled_render_to_texture' ); + + }, + + get: function ( name ) { + + const extension = getExtension( name ); + + if ( extension === null ) { + + console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' ); + + } + + return extension; + + } + + }; + +} + +function WebGLGeometries( gl, attributes, info, bindingStates ) { + + const geometries = {}; + const wireframeAttributes = new WeakMap(); + + function onGeometryDispose( event ) { + + const geometry = event.target; + + if ( geometry.index !== null ) { + + attributes.remove( geometry.index ); + + } + + for ( const name in geometry.attributes ) { + + attributes.remove( geometry.attributes[ name ] ); + + } + + geometry.removeEventListener( 'dispose', onGeometryDispose ); + + delete geometries[ geometry.id ]; + + const attribute = wireframeAttributes.get( geometry ); + + if ( attribute ) { + + attributes.remove( attribute ); + wireframeAttributes.delete( geometry ); + + } + + bindingStates.releaseStatesOfGeometry( geometry ); + + if ( geometry.isInstancedBufferGeometry === true ) { + + delete geometry._maxInstanceCount; + + } + + // + + info.memory.geometries --; + + } + + function get( object, geometry ) { + + if ( geometries[ geometry.id ] === true ) return geometry; + + geometry.addEventListener( 'dispose', onGeometryDispose ); + + geometries[ geometry.id ] = true; + + info.memory.geometries ++; + + return geometry; + + } + + function update( geometry ) { + + const geometryAttributes = geometry.attributes; + + // Updating index buffer in VAO now. See WebGLBindingStates. + + for ( const name in geometryAttributes ) { + + attributes.update( geometryAttributes[ name ], 34962 ); + + } + + // morph targets + + const morphAttributes = geometry.morphAttributes; + + for ( const name in morphAttributes ) { + + const array = morphAttributes[ name ]; + + for ( let i = 0, l = array.length; i < l; i ++ ) { + + attributes.update( array[ i ], 34962 ); + + } + + } + + } + + function updateWireframeAttribute( geometry ) { + + const indices = []; + + const geometryIndex = geometry.index; + const geometryPosition = geometry.attributes.position; + let version = 0; + + if ( geometryIndex !== null ) { + + const array = geometryIndex.array; + version = geometryIndex.version; + + for ( let i = 0, l = array.length; i < l; i += 3 ) { + + const a = array[ i + 0 ]; + const b = array[ i + 1 ]; + const c = array[ i + 2 ]; + + indices.push( a, b, b, c, c, a ); + + } + + } else { + + const array = geometryPosition.array; + version = geometryPosition.version; + + for ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) { + + const a = i + 0; + const b = i + 1; + const c = i + 2; + + indices.push( a, b, b, c, c, a ); + + } + + } + + const attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ); + attribute.version = version; + + // Updating index buffer in VAO now. See WebGLBindingStates + + // + + const previousAttribute = wireframeAttributes.get( geometry ); + + if ( previousAttribute ) attributes.remove( previousAttribute ); + + // + + wireframeAttributes.set( geometry, attribute ); + + } + + function getWireframeAttribute( geometry ) { + + const currentAttribute = wireframeAttributes.get( geometry ); + + if ( currentAttribute ) { + + const geometryIndex = geometry.index; + + if ( geometryIndex !== null ) { + + // if the attribute is obsolete, create a new one + + if ( currentAttribute.version < geometryIndex.version ) { + + updateWireframeAttribute( geometry ); + + } + + } + + } else { + + updateWireframeAttribute( geometry ); + + } + + return wireframeAttributes.get( geometry ); + + } + + return { + + get: get, + update: update, + + getWireframeAttribute: getWireframeAttribute + + }; + +} + +function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode( value ) { + + mode = value; + + } + + let type, bytesPerElement; + + function setIndex( value ) { + + type = value.type; + bytesPerElement = value.bytesPerElement; + + } + + function render( start, count ) { + + gl.drawElements( mode, count, type, start * bytesPerElement ); + + info.update( count, mode, 1 ); + + } + + function renderInstances( start, count, primcount ) { + + if ( primcount === 0 ) return; + + let extension, methodName; + + if ( isWebGL2 ) { + + extension = gl; + methodName = 'drawElementsInstanced'; + + } else { + + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawElementsInstancedANGLE'; + + if ( extension === null ) { + + console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); + return; + + } + + } + + extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount ); + + info.update( count, mode, primcount ); + + } + + // + + this.setMode = setMode; + this.setIndex = setIndex; + this.render = render; + this.renderInstances = renderInstances; + +} + +function WebGLInfo( gl ) { + + const memory = { + geometries: 0, + textures: 0 + }; + + const render = { + frame: 0, + calls: 0, + triangles: 0, + points: 0, + lines: 0 + }; + + function update( count, mode, instanceCount ) { + + render.calls ++; + + switch ( mode ) { + + case 4: + render.triangles += instanceCount * ( count / 3 ); + break; + + case 1: + render.lines += instanceCount * ( count / 2 ); + break; + + case 3: + render.lines += instanceCount * ( count - 1 ); + break; + + case 2: + render.lines += instanceCount * count; + break; + + case 0: + render.points += instanceCount * count; + break; + + default: + console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode ); + break; + + } + + } + + function reset() { + + render.frame ++; + render.calls = 0; + render.triangles = 0; + render.points = 0; + render.lines = 0; + + } + + return { + memory: memory, + render: render, + programs: null, + autoReset: true, + reset: reset, + update: update + }; + +} + +class DataTexture2DArray extends Texture { + + constructor( data = null, width = 1, height = 1, depth = 1 ) { + + super( null ); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture2DArray.prototype.isDataTexture2DArray = true; + +function numericalSort( a, b ) { + + return a[ 0 ] - b[ 0 ]; + +} + +function absNumericalSort( a, b ) { + + return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] ); + +} + +function denormalize( morph, attribute ) { + + let denominator = 1; + const array = attribute.isInterleavedBufferAttribute ? attribute.data.array : attribute.array; + + if ( array instanceof Int8Array ) denominator = 127; + else if ( array instanceof Int16Array ) denominator = 32767; + else if ( array instanceof Int32Array ) denominator = 2147483647; + else console.error( 'THREE.WebGLMorphtargets: Unsupported morph attribute data type: ', array ); + + morph.divideScalar( denominator ); + +} + +function WebGLMorphtargets( gl, capabilities, textures ) { + + const influencesList = {}; + const morphInfluences = new Float32Array( 8 ); + const morphTextures = new WeakMap(); + const morph = new Vector3(); + + const workInfluences = []; + + for ( let i = 0; i < 8; i ++ ) { + + workInfluences[ i ] = [ i, 0 ]; + + } + + function update( object, geometry, material, program ) { + + const objectInfluences = object.morphTargetInfluences; + + if ( capabilities.isWebGL2 === true ) { + + // instead of using attributes, the WebGL 2 code path encodes morph targets + // into an array of data textures. Each layer represents a single morph target. + + const numberOfMorphTargets = geometry.morphAttributes.position.length; + + let entry = morphTextures.get( geometry ); + + if ( entry === undefined || entry.count !== numberOfMorphTargets ) { + + if ( entry !== undefined ) entry.texture.dispose(); + + const hasMorphNormals = geometry.morphAttributes.normal !== undefined; + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal || []; + + const numberOfVertices = geometry.attributes.position.count; + const numberOfVertexData = ( hasMorphNormals === true ) ? 2 : 1; // (v,n) vs. (v) + + let width = numberOfVertices * numberOfVertexData; + let height = 1; + + if ( width > capabilities.maxTextureSize ) { + + height = Math.ceil( width / capabilities.maxTextureSize ); + width = capabilities.maxTextureSize; + + } + + const buffer = new Float32Array( width * height * 4 * numberOfMorphTargets ); + + const texture = new DataTexture2DArray( buffer, width, height, numberOfMorphTargets ); + texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower) + texture.type = FloatType; + texture.needsUpdate = true; + + // fill buffer + + const vertexDataStride = numberOfVertexData * 4; + + for ( let i = 0; i < numberOfMorphTargets; i ++ ) { + + const morphTarget = morphTargets[ i ]; + const morphNormal = morphNormals[ i ]; + + const offset = width * height * 4 * i; + + for ( let j = 0; j < morphTarget.count; j ++ ) { + + morph.fromBufferAttribute( morphTarget, j ); + + if ( morphTarget.normalized === true ) denormalize( morph, morphTarget ); + + const stride = j * vertexDataStride; + + buffer[ offset + stride + 0 ] = morph.x; + buffer[ offset + stride + 1 ] = morph.y; + buffer[ offset + stride + 2 ] = morph.z; + buffer[ offset + stride + 3 ] = 0; + + if ( hasMorphNormals === true ) { + + morph.fromBufferAttribute( morphNormal, j ); + + if ( morphNormal.normalized === true ) denormalize( morph, morphNormal ); + + buffer[ offset + stride + 4 ] = morph.x; + buffer[ offset + stride + 5 ] = morph.y; + buffer[ offset + stride + 6 ] = morph.z; + buffer[ offset + stride + 7 ] = 0; + + } + + } + + } + + entry = { + count: numberOfMorphTargets, + texture: texture, + size: new Vector2( width, height ) + }; + + morphTextures.set( geometry, entry ); + + function disposeTexture() { + + texture.dispose(); + + morphTextures.delete( geometry ); + + geometry.removeEventListener( 'dispose', disposeTexture ); + + } + + geometry.addEventListener( 'dispose', disposeTexture ); + + } + + // + + let morphInfluencesSum = 0; + + for ( let i = 0; i < objectInfluences.length; i ++ ) { + + morphInfluencesSum += objectInfluences[ i ]; + + } + + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence ); + program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences ); + + program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures ); + program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size ); + + + } else { + + // When object doesn't have morph target influences defined, we treat it as a 0-length array + // This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences + + const length = objectInfluences === undefined ? 0 : objectInfluences.length; + + let influences = influencesList[ geometry.id ]; + + if ( influences === undefined || influences.length !== length ) { + + // initialise list + + influences = []; + + for ( let i = 0; i < length; i ++ ) { + + influences[ i ] = [ i, 0 ]; + + } + + influencesList[ geometry.id ] = influences; + + } + + // Collect influences + + for ( let i = 0; i < length; i ++ ) { + + const influence = influences[ i ]; + + influence[ 0 ] = i; + influence[ 1 ] = objectInfluences[ i ]; + + } + + influences.sort( absNumericalSort ); + + for ( let i = 0; i < 8; i ++ ) { + + if ( i < length && influences[ i ][ 1 ] ) { + + workInfluences[ i ][ 0 ] = influences[ i ][ 0 ]; + workInfluences[ i ][ 1 ] = influences[ i ][ 1 ]; + + } else { + + workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER; + workInfluences[ i ][ 1 ] = 0; + + } + + } + + workInfluences.sort( numericalSort ); + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal; + + let morphInfluencesSum = 0; + + for ( let i = 0; i < 8; i ++ ) { + + const influence = workInfluences[ i ]; + const index = influence[ 0 ]; + const value = influence[ 1 ]; + + if ( index !== Number.MAX_SAFE_INTEGER && value ) { + + if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) { + + geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] ); + + } + + if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) { + + geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] ); + + } + + morphInfluences[ i ] = value; + morphInfluencesSum += value; + + } else { + + if ( morphTargets && geometry.hasAttribute( 'morphTarget' + i ) === true ) { + + geometry.deleteAttribute( 'morphTarget' + i ); + + } + + if ( morphNormals && geometry.hasAttribute( 'morphNormal' + i ) === true ) { + + geometry.deleteAttribute( 'morphNormal' + i ); + + } + + morphInfluences[ i ] = 0; + + } + + } + + // GLSL shader uses formula baseinfluence * base + sum(target * influence) + // This allows us to switch between absolute morphs and relative morphs without changing shader code + // When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence) + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence ); + program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences ); + + } + + } + + return { + + update: update + + }; + +} + +function WebGLObjects( gl, geometries, attributes, info ) { + + let updateMap = new WeakMap(); + + function update( object ) { + + const frame = info.render.frame; + + const geometry = object.geometry; + const buffergeometry = geometries.get( object, geometry ); + + // Update once per frame + + if ( updateMap.get( buffergeometry ) !== frame ) { + + geometries.update( buffergeometry ); + + updateMap.set( buffergeometry, frame ); + + } + + if ( object.isInstancedMesh ) { + + if ( object.hasEventListener( 'dispose', onInstancedMeshDispose ) === false ) { + + object.addEventListener( 'dispose', onInstancedMeshDispose ); + + } + + attributes.update( object.instanceMatrix, 34962 ); + + if ( object.instanceColor !== null ) { + + attributes.update( object.instanceColor, 34962 ); + + } + + } + + return buffergeometry; + + } + + function dispose() { + + updateMap = new WeakMap(); + + } + + function onInstancedMeshDispose( event ) { + + const instancedMesh = event.target; + + instancedMesh.removeEventListener( 'dispose', onInstancedMeshDispose ); + + attributes.remove( instancedMesh.instanceMatrix ); + + if ( instancedMesh.instanceColor !== null ) attributes.remove( instancedMesh.instanceColor ); + + } + + return { + + update: update, + dispose: dispose + + }; + +} + +class DataTexture3D extends Texture { + + constructor( data = null, width = 1, height = 1, depth = 1 ) { + + // We're going to add .setXXX() methods for setting properties later. + // Users can still set in DataTexture3D directly. + // + // const texture = new THREE.DataTexture3D( data, width, height, depth ); + // texture.anisotropy = 16; + // + // See #14839 + + super( null ); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture3D.prototype.isDataTexture3D = true; + +/** + * Uniforms of a program. + * Those form a tree structure with a special top-level container for the root, + * which you get by calling 'new WebGLUniforms( gl, program )'. + * + * + * Properties of inner nodes including the top-level container: + * + * .seq - array of nested uniforms + * .map - nested uniforms by name + * + * + * Methods of all nodes except the top-level container: + * + * .setValue( gl, value, [textures] ) + * + * uploads a uniform value(s) + * the 'textures' parameter is needed for sampler uniforms + * + * + * Static methods of the top-level container (textures factorizations): + * + * .upload( gl, seq, values, textures ) + * + * sets uniforms in 'seq' to 'values[id].value' + * + * .seqWithValue( seq, values ) : filteredSeq + * + * filters 'seq' entries with corresponding entry in values + * + * + * Methods of the top-level container (textures factorizations): + * + * .setValue( gl, name, value, textures ) + * + * sets uniform with name 'name' to 'value' + * + * .setOptional( gl, obj, prop ) + * + * like .set for an optional property of the object + * + */ + +const emptyTexture = new Texture(); +const emptyTexture2dArray = new DataTexture2DArray(); +const emptyTexture3d = new DataTexture3D(); +const emptyCubeTexture = new CubeTexture(); + +// --- Utilities --- + +// Array Caches (provide typed arrays for temporary by size) + +const arrayCacheF32 = []; +const arrayCacheI32 = []; + +// Float32Array caches used for uploading Matrix uniforms + +const mat4array = new Float32Array( 16 ); +const mat3array = new Float32Array( 9 ); +const mat2array = new Float32Array( 4 ); + +// Flattening for arrays of vectors and matrices + +function flatten( array, nBlocks, blockSize ) { + + const firstElem = array[ 0 ]; + + if ( firstElem <= 0 || firstElem > 0 ) return array; + // unoptimized: ! isNaN( firstElem ) + // see http://jacksondunstan.com/articles/983 + + const n = nBlocks * blockSize; + let r = arrayCacheF32[ n ]; + + if ( r === undefined ) { + + r = new Float32Array( n ); + arrayCacheF32[ n ] = r; + + } + + if ( nBlocks !== 0 ) { + + firstElem.toArray( r, 0 ); + + for ( let i = 1, offset = 0; i !== nBlocks; ++ i ) { + + offset += blockSize; + array[ i ].toArray( r, offset ); + + } + + } + + return r; + +} + +function arraysEqual( a, b ) { + + if ( a.length !== b.length ) return false; + + for ( let i = 0, l = a.length; i < l; i ++ ) { + + if ( a[ i ] !== b[ i ] ) return false; + + } + + return true; + +} + +function copyArray( a, b ) { + + for ( let i = 0, l = b.length; i < l; i ++ ) { + + a[ i ] = b[ i ]; + + } + +} + +// Texture unit allocation + +function allocTexUnits( textures, n ) { + + let r = arrayCacheI32[ n ]; + + if ( r === undefined ) { + + r = new Int32Array( n ); + arrayCacheI32[ n ] = r; + + } + + for ( let i = 0; i !== n; ++ i ) { + + r[ i ] = textures.allocateTextureUnit(); + + } + + return r; + +} + +// --- Setters --- + +// Note: Defining these methods externally, because they come in a bunch +// and this way their names minify. + +// Single scalar + +function setValueV1f( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1f( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single float vector (from flat array or THREE.VectorN) + +function setValueV2f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) { + + gl.uniform2f( this.addr, v.x, v.y ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +function setValueV3f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) { + + gl.uniform3f( this.addr, v.x, v.y, v.z ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + cache[ 2 ] = v.z; + + } + + } else if ( v.r !== undefined ) { + + if ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) { + + gl.uniform3f( this.addr, v.r, v.g, v.b ); + + cache[ 0 ] = v.r; + cache[ 1 ] = v.g; + cache[ 2 ] = v.b; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +function setValueV4f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) { + + gl.uniform4f( this.addr, v.x, v.y, v.z, v.w ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + cache[ 2 ] = v.z; + cache[ 3 ] = v.w; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +// Single matrix (from flat array or THREE.MatrixN) + +function setValueM2( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix2fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat2array.set( elements ); + + gl.uniformMatrix2fv( this.addr, false, mat2array ); + + copyArray( cache, elements ); + + } + +} + +function setValueM3( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix3fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat3array.set( elements ); + + gl.uniformMatrix3fv( this.addr, false, mat3array ); + + copyArray( cache, elements ); + + } + +} + +function setValueM4( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix4fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat4array.set( elements ); + + gl.uniformMatrix4fv( this.addr, false, mat4array ); + + copyArray( cache, elements ); + + } + +} + +// Single integer / boolean + +function setValueV1i( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1i( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single integer / boolean vector (from flat array) + +function setValueV2i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2iv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV3i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3iv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV4i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4iv( this.addr, v ); + + copyArray( cache, v ); + +} + +// Single unsigned integer + +function setValueV1ui( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1ui( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single unsigned integer vector (from flat array) + +function setValueV2ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2uiv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV3ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3uiv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV4ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4uiv( this.addr, v ); + + copyArray( cache, v ); + +} + + +// Single texture (2D / Cube) + +function setValueT1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.safeSetTexture2D( v || emptyTexture, unit ); + +} + +function setValueT3D1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.setTexture3D( v || emptyTexture3d, unit ); + +} + +function setValueT6( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.safeSetTextureCube( v || emptyCubeTexture, unit ); + +} + +function setValueT2DArray1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.setTexture2DArray( v || emptyTexture2dArray, unit ); + +} + +// Helper to pick the right setter for the singular case + +function getSingularSetter( type ) { + + switch ( type ) { + + case 0x1406: return setValueV1f; // FLOAT + case 0x8b50: return setValueV2f; // _VEC2 + case 0x8b51: return setValueV3f; // _VEC3 + case 0x8b52: return setValueV4f; // _VEC4 + + case 0x8b5a: return setValueM2; // _MAT2 + case 0x8b5b: return setValueM3; // _MAT3 + case 0x8b5c: return setValueM4; // _MAT4 + + case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4 + + case 0x1405: return setValueV1ui; // UINT + case 0x8dc6: return setValueV2ui; // _VEC2 + case 0x8dc7: return setValueV3ui; // _VEC3 + case 0x8dc8: return setValueV4ui; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3D1; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArray1; + + } + +} + + +// Array of scalars + +function setValueV1fArray( gl, v ) { + + gl.uniform1fv( this.addr, v ); + +} + +// Array of vectors (from flat array or array of THREE.VectorN) + +function setValueV2fArray( gl, v ) { + + const data = flatten( v, this.size, 2 ); + + gl.uniform2fv( this.addr, data ); + +} + +function setValueV3fArray( gl, v ) { + + const data = flatten( v, this.size, 3 ); + + gl.uniform3fv( this.addr, data ); + +} + +function setValueV4fArray( gl, v ) { + + const data = flatten( v, this.size, 4 ); + + gl.uniform4fv( this.addr, data ); + +} + +// Array of matrices (from flat array or array of THREE.MatrixN) + +function setValueM2Array( gl, v ) { + + const data = flatten( v, this.size, 4 ); + + gl.uniformMatrix2fv( this.addr, false, data ); + +} + +function setValueM3Array( gl, v ) { + + const data = flatten( v, this.size, 9 ); + + gl.uniformMatrix3fv( this.addr, false, data ); + +} + +function setValueM4Array( gl, v ) { + + const data = flatten( v, this.size, 16 ); + + gl.uniformMatrix4fv( this.addr, false, data ); + +} + +// Array of integer / boolean + +function setValueV1iArray( gl, v ) { + + gl.uniform1iv( this.addr, v ); + +} + +// Array of integer / boolean vectors (from flat array) + +function setValueV2iArray( gl, v ) { + + gl.uniform2iv( this.addr, v ); + +} + +function setValueV3iArray( gl, v ) { + + gl.uniform3iv( this.addr, v ); + +} + +function setValueV4iArray( gl, v ) { + + gl.uniform4iv( this.addr, v ); + +} + +// Array of unsigned integer + +function setValueV1uiArray( gl, v ) { + + gl.uniform1uiv( this.addr, v ); + +} + +// Array of unsigned integer vectors (from flat array) + +function setValueV2uiArray( gl, v ) { + + gl.uniform2uiv( this.addr, v ); + +} + +function setValueV3uiArray( gl, v ) { + + gl.uniform3uiv( this.addr, v ); + +} + +function setValueV4uiArray( gl, v ) { + + gl.uniform4uiv( this.addr, v ); + +} + + +// Array of textures (2D / 3D / Cube / 2DArray) + +function setValueT1Array( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] ); + + } + +} + +function setValueT3DArray( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.setTexture3D( v[ i ] || emptyTexture3d, units[ i ] ); + + } + +} + +function setValueT6Array( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] ); + + } + +} + +function setValueT2DArrayArray( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.setTexture2DArray( v[ i ] || emptyTexture2dArray, units[ i ] ); + + } + +} + + +// Helper to pick the right setter for a pure (bottom-level) array + +function getPureArraySetter( type ) { + + switch ( type ) { + + case 0x1406: return setValueV1fArray; // FLOAT + case 0x8b50: return setValueV2fArray; // _VEC2 + case 0x8b51: return setValueV3fArray; // _VEC3 + case 0x8b52: return setValueV4fArray; // _VEC4 + + case 0x8b5a: return setValueM2Array; // _MAT2 + case 0x8b5b: return setValueM3Array; // _MAT3 + case 0x8b5c: return setValueM4Array; // _MAT4 + + case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 + + case 0x1405: return setValueV1uiArray; // UINT + case 0x8dc6: return setValueV2uiArray; // _VEC2 + case 0x8dc7: return setValueV3uiArray; // _VEC3 + case 0x8dc8: return setValueV4uiArray; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1Array; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3DArray; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6Array; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArrayArray; + + } + +} + +// --- Uniform Classes --- + +function SingleUniform( id, activeInfo, addr ) { + + this.id = id; + this.addr = addr; + this.cache = []; + this.setValue = getSingularSetter( activeInfo.type ); + + // this.path = activeInfo.name; // DEBUG + +} + +function PureArrayUniform( id, activeInfo, addr ) { + + this.id = id; + this.addr = addr; + this.cache = []; + this.size = activeInfo.size; + this.setValue = getPureArraySetter( activeInfo.type ); + + // this.path = activeInfo.name; // DEBUG + +} + +PureArrayUniform.prototype.updateCache = function ( data ) { + + const cache = this.cache; + + if ( data instanceof Float32Array && cache.length !== data.length ) { + + this.cache = new Float32Array( data.length ); + + } + + copyArray( cache, data ); + +}; + +function StructuredUniform( id ) { + + this.id = id; + + this.seq = []; + this.map = {}; + +} + +StructuredUniform.prototype.setValue = function ( gl, value, textures ) { + + const seq = this.seq; + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ]; + u.setValue( gl, value[ u.id ], textures ); + + } + +}; + +// --- Top-level --- + +// Parser - builds up the property tree from the path strings + +const RePathPart = /(\w+)(\])?(\[|\.)?/g; + +// extracts +// - the identifier (member name or array index) +// - followed by an optional right bracket (found when array index) +// - followed by an optional left bracket or dot (type of subscript) +// +// Note: These portions can be read in a non-overlapping fashion and +// allow straightforward parsing of the hierarchy that WebGL encodes +// in the uniform names. + +function addUniform( container, uniformObject ) { + + container.seq.push( uniformObject ); + container.map[ uniformObject.id ] = uniformObject; + +} + +function parseUniform( activeInfo, addr, container ) { + + const path = activeInfo.name, + pathLength = path.length; + + // reset RegExp object, because of the early exit of a previous run + RePathPart.lastIndex = 0; + + while ( true ) { + + const match = RePathPart.exec( path ), + matchEnd = RePathPart.lastIndex; + + let id = match[ 1 ]; + const idIsIndex = match[ 2 ] === ']', + subscript = match[ 3 ]; + + if ( idIsIndex ) id = id | 0; // convert to integer + + if ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) { + + // bare name or "pure" bottom-level array "[0]" suffix + + addUniform( container, subscript === undefined ? + new SingleUniform( id, activeInfo, addr ) : + new PureArrayUniform( id, activeInfo, addr ) ); + + break; + + } else { + + // step into inner node / create it in case it doesn't exist + + const map = container.map; + let next = map[ id ]; + + if ( next === undefined ) { + + next = new StructuredUniform( id ); + addUniform( container, next ); + + } + + container = next; + + } + + } + +} + +// Root Container + +function WebGLUniforms( gl, program ) { + + this.seq = []; + this.map = {}; + + const n = gl.getProgramParameter( program, 35718 ); + + for ( let i = 0; i < n; ++ i ) { + + const info = gl.getActiveUniform( program, i ), + addr = gl.getUniformLocation( program, info.name ); + + parseUniform( info, addr, this ); + + } + +} + +WebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) { + + const u = this.map[ name ]; + + if ( u !== undefined ) u.setValue( gl, value, textures ); + +}; + +WebGLUniforms.prototype.setOptional = function ( gl, object, name ) { + + const v = object[ name ]; + + if ( v !== undefined ) this.setValue( gl, name, v ); + +}; + + +// Static interface + +WebGLUniforms.upload = function ( gl, seq, values, textures ) { + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ], + v = values[ u.id ]; + + if ( v.needsUpdate !== false ) { + + // note: always updating when .needsUpdate is undefined + u.setValue( gl, v.value, textures ); + + } + + } + +}; + +WebGLUniforms.seqWithValue = function ( seq, values ) { + + const r = []; + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ]; + if ( u.id in values ) r.push( u ); + + } + + return r; + +}; + +function WebGLShader( gl, type, string ) { + + const shader = gl.createShader( type ); + + gl.shaderSource( shader, string ); + gl.compileShader( shader ); + + return shader; + +} + +let programIdCount = 0; + +function addLineNumbers( string ) { + + const lines = string.split( '\n' ); + + for ( let i = 0; i < lines.length; i ++ ) { + + lines[ i ] = ( i + 1 ) + ': ' + lines[ i ]; + + } + + return lines.join( '\n' ); + +} + +function getEncodingComponents( encoding ) { + + switch ( encoding ) { + + case LinearEncoding: + return [ 'Linear', '( value )' ]; + case sRGBEncoding: + return [ 'sRGB', '( value )' ]; + default: + console.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding ); + return [ 'Linear', '( value )' ]; + + } + +} + +function getShaderErrors( gl, shader, type ) { + + const status = gl.getShaderParameter( shader, 35713 ); + const errors = gl.getShaderInfoLog( shader ).trim(); + + if ( status && errors === '' ) return ''; + + // --enable-privileged-webgl-extension + // console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) ); + + return type.toUpperCase() + '\n\n' + errors + '\n\n' + addLineNumbers( gl.getShaderSource( shader ) ); + +} + +function getTexelEncodingFunction( functionName, encoding ) { + + const components = getEncodingComponents( encoding ); + return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }'; + +} + +function getToneMappingFunction( functionName, toneMapping ) { + + let toneMappingName; + + switch ( toneMapping ) { + + case LinearToneMapping: + toneMappingName = 'Linear'; + break; + + case ReinhardToneMapping: + toneMappingName = 'Reinhard'; + break; + + case CineonToneMapping: + toneMappingName = 'OptimizedCineon'; + break; + + case ACESFilmicToneMapping: + toneMappingName = 'ACESFilmic'; + break; + + case CustomToneMapping: + toneMappingName = 'Custom'; + break; + + default: + console.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping ); + toneMappingName = 'Linear'; + + } + + return 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }'; + +} + +function generateExtensions( parameters ) { + + const chunks = [ + ( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', + ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', + ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '', + ( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : '' + ]; + + return chunks.filter( filterEmptyLine ).join( '\n' ); + +} + +function generateDefines( defines ) { + + const chunks = []; + + for ( const name in defines ) { + + const value = defines[ name ]; + + if ( value === false ) continue; + + chunks.push( '#define ' + name + ' ' + value ); + + } + + return chunks.join( '\n' ); + +} + +function fetchAttributeLocations( gl, program ) { + + const attributes = {}; + + const n = gl.getProgramParameter( program, 35721 ); + + for ( let i = 0; i < n; i ++ ) { + + const info = gl.getActiveAttrib( program, i ); + const name = info.name; + + let locationSize = 1; + if ( info.type === 35674 ) locationSize = 2; + if ( info.type === 35675 ) locationSize = 3; + if ( info.type === 35676 ) locationSize = 4; + + // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i ); + + attributes[ name ] = { + type: info.type, + location: gl.getAttribLocation( program, name ), + locationSize: locationSize + }; + + } + + return attributes; + +} + +function filterEmptyLine( string ) { + + return string !== ''; + +} + +function replaceLightNums( string, parameters ) { + + return string + .replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights ) + .replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights ) + .replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights ) + .replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights ) + .replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights ) + .replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows ) + .replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows ) + .replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows ); + +} + +function replaceClippingPlaneNums( string, parameters ) { + + return string + .replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes ) + .replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) ); + +} + +// Resolve Includes + +const includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm; + +function resolveIncludes( string ) { + + return string.replace( includePattern, includeReplacer ); + +} + +function includeReplacer( match, include ) { + + const string = ShaderChunk[ include ]; + + if ( string === undefined ) { + + throw new Error( 'Can not resolve #include <' + include + '>' ); + + } + + return resolveIncludes( string ); + +} + +// Unroll Loops + +const deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; +const unrollLoopPattern = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; + +function unrollLoops( string ) { + + return string + .replace( unrollLoopPattern, loopReplacer ) + .replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer ); + +} + +function deprecatedLoopReplacer( match, start, end, snippet ) { + + console.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' ); + return loopReplacer( match, start, end, snippet ); + +} + +function loopReplacer( match, start, end, snippet ) { + + let string = ''; + + for ( let i = parseInt( start ); i < parseInt( end ); i ++ ) { + + string += snippet + .replace( /\[\s*i\s*\]/g, '[ ' + i + ' ]' ) + .replace( /UNROLLED_LOOP_INDEX/g, i ); + + } + + return string; + +} + +// + +function generatePrecision( parameters ) { + + let precisionstring = 'precision ' + parameters.precision + ' float;\nprecision ' + parameters.precision + ' int;'; + + if ( parameters.precision === 'highp' ) { + + precisionstring += '\n#define HIGH_PRECISION'; + + } else if ( parameters.precision === 'mediump' ) { + + precisionstring += '\n#define MEDIUM_PRECISION'; + + } else if ( parameters.precision === 'lowp' ) { + + precisionstring += '\n#define LOW_PRECISION'; + + } + + return precisionstring; + +} + +function generateShadowMapTypeDefine( parameters ) { + + let shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC'; + + if ( parameters.shadowMapType === PCFShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF'; + + } else if ( parameters.shadowMapType === PCFSoftShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT'; + + } else if ( parameters.shadowMapType === VSMShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM'; + + } + + return shadowMapTypeDefine; + +} + +function generateEnvMapTypeDefine( parameters ) { + + let envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + + if ( parameters.envMap ) { + + switch ( parameters.envMapMode ) { + + case CubeReflectionMapping: + case CubeRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + break; + + case CubeUVReflectionMapping: + case CubeUVRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV'; + break; + + } + + } + + return envMapTypeDefine; + +} + +function generateEnvMapModeDefine( parameters ) { + + let envMapModeDefine = 'ENVMAP_MODE_REFLECTION'; + + if ( parameters.envMap ) { + + switch ( parameters.envMapMode ) { + + case CubeRefractionMapping: + case CubeUVRefractionMapping: + + envMapModeDefine = 'ENVMAP_MODE_REFRACTION'; + break; + + } + + } + + return envMapModeDefine; + +} + +function generateEnvMapBlendingDefine( parameters ) { + + let envMapBlendingDefine = 'ENVMAP_BLENDING_NONE'; + + if ( parameters.envMap ) { + + switch ( parameters.combine ) { + + case MultiplyOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY'; + break; + + case MixOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MIX'; + break; + + case AddOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_ADD'; + break; + + } + + } + + return envMapBlendingDefine; + +} + +function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) { + + // TODO Send this event to Three.js DevTools + // console.log( 'WebGLProgram', cacheKey ); + + const gl = renderer.getContext(); + + const defines = parameters.defines; + + let vertexShader = parameters.vertexShader; + let fragmentShader = parameters.fragmentShader; + + const shadowMapTypeDefine = generateShadowMapTypeDefine( parameters ); + const envMapTypeDefine = generateEnvMapTypeDefine( parameters ); + const envMapModeDefine = generateEnvMapModeDefine( parameters ); + const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters ); + + const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters ); + + const customDefines = generateDefines( defines ); + + const program = gl.createProgram(); + + let prefixVertex, prefixFragment; + let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : ''; + + if ( parameters.isRawShaderMaterial ) { + + prefixVertex = [ + + customDefines + + ].filter( filterEmptyLine ).join( '\n' ); + + if ( prefixVertex.length > 0 ) { + + prefixVertex += '\n'; + + } + + prefixFragment = [ + + customExtensions, + customDefines + + ].filter( filterEmptyLine ).join( '\n' ); + + if ( prefixFragment.length > 0 ) { + + prefixFragment += '\n'; + + } + + } else { + + prefixVertex = [ + + generatePrecision( parameters ), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + parameters.instancing ? '#define USE_INSTANCING' : '', + parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', + + parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', + + '#define MAX_BONES ' + parameters.maxBones, + ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', + ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.skinning ? '#define USE_SKINNING' : '', + parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', + + parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', + parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', + ( parameters.morphTargets && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE' : '', + ( parameters.morphTargets && parameters.isWebGL2 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + + 'uniform mat4 modelMatrix;', + 'uniform mat4 modelViewMatrix;', + 'uniform mat4 projectionMatrix;', + 'uniform mat4 viewMatrix;', + 'uniform mat3 normalMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + '#ifdef USE_INSTANCING', + + ' attribute mat4 instanceMatrix;', + + '#endif', + + '#ifdef USE_INSTANCING_COLOR', + + ' attribute vec3 instanceColor;', + + '#endif', + + 'attribute vec3 position;', + 'attribute vec3 normal;', + 'attribute vec2 uv;', + + '#ifdef USE_TANGENT', + + ' attribute vec4 tangent;', + + '#endif', + + '#if defined( USE_COLOR_ALPHA )', + + ' attribute vec4 color;', + + '#elif defined( USE_COLOR )', + + ' attribute vec3 color;', + + '#endif', + + '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', + + ' attribute vec3 morphTarget0;', + ' attribute vec3 morphTarget1;', + ' attribute vec3 morphTarget2;', + ' attribute vec3 morphTarget3;', + + ' #ifdef USE_MORPHNORMALS', + + ' attribute vec3 morphNormal0;', + ' attribute vec3 morphNormal1;', + ' attribute vec3 morphNormal2;', + ' attribute vec3 morphNormal3;', + + ' #else', + + ' attribute vec3 morphTarget4;', + ' attribute vec3 morphTarget5;', + ' attribute vec3 morphTarget6;', + ' attribute vec3 morphTarget7;', + + ' #endif', + + '#endif', + + '#ifdef USE_SKINNING', + + ' attribute vec4 skinIndex;', + ' attribute vec4 skinWeight;', + + '#endif', + + '\n' + + ].filter( filterEmptyLine ).join( '\n' ); + + prefixFragment = [ + + customExtensions, + + generatePrecision( parameters ), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.matcap ? '#define USE_MATCAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapTypeDefine : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.envMap ? '#define ' + envMapBlendingDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', + ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoat ? '#define USE_CLEARCOAT' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + parameters.alphaTest ? '#define USE_ALPHATEST' : '', + + parameters.sheen ? '#define USE_SHEEN' : '', + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', + + parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + + ( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '', + + 'uniform mat4 viewMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + ( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '', + ( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below + ( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '', + + parameters.dithering ? '#define DITHERING' : '', + parameters.alphaWrite ? '' : '#define OPAQUE', + + ShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below + getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ), + + parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', + + '\n' + + ].filter( filterEmptyLine ).join( '\n' ); + + } + + vertexShader = resolveIncludes( vertexShader ); + vertexShader = replaceLightNums( vertexShader, parameters ); + vertexShader = replaceClippingPlaneNums( vertexShader, parameters ); + + fragmentShader = resolveIncludes( fragmentShader ); + fragmentShader = replaceLightNums( fragmentShader, parameters ); + fragmentShader = replaceClippingPlaneNums( fragmentShader, parameters ); + + vertexShader = unrollLoops( vertexShader ); + fragmentShader = unrollLoops( fragmentShader ); + + if ( parameters.isWebGL2 && parameters.isRawShaderMaterial !== true ) { + + // GLSL 3.0 conversion for built-in materials and ShaderMaterial + + versionString = '#version 300 es\n'; + + prefixVertex = [ + 'precision mediump sampler2DArray;', + '#define attribute in', + '#define varying out', + '#define texture2D texture' + ].join( '\n' ) + '\n' + prefixVertex; + + prefixFragment = [ + '#define varying in', + ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', + ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor', + '#define gl_FragDepthEXT gl_FragDepth', + '#define texture2D texture', + '#define textureCube texture', + '#define texture2DProj textureProj', + '#define texture2DLodEXT textureLod', + '#define texture2DProjLodEXT textureProjLod', + '#define textureCubeLodEXT textureLod', + '#define texture2DGradEXT textureGrad', + '#define texture2DProjGradEXT textureProjGrad', + '#define textureCubeGradEXT textureGrad' + ].join( '\n' ) + '\n' + prefixFragment; + + } + + const vertexGlsl = versionString + prefixVertex + vertexShader; + const fragmentGlsl = versionString + prefixFragment + fragmentShader; + + // console.log( '*VERTEX*', vertexGlsl ); + // console.log( '*FRAGMENT*', fragmentGlsl ); + + const glVertexShader = WebGLShader( gl, 35633, vertexGlsl ); + const glFragmentShader = WebGLShader( gl, 35632, fragmentGlsl ); + + gl.attachShader( program, glVertexShader ); + gl.attachShader( program, glFragmentShader ); + + // Force a particular attribute to index 0. + + if ( parameters.index0AttributeName !== undefined ) { + + gl.bindAttribLocation( program, 0, parameters.index0AttributeName ); + + } else if ( parameters.morphTargets === true ) { + + // programs with morphTargets displace position out of attribute 0 + gl.bindAttribLocation( program, 0, 'position' ); + + } + + gl.linkProgram( program ); + + // check for link errors + if ( renderer.debug.checkShaderErrors ) { + + const programLog = gl.getProgramInfoLog( program ).trim(); + const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim(); + const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim(); + + let runnable = true; + let haveDiagnostics = true; + + if ( gl.getProgramParameter( program, 35714 ) === false ) { + + runnable = false; + + const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' ); + const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' ); + + console.error( + 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' + + 'VALIDATE_STATUS ' + gl.getProgramParameter( program, 35715 ) + '\n\n' + + 'Program Info Log: ' + programLog + '\n' + + vertexErrors + '\n' + + fragmentErrors + ); + + } else if ( programLog !== '' ) { + + console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog ); + + } else if ( vertexLog === '' || fragmentLog === '' ) { + + haveDiagnostics = false; + + } + + if ( haveDiagnostics ) { + + this.diagnostics = { + + runnable: runnable, + + programLog: programLog, + + vertexShader: { + + log: vertexLog, + prefix: prefixVertex + + }, + + fragmentShader: { + + log: fragmentLog, + prefix: prefixFragment + + } + + }; + + } + + } + + // Clean up + + // Crashes in iOS9 and iOS10. #18402 + // gl.detachShader( program, glVertexShader ); + // gl.detachShader( program, glFragmentShader ); + + gl.deleteShader( glVertexShader ); + gl.deleteShader( glFragmentShader ); + + // set up caching for uniform locations + + let cachedUniforms; + + this.getUniforms = function () { + + if ( cachedUniforms === undefined ) { + + cachedUniforms = new WebGLUniforms( gl, program ); + + } + + return cachedUniforms; + + }; + + // set up caching for attribute locations + + let cachedAttributes; + + this.getAttributes = function () { + + if ( cachedAttributes === undefined ) { + + cachedAttributes = fetchAttributeLocations( gl, program ); + + } + + return cachedAttributes; + + }; + + // free resource + + this.destroy = function () { + + bindingStates.releaseStatesOfProgram( this ); + + gl.deleteProgram( program ); + this.program = undefined; + + }; + + // + + this.name = parameters.shaderName; + this.id = programIdCount ++; + this.cacheKey = cacheKey; + this.usedTimes = 1; + this.program = program; + this.vertexShader = glVertexShader; + this.fragmentShader = glFragmentShader; + + return this; + +} + +let _id = 0; + +class WebGLShaderCache { + + constructor() { + + this.shaderCache = new Map(); + this.materialCache = new Map(); + + } + + update( material ) { + + const vertexShader = material.vertexShader; + const fragmentShader = material.fragmentShader; + + const vertexShaderStage = this._getShaderStage( vertexShader ); + const fragmentShaderStage = this._getShaderStage( fragmentShader ); + + const materialShaders = this._getShaderCacheForMaterial( material ); + + if ( materialShaders.has( vertexShaderStage ) === false ) { + + materialShaders.add( vertexShaderStage ); + vertexShaderStage.usedTimes ++; + + } + + if ( materialShaders.has( fragmentShaderStage ) === false ) { + + materialShaders.add( fragmentShaderStage ); + fragmentShaderStage.usedTimes ++; + + } + + return this; + + } + + remove( material ) { + + const materialShaders = this.materialCache.get( material ); + + for ( const shaderStage of materialShaders ) { + + shaderStage.usedTimes --; + + if ( shaderStage.usedTimes === 0 ) this.shaderCache.delete( shaderStage ); + + } + + this.materialCache.delete( material ); + + return this; + + } + + getVertexShaderID( material ) { + + return this._getShaderStage( material.vertexShader ).id; + + } + + getFragmentShaderID( material ) { + + return this._getShaderStage( material.fragmentShader ).id; + + } + + dispose() { + + this.shaderCache.clear(); + this.materialCache.clear(); + + } + + _getShaderCacheForMaterial( material ) { + + const cache = this.materialCache; + + if ( cache.has( material ) === false ) { + + cache.set( material, new Set() ); + + } + + return cache.get( material ); + + } + + _getShaderStage( code ) { + + const cache = this.shaderCache; + + if ( cache.has( code ) === false ) { + + const stage = new WebGLShaderStage(); + cache.set( code, stage ); + + } + + return cache.get( code ); + + } + +} + +class WebGLShaderStage { + + constructor() { + + this.id = _id ++; + + this.usedTimes = 0; + + } + +} + +function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ) { + + const _programLayers = new Layers(); + const _customShaders = new WebGLShaderCache(); + const programs = []; + + const isWebGL2 = capabilities.isWebGL2; + const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer; + const floatVertexTextures = capabilities.floatVertexTextures; + const maxVertexUniforms = capabilities.maxVertexUniforms; + const vertexTextures = capabilities.vertexTextures; + let precision = capabilities.precision; + + const shaderIDs = { + MeshDepthMaterial: 'depth', + MeshDistanceMaterial: 'distanceRGBA', + MeshNormalMaterial: 'normal', + MeshBasicMaterial: 'basic', + MeshLambertMaterial: 'lambert', + MeshPhongMaterial: 'phong', + MeshToonMaterial: 'toon', + MeshStandardMaterial: 'physical', + MeshPhysicalMaterial: 'physical', + MeshMatcapMaterial: 'matcap', + LineBasicMaterial: 'basic', + LineDashedMaterial: 'dashed', + PointsMaterial: 'points', + ShadowMaterial: 'shadow', + SpriteMaterial: 'sprite' + }; + + function getMaxBones( object ) { + + const skeleton = object.skeleton; + const bones = skeleton.bones; + + if ( floatVertexTextures ) { + + return 1024; + + } else { + + // default for when object is not specified + // ( for example when prebuilding shader to be used with multiple objects ) + // + // - leave some extra space for other uniforms + // - limit here is ANGLE's 254 max uniform vectors + // (up to 54 should be safe) + + const nVertexUniforms = maxVertexUniforms; + const nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 ); + + const maxBones = Math.min( nVertexMatrices, bones.length ); + + if ( maxBones < bones.length ) { + + console.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' ); + return 0; + + } + + return maxBones; + + } + + } + + function getParameters( material, lights, shadows, scene, object ) { + + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + + const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment ); + + const shaderID = shaderIDs[ material.type ]; + + // heuristics to create shader parameters according to lights in the scene + // (not to blow over maxLights budget) + + const maxBones = object.isSkinnedMesh ? getMaxBones( object ) : 0; + + if ( material.precision !== null ) { + + precision = capabilities.getMaxPrecision( material.precision ); + + if ( precision !== material.precision ) { + + console.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' ); + + } + + } + + let vertexShader, fragmentShader; + let customVertexShaderID, customFragmentShaderID; + + if ( shaderID ) { + + const shader = ShaderLib[ shaderID ]; + + vertexShader = shader.vertexShader; + fragmentShader = shader.fragmentShader; + + } else { + + vertexShader = material.vertexShader; + fragmentShader = material.fragmentShader; + + _customShaders.update( material ); + + customVertexShaderID = _customShaders.getVertexShaderID( material ); + customFragmentShaderID = _customShaders.getFragmentShaderID( material ); + + } + + const currentRenderTarget = renderer.getRenderTarget(); + + const useAlphaTest = material.alphaTest > 0; + const useClearcoat = material.clearcoat > 0; + + const parameters = { + + isWebGL2: isWebGL2, + + shaderID: shaderID, + shaderName: material.type, + + vertexShader: vertexShader, + fragmentShader: fragmentShader, + defines: material.defines, + + customVertexShaderID: customVertexShaderID, + customFragmentShaderID: customFragmentShaderID, + + isRawShaderMaterial: material.isRawShaderMaterial === true, + glslVersion: material.glslVersion, + + precision: precision, + + instancing: object.isInstancedMesh === true, + instancingColor: object.isInstancedMesh === true && object.instanceColor !== null, + + supportsVertexTextures: vertexTextures, + outputEncoding: ( currentRenderTarget !== null ) ? currentRenderTarget.texture.encoding : renderer.outputEncoding, + map: !! material.map, + matcap: !! material.matcap, + envMap: !! envMap, + envMapMode: envMap && envMap.mapping, + envMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ), + lightMap: !! material.lightMap, + aoMap: !! material.aoMap, + emissiveMap: !! material.emissiveMap, + bumpMap: !! material.bumpMap, + normalMap: !! material.normalMap, + objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap, + tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap, + + decodeVideoTexture: !! material.map && ( material.map.isVideoTexture === true ) && ( material.map.encoding === sRGBEncoding ), + + clearcoat: useClearcoat, + clearcoatMap: useClearcoat && !! material.clearcoatMap, + clearcoatRoughnessMap: useClearcoat && !! material.clearcoatRoughnessMap, + clearcoatNormalMap: useClearcoat && !! material.clearcoatNormalMap, + + displacementMap: !! material.displacementMap, + roughnessMap: !! material.roughnessMap, + metalnessMap: !! material.metalnessMap, + specularMap: !! material.specularMap, + specularIntensityMap: !! material.specularIntensityMap, + specularColorMap: !! material.specularColorMap, + + alphaMap: !! material.alphaMap, + alphaTest: useAlphaTest, + alphaWrite: material.alphaWrite || material.transparent, + + gradientMap: !! material.gradientMap, + + sheen: material.sheen > 0, + sheenColorMap: !! material.sheenColorMap, + sheenRoughnessMap: !! material.sheenRoughnessMap, + + transmission: material.transmission > 0, + transmissionMap: !! material.transmissionMap, + thicknessMap: !! material.thicknessMap, + + combine: material.combine, + + vertexTangents: ( !! material.normalMap && !! object.geometry && !! object.geometry.attributes.tangent ), + vertexColors: material.vertexColors, + vertexAlphas: material.vertexColors === true && !! object.geometry && !! object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheenColorMap || !! material.sheenRoughnessMap, + uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || material.sheen > 0 || !! material.sheenColorMap || !! material.sheenRoughnessMap ) && !! material.displacementMap, + + fog: !! fog, + useFog: material.fog, + fogExp2: ( fog && fog.isFogExp2 ), + + flatShading: !! material.flatShading, + + sizeAttenuation: material.sizeAttenuation, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + skinning: object.isSkinnedMesh === true && maxBones > 0, + maxBones: maxBones, + useVertexTexture: floatVertexTextures, + + morphTargets: !! object.geometry && !! object.geometry.morphAttributes.position, + morphNormals: !! object.geometry && !! object.geometry.morphAttributes.normal, + morphTargetsCount: ( !! object.geometry && !! object.geometry.morphAttributes.position ) ? object.geometry.morphAttributes.position.length : 0, + + numDirLights: lights.directional.length, + numPointLights: lights.point.length, + numSpotLights: lights.spot.length, + numRectAreaLights: lights.rectArea.length, + numHemiLights: lights.hemi.length, + + numDirLightShadows: lights.directionalShadowMap.length, + numPointLightShadows: lights.pointShadowMap.length, + numSpotLightShadows: lights.spotShadowMap.length, + + numClippingPlanes: clipping.numPlanes, + numClipIntersection: clipping.numIntersection, + + dithering: material.dithering, + + shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0, + shadowMapType: renderer.shadowMap.type, + + toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping, + physicallyCorrectLights: renderer.physicallyCorrectLights, + + premultipliedAlpha: material.premultipliedAlpha, + + doubleSided: material.side === DoubleSide, + flipSided: material.side === BackSide, + + depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false, + + index0AttributeName: material.index0AttributeName, + + extensionDerivatives: material.extensions && material.extensions.derivatives, + extensionFragDepth: material.extensions && material.extensions.fragDepth, + extensionDrawBuffers: material.extensions && material.extensions.drawBuffers, + extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD, + + rendererExtensionFragDepth: isWebGL2 || extensions.has( 'EXT_frag_depth' ), + rendererExtensionDrawBuffers: isWebGL2 || extensions.has( 'WEBGL_draw_buffers' ), + rendererExtensionShaderTextureLod: isWebGL2 || extensions.has( 'EXT_shader_texture_lod' ), + + customProgramCacheKey: material.customProgramCacheKey() + + }; + + return parameters; + + } + + function getProgramCacheKey( parameters ) { + + const array = []; + + if ( parameters.shaderID ) { + + array.push( parameters.shaderID ); + + } else { + + array.push( parameters.customVertexShaderID ); + array.push( parameters.customFragmentShaderID ); + + } + + if ( parameters.defines !== undefined ) { + + for ( const name in parameters.defines ) { + + array.push( name ); + array.push( parameters.defines[ name ] ); + + } + + } + + if ( parameters.isRawShaderMaterial === false ) { + + getProgramCacheKeyParameters( array, parameters ); + getProgramCacheKeyBooleans( array, parameters ); + array.push( renderer.outputEncoding ); + + } + + array.push( parameters.customProgramCacheKey ); + + return array.join(); + + } + + function getProgramCacheKeyParameters( array, parameters ) { + + array.push( parameters.precision ); + array.push( parameters.outputEncoding ); + array.push( parameters.envMapMode ); + array.push( parameters.combine ); + array.push( parameters.vertexUvs ); + array.push( parameters.fogExp2 ); + array.push( parameters.sizeAttenuation ); + array.push( parameters.maxBones ); + array.push( parameters.morphTargetsCount ); + array.push( parameters.numDirLights ); + array.push( parameters.numPointLights ); + array.push( parameters.numSpotLights ); + array.push( parameters.numHemiLights ); + array.push( parameters.numRectAreaLights ); + array.push( parameters.numDirLightShadows ); + array.push( parameters.numPointLightShadows ); + array.push( parameters.numSpotLightShadows ); + array.push( parameters.shadowMapType ); + array.push( parameters.toneMapping ); + array.push( parameters.numClippingPlanes ); + array.push( parameters.numClipIntersection ); + array.push( parameters.alphaWrite ); + + } + + function getProgramCacheKeyBooleans( array, parameters ) { + + _programLayers.disableAll(); + + if ( parameters.isWebGL2 ) + _programLayers.enable( 0 ); + if ( parameters.supportsVertexTextures ) + _programLayers.enable( 1 ); + if ( parameters.instancing ) + _programLayers.enable( 2 ); + if ( parameters.instancingColor ) + _programLayers.enable( 3 ); + if ( parameters.map ) + _programLayers.enable( 4 ); + if ( parameters.matcap ) + _programLayers.enable( 5 ); + if ( parameters.envMap ) + _programLayers.enable( 6 ); + if ( parameters.envMapCubeUV ) + _programLayers.enable( 7 ); + if ( parameters.lightMap ) + _programLayers.enable( 8 ); + if ( parameters.aoMap ) + _programLayers.enable( 9 ); + if ( parameters.emissiveMap ) + _programLayers.enable( 10 ); + if ( parameters.bumpMap ) + _programLayers.enable( 11 ); + if ( parameters.normalMap ) + _programLayers.enable( 12 ); + if ( parameters.objectSpaceNormalMap ) + _programLayers.enable( 13 ); + if ( parameters.tangentSpaceNormalMap ) + _programLayers.enable( 14 ); + if ( parameters.clearcoat ) + _programLayers.enable( 15 ); + if ( parameters.clearcoatMap ) + _programLayers.enable( 16 ); + if ( parameters.clearcoatRoughnessMap ) + _programLayers.enable( 17 ); + if ( parameters.clearcoatNormalMap ) + _programLayers.enable( 18 ); + if ( parameters.displacementMap ) + _programLayers.enable( 19 ); + if ( parameters.specularMap ) + _programLayers.enable( 20 ); + if ( parameters.roughnessMap ) + _programLayers.enable( 21 ); + if ( parameters.metalnessMap ) + _programLayers.enable( 22 ); + if ( parameters.gradientMap ) + _programLayers.enable( 23 ); + if ( parameters.alphaMap ) + _programLayers.enable( 24 ); + if ( parameters.alphaTest ) + _programLayers.enable( 25 ); + if ( parameters.vertexColors ) + _programLayers.enable( 26 ); + if ( parameters.vertexAlphas ) + _programLayers.enable( 27 ); + if ( parameters.vertexUvs ) + _programLayers.enable( 28 ); + if ( parameters.vertexTangents ) + _programLayers.enable( 29 ); + if ( parameters.uvsVertexOnly ) + _programLayers.enable( 30 ); + if ( parameters.fog ) + _programLayers.enable( 31 ); + + array.push( _programLayers.mask ); + _programLayers.disableAll(); + + if ( parameters.useFog ) + _programLayers.enable( 0 ); + if ( parameters.flatShading ) + _programLayers.enable( 1 ); + if ( parameters.logarithmicDepthBuffer ) + _programLayers.enable( 2 ); + if ( parameters.skinning ) + _programLayers.enable( 3 ); + if ( parameters.useVertexTexture ) + _programLayers.enable( 4 ); + if ( parameters.morphTargets ) + _programLayers.enable( 5 ); + if ( parameters.morphNormals ) + _programLayers.enable( 6 ); + if ( parameters.premultipliedAlpha ) + _programLayers.enable( 7 ); + if ( parameters.shadowMapEnabled ) + _programLayers.enable( 8 ); + if ( parameters.physicallyCorrectLights ) + _programLayers.enable( 9 ); + if ( parameters.doubleSided ) + _programLayers.enable( 10 ); + if ( parameters.flipSided ) + _programLayers.enable( 11 ); + if ( parameters.depthPacking ) + _programLayers.enable( 12 ); + if ( parameters.dithering ) + _programLayers.enable( 13 ); + if ( parameters.specularIntensityMap ) + _programLayers.enable( 14 ); + if ( parameters.specularColorMap ) + _programLayers.enable( 15 ); + if ( parameters.transmission ) + _programLayers.enable( 16 ); + if ( parameters.transmissionMap ) + _programLayers.enable( 17 ); + if ( parameters.thicknessMap ) + _programLayers.enable( 18 ); + if ( parameters.sheen ) + _programLayers.enable( 19 ); + if ( parameters.sheenColorMap ) + _programLayers.enable( 20 ); + if ( parameters.sheenRoughnessMap ) + _programLayers.enable( 21 ); + if ( parameters.decodeVideoTexture ) + _programLayers.enable( 22 ); + + array.push( _programLayers.mask ); + + } + + function getUniforms( material ) { + + const shaderID = shaderIDs[ material.type ]; + let uniforms; + + if ( shaderID ) { + + const shader = ShaderLib[ shaderID ]; + uniforms = UniformsUtils.clone( shader.uniforms ); + + } else { + + uniforms = material.uniforms; + + } + + return uniforms; + + } + + function acquireProgram( parameters, cacheKey ) { + + let program; + + // Check if code has been already compiled + for ( let p = 0, pl = programs.length; p < pl; p ++ ) { + + const preexistingProgram = programs[ p ]; + + if ( preexistingProgram.cacheKey === cacheKey ) { + + program = preexistingProgram; + ++ program.usedTimes; + + break; + + } + + } + + if ( program === undefined ) { + + program = new WebGLProgram( renderer, cacheKey, parameters, bindingStates ); + programs.push( program ); + + } + + return program; + + } + + function releaseProgram( program ) { + + if ( -- program.usedTimes === 0 ) { + + // Remove from unordered set + const i = programs.indexOf( program ); + programs[ i ] = programs[ programs.length - 1 ]; + programs.pop(); + + // Free WebGL resources + program.destroy(); + + } + + } + + function releaseShaderCache( material ) { + + _customShaders.remove( material ); + + } + + function dispose() { + + _customShaders.dispose(); + + } + + return { + getParameters: getParameters, + getProgramCacheKey: getProgramCacheKey, + getUniforms: getUniforms, + acquireProgram: acquireProgram, + releaseProgram: releaseProgram, + releaseShaderCache: releaseShaderCache, + // Exposed for resource monitoring & error feedback via renderer.info: + programs: programs, + dispose: dispose + }; + +} + +function WebGLProperties() { + + let properties = new WeakMap(); + + function get( object ) { + + let map = properties.get( object ); + + if ( map === undefined ) { + + map = {}; + properties.set( object, map ); + + } + + return map; + + } + + function remove( object ) { + + properties.delete( object ); + + } + + function update( object, key, value ) { + + properties.get( object )[ key ] = value; + + } + + function dispose() { + + properties = new WeakMap(); + + } + + return { + get: get, + remove: remove, + update: update, + dispose: dispose + }; + +} + +function painterSortStable( a, b ) { + + if ( a.groupOrder !== b.groupOrder ) { + + return a.groupOrder - b.groupOrder; + + } else if ( a.renderOrder !== b.renderOrder ) { + + return a.renderOrder - b.renderOrder; + + } else if ( a.material.id !== b.material.id ) { + + return a.material.id - b.material.id; + + } else if ( a.z !== b.z ) { + + return a.z - b.z; + + } else { + + return a.id - b.id; + + } + +} + +function reversePainterSortStable( a, b ) { + + if ( a.groupOrder !== b.groupOrder ) { + + return a.groupOrder - b.groupOrder; + + } else if ( a.renderOrder !== b.renderOrder ) { + + return a.renderOrder - b.renderOrder; + + } else if ( a.z !== b.z ) { + + return b.z - a.z; + + } else { + + return a.id - b.id; + + } + +} + + +function WebGLRenderList() { + + const renderItems = []; + let renderItemsIndex = 0; + + const opaque = []; + const transmissive = []; + const transparent = []; + + function init() { + + renderItemsIndex = 0; + + opaque.length = 0; + transmissive.length = 0; + transparent.length = 0; + + } + + function getNextRenderItem( object, geometry, material, groupOrder, z, group ) { + + let renderItem = renderItems[ renderItemsIndex ]; + + if ( renderItem === undefined ) { + + renderItem = { + id: object.id, + object: object, + geometry: geometry, + material: material, + groupOrder: groupOrder, + renderOrder: object.renderOrder, + z: z, + group: group + }; + + renderItems[ renderItemsIndex ] = renderItem; + + } else { + + renderItem.id = object.id; + renderItem.object = object; + renderItem.geometry = geometry; + renderItem.material = material; + renderItem.groupOrder = groupOrder; + renderItem.renderOrder = object.renderOrder; + renderItem.z = z; + renderItem.group = group; + + } + + renderItemsIndex ++; + + return renderItem; + + } + + function push( object, geometry, material, groupOrder, z, group ) { + + const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group ); + + if ( material.transmission > 0.0 ) { + + transmissive.push( renderItem ); + + } else if ( material.transparent === true ) { + + transparent.push( renderItem ); + + } else { + + opaque.push( renderItem ); + + } + + } + + function unshift( object, geometry, material, groupOrder, z, group ) { + + const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group ); + + if ( material.transmission > 0.0 ) { + + transmissive.unshift( renderItem ); + + } else if ( material.transparent === true ) { + + transparent.unshift( renderItem ); + + } else { + + opaque.unshift( renderItem ); + + } + + } + + function sort( customOpaqueSort, customTransparentSort ) { + + if ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable ); + if ( transmissive.length > 1 ) transmissive.sort( customTransparentSort || reversePainterSortStable ); + if ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable ); + + } + + function finish() { + + // Clear references from inactive renderItems in the list + + for ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) { + + const renderItem = renderItems[ i ]; + + if ( renderItem.id === null ) break; + + renderItem.id = null; + renderItem.object = null; + renderItem.geometry = null; + renderItem.material = null; + renderItem.group = null; + + } + + } + + return { + + opaque: opaque, + transmissive: transmissive, + transparent: transparent, + + init: init, + push: push, + unshift: unshift, + finish: finish, + + sort: sort + }; + +} + +function WebGLRenderLists() { + + let lists = new WeakMap(); + + function get( scene, renderCallDepth ) { + + let list; + + if ( lists.has( scene ) === false ) { + + list = new WebGLRenderList(); + lists.set( scene, [ list ] ); + + } else { + + if ( renderCallDepth >= lists.get( scene ).length ) { + + list = new WebGLRenderList(); + lists.get( scene ).push( list ); + + } else { + + list = lists.get( scene )[ renderCallDepth ]; + + } + + } + + return list; + + } + + function dispose() { + + lists = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +function UniformsCache() { + + const lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + let uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + direction: new Vector3(), + color: new Color$1() + }; + break; + + case 'SpotLight': + uniforms = { + position: new Vector3(), + direction: new Vector3(), + color: new Color$1(), + distance: 0, + coneCos: 0, + penumbraCos: 0, + decay: 0 + }; + break; + + case 'PointLight': + uniforms = { + position: new Vector3(), + color: new Color$1(), + distance: 0, + decay: 0 + }; + break; + + case 'HemisphereLight': + uniforms = { + direction: new Vector3(), + skyColor: new Color$1(), + groundColor: new Color$1() + }; + break; + + case 'RectAreaLight': + uniforms = { + color: new Color$1(), + position: new Vector3(), + halfWidth: new Vector3(), + halfHeight: new Vector3() + }; + break; + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + +} + +function ShadowUniformsCache() { + + const lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + let uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'SpotLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'PointLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + shadowCameraNear: 1, + shadowCameraFar: 1000 + }; + break; + + // TODO (abelnation): set RectAreaLight shadow uniforms + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + +} + + + +let nextVersion = 0; + +function shadowCastingLightsFirst( lightA, lightB ) { + + return ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 ); + +} + +function WebGLLights( extensions, capabilities ) { + + const cache = new UniformsCache(); + + const shadowCache = ShadowUniformsCache(); + + const state = { + + version: 0, + + hash: { + directionalLength: - 1, + pointLength: - 1, + spotLength: - 1, + rectAreaLength: - 1, + hemiLength: - 1, + + numDirectionalShadows: - 1, + numPointShadows: - 1, + numSpotShadows: - 1 + }, + + ambient: [ 0, 0, 0 ], + probe: [], + directional: [], + directionalShadow: [], + directionalShadowMap: [], + directionalShadowMatrix: [], + spot: [], + spotShadow: [], + spotShadowMap: [], + spotShadowMatrix: [], + rectArea: [], + rectAreaLTC1: null, + rectAreaLTC2: null, + point: [], + pointShadow: [], + pointShadowMap: [], + pointShadowMatrix: [], + hemi: [] + + }; + + for ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() ); + + const vector3 = new Vector3(); + const matrix4 = new Matrix4(); + const matrix42 = new Matrix4(); + + function setup( lights, physicallyCorrectLights ) { + + let r = 0, g = 0, b = 0; + + for ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 ); + + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + let numDirectionalShadows = 0; + let numPointShadows = 0; + let numSpotShadows = 0; + + lights.sort( shadowCastingLightsFirst ); + + // artist-friendly light intensity scaling factor + const scaleFactor = ( physicallyCorrectLights !== true ) ? Math.PI : 1; + + for ( let i = 0, l = lights.length; i < l; i ++ ) { + + const light = lights[ i ]; + + const color = light.color; + const intensity = light.intensity; + const distance = light.distance; + + const shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null; + + if ( light.isAmbientLight ) { + + r += color.r * intensity * scaleFactor; + g += color.g * intensity * scaleFactor; + b += color.b * intensity * scaleFactor; + + } else if ( light.isLightProbe ) { + + for ( let j = 0; j < 9; j ++ ) { + + state.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity ); + + } + + } else if ( light.isDirectionalLight ) { + + const uniforms = cache.get( light ); + + uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor ); + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.directionalShadow[ directionalLength ] = shadowUniforms; + state.directionalShadowMap[ directionalLength ] = shadowMap; + state.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix; + + numDirectionalShadows ++; + + } + + state.directional[ directionalLength ] = uniforms; + + directionalLength ++; + + } else if ( light.isSpotLight ) { + + const uniforms = cache.get( light ); + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + + uniforms.color.copy( color ).multiplyScalar( intensity * scaleFactor ); + uniforms.distance = distance; + + uniforms.coneCos = Math.cos( light.angle ); + uniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) ); + uniforms.decay = light.decay; + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.spotShadow[ spotLength ] = shadowUniforms; + state.spotShadowMap[ spotLength ] = shadowMap; + state.spotShadowMatrix[ spotLength ] = light.shadow.matrix; + + numSpotShadows ++; + + } + + state.spot[ spotLength ] = uniforms; + + spotLength ++; + + } else if ( light.isRectAreaLight ) { + + const uniforms = cache.get( light ); + + // (a) intensity is the total visible light emitted + //uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) ); + + // (b) intensity is the brightness of the light + uniforms.color.copy( color ).multiplyScalar( intensity ); + + uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 ); + uniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 ); + + state.rectArea[ rectAreaLength ] = uniforms; + + rectAreaLength ++; + + } else if ( light.isPointLight ) { + + const uniforms = cache.get( light ); + + uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor ); + uniforms.distance = light.distance; + uniforms.decay = light.decay; + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + shadowUniforms.shadowCameraNear = shadow.camera.near; + shadowUniforms.shadowCameraFar = shadow.camera.far; + + state.pointShadow[ pointLength ] = shadowUniforms; + state.pointShadowMap[ pointLength ] = shadowMap; + state.pointShadowMatrix[ pointLength ] = light.shadow.matrix; + + numPointShadows ++; + + } + + state.point[ pointLength ] = uniforms; + + pointLength ++; + + } else if ( light.isHemisphereLight ) { + + const uniforms = cache.get( light ); + + uniforms.skyColor.copy( light.color ).multiplyScalar( intensity * scaleFactor ); + uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity * scaleFactor ); + + state.hemi[ hemiLength ] = uniforms; + + hemiLength ++; + + } + + } + + if ( rectAreaLength > 0 ) { + + if ( capabilities.isWebGL2 ) { + + // WebGL 2 + + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + + } else { + + // WebGL 1 + + if ( extensions.has( 'OES_texture_float_linear' ) === true ) { + + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + + } else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) { + + state.rectAreaLTC1 = UniformsLib.LTC_HALF_1; + state.rectAreaLTC2 = UniformsLib.LTC_HALF_2; + + } else { + + console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' ); + + } + + } + + } + + state.ambient[ 0 ] = r; + state.ambient[ 1 ] = g; + state.ambient[ 2 ] = b; + + const hash = state.hash; + + if ( hash.directionalLength !== directionalLength || + hash.pointLength !== pointLength || + hash.spotLength !== spotLength || + hash.rectAreaLength !== rectAreaLength || + hash.hemiLength !== hemiLength || + hash.numDirectionalShadows !== numDirectionalShadows || + hash.numPointShadows !== numPointShadows || + hash.numSpotShadows !== numSpotShadows ) { + + state.directional.length = directionalLength; + state.spot.length = spotLength; + state.rectArea.length = rectAreaLength; + state.point.length = pointLength; + state.hemi.length = hemiLength; + + state.directionalShadow.length = numDirectionalShadows; + state.directionalShadowMap.length = numDirectionalShadows; + state.pointShadow.length = numPointShadows; + state.pointShadowMap.length = numPointShadows; + state.spotShadow.length = numSpotShadows; + state.spotShadowMap.length = numSpotShadows; + state.directionalShadowMatrix.length = numDirectionalShadows; + state.pointShadowMatrix.length = numPointShadows; + state.spotShadowMatrix.length = numSpotShadows; + + hash.directionalLength = directionalLength; + hash.pointLength = pointLength; + hash.spotLength = spotLength; + hash.rectAreaLength = rectAreaLength; + hash.hemiLength = hemiLength; + + hash.numDirectionalShadows = numDirectionalShadows; + hash.numPointShadows = numPointShadows; + hash.numSpotShadows = numSpotShadows; + + state.version = nextVersion ++; + + } + + } + + function setupView( lights, camera ) { + + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + const viewMatrix = camera.matrixWorldInverse; + + for ( let i = 0, l = lights.length; i < l; i ++ ) { + + const light = lights[ i ]; + + if ( light.isDirectionalLight ) { + + const uniforms = state.directional[ directionalLength ]; + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + vector3.setFromMatrixPosition( light.target.matrixWorld ); + uniforms.direction.sub( vector3 ); + uniforms.direction.transformDirection( viewMatrix ); + + directionalLength ++; + + } else if ( light.isSpotLight ) { + + const uniforms = state.spot[ spotLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + vector3.setFromMatrixPosition( light.target.matrixWorld ); + uniforms.direction.sub( vector3 ); + uniforms.direction.transformDirection( viewMatrix ); + + spotLength ++; + + } else if ( light.isRectAreaLight ) { + + const uniforms = state.rectArea[ rectAreaLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + // extract local rotation of light to derive width/height half vectors + matrix42.identity(); + matrix4.copy( light.matrixWorld ); + matrix4.premultiply( viewMatrix ); + matrix42.extractRotation( matrix4 ); + + uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 ); + uniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 ); + + uniforms.halfWidth.applyMatrix4( matrix42 ); + uniforms.halfHeight.applyMatrix4( matrix42 ); + + rectAreaLength ++; + + } else if ( light.isPointLight ) { + + const uniforms = state.point[ pointLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + pointLength ++; + + } else if ( light.isHemisphereLight ) { + + const uniforms = state.hemi[ hemiLength ]; + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + uniforms.direction.transformDirection( viewMatrix ); + uniforms.direction.normalize(); + + hemiLength ++; + + } + + } + + } + + return { + setup: setup, + setupView: setupView, + state: state + }; + +} + +function WebGLRenderState( extensions, capabilities ) { + + const lights = new WebGLLights( extensions, capabilities ); + + const lightsArray = []; + const shadowsArray = []; + + function init() { + + lightsArray.length = 0; + shadowsArray.length = 0; + + } + + function pushLight( light ) { + + lightsArray.push( light ); + + } + + function pushShadow( shadowLight ) { + + shadowsArray.push( shadowLight ); + + } + + function setupLights( physicallyCorrectLights ) { + + lights.setup( lightsArray, physicallyCorrectLights ); + + } + + function setupLightsView( camera ) { + + lights.setupView( lightsArray, camera ); + + } + + const state = { + lightsArray: lightsArray, + shadowsArray: shadowsArray, + + lights: lights + }; + + return { + init: init, + state: state, + setupLights: setupLights, + setupLightsView: setupLightsView, + + pushLight: pushLight, + pushShadow: pushShadow + }; + +} + +function WebGLRenderStates( extensions, capabilities ) { + + let renderStates = new WeakMap(); + + function get( scene, renderCallDepth = 0 ) { + + let renderState; + + if ( renderStates.has( scene ) === false ) { + + renderState = new WebGLRenderState( extensions, capabilities ); + renderStates.set( scene, [ renderState ] ); + + } else { + + if ( renderCallDepth >= renderStates.get( scene ).length ) { + + renderState = new WebGLRenderState( extensions, capabilities ); + renderStates.get( scene ).push( renderState ); + + } else { + + renderState = renderStates.get( scene )[ renderCallDepth ]; + + } + + } + + return renderState; + + } + + function dispose() { + + renderStates = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +/** + * parameters = { + * + * opacity: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * wireframe: , + * wireframeLinewidth: + * } + */ + +class MeshDepthMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshDepthMaterial'; + + this.depthPacking = BasicDepthPacking; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.depthPacking = source.depthPacking; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + return this; + + } + +} + +MeshDepthMaterial.prototype.isMeshDepthMaterial = true; + +/** + * parameters = { + * + * referencePosition: , + * nearDistance: , + * farDistance: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: + * + * } + */ + +class MeshDistanceMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshDistanceMaterial'; + + this.referencePosition = new Vector3(); + this.nearDistance = 1; + this.farDistance = 1000; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.fog = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.referencePosition.copy( source.referencePosition ); + this.nearDistance = source.nearDistance; + this.farDistance = source.farDistance; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + return this; + + } + +} + +MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true; + +const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}"; + +const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"; + +function WebGLShadowMap( _renderer, _objects, _capabilities ) { + + let _frustum = new Frustum(); + + const _shadowMapSize = new Vector2(), + _viewportSize = new Vector2(), + + _viewport = new Vector4(), + + _depthMaterial = new MeshDepthMaterial( { depthPacking: RGBADepthPacking } ), + _distanceMaterial = new MeshDistanceMaterial(), + + _materialCache = {}, + + _maxTextureSize = _capabilities.maxTextureSize; + + const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide }; + + const shadowMaterialVertical = new ShaderMaterial( { + defines: { + VSM_SAMPLES: 8 + }, + uniforms: { + shadow_pass: { value: null }, + resolution: { value: new Vector2() }, + radius: { value: 4.0 } + }, + + vertexShader: vertex, + fragmentShader: fragment + + } ); + + const shadowMaterialHorizontal = shadowMaterialVertical.clone(); + shadowMaterialHorizontal.defines.HORIZONTAL_PASS = 1; + + const fullScreenTri = new BufferGeometry(); + fullScreenTri.setAttribute( + 'position', + new BufferAttribute( + new Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ), + 3 + ) + ); + + const fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical ); + + const scope = this; + + this.enabled = false; + + this.autoUpdate = true; + this.needsUpdate = false; + + this.type = PCFShadowMap; + + this.render = function ( lights, scene, camera ) { + + if ( scope.enabled === false ) return; + if ( scope.autoUpdate === false && scope.needsUpdate === false ) return; + + if ( lights.length === 0 ) return; + + const currentRenderTarget = _renderer.getRenderTarget(); + const activeCubeFace = _renderer.getActiveCubeFace(); + const activeMipmapLevel = _renderer.getActiveMipmapLevel(); + + const _state = _renderer.state; + + // Set GL state for depth map. + _state.setBlending( NoBlending ); + _state.buffers.color.setClear( 1, 1, 1, 1 ); + _state.buffers.depth.setTest( true ); + _state.setScissorTest( false ); + + // render depth map + + for ( let i = 0, il = lights.length; i < il; i ++ ) { + + const light = lights[ i ]; + const shadow = light.shadow; + + if ( shadow === undefined ) { + + console.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' ); + continue; + + } + + if ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue; + + _shadowMapSize.copy( shadow.mapSize ); + + const shadowFrameExtents = shadow.getFrameExtents(); + + _shadowMapSize.multiply( shadowFrameExtents ); + + _viewportSize.copy( shadow.mapSize ); + + if ( _shadowMapSize.x > _maxTextureSize || _shadowMapSize.y > _maxTextureSize ) { + + if ( _shadowMapSize.x > _maxTextureSize ) { + + _viewportSize.x = Math.floor( _maxTextureSize / shadowFrameExtents.x ); + _shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x; + shadow.mapSize.x = _viewportSize.x; + + } + + if ( _shadowMapSize.y > _maxTextureSize ) { + + _viewportSize.y = Math.floor( _maxTextureSize / shadowFrameExtents.y ); + _shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y; + shadow.mapSize.y = _viewportSize.y; + + } + + } + + if ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) { + + const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + + shadow.camera.updateProjectionMatrix(); + + } + + if ( shadow.map === null ) { + + const pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.camera.updateProjectionMatrix(); + + } + + _renderer.setRenderTarget( shadow.map ); + _renderer.clear(); + + const viewportCount = shadow.getViewportCount(); + + for ( let vp = 0; vp < viewportCount; vp ++ ) { + + const viewport = shadow.getViewport( vp ); + + _viewport.set( + _viewportSize.x * viewport.x, + _viewportSize.y * viewport.y, + _viewportSize.x * viewport.z, + _viewportSize.y * viewport.w + ); + + _state.viewport( _viewport ); + + shadow.updateMatrices( light, vp ); + + _frustum = shadow.getFrustum(); + + renderObject( scene, camera, shadow.camera, light, this.type ); + + } + + // do blur pass for VSM + + if ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) { + + VSMPass( shadow, camera ); + + } + + shadow.needsUpdate = false; + + } + + scope.needsUpdate = false; + + _renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel ); + + }; + + function VSMPass( shadow, camera ) { + + const geometry = _objects.update( fullScreenMesh ); + + if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) { + + shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples; + shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples; + + shadowMaterialVertical.needsUpdate = true; + shadowMaterialHorizontal.needsUpdate = true; + + } + + // vertical pass + + shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture; + shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize; + shadowMaterialVertical.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget( shadow.mapPass ); + _renderer.clear(); + _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null ); + + // horizontal pass + + shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture; + shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize; + shadowMaterialHorizontal.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget( shadow.map ); + _renderer.clear(); + _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null ); + + } + + function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) { + + let result = null; + + const customMaterial = ( light.isPointLight === true ) ? object.customDistanceMaterial : object.customDepthMaterial; + + if ( customMaterial !== undefined ) { + + result = customMaterial; + + } else { + + result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial; + + } + + if ( ( _renderer.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0 ) || + ( material.displacementMap && material.displacementScale !== 0 ) || + ( material.alphaMap && material.alphaTest > 0 ) ) { + + // in this case we need a unique material instance reflecting the + // appropriate state + + const keyA = result.uuid, keyB = material.uuid; + + let materialsForVariant = _materialCache[ keyA ]; + + if ( materialsForVariant === undefined ) { + + materialsForVariant = {}; + _materialCache[ keyA ] = materialsForVariant; + + } + + let cachedMaterial = materialsForVariant[ keyB ]; + + if ( cachedMaterial === undefined ) { + + cachedMaterial = result.clone(); + materialsForVariant[ keyB ] = cachedMaterial; + + } + + result = cachedMaterial; + + } + + result.visible = material.visible; + result.wireframe = material.wireframe; + + if ( type === VSMShadowMap ) { + + result.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side; + + } else { + + result.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ]; + + } + + result.alphaMap = material.alphaMap; + result.alphaTest = material.alphaTest; + + result.clipShadows = material.clipShadows; + result.clippingPlanes = material.clippingPlanes; + result.clipIntersection = material.clipIntersection; + + result.displacementMap = material.displacementMap; + result.displacementScale = material.displacementScale; + result.displacementBias = material.displacementBias; + + result.wireframeLinewidth = material.wireframeLinewidth; + result.linewidth = material.linewidth; + + if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) { + + result.referencePosition.setFromMatrixPosition( light.matrixWorld ); + result.nearDistance = shadowCameraNear; + result.farDistance = shadowCameraFar; + + } + + return result; + + } + + function renderObject( object, camera, shadowCamera, light, type ) { + + if ( object.visible === false ) return; + + const visible = object.layers.test( camera.layers ); + + if ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) { + + if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) { + + object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld ); + + const geometry = _objects.update( object ); + const material = object.material; + + if ( Array.isArray( material ) ) { + + const groups = geometry.groups; + + for ( let k = 0, kl = groups.length; k < kl; k ++ ) { + + const group = groups[ k ]; + const groupMaterial = material[ group.materialIndex ]; + + if ( groupMaterial && groupMaterial.visible ) { + + const depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); + + _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group ); + + } + + } + + } else if ( material.visible ) { + + const depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type ); + + _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null ); + + } + + } + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + renderObject( children[ i ], camera, shadowCamera, light, type ); + + } + + } + +} + +function WebGLState( gl, extensions, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + function ColorBuffer() { + + let locked = false; + + const color = new Vector4(); + let currentColorMask = null; + const currentColorClear = new Vector4( 0, 0, 0, 0 ); + + return { + + setMask: function ( colorMask ) { + + if ( currentColorMask !== colorMask && ! locked ) { + + gl.colorMask( colorMask, colorMask, colorMask, colorMask ); + currentColorMask = colorMask; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( r, g, b, a, premultipliedAlpha ) { + + if ( premultipliedAlpha === true ) { + + r *= a; g *= a; b *= a; + + } + + color.set( r, g, b, a ); + + if ( currentColorClear.equals( color ) === false ) { + + gl.clearColor( r, g, b, a ); + currentColorClear.copy( color ); + + } + + }, + + reset: function () { + + locked = false; + + currentColorMask = null; + currentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state + + } + + }; + + } + + function DepthBuffer() { + + let locked = false; + + let currentDepthMask = null; + let currentDepthFunc = null; + let currentDepthClear = null; + + return { + + setTest: function ( depthTest ) { + + if ( depthTest ) { + + enable( 2929 ); + + } else { + + disable( 2929 ); + + } + + }, + + setMask: function ( depthMask ) { + + if ( currentDepthMask !== depthMask && ! locked ) { + + gl.depthMask( depthMask ); + currentDepthMask = depthMask; + + } + + }, + + setFunc: function ( depthFunc ) { + + if ( currentDepthFunc !== depthFunc ) { + + if ( depthFunc ) { + + switch ( depthFunc ) { + + case NeverDepth: + + gl.depthFunc( 512 ); + break; + + case AlwaysDepth: + + gl.depthFunc( 519 ); + break; + + case LessDepth: + + gl.depthFunc( 513 ); + break; + + case LessEqualDepth: + + gl.depthFunc( 515 ); + break; + + case EqualDepth: + + gl.depthFunc( 514 ); + break; + + case GreaterEqualDepth: + + gl.depthFunc( 518 ); + break; + + case GreaterDepth: + + gl.depthFunc( 516 ); + break; + + case NotEqualDepth: + + gl.depthFunc( 517 ); + break; + + default: + + gl.depthFunc( 515 ); + + } + + } else { + + gl.depthFunc( 515 ); + + } + + currentDepthFunc = depthFunc; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( depth ) { + + if ( currentDepthClear !== depth ) { + + gl.clearDepth( depth ); + currentDepthClear = depth; + + } + + }, + + reset: function () { + + locked = false; + + currentDepthMask = null; + currentDepthFunc = null; + currentDepthClear = null; + + } + + }; + + } + + function StencilBuffer() { + + let locked = false; + + let currentStencilMask = null; + let currentStencilFunc = null; + let currentStencilRef = null; + let currentStencilFuncMask = null; + let currentStencilFail = null; + let currentStencilZFail = null; + let currentStencilZPass = null; + let currentStencilClear = null; + + return { + + setTest: function ( stencilTest ) { + + if ( ! locked ) { + + if ( stencilTest ) { + + enable( 2960 ); + + } else { + + disable( 2960 ); + + } + + } + + }, + + setMask: function ( stencilMask ) { + + if ( currentStencilMask !== stencilMask && ! locked ) { + + gl.stencilMask( stencilMask ); + currentStencilMask = stencilMask; + + } + + }, + + setFunc: function ( stencilFunc, stencilRef, stencilMask ) { + + if ( currentStencilFunc !== stencilFunc || + currentStencilRef !== stencilRef || + currentStencilFuncMask !== stencilMask ) { + + gl.stencilFunc( stencilFunc, stencilRef, stencilMask ); + + currentStencilFunc = stencilFunc; + currentStencilRef = stencilRef; + currentStencilFuncMask = stencilMask; + + } + + }, + + setOp: function ( stencilFail, stencilZFail, stencilZPass ) { + + if ( currentStencilFail !== stencilFail || + currentStencilZFail !== stencilZFail || + currentStencilZPass !== stencilZPass ) { + + gl.stencilOp( stencilFail, stencilZFail, stencilZPass ); + + currentStencilFail = stencilFail; + currentStencilZFail = stencilZFail; + currentStencilZPass = stencilZPass; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( stencil ) { + + if ( currentStencilClear !== stencil ) { + + gl.clearStencil( stencil ); + currentStencilClear = stencil; + + } + + }, + + reset: function () { + + locked = false; + + currentStencilMask = null; + currentStencilFunc = null; + currentStencilRef = null; + currentStencilFuncMask = null; + currentStencilFail = null; + currentStencilZFail = null; + currentStencilZPass = null; + currentStencilClear = null; + + } + + }; + + } + + // + + const colorBuffer = new ColorBuffer(); + const depthBuffer = new DepthBuffer(); + const stencilBuffer = new StencilBuffer(); + + let enabledCapabilities = {}; + + let currentBoundFramebuffers = {}; + let currentDrawbuffers = new WeakMap(); + let defaultDrawbuffers = []; + + let currentProgram = null; + + let currentBlendingEnabled = false; + let currentBlending = null; + let currentBlendEquation = null; + let currentBlendSrc = null; + let currentBlendDst = null; + let currentBlendEquationAlpha = null; + let currentBlendSrcAlpha = null; + let currentBlendDstAlpha = null; + let currentPremultipledAlpha = false; + + let currentFlipSided = null; + let currentCullFace = null; + + let currentLineWidth = null; + + let currentPolygonOffsetFactor = null; + let currentPolygonOffsetUnits = null; + + const maxTextures = gl.getParameter( 35661 ); + + let lineWidthAvailable = false; + let version = 0; + const glVersion = gl.getParameter( 7938 ); + + if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) { + + version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] ); + lineWidthAvailable = ( version >= 1.0 ); + + } else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) { + + version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] ); + lineWidthAvailable = ( version >= 2.0 ); + + } + + let currentTextureSlot = null; + let currentBoundTextures = {}; + + const scissorParam = gl.getParameter( 3088 ); + const viewportParam = gl.getParameter( 2978 ); + + const currentScissor = new Vector4().fromArray( scissorParam ); + const currentViewport = new Vector4().fromArray( viewportParam ); + + function createTexture( type, target, count ) { + + const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4. + const texture = gl.createTexture(); + + gl.bindTexture( type, texture ); + gl.texParameteri( type, 10241, 9728 ); + gl.texParameteri( type, 10240, 9728 ); + + for ( let i = 0; i < count; i ++ ) { + + gl.texImage2D( target + i, 0, 6408, 1, 1, 0, 6408, 5121, data ); + + } + + return texture; + + } + + const emptyTextures = {}; + emptyTextures[ 3553 ] = createTexture( 3553, 3553, 1 ); + emptyTextures[ 34067 ] = createTexture( 34067, 34069, 6 ); + + // init + + colorBuffer.setClear( 0, 0, 0, 1 ); + depthBuffer.setClear( 1 ); + stencilBuffer.setClear( 0 ); + + enable( 2929 ); + depthBuffer.setFunc( LessEqualDepth ); + + setFlipSided( false ); + setCullFace( CullFaceBack ); + enable( 2884 ); + + setBlending( NoBlending ); + + // + + function enable( id ) { + + if ( enabledCapabilities[ id ] !== true ) { + + gl.enable( id ); + enabledCapabilities[ id ] = true; + + } + + } + + function disable( id ) { + + if ( enabledCapabilities[ id ] !== false ) { + + gl.disable( id ); + enabledCapabilities[ id ] = false; + + } + + } + + function bindFramebuffer( target, framebuffer ) { + + if ( currentBoundFramebuffers[ target ] !== framebuffer ) { + + gl.bindFramebuffer( target, framebuffer ); + + currentBoundFramebuffers[ target ] = framebuffer; + + if ( isWebGL2 ) { + + // 36009 is equivalent to 36160 + + if ( target === 36009 ) { + + currentBoundFramebuffers[ 36160 ] = framebuffer; + + } + + if ( target === 36160 ) { + + currentBoundFramebuffers[ 36009 ] = framebuffer; + + } + + } + + return true; + + } + + return false; + + } + + function drawBuffers( renderTarget, framebuffer ) { + + let drawBuffers = defaultDrawbuffers; + + let needsUpdate = false; + + if ( renderTarget ) { + + drawBuffers = currentDrawbuffers.get( framebuffer ); + + if ( drawBuffers === undefined ) { + + drawBuffers = []; + currentDrawbuffers.set( framebuffer, drawBuffers ); + + } + + if ( renderTarget.isWebGLMultipleRenderTargets ) { + + const textures = renderTarget.texture; + + if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== 36064 ) { + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + drawBuffers[ i ] = 36064 + i; + + } + + drawBuffers.length = textures.length; + + needsUpdate = true; + + } + + } else { + + if ( drawBuffers[ 0 ] !== 36064 ) { + + drawBuffers[ 0 ] = 36064; + + needsUpdate = true; + + } + + } + + } else { + + if ( drawBuffers[ 0 ] !== 1029 ) { + + drawBuffers[ 0 ] = 1029; + + needsUpdate = true; + + } + + } + + if ( needsUpdate ) { + + if ( capabilities.isWebGL2 ) { + + gl.drawBuffers( drawBuffers ); + + } else { + + extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers ); + + } + + } + + + } + + function useProgram( program ) { + + if ( currentProgram !== program ) { + + gl.useProgram( program ); + + currentProgram = program; + + return true; + + } + + return false; + + } + + const equationToGL = { + [ AddEquation ]: 32774, + [ SubtractEquation ]: 32778, + [ ReverseSubtractEquation ]: 32779 + }; + + if ( isWebGL2 ) { + + equationToGL[ MinEquation ] = 32775; + equationToGL[ MaxEquation ] = 32776; + + } else { + + const extension = extensions.get( 'EXT_blend_minmax' ); + + if ( extension !== null ) { + + equationToGL[ MinEquation ] = extension.MIN_EXT; + equationToGL[ MaxEquation ] = extension.MAX_EXT; + + } + + } + + const factorToGL = { + [ ZeroFactor ]: 0, + [ OneFactor ]: 1, + [ SrcColorFactor ]: 768, + [ SrcAlphaFactor ]: 770, + [ SrcAlphaSaturateFactor ]: 776, + [ DstColorFactor ]: 774, + [ DstAlphaFactor ]: 772, + [ OneMinusSrcColorFactor ]: 769, + [ OneMinusSrcAlphaFactor ]: 771, + [ OneMinusDstColorFactor ]: 775, + [ OneMinusDstAlphaFactor ]: 773 + }; + + function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) { + + if ( blending === NoBlending ) { + + if ( currentBlendingEnabled === true ) { + + disable( 3042 ); + currentBlendingEnabled = false; + + } + + return; + + } + + if ( currentBlendingEnabled === false ) { + + enable( 3042 ); + currentBlendingEnabled = true; + + } + + if ( blending !== CustomBlending ) { + + if ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) { + + if ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) { + + gl.blendEquation( 32774 ); + + currentBlendEquation = AddEquation; + currentBlendEquationAlpha = AddEquation; + + } + + if ( premultipliedAlpha ) { + + switch ( blending ) { + + case NormalBlending: + gl.blendFuncSeparate( 1, 771, 1, 771 ); + break; + + case AdditiveBlending: + gl.blendFunc( 1, 1 ); + break; + + case SubtractiveBlending: + gl.blendFuncSeparate( 0, 0, 769, 771 ); + break; + + case MultiplyBlending: + gl.blendFuncSeparate( 0, 768, 0, 770 ); + break; + + default: + console.error( 'THREE.WebGLState: Invalid blending: ', blending ); + break; + + } + + } else { + + switch ( blending ) { + + case NormalBlending: + gl.blendFuncSeparate( 770, 771, 1, 771 ); + break; + + case AdditiveBlending: + gl.blendFunc( 770, 1 ); + break; + + case SubtractiveBlending: + gl.blendFunc( 0, 769 ); + break; + + case MultiplyBlending: + gl.blendFunc( 0, 768 ); + break; + + default: + console.error( 'THREE.WebGLState: Invalid blending: ', blending ); + break; + + } + + } + + currentBlendSrc = null; + currentBlendDst = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + + currentBlending = blending; + currentPremultipledAlpha = premultipliedAlpha; + + } + + return; + + } + + // custom blending + + blendEquationAlpha = blendEquationAlpha || blendEquation; + blendSrcAlpha = blendSrcAlpha || blendSrc; + blendDstAlpha = blendDstAlpha || blendDst; + + if ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) { + + gl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] ); + + currentBlendEquation = blendEquation; + currentBlendEquationAlpha = blendEquationAlpha; + + } + + if ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) { + + gl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] ); + + currentBlendSrc = blendSrc; + currentBlendDst = blendDst; + currentBlendSrcAlpha = blendSrcAlpha; + currentBlendDstAlpha = blendDstAlpha; + + } + + currentBlending = blending; + currentPremultipledAlpha = null; + + } + + function setMaterial( material, frontFaceCW ) { + + material.side === DoubleSide + ? disable( 2884 ) + : enable( 2884 ); + + let flipSided = ( material.side === BackSide ); + if ( frontFaceCW ) flipSided = ! flipSided; + + setFlipSided( flipSided ); + + ( material.blending === NormalBlending && material.transparent === false ) + ? setBlending( NoBlending ) + : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha ); + + depthBuffer.setFunc( material.depthFunc ); + depthBuffer.setTest( material.depthTest ); + depthBuffer.setMask( material.depthWrite ); + colorBuffer.setMask( material.colorWrite ); + + const stencilWrite = material.stencilWrite; + stencilBuffer.setTest( stencilWrite ); + if ( stencilWrite ) { + + stencilBuffer.setMask( material.stencilWriteMask ); + stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask ); + stencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass ); + + } + + setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits ); + + material.alphaToCoverage === true + ? enable( 32926 ) + : disable( 32926 ); + + } + + // + + function setFlipSided( flipSided ) { + + if ( currentFlipSided !== flipSided ) { + + if ( flipSided ) { + + gl.frontFace( 2304 ); + + } else { + + gl.frontFace( 2305 ); + + } + + currentFlipSided = flipSided; + + } + + } + + function setCullFace( cullFace ) { + + if ( cullFace !== CullFaceNone ) { + + enable( 2884 ); + + if ( cullFace !== currentCullFace ) { + + if ( cullFace === CullFaceBack ) { + + gl.cullFace( 1029 ); + + } else if ( cullFace === CullFaceFront ) { + + gl.cullFace( 1028 ); + + } else { + + gl.cullFace( 1032 ); + + } + + } + + } else { + + disable( 2884 ); + + } + + currentCullFace = cullFace; + + } + + function setLineWidth( width ) { + + if ( width !== currentLineWidth ) { + + if ( lineWidthAvailable ) gl.lineWidth( width ); + + currentLineWidth = width; + + } + + } + + function setPolygonOffset( polygonOffset, factor, units ) { + + if ( polygonOffset ) { + + enable( 32823 ); + + if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) { + + gl.polygonOffset( factor, units ); + + currentPolygonOffsetFactor = factor; + currentPolygonOffsetUnits = units; + + } + + } else { + + disable( 32823 ); + + } + + } + + function setScissorTest( scissorTest ) { + + if ( scissorTest ) { + + enable( 3089 ); + + } else { + + disable( 3089 ); + + } + + } + + // texture + + function activeTexture( webglSlot ) { + + if ( webglSlot === undefined ) webglSlot = 33984 + maxTextures - 1; + + if ( currentTextureSlot !== webglSlot ) { + + gl.activeTexture( webglSlot ); + currentTextureSlot = webglSlot; + + } + + } + + function bindTexture( webglType, webglTexture ) { + + if ( currentTextureSlot === null ) { + + activeTexture(); + + } + + let boundTexture = currentBoundTextures[ currentTextureSlot ]; + + if ( boundTexture === undefined ) { + + boundTexture = { type: undefined, texture: undefined }; + currentBoundTextures[ currentTextureSlot ] = boundTexture; + + } + + if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) { + + gl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] ); + + boundTexture.type = webglType; + boundTexture.texture = webglTexture; + + } + + } + + function unbindTexture() { + + const boundTexture = currentBoundTextures[ currentTextureSlot ]; + + if ( boundTexture !== undefined && boundTexture.type !== undefined ) { + + gl.bindTexture( boundTexture.type, null ); + + boundTexture.type = undefined; + boundTexture.texture = undefined; + + } + + } + + function compressedTexImage2D() { + + try { + + gl.compressedTexImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texSubImage2D() { + + try { + + gl.texSubImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texSubImage3D() { + + try { + + gl.texSubImage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function compressedTexSubImage2D() { + + try { + + gl.compressedTexSubImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texStorage2D() { + + try { + + gl.texStorage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texStorage3D() { + + try { + + gl.texStorage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texImage2D() { + + try { + + gl.texImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texImage3D() { + + try { + + gl.texImage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + // + + function scissor( scissor ) { + + if ( currentScissor.equals( scissor ) === false ) { + + gl.scissor( scissor.x, scissor.y, scissor.z, scissor.w ); + currentScissor.copy( scissor ); + + } + + } + + function viewport( viewport ) { + + if ( currentViewport.equals( viewport ) === false ) { + + gl.viewport( viewport.x, viewport.y, viewport.z, viewport.w ); + currentViewport.copy( viewport ); + + } + + } + + // + + function reset() { + + // reset state + + gl.disable( 3042 ); + gl.disable( 2884 ); + gl.disable( 2929 ); + gl.disable( 32823 ); + gl.disable( 3089 ); + gl.disable( 2960 ); + gl.disable( 32926 ); + + gl.blendEquation( 32774 ); + gl.blendFunc( 1, 0 ); + gl.blendFuncSeparate( 1, 0, 1, 0 ); + + gl.colorMask( true, true, true, true ); + gl.clearColor( 0, 0, 0, 0 ); + + gl.depthMask( true ); + gl.depthFunc( 513 ); + gl.clearDepth( 1 ); + + gl.stencilMask( 0xffffffff ); + gl.stencilFunc( 519, 0, 0xffffffff ); + gl.stencilOp( 7680, 7680, 7680 ); + gl.clearStencil( 0 ); + + gl.cullFace( 1029 ); + gl.frontFace( 2305 ); + + gl.polygonOffset( 0, 0 ); + + gl.activeTexture( 33984 ); + + gl.bindFramebuffer( 36160, null ); + + if ( isWebGL2 === true ) { + + gl.bindFramebuffer( 36009, null ); + gl.bindFramebuffer( 36008, null ); + + } + + gl.useProgram( null ); + + gl.lineWidth( 1 ); + + gl.scissor( 0, 0, gl.canvas.width, gl.canvas.height ); + gl.viewport( 0, 0, gl.canvas.width, gl.canvas.height ); + + // reset internals + + enabledCapabilities = {}; + + currentTextureSlot = null; + currentBoundTextures = {}; + + currentBoundFramebuffers = {}; + currentDrawbuffers = new WeakMap(); + defaultDrawbuffers = []; + + currentProgram = null; + + currentBlendingEnabled = false; + currentBlending = null; + currentBlendEquation = null; + currentBlendSrc = null; + currentBlendDst = null; + currentBlendEquationAlpha = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + currentPremultipledAlpha = false; + + currentFlipSided = null; + currentCullFace = null; + + currentLineWidth = null; + + currentPolygonOffsetFactor = null; + currentPolygonOffsetUnits = null; + + currentScissor.set( 0, 0, gl.canvas.width, gl.canvas.height ); + currentViewport.set( 0, 0, gl.canvas.width, gl.canvas.height ); + + colorBuffer.reset(); + depthBuffer.reset(); + stencilBuffer.reset(); + + } + + return { + + buffers: { + color: colorBuffer, + depth: depthBuffer, + stencil: stencilBuffer + }, + + enable: enable, + disable: disable, + + bindFramebuffer: bindFramebuffer, + drawBuffers: drawBuffers, + + useProgram: useProgram, + + setBlending: setBlending, + setMaterial: setMaterial, + + setFlipSided: setFlipSided, + setCullFace: setCullFace, + + setLineWidth: setLineWidth, + setPolygonOffset: setPolygonOffset, + + setScissorTest: setScissorTest, + + activeTexture: activeTexture, + bindTexture: bindTexture, + unbindTexture: unbindTexture, + compressedTexImage2D: compressedTexImage2D, + texImage2D: texImage2D, + texImage3D: texImage3D, + + texStorage2D: texStorage2D, + texStorage3D: texStorage3D, + texSubImage2D: texSubImage2D, + texSubImage3D: texSubImage3D, + compressedTexSubImage2D: compressedTexSubImage2D, + + scissor: scissor, + viewport: viewport, + + reset: reset + + }; + +} + +function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { + + const isWebGL2 = capabilities.isWebGL2; + const maxTextures = capabilities.maxTextures; + const maxCubemapSize = capabilities.maxCubemapSize; + const maxTextureSize = capabilities.maxTextureSize; + const maxSamples = capabilities.maxSamples; + const hasMultisampledRenderToTexture = extensions.has( 'WEBGL_multisampled_render_to_texture' ); + const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : undefined; + + const _videoTextures = new WeakMap(); + let _canvas; + + // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas, + // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")! + // Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d). + + let useOffscreenCanvas = false; + + try { + + useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' + && ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null; + + } catch ( err ) { + + // Ignore any errors + + } + + function createCanvas( width, height ) { + + // Use OffscreenCanvas when available. Specially needed in web workers + + return useOffscreenCanvas ? + new OffscreenCanvas( width, height ) : createElementNS( 'canvas' ); + + } + + function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) { + + let scale = 1; + + // handle case if texture exceeds max size + + if ( image.width > maxSize || image.height > maxSize ) { + + scale = maxSize / Math.max( image.width, image.height ); + + } + + // only perform resize if necessary + + if ( scale < 1 || needsPowerOfTwo === true ) { + + // only perform resize for certain image types + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + const floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor; + + const width = floor( scale * image.width ); + const height = floor( scale * image.height ); + + if ( _canvas === undefined ) _canvas = createCanvas( width, height ); + + // cube textures can't reuse the same canvas + + const canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas; + + canvas.width = width; + canvas.height = height; + + const context = canvas.getContext( '2d' ); + context.drawImage( image, 0, 0, width, height ); + + console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' ); + + return canvas; + + } else { + + if ( 'data' in image ) { + + console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' ); + + } + + return image; + + } + + } + + return image; + + } + + function isPowerOfTwo$1( image ) { + + return isPowerOfTwo( image.width ) && isPowerOfTwo( image.height ); + + } + + function textureNeedsPowerOfTwo( texture ) { + + if ( isWebGL2 ) return false; + + return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || + ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ); + + } + + function textureNeedsGenerateMipmaps( texture, supportsMips ) { + + return texture.generateMipmaps && supportsMips && + texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter; + + } + + function generateMipmap( target ) { + + _gl.generateMipmap( target ); + + } + + function getInternalFormat( internalFormatName, glFormat, glType, encoding, isVideoTexture = false ) { + + if ( isWebGL2 === false ) return glFormat; + + if ( internalFormatName !== null ) { + + if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ]; + + console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' ); + + } + + let internalFormat = glFormat; + + if ( glFormat === 6403 ) { + + if ( glType === 5126 ) internalFormat = 33326; + if ( glType === 5131 ) internalFormat = 33325; + if ( glType === 5121 ) internalFormat = 33321; + + } + + if ( glFormat === 6407 ) { + + if ( glType === 5126 ) internalFormat = 34837; + if ( glType === 5131 ) internalFormat = 34843; + if ( glType === 5121 ) internalFormat = 32849; + + } + + if ( glFormat === 6408 ) { + + if ( glType === 5126 ) internalFormat = 34836; + if ( glType === 5131 ) internalFormat = 34842; + if ( glType === 5121 ) internalFormat = ( encoding === sRGBEncoding && isVideoTexture === false ) ? 35907 : 32856; + + } + + if ( internalFormat === 33325 || internalFormat === 33326 || + internalFormat === 34842 || internalFormat === 34836 ) { + + extensions.get( 'EXT_color_buffer_float' ); + + } + + return internalFormat; + + } + + function getMipLevels( texture, image, supportsMips ) { + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) { + + return Math.log2( Math.max( image.width, image.height ) ) + 1; + + } else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) { + + // user-defined mipmaps + + return texture.mipmaps.length; + + } else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) { + + return image.mipmaps.length; + + } else { + + // texture without mipmaps (only base level) + + return 1; + + } + + } + + // Fallback filters for non-power-of-2 textures + + function filterFallback( f ) { + + if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) { + + return 9728; + + } + + return 9729; + + } + + // + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + deallocateTexture( texture ); + + if ( texture.isVideoTexture ) { + + _videoTextures.delete( texture ); + + } + + info.memory.textures --; + + } + + function onRenderTargetDispose( event ) { + + const renderTarget = event.target; + + renderTarget.removeEventListener( 'dispose', onRenderTargetDispose ); + + deallocateRenderTarget( renderTarget ); + + } + + // + + function deallocateTexture( texture ) { + + const textureProperties = properties.get( texture ); + + if ( textureProperties.__webglInit === undefined ) return; + + _gl.deleteTexture( textureProperties.__webglTexture ); + + properties.remove( texture ); + + } + + function deallocateRenderTarget( renderTarget ) { + + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get( renderTarget ); + const textureProperties = properties.get( texture ); + + if ( ! renderTarget ) return; + + if ( textureProperties.__webglTexture !== undefined ) { + + _gl.deleteTexture( textureProperties.__webglTexture ); + + info.memory.textures --; + + } + + if ( renderTarget.depthTexture ) { + + renderTarget.depthTexture.dispose(); + + } + + if ( renderTarget.isWebGLCubeRenderTarget ) { + + for ( let i = 0; i < 6; i ++ ) { + + _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] ); + + } + + } else { + + _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); + if ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer ); + if ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer ); + if ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer ); + + } + + if ( renderTarget.isWebGLMultipleRenderTargets ) { + + for ( let i = 0, il = texture.length; i < il; i ++ ) { + + const attachmentProperties = properties.get( texture[ i ] ); + + if ( attachmentProperties.__webglTexture ) { + + _gl.deleteTexture( attachmentProperties.__webglTexture ); + + info.memory.textures --; + + } + + properties.remove( texture[ i ] ); + + } + + } + + properties.remove( texture ); + properties.remove( renderTarget ); + + } + + // + + let textureUnits = 0; + + function resetTextureUnits() { + + textureUnits = 0; + + } + + function allocateTextureUnit() { + + const textureUnit = textureUnits; + + if ( textureUnit >= maxTextures ) { + + console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures ); + + } + + textureUnits += 1; + + return textureUnit; + + } + + // + + function setTexture2D( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.isVideoTexture ) updateVideoTexture( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + const image = texture.image; + + if ( image === undefined ) { + + console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' ); + + } else if ( image.complete === false ) { + + console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' ); + + } else { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 3553, textureProperties.__webglTexture ); + + } + + function setTexture2DArray( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 35866, textureProperties.__webglTexture ); + + } + + function setTexture3D( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 32879, textureProperties.__webglTexture ); + + } + + function setTextureCube( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadCubeTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); + + } + + const wrappingToGL = { + [ RepeatWrapping ]: 10497, + [ ClampToEdgeWrapping ]: 33071, + [ MirroredRepeatWrapping ]: 33648 + }; + + const filterToGL = { + [ NearestFilter ]: 9728, + [ NearestMipmapNearestFilter ]: 9984, + [ NearestMipmapLinearFilter ]: 9986, + + [ LinearFilter ]: 9729, + [ LinearMipmapNearestFilter ]: 9985, + [ LinearMipmapLinearFilter ]: 9987 + }; + + function setTextureParameters( textureType, texture, supportsMips ) { + + if ( supportsMips ) { + + _gl.texParameteri( textureType, 10242, wrappingToGL[ texture.wrapS ] ); + _gl.texParameteri( textureType, 10243, wrappingToGL[ texture.wrapT ] ); + + if ( textureType === 32879 || textureType === 35866 ) { + + _gl.texParameteri( textureType, 32882, wrappingToGL[ texture.wrapR ] ); + + } + + _gl.texParameteri( textureType, 10240, filterToGL[ texture.magFilter ] ); + _gl.texParameteri( textureType, 10241, filterToGL[ texture.minFilter ] ); + + } else { + + _gl.texParameteri( textureType, 10242, 33071 ); + _gl.texParameteri( textureType, 10243, 33071 ); + + if ( textureType === 32879 || textureType === 35866 ) { + + _gl.texParameteri( textureType, 32882, 33071 ); + + } + + if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) { + + console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' ); + + } + + _gl.texParameteri( textureType, 10240, filterFallback( texture.magFilter ) ); + _gl.texParameteri( textureType, 10241, filterFallback( texture.minFilter ) ); + + if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) { + + console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' ); + + } + + } + + if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) { + + const extension = extensions.get( 'EXT_texture_filter_anisotropic' ); + + if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2 + if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only + + if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) { + + _gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) ); + properties.get( texture ).__currentAnisotropy = texture.anisotropy; + + } + + } + + } + + function initTexture( textureProperties, texture ) { + + if ( textureProperties.__webglInit === undefined ) { + + textureProperties.__webglInit = true; + + texture.addEventListener( 'dispose', onTextureDispose ); + + textureProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures ++; + + } + + } + + function uploadTexture( textureProperties, texture, slot ) { + + let textureType = 3553; + + if ( texture.isDataTexture2DArray ) textureType = 35866; + if ( texture.isDataTexture3D ) textureType = 32879; + + initTexture( textureProperties, texture ); + + state.activeTexture( 33984 + slot ); + state.bindTexture( textureType, textureProperties.__webglTexture ); + + _gl.pixelStorei( 37440, texture.flipY ); + _gl.pixelStorei( 37441, texture.premultiplyAlpha ); + _gl.pixelStorei( 3317, texture.unpackAlignment ); + _gl.pixelStorei( 37443, 0 ); + + const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false; + let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize ); + image = verifyColorSpace( texture, image ); + + const supportsMips = isPowerOfTwo$1( image ) || isWebGL2, + glFormat = utils.convert( texture.format, texture.encoding ); + + let glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture ); + + setTextureParameters( textureType, texture, supportsMips ); + + let mipmap; + const mipmaps = texture.mipmaps; + + const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true ); + const allocateMemory = ( textureProperties.__version === undefined ); + const levels = getMipLevels( texture, image, supportsMips ); + + if ( texture.isDepthTexture ) { + + // populate depth texture with dummy data + + glInternalFormat = 6402; + + if ( isWebGL2 ) { + + if ( texture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( texture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } else if ( texture.type === UnsignedInt248Type ) { + + glInternalFormat = 35056; + + } else { + + glInternalFormat = 33189; // WebGL2 requires sized internalformat for glTexImage2D + + } + + } else { + + if ( texture.type === FloatType ) { + + console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' ); + + } + + } + + // validation checks for WebGL 1 + + if ( texture.format === DepthFormat && glInternalFormat === 6402 ) { + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' ); + + texture.type = UnsignedShortType; + glType = utils.convert( texture.type ); + + } + + } + + if ( texture.format === DepthStencilFormat && glInternalFormat === 6402 ) { + + // Depth stencil textures need the DEPTH_STENCIL internal format + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + glInternalFormat = 34041; + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL. + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedInt248Type ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' ); + + texture.type = UnsignedInt248Type; + glType = utils.convert( texture.type ); + + } + + } + + // + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); + + } + + } else if ( texture.isDataTexture ) { + + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if ( mipmaps.length > 0 && supportsMips ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + texture.generateMipmaps = false; + + } else { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } + + state.texSubImage2D( 3553, 0, 0, 0, image.width, image.height, glFormat, glType, image.data ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data ); + + } + + } + + } else if ( texture.isCompressedTexture ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( texture.format !== RGBAFormat ) { + + if ( glFormat !== null ) { + + if ( useTexStorage ) { + + state.compressedTexSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data ); + + } else { + + state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' ); + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + } + + } else if ( texture.isDataTexture2DArray ) { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage3D( 35866, levels, glInternalFormat, image.width, image.height, image.depth ); + + } + + state.texSubImage3D( 35866, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); + + } else { + + state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data ); + + } + + } else if ( texture.isDataTexture3D ) { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage3D( 32879, levels, glInternalFormat, image.width, image.height, image.depth ); + + } + + state.texSubImage3D( 32879, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); + + } else { + + state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data ); + + } + + } else if ( texture.isFramebufferTexture ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); + + } + + } else { + + // regular Texture (image, video, canvas) + + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if ( mipmaps.length > 0 && supportsMips ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, i, 0, 0, glFormat, glType, mipmap ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap ); + + } + + } + + texture.generateMipmaps = false; + + } else { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } + + state.texSubImage2D( 3553, 0, 0, 0, glFormat, glType, image ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image ); + + } + + } + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( textureType ); + + } + + textureProperties.__version = texture.version; + + if ( texture.onUpdate ) texture.onUpdate( texture ); + + } + + function uploadCubeTexture( textureProperties, texture, slot ) { + + if ( texture.image.length !== 6 ) return; + + initTexture( textureProperties, texture ); + + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); + + _gl.pixelStorei( 37440, texture.flipY ); + _gl.pixelStorei( 37441, texture.premultiplyAlpha ); + _gl.pixelStorei( 3317, texture.unpackAlignment ); + _gl.pixelStorei( 37443, 0 ); + + const isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) ); + const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); + + const cubeImage = []; + + for ( let i = 0; i < 6; i ++ ) { + + if ( ! isCompressed && ! isDataTexture ) { + + cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize ); + + } else { + + cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; + + } + + cubeImage[ i ] = verifyColorSpace( texture, cubeImage[ i ] ); + + } + + const image = cubeImage[ 0 ], + supportsMips = isPowerOfTwo$1( image ) || isWebGL2, + glFormat = utils.convert( texture.format, texture.encoding ), + glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + + const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true ); + const allocateMemory = ( textureProperties.__version === undefined ); + let levels = getMipLevels( texture, image, supportsMips ); + + setTextureParameters( 34067, texture, supportsMips ); + + let mipmaps; + + if ( isCompressed ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 34067, levels, glInternalFormat, image.width, image.height ); + + } + + for ( let i = 0; i < 6; i ++ ) { + + mipmaps = cubeImage[ i ].mipmaps; + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + + if ( texture.format !== RGBAFormat ) { + + if ( glFormat !== null ) { + + if ( useTexStorage ) { + + state.compressedTexSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data ); + + } else { + + state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + } + + } + + } else { + + mipmaps = texture.mipmaps; + + if ( useTexStorage && allocateMemory ) { + + // TODO: Uniformly handle mipmap definitions + // Normal textures and compressed cube textures define base level + mips with their mipmap array + // Uncompressed cube textures use their mipmap array only for mips (no base level) + + if ( mipmaps.length > 0 ) levels ++; + + state.texStorage2D( 34067, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height ); + + } + + for ( let i = 0; i < 6; i ++ ) { + + if ( isDataTexture ) { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data ); + + } else { + + state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); + + } + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + const mipmapImage = mipmap.image[ i ].image; + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data ); + + } else { + + state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data ); + + } + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] ); + + } else { + + state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); + + } + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] ); + + } else { + + state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); + + } + + } + + } + + } + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + // We assume images for cube map have the same size. + generateMipmap( 34067 ); + + } + + textureProperties.__version = texture.version; + + if ( texture.onUpdate ) texture.onUpdate( texture ); + + } + + // Render targets + + // Setup storage for target texture and bind it to correct framebuffer + function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget ) { + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const renderTargetProperties = properties.get( renderTarget ); + + if ( ! renderTargetProperties.__hasExternalTextures ) { + + if ( textureTarget === 32879 || textureTarget === 35866 ) { + + state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null ); + + } else { + + state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null ); + + } + + } + + state.bindFramebuffer( 36160, framebuffer ); + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) ); + + } else { + + _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 ); + + } + + state.bindFramebuffer( 36160, null ); + + } + + + // Setup storage for internal depth/stencil buffers and bind to correct framebuffer + function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) { + + _gl.bindRenderbuffer( 36161, renderbuffer ); + + if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) { + + let glInternalFormat = 33189; + + if ( isMultisample || renderTarget.useRenderToTexture ) { + + const depthTexture = renderTarget.depthTexture; + + if ( depthTexture && depthTexture.isDepthTexture ) { + + if ( depthTexture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( depthTexture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } + + } + + const samples = getRenderTargetSamples( renderTarget ); + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + } else { + + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + _gl.framebufferRenderbuffer( 36160, 36096, 36161, renderbuffer ); + + } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) { + + const samples = getRenderTargetSamples( renderTarget ); + + if ( isMultisample && renderTarget.useRenderbuffer ) { + + _gl.renderbufferStorageMultisample( 36161, samples, 35056, renderTarget.width, renderTarget.height ); + + } else if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, 35056, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorage( 36161, 34041, renderTarget.width, renderTarget.height ); + + } + + + _gl.framebufferRenderbuffer( 36160, 33306, 36161, renderbuffer ); + + } else { + + // Use the first texture for MRT so far + const texture = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture[ 0 ] : renderTarget.texture; + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const samples = getRenderTargetSamples( renderTarget ); + + if ( isMultisample && renderTarget.useRenderbuffer ) { + + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + } + + _gl.bindRenderbuffer( 36161, null ); + + } + + // Setup resources for a Depth Texture for a FBO (needs an extension) + function setupDepthTexture( framebuffer, renderTarget ) { + + const isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget ); + if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' ); + + state.bindFramebuffer( 36160, framebuffer ); + + if ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) { + + throw new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' ); + + } + + // upload an empty depth texture with framebuffer size + if ( ! properties.get( renderTarget.depthTexture ).__webglTexture || + renderTarget.depthTexture.image.width !== renderTarget.width || + renderTarget.depthTexture.image.height !== renderTarget.height ) { + + renderTarget.depthTexture.image.width = renderTarget.width; + renderTarget.depthTexture.image.height = renderTarget.height; + renderTarget.depthTexture.needsUpdate = true; + + } + + setTexture2D( renderTarget.depthTexture, 0 ); + + const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture; + const samples = getRenderTargetSamples( renderTarget ); + + if ( renderTarget.depthTexture.format === DepthFormat ) { + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 36096, 3553, webglDepthTexture, 0, samples ); + + } else { + + _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 ); + + } + + } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) { + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 33306, 3553, webglDepthTexture, 0, samples ); + + } else { + + _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 ); + + } + + } else { + + throw new Error( 'Unknown depthTexture format' ); + + } + + } + + // Setup GL resources for a non-texture depth buffer + function setupDepthRenderbuffer( renderTarget ) { + + const renderTargetProperties = properties.get( renderTarget ); + const isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); + + if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) { + + if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' ); + + setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget ); + + } else { + + if ( isCube ) { + + renderTargetProperties.__webglDepthbuffer = []; + + for ( let i = 0; i < 6; i ++ ) { + + state.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer[ i ] ); + renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false ); + + } + + } else { + + state.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); + renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false ); + + } + + } + + state.bindFramebuffer( 36160, null ); + + } + + // rebind framebuffer with external textures + function rebindTextures( renderTarget, colorTexture, depthTexture ) { + + const renderTargetProperties = properties.get( renderTarget ); + + if ( colorTexture !== undefined ) { + + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, 36064, 3553 ); + + } + + if ( depthTexture !== undefined ) { + + setupDepthRenderbuffer( renderTarget ); + + } + + } + + // Set up GL resources for the render target + function setupRenderTarget( renderTarget ) { + + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get( renderTarget ); + const textureProperties = properties.get( texture ); + + renderTarget.addEventListener( 'dispose', onRenderTargetDispose ); + + if ( renderTarget.isWebGLMultipleRenderTargets !== true ) { + + if ( textureProperties.__webglTexture === undefined ) { + + textureProperties.__webglTexture = _gl.createTexture(); + + } + + textureProperties.__version = texture.version; + info.memory.textures ++; + + } + + const isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); + const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true ); + const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray; + const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2; + + // Setup framebuffer + + if ( isCube ) { + + renderTargetProperties.__webglFramebuffer = []; + + for ( let i = 0; i < 6; i ++ ) { + + renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer(); + + } + + } else { + + renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer(); + + if ( isMultipleRenderTargets ) { + + if ( capabilities.drawBuffers ) { + + const textures = renderTarget.texture; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const attachmentProperties = properties.get( textures[ i ] ); + + if ( attachmentProperties.__webglTexture === undefined ) { + + attachmentProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures ++; + + } + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' ); + + } + + } else if ( renderTarget.useRenderbuffer ) { + + if ( isWebGL2 ) { + + renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer(); + renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer(); + + _gl.bindRenderbuffer( 36161, renderTargetProperties.__webglColorRenderbuffer ); + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const samples = getRenderTargetSamples( renderTarget ); + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + state.bindFramebuffer( 36160, renderTargetProperties.__webglMultisampledFramebuffer ); + _gl.framebufferRenderbuffer( 36160, 36064, 36161, renderTargetProperties.__webglColorRenderbuffer ); + _gl.bindRenderbuffer( 36161, null ); + + if ( renderTarget.depthBuffer ) { + + renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true ); + + } + + state.bindFramebuffer( 36160, null ); + + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); + + } + + } + + } + + // Setup color buffer + + if ( isCube ) { + + state.bindTexture( 34067, textureProperties.__webglTexture ); + setTextureParameters( 34067, texture, supportsMips ); + + for ( let i = 0; i < 6; i ++ ) { + + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, texture, 36064, 34069 + i ); + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( 34067 ); + + } + + state.unbindTexture(); + + } else if ( isMultipleRenderTargets ) { + + const textures = renderTarget.texture; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const attachment = textures[ i ]; + const attachmentProperties = properties.get( attachment ); + + state.bindTexture( 3553, attachmentProperties.__webglTexture ); + setTextureParameters( 3553, attachment, supportsMips ); + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, 36064 + i, 3553 ); + + if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) { + + generateMipmap( 3553 ); + + } + + } + + state.unbindTexture(); + + } else { + + let glTextureType = 3553; + + if ( isRenderTarget3D ) { + + // Render targets containing layers, i.e: Texture 3D and 2d arrays + + if ( isWebGL2 ) { + + const isTexture3D = texture.isDataTexture3D; + glTextureType = isTexture3D ? 32879 : 35866; + + } else { + + console.warn( 'THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.' ); + + } + + } + + state.bindTexture( glTextureType, textureProperties.__webglTexture ); + setTextureParameters( glTextureType, texture, supportsMips ); + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, texture, 36064, glTextureType ); + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( glTextureType ); + + } + + state.unbindTexture(); + + } + + // Setup depth and stencil buffers + + if ( renderTarget.depthBuffer ) { + + setupDepthRenderbuffer( renderTarget ); + + } + + } + + function updateRenderTargetMipmap( renderTarget ) { + + const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2; + + const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ]; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const texture = textures[ i ]; + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + const target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553; + const webglTexture = properties.get( texture ).__webglTexture; + + state.bindTexture( target, webglTexture ); + generateMipmap( target ); + state.unbindTexture(); + + } + + } + + } + + function updateMultisampleRenderTarget( renderTarget ) { + + if ( renderTarget.useRenderbuffer ) { + + if ( isWebGL2 ) { + + const width = renderTarget.width; + const height = renderTarget.height; + let mask = 16384; + const invalidationArray = [ 36064 ]; + const depthStyle = renderTarget.stencilBuffer ? 33306 : 36096; + + if ( renderTarget.depthBuffer ) { + + invalidationArray.push( depthStyle ); + + } + + if ( ! renderTarget.ignoreDepthForMultisampleCopy ) { + + if ( renderTarget.depthBuffer ) mask |= 256; + if ( renderTarget.stencilBuffer ) mask |= 1024; + + } + + const renderTargetProperties = properties.get( renderTarget ); + + state.bindFramebuffer( 36008, renderTargetProperties.__webglMultisampledFramebuffer ); + state.bindFramebuffer( 36009, renderTargetProperties.__webglFramebuffer ); + + if ( renderTarget.ignoreDepthForMultisampleCopy ) { + + _gl.invalidateFramebuffer( 36008, [ depthStyle ] ); + _gl.invalidateFramebuffer( 36009, [ depthStyle ] ); + + } + + _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 ); + _gl.invalidateFramebuffer( 36008, invalidationArray ); + + state.bindFramebuffer( 36008, null ); + state.bindFramebuffer( 36009, renderTargetProperties.__webglMultisampledFramebuffer ); + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); + + } + + } + + } + + function getRenderTargetSamples( renderTarget ) { + + return ( isWebGL2 && ( renderTarget.useRenderbuffer || renderTarget.useRenderToTexture ) ) ? + Math.min( maxSamples, renderTarget.samples ) : 0; + + } + + function updateVideoTexture( texture ) { + + const frame = info.render.frame; + + // Check the last frame we updated the VideoTexture + + if ( _videoTextures.get( texture ) !== frame ) { + + _videoTextures.set( texture, frame ); + texture.update(); + + } + + } + + function verifyColorSpace( texture, image ) { + + const encoding = texture.encoding; + const format = texture.format; + const type = texture.type; + + if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image; + + if ( encoding !== LinearEncoding ) { + + // sRGB + + if ( encoding === sRGBEncoding && texture.isVideoTexture !== true ) { + + if ( isWebGL2 === false ) { + + // in WebGL 1, try to use EXT_sRGB extension and unsized formats + + if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) { + + texture.format = _SRGBAFormat; + + // it's not possible to generate mips in WebGL 1 with this extension + + texture.minFilter = LinearFilter; + texture.generateMipmaps = false; + + } else { + + // slow fallback (CPU decode) + + image = ImageUtils.sRGBToLinear( image ); + + } + + } else { + + // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format + + if ( format !== RGBAFormat || type !== UnsignedByteType ) { + + console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' ); + + } + + } + + } else { + + console.error( 'THREE.WebGLTextures: Unsupported texture encoding:', encoding ); + + } + + } + + return image; + + } + + // backwards compatibility + + let warnedTexture2D = false; + let warnedTextureCube = false; + + function safeSetTexture2D( texture, slot ) { + + if ( texture && texture.isWebGLRenderTarget ) { + + if ( warnedTexture2D === false ) { + + console.warn( 'THREE.WebGLTextures.safeSetTexture2D: don\'t use render targets as textures. Use their .texture property instead.' ); + warnedTexture2D = true; + + } + + texture = texture.texture; + + } + + setTexture2D( texture, slot ); + + } + + function safeSetTextureCube( texture, slot ) { + + if ( texture && texture.isWebGLCubeRenderTarget ) { + + if ( warnedTextureCube === false ) { + + console.warn( 'THREE.WebGLTextures.safeSetTextureCube: don\'t use cube render targets as textures. Use their .texture property instead.' ); + warnedTextureCube = true; + + } + + texture = texture.texture; + + } + + + setTextureCube( texture, slot ); + + } + + // + + this.allocateTextureUnit = allocateTextureUnit; + this.resetTextureUnits = resetTextureUnits; + + this.setTexture2D = setTexture2D; + this.setTexture2DArray = setTexture2DArray; + this.setTexture3D = setTexture3D; + this.setTextureCube = setTextureCube; + this.rebindTextures = rebindTextures; + this.setupRenderTarget = setupRenderTarget; + this.updateRenderTargetMipmap = updateRenderTargetMipmap; + this.updateMultisampleRenderTarget = updateMultisampleRenderTarget; + this.setupDepthRenderbuffer = setupDepthRenderbuffer; + this.setupFrameBufferTexture = setupFrameBufferTexture; + + this.safeSetTexture2D = safeSetTexture2D; + this.safeSetTextureCube = safeSetTextureCube; + +} + +function WebGLUtils( gl, extensions, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + function convert( p, encoding = null ) { + + let extension; + + if ( p === UnsignedByteType ) return 5121; + if ( p === UnsignedShort4444Type ) return 32819; + if ( p === UnsignedShort5551Type ) return 32820; + if ( p === UnsignedShort565Type ) return 33635; + + if ( p === ByteType ) return 5120; + if ( p === ShortType ) return 5122; + if ( p === UnsignedShortType ) return 5123; + if ( p === IntType ) return 5124; + if ( p === UnsignedIntType ) return 5125; + if ( p === FloatType ) return 5126; + + if ( p === HalfFloatType ) { + + if ( isWebGL2 ) return 5131; + + extension = extensions.get( 'OES_texture_half_float' ); + + if ( extension !== null ) { + + return extension.HALF_FLOAT_OES; + + } else { + + return null; + + } + + } + + if ( p === AlphaFormat ) return 6406; + if ( p === RGBAFormat ) return 6408; + if ( p === LuminanceFormat ) return 6409; + if ( p === LuminanceAlphaFormat ) return 6410; + if ( p === DepthFormat ) return 6402; + if ( p === DepthStencilFormat ) return 34041; + if ( p === RedFormat ) return 6403; + + // WebGL 1 sRGB fallback + + if ( p === _SRGBAFormat ) { + + extension = extensions.get( 'EXT_sRGB' ); + + if ( extension !== null ) { + + return extension.SRGB_ALPHA_EXT; + + } else { + + return null; + + } + + } + + // WebGL2 formats. + + if ( p === RedIntegerFormat ) return 36244; + if ( p === RGFormat ) return 33319; + if ( p === RGIntegerFormat ) return 33320; + if ( p === RGBIntegerFormat ) return 36248; + if ( p === RGBAIntegerFormat ) return 36249; + + // S3TC + + if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) { + + if ( encoding === sRGBEncoding ) { + + extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' ); + + if ( extension !== null ) { + + if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + + } else { + + return null; + + } + + } else { + + extension = extensions.get( 'WEBGL_compressed_texture_s3tc' ); + + if ( extension !== null ) { + + if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT; + + } else { + + return null; + + } + + } + + } + + // PVRTC + + if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + + if ( extension !== null ) { + + if ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + + } else { + + return null; + + } + + } + + // ETC1 + + if ( p === RGB_ETC1_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc1' ); + + if ( extension !== null ) { + + return extension.COMPRESSED_RGB_ETC1_WEBGL; + + } else { + + return null; + + } + + } + + // ETC2 + + if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc' ); + + if ( extension !== null ) { + + if ( p === RGB_ETC2_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2; + if ( p === RGBA_ETC2_EAC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC; + + } else { + + return null; + + } + + } + + // ASTC + + if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || + p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || + p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || + p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || + p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_astc' ); + + if ( extension !== null ) { + + if ( p === RGBA_ASTC_4x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR; + if ( p === RGBA_ASTC_5x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR; + if ( p === RGBA_ASTC_5x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR; + if ( p === RGBA_ASTC_6x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR; + if ( p === RGBA_ASTC_6x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR; + if ( p === RGBA_ASTC_8x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR; + if ( p === RGBA_ASTC_8x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR; + if ( p === RGBA_ASTC_8x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR; + if ( p === RGBA_ASTC_10x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR; + if ( p === RGBA_ASTC_10x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR; + if ( p === RGBA_ASTC_10x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR; + if ( p === RGBA_ASTC_10x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR; + if ( p === RGBA_ASTC_12x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR; + if ( p === RGBA_ASTC_12x12_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR; + + } else { + + return null; + + } + + } + + // BPTC + + if ( p === RGBA_BPTC_Format ) { + + extension = extensions.get( 'EXT_texture_compression_bptc' ); + + if ( extension !== null ) { + + if ( p === RGBA_BPTC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT; + + } else { + + return null; + + } + + } + + // + + if ( p === UnsignedInt248Type ) { + + if ( isWebGL2 ) return 34042; + + extension = extensions.get( 'WEBGL_depth_texture' ); + + if ( extension !== null ) { + + return extension.UNSIGNED_INT_24_8_WEBGL; + + } else { + + return null; + + } + + } + + } + + return { convert: convert }; + +} + +class ArrayCamera extends PerspectiveCamera { + + constructor( array = [] ) { + + super(); + + this.cameras = array; + + } + +} + +ArrayCamera.prototype.isArrayCamera = true; + +class Group$1 extends Object3D { + + constructor() { + + super(); + + this.type = 'Group'; + + } + +} + +Group$1.prototype.isGroup = true; + +const _moveEvent = { type: 'move' }; + +class WebXRController { + + constructor() { + + this._targetRay = null; + this._grip = null; + this._hand = null; + + } + + getHandSpace() { + + if ( this._hand === null ) { + + this._hand = new Group$1(); + this._hand.matrixAutoUpdate = false; + this._hand.visible = false; + + this._hand.joints = {}; + this._hand.inputState = { pinching: false }; + + } + + return this._hand; + + } + + getTargetRaySpace() { + + if ( this._targetRay === null ) { + + this._targetRay = new Group$1(); + this._targetRay.matrixAutoUpdate = false; + this._targetRay.visible = false; + this._targetRay.hasLinearVelocity = false; + this._targetRay.linearVelocity = new Vector3(); + this._targetRay.hasAngularVelocity = false; + this._targetRay.angularVelocity = new Vector3(); + + } + + return this._targetRay; + + } + + getGripSpace() { + + if ( this._grip === null ) { + + this._grip = new Group$1(); + this._grip.matrixAutoUpdate = false; + this._grip.visible = false; + this._grip.hasLinearVelocity = false; + this._grip.linearVelocity = new Vector3(); + this._grip.hasAngularVelocity = false; + this._grip.angularVelocity = new Vector3(); + + } + + return this._grip; + + } + + dispatchEvent( event ) { + + if ( this._targetRay !== null ) { + + this._targetRay.dispatchEvent( event ); + + } + + if ( this._grip !== null ) { + + this._grip.dispatchEvent( event ); + + } + + if ( this._hand !== null ) { + + this._hand.dispatchEvent( event ); + + } + + return this; + + } + + disconnect( inputSource ) { + + this.dispatchEvent( { type: 'disconnected', data: inputSource } ); + + if ( this._targetRay !== null ) { + + this._targetRay.visible = false; + + } + + if ( this._grip !== null ) { + + this._grip.visible = false; + + } + + if ( this._hand !== null ) { + + this._hand.visible = false; + + } + + return this; + + } + + update( inputSource, frame, referenceSpace ) { + + let inputPose = null; + let gripPose = null; + let handPose = null; + + const targetRay = this._targetRay; + const grip = this._grip; + const hand = this._hand; + + if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) { + + if ( targetRay !== null ) { + + inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); + + if ( inputPose !== null ) { + + targetRay.matrix.fromArray( inputPose.transform.matrix ); + targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale ); + + if ( inputPose.linearVelocity ) { + + targetRay.hasLinearVelocity = true; + targetRay.linearVelocity.copy( inputPose.linearVelocity ); + + } else { + + targetRay.hasLinearVelocity = false; + + } + + if ( inputPose.angularVelocity ) { + + targetRay.hasAngularVelocity = true; + targetRay.angularVelocity.copy( inputPose.angularVelocity ); + + } else { + + targetRay.hasAngularVelocity = false; + + } + + this.dispatchEvent( _moveEvent ); + + } + + } + + if ( hand && inputSource.hand ) { + + handPose = true; + + for ( const inputjoint of inputSource.hand.values() ) { + + // Update the joints groups with the XRJoint poses + const jointPose = frame.getJointPose( inputjoint, referenceSpace ); + + if ( hand.joints[ inputjoint.jointName ] === undefined ) { + + // The transform of this joint will be updated with the joint pose on each frame + const joint = new Group$1(); + joint.matrixAutoUpdate = false; + joint.visible = false; + hand.joints[ inputjoint.jointName ] = joint; + // ?? + hand.add( joint ); + + } + + const joint = hand.joints[ inputjoint.jointName ]; + + if ( jointPose !== null ) { + + joint.matrix.fromArray( jointPose.transform.matrix ); + joint.matrix.decompose( joint.position, joint.rotation, joint.scale ); + joint.jointRadius = jointPose.radius; + + } + + joint.visible = jointPose !== null; + + } + + // Custom events + + // Check pinchz + const indexTip = hand.joints[ 'index-finger-tip' ]; + const thumbTip = hand.joints[ 'thumb-tip' ]; + const distance = indexTip.position.distanceTo( thumbTip.position ); + + const distanceToPinch = 0.02; + const threshold = 0.005; + + if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) { + + hand.inputState.pinching = false; + this.dispatchEvent( { + type: 'pinchend', + handedness: inputSource.handedness, + target: this + } ); + + } else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) { + + hand.inputState.pinching = true; + this.dispatchEvent( { + type: 'pinchstart', + handedness: inputSource.handedness, + target: this + } ); + + } + + } else { + + if ( grip !== null && inputSource.gripSpace ) { + + gripPose = frame.getPose( inputSource.gripSpace, referenceSpace ); + + if ( gripPose !== null ) { + + grip.matrix.fromArray( gripPose.transform.matrix ); + grip.matrix.decompose( grip.position, grip.rotation, grip.scale ); + + if ( gripPose.linearVelocity ) { + + grip.hasLinearVelocity = true; + grip.linearVelocity.copy( gripPose.linearVelocity ); + + } else { + + grip.hasLinearVelocity = false; + + } + + if ( gripPose.angularVelocity ) { + + grip.hasAngularVelocity = true; + grip.angularVelocity.copy( gripPose.angularVelocity ); + + } else { + + grip.hasAngularVelocity = false; + + } + + } + + } + + } + + } + + if ( targetRay !== null ) { + + targetRay.visible = ( inputPose !== null ); + + } + + if ( grip !== null ) { + + grip.visible = ( gripPose !== null ); + + } + + if ( hand !== null ) { + + hand.visible = ( handPose !== null ); + + } + + return this; + + } + +} + +class DepthTexture extends Texture { + + constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { + + format = format !== undefined ? format : DepthFormat; + + if ( format !== DepthFormat && format !== DepthStencilFormat ) { + + throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); + + } + + if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; + if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; + + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + + this.image = { width: width, height: height }; + + this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; + + this.flipY = false; + this.generateMipmaps = false; + + } + + +} + +DepthTexture.prototype.isDepthTexture = true; + +class WebXRManager extends EventDispatcher { + + constructor( renderer, gl ) { + + super(); + + const scope = this; + + let session = null; + let framebufferScaleFactor = 1.0; + + let referenceSpace = null; + let referenceSpaceType = 'local-floor'; + const hasMultisampledRenderToTexture = renderer.extensions.has( 'WEBGL_multisampled_render_to_texture' ); + + let pose = null; + let glBinding = null; + let glProjLayer = null; + let glBaseLayer = null; + let isMultisample = false; + let xrFrame = null; + const attributes = gl.getContextAttributes(); + let initialRenderTarget = null; + let newRenderTarget = null; + + const controllers = []; + const inputSourcesMap = new Map(); + + // + + const cameraL = new PerspectiveCamera(); + cameraL.layers.enable( 1 ); + cameraL.viewport = new Vector4(); + + const cameraR = new PerspectiveCamera(); + cameraR.layers.enable( 2 ); + cameraR.viewport = new Vector4(); + + const cameras = [ cameraL, cameraR ]; + + const cameraVR = new ArrayCamera(); + cameraVR.layers.enable( 1 ); + cameraVR.layers.enable( 2 ); + + let _currentDepthNear = null; + let _currentDepthFar = null; + + // + + this.cameraAutoUpdate = true; + this.enabled = false; + + this.isPresenting = false; + + this.getController = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getTargetRaySpace(); + + }; + + this.getControllerGrip = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getGripSpace(); + + }; + + this.getHand = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getHandSpace(); + + }; + + // + + function onSessionEvent( event ) { + + const controller = inputSourcesMap.get( event.inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: event.type, data: event.inputSource } ); + + } + + } + + function onSessionEnd() { + + inputSourcesMap.forEach( function ( controller, inputSource ) { + + controller.disconnect( inputSource ); + + } ); + + inputSourcesMap.clear(); + + _currentDepthNear = null; + _currentDepthFar = null; + + // restore framebuffer/rendering state + + renderer.setRenderTarget( initialRenderTarget ); + + glBaseLayer = null; + glProjLayer = null; + glBinding = null; + session = null; + newRenderTarget = null; + + // + + animation.stop(); + + scope.isPresenting = false; + + scope.dispatchEvent( { type: 'sessionend' } ); + + } + + this.setFramebufferScaleFactor = function ( value ) { + + framebufferScaleFactor = value; + + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' ); + + } + + }; + + this.setReferenceSpaceType = function ( value ) { + + referenceSpaceType = value; + + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' ); + + } + + }; + + this.getReferenceSpace = function () { + + return referenceSpace; + + }; + + this.getBaseLayer = function () { + + return glProjLayer !== null ? glProjLayer : glBaseLayer; + + }; + + this.getBinding = function () { + + return glBinding; + + }; + + this.getFrame = function () { + + return xrFrame; + + }; + + this.getSession = function () { + + return session; + + }; + + this.setSession = async function ( value ) { + + session = value; + + if ( session !== null ) { + + initialRenderTarget = renderer.getRenderTarget(); + + session.addEventListener( 'select', onSessionEvent ); + session.addEventListener( 'selectstart', onSessionEvent ); + session.addEventListener( 'selectend', onSessionEvent ); + session.addEventListener( 'squeeze', onSessionEvent ); + session.addEventListener( 'squeezestart', onSessionEvent ); + session.addEventListener( 'squeezeend', onSessionEvent ); + session.addEventListener( 'end', onSessionEnd ); + session.addEventListener( 'inputsourceschange', onInputSourcesChange ); + + if ( attributes.xrCompatible !== true ) { + + await gl.makeXRCompatible(); + + } + + if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) { + + const layerInit = { + antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true, + alpha: attributes.alpha, + depth: attributes.depth, + stencil: attributes.stencil, + framebufferScaleFactor: framebufferScaleFactor + }; + + glBaseLayer = new XRWebGLLayer( session, gl, layerInit ); + + session.updateRenderState( { baseLayer: glBaseLayer } ); + + newRenderTarget = new WebGLRenderTarget( + glBaseLayer.framebufferWidth, + glBaseLayer.framebufferHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + encoding: renderer.outputEncoding + } + ); + + } else { + + isMultisample = attributes.antialias; + let depthFormat = null; + let depthType = null; + let glDepthFormat = null; + + if ( attributes.depth ) { + + glDepthFormat = attributes.stencil ? 35056 : 33190; + depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat; + depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType; + + } + + const projectionlayerInit = { + colorFormat: ( renderer.outputEncoding === sRGBEncoding ) ? 35907 : 32856, + depthFormat: glDepthFormat, + scaleFactor: framebufferScaleFactor + }; + + glBinding = new XRWebGLBinding( session, gl ); + + glProjLayer = glBinding.createProjectionLayer( projectionlayerInit ); + + session.updateRenderState( { layers: [ glProjLayer ] } ); + + if ( isMultisample ) { + + newRenderTarget = new WebGLMultisampleRenderTarget( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + useRenderToTexture: hasMultisampledRenderToTexture, + encoding: renderer.outputEncoding + } ); + + } else { + + newRenderTarget = new WebGLRenderTarget( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + encoding: renderer.outputEncoding + } ); + + } + + } + + // Set foveation to maximum. + this.setFoveation( 1.0 ); + + referenceSpace = await session.requestReferenceSpace( referenceSpaceType ); + + animation.setContext( session ); + animation.start(); + + scope.isPresenting = true; + + scope.dispatchEvent( { type: 'sessionstart' } ); + + } + + }; + + function onInputSourcesChange( event ) { + + const inputSources = session.inputSources; + + // Assign inputSources to available controllers + + for ( let i = 0; i < controllers.length; i ++ ) { + + inputSourcesMap.set( inputSources[ i ], controllers[ i ] ); + + } + + // Notify disconnected + + for ( let i = 0; i < event.removed.length; i ++ ) { + + const inputSource = event.removed[ i ]; + const controller = inputSourcesMap.get( inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: 'disconnected', data: inputSource } ); + inputSourcesMap.delete( inputSource ); + + } + + } + + // Notify connected + + for ( let i = 0; i < event.added.length; i ++ ) { + + const inputSource = event.added[ i ]; + const controller = inputSourcesMap.get( inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: 'connected', data: inputSource } ); + + } + + } + + } + + // + + const cameraLPos = new Vector3(); + const cameraRPos = new Vector3(); + + /** + * Assumes 2 cameras that are parallel and share an X-axis, and that + * the cameras' projection and world matrices have already been set. + * And that near and far planes are identical for both cameras. + * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765 + */ + function setProjectionFromUnion( camera, cameraL, cameraR ) { + + cameraLPos.setFromMatrixPosition( cameraL.matrixWorld ); + cameraRPos.setFromMatrixPosition( cameraR.matrixWorld ); + + const ipd = cameraLPos.distanceTo( cameraRPos ); + + const projL = cameraL.projectionMatrix.elements; + const projR = cameraR.projectionMatrix.elements; + + // VR systems will have identical far and near planes, and + // most likely identical top and bottom frustum extents. + // Use the left camera for these values. + const near = projL[ 14 ] / ( projL[ 10 ] - 1 ); + const far = projL[ 14 ] / ( projL[ 10 ] + 1 ); + const topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ]; + const bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ]; + + const leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ]; + const rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ]; + const left = near * leftFov; + const right = near * rightFov; + + // Calculate the new camera's position offset from the + // left camera. xOffset should be roughly half `ipd`. + const zOffset = ipd / ( - leftFov + rightFov ); + const xOffset = zOffset * - leftFov; + + // TODO: Better way to apply this offset? + cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale ); + camera.translateX( xOffset ); + camera.translateZ( zOffset ); + camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale ); + camera.matrixWorldInverse.copy( camera.matrixWorld ).invert(); + + // Find the union of the frustum values of the cameras and scale + // the values so that the near plane's position does not change in world space, + // although must now be relative to the new union camera. + const near2 = near + zOffset; + const far2 = far + zOffset; + const left2 = left - xOffset; + const right2 = right + ( ipd - xOffset ); + const top2 = topFov * far / far2 * near2; + const bottom2 = bottomFov * far / far2 * near2; + + camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 ); + + } + + function updateCamera( camera, parent ) { + + if ( parent === null ) { + + camera.matrixWorld.copy( camera.matrix ); + + } else { + + camera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix ); + + } + + camera.matrixWorldInverse.copy( camera.matrixWorld ).invert(); + + } + + this.updateCamera = function ( camera ) { + + if ( session === null ) return; + + cameraVR.near = cameraR.near = cameraL.near = camera.near; + cameraVR.far = cameraR.far = cameraL.far = camera.far; + + if ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) { + + // Note that the new renderState won't apply until the next frame. See #18320 + + session.updateRenderState( { + depthNear: cameraVR.near, + depthFar: cameraVR.far + } ); + + _currentDepthNear = cameraVR.near; + _currentDepthFar = cameraVR.far; + + } + + const parent = camera.parent; + const cameras = cameraVR.cameras; + + updateCamera( cameraVR, parent ); + + for ( let i = 0; i < cameras.length; i ++ ) { + + updateCamera( cameras[ i ], parent ); + + } + + cameraVR.matrixWorld.decompose( cameraVR.position, cameraVR.quaternion, cameraVR.scale ); + + // update user camera and its children + + camera.position.copy( cameraVR.position ); + camera.quaternion.copy( cameraVR.quaternion ); + camera.scale.copy( cameraVR.scale ); + camera.matrix.copy( cameraVR.matrix ); + camera.matrixWorld.copy( cameraVR.matrixWorld ); + + const children = camera.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateMatrixWorld( true ); + + } + + // update projection matrix for proper view frustum culling + + if ( cameras.length === 2 ) { + + setProjectionFromUnion( cameraVR, cameraL, cameraR ); + + } else { + + // assume single camera setup (AR) + + cameraVR.projectionMatrix.copy( cameraL.projectionMatrix ); + + } + + }; + + this.getCamera = function () { + + return cameraVR; + + }; + + this.getFoveation = function () { + + if ( glProjLayer !== null ) { + + return glProjLayer.fixedFoveation; + + } + + if ( glBaseLayer !== null ) { + + return glBaseLayer.fixedFoveation; + + } + + return undefined; + + }; + + this.setFoveation = function ( foveation ) { + + // 0 = no foveation = full resolution + // 1 = maximum foveation = the edges render at lower resolution + + if ( glProjLayer !== null ) { + + glProjLayer.fixedFoveation = foveation; + + } + + if ( glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined ) { + + glBaseLayer.fixedFoveation = foveation; + + } + + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame( time, frame ) { + + pose = frame.getViewerPose( referenceSpace ); + xrFrame = frame; + + if ( pose !== null ) { + + const views = pose.views; + + if ( glBaseLayer !== null ) { + + renderer.setRenderTargetFramebuffer( newRenderTarget, glBaseLayer.framebuffer ); + renderer.setRenderTarget( newRenderTarget ); + + } + + let cameraVRNeedsUpdate = false; + + // check if it's necessary to rebuild cameraVR's camera list + + if ( views.length !== cameraVR.cameras.length ) { + + cameraVR.cameras.length = 0; + cameraVRNeedsUpdate = true; + + } + + for ( let i = 0; i < views.length; i ++ ) { + + const view = views[ i ]; + + let viewport = null; + + if ( glBaseLayer !== null ) { + + viewport = glBaseLayer.getViewport( view ); + + } else { + + const glSubImage = glBinding.getViewSubImage( glProjLayer, view ); + viewport = glSubImage.viewport; + + // For side-by-side projection, we only produce a single texture for both eyes. + if ( i === 0 ) { + + renderer.setRenderTargetTextures( + newRenderTarget, + glSubImage.colorTexture, + glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture ); + + renderer.setRenderTarget( newRenderTarget ); + + } + + } + + const camera = cameras[ i ]; + + camera.matrix.fromArray( view.transform.matrix ); + camera.projectionMatrix.fromArray( view.projectionMatrix ); + camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height ); + + if ( i === 0 ) { + + cameraVR.matrix.copy( camera.matrix ); + + } + + if ( cameraVRNeedsUpdate === true ) { + + cameraVR.cameras.push( camera ); + + } + + } + + } + + // + + const inputSources = session.inputSources; + + for ( let i = 0; i < controllers.length; i ++ ) { + + const controller = controllers[ i ]; + const inputSource = inputSources[ i ]; + + controller.update( inputSource, frame, referenceSpace ); + + } + + if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame ); + + xrFrame = null; + + } + + const animation = new WebGLAnimation(); + + animation.setAnimationLoop( onAnimationFrame ); + + this.setAnimationLoop = function ( callback ) { + + onAnimationFrameCallback = callback; + + }; + + this.dispose = function () {}; + + } + +} + +function WebGLMaterials( properties ) { + + function refreshFogUniforms( uniforms, fog ) { + + uniforms.fogColor.value.copy( fog.color ); + + if ( fog.isFog ) { + + uniforms.fogNear.value = fog.near; + uniforms.fogFar.value = fog.far; + + } else if ( fog.isFogExp2 ) { + + uniforms.fogDensity.value = fog.density; + + } + + } + + function refreshMaterialUniforms( uniforms, material, pixelRatio, height, transmissionRenderTarget ) { + + if ( material.isMeshBasicMaterial ) { + + refreshUniformsCommon( uniforms, material ); + + } else if ( material.isMeshLambertMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsLambert( uniforms, material ); + + } else if ( material.isMeshToonMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsToon( uniforms, material ); + + } else if ( material.isMeshPhongMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsPhong( uniforms, material ); + + } else if ( material.isMeshStandardMaterial ) { + + refreshUniformsCommon( uniforms, material ); + + if ( material.isMeshPhysicalMaterial ) { + + refreshUniformsPhysical( uniforms, material, transmissionRenderTarget ); + + } else { + + refreshUniformsStandard( uniforms, material ); + + } + + } else if ( material.isMeshMatcapMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsMatcap( uniforms, material ); + + } else if ( material.isMeshDepthMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsDepth( uniforms, material ); + + } else if ( material.isMeshDistanceMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsDistance( uniforms, material ); + + } else if ( material.isMeshNormalMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsNormal( uniforms, material ); + + } else if ( material.isLineBasicMaterial ) { + + refreshUniformsLine( uniforms, material ); + + if ( material.isLineDashedMaterial ) { + + refreshUniformsDash( uniforms, material ); + + } + + } else if ( material.isPointsMaterial ) { + + refreshUniformsPoints( uniforms, material, pixelRatio, height ); + + } else if ( material.isSpriteMaterial ) { + + refreshUniformsSprites( uniforms, material ); + + } else if ( material.isShadowMaterial ) { + + uniforms.color.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + + } else if ( material.isShaderMaterial ) { + + material.uniformsNeedUpdate = false; // #15581 + + } + + } + + function refreshUniformsCommon( uniforms, material ) { + + uniforms.opacity.value = material.opacity; + + if ( material.color ) { + + uniforms.diffuse.value.copy( material.color ); + + } + + if ( material.emissive ) { + + uniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity ); + + } + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.specularMap ) { + + uniforms.specularMap.value = material.specularMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + const envMap = properties.get( material ).envMap; + + if ( envMap ) { + + uniforms.envMap.value = envMap; + + uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1; + + uniforms.reflectivity.value = material.reflectivity; + uniforms.ior.value = material.ior; + uniforms.refractionRatio.value = material.refractionRatio; + + } + + if ( material.lightMap ) { + + uniforms.lightMap.value = material.lightMap; + uniforms.lightMapIntensity.value = material.lightMapIntensity; + + } + + if ( material.aoMap ) { + + uniforms.aoMap.value = material.aoMap; + uniforms.aoMapIntensity.value = material.aoMapIntensity; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. specular map + // 3. displacementMap map + // 4. normal map + // 5. bump map + // 6. roughnessMap map + // 7. metalnessMap map + // 8. alphaMap map + // 9. emissiveMap map + // 10. clearcoat map + // 11. clearcoat normal map + // 12. clearcoat roughnessMap map + // 13. specular intensity map + // 14. specular tint map + // 15. transmission map + // 16. thickness map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.specularMap ) { + + uvScaleMap = material.specularMap; + + } else if ( material.displacementMap ) { + + uvScaleMap = material.displacementMap; + + } else if ( material.normalMap ) { + + uvScaleMap = material.normalMap; + + } else if ( material.bumpMap ) { + + uvScaleMap = material.bumpMap; + + } else if ( material.roughnessMap ) { + + uvScaleMap = material.roughnessMap; + + } else if ( material.metalnessMap ) { + + uvScaleMap = material.metalnessMap; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } else if ( material.emissiveMap ) { + + uvScaleMap = material.emissiveMap; + + } else if ( material.clearcoatMap ) { + + uvScaleMap = material.clearcoatMap; + + } else if ( material.clearcoatNormalMap ) { + + uvScaleMap = material.clearcoatNormalMap; + + } else if ( material.clearcoatRoughnessMap ) { + + uvScaleMap = material.clearcoatRoughnessMap; + + } else if ( material.specularIntensityMap ) { + + uvScaleMap = material.specularIntensityMap; + + } else if ( material.specularColorMap ) { + + uvScaleMap = material.specularColorMap; + + } else if ( material.transmissionMap ) { + + uvScaleMap = material.transmissionMap; + + } else if ( material.thicknessMap ) { + + uvScaleMap = material.thicknessMap; + + } else if ( material.sheenColorMap ) { + + uvScaleMap = material.sheenColorMap; + + } else if ( material.sheenRoughnessMap ) { + + uvScaleMap = material.sheenRoughnessMap; + + } + + if ( uvScaleMap !== undefined ) { + + // backwards compatibility + if ( uvScaleMap.isWebGLRenderTarget ) { + + uvScaleMap = uvScaleMap.texture; + + } + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + // uv repeat and offset setting priorities for uv2 + // 1. ao map + // 2. light map + + let uv2ScaleMap; + + if ( material.aoMap ) { + + uv2ScaleMap = material.aoMap; + + } else if ( material.lightMap ) { + + uv2ScaleMap = material.lightMap; + + } + + if ( uv2ScaleMap !== undefined ) { + + // backwards compatibility + if ( uv2ScaleMap.isWebGLRenderTarget ) { + + uv2ScaleMap = uv2ScaleMap.texture; + + } + + if ( uv2ScaleMap.matrixAutoUpdate === true ) { + + uv2ScaleMap.updateMatrix(); + + } + + uniforms.uv2Transform.value.copy( uv2ScaleMap.matrix ); + + } + + } + + function refreshUniformsLine( uniforms, material ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + + } + + function refreshUniformsDash( uniforms, material ) { + + uniforms.dashSize.value = material.dashSize; + uniforms.totalSize.value = material.dashSize + material.gapSize; + uniforms.scale.value = material.scale; + + } + + function refreshUniformsPoints( uniforms, material, pixelRatio, height ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + uniforms.size.value = material.size * pixelRatio; + uniforms.scale.value = height * 0.5; + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } + + if ( uvScaleMap !== undefined ) { + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + } + + function refreshUniformsSprites( uniforms, material ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + uniforms.rotation.value = material.rotation; + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } + + if ( uvScaleMap !== undefined ) { + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + } + + function refreshUniformsLambert( uniforms, material ) { + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + } + + function refreshUniformsPhong( uniforms, material ) { + + uniforms.specular.value.copy( material.specular ); + uniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 ) + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsToon( uniforms, material ) { + + if ( material.gradientMap ) { + + uniforms.gradientMap.value = material.gradientMap; + + } + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsStandard( uniforms, material ) { + + uniforms.roughness.value = material.roughness; + uniforms.metalness.value = material.metalness; + + if ( material.roughnessMap ) { + + uniforms.roughnessMap.value = material.roughnessMap; + + } + + if ( material.metalnessMap ) { + + uniforms.metalnessMap.value = material.metalnessMap; + + } + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + const envMap = properties.get( material ).envMap; + + if ( envMap ) { + + //uniforms.envMap.value = material.envMap; // part of uniforms common + uniforms.envMapIntensity.value = material.envMapIntensity; + + } + + } + + function refreshUniformsPhysical( uniforms, material, transmissionRenderTarget ) { + + refreshUniformsStandard( uniforms, material ); + + uniforms.ior.value = material.ior; // also part of uniforms common + + if ( material.sheen > 0 ) { + + uniforms.sheenColor.value.copy( material.sheenColor ).multiplyScalar( material.sheen ); + + uniforms.sheenRoughness.value = material.sheenRoughness; + + if ( material.sheenColorMap ) { + + uniforms.sheenColorMap.value = material.sheenColorMap; + + } + + if ( material.sheenRoughnessMap ) { + + uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap; + + } + + } + + if ( material.clearcoat > 0 ) { + + uniforms.clearcoat.value = material.clearcoat; + uniforms.clearcoatRoughness.value = material.clearcoatRoughness; + + if ( material.clearcoatMap ) { + + uniforms.clearcoatMap.value = material.clearcoatMap; + + } + + if ( material.clearcoatRoughnessMap ) { + + uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap; + + } + + if ( material.clearcoatNormalMap ) { + + uniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale ); + uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap; + + if ( material.side === BackSide ) { + + uniforms.clearcoatNormalScale.value.negate(); + + } + + } + + } + + if ( material.transmission > 0 ) { + + uniforms.transmission.value = material.transmission; + uniforms.transmissionSamplerMap.value = transmissionRenderTarget.texture; + uniforms.transmissionSamplerSize.value.set( transmissionRenderTarget.width, transmissionRenderTarget.height ); + + if ( material.transmissionMap ) { + + uniforms.transmissionMap.value = material.transmissionMap; + + } + + uniforms.thickness.value = material.thickness; + + if ( material.thicknessMap ) { + + uniforms.thicknessMap.value = material.thicknessMap; + + } + + uniforms.attenuationDistance.value = material.attenuationDistance; + uniforms.attenuationColor.value.copy( material.attenuationColor ); + + } + + uniforms.specularIntensity.value = material.specularIntensity; + uniforms.specularColor.value.copy( material.specularColor ); + + if ( material.specularIntensityMap ) { + + uniforms.specularIntensityMap.value = material.specularIntensityMap; + + } + + if ( material.specularColorMap ) { + + uniforms.specularColorMap.value = material.specularColorMap; + + } + + } + + function refreshUniformsMatcap( uniforms, material ) { + + if ( material.matcap ) { + + uniforms.matcap.value = material.matcap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsDepth( uniforms, material ) { + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsDistance( uniforms, material ) { + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + uniforms.referencePosition.value.copy( material.referencePosition ); + uniforms.nearDistance.value = material.nearDistance; + uniforms.farDistance.value = material.farDistance; + + } + + function refreshUniformsNormal( uniforms, material ) { + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + return { + refreshFogUniforms: refreshFogUniforms, + refreshMaterialUniforms: refreshMaterialUniforms + }; + +} + +function createCanvasElement() { + + const canvas = createElementNS( 'canvas' ); + canvas.style.display = 'block'; + return canvas; + +} + +function WebGLRenderer( parameters = {} ) { + + const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(), + _context = parameters.context !== undefined ? parameters.context : null, + + _alpha = parameters.alpha !== undefined ? parameters.alpha : false, + _depth = parameters.depth !== undefined ? parameters.depth : true, + _stencil = parameters.stencil !== undefined ? parameters.stencil : true, + _antialias = parameters.antialias !== undefined ? parameters.antialias : false, + _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, + _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false, + _powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default', + _failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false; + + let currentRenderList = null; + let currentRenderState = null; + + // render() can be called from within a callback triggered by another render. + // We track this so that the nested render call gets its list and state isolated from the parent render call. + + const renderListStack = []; + const renderStateStack = []; + + // public properties + + this.domElement = _canvas; + + // Debug configuration container + this.debug = { + + /** + * Enables error checking and reporting when shader programs are being compiled + * @type {boolean} + */ + checkShaderErrors: true + }; + + // clearing + + this.autoClear = true; + this.autoClearColor = true; + this.autoClearDepth = true; + this.autoClearStencil = true; + + // scene graph + + this.sortObjects = true; + + // user-defined clipping + + this.clippingPlanes = []; + this.localClippingEnabled = false; + + // physically based shading + + this.outputEncoding = LinearEncoding; + + // physical lights + + this.physicallyCorrectLights = false; + + // tone mapping + + this.toneMapping = NoToneMapping; + this.toneMappingExposure = 1.0; + + // internal properties + + const _this = this; + + let _isContextLost = false; + + // internal state cache + + let _currentActiveCubeFace = 0; + let _currentActiveMipmapLevel = 0; + let _currentRenderTarget = null; + let _currentMaterialId = - 1; + + let _currentCamera = null; + + const _currentViewport = new Vector4(); + const _currentScissor = new Vector4(); + let _currentScissorTest = null; + + // + + let _width = _canvas.width; + let _height = _canvas.height; + + let _pixelRatio = 1; + let _opaqueSort = null; + let _transparentSort = null; + + const _viewport = new Vector4( 0, 0, _width, _height ); + const _scissor = new Vector4( 0, 0, _width, _height ); + let _scissorTest = false; + + // frustum + + const _frustum = new Frustum(); + + // clipping + + let _clippingEnabled = false; + let _localClippingEnabled = false; + + // transmission + + let _transmissionRenderTarget = null; + + // camera matrices cache + + const _projScreenMatrix = new Matrix4(); + + const _vector3 = new Vector3(); + + const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true }; + + function getTargetPixelRatio() { + + return _currentRenderTarget === null ? _pixelRatio : 1; + + } + + // initialize + + let _gl = _context; + + function getContext( contextNames, contextAttributes ) { + + for ( let i = 0; i < contextNames.length; i ++ ) { + + const contextName = contextNames[ i ]; + const context = _canvas.getContext( contextName, contextAttributes ); + if ( context !== null ) return context; + + } + + return null; + + } + + try { + + const contextAttributes = { + alpha: true, + depth: _depth, + stencil: _stencil, + antialias: _antialias, + premultipliedAlpha: _premultipliedAlpha, + preserveDrawingBuffer: _preserveDrawingBuffer, + powerPreference: _powerPreference, + failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat + }; + + // OffscreenCanvas does not have setAttribute, see #22811 + if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` ); + + // event listeners must be registered before WebGL context is created, see #12753 + _canvas.addEventListener( 'webglcontextlost', onContextLost, false ); + _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false ); + + if ( _gl === null ) { + + const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ]; + + if ( _this.isWebGL1Renderer === true ) { + + contextNames.shift(); + + } + + _gl = getContext( contextNames, contextAttributes ); + + if ( _gl === null ) { + + if ( getContext( contextNames ) ) { + + throw new Error( 'Error creating WebGL context with your selected attributes.' ); + + } else { + + throw new Error( 'Error creating WebGL context.' ); + + } + + } + + } + + // Some experimental-webgl implementations do not have getShaderPrecisionFormat + + if ( _gl.getShaderPrecisionFormat === undefined ) { + + _gl.getShaderPrecisionFormat = function () { + + return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 }; + + }; + + } + + } catch ( error ) { + + console.error( 'THREE.WebGLRenderer: ' + error.message ); + throw error; + + } + + let extensions, capabilities, state, info; + let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects; + let programCache, materials, renderLists, renderStates, clipping, shadowMap; + + let background, morphtargets, bufferRenderer, indexedBufferRenderer; + + let utils, bindingStates; + + function initGLContext() { + + extensions = new WebGLExtensions( _gl ); + + capabilities = new WebGLCapabilities( _gl, extensions, parameters ); + + extensions.init( capabilities ); + + utils = new WebGLUtils( _gl, extensions, capabilities ); + + state = new WebGLState( _gl, extensions, capabilities ); + + info = new WebGLInfo( _gl ); + properties = new WebGLProperties(); + textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ); + cubemaps = new WebGLCubeMaps( _this ); + cubeuvmaps = new WebGLCubeUVMaps( _this ); + attributes = new WebGLAttributes( _gl, capabilities ); + bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities ); + geometries = new WebGLGeometries( _gl, attributes, info, bindingStates ); + objects = new WebGLObjects( _gl, geometries, attributes, info ); + morphtargets = new WebGLMorphtargets( _gl, capabilities, textures ); + clipping = new WebGLClipping( properties ); + programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ); + materials = new WebGLMaterials( properties ); + renderLists = new WebGLRenderLists(); + renderStates = new WebGLRenderStates( extensions, capabilities ); + background = new WebGLBackground( _this, cubemaps, state, objects, _alpha, _premultipliedAlpha ); + shadowMap = new WebGLShadowMap( _this, objects, capabilities ); + + bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities ); + indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities ); + + info.programs = programCache.programs; + + _this.capabilities = capabilities; + _this.extensions = extensions; + _this.properties = properties; + _this.renderLists = renderLists; + _this.shadowMap = shadowMap; + _this.state = state; + _this.info = info; + + } + + initGLContext(); + + // xr + + const xr = new WebXRManager( _this, _gl ); + + this.xr = xr; + + // API + + this.getContext = function () { + + return _gl; + + }; + + this.getContextAttributes = function () { + + return _gl.getContextAttributes(); + + }; + + this.forceContextLoss = function () { + + const extension = extensions.get( 'WEBGL_lose_context' ); + if ( extension ) extension.loseContext(); + + }; + + this.forceContextRestore = function () { + + const extension = extensions.get( 'WEBGL_lose_context' ); + if ( extension ) extension.restoreContext(); + + }; + + this.getPixelRatio = function () { + + return _pixelRatio; + + }; + + this.setPixelRatio = function ( value ) { + + if ( value === undefined ) return; + + _pixelRatio = value; + + this.setSize( _width, _height, false ); + + }; + + this.getSize = function ( target ) { + + return target.set( _width, _height ); + + }; + + this.setSize = function ( width, height, updateStyle ) { + + if ( xr.isPresenting ) { + + console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' ); + return; + + } + + _width = width; + _height = height; + + _canvas.width = Math.floor( width * _pixelRatio ); + _canvas.height = Math.floor( height * _pixelRatio ); + + if ( updateStyle !== false ) { + + _canvas.style.width = width + 'px'; + _canvas.style.height = height + 'px'; + + } + + this.setViewport( 0, 0, width, height ); + + }; + + this.getDrawingBufferSize = function ( target ) { + + return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor(); + + }; + + this.setDrawingBufferSize = function ( width, height, pixelRatio ) { + + _width = width; + _height = height; + + _pixelRatio = pixelRatio; + + _canvas.width = Math.floor( width * pixelRatio ); + _canvas.height = Math.floor( height * pixelRatio ); + + this.setViewport( 0, 0, width, height ); + + }; + + this.getCurrentViewport = function ( target ) { + + return target.copy( _currentViewport ); + + }; + + this.getViewport = function ( target ) { + + return target.copy( _viewport ); + + }; + + this.setViewport = function ( x, y, width, height ) { + + if ( x.isVector4 ) { + + _viewport.set( x.x, x.y, x.z, x.w ); + + } else { + + _viewport.set( x, y, width, height ); + + } + + state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() ); + + }; + + this.getScissor = function ( target ) { + + return target.copy( _scissor ); + + }; + + this.setScissor = function ( x, y, width, height ) { + + if ( x.isVector4 ) { + + _scissor.set( x.x, x.y, x.z, x.w ); + + } else { + + _scissor.set( x, y, width, height ); + + } + + state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() ); + + }; + + this.getScissorTest = function () { + + return _scissorTest; + + }; + + this.setScissorTest = function ( boolean ) { + + state.setScissorTest( _scissorTest = boolean ); + + }; + + this.setOpaqueSort = function ( method ) { + + _opaqueSort = method; + + }; + + this.setTransparentSort = function ( method ) { + + _transparentSort = method; + + }; + + // Clearing + + this.getClearColor = function ( target ) { + + return target.copy( background.getClearColor() ); + + }; + + this.setClearColor = function () { + + background.setClearColor.apply( background, arguments ); + + }; + + this.getClearAlpha = function () { + + return background.getClearAlpha(); + + }; + + this.setClearAlpha = function () { + + background.setClearAlpha.apply( background, arguments ); + + }; + + this.clear = function ( color, depth, stencil ) { + + let bits = 0; + + if ( color === undefined || color ) bits |= 16384; + if ( depth === undefined || depth ) bits |= 256; + if ( stencil === undefined || stencil ) bits |= 1024; + + _gl.clear( bits ); + + }; + + this.clearColor = function () { + + this.clear( true, false, false ); + + }; + + this.clearDepth = function () { + + this.clear( false, true, false ); + + }; + + this.clearStencil = function () { + + this.clear( false, false, true ); + + }; + + // + + this.dispose = function () { + + _canvas.removeEventListener( 'webglcontextlost', onContextLost, false ); + _canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false ); + + renderLists.dispose(); + renderStates.dispose(); + properties.dispose(); + cubemaps.dispose(); + cubeuvmaps.dispose(); + objects.dispose(); + bindingStates.dispose(); + programCache.dispose(); + + xr.dispose(); + + xr.removeEventListener( 'sessionstart', onXRSessionStart ); + xr.removeEventListener( 'sessionend', onXRSessionEnd ); + + if ( _transmissionRenderTarget ) { + + _transmissionRenderTarget.dispose(); + _transmissionRenderTarget = null; + + } + + animation.stop(); + + }; + + // Events + + function onContextLost( event ) { + + event.preventDefault(); + + console.log( 'THREE.WebGLRenderer: Context Lost.' ); + + _isContextLost = true; + + } + + function onContextRestore( /* event */ ) { + + console.log( 'THREE.WebGLRenderer: Context Restored.' ); + + _isContextLost = false; + + const infoAutoReset = info.autoReset; + const shadowMapEnabled = shadowMap.enabled; + const shadowMapAutoUpdate = shadowMap.autoUpdate; + const shadowMapNeedsUpdate = shadowMap.needsUpdate; + const shadowMapType = shadowMap.type; + + initGLContext(); + + info.autoReset = infoAutoReset; + shadowMap.enabled = shadowMapEnabled; + shadowMap.autoUpdate = shadowMapAutoUpdate; + shadowMap.needsUpdate = shadowMapNeedsUpdate; + shadowMap.type = shadowMapType; + + } + + function onMaterialDispose( event ) { + + const material = event.target; + + material.removeEventListener( 'dispose', onMaterialDispose ); + + deallocateMaterial( material ); + + } + + // Buffer deallocation + + function deallocateMaterial( material ) { + + releaseMaterialProgramReferences( material ); + + properties.remove( material ); + + } + + + function releaseMaterialProgramReferences( material ) { + + const programs = properties.get( material ).programs; + + if ( programs !== undefined ) { + + programs.forEach( function ( program ) { + + programCache.releaseProgram( program ); + + } ); + + if ( material.isShaderMaterial ) { + + programCache.releaseShaderCache( material ); + + } + + } + + } + + // Buffer rendering + + this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) { + + if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null) + + const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 ); + + const program = setProgram( camera, scene, geometry, material, object ); + + state.setMaterial( material, frontFaceCW ); + + // + + let index = geometry.index; + const position = geometry.attributes.position; + + // + + if ( index === null ) { + + if ( position === undefined || position.count === 0 ) return; + + } else if ( index.count === 0 ) { + + return; + + } + + // + + let rangeFactor = 1; + + if ( material.wireframe === true ) { + + index = geometries.getWireframeAttribute( geometry ); + rangeFactor = 2; + + } + + bindingStates.setup( object, material, program, geometry, index ); + + let attribute; + let renderer = bufferRenderer; + + if ( index !== null ) { + + attribute = attributes.get( index ); + + renderer = indexedBufferRenderer; + renderer.setIndex( attribute ); + + } + + // + + const dataCount = ( index !== null ) ? index.count : position.count; + + const rangeStart = geometry.drawRange.start * rangeFactor; + const rangeCount = geometry.drawRange.count * rangeFactor; + + const groupStart = group !== null ? group.start * rangeFactor : 0; + const groupCount = group !== null ? group.count * rangeFactor : Infinity; + + const drawStart = Math.max( rangeStart, groupStart ); + const drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1; + + const drawCount = Math.max( 0, drawEnd - drawStart + 1 ); + + if ( drawCount === 0 ) return; + + // + + if ( object.isMesh ) { + + if ( material.wireframe === true ) { + + state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() ); + renderer.setMode( 1 ); + + } else { + + renderer.setMode( 4 ); + + } + + } else if ( object.isLine ) { + + let lineWidth = material.linewidth; + + if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material + + state.setLineWidth( lineWidth * getTargetPixelRatio() ); + + if ( object.isLineSegments ) { + + renderer.setMode( 1 ); + + } else if ( object.isLineLoop ) { + + renderer.setMode( 2 ); + + } else { + + renderer.setMode( 3 ); + + } + + } else if ( object.isPoints ) { + + renderer.setMode( 0 ); + + } else if ( object.isSprite ) { + + renderer.setMode( 4 ); + + } + + if ( object.isInstancedMesh ) { + + renderer.renderInstances( drawStart, drawCount, object.count ); + + } else if ( geometry.isInstancedBufferGeometry ) { + + const instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount ); + + renderer.renderInstances( drawStart, drawCount, instanceCount ); + + } else { + + renderer.render( drawStart, drawCount ); + + } + + }; + + // Compile + + this.compile = function ( scene, camera ) { + + currentRenderState = renderStates.get( scene ); + currentRenderState.init(); + + renderStateStack.push( currentRenderState ); + + scene.traverseVisible( function ( object ) { + + if ( object.isLight && object.layers.test( camera.layers ) ) { + + currentRenderState.pushLight( object ); + + if ( object.castShadow ) { + + currentRenderState.pushShadow( object ); + + } + + } + + } ); + + currentRenderState.setupLights( _this.physicallyCorrectLights ); + + scene.traverse( function ( object ) { + + const material = object.material; + + if ( material ) { + + if ( Array.isArray( material ) ) { + + for ( let i = 0; i < material.length; i ++ ) { + + const material2 = material[ i ]; + + getProgram( material2, scene, object ); + + } + + } else { + + getProgram( material, scene, object ); + + } + + } + + } ); + + renderStateStack.pop(); + currentRenderState = null; + + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame( time ) { + + if ( onAnimationFrameCallback ) onAnimationFrameCallback( time ); + + } + + function onXRSessionStart() { + + animation.stop(); + + } + + function onXRSessionEnd() { + + animation.start(); + + } + + const animation = new WebGLAnimation(); + animation.setAnimationLoop( onAnimationFrame ); + + if ( typeof window !== 'undefined' ) animation.setContext( window ); + + this.setAnimationLoop = function ( callback ) { + + onAnimationFrameCallback = callback; + xr.setAnimationLoop( callback ); + + ( callback === null ) ? animation.stop() : animation.start(); + + }; + + xr.addEventListener( 'sessionstart', onXRSessionStart ); + xr.addEventListener( 'sessionend', onXRSessionEnd ); + + // Rendering + + this.render = function ( scene, camera ) { + + if ( camera !== undefined && camera.isCamera !== true ) { + + console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' ); + return; + + } + + if ( _isContextLost === true ) return; + + // update scene graph + + if ( scene.autoUpdate === true ) scene.updateMatrixWorld(); + + // update camera matrices and frustum + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + if ( xr.enabled === true && xr.isPresenting === true ) { + + if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera ); + + camera = xr.getCamera(); // use XR camera for rendering + + } + + // + if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget ); + + currentRenderState = renderStates.get( scene, renderStateStack.length ); + currentRenderState.init(); + + renderStateStack.push( currentRenderState ); + + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); + _frustum.setFromProjectionMatrix( _projScreenMatrix ); + + _localClippingEnabled = this.localClippingEnabled; + _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled, camera ); + + currentRenderList = renderLists.get( scene, renderListStack.length ); + currentRenderList.init(); + + renderListStack.push( currentRenderList ); + + projectObject( scene, camera, 0, _this.sortObjects ); + + currentRenderList.finish(); + + if ( _this.sortObjects === true ) { + + currentRenderList.sort( _opaqueSort, _transparentSort ); + + } + + // + + if ( _clippingEnabled === true ) clipping.beginShadows(); + + const shadowsArray = currentRenderState.state.shadowsArray; + + shadowMap.render( shadowsArray, scene, camera ); + + if ( _clippingEnabled === true ) clipping.endShadows(); + + // + + if ( this.info.autoReset === true ) this.info.reset(); + + // + + background.render( currentRenderList, scene ); + + // render scene + + currentRenderState.setupLights( _this.physicallyCorrectLights ); + + if ( camera.isArrayCamera ) { + + const cameras = camera.cameras; + + for ( let i = 0, l = cameras.length; i < l; i ++ ) { + + const camera2 = cameras[ i ]; + + renderScene( currentRenderList, scene, camera2, camera2.viewport ); + + } + + } else { + + renderScene( currentRenderList, scene, camera ); + + } + + // + + if ( _currentRenderTarget !== null ) { + + // resolve multisample renderbuffers to a single-sample texture if necessary + + textures.updateMultisampleRenderTarget( _currentRenderTarget ); + + // Generate mipmap if we're using any kind of mipmap filtering + + textures.updateRenderTargetMipmap( _currentRenderTarget ); + + } + + // + + if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera ); + + // Ensure depth buffer writing is enabled so it can be cleared on next render + + state.buffers.depth.setTest( true ); + state.buffers.depth.setMask( true ); + state.buffers.color.setMask( true ); + + state.setPolygonOffset( false ); + + // _gl.finish(); + + bindingStates.resetDefaultState(); + _currentMaterialId = - 1; + _currentCamera = null; + + renderStateStack.pop(); + + if ( renderStateStack.length > 0 ) { + + currentRenderState = renderStateStack[ renderStateStack.length - 1 ]; + + } else { + + currentRenderState = null; + + } + + renderListStack.pop(); + + if ( renderListStack.length > 0 ) { + + currentRenderList = renderListStack[ renderListStack.length - 1 ]; + + } else { + + currentRenderList = null; + + } + + }; + + function projectObject( object, camera, groupOrder, sortObjects ) { + + if ( object.visible === false ) return; + + const visible = object.layers.test( camera.layers ); + + if ( visible ) { + + if ( object.isGroup ) { + + groupOrder = object.renderOrder; + + } else if ( object.isLOD ) { + + if ( object.autoUpdate === true ) object.update( camera ); + + } else if ( object.isLight ) { + + currentRenderState.pushLight( object ); + + if ( object.castShadow ) { + + currentRenderState.pushShadow( object ); + + } + + } else if ( object.isSprite ) { + + if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) { + + if ( sortObjects ) { + + _vector3.setFromMatrixPosition( object.matrixWorld ) + .applyMatrix4( _projScreenMatrix ); + + } + + const geometry = objects.update( object ); + const material = object.material; + + if ( material.visible ) { + + currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null ); + + } + + } + + } else if ( object.isMesh || object.isLine || object.isPoints ) { + + if ( object.isSkinnedMesh ) { + + // update skeleton only once in a frame + + if ( object.skeleton.frame !== info.render.frame ) { + + object.skeleton.update(); + object.skeleton.frame = info.render.frame; + + } + + } + + if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) { + + if ( sortObjects ) { + + _vector3.setFromMatrixPosition( object.matrixWorld ) + .applyMatrix4( _projScreenMatrix ); + + } + + const geometry = objects.update( object ); + const material = object.material; + + if ( Array.isArray( material ) ) { + + const groups = geometry.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + if ( groupMaterial && groupMaterial.visible ) { + + currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group ); + + } + + } + + } else if ( material.visible ) { + + currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null ); + + } + + } + + } + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + projectObject( children[ i ], camera, groupOrder, sortObjects ); + + } + + } + + function renderScene( currentRenderList, scene, camera, viewport ) { + + const opaqueObjects = currentRenderList.opaque; + const transmissiveObjects = currentRenderList.transmissive; + const transparentObjects = currentRenderList.transparent; + + currentRenderState.setupLightsView( camera ); + + if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, scene, camera ); + + if ( viewport ) state.viewport( _currentViewport.copy( viewport ) ); + + if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera ); + if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera ); + if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera ); + + } + + function renderTransmissionPass( opaqueObjects, scene, camera ) { + + if ( _transmissionRenderTarget === null ) { + + const needsAntialias = _antialias === true && capabilities.isWebGL2 === true; + const renderTargetType = needsAntialias ? WebGLMultisampleRenderTarget : WebGLRenderTarget; + + _transmissionRenderTarget = new renderTargetType( 1024, 1024, { + generateMipmaps: true, + type: utils.convert( HalfFloatType ) !== null ? HalfFloatType : UnsignedByteType, + minFilter: LinearMipmapLinearFilter, + magFilter: NearestFilter, + wrapS: ClampToEdgeWrapping, + wrapT: ClampToEdgeWrapping, + useRenderToTexture: extensions.has( 'WEBGL_multisampled_render_to_texture' ) + } ); + + } + + const currentRenderTarget = _this.getRenderTarget(); + _this.setRenderTarget( _transmissionRenderTarget ); + _this.clear(); + + // Turn off the features which can affect the frag color for opaque objects pass. + // Otherwise they are applied twice in opaque objects pass and transmission objects pass. + const currentToneMapping = _this.toneMapping; + _this.toneMapping = NoToneMapping; + + renderObjects( opaqueObjects, scene, camera ); + + _this.toneMapping = currentToneMapping; + + textures.updateMultisampleRenderTarget( _transmissionRenderTarget ); + textures.updateRenderTargetMipmap( _transmissionRenderTarget ); + + _this.setRenderTarget( currentRenderTarget ); + + } + + function renderObjects( renderList, scene, camera ) { + + const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null; + + for ( let i = 0, l = renderList.length; i < l; i ++ ) { + + const renderItem = renderList[ i ]; + + const object = renderItem.object; + const geometry = renderItem.geometry; + const material = overrideMaterial === null ? renderItem.material : overrideMaterial; + const group = renderItem.group; + + if ( object.layers.test( camera.layers ) ) { + + renderObject( object, scene, camera, geometry, material, group ); + + } + + } + + } + + function renderObject( object, scene, camera, geometry, material, group ) { + + object.onBeforeRender( _this, scene, camera, geometry, material, group ); + + object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld ); + object.normalMatrix.getNormalMatrix( object.modelViewMatrix ); + + material.onBeforeRender( _this, scene, camera, geometry, object, group ); + + if ( material.transparent === true && material.side === DoubleSide ) { + + material.side = BackSide; + material.needsUpdate = true; + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + material.side = FrontSide; + material.needsUpdate = true; + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + material.side = DoubleSide; + + } else { + + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + } + + object.onAfterRender( _this, scene, camera, geometry, material, group ); + + } + + function getProgram( material, scene, object ) { + + if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + const materialProperties = properties.get( material ); + + const lights = currentRenderState.state.lights; + const shadowsArray = currentRenderState.state.shadowsArray; + + const lightsStateVersion = lights.state.version; + + const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object ); + const programCacheKey = programCache.getProgramCacheKey( parameters ); + + let programs = materialProperties.programs; + + // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change + + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; + materialProperties.fog = scene.fog; + materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment ); + + if ( programs === undefined ) { + + // new material + + material.addEventListener( 'dispose', onMaterialDispose ); + + programs = new Map(); + materialProperties.programs = programs; + + } + + let program = programs.get( programCacheKey ); + + if ( program !== undefined ) { + + // early out if program and light state is identical + + if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) { + + updateCommonMaterialProperties( material, parameters ); + + return program; + + } + + } else { + + parameters.uniforms = programCache.getUniforms( material ); + + material.onBuild( object, parameters, _this ); + + material.onBeforeCompile( parameters, _this ); + + program = programCache.acquireProgram( parameters, programCacheKey ); + programs.set( programCacheKey, program ); + + materialProperties.uniforms = parameters.uniforms; + + } + + const uniforms = materialProperties.uniforms; + + if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) { + + uniforms.clippingPlanes = clipping.uniform; + + } + + updateCommonMaterialProperties( material, parameters ); + + // store the light setup it was created for + + materialProperties.needsLights = materialNeedsLights( material ); + materialProperties.lightsStateVersion = lightsStateVersion; + + if ( materialProperties.needsLights ) { + + // wire up the material to this renderer's lighting state + + uniforms.ambientLightColor.value = lights.state.ambient; + uniforms.lightProbe.value = lights.state.probe; + uniforms.directionalLights.value = lights.state.directional; + uniforms.directionalLightShadows.value = lights.state.directionalShadow; + uniforms.spotLights.value = lights.state.spot; + uniforms.spotLightShadows.value = lights.state.spotShadow; + uniforms.rectAreaLights.value = lights.state.rectArea; + uniforms.ltc_1.value = lights.state.rectAreaLTC1; + uniforms.ltc_2.value = lights.state.rectAreaLTC2; + uniforms.pointLights.value = lights.state.point; + uniforms.pointLightShadows.value = lights.state.pointShadow; + uniforms.hemisphereLights.value = lights.state.hemi; + + uniforms.directionalShadowMap.value = lights.state.directionalShadowMap; + uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix; + uniforms.spotShadowMap.value = lights.state.spotShadowMap; + uniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix; + uniforms.pointShadowMap.value = lights.state.pointShadowMap; + uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix; + // TODO (abelnation): add area lights shadow info to uniforms + + } + + const progUniforms = program.getUniforms(); + const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms ); + + materialProperties.currentProgram = program; + materialProperties.uniformsList = uniformsList; + + return program; + + } + + function updateCommonMaterialProperties( material, parameters ) { + + const materialProperties = properties.get( material ); + + materialProperties.outputEncoding = parameters.outputEncoding; + materialProperties.instancing = parameters.instancing; + materialProperties.skinning = parameters.skinning; + materialProperties.morphTargets = parameters.morphTargets; + materialProperties.morphNormals = parameters.morphNormals; + materialProperties.morphTargetsCount = parameters.morphTargetsCount; + materialProperties.numClippingPlanes = parameters.numClippingPlanes; + materialProperties.numIntersection = parameters.numClipIntersection; + materialProperties.vertexAlphas = parameters.vertexAlphas; + materialProperties.vertexTangents = parameters.vertexTangents; + materialProperties.toneMapping = parameters.toneMapping; + + } + + function setProgram( camera, scene, geometry, material, object ) { + + if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + textures.resetTextureUnits(); + + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding; + const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment ); + const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4; + const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent; + const morphTargets = !! geometry.morphAttributes.position; + const morphNormals = !! geometry.morphAttributes.normal; + const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0; + const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping; + + const materialProperties = properties.get( material ); + const lights = currentRenderState.state.lights; + + if ( _clippingEnabled === true ) { + + if ( _localClippingEnabled === true || camera !== _currentCamera ) { + + const useCache = + camera === _currentCamera && + material.id === _currentMaterialId; + + // we might want to call this function with some ClippingGroup + // object instead of the material, once it becomes feasible + // (#8465, #8379) + clipping.setState( material, camera, useCache ); + + } + + } + + // + + let needsProgramChange = false; + + if ( material.version === materialProperties.__version ) { + + if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) { + + needsProgramChange = true; + + } else if ( materialProperties.outputEncoding !== encoding ) { + + needsProgramChange = true; + + } else if ( object.isInstancedMesh && materialProperties.instancing === false ) { + + needsProgramChange = true; + + } else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) { + + needsProgramChange = true; + + } else if ( object.isSkinnedMesh && materialProperties.skinning === false ) { + + needsProgramChange = true; + + } else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) { + + needsProgramChange = true; + + } else if ( materialProperties.envMap !== envMap ) { + + needsProgramChange = true; + + } else if ( material.fog && materialProperties.fog !== fog ) { + + needsProgramChange = true; + + } else if ( materialProperties.numClippingPlanes !== undefined && + ( materialProperties.numClippingPlanes !== clipping.numPlanes || + materialProperties.numIntersection !== clipping.numIntersection ) ) { + + needsProgramChange = true; + + } else if ( materialProperties.vertexAlphas !== vertexAlphas ) { + + needsProgramChange = true; + + } else if ( materialProperties.vertexTangents !== vertexTangents ) { + + needsProgramChange = true; + + } else if ( materialProperties.morphTargets !== morphTargets ) { + + needsProgramChange = true; + + } else if ( materialProperties.morphNormals !== morphNormals ) { + + needsProgramChange = true; + + } else if ( materialProperties.toneMapping !== toneMapping ) { + + needsProgramChange = true; + + } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) { + + needsProgramChange = true; + + } + + } else { + + needsProgramChange = true; + materialProperties.__version = material.version; + + } + + // + + let program = materialProperties.currentProgram; + + if ( needsProgramChange === true ) { + + program = getProgram( material, scene, object ); + + } + + let refreshProgram = false; + let refreshMaterial = false; + let refreshLights = false; + + const p_uniforms = program.getUniforms(), + m_uniforms = materialProperties.uniforms; + + if ( state.useProgram( program.program ) ) { + + refreshProgram = true; + refreshMaterial = true; + refreshLights = true; + + } + + if ( material.id !== _currentMaterialId ) { + + _currentMaterialId = material.id; + + refreshMaterial = true; + + } + + if ( refreshProgram || _currentCamera !== camera ) { + + p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); + + if ( capabilities.logarithmicDepthBuffer ) { + + p_uniforms.setValue( _gl, 'logDepthBufFC', + 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) ); + + } + + if ( _currentCamera !== camera ) { + + _currentCamera = camera; + + // lighting uniforms depend on the camera so enforce an update + // now, in case this material supports lights - or later, when + // the next material that does gets activated: + + refreshMaterial = true; // set to true on material change + refreshLights = true; // remains set until update done + + } + + // load material specific uniforms + // (shader material also gets them for the sake of genericity) + + if ( material.isShaderMaterial || + material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshStandardMaterial || + material.envMap ) { + + const uCamPos = p_uniforms.map.cameraPosition; + + if ( uCamPos !== undefined ) { + + uCamPos.setValue( _gl, + _vector3.setFromMatrixPosition( camera.matrixWorld ) ); + + } + + } + + if ( material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial ) { + + p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true ); + + } + + if ( material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial || + material.isShadowMaterial || + object.isSkinnedMesh ) { + + p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); + + } + + } + + // skinning and morph target uniforms must be set even if material didn't change + // auto-setting of texture unit for bone and morph texture must go before other textures + // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures + + if ( object.isSkinnedMesh ) { + + p_uniforms.setOptional( _gl, object, 'bindMatrix' ); + p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' ); + + const skeleton = object.skeleton; + + if ( skeleton ) { + + if ( capabilities.floatVertexTextures ) { + + if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture(); + + p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures ); + p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize ); + + } else { + + p_uniforms.setOptional( _gl, skeleton, 'boneMatrices' ); + + } + + } + + } + + if ( !! geometry && ( geometry.morphAttributes.position !== undefined || geometry.morphAttributes.normal !== undefined ) ) { + + morphtargets.update( object, geometry, material, program ); + + } + + + if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) { + + materialProperties.receiveShadow = object.receiveShadow; + p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow ); + + } + + if ( refreshMaterial ) { + + p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure ); + + if ( materialProperties.needsLights ) { + + // the current material requires lighting info + + // note: all lighting uniforms are always set correctly + // they simply reference the renderer's state for their + // values + // + // use the current material's .needsUpdate flags to set + // the GL state when required + + markUniformsLightsNeedsUpdate( m_uniforms, refreshLights ); + + } + + // refresh uniforms common to several materials + + if ( fog && material.fog ) { + + materials.refreshFogUniforms( m_uniforms, fog ); + + } + + materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget ); + + WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures ); + + } + + if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) { + + WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures ); + material.uniformsNeedUpdate = false; + + } + + if ( material.isSpriteMaterial ) { + + p_uniforms.setValue( _gl, 'center', object.center ); + + } + + // common matrices + + p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); + p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); + p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); + + return program; + + } + + // If uniforms are marked as clean, they don't need to be loaded to the GPU. + + function markUniformsLightsNeedsUpdate( uniforms, value ) { + + uniforms.ambientLightColor.needsUpdate = value; + uniforms.lightProbe.needsUpdate = value; + + uniforms.directionalLights.needsUpdate = value; + uniforms.directionalLightShadows.needsUpdate = value; + uniforms.pointLights.needsUpdate = value; + uniforms.pointLightShadows.needsUpdate = value; + uniforms.spotLights.needsUpdate = value; + uniforms.spotLightShadows.needsUpdate = value; + uniforms.rectAreaLights.needsUpdate = value; + uniforms.hemisphereLights.needsUpdate = value; + + } + + function materialNeedsLights( material ) { + + return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || + material.isMeshStandardMaterial || material.isShadowMaterial || + ( material.isShaderMaterial && material.lights === true ); + + } + + this.getActiveCubeFace = function () { + + return _currentActiveCubeFace; + + }; + + this.getActiveMipmapLevel = function () { + + return _currentActiveMipmapLevel; + + }; + + this.getRenderTarget = function () { + + return _currentRenderTarget; + + }; + + this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) { + + properties.get( renderTarget.texture ).__webglTexture = colorTexture; + properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture; + + const renderTargetProperties = properties.get( renderTarget ); + renderTargetProperties.__hasExternalTextures = true; + + if ( renderTargetProperties.__hasExternalTextures ) { + + renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined; + + if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) { + + // The multisample_render_to_texture extension doesn't work properly if there + // are midframe flushes and an external depth buffer. Disable use of the extension. + if ( renderTarget.useRenderToTexture ) { + + console.warn( 'render-to-texture extension was disabled because an external texture was provided' ); + renderTarget.useRenderToTexture = false; + renderTarget.useRenderbuffer = true; + + } + + } + + } + + }; + + this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) { + + const renderTargetProperties = properties.get( renderTarget ); + renderTargetProperties.__webglFramebuffer = defaultFramebuffer; + renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined; + + }; + + this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) { + + _currentRenderTarget = renderTarget; + _currentActiveCubeFace = activeCubeFace; + _currentActiveMipmapLevel = activeMipmapLevel; + let useDefaultFramebuffer = true; + + if ( renderTarget ) { + + const renderTargetProperties = properties.get( renderTarget ); + + if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) { + + // We need to make sure to rebind the framebuffer. + state.bindFramebuffer( 36160, null ); + useDefaultFramebuffer = false; + + } else if ( renderTargetProperties.__webglFramebuffer === undefined ) { + + textures.setupRenderTarget( renderTarget ); + + } else if ( renderTargetProperties.__hasExternalTextures ) { + + // Color and depth texture must be rebound in order for the swapchain to update. + textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture ); + + } + + } + + let framebuffer = null; + let isCube = false; + let isRenderTarget3D = false; + + if ( renderTarget ) { + + const texture = renderTarget.texture; + + if ( texture.isDataTexture3D || texture.isDataTexture2DArray ) { + + isRenderTarget3D = true; + + } + + const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer; + + if ( renderTarget.isWebGLCubeRenderTarget ) { + + framebuffer = __webglFramebuffer[ activeCubeFace ]; + isCube = true; + + } else if ( renderTarget.useRenderbuffer ) { + + framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer; + + } else { + + framebuffer = __webglFramebuffer; + + } + + _currentViewport.copy( renderTarget.viewport ); + _currentScissor.copy( renderTarget.scissor ); + _currentScissorTest = renderTarget.scissorTest; + + } else { + + _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor(); + _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor(); + _currentScissorTest = _scissorTest; + + } + + const framebufferBound = state.bindFramebuffer( 36160, framebuffer ); + + if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) { + + state.drawBuffers( renderTarget, framebuffer ); + + } + + state.viewport( _currentViewport ); + state.scissor( _currentScissor ); + state.setScissorTest( _currentScissorTest ); + + if ( isCube ) { + + const textureProperties = properties.get( renderTarget.texture ); + _gl.framebufferTexture2D( 36160, 36064, 34069 + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel ); + + } else if ( isRenderTarget3D ) { + + const textureProperties = properties.get( renderTarget.texture ); + const layer = activeCubeFace || 0; + _gl.framebufferTextureLayer( 36160, 36064, textureProperties.__webglTexture, activeMipmapLevel || 0, layer ); + + } + + _currentMaterialId = - 1; // reset current material to ensure correct uniform bindings + + }; + + this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) { + + if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' ); + return; + + } + + let framebuffer = properties.get( renderTarget ).__webglFramebuffer; + + if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) { + + framebuffer = framebuffer[ activeCubeFaceIndex ]; + + } + + if ( framebuffer ) { + + state.bindFramebuffer( 36160, framebuffer ); + + try { + + const texture = renderTarget.texture; + const textureFormat = texture.format; + const textureType = texture.type; + + if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( 35739 ) ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' ); + return; + + } + + const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) ); + + if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( 35738 ) && // Edge and Chrome Mac < 52 (#9513) + ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox + ! halfFloatSupportedByExt ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' ); + return; + + } + + if ( _gl.checkFramebufferStatus( 36160 ) === 36053 ) { + + // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604) + + if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) { + + _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer ); + + } + + } else { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' ); + + } + + } finally { + + // restore framebuffer of current render target if necessary + + const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null; + state.bindFramebuffer( 36160, framebuffer ); + + } + + } + + }; + + this.copyFramebufferToTexture = function ( position, texture, level = 0 ) { + + if ( texture.isFramebufferTexture !== true ) { + + console.error( 'THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.' ); + return; + + } + + const levelScale = Math.pow( 2, - level ); + const width = Math.floor( texture.image.width * levelScale ); + const height = Math.floor( texture.image.height * levelScale ); + + textures.setTexture2D( texture, 0 ); + + _gl.copyTexSubImage2D( 3553, level, 0, 0, position.x, position.y, width, height ); + + state.unbindTexture(); + + }; + + this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) { + + const width = srcTexture.image.width; + const height = srcTexture.image.height; + const glFormat = utils.convert( dstTexture.format ); + const glType = utils.convert( dstTexture.type ); + + textures.setTexture2D( dstTexture, 0 ); + + // As another texture upload may have changed pixelStorei + // parameters, make sure they are correct for the dstTexture + _gl.pixelStorei( 37440, dstTexture.flipY ); + _gl.pixelStorei( 37441, dstTexture.premultiplyAlpha ); + _gl.pixelStorei( 3317, dstTexture.unpackAlignment ); + + if ( srcTexture.isDataTexture ) { + + _gl.texSubImage2D( 3553, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); + + } else { + + if ( srcTexture.isCompressedTexture ) { + + _gl.compressedTexSubImage2D( 3553, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data ); + + } else { + + _gl.texSubImage2D( 3553, level, position.x, position.y, glFormat, glType, srcTexture.image ); + + } + + } + + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( 3553 ); + + state.unbindTexture(); + + }; + + this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) { + + if ( _this.isWebGL1Renderer ) { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' ); + return; + + } + + const width = sourceBox.max.x - sourceBox.min.x + 1; + const height = sourceBox.max.y - sourceBox.min.y + 1; + const depth = sourceBox.max.z - sourceBox.min.z + 1; + const glFormat = utils.convert( dstTexture.format ); + const glType = utils.convert( dstTexture.type ); + let glTarget; + + if ( dstTexture.isDataTexture3D ) { + + textures.setTexture3D( dstTexture, 0 ); + glTarget = 32879; + + } else if ( dstTexture.isDataTexture2DArray ) { + + textures.setTexture2DArray( dstTexture, 0 ); + glTarget = 35866; + + } else { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' ); + return; + + } + + _gl.pixelStorei( 37440, dstTexture.flipY ); + _gl.pixelStorei( 37441, dstTexture.premultiplyAlpha ); + _gl.pixelStorei( 3317, dstTexture.unpackAlignment ); + + const unpackRowLen = _gl.getParameter( 3314 ); + const unpackImageHeight = _gl.getParameter( 32878 ); + const unpackSkipPixels = _gl.getParameter( 3316 ); + const unpackSkipRows = _gl.getParameter( 3315 ); + const unpackSkipImages = _gl.getParameter( 32877 ); + + const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image; + + _gl.pixelStorei( 3314, image.width ); + _gl.pixelStorei( 32878, image.height ); + _gl.pixelStorei( 3316, sourceBox.min.x ); + _gl.pixelStorei( 3315, sourceBox.min.y ); + _gl.pixelStorei( 32877, sourceBox.min.z ); + + if ( srcTexture.isDataTexture || srcTexture.isDataTexture3D ) { + + _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data ); + + } else { + + if ( srcTexture.isCompressedTexture ) { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' ); + _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data ); + + } else { + + _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image ); + + } + + } + + _gl.pixelStorei( 3314, unpackRowLen ); + _gl.pixelStorei( 32878, unpackImageHeight ); + _gl.pixelStorei( 3316, unpackSkipPixels ); + _gl.pixelStorei( 3315, unpackSkipRows ); + _gl.pixelStorei( 32877, unpackSkipImages ); + + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget ); + + state.unbindTexture(); + + }; + + this.initTexture = function ( texture ) { + + textures.setTexture2D( texture, 0 ); + + state.unbindTexture(); + + }; + + this.resetState = function () { + + _currentActiveCubeFace = 0; + _currentActiveMipmapLevel = 0; + _currentRenderTarget = null; + + state.reset(); + bindingStates.reset(); + + }; + + if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); + + } + +} + +WebGLRenderer.prototype.isWebGLRenderer = true; + +class Fog { + + constructor( color, near = 1, far = 1000 ) { + + this.name = ''; + + this.color = new Color$1( color ); + + this.near = near; + this.far = far; + + } + + clone() { + + return new Fog( this.color, this.near, this.far ); + + } + + toJSON( /* meta */ ) { + + return { + type: 'Fog', + color: this.color.getHex(), + near: this.near, + far: this.far + }; + + } + +} + +Fog.prototype.isFog = true; + +class Scene extends Object3D { + + constructor() { + + super(); + + this.type = 'Scene'; + + this.background = null; + this.environment = null; + this.fog = null; + + this.overrideMaterial = null; + + this.autoUpdate = true; // checked by the renderer + + if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); + + } + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + if ( source.background !== null ) this.background = source.background.clone(); + if ( source.environment !== null ) this.environment = source.environment.clone(); + if ( source.fog !== null ) this.fog = source.fog.clone(); + + if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone(); + + this.autoUpdate = source.autoUpdate; + this.matrixAutoUpdate = source.matrixAutoUpdate; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + if ( this.fog !== null ) data.object.fog = this.fog.toJSON(); + + return data; + + } + +} + +Scene.prototype.isScene = true; + +class InterleavedBuffer { + + constructor( array, stride ) { + + this.array = array; + this.stride = stride; + this.count = array !== undefined ? array.length / stride : 0; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: - 1 }; + + this.version = 0; + + this.uuid = generateUUID(); + + } + + onUploadCallback() {} + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + + setUsage( value ) { + + this.usage = value; + + return this; + + } + + copy( source ) { + + this.array = new source.array.constructor( source.array ); + this.count = source.count; + this.stride = source.stride; + this.usage = source.usage; + + return this; + + } + + copyAt( index1, attribute, index2 ) { + + index1 *= this.stride; + index2 *= attribute.stride; + + for ( let i = 0, l = this.stride; i < l; i ++ ) { + + this.array[ index1 + i ] = attribute.array[ index2 + i ]; + + } + + return this; + + } + + set( value, offset = 0 ) { + + this.array.set( value, offset ); + + return this; + + } + + clone( data ) { + + if ( data.arrayBuffers === undefined ) { + + data.arrayBuffers = {}; + + } + + if ( this.array.buffer._uuid === undefined ) { + + this.array.buffer._uuid = generateUUID(); + + } + + if ( data.arrayBuffers[ this.array.buffer._uuid ] === undefined ) { + + data.arrayBuffers[ this.array.buffer._uuid ] = this.array.slice( 0 ).buffer; + + } + + const array = new this.array.constructor( data.arrayBuffers[ this.array.buffer._uuid ] ); + + const ib = new this.constructor( array, this.stride ); + ib.setUsage( this.usage ); + + return ib; + + } + + onUpload( callback ) { + + this.onUploadCallback = callback; + + return this; + + } + + toJSON( data ) { + + if ( data.arrayBuffers === undefined ) { + + data.arrayBuffers = {}; + + } + + // generate UUID for array buffer if necessary + + if ( this.array.buffer._uuid === undefined ) { + + this.array.buffer._uuid = generateUUID(); + + } + + if ( data.arrayBuffers[ this.array.buffer._uuid ] === undefined ) { + + data.arrayBuffers[ this.array.buffer._uuid ] = Array.prototype.slice.call( new Uint32Array( this.array.buffer ) ); + + } + + // + + return { + uuid: this.uuid, + buffer: this.array.buffer._uuid, + type: this.array.constructor.name, + stride: this.stride + }; + + } + +} + +InterleavedBuffer.prototype.isInterleavedBuffer = true; + +const _vector$6 = /*@__PURE__*/ new Vector3(); + +class InterleavedBufferAttribute { + + constructor( interleavedBuffer, itemSize, offset, normalized = false ) { + + this.name = ''; + + this.data = interleavedBuffer; + this.itemSize = itemSize; + this.offset = offset; + + this.normalized = normalized === true; + + } + + get count() { + + return this.data.count; + + } + + get array() { + + return this.data.array; + + } + + set needsUpdate( value ) { + + this.data.needsUpdate = value; + + } + + applyMatrix4( m ) { + + for ( let i = 0, l = this.data.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.applyMatrix4( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + applyNormalMatrix( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.applyNormalMatrix( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + transformDirection( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.transformDirection( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + setX( index, x ) { + + this.data.array[ index * this.data.stride + this.offset ] = x; + + return this; + + } + + setY( index, y ) { + + this.data.array[ index * this.data.stride + this.offset + 1 ] = y; + + return this; + + } + + setZ( index, z ) { + + this.data.array[ index * this.data.stride + this.offset + 2 ] = z; + + return this; + + } + + setW( index, w ) { + + this.data.array[ index * this.data.stride + this.offset + 3 ] = w; + + return this; + + } + + getX( index ) { + + return this.data.array[ index * this.data.stride + this.offset ]; + + } + + getY( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 1 ]; + + } + + getZ( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 2 ]; + + } + + getW( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 3 ]; + + } + + setXY( index, x, y ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + + return this; + + } + + setXYZ( index, x, y, z ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + this.data.array[ index + 2 ] = z; + + return this; + + } + + setXYZW( index, x, y, z, w ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + this.data.array[ index + 2 ] = z; + this.data.array[ index + 3 ] = w; + + return this; + + } + + clone( data ) { + + if ( data === undefined ) { + + console.log( 'THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.' ); + + const array = []; + + for ( let i = 0; i < this.count; i ++ ) { + + const index = i * this.data.stride + this.offset; + + for ( let j = 0; j < this.itemSize; j ++ ) { + + array.push( this.data.array[ index + j ] ); + + } + + } + + return new BufferAttribute( new this.array.constructor( array ), this.itemSize, this.normalized ); + + } else { + + if ( data.interleavedBuffers === undefined ) { + + data.interleavedBuffers = {}; + + } + + if ( data.interleavedBuffers[ this.data.uuid ] === undefined ) { + + data.interleavedBuffers[ this.data.uuid ] = this.data.clone( data ); + + } + + return new InterleavedBufferAttribute( data.interleavedBuffers[ this.data.uuid ], this.itemSize, this.offset, this.normalized ); + + } + + } + + toJSON( data ) { + + if ( data === undefined ) { + + console.log( 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.' ); + + const array = []; + + for ( let i = 0; i < this.count; i ++ ) { + + const index = i * this.data.stride + this.offset; + + for ( let j = 0; j < this.itemSize; j ++ ) { + + array.push( this.data.array[ index + j ] ); + + } + + } + + // deinterleave data and save it as an ordinary buffer attribute for now + + return { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: array, + normalized: this.normalized + }; + + } else { + + // save as true interlaved attribtue + + if ( data.interleavedBuffers === undefined ) { + + data.interleavedBuffers = {}; + + } + + if ( data.interleavedBuffers[ this.data.uuid ] === undefined ) { + + data.interleavedBuffers[ this.data.uuid ] = this.data.toJSON( data ); + + } + + return { + isInterleavedBufferAttribute: true, + itemSize: this.itemSize, + data: this.data.uuid, + offset: this.offset, + normalized: this.normalized + }; + + } + + } + +} + +InterleavedBufferAttribute.prototype.isInterleavedBufferAttribute = true; + +/** + * parameters = { + * color: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * rotation: , + * sizeAttenuation: + * } + */ + +class SpriteMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'SpriteMaterial'; + + this.color = new Color$1( 0xffffff ); + + this.map = null; + + this.alphaMap = null; + + this.rotation = 0; + + this.sizeAttenuation = true; + + this.transparent = true; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.rotation = source.rotation; + + this.sizeAttenuation = source.sizeAttenuation; + + return this; + + } + +} + +SpriteMaterial.prototype.isSpriteMaterial = true; + +let _geometry; + +const _intersectPoint = /*@__PURE__*/ new Vector3(); +const _worldScale = /*@__PURE__*/ new Vector3(); +const _mvPosition = /*@__PURE__*/ new Vector3(); + +const _alignedPosition = /*@__PURE__*/ new Vector2(); +const _rotatedPosition = /*@__PURE__*/ new Vector2(); +const _viewWorldMatrix = /*@__PURE__*/ new Matrix4(); + +const _vA = /*@__PURE__*/ new Vector3(); +const _vB = /*@__PURE__*/ new Vector3(); +const _vC = /*@__PURE__*/ new Vector3(); + +const _uvA = /*@__PURE__*/ new Vector2(); +const _uvB = /*@__PURE__*/ new Vector2(); +const _uvC = /*@__PURE__*/ new Vector2(); + +class Sprite extends Object3D { + + constructor( material ) { + + super(); + + this.type = 'Sprite'; + + if ( _geometry === undefined ) { + + _geometry = new BufferGeometry(); + + const float32Array = new Float32Array( [ + - 0.5, - 0.5, 0, 0, 0, + 0.5, - 0.5, 0, 1, 0, + 0.5, 0.5, 0, 1, 1, + - 0.5, 0.5, 0, 0, 1 + ] ); + + const interleavedBuffer = new InterleavedBuffer( float32Array, 5 ); + + _geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] ); + _geometry.setAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) ); + _geometry.setAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) ); + + } + + this.geometry = _geometry; + this.material = ( material !== undefined ) ? material : new SpriteMaterial(); + + this.center = new Vector2( 0.5, 0.5 ); + + } + + raycast( raycaster, intersects ) { + + if ( raycaster.camera === null ) { + + console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' ); + + } + + _worldScale.setFromMatrixScale( this.matrixWorld ); + + _viewWorldMatrix.copy( raycaster.camera.matrixWorld ); + this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld ); + + _mvPosition.setFromMatrixPosition( this.modelViewMatrix ); + + if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { + + _worldScale.multiplyScalar( - _mvPosition.z ); + + } + + const rotation = this.material.rotation; + let sin, cos; + + if ( rotation !== 0 ) { + + cos = Math.cos( rotation ); + sin = Math.sin( rotation ); + + } + + const center = this.center; + + transformVertex( _vA.set( - 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + transformVertex( _vB.set( 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + transformVertex( _vC.set( 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + + _uvA.set( 0, 0 ); + _uvB.set( 1, 0 ); + _uvC.set( 1, 1 ); + + // check first triangle + let intersect = raycaster.ray.intersectTriangle( _vA, _vB, _vC, false, _intersectPoint ); + + if ( intersect === null ) { + + // check second triangle + transformVertex( _vB.set( - 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + _uvB.set( 0, 1 ); + + intersect = raycaster.ray.intersectTriangle( _vA, _vC, _vB, false, _intersectPoint ); + if ( intersect === null ) { + + return; + + } + + } + + const distance = raycaster.ray.origin.distanceTo( _intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + point: _intersectPoint.clone(), + uv: Triangle.getUV( _intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() ), + face: null, + object: this + + } ); + + } + + copy( source ) { + + super.copy( source ); + + if ( source.center !== undefined ) this.center.copy( source.center ); + + this.material = source.material; + + return this; + + } + +} + +Sprite.prototype.isSprite = true; + +function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) { + + // compute position in camera space + _alignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale ); + + // to check if rotation is not zero + if ( sin !== undefined ) { + + _rotatedPosition.x = ( cos * _alignedPosition.x ) - ( sin * _alignedPosition.y ); + _rotatedPosition.y = ( sin * _alignedPosition.x ) + ( cos * _alignedPosition.y ); + + } else { + + _rotatedPosition.copy( _alignedPosition ); + + } + + + vertexPosition.copy( mvPosition ); + vertexPosition.x += _rotatedPosition.x; + vertexPosition.y += _rotatedPosition.y; + + // transform to world space + vertexPosition.applyMatrix4( _viewWorldMatrix ); + +} + +const _basePosition = /*@__PURE__*/ new Vector3(); + +const _skinIndex = /*@__PURE__*/ new Vector4(); +const _skinWeight = /*@__PURE__*/ new Vector4(); + +const _vector$5 = /*@__PURE__*/ new Vector3(); +const _matrix = /*@__PURE__*/ new Matrix4(); + +class SkinnedMesh extends Mesh { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'SkinnedMesh'; + + this.bindMode = 'attached'; + this.bindMatrix = new Matrix4(); + this.bindMatrixInverse = new Matrix4(); + + } + + copy( source ) { + + super.copy( source ); + + this.bindMode = source.bindMode; + this.bindMatrix.copy( source.bindMatrix ); + this.bindMatrixInverse.copy( source.bindMatrixInverse ); + + this.skeleton = source.skeleton; + + return this; + + } + + bind( skeleton, bindMatrix ) { + + this.skeleton = skeleton; + + if ( bindMatrix === undefined ) { + + this.updateMatrixWorld( true ); + + this.skeleton.calculateInverses(); + + bindMatrix = this.matrixWorld; + + } + + this.bindMatrix.copy( bindMatrix ); + this.bindMatrixInverse.copy( bindMatrix ).invert(); + + } + + pose() { + + this.skeleton.pose(); + + } + + normalizeSkinWeights() { + + const vector = new Vector4(); + + const skinWeight = this.geometry.attributes.skinWeight; + + for ( let i = 0, l = skinWeight.count; i < l; i ++ ) { + + vector.x = skinWeight.getX( i ); + vector.y = skinWeight.getY( i ); + vector.z = skinWeight.getZ( i ); + vector.w = skinWeight.getW( i ); + + const scale = 1.0 / vector.manhattanLength(); + + if ( scale !== Infinity ) { + + vector.multiplyScalar( scale ); + + } else { + + vector.set( 1, 0, 0, 0 ); // do something reasonable + + } + + skinWeight.setXYZW( i, vector.x, vector.y, vector.z, vector.w ); + + } + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + if ( this.bindMode === 'attached' ) { + + this.bindMatrixInverse.copy( this.matrixWorld ).invert(); + + } else if ( this.bindMode === 'detached' ) { + + this.bindMatrixInverse.copy( this.bindMatrix ).invert(); + + } else { + + console.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode ); + + } + + } + + boneTransform( index, target ) { + + const skeleton = this.skeleton; + const geometry = this.geometry; + + _skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index ); + _skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index ); + + _basePosition.copy( target ).applyMatrix4( this.bindMatrix ); + + target.set( 0, 0, 0 ); + + for ( let i = 0; i < 4; i ++ ) { + + const weight = _skinWeight.getComponent( i ); + + if ( weight !== 0 ) { + + const boneIndex = _skinIndex.getComponent( i ); + + _matrix.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] ); + + target.addScaledVector( _vector$5.copy( _basePosition ).applyMatrix4( _matrix ), weight ); + + } + + } + + return target.applyMatrix4( this.bindMatrixInverse ); + + } + +} + +SkinnedMesh.prototype.isSkinnedMesh = true; + +class Bone extends Object3D { + + constructor() { + + super(); + + this.type = 'Bone'; + + } + +} + +Bone.prototype.isBone = true; + +class DataTexture extends Texture { + + constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding ) { + + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + + this.image = { data: data, width: width, height: height }; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture.prototype.isDataTexture = true; + +const _offsetMatrix = /*@__PURE__*/ new Matrix4(); +const _identityMatrix = /*@__PURE__*/ new Matrix4(); + +class Skeleton { + + constructor( bones = [], boneInverses = [] ) { + + this.uuid = generateUUID(); + + this.bones = bones.slice( 0 ); + this.boneInverses = boneInverses; + this.boneMatrices = null; + + this.boneTexture = null; + this.boneTextureSize = 0; + + this.frame = - 1; + + this.init(); + + } + + init() { + + const bones = this.bones; + const boneInverses = this.boneInverses; + + this.boneMatrices = new Float32Array( bones.length * 16 ); + + // calculate inverse bone matrices if necessary + + if ( boneInverses.length === 0 ) { + + this.calculateInverses(); + + } else { + + // handle special case + + if ( bones.length !== boneInverses.length ) { + + console.warn( 'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.' ); + + this.boneInverses = []; + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + this.boneInverses.push( new Matrix4() ); + + } + + } + + } + + } + + calculateInverses() { + + this.boneInverses.length = 0; + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const inverse = new Matrix4(); + + if ( this.bones[ i ] ) { + + inverse.copy( this.bones[ i ].matrixWorld ).invert(); + + } + + this.boneInverses.push( inverse ); + + } + + } + + pose() { + + // recover the bind-time world matrices + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone ) { + + bone.matrixWorld.copy( this.boneInverses[ i ] ).invert(); + + } + + } + + // compute the local matrices, positions, rotations and scales + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone ) { + + if ( bone.parent && bone.parent.isBone ) { + + bone.matrix.copy( bone.parent.matrixWorld ).invert(); + bone.matrix.multiply( bone.matrixWorld ); + + } else { + + bone.matrix.copy( bone.matrixWorld ); + + } + + bone.matrix.decompose( bone.position, bone.quaternion, bone.scale ); + + } + + } + + } + + update() { + + const bones = this.bones; + const boneInverses = this.boneInverses; + const boneMatrices = this.boneMatrices; + const boneTexture = this.boneTexture; + + // flatten bone matrices to array + + for ( let i = 0, il = bones.length; i < il; i ++ ) { + + // compute the offset between the current and the original transform + + const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix; + + _offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] ); + _offsetMatrix.toArray( boneMatrices, i * 16 ); + + } + + if ( boneTexture !== null ) { + + boneTexture.needsUpdate = true; + + } + + } + + clone() { + + return new Skeleton( this.bones, this.boneInverses ); + + } + + computeBoneTexture() { + + // layout (1 matrix = 4 pixels) + // RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4) + // with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8) + // 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16) + // 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32) + // 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64) + + let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix + size = ceilPowerOfTwo( size ); + size = Math.max( size, 4 ); + + const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel + boneMatrices.set( this.boneMatrices ); // copy current values + + const boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType ); + boneTexture.needsUpdate = true; + + this.boneMatrices = boneMatrices; + this.boneTexture = boneTexture; + this.boneTextureSize = size; + + return this; + + } + + getBoneByName( name ) { + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone.name === name ) { + + return bone; + + } + + } + + return undefined; + + } + + dispose( ) { + + if ( this.boneTexture !== null ) { + + this.boneTexture.dispose(); + + this.boneTexture = null; + + } + + } + + fromJSON( json, bones ) { + + this.uuid = json.uuid; + + for ( let i = 0, l = json.bones.length; i < l; i ++ ) { + + const uuid = json.bones[ i ]; + let bone = bones[ uuid ]; + + if ( bone === undefined ) { + + console.warn( 'THREE.Skeleton: No bone found with UUID:', uuid ); + bone = new Bone(); + + } + + this.bones.push( bone ); + this.boneInverses.push( new Matrix4().fromArray( json.boneInverses[ i ] ) ); + + } + + this.init(); + + return this; + + } + + toJSON() { + + const data = { + metadata: { + version: 4.5, + type: 'Skeleton', + generator: 'Skeleton.toJSON' + }, + bones: [], + boneInverses: [] + }; + + data.uuid = this.uuid; + + const bones = this.bones; + const boneInverses = this.boneInverses; + + for ( let i = 0, l = bones.length; i < l; i ++ ) { + + const bone = bones[ i ]; + data.bones.push( bone.uuid ); + + const boneInverse = boneInverses[ i ]; + data.boneInverses.push( boneInverse.toArray() ); + + } + + return data; + + } + +} + +/** + * parameters = { + * color: , + * opacity: , + * + * linewidth: , + * linecap: "round", + * linejoin: "round" + * } + */ + +class LineBasicMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'LineBasicMaterial'; + + this.color = new Color$1( 0xffffff ); + + this.linewidth = 1; + this.linecap = 'round'; + this.linejoin = 'round'; + + this.setValues( parameters ); + + } + + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.linewidth = source.linewidth; + this.linecap = source.linecap; + this.linejoin = source.linejoin; + + return this; + + } + +} + +LineBasicMaterial.prototype.isLineBasicMaterial = true; + +const _start$1 = /*@__PURE__*/ new Vector3(); +const _end$1 = /*@__PURE__*/ new Vector3(); +const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4(); +const _ray$1 = /*@__PURE__*/ new Ray(); +const _sphere$1 = /*@__PURE__*/ new Sphere(); + +class Line extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) { + + super(); + + this.type = 'Line'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + computeLineDistances() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + // we assume non-indexed geometry + + if ( geometry.index === null ) { + + const positionAttribute = geometry.attributes.position; + const lineDistances = [ 0 ]; + + for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) { + + _start$1.fromBufferAttribute( positionAttribute, i - 1 ); + _end$1.fromBufferAttribute( positionAttribute, i ); + + lineDistances[ i ] = lineDistances[ i - 1 ]; + lineDistances[ i ] += _start$1.distanceTo( _end$1 ); + + } + + geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); + + } else { + + console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + return this; + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Line.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$1.copy( geometry.boundingSphere ); + _sphere$1.applyMatrix4( matrixWorld ); + _sphere$1.radius += threshold; + + if ( raycaster.ray.intersectsSphere( _sphere$1 ) === false ) return; + + // + + _inverseMatrix$1.copy( matrixWorld ).invert(); + _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 ); + + const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + const localThresholdSq = localThreshold * localThreshold; + + const vStart = new Vector3(); + const vEnd = new Vector3(); + const interSegment = new Vector3(); + const interRay = new Vector3(); + const step = this.isLineSegments ? 2 : 1; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if ( index !== null ) { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end - 1; i < l; i += step ) { + + const a = index.getX( i ); + const b = index.getX( i + 1 ); + + vStart.fromBufferAttribute( positionAttribute, a ); + vEnd.fromBufferAttribute( positionAttribute, b ); + + const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); + + if ( distSq > localThresholdSq ) continue; + + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo( interRay ); + + if ( distance < raycaster.near || distance > raycaster.far ) continue; + + intersects.push( { + + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), + index: i, + face: null, + faceIndex: null, + object: this + + } ); + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end - 1; i < l; i += step ) { + + vStart.fromBufferAttribute( positionAttribute, i ); + vEnd.fromBufferAttribute( positionAttribute, i + 1 ); + + const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); + + if ( distSq > localThresholdSq ) continue; + + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo( interRay ); + + if ( distance < raycaster.near || distance > raycaster.far ) continue; + + intersects.push( { + + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), + index: i, + face: null, + faceIndex: null, + object: this + + } ); + + } + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + +} + +Line.prototype.isLine = true; + +const _start = /*@__PURE__*/ new Vector3(); +const _end = /*@__PURE__*/ new Vector3(); + +class LineSegments extends Line { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'LineSegments'; + + } + + computeLineDistances() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + // we assume non-indexed geometry + + if ( geometry.index === null ) { + + const positionAttribute = geometry.attributes.position; + const lineDistances = []; + + for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) { + + _start.fromBufferAttribute( positionAttribute, i ); + _end.fromBufferAttribute( positionAttribute, i + 1 ); + + lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ]; + lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end ); + + } + + geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); + + } else { + + console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + return this; + + } + +} + +LineSegments.prototype.isLineSegments = true; + +class LineLoop extends Line { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'LineLoop'; + + } + +} + +LineLoop.prototype.isLineLoop = true; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * + * size: , + * sizeAttenuation: + * + * } + */ + +class PointsMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'PointsMaterial'; + + this.color = new Color$1( 0xffffff ); + + this.map = null; + + this.alphaMap = null; + + this.size = 1; + this.sizeAttenuation = true; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.size = source.size; + this.sizeAttenuation = source.sizeAttenuation; + + return this; + + } + +} + +PointsMaterial.prototype.isPointsMaterial = true; + +const _inverseMatrix = /*@__PURE__*/ new Matrix4(); +const _ray = /*@__PURE__*/ new Ray(); +const _sphere = /*@__PURE__*/ new Sphere(); +const _position$2 = /*@__PURE__*/ new Vector3(); + +class Points extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new PointsMaterial() ) { + + super(); + + this.type = 'Points'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Points.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere.copy( geometry.boundingSphere ); + _sphere.applyMatrix4( matrixWorld ); + _sphere.radius += threshold; + + if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return; + + // + + _inverseMatrix.copy( matrixWorld ).invert(); + _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix ); + + const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + const localThresholdSq = localThreshold * localThreshold; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if ( index !== null ) { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i ++ ) { + + const a = index.getX( i ); + + _position$2.fromBufferAttribute( positionAttribute, a ); + + testPoint( _position$2, a, localThresholdSq, matrixWorld, raycaster, intersects, this ); + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end; i < l; i ++ ) { + + _position$2.fromBufferAttribute( positionAttribute, i ); + + testPoint( _position$2, i, localThresholdSq, matrixWorld, raycaster, intersects, this ); + + } + + } + + } else { + + console.error( 'THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + +} + +Points.prototype.isPoints = true; + +function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) { + + const rayPointDistanceSq = _ray.distanceSqToPoint( point ); + + if ( rayPointDistanceSq < localThresholdSq ) { + + const intersectPoint = new Vector3(); + + _ray.closestPointToPoint( point, intersectPoint ); + intersectPoint.applyMatrix4( matrixWorld ); + + const distance = raycaster.ray.origin.distanceTo( intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + distanceToRay: Math.sqrt( rayPointDistanceSq ), + point: intersectPoint, + index: index, + face: null, + object: object + + } ); + + } + +} + +class PolyhedronGeometry extends BufferGeometry { + + constructor( vertices = [], indices = [], radius = 1, detail = 0 ) { + + super(); + + this.type = 'PolyhedronGeometry'; + + this.parameters = { + vertices: vertices, + indices: indices, + radius: radius, + detail: detail + }; + + // default buffer data + + const vertexBuffer = []; + const uvBuffer = []; + + // the subdivision creates the vertex buffer data + + subdivide( detail ); + + // all vertices should lie on a conceptual sphere with a given radius + + applyRadius( radius ); + + // finally, create the uv data + + generateUVs(); + + // build non-indexed geometry + + this.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) ); + + if ( detail === 0 ) { + + this.computeVertexNormals(); // flat normals + + } else { + + this.normalizeNormals(); // smooth normals + + } + + // helper functions + + function subdivide( detail ) { + + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + // iterate over all faces and apply a subdivison with the given detail value + + for ( let i = 0; i < indices.length; i += 3 ) { + + // get the vertices of the face + + getVertexByIndex( indices[ i + 0 ], a ); + getVertexByIndex( indices[ i + 1 ], b ); + getVertexByIndex( indices[ i + 2 ], c ); + + // perform subdivision + + subdivideFace( a, b, c, detail ); + + } + + } + + function subdivideFace( a, b, c, detail ) { + + const cols = detail + 1; + + // we use this multidimensional array as a data structure for creating the subdivision + + const v = []; + + // construct all of the vertices for this subdivision + + for ( let i = 0; i <= cols; i ++ ) { + + v[ i ] = []; + + const aj = a.clone().lerp( c, i / cols ); + const bj = b.clone().lerp( c, i / cols ); + + const rows = cols - i; + + for ( let j = 0; j <= rows; j ++ ) { + + if ( j === 0 && i === cols ) { + + v[ i ][ j ] = aj; + + } else { + + v[ i ][ j ] = aj.clone().lerp( bj, j / rows ); + + } + + } + + } + + // construct all of the faces + + for ( let i = 0; i < cols; i ++ ) { + + for ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) { + + const k = Math.floor( j / 2 ); + + if ( j % 2 === 0 ) { + + pushVertex( v[ i ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k ] ); + pushVertex( v[ i ][ k ] ); + + } else { + + pushVertex( v[ i ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k ] ); + + } + + } + + } + + } + + function applyRadius( radius ) { + + const vertex = new Vector3(); + + // iterate over the entire buffer and apply the radius to each vertex + + for ( let i = 0; i < vertexBuffer.length; i += 3 ) { + + vertex.x = vertexBuffer[ i + 0 ]; + vertex.y = vertexBuffer[ i + 1 ]; + vertex.z = vertexBuffer[ i + 2 ]; + + vertex.normalize().multiplyScalar( radius ); + + vertexBuffer[ i + 0 ] = vertex.x; + vertexBuffer[ i + 1 ] = vertex.y; + vertexBuffer[ i + 2 ] = vertex.z; + + } + + } + + function generateUVs() { + + const vertex = new Vector3(); + + for ( let i = 0; i < vertexBuffer.length; i += 3 ) { + + vertex.x = vertexBuffer[ i + 0 ]; + vertex.y = vertexBuffer[ i + 1 ]; + vertex.z = vertexBuffer[ i + 2 ]; + + const u = azimuth( vertex ) / 2 / Math.PI + 0.5; + const v = inclination( vertex ) / Math.PI + 0.5; + uvBuffer.push( u, 1 - v ); + + } + + correctUVs(); + + correctSeam(); + + } + + function correctSeam() { + + // handle case when face straddles the seam, see #3269 + + for ( let i = 0; i < uvBuffer.length; i += 6 ) { + + // uv data of a single face + + const x0 = uvBuffer[ i + 0 ]; + const x1 = uvBuffer[ i + 2 ]; + const x2 = uvBuffer[ i + 4 ]; + + const max = Math.max( x0, x1, x2 ); + const min = Math.min( x0, x1, x2 ); + + // 0.9 is somewhat arbitrary + + if ( max > 0.9 && min < 0.1 ) { + + if ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1; + if ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1; + if ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1; + + } + + } + + } + + function pushVertex( vertex ) { + + vertexBuffer.push( vertex.x, vertex.y, vertex.z ); + + } + + function getVertexByIndex( index, vertex ) { + + const stride = index * 3; + + vertex.x = vertices[ stride + 0 ]; + vertex.y = vertices[ stride + 1 ]; + vertex.z = vertices[ stride + 2 ]; + + } + + function correctUVs() { + + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + const centroid = new Vector3(); + + const uvA = new Vector2(); + const uvB = new Vector2(); + const uvC = new Vector2(); + + for ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) { + + a.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] ); + b.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] ); + c.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] ); + + uvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] ); + uvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] ); + uvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] ); + + centroid.copy( a ).add( b ).add( c ).divideScalar( 3 ); + + const azi = azimuth( centroid ); + + correctUV( uvA, j + 0, a, azi ); + correctUV( uvB, j + 2, b, azi ); + correctUV( uvC, j + 4, c, azi ); + + } + + } + + function correctUV( uv, stride, vector, azimuth ) { + + if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) { + + uvBuffer[ stride ] = uv.x - 1; + + } + + if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) { + + uvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5; + + } + + } + + // Angle around the Y axis, counter-clockwise when looking from above. + + function azimuth( vector ) { + + return Math.atan2( vector.z, - vector.x ); + + } + + + // Angle above the XZ plane. + + function inclination( vector ) { + + return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) ); + + } + + } + + static fromJSON( data ) { + + return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details ); + + } + +} + +class IcosahedronGeometry extends PolyhedronGeometry { + + constructor( radius = 1, detail = 0 ) { + + const t = ( 1 + Math.sqrt( 5 ) ) / 2; + + const vertices = [ + - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0, + 0, - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, + t, 0, - 1, t, 0, 1, - t, 0, - 1, - t, 0, 1 + ]; + + const indices = [ + 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, + 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, + 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, + 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 + ]; + + super( vertices, indices, radius, detail ); + + this.type = 'IcosahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail + }; + + } + + static fromJSON( data ) { + + return new IcosahedronGeometry( data.radius, data.detail ); + + } + +} + +/** + * parameters = { + * color: , + * roughness: , + * metalness: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * roughnessMap: new THREE.Texture( ), + * + * metalnessMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * envMapIntensity: + * + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * flatShading: + * } + */ + +class MeshStandardMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.defines = { 'STANDARD': '' }; + + this.type = 'MeshStandardMaterial'; + + this.color = new Color$1( 0xffffff ); // diffuse + this.roughness = 1.0; + this.metalness = 0.0; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color$1( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.roughnessMap = null; + + this.metalnessMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.envMapIntensity = 1.0; + + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.flatShading = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.defines = { 'STANDARD': '' }; + + this.color.copy( source.color ); + this.roughness = source.roughness; + this.metalness = source.metalness; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.roughnessMap = source.roughnessMap; + + this.metalnessMap = source.metalnessMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.envMapIntensity = source.envMapIntensity; + + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.flatShading = source.flatShading; + + return this; + + } + +} + +MeshStandardMaterial.prototype.isMeshStandardMaterial = true; + +/** + * parameters = { + * clearcoat: , + * clearcoatMap: new THREE.Texture( ), + * clearcoatRoughness: , + * clearcoatRoughnessMap: new THREE.Texture( ), + * clearcoatNormalScale: , + * clearcoatNormalMap: new THREE.Texture( ), + * + * ior: , + * reflectivity: , + * + * sheen: , + * sheenColor: , + * sheenColorMap: new THREE.Texture( ), + * sheenRoughness: , + * sheenRoughnessMap: new THREE.Texture( ), + * + * transmission: , + * transmissionMap: new THREE.Texture( ), + * + * thickness: , + * thicknessMap: new THREE.Texture( ), + * attenuationDistance: , + * attenuationColor: , + * + * specularIntensity: , + * specularIntensityMap: new THREE.Texture( ), + * specularColor: , + * specularColorMap: new THREE.Texture( ) + * } + */ + +class MeshPhysicalMaterial extends MeshStandardMaterial { + + constructor( parameters ) { + + super(); + + this.defines = { + + 'STANDARD': '', + 'PHYSICAL': '' + + }; + + this.type = 'MeshPhysicalMaterial'; + + this.clearcoatMap = null; + this.clearcoatRoughness = 0.0; + this.clearcoatRoughnessMap = null; + this.clearcoatNormalScale = new Vector2( 1, 1 ); + this.clearcoatNormalMap = null; + + this.ior = 1.5; + + Object.defineProperty( this, 'reflectivity', { + get: function () { + + return ( clamp( 2.5 * ( this.ior - 1 ) / ( this.ior + 1 ), 0, 1 ) ); + + }, + set: function ( reflectivity ) { + + this.ior = ( 1 + 0.4 * reflectivity ) / ( 1 - 0.4 * reflectivity ); + + } + } ); + + this.sheenColor = new Color$1( 0x000000 ); + this.sheenColorMap = null; + this.sheenRoughness = 1.0; + this.sheenRoughnessMap = null; + + this.transmissionMap = null; + + this.thickness = 0; + this.thicknessMap = null; + this.attenuationDistance = 0.0; + this.attenuationColor = new Color$1( 1, 1, 1 ); + + this.specularIntensity = 1.0; + this.specularIntensityMap = null; + this.specularColor = new Color$1( 1, 1, 1 ); + this.specularColorMap = null; + + this._sheen = 0.0; + this._clearcoat = 0; + this._transmission = 0; + + this.setValues( parameters ); + + } + + get sheen() { + + return this._sheen; + + } + + set sheen( value ) { + + if ( this._sheen > 0 !== value > 0 ) { + + this.version ++; + + } + + this._sheen = value; + + } + + get clearcoat() { + + return this._clearcoat; + + } + + set clearcoat( value ) { + + if ( this._clearcoat > 0 !== value > 0 ) { + + this.version ++; + + } + + this._clearcoat = value; + + } + + get transmission() { + + return this._transmission; + + } + + set transmission( value ) { + + if ( this._transmission > 0 !== value > 0 ) { + + this.version ++; + + } + + this._transmission = value; + + } + + copy( source ) { + + super.copy( source ); + + this.defines = { + + 'STANDARD': '', + 'PHYSICAL': '' + + }; + + this.clearcoat = source.clearcoat; + this.clearcoatMap = source.clearcoatMap; + this.clearcoatRoughness = source.clearcoatRoughness; + this.clearcoatRoughnessMap = source.clearcoatRoughnessMap; + this.clearcoatNormalMap = source.clearcoatNormalMap; + this.clearcoatNormalScale.copy( source.clearcoatNormalScale ); + + this.ior = source.ior; + + this.sheen = source.sheen; + this.sheenColor.copy( source.sheenColor ); + this.sheenColorMap = source.sheenColorMap; + this.sheenRoughness = source.sheenRoughness; + this.sheenRoughnessMap = source.sheenRoughnessMap; + + this.transmission = source.transmission; + this.transmissionMap = source.transmissionMap; + + this.thickness = source.thickness; + this.thicknessMap = source.thicknessMap; + this.attenuationDistance = source.attenuationDistance; + this.attenuationColor.copy( source.attenuationColor ); + + this.specularIntensity = source.specularIntensity; + this.specularIntensityMap = source.specularIntensityMap; + this.specularColor.copy( source.specularColor ); + this.specularColorMap = source.specularColorMap; + + return this; + + } + +} + +MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true; + +const AnimationUtils = { + + // same as Array.prototype.slice, but also works on typed arrays + arraySlice: function ( array, from, to ) { + + if ( AnimationUtils.isTypedArray( array ) ) { + + // in ios9 array.subarray(from, undefined) will return empty array + // but array.subarray(from) or array.subarray(from, len) is correct + return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) ); + + } + + return array.slice( from, to ); + + }, + + // converts an array to a specific type + convertArray: function ( array, type, forceClone ) { + + if ( ! array || // let 'undefined' and 'null' pass + ! forceClone && array.constructor === type ) return array; + + if ( typeof type.BYTES_PER_ELEMENT === 'number' ) { + + return new type( array ); // create typed array + + } + + return Array.prototype.slice.call( array ); // create Array + + }, + + isTypedArray: function ( object ) { + + return ArrayBuffer.isView( object ) && + ! ( object instanceof DataView ); + + }, + + // returns an array by which times and values can be sorted + getKeyframeOrder: function ( times ) { + + function compareTime( i, j ) { + + return times[ i ] - times[ j ]; + + } + + const n = times.length; + const result = new Array( n ); + for ( let i = 0; i !== n; ++ i ) result[ i ] = i; + + result.sort( compareTime ); + + return result; + + }, + + // uses the array previously returned by 'getKeyframeOrder' to sort data + sortedArray: function ( values, stride, order ) { + + const nValues = values.length; + const result = new values.constructor( nValues ); + + for ( let i = 0, dstOffset = 0; dstOffset !== nValues; ++ i ) { + + const srcOffset = order[ i ] * stride; + + for ( let j = 0; j !== stride; ++ j ) { + + result[ dstOffset ++ ] = values[ srcOffset + j ]; + + } + + } + + return result; + + }, + + // function for parsing AOS keyframe formats + flattenJSON: function ( jsonKeys, times, values, valuePropertyName ) { + + let i = 1, key = jsonKeys[ 0 ]; + + while ( key !== undefined && key[ valuePropertyName ] === undefined ) { + + key = jsonKeys[ i ++ ]; + + } + + if ( key === undefined ) return; // no data + + let value = key[ valuePropertyName ]; + if ( value === undefined ) return; // no data + + if ( Array.isArray( value ) ) { + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + values.push.apply( values, value ); // push all elements + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } else if ( value.toArray !== undefined ) { + + // ...assume THREE.Math-ish + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + value.toArray( values, values.length ); + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } else { + + // otherwise push as-is + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + values.push( value ); + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } + + }, + + subclip: function ( sourceClip, name, startFrame, endFrame, fps = 30 ) { + + const clip = sourceClip.clone(); + + clip.name = name; + + const tracks = []; + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + const track = clip.tracks[ i ]; + const valueSize = track.getValueSize(); + + const times = []; + const values = []; + + for ( let j = 0; j < track.times.length; ++ j ) { + + const frame = track.times[ j ] * fps; + + if ( frame < startFrame || frame >= endFrame ) continue; + + times.push( track.times[ j ] ); + + for ( let k = 0; k < valueSize; ++ k ) { + + values.push( track.values[ j * valueSize + k ] ); + + } + + } + + if ( times.length === 0 ) continue; + + track.times = AnimationUtils.convertArray( times, track.times.constructor ); + track.values = AnimationUtils.convertArray( values, track.values.constructor ); + + tracks.push( track ); + + } + + clip.tracks = tracks; + + // find minimum .times value across all tracks in the trimmed clip + + let minStartTime = Infinity; + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + if ( minStartTime > clip.tracks[ i ].times[ 0 ] ) { + + minStartTime = clip.tracks[ i ].times[ 0 ]; + + } + + } + + // shift all tracks such that clip begins at t=0 + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + clip.tracks[ i ].shift( - 1 * minStartTime ); + + } + + clip.resetDuration(); + + return clip; + + }, + + makeClipAdditive: function ( targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30 ) { + + if ( fps <= 0 ) fps = 30; + + const numTracks = referenceClip.tracks.length; + const referenceTime = referenceFrame / fps; + + // Make each track's values relative to the values at the reference frame + for ( let i = 0; i < numTracks; ++ i ) { + + const referenceTrack = referenceClip.tracks[ i ]; + const referenceTrackType = referenceTrack.ValueTypeName; + + // Skip this track if it's non-numeric + if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) continue; + + // Find the track in the target clip whose name and type matches the reference track + const targetTrack = targetClip.tracks.find( function ( track ) { + + return track.name === referenceTrack.name + && track.ValueTypeName === referenceTrackType; + + } ); + + if ( targetTrack === undefined ) continue; + + let referenceOffset = 0; + const referenceValueSize = referenceTrack.getValueSize(); + + if ( referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { + + referenceOffset = referenceValueSize / 3; + + } + + let targetOffset = 0; + const targetValueSize = targetTrack.getValueSize(); + + if ( targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { + + targetOffset = targetValueSize / 3; + + } + + const lastIndex = referenceTrack.times.length - 1; + let referenceValue; + + // Find the value to subtract out of the track + if ( referenceTime <= referenceTrack.times[ 0 ] ) { + + // Reference frame is earlier than the first keyframe, so just use the first keyframe + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); + + } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { + + // Reference frame is after the last keyframe, so just use the last keyframe + const startIndex = lastIndex * referenceValueSize + referenceOffset; + const endIndex = startIndex + referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); + + } else { + + // Interpolate to the reference value + const interpolant = referenceTrack.createInterpolant(); + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + interpolant.evaluate( referenceTime ); + referenceValue = AnimationUtils.arraySlice( interpolant.resultBuffer, startIndex, endIndex ); + + } + + // Conjugate the quaternion + if ( referenceTrackType === 'quaternion' ) { + + const referenceQuat = new Quaternion().fromArray( referenceValue ).normalize().conjugate(); + referenceQuat.toArray( referenceValue ); + + } + + // Subtract the reference value from all of the track values + + const numTimes = targetTrack.times.length; + for ( let j = 0; j < numTimes; ++ j ) { + + const valueStart = j * targetValueSize + targetOffset; + + if ( referenceTrackType === 'quaternion' ) { + + // Multiply the conjugate for quaternion track types + Quaternion.multiplyQuaternionsFlat( + targetTrack.values, + valueStart, + referenceValue, + 0, + targetTrack.values, + valueStart + ); + + } else { + + const valueEnd = targetValueSize - targetOffset * 2; + + // Subtract each value for all other numeric track types + for ( let k = 0; k < valueEnd; ++ k ) { + + targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; + + } + + } + + } + + } + + targetClip.blendMode = AdditiveAnimationBlendMode; + + return targetClip; + + } + +}; + +/** + * Abstract base class of interpolants over parametric samples. + * + * The parameter domain is one dimensional, typically the time or a path + * along a curve defined by the data. + * + * The sample values can have any dimensionality and derived classes may + * apply special interpretations to the data. + * + * This class provides the interval seek in a Template Method, deferring + * the actual interpolation to derived classes. + * + * Time complexity is O(1) for linear access crossing at most two points + * and O(log N) for random access, where N is the number of positions. + * + * References: + * + * http://www.oodesign.com/template-method-pattern.html + * + */ + +class Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + this.parameterPositions = parameterPositions; + this._cachedIndex = 0; + + this.resultBuffer = resultBuffer !== undefined ? + resultBuffer : new sampleValues.constructor( sampleSize ); + this.sampleValues = sampleValues; + this.valueSize = sampleSize; + + this.settings = null; + this.DefaultSettings_ = {}; + + } + + evaluate( t ) { + + const pp = this.parameterPositions; + let i1 = this._cachedIndex, + t1 = pp[ i1 ], + t0 = pp[ i1 - 1 ]; + + validate_interval: { + + seek: { + + let right; + + linear_scan: { + + //- See http://jsperf.com/comparison-to-undefined/3 + //- slower code: + //- + //- if ( t >= t1 || t1 === undefined ) { + forward_scan: if ( ! ( t < t1 ) ) { + + for ( let giveUpAt = i1 + 2; ; ) { + + if ( t1 === undefined ) { + + if ( t < t0 ) break forward_scan; + + // after end + + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t, t0 ); + + } + + if ( i1 === giveUpAt ) break; // this loop + + t0 = t1; + t1 = pp[ ++ i1 ]; + + if ( t < t1 ) { + + // we have arrived at the sought interval + break seek; + + } + + } + + // prepare binary search on the right side of the index + right = pp.length; + break linear_scan; + + } + + //- slower code: + //- if ( t < t0 || t0 === undefined ) { + if ( ! ( t >= t0 ) ) { + + // looping? + + const t1global = pp[ 1 ]; + + if ( t < t1global ) { + + i1 = 2; // + 1, using the scan for the details + t0 = t1global; + + } + + // linear reverse scan + + for ( let giveUpAt = i1 - 2; ; ) { + + if ( t0 === undefined ) { + + // before start + + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); + + } + + if ( i1 === giveUpAt ) break; // this loop + + t1 = t0; + t0 = pp[ -- i1 - 1 ]; + + if ( t >= t0 ) { + + // we have arrived at the sought interval + break seek; + + } + + } + + // prepare binary search on the left side of the index + right = i1; + i1 = 0; + break linear_scan; + + } + + // the interval is valid + + break validate_interval; + + } // linear scan + + // binary search + + while ( i1 < right ) { + + const mid = ( i1 + right ) >>> 1; + + if ( t < pp[ mid ] ) { + + right = mid; + + } else { + + i1 = mid + 1; + + } + + } + + t1 = pp[ i1 ]; + t0 = pp[ i1 - 1 ]; + + // check boundary cases, again + + if ( t0 === undefined ) { + + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); + + } + + if ( t1 === undefined ) { + + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t0, t ); + + } + + } // seek + + this._cachedIndex = i1; + + this.intervalChanged_( i1, t0, t1 ); + + } // validate_interval + + return this.interpolate_( i1, t0, t, t1 ); + + } + + getSettings_() { + + return this.settings || this.DefaultSettings_; + + } + + copySampleValue_( index ) { + + // copies a sample value to the result buffer + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + offset = index * stride; + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = values[ offset + i ]; + + } + + return result; + + } + + // Template methods for derived classes: + + interpolate_( /* i1, t0, t, t1 */ ) { + + throw new Error( 'call to abstract method' ); + // implementations shall return this.resultBuffer + + } + + intervalChanged_( /* i1, t0, t1 */ ) { + + // empty + + } + +} + +// ALIAS DEFINITIONS + +Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_; +Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_; + +/** + * Fast and simple cubic spline interpolant. + * + * It was derived from a Hermitian construction setting the first derivative + * at each sample position to the linear slope between neighboring positions + * over their parameter interval. + */ + +class CubicInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + this._weightPrev = - 0; + this._offsetPrev = - 0; + this._weightNext = - 0; + this._offsetNext = - 0; + + this.DefaultSettings_ = { + + endingStart: ZeroCurvatureEnding, + endingEnd: ZeroCurvatureEnding + + }; + + } + + intervalChanged_( i1, t0, t1 ) { + + const pp = this.parameterPositions; + let iPrev = i1 - 2, + iNext = i1 + 1, + + tPrev = pp[ iPrev ], + tNext = pp[ iNext ]; + + if ( tPrev === undefined ) { + + switch ( this.getSettings_().endingStart ) { + + case ZeroSlopeEnding: + + // f'(t0) = 0 + iPrev = i1; + tPrev = 2 * t0 - t1; + + break; + + case WrapAroundEnding: + + // use the other end of the curve + iPrev = pp.length - 2; + tPrev = t0 + pp[ iPrev ] - pp[ iPrev + 1 ]; + + break; + + default: // ZeroCurvatureEnding + + // f''(t0) = 0 a.k.a. Natural Spline + iPrev = i1; + tPrev = t1; + + } + + } + + if ( tNext === undefined ) { + + switch ( this.getSettings_().endingEnd ) { + + case ZeroSlopeEnding: + + // f'(tN) = 0 + iNext = i1; + tNext = 2 * t1 - t0; + + break; + + case WrapAroundEnding: + + // use the other end of the curve + iNext = 1; + tNext = t1 + pp[ 1 ] - pp[ 0 ]; + + break; + + default: // ZeroCurvatureEnding + + // f''(tN) = 0, a.k.a. Natural Spline + iNext = i1 - 1; + tNext = t0; + + } + + } + + const halfDt = ( t1 - t0 ) * 0.5, + stride = this.valueSize; + + this._weightPrev = halfDt / ( t0 - tPrev ); + this._weightNext = halfDt / ( tNext - t1 ); + this._offsetPrev = iPrev * stride; + this._offsetNext = iNext * stride; + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + o1 = i1 * stride, o0 = o1 - stride, + oP = this._offsetPrev, oN = this._offsetNext, + wP = this._weightPrev, wN = this._weightNext, + + p = ( t - t0 ) / ( t1 - t0 ), + pp = p * p, + ppp = pp * p; + + // evaluate polynomials + + const sP = - wP * ppp + 2 * wP * pp - wP * p; + const s0 = ( 1 + wP ) * ppp + ( - 1.5 - 2 * wP ) * pp + ( - 0.5 + wP ) * p + 1; + const s1 = ( - 1 - wN ) * ppp + ( 1.5 + wN ) * pp + 0.5 * p; + const sN = wN * ppp - wN * pp; + + // combine data linearly + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = + sP * values[ oP + i ] + + s0 * values[ o0 + i ] + + s1 * values[ o1 + i ] + + sN * values[ oN + i ]; + + } + + return result; + + } + +} + +class LinearInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + offset1 = i1 * stride, + offset0 = offset1 - stride, + + weight1 = ( t - t0 ) / ( t1 - t0 ), + weight0 = 1 - weight1; + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = + values[ offset0 + i ] * weight0 + + values[ offset1 + i ] * weight1; + + } + + return result; + + } + +} + +/** + * + * Interpolant that evaluates to the sample value at the position preceeding + * the parameter. + */ + +class DiscreteInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1 /*, t0, t, t1 */ ) { + + return this.copySampleValue_( i1 - 1 ); + + } + +} + +class KeyframeTrack { + + constructor( name, times, values, interpolation ) { + + if ( name === undefined ) throw new Error( 'THREE.KeyframeTrack: track name is undefined' ); + if ( times === undefined || times.length === 0 ) throw new Error( 'THREE.KeyframeTrack: no keyframes in track named ' + name ); + + this.name = name; + + this.times = AnimationUtils.convertArray( times, this.TimeBufferType ); + this.values = AnimationUtils.convertArray( values, this.ValueBufferType ); + + this.setInterpolation( interpolation || this.DefaultInterpolation ); + + } + + // Serialization (in static context, because of constructor invocation + // and automatic invocation of .toJSON): + + static toJSON( track ) { + + const trackType = track.constructor; + + let json; + + // derived classes can define a static toJSON method + if ( trackType.toJSON !== this.toJSON ) { + + json = trackType.toJSON( track ); + + } else { + + // by default, we assume the data can be serialized as-is + json = { + + 'name': track.name, + 'times': AnimationUtils.convertArray( track.times, Array ), + 'values': AnimationUtils.convertArray( track.values, Array ) + + }; + + const interpolation = track.getInterpolation(); + + if ( interpolation !== track.DefaultInterpolation ) { + + json.interpolation = interpolation; + + } + + } + + json.type = track.ValueTypeName; // mandatory + + return json; + + } + + InterpolantFactoryMethodDiscrete( result ) { + + return new DiscreteInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + InterpolantFactoryMethodLinear( result ) { + + return new LinearInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + InterpolantFactoryMethodSmooth( result ) { + + return new CubicInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + setInterpolation( interpolation ) { + + let factoryMethod; + + switch ( interpolation ) { + + case InterpolateDiscrete: + + factoryMethod = this.InterpolantFactoryMethodDiscrete; + + break; + + case InterpolateLinear: + + factoryMethod = this.InterpolantFactoryMethodLinear; + + break; + + case InterpolateSmooth: + + factoryMethod = this.InterpolantFactoryMethodSmooth; + + break; + + } + + if ( factoryMethod === undefined ) { + + const message = 'unsupported interpolation for ' + + this.ValueTypeName + ' keyframe track named ' + this.name; + + if ( this.createInterpolant === undefined ) { + + // fall back to default, unless the default itself is messed up + if ( interpolation !== this.DefaultInterpolation ) { + + this.setInterpolation( this.DefaultInterpolation ); + + } else { + + throw new Error( message ); // fatal, in this case + + } + + } + + console.warn( 'THREE.KeyframeTrack:', message ); + return this; + + } + + this.createInterpolant = factoryMethod; + + return this; + + } + + getInterpolation() { + + switch ( this.createInterpolant ) { + + case this.InterpolantFactoryMethodDiscrete: + + return InterpolateDiscrete; + + case this.InterpolantFactoryMethodLinear: + + return InterpolateLinear; + + case this.InterpolantFactoryMethodSmooth: + + return InterpolateSmooth; + + } + + } + + getValueSize() { + + return this.values.length / this.times.length; + + } + + // move all keyframes either forwards or backwards in time + shift( timeOffset ) { + + if ( timeOffset !== 0.0 ) { + + const times = this.times; + + for ( let i = 0, n = times.length; i !== n; ++ i ) { + + times[ i ] += timeOffset; + + } + + } + + return this; + + } + + // scale all keyframe times by a factor (useful for frame <-> seconds conversions) + scale( timeScale ) { + + if ( timeScale !== 1.0 ) { + + const times = this.times; + + for ( let i = 0, n = times.length; i !== n; ++ i ) { + + times[ i ] *= timeScale; + + } + + } + + return this; + + } + + // removes keyframes before and after animation without changing any values within the range [startTime, endTime]. + // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values + trim( startTime, endTime ) { + + const times = this.times, + nKeys = times.length; + + let from = 0, + to = nKeys - 1; + + while ( from !== nKeys && times[ from ] < startTime ) { + + ++ from; + + } + + while ( to !== - 1 && times[ to ] > endTime ) { + + -- to; + + } + + ++ to; // inclusive -> exclusive bound + + if ( from !== 0 || to !== nKeys ) { + + // empty tracks are forbidden, so keep at least one keyframe + if ( from >= to ) { + + to = Math.max( to, 1 ); + from = to - 1; + + } + + const stride = this.getValueSize(); + this.times = AnimationUtils.arraySlice( times, from, to ); + this.values = AnimationUtils.arraySlice( this.values, from * stride, to * stride ); + + } + + return this; + + } + + // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable + validate() { + + let valid = true; + + const valueSize = this.getValueSize(); + if ( valueSize - Math.floor( valueSize ) !== 0 ) { + + console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this ); + valid = false; + + } + + const times = this.times, + values = this.values, + + nKeys = times.length; + + if ( nKeys === 0 ) { + + console.error( 'THREE.KeyframeTrack: Track is empty.', this ); + valid = false; + + } + + let prevTime = null; + + for ( let i = 0; i !== nKeys; i ++ ) { + + const currTime = times[ i ]; + + if ( typeof currTime === 'number' && isNaN( currTime ) ) { + + console.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime ); + valid = false; + break; + + } + + if ( prevTime !== null && prevTime > currTime ) { + + console.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime ); + valid = false; + break; + + } + + prevTime = currTime; + + } + + if ( values !== undefined ) { + + if ( AnimationUtils.isTypedArray( values ) ) { + + for ( let i = 0, n = values.length; i !== n; ++ i ) { + + const value = values[ i ]; + + if ( isNaN( value ) ) { + + console.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value ); + valid = false; + break; + + } + + } + + } + + } + + return valid; + + } + + // removes equivalent sequential keys as common in morph target sequences + // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) + optimize() { + + // times or values may be shared with other tracks, so overwriting is unsafe + const times = AnimationUtils.arraySlice( this.times ), + values = AnimationUtils.arraySlice( this.values ), + stride = this.getValueSize(), + + smoothInterpolation = this.getInterpolation() === InterpolateSmooth, + + lastIndex = times.length - 1; + + let writeIndex = 1; + + for ( let i = 1; i < lastIndex; ++ i ) { + + let keep = false; + + const time = times[ i ]; + const timeNext = times[ i + 1 ]; + + // remove adjacent keyframes scheduled at the same time + + if ( time !== timeNext && ( i !== 1 || time !== times[ 0 ] ) ) { + + if ( ! smoothInterpolation ) { + + // remove unnecessary keyframes same as their neighbors + + const offset = i * stride, + offsetP = offset - stride, + offsetN = offset + stride; + + for ( let j = 0; j !== stride; ++ j ) { + + const value = values[ offset + j ]; + + if ( value !== values[ offsetP + j ] || + value !== values[ offsetN + j ] ) { + + keep = true; + break; + + } + + } + + } else { + + keep = true; + + } + + } + + // in-place compaction + + if ( keep ) { + + if ( i !== writeIndex ) { + + times[ writeIndex ] = times[ i ]; + + const readOffset = i * stride, + writeOffset = writeIndex * stride; + + for ( let j = 0; j !== stride; ++ j ) { + + values[ writeOffset + j ] = values[ readOffset + j ]; + + } + + } + + ++ writeIndex; + + } + + } + + // flush last keyframe (compaction looks ahead) + + if ( lastIndex > 0 ) { + + times[ writeIndex ] = times[ lastIndex ]; + + for ( let readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j ) { + + values[ writeOffset + j ] = values[ readOffset + j ]; + + } + + ++ writeIndex; + + } + + if ( writeIndex !== times.length ) { + + this.times = AnimationUtils.arraySlice( times, 0, writeIndex ); + this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride ); + + } else { + + this.times = times; + this.values = values; + + } + + return this; + + } + + clone() { + + const times = AnimationUtils.arraySlice( this.times, 0 ); + const values = AnimationUtils.arraySlice( this.values, 0 ); + + const TypedKeyframeTrack = this.constructor; + const track = new TypedKeyframeTrack( this.name, times, values ); + + // Interpolant argument to constructor is not saved, so copy the factory method directly. + track.createInterpolant = this.createInterpolant; + + return track; + + } + +} + +KeyframeTrack.prototype.TimeBufferType = Float32Array; +KeyframeTrack.prototype.ValueBufferType = Float32Array; +KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; + +/** + * A Track of Boolean keyframe values. + */ +class BooleanKeyframeTrack extends KeyframeTrack {} + +BooleanKeyframeTrack.prototype.ValueTypeName = 'bool'; +BooleanKeyframeTrack.prototype.ValueBufferType = Array; +BooleanKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track of keyframe values that represent color. + */ +class ColorKeyframeTrack extends KeyframeTrack {} + +ColorKeyframeTrack.prototype.ValueTypeName = 'color'; + +/** + * A Track of numeric keyframe values. + */ +class NumberKeyframeTrack extends KeyframeTrack {} + +NumberKeyframeTrack.prototype.ValueTypeName = 'number'; + +/** + * Spherical linear unit quaternion interpolant. + */ + +class QuaternionLinearInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + alpha = ( t - t0 ) / ( t1 - t0 ); + + let offset = i1 * stride; + + for ( let end = offset + stride; offset !== end; offset += 4 ) { + + Quaternion.slerpFlat( result, 0, values, offset - stride, values, offset, alpha ); + + } + + return result; + + } + +} + +/** + * A Track of quaternion keyframe values. + */ +class QuaternionKeyframeTrack extends KeyframeTrack { + + InterpolantFactoryMethodLinear( result ) { + + return new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + +} + +QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion'; +// ValueBufferType is inherited +QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; +QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track that interpolates Strings + */ +class StringKeyframeTrack extends KeyframeTrack {} + +StringKeyframeTrack.prototype.ValueTypeName = 'string'; +StringKeyframeTrack.prototype.ValueBufferType = Array; +StringKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track of vectored keyframe values. + */ +class VectorKeyframeTrack extends KeyframeTrack {} + +VectorKeyframeTrack.prototype.ValueTypeName = 'vector'; + +class AnimationClip { + + constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) { + + this.name = name; + this.tracks = tracks; + this.duration = duration; + this.blendMode = blendMode; + + this.uuid = generateUUID(); + + // this means it should figure out its duration by scanning the tracks + if ( this.duration < 0 ) { + + this.resetDuration(); + + } + + } + + + static parse( json ) { + + const tracks = [], + jsonTracks = json.tracks, + frameTime = 1.0 / ( json.fps || 1.0 ); + + for ( let i = 0, n = jsonTracks.length; i !== n; ++ i ) { + + tracks.push( parseKeyframeTrack( jsonTracks[ i ] ).scale( frameTime ) ); + + } + + const clip = new this( json.name, json.duration, tracks, json.blendMode ); + clip.uuid = json.uuid; + + return clip; + + } + + static toJSON( clip ) { + + const tracks = [], + clipTracks = clip.tracks; + + const json = { + + 'name': clip.name, + 'duration': clip.duration, + 'tracks': tracks, + 'uuid': clip.uuid, + 'blendMode': clip.blendMode + + }; + + for ( let i = 0, n = clipTracks.length; i !== n; ++ i ) { + + tracks.push( KeyframeTrack.toJSON( clipTracks[ i ] ) ); + + } + + return json; + + } + + static CreateFromMorphTargetSequence( name, morphTargetSequence, fps, noLoop ) { + + const numMorphTargets = morphTargetSequence.length; + const tracks = []; + + for ( let i = 0; i < numMorphTargets; i ++ ) { + + let times = []; + let values = []; + + times.push( + ( i + numMorphTargets - 1 ) % numMorphTargets, + i, + ( i + 1 ) % numMorphTargets ); + + values.push( 0, 1, 0 ); + + const order = AnimationUtils.getKeyframeOrder( times ); + times = AnimationUtils.sortedArray( times, 1, order ); + values = AnimationUtils.sortedArray( values, 1, order ); + + // if there is a key at the first frame, duplicate it as the + // last frame as well for perfect loop. + if ( ! noLoop && times[ 0 ] === 0 ) { + + times.push( numMorphTargets ); + values.push( values[ 0 ] ); + + } + + tracks.push( + new NumberKeyframeTrack( + '.morphTargetInfluences[' + morphTargetSequence[ i ].name + ']', + times, values + ).scale( 1.0 / fps ) ); + + } + + return new this( name, - 1, tracks ); + + } + + static findByName( objectOrClipArray, name ) { + + let clipArray = objectOrClipArray; + + if ( ! Array.isArray( objectOrClipArray ) ) { + + const o = objectOrClipArray; + clipArray = o.geometry && o.geometry.animations || o.animations; + + } + + for ( let i = 0; i < clipArray.length; i ++ ) { + + if ( clipArray[ i ].name === name ) { + + return clipArray[ i ]; + + } + + } + + return null; + + } + + static CreateClipsFromMorphTargetSequences( morphTargets, fps, noLoop ) { + + const animationToMorphTargets = {}; + + // tested with https://regex101.com/ on trick sequences + // such flamingo_flyA_003, flamingo_run1_003, crdeath0059 + const pattern = /^([\w-]*?)([\d]+)$/; + + // sort morph target names into animation groups based + // patterns like Walk_001, Walk_002, Run_001, Run_002 + for ( let i = 0, il = morphTargets.length; i < il; i ++ ) { + + const morphTarget = morphTargets[ i ]; + const parts = morphTarget.name.match( pattern ); + + if ( parts && parts.length > 1 ) { + + const name = parts[ 1 ]; + + let animationMorphTargets = animationToMorphTargets[ name ]; + + if ( ! animationMorphTargets ) { + + animationToMorphTargets[ name ] = animationMorphTargets = []; + + } + + animationMorphTargets.push( morphTarget ); + + } + + } + + const clips = []; + + for ( const name in animationToMorphTargets ) { + + clips.push( this.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps, noLoop ) ); + + } + + return clips; + + } + + // parse the animation.hierarchy format + static parseAnimation( animation, bones ) { + + if ( ! animation ) { + + console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' ); + return null; + + } + + const addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) { + + // only return track if there are actually keys. + if ( animationKeys.length !== 0 ) { + + const times = []; + const values = []; + + AnimationUtils.flattenJSON( animationKeys, times, values, propertyName ); + + // empty keys are filtered out, so check again + if ( times.length !== 0 ) { + + destTracks.push( new trackType( trackName, times, values ) ); + + } + + } + + }; + + const tracks = []; + + const clipName = animation.name || 'default'; + const fps = animation.fps || 30; + const blendMode = animation.blendMode; + + // automatic length determination in AnimationClip. + let duration = animation.length || - 1; + + const hierarchyTracks = animation.hierarchy || []; + + for ( let h = 0; h < hierarchyTracks.length; h ++ ) { + + const animationKeys = hierarchyTracks[ h ].keys; + + // skip empty tracks + if ( ! animationKeys || animationKeys.length === 0 ) continue; + + // process morph targets + if ( animationKeys[ 0 ].morphTargets ) { + + // figure out all morph targets used in this track + const morphTargetNames = {}; + + let k; + + for ( k = 0; k < animationKeys.length; k ++ ) { + + if ( animationKeys[ k ].morphTargets ) { + + for ( let m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) { + + morphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1; + + } + + } + + } + + // create a track for each morph target with all zero + // morphTargetInfluences except for the keys in which + // the morphTarget is named. + for ( const morphTargetName in morphTargetNames ) { + + const times = []; + const values = []; + + for ( let m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) { + + const animationKey = animationKeys[ k ]; + + times.push( animationKey.time ); + values.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 ); + + } + + tracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) ); + + } + + duration = morphTargetNames.length * ( fps || 1.0 ); + + } else { + + // ...assume skeletal animation + + const boneName = '.bones[' + bones[ h ].name + ']'; + + addNonemptyTrack( + VectorKeyframeTrack, boneName + '.position', + animationKeys, 'pos', tracks ); + + addNonemptyTrack( + QuaternionKeyframeTrack, boneName + '.quaternion', + animationKeys, 'rot', tracks ); + + addNonemptyTrack( + VectorKeyframeTrack, boneName + '.scale', + animationKeys, 'scl', tracks ); + + } + + } + + if ( tracks.length === 0 ) { + + return null; + + } + + const clip = new this( clipName, duration, tracks, blendMode ); + + return clip; + + } + + resetDuration() { + + const tracks = this.tracks; + let duration = 0; + + for ( let i = 0, n = tracks.length; i !== n; ++ i ) { + + const track = this.tracks[ i ]; + + duration = Math.max( duration, track.times[ track.times.length - 1 ] ); + + } + + this.duration = duration; + + return this; + + } + + trim() { + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + this.tracks[ i ].trim( 0, this.duration ); + + } + + return this; + + } + + validate() { + + let valid = true; + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + valid = valid && this.tracks[ i ].validate(); + + } + + return valid; + + } + + optimize() { + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + this.tracks[ i ].optimize(); + + } + + return this; + + } + + clone() { + + const tracks = []; + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + tracks.push( this.tracks[ i ].clone() ); + + } + + return new this.constructor( this.name, this.duration, tracks, this.blendMode ); + + } + + toJSON() { + + return this.constructor.toJSON( this ); + + } + +} + +function getTrackTypeForValueTypeName( typeName ) { + + switch ( typeName.toLowerCase() ) { + + case 'scalar': + case 'double': + case 'float': + case 'number': + case 'integer': + + return NumberKeyframeTrack; + + case 'vector': + case 'vector2': + case 'vector3': + case 'vector4': + + return VectorKeyframeTrack; + + case 'color': + + return ColorKeyframeTrack; + + case 'quaternion': + + return QuaternionKeyframeTrack; + + case 'bool': + case 'boolean': + + return BooleanKeyframeTrack; + + case 'string': + + return StringKeyframeTrack; + + } + + throw new Error( 'THREE.KeyframeTrack: Unsupported typeName: ' + typeName ); + +} + +function parseKeyframeTrack( json ) { + + if ( json.type === undefined ) { + + throw new Error( 'THREE.KeyframeTrack: track type undefined, can not parse' ); + + } + + const trackType = getTrackTypeForValueTypeName( json.type ); + + if ( json.times === undefined ) { + + const times = [], values = []; + + AnimationUtils.flattenJSON( json.keys, times, values, 'value' ); + + json.times = times; + json.values = values; + + } + + // derived classes can define a static parse method + if ( trackType.parse !== undefined ) { + + return trackType.parse( json ); + + } else { + + // by default, we assume a constructor compatible with the base + return new trackType( json.name, json.times, json.values, json.interpolation ); + + } + +} + +const Cache = { + + enabled: false, + + files: {}, + + add: function ( key, file ) { + + if ( this.enabled === false ) return; + + // console.log( 'THREE.Cache', 'Adding key:', key ); + + this.files[ key ] = file; + + }, + + get: function ( key ) { + + if ( this.enabled === false ) return; + + // console.log( 'THREE.Cache', 'Checking key:', key ); + + return this.files[ key ]; + + }, + + remove: function ( key ) { + + delete this.files[ key ]; + + }, + + clear: function () { + + this.files = {}; + + } + +}; + +class LoadingManager { + + constructor( onLoad, onProgress, onError ) { + + const scope = this; + + let isLoading = false; + let itemsLoaded = 0; + let itemsTotal = 0; + let urlModifier = undefined; + const handlers = []; + + // Refer to #5689 for the reason why we don't set .onStart + // in the constructor + + this.onStart = undefined; + this.onLoad = onLoad; + this.onProgress = onProgress; + this.onError = onError; + + this.itemStart = function ( url ) { + + itemsTotal ++; + + if ( isLoading === false ) { + + if ( scope.onStart !== undefined ) { + + scope.onStart( url, itemsLoaded, itemsTotal ); + + } + + } + + isLoading = true; + + }; + + this.itemEnd = function ( url ) { + + itemsLoaded ++; + + if ( scope.onProgress !== undefined ) { + + scope.onProgress( url, itemsLoaded, itemsTotal ); + + } + + if ( itemsLoaded === itemsTotal ) { + + isLoading = false; + + if ( scope.onLoad !== undefined ) { + + scope.onLoad(); + + } + + } + + }; + + this.itemError = function ( url ) { + + if ( scope.onError !== undefined ) { + + scope.onError( url ); + + } + + }; + + this.resolveURL = function ( url ) { + + if ( urlModifier ) { + + return urlModifier( url ); + + } + + return url; + + }; + + this.setURLModifier = function ( transform ) { + + urlModifier = transform; + + return this; + + }; + + this.addHandler = function ( regex, loader ) { + + handlers.push( regex, loader ); + + return this; + + }; + + this.removeHandler = function ( regex ) { + + const index = handlers.indexOf( regex ); + + if ( index !== - 1 ) { + + handlers.splice( index, 2 ); + + } + + return this; + + }; + + this.getHandler = function ( file ) { + + for ( let i = 0, l = handlers.length; i < l; i += 2 ) { + + const regex = handlers[ i ]; + const loader = handlers[ i + 1 ]; + + if ( regex.global ) regex.lastIndex = 0; // see #17920 + + if ( regex.test( file ) ) { + + return loader; + + } + + } + + return null; + + }; + + } + +} + +const DefaultLoadingManager = new LoadingManager(); + +class Loader { + + constructor( manager ) { + + this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + + this.crossOrigin = 'anonymous'; + this.withCredentials = false; + this.path = ''; + this.resourcePath = ''; + this.requestHeader = {}; + + } + + load( /* url, onLoad, onProgress, onError */ ) {} + + loadAsync( url, onProgress ) { + + const scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.load( url, resolve, onProgress, reject ); + + } ); + + } + + parse( /* data */ ) {} + + setCrossOrigin( crossOrigin ) { + + this.crossOrigin = crossOrigin; + return this; + + } + + setWithCredentials( value ) { + + this.withCredentials = value; + return this; + + } + + setPath( path ) { + + this.path = path; + return this; + + } + + setResourcePath( resourcePath ) { + + this.resourcePath = resourcePath; + return this; + + } + + setRequestHeader( requestHeader ) { + + this.requestHeader = requestHeader; + return this; + + } + +} + +const loading = {}; + +class FileLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + if ( url === undefined ) url = ''; + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + this.manager.itemStart( url ); + + setTimeout( () => { + + if ( onLoad ) onLoad( cached ); + + this.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + // Check if request is duplicate + + if ( loading[ url ] !== undefined ) { + + loading[ url ].push( { + + onLoad: onLoad, + onProgress: onProgress, + onError: onError + + } ); + + return; + + } + + // Initialise array for duplicate requests + loading[ url ] = []; + + loading[ url ].push( { + onLoad: onLoad, + onProgress: onProgress, + onError: onError, + } ); + + // create request + const req = new Request( url, { + headers: new Headers( this.requestHeader ), + credentials: this.withCredentials ? 'include' : 'same-origin', + // An abort controller could be added within a future PR + } ); + + // start the fetch + fetch( req ) + .then( response => { + + if ( response.status === 200 || response.status === 0 ) { + + // Some browsers return HTTP Status 0 when using non-http protocol + // e.g. 'file://' or 'data://'. Handle as success. + + if ( response.status === 0 ) { + + console.warn( 'THREE.FileLoader: HTTP Status 0 received.' ); + + } + + if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) { + + return response; + + } + + const callbacks = loading[ url ]; + const reader = response.body.getReader(); + const contentLength = response.headers.get( 'Content-Length' ); + const total = contentLength ? parseInt( contentLength ) : 0; + const lengthComputable = total !== 0; + let loaded = 0; + + // periodically read data into the new stream tracking while download progress + const stream = new ReadableStream( { + start( controller ) { + + readData(); + + function readData() { + + reader.read().then( ( { done, value } ) => { + + if ( done ) { + + controller.close(); + + } else { + + loaded += value.byteLength; + + const event = new ProgressEvent( 'progress', { lengthComputable, loaded, total } ); + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onProgress ) callback.onProgress( event ); + + } + + controller.enqueue( value ); + readData(); + + } + + } ); + + } + + } + + } ); + + return new Response( stream ); + + } else { + + throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` ); + + } + + } ) + .then( response => { + + switch ( this.responseType ) { + + case 'arraybuffer': + + return response.arrayBuffer(); + + case 'blob': + + return response.blob(); + + case 'document': + + return response.text() + .then( text => { + + const parser = new DOMParser(); + return parser.parseFromString( text, this.mimeType ); + + } ); + + case 'json': + + return response.json(); + + default: + + return response.text(); + + } + + } ) + .then( data => { + + // Add to cache only on HTTP success, so that we do not cache + // error response bodies as proper responses to requests. + Cache.add( url, data ); + + const callbacks = loading[ url ]; + delete loading[ url ]; + + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onLoad ) callback.onLoad( data ); + + } + + } ) + .catch( err => { + + // Abort errors and other errors are handled the same + + const callbacks = loading[ url ]; + + if ( callbacks === undefined ) { + + // When onLoad was called and url was deleted in `loading` + this.manager.itemError( url ); + throw err; + + } + + delete loading[ url ]; + + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onError ) callback.onError( err ); + + } + + this.manager.itemError( url ); + + } ) + .finally( () => { + + this.manager.itemEnd( url ); + + } ); + + this.manager.itemStart( url ); + + } + + setResponseType( value ) { + + this.responseType = value; + return this; + + } + + setMimeType( value ) { + + this.mimeType = value; + return this; + + } + +} + +class ImageLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const scope = this; + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + scope.manager.itemStart( url ); + + setTimeout( function () { + + if ( onLoad ) onLoad( cached ); + + scope.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + const image = createElementNS( 'img' ); + + function onImageLoad() { + + removeEventListeners(); + + Cache.add( url, this ); + + if ( onLoad ) onLoad( this ); + + scope.manager.itemEnd( url ); + + } + + function onImageError( event ) { + + removeEventListeners(); + + if ( onError ) onError( event ); + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + } + + function removeEventListeners() { + + image.removeEventListener( 'load', onImageLoad, false ); + image.removeEventListener( 'error', onImageError, false ); + + } + + image.addEventListener( 'load', onImageLoad, false ); + image.addEventListener( 'error', onImageError, false ); + + if ( url.substr( 0, 5 ) !== 'data:' ) { + + if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin; + + } + + scope.manager.itemStart( url ); + + image.src = url; + + return image; + + } + +} + +class CubeTextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( urls, onLoad, onProgress, onError ) { + + const texture = new CubeTexture(); + + const loader = new ImageLoader( this.manager ); + loader.setCrossOrigin( this.crossOrigin ); + loader.setPath( this.path ); + + let loaded = 0; + + function loadTexture( i ) { + + loader.load( urls[ i ], function ( image ) { + + texture.images[ i ] = image; + + loaded ++; + + if ( loaded === 6 ) { + + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture ); + + } + + }, undefined, onError ); + + } + + for ( let i = 0; i < urls.length; ++ i ) { + + loadTexture( i ); + + } + + return texture; + + } + +} + +/** + * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...) + * + * Sub classes have to implement the parse() method which will be used in load(). + */ + +class DataTextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const texture = new DataTexture(); + + const loader = new FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setPath( this.path ); + loader.setWithCredentials( scope.withCredentials ); + loader.load( url, function ( buffer ) { + + const texData = scope.parse( buffer ); + + if ( ! texData ) return; + + if ( texData.image !== undefined ) { + + texture.image = texData.image; + + } else if ( texData.data !== undefined ) { + + texture.image.width = texData.width; + texture.image.height = texData.height; + texture.image.data = texData.data; + + } + + texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping; + texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping; + + texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter; + texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter; + + texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1; + + if ( texData.encoding !== undefined ) { + + texture.encoding = texData.encoding; + + } + + if ( texData.flipY !== undefined ) { + + texture.flipY = texData.flipY; + + } + + if ( texData.format !== undefined ) { + + texture.format = texData.format; + + } + + if ( texData.type !== undefined ) { + + texture.type = texData.type; + + } + + if ( texData.mipmaps !== undefined ) { + + texture.mipmaps = texData.mipmaps; + texture.minFilter = LinearMipmapLinearFilter; // presumably... + + } + + if ( texData.mipmapCount === 1 ) { + + texture.minFilter = LinearFilter; + + } + + if ( texData.generateMipmaps !== undefined ) { + + texture.generateMipmaps = texData.generateMipmaps; + + } + + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture, texData ); + + }, onProgress, onError ); + + + return texture; + + } + +} + +class TextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const texture = new Texture(); + + const loader = new ImageLoader( this.manager ); + loader.setCrossOrigin( this.crossOrigin ); + loader.setPath( this.path ); + + loader.load( url, function ( image ) { + + texture.image = image; + texture.needsUpdate = true; + + if ( onLoad !== undefined ) { + + onLoad( texture ); + + } + + }, onProgress, onError ); + + return texture; + + } + +} + +class Light extends Object3D { + + constructor( color, intensity = 1 ) { + + super(); + + this.type = 'Light'; + + this.color = new Color$1( color ); + this.intensity = intensity; + + } + + dispose() { + + // Empty here in base class; some subclasses override. + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + this.intensity = source.intensity; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.color = this.color.getHex(); + data.object.intensity = this.intensity; + + if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex(); + + if ( this.distance !== undefined ) data.object.distance = this.distance; + if ( this.angle !== undefined ) data.object.angle = this.angle; + if ( this.decay !== undefined ) data.object.decay = this.decay; + if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra; + + if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON(); + + return data; + + } + +} + +Light.prototype.isLight = true; + +const _projScreenMatrix$1 = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld$1 = /*@__PURE__*/ new Vector3(); +const _lookTarget$1 = /*@__PURE__*/ new Vector3(); + +class LightShadow { + + constructor( camera ) { + + this.camera = camera; + + this.bias = 0; + this.normalBias = 0; + this.radius = 1; + this.blurSamples = 8; + + this.mapSize = new Vector2( 512, 512 ); + + this.map = null; + this.mapPass = null; + this.matrix = new Matrix4(); + + this.autoUpdate = true; + this.needsUpdate = false; + + this._frustum = new Frustum(); + this._frameExtents = new Vector2( 1, 1 ); + + this._viewportCount = 1; + + this._viewports = [ + + new Vector4( 0, 0, 1, 1 ) + + ]; + + } + + getViewportCount() { + + return this._viewportCount; + + } + + getFrustum() { + + return this._frustum; + + } + + updateMatrices( light ) { + + const shadowCamera = this.camera; + const shadowMatrix = this.matrix; + + _lightPositionWorld$1.setFromMatrixPosition( light.matrixWorld ); + shadowCamera.position.copy( _lightPositionWorld$1 ); + + _lookTarget$1.setFromMatrixPosition( light.target.matrixWorld ); + shadowCamera.lookAt( _lookTarget$1 ); + shadowCamera.updateMatrixWorld(); + + _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse ); + this._frustum.setFromProjectionMatrix( _projScreenMatrix$1 ); + + shadowMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + + shadowMatrix.multiply( shadowCamera.projectionMatrix ); + shadowMatrix.multiply( shadowCamera.matrixWorldInverse ); + + } + + getViewport( viewportIndex ) { + + return this._viewports[ viewportIndex ]; + + } + + getFrameExtents() { + + return this._frameExtents; + + } + + dispose() { + + if ( this.map ) { + + this.map.dispose(); + + } + + if ( this.mapPass ) { + + this.mapPass.dispose(); + + } + + } + + copy( source ) { + + this.camera = source.camera.clone(); + + this.bias = source.bias; + this.radius = source.radius; + + this.mapSize.copy( source.mapSize ); + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + toJSON() { + + const object = {}; + + if ( this.bias !== 0 ) object.bias = this.bias; + if ( this.normalBias !== 0 ) object.normalBias = this.normalBias; + if ( this.radius !== 1 ) object.radius = this.radius; + if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray(); + + object.camera = this.camera.toJSON( false ).object; + delete object.camera.matrix; + + return object; + + } + +} + +class SpotLightShadow extends LightShadow { + + constructor() { + + super( new PerspectiveCamera( 50, 1, 0.5, 500 ) ); + + this.focus = 1; + + } + + updateMatrices( light ) { + + const camera = this.camera; + + const fov = RAD2DEG * 2 * light.angle * this.focus; + const aspect = this.mapSize.width / this.mapSize.height; + const far = light.distance || camera.far; + + if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) { + + camera.fov = fov; + camera.aspect = aspect; + camera.far = far; + camera.updateProjectionMatrix(); + + } + + super.updateMatrices( light ); + + } + + copy( source ) { + + super.copy( source ); + + this.focus = source.focus; + + return this; + + } + +} + +SpotLightShadow.prototype.isSpotLightShadow = true; + +class SpotLight extends Light { + + constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1 ) { + + super( color, intensity ); + + this.type = 'SpotLight'; + + this.position.copy( Object3D.DefaultUp ); + this.updateMatrix(); + + this.target = new Object3D(); + + this.distance = distance; + this.angle = angle; + this.penumbra = penumbra; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new SpotLightShadow(); + + } + + get power() { + + // compute the light's luminous power (in lumens) from its intensity (in candela) + // by convention for a spotlight, luminous power (lm) = π * luminous intensity (cd) + return this.intensity * Math.PI; + + } + + set power( power ) { + + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / Math.PI; + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.distance = source.distance; + this.angle = source.angle; + this.penumbra = source.penumbra; + this.decay = source.decay; + + this.target = source.target.clone(); + + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +SpotLight.prototype.isSpotLight = true; + +const _projScreenMatrix = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld = /*@__PURE__*/ new Vector3(); +const _lookTarget = /*@__PURE__*/ new Vector3(); + +class PointLightShadow extends LightShadow { + + constructor() { + + super( new PerspectiveCamera( 90, 1, 0.5, 500 ) ); + + this._frameExtents = new Vector2( 4, 2 ); + + this._viewportCount = 6; + + this._viewports = [ + // These viewports map a cube-map onto a 2D texture with the + // following orientation: + // + // xzXZ + // y Y + // + // X - Positive x direction + // x - Negative x direction + // Y - Positive y direction + // y - Negative y direction + // Z - Positive z direction + // z - Negative z direction + + // positive X + new Vector4( 2, 1, 1, 1 ), + // negative X + new Vector4( 0, 1, 1, 1 ), + // positive Z + new Vector4( 3, 1, 1, 1 ), + // negative Z + new Vector4( 1, 1, 1, 1 ), + // positive Y + new Vector4( 3, 0, 1, 1 ), + // negative Y + new Vector4( 1, 0, 1, 1 ) + ]; + + this._cubeDirections = [ + new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ), + new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 ) + ]; + + this._cubeUps = [ + new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), + new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, - 1 ) + ]; + + } + + updateMatrices( light, viewportIndex = 0 ) { + + const camera = this.camera; + const shadowMatrix = this.matrix; + + const far = light.distance || camera.far; + + if ( far !== camera.far ) { + + camera.far = far; + camera.updateProjectionMatrix(); + + } + + _lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); + camera.position.copy( _lightPositionWorld ); + + _lookTarget.copy( camera.position ); + _lookTarget.add( this._cubeDirections[ viewportIndex ] ); + camera.up.copy( this._cubeUps[ viewportIndex ] ); + camera.lookAt( _lookTarget ); + camera.updateMatrixWorld(); + + shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z ); + + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); + this._frustum.setFromProjectionMatrix( _projScreenMatrix ); + + } + +} + +PointLightShadow.prototype.isPointLightShadow = true; + +class PointLight extends Light { + + constructor( color, intensity, distance = 0, decay = 1 ) { + + super( color, intensity ); + + this.type = 'PointLight'; + + this.distance = distance; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new PointLightShadow(); + + } + + get power() { + + // compute the light's luminous power (in lumens) from its intensity (in candela) + // for an isotropic light source, luminous power (lm) = 4 π luminous intensity (cd) + return this.intensity * 4 * Math.PI; + + } + + set power( power ) { + + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / ( 4 * Math.PI ); + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.distance = source.distance; + this.decay = source.decay; + + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +PointLight.prototype.isPointLight = true; + +class DirectionalLightShadow extends LightShadow { + + constructor() { + + super( new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) ); + + } + +} + +DirectionalLightShadow.prototype.isDirectionalLightShadow = true; + +class DirectionalLight extends Light { + + constructor( color, intensity ) { + + super( color, intensity ); + + this.type = 'DirectionalLight'; + + this.position.copy( Object3D.DefaultUp ); + this.updateMatrix(); + + this.target = new Object3D(); + + this.shadow = new DirectionalLightShadow(); + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.target = source.target.clone(); + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +DirectionalLight.prototype.isDirectionalLight = true; + +class LoaderUtils { + + static decodeText( array ) { + + if ( typeof TextDecoder !== 'undefined' ) { + + return new TextDecoder().decode( array ); + + } + + // Avoid the String.fromCharCode.apply(null, array) shortcut, which + // throws a "maximum call stack size exceeded" error for large arrays. + + let s = ''; + + for ( let i = 0, il = array.length; i < il; i ++ ) { + + // Implicitly assumes little-endian. + s += String.fromCharCode( array[ i ] ); + + } + + try { + + // merges multi-byte utf-8 characters. + + return decodeURIComponent( escape( s ) ); + + } catch ( e ) { // see #16358 + + return s; + + } + + } + + static extractUrlBase( url ) { + + const index = url.lastIndexOf( '/' ); + + if ( index === - 1 ) return './'; + + return url.substr( 0, index + 1 ); + + } + + static resolveURL( url, path ) { + + // Invalid URL + if ( typeof url !== 'string' || url === '' ) return ''; + + // Host Relative URL + if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) { + + path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); + + } + + // Absolute URL http://,https://,// + if ( /^(https?:)?\/\//i.test( url ) ) return url; + + // Data URI + if ( /^data:.*,.*$/i.test( url ) ) return url; + + // Blob URL + if ( /^blob:.*$/i.test( url ) ) return url; + + // Relative URL + return path + url; + + } + +} + +class ImageBitmapLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + if ( typeof createImageBitmap === 'undefined' ) { + + console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' ); + + } + + if ( typeof fetch === 'undefined' ) { + + console.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' ); + + } + + this.options = { premultiplyAlpha: 'none' }; + + } + + setOptions( options ) { + + this.options = options; + + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + if ( url === undefined ) url = ''; + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const scope = this; + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + scope.manager.itemStart( url ); + + setTimeout( function () { + + if ( onLoad ) onLoad( cached ); + + scope.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + const fetchOptions = {}; + fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include'; + fetchOptions.headers = this.requestHeader; + + fetch( url, fetchOptions ).then( function ( res ) { + + return res.blob(); + + } ).then( function ( blob ) { + + return createImageBitmap( blob, Object.assign( scope.options, { colorSpaceConversion: 'none' } ) ); + + } ).then( function ( imageBitmap ) { + + Cache.add( url, imageBitmap ); + + if ( onLoad ) onLoad( imageBitmap ); + + scope.manager.itemEnd( url ); + + } ).catch( function ( e ) { + + if ( onError ) onError( e ); + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + } ); + + scope.manager.itemStart( url ); + + } + +} + +ImageBitmapLoader.prototype.isImageBitmapLoader = true; + +// Characters [].:/ are reserved for track binding syntax. +const _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +const _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' ); + +// Attempts to allow node names from any language. ES5's `\w` regexp matches +// only latin characters, and the unicode \p{L} is not yet supported. So +// instead, we exclude reserved characters and match everything else. +const _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; +const _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; + +// Parent directories, delimited by '/' or ':'. Currently unused, but must +// be matched to parse the rest of the track name. +const _directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', _wordChar ); + +// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. +const _nodeRe = /(WCOD+)?/.source.replace( 'WCOD', _wordCharOrDot ); + +// Object on target node, and accessor. May not contain reserved +// characters. Accessor may contain any character except closing bracket. +const _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', _wordChar ); + +// Property and accessor. May not contain reserved characters. Accessor may +// contain any non-bracket characters. +const _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', _wordChar ); + +const _trackRe = new RegExp( '' + + '^' + + _directoryRe + + _nodeRe + + _objectRe + + _propertyRe + + '$' +); + +const _supportedObjectNames = [ 'material', 'materials', 'bones' ]; + +class Composite { + + constructor( targetGroup, path, optionalParsedPath ) { + + const parsedPath = optionalParsedPath || PropertyBinding.parseTrackName( path ); + + this._targetGroup = targetGroup; + this._bindings = targetGroup.subscribe_( path, parsedPath ); + + } + + getValue( array, offset ) { + + this.bind(); // bind all binding + + const firstValidIndex = this._targetGroup.nCachedObjects_, + binding = this._bindings[ firstValidIndex ]; + + // and only call .getValue on the first + if ( binding !== undefined ) binding.getValue( array, offset ); + + } + + setValue( array, offset ) { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].setValue( array, offset ); + + } + + } + + bind() { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].bind(); + + } + + } + + unbind() { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].unbind(); + + } + + } + +} + +// Note: This class uses a State pattern on a per-method basis: +// 'bind' sets 'this.getValue' / 'setValue' and shadows the +// prototype version of these methods with one that represents +// the bound state. When the property is not found, the methods +// become no-ops. +class PropertyBinding { + + constructor( rootNode, path, parsedPath ) { + + this.path = path; + this.parsedPath = parsedPath || PropertyBinding.parseTrackName( path ); + + this.node = PropertyBinding.findNode( rootNode, this.parsedPath.nodeName ) || rootNode; + + this.rootNode = rootNode; + + // initial state of these methods that calls 'bind' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + + } + + + static create( root, path, parsedPath ) { + + if ( ! ( root && root.isAnimationObjectGroup ) ) { + + return new PropertyBinding( root, path, parsedPath ); + + } else { + + return new PropertyBinding.Composite( root, path, parsedPath ); + + } + + } + + /** + * Replaces spaces with underscores and removes unsupported characters from + * node names, to ensure compatibility with parseTrackName(). + * + * @param {string} name Node name to be sanitized. + * @return {string} + */ + static sanitizeNodeName( name ) { + + return name.replace( /\s/g, '_' ).replace( _reservedRe, '' ); + + } + + static parseTrackName( trackName ) { + + const matches = _trackRe.exec( trackName ); + + if ( ! matches ) { + + throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); + + } + + const results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[ 2 ], + objectName: matches[ 3 ], + objectIndex: matches[ 4 ], + propertyName: matches[ 5 ], // required + propertyIndex: matches[ 6 ] + }; + + const lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); + + if ( lastDot !== undefined && lastDot !== - 1 ) { + + const objectName = results.nodeName.substring( lastDot + 1 ); + + // Object names must be checked against an allowlist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) { + + results.nodeName = results.nodeName.substring( 0, lastDot ); + results.objectName = objectName; + + } + + } + + if ( results.propertyName === null || results.propertyName.length === 0 ) { + + throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); + + } + + return results; + + } + + static findNode( root, nodeName ) { + + if ( ! nodeName || nodeName === '' || nodeName === '.' || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { + + return root; + + } + + // search into skeleton bones. + if ( root.skeleton ) { + + const bone = root.skeleton.getBoneByName( nodeName ); + + if ( bone !== undefined ) { + + return bone; + + } + + } + + // search into node subtree. + if ( root.children ) { + + const searchNodeSubtree = function ( children ) { + + for ( let i = 0; i < children.length; i ++ ) { + + const childNode = children[ i ]; + + if ( childNode.name === nodeName || childNode.uuid === nodeName ) { + + return childNode; + + } + + const result = searchNodeSubtree( childNode.children ); + + if ( result ) return result; + + } + + return null; + + }; + + const subTreeNode = searchNodeSubtree( root.children ); + + if ( subTreeNode ) { + + return subTreeNode; + + } + + } + + return null; + + } + + // these are used to "bind" a nonexistent property + _getValue_unavailable() {} + _setValue_unavailable() {} + + // Getters + + _getValue_direct( buffer, offset ) { + + buffer[ offset ] = this.targetObject[ this.propertyName ]; + + } + + _getValue_array( buffer, offset ) { + + const source = this.resolvedProperty; + + for ( let i = 0, n = source.length; i !== n; ++ i ) { + + buffer[ offset ++ ] = source[ i ]; + + } + + } + + _getValue_arrayElement( buffer, offset ) { + + buffer[ offset ] = this.resolvedProperty[ this.propertyIndex ]; + + } + + _getValue_toArray( buffer, offset ) { + + this.resolvedProperty.toArray( buffer, offset ); + + } + + // Direct + + _setValue_direct( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + + } + + _setValue_direct_setNeedsUpdate( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + this.targetObject.needsUpdate = true; + + } + + _setValue_direct_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // EntireArray + + _setValue_array( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + } + + _setValue_array_setNeedsUpdate( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + this.targetObject.needsUpdate = true; + + } + + _setValue_array_setMatrixWorldNeedsUpdate( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // ArrayElement + + _setValue_arrayElement( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + + } + + _setValue_arrayElement_setNeedsUpdate( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + this.targetObject.needsUpdate = true; + + } + + _setValue_arrayElement_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // HasToFromArray + + _setValue_fromArray( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + + } + + _setValue_fromArray_setNeedsUpdate( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + this.targetObject.needsUpdate = true; + + } + + _setValue_fromArray_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + _getValue_unbound( targetArray, offset ) { + + this.bind(); + this.getValue( targetArray, offset ); + + } + + _setValue_unbound( sourceArray, offset ) { + + this.bind(); + this.setValue( sourceArray, offset ); + + } + + // create getter / setter pair for a property in the scene graph + bind() { + + let targetObject = this.node; + const parsedPath = this.parsedPath; + + const objectName = parsedPath.objectName; + const propertyName = parsedPath.propertyName; + let propertyIndex = parsedPath.propertyIndex; + + if ( ! targetObject ) { + + targetObject = PropertyBinding.findNode( this.rootNode, parsedPath.nodeName ) || this.rootNode; + + this.node = targetObject; + + } + + // set fail state so we can just 'return' on error + this.getValue = this._getValue_unavailable; + this.setValue = this._setValue_unavailable; + + // ensure there is a value node + if ( ! targetObject ) { + + console.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\'t found.' ); + return; + + } + + if ( objectName ) { + + let objectIndex = parsedPath.objectIndex; + + // special cases were we need to reach deeper into the hierarchy to get the face materials.... + switch ( objectName ) { + + case 'materials': + + if ( ! targetObject.material ) { + + console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this ); + return; + + } + + if ( ! targetObject.material.materials ) { + + console.error( 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this ); + return; + + } + + targetObject = targetObject.material.materials; + + break; + + case 'bones': + + if ( ! targetObject.skeleton ) { + + console.error( 'THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this ); + return; + + } + + // potential future optimization: skip this if propertyIndex is already an integer + // and convert the integer string to a true integer. + + targetObject = targetObject.skeleton.bones; + + // support resolving morphTarget names into indices. + for ( let i = 0; i < targetObject.length; i ++ ) { + + if ( targetObject[ i ].name === objectIndex ) { + + objectIndex = i; + break; + + } + + } + + break; + + default: + + if ( targetObject[ objectName ] === undefined ) { + + console.error( 'THREE.PropertyBinding: Can not bind to objectName of node undefined.', this ); + return; + + } + + targetObject = targetObject[ objectName ]; + + } + + + if ( objectIndex !== undefined ) { + + if ( targetObject[ objectIndex ] === undefined ) { + + console.error( 'THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject ); + return; + + } + + targetObject = targetObject[ objectIndex ]; + + } + + } + + // resolve property + const nodeProperty = targetObject[ propertyName ]; + + if ( nodeProperty === undefined ) { + + const nodeName = parsedPath.nodeName; + + console.error( 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName + + '.' + propertyName + ' but it wasn\'t found.', targetObject ); + return; + + } + + // determine versioning scheme + let versioning = this.Versioning.None; + + this.targetObject = targetObject; + + if ( targetObject.needsUpdate !== undefined ) { // material + + versioning = this.Versioning.NeedsUpdate; + + } else if ( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform + + versioning = this.Versioning.MatrixWorldNeedsUpdate; + + } + + // determine how the property gets bound + let bindingType = this.BindingType.Direct; + + if ( propertyIndex !== undefined ) { + + // access a sub element of the property array (only primitives are supported right now) + + if ( propertyName === 'morphTargetInfluences' ) { + + // potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. + + // support resolving morphTarget names into indices. + if ( ! targetObject.geometry ) { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this ); + return; + + } + + if ( targetObject.geometry.isBufferGeometry ) { + + if ( ! targetObject.geometry.morphAttributes ) { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this ); + return; + + } + + if ( targetObject.morphTargetDictionary[ propertyIndex ] !== undefined ) { + + propertyIndex = targetObject.morphTargetDictionary[ propertyIndex ]; + + } + + + } else { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.', this ); + return; + + } + + } + + bindingType = this.BindingType.ArrayElement; + + this.resolvedProperty = nodeProperty; + this.propertyIndex = propertyIndex; + + } else if ( nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined ) { + + // must use copy for Object3D.Euler/Quaternion + + bindingType = this.BindingType.HasFromToArray; + + this.resolvedProperty = nodeProperty; + + } else if ( Array.isArray( nodeProperty ) ) { + + bindingType = this.BindingType.EntireArray; + + this.resolvedProperty = nodeProperty; + + } else { + + this.propertyName = propertyName; + + } + + // select getter / setter + this.getValue = this.GetterByBindingType[ bindingType ]; + this.setValue = this.SetterByBindingTypeAndVersioning[ bindingType ][ versioning ]; + + } + + unbind() { + + this.node = null; + + // back to the prototype version of getValue / setValue + // note: avoiding to mutate the shape of 'this' via 'delete' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + + } + +} + +PropertyBinding.Composite = Composite; + +PropertyBinding.prototype.BindingType = { + Direct: 0, + EntireArray: 1, + ArrayElement: 2, + HasFromToArray: 3 +}; + +PropertyBinding.prototype.Versioning = { + None: 0, + NeedsUpdate: 1, + MatrixWorldNeedsUpdate: 2 +}; + +PropertyBinding.prototype.GetterByBindingType = [ + + PropertyBinding.prototype._getValue_direct, + PropertyBinding.prototype._getValue_array, + PropertyBinding.prototype._getValue_arrayElement, + PropertyBinding.prototype._getValue_toArray, + +]; + +PropertyBinding.prototype.SetterByBindingTypeAndVersioning = [ + + [ + // Direct + PropertyBinding.prototype._setValue_direct, + PropertyBinding.prototype._setValue_direct_setNeedsUpdate, + PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate, + + ], [ + + // EntireArray + + PropertyBinding.prototype._setValue_array, + PropertyBinding.prototype._setValue_array_setNeedsUpdate, + PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate, + + ], [ + + // ArrayElement + PropertyBinding.prototype._setValue_arrayElement, + PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate, + PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate, + + ], [ + + // HasToFromArray + PropertyBinding.prototype._setValue_fromArray, + PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate, + PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate, + + ] + +]; + +class Raycaster { + + constructor( origin, direction, near = 0, far = Infinity ) { + + this.ray = new Ray( origin, direction ); + // direction is assumed to be normalized (for accurate distance calculations) + + this.near = near; + this.far = far; + this.camera = null; + this.layers = new Layers(); + + this.params = { + Mesh: {}, + Line: { threshold: 1 }, + LOD: {}, + Points: { threshold: 1 }, + Sprite: {} + }; + + } + + set( origin, direction ) { + + // direction is assumed to be normalized (for accurate distance calculations) + + this.ray.set( origin, direction ); + + } + + setFromCamera( coords, camera ) { + + if ( camera && camera.isPerspectiveCamera ) { + + this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); + this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); + this.camera = camera; + + } else if ( camera && camera.isOrthographicCamera ) { + + this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera + this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ); + this.camera = camera; + + } else { + + console.error( 'THREE.Raycaster: Unsupported camera type: ' + camera.type ); + + } + + } + + intersectObject( object, recursive = true, intersects = [] ) { + + intersectObject( object, this, intersects, recursive ); + + intersects.sort( ascSort ); + + return intersects; + + } + + intersectObjects( objects, recursive = true, intersects = [] ) { + + for ( let i = 0, l = objects.length; i < l; i ++ ) { + + intersectObject( objects[ i ], this, intersects, recursive ); + + } + + intersects.sort( ascSort ); + + return intersects; + + } + +} + +function ascSort( a, b ) { + + return a.distance - b.distance; + +} + +function intersectObject( object, raycaster, intersects, recursive ) { + + if ( object.layers.test( raycaster.layers ) ) { + + object.raycast( raycaster, intersects ); + + } + + if ( recursive === true ) { + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + intersectObject( children[ i ], raycaster, intersects, true ); + + } + + } + +} + +const _floatView = new Float32Array( 1 ); +const _int32View = new Int32Array( _floatView.buffer ); + +class DataUtils { + + // Converts float32 to float16 (stored as uint16 value). + + static toHalfFloat( val ) { + + if ( val > 65504 ) { + + console.warn( 'THREE.DataUtils.toHalfFloat(): value exceeds 65504.' ); + + val = 65504; // maximum representable value in float16 + + } + + // Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410 + + /* This method is faster than the OpenEXR implementation (very often + * used, eg. in Ogre), with the additional benefit of rounding, inspired + * by James Tursa?s half-precision code. */ + + _floatView[ 0 ] = val; + const x = _int32View[ 0 ]; + + let bits = ( x >> 16 ) & 0x8000; /* Get the sign */ + let m = ( x >> 12 ) & 0x07ff; /* Keep one extra bit for rounding */ + const e = ( x >> 23 ) & 0xff; /* Using int is faster here */ + + /* If zero, or denormal, or exponent underflows too much for a denormal + * half, return signed zero. */ + if ( e < 103 ) return bits; + + /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */ + if ( e > 142 ) { + + bits |= 0x7c00; + /* If exponent was 0xff and one mantissa bit was set, it means NaN, + * not Inf, so make sure we set one mantissa bit too. */ + bits |= ( ( e == 255 ) ? 0 : 1 ) && ( x & 0x007fffff ); + return bits; + + } + + /* If exponent underflows but not too much, return a denormal */ + if ( e < 113 ) { + + m |= 0x0800; + /* Extra rounding may overflow and set mantissa to 0 and exponent + * to 1, which is OK. */ + bits |= ( m >> ( 114 - e ) ) + ( ( m >> ( 113 - e ) ) & 1 ); + return bits; + + } + + bits |= ( ( e - 112 ) << 10 ) | ( m >> 1 ); + /* Extra rounding. An overflow will set mantissa to 0 and increment + * the exponent, which is OK. */ + bits += m & 1; + return bits; + + } + +} + +// + +Loader.prototype.extractUrlBase = function ( url ) { + + console.warn( 'THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.' ); + return LoaderUtils.extractUrlBase( url ); + +}; + +Loader.Handlers = { + + add: function ( /* regex, loader */ ) { + + console.error( 'THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.' ); + + }, + + get: function ( /* file */ ) { + + console.error( 'THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.' ); + + } + +}; + +// + +Box3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +Box3.prototype.empty = function () { + + console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + +}; + +Box3.prototype.isIntersectionBox = function ( box ) { + + console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' ); + return this.intersectsBox( box ); + +}; + +Box3.prototype.isIntersectionSphere = function ( sphere ) { + + console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); + return this.intersectsSphere( sphere ); + +}; + +Box3.prototype.size = function ( optionalTarget ) { + + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); + return this.getSize( optionalTarget ); + +}; + +// + +Sphere.prototype.empty = function () { + + console.warn( 'THREE.Sphere: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + +}; + +// + +Frustum.prototype.setFromMatrix = function ( m ) { + + console.warn( 'THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().' ); + return this.setFromProjectionMatrix( m ); + +}; + +// + +Matrix3.prototype.flattenToArrayOffset = function ( array, offset ) { + + console.warn( 'THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); + return this.toArray( array, offset ); + +}; + +Matrix3.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); + return vector.applyMatrix3( this ); + +}; + +Matrix3.prototype.multiplyVector3Array = function ( /* a */ ) { + + console.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' ); + +}; + +Matrix3.prototype.applyToBufferAttribute = function ( attribute ) { + + console.warn( 'THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.' ); + return attribute.applyMatrix3( this ); + +}; + +Matrix3.prototype.applyToVector3Array = function ( /* array, offset, length */ ) { + + console.error( 'THREE.Matrix3: .applyToVector3Array() has been removed.' ); + +}; + +Matrix3.prototype.getInverse = function ( matrix ) { + + console.warn( 'THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.' ); + return this.copy( matrix ).invert(); + +}; + +// + +Matrix4.prototype.extractPosition = function ( m ) { + + console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); + return this.copyPosition( m ); + +}; + +Matrix4.prototype.flattenToArrayOffset = function ( array, offset ) { + + console.warn( 'THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); + return this.toArray( array, offset ); + +}; + +Matrix4.prototype.getPosition = function () { + + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return new Vector3().setFromMatrixColumn( this, 3 ); + +}; + +Matrix4.prototype.setRotationFromQuaternion = function ( q ) { + + console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); + return this.makeRotationFromQuaternion( q ); + +}; + +Matrix4.prototype.multiplyToArray = function () { + + console.warn( 'THREE.Matrix4: .multiplyToArray() has been removed.' ); + +}; + +Matrix4.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.multiplyVector4 = function ( vector ) { + + console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.multiplyVector3Array = function ( /* a */ ) { + + console.error( 'THREE.Matrix4: .multiplyVector3Array() has been removed.' ); + +}; + +Matrix4.prototype.rotateAxis = function ( v ) { + + console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' ); + v.transformDirection( this ); + +}; + +Matrix4.prototype.crossVector = function ( vector ) { + + console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.translate = function () { + + console.error( 'THREE.Matrix4: .translate() has been removed.' ); + +}; + +Matrix4.prototype.rotateX = function () { + + console.error( 'THREE.Matrix4: .rotateX() has been removed.' ); + +}; + +Matrix4.prototype.rotateY = function () { + + console.error( 'THREE.Matrix4: .rotateY() has been removed.' ); + +}; + +Matrix4.prototype.rotateZ = function () { + + console.error( 'THREE.Matrix4: .rotateZ() has been removed.' ); + +}; + +Matrix4.prototype.rotateByAxis = function () { + + console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); + +}; + +Matrix4.prototype.applyToBufferAttribute = function ( attribute ) { + + console.warn( 'THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.' ); + return attribute.applyMatrix4( this ); + +}; + +Matrix4.prototype.applyToVector3Array = function ( /* array, offset, length */ ) { + + console.error( 'THREE.Matrix4: .applyToVector3Array() has been removed.' ); + +}; + +Matrix4.prototype.makeFrustum = function ( left, right, bottom, top, near, far ) { + + console.warn( 'THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.' ); + return this.makePerspective( left, right, top, bottom, near, far ); + +}; + +Matrix4.prototype.getInverse = function ( matrix ) { + + console.warn( 'THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.' ); + return this.copy( matrix ).invert(); + +}; + +// + +Plane.prototype.isIntersectionLine = function ( line ) { + + console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); + return this.intersectsLine( line ); + +}; + +// + +Quaternion.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); + return vector.applyQuaternion( this ); + +}; + +Quaternion.prototype.inverse = function ( ) { + + console.warn( 'THREE.Quaternion: .inverse() has been renamed to invert().' ); + return this.invert(); + +}; + +// + +Ray.prototype.isIntersectionBox = function ( box ) { + + console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); + return this.intersectsBox( box ); + +}; + +Ray.prototype.isIntersectionPlane = function ( plane ) { + + console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' ); + return this.intersectsPlane( plane ); + +}; + +Ray.prototype.isIntersectionSphere = function ( sphere ) { + + console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); + return this.intersectsSphere( sphere ); + +}; + +// + +Triangle.prototype.area = function () { + + console.warn( 'THREE.Triangle: .area() has been renamed to .getArea().' ); + return this.getArea(); + +}; + +Triangle.prototype.barycoordFromPoint = function ( point, target ) { + + console.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' ); + return this.getBarycoord( point, target ); + +}; + +Triangle.prototype.midpoint = function ( target ) { + + console.warn( 'THREE.Triangle: .midpoint() has been renamed to .getMidpoint().' ); + return this.getMidpoint( target ); + +}; + +Triangle.prototypenormal = function ( target ) { + + console.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' ); + return this.getNormal( target ); + +}; + +Triangle.prototype.plane = function ( target ) { + + console.warn( 'THREE.Triangle: .plane() has been renamed to .getPlane().' ); + return this.getPlane( target ); + +}; + +Triangle.barycoordFromPoint = function ( point, a, b, c, target ) { + + console.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' ); + return Triangle.getBarycoord( point, a, b, c, target ); + +}; + +Triangle.normal = function ( a, b, c, target ) { + + console.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' ); + return Triangle.getNormal( a, b, c, target ); + +}; + +// + +Vector2.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector2.prototype.distanceToManhattan = function ( v ) { + + console.warn( 'THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' ); + return this.manhattanDistanceTo( v ); + +}; + +Vector2.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Vector3.prototype.setEulerFromRotationMatrix = function () { + + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + +}; + +Vector3.prototype.setEulerFromQuaternion = function () { + + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + +}; + +Vector3.prototype.getPositionFromMatrix = function ( m ) { + + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); + return this.setFromMatrixPosition( m ); + +}; + +Vector3.prototype.getScaleFromMatrix = function ( m ) { + + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); + return this.setFromMatrixScale( m ); + +}; + +Vector3.prototype.getColumnFromMatrix = function ( index, matrix ) { + + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); + return this.setFromMatrixColumn( matrix, index ); + +}; + +Vector3.prototype.applyProjection = function ( m ) { + + console.warn( 'THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.' ); + return this.applyMatrix4( m ); + +}; + +Vector3.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector3.prototype.distanceToManhattan = function ( v ) { + + console.warn( 'THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' ); + return this.manhattanDistanceTo( v ); + +}; + +Vector3.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Vector4.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector4.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Object3D.prototype.getChildByName = function ( name ) { + + console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); + return this.getObjectByName( name ); + +}; + +Object3D.prototype.renderDepth = function () { + + console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' ); + +}; + +Object3D.prototype.translate = function ( distance, axis ) { + + console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' ); + return this.translateOnAxis( axis, distance ); + +}; + +Object3D.prototype.getWorldRotation = function () { + + console.error( 'THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.' ); + +}; + +Object3D.prototype.applyMatrix = function ( matrix ) { + + console.warn( 'THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + +}; + +Object.defineProperties( Object3D.prototype, { + + eulerOrder: { + get: function () { + + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); + return this.rotation.order; + + }, + set: function ( value ) { + + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); + this.rotation.order = value; + + } + }, + useQuaternion: { + get: function () { + + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + + }, + set: function () { + + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + + } + } + +} ); + +Mesh.prototype.setDrawMode = function () { + + console.error( 'THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + +}; + +Object.defineProperties( Mesh.prototype, { + + drawMode: { + get: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.' ); + return TrianglesDrawMode; + + }, + set: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + + } + } + +} ); + +SkinnedMesh.prototype.initBones = function () { + + console.error( 'THREE.SkinnedMesh: initBones() has been removed.' ); + +}; + +// + +PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { + + console.warn( 'THREE.PerspectiveCamera.setLens is deprecated. ' + + 'Use .setFocalLength and .filmGauge for a photographic setup.' ); + + if ( filmGauge !== undefined ) this.filmGauge = filmGauge; + this.setFocalLength( focalLength ); + +}; + +// + +Object.defineProperties( Light.prototype, { + onlyShadow: { + set: function () { + + console.warn( 'THREE.Light: .onlyShadow has been removed.' ); + + } + }, + shadowCameraFov: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' ); + this.shadow.camera.fov = value; + + } + }, + shadowCameraLeft: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' ); + this.shadow.camera.left = value; + + } + }, + shadowCameraRight: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' ); + this.shadow.camera.right = value; + + } + }, + shadowCameraTop: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' ); + this.shadow.camera.top = value; + + } + }, + shadowCameraBottom: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' ); + this.shadow.camera.bottom = value; + + } + }, + shadowCameraNear: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' ); + this.shadow.camera.near = value; + + } + }, + shadowCameraFar: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' ); + this.shadow.camera.far = value; + + } + }, + shadowCameraVisible: { + set: function () { + + console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' ); + + } + }, + shadowBias: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' ); + this.shadow.bias = value; + + } + }, + shadowDarkness: { + set: function () { + + console.warn( 'THREE.Light: .shadowDarkness has been removed.' ); + + } + }, + shadowMapWidth: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' ); + this.shadow.mapSize.width = value; + + } + }, + shadowMapHeight: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' ); + this.shadow.mapSize.height = value; + + } + } +} ); + +// + +Object.defineProperties( BufferAttribute.prototype, { + + length: { + get: function () { + + console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' ); + return this.array.length; + + } + }, + dynamic: { + get: function () { + + console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' ); + return this.usage === DynamicDrawUsage; + + }, + set: function ( /* value */ ) { + + console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' ); + this.setUsage( DynamicDrawUsage ); + + } + } + +} ); + +BufferAttribute.prototype.setDynamic = function ( value ) { + + console.warn( 'THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.' ); + this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage ); + return this; + +}; + +BufferAttribute.prototype.copyIndicesArray = function ( /* indices */ ) { + + console.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' ); + +}, + +BufferAttribute.prototype.setArray = function ( /* array */ ) { + + console.error( 'THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers' ); + +}; + +// + +BufferGeometry.prototype.addIndex = function ( index ) { + + console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); + this.setIndex( index ); + +}; + +BufferGeometry.prototype.addAttribute = function ( name, attribute ) { + + console.warn( 'THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().' ); + + if ( ! ( attribute && attribute.isBufferAttribute ) && ! ( attribute && attribute.isInterleavedBufferAttribute ) ) { + + console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' ); + + return this.setAttribute( name, new BufferAttribute( arguments[ 1 ], arguments[ 2 ] ) ); + + } + + if ( name === 'index' ) { + + console.warn( 'THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.' ); + this.setIndex( attribute ); + + return this; + + } + + return this.setAttribute( name, attribute ); + +}; + +BufferGeometry.prototype.addDrawCall = function ( start, count, indexOffset ) { + + if ( indexOffset !== undefined ) { + + console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); + + } + + console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); + this.addGroup( start, count ); + +}; + +BufferGeometry.prototype.clearDrawCalls = function () { + + console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' ); + this.clearGroups(); + +}; + +BufferGeometry.prototype.computeOffsets = function () { + + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); + +}; + +BufferGeometry.prototype.removeAttribute = function ( name ) { + + console.warn( 'THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().' ); + + return this.deleteAttribute( name ); + +}; + +BufferGeometry.prototype.applyMatrix = function ( matrix ) { + + console.warn( 'THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + +}; + +Object.defineProperties( BufferGeometry.prototype, { + + drawcalls: { + get: function () { + + console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); + return this.groups; + + } + }, + offsets: { + get: function () { + + console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' ); + return this.groups; + + } + } + +} ); + +InterleavedBuffer.prototype.setDynamic = function ( value ) { + + console.warn( 'THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.' ); + this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage ); + return this; + +}; + +InterleavedBuffer.prototype.setArray = function ( /* array */ ) { + + console.error( 'THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers' ); + +}; + +// + +Scene.prototype.dispose = function () { + + console.error( 'THREE.Scene: .dispose() has been removed.' ); + +}; + +// + +Object.defineProperties( Material.prototype, { + + wrapAround: { + get: function () { + + console.warn( 'THREE.Material: .wrapAround has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.Material: .wrapAround has been removed.' ); + + } + }, + + overdraw: { + get: function () { + + console.warn( 'THREE.Material: .overdraw has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.Material: .overdraw has been removed.' ); + + } + }, + + wrapRGB: { + get: function () { + + console.warn( 'THREE.Material: .wrapRGB has been removed.' ); + return new Color$1(); + + } + }, + + shading: { + get: function () { + + console.error( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + + }, + set: function ( value ) { + + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( value === FlatShading ); + + } + }, + + stencilMask: { + get: function () { + + console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' ); + return this.stencilFuncMask; + + }, + set: function ( value ) { + + console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' ); + this.stencilFuncMask = value; + + } + }, + + vertexTangents: { + get: function () { + + console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' ); + + } + }, + +} ); + +Object.defineProperties( ShaderMaterial.prototype, { + + derivatives: { + get: function () { + + console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); + return this.extensions.derivatives; + + }, + set: function ( value ) { + + console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); + this.extensions.derivatives = value; + + } + } + +} ); + +// + +WebGLRenderer.prototype.clearTarget = function ( renderTarget, color, depth, stencil ) { + + console.warn( 'THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.' ); + this.setRenderTarget( renderTarget ); + this.clear( color, depth, stencil ); + +}; + +WebGLRenderer.prototype.animate = function ( callback ) { + + console.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' ); + this.setAnimationLoop( callback ); + +}; + +WebGLRenderer.prototype.getCurrentRenderTarget = function () { + + console.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' ); + return this.getRenderTarget(); + +}; + +WebGLRenderer.prototype.getMaxAnisotropy = function () { + + console.warn( 'THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().' ); + return this.capabilities.getMaxAnisotropy(); + +}; + +WebGLRenderer.prototype.getPrecision = function () { + + console.warn( 'THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.' ); + return this.capabilities.precision; + +}; + +WebGLRenderer.prototype.resetGLState = function () { + + console.warn( 'THREE.WebGLRenderer: .resetGLState() is now .state.reset().' ); + return this.state.reset(); + +}; + +WebGLRenderer.prototype.supportsFloatTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); + return this.extensions.get( 'OES_texture_float' ); + +}; + +WebGLRenderer.prototype.supportsHalfFloatTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' ); + return this.extensions.get( 'OES_texture_half_float' ); + +}; + +WebGLRenderer.prototype.supportsStandardDerivatives = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' ); + return this.extensions.get( 'OES_standard_derivatives' ); + +}; + +WebGLRenderer.prototype.supportsCompressedTextureS3TC = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' ); + return this.extensions.get( 'WEBGL_compressed_texture_s3tc' ); + +}; + +WebGLRenderer.prototype.supportsCompressedTexturePVRTC = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' ); + return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + +}; + +WebGLRenderer.prototype.supportsBlendMinMax = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' ); + return this.extensions.get( 'EXT_blend_minmax' ); + +}; + +WebGLRenderer.prototype.supportsVertexTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' ); + return this.capabilities.vertexTextures; + +}; + +WebGLRenderer.prototype.supportsInstancedArrays = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' ); + return this.extensions.get( 'ANGLE_instanced_arrays' ); + +}; + +WebGLRenderer.prototype.enableScissorTest = function ( boolean ) { + + console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' ); + this.setScissorTest( boolean ); + +}; + +WebGLRenderer.prototype.initMaterial = function () { + + console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' ); + +}; + +WebGLRenderer.prototype.addPrePlugin = function () { + + console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' ); + +}; + +WebGLRenderer.prototype.addPostPlugin = function () { + + console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' ); + +}; + +WebGLRenderer.prototype.updateShadowMap = function () { + + console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' ); + +}; + +WebGLRenderer.prototype.setFaceCulling = function () { + + console.warn( 'THREE.WebGLRenderer: .setFaceCulling() has been removed.' ); + +}; + +WebGLRenderer.prototype.allocTextureUnit = function () { + + console.warn( 'THREE.WebGLRenderer: .allocTextureUnit() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTexture = function () { + + console.warn( 'THREE.WebGLRenderer: .setTexture() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTexture2D = function () { + + console.warn( 'THREE.WebGLRenderer: .setTexture2D() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTextureCube = function () { + + console.warn( 'THREE.WebGLRenderer: .setTextureCube() has been removed.' ); + +}; + +WebGLRenderer.prototype.getActiveMipMapLevel = function () { + + console.warn( 'THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().' ); + return this.getActiveMipmapLevel(); + +}; + +Object.defineProperties( WebGLRenderer.prototype, { + + shadowMapEnabled: { + get: function () { + + return this.shadowMap.enabled; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); + this.shadowMap.enabled = value; + + } + }, + shadowMapType: { + get: function () { + + return this.shadowMap.type; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); + this.shadowMap.type = value; + + } + }, + shadowMapCullFace: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function ( /* value */ ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' ); + + } + }, + context: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.' ); + return this.getContext(); + + } + }, + vr: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .vr has been renamed to .xr' ); + return this.xr; + + } + }, + gammaInput: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.' ); + return false; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.' ); + + } + }, + gammaOutput: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.' ); + return false; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.' ); + this.outputEncoding = ( value === true ) ? sRGBEncoding : LinearEncoding; + + } + }, + toneMappingWhitePoint: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.' ); + return 1.0; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.' ); + + } + }, + gammaFactor: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' ); + return 2; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' ); + + } + } +} ); + +Object.defineProperties( WebGLShadowMap.prototype, { + + cullFace: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function ( /* cullFace */ ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' ); + + } + }, + renderReverseSided: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' ); + + } + }, + renderSingleSided: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' ); + + } + } + +} ); + +// + +Object.defineProperties( WebGLRenderTarget.prototype, { + + wrapS: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); + return this.texture.wrapS; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); + this.texture.wrapS = value; + + } + }, + wrapT: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); + return this.texture.wrapT; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); + this.texture.wrapT = value; + + } + }, + magFilter: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); + return this.texture.magFilter; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); + this.texture.magFilter = value; + + } + }, + minFilter: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); + return this.texture.minFilter; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); + this.texture.minFilter = value; + + } + }, + anisotropy: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); + return this.texture.anisotropy; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); + this.texture.anisotropy = value; + + } + }, + offset: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); + return this.texture.offset; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); + this.texture.offset = value; + + } + }, + repeat: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); + return this.texture.repeat; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); + this.texture.repeat = value; + + } + }, + format: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); + return this.texture.format; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); + this.texture.format = value; + + } + }, + type: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); + return this.texture.type; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); + this.texture.type = value; + + } + }, + generateMipmaps: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); + return this.texture.generateMipmaps; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); + this.texture.generateMipmaps = value; + + } + } + +} ); + +// + +CubeCamera.prototype.updateCubeMap = function ( renderer, scene ) { + + console.warn( 'THREE.CubeCamera: .updateCubeMap() is now .update().' ); + return this.update( renderer, scene ); + +}; + +CubeCamera.prototype.clear = function ( renderer, color, depth, stencil ) { + + console.warn( 'THREE.CubeCamera: .clear() is now .renderTarget.clear().' ); + return this.renderTarget.clear( renderer, color, depth, stencil ); + +}; + +ImageUtils.crossOrigin = undefined; + +ImageUtils.loadTexture = function ( url, mapping, onLoad, onError ) { + + console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' ); + + const loader = new TextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); + + const texture = loader.load( url, onLoad, undefined, onError ); + + if ( mapping ) texture.mapping = mapping; + + return texture; + +}; + +ImageUtils.loadTextureCube = function ( urls, mapping, onLoad, onError ) { + + console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' ); + + const loader = new CubeTextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); + + const texture = loader.load( urls, onLoad, undefined, onError ); + + if ( mapping ) texture.mapping = mapping; + + return texture; + +}; + +ImageUtils.loadCompressedTexture = function () { + + console.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' ); + +}; + +ImageUtils.loadCompressedTextureCube = function () { + + console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' ); + +}; + +if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: { + revision: REVISION, + } } ) ); + +} + +if ( typeof window !== 'undefined' ) { + + if ( window.__THREE__ ) { + + console.warn( 'WARNING: Multiple instances of Three.js being imported.' ); + + } else { + + window.__THREE__ = REVISION; + + } + +} + +class GLTFLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + this.dracoLoader = null; + this.ktx2Loader = null; + this.meshoptDecoder = null; + + this.pluginCallbacks = []; + + this.register( function ( parser ) { + + return new GLTFMaterialsClearcoatExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFTextureBasisUExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFTextureWebPExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsSheenExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsTransmissionExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsVolumeExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsIorExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsSpecularExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFLightsExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMeshoptCompression( parser ); + + } ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + let resourcePath; + + if ( this.resourcePath !== '' ) { + + resourcePath = this.resourcePath; + + } else if ( this.path !== '' ) { + + resourcePath = this.path; + + } else { + + resourcePath = LoaderUtils.extractUrlBase( url ); + + } + + // Tells the LoadingManager to track an extra item, which resolves after + // the model is fully loaded. This means the count of items loaded will + // be incorrect, but ensures manager.onLoad() does not fire early. + this.manager.itemStart( url ); + + const _onError = function ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + }; + + const loader = new FileLoader( this.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + + loader.load( url, function ( data ) { + + try { + + scope.parse( data, resourcePath, function ( gltf ) { + + onLoad( gltf ); + + scope.manager.itemEnd( url ); + + }, _onError ); + + } catch ( e ) { + + _onError( e ); + + } + + }, onProgress, _onError ); + + } + + setDRACOLoader( dracoLoader ) { + + this.dracoLoader = dracoLoader; + return this; + + } + + setDDSLoader() { + + throw new Error( + + 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".' + + ); + + } + + setKTX2Loader( ktx2Loader ) { + + this.ktx2Loader = ktx2Loader; + return this; + + } + + setMeshoptDecoder( meshoptDecoder ) { + + this.meshoptDecoder = meshoptDecoder; + return this; + + } + + register( callback ) { + + if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) { + + this.pluginCallbacks.push( callback ); + + } + + return this; + + } + + unregister( callback ) { + + if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) { + + this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 ); + + } + + return this; + + } + + parse( data, path, onLoad, onError ) { + + let content; + const extensions = {}; + const plugins = {}; + + if ( typeof data === 'string' ) { + + content = data; + + } else { + + const magic = LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) ); + + if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) { + + try { + + extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); + + } catch ( error ) { + + if ( onError ) onError( error ); + return; + + } + + content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; + + } else { + + content = LoaderUtils.decodeText( new Uint8Array( data ) ); + + } + + } + + const json = JSON.parse( content ); + + if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) { + + if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) ); + return; + + } + + const parser = new GLTFParser( json, { + + path: path || this.resourcePath || '', + crossOrigin: this.crossOrigin, + requestHeader: this.requestHeader, + manager: this.manager, + ktx2Loader: this.ktx2Loader, + meshoptDecoder: this.meshoptDecoder + + } ); + + parser.fileLoader.setRequestHeader( this.requestHeader ); + + for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) { + + const plugin = this.pluginCallbacks[ i ]( parser ); + plugins[ plugin.name ] = plugin; + + // Workaround to avoid determining as unknown extension + // in addUnknownExtensionsToUserData(). + // Remove this workaround if we move all the existing + // extension handlers to plugin system + extensions[ plugin.name ] = true; + + } + + if ( json.extensionsUsed ) { + + for ( let i = 0; i < json.extensionsUsed.length; ++ i ) { + + const extensionName = json.extensionsUsed[ i ]; + const extensionsRequired = json.extensionsRequired || []; + + switch ( extensionName ) { + + case EXTENSIONS.KHR_MATERIALS_UNLIT: + extensions[ extensionName ] = new GLTFMaterialsUnlitExtension(); + break; + + case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: + extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension(); + break; + + case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION: + extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader ); + break; + + case EXTENSIONS.KHR_TEXTURE_TRANSFORM: + extensions[ extensionName ] = new GLTFTextureTransformExtension(); + break; + + case EXTENSIONS.KHR_MESH_QUANTIZATION: + extensions[ extensionName ] = new GLTFMeshQuantizationExtension(); + break; + + default: + + if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) { + + console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' ); + + } + + } + + } + + } + + parser.setExtensions( extensions ); + parser.setPlugins( plugins ); + parser.parse( onLoad, onError ); + + } + + parseAsync( data, path ) { + + const scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.parse( data, path, resolve, reject ); + + } ); + + } + +} + +/* GLTFREGISTRY */ + +function GLTFRegistry() { + + let objects = {}; + + return { + + get: function ( key ) { + + return objects[ key ]; + + }, + + add: function ( key, object ) { + + objects[ key ] = object; + + }, + + remove: function ( key ) { + + delete objects[ key ]; + + }, + + removeAll: function () { + + objects = {}; + + } + + }; + +} + +/*********************************/ +/********** EXTENSIONS ***********/ +/*********************************/ + +const EXTENSIONS = { + KHR_BINARY_GLTF: 'KHR_binary_glTF', + KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression', + KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual', + KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat', + KHR_MATERIALS_IOR: 'KHR_materials_ior', + KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness', + KHR_MATERIALS_SHEEN: 'KHR_materials_sheen', + KHR_MATERIALS_SPECULAR: 'KHR_materials_specular', + KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission', + KHR_MATERIALS_UNLIT: 'KHR_materials_unlit', + KHR_MATERIALS_VOLUME: 'KHR_materials_volume', + KHR_TEXTURE_BASISU: 'KHR_texture_basisu', + KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform', + KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization', + EXT_TEXTURE_WEBP: 'EXT_texture_webp', + EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression' +}; + +/** + * Punctual Lights Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual + */ +class GLTFLightsExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL; + + // Object3D instance caches + this.cache = { refs: {}, uses: {} }; + + } + + _markDefs() { + + const parser = this.parser; + const nodeDefs = this.parser.json.nodes || []; + + for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) { + + const nodeDef = nodeDefs[ nodeIndex ]; + + if ( nodeDef.extensions + && nodeDef.extensions[ this.name ] + && nodeDef.extensions[ this.name ].light !== undefined ) { + + parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light ); + + } + + } + + } + + _loadLight( lightIndex ) { + + const parser = this.parser; + const cacheKey = 'light:' + lightIndex; + let dependency = parser.cache.get( cacheKey ); + + if ( dependency ) return dependency; + + const json = parser.json; + const extensions = ( json.extensions && json.extensions[ this.name ] ) || {}; + const lightDefs = extensions.lights || []; + const lightDef = lightDefs[ lightIndex ]; + let lightNode; + + const color = new Color$1( 0xffffff ); + + if ( lightDef.color !== undefined ) color.fromArray( lightDef.color ); + + const range = lightDef.range !== undefined ? lightDef.range : 0; + + switch ( lightDef.type ) { + + case 'directional': + lightNode = new DirectionalLight( color ); + lightNode.target.position.set( 0, 0, - 1 ); + lightNode.add( lightNode.target ); + break; + + case 'point': + lightNode = new PointLight( color ); + lightNode.distance = range; + break; + + case 'spot': + lightNode = new SpotLight( color ); + lightNode.distance = range; + // Handle spotlight properties. + lightDef.spot = lightDef.spot || {}; + lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0; + lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0; + lightNode.angle = lightDef.spot.outerConeAngle; + lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle; + lightNode.target.position.set( 0, 0, - 1 ); + lightNode.add( lightNode.target ); + break; + + default: + throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type ); + + } + + // Some lights (e.g. spot) default to a position other than the origin. Reset the position + // here, because node-level parsing will only override position if explicitly specified. + lightNode.position.set( 0, 0, 0 ); + + lightNode.decay = 2; + + if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity; + + lightNode.name = parser.createUniqueName( lightDef.name || ( 'light_' + lightIndex ) ); + + dependency = Promise.resolve( lightNode ); + + parser.cache.add( cacheKey, dependency ); + + return dependency; + + } + + createNodeAttachment( nodeIndex ) { + + const self = this; + const parser = this.parser; + const json = parser.json; + const nodeDef = json.nodes[ nodeIndex ]; + const lightDef = ( nodeDef.extensions && nodeDef.extensions[ this.name ] ) || {}; + const lightIndex = lightDef.light; + + if ( lightIndex === undefined ) return null; + + return this._loadLight( lightIndex ).then( function ( light ) { + + return parser._getNodeRef( self.cache, lightIndex, light ); + + } ); + + } + +} + +/** + * Unlit Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit + */ +class GLTFMaterialsUnlitExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MATERIALS_UNLIT; + + } + + getMaterialType() { + + return MeshBasicMaterial; + + } + + extendParams( materialParams, materialDef, parser ) { + + const pending = []; + + materialParams.color = new Color$1( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + const metallicRoughness = materialDef.pbrMetallicRoughness; + + if ( metallicRoughness ) { + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + const array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) ); + + } + + } + + return Promise.all( pending ); + + } + +} + +/** + * Clearcoat Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat + */ +class GLTFMaterialsClearcoatExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.clearcoatFactor !== undefined ) { + + materialParams.clearcoat = extension.clearcoatFactor; + + } + + if ( extension.clearcoatTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) ); + + } + + if ( extension.clearcoatRoughnessFactor !== undefined ) { + + materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor; + + } + + if ( extension.clearcoatRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) ); + + } + + if ( extension.clearcoatNormalTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) ); + + if ( extension.clearcoatNormalTexture.scale !== undefined ) { + + const scale = extension.clearcoatNormalTexture.scale; + + materialParams.clearcoatNormalScale = new Vector2( scale, scale ); + + } + + } + + return Promise.all( pending ); + + } + +} + +/** + * Sheen Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen + */ +class GLTFMaterialsSheenExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_SHEEN; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + materialParams.sheenColor = new Color$1( 0, 0, 0 ); + materialParams.sheenRoughness = 0; + materialParams.sheen = 1; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.sheenColorFactor !== undefined ) { + + materialParams.sheenColor.fromArray( extension.sheenColorFactor ); + + } + + if ( extension.sheenRoughnessFactor !== undefined ) { + + materialParams.sheenRoughness = extension.sheenRoughnessFactor; + + } + + if ( extension.sheenColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture ) ); + + } + + if ( extension.sheenRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * Transmission Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission + * Draft: https://github.com/KhronosGroup/glTF/pull/1698 + */ +class GLTFMaterialsTransmissionExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.transmissionFactor !== undefined ) { + + materialParams.transmission = extension.transmissionFactor; + + } + + if ( extension.transmissionTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * Materials Volume Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume + */ +class GLTFMaterialsVolumeExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_VOLUME; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0; + + if ( extension.thicknessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) ); + + } + + materialParams.attenuationDistance = extension.attenuationDistance || 0; + + const colorArray = extension.attenuationColor || [ 1, 1, 1 ]; + materialParams.attenuationColor = new Color$1( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] ); + + return Promise.all( pending ); + + } + +} + +/** + * Materials ior Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior + */ +class GLTFMaterialsIorExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_IOR; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const extension = materialDef.extensions[ this.name ]; + + materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5; + + return Promise.resolve(); + + } + +} + +/** + * Materials specular Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular + */ +class GLTFMaterialsSpecularExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0; + + if ( extension.specularTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) ); + + } + + const colorArray = extension.specularColorFactor || [ 1, 1, 1 ]; + materialParams.specularColor = new Color$1( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] ); + + if ( extension.specularColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture ).then( function ( texture ) { + + texture.encoding = sRGBEncoding; + + } ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * BasisU Texture Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu + */ +class GLTFTextureBasisUExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_TEXTURE_BASISU; + + } + + loadTexture( textureIndex ) { + + const parser = this.parser; + const json = parser.json; + + const textureDef = json.textures[ textureIndex ]; + + if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) { + + return null; + + } + + const extension = textureDef.extensions[ this.name ]; + const source = json.images[ extension.source ]; + const loader = parser.options.ktx2Loader; + + if ( ! loader ) { + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' ); + + } else { + + // Assumes that the extension is optional and that a fallback texture is present + return null; + + } + + } + + return parser.loadTextureImage( textureIndex, source, loader ); + + } + +} + +/** + * WebP Texture Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp + */ +class GLTFTextureWebPExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.EXT_TEXTURE_WEBP; + this.isSupported = null; + + } + + loadTexture( textureIndex ) { + + const name = this.name; + const parser = this.parser; + const json = parser.json; + + const textureDef = json.textures[ textureIndex ]; + + if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) { + + return null; + + } + + const extension = textureDef.extensions[ name ]; + const source = json.images[ extension.source ]; + + let loader = parser.textureLoader; + if ( source.uri ) { + + const handler = parser.options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; + + } + + return this.detectSupport().then( function ( isSupported ) { + + if ( isSupported ) return parser.loadTextureImage( textureIndex, source, loader ); + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' ); + + } + + // Fall back to PNG or JPEG. + return parser.loadTexture( textureIndex ); + + } ); + + } + + detectSupport() { + + if ( ! this.isSupported ) { + + this.isSupported = new Promise( function ( resolve ) { + + const image = new Image(); + + // Lossy test image. Support for lossy images doesn't guarantee support for all + // WebP images, unfortunately. + image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA'; + + image.onload = image.onerror = function () { + + resolve( image.height === 1 ); + + }; + + } ); + + } + + return this.isSupported; + + } + +} + +/** + * meshopt BufferView Compression Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression + */ +class GLTFMeshoptCompression { + + constructor( parser ) { + + this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION; + this.parser = parser; + + } + + loadBufferView( index ) { + + const json = this.parser.json; + const bufferView = json.bufferViews[ index ]; + + if ( bufferView.extensions && bufferView.extensions[ this.name ] ) { + + const extensionDef = bufferView.extensions[ this.name ]; + + const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer ); + const decoder = this.parser.options.meshoptDecoder; + + if ( ! decoder || ! decoder.supported ) { + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' ); + + } else { + + // Assumes that the extension is optional and that fallback buffer data is present + return null; + + } + + } + + return Promise.all( [ buffer, decoder.ready ] ).then( function ( res ) { + + const byteOffset = extensionDef.byteOffset || 0; + const byteLength = extensionDef.byteLength || 0; + + const count = extensionDef.count; + const stride = extensionDef.byteStride; + + const result = new ArrayBuffer( count * stride ); + const source = new Uint8Array( res[ 0 ], byteOffset, byteLength ); + + decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter ); + return result; + + } ); + + } else { + + return null; + + } + + } + +} + +/* BINARY EXTENSION */ +const BINARY_EXTENSION_HEADER_MAGIC = 'glTF'; +const BINARY_EXTENSION_HEADER_LENGTH = 12; +const BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 }; + +class GLTFBinaryExtension { + + constructor( data ) { + + this.name = EXTENSIONS.KHR_BINARY_GLTF; + this.content = null; + this.body = null; + + const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH ); + + this.header = { + magic: LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ), + version: headerView.getUint32( 4, true ), + length: headerView.getUint32( 8, true ) + }; + + if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) { + + throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' ); + + } else if ( this.header.version < 2.0 ) { + + throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' ); + + } + + const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH; + const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH ); + let chunkIndex = 0; + + while ( chunkIndex < chunkContentsLength ) { + + const chunkLength = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + const chunkType = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) { + + const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength ); + this.content = LoaderUtils.decodeText( contentArray ); + + } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) { + + const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex; + this.body = data.slice( byteOffset, byteOffset + chunkLength ); + + } + + // Clients must ignore chunks with unknown types. + + chunkIndex += chunkLength; + + } + + if ( this.content === null ) { + + throw new Error( 'THREE.GLTFLoader: JSON content not found.' ); + + } + + } + +} + +/** + * DRACO Mesh Compression Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression + */ +class GLTFDracoMeshCompressionExtension { + + constructor( json, dracoLoader ) { + + if ( ! dracoLoader ) { + + throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' ); + + } + + this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION; + this.json = json; + this.dracoLoader = dracoLoader; + this.dracoLoader.preload(); + + } + + decodePrimitive( primitive, parser ) { + + const json = this.json; + const dracoLoader = this.dracoLoader; + const bufferViewIndex = primitive.extensions[ this.name ].bufferView; + const gltfAttributeMap = primitive.extensions[ this.name ].attributes; + const threeAttributeMap = {}; + const attributeNormalizedMap = {}; + const attributeTypeMap = {}; + + for ( const attributeName in gltfAttributeMap ) { + + const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase(); + + threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ]; + + } + + for ( const attributeName in primitive.attributes ) { + + const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase(); + + if ( gltfAttributeMap[ attributeName ] !== undefined ) { + + const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ]; + const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + attributeTypeMap[ threeAttributeName ] = componentType; + attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true; + + } + + } + + return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) { + + return new Promise( function ( resolve ) { + + dracoLoader.decodeDracoFile( bufferView, function ( geometry ) { + + for ( const attributeName in geometry.attributes ) { + + const attribute = geometry.attributes[ attributeName ]; + const normalized = attributeNormalizedMap[ attributeName ]; + + if ( normalized !== undefined ) attribute.normalized = normalized; + + } + + resolve( geometry ); + + }, threeAttributeMap, attributeTypeMap ); + + } ); + + } ); + + } + +} + +/** + * Texture Transform Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform + */ +class GLTFTextureTransformExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM; + + } + + extendTexture( texture, transform ) { + + if ( transform.texCoord !== undefined ) { + + console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' ); + + } + + if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) { + + // See https://github.com/mrdoob/three.js/issues/21819. + return texture; + + } + + texture = texture.clone(); + + if ( transform.offset !== undefined ) { + + texture.offset.fromArray( transform.offset ); + + } + + if ( transform.rotation !== undefined ) { + + texture.rotation = transform.rotation; + + } + + if ( transform.scale !== undefined ) { + + texture.repeat.fromArray( transform.scale ); + + } + + texture.needsUpdate = true; + + return texture; + + } + +} + +/** + * Specular-Glossiness Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness + */ + +/** + * A sub class of StandardMaterial with some of the functionality + * changed via the `onBeforeCompile` callback + * @pailhead + */ +class GLTFMeshStandardSGMaterial extends MeshStandardMaterial { + + constructor( params ) { + + super(); + + this.isGLTFSpecularGlossinessMaterial = true; + + //various chunks that need replacing + const specularMapParsFragmentChunk = [ + '#ifdef USE_SPECULARMAP', + ' uniform sampler2D specularMap;', + '#endif' + ].join( '\n' ); + + const glossinessMapParsFragmentChunk = [ + '#ifdef USE_GLOSSINESSMAP', + ' uniform sampler2D glossinessMap;', + '#endif' + ].join( '\n' ); + + const specularMapFragmentChunk = [ + 'vec3 specularFactor = specular;', + '#ifdef USE_SPECULARMAP', + ' vec4 texelSpecular = texture2D( specularMap, vUv );', + ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' specularFactor *= texelSpecular.rgb;', + '#endif' + ].join( '\n' ); + + const glossinessMapFragmentChunk = [ + 'float glossinessFactor = glossiness;', + '#ifdef USE_GLOSSINESSMAP', + ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', + ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' glossinessFactor *= texelGlossiness.a;', + '#endif' + ].join( '\n' ); + + const lightPhysicalFragmentChunk = [ + 'PhysicalMaterial material;', + 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', + 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', + 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', + 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', + 'material.roughness += geometryRoughness;', + 'material.roughness = min( material.roughness, 1.0 );', + 'material.specularColor = specularFactor;', + ].join( '\n' ); + + const uniforms = { + specular: { value: new Color$1().setHex( 0xffffff ) }, + glossiness: { value: 1 }, + specularMap: { value: null }, + glossinessMap: { value: null } + }; + + this._extraUniforms = uniforms; + + this.onBeforeCompile = function ( shader ) { + + for ( const uniformName in uniforms ) { + + shader.uniforms[ uniformName ] = uniforms[ uniformName ]; + + } + + shader.fragmentShader = shader.fragmentShader + .replace( 'uniform float roughness;', 'uniform vec3 specular;' ) + .replace( 'uniform float metalness;', 'uniform float glossiness;' ) + .replace( '#include ', specularMapParsFragmentChunk ) + .replace( '#include ', glossinessMapParsFragmentChunk ) + .replace( '#include ', specularMapFragmentChunk ) + .replace( '#include ', glossinessMapFragmentChunk ) + .replace( '#include ', lightPhysicalFragmentChunk ); + + }; + + Object.defineProperties( this, { + + specular: { + get: function () { + + return uniforms.specular.value; + + }, + set: function ( v ) { + + uniforms.specular.value = v; + + } + }, + + specularMap: { + get: function () { + + return uniforms.specularMap.value; + + }, + set: function ( v ) { + + uniforms.specularMap.value = v; + + if ( v ) { + + this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps + + } else { + + delete this.defines.USE_SPECULARMAP; + + } + + } + }, + + glossiness: { + get: function () { + + return uniforms.glossiness.value; + + }, + set: function ( v ) { + + uniforms.glossiness.value = v; + + } + }, + + glossinessMap: { + get: function () { + + return uniforms.glossinessMap.value; + + }, + set: function ( v ) { + + uniforms.glossinessMap.value = v; + + if ( v ) { + + this.defines.USE_GLOSSINESSMAP = ''; + this.defines.USE_UV = ''; + + } else { + + delete this.defines.USE_GLOSSINESSMAP; + delete this.defines.USE_UV; + + } + + } + } + + } ); + + delete this.metalness; + delete this.roughness; + delete this.metalnessMap; + delete this.roughnessMap; + + this.setValues( params ); + + } + + copy( source ) { + + super.copy( source ); + + this.specularMap = source.specularMap; + this.specular.copy( source.specular ); + this.glossinessMap = source.glossinessMap; + this.glossiness = source.glossiness; + delete this.metalness; + delete this.roughness; + delete this.metalnessMap; + delete this.roughnessMap; + return this; + + } + +} + + +class GLTFMaterialsPbrSpecularGlossinessExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS; + + this.specularGlossinessParams = [ + 'color', + 'map', + 'lightMap', + 'lightMapIntensity', + 'aoMap', + 'aoMapIntensity', + 'emissive', + 'emissiveIntensity', + 'emissiveMap', + 'bumpMap', + 'bumpScale', + 'normalMap', + 'normalMapType', + 'displacementMap', + 'displacementScale', + 'displacementBias', + 'specularMap', + 'specular', + 'glossinessMap', + 'glossiness', + 'alphaMap', + 'envMap', + 'envMapIntensity', + 'refractionRatio', + ]; + + } + + getMaterialType() { + + return GLTFMeshStandardSGMaterial; + + } + + extendParams( materialParams, materialDef, parser ) { + + const pbrSpecularGlossiness = materialDef.extensions[ this.name ]; + + materialParams.color = new Color$1( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + const pending = []; + + if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) { + + const array = pbrSpecularGlossiness.diffuseFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture ) ); + + } + + materialParams.emissive = new Color$1( 0.0, 0.0, 0.0 ); + materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0; + materialParams.specular = new Color$1( 1.0, 1.0, 1.0 ); + + if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) { + + materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor ); + + } + + if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) { + + const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture; + pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) ); + pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef ) ); + + } + + return Promise.all( pending ); + + } + + createMaterial( materialParams ) { + + const material = new GLTFMeshStandardSGMaterial( materialParams ); + material.fog = true; + + material.color = materialParams.color; + + material.map = materialParams.map === undefined ? null : materialParams.map; + + material.lightMap = null; + material.lightMapIntensity = 1.0; + + material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap; + material.aoMapIntensity = 1.0; + + material.emissive = materialParams.emissive; + material.emissiveIntensity = 1.0; + material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap; + + material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap; + material.bumpScale = 1; + + material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap; + material.normalMapType = TangentSpaceNormalMap; + + if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale; + + material.displacementMap = null; + material.displacementScale = 1; + material.displacementBias = 0; + + material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap; + material.specular = materialParams.specular; + + material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap; + material.glossiness = materialParams.glossiness; + + material.alphaMap = null; + + material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap; + material.envMapIntensity = 1.0; + + material.refractionRatio = 0.98; + + return material; + + } + +} + +/** + * Mesh Quantization Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization + */ +class GLTFMeshQuantizationExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MESH_QUANTIZATION; + + } + +} + +/*********************************/ +/********** INTERPOLATION ********/ +/*********************************/ + +// Spline Interpolation +// Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation +class GLTFCubicSplineInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + copySampleValue_( index ) { + + // Copies a sample value to the result buffer. See description of glTF + // CUBICSPLINE values layout in interpolate_() function below. + + const result = this.resultBuffer, + values = this.sampleValues, + valueSize = this.valueSize, + offset = index * valueSize * 3 + valueSize; + + for ( let i = 0; i !== valueSize; i ++ ) { + + result[ i ] = values[ offset + i ]; + + } + + return result; + + } + +} + +GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + +GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + +GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) { + + const result = this.resultBuffer; + const values = this.sampleValues; + const stride = this.valueSize; + + const stride2 = stride * 2; + const stride3 = stride * 3; + + const td = t1 - t0; + + const p = ( t - t0 ) / td; + const pp = p * p; + const ppp = pp * p; + + const offset1 = i1 * stride3; + const offset0 = offset1 - stride3; + + const s2 = - 2 * ppp + 3 * pp; + const s3 = ppp - pp; + const s0 = 1 - s2; + const s1 = s3 - pp + p; + + // Layout of keyframe output values for CUBICSPLINE animations: + // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ] + for ( let i = 0; i !== stride; i ++ ) { + + const p0 = values[ offset0 + i + stride ]; // splineVertex_k + const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k) + const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1 + const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k) + + result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1; + + } + + return result; + +}; + +const _q = new Quaternion(); + +class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant { + + interpolate_( i1, t0, t, t1 ) { + + const result = super.interpolate_( i1, t0, t, t1 ); + + _q.fromArray( result ).normalize().toArray( result ); + + return result; + + } + +} + + +/*********************************/ +/********** INTERNALS ************/ +/*********************************/ + +/* CONSTANTS */ + +const WEBGL_CONSTANTS = { + FLOAT: 5126, + //FLOAT_MAT2: 35674, + FLOAT_MAT3: 35675, + FLOAT_MAT4: 35676, + FLOAT_VEC2: 35664, + FLOAT_VEC3: 35665, + FLOAT_VEC4: 35666, + LINEAR: 9729, + REPEAT: 10497, + SAMPLER_2D: 35678, + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6, + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123 +}; + +const WEBGL_COMPONENT_TYPES = { + 5120: Int8Array, + 5121: Uint8Array, + 5122: Int16Array, + 5123: Uint16Array, + 5125: Uint32Array, + 5126: Float32Array +}; + +const WEBGL_FILTERS = { + 9728: NearestFilter, + 9729: LinearFilter, + 9984: NearestMipmapNearestFilter, + 9985: LinearMipmapNearestFilter, + 9986: NearestMipmapLinearFilter, + 9987: LinearMipmapLinearFilter +}; + +const WEBGL_WRAPPINGS = { + 33071: ClampToEdgeWrapping, + 33648: MirroredRepeatWrapping, + 10497: RepeatWrapping +}; + +const WEBGL_TYPE_SIZES = { + 'SCALAR': 1, + 'VEC2': 2, + 'VEC3': 3, + 'VEC4': 4, + 'MAT2': 4, + 'MAT3': 9, + 'MAT4': 16 +}; + +const ATTRIBUTES = { + POSITION: 'position', + NORMAL: 'normal', + TANGENT: 'tangent', + TEXCOORD_0: 'uv', + TEXCOORD_1: 'uv2', + COLOR_0: 'color', + WEIGHTS_0: 'skinWeight', + JOINTS_0: 'skinIndex', +}; + +const PATH_PROPERTIES = { + scale: 'scale', + translation: 'position', + rotation: 'quaternion', + weights: 'morphTargetInfluences' +}; + +const INTERPOLATION = { + CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each + // keyframe track will be initialized with a default interpolation type, then modified. + LINEAR: InterpolateLinear, + STEP: InterpolateDiscrete +}; + +const ALPHA_MODES = { + OPAQUE: 'OPAQUE', + MASK: 'MASK', + BLEND: 'BLEND' +}; + +/** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material + */ +function createDefaultMaterial( cache ) { + + if ( cache[ 'DefaultMaterial' ] === undefined ) { + + cache[ 'DefaultMaterial' ] = new MeshStandardMaterial( { + color: 0xFFFFFF, + emissive: 0x000000, + metalness: 1, + roughness: 1, + transparent: false, + depthTest: true, + side: FrontSide + } ); + + } + + return cache[ 'DefaultMaterial' ]; + +} + +function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) { + + // Add unknown glTF extensions to an object's userData. + + for ( const name in objectDef.extensions ) { + + if ( knownExtensions[ name ] === undefined ) { + + object.userData.gltfExtensions = object.userData.gltfExtensions || {}; + object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ]; + + } + + } + +} + +/** + * @param {Object3D|Material|BufferGeometry} object + * @param {GLTF.definition} gltfDef + */ +function assignExtrasToUserData( object, gltfDef ) { + + if ( gltfDef.extras !== undefined ) { + + if ( typeof gltfDef.extras === 'object' ) { + + Object.assign( object.userData, gltfDef.extras ); + + } else { + + console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras ); + + } + + } + +} + +/** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets + * + * @param {BufferGeometry} geometry + * @param {Array} targets + * @param {GLTFParser} parser + * @return {Promise} + */ +function addMorphTargets( geometry, targets, parser ) { + + let hasMorphPosition = false; + let hasMorphNormal = false; + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( target.POSITION !== undefined ) hasMorphPosition = true; + if ( target.NORMAL !== undefined ) hasMorphNormal = true; + + if ( hasMorphPosition && hasMorphNormal ) break; + + } + + if ( ! hasMorphPosition && ! hasMorphNormal ) return Promise.resolve( geometry ); + + const pendingPositionAccessors = []; + const pendingNormalAccessors = []; + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( hasMorphPosition ) { + + const pendingAccessor = target.POSITION !== undefined + ? parser.getDependency( 'accessor', target.POSITION ) + : geometry.attributes.position; + + pendingPositionAccessors.push( pendingAccessor ); + + } + + if ( hasMorphNormal ) { + + const pendingAccessor = target.NORMAL !== undefined + ? parser.getDependency( 'accessor', target.NORMAL ) + : geometry.attributes.normal; + + pendingNormalAccessors.push( pendingAccessor ); + + } + + } + + return Promise.all( [ + Promise.all( pendingPositionAccessors ), + Promise.all( pendingNormalAccessors ) + ] ).then( function ( accessors ) { + + const morphPositions = accessors[ 0 ]; + const morphNormals = accessors[ 1 ]; + + if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions; + if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals; + geometry.morphTargetsRelative = true; + + return geometry; + + } ); + +} + +/** + * @param {Mesh} mesh + * @param {GLTF.Mesh} meshDef + */ +function updateMorphTargets( mesh, meshDef ) { + + mesh.updateMorphTargets(); + + if ( meshDef.weights !== undefined ) { + + for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) { + + mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ]; + + } + + } + + // .extras has user-defined data, so check that .extras.targetNames is an array. + if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) { + + const targetNames = meshDef.extras.targetNames; + + if ( mesh.morphTargetInfluences.length === targetNames.length ) { + + mesh.morphTargetDictionary = {}; + + for ( let i = 0, il = targetNames.length; i < il; i ++ ) { + + mesh.morphTargetDictionary[ targetNames[ i ] ] = i; + + } + + } else { + + console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' ); + + } + + } + +} + +function createPrimitiveKey( primitiveDef ) { + + const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]; + let geometryKey; + + if ( dracoExtension ) { + + geometryKey = 'draco:' + dracoExtension.bufferView + + ':' + dracoExtension.indices + + ':' + createAttributesKey( dracoExtension.attributes ); + + } else { + + geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode; + + } + + return geometryKey; + +} + +function createAttributesKey( attributes ) { + + let attributesKey = ''; + + const keys = Object.keys( attributes ).sort(); + + for ( let i = 0, il = keys.length; i < il; i ++ ) { + + attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';'; + + } + + return attributesKey; + +} + +function getNormalizedComponentScale( constructor ) { + + // Reference: + // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data + + switch ( constructor ) { + + case Int8Array: + return 1 / 127; + + case Uint8Array: + return 1 / 255; + + case Int16Array: + return 1 / 32767; + + case Uint16Array: + return 1 / 65535; + + default: + throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' ); + + } + +} + +/* GLTF PARSER */ + +class GLTFParser { + + constructor( json = {}, options = {} ) { + + this.json = json; + this.extensions = {}; + this.plugins = {}; + this.options = options; + + // loader object cache + this.cache = new GLTFRegistry(); + + // associations between Three.js objects and glTF elements + this.associations = new Map(); + + // BufferGeometry caching + this.primitiveCache = {}; + + // Object3D instance caches + this.meshCache = { refs: {}, uses: {} }; + this.cameraCache = { refs: {}, uses: {} }; + this.lightCache = { refs: {}, uses: {} }; + + this.textureCache = {}; + + // Track node names, to ensure no duplicates + this.nodeNamesUsed = {}; + + // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the + // expensive work of uploading a texture to the GPU off the main thread. + if ( typeof createImageBitmap !== 'undefined' && /Firefox|Safari/.test( navigator.userAgent ) === false ) { + + this.textureLoader = new ImageBitmapLoader( this.options.manager ); + + } else { + + this.textureLoader = new TextureLoader( this.options.manager ); + + } + + this.textureLoader.setCrossOrigin( this.options.crossOrigin ); + this.textureLoader.setRequestHeader( this.options.requestHeader ); + + this.fileLoader = new FileLoader( this.options.manager ); + this.fileLoader.setResponseType( 'arraybuffer' ); + + if ( this.options.crossOrigin === 'use-credentials' ) { + + this.fileLoader.setWithCredentials( true ); + + } + + } + + setExtensions( extensions ) { + + this.extensions = extensions; + + } + + setPlugins( plugins ) { + + this.plugins = plugins; + + } + + parse( onLoad, onError ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + + // Clear the loader cache + this.cache.removeAll(); + + // Mark the special nodes/meshes in json for efficient parse + this._invokeAll( function ( ext ) { + + return ext._markDefs && ext._markDefs(); + + } ); + + Promise.all( this._invokeAll( function ( ext ) { + + return ext.beforeRoot && ext.beforeRoot(); + + } ) ).then( function () { + + return Promise.all( [ + + parser.getDependencies( 'scene' ), + parser.getDependencies( 'animation' ), + parser.getDependencies( 'camera' ), + + ] ); + + } ).then( function ( dependencies ) { + + const result = { + scene: dependencies[ 0 ][ json.scene || 0 ], + scenes: dependencies[ 0 ], + animations: dependencies[ 1 ], + cameras: dependencies[ 2 ], + asset: json.asset, + parser: parser, + userData: {} + }; + + addUnknownExtensionsToUserData( extensions, result, json ); + + assignExtrasToUserData( result, json ); + + Promise.all( parser._invokeAll( function ( ext ) { + + return ext.afterRoot && ext.afterRoot( result ); + + } ) ).then( function () { + + onLoad( result ); + + } ); + + } ).catch( onError ); + + } + + /** + * Marks the special nodes/meshes in json for efficient parse. + */ + _markDefs() { + + const nodeDefs = this.json.nodes || []; + const skinDefs = this.json.skins || []; + const meshDefs = this.json.meshes || []; + + // Nothing in the node definition indicates whether it is a Bone or an + // Object3D. Use the skins' joint references to mark bones. + for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) { + + const joints = skinDefs[ skinIndex ].joints; + + for ( let i = 0, il = joints.length; i < il; i ++ ) { + + nodeDefs[ joints[ i ] ].isBone = true; + + } + + } + + // Iterate over all nodes, marking references to shared resources, + // as well as skeleton joints. + for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) { + + const nodeDef = nodeDefs[ nodeIndex ]; + + if ( nodeDef.mesh !== undefined ) { + + this._addNodeRef( this.meshCache, nodeDef.mesh ); + + // Nothing in the mesh definition indicates whether it is + // a SkinnedMesh or Mesh. Use the node's mesh reference + // to mark SkinnedMesh if node has skin. + if ( nodeDef.skin !== undefined ) { + + meshDefs[ nodeDef.mesh ].isSkinnedMesh = true; + + } + + } + + if ( nodeDef.camera !== undefined ) { + + this._addNodeRef( this.cameraCache, nodeDef.camera ); + + } + + } + + } + + /** + * Counts references to shared node / Object3D resources. These resources + * can be reused, or "instantiated", at multiple nodes in the scene + * hierarchy. Mesh, Camera, and Light instances are instantiated and must + * be marked. Non-scenegraph resources (like Materials, Geometries, and + * Textures) can be reused directly and are not marked here. + * + * Example: CesiumMilkTruck sample model reuses "Wheel" meshes. + */ + _addNodeRef( cache, index ) { + + if ( index === undefined ) return; + + if ( cache.refs[ index ] === undefined ) { + + cache.refs[ index ] = cache.uses[ index ] = 0; + + } + + cache.refs[ index ] ++; + + } + + /** Returns a reference to a shared resource, cloning it if necessary. */ + _getNodeRef( cache, index, object ) { + + if ( cache.refs[ index ] <= 1 ) return object; + + const ref = object.clone(); + + // Propagates mappings to the cloned object, prevents mappings on the + // original object from being lost. + const updateMappings = ( original, clone ) => { + + const mappings = this.associations.get( original ); + if ( mappings != null ) { + + this.associations.set( clone, mappings ); + + } + + for ( const [ i, child ] of original.children.entries() ) { + + updateMappings( child, clone.children[ i ] ); + + } + + }; + + updateMappings( object, ref ); + + ref.name += '_instance_' + ( cache.uses[ index ] ++ ); + + return ref; + + } + + _invokeOne( func ) { + + const extensions = Object.values( this.plugins ); + extensions.push( this ); + + for ( let i = 0; i < extensions.length; i ++ ) { + + const result = func( extensions[ i ] ); + + if ( result ) return result; + + } + + return null; + + } + + _invokeAll( func ) { + + const extensions = Object.values( this.plugins ); + extensions.unshift( this ); + + const pending = []; + + for ( let i = 0; i < extensions.length; i ++ ) { + + const result = func( extensions[ i ] ); + + if ( result ) pending.push( result ); + + } + + return pending; + + } + + /** + * Requests the specified dependency asynchronously, with caching. + * @param {string} type + * @param {number} index + * @return {Promise} + */ + getDependency( type, index ) { + + const cacheKey = type + ':' + index; + let dependency = this.cache.get( cacheKey ); + + if ( ! dependency ) { + + switch ( type ) { + + case 'scene': + dependency = this.loadScene( index ); + break; + + case 'node': + dependency = this.loadNode( index ); + break; + + case 'mesh': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadMesh && ext.loadMesh( index ); + + } ); + break; + + case 'accessor': + dependency = this.loadAccessor( index ); + break; + + case 'bufferView': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadBufferView && ext.loadBufferView( index ); + + } ); + break; + + case 'buffer': + dependency = this.loadBuffer( index ); + break; + + case 'material': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadMaterial && ext.loadMaterial( index ); + + } ); + break; + + case 'texture': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadTexture && ext.loadTexture( index ); + + } ); + break; + + case 'skin': + dependency = this.loadSkin( index ); + break; + + case 'animation': + dependency = this.loadAnimation( index ); + break; + + case 'camera': + dependency = this.loadCamera( index ); + break; + + default: + throw new Error( 'Unknown type: ' + type ); + + } + + this.cache.add( cacheKey, dependency ); + + } + + return dependency; + + } + + /** + * Requests all dependencies of the specified type asynchronously, with caching. + * @param {string} type + * @return {Promise>} + */ + getDependencies( type ) { + + let dependencies = this.cache.get( type ); + + if ( ! dependencies ) { + + const parser = this; + const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || []; + + dependencies = Promise.all( defs.map( function ( def, index ) { + + return parser.getDependency( type, index ); + + } ) ); + + this.cache.add( type, dependencies ); + + } + + return dependencies; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferIndex + * @return {Promise} + */ + loadBuffer( bufferIndex ) { + + const bufferDef = this.json.buffers[ bufferIndex ]; + const loader = this.fileLoader; + + if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) { + + throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' ); + + } + + // If present, GLB container is required to be the first buffer. + if ( bufferDef.uri === undefined && bufferIndex === 0 ) { + + return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body ); + + } + + const options = this.options; + + return new Promise( function ( resolve, reject ) { + + loader.load( LoaderUtils.resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () { + + reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) ); + + } ); + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferViewIndex + * @return {Promise} + */ + loadBufferView( bufferViewIndex ) { + + const bufferViewDef = this.json.bufferViews[ bufferViewIndex ]; + + return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) { + + const byteLength = bufferViewDef.byteLength || 0; + const byteOffset = bufferViewDef.byteOffset || 0; + return buffer.slice( byteOffset, byteOffset + byteLength ); + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors + * @param {number} accessorIndex + * @return {Promise} + */ + loadAccessor( accessorIndex ) { + + const parser = this; + const json = this.json; + + const accessorDef = this.json.accessors[ accessorIndex ]; + + if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) { + + // Ignore empty accessors, which may be used to declare runtime + // information about attributes coming from another source (e.g. Draco + // compression extension). + return Promise.resolve( null ); + + } + + const pendingBufferViews = []; + + if ( accessorDef.bufferView !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) ); + + } else { + + pendingBufferViews.push( null ); + + } + + if ( accessorDef.sparse !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) ); + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) ); + + } + + return Promise.all( pendingBufferViews ).then( function ( bufferViews ) { + + const bufferView = bufferViews[ 0 ]; + + const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ]; + const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. + const elementBytes = TypedArray.BYTES_PER_ELEMENT; + const itemBytes = elementBytes * itemSize; + const byteOffset = accessorDef.byteOffset || 0; + const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined; + const normalized = accessorDef.normalized === true; + let array, bufferAttribute; + + // The buffer is not interleaved if the stride is the item size in bytes. + if ( byteStride && byteStride !== itemBytes ) { + + // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer + // This makes sure that IBA.count reflects accessor.count properly + const ibSlice = Math.floor( byteOffset / byteStride ); + const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count; + let ib = parser.cache.get( ibCacheKey ); + + if ( ! ib ) { + + array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes ); + + // Integer parameters to IB/IBA are in array elements, not bytes. + ib = new InterleavedBuffer( array, byteStride / elementBytes ); + + parser.cache.add( ibCacheKey, ib ); + + } + + bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized ); + + } else { + + if ( bufferView === null ) { + + array = new TypedArray( accessorDef.count * itemSize ); + + } else { + + array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize ); + + } + + bufferAttribute = new BufferAttribute( array, itemSize, normalized ); + + } + + // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors + if ( accessorDef.sparse !== undefined ) { + + const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR; + const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ]; + + const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0; + const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0; + + const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices ); + const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize ); + + if ( bufferView !== null ) { + + // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes. + bufferAttribute = new BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized ); + + } + + for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) { + + const index = sparseIndices[ i ]; + + bufferAttribute.setX( index, sparseValues[ i * itemSize ] ); + if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] ); + if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] ); + if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] ); + if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.' ); + + } + + } + + return bufferAttribute; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures + * @param {number} textureIndex + * @return {Promise} + */ + loadTexture( textureIndex ) { + + const json = this.json; + const options = this.options; + const textureDef = json.textures[ textureIndex ]; + const source = json.images[ textureDef.source ]; + + let loader = this.textureLoader; + + if ( source.uri ) { + + const handler = options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; + + } + + return this.loadTextureImage( textureIndex, source, loader ); + + } + + loadTextureImage( textureIndex, source, loader ) { + + const parser = this; + const json = this.json; + const options = this.options; + + const textureDef = json.textures[ textureIndex ]; + + const cacheKey = ( source.uri || source.bufferView ) + ':' + textureDef.sampler; + + if ( this.textureCache[ cacheKey ] ) { + + // See https://github.com/mrdoob/three.js/issues/21559. + return this.textureCache[ cacheKey ]; + + } + + const URL = self.URL || self.webkitURL; + + let sourceURI = source.uri || ''; + let isObjectURL = false; + + if ( source.bufferView !== undefined ) { + + // Load binary image data from bufferView, if provided. + + sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) { + + isObjectURL = true; + const blob = new Blob( [ bufferView ], { type: source.mimeType } ); + sourceURI = URL.createObjectURL( blob ); + return sourceURI; + + } ); + + } else if ( source.uri === undefined ) { + + throw new Error( 'THREE.GLTFLoader: Image ' + textureIndex + ' is missing URI and bufferView' ); + + } + + const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) { + + return new Promise( function ( resolve, reject ) { + + let onLoad = resolve; + + if ( loader.isImageBitmapLoader === true ) { + + onLoad = function ( imageBitmap ) { + + const texture = new Texture( imageBitmap ); + texture.needsUpdate = true; + + resolve( texture ); + + }; + + } + + loader.load( LoaderUtils.resolveURL( sourceURI, options.path ), onLoad, undefined, reject ); + + } ); + + } ).then( function ( texture ) { + + // Clean up resources and configure Texture. + + if ( isObjectURL === true ) { + + URL.revokeObjectURL( sourceURI ); + + } + + texture.flipY = false; + + if ( textureDef.name ) texture.name = textureDef.name; + + const samplers = json.samplers || {}; + const sampler = samplers[ textureDef.sampler ] || {}; + + texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || LinearFilter; + texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter; + texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping; + texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping; + + parser.associations.set( texture, { textures: textureIndex } ); + + return texture; + + } ).catch( function () { + + console.error( 'THREE.GLTFLoader: Couldn\'t load texture', sourceURI ); + return null; + + } ); + + this.textureCache[ cacheKey ] = promise; + + return promise; + + } + + /** + * Asynchronously assigns a texture to the given material parameters. + * @param {Object} materialParams + * @param {string} mapName + * @param {Object} mapDef + * @return {Promise} + */ + assignTexture( materialParams, mapName, mapDef ) { + + const parser = this; + + return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) { + + // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured + // However, we will copy UV set 0 to UV set 1 on demand for aoMap + if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) { + + console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' ); + + } + + if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) { + + const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined; + + if ( transform ) { + + const gltfReference = parser.associations.get( texture ); + texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform ); + parser.associations.set( texture, gltfReference ); + + } + + } + + materialParams[ mapName ] = texture; + + return texture; + + } ); + + } + + /** + * Assigns final material to a Mesh, Line, or Points instance. The instance + * already has a material (generated from the glTF material options alone) + * but reuse of the same glTF material may require multiple threejs materials + * to accommodate different primitive types, defines, etc. New materials will + * be created if necessary, and reused from a cache. + * @param {Object3D} mesh Mesh, Line, or Points instance. + */ + assignFinalMaterial( mesh ) { + + const geometry = mesh.geometry; + let material = mesh.material; + + const useDerivativeTangents = geometry.attributes.tangent === undefined; + const useVertexColors = geometry.attributes.color !== undefined; + const useFlatShading = geometry.attributes.normal === undefined; + + if ( mesh.isPoints ) { + + const cacheKey = 'PointsMaterial:' + material.uuid; + + let pointsMaterial = this.cache.get( cacheKey ); + + if ( ! pointsMaterial ) { + + pointsMaterial = new PointsMaterial(); + Material.prototype.copy.call( pointsMaterial, material ); + pointsMaterial.color.copy( material.color ); + pointsMaterial.map = material.map; + pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px + + this.cache.add( cacheKey, pointsMaterial ); + + } + + material = pointsMaterial; + + } else if ( mesh.isLine ) { + + const cacheKey = 'LineBasicMaterial:' + material.uuid; + + let lineMaterial = this.cache.get( cacheKey ); + + if ( ! lineMaterial ) { + + lineMaterial = new LineBasicMaterial(); + Material.prototype.copy.call( lineMaterial, material ); + lineMaterial.color.copy( material.color ); + + this.cache.add( cacheKey, lineMaterial ); + + } + + material = lineMaterial; + + } + + // Clone the material if it will be modified + if ( useDerivativeTangents || useVertexColors || useFlatShading ) { + + let cacheKey = 'ClonedMaterial:' + material.uuid + ':'; + + if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:'; + if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:'; + if ( useVertexColors ) cacheKey += 'vertex-colors:'; + if ( useFlatShading ) cacheKey += 'flat-shading:'; + + let cachedMaterial = this.cache.get( cacheKey ); + + if ( ! cachedMaterial ) { + + cachedMaterial = material.clone(); + + if ( useVertexColors ) cachedMaterial.vertexColors = true; + if ( useFlatShading ) cachedMaterial.flatShading = true; + + if ( useDerivativeTangents ) { + + // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995 + if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1; + if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1; + + } + + this.cache.add( cacheKey, cachedMaterial ); + + this.associations.set( cachedMaterial, this.associations.get( material ) ); + + } + + material = cachedMaterial; + + } + + // workarounds for mesh and geometry + + if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) { + + geometry.setAttribute( 'uv2', geometry.attributes.uv ); + + } + + mesh.material = material; + + } + + getMaterialType( /* materialIndex */ ) { + + return MeshStandardMaterial; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials + * @param {number} materialIndex + * @return {Promise} + */ + loadMaterial( materialIndex ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + const materialDef = json.materials[ materialIndex ]; + + let materialType; + const materialParams = {}; + const materialExtensions = materialDef.extensions || {}; + + const pending = []; + + if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) { + + const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ]; + materialType = sgExtension.getMaterialType(); + pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) ); + + } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) { + + const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ]; + materialType = kmuExtension.getMaterialType(); + pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) ); + + } else { + + // Specification: + // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material + + const metallicRoughness = materialDef.pbrMetallicRoughness || {}; + + materialParams.color = new Color$1( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + const array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) ); + + } + + materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0; + materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0; + + if ( metallicRoughness.metallicRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) ); + pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) ); + + } + + materialType = this._invokeOne( function ( ext ) { + + return ext.getMaterialType && ext.getMaterialType( materialIndex ); + + } ); + + pending.push( Promise.all( this._invokeAll( function ( ext ) { + + return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams ); + + } ) ) ); + + } + + if ( materialDef.doubleSided === true ) { + + materialParams.side = DoubleSide; + + } + + const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE; + + if ( alphaMode === ALPHA_MODES.BLEND ) { + + materialParams.transparent = true; + + // See: https://github.com/mrdoob/three.js/issues/17706 + materialParams.depthWrite = false; + + } else { + + materialParams.transparent = false; + materialParams.alphaWrite = false; + + if ( alphaMode === ALPHA_MODES.MASK ) { + + materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5; + + } + + } + + if ( materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) ); + + materialParams.normalScale = new Vector2( 1, 1 ); + + if ( materialDef.normalTexture.scale !== undefined ) { + + const scale = materialDef.normalTexture.scale; + + materialParams.normalScale.set( scale, scale ); + + } + + } + + if ( materialDef.occlusionTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) ); + + if ( materialDef.occlusionTexture.strength !== undefined ) { + + materialParams.aoMapIntensity = materialDef.occlusionTexture.strength; + + } + + } + + if ( materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial ) { + + materialParams.emissive = new Color$1().fromArray( materialDef.emissiveFactor ); + + } + + if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture ) ); + + } + + return Promise.all( pending ).then( function () { + + let material; + + if ( materialType === GLTFMeshStandardSGMaterial ) { + + material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams ); + + } else { + + material = new materialType( materialParams ); + + } + + if ( materialDef.name ) material.name = materialDef.name; + + // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding. + if ( material.map ) material.map.encoding = sRGBEncoding; + if ( material.emissiveMap ) material.emissiveMap.encoding = sRGBEncoding; + + assignExtrasToUserData( material, materialDef ); + + parser.associations.set( material, { materials: materialIndex } ); + + if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef ); + + return material; + + } ); + + } + + /** When Object3D instances are targeted by animation, they need unique names. */ + createUniqueName( originalName ) { + + const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' ); + + let name = sanitizedName; + + for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) { + + name = sanitizedName + '_' + i; + + } + + this.nodeNamesUsed[ name ] = true; + + return name; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry + * + * Creates BufferGeometries from primitives. + * + * @param {Array} primitives + * @return {Promise>} + */ + loadGeometries( primitives ) { + + const parser = this; + const extensions = this.extensions; + const cache = this.primitiveCache; + + function createDracoPrimitive( primitive ) { + + return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] + .decodePrimitive( primitive, parser ) + .then( function ( geometry ) { + + return addPrimitiveAttributes( geometry, primitive, parser ); + + } ); + + } + + const pending = []; + + for ( let i = 0, il = primitives.length; i < il; i ++ ) { + + const primitive = primitives[ i ]; + const cacheKey = createPrimitiveKey( primitive ); + + // See if we've already created this geometry + const cached = cache[ cacheKey ]; + + if ( cached ) { + + // Use the cached geometry if it exists + pending.push( cached.promise ); + + } else { + + let geometryPromise; + + if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) { + + // Use DRACO geometry if available + geometryPromise = createDracoPrimitive( primitive ); + + } else { + + // Otherwise create a new geometry + geometryPromise = addPrimitiveAttributes( new BufferGeometry(), primitive, parser ); + + } + + // Cache this geometry + cache[ cacheKey ] = { primitive: primitive, promise: geometryPromise }; + + pending.push( geometryPromise ); + + } + + } + + return Promise.all( pending ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes + * @param {number} meshIndex + * @return {Promise} + */ + loadMesh( meshIndex ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + + const meshDef = json.meshes[ meshIndex ]; + const primitives = meshDef.primitives; + + const pending = []; + + for ( let i = 0, il = primitives.length; i < il; i ++ ) { + + const material = primitives[ i ].material === undefined + ? createDefaultMaterial( this.cache ) + : this.getDependency( 'material', primitives[ i ].material ); + + pending.push( material ); + + } + + pending.push( parser.loadGeometries( primitives ) ); + + return Promise.all( pending ).then( function ( results ) { + + const materials = results.slice( 0, results.length - 1 ); + const geometries = results[ results.length - 1 ]; + + const meshes = []; + + for ( let i = 0, il = geometries.length; i < il; i ++ ) { + + const geometry = geometries[ i ]; + const primitive = primitives[ i ]; + + // 1. create Mesh + + let mesh; + + const material = materials[ i ]; + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || + primitive.mode === undefined ) { + + // .isSkinnedMesh isn't in glTF spec. See ._markDefs() + mesh = meshDef.isSkinnedMesh === true + ? new SkinnedMesh( geometry, material ) + : new Mesh( geometry, material ); + + if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) { + + // we normalize floating point skin weight array to fix malformed assets (see #15319) + // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs + mesh.normalizeSkinWeights(); + + } + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) { + + mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleStripDrawMode ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { + + mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleFanDrawMode ); + + } + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) { + + mesh = new LineSegments( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) { + + mesh = new Line( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) { + + mesh = new LineLoop( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) { + + mesh = new Points( geometry, material ); + + } else { + + throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode ); + + } + + if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) { + + updateMorphTargets( mesh, meshDef ); + + } + + mesh.name = parser.createUniqueName( meshDef.name || ( 'mesh_' + meshIndex ) ); + + assignExtrasToUserData( mesh, meshDef ); + + if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive ); + + parser.assignFinalMaterial( mesh ); + + meshes.push( mesh ); + + } + + for ( let i = 0, il = meshes.length; i < il; i ++ ) { + + parser.associations.set( meshes[ i ], { + meshes: meshIndex, + primitives: i + } ); + + } + + if ( meshes.length === 1 ) { + + return meshes[ 0 ]; + + } + + const group = new Group$1(); + + parser.associations.set( group, { meshes: meshIndex } ); + + for ( let i = 0, il = meshes.length; i < il; i ++ ) { + + group.add( meshes[ i ] ); + + } + + return group; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras + * @param {number} cameraIndex + * @return {Promise} + */ + loadCamera( cameraIndex ) { + + let camera; + const cameraDef = this.json.cameras[ cameraIndex ]; + const params = cameraDef[ cameraDef.type ]; + + if ( ! params ) { + + console.warn( 'THREE.GLTFLoader: Missing camera parameters.' ); + return; + + } + + if ( cameraDef.type === 'perspective' ) { + + camera = new PerspectiveCamera( MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 ); + + } else if ( cameraDef.type === 'orthographic' ) { + + camera = new OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar ); + + } + + if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name ); + + assignExtrasToUserData( camera, cameraDef ); + + return Promise.resolve( camera ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins + * @param {number} skinIndex + * @return {Promise} + */ + loadSkin( skinIndex ) { + + const skinDef = this.json.skins[ skinIndex ]; + + const skinEntry = { joints: skinDef.joints }; + + if ( skinDef.inverseBindMatrices === undefined ) { + + return Promise.resolve( skinEntry ); + + } + + return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) { + + skinEntry.inverseBindMatrices = accessor; + + return skinEntry; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations + * @param {number} animationIndex + * @return {Promise} + */ + loadAnimation( animationIndex ) { + + const json = this.json; + + const animationDef = json.animations[ animationIndex ]; + + const pendingNodes = []; + const pendingInputAccessors = []; + const pendingOutputAccessors = []; + const pendingSamplers = []; + const pendingTargets = []; + + for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) { + + const channel = animationDef.channels[ i ]; + const sampler = animationDef.samplers[ channel.sampler ]; + const target = channel.target; + const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated. + const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input; + const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output; + + pendingNodes.push( this.getDependency( 'node', name ) ); + pendingInputAccessors.push( this.getDependency( 'accessor', input ) ); + pendingOutputAccessors.push( this.getDependency( 'accessor', output ) ); + pendingSamplers.push( sampler ); + pendingTargets.push( target ); + + } + + return Promise.all( [ + + Promise.all( pendingNodes ), + Promise.all( pendingInputAccessors ), + Promise.all( pendingOutputAccessors ), + Promise.all( pendingSamplers ), + Promise.all( pendingTargets ) + + ] ).then( function ( dependencies ) { + + const nodes = dependencies[ 0 ]; + const inputAccessors = dependencies[ 1 ]; + const outputAccessors = dependencies[ 2 ]; + const samplers = dependencies[ 3 ]; + const targets = dependencies[ 4 ]; + + const tracks = []; + + for ( let i = 0, il = nodes.length; i < il; i ++ ) { + + const node = nodes[ i ]; + const inputAccessor = inputAccessors[ i ]; + const outputAccessor = outputAccessors[ i ]; + const sampler = samplers[ i ]; + const target = targets[ i ]; + + if ( node === undefined ) continue; + + node.updateMatrix(); + node.matrixAutoUpdate = true; + + let TypedKeyframeTrack; + + switch ( PATH_PROPERTIES[ target.path ] ) { + + case PATH_PROPERTIES.weights: + + TypedKeyframeTrack = NumberKeyframeTrack; + break; + + case PATH_PROPERTIES.rotation: + + TypedKeyframeTrack = QuaternionKeyframeTrack; + break; + + case PATH_PROPERTIES.position: + case PATH_PROPERTIES.scale: + default: + + TypedKeyframeTrack = VectorKeyframeTrack; + break; + + } + + const targetName = node.name ? node.name : node.uuid; + + const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear; + + const targetNames = []; + + if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) { + + node.traverse( function ( object ) { + + if ( object.morphTargetInfluences ) { + + targetNames.push( object.name ? object.name : object.uuid ); + + } + + } ); + + } else { + + targetNames.push( targetName ); + + } + + let outputArray = outputAccessor.array; + + if ( outputAccessor.normalized ) { + + const scale = getNormalizedComponentScale( outputArray.constructor ); + const scaled = new Float32Array( outputArray.length ); + + for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) { + + scaled[ j ] = outputArray[ j ] * scale; + + } + + outputArray = scaled; + + } + + for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) { + + const track = new TypedKeyframeTrack( + targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], + inputAccessor.array, + outputArray, + interpolation + ); + + // Override interpolation with custom factory method. + if ( sampler.interpolation === 'CUBICSPLINE' ) { + + track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) { + + // A CUBICSPLINE keyframe in glTF has three output values for each input value, + // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize() + // must be divided by three to get the interpolant's sampleSize argument. + + const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant; + + return new interpolantType( this.times, this.values, this.getValueSize() / 3, result ); + + }; + + // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants. + track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true; + + } + + tracks.push( track ); + + } + + } + + const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex; + + return new AnimationClip( name, undefined, tracks ); + + } ); + + } + + createNodeMesh( nodeIndex ) { + + const json = this.json; + const parser = this; + const nodeDef = json.nodes[ nodeIndex ]; + + if ( nodeDef.mesh === undefined ) return null; + + return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) { + + const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh ); + + // if weights are provided on the node, override weights on the mesh. + if ( nodeDef.weights !== undefined ) { + + node.traverse( function ( o ) { + + if ( ! o.isMesh ) return; + + for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) { + + o.morphTargetInfluences[ i ] = nodeDef.weights[ i ]; + + } + + } ); + + } + + return node; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy + * @param {number} nodeIndex + * @return {Promise} + */ + loadNode( nodeIndex ) { + + const json = this.json; + const extensions = this.extensions; + const parser = this; + + const nodeDef = json.nodes[ nodeIndex ]; + + // reserve node's name before its dependencies, so the root has the intended name. + const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : ''; + + return ( function () { + + const pending = []; + + const meshPromise = parser._invokeOne( function ( ext ) { + + return ext.createNodeMesh && ext.createNodeMesh( nodeIndex ); + + } ); + + if ( meshPromise ) { + + pending.push( meshPromise ); + + } + + if ( nodeDef.camera !== undefined ) { + + pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) { + + return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera ); + + } ) ); + + } + + parser._invokeAll( function ( ext ) { + + return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex ); + + } ).forEach( function ( promise ) { + + pending.push( promise ); + + } ); + + return Promise.all( pending ); + + }() ).then( function ( objects ) { + + let node; + + // .isBone isn't in glTF spec. See ._markDefs + if ( nodeDef.isBone === true ) { + + node = new Bone(); + + } else if ( objects.length > 1 ) { + + node = new Group$1(); + + } else if ( objects.length === 1 ) { + + node = objects[ 0 ]; + + } else { + + node = new Object3D(); + + } + + if ( node !== objects[ 0 ] ) { + + for ( let i = 0, il = objects.length; i < il; i ++ ) { + + node.add( objects[ i ] ); + + } + + } + + if ( nodeDef.name ) { + + node.userData.name = nodeDef.name; + node.name = nodeName; + + } + + assignExtrasToUserData( node, nodeDef ); + + if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef ); + + if ( nodeDef.matrix !== undefined ) { + + const matrix = new Matrix4(); + matrix.fromArray( nodeDef.matrix ); + node.applyMatrix4( matrix ); + + } else { + + if ( nodeDef.translation !== undefined ) { + + node.position.fromArray( nodeDef.translation ); + + } + + if ( nodeDef.rotation !== undefined ) { + + node.quaternion.fromArray( nodeDef.rotation ); + + } + + if ( nodeDef.scale !== undefined ) { + + node.scale.fromArray( nodeDef.scale ); + + } + + } + + if ( ! parser.associations.has( node ) ) { + + parser.associations.set( node, {} ); + + } + + parser.associations.get( node ).nodes = nodeIndex; + + return node; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes + * @param {number} sceneIndex + * @return {Promise} + */ + loadScene( sceneIndex ) { + + const json = this.json; + const extensions = this.extensions; + const sceneDef = this.json.scenes[ sceneIndex ]; + const parser = this; + + // Loader returns Group, not Scene. + // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172 + const scene = new Group$1(); + if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name ); + + assignExtrasToUserData( scene, sceneDef ); + + if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef ); + + const nodeIds = sceneDef.nodes || []; + + const pending = []; + + for ( let i = 0, il = nodeIds.length; i < il; i ++ ) { + + pending.push( buildNodeHierarchy( nodeIds[ i ], scene, json, parser ) ); + + } + + return Promise.all( pending ).then( function () { + + // Removes dangling associations, associations that reference a node that + // didn't make it into the scene. + const reduceAssociations = ( node ) => { + + const reducedAssociations = new Map(); + + for ( const [ key, value ] of parser.associations ) { + + if ( key instanceof Material || key instanceof Texture ) { + + reducedAssociations.set( key, value ); + + } + + } + + node.traverse( ( node ) => { + + const mappings = parser.associations.get( node ); + + if ( mappings != null ) { + + reducedAssociations.set( node, mappings ); + + } + + } ); + + return reducedAssociations; + + }; + + parser.associations = reduceAssociations( scene ); + + return scene; + + } ); + + } + +} + +function buildNodeHierarchy( nodeId, parentObject, json, parser ) { + + const nodeDef = json.nodes[ nodeId ]; + + return parser.getDependency( 'node', nodeId ).then( function ( node ) { + + if ( nodeDef.skin === undefined ) return node; + + // build skeleton here as well + + let skinEntry; + + return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) { + + skinEntry = skin; + + const pendingJoints = []; + + for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) { + + pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) ); + + } + + return Promise.all( pendingJoints ); + + } ).then( function ( jointNodes ) { + + node.traverse( function ( mesh ) { + + if ( ! mesh.isMesh ) return; + + const bones = []; + const boneInverses = []; + + for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) { + + const jointNode = jointNodes[ j ]; + + if ( jointNode ) { + + bones.push( jointNode ); + + const mat = new Matrix4(); + + if ( skinEntry.inverseBindMatrices !== undefined ) { + + mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 ); + + } + + boneInverses.push( mat ); + + } else { + + console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] ); + + } + + } + + mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld ); + + } ); + + return node; + + } ); + + } ).then( function ( node ) { + + // build node hierachy + + parentObject.add( node ); + + const pending = []; + + if ( nodeDef.children ) { + + const children = nodeDef.children; + + for ( let i = 0, il = children.length; i < il; i ++ ) { + + const child = children[ i ]; + pending.push( buildNodeHierarchy( child, node, json, parser ) ); + + } + + } + + return Promise.all( pending ); + + } ); + +} + +/** + * @param {BufferGeometry} geometry + * @param {GLTF.Primitive} primitiveDef + * @param {GLTFParser} parser + */ +function computeBounds( geometry, primitiveDef, parser ) { + + const attributes = primitiveDef.attributes; + + const box = new Box3(); + + if ( attributes.POSITION !== undefined ) { + + const accessor = parser.json.accessors[ attributes.POSITION ]; + + const min = accessor.min; + const max = accessor.max; + + // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement. + + if ( min !== undefined && max !== undefined ) { + + box.set( + new Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ), + new Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) + ); + + if ( accessor.normalized ) { + + const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] ); + box.min.multiplyScalar( boxScale ); + box.max.multiplyScalar( boxScale ); + + } + + } else { + + console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' ); + + return; + + } + + } else { + + return; + + } + + const targets = primitiveDef.targets; + + if ( targets !== undefined ) { + + const maxDisplacement = new Vector3(); + const vector = new Vector3(); + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( target.POSITION !== undefined ) { + + const accessor = parser.json.accessors[ target.POSITION ]; + const min = accessor.min; + const max = accessor.max; + + // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement. + + if ( min !== undefined && max !== undefined ) { + + // we need to get max of absolute components because target weight is [-1,1] + vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) ); + vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) ); + vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) ); + + + if ( accessor.normalized ) { + + const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] ); + vector.multiplyScalar( boxScale ); + + } + + // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative + // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets + // are used to implement key-frame animations and as such only two are active at a time - this results in very large + // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size. + maxDisplacement.max( vector ); + + } else { + + console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' ); + + } + + } + + } + + // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets. + box.expandByVector( maxDisplacement ); + + } + + geometry.boundingBox = box; + + const sphere = new Sphere(); + + box.getCenter( sphere.center ); + sphere.radius = box.min.distanceTo( box.max ) / 2; + + geometry.boundingSphere = sphere; + +} + +/** + * @param {BufferGeometry} geometry + * @param {GLTF.Primitive} primitiveDef + * @param {GLTFParser} parser + * @return {Promise} + */ +function addPrimitiveAttributes( geometry, primitiveDef, parser ) { + + const attributes = primitiveDef.attributes; + + const pending = []; + + function assignAttributeAccessor( accessorIndex, attributeName ) { + + return parser.getDependency( 'accessor', accessorIndex ) + .then( function ( accessor ) { + + geometry.setAttribute( attributeName, accessor ); + + } ); + + } + + for ( const gltfAttributeName in attributes ) { + + const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase(); + + // Skip attributes already provided by e.g. Draco extension. + if ( threeAttributeName in geometry.attributes ) continue; + + pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) ); + + } + + if ( primitiveDef.indices !== undefined && ! geometry.index ) { + + const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) { + + geometry.setIndex( accessor ); + + } ); + + pending.push( accessor ); + + } + + assignExtrasToUserData( geometry, primitiveDef ); + + computeBounds( geometry, primitiveDef, parser ); + + return Promise.all( pending ).then( function () { + + return primitiveDef.targets !== undefined + ? addMorphTargets( geometry, primitiveDef.targets, parser ) + : geometry; + + } ); + +} + +/** + * @param {BufferGeometry} geometry + * @param {Number} drawMode + * @return {BufferGeometry} + */ +function toTrianglesDrawMode( geometry, drawMode ) { + + let index = geometry.getIndex(); + + // generate index if not present + + if ( index === null ) { + + const indices = []; + + const position = geometry.getAttribute( 'position' ); + + if ( position !== undefined ) { + + for ( let i = 0; i < position.count; i ++ ) { + + indices.push( i ); + + } + + geometry.setIndex( indices ); + index = geometry.getIndex(); + + } else { + + console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' ); + return geometry; + + } + + } + + // + + const numberOfTriangles = index.count - 2; + const newIndices = []; + + if ( drawMode === TriangleFanDrawMode ) { + + // gl.TRIANGLE_FAN + + for ( let i = 1; i <= numberOfTriangles; i ++ ) { + + newIndices.push( index.getX( 0 ) ); + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + + } + + } else { + + // gl.TRIANGLE_STRIP + + for ( let i = 0; i < numberOfTriangles; i ++ ) { + + if ( i % 2 === 0 ) { + + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i + 2 ) ); + + + } else { + + newIndices.push( index.getX( i + 2 ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i ) ); + + } + + } + + } + + if ( ( newIndices.length / 3 ) !== numberOfTriangles ) { + + console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' ); + + } + + // build final geometry + + const newGeometry = geometry.clone(); + newGeometry.setIndex( newIndices ); + + return newGeometry; + +} + +const _taskCache = new WeakMap(); + +class DRACOLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + this.decoderPath = ''; + this.decoderConfig = {}; + this.decoderBinary = null; + this.decoderPending = null; + + this.workerLimit = 4; + this.workerPool = []; + this.workerNextTaskID = 1; + this.workerSourceURL = ''; + + this.defaultAttributeIDs = { + position: 'POSITION', + normal: 'NORMAL', + color: 'COLOR', + uv: 'TEX_COORD' + }; + this.defaultAttributeTypes = { + position: 'Float32Array', + normal: 'Float32Array', + color: 'Float32Array', + uv: 'Float32Array' + }; + + } + + setDecoderPath( path ) { + + this.decoderPath = path; + + return this; + + } + + setDecoderConfig( config ) { + + this.decoderConfig = config; + + return this; + + } + + setWorkerLimit( workerLimit ) { + + this.workerLimit = workerLimit; + + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + const loader = new FileLoader( this.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + + loader.load( url, ( buffer ) => { + + const taskConfig = { + attributeIDs: this.defaultAttributeIDs, + attributeTypes: this.defaultAttributeTypes, + useUniqueIDs: false + }; + + this.decodeGeometry( buffer, taskConfig ) + .then( onLoad ) + .catch( onError ); + + }, onProgress, onError ); + + } + + /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */ + decodeDracoFile( buffer, callback, attributeIDs, attributeTypes ) { + + const taskConfig = { + attributeIDs: attributeIDs || this.defaultAttributeIDs, + attributeTypes: attributeTypes || this.defaultAttributeTypes, + useUniqueIDs: !! attributeIDs + }; + + this.decodeGeometry( buffer, taskConfig ).then( callback ); + + } + + decodeGeometry( buffer, taskConfig ) { + + // TODO: For backward-compatibility, support 'attributeTypes' objects containing + // references (rather than names) to typed array constructors. These must be + // serialized before sending them to the worker. + for ( const attribute in taskConfig.attributeTypes ) { + + const type = taskConfig.attributeTypes[ attribute ]; + + if ( type.BYTES_PER_ELEMENT !== undefined ) { + + taskConfig.attributeTypes[ attribute ] = type.name; + + } + + } + + // + + const taskKey = JSON.stringify( taskConfig ); + + // Check for an existing task using this buffer. A transferred buffer cannot be transferred + // again from this thread. + if ( _taskCache.has( buffer ) ) { + + const cachedTask = _taskCache.get( buffer ); + + if ( cachedTask.key === taskKey ) { + + return cachedTask.promise; + + } else if ( buffer.byteLength === 0 ) { + + // Technically, it would be possible to wait for the previous task to complete, + // transfer the buffer back, and decode again with the second configuration. That + // is complex, and I don't know of any reason to decode a Draco buffer twice in + // different ways, so this is left unimplemented. + throw new Error( + + 'THREE.DRACOLoader: Unable to re-decode a buffer with different ' + + 'settings. Buffer has already been transferred.' + + ); + + } + + } + + // + + let worker; + const taskID = this.workerNextTaskID ++; + const taskCost = buffer.byteLength; + + // Obtain a worker and assign a task, and construct a geometry instance + // when the task completes. + const geometryPending = this._getWorker( taskID, taskCost ) + .then( ( _worker ) => { + + worker = _worker; + + return new Promise( ( resolve, reject ) => { + + worker._callbacks[ taskID ] = { resolve, reject }; + + worker.postMessage( { type: 'decode', id: taskID, taskConfig, buffer }, [ buffer ] ); + + // this.debug(); + + } ); + + } ) + .then( ( message ) => this._createGeometry( message.geometry ) ); + + // Remove task from the task list. + // Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416) + geometryPending + .catch( () => true ) + .then( () => { + + if ( worker && taskID ) { + + this._releaseTask( worker, taskID ); + + // this.debug(); + + } + + } ); + + // Cache the task result. + _taskCache.set( buffer, { + + key: taskKey, + promise: geometryPending + + } ); + + return geometryPending; + + } + + _createGeometry( geometryData ) { + + const geometry = new BufferGeometry(); + + if ( geometryData.index ) { + + geometry.setIndex( new BufferAttribute( geometryData.index.array, 1 ) ); + + } + + for ( let i = 0; i < geometryData.attributes.length; i ++ ) { + + const attribute = geometryData.attributes[ i ]; + const name = attribute.name; + const array = attribute.array; + const itemSize = attribute.itemSize; + + geometry.setAttribute( name, new BufferAttribute( array, itemSize ) ); + + } + + return geometry; + + } + + _loadLibrary( url, responseType ) { + + const loader = new FileLoader( this.manager ); + loader.setPath( this.decoderPath ); + loader.setResponseType( responseType ); + loader.setWithCredentials( this.withCredentials ); + + return new Promise( ( resolve, reject ) => { + + loader.load( url, resolve, undefined, reject ); + + } ); + + } + + preload() { + + this._initDecoder(); + + return this; + + } + + _initDecoder() { + + if ( this.decoderPending ) return this.decoderPending; + + const useJS = typeof WebAssembly !== 'object' || this.decoderConfig.type === 'js'; + const librariesPending = []; + + if ( useJS ) { + + librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) ); + + } else { + + librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) ); + librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) ); + + } + + this.decoderPending = Promise.all( librariesPending ) + .then( ( libraries ) => { + + const jsContent = libraries[ 0 ]; + + if ( ! useJS ) { + + this.decoderConfig.wasmBinary = libraries[ 1 ]; + + } + + const fn = DRACOWorker.toString(); + + const body = [ + '/* draco decoder */', + jsContent, + '', + '/* worker */', + fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) + ].join( '\n' ); + + this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) ); + + } ); + + return this.decoderPending; + + } + + _getWorker( taskID, taskCost ) { + + return this._initDecoder().then( () => { + + if ( this.workerPool.length < this.workerLimit ) { + + const worker = new Worker( this.workerSourceURL ); + + worker._callbacks = {}; + worker._taskCosts = {}; + worker._taskLoad = 0; + + worker.postMessage( { type: 'init', decoderConfig: this.decoderConfig } ); + + worker.onmessage = function ( e ) { + + const message = e.data; + + switch ( message.type ) { + + case 'decode': + worker._callbacks[ message.id ].resolve( message ); + break; + + case 'error': + worker._callbacks[ message.id ].reject( message ); + break; + + default: + console.error( 'THREE.DRACOLoader: Unexpected message, "' + message.type + '"' ); + + } + + }; + + this.workerPool.push( worker ); + + } else { + + this.workerPool.sort( function ( a, b ) { + + return a._taskLoad > b._taskLoad ? - 1 : 1; + + } ); + + } + + const worker = this.workerPool[ this.workerPool.length - 1 ]; + worker._taskCosts[ taskID ] = taskCost; + worker._taskLoad += taskCost; + return worker; + + } ); + + } + + _releaseTask( worker, taskID ) { + + worker._taskLoad -= worker._taskCosts[ taskID ]; + delete worker._callbacks[ taskID ]; + delete worker._taskCosts[ taskID ]; + + } + + debug() { + + console.log( 'Task load: ', this.workerPool.map( ( worker ) => worker._taskLoad ) ); + + } + + dispose() { + + for ( let i = 0; i < this.workerPool.length; ++ i ) { + + this.workerPool[ i ].terminate(); + + } + + this.workerPool.length = 0; + + return this; + + } + +} + +/* WEB WORKER */ + +function DRACOWorker() { + + let decoderConfig; + let decoderPending; + + onmessage = function ( e ) { + + const message = e.data; + + switch ( message.type ) { + + case 'init': + decoderConfig = message.decoderConfig; + decoderPending = new Promise( function ( resolve/*, reject*/ ) { + + decoderConfig.onModuleLoaded = function ( draco ) { + + // Module is Promise-like. Wrap before resolving to avoid loop. + resolve( { draco: draco } ); + + }; + + DracoDecoderModule( decoderConfig ); // eslint-disable-line no-undef + + } ); + break; + + case 'decode': + const buffer = message.buffer; + const taskConfig = message.taskConfig; + decoderPending.then( ( module ) => { + + const draco = module.draco; + const decoder = new draco.Decoder(); + const decoderBuffer = new draco.DecoderBuffer(); + decoderBuffer.Init( new Int8Array( buffer ), buffer.byteLength ); + + try { + + const geometry = decodeGeometry( draco, decoder, decoderBuffer, taskConfig ); + + const buffers = geometry.attributes.map( ( attr ) => attr.array.buffer ); + + if ( geometry.index ) buffers.push( geometry.index.array.buffer ); + + self.postMessage( { type: 'decode', id: message.id, geometry }, buffers ); + + } catch ( error ) { + + console.error( error ); + + self.postMessage( { type: 'error', id: message.id, error: error.message } ); + + } finally { + + draco.destroy( decoderBuffer ); + draco.destroy( decoder ); + + } + + } ); + break; + + } + + }; + + function decodeGeometry( draco, decoder, decoderBuffer, taskConfig ) { + + const attributeIDs = taskConfig.attributeIDs; + const attributeTypes = taskConfig.attributeTypes; + + let dracoGeometry; + let decodingStatus; + + const geometryType = decoder.GetEncodedGeometryType( decoderBuffer ); + + if ( geometryType === draco.TRIANGULAR_MESH ) { + + dracoGeometry = new draco.Mesh(); + decodingStatus = decoder.DecodeBufferToMesh( decoderBuffer, dracoGeometry ); + + } else if ( geometryType === draco.POINT_CLOUD ) { + + dracoGeometry = new draco.PointCloud(); + decodingStatus = decoder.DecodeBufferToPointCloud( decoderBuffer, dracoGeometry ); + + } else { + + throw new Error( 'THREE.DRACOLoader: Unexpected geometry type.' ); + + } + + if ( ! decodingStatus.ok() || dracoGeometry.ptr === 0 ) { + + throw new Error( 'THREE.DRACOLoader: Decoding failed: ' + decodingStatus.error_msg() ); + + } + + const geometry = { index: null, attributes: [] }; + + // Gather all vertex attributes. + for ( const attributeName in attributeIDs ) { + + const attributeType = self[ attributeTypes[ attributeName ] ]; + + let attribute; + let attributeID; + + // A Draco file may be created with default vertex attributes, whose attribute IDs + // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively, + // a Draco file may contain a custom set of attributes, identified by known unique + // IDs. glTF files always do the latter, and `.drc` files typically do the former. + if ( taskConfig.useUniqueIDs ) { + + attributeID = attributeIDs[ attributeName ]; + attribute = decoder.GetAttributeByUniqueId( dracoGeometry, attributeID ); + + } else { + + attributeID = decoder.GetAttributeId( dracoGeometry, draco[ attributeIDs[ attributeName ] ] ); + + if ( attributeID === - 1 ) continue; + + attribute = decoder.GetAttribute( dracoGeometry, attributeID ); + + } + + geometry.attributes.push( decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) ); + + } + + // Add index. + if ( geometryType === draco.TRIANGULAR_MESH ) { + + geometry.index = decodeIndex( draco, decoder, dracoGeometry ); + + } + + draco.destroy( dracoGeometry ); + + return geometry; + + } + + function decodeIndex( draco, decoder, dracoGeometry ) { + + const numFaces = dracoGeometry.num_faces(); + const numIndices = numFaces * 3; + const byteLength = numIndices * 4; + + const ptr = draco._malloc( byteLength ); + decoder.GetTrianglesUInt32Array( dracoGeometry, byteLength, ptr ); + const index = new Uint32Array( draco.HEAPF32.buffer, ptr, numIndices ).slice(); + draco._free( ptr ); + + return { array: index, itemSize: 1 }; + + } + + function decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) { + + const numComponents = attribute.num_components(); + const numPoints = dracoGeometry.num_points(); + const numValues = numPoints * numComponents; + const byteLength = numValues * attributeType.BYTES_PER_ELEMENT; + const dataType = getDracoDataType( draco, attributeType ); + + const ptr = draco._malloc( byteLength ); + decoder.GetAttributeDataArrayForAllPoints( dracoGeometry, attribute, dataType, byteLength, ptr ); + const array = new attributeType( draco.HEAPF32.buffer, ptr, numValues ).slice(); + draco._free( ptr ); + + return { + name: attributeName, + array: array, + itemSize: numComponents + }; + + } + + function getDracoDataType( draco, attributeType ) { + + switch ( attributeType ) { + + case Float32Array: return draco.DT_FLOAT32; + case Int8Array: return draco.DT_INT8; + case Int16Array: return draco.DT_INT16; + case Int32Array: return draco.DT_INT32; + case Uint8Array: return draco.DT_UINT8; + case Uint16Array: return draco.DT_UINT16; + case Uint32Array: return draco.DT_UINT32; + + } + + } + +} + +// https://github.com/mrdoob/three.js/issues/5552 +// http://en.wikipedia.org/wiki/RGBE_image_format + +class RGBELoader extends DataTextureLoader { + + constructor( manager ) { + + super( manager ); + + this.type = HalfFloatType; + + } + + // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html + + parse( buffer ) { + + const + /* return codes for rgbe routines */ + //RGBE_RETURN_SUCCESS = 0, + RGBE_RETURN_FAILURE = - 1, + + /* default error routine. change this to change error handling */ + rgbe_read_error = 1, + rgbe_write_error = 2, + rgbe_format_error = 3, + rgbe_memory_error = 4, + rgbe_error = function ( rgbe_error_code, msg ) { + + switch ( rgbe_error_code ) { + + case rgbe_read_error: console.error( 'THREE.RGBELoader Read Error: ' + ( msg || '' ) ); + break; + case rgbe_write_error: console.error( 'THREE.RGBELoader Write Error: ' + ( msg || '' ) ); + break; + case rgbe_format_error: console.error( 'THREE.RGBELoader Bad File Format: ' + ( msg || '' ) ); + break; + default: + case rgbe_memory_error: console.error( 'THREE.RGBELoader: Error: ' + ( msg || '' ) ); + + } + + return RGBE_RETURN_FAILURE; + + }, + + /* offsets to red, green, and blue components in a data (float) pixel */ + //RGBE_DATA_RED = 0, + //RGBE_DATA_GREEN = 1, + //RGBE_DATA_BLUE = 2, + + /* number of floats per pixel, use 4 since stored in rgba image format */ + //RGBE_DATA_SIZE = 4, + + /* flags indicating which fields in an rgbe_header_info are valid */ + RGBE_VALID_PROGRAMTYPE = 1, + RGBE_VALID_FORMAT = 2, + RGBE_VALID_DIMENSIONS = 4, + + NEWLINE = '\n', + + fgets = function ( buffer, lineLimit, consume ) { + + const chunkSize = 128; + + lineLimit = ! lineLimit ? 1024 : lineLimit; + let p = buffer.pos, + i = - 1, len = 0, s = '', + chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ); + + while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) { + + s += chunk; len += chunk.length; + p += chunkSize; + chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ); + + } + + if ( - 1 < i ) { + + /*for (i=l-1; i>=0; i--) { + byteCode = m.charCodeAt(i); + if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++; + else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2; + if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate + }*/ + if ( false !== consume ) buffer.pos += len + i + 1; + return s + chunk.slice( 0, i ); + + } + + return false; + + }, + + /* minimal header reading. modify if you want to parse more information */ + RGBE_ReadHeader = function ( buffer ) { + + + // regexes to parse header info fields + const magic_token_re = /^#\?(\S+)/, + gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, + exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, + format_re = /^\s*FORMAT=(\S+)\s*$/, + dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, + + // RGBE format header struct + header = { + + valid: 0, /* indicate which fields are valid */ + + string: '', /* the actual header string */ + + comments: '', /* comments found in header */ + + programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */ + + format: '', /* RGBE format, default 32-bit_rle_rgbe */ + + gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */ + + exposure: 1.0, /* a value of 1.0 in an image corresponds to watts/steradian/m^2. defaults to 1.0 */ + + width: 0, height: 0 /* image dimensions, width/height */ + + }; + + let line, match; + + if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) { + + return rgbe_error( rgbe_read_error, 'no header found' ); + + } + + /* if you want to require the magic token then uncomment the next line */ + if ( ! ( match = line.match( magic_token_re ) ) ) { + + return rgbe_error( rgbe_format_error, 'bad initial token' ); + + } + + header.valid |= RGBE_VALID_PROGRAMTYPE; + header.programtype = match[ 1 ]; + header.string += line + '\n'; + + while ( true ) { + + line = fgets( buffer ); + if ( false === line ) break; + header.string += line + '\n'; + + if ( '#' === line.charAt( 0 ) ) { + + header.comments += line + '\n'; + continue; // comment line + + } + + if ( match = line.match( gamma_re ) ) { + + header.gamma = parseFloat( match[ 1 ], 10 ); + + } + + if ( match = line.match( exposure_re ) ) { + + header.exposure = parseFloat( match[ 1 ], 10 ); + + } + + if ( match = line.match( format_re ) ) { + + header.valid |= RGBE_VALID_FORMAT; + header.format = match[ 1 ];//'32-bit_rle_rgbe'; + + } + + if ( match = line.match( dimensions_re ) ) { + + header.valid |= RGBE_VALID_DIMENSIONS; + header.height = parseInt( match[ 1 ], 10 ); + header.width = parseInt( match[ 2 ], 10 ); + + } + + if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break; + + } + + if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) { + + return rgbe_error( rgbe_format_error, 'missing format specifier' ); + + } + + if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) { + + return rgbe_error( rgbe_format_error, 'missing image size specifier' ); + + } + + return header; + + }, + + RGBE_ReadPixels_RLE = function ( buffer, w, h ) { + + const scanline_width = w; + + if ( + // run length encoding is not allowed so read flat + ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) || + // this file is not run length encoded + ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) ) + ) { + + // return the flat buffer + return new Uint8Array( buffer ); + + } + + if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) { + + return rgbe_error( rgbe_format_error, 'wrong scanline width' ); + + } + + const data_rgba = new Uint8Array( 4 * w * h ); + + if ( ! data_rgba.length ) { + + return rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' ); + + } + + let offset = 0, pos = 0; + + const ptr_end = 4 * scanline_width; + const rgbeStart = new Uint8Array( 4 ); + const scanline_buffer = new Uint8Array( ptr_end ); + let num_scanlines = h; + + // read in each successive scanline + while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) { + + if ( pos + 4 > buffer.byteLength ) { + + return rgbe_error( rgbe_read_error ); + + } + + rgbeStart[ 0 ] = buffer[ pos ++ ]; + rgbeStart[ 1 ] = buffer[ pos ++ ]; + rgbeStart[ 2 ] = buffer[ pos ++ ]; + rgbeStart[ 3 ] = buffer[ pos ++ ]; + + if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) { + + return rgbe_error( rgbe_format_error, 'bad rgbe scanline format' ); + + } + + // read each of the four channels for the scanline into the buffer + // first red, then green, then blue, then exponent + let ptr = 0, count; + + while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) { + + count = buffer[ pos ++ ]; + const isEncodedRun = count > 128; + if ( isEncodedRun ) count -= 128; + + if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) { + + return rgbe_error( rgbe_format_error, 'bad scanline data' ); + + } + + if ( isEncodedRun ) { + + // a (encoded) run of the same value + const byteValue = buffer[ pos ++ ]; + for ( let i = 0; i < count; i ++ ) { + + scanline_buffer[ ptr ++ ] = byteValue; + + } + //ptr += count; + + } else { + + // a literal-run + scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr ); + ptr += count; pos += count; + + } + + } + + + // now convert data from buffer into rgba + // first red, then green, then blue, then exponent (alpha) + const l = scanline_width; //scanline_buffer.byteLength; + for ( let i = 0; i < l; i ++ ) { + + let off = 0; + data_rgba[ offset ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 1 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 2 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 3 ] = scanline_buffer[ i + off ]; + offset += 4; + + } + + num_scanlines --; + + } + + return data_rgba; + + }; + + const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) { + + const e = sourceArray[ sourceOffset + 3 ]; + const scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale; + destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale; + destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale; + destArray[ destOffset + 3 ] = 1; + + }; + + const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) { + + const e = sourceArray[ sourceOffset + 3 ]; + const scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + // clamping to 65504, the maximum representable value in float16 + destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) ); + destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) ); + destArray[ destOffset + 2 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) ); + destArray[ destOffset + 3 ] = DataUtils.toHalfFloat( 1 ); + + }; + + const byteArray = new Uint8Array( buffer ); + byteArray.pos = 0; + const rgbe_header_info = RGBE_ReadHeader( byteArray ); + + if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) { + + const w = rgbe_header_info.width, + h = rgbe_header_info.height, + image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h ); + + if ( RGBE_RETURN_FAILURE !== image_rgba_data ) { + + let data, format, type; + let numElements; + + switch ( this.type ) { + + case FloatType: + + numElements = image_rgba_data.length / 4; + const floatArray = new Float32Array( numElements * 4 ); + + for ( let j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 ); + + } + + data = floatArray; + type = FloatType; + break; + + case HalfFloatType: + + numElements = image_rgba_data.length / 4; + const halfArray = new Uint16Array( numElements * 4 ); + + for ( let j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 ); + + } + + data = halfArray; + type = HalfFloatType; + break; + + default: + + console.error( 'THREE.RGBELoader: unsupported type: ', this.type ); + break; + + } + + return { + width: w, height: h, + data: data, + header: rgbe_header_info.string, + gamma: rgbe_header_info.gamma, + exposure: rgbe_header_info.exposure, + format: format, + type: type + }; + + } + + } + + return null; + + } + + setDataType( value ) { + + this.type = value; + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + function onLoadCallback( texture, texData ) { + + switch ( texture.type ) { + + case FloatType: + + texture.encoding = LinearEncoding; + texture.minFilter = LinearFilter; + texture.magFilter = LinearFilter; + texture.generateMipmaps = false; + texture.flipY = true; + break; + + case HalfFloatType: + + texture.encoding = LinearEncoding; + texture.minFilter = LinearFilter; + texture.magFilter = LinearFilter; + texture.generateMipmaps = false; + texture.flipY = true; + break; + + } + + if ( onLoad ) onLoad( texture, texData ); + + } + + return super.load( url, onLoadCallback, onProgress, onError ); + + } + +} + +// http://mrl.nyu.edu/~perlin/noise/ + +const _p = [ 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, + 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, + 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, + 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, + 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, + 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, + 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, + 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, + 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, + 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 ]; + +for ( let i = 0; i < 256; i ++ ) { + + _p[ 256 + i ] = _p[ i ]; + +} + +function fade( t ) { + + return t * t * t * ( t * ( t * 6 - 15 ) + 10 ); + +} + +function lerp$1( t, a, b ) { + + return a + t * ( b - a ); + +} + +function grad( hash, x, y, z ) { + + const h = hash & 15; + const u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z; + return ( ( h & 1 ) == 0 ? u : - u ) + ( ( h & 2 ) == 0 ? v : - v ); + +} + +class ImprovedNoise { + + noise( x, y, z ) { + + const floorX = Math.floor( x ), floorY = Math.floor( y ), floorZ = Math.floor( z ); + + const X = floorX & 255, Y = floorY & 255, Z = floorZ & 255; + + x -= floorX; + y -= floorY; + z -= floorZ; + + const xMinus1 = x - 1, yMinus1 = y - 1, zMinus1 = z - 1; + + const u = fade( x ), v = fade( y ), w = fade( z ); + + const A = _p[ X ] + Y, AA = _p[ A ] + Z, AB = _p[ A + 1 ] + Z, B = _p[ X + 1 ] + Y, BA = _p[ B ] + Z, BB = _p[ B + 1 ] + Z; + + return lerp$1( w, lerp$1( v, lerp$1( u, grad( _p[ AA ], x, y, z ), + grad( _p[ BA ], xMinus1, y, z ) ), + lerp$1( u, grad( _p[ AB ], x, yMinus1, z ), + grad( _p[ BB ], xMinus1, yMinus1, z ) ) ), + lerp$1( v, lerp$1( u, grad( _p[ AA + 1 ], x, y, zMinus1 ), + grad( _p[ BA + 1 ], xMinus1, y, zMinus1 ) ), + lerp$1( u, grad( _p[ AB + 1 ], x, yMinus1, zMinus1 ), + grad( _p[ BB + 1 ], xMinus1, yMinus1, zMinus1 ) ) ) ); + + } + +} + +class BuildTool extends Object3D { + + constructor () { + + super(); + + + this.space = 0.075; + + let geo = new BufferGeometry(); + let p1 = 0.5+(this.space*0.5); + let p2 = 0.5-(this.space*0.5); + let v = [-p2, 0, p2, -p1, 0, p1, p2, 0, p2, p1, 0, p1, p1, 0, -p1, p2, 0, -p2, -p2, 0, -p2, -p1, 0, -p1]; + let indices = [0, 1, 2, 1, 3, 2, 3, 4, 2, 2, 4, 5, 5, 4, 6, 4, 7, 6, 7, 1, 6, 1, 0, 6]; + let n = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]; + let uv = [1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0]; + + geo.setIndex( indices ); + geo.setAttribute( 'position', new Float32BufferAttribute( v, 3 ) ); + geo.setAttribute( 'normal', new Float32BufferAttribute( n, 3 ) ); + geo.setAttribute( 'uv', new Float32BufferAttribute( uv, 2 ) ); + + geo.morphAttributes.position = []; + + geo.morphAttributes.position.push( this.makeMorph(3) ); + geo.morphAttributes.position.push( this.makeMorph(4, 0.5) ); + geo.morphAttributes.position.push( this.makeMorph(6, 1.5) ); + + this.mesh = new Mesh( geo ); + + this.mesh.material.depthWrite = true; + this.mesh.material.depthTest = false; + //this.mesh.material.toneMapped = false; + this.mesh.material.morphTargets = false; + this.mesh.material.transparent = true; + this.mesh.material.renderOrder = 1; + + this.type = 'Tool'; + this.add(this.mesh); + + } + + makeMorph ( s, d = 0 ) { + + let p1 = (s*0.5)+(this.space*0.5); + let p2 = (s*0.5)-(this.space*0.5); + + let v = [-p2, 0, p2, -p1, 0, p1, p2, 0, p2, p1, 0, p1, p1, 0, -p1, p2, 0, -p2, -p2, 0, -p2, -p1, 0, -p1]; + + let i = v.length/3, n; + while(i--){ n=i*3; v[n] += d; v[n+2] += d; } + + return new Float32BufferAttribute( v, 3 ); + + } + + set color( c ) { + this.mesh.material.color.set(c).convertSRGBToLinear(); + } + + set resize ( s ) { + + this.mesh.morphTargetInfluences[ 0 ] = 0; + this.mesh.morphTargetInfluences[ 1 ] = 0; + this.mesh.morphTargetInfluences[ 2 ] = 0; + + if( s==3 ) this.mesh.morphTargetInfluences[ 0 ] = 1; + if( s==4 ) this.mesh.morphTargetInfluences[ 1 ] = 1; + if( s==6 ) this.mesh.morphTargetInfluences[ 2 ] = 1; + + } + +} + +class Pool { + + constructor( callback, tileSize=64, normal=true, roughness=false, pixel=false, env=true ) { + + this.sky = 'day'; + + this.callback = callback; + + this.tileSize = tileSize; + this.isWithNormal = normal; + this.isWithRoughness = roughness; + this.isPixelStyle = pixel; + this.isWithEnv = env; + + this.loaderGLB = new GLTFLoader(); + let dracoLoader = new DRACOLoader().setDecoderPath( './build/draco/' ); + this.loaderGLB.setDRACOLoader( dracoLoader ); + + this.mapPath = './assets/textures/'; + this.modelPath = './assets/models/'; + + this.modelSrc = [ 'cars', 'world' ]; + + this.imgSrc = ['tiles.png','town.png','building.png', 'cars.png' ]; + + if( this.isWithNormal ) this.imgSrc.push( 'tiles_n.png', 'building_n.png', 'town_n.png' ); + if( this.isWithRoughness ) this.imgSrc.push( 'tiles_r.png', 'building_r.png', 'town_r.png' ); + this.imgSrc.push( 'border.jpg', 'border_a.jpg' ); + + this.imgs = []; + this.num = 0; + + this.tiles = { + normal:[], + roughness:[], + texture:[], + }; + + this.color = { + ground:'#c68564', + normal:'#8080ff', + snow:'#e6f0ff', + white:'#ffffff', + lightGrey:'#CCCCCC', + metal:'#AAAAAA', + sky:'#8397ac', + }; + + this.textures = {}; + this.geos = {}; + + if (this.isWithEnv) this.loadEnvmap(); + else this.loadImages(); + + } + + displayMessage( str ){ + + if( hub ) hub.message( str ); + + } + + + //----------------------------------- ENVMAP + + loadEnvmap() { + + this.displayMessage( 'Loading envmap ...' ); + + new RGBELoader().load( + this.mapPath + this.sky + '.hdr', + function ( texture ) { + + this.env = texture; + this.loadImages(); + + }.bind(this), + undefined, + function ( err ) { + console.warn('[3dcity] Failed to load envmap, continuing without it:', err); + this.env = null; + this.loadImages(); + }.bind(this) + ); + + } + + + //----------------------------------- TEXTURES + + loadImages() { + + this.displayMessage( 'Loading images ...' ); + + let n = this.num; + let url = this.imgSrc[n]; + let name = url.substring( url.lastIndexOf('/')+1, url.lastIndexOf('.') ); + + + this.imgs[name] = new Image(); + this.imgs[name].onload = function(){ + this.num++; + if( this.num === this.imgSrc.length ) this.defineCanvas(); + else this.loadImages(); + }.bind(this); + this.imgs[name].onerror = function(err){ + console.warn('[3dcity] Failed to load image:', url, err); + this.num++; + if( this.num === this.imgSrc.length ) this.defineCanvas(); + else this.loadImages(); + }.bind(this); + this.imgs[name].src = this.mapPath + url; + + } + + + + defineCanvas() { + + this.num = 0; + + this.canvas = { + town: this.makeCanvas( 'town' ), + building: this.makeCanvas( 'building' ), + tiles: this.makeCanvas( 'tiles', true ), + }; + + if( this.isWithNormal ) this.canvas[ 'tiles_n' ] = this.makeCanvas( 'tiles_n', true ); + if( this.isWithRoughness ) { + this.canvas[ 'tiles_r' ] = this.makeCanvas( 'tiles_r', true ); + this.canvas[ 'town_r' ] = this.makeCanvas( 'town_r' ); + this.canvas[ 'building_r' ] = this.makeCanvas( 'building_r' ); + } + + this.drawCanvas(); + + this.makeCarColor(); + + } + + makeCanvas( name, resize ) { + + let r = 1; + if (resize) { + if (this.tileSize === 32) r = 0.5; + else if (this.tileSize === 16) r = 0.25; + } + + let img = this.imgs[name]; + let c = document.createElement("canvas"); + c.width = img.width*r; + c.height = img.height*r; + return c + + } + + drawCanvas() { + + let c, ctx; + + // TODO add color effect on canvas + + for( let name in this.canvas ){ + + c = this.canvas[name]; + + ctx = c.getContext('2d'); + ctx.clearRect ( 0 , 0, c.width, c.height ); + if( name === 'tiles' || name === 'town' || name === 'building'){ + ctx.fillStyle = this.color.ground; + ctx.fillRect( 0, 0, c.width, c.height ); + } + if( name === 'tiles_n' ){ + ctx.fillStyle = this.color.normal; + ctx.fillRect( 0, 0, c.width, c.height ); + } + if( name === 'tiles_r' || name === 'town_r' || name === 'building_r'){ + ctx.fillStyle = this.color.lightGrey; + ctx.fillRect( 0, 0, c.width, c.height ); + } + + ctx.drawImage( this.imgs[ name ], 0, 0, c.width, c.height ); + + } + + this.defineTextures(); + + } + + //this.tint( this.townCanvas, this.imgs[1], this.imgs[4] ); + //this.tint( this.buildingCanvas, this.imgs[2], this.imgs[3] ); + + + defineTextures() { + + this.makePixelData( 'tiles' ); + + this.textures['town'] = new Texture( this.canvas.town ); + this.filterTexture( this.textures['town'], { flip:false } ); + + this.textures['building'] = new Texture( this.canvas.building ); + this.filterTexture( this.textures['building'], { flip:false } ); + + if( this.isWithNormal ){ + + this.makePixelData( 'tiles_n' ); + + this.textures['town_n'] = new Texture( this.imgs['town_n'] ); + this.filterTexture( this.textures['town_n'], { flip:false, normal:true } ); + + this.textures['building_n'] = new Texture( this.imgs['building_n'] ); + this.filterTexture( this.textures['building_n'], { flip:false, normal:true } ); + + } + + if( this.isWithRoughness ){ + + this.makePixelData( 'tiles_r' ); + + this.textures['town_r'] = new Texture( this.canvas.town_r ); + this.filterTexture( this.textures['town_r'], { flip:false, normal:true } ); + + this.textures['building_r'] = new Texture( this.canvas.building_r ); + this.filterTexture( this.textures['building_r'], { flip:false, normal:true } ); + + } + + this.textures['border'] = new Texture( this.imgs['border'] ); + this.filterTexture( this.textures['border'], { flip:false } ); + + this.textures['border_a'] = new Texture( this.imgs['border_a'] ); + this.filterTexture( this.textures['border_a'], { flip:false } ); + + this.loadModel(); + + } + + filterTexture ( texture, o = {} ){ + + if( !o.normal ) texture.encoding = sRGBEncoding; + if( o.flip !== undefined ) texture.flipY = o.flip; + if( o.midmap !== undefined ) texture.generateMipmaps = o.midmap; + if( o.alpha !== undefined ) texture.premultiplyAlpha = o.alpha; + + if( this.isPixelStyle ){ + texture.magFilter = NearestFilter; + texture.minFilter = LinearMipMapLinearFilter; + } else { + texture.magFilter = LinearFilter; + texture.minFilter = LinearMipmapLinearFilter; + } + + //texture.anisotropy = this.anisotropy; + texture.needsUpdate = true; + + } + + + makePixelData( name ) { + + let ctx = this.canvas[ name ].getContext('2d'); + let pix = this.tileSize, x, y; + + for ( let i = 0; i < 240; i++ ){ + + x = ( i % 32 ) * pix; + y = Math.floor( i / 32 ) * pix; + let data = ctx.getImageData(x, y, pix, pix).data; + if ( name === 'tiles_n' ) this.tiles.normal[i] = new DataTexture( data, pix, pix ); + else if ( name === 'tiles_r' ) this.tiles.roughness[i] = new DataTexture( data, pix, pix ); + else this.tiles.texture[i] = new DataTexture( data, pix, pix ); + + } + + } + + + tint( canvas, image, supImage ) { + + let data, i, n; + let pixels = canvas.width*canvas.height; + let ctx = canvas.getContext('2d'); + + // draw windows + let topData = null; + let newImg = null; + if(supImage && this.dayTime!==0 && this.dayTime!==1){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(supImage, 0, 0); + topData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = topData.data; + i = pixels; + while(i--){ + n = i<<2; + if(data[n+3] !== 0){ + if(data[n+0]==0 && data[n+1]==0 && data[n+2]==0){// black + data[n+3]=60; + } + if(data[n+1]==0){ + //if(data[n+0]==255 && data[n+1]==0 && data[n+2]==0){// red + if(this.dayTime==3) data[n+1]=255; + if(this.dayTime==2) {data[n+0]=0; data[n+3]=60;} + } + + } + } + ctx.putImageData(topData, 0, 0); + newImg = document.createElement('img'); + newImg.src = canvas.toDataURL("image/png"); + } + + if(image){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(image, 0, 0); + } else { + ctx.drawImage(this.skyCanvasBasic, 0, 0); + } + + if( this.dayTime!==0 ){ + let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = imageData.data; + i = pixels; + let c = this.tcolor; + while(i--){ + n = i<<2;//i*4; + data[n+0] = data[n+0] * (1-c.a) + (c.r*c.a); + data[n+1] = data[n+1] * (1-c.a) + (c.g*c.a); + data[n+2] = data[n+2] * (1-c.a) + (c.b*c.a); + } + ctx.putImageData(imageData, 0, 0); + if(newImg){ + ctx.drawImage(newImg, 0, 0); + } + } + + } + + //----------------------------------- TITLE + + rand ( low, high ) { return low + Math.random() * ( high - low ); } + + makeTitleTexture ( n = 0 ) { + + let color = [ this.color.metal, '#fff' ]; + if(n===1) color = [ '#333333', '#999999' ]; + if(n===2) color = [ '#000', '#999999' ]; + + let s = 0.25; + + let c = document.createElement( 'canvas' ); + c.width = c.height = 1024*s; + let ctx = c.getContext('2d'); + + ctx.beginPath(); + ctx.fillStyle = color[0]; + ctx.rect(0, 0, 1024*s, 1024*s); + ctx.fill(); + + let i = 8, r1, r2; + while(i--){ + r1 = this.rand( 150, 255 ); + r2 = this.rand( r1-60, r1-20 ); + ctx.beginPath(); + ctx.fillStyle = n!==1 ? 'rgb('+r1+','+r1+','+r2+')': color[1]; + ctx.rect( i*146*s, 0, 146*s, 200*s); + ctx.fill(); + } + + let t = new Texture( c ); + this.filterTexture( t, { flip:false } ); + return t; + + } + + + + + //----------------------------------- CARS + + makeCarColor () { + + let c = document.createElement( 'canvas' ); + c.width = c.height = 1024; + let ctx = c.getContext('2d'); + let i, n=0, j=0, k = 3; + + while(k--){ + + ctx.clearRect ( 0 , 0, c.width, c.height ); + + for( i=0; i<16; i++ ){ + ctx.beginPath(); + if(i!==11 && i!==15) ctx.fillStyle = this.carColor(); + ctx.rect(n*256, j*256, 256, 256); + ctx.fill(); + n++; + if(n==4){ n=0; j++; } + } + + ctx.drawImage( this.imgs.cars, 0, 0 ); + let name = 'cars_' + k; + this.textures[name] = new Texture( c ); + this.filterTexture( this.textures[name], { flip:false } ); + + } + + } + + carColor () { + + let carcolors = [ + [0xFFFFFF, 0xD0D1D3, 0XEFEFEF, 0xEEEEEE],//white + [0x252122, 0x302A2B, 0x27362B, 0x2F312B],//black + [0x8D9495, 0xC1C0BC, 0xCED4D4, 0xBEC4C4],//silver + [0x939599, 0x424242, 0x5A5A5A, 0x747675],//gray + [0xC44920, 0xFF4421, 0x600309, 0xD9141E],//red + [0x4AD1FB, 0x275A63, 0x118DDC, 0x2994A6],//blue + [0xA67936, 0x874921, 0xD7A56B, 0x550007],//brown + [0x5FF12C, 0x188047, 0x8DAE29, 0x1AB619],//green + [0xFFF10A, 0xFFFFBD, 0xFCFADF, 0xFFBD0A],//yellow/gold + [0xB92968, 0x5C1A4F, 0x001255, 0xFFB7E7]//other + ]; + + let l = this.randInt(0,9), n = this.randInt(0,3); + let base = carcolors[l][n]; + let resl = base.toString(16); + if(resl.length<6) resl = '#0'+resl; + else resl = '#'+resl; + return resl; + + } + + randInt( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + tile( type, id ) { + return this.tiles[type][id]; + } + + texture( name ) { + return this.textures[name]; + } + + + //----------------------------------- 3D MODEL + + loadModel() { + + this.displayMessage( 'Loading 3d model ...' ); + + let n = this.num; + let name = this.modelSrc[n]; + + this.loaderGLB.load( this.modelPath + name + '.glb', function ( gltf ) { + + let o = {}, b1, b2, t; + gltf.scene.traverse( function ( node ) { + if( node.name === 'title' ) t = node; + if( node.name === 'border' ) b1 = node; + if( node.name === 'border_min' ) b2 = node; + if( node.isMesh && !o[node.name] ) o[node.name] = node.geometry; + }); + if(b1) this.border = b1; + if(b2) this.border_min = b2; + if(t) this.title = t; + this.defineGeometry( o, name ); + + this.num++; + if( this.num === this.modelSrc.length ){ + this.displayMessage( '...' ); + this.callback(); + } else { + this.loadModel(); + } + + }.bind(this)); + + } + + defineGeometry ( o, name ){ + + let g, n; + + switch( name ){ + case 'cars': + + g = { cars:[] }; + for( let c in o ){ + n = Number( c.substring(4) ); + g.cars[n] = o[c]; + } + + break; + case 'world': + + g = { + town:[ + null, null, null, null, + o.police, o.park_1, o.park_2, o.fire, + o.coal, o.nuclear, o.port, o.stadium, o.airport + ], + tree:[ + o.ttt3, o.ttt3, o.ttt4, o.ttt4, + o.ttt0, o.ttt1, o.ttt2, o.ttt5 + ], + sprite:[ + o.train, o.elico.clone(), o.plane.clone() + ], + + residential:[], + commercial:[], + industrial:[], + house:[] + }; + + // BASIC + let i = 9; + while(i--) g.industrial[i] = o['i_0'+i]; + i = 19; + while(i--) g.residential[i] = i<10 ? o['r_0'+i] : o['r_'+i]; + i = 21; + while(i--) g.commercial[i] = i<10 ? o['c_0'+i] : o['c_'+i]; + i = 12; + while(i--) g.house[i] = i<10 ? o['rh_0'+i] : o['rh_'+i]; + + break; + } + + // ADD TO GEOS POOL + this.geos = { ...this.geos, ...g }; + + } + + geo ( type, id ){ + return this.geos[type][id] || null; + } + + +} + +/** + * @param {Array} geometries + * @param {Boolean} useGroups + * @return {BufferGeometry} + */ +function mergeBufferGeometries( geometries, useGroups = false ) { + + const isIndexed = geometries[ 0 ].index !== null; + + const attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) ); + const morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) ); + + const attributes = {}; + const morphAttributes = {}; + + const morphTargetsRelative = geometries[ 0 ].morphTargetsRelative; + + const mergedGeometry = new BufferGeometry(); + + let offset = 0; + + for ( let i = 0; i < geometries.length; ++ i ) { + + const geometry = geometries[ i ]; + let attributesCount = 0; + + // ensure that all geometries are indexed, or none + + if ( isIndexed !== ( geometry.index !== null ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' ); + return null; + + } + + // gather attributes, exit early if they're different + + for ( const name in geometry.attributes ) { + + if ( ! attributesUsed.has( name ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' ); + return null; + + } + + if ( attributes[ name ] === undefined ) attributes[ name ] = []; + + attributes[ name ].push( geometry.attributes[ name ] ); + + attributesCount ++; + + } + + // ensure geometries have the same number of attributes + + if ( attributesCount !== attributesUsed.size ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' ); + return null; + + } + + // gather morph attributes, exit early if they're different + + if ( morphTargetsRelative !== geometry.morphTargetsRelative ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' ); + return null; + + } + + for ( const name in geometry.morphAttributes ) { + + if ( ! morphAttributesUsed.has( name ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.' ); + return null; + + } + + if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = []; + + morphAttributes[ name ].push( geometry.morphAttributes[ name ] ); + + } + + // gather .userData + + mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || []; + mergedGeometry.userData.mergedUserData.push( geometry.userData ); + + if ( useGroups ) { + + let count; + + if ( isIndexed ) { + + count = geometry.index.count; + + } else if ( geometry.attributes.position !== undefined ) { + + count = geometry.attributes.position.count; + + } else { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' ); + return null; + + } + + mergedGeometry.addGroup( offset, count, i ); + + offset += count; + + } + + } + + // merge indices + + if ( isIndexed ) { + + let indexOffset = 0; + const mergedIndex = []; + + for ( let i = 0; i < geometries.length; ++ i ) { + + const index = geometries[ i ].index; + + for ( let j = 0; j < index.count; ++ j ) { + + mergedIndex.push( index.getX( j ) + indexOffset ); + + } + + indexOffset += geometries[ i ].attributes.position.count; + + } + + mergedGeometry.setIndex( mergedIndex ); + + } + + // merge attributes + + for ( const name in attributes ) { + + const mergedAttribute = mergeBufferAttributes( attributes[ name ] ); + + if ( ! mergedAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' ); + return null; + + } + + mergedGeometry.setAttribute( name, mergedAttribute ); + + } + + // merge morph attributes + + for ( const name in morphAttributes ) { + + const numMorphTargets = morphAttributes[ name ][ 0 ].length; + + if ( numMorphTargets === 0 ) break; + + mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {}; + mergedGeometry.morphAttributes[ name ] = []; + + for ( let i = 0; i < numMorphTargets; ++ i ) { + + const morphAttributesToMerge = []; + + for ( let j = 0; j < morphAttributes[ name ].length; ++ j ) { + + morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] ); + + } + + const mergedMorphAttribute = mergeBufferAttributes( morphAttributesToMerge ); + + if ( ! mergedMorphAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' ); + return null; + + } + + mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute ); + + } + + } + + return mergedGeometry; + +} + +/** + * @param {Array} attributes + * @return {BufferAttribute} + */ +function mergeBufferAttributes( attributes ) { + + let TypedArray; + let itemSize; + let normalized; + let arrayLength = 0; + + for ( let i = 0; i < attributes.length; ++ i ) { + + const attribute = attributes[ i ]; + + if ( attribute.isInterleavedBufferAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' ); + return null; + + } + + if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; + if ( TypedArray !== attribute.array.constructor ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' ); + return null; + + } + + if ( itemSize === undefined ) itemSize = attribute.itemSize; + if ( itemSize !== attribute.itemSize ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' ); + return null; + + } + + if ( normalized === undefined ) normalized = attribute.normalized; + if ( normalized !== attribute.normalized ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' ); + return null; + + } + + arrayLength += attribute.array.length; + + } + + const array = new TypedArray( arrayLength ); + let offset = 0; + + for ( let i = 0; i < attributes.length; ++ i ) { + + array.set( attributes[ i ].array, offset ); + + offset += attributes[ i ].array.length; + + } + + return new BufferAttribute( array, itemSize, normalized ); + +} + +class Pool$1 { + + constructor ( factory, pool ) { + + var k, v, _ref; + this.factory = factory; + this.objects = {}; + if ((pool != null) && (pool.objects != null)) { + _ref = pool.objects; + for (k in _ref) { + v = _ref[k]; + this.objects[k] = this.factory.copy(v); + } + } + + } + + get length() { + return Object.keys(this.objects).length; + } + + toJSON() { + return this.objects; + } + + get( id ) { + return this.objects[id]; + } + + put( obj ) { + return this.objects[obj.id] = obj; + } + + pop ( obj ) { + var id, result, _ref; + id = (_ref = obj.id) != null ? _ref : obj; + result = this.objects[id]; + if (typeof result.release === "function") { + result.release(); + } + delete this.objects[id]; + return result; + } + + all() { + return this.objects; + } + + clear() { + return this.objects = {}; + } + +} + +class ControlSignals { + + constructor ( intersection ) { + + this.intersection = intersection; + this.onTick = Traffic.binding(this.onTick, this); + this.flipMultiplier = Traffic.random(); + this.phaseOffset = 100 * Traffic.random(); + this.time = this.phaseOffset; + this.stateNum = 0; + this.states = [['L', '', 'L', ''], ['FR', '', 'FR', ''], ['', 'L', '', 'L'], ['', 'FR', '', 'FR']]; + + } + + get flipInterval() { + + return (0.1 + 0.05 * this.flipMultiplier) * Traffic.settings.lightsFlipInterval; + + } + + get state() { + + let i, len, results; + let stringState = this.states[this.stateNum % this.states.length]; + if (this.intersection.roads.length <= 2) { stringState = ['LFR', 'LFR', 'LFR', 'LFR']; } + results = []; + for (i = 0, len = stringState.length; i < len; i++) { + results.push( this._decode( stringState[i] ) ); + } + return results; + + } + + copy( controlSignals, intersection ) { + + var result; + if (controlSignals == null) { + return new ControlSignals(intersection); + } + result = Object.create(ControlSignals.prototype); + result.flipMultiplier = controlSignals.flipMultiplier; + result.time = result.phaseOffset = controlSignals.phaseOffset; + result.stateNum = 0; + result.intersection = intersection; + return result; + + } + + toJSON() { + + return { + flipMultiplier: this.flipMultiplier, + phaseOffset: this.phaseOffset + } + + } + + _decode(str) { + + let state = [0, 0, 0]; + if (Traffic.indexOf.call(str, 'L') >= 0) state[0] = 1; + if (Traffic.indexOf.call(str, 'F') >= 0) state[1] = 1; + if (Traffic.indexOf.call(str, 'R') >= 0) state[2] = 1; + return state; + + } + + flip() { + + this.stateNum += 1; + + } + + onTick( delta ) { + + this.time += delta; + if ( this.time > this.flipInterval ) { + this.flip(); + this.time -= this.flipInterval; + } + + } + +} + +class Point { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + get length() { + + return Traffic.sqrt(this.x * this.x + this.y * this.y); + + } + + get direction() { + + return Traffic.atan2(this.y, this.x); + + } + + get normalized() { + + return new this.constructor(this.x / this.length, this.y / this.length); + + } + + toKey(){ + + return [this.x, this.y].join(','); + + } + + add( o ) { + + return new this.constructor(this.x + o.x, this.y + o.y); + + } + + subtract( o ) { + + return new this.constructor(this.x - o.x, this.y - o.y); + + } + + mult( k ) { + + return new this.constructor(this.x * k, this.y * k); + + } + + divide( k ) { + + return new this.constructor(this.x / k, this.y / k); + + } + + distanceTo( v ) { + + return Traffic.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y; + return dx * dx + dy * dy; + + } + + +} + +class Segment { + + constructor( source, target ) { + + this.source = source; + this.target = target; + + } + + get vector() { + + return this.target.subtract( this.source ); + + } + + get length() { + + return this.vector.length; + + } + + get direction() { + + return this.vector.direction; + + } + + get center() { + + return this.getPoint(0.5); + + } + + split( n, reverse ) { + + let result = [], order = [], i = n; + while( i-- ) order.push(i); + if( !reverse ) order = order.reverse(); + for( let k in order ) result.push( this.subsegment(order[k] / n, (order[k] + 1) / n) ); + return result + + } + + getPoint( a ) { + + return this.source.add( this.vector.mult(a) ); + + } + + subsegment( a, b ) { + + let offset = this.vector; + let start = this.source.add( offset.mult(a) ); + let end = this.source.add( offset.mult(b) ); + return new Segment(start, end); + + } + +} + +class Rect { + + constructor( x = 0, y = 0, width = 0, height = 0 ) { + + this.x = x; + this.y = y; + this._width = width; + this._height = height; + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this._width = v._width; + this._height = v._height; + return this; + + } + + clone() { + + return new this.constructor( this.x, this.y, this._width, this._height ); + + } + + toJSON() { + + return Traffic.extend({}, this); + + } + + key(){ + + return [this.x, this.y].join(','); + + } + + area() { + + return this.width() * this.height(); + + } + + left( left ) { + + if( left != null ) this.x = left; + return this.x; + + } + + right( right ) { + + if( right != null ) this.x = right - this.width(); + return this.x + this.width(); + + } + + width( width ) { + + if( width != null ) this._width = width; + return this._width; + + } + + top( top ) { + + if (top != null) this.y = top; + return this.y; + + } + + bottom( bottom ) { + + if( bottom != null ) this.y = bottom - this.height(); + return this.y + this.height(); + + } + + height( height ) { + + if (height != null) this._height = height; + return this._height; + + } + + pos() { + + return new Point( this.x, this.y ); + + } + + center( center ) { + + if (center != null) { + this.x = center.x - this.width() * 0.5; + this.y = center.y - this.height() * 0.5; + } + return new Point( this.x + this.width() * 0.5, this.y + this.height() * 0.5 ); + + } + + containsPoint( point ) { + + return (this.left() <= point.x && point.x <= this.right()) && (this.top() <= point.y && point.y <= this.bottom()) + + } + + containsRect( rect ) { + + return this.left() <= rect.left() && rect.right() <= this.right() && this.top() <= rect.top() && rect.bottom() <= this.bottom(); + + } + + getVertices() { + + return [ + new Point(this.left(), this.top()), + new Point(this.right(), this.top()), + new Point(this.right(), this.bottom()), + new Point(this.left(), this.bottom()) + ]; + + } + + getSide( i ) { + + let vertices = this.getVertices(); + return new Segment(vertices[i], vertices[(i + 1) % 4]); + + } + + getSectorId( point ) { + + let offset = point.subtract( this.center() ); + if (offset.y <= 0 && Traffic.abs(offset.x) <= Traffic.abs(offset.y)) return 0; + if (offset.x >= 0 && Traffic.abs(offset.x) >= Traffic.abs(offset.y)) return 1; + if (offset.y >= 0 && Traffic.abs(offset.x) <= Traffic.abs(offset.y)) return 2; + if (offset.x <= 0 && Traffic.abs(offset.x) >= Traffic.abs(offset.y)) return 3; + + /* if (offset.y <= 0 && (offset.x) <= (offset.y)) return 0; + if (offset.x >= 0 && (offset.x) >= (offset.y)) return 1; + if (offset.y >= 0 && (offset.x) <= (offset.y)) return 2; + if (offset.x <= 0 && (offset.x) >= (offset.y)) return 3;*/ + throw Error('algorithm error'); + + } + + getSector( point ) { + + return this.getSide(this.getSectorId(point)); + + } + +} + +class Intersection { + + constructor( rect ) { + + this.rect = rect; + this.key = this.rect.key(); + this.id = Traffic.uniqueId('intersection'); + this.roads = []; + this.inRoads = []; + this.controlSignals = new ControlSignals( this ); + + } + + copy( intersection ) { + + this.rect = intersection.rect.clone(); + return this; + + /*var result; + intersection.rect = intersection.rect.clone() + result = Object.create( Intersection.prototype ); + Traffic.extend( result, intersection ); + result.roads = []; + result.inRoads = []; + result.controlSignals = new ControlSignals( result ); + return result;*/ + + } + + toJSON() { + + return { id: this.id, rect: this.rect }; + + } + + update() { + + let i, n =0; + for( i in this.roads ){ this.roads[i].update(); n++; } + for( i in this.inRoads ){ this.inRoads[i].update(); n++; } + console.log( 'update', n ); + + } +} + +class Lane { + + constructor ( sourceSegment, targetSegment, road ) { + + this.sourceSegment = sourceSegment; + this.targetSegment = targetSegment; + this.road = road; + this.leftAdjacent = null; + this.rightAdjacent = null; + this.leftmostAdjacent = null; + this.rightmostAdjacent = null; + this.carsPositions = {}; + this.update(); + + } + + get sourceSideId() { + + return this.road.sourceSideId; + + } + + get targetSideId() { + + return this.road.targetSideId; + + } + + get isRightmost() { + + return this === this.rightmostAdjacent; + + } + + get isLeftmost() { + + return this === this.leftmostAdjacent; + + } + + get leftBorder() { + + return new Segment(this.sourceSegment.source, this.targetSegment.target); + + } + + get rightBorder() { + + return new Segment(this.sourceSegment.target, this.targetSegment.source); + + } + + toJSON( lane ) { + + var obj = Traffic.extend({}, this); + delete obj.carsPositions; + return obj; + + } + + update() { + + this.middleLine = new Segment( this.sourceSegment.center, this.targetSegment.center ); + this.length = this.middleLine.length; + this.direction = this.middleLine.direction; + + } + + getTurnDirection( other ) { + + return this.road.getTurnDirection(other.road); + + } + + getDirection() { + + return this.direction; + + } + + getPoint( a ) { + + return this.middleLine.getPoint( a ); + + } + + addCarPosition( carPosition ) { + + if (carPosition.id in this.carsPositions) throw Error('car is already here'); + this.carsPositions[carPosition.id] = carPosition; + + } + + removeCar( carPosition ) { + + if (!(carPosition.id in this.carsPositions)) throw Error('removing unknown car'); + delete this.carsPositions[carPosition.id]; + + } + + getNext( carPosition ) { + + let bestDistance, distance, id, next, o; + if (carPosition.lane !== this) throw Error('car is on other lane'); + next = null; + bestDistance = Infinity; + + for ( id in this.carsPositions ) { + o = this.carsPositions[id]; + distance = o.position - carPosition.position; + if (!o.free && (0 < distance && distance < bestDistance)) { + bestDistance = distance; + next = o; + } + } + return next; + + } + +} + +class Road { + + constructor ( source, target ) { + + this.source = source; + this.target = target; + this.id = Traffic.uniqueId('road'); + this.lanes = []; + this.lanesNumber = null; + this.update(); + + } + + get length() { + + return this.targetSide.target.subtract(this.sourceSide.source).length; + + } + + get leftmostLane() { + + return this.lanes[this.lanesNumber - 1]; + + } + + get rightmostLane() { + + return this.lanes[0]; + + } + + copy( road ) { + + let result; + result = Object.create(Road.prototype); + Traffic.extend.extend(result, road); + if (result.lanes == null) result.lanes = []; + return result; + + } + + toJSON() { + + return { id: this.id, source: this.source.id, target: this.target.id }; + + } + + getTurnDirection( other ) { + + let side1, side2; + if (this.target !== other.source) throw Error('invalid roads'); + side1 = this.targetSideId; + side2 = other.sourceSideId; + return (side2 - side1 - 1 + 8) % 4; + + } + + update() { + + let i, sourceSplits, targetSplits, _base, _i, _j, _ref, _ref1, _results; + if (!(this.source && this.target)) throw Error('incomplete road'); + this.sourceSideId = this.source.rect.getSectorId(this.target.rect.center()); + this.sourceSide = this.source.rect.getSide(this.sourceSideId).subsegment(0.5, 1.0); + this.targetSideId = this.target.rect.getSectorId(this.source.rect.center()); + this.targetSide = this.target.rect.getSide(this.targetSideId).subsegment(0, 0.5); + this.lanesNumber = Traffic.min(this.sourceSide.length, this.targetSide.length) | 0; + this.lanesNumber = Traffic.max(2, this.lanesNumber / Traffic.settings.gridSize | 0); + sourceSplits = this.sourceSide.split(this.lanesNumber, true); + targetSplits = this.targetSide.split(this.lanesNumber); + if ((this.lanes == null) || this.lanes.length < this.lanesNumber) { + if (this.lanes == null) this.lanes = []; + for (i = _i = 0, _ref = this.lanesNumber - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { + if ((_base = this.lanes)[i] == null) _base[i] = new Lane(sourceSplits[i], targetSplits[i], this); + } + } + _results = []; + for (i = _j = 0, _ref1 = this.lanesNumber - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) { + this.lanes[i].sourceSegment = sourceSplits[i]; + this.lanes[i].targetSegment = targetSplits[i]; + this.lanes[i].leftAdjacent = this.lanes[i + 1]; + this.lanes[i].rightAdjacent = this.lanes[i - 1]; + this.lanes[i].leftmostAdjacent = this.lanes[this.lanesNumber - 1]; + this.lanes[i].rightmostAdjacent = this.lanes[0]; + _results.push(this.lanes[i].update()); + } + + //this.source.update(); + //this.target.update(); + //return _results; + + //console.log( 'update road', _results.length ) + + } + +} + +class LanePosition { + + constructor ( car, lane, position ) { + + this.car = car; + this.position = position; + this.id = Traffic.uniqueId('laneposition'); + this.free = true; + this._lane = lane; + + } + + get lane() { + + return this._lane; + + } + + set lane( value ) { + + this.release(); + this._lane = value; + + } + + get relativePosition() { + + return this.position / this.lane.length; + + } + + get nextCarDistance() { + + let frontPosition, next, rearPosition; + next = this.getNext(); + if( next ) { + rearPosition = next.position - next.car.length * 0.5; + frontPosition = this.position + this.car.length * 0.5; + return { car: next.car, distance: (rearPosition - frontPosition) }; + } + return { car: null, distance: Infinity }; + + } + + acquire() { + + let _ref; + if (((_ref = this.lane) != null ? _ref.addCarPosition : void 0) != null) { + this.free = false; + return this.lane.addCarPosition(this); + } + + } + + release() { + + let _ref; + if (!this.free && ((_ref = this.lane) != null ? _ref.removeCar : void 0)) { + this.free = true; + return this.lane.removeCar(this); + } + + } + + getNext() { + + if (this.lane && !this.free) return this.lane.getNext(this); + + } + +} + +class Curve { + + constructor ( _at_A, _at_B, _at_O, _at_Q ) { + + this.A = _at_A; + this.B = _at_B; + this.O = _at_O; + this.Q = _at_Q; + this.AB = new Segment(this.A, this.B); + this.AO = new Segment(this.A, this.O); + this.OQ = new Segment(this.O, this.Q); + this.QB = new Segment(this.Q, this.B); + this._length = null; + + } + + get length (){ + + let i, point, pointsNumber, prevPoint, _i; + if( this._length == null ) { + pointsNumber = 10; + prevPoint = null; + this._length = 0; + for (i = _i = 0; 0 <= pointsNumber ? _i <= pointsNumber : _i >= pointsNumber; i = 0 <= pointsNumber ? ++_i : --_i) { + point = this.getPoint(i / pointsNumber); + if( prevPoint ) this._length += point.subtract( prevPoint ).length; + prevPoint = point; + } + } + return this._length; + + } + + getPoint ( a ) { + let p0, p1, p2, r0, r1; + p0 = this.AO.getPoint(a); + p1 = this.OQ.getPoint(a); + p2 = this.QB.getPoint(a); + r0 = (new Segment(p0, p1)).getPoint(a); + r1 = (new Segment(p1, p2)).getPoint(a); + return (new Segment(r0, r1)).getPoint(a); + } + + getDirection ( a ) { + let p0, p1, p2, r0, r1; + p0 = this.AO.getPoint(a); + p1 = this.OQ.getPoint(a); + p2 = this.QB.getPoint(a); + r0 = (new Segment(p0, p1)).getPoint(a); + r1 = (new Segment(p1, p2)).getPoint(a); + return (new Segment(r0, r1)).direction; + } + +} + +class Trajectory { + + constructor ( car, lane, position ) { + + this.car = car; + if (position == null) position = 0; + this.current = new LanePosition(this.car, lane, position); + this.current.acquire(); + this.next = new LanePosition(this.car); + this.temp = new LanePosition(this.car); + this.isChangingLanes = false; + + } + + get lane() { + + return this.temp.lane || this.current.lane; + + } + + get absolutePosition() { + + if (this.temp.lane != null) return this.temp.position; + else return this.current.position; + + } + + get relativePosition() { + + return this.absolutePosition / this.lane.length; + + } + + get direction() { + + return this.lane.getDirection(this.relativePosition); + + } + + get coords() { + + return this.lane.getPoint(this.relativePosition); + + } + + get nextCarDistance() { + + let a, b; + a = this.current.nextCarDistance; + b = this.next.nextCarDistance; + if (a.distance < b.distance) return a; + else return b; + + } + + get distanceToStopLine() { + + if (!this.canEnterIntersection()) return this.getDistanceToIntersection(); + return Infinity; + + } + + get nextIntersection() { + + return this.current.lane.road.target; + + } + + get previousIntersection() { + + return this.current.lane.road.source; + + } + + isValidTurn() { + + let nextLane, sourceLane, turnNumber; + nextLane = this.car.nextLane; + sourceLane = this.current.lane; + if (!nextLane) throw Error('no road to enter'); + turnNumber = sourceLane.getTurnDirection(nextLane); + if (turnNumber === 3) throw Error('no U-turns are allowed'); + if (turnNumber === 0 && !sourceLane.isLeftmost) throw Error('no left turns from this lane'); + if (turnNumber === 2 && !sourceLane.isRightmost) throw Error('no right turns from this lane'); + return true; + + } + + canEnterIntersection() { + + let intersection, nextLane, sideId, sourceLane, turnNumber; + nextLane = this.car.nextLane; + sourceLane = this.current.lane; + if (!nextLane) return true; + intersection = this.nextIntersection; + turnNumber = sourceLane.getTurnDirection(nextLane); + sideId = sourceLane.road.targetSideId; + return intersection.controlSignals.state[sideId][turnNumber]; + + } + + getDistanceToIntersection() { + + let distance; + distance = this.current.lane.length - (this.car.length * 0.5) - this.current.position; + if (!this.isChangingLanes) return Traffic.max(distance, 0); + else return Infinity; + + } + + timeToMakeTurn( plannedStep = 0 ) { + + return this.getDistanceToIntersection() <= plannedStep; + + } + + moveForward( distance ) { + + let gap, tempRelativePosition, _ref, _ref1; + distance = Traffic.max(distance, 0); + this.current.position += distance; + this.next.position += distance; + this.temp.position += distance; + if (this.timeToMakeTurn() && this.canEnterIntersection() && this.isValidTurn()) this._startChangingLanes(this.car.popNextLane(), 0); + + tempRelativePosition = this.temp.position / ((_ref = this.temp.lane) != null ? _ref.length : void 0); + gap = 2 * this.car.length; + if (this.isChangingLanes && this.temp.position > gap && !this.current.free) this.current.release(); + + if (this.isChangingLanes && this.next.free && this.temp.position + gap > ((_ref1 = this.temp.lane) != null ? _ref1.length : void 0)) this.next.acquire(); + if (this.isChangingLanes && tempRelativePosition >= 1) this._finishChangingLanes(); + if (this.current.lane && !this.isChangingLanes && !this.car.nextLane) return this.car.pickNextLane(); + + } + + changeLane( nextLane ) { + + let nextPosition; + if (this.isChangingLanes) throw Error('already changing lane'); + if (nextLane == null) throw Error('no next lane'); + if (nextLane === this.lane) throw Error('next lane == current lane'); + if (this.lane.road !== nextLane.road) throw Error('not neighbouring lanes'); + nextPosition = this.current.position + 3 * this.car.length; + //nextPosition = this.current.position + 3 * this.car.length; + //if (!(nextPosition < this.lane.length)) throw Error('too late to change lane'); + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position + 2 * this.car.length; + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position + 1 * this.car.length; + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position; + return this._startChangingLanes(nextLane, nextPosition); + + } + + _getIntersectionLaneChangeCurve() { + + } + + _getAdjacentLaneChangeCurve() { + + let control1, control2, direction1, direction2, distance, p1, p2; + p1 = this.current.lane.getPoint(this.current.relativePosition); + p2 = this.next.lane.getPoint(this.next.relativePosition); + distance = p2.subtract(p1).length; + direction1 = this.current.lane.middleLine.vector.normalized.mult(distance * 0.3); + control1 = p1.add(direction1); + direction2 = this.next.lane.middleLine.vector.normalized.mult(distance * 0.3); + control2 = p2.subtract(direction2); + return new Curve(p1, p2, control1, control2); + + } + + _getCurve() { + + return this._getAdjacentLaneChangeCurve(); + + } + + _startChangingLanes( nextLane, nextPosition ) { + + if (this.isChangingLanes) throw Error('already changing lane'); + if (nextLane == null) throw Error('no next lane'); + this.isChangingLanes = true; + this.next.lane = nextLane; + this.next.position = nextPosition; + this.temp.lane = this._getCurve(); + this.temp.position = 0; + return this.next.position -= this.temp.lane.length; + + } + + _finishChangingLanes() { + + if (!this.isChangingLanes) throw Error('no lane changing is going on'); + this.isChangingLanes = false; + this.current.lane = this.next.lane; + this.current.position = this.next.position || 0; + this.current.acquire(); + this.next.lane = null; + this.next.position = NaN; + this.temp.lane = null; + this.temp.position = NaN; + return this.current.lane; + + } + + release() { + + let _ref, _ref1, _ref2; + if ((_ref = this.current) != null) _ref.release(); + if ((_ref1 = this.next) != null) _ref1.release(); + return (_ref2 = this.temp) != null ? _ref2.release() : void 0; + + } + +} + +class Car { + + constructor( lane, position ) { + + this.type = Traffic.rand(Traffic.TYPE_OF_CARS.length-1); + + this.id = Traffic.uniqueId('car'); + this.color = (300 + 240 * Traffic.random() | 0) % 360; + this._speed = 0; + + this.width = Traffic.TYPE_OF_CARS[this.type].w*Traffic.settings.carScale; + this.length = Traffic.TYPE_OF_CARS[this.type].l*Traffic.settings.carScale; + this.maxSpeed = 30*Traffic.settings.carSpeed; + if( Traffic.TYPE_OF_CARS[this.type].maxSpeed ) this.maxSpeed = Traffic.TYPE_OF_CARS[this.type].maxSpeed*Traffic.settings.carSpeed; + // minimal space between two car !! + this.s0 = 2 * Traffic.settings.carScale; + // minimal space before intersection + this.s1 = 1 * Traffic.settings.carScale; + + this.timeHeadway = 1.5*Traffic.settings.carSpeed; + this.maxAcceleration = 1*Traffic.settings.carSpeed; + this.maxDeceleration = 3*Traffic.settings.carSpeed; + + this.mid = Traffic.settings.gridSize*0.5; + + this.trajectory = new Trajectory( this, lane, position ); + this.alive = true; + this.preferedLane = null; + + this.toLongStop = 0; + + } + + get pos() { + + let p = this.coords; + return { x:p.x-this.mid, y:p.y-this.mid }; + + } + + get coords() { + + return this.trajectory.coords; + + } + + get speed() { + + return this._speed; + + } + + set speed( value ) { + + this._speed = Traffic.clamp( value, 0, this.maxSpeed ); + + } + + get direction() { + + return this.trajectory.direction; + + } + + release() { + + return this.trajectory.release(); + + } + + getAcceleration() { + + let a, b, breakGap, busyRoadCoeff, coeff, deltaSpeed, distanceGap, distanceToNextCar, freeRoadCoeff, intersectionCoeff, nextCarDistance, safeDistance, safeIntersectionDistance, timeGap, _ref; + nextCarDistance = this.trajectory.nextCarDistance; + distanceToNextCar = Traffic.max(nextCarDistance.distance, 0); + a = this.maxAcceleration; + b = this.maxDeceleration; + deltaSpeed = (this.speed - ((_ref = nextCarDistance.car) != null ? _ref.speed : void 0)) || 0; + freeRoadCoeff = Traffic.pow(this.speed / this.maxSpeed, 4); + distanceGap = this.s0; + timeGap = this.speed * this.timeHeadway; + breakGap = this.speed * deltaSpeed / (2 * Traffic.sqrt(a * b)); + safeDistance = (distanceGap + timeGap + breakGap); + busyRoadCoeff = Traffic.pow(safeDistance / distanceToNextCar, 2); + safeIntersectionDistance = this.s1 + timeGap + Traffic.pow(this.speed, 2) / (2 * b); + intersectionCoeff = Traffic.pow(safeIntersectionDistance / this.trajectory.distanceToStopLine, 2); + coeff = 1 - freeRoadCoeff - busyRoadCoeff - intersectionCoeff; + return this.maxAcceleration * coeff; + + } + + move( delta ) { + + let acceleration, currentLane, preferedLane, step, turnNumber; + acceleration = this.getAcceleration(); + this.speed += acceleration * delta; + if ( !this.trajectory.isChangingLanes && this.nextLane ) { + currentLane = this.trajectory.current.lane; + turnNumber = currentLane.getTurnDirection(this.nextLane); + + switch (turnNumber) { + case 0: preferedLane = currentLane.leftmostAdjacent; break; + case 2: preferedLane = currentLane.rightmostAdjacent; break; + default: preferedLane = currentLane; + } + + if ( preferedLane !== currentLane ) { + this.trajectory.changeLane(preferedLane); + } + } + step = this.speed * delta + 0.5 * acceleration * Traffic.pow(delta, 2); + // TODO: hacks, should have changed speed + if (this.trajectory.nextCarDistance.distance < step) { /*this.alive = false;*/ console.log('bad IDM');} + if (this.trajectory.timeToMakeTurn(step)) { + if (this.nextLane == null) return this.alive = false; + } + + + // bug with two car collision + if( this.trajectory.isChangingLanes ){ + if( step <= 0 ) this.toLongStop ++; + else this.toLongStop = 0; + if ( this.toLongStop > 1000 ){ console.log('car is locked !!'); this.alive = false; } + } + + // + + this.trajectory.moveForward( step ); + + } + + pickNextRoad() { + + let currentLane, intersection, possibleRoads; + intersection = this.trajectory.nextIntersection; + currentLane = this.trajectory.current.lane; + possibleRoads = intersection.roads.filter(function(x) { + return x.target !== currentLane.road.source; + }); + /*possibleRoads = Traffic.filter(function(x) { + return x.target !== currentLane.road.source; + }, intersection.roads);*/ + if (possibleRoads.length === 0) return null; + return Traffic.sample(possibleRoads); + + } + + pickNextLane() { + + let laneNumber, nextRoad, turnNumber; + if (this.nextLane) throw Error('next lane is already chosen'); + this.nextLane = null; + nextRoad = this.pickNextRoad(); + if (!nextRoad) return null; + turnNumber = this.trajectory.current.lane.road.getTurnDirection(nextRoad); + laneNumber = (function() { + switch (turnNumber) { + case 0: return nextRoad.lanesNumber - 1; case 1: return Traffic.rand(0, nextRoad.lanesNumber - 1); case 2: return 0; } + })(); + this.nextLane = nextRoad.lanes[laneNumber]; + if (!this.nextLane) throw Error('can not pick next lane'); + return this.nextLane; + + } + + popNextLane() { + + let nextLane = this.nextLane; + this.nextLane = null; + this.preferedLane = null; + return nextLane; + + } + +} + +class TrafficWorld { + + constructor () { + + this.toRemove = []; + this.onTick = Traffic.bind(this.onTick, this); + this.minDistance = Traffic.settings.gridSize/5; + this.set(); + + } + + get instantSpeed() { + + let speeds = Traffic.map( this.cars.all(), function(car) { return car.speed; }); + if (speeds.length === 0) return 0; + return (Traffic.reduce(speeds, function(a, b) { return a + b; })) / speeds.length; + + } + + set( obj = {} ) { + + if (obj == null) obj = {}; + this.intersections = new Pool$1( Intersection, obj.intersections); + this.roads = new Pool$1( Road, obj.roads ); + this.cars = new Pool$1( Car, obj.cars ); + return this.carsNumber = 0; + + } + + save() { + + let data; + data = Traffic.extend({}, this); + delete data.cars; + return window.localStorage.world = JSON.stringify(data); + + } + + load() { + + let data, id, intersection, road, _ref, _ref1, _results; + data = window.localStorage.world; + data = data && JSON.parse(data); + if (data == null) return; + this.clear(); + this.carsNumber = data.carsNumber || 0; + _ref = data.intersections; + for (id in _ref) { + intersection = _ref[id]; + this.addIntersection( new Intersection().copy(intersection) ); + } + _ref1 = data.roads; + _results = []; + for (id in _ref1) { + road = _ref1[id]; + road = new Road().copy(road); + road.source = this.getIntersection(road.source); + road.target = this.getIntersection(road.target); + _results.push(this.addRoad(road)); + } + return _results; + + } + + generateMap( X = 2, Y = 2, linemax = 5 , mult = 0.8, nCars = 100, decal = {x:1, y:1} ) { + + let minX = 0; + let maxX = X*2; + let minY = 0; + let maxY = Y*2; + + /*let minX = -X; + let maxX = X; + let minY = -Y; + let maxY = Y;*/ + let gridSize, intersection, intersectionsNumber, map, previous, step, x, y, _i, _j, _k, _l; + + this.clear(); + intersectionsNumber = (mult * (maxX - minX + 1) * (maxY - minY + 1)) | 0; + map = {}; + gridSize = Traffic.settings.gridSize; + step = linemax * gridSize; + this.carsNumber = nCars; + while ( intersectionsNumber > 0 ) { + x = Traffic.rand( minX, maxX ); + y = Traffic.rand( minY, maxY ); + if ( map[[x, y]] == null ) { + + intersection = this.addPoint( decal.x + (step * x), decal.y + (step * y) ); + //rect = new Rect( decal.x + (step * x), decal.y + (step * y), gridSize, gridSize ); + //intersection = new Intersection( rect ); + this.addIntersection( map[[x, y]] = intersection ); + intersectionsNumber -= 1; + } + } + for (x = _i = minX; minX <= maxX ? _i <= maxX : _i >= maxX; x = minX <= maxX ? ++_i : --_i) { + previous = null; + for (y = _j = minY; minY <= maxY ? _j <= maxY : _j >= maxY; y = minY <= maxY ? ++_j : --_j) { + intersection = map[[x, y]]; + if (intersection != null) { + if (Traffic.random() < 0.9) { + if (previous != null) this.addRoad( new Road(intersection, previous) ); + if (previous != null) this.addRoad( new Road(previous, intersection) ); + } + previous = intersection; + } + } + } + for (y = _k = minY; minY <= maxY ? _k <= maxY : _k >= maxY; y = minY <= maxY ? ++_k : --_k) { + previous = null; + for (x = _l = minX; minX <= maxX ? _l <= maxX : _l >= maxX; x = minX <= maxX ? ++_l : --_l) { + intersection = map[[x, y]]; + if (intersection != null) { + if (Traffic.random() < 0.9) { + if (previous != null) this.addRoad( new Road(intersection, previous) ); + if (previous != null) this.addRoad( new Road(previous, intersection) ); + } + previous = intersection; + } + } + } + return null; + } + + clear() { + + return this.set({}); + + } + + onTick( delta ) { + + let car, id, intersection, v; + if (delta > 1) throw Error('delta > 1'); + this.refreshCars(); + v = this.intersections.all(); + for ( id in v ) { + intersection = v[id]; + intersection.controlSignals.onTick(delta); + } + v = this.cars.all(); + //_results = []; + + for ( id in v ) { + car = v[id]; + car.move( delta ); + if ( !car.alive ) this.removeCar( car ); + } + + + + } + + // ________________TEST + + + roadFromTo( p1, p2 ) { + + let from = this.addPoint( p1.x, p1.y ); + let to = this.addPoint( p2.x, p2.y ); + this.addRoad( new Road(from, to) ); + + from.update(); + to.update(); + + } + + addPoint( x,y ) { + + let tmp = Traffic.TMP; + let key = [ x, y ].join(','); + + if( tmp.has( key ) ) return tmp.get( key ); + + let gridSize = Traffic.settings.gridSize; + let rect = new Rect( x, y, gridSize, gridSize ); + let intersection = new Intersection( rect ); + + tmp.set( key, intersection ); + this.intersections.put( intersection ); + + return intersection; + + } + + removePoint( intersection ) { + + let tmp = Traffic.TMP; + if( tmp.has( intersection.key ) ) return tmp.delete( intersection.key ); + return this.intersections.pop( intersection ); + + } + + + + + + refreshCars() { + + if (this.cars.length < this.carsNumber) this.addRandomCar(); + if (this.cars.length > this.carsNumber) return this.removeRandomCar(); + + } + + addRoad( road ) { + + this.roads.put(road); + road.source.roads.push(road); + road.target.inRoads.push(road); + return road.update(); + + } + + getRoad( id ) { + + return this.roads.get(id); + + } + + addCar( car ) { + + return this.cars.put(car); + + } + + getCar( id ) { + + return this.cars.get(id); + + } + + removeCar( car ) { + + this.toRemove.push(car.id); + this.cars.pop(car); + + } + + clearTmpRemove() { + + this.toRemove = []; + + } + + addIntersection( intersection ) { + + return this.intersections.put(intersection); + + } + + + + getIntersection( id ) { + + return this.intersections.get(id); + + } + + addRandomCar() { + + let lane, road; + road = Traffic.sample(this.roads.all()); + if (road != null) { + lane = Traffic.sample(road.lanes); + if (lane != null){ + //console.log('car add'); + return this.addCar( new Car(lane) ); + } + } + + } + + removeRandomCar() { + + let car; + car = Traffic.sample( this.cars.all() ); + if (car != null) return this.removeCar(car); + + } + +} + +const ctor = function(){}; +const breaker = {}; + +// Save bytes in the minified (but not gzipped) version: +const ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + +// Create quick reference variables for speed access to core prototypes. +const slice = ArrayProto.slice, + hasOwnProperty = ObjProto.hasOwnProperty; +const nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind; + + + +const Traffic = { + + idCounter : 0, + + TMP: new Map(), + + STATE : [ { RED: 0, GREEN: 1 } ], + + TYPE_OF_CARS : [ + + { w:1.8, l:4.8, h:1.4, m:'car001', name:'fordM' , wPos:[0.76,0,1.46], wRadius:0.36, nWheels:4, maxSpeed:40 }, + { w:1.8, l:4.5, h:1.8, m:'car002', name:'vaz' , wPos:[0.72,0,1.31], wRadius:0.36, nWheels:4 }, + { w:2.2, l:5.0, h:1.5, m:'car003', name:'coupe' , wPos:[0.96,0,1.49], wRadius:0.36, nWheels:4 }, + { w:2.2, l:5.2, h:1.9, m:'car004', name:'c4' , wPos:[0.93,0,1.65], wRadius:0.40, nWheels:4 }, + { w:2.2, l:5.2, h:1.8, m:'car005', name:'ben' , wPos:[0.88,0,1.58], wRadius:0.40, nWheels:4 }, + { w:2.1, l:5.4, h:1.7, m:'car006', name:'taxi' , wPos:[0.90,0,1.49], wRadius:0.40, nWheels:4 }, + { w:2.2, l:5.4, h:1.9, m:'car007', name:'207' , wPos:[0.94,0,1.60], wRadius:0.40, nWheels:4 }, + { w:2.3, l:5.9, h:1.7, m:'car008', name:'police' , wPos:[0.96,0,1.67], wRadius:0.40, nWheels:4 }, + { w:2.7, l:6.2, h:2.6, m:'car009', name:'van1' , wPos:[1.14,0,1.95], wRadius:0.46, nWheels:4 }, + { w:2.2, l:6.6, h:2.8, m:'car010', name:'van2' , wPos:[0.89,0,2.10], wRadius:0.40, nWheels:4 }, + { w:2.8, l:7.0, h:3.2, m:'car011', name:'van3' , wPos:[0.90,0,1.83], wRadius:0.46, nWheels:4 }, + { w:2.8, l:8.9, h:3.9, m:'car012', name:'truck1' , wPos:[1.00,0,2.58], wRadius:0.57, nWheels:6, maxSpeed:20 }, + { w:3.0, l:10.6, h:3.4, m:'car013', name:'truck1', wPos:[1.17,0,3.64], wRadius:0.57, nWheels:6, maxSpeed:20 }, + { w:3.0, l:12.7, h:3.4, m:'car014', name:'bus' , wPos:[1.25,0,2.49], wRadius:0.64, nWheels:4, maxSpeed:10 }, + + ], + + settings : { + lightsFlipInterval: 160, + gridSize: 1, + carScale: 0.05, + carSpeed: 0.05, + defaultTimeFactor: 5, + }, + + abs : Math.abs, + sqrt : Math.sqrt, + atan2 : Math.atan2, + random : Math.random, + max : Math.max, + min : Math.min, + pow : Math.pow, + + rand : function( min, max ){ + + if ( !max ) { max = min; min = 0; } + return min + Math.floor(Math.random() * (max - min + 1)); + + }, + + clamp : function( value, min, max ) { + + if (value < min) return min; + if (value > max) return max; + return value; + + }, + + // + + binding : function( fn, me ){ + + return function(){ return fn.apply(me, arguments); }; + + }, + + bind : function( func, context ) { + + let args, bound; + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + //if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + let self = new ctor; + ctor.prototype = null; + let result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; + } + + }, + + indexOf : [].indexOf || function( item ) { for (let i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + + sample : function( obj, n, guard ){ + + if( n == null || guard ) { + if( obj.length !== +obj.length ) obj = Traffic.values(obj); + //if( obj.length !== obj.length+1 ) obj = Traffic.values(obj); + return obj[Traffic.rand(obj.length - 1)]; + } + return Traffic.shuffle(obj).slice(0, Math.max(0, n)); + + }, + + shuffle: function( obj ) { + + let rand, index = 0, shuffled = []; + Traffic.each(obj, function(value) { + rand = Traffic.rand(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + + }, + + uniqueId: function( prefix ) { + + let id = ++Traffic.idCounter + ''; + return prefix ? prefix + id : id; + + }, + + extend: function( obj ) { + + Traffic.each(slice.call(arguments, 1), function(source) { + if (source) { + for (let prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + + }, + + reduce: function( obj, iterator, memo, context ) { + + let initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = Traffic.bind(iterator, context); + return initial ? obj.reduce( iterator, memo ) : obj.reduce( iterator ); + } + Traffic.each( obj, function( value, index, list ) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + //if (!initial) throw new TypeError(reduceError); + return memo; + + }, + + each : function( obj, iterator, context ) { + + let i, keys; + + if (obj == null) return obj; + if (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } else if (obj.length === +obj.length) { + i = obj.length; + while(i--){ + if (iterator.call(context, obj[i], i, obj) === breaker) return; + } + } else { + keys = Traffic.keys(obj); + i = keys.length; + while(i--){ + if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; + } + } + return obj; + + }, + + keys: function( obj ) { + + if (!Traffic.isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + let keys = []; + for (let key in obj) if (Traffic.has(obj, key)) keys.push(key); + return keys; + + }, + + isObject: function( obj ) { + return obj === Object(obj); + }, + + has: function( obj, key ) { + + return hasOwnProperty.call(obj, key); + + }, + + values: function( obj ) { + + let keys = Traffic.keys(obj); + let values = []; + let i = keys.length; + while(i--){ + values[i] = obj[keys[i]]; + } + return values; + + }, + + map: function( obj, iterator, context ){ + + let results = []; + if ( obj == null ) return results; + if ( nativeMap && obj.map === nativeMap ) return obj.map( iterator, context ); + Traffic.each(obj, function(value, index, list) { + results.push(iterator.call(context, value, index, list)); + }); + return results; + + } + +}; + +class TrafficBase extends Group$1 { + + constructor( o = {} ) { + + super(); + + let isStandard = o.isStandard !== undefined ? o.isStandard : true; + + this.position.y = 0.01; + + this.callback = o.callback || null; + + this.cars = []; + this.roads = []; + this.inter = []; + this.mats = {}; + + this.mapPath = './assets/textures/'; + this.modelPath = './assets/models/'; + + const loader = new TextureLoader(); + this.grid = Traffic.settings.gridSize; + + this.sets = { + timeFactor:5, + lightsFlip:0 + }; + + + + //const MATYPE = THREE.MeshBasicMaterial + const MATYPE = isStandard ? MeshStandardMaterial : MeshBasicMaterial; + let op = isStandard ? { metalness:0.8, roughness:0.2 } : {}; + + this.car_geo = {}; + this.car_mat = []; + + + + this.car_mat[0] = new MATYPE( op ); + this.car_mat[1] = new MATYPE( op ); + this.car_mat[2] = new MATYPE( op ); + let img = new Image(); + img.onload = function(){ + this.generateRandomColor( img, this.car_mat[0] ); + this.generateRandomColor( img, this.car_mat[1] ); + this.generateRandomColor( img, this.car_mat[2] ); + }.bind(this); + img.src = this.mapPath + 'cars.png'; + + this.inter_geo = new PlaneGeometry( this.grid, this.grid ); + this.inter_geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI*0.5)); + + this.road_geo = new PlaneGeometry( this.grid, this.grid ); + this.road_geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI*0.5)); + + this.mats['inter_mat'] = new MATYPE( { map:loader.load( this.mapPath + 'roadx.png' ), ...op } ); + this.mats['road_mat'] = new MATYPE( { map:loader.load( this.mapPath + 'road.png' ), ...op } ); + + + + this.loadCarsModel(); + + + } + + clearAll(){ + + clearInterval( this.interval ); + + let i = this.children.length; + while(i--){ + this.remove(this.children[i]); + } + + // geometry + + for(let g in this.car_geo){ + + this.car_geo[g].dispose(); + + } + this.road_geo.dispose(); + this.inter_geo.dispose(); + + // material + + this.car_mat[0].dispose(); + this.car_mat[1].dispose(); + this.car_mat[2]; + + this.mats['inter_mat'].dispose(); + this.mats['road_mat'].dispose(); + + this.cars = []; + this.roads = []; + this.inter = []; + this.mats = {}; + + this.parent.remove(this); + + } + + init(){ + + Traffic.settings.gridSize = 1; + Traffic.settings.carScale = 0.05; + Traffic.settings.carSpeed = 0.05; + Traffic.settings.defaultTimeFactor = 5; + + this.world = new TrafficWorld(); + this.world.generateMap( 2, 2, 4, 1, 100 ); + //world.generateMap( 6, 6, 2, 1, 100 ); + //world.generateMap( 1, 1, 10, 0.5, 100 ); + //world.carsNumber = 100; + this.previousTime = 0; + this.sets.timeFactor = Traffic.settings.defaultTimeFactor; + this.sets.lightsFlip = Traffic.settings.lightsFlipInterval; + + + this.interval = setInterval( this.update.bind(this), 1000/60); + + + if(this.callback) this.callback(); + + //setTimeout(function(){ world.roadFromTo({x:4, y:3},{x:4,y:8}); }, 3000); + //setTimeout(function(){ world.roadFromTo({x:4, y:8},{x:10,y:8}); }, 4000); + //setTimeout(function(){ world.generateMap( 1, 1, 8, 1, 100 );; }, 6000); + + } + + update(){ + + Traffic.settings.lightsFlipInterval = this.sets.lightsFlip; + + let now = Date.now(); + now - this.lastUpdate; + this.lastUpdate = now; + let time = Date.now(); + + let delta = (time - this.previousTime) || 0; + //if (delta > 1) { + if (delta > 100) { delta = 100; } + this.previousTime = time; + this.world.onTick( this.sets.timeFactor * delta / 1000 ); + //console.log(dt) + //var dt = 0.1; + //var dt = Math.random() + //world.onTick(0.1); + + let o0, o1, o3, id; + + o0 = this.world.intersections.all(); + for (id in o0) { + this.addInter(o0[id]); + } + o1 = this.world.roads.all(); + for (id in o1) { + this.addRoad(o1[id]); + this.addSignals(o1[id]); + } + /*o2 = this.world.roads.all(); + for (id in o2) { + //road = _ref2[id]; + this.drawSignals(road); + }*/ + + // remove car + let i = this.world.toRemove.length; + while(i--){ this.removeCar( this.world.toRemove[i]); } this.world.clearTmpRemove(); + + o3 = this.world.cars.all(); + for (id in o3) { + this.addCar( o3[id], id ); + } + //} + + // window.requestAnimationFrame(update); + } + + generateRandomColor( img, mat ) { + + const canvas = document.createElement( 'canvas' ); + canvas.width = canvas.height = 1024; + const ctx = canvas.getContext('2d'); + let i, n=0, j=0; + + for( i=0; i<16; i++ ){ + ctx.beginPath(); + if(i!==11 && i!==15) ctx.fillStyle = this.randCarColor(); + ctx.rect(n*256, j*256, 256, 256); + ctx.fill(); + n++; + if(n==4){ n=0; j++; } + } + + ctx.drawImage(img, 0, 0, 1024,1024); + let tx = new Texture(canvas); + tx.needsUpdate = true; + tx.flipY = false; + mat.map = tx; + mat.needsUpdate = true; + + } + + loadCarsModel() { + + let geo = this.car_geo; + let glbLoader = new GLTFLoader(); + let dracoLoader = new DRACOLoader().setDecoderPath( './build/draco/' ); + glbLoader.setDRACOLoader( dracoLoader ); + + glbLoader.load( this.modelPath + 'cars.glb', function ( gltf ) { + + gltf.scene.traverse( function ( node ) { + + if( node.isMesh ) geo[node.name] = node.geometry; + + }); + + this.init(); + + }.bind(this)); + + } + + addRoad( road ) { + + if ((road.source == null) || (road.target == null)) throw Error('invalid road'); + let id = road.id.substring(4); + if(this.roads[id]==null){ + //var sourceSide = road.sourceSide; + // var targetSide = road.targetSide + + let p0 = road.source.rect.pos(); + let p1 = road.target.rect.pos(); + let lngx = ((p1.x-p0.x)/this.grid); + let lngy = ((p1.y-p0.y)/this.grid); + let side = 0; + let dir = 1; + + //if( lngy===0 && lngx=== 0 ) return; + + if(lngy!=0) side=1; + let i; + + if(side==0){ + i = Math.abs(lngx)-1; + if(lngx<0) dir = -1; + }else { + i = Math.abs(lngy)-1; + if(lngy<0) dir = -1; + } + + if( i<=0 ) return; + + //var g = new THREE.BufferGeometry(); + let m = new Matrix4(); + + let ng; + let geoms = []; + + while(i--){ + if(side==0){ + m.makeTranslation((p0.x+(this.grid*dir)+((i*this.grid)*dir)), 0, p0.y); + m.multiply(new Matrix4().makeRotationY(Math.PI*0.5)); + }else { + m.makeTranslation(p0.x, 0, (p0.y+(this.grid*dir)+((i*this.grid)*dir))); + } + + ng = this.road_geo.clone(); + ng.applyMatrix4( m ); + + geoms.push( ng ); + + + //g.merge( road_geo, m ); + } + + + + let g = mergeBufferGeometries( geoms ); + + //var mtx = new THREE.Matrix4().makeScale(scaler,scaler,scaler) + //g.applyMatrix4( mtx ) + + + let c = new Mesh( g, this.mats['road_mat'] ); + this.add( c ); + + + /*var dir = 0, lng; + if(lng1>lng0) dir=1; + + if(dir == 0 ) lng = lng0/14; + else lng = lng1/14;*/ + + //console.log(lngx, lngy) + + //c.position.set(p0.x, 0.8,p0.y); + this.roads[id] = c; + } + /*; + var start = sourceSide.source.x;*/ + //var end = targetSide.target.center(); + //console.log(sourceSide) + + + + //(sourceSide.source, sourceSide.target, targetSide.source, targetSide.target) + } + + addSignals(cc, id) { + } + + + addCar( car ) { + + let id = car.id.substring(3); + if( this.cars[id]==null ){ + let r = this.randInt(0,2); + let c = new Mesh( this.car_geo[ Traffic.TYPE_OF_CARS[ car.type].m ], this.car_mat[r] ); + + this.add( c ); + c.position.set(10000, 0,0); + c.scale.set(5, 5, 5); + //c.scale.set(car.length, car.length/2, car.width); + this.cars[id] = c; + } else { + let p = car.pos; + let r = car.direction; + this.cars[id].position.set(p.x,0,p.y); + this.cars[id].rotation.y = -r+(Math.PI*0.5); + } + } + + removeCar( id ) { + + id = id.substring(3); + if(this.cars[id]!=null){ + this.remove( this.cars[id] ); + this.cars[id] = null; + } + + } + + addInter( intersection ) {//intersection + + let id = intersection.id.substring(12); + if( this.inter[id]==null ){ + this.inter[id] = new Mesh( this.inter_geo, this.mats['inter_mat'] ); + this.add( this.inter[id] ); + intersection.roads.length; + // console.log(intersection.inRoads.length) + /*var i = type; + while(i){ + var sideId = intersection.roads[i].targetSideId; + console.log(sideId) + }*/ + /*switch(type){ + case 4: inter[id].material = inter_matx; break; + case 3: inter[id].material = inter_maty; break; + case 2: inter[id].material = inter_matz; break; + case 1: inter[id].material = inter_mate; break; + }*/ + let c = intersection.rect.pos(); + this.inter[id].position.set(c.x,0,c.y); + //inter[id].scale.set(1, 1, 1).multiplyScalar(scaler); + } else { + //var c = cc.rect; + intersection.controlSignals.state[0]; + //if(l[0]==1)inter[id].material = inter_mat; + //else inter[id].material = inter_mat0; + + } + + } + + // some math function + + randColor() { return '#'+Math.floor(Math.random()*16777215).toString(16); } + + randCarColor () { + + let carcolors = [ + [0xFFFFFF, 0xD0D1D3, 0XEFEFEF, 0xEEEEEE],//white + [0x252122, 0x302A2B, 0x27362B, 0x2F312B],//black + [0x8D9495, 0xC1C0BC, 0xCED4D4, 0xBEC4C4],//silver + [0x939599, 0x424242, 0x5A5A5A, 0x747675],//gray + [0xC44920, 0xFF4421, 0x600309, 0xD9141E],//red + [0x4AD1FB, 0x275A63, 0x118DDC, 0x2994A6],//blue + [0xA67936, 0x874921, 0xD7A56B, 0x550007],//brown + [0x5FF12C, 0x188047, 0x8DAE29, 0x1AB619],//green + [0xFFF10A, 0xFFFFBD, 0xFCFADF, 0xFFBD0A],//yellow/gold + [0xB92968, 0x5C1A4F, 0x001255, 0xFFB7E7]//other + ]; + + let l, p = this.randInt(0,100), n = this.randInt(0,3); + + if(p<23)l=0; + else if(p<44)l=1; + else if(p<62)l=2; + else if(p<76)l=3; + else if(p<84)l=4; + else if(p<90)l=5; + else if(p<96)l=6; + else if(p<97)l=7; + else if(p<98)l=8; + else l=9; + + let base = carcolors[l][n]; + + let resl = base.toString(16); + if(resl.length<6) resl = '#0'+resl; + else resl = '#'+resl; + return resl; + } + + randInt( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + + + +} + +//let Audio; + +class View { + + constructor ( isMobile, Hub, pix, isLow ) { + + this.container = document.getElementById( 'container' ); + + this.mapPath = './assets/textures/'; + this.modelPath = './assets/models/'; + this.rootModel = this.modelPath + 'world.glb'; + + this.hub = null; + + this.isMenu = false; + + this.inMapGenation = false; + + this.isPixelStyle = false; + + this.metalness = 0.6; + this.roughness = 0.3; + this.wireframe = false; + + this.loadGame = null; + + + this.M_list = ['treeLists' , 'townLists' , 'houseLists' , 'buildingLists' ]; + this.M_temp = ['tempTreeLayers', 'temptownLayers', 'tempHouseLayers' , 'tempBuildingLayers' ]; + //this.M_geom = ['treeGeo' , 'buildingGeo' , 'houseGeo' , 'X' ]; + this.M_mesh = ['treeMeshs' , 'townMeshs' , 'houseMeshs' , 'buildingMeshs' ]; + this.M_mats = ['townMaterial' , 'townMaterial' , 'buildingMaterial' , 'buildingMaterial' ]; + + this.pix = window.devicePixelRatio; + if( this.pix > 2 ) this.pix = 2; + + this.isLow = isLow || false; + + this.isMobile = isMobile || false; + + this.ARRAY_TYPE = ( typeof Float32Array !== 'undefined' ) ? Float32Array : Array; + + this.isWithTree = true; + this.isWithLight = true; + + this.isStandardMaterial = true; + + this.isWithEnv = true; + this.isWithNormal = true; + this.isWithRoughness = true; + this.isWithFog = true; + this.isIsland = false; + this.isWinter = false; + + this.isComputeVertex = true; + this.isTransGeo = true; + + //this.tmpCanvas = null; + //this.tilesDataNormal = []; + //this.tilesDataTextures = []; + + this.key = [0,0,0,0,0,0,0]; + + this.oldData = []; + + this.tileSize = 64;//64; + + + if(this.isMobile || this.isLow){ + this.pix = 1; + this.isWithTree = !this.isLow; + this.isWithEnv = false; + this.isWithNormal = false; + this.isWithLight = false; + this.isStandardMaterial = false; + this.tileSize = 32; + } + + // Terrain layer texture scale (16px * mu per tile). + // Default tiles are 64px (mu=4) or 32px (mu=2). + // On mobile we downgrade tiles to 16px (mu=1) to reduce GPU/memory load. + this.poolTileSize = this.tileSize; + if (this.isMobile) this.poolTileSize = 16; + this.mu = Math.max(1, Math.round(this.poolTileSize / 16)); + + this.f = [0,0,0]; + this.stats = [0,0]; + this.isWithStats = false; + + + this.dayTime = 0; + + this.tcolor = {r:10, g: 15, b: 80, a: 0.9}; + + this.snd_layzone = new Audio("./sound/layzone.mp3"); + + this.imgSrc = ['tiles'+this.tileSize+'.png','town.jpg','building.jpg','building_win.png','town_win.png' ]; + if( this.isWithNormal ) { + this.imgSrc.push( 'building_n.png', 'town_n.png', 'tiles'+this.tileSize+'_n.png' ); + } + this.imgSrcPlus = ['tiles'+this.tileSize+'_w.png','town_w.jpg','building_w.jpg']; + + let j = this.imgSrc.length; + while(j--) this.imgSrc[j] = this.mapPath + this.imgSrc[j]; + + j = this.imgSrcPlus.length; + while(j--) this.imgSrcPlus[j] = this.mapPath + this.imgSrcPlus[j]; + + this.winterMapLoaded = false; + + this.tmpGameData = null; + + + this.imgs = []; + this.num = 0; + + this.fullRedraw = false; + this._layerDrawQueue = null; + this._layerDrawRaf = 0; + this._treeBuildQueue = null; + this._treeBuildRaf = 0; + + this.isWithBackground = false; + this.isWithHeight = false; + + + // camera + this.ToRad = Math.PI / 180; + this.camera = null; + + + this.scene = null; + this.renderer = null; + this.timer = null; + + + this.miniTerrain = []; + this.terrainTxt = []; + this.terrainTxtN = []; + this.terrainTxtR = []; + + this.forceUpdate = { x:-1, y:-1 }; + + this.cam = { horizontal:90, vertical:60, distance:120 }; + const rect = this.container.getBoundingClientRect(); + this.vsize = { x:rect.width || window.innerWidth, y:rect.height || window.innerHeight, z:(rect.width || window.innerWidth)/(rect.height || window.innerHeight)}; + this.mouse = { ox:0, oy:0, h:0, v:0, mx:0, my:0, dx:0, dy:0, down:false, over:false, drag:false, click:false, move:true, dragView:false, button:0 }; + this.raypos = {x:-1, y:0, z:-1}; + + this.select = ''; + this.meshs = {}; + + this.mapSize = [128,128]; + this.nlayers = 64; + + //this.terrain = null; + + this.tool = null; + + this.currentTool = null; + + this.heightData = null; + + // textures + this.worldTexture = null; + this.centralTexture = null; + this.serviceTexture = null; + this.buildingTexture = null; + this.skyTexture = null; + + // material + this.townMaterial = null; + this.buildingMaterial = null; + + this.townCanvas = null; + this.buildingCanvas = null; + //this.groundCanvas = null; + this.skyCanvas = null; + this.skyCanvasBasic = null; + + this.buildingHeigth = null; + this.townMap = null; + this.buildingMap = null; + + // geometry + this.buildingGeo = null; + this.residentialGeo = null; + this.commercialGeo = null; + this.industrialGeo = null; + this.spriteGeo = null; + this.treeGeo = null; + this.houseGeo = null; + + + + this.treeMeshs = []; + this.treeLists = []; + this.tempTreeLayers = []; + this.treeValue = []; + + this.powerMeshs = []; + this.powerMaterial = null; + + this.buildingMeshs = []; + this.buildingLists = []; + this.tempBuildingLayers = []; + + this.townMeshs = []; + this.townLists = []; + this.temptownLayers = []; + + this.houseMeshs = []; + this.houseLists = []; + this.tempHouseLayers = []; + + + this.tempDestruct = []; + + this.currentLayer = 0; + + this.needResize = false; + + this.env = null; + + this.ease_p = -1; + this.onEase = null; + + + this.spriteLists = ['train', 'elico', 'plane', 'boat', 'monster', 'tornado', 'sparks']; + //this.spriteLists = []; + this.spriteMeshs = []; + this.spriteObjs = {}; + + this.terrainMaterials = []; + + + this.pool = new Pool( function() {this.done();}.bind(this), this.poolTileSize, this.isWithNormal, this.isWithRoughness, this.isPixelStyle, this.isWithEnv ); + + + } + + preIntro() { + + this.center.x = 19*0.5; + this.center.z = 19*0.5; + this.cam.distance = 30; + this.moveCamera(); + + this.addBorder(); + + const cgeo = new PlaneGeometry( 19, 19, 3, 3 ); + cgeo.rotateX( -Math.PI * 0.5 ); + + this.basePlane = new Mesh( cgeo, this.planeMat ); + this.basePlane.position.copy( this.center ); + this.scene.add( this.basePlane ); + + this.title = this.pool.title; + this.title.material = this.titleMat; + + + + this.title.position.copy( this.center ); + this.scene.add( this.title ); + + + // traffic map + this.traffic = new TrafficBase({ isStandard:this.isStandardMaterial }); + this.scene.add( this.traffic ); + + // add random building + this.buildings = new Group$1(); + let j = 16, m, px = 0, pz = 0; + while(j--){ + if(px === 4){ pz ++; px = 0; } + m = this.getRandomObject(); + m.position.set( (px*4)+3, 0.01,( pz*4)+3); + this.buildings.add(m); + px++; + } + this.scene.add( this.buildings ); + + this.plane = new Mesh( new PlaneGeometry( 18, 4.5, 5, 1 ), new MeshBasicMaterial( { transparent:true, alphaToCoverage: true } ) ); + this.plane.geometry.rotateX( -Math.PI * 0.4 ); + this.plane.position.copy(this.center); + this.plane.position.y = 0.8; + this.plane.position.z = 19+3.2; + this.plane.name = 'p1'; + this.scene.add( this.plane ); + + Tools.setStyle({ + fontFamily: 'sans-serif', + fontWeight:'bold', + fontShadow: 'none', + button : '#c1cbd7', + overoff : '#223143', + over : '#6c819a', + select : '#45586f', + text : '#223143', + textOver : '#FFFFFF', + border: '#6c819a', + borderSize: 3, + fontSize: 20, + }); + + this.ui = new Gui( { w:512, maxHeight:128, parent:null, isCanvas:true, close:false, transparent:true, plane:this.plane } ); + this.ui.add('grid', { values:['新建','读取'], selectable:false, bsize:[200, 40 ], spaces:[ 18,2 ], radius:40 }).onChange( this.openMap.bind(this) ); + + //let loaderButton = gg.c[3] + + //console.log(loaderButton) + //loaderButton.type = "file"; + // loaderButton.addEventListener( 'change', function(e){ this.fileSelect( e.target.files[0] ); }.bind(this), false ); + + this.ui.onDraw = function () { + + if( this.screen === null ){ + + this.screen = new Texture( this.canvas ); + //this.screen.minFilter = THREE.LinearFilter; + this.screen.encoding = sRGBEncoding; + this.plane.material.map = this.screen; + this.plane.material.needsUpdate = true; + + } + + this.screen.needsUpdate = true; + + }; + + this.isMenu = true; + + } + + fileSelect( e ){ + + hub.generate( true ); + this.inMapGenation = true; + + const file = e.target.files[0]; + const reader = new FileReader(); + let fname = file.name; + let type = fname.substring(fname.lastIndexOf('.')+1, fname.length ); + if( type !== 'json' ) return + reader.readAsText( file ); + + reader.onload = function (e) { + + + this.tmpGameData = e.target.result; + this.openMap( 'LOADDONE' ); + + }.bind(this); + + } + + openMap( type ){ + + if( type === '新建' ) type = 'NEW'; + if( type === '读取' ) type = 'LOAD'; + + if( this.isMobile && type==='LOAD' ){ + if( window.localStorage.getItem( 'micropolisJSGame' ) ) type = 'LOADDONE'; + else return + } + + if( type==='LOAD' ){ + + if(!this.fileInput){ + + this.fileInput = document.createElement("input"); + this.fileInput.type ='file'; + this.fileInput.style.display='none'; + this.fileInput.onchange = this.fileSelect.bind(this); + //fileInput.func=func + document.body.appendChild( this.fileInput ); + + + } + + let eventMouse = document.createEvent("MouseEvents"); + eventMouse.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + this.fileInput.dispatchEvent(eventMouse); + + return + } + + if( this.fileInput ) document.body.removeChild(this.fileInput); + + this.command = type; + + this.isMenu = false; + + this.ease_p = 0; + this.onEase = this.easing; + + this.scene.remove( this.title ); + this.scene.remove( this.plane ); + + this.traffic.clearAll(); + this.scene.remove( this.buildings ); + + this.ui.clear(); + + } + + endOpen() { + + if( this.command === 'LOADDONE' ){ + + //this.loadGame( e.target.result ) + + //this.paintMap() + + this.isMenu = false; + setTimeout( function(){ this.ui.dispose(); }.bind(this), 100 ); + + Main.loadGame( true ); + + + } + + if( this.command === 'NEW' ){ + + Main.newMap('NEW'); + + this.scene.add( this.plane ); + this.plane.position.copy(this.center); + this.plane.position.y = 4; + this.plane.position.z = 128-5; + this.isMenu = true; + + this.plane.scale.set(4,4,4); + + this.ui.add('grid', { values:['平面','高度'], selectable:false, bsize:[140, 30 ], spaces:[ 18,2 ], radius:30 }).onChange( function(label){ + const t = label === '高度' ? 'HIGH' : 'NEW'; + setTimeout( Main.newMap, 1000, t ); + } ); + this.ui.add('selector', { name:'', h:30, values:['简单', '普通', '困难'], radius:30, value:'普通', p:0 }).onChange( function(label){ + const map = { '简单':'LOW', '普通':'MEDIUM', '困难':'HARD' }; + Main.setDifficulty( map[label] || 'MEDIUM' ); + } ); + this.ui.add('button', { name:'开始游戏', h:40, radius:40, p:20, forceWidth: 300 }).onChange( this.startPlay.bind(this) ); + + } + + } + + startPlay(){ + + this.isMenu = false; + if(this.plane) this.scene.remove( this.plane ); + setTimeout( function(){ this.ui.dispose(); }.bind(this), 100 ); + + // + + Main.playMap(); + + } + + easing() { + + let v = this.ease_p; + if( v >= 1 ) { + this.onEase = null; + v = 1; + this.endOpen(); + } + + let p = 19*0.5; + this.center.x = this.center.z = p + ( (this.mapSize[0]*0.5) - p ) * v; + this.cam.distance = 40 + ( 150 - 40 ) * v; + this.moveCamera(); + + this.basePlane.position.copy( this.center ); + let s = 1 + ( (128/19) - 1 ) * v; + this.basePlane.scale.set( s, 1, s ); + + this.border.morphTargetInfluences[ 0 ] = 1 - v; + + this.ease_p = v + 0.01; + + } + + + + //----------------------------------- BORDER + + addBorder() { + + this.border = this.pool.border; + this.border_m = this.pool.border_min; + this.border_m.position.set( 0, 0, 0 ); + this.border.position.set( 0, 0, 0 ); + this.scene.add( this.border ); + + this.border.material = this.borderMat; + this.border.geometry.morphAttributes.position = [ this.border_m.geometry.attributes.position ]; + this.border.updateMorphTargets(); + this.border.morphTargetInfluences[ 0 ] = 1; + + } + + done() { + + + + //console.log( 'pool full loaded !!!' ) + + this.init(); + this.createMaterial(); + + Main.start(); + + } + + createMaterial() { + + this.colors = { + ground: new Color$1( this.pool.color.ground ).convertSRGBToLinear(), + metal: new Color$1( this.pool.color.metal ).convertSRGBToLinear(), + sky: new Color$1( this.pool.color.sky ).convertSRGBToLinear() + }; + + let i = this.nlayers; + let option = this.isStandardMaterial ? { roughness:1, metalness:1, envMapIntensity:1 } : {}; + let Type = this.isStandardMaterial ? MeshStandardMaterial : MeshBasicMaterial; + + while(i--){ + this.terrainMaterials[i] = new Type({ color:0xffffff, vertexColors:true, ...option }); + this.modifyShader( this.terrainMaterials[i] ); + } + + this.townMaterial = new Type( { map: this.pool.texture('town'), ...option } ); + this.modifyShader( this.townMaterial ); + this.buildingMaterial = new Type( { map: this.pool.texture('building'), ...option } ); + this.modifyShader( this.buildingMaterial ); + + this.titleMat = new Type( { map: this.pool.makeTitleTexture(), ...option } ); + if( this.isStandardMaterial ){ + this.titleMat.roughnessMap = this.pool.makeTitleTexture(1); + this.titleMat.emissiveMap = this.pool.makeTitleTexture(2); + this.titleMat.emissive = new Color$1( 0x666622 ); + } + this.modifyShader( this.titleMat ); + + if( this.isStandardMaterial ) option.roughness = 0; + this.waterMat = new Type({ color:0x645cab, transparent:true, opacity:0.8, ...option }); + + if( this.isStandardMaterial ) { option.roughness = 0.2; option.metalness = 0.8; } + //this.borderMat = new Type({ map:this.pool.texture('border'), alphaMap:this.pool.texture('border_a'), transparent:true, ...option }) + this.borderMat = new Type({ color:this.colors.metal , alphaMap:this.pool.texture('border_a'), transparent:true, ...option }); + + if( this.isStandardMaterial ) { option.roughness = 0.8; option.metalness = 0.2; } + this.planeMat = new Type({ color:this.colors.ground, depthWrite:false, ...option }); + + + if( this.isStandardMaterial ){ + + if( this.isWithRoughness ){ + this.townMaterial.roughnessMap = this.pool.texture('town_r'); + this.buildingMaterial.roughnessMap = this.pool.texture('building_r'); + } + + if( this.isWithNormal ){ + this.townMaterial.normalMap = this.pool.texture('town_n'); + this.buildingMaterial.normalMap = this.pool.texture('building_n'); + } + + } + + this.powerMaterial = new SpriteMaterial({ map:this.powerTexture(), transparent:true, depthTest: false, toneMapped:false }); + + this.preIntro(); + + } + + modifyShader( m ) { + + if( !this.isStandardMaterial ) return + + m.onBeforeCompile = function ( s ) { + s.fragmentShader = s.fragmentShader.replace( '#include ', ` + float metalnessFactor = metalness; + #ifdef USE_ROUGHNESSMAP + metalnessFactor *= 1.0 - texelRoughness.g; + #endif + `); + }; + + } + + + + + //----------------------------------- INIT + + init () { + + this.tmpPos = new Vector2( 0, 0 ); + + //if(this.isMobile) this.pix = 0.5; + //this.clock = new THREE.Clock(); + + this.scene = new Scene(); + + + this.camera = new PerspectiveCamera( 50, this.vsize.z, 0.1, 1000 ); + this.scene.add( this.camera ); + + this.rayVector = new Vector2( 0, 0 ); + this.raycaster = new Raycaster(); + + this.land = new Group$1(); + this.scene.add( this.land ); + + if( this.isWithFog ){ + + //this.fog = new THREE.Fog( 0xCC7F66, 1, 100 ); + this.fog = new Fog( 0x90a3b7, 1, 100 ); + this.scene.fog = this.fog; + + } + + this.center = new Vector3(); + this.center.x = this.mapSize[0]*0.5; + this.center.z = this.mapSize[1]*0.5; + this.moveCamera(); + + this.ease = new Vector3(); + this.easeRot = new Vector3(); + + + //this.renderer = new THREE.WebGLRenderer({ canvas:this.canvas, antialias:false }); + let renderer = new WebGLRenderer({ antialias:false }); + renderer.setSize( this.vsize.x, this.vsize.y ); + renderer.setPixelRatio( this.pix ); + //renderer.sortObjects = false; + //renderer.sortElements = false; + //renderer.autoClear = this.isWithBackground; + + renderer.outputEncoding = sRGBEncoding; + renderer.toneMapping = ACESFilmicToneMapping; + //renderer.physicallyCorrectLights = true + renderer.toneMappingExposure = 1.0; + + this.anisotropy = renderer.capabilities.getMaxAnisotropy(); + + //this.renderer.autoClear = false; + this.container.appendChild( renderer.domElement ); + + this.renderer = renderer; + + if( this.isWithEnv ){ + + let envmap = this.pool.env; + let pmremGenerator = new PMREMGenerator( renderer ); + this.env = pmremGenerator.fromEquirectangular( envmap ).texture; + this.scene.background = this.env; + this.scene.environment = this.env; + envmap.dispose(); + pmremGenerator.dispose(); + + } + + + if( this.isWithLight ); + + //let _this = this; + + + if( this.isWithBackground ){ + + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], ['#cc7f66','#A7DCFA', 'deepskyblue']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], ['#cc7f66','#A7DCFA', 'deepskyblue']]); + this.skyTexture = new Texture(this.skyCanvas); + this.skyTexture.encoding = sRGBEncoding; + this.skyTexture.needsUpdate = true; + this.back = new Mesh( new IcosahedronGeometry(300,1), new MeshBasicMaterial( { map:this.skyTexture, side:BackSide, depthWrite: false, fog:false } )); + this.scene.add( this.back ); + //this.renderer.autoClear = false; + + } else { + + this.renderer.setClearColor( this.pool.color.sky, 1 ); + + } + + + window.addEventListener( 'resize', function(e) { this.resize(); }.bind(this), false ); + + // disable context menu + document.addEventListener("contextmenu", function(e){ e.preventDefault(); }, false); + + document.addEventListener( 'mousewheel', this, false ); + + // Prefer pointer events on mobile (needed so UIL canvas UI gets mouse set before Roots handles pointerdown) + this.container.addEventListener( 'pointerdown', this, { capture:true, passive:false } ); + this.container.addEventListener( 'pointermove', this, { capture:true, passive:false } ); + this.container.addEventListener( 'pointerup', this, { capture:true, passive:false } ); + + this.container.addEventListener( 'mousemove', this, false ); + this.container.addEventListener( 'mousedown', this, false ); + //this.container.addEventListener( 'mouseup', this, false ); + //this.container.addEventListener( 'mouseout', this, false ); + + this.container.addEventListener( 'touchmove', this, false ); + this.container.addEventListener( 'touchstart', this, false ); + this.container.addEventListener( 'touchend', this, false ); + + document.addEventListener( 'mouseup', this, false ); + + this.initLayer(); + + + // new Tool + this.tool = new BuildTool(); + this.scene.add( this.tool ); + this.tool.visible = false; + + + + + + // active key (移动端也启用,支持虚拟方向键) + this.bindKeys(); + + + this.loop(0); + + } + + //----------------------------------- RENDER + + loop( time ) { + + requestAnimationFrame( this.loop.bind(this) ); + + //requestAnimationFrame( function(t){ this.loop(t) }.bind(this) ); + + if( this.onEase !== null ) this.onEase(); + + if( this.dragMode() ){ + this.dragCenterposition(); + }else { + this.updateKey(); + } + + this.render( time ); + + } + + + //----------------------------------- RENDER + + render( time ) { + + this.doResize(); + this.renderer.render( this.scene, this.camera ); + + } + + + //----------------------------------- EVENT + + handleEvent( e ) { + + switch( e.type ) { + case 'pointerup': this.onMouseUp( e ); break; + case 'pointerdown': this.onMouseDown( e ); break; + case 'pointermove': this.onMouseMove( e ); break; + case 'mouseup': case 'mouseout': case 'touchend':this.onMouseUp( e ); break; + case 'mousedown': case 'touchstart': this.onMouseDown( e ); break; + case 'mousemove': case 'touchmove': this.onMouseMove( e ); break; + case 'mousewheel': this.onMouseWheel( e ); break; + } + + } + + + //----------------------------------- RESIZE + + resize( e ) { this.needResize = true; } + + doResize() { + + if( !this.needResize ) return; + + const rect = this.container.getBoundingClientRect(); + const w = Math.max(1, Math.round(rect.width || window.innerWidth)); + const h = Math.max(1, Math.round(rect.height || window.innerHeight)); + this.vsize = { x:w, y:h, z:w/h }; + this.camera.aspect = this.vsize.z; + this.camera.updateProjectionMatrix(); + this.renderer.setSize( this.vsize.x, this.vsize.y ); + if( window.hub && window.hub.updateLayout ) window.hub.updateLayout(); + this.needResize = false; + + } + + + //----------------------------------- ZOOM + + startZoom() { + this.timer = setInterval( this.faddingZoom, 1000/60, this ); + } + + faddingZoom( t ) { + if(t.cam.distance>20){ + t.cam.distance--; + t.moveCamera(); + }else clearInterval(t.timer); + } + + + //----------------------------------- MATH + + clamp( value, min, max ) { + + if (value < min) return min; + if (value > max) return max; + return value; + + } + + randRange( min, max ) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + unwrapDegrees( r ) { + r = r % 360; + if (r > 180) r -= 360; + if (r < -180) r += 360; + return r; + } + + + //----------------------------------- LOAD IMAGES + + + + winterSwitch() { + /*if(!this.isWinter && this.winterMapLoaded) this.isWinter = true; + else this.isWinter = false; + + this.updateBackground(); + this.setTimeColors(this.dayTime);*/ + } + + textureSwitch( type ) { + /*switch(type){ + case 'normal': + this.townMaterial.map = this.townTexture; + this.buildingMaterial.map = this.buildingTexture; + break; + case 'white': + + break; + }*/ + + } + + setTimeColors( id ) { + + /*this.dayTime = id; + if(this.dayTime==1)this.tcolor = {r:100, g: 15, b: 80, a: 0.3}; + if(this.dayTime==2)this.tcolor = {r:10, g: 15, b: 80, a: 0.8}; + if(this.dayTime==3)this.tcolor = {r:10, g: 15, b: 80, a: 0.6}; + + this.tint(this.skyCanvas); + + if(!this.isWinter){ + //this.tint(this.groundCanvas, this.imgs[0]); + this.tint(this.townCanvas, this.imgs[1], this.imgs[4]); + this.tint(this.buildingCanvas, this.imgs[2], this.imgs[3]); + } else { + //this.tint(this.groundCanvas, this.imgs[5]); + this.tint(this.townCanvas, this.imgs[6], this.imgs[4]); + this.tint(this.buildingCanvas, this.imgs[7], this.imgs[3]); + } + + if(this.isWithFog){ + if(this.isIsland){ + if(this.isWinter){ + if(this.dayTime==0)this.fog.color.setHex(0xAFEEEE); + if(this.dayTime==1)this.fog.color.setHex(0x98ABBF); + if(this.dayTime==2)this.fog.color.setHex(0x2B3C70); + if(this.dayTime==3)this.fog.color.setHex(0x4C688F); + }else{ + if(this.dayTime==0)this.fog.color.setHex(0x6666e6); + if(this.dayTime==1)this.fog.color.setHex(0x654CB9); + if(this.dayTime==2)this.fog.color.setHex(0x1C206E); + if(this.dayTime==3)this.fog.color.setHex(0x2F328C); + } + } else { + if(this.isWinter){ + if(this.dayTime==0)this.fog.color.setHex(0xE6F0FF); + if(this.dayTime==1)this.fog.color.setHex(0xBFACCA); + if(this.dayTime==2)this.fog.color.setHex(0x363C73); + if(this.dayTime==3)this.fog.color.setHex(0x626996); + }else{ + if(this.dayTime==0)this.fog.color.setHex(0xE2946D); + if(this.dayTime==1)this.fog.color.setHex(0xBC6C64); + if(this.dayTime==2)this.fog.color.setHex(0x352A56); + if(this.dayTime==3)this.fog.color.setHex(0x60445C); + } + } + } + this.buildingTexture.needsUpdate = true; + this.townTexture.needsUpdate = true; + this.skyTexture.needsUpdate = true; + this.fullRedraw = true;*/ + + } + + //----------------------------------- 3D GEOMETRY + + getRandomObject( nn ) { + + nn = nn || this.randRange(0,2); + let geo; + switch(nn){ + + case 0: geo = this.pool.geo('residential', this.randRange(1,18) ); break; + case 1: geo = this.pool.geo('commercial', this.randRange(1,20) ); break; + case 2: geo = this.pool.geo('industrial', this.randRange(1,8) ); break; + + /*case 0: geo = this.buildingGeo[this.randRange(4,12)]; mat = this.townMaterial; break; + case 1: geo = this.residentialGeo[this.randRange(1, this.residentialGeo.length-1)]; mat = this.buildingMaterial; break; + case 2: geo = this.commercialGeo[this.randRange(1, this.commercialGeo.length-1)]; mat = this.buildingMaterial; break; + case 3: geo = this.industrialGeo[this.randRange(1, this.industrialGeo.length-1)]; mat = this.buildingMaterial; break; + case 4: geo = this.houseGeo[this.randRange(0, this.houseGeo.length-1)]; mat = this.buildingMaterial; break; + case 5: geo = this.spriteGeo[this.randRange(0, this.spriteGeo.length-1)]; mat = this.townMaterial; break; + case 6: + r = this.randRange(0,2); + n = 0; + if(r==1) n= 4; + if(r==2) n= 6; + geo = this.treeGeo[n]; + mat = this.townMaterial; + break;*/ + } + + // + + + let mesh = new Mesh( geo, this.buildingMaterial ); + //mesh.name = geo.name; + return mesh; + + } + + + + + //----------------------------------- MESH CONSTRUCTOR + + buildMeshLayer( layer, type = 'tree' ) { + + type = type; + + let id = 0; + + if( type === 'tree' ) id = 0; + if( type === 'town' ) id = 1; + if( type === 'house' ) id = 2; + if( type === 'building' ) id = 3; + + let list = this.M_list[id]; + let temp = this.M_temp[id]; + //let geom = this.M_geom[id]; + let mesh = this.M_mesh[id]; + let mats = this.M_mats[id]; + + let isIndexed = false, index, indexOffset = 0; + + let _g, v, nr, uv, t, i, j, lng, n, ar, k, decal = 0; + + if( this[list][layer] ){ + + i = this[list][layer].length; + + v = []; + uv = []; + nr = []; + index = []; + + while( i-- ){ + + ar = this[list][layer][i]; + + if( id === 3 ){ // building + + k = Base.R.length; + while(k--){ + if( ar[3] === Base.R[k] ){ + _g = this.pool.geo('residential', k); + // remove little house + if(k===0 && ar[5]===0){ this.buildingLists[layer][i][5] = 1; this.addBaseHouse( ar[0], ar[1], ar[2] ); } + else if(k>0 && ar[5]===1){ this.buildingLists[layer][i][5] = 0; this.removeBaseHouse( ar[0], ar[1], ar[2] ); } + } + + } + + k = Base.C.length; + while(k--){ if( ar[3] === Base.C[k] ) _g = this.pool.geo('commercial', k); } + + k = Base.I.length; + while(k--){ if( ar[3] === Base.I[k] ) _g = this.pool.geo('industrial', k); } + + } else if( id === 2 ){ // house + + k = Base.H.length; + while(k--){ if( ar[3] === Base.H[k] ) _g = this.pool.geo('house', k); } + + } else { // other + + _g = this.pool.geo( type, ar[3] ); + + } + + // add to temp array if geometry + + if( _g ){ + + // index + if( _g.index !== null ){ + + isIndexed = true; + lng = _g.index.count; + + for ( j = 0; j < lng; ++ j ) index.push( _g.index.getX( j ) + indexOffset ); + indexOffset += _g.attributes.position.count; + + } + + // position + t = _g.attributes.position.array; + lng = _g.attributes.position.count; + + for( j = 0; j < lng; ++ j ){ + n = j * 3; + v.push( t[n] + ar[0], t[n+1] + ar[1], t[n+2] + ar[2] + decal ); + } + + // normal + nr = [ ...nr, ..._g.attributes.normal.array ]; + // uv + uv = [ ...uv, ..._g.attributes.uv.array ]; + + } + + } + + // remove old mesh + + if( this[mesh][layer] ){ + + this[mesh][layer].geometry.dispose(); + this.scene.remove( this[mesh][layer] ); + + } + + if( v.length > 0 ){ + + // final geometry + + let g = new BufferGeometry(); + + if( isIndexed ) g.setIndex( index ); + g.setAttribute( 'position', new Float32BufferAttribute( v , 3 ) ); + g.setAttribute( 'normal', new Float32BufferAttribute( nr, 3 ) ); + g.setAttribute( 'uv', new Float32BufferAttribute( uv, 2 ) ); + + // final mesh + this[mesh][layer] = new Mesh( g, this[mats] ); + this.scene.add( this[mesh][layer] ); + + } + + // clear temp + this[temp][layer] = 0; + + } + + } + + //----------------------------------- TREE TEST + + addTree ( x, y = 0, z, v, layer ) { + + if( !this.isWithTree ) return; + // v 21 to 43 + if( !this.treeLists[layer] ) this.treeLists[layer]=[]; + this.treeLists[layer].push([x,y,z,v]); + + } + + populateTree (){ + + if(!this.isWithTree) return; + + if (this.isMobile || this.isLow) { + this.startTreeBuild(); + return; + } + + let l = this.nlayers; + while( l-- ) this.buildMeshLayer( l ); + + } + + cancelTreeBuild() { + if (this._treeBuildRaf) { + cancelAnimationFrame(this._treeBuildRaf); + this._treeBuildRaf = 0; + } + this._treeBuildQueue = null; + } + + startTreeBuild() { + this.cancelTreeBuild(); + if (!this.isWithTree) return; + + this._treeBuildQueue = []; + for (let i = this.nlayers - 1; i >= 0; i--) { + if (this.treeLists[i] && this.treeLists[i].length) this._treeBuildQueue.push(i); + } + this.processTreeBuild(); + } + + processTreeBuild() { + if (!this._treeBuildQueue || this._treeBuildQueue.length === 0) { + this.cancelTreeBuild(); + return; + } + + const start = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now(); + let processed = 0; + + while (this._treeBuildQueue.length) { + const layer = this._treeBuildQueue.shift(); + this.buildMeshLayer(layer); + processed++; + + const now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now(); + if (processed >= 1 && (now - start) > 10) break; + } + + this._treeBuildRaf = requestAnimationFrame(this.processTreeBuild.bind(this)); + } + + clearAllTrees () { + + this.cancelTreeBuild(); + if(!this.isWithTree) return; + let l = this.nlayers; + while(l--){ + if( this.treeMeshs[l] ){ + this.scene.remove( this.treeMeshs[l] ); + if(this.treeMeshs[l].geometry) this.treeMeshs[l].geometry.dispose(); + } + } + this.treeMeshs = []; + this.treeLists = []; + this.tempTreeLayers = []; + this.treeValue = []; + + } + + removeTreePack ( ar ) { + + if(!this.isWithTree) return; + //this.tempTreeLayers = []; + let i = ar.length; + while(i--){ + this.removeTree(ar[i][0], ar[i][1], true); + } + // rebuild layers + i = this.tempTreeLayers.length; + while(i--){ + if(this.tempTreeLayers[i] === 1){ this.rebuildTreeLayer(i); } + } + } + + removeTree ( x, z, m ) { + + let l = this.findLayer(x, z), ar; + if(this.treeLists[l]){ + let i = this.treeLists[l].length; + while(i--){ + ar = this.treeLists[l][i]; + if(ar[0] == x && ar[2]==z){ + this.treeLists[l].splice(i, 1); + if(!m){ + this.rebuildTreeLayer(l); + return; + } else { + // multy trees + this.tempTreeLayers[l] = 1; + } + } + } + } + } + + rebuildTreeLayer ( l ) { + + if(!this.isWithTree) return; + this.scene.remove(this.treeMeshs[l]); + this.treeMeshs[l].geometry.dispose(); + + this.buildMeshLayer(l); + + } + + + //------------------------------------ BACKGROUND MAP + + updateBackground () { + + let rootColors; + let fogColors; + if(this.isWithBackground ){ + if(this.isIsland){ + rootColors = '#6666e6'; + fogColors = 0x6666e6; + if(this.isWinter){ + rootColors = '#AFEEEE'; + fogColors = 0xAFEEEE; + } + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + if(this.isWithFog){ + this.fog.color.setHex(fogColors); + //this.fog.color.convertSRGBToLinear() + } + } + else { + rootColors = '#E2946D'; + fogColors = 0xE2946D; + if(this.isWinter){ + rootColors = '#E6F0FF'; + fogColors = 0xE6F0FF; + } + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + if(this.isWithFog){ + this.fog.color.setHex(fogColors); + //this.fog.color.convertSRGBToLinear() + } + } + this.skyTexture = new Texture(this.skyCanvas); + this.skyTexture.encoding = sRGBEncoding; + this.skyTexture.needsUpdate = true; + this.back.material.map = this.skyTexture; + } else { + if(this.isIsland) this.renderer.setClearColor( 0x6666e6, 1 ); + else this.renderer.setClearColor( 0xcc7f66, 1 ); + } + + if(this.isWithLight); + } + + + + //------------------------------------ TERRAIN MAP + + clearTerrain () { + + if( this.miniTerrain.length !== 0 ){ + let e = this.miniTerrain.length; + while(e--){ this.land.remove( this.miniTerrain[e] ); } + this.miniTerrain = []; + } + + } + + initTerrain() { + + this.center.x = this.mapSize[0]*0.5; + this.center.z = this.mapSize[1]*0.5; + + // create terrain if not existe + if( this.miniTerrain.length === 0 ){ + + let n = 0, i, j, k, geo, mesh; + + let divid = this.isWithHeight ? 16 : 1; + + let colors; + + for( i=0; i<8; i++){ + for( j=0; j<8; j++){ + + geo = new PlaneGeometry( 16, 16, divid, divid ); + geo.rotateX( -Math.PI * 0.5 ); + geo.translate( (8+j*16)-0.5, 0, (8+i*16)-0.5 ); + + k = geo.attributes.position.array.length; + colors = [];//new Float32Array( lng ); + while( k-- ) colors[k] = 1.0; + geo.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + mesh = new Mesh( geo, this.terrainMaterials[ n ] ); + + // if( this.isWithLight ) mesh = new THREE.Mesh( geo, new THREE.MeshStandardMaterial({ color:0xffffff, metalness:this.metalness, roughness:this.roughness, wireframe:this.wireframe, vertexColors:true }) ); + //else mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial({ color:0xffffff, vertexColors:true }) ); + + mesh.name = 'terrain_' + n; + this.land.add( mesh ); + this.miniTerrain[n] = mesh; + n++; + + } + } + } + + // update start map texture + + if( this.isWithHeight ){ + + this.applyHeight(); + //this.center.y = this.heightData[this.findId(this.center.x,this.center.z)]; + this.center.y = this.heightData[this.findHeightId(this.center.x,this.center.z)]; + + } else { + + this.center.y = 0; + + } + + + this.initTerrainTexture(); + + this.moveCamera(); + if( this.isWithBackground ) this.back.position.copy(this.center); + + + } + + initTerrainTexture () { + + let n = this.nlayers; + let texture, textureN, textureR; + let canvas = document.createElement('canvas'); + canvas.width = canvas.height = 256*this.mu; + + while( n-- ){ + + texture = new Texture( canvas ); + this.pool.filterTexture( texture, {} ); + + this.miniTerrain[n].material.map = texture; + this.terrainTxt[n] = texture; + + if( this.isWithNormal ){ + + textureN = new Texture( canvas ); + this.pool.filterTexture( textureN, { normal:true } ); + + this.miniTerrain[n].material.normalMap = textureN; + this.terrainTxtN[n] = textureN; + + } + + if( this.isWithRoughness ){ + + textureR = new Texture( canvas ); + this.pool.filterTexture( textureR, { normal:true } ); + + this.miniTerrain[n].material.roughnessMap = textureR; + //this.miniTerrain[n].material.metalnessMap = textureR; + this.terrainTxtR[n] = textureR; + + } + + } + + } + + //------------------------------------------HEIGHT + + generateHeight() { + + let d = this.mapSize[0]+1; + let size = d * d; + + this.heightData = new this.ARRAY_TYPE(size); + + let perlin = new ImprovedNoise(); + + let noise; + + let r = 1 / d; + let quality = 1 / 20; + let i = size, x, y; + + while( i-- ){ + + x = i % d; + y = Math.floor( i * r ); + noise = (perlin.noise( x * quality, 0, y * quality ) + 1)*0.5; + noise *= 2; + noise = Math.pow( noise, 3 ); + this.heightData[ i ] = noise; + + } + + //console.log(min, max) + this.isWithHeight = true; + + } + + clearHeight() { + + if( this.water ) this.scene.remove( this.water ); + this.heightData = null; + this.isWithHeight = false; + + } + + applyHeight() { + + let i, j, gr, gn, gc; + let lng = this.heightData.length; + let n, nn, geo, id, deep; + this.Gtmp = []; + + let big = new PlaneGeometry( 16*8, 16*8, 16*8, 16*8 ); + big.rotateX( -Math.PI * 0.5 ); + big.translate( this.center.x, 0, this.center.z ); + + gr = big.attributes.position.array; + + i = lng; + while(i--){ + n = i*3; + gr[n+1] = this.heightData[i]; + } + + big.attributes.position.needUpdate = true; + big.computeVertexNormals(); + let rn = big.attributes.normal.array; + + i = 64; + while (i--){ + + geo = this.miniTerrain[i].geometry; + + gr = geo.attributes.position.array; + gn = geo.attributes.normal.array; + gc = geo.attributes.color.array; + + j = gr.length/3; + + this.Gtmp[i] = new this.ARRAY_TYPE(j); + + while(j--){ + + n = j * 3; + //id = this.findHeightId( gr[n], gr[n+2] ) + id = this.findHeightId( gr[n]+0.5, gr[n+2]+0.5 ); + + gr[n+1] = this.Gtmp[i][j] = this.heightData[ id ]; + + nn = id*3; + gn[n] = rn[nn]; + gn[n+1] = rn[nn+1]; + gn[n+2] = rn[nn+2]; + + deep = 0.5 + this.clamp( this.heightData[ id ]/3, -1, 1) * 0.5; + + gc[n] = gc[n+1] = gc[n+2] = deep; + + if( gr[n+1]<0 ){ // under sea + gc[n] -= deep * 0.5; + gc[n+1] -= deep * 0.4; + } + + // border smooth + if(gr[n]===-0.5 || gr[n+2]===-0.5 || gr[n]===128-0.5 || gr[n+2]===128-0.5){ + if( gr[n+1]>0 ) gr[n+1] = this.heightData[ id ] = 0.25; + if( gr[n+1]<0 ) gr[n+1] = this.heightData[ id ] = 0; + } + + } + + + geo.attributes.position.needUpdate = true; + geo.attributes.normal.needUpdate = true; + geo.attributes.color.needUpdate = true; + //geo.computeVertexNormals(); + + } + + big.dispose(); + big = null; + + // add water mesh + + let waterGeo = new PlaneGeometry( 16*8, 16*8, 1, 1 ); + waterGeo.rotateX( -Math.PI * 0.5 ); + waterGeo.translate( this.center.x-0.5, 0, this.center.z-0.5 ); + + + this.water = new Mesh( waterGeo, this.waterMat ); + this.scene.add( this.water ); + + } + + makePlanar( ar, y ) { + + let layer, x, z, id; + let i = ar.length; + let tempHeightLayers = []; + + while( i-- ) { + x = ar[i][0]; + z = ar[i][1]; + id = this.findHeightId(x, z); + + this.heightData[ id ] = y; + + layer = this.findLayer(x, z); + + //v = this.findVertices( layer, [x, z] );//findVertices(layer, [x, z] ); + //this.Gtmp[layer][v] = y; + tempHeightLayers[layer] = 1; + } + + // rebuild layers + i = tempHeightLayers.length; + while ( i-- ) { + if(tempHeightLayers[i] === 1) this.updateVertices( i ); + } + + } + + updateVertices ( layer ){ + + let g = this.miniTerrain[ layer ].geometry; + //let ar = this.Gtmp[ layer ]; + + let v = g.attributes.position.array; + g.attributes.color.array; + let i = v.length/3, n, id; + + while(i--){ + + n = i*3; + id = this.findHeightId( v[n]+0.5, v[n+2]+0.5 ); + v[n+1] = this.heightData[ id ]; + + + /*v[n+1] = ar[i]; + c[n+1] = 0; + c[n+2] = 0;*/ + } + + g.attributes.position.needsUpdate = true; + //g.attributes.color.needsUpdate = true; + //g.computeBoundingSphere(); + //g.computeVertexNormals(); + + console.log('updated !!'); + + } + + + //------------------------------------------LAYER TOOL 8X8 + + findLayer( x, y ) { + let cx = Math.floor(x/16); + let cy = Math.floor(y/16); + return cx+(cy*8) + } + + findLayerPos( x, y, layer ) { + let cy = Math.floor(layer/8); + let cx = Math.floor(layer-(cy*8)); + let py = y-(16*cy); + let px = x-(16*cx); + return [px,py] + } + + findPosition( id ) { + let y = Math.floor(id/this.mapSize[1]); + let x = id-(y*this.mapSize[1]); + return [x,y] + } + + findId( x, y ) { + return x+(y*this.mapSize[1]) + } + + findVertices( layer, pos ){ + let cy = Math.floor(layer/8); + let cx = Math.floor(layer-(cy*8)); + let py = pos[1]-(16*cy); + let px = pos[0]-(16*cx); + return px + (py*16) + } + + findHeightId( x, y ) { + return x+(y*(this.mapSize[1]+1)) + } + + + //------------------------------------------RAY + + rayTest () { + + let intersects; + + this.raycaster.setFromCamera( this.rayVector, this.camera ); + + if( this.isMenu && !this.inMapGenation ){ + + this.ui.noMouse(); + + intersects = this.raycaster.intersectObjects( this.scene.children ); + + if ( intersects.length > 0 ){ + if( intersects[ 0 ].object.name === 'p1' ){ + this.ui.setMouse( intersects[ 0 ].uv ); + } + } + + } + + if ( this.land.children.length > 0 ) { + intersects = this.raycaster.intersectObjects( this.land.children ); + if ( intersects.length > 0 ) { + + this.raypos.x = Math.round( intersects[0].point.x ); + this.raypos.z = Math.round( intersects[0].point.z ); + + if( this.isWithHeight ) this.raypos.y = Math.round( intersects[0].point.y ); + else this.raypos.y = 0; + + if( this.currentTool ){ + + this.tool.position.set(this.raypos.x, this.raypos.y, this.raypos.z); + + //this.tool.position.set(this.raypos.x, this.raypos.y, this.raypos.z); + if(this.mouse.click || this.mouse.drag){ + Main.mapClick( this.currentTool.tool ); + + } + //if(this.mouse.click || this.currentTool.drag) mapClick(); + + this.mouse.click=false; + } + } else { + this.raypos.x = -1; + this.raypos.z = -1; + } + } + } + + + //------------------------------------------TOOL + + selectTool ( id ) { + + this.tool.visible = false; + this.raypos.x = -1; + this.raypos.z = -1; + + if( id === 0 || id === 18){ + this.currentTool = null; + this.mouse.dragView = false; + this.mouse.move = true; + } else if ( id === 16 ){ + this.currentTool = null; + this.mouse.move = false; + this.mouse.dragView = true; + } else { + this.currentTool = Base.toolSet[id]; + this.mouse.move = false; + this.mouse.dragView = false; + + this.tool.visible = true; + this.tool.color = this.currentTool.color; + this.tool.resize = this.currentTool.size; + + } + + Main.sendTool( Base.toolSet[id].tool ); + + } + + + //------------------------------------------BUILD + + build( x, y ) { + + if( this.currentTool.tool==='query' ) return; + + if( this.currentTool.build ){ + + let size = this.currentTool.size; + this.currentTool.sy; + + let py = 0; + + if( this.isWithHeight ) py = this.heightData[ this.findHeightId(x,y) ]; + + let zone; + if(size == 1 ) zone = [ [x, y] ]; + else if(size == 3) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1] ]; + else if(size == 4) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1], [x+2, y-1], [x+2, y] , [x+2, y+1] , [x+2, y+2], [x-1, y+2], [x, y+2], [x+1, y+2] ]; + else if(size == 6) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1], [x+2, y-1], [x+2, y] , [x+2, y+1] , [x+2, y+2], [x-1, y+2], [x, y+2], [x+1, y+2], + [x+3, y-1], [x+4, y-1], [x+3, y], [x+4, y], [x+3, y+1], [x+4, y+1], [x+3, y+2], [x+4, y+2], [x+3, y+3], [x+4, y+3], [x+3, y+4], [x+4, y+4], + [x-1, y+3], [x-1, y+4], [x, y+3], [x, y+4], [x+1, y+3], [x+1, y+4], [x+2, y+3], [x+2, y+4] + ]; + + this.removeTreePack(zone); + + if( this.isWithHeight && size !== 1 ) this.makePlanar( zone, py ); + + let v = this.currentTool.geo; + + // standard building + if(v<4 && v!==0){ + this.addBaseBuilding(x, py, y, v, zone); + this.snd_layzone.play(); + } + // town building + if(v==8 || v==9 || v==4 || v==5 || v==7 || v==10 || v==11 || v==12){ + this.addBaseTown(x,py,y,v,zone); + this.snd_layzone.play(); + } + + } else { + this.removeTree(x,y); + if( this.isWithHeight ){ + let py = this.heightData[this.findHeightId(x,y)]; + this.makePlanar( [[x,y]], py ); + } + if( this.currentTool.tool === 'bulldozer' ){ + this.forceUpdate.x = x; + this.forceUpdate.y = y; + this.testDestruct(x,y); + } + } + } + + + + //--------------------------------------------------TEST DESTRUCT + + testLayer( x, y ) { + + let l = this.findLayer(x,y); + let list = [l]; + let pos = this.findLayerPos(x,y,l); + let a = 0,b = 0; + + if(pos[0]<4) a=1; + else if(pos[0]>13) a=2; + + if(pos[1]<4) b=1; + else if(pos[1]>13) b=2; + + if(b==1) if(l-8>-1) list.push(l-8); + if(b==2) if(l+8<64) list.push(l+8); + + if(a==1) if(l-1>-1) list.push(l-1); + if(a==2) if(l+1<64) list.push(l+1); + + if(a==1 && b==1) if(l-9>-1) list.push(l-9); + if(a==2 && b==2) if(l+9<64) list.push(l+9); + + if(a==1 && b==2) if(l+7<64) list.push(l+7); + if(a==2 && b==1) if(l-7>-1) list.push(l-7); + + //console.log(list); + return list; + } + + testDestruct( x, y ){ + + let i, j, ar, ar2, l; + let list = this.testLayer(x,y); + + for(let h= 0; h87)vertical=87; + if(vertical<1)vertical=1; + let phi = vertical*this.ToRad ; + let theta = horizontal*this.ToRad; + p.x = (distance * Math.sin(phi) * Math.cos(theta)) + origine.x; + p.z = (distance * Math.sin(phi) * Math.sin(theta)) + origine.z; + p.y = (distance * Math.cos(phi)) + origine.y; + return p; + + } + + moveCamera () { + + this.camera.position.copy(this.Orbit(this.center, this.cam.horizontal, this.cam.vertical, this.cam.distance)); + this.camera.lookAt(this.center); + + if(this.isWithFog){ + this.fog.far=this.cam.distance*4; + if(this.fog.far<20)this.fog.far=20; + } + + } + + dragCenterposition (){ + + if ( this.ease.x == 0 && this.ease.z == 0 ) return; + this.easeRot.y = this.cam.horizontal*this.ToRad; + this.unwrapDegrees(Math.round(this.cam.horizontal)); + this.easeRot.x = Math.sin(this.easeRot.y) * this.ease.x + Math.cos(this.easeRot.y) * this.ease.z; + this.easeRot.z = Math.cos(this.easeRot.y) * this.ease.x - Math.sin(this.easeRot.y) * this.ease.z; + + this.center.x += this.easeRot.x; + this.center.z -= this.easeRot.z; + + if(this.center.x<0) this.center.x = 0; + if(this.center.x>128) this.center.x = 128; + if(this.center.z<0) this.center.z = 0; + if(this.center.z>128) this.center.z = 128; + + this.moveCamera(); + + } + + onMouseDown (e) { + + e.preventDefault(); + const rect = this.renderer && this.renderer.domElement ? this.renderer.domElement.getBoundingClientRect() : this.container.getBoundingClientRect(); + let clientX, clientY; + if (e.touches && e.touches[0]) { + clientX = e.touches[0].clientX; + clientY = e.touches[0].clientY; + } else { + clientX = e.clientX; + clientY = e.clientY; + } + let px = clientX - rect.left; + let py = clientY - rect.top; + if (!e.touches) { + // 0: default 1: left 2: middle 3: right + this.mouse.button = e.which || e.button || 0; + } + + //if(this.mouse.button===1 && this.currentTool) this.mouse.move = true; + + this.mouse.ox = px; + this.mouse.oy = py; + this.rayVector.x = ( px / rect.width ) * 2 - 1; + this.rayVector.y = - ( py / rect.height ) * 2 + 1; + this.mouse.h = this.cam.horizontal; + this.mouse.v = this.cam.vertical; + this.mouse.down = true; + // Ensure menu UI can be clicked on mobile: setMouse(uv) must be available before UIL Roots handles pointerdown. + if ( this.isMenu ) this.rayTest(); + + if(this.currentTool && this.mouse.button<2){// only for tool + this.mouse.click = true; + if(this.currentTool.drag){ this.mouse.drag = true;} + if (e.touches || e.pointerType === 'touch') this.rayTest(); + + } + + } + + onMouseUp (e) { + e.preventDefault(); + this.mouse.button = 0; + this.mouse.down = false; + this.mouse.drag = false; + if(this.currentTool==null)this.mouse.move = true; + this.ease.x = 0; + this.ease.z = 0; + document.body.style.cursor = 'auto'; + } + + onMouseMove (e) { + e.preventDefault(); + const rect = this.renderer && this.renderer.domElement ? this.renderer.domElement.getBoundingClientRect() : this.container.getBoundingClientRect(); + let clientX, clientY; + if (e.touches && e.touches[0]) { + clientX = e.touches[0].clientX; + clientY = e.touches[0].clientY; + } else { + clientX = e.clientX; + clientY = e.clientY; + } + let px = clientX - rect.left; + let py = clientY - rect.top; + + if (this.mouse.down) { + if(this.mouse.move || this.mouse.button===2){ + this.mouse.dragView = false; + document.body.style.cursor = 'crosshair'; + this.cam.horizontal = ((px - this.mouse.ox) * 0.3) + this.mouse.h; + this.cam.vertical = (-(py -this. mouse.oy) * 0.3) + this.mouse.v; + this.moveCamera(); + } + if(this.mouse.dragView || this.mouse.button===3){ + document.body.style.cursor = 'move'; + this.mouse.move = false; + this.ease.x = (px - this.mouse.ox)/1000; + this.ease.z = (py - this. mouse.oy)/1000; + } + } + + if(this.currentTool !== null || this.isMenu ){ + this.rayVector.x = ( px / rect.width ) * 2 - 1; + this.rayVector.y = - ( py / rect.height ) * 2 + 1; + this.rayTest(); + } + } + + onMouseWheel (e) { + //e.preventDefault(); + let delta = 0; + if(e.wheelDelta){delta=e.wheelDelta*-1;} + else if(e.detail){delta=e.detail*20;} + this.cam.distance+=(delta/80); + if(this.cam.distance<1)this.cam.distance = 1; + if(this.cam.distance>150)this.cam.distance = 150; + this.moveCamera(); + + } + + + // ----------------------- + // GROUND TEXTURE + // ----------------------- + + paintMap ( mapSize, island = false, withHeight = false ) { + + this.isIsland = island; + + if( mapSize ) this.mapSize = mapSize; + + if( this.basePlane ) this.scene.remove( this.basePlane ); + + //console.log(tilesData.length) + this.cancelLayerDraw(); + this.clearTerrain(); + this.clearAllTrees(); + this.clearHeight(); + + if( withHeight ) this.generateHeight(); + + //this.initTerrain(); + + let y = this.mapSize[1]; + let x, v, n = tilesData.length, cy, cx, layer, r, ty = 0, id; + + while( y-- ){ + x = this.mapSize[0]; + while( x-- ){ + + // find layer + cy = Math.floor(y/16); + cx = Math.floor(x/16); + layer = cx+(cy*8); + + n--; + v = tilesData[n]; + + if( this.isWithHeight ){ + + if( v > 1 && v < 5 ){ // water + id = this.findHeightId(x, y); + this.heightData[ id ] *= -1; + if( x === this.mapSize[0]-1 ) this.heightData[ id+1 ] *= -1; + if( y === this.mapSize[1]-1 ) this.heightData[ id+this.mapSize[1] ] *= -1; + tilesData[n] = 0; + } + if( v > 4 && v < 21 ){ // water border + this.heightData[ this.findHeightId(x, y) ] *= 0.5; + tilesData[n] = 0; + } + } + if( v > 20 && v < 30 ){// tree 44 + + if( this.isWithHeight ) ty = this.heightData[ this.findHeightId(x, y) ]-0.1; + + r = v-21; + if(r===8) r = Math.floor(Math.random()*7);//r=8// big middle tree + + if( withHeight && ty > 0.5 ){ + if( x===0 || y===0 || x===this.mapSize[0]-1 || y===this.mapSize[0]-1) ty = 0.5; + } + + + + this.addTree( x, ty, y, r, layer ); + this.treeValue[n] = v; + + } + + } + } + + this.updateBackground(); + + this.initTerrain(); + + if (this.isMobile || this.isLow) { + if (typeof hub !== 'undefined' && hub.generate) hub.generate(true); + this.startLayerDraw(true); + return; + } + + let i = this.nlayers; + while(i--){ + this.drawLayer( i, true ); + } + this.finishPaintMap(); + + } + + cancelLayerDraw() { + if (this._layerDrawRaf) { + cancelAnimationFrame(this._layerDrawRaf); + this._layerDrawRaf = 0; + } + this._layerDrawQueue = null; + } + + startLayerDraw(full) { + this.cancelLayerDraw(); + this._layerDrawQueue = []; + for (let i = this.nlayers - 1; i >= 0; i--) this._layerDrawQueue.push(i); + this._layerDrawFull = !!full; + this.processLayerDraw(); + } + + processLayerDraw() { + if (!this._layerDrawQueue || this._layerDrawQueue.length === 0) { + this.finishPaintMap(); + return; + } + + const start = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now(); + let processed = 0; + + while (this._layerDrawQueue.length) { + const layer = this._layerDrawQueue.shift(); + this.drawLayer(layer, this._layerDrawFull); + processed++; + + const now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now(); + if (processed >= 1 && (now - start) > 10) break; + } + + this._layerDrawRaf = requestAnimationFrame(this.processLayerDraw.bind(this)); + } + + finishPaintMap() { + this.populateTree(); + + if(this.fullRedraw){ + this.fullRedraw = false; + } + + this.inMapGenation = false; + if (typeof hub !== 'undefined' && hub.generate) hub.generate(false); + } + + initLayer() { + + let i = this.nlayers; + while(i--){ + this.tempHouseLayers[i] = 0; + this.tempBuildingLayers[i] = 0; + } + + } + + updateLayer() { + + let i = this.nlayers; + + while(i--){ + + if( layerData[i] === 1 ) this.drawLayer( i ); + if(this.tempHouseLayers[i] === 1){ this.rebuildHouseLayer(i); this.tempHouseLayers[i] = 0; } + if(this.tempBuildingLayers[i] === 1){ this.rebuildBuildingLayer(i); this.tempBuildingLayers[i] = 0; } + + } + + } + + drawLayer ( layer, full ){ + + let y = 16, x, v, n, ar, i, vx, vy, g; + let ly = Math.floor(layer/8); + let lx = Math.floor(layer-(ly*8)); + + let pix = 32; + let mid = pix * 0.5; + + while( y-- ){ + + x = 16; + while(x--){ + + vx = (lx*16)+x; + vy = (ly*16)+y; + + n = vx+(vy*this.mapSize[1]); + v = tilesData[n]; + + g = v < 240 ? v : 0; + + if( !full && v === this.oldData[n] ) continue; + this.oldData[n] = v; + + if( g < 240 ){ + + this.tmpPos.x = x*mid*this.mu; + this.tmpPos.y = (240 - y*mid)*this.mu; + + // apply tile change + this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('texture', g), this.terrainTxt[layer] ); + if( this.isWithNormal ) this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('normal', g), this.terrainTxtN[layer] ); + if( this.isWithRoughness ) this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('roughness', g), this.terrainTxtR[layer] ); + + } + + if( v > 239 ){ + + // MESH BUILD + if((v>248 && v<261) || v==0){ + if(this.houseLists[layer]){ + i = this.houseLists[layer].length; + while(i--){ + ar = this.houseLists[layer][i]; + if( ar[0] === vx && ar[2] === vy ){ + if( ar[3] !== v ){ + this.houseLists[layer][i][3] = v; + this.tempHouseLayers[layer] = 1; + } + } + } + } + } else { + if(this.buildingLists[layer]){ + i = this.buildingLists[layer].length; + while(i--){ + ar = this.buildingLists[layer][i]; + if( ar[0] === vx && ar[2] === vy ){ + if( ar[3] !== v ){ + this.buildingLists[layer][i][3] = v; + this.tempBuildingLayers[layer] = 1; + } + } + } + } + } + + } + + + } + } + } + + + // ----------------------- + // SPRITE + // ----------------------- + + moveSprite () { + + if(!spriteData) return + + let i = spriteData.length; + let pos = new Vector3(); + let v, frame, c; + + while(i--){ + c = spriteData[i]; + frame = c[1]; + v = c[0]; + pos.x = Math.round((c[2]-8)/16); + pos.z = Math.round((c[3]-8)/16); + pos.y = 0; + + + if( this.isWithHeight ) pos.y = this.heightData[ this.findHeightId(pos.x,pos.z) ]; + + + if( c[0] == 2) pos.y += 5; + if( c[0] == 3){ + if(frame==11)pos.y += 0; + else if(frame==10)pos.y += 1; + else if (frame==9)pos.y += 3; + else pos.y += 6; + } + + //if(this.spriteMeshs[i] == null) this.addSprite( i, c[0], pos ); + //this.spriteMeshs[i].position.lerp(pos, 0.6); + //this.spriteMeshs[i].rotation.y = this.rotationSprite(c[0], frame); + + /*if(this.spriteObjs[this.spriteLists[v]] == null) this.spriteObjs[this.spriteLists[v]] = this.addSprite( v, pos ); + this.spriteObjs[this.spriteLists[v]].position.lerp(pos, 0.6); + this.spriteObjs[this.spriteLists[v]].rotation.y = this.rotationSprite(c[0], frame);*/ + + if(this.spriteObjs[this.spriteLists[v]] == null) this.spriteObjs[this.spriteLists[v]] = this.addSprite( v, pos ); + + // underwater train + if(v===1 && frame===5)this.spriteObjs[this.spriteLists[v]].visible = false; + else this.spriteObjs[this.spriteLists[v]].visible = true; + + this.spriteObjs[this.spriteLists[v]].position.lerp(pos, 0.6); + this.spriteObjs[this.spriteLists[v]].rotation.y = this.rotationSprite(c[0], frame); + } + } + + rotationSprite ( v, f ) { + + let r = 0; + if(v===1){// train + if(f===1) r = 0; + else if(f===2) r = 90*this.ToRad; + else if(f===3) r = 45*this.ToRad; + else if(f===4) r = -45*this.ToRad; + }else if(v===2 || v===3){// elico plane + if(f===1) r = 0; + else if(f===2) r = -45*this.ToRad; + else if(f===3) r = -90*this.ToRad; + else if(f===4) r = -135*this.ToRad; + else if(f===5) r = -180*this.ToRad; + else if(f===6) r = -225*this.ToRad; + else if(f===7) r = -270*this.ToRad; + else if(f===8) r = -315*this.ToRad; + + else if(f===9) r = -90*this.ToRad; + else if(f===10) r = -90*this.ToRad; + else if(f===11) r = -90*this.ToRad; + } + return r + + } + + addSprite ( v, p ) { + + let m; + if(v===1){// train + m = new Mesh(this.pool.geo('sprite',0), this.townMaterial ); + //m.scale.set(1, 1, -1 ) + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + //this.spriteObjs[this.spriteLists[v]] = m; + }else if(v===2){// elico + m = new Mesh(this.pool.geo('sprite',1), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + }else if(v===3){// plane + m = new Mesh(this.pool.geo('sprite',2), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + } else { + m = new Mesh(new BoxGeometry(1,1,1), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + } + return m; + + //this.spriteObjs[this.spriteLists[v]] = m; + } + + + + // ----------------------- + // POWER SPRITE + // ----------------------- + + showPower (){ + + //if( !powerData ) return + + let i = powerData.length; + while(i--){ + if(powerData[i]===0) continue;//{ if( this.powerMeshs[i] !== null ) this.removePowerMesh(i); } + else if(powerData[i]===2){ if(this.powerMeshs[i] == null) this.addPowerMesh(i, this.findPosition(i)); } + else if(powerData[i]===1){ if(this.powerMeshs[i] !== null) this.removePowerMesh(i); } + } + + } + + addPowerMesh ( i, ar ) { + + let py = 0; + + if( this.isWithHeight ) py = this.heightData[ this.findHeightId(ar[0],ar[1])]; + + let m = new Sprite( this.powerMaterial ); + //m.scale.set( 2, 2, 1 ); + m.position.set(ar[0], py+1, ar[1]); + this.scene.add(m); + this.powerMeshs[i] = m; + } + + removePowerMesh ( i ) { + this.scene.remove(this.powerMeshs[i]); + this.powerMeshs[i] = null; + } + + + + // ----------------------- + // AUTO TEXTURE + // ----------------------- + + powerTexture () { + + let c = document.createElement("canvas"); + let ctx = c.getContext("2d"); + c.width = c.height = 64; + let grd = ctx.createLinearGradient(0,0,64,64); + grd.addColorStop(0.3,"yellow"); + grd.addColorStop(1,"red"); + ctx.beginPath(); + ctx.moveTo(44,0); + ctx.lineTo(10,34); + ctx.lineTo(34,34); + ctx.lineTo(20,64); + ctx.lineTo(54,30); + ctx.lineTo(30,30); + ctx.lineTo(44,0); + ctx.closePath(); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.fillStyle = grd; + ctx.fill(); + let texture = new Texture(c); + texture.needsUpdate = true; + return texture; + + } + + gradTexture (color) { + let c = document.createElement("canvas"); + let ctx = c.getContext("2d"); + c.width = 16; c.height = 256; + let gradient = ctx.createLinearGradient(0,0,0,256); + let i = color[0].length; + while(i--){ gradient.addColorStop(color[0][i],color[1][i]); } + ctx.fillStyle = gradient; + ctx.fillRect(0,0,16,256); + //this.tint(c); + //let texture = new THREE.Texture(c); + //texture.needsUpdate = true; + return c; + } + + tint (canvas, image, supImage) { + let data, i, n; + let pixels = canvas.width*canvas.height; + let ctx = canvas.getContext('2d'); + + // draw windows + let topData = null; + let newImg = null; + if(supImage && this.dayTime!==0 && this.dayTime!==1){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(supImage, 0, 0); + topData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = topData.data; + i = pixels; + while(i--){ + n = i<<2; + if(data[n+3] !== 0){ + if(data[n+0]==0 && data[n+1]==0 && data[n+2]==0){// black + data[n+3]=60; + } + if(data[n+1]==0){ + //if(data[n+0]==255 && data[n+1]==0 && data[n+2]==0){// red + if(this.dayTime==3) data[n+1]=255; + if(this.dayTime==2) {data[n+0]=0; data[n+3]=60;} + } + + } + } + ctx.putImageData(topData, 0, 0); + newImg = document.createElement('img'); + newImg.src = canvas.toDataURL("image/png"); + } + + if(image){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(image, 0, 0); + } else { + ctx.drawImage(this.skyCanvasBasic, 0, 0); + } + + if(this.dayTime!==0){ + let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = imageData.data; + i = pixels; + let c = this.tcolor; + while(i--){ + n = i<<2;//i*4; + data[n+0] = data[n+0] * (1-c.a) + (c.r*c.a); + data[n+1] = data[n+1] * (1-c.a) + (c.g*c.a); + data[n+2] = data[n+2] * (1-c.a) + (c.b*c.a); + } + ctx.putImageData(imageData, 0, 0); + if(newImg){ + ctx.drawImage(newImg, 0, 0); + } + } + } + + // ----------------------- + // KEYBOARD + // ----------------------- + + updateKey (){ + + // 移除移动端限制,支持虚拟方向键 + + let f = 0.3, d = false; + + if(this.key[0] == 1 || this.key[1] == 1 ){ + if(this.key[0] == 1)this.ease.z = -f; + if(this.key[1] == 1)this.ease.z = f; + d = true; + } + else this.ease.z = 0; + + if(this.key[2] == 1 || this.key[3] == 1 ){ + if(this.key[2] == 1)this.ease.x = -f; + if(this.key[3] == 1)this.ease.x = f; + d = true; + } + else this.ease.x = 0; + if( d ) this.dragCenterposition(); + + } + + bindKeys (){ + + let _this = this; + + document.onkeydown = function(e) { + e = e || window.event; + switch ( e.keyCode ) { + case 38: case 87: case 90: _this.key[0] = 1; break; // up, W, Z + case 40: case 83: _this.key[1] = 1; break; // down, S + case 37: case 65: case 81: _this.key[2] = 1; break; // left, A, Q + case 39: case 68: _this.key[3] = 1; break; // right, D + //case 17: case 67: _this.key[4] = 1; break; // ctrl, C + //case 69: _this.key[5] = 1; break; // E + //case 32: _this.key[6] = 1; break; // space + } + }; + document.onkeyup = function(e) { + e = e || window.event; + switch( e.keyCode ) { + case 38: case 87: case 90: _this.key[0] = 0; break; // up, W, Z + case 40: case 83: _this.key[1] = 0; break; // down, S + case 37: case 65: case 81: _this.key[2] = 0; break; // left, A, Q + case 39: case 68: _this.key[3] = 0; break; // right, D + //case 17: case 67: _this.key[4] = 0; break; // ctrl, C + //case 69: _this.key[5] = 0; break; // E + //case 32: _this.key[6] = 0; break; // space + } + }; + self.focus(); + + } + + +} + +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ +var saveAs = function(e) { + + if (typeof e === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { + return + } + var t = e.document, + n = function() { + return e.URL || e.webkitURL || e + }, + r = t.createElementNS("http://www.w3.org/1999/xhtml", "a"), + o = "download" in r, + a = function(e) { + var t = new MouseEvent("click"); + e.dispatchEvent(t); + }, + i = /constructor/i.test(e.HTMLElement) || e.safari, + f = /CriOS\/[\d]+/.test(navigator.userAgent), + u = function(t) { + (e.setImmediate || e.setTimeout)(function() { + throw t + }, 0); + }, + s = "application/octet-stream", + d = 1e3 * 40, + c = function(e) { + var t = function() { + if (typeof e === "string") { + n().revokeObjectURL(e); + } else { + e.remove(); + } + }; + setTimeout(t, d); + }, + l = function(e, t, n) { + t = [].concat(t); + var r = t.length; + while (r--) { + var o = e["on" + t[r]]; + if (typeof o === "function") { + try { + o.call(e, n || e); + } catch (a) { + u(a); + } + } + } + }, + p = function(e) { + if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)) { + return new Blob([String.fromCharCode(65279), e], { + type: e.type + }) + } + return e + }, + v = function(t, u, d) { + if (!d) { + t = p(t); + } + var v = this, + w = t.type, + m = w === s, + y, h = function() { + l(v, "writestart progress write writeend".split(" ")); + }, + S = function() { + if ((f || m && i) && e.FileReader) { + var r = new FileReader; + r.onloadend = function() { + var t = f ? r.result : r.result.replace(/^data:[^;]*;/, "data:attachment/file;"); + var n = e.open(t, "_blank"); + if (!n) e.location.href = t; + t = undefined; + v.readyState = v.DONE; + h(); + }; + r.readAsDataURL(t); + v.readyState = v.INIT; + return + } + if (!y) { + y = n().createObjectURL(t); + } + if (m) { + e.location.href = y; + } else { + var o = e.open(y, "_blank"); + if (!o) { + e.location.href = y; + } + } + v.readyState = v.DONE; + h(); + c(y); + }; + v.readyState = v.INIT; + if (o) { + y = n().createObjectURL(t); + setTimeout(function() { + r.href = y; + r.download = u; + a(r); + h(); + c(y); + v.readyState = v.DONE; + }); + return + } + S(); + }, + w = v.prototype, + m = function(e, t, n) { + return new v(e, t || e.name || "download", n) + }; + + if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { + return function(e, t, n) { + t = t || e.name || "download"; + if (!n) { e = p(e); } + return navigator.msSaveOrOpenBlob(e, t) + } + } + + w.abort = function() {}; + w.readyState = w.INIT = 0; + w.WRITING = 1; + w.DONE = 2; + w.error = w.onwritestart = w.onprogress = w.onwrite = w.onabort = w.onerror = w.onwriteend = null; + return m + +}(typeof self !== "undefined" && self || typeof window !== "undefined" && window ); + +document.getElementById('debug'); +const simulation_timestep = 30; + +window.tilesData = null; +window.spriteData = null; +window.gameData = null; +window.powerData = null; +window.layerData = []; + +window.isMobile = false; + +window.trans = false; +window.newup = false; +window.powerup = false; + +//var storage; +window.directMessage = null; +window.isWorker = true; + +window.withHeight = false; + +class Main { + + static init ( DirectMessage ){ + + if( DirectMessage !== undefined ){ + + directMessage = DirectMessage; + isWorker = false; + + } + + isMobile = testMobile(); + + //storage = window.localStorage; + + this.initWorker(); + window.hub = new Hub(); + window.view3d = new View( isMobile ); + + } + + // viex3d + + static initWorker (){ + + if( isWorker ){ + + window.cityWorker = new Worker( './build/citygame.min.js' ); + + //window.cityWorker = new Worker( 'js/worker.city.js' ); + cityWorker.postMessage = cityWorker.webkitPostMessage || cityWorker.postMessage; + //post({tell:"INIT", url:document.location.href.replace(/\/[^/]*$/,"/") + "build/city.3d.js", timestep:simulation_timestep }); + cityWorker.onmessage = message; + + post({ tell:"INIT", timestep:simulation_timestep }); + + } else { + + post({ tell:"INIT", timestep:simulation_timestep, returnMessage:message }); + + } + + } + + static start (){ + + hub.start(); + + //hub.message('Generating world...') + //post({ tell:"NEWMAP"}) + + } + + static sendTool( name ) { + post({tell:"TOOL", name:name}); + } + + static destroy( x, y ) { + + // TODO SOUND EXPLOSION + + post({tell:"MAPCLICK", x:x, y:y, single:true }); + } + + static mapClick( tool ) { + var p = view3d.raypos; + + if( p.x<0 && p.z<0 ) return + + //if( tool === 'bulldozer' ) view3d.testDestruct( p.x, p.y ) + post({tell:"MAPCLICK", x:p.x, y:p.z }); + } + + // HUB + + static selectTool( id ) { + view3d.selectTool( id ); + } + + static setTimeColors( id ) { + view3d.setTimeColors(id); + } + + static newMap( t ) { + + if( view3d.inMapGenation ) return; + + hub.generate( true ); + withHeight = t!=='NEW'; + view3d.inMapGenation = true; + setTimeout( post, 1000, {tell:"NEWMAP"}); + + } + + static playMap() { + + hub.initGameHub(); + view3d.startZoom(); + post({tell:"PLAYMAP"}); + + } + + static selectTool( id ) { + view3d.selectTool(id); + } + + static setDifficulty( t ) { + + //console.log( t ) + let n = 0; + if(t === 'MEDIUM') n = 1; + if(t === 'HARD') n = 2; + post({tell:"DIFFICULTY", n:n }); + } + + static setSpeed( n ) { + post({tell:"SPEED", n:n }); + } + + static getBudjet() { + post({ tell:"BUDGET" }); + } + + static setBudjet( budgetData ) { + post({ tell:"NEWBUDGET", budgetData:budgetData }); + } + + static getEval() { + post({ tell:"EVAL" }); + } + + static setDisaster(disaster){ + console.log(disaster); + post({ tell:"DISASTER", disaster:disaster }); + } + + static setOverlays( type ) { + //cityWorker.postMessage({ tell:"OVERLAYS", type:type }); + } + + static saveGame() { + var saveCity = []; + view3d.saveCityBuild(saveCity); + saveCity = JSON.stringify(saveCity); + // var cityData = view3d.saveCityBuild(); + post({ tell:"SAVEGAME", saveCity:saveCity }); + } + + static loadGame( atStart ) { + var isStart = atStart || false; + if( isStart ){ + hub.generate( true ); + view3d.inMapGenation = true; + } + post({ tell:"LOADGAME", isStart:isStart }); + } + + static newGameMap() { + console.log("new map"); + + //saveTextAsFile('test', 'game is saved'); + } + + static showStats() { + view3d.isWithStats = true; + } + + static hideStats() { + view3d.isWithStats = false; + } + + + + + +} + +function testMobile() { + if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) + || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) return true; + else return false; +} + + + +//======================================= +// SAVE LOAD +//======================================= + +function makeGameSave( gameData, key ) { + window.localStorage.setItem(key, gameData); + console.log("game is save", key); + + if( !view3d.isMobile ){ + var blob = new Blob([gameData], {type: "text/plain;charset=utf-8"}); + saveAs(blob, "city3d.json"); + } + +} + +function makeLoadGame( key, atStart ) { + + var isStart = atStart || false; + + let savegame; + if( view3d.tmpGameData ){ + savegame = view3d.tmpGameData; + } else { + savegame = window.localStorage.getItem( key ); + } + + if(savegame){ + console.log("game is load"); + post({tell:"MAKELOADGAME", savegame:savegame, isStart:isStart}); + view3d.tmpGameData = null; + + } else { + console.log("No loading game found"); + } +} + + +//======================================= +// CITY FLOW +//======================================= + +function post( e, buffer ) { + + if( isWorker ) cityWorker.postMessage( e, buffer ); + else directMessage( { data : e } ); + +} + +function message( e ) { + + var phase = e.data.tell; + if( phase == "READY"){ + + console.log(isWorker ? 'is Worker !!' : 'is Direct !!'); + + } + if( phase == "NEWMAP"){ + + hub.generate( false ); + tilesData = e.data.tilesData; + view3d.paintMap( e.data.mapSize, e.data.island, withHeight ); + + } + + if( phase == "FULLREBUILD"){ + + //console.log('fullrebuild') + + if(e.data.isStart){ + hub.generate( false ); + } + view3d.fullRedraw = true; + tilesData = e.data.tilesData; + view3d.paintMap( e.data.mapSize, e.data.island, withHeight ); + view3d.loadCityBuild( e.data.cityData ); + + if( e.data.isStart ) view3d.startPlay(); + } + if( phase == "BUILD"){ + view3d.build(e.data.x, e.data.y); + } + if( phase == "RUN"){ + tilesData = e.data.tilesData; + powerData = e.data.powerData; + spriteData = e.data.sprites; + layerData = e.data.layer; + + hub.updateCITYinfo(e.data.infos); + + newup = true; + powerup = e.data.infos[9]; + + // update only layer change + view3d.updateLayer(); + view3d.moveSprite(); + view3d.showPower(); + + } + if( phase == "BUDGET"){ + hub.openBudget(e.data.budgetData); + } + if( phase == "QUERY"){ + hub.openQuery(e.data.queryTxt); + } + if( phase == "EVAL"){ + hub.openEval(e.data.evalData); + } + if( phase == "SAVEGAME"){ + makeGameSave(e.data.gameData, e.data.key); + + + } + if( phase == "LOADGAME"){ + makeLoadGame(e.data.key, e.data.isStart); + } +} + +export { Main }; diff --git a/games/3dcity/build/citygame.js b/games/3dcity/build/citygame.js new file mode 100644 index 0000000..8ea02c2 --- /dev/null +++ b/games/3dcity/build/citygame.js @@ -0,0 +1,8428 @@ +/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.city = {})); +}(this, (function (exports) { 'use strict'; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const Micro = { + haveMapAnimation: true, + localStorage: null, + GameMapProps: ['cityCentreX', 'cityCentreY', 'pollutionMaxX', 'pollutionMaxY', 'width', 'height'], + savePropsVar: ['cityTime'], + CensusProps: ['resPop', 'comPop', 'indPop', 'crimeRamp', 'pollutionRamp', 'landValueAverage', 'pollutionAverage', 'crimeAverage', 'totalPop', 'resHist10', 'resHist120', 'comHist10', 'comHist120', 'indHist10', 'indHist120', 'crimeHist10', 'crimeHist120', 'moneyHist10', 'moneyHist120', 'pollutionHist10', 'pollutionHist120'], + BudgetProps: ['autoBudget', 'totalFunds', 'policePercent', 'roadPercent', 'firePercent', 'roadSpend', 'policeSpend', 'fireSpend', 'roadMaintenanceBudget', 'policeMaintenanceBudget', 'fireMaintenanceBudget', 'cityTax', 'roadEffect', 'policeEffect', 'fireEffect'], + // eval + PROBLEMS: ['CVP_CRIME', 'CVP_POLLUTION', 'CVP_HOUSING', 'CVP_TAXES', 'CVP_TRAFFIC', 'CVP_UNEMPLOYMENT', 'CVP_FIRE'], + NUMPROBLEMS: 7, + //this.PROBLEMS.length, + NUM_COMPLAINTS: 4, + problemData: [], + EvalProps: ['cityClass', 'cityScore'], + speedPowerScan: [2, 4, 5, 6], + speedPollutionTerrainLandValueScan: [2, 7, 17, 30], + speedCrimeScan: [1, 8, 18, 32], + speedPopulationDensityScan: [1, 9, 19, 38], + speedFireAnalysis: [1, 10, 20, 40], + CENSUS_FREQUENCY_10: 4, + CENSUS_FREQUENCY_120: 4 * 10, + TAX_FREQUENCY: 48, + MAP_WIDTH: 128, + MAP_HEIGHT: 128, + MAP_DEFAULT_WIDTH: 128 * 3, + //Micro.MAP_WIDTH*3, + MAP_DEFAULT_HEIGHT: 128 * 3, + //Micro.MAP_HEIGHT*3, + MAP_BIG_DEFAULT_WIDTH: 128 * 16, + //Micro.MAP_WIDTH*16, + MAP_BIG_DEFAULT_HEIGHT: 128 * 16, + //Micro.MAP_HEIGHT*16, + MAP_BIG_DEFAULT_ID: "bigMap", + MAP_PARENT_ID: "splashContainer", + MAP_DEFAULT_ID: "SplashCanvas", + //GameCanvas + DEFAULT_WIDTH: 400, + DEFAULT_HEIGHT: 400, + DEFAULT_ID: "MicropolisCanvas", + RCI_DEFAULT_ID: "RCICanvas", + // Simulation + LEVEL_EASY: 0, + LEVEL_MED: 1, + LEVEL_HARD: 2, + SPEED_PAUSED: 0, + SPEED_SLOW: 1, + SPEED_MED: 2, + SPEED_FAST: 3, + SPEED_ULTRA: 4, + // Traffic + ROUTE_FOUND: 1, + NO_ROUTE_FOUND: 0, + NO_ROAD_FOUND: -1, + MAX_TRAFFIC_DISTANCE: 30, + perimX: [-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2], + perimY: [-2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1], + //SpriteConstants + SPRITE_TRAIN: 1, + SPRITE_HELICOPTER: 2, + SPRITE_AIRPLANE: 3, + SPRITE_SHIP: 4, + SPRITE_MONSTER: 5, + SPRITE_TORNADO: 6, + SPRITE_EXPLOSION: 7, + // Evaluation + CC_VILLAGE: 'VILLAGE', + CC_TOWN: 'TOWN', + CC_CITY: 'CITY', + CC_CAPITAL: 'CAPITAL', + CC_METROPOLIS: 'METROPOLIS', + CC_MEGALOPOLIS: 'MEGALOPOLIS', + CRIME: 0, + POLLUTION: 1, + HOUSING: 2, + TAXES: 3, + TRAFFIC: 4, + UNEMPLOYMENT: 5, + FIRE: 6, + // Valves + RES_VALVE_RANGE: 2000, + COM_VALVE_RANGE: 1500, + IND_VALVE_RANGE: 1500, + taxTable: [200, 150, 120, 100, 80, 50, 30, 0, -10, -40, -100, -150, -200, -250, -300, -350, -400, -450, -500, -550, -600], + extMarketParamTable: [1.2, 1.1, 0.98], + // Budget + RLevels: [0.7, 0.9, 1.2], + FLevels: [1.4, 1.2, 0.8], + MAX_ROAD_EFFECT: 32, + MAX_POLICESTATION_EFFECT: 1000, + MAX_FIRESTATION_EFFECT: 1000, + policeMaintenanceCost: 100, + fireMaintenanceCost: 100, + roadMaintenanceCost: 1, + railMaintenanceCost: 2, + // PowerManager + COAL_POWER_STRENGTH: 700, + NUCLEAR_POWER_STRENGTH: 2000, + //DisasterWindow + DISASTER_NONE: 'None', + DISASTER_MONSTER: 'Monster', + DISASTER_FIRE: 'Fire', + DISASTER_FLOOD: 'Flood', + DISASTER_CRASH: 'Crash', + DISASTER_MELTDOWN: 'Meltdown', + DISASTER_TORNADO: 'Tornado', + // storage + CURRENT_VERSION: 3, + KEY: 'micropolisJSGame', + // disasters + DisChance: [479, 239, 59], + // map generator + TERRAIN_CREATE_ISLAND: 0, + TERRAIN_TREE_LEVEL: -1, + //level for tree creation + TERRAIN_LAKE_LEVEL: -1, + //level for river curviness; -1==auto, 0==none, >0==level + TERRAIN_CURVE_LEVEL: -1, + //level for lake creation; -1==auto, 0==none, >0==level + ISLAND_RADIUS: 18, + M_ARRAY_TYPE: typeof Float32Array !== 'undefined' ? Float32Array : Array, + // census + arrs: ['res', 'com', 'ind', 'crime', 'money', 'pollution'], + directionTable: [0, 3, 2, 1, 3, 4, 5, 7, 6, 5, 7, 8, 1], + SMOOTH_NEIGHBOURS_THEN_BLOCK: 0, + SMOOTH_ALL_THEN_CLAMP: 1, + simData: null, + messageManager: null + }; + class EventEmitter { + static emitEvent(event, value) { + // ??? + Micro.messageManager.sendMessage(event, value); + } + + } //var M_ARRAY_TYPE; + //if(!M_ARRAY_TYPE) { M_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; } + + class MiscUtils { + /**/ + //static makeConstantDescriptor = function(value) { + static mcd(value) { + return { + configurable: false, + enumerable: false, + writeable: false, + value: value + }; + } + + static rotate10Arrays() { + for (var i = 0; i < Micro.arrs.length; i++) { + var name10 = Micro.arrs[i] + 'Hist10'; //this[name10] = [0].concat(this[name10].slice(0, -1)); + + this[name10].pop(); + this[name10].unshift(0); + } + } + + static rotate120Arrays() { + for (var i = 0; i < Micro.arrs.length; i++) { + var name120 = Micro.arrs[i] + 'Hist120'; //this[name120] = [0].concat(this[name120].slice(0, -1)); + + this[name120].pop(); + this[name120].unshift(0); + } + } + + static isCallable(f) { + return typeof f === 'function'; + } + + static copyFrom(data, sourceMap, sourceFn) { + var mapFn = function (elem) { + return sourceFn(elem); + }; + + var i = sourceMap.data.length; + + while (i--) data[i] = sourceMap.data[i].map(mapFn); + } + + static makeArrayOf(length, value) { + //var result = []; + //var result = new M_ARRAY_TYPE(length); + var result = new Array(length); //for (var a = 0; a < length; a++) result[a] = value; + + var i = length; + + while (i--) result[i] = value; + + return result; + } + + } + + class math { + static lerp(x, y, t) { + return (1 - t) * x + t * y; + } + + static rand(low, high) { + return low + Math.random() * (high - low); + } + + static randInt(low, high) { + return low + Math.floor(Math.random() * (high - low + 1)); + } + + static clamp(value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + } + + static getChance(chance) { + return (math.getRandom16() & chance) === 0; + } + + static getERandom(max) { + var r1 = math.getRandom(max); + var r2 = math.getRandom(max); + return Math.min(r1, r2); + } + + static getRandom(max) { + return Math.floor(Math.random() * (max + 1)); + } + + static getRandom16() { + return math.getRandom(65535); + } + + static getRandom16Signed() { + var value = math.getRandom16(); + if (value < 32768) return value;else return -(2 ** 16) + value; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class ZoneUtils { + // TileUtils + static pixToWorld(p) { + return p >> 4; + } + + static worldToPix(w) { + return w << 4; + } + + static unwrapTile(tile) { + if (tile.isTile) return tile = tile.getValue(); + return tile; + } + + static canBulldoze(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.FIRSTRIVEDGE && tile <= Tile.LASTRUBBLE || tile >= Tile.POWERBASE + 2 && tile <= Tile.POWERBASE + 12 || tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP + 2; + } + + static isCommercial(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.COMBASE && tile < Tile.INDBASE; + } + + static isIndustrial(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.INDBASE && tile < Tile.PORTBASE; + } + + static isResidential(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.RESBASE && tile < Tile.HOSPITALBASE; + } + + static isDriveable(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.ROADBASE && tile <= Tile.LASTRAIL || tile === Tile.RAILHPOWERV || tile === Tile.RAILVPOWERH; + } + + static isFire(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.FIREBASE && tile < Tile.ROADBASE; + } + + static isFlood(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.FLOOD && tile < Tile.LASTFLOOD; + } + + static isManualExplosion(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP; + } + + static isRail(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.RAILBASE && tile < Tile.RESBASE; + } + + static isRoad(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.ROADBASE && tile < Tile.POWERBASE; + } + + static normalizeRoad(tile) { + tile = ZoneUtils.unwrapTile(tile); + return tile >= Tile.ROADBASE && tile <= Tile.LASTROAD + 1 ? (tile & 15) + 64 : tile; + } /// + + + static isCommercialZone(tile) { + return tile.isZone() && ZoneUtils.isCommercial(tile); + } + + static isIndustrialZone(tile) { + return tile.isZone() && ZoneUtils.isIndustrial(tile); + } + + static isResidentialZone(tile) { + return tile.isZone() && ZoneUtils.isResidential(tile); + } + + static randomFire(tile) { + return new Tiles(Tile.FIRE + (math.getRandom16() & 3), Tile.ANIMBIT); + } + + static randomRubble(tile) { + return new Tiles(Tile.RUBBLE + (math.getRandom16() & 3), Tile.BULLBIT); + } + + static HOSPITAL(tile) {} // ZoneUtils + + + static checkZoneSize(tile) { + if (tile >= Tile.RESBASE - 1 && tile <= Tile.PORTBASE - 1 || tile >= Tile.LASTPOWERPLANT + 1 && tile <= Tile.POLICESTATION + 4 || tile >= Tile.CHURCH1BASE && tile <= Tile.CHURCH7LAST) { + return 3; + } + + if (tile >= Tile.PORTBASE && tile <= Tile.LASTPORT || tile >= Tile.COALBASE && tile <= Tile.LASTPOWERPLANT || tile >= Tile.STADIUMBASE && tile <= Tile.LASTZONE) { + return 4; + } + + return 0; + } + + static fireZone(map, x, y, blockMaps) { + let tileValue = map.getTileValue(x, y); + let zoneSize = 2; // A zone being on fire naturally hurts growth + + let value = blockMaps.rateOfGrowthMap.worldGet(x, y); + value = math.clamp(value - 20, -200, 200); + blockMaps.rateOfGrowthMap.worldSet(x, y, value); + if (tileValue === Tile.AIRPORT) zoneSize = 5;else if (tileValue >= Tile.PORTBASE) zoneSize = 3;else if (tileValue < Tile.PORTBASE) zoneSize = 2; // Make remaining tiles of the zone bulldozable + + let xDelta, yDelta, xTem, yTem; + + for (xDelta = -1; xDelta < zoneSize; xDelta++) { + for (yDelta = -1; yDelta < zoneSize; yDelta++) { + xTem = x + xDelta; + yTem = y + yDelta; + if (!map.testBounds(xTem, yTem)) continue; + if (map.getTileValue(xTem, yTem >= Tile.ROADBASE)) map.addTileFlags(xTem, yTem, Tile.BULLBIT); + } + } + } + + static getLandPollutionValue(blockMaps, x, y) { + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 30) return 0; + if (landValue < 80) return 1; + if (landValue < 150) return 2; + return 3; + } + + static incRateOfGrowth(blockMaps, x, y, growthDelta) { + let currentRate = blockMaps.rateOfGrowthMap.worldGet(x, y); // TODO why the scale of 4 here + + let newValue = math.clamp(currentRate + growthDelta * 4, -200, 200); + blockMaps.rateOfGrowthMap.worldSet(x, y, newValue); + } // Calls map.putZone after first checking for flood, fire and radiation + + + static putZone(map, x, y, centreTile, isPowered) { + let dY, dX, tileValue; + + for (dY = -1; dY < 2; dY++) { + for (dX = -1; dX < 2; dX++) { + tileValue = map.getTileValue(x + dX, y + dY); + if (tileValue >= Tile.FLOOD && tileValue < Tile.ROADBASE) return; + } + } + + map.putZone(x, y, centreTile, 3); + map.addTileFlags(x, y, Tile.BULLBIT); + if (isPowered) map.addTileFlags(x, y, Tile.POWERBIT); + } + + } //export const ZoneUtils = ZoneUtils + + ZoneUtils.checkBigZone = function (tile) { + let result; + + switch (tile) { + case Tile.POWERPLANT: + case Tile.PORT: + case Tile.NUCLEAR: + case Tile.STADIUM: + result = { + zoneSize: 4, + deltaX: 0, + deltaY: 0 + }; + break; + + case Tile.POWERPLANT + 1: + case Tile.COALSMOKE3: + case Tile.COALSMOKE3 + 1: + case Tile.COALSMOKE3 + 2: + case Tile.PORT + 1: + case Tile.NUCLEAR + 1: + case Tile.STADIUM + 1: + result = { + zoneSize: 4, + deltaX: -1, + deltaY: 0 + }; + break; + + case Tile.POWERPLANT + 4: + case Tile.PORT + 4: + case Tile.NUCLEAR + 4: + case Tile.STADIUM + 4: + result = { + zoneSize: 4, + deltaX: 0, + deltaY: -1 + }; + break; + + case Tile.POWERPLANT + 5: + case Tile.PORT + 5: + case Tile.NUCLEAR + 5: + case Tile.STADIUM + 5: + result = { + zoneSize: 4, + deltaX: -1, + deltaY: -1 + }; + break; + + case Tile.AIRPORT: + result = { + zoneSize: 6, + deltaX: 0, + deltaY: 0 + }; + break; + + case Tile.AIRPORT + 1: + result = { + zoneSize: 6, + deltaX: -1, + deltaY: 0 + }; + break; + + case Tile.AIRPORT + 2: + result = { + zoneSize: 6, + deltaX: -2, + deltaY: 0 + }; + break; + + case Tile.AIRPORT + 3: + result = { + zoneSize: 6, + deltaX: -3, + deltaY: 0 + }; + break; + + case Tile.AIRPORT + 6: + result = { + zoneSize: 6, + deltaX: 0, + deltaY: -1 + }; + break; + + case Tile.AIRPORT + 7: + result = { + zoneSize: 6, + deltaX: -1, + deltaY: -1 + }; + break; + + case Tile.AIRPORT + 8: + result = { + zoneSize: 6, + deltaX: -2, + deltaY: -1 + }; + break; + + case Tile.AIRPORT + 9: + result = { + zoneSize: 6, + deltaX: -3, + deltaY: -1 + }; + break; + + case Tile.AIRPORT + 12: + result = { + zoneSize: 6, + deltaX: 0, + deltaY: -2 + }; + break; + + case Tile.AIRPORT + 13: + result = { + zoneSize: 6, + deltaX: -1, + deltaY: -2 + }; + break; + + case Tile.AIRPORT + 14: + result = { + zoneSize: 6, + deltaX: -2, + deltaY: -2 + }; + break; + + case Tile.AIRPORT + 15: + result = { + zoneSize: 6, + deltaX: -3, + deltaY: -2 + }; + break; + + case Tile.AIRPORT + 18: + result = { + zoneSize: 6, + deltaX: 0, + deltaY: -3 + }; + break; + + case Tile.AIRPORT + 19: + result = { + zoneSize: 6, + deltaX: -1, + deltaY: -3 + }; + break; + + case Tile.AIRPORT + 20: + result = { + zoneSize: 6, + deltaX: -2, + deltaY: -3 + }; + break; + + case Tile.AIRPORT + 21: + result = { + zoneSize: 6, + deltaX: -3, + deltaY: -3 + }; + break; + + default: + result = { + zoneSize: 0, + deltaX: 0, + deltaY: 0 + }; + break; + } + + return result; + }; + + class Tiles { + constructor(tileValue = Tile.DIRT, bitMask) { + this.isTile = true; + /* + if (!(this.isTile)) return new Tiles(); + if (arguments.length > 0 && typeof(tileValue) !== 'number') throw new Error('Tile constructor called with invalid tileValue ' + tileValue); + if (arguments.length > 1 && typeof(bitMask) !== 'number') throw new Error('Tile constructor called with invalid bitMask ' + bitMask); + if (arguments.length > 1 && (tileValue < Tile.TILE_INVALID || tileValue >= Tile.TILE_COUNT)) throw new Error('Tile constructor called with out-of-range tileValue ' + tileValue); + if (arguments.length > 1 && (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1))) throw new Error('Tile constructor called with out-of-range bitmask ' + bitMask); + */ + + this._value = tileValue; + if (arguments.length > 1) this._value |= bitMask; + } + + getValue() { + return this._value & Tile.BIT_MASK; + } + + setValue(tileValue) { + if (arguments.length === 0 || typeof tileValue !== 'number' || tileValue < 0) throw new Error('Invalid parameter'); + let existingFlags = 0; + if (tileValue < Tile.BIT_START) existingFlags = this._value & Tile.ALLBITS; //this.getFlags(); + + this._value = tileValue | existingFlags; + } + + isBulldozable() { + return (this._value & Tile.BULLBIT) > 0; + } + + isAnimated() { + return (this._value & Tile.ANIMBIT) > 0; + } + + isConductive() { + return (this._value & Tile.CONDBIT) > 0; + } + + isCombustible() { + return (this._value & Tile.BURNBIT) > 0; + } + + isPowered() { + return (this._value & Tile.POWERBIT) > 0; + } + + isZone() { + return (this._value & Tile.ZONEBIT) > 0; + } + + addFlags(bitMask) { + if (!arguments.length || typeof bitMask !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value |= bitMask; + } + + removeFlags(bitMask) { + if (!arguments.length || typeof bitMask !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value &= ~bitMask; + } + + setFlags(bitMask) { + //if (typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Invalid parameter'); + //if (arguments.length === 0) throw new Error('Tile setFlags called with no arguments'); + //if (typeof(bitMask) !== 'number') throw new Error('Tile setFlags called with invalid bitmask ' + bitMask); + // if (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Tile setFlags called with out-of-range bitmask ' + bitMask); + let existingValue = this._value & ~Tile.ALLBITS; + this._value = existingValue | bitMask; + } + + getFlags() { + return this._value & Tile.ALLBITS; + } + + getRawValue() { + return this._value; + } + + set(tileValue, bitMask) { + if (arguments.length < 2 || typeof tileValue !== 'number' || typeof bitMask !== 'number' || tileValue >= Tile.TILE_COUNT) throw new Error('Invalid parameter'); + this.setValue(tileValue); + this.setFlags(bitMask); + } + + toString() { + let value = this.getValue(); + let s = 'Tile# ' + value; + s += this.isCombustible() ? ' burning' : ''; + s += this.isPowered() ? ' powered' : ''; + s += this.isAnimated() ? ' animated' : ''; + s += this.isConductive() ? ' conductive' : ''; + s += this.isZone() ? ' zone' : ''; + s += this.isBulldozable() ? ' bulldozeable' : ''; + return s; + } + + } + const Tile = { + // Bit-masks for statusBits + POWERBIT: 0x8000, + // bit 15, tile has power. + CONDBIT: 0x4000, + // bit 14. tile can conduct electricity. + BURNBIT: 0x2000, + // bit 13, tile can be lit. + BULLBIT: 0x1000, + // bit 12, tile is bulldozable. + ANIMBIT: 0x0800, + // bit 11, tile is animated. + ZONEBIT: 0x0400, + // bit 10, tile is the center tile of the zone. + BLBNBIT: 0x1000 | 0x2000, + //BULLBIT | BURNBIT, + BLBNCNBIT: 0x1000 | 0x2000 | 0x4000, + //BULLBIT | BURNBIT | CONDBIT, + BNCNBIT: 0x2000 | 0x4000, + //BURNBIT | CONDBIT, + ASCBIT: 0x0800 | 0x4000 | 0x2000, + // ANIMBIT | CONDBIT | BURNBIT, + ALLBITS: 0x8000 | 0x4000 | 0x2000 | 0x1000 | 0x0800 | 0x0400, + // POWERBIT | CONDBIT | BURNBIT | BULLBIT | ANIMBIT | ZONEBIT, + BIT_START: 0x400, + BIT_END: 0x8000, + BIT_MASK: 0x400 - 1, + // BIT_START - 1, + // TODO Add comment for each tile + DIRT: 0, + // Clear tile + // tile 1 ? + + /* Water */ + RIVER: 2, + REDGE: 3, + CHANNEL: 4, + FIRSTRIVEDGE: 5, + // tile 6 -- 19 ? + LASTRIVEDGE: 20, + WATER_LOW: 2, + //RIVER, // First water tile + WATER_HIGH: 20, + //LASTRIVEDGE, // Last water tile (inclusive) + TREEBASE: 21, + WOODS_LOW: 21, + //TREEBASE, + LASTTREE: 36, + WOODS: 37, + UNUSED_TRASH1: 38, + UNUSED_TRASH2: 39, + WOODS_HIGH: 39, + //UNUSED_TRASH2, // Why is an 'UNUSED' tile used? + WOODS2: 40, + WOODS3: 41, + WOODS4: 42, + WOODS5: 43, + // Rubble (4 tiles) + RUBBLE: 44, + LASTRUBBLE: 47, + // fLOOD 4 tiles + FLOOD: 48, + LASTFLOOD: 51, + // Radiation + RADTILE: 52, + // Radio-active contaminated tile + UNUSED_TRASH3: 53, + UNUSED_TRASH4: 54, + UNUSED_TRASH5: 55, + + /* Fire animation (8 tiles) */ + FIRE: 56 - 8, + FIREBASE: 56 - 8, + //FIRE, + LASTFIRE: 63 - 8, + HBRIDGE: 64, + // Horizontal bridge + ROADBASE: 64, + // HBRIDGE, + VBRIDGE: 65, + // Vertical bridge + ROADS: 66, + ROADS2: 67, + ROADS3: 68, + ROADS4: 69, + ROADS5: 70, + ROADS6: 71, + ROADS7: 72, + ROADS8: 73, + ROADS9: 74, + ROADS10: 75, + INTERSECTION: 76, + HROADPOWER: 77, + VROADPOWER: 78, + BRWH: 79, + LTRFBASE: 80, + // First tile with low traffic + // tile 81 -- 94 ? + BRWV: 95, + // tile 96 -- 110 ? + BRWXXX1: 111, + // tile 96 -- 110 ? + BRWXXX2: 127, + // tile 96 -- 110 ? + BRWXXX3: 143, + HTRFBASE: 144, + // First tile with high traffic + // tile 145 -- 158 ? + BRWXXX4: 159, + // tile 160 -- 174 ? + BRWXXX5: 175, + // tile 176 -- 190 ? + BRWXXX6: 191, + // tile 192 -- 205 ? + LASTROAD: 206, + BRWXXX7: 207, + + /* Power lines */ + HPOWER: 208, + VPOWER: 209, + LHPOWER: 210, + LVPOWER: 211, + LVPOWER2: 212, + LVPOWER3: 213, + LVPOWER4: 214, + LVPOWER5: 215, + LVPOWER6: 216, + LVPOWER7: 217, + LVPOWER8: 218, + LVPOWER9: 219, + LVPOWER10: 220, + RAILHPOWERV: 221, + // Horizontal rail, vertical power + RAILVPOWERH: 222, + // Vertical rail, horizontal power + POWERBASE: 208, + //HPOWER, + LASTPOWER: 222, + //RAILVPOWERH, + UNUSED_TRASH6: 223, + + /* Rail */ + HRAIL: 224, + VRAIL: 225, + LHRAIL: 226, + LVRAIL: 227, + LVRAIL2: 228, + LVRAIL3: 229, + LVRAIL4: 230, + LVRAIL5: 231, + LVRAIL6: 232, + LVRAIL7: 233, + LVRAIL8: 234, + LVRAIL9: 235, + LVRAIL10: 236, + HRAILROAD: 237, + VRAILROAD: 238, + RAILBASE: 224, + //HRAIL, + LASTRAIL: 238, + ROADVPOWERH: 239, + + /* bogus? */ + // Residential zone tiles + RESBASE: 240, + // Empty residential, tiles 240--248 + FREEZ: 244, + // center-tile of 3x3 empty residential + HOUSE: 249, + // Single tile houses until 260 + LHTHR: 249, + //HOUSE, + HHTHR: 260, + RZB: 265, + // center tile first 3x3 tile residential + HOSPITALBASE: 405, + // Center of hospital (tiles 405--413) + HOSPITAL: 409, + // Center of hospital (tiles 405--413) + CHURCHBASE: 414, + // Center of church (tiles 414--422) + CHURCH0BASE: 414, + // numbered alias + CHURCH: 418, + // Center of church (tiles 414--422) + CHURCH0: 418, + // numbered alias + // Commercial zone tiles + COMBASE: 423, + // Empty commercial, tiles 423--431 + // tile 424 -- 426 ? + COMCLR: 427, + // tile 428 -- 435 ? + CZB: 436, + // tile 437 -- 608 ? + COMLAST: 609, + // tile 610, 611 ? + // Industrial zone tiles. + INDBASE: 612, + // Top-left tile of empty industrial zone. + INDCLR: 616, + // Center tile of empty industrial zone. + LASTIND: 620, + // Last tile of empty industrial zone. + // Industrial zone population 0, value 0: 621 -- 629 + IND1: 621, + // Top-left tile of first non-empty industry zone. + IZB: 625, + // Center tile of first non-empty industry zone. + // Industrial zone population 1, value 0: 630 -- 638 + // Industrial zone population 2, value 0: 639 -- 647 + IND2: 641, + IND3: 644, + // Industrial zone population 3, value 0: 648 -- 656 + IND4: 649, + IND5: 650, + // Industrial zone population 0, value 1: 657 -- 665 + // Industrial zone population 1, value 1: 666 -- 674 + // Industrial zone population 2, value 1: 675 -- 683 + IND6: 676, + IND7: 677, + // Industrial zone population 3, value 1: 684 -- 692 + IND8: 686, + IND9: 689, + // Seaport + PORTBASE: 693, + // Top-left tile of the seaport. + PORT: 698, + // Center tile of the seaport. + LASTPORT: 708, + // Last tile of the seaport. + AIRPORTBASE: 709, + // tile 710 ? + RADAR: 711, + // tile 712 -- 715 ? + AIRPORT: 716, + // tile 717 -- 744 ? + // Coal power plant (4x4). + COALBASE: 745, + // First tile of coal power plant. + POWERPLANT: 750, + // 'Center' tile of coal power plant. + LASTPOWERPLANT: 760, + // Last tile of coal power plant. + // Fire station (3x3). + FIRESTBASE: 761, + // First tile of fire station. + FIRESTATION: 765, + // 'Center tile' of fire station. + // 769 last tile fire station. + POLICESTBASE: 770, + // tile 771 -- 773 ? + POLICESTATION: 774, + // tile 775 -- 778 ? + // Stadium (4x4). + STADIUMBASE: 779, + // First tile stadium. + STADIUM: 784, + // 'Center tile' stadium. + // Last tile stadium 794. + // tile 785 -- 799 ? + FULLSTADIUM: 800, + // tile 801 -- 810 ? + // Nuclear power plant (4x4). + NUCLEARBASE: 811, + // First tile nuclear power plant. + NUCLEAR: 816, + // 'Center' tile nuclear power plant. + LASTZONE: 826, + // Also last tile nuclear power plant. + LIGHTNINGBOLT: 827, + // bridge horisontal open close + HBRDG0: 828, + HBRDG1: 829, + HBRDG2: 830, + HBRDG3: 831, + //HBRDG_END : 832, + RADAR0: 832, + RADAR1: 833, + RADAR2: 834, + RADAR3: 835, + RADAR4: 836, + RADAR5: 837, + RADAR6: 838, + RADAR7: 839, + FOUNTAIN: 840, + // tile 841 -- 843: fountain animation. + INDBASE2: 844, + TELEBASE: 844, + // tile 845 -- 850 ? + TELELAST: 851, + SMOKEBASE: 852, + // tile 853 -- 859 ? + TINYEXP: 860, + // tile 861 -- 863 ? + SOMETINYEXP: 864, + // tile 865 -- 866 ? + LASTTINYEXP: 867, + // tile 868 -- 882 ? + TINYEXPLAST: 883, + // tile 884 -- 915 ? + COALSMOKE1: 916, + // Chimney animation at coal power plant (2, 0). + // 919 last animation tile for chimney at coal power plant (2, 0). + COALSMOKE2: 920, + // Chimney animation at coal power plant (3, 0). + // 923 last animation tile for chimney at coal power plant (3, 0). + COALSMOKE3: 924, + // Chimney animation at coal power plant (2, 1). + // 927 last animation tile for chimney at coal power plant (2, 1). + COALSMOKE4: 928, + // Chimney animation at coal power plant (3, 1). + // 931 last animation tile for chimney at coal power plant (3, 1). + FOOTBALLGAME1: 932, + // tile 933 -- 939 ? + FOOTBALLGAME2: 940, + // tile 941 -- 94 bridge open close + VBRDG0: 948, + VBRDG1: 949, + VBRDG2: 950, + VBRDG3: 951, + // nuclear animation // disable + NUKESWIRL1: 952, + NUKESWIRL2: 953, + NUKESWIRL3: 954, + NUKESWIRL4: 955, + // Tiles 956-959 unused (originally) + // TILE_COUNT : 960, + // Extended zones: 956-1019 + CHURCH1BASE: 956, + CHURCH1: 960, + CHURCH2BASE: 965, + CHURCH2: 969, + CHURCH3BASE: 974, + CHURCH3: 978, + CHURCH4BASE: 983, + CHURCH4: 987, + CHURCH5BASE: 992, + CHURCH5: 996, + CHURCH6BASE: 1001, + CHURCH6: 1005, + CHURCH7BASE: 1010, + CHURCH7: 1014, + CHURCH7LAST: 1018, + // Tiles 1020-1023 unused + TILE_COUNT: 1024, + TILE_INVALID: -1, + // Invalid tile (not used in the world map). + MIN_SIZE: 16 // Minimum size of tile in pixels + + }; + const RoadTable = [Tile.ROADS, Tile.ROADS2, Tile.ROADS, Tile.ROADS3, Tile.ROADS2, Tile.ROADS2, Tile.ROADS4, Tile.ROADS8, Tile.ROADS, Tile.ROADS6, Tile.ROADS, Tile.ROADS7, Tile.ROADS5, Tile.ROADS10, Tile.ROADS9, Tile.INTERSECTION]; + const RailTable = [Tile.LHRAIL, Tile.LVRAIL, Tile.LHRAIL, Tile.LVRAIL2, Tile.LVRAIL, Tile.LVRAIL, Tile.LVRAIL3, Tile.LVRAIL7, Tile.LHRAIL, Tile.LVRAIL5, Tile.LHRAIL, Tile.LVRAIL6, Tile.LVRAIL4, Tile.LVRAIL9, Tile.LVRAIL8, Tile.LVRAIL10]; + const WireTable = [Tile.LHPOWER, Tile.LVPOWER, Tile.LHPOWER, Tile.LVPOWER2, Tile.LVPOWER, Tile.LVPOWER, Tile.LVPOWER3, Tile.LVPOWER7, Tile.LHPOWER, Tile.LVPOWER5, Tile.LHPOWER, Tile.LVPOWER6, Tile.LVPOWER4, Tile.LVPOWER9, Tile.LVPOWER8, Tile.LVPOWER10]; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class MessageManager { + constructor() { + this.data = []; + } + + sendMessage(message, data) { + this.data.push({ + message: message, + data: data + }); + } + + clear() { + this.data = []; + } + + getMessages() { + return this.data.slice(); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + var messageData = { + AUTOBUDGET_CHANGED: MiscUtils.mcd('Autobudget changed'), + BUDGET_NEEDED: MiscUtils.mcd('User needs to budget'), + BUDGET_REQUESTED: MiscUtils.mcd('Budget window requested'), + BUDGET_WINDOW_CLOSED: MiscUtils.mcd('Budget window closed'), + BLACKOUTS_REPORTED: MiscUtils.mcd('Blackouts reported'), + CLASSIFICATION_UPDATED: MiscUtils.mcd('Classification updated'), + CONGRATS_SHOWING: MiscUtils.mcd('Congratulations showing'), + CONGRATS_WINDOW_CLOSED: MiscUtils.mcd('Congratulations window closed'), + DATE_UPDATED: MiscUtils.mcd('Date changed'), + DEBUG_WINDOW_REQUESTED: MiscUtils.mcd('Debug Window Requested'), + DEBUG_WINDOW_CLOSED: MiscUtils.mcd('Debug Window Closed'), + DISASTER_REQUESTED: MiscUtils.mcd('Disaster Requested'), + DISASTER_WINDOW_CLOSED: MiscUtils.mcd('Disaster window closed'), + EARTHQUAKE: MiscUtils.mcd('Earthquake'), + EVAL_REQUESTED: MiscUtils.mcd('Evaluation Requested'), + EVAL_UPDATED: MiscUtils.mcd('Evaluation Updated'), + EVAL_WINDOW_CLOSED: MiscUtils.mcd('Eval window closed'), + EXPLOSION_REPORTED: MiscUtils.mcd('Explosion Reported'), + FIRE_REPORTED: MiscUtils.mcd('Fire!'), + FIRE_STATION_NEEDS_FUNDING: MiscUtils.mcd('Fire station needs funding'), + FLOODING_REPORTED: MiscUtils.mcd('Flooding reported'), + FRONT_END_MESSAGE: MiscUtils.mcd('Front-end Message'), + FUNDS_CHANGED: MiscUtils.mcd('Total funds has changed'), + HEAVY_TRAFFIC: MiscUtils.mcd('Heavy traffic in city'), + HELICOPTER_CRASHED: MiscUtils.mcd('Helicopter crashed'), + HIGH_CRIME: MiscUtils.mcd('High crime'), + HIGH_POLLUTION: MiscUtils.mcd('High pollution'), + MONSTER_SIGHTED: MiscUtils.mcd('Monster sighted'), + NAG_WINDOW_CLOSED: MiscUtils.mcd('Nag window closed'), + NEED_AIRPORT: MiscUtils.mcd('Airport needed'), + NEED_ELECTRICITY: MiscUtils.mcd('More power needed'), + NEED_FIRE_STATION: MiscUtils.mcd('Fire station needed'), + NEED_MORE_COMMERCIAL: MiscUtils.mcd('More commercial zones needed'), + NEED_MORE_INDUSTRIAL: MiscUtils.mcd('More industrial zones needed'), + NEED_MORE_RAILS: MiscUtils.mcd('More railways needed'), + NEED_MORE_RESIDENTIAL: MiscUtils.mcd('More residential needed'), + NEED_MORE_ROADS: MiscUtils.mcd('More roads needed'), + NEED_POLICE_STATION: MiscUtils.mcd('Police station needed'), + NEED_SEAPORT: MiscUtils.mcd('Seaport needed'), + NEED_STADIUM: MiscUtils.mcd('Stadium needed'), + NO_MONEY: MiscUtils.mcd('No money'), + NOT_ENOUGH_POWER: MiscUtils.mcd('Not enough power'), + NUCLEAR_MELTDOWN: MiscUtils.mcd('Nuclear Meltdown'), + PLANE_CRASHED: MiscUtils.mcd('Plane crashed'), + POLICE_NEEDS_FUNDING: MiscUtils.mcd('Police need funding'), + POPULATION_UPDATED: MiscUtils.mcd('Population updated'), + QUERY_WINDOW_CLOSED: MiscUtils.mcd('Query window closed'), + QUERY_WINDOW_NEEDED: MiscUtils.mcd('Query window needed'), + REACHED_CAPITAL: MiscUtils.mcd('Now a capital'), + REACHED_CITY: MiscUtils.mcd('Now a city'), + REACHED_METROPOLIS: MiscUtils.mcd('Now a metropolis'), + REACHED_MEGALOPOLIS: MiscUtils.mcd('Now a megalopolis'), + REACHED_TOWN: MiscUtils.mcd('Now a town'), + REACHED_VILLAGE: MiscUtils.mcd('Now a village'), + ROAD_NEEDS_FUNDING: MiscUtils.mcd('Roads need funding'), + SAVE_REQUESTED: MiscUtils.mcd('Save requested'), + SAVE_WINDOW_CLOSED: MiscUtils.mcd('Save window closed'), + SCORE_UPDATED: MiscUtils.mcd('Score updated'), + SCREENSHOT_LINK_CLOSED: MiscUtils.mcd('Screenshot link closed'), + SCREENSHOT_WINDOW_CLOSED: MiscUtils.mcd('Screenshot window closed'), + SCREENSHOT_WINDOW_REQUESTED: MiscUtils.mcd('Screenshot window requested'), + SETTINGS_WINDOW_CLOSED: MiscUtils.mcd('Settings window closed'), + SETTINGS_WINDOW_REQUESTED: MiscUtils.mcd('Settings window requested'), + SHIP_CRASHED: MiscUtils.mcd('Shipwrecked'), + SOUND_EXPLOSIONHIGH: MiscUtils.mcd('Explosion! Bang!'), + SOUND_EXPLOSIONLOW: MiscUtils.mcd('Explosion! Bang!'), + SOUND_HEAVY_TRAFFIC: MiscUtils.mcd('Heavy Traffic sound'), + SOUND_HONKHONK: MiscUtils.mcd('HonkHonk sound'), + SOUND_MONSTER: MiscUtils.mcd('Monster sound'), + SPEED_CHANGE: MiscUtils.mcd('Speed change'), + SPRITE_DYING: MiscUtils.mcd('Sprite dying'), + SPRITE_MOVED: MiscUtils.mcd('Sprite move'), + TAX_TOO_HIGH: MiscUtils.mcd('Tax too high'), + TOOL_CLICKED: MiscUtils.mcd('Tool clicked'), + TORNADO_SIGHTED: MiscUtils.mcd('Tornado sighted'), + TOUCH_WINDOW_CLOSED: MiscUtils.mcd('Touch Window closed'), + TRAFFIC_JAMS: MiscUtils.mcd('Traffic jams reported'), + TRAIN_CRASHED: MiscUtils.mcd('Train crashed'), + VALVES_UPDATED: MiscUtils.mcd('Valves updated'), + WELCOME: MiscUtils.mcd('Welcome to micropolisJS'), + WELCOMEBACK: MiscUtils.mcd('Welcome back to your 3D city') + }; + const Messages = Object.defineProperties({}, messageData); //var Messages = Object.defineProperties({}, messageData); + + var disasterMessages = [Messages.EARTHQUAKE, Messages.EXPLOSION_REPORTED, Messages.FIRE_REPORTED, Messages.FLOODING_REPORTED, Messages.MONSTER_SIGHTED, Messages.NUCLEAR_MELTDOWN, Messages.TORNADO_SIGHTED]; + Object.defineProperty(Messages, 'disasterMessages', MiscUtils.mcd(disasterMessages)); + var crashes = [Messages.HELICOPTER_CRASHED, Messages.PLANE_CRASHED, Messages.SHIP_CRASHED, Messages.TRAIN_CRASHED]; + Object.defineProperty(Messages, 'crashes', MiscUtils.mcd(crashes)); //export { Messages }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + const Text = function () { + // TODO Some kind of rudimentary L20N based on navigator.language? + // Query tool strings + var densityStrings = ['Low', 'Medium', 'High', 'Very High']; + var landValueStrings = ['Slum', 'Lower Class', 'Middle Class', 'High']; + var crimeStrings = ['Safe', 'Light', 'Moderate', 'Dangerous']; + var pollutionStrings = ['None', 'Moderate', 'Heavy', 'Very Heavy']; + var rateStrings = ['Declining', 'Stable', 'Slow Growth', 'Fast Growth']; + var zoneTypes = ['Clear', 'Water', 'Trees', 'Rubble', 'Flood', 'Radioactive Waste', 'Fire', 'Road', 'Power', 'Rail', 'Residential', 'Commercial', 'Industrial', 'Seaport', 'Airport', 'Coal Power', 'Fire Department', 'Police Department', 'Stadium', 'Nuclear Power', 'Draw Bridge', 'Radar Dish', 'Fountain', 'Industrial', 'Steelers 38 Bears 3', 'Draw Bridge', 'Ur 238']; // Evaluation window + + var gameLevel = {}; + gameLevel['' + Micro.LEVEL_EASY] = 'Easy'; + gameLevel['' + Micro.LEVEL_MED] = 'Medium'; + gameLevel['' + Micro.LEVEL_HARD] = 'Hard'; + var cityClass = {}; + cityClass[Micro.CC_VILLAGE] = 'VILLAGE'; + cityClass[Micro.CC_TOWN] = 'TOWN'; + cityClass[Micro.CC_CITY] = 'CITY'; + cityClass[Micro.CC_CAPITAL] = 'CAPITAL'; + cityClass[Micro.CC_METROPOLIS] = 'METROPOLIS'; + cityClass[Micro.CC_MEGALOPOLIS] = 'MEGALOPOLIS'; + var problems = {}; + problems[Micro.CRIME] = 'Crime'; + problems[Micro.POLLUTION] = 'Pollution'; + problems[Micro.HOUSING] = 'Housing'; + problems[Micro.TAXES] = 'Taxes'; + problems[Micro.TRAFFIC] = 'Traffic'; + problems[Micro.UNEMPLOYMENT] = 'Unemployment'; + problems[Micro.FIRE] = 'Fire'; // months + + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // Tool strings + + var toolMessages = { + noMoney: 'Insufficient funds to build that', + needsDoze: 'Area must be bulldozed first' + }; // Message strings + + var neutralMessages = {}; + neutralMessages[Messages.FIRE_STATION_NEEDS_FUNDING] = 'Fire departments need funding'; + neutralMessages[Messages.NEED_AIRPORT] = 'Commerce requires an Airport'; + neutralMessages[Messages.NEED_FIRE_STATION] = 'Citizens demand a Fire Department'; + neutralMessages[Messages.NEED_ELECTRICITY] = 'Build a Power Plant'; + neutralMessages[Messages.NEED_MORE_INDUSTRIAL] = 'More industrial zones needed'; + neutralMessages[Messages.NEED_MORE_COMMERCIAL] = 'More commercial zones needed'; + neutralMessages[Messages.NEED_MORE_RESIDENTIAL] = 'More residential zones needed'; + neutralMessages[Messages.NEED_MORE_RAILS] = 'Inadequate rail system'; + neutralMessages[Messages.NEED_MORE_ROADS] = 'More roads required'; + neutralMessages[Messages.NEED_POLICE_STATION] = 'Citizens demand a Police Department'; + neutralMessages[Messages.NEED_SEAPORT] = 'Industry requires a Sea Port'; + neutralMessages[Messages.NEED_STADIUM] = 'Residents demand a Stadium'; + neutralMessages[Messages.ROAD_NEEDS_FUNDING] = 'Roads deteriorating, due to lack of funds'; + neutralMessages[Messages.POLICE_NEEDS_FUNDING] = 'Police departments need funding'; + neutralMessages[Messages.WELCOME] = 'Welcome to 3D City'; + neutralMessages[Messages.WELCOMEBACK] = 'Welcome to 3D City'; + var badMessages = {}; + badMessages[Messages.BLACKOUTS_REPORTED] = 'Brownouts, build another Power Plant'; + badMessages[Messages.COPTER_CRASHED] = 'A helicopter crashed '; + badMessages[Messages.EARTHQUAKE] = 'Major earthquake reported !!'; + badMessages[Messages.EXPLOSION_REPORTED] = 'Explosion detected '; + badMessages[Messages.FLOODING_REPORTED] = 'Flooding reported !'; + badMessages[Messages.FIRE_REPORTED] = 'Fire reported '; + badMessages[Messages.HEAVY_TRAFFIC] = 'Heavy Traffic reported'; + badMessages[Messages.HIGH_CRIME] = 'Crime very high'; + badMessages[Messages.HIGH_POLLUTION] = 'Pollution very high'; + badMessages[Messages.MONSTER_SIGHTED] = 'A Monster has been sighted !'; + badMessages[Messages.NO_MONEY] = 'YOUR CITY HAS GONE BROKE'; + badMessages[Messages.NOT_ENOUGH_POWER] = 'Blackouts reported. insufficient power capacity'; + badMessages[Messages.NUCLEAR_MELTDOWN] = 'A Nuclear Meltdown has occurred !!'; + badMessages[Messages.PLANE_CRASHED] = 'A plane has crashed '; + badMessages[Messages.SHIP_CRASHED] = 'Shipwreck reported '; + badMessages[Messages.TAX_TOO_HIGH] = 'Citizens upset. The tax rate is too high'; + badMessages[Messages.TORNADO_SIGHTED] = 'Tornado reported !'; + badMessages[Messages.TRAFFIC_JAMS] = 'Frequent traffic jams reported'; + badMessages[Messages.TRAIN_CRASHED] = 'A train crashed '; + var goodMessages = {}; + goodMessages[Messages.REACHED_CAPITAL] = 'Population has reached 50,000'; + goodMessages[Messages.REACHED_CITY] = 'Population has reached 10,000'; + goodMessages[Messages.REACHED_MEGALOPOLIS] = 'Population has reached 500,000'; + goodMessages[Messages.REACHED_METROPOLIS] = 'Population has reached 100,000'; + goodMessages[Messages.REACHED_TOWN] = 'Population has reached 2,000'; + return { + badMessages: badMessages, + cityClass: cityClass, + crimeStrings: crimeStrings, + densityStrings: densityStrings, + gameLevel: gameLevel, + goodMessages: goodMessages, + landValueStrings: landValueStrings, + months: months, + neutralMessages: neutralMessages, + problems: problems, + pollutionStrings: pollutionStrings, + rateStrings: rateStrings, + toolMessages: toolMessages, + zoneTypes: zoneTypes + }; + }; + + const TXT = new Text(); + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class SpriteUtils { + static pixToWorld(p) { + return ZoneUtils.pixToWorld(p); + } + + static worldToPix(w) { + return ZoneUtils.worldToPix(w); + } // Attempt to move 45° towards the desired direction, either + // clockwise or anticlockwise, whichever gets us there quicker + + + static turnTo(presentDir, desiredDir) { + if (presentDir === desiredDir) return presentDir; + + if (presentDir < desiredDir) { + // select clockwise or anticlockwise + if (desiredDir - presentDir < 4) presentDir++;else presentDir--; + } else { + if (presentDir - desiredDir < 4) presentDir--;else presentDir++; + } + + if (presentDir > 8) presentDir = 1; + if (presentDir < 1) presentDir = 8; + return presentDir; + } + + static absoluteValue(x) { + return Math.abs(x); + } + + static getTileValue(map, x, y) { + let wX = ZoneUtils.pixToWorld(x); + let wY = ZoneUtils.pixToWorld(y); + if (wX < 0 || wX >= map.width || wY < 0 || wY >= map.height) return -1; + return map.getTileValue(wX, wY); + } // Choose the best direction to get from the origin to the destination + // If the destination is equidistant in both x and y deltas, a diagonal + // will be chosen, otherwise the most 'dominant' difference will be selected + // (so if a destination is 4 units north and 2 units east, north will be chosen). + // This code seems to always choose south if we're already there which seems like + // a bug + + + static getDir(orgX, orgY, destX, destY) { + let deltaX = destX - orgX; + let deltaY = destY - orgY; + let i; + + if (deltaX < 0) { + i = deltaY < 0 ? 11 : 8; + } else { + i = deltaY < 0 ? 2 : 5; + } + + deltaX = Math.abs(deltaX); + deltaY = Math.abs(deltaY); + if (deltaX * 2 < deltaY) i++;else if (deltaY * 2 < deltaX) i--; + if (i < 0 || i > 12) i = 0; + return Micro.directionTable[i]; + } + + static absoluteDistance(orgX, orgY, destX, destY) { + let deltaX = destX - orgX; + let deltaY = destY - orgY; + return Math.abs(deltaX) + Math.abs(deltaY); + } + + static checkWet(tileValue) { + if (tileValue === Tile.HPOWER || tileValue === Tile.VPOWER || tileValue === Tile.HRAIL || tileValue === Tile.VRAIL || tileValue === Tile.BRWH || tileValue === Tile.BRWV) return true;else return false; + } + + static destroyMapTile(spriteManager, map, blockMaps, ox, oy) { + let x = ZoneUtils.pixToWorld(ox); + let y = ZoneUtils.pixToWorld(oy); + if (!map.testBounds(x, y)) return; + let tile = map.getTile(x, y); + let tileValue = tile.getValue(); + if (tileValue < Tile.TREEBASE) return; + + if (!tile.isCombustible()) { + if (tileValue >= Tile.ROADBASE && tileValue <= Tile.LASTROAD) map.setTile(x, y, Tile.RIVER, 0); + return; + } + + if (tile.isZone()) { + ZoneUtils.fireZone(map, x, y, blockMaps); + if (tileValue > Tile.RZB) spriteManager.makeExplosionAt(ox, oy); + } + + if (SpriteUtils.checkWet(tileValue)) map.setTile(x, y, Tile.RIVER, 0);else map.setTile(x, y, Tile.TINYEXP, Tile.BULLBIT | Tile.ANIMBIT); + } + + static getDistance(x1, y1, x2, y2) { + return Math.abs(x1 - x2) + Math.abs(y1 - y2); + } + + static checkSpriteCollision(s1, s2) { + return s1.frame !== 0 && s2.frame !== 0 && SpriteUtils.getDistance(s1.x, s1.y, s2.x, s2.y) < 30; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BaseSprite { + constructor() {} + + init(type, map, spriteManager, x, y) { + this.type = type; + this.map = map; + this.spriteManager = spriteManager; + this.x = x; + this.y = y; + this.origX = 0; + this.origY = 0; + this.destX = 0; + this.destY = 0; + this.count = 0; + this.soundCount = 0; + this.dir = 0; + this.newDir = 0; + this.step = 0; + this.flag = 0; + this.turn = 0; + this.accel = 0; + this.speed = 100; + } + + getFileName() { + return ['obj', this.type, '-', this.frame - 1].join(''); + } + + spriteNotInBounds() { + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + return x < 0 || y < 0 || x >= this.map.width || y >= this.map.height; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class TrainSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_TRAIN, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 1; + this.dir = 4; + this.tileDeltaX = [0, 16, 0, -16]; + this.tileDeltaY = [-16, 0, 16, 0]; + this.xDelta = [0, 4, 0, -4, 0]; + this.yDelta = [-4, 0, 4, 0, 0]; + this.TrainPic2 = [1, 2, 1, 2, 5]; // Frame values + + this.NORTHSOUTH = 1; + this.EASTWEST = 2; + this.NWSE = 3; + this.NESW = 4; + this.UNDERWATER = 5; // Direction values + + this.NORTH = 0; + this.EAST = 1; + this.SOUTH = 2; + this.WEST = 3; + this.CANTMOVE = 4; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + // Trains can only move in the 4 cardinal directions + // Over the course of 4 frames, we move through a tile, so + // ever fourth frame, we try to find a direction to move in + // (excluding the opposite direction from the current direction + // of travel). If there is no possible direction found, our direction + // is set to CANTMOVE. (Thus, if we're in a dead end, we can start heading + // backwards next time round). If we fail to find a destination after 2 attempts, + // we die. + if (this.frame === this.NWSE || this.frame === this.NESW) this.frame = this.TrainPic2[this.dir]; + this.x += this.xDelta[this.dir]; + this.y += this.yDelta[this.dir]; // Find a new direction. + + if ((spriteCycle & 3) === 0) { + // Choose a random starting point for our search + let dir = math.getRandom16() & 3; + + for (let i = dir; i < dir + 4; i++) { + let dir2 = i & 3; + + if (this.dir !== this.CANTMOVE) { + // Avoid the opposite direction + if (dir2 === (this.dir + 2 & 3)) continue; + } + + let tileValue = SpriteUtils.getTileValue(this.map, this.x + this.tileDeltaX[dir2], this.y + this.tileDeltaY[dir2]); + + if (tileValue >= Tile.RAILBASE && tileValue <= Tile.LASTRAIL || tileValue === Tile.RAILVPOWERH || tileValue === Tile.RAILHPOWERV) { + if (this.dir !== dir2 && this.dir !== this.CANTMOVE) { + if (this.dir + dir2 === this.WEST) this.frame = this.NWSE;else this.frame = this.NESW; + } else { + this.frame = this.TrainPic2[dir2]; + } + + if (tileValue === Tile.HRAIL || tileValue === Tile.VRAIL) this.frame = this.UNDERWATER; + this.dir = dir2; + return; + } + } // Nowhere to go. Die. + + + if (this.dir === this.CANTMOVE) { + this.frame = 0; + return; + } // We didn't find a direction this time. We'll try the opposite + // next time around + + + this.dir = this.CANTMOVE; + } + } + + explodeSprite(messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.TRAIN_CRASHED); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BoatSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_SHIP, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + if (x < SpriteUtils.worldToPix(4)) this.frame = 3;else if (x >= SpriteUtils.worldToPix(map.width - 4)) this.frame = 7;else if (y < SpriteUtils.worldToPix(4)) this.frame = 5;else if (y >= SpriteUtils.worldToPix(map.height - 4)) this.frame = 1;else this.frame = 3; + this.newDir = this.frame; + this.dir = 10; + this.count = 1; + this.tileDeltaX = [0, 0, 1, 1, 1, 0, -1, -1, -1]; + this.tileDeltaY = [0, -1, -1, 0, 1, 1, 1, 0, -1]; + this.xDelta = [0, 0, 2, 2, 2, 0, -2, -2, -2]; + this.yDelta = [0, -2, -2, 0, 2, 2, 2, 0, -2]; + this.tileWhiteList = [Tile.RIVER, Tile.CHANNEL, Tile.POWERBASE, Tile.POWERBASE + 1, Tile.RAILBASE, Tile.RAILBASE + 1, Tile.BRWH, Tile.BRWV]; + this.CANTMOVE = 10; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + let t = Tile.RIVER; + let startDir, frame, dir, x, y, tileValue; + if (this.soundCount > 0) this.soundCount--; + + if (this.soundCount === 0) { + if ((math.getRandom16() & 3) === 1) { + // TODO Scenarios + // TODO Sound + messageManager.sendMessage(Messages.SOUND_HONKHONK); + } + + this.soundCount = 200; + } + + if (this.count > 0) this.count--; + + if (this.count === 0) { + // Ships turn slowly: only 45° every 9 cycles + this.count = 9; // If already executing a turn, continue to do so + + if (this.frame !== this.newDir) { + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + return; + } // Otherwise pick a new direction + // Choose a random starting direction to search from + // 0 = N, 1 = NE, ... 7 = NW + + + startDir = math.getRandom16() & 7; + frame = this.frame; + + for (dir = startDir; dir < startDir + 8; dir++) { + frame = (dir & 7) + 1; + if (frame === this.dir) continue; + x = SpriteUtils.pixToWorld(this.x) + this.tileDeltaX[frame]; + y = SpriteUtils.pixToWorld(this.y) + this.tileDeltaY[frame]; + + if (this.map.testBounds(x, y)) { + tileValue = this.map.getTileValue(x, y); // Test for a suitable water tile + + if (tileValue === Tile.CHANNEL || tileValue === Tile.BRWH || tileValue === Tile.BRWV || this.oppositeAndUnderwater(tileValue, this.dir, frame)) { + this.newDir = frame; + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + this.dir = frame + 4; + if (this.dir > 8) this.dir -= 8; + break; + } + } + } + + if (dir === startDir + 8) { + this.dir = this.CANTMOVE; + this.newDir = (math.getRandom16() & 7) + 1; + } + } else { + frame = this.frame; + + if (frame === this.newDir) { + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + } + + if (this.spriteNotInBounds()) { + this.frame = 0; + return; + } // If we didn't find a new direction, we might explode + // depending on the last tile we looked at. + + + for (let i = 0; i < 8; i++) { + if (t === this.tileWhiteList[i]) break; + + if (i === 7) { + this.explodeSprite(messageManager); + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } + } + } + + explodeSprite(messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.SHIP_CRASHED); + } // This is an odd little function. It returns true if + // oldDir is 180° from newDir and tileValue is underwater + // rail or wire, and returns false otherwise + + + oppositeAndUnderwater(tileValue, oldDir, newDir) { + let opposite = oldDir + 4; + if (opposite > 8) opposite -= 8; + if (newDir != opposite) return false; + if (tileValue == Tile.POWERBASE || tileValue == Tile.POWERBASE + 1 || tileValue == Tile.RAILBASE || tileValue == Tile.RAILBASE + 1) return true; + return false; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class MonsterSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_MONSTER, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x > SpriteUtils.worldToPix(map.width) / 2) { + if (y > SpriteUtils.worldToPix(map.height) / 2) this.frame = 10;else this.frame = 7; + } else if (y > SpriteUtils.worldToPix(map.height) / 2) { + this.frame = 1; + } else { + this.frame = 4; + } + + this.flag = 0; + this.count = 1000; + this.destX = SpriteUtils.worldToPix(map.pollutionMaxX); + this.destY = SpriteUtils.worldToPix(map.pollutionMaxY); + this.origX = this.x; + this.origY = this.y; + this._seenLand = false; + this.xDelta = [2, 2, -2, -2, 0]; + this.yDelta = [-2, 2, 2, -2, 0]; + this.cardinals1 = [0, 1, 2, 3]; + this.cardinals2 = [1, 2, 3, 0]; + this.diagonals1 = [2, 5, 8, 11]; + this.diagonals2 = [11, 2, 5, 8]; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + if (this.soundCount > 0) this.soundCount--; // Frames 1 - 12 are diagonal sprites, 3 for each direction. + // 1-3 NE, 2-6 SE, etc. 13-16 represent the cardinal directions. + + let currentDir = Math.floor((this.frame - 1) / 3); + let frame, dir; + + if (currentDir < 4) { + /* turn n s e w */ + // Calculate how far in the 3 step animation we were, + // move on to the next one + frame = (this.frame - 1) % 3; + if (frame === 2) this.step = 0; + if (frame === 0) this.step = 1; + if (this.step) frame++;else frame--; + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + + if (absDist < 60) { + if (this.flag === 0) { + this.flag = 1; + this.destX = this.origX; + this.destY = this.origY; + } else { + this.frame = 0; + return; + } + } // Perhaps switch to a cardinal direction + + + dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + dir = Math.floor((dir - 1) / 2); + + if (dir !== currentDir && math.getChance(10)) { + if (math.getRandom16() & 1) frame = this.cardinals1[currentDir];else frame = this.cardinals2[currentDir]; + currentDir = 4; + + if (!this.soundCount) { + messageManager.sendMessage(Messages.SOUND_MONSTER); + this.soundCount = 50 + math.getRandom(100); + } + } + } else { + // Travelling in a cardinal direction. Switch to a diagonal + currentDir = 4; + dir = this.frame; + frame = dir - 13 & 3; + + if (!(math.getRandom16() & 3)) { + if (math.getRandom16() & 1) frame = this.diagonals1[frame];else frame = this.diagonals2[frame]; // We mung currentDir and frame here to + // make the assignment below work + + currentDir = Math.floor((frame - 1) / 3); + frame = (frame - 1) % 3; + } + } + + frame = currentDir * 3 + frame + 1; + if (frame > 16) frame = 16; + this.frame = frame; + this.x += this.xDelta[currentDir]; + this.y += this.yDelta[currentDir]; + if (this.count > 0) this.count--; + let tileValue = SpriteUtils.getTileValue(this.map, this.x, this.y); + if (tileValue === -1 || tileValue === Tile.RIVER && this.count < 500) this.frame = 0; + if (tileValue === Tile.DIRT || tileValue > Tile.WATER_HIGH) this._seenLand = true; + let spriteList = this.spriteManager.getSpriteList(); + + for (let i = 0; i < spriteList.length; i++) { + let s = spriteList[i]; + if (s.frame !== 0 && (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && SpriteUtils.checkSpriteCollision(this, s)) s.explodeSprite(messageManager); + } + + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class CopterSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_HELICOPTER, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 5; + this.count = 1500; + this.destX = math.getRandom(SpriteUtils.worldToPix(map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(map.height)) + 8; + this.origX = x; + this.origY = y; + this.xDelta = [0, 0, 3, 5, 3, 0, -3, -5, -3]; + this.yDelta = [0, -5, -3, 0, 3, 5, 3, 0, -3]; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + if (this.soundCount > 0) this.soundCount--; + if (this.count > 0) this.count--; + + if (this.count === 0) { + // Head towards a monster, and certain doom + let s = this.spriteManager.getSprite(Micro.SPRITE_MONSTER); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + // No monsters. Hm. I bet flying near that tornado is sensible + s = this.spriteManager.getSprite(Micro.SPRITE_TORNADO); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + this.destX = this.origX; + this.destY = this.origY; + } + } // If near destination, let's get her on the ground + + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.origX, this.origY); + + if (absDist < 30) { + this.frame = 0; + return; + } + } + + if (this.soundCount === 0) { + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + + if (x >= 0 && x < this.map.width && y >= 0 && y < this.map.height) { + if (blockMaps.trafficDensityMap.worldGet(x, y) > 170 && (math.getRandom16() & 7) === 0) { + messageManager.sendMessage(Messages.HEAVY_TRAFFIC, { + x: x, + y: y + }); + messageManager.sendMessage(Messages.SOUND_HEAVY_TRAFFIC); + this.soundCount = 200; + } + } + } + + let frame = this.frame; + + if ((spriteCycle & 3) === 0) { + let dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, dir); + this.frame = frame; + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + + explodeSprite(messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.HELICOPTER_CRASHED); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class AirplaneSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_AIRPLANE, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x > SpriteUtils.worldToPix(map.width - 20)) { + this.destX = this.x - 200; + this.frame = 7; + } else { + this.destX = this.x + 200; + this.frame = 11; + } + + this.destY = this.y; + this.xDelta = [0, 0, 6, 8, 6, 0, -6, -8, -6, 8, 8, 8]; + this.yDelta = [0, -8, -6, 0, 6, 8, 6, 0, -6, 0, 0, 0]; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + let frame = this.frame; + + if (spriteCycle % 5 === 0) { + // Frames > 8 mean the plane is taking off + if (frame > 8) { + frame--; + + if (frame < 9) { + // Planes always take off to the east + frame = 3; + } + + this.frame = frame; + } else { + let d = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, d); + this.frame = frame; + } + } + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + + if (absDist < 50) { + // We're pretty close to the destination + this.destX = math.getRandom(SpriteUtils.worldToPix(this.map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(this.map.height)) + 8; + } + + if (disasterManager.enableDisasters) { + let explode = false; + let spriteList = this.spriteManager.getSpriteList(); + + for (let i = 0; i < spriteList.length; i++) { + let s = spriteList[i]; //if (s.frame === 0 || s === sprite) continue; + + if (s.frame === 0) continue; + + if ((s.type === Micro.SPRITE_HELICOPTER || s.type === Micro.SPRITE_AIRPLANE) && SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + explode = true; + } + } + + if (explode) this.explodeSprite(messageManager); + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + if (this.spriteNotInBounds()) this.frame = 0; + } + + explodeSprite(messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.PLANE_CRASHED); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class TornadoSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_TORNADO, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -40; + this.frame = 1; + this.count = 200; + this.xDelta = [2, 3, 2, 0, -2, -3]; + this.yDelta = [-2, 0, 2, 3, 2, 0]; + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + let frame; + frame = this.frame; // If middle frame, move right or left + // depending on the flag value + // If frame = 1, perhaps die based on flag + // value + + if (frame === 2) { + if (this.flag) frame = 3;else frame = 1; + } else { + if (frame === 1) this.flag = 1;else this.flag = 0; + frame = 2; + } + + if (this.count > 0) this.count--; + this.frame = frame; + let spriteList = this.spriteManager.getSpriteList(); + + for (let i = 0; i < spriteList.length; i++) { + let s = spriteList[i]; // Explode vulnerable sprites + + if (s.frame !== 0 && (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + } + } + + frame = Random.getRandom(5); + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + if (this.spriteNotInBounds()) this.frame = 0; + if (this.count !== 0 && Random.getRandom(500) === 0) this.frame = 0; + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } + + } + /* + + // Metadata for image loading + Object.defineProperties(TornadoSprite, + {ID: Micro.makeConstantDescriptor(6), + width: Micro.makeConstantDescriptor(48), + frames: Micro.makeConstantDescriptor(3)}); + + + return TornadoSprite; + }); + */ + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class ExplosionSprite extends BaseSprite { + constructor(map, spriteManager, x, y) { + super(); + this.init(Micro.SPRITE_EXPLOSION, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + this.frame = 1; + } + + startFire(x, y) { + x = ZoneUtils.pixToWorld(x); + y = ZoneUtils.pixToWorld(y); + if (!this.map.testBounds(x, y)) return; + let tile = this.map.getTile(x, y); + let tileValue = tile.getValue(); + if (!tile.isCombustible() && tileValue !== Tile.DIRT) return; + if (tile.isZone()) return; + this.map.setTo(x, y, ZoneUtils.randomFire()); + } + + move(spriteCycle, messageManager, disasterManager, blockMaps) { + if ((spriteCycle & 1) === 0) { + if (this.frame === 1) { + // Convert sprite coordinates to tile coordinates. + let explosionX = ZoneUtils.pixToWorld(this.x); + let explosionY = ZoneUtils.pixToWorld(this.y); + messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + messageManager.sendMessage(Messages.EXPLOSION_REPORTED, { + x: explosionX, + y: explosionY + }); + } + + this.frame++; + } + + if (this.frame > 6) { + this.frame = 0; + this.startFire(this.x, this.y); + this.startFire(this.x - 16, this.y - 16); + this.startFire(this.x + 16, this.y + 16); + this.startFire(this.x - 16, this.y + 16); + this.startFire(this.x + 16, this.y + 16); + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const constructors = {}; + constructors[Micro.SPRITE_TRAIN] = TrainSprite; + constructors[Micro.SPRITE_SHIP] = BoatSprite; + constructors[Micro.SPRITE_MONSTER] = MonsterSprite; + constructors[Micro.SPRITE_HELICOPTER] = CopterSprite; + constructors[Micro.SPRITE_AIRPLANE] = AirplaneSprite; + constructors[Micro.SPRITE_TORNADO] = TornadoSprite; + constructors[Micro.SPRITE_EXPLOSION] = ExplosionSprite; + class SpriteManager { + constructor(map) { + this.spriteList = []; + this.map = map; + this.spriteCycle = 0; + } + + getSprite(type) { + let filteredList = this.spriteList.filter(function (s) { + return s.frame !== 0 && s.type === type; + }); + if (filteredList.length === 0) return null; + return filteredList[0]; + } + + getSpriteList() { + return this.spriteList.slice(); + } + + getSpritesInView(startX, startY, lastX, lastY) { + startX = SpriteUtils.worldToPix(startX); + startY = SpriteUtils.worldToPix(startY); + lastX = SpriteUtils.worldToPix(lastX); + lastY = SpriteUtils.worldToPix(lastY); + return this.spriteList.filter(function (s) { + return s.x + s.xOffset >= startX && s.y + s.yOffset >= startY && !(s.x + s.xOffset >= lastX && s.y + s.yOffset >= lastY); + }); + } + + moveObjects(simData) { + if (!simData) simData = Micro.simData; + let messageManager = simData.messageManager; + let disasterManager = simData.disasterManager; + let blockMaps = simData.blockMaps; + this.spriteCycle += 1; + let list = this.spriteList.slice(); + let i = list.length; + + while (i--) { + //for (let i = 0, l = list.length; i < l; i++) { + let sprite = list[i]; + if (sprite.frame === 0) continue; + sprite.move(this.spriteCycle, messageManager, disasterManager, blockMaps); + } + + this.pruneDeadSprites(); + } + + makeSprite(type, x, y) { + this.spriteList.push(new constructors[type](this.map, this, x, y)); + } + + makeTornado(messageManager) { + let sprite = this.getSprite(Micro.SPRITE_TORNADO); + + if (sprite !== null) { + sprite.count = 200; + return; + } + + let x = math.getRandom(SpriteUtils.worldToPix(this.map.width) - 800) + 400; + let y = math.getRandom(SpriteUtils.worldToPix(this.map.height) - 200) + 100; + this.makeSprite(Micro.SPRITE_TORNADO, x, y); + messageManager.sendMessage(Messages.TORNADO_SIGHTED, { + x: SpriteUtils.pixToWorld(x), + y: SpriteUtils.pixToWorld(y) + }); + } + + makeExplosion(x, y) { + if (this.map.testBounds(x, y)) this.makeExplosionAt(SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + makeExplosionAt(x, y) { + this.makeSprite(Micro.SPRITE_EXPLOSION, x, y); + } + + generatePlane(x, y) { + if (this.getSprite(Micro.SPRITE_AIRPLANE) !== null) return; + this.makeSprite(Micro.SPRITE_AIRPLANE, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + generateTrain(census, x, y) { + if (census.totalPop > 20 && this.getSprite(Micro.SPRITE_TRAIN) === null && math.getRandom(25) === 0) this.makeSprite(Micro.SPRITE_TRAIN, SpriteUtils.worldToPix(x) + 8, SpriteUtils.worldToPix(y) + 8); + } + + generateShip() { + // XXX This code is borked. The map generator will never + // place a channel tile on the edges of the map + let x, y; + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, 0) === Tile.CHANNEL) { + this.makeShipHere(x, 0); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(0, y) === Tile.CHANNEL) { + this.makeShipHere(0, y); + return; + } + } + } + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, this.map.height - 1) === Tile.CHANNEL) { + this.makeShipHere(x, this.map.height - 1); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(this.map.width - 1, y) === Tile.CHANNEL) { + this.makeShipHere(this.map.width - 1, y); + return; + } + } + } + } + + getBoatDistance(x, y) { + let dist = 99999; + let pixelX = SpriteUtils.worldToPix(x) + 8; + let pixelY = SpriteUtils.worldToPix(y) + 8; + let sprite; + + for (let i = 0, l = this.spriteList.length; i < l; i++) { + sprite = this.spriteList[i]; + + if (sprite.type === Micro.SPRITE_SHIP && sprite.frame !== 0) { + //let sprDist = Micro.absoluteValue(sprite.x - pixelX) + Micro.absoluteValue(sprite.y - pixelY); + let sprDist = Math.abs(sprite.x - pixelX) + Math.abs(sprite.y - pixelY); + dist = Math.min(dist, sprDist); + } + } + + return dist; + } + + makeShipHere(x, y) { + this.makeSprite(Micro.SPRITE_SHIP, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + generateCopter(x, y) { + if (this.getSprite(Micro.SPRITE_HELICOPTER) !== null) return; + this.makeSprite(Micro.SPRITE_HELICOPTER, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + makeMonsterAt(messageManager, x, y) { + this.makeSprite(Micro.SPRITE_MONSTER, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + messageManager.sendMessage(Messages.MONSTER_SIGHTED, { + x: x, + y: y + }); + } + + makeMonster(messageManager) { + let sprite = this.getSprite(Micro.SPRITE_MONSTER); + + if (sprite !== null) { + sprite.soundCount = 1; + sprite.count = 1000; + sprite.destX = SpriteUtils.worldToPix(this.map.pollutionMaxX); + sprite.destY = SpriteUtils.worldToPix(this.map.pollutionMaxY); + } + + let done = 0; + + for (let i = 0; i < 300; i++) { + let x = math.getRandom(this.map.width - 20) + 10; + let y = math.getRandom(this.map.height - 10) + 5; + let tile = this.map.getTile(x, y); + + if (tile.getValue() === Tile.RIVER) { + this.makeMonsterAt(messageManager, x, y); + done = 1; + break; + } + } + + if (done === 0) this.makeMonsterAt(messageManager, 60, 50); + } + + pruneDeadSprites(type) { + this.spriteList = this.spriteList.filter(function (s) { + return s.frame !== 0; + }); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class EvaluationUtils { + static getTrafficAverage(blockMaps, census) { + var trafficDensityMap = blockMaps.trafficDensityMap; + var landValueMap = blockMaps.landValueMap; + var trafficTotal = 0; + var count = 1; + + for (var x = 0; x < landValueMap.gameMapWidth; x += landValueMap.blockSize) { + for (var y = 0; y < landValueMap.gameMapHeight; y += landValueMap.blockSize) { + if (landValueMap.worldGet(x, y) > 0) { + trafficTotal += trafficDensityMap.worldGet(x, y); + count++; + } + } + } + + var trafficAverage = Math.floor(trafficTotal / count) * 2.4; //census.trafficAverage = trafficAverage //?? + + return trafficAverage; + } + + static getUnemployment(census) { + var b = (census.comPop + census.indPop) * 8; + if (b === 0) return 0; // Ratio total people / working. At least 1. + + var r = census.resPop / b; + b = Math.round((r - 1) * 255); + return Math.min(b, 255); + } + + static getFireSeverity(census) { + return Math.min(census.firePop * 5, 255); + } + + } + class Evaluation { + constructor(gameLevel) { + this.problemVotes = []; + this.problemOrder = []; + this.evalInit(); + this.gameLevel = '' + gameLevel; + this.changed = false; + } + + save(saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) saveData[Micro.EvalProps[i]] = this[Micro.EvalProps[i]]; + } + + load(saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) this[Micro.EvalProps[i]] = saveData[Micro.EvalProps[i]]; + } + + cityEvaluation(simData) { + if (!simData) simData = Micro.simData; + var census = simData.census; + + if (census.totalPop > 0) { + Micro.problemData = []; //var problemTable = []; + + for (var i = 0; i < Micro.NUMPROBLEMS; i++) Micro.problemData.push(0); + + this.getAssessedValue(census); + this.getPopulation(census); + this.doProblems(simData.census, simData.budget, simData.blockMaps); + this.getScore(simData); + this.doVotes(); + this.changeEval(); + } else { + this.evalInit(); + this.cityYes = 50; + this.changeEval(); + } + } + + evalInit() { + let i; + this.cityYes = 0; + this.cityPop = 0; + this.cityPopDelta = 0; + this.cityAssessedValue = 0; + this.cityClass = Micro.CC_VILLAGE; + this.cityClassLast = Micro.CC_VILLAGE; + this.cityScore = 500; + this.cityScoreDelta = 0; + + for (i = 0; i < Micro.NUMPROBLEMS; i++) this.problemVotes[i] = { + index: i, + voteCount: 0 + }; + + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) this.problemOrder[i] = Micro.NUMPROBLEMS; + } + + getAssessedValue(census) { + var value; + value = census.roadTotal * 5; + value += census.railTotal * 10; + value += census.policeStationPop * 1000; + value += census.fireStationPop * 1000; + value += census.hospitalPop * 400; + value += census.stadiumPop * 3000; + value += census.seaportPop * 5000; + value += census.airportPop * 10000; + value += census.coalPowerPop * 3000; + value += census.nuclearPowerPop * 6000; + this.cityAssessedValue = value * 1000; + } + + getPopulation(census) { + let oldPopulation = this.cityPop; + this.cityPop = (census.resPop + (census.comPop + census.indPop) * 8) * 20; + this.cityPopDelta = this.cityPop - oldPopulation; + if (this.cityPopDelta !== 0) EventEmitter.emitEvent(Messages.POPULATION_UPDATED, this.cityPop); + return this.cityPop; + } + + getCityClass(cityPopulation) { + this.cityClass = Micro.CC_VILLAGE; + if (cityPopulation > 2000) this.cityClass = Micro.CC_TOWN; + if (cityPopulation > 10000) this.cityClass = Micro.CC_CITY; + if (cityPopulation > 50000) this.cityClass = Micro.CC_CAPITAL; + if (cityPopulation > 100000) this.cityClass = Micro.CC_METROPOLIS; + if (cityPopulation > 500000) this.cityClass = Micro.CC_MEGALOPOLIS; + + if (this.cityClass !== this.cityClassLast) { + this.cityClassLast = this.cityClass; + EventEmitter.emitEvent(Messages.CLASSIFICATION_UPDATED, this.cityClass); + } + + return this.cityClass; + } + + voteProblems() { + for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + this.problemVotes[i].index = i; + this.problemVotes[i].voteCount = 0; + } + + var problem = 0; + var voteCount = 0; + var loopCount = 0; + + while (voteCount < 100 && loopCount < 600) { + var voterProblemTolerance = math.getRandom(300); + + if (Micro.problemData[problem] > voterProblemTolerance) { + this.problemVotes[problem].voteCount += 1; + voteCount++; + } + + problem = (problem + 1) % Micro.NUMPROBLEMS; + loopCount++; + } + } + + doProblems(census, budget, blockMaps) { + //var problemTaken = []; + + /*for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + problemTaken[i] = false; + problemTable[i] = 0; + }*/ + Micro.problemData[Micro.CRIME] = census.crimeAverage; + Micro.problemData[Micro.POLLUTION] = census.pollutionAverage; + Micro.problemData[Micro.HOUSING] = census.landValueAverage * 7 / 10; + Micro.problemData[Micro.TAXES] = budget.cityTax * 10; + Micro.problemData[Micro.TRAFFIC] = EvaluationUtils.getTrafficAverage(blockMaps, census); + Micro.problemData[Micro.UNEMPLOYMENT] = EvaluationUtils.getUnemployment(census); + Micro.problemData[Micro.FIRE] = EvaluationUtils.getFireSeverity(census); + this.voteProblems(); // Rank the problems + + this.problemVotes.sort(function (a, b) { + return b.voteCount - a.voteCount; + }); + this.problemOrder = this.problemVotes.map(function (pv, i) { + if (i >= Micro.NUM_COMPLAINTS || pv.voteCount === 0) return null; + return pv.index; + }); + /*for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + // Find biggest problem not taken yet + var maxVotes = 0; + var bestProblem = Micro.NUMPROBLEMS; + for (var j = 0; j < Micro.NUMPROBLEMS; j++) { + if ((this.problemVotes[j] > maxVotes) && (!problemTaken[j])) { + bestProblem = j; + maxVotes = this.problemVotes[j]; + } + } + // bestProblem == NUMPROBLEMS means no problem found + this.problemOrder[i] = bestProblem; + if (bestProblem < Micro.NUMPROBLEMS) { + problemTaken[bestProblem] = true; + } + }*/ + } + + getScore(simData) { + var census = simData.census; + var budget = simData.budget; + var valves = simData.valves; + var cityScoreLast; + cityScoreLast = this.cityScore; + var score = 0; + + for (var i = 0; i < Micro.NUMPROBLEMS; i++) score += Micro.problemData[i]; + + score = Math.floor(score / 3); + score = (250 - Math.min(score, 250)) * 4; //score = Math.min(score, 256); + //score = math.clamp((256 - score) * 4, 0, 1000); + // Penalise the player by 15% if demand for any type of zone is capped due + // to lack of suitable buildings + + let demandPenalty = 0.85; + if (valves.resCap) score = Math.round(score * demandPenalty); + if (valves.comCap) score = Math.round(score * demandPenalty); + if (valves.indCap) score = Math.round(score * demandPenalty); // Penalize if roads/rail underfunded + + if (budget.roadEffect < budget.MAX_ROAD_EFFECT) score -= budget.MAX_ROAD_EFFECT - budget.roadEffect; // Penalize player by up to 10% for underfunded police and fire services + + if (budget.policeEffect < budget.MAX_POLICE_STATION_EFFECT) { + score = Math.round(score * (0.9 + budget.policeEffect / (10 * budget.MAX_POLICE_STATION_EFFECT))); + } + + if (budget.fireEffect < budget.MAX_FIRE_STATION_EFFECT) { + score = Math.round(score * (0.9 + budget.fireEffect / (10 * budget.MAX_FIRE_STATION_EFFECT))); + } // Penalise the player by 15% if demand for any type of zone has collapsed due to overprovision + + + if (valves.resValve < -1000) score = Math.round(score * 0.85); + if (valves.comValve < -1000) score = Math.round(score * 0.85); + if (valves.indValve < -1000) score = Math.round(score * 0.85); + var scale = 1.0; + + if (this.cityPop === 0 || this.cityPopDelta === 0 || this.cityPopDelta === this.cityPop) { + // Leave score unchanged if city is empty, if there hasn't been any migration, if the + // initial settlers have just arrived, or if the city has doubled in size + scale = 1.0; + } else if (this.cityPopDelta > 0) { + // If the city is growing, scale score by percentage growth in population + scale = this.cityPopDelta / this.cityPop + 1.0; + } else if (this.cityPopDelta < 0) { + // If the city is shrinking, scale down by up to 5% based on level of outward migration + scale = 0.95 + Math.floor(this.cityPopDelta / (this.cityPop - this.cityPopDelta)); + } + + score = Math.round(score * scale); // Penalize player for having fires and a burdensome tax rate + + score = score - EvaluationUtils.getFireSeverity(census) - budget.cityTax; // dec score for fires and tax + // Penalize player based on ratio of unpowered zones to total zones + + scale = census.unpoweredZoneCount + census.poweredZoneCount; // dec score for unpowered zones + + if (scale > 0.0) score = Math.round(score * (census.poweredZoneCount / scale)); // Force in to range 0-1000. New score is average of last score and new computed value + + score = math.clamp(score, 0, 1000); + this.cityScore = Math.round((this.cityScore + score) / 2); + this.cityScoreDelta = this.cityScore - cityScoreLast; + if (this.cityScoreDelta !== 0) EventEmitter.emitEvent(Messages.SCORE_UPDATED, this.cityScore); + } + + doVotes() { + this.cityYes = 0; + + for (let i = 0; i < 100; i++) { + let voterExpectation = math.getRandom(1000); + if (this.cityScore > voterExpectation) this.cityYes++; + } + } + + changeEval() { + this.changed = true; + } + + countProblems() { + var i; + + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + if (this.problemOrder[i] === Micro.NUMPROBLEMS) break; + } + + return i; + } + + getProblemNumber(i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] === Micro.NUMPROBLEMS) return -1;else return this.problemOrder[i]; + } + + getProblemVotes(i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] == Micro.NUMPROBLEMS) return -1;else return this.problemVotes[this.problemOrder[i]].voteCount; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class Valves { + constructor() { + this.resValve = 0; + this.comValve = 0; + this.indValve = 0; + this.resCap = false; + this.comCap = false; + this.indCap = false; + } + + save(saveData) { + saveData.resValve = this.resValve; + saveData.comValve = this.comValve; + saveData.indValve = this.indValve; + } + + load(saveData) { + this.resValve = saveData.resValve; + this.comValve = saveData.comValve; + this.indValve = saveData.indValve; + EventEmitter.emitEvent(Messages.VALVES_UPDATED, { + residential: this.resValve, + commercial: this.comValve, + industrial: this.indValve + }); + } + + setValves(gameLevel, census, budget) { + var resPopDenom = 8; + var birthRate = 0.02; + var labourBaseMax = 1.3; + var internalMarketDenom = 3.7; + var projectedIndPopMin = 5.0; + var resRatioDefault = 1.3; + var resRatioMax = 2; + var comRatioMax = 2; + var indRatioMax = 2; + var taxMax = 20; + var taxTableScale = 600; + var employment, labourBase; // Residential zones scale their population index when reporting it to the census + + var normalizedResPop = census.resPop / resPopDenom; + census.totalPop = Math.round(normalizedResPop + census.comPop + census.indPop); // A lack of developed commercial and industrial zones means there are no employment opportunities, which constrain + // growth. (This might hurt initially if, for example, the player lays out an initial grid, as the residential zones + // will likely develop first, so the residential valve will immediately crater). + + if (census.resPop > 0) employment = (census.comHist10[1] + census.indHist10[1]) / normalizedResPop;else employment = 1; // Given the employment rate, calculate expected migration, add in births, and project the new population. + + var migration = normalizedResPop * (employment - 1); + var births = normalizedResPop * birthRate; + var projectedResPop = normalizedResPop + migration + births; // Examine how many zones require workers + + labourBase = census.comHist10[1] + census.indHist10[1]; + if (labourBase > 0.0) labourBase = census.resHist10[1] / labourBase;else labourBase = 1; + labourBase = math.clamp(labourBase, 0.0, labourBaseMax); // Project future industry and commercial needs, taking into account available labour, and competition from + // other global cities + + var internalMarket = (normalizedResPop + census.comPop + census.indPop) / internalMarketDenom; + var projectedComPop = internalMarket * labourBase; + var projectedIndPop = census.indPop * labourBase * Micro.extMarketParamTable[gameLevel]; + projectedIndPop = Math.max(projectedIndPop, projectedIndPopMin); // Calculate the expected percentage changes in each population type + + var resRatio; + if (normalizedResPop > 0) resRatio = projectedResPop / normalizedResPop;else resRatio = resRatioDefault; + var comRatio; + if (census.comPop > 0) comRatio = projectedComPop / census.comPop;else comRatio = projectedComPop; + var indRatio; + if (census.indPop > 0) indRatio = projectedIndPop / census.indPop;else indRatio = projectedIndPop; + resRatio = Math.min(resRatio, resRatioMax); + comRatio = Math.min(comRatio, comRatioMax); + indRatio = Math.min(indRatio, indRatioMax); // Global tax and game level effects. + + var z = Math.min(budget.cityTax + gameLevel, taxMax); + resRatio = (resRatio - 1) * taxTableScale + Micro.taxTable[z]; + comRatio = (comRatio - 1) * taxTableScale + Micro.taxTable[z]; + indRatio = (indRatio - 1) * taxTableScale + Micro.taxTable[z]; // Ratios are velocity changes to valves. + + this.resValve = math.clamp(this.resValve + Math.round(resRatio), -Micro.RES_VALVE_RANGE, Micro.RES_VALVE_RANGE); + this.comValve = math.clamp(this.comValve + Math.round(comRatio), -Micro.COM_VALVE_RANGE, Micro.COM_VALVE_RANGE); + this.indValve = math.clamp(this.indValve + Math.round(indRatio), -Micro.IND_VALVE_RANGE, Micro.IND_VALVE_RANGE); + if (this.resCap && this.resValve > 0) this.resValve = 0; + if (this.comCap && this.comValve > 0) this.comValve = 0; + if (this.indCap && this.indValve > 0) this.indValve = 0; + EventEmitter.emitEvent(Messages.VALVES_UPDATED, { + residential: this.resValve, + commercial: this.comValve, + industrial: this.indValve + }); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class Budget { + constructor() { + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + this.totalFunds = 0; + this.cityTax = 7; + this.cashFlow = 0; + this.taxFund = 0; // These values denote how much money is required to fully maintain the relevant services + + this.roadMaintenanceBudget = 0; + this.fireMaintenanceBudget = 0; + this.policeMaintenanceBudget = 0; // Percentage of budget used + + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; // Cash value of spending. Should equal Math.round(_Fund * _Percent) + + this.roadSpend = 0; + this.fireSpend = 0; + this.policeSpend = 0; + this.awaitingValues = false; + this.autoBudget = true; + } + + save(saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) saveData[Micro.BudgetProps[i]] = this[Micro.BudgetProps[i]]; + } + + load(saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) this[Micro.BudgetProps[i]] = saveData[Micro.BudgetProps[i]]; + + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + } + + setAutoBudget(value) { + this.autoBudget = value; + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + } // Calculates the best possible outcome in terms of funding the various services + // given the player's current funds and tax yield. On entry, roadPercent etc. are + // assumed to contain the desired percentage level, and taxFunds should contain the + // most recent tax collected. On exit, the *Percent members will be updated with what + // we can actually afford to spend. Returns an object containing the amount of cash + // that would be spent on each service. + + + _calculateBestPercentages() { + // How much would we be spending based on current percentages? + // Note: the *Budget items are updated every January by collectTax + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); + var total = this.roadSpend + this.fireSpend + this.policeSpend; // If we don't have any services on the map, we can bail early + + if (total === 0) { + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; + return { + road: 1, + fire: 1, + police: 1 + }; + } // How much are we actually going to spend? + + + var roadCost = 0; + var fireCost = 0; + var policeCost = 0; + var cashRemaining = this.totalFunds + this.taxFund; // Spending priorities: road, fire, police + + if (cashRemaining >= this.roadSpend) roadCost = this.roadSpend;else roadCost = cashRemaining; + cashRemaining -= roadCost; + if (cashRemaining >= this.fireSpend) fireCost = this.fireSpend;else fireCost = cashRemaining; + cashRemaining -= fireCost; + if (cashRemaining >= this.policeSpend) policeCost = this.policeSpend;else policeCost = cashRemaining; + cashRemaining -= policeCost; + if (this.roadMaintenanceBudget > 0) this.roadPercent = (roadCost / this.roadMaintenanceBudget).toPrecision(2) - 0;else this.roadPercent = 1; + if (this.fireMaintenanceBudget > 0) this.firePercent = (fireCost / this.fireMaintenanceBudget).toPrecision(2) - 0;else this.firePercent = 1; + if (this.policeMaintenanceBudget > 0) this.policePercent = (policeCost / this.policeMaintenanceBudget).toPrecision(2) - 0;else this.policePercent = 1; + return { + road: roadCost, + police: policeCost, + fire: fireCost + }; + } // User initiated budget + + + doBudgetWindow() { + //doBudgetMenu + return this.doBudgetNow(true); + } + + doBudgetNow(fromWindow) { + var costs = this._calculateBestPercentages(); + + if (!this.autoBudget && !fromWindow) { + this.autoBudget = false; + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + return; + } + + var roadCost = costs.road; + var policeCost = costs.police; + var fireCost = costs.fire; + var totalCost = roadCost + policeCost + fireCost; + var cashRemaining = this.totalFunds + this.taxFund - totalCost; // Autobudget + + if (cashRemaining > 0 && this.autoBudget || fromWindow) { + // Either we were able to fully fund services, or we have just normalised user input. Go ahead and spend. + this.awaitingValues = false; + this.doBudgetSpend(roadCost, fireCost, policeCost); + return; + } // Uh-oh. Not enough money. Make this the user's problem. + // They don't know it yet, but they're about to get a budget window. + + + this.setAutoBudget(false); + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + EventEmitter.emitEvent(Messages.NO_MONEY); + } + + doBudgetSpend(roadValue, fireValue, policeValue) { + this.roadSpend = roadValue; + this.fireSpend = fireValue; + this.policeSpend = policeValue; + var total = this.roadSpend + this.fireSpend + this.policeSpend; + this.spend(-(this.taxFund - total)); + this.updateFundEffects(); + } + + updateFundEffects() { + // The caller is assumed to have correctly set the percentage spend + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); // Update the effect this level of spending will have on infrastructure deterioration + + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + if (this.roadMaintenanceBudget > 0) this.roadEffect = Math.floor(this.roadEffect * this.roadSpend / this.roadMaintenanceBudget); + if (this.fireMaintenanceBudget > 0) this.fireEffect = Math.floor(this.fireEffect * this.fireSpend / this.fireMaintenanceBudget); + if (this.policeMaintenanceBudget > 0) this.policeEffect = Math.floor(this.policeEffect * this.policeSpend / this.policeMaintenanceBudget); + } + + collectTax(gameLevel, census) { + this.cashFlow = 0; // How much would it cost to fully fund every service? + + this.policeMaintenanceBudget = census.policeStationPop * Micro.policeMaintenanceCost; + this.fireMaintenanceBudget = census.fireStationPop * Micro.fireMaintenanceCost; + var roadCost = census.roadTotal * Micro.roadMaintenanceCost; + var railCost = census.railTotal * Micro.railMaintenanceCost; + this.roadMaintenanceBudget = Math.floor((roadCost + railCost) * Micro.RLevels[gameLevel]); + this.taxFund = Math.floor(Math.floor(census.totalPop * census.landValueAverage / 120) * this.cityTax * Micro.FLevels[gameLevel]); + + if (census.totalPop > 0) { + this.cashFlow = this.taxFund - (this.policeMaintenanceBudget + this.fireMaintenanceBudget + this.roadMaintenanceBudget); + this.doBudgetNow(false); + } else { + // We don't want roads etc deteriorating when population hasn't yet been established + // (particularly early game) + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + } + } + + setTax(amount) { + if (amount === this.cityTax) return; + this.cityTax = amount; + } + + setFunds(amount) { + if (amount === this.totalFunds) return; + this.totalFunds = Math.max(0, amount); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + if (this.totalFunds === 0) EventEmitter.emitEvent(Messages.NO_MONEY); + } + + spend(amount) { + this.setFunds(this.totalFunds - amount); + } + + shouldDegradeRoad() { + return this.roadEffect < Math.floor(15 * this.MAX_ROAD_EFFECT / 16); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class Census { + constructor() { + this.clearCensus(); + this.changed = false; + this.crimeRamp = 0; + this.pollutionRamp = 0; // Set externally + + this.landValueAverage = 0; + this.pollutionAverage = 0; + this.crimeAverage = 0; + this.totalPop = 0; + + var createArray = function (arrName) { + //this[arrName] = new M_ARRAY_TYPE(120); + this[arrName] = []; //for (var a = 0; a < 120; a++) this[arrName][a] = 0; + + var a = 120; + + while (a--) this[arrName][a] = 0; + }; //for (var i = 0; i < Micro.arrs.length; i++) { + + + let i = Micro.arrs.length; + + while (i--) { + var name10 = Micro.arrs[i] + 'Hist10'; + var name120 = Micro.arrs[i] + 'Hist120'; + createArray.call(this, name10); + createArray.call(this, name120); + } + } + + save(saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) saveData[Micro.CensusProps[i]] = this[Micro.CensusProps[i]]; + } + + load(saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) this[Micro.CensusProps[i]] = saveData[Micro.CensusProps[i]]; + } + + clearCensus() { + this.poweredZoneCount = 0; + this.unpoweredZoneCount = 0; + this.firePop = 0; + this.roadTotal = 0; + this.railTotal = 0; + this.resPop = 0; + this.comPop = 0; + this.indPop = 0; + this.resZonePop = 0; + this.comZonePop = 0; + this.indZonePop = 0; + this.hospitalPop = 0; + this.churchPop = 0; + this.policeStationPop = 0; + this.fireStationPop = 0; + this.stadiumPop = 0; + this.coalPowerPop = 0; + this.nuclearPowerPop = 0; + this.seaportPop = 0; + this.airportPop = 0; + } + + take10Census(budget) { + var resPopDenom = 8; + MiscUtils.rotate10Arrays.call(this); + this.resHist10[0] = Math.floor(this.resPop / resPopDenom); + this.comHist10[0] = this.comPop; + this.indHist10[0] = this.indPop; + this.crimeRamp += Math.floor((this.crimeAverage - this.crimeRamp) / 4); + this.crimeHist10[0] = Math.min(this.crimeRamp, 255); + this.pollutionRamp += Math.floor((this.pollutionAverage - this.pollutionRamp) / 4); + this.pollutionHist10[0] = Math.min(this.pollutionRamp, 255); + var x = Math.floor(budget.cashFlow / 20) + 128; + this.moneyHist10[0] = math.clamp(x, 0, 255); + this.resPop >> 8; + if (this.hospitalPop < this.resPopScaled) this.needHospital = 1;else if (this.hospitalPop > this.resPopScaled) this.needHospital = -1;else if (this.hospitalPop === this.resPopScaled) this.needHospital = 0; + this.changed = true; + } + + take120Census() { + MiscUtils.rotate120Arrays.call(this); + var resPopDenom = 8; + this.resHist120[0] = Math.floor(this.resPop / resPopDenom); + this.comHist120[0] = this.comPop; + this.indHist120[0] = this.indPop; + this.crimeHist120[0] = this.crimeHist10[0]; + this.pollutionHist120[0] = this.pollutionHist10[0]; + this.moneyHist120[0] = this.moneyHist10[0]; + this.changed = true; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BlockMap { + constructor(gameMapWidth, gameMapHeight, blockSize) { + if (gameMapWidth === undefined || gameMapHeight === undefined || blockSize === undefined) throw new Error('Invalid dimensions for block map'); + this.isBlockMap = true; + this.blockSize = blockSize; + this.gameMapWidth = gameMapWidth; + this.gameMapHeight = gameMapHeight; + this.width = Math.floor((gameMapWidth + blockSize - 1) / blockSize); + this.height = Math.floor((gameMapHeight + blockSize - 1) / blockSize); + this.data = []; + this.clear(); + } + + clear() { + let x, + y = this.height; + + while (y--) { + x = this.width; + + while (x--) { + this.data[this.width * y + x] = 0; + } + } + } + + copyFrom(sourceMap, sourceFn) { + if (sourceMap.width !== this.width || sourceMap.height !== this.height || sourceMap.blockSize !== this.blockSize) console.warn('Copying from incompatible blockMap!'); + let x, + y, + height = sourceMap.height, + width = sourceMap.width; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + this.data[width * y + x] = sourceFn(sourceMap.data[width * y + x]); + } + } + } + + get(x, y) { + return this.data[this.width * y + x]; + } + + set(x, y, value) { + this.data[this.width * y + x] = value; + } + + toBlock(num) { + return Math.floor(num / this.blockSize); + } + + worldGet(x, y) { + return this.get(this.toBlock(x), this.toBlock(y)); + } + + worldSet(x, y, value) { + this.set(this.toBlock(x), this.toBlock(y), value); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const Direction = { + INVALID: -1, + NORTH: 0, + NORTHEAST: 1, + EAST: 2, + SOUTHEAST: 3, + SOUTH: 4, + SOUTHWEST: 5, + WEST: 6, + NORTHWEST: 7, + BEGIN: 0, + END: 8, + // Move direction clockwise by 45 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return dir + count; + }, + // Move direction clockwise by 90 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.increment45(dir, 2); + }, + // Move direction clockwise by 45 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return (dir - Direction.NORTH + count & 7) + Direction.NORTH; + }, + // Move direction clockwise by 90 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 2); + }, + // Move direction clockwise by 180 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate180: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 4); + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class Position { + constructor(pos, deltaX, deltaY) { + this.isPosition = true; + this.width = Micro.MAP_WIDTH; + this.height = Micro.MAP_HEIGHT; + this.x = 0; + this.y = 0; + this.validDirs = [Direction.NORTH, Direction.NORTHEAST, Direction.EAST, Direction.SOUTHEAST, Direction.SOUTH, Direction.SOUTHWEST, Direction.WEST, Direction.NORTHWEST, Direction.INVALID]; + if (arguments.length === 0) return this; + if (arguments.length === 1 && !pos.isPosition) throw new Error('Position constructor called with invalid pos ' + pos); + if (arguments.length === 3 && !pos.isPosition) throw new Error('Position constructor called with invalid pos ' + pos); + if (arguments.length === 3 && !(this.isNumber(deltaX) && this.isNumber(deltaY))) throw new Error('Position constructor called with invalid deltas ' + deltaX + ' ' + deltaY); + if (arguments.length === 2 && this.isNumber(pos) && !this.isNumber(deltaX)) throw new Error('Position constructor called with invalid y coordinate ' + pos + ' ' + deltaX); + if (arguments.length === 2 && pos.isPosition && !(this.isNumber(deltaX) && this.isDirection(deltaX))) throw new Error('Position constructor called with invalid direction ' + pos + ' ' + deltaX); + if (arguments.length === 2 && !this.isNumber(pos) && !pos.isPosition) throw new Error('Position constructor called with bad existing position ' + pos + ' ' + deltaX); // This overloaded constructor accepts the following parameters + // Position(x, y) - positive integral coordinates + // Position(Position p) - assign from existing position + // Position(Position p, Direction d) - assign from existing position and move in Direction d + // Position(Position p, deltaX, deltaY) - assign from p and then adjust x/y coordinates + // Check for the possible combinations of arguments, and error out for invalid arguments + //if ((arguments.length === 1 || arguments.length === 3) && !(pos instanceof Position)) throw new Error('Invalid parameter'); + //if (arguments.length === 3 && (!isNumber(deltaX) || !isNumber(deltaY))) throw new Error('Invalid parameter'); + //if (arguments.length === 2 && ((isNumber(pos) && !isNumber(deltaX)) || (pos instanceof Position && !isNumber(deltaX)) || (pos instanceof Position && isNumber(deltaX) && !isDirection(deltaX)) || (!isNumber(pos) && !(pos instanceof Position)))) throw new Error('Invalid parameter'); + + let moveOK = true; + + if (this.isNumber(pos)) { + // Coordinates + this.x = pos; + this.y = deltaX; + } else { + this.set(pos); + if (arguments.length === 2) moveOK = this.move(deltaX);else if (arguments.length === 3) { + this.x += deltaX; + this.y += deltaY; + } + } + + if (this.x < 0 || this.x >= this.width || this.y < 0 || this.y >= this.height || !moveOK) throw new Error('Invalid parameter'); + } + + isNumber(v) { + return !isNaN(v); //return typeof(v) === 'number'; + } + + isDirection(param) { + return this.isNumber(param) && this.validDirs.indexOf(param) !== -1; + } + + set(from) { + this.x = from.x; + this.y = from.y; + } + + toString() { + return '(' + this.x + ', ' + this.y + ')'; + } + + toInt() { + return this.y * this.width + this.x; + } + + move(dir) { + let up = false; + + switch (dir) { + case Direction.INVALID: + return true; + //up = true; break; + + case Direction.NORTH: + if (this.y > 0) { + this.y--; + up = true; + } + + break; + + case Direction.NORTHEAST: + if (this.y > 0 && this.x < this.width - 1) { + this.y--; + this.x++; + up = true; + } + + break; + + case Direction.EAST: + if (this.x < this.width - 1) { + this.x++; + up = true; + } + + break; + + case Direction.SOUTHEAST: + if (this.y < this.height - 1 && this.x < this.width - 1) { + this.x++; + this.y++; + up = true; + } + + break; + + case Direction.SOUTH: + if (this.y < this.height - 1) { + this.y++; + up = true; + } + + break; + + case Direction.SOUTHWEST: + if (this.y < this.height - 1 && this.x > 0) { + this.y++; + this.x--; + up = true; + } + + break; + + case Direction.WEST: + if (this.x > 0) { + this.x--; + up = true; + } + + break; + + case Direction.NORTHWEST: + if (this.y > 0 && this.x > 0) { + this.y--; + this.x--; + up = true; + } + + break; + } + + return up; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class PowerManager { + constructor(map) { + this._map = map; + this._powerStack = []; + this.powerGridMap = new BlockMap(this._map.width, this._map.height, 1, 0); + } + + setTilePower(x, y) { + var tile = this._map.getTile(x, y); + + var tileValue = tile.getValue(); + + if (tileValue === Tile.NUCLEAR || tileValue === Tile.POWERPLANT || this.powerGridMap.worldGet(x, y) > 0) { + tile.addFlags(Tile.POWERBIT); + return; + } + + tile.removeFlags(Tile.POWERBIT); + } + + clearPowerStack() { + this._powerStackPointer = 0; + this._powerStack = []; + } + + testForConductive(pos, testDir) { + var movedPos = new Position(pos); + + if (movedPos.move(testDir)) { + if (this._map.getTile(movedPos.x, movedPos.y).isConductive()) { + if (this.powerGridMap.worldGet(movedPos.x, movedPos.y) === 0) return true; + } + } + + return false; + } // Note: the algorithm is buggy: if you have two adjacent power + // plants, the second will be regarded as drawing power from the first + // rather than as a power source itself + + + doPowerScan(census) { + // Clear power this._map. + this.powerGridMap.clear(); // Power that the combined coal and nuclear power plants can deliver. + + let maxPower = census.coalPowerPop * Micro.COAL_POWER_STRENGTH + census.nuclearPowerPop * Micro.NUCLEAR_POWER_STRENGTH; + let powerConsumption = 0; // Amount of power used. + + while (this._powerStack.length > 0) { + var pos = this._powerStack.pop(); + + var anyDir = Direction.INVALID; + var conNum; + + do { + powerConsumption++; + + if (powerConsumption > maxPower) { + EventEmitter.emitEvent(Messages.NOT_ENOUGH_POWER); + return; + } + + if (anyDir !== Direction.INVALID) pos.move(anyDir); + this.powerGridMap.worldSet(pos.x, pos.y, 1); + conNum = 0; + var dir = Direction.BEGIN; + + while (dir < Direction.END && conNum < 2) { + if (this.testForConductive(pos, dir)) { + conNum++; + anyDir = dir; + } + + dir = Direction.increment90(dir); + } + + if (conNum > 1) this._powerStack.push(new Position(pos)); + } while (conNum); + } + } + + coalPowerFound(map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.coalPowerPop += 1; + + this._powerStack.push(new Position(x, y)); // Ensure animation runs + + + var dX = [-1, 2, 1, 2]; + var dY = [-1, -1, 0, 0]; // Ensure animation bits set no animation for 3d + + if (!simData.is3D) for (var i = 0; i < 4; i++) map.addTileFlags(x + dX[i], y + dY[i], Tile.ANIMBIT); + } + + nuclearPowerFound(map, x, y, simData) { + if (!simData) simData = Micro.simData; + var meltdownTable = [30000, 20000, 10000]; // TODO With the auto repair system, zone gets repaired before meltdown + // In original Micropolis code, we bail and don't repair if melting down + + if (simData.disasterManager.disastersEnabled && math.getRandom(meltdownTable[simData.gameLevel]) === 0) { + // simData.disasterManager.doMeltdown(messageManager, x, y); + return; + } + + simData.census.nuclearPowerPop += 1; + + this._powerStack.push(new Position(x, y)); //console.log(x, y, new map.Position(x, y)) + // Ensure animation bits set no animation for 3d + + + if (!simData.is3D) for (var i = 0; i < 4; i++) map.addTileFlags(x, y, Tile.ANIMBIT | Tile.CONDBIT | Tile.POWERBIT | Tile.BURNBIT); + } + + registerHandlers(mapScanner, repairManager) { + mapScanner.addAction(Tile.POWERPLANT, this.coalPowerFound.bind(this)); + mapScanner.addAction(Tile.NUCLEAR, this.nuclearPowerFound.bind(this)); + repairManager.addAction(Tile.POWERPLANT, 7, 4); + repairManager.addAction(Tile.NUCLEAR, 7, 4); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + class MapScanner { + constructor(map) { + this._map = map; + this._actions = []; + } + + addAction(criterion, action) { + this._actions.push({ + criterion: criterion, + action: action + }); + } + + mapScan(startX, maxX, simData) { + if (!simData) simData = Micro.simData; + let y = this._map.height, + x, + i, + id, + tile, + tileValue, + current, + callable; + + while (y--) { + for (x = startX; x < maxX; x++) { + id = this._map.getId(x, y); //x + y * this.mapWidth; + + tile = this._map.data[id] || new Tiles(); + tileValue = tile.getValue(); + if (tileValue < Tile.FLOOD) continue; + if (tile.isConductive()) simData.powerManager.setTilePower(x, y); + + if (tile.isZone()) { + simData.repairManager.checkTile(x, y, simData.cityTime); + + if (tile.isPowered()) { + simData.census.poweredZoneCount += 1; + + this._map.powered({ + v: 1, + id: id + }); + /*this._map.powerData[id] = 1;*/ + + } else { + simData.census.unpoweredZoneCount += 1; + + this._map.powered({ + v: 2, + id: id + }); + /*this._map.powerData[id] = 2;*/ + + } + } + + i = this._actions.length; + + while (i--) { + current = this._actions[i]; + callable = MiscUtils.isCallable(current.criterion); + + if (callable && current.criterion.call(null, tile)) { + current.action.call(null, this._map, x, y, simData); + break; + } else if (!callable && current.criterion === tileValue) { + current.action.call(null, this._map, x, y, simData); + break; + } + } + } + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class RepairManager { + constructor(map) { + this._map = map; + this._actions = []; + } + + addAction(criterion, period, zoneSize) { + this._actions.push({ + criterion: criterion, + period: period, + zoneSize: zoneSize + }); + } + + repairZone(x, y, zoneSize) { + let xx, yy, current, currentValue; + + let centre = this._map.getTileValue(x, y); + + let tileValue = centre - zoneSize - 2; + + for (yy = -1; yy < zoneSize - 1; yy++) { + for (xx = -1; xx < zoneSize - 1; xx++) { + tileValue++; + current = this._map.getTile(x + xx, y + yy); + if (current.isZone() || current.isAnimated()) continue; + currentValue = current.getValue(); + if (currentValue < Tile.RUBBLE || currentValue >= Tile.ROADBASE) this._map.setTile(x + xx, y + yy, tileValue, Tile.CONDBIT | Tile.BURNBIT); + } + } + } + + checkTile(x, y, cityTime) { + let i = this._actions.length, + current, + period, + tile, + tileValue, + callable; + + while (i--) { + current = this._actions[i]; + period = current.period; + if ((cityTime & period) !== 0) continue; + tile = this._map.getTile(x, y); + tileValue = tile.getValue(); + callable = MiscUtils.isCallable(current.criterion); + if (callable && current.criterion.call(null, tile)) this.repairZone(x, y, current.zoneSize);else if (!callable && current.criterion === tileValue) this.repairZone(x, y, current.zoneSize); + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class Traffic { + constructor(map, spriteManager) { + this._map = map; + this._stack = []; + this._spriteManager = spriteManager; + } + + makeTraffic(x, y, blockMaps, destFn) { + this._stack = []; + let pos = new Position(x, y); + + if (this.findPerimeterRoad(pos)) { + if (this.tryDrive(pos, destFn)) { + this.addToTrafficDensityMap(blockMaps); + return Micro.ROUTE_FOUND; + } + + return Micro.NO_ROUTE_FOUND; + } else { + return Micro.NO_ROAD_FOUND; + } + } + + addToTrafficDensityMap(blockMaps) { + let trafficDensityMap = blockMaps.trafficDensityMap; + + while (this._stack.length > 0) { + let pos = this._stack.pop(); // Could this happen?!? + + + if (!this._map.testBounds(pos.x, pos.y)) continue; + + let tileValue = this._map.getTileValue(pos.x, pos.y); + + if (tileValue >= Tile.ROADBASE && tileValue < Tile.POWERBASE) { + // Update traffic density. + let traffic = trafficDensityMap.worldGet(pos.x, pos.y); + traffic += 50; + traffic = Math.min(traffic, 240); + trafficDensityMap.worldSet(pos.x, pos.y, traffic); // Attract traffic copter to the traffic + + if (traffic >= 240 && math.getRandom(5) === 0) { + let sprite = this._spriteManager.getSprite(Micro.SPRITE_HELICOPTER); + + if (sprite !== null) { + sprite.destX = ZoneUtils.worldToPix(pos.x); + sprite.destY = ZoneUtils.worldToPix(pos.y); + } + } + } + } + } + + findPerimeterRoad(pos) { + for (let i = 0; i < 12; i++) { + let xx = pos.x + Micro.perimX[i]; + let yy = pos.y + Micro.perimY[i]; + + if (this._map.testBounds(xx, yy)) { + if (ZoneUtils.isDriveable(this._map.getTileValue(xx, yy))) { + pos.x = xx; + pos.y = yy; + return true; + } + } + } + + return false; + } + + tryDrive(startPos, destFn) { + let dirLast = Direction.INVALID; + let drivePos = new Position(startPos); + /* Maximum distance to try */ + + for (let dist = 0; dist < Micro.MAX_TRAFFIC_DISTANCE; dist++) { + let dir = this.tryGo(drivePos, dirLast); + + if (dir != Direction.INVALID) { + drivePos.move(dir); + dirLast = Direction.rotate180(dir); + if (dist & 1) this._stack.push(new Position(drivePos)); + if (this.driveDone(drivePos, destFn)) return true; + } else { + if (this._stack.length > 0) { + this._stack.pop(); + + dist += 3; + } else { + return false; + } + } + } + + return false; + } + + tryGo(pos, dirLast) { + let directions = []; // Find connections from current position. + + let dir = Direction.NORTH; + let i, + count = 0; + + for (i = 0; i < 4; i++) { + if (dir != dirLast && ZoneUtils.isDriveable(this._map.getTileFromMapOrDefault(pos, dir, Tile.DIRT))) { + // found a road in an allowed direction + directions[i] = dir; + count++; + } else { + directions[i] = Direction.INVALID; + } + + dir = Direction.rotate90(dir); + } + + if (count === 0) return Direction.INVALID; + + if (count === 1) { + for (i = 0; i < 4; i++) { + if (directions[i] != Direction.INVALID) return directions[i]; + } + } + + i = math.getRandom16() & 3; + + while (directions[i] === Direction.INVALID) i = i + 1 & 3; + + return directions[i]; + } + + driveDone(pos, destFn) { + if (pos.y > 0) { + if (destFn(this._map.getTileValue(pos.x, pos.y - 1))) return true; + } + + if (pos.x < this._map.width - 1) { + if (destFn(this._map.getTileValue(pos.x + 1, pos.y))) return true; + } + + if (pos.y < this._map.height - 1) { + if (destFn(this._map.getTileValue(pos.x, pos.y + 1))) return true; + } + + if (pos.x > 0) { + if (destFn(this._map.getTileValue(pos.x - 1, pos.y))) return true; + } + + return false; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const vulnerable = function (tile) { + let tileValue = tile.getValue(); + if (tileValue < Tile.RESBASE || tileValue > Tile.LASTZONE || tile.isZone()) return false; + return true; + }; + class DisasterManager { + constructor(map, spriteManager, gameLevel) { + this._map = map; + this._spriteManager = spriteManager; + this._gameLevel = gameLevel; + this._floodCount = 0; + this.disastersEnabled = false; + this.Dx = [0, 1, 0, -1]; + this.Dy = [-1, 0, 1, 0]; // TODO enable disasters + //Object.defineProperty(this, 'disastersEnabled', MiscUtils.mcd(false)); + } + + doDisasters(census) { + if (this._floodCount) this._floodCount--; // TODO Scenarios + + if (!this.disastersEnabled) return; + + if (math.getRandom(Micro.DisChance[this._gameLevel])) { + switch (math.getRandom(8)) { + case 0: + case 1: + this.setFire(); + break; + + case 2: + case 3: + this.makeFlood(); + break; + + case 4: + break; + + case 5: + this._spriteManager.makeTornado(); + + break; + + case 6: + // TODO Earthquakes + //this.makeEarthquake(); + break; + + case 7: + case 8: + if (census.pollutionAverage > 60) this._spriteManager.makeMonster(); + break; + } + } + } + + setDifficulty(gameLevel) { + this._gameLevel = gameLevel; + } + + scenarioDisaster() {// TODO Scenarios + } // User initiated meltdown: need to find the plant first + + + makeMeltdown() { + for (let x = 0; x < this._map.width - 1; x++) { + for (let y = 0; y < this._map.height - 1; y++) { + if (this._map.getTileValue(x, y) === Tile.NUCLEAR) { + this.doMeltdown(x, y); + return; + } + } + } + } + + makeEarthquake() { + let strength = math.getRandom(700) + 300; + this.doEarthquake(strength); + EventEmitter.emitEvent(Messages.EARTHQUAKE, { + x: this._map.cityCenterX, + y: this._map.cityCenterY + }); + let i, x, y; + + for (i = 0; i < strength; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + + if (vulnerable(this._map.getTile(x, y))) { + if ((i & 0x3) !== 0) this._map.setTo(x, y, ZoneUtils.randomRubble());else this._map.setTo(x, y, ZoneUtils.randomFire()); + } + } + } + + setFire(times = 1, zonesOnly = false) { + let i, x, y, tile, lowerLimit; + + for (i = 0; i < times; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + if (!this._map.testBounds(x, y)) continue; + tile = this._map.getTile(x, y); + + if (!tile.isZone()) { + tile = tile.getValue(); + lowerLimit = zonesOnly ? Tile.LHTHR : Tile.TREEBASE; + + if (tile > lowerLimit && tile < Tile.LASTZONE) { + this._map.setTo(x, y, ZoneUtils.randomFire()); + + EventEmitter.emitEvent(Messages.FIRE_REPORTED, { + showable: true, + x: x, + y: y + }); + return; + } + } + } + } + + makeCrash() { + let s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + + if (s !== null) { + s.explodeSprite(); + return; + } + + let x = math.getRandom(this._map.width - 1); + let y = math.getRandom(this._map.height - 1); + + this._spriteManager.generatePlane(x, y); + + s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + s.explodeSprite(); + } + + makeFire() { + this.setFire(40, false); + } + + makeFlood() { + let i, x, y, tileValue, j, xx, yy, tile; + + for (i = 0; i < 300; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + if (!this._map.testBounds(x, y)) continue; + tileValue = this._map.getTileValue(x, y); + + if (tileValue > Tile.CHANNEL && tileValue <= Tile.WATER_HIGH) { + for (j = 0; j < 4; j++) { + xx = x + this.Dx[j]; + yy = y + this.Dy[j]; + if (!this._map.testBounds(xx, yy)) continue; + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile === Tile.DIRT || tile.isBulldozable() && tile.isCombustible) { + this._map.setTo(xx, yy, new Tiles(Tile.FLOOD)); + + this._floodCount = 30; + EventEmitter.emitEvent(Messages.FLOODING_REPORTED, { + showable: true, + x: xx, + y: yy + }); + return; + } + } + } + } + } + + doFlood(x, y, blockMaps) { + let i, xx, yy, tile, tileValue; + + if (this._floodCount > 0) { + // Flood is not over yet + for (i = 0; i < 4; i++) { + if (math.getChance(7)) { + xx = x + this.Dx[i]; + yy = y + this.Dy[i]; + + if (this._map.testBounds(xx, yy)) { + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile.isCombustible() || tileValue === Tile.DIRT || tileValue >= Tile.WOODS5 && tileValue < Tile.FLOOD) { + if (tile.isZone()) ZoneUtils.fireZone(this.map, xx, yy, blockMaps); + + this._map.setTile(xx, yy, Tile.FLOOD + math.getRandom(2), 0); //this._map.setTo(xx, yy, new Tiles(Tile.FLOOD + math.getRandom(2))); + + } + } + } + } + } else { + if (math.getChance(15)) this._map.setTile(x, y, Tile.DIRT, 0); + } + } + + doMeltdown(x, y) { + this._spriteManager.makeExplosion(x - 1, y - 1); + + this._spriteManager.makeExplosion(x - 1, y + 2); + + this._spriteManager.makeExplosion(x + 2, y - 1); + + this._spriteManager.makeExplosion(x + 2, y + 2); + + let i, dY, dX, tile; // Whole power plant is at fire + + for (dX = x - 1; dX < x + 3; dX++) { + for (dY = y - 1; dY < y + 3; dY++) { + this._map.setTo(dX, dY, ZoneUtils.randomFire()); + } + } // Add lots of radiation tiles around the plant + + + for (i = 0; i < 200; i++) { + dX = x - 20 + math.getRandom(40); + dY = y - 15 + math.getRandom(30); + if (!this._map.testBounds(dX, dY)) continue; + tile = this._map.getTile(dX, dY); + if (tile.isZone()) continue; + if (tile.isCombustible() || tile.getValue() === Tile.DIRT) this._map.setTile(dX, dY, Tile.RADTILE, 0); //this._map.setTo(dX, dY, new Tiles(Tile.RADTILE)); + } // Report disaster to the user + + + EventEmitter.emitEvent(Messages.NUCLEAR_MELTDOWN, { + showable: true, + x: x, + y: y + }); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const freeZone = [0, 3, 6, 1, 4, 7, 2, 5, 8]; + const Residential = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isResidentialZone, Residential.residentialFound); + mapScanner.addAction(ZoneUtils.HOSPITAL, Residential.hospitalFound); + repairManager.addAction(Tile.HOSPITAL, 15, 3); + }, + // Residential tiles have 'populations' of 16, 24, 32 or 40 + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + placeResidential: function (map, x, y, population, lpValue, zonePower) { + let centreTile = (lpValue * 4 + population) * 9 + Tile.RZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + // Look for housing in the adjacent 8 tiles + getFreeZonePopulation: function (map, x, y, tileValue) { + let count = 0, + xx, + yy; + + for (xx = x - 1; xx <= x + 1; xx++) { + for (yy = y - 1; yy <= y + 1; yy++) { + if (xx === x && yy === y) continue; + tileValue = map.getTileValue(xx, yy); + if (tileValue >= Tile.LHTHR && tileValue <= Tile.HHTHR) count += 1; + } + } + + return count; + }, + getZonePopulation: function (map, x, y, tileValue) { + //if ( tileValue.isTile ) tileValue = new Tiles().getValue(); + if (tileValue === Tile.FREEZ) return Residential.getFreeZonePopulation(map, x, y, tileValue); + let populationIndex = Math.floor((tileValue - Tile.RZB) / 9) % 4 + 1; + return populationIndex * 8 + 16; + }, + // Assess a tile for suitability for a house. Prefer tiles near roads + evalLot: function (map, x, y) { + let xDelta = [0, 1, 0, -1]; + let yDelta = [-1, 0, 1, 0]; + if (!map.testBounds(x, y)) return -1; + let tileValue = map.getTileValue(x, y); + if (tileValue < Tile.RESBASE || tileValue > Tile.RESBASE + 8) return -1; + let score = 1, + i, + edgeX, + edgeY; + + for (i = 0; i < 4; i++) { + edgeX = x + xDelta[i]; + edgeY = y + yDelta[i]; + if (edgeX < 0 || edgeX >= map.width || edgeY < 0 || edgeY >= map.height) continue; + tileValue = map.getTileValue(edgeX, edgeY); + if (tileValue !== Tile.DIRT && tileValue <= Tile.LASTROAD) score += 1; + } + + return score; + }, + buildHouse: function (map, x, y, lpValue) { + let best = 0; + let bestScore = 0; // Deliberately ordered so that the centre tile is at index 0 + + let xDelta = [0, -1, 0, 1, -1, 1, -1, 0, 1]; + let yDelta = [0, -1, -1, -1, 0, 0, 1, 1, 1]; + let i, xx, yy, score; + + for (i = 0; i < 9; i++) { + xx = x + xDelta[i]; + yy = y + yDelta[i]; + score = Residential.evalLot(map, xx, yy); + + if (score > bestScore) { + bestScore = score; + best = i; + } else if (score === bestScore && math.getChance(7)) { + // Ensures we don't always select the same position when we + // have a choice + best = i; + } + } + + if (best > 0 && map.testBounds(x + xDelta[best], y + yDelta[best])) map.setTile(x + xDelta[best], y + yDelta[best], Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT); //map.setTo(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + //map.setTile(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + }, + growZone: function (map, x, y, blockMaps, population, lpValue, zonePower) { + let pollution = blockMaps.pollutionDensityMap.worldGet(x, y); // Cough! Too polluted noone wants to move here! + + if (pollution > 128) return; + let tileValue = map.getTileValue(x, y); + + if (tileValue === Tile.FREEZ) { + if (population < 8) { + // Zone capacity not yet reached: build another house + Residential.buildHouse(map, x, y, lpValue); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 1); + } else if (blockMaps.populationDensityMap.worldGet(x, y) > 64) { + // There is local demand for higher density housing + Residential.placeResidential(map, x, y, 0, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + + return; + } + + if (population < 40) { + // Zone population not yet maxed out + Residential.placeResidential(map, x, y, Math.floor(population / 8) - 1, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + degradeZone: function (map, x, y, blockMaps, population, lpValue, zonePower) { + let xx, yy; + if (population === 0) return; + + if (population > 16) { + // Degrade to a lower density block + Residential.placeResidential(map, x, y, Math.floor((population - 24) / 8), lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } + + if (population === 16) { + // Already at lowest density: degrade to 8 individual houses + map.setTo(x, y, new Tiles(Tile.FREEZ, Tile.BLBNCNBIT | Tile.ZONEBIT)); + + for (yy = y - 1; yy <= y + 1; yy++) { + for (xx = x - 1; xx <= x + 1; xx++) { + if (xx === x && yy === y) continue; + map.setTile(x, y, Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT); //map.setTo(x, y, new Tiles(Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT)); + } + } + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } // Already down to individual houses. Remove one + + + let i = 0; + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -1); + + for (xx = x - 1; xx <= x + 1; xx++) { + for (yy = y - 1; yy <= y + 1; yy++) { + let currentValue = map.getTileValue(xx, yy); + + if (currentValue >= Tile.LHTHR && currentValue <= Tile.HHTHR) { + // We've found a house. Replace it with the normal free zone tile + map.setTile(xx, yy, freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT); //map.setTo(xx, yy, new Tiles(freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT)); + + return; + } + + i += 1; + } + } + }, + // Returns a score for the zone in the range -3000 - 3000 + evalResidential: function (blockMaps, x, y, traffic) { + if (traffic === Micro.NO_ROAD_FOUND) return -3000; + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 0) landValue = 0;else landValue = Math.min(landValue * 32, 6000); + return landValue - 3000; + }, + residentialFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; // If we choose to grow this zone, we will fill it with an index in the range 0-3 reflecting the land value and + // pollution scores (higher is better). This is then used to select the variant to build + + let lpValue; // Notify the census + + simData.census.resZonePop += 1; // Also, notify the census of our population + + let tileValue = map.getTileValue(x, y); + let population = Residential.getZonePopulation(map, x, y, tileValue); + simData.census.resPop += population; + let zonePower = map.getTile(x, y).isPowered(); + let trafficOK = Micro.ROUTE_FOUND; // Occasionally check to see if the zone is connected to the road network. The chance of this happening increases + // as the zone's population increases. Note: we will never execute this conditional if the zone is empty, as zero + // will never be be bigger than any of the values Random will generate + + if (population > math.getRandom(35)) { + // Is there a route from this zone to a commercial zone? + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isCommercial); // If we're not connected to the road network, then going shopping will be a pain. Move out. + + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } // Sometimes we will randomly choose to assess this block. However, always assess it if it's empty or contains only single houses. + + + if (tileValue === Tile.FREEZ || math.getChance(7)) { + // First, score the individual zone. This is a value in the range -3000 to 3000 + // Then take into account global demand for housing. + let locationScore = Residential.evalResidential(simData.blockMaps, x, y, trafficOK); + let zoneScore = simData.valves.resValve + locationScore; // Naturally unpowered zones should be penalized + + if (!zonePower) zoneScore = -500; // The residential demand valve has range -2000 to 2000, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5500 - 5000. + // Now, observe that if there are no roads we will never take this branch, as zoneScore will equal -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -20880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 81.8% of them are above -20880, so nearly 82% of the time, we will never take this branch. + // Thus, there's approximately a 9% chance that the value will be in the range, and we *might* grow. + //if (trafficOK && (zoneScore > -350) && ((zoneScore - 26380) > math.getRandom16Signed())) { + + if (zoneScore > -350 && zoneScore - 26380 > math.getRandom16Signed()) { + // If this zone is empty, and residential demand is strong, we might make a hospital + //if (population === 0 && ((math.getRandom16() & 3) === 0)) { + if (population === 0 && math.getChance(3)) { + Residential.makeHospital(map, x, y, simData, zonePower); + return; + } // Get an index in the range 0-3 scoring the land desirability and pollution, and grow the zone to the next + // population rank + + + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } // Again, given the above, zoneScore + 26380 must lie in the range 20880 - 26030. + // There is a 10.2% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 89.7% chance of the number being below 20880 thus never triggering this branch, which leaves a + // 0.1% chance of this branch being conditional on zoneScore. + + + if (zoneScore < 350 && zoneScore + 26380 < math.getRandom16Signed()) { + // Get an index in the range 0-3 scoring the land desirability and pollution, and degrade to the next + // lower ranked zone + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + }, + makeHospital: function (map, x, y, simData, zonePower) { + if (!simData) simData = Micro.simData; // We only build a hospital if the population requires it + + if (simData.census.needHospital > 0) { + ZoneUtils.putZone(map, x, y, Tile.HOSPITAL, zonePower); + simData.census.needHospital = 0; + return; + } + }, + hospitalFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.hospitalPop += 1; // Degrade to an empty zone if a hospital is no longer sustainable + + if (simData.census.needHospital === -1) { + if (math.getRandom(20) === 0) ZoneUtils.putZone(map, x, y, Tile.FREEZ, map.getTile(x, y).isPowered()); + } + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const Commercial = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isCommercialZone, Commercial.commercialFound); + }, + // Commercial tiles have 'populations' from 1 to 5, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + getZonePopulation: function (map, x, y, tileValue) { + //if (tileValue.isTile ) tileValue = new Tiles().getValue(); //COMCLEAR) + if (tileValue === Tile.COMCLR) return 0; + return Math.floor((tileValue - Tile.CZB) / 9) % 5 + 1; + }, + // Takes a map and coordinates, a population category in the range 1-5, a value category in the range 0-3, and places + // the appropriate industrial zone on the map + placeCommercial: function (map, x, y, population, lpValue, zonePower) { + var centreTile = (lpValue * 5 + population) * 9 + Tile.CZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + growZone: function (map, x, y, blockMaps, population, lpValue, zonePower) { + // landValueMap contains values in the range 0-250, representing the desirability of the land. + // Thus, after shifting, landValue will be in the range 0-7. + var landValue = blockMaps.landValueMap.worldGet(x, y); + landValue = landValue >> 5; + if (population > landValue) return; // This zone is desirable, and seemingly not to crowded. Switch to the next category of zone. + + if (population < 5) { + Commercial.placeCommercial(map, x, y, population, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + degradeZone: function (map, x, y, blockMaps, populationCategory, lpCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) { + Commercial.placeCommercial(map, x, y, populationCategory - 2, lpCategory, zonePower); + } else { + ZoneUtils.putZone(map, x, y, Tile.COMCLR, zonePower); + } + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + // Called by the map scanner when it finds the centre of an commercial zone + commercialFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; // lpValue will be filled if we actually decide to trigger growth/decay. It will be an index of the land/pollution + // value in the range 0-3 + + var lpValue; // Notify the census + + simData.census.comZonePop += 1; // Calculate the population level for this tile, and add to census + + var tileValue = map.getTileValue(x, y); + var population = Commercial.getZonePopulation(map, x, y, tileValue); + simData.census.comPop += population; + var zonePower = map.getTile(x, y).isPowered(); // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if consumers cannot reach the shops. + // Note in particular, we will never take this branch if the zone is empty. + + var trafficOK = Micro.ROUTE_FOUND; + + if (population > math.getRandom(5)) { + // Try to find a route from here to an industrial zone + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isIndustrial); // Trigger outward migration if not connected to road network + + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } // Occasionally assess and perhaps modify the tile + + + if (math.getChance(7)) { + var locationScore = trafficOK === Micro.NO_ROAD_FOUND ? -3000 : simData.blockMaps.cityCentreDistScoreMap.worldGet(x, y); + var zoneScore = simData.valves.comValve + locationScore; // Unpowered zones should of course be penalized + + if (!zonePower) zoneScore = -500; // The commercial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5064 - 1564. (The comRateMap, which scores + // commercial neighbourhoods based on their distance from the city centre, has range -64 to 64). + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24816. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.8% of them are above -24816, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 3% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + + if (zonePower && zoneScore > -350 && zoneScore - 26380 > math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } // Again, given the above, zoneScore + 26380 must lie in the range 21316 - 27944. + // There is a 7.3% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 82.5% chance of the number being below 21316 thus never triggering this branch, which leaves a + // 10.1% chance of this branch being conditional on zoneScore. + + + if (zoneScore < 350 && zoneScore + 26380 < math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const animated = [true, false, true, true, false, false, true, true]; + const xDelta = [-1, 0, 1, 0, 0, 0, 0, 1]; + const yDelta = [-1, 0, -1, -1, 0, 0, -1, -1]; + const Industrial = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isIndustrialZone, Industrial.industrialFound); + }, + // Industrial tiles have 'populations' from 1 to 4, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + getZonePopulation: function (map, x, y, tileValue) { + if (tileValue === Tile.INDCLR) return 0; + return Math.floor((tileValue - Tile.IZB) / 9) % 4 + 1; + }, + placeIndustrial: function (map, x, y, populationCategory, valueCategory, zonePower) { + var centreTile = (valueCategory * 4 + populationCategory) * 9 + Tile.IZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + growZone: function (map, x, y, blockMaps, population, valueCategory, zonePower) { + // Switch to the next category of zone + if (population < 4) { + Industrial.placeIndustrial(map, x, y, population, valueCategory, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + degradeZone: function (map, x, y, blockMaps, populationCategory, valueCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) Industrial.placeIndustrial(map, x, y, populationCategory - 2, valueCategory, zonePower);else ZoneUtils.putZone(map, x, y, Tile.INDCLR, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + // Takes a map and coordinates, the tile value of the centre of the zone, and a boolean indicating whether + // the zone has power, and sets or unsets the animation bit in the appropriate part of the zone + setAnimation: function (map, x, y, tileValue, isPowered) { + if (tileValue < Tile.IZB) return; // There are only 7 different types of populated industrial zones. + // As tileValue - IZB will never be 8x9 or more away from IZB, we + // can shift right by 3, and get the same effect as dividing by 9 + + var i = tileValue - Tile.IZB >> 3; + + if (animated[i] && isPowered) { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.ASCBIT); + } else { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.BNCNBIT); + map.removeTileFlags(x + xDelta[i], y + yDelta[i], Tile.ANIMBIT); + } + }, + industrialFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.indZonePop += 1; // Calculate the population level for this tile, and add to census + + var tileValue = map.getTileValue(x, y); + var population = Industrial.getZonePopulation(map, x, y, tileValue); + simData.census.indPop += population; // Set animation bit if appropriate + + var zonePower = map.getTile(x, y).isPowered(); + if (!simData.is3D) Industrial.setAnimation(map, x, y, tileValue, zonePower); // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if workers cannot reach the factories. + // Note in particular, we will never take this branch if the zone is empty. + + var trafficOK = Micro.ROUTE_FOUND; + + if (population > math.getRandom(5)) { + // Try to find a route from here to a residential zone + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isResidential); // Trigger outward migration if not connected to road network (unless the zone is already empty) + + if (trafficOK === Micro.NO_ROAD_FOUND) { + var newValue = math.getRandom16() & 1; + Industrial.degradeZone(map, x, y, simData.blockMaps, population, newValue, zonePower); + return; + } + } // Occasionally assess and perhaps modify the tile + + + if (math.getChance(7)) { + var zoneScore = simData.valves.indValve + (trafficOK === Micro.NO_ROAD_FOUND ? -1000 : 0); // Unpowered zones should of course be penalized + + if (!zonePower) zoneScore = -500; // The industrial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -3000 - 1500 + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -1000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.9% of them are above -24880, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 2.9% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + + if (zoneScore > -350 && zoneScore - 26380 > math.getRandom16Signed()) { + Industrial.growZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + return; + } // Again, given the above, zoneScore + 26380 must lie in the range 23380 - 27880. + // There is a 7.4% chance of getRandom16() always yielding a number > 27880 which would take this branch. + // There is a 85.6% chance of the number being below 23380 thus never triggering this branch, which leaves a + // 9% chance of this branch being conditional on zoneScore. + + + if (zoneScore < 350 && zoneScore + 26380 < math.getRandom16Signed()) Industrial.degradeZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + } + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const verticalDeltaX = [0, 1, 0, 0, 0, 0, 1]; + const verticalDeltaY = [-2, -2, -1, 0, 1, 2, 2]; + const horizontalDeltaX = [-2, 2, -2, -1, 0, 1, 2]; + const horizontalDeltaY = [-1, -1, 0, 0, 0, 0, 0]; + const openVertical = [Tile.VBRDG0, Tile.VBRDG1, Tile.RIVER, Tile.BRWV, Tile.RIVER, Tile.VBRDG2, Tile.VBRDG3]; + const closeVertical = [Tile.VBRIDGE, Tile.RIVER, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.RIVER]; + const openHorizontal = [Tile.HBRDG1, Tile.HBRDG3, Tile.HBRDG0, Tile.RIVER, Tile.BRWH, Tile.RIVER, Tile.HBRDG2]; + const closeHorizontal = [Tile.RIVER, Tile.RIVER, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE]; + /* + const openVertical = [ + Tile.VBRDG0 | Tile.BULLBIT, Tile.VBRDG1 | Tile.BULLBIT, + Tile.RIVER, Tile.BRWV | Tile.BULLBIT, + Tile.RIVER, Tile.VBRDG2 | Tile.BULLBIT, Tile.VBRDG3 | Tile.BULLBIT + ]; + const closeVertical = [ + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER + ]; + const openHorizontal = [ + Tile.HBRDG1 | Tile.BULLBIT, Tile.HBRDG3 | Tile.BULLBIT, + Tile.HBRDG0 | Tile.BULLBIT, Tile.RIVER, Tile.BRWH | Tile.BULLBIT, + Tile.RIVER, Tile.HBRDG2 | Tile.BULLBIT + ]; + const closeHorizontal = [ + Tile.RIVER, Tile.RIVER, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT + ];*/ + + const densityTable = [Tile.ROADBASE, Tile.LTRFBASE, Tile.HTRFBASE]; + const Road = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isRoad, Road.roadFound); + }, + openBridge: function (map, origX, origY, xDelta, yDelta, oldTiles, newTiles) { + let i, x, y; + + for (i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + + if (map.testBounds(x, y)) { + if (map.getTileValue(x, y) === (oldTiles[i] & Tile.BIT_MASK)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + closeBridge: function (map, origX, origY, xDelta, yDelta, oldTiles, newTiles) { + let i, x, y, tileValue; + + for (i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + + if (map.testBounds(x, y)) { + tileValue = map.getTileValue(x, y); + if (tileValue === Tile.CHANNEL || (tileValue & 15) === (oldTiles[i] & 15)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + doBridge: function (map, x, y, currentTile, simData) { + //console.log( 'make bridge !!' ) + if (!simData) simData = Micro.simData; + + if (currentTile === Tile.BRWV) { + // We have an open vertical bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) Road.closeBridge(map, x, y, verticalDeltaX, verticalDeltaY, openVertical, closeVertical); + return true; + } + + if (currentTile == Tile.BRWH) { + // We have an open horizontal bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) Road.closeBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, openHorizontal, closeHorizontal); + return true; + } + + if (simData.spriteManager.getBoatDistance(x, y) < 300 || math.getChance(7)) { + if (currentTile & 1) { + if (x < map.width - 1) { + if (map.getTileValue(x + 1, y) === Tile.CHANNEL) { + // We have a closed vertical bridge. Open it. + Road.openBridge(map, x, y, verticalDeltaX, verticalDeltaY, closeVertical, openVertical); + return true; + } + } + + return false; + } else { + if (y > 0) { + if (map.getTileValue(x, y - 1) === Tile.CHANNEL) { + // We have a closed horizontal bridge. Open it. + Road.openBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, closeHorizontal, openHorizontal); + return true; + } + } + } + } + + return false; + }, + roadFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.roadTotal += 1; + let currentTile = map.getTile(x, y); + let tileValue = currentTile.getValue(); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + //currentTile = map.getTile(x, y); + // Don't degrade tiles with power lines + if (!currentTile.isConductive()) { + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + //let mapValue = currentTile.getValue(); + // Replace bridge tiles with water, otherwise rubble + if ((tileValue & 15) < 2 || (tileValue & 15) === 15) map.setTile(x, y, Tile.RIVER);else map.setTo(x, y, ZoneUtils.randomRubble()); + return; + } + } + } + } // Bridges are not combustible + + + if (!currentTile.isCombustible()) { + // The comment in the original Micropolis code states bridges count for 4 + // However, with the increment above, it's actually 5. Bug? + simData.census.roadTotal += 4; //if ( Road.doBridge(map, x, y, tileValue, simData)) return; + } // Examine traffic density, and modify tile to represent last scanned traffic + // density + + + let density = 0; + + if (tileValue < Tile.LTRFBASE) { + density = 0; + } else if (tileValue < Tile.HTRFBASE) { + density = 1; + } else { + // Heavy traffic counts as two tiles with regards to upkeep cost + // Note, if this is heavy traffic on a bridge, and it wasn't handled above, + // it actually counts for 7 road tiles + simData.census.roadTotal += 1; + density = 2; + } // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + + + let currentDensity = simData.blockMaps.trafficDensityMap.worldGet(x, y) >> 6; // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + + if (currentDensity > 1) currentDensity -= 1; + if (currentDensity === density) return; + let newValue = (tileValue - Tile.ROADBASE & 15) + densityTable[currentDensity]; // Preserve all bits except animation + + let newFlags = currentTile.getFlags() & ~Tile.ANIMBIT; + if (currentDensity > 0) newFlags |= Tile.ANIMBIT; + map.setTo(x, y, new Tiles(newValue, newFlags)); + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const Transport = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isRail, Transport.railFound); + mapScanner.addAction(Tile.PORT, Transport.portFound); + mapScanner.addAction(Tile.AIRPORT, Transport.airportFound); + repairManager.addAction(Tile.PORT, 15, 4); + repairManager.addAction(Tile.AIRPORT, 7, 6); + }, + railFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.railTotal += 1; + simData.spriteManager.generateTrain(simData.census, x, y); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + let currentTile = map.getTile(x, y); // Don't degrade tiles with power lines + + if (currentTile.isConductive()) return; + + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + let mapValue = currentTile.getValue(); // Replace bridge tiles with water, otherwise rubble + + if (mapValue < Tile.RAILBASE + 2) map.setTile(x, y, Tile.RIVER, 0);else map.setTo(x, y, ZoneUtils.randomRubble()); + } + } + } + }, + airportFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.airportPop += 1; + let tile = map.getTile(x, y); + + if (tile.isPowered()) { + if (map.getTileValue(x + 1, y - 1) === Tile.RADAR) map.setTile(x + 1, y - 1, Tile.RADAR0, Tile.CONDBIT | Tile.ANIMBIT | Tile.BURNBIT); + + if (math.getRandom(5) === 0) { + simData.spriteManager.generatePlane(x, y); + return; + } + + if (math.getRandom(12) === 0) simData.spriteManager.generateCopter(x, y); + } else { + map.setTile(x + 1, y - 1, Tile.RADAR, Tile.CONDBIT | Tile.BURNBIT); + } + }, + portFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.seaportPop += 1; + let tile = map.getTile(x, y); + if (tile.isPowered() && simData.spriteManager.getSprite(Micro.SPRITE_SHIP) === null) simData.spriteManager.generateShip(); + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + const handleService = function (censusStat, budgetEffect, blockMap) { + return function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census[censusStat] += 1; + var effect = simData.budget[budgetEffect]; + var isPowered = map.getTile(x, y).isPowered(); // Unpowered buildings are half as effective + + if (!isPowered) effect = Math.floor(effect / 2); + var pos = new Position(x, y); + var connectedToRoads = simData.traffic.findPerimeterRoad(pos); + if (!connectedToRoads) effect = Math.floor(effect / 2); + var currentEffect = simData.blockMaps[blockMap].worldGet(x, y); + currentEffect += effect; + simData.blockMaps[blockMap].worldSet(x, y, currentEffect); + }; + }; + + const EmergencyServices = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(Tile.POLICESTATION, EmergencyServices.policeStationFound); + mapScanner.addAction(Tile.FIRESTATION, EmergencyServices.fireStationFound); + }, + policeStationFound: handleService('policeStationPop', 'policeEffect', 'policeStationMap'), + fireStationFound: handleService('fireStationPop', 'fireEffect', 'fireStationMap') + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const xDelta$1 = [-1, 0, 1, 0]; + const yDelta$1 = [0, -1, 0, 1]; + const MiscTiles = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(ZoneUtils.isFire, MiscTiles.fireFound, true); + mapScanner.addAction(Tile.RADTILE, MiscTiles.radiationFound, true); + mapScanner.addAction(ZoneUtils.isFlood, MiscTiles.floodFound, true); //mapScanner.addAction(ZoneUtils.isManualExplosion, MiscTiles.explosionFound, true); + }, + fireFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.firePop += 1; + if ((math.getRandom16() & 3) !== 0) return; + let i, xTem, yTem, tile; // Try to set neighbouring tiles on fire as well + + for (i = 0; i < 4; i++) { + if (math.getChance(7)) { + xTem = x + xDelta$1[i]; + yTem = y + yDelta$1[i]; + + if (map.testBounds(xTem, yTem)) { + tile = map.getTile(x, y); + if (!tile.isCombustible()) continue; + + if (tile.isZone()) { + // Neighbour is a ione and burnable + ZoneUtils.fireZone(map, x, y, simData.blockMaps); // Industrial zones etc really go boom + + if (tile.getValue() > Tile.IZB) simData.spriteManager.makeExplosionAt(x, y); + } + + map.setTo(ZoneUtils.randomFire()); + } + } + } // Compute likelyhood of fire running out of fuel + + + let rate = 10; // Likelyhood of extinguishing (bigger means less chance) + + i = simData.blockMaps.fireStationEffectMap.worldGet(x, y); + if (i > 100) rate = 1;else if (i > 20) rate = 2;else if (i > 0) rate = 3; // Decide whether to put out the fire. + + if (math.getRandom(rate) === 0) map.setTo(x, y, ZoneUtils.randomRubble()); + }, + radiationFound: function (map, x, y, simData) { + if (math.getChance(4095)) map.setTile(x, y, Tile.DIRT, 0); + }, + floodFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.disasterManager.doFlood(x, y, simData.blockMaps); + } + /*explosionFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + let tileValue = map.getTileValue(x, y); + map.setTo(x, y, ZoneUtils.randomRubble()); + return; + }*/ + + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + const Stadia = { + registerHandlers: function (mapScanner, repairManager) { + mapScanner.addAction(Tile.STADIUM, Stadia.emptyStadiumFound); + mapScanner.addAction(Tile.FULLSTADIUM, Stadia.fullStadiumFound); + repairManager.addAction(Tile.STADIUM, 15, 4); + }, + emptyStadiumFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.stadiumPop += 1; + + if (map.getTile(x, y).isPowered()) { + // Occasionally start the big game + if ((simData.cityTime + x + y & 31) === 0) { + map.putZone(x, y, Tile.FULLSTADIUM, 4); + map.addTileFlags(x, y, Tile.POWERBIT); + map.setTo(x + 1, y, new Tiles(Tile.FOOTBALLGAME1, Tile.ANIMBIT)); + map.setTo(x + 1, y + 1, new Tiles(Tile.FOOTBALLGAME2, Tile.ANIMBIT)); + } + } + }, + fullStadiumFound: function (map, x, y, simData) { + if (!simData) simData = Micro.simData; + simData.census.stadiumPop += 1; + let isPowered = map.getTile(x, y).isPowered(); + + if ((simData.cityTime + x + y & 7) === 0) { + map.putZone(x, y, Tile.STADIUM, 4); + if (isPowered) map.addTileFlags(x, y, Tile.POWERBIT); + } + } + }; + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + class MapUtils { + // Smooth the map src into dest. The way in which the map is smoothed depends on the value of smoothStyle. + // The meanings are as follows: + // + // SMOOTH_NEIGHBOURS_THEN_BLOCK + // ============================ + // For each square in src, sum the values of its immediate neighbours, and take the average, then take the average of + // that result and the square's value. This result is the new value of the square in dest. + // + // SMOOTH_ALL_THEN_CLAMP + // ===================== + // For each square in src, sum the values of that square and it's four immediate neighbours, and take an average + // rounding down. Clamp the resulting value in the range 0-255. This clamped value is the square's new value in dest. + static smoothMap(src, dest, smoothStyle) { + let x = src.width, + y, + edges; + + while (x--) { + y = src.height; + + while (y--) { + edges = 0; + if (x > 0) edges += src.get(x - 1, y); + if (x < src.width - 1) edges += src.get(x + 1, y); + if (y > 0) edges += src.get(x, y - 1); + if (y < src.height - 1) edges += src.get(x, y + 1); + + if (smoothStyle === Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK) { + edges = src.get(x, y) + Math.floor(edges / 4); + dest.set(x, y, Math.floor(edges / 2)); + } else { + edges = edges + src.get(x, y) >> 2; + if (edges > 255) edges = 255; + dest.set(x, y, edges); + } + } + } + } // Over time, the rate of growth of a neighbourhood should trend towards zero (stable) + + + static neutraliseRateOfGrowthMap(blockMaps) { + let bm = blockMaps.rateOfGrowthMap; + let x = bm.width, + y, + value; + + while (x--) { + y = bm.height; + + while (y--) { + value = bm.get(x, y); + + if (value !== 0) { + if (value > 0) value--;else value++; + value = math.clamp(value, -200, 200); + bm.set(x, y, value); + } + } + } + } // Over time, traffic density should ease. + + + static neutraliseTrafficMap(blockMaps) { + let bm = blockMaps.trafficDensityMap; + let x = bm.width, + y, + value; + + while (x--) { + y = bm.height; + + while (y--) { + value = bm.get(x, y); + + if (value !== 0) { + if (value <= 24) value = 0;else if (value > 200) value = value - 34;else value = value - 24; + bm.set(x, y, value); + } + } + } + } // Given a tileValue, score it on the pollution it generates, in the range 0-255 + + + static getPollutionValue(tileValue) { + if (tileValue < Tile.POWERBASE) { + // Roads, fires and radiation lie below POWERBASE + // Heavy traffic is bad + if (tileValue >= Tile.HTRFBASE) return 75; // Low traffic not so much + + if (tileValue >= Tile.LTRFBASE) return 50; + + if (tileValue < Tile.ROADBASE) { + // Fire = carbon monoxide = a bad score for you + if (tileValue > Tile.FIREBASE) return 90; // Radiation. Top of the charts. + + if (tileValue >= Tile.RADTILE) return 255; + } // All other types of ground are pure. + + + return 0; + } // If we've reached this point, we're classifying some form of zone tile + // Residential and commercial zones don't pollute + + + if (tileValue <= Tile.LASTIND) return 0; // Industrial zones, however... + + if (tileValue < Tile.PORTBASE) return 50; // Coal power plants are bad + + if (tileValue <= Tile.LASTPOWERPLANT) return 100; + return 0; + } // Compute the Manhattan distance of the given point from the city centre, and force into the range 0-64 + + + static getCityCentreDistance(map, x, y) { + let xDis, yDis; + if (x > map.cityCentreX) xDis = x - map.cityCentreX;else xDis = map.cityCentreX - x; + if (y > map.cityCentreY) yDis = y - map.cityCentreY;else yDis = map.cityCentreY - y; + return Math.min(xDis + yDis, 64); + } // This monster function fills up the landValueMap, the terrainDensityMap and the pollutionDensityMap based + // on values found by iterating over the map. + // + // Factors that affect land value: + // * Distance from the city centre + // * High crime + // * High pollution + // * Proximity to undeveloped terrain (who doesn't love a good view?) + // + // Pollution is completely determined by the tile types in the block + + + static pollutionTerrainLandValueScan(map, census, blockMaps) { + // We record raw pollution readings for each tile into tempMap1, and then use tempMap2 and tempMap1 to smooth + // out the pollution in order to construct the new values for the populationDensityMap + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; // tempMap3 will be used to record raw terrain information, i.e. if the the land is developed. This will be + // smoothed in to terrainDensityMap later + + let tempMap3 = blockMaps.tempMap3; + tempMap3.clear(); + let landValueMap = blockMaps.landValueMap; + let terrainDensityMap = blockMaps.terrainDensityMap; + let pollutionDensityMap = blockMaps.pollutionDensityMap; + let crimeRateMap = blockMaps.crimeRateMap; + let totalLandValue = 0; + let developedTileCount = 0; + let x = landValueMap.width, + y, + pollutionLevel, + developed, + worldX, + worldY, + mapX, + mapY, + tileValue, + terrainValue, + landValue; + + while (x--) { + y = landValueMap.height; + + while (y--) { + pollutionLevel = 0; + developed = false; // The land value map has a chunk size of 2 + + worldX = x * 2; + worldY = y * 2; + + for (mapX = worldX; mapX <= worldX + 1; mapX++) { + for (mapY = worldY; mapY <= worldY + 1; mapY++) { + tileValue = map.getTileValue(mapX, mapY); + if (tileValue === Tile.DIRT) continue; + + if (tileValue < Tile.RUBBLE) { + // Undeveloped land: record in tempMap3. Each undeveloped piece of land scores 15. + // tempMap3 has a chunk size of 4, so each square in tempMap3 will ultimately contain a + // maximum value of 240 + terrainValue = tempMap3.worldGet(mapX, mapY); + tempMap3.worldSet(mapX, mapY, terrainValue + 15); + continue; + } + + pollutionLevel += MapUtils.getPollutionValue(tileValue); + + if (tileValue >= Tile.ROADBASE) { + developed = true; + } + } + } + + pollutionLevel = Math.min(pollutionLevel, 255); + tempMap1.set(x, y, pollutionLevel); + + if (developed) { + landValue = 34 - Math.floor(MapUtils.getCityCentreDistance(map, worldX, worldY) / 2); + landValue = landValue << 2; // Land in the same neighbourhood as unspoiled land is more valuable... + + landValue += terrainDensityMap.get(x >> 1, y >> 1); // ... and polluted land obviously is less valuable + + landValue -= pollutionDensityMap.get(x, y); // ... getting mugged won't help either + + if (crimeRateMap.get(x, y) > 190) { + landValue -= 20; + } // Clamp in range 1-250 (0 represents undeveloped land) + + + landValue = math.clamp(landValue, 1, 250); + landValueMap.set(x, y, landValue); + totalLandValue += landValue; + developedTileCount++; + } else { + landValueMap.set(x, y, 0); + } + } + } + + if (developedTileCount > 0) census.landValueAverage = Math.floor(totalLandValue / developedTileCount);else census.landValueAverage = 0; // Smooth the pollution map twice + + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + let maxPollution = 0; + let pollutedTileCount = 0; + let totalPollution = 0; + let pollution; // We iterate over the now-smoothed pollution map rather than using the block map's copy routines + // so that we can compute the average and total pollution en-route + + for (x = 0; x < map.width; x += pollutionDensityMap.blockSize) { + for (y = 0; y < map.height; y += pollutionDensityMap.blockSize) { + // Copy the values into pollutionDensityMap + pollution = tempMap1.worldGet(x, y); + pollutionDensityMap.worldSet(x, y, pollution); + + if (pollution !== 0) { + pollutedTileCount++; + totalPollution += pollution; // Note the most polluted location: any monsters will be drawn there (randomly choosing one + // if we have multiple competitors for most polluted) + + if (pollution > maxPollution || pollution === maxPollution && math.getChance(3)) { + maxPollution = pollution; + map.pollutionMaxX = x; + map.pollutionMaxY = y; + } + } + } + } + + if (pollutedTileCount) census.pollutionAverage = Math.floor(totalPollution / pollutedTileCount);else census.pollutionAverage = 0; + MapUtils.smoothMap(tempMap3, terrainDensityMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + } // Computes the coverage radius of police stations, and scores each neighbourhood in the map on its crime rate. + // Factors that attract crime are: + // * The zone has a low value + // * The zone is a slum + // * The zone is far away from those pesky police + + + static crimeScan(census, blockMaps) { + let policeStationMap = blockMaps.policeStationMap; + let policeStationEffectMap = blockMaps.policeStationEffectMap; + let crimeRateMap = blockMaps.crimeRateMap; + let landValueMap = blockMaps.landValueMap; + let populationDensityMap = blockMaps.populationDensityMap; + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationEffectMap, policeStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + let totalCrime = 0; + let crimeZoneCount = 0; + let x, + y, + width = crimeRateMap.mapWidth, + height = crimeRateMap.mapHeight, + value; // Scan the map, looking for developed land, as it can attract crime. + + for (x = 0; x < width; x += blockSize) { + for (y = 0; y < height; y += blockSize) { + // Remember: landValueMap values are in the range 0-250 + value = landValueMap.worldGet(x, y); + + if (value > 0) { + crimeZoneCount += 1; // Force value in the range -122 to 128. Lower valued pieces of land attract more crime. + + value = 128 - value; // Add population density (a value between 0 and 510). value now lies in range -260 - 382. + // Denser areas attract more crime. + + value += populationDensityMap.worldGet(x, y); // Clamp in range -260 to 300 + + value = Math.min(value, 300); // If the police are nearby, there's no point committing the crime of the century + + value -= policeStationMap.worldGet(x, y); // Force in to range 0-250 + + value = math.clamp(value, 0, 250); + crimeRateMap.worldSet(x, y, value); + totalCrime += value; + } else { + crimeRateMap.worldSet(x, y, 0); + } + } + } + + if (crimeZoneCount > 0) census.crimeAverage = Math.floor(totalCrime / crimeZoneCount);else census.crimeAverage = 0; + } // Iterate over the map, and score each neighbourhood on its distance from the city centre. Scores are in the range + // -64 to 64. This affects the growth of commercial zones within that neighbourhood. + + + static fillCityCentreDistScoreMap(map, blockMaps) { + let bm = blockMaps.cityCentreDistScoreMap; + let x = bm.width, + y, + value; + + while (x--) { + y = bm.height; + + while (y--) { + // First, we compute the Manhattan distance of the top-left hand corner of the neighbourhood to the city centre + // and half that value. This leaves us a value in the range 0 - 32 + value = Math.floor(MapUtils.getCityCentreDistance(map, x * 8, y * 8) / 2); // Now, we scale up by a factor of 4. We're in the range 0 - 128 + + value = value * 4; // And finally, subtract from 64, leaving us a score in the range -64 to 64 + + value = 64 - value; + bm.set(x, y, value); + } + } + } + + // Dispatch to the correct zone type to get the population value for that zone + static getPopulationDensity(map, x, y, tile) { + if (tile < Tile.COMBASE) return Residential.getZonePopulation(map, x, y, tile); + if (tile < Tile.INDBASE) return Commercial.getZonePopulation(map, x, y, tile) * 8; + if (tile < Tile.PORTBASE) return Industrial.getZonePopulation(map, x, y, tile) * 8; + return 0; + } // Iterate over the map, examining each zone for population. We then smooth the results into a population density + // map, which is used when deciding to grow residential zones. At the same time, we also note the most populous area + // (in terms of zones) to calculate our city centre. Finally, we score each area of the map on its distance from the + // city centre. + + + static populationDensityScan(map, blockMaps) { + // We will build the initial unsmoothed map in tempMap1, and smooth it in to tempMap2 + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; + blockMaps.populationDensityMap; // We will sum all the coordinates that contain zones into xTot and yTot. They are used in our city centre heuristic. + + let Xtot = 0; + let Ytot = 0; + let zoneTotal = 0; + tempMap1.clear(); + let x = map.width, + y, + tile, + tileValue, + population; + + while (x--) { + y = map.height; + + while (y--) { + tile = map.getTile(x, y); + + if (tile.isZone()) { + tileValue = tile.getValue(); // Ask the zone to calculate its population, scale it up, then clamp in the range 0-254 + + population = MapUtils.getPopulationDensity(map, x, y, tileValue) * 8; + population = Math.min(population, 254); // The block size of population density is 2x2, so there can only be 1 zone per block + + tempMap1.worldSet(x, y, population); + Xtot += x; + Ytot += y; + zoneTotal++; + } + } + } + + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + blockMaps.populationDensityMap.copyFrom(tempMap2, function (x) { + return x * 2; + }); // XXX This follows the original Micropolis source, but it feels weird to me that we score the entire map + // based on city centre proximity, and then potentially move the city centre. I think these should be + // swapped. + + MapUtils.fillCityCentreDistScoreMap(map, blockMaps); // Compute new city center + + if (zoneTotal > 0) { + map.cityCentreX = Math.floor(Xtot / zoneTotal); + map.cityCentreY = Math.floor(Ytot / zoneTotal); + } else { + map.cityCentreX = Math.floor(map.width * 0.5); + map.cityCentreY = Math.floor(map.height * 0.5); + } + } // Compute the radius of coverage for the firestations found during the map scan + + + static fireAnalysis(blockMaps) { + let fireStationMap = blockMaps.fireStationMap; + let fireStationEffectMap = blockMaps.fireStationEffectMap; + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationEffectMap, fireStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ + class Simulation { + constructor(gameMap, gameLevel, speed, is3D, savedGame) { + if (gameLevel !== Micro.LEVEL_EASY && gameLevel !== Micro.LEVEL_MED && gameLevel !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); // if (speed !== Micro.SPEED_PAUSED && speed !== Micro.SPEED_SLOW && speed !== Micro.SPEED_MED && speed !== Micro.SPEED_FAST) throw new Error('Invalid speed!'); + + this.map = gameMap; + this.gameLevel = gameLevel; + this.div = this.map.width / 8; + this.is3D = is3D || false; + this.time = typeof performance === 'undefined' ? Date : performance; + this.speed = speed; + this.speedCycle = 0; + this.phaseCycle = 0; + this.simCycle = 0; + this.doInitialEval = true; + this.cityTime = 50; + this.cityPopLast = 0; + this.messageLast = Messages.VILLAGE_REACHED; + this.startingYear = 1900; // Last valves updated to the user + + this.resValveLast = 0; + this.comValveLast = 0; + this.indValveLast = 0; // Last date sent to front end + + this._cityYearLast = -1; + this._cityMonthLast = -1; // Last time we relayed a message from PowerManager to the front-end + + this._lastPowerMessage = null; + this.infos = []; // And now, the main cast of characters + + this.evaluation = new Evaluation(this.gameLevel); + this.valves = new Valves(); + this.budget = new Budget(); + this.census = new Census(); + this.powerManager = new PowerManager(this.map); + this.spriteManager = new SpriteManager(this.map); + this.mapScanner = new MapScanner(this.map); + this.repairManager = new RepairManager(this.map); + this.traffic = new Traffic(this.map, this.spriteManager); + this.disasterManager = new DisasterManager(this.map, this.spriteManager, this.gameLevel); + this.messageManager = new MessageManager(); + Micro.messageManager = this.messageManager; + let w = this.map.width, + h = this.map.height; + this.blockMaps = { + // Holds a "distance score" for the block from the city centre, range -64 to 64 + cityCentreDistScoreMap: new BlockMap(w, h, 8), + // Holds a score representing how dangerous an area is, in range 0-250 (larger is worse) + crimeRateMap: new BlockMap(w, h, 2), + // A map used to note positions of fire stations during the map scan, range 0-1000 + fireStationMap: new BlockMap(w, h, 8), + // Holds a value containing a score representing the effect of fire cover in this neighborhood, range 0-1000 + fireStationEffectMap: new BlockMap(w, h, 8), + // Holds scores representing the land value in the range 0-250 + landValueMap: new BlockMap(w, h, 2), + // A map used to note positions of police stations during the map scan, range 0-1000 + policeStationMap: new BlockMap(w, h, 8), + // Holds a value containing a score representing how much crime is dampened in this block, range 0-1000 + policeStationEffectMap: new BlockMap(w, h, 8), + // Holds a value representing the amount of pollution in a neighbourhood, in the range 0-255 + pollutionDensityMap: new BlockMap(w, h, 2), + // Holds a value representing population density of a block, in the range 0-510 + populationDensityMap: new BlockMap(w, h, 2), + // Holds a value representing the rate of growth of a neighbourhood in the range -200 to +200 + rateOfGrowthMap: new BlockMap(w, h, 8), + // Scores a block on how undeveloped/unspoilt it is, range 0-240 + terrainDensityMap: new BlockMap(w, h, 4), + // Scores the volume of traffic in this cluster, range 0-240 + trafficDensityMap: new BlockMap(w, h, 2), + // Temporary maps + tempMap1: new BlockMap(w, h, 2), + tempMap2: new BlockMap(w, h, 2), + tempMap3: new BlockMap(w, h, 4) + }; + this.clearCensus(); + + if (savedGame) { + this.load(savedGame); //this.cityPopLast = savedGame.totalPop; + } else { + this.budget.setFunds(20000); + this.census.totalPop = 1; + } + + Micro.simData = this; + this.init(); + } + + save(saveData) { + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) saveData[Micro.savePropsVar[i]] = this[Micro.savePropsVar[i]]; + + this.map.save(saveData); + this.evaluation.save(saveData); + this.valves.save(saveData); + this.budget.save(saveData); + this.census.save(saveData); + } + + load(saveData) { + //console.log(saveData) + this.messageManager.clear(); + + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) this[Micro.savePropsVar[i]] = saveData[Micro.savePropsVar[i]]; //this.map.load(saveData); + + + this.evaluation.load(saveData); + this.valves.load(saveData); + this.budget.load(saveData); + this.census.load(saveData); + } + + setSpeed(s) { + this.speed = s; + } + + setDifficulty(s) { + if (s !== Micro.LEVEL_EASY && s !== Micro.LEVEL_MED && s !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); + this.gameLevel = s; + this.disasterManager.setDifficulty(this.gameLevel); + } + + isPaused() { + return this.speed === Micro.SPEED_PAUSED; + } + + simTick() { + let up = this.simFrame(); + + if (up) { + this.updateTime(); + this.updateInfo(); + } + + return up; + } + + updateInfo() { + this.infos[0] = [TXT.months[this._cityMonthLast], this._cityYearLast].join(' '); + this.infos[1] = TXT.cityClass[this.evaluation.cityScore]; + this.infos[2] = this.evaluation.cityScore; + this.infos[3] = this.evaluation.cityPop; + this.infos[4] = this.budget.totalFunds; + this.infos[5] = this.valves.resValve; + this.infos[6] = this.valves.comValve; + this.infos[7] = this.valves.indValve; //this.infos[8] = '' // message + + this.infos[9] = this.map.powerChange; + this.map.powerChange = false; + return this.infos; + } + + simFrame() { + if (this.budget.awaitingValues) return false; + if (this.speed === Micro.SPEED_PAUSED) return false; // Default to slow speed + + let threshold = 100; + if (this.speed === Micro.SPEED_MED) threshold = 50; + if (this.speed === Micro.SPEED_FAST) threshold = 10; + if (this.speed === Micro.SPEED_ULTRA) threshold = 5; + let now = this.time.now(); //new Date() + + if (now - this.prevTime < threshold) return false; + this.messageManager.clear(); + this.simulate(); + this.prevTime = now; + return true; + } + + clearCensus() { + this.census.clearCensus(); + this.powerManager.clearPowerStack(); + this.blockMaps.fireStationMap.clear(); + this.blockMaps.policeStationMap.clear(); + } + + init() { + this.prevTime = -1; // Register actions + + this.powerManager.registerHandlers(this.mapScanner, this.repairManager); + Commercial.registerHandlers(this.mapScanner, this.repairManager); + EmergencyServices.registerHandlers(this.mapScanner, this.repairManager); + Industrial.registerHandlers(this.mapScanner, this.repairManager); + MiscTiles.registerHandlers(this.mapScanner, this.repairManager); + Road.registerHandlers(this.mapScanner, this.repairManager); + Residential.registerHandlers(this.mapScanner, this.repairManager); + Stadia.registerHandlers(this.mapScanner, this.repairManager); + Transport.registerHandlers(this.mapScanner, this.repairManager); + this.evaluation.evalInit(); + this.valves.setValves(this.gameLevel, this.census, this.budget); + this.clearCensus(); //this.mapScanner.mapScan(0, this.map.width, simData); + + this.mapScanner.mapScan(0, this.map.width, null); + this.powerManager.doPowerScan(this.census); + MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); + MapUtils.crimeScan(this.census, this.blockMaps); + MapUtils.populationDensityScan(this.map, this.blockMaps); + MapUtils.fireAnalysis(this.blockMaps); //this.census.totalPop = 1; + // if (savedGame) this.load(savedGame); + } + + simulate() { + this.phaseCycle &= 15; + let speedIndex = this.speed - 1; + + switch (this.phaseCycle) { + case 0: + if (++this.simCycle > 1023) this.simCycle = 0; + + if (this.doInitialEval) { + this.doInitialEval = false; + this.evaluation.cityEvaluation(); + } + + this.cityTime++; + if ((this.simCycle & 1) === 0) this.valves.setValves(this.gameLevel, this.census, this.budget); + this.clearCensus(); + break; + + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + this.mapScanner.mapScan((this.phaseCycle - 1) * this.div, this.phaseCycle * this.div, null); + break; + + case 9: + if (this.cityTime % Micro.CENSUS_FREQUENCY_10 === 0) this.census.take10Census(this.budget); + if (this.cityTime % Micro.CENSUS_FREQUENCY_120 === 0) this.census.take120Census(this.budget); + + if (this.cityTime % Micro.TAX_FREQUENCY === 0) { + this.budget.collectTax(this.gameLevel, this.census); + this.evaluation.cityEvaluation(); + } + break; + + case 10: + if (this.simCycle % 5 === 0) { + MapUtils.neutraliseRateOfGrowthMap(this.blockMaps); + } + MapUtils.neutraliseTrafficMap(this.blockMaps); + this.sendMessages(); + break; + + case 11: + if (this.simCycle % Micro.speedPowerScan[speedIndex] === 0) this.powerManager.doPowerScan(this.census); + break; + + case 12: + if (this.simCycle % Micro.speedPollutionTerrainLandValueScan[speedIndex] === 0) MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); + break; + + case 13: + if (this.simCycle % Micro.speedCrimeScan[speedIndex] === 0) MapUtils.crimeScan(this.census, this.blockMaps); + break; + + case 14: + if (this.simCycle % Micro.speedPopulationDensityScan[speedIndex] === 0) MapUtils.populationDensityScan(this.map, this.blockMaps); + break; + + case 15: + if (this.simCycle % Micro.speedFireAnalysis[speedIndex] === 0) MapUtils.fireAnalysis(this.blockMaps); + this.disasterManager.doDisasters(this.census); + break; + } // Go on the the next phase. + + + this.phaseCycle = this.phaseCycle + 1 & 15; + } + + sendMessages() { + this.checkGrowth(); + let totalZonePop = this.census.resZonePop + this.census.comZonePop + this.census.indZonePop; + let powerPop = this.census.nuclearPowerPop + this.census.coalPowerPop; + + switch (this.cityTime & 63) { + case 1: + if (Math.floor(totalZonePop / 4) >= this.census.resZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_RESIDENTIAL); + break; + + case 5: + if (Math.floor(totalZonePop / 8) >= this.census.comZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_COMMERCIAL); + break; + + case 10: + if (Math.floor(totalZonePop / 8) >= this.census.indZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_INDUSTRIAL); + break; + + case 14: + if (totalZonePop > 10 && totalZonePop * 2 > this.census.roadTotal) this.messageManager.sendMessage(Messages.NEED_MORE_ROADS); + break; + + case 18: + if (totalZonePop > 50 && totalZonePop > this.census.railTotal) this.messageManager.sendMessage(Messages.NEED_MORE_RAILS); + break; + + case 22: + if (totalZonePop > 10 && powerPop == 0) this.messageManager.sendMessage(Messages.NEED_ELECTRICITY); + break; + + case 26: + if (this.census.resPop > 500 && this.census.stadiumPop === 0) { + this.messageManager.sendMessage(Messages.NEED_STADIUM); + this.valves.resCap = true; + } else { + this.valves.resCap = false; + } + break; + + case 28: + if (this.census.indPop > 70 && this.census.seaportPop === 0) { + this.messageManager.sendMessage(Messages.NEED_SEAPORT); + this.valves.indCap = true; + } else { + this.valves.indCap = false; + } + break; + + case 30: + if (this.census.comPop > 100 && this.census.airportPop === 0) { + this.messageManager.sendMessage(Messages._NEED_AIRPORT); + this.valves.comCap = true; + } else { + this.valves.comCap = false; + } + break; + + case 32: + let zoneCount = this.census.unpoweredZoneCount + this.census.poweredZoneCount; + + if (zoneCount > 0) { + if (this.census.poweredZoneCount / zoneCount < 0.7) this.messageManager.sendMessage(Messages.BLACKOUTS_REPORTED); + } + break; + + case 35: + if (this.census.pollutionAverage > 60) this.messageManager.sendMessage(Messages.HIGH_POLLUTION); + break; + + case 42: + if (this.census.crimeAverage > 100) this.messageManager.sendMessage(Messages.HIGH_CRIME); + break; + + case 45: + if (this.census.totalPop > 60 && this.census.fireStationPop === 0) this.messageManager.sendMessage(Messages.NEED_FIRE_STATION); + break; + + case 48: + if (this.census.totalPop > 60 && this.census.policeStationPop === 0) this.messageManager.sendMessage(Messages.NEED_POLICE_STATION); + break; + + case 51: + if (this.budget.cityTax > 12) this.messageManager.sendMessage(Messages.TAX_TOO_HIGH); + break; + + case 54: + if (this.budget.roadEffect < Math.floor(5 * this.budget.MAX_ROAD_EFFECT / 8) && this.census.roadTotal > 30) this.messageManager.sendMessage(Messages.ROAD_NEEDS_FUNDING); + break; + + case 57: + if (this.budget.fireEffect < Math.floor(7 * this.budget.MAX_FIRE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.FIRE_STATION_NEEDS_FUNDING); + break; + + case 60: + if (this.budget.policeEffect < Math.floor(7 * this.budget.MAX_POLICE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.POLICE_NEEDS_FUNDING); + break; + + case 63: + if (this.census.trafficAverage > 60) this.messageManager.sendMessage(Messages.TRAFFIC_JAMS, -1, -1, true); + break; + } + } + + checkGrowth() { + if ((this.cityTime & 3) !== 0) return; + let message = ''; + let cityPop = this.evaluation.getPopulation(this.census); + + if (cityPop !== this.cityPopLast) { + let lastClass = this.evaluation.getCityClass(this.cityPopLast); + let newClass = this.evaluation.getCityClass(cityPop); + + if (lastClass !== newClass) { + switch (newClass) { + case Micro.CC_VILLAGE: + // Don't mention it. + break; + + case Micro.CC_TOWN: + message = Messages.REACHED_TOWN; + break; + + case Micro.CC_CITY: + message = Messages.REACHED_CITY; + break; + + case Micro.CC_CAPITAL: + message = Messages.REACHED_CAPITAL; + break; + + case Micro.CC_METROPOLIS: + message = Messages.REACHED_METROPOLIS; + break; + + case Micro.CC_MEGALOPOLIS: + message = Messages.REACHED_MEGALOPOLIS; + break; + } + } + } + + if (message !== '' && message !== this.messageLast) { + this.messageManager.sendMessage(message); + this.messageLast = message; + } + + this.cityPopLast = cityPop; + } // update date + + + setYear(year) { + if (year < this.startingYear) year = this.startingYear; + year = year - this.startingYear - this.cityTime / 48; + this.cityTime += year * 48; + this.updateTime(); + } + + updateTime() { + let megalinium = 1000000; + let cityYear = Math.floor(this.cityTime / 48) + this.startingYear; + let cityMonth = Math.floor(this.cityTime % 48) >> 2; + + if (cityYear >= megalinium) { + this.setYear(this.startingYear); + return; + } + + if (this._cityYearLast !== cityYear || this._cityMonthLast !== cityMonth) { + this._cityYearLast = cityYear; + this._cityMonthLast = cityMonth; + this.messageManager.sendMessage(Messages.DATE_UPDATED, { + month: cityMonth, + year: cityYear + }); + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class TileHistory { + constructor() { + this.clear(); + } + + clear() { + this.data = {}; + } + + toKey(x, y) { + return [x, y].join(','); + } + + getTile(x, y) { + let key = this.toKey(x, y); + return this.data[key]; + } + + setTile(x, y, value) { + let key = this.toKey(x, y); + this.data[key] = value; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + class AnimationManager { + constructor(map, animationPeriod, blinkPeriod) { + animationPeriod = animationPeriod || 5; + blinkPeriod = blinkPeriod || 30; + this._map = map; + this.animationPeriod = animationPeriod; + this.blinkPeriod = blinkPeriod; + this.shouldBlink = false; + this.count = 1; // When painting we keep track of what frames + // have been painted at which map coordinates so we can + // consistently display the correct frame even as the + // canvas moves + + this._lastPainted = null; + this._data = []; + this.initArray(); + this.registerAnimations(); + } + + initArray() { + // Map all tiles to their own value in case we ever + // look up a tile that is not animated + for (let i = 0; i < Tile.TILE_COUNT; i++) this._data[i] = i; + } + + inSequence(tileValue, lastValue) { + // It is important that we use the base value as the starting point + // rather than the last painted value: base values often don't recur + // in their sequences + let seen = [tileValue]; + let current = this._data[tileValue]; + + while (seen.indexOf(current) === -1) { + if (current === lastValue) return true; + seen.push(current); + current = this._data[current]; + } + + return false; + } + + getTiles(startX, startY, boundX, boundY, isPaused = false) { + let shouldChangeAnimation = false; + if (!isPaused) this.count += 1; + if (this.count % this.blinkPeriod === 0) this.shouldBlink = !this.shouldBlink; + if (this.count % this.animationPeriod === 0 && !isPaused) shouldChangeAnimation = true; + let newPainted = new TileHistory(); + let tilesToPaint = []; + + for (let x = startX; x < boundX; x++) { + for (let y = startY; y < boundY; y++) { + if (x < 0 || x >= this._map.width || y < 0 || y >= this._map.height) continue; + + let tile = this._map.getTile(x, y); + /*if (tile.isZone() && !tile.isPowered() && this.shouldBlink) { + tilesToPaint.push({x: x, y: y, tileValue: Tile.LIGHTNINGBOLT}); + continue; + }*/ + + + if (!tile.isAnimated()) continue; + let tileValue = tile.getValue(); + let newTile = Tile.TILE_INVALID; + let last; + if (this._lastPainted) last = this._lastPainted.getTile(x, y); + + if (shouldChangeAnimation) { + // Have we painted any of this sequence before? If so, paint the next tile + if (last && this.inSequence(tileValue, last)) { + newTile = this._data[last]; + + if (last === Tile.LASTTINYEXP) { + this._map.setTo(x, y, ZoneUtils.randomRubble()); + + newTile = this._map.getTileValue(x, y); + } else { + newTile = this._data[last]; + } + } else { + // Either we haven't painted anything here before, or the last tile painted + // there belongs to a different tile's animation sequence + newTile = this._data[tileValue]; + } + } else { + // Have we painted any of this sequence before? If so, paint the same tile + if (last && this.inSequence(tileValue, last)) newTile = last; + } + + if (newTile === Tile.TILE_INVALID) continue; + tilesToPaint.push({ + x: x, + y: y, + tileValue: newTile + }); + newPainted.setTile(x, y, newTile); + + this._map.setPaintValue(x, y, newTile); /// DIRECT SET TEXTURES + + } + } + + this._lastPainted = newPainted; + return tilesToPaint; + } + + registerSingleAnimation(arr) { + for (let i = 1; i < arr.length; i++) this._data[arr[i - 1]] = arr[i]; + } + + registerAnimations() { + this.registerSingleAnimation([56, 57, 58, 59, 60, 61, 62, 63, 56]); // fire + + this.registerSingleAnimation([860, 861, 862, 863, 864, 865, 866, 867]); // explosion + // traffic + + this.registerSingleAnimation([80, 128, 112, 96, 80]); + this.registerSingleAnimation([81, 129, 113, 97, 81]); + this.registerSingleAnimation([82, 130, 114, 98, 82]); + this.registerSingleAnimation([83, 131, 115, 99, 83]); + this.registerSingleAnimation([84, 132, 116, 100, 84]); + this.registerSingleAnimation([85, 133, 117, 101, 85]); + this.registerSingleAnimation([86, 134, 118, 102, 86]); + this.registerSingleAnimation([87, 135, 119, 103, 87]); + this.registerSingleAnimation([88, 136, 120, 104, 88]); + this.registerSingleAnimation([89, 137, 121, 105, 89]); + this.registerSingleAnimation([90, 138, 122, 106, 90]); + this.registerSingleAnimation([91, 139, 123, 107, 91]); + this.registerSingleAnimation([92, 140, 124, 108, 92]); + this.registerSingleAnimation([93, 141, 125, 109, 93]); + this.registerSingleAnimation([94, 142, 126, 110, 94]); + this.registerSingleAnimation([95, 143, 127, 111, 95]); + this.registerSingleAnimation([144, 192, 176, 160, 144]); + this.registerSingleAnimation([145, 193, 177, 161, 145]); + this.registerSingleAnimation([146, 194, 178, 162, 146]); + this.registerSingleAnimation([147, 195, 179, 163, 147]); + this.registerSingleAnimation([148, 196, 180, 164, 148]); + this.registerSingleAnimation([149, 197, 181, 165, 149]); + this.registerSingleAnimation([150, 198, 182, 166, 150]); + this.registerSingleAnimation([151, 199, 183, 167, 151]); + this.registerSingleAnimation([152, 200, 184, 168, 152]); + this.registerSingleAnimation([153, 201, 185, 169, 153]); + this.registerSingleAnimation([154, 202, 186, 170, 154]); + this.registerSingleAnimation([155, 203, 187, 171, 155]); + this.registerSingleAnimation([156, 204, 188, 172, 156]); + this.registerSingleAnimation([157, 205, 189, 173, 157]); + this.registerSingleAnimation([158, 206, 190, 174, 158]); + this.registerSingleAnimation([159, 207, 191, 175, 159]); + /* + // NOT NEED + this.registerSingleAnimation([621, 852, 853, 854, 855, 856, 857, 858, 859, 852]);// industrial polution + this.registerSingleAnimation([641, 884, 885, 886, 887, 884]); + this.registerSingleAnimation([644, 888, 889, 890, 891, 888]); + this.registerSingleAnimation([649, 892, 893, 894, 895, 892]); + this.registerSingleAnimation([650, 896, 897, 898, 899, 896]); + this.registerSingleAnimation([676, 900, 901, 902, 903, 900]); + this.registerSingleAnimation([677, 904, 905, 906, 907, 904]); + this.registerSingleAnimation([686, 908, 909, 910, 911, 908]); + this.registerSingleAnimation([689, 912, 913, 914, 915, 912]); + this.registerSingleAnimation([747, 916, 917, 918, 919, 916]); + this.registerSingleAnimation([748, 920, 921, 922, 923, 920]); + this.registerSingleAnimation([751, 924, 925, 926, 927, 924]); + this.registerSingleAnimation([752, 928, 929, 930, 931, 928]); + this.registerSingleAnimation([820, 952, 953, 954, 955, 952]); + this.registerSingleAnimation([832, 833, 834, 835, 836, 837, 838, 839, 832]); + this.registerSingleAnimation([840, 841, 842, 843, 840]); + this.registerSingleAnimation([844, 845, 846, 847, 848, 849, 850, 851, 844]); + this.registerSingleAnimation([932, 933, 934, 935, 936, 937, 938, 939, 932]);// football + this.registerSingleAnimation([940, 941, 942, 943, 944, 945, 946, 947, 940]);// football + */ + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ + + class GameMap { + constructor(width = 128, height = 128, defaultValue) { + this.isIsland = false; + this.pp = []; //this.Position = new PositionMaker( width, height ); // !! find better way + + this.width = width; + this.height = height; + this.fsize = this.width * this.height; + this.defaultValue = new Tiles().getValue(); + this.data = []; //new Array(this.fsize); + + this.tilesData = new Micro.M_ARRAY_TYPE(this.fsize); + this.powerData = new Micro.M_ARRAY_TYPE(this.fsize); + let i = this.fsize; + + while (i--) { + this.data[i] = new Tiles(this.defaultValue); + this.tilesData[i] = this.defaultValue; + } + /*console.log(this.data.length)*/ + // Generally set externally + + + this.cityCentreX = Math.floor(this.width * 0.5); + this.cityCentreY = Math.floor(this.height * 0.5); + this.pollutionMaxX = this.cityCentreX; + this.pollutionMaxY = this.cityCentreY; + this.powerChange = false; + this.layer = []; + this.resetLayer(); + this.makePP(); + } // 3D LAYER + + + upLayer(id, value, x, y) { + if (value >= Tile.TINYEXP && value <= Tile.TINYEXPLAST) value -= 860 - 35; // explosion decal + //if(value>=Tile.HBRDG0 && value<=Tile.HBRDG3) value -= 832+32 + //if(value>=Tile.VBRDG0 && value<=Tile.VBRDG3) value -= 832+32 + + this.tilesData[id] = value; //if( this.goodValue(value) ){ + + this.layer[this.findLayer(x, y)] = 1; + } + + resetLayer() { + let i = 64; + + while (i--) this.layer[i] = 0; + } + + findLayer(x, y) { + let cx = Math.floor(x / 16); + let cy = Math.floor(y / 16); + return cx + cy * 8; + } + + goodValue(v) { + if (v === 0) return true; // dirt + else if (v > 1 && v < 240) return true; // water edge tree + //else if( v > 1 && v < 44 ) return true // water edge tree + //if( v > 43 && v < 48 ) return true // rubble + // else if( v > 43 && v < 240 ) return true // road wire rail + + return false; + } // + + + makePP() { + let x = this.width, + y, + n = 0; + let pp = []; + + while (x--) { + y = this.height; + + while (y--) { + pp[n] = [x, y]; + n++; + } + } + + this.pp = pp; + } // change power statue for 3d + + + powered(o) { + let id = o.id || this.getId(o.x, o.y); + this.powerData[id] = o.v; + this.powerChange = true; + } + /*makePos (){ + return new PositionMaker( this.width, this.height ); + }*/ + + + save(saveData) { + let i = 0, + lng; // GAME PROPS + + lng = Micro.GameMapProps.length; + + while (i < lng) { + saveData[Micro.GameMapProps[i]] = this[Micro.GameMapProps[i]]; + i++; + } // MAP DATA + //saveData.map = this.data.map(function(t) { return {value: t.getRawValue()}; }); + + + saveData.map = []; + i = 0; + lng = this.fsize; + + while (i < lng) { + saveData.map[i] = this.data[i].getRawValue(); + i++; + } // TILES VALUES + + + saveData.tileValue = []; + i = 0; + lng = this.fsize; + + while (i < lng) { + saveData.tileValue[i] = this.tilesData[i]; + i++; + } + } + + load(saveData) { + let x, + y, + lng, + i = 0, + map = saveData.map, + tiles = saveData.tileValue; // GAME PROPS + + lng = Micro.GameMapProps.length; + + while (i < lng) { + this[Micro.GameMapProps[i]] = saveData[Micro.GameMapProps[i]]; + i++; + } // MAP DATA + + + let isOld = map[0].value !== undefined ? true : false; + i = 0; + lng = this.fsize; + + while (i < lng) { + x = i % this.width; + y = Math.floor(i / this.width); + if (isOld) this.setTileValue(x, y, map[i].value);else this.setTileValue(x, y, map[i]); + i++; + } // TILES VALUES + + + i = 0; + lng = this.fsize; + + while (i < lng) { + this.tilesData[i] = tiles[i]; + i++; + } + } + + testBounds(x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + } + + getId(x, y) { + return x + y * this.width; + } + + getTile(x, y, newTile) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof x === 'object') { + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let width = this.width; + let height = this.height; + + if (x < 0 || y < 0 || x >= width || y >= height) { + console.warn('getTile called with bad bounds', x, y); + return new Tiles(Tile.TILE_INVALID); + } + + let tileIndex = this.getId(x, y); + let tile = this.data[tileIndex]; //var tileIndex = this._calculateIndex(x, y); + // Return the original tile if we're not given a tile to fill + + if (!newTile) return tile; + newTile.set(tile); + return tile; //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + //return this.data[tileIndex]; + } + + getTileValue(x, y) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; // Argument-shuffling + + if (typeof x === 'object') { + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw e; + let tileIndex = this.getId(x, y); + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getValue(); + } + + getTileFlags(x, y) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; // Argument-shuffling + + if (typeof x === 'object') { + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw e; + let tileIndex = this.getId(x, y); + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getFlags(); + } + + getTiles(x, y, w, h) { + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; // Argument-shuffling + + if (arguments.length === 3) { + h = w; + w = y; + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw e; + let res = []; + + for (let a = y, ylim = y + h; a < ylim; a++) { + res[a - y] = []; + + for (let b = x, xlim = x + w; b < xlim; b++) { + let tileIndex = this.getId(b, a); //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + + res[a - y].push(this.data[tileIndex]); + } + } + + return res; + } + + getTileValues(x, y, w, h, result) { + result = result || []; + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; // Argument-shuffling + + if (arguments.length === 3) { + h = w; + w = y; + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let width = this.width; + let height = this.height; // Result is stored in row-major order + + for (let a = y, ylim = y + h; a < ylim; a++) { + for (let b = x, xlim = x + w; b < xlim; b++) { + if (a < 0 || b < 0 || a >= height || b >= width) { + result[(a - y) * w + (b - x)] = Tile.TILE_INVALID; + continue; + } + + let tileIndex = b + a * width; //result[(a - y) * w + (b - x)] = this._data[tileIndex].getRawValue(); + + result[(a - y) * w + (b - x)] = this.data[tileIndex].getRawValue(); + } + } + + return result; + } + + getTileFromMapOrDefault(pos, dir, defaultTile) { + switch (dir) { + case Direction.NORTH: + if (pos.y > 0) return this.getTileValue(pos.x, pos.y - 1); + return defaultTile; + + case Direction.EAST: + if (pos.x < this.width - 1) return this.getTileValue(pos.x + 1, pos.y); + return defaultTile; + + case Direction.SOUTH: + if (pos.y < this.height - 1) return this.getTileValue(pos.x, pos.y + 1); + return defaultTile; + + case Direction.WEST: + if (pos.x > 0) return this.getTileValue(pos.x - 1, pos.y); + return defaultTile; + + default: + return defaultTile; + } + } //---------------------- + + + testOld(id, value) { + if (this.data[id].getValue() !== value) return true; + return false; + } + + setTile(x, y, value, flags) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 3) throw e; + // Argument-shuffling + if (arguments.length === 3) { + flags = value; + value = y; + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let id = this.getId(x, y); + let isNew = this.testOld(id, value); + this.data[id].set(value, flags); + if (isNew) this.upLayer(id, value, x, y); + } + + setTo(x, y, tile) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (tile === undefined) { + tile = y; + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let id = this.getId(x, y); + let value = tile.getValue(); + let isNew = this.testOld(id, value); + this.data[id] = tile; // this.data[ id ].setValue(value); + + if (isNew) this.upLayer(id, value, x, y); + } + + setTileValue(x, y, value) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { + value = y; + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let id = this.getId(x, y); + let isNew = this.testOld(id, value); //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + + this.data[id].setValue(value); + if (isNew) this.upLayer(id, value, x, y); + } + + setPaintValue(x, y, value) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { + value = y; + y = x.y; + x = x.x; + } //if (!this.testBounds(x, y)) throw e; + + + let id = this.getId(x, y); + this.upLayer(id, value, x, y); + } + + setTileFlags(x, y, flags) { + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; // Argument-shuffling + + if (arguments.length === 2) { + flags = y; + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw e; + let id = this.getId(x, y); + this.data[id].setFlags(flags); + } + + addTileFlags(x, y, flags) { + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; // Argument-shuffling + + if (arguments.length === 2) { + flags = y; + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw e; + let id = this.getId(x, y); + this.data[id].addFlags(flags); + } + + removeTileFlags(x, y, flags) { + if (arguments.length < 2) throw new Error('GameMap removeTileFlags called with too few arguments'); + + if (arguments.length === 2) { + flags = y; + y = x.y; + x = x.x; + } + + if (!this.testBounds(x, y)) throw new Error('GameMap removeTileFlags called with invalid bounds' + x + ', ' + y); + let id = this.getId(x, y); + this.data[id].removeFlags(flags); ///this.upLayer( id, this.data[id].getValue(), x, y ) + } + + putZone(centreX, centreY, centreTile, size) { + if (!this.testBounds(centreX, centreY) || !this.testBounds(centreX - 1 + size, centreY - 1 + size)) throw new Error('GameMap putZone called with invalid bounds'); + let tile = centreTile - 1 - size; + let startX = centreX - 1; + let startY = centreY - 1; + let x, y; + + for (y = startY; y < startY + size; y++) { + for (x = startX; x < startX + size; x++) { + if (x === centreX && y === centreY) this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT | Tile.ZONEBIT));else this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT)); + tile += 1; + } + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + class MapGenerator { + constructor() { + this.SRMatrix = [[0, 0, 3, 3, 0, 0], [0, 3, 2, 2, 3, 0], [3, 2, 2, 2, 2, 3], [3, 2, 2, 2, 2, 3], [0, 3, 2, 2, 3, 0], [0, 0, 3, 3, 0, 0]]; + this.BRMatrix = [[0, 0, 0, 3, 3, 3, 0, 0, 0], [0, 0, 3, 2, 2, 2, 3, 0, 0], [0, 3, 2, 2, 2, 2, 2, 3, 0], [3, 2, 2, 2, 2, 2, 2, 2, 3], [3, 2, 2, 2, 4, 2, 2, 2, 3], [3, 2, 2, 2, 2, 2, 2, 2, 3], [0, 3, 2, 2, 2, 2, 2, 3, 0], [0, 0, 3, 2, 2, 2, 3, 0, 0], [0, 0, 0, 3, 3, 3, 0, 0, 0]]; + this.riverEdge = [13, 13, 17, 15, 5, 2, 19, 17, 9, 11, 2, 13, 7, 9, 5, 2]; + this.treeTable = [0, 0, 0, 34, 0, 0, 36, 35, 0, 32, 0, 33, 30, 31, 29, 37]; + } + + construct(w, h, debug = false) { + Micro.TERRAIN_TREE_LEVEL = -1; + Micro.TERRAIN_LAKE_LEVEL = -1; + Micro.TERRAIN_CURVE_LEVEL = -1; + Micro.ISLAND_RADIUS = 18; + if (debug) console.time("start newmap"); + this.map = new GameMap(w || Micro.MAP_WIDTH, h || Micro.MAP_HEIGHT); //this.map.makePP() + + Micro.TERRAIN_CREATE_ISLAND = math.getRandom(2) - 1; + + if (Micro.TERRAIN_CREATE_ISLAND < 0) { + if (math.getRandom(100) < 10) { + this.makeIsland(); + return this.map; + } + } + + if (Micro.TERRAIN_CREATE_ISLAND === 1) this.makeNakedIsland();else this.clearMap(); // Lay a river. + + if (Micro.TERRAIN_CURVE_LEVEL !== 0) { + let terrainXStart = 40 + math.getRandom(this.map.width - 79); + let terrainYStart = 33 + math.getRandom(this.map.height - 66); + let terrainPos = new Position(terrainXStart, terrainYStart); + this.doRivers(terrainPos); + } // Lay a few lakes. + + + if (Micro.TERRAIN_LAKE_LEVEL !== 0) this.makeLakes(); + this.smoothRiver(); + this.cleanBorder(); // And add trees. + + if (Micro.TERRAIN_TREE_LEVEL !== 0) this.doTrees(); + if (debug) console.timeEnd("start newmap"); + return this.map; + } + + cleanBorder() { + let map = this.map; + if (map.isIsland) return; + let x, y, l, r, s; + + for (x = 0; x < map.width; x++) { + l = x + 1; + if (l > map.width - 1) l = map.width - 1; + r = x - 1; + if (r < 0) r = 0; + s = 1; + if (map.getTileValue(x, s) + map.getTileValue(l, s) + map.getTileValue(r, s) === 6) map.setTile(x, 0, Tile.RIVER, 0); + s = map.height - 2; + if (map.getTileValue(x, s) + map.getTileValue(l, s) + map.getTileValue(r, s) === 6) map.setTile(x, map.height - 1, Tile.RIVER, 0); + } + + for (y = 0; y < map.height; y++) { + l = y + 1; + if (l > map.height - 1) l = map.height - 1; + r = y - 1; + if (r < 0) r = 0; + s = 1; + if (map.getTileValue(s, y) + map.getTileValue(s, l) + map.getTileValue(s, r) === 6) map.setTile(0, y, Tile.RIVER, 0); + s = map.width - 2; + if (map.getTileValue(s, y) + map.getTileValue(s, l) + map.getTileValue(s, r) === 6) map.setTile(map.width - 1, y, Tile.RIVER, 0); + } + } + + clearMap() { + let map = this.map; + map.pp.forEach(v => { + //function ( v ) { + map.setTile(v[0], v[1], Tile.DIRT, 0); + }); + } + + clearUnnatural() { + let map = this.map, + value; + map.pp.forEach(v => { + value = map.getTileValue(v[0], v[1]); + if (value > Tile.WOODS) map.setTile(v[0], v[1], Tile.DIRT, 0); + }); + } + + makeNakedIsland() { + let map = this.map; + let terrainIslandRadius = Micro.ISLAND_RADIUS; + let x, y, mapX, mapY; + map.isIsland = true; + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + if (x < 5 || x >= map.width - 5 || y < 5 || y >= map.height - 5) map.setTile(x, y, Tile.RIVER, 0);else map.setTile(x, y, Tile.DIRT, 0); + }); + + for (x = 0; x < map.width - 5; x += 2) { + mapY = math.getERandom(terrainIslandRadius); + this.plopBRiver({ + x: x, + y: mapY + }); + mapY = map.height - 10 - math.getERandom(terrainIslandRadius); + this.plopBRiver({ + x: x, + y: mapY + }); + this.plopSRiver({ + x: x, + y: 0 + }); + this.plopSRiver({ + x: x, + y: map.height - 6 + }); + } + + for (y = 0; y < map.height - 5; y += 2) { + mapX = math.getERandom(terrainIslandRadius); + this.plopBRiver({ + x: mapX, + y: y + }); + mapX = map.width - 10 - math.getERandom(terrainIslandRadius); + this.plopBRiver({ + x: mapX, + y: y + }); + this.plopSRiver({ + x: 0, + y: y + }); + this.plopSRiver({ + x: map.width - 6, + y: y + }); + } + } + + makeIsland() { + this.makeNakedIsland(); + this.smoothRiver(); + this.doTrees(); + } + + makeLakes() { + let x, y; + let numLakes = Micro.TERRAIN_LAKE_LEVEL < 0 ? math.getRandom(10) : Micro.TERRAIN_LAKE_LEVEL * 0.5; + + while (numLakes > 0) { + x = math.getRandom(this.map.width - 21) + 10; + y = math.getRandom(this.map.height - 20) + 10; + this.makeSingleLake(new Position(x, y)); + numLakes--; + } + } + + makeSingleLake(pos) { + let numPlops = math.getRandom(12) + 2, + plopPos; + + while (numPlops > 0) { + plopPos = new Position(pos, math.getRandom(12) - 6, math.getRandom(12) - 6); + if (math.getRandom(4)) this.plopSRiver(plopPos);else this.plopBRiver(plopPos); + numPlops--; + } + } + + treeSplash(x, y) { + let numTrees = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(150) + 50 : math.getRandom(100 + Micro.TERRAIN_TREE_LEVEL * 2) + 50; + let treePos = new Position(x, y), + dir; + + while (numTrees > 0) { + dir = Direction.NORTH + math.getRandom(7); + treePos.move(dir); // XXX Should use the fact that positions return success/failure for moves + + if (!this.map.testBounds(treePos.x, treePos.y)) return; + if (this.map.getTileValue(treePos) === Tile.DIRT) this.map.setTile(treePos, Tile.WOODS, Tile.BLBNBIT); + numTrees--; + } + } + + doTrees() { + let i = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(100) + 50 : Micro.TERRAIN_TREE_LEVEL + 3; + + while (i--) { + this.treeSplash(math.getRandom(this.map.width - 1), math.getRandom(this.map.height - 1)); + } + /*for (var x = 0; x < i; x++) { + var xloc = math.getRandom(this.map.width - 1); + var yloc = math.getRandom(this.map.height - 1); + this.treeSplash( xloc, yloc ); + }*/ + + + this.smoothTrees(); + this.smoothTrees(); + } + + smoothRiver() { + let map = this.map; + let riverEdge = this.riverEdge; + let x, y, z, xt, yt, tt, bitIndex, temp; + let dx = [-1, 0, 1, 0]; + let dy = [0, 1, 0, -1]; + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + + if (map.getTileValue(x, y) === Tile.REDGE) { + bitIndex = 0; + + for (z = 0; z < 4; z++) { + bitIndex = bitIndex << 1; + xt = x + dx[z]; + yt = y + dy[z]; + + if (map.testBounds(xt, yt)) { + tt = map.getTileValue(xt, yt); + if (tt !== Tile.DIRT && (tt < Tile.WOODS_LOW || tt > Tile.WOODS_HIGH)) bitIndex++; + } + } + + temp = riverEdge[bitIndex & 15]; + if (temp !== Tile.RIVER && math.getRandom(1)) temp++; //map.setTileValue(x, y, temp, 0); + + map.setTile(x, y, temp, Tile.BULLBIT); // or we can't make bridge !!! + } + }); + } + + isTree(value) { + return value >= Tile.WOODS_LOW && value <= Tile.WOODS_HIGH; + } + + smoothTrees() { + let map = this.map; + let x, y; + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + if (this.isTree(map.getTileValue(x, y))) this.smoothTreesAt(x, y, false); + }); + } + + smoothTreesAt(x, y, preserve) { + let map = this.map; + let dx = [-1, 0, 1, 0]; + let dy = [0, 1, 0, -1]; + if (!this.isTree(this.map.getTileValue(x, y))) return; + let i, + xTemp, + yTemp, + temp, + bitIndex = 0; + + for (i = 0; i < 4; i++) { + bitIndex = bitIndex << 1; + xTemp = x + dx[i]; + yTemp = y + dy[i]; + if (map.testBounds(xTemp, yTemp) && this.isTree(map.getTileValue(xTemp, yTemp))) bitIndex++; + } + + temp = this.treeTable[bitIndex & 15]; + + if (temp) { + if (temp !== Tile.WOODS) { + if (x + y & 1) temp -= 8; + } + + if (temp > 28 && temp < 38) temp -= 8; + map.setTile(x, y, temp, Tile.BLBNBIT); + } else { + if (!preserve) { + if (temp > 28 && temp < 38) temp -= 8; + map.setTileValue(x, y, temp, 0); + } + } + } + + doRivers(terrainPos) { + let riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doBRiver(terrainPos, riverDir, riverDir); + riverDir = Direction.rotate180(riverDir); + let terrainDir = this.doBRiver(terrainPos, riverDir, riverDir); + riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doSRiver(terrainPos, riverDir, terrainDir); + } + + doBRiver(riverPos, riverDir, terrainDir) { + let rate1, rate2; + + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + + let pos = new Position(riverPos); + + while (this.map.testBounds(pos.x + 4, pos.y + 4)) { + this.plopBRiver(pos); + + if (math.getRandom(rate1 + 1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2 + 1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2 + 1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + + pos.move(terrainDir); + } + + return terrainDir; + } + + doSRiver(riverPos, riverDir, terrainDir) { + let rate1, rate2; + + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + + let pos = new Position(riverPos); + + while (this.map.testBounds(pos.x + 3, pos.y + 3)) { + this.plopSRiver(pos); + + if (math.getRandom(rate1 + 1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2 + 1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2 + 1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + + pos.move(terrainDir); + } + + return terrainDir; + } + + putOnMap(newVal, x, y) { + if (newVal === 0) return; + if (!this.map.testBounds(x, y)) return; + let tmp = this.map.getTileValue(x, y); + + if (tmp !== Tile.DIRT) { + if (tmp === Tile.RIVER && newVal !== Tile.CHANNEL) return; + if (tmp === Tile.CHANNEL) return; + } + + this.map.setTile(x, y, newVal, 0); + } + + plopBRiver(pos) { + let x = 9, + y; + + while (x--) { + y = 9; + + while (y--) { + this.putOnMap(this.BRMatrix[y][x], pos.x + x, pos.y + y); + } + } + } + + plopSRiver(pos) { + let x = 6, + y; + + while (x--) { + y = 6; + + while (y--) { + this.putOnMap(this.SRMatrix[y][x], pos.x + x, pos.y + y); + } + } + } + + smoothWater() { + let map = this.map, + tile, + pos, + dir, + x, + y, + makeRiver; + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + tile = map.getTileValue(x, y); + + if (tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + pos = new Position(x, y); + + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); // If nearest object is not water: + + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + // set river edge + map.setTileValue(x, y, Tile.REDGE, 0); + break; // Continue with next tile + } + } + } + }); + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + tile = map.getTileValue(x, y); + + if (tile !== Tile.CHANNEL && tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + makeRiver = true; + pos = new Position(x, y); + + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); + + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + makeRiver = false; + break; + } + } + + if (makeRiver) map.setTileValue(x, y, Tile.RIVER, 0); + } + }); + map.pp.forEach(v => { + x = v[0]; + y = v[1]; + tile = map.getTileValue(x, y); + + if (tile >= Tile.WOODS_LOW && tile <= Tile.WOODS_HIGH) { + pos = new Position(x, y); + + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, TILE_INVALID); + + if (tile === Tile.RIVER || tile === Tile.CHANNEL) { + map.setTileValue(x, y, Tile.REDGE, 0); + break; + } + } + } + }); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class WorldEffects { + constructor(map) { + this._map = map; + this._data = {}; + } + + toKey(x, y) { + return [x, y].join(','); + } + + fromKey(k) { + k = k.split(','); + return { + x: k[0] - 0, + y: k[1] - 0 + }; + } + + clear() { + this._data = []; + } + + getTile(x, y) { + let key = this.toKey(x, y); + let tile = this._data[key]; + if (tile === undefined) tile = this._map.getTile(x, y); + return tile; + } + + getTileValue(x, y) { + return this.getTile(x, y).getValue(); + } + + setTile(x, y, value, flags) { + if (flags !== undefined && value.isTile) throw new Error('Flags supplied with already defined tile'); + if (flags === undefined && !value.isTile) value = new Tiles(value);else if (flags !== undefined) value = new Tiles(value, flags); + let key = this.toKey(x, y); + this._data[key] = value; + } + + apply() { + let keys = Object.keys(this._data); + + for (let i = 0, l = keys.length; i < l; i++) { + let coords = this.fromKey(keys[i]); + + this._map.setTo(coords, this._data[keys[i]]); + } + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BaseTool { + constructor() { + this.TOOLRESULT_OK = 0; + this.TOOLRESULT_FAILED = 1; + this.TOOLRESULT_NO_MONEY = 2; + this.TOOLRESULT_NEEDS_BULLDOZE = 3; + this.autoBulldoze = true; + this.bulldozerCost = 1; + } + + init(cost, map, shouldAutoBulldoze, IsDraggable = false) { + //Object.defineProperty(this, 'toolCost', MiscUtils.mcd(cost)); + this.toolCost = cost; + this.result = null; + this.isDraggable = IsDraggable; + this._shouldAutoBulldoze = shouldAutoBulldoze; + this._map = map; + this._worldEffects = new WorldEffects(map); + this._applicationCost = 0; + } + + clear() { + this._applicationCost = 0; + + this._worldEffects.clear(); + } + + addCost(cost) { + this._applicationCost += cost; + } + + doAutoBulldoze(x, y) { + //if ( !this._shouldAutoBulldoze ) return; + let tile = this._worldEffects.getTile(x, y); + + if (tile.isBulldozable()) { + tile = ZoneUtils.normalizeRoad(tile); + + if (tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP || tile < Tile.HBRIDGE && tile !== Tile.DIRT) { + this.addCost(1); + + this._worldEffects.setTile(x, y, Tile.DIRT); + } + } + } + + apply(budget) { + this._worldEffects.apply(); + + budget.spend(this._applicationCost); + this.clear(); + } + + modifyIfEnoughFunding(budget) { + if (this.result !== this.TOOLRESULT_OK) { + this.clear(); + return false; + } + + if (budget.totalFunds < this._applicationCost) { + this.result = this.TOOLRESULT_NO_MONEY; + this.clear(); + return false; + } + + this.apply.call(this, budget); + this.clear(); + return true; + } + + setAutoBulldoze(value) { + this.autoBulldoze = value; + } + + getAutoBulldoze() { + return this.autoBulldoze; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BaseToolConnector extends BaseTool { + constructor() { + super(); + } + + fixSingle(x, y) { + let adjTile = 0; + + let tile = this._worldEffects.getTile(x, y); + + tile = ZoneUtils.normalizeRoad(tile); + + if (tile >= Tile.ROADS && tile <= Tile.INTERSECTION) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 1; + } + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 2; + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 4; + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 8; + } + + this._worldEffects.setTile(x, y, RoadTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + + return; + } + + if (tile >= Tile.LHRAIL && tile <= Tile.LVRAIL10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 1; + } + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 2; + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 4; + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 8; + } + + this._worldEffects.setTile(x, y, RailTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + + return; + } + + if (tile >= Tile.LHPOWER && tile <= Tile.LVPOWER10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 1; + } + } + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 2; + } + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 4; + } + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 8; + } + } + + this._worldEffects.setTile(x, y, WireTable[adjTile] | Tile.BLBNCNBIT); + + return; + } + } + + checkZoneConnections(x, y) { + this.fixSingle(x, y); + if (y > 0) this.fixSingle(x, y - 1); + if (x < this._map.width - 1) this.fixSingle(x + 1, y); + if (y < this._map.height - 1) this.fixSingle(x, y + 1); + if (x > 0) this.fixSingle(x - 1, y); + } + + checkBorder(x, y, size) { + // Adjust to top left tile + x = x - 1; + y = y - 1; + let i; + + for (i = 0; i < size; i++) this.fixZone(x + i, y - 1); + + for (i = 0; i < size; i++) this.fixZone(x - 1, y + i); + + for (i = 0; i < size; i++) this.fixZone(x + i, y + size); + + for (i = 0; i < size; i++) this.fixZone(x + size, y + i); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BuildingTool extends BaseToolConnector { + constructor(cost, centreTile, map, size, animated) { + super(); + this.init(cost, map, false); + this.centreTile = centreTile; + this.size = size; + this.animated = animated; + } + + putBuilding(leftX, topY) { + let posX, posY, tileValue, tileFlags; + let baseTile = this.centreTile - this.size - 1; + + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + + for (let dx = 0; dx < this.size; dx++) { + posX = leftX + dx; + tileValue = baseTile; + tileFlags = Tile.BNCNBIT; + + if (dx === 1) { + if (dy === 1) tileFlags |= Tile.ZONEBIT;else if (dy === 2 && this.animated) tileFlags |= Tile.ANIMBIT; + } + + this._worldEffects.setTile(posX, posY, tileValue, tileFlags); + + baseTile++; + } + } + } + + prepareBuildingSite(leftX, topY) { + // Check that the entire site is on the map + if (leftX < 0 || leftX + this.size > this._map.width) return this.TOOLRESULT_FAILED; + if (topY < 0 || topY + this.size > this._map.height) return this.TOOLRESULT_FAILED; + let posX, posY, tileValue; // Check whether the tiles are clear + + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + + for (let dx = 0; dx < this.size; dx++) { + posX = leftX + dx; + tileValue = this._worldEffects.getTileValue(posX, posY); + if (tileValue === Tile.DIRT) continue; + + if (!this.autoBulldoze) { + // No Tile.DIRT and no bull-dozer => not buildable + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + + if (!ZoneUtils.canBulldoze(tileValue)) { + // tilevalue cannot be auto-bulldozed + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + + this._worldEffects.setTile(posX, posY, Tile.DIRT); + + this.addCost(this.bulldozerCost); + } + } + + return this.TOOLRESULT_OK; + } + + buildBuilding(x, y) { + // Correct to top left + x--; + y--; + let prepareResult = this.prepareBuildingSite(x, y); + if (prepareResult !== this.TOOLRESULT_OK) return prepareResult; + this.addCost(this.toolCost); + this.putBuilding(x, y); + this.checkBorder(x, y); + return this.TOOLRESULT_OK; + } + + doTool(x, y, blockMaps) { + this.result = this.buildBuilding(x, y); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class BulldozerTool extends BaseToolConnector { + constructor(map) { + super(); + this.init(10, map, true); + } + + putRubble(x, y, size) { + for (let xx = x; xx < x + size; xx++) { + for (let yy = y; yy < y + size; yy++) { + if (this._map.testBounds(xx, yy)) { + let tile = this._worldEffects.getTile(xx, yy); + + if (tile !== Tile.RADTILE && tile !== Tile.DIRT) { + this._worldEffects.setTile(xx, yy, Tile.TINYEXP + math.getRandom(2), Tile.ANIMBIT | Tile.BULLBIT); + } + } + } + } + } + + layDoze(x, y) { + let tile = this._worldEffects.getTile(x, y); + + if (!tile.isBulldozable()) return this.TOOLRESULT_FAILED; + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.HBRIDGE: + case Tile.VBRIDGE: + case Tile.BRWV: + case Tile.BRWH: + case Tile.HBRDG0: + case Tile.HBRDG1: + case Tile.HBRDG2: + case Tile.HBRDG3: + case Tile.VBRDG0: + case Tile.VBRDG1: + case Tile.VBRDG2: + case Tile.VBRDG3: + case Tile.HPOWER: + case Tile.VPOWER: + case Tile.HRAIL: + case Tile.VRAIL: + this._worldEffects.setTile(x, y, Tile.RIVER); + + break; + + default: + this._worldEffects.setTile(x, y, Tile.DIRT); + + break; + } + + this.addCost(1); + return this.TOOLRESULT_OK; + } + + doTool(x, y, blockMaps, messageManager) { + if (!this._map.testBounds(x, y)) this.result = this.TOOLRESULT_FAILED; + + let tile = this._worldEffects.getTile(x, y); + + let tileValue = tile.getValue(); + let zoneSize = 0; + let deltaX; + let deltaY; + + if (tile.isZone()) { + zoneSize = ZoneUtils.checkZoneSize(tileValue); + deltaX = 0; + deltaY = 0; + } else { + let result = ZoneUtils.checkBigZone(tileValue); + zoneSize = result.zoneSize; + deltaX = result.deltaX; + deltaY = result.deltaY; + } //console.log( zoneSize, deltaX, deltaY ) + + + if (zoneSize > 0) { + this.addCost(this.bulldozerCost); //this._map.powerData[ this._map.getId( x, y ) ] = 0; + + this._map.powered({ + v: 1, + x: x, + y: y + }); + let centerX = x + deltaX; + let centerY = y + deltaY; + + switch (zoneSize) { + case 3: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + this.putRubble(centerX - 1, centerY - 1, 3); + break; + + case 4: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 4); + break; + + case 6: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 6); + break; + } + + this.result = this.TOOLRESULT_OK; + } + + let toolResult; + + if (tileValue === Tile.RIVER || tileValue === Tile.REDGE || tileValue === Tile.CHANNEL) { + toolResult = this.layDoze(x, y); + if (tileValue !== this._worldEffects.getTileValue(x, y)) this.addCost(5); + } else { + toolResult = this.layDoze(x, y); + this.checkZoneConnections(x, y); + } + + this.result = toolResult; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class ParkTool extends BaseTool { + constructor(map) { + super(); + this.init(10, map, true); + } + + doTool(x, y, blockMaps) { + if (this._worldEffects.getTileValue(x, y) !== Tile.DIRT) { + this.result = this.TOOLRESULT_NEEDS_BULLDOZE; + return; + } + + let value = math.getRandom(4); + let tileFlags = Tile.BURNBIT | Tile.BULLBIT; + let tileValue; + + if (value === 4) { + tileValue = Tile.FOUNTAIN; + tileFlags |= Tile.ANIMBIT; + } else { + tileValue = value + Tile.WOODS2; + } + + this._worldEffects.setTile(x, y, tileValue, tileFlags); + + this.addCost(10); + this.result = this.TOOLRESULT_OK; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class RailTool extends BaseToolConnector { + constructor(map) { + super(); + this.init(20, map, true, true); + } + + layRail(x, y) { + this.doAutoBulldoze(x, y); + let cost = this.toolCost; + + let tile = this._worldEffects.getTileValue(x, y); + + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.DIRT: + this._worldEffects.setTile(x, y, Tile.LHRAIL | Tile.BULLBIT | Tile.BURNBIT); + + break; + + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + cost = 100; + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || tile >= Tile.LHRAIL && tile <= Tile.HRAILROAD) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + + break; + } + } + + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || tile > Tile.VRAIL && tile < Tile.VRAILROAD) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + + break; + } + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || tile > Tile.HRAIL && tile < Tile.HRAILROAD) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + + break; + } + } + + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || tile > Tile.HRAIL && tile < Tile.HRAILROAD) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + + break; + } + } + + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: + this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LVPOWER: + this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.ROADS: + this._worldEffects.setTile(x, y, Tile.VRAILROAD, Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.ROADS2: + this._worldEffects.setTile(x, y, Tile.HRAILROAD, Tile.BURNBIT | Tile.BULLBIT); + + break; + + default: + return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + } + + doTool(x, y, blockMaps) { + this.result = this.layRail(x, y); + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class RoadTool extends BaseToolConnector { + constructor(map) { + super(); + + this.doTool = function (x, y, blockMaps) { + this.result = this.layRoad(x, y); + }; + + this.init(10, map, true, true); + } + + layRoad(x, y) { + this.doAutoBulldoze(x, y); + + let tile = this._worldEffects.getTileValue(x, y); + + let cost = this.toolCost; + + switch (tile) { + case Tile.DIRT: + this._worldEffects.setTile(x, y, Tile.ROADS, Tile.BULLBIT | Tile.BURNBIT); + + break; + + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + //console.log('is water') + cost = 50; + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || tile >= Tile.ROADS && tile <= Tile.HROADPOWER) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + + break; + } + } + + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || tile >= Tile.ROADS && tile <= Tile.INTERSECTION) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + + break; + } + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + + break; + } + } + + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + + break; + } + } + + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: + this._worldEffects.setTile(x, y, Tile.VROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LVPOWER: + this._worldEffects.setTile(x, y, Tile.HROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LHRAIL: + this._worldEffects.setTile(x, y, Tile.HRAILROAD | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LVRAIL: + this._worldEffects.setTile(x, y, Tile.VRAILROAD | Tile.BURNBIT | Tile.BULLBIT); + + break; + + default: + return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class QueryTool extends BaseTool { + constructor(map) { + super(); + this.init(0, map, false, false); + this.txt = ""; + } + + classifyPopulationDensity(x, y, blockMaps) { + var density = blockMaps.populationDensityMap.worldGet(x, y); //if (debug) document.getElementById("queryDensityRaw").innerHTML=density; + + density = density >> 6; + density = density & 3; + this.txt += 'Density: ' + TXT.densityStrings[density] + '
'; //document.getElementById("queryDensity").innerHTML=TXT.densityStrings[density]; + } + + classifyLandValue(x, y, blockMaps) { + var landValue = blockMaps.landValueMap.worldGet(x, y); //if (debug) document.getElementById("queryLandValueRaw").innerHTML=landValue; + + var i = 0; + if (landValue >= 150) i = 3;else if (landValue >= 80) i = 2;else if (landValue >= 30) i = 1; //var text = TXT.landValueStrings[i]; + + this.txt += 'Value: ' + TXT.landValueStrings[i] + '
'; //document.getElementById("queryLandValue").innerHTML=text; + } + + classifyCrime(x, y, blockMaps) { + var crime = blockMaps.crimeRateMap.worldGet(x, y); //if (debug) document.getElementById("queryCrimeRaw").innerHTML=crime; + + crime = crime >> 6; + crime = crime & 3; + this.txt += 'Crime: ' + TXT.crimeStrings[crime] + '
'; //document.getElementById("queryCrime").innerHTML=TXT.crimeStrings[crime]; + } + + classifyPollution(x, y, blockMaps) { + var pollution = blockMaps.pollutionDensityMap.worldGet(x, y); //if (debug) document.getElementById("queryPollutionRaw").innerHTML=pollution; + + pollution = pollution >> 6; + pollution = pollution & 3; + this.txt += 'Pollution: ' + TXT.pollutionStrings[pollution] + '
'; //document.getElementById("queryPollution").innerHTML=TXT.pollutionStrings[pollution]; + } + + classifyRateOfGrowth(x, y, blockMaps) { + var rate = blockMaps.rateOfGrowthMap.worldGet(x, y); //if (debug) document.getElementById("queryRateRaw").innerHTML=rate; + + rate = rate >> 6; + rate = rate & 3; + this.txt += 'Growth: ' + TXT.rateStrings[rate]; //document.getElementById("queryRate").innerHTML=TXT.rateStrings[rate]; + } + + classifyDebug(x, y, blockMaps) { + /*document.getElementById("queryFireStationRaw").innerHTML=blockMaps.fireStationMap.worldGet(x, y); + document.getElementById("queryFireStationEffectRaw").innerHTML=blockMaps.fireStationEffectMap.worldGet(x, y); + document.getElementById("queryPoliceStationRaw").innerHTML=blockMaps.policeStationMap.worldGet(x, y); + document.getElementById("queryPoliceStationEffectRaw").innerHTML=blockMaps.policeStationEffectMap.worldGet(x, y); + document.getElementById("queryTerrainDensityRaw").innerHTML=blockMaps.terrainDensityMap.worldGet(x, y); + document.getElementById("queryTrafficDensityRaw").innerHTML=blockMaps.trafficDensityMap.worldGet(x, y); + document.getElementById("queryComRateRaw").innerHTML=blockMaps.comRateMap.worldGet(x, y);*/ + } + + classifyZone(x, y) { + var baseTiles = [Tile.DIRT, Tile.RIVER, Tile.TREEBASE, Tile.RUBBLE, Tile.FLOOD, Tile.RADTILE, Tile.FIRE, Tile.ROADBASE, Tile.POWERBASE, Tile.RAILBASE, Tile.RESBASE, Tile.COMBASE, Tile.INDBASE, Tile.PORTBASE, Tile.AIRPORTBASE, Tile.COALBASE, Tile.FIRESTBASE, Tile.POLICESTBASE, Tile.STADIUMBASE, Tile.NUCLEARBASE, Tile.HBRDG0, Tile.RADAR0, Tile.FOUNTAIN, Tile.INDBASE2, Tile.FOOTBALLGAME1, Tile.VBRDG0, 952]; + + var tileValue = this._map.getTileValue(x, y); + + if (tileValue >= Tile.COALSMOKE1 && tileValue < Tile.FOOTBALLGAME1) tileValue = Tile.COALBASE; + var index = 0, + l; + + for (index = 0, l = baseTiles.length - 1; index < l; index++) { + if (tileValue < baseTiles[index + 1]) break; + } + + this.txt = 'Zone: ' + TXT.zoneTypes[index] + '
'; //document.getElementById("queryZoneType").innerHTML=TXT.zoneTypes[index]; + } + + getInfo() { + return this.txt; + } + + doTool(x, y, blockMaps, messageManager) { + var text = 'Position (' + x + ', ' + y + ')'; + text += ' TileValue: ' + this._map.getTileValue(x, y); + + { + this._map.getTile(x, y); + /*document.getElementById("queryTile").innerHTML=[x,y].join(', '); + document.getElementById("queryTileValue").innerHTML=tile.getValue(); + document.getElementById("queryTileBurnable").innerHTML=tile.isCombustible(); + document.getElementById("queryTileBulldozable").innerHTML=tile.isBulldozable(); + document.getElementById("queryTileCond").innerHTML=tile.isConductive(); + document.getElementById("queryTileAnim").innerHTML=tile.isAnimated(); + document.getElementById("queryTilePowered").innerHTML=tile.isPowered();*/ + + } + + this.classifyZone(x, y); + this.classifyPopulationDensity(x, y, blockMaps); + this.classifyLandValue(x, y, blockMaps); + this.classifyCrime(x, y, blockMaps); + this.classifyPollution(x, y, blockMaps); + this.classifyRateOfGrowth(x, y, blockMaps); + this.classifyDebug(x, y, blockMaps); + messageManager.sendMessage(Messages.QUERY_WINDOW_NEEDED); + this.result = this.TOOLRESULT_OK; + } + + } + + /* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + class WireTool extends BaseToolConnector { + constructor(map) { + super(); + this.init(5, map, true, true); + } + + layWire(x, y) { + this.doAutoBulldoze(x, y); + let cost = 5; + + let tile = this._worldEffects.getTileValue(x, y); + + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.DIRT: + this._worldEffects.setTile(x, y, Tile.LHPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + cost = 25; + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + + break; + } + } + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + + break; + } + } + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + + break; + } + } + } + + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + + break; + } + } + } + + return this.TOOLRESULT_FAILED; + + case Tile.ROADS: + this._worldEffects.setTile(x, y, Tile.HROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.ROADS2: + this._worldEffects.setTile(x, y, Tile.VROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LHRAIL: + this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + case Tile.LVRAIL: + this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); + + break; + + default: + return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + } + + doTool(x, y, blockMaps) { + this.result = this.layWire(x, y); + } + + } + + const postMessage = self.webkitPostMessage || self.postMessage; + + var Game; + var isWorker = true; + var returnMessage; //var ab = new ArrayBuffer( 1 ); + //CityGame.post( ab, [ab] ); + + var trans = false; // ( ab.byteLength === 0 ); + + self.onmessage = function (e) { + CityGame.message(e); + }; + + class CityGame { + static message(e) { + var p = e.data.tell; + + if (p == "INIT") { + if (e.data.returnMessage) { + returnMessage = e.data.returnMessage; + isWorker = false; + } + + Game = new MainGame(e.data.timestep); + } + + if (p == "NEWMAP") Game.newMap(); + if (p == "PLAYMAP") Game.playMap(); + if (p == "TOOL") Game.tool(e.data.name); + if (p == "MAPCLICK") Game.mapClick(e.data.x, e.data.y, e.data.single || false); //if( p == "DESTROY" ) Game.destroy(e.data.x, e.data.y); + //if( p == "RUN" && trans) updateTrans(e.data); + + if (p == "DIFFICULTY") Game.changeDifficulty(e.data.n); + if (p == "SPEED") Game.changeSpeed(e.data.n); + if (p == "BUDGET") Game.handleBudgetRequest(); + if (p == "NEWBUDGET") Game.setBudget(e.data.budgetData); + if (p == "DISASTER") Game.setDisaster(e.data.disaster); + if (p == "EVAL") Game.getEvaluation(); + if (p == "SAVEGAME") Game.saveGame(e.data.saveCity); + if (p == "LOADGAME") Game.loadGame(e.data.isStart); + if (p == "MAKELOADGAME") Game.makeLoadGame(e.data.savegame, e.data.isStart); + } + + static post(e, buffer) { + if (isWorker) postMessage(e, buffer);else returnMessage({ + data: e + }); + } + + } + + var update = function () { + Game.tick(); + }; + + class MainGame { + constructor(timestep) { + this.timestep = timestep; + this.mapSize = [128, 128]; + this.difficulty = 1; + this.speed = 2; + this.oldSpeed = 0; + this.mapGen = new MapGenerator(); + this.simulation = null; + this.gameTools = null; + this.animationManager = null; + this.map = null; + this.isPaused = false; + this.simNeededBudget = false; + this.currentTool = null; + this.timer = null; + this.infos = []; + this.sprites = []; + this.spritesData = null; + this.animsData = null; //this.tilesData = null; + + this.spritesData = []; + this.power = null; + CityGame.post({ + tell: "READY" + }); + } + + next(delay = 0) { + this.timer = setTimeout(update, delay); + } + + stop() { + if (this.timer === null) return; + clearInterval(this.timer); + this.timer = null; + } + + tick() { + //if ( this.isPaused ) return + let up = this.simulation.simTick(); + + if (up) { + this.infos = this.simulation.infos; + this.processMessages(Game.simulation.messageManager.getMessages()); + this.animatedTiles(); + this.simulation.spriteManager.moveObjects(); + this.calculateSprites(); + CityGame.post({ + tell: "RUN", + infos: this.infos, + tilesData: this.map.tilesData, + powerData: this.map.powerData, + sprites: this.spritesData, + layer: this.map.layer + }); + this.map.resetLayer(); + } + + this.next(); + } + + newMap() { + this.map = this.mapGen.construct(this.mapSize[0], this.mapSize[1]); + CityGame.post({ + tell: "NEWMAP", + tilesData: this.map.tilesData, + mapSize: this.mapSize, + island: this.map.isIsland, + trans: trans + }); + } + + playMap(loading) { + var messageMgr = new MessageManager(); + var money = 20000; + if (this.difficulty == 1) money = 10000; + if (this.difficulty == 2) money = 5000; + this.gameTools = { + airport: new BuildingTool(10000, Tile.AIRPORT, this.map, 6, false), + bulldozer: new BulldozerTool(this.map), + coal: new BuildingTool(3000, Tile.POWERPLANT, this.map, 4, false), + commercial: new BuildingTool(100, Tile.COMCLR, this.map, 3, false), + fire: new BuildingTool(500, Tile.FIRESTATION, this.map, 3, false), + industrial: new BuildingTool(100, Tile.INDCLR, this.map, 3, false), + nuclear: new BuildingTool(5000, Tile.NUCLEAR, this.map, 4, true), + park: new ParkTool(this.map), + police: new BuildingTool(500, Tile.POLICESTATION, this.map, 3, false), + port: new BuildingTool(3000, Tile.PORT, this.map, 4, false), + rail: new RailTool(this.map), + residential: new BuildingTool(100, Tile.FREEZ, this.map, 3, false), + road: new RoadTool(this.map), + query: new QueryTool(this.map), + stadium: new BuildingTool(5000, Tile.STADIUM, this.map, 4, false), + wire: new WireTool(this.map) + }; + this.animationManager = new AnimationManager(this.map); + + if (loading) { + money = this.savedGame.totalFunds; //this.infos[3] = this.savedGame.totalPop; + + this.speed = this.savedGame.speed; + this.difficulty = this.savedGame.difficulty; + this.simulation = new Simulation(this.map, this.difficulty, this.speed, true, this.savedGame); //this.processMessages(Messages.EVAL_UPDATED); + + messageMgr.sendMessage(Messages.WELCOMEBACK); + } else { + this.simulation = new Simulation(this.map, this.difficulty, this.speed, true); + messageMgr.sendMessage(Messages.WELCOME); + } + + this.simulation.budget.setFunds(money); //messageMgr.sendMessage(Messages.FUNDS_CHANGED, money); + + this.processMessages(messageMgr.getMessages()); // update simulation time + + this.isPaused = false; //if(!trans) + //this.timer = setInterval(update, 1000/this.timestep); + //this.timer = setInterval(update, 0); + //else update(); + + this.tick(); //this.next() + } + /*changeTimeStep (n){ + clearInterval(this.timer); + this.next() + //this.timestep = n; + //this.timer = setInterval(update, 1000/this.timestep) + //this.timer = setInterval(update, 0); + }*/ + + + changeSpeed(n) { + // 0:pause 1:slow 2:medium 3:fast + this.speed = n; + this.simulation.setSpeed(this.speed); + + if (this.speed === 0) { + this.isPaused = true; + this.stop(); + } else { + if (this.isPaused) { + this.isPaused = false; + this.stop(); + this.tick(); + } + } + /*if(this.speed === 4){ + + this.simulation.setSpeed(this.speed-1); + } else { + + this.simulation.setSpeed(this.speed); + }*/ + + } + + changeDifficulty(n) { + // 0: easy 1: medium 2: hard + this.difficulty = n; + if (this.simulation) this.simulation.setDifficulty(this.difficulty); + } + + animatedTiles() { + var animTiles = this.animationManager.getTiles(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1, this.isPaused); + var i = animTiles.length; + this.animsData = new Micro.M_ARRAY_TYPE(i); + + while (i--) { + var tile = animTiles[i]; + this.animsData[i] = [tile.tileValue, tile.x, tile.y]; + } + } + + calculateSprites() { + this.sprites = this.simulation.spriteManager.getSpritesInView(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1); + var i = this.sprites.length; //this.spritesData = new M_ARRAY_TYPE(i); + + while (i--) { + var sprite = this.sprites[i]; + this.spritesData[i] = [sprite.type, sprite.frame, sprite.x || 0, sprite.y || 0]; + } + } + + processMessages(messages) { + var messageOutput = false; + + for (var i = 0, l = messages.length; i < l; i++) { + var m = messages[i]; + + switch (m.message) { + case Messages.BUDGET_NEEDED: + this.simNeededBudget = true; + this.handleBudgetRequest(); + break; + + case Messages.QUERY_WINDOW_NEEDED: + CityGame.post({ + tell: "QUERY", + queryTxt: this.currentTool.getInfo() + }); + break; + //case Messages.DATE_UPDATED: this.infos[0] = [TXT.months[ m.data.month ], m.data.year].join(' '); break; + // case Messages.EVAL_UPDATED: this.infos[1] = TXT.cityClass[m.data.classification]; this.infos[2] = m.data.score; this.infos[3] = m.data.population; break; + //case Messages.FUNDS_CHANGED: this.infos[4] = m.data; break; + //case Messages.VALVES_UPDATED: this.infos[5] = m.data.residential; this.infos[6] = m.data.commercial; this.infos[7] = m.data.industrial; break; + + default: + if (!messageOutput && TXT.goodMessages[m.message] !== undefined) { + this.infos[8] = TXT.goodMessages[m.message]; + break; + } + + if (!messageOutput && TXT.badMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.badMessages[m.message]; + break; + } + + if (!messageOutput && TXT.neutralMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.neutralMessages[m.message]; + break; + } + + } + } + } + + tool(name) { + if (this.currentTool !== null) this.currentTool.clear(); + if (name !== "none") this.currentTool = this.gameTools[name];else this.currentTool = null; + } + + destroy(x, y) { + console.log('isDestroy'); //console.log( 'destuct ', x, y ) + //this.mapClick(x,y); + //this.map.powerData[this.findId(x,y)] = 1; + // this.simulation.powerManager.setTilePower(x,y); + // var messageMgr = new Micro.MessageManager(); + // this.gameTools["bulldozer"].doTool(x, y, messageMgr, this.simulation.blockMaps ); + } + + findId(x, y) { + var id = x + y * this.mapSize[1]; + return id; + } + + mapClick(x, y, single) { + if (this.currentTool !== null) { + //console.log(this.currentTool[0]) + var budget = this.simulation.budget; + this.simulation.evaluation; + var messageMgr = new MessageManager(); + this.currentTool.doTool(x, y, this.simulation.blockMaps, messageMgr); + this.currentTool.modifyIfEnoughFunding(budget, messageMgr); + + switch (this.currentTool.result) { + case this.currentTool.TOOLRESULT_NEEDS_BULLDOZE: + TXT.toolMessages.needsDoze; + break; + + case this.currentTool.TOOLRESULT_NO_MONEY: + TXT.toolMessages.noMoney; + break; + + default: + + if (!single) CityGame.post({ + tell: "BUILD", + x: x, + y: y + }); + break; + } + + this.processMessages(messageMgr.getMessages()); + } + } + + setDisaster(disaster) { + if (disaster === Micro.DISASTER_NONE) return; + var m = new MessageManager(); + + switch (disaster) { + case Micro.DISASTER_MONSTER: + this.simulation.spriteManager.makeMonster(m); + break; + + case Micro.DISASTER_FIRE: + this.simulation.disasterManager.makeFire(m); + break; + + case Micro.DISASTER_FLOOD: + this.simulation.disasterManager.makeFlood(m); + break; + + case Micro.DISASTER_CRASH: + this.simulation.disasterManager.makeCrash(m); + break; + + case Micro.DISASTER_MELTDOWN: + this.simulation.disasterManager.makeMeltdown(m); + break; + + case Micro.DISASTER_TORNADO: + this.simulation.spriteManager.makeTornado(m); + break; + } + + this.processMessages(m.getMessages()); + } + + setBudget(budgetData) { + this.simulation.budget.cityTax = budgetData[0]; + this.simulation.budget.roadPercent = budgetData[1] / 100; + this.simulation.budget.firePercent = budgetData[2] / 100; + this.simulation.budget.policePercent = budgetData[3] / 100; + } + + handleBudgetRequest() { + this.budgetShowing = true; + let budgetData = { + roadFund: this.simulation.budget.roadFund, + roadRate: Math.floor(this.simulation.budget.roadPercent * 100), + fireFund: this.simulation.budget.fireFund, + fireRate: Math.floor(this.simulation.budget.firePercent * 100), + policeFund: this.simulation.budget.policeFund, + policeRate: Math.floor(this.simulation.budget.policePercent * 100), + taxRate: this.simulation.budget.cityTax, + totalFunds: this.simulation.budget.totalFunds, + taxesCollected: this.simulation.budget.taxFund + }; + CityGame.post({ + tell: "BUDGET", + budgetData: budgetData + }); + + if (this.simNeededBudget) { + this.simulation.budget.doBudgetWindow(); + this.simNeededBudget = false; + } else { + this.simulation.budget.updateFundEffects(); + } //this.budgetWindow.open(this.handleBudgetClosed.bind(this), budgetData); + // Let the input know we handled this request + //this.inputStatus.budgetHandled(); + + } + + getEvaluation() { + let evaluation = this.simulation.evaluation; + let problemes = ""; + + for (var i = 0; i < 4; i++) { + let problemNo = evaluation.getProblemNumber(i); + let text = ''; + if (problemNo !== -1) text = TXT.problems[problemNo]; + problemes += text + "
"; + } + + let evalData = [evaluation.cityYes, problemes]; + CityGame.post({ + tell: "EVAL", + evalData: evalData + }); + } //______________________________________ SAVE + + + saveGame(cityData) { + //this.oldSpeed = this.speed; + //this.changeSpeed(0); + let gameData = { + name: "Yoooooo", + everClicked: true + }; + gameData.speed = this.speed; + gameData.difficulty = this.difficulty; + gameData.version = Micro.CURRENT_VERSION; + gameData.city = cityData; + this.simulation.save(gameData); + gameData = JSON.stringify(gameData); + CityGame.post({ + tell: "SAVEGAME", + gameData: gameData, + key: Micro.KEY + }); //this.changeSpeed(this.oldSpeed); + } + /*makeSaveGame : function(gameData){ + gameData.version = Micro.CURRENT_VERSION; + gameData = JSON.stringify(gameData); + }*/ + //______________________________________ LOAD + + + loadGame(atStart) { + var isStart = atStart || false; + CityGame.post({ + tell: "LOADGAME", + key: Micro.KEY, + isStart: isStart + }); + } + + makeLoadGame(gameData, atStart) { + let isStart = atStart || false; + clearInterval(this.timer); + this.savedGame = JSON.parse(gameData); //this.simulation.load(this.savedGame); + //this.map = this.simulation.map; + // this.everClicked = savedGame.everClicked; + //if (savedGame.version !== Micro.CURRENT_VERSION) this.transitionOldSave(savedGame); + //savedGame.isSavedGame = true; + + /*if(this.map){ + this.map.load(this.savedGame); + }else{*/ + + this.map = new GameMap(Micro.MAP_WIDTH, Micro.MAP_HEIGHT); + this.map.load(this.savedGame); //} + // + //this.playMap(true); + //this.simulation.map = this.map;//return + // + //this.map = this.simulation.map; + + CityGame.post({ + tell: "FULLREBUILD", + tilesData: this.map.tilesData, + mapSize: this.mapSize, + island: this.map.isIsland, + cityData: this.savedGame.city, + isStart: isStart + }); + } + + transitionOldSave(savedGame) { + switch (savedGame.version) { + case 1: + savedGame.everClicked = false; + + /* falls through */ + + case 2: + savedGame.pollutionMaxX = Math.floor(savedGame.width / 2); + savedGame.pollutionMaxY = Math.floor(savedGame.height / 2); + savedGame.cityCentreX = Math.floor(savedGame.width / 2); + savedGame.cityCentreY = Math.floor(savedGame.height / 2); + break; + //default: throw new Error('Unknown save version!'); + } + } + + } + + exports.CityGame = CityGame; + exports.MainGame = MainGame; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/games/3dcity/build/citygame.min.js b/games/3dcity/build/citygame.min.js new file mode 100644 index 0000000..3c97f90 --- /dev/null +++ b/games/3dcity/build/citygame.min.js @@ -0,0 +1,6 @@ +/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).city={})}(this,(function(t){"use strict";const e={haveMapAnimation:!0,localStorage:null,GameMapProps:["cityCentreX","cityCentreY","pollutionMaxX","pollutionMaxY","width","height"],savePropsVar:["cityTime"],CensusProps:["resPop","comPop","indPop","crimeRamp","pollutionRamp","landValueAverage","pollutionAverage","crimeAverage","totalPop","resHist10","resHist120","comHist10","comHist120","indHist10","indHist120","crimeHist10","crimeHist120","moneyHist10","moneyHist120","pollutionHist10","pollutionHist120"],BudgetProps:["autoBudget","totalFunds","policePercent","roadPercent","firePercent","roadSpend","policeSpend","fireSpend","roadMaintenanceBudget","policeMaintenanceBudget","fireMaintenanceBudget","cityTax","roadEffect","policeEffect","fireEffect"],PROBLEMS:["CVP_CRIME","CVP_POLLUTION","CVP_HOUSING","CVP_TAXES","CVP_TRAFFIC","CVP_UNEMPLOYMENT","CVP_FIRE"],NUMPROBLEMS:7,NUM_COMPLAINTS:4,problemData:[],EvalProps:["cityClass","cityScore"],speedPowerScan:[2,4,5,6],speedPollutionTerrainLandValueScan:[2,7,17,30],speedCrimeScan:[1,8,18,32],speedPopulationDensityScan:[1,9,19,38],speedFireAnalysis:[1,10,20,40],CENSUS_FREQUENCY_10:4,CENSUS_FREQUENCY_120:40,TAX_FREQUENCY:48,MAP_WIDTH:128,MAP_HEIGHT:128,MAP_DEFAULT_WIDTH:384,MAP_DEFAULT_HEIGHT:384,MAP_BIG_DEFAULT_WIDTH:2048,MAP_BIG_DEFAULT_HEIGHT:2048,MAP_BIG_DEFAULT_ID:"bigMap",MAP_PARENT_ID:"splashContainer",MAP_DEFAULT_ID:"SplashCanvas",DEFAULT_WIDTH:400,DEFAULT_HEIGHT:400,DEFAULT_ID:"MicropolisCanvas",RCI_DEFAULT_ID:"RCICanvas",LEVEL_EASY:0,LEVEL_MED:1,LEVEL_HARD:2,SPEED_PAUSED:0,SPEED_SLOW:1,SPEED_MED:2,SPEED_FAST:3,SPEED_ULTRA:4,ROUTE_FOUND:1,NO_ROUTE_FOUND:0,NO_ROAD_FOUND:-1,MAX_TRAFFIC_DISTANCE:30,perimX:[-1,0,1,2,2,2,1,0,-1,-2,-2,-2],perimY:[-2,-2,-2,-1,0,1,2,2,2,1,0,-1],SPRITE_TRAIN:1,SPRITE_HELICOPTER:2,SPRITE_AIRPLANE:3,SPRITE_SHIP:4,SPRITE_MONSTER:5,SPRITE_TORNADO:6,SPRITE_EXPLOSION:7,CC_VILLAGE:"VILLAGE",CC_TOWN:"TOWN",CC_CITY:"CITY",CC_CAPITAL:"CAPITAL",CC_METROPOLIS:"METROPOLIS",CC_MEGALOPOLIS:"MEGALOPOLIS",CRIME:0,POLLUTION:1,HOUSING:2,TAXES:3,TRAFFIC:4,UNEMPLOYMENT:5,FIRE:6,RES_VALVE_RANGE:2e3,COM_VALVE_RANGE:1500,IND_VALVE_RANGE:1500,taxTable:[200,150,120,100,80,50,30,0,-10,-40,-100,-150,-200,-250,-300,-350,-400,-450,-500,-550,-600],extMarketParamTable:[1.2,1.1,.98],RLevels:[.7,.9,1.2],FLevels:[1.4,1.2,.8],MAX_ROAD_EFFECT:32,MAX_POLICESTATION_EFFECT:1e3,MAX_FIRESTATION_EFFECT:1e3,policeMaintenanceCost:100,fireMaintenanceCost:100,roadMaintenanceCost:1,railMaintenanceCost:2,COAL_POWER_STRENGTH:700,NUCLEAR_POWER_STRENGTH:2e3,DISASTER_NONE:"None",DISASTER_MONSTER:"Monster",DISASTER_FIRE:"Fire",DISASTER_FLOOD:"Flood",DISASTER_CRASH:"Crash",DISASTER_MELTDOWN:"Meltdown",DISASTER_TORNADO:"Tornado",CURRENT_VERSION:3,KEY:"micropolisJSGame",DisChance:[479,239,59],TERRAIN_CREATE_ISLAND:0,TERRAIN_TREE_LEVEL:-1,TERRAIN_LAKE_LEVEL:-1,TERRAIN_CURVE_LEVEL:-1,ISLAND_RADIUS:18,M_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,arrs:["res","com","ind","crime","money","pollution"],directionTable:[0,3,2,1,3,4,5,7,6,5,7,8,1],SMOOTH_NEIGHBOURS_THEN_BLOCK:0,SMOOTH_ALL_THEN_CLAMP:1,simData:null,messageManager:null};class i{static emitEvent(t,i){e.messageManager.sendMessage(t,i)}}class s{static mcd(t){return{configurable:!1,enumerable:!1,writeable:!1,value:t}}static rotate10Arrays(){for(var t=0;ti?i:t}static getChance(t){return 0==(a.getRandom16()&t)}static getERandom(t){var e=a.getRandom(t),i=a.getRandom(t);return Math.min(e,i)}static getRandom(t){return Math.floor(Math.random()*(t+1))}static getRandom16(){return a.getRandom(65535)}static getRandom16Signed(){var t=a.getRandom16();return t<32768?t:-65536+t}}class o{static pixToWorld(t){return t>>4}static worldToPix(t){return t<<4}static unwrapTile(t){return t.isTile?t.getValue():t}static canBulldoze(t){return(t=o.unwrapTile(t))>=n.FIRSTRIVEDGE&&t<=n.LASTRUBBLE||t>=n.POWERBASE+2&&t<=n.POWERBASE+12||t>=n.TINYEXP&&t<=n.LASTTINYEXP+2}static isCommercial(t){return(t=o.unwrapTile(t))>=n.COMBASE&&t=n.INDBASE&&t=n.RESBASE&&t=n.ROADBASE&&t<=n.LASTRAIL||t===n.RAILHPOWERV||t===n.RAILVPOWERH}static isFire(t){return(t=o.unwrapTile(t))>=n.FIREBASE&&t=n.FLOOD&&t=n.TINYEXP&&t<=n.LASTTINYEXP}static isRail(t){return(t=o.unwrapTile(t))>=n.RAILBASE&&t=n.ROADBASE&&t=n.ROADBASE&&t<=n.LASTROAD+1?64+(15&t):t}static isCommercialZone(t){return t.isZone()&&o.isCommercial(t)}static isIndustrialZone(t){return t.isZone()&&o.isIndustrial(t)}static isResidentialZone(t){return t.isZone()&&o.isResidential(t)}static randomFire(t){return new r(n.FIRE+(3&a.getRandom16()),n.ANIMBIT)}static randomRubble(t){return new r(n.RUBBLE+(3&a.getRandom16()),n.BULLBIT)}static HOSPITAL(t){}static checkZoneSize(t){return t>=n.RESBASE-1&&t<=n.PORTBASE-1||t>=n.LASTPOWERPLANT+1&&t<=n.POLICESTATION+4||t>=n.CHURCH1BASE&&t<=n.CHURCH7LAST?3:t>=n.PORTBASE&&t<=n.LASTPORT||t>=n.COALBASE&&t<=n.LASTPOWERPLANT||t>=n.STADIUMBASE&&t<=n.LASTZONE?4:0}static fireZone(t,e,i,s){let o,r,h,l,d=t.getTileValue(e,i),E=2,c=s.rateOfGrowthMap.worldGet(e,i);for(c=a.clamp(c-20,-200,200),s.rateOfGrowthMap.worldSet(e,i,c),d===n.AIRPORT?E=5:d>=n.PORTBASE?E=3:d=n.ROADBASE)&&t.addTileFlags(h,l,n.BULLBIT)}static getLandPollutionValue(t,e,i){let s=t.landValueMap.worldGet(e,i);return s-=t.pollutionDensityMap.worldGet(e,i),s<30?0:s<80?1:s<150?2:3}static incRateOfGrowth(t,e,i,s){let o=t.rateOfGrowthMap.worldGet(e,i),r=a.clamp(o+4*s,-200,200);t.rateOfGrowthMap.worldSet(e,i,r)}static putZone(t,e,i,s,a){let o,r,h;for(o=-1;o<2;o++)for(r=-1;r<2;r++)if(h=t.getTileValue(e+r,i+o),h>=n.FLOOD&&h1&&(this._value|=e)}getValue(){return this._value&n.BIT_MASK}setValue(t){if(0===arguments.length||"number"!=typeof t||t<0)throw new Error("Invalid parameter");let e=0;t0}isAnimated(){return(this._value&n.ANIMBIT)>0}isConductive(){return(this._value&n.CONDBIT)>0}isCombustible(){return(this._value&n.BURNBIT)>0}isPowered(){return(this._value&n.POWERBIT)>0}isZone(){return(this._value&n.ZONEBIT)>0}addFlags(t){if(!arguments.length||"number"!=typeof t||t=n.BIT_END<<1)throw new Error("Invalid parameter");this._value|=t}removeFlags(t){if(!arguments.length||"number"!=typeof t||t=n.BIT_END<<1)throw new Error("Invalid parameter");this._value&=~t}setFlags(t){let e=this._value&~n.ALLBITS;this._value=e|t}getFlags(){return this._value&n.ALLBITS}getRawValue(){return this._value}set(t,e){if(arguments.length<2||"number"!=typeof t||"number"!=typeof e||t>=n.TILE_COUNT)throw new Error("Invalid parameter");this.setValue(t),this.setFlags(e)}toString(){let t="Tile# "+this.getValue();return t+=this.isCombustible()?" burning":"",t+=this.isPowered()?" powered":"",t+=this.isAnimated()?" animated":"",t+=this.isConductive()?" conductive":"",t+=this.isZone()?" zone":"",t+=this.isBulldozable()?" bulldozeable":"",t}}const n={POWERBIT:32768,CONDBIT:16384,BURNBIT:8192,BULLBIT:4096,ANIMBIT:2048,ZONEBIT:1024,BLBNBIT:12288,BLBNCNBIT:28672,BNCNBIT:24576,ASCBIT:26624,ALLBITS:64512,BIT_START:1024,BIT_END:32768,BIT_MASK:1023,DIRT:0,RIVER:2,REDGE:3,CHANNEL:4,FIRSTRIVEDGE:5,LASTRIVEDGE:20,WATER_LOW:2,WATER_HIGH:20,TREEBASE:21,WOODS_LOW:21,LASTTREE:36,WOODS:37,UNUSED_TRASH1:38,UNUSED_TRASH2:39,WOODS_HIGH:39,WOODS2:40,WOODS3:41,WOODS4:42,WOODS5:43,RUBBLE:44,LASTRUBBLE:47,FLOOD:48,LASTFLOOD:51,RADTILE:52,UNUSED_TRASH3:53,UNUSED_TRASH4:54,UNUSED_TRASH5:55,FIRE:48,FIREBASE:48,LASTFIRE:55,HBRIDGE:64,ROADBASE:64,VBRIDGE:65,ROADS:66,ROADS2:67,ROADS3:68,ROADS4:69,ROADS5:70,ROADS6:71,ROADS7:72,ROADS8:73,ROADS9:74,ROADS10:75,INTERSECTION:76,HROADPOWER:77,VROADPOWER:78,BRWH:79,LTRFBASE:80,BRWV:95,BRWXXX1:111,BRWXXX2:127,BRWXXX3:143,HTRFBASE:144,BRWXXX4:159,BRWXXX5:175,BRWXXX6:191,LASTROAD:206,BRWXXX7:207,HPOWER:208,VPOWER:209,LHPOWER:210,LVPOWER:211,LVPOWER2:212,LVPOWER3:213,LVPOWER4:214,LVPOWER5:215,LVPOWER6:216,LVPOWER7:217,LVPOWER8:218,LVPOWER9:219,LVPOWER10:220,RAILHPOWERV:221,RAILVPOWERH:222,POWERBASE:208,LASTPOWER:222,UNUSED_TRASH6:223,HRAIL:224,VRAIL:225,LHRAIL:226,LVRAIL:227,LVRAIL2:228,LVRAIL3:229,LVRAIL4:230,LVRAIL5:231,LVRAIL6:232,LVRAIL7:233,LVRAIL8:234,LVRAIL9:235,LVRAIL10:236,HRAILROAD:237,VRAILROAD:238,RAILBASE:224,LASTRAIL:238,ROADVPOWERH:239,RESBASE:240,FREEZ:244,HOUSE:249,LHTHR:249,HHTHR:260,RZB:265,HOSPITALBASE:405,HOSPITAL:409,CHURCHBASE:414,CHURCH0BASE:414,CHURCH:418,CHURCH0:418,COMBASE:423,COMCLR:427,CZB:436,COMLAST:609,INDBASE:612,INDCLR:616,LASTIND:620,IND1:621,IZB:625,IND2:641,IND3:644,IND4:649,IND5:650,IND6:676,IND7:677,IND8:686,IND9:689,PORTBASE:693,PORT:698,LASTPORT:708,AIRPORTBASE:709,RADAR:711,AIRPORT:716,COALBASE:745,POWERPLANT:750,LASTPOWERPLANT:760,FIRESTBASE:761,FIRESTATION:765,POLICESTBASE:770,POLICESTATION:774,STADIUMBASE:779,STADIUM:784,FULLSTADIUM:800,NUCLEARBASE:811,NUCLEAR:816,LASTZONE:826,LIGHTNINGBOLT:827,HBRDG0:828,HBRDG1:829,HBRDG2:830,HBRDG3:831,RADAR0:832,RADAR1:833,RADAR2:834,RADAR3:835,RADAR4:836,RADAR5:837,RADAR6:838,RADAR7:839,FOUNTAIN:840,INDBASE2:844,TELEBASE:844,TELELAST:851,SMOKEBASE:852,TINYEXP:860,SOMETINYEXP:864,LASTTINYEXP:867,TINYEXPLAST:883,COALSMOKE1:916,COALSMOKE2:920,COALSMOKE3:924,COALSMOKE4:928,FOOTBALLGAME1:932,FOOTBALLGAME2:940,VBRDG0:948,VBRDG1:949,VBRDG2:950,VBRDG3:951,NUKESWIRL1:952,NUKESWIRL2:953,NUKESWIRL3:954,NUKESWIRL4:955,CHURCH1BASE:956,CHURCH1:960,CHURCH2BASE:965,CHURCH2:969,CHURCH3BASE:974,CHURCH3:978,CHURCH4BASE:983,CHURCH4:987,CHURCH5BASE:992,CHURCH5:996,CHURCH6BASE:1001,CHURCH6:1005,CHURCH7BASE:1010,CHURCH7:1014,CHURCH7LAST:1018,TILE_COUNT:1024,TILE_INVALID:-1,MIN_SIZE:16},h=[n.ROADS,n.ROADS2,n.ROADS,n.ROADS3,n.ROADS2,n.ROADS2,n.ROADS4,n.ROADS8,n.ROADS,n.ROADS6,n.ROADS,n.ROADS7,n.ROADS5,n.ROADS10,n.ROADS9,n.INTERSECTION],l=[n.LHRAIL,n.LVRAIL,n.LHRAIL,n.LVRAIL2,n.LVRAIL,n.LVRAIL,n.LVRAIL3,n.LVRAIL7,n.LHRAIL,n.LVRAIL5,n.LHRAIL,n.LVRAIL6,n.LVRAIL4,n.LVRAIL9,n.LVRAIL8,n.LVRAIL10],d=[n.LHPOWER,n.LVPOWER,n.LHPOWER,n.LVPOWER2,n.LVPOWER,n.LVPOWER,n.LVPOWER3,n.LVPOWER7,n.LHPOWER,n.LVPOWER5,n.LHPOWER,n.LVPOWER6,n.LVPOWER4,n.LVPOWER9,n.LVPOWER8,n.LVPOWER10];class E{constructor(){this.data=[]}sendMessage(t,e){this.data.push({message:t,data:e})}clear(){this.data=[]}getMessages(){return this.data.slice()}}var c={AUTOBUDGET_CHANGED:s.mcd("Autobudget changed"),BUDGET_NEEDED:s.mcd("User needs to budget"),BUDGET_REQUESTED:s.mcd("Budget window requested"),BUDGET_WINDOW_CLOSED:s.mcd("Budget window closed"),BLACKOUTS_REPORTED:s.mcd("Blackouts reported"),CLASSIFICATION_UPDATED:s.mcd("Classification updated"),CONGRATS_SHOWING:s.mcd("Congratulations showing"),CONGRATS_WINDOW_CLOSED:s.mcd("Congratulations window closed"),DATE_UPDATED:s.mcd("Date changed"),DEBUG_WINDOW_REQUESTED:s.mcd("Debug Window Requested"),DEBUG_WINDOW_CLOSED:s.mcd("Debug Window Closed"),DISASTER_REQUESTED:s.mcd("Disaster Requested"),DISASTER_WINDOW_CLOSED:s.mcd("Disaster window closed"),EARTHQUAKE:s.mcd("Earthquake"),EVAL_REQUESTED:s.mcd("Evaluation Requested"),EVAL_UPDATED:s.mcd("Evaluation Updated"),EVAL_WINDOW_CLOSED:s.mcd("Eval window closed"),EXPLOSION_REPORTED:s.mcd("Explosion Reported"),FIRE_REPORTED:s.mcd("Fire!"),FIRE_STATION_NEEDS_FUNDING:s.mcd("Fire station needs funding"),FLOODING_REPORTED:s.mcd("Flooding reported"),FRONT_END_MESSAGE:s.mcd("Front-end Message"),FUNDS_CHANGED:s.mcd("Total funds has changed"),HEAVY_TRAFFIC:s.mcd("Heavy traffic in city"),HELICOPTER_CRASHED:s.mcd("Helicopter crashed"),HIGH_CRIME:s.mcd("High crime"),HIGH_POLLUTION:s.mcd("High pollution"),MONSTER_SIGHTED:s.mcd("Monster sighted"),NAG_WINDOW_CLOSED:s.mcd("Nag window closed"),NEED_AIRPORT:s.mcd("Airport needed"),NEED_ELECTRICITY:s.mcd("More power needed"),NEED_FIRE_STATION:s.mcd("Fire station needed"),NEED_MORE_COMMERCIAL:s.mcd("More commercial zones needed"),NEED_MORE_INDUSTRIAL:s.mcd("More industrial zones needed"),NEED_MORE_RAILS:s.mcd("More railways needed"),NEED_MORE_RESIDENTIAL:s.mcd("More residential needed"),NEED_MORE_ROADS:s.mcd("More roads needed"),NEED_POLICE_STATION:s.mcd("Police station needed"),NEED_SEAPORT:s.mcd("Seaport needed"),NEED_STADIUM:s.mcd("Stadium needed"),NO_MONEY:s.mcd("No money"),NOT_ENOUGH_POWER:s.mcd("Not enough power"),NUCLEAR_MELTDOWN:s.mcd("Nuclear Meltdown"),PLANE_CRASHED:s.mcd("Plane crashed"),POLICE_NEEDS_FUNDING:s.mcd("Police need funding"),POPULATION_UPDATED:s.mcd("Population updated"),QUERY_WINDOW_CLOSED:s.mcd("Query window closed"),QUERY_WINDOW_NEEDED:s.mcd("Query window needed"),REACHED_CAPITAL:s.mcd("Now a capital"),REACHED_CITY:s.mcd("Now a city"),REACHED_METROPOLIS:s.mcd("Now a metropolis"),REACHED_MEGALOPOLIS:s.mcd("Now a megalopolis"),REACHED_TOWN:s.mcd("Now a town"),REACHED_VILLAGE:s.mcd("Now a village"),ROAD_NEEDS_FUNDING:s.mcd("Roads need funding"),SAVE_REQUESTED:s.mcd("Save requested"),SAVE_WINDOW_CLOSED:s.mcd("Save window closed"),SCORE_UPDATED:s.mcd("Score updated"),SCREENSHOT_LINK_CLOSED:s.mcd("Screenshot link closed"),SCREENSHOT_WINDOW_CLOSED:s.mcd("Screenshot window closed"),SCREENSHOT_WINDOW_REQUESTED:s.mcd("Screenshot window requested"),SETTINGS_WINDOW_CLOSED:s.mcd("Settings window closed"),SETTINGS_WINDOW_REQUESTED:s.mcd("Settings window requested"),SHIP_CRASHED:s.mcd("Shipwrecked"),SOUND_EXPLOSIONHIGH:s.mcd("Explosion! Bang!"),SOUND_EXPLOSIONLOW:s.mcd("Explosion! Bang!"),SOUND_HEAVY_TRAFFIC:s.mcd("Heavy Traffic sound"),SOUND_HONKHONK:s.mcd("HonkHonk sound"),SOUND_MONSTER:s.mcd("Monster sound"),SPEED_CHANGE:s.mcd("Speed change"),SPRITE_DYING:s.mcd("Sprite dying"),SPRITE_MOVED:s.mcd("Sprite move"),TAX_TOO_HIGH:s.mcd("Tax too high"),TOOL_CLICKED:s.mcd("Tool clicked"),TORNADO_SIGHTED:s.mcd("Tornado sighted"),TOUCH_WINDOW_CLOSED:s.mcd("Touch Window closed"),TRAFFIC_JAMS:s.mcd("Traffic jams reported"),TRAIN_CRASHED:s.mcd("Train crashed"),VALVES_UPDATED:s.mcd("Valves updated"),WELCOME:s.mcd("Welcome to micropolisJS"),WELCOMEBACK:s.mcd("Welcome back to your 3D city")};const R=Object.defineProperties({},c);var u=[R.EARTHQUAKE,R.EXPLOSION_REPORTED,R.FIRE_REPORTED,R.FLOODING_REPORTED,R.MONSTER_SIGHTED,R.NUCLEAR_MELTDOWN,R.TORNADO_SIGHTED];Object.defineProperty(R,"disasterMessages",s.mcd(u));var T=[R.HELICOPTER_CRASHED,R.PLANE_CRASHED,R.SHIP_CRASHED,R.TRAIN_CRASHED];Object.defineProperty(R,"crashes",s.mcd(T));const p=new function(){var t={};t[""+e.LEVEL_EASY]="Easy",t[""+e.LEVEL_MED]="Medium",t[""+e.LEVEL_HARD]="Hard";var i={};i[e.CC_VILLAGE]="VILLAGE",i[e.CC_TOWN]="TOWN",i[e.CC_CITY]="CITY",i[e.CC_CAPITAL]="CAPITAL",i[e.CC_METROPOLIS]="METROPOLIS",i[e.CC_MEGALOPOLIS]="MEGALOPOLIS";var s={};s[e.CRIME]="Crime",s[e.POLLUTION]="Pollution",s[e.HOUSING]="Housing",s[e.TAXES]="Taxes",s[e.TRAFFIC]="Traffic",s[e.UNEMPLOYMENT]="Unemployment",s[e.FIRE]="Fire";var a={};a[R.FIRE_STATION_NEEDS_FUNDING]="Fire departments need funding",a[R.NEED_AIRPORT]="Commerce requires an Airport",a[R.NEED_FIRE_STATION]="Citizens demand a Fire Department",a[R.NEED_ELECTRICITY]="Build a Power Plant",a[R.NEED_MORE_INDUSTRIAL]="More industrial zones needed",a[R.NEED_MORE_COMMERCIAL]="More commercial zones needed",a[R.NEED_MORE_RESIDENTIAL]="More residential zones needed",a[R.NEED_MORE_RAILS]="Inadequate rail system",a[R.NEED_MORE_ROADS]="More roads required",a[R.NEED_POLICE_STATION]="Citizens demand a Police Department",a[R.NEED_SEAPORT]="Industry requires a Sea Port",a[R.NEED_STADIUM]="Residents demand a Stadium",a[R.ROAD_NEEDS_FUNDING]="Roads deteriorating, due to lack of funds",a[R.POLICE_NEEDS_FUNDING]="Police departments need funding",a[R.WELCOME]="Welcome to 3D City",a[R.WELCOMEBACK]="Welcome to 3D City";var o={};o[R.BLACKOUTS_REPORTED]="Brownouts, build another Power Plant",o[R.COPTER_CRASHED]="A helicopter crashed ",o[R.EARTHQUAKE]="Major earthquake reported !!",o[R.EXPLOSION_REPORTED]="Explosion detected ",o[R.FLOODING_REPORTED]="Flooding reported !",o[R.FIRE_REPORTED]="Fire reported ",o[R.HEAVY_TRAFFIC]="Heavy Traffic reported",o[R.HIGH_CRIME]="Crime very high",o[R.HIGH_POLLUTION]="Pollution very high",o[R.MONSTER_SIGHTED]="A Monster has been sighted !",o[R.NO_MONEY]="YOUR CITY HAS GONE BROKE",o[R.NOT_ENOUGH_POWER]="Blackouts reported. insufficient power capacity",o[R.NUCLEAR_MELTDOWN]="A Nuclear Meltdown has occurred !!",o[R.PLANE_CRASHED]="A plane has crashed ",o[R.SHIP_CRASHED]="Shipwreck reported ",o[R.TAX_TOO_HIGH]="Citizens upset. The tax rate is too high",o[R.TORNADO_SIGHTED]="Tornado reported !",o[R.TRAFFIC_JAMS]="Frequent traffic jams reported",o[R.TRAIN_CRASHED]="A train crashed ";var r={};return r[R.REACHED_CAPITAL]="Population has reached 50,000",r[R.REACHED_CITY]="Population has reached 10,000",r[R.REACHED_MEGALOPOLIS]="Population has reached 500,000",r[R.REACHED_METROPOLIS]="Population has reached 100,000",r[R.REACHED_TOWN]="Population has reached 2,000",{badMessages:o,cityClass:i,crimeStrings:["Safe","Light","Moderate","Dangerous"],densityStrings:["Low","Medium","High","Very High"],gameLevel:t,goodMessages:r,landValueStrings:["Slum","Lower Class","Middle Class","High"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],neutralMessages:a,problems:s,pollutionStrings:["None","Moderate","Heavy","Very Heavy"],rateStrings:["Declining","Stable","Slow Growth","Fast Growth"],toolMessages:{noMoney:"Insufficient funds to build that",needsDoze:"Area must be bulldozed first"},zoneTypes:["Clear","Water","Trees","Rubble","Flood","Radioactive Waste","Fire","Road","Power","Rail","Residential","Commercial","Industrial","Seaport","Airport","Coal Power","Fire Department","Police Department","Stadium","Nuclear Power","Draw Bridge","Radar Dish","Fountain","Industrial","Steelers 38\tBears 3","Draw Bridge","Ur 238"]}};class m{static pixToWorld(t){return o.pixToWorld(t)}static worldToPix(t){return o.worldToPix(t)}static turnTo(t,e){return t===e||(t8&&(t=1),t<1&&(t=8)),t}static absoluteValue(t){return Math.abs(t)}static getTileValue(t,e,i){let s=o.pixToWorld(e),a=o.pixToWorld(i);return s<0||s>=t.width||a<0||a>=t.height?-1:t.getTileValue(s,a)}static getDir(t,i,s,a){let o,r=s-t,n=a-i;return o=r<0?n<0?11:8:n<0?2:5,r=Math.abs(r),n=Math.abs(n),2*r12)&&(o=0),e.directionTable[o]}static absoluteDistance(t,e,i,s){let a=i-t,o=s-e;return Math.abs(a)+Math.abs(o)}static checkWet(t){return t===n.HPOWER||t===n.VPOWER||t===n.HRAIL||t===n.VRAIL||t===n.BRWH||t===n.BRWV}static destroyMapTile(t,e,i,s,a){let r=o.pixToWorld(s),h=o.pixToWorld(a);if(!e.testBounds(r,h))return;let l=e.getTile(r,h),d=l.getValue();dn.RZB&&t.makeExplosionAt(s,a)),m.checkWet(d)?e.setTile(r,h,n.RIVER,0):e.setTile(r,h,n.TINYEXP,n.BULLBIT|n.ANIMBIT)):d>=n.ROADBASE&&d<=n.LASTROAD&&e.setTile(r,h,n.RIVER,0))}static getDistance(t,e,i,s){return Math.abs(t-i)+Math.abs(e-s)}static checkSpriteCollision(t,e){return 0!==t.frame&&0!==e.frame&&m.getDistance(t.x,t.y,e.x,e.y)<30}}class A{constructor(){}init(t,e,i,s,a){this.type=t,this.map=e,this.spriteManager=i,this.x=s,this.y=a,this.origX=0,this.origY=0,this.destX=0,this.destY=0,this.count=0,this.soundCount=0,this.dir=0,this.newDir=0,this.step=0,this.flag=0,this.turn=0,this.accel=0,this.speed=100}getFileName(){return["obj",this.type,"-",this.frame-1].join("")}spriteNotInBounds(){let t=m.pixToWorld(this.x),e=m.pixToWorld(this.y);return t<0||e<0||t>=this.map.width||e>=this.map.height}}const g={};g[e.SPRITE_TRAIN]=class extends A{constructor(t,i,s,a){super(),this.init(e.SPRITE_TRAIN,t,i,s,a),this.width=32,this.height=32,this.xOffset=-16,this.yOffset=-16,this.frame=1,this.dir=4,this.tileDeltaX=[0,16,0,-16],this.tileDeltaY=[-16,0,16,0],this.xDelta=[0,4,0,-4,0],this.yDelta=[-4,0,4,0,0],this.TrainPic2=[1,2,1,2,5],this.NORTHSOUTH=1,this.EASTWEST=2,this.NWSE=3,this.NESW=4,this.UNDERWATER=5,this.NORTH=0,this.EAST=1,this.SOUTH=2,this.WEST=3,this.CANTMOVE=4}move(t,e,i,s){if(this.frame!==this.NWSE&&this.frame!==this.NESW||(this.frame=this.TrainPic2[this.dir]),this.x+=this.xDelta[this.dir],this.y+=this.yDelta[this.dir],0==(3&t)){let t=3&a.getRandom16();for(let e=t;e=n.RAILBASE&&i<=n.LASTRAIL||i===n.RAILVPOWERH||i===n.RAILHPOWERV)return this.dir!==t&&this.dir!==this.CANTMOVE?this.dir+t===this.WEST?this.frame=this.NWSE:this.frame=this.NESW:this.frame=this.TrainPic2[t],i!==n.HRAIL&&i!==n.VRAIL||(this.frame=this.UNDERWATER),void(this.dir=t)}if(this.dir===this.CANTMOVE)return void(this.frame=0);this.dir=this.CANTMOVE}}explodeSprite(t){this.frame=0,this.spriteManager.makeExplosionAt(this.x,this.y),t.sendMessage(R.TRAIN_CRASHED)}},g[e.SPRITE_SHIP]=class extends A{constructor(t,i,s,a){super(),this.init(e.SPRITE_SHIP,t,i,s,a),this.width=48,this.height=48,this.xOffset=-24,this.yOffset=-24,s=m.worldToPix(t.width-4)?this.frame=7:a=m.worldToPix(t.height-4)?this.frame=1:this.frame=3,this.newDir=this.frame,this.dir=10,this.count=1,this.tileDeltaX=[0,0,1,1,1,0,-1,-1,-1],this.tileDeltaY=[0,-1,-1,0,1,1,1,0,-1],this.xDelta=[0,0,2,2,2,0,-2,-2,-2],this.yDelta=[0,-2,-2,0,2,2,2,0,-2],this.tileWhiteList=[n.RIVER,n.CHANNEL,n.POWERBASE,n.POWERBASE+1,n.RAILBASE,n.RAILBASE+1,n.BRWH,n.BRWV],this.CANTMOVE=10}move(t,e,i,s){let o,r,h,l,d,E,c=n.RIVER;if(this.soundCount>0&&this.soundCount--,0===this.soundCount&&(1==(3&a.getRandom16())&&e.sendMessage(R.SOUND_HONKHONK),this.soundCount=200),this.count>0&&this.count--,0===this.count){if(this.count=9,this.frame!==this.newDir)return void(this.frame=m.turnTo(this.frame,this.newDir));for(o=7&a.getRandom16(),r=this.frame,h=o;h8&&(this.dir-=8);break}h===o+8&&(this.dir=this.CANTMOVE,this.newDir=1+(7&a.getRandom16()))}else r=this.frame,r===this.newDir&&(this.x+=this.xDelta[r],this.y+=this.yDelta[r]);if(this.spriteNotInBounds())this.frame=0;else for(let t=0;t<8&&c!==this.tileWhiteList[t];t++)7===t&&(this.explodeSprite(e),m.destroyMapTile(this.spriteManager,this.map,s,this.x,this.y))}explodeSprite(t){this.frame=0,this.spriteManager.makeExplosionAt(this.x,this.y),t.sendMessage(R.SHIP_CRASHED)}oppositeAndUnderwater(t,e,i){let s=e+4;return s>8&&(s-=8),i==s&&(t==n.POWERBASE||t==n.POWERBASE+1||t==n.RAILBASE||t==n.RAILBASE+1)}},g[e.SPRITE_MONSTER]=class extends A{constructor(t,i,s,a){super(),this.init(e.SPRITE_MONSTER,t,i,s,a),this.width=48,this.height=48,this.xOffset=-24,this.yOffset=-24,s>m.worldToPix(t.width)/2?a>m.worldToPix(t.height)/2?this.frame=10:this.frame=7:a>m.worldToPix(t.height)/2?this.frame=1:this.frame=4,this.flag=0,this.count=1e3,this.destX=m.worldToPix(t.pollutionMaxX),this.destY=m.worldToPix(t.pollutionMaxY),this.origX=this.x,this.origY=this.y,this._seenLand=!1,this.xDelta=[2,2,-2,-2,0],this.yDelta=[-2,2,2,-2,0],this.cardinals1=[0,1,2,3],this.cardinals2=[1,2,3,0],this.diagonals1=[2,5,8,11],this.diagonals2=[11,2,5,8]}move(t,i,s,o){this.soundCount>0&&this.soundCount--;let r,h,l=Math.floor((this.frame-1)/3);if(l<4){if(r=(this.frame-1)%3,2===r&&(this.step=0),0===r&&(this.step=1),this.step?r++:r--,m.absoluteDistance(this.x,this.y,this.destX,this.destY)<60){if(0!==this.flag)return void(this.frame=0);this.flag=1,this.destX=this.origX,this.destY=this.origY}h=m.getDir(this.x,this.y,this.destX,this.destY),h=Math.floor((h-1)/2),h!==l&&a.getChance(10)&&(r=1&a.getRandom16()?this.cardinals1[l]:this.cardinals2[l],l=4,this.soundCount||(i.sendMessage(R.SOUND_MONSTER),this.soundCount=50+a.getRandom(100)))}else l=4,h=this.frame,r=h-13&3,3&a.getRandom16()||(r=1&a.getRandom16()?this.diagonals1[r]:this.diagonals2[r],l=Math.floor((r-1)/3),r=(r-1)%3);r=3*l+r+1,r>16&&(r=16),this.frame=r,this.x+=this.xDelta[l],this.y+=this.yDelta[l],this.count>0&&this.count--;let d=m.getTileValue(this.map,this.x,this.y);(-1===d||d===n.RIVER&&this.count<500)&&(this.frame=0),(d===n.DIRT||d>n.WATER_HIGH)&&(this._seenLand=!0);let E=this.spriteManager.getSpriteList();for(let t=0;t0&&this.soundCount--,this.count>0&&this.count--,0===this.count){let t=this.spriteManager.getSprite(e.SPRITE_MONSTER);if(null!==t?(this.destX=t.x,this.destY=t.y):(t=this.spriteManager.getSprite(e.SPRITE_TORNADO),null!==t?(this.destX=t.x,this.destY=t.y):(this.destX=this.origX,this.destY=this.origY)),m.absoluteDistance(this.x,this.y,this.origX,this.origY)<30)return void(this.frame=0)}if(0===this.soundCount){let t=m.pixToWorld(this.x),e=m.pixToWorld(this.y);t>=0&&t=0&&e170&&0==(7&a.getRandom16())&&(i.sendMessage(R.HEAVY_TRAFFIC,{x:t,y:e}),i.sendMessage(R.SOUND_HEAVY_TRAFFIC),this.soundCount=200)}let r=this.frame;if(0==(3&t)){let t=m.getDir(this.x,this.y,this.destX,this.destY);r=m.turnTo(r,t),this.frame=r}this.x+=this.xDelta[r],this.y+=this.yDelta[r]}explodeSprite(t){this.frame=0,this.spriteManager.makeExplosionAt(this.x,this.y),t.sendMessage(R.HELICOPTER_CRASHED)}},g[e.SPRITE_AIRPLANE]=class extends A{constructor(t,i,s,a){super(),this.init(e.SPRITE_AIRPLANE,t,i,s,a),this.width=48,this.height=48,this.xOffset=-24,this.yOffset=-24,s>m.worldToPix(t.width-20)?(this.destX=this.x-200,this.frame=7):(this.destX=this.x+200,this.frame=11),this.destY=this.y,this.xDelta=[0,0,6,8,6,0,-6,-8,-6,8,8,8],this.yDelta=[0,-8,-6,0,6,8,6,0,-6,0,0,0]}move(t,i,s,o){let r=this.frame;if(t%5==0)if(r>8)r--,r<9&&(r=3),this.frame=r;else{let t=m.getDir(this.x,this.y,this.destX,this.destY);r=m.turnTo(r,t),this.frame=r}if(m.absoluteDistance(this.x,this.y,this.destX,this.destY)<50&&(this.destX=a.getRandom(m.worldToPix(this.map.width))+8,this.destY=a.getRandom(m.worldToPix(this.map.height))+8),s.enableDisasters){let t=!1,s=this.spriteManager.getSpriteList();for(let a=0;a0&&this.count--,this.frame=o;let r=this.spriteManager.getSpriteList();for(let t=0;t6&&(this.frame=0,this.startFire(this.x,this.y),this.startFire(this.x-16,this.y-16),this.startFire(this.x+16,this.y+16),this.startFire(this.x-16,this.y+16),this.startFire(this.x+16,this.y+16))}};class f{constructor(t){this.spriteList=[],this.map=t,this.spriteCycle=0}getSprite(t){let e=this.spriteList.filter((function(e){return 0!==e.frame&&e.type===t}));return 0===e.length?null:e[0]}getSpriteList(){return this.spriteList.slice()}getSpritesInView(t,e,i,s){return t=m.worldToPix(t),e=m.worldToPix(e),i=m.worldToPix(i),s=m.worldToPix(s),this.spriteList.filter((function(a){return a.x+a.xOffset>=t&&a.y+a.yOffset>=e&&!(a.x+a.xOffset>=i&&a.y+a.yOffset>=s)}))}moveObjects(t){t||(t=e.simData);let i=t.messageManager,s=t.disasterManager,a=t.blockMaps;this.spriteCycle+=1;let o=this.spriteList.slice(),r=o.length;for(;r--;){let t=o[r];0!==t.frame&&t.move(this.spriteCycle,i,s,a)}this.pruneDeadSprites()}makeSprite(t,e,i){this.spriteList.push(new g[t](this.map,this,e,i))}makeTornado(t){let i=this.getSprite(e.SPRITE_TORNADO);if(null!==i)return void(i.count=200);let s=a.getRandom(m.worldToPix(this.map.width)-800)+400,o=a.getRandom(m.worldToPix(this.map.height)-200)+100;this.makeSprite(e.SPRITE_TORNADO,s,o),t.sendMessage(R.TORNADO_SIGHTED,{x:m.pixToWorld(s),y:m.pixToWorld(o)})}makeExplosion(t,e){this.map.testBounds(t,e)&&this.makeExplosionAt(m.worldToPix(t),m.worldToPix(e))}makeExplosionAt(t,i){this.makeSprite(e.SPRITE_EXPLOSION,t,i)}generatePlane(t,i){null===this.getSprite(e.SPRITE_AIRPLANE)&&this.makeSprite(e.SPRITE_AIRPLANE,m.worldToPix(t),m.worldToPix(i))}generateTrain(t,i,s){t.totalPop>20&&null===this.getSprite(e.SPRITE_TRAIN)&&0===a.getRandom(25)&&this.makeSprite(e.SPRITE_TRAIN,m.worldToPix(i)+8,m.worldToPix(s)+8)}generateShip(){let t,e;if(a.getChance(3))for(t=4;t0&&(a+=i.worldGet(r,n),o++);return 2.4*Math.floor(a/o)}static getUnemployment(t){var e=8*(t.comPop+t.indPop);if(0===e)return 0;var i=t.resPop/e;return e=Math.round(255*(i-1)),Math.min(e,255)}static getFireSeverity(t){return Math.min(5*t.firePop,255)}}class S{constructor(t){this.problemVotes=[],this.problemOrder=[],this.evalInit(),this.gameLevel=""+t,this.changed=!1}save(t){for(var i=0,s=e.EvalProps.length;i0){e.problemData=[];for(var s=0;s2e3&&(this.cityClass=e.CC_TOWN),t>1e4&&(this.cityClass=e.CC_CITY),t>5e4&&(this.cityClass=e.CC_CAPITAL),t>1e5&&(this.cityClass=e.CC_METROPOLIS),t>5e5&&(this.cityClass=e.CC_MEGALOPOLIS),this.cityClass!==this.cityClassLast&&(this.cityClassLast=this.cityClass,i.emitEvent(R.CLASSIFICATION_UPDATED,this.cityClass)),this.cityClass}voteProblems(){for(var t=0;tr&&(this.problemVotes[i].voteCount+=1,s++),i=(i+1)%e.NUMPROBLEMS,o++}}doProblems(t,i,s){e.problemData[e.CRIME]=t.crimeAverage,e.problemData[e.POLLUTION]=t.pollutionAverage,e.problemData[e.HOUSING]=7*t.landValueAverage/10,e.problemData[e.TAXES]=10*i.cityTax,e.problemData[e.TRAFFIC]=O.getTrafficAverage(s,t),e.problemData[e.UNEMPLOYMENT]=O.getUnemployment(t),e.problemData[e.FIRE]=O.getFireSeverity(t),this.voteProblems(),this.problemVotes.sort((function(t,e){return e.voteCount-t.voteCount})),this.problemOrder=this.problemVotes.map((function(t,i){return i>=e.NUM_COMPLAINTS||0===t.voteCount?null:t.index}))}getScore(t){var s,o=t.census,r=t.budget,n=t.valves;s=this.cityScore;for(var h=0,l=0;l0?E=this.cityPopDelta/this.cityPop+1:this.cityPopDelta<0&&(E=.95+Math.floor(this.cityPopDelta/(this.cityPop-this.cityPopDelta))),h=(h=Math.round(h*E))-O.getFireSeverity(o)-r.cityTax,(E=o.unpoweredZoneCount+o.poweredZoneCount)>0&&(h=Math.round(h*(o.poweredZoneCount/E))),h=a.clamp(h,0,1e3),this.cityScore=Math.round((this.cityScore+h)/2),this.cityScoreDelta=this.cityScore-s,0!==this.cityScoreDelta&&i.emitEvent(R.SCORE_UPDATED,this.cityScore)}doVotes(){this.cityYes=0;for(let t=0;t<100;t++){let t=a.getRandom(1e3);this.cityScore>t&&this.cityYes++}}changeEval(){this.changed=!0}countProblems(){var t;for(t=0;t=e.NUM_COMPLAINTS||this.problemOrder[t]===e.NUMPROBLEMS?-1:this.problemOrder[t]}getProblemVotes(t){return t<0||t>=e.NUM_COMPLAINTS||this.problemOrder[t]==e.NUMPROBLEMS?-1:this.problemVotes[this.problemOrder[t]].voteCount}}class I{constructor(){this.resValve=0,this.comValve=0,this.indValve=0,this.resCap=!1,this.comCap=!1,this.indCap=!1}save(t){t.resValve=this.resValve,t.comValve=this.comValve,t.indValve=this.indValve}load(t){this.resValve=t.resValve,this.comValve=t.comValve,this.indValve=t.indValve,i.emitEvent(R.VALVES_UPDATED,{residential:this.resValve,commercial:this.comValve,industrial:this.indValve})}setValves(t,s,o){var r,n=s.resPop/8;s.totalPop=Math.round(n+s.comPop+s.indPop);var h=n+n*((s.resPop>0?(s.comHist10[1]+s.indHist10[1])/n:1)-1)+.02*n;r=(r=s.comHist10[1]+s.indHist10[1])>0?s.resHist10[1]/r:1,r=a.clamp(r,0,1.3);var l,d,E,c=(n+s.comPop+s.indPop)/3.7*r,u=s.indPop*r*e.extMarketParamTable[t];u=Math.max(u,5),l=n>0?h/n:1.3,d=s.comPop>0?c/s.comPop:c,E=s.indPop>0?u/s.indPop:u,l=Math.min(l,2),d=Math.min(d,2),E=Math.min(E,2);var T=Math.min(o.cityTax+t,20);l=600*(l-1)+e.taxTable[T],d=600*(d-1)+e.taxTable[T],E=600*(E-1)+e.taxTable[T],this.resValve=a.clamp(this.resValve+Math.round(l),-e.RES_VALVE_RANGE,e.RES_VALVE_RANGE),this.comValve=a.clamp(this.comValve+Math.round(d),-e.COM_VALVE_RANGE,e.COM_VALVE_RANGE),this.indValve=a.clamp(this.indValve+Math.round(E),-e.IND_VALVE_RANGE,e.IND_VALVE_RANGE),this.resCap&&this.resValve>0&&(this.resValve=0),this.comCap&&this.comValve>0&&(this.comValve=0),this.indCap&&this.indValve>0&&(this.indValve=0),i.emitEvent(R.VALVES_UPDATED,{residential:this.resValve,commercial:this.comValve,industrial:this.indValve})}}class L{constructor(){this.roadEffect=e.MAX_ROAD_EFFECT,this.policeEffect=e.MAX_POLICESTATION_EFFECT,this.fireEffect=e.MAX_FIRESTATION_EFFECT,this.totalFunds=0,this.cityTax=7,this.cashFlow=0,this.taxFund=0,this.roadMaintenanceBudget=0,this.fireMaintenanceBudget=0,this.policeMaintenanceBudget=0,this.roadPercent=1,this.firePercent=1,this.policePercent=1,this.roadSpend=0,this.fireSpend=0,this.policeSpend=0,this.awaitingValues=!1,this.autoBudget=!0}save(t){for(var i=0,s=e.BudgetProps.length;i=this.roadSpend?this.roadSpend:s,s-=e=s>=this.fireSpend?this.fireSpend:s,s-=i=s>=this.policeSpend?this.policeSpend:s,this.roadMaintenanceBudget>0?this.roadPercent=(t/this.roadMaintenanceBudget).toPrecision(2)-0:this.roadPercent=1,this.fireMaintenanceBudget>0?this.firePercent=(e/this.fireMaintenanceBudget).toPrecision(2)-0:this.firePercent=1,this.policeMaintenanceBudget>0?this.policePercent=(i/this.policeMaintenanceBudget).toPrecision(2)-0:this.policePercent=1,{road:t,police:i,fire:e}}doBudgetWindow(){return this.doBudgetNow(!0)}doBudgetNow(t){var e=this._calculateBestPercentages();if(!this.autoBudget&&!t)return this.autoBudget=!1,this.awaitingValues=!0,void i.emitEvent(R.BUDGET_NEEDED);var s=e.road,a=e.police,o=e.fire,r=s+a+o;if(this.totalFunds+this.taxFund-r>0&&this.autoBudget||t)return this.awaitingValues=!1,void this.doBudgetSpend(s,o,a);this.setAutoBudget(!1),this.awaitingValues=!0,i.emitEvent(R.BUDGET_NEEDED),i.emitEvent(R.NO_MONEY)}doBudgetSpend(t,e,i){this.roadSpend=t,this.fireSpend=e,this.policeSpend=i;var s=this.roadSpend+this.fireSpend+this.policeSpend;this.spend(-(this.taxFund-s)),this.updateFundEffects()}updateFundEffects(){this.roadSpend=Math.round(this.roadMaintenanceBudget*this.roadPercent),this.fireSpend=Math.round(this.fireMaintenanceBudget*this.firePercent),this.policeSpend=Math.round(this.policeMaintenanceBudget*this.policePercent),this.roadEffect=e.MAX_ROAD_EFFECT,this.policeEffect=e.MAX_POLICESTATION_EFFECT,this.fireEffect=e.MAX_FIRESTATION_EFFECT,this.roadMaintenanceBudget>0&&(this.roadEffect=Math.floor(this.roadEffect*this.roadSpend/this.roadMaintenanceBudget)),this.fireMaintenanceBudget>0&&(this.fireEffect=Math.floor(this.fireEffect*this.fireSpend/this.fireMaintenanceBudget)),this.policeMaintenanceBudget>0&&(this.policeEffect=Math.floor(this.policeEffect*this.policeSpend/this.policeMaintenanceBudget))}collectTax(t,i){this.cashFlow=0,this.policeMaintenanceBudget=i.policeStationPop*e.policeMaintenanceCost,this.fireMaintenanceBudget=i.fireStationPop*e.fireMaintenanceCost;var s=i.roadTotal*e.roadMaintenanceCost,a=i.railTotal*e.railMaintenanceCost;this.roadMaintenanceBudget=Math.floor((s+a)*e.RLevels[t]),this.taxFund=Math.floor(Math.floor(i.totalPop*i.landValueAverage/120)*this.cityTax*e.FLevels[t]),i.totalPop>0?(this.cashFlow=this.taxFund-(this.policeMaintenanceBudget+this.fireMaintenanceBudget+this.roadMaintenanceBudget),this.doBudgetNow(!1)):(this.roadEffect=e.MAX_ROAD_EFFECT,this.policeEffect=e.MAX_POLICESTATION_EFFECT,this.fireEffect=e.MAX_FIRESTATION_EFFECT)}setTax(t){t!==this.cityTax&&(this.cityTax=t)}setFunds(t){t!==this.totalFunds&&(this.totalFunds=Math.max(0,t),i.emitEvent(R.FUNDS_CHANGED,this.totalFunds),0===this.totalFunds&&i.emitEvent(R.NO_MONEY))}spend(t){this.setFunds(this.totalFunds-t)}shouldDegradeRoad(){return this.roadEffectthis.resPopScaled?this.needHospital=-1:this.hospitalPop===this.resPopScaled&&(this.needHospital=0),this.changed=!0}take120Census(){s.rotate120Arrays.call(this);this.resHist120[0]=Math.floor(this.resPop/8),this.comHist120[0]=this.comPop,this.indHist120[0]=this.indPop,this.crimeHist120[0]=this.crimeHist10[0],this.pollutionHist120[0]=this.pollutionHist10[0],this.moneyHist120[0]=this.moneyHist10[0],this.changed=!0}}class _{constructor(t,e,i){if(void 0===t||void 0===e||void 0===i)throw new Error("Invalid dimensions for block map");this.isBlockMap=!0,this.blockSize=i,this.gameMapWidth=t,this.gameMapHeight=e,this.width=Math.floor((t+i-1)/i),this.height=Math.floor((e+i-1)/i),this.data=[],this.clear()}clear(){let t,e=this.height;for(;e--;)for(t=this.width;t--;)this.data[this.width*e+t]=0}copyFrom(t,e){t.width===this.width&&t.height===this.height&&t.blockSize===this.blockSize||console.warn("Copying from incompatible blockMap!");let i,s,a=t.height,o=t.width;for(s=0;s=this.width||this.y<0||this.y>=this.height||!a)throw new Error("Invalid parameter")}isNumber(t){return!isNaN(t)}isDirection(t){return this.isNumber(t)&&-1!==this.validDirs.indexOf(t)}set(t){this.x=t.x,this.y=t.y}toString(){return"("+this.x+", "+this.y+")"}toInt(){return this.y*this.width+this.x}move(t){let e=!1;switch(t){case P.INVALID:return!0;case P.NORTH:this.y>0&&(this.y--,e=!0);break;case P.NORTHEAST:this.y>0&&this.x0&&(this.y++,this.x--,e=!0);break;case P.WEST:this.x>0&&(this.x--,e=!0);break;case P.NORTHWEST:this.y>0&&this.x>0&&(this.y--,this.x--,e=!0)}return e}}class N{constructor(t){this._map=t,this._powerStack=[],this.powerGridMap=new _(this._map.width,this._map.height,1,0)}setTilePower(t,e){var i=this._map.getTile(t,e),s=i.getValue();s===n.NUCLEAR||s===n.POWERPLANT||this.powerGridMap.worldGet(t,e)>0?i.addFlags(n.POWERBIT):i.removeFlags(n.POWERBIT)}clearPowerStack(){this._powerStackPointer=0,this._powerStack=[]}testForConductive(t,e){var i=new M(t);return!(!i.move(e)||!this._map.getTile(i.x,i.y).isConductive()||0!==this.powerGridMap.worldGet(i.x,i.y))}doPowerScan(t){this.powerGridMap.clear();let s=t.coalPowerPop*e.COAL_POWER_STRENGTH+t.nuclearPowerPop*e.NUCLEAR_POWER_STRENGTH,a=0;for(;this._powerStack.length>0;){var o,r=this._powerStack.pop(),n=P.INVALID;do{if(a++,a>s)return void i.emitEvent(R.NOT_ENOUGH_POWER);n!==P.INVALID&&r.move(n),this.powerGridMap.worldSet(r.x,r.y,1),o=0;for(var h=P.BEGIN;h1&&this._powerStack.push(new M(r))}while(o)}}coalPowerFound(t,i,s,a){a||(a=e.simData),a.census.coalPowerPop+=1,this._powerStack.push(new M(i,s));var o=[-1,2,1,2],r=[-1,-1,0,0];if(!a.is3D)for(var h=0;h<4;h++)t.addTileFlags(i+o[h],s+r[h],n.ANIMBIT)}nuclearPowerFound(t,i,s,o){o||(o=e.simData);if(!(o.disasterManager.disastersEnabled&&0===a.getRandom([3e4,2e4,1e4][o.gameLevel])||(o.census.nuclearPowerPop+=1,this._powerStack.push(new M(i,s)),o.is3D)))for(var r=0;r<4;r++)t.addTileFlags(i,s,n.ANIMBIT|n.CONDBIT|n.POWERBIT|n.BURNBIT)}registerHandlers(t,e){t.addAction(n.POWERPLANT,this.coalPowerFound.bind(this)),t.addAction(n.NUCLEAR,this.nuclearPowerFound.bind(this)),e.addAction(n.POWERPLANT,7,4),e.addAction(n.NUCLEAR,7,4)}}class C{constructor(t){this._map=t,this._actions=[]}addAction(t,e){this._actions.push({criterion:t,action:e})}mapScan(t,i,a){a||(a=e.simData);let o,h,l,d,E,c,R,u=this._map.height;for(;u--;)for(o=t;o=n.ROADBASE)&&this._map.setTile(t+s,e+a,h,n.CONDBIT|n.BURNBIT))}checkTile(t,e,i){let a,o,r,n,h,l=this._actions.length;for(;l--;)a=this._actions[l],o=a.period,0==(i&o)&&(r=this._map.getTile(t,e),n=r.getValue(),h=s.isCallable(a.criterion),h&&a.criterion.call(null,r)?this.repairZone(t,e,a.zoneSize):h||a.criterion!==n||this.repairZone(t,e,a.zoneSize))}}class w{constructor(t,e){this._map=t,this._stack=[],this._spriteManager=e}makeTraffic(t,i,s,a){this._stack=[];let o=new M(t,i);return this.findPerimeterRoad(o)?this.tryDrive(o,a)?(this.addToTrafficDensityMap(s),e.ROUTE_FOUND):e.NO_ROUTE_FOUND:e.NO_ROAD_FOUND}addToTrafficDensityMap(t){let i=t.trafficDensityMap;for(;this._stack.length>0;){let t=this._stack.pop();if(!this._map.testBounds(t.x,t.y))continue;let s=this._map.getTileValue(t.x,t.y);if(s>=n.ROADBASE&&s=240&&0===a.getRandom(5)){let i=this._spriteManager.getSprite(e.SPRITE_HELICOPTER);null!==i&&(i.destX=o.worldToPix(t.x),i.destY=o.worldToPix(t.y))}}}}findPerimeterRoad(t){for(let i=0;i<12;i++){let s=t.x+e.perimX[i],a=t.y+e.perimY[i];if(this._map.testBounds(s,a)&&o.isDriveable(this._map.getTileValue(s,a)))return t.x=s,t.y=a,!0}return!1}tryDrive(t,i){let s=P.INVALID,a=new M(t);for(let t=0;t0))return!1;this._stack.pop(),t+=3}}return!1}tryGo(t,e){let i,s=[],r=P.NORTH,h=0;for(i=0;i<4;i++)r!=e&&o.isDriveable(this._map.getTileFromMapOrDefault(t,r,n.DIRT))?(s[i]=r,h++):s[i]=P.INVALID,r=P.rotate90(r);if(0===h)return P.INVALID;if(1===h)for(i=0;i<4;i++)if(s[i]!=P.INVALID)return s[i];for(i=3&a.getRandom16();s[i]===P.INVALID;)i=i+1&3;return s[i]}driveDone(t,e){return!!(t.y>0&&e(this._map.getTileValue(t.x,t.y-1)))||(!!(t.x0&&e(this._map.getTileValue(t.x-1,t.y)))))}}const V=function(t){let e=t.getValue();return!(en.LASTZONE||t.isZone())};class H{constructor(t,e,i){this._map=t,this._spriteManager=e,this._gameLevel=i,this._floodCount=0,this.disastersEnabled=!1,this.Dx=[0,1,0,-1],this.Dy=[-1,0,1,0]}doDisasters(t){if(this._floodCount&&this._floodCount--,this.disastersEnabled&&a.getRandom(e.DisChance[this._gameLevel]))switch(a.getRandom(8)){case 0:case 1:this.setFire();break;case 2:case 3:this.makeFlood();break;case 4:break;case 5:this._spriteManager.makeTornado();break;case 6:break;case 7:case 8:t.pollutionAverage>60&&this._spriteManager.makeMonster()}}setDifficulty(t){this._gameLevel=t}scenarioDisaster(){}makeMeltdown(){for(let t=0;td&&ln.CHANNEL&&o<=n.WATER_HIGH))for(h=0;h<4;h++)if(l=e+this.Dx[h],d=s+this.Dy[h],this._map.testBounds(l,d)&&(E=this._map.getTile(l,d),o=E.getValue(),E===n.DIRT||E.isBulldozable()&&E.isCombustible))return this._map.setTo(l,d,new r(n.FLOOD)),this._floodCount=30,void i.emitEvent(R.FLOODING_REPORTED,{showable:!0,x:l,y:d})}doFlood(t,e,i){let s,r,h,l,d;if(this._floodCount>0)for(s=0;s<4;s++)a.getChance(7)&&(r=t+this.Dx[s],h=e+this.Dy[s],this._map.testBounds(r,h)&&(l=this._map.getTile(r,h),d=l.getValue(),(l.isCombustible()||d===n.DIRT||d>=n.WOODS5&&d=n.LHTHR&&s<=n.HHTHR&&(r+=1);return r},getZonePopulation:function(t,e,i,s){if(s===n.FREEZ)return v.getFreeZonePopulation(t,e,i,s);return 8*(Math.floor((s-n.RZB)/9)%4+1)+16},evalLot:function(t,e,i){let s=[0,1,0,-1],a=[-1,0,1,0];if(!t.testBounds(e,i))return-1;let o=t.getTileValue(e,i);if(on.RESBASE+8)return-1;let r,h,l,d=1;for(r=0;r<4;r++)h=e+s[r],l=i+a[r],h<0||h>=t.width||l<0||l>=t.height||(o=t.getTileValue(h,l),o!==n.DIRT&&o<=n.LASTROAD&&(d+=1));return d},buildHouse:function(t,e,i,s){let o,r,h,l,d=0,E=0,c=[0,-1,0,1,-1,1,-1,0,1],R=[0,-1,-1,-1,0,0,1,1,1];for(o=0;o<9;o++)r=e+c[o],h=i+R[o],l=v.evalLot(t,r,h),l>E?(E=l,d=o):l===E&&a.getChance(7)&&(d=o);d>0&&t.testBounds(e+c[d],i+R[d])&&t.setTile(e+c[d],i+R[d],n.HOUSE+a.getRandom(2)+3*s,n.BLBNCNBIT)},growZone:function(t,e,i,s,a,r,h){s.pollutionDensityMap.worldGet(e,i)>128||(t.getTileValue(e,i)!==n.FREEZ?a<40&&(v.placeResidential(t,e,i,Math.floor(a/8)-1,r,h),o.incRateOfGrowth(s,e,i,8)):a<8?(v.buildHouse(t,e,i,r),o.incRateOfGrowth(s,e,i,1)):s.populationDensityMap.worldGet(e,i)>64&&(v.placeResidential(t,e,i,0,r,h),o.incRateOfGrowth(s,e,i,8)))},degradeZone:function(t,e,i,s,h,l,d){let E,c;if(0===h)return;if(h>16)return v.placeResidential(t,e,i,Math.floor((h-24)/8),l,d),void o.incRateOfGrowth(s,e,i,-8);if(16===h){for(t.setTo(e,i,new r(n.FREEZ,n.BLBNCNBIT|n.ZONEBIT)),c=i-1;c<=i+1;c++)for(E=e-1;E<=e+1;E++)E===e&&c===i||t.setTile(e,i,n.LHTHR+l+a.getRandom(2),n.BLBNCNBIT);return void o.incRateOfGrowth(s,e,i,-8)}let R=0;for(o.incRateOfGrowth(s,e,i,-1),E=e-1;E<=e+1;E++)for(c=i-1;c<=i+1;c++){let e=t.getTileValue(E,c);if(e>=n.LHTHR&&e<=n.HHTHR)return void t.setTile(E,c,y[R]+n.RESBASE,n.BLBNCNBIT);R+=1}},evalResidential:function(t,i,s,a){if(a===e.NO_ROAD_FOUND)return-3e3;let o=t.landValueMap.worldGet(i,s);return o-=t.pollutionDensityMap.worldGet(i,s),o=o<0?0:Math.min(32*o,6e3),o-3e3},residentialFound:function(t,i,s,r){let h;r||(r=e.simData),r.census.resZonePop+=1;let l=t.getTileValue(i,s),d=v.getZonePopulation(t,i,s,l);r.census.resPop+=d;let E=t.getTile(i,s).isPowered(),c=e.ROUTE_FOUND;if(d>a.getRandom(35)&&(c=r.traffic.makeTraffic(i,s,r.blockMaps,o.isCommercial),c===e.NO_ROAD_FOUND))return h=o.getLandPollutionValue(r.blockMaps,i,s),void v.degradeZone(t,i,s,r.blockMaps,d,h,E);if(l===n.FREEZ||a.getChance(7)){let e=v.evalResidential(r.blockMaps,i,s,c),n=r.valves.resValve+e;if(E||(n=-500),n>-350&&n-26380>a.getRandom16Signed())return 0===d&&a.getChance(3)?void v.makeHospital(t,i,s,r,E):(h=o.getLandPollutionValue(r.blockMaps,i,s),void v.growZone(t,i,s,r.blockMaps,d,h,E));n<350&&n+263800)return o.putZone(t,i,s,n.HOSPITAL,r),void(a.census.needHospital=0)},hospitalFound:function(t,i,s,r){r||(r=e.simData),r.census.hospitalPop+=1,-1===r.census.needHospital&&0===a.getRandom(20)&&o.putZone(t,i,s,n.FREEZ,t.getTile(i,s).isPowered())}},b={registerHandlers:function(t,e){t.addAction(o.isCommercialZone,b.commercialFound)},getZonePopulation:function(t,e,i,s){return s===n.COMCLR?0:Math.floor((s-n.CZB)/9)%5+1},placeCommercial:function(t,e,i,s,a,r){var h=9*(5*a+s)+n.CZB;o.putZone(t,e,i,h,r)},growZone:function(t,e,i,s,a,r,n){var h=s.landValueMap.worldGet(e,i);a>(h>>=5)||a<5&&(b.placeCommercial(t,e,i,a,r,n),o.incRateOfGrowth(s,e,i,8))},degradeZone:function(t,e,i,s,a,r,h){a>1?b.placeCommercial(t,e,i,a-2,r,h):o.putZone(t,e,i,n.COMCLR,h),o.incRateOfGrowth(s,e,i,-8)},commercialFound:function(t,i,s,r){var n;r||(r=e.simData),r.census.comZonePop+=1;var h=t.getTileValue(i,s),l=b.getZonePopulation(t,i,s,h);r.census.comPop+=l;var d=t.getTile(i,s).isPowered(),E=e.ROUTE_FOUND;if(l>a.getRandom(5)&&(E=r.traffic.makeTraffic(i,s,r.blockMaps,o.isIndustrial))===e.NO_ROAD_FOUND)return n=o.getLandPollutionValue(r.blockMaps,i,s),void b.degradeZone(t,i,s,r.blockMaps,l,n,d);if(a.getChance(7)){var c=E===e.NO_ROAD_FOUND?-3e3:r.blockMaps.cityCentreDistScoreMap.worldGet(i,s),R=r.valves.comValve+c;if(d||(R=-500),d&&R>-350&&R-26380>a.getRandom16Signed())return n=o.getLandPollutionValue(r.blockMaps,i,s),void b.growZone(t,i,s,r.blockMaps,l,n,d);R<350&&R+263801?x.placeIndustrial(t,e,i,a-2,r,h):o.putZone(t,e,i,n.INDCLR,h),o.incRateOfGrowth(s,e,i,-8)},setAnimation:function(t,e,i,s,a){if(!(s>3;U[o]&&a?t.addTileFlags(e+F[o],i+W[o],n.ASCBIT):(t.addTileFlags(e+F[o],i+W[o],n.BNCNBIT),t.removeTileFlags(e+F[o],i+W[o],n.ANIMBIT))}},industrialFound:function(t,i,s,r){r||(r=e.simData),r.census.indZonePop+=1;var n=t.getTileValue(i,s),h=x.getZonePopulation(t,i,s,n);r.census.indPop+=h;var l=t.getTile(i,s).isPowered();r.is3D||x.setAnimation(t,i,s,n,l);var d=e.ROUTE_FOUND;if(h>a.getRandom(5)&&(d=r.traffic.makeTraffic(i,s,r.blockMaps,o.isResidential))===e.NO_ROAD_FOUND){var E=1&a.getRandom16();x.degradeZone(t,i,s,r.blockMaps,h,E,l)}else if(a.getChance(7)){var c=r.valves.indValve+(d===e.NO_ROAD_FOUND?-1e3:0);if(l||(c=-500),c>-350&&c-26380>a.getRandom16Signed())return void x.growZone(t,i,s,r.blockMaps,h,1&a.getRandom16(),l);c<350&&c+26380340&&j.closeBridge(t,i,s,k,G,X,Z),!0;if(o==n.BRWH)return a.getChance(3)&&r.spriteManager.getBoatDistance(i,s)>340&&j.closeBridge(t,i,s,z,Y,K,q),!0;if(r.spriteManager.getBoatDistance(i,s)<300||a.getChance(7)){if(1&o)return i0&&t.getTileValue(i,s-1)===n.CHANNEL)return j.openBridge(t,i,s,z,Y,q,K),!0}return!1},roadFound:function(t,i,s,h){h||(h=e.simData),h.census.roadTotal+=1;let l=t.getTile(i,s),d=l.getValue();if(h.budget.shouldDegradeRoad()&&a.getChance(511)&&!l.isConductive()&&h.budget.roadEffect<(31&a.getRandom16()))return void((15&d)<2||15==(15&d)?t.setTile(i,s,n.RIVER):t.setTo(i,s,o.randomRubble()));l.isCombustible()||(h.census.roadTotal+=4);let E=0;d>6;if(c>1&&(c-=1),c===E)return;let R=(d-n.ROADBASE&15)+Q[c],u=l.getFlags()&~n.ANIMBIT;c>0&&(u|=n.ANIMBIT),t.setTo(i,s,new r(R,u))}},J={registerHandlers:function(t,e){t.addAction(o.isRail,J.railFound),t.addAction(n.PORT,J.portFound),t.addAction(n.AIRPORT,J.airportFound),e.addAction(n.PORT,15,4),e.addAction(n.AIRPORT,7,6)},railFound:function(t,i,s,r){if(r||(r=e.simData),r.census.railTotal+=1,r.spriteManager.generateTrain(r.census,i,s),r.budget.shouldDegradeRoad()&&a.getChance(511)){let e=t.getTile(i,s);if(e.isConductive())return;if(r.budget.roadEffect<(31&a.getRandom16())){e.getValue()n.IZB&&r.spriteManager.makeExplosionAt(i,s)),t.setTo(o.randomFire())}let c=10;h=r.blockMaps.fireStationEffectMap.worldGet(i,s),h>100?c=1:h>20?c=2:h>0&&(c=3),0===a.getRandom(c)&&t.setTo(i,s,o.randomRubble())},radiationFound:function(t,e,i,s){a.getChance(4095)&&t.setTile(e,i,n.DIRT,0)},floodFound:function(t,i,s,a){a||(a=e.simData),a.disasterManager.doFlood(i,s,a.blockMaps)}},at={registerHandlers:function(t,e){t.addAction(n.STADIUM,at.emptyStadiumFound),t.addAction(n.FULLSTADIUM,at.fullStadiumFound),e.addAction(n.STADIUM,15,4)},emptyStadiumFound:function(t,i,s,a){a||(a=e.simData),a.census.stadiumPop+=1,t.getTile(i,s).isPowered()&&0==(a.cityTime+i+s&31)&&(t.putZone(i,s,n.FULLSTADIUM,4),t.addTileFlags(i,s,n.POWERBIT),t.setTo(i+1,s,new r(n.FOOTBALLGAME1,n.ANIMBIT)),t.setTo(i+1,s+1,new r(n.FOOTBALLGAME2,n.ANIMBIT)))},fullStadiumFound:function(t,i,s,a){a||(a=e.simData),a.census.stadiumPop+=1;let o=t.getTile(i,s).isPowered();0==(a.cityTime+i+s&7)&&(t.putZone(i,s,n.STADIUM,4),o&&t.addTileFlags(i,s,n.POWERBIT))}};class ot{static smoothMap(t,i,s){let a,o,r=t.width;for(;r--;)for(a=t.height;a--;)o=0,r>0&&(o+=t.get(r-1,a)),r0&&(o+=t.get(r,a-1)),a>2,o>255&&(o=255),i.set(r,a,o))}static neutraliseRateOfGrowthMap(t){let e,i,s=t.rateOfGrowthMap,o=s.width;for(;o--;)for(e=s.height;e--;)i=s.get(o,e),0!==i&&(i>0?i--:i++,i=a.clamp(i,-200,200),s.set(o,e,i))}static neutraliseTrafficMap(t){let e,i,s=t.trafficDensityMap,a=s.width;for(;a--;)for(e=s.height;e--;)i=s.get(a,e),0!==i&&(i<=24?i=0:i-=i>200?34:24,s.set(a,e,i))}static getPollutionValue(t){if(t=n.HTRFBASE)return 75;if(t>=n.LTRFBASE)return 50;if(tn.FIREBASE)return 90;if(t>=n.RADTILE)return 255}return 0}return t<=n.LASTIND?0:tt.cityCentreX?e-t.cityCentreX:t.cityCentreX-e,a=i>t.cityCentreY?i-t.cityCentreY:t.cityCentreY-i,Math.min(s+a,64)}static pollutionTerrainLandValueScan(t,i,s){let o=s.tempMap1,r=s.tempMap2,h=s.tempMap3;h.clear();let l,d,E,c,R,u,T,p,m,A,g=s.landValueMap,f=s.terrainDensityMap,O=s.pollutionDensityMap,S=s.crimeRateMap,I=0,L=0,D=g.width;for(;D--;)for(l=g.height;l--;){for(d=0,E=!1,c=2*D,R=2*l,u=c;u<=c+1;u++)for(T=R;T<=R+1;T++)p=t.getTileValue(u,T),p!==n.DIRT&&(p=n.ROADBASE&&(E=!0)));d=Math.min(d,255),o.set(D,l,d),E?(A=34-Math.floor(ot.getCityCentreDistance(t,c,R)/2),A<<=2,A+=f.get(D>>1,l>>1),A-=O.get(D,l),S.get(D,l)>190&&(A-=20),A=a.clamp(A,1,250),g.set(D,l,A),I+=A,L++):g.set(D,l,0)}i.landValueAverage=L>0?Math.floor(I/L):0,ot.smoothMap(o,r,e.SMOOTH_ALL_THEN_CLAMP),ot.smoothMap(r,o,e.SMOOTH_ALL_THEN_CLAMP);let _,P=0,M=0,N=0;for(D=0;DP||_===P&&a.getChance(3))&&(P=_,t.pollutionMaxX=D,t.pollutionMaxY=l));i.pollutionAverage=M?Math.floor(N/M):0,ot.smoothMap(h,f,e.SMOOTH_NEIGHBOURS_THEN_BLOCK)}static crimeScan(t,i){let s=i.policeStationMap,o=i.policeStationEffectMap,r=i.crimeRateMap,n=i.landValueMap,h=i.populationDensityMap;ot.smoothMap(s,o,e.SMOOTH_NEIGHBOURS_THEN_BLOCK),ot.smoothMap(o,s,e.SMOOTH_NEIGHBOURS_THEN_BLOCK),ot.smoothMap(s,o,e.SMOOTH_NEIGHBOURS_THEN_BLOCK);let l,d,E,c=0,R=0,u=r.mapWidth,T=r.mapHeight;for(l=0;l0?(R+=1,E=128-E,E+=h.worldGet(l,d),E=Math.min(E,300),E-=s.worldGet(l,d),E=a.clamp(E,0,250),r.worldSet(l,d,E),c+=E):r.worldSet(l,d,0);t.crimeAverage=R>0?Math.floor(c/R):0}static fillCityCentreDistScoreMap(t,e){let i,s,a=e.cityCentreDistScoreMap,o=a.width;for(;o--;)for(i=a.height;i--;)s=Math.floor(ot.getCityCentreDistance(t,8*o,8*i)/2),s*=4,s=64-s,a.set(o,i,s)}static getPopulationDensity(t,e,i,s){return s0?(t.cityCentreX=Math.floor(o/n),t.cityCentreY=Math.floor(r/n)):(t.cityCentreX=Math.floor(.5*t.width),t.cityCentreY=Math.floor(.5*t.height))}static fireAnalysis(t){let i=t.fireStationMap,s=t.fireStationEffectMap;ot.smoothMap(i,s,e.SMOOTH_NEIGHBOURS_THEN_BLOCK),ot.smoothMap(s,i,e.SMOOTH_NEIGHBOURS_THEN_BLOCK),ot.smoothMap(i,s,e.SMOOTH_NEIGHBOURS_THEN_BLOCK)}}class rt{constructor(t,i,s,a,o){if(i!==e.LEVEL_EASY&&i!==e.LEVEL_MED&&i!==e.LEVEL_HARD)throw new Error("Invalid level!");this.map=t,this.gameLevel=i,this.div=this.map.width/8,this.is3D=a||!1,this.time="undefined"==typeof performance?Date:performance,this.speed=s,this.speedCycle=0,this.phaseCycle=0,this.simCycle=0,this.doInitialEval=!0,this.cityTime=50,this.cityPopLast=0,this.messageLast=R.VILLAGE_REACHED,this.startingYear=1900,this.resValveLast=0,this.comValveLast=0,this.indValveLast=0,this._cityYearLast=-1,this._cityMonthLast=-1,this._lastPowerMessage=null,this.infos=[],this.evaluation=new S(this.gameLevel),this.valves=new I,this.budget=new L,this.census=new D,this.powerManager=new N(this.map),this.spriteManager=new f(this.map),this.mapScanner=new C(this.map),this.repairManager=new B(this.map),this.traffic=new w(this.map,this.spriteManager),this.disasterManager=new H(this.map,this.spriteManager,this.gameLevel),this.messageManager=new E,e.messageManager=this.messageManager;let r=this.map.width,n=this.map.height;this.blockMaps={cityCentreDistScoreMap:new _(r,n,8),crimeRateMap:new _(r,n,2),fireStationMap:new _(r,n,8),fireStationEffectMap:new _(r,n,8),landValueMap:new _(r,n,2),policeStationMap:new _(r,n,8),policeStationEffectMap:new _(r,n,8),pollutionDensityMap:new _(r,n,2),populationDensityMap:new _(r,n,2),rateOfGrowthMap:new _(r,n,8),terrainDensityMap:new _(r,n,4),trafficDensityMap:new _(r,n,2),tempMap1:new _(r,n,2),tempMap2:new _(r,n,2),tempMap3:new _(r,n,4)},this.clearCensus(),o?this.load(o):(this.budget.setFunds(2e4),this.census.totalPop=1),e.simData=this,this.init()}save(t){for(let i=0,s=e.savePropsVar.length;i1023&&(this.simCycle=0),this.doInitialEval&&(this.doInitialEval=!1,this.evaluation.cityEvaluation()),this.cityTime++,0==(1&this.simCycle)&&this.valves.setValves(this.gameLevel,this.census,this.budget),this.clearCensus();break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:this.mapScanner.mapScan((this.phaseCycle-1)*this.div,this.phaseCycle*this.div,null);break;case 9:this.cityTime%e.CENSUS_FREQUENCY_10==0&&this.census.take10Census(this.budget),this.cityTime%e.CENSUS_FREQUENCY_120==0&&this.census.take120Census(this.budget),this.cityTime%e.TAX_FREQUENCY==0&&(this.budget.collectTax(this.gameLevel,this.census),this.evaluation.cityEvaluation());break;case 10:this.simCycle%5==0&&ot.neutraliseRateOfGrowthMap(this.blockMaps),ot.neutraliseTrafficMap(this.blockMaps),this.sendMessages();break;case 11:this.simCycle%e.speedPowerScan[t]==0&&this.powerManager.doPowerScan(this.census);break;case 12:this.simCycle%e.speedPollutionTerrainLandValueScan[t]==0&&ot.pollutionTerrainLandValueScan(this.map,this.census,this.blockMaps);break;case 13:this.simCycle%e.speedCrimeScan[t]==0&&ot.crimeScan(this.census,this.blockMaps);break;case 14:this.simCycle%e.speedPopulationDensityScan[t]==0&&ot.populationDensityScan(this.map,this.blockMaps);break;case 15:this.simCycle%e.speedFireAnalysis[t]==0&&ot.fireAnalysis(this.blockMaps),this.disasterManager.doDisasters(this.census)}this.phaseCycle=this.phaseCycle+1&15}sendMessages(){this.checkGrowth();let t=this.census.resZonePop+this.census.comZonePop+this.census.indZonePop,e=this.census.nuclearPowerPop+this.census.coalPowerPop;switch(63&this.cityTime){case 1:Math.floor(t/4)>=this.census.resZonePop&&this.messageManager.sendMessage(R.NEED_MORE_RESIDENTIAL);break;case 5:Math.floor(t/8)>=this.census.comZonePop&&this.messageManager.sendMessage(R.NEED_MORE_COMMERCIAL);break;case 10:Math.floor(t/8)>=this.census.indZonePop&&this.messageManager.sendMessage(R.NEED_MORE_INDUSTRIAL);break;case 14:t>10&&2*t>this.census.roadTotal&&this.messageManager.sendMessage(R.NEED_MORE_ROADS);break;case 18:t>50&&t>this.census.railTotal&&this.messageManager.sendMessage(R.NEED_MORE_RAILS);break;case 22:t>10&&0==e&&this.messageManager.sendMessage(R.NEED_ELECTRICITY);break;case 26:this.census.resPop>500&&0===this.census.stadiumPop?(this.messageManager.sendMessage(R.NEED_STADIUM),this.valves.resCap=!0):this.valves.resCap=!1;break;case 28:this.census.indPop>70&&0===this.census.seaportPop?(this.messageManager.sendMessage(R.NEED_SEAPORT),this.valves.indCap=!0):this.valves.indCap=!1;break;case 30:this.census.comPop>100&&0===this.census.airportPop?(this.messageManager.sendMessage(R._NEED_AIRPORT),this.valves.comCap=!0):this.valves.comCap=!1;break;case 32:let i=this.census.unpoweredZoneCount+this.census.poweredZoneCount;i>0&&this.census.poweredZoneCount/i<.7&&this.messageManager.sendMessage(R.BLACKOUTS_REPORTED);break;case 35:this.census.pollutionAverage>60&&this.messageManager.sendMessage(R.HIGH_POLLUTION);break;case 42:this.census.crimeAverage>100&&this.messageManager.sendMessage(R.HIGH_CRIME);break;case 45:this.census.totalPop>60&&0===this.census.fireStationPop&&this.messageManager.sendMessage(R.NEED_FIRE_STATION);break;case 48:this.census.totalPop>60&&0===this.census.policeStationPop&&this.messageManager.sendMessage(R.NEED_POLICE_STATION);break;case 51:this.budget.cityTax>12&&this.messageManager.sendMessage(R.TAX_TOO_HIGH);break;case 54:this.budget.roadEffect30&&this.messageManager.sendMessage(R.ROAD_NEEDS_FUNDING);break;case 57:this.budget.fireEffect20&&this.messageManager.sendMessage(R.FIRE_STATION_NEEDS_FUNDING);break;case 60:this.budget.policeEffect20&&this.messageManager.sendMessage(R.POLICE_NEEDS_FUNDING);break;case 63:this.census.trafficAverage>60&&this.messageManager.sendMessage(R.TRAFFIC_JAMS,-1,-1,!0)}}checkGrowth(){if(0!=(3&this.cityTime))return;let t="",i=this.evaluation.getPopulation(this.census);if(i!==this.cityPopLast){let s=this.evaluation.getCityClass(this.cityPopLast),a=this.evaluation.getCityClass(i);if(s!==a)switch(a){case e.CC_VILLAGE:break;case e.CC_TOWN:t=R.REACHED_TOWN;break;case e.CC_CITY:t=R.REACHED_CITY;break;case e.CC_CAPITAL:t=R.REACHED_CAPITAL;break;case e.CC_METROPOLIS:t=R.REACHED_METROPOLIS;break;case e.CC_MEGALOPOLIS:t=R.REACHED_MEGALOPOLIS}}""!==t&&t!==this.messageLast&&(this.messageManager.sendMessage(t),this.messageLast=t),this.cityPopLast=i}setYear(t){t>2;t>=1e6?this.setYear(this.startingYear):this._cityYearLast===t&&this._cityMonthLast===e||(this._cityYearLast=t,this._cityMonthLast=e,this.messageManager.sendMessage(R.DATE_UPDATED,{month:e,year:t}))}}class nt{constructor(){this.clear()}clear(){this.data={}}toKey(t,e){return[t,e].join(",")}getTile(t,e){let i=this.toKey(t,e);return this.data[i]}setTile(t,e,i){let s=this.toKey(t,e);this.data[s]=i}}class ht{constructor(t,e,i){e=e||5,i=i||30,this._map=t,this.animationPeriod=e,this.blinkPeriod=i,this.shouldBlink=!1,this.count=1,this._lastPainted=null,this._data=[],this.initArray(),this.registerAnimations()}initArray(){for(let t=0;t=this._map.width||t<0||t>=this._map.height)continue;let e=this._map.getTile(a,t);if(!e.isAnimated())continue;let i,s=e.getValue(),d=n.TILE_INVALID;this._lastPainted&&(i=this._lastPainted.getTile(a,t)),r?i&&this.inSequence(s,i)?(d=this._data[i],i===n.LASTTINYEXP?(this._map.setTo(a,t,o.randomRubble()),d=this._map.getTileValue(a,t)):d=this._data[i]):d=this._data[s]:i&&this.inSequence(s,i)&&(d=i),d!==n.TILE_INVALID&&(l.push({x:a,y:t,tileValue:d}),h.setTile(a,t,d),this._map.setPaintValue(a,t,d))}return this._lastPainted=h,l}registerSingleAnimation(t){for(let e=1;e=n.TINYEXP&&e<=n.TINYEXPLAST&&(e-=825),this.tilesData[t]=e,this.layer[this.findLayer(i,s)]=1}resetLayer(){let t=64;for(;t--;)this.layer[t]=0}findLayer(t,e){return Math.floor(t/16)+8*Math.floor(e/16)}goodValue(t){return 0===t||t>1&&t<240}makePP(){let t,e=this.width,i=0,s=[];for(;e--;)for(t=this.height;t--;)s[i]=[e,t],i++;this.pp=s}powered(t){let e=t.id||this.getId(t.x,t.y);this.powerData[e]=t.v,this.powerChange=!0}save(t){let i,s=0;for(i=e.GameMapProps.length;s=0&&e>=0&&t=s||e>=a)return console.warn("getTile called with bad bounds",t,e),new r(n.TILE_INVALID);let o=this.getId(t,e),h=this.data[o];return i?(i.set(h),h):h}getTileValue(t,e){let i=new Error("Invalid parameter");if(arguments.length<1)throw i;if("object"==typeof t&&(e=t.y,t=t.x),!this.testBounds(t,e))throw i;let s=this.getId(t,e);return s in this.data||(this.data[s]=new r(this.defaultValue)),this.data[s].getValue()}getTileFlags(t,e){let i=new Error("Invalid parameter");if(arguments.length<1)throw i;if("object"==typeof t&&(e=t.y,t=t.x),!this.testBounds(t,e))throw i;let s=this.getId(t,e);return s in this.data||(this.data[s]=new r(this.defaultValue)),this.data[s].getFlags()}getTiles(t,e,i,s){let a=new Error("Invalid parameter");if(arguments.length<3)throw a;if(3===arguments.length&&(s=i,i=e,e=t.y,t=t.x),!this.testBounds(t,e))throw a;let o=[];for(let a=e,r=e+s;a=h||s>=r){a[(o-e)*i+(s-t)]=n.TILE_INVALID;continue}let l=s+o*r;a[(o-e)*i+(s-t)]=this.data[l].getRawValue()}return a}getTileFromMapOrDefault(t,e,i){switch(e){case P.NORTH:return t.y>0?this.getTileValue(t.x,t.y-1):i;case P.EAST:return t.x0?this.getTileValue(t.x-1,t.y):i;default:return i}}testOld(t,e){return this.data[t].getValue()!==e}setTile(t,e,i,s){3===arguments.length&&(s=i,i=e,e=t.y,t=t.x);let a=this.getId(t,e),o=this.testOld(a,i);this.data[a].set(i,s),o&&this.upLayer(a,i,t,e)}setTo(t,e,i){void 0===i&&(i=e,e=t.y,t=t.x);let s=this.getId(t,e),a=i.getValue(),o=this.testOld(s,a);this.data[s]=i,o&&this.upLayer(s,a,t,e)}setTileValue(t,e,i){2===arguments.length&&(i=e,e=t.y,t=t.x);let s=this.getId(t,e),a=this.testOld(s,i);this.data[s].setValue(i),a&&this.upLayer(s,i,t,e)}setPaintValue(t,e,i){2===arguments.length&&(i=e,e=t.y,t=t.x);let s=this.getId(t,e);this.upLayer(s,i,t,e)}setTileFlags(t,e,i){let s=new Error("Invalid flag parameter");if(arguments.length<2)throw s;if(2===arguments.length&&(i=e,e=t.y,t=t.x),!this.testBounds(t,e))throw s;let a=this.getId(t,e);this.data[a].setFlags(i)}addTileFlags(t,e,i){let s=new Error("Invalid flag parameter");if(arguments.length<2)throw s;if(2===arguments.length&&(i=e,e=t.y,t=t.x),!this.testBounds(t,e))throw s;let a=this.getId(t,e);this.data[a].addFlags(i)}removeTileFlags(t,e,i){if(arguments.length<2)throw new Error("GameMap removeTileFlags called with too few arguments");if(2===arguments.length&&(i=e,e=t.y,t=t.x),!this.testBounds(t,e))throw new Error("GameMap removeTileFlags called with invalid bounds"+t+", "+e);let s=this.getId(t,e);this.data[s].removeFlags(i)}putZone(t,e,i,s){if(!this.testBounds(t,e)||!this.testBounds(t-1+s,e-1+s))throw new Error("GameMap putZone called with invalid bounds");let a,o,h=i-1-s,l=t-1,d=e-1;for(o=d;oo.width-1&&(i=o.width-1),s=t-1,s<0&&(s=0),a=1,o.getTileValue(t,a)+o.getTileValue(i,a)+o.getTileValue(s,a)===6&&o.setTile(t,0,n.RIVER,0),a=o.height-2,o.getTileValue(t,a)+o.getTileValue(i,a)+o.getTileValue(s,a)===6&&o.setTile(t,o.height-1,n.RIVER,0);for(e=0;eo.height-1&&(i=o.height-1),s=e-1,s<0&&(s=0),a=1,o.getTileValue(a,e)+o.getTileValue(a,i)+o.getTileValue(a,s)===6&&o.setTile(0,e,n.RIVER,0),a=o.width-2,o.getTileValue(a,e)+o.getTileValue(a,i)+o.getTileValue(a,s)===6&&o.setTile(o.width-1,e,n.RIVER,0)}}clearMap(){let t=this.map;t.pp.forEach((e=>{t.setTile(e[0],e[1],n.DIRT,0)}))}clearUnnatural(){let t,e=this.map;e.pp.forEach((i=>{t=e.getTileValue(i[0],i[1]),t>n.WOODS&&e.setTile(i[0],i[1],n.DIRT,0)}))}makeNakedIsland(){let t,i,s,o,r=this.map,h=e.ISLAND_RADIUS;for(r.isIsland=!0,r.pp.forEach((e=>{t=e[0],i=e[1],t<5||t>=r.width-5||i<5||i>=r.height-5?r.setTile(t,i,n.RIVER,0):r.setTile(t,i,n.DIRT,0)})),t=0;t0;)t=a.getRandom(this.map.width-21)+10,i=a.getRandom(this.map.height-20)+10,this.makeSingleLake(new M(t,i)),s--}makeSingleLake(t){let e,i=a.getRandom(12)+2;for(;i>0;)e=new M(t,a.getRandom(12)-6,a.getRandom(12)-6),a.getRandom(4)?this.plopSRiver(e):this.plopBRiver(e),i--}treeSplash(t,i){let s,o=e.TERRAIN_TREE_LEVEL<0?a.getRandom(150)+50:a.getRandom(100+2*e.TERRAIN_TREE_LEVEL)+50,r=new M(t,i);for(;o>0;){if(s=P.NORTH+a.getRandom(7),r.move(s),!this.map.testBounds(r.x,r.y))return;this.map.getTileValue(r)===n.DIRT&&this.map.setTile(r,n.WOODS,n.BLBNBIT),o--}}doTrees(){let t=e.TERRAIN_TREE_LEVEL<0?a.getRandom(100)+50:e.TERRAIN_TREE_LEVEL+3;for(;t--;)this.treeSplash(a.getRandom(this.map.width-1),a.getRandom(this.map.height-1));this.smoothTrees(),this.smoothTrees()}smoothRiver(){let t,e,i,s,o,r,h,l,d=this.map,E=this.riverEdge,c=[-1,0,1,0],R=[0,1,0,-1];d.pp.forEach((u=>{if(t=u[0],e=u[1],d.getTileValue(t,e)===n.REDGE){for(h=0,i=0;i<4;i++)h<<=1,s=t+c[i],o=e+R[i],d.testBounds(s,o)&&(r=d.getTileValue(s,o),r!==n.DIRT&&(rn.WOODS_HIGH)&&h++);l=E[15&h],l!==n.RIVER&&a.getRandom(1)&&l++,d.setTile(t,e,l,n.BULLBIT)}}))}isTree(t){return t>=n.WOODS_LOW&&t<=n.WOODS_HIGH}smoothTrees(){let t,e,i=this.map;i.pp.forEach((s=>{t=s[0],e=s[1],this.isTree(i.getTileValue(t,e))&&this.smoothTreesAt(t,e,!1)}))}smoothTreesAt(t,e,i){let s=this.map,a=[-1,0,1,0],o=[0,1,0,-1];if(!this.isTree(this.map.getTileValue(t,e)))return;let r,h,l,d,E=0;for(r=0;r<4;r++)E<<=1,h=t+a[r],l=e+o[r],s.testBounds(h,l)&&this.isTree(s.getTileValue(h,l))&&E++;d=this.treeTable[15&E],d?(d!==n.WOODS&&t+e&1&&(d-=8),d>28&&d<38&&(d-=8),s.setTile(t,e,d,n.BLBNBIT)):i||(d>28&&d<38&&(d-=8),s.setTileValue(t,e,d,0))}doRivers(t){let e=P.NORTH+2*a.getRandom(3);this.doBRiver(t,e,e),e=P.rotate180(e);let i=this.doBRiver(t,e,e);e=P.NORTH+2*a.getRandom(3),this.doSRiver(t,e,i)}doBRiver(t,i,s){let o,r;e.TERRAIN_CURVE_LEVEL<0?(o=100,r=200):(o=e.TERRAIN_CURVE_LEVEL+10,r=e.TERRAIN_CURVE_LEVEL+100);let n=new M(t);for(;this.map.testBounds(n.x+4,n.y+4);)this.plopBRiver(n),a.getRandom(o+1)<10?s=i:(a.getRandom(r+1)>90&&(s=P.rotate45(s)),a.getRandom(r+1)>90&&(s=P.rotate45(s,7))),n.move(s);return s}doSRiver(t,i,s){let o,r;e.TERRAIN_CURVE_LEVEL<0?(o=100,r=200):(o=e.TERRAIN_CURVE_LEVEL+10,r=e.TERRAIN_CURVE_LEVEL+100);let n=new M(t);for(;this.map.testBounds(n.x+3,n.y+3);)this.plopSRiver(n),a.getRandom(o+1)<10?s=i:(a.getRandom(r+1)>90&&(s=P.rotate45(s)),a.getRandom(r+1)>90&&(s=P.rotate45(s,7))),n.move(s);return s}putOnMap(t,e,i){if(0===t)return;if(!this.map.testBounds(e,i))return;let s=this.map.getTileValue(e,i);if(s!==n.DIRT){if(s===n.RIVER&&t!==n.CHANNEL)return;if(s===n.CHANNEL)return}this.map.setTile(e,i,t,0)}plopBRiver(t){let e,i=9;for(;i--;)for(e=9;e--;)this.putOnMap(this.BRMatrix[e][i],t.x+i,t.y+e)}plopSRiver(t){let e,i=6;for(;i--;)for(e=6;e--;)this.putOnMap(this.SRMatrix[e][i],t.x+i,t.y+e)}smoothWater(){let t,e,i,s,a,o,r=this.map;r.pp.forEach((o=>{if(s=o[0],a=o[1],t=r.getTileValue(s,a),t>=n.WATER_LOW&&t<=n.WATER_HIGH)for(e=new M(s,a),i=P.BEGIN;in.WATER_HIGH){r.setTileValue(s,a,n.REDGE,0);break}})),r.pp.forEach((h=>{if(s=h[0],a=h[1],t=r.getTileValue(s,a),t!==n.CHANNEL&&t>=n.WATER_LOW&&t<=n.WATER_HIGH){for(o=!0,e=new M(s,a),i=P.BEGIN;in.WATER_HIGH){o=!1;break}o&&r.setTileValue(s,a,n.RIVER,0)}})),r.pp.forEach((o=>{if(s=o[0],a=o[1],t=r.getTileValue(s,a),t>=n.WOODS_LOW&&t<=n.WOODS_HIGH)for(e=new M(s,a),i=P.BEGIN;i=n.TINYEXP&&i<=n.LASTTINYEXP||i=n.ROADS&&s<=n.INTERSECTION?(e>0&&(s=this._worldEffects.getTile(t,e-1),s=o.normalizeRoad(s),(s===n.HRAILROAD||s>=n.ROADBASE&&s<=n.VROADPOWER)&&s!==n.HROADPOWER&&s!==n.VRAILROAD&&s!==n.ROADBASE&&(i|=1)),t=n.ROADBASE&&s<=n.VROADPOWER)&&s!==n.VROADPOWER&&s!==n.HRAILROAD&&s!==n.VBRIDGE&&(i|=2)),e=n.ROADBASE&&s<=n.VROADPOWER)&&s!==n.HROADPOWER&&s!==n.VRAILROAD&&s!==n.ROADBASE&&(i|=4)),t>0&&(s=this._worldEffects.getTile(t-1,e),s=o.normalizeRoad(s),(s===n.VRAILROAD||s>=n.ROADBASE&&s<=n.VROADPOWER)&&s!==n.VROADPOWER&&s!==n.HRAILROAD&&s!==n.VBRIDGE&&(i|=8)),void this._worldEffects.setTile(t,e,h[i]|n.BULLBIT|n.BURNBIT)):s>=n.LHRAIL&&s<=n.LVRAIL10?(e>0&&(s=this._worldEffects.getTile(t,e-1),s=o.normalizeRoad(s),s>=n.RAILHPOWERV&&s<=n.VRAILROAD&&s!==n.RAILHPOWERV&&s!==n.HRAILROAD&&s!==n.HRAIL&&(i|=1)),t=n.RAILHPOWERV&&s<=n.VRAILROAD&&s!==n.RAILVPOWERH&&s!==n.VRAILROAD&&s!==n.VRAIL&&(i|=2)),e=n.RAILHPOWERV&&s<=n.VRAILROAD&&s!==n.RAILHPOWERV&&s!==n.HRAILROAD&&s!==n.HRAIL&&(i|=4)),t>0&&(s=this._worldEffects.getTile(t-1,e),s=o.normalizeRoad(s),s>=n.RAILHPOWERV&&s<=n.VRAILROAD&&s!==n.RAILVPOWERH&&s!==n.VRAILROAD&&s!==n.VRAIL&&(i|=8)),void this._worldEffects.setTile(t,e,l[i]|n.BULLBIT|n.BURNBIT)):s>=n.LHPOWER&&s<=n.LVPOWER10?(e>0&&(s=this._worldEffects.getTile(t,e-1),s.isConductive()&&(s=s.getValue(),s=o.normalizeRoad(s),s!==n.VPOWER&&s!==n.VROADPOWER&&s!==n.RAILVPOWERH&&(i|=1))),t0&&(s=this._worldEffects.getTile(t-1,e),s.isConductive()&&(s=s.getValue(),s=o.normalizeRoad(s),s!==n.HPOWER&&s!==n.HROADPOWER&&s!==n.RAILHPOWERV&&(i|=8))),void this._worldEffects.setTile(t,e,d[i]|n.BLBNCNBIT)):void 0}checkZoneConnections(t,e){this.fixSingle(t,e),e>0&&this.fixSingle(t,e-1),t0&&this.fixSingle(t-1,e)}checkBorder(t,e,i){let s;for(t-=1,e-=1,s=0;sthis._map.width)return this.TOOLRESULT_FAILED;if(e<0||e+this.size>this._map.height)return this.TOOLRESULT_FAILED;let i,s,a;for(let r=0;r0){this.addCost(this.bulldozerCost),this._map.powered({v:1,x:t,y:e});let i=t+a,s=e+r;switch(E){case 3:this.putRubble(i-1,s-1,3);break;case 4:this.putRubble(i-1,s-1,4);break;case 6:this.putRubble(i-1,s-1,6)}this.result=this.TOOLRESULT_OK}d===n.RIVER||d===n.REDGE||d===n.CHANNEL?(h=this.layDoze(t,e),d!==this._worldEffects.getTileValue(t,e)&&this.addCost(5)):(h=this.layDoze(t,e),this.checkZoneConnections(t,e)),this.result=h}}class pt extends ct{constructor(t){super(),this.init(10,t,!0)}doTool(t,e,i){if(this._worldEffects.getTileValue(t,e)!==n.DIRT)return void(this.result=this.TOOLRESULT_NEEDS_BULLDOZE);let s,o=a.getRandom(4),r=n.BURNBIT|n.BULLBIT;4===o?(s=n.FOUNTAIN,r|=n.ANIMBIT):s=o+n.WOODS2,this._worldEffects.setTile(t,e,s,r),this.addCost(10),this.result=this.TOOLRESULT_OK}}class mt extends Rt{constructor(t){super(),this.init(20,t,!0,!0)}layRail(t,e){this.doAutoBulldoze(t,e);let i=this.toolCost,s=this._worldEffects.getTileValue(t,e);switch(s=o.normalizeRoad(s),s){case n.DIRT:this._worldEffects.setTile(t,e,n.LHRAIL|n.BULLBIT|n.BURNBIT);break;case n.RIVER:case n.REDGE:case n.CHANNEL:if(i=100,t=n.LHRAIL&&s<=n.HRAILROAD)){this._worldEffects.setTile(t,e,n.HRAIL,n.BULLBIT);break}if(t>0&&(s=this._worldEffects.getTileValue(t-1,e),s=o.normalizeRoad(s),s==n.RAILHPOWERV||s==n.HRAIL||s>n.VRAIL&&sn.HRAIL&&s0&&(s=this._worldEffects.getTileValue(t,e-1),s=o.normalizeRoad(s),s==n.RAILVPOWERH||s==n.VRAILROAD||s>n.HRAIL&&s=n.ROADS&&i<=n.HROADPOWER)){this._worldEffects.setTile(t,e,n.HBRIDGE,n.BULLBIT);break}if(t>0&&(i=this._worldEffects.getTileValue(t-1,e),i=o.normalizeRoad(i),i===n.VRAILROAD||i===n.HBRIDGE||i>=n.ROADS&&i<=n.INTERSECTION)){this._worldEffects.setTile(t,e,n.HBRIDGE,n.BULLBIT);break}if(e=n.VBRIDGE&&i<=n.INTERSECTION)){this._worldEffects.setTile(t,e,n.VBRIDGE,n.BULLBIT);break}if(e>0&&(i=this._worldEffects.getTileValue(t,e-1),i=o.normalizeRoad(i),i===n.HRAILROAD||i===n.VROADPOWER||i>=n.VBRIDGE&&i<=n.INTERSECTION)){this._worldEffects.setTile(t,e,n.VBRIDGE,n.BULLBIT);break}return this.TOOLRESULT_FAILED;case n.LHPOWER:this._worldEffects.setTile(t,e,n.VROADPOWER|n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.LVPOWER:this._worldEffects.setTile(t,e,n.HROADPOWER|n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.LHRAIL:this._worldEffects.setTile(t,e,n.HRAILROAD|n.BURNBIT|n.BULLBIT);break;case n.LVRAIL:this._worldEffects.setTile(t,e,n.VRAILROAD|n.BURNBIT|n.BULLBIT);break;default:return this.TOOLRESULT_FAILED}return this.addCost(s),this.checkZoneConnections(t,e),this.TOOLRESULT_OK}}class gt extends ct{constructor(t){super(),this.init(0,t,!1,!1),this.txt=""}classifyPopulationDensity(t,e,i){var s=i.populationDensityMap.worldGet(t,e);s>>=6,s&=3,this.txt+="Density: "+p.densityStrings[s]+"
"}classifyLandValue(t,e,i){var s=i.landValueMap.worldGet(t,e),a=0;s>=150?a=3:s>=80?a=2:s>=30&&(a=1),this.txt+="Value: "+p.landValueStrings[a]+"
"}classifyCrime(t,e,i){var s=i.crimeRateMap.worldGet(t,e);s>>=6,s&=3,this.txt+="Crime: "+p.crimeStrings[s]+"
"}classifyPollution(t,e,i){var s=i.pollutionDensityMap.worldGet(t,e);s>>=6,s&=3,this.txt+="Pollution: "+p.pollutionStrings[s]+"
"}classifyRateOfGrowth(t,e,i){var s=i.rateOfGrowthMap.worldGet(t,e);s>>=6,s&=3,this.txt+="Growth: "+p.rateStrings[s]}classifyDebug(t,e,i){}classifyZone(t,e){var i=[n.DIRT,n.RIVER,n.TREEBASE,n.RUBBLE,n.FLOOD,n.RADTILE,n.FIRE,n.ROADBASE,n.POWERBASE,n.RAILBASE,n.RESBASE,n.COMBASE,n.INDBASE,n.PORTBASE,n.AIRPORTBASE,n.COALBASE,n.FIRESTBASE,n.POLICESTBASE,n.STADIUMBASE,n.NUCLEARBASE,n.HBRDG0,n.RADAR0,n.FOUNTAIN,n.INDBASE2,n.FOOTBALLGAME1,n.VBRDG0,952],s=this._map.getTileValue(t,e);s>=n.COALSMOKE1&&s"}getInfo(){return this.txt}doTool(t,e,i,s){this._map.getTileValue(t,e),this._map.getTile(t,e),this.classifyZone(t,e),this.classifyPopulationDensity(t,e,i),this.classifyLandValue(t,e,i),this.classifyCrime(t,e,i),this.classifyPollution(t,e,i),this.classifyRateOfGrowth(t,e,i),this.classifyDebug(t,e,i),s.sendMessage(R.QUERY_WINDOW_NEEDED),this.result=this.TOOLRESULT_OK}}class ft extends Rt{constructor(t){super(),this.init(5,t,!0,!0)}layWire(t,e){this.doAutoBulldoze(t,e);let i=5,s=this._worldEffects.getTileValue(t,e);switch(s=o.normalizeRoad(s),s){case n.DIRT:this._worldEffects.setTile(t,e,n.LHPOWER,n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.RIVER:case n.REDGE:case n.CHANNEL:if(i=25,t0&&(s=this._worldEffects.getTile(t-1,e),s.isConductive()&&(s=s.getValue(),s=o.normalizeRoad(s),s!=n.HROADPOWER&&s!=n.RAILHPOWERV&&s!=n.HPOWER))){this._worldEffects.setTile(t,e,n.VPOWER,n.CONDBIT|n.BULLBIT);break}if(e0&&(s=this._worldEffects.getTile(t,e-1),s.isConductive()&&(s=s.getValue(),s=o.normalizeRoad(s),s!=n.VROADPOWER&&s!=n.RAILVPOWERH&&s!=n.VPOWER))){this._worldEffects.setTile(t,e,n.HPOWER,n.CONDBIT|n.BULLBIT);break}return this.TOOLRESULT_FAILED;case n.ROADS:this._worldEffects.setTile(t,e,n.HROADPOWER,n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.ROADS2:this._worldEffects.setTile(t,e,n.VROADPOWER,n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.LHRAIL:this._worldEffects.setTile(t,e,n.RAILHPOWERV,n.CONDBIT|n.BURNBIT|n.BULLBIT);break;case n.LVRAIL:this._worldEffects.setTile(t,e,n.RAILVPOWERH,n.CONDBIT|n.BURNBIT|n.BULLBIT);break;default:return this.TOOLRESULT_FAILED}return this.addCost(i),this.checkZoneConnections(t,e),this.TOOLRESULT_OK}doTool(t,e,i){this.result=this.layWire(t,e)}}const Ot=self.webkitPostMessage||self.postMessage;var St,It,Lt=!0;self.onmessage=function(t){Dt.message(t)};class Dt{static message(t){var e=t.data.tell;"INIT"==e&&(t.data.returnMessage&&(It=t.data.returnMessage,Lt=!1),St=new Pt(t.data.timestep)),"NEWMAP"==e&&St.newMap(),"PLAYMAP"==e&&St.playMap(),"TOOL"==e&&St.tool(t.data.name),"MAPCLICK"==e&&St.mapClick(t.data.x,t.data.y,t.data.single||!1),"DIFFICULTY"==e&&St.changeDifficulty(t.data.n),"SPEED"==e&&St.changeSpeed(t.data.n),"BUDGET"==e&&St.handleBudgetRequest(),"NEWBUDGET"==e&&St.setBudget(t.data.budgetData),"DISASTER"==e&&St.setDisaster(t.data.disaster),"EVAL"==e&&St.getEvaluation(),"SAVEGAME"==e&&St.saveGame(t.data.saveCity),"LOADGAME"==e&&St.loadGame(t.data.isStart),"MAKELOADGAME"==e&&St.makeLoadGame(t.data.savegame,t.data.isStart)}static post(t,e){Lt?Ot(t,e):It({data:t})}}var _t=function(){St.tick()};class Pt{constructor(t){this.timestep=t,this.mapSize=[128,128],this.difficulty=1,this.speed=2,this.oldSpeed=0,this.mapGen=new dt,this.simulation=null,this.gameTools=null,this.animationManager=null,this.map=null,this.isPaused=!1,this.simNeededBudget=!1,this.currentTool=null,this.timer=null,this.infos=[],this.sprites=[],this.spritesData=null,this.animsData=null,this.spritesData=[],this.power=null,Dt.post({tell:"READY"})}next(t=0){this.timer=setTimeout(_t,t)}stop(){null!==this.timer&&(clearInterval(this.timer),this.timer=null)}tick(){this.simulation.simTick()&&(this.infos=this.simulation.infos,this.processMessages(St.simulation.messageManager.getMessages()),this.animatedTiles(),this.simulation.spriteManager.moveObjects(),this.calculateSprites(),Dt.post({tell:"RUN",infos:this.infos,tilesData:this.map.tilesData,powerData:this.map.powerData,sprites:this.spritesData,layer:this.map.layer}),this.map.resetLayer()),this.next()}newMap(){this.map=this.mapGen.construct(this.mapSize[0],this.mapSize[1]),Dt.post({tell:"NEWMAP",tilesData:this.map.tilesData,mapSize:this.mapSize,island:this.map.isIsland,trans:false})}playMap(t){var e=new E,i=2e4;1==this.difficulty&&(i=1e4),2==this.difficulty&&(i=5e3),this.gameTools={airport:new ut(1e4,n.AIRPORT,this.map,6,!1),bulldozer:new Tt(this.map),coal:new ut(3e3,n.POWERPLANT,this.map,4,!1),commercial:new ut(100,n.COMCLR,this.map,3,!1),fire:new ut(500,n.FIRESTATION,this.map,3,!1),industrial:new ut(100,n.INDCLR,this.map,3,!1),nuclear:new ut(5e3,n.NUCLEAR,this.map,4,!0),park:new pt(this.map),police:new ut(500,n.POLICESTATION,this.map,3,!1),port:new ut(3e3,n.PORT,this.map,4,!1),rail:new mt(this.map),residential:new ut(100,n.FREEZ,this.map,3,!1),road:new At(this.map),query:new gt(this.map),stadium:new ut(5e3,n.STADIUM,this.map,4,!1),wire:new ft(this.map)},this.animationManager=new ht(this.map),t?(i=this.savedGame.totalFunds,this.speed=this.savedGame.speed,this.difficulty=this.savedGame.difficulty,this.simulation=new rt(this.map,this.difficulty,this.speed,!0,this.savedGame),e.sendMessage(R.WELCOMEBACK)):(this.simulation=new rt(this.map,this.difficulty,this.speed,!0),e.sendMessage(R.WELCOME)),this.simulation.budget.setFunds(i),this.processMessages(e.getMessages()),this.isPaused=!1,this.tick()}changeSpeed(t){this.speed=t,this.simulation.setSpeed(this.speed),0===this.speed?(this.isPaused=!0,this.stop()):this.isPaused&&(this.isPaused=!1,this.stop(),this.tick())}changeDifficulty(t){this.difficulty=t,this.simulation&&this.simulation.setDifficulty(this.difficulty)}animatedTiles(){var t=this.animationManager.getTiles(0,0,this.mapSize[0]+1,this.mapSize[1]+1,this.isPaused),i=t.length;for(this.animsData=new e.M_ARRAY_TYPE(i);i--;){var s=t[i];this.animsData[i]=[s.tileValue,s.x,s.y]}}calculateSprites(){this.sprites=this.simulation.spriteManager.getSpritesInView(0,0,this.mapSize[0]+1,this.mapSize[1]+1);for(var t=this.sprites.length;t--;){var e=this.sprites[t];this.spritesData[t]=[e.type,e.frame,e.x||0,e.y||0]}}processMessages(t){for(var e=!1,i=0,s=t.length;i"}let s=[t.cityYes,e];Dt.post({tell:"EVAL",evalData:s})}saveGame(t){let i={name:"Yoooooo",everClicked:!0};i.speed=this.speed,i.difficulty=this.difficulty,i.version=e.CURRENT_VERSION,i.city=t,this.simulation.save(i),i=JSON.stringify(i),Dt.post({tell:"SAVEGAME",gameData:i,key:e.KEY})}loadGame(t){var i=t||!1;Dt.post({tell:"LOADGAME",key:e.KEY,isStart:i})}makeLoadGame(t,i){let s=i||!1;clearInterval(this.timer),this.savedGame=JSON.parse(t),this.map=new lt(e.MAP_WIDTH,e.MAP_HEIGHT),this.map.load(this.savedGame),Dt.post({tell:"FULLREBUILD",tilesData:this.map.tilesData,mapSize:this.mapSize,island:this.map.isIsland,cityData:this.savedGame.city,isStart:s})}transitionOldSave(t){switch(t.version){case 1:t.everClicked=!1;case 2:t.pollutionMaxX=Math.floor(t.width/2),t.pollutionMaxY=Math.floor(t.height/2),t.cityCentreX=Math.floor(t.width/2),t.cityCentreY=Math.floor(t.height/2)}}}t.CityGame=Dt,t.MainGame=Pt,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/games/3dcity/build/citygame.module.js b/games/3dcity/build/citygame.module.js new file mode 100644 index 0000000..4f73f3f --- /dev/null +++ b/games/3dcity/build/citygame.module.js @@ -0,0 +1,8705 @@ +/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + + +const Micro = { + + haveMapAnimation: true, + + localStorage : null, + + GameMapProps : ['cityCentreX', 'cityCentreY', 'pollutionMaxX', 'pollutionMaxY', 'width', 'height'], + savePropsVar : ['cityTime'], + CensusProps : ['resPop', 'comPop', 'indPop', 'crimeRamp', 'pollutionRamp', 'landValueAverage', 'pollutionAverage', + 'crimeAverage', 'totalPop', 'resHist10', 'resHist120', 'comHist10', 'comHist120', 'indHist10', + 'indHist120', 'crimeHist10', 'crimeHist120', 'moneyHist10', 'moneyHist120', 'pollutionHist10', 'pollutionHist120' + ], + BudgetProps : ['autoBudget', 'totalFunds', 'policePercent', 'roadPercent', 'firePercent', 'roadSpend', + 'policeSpend', 'fireSpend', 'roadMaintenanceBudget', 'policeMaintenanceBudget', + 'fireMaintenanceBudget', 'cityTax', 'roadEffect', 'policeEffect', 'fireEffect' + ], + // eval + PROBLEMS : ['CVP_CRIME', 'CVP_POLLUTION', 'CVP_HOUSING', 'CVP_TAXES', 'CVP_TRAFFIC', 'CVP_UNEMPLOYMENT', 'CVP_FIRE'], + NUMPROBLEMS : 7,//this.PROBLEMS.length, + NUM_COMPLAINTS : 4, + problemData : [], + EvalProps : ['cityClass', 'cityScore'], + + speedPowerScan : [2, 4, 5, 6], + speedPollutionTerrainLandValueScan : [2, 7, 17, 30], + speedCrimeScan : [1, 8, 18, 32], + speedPopulationDensityScan : [1, 9, 19, 38], + speedFireAnalysis : [1, 10, 20, 40], + CENSUS_FREQUENCY_10 : 4, + CENSUS_FREQUENCY_120 : 4*10, + TAX_FREQUENCY : 48, + + MAP_WIDTH : 128, + MAP_HEIGHT : 128, + + MAP_DEFAULT_WIDTH : 128*3, //Micro.MAP_WIDTH*3, + MAP_DEFAULT_HEIGHT : 128*3, //Micro.MAP_HEIGHT*3, + MAP_BIG_DEFAULT_WIDTH : 128*16, //Micro.MAP_WIDTH*16, + MAP_BIG_DEFAULT_HEIGHT : 128*16, //Micro.MAP_HEIGHT*16, + MAP_BIG_DEFAULT_ID : "bigMap", + MAP_PARENT_ID : "splashContainer", + MAP_DEFAULT_ID : "SplashCanvas", + + //GameCanvas + DEFAULT_WIDTH : 400, + DEFAULT_HEIGHT : 400, + DEFAULT_ID : "MicropolisCanvas", + RCI_DEFAULT_ID : "RCICanvas", + + // Simulation + LEVEL_EASY : 0, + LEVEL_MED : 1, + LEVEL_HARD : 2, + + SPEED_PAUSED : 0, + SPEED_SLOW : 1, + SPEED_MED : 2, + SPEED_FAST : 3, + SPEED_ULTRA : 4, + + // Traffic + ROUTE_FOUND : 1, + NO_ROUTE_FOUND : 0, + NO_ROAD_FOUND : -1, + MAX_TRAFFIC_DISTANCE : 30, + perimX : [-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2], + perimY : [-2,-2,-2,-1, 0, 1, 2, 2, 2, 1, 0,-1], + + //SpriteConstants + SPRITE_TRAIN : 1, + SPRITE_HELICOPTER : 2, + SPRITE_AIRPLANE : 3, + SPRITE_SHIP : 4, + SPRITE_MONSTER : 5, + SPRITE_TORNADO : 6, + SPRITE_EXPLOSION : 7, + + // Evaluation + CC_VILLAGE : 'VILLAGE', + CC_TOWN : 'TOWN', + CC_CITY : 'CITY', + CC_CAPITAL : 'CAPITAL', + CC_METROPOLIS : 'METROPOLIS', + CC_MEGALOPOLIS : 'MEGALOPOLIS', + CRIME : 0, + POLLUTION : 1, + HOUSING : 2, + TAXES : 3, + TRAFFIC : 4, + UNEMPLOYMENT : 5, + FIRE : 6, + + // Valves + RES_VALVE_RANGE : 2000, + COM_VALVE_RANGE : 1500, + IND_VALVE_RANGE : 1500, + taxTable : [ 200, 150, 120, 100, 80, 50, 30, 0, -10, -40, -100, -150, -200, -250, -300, -350, -400, -450, -500, -550, -600], + extMarketParamTable : [1.2, 1.1, 0.98], + + // Budget + RLevels : [0.7, 0.9, 1.2], + FLevels : [1.4, 1.2, 0.8], + MAX_ROAD_EFFECT : 32, + MAX_POLICESTATION_EFFECT : 1000, + MAX_FIRESTATION_EFFECT : 1000, + + policeMaintenanceCost : 100, + fireMaintenanceCost : 100, + roadMaintenanceCost : 1, + railMaintenanceCost : 2, + + // PowerManager + COAL_POWER_STRENGTH : 700, + NUCLEAR_POWER_STRENGTH : 2000, + + //DisasterWindow + DISASTER_NONE:'None', + DISASTER_MONSTER:'Monster', + DISASTER_FIRE:'Fire', + DISASTER_FLOOD:'Flood', + DISASTER_CRASH:'Crash', + DISASTER_MELTDOWN:'Meltdown', + DISASTER_TORNADO:'Tornado', + + // storage + CURRENT_VERSION : 3, + KEY : 'micropolisJSGame', + + // disasters + DisChance: [479, 239, 59], + + // map generator + TERRAIN_CREATE_ISLAND : 0, + TERRAIN_TREE_LEVEL : -1,//level for tree creation + TERRAIN_LAKE_LEVEL : -1, //level for river curviness; -1==auto, 0==none, >0==level + TERRAIN_CURVE_LEVEL : -1,//level for lake creation; -1==auto, 0==none, >0==level + ISLAND_RADIUS : 18, + + + M_ARRAY_TYPE: ( typeof Float32Array !== 'undefined' ) ? Float32Array : Array, + + // census + arrs: ['res', 'com', 'ind', 'crime', 'money', 'pollution'], + + directionTable : [0, 3, 2, 1, 3, 4, 5, 7, 6, 5, 7, 8, 1], + + SMOOTH_NEIGHBOURS_THEN_BLOCK: 0, + SMOOTH_ALL_THEN_CLAMP : 1, + + simData:null, + messageManager:null, + +}; + +class EventEmitter { + + static emitEvent ( event, value ) { + + // ??? + Micro.messageManager.sendMessage( event, value ); + + } + +} +//var M_ARRAY_TYPE; +//if(!M_ARRAY_TYPE) { M_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; } + + +class MiscUtils { + + /**/ + + //static makeConstantDescriptor = function(value) { + static mcd (value) { + return {configurable: false, enumerable: false, writeable: false, value: value}; + } + + static rotate10Arrays () { + for (var i = 0; i < Micro.arrs.length; i++) { + var name10 = Micro.arrs[i] + 'Hist10'; + //this[name10] = [0].concat(this[name10].slice(0, -1)); + this[name10].pop(); + this[name10].unshift(0); + } + } + + static rotate120Arrays () { + for (var i = 0; i < Micro.arrs.length; i++) { + var name120 = Micro.arrs[i] + 'Hist120'; + //this[name120] = [0].concat(this[name120].slice(0, -1)); + this[name120].pop(); + this[name120].unshift(0); + } + } + + static isCallable ( f ) { + return typeof(f) === 'function'; + } + + static copyFrom (data, sourceMap, sourceFn) { + var mapFn = function(elem) { return sourceFn(elem); }; + var i = sourceMap.data.length; + while(i--) data[i] = sourceMap.data[i].map(mapFn); + } + + static makeArrayOf (length, value) { + //var result = []; + //var result = new M_ARRAY_TYPE(length); + var result = new Array(length); + //for (var a = 0; a < length; a++) result[a] = value; + var i = length; while(i--) result[i] = value; + return result; + + } + + +} + +class math { + + static lerp ( x, y, t ) { return ( 1 - t ) * x + t * y; } + static rand ( low, high ) { return low + Math.random() * ( high - low ); } + static randInt ( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + static clamp (value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + } + + static getChance (chance) { + return (math.getRandom16() & chance) === 0; + } + + static getERandom ( max ) { + var r1 = math.getRandom(max); + var r2 = math.getRandom(max); + return Math.min(r1, r2); + } + + static getRandom ( max ) { + return Math.floor(Math.random() * (max + 1)); + } + + static getRandom16 () { + return math.getRandom(65535); + } + + static getRandom16Signed () { + var value = math.getRandom16(); + if (value < 32768) return value; + else return -(2 ** 16) + value; + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +class ZoneUtils { + + // TileUtils + + static pixToWorld (p) { + return p >> 4; + } + + static worldToPix (w) { + return w << 4; + } + + static unwrapTile ( tile ) { + + if ( tile.isTile ) return tile = tile.getValue(); + return tile + } + + static canBulldoze (tile) { + + tile = ZoneUtils.unwrapTile( tile ); + return (tile >= Tile.FIRSTRIVEDGE && tile <= Tile.LASTRUBBLE) || + (tile >= Tile.POWERBASE + 2 && tile <= Tile.POWERBASE + 12) || + (tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP + 2); + } + + static isCommercial (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.COMBASE && tile < Tile.INDBASE; + } + + static isIndustrial (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.INDBASE && tile < Tile.PORTBASE; + } + + static isResidential (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.RESBASE && tile < Tile.HOSPITALBASE; + } + + static isDriveable (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return (tile >= Tile.ROADBASE && tile <= Tile.LASTRAIL) || tile === Tile.RAILHPOWERV || tile === Tile.RAILVPOWERH; + } + + static isFire (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.FIREBASE && tile < Tile.ROADBASE; + } + + static isFlood (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.FLOOD && tile < Tile.LASTFLOOD; + } + + static isManualExplosion (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP; + } + + static isRail (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.RAILBASE && tile < Tile.RESBASE; + } + + static isRoad (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return tile >= Tile.ROADBASE && tile < Tile.POWERBASE; + } + + static normalizeRoad (tile) { + tile = ZoneUtils.unwrapTile( tile ); + return (tile >= Tile.ROADBASE && tile <= Tile.LASTROAD + 1) ? (tile & 15) + 64 : tile; + } + + /// + + static isCommercialZone (tile) { + return tile.isZone() && ZoneUtils.isCommercial(tile) + } + + static isIndustrialZone (tile) { + return tile.isZone() && ZoneUtils.isIndustrial(tile) + } + + static isResidentialZone (tile) { + return tile.isZone() && ZoneUtils.isResidential(tile) + } + + static randomFire (tile) { + return new Tiles(Tile.FIRE + (math.getRandom16() & 3), Tile.ANIMBIT); + } + + static randomRubble ( tile ) { + return new Tiles(Tile.RUBBLE + (math.getRandom16() & 3), Tile.BULLBIT); + } + + static HOSPITAL (tile) { + } + + // ZoneUtils + + static checkBigZone = function(tile) { + + let result; + switch (tile) { + case Tile.POWERPLANT: + case Tile.PORT: + case Tile.NUCLEAR: + case Tile.STADIUM: + result = {zoneSize: 4, deltaX: 0, deltaY: 0}; + break; + + case Tile.POWERPLANT + 1: + case Tile.COALSMOKE3: + case Tile.COALSMOKE3 + 1: + case Tile.COALSMOKE3 + 2: + case Tile.PORT + 1: + case Tile.NUCLEAR + 1: + case Tile.STADIUM + 1: + result = {zoneSize: 4, deltaX: -1, deltaY: 0}; + break; + + case Tile.POWERPLANT + 4: + case Tile.PORT + 4: + case Tile.NUCLEAR + 4: + case Tile.STADIUM + 4: + result = {zoneSize: 4, deltaX: 0, deltaY: -1}; + break; + + case Tile.POWERPLANT + 5: + case Tile.PORT + 5: + case Tile.NUCLEAR + 5: + case Tile.STADIUM + 5: + result = {zoneSize: 4, deltaX: -1, deltaY: -1}; + break; + case Tile.AIRPORT: result = {zoneSize: 6, deltaX: 0, deltaY: 0}; break; + case Tile.AIRPORT + 1: result = {zoneSize: 6, deltaX: -1, deltaY: 0}; break; + case Tile.AIRPORT + 2: result = {zoneSize: 6, deltaX: -2, deltaY: 0}; break; + case Tile.AIRPORT + 3: result = {zoneSize: 6, deltaX: -3, deltaY: 0}; break; + case Tile.AIRPORT + 6: result = {zoneSize: 6, deltaX: 0, deltaY: -1}; break; + case Tile.AIRPORT + 7: result = {zoneSize: 6, deltaX: -1, deltaY: -1}; break; + case Tile.AIRPORT + 8: result = {zoneSize: 6, deltaX: -2, deltaY: -1}; break; + case Tile.AIRPORT + 9: result = {zoneSize: 6, deltaX: -3, deltaY: -1}; break; + case Tile.AIRPORT + 12: result = {zoneSize: 6, deltaX: 0, deltaY: -2}; break; + case Tile.AIRPORT + 13: result = {zoneSize: 6, deltaX: -1, deltaY: -2}; break; + case Tile.AIRPORT + 14: result = {zoneSize: 6, deltaX: -2, deltaY: -2}; break; + case Tile.AIRPORT + 15: result = {zoneSize: 6, deltaX: -3, deltaY: -2}; break; + case Tile.AIRPORT + 18: result = {zoneSize: 6, deltaX: 0, deltaY: -3}; break; + case Tile.AIRPORT + 19: result = {zoneSize: 6, deltaX: -1, deltaY: -3}; break; + case Tile.AIRPORT + 20: result = {zoneSize: 6, deltaX: -2, deltaY: -3}; break; + case Tile.AIRPORT + 21: result = {zoneSize: 6, deltaX: -3, deltaY: -3}; break; + default: result = {zoneSize: 0, deltaX: 0, deltaY: 0}; break; + } + return result; + } + + + static checkZoneSize (tile) { + if ((tile >= Tile.RESBASE - 1 && tile <= Tile.PORTBASE - 1) || + (tile >= Tile.LASTPOWERPLANT + 1 && tile <= Tile.POLICESTATION + 4) || + (tile >= Tile.CHURCH1BASE && tile <= Tile.CHURCH7LAST)) { + return 3; + } + + if ((tile >= Tile.PORTBASE && tile <= Tile.LASTPORT) || + (tile >= Tile.COALBASE && tile <= Tile.LASTPOWERPLANT) || + (tile >= Tile.STADIUMBASE && tile <= Tile.LASTZONE)) { + return 4; + } + return 0; + } + + static fireZone ( map, x, y, blockMaps ) { + + let tileValue = map.getTileValue(x, y); + let zoneSize = 2; + + // A zone being on fire naturally hurts growth + let value = blockMaps.rateOfGrowthMap.worldGet(x, y); + value = math.clamp(value - 20, -200, 200); + blockMaps.rateOfGrowthMap.worldSet(x, y, value); + + if (tileValue === Tile.AIRPORT) zoneSize = 5; + else if (tileValue >= Tile.PORTBASE) zoneSize = 3; + else if (tileValue < Tile.PORTBASE) zoneSize = 2; + + // Make remaining tiles of the zone bulldozable + let xDelta, yDelta, xTem, yTem; + for ( xDelta = -1; xDelta < zoneSize; xDelta++) { + for ( yDelta = -1; yDelta < zoneSize; yDelta++) { + xTem = x + xDelta; + yTem = y + yDelta; + if (!map.testBounds(xTem, yTem)) continue; + if (map.getTileValue(xTem, yTem >= Tile.ROADBASE)) map.addTileFlags(xTem, yTem, Tile.BULLBIT); + } + } + + } + + static getLandPollutionValue ( blockMaps, x, y ) { + + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 30) return 0; + if (landValue < 80) return 1; + if (landValue < 150) return 2; + return 3; + + } + + static incRateOfGrowth ( blockMaps, x, y, growthDelta ) { + + let currentRate = blockMaps.rateOfGrowthMap.worldGet(x, y); + // TODO why the scale of 4 here + let newValue = math.clamp( currentRate + growthDelta * 4, -200, 200 ); + blockMaps.rateOfGrowthMap.worldSet(x, y, newValue); + + } + + // Calls map.putZone after first checking for flood, fire and radiation + static putZone ( map, x, y, centreTile, isPowered ) { + + let dY, dX, tileValue; + for ( dY = -1; dY < 2; dY++) { + for ( dX = -1; dX < 2; dX++) { + tileValue = map.getTileValue(x + dX, y + dY); + if (tileValue >= Tile.FLOOD && tileValue < Tile.ROADBASE) return; + } + } + map.putZone(x, y, centreTile, 3); + map.addTileFlags(x, y, Tile.BULLBIT); + if (isPowered) map.addTileFlags(x, y, Tile.POWERBIT); + + } + +} + +//export const ZoneUtils = ZoneUtils + +class Tiles { + + constructor ( tileValue = Tile.DIRT, bitMask ) { + + this.isTile = true; + + /* + if (!(this.isTile)) return new Tiles(); + if (arguments.length > 0 && typeof(tileValue) !== 'number') throw new Error('Tile constructor called with invalid tileValue ' + tileValue); + if (arguments.length > 1 && typeof(bitMask) !== 'number') throw new Error('Tile constructor called with invalid bitMask ' + bitMask); + if (arguments.length > 1 && (tileValue < Tile.TILE_INVALID || tileValue >= Tile.TILE_COUNT)) throw new Error('Tile constructor called with out-of-range tileValue ' + tileValue); + if (arguments.length > 1 && (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1))) throw new Error('Tile constructor called with out-of-range bitmask ' + bitMask); + */ + + this._value = tileValue; + if (arguments.length > 1) this._value |= bitMask; + + } + + getValue () { + return this._value & Tile.BIT_MASK; + } + + setValue ( tileValue ) { + if ( arguments.length === 0 || typeof(tileValue) !== 'number' || tileValue < 0) throw new Error('Invalid parameter'); + + let existingFlags = 0; + if ( tileValue < Tile.BIT_START ) existingFlags = this._value & Tile.ALLBITS;//this.getFlags(); + this._value = tileValue | existingFlags; + } + + isBulldozable () { + return (this._value & Tile.BULLBIT) > 0; + } + + isAnimated () { + return (this._value & Tile.ANIMBIT) > 0; + } + + isConductive () { + return (this._value & Tile.CONDBIT) > 0; + } + + isCombustible () { + return (this._value & Tile.BURNBIT) > 0; + } + + isPowered () { + return (this._value & Tile.POWERBIT) > 0; + } + + isZone () { + return (this._value & Tile.ZONEBIT) > 0; + } + + addFlags (bitMask) { + if (!arguments.length || typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value |= bitMask; + } + + removeFlags (bitMask) { + if (!arguments.length || typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value &= ~bitMask; + } + + setFlags (bitMask) { + //if (typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Invalid parameter'); + //if (arguments.length === 0) throw new Error('Tile setFlags called with no arguments'); + //if (typeof(bitMask) !== 'number') throw new Error('Tile setFlags called with invalid bitmask ' + bitMask); + // if (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Tile setFlags called with out-of-range bitmask ' + bitMask); + let existingValue = this._value & ~Tile.ALLBITS; + this._value = existingValue | bitMask; + } + + getFlags () { + return this._value & Tile.ALLBITS; + } + + getRawValue () { + return this._value; + } + + set ( tileValue, bitMask ) { + if (arguments.length < 2 || typeof(tileValue) !== 'number' || typeof(bitMask) !== 'number' || tileValue >= Tile.TILE_COUNT) throw new Error('Invalid parameter'); + this.setValue(tileValue); + this.setFlags(bitMask); + } + + toString () { + let value = this.getValue(); + let s = 'Tile# ' + value; + s += this.isCombustible() ? ' burning' : ''; + s += this.isPowered() ? ' powered' : ''; + s += this.isAnimated() ? ' animated' : ''; + s += this.isConductive() ? ' conductive' : ''; + s += this.isZone() ? ' zone' : ''; + s += this.isBulldozable() ? ' bulldozeable' : ''; + return s; + } + +} + + + +const Tile = { + + // Bit-masks for statusBits + POWERBIT : 0x8000, // bit 15, tile has power. + CONDBIT : 0x4000, // bit 14. tile can conduct electricity. + BURNBIT : 0x2000, // bit 13, tile can be lit. + BULLBIT : 0x1000, // bit 12, tile is bulldozable. + ANIMBIT : 0x0800, // bit 11, tile is animated. + ZONEBIT : 0x0400, // bit 10, tile is the center tile of the zone. + BLBNBIT : 0x1000 | 0x2000, //BULLBIT | BURNBIT, + BLBNCNBIT : 0x1000 | 0x2000 | 0x4000, //BULLBIT | BURNBIT | CONDBIT, + BNCNBIT : 0x2000 | 0x4000, //BURNBIT | CONDBIT, + ASCBIT : 0x0800 | 0x4000 | 0x2000, // ANIMBIT | CONDBIT | BURNBIT, + ALLBITS : 0x8000 | 0x4000 | 0x2000 | 0x1000 | 0x0800 | 0x0400, // POWERBIT | CONDBIT | BURNBIT | BULLBIT | ANIMBIT | ZONEBIT, + BIT_START : 0x400, + BIT_END : 0x8000, + BIT_MASK : 0x400 - 1, // BIT_START - 1, + + // TODO Add comment for each tile + DIRT : 0, // Clear tile + // tile 1 ? + + /* Water */ + RIVER : 2, + REDGE : 3, + CHANNEL : 4, + FIRSTRIVEDGE : 5, + // tile 6 -- 19 ? + LASTRIVEDGE : 20, + WATER_LOW : 2, //RIVER, // First water tile + WATER_HIGH : 20, //LASTRIVEDGE, // Last water tile (inclusive) + + TREEBASE : 21, + WOODS_LOW : 21, //TREEBASE, + LASTTREE : 36, + WOODS : 37, + UNUSED_TRASH1 : 38, + UNUSED_TRASH2 : 39, + WOODS_HIGH : 39, //UNUSED_TRASH2, // Why is an 'UNUSED' tile used? + WOODS2 : 40, + WOODS3 : 41, + WOODS4 : 42, + WOODS5 : 43, + + // Rubble (4 tiles) + RUBBLE : 44, + LASTRUBBLE : 47, + // fLOOD 4 tiles + FLOOD : 48, + LASTFLOOD : 51, + // Radiation + RADTILE : 52, // Radio-active contaminated tile + + UNUSED_TRASH3 : 53, + UNUSED_TRASH4 : 54, + UNUSED_TRASH5 : 55, + + /* Fire animation (8 tiles) */ + FIRE : 56-8, + FIREBASE : 56-8, //FIRE, + LASTFIRE : 63-8, + + HBRIDGE : 64, // Horizontal bridge + ROADBASE : 64, // HBRIDGE, + VBRIDGE : 65, // Vertical bridge + ROADS : 66, + ROADS2 : 67, + ROADS3 : 68, + ROADS4 : 69, + ROADS5 : 70, + ROADS6 : 71, + ROADS7 : 72, + ROADS8 : 73, + ROADS9 : 74, + ROADS10 : 75, + INTERSECTION : 76, + HROADPOWER : 77, + VROADPOWER : 78, + BRWH : 79, + LTRFBASE : 80, // First tile with low traffic + // tile 81 -- 94 ? + BRWV : 95, + // tile 96 -- 110 ? + BRWXXX1 : 111, + // tile 96 -- 110 ? + BRWXXX2 : 127, + // tile 96 -- 110 ? + BRWXXX3 : 143, + HTRFBASE : 144, // First tile with high traffic + // tile 145 -- 158 ? + BRWXXX4 : 159, + // tile 160 -- 174 ? + BRWXXX5 : 175, + // tile 176 -- 190 ? + BRWXXX6 : 191, + // tile 192 -- 205 ? + LASTROAD : 206, + BRWXXX7 : 207, + + /* Power lines */ + HPOWER : 208, + VPOWER : 209, + LHPOWER : 210, + LVPOWER : 211, + LVPOWER2 : 212, + LVPOWER3 : 213, + LVPOWER4 : 214, + LVPOWER5 : 215, + LVPOWER6 : 216, + LVPOWER7 : 217, + LVPOWER8 : 218, + LVPOWER9 : 219, + LVPOWER10 : 220, + RAILHPOWERV : 221, // Horizontal rail, vertical power + RAILVPOWERH : 222, // Vertical rail, horizontal power + POWERBASE : 208, //HPOWER, + LASTPOWER : 222, //RAILVPOWERH, + + UNUSED_TRASH6 : 223, + + /* Rail */ + HRAIL : 224, + VRAIL : 225, + LHRAIL : 226, + LVRAIL : 227, + LVRAIL2 : 228, + LVRAIL3 : 229, + LVRAIL4 : 230, + LVRAIL5 : 231, + LVRAIL6 : 232, + LVRAIL7 : 233, + LVRAIL8 : 234, + LVRAIL9 : 235, + LVRAIL10 : 236, + HRAILROAD : 237, + VRAILROAD : 238, + RAILBASE : 224, //HRAIL, + LASTRAIL : 238, + + ROADVPOWERH : 239, /* bogus? */ + + // Residential zone tiles + + RESBASE : 240, // Empty residential, tiles 240--248 + FREEZ : 244, // center-tile of 3x3 empty residential + + HOUSE : 249, // Single tile houses until 260 + LHTHR : 249,//HOUSE, + HHTHR : 260, + + RZB : 265, // center tile first 3x3 tile residential + + HOSPITALBASE : 405, // Center of hospital (tiles 405--413) + HOSPITAL : 409, // Center of hospital (tiles 405--413) + + CHURCHBASE : 414, // Center of church (tiles 414--422) + CHURCH0BASE : 414, // numbered alias + CHURCH : 418, // Center of church (tiles 414--422) + CHURCH0 : 418, // numbered alias + + // Commercial zone tiles + + COMBASE : 423, // Empty commercial, tiles 423--431 + // tile 424 -- 426 ? + COMCLR : 427, + // tile 428 -- 435 ? + CZB : 436, + // tile 437 -- 608 ? + COMLAST : 609, + // tile 610, 611 ? + + // Industrial zone tiles. + INDBASE : 612, // Top-left tile of empty industrial zone. + INDCLR : 616, // Center tile of empty industrial zone. + LASTIND : 620, // Last tile of empty industrial zone. + + // Industrial zone population 0, value 0: 621 -- 629 + IND1 : 621, // Top-left tile of first non-empty industry zone. + IZB : 625, // Center tile of first non-empty industry zone. + + // Industrial zone population 1, value 0: 630 -- 638 + + // Industrial zone population 2, value 0: 639 -- 647 + IND2 : 641, + IND3 : 644, + + // Industrial zone population 3, value 0: 648 -- 656 + IND4 : 649, + IND5 : 650, + + // Industrial zone population 0, value 1: 657 -- 665 + + // Industrial zone population 1, value 1: 666 -- 674 + + // Industrial zone population 2, value 1: 675 -- 683 + IND6 : 676, + IND7 : 677, + + // Industrial zone population 3, value 1: 684 -- 692 + IND8 : 686, + IND9 : 689, + + // Seaport + PORTBASE : 693, // Top-left tile of the seaport. + PORT : 698, // Center tile of the seaport. + LASTPORT : 708, // Last tile of the seaport. + + AIRPORTBASE : 709, + // tile 710 ? + RADAR : 711, + // tile 712 -- 715 ? + AIRPORT : 716, + // tile 717 -- 744 ? + + // Coal power plant (4x4). + COALBASE : 745, // First tile of coal power plant. + POWERPLANT : 750, // 'Center' tile of coal power plant. + LASTPOWERPLANT : 760, // Last tile of coal power plant. + + // Fire station (3x3). + FIRESTBASE : 761, // First tile of fire station. + FIRESTATION : 765, // 'Center tile' of fire station. + // 769 last tile fire station. + + POLICESTBASE : 770, + // tile 771 -- 773 ? + POLICESTATION : 774, + // tile 775 -- 778 ? + + // Stadium (4x4). + STADIUMBASE : 779, // First tile stadium. + STADIUM : 784, // 'Center tile' stadium. + // Last tile stadium 794. + + // tile 785 -- 799 ? + FULLSTADIUM : 800, + // tile 801 -- 810 ? + + // Nuclear power plant (4x4). + NUCLEARBASE : 811, // First tile nuclear power plant. + NUCLEAR : 816, // 'Center' tile nuclear power plant. + LASTZONE : 826, // Also last tile nuclear power plant. + + LIGHTNINGBOLT : 827, + + // bridge horisontal open close + HBRDG0 : 828, + HBRDG1 : 829, + HBRDG2 : 830, + HBRDG3 : 831, + //HBRDG_END : 832, + + RADAR0 : 832, + RADAR1 : 833, + RADAR2 : 834, + RADAR3 : 835, + RADAR4 : 836, + RADAR5 : 837, + RADAR6 : 838, + RADAR7 : 839, + FOUNTAIN : 840, + // tile 841 -- 843: fountain animation. + INDBASE2 : 844, + TELEBASE : 844, + // tile 845 -- 850 ? + TELELAST : 851, + SMOKEBASE : 852, + // tile 853 -- 859 ? + TINYEXP : 860, + // tile 861 -- 863 ? + SOMETINYEXP : 864, + // tile 865 -- 866 ? + LASTTINYEXP : 867, + // tile 868 -- 882 ? + TINYEXPLAST : 883, + // tile 884 -- 915 ? + + COALSMOKE1 : 916, // Chimney animation at coal power plant (2, 0). + // 919 last animation tile for chimney at coal power plant (2, 0). + + COALSMOKE2 : 920, // Chimney animation at coal power plant (3, 0). + // 923 last animation tile for chimney at coal power plant (3, 0). + + COALSMOKE3 : 924, // Chimney animation at coal power plant (2, 1). + // 927 last animation tile for chimney at coal power plant (2, 1). + + COALSMOKE4 : 928, // Chimney animation at coal power plant (3, 1). + // 931 last animation tile for chimney at coal power plant (3, 1). + + FOOTBALLGAME1 : 932, + // tile 933 -- 939 ? + FOOTBALLGAME2 : 940, + // tile 941 -- 94 bridge open close + VBRDG0 : 948, + VBRDG1 : 949, + VBRDG2 : 950, + VBRDG3 : 951, + // nuclear animation // disable + NUKESWIRL1 : 952, + NUKESWIRL2 : 953, + NUKESWIRL3 : 954, + NUKESWIRL4 : 955, + + // Tiles 956-959 unused (originally) + // TILE_COUNT : 960, + + // Extended zones: 956-1019 + CHURCH1BASE : 956, + CHURCH1 : 960, + CHURCH2BASE : 965, + CHURCH2 : 969, + CHURCH3BASE : 974, + CHURCH3 : 978, + CHURCH4BASE : 983, + CHURCH4 : 987, + CHURCH5BASE : 992, + CHURCH5 : 996, + CHURCH6BASE : 1001, + CHURCH6 : 1005, + CHURCH7BASE : 1010, + CHURCH7 : 1014, + CHURCH7LAST : 1018, + + // Tiles 1020-1023 unused + TILE_COUNT : 1024, + TILE_INVALID : -1, // Invalid tile (not used in the world map). + MIN_SIZE : 16, // Minimum size of tile in pixels +}; + +const RoadTable = [ + Tile.ROADS, Tile.ROADS2, Tile.ROADS, Tile.ROADS3, + Tile.ROADS2, Tile.ROADS2, Tile.ROADS4, Tile.ROADS8, + Tile.ROADS, Tile.ROADS6, Tile.ROADS, Tile.ROADS7, + Tile.ROADS5, Tile.ROADS10, Tile.ROADS9, Tile.INTERSECTION +]; + +const RailTable = [ + Tile.LHRAIL, Tile.LVRAIL, Tile.LHRAIL, Tile.LVRAIL2, + Tile.LVRAIL, Tile.LVRAIL, Tile.LVRAIL3, Tile.LVRAIL7, + Tile.LHRAIL, Tile.LVRAIL5, Tile.LHRAIL, Tile.LVRAIL6, + Tile.LVRAIL4, Tile.LVRAIL9, Tile.LVRAIL8, Tile.LVRAIL10 +]; + +const WireTable = [ + Tile.LHPOWER, Tile.LVPOWER, Tile.LHPOWER, Tile.LVPOWER2, + Tile.LVPOWER, Tile.LVPOWER, Tile.LVPOWER3, Tile.LVPOWER7, + Tile.LHPOWER, Tile.LVPOWER5, Tile.LHPOWER, Tile.LVPOWER6, + Tile.LVPOWER4, Tile.LVPOWER9, Tile.LVPOWER8, Tile.LVPOWER10 +]; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + + +class MessageManager { + + constructor () { + this.data = []; + } + + sendMessage (message, data) { + this.data.push({message: message, data: data}); + } + + clear () { + this.data = []; + } + + getMessages () { + return this.data.slice(); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +var messageData = { + AUTOBUDGET_CHANGED: MiscUtils.mcd('Autobudget changed'), + BUDGET_NEEDED: MiscUtils.mcd('User needs to budget'), + BUDGET_REQUESTED: MiscUtils.mcd('Budget window requested'), + BUDGET_WINDOW_CLOSED: MiscUtils.mcd('Budget window closed'), + BLACKOUTS_REPORTED: MiscUtils.mcd('Blackouts reported'), + CLASSIFICATION_UPDATED: MiscUtils.mcd('Classification updated'), + CONGRATS_SHOWING: MiscUtils.mcd('Congratulations showing'), + CONGRATS_WINDOW_CLOSED: MiscUtils.mcd('Congratulations window closed'), + DATE_UPDATED: MiscUtils.mcd('Date changed'), + DEBUG_WINDOW_REQUESTED: MiscUtils.mcd('Debug Window Requested'), + DEBUG_WINDOW_CLOSED: MiscUtils.mcd('Debug Window Closed'), + DISASTER_REQUESTED: MiscUtils.mcd('Disaster Requested'), + DISASTER_WINDOW_CLOSED: MiscUtils.mcd('Disaster window closed'), + EARTHQUAKE: MiscUtils.mcd('Earthquake'), + EVAL_REQUESTED: MiscUtils.mcd('Evaluation Requested'), + EVAL_UPDATED: MiscUtils.mcd('Evaluation Updated'), + EVAL_WINDOW_CLOSED: MiscUtils.mcd('Eval window closed'), + EXPLOSION_REPORTED: MiscUtils.mcd('Explosion Reported'), + FIRE_REPORTED: MiscUtils.mcd('Fire!'), + FIRE_STATION_NEEDS_FUNDING: MiscUtils.mcd('Fire station needs funding'), + FLOODING_REPORTED: MiscUtils.mcd('Flooding reported'), + FRONT_END_MESSAGE: MiscUtils.mcd('Front-end Message'), + FUNDS_CHANGED: MiscUtils.mcd('Total funds has changed'), + HEAVY_TRAFFIC: MiscUtils.mcd('Heavy traffic in city'), + HELICOPTER_CRASHED: MiscUtils.mcd('Helicopter crashed'), + HIGH_CRIME: MiscUtils.mcd('High crime'), + HIGH_POLLUTION: MiscUtils.mcd('High pollution'), + MONSTER_SIGHTED: MiscUtils.mcd('Monster sighted'), + NAG_WINDOW_CLOSED: MiscUtils.mcd('Nag window closed'), + NEED_AIRPORT: MiscUtils.mcd('Airport needed'), + NEED_ELECTRICITY: MiscUtils.mcd('More power needed'), + NEED_FIRE_STATION: MiscUtils.mcd('Fire station needed'), + NEED_MORE_COMMERCIAL: MiscUtils.mcd('More commercial zones needed'), + NEED_MORE_INDUSTRIAL: MiscUtils.mcd('More industrial zones needed'), + NEED_MORE_RAILS: MiscUtils.mcd('More railways needed'), + NEED_MORE_RESIDENTIAL: MiscUtils.mcd('More residential needed'), + NEED_MORE_ROADS: MiscUtils.mcd('More roads needed'), + NEED_POLICE_STATION: MiscUtils.mcd('Police station needed'), + NEED_SEAPORT: MiscUtils.mcd('Seaport needed'), + NEED_STADIUM: MiscUtils.mcd('Stadium needed'), + NO_MONEY: MiscUtils.mcd('No money'), + NOT_ENOUGH_POWER: MiscUtils.mcd('Not enough power'), + NUCLEAR_MELTDOWN: MiscUtils.mcd('Nuclear Meltdown'), + PLANE_CRASHED: MiscUtils.mcd('Plane crashed'), + POLICE_NEEDS_FUNDING: MiscUtils.mcd('Police need funding'), + POPULATION_UPDATED: MiscUtils.mcd('Population updated'), + QUERY_WINDOW_CLOSED: MiscUtils.mcd('Query window closed'), + QUERY_WINDOW_NEEDED: MiscUtils.mcd('Query window needed'), + REACHED_CAPITAL: MiscUtils.mcd('Now a capital'), + REACHED_CITY: MiscUtils.mcd('Now a city'), + REACHED_METROPOLIS: MiscUtils.mcd('Now a metropolis'), + REACHED_MEGALOPOLIS: MiscUtils.mcd('Now a megalopolis'), + REACHED_TOWN: MiscUtils.mcd('Now a town'), + REACHED_VILLAGE: MiscUtils.mcd('Now a village'), + ROAD_NEEDS_FUNDING: MiscUtils.mcd('Roads need funding'), + SAVE_REQUESTED: MiscUtils.mcd('Save requested'), + SAVE_WINDOW_CLOSED: MiscUtils.mcd('Save window closed'), + SCORE_UPDATED: MiscUtils.mcd('Score updated'), + SCREENSHOT_LINK_CLOSED: MiscUtils.mcd('Screenshot link closed'), + SCREENSHOT_WINDOW_CLOSED: MiscUtils.mcd('Screenshot window closed'), + SCREENSHOT_WINDOW_REQUESTED: MiscUtils.mcd('Screenshot window requested'), + SETTINGS_WINDOW_CLOSED: MiscUtils.mcd('Settings window closed'), + SETTINGS_WINDOW_REQUESTED: MiscUtils.mcd('Settings window requested'), + SHIP_CRASHED: MiscUtils.mcd('Shipwrecked'), + SOUND_EXPLOSIONHIGH: MiscUtils.mcd('Explosion! Bang!'), + SOUND_EXPLOSIONLOW: MiscUtils.mcd('Explosion! Bang!'), + SOUND_HEAVY_TRAFFIC: MiscUtils.mcd('Heavy Traffic sound'), + SOUND_HONKHONK: MiscUtils.mcd('HonkHonk sound'), + SOUND_MONSTER: MiscUtils.mcd('Monster sound'), + SPEED_CHANGE: MiscUtils.mcd('Speed change'), + SPRITE_DYING: MiscUtils.mcd('Sprite dying'), + SPRITE_MOVED: MiscUtils.mcd('Sprite move'), + TAX_TOO_HIGH: MiscUtils.mcd('Tax too high'), + TOOL_CLICKED: MiscUtils.mcd('Tool clicked'), + TORNADO_SIGHTED: MiscUtils.mcd('Tornado sighted'), + TOUCH_WINDOW_CLOSED: MiscUtils.mcd('Touch Window closed'), + TRAFFIC_JAMS: MiscUtils.mcd('Traffic jams reported'), + TRAIN_CRASHED: MiscUtils.mcd('Train crashed'), + VALVES_UPDATED: MiscUtils.mcd('Valves updated'), + WELCOME: MiscUtils.mcd('Welcome to micropolisJS'), + WELCOMEBACK: MiscUtils.mcd('Welcome back to your 3D city') +}; + +const Messages = Object.defineProperties({}, messageData); +//var Messages = Object.defineProperties({}, messageData); + +var disasterMessages = [Messages.EARTHQUAKE, Messages.EXPLOSION_REPORTED, Messages.FIRE_REPORTED, + Messages.FLOODING_REPORTED, Messages.MONSTER_SIGHTED, Messages.NUCLEAR_MELTDOWN, + Messages.TORNADO_SIGHTED]; +Object.defineProperty(Messages, 'disasterMessages', MiscUtils.mcd(disasterMessages)); + +var crashes = [Messages.HELICOPTER_CRASHED, Messages.PLANE_CRASHED, Messages.SHIP_CRASHED, Messages.TRAIN_CRASHED]; +Object.defineProperty(Messages, 'crashes', MiscUtils.mcd(crashes)); + + +//export { Messages }; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const Text = function(){ + // TODO Some kind of rudimentary L20N based on navigator.language? + + // Query tool strings + var densityStrings = ['Low', 'Medium', 'High', 'Very High']; + var landValueStrings = ['Slum', 'Lower Class', 'Middle Class', 'High']; + var crimeStrings = ['Safe', 'Light', 'Moderate', 'Dangerous']; + var pollutionStrings = ['None', 'Moderate', 'Heavy', 'Very Heavy']; + var rateStrings = ['Declining', 'Stable', 'Slow Growth', 'Fast Growth']; + var zoneTypes = ['Clear', 'Water', 'Trees', 'Rubble', 'Flood', 'Radioactive Waste', + 'Fire', 'Road', 'Power', 'Rail', 'Residential', 'Commercial', + 'Industrial', 'Seaport', 'Airport', 'Coal Power', 'Fire Department', + 'Police Department', 'Stadium', 'Nuclear Power', 'Draw Bridge', + 'Radar Dish', 'Fountain', 'Industrial', 'Steelers 38 Bears 3', + 'Draw Bridge', 'Ur 238']; + + // Evaluation window + var gameLevel = {}; + gameLevel['' + Micro.LEVEL_EASY] = 'Easy'; + gameLevel['' + Micro.LEVEL_MED] = 'Medium'; + gameLevel['' + Micro.LEVEL_HARD] = 'Hard'; + + var cityClass = {}; + cityClass[Micro.CC_VILLAGE] = 'VILLAGE'; + cityClass[Micro.CC_TOWN] = 'TOWN'; + cityClass[Micro.CC_CITY] = 'CITY'; + cityClass[Micro.CC_CAPITAL] = 'CAPITAL'; + cityClass[Micro.CC_METROPOLIS] = 'METROPOLIS'; + cityClass[Micro.CC_MEGALOPOLIS] = 'MEGALOPOLIS'; + + var problems = {}; + problems[Micro.CRIME] = 'Crime'; + problems[Micro.POLLUTION] = 'Pollution'; + problems[Micro.HOUSING] = 'Housing'; + problems[Micro.TAXES] = 'Taxes'; + problems[Micro.TRAFFIC] = 'Traffic'; + problems[Micro.UNEMPLOYMENT] = 'Unemployment'; + problems[Micro.FIRE] = 'Fire'; + + // months + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + + // Tool strings + var toolMessages = { + noMoney: 'Insufficient funds to build that', + needsDoze: 'Area must be bulldozed first' + }; + + // Message strings + var neutralMessages = {}; + neutralMessages[Messages.FIRE_STATION_NEEDS_FUNDING] = 'Fire departments need funding'; + neutralMessages[Messages.NEED_AIRPORT] = 'Commerce requires an Airport'; + neutralMessages[Messages.NEED_FIRE_STATION] = 'Citizens demand a Fire Department'; + neutralMessages[Messages.NEED_ELECTRICITY] = 'Build a Power Plant'; + neutralMessages[Messages.NEED_MORE_INDUSTRIAL] = 'More industrial zones needed'; + neutralMessages[Messages.NEED_MORE_COMMERCIAL] = 'More commercial zones needed'; + neutralMessages[Messages.NEED_MORE_RESIDENTIAL] = 'More residential zones needed'; + neutralMessages[Messages.NEED_MORE_RAILS] = 'Inadequate rail system'; + neutralMessages[Messages.NEED_MORE_ROADS] = 'More roads required'; + neutralMessages[Messages.NEED_POLICE_STATION] = 'Citizens demand a Police Department'; + neutralMessages[Messages.NEED_SEAPORT] = 'Industry requires a Sea Port'; + neutralMessages[Messages.NEED_STADIUM] = 'Residents demand a Stadium'; + neutralMessages[Messages.ROAD_NEEDS_FUNDING] = 'Roads deteriorating, due to lack of funds'; + neutralMessages[Messages.POLICE_NEEDS_FUNDING] = 'Police departments need funding'; + neutralMessages[Messages.WELCOME] = 'Welcome to 3D City'; + neutralMessages[Messages.WELCOMEBACK] = 'Welcome to 3D City'; + + var badMessages = {}; + badMessages[Messages.BLACKOUTS_REPORTED] = 'Brownouts, build another Power Plant'; + badMessages[Messages.COPTER_CRASHED] = 'A helicopter crashed '; + badMessages[Messages.EARTHQUAKE] = 'Major earthquake reported !!'; + badMessages[Messages.EXPLOSION_REPORTED] = 'Explosion detected '; + badMessages[Messages.FLOODING_REPORTED] = 'Flooding reported !'; + badMessages[Messages.FIRE_REPORTED] = 'Fire reported '; + badMessages[Messages.HEAVY_TRAFFIC] = 'Heavy Traffic reported'; + badMessages[Messages.HIGH_CRIME] = 'Crime very high'; + badMessages[Messages.HIGH_POLLUTION] = 'Pollution very high'; + badMessages[Messages.MONSTER_SIGHTED] = 'A Monster has been sighted !'; + badMessages[Messages.NO_MONEY] = 'YOUR CITY HAS GONE BROKE'; + badMessages[Messages.NOT_ENOUGH_POWER] = 'Blackouts reported. insufficient power capacity'; + badMessages[Messages.NUCLEAR_MELTDOWN] = 'A Nuclear Meltdown has occurred !!'; + badMessages[Messages.PLANE_CRASHED] = 'A plane has crashed '; + badMessages[Messages.SHIP_CRASHED] = 'Shipwreck reported '; + badMessages[Messages.TAX_TOO_HIGH] = 'Citizens upset. The tax rate is too high'; + badMessages[Messages.TORNADO_SIGHTED] = 'Tornado reported !'; + badMessages[Messages.TRAFFIC_JAMS] = 'Frequent traffic jams reported'; + badMessages[Messages.TRAIN_CRASHED] = 'A train crashed '; + + var goodMessages = {}; + goodMessages[Messages.REACHED_CAPITAL] = 'Population has reached 50,000'; + goodMessages[Messages.REACHED_CITY] = 'Population has reached 10,000'; + goodMessages[Messages.REACHED_MEGALOPOLIS] = 'Population has reached 500,000'; + goodMessages[Messages.REACHED_METROPOLIS] = 'Population has reached 100,000'; + goodMessages[Messages.REACHED_TOWN] = 'Population has reached 2,000'; + + return { + badMessages: badMessages, + cityClass: cityClass, + crimeStrings: crimeStrings, + densityStrings: densityStrings, + gameLevel: gameLevel, + goodMessages: goodMessages, + landValueStrings: landValueStrings, + months: months, + neutralMessages: neutralMessages, + problems: problems, + pollutionStrings: pollutionStrings, + rateStrings: rateStrings, + toolMessages: toolMessages, + zoneTypes: zoneTypes + } + +}; + +const TXT = new Text(); + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +class SpriteUtils { + + static pixToWorld (p) { + return ZoneUtils.pixToWorld(p); + } + + static worldToPix (w) { + return ZoneUtils.worldToPix(w); + } + + // Attempt to move 45° towards the desired direction, either + // clockwise or anticlockwise, whichever gets us there quicker + static turnTo ( presentDir, desiredDir ) { + + if (presentDir === desiredDir) return presentDir; + + if (presentDir < desiredDir) { + // select clockwise or anticlockwise + if (desiredDir - presentDir < 4) presentDir++; + else presentDir--; + } else { + if (presentDir - desiredDir < 4) presentDir--; + else presentDir++; + } + if (presentDir > 8) presentDir = 1; + if (presentDir < 1) presentDir = 8; + return presentDir; + + } + + static absoluteValue ( x ) { + return Math.abs(x); + } + + static getTileValue ( map, x, y ) { + + let wX = ZoneUtils.pixToWorld(x); + let wY = ZoneUtils.pixToWorld(y); + if (wX < 0 || wX >= map.width || wY < 0 || wY >= map.height) return -1; + return map.getTileValue(wX, wY); + + } + + + // Choose the best direction to get from the origin to the destination + // If the destination is equidistant in both x and y deltas, a diagonal + // will be chosen, otherwise the most 'dominant' difference will be selected + // (so if a destination is 4 units north and 2 units east, north will be chosen). + // This code seems to always choose south if we're already there which seems like + // a bug + + static getDir ( orgX, orgY, destX, destY ) { + + let deltaX = destX - orgX; + let deltaY = destY - orgY; + let i; + + if (deltaX < 0) { + i = deltaY < 0 ? 11 : 8; + } else { + i = deltaY < 0 ? 2 : 5; + } + + deltaX = Math.abs(deltaX); + deltaY = Math.abs(deltaY); + + if (deltaX * 2 < deltaY) i++; + else if (deltaY * 2 < deltaX) i--; + if (i < 0 || i > 12) i = 0; + return Micro.directionTable[i]; + + } + + static absoluteDistance ( orgX, orgY, destX, destY ) { + + let deltaX = destX - orgX; + let deltaY = destY - orgY; + return Math.abs(deltaX) + Math.abs(deltaY); + + } + + static checkWet ( tileValue ) { + + if (tileValue === Tile.HPOWER || tileValue === Tile.VPOWER || tileValue === Tile.HRAIL || tileValue === Tile.VRAIL || tileValue === Tile.BRWH || tileValue === Tile.BRWV) return true; + else return false; + + } + + static destroyMapTile ( spriteManager, map, blockMaps, ox, oy ) { + + let x = ZoneUtils.pixToWorld(ox); + let y = ZoneUtils.pixToWorld(oy); + + if (!map.testBounds(x, y)) return; + + let tile = map.getTile(x, y); + let tileValue = tile.getValue(); + + if (tileValue < Tile.TREEBASE) return; + + if (!tile.isCombustible()) { + if (tileValue >= Tile.ROADBASE && tileValue <= Tile.LASTROAD) map.setTile(x, y, Tile.RIVER, 0); + return; + } + + if (tile.isZone()) { + ZoneUtils.fireZone( map, x, y, blockMaps ); + if (tileValue > Tile.RZB) spriteManager.makeExplosionAt(ox, oy); + } + if (SpriteUtils.checkWet(tileValue)) map.setTile(x, y, Tile.RIVER, 0); + else map.setTile(x, y, Tile.TINYEXP, Tile.BULLBIT | Tile.ANIMBIT); + + } + + static getDistance (x1, y1, x2, y2) { + return Math.abs(x1 - x2) + Math.abs(y1 - y2); + } + + static checkSpriteCollision (s1, s2) { + return s1.frame !== 0 && s2.frame !== 0 && SpriteUtils.getDistance(s1.x, s1.y, s2.x, s2.y) < 30; + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BaseSprite { + + constructor ( ) { + } + + init ( type, map, spriteManager, x, y ) { + + this.type = type; + this.map = map; + this.spriteManager = spriteManager; + this.x = x; + this.y = y; + this.origX = 0; + this.origY = 0; + this.destX = 0; + this.destY = 0; + this.count = 0; + this.soundCount = 0; + this.dir = 0; + this.newDir = 0; + this.step = 0; + this.flag = 0; + this.turn = 0; + this.accel = 0; + this.speed = 100; + } + + getFileName () { + return ['obj', this.type, '-', this.frame - 1].join(''); + } + + spriteNotInBounds () { + + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + return x < 0 || y < 0 || x >= this.map.width || y >= this.map.height; + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class TrainSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init(Micro.SPRITE_TRAIN, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 1; + this.dir = 4; + + this.tileDeltaX = [ 0, 16, 0, -16]; + this.tileDeltaY = [-16, 0, 16, 0 ]; + this.xDelta = [ 0, 4, 0, -4, 0]; + this.yDelta = [ -4, 0, 4, 0, 0]; + + this.TrainPic2 = [ 1, 2, 1, 2, 5]; + + // Frame values + this.NORTHSOUTH = 1; + this.EASTWEST = 2; + this.NWSE = 3; + this.NESW = 4; + this.UNDERWATER = 5; + + // Direction values + this.NORTH = 0; + this.EAST = 1; + this.SOUTH = 2; + this.WEST = 3; + this.CANTMOVE = 4; + + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + // Trains can only move in the 4 cardinal directions + // Over the course of 4 frames, we move through a tile, so + // ever fourth frame, we try to find a direction to move in + // (excluding the opposite direction from the current direction + // of travel). If there is no possible direction found, our direction + // is set to CANTMOVE. (Thus, if we're in a dead end, we can start heading + // backwards next time round). If we fail to find a destination after 2 attempts, + // we die. + + if (this.frame === this.NWSE || this.frame === this.NESW) this.frame = this.TrainPic2[this.dir]; + + this.x += this.xDelta[this.dir]; + this.y += this.yDelta[this.dir]; + + // Find a new direction. + if ((spriteCycle & 3) === 0) { + // Choose a random starting point for our search + let dir = math.getRandom16() & 3; + + for (let i = dir; i < dir + 4; i++) { + let dir2 = i & 3; + + if (this.dir !== this.CANTMOVE) { + // Avoid the opposite direction + if (dir2 === ((this.dir + 2) & 3)) continue; + } + + let tileValue = SpriteUtils.getTileValue(this.map, this.x + this.tileDeltaX[dir2], this.y + this.tileDeltaY[dir2]); + + if ((tileValue >= Tile.RAILBASE && tileValue <= Tile.LASTRAIL) || tileValue === Tile.RAILVPOWERH || tileValue === Tile.RAILHPOWERV) { + if (this.dir !== dir2 && this.dir !== this.CANTMOVE) { + + if (this.dir + dir2 === this.WEST) this.frame = this.NWSE; + else this.frame = this.NESW; + + } else { + this.frame = this.TrainPic2[dir2]; + } + + if (tileValue === Tile.HRAIL || tileValue === Tile.VRAIL) this.frame = this.UNDERWATER; + + this.dir = dir2; + return; + } + } + + // Nowhere to go. Die. + if (this.dir === this.CANTMOVE) { + this.frame = 0; + return; + } + + // We didn't find a direction this time. We'll try the opposite + // next time around + this.dir = this.CANTMOVE; + } + } + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.TRAIN_CRASHED); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BoatSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init( Micro.SPRITE_SHIP, map, spriteManager, x, y ); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x < SpriteUtils.worldToPix(4)) this.frame = 3; + else if (x >= SpriteUtils.worldToPix(map.width - 4)) this.frame = 7; + else if (y < SpriteUtils.worldToPix(4)) this.frame = 5; + else if (y >= SpriteUtils.worldToPix(map.height - 4)) this.frame = 1; + else this.frame = 3; + + this.newDir = this.frame; + this.dir = 10; + this.count = 1; + + this.tileDeltaX = [0, 0, 1, 1, 1, 0, -1, -1, -1]; + this.tileDeltaY = [0, -1, -1, 0, 1, 1, 1, 0, -1]; + this.xDelta = [0, 0, 2, 2, 2, 0, -2, -2, -2]; + this.yDelta = [0, -2, -2, 0, 2, 2, 2, 0, -2]; + this.tileWhiteList = [Tile.RIVER, Tile.CHANNEL, Tile.POWERBASE, Tile.POWERBASE + 1, Tile.RAILBASE, Tile.RAILBASE + 1, Tile.BRWH, Tile.BRWV]; + + this.CANTMOVE = 10; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + let t = Tile.RIVER; + + let startDir, frame, dir, x, y, tileValue; + + if (this.soundCount > 0) this.soundCount--; + + if (this.soundCount === 0) { + if ((math.getRandom16() & 3) === 1) { + // TODO Scenarios + // TODO Sound + messageManager.sendMessage(Messages.SOUND_HONKHONK); + } + + this.soundCount = 200; + } + + if (this.count > 0) this.count--; + + if (this.count === 0) { + + // Ships turn slowly: only 45° every 9 cycles + this.count = 9; + + // If already executing a turn, continue to do so + if (this.frame !== this.newDir) { + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + return; + } + + // Otherwise pick a new direction + // Choose a random starting direction to search from + // 0 = N, 1 = NE, ... 7 = NW + startDir = math.getRandom16() & 7; + frame = this.frame; + + for ( dir = startDir; dir < (startDir + 8); dir++) { + + frame = (dir & 7) + 1; + + if (frame === this.dir) continue; + + x = SpriteUtils.pixToWorld(this.x) + this.tileDeltaX[frame]; + y = SpriteUtils.pixToWorld(this.y) + this.tileDeltaY[frame]; + + if (this.map.testBounds(x, y)) { + tileValue = this.map.getTileValue(x, y); + + // Test for a suitable water tile + if (tileValue === Tile.CHANNEL || tileValue === Tile.BRWH || tileValue === Tile.BRWV || this.oppositeAndUnderwater(tileValue, this.dir, frame)) { + this.newDir = frame; + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + this.dir = frame + 4; + + if (this.dir > 8) this.dir -= 8; + break; + } + } + } + + if (dir === (startDir + 8)) { + this.dir = this.CANTMOVE; + this.newDir = (math.getRandom16() & 7) + 1; + } + } else { + frame = this.frame; + + if (frame === this.newDir) { + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + } + + if (this.spriteNotInBounds()) { + this.frame = 0; + return; + } + + // If we didn't find a new direction, we might explode + // depending on the last tile we looked at. + for (let i = 0; i < 8; i++) { + + if (t === this.tileWhiteList[i]) break; + if (i === 7) { + this.explodeSprite(messageManager); + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } + } + } + + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.SHIP_CRASHED); + } + + // This is an odd little function. It returns true if + // oldDir is 180° from newDir and tileValue is underwater + // rail or wire, and returns false otherwise + oppositeAndUnderwater (tileValue, oldDir, newDir) { + let opposite = oldDir + 4; + if (opposite > 8) opposite -= 8; + if (newDir != opposite) return false; + if (tileValue == Tile.POWERBASE || tileValue == Tile.POWERBASE + 1 || tileValue == Tile.RAILBASE || tileValue == Tile.RAILBASE + 1) return true; + return false; + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class MonsterSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init(Micro.SPRITE_MONSTER, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x > SpriteUtils.worldToPix(map.width) / 2) { + if (y > SpriteUtils.worldToPix(map.height) / 2) this.frame = 10; + else this.frame = 7; + } else if (y > SpriteUtils.worldToPix(map.height) / 2) { + this.frame = 1; + } else { + this.frame = 4; + } + + this.flag = 0; + this.count = 1000; + this.destX = SpriteUtils.worldToPix(map.pollutionMaxX); + this.destY = SpriteUtils.worldToPix(map.pollutionMaxY); + this.origX = this.x; + this.origY = this.y; + this._seenLand = false; + + this.xDelta = [ 2, 2, -2, -2, 0]; + this.yDelta = [-2, 2, 2, -2, 0]; + this.cardinals1 = [ 0, 1, 2, 3]; + this.cardinals2 = [ 1, 2, 3, 0]; + this.diagonals1 = [ 2, 5, 8, 11]; + this.diagonals2 = [11, 2, 5, 8]; + } + + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + + if (this.soundCount > 0) this.soundCount--; + + // Frames 1 - 12 are diagonal sprites, 3 for each direction. + // 1-3 NE, 2-6 SE, etc. 13-16 represent the cardinal directions. + let currentDir = Math.floor((this.frame - 1) / 3); + let frame, dir; + + if (currentDir < 4) { /* turn n s e w */ + // Calculate how far in the 3 step animation we were, + // move on to the next one + frame = (this.frame - 1) % 3; + + if (frame === 2) this.step = 0; + + if (frame === 0) this.step = 1; + + if (this.step) frame++; + else frame--; + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + + if (absDist < 60) { + if (this.flag === 0) { + this.flag = 1; + this.destX = this.origX; + this.destY = this.origY; + } else { + this.frame = 0; + return; + } + } + + // Perhaps switch to a cardinal direction + dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + dir = Math.floor((dir - 1) / 2); + + if (dir !== currentDir && math.getChance(10)) { + + if (math.getRandom16() & 1) frame = this.cardinals1[currentDir]; + else frame = this.cardinals2[currentDir]; + + currentDir = 4; + + if (!this.soundCount) { + messageManager.sendMessage(Messages.SOUND_MONSTER); + this.soundCount = 50 + math.getRandom(100); + } + } + } else { + // Travelling in a cardinal direction. Switch to a diagonal + currentDir = 4; + dir = this.frame; + frame = (dir - 13) & 3; + + if (!(math.getRandom16() & 3)) { + if (math.getRandom16() & 1) frame = this.diagonals1[frame]; + else frame = this.diagonals2[frame]; + + // We mung currentDir and frame here to + // make the assignment below work + currentDir = Math.floor((frame - 1) / 3); + frame = (frame - 1) % 3; + } + } + + frame = currentDir * 3 + frame + 1; + if (frame > 16) frame = 16; + + this.frame = frame; + + this.x += this.xDelta[currentDir]; + this.y += this.yDelta[currentDir]; + + if (this.count > 0) this.count--; + + let tileValue = SpriteUtils.getTileValue(this.map, this.x, this.y); + + if (tileValue === -1 || (tileValue === Tile.RIVER && this.count < 500)) this.frame = 0; + + if (tileValue === Tile.DIRT || tileValue > Tile.WATER_HIGH) this._seenLand = true; + + let spriteList = this.spriteManager.getSpriteList(); + for (let i = 0; i < spriteList.length; i++) { + let s = spriteList[i]; + + if (s.frame !== 0 && + (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || + s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && + SpriteUtils.checkSpriteCollision(this, s)) + s.explodeSprite(messageManager); + } + + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class CopterSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init(Micro.SPRITE_HELICOPTER, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 5; + this.count = 1500; + this.destX = math.getRandom(SpriteUtils.worldToPix(map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(map.height)) + 8; + this.origX = x; + this.origY = y; + + this.xDelta = [0, 0, 3, 5, 3, 0, -3, -5, -3]; + this.yDelta = [0, -5, -3, 0, 3, 5, 3, 0, -3]; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + if (this.soundCount > 0) this.soundCount--; + + if (this.count > 0) this.count--; + + if (this.count === 0) { + // Head towards a monster, and certain doom + let s = this.spriteManager.getSprite(Micro.SPRITE_MONSTER); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + // No monsters. Hm. I bet flying near that tornado is sensible + s = this.spriteManager.getSprite(Micro.SPRITE_TORNADO); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + this.destX = this.origX; + this.destY = this.origY; + } + } + + // If near destination, let's get her on the ground + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.origX, this.origY); + if (absDist < 30) { + this.frame = 0; + return; + } + } + + if (this.soundCount === 0) { + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + + if (x >= 0 && x < this.map.width && y >= 0 && y < this.map.height) { + if (blockMaps.trafficDensityMap.worldGet(x, y) > 170 && (math.getRandom16() & 7) === 0) { + messageManager.sendMessage(Messages.HEAVY_TRAFFIC, {x: x, y: y}); + messageManager.sendMessage(Messages.SOUND_HEAVY_TRAFFIC); + this.soundCount = 200; + } + } + } + + let frame = this.frame; + + if ((spriteCycle & 3) === 0) { + let dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, dir); + this.frame = frame; + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.HELICOPTER_CRASHED); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class AirplaneSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init( Micro.SPRITE_AIRPLANE, map, spriteManager, x, y ); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + if (x > SpriteUtils.worldToPix(map.width - 20)) { + this.destX = this.x - 200; + this.frame = 7; + } else { + this.destX = this.x + 200; + this.frame = 11; + } + this.destY = this.y; + + this.xDelta = [0, 0, 6, 8, 6, 0, -6, -8, -6, 8, 8, 8]; + this.yDelta = [0, -8, -6, 0, 6, 8, 6, 0, -6, 0, 0, 0]; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + let frame = this.frame; + + if ((spriteCycle % 5) === 0) { + // Frames > 8 mean the plane is taking off + if (frame > 8) { + frame--; + if (frame < 9) { // Planes always take off to the east + frame = 3; + } + this.frame = frame; + } else { + let d = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, d); + this.frame = frame; + } + } + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + if (absDist < 50) { + // We're pretty close to the destination + this.destX = math.getRandom(SpriteUtils.worldToPix(this.map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(this.map.height)) + 8; + } + + if (disasterManager.enableDisasters) { + let explode = false; + + let spriteList = this.spriteManager.getSpriteList(); + for (let i = 0; i < spriteList.length; i++) { + + let s = spriteList[i]; + + //if (s.frame === 0 || s === sprite) continue; + if (s.frame === 0 ) continue; + + if ((s.type === Micro.SPRITE_HELICOPTER || s.type === Micro.SPRITE_AIRPLANE) && SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + explode = true; + } + } + + if (explode) this.explodeSprite(messageManager); + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + + if (this.spriteNotInBounds()) this.frame = 0; + } + + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.PLANE_CRASHED); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class TornadoSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init(Micro.SPRITE_TORNADO, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -40; + this.frame = 1; + this.count = 200; + + this.xDelta = [2, 3, 2, 0, -2, -3]; + this.yDelta = [-2, 0, 2, 3, 2, 0]; + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + let frame; + frame = this.frame; + + // If middle frame, move right or left + // depending on the flag value + // If frame = 1, perhaps die based on flag + // value + if (frame === 2) { + if (this.flag) frame = 3; + else frame = 1; + } else { + if (frame === 1) this.flag = 1; + else this.flag = 0; + + frame = 2; + } + + if (this.count > 0) this.count--; + + this.frame = frame; + + let spriteList = this.spriteManager.getSpriteList(); + + for (let i = 0; i < spriteList.length; i++) { + + let s = spriteList[i]; + + // Explode vulnerable sprites + if (s.frame !== 0 && + (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || + s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && + SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + } + } + + frame = Random.getRandom(5); + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + + if (this.spriteNotInBounds()) this.frame = 0; + + if (this.count !== 0 && Random.getRandom(500) === 0) this.frame = 0; + + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } +} +/* + + // Metadata for image loading + Object.defineProperties(TornadoSprite, + {ID: Micro.makeConstantDescriptor(6), + width: Micro.makeConstantDescriptor(48), + frames: Micro.makeConstantDescriptor(3)}); + + + return TornadoSprite; +}); +*/ + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class ExplosionSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super(); + + this.init(Micro.SPRITE_EXPLOSION, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + this.frame = 1; + } + + startFire (x, y) { + x = ZoneUtils.pixToWorld(x); + y = ZoneUtils.pixToWorld(y); + + if (!this.map.testBounds(x, y)) return; + + let tile = this.map.getTile(x, y); + let tileValue = tile.getValue(); + + if (!tile.isCombustible() && tileValue !== Tile.DIRT) return; + + if (tile.isZone()) return; + + this.map.setTo(x, y, ZoneUtils.randomFire()); + + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + + if ((spriteCycle & 1) === 0) { + if (this.frame === 1) { + // Convert sprite coordinates to tile coordinates. + let explosionX = ZoneUtils.pixToWorld(this.x); + let explosionY = ZoneUtils.pixToWorld(this.y); + messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + messageManager.sendMessage(Messages.EXPLOSION_REPORTED, {x: explosionX, y: explosionY}); + } + + this.frame++; + } + + if (this.frame > 6) { + this.frame = 0; + + this.startFire(this.x, this.y); + this.startFire(this.x - 16, this.y - 16); + this.startFire(this.x + 16, this.y + 16); + this.startFire(this.x - 16, this.y + 16); + this.startFire(this.x + 16, this.y + 16); + } + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const constructors = {}; +constructors[Micro.SPRITE_TRAIN] = TrainSprite; +constructors[Micro.SPRITE_SHIP] = BoatSprite; +constructors[Micro.SPRITE_MONSTER] = MonsterSprite; +constructors[Micro.SPRITE_HELICOPTER] = CopterSprite; +constructors[Micro.SPRITE_AIRPLANE] = AirplaneSprite; +constructors[Micro.SPRITE_TORNADO] = TornadoSprite; +constructors[Micro.SPRITE_EXPLOSION] = ExplosionSprite; + + + + +class SpriteManager { + + constructor ( map ) { + + this.spriteList = []; + this.map = map; + this.spriteCycle = 0; + } + + getSprite (type) { + + let filteredList = this.spriteList.filter(function (s) { + return s.frame !== 0 && s.type === type; + }); + if (filteredList.length === 0) return null; + return filteredList[0]; + } + + getSpriteList () { + return this.spriteList.slice(); + } + + getSpritesInView (startX, startY, lastX, lastY) { + startX = SpriteUtils.worldToPix(startX); + startY = SpriteUtils.worldToPix(startY); + lastX = SpriteUtils.worldToPix(lastX); + lastY = SpriteUtils.worldToPix(lastY); + return this.spriteList.filter(function(s) { + return (s.x + s.xOffset >= startX && s.y + s.yOffset >= startY) && + !(s.x + s.xOffset >= lastX && s.y + s.yOffset >= lastY); + }); + } + + moveObjects ( simData ) { + + if(!simData) simData = Micro.simData; + + let messageManager = simData.messageManager; + let disasterManager = simData.disasterManager; + let blockMaps = simData.blockMaps; + + this.spriteCycle += 1; + + let list = this.spriteList.slice(); + + let i = list.length; + while(i--){ + //for (let i = 0, l = list.length; i < l; i++) { + let sprite = list[i]; + if (sprite.frame === 0) continue; + sprite.move(this.spriteCycle, messageManager, disasterManager, blockMaps); + } + + this.pruneDeadSprites(); + } + + makeSprite (type, x, y) { + + this.spriteList.push(new constructors[type](this.map, this, x, y)); + + } + + makeTornado (messageManager) { + let sprite = this.getSprite( Micro.SPRITE_TORNADO ); + if (sprite !== null) { + sprite.count = 200; + return; + } + let x = math.getRandom(SpriteUtils.worldToPix(this.map.width) - 800) + 400; + let y = math.getRandom(SpriteUtils.worldToPix(this.map.height) - 200) + 100; + + this.makeSprite( Micro.SPRITE_TORNADO, x, y ); + messageManager.sendMessage(Messages.TORNADO_SIGHTED, {x: SpriteUtils.pixToWorld(x), y: SpriteUtils.pixToWorld(y)}); + } + + makeExplosion (x, y) { + if (this.map.testBounds(x, y)) this.makeExplosionAt(SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + makeExplosionAt(x, y) { + this.makeSprite(Micro.SPRITE_EXPLOSION, x, y); + } + + generatePlane (x, y) { + if (this.getSprite(Micro.SPRITE_AIRPLANE) !== null) return; + this.makeSprite(Micro.SPRITE_AIRPLANE, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + generateTrain (census, x, y) { + if (census.totalPop > 20 && this.getSprite(Micro.SPRITE_TRAIN) === null && math.getRandom(25) === 0) this.makeSprite(Micro.SPRITE_TRAIN,SpriteUtils.worldToPix(x) + 8, SpriteUtils.worldToPix(y) + 8); + } + + generateShip () { + // XXX This code is borked. The map generator will never + // place a channel tile on the edges of the map + let x,y; + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, 0) === Tile.CHANNEL) { + this.makeShipHere(x, 0); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(0, y) === Tile.CHANNEL) { + this.makeShipHere(0, y); + return; + } + } + } + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, this.map.height - 1) === Tile.CHANNEL) { + this.makeShipHere(x, this.map.height - 1); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(this.map.width - 1, y) === Tile.CHANNEL) { + this.makeShipHere(this.map.width - 1, y); + return; + } + } + } + } + + getBoatDistance (x, y) { + let dist = 99999; + let pixelX = SpriteUtils.worldToPix(x) + 8; + let pixelY = SpriteUtils.worldToPix(y) + 8; + let sprite; + + for (let i = 0, l = this.spriteList.length; i < l; i++) { + sprite = this.spriteList[i]; + if (sprite.type === Micro.SPRITE_SHIP && sprite.frame !== 0) { + //let sprDist = Micro.absoluteValue(sprite.x - pixelX) + Micro.absoluteValue(sprite.y - pixelY); + let sprDist = Math.abs(sprite.x - pixelX) + Math.abs(sprite.y - pixelY); + dist = Math.min(dist, sprDist); + } + } + + return dist; + } + + makeShipHere (x, y) { + this.makeSprite(Micro.SPRITE_SHIP,SpriteUtils.worldToPix(x),SpriteUtils.worldToPix(y)); + } + + generateCopter (x, y) { + if (this.getSprite(Micro.SPRITE_HELICOPTER) !== null) return; + this.makeSprite(Micro.SPRITE_HELICOPTER,SpriteUtils.worldToPix(x),SpriteUtils.worldToPix(y)); + } + + makeMonsterAt (messageManager, x, y) { + + this.makeSprite(Micro.SPRITE_MONSTER, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + messageManager.sendMessage(Messages.MONSTER_SIGHTED, {x: x, y: y}); + } + + makeMonster (messageManager) { + let sprite = this.getSprite(Micro.SPRITE_MONSTER); + if (sprite !== null) { + sprite.soundCount = 1; + sprite.count = 1000; + sprite.destX = SpriteUtils.worldToPix(this.map.pollutionMaxX); + sprite.destY = SpriteUtils.worldToPix(this.map.pollutionMaxY); + } + + let done = 0; + for (let i = 0; i < 300; i++) { + let x = math.getRandom(this.map.width - 20) + 10; + let y = math.getRandom(this.map.height - 10) + 5; + let tile = this.map.getTile(x, y); + if (tile.getValue() === Tile.RIVER) { + this.makeMonsterAt(messageManager, x, y); + done = 1; + break; + } + } + + if (done === 0) this.makeMonsterAt(messageManager, 60, 50); + } + + pruneDeadSprites (type) { + this.spriteList = this.spriteList.filter(function (s) { return s.frame !== 0; }); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class EvaluationUtils { + + static getTrafficAverage ( blockMaps, census ) { + + var trafficDensityMap = blockMaps.trafficDensityMap; + var landValueMap = blockMaps.landValueMap; + var trafficTotal = 0; + var count = 1; + + for (var x = 0; x < landValueMap.gameMapWidth; x += landValueMap.blockSize) { + for (var y = 0; y < landValueMap.gameMapHeight; y += landValueMap.blockSize) { + if (landValueMap.worldGet(x, y) > 0) { + trafficTotal += trafficDensityMap.worldGet(x, y); + count++; + } + } + } + + var trafficAverage = Math.floor(trafficTotal / count) * 2.4; + //census.trafficAverage = trafficAverage //?? + return trafficAverage; + + } + + + static getUnemployment ( census ) { + + var b = (census.comPop + census.indPop) * 8; + if (b === 0) return 0; + // Ratio total people / working. At least 1. + var r = census.resPop / b; + b = Math.round((r - 1) * 255); + return Math.min(b, 255); + + } + + + static getFireSeverity ( census ) { + + return Math.min(census.firePop * 5, 255); + + } + +} + + +class Evaluation { + + constructor ( gameLevel ) { + + this.problemVotes = []; + this.problemOrder = []; + this.evalInit(); + this.gameLevel = '' + gameLevel; + this.changed = false; + + } + + save (saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) + saveData[Micro.EvalProps[i]] = this[Micro.EvalProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) + this[Micro.EvalProps[i]] = saveData[Micro.EvalProps[i]]; + } + + cityEvaluation ( simData ) { + + if(!simData) simData = Micro.simData; + + var census = simData.census; + + if ( census.totalPop > 0 ) { + + Micro.problemData = []; + //var problemTable = []; + for (var i = 0; i < Micro.NUMPROBLEMS; i++) Micro.problemData.push(0); + this.getAssessedValue( census ); + this.getPopulation( census ); + this.doProblems( simData.census, simData.budget, simData.blockMaps ); + this.getScore( simData ); + this.doVotes(); + this.changeEval(); + } else { + this.evalInit(); + this.cityYes = 50; + this.changeEval(); + } + } + + evalInit () { + + let i; + this.cityYes = 0; + this.cityPop = 0; + this.cityPopDelta = 0; + this.cityAssessedValue = 0; + this.cityClass = Micro.CC_VILLAGE; + this.cityClassLast = Micro.CC_VILLAGE; + this.cityScore = 500; + this.cityScoreDelta = 0; + for (i = 0; i < Micro.NUMPROBLEMS; i++) this.problemVotes[i] = { index: i, voteCount: 0 }; + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) this.problemOrder[i] = Micro.NUMPROBLEMS; + + } + + getAssessedValue( census ) { + + var value; + value = census.roadTotal * 5; + value += census.railTotal * 10; + value += census.policeStationPop * 1000; + value += census.fireStationPop * 1000; + value += census.hospitalPop * 400; + value += census.stadiumPop * 3000; + value += census.seaportPop * 5000; + value += census.airportPop * 10000; + value += census.coalPowerPop * 3000; + value += census.nuclearPowerPop * 6000; + this.cityAssessedValue = value * 1000; + + } + + getPopulation ( census ) { + + let oldPopulation = this.cityPop; + this.cityPop = (census.resPop + (census.comPop + census.indPop) * 8) * 20; + this.cityPopDelta = this.cityPop - oldPopulation; + if (this.cityPopDelta !== 0) EventEmitter.emitEvent(Messages.POPULATION_UPDATED, this.cityPop); + return this.cityPop; + + } + + getCityClass ( cityPopulation ) { + + this.cityClass = Micro.CC_VILLAGE; + if (cityPopulation > 2000) this.cityClass = Micro.CC_TOWN; + if (cityPopulation > 10000) this.cityClass = Micro.CC_CITY; + if (cityPopulation > 50000) this.cityClass = Micro.CC_CAPITAL; + if (cityPopulation > 100000) this.cityClass = Micro.CC_METROPOLIS; + if (cityPopulation > 500000) this.cityClass = Micro.CC_MEGALOPOLIS; + + if ( this.cityClass !== this.cityClassLast ) { + this.cityClassLast = this.cityClass; + EventEmitter.emitEvent( Messages.CLASSIFICATION_UPDATED, this.cityClass ); + } + + return this.cityClass; + + } + + voteProblems () { + + for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + this.problemVotes[i].index = i; + this.problemVotes[i].voteCount = 0; + } + + var problem = 0; + var voteCount = 0; + var loopCount = 0; + + while (voteCount < 100 && loopCount < 600) { + var voterProblemTolerance = math.getRandom(300); + if ( Micro.problemData[problem] > voterProblemTolerance ) { + this.problemVotes[problem].voteCount += 1; + voteCount++; + } + + problem = (problem + 1) % Micro.NUMPROBLEMS; + loopCount++; + } + } + + doProblems ( census, budget, blockMaps ) { + //var problemTaken = []; + + /*for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + problemTaken[i] = false; + problemTable[i] = 0; + }*/ + + Micro.problemData[Micro.CRIME] = census.crimeAverage; + Micro.problemData[Micro.POLLUTION] = census.pollutionAverage; + Micro.problemData[Micro.HOUSING] = census.landValueAverage * 7 / 10; + Micro.problemData[Micro.TAXES] = budget.cityTax * 10; + Micro.problemData[Micro.TRAFFIC] = EvaluationUtils.getTrafficAverage( blockMaps, census ); + Micro.problemData[Micro.UNEMPLOYMENT] = EvaluationUtils.getUnemployment( census ); + Micro.problemData[Micro.FIRE] = EvaluationUtils.getFireSeverity( census ); + + this.voteProblems(); + + // Rank the problems + this.problemVotes.sort(function(a, b) { + return b.voteCount - a.voteCount; + }); + + this.problemOrder = this.problemVotes.map(function(pv, i) { + if (i >= Micro.NUM_COMPLAINTS || pv.voteCount === 0) return null; + return pv.index; + }); + + /*for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + // Find biggest problem not taken yet + var maxVotes = 0; + var bestProblem = Micro.NUMPROBLEMS; + for (var j = 0; j < Micro.NUMPROBLEMS; j++) { + if ((this.problemVotes[j] > maxVotes) && (!problemTaken[j])) { + bestProblem = j; + maxVotes = this.problemVotes[j]; + } + } + // bestProblem == NUMPROBLEMS means no problem found + this.problemOrder[i] = bestProblem; + if (bestProblem < Micro.NUMPROBLEMS) { + problemTaken[bestProblem] = true; + } + }*/ + } + + getScore ( simData ) { + + var census = simData.census; + var budget = simData.budget; + var valves = simData.valves; + + var cityScoreLast; + + cityScoreLast = this.cityScore; + var score = 0; + + for ( var i = 0; i < Micro.NUMPROBLEMS; i++ ) score += Micro.problemData[i]; + + score = Math.floor(score / 3); + score = (250 - Math.min(score, 250)) * 4; + //score = Math.min(score, 256); + //score = math.clamp((256 - score) * 4, 0, 1000); + + // Penalise the player by 15% if demand for any type of zone is capped due + // to lack of suitable buildings + let demandPenalty = 0.85; + + if (valves.resCap) score = Math.round(score * demandPenalty); + + if (valves.comCap) score = Math.round(score * demandPenalty); + + if (valves.indCap) score = Math.round(score * demandPenalty); + + // Penalize if roads/rail underfunded + + if (budget.roadEffect < budget.MAX_ROAD_EFFECT) score -= budget.MAX_ROAD_EFFECT - budget.roadEffect; + + // Penalize player by up to 10% for underfunded police and fire services + + if (budget.policeEffect < budget.MAX_POLICE_STATION_EFFECT) { + score = Math.round(score * (0.9 + (budget.policeEffect / (10 * budget.MAX_POLICE_STATION_EFFECT)))); + } + + if (budget.fireEffect < budget.MAX_FIRE_STATION_EFFECT) { + score = Math.round(score * (0.9 + (budget.fireEffect / (10 * budget.MAX_FIRE_STATION_EFFECT)))); + } + + // Penalise the player by 15% if demand for any type of zone has collapsed due to overprovision + + if (valves.resValve < -1000) score = Math.round(score * 0.85); + if (valves.comValve < -1000) score = Math.round(score * 0.85); + if (valves.indValve < -1000) score = Math.round(score * 0.85); + + var scale = 1.0; + if ( this.cityPop === 0 || this.cityPopDelta === 0 || this.cityPopDelta === this.cityPop ) { + // Leave score unchanged if city is empty, if there hasn't been any migration, if the + // initial settlers have just arrived, or if the city has doubled in size + scale = 1.0; + } else if (this.cityPopDelta > 0) { + // If the city is growing, scale score by percentage growth in population + scale = (this.cityPopDelta / this.cityPop) + 1.0; + } else if (this.cityPopDelta < 0) { + // If the city is shrinking, scale down by up to 5% based on level of outward migration + scale = 0.95 + Math.floor(this.cityPopDelta / (this.cityPop - this.cityPopDelta)); + } + + score = Math.round( score * scale ); + + // Penalize player for having fires and a burdensome tax rate + score = score - EvaluationUtils.getFireSeverity(census) - budget.cityTax; // dec score for fires and tax + + // Penalize player based on ratio of unpowered zones to total zones + scale = census.unpoweredZoneCount + census.poweredZoneCount; // dec score for unpowered zones + if (scale > 0.0) score = Math.round(score * (census.poweredZoneCount / scale)); + + // Force in to range 0-1000. New score is average of last score and new computed value + score = math.clamp(score, 0, 1000); + this.cityScore = Math.round((this.cityScore + score) / 2); + + this.cityScoreDelta = this.cityScore - cityScoreLast; + + if (this.cityScoreDelta !== 0) EventEmitter.emitEvent(Messages.SCORE_UPDATED, this.cityScore); + + } + + doVotes () { + this.cityYes = 0; + + for (let i = 0; i < 100; i++) { + let voterExpectation = math.getRandom(1000); + if (this.cityScore > voterExpectation) this.cityYes++; + } + } + + changeEval () { + this.changed = true; + } + + countProblems () { + var i; + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + if (this.problemOrder[i] === Micro.NUMPROBLEMS) break; + } + return i; + } + + getProblemNumber (i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] === Micro.NUMPROBLEMS) return -1; + else return this.problemOrder[i]; + } + + getProblemVotes (i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] == Micro.NUMPROBLEMS) return -1; + else return this.problemVotes[this.problemOrder[i]].voteCount; + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class Valves { + + constructor () { + + this.resValve = 0; + this.comValve = 0; + this.indValve = 0; + this.resCap = false; + this.comCap = false; + this.indCap = false; + } + + save ( saveData ) { + saveData.resValve = this.resValve; + saveData.comValve = this.comValve; + saveData.indValve = this.indValve; + } + + load ( saveData ) { + + this.resValve = saveData.resValve; + this.comValve = saveData.comValve; + this.indValve = saveData.indValve; + + EventEmitter.emitEvent( Messages.VALVES_UPDATED, {residential: this.resValve, commercial: this.comValve, industrial: this.indValve}); + + } + + setValves ( gameLevel, census, budget ) { + + var resPopDenom = 8; + var birthRate = 0.02; + var labourBaseMax = 1.3; + var internalMarketDenom = 3.7; + var projectedIndPopMin = 5.0; + var resRatioDefault = 1.3; + var resRatioMax = 2; + var comRatioMax = 2; + var indRatioMax = 2; + var taxMax = 20; + var taxTableScale = 600; + var employment, labourBase; + + // Residential zones scale their population index when reporting it to the census + var normalizedResPop = census.resPop / resPopDenom; + census.totalPop = Math.round(normalizedResPop + census.comPop + census.indPop); + + // A lack of developed commercial and industrial zones means there are no employment opportunities, which constrain + // growth. (This might hurt initially if, for example, the player lays out an initial grid, as the residential zones + // will likely develop first, so the residential valve will immediately crater). + if (census.resPop > 0) employment = (census.comHist10[1] + census.indHist10[1]) / normalizedResPop; + else employment = 1; + + // Given the employment rate, calculate expected migration, add in births, and project the new population. + var migration = normalizedResPop * (employment - 1); + var births = normalizedResPop * birthRate; + var projectedResPop = normalizedResPop + migration + births; + + // Examine how many zones require workers + labourBase = census.comHist10[1] + census.indHist10[1]; + if (labourBase > 0.0) labourBase = census.resHist10[1] / labourBase; + else labourBase = 1; + labourBase = math.clamp(labourBase, 0.0, labourBaseMax); + + // Project future industry and commercial needs, taking into account available labour, and competition from + // other global cities + var internalMarket = (normalizedResPop + census.comPop + census.indPop) / internalMarketDenom; + var projectedComPop = internalMarket * labourBase; + var projectedIndPop = census.indPop * labourBase * Micro.extMarketParamTable[gameLevel]; + projectedIndPop = Math.max(projectedIndPop, projectedIndPopMin); + + // Calculate the expected percentage changes in each population type + var resRatio; + if (normalizedResPop > 0) resRatio = projectedResPop / normalizedResPop; + else resRatio = resRatioDefault; + + var comRatio; + if (census.comPop > 0) comRatio = projectedComPop / census.comPop; + else comRatio = projectedComPop; + + var indRatio; + if (census.indPop > 0) indRatio = projectedIndPop / census.indPop; + else indRatio = projectedIndPop; + + resRatio = Math.min(resRatio, resRatioMax); + comRatio = Math.min(comRatio, comRatioMax); + indRatio = Math.min(indRatio, indRatioMax); + + // Global tax and game level effects. + var z = Math.min((budget.cityTax + gameLevel), taxMax); + resRatio = (resRatio - 1) * taxTableScale + Micro.taxTable[z]; + comRatio = (comRatio - 1) * taxTableScale + Micro.taxTable[z]; + indRatio = (indRatio - 1) * taxTableScale + Micro.taxTable[z]; + + // Ratios are velocity changes to valves. + this.resValve = math.clamp(this.resValve + Math.round(resRatio), -Micro.RES_VALVE_RANGE, Micro.RES_VALVE_RANGE); + this.comValve = math.clamp(this.comValve + Math.round(comRatio), -Micro.COM_VALVE_RANGE, Micro.COM_VALVE_RANGE); + this.indValve = math.clamp(this.indValve + Math.round(indRatio), -Micro.IND_VALVE_RANGE, Micro.IND_VALVE_RANGE); + + if (this.resCap && this.resValve > 0) this.resValve = 0; + if (this.comCap && this.comValve > 0) this.comValve = 0; + if (this.indCap && this.indValve > 0) this.indValve = 0; + + EventEmitter.emitEvent( Messages.VALVES_UPDATED, {residential: this.resValve, commercial: this.comValve, industrial: this.indValve}); + + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class Budget { + + constructor () { + + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + this.totalFunds = 0; + this.cityTax = 7; + this.cashFlow = 0; + this.taxFund = 0; + + // These values denote how much money is required to fully maintain the relevant services + this.roadMaintenanceBudget = 0; + this.fireMaintenanceBudget = 0; + this.policeMaintenanceBudget = 0; + + // Percentage of budget used + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; + + // Cash value of spending. Should equal Math.round(_Fund * _Percent) + this.roadSpend = 0; + this.fireSpend = 0; + this.policeSpend = 0; + + this.awaitingValues = false; + this.autoBudget = true; + + } + + save (saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) + saveData[Micro.BudgetProps[i]] = this[Micro.BudgetProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) + this[Micro.BudgetProps[i]] = saveData[Micro.BudgetProps[i]]; + + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + } + + setAutoBudget (value) { + this.autoBudget = value; + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + } + + // Calculates the best possible outcome in terms of funding the various services + // given the player's current funds and tax yield. On entry, roadPercent etc. are + // assumed to contain the desired percentage level, and taxFunds should contain the + // most recent tax collected. On exit, the *Percent members will be updated with what + // we can actually afford to spend. Returns an object containing the amount of cash + // that would be spent on each service. + _calculateBestPercentages () { + + // How much would we be spending based on current percentages? + // Note: the *Budget items are updated every January by collectTax + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); + var total = this.roadSpend + this.fireSpend + this.policeSpend; + + // If we don't have any services on the map, we can bail early + if (total === 0) { + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; + return {road: 1, fire: 1, police: 1}; + } + + // How much are we actually going to spend? + var roadCost = 0; + var fireCost = 0; + var policeCost = 0; + + var cashRemaining = this.totalFunds + this.taxFund; + + // Spending priorities: road, fire, police + if (cashRemaining >= this.roadSpend) roadCost = this.roadSpend; + else roadCost = cashRemaining; + cashRemaining -= roadCost; + + if (cashRemaining >= this.fireSpend) fireCost = this.fireSpend; + else fireCost = cashRemaining; + cashRemaining -= fireCost; + + if (cashRemaining >= this.policeSpend) policeCost = this.policeSpend; + else policeCost = cashRemaining; + cashRemaining -= policeCost; + + if (this.roadMaintenanceBudget > 0) this.roadPercent = (roadCost / this.roadMaintenanceBudget).toPrecision(2) - 0; + else this.roadPercent = 1; + + if (this.fireMaintenanceBudget > 0) this.firePercent = (fireCost / this.fireMaintenanceBudget).toPrecision(2) - 0; + else this.firePercent = 1; + + if (this.policeMaintenanceBudget > 0) this.policePercent = (policeCost / this.policeMaintenanceBudget).toPrecision(2) - 0; + else this.policePercent = 1; + + return { road: roadCost, police: policeCost, fire: fireCost }; + } + + // User initiated budget + doBudgetWindow () { //doBudgetMenu + return this.doBudgetNow(true); + } + + doBudgetNow ( fromWindow ) { + + var costs = this._calculateBestPercentages(); + + if (!this.autoBudget && !fromWindow) { + this.autoBudget = false; + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + return; + } + + var roadCost = costs.road; + var policeCost = costs.police; + var fireCost = costs.fire; + var totalCost = roadCost + policeCost + fireCost; + var cashRemaining = this.totalFunds + this.taxFund - totalCost; + + // Autobudget + if ((cashRemaining > 0 && this.autoBudget) || fromWindow) { + // Either we were able to fully fund services, or we have just normalised user input. Go ahead and spend. + this.awaitingValues = false; + this.doBudgetSpend( roadCost, fireCost, policeCost ); + return; + } + + // Uh-oh. Not enough money. Make this the user's problem. + // They don't know it yet, but they're about to get a budget window. + this.setAutoBudget(false); + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + EventEmitter.emitEvent(Messages.NO_MONEY); + } + + doBudgetSpend ( roadValue, fireValue, policeValue ) { + + this.roadSpend = roadValue; + this.fireSpend = fireValue; + this.policeSpend = policeValue; + var total = this.roadSpend + this.fireSpend + this.policeSpend; + + this.spend(-(this.taxFund - total) ); + this.updateFundEffects(); + + } + + updateFundEffects () { + // The caller is assumed to have correctly set the percentage spend + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); + + // Update the effect this level of spending will have on infrastructure deterioration + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + + if (this.roadMaintenanceBudget > 0) this.roadEffect = Math.floor(this.roadEffect * this.roadSpend / this.roadMaintenanceBudget); + if (this.fireMaintenanceBudget > 0) this.fireEffect = Math.floor(this.fireEffect * this.fireSpend / this.fireMaintenanceBudget); + if (this.policeMaintenanceBudget > 0) this.policeEffect = Math.floor(this.policeEffect * this.policeSpend / this.policeMaintenanceBudget); + + } + + collectTax ( gameLevel, census ) { + + this.cashFlow = 0; + // How much would it cost to fully fund every service? + this.policeMaintenanceBudget = census.policeStationPop * Micro.policeMaintenanceCost; + this.fireMaintenanceBudget = census.fireStationPop * Micro.fireMaintenanceCost; + + var roadCost = census.roadTotal * Micro.roadMaintenanceCost; + var railCost = census.railTotal * Micro.railMaintenanceCost; + this.roadMaintenanceBudget = Math.floor((roadCost + railCost) * Micro.RLevels[gameLevel]); + + this.taxFund = Math.floor( Math.floor( census.totalPop * census.landValueAverage / 120) * this.cityTax * Micro.FLevels[gameLevel]); + + if (census.totalPop > 0) { + this.cashFlow = this.taxFund - (this.policeMaintenanceBudget + this.fireMaintenanceBudget + this.roadMaintenanceBudget); + this.doBudgetNow( false ); + } else { + // We don't want roads etc deteriorating when population hasn't yet been established + // (particularly early game) + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + } + } + + setTax ( amount ) { + if (amount === this.cityTax) return; + this.cityTax = amount; + } + + setFunds ( amount ) { + if (amount === this.totalFunds) return; + this.totalFunds = Math.max(0, amount); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + if (this.totalFunds === 0) EventEmitter.emitEvent(Messages.NO_MONEY); + } + + spend ( amount ) { + this.setFunds(this.totalFunds - amount); + } + + shouldDegradeRoad () { + return this.roadEffect < Math.floor(15 * this.MAX_ROAD_EFFECT / 16); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class Census { + + constructor () { + + this.clearCensus(); + this.changed = false; + this.crimeRamp = 0; + this.pollutionRamp = 0; + + // Set externally + this.landValueAverage = 0; + this.pollutionAverage = 0; + this.crimeAverage = 0; + this.totalPop = 0; + + var createArray = function(arrName) { + //this[arrName] = new M_ARRAY_TYPE(120); + this[arrName] = []; + //for (var a = 0; a < 120; a++) this[arrName][a] = 0; + var a = 120; + while(a--) this[arrName][a] = 0; + }; + + //for (var i = 0; i < Micro.arrs.length; i++) { + + let i = Micro.arrs.length; + while(i--){ + var name10 = Micro.arrs[i] + 'Hist10'; + var name120 = Micro.arrs[i] + 'Hist120'; + createArray.call(this, name10); + createArray.call(this, name120); + } + } + + save (saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) + saveData[Micro.CensusProps[i]] = this[Micro.CensusProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) + this[Micro.CensusProps[i]] = saveData[Micro.CensusProps[i]]; + } + + clearCensus () { + + this.poweredZoneCount = 0; + this.unpoweredZoneCount = 0; + this.firePop = 0; + this.roadTotal = 0; + this.railTotal = 0; + this.resPop = 0; + this.comPop = 0; + this.indPop = 0; + this.resZonePop = 0; + this.comZonePop = 0; + this.indZonePop = 0; + this.hospitalPop = 0; + this.churchPop = 0; + this.policeStationPop = 0; + this.fireStationPop = 0; + this.stadiumPop = 0; + this.coalPowerPop = 0; + this.nuclearPowerPop = 0; + this.seaportPop = 0; + this.airportPop = 0; + + } + + take10Census ( budget ) { + + var resPopDenom = 8; + MiscUtils.rotate10Arrays.call(this); + + this.resHist10[0] = Math.floor(this.resPop / resPopDenom); + this.comHist10[0] = this.comPop; + this.indHist10[0] = this.indPop; + + this.crimeRamp += Math.floor((this.crimeAverage - this.crimeRamp) / 4); + this.crimeHist10[0] = Math.min(this.crimeRamp, 255); + + this.pollutionRamp += Math.floor((this.pollutionAverage - this.pollutionRamp) / 4); + this.pollutionHist10[0] = Math.min(this.pollutionRamp, 255); + + var x = Math.floor(budget.cashFlow / 20) + 128; + this.moneyHist10[0] = math.clamp(x, 0, 255); + + this.resPop >> 8; + + if (this.hospitalPop < this.resPopScaled) this.needHospital = 1; + else if (this.hospitalPop > this.resPopScaled) this.needHospital = -1; + else if (this.hospitalPop === this.resPopScaled) this.needHospital = 0; + + this.changed = true; + + } + + take120Census () { + + MiscUtils.rotate120Arrays.call(this); + var resPopDenom = 8; + + this.resHist120[0] = Math.floor(this.resPop / resPopDenom); + this.comHist120[0] = this.comPop; + this.indHist120[0] = this.indPop; + this.crimeHist120[0] = this.crimeHist10[0]; + this.pollutionHist120[0] = this.pollutionHist10[0]; + this.moneyHist120[0] = this.moneyHist10[0]; + this.changed = true; + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BlockMap { + + constructor ( gameMapWidth, gameMapHeight, blockSize ) { + + if (gameMapWidth === undefined || gameMapHeight === undefined || blockSize === undefined) throw new Error('Invalid dimensions for block map') + + this.isBlockMap = true; + + this.blockSize = blockSize; + this.gameMapWidth = gameMapWidth; + this.gameMapHeight = gameMapHeight; + + this.width = Math.floor((gameMapWidth + blockSize - 1) / blockSize); + this.height = Math.floor((gameMapHeight + blockSize - 1) / blockSize); + + this.data = []; + this.clear(); + + } + + clear () { + + let x, y = this.height; + while( y-- ){ + x = this.width; + while( x-- ){ + this.data[ this.width * y + x ] = 0; + } + } + + } + + copyFrom ( sourceMap, sourceFn ) { + + if (sourceMap.width !== this.width || sourceMap.height !== this.height || sourceMap.blockSize !== this.blockSize) console.warn('Copying from incompatible blockMap!'); + let x, y, height = sourceMap.height, width = sourceMap.width; + for ( y = 0; y < height; y++) { + for ( x = 0; x < width; x++){ + this.data[width * y + x] = sourceFn(sourceMap.data[width * y + x]); + } + } + } + + get ( x, y ) { + return this.data[ this.width * y + x ]; + } + + set ( x, y, value ) { + this.data[ this.width * y + x ] = value; + } + + toBlock ( num ) { + return Math.floor( num / this.blockSize ); + } + + worldGet ( x, y ) { + return this.get( this.toBlock(x), this.toBlock(y) ); + } + + worldSet ( x, y, value ) { + this.set( this.toBlock(x), this.toBlock(y), value ); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const Direction = { + + INVALID: -1, + NORTH: 0, + NORTHEAST: 1, + EAST: 2, + SOUTHEAST: 3, + SOUTH: 4, + SOUTHWEST: 5, + WEST: 6, + NORTHWEST: 7, + BEGIN: 0, + END: 8, + + // Move direction clockwise by 45 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return dir + count; + }, + // Move direction clockwise by 90 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.increment45(dir, 2); + }, + // Move direction clockwise by 45 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return ((dir - Direction.NORTH + count) & 7) + Direction.NORTH; + }, + // Move direction clockwise by 90 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 2); + }, + // Move direction clockwise by 180 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate180: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 4); + }, +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class Position { + + constructor ( pos, deltaX, deltaY ) { + + this.isPosition = true; + this.width = Micro.MAP_WIDTH; + this.height = Micro.MAP_HEIGHT; + this.x = 0; + this.y = 0; + + + this.validDirs = [Direction.NORTH, Direction.NORTHEAST, Direction.EAST, Direction.SOUTHEAST, + Direction.SOUTH, Direction.SOUTHWEST, Direction.WEST, Direction.NORTHWEST, + Direction.INVALID]; + + + if (arguments.length === 0) return this; + + if (arguments.length === 1 && !pos.isPosition ) throw new Error('Position constructor called with invalid pos ' + pos); + + if (arguments.length === 3 && !pos.isPosition ) throw new Error('Position constructor called with invalid pos ' + pos); + + if (arguments.length === 3 && !(this.isNumber(deltaX) && this.isNumber(deltaY))) throw new Error('Position constructor called with invalid deltas ' + deltaX + ' ' + deltaY); + + if (arguments.length === 2 && this.isNumber(pos) && !this.isNumber(deltaX)) throw new Error('Position constructor called with invalid y coordinate ' + pos + ' ' + deltaX); + + if (arguments.length === 2 && (pos.isPosition) && !(this.isNumber(deltaX) && this.isDirection(deltaX))) throw new Error('Position constructor called with invalid direction ' + pos + ' ' + deltaX); + + if (arguments.length === 2 && !this.isNumber(pos) && !pos.isPosition) throw new Error('Position constructor called with bad existing position ' + pos + ' ' + deltaX); + + + // This overloaded constructor accepts the following parameters + // Position(x, y) - positive integral coordinates + // Position(Position p) - assign from existing position + // Position(Position p, Direction d) - assign from existing position and move in Direction d + // Position(Position p, deltaX, deltaY) - assign from p and then adjust x/y coordinates + // Check for the possible combinations of arguments, and error out for invalid arguments + //if ((arguments.length === 1 || arguments.length === 3) && !(pos instanceof Position)) throw new Error('Invalid parameter'); + //if (arguments.length === 3 && (!isNumber(deltaX) || !isNumber(deltaY))) throw new Error('Invalid parameter'); + //if (arguments.length === 2 && ((isNumber(pos) && !isNumber(deltaX)) || (pos instanceof Position && !isNumber(deltaX)) || (pos instanceof Position && isNumber(deltaX) && !isDirection(deltaX)) || (!isNumber(pos) && !(pos instanceof Position)))) throw new Error('Invalid parameter'); + let moveOK = true; + + if (this.isNumber(pos)) { + // Coordinates + this.x = pos; + this.y = deltaX; + } else { + this.set( pos ); + if (arguments.length === 2) moveOK = this.move( deltaX ); + else if (arguments.length === 3) { + this.x += deltaX; + this.y += deltaY; + } + } + + if ( this.x < 0 || this.x >= this.width || this.y < 0 || this.y >= this.height || !moveOK) throw new Error('Invalid parameter'); + + } + + isNumber ( v ) { + return !isNaN(v) + //return typeof(v) === 'number'; + } + + isDirection ( param ) { + return this.isNumber(param) && this.validDirs.indexOf(param) !== -1; + } + + + set ( from ) { + this.x = from.x; + this.y = from.y; + } + + toString () { + return '(' + this.x + ', ' + this.y + ')'; + } + + toInt () { + return this.y * this.width + this.x; + } + + move ( dir ) { + + let up = false; + switch (dir) { + case Direction.INVALID: return true;//up = true; break; + case Direction.NORTH: if (this.y > 0) { this.y--; up = true; } break; + case Direction.NORTHEAST: if (this.y > 0 && this.x < this.width - 1) { this.y--; this.x++; up = true; } break; + case Direction.EAST: if (this.x < this.width - 1) { this.x++; up = true; } break; + case Direction.SOUTHEAST: if (this.y < this.height - 1 && this.x < this.width - 1) { this.x++; this.y++; up = true; } break; + case Direction.SOUTH: if (this.y < this.height - 1) { this.y++; up = true; } break; + case Direction.SOUTHWEST: if (this.y < this.height - 1 && this.x > 0) { this.y++; this.x--; up = true; } break; + case Direction.WEST: if (this.x > 0) { this.x--; up = true; } break; + case Direction.NORTHWEST: if (this.y > 0 && this.x > 0) { this.y--; this.x--; up = true; } break; + } + return up; + + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class PowerManager { + + constructor ( map ) { + + this._map = map; + this._powerStack = []; + this.powerGridMap = new BlockMap(this._map.width, this._map.height, 1, 0); + + } + + setTilePower (x, y) { + + var tile = this._map.getTile(x, y); + var tileValue = tile.getValue(); + + if (tileValue === Tile.NUCLEAR || tileValue === Tile.POWERPLANT || this.powerGridMap.worldGet(x, y) > 0) { + tile.addFlags(Tile.POWERBIT); + return; + } + + tile.removeFlags(Tile.POWERBIT); + + } + + clearPowerStack () { + this._powerStackPointer = 0; + this._powerStack = []; + } + + testForConductive ( pos, testDir ) { + var movedPos = new Position(pos); + if (movedPos.move(testDir)) { + if (this._map.getTile(movedPos.x, movedPos.y).isConductive()) { + if (this.powerGridMap.worldGet(movedPos.x, movedPos.y) === 0) + return true; + } + } + return false; + } + + // Note: the algorithm is buggy: if you have two adjacent power + // plants, the second will be regarded as drawing power from the first + // rather than as a power source itself + doPowerScan ( census ) { + // Clear power this._map. + this.powerGridMap.clear(); + + // Power that the combined coal and nuclear power plants can deliver. + let maxPower = census.coalPowerPop * Micro.COAL_POWER_STRENGTH + census.nuclearPowerPop * Micro.NUCLEAR_POWER_STRENGTH; + + let powerConsumption = 0; // Amount of power used. + + while (this._powerStack.length > 0) { + var pos = this._powerStack.pop(); + var anyDir = Direction.INVALID; + var conNum; + do { + powerConsumption++; + if (powerConsumption > maxPower) { + EventEmitter.emitEvent(Messages.NOT_ENOUGH_POWER); + return; + } + + if (anyDir !== Direction.INVALID) + pos.move(anyDir); + + this.powerGridMap.worldSet(pos.x, pos.y, 1); + conNum = 0; + var dir = Direction.BEGIN; + + while (dir < Direction.END && conNum < 2) { + if (this.testForConductive(pos, dir)) { + conNum++; + anyDir = dir; + } + dir = Direction.increment90(dir); + } + if (conNum > 1) this._powerStack.push( new Position(pos) ); + } while ( conNum ); + } + } + + coalPowerFound ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.coalPowerPop += 1; + this._powerStack.push(new Position(x, y)); + + // Ensure animation runs + var dX = [-1, 2, 1, 2]; + var dY = [-1, -1, 0, 0]; + + // Ensure animation bits set no animation for 3d + if(!simData.is3D) for (var i = 0; i < 4; i++) map.addTileFlags(x + dX[i], y + dY[i], Tile.ANIMBIT); + + } + + nuclearPowerFound ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + var meltdownTable = [30000, 20000, 10000]; + // TODO With the auto repair system, zone gets repaired before meltdown + // In original Micropolis code, we bail and don't repair if melting down + if (simData.disasterManager.disastersEnabled && math.getRandom(meltdownTable[simData.gameLevel]) === 0) { + // simData.disasterManager.doMeltdown(messageManager, x, y); + return; + } + simData.census.nuclearPowerPop += 1; + this._powerStack.push(new Position(x, y)); + //console.log(x, y, new map.Position(x, y)) + + // Ensure animation bits set no animation for 3d + if(!simData.is3D) + for (var i = 0; i < 4; i++) map.addTileFlags(x, y, Tile.ANIMBIT | Tile.CONDBIT | Tile.POWERBIT | Tile.BURNBIT); + } + + registerHandlers (mapScanner, repairManager) { + mapScanner.addAction(Tile.POWERPLANT, this.coalPowerFound.bind(this)); + mapScanner.addAction(Tile.NUCLEAR, this.nuclearPowerFound.bind(this)); + repairManager.addAction(Tile.POWERPLANT, 7, 4); + repairManager.addAction(Tile.NUCLEAR, 7, 4); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +class MapScanner { + + constructor ( map ) { + + this._map = map; + this._actions = []; + + } + + addAction ( criterion, action ) { + + this._actions.push({ criterion: criterion, action: action }); + + } + + mapScan ( startX, maxX, simData ) { + + if(!simData) simData = Micro.simData; + + let y = this._map.height, x, i, id, tile, tileValue, current, callable; + + while( y-- ){ + + for ( x = startX; x < maxX; x++ ) { + + id = this._map.getId( x, y ); //x + y * this.mapWidth; + tile = this._map.data[id] || new Tiles(); + tileValue = tile.getValue(); + + if ( tileValue < Tile.FLOOD ) continue; + + if ( tile.isConductive() ) simData.powerManager.setTilePower(x, y); + + if ( tile.isZone() ) { + simData.repairManager.checkTile( x, y, simData.cityTime ); + if ( tile.isPowered() ){ simData.census.poweredZoneCount += 1; this._map.powered({ v:1, id:id });/*this._map.powerData[id] = 1;*/ } + else { simData.census.unpoweredZoneCount += 1; this._map.powered({ v:2, id:id });/*this._map.powerData[id] = 2;*/ } + } + + i = this._actions.length; + while(i--){ + + current = this._actions[i]; + callable = MiscUtils.isCallable(current.criterion); + + if (callable && current.criterion.call(null, tile)) { + current.action.call(null, this._map, x, y, simData); + break; + } else if (!callable && current.criterion === tileValue) { + current.action.call(null, this._map, x, y, simData); + break; + } + } + } + } + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class RepairManager { + + constructor ( map ) { + + this._map = map; + this._actions = []; + + } + + addAction ( criterion, period, zoneSize ) { + + this._actions.push({ criterion: criterion, period: period, zoneSize: zoneSize }); + + } + + repairZone ( x, y, zoneSize ) { + + let xx, yy, current, currentValue; + let centre = this._map.getTileValue(x, y); + let tileValue = centre - zoneSize - 2; + + for ( yy = -1; yy < zoneSize - 1; yy++) { + for ( xx = -1; xx < zoneSize - 1; xx++) { + tileValue++; + + current = this._map.getTile(x + xx, y + yy); + if (current.isZone() || current.isAnimated()) continue; + + currentValue = current.getValue(); + if (currentValue < Tile.RUBBLE || currentValue >= Tile.ROADBASE) + this._map.setTile(x + xx, y + yy, tileValue, Tile.CONDBIT | Tile.BURNBIT); + } + } + + } + + checkTile ( x, y, cityTime ) { + + let i = this._actions.length, current, period, tile, tileValue, callable; + + while( i-- ){ + + current = this._actions[i]; + period = current.period; + + if ((cityTime & period) !== 0) continue; + + tile = this._map.getTile(x, y); + tileValue = tile.getValue(); + + callable = MiscUtils.isCallable( current.criterion ); + if (callable && current.criterion.call(null, tile)) this.repairZone( x, y, current.zoneSize ); + else if (!callable && current.criterion === tileValue) this.repairZone( x, y, current.zoneSize ); + + } + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class Traffic { + + constructor ( map, spriteManager ) { + + this._map = map; + this._stack = []; + this._spriteManager = spriteManager; + + } + + makeTraffic ( x, y, blockMaps, destFn ) { + + this._stack = []; + + let pos = new Position(x, y); + + if (this.findPerimeterRoad(pos)) { + if (this.tryDrive(pos, destFn)) { + this.addToTrafficDensityMap(blockMaps); + return Micro.ROUTE_FOUND; + } + return Micro.NO_ROUTE_FOUND; + } else { + return Micro.NO_ROAD_FOUND; + } + + } + + addToTrafficDensityMap ( blockMaps ) { + + let trafficDensityMap = blockMaps.trafficDensityMap; + + while ( this._stack.length > 0 ) { + + let pos = this._stack.pop(); + + // Could this happen?!? + if (!this._map.testBounds(pos.x, pos.y)) continue; + + let tileValue = this._map.getTileValue( pos.x, pos.y ); + + if ( tileValue >= Tile.ROADBASE && tileValue < Tile.POWERBASE ) { + // Update traffic density. + let traffic = trafficDensityMap.worldGet(pos.x, pos.y); + traffic += 50; + traffic = Math.min(traffic, 240); + trafficDensityMap.worldSet(pos.x, pos.y, traffic); + + // Attract traffic copter to the traffic + if (traffic >= 240 && math.getRandom(5) === 0) { + let sprite = this._spriteManager.getSprite(Micro.SPRITE_HELICOPTER); + if (sprite !== null) { + sprite.destX = ZoneUtils.worldToPix(pos.x); + sprite.destY = ZoneUtils.worldToPix(pos.y); + } + } + } + } + + } + + findPerimeterRoad ( pos ) { + + for ( let i = 0; i < 12; i++ ) { + + let xx = pos.x + Micro.perimX[i]; + let yy = pos.y + Micro.perimY[i]; + + if (this._map.testBounds(xx, yy)) { + if (ZoneUtils.isDriveable(this._map.getTileValue(xx, yy))) { + pos.x = xx; + pos.y = yy; + return true; + } + } + } + return false; + + } + + tryDrive ( startPos, destFn ) { + + let dirLast = Direction.INVALID; + let drivePos = new Position(startPos); + + /* Maximum distance to try */ + for (let dist = 0; dist < Micro.MAX_TRAFFIC_DISTANCE; dist++) { + let dir = this.tryGo(drivePos, dirLast); + if (dir != Direction.INVALID) { + drivePos.move(dir); + dirLast = Direction.rotate180(dir); + + if (dist & 1) this._stack.push( new Position(drivePos) ); + if (this.driveDone(drivePos, destFn)) return true; + } else { + if (this._stack.length > 0) { + this._stack.pop(); + dist += 3; + } else { + return false; + } + } + } + return false; + } + + tryGo ( pos, dirLast ) { + + let directions = []; + // Find connections from current position. + let dir = Direction.NORTH; + let i, count = 0; + + for ( i = 0; i < 4; i++ ) { + if (dir != dirLast && ZoneUtils.isDriveable(this._map.getTileFromMapOrDefault(pos, dir, Tile.DIRT))) { + // found a road in an allowed direction + directions[i] = dir; + count++; + } else { + directions[i] = Direction.INVALID; + } + dir = Direction.rotate90(dir); + } + if (count === 0) return Direction.INVALID; + if (count === 1) { + for (i = 0; i < 4; i++) { + if (directions[i] != Direction.INVALID) return directions[i]; + } + } + i = math.getRandom16() & 3; + while ( directions[i] === Direction.INVALID ) i = (i + 1) & 3; + return directions[i]; + + } + + driveDone ( pos, destFn ) { + + if (pos.y > 0) { if (destFn(this._map.getTileValue(pos.x, pos.y - 1))) return true; } + if (pos.x < (this._map.width - 1)) { if (destFn(this._map.getTileValue(pos.x + 1, pos.y))) return true; } + if (pos.y < (this._map.height - 1)) { if (destFn(this._map.getTileValue(pos.x, pos.y + 1))) return true; } + if (pos.x > 0) { if (destFn(this._map.getTileValue(pos.x - 1, pos.y))) return true; } + return false; + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const vulnerable = function( tile ) { + + let tileValue = tile.getValue(); + if (tileValue < Tile.RESBASE || tileValue > Tile.LASTZONE || tile.isZone()) return false; + return true; + +}; + +class DisasterManager { + + constructor ( map, spriteManager, gameLevel ) { + + this._map = map; + this._spriteManager = spriteManager; + this._gameLevel = gameLevel; + + this._floodCount = 0; + this.disastersEnabled = false; + + this.Dx = [ 0, 1, 0, -1]; + this.Dy = [-1, 0, 1, 0]; + + // TODO enable disasters + //Object.defineProperty(this, 'disastersEnabled', MiscUtils.mcd(false)); + } + + doDisasters ( census ) { + + if (this._floodCount) this._floodCount--; + + // TODO Scenarios + + if (!this.disastersEnabled) return; + + if (math.getRandom(Micro.DisChance[this._gameLevel])) { + switch (math.getRandom(8)) { + case 0: + case 1: this.setFire(); break; + + case 2: + case 3: this.makeFlood(); break; + + case 4: + break; + + case 5: this._spriteManager.makeTornado(); break; + + case 6: + // TODO Earthquakes + //this.makeEarthquake(); + break; + + case 7: + case 8: if (census.pollutionAverage > 60) this._spriteManager.makeMonster(); break; + } + } + } + + setDifficulty (gameLevel) { + this._gameLevel = gameLevel; + } + + scenarioDisaster () { + // TODO Scenarios + } + // User initiated meltdown: need to find the plant first + makeMeltdown () { + for (let x = 0; x < (this._map.width - 1); x++) { + for (let y = 0; y < (this._map.height - 1); y++) { + if (this._map.getTileValue(x, y) === Tile.NUCLEAR) { + this.doMeltdown( x, y ); + return; + } + } + } + } + + makeEarthquake () { + + let strength = math.getRandom(700) + 300; + this.doEarthquake(strength); + + EventEmitter.emitEvent(Messages.EARTHQUAKE, {x: this._map.cityCenterX, y: this._map.cityCenterY}); + + let i, x, y; + + for ( i = 0; i < strength; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + + if (vulnerable(this._map.getTile(x, y))) { + if ((i & 0x3) !== 0) this._map.setTo(x, y, ZoneUtils.randomRubble()); + else this._map.setTo(x, y, ZoneUtils.randomFire()); + } + } + + } + + setFire ( times = 1, zonesOnly = false ) { + + let i, x, y, tile, lowerLimit; + + for ( i = 0; i < times; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + + if (!this._map.testBounds(x, y)) continue; + + tile = this._map.getTile(x, y); + + if (!tile.isZone()) { + tile = tile.getValue(); + lowerLimit = zonesOnly ? Tile.LHTHR : Tile.TREEBASE; + if (tile > lowerLimit && tile < Tile.LASTZONE) { + this._map.setTo(x, y, ZoneUtils.randomFire()); + EventEmitter.emitEvent(Messages.FIRE_REPORTED, {showable: true, x: x, y: y}); + return; + } + } + } + } + + makeCrash () { + + let s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + if (s !== null) { s.explodeSprite(); return; } + + let x = math.getRandom(this._map.width - 1); + let y = math.getRandom(this._map.height - 1); + this._spriteManager.generatePlane(x, y); + s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + s.explodeSprite(); + + } + + makeFire () { + + this.setFire( 40, false); + + } + + makeFlood () { + + let i, x, y, tileValue, j, xx, yy, tile; + + for ( i = 0; i < 300; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + if (!this._map.testBounds(x, y)) continue; + + tileValue = this._map.getTileValue(x, y); + + if (tileValue > Tile.CHANNEL && tileValue <= Tile.WATER_HIGH) { + for ( j = 0; j < 4; j++) { + xx = x + this.Dx[j]; + yy = y + this.Dy[j]; + + if (!this._map.testBounds(xx, yy)) continue; + + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile === Tile.DIRT || (tile.isBulldozable() && tile.isCombustible)) { + this._map.setTo(xx, yy, new Tiles(Tile.FLOOD)); + this._floodCount = 30; + EventEmitter.emitEvent(Messages.FLOODING_REPORTED, {showable: true, x: xx, y: yy}); + return; + } + } + } + } + + } + + doFlood ( x, y, blockMaps ) { + + let i, xx, yy, tile, tileValue; + + if (this._floodCount > 0) { + // Flood is not over yet + for ( i = 0; i < 4; i++) { + if (math.getChance(7)) { + xx = x + this.Dx[i]; + yy = y + this.Dy[i]; + + if (this._map.testBounds(xx, yy)) { + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile.isCombustible() || tileValue === Tile.DIRT || (tileValue >= Tile.WOODS5 && tileValue < Tile.FLOOD)) { + if (tile.isZone()) ZoneUtils.fireZone(this.map, xx, yy, blockMaps); + + this._map.setTile(xx, yy, Tile.FLOOD + math.getRandom(2), 0); + //this._map.setTo(xx, yy, new Tiles(Tile.FLOOD + math.getRandom(2))); + } + } + } + } + } else { + if (math.getChance(15)) this._map.setTile(x, y, Tile.DIRT, 0); + } + + } + + doMeltdown ( x, y ) { + + this._spriteManager.makeExplosion(x - 1, y - 1); + this._spriteManager.makeExplosion(x - 1, y + 2); + this._spriteManager.makeExplosion(x + 2, y - 1); + this._spriteManager.makeExplosion(x + 2, y + 2); + + let i, dY, dX, tile; + + // Whole power plant is at fire + for (dX = x - 1; dX < x + 3; dX++) { + for (dY = y - 1; dY < y + 3; dY++) { + this._map.setTo(dX, dY, ZoneUtils.randomFire()); + } + } + + // Add lots of radiation tiles around the plant + for ( i = 0; i < 200; i++) { + dX = x - 20 + math.getRandom(40); + dY = y - 15 + math.getRandom(30); + + if (!this._map.testBounds(dX, dY)) continue; + + tile = this._map.getTile(dX, dY); + + if (tile.isZone()) continue; + if (tile.isCombustible() || tile.getValue() === Tile.DIRT) this._map.setTile(dX, dY, Tile.RADTILE, 0);//this._map.setTo(dX, dY, new Tiles(Tile.RADTILE)); + } + + // Report disaster to the user + EventEmitter.emitEvent(Messages.NUCLEAR_MELTDOWN, {showable: true, x: x, y: y}); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const freeZone = [0, 3, 6, 1, 4, 7, 2, 5, 8]; + +const Residential = { + + registerHandlers: function ( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isResidentialZone, Residential.residentialFound); + mapScanner.addAction(ZoneUtils.HOSPITAL, Residential.hospitalFound); + repairManager.addAction(Tile.HOSPITAL, 15, 3); + }, + + // Residential tiles have 'populations' of 16, 24, 32 or 40 + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + placeResidential: function ( map, x, y, population, lpValue, zonePower ) { + + let centreTile = ((lpValue * 4) + population) * 9 + Tile.RZB; + ZoneUtils.putZone( map, x, y, centreTile, zonePower ); + + }, + + // Look for housing in the adjacent 8 tiles + getFreeZonePopulation: function( map, x, y, tileValue ) { + + let count = 0, xx, yy; + for ( xx = x - 1; xx <= x + 1; xx++) { + for ( yy = y - 1; yy <= y + 1; yy++) { + if (xx === x && yy === y) continue; + tileValue = map.getTileValue(xx, yy); + if (tileValue >= Tile.LHTHR && tileValue <= Tile.HHTHR) count += 1; + } + } + return count; + }, + + getZonePopulation: function ( map, x, y, tileValue ) { + //if ( tileValue.isTile ) tileValue = new Tiles().getValue(); + if ( tileValue === Tile.FREEZ) return Residential.getFreeZonePopulation(map, x, y, tileValue); + let populationIndex = Math.floor((tileValue - Tile.RZB) / 9) % 4 + 1; + return populationIndex * 8 + 16; + }, + + // Assess a tile for suitability for a house. Prefer tiles near roads + evalLot: function( map, x, y ) { + + let xDelta = [0, 1, 0, -1]; + let yDelta = [-1, 0, 1, 0]; + + if (!map.testBounds(x, y)) return -1; + + let tileValue = map.getTileValue(x, y); + if (tileValue < Tile.RESBASE || tileValue > Tile.RESBASE + 8) return -1; + + let score = 1, i, edgeX, edgeY; + for ( i = 0; i < 4; i++) { + + edgeX = x + xDelta[i]; + edgeY = y + yDelta[i]; + if (edgeX < 0 || edgeX >= map.width || edgeY < 0 || edgeY >= map.height) continue; + tileValue = map.getTileValue(edgeX, edgeY); + if (tileValue !== Tile.DIRT && tileValue <= Tile.LASTROAD) score += 1; + } + return score; + + }, + + buildHouse: function ( map, x, y, lpValue ) { + + let best = 0; + let bestScore = 0; + + // Deliberately ordered so that the centre tile is at index 0 + let xDelta = [0, -1, 0, 1, -1, 1, -1, 0, 1]; + let yDelta = [0, -1, -1, -1, 0, 0, 1, 1, 1]; + + let i, xx, yy, score; + + for ( i = 0; i < 9; i++) { + xx = x + xDelta[i]; + yy = y + yDelta[i]; + score = Residential.evalLot(map, xx, yy); + if (score > bestScore) { + bestScore = score; + best = i; + } else if (score === bestScore && math.getChance(7)) { + // Ensures we don't always select the same position when we + // have a choice + best = i; + } + } + if (best > 0 && map.testBounds(x + xDelta[best], y + yDelta[best])) + map.setTile(x + xDelta[best], y + yDelta[best], Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT); + //map.setTo(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + //map.setTile(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + }, + + growZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + + let pollution = blockMaps.pollutionDensityMap.worldGet(x, y); + // Cough! Too polluted noone wants to move here! + if (pollution > 128) return; + + let tileValue = map.getTileValue(x, y); + + if (tileValue === Tile.FREEZ) { + if (population < 8) { + // Zone capacity not yet reached: build another house + Residential.buildHouse(map, x, y, lpValue); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 1); + } + else if (blockMaps.populationDensityMap.worldGet(x, y) > 64) { + // There is local demand for higher density housing + Residential.placeResidential(map, x, y, 0, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + + } + + return; + } + + if (population < 40) { + // Zone population not yet maxed out + Residential.placeResidential(map, x, y, Math.floor(population / 8) - 1, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + let xx, yy; + if (population === 0) return; + + if (population > 16) { + // Degrade to a lower density block + Residential.placeResidential(map, x, y, Math.floor((population - 24) / 8), lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } + + if (population === 16) { + // Already at lowest density: degrade to 8 individual houses + map.setTo(x, y, new Tiles(Tile.FREEZ, Tile.BLBNCNBIT | Tile.ZONEBIT)); + + for (yy = y - 1; yy <= y + 1; yy++) { + for (xx = x - 1; xx <= x + 1; xx++) { + if (xx === x && yy === y) continue; + map.setTile(x, y, Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT); + //map.setTo(x, y, new Tiles(Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT)); + } + } + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } + + // Already down to individual houses. Remove one + let i = 0; + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -1); + + for (xx = x - 1; xx <= x + 1; xx++) { + for (yy = y - 1; yy <= y + 1; yy++) { + let currentValue = map.getTileValue(xx, yy); + if (currentValue >= Tile.LHTHR && currentValue <= Tile.HHTHR) { + // We've found a house. Replace it with the normal free zone tile + map.setTile(xx, yy, freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT); + //map.setTo(xx, yy, new Tiles(freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT)); + return; + } + i += 1; + } + } + }, + + // Returns a score for the zone in the range -3000 - 3000 + evalResidential: function ( blockMaps, x, y, traffic ) { + + if (traffic === Micro.NO_ROAD_FOUND) return -3000; + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 0) landValue = 0; + else landValue = Math.min(landValue * 32, 6000); + return landValue - 3000; + + }, + + residentialFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + // If we choose to grow this zone, we will fill it with an index in the range 0-3 reflecting the land value and + // pollution scores (higher is better). This is then used to select the variant to build + let lpValue; + // Notify the census + simData.census.resZonePop += 1; + + // Also, notify the census of our population + let tileValue = map.getTileValue(x, y); + let population = Residential.getZonePopulation(map, x, y, tileValue); + simData.census.resPop += population; + + let zonePower = map.getTile(x, y).isPowered(); + + let trafficOK = Micro.ROUTE_FOUND; + + // Occasionally check to see if the zone is connected to the road network. The chance of this happening increases + // as the zone's population increases. Note: we will never execute this conditional if the zone is empty, as zero + // will never be be bigger than any of the values Random will generate + if (population > math.getRandom(35)) { + // Is there a route from this zone to a commercial zone? + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isCommercial); + + // If we're not connected to the road network, then going shopping will be a pain. Move out. + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } + + // Sometimes we will randomly choose to assess this block. However, always assess it if it's empty or contains only single houses. + if (tileValue === Tile.FREEZ || math.getChance(7)) { + // First, score the individual zone. This is a value in the range -3000 to 3000 + // Then take into account global demand for housing. + let locationScore = Residential.evalResidential(simData.blockMaps, x, y, trafficOK); + let zoneScore = simData.valves.resValve + locationScore; + + // Naturally unpowered zones should be penalized + if (!zonePower) zoneScore = -500; + // The residential demand valve has range -2000 to 2000, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5500 - 5000. + + // Now, observe that if there are no roads we will never take this branch, as zoneScore will equal -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -20880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 81.8% of them are above -20880, so nearly 82% of the time, we will never take this branch. + // Thus, there's approximately a 9% chance that the value will be in the range, and we *might* grow. + //if (trafficOK && (zoneScore > -350) && ((zoneScore - 26380) > math.getRandom16Signed())) { + if (zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + // If this zone is empty, and residential demand is strong, we might make a hospital + //if (population === 0 && ((math.getRandom16() & 3) === 0)) { + if (population === 0 && math.getChance(3)) { + Residential.makeHospital(map, x, y, simData, zonePower); + return; + } + // Get an index in the range 0-3 scoring the land desirability and pollution, and grow the zone to the next + // population rank + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + // Again, given the above, zoneScore + 26380 must lie in the range 20880 - 26030. + // There is a 10.2% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 89.7% chance of the number being below 20880 thus never triggering this branch, which leaves a + // 0.1% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && ((zoneScore + 26380) < math.getRandom16Signed())) { + // Get an index in the range 0-3 scoring the land desirability and pollution, and degrade to the next + // lower ranked zone + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + }, + + makeHospital: function ( map, x, y, simData, zonePower ) { + if(!simData) simData = Micro.simData; + // We only build a hospital if the population requires it + if (simData.census.needHospital > 0) { + ZoneUtils.putZone(map, x, y, Tile.HOSPITAL, zonePower); + simData.census.needHospital = 0; + return; + } + }, + + hospitalFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData; + + simData.census.hospitalPop += 1; + // Degrade to an empty zone if a hospital is no longer sustainable + if (simData.census.needHospital === -1) { + if (math.getRandom(20) === 0) ZoneUtils.putZone(map, x, y, Tile.FREEZ, map.getTile(x, y).isPowered()); + } + } + +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +const Commercial = { + + registerHandlers: function( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isCommercialZone, Commercial.commercialFound ); + }, + + // Commercial tiles have 'populations' from 1 to 5, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + getZonePopulation: function(map, x, y, tileValue) { + //if (tileValue.isTile ) tileValue = new Tiles().getValue(); //COMCLEAR) + if (tileValue === Tile.COMCLR) return 0; + return Math.floor((tileValue - Tile.CZB) / 9) % 5 + 1; + + }, + + // Takes a map and coordinates, a population category in the range 1-5, a value category in the range 0-3, and places + // the appropriate industrial zone on the map + placeCommercial: function ( map, x, y, population, lpValue, zonePower ) { + var centreTile = ((lpValue * 5) + population) * 9 + Tile.CZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + + growZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + // landValueMap contains values in the range 0-250, representing the desirability of the land. + // Thus, after shifting, landValue will be in the range 0-7. + var landValue = blockMaps.landValueMap.worldGet(x, y); + landValue = landValue >> 5; + + if (population > landValue) return; + + // This zone is desirable, and seemingly not to crowded. Switch to the next category of zone. + if (population < 5) { + Commercial.placeCommercial(map, x, y, population, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function (map, x, y, blockMaps, populationCategory, lpCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) { + Commercial.placeCommercial(map, x, y, populationCategory - 2, lpCategory, zonePower); + } else { + ZoneUtils.putZone(map, x, y, Tile.COMCLR, zonePower); + } + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + + // Called by the map scanner when it finds the centre of an commercial zone + commercialFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + // lpValue will be filled if we actually decide to trigger growth/decay. It will be an index of the land/pollution + // value in the range 0-3 + var lpValue; + + // Notify the census + simData.census.comZonePop += 1; + + // Calculate the population level for this tile, and add to census + var tileValue = map.getTileValue(x, y); + var population = Commercial.getZonePopulation(map, x, y, tileValue); + simData.census.comPop += population; + + var zonePower = map.getTile(x, y).isPowered(); + + // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if consumers cannot reach the shops. + // Note in particular, we will never take this branch if the zone is empty. + var trafficOK = Micro.ROUTE_FOUND; + if (population > math.getRandom(5)) { + // Try to find a route from here to an industrial zone + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isIndustrial); + + // Trigger outward migration if not connected to road network + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } + + // Occasionally assess and perhaps modify the tile + if (math.getChance(7)) { + + var locationScore = trafficOK === Micro.NO_ROAD_FOUND ? -3000 : simData.blockMaps.cityCentreDistScoreMap.worldGet(x, y); + var zoneScore = simData.valves.comValve + locationScore; + + // Unpowered zones should of course be penalized + if (!zonePower) zoneScore = -500; + + // The commercial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5064 - 1564. (The comRateMap, which scores + // commercial neighbourhoods based on their distance from the city centre, has range -64 to 64). + + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24816. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.8% of them are above -24816, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 3% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + if (zonePower && zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + + // Again, given the above, zoneScore + 26380 must lie in the range 21316 - 27944. + // There is a 7.3% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 82.5% chance of the number being below 21316 thus never triggering this branch, which leaves a + // 10.1% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && (zoneScore + 26380) < math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + } +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const animated = [true, false, true, true, false, false, true, true]; +const xDelta = [-1, 0, 1, 0, 0, 0, 0, 1]; +const yDelta = [-1, 0, -1, -1, 0, 0, -1, -1]; + +const Industrial = { + + registerHandlers: function(mapScanner, repairManager) { + mapScanner.addAction( ZoneUtils.isIndustrialZone, Industrial.industrialFound ); + }, + + // Industrial tiles have 'populations' from 1 to 4, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + + getZonePopulation: function( map, x, y, tileValue ) { + + if (tileValue === Tile.INDCLR) return 0; + return Math.floor((tileValue - Tile.IZB) / 9) % 4 + 1; + + }, + + placeIndustrial: function(map, x, y, populationCategory, valueCategory, zonePower) { + var centreTile = ((valueCategory * 4) + populationCategory) * 9 + Tile.IZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + + growZone: function(map, x, y, blockMaps, population, valueCategory, zonePower) { + // Switch to the next category of zone + if (population < 4) { + Industrial.placeIndustrial(map, x, y, population, valueCategory, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function(map, x, y, blockMaps, populationCategory, valueCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) Industrial.placeIndustrial( map, x, y, populationCategory - 2, valueCategory, zonePower ); + else ZoneUtils.putZone(map, x, y, Tile.INDCLR, zonePower); + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + + + + // Takes a map and coordinates, the tile value of the centre of the zone, and a boolean indicating whether + // the zone has power, and sets or unsets the animation bit in the appropriate part of the zone + setAnimation: function(map, x, y, tileValue, isPowered) { + + if (tileValue < Tile.IZB) return; + // There are only 7 different types of populated industrial zones. + // As tileValue - IZB will never be 8x9 or more away from IZB, we + // can shift right by 3, and get the same effect as dividing by 9 + var i = (tileValue - Tile.IZB) >> 3; + + if (animated[i] && isPowered) { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.ASCBIT); + } else { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.BNCNBIT); + map.removeTileFlags(x + xDelta[i], y + yDelta[i], Tile.ANIMBIT); + } + }, + + industrialFound: function(map, x, y, simData) { + + if(!simData) simData = Micro.simData; + + simData.census.indZonePop += 1; + + // Calculate the population level for this tile, and add to census + var tileValue = map.getTileValue(x, y); + var population = Industrial.getZonePopulation( map, x, y, tileValue ); + simData.census.indPop += population; + + // Set animation bit if appropriate + var zonePower = map.getTile(x, y).isPowered(); + if(!simData.is3D) Industrial.setAnimation( map, x, y, tileValue, zonePower ); + + // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if workers cannot reach the factories. + // Note in particular, we will never take this branch if the zone is empty. + var trafficOK = Micro.ROUTE_FOUND; + if (population > math.getRandom(5)) { + // Try to find a route from here to a residential zone + trafficOK = simData.traffic.makeTraffic( x, y, simData.blockMaps, ZoneUtils.isResidential ); + + // Trigger outward migration if not connected to road network (unless the zone is already empty) + if (trafficOK === Micro.NO_ROAD_FOUND) { + var newValue = math.getRandom16() & 1; + Industrial.degradeZone(map, x, y, simData.blockMaps, population, newValue, zonePower); + return; + } + } + + // Occasionally assess and perhaps modify the tile + if (math.getChance(7)) { + var zoneScore = simData.valves.indValve + (trafficOK === Micro.NO_ROAD_FOUND ? -1000 : 0); + + // Unpowered zones should of course be penalized + if (!zonePower) zoneScore = -500; + + // The industrial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -3000 - 1500 + + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -1000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.9% of them are above -24880, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 2.9% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + if (zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + Industrial.growZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + return; + } + + // Again, given the above, zoneScore + 26380 must lie in the range 23380 - 27880. + // There is a 7.4% chance of getRandom16() always yielding a number > 27880 which would take this branch. + // There is a 85.6% chance of the number being below 23380 thus never triggering this branch, which leaves a + // 9% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && (zoneScore + 26380) < math.getRandom16Signed()) + Industrial.degradeZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + } + + } + +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const verticalDeltaX = [0, 1, 0, 0, 0, 0, 1]; +const verticalDeltaY = [-2, -2, -1, 0, 1, 2, 2]; +const horizontalDeltaX = [-2, 2, -2, -1, 0, 1, 2]; +const horizontalDeltaY = [ -1, -1, 0, 0, 0, 0, 0]; + +const openVertical = [ Tile.VBRDG0, Tile.VBRDG1, Tile.RIVER, Tile.BRWV, Tile.RIVER, Tile.VBRDG2, Tile.VBRDG3 ]; +const closeVertical = [ Tile.VBRIDGE, Tile.RIVER, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.RIVER ]; + +const openHorizontal = [ Tile.HBRDG1, Tile.HBRDG3, Tile.HBRDG0, Tile.RIVER, Tile.BRWH, Tile.RIVER, Tile.HBRDG2 ]; +const closeHorizontal = [ Tile.RIVER, Tile.RIVER, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE ]; +/* +const openVertical = [ + Tile.VBRDG0 | Tile.BULLBIT, Tile.VBRDG1 | Tile.BULLBIT, + Tile.RIVER, Tile.BRWV | Tile.BULLBIT, + Tile.RIVER, Tile.VBRDG2 | Tile.BULLBIT, Tile.VBRDG3 | Tile.BULLBIT +]; +const closeVertical = [ + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER +]; +const openHorizontal = [ + Tile.HBRDG1 | Tile.BULLBIT, Tile.HBRDG3 | Tile.BULLBIT, + Tile.HBRDG0 | Tile.BULLBIT, Tile.RIVER, Tile.BRWH | Tile.BULLBIT, + Tile.RIVER, Tile.HBRDG2 | Tile.BULLBIT +]; +const closeHorizontal = [ + Tile.RIVER, Tile.RIVER, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT +];*/ + +const densityTable = [Tile.ROADBASE, Tile.LTRFBASE, Tile.HTRFBASE]; + +const Road = { + + registerHandlers: function ( mapScanner, repairManager ) { + + mapScanner.addAction( ZoneUtils.isRoad, Road.roadFound ); + + }, + + openBridge: function ( map, origX, origY, xDelta, yDelta, oldTiles, newTiles ) { + + let i, x, y; + + for ( i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + if (map.testBounds(x, y)) { + if (map.getTileValue(x, y) === (oldTiles[i] & Tile.BIT_MASK)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + + closeBridge: function ( map, origX, origY, xDelta, yDelta, oldTiles, newTiles ) { + + let i, x, y, tileValue; + + for ( i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + if (map.testBounds(x, y)) { + tileValue = map.getTileValue(x, y); + if (tileValue === Tile.CHANNEL || (tileValue & 15) === (oldTiles[i] & 15)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + + doBridge: function ( map, x, y, currentTile, simData ) { + + //console.log( 'make bridge !!' ) + + if(!simData) simData = Micro.simData; + + if (currentTile === Tile.BRWV) { + // We have an open vertical bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) + Road.closeBridge(map, x, y, verticalDeltaX, verticalDeltaY, openVertical, closeVertical); + return true; + } + if (currentTile == Tile.BRWH) { + // We have an open horizontal bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) + Road.closeBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, openHorizontal, closeHorizontal); + return true; + } + if (simData.spriteManager.getBoatDistance(x, y) < 300 || math.getChance(7)) { + if (currentTile & 1) { + if (x < map.width - 1) { + if (map.getTileValue(x + 1, y) === Tile.CHANNEL) { + // We have a closed vertical bridge. Open it. + Road.openBridge(map, x, y, verticalDeltaX, verticalDeltaY, closeVertical, openVertical); + return true; + } + } + return false; + } else { + if (y > 0) { + if (map.getTileValue(x, y - 1) === Tile.CHANNEL) { + // We have a closed horizontal bridge. Open it. + Road.openBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, closeHorizontal, openHorizontal); + return true; + } + } + } + } + return false; + }, + + roadFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.roadTotal += 1; + let currentTile = map.getTile(x, y); + let tileValue = currentTile.getValue(); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + //currentTile = map.getTile(x, y); + + // Don't degrade tiles with power lines + if (!currentTile.isConductive()) { + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + //let mapValue = currentTile.getValue(); + + // Replace bridge tiles with water, otherwise rubble + if ((tileValue & 15) < 2 || (tileValue & 15) === 15) map.setTile(x, y, Tile.RIVER); + else map.setTo(x, y, ZoneUtils.randomRubble()); + return; + } + } + } + } + + // Bridges are not combustible + if (!currentTile.isCombustible()) { + // The comment in the original Micropolis code states bridges count for 4 + // However, with the increment above, it's actually 5. Bug? + simData.census.roadTotal += 4; + //if ( Road.doBridge(map, x, y, tileValue, simData)) return; + } + + // Examine traffic density, and modify tile to represent last scanned traffic + // density + let density = 0; + if (tileValue < Tile.LTRFBASE) { + density = 0; + } else if (tileValue < Tile.HTRFBASE) { + density = 1; + } else { + // Heavy traffic counts as two tiles with regards to upkeep cost + // Note, if this is heavy traffic on a bridge, and it wasn't handled above, + // it actually counts for 7 road tiles + simData.census.roadTotal += 1; + density = 2; + } + + // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + let currentDensity = simData.blockMaps.trafficDensityMap.worldGet(x, y) >> 6; + // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + if (currentDensity > 1) currentDensity -= 1; + if (currentDensity === density) return; + + let newValue = ((tileValue - Tile.ROADBASE) & 15) + densityTable[currentDensity]; + // Preserve all bits except animation + let newFlags = currentTile.getFlags() & ~Tile.ANIMBIT; + if (currentDensity > 0) newFlags |= Tile.ANIMBIT; + + map.setTo(x, y, new Tiles(newValue, newFlags)); + + } +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + + + +const Transport = { + + registerHandlers: function ( mapScanner, repairManager ) { + + mapScanner.addAction(ZoneUtils.isRail, Transport.railFound ); + mapScanner.addAction(Tile.PORT, Transport.portFound ); + mapScanner.addAction(Tile.AIRPORT, Transport.airportFound ); + + repairManager.addAction(Tile.PORT, 15, 4); + repairManager.addAction(Tile.AIRPORT, 7, 6); + + }, + + railFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.railTotal += 1; + simData.spriteManager.generateTrain(simData.census, x, y); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + let currentTile = map.getTile(x, y); + + // Don't degrade tiles with power lines + if (currentTile.isConductive()) return; + + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + let mapValue = currentTile.getValue(); + + // Replace bridge tiles with water, otherwise rubble + if ( mapValue < Tile.RAILBASE + 2 ) map.setTile( x, y, Tile.RIVER, 0 ); + else map.setTo( x, y, ZoneUtils.randomRubble() ); + } + } + } + }, + + airportFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.airportPop += 1; + + let tile = map.getTile(x, y); + if (tile.isPowered()) { + if (map.getTileValue(x + 1, y - 1) === Tile.RADAR) map.setTile(x + 1, y - 1, Tile.RADAR0, Tile.CONDBIT | Tile.ANIMBIT | Tile.BURNBIT); + if (math.getRandom(5) === 0) { + simData.spriteManager.generatePlane(x, y); + return; + } + if (math.getRandom(12) === 0) simData.spriteManager.generateCopter(x, y); + } else { + map.setTile(x + 1, y - 1, Tile.RADAR, Tile.CONDBIT | Tile.BURNBIT); + } + }, + + portFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.seaportPop += 1; + let tile = map.getTile(x, y); + if (tile.isPowered() && simData.spriteManager.getSprite( Micro.SPRITE_SHIP ) === null) simData.spriteManager.generateShip(); + + } +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +const handleService = function( censusStat, budgetEffect, blockMap ) { + + return function( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census[censusStat] += 1; + var effect = simData.budget[budgetEffect]; + var isPowered = map.getTile(x, y).isPowered(); + // Unpowered buildings are half as effective + if (!isPowered) effect = Math.floor(effect / 2); + + var pos = new Position(x, y); + var connectedToRoads = simData.traffic.findPerimeterRoad( pos ); + if (!connectedToRoads) effect = Math.floor(effect / 2); + + var currentEffect = simData.blockMaps[blockMap].worldGet(x, y); + currentEffect += effect; + simData.blockMaps[blockMap].worldSet(x, y, currentEffect); + } + +}; + +const EmergencyServices = { + + registerHandlers: function(mapScanner, repairManager) { + mapScanner.addAction(Tile.POLICESTATION, EmergencyServices.policeStationFound); + mapScanner.addAction(Tile.FIRESTATION, EmergencyServices.fireStationFound); + }, + + policeStationFound: handleService('policeStationPop', 'policeEffect', 'policeStationMap'), + fireStationFound: handleService('fireStationPop', 'fireEffect', 'fireStationMap') + +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. +* +* This code is released under the GNU GPL v3, with some additional terms. +* Please see the files LICENSE and COPYING for details. Alternatively, +* consult http://micropolisjs.graememcc.co.uk/LICENSE and +* http://micropolisjs.graememcc.co.uk/COPYING +* +*/ + +const xDelta$1 = [-1, 0, 1, 0 ]; +const yDelta$1 = [ 0, -1, 0, 1 ]; + + + +const MiscTiles = { + + registerHandlers: function( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isFire, MiscTiles.fireFound, true); + mapScanner.addAction(Tile.RADTILE, MiscTiles.radiationFound, true); + mapScanner.addAction(ZoneUtils.isFlood, MiscTiles.floodFound, true); + //mapScanner.addAction(ZoneUtils.isManualExplosion, MiscTiles.explosionFound, true); + }, + + fireFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.firePop += 1; + + if ((math.getRandom16() & 3) !== 0) return; + + let i, xTem, yTem, tile; + + // Try to set neighbouring tiles on fire as well + for ( i = 0; i < 4; i++) { + if (math.getChance(7)) { + xTem = x + xDelta$1[i]; + yTem = y + yDelta$1[i]; + if (map.testBounds(xTem, yTem)) { + tile = map.getTile(x, y); + if (!tile.isCombustible()) continue; + if (tile.isZone()) { + // Neighbour is a ione and burnable + ZoneUtils.fireZone(map, x, y, simData.blockMaps); + // Industrial zones etc really go boom + if (tile.getValue() > Tile.IZB) simData.spriteManager.makeExplosionAt(x, y); + } + map.setTo( ZoneUtils.randomFire() ); + } + } + } + + // Compute likelyhood of fire running out of fuel + let rate = 10; // Likelyhood of extinguishing (bigger means less chance) + i = simData.blockMaps.fireStationEffectMap.worldGet(x, y); + + if (i > 100) rate = 1; + else if (i > 20) rate = 2; + else if (i > 0) rate = 3; + + // Decide whether to put out the fire. + if ( math.getRandom(rate) === 0 ) map.setTo( x, y, ZoneUtils.randomRubble() ); + }, + + radiationFound: function ( map, x, y, simData ) { + if (math.getChance(4095)) map.setTile( x, y, Tile.DIRT, 0 ); + }, + + floodFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData; + simData.disasterManager.doFlood( x, y, simData.blockMaps ); + }, + + /*explosionFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + let tileValue = map.getTileValue(x, y); + map.setTo(x, y, ZoneUtils.randomRubble()); + return; + }*/ +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +const Stadia = { + + registerHandlers: function( mapScanner, repairManager ) { + + mapScanner.addAction( Tile.STADIUM, Stadia.emptyStadiumFound ); + mapScanner.addAction( Tile.FULLSTADIUM, Stadia.fullStadiumFound ); + repairManager.addAction( Tile.STADIUM, 15, 4 ); + + }, + + emptyStadiumFound: function( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.stadiumPop += 1; + + if (map.getTile(x, y).isPowered()) { + // Occasionally start the big game + if (((simData.cityTime + x + y) & 31) === 0) { + map.putZone(x, y, Tile.FULLSTADIUM, 4); + map.addTileFlags(x, y, Tile.POWERBIT); + map.setTo(x + 1, y, new Tiles(Tile.FOOTBALLGAME1, Tile.ANIMBIT)); + map.setTo(x + 1, y + 1, new Tiles(Tile.FOOTBALLGAME2, Tile.ANIMBIT)); + } + } + }, + + fullStadiumFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData; + + simData.census.stadiumPop += 1; + let isPowered = map.getTile(x, y).isPowered(); + + if (((simData.cityTime + x + y) & 7) === 0) { + map.putZone(x, y, Tile.STADIUM, 4); + if ( isPowered ) map.addTileFlags( x, y, Tile.POWERBIT ); + } + + } + +}; + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +class MapUtils { + + // Smooth the map src into dest. The way in which the map is smoothed depends on the value of smoothStyle. + // The meanings are as follows: + // + // SMOOTH_NEIGHBOURS_THEN_BLOCK + // ============================ + // For each square in src, sum the values of its immediate neighbours, and take the average, then take the average of + // that result and the square's value. This result is the new value of the square in dest. + // + // SMOOTH_ALL_THEN_CLAMP + // ===================== + // For each square in src, sum the values of that square and it's four immediate neighbours, and take an average + // rounding down. Clamp the resulting value in the range 0-255. This clamped value is the square's new value in dest. + static smoothMap ( src, dest, smoothStyle ) { + + let x = src.width, y, edges; + + while( x-- ){ + y = src.height; + while( y-- ){ + + edges = 0; + if (x > 0) edges += src.get(x - 1, y); + if (x < src.width - 1) edges += src.get(x + 1, y); + if (y > 0) edges += src.get(x, y - 1); + if (y < src.height - 1) edges += src.get(x, y + 1); + + if (smoothStyle === Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK) { + edges = src.get(x, y) + Math.floor(edges / 4); + dest.set(x, y, Math.floor(edges/2)); + } else { + edges = (edges + src.get(x, y)) >> 2; + if (edges > 255) edges = 255; + dest.set(x, y, edges); + } + } + } + + } + + // Over time, the rate of growth of a neighbourhood should trend towards zero (stable) + static neutraliseRateOfGrowthMap ( blockMaps ) { + + let bm = blockMaps.rateOfGrowthMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height; + while( y-- ){ + + value = bm.get( x, y ); + + if (value !== 0){ + if (value > 0) value--; + else value++; + + value = math.clamp( value, -200, 200 ); + bm.set( x, y, value ); + } + } + } + } + + // Over time, traffic density should ease. + static neutraliseTrafficMap ( blockMaps ) { + + let bm = blockMaps.trafficDensityMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height; + while( y-- ){ + + value = bm.get(x, y); + + if (value !== 0){ + if (value <= 24) value = 0; + else if (value > 200) value = value - 34; + else value = value - 24; + bm.set(x, y, value); + } + } + } + + } + + // Given a tileValue, score it on the pollution it generates, in the range 0-255 + static getPollutionValue ( tileValue ) { + + if (tileValue < Tile.POWERBASE) { + // Roads, fires and radiation lie below POWERBASE + + // Heavy traffic is bad + if (tileValue >= Tile.HTRFBASE) return 75; + // Low traffic not so much + if (tileValue >= Tile.LTRFBASE) return 50; + + if (tileValue < Tile.ROADBASE) { + // Fire = carbon monoxide = a bad score for you + if (tileValue > Tile.FIREBASE) return 90; + // Radiation. Top of the charts. + if (tileValue >= Tile.RADTILE) return 255; + } + + // All other types of ground are pure. + return 0; + } + + // If we've reached this point, we're classifying some form of zone tile + + // Residential and commercial zones don't pollute + if (tileValue <= Tile.LASTIND) return 0; + // Industrial zones, however... + if (tileValue < Tile.PORTBASE) return 50; + // Coal power plants are bad + if (tileValue <= Tile.LASTPOWERPLANT) return 100; + + return 0; + + } + + // Compute the Manhattan distance of the given point from the city centre, and force into the range 0-64 + static getCityCentreDistance ( map, x, y ) { + + let xDis, yDis; + if ( x > map.cityCentreX ) xDis = x - map.cityCentreX; + else xDis = map.cityCentreX - x; + if ( y > map.cityCentreY ) yDis = y - map.cityCentreY; + else yDis = map.cityCentreY - y; + return Math.min(xDis + yDis, 64); + + } + + // This monster function fills up the landValueMap, the terrainDensityMap and the pollutionDensityMap based + // on values found by iterating over the map. + // + // Factors that affect land value: + // * Distance from the city centre + // * High crime + // * High pollution + // * Proximity to undeveloped terrain (who doesn't love a good view?) + // + // Pollution is completely determined by the tile types in the block + static pollutionTerrainLandValueScan ( map, census, blockMaps ) { + + // We record raw pollution readings for each tile into tempMap1, and then use tempMap2 and tempMap1 to smooth + // out the pollution in order to construct the new values for the populationDensityMap + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; + // tempMap3 will be used to record raw terrain information, i.e. if the the land is developed. This will be + // smoothed in to terrainDensityMap later + let tempMap3 = blockMaps.tempMap3; + tempMap3.clear(); + + let landValueMap = blockMaps.landValueMap; + let terrainDensityMap = blockMaps.terrainDensityMap; + let pollutionDensityMap = blockMaps.pollutionDensityMap; + let crimeRateMap = blockMaps.crimeRateMap; + + let totalLandValue = 0; + let developedTileCount = 0; + + let x = landValueMap.width, y, pollutionLevel, developed, worldX, worldY, mapX, mapY, tileValue, terrainValue, landValue; + + while( x-- ){ + y = landValueMap.height; + while( y-- ){ + + pollutionLevel = 0; + developed = false; + + // The land value map has a chunk size of 2 + worldX = x * 2; + worldY = y * 2; + + for ( mapX = worldX; mapX <= worldX + 1; mapX++) { + for ( mapY = worldY; mapY <= worldY + 1; mapY++) { + + + tileValue = map.getTileValue( mapX, mapY ); + if (tileValue === Tile.DIRT) continue; + + if (tileValue < Tile.RUBBLE) { + // Undeveloped land: record in tempMap3. Each undeveloped piece of land scores 15. + // tempMap3 has a chunk size of 4, so each square in tempMap3 will ultimately contain a + // maximum value of 240 + terrainValue = tempMap3.worldGet(mapX, mapY); + tempMap3.worldSet(mapX, mapY, terrainValue + 15); + continue; + } + + pollutionLevel += MapUtils.getPollutionValue(tileValue); + if (tileValue >= Tile.ROADBASE) { + developed = true; + } + + } + } + + pollutionLevel = Math.min(pollutionLevel, 255); + tempMap1.set(x, y, pollutionLevel); + + if (developed) { + landValue = 34 - Math.floor(MapUtils.getCityCentreDistance(map, worldX, worldY) / 2); + landValue = landValue << 2; + // Land in the same neighbourhood as unspoiled land is more valuable... + landValue += terrainDensityMap.get(x >> 1, y >> 1); + // ... and polluted land obviously is less valuable + landValue -= pollutionDensityMap.get(x, y); + // ... getting mugged won't help either + if (crimeRateMap.get(x, y) > 190) { landValue -= 20; } + // Clamp in range 1-250 (0 represents undeveloped land) + landValue = math.clamp(landValue, 1, 250); + landValueMap.set(x, y, landValue); + + totalLandValue += landValue; + developedTileCount++; + } else { + landValueMap.set(x, y, 0); + } + } + } + + if (developedTileCount > 0) census.landValueAverage = Math.floor(totalLandValue / developedTileCount); + else census.landValueAverage = 0; + + // Smooth the pollution map twice + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + + let maxPollution = 0; + let pollutedTileCount = 0; + let totalPollution = 0; + let pollution; + + // We iterate over the now-smoothed pollution map rather than using the block map's copy routines + // so that we can compute the average and total pollution en-route + for (x = 0; x < map.width; x += pollutionDensityMap.blockSize) { + for (y = 0; y < map.height; y += pollutionDensityMap.blockSize) { + // Copy the values into pollutionDensityMap + pollution = tempMap1.worldGet(x, y); + pollutionDensityMap.worldSet(x, y, pollution); + + if (pollution !== 0) { + pollutedTileCount++; + totalPollution += pollution; + + // Note the most polluted location: any monsters will be drawn there (randomly choosing one + // if we have multiple competitors for most polluted) + if (pollution > maxPollution || (pollution === maxPollution && math.getChance(3))) { + maxPollution = pollution; + map.pollutionMaxX = x; + map.pollutionMaxY = y; + } + } + } + } + + if (pollutedTileCount) census.pollutionAverage = Math.floor(totalPollution / pollutedTileCount); + else census.pollutionAverage = 0; + + MapUtils.smoothMap(tempMap3, terrainDensityMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + } + + // Computes the coverage radius of police stations, and scores each neighbourhood in the map on its crime rate. + // Factors that attract crime are: + // * The zone has a low value + // * The zone is a slum + // * The zone is far away from those pesky police + static crimeScan ( census, blockMaps ) { + + let policeStationMap = blockMaps.policeStationMap; + let policeStationEffectMap = blockMaps.policeStationEffectMap; + let crimeRateMap = blockMaps.crimeRateMap; + let landValueMap = blockMaps.landValueMap; + let populationDensityMap = blockMaps.populationDensityMap; + + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationEffectMap, policeStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + let totalCrime = 0; + let crimeZoneCount = 0; + + let x, y, width = crimeRateMap.mapWidth, height = crimeRateMap.mapHeight, value; + + // Scan the map, looking for developed land, as it can attract crime. + for ( x = 0; x < width; x += blockSize ) { + for ( y = 0; y < height; y += blockSize ) { + // Remember: landValueMap values are in the range 0-250 + value = landValueMap.worldGet(x, y); + + if (value > 0) { + + crimeZoneCount += 1; + // Force value in the range -122 to 128. Lower valued pieces of land attract more crime. + value = 128 - value; + // Add population density (a value between 0 and 510). value now lies in range -260 - 382. + // Denser areas attract more crime. + value += populationDensityMap.worldGet(x, y); + // Clamp in range -260 to 300 + value = Math.min(value, 300); + // If the police are nearby, there's no point committing the crime of the century + value -= policeStationMap.worldGet(x, y); + // Force in to range 0-250 + value = math.clamp(value, 0, 250); + + crimeRateMap.worldSet(x, y, value); + totalCrime += value; + + } else { + + crimeRateMap.worldSet(x, y, 0); + + } + } + } + + if ( crimeZoneCount > 0 ) census.crimeAverage = Math.floor(totalCrime / crimeZoneCount); + else census.crimeAverage = 0; + + } + + // Iterate over the map, and score each neighbourhood on its distance from the city centre. Scores are in the range + // -64 to 64. This affects the growth of commercial zones within that neighbourhood. + static fillCityCentreDistScoreMap ( map, blockMaps ) { + + let bm = blockMaps.cityCentreDistScoreMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height; + while( y-- ){ + // First, we compute the Manhattan distance of the top-left hand corner of the neighbourhood to the city centre + // and half that value. This leaves us a value in the range 0 - 32 + value = Math.floor(MapUtils.getCityCentreDistance(map, x * 8, y * 8) / 2); + // Now, we scale up by a factor of 4. We're in the range 0 - 128 + value = value * 4; + // And finally, subtract from 64, leaving us a score in the range -64 to 64 + value = 64 - value; + bm.set(x, y, value); + } + } + }; + + // Dispatch to the correct zone type to get the population value for that zone + static getPopulationDensity ( map, x, y, tile ) { + + if (tile < Tile.COMBASE) return Residential.getZonePopulation(map, x, y, tile); + if (tile < Tile.INDBASE) return Commercial.getZonePopulation(map, x, y, tile) * 8; + if (tile < Tile.PORTBASE) return Industrial.getZonePopulation(map, x, y, tile) * 8; + return 0; + + } + + // Iterate over the map, examining each zone for population. We then smooth the results into a population density + // map, which is used when deciding to grow residential zones. At the same time, we also note the most populous area + // (in terms of zones) to calculate our city centre. Finally, we score each area of the map on its distance from the + // city centre. + static populationDensityScan ( map, blockMaps ) { + + // We will build the initial unsmoothed map in tempMap1, and smooth it in to tempMap2 + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; + blockMaps.populationDensityMap; + + // We will sum all the coordinates that contain zones into xTot and yTot. They are used in our city centre heuristic. + let Xtot = 0; + let Ytot = 0; + let zoneTotal = 0; + + tempMap1.clear(); + + let x = map.width, y, tile, tileValue, population; + + while( x-- ){ + y = map.height; + while( y-- ){ + + tile = map.getTile(x, y); + if (tile.isZone()) { + + tileValue = tile.getValue(); + + // Ask the zone to calculate its population, scale it up, then clamp in the range 0-254 + population = MapUtils.getPopulationDensity(map, x, y, tileValue) * 8; + population = Math.min(population, 254); + + // The block size of population density is 2x2, so there can only be 1 zone per block + tempMap1.worldSet(x, y, population); + Xtot += x; + Ytot += y; + zoneTotal++; + + } + } + } + + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + + blockMaps.populationDensityMap.copyFrom(tempMap2, function(x) {return x * 2;}); + + // XXX This follows the original Micropolis source, but it feels weird to me that we score the entire map + // based on city centre proximity, and then potentially move the city centre. I think these should be + // swapped. + MapUtils.fillCityCentreDistScoreMap( map, blockMaps ); + + // Compute new city center + if (zoneTotal > 0) { + map.cityCentreX = Math.floor(Xtot / zoneTotal); + map.cityCentreY = Math.floor(Ytot / zoneTotal); + } else { + map.cityCentreX = Math.floor(map.width * 0.5); + map.cityCentreY = Math.floor(map.height * 0.5); + } + } + + // Compute the radius of coverage for the firestations found during the map scan + static fireAnalysis ( blockMaps ) { + + let fireStationMap = blockMaps.fireStationMap; + let fireStationEffectMap = blockMaps.fireStationEffectMap; + + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationEffectMap, fireStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ + +class Simulation { + + constructor ( gameMap, gameLevel, speed, is3D, savedGame ) { + + if (gameLevel !== Micro.LEVEL_EASY && gameLevel !== Micro.LEVEL_MED && gameLevel !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); + // if (speed !== Micro.SPEED_PAUSED && speed !== Micro.SPEED_SLOW && speed !== Micro.SPEED_MED && speed !== Micro.SPEED_FAST) throw new Error('Invalid speed!'); + + this.map = gameMap; + this.gameLevel = gameLevel; + + this.div = this.map.width / 8; + + this.is3D = is3D || false; + + this.time = typeof performance === 'undefined' ? Date : performance; + + this.speed = speed; + this.speedCycle = 0; + this.phaseCycle = 0; + this.simCycle = 0; + this.doInitialEval = true; + this.cityTime = 50; + this.cityPopLast = 0; + this.messageLast = Messages.VILLAGE_REACHED; + this.startingYear = 1900; + + // Last valves updated to the user + this.resValveLast = 0; + this.comValveLast = 0; + this.indValveLast = 0; + + // Last date sent to front end + this._cityYearLast = -1; + this._cityMonthLast = -1; + + // Last time we relayed a message from PowerManager to the front-end + this._lastPowerMessage = null; + + this.infos = []; + + // And now, the main cast of characters + this.evaluation = new Evaluation( this.gameLevel ); + this.valves = new Valves(); + this.budget = new Budget(); + this.census = new Census(); + this.powerManager = new PowerManager( this.map ); + this.spriteManager = new SpriteManager( this.map ); + this.mapScanner = new MapScanner(this.map); + this.repairManager = new RepairManager(this.map); + this.traffic = new Traffic(this.map, this.spriteManager); + this.disasterManager = new DisasterManager(this.map, this.spriteManager, this.gameLevel); + + this.messageManager = new MessageManager(); + Micro.messageManager = this.messageManager; + + let w = this.map.width, h = this.map.height; + + this.blockMaps = { + + // Holds a "distance score" for the block from the city centre, range -64 to 64 + cityCentreDistScoreMap: new BlockMap( w, h, 8), + + // Holds a score representing how dangerous an area is, in range 0-250 (larger is worse) + crimeRateMap: new BlockMap( w, h, 2), + + // A map used to note positions of fire stations during the map scan, range 0-1000 + fireStationMap: new BlockMap( w, h, 8), + // Holds a value containing a score representing the effect of fire cover in this neighborhood, range 0-1000 + fireStationEffectMap: new BlockMap( w, h, 8), + + // Holds scores representing the land value in the range 0-250 + landValueMap: new BlockMap( w, h, 2), + + // A map used to note positions of police stations during the map scan, range 0-1000 + policeStationMap: new BlockMap( w, h, 8), + // Holds a value containing a score representing how much crime is dampened in this block, range 0-1000 + policeStationEffectMap: new BlockMap( w, h, 8), + + // Holds a value representing the amount of pollution in a neighbourhood, in the range 0-255 + pollutionDensityMap: new BlockMap( w, h, 2), + + // Holds a value representing population density of a block, in the range 0-510 + populationDensityMap: new BlockMap( w, h, 2), + + // Holds a value representing the rate of growth of a neighbourhood in the range -200 to +200 + rateOfGrowthMap: new BlockMap( w, h, 8), + + // Scores a block on how undeveloped/unspoilt it is, range 0-240 + terrainDensityMap: new BlockMap( w, h, 4), + // Scores the volume of traffic in this cluster, range 0-240 + trafficDensityMap: new BlockMap( w, h, 2), + + // Temporary maps + tempMap1: new BlockMap( w, h, 2), + tempMap2: new BlockMap( w, h, 2), + tempMap3: new BlockMap( w, h, 4) + + }; + + this.clearCensus(); + + if (savedGame) { + this.load(savedGame); + //this.cityPopLast = savedGame.totalPop; + } else { + this.budget.setFunds( 20000 ); + this.census.totalPop = 1; + } + + Micro.simData = this; + + this.init(); + + } + + + save ( saveData ) { + + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) + saveData[Micro.savePropsVar[i]] = this[Micro.savePropsVar[i]]; + + this.map.save(saveData); + this.evaluation.save(saveData); + this.valves.save(saveData); + this.budget.save(saveData); + this.census.save(saveData); + + } + + load (saveData) { + //console.log(saveData) + this.messageManager.clear(); + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) + this[Micro.savePropsVar[i]] = saveData[Micro.savePropsVar[i]]; + + //this.map.load(saveData); + this.evaluation.load(saveData); + this.valves.load(saveData); + this.budget.load(saveData); + this.census.load(saveData); + + } + + setSpeed (s) { + this.speed = s; + } + + setDifficulty(s) { + + if (s !== Micro.LEVEL_EASY && s !== Micro.LEVEL_MED && s !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); + this.gameLevel = s; + this.disasterManager.setDifficulty( this.gameLevel ); + + } + + isPaused () { + + return this.speed === Micro.SPEED_PAUSED; + + } + + simTick () { + + let up = this.simFrame(); + + if(up){ + this.updateTime(); + this.updateInfo(); + } + + return up; + + } + + updateInfo(){ + + this.infos[0] = [TXT.months[ this._cityMonthLast ], this._cityYearLast].join(' '); + + this.infos[1] = TXT.cityClass[this.evaluation.cityScore]; + this.infos[2] = this.evaluation.cityScore; + this.infos[3] = this.evaluation.cityPop; + + this.infos[4] = this.budget.totalFunds; + this.infos[5] = this.valves.resValve; + this.infos[6] = this.valves.comValve; + this.infos[7] = this.valves.indValve; + + //this.infos[8] = '' // message + + this.infos[9] = this.map.powerChange; + this.map.powerChange = false; + + return this.infos + + } + + simFrame () { + + if ( this.budget.awaitingValues ) return false; + + if ( this.speed === Micro.SPEED_PAUSED ) return false; + + // Default to slow speed + let threshold = 100; + if (this.speed === Micro.SPEED_MED ) threshold = 50; + if (this.speed === Micro.SPEED_FAST ) threshold = 10; + if (this.speed === Micro.SPEED_ULTRA ) threshold = 5; + + let now = this.time.now();//new Date() + if ( now - this.prevTime < threshold ) return false; + + this.messageManager.clear(); + + this.simulate(); + this.prevTime = now; + return true + + } + + clearCensus () { + this.census.clearCensus(); + this.powerManager.clearPowerStack(); + this.blockMaps.fireStationMap.clear(); + this.blockMaps.policeStationMap.clear(); + } + + init () { + + this.prevTime = -1; + + + // Register actions + this.powerManager.registerHandlers(this.mapScanner, this.repairManager); + Commercial.registerHandlers(this.mapScanner, this.repairManager); + EmergencyServices.registerHandlers(this.mapScanner, this.repairManager); + Industrial.registerHandlers(this.mapScanner, this.repairManager); + MiscTiles.registerHandlers(this.mapScanner, this.repairManager); + Road.registerHandlers(this.mapScanner, this.repairManager); + Residential.registerHandlers(this.mapScanner, this.repairManager); + Stadia.registerHandlers(this.mapScanner, this.repairManager); + Transport.registerHandlers(this.mapScanner, this.repairManager); + + + this.evaluation.evalInit(); + this.valves.setValves(this.gameLevel, this.census, this.budget); + this.clearCensus(); + //this.mapScanner.mapScan(0, this.map.width, simData); + this.mapScanner.mapScan(0, this.map.width, null); + this.powerManager.doPowerScan(this.census); + + MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); + MapUtils.crimeScan(this.census, this.blockMaps); + MapUtils.populationDensityScan(this.map, this.blockMaps); + MapUtils.fireAnalysis(this.blockMaps); + //this.census.totalPop = 1; + + // if (savedGame) this.load(savedGame); + } + + simulate () { + + this.phaseCycle &= 15; + + let speedIndex = this.speed - 1; + switch (this.phaseCycle){ + case 0: + if (++this.simCycle > 1023) this.simCycle = 0; + if (this.doInitialEval) { this.doInitialEval = false; this.evaluation.cityEvaluation(); } + this.cityTime++; + if ((this.simCycle & 1) === 0) this.valves.setValves( this.gameLevel, this.census, this.budget ); + this.clearCensus(); + break; + case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: + this.mapScanner.mapScan((this.phaseCycle - 1) * this.div, this.phaseCycle * this.div, null); + break; + case 9: + if (this.cityTime % Micro.CENSUS_FREQUENCY_10 === 0) this.census.take10Census(this.budget); + if (this.cityTime % Micro.CENSUS_FREQUENCY_120 === 0) this.census.take120Census(this.budget); + if (this.cityTime % Micro.TAX_FREQUENCY === 0) { this.budget.collectTax( this.gameLevel, this.census ); this.evaluation.cityEvaluation(); } break; + case 10: if ((this.simCycle % 5) === 0){ MapUtils.neutraliseRateOfGrowthMap(this.blockMaps);} MapUtils.neutraliseTrafficMap(this.blockMaps); this.sendMessages(); break; + case 11: if ((this.simCycle % Micro.speedPowerScan[speedIndex]) === 0) this.powerManager.doPowerScan(this.census); break; + case 12: if ((this.simCycle % Micro.speedPollutionTerrainLandValueScan[speedIndex]) === 0) MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); break; + case 13: if ((this.simCycle % Micro.speedCrimeScan[speedIndex]) === 0) MapUtils.crimeScan(this.census, this.blockMaps); break; + case 14: if ((this.simCycle % Micro.speedPopulationDensityScan[speedIndex]) === 0) MapUtils.populationDensityScan(this.map, this.blockMaps); break; + case 15: if ((this.simCycle % Micro.speedFireAnalysis[speedIndex]) === 0) MapUtils.fireAnalysis(this.blockMaps); this.disasterManager.doDisasters(this.census ); break; + } + // Go on the the next phase. + this.phaseCycle = (this.phaseCycle + 1) & 15; + } + + sendMessages () { + + this.checkGrowth(); + let totalZonePop = this.census.resZonePop + this.census.comZonePop + this.census.indZonePop; + let powerPop = this.census.nuclearPowerPop + this.census.coalPowerPop; + switch (this.cityTime & 63) { + case 1: if (Math.floor(totalZonePop / 4) >= this.census.resZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_RESIDENTIAL); break; + case 5: if (Math.floor(totalZonePop / 8) >= this.census.comZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_COMMERCIAL); break; + case 10: if (Math.floor(totalZonePop / 8) >= this.census.indZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_INDUSTRIAL); break; + case 14: if (totalZonePop > 10 && totalZonePop * 2 > this.census.roadTotal) this.messageManager.sendMessage(Messages.NEED_MORE_ROADS); break; + case 18: if (totalZonePop > 50 && totalZonePop > this.census.railTotal) this.messageManager.sendMessage(Messages.NEED_MORE_RAILS); break; + case 22: if (totalZonePop > 10 && powerPop == 0) this.messageManager.sendMessage(Messages.NEED_ELECTRICITY); break; + case 26: if (this.census.resPop > 500 && this.census.stadiumPop === 0) { this.messageManager.sendMessage(Messages.NEED_STADIUM); this.valves.resCap = true; } else { this.valves.resCap = false;} break; + case 28: if (this.census.indPop > 70 && this.census.seaportPop === 0) { this.messageManager.sendMessage(Messages.NEED_SEAPORT); this.valves.indCap = true; } else { this.valves.indCap = false; } break; + case 30: if (this.census.comPop > 100 && this.census.airportPop === 0) { this.messageManager.sendMessage(Messages._NEED_AIRPORT); this.valves.comCap = true; } else { this.valves.comCap = false; } break; + case 32: let zoneCount = this.census.unpoweredZoneCount + this.census.poweredZoneCount; if (zoneCount > 0) { if (this.census.poweredZoneCount / zoneCount < 0.7) this.messageManager.sendMessage(Messages.BLACKOUTS_REPORTED);} break; + case 35: if (this.census.pollutionAverage > 60) this.messageManager.sendMessage(Messages.HIGH_POLLUTION); break; + case 42: if (this.census.crimeAverage > 100) this.messageManager.sendMessage(Messages.HIGH_CRIME); break; + case 45: if (this.census.totalPop > 60 && this.census.fireStationPop === 0) this.messageManager.sendMessage(Messages.NEED_FIRE_STATION); break; + case 48: if (this.census.totalPop > 60 && this.census.policeStationPop === 0) this.messageManager.sendMessage(Messages.NEED_POLICE_STATION); break; + case 51: if (this.budget.cityTax > 12) this.messageManager.sendMessage(Messages.TAX_TOO_HIGH); break; + case 54: if (this.budget.roadEffect < Math.floor(5 * this.budget.MAX_ROAD_EFFECT / 8) && this.census.roadTotal > 30) this.messageManager.sendMessage(Messages.ROAD_NEEDS_FUNDING); break; + case 57: if (this.budget.fireEffect < Math.floor(7 * this.budget.MAX_FIRE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.FIRE_STATION_NEEDS_FUNDING); break; + case 60: if (this.budget.policeEffect < Math.floor(7 * this.budget.MAX_POLICE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.POLICE_NEEDS_FUNDING); break; + case 63: if (this.census.trafficAverage > 60) this.messageManager.sendMessage(Messages.TRAFFIC_JAMS, -1, -1, true); break; + } + } + + checkGrowth () { + + if ((this.cityTime & 3) !== 0) return; + + let message = ''; + let cityPop = this.evaluation.getPopulation(this.census); + + if ( cityPop !== this.cityPopLast ) { + let lastClass = this.evaluation.getCityClass(this.cityPopLast); + let newClass = this.evaluation.getCityClass(cityPop); + if (lastClass !== newClass) { + switch (newClass) { + case Micro.CC_VILLAGE: + // Don't mention it. + break; + case Micro.CC_TOWN: message = Messages.REACHED_TOWN; break; + case Micro.CC_CITY: message = Messages.REACHED_CITY; break; + case Micro.CC_CAPITAL: message = Messages.REACHED_CAPITAL; break; + case Micro.CC_METROPOLIS: message = Messages.REACHED_METROPOLIS; break; + case Micro.CC_MEGALOPOLIS: message = Messages.REACHED_MEGALOPOLIS; break; + } + } + } + if (message !== '' && message !== this.messageLast) { + this.messageManager.sendMessage(message); + this.messageLast = message; + } + this.cityPopLast = cityPop; + + } + + // update date + + setYear (year) { + if (year < this.startingYear) year = this.startingYear; + year = (year - this.startingYear) - (this.cityTime / 48); + this.cityTime += year * 48; + this.updateTime(); + } + + updateTime () { + + let megalinium = 1000000; + let cityYear = Math.floor(this.cityTime / 48) + this.startingYear; + let cityMonth = Math.floor(this.cityTime % 48) >> 2; + + if (cityYear >= megalinium) { + this.setYear(this.startingYear); + return; + } + + if (this._cityYearLast !== cityYear || this._cityMonthLast !== cityMonth) { + this._cityYearLast = cityYear; + this._cityMonthLast = cityMonth; + this.messageManager.sendMessage(Messages.DATE_UPDATED, {month: cityMonth, year: cityYear}); + } + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class TileHistory { + + constructor () { + + this.clear(); + + } + + clear () { + + this.data = {}; + + } + + toKey ( x, y ) { + + return [x, y].join(','); + + } + + getTile ( x, y ) { + + let key = this.toKey( x, y ); + return this.data[key]; + + } + + setTile ( x, y, value ) { + + let key = this.toKey( x, y ); + this.data[key] = value; + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +//import { TileUtils } from './tileUtils'; + +class AnimationManager { + + constructor ( map, animationPeriod, blinkPeriod ) { + + animationPeriod = animationPeriod || 5; + blinkPeriod = blinkPeriod || 30; + + this._map = map; + this.animationPeriod = animationPeriod; + this.blinkPeriod = blinkPeriod; + this.shouldBlink = false; + this.count = 1; + + // When painting we keep track of what frames + // have been painted at which map coordinates so we can + // consistently display the correct frame even as the + // canvas moves + this._lastPainted = null; + + this._data = []; + this.initArray(); + this.registerAnimations(); + + } + + initArray () { + // Map all tiles to their own value in case we ever + // look up a tile that is not animated + for (let i = 0; i < Tile.TILE_COUNT; i++) this._data[i] = i; + } + + inSequence(tileValue, lastValue) { + // It is important that we use the base value as the starting point + // rather than the last painted value: base values often don't recur + // in their sequences + let seen = [tileValue]; + let current = this._data[tileValue]; + + while (seen.indexOf(current) === -1) { + if (current === lastValue) return true; + + seen.push(current); + current = this._data[current]; + } + return false; + } + + getTiles( startX, startY, boundX, boundY, isPaused = false ) { + + let shouldChangeAnimation = false; + + if (!isPaused) this.count += 1; + + if ((this.count % this.blinkPeriod) === 0) this.shouldBlink = !this.shouldBlink; + + if ((this.count % this.animationPeriod) === 0 && !isPaused) shouldChangeAnimation = true; + + let newPainted = new TileHistory(); + let tilesToPaint = []; + + for (let x = startX; x < boundX; x++) { + for (let y = startY; y < boundY; y++) { + if (x < 0 || x >= this._map.width || y < 0 || y >= this._map.height) continue; + + let tile = this._map.getTile(x, y); + /*if (tile.isZone() && !tile.isPowered() && this.shouldBlink) { + tilesToPaint.push({x: x, y: y, tileValue: Tile.LIGHTNINGBOLT}); + continue; + }*/ + + if (!tile.isAnimated()) continue; + + let tileValue = tile.getValue(); + let newTile = Tile.TILE_INVALID; + let last; + + if (this._lastPainted) last = this._lastPainted.getTile(x, y); + + if (shouldChangeAnimation) { + // Have we painted any of this sequence before? If so, paint the next tile + if (last && this.inSequence(tileValue, last)) { + + + newTile = this._data[last]; + + if (last === Tile.LASTTINYEXP) { + this._map.setTo( x, y, ZoneUtils.randomRubble() ); + newTile = this._map.getTileValue(x, y); + } else { + newTile = this._data[last]; + } + + + } else { + // Either we haven't painted anything here before, or the last tile painted + // there belongs to a different tile's animation sequence + newTile = this._data[tileValue]; + } + } else { + // Have we painted any of this sequence before? If so, paint the same tile + if (last && this.inSequence(tileValue, last)) newTile = last; + } + + if (newTile === Tile.TILE_INVALID) continue; + + tilesToPaint.push({x: x, y: y, tileValue: newTile}); + newPainted.setTile(x, y, newTile); + + this._map.setPaintValue(x, y, newTile); /// DIRECT SET TEXTURES + } + } + this._lastPainted = newPainted; + return tilesToPaint; + } + + registerSingleAnimation (arr) { + for (let i = 1; i < arr.length; i++) this._data[arr[i - 1]] = arr[i]; + } + + registerAnimations () { + + this.registerSingleAnimation([56, 57, 58, 59, 60, 61, 62, 63, 56]);// fire + this.registerSingleAnimation([860, 861, 862, 863, 864, 865, 866, 867]);// explosion + + + + // traffic + + this.registerSingleAnimation([80, 128, 112, 96, 80]); + this.registerSingleAnimation([81, 129, 113, 97, 81]); + this.registerSingleAnimation([82, 130, 114, 98, 82]); + this.registerSingleAnimation([83, 131, 115, 99, 83]); + this.registerSingleAnimation([84, 132, 116, 100, 84]); + this.registerSingleAnimation([85, 133, 117, 101, 85]); + this.registerSingleAnimation([86, 134, 118, 102, 86]); + this.registerSingleAnimation([87, 135, 119, 103, 87]); + this.registerSingleAnimation([88, 136, 120, 104, 88]); + this.registerSingleAnimation([89, 137, 121, 105, 89]); + this.registerSingleAnimation([90, 138, 122, 106, 90]); + this.registerSingleAnimation([91, 139, 123, 107, 91]); + this.registerSingleAnimation([92, 140, 124, 108, 92]); + this.registerSingleAnimation([93, 141, 125, 109, 93]); + this.registerSingleAnimation([94, 142, 126, 110, 94]); + this.registerSingleAnimation([95, 143, 127, 111, 95]); + + this.registerSingleAnimation([144, 192, 176, 160, 144]); + this.registerSingleAnimation([145, 193, 177, 161, 145]); + this.registerSingleAnimation([146, 194, 178, 162, 146]); + this.registerSingleAnimation([147, 195, 179, 163, 147]); + this.registerSingleAnimation([148, 196, 180, 164, 148]); + this.registerSingleAnimation([149, 197, 181, 165, 149]); + this.registerSingleAnimation([150, 198, 182, 166, 150]); + this.registerSingleAnimation([151, 199, 183, 167, 151]); + this.registerSingleAnimation([152, 200, 184, 168, 152]); + this.registerSingleAnimation([153, 201, 185, 169, 153]); + this.registerSingleAnimation([154, 202, 186, 170, 154]); + this.registerSingleAnimation([155, 203, 187, 171, 155]); + this.registerSingleAnimation([156, 204, 188, 172, 156]); + this.registerSingleAnimation([157, 205, 189, 173, 157]); + this.registerSingleAnimation([158, 206, 190, 174, 158]); + this.registerSingleAnimation([159, 207, 191, 175, 159]); +/* + // NOT NEED + this.registerSingleAnimation([621, 852, 853, 854, 855, 856, 857, 858, 859, 852]);// industrial polution + this.registerSingleAnimation([641, 884, 885, 886, 887, 884]); + this.registerSingleAnimation([644, 888, 889, 890, 891, 888]); + this.registerSingleAnimation([649, 892, 893, 894, 895, 892]); + this.registerSingleAnimation([650, 896, 897, 898, 899, 896]); + this.registerSingleAnimation([676, 900, 901, 902, 903, 900]); + this.registerSingleAnimation([677, 904, 905, 906, 907, 904]); + this.registerSingleAnimation([686, 908, 909, 910, 911, 908]); + this.registerSingleAnimation([689, 912, 913, 914, 915, 912]); + this.registerSingleAnimation([747, 916, 917, 918, 919, 916]); + this.registerSingleAnimation([748, 920, 921, 922, 923, 920]); + this.registerSingleAnimation([751, 924, 925, 926, 927, 924]); + this.registerSingleAnimation([752, 928, 929, 930, 931, 928]); + this.registerSingleAnimation([820, 952, 953, 954, 955, 952]); + this.registerSingleAnimation([832, 833, 834, 835, 836, 837, 838, 839, 832]); + this.registerSingleAnimation([840, 841, 842, 843, 840]); + this.registerSingleAnimation([844, 845, 846, 847, 848, 849, 850, 851, 844]); + this.registerSingleAnimation([932, 933, 934, 935, 936, 937, 938, 939, 932]);// football + this.registerSingleAnimation([940, 941, 942, 943, 944, 945, 946, 947, 940]);// football + */ + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ +//import { PositionMaker } from '../math/PositionMaker.js'; + +class GameMap { + + constructor ( width = 128, height = 128, defaultValue ) { + + this.isIsland = false; + this.pp = []; + + //this.Position = new PositionMaker( width, height ); // !! find better way + + this.width = width; + this.height = height; + + this.fsize = this.width * this.height; + + this.defaultValue = new Tiles().getValue(); + + this.data = [];//new Array(this.fsize); + this.tilesData = new Micro.M_ARRAY_TYPE(this.fsize); + this.powerData = new Micro.M_ARRAY_TYPE(this.fsize); + + let i = this.fsize; + while(i--){ + this.data[i] = new Tiles( this.defaultValue ); + this.tilesData[i] = this.defaultValue; + } + /*console.log(this.data.length)*/ + + // Generally set externally + this.cityCentreX = Math.floor(this.width * 0.5); + this.cityCentreY = Math.floor(this.height * 0.5); + this.pollutionMaxX = this.cityCentreX; + this.pollutionMaxY = this.cityCentreY; + + this.powerChange = false; + + this.layer = []; + this.resetLayer(); + + + this.makePP(); + + } + + // 3D LAYER + + upLayer ( id, value, x, y ){ + + if(value>=Tile.TINYEXP && value<=Tile.TINYEXPLAST) value -= (860-35);// explosion decal + + //if(value>=Tile.HBRDG0 && value<=Tile.HBRDG3) value -= 832+32 + //if(value>=Tile.VBRDG0 && value<=Tile.VBRDG3) value -= 832+32 + + this.tilesData[ id ] = value; + + //if( this.goodValue(value) ){ + this.layer[this.findLayer(x,y)] = 1; + + } + + resetLayer () { + + let i = 64; + while( i-- ) this.layer[i] = 0; + + } + + findLayer ( x, y ){ + let cx = Math.floor(x/16); + let cy = Math.floor(y/16); + return cx+(cy*8) + } + + goodValue ( v ){ + + if( v === 0 ) return true // dirt + else if( v > 1 && v < 240 ) return true // water edge tree + //else if( v > 1 && v < 44 ) return true // water edge tree + //if( v > 43 && v < 48 ) return true // rubble + // else if( v > 43 && v < 240 ) return true // road wire rail + return false + + } + + // + + makePP () { + + let x = this.width, y, n=0; + + let pp = []; + + while( x-- ){ + y = this.height; + while( y-- ){ + pp[n] = [x,y]; + n++; + } + } + + this.pp = pp; + + } + + // change power statue for 3d + powered ( o ) { + + let id = o.id || this.getId( o.x, o.y ); + this.powerData[id] = o.v; + this.powerChange = true; + + } + + /*makePos (){ + + return new PositionMaker( this.width, this.height ); + + }*/ + + save ( saveData ) { + + let i=0, lng; + + // GAME PROPS + lng = Micro.GameMapProps.length; + while( i < lng ){ + saveData[Micro.GameMapProps[i]] = this[Micro.GameMapProps[i]]; + i++; + } + + // MAP DATA + //saveData.map = this.data.map(function(t) { return {value: t.getRawValue()}; }); + + + saveData.map = []; + i = 0; + lng = this.fsize; + while( i < lng ){ + saveData.map[i] = this.data[i].getRawValue(); + i++; + } + + // TILES VALUES + saveData.tileValue = []; + i = 0; + lng = this.fsize; + while( i < lng ){ + saveData.tileValue[i] = this.tilesData[i]; + i++; + } + + } + + load ( saveData ) { + + let x, y, lng, i = 0, map = saveData.map, tiles = saveData.tileValue; + + // GAME PROPS + lng = Micro.GameMapProps.length; + while( i < lng ){ + this[Micro.GameMapProps[i]] = saveData[Micro.GameMapProps[i]]; + i++; + } + + // MAP DATA + + let isOld = map[0].value !== undefined ? true : false; + i = 0; + lng = this.fsize; + while( i < lng ){ + x = i % this.width; + y = Math.floor(i / this.width); + if( isOld ) this.setTileValue( x, y, map[i].value ); + else this.setTileValue( x, y, map[i] ); + i++; + } + + // TILES VALUES + i = 0; + lng = this.fsize; + while( i < lng ){ + this.tilesData[i] = tiles[i]; + i++; + } + + } + + testBounds (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + } + + getId ( x, y ){ + return x + y * this.width + } + + getTile ( x, y, newTile ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let width = this.width; + let height = this.height; + + if (x < 0 || y < 0 || x >= width || y >= height) { + console.warn('getTile called with bad bounds', x, y); + return new Tiles(Tile.TILE_INVALID); + } + let tileIndex = this.getId( x, y ); + let tile = this.data[tileIndex]; + + //var tileIndex = this._calculateIndex(x, y); + // Return the original tile if we're not given a tile to fill + if (!newTile) return tile; + + newTile.set(tile); + return tile; + + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + //return this.data[tileIndex]; + } + + getTileValue( x, y ) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let tileIndex = this.getId(x, y); + + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getValue(); + } + + getTileFlags( x, y ) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let tileIndex = this.getId(x, y); + + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getFlags(); + } + + getTiles( x, y, w, h ) { + + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; + // Argument-shuffling + if (arguments.length === 3) { h = w; w = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let res = []; + for (let a = y, ylim = y + h; a < ylim; a++) { + res[a - y] = []; + for (let b = x, xlim = x + w; b < xlim; b++) { + let tileIndex = this.getId(b, a); + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + res[a-y].push(this.data[tileIndex]); + } + } + return res; + + } + + getTileValues( x, y, w, h, result ) { + + result = result || []; + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; + // Argument-shuffling + if (arguments.length === 3) { h = w; w = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + let width = this.width; + let height = this.height; + + // Result is stored in row-major order + for (let a = y, ylim = y + h; a < ylim; a++) { + for (let b = x, xlim = x + w; b < xlim; b++) { + if (a < 0 || b < 0 || a >= height || b >= width) { + result[(a - y) * w + (b - x)] = Tile.TILE_INVALID; + continue; + } + let tileIndex = b + a * width; + //result[(a - y) * w + (b - x)] = this._data[tileIndex].getRawValue(); + result[(a - y) * w + (b - x)] = this.data[tileIndex].getRawValue(); + } + } + + return result; + + } + + getTileFromMapOrDefault( pos, dir, defaultTile ) { + + switch (dir) { + case Direction.NORTH: + if (pos.y > 0) return this.getTileValue(pos.x, pos.y - 1); + return defaultTile; + case Direction.EAST: + if (pos.x < this.width - 1) return this.getTileValue(pos.x + 1, pos.y); + return defaultTile; + case Direction.SOUTH: + if (pos.y < this.height - 1) return this.getTileValue(pos.x, pos.y + 1); + return defaultTile; + case Direction.WEST: + if (pos.x > 0) return this.getTileValue(pos.x - 1, pos.y); + return defaultTile; + default: + return defaultTile; + } + + } + + //---------------------- + + testOld ( id, value ){ + + if( this.data[ id ].getValue() !== value ) return true + return false + + } + + setTile( x, y, value, flags ) { + + //var e = new Error('Invalid parameter'); + //if (arguments.length < 3) throw e; + // Argument-shuffling + if ( arguments.length === 3 ) { flags = value; value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let isNew = this.testOld( id, value ); + + this.data[ id ].set( value, flags ); + + if( isNew ) this.upLayer( id, value, x, y ); + + } + + setTo( x, y, tile ) { + + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if ( tile === undefined ) { tile = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let value = tile.getValue(); + let isNew = this.testOld( id, value ); + + this.data[ id ] = tile; + // this.data[ id ].setValue(value); + + if( isNew ) this.upLayer( id, value, x, y ); + + } + + setTileValue( x, y, value ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let isNew = this.testOld( id, value ); + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + + this.data[ id ].setValue( value ); + + if( isNew ) this.upLayer( id, value, x, y ); + + } + + setPaintValue( x, y, value ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + this.upLayer( id, value, x, y ); + + } + + setTileFlags( x, y, flags ) { + + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let id = this.getId(x, y); + this.data[id].setFlags(flags); + + } + + addTileFlags( x, y, flags ) { + + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let id = this.getId(x, y); + this.data[id].addFlags(flags); + + } + + removeTileFlags( x, y, flags ) { + + if (arguments.length < 2) throw new Error('GameMap removeTileFlags called with too few arguments'); // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw new Error('GameMap removeTileFlags called with invalid bounds'+ x + ', ' + y); + + let id = this.getId( x, y ); + this.data[id].removeFlags(flags); + + ///this.upLayer( id, this.data[id].getValue(), x, y ) + + } + + putZone( centreX, centreY, centreTile, size ) { + + if (!this.testBounds(centreX, centreY) || !this.testBounds(centreX - 1 + size, centreY - 1 + size)) throw new Error('GameMap putZone called with invalid bounds'); + + let tile = centreTile - 1 - size; + let startX = centreX - 1; + let startY = centreY - 1; + let x, y; + + for ( y = startY; y < startY + size; y++) { + for ( x = startX; x < startX + size; x++) { + if (x === centreX && y === centreY) this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT | Tile.ZONEBIT)); + else this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT)); + tile += 1; + } + } + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +class MapGenerator { + + constructor () { + + this.SRMatrix = [ + [ 0, 0, 3, 3, 0, 0 ], + [ 0, 3, 2, 2, 3, 0 ], + [ 3, 2, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 2, 3 ], + [ 0, 3, 2, 2, 3, 0 ], + [ 0, 0, 3, 3, 0, 0 ] + ]; + this.BRMatrix = [ + [ 0, 0, 0, 3, 3, 3, 0, 0, 0 ], + [ 0, 0, 3, 2, 2, 2, 3, 0, 0 ], + [ 0, 3, 2, 2, 2, 2, 2, 3, 0 ], + [ 3, 2, 2, 2, 2, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 4, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 2, 2, 2, 2, 3 ], + [ 0, 3, 2, 2, 2, 2, 2, 3, 0 ], + [ 0, 0, 3, 2, 2, 2, 3, 0, 0 ], + [ 0, 0, 0, 3, 3, 3, 0, 0, 0 ] + ]; + + this.riverEdge = [ + 13, 13, 17, 15, + 5 , 2 , 19, 17, + 9 , 11, 2 , 13, + 7 , 9 , 5 , 2 + ]; + + this.treeTable = [ + 0, 0, 0, 34, + 0, 0, 36, 35, + 0, 32, 0, 33, + 30, 31, 29, 37 + ]; + + } + + construct( w, h, debug = false ) { + + Micro.TERRAIN_TREE_LEVEL = -1; + Micro.TERRAIN_LAKE_LEVEL = -1; + Micro.TERRAIN_CURVE_LEVEL = -1; + Micro.ISLAND_RADIUS = 18; + + if(debug) console.time("start newmap"); + + this.map = new GameMap( w || Micro.MAP_WIDTH, h || Micro.MAP_HEIGHT ); + //this.map.makePP() + + Micro.TERRAIN_CREATE_ISLAND = math.getRandom(2) - 1; + + if ( Micro.TERRAIN_CREATE_ISLAND < 0 ) { + if (math.getRandom(100) < 10) { + this.makeIsland(); + return this.map; + } + } + + if ( Micro.TERRAIN_CREATE_ISLAND === 1 ) this.makeNakedIsland(); + else this.clearMap(); + + + // Lay a river. + if ( Micro.TERRAIN_CURVE_LEVEL !== 0 ) { + let terrainXStart = 40 + math.getRandom( this.map.width - 79 ); + let terrainYStart = 33 + math.getRandom( this.map.height - 66 ); + let terrainPos = new Position( terrainXStart, terrainYStart ); + this.doRivers( terrainPos ); + } + + // Lay a few lakes. + if ( Micro.TERRAIN_LAKE_LEVEL !== 0 ) this.makeLakes(); + + this.smoothRiver(); + this.cleanBorder(); + + // And add trees. + if ( Micro.TERRAIN_TREE_LEVEL !== 0 ) this.doTrees(); + + if( debug ) console.timeEnd("start newmap"); + + return this.map; + + } + + cleanBorder() { + + let map = this.map; + if( map.isIsland ) return + let x, y, l, r, s; + + for ( x = 0; x < map.width; x ++) { + + l = x + 1; if(l>map.width-1) l = map.width-1; + r = x - 1; if(r<0) r = 0; + s = 1; + if( map.getTileValue( x, s ) + map.getTileValue( l, s ) + map.getTileValue( r, s ) === 6 ) map.setTile( x, 0, Tile.RIVER, 0); + s = map.height-2; + if( map.getTileValue( x, s ) + map.getTileValue( l, s ) + map.getTileValue( r, s ) === 6 ) map.setTile( x, map.height-1, Tile.RIVER, 0); + + } + + for ( y = 0; y < map.height; y ++) { + + l = y + 1; if(l>map.height-1) l = map.height-1; + r = y - 1; if(r<0) r = 0; + s = 1; + if( map.getTileValue( s, y ) + map.getTileValue( s, l ) + map.getTileValue( s, r ) === 6 ) map.setTile( 0, y, Tile.RIVER, 0); + s = map.width-2; + if( map.getTileValue( s, y ) + map.getTileValue( s, l ) + map.getTileValue( s, r ) === 6 ) map.setTile( map.width-1, y, Tile.RIVER, 0); + + } + + } + + clearMap() { + + let map = this.map; + + map.pp.forEach( v => {//function ( v ) { + + map.setTile( v[0], v[1], Tile.DIRT, 0); + + }); + + } + + clearUnnatural() { + + let map = this.map, value; + + map.pp.forEach( v => { + + value = map.getTileValue( v[0], v[1] ); + if ( value > Tile.WOODS ) map.setTile( v[0], v[1], Tile.DIRT, 0); + + }); + + } + + makeNakedIsland() { + + let map = this.map; + let terrainIslandRadius = Micro.ISLAND_RADIUS; + let x, y, mapX, mapY; + + map.isIsland = true; + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + + if ((x < 5) || (x >= map.width - 5) || (y < 5) || (y >= map.height - 5)) map.setTile(x, y, Tile.RIVER, 0); + else map.setTile( x, y, Tile.DIRT, 0 ); + + }); + + for ( x = 0; x < map.width - 5; x += 2) { + mapY = math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:x, y:mapY }); + + mapY = (map.height - 10) - math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:x, y:mapY }); + this.plopSRiver({ x:x, y:0 }); + this.plopSRiver({ x:x, y:map.height - 6 }); + } + for ( y = 0; y < map.height - 5; y += 2 ) { + mapX = math.getERandom( terrainIslandRadius ); + this.plopBRiver({ x:mapX, y:y }); + + mapX = map.width - 10 - math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:mapX, y:y }); + this.plopSRiver({ x:0, y:y }); + this.plopSRiver({ x:map.width - 6, y:y }); + } + + } + + makeIsland() { + + this.makeNakedIsland(); + this.smoothRiver(); + this.doTrees(); + + } + + makeLakes() { + + let x, y; + let numLakes = Micro.TERRAIN_LAKE_LEVEL < 0 ? math.getRandom(10) : Micro.TERRAIN_LAKE_LEVEL * 0.5; + + while (numLakes > 0) { + x = math.getRandom( this.map.width - 21) + 10; + y = math.getRandom( this.map.height - 20) + 10; + this.makeSingleLake( new Position(x, y) ); + numLakes--; + } + + } + + makeSingleLake( pos ) { + + let numPlops = math.getRandom(12) + 2, plopPos; + while ( numPlops > 0 ) { + plopPos = new Position(pos, math.getRandom(12) - 6, math.getRandom(12) - 6); + if ( math.getRandom(4) ) this.plopSRiver(plopPos); + else this.plopBRiver( plopPos ); + numPlops--; + } + + } + + treeSplash( x, y ) { + + let numTrees = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(150) + 50 : math.getRandom(100 + (Micro.TERRAIN_TREE_LEVEL * 2)) + 50; + let treePos = new Position(x, y), dir; + + while (numTrees > 0) { + + dir = Direction.NORTH + math.getRandom(7); + treePos.move( dir ); + + // XXX Should use the fact that positions return success/failure for moves + if (!this.map.testBounds(treePos.x, treePos.y)) return; + if ( this.map.getTileValue(treePos) === Tile.DIRT ) this.map.setTile(treePos, Tile.WOODS, Tile.BLBNBIT); + + numTrees--; + } + } + + doTrees() { + + let i = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(100) + 50 : Micro.TERRAIN_TREE_LEVEL + 3; + + while(i--){ + this.treeSplash( math.getRandom( this.map.width - 1), math.getRandom( this.map.height - 1) ); + } + + /*for (var x = 0; x < i; x++) { + var xloc = math.getRandom(this.map.width - 1); + var yloc = math.getRandom(this.map.height - 1); + this.treeSplash( xloc, yloc ); + }*/ + + this.smoothTrees(); + this.smoothTrees(); + + } + + smoothRiver() { + + let map = this.map; + let riverEdge = this.riverEdge; + let x, y, z, xt, yt, tt, bitIndex, temp; + let dx = [-1, 0, 1, 0]; + let dy = [0, 1, 0, -1]; + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + + if ( map.getTileValue(x, y) === Tile.REDGE ) { + + bitIndex = 0; + + for ( z = 0; z < 4; z++) { + bitIndex = bitIndex << 1; + xt = x + dx[z]; + yt = y + dy[z]; + if( map.testBounds( xt, yt ) ){ + tt = map.getTileValue( xt, yt ); + if( tt !== Tile.DIRT && ( tt < Tile.WOODS_LOW || tt > Tile.WOODS_HIGH ) ) bitIndex++; + } + } + + temp = riverEdge[bitIndex & 15]; + if ( temp !== Tile.RIVER && math.getRandom(1) ) temp++; + + //map.setTileValue(x, y, temp, 0); + + map.setTile( x, y, temp, Tile.BULLBIT ); // or we can't make bridge !!! + + } + }); + } + + isTree( value ) { + + return value >= Tile.WOODS_LOW && value <= Tile.WOODS_HIGH; + + } + + smoothTrees() { + + let map = this.map; + let x, y; + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + if (this.isTree(map.getTileValue(x, y))) this.smoothTreesAt( x, y, false ); + + }); + + } + + smoothTreesAt( x, y, preserve ) { + + let map = this.map; + let dx = [-1, 0, 1, 0 ]; + let dy = [ 0, 1, 0, -1 ]; + + if (!this.isTree(this.map.getTileValue(x, y))) return; + + let i, xTemp, yTemp, temp, bitIndex = 0; + + for ( i = 0; i < 4; i++) { + bitIndex = bitIndex << 1; + xTemp = x + dx[i]; + yTemp = y + dy[i]; + if (map.testBounds(xTemp, yTemp) && this.isTree(map.getTileValue(xTemp, yTemp))) bitIndex++; + } + + temp = this.treeTable[ bitIndex & 15 ]; + if (temp) { + if (temp !== Tile.WOODS) { + if ((x + y) & 1) temp -= 8; + } + if(temp>28 && temp<38) temp-=8; + map.setTile(x, y, temp, Tile.BLBNBIT); + } else { + if (!preserve){ + if(temp>28 && temp<38) temp-=8; + map.setTileValue(x, y, temp, 0); + } } + + } + + doRivers( terrainPos ) { + + let riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doBRiver( terrainPos, riverDir, riverDir ); + + riverDir = Direction.rotate180(riverDir); + let terrainDir = this.doBRiver( terrainPos, riverDir, riverDir ); + + riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doSRiver( terrainPos, riverDir, terrainDir ); + + } + + doBRiver( riverPos, riverDir, terrainDir) { + + let rate1, rate2; + + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + let pos = new Position(riverPos); + while ( this.map.testBounds( pos.x + 4, pos.y + 4 ) ) { + this.plopBRiver(pos); + if (math.getRandom(rate1+1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + pos.move(terrainDir); + } + return terrainDir; + + } + + doSRiver(riverPos, riverDir, terrainDir) { + + let rate1, rate2; + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + let pos = new Position(riverPos); + while ( this.map.testBounds(pos.x + 3, pos.y + 3) ) { + this.plopSRiver(pos); + if (math.getRandom(rate1+1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + pos.move(terrainDir); + } + return terrainDir; + + } + + putOnMap( newVal, x, y ) { + + if (newVal === 0) return; + if (!this.map.testBounds(x, y)) return; + + let tmp = this.map.getTileValue(x, y); + + if (tmp !== Tile.DIRT) { + if (tmp === Tile.RIVER && newVal !== Tile.CHANNEL) return; + if (tmp === Tile.CHANNEL) return; + } + + this.map.setTile(x, y, newVal, 0); + + } + + plopBRiver( pos ) { + + let x = 9, y; + + while(x--){ + y = 9; + while(y--){ + this.putOnMap( this.BRMatrix[y][x], pos.x + x, pos.y + y ); + } + } + + } + + plopSRiver( pos ) { + + let x = 6, y; + + while(x--){ + y = 6; + while(y--){ + this.putOnMap( this.SRMatrix[y][x], pos.x + x, pos.y + y ); + } + } + + } + + smoothWater() { + + let map = this.map, tile, pos, dir, x, y, makeRiver; + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + + tile = map.getTileValue(x, y); + + if (tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); + + // If nearest object is not water: + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + // set river edge + map.setTileValue(x, y, Tile.REDGE, 0); + break; // Continue with next tile + } + } + } + }); + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + + tile = map.getTileValue(x, y); + if (tile !== Tile.CHANNEL && tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + makeRiver = true; + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + makeRiver = false; + break; + } + } + if (makeRiver) map.setTileValue(x, y, Tile.RIVER, 0); + } + }); + + map.pp.forEach( v => { + + x = v[0]; + y = v[1]; + + tile = map.getTileValue(x, y); + if (tile >= Tile.WOODS_LOW && tile <= Tile.WOODS_HIGH) { + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, TILE_INVALID); + if (tile === Tile.RIVER || tile === Tile.CHANNEL) { + map.setTileValue(x, y, Tile.REDGE, 0); + break; + } + } + } + }); + } + + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +class WorldEffects { + + constructor ( map ) { + + this._map = map; + this._data = {}; + } + + toKey (x, y) { + return [x, y].join(','); + } + + fromKey (k) { + k = k.split(','); + return {x: k[0] - 0, y: k[1] - 0}; + } + + clear () { + this._data = []; + } + + getTile (x, y) { + let key = this.toKey(x, y); + let tile = this._data[key]; + if ( tile === undefined ) tile = this._map.getTile(x, y); + return tile; + } + + getTileValue (x, y) { + return this.getTile(x, y).getValue(); + } + + setTile ( x, y, value, flags ) { + + if (flags !== undefined && value.isTile ) throw new Error('Flags supplied with already defined tile'); + if (flags === undefined && !value.isTile ) value = new Tiles(value); + else if (flags !== undefined) value = new Tiles(value, flags); + let key = this.toKey( x, y ); + this._data[key] = value; + } + + apply () { + let keys = Object.keys(this._data); + for ( let i = 0, l = keys.length; i < l; i++ ) { + let coords = this.fromKey(keys[i]); + this._map.setTo( coords, this._data[keys[i]] ); + } + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + +class BaseTool { + + constructor () { + + this.TOOLRESULT_OK = 0; + this.TOOLRESULT_FAILED = 1; + this.TOOLRESULT_NO_MONEY = 2; + this.TOOLRESULT_NEEDS_BULLDOZE = 3; + this.autoBulldoze = true; + this.bulldozerCost = 1; + + } + + init ( cost, map, shouldAutoBulldoze, IsDraggable = false ) { + + //Object.defineProperty(this, 'toolCost', MiscUtils.mcd(cost)); + this.toolCost = cost; + this.result = null; + this.isDraggable = IsDraggable; + this._shouldAutoBulldoze = shouldAutoBulldoze; + this._map = map; + this._worldEffects = new WorldEffects( map ); + this._applicationCost = 0; + + } + + clear () { + + this._applicationCost = 0; + this._worldEffects.clear(); + + } + + addCost ( cost ) { + + this._applicationCost += cost; + + } + + doAutoBulldoze ( x, y ) { + + //if ( !this._shouldAutoBulldoze ) return; + let tile = this._worldEffects.getTile(x, y); + if ( tile.isBulldozable() ) { + tile = ZoneUtils.normalizeRoad( tile ); + if ((tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP) || (tile < Tile.HBRIDGE && tile !== Tile.DIRT)) { + this.addCost(1); + this._worldEffects.setTile(x, y, Tile.DIRT); + } + } + + } + + apply ( budget ) { + + this._worldEffects.apply(); + budget.spend(this._applicationCost); + this.clear(); + + } + + modifyIfEnoughFunding ( budget ) { + + if (this.result !== this.TOOLRESULT_OK) { this.clear(); return false; } + if (budget.totalFunds < this._applicationCost) { this.result = this.TOOLRESULT_NO_MONEY; this.clear(); return false; } + this.apply.call(this, budget); + this.clear(); + return true; + + } + + setAutoBulldoze ( value ) { + + this.autoBulldoze = value; + + } + + getAutoBulldoze () { + + return this.autoBulldoze; + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BaseToolConnector extends BaseTool { + + constructor () { + + super(); + + } + + fixSingle ( x, y ) { + + let adjTile = 0; + let tile = this._worldEffects.getTile(x, y); + + tile = ZoneUtils.normalizeRoad(tile); + + if (tile >= Tile.ROADS && tile <= Tile.INTERSECTION) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 1; + } + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 2; + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 4; + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 8; + } + + this._worldEffects.setTile(x, y, RoadTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + return; + } + + if (tile >= Tile.LHRAIL && tile <= Tile.LVRAIL10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 1; + } + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 2; + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 4; + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 8; + } + this._worldEffects.setTile(x, y, RailTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + return; + } + + if (tile >= Tile.LHPOWER && tile <= Tile.LVPOWER10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 1; + } + } + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 2; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 4; + } + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 8; + } + } + this._worldEffects.setTile(x, y, WireTable[adjTile] | Tile.BLBNCNBIT); + return; + } + } + + checkZoneConnections ( x, y ) { + + this.fixSingle(x, y); + if (y > 0) this.fixSingle(x, y - 1); + if (x < this._map.width - 1) this.fixSingle(x + 1, y); + if (y < this._map.height - 1) this.fixSingle(x, y + 1); + if (x > 0) this.fixSingle(x - 1, y); + + } + + checkBorder ( x, y, size ) { + + // Adjust to top left tile + x = x - 1; + y = y - 1; + let i; + for (i = 0; i < size; i++) this.fixZone(x + i, y - 1); + for (i = 0; i < size; i++) this.fixZone(x - 1, y + i); + for (i = 0; i < size; i++) this.fixZone(x + i, y + size); + for (i = 0; i < size; i++) this.fixZone(x + size, y + i); + + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BuildingTool extends BaseToolConnector { + + constructor ( cost, centreTile, map, size, animated ) { + + super(); + this.init( cost, map, false ); + this.centreTile = centreTile; + this.size = size; + this.animated = animated; + + } + + putBuilding ( leftX, topY ) { + let posX, posY, tileValue, tileFlags; + let baseTile = this.centreTile - this.size - 1; + + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + + for ( let dx = 0; dx < this.size; dx++ ) { + posX = leftX + dx; + tileValue = baseTile; + tileFlags = Tile.BNCNBIT; + + if (dx === 1) { + if (dy === 1) tileFlags |= Tile.ZONEBIT; + else if (dy === 2 && this.animated) tileFlags |= Tile.ANIMBIT; + } + this._worldEffects.setTile(posX, posY, tileValue, tileFlags); + baseTile++; + } + } + } + + prepareBuildingSite ( leftX, topY ) { + // Check that the entire site is on the map + if (leftX < 0 || leftX + this.size > this._map.width) return this.TOOLRESULT_FAILED; + if (topY < 0 || topY + this.size > this._map.height) return this.TOOLRESULT_FAILED; + + let posX, posY, tileValue; + + // Check whether the tiles are clear + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + for (let dx = 0; dx < this.size; dx++) { + posX = leftX + dx; + tileValue = this._worldEffects.getTileValue(posX, posY); + + if (tileValue === Tile.DIRT) continue; + if (!this.autoBulldoze) { + // No Tile.DIRT and no bull-dozer => not buildable + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + + if (!ZoneUtils.canBulldoze(tileValue)) { + // tilevalue cannot be auto-bulldozed + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + this._worldEffects.setTile(posX, posY, Tile.DIRT); + this.addCost(this.bulldozerCost); + } + } + return this.TOOLRESULT_OK; + } + + buildBuilding ( x, y ) { + // Correct to top left + x--; + y--; + + let prepareResult = this.prepareBuildingSite(x, y); + if (prepareResult !== this.TOOLRESULT_OK) return prepareResult; + + this.addCost(this.toolCost); + this.putBuilding(x, y); + this.checkBorder(x, y); + + return this.TOOLRESULT_OK; + } + + doTool ( x, y, blockMaps ) { + this.result = this.buildBuilding(x, y); + } + +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class BulldozerTool extends BaseToolConnector { + + constructor( map ) { + + super(); + this.init(10, map, true); + + } + + + putRubble( x, y, size ) { + + for (let xx = x; xx < x + size; xx++) { + for (let yy = y; yy < y + size; yy++) { + if (this._map.testBounds(xx, yy)) { + let tile = this._worldEffects.getTile(xx, yy); + if (tile !== Tile.RADTILE && tile !== Tile.DIRT) { + this._worldEffects.setTile(xx, yy, Tile.TINYEXP + math.getRandom(2), Tile.ANIMBIT | Tile.BULLBIT ); + } + } + } + } + + } + + layDoze( x, y ) { + + let tile = this._worldEffects.getTile(x, y); + + if (!tile.isBulldozable()) return this.TOOLRESULT_FAILED; + + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.HBRIDGE: + case Tile.VBRIDGE: + case Tile.BRWV: + case Tile.BRWH: + case Tile.HBRDG0: + case Tile.HBRDG1: + case Tile.HBRDG2: + case Tile.HBRDG3: + case Tile.VBRDG0: + case Tile.VBRDG1: + case Tile.VBRDG2: + case Tile.VBRDG3: + case Tile.HPOWER: + case Tile.VPOWER: + case Tile.HRAIL: + case Tile.VRAIL: + this._worldEffects.setTile(x, y, Tile.RIVER); + break; + + default: this._worldEffects.setTile(x, y, Tile.DIRT); break; + } + + this.addCost(1); + return this.TOOLRESULT_OK; + + } + + doTool( x, y, blockMaps, messageManager ) { + + if (!this._map.testBounds(x, y)) this.result = this.TOOLRESULT_FAILED; + + let tile = this._worldEffects.getTile(x, y); + let tileValue = tile.getValue(); + + let zoneSize = 0; + let deltaX; + let deltaY; + + if (tile.isZone()) { + zoneSize = ZoneUtils.checkZoneSize(tileValue); + deltaX = 0; + deltaY = 0; + } else { + let result = ZoneUtils.checkBigZone(tileValue); + zoneSize = result.zoneSize; + deltaX = result.deltaX; + deltaY = result.deltaY; + } + + //console.log( zoneSize, deltaX, deltaY ) + + if (zoneSize > 0) { + + this.addCost(this.bulldozerCost); + + //this._map.powerData[ this._map.getId( x, y ) ] = 0; + + this._map.powered({ v:1, x:x, y:y }); + let centerX = x + deltaX; + let centerY = y + deltaY; + + switch (zoneSize) { + case 3: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + this.putRubble(centerX - 1, centerY - 1, 3); + break; + case 4: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 4); + break; + case 6: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 6); + break; + } + + this.result = this.TOOLRESULT_OK; + } + + let toolResult; + if (tileValue === Tile.RIVER || tileValue === Tile.REDGE || tileValue === Tile.CHANNEL) { + toolResult = this.layDoze(x, y); + if (tileValue !== this._worldEffects.getTileValue(x, y)) this.addCost(5); + } else { + toolResult = this.layDoze(x, y); + this.checkZoneConnections(x, y); + } + + this.result = toolResult; + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class ParkTool extends BaseTool { + + constructor ( map ) { + + super(); + this.init( 10, map, true ); + + } + + doTool ( x, y, blockMaps ) { + + if (this._worldEffects.getTileValue(x, y) !== Tile.DIRT) { + this.result = this.TOOLRESULT_NEEDS_BULLDOZE; + return; + } + let value = math.getRandom(4); + let tileFlags = Tile.BURNBIT | Tile.BULLBIT; + let tileValue; + + if (value === 4) { + tileValue = Tile.FOUNTAIN; + tileFlags |= Tile.ANIMBIT; + } else { + tileValue = value + Tile.WOODS2; + } + + this._worldEffects.setTile(x, y, tileValue, tileFlags); + this.addCost(10); + this.result = this.TOOLRESULT_OK; + + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class RailTool extends BaseToolConnector { + + constructor ( map ) { + + super(); + this.init(20, map, true, true); + + } + + layRail ( x, y ) { + + this.doAutoBulldoze(x, y); + let cost = this.toolCost; + let tile = this._worldEffects.getTileValue(x, y); + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.LHRAIL | Tile.BULLBIT | Tile.BURNBIT); break; + + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + cost = 100; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || (tile >= Tile.LHRAIL && tile <= Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + break; + } + } + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || (tile > Tile.VRAIL && tile < Tile.VRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + break; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || (tile > Tile.HRAIL && tile < Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + break; + } + } + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || (tile > Tile.HRAIL && tile < Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + break; + } + } + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVPOWER: this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS: this._worldEffects.setTile(x, y, Tile.VRAILROAD, Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS2: this._worldEffects.setTile(x, y, Tile.HRAILROAD, Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + }; + + doTool (x, y, blockMaps) { + this.result = this.layRail(x, y); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class RoadTool extends BaseToolConnector { + + constructor ( map ) { + + super(); + this.init(10, map, true, true); + + } + + layRoad ( x, y ) { + + this.doAutoBulldoze(x, y); + let tile = this._worldEffects.getTileValue(x, y); + let cost = this.toolCost; + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.ROADS, Tile.BULLBIT | Tile.BURNBIT); break; + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + + //console.log('is water') + cost = 50; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || (tile >= Tile.ROADS && tile <= Tile.HROADPOWER)) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + break; + } + } + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || (tile >= Tile.ROADS && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + break; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || (tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + break; + } + } + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || (tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + break; + } + } + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: this._worldEffects.setTile(x, y, Tile.VROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVPOWER: this._worldEffects.setTile(x, y, Tile.HROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LHRAIL: this._worldEffects.setTile(x, y, Tile.HRAILROAD | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVRAIL: this._worldEffects.setTile(x, y, Tile.VRAILROAD | Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + } + + doTool = function(x, y, blockMaps) { + this.result = this.layRoad(x, y); + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class QueryTool extends BaseTool { + + constructor ( map ) { + + super(); + this.init(0, map, false, false); + this.txt = ""; + + } + + classifyPopulationDensity (x, y, blockMaps) { + var density = blockMaps.populationDensityMap.worldGet(x, y); + //if (debug) document.getElementById("queryDensityRaw").innerHTML=density; + density = density >> 6; + density = density & 3; + + this.txt+='Density: '+TXT.densityStrings[density]+'
'; + //document.getElementById("queryDensity").innerHTML=TXT.densityStrings[density]; + } + + classifyLandValue (x, y, blockMaps) { + var landValue = blockMaps.landValueMap.worldGet(x, y); + //if (debug) document.getElementById("queryLandValueRaw").innerHTML=landValue; + + var i = 0; + if (landValue >= 150) i = 3; + else if (landValue >= 80) i = 2; + else if (landValue >= 30) i = 1; + + //var text = TXT.landValueStrings[i]; + this.txt+='Value: '+TXT.landValueStrings[i]+'
'; + //document.getElementById("queryLandValue").innerHTML=text; + } + + classifyCrime (x, y, blockMaps) { + var crime = blockMaps.crimeRateMap.worldGet(x, y); + //if (debug) document.getElementById("queryCrimeRaw").innerHTML=crime; + + crime = crime >> 6; + crime = crime & 3; + + this.txt+='Crime: '+TXT.crimeStrings[crime]+'
'; + //document.getElementById("queryCrime").innerHTML=TXT.crimeStrings[crime]; + } + + classifyPollution (x, y, blockMaps) { + var pollution = blockMaps.pollutionDensityMap.worldGet(x, y); + //if (debug) document.getElementById("queryPollutionRaw").innerHTML=pollution; + pollution = pollution >> 6; + pollution = pollution & 3; + + this.txt+='Pollution: '+TXT.pollutionStrings[pollution]+'
'; + //document.getElementById("queryPollution").innerHTML=TXT.pollutionStrings[pollution]; + } + + classifyRateOfGrowth (x, y, blockMaps) { + var rate = blockMaps.rateOfGrowthMap.worldGet(x, y); + //if (debug) document.getElementById("queryRateRaw").innerHTML=rate; + rate = rate >> 6; + rate = rate & 3; + + this.txt+='Growth: '+TXT.rateStrings[rate]; + //document.getElementById("queryRate").innerHTML=TXT.rateStrings[rate]; + } + + classifyDebug (x, y, blockMaps) { + /*document.getElementById("queryFireStationRaw").innerHTML=blockMaps.fireStationMap.worldGet(x, y); + document.getElementById("queryFireStationEffectRaw").innerHTML=blockMaps.fireStationEffectMap.worldGet(x, y); + document.getElementById("queryPoliceStationRaw").innerHTML=blockMaps.policeStationMap.worldGet(x, y); + document.getElementById("queryPoliceStationEffectRaw").innerHTML=blockMaps.policeStationEffectMap.worldGet(x, y); + document.getElementById("queryTerrainDensityRaw").innerHTML=blockMaps.terrainDensityMap.worldGet(x, y); + document.getElementById("queryTrafficDensityRaw").innerHTML=blockMaps.trafficDensityMap.worldGet(x, y); + document.getElementById("queryComRateRaw").innerHTML=blockMaps.comRateMap.worldGet(x, y);*/ + } + + classifyZone (x, y) { + var baseTiles = [ + Tile.DIRT, Tile.RIVER, Tile.TREEBASE, Tile.RUBBLE, + Tile.FLOOD, Tile.RADTILE, Tile.FIRE, Tile.ROADBASE, + Tile.POWERBASE, Tile.RAILBASE, Tile.RESBASE, Tile.COMBASE, + Tile.INDBASE, Tile.PORTBASE, Tile.AIRPORTBASE, Tile.COALBASE, + Tile.FIRESTBASE, Tile.POLICESTBASE, Tile.STADIUMBASE, Tile.NUCLEARBASE, + Tile.HBRDG0, Tile.RADAR0, Tile.FOUNTAIN, Tile.INDBASE2, + Tile.FOOTBALLGAME1, Tile.VBRDG0, 952]; + + var tileValue = this._map.getTileValue(x, y); + if (tileValue >= Tile.COALSMOKE1 && tileValue < Tile.FOOTBALLGAME1) tileValue = Tile.COALBASE; + + var index = 0, l; + for (index = 0, l = baseTiles.length - 1; index < l; index++) { + if (tileValue < baseTiles[index + 1]) + break; + } + + this.txt='Zone: '+TXT.zoneTypes[index]+'
'; + + //document.getElementById("queryZoneType").innerHTML=TXT.zoneTypes[index]; + } + + getInfo () { + return this.txt; + } + + doTool (x, y, blockMaps, messageManager) { + + var text = 'Position (' + x + ', ' + y + ')'; + text += ' TileValue: ' + this._map.getTileValue(x, y); + + { + this._map.getTile(x, y); + /*document.getElementById("queryTile").innerHTML=[x,y].join(', '); + document.getElementById("queryTileValue").innerHTML=tile.getValue(); + document.getElementById("queryTileBurnable").innerHTML=tile.isCombustible(); + document.getElementById("queryTileBulldozable").innerHTML=tile.isBulldozable(); + document.getElementById("queryTileCond").innerHTML=tile.isConductive(); + document.getElementById("queryTileAnim").innerHTML=tile.isAnimated(); + document.getElementById("queryTilePowered").innerHTML=tile.isPowered();*/ + } + + this.classifyZone(x, y); + this.classifyPopulationDensity(x, y, blockMaps); + this.classifyLandValue(x, y, blockMaps); + this.classifyCrime(x, y, blockMaps); + this.classifyPollution(x, y, blockMaps); + this.classifyRateOfGrowth(x, y, blockMaps); + this.classifyDebug(x, y, blockMaps); + + messageManager.sendMessage(Messages.QUERY_WINDOW_NEEDED); + + this.result = this.TOOLRESULT_OK; + } +} + +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +class WireTool extends BaseToolConnector { + + constructor ( map ) { + + super(); + this.init( 5, map, true, true ); + + } + + layWire ( x, y ) { + + this.doAutoBulldoze( x, y ); + let cost = 5; + let tile = this._worldEffects.getTileValue( x, y ); + tile = ZoneUtils.normalizeRoad( tile ); + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.LHPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.RIVER: case Tile.REDGE: case Tile.CHANNEL: + cost = 25; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + return this.TOOLRESULT_FAILED; + + case Tile.ROADS: this._worldEffects.setTile(x, y, Tile.HROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS2: this._worldEffects.setTile(x, y, Tile.VROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LHRAIL: this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVRAIL: this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost( cost ); + this.checkZoneConnections( x, y ); + return this.TOOLRESULT_OK; + + } + + doTool ( x, y, blockMaps ) { + + this.result = this.layWire( x, y ); + + } +} + +const postMessage = self.webkitPostMessage || self.postMessage; +//var timestep = 1000/30; +var Game; +var isWorker = true; +var returnMessage; + +//var ab = new ArrayBuffer( 1 ); +//CityGame.post( ab, [ab] ); +var trans = false;// ( ab.byteLength === 0 ); + + +self.onmessage = function ( e ) { CityGame.message( e ); }; + + +class CityGame { + + static message ( e ) { + + var p = e.data.tell; + + if( p == "INIT" ) { + + if( e.data.returnMessage ){ + + returnMessage = e.data.returnMessage; + isWorker = false; + + } + + Game = new MainGame( e.data.timestep ); + + } + + + if( p == "NEWMAP" ) Game.newMap(); + if( p == "PLAYMAP" ) Game.playMap(); + if( p == "TOOL" ) Game.tool(e.data.name); + if( p == "MAPCLICK" ) Game.mapClick(e.data.x, e.data.y, e.data.single || false); + + //if( p == "DESTROY" ) Game.destroy(e.data.x, e.data.y); + + //if( p == "RUN" && trans) updateTrans(e.data); + + if( p == "DIFFICULTY" ) Game.changeDifficulty(e.data.n); + if( p == "SPEED" ) Game.changeSpeed(e.data.n); + + if( p == "BUDGET") Game.handleBudgetRequest(); + if( p == "NEWBUDGET") Game.setBudget(e.data.budgetData); + + if( p == "DISASTER") Game.setDisaster(e.data.disaster); + + if( p == "EVAL") Game.getEvaluation(); + + if( p == "SAVEGAME") Game.saveGame(e.data.saveCity); + if( p == "LOADGAME") Game.loadGame(e.data.isStart); + if( p == "MAKELOADGAME") Game.makeLoadGame(e.data.savegame, e.data.isStart); + + } + + static post ( e, buffer ){ + + if( isWorker ) postMessage( e, buffer ); + else returnMessage( { data : e } ); + + } + + + +} + + +var update = function(){ + + Game.tick(); + +}; + + +class MainGame { + + constructor ( timestep ) { + + this.timestep = timestep; + + this.mapSize = [128,128]; + this.difficulty = 1; + this.speed = 2; + this.oldSpeed = 0; + this.mapGen = new MapGenerator(); + + this.simulation = null; + this.gameTools = null; + this.animationManager = null; + this.map = null; + + this.isPaused = false; + this.simNeededBudget = false; + this.currentTool = null; + this.timer = null; + this.infos = []; + this.sprites = []; + + this.spritesData = null; + this.animsData = null; + //this.tilesData = null; + + this.spritesData = []; + + this.power = null; + + CityGame.post({ tell:"READY" }); + + } + + next ( delay = 0 ) { + + this.timer = setTimeout( update, delay ); + + } + + stop (){ + + if( this.timer === null ) return; + clearInterval( this.timer ); + this.timer = null; + + } + + tick () { + + //if ( this.isPaused ) return + + let up = this.simulation.simTick(); + + if( up ) { + + this.infos = this.simulation.infos; + + this.processMessages( Game.simulation.messageManager.getMessages() ); + + this.animatedTiles(); + + this.simulation.spriteManager.moveObjects(); + this.calculateSprites(); + + CityGame.post({ tell:"RUN", infos:this.infos, tilesData:this.map.tilesData, powerData:this.map.powerData, sprites:this.spritesData, layer:this.map.layer }); + + this.map.resetLayer(); + + } + + this.next(); + + } + + newMap () { + + this.map = this.mapGen.construct( this.mapSize[0], this.mapSize[1] ); + CityGame.post({ tell:"NEWMAP", tilesData:this.map.tilesData, mapSize:this.mapSize, island:this.map.isIsland, trans:trans }); + + } + + playMap ( loading ) { + + var messageMgr = new MessageManager(); + var money = 20000; + if(this.difficulty == 1) money = 10000; + if(this.difficulty == 2) money = 5000; + + this.gameTools = { + airport: new BuildingTool(10000, Tile.AIRPORT, this.map, 6, false), + bulldozer: new BulldozerTool(this.map), + coal: new BuildingTool(3000, Tile.POWERPLANT, this.map, 4, false), + commercial: new BuildingTool(100, Tile.COMCLR, this.map, 3, false), + fire: new BuildingTool(500, Tile.FIRESTATION, this.map, 3, false), + industrial: new BuildingTool(100, Tile.INDCLR, this.map, 3, false), + nuclear: new BuildingTool(5000, Tile.NUCLEAR, this.map, 4, true), + park: new ParkTool(this.map), + police: new BuildingTool(500, Tile.POLICESTATION, this.map, 3, false), + port: new BuildingTool(3000, Tile.PORT, this.map, 4, false), + rail: new RailTool(this.map), + residential: new BuildingTool(100, Tile.FREEZ, this.map, 3, false), + road: new RoadTool(this.map), + query: new QueryTool(this.map), + stadium: new BuildingTool(5000, Tile.STADIUM, this.map, 4, false), + wire: new WireTool(this.map), + }; + + this.animationManager = new AnimationManager( this.map ); + + if(loading){ + money = this.savedGame.totalFunds; + //this.infos[3] = this.savedGame.totalPop; + this.speed = this.savedGame.speed; + this.difficulty = this.savedGame.difficulty; + this.simulation = new Simulation( this.map, this.difficulty, this.speed, true, this.savedGame); + //this.processMessages(Messages.EVAL_UPDATED); + messageMgr.sendMessage(Messages.WELCOMEBACK); + + }else { + this.simulation = new Simulation( this.map, this.difficulty, this.speed, true); + messageMgr.sendMessage(Messages.WELCOME); + + } + + this.simulation.budget.setFunds(money); + //messageMgr.sendMessage(Messages.FUNDS_CHANGED, money); + this.processMessages( messageMgr.getMessages() ); + + // update simulation time + this.isPaused = false; + //if(!trans) + //this.timer = setInterval(update, 1000/this.timestep); + //this.timer = setInterval(update, 0); + //else update(); + + this.tick(); + + //this.next() + } + + + + /*changeTimeStep (n){ + + clearInterval(this.timer); + this.next() + //this.timestep = n; + //this.timer = setInterval(update, 1000/this.timestep) + //this.timer = setInterval(update, 0); + + }*/ + + changeSpeed (n){ + // 0:pause 1:slow 2:medium 3:fast + this.speed = n; + this.simulation.setSpeed(this.speed); + + if(this.speed === 0) { + this.isPaused = true; + this.stop(); + } else { + if( this.isPaused ){ + this.isPaused = false; + this.stop(); + this.tick(); + } + + } + + + + /*if(this.speed === 4){ + + this.simulation.setSpeed(this.speed-1); + } else { + + this.simulation.setSpeed(this.speed); + }*/ + } + + changeDifficulty(n){ + // 0: easy 1: medium 2: hard + this.difficulty = n; + if(this.simulation) this.simulation.setDifficulty ( this.difficulty ); + } + + animatedTiles () { + + var animTiles = this.animationManager.getTiles(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1, this.isPaused ); + var i = animTiles.length; + this.animsData = new Micro.M_ARRAY_TYPE(i); + while(i--){ + var tile = animTiles[i]; + this.animsData[i] = [ tile.tileValue, tile.x, tile.y ]; + } + } + + calculateSprites () { + this.sprites = this.simulation.spriteManager.getSpritesInView(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1); + var i = this.sprites.length; + //this.spritesData = new M_ARRAY_TYPE(i); + while(i--){ + var sprite = this.sprites[i]; + this.spritesData[i] = [sprite.type, sprite.frame, sprite.x || 0, sprite.y || 0]; + } + } + + processMessages ( messages ) { + + var messageOutput = false; + + for (var i = 0, l = messages.length; i < l; i++) { + var m = messages[i]; + switch (m.message) { + case Messages.BUDGET_NEEDED: this.simNeededBudget = true; this.handleBudgetRequest(); break; + case Messages.QUERY_WINDOW_NEEDED: CityGame.post({tell:"QUERY", queryTxt:this.currentTool.getInfo() }); break; + //case Messages.DATE_UPDATED: this.infos[0] = [TXT.months[ m.data.month ], m.data.year].join(' '); break; + // case Messages.EVAL_UPDATED: this.infos[1] = TXT.cityClass[m.data.classification]; this.infos[2] = m.data.score; this.infos[3] = m.data.population; break; + //case Messages.FUNDS_CHANGED: this.infos[4] = m.data; break; + //case Messages.VALVES_UPDATED: this.infos[5] = m.data.residential; this.infos[6] = m.data.commercial; this.infos[7] = m.data.industrial; break; + default: + if (!messageOutput && TXT.goodMessages[m.message] !== undefined) { + this.infos[8] = TXT.goodMessages[m.message]; + break; + } + if (!messageOutput && TXT.badMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.badMessages[m.message]; + break; + } + if (!messageOutput && TXT.neutralMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.neutralMessages[m.message] ; + break; + } + } + } + } + + tool (name){ + + if(this.currentTool!==null) this.currentTool.clear(); + if(name !== "none") this.currentTool = this.gameTools[name]; + else this.currentTool = null; + + } + + destroy (x,y){ + + console.log('isDestroy'); + + //console.log( 'destuct ', x, y ) + + //this.mapClick(x,y); + //this.map.powerData[this.findId(x,y)] = 1; + + // this.simulation.powerManager.setTilePower(x,y); + // var messageMgr = new Micro.MessageManager(); + // this.gameTools["bulldozer"].doTool(x, y, messageMgr, this.simulation.blockMaps ); + } + + findId (x, y){ + var id = x+(y*this.mapSize[1]); + return id; + } + + mapClick (x,y, single){ + if( this.currentTool !== null ){ + //console.log(this.currentTool[0]) + var budget = this.simulation.budget; + this.simulation.evaluation; + var messageMgr = new MessageManager(); + this.currentTool.doTool(x, y, this.simulation.blockMaps, messageMgr ); + this.currentTool.modifyIfEnoughFunding(budget, messageMgr); + + switch (this.currentTool.result) { + case this.currentTool.TOOLRESULT_NEEDS_BULLDOZE: TXT.toolMessages.needsDoze; break; + case this.currentTool.TOOLRESULT_NO_MONEY: TXT.toolMessages.noMoney; break; + default: + //if( id >= 11 && id != 15 ) this.needMapUpdate = true; + if(!single) CityGame.post({tell:"BUILD", x:x, y:y }); + break; + } + + this.processMessages(messageMgr.getMessages()); + } + } + + setDisaster (disaster){ + if (disaster === Micro.DISASTER_NONE) return; + var m = new MessageManager(); + switch (disaster) { + case Micro.DISASTER_MONSTER: this.simulation.spriteManager.makeMonster(m); break; + case Micro.DISASTER_FIRE: this.simulation.disasterManager.makeFire(m); break; + case Micro.DISASTER_FLOOD: this.simulation.disasterManager.makeFlood(m); break; + case Micro.DISASTER_CRASH: this.simulation.disasterManager.makeCrash(m); break; + case Micro.DISASTER_MELTDOWN: this.simulation.disasterManager.makeMeltdown(m); break; + case Micro.DISASTER_TORNADO: this.simulation.spriteManager.makeTornado(m); break; + } + this.processMessages(m.getMessages()); + } + + setBudget (budgetData){ + this.simulation.budget.cityTax = budgetData[0]; + this.simulation.budget.roadPercent = budgetData[1]/100; + this.simulation.budget.firePercent = budgetData[2]/100; + this.simulation.budget.policePercent = budgetData[3]/100; + } + + handleBudgetRequest () { + + this.budgetShowing = true; + + let budgetData = { + roadFund: this.simulation.budget.roadFund, + roadRate: Math.floor(this.simulation.budget.roadPercent * 100), + fireFund: this.simulation.budget.fireFund, + fireRate: Math.floor(this.simulation.budget.firePercent * 100), + policeFund: this.simulation.budget.policeFund, + policeRate: Math.floor(this.simulation.budget.policePercent * 100), + taxRate: this.simulation.budget.cityTax, + totalFunds: this.simulation.budget.totalFunds, + taxesCollected: this.simulation.budget.taxFund + }; + + CityGame.post({ tell:"BUDGET", budgetData:budgetData}); + + if (this.simNeededBudget) { + this.simulation.budget.doBudgetWindow(); + this.simNeededBudget = false; + } else { + this.simulation.budget.updateFundEffects(); + } + + + + + //this.budgetWindow.open(this.handleBudgetClosed.bind(this), budgetData); + // Let the input know we handled this request + //this.inputStatus.budgetHandled(); + } + + getEvaluation (){ + let evaluation = this.simulation.evaluation; + let problemes = ""; + for (var i = 0; i < 4; i++) { + let problemNo = evaluation.getProblemNumber(i); + let text = ''; + if (problemNo !== -1) text =TXT.problems[problemNo]; + problemes += text+"
"; + } + + let evalData = [ evaluation.cityYes, problemes]; + + CityGame.post({ tell:"EVAL", evalData:evalData}); + + } + + + //______________________________________ SAVE + + + saveGame (cityData){ + //this.oldSpeed = this.speed; + //this.changeSpeed(0); + + let gameData = {name:"Yoooooo", everClicked: true}; + gameData.speed = this.speed; + gameData.difficulty = this.difficulty; + gameData.version = Micro.CURRENT_VERSION; + gameData.city = cityData; + this.simulation.save(gameData); + + gameData = JSON.stringify(gameData); + + CityGame.post({ tell:"SAVEGAME", gameData:gameData, key:Micro.KEY }); + + //this.changeSpeed(this.oldSpeed); + } + /*makeSaveGame : function(gameData){ + gameData.version = Micro.CURRENT_VERSION; + gameData = JSON.stringify(gameData); + }*/ + + //______________________________________ LOAD + + loadGame (atStart){ + var isStart = atStart || false; + CityGame.post({ tell:"LOADGAME", key:Micro.KEY, isStart:isStart }); + } + + makeLoadGame( gameData, atStart ) { + + + + let isStart = atStart || false; + clearInterval(this.timer); + this.savedGame = JSON.parse(gameData); + + + + //this.simulation.load(this.savedGame); + //this.map = this.simulation.map; + // this.everClicked = savedGame.everClicked; + //if (savedGame.version !== Micro.CURRENT_VERSION) this.transitionOldSave(savedGame); + //savedGame.isSavedGame = true; + /*if(this.map){ + this.map.load(this.savedGame); + }else{*/ + this.map = new GameMap(Micro.MAP_WIDTH, Micro.MAP_HEIGHT); + this.map.load(this.savedGame); + //} + + // + + //this.playMap(true); + //this.simulation.map = this.map;//return + // + //this.map = this.simulation.map; + + CityGame.post({ tell:"FULLREBUILD", tilesData:this.map.tilesData, mapSize:this.mapSize, island:this.map.isIsland, cityData:this.savedGame.city, isStart:isStart }); + } + + transitionOldSave (savedGame) { + switch (savedGame.version) { + case 1: savedGame.everClicked = false; + /* falls through */ + case 2: + savedGame.pollutionMaxX = Math.floor(savedGame.width / 2); + savedGame.pollutionMaxY = Math.floor(savedGame.height / 2); + savedGame.cityCentreX = Math.floor(savedGame.width / 2); + savedGame.cityCentreY = Math.floor(savedGame.height / 2); + break; + //default: throw new Error('Unknown save version!'); + } + } + +} + +export { CityGame, MainGame }; diff --git a/games/3dcity/build/draco/draco_decoder.js b/games/3dcity/build/draco/draco_decoder.js new file mode 100644 index 0000000..e58cce9 --- /dev/null +++ b/games/3dcity/build/draco/draco_decoder.js @@ -0,0 +1,48 @@ + +var DracoDecoderModule = (function() { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(DracoDecoderModule) { + DracoDecoderModule = DracoDecoderModule || {}; + +var Module=typeof DracoDecoderModule!=="undefined"?DracoDecoderModule:{};var isRuntimeInitialized=false;var isModuleParsed=false;Module["onRuntimeInitialized"]=function(){isRuntimeInitialized=true;if(isModuleParsed){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};Module["onModuleParsed"]=function(){isModuleParsed=true;if(isRuntimeInitialized){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};function isVersionSupported(versionString){if(typeof versionString!=="string")return false;const version=versionString.split(".");if(version.length<2||version.length>3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(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){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;if(end>_emscripten_get_heap_size()){abort()}HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(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 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}function convertJsFunctionToWasm(func,sig){return func}function addFunctionWasm(func,sig){var table=wasmTable;var ret=table.length;try{table.grow(1)}catch(err){if(!err instanceof RangeError){throw err}throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{table.set(ret,func)}catch(err){if(!err instanceof TypeError){throw err}assert(typeof sig!=="undefined","Missing signature argument to addFunction");var wrapped=convertJsFunctionToWasm(func,sig);table.set(ret,wrapped)}return ret}function removeFunctionWasm(index){}var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];var WebAssembly={Memory:function(opts){return{buffer:new ArrayBuffer(opts["initial"]*65536),grow:function(amount){var ret=__growWasmMemory(amount);return ret}}},Table:function(opts){var ret=new Array(opts["initial"]);ret.grow=function(by){if(ret.length>=293+0){abort("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.")}ret.push(null)};ret.set=function(i,func){ret[i]=func};ret.get=function(i){return ret[i]};return ret},Module:function(binary){return{}},Instance:function(module,info){var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=0;o[c>>2]=0;o[c+4>>2]=0;d=_j(b);if(d>>>0<4294967280){a:{b:{if(d>>>0>=11){f=d+16&-16;e=Hk(f);o[c+8>>2]=f|-2147483648;o[c>>2]=e;o[c+4>>2]=d;break b}m[c+11|0]=d;e=c;if(!d){break a}}wl(e,b,d)}m[d+e|0]=0;a=ea(a,c);if(m[c+11|0]<=-1){ul(o[c>>2])}R=c+16|0;return(a|0)!=0}Kk();D()}function ea(a,b){var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=o[a+4>>2];if(a){h=p[b+11|0];i=h<<24>>24<0;h=i?o[b+4>>2]:h;l=i?o[b>>2]:b;while(1){b=a+16|0;g=p[a+27|0];i=g<<24>>24<0;j=i?o[a+20>>2]:g;m=j>>>0>>0;a:{b:{c:{d:{e:{f:{g=m?j:h;if(g){k=i?o[b>>2]:b;n=Zj(l,k,g);if(n){break f}}if(h>>>0>>0){break a}if(!g){break d}k=i?o[b>>2]:b;break e}if((n|0)<=-1){break a}}b=Zj(k,l,g);if(b){break c}}if(m){break b}return 1}if((b|0)<=-1){break b}return 1}a=a+4|0}a=o[a>>2];if(a){continue}break}}return 0}function fa(a,b){var p=0,q=0,r=0,s=0;p=R-16|0;R=p;o[p+12>>2]=0;o[p+8>>2]=0;o[p>>2]=0;o[p+4>>2]=0;q=_j(b);if(q>>>0<4294967280){a:{b:{if(q>>>0>=11){s=q+16&-16;r=Hk(s);o[p+8>>2]=s|-2147483648;o[p>>2]=r;o[p+4>>2]=q;break b}m[p+11|0]=q;r=p;if(!q){break a}}wl(r,b,q)}m[q+r|0]=0;jj(a,p,p+12|0);a=o[p+12>>2];if(m[p+11|0]<=-1){ul(o[p>>2])}R=p+16|0;return a}Kk();D()}function ga(a,b,t){var u=0,v=0,w=0,x=0;u=R-32|0;R=u;o[u+24>>2]=0;o[u+16>>2]=0;o[u+20>>2]=0;v=_j(b);if(v>>>0<4294967280){a:{b:{if(v>>>0>=11){x=v+16&-16;w=Hk(x);o[u+24>>2]=x|-2147483648;o[u+16>>2]=w;o[u+20>>2]=v;break b}m[u+27|0]=v;w=u+16|0;if(!v){break a}}wl(w,b,v)}m[v+w|0]=0;o[u+8>>2]=0;o[u>>2]=0;o[u+4>>2]=0;kj(a,u+16|0,u);a=o[t>>2];if(a){o[t+4>>2]=a;ul(a);o[t+8>>2]=0;o[t>>2]=0;o[t+4>>2]=0}o[t>>2]=o[u>>2];o[t+4>>2]=o[u+4>>2];o[t+8>>2]=o[u+8>>2];if(m[u+27|0]<=-1){ul(o[u+16>>2])}R=u+32|0;return}Kk();D()}function ha(a,b){var y=0,z=0,A=0,B=0,C=0;y=R-32|0;R=y;o[y+24>>2]=0;o[y+28>>2]=0;o[y+16>>2]=0;o[y+8>>2]=0;o[y+12>>2]=0;z=_j(b);if(z>>>0<4294967280){a:{b:{if(z>>>0>=11){B=z+16&-16;A=Hk(B);o[y+16>>2]=B|-2147483648;o[y+8>>2]=A;o[y+12>>2]=z;break b}m[y+19|0]=z;A=y+8|0;if(!z){break a}}wl(A,b,z)}m[z+A|0]=0;lj(a,y+8|0,y+24|0);C=t[y+24>>3];if(m[y+19|0]<=-1){ul(o[y+8>>2])}R=y+32|0;return C}Kk();D()}function ia(a,b,t){var E=0,F=0,G=0,H=0;E=R-16|0;R=E;o[E+8>>2]=0;o[E>>2]=0;o[E+4>>2]=0;F=_j(t);if(F>>>0<4294967280){a:{b:{if(F>>>0>=11){H=F+16&-16;G=Hk(H);o[E+8>>2]=H|-2147483648;o[E>>2]=G;o[E+4>>2]=F;break b}m[E+11|0]=F;G=E;if(!F){break a}}wl(G,t,F)}m[F+G|0]=0;a=a+16|0;t=0;c:{if(!mj(b,E,a)){break c}t=o[a>>2];if(m[a+11|0]<=-1){break c}t=a}if(m[E+11|0]<=-1){ul(o[E>>2])}R=E+16|0;return t}Kk();D()}function ja(a,b,t){var D=0,I=0,J=0,K=0;a:{if(o[a+12>>2]==(b|0)){break a}D=o[a>>2];J=a+4|0;I=o[J>>2];if((D|0)!=(I|0)){while(1){K=I+ -12|0;if(m[I+ -1|0]<=-1){ul(o[K>>2])}I=K;if((I|0)!=(D|0)){continue}break}}o[a+12>>2]=b;o[J>>2]=D;I=o[b>>2];J=b+4|0;if((I|0)==(J|0)){break a}K=a+8|0;while(1){b=I+16|0;b:{if(o[K>>2]!=(D|0)){Mk(D,b);b=a+4|0;o[b>>2]=o[b>>2]+12;break b}ka(a,b)}D=o[I+4>>2];c:{if(!D){b=o[I+8>>2];if(o[b>>2]==(I|0)){break c}I=I+8|0;while(1){D=o[I>>2];I=D+8|0;b=o[D+8>>2];if((D|0)!=o[b>>2]){continue}break}break c}while(1){b=D;D=o[D>>2];if(D){continue}break}}if((b|0)==(J|0)){break a}D=o[a+4>>2];I=b;continue}}D=0;d:{if((t|0)<0){break d}b=o[a+4>>2];a=o[a>>2];if((b-a|0)/12>>>0<=t>>>0){break d}D=a+u(t,12)|0;if(m[D+11|0]>-1){break d}D=o[D>>2]}return D}function ka(a,b){var t=0,L=0,M=0,N=0,O=0;a:{b:{c:{M=o[a>>2];O=(o[a+4>>2]-M|0)/12|0;t=O+1|0;if(t>>>0<357913942){M=(o[a+8>>2]-M|0)/12|0;N=M<<1;t=M>>>0<178956970?N>>>0>>0?t:N:357913941;L=0;d:{if(!t){break d}if(t>>>0>=357913942){break c}L=Hk(u(t,12))}M=L+u(t,12)|0;b=Mk(L+u(O,12)|0,b);O=b+12|0;t=o[a+4>>2];L=o[a>>2];if((t|0)==(L|0)){break b}while(1){t=t+ -12|0;N=o[t+4>>2];b=b+ -12|0;o[b>>2]=o[t>>2];o[b+4>>2]=N;N=t+8|0;o[b+8>>2]=o[N>>2];o[t>>2]=0;o[t+4>>2]=0;o[N>>2]=0;if((t|0)!=(L|0)){continue}break}L=o[a+4>>2];t=o[a>>2];break a}Yk();D()}_a(1040);D()}t=L}o[a>>2]=b;o[a+8>>2]=M;o[a+4>>2]=O;if((t|0)!=(L|0)){while(1){a=L+ -12|0;if(m[L+ -1|0]<=-1){ul(o[a>>2])}L=a;if((a|0)!=(t|0)){continue}break}}if(t){ul(t)}}function la(a){var b=0;ui(a);b=a+16|0;o[b>>2]=0;o[b+4>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0;o[a+12>>2]=b;o[a+32>>2]=0;o[a+36>>2]=0;return a}function ma(a){var P=0;P=R-32|0;R=P;Rf(P+8|0,a);a=o[P+24>>2];if(m[P+23|0]<=-1){ul(o[P+12>>2])}R=P+32|0;return a}function na(a){var Q=0;Q=R-16|0;R=Q;Tf(Q);o[a+24>>2]=o[Q>>2];Ok(a+28|0,Q|4);a=a+24|0;if(m[Q+15|0]<=-1){ul(o[Q+4>>2])}R=Q+16|0;return a}function oa(a,S,T){var U=0;U=R-16|0;R=U;Sf(U,a,S,T);o[a+24>>2]=o[U>>2];Ok(a+28|0,U|4);a=a+24|0;if(m[U+15|0]<=-1){ul(o[U+4>>2])}R=U+16|0;return a}function pa(a,S){var T=0,V=0,W=0,X=0;T=R-32|0;R=T;o[T+24>>2]=0;o[T+16>>2]=0;o[T+20>>2]=0;V=_j(S);if(V>>>0<4294967280){a:{b:{if(V>>>0>=11){X=V+16&-16;W=Hk(X);o[T+24>>2]=X|-2147483648;o[T+16>>2]=W;o[T+20>>2]=V;break b}m[T+27|0]=V;W=T+16|0;if(!V){break a}}wl(W,S,V)}m[V+W|0]=0;o[T+8>>2]=67108864;o[T>>2]=0;o[T+4>>2]=0;m[T+4|0]=0;o[T>>2]=1701667182;V=o[a+4>>2];S=-1;c:{if(!V){break c}V=dj(V,T,T+16|0);S=-1;if(!V){break c}S=uj(a,o[V+24>>2])}if(m[T+11|0]<=-1){ul(o[T>>2])}if(m[T+27|0]<=-1){ul(o[T+16>>2])}R=T+32|0;return S}Kk();D()}function qa(a,S,Y){var Z=0,_=0,$=0,aa=0;Z=R-32|0;R=Z;o[Z+24>>2]=0;o[Z+16>>2]=0;o[Z+20>>2]=0;a:{aa=_j(S);if(aa>>>0<4294967280){b:{c:{if(aa>>>0>=11){_=aa+16&-16;$=Hk(_);o[Z+24>>2]=_|-2147483648;o[Z+16>>2]=$;o[Z+20>>2]=aa;break c}m[Z+27|0]=aa;$=Z+16|0;if(!aa){break b}}wl($,S,aa)}m[$+aa|0]=0;o[Z+8>>2]=0;o[Z>>2]=0;o[Z+4>>2]=0;_=_j(Y);if(_>>>0>=4294967280){break a}d:{e:{if(_>>>0>=11){S=_+16&-16;$=Hk(S);o[Z+8>>2]=S|-2147483648;o[Z>>2]=$;o[Z+4>>2]=_;break e}m[Z+11|0]=_;$=Z;if(!_){break d}}wl($,Y,_)}m[_+$|0]=0;Y=o[a+4>>2];S=-1;f:{if(!Y){break f}Y=dj(Y,Z+16|0,Z);S=-1;if(!Y){break f}S=uj(a,o[Y+24>>2])}a=S;if(m[Z+11|0]<=-1){ul(o[Z>>2])}if(m[Z+27|0]<=-1){ul(o[Z+16>>2])}R=Z+32|0;return a}Kk();D()}Kk();D()}function ra(a,S,Y){var ba=0,ca=0,da=0;ba=R-16|0;R=ba;ca=o[a+96>>2];o[ba+8>>2]=0;o[ba>>2]=0;o[ba+4>>2]=0;a=Hk(12);o[ba>>2]=a;o[ba+4>>2]=a;da=a+12|0;o[ba+8>>2]=da;ca=wl(a,ca+u(S,12)|0,12)+12|0;o[ba+4>>2]=ca;S=o[Y>>2];if(S){o[Y+4>>2]=S;ul(S);o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0}o[Y>>2]=a;o[Y+8>>2]=da;o[Y+4>>2]=ca;R=ba+16|0;return 1}function sa(a,S){var Y=0,ea=0;Y=R-96|0;R=Y;xl(Y+16|0,0,76);o[Y+92>>2]=-1;o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0;a:{if(ta(Y+16|0,a,Y)){a=o[S>>2];if(a){o[S+4>>2]=a;ul(a);o[S+8>>2]=0;o[S>>2]=0;o[S+4>>2]=0}o[S>>2]=o[Y>>2];o[S+4>>2]=o[Y+4>>2];o[S+8>>2]=o[Y+8>>2];o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0;ea=o[Y+84>>2];break a}a=o[Y>>2];if(!a){break a}o[Y+4>>2]=a;ul(a)}a=o[Y+72>>2];if(a){ul(a)}a=o[Y+48>>2];if(a){o[Y+52>>2]=a;ul(a)}a=o[Y+36>>2];if(a){o[Y+40>>2]=a;ul(a)}a=o[Y+24>>2];if(a){o[Y+28>>2]=a;ul(a)}a=o[Y+20>>2];o[Y+20>>2]=0;if(a){ua(Y+16|4,a)}R=Y+96|0;return ea}function ta(a,S,fa){var ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0;ja=R-16|0;R=ja;a:{if(!va(a,S)){break a}ia=1;ha=o[S+96>>2];oa=S+100|0;ga=o[oa>>2];if((ha|0)==(ga|0)){break a}pa=a+12|0;qa=a+24|0;ra=a+36|0;na=fa+8|0;la=fa+4|0;while(1){if(!(o[o[a+56>>2]+(ma>>>3&536870908)>>2]>>>(ma&31)&1)){ia=u(ma,3);Zi(a,0,ia);sa=o[pa>>2];ka=o[a+8>>2];Zi(a,1,ia+1|0);ha=o[qa>>2];ga=o[a+20>>2];Zi(a,2,ia+2|0);ia=ha-ga>>2;ha=sa-ka|0;ga=ha>>2;ka=ia>>>0>ga>>>0;ka=o[ra>>2]-o[a+32>>2]>>2>>>0>(ka?ia:ga)>>>0?2:ka?1:ha?0:-1;b:{if(o[a+68>>2]<1){break b}ga=o[a+76>>2];o[ja+12>>2]=ga;ha=o[la>>2];c:{if(ha>>>0>2]){o[ha>>2]=ga;o[la>>2]=ha+4;break c}wa(fa,ja+12|0)}ga=ja;ia=o[((ka<<2)+a|0)+44>>2];ha=-1;d:{if((ia|0)<0){break d}ha=(ia>>>0)/3|0;ha=o[(o[o[a>>2]+96>>2]+u(ha,12)|0)+(ia-u(ha,3)<<2)>>2]}o[ga+8>>2]=ha;ga=o[la>>2];e:{if(ga>>>0>2]){o[ga>>2]=ha;o[la>>2]=ga+4;break e}wa(fa,ja+8|0)}ga=o[a+72>>2]+2|0;o[a+72>>2]=ga;if(!(ga&1)){break b}o[ja+4>>2]=ha;ga=o[la>>2];f:{if(ga>>>0>2]){o[ga>>2]=ha;o[la>>2]=ga+4;break f}wa(fa,ja+4|0)}o[a+72>>2]=o[a+72>>2]+1}xa(a,ka,fa);ha=o[S+96>>2];ga=o[oa>>2]}ia=1;ma=ma+1|0;if(ma>>>0<(ga-ha|0)/12>>>0){continue}break}}R=ja+16|0;return ia}function ua(a,R){if(R){a=o[R+76>>2];if(a){o[R+80>>2]=a;ul(a)}a=o[R- -64>>2];if(a){o[R+68>>2]=a;ul(a)}a=o[R+48>>2];if(a){o[R+52>>2]=a;ul(a)}a=o[R+24>>2];if(a){o[R+28>>2]=a;ul(a)}a=o[R+12>>2];if(a){o[R+16>>2]=a;ul(a)}a=o[R>>2];if(a){o[R+4>>2]=a;ul(a)}ul(R)}}function va(a,S){var fa=0,ta=0,va=0;fa=R-16|0;R=fa;o[a+68>>2]=0;o[a+72>>2]=0;o[a>>2]=S;Yi(fa+8|0,S);ta=o[fa+8>>2];o[fa+8>>2]=0;va=o[a+4>>2];o[a+4>>2]=ta;a:{if(!va){o[fa+8>>2]=0;break a}ta=a+4|0;ua(ta,va);va=o[fa+8>>2];o[fa+8>>2]=0;if(va){ua(fa+8|0,va)}ta=o[ta>>2]}if(ta){ta=o[S+100>>2];S=o[S+96>>2];m[fa+7|0]=0;$a(a+56|0,(ta-S|0)/12|0,fa+7|0);a=1}else{a=0}R=fa+16|0;return a}function wa(a,R){var S=0,ua=0,wa=0,xa=0,ya=0,za=0;a:{wa=o[a>>2];ya=o[a+4>>2]-wa|0;S=ya>>2;ua=S+1|0;if(ua>>>0<1073741824){za=S<<2;S=o[a+8>>2]-wa|0;xa=S>>1;ua=S>>2>>>0<536870911?xa>>>0>>0?ua:xa:1073741823;S=0;b:{if(!ua){break b}if(ua>>>0>=1073741824){break a}S=Hk(ua<<2)}xa=za+S|0;o[xa>>2]=o[R>>2];R=S+(ua<<2)|0;ua=xa+4|0;if((ya|0)>=1){wl(S,wa,ya)}o[a>>2]=S;o[a+8>>2]=R;o[a+4>>2]=ua;if(wa){ul(wa)}return}Yk();D()}_a(1040);D()}function xa(a,Aa,Ba){var Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0;Ea=R-16|0;R=Ea;o[a+68>>2]=o[a+68>>2]+1;Ca=u(Aa,12)+a|0;Ca=o[Ca+12>>2]-o[Ca+8>>2]|0;if((Ca|0)>=1){Ja=Ca>>2;Ca=o[((Aa<<2)+a|0)+44>>2];Ha=Ba+8|0;Fa=Ba+4|0;while(1){Aa=Ca;Ga=(Ca>>>0)/3|0;Ca=(Ca|0)==-1?-1:Ga;Da=o[a+56>>2]+(Ca>>>3&536870908)|0;o[Da>>2]=o[Da>>2]|1<<(Ca&31);o[a+72>>2]=o[a+72>>2]+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2]+12>>2]+(Aa<<2)>>2]}Ia=Ia+1|0;if((Ia|0)<(Ja|0)){continue}break}}R=Ea+16|0}function ya(a,R,Aa){var Ba=0,Ka=0,La=0;a:{if(r[a+80>>2]>65535){break a}Ka=o[a+96>>2];a=o[a+100>>2]-Ka|0;La=(a|0)/12|0;if((u(La,6)|0)!=(R|0)){break a}if(!a){return 1}a=0;while(1){R=u(a,6)+Aa|0;Ba=u(a,12)+Ka|0;n[R>>1]=o[Ba>>2];n[R+2>>1]=o[Ba+4>>2];n[R+4>>1]=o[Ba+8>>2];Ba=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ba}function za(a,R,Aa){var Ma=0,Na=0,Oa=0;Na=o[a+96>>2];a=o[a+100>>2]-Na|0;Oa=(a|0)/12|0;if((a|0)==(R|0)){if(!R){return 1}a=0;while(1){Ma=u(a,12);R=Ma+Aa|0;Ma=Ma+Na|0;o[R>>2]=o[Ma>>2];o[R+4>>2]=o[Ma+4>>2];o[R+8>>2]=o[Ma+8>>2];Ma=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ma}function Aa(a,Aa,Pa){var Qa=0,Ra=0,Sa=0,Ta=0;Qa=R-32|0;R=Qa;Ra=m[a+24|0];Ta=o[259];o[Qa+24>>2]=o[258];o[Qa+28>>2]=Ta;Ta=o[257];o[Qa+16>>2]=o[256];o[Qa+20>>2]=Ta;a:{if(Ba(a,Aa,Ra,Qa+16|0)){a=0;o[Qa+8>>2]=0;o[Qa>>2]=0;o[Qa+4>>2]=0;Aa=0;if(Ra){if((Ra|0)<=-1){break a}Aa=Ra<<2;Sa=Hk(Aa);o[Qa>>2]=Sa;a=(Ra<<2)+Sa|0;o[Qa+8>>2]=a;wl(Sa,Qa+16|0,Aa);o[Qa+4>>2]=a;Aa=a}Ra=o[Pa>>2];if(Ra){o[Pa+4>>2]=Ra;ul(Ra);o[Pa+8>>2]=0;o[Pa>>2]=0;o[Pa+4>>2]=0;Aa=o[Qa+4>>2];Sa=o[Qa>>2];a=o[Qa+8>>2]}o[Pa>>2]=Sa;o[Pa+8>>2]=a;o[Pa+4>>2]=Aa;Sa=1}R=Qa+32|0;return Sa}Yk();D()}function Ba(a,R,Aa,Pa){var Ua=0,Va=0,Wa=v(0),Xa=0,Ya=0;a:{b:{if(!Pa){break b}Ua=o[a+28>>2]+ -1|0;if(Ua>>>0>10){break b}c:{switch(Ua-1|0){default:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(m[R|0]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(127)):Wa;R=R+1|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 0:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(p[R|0]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(255)):Wa;R=R+1|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 1:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(n[R>>1]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(32767)):Wa;R=R+2|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 2:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(q[R>>1]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(65535)):Wa;R=R+2|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 3:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(o[R>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(4.656612873077393e-10)):Wa;R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 4:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(r[R>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(2.3283064365386963e-10)):Wa;R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 5:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(+r[R>>2]+4294967296*+o[R+4>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(1.0842021724855044e-19)):Wa;R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 6:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(+r[R>>2]+4294967296*+r[R+4>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(5.421010862427522e-20)):Wa;R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 7:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){o[(Va<<2)+Pa>>2]=o[R>>2];R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 8:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){s[(Va<<2)+Pa>>2]=t[R>>3];R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 9:break c}}Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){s[(Va<<2)+Pa>>2]=p[R|0]?v(1):v(0);R=R+1|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}xl((Ua<<2)+Pa|0,0,Aa-Ua<<2)}return Ya}xl((Ua<<2)+Pa|0,0,Aa-Ua<<2);return 1}function Ca(a,Aa,Pa){var Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0;Za=R-16|0;R=Za;bb=o[a+80>>2];cb=m[Aa+24|0];a=o[259];o[Za+8>>2]=o[258];o[Za+12>>2]=a;a=o[257];o[Za>>2]=o[256];o[Za+4>>2]=a;a=u(bb,cb);$a=o[Pa>>2];_a=o[Pa+4>>2]-$a>>2;a:{if(a>>>0>_a>>>0){Da(Pa,a-_a|0);break a}if(a>>>0>=_a>>>0){break a}o[Pa+4>>2]=$a+(a<<2)}b:{if(!bb){a=1;break b}$a=0;db=Aa+68|0;eb=(cb|0)<1;while(1){a=ab;_a=Aa;if(!p[_a+84|0]){a=o[o[db>>2]+(ab<<2)>>2]}if(!Ba(_a,a,m[Aa+24|0],Za)){a=0;break b}if(!eb){_a=o[Pa>>2];a=0;while(1){o[_a+($a<<2)>>2]=o[(a<<2)+Za>>2];$a=$a+1|0;a=a+1|0;if((cb|0)!=(a|0)){continue}break}}a=1;ab=ab+1|0;if((bb|0)!=(ab|0)){continue}break}}R=Za+16|0;return a}function Da(a,R){var Aa=0,Pa=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0;Pa=o[a+8>>2];fb=a+4|0;Aa=o[fb>>2];if(Pa-Aa>>2>>>0>=R>>>0){a=R<<2;kb=fb,lb=xl(Aa,0,a)+a|0,o[kb>>2]=lb;return}a:{fb=o[a>>2];hb=Aa-fb|0;Aa=hb>>2;gb=Aa+R|0;if(gb>>>0<1073741824){jb=Aa<<2;Pa=Pa-fb|0;Aa=Pa>>1;Pa=Pa>>2>>>0<536870911?Aa>>>0>>0?gb:Aa:1073741823;Aa=0;b:{if(!Pa){break b}if(Pa>>>0>=1073741824){break a}ib=Hk(Pa<<2);Aa=ib}xl(jb+Aa|0,0,R<<2);R=Aa+(gb<<2)|0;gb=Aa+(Pa<<2)|0;if((hb|0)>=1){wl(ib,fb,hb)}o[a>>2]=Aa;o[a+8>>2]=gb;o[a+4>>2]=R;if(fb){ul(fb)}return}Yk();D()}_a(1040);D()}function Ea(a,mb,nb){var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0;pb=R-16|0;R=pb;sb=o[a+80>>2];rb=m[mb+24|0];qb=u(sb,rb);a:{a=o[mb+28>>2];b:{if(!(!p[mb+84|0]|((a|0)!=2?(a|0)!=1:0))){rb=o[mb+48>>2];mb=o[o[mb>>2]>>2];o[pb+8>>2]=0;o[pb>>2]=0;o[pb+4>>2]=0;a=0;if(qb){if((qb|0)<=-1){break a}a=Hk(qb);o[pb>>2]=a;ob=a+qb|0;o[pb+8>>2]=ob;wl(a,mb+rb|0,qb);o[pb+4>>2]=ob}mb=o[nb>>2];if(mb){o[nb+4>>2]=mb;ul(mb);o[nb+8>>2]=0;o[nb>>2]=0;o[nb+4>>2]=0}o[nb>>2]=a;o[nb+8>>2]=ob;o[nb+4>>2]=ob;ob=1;break b}o[pb+8>>2]=0;o[pb>>2]=0;o[pb+4>>2]=0;if(rb){if((rb|0)<=-1){break a}ob=Hk(rb);o[pb>>2]=ob;o[pb+4>>2]=ob;o[pb+8>>2]=ob+rb;a=rb;while(1){m[ob|0]=0;ob=o[pb+4>>2]+1|0;o[pb+4>>2]=ob;a=a+ -1|0;if(a){continue}break}}ob=o[nb>>2];a=o[nb+4>>2]-ob|0;c:{if(qb>>>0>a>>>0){Fa(nb,qb-a|0);break c}if(qb>>>0>=a>>>0){break c}o[nb+4>>2]=ob+qb}d:{if(!sb){ob=1;break d}a=0;tb=mb+68|0;ub=(rb|0)<1;qb=0;while(1){ob=qb;vb=mb;if(!p[mb+84|0]){ob=o[o[tb>>2]+(qb<<2)>>2]}if(!Ga(vb,ob,m[mb+24|0],o[pb>>2])){ob=0;break d}ob=0;if(!ub){while(1){m[o[nb>>2]+a|0]=p[o[pb>>2]+ob|0];a=a+1|0;ob=ob+1|0;if((rb|0)!=(ob|0)){continue}break}}ob=1;qb=qb+1|0;if((sb|0)!=(qb|0)){continue}break}}a=o[pb>>2];if(!a){break b}o[pb+4>>2]=a;ul(a)}R=pb+16|0;return ob}Yk();D()}function Fa(a,R){var mb=0,nb=0,wb=0,xb=0,yb=0,zb=0;a:{nb=o[a+8>>2];wb=a+4|0;mb=o[wb>>2];b:{if(nb-mb>>>0>=R>>>0){while(1){m[mb|0]=0;mb=o[wb>>2]+1|0;o[wb>>2]=mb;R=R+ -1|0;if(R){continue}break b}}xb=o[a>>2];yb=mb-xb|0;mb=yb+R|0;if((mb|0)<=-1){break a}wb=0;nb=nb-xb|0;zb=nb<<1;nb=nb>>>0<1073741823?zb>>>0>>0?mb:zb:2147483647;if(nb){wb=Hk(nb)}mb=wb+yb|0;xl(mb,0,R);nb=nb+wb|0;while(1){mb=mb+1|0;R=R+ -1|0;if(R){continue}break}if((yb|0)>=1){wl(wb,xb,yb)}o[a>>2]=wb;o[a+8>>2]=nb;o[a+4>>2]=mb;if(!xb){break b}ul(xb)}return}Yk();D()}function Ga(a,R,Ab,Bb){var Cb=0,Db=0,Eb=0,Fb=0,Gb=v(0),Hb=0;a:{b:{if(!Bb){break b}Cb=o[a+28>>2]+ -1|0;if(Cb>>>0>10){break b}c:{d:{e:{switch(Cb-1|0){default:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 0:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 1:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+2|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 2:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+2|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 3:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+4|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 4:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+4|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 5:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 6:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 7:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24<1){break c}Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){Cb=Bb+Db|0;Gb=s[R>>2];f:{if(v(w(Gb))(Ab|0)?Ab:Cb)<<24>>24){continue}break}break c;case 8:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24<1){break d}Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){Cb=Bb+Db|0;Hb=t[R>>3];g:{if(w(Hb)<2147483648){Fb=~~Hb;break g}Fb=-2147483648}m[Cb|0]=Fb;R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}break d;case 9:break e}}Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}xl(Bb+Cb|0,0,Ab-Cb|0);break b}if((Cb|0)>=(Ab|0)){break b}break a}if((Cb|0)>=(Ab|0)){break b}break a}return Eb}xl(Bb+Cb|0,0,Ab-Cb|0);return 1}function Ha(a,Ab,Bb){var Ib=0,Jb=0,Kb=0,Lb=0,Mb=0,Nb=0,Ob=0,Pb=0;Jb=R-16|0;R=Jb;Mb=o[a+80>>2];Lb=m[Ab+24|0];Kb=u(Mb,Lb);a:{a=o[Ab+28>>2];b:{if(!(!p[Ab+84|0]|((a|0)!=2?(a|0)!=1:0))){Lb=o[Ab+48>>2];Ab=o[o[Ab>>2]>>2];o[Jb+8>>2]=0;o[Jb>>2]=0;o[Jb+4>>2]=0;a=0;if(Kb){if((Kb|0)<=-1){break a}a=Hk(Kb);o[J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0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+1|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 0:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+1|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 1:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+2|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 2:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+2|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 3:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 4:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 5:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 6:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 7:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24<1){break c}Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){Qb=Bb+Rb|0;Ub=s[R>>2];f:{if(Ub=v(0)){Tb=~~Ub>>>0;break f}Tb=0}m[Qb|0]=Tb;R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}break c;case 8:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24<1){break d}Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){Qb=Bb+Rb|0;Vb=t[R>>3];g:{if(Vb<4294967296&Vb>=0){Tb=~~Vb>>>0;break g}Tb=0}m[Qb|0]=Tb;R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}break d;case 9:break e}}Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+1|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}xl(Bb+Qb|0,0,Ab-Qb|0);break b}if((Qb|0)>=(Ab|0)){break b}break a}if((Qb|0)>=(Ab|0)){break b}break a}return Sb}xl(Bb+Qb|0,0,Ab-Qb|0);return 1}function Ja(a,Ab,Bb){var Wb=0,Xb=0,Yb=0,Zb=0,_b=0,$b=0,ac=0,bc=0,cc=0;Wb=R-16|0;R=Wb;ac=o[a+80>>2];_b=m[Ab+24|0];a=u(ac,_b);a:{Xb=o[Ab+28>>2];b:{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,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;Bb=o[a+8>>2];dc=a+4|0;Ab=o[dc>>2];if(Bb-Ab>>1>>>0>=R>>>0){a=R<<1;ic=dc,jc=xl(Ab,0,a)+a|0,o[ic>>2]=jc;return}a:{dc=o[a>>2];fc=Ab-dc|0;Ab=fc>>1;ec=Ab+R|0;if((ec|0)>-1){hc=Ab<<1;Bb=Bb-dc|0;Bb=Bb>>1>>>0<1073741823?Bb>>>0>>0?ec:Bb:2147483647;Ab=0;b:{if(!Bb){break b}if((Bb|0)<=-1){break a}gc=Hk(Bb<<1);Ab=gc}xl(hc+Ab|0,0,R<<1);R=Ab+(ec<<1)|0;ec=Ab+(Bb<<1)|0;if((fc|0)>=1){wl(gc,dc,fc)}o[a>>2]=Ab;o[a+8>>2]=ec;o[a+4>>2]=R;if(dc){ul(dc)}return}Yk();D()}_a(1040);D()}function La(a,R,kc,lc){var mc=0,nc=0,oc=0,pc=0,qc=v(0),rc=0;a:{b:{if(!lc){break b}mc=o[a+28>>2]+ -1|0;if(mc>>>0>10){break b}c:{d:{e:{switch(mc-1|0){default:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=m[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 0:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=p[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 1:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=q[R>>1];R=R+2|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 2:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=q[R>>1];R=R+2|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 3:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 4:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 5:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 6:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 7:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24<1){break c}mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){mc=(nc<<1)+lc|0;qc=s[R>>2];f:{if(v(w(qc))>1]=pc;R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}break c;case 8:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24<1){break d}mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){mc=(nc<<1)+lc|0;rc=t[R>>3];g:{if(w(rc)<2147483648){pc=~~rc;break g}pc=-2147483648}n[mc>>1]=pc;R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}break d;case 9:break e}}oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=p[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}xl((mc<<1)+lc|0,0,kc-mc<<1);break b}if((mc|0)>=(kc|0)){break b}break a}if((mc|0)>=(kc|0)){break b}break a}return oc}xl((mc<<1)+lc|0,0,kc-mc<<1);return 1}function Ma(a,kc,lc){var sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0;sc=R-16|0;R=sc;yc=o[a+80>>2];wc=m[kc+24|0];a=u(yc,wc);a:{tc=o[kc+28>>2];b:{if(!(!p[kc+84|0]|((tc|0)!=4?(tc|0)!=3:0))){xc=o[kc+48>>2];tc=o[o[kc>>2]>>2];o[sc+8>>2]=0;o[sc>>2]=0;o[sc+4>>2]=0;kc=0;a=a<<1;if(a){if((a|0)<=-1){break a}uc=Hk(a);o[sc>>2]=uc;vc=(a>>1<<1)+uc|0;o[sc+8>>2]=vc;kc=wl(uc,tc+xc|0,a)+a|0;o[sc+4>>2]=kc}a=o[lc>>2];if(a){o[lc+4>>2]=a;ul(a);o[lc+8>>2]=0;o[lc>>2]=0;o[lc+4>>2]=0}o[lc>>2]=uc;o[lc+8>>2]=vc;o[lc+4>>2]=kc;a=1;break b}o[sc+8>>2]=0;o[sc>>2]=0;o[sc+4>>2]=0;if(wc){if((wc|0)<=-1){break a}tc=wc<<1;uc=Hk(tc);o[sc>>2]=uc;vc=tc+uc|0;o[sc+8>>2]=vc;xl(uc,0,tc);o[sc+4>>2]=vc}uc=o[lc>>2];tc=o[lc+4>>2]-uc>>1;c:{if(a>>>0>tc>>>0){Ka(lc,a-tc|0);break c}if(a>>>0>=tc>>>0){break c}o[lc+4>>2]=uc+(a<<1)}d:{if(!yc){a=1;break d}uc=0;vc=kc+68|0;zc=(wc|0)<1;while(1){a=xc;tc=kc;if(!p[kc+84|0]){a=o[o[vc>>2]+(xc<<2)>>2]}if(!Na(tc,a,m[kc+24|0],o[sc>>2])){a=0;break d}if(!zc){tc=o[lc>>2];a=0;Ac=o[sc>>2];while(1){n[tc+(uc<<1)>>1]=q[Ac+(a<<1)>>1];uc=uc+1|0;a=a+1|0;if((wc|0)!=(a|0)){continue}break}}a=1;xc=xc+1|0;if((yc|0)!=(xc|0)){continue}break}}kc=o[sc>>2];if(!kc){break b}o[sc+4>>2]=kc;ul(kc)}R=sc+16|0;return a}Yk();D()}function Na(a,R,kc,lc){var Bc=0,Cc=0,Dc=0,Ec=0,Fc=v(0),Gc=0;a:{b:{if(!lc){break b}Bc=o[a+28>>2]+ -1|0;if(Bc>>>0>10){break b}c:{d:{e:{switch(Bc-1|0){default:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=m[R|0];R=R+1|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 0:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=p[R|0];R=R+1|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 1:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=q[R>>1];R=R+2|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 2:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=q[R>>1];R=R+2|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 3:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 4:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 5:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 6:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 7:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24<1){break c}Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){Bc=(Cc<<1)+lc|0;Fc=s[R>>2];f:{if(Fc=v(0)){Ec=~~Fc>>>0;break f}Ec=0}n[Bc>>1]=Ec;R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}break c;case 8:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24<1){break d}Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){Bc=(Cc<<1)+lc|0;Gc=t[R>>3];g:{if(Gc<4294967296&Gc>=0){Ec=~~Gc>>>0;break g}Ec=0}n[Bc>>1]=Ec;R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}break d;case 9:break e}}Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[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4>>2]-Ic>>2;d:{if(Jc>>>0>a>>>0){Da(lc,Jc-a|0);break d}if(Jc>>>0>=a>>>0){break d}o[lc+4>>2]=Ic+(Jc<<2)}e:{if(!Nc){a=1;break e}Ic=0;Lc=kc+68|0;Oc=(Kc|0)<1;while(1){a=Mc;Jc=kc;if(!p[kc+84|0]){a=o[o[Lc>>2]+(Mc<<2)>>2]}if(!Pa(Jc,a,m[kc+24|0],o[Hc>>2])){a=0;break e}if(!Oc){Jc=o[lc>>2];a=0;Pc=o[Hc>>2];while(1){o[Jc+(Ic<<2)>>2]=o[Pc+(a<<2)>>2];Ic=Ic+1|0;a=a+1|0;if((Kc|0)!=(a|0)){continue}break}}a=1;Mc=Mc+1|0;if((Nc|0)!=(Mc|0)){continue}break}}kc=o[Hc>>2];if(!kc){break b}o[Hc+4>>2]=kc;ul(kc)}R=Hc+16|0;return a}Yk();D()}function Pa(a,R,kc,lc){var Qc=0,Rc=0,Sc=0,Tc=0,Uc=v(0),Vc=0;a:{b:{if(!lc){break b}Qc=o[a+28>>2]+ -1|0;if(Qc>>>0>10){break b}c:{d:{e:{switch(Qc-1|0){default:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=m[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 0:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=p[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 1:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=n[R>>1];R=R+2|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 2:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=q[R>>1];R=R+2|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 3:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 4:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 5:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 6:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 7:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24<1){break c}Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){Qc=(Rc<<2)+lc|0;Uc=s[R>>2];f:{if(v(w(Uc))>2]=Tc;R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}break c;case 8:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24<1){break d}Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){Qc=(Rc<<2)+lc|0;Vc=t[R>>3];g:{if(w(Vc)<2147483648){Tc=~~Vc;break g}Tc=-2147483648}o[Qc>>2]=Tc;R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}break d;case 9:break e}}Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=p[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}xl((Qc<<2)+lc|0,0,kc-Qc<<2);break b}if((Qc|0)>=(kc|0)){break b}break a}if((Qc|0)>=(kc|0)){break b}break a}return Sc}xl((Qc<<2)+lc|0,0,kc-Qc<<2);return 1}function Qa(a,kc,lc){var Wc=0,Xc=0,Yc=0,Zc=0,_c=0,$c=0,ad=0,bd=0,cd=0;Wc=R-16|0;R=Wc;ad=o[a+80>>2];Zc=m[kc+24|0];Yc=u(ad,Zc);a:{a=o[kc+28>>2];b:{if(!(!p[kc+84|0]|((a|0)!=6?(a|0)!=5:0))){$c=o[kc+48>>2];Zc=o[o[kc>>2]>>2];o[Wc+8>>2]=0;o[Wc>>2]=0;o[Wc+4>>2]=0;a=0;kc=Yc<<2;c:{if(!kc){break c}a=kc>>2;if(a>>>0>=1073741824){break a}Xc=Hk(kc);o[Wc>>2]=Xc;o[Wc+4>>2]=Xc;_c=(a<<2)+Xc|0;o[Wc+8>>2]=_c;if((kc|0)<1){a=Xc;break c}a=wl(Xc,Zc+$c|0,kc)+kc|0;o[Wc+4>>2]=a}kc=o[lc>>2];if(kc){o[lc+4>>2]=kc;ul(kc);o[lc+8>>2]=0;o[lc>>2]=0;o[lc+4>>2]=0}o[lc>>2]=Xc;o[lc+8>>2]=_c;o[lc+4>>2]=a;a=1;break b}o[Wc+8>>2]=0;o[Wc>>2]=0;o[Wc+4>>2]=0;if(Zc){if((Zc|0)<=-1){break a}a=Zc<<2;Xc=Hk(a);o[Wc>>2]=Xc;_c=a+Xc|0;o[Wc+8>>2]=_c;xl(Xc,0,a);o[Wc+4>>2]=_c}Xc=o[lc>>2];a=o[lc+4>>2]-Xc>>2;d:{if(Yc>>>0>a>>>0){Da(lc,Yc-a|0);break d}if(Yc>>>0>=a>>>0){break d}o[lc+4>>2]=Xc+(Yc<<2)}e:{if(!ad){a=1;break e}Xc=0;_c=kc+68|0;bd=(Zc|0)<1;while(1){a=$c;Yc=kc;if(!p[kc+84|0]){a=o[o[_c>>2]+($c<<2)>>2]}if(!Ra(Yc,a,m[kc+24|0],o[Wc>>2])){a=0;break e}if(!bd){Yc=o[lc>>2];a=0;cd=o[Wc>>2];while(1){o[Yc+(Xc<<2)>>2]=o[cd+(a<<2)>>2];Xc=Xc+1|0;a=a+1|0;if((Zc|0)!=(a|0)){continue}break}}a=1;$c=$c+1|0;if((ad|0)!=($c|0)){continue}break}}kc=o[Wc>>2];if(!kc){break b}o[Wc+4>>2]=kc;ul(kc)}R=Wc+16|0;return a}Yk();D()}function Ra(a,R,kc,lc){var dd=0,ed=0,fd=0,gd=0,hd=v(0),id=0;a:{b:{if(!lc){break b}dd=o[a+28>>2]+ -1|0;if(dd>>>0>10){break b}c:{d:{e:{switch(dd-1|0){default:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=m[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 0:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=p[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 1:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=n[R>>1];R=R+2|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 2:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=q[R>>1];R=R+2|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 3:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 4:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 5:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 6:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 7:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24<1){break c}dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){dd=(ed<<2)+lc|0;hd=s[R>>2];f:{if(hd=v(0)){gd=~~hd>>>0;break f}gd=0}o[dd>>2]=gd;R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}break c;case 8:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24<1){break d}dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){dd=(ed<<2)+lc|0;id=t[R>>3];g:{if(id<4294967296&id>=0){gd=~~id>>>0;break g}gd=0}o[dd>>2]=gd;R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}break d;case 9:break e}}fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=p[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}xl((dd<<2)+lc|0,0,kc-dd<<2);break b}if((dd|0)>=(kc|0)){break b}break a}if((dd|0)>=(kc|0)){break b}break a}return fd}xl((dd<<2)+lc|0,0,kc-dd<<2);return 1}function Sa(a,kc,lc,jd,kd){var ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0;md=R-16|0;R=md;lc=lc+ -1|0;a:{if(lc>>>0>8){break a}b:{switch(lc-1|0){default:ld=Ta(a,kc,jd,kd);break a;case 1:ld=Ua(a,kc,jd,kd);break a;case 3:ld=Va(a,kc,jd,kd);break a;case 0:ld=Wa(a,kc,jd,kd);break a;case 2:ld=Xa(a,kc,jd,kd);break a;case 4:ld=Ya(a,kc,jd,kd);break a;case 5:case 6:break a;case 7:break b}}nd=o[a+80>>2];od=m[kc+24|0];pd=od<<2;if((u(nd,pd)|0)!=(jd|0)){break a}a=0;lc=o[259];o[md+8>>2]=o[258];o[md+12>>2]=lc;lc=o[257];o[md>>2]=o[256];o[md+4>>2]=lc;if(!nd){ld=1;break a}qd=kc+68|0;rd=(od|0)<1;lc=0;while(1){jd=lc;ld=kc;if(!p[kc+84|0]){jd=o[o[qd>>2]+(lc<<2)>>2]}if(!Ba(ld,jd,m[kc+24|0],md)){ld=0;break a}if(!rd){wl((a<<2)+kd|0,md,pd);a=a+od|0}ld=1;lc=lc+1|0;if((nd|0)!=(lc|0)){continue}break}}R=md+16|0;return ld}function Ta(a,kc,lc,jd){var kd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0;sd=R-16|0;R=sd;a:{vd=o[a+80>>2];td=m[kc+24|0];b:{if((u(vd,td)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=1)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);kd=1;break b}o[sd+8>>2]=0;o[sd>>2]=0;o[sd+4>>2]=0;if(td){if((td|0)<=-1){break a}kd=Hk(td);o[sd>>2]=kd;o[sd+4>>2]=kd;o[sd+8>>2]=kd+td;lc=td;while(1){m[kd|0]=0;kd=o[sd+4>>2]+1|0;o[sd+4>>2]=kd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!vd){kd=1;break c}lc=0;wd=kc+68|0;xd=(td|0)<1;while(1){a=ud;kd=kc;if(!p[kd+84|0]){a=o[o[wd>>2]+(ud<<2)>>2]}if(!Ga(kd,a,m[kc+24|0],o[sd>>2])){kd=0;break c}if(!xd){kd=0;a=o[sd>>2];while(1){m[lc+jd|0]=p[a+kd|0];lc=lc+1|0;kd=kd+1|0;if((td|0)!=(kd|0)){continue}break}}kd=1;ud=ud+1|0;if((vd|0)!=(ud|0)){continue}break}}a=o[sd>>2];if(!a){break b}o[sd+4>>2]=a;ul(a)}R=sd+16|0;return kd}Yk();D()}function Ua(a,kc,lc,jd){var yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;yd=R-16|0;R=yd;a:{Cd=o[a+80>>2];Ad=m[kc+24|0];a=Ad<<1;b:{if((u(Cd,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=3)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);zd=1;break b}lc=0;o[yd+8>>2]=0;o[yd>>2]=0;o[yd+4>>2]=0;if(Ad){if((Ad|0)<=-1){break a}lc=Hk(a);o[yd>>2]=lc;o[yd+8>>2]=(Ad<<1)+lc;Fd=yd,Gd=xl(lc,0,a)+a|0,o[Fd+4>>2]=Gd}c:{if(!Cd){zd=1;break c}lc=0;Dd=kc+68|0;Ed=(Ad|0)<1;while(1){a=Bd;zd=kc;if(!p[kc+84|0]){a=o[o[Dd>>2]+(Bd<<2)>>2]}d:{if(!La(zd,a,m[kc+24|0],o[yd>>2])){zd=0;break d}if(!Ed){zd=0;a=o[yd>>2];while(1){n[(lc<<1)+jd>>1]=q[a+(zd<<1)>>1];lc=lc+1|0;zd=zd+1|0;if((Ad|0)!=(zd|0)){continue}break}}zd=1;Bd=Bd+1|0;if((Cd|0)!=(Bd|0)){continue}}break}lc=o[yd>>2]}if(!lc){break b}o[yd+4>>2]=lc;ul(lc)}R=yd+16|0;return zd}Yk();D()}function Va(a,kc,lc,jd){var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0,Od=0,Pd=0;Hd=R-16|0;R=Hd;a:{Ld=o[a+80>>2];Jd=m[kc+24|0];a=Jd<<2;b:{if((u(Ld,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=5)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);Id=1;break b}lc=0;o[Hd+8>>2]=0;o[Hd>>2]=0;o[Hd+4>>2]=0;if(Jd){if((Jd|0)<=-1){break a}lc=Hk(a);o[Hd>>2]=lc;o[Hd+8>>2]=(Jd<<2)+lc;Od=Hd,Pd=xl(lc,0,a)+a|0,o[Od+4>>2]=Pd}c:{if(!Ld){Id=1;break c}lc=0;Md=kc+68|0;Nd=(Jd|0)<1;while(1){a=Kd;Id=kc;if(!p[kc+84|0]){a=o[o[Md>>2]+(Kd<<2)>>2]}d:{if(!Pa(Id,a,m[kc+24|0],o[Hd>>2])){Id=0;break d}if(!Nd){Id=0;a=o[Hd>>2];while(1){o[(lc<<2)+jd>>2]=o[a+(Id<<2)>>2];lc=lc+1|0;Id=Id+1|0;if((Jd|0)!=(Id|0)){continue}break}}Id=1;Kd=Kd+1|0;if((Ld|0)!=(Kd|0)){continue}}break}lc=o[Hd>>2]}if(!lc){break b}o[Hd+4>>2]=lc;ul(lc)}R=Hd+16|0;return Id}Yk();D()}function Wa(a,kc,lc,jd){var Qd=0,Rd=0,Sd=0,Td=0,Ud=0,Vd=0,Wd=0;Rd=R-16|0;R=Rd;a:{Ud=o[a+80>>2];Sd=m[kc+24|0];b:{if((u(Ud,Sd)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=2)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);Qd=1;break b}o[Rd+8>>2]=0;o[Rd>>2]=0;o[Rd+4>>2]=0;if(Sd){if((Sd|0)<=-1){break a}Qd=Hk(Sd);o[Rd>>2]=Qd;o[Rd+4>>2]=Qd;o[Rd+8>>2]=Qd+Sd;lc=Sd;while(1){m[Qd|0]=0;Qd=o[Rd+4>>2]+1|0;o[Rd+4>>2]=Qd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!Ud){Qd=1;break c}lc=0;Vd=kc+68|0;Wd=(Sd|0)<1;while(1){a=Td;Qd=kc;if(!p[Qd+84|0]){a=o[o[Vd>>2]+(Td<<2)>>2]}if(!Ia(Qd,a,m[kc+24|0],o[Rd>>2])){Qd=0;break c}if(!Wd){Qd=0;a=o[Rd>>2];while(1){m[lc+jd|0]=p[a+Qd|0];lc=lc+1|0;Qd=Qd+1|0;if((Sd|0)!=(Qd|0)){continue}break}}Qd=1;Td=Td+1|0;if((Ud|0)!=(Td|0)){continue}break}}a=o[Rd>>2];if(!a){break b}o[Rd+4>>2]=a;ul(a)}R=Rd+16|0;return Qd}Yk();D()}function Xa(a,kc,lc,jd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Xd=R-16|0;R=Xd;a:{$d=o[a+80>>2];Zd=m[kc+24|0];a=Zd<<1;b:{if((u($d,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=4)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);Yd=1;break b}lc=0;o[Xd+8>>2]=0;o[Xd>>2]=0;o[Xd+4>>2]=0;if(Zd){if((Zd|0)<=-1){break a}lc=Hk(a);o[Xd>>2]=lc;o[Xd+8>>2]=(Zd<<1)+lc;ce=Xd,de=xl(lc,0,a)+a|0,o[ce+4>>2]=de}c:{if(!$d){Yd=1;break c}lc=0;ae=kc+68|0;be=(Zd|0)<1;while(1){a=_d;Yd=kc;if(!p[kc+84|0]){a=o[o[ae>>2]+(_d<<2)>>2]}d:{if(!Na(Yd,a,m[kc+24|0],o[Xd>>2])){Yd=0;break d}if(!be){Yd=0;a=o[Xd>>2];while(1){n[(lc<<1)+jd>>1]=q[a+(Yd<<1)>>1];lc=lc+1|0;Yd=Yd+1|0;if((Zd|0)!=(Yd|0)){continue}break}}Yd=1;_d=_d+1|0;if(($d|0)!=(_d|0)){continue}}break}lc=o[Xd>>2]}if(!lc){break b}o[Xd+4>>2]=lc;ul(lc)}R=Xd+16|0;return Yd}Yk();D()}function Ya(a,kc,lc,jd){var ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0;ee=R-16|0;R=ee;a:{ie=o[a+80>>2];ge=m[kc+24|0];a=ge<<2;b:{if((u(ie,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=6)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);fe=1;break b}lc=0;o[ee+8>>2]=0;o[ee>>2]=0;o[ee+4>>2]=0;if(ge){if((ge|0)<=-1){break a}lc=Hk(a);o[ee>>2]=lc;o[ee+8>>2]=(ge<<2)+lc;le=ee,me=xl(lc,0,a)+a|0,o[le+4>>2]=me}c:{if(!ie){fe=1;break c}lc=0;je=kc+68|0;ke=(ge|0)<1;while(1){a=he;fe=kc;if(!p[kc+84|0]){a=o[o[je>>2]+(he<<2)>>2]}d:{if(!Ra(fe,a,m[kc+24|0],o[ee>>2])){fe=0;break d}if(!ke){fe=0;a=o[ee>>2];while(1){o[(lc<<2)+jd>>2]=o[a+(fe<<2)>>2];lc=lc+1|0;fe=fe+1|0;if((ge|0)!=(fe|0)){continue}break}}fe=1;he=he+1|0;if((ie|0)!=(he|0)){continue}}break}lc=o[ee>>2]}if(!lc){break b}o[ee+4>>2]=lc;ul(lc)}R=ee+16|0;return fe}Yk();D()}function Za(a,R){var kc=0,lc=0;kc=o[a+4>>2];if(!kc){return 0}R=o[o[o[a+8>>2]+(R<<2)>>2]+60>>2];if((R|0)<0){return 0}a=o[kc+24>>2];kc=o[kc+28>>2];if((a|0)==(kc|0)){return 0}a:{while(1){lc=o[a>>2];if((R|0)==o[lc+24>>2]){break a}a=a+4|0;if((kc|0)!=(a|0)){continue}break}return 0}return lc}function _a(a){var R=0;R=G(8)|0;o[R>>2]=12288;o[R>>2]=12332;Ik(R+4|0,a);o[R>>2]=12380;H(R|0,12412,1);D()}function $a(a,jd,ne){var oe=0,pe=0,qe=0,re=0,se=0;pe=R-16|0;R=pe;o[a+4>>2]=0;a:{b:{if(!jd){break b}qe=o[a+8>>2];oe=qe<<5;c:{if(oe>>>0>=jd>>>0){o[a+4>>2]=jd;break c}o[pe+8>>2]=0;o[pe>>2]=0;o[pe+4>>2]=0;if((jd|0)<=-1){break a}se=pe;if(oe>>>0<=1073741822){re=jd+31&-32;oe=qe<<6;re=oe>>>0>>0?re:oe}else{re=2147483647}ab(se,re);re=o[a>>2];o[a>>2]=o[pe>>2];o[pe>>2]=re;qe=o[a+4>>2];o[a+4>>2]=jd;o[pe+4>>2]=qe;oe=a+8|0;qe=o[oe>>2];o[oe>>2]=o[pe+8>>2];o[pe+8>>2]=qe;if(!re){break c}ul(re)}oe=jd>>>5;qe=oe<<2;a=o[a>>2];if(p[ne|0]){a=xl(a,255,qe);jd=jd&31;if(!jd){break b}a=a+(oe<<2)|0;o[a>>2]=o[a>>2]|-1>>>32-jd;break b}a=xl(a,0,qe);jd=jd&31;if(!jd){break b}a=a+(oe<<2)|0;o[a>>2]=o[a>>2]&(-1>>>32-jd^-1)}R=pe+16|0;return}Yk();D()}function ab(a,jd){var ne=0,te=0;ne=R-32|0;R=ne;a:{b:{if(o[a+8>>2]<<5>>>0>=jd>>>0){break b}o[ne+24>>2]=0;o[ne+16>>2]=0;o[ne+20>>2]=0;if((jd|0)<=-1){break a}jd=(jd+ -1>>>5)+1|0;te=Hk(jd<<2);o[ne+24>>2]=jd;o[ne+20>>2]=0;o[ne+16>>2]=te;jd=o[a>>2];o[ne+12>>2]=0;o[ne+8>>2]=jd;te=o[a+4>>2];o[ne+4>>2]=te&31;o[ne>>2]=jd+(te>>>3&536870908);bb(ne+16|0,ne+8|0,ne);jd=o[a>>2];o[a>>2]=o[ne+16>>2];o[ne+16>>2]=jd;te=o[a+4>>2];o[a+4>>2]=o[ne+20>>2];o[ne+20>>2]=te;a=a+8|0;te=o[a>>2];o[a>>2]=o[ne+24>>2];o[ne+24>>2]=te;if(!jd){break b}ul(jd)}R=ne+32|0;return}Yk();D()}function bb(a,jd,ue){var ve=0,we=0,xe=0,ye=0,ze=0,Ae=0;xe=R-32|0;R=xe;ze=o[ue+4>>2];ve=o[jd+4>>2];Ae=o[ue>>2];ye=o[jd>>2];jd=(ze-ve|0)+(Ae-ye<<3)|0;ue=o[a+4>>2];we=jd+ue|0;o[a+4>>2]=we;a:{if(!(!ue|(we+ -1^ue+ -1)>>>0>31)){a=o[a>>2];break a}a=o[a>>2];if(we>>>0<=32){o[a>>2]=0;break a}o[(we+ -1>>>3&536870908)+a>>2]=0}a=(ue>>>3&536870908)+a|0;ue=ue&31;b:{if((ue|0)==(ve|0)){c:{if((jd|0)<1){break c}d:{if(!ve){ue=0;break d}we=32-ve|0;ue=(jd|0)<(we|0)?jd:we;we=-1<>>we-ue;o[a>>2]=o[a>>2]&(we^-1)|we&o[ye>>2];jd=jd-ue|0;ve=ue+ve|0;ue=ve&31;a=(ve>>>3&536870908)+a|0;ye=ye+4|0}ve=(jd|0)/32|0;we=ve<<2;a=yl(a,ye,we)+we|0;ve=jd-(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]&(Ge&-1>>>Fe-Ee^-1);Fe=o[De>>2]&-1>>>32-Ce;o[jd>>2]=Ge|Fe<>2]=ue;De=jd+(De>>>3&536870908)|0;o[Be>>2]=De;jd=Ce-Ee|0;if((jd|0)<1){break a}o[De>>2]=o[De>>2]&(-1>>>32-jd^-1)|Fe>>>Ee;o[Be+4>>2]=jd;ue=jd}jd=o[Be>>2];o[a+4>>2]=ue;o[a>>2]=jd}function db(a){a=a|0;return o[a>>2]}function eb(a){a=a|0;return!o[a>>2]|0}function fb(a){a=a|0;var jd=0;jd=a+4|0;if(m[a+15|0]<=-1){jd=o[jd>>2]}return jd|0}function gb(a){a=a|0;if(a){if(m[a+15|0]<=-1){ul(o[a+4>>2])}ul(a)}}function hb(){var a=0;a=Hk(12);o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;return a|0}function ib(ue,Be){ue=ue|0;Be=Be|0;return q[o[ue>>2]+(Be<<1)>>1]}function jb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]>>1}function kb(ue){ue=ue|0;var Be=0;if(ue){Be=o[ue>>2];if(Be){o[ue+4>>2]=Be;ul(Be)}ul(ue)}}function lb(){return qj(Hk(84))|0}function mb(ue){ue=ue|0;return o[ue+12>>2]-o[ue+8>>2]>>2}function nb(ue){ue=ue|0;return o[ue+80>>2]}function ob(ue){ue=ue|0;if(ue){l[o[o[ue>>2]+4>>2]](ue)}}function pb(ue,Ke){ue=ue|0;Ke=Ke|0;return p[o[ue>>2]+Ke|0]}function qb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]|0}function rb(ue,Ke){ue=ue|0;Ke=Ke|0;return o[o[ue>>2]+(Ke<<2)>>2]}function sb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]>>2}function tb(){var ue=0;ue=Hk(8);o[ue+4>>2]=-1;o[ue>>2]=1116;return ue|0}function ub(Ke,Le){Ke=Ke|0;Le=Le|0;return l[o[o[Ke>>2]+12>>2]](Ke,Le)|0}function vb(Ke){Ke=Ke|0;return o[Ke+4>>2]}function wb(){return pd(Hk(96))|0}function xb(Ke){Ke=Ke|0;return o[Ke+88>>2]}function yb(Ke){Ke=Ke|0;return o[Ke+56>>2]}function zb(Ke){Ke=Ke|0;return o[Ke+28>>2]}function Ab(o){o=o|0;return m[o+24|0]}function Bb(o){o=o|0;return p[o+32|0]}function Cb(Ke){Ke=Ke|0;return o[Ke+40>>2]}function Db(Ke){Ke=Ke|0;return o[Ke+48>>2]}function Eb(Ke){Ke=Ke|0;return o[Ke+60>>2]}function Fb(Ke){Ke=Ke|0;var Le=0,Me=0;if(Ke){Le=Ke+88|0;Me=o[Le>>2];o[Le>>2]=0;if(Me){Le=o[Me+8>>2];if(Le){o[Me+12>>2]=Le;ul(Le)}ul(Me)}Me=o[Ke+68>>2];if(Me){o[Ke+72>>2]=Me;ul(Me)}Le=Ke- -64|0;Me=o[Le>>2];o[Le>>2]=0;if(Me){Le=o[Me>>2];if(Le){o[Me+4>>2]=Le;ul(Le)}ul(Me)}ul(Ke)}}function Gb(){var Ke=0;Ke=Hk(40);o[Ke>>2]=-1;ki(Ke+8|0);return Ke|0}function Hb(Ne){Ne=Ne|0;var Oe=0;if(Ne){Oe=o[Ne+8>>2];if(Oe){o[Ne+12>>2]=Oe;ul(Oe)}ul(Ne)}}function Ib(){var Ne=0;Ne=Hk(24);o[Ne+4>>2]=-1;o[Ne>>2]=1232;o[Ne+8>>2]=0;o[Ne+12>>2]=0;o[Ne+16>>2]=0;o[Ne+20>>2]=0;return Ne|0}function Jb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return v(s[o[Pe+8>>2]+(Qe<<2)>>2])}function Kb(o){o=o|0;return v(s[o+20>>2])}function Lb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return m[o[Pe>>2]+Qe|0]}function Mb(){var Pe=0;Pe=Hk(28);o[Pe>>2]=0;o[Pe+4>>2]=0;o[Pe+24>>2]=0;o[Pe+16>>2]=0;o[Pe+20>>2]=0;o[Pe+8>>2]=0;o[Pe+12>>2]=0;return Pe|0}function Nb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return da(Qe,Re)|0}function Ob(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return fa(Qe,Re)|0}function Pb(o,Qe,Re,Se){o=o|0;Qe=Qe|0;Re=Re|0;Se=Se|0;ga(Qe,Re,Se)}function Qb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return+ha(Qe,Re)}function Rb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return ia(o,Qe,Re)|0}function Sb(Qe,Re){Qe=Qe|0;Re=Re|0;return o[Re+8>>2]}function Tb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return ja(o,Qe,Re)|0}function Ub(Qe){Qe=Qe|0;var Re=0,Se=0,Te=0,Ue=0,Ve=0;if(Qe){if(m[Qe+27|0]<=-1){ul(o[Qe+16>>2])}Se=o[Qe>>2];if(Se){Re=Se;Ve=Qe+4|0;Te=o[Ve>>2];Ue=Re;a:{if((Te|0)==(Re|0)){break a}while(1){Re=Te+ -12|0;if(m[Te+ -1|0]<=-1){ul(o[Re>>2])}Te=Re;if((Re|0)!=(Se|0)){continue}break}Ue=o[Qe>>2]}Re=Ue;o[Ve>>2]=Se;ul(Re)}ul(Qe)}}function Vb(Qe,We){Qe=Qe|0;We=We|0;return n[o[Qe>>2]+(We<<1)>>1]}function Wb(Qe,We){Qe=Qe|0;We=We|0;return v(s[o[Qe>>2]+(We<<2)>>2])}function Xb(){return ld(Hk(64))|0}function Yb(o){o=o|0;if(o){ul(o)}}function Zb(){return oi(Hk(40))|0}function _b(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;o[Qe+16>>2]=0;o[Qe+20>>2]=0;o[Qe>>2]=We;o[Qe+8>>2]=Xe;o[Qe+12>>2]=0}function $b(){return la(Hk(40))|0}function ac(o,Qe){o=o|0;Qe=Qe|0;return ma(Qe)|0}function bc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return na(o)|0}function cc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return oa(o,Qe,We)|0}function dc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return rj(Qe,We)|0}function ec(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return pa(Qe,We)|0}function fc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return qa(Qe,We,Xe)|0}function gc(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;return o[o[We+8>>2]+(Xe<<2)>>2]}function hc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return tj(Qe,We)|0}function ic(Qe,We){Qe=Qe|0;We=We|0;return o[We+4>>2]}function jc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return Za(Qe,We)|0}function kc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ra(Qe,We,Xe)|0}function lc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return sa(Qe,We)|0}function mc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ya(Qe,We,Xe)|0}function nc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return za(Qe,We,Xe)|0}function oc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Aa(Qe,We,Xe)|0}function pc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ca(Qe,We,Xe)|0}function qc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Oa(Qe,We,Xe)|0}function rc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ea(Qe,We,Xe)|0}function sc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ha(Qe,We,Xe)|0}function tc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ja(Qe,We,Xe)|0}function uc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ma(Qe,We,Xe)|0}function vc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Qa(Qe,We,Xe)|0}function wc(o,Qe,We,Xe,Ye,Ze){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;Ye=Ye|0;Ze=Ze|0;return Sa(Qe,We,Xe,Ye,Ze)|0}function xc(o,Qe){o=o|0;Qe=Qe|0;Uf(o,Qe)}function yc(Qe){Qe=Qe|0;if(Qe){if(m[Qe+39|0]<=-1){ul(o[Qe+28>>2])}zc(Qe+12|0,o[Qe+16>>2]);Ac(Qe,o[Qe+4>>2]);ul(Qe)}}function zc(Qe,We){if(We){zc(Qe,o[We>>2]);zc(Qe,o[We+4>>2]);Ac(We+20|0,o[We+24>>2]);ul(We)}}function Ac(Qe,We){if(We){Ac(Qe,o[We>>2]);Ac(Qe,o[We+4>>2]);if(m[We+39|0]<=-1){ul(o[We+28>>2])}if(m[We+27|0]<=-1){ul(o[We+16>>2])}ul(We)}}function Bc(){return Li(Hk(108))|0}function Cc(Qe){Qe=Qe|0;return(o[Qe+100>>2]-o[Qe+96>>2]|0)/12|0}function Dc(){var Qe=0,We=0,Xe=0;We=Hk(24);Xe=We+4|0;Qe=Xe;o[Qe>>2]=0;o[Qe+4>>2]=0;Qe=We+16|0;o[Qe>>2]=0;o[Qe+4>>2]=0;o[We>>2]=Xe;o[We+12>>2]=Qe;return We|0}function Ec(Ye){Ye=Ye|0;if(Ye){Fc(Ye+12|0,o[Ye+16>>2]);Gc(Ye,o[Ye+4>>2]);ul(Ye)}}function Fc(Ye,Ze){var _e=0;if(Ze){Fc(Ye,o[Ze>>2]);Fc(Ye,o[Ze+4>>2]);_e=Ze+28|0;Ye=o[_e>>2];o[_e>>2]=0;if(Ye){Fc(Ye+12|0,o[Ye+16>>2]);Gc(Ye,o[Ye+4>>2]);ul(Ye)}if(m[Ze+27|0]<=-1){ul(o[Ze+16>>2])}ul(Ze)}}function Gc(Ye,Ze){if(Ze){Gc(Ye,o[Ze>>2]);Gc(Ye,o[Ze+4>>2]);Ye=o[Ze+28>>2];if(Ye){o[Ze+32>>2]=Ye;ul(Ye)}if(m[Ze+27|0]<=-1){ul(o[Ze+16>>2])}ul(Ze)}}function Hc(){return 0}function Ic(){return-1}function Jc(){return-2}function Kc(){return-3}function Lc(){return-4}function Mc(){return-5}function Nc(){return 1}function Oc(){return 2}function Pc(){return 3}function Qc(){return 4}function Rc(){return 5}function Sc(){return 6}function Tc(){return 7}function Uc(){return 8}function Vc(){return 9}function Wc(){return 10}function Xc(){return 11}function Yc(){return 12}function Zc(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var $e=0;Ze=o[Ze+88>>2];if(!(!Ze|o[Ze>>2]!=2)){$e=Ye;Ye=o[Ze+8>>2];o[$e+4>>2]=p[Ye|0]|p[Ye+1|0]<<8|(p[Ye+2|0]<<16|p[Ye+3|0]<<24);$e=1}return $e|0}function _c(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var af=0,bf=0;o[Ze>>2]=2;af=o[Ze+8>>2];bf=o[Ze+12>>2]-af|0;if(bf>>>0<=4294967291){Ze=Ze+8|0;ni(Ze,bf+4|0);af=o[Ze>>2]}Ze=af+bf|0;Ye=p[Ye+4|0]|p[Ye+5|0]<<8|(p[Ye+6|0]<<16|p[Ye+7|0]<<24);m[Ze|0]=Ye;m[Ze+1|0]=Ye>>>8;m[Ze+2|0]=Ye>>>16;m[Ze+3|0]=Ye>>>24}function $c(o){o=o|0;return o|0}function ad(o){o=o|0;ul(o)}function bd(o){o=o|0;return 2}function cd(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var cf=0,df=0,ef=0,ff=0,gf=0,hf=0;ef=o[Ze+88>>2];if(!(!ef|o[ef>>2]!=1)){ff=ef+8|0;ef=o[ff>>2];cf=ef;o[Ye+4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ze){o[Ye+12>>2]=Ze;ul(Ze)}return Ye|0}function hd(Ye){Ye=Ye|0;var pf=0;o[Ye>>2]=1232;pf=o[Ye+8>>2];if(pf){o[Ye+12>>2]=pf;ul(pf)}ul(Ye)}function id(o){o=o|0;return 1}function jd(Ye,xf){var yf=0;yf=Hk(40);o[yf>>2]=-1;ki(yf+8|0);l[o[o[Ye>>2]+16>>2]](Ye,yf);Ye=o[xf+88>>2];o[xf+88>>2]=yf;if(Ye){xf=o[Ye+8>>2];if(xf){o[Ye+12>>2]=xf;ul(xf)}ul(Ye)}return 1}function kd(Ye,xf,zf){var Af=0,Bf=0,Cf=0,Df=0,Ef=0,Ff=0;Cf=o[Ye+8>>2];Af=o[Ye+4>>2];if(Cf-Af>>2>>>0>=xf>>>0){while(1){o[Af>>2]=o[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}o[Ye+4>>2]=Af;return}a:{Df=o[Ye>>2];Ef=Af-Df|0;Ff=Ef>>2;Af=Ff+xf|0;if(Af>>>0<1073741824){Cf=Cf-Df|0;Bf=Cf>>1;Af=Cf>>2>>>0<536870911?Bf>>>0>>0?Af:Bf:1073741823;Bf=0;b:{if(!Af){break b}if(Af>>>0>=1073741824){break a}Bf=Hk(Af<<2)}Cf=Bf+(Af<<2)|0;Af=Bf+(Ff<<2)|0;while(1){o[Af>>2]=o[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}if((Ef|0)>=1){wl(Bf,Df,Ef)}o[Ye>>2]=Bf;o[Ye+8>>2]=Cf;o[Ye+4>>2]=Af;if(Df){ul(Df)}return}Yk();D()}_a(1308);D()}function ld(Ye){o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+40>>2]=0;o[Ye+44>>2]=0;o[Ye+28>>2]=9;m[Ye+24|0]=1;o[Ye+56>>2]=-1;o[Ye+60>>2]=0;o[Ye+16>>2]=0;o[Ye+20>>2]=0;o[Ye+48>>2]=0;o[Ye+52>>2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g|0)){break c}o[ag+12>>2]=-1;$f=$f+1|0;if($f>>>0>cg>>>0){yd(lg,$f-cg|0,ag+12|0);Tf=o[lg>>2];break c}if($f>>>0>=cg>>>0){break c}o[ng>>2]=($f<<2)+Tf}o[Tf+bg>>2]=kg;$f=1;kg=kg+1|0;if((fg|0)!=(kg|0)){continue}break}}R=ag+96|0;return $f|0}function xd(Ye,xf,qg){var rg=0,sg=0,tg=0,ug=0;a:{if(Ye>>>0>5){break a}tg=o[qg+16>>2];rg=o[qg+12>>2];sg=o[qg+20>>2];if((rg|0)<(sg|0)?1:(rg|0)<=(sg|0)?r[qg+8>>2]>tg>>>0?0:1:0){break a}rg=p[tg+o[qg>>2]|0];tg=tg+1|0;if(tg>>>0<1){sg=sg+1|0}o[qg+16>>2]=tg;o[qg+20>>2]=sg;sg=xf;if(rg&128){if(!xd(Ye+1|0,xf,qg)){break a}Ye=o[xf>>2]<<7;o[xf>>2]=Ye;rg=Ye|rg&127}o[sg>>2]=rg;ug=1}return ug}function yd(Ye,xf,qg){var vg=0,wg=0,xg=0,yg=0,zg=0,Ag=0;xg=o[Ye+8>>2];vg=o[Ye+4>>2];if(xg-vg>>2>>>0>=xf>>>0){while(1){o[vg>>2]=o[qg>>2];vg=vg+4|0;xf=xf+ -1|0;if(xf){continue}break}o[Ye+4>>2]=vg;return}a:{yg=o[Ye>>2];zg=vg-yg|0;Ag=zg>>2;vg=Ag+xf|0;if(vg>>>0<1073741824){xg=xg-yg|0;wg=xg>>1;vg=xg>>2>>>0<536870911?wg>>>0>>0?vg:wg:1073741823;wg=0;b:{if(!vg){break b}if(vg>>>0>=1073741824){break a}wg=Hk(vg<<2)}xg=wg+(vg<<2)|0;vg=wg+(Ag<<2)|0;while(1){o[vg>>2]=o[qg>>2];vg=vg+4|0;xf=xf+ -1|0;if(xf){continue}break}if((zg|0)>=1){wl(wg,yg,zg)}o[Ye>>2]=wg;o[Ye+8>>2]=xg;o[Ye+4>>2]=vg;if(yg){ul(yg)}return}Yk();D()}_a(1520);D()}function zd(Ye){Ye=Ye|0;var xf=0;o[Ye>>2]=1384;xf=o[Ye+16>>2];if(xf){o[Ye+20>>2]=xf;ul(xf)}xf=o[Ye+4>>2];if(xf){o[Ye+8>>2]=xf;ul(xf)}return Ye|0}function Ad(o){o=o|0;D()}function Bd(Ye,qg){Ye=Ye|0;qg=qg|0;var Bg=0;a:{if(!l[o[o[Ye>>2]+36>>2]](Ye,qg)){break a}if(!l[o[o[Ye>>2]+40>>2]](Ye,qg)){break a}Bg=l[o[o[Ye>>2]+44>>2]](Ye)|0}return Bg|0}function Cd(Ye,qg){Ye=Ye|0;qg=qg|0;return o[o[Ye+4>>2]+(qg<<2)>>2]}function Dd(Ye){Ye=Ye|0;return o[Ye+8>>2]-o[Ye+4>>2]>>2}function Ed(o,Ye){o=o|0;Ye=Ye|0;return 0}function Fd(o,Ye){o=o|0;Ye=Ye|0;return 1}function Gd(Ye){o[Ye+12>>2]=-1;o[Ye+16>>2]=0;o[Ye+4>>2]=0;o[Ye+8>>2]=0;o[Ye>>2]=1596}function Hd(Ye,qg,Cg){Ye=Ye|0;qg=qg|0;Cg=Cg|0;o[Ye+4>>2]=qg;qg=o[o[o[qg+4>>2]+8>>2]+(Cg<<2)>>2];o[Ye+12>>2]=Cg;o[Ye+8>>2]=qg;return 1}function Id(Ye,qg){Ye=Ye|0;qg=qg|0;o[Ye+12>>2]=-1;o[Ye+8>>2]=qg;return 1}function Jd(Ye,qg,Cg){Ye=Ye|0;qg=qg|0;Cg=Cg|0;var Dg=0,Eg=0;Dg=o[Ye+8>>2];a:{if(m[Dg+24|0]<1){break a}if(!rd(Dg,o[qg+4>>2]-o[qg>>2]>>2)){break a}Eg=l[o[o[Ye>>2]+32>>2]](Ye,qg,Cg)|0}return Eg|0}function Kd(o,Ye,qg){o=o|0;Ye=Ye|0;qg=qg|0;return 1}function Ld(Ye){var qg=0,Cg=0,Fg=0,Gg=0,Hg=0,Ig=0,Jg=0,Kg=0;a:{Fg=o[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l[o[o[bh>>2]+4>>2]](bh)}if((dh|0)!=(ch|0)){continue}break}}o[Ye+40>>2]=ch}ih=1;if((gh|0)<1){break a}ih=0;dh=0;while(1){eh=o[$g+16>>2];ch=o[$g+12>>2];bh=o[$g+20>>2];if((ch|0)<(bh|0)?1:(ch|0)<=(bh|0)?r[$g+8>>2]>eh>>>0?0:1:0){break a}hh=p[eh+o[$g>>2]|0];eh=eh+1|0;if(eh>>>0<1){bh=bh+1|0}ch=$g;o[ch+16>>2]=eh;o[ch+20>>2]=bh;l[o[o[Ye>>2]+48>>2]](fh+8|0,Ye,hh);bh=o[Ye+36>>2];ch=o[fh+8>>2];o[fh+8>>2]=0;eh=dh<<2;hh=bh+eh|0;bh=o[hh>>2];o[hh>>2]=ch;if(bh){l[o[o[bh>>2]+4>>2]](bh)}bh=o[fh+8>>2];o[fh+8>>2]=0;if(bh){l[o[o[bh>>2]+4>>2]](bh)}bh=o[o[jh>>2]+eh>>2];if(!bh){break a}if(!(lh=bh,mh=l[o[o[Ye>>2]+28>>2]](Ye)|0,nh=l[o[o[Ye>>2]+20>>2]](Ye,dh)|0,kh=o[o[bh>>2]+8>>2],l[kh](lh|0,mh|0,nh|0)|0)){break a}dh=dh+1|0;if((gh|0)!=(dh|0)){continue}break}ih=1}R=fh+16|0;return ih|0}function Sd(Ye,$g){var oh=0,ph=0,qh=0,rh=0,sh=0,th=0,uh=0,vh=0,wh=0;ph=o[Ye+8>>2];qh=Ye+4|0;oh=o[qh>>2];if(ph-oh>>2>>>0>=$g>>>0){Ye=$g<<2;vh=qh,wh=xl(oh,0,Ye)+Ye|0,o[vh>>2]=wh;return}a:{qh=o[Ye>>2];rh=oh-qh>>2;sh=rh+$g|0;if(sh>>>0<1073741824){rh=rh<<2;ph=ph-qh|0;uh=ph>>1;ph=ph>>2>>>0<536870911?uh>>>0>>0?sh:uh:1073741823;if(ph){if(ph>>>0>=1073741824){break a}th=Hk(ph<<2)}rh=rh+th|0;xl(rh,0,$g<<2);$g=(sh<<2)+th|0;sh=(ph<<2)+th|0;if((oh|0)!=(qh|0)){while(1){oh=oh+ -4|0;ph=o[oh>>2];o[oh>>2]=0;rh=rh+ -4|0;o[rh>>2]=ph;if((oh|0)!=(qh|0)){continue}break}qh=o[Ye>>2];oh=o[Ye+4>>2]}o[Ye>>2]=rh;o[Ye+8>>2]=sh;o[Ye+4>>2]=$g;if((oh|0)!=(qh|0)){while(1){oh=oh+ -4|0;Ye=o[oh>>2];o[oh>>2]=0;if(Ye){l[o[o[Ye>>2]+4>>2]](Ye)}if((oh|0)!=(qh|0)){continue}break}}if(qh){ul(qh)}return}Yk();D()}_a(1832);D()}function Td(Ye,$g){Ye=Ye|0;$g=$g|0;var xh=0,yh=0,zh=0,Ah=0,Bh=0,Ch=0,Dh=0;xh=o[Ye+60>>2];a:{if(!xh){break a}o[xh+4>>2]=Ye+48;if(!l[o[o[xh>>2]+12>>2]](xh)){break a}b:{yh=l[o[o[Ye>>2]+24>>2]](Ye)|0;if((yh|0)<1){break b}Ah=Ye+60|0;xh=0;while(1){c:{Bh=o[(l[o[o[Ye>>2]+28>>2]](Ye)|0)+4>>2];Ch=l[o[o[Ye>>2]+20>>2]](Ye,xh)|0;zh=o[Ah>>2];if(!l[o[o[zh>>2]+8>>2]](zh,o[o[Bh+8>>2]+(Ch<<2)>>2])){break c}xh=xh+1|0;if((yh|0)!=(xh|0)){continue}break b}break}return 0}if(!l[o[o[Ye>>2]+36>>2]](Ye,$g)){break a}if(!l[o[o[Ye>>2]+40>>2]](Ye,$g)){break a}Dh=l[o[o[Ye>>2]+44>>2]](Ye)|0}return Dh|0}function Ud(Ye,$g){Ye=Ye|0;$g=$g|0;var Eh=0,Fh=0,Gh=0,Hh=0,Ih=0;Eh=1;Fh=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Fh|0)<1){break a}Hh=Ye+48|0;Eh=0;Ih=Ye+36|0;Ye=0;while(1){Gh=o[o[Ih>>2]+(Ye<<2)>>2];if(!l[o[o[Gh>>2]+16>>2]](Gh,Hh,$g)){break a}Ye=Ye+1|0;if((Fh|0)!=(Ye|0)){continue}break}Eh=1}return Eh|0}function Vd(Ye,$g){Ye=Ye|0;$g=$g|0;var Jh=0,Kh=0,Lh=0,Mh=0,Nh=0;Jh=1;Kh=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Kh|0)<1){break a}Mh=Ye+48|0;Jh=0;Nh=Ye+36|0;Ye=0;while(1){Lh=o[o[Nh>>2]+(Ye<<2)>>2];if(!l[o[o[Lh>>2]+20>>2]](Lh,Mh,$g)){break a}Ye=Ye+1|0;if((Kh|0)!=(Ye|0)){continue}break}Jh=1}return Jh|0}function Wd(Ye){Ye=Ye|0;var $g=0,Oh=0,Ph=0,Qh=0,Rh=0,Sh=0,Th=0,Uh=0,Vh=0,Wh=0,Xh=0,Yh=0,Zh=0;Qh=R-16|0;R=Qh;$g=1;Th=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Th|0)<1){break a}Zh=Ye+48|0;Sh=Ye+36|0;while(1){b:{c:{if(!o[(l[o[o[Ye>>2]+28>>2]](Ye)|0)+40>>2]){break c}Uh=Rh<<2;$g=o[Uh+o[Sh>>2]>>2];Oh=o[$g+8>>2];Vh=Ld($g);if(!Vh){break c}$g=l[o[o[Ye>>2]+28>>2]](Ye)|0;Wh=o[Oh+56>>2];Xh=o[$g+40>>2];$g=Hk(32);o[Qh>>2]=$g;o[Qh+4>>2]=24;o[Qh+8>>2]=-2147483616;m[$g+24|0]=0;Oh=p[1764]|p[1765]<<8|(p[1766]<<16|p[1767]<<24);Ph=p[1760]|p[1761]<<8|(p[1762]<<16|p[1763]<<24);m[$g+16|0]=Ph;m[$g+17|0]=Ph>>>8;m[$g+18|0]=Ph>>>16;m[$g+19|0]=Ph>>>24;m[$g+20|0]=Oh;m[$g+21|0]=Oh>>>8;m[$g+22|0]=Oh>>>16;m[$g+23|0]=Oh>>>24;Oh=p[1756]|p[1757]<<8|(p[1758]<<16|p[1759]<<24);Ph=p[1752]|p[1753]<<8|(p[1754]<<16|p[1755]<<24);m[$g+8|0]=Ph;m[$g+9|0]=Ph>>>8;m[$g+10|0]=Ph>>>16;m[$g+11|0]=Ph>>>24;m[$g+12|0]=Oh;m[$g+13|0]=Oh>>>8;m[$g+14|0]=Oh>>>16;m[$g+15|0]=Oh>>>24;Oh=p[1748]|p[1749]<<8|(p[1750]<<16|p[1751]<<24);Ph=p[1744]|p[1745]<<8|(p[1746]<<16|p[1747]<<24);m[$g|0]=Ph;m[$g+1|0]=Ph>>>8;m[$g+2|0]=Ph>>>16;m[$g+3|0]=Ph>>>24;m[$g+4|0]=Oh;m[$g+5|0]=Oh>>>8;m[$g+6|0]=Oh>>>16;m[$g+7|0]=Oh>>>24;d:{e:{Ph=Xh+16|0;Oh=Ph;$g=o[Oh>>2];if(!$g){break e}while(1){Yh=o[$g+16>>2]<(Wh|0);Oh=Yh?Oh:$g;$g=o[(Yh<<2)+$g>>2];if($g){continue}break}if((Oh|0)==(Ph|0)|(Wh|0)>2]){break e}$g=Oh+20|0;if(!ea($g,Qh)){break e}$g=yi($g,Qh);break d}$g=yi(Xh,Qh)}if(m[Qh+11|0]<=-1){ul(o[Qh>>2])}if(!$g){break c}sd(o[o[o[Sh>>2]+Uh>>2]+8>>2],Vh);break b}$g=o[o[Sh>>2]+(Rh<<2)>>2];if(l[o[o[$g>>2]+24>>2]]($g,Zh)){break b}$g=0;break a}$g=1;Rh=Rh+1|0;if((Th|0)!=(Rh|0)){continue}break}}R=Qh+16|0;return $g|0}function Xd(Ye,_h,$h){Ye=Ye|0;_h=_h|0;$h=$h|0;if($h>>>0>3){o[Ye>>2]=0;return}a:{b:{switch($h-1|0){default:_h=Hk(20);Gd(_h);break a;case 0:_h=Hk(24);$d(_h);break a;case 1:_h=Hk(36);$d(_h);o[_h+32>>2]=0;o[_h+24>>2]=-1;o[_h+28>>2]=0;o[_h>>2]=7664;break a;case 2:break b}}_h=Hk(28);$d(_h);o[_h+24>>2]=-1;o[_h>>2]=5528;o[Ye>>2]=_h;return}o[Ye>>2]=_h}function Yd(Ye){Ye=Ye|0;var _h=0,$h=0,ai=0,bi=0,ci=0;o[Ye>>2]=1692;_h=Ye+60|0;$h=o[_h>>2];o[_h>>2]=0;if($h){l[o[o[$h>>2]+4>>2]]($h)}_h=o[Ye+48>>2];if(_h){o[Ye+52>>2]=_h;ul(_h)}$h=o[Ye+36>>2];if($h){_h=$h;ci=Ye+40|0;ai=o[ci>>2];bi=_h;a:{if((_h|0)==(ai|0)){break a}while(1){ai=ai+ -4|0;_h=o[ai>>2];o[ai>>2]=0;if(_h){l[o[o[_h>>2]+4>>2]](_h)}if(($h|0)!=(ai|0)){continue}break}bi=o[Ye+36>>2]}_h=bi;o[ci>>2]=$h;ul(_h)}o[Ye>>2]=1384;_h=o[Ye+16>>2];if(_h){o[Ye+20>>2]=_h;ul(_h)}_h=o[Ye+4>>2];if(_h){o[Ye+8>>2]=_h;ul(_h)}return Ye|0}function Zd(Ye){Ye=Ye|0;var di=0,ei=0,fi=0,gi=0,hi=0;o[Ye>>2]=1692;di=Ye+60|0;ei=o[di>>2];o[di>>2]=0;if(ei){l[o[o[ei>>2]+4>>2]](ei)}di=o[Ye+48>>2];if(di){o[Ye+52>>2]=di;ul(di)}ei=o[Ye+36>>2];if(ei){di=ei;hi=Ye+40|0;fi=o[hi>>2];gi=di;a:{if((di|0)==(fi|0)){break a}while(1){fi=fi+ -4|0;di=o[fi>>2];o[fi>>2]=0;if(di){l[o[o[di>>2]+4>>2]](di)}if((ei|0)!=(fi|0)){continue}break}gi=o[Ye+36>>2]}di=gi;o[hi>>2]=ei;ul(di)}o[Ye>>2]=1384;di=o[Ye+16>>2];if(di){o[Ye+20>>2]=di;ul(di)}di=o[Ye+4>>2];if(di){o[Ye+8>>2]=di;ul(di)}ul(Ye)}function _d(Ye,ii){Ye=Ye|0;ii=ii|0;var ji=0,ki=0;ki=o[Ye+16>>2];ji=0;a:{if(o[Ye+20>>2]-ki>>2<=(ii|0)){break a}ii=o[(ii<<2)+ki>>2];ji=0;if((ii|0)<0){break a}ji=Ld(o[o[Ye+36>>2]+(ii<<2)>>2])}return ji|0}function $d(Ye){Gd(Ye);o[Ye+20>>2]=0;o[Ye>>2]=1908}function ae(o,Ye,ii){o=o|0;Ye=Ye|0;ii=ii|0;return Hd(o,Ye,ii)|0}function be(Ye,ii){Ye=Ye|0;ii=ii|0;return l[o[o[Ye>>2]+48>>2]](Ye,o[ii+4>>2]-o[ii>>2]>>2)|0}function ce(Ye,ii,li){Ye=Ye|0;ii=ii|0;li=li|0;var mi=0,ni=0,oi=0,pi=0,qi=0,ri=0,si=0,ti=0,ui=0,vi=0;oi=R-16|0;R=oi;si=o[li+8>>2];pi=o[li+16>>2];qi=o[li+12>>2];mi=qi;ni=o[li+20>>2];a:{if((mi|0)<(ni|0)?1:(mi|0)<=(ni|0)?si>>>0>pi>>>0?0:1:0){break a}ti=o[li>>2];ui=m[ti+pi|0];mi=ni;ri=pi+1|0;if(ri>>>0<1){mi=mi+1|0}o[li+16>>2]=ri;o[li+20>>2]=mi;b:{if((ui|0)==-2){break b}if((qi|0)<(mi|0)?1:(qi|0)<=(mi|0)?si>>>0>ri>>>0?0:1:0){break a}qi=m[ri+ti|0];pi=pi+2|0;if(pi>>>0<2){ni=ni+1|0}mi=li;o[mi+16>>2]=pi;o[mi+20>>2]=ni;l[o[o[Ye>>2]+40>>2]](oi+8|0,Ye,ui,qi);ni=o[oi+8>>2];o[oi+8>>2]=0;mi=o[Ye+20>>2];o[Ye+20>>2]=ni;if(!mi){o[oi+8>>2]=0;break b}l[o[o[mi>>2]+4>>2]](mi);mi=o[oi+8>>2];o[oi+8>>2]=0;if(!mi){break b}l[o[o[mi>>2]+4>>2]](mi)}mi=o[Ye+20>>2];if(mi){if(!l[o[o[Ye>>2]+28>>2]](Ye,mi)){break a}}vi=l[o[o[Ye>>2]+36>>2]](Ye,ii,li)|0}R=oi+16|0;return vi|0}function de(Ye,ii,li,wi){Ye=Ye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wi|0)?1:(Fi|0)>=(wi|0)?r[li+8>>2]
  • >>0?0:1:0){continue}break}break b}wl(Ji,Fi+o[li>>2]|0,Ei);wi=o[li+20>>2];Ci=zi+o[li+16>>2]|0;if(Ci>>>0>>0){wi=wi+1|0}o[li+16>>2]=Ci;o[li+20>>2]=wi}Ci=0;if(!Hi){break c}zi=o[Ye+20>>2];if(zi){Ci=1;if(l[o[o[zi>>2]+32>>2]](zi)){break c}}ji(Ji,Hi,Ji);Ci=1}zi=o[Ye+20>>2];f:{if(!zi){break f}if(!l[o[o[zi>>2]+40>>2]](zi,li)){break a}if(!Ci){break f}Di=0;Ye=o[Ye+20>>2];if(!l[o[o[Ye>>2]+44>>2]](Ye,Ji,Ji,Hi,Ki,o[ii>>2])){break b}}Di=1}return Di|0}return 0}function ge(Ye,ii,li){var Ni=0,Oi=0,Pi=0,Qi=0;Ni=R-80|0;R=Ni;Oi=ld(Ni+16|0);Pi=o[o[Ye+8>>2]+56>>2];Qi=li<<24>>24;li=u(ti(5),li);md(Oi,Pi,Qi,5,0,li,li>>31);li=Hk(96);qd(li,Oi);o[Ni+8>>2]=li;m[li+84|0]=1;o[li+72>>2]=o[li+68>>2];rd(li,ii);o[Ni>>2]=0;ii=o[Ni+8>>2];o[Ni+8>>2]=0;li=Ye+16|0;Ye=o[li>>2];o[li>>2]=ii;a:{if(!Ye){o[Ni>>2]=0;break a}Fb(Ye);Ye=o[Ni>>2];o[Ni>>2]=0;if(!Ye){break a}Fb(Ye)}Ye=o[Ni+8>>2];o[Ni+8>>2]=0;if(Ye){Fb(Ye)}R=Ni+80|0}function he(Ye,ii){Ye=Ye|0;ii=ii|0;var li=0,Ri=0,Si=0,Ti=0,Ui=0,Vi=0,Wi=0,Xi=0,Yi=0;Ri=o[Ye+8>>2];li=o[Ri+28>>2]+ -1|0;if(li>>>0>5){return 0}a:{b:{switch(li-1|0){case 0:Ti=m[Ri+24|0];Ui=Hk((Ti|0)>-1?Ti:-1);li=o[Ye+16>>2];Ri=0;c:{if(!o[li+80>>2]){break c}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=(Ti|0)<1;Xi=Ye+8|0;li=0;while(1){Ye=0;if(!Vi){while(1){m[Ye+Ui|0]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Ti|0)!=(Ye|0)){continue}break}}wl(o[o[o[Xi>>2]- -64>>2]>>2]+Wi|0,Ui,Ti);Wi=Ti+Wi|0;Si=Si+1|0;if((Si|0)!=(ii|0)){continue}break}break a;default:Ti=m[Ri+24|0];Ui=Hk((Ti|0)>-1?Ti:-1);li=o[Ye+16>>2];Ri=0;d:{if(!o[li+80>>2]){break d}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=(Ti|0)<1;Xi=Ye+8|0;li=0;while(1){Ye=0;if(!Vi){while(1){m[Ye+Ui|0]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Ti|0)!=(Ye|0)){continue}break}}wl(o[o[o[Xi>>2]- -64>>2]>>2]+Wi|0,Ui,Ti);Wi=Ti+Wi|0;Si=Si+1|0;if((Si|0)!=(ii|0)){continue}break}break a;case 2:Si=m[Ri+24|0];Ri=Si+Si|0;Ui=Hk(Ri>>>0>>0?-1:Ri);li=o[Ye+16>>2];Ri=0;e:{if(!o[li+80>>2]){break e}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=Si<<1;Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){n[(Ye<<1)+Ui>>1]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 1:Si=m[Ri+24|0];Ri=Si+Si|0;Ui=Hk(Ri>>>0>>0?-1:Ri);li=o[Ye+16>>2];Ri=0;f:{if(!o[li+80>>2]){break f}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=Si<<1;Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){n[(Ye<<1)+Ui>>1]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 4:Si=m[Ri+24|0];Vi=Si<<2;Ui=Hk((Si|0)!=(Si&1073741823)?-1:Vi);li=o[Ye+16>>2];Ri=0;g:{if(!o[li+80>>2]){break g}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){o[(Ye<<2)+Ui>>2]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 3:break b}}Si=m[Ri+24|0];Vi=Si<<2;Ui=Hk((Si|0)!=(Si&1073741823)?-1:Vi);li=o[Ye+16>>2];Ri=0;h:{if(!o[li+80>>2]){break h}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){o[(Ye<<2)+Ui>>2]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}}ul(Ui);return 1}function ie(Ye){Ye=Ye|0;var ii=0,Zi=0;o[Ye>>2]=1908;Zi=Ye+20|0;ii=o[Zi>>2];o[Zi>>2]=0;if(ii){l[o[o[ii>>2]+4>>2]](ii)}o[Ye>>2]=1596;Zi=Ye+16|0;ii=o[Zi>>2];o[Zi>>2]=0;if(ii){Fb(ii)}return Ye|0}function je(Ye){Ye=Ye|0;var _i=0,$i=0;o[Ye>>2]=1908;$i=Ye+20|0;_i=o[$i>>2];o[$i>>2]=0;if(_i){l[o[o[_i>>2]+4>>2]](_i)}o[Ye>>2]=1596;$i=Ye+16|0;_i=o[$i>>2];o[$i>>2]=0;if(_i){Fb(_i)}ul(Ye)}function ke(Ye){Ye=Ye|0;return m[o[Ye+8>>2]+24|0]}function le(Ye,aj,bj,cj,dj,ej){var fj=0,gj=0,hj=0;ej=R-32|0;R=ej;gj=o[o[o[aj+4>>2]+8>>2]+(cj<<2)>>2];a:{b:{if((l[o[o[aj>>2]+8>>2]](aj)|0)!=1|bj+ -1>>>0>5){break b}hj=l[o[o[aj>>2]+36>>2]](aj)|0;fj=l[o[o[aj>>2]+44>>2]](aj,cj)|0;if(!(fj?hj:0)){o[Ye>>2]=0;break a}cj=l[o[o[aj>>2]+40>>2]](aj,cj)|0;if(cj){aj=o[aj+44>>2];o[ej+12>>2]=cj;o[ej+8>>2]=aj;o[ej+20>>2]=fj;o[ej+16>>2]=fj+12;ne(Ye,bj,gj,dj,ej+8|0);if(o[Ye>>2]){break a}o[Ye>>2]=0;break b}aj=o[aj+44>>2];o[ej+12>>2]=hj;o[ej+8>>2]=aj;o[ej+20>>2]=fj;o[ej+16>>2]=fj+12;oe(Ye,bj,gj,dj,ej+8|0);if(o[Ye>>2]){break a}o[Ye>>2]=0}o[Ye>>2]=0}R=ej+32|0}function me(Ye,aj,bj){var cj=0,dj=0,ej=0,ij=0,jj=0,kj=0,lj=0,mj=0;o[Ye>>2]=2732;o[Ye+4>>2]=aj;aj=o[bj+8>>2];cj=o[bj+12>>2];dj=o[bj+16>>2];ij=o[bj+20>>2];jj=o[bj>>2];kj=o[bj+4>>2];o[Ye+40>>2]=0;ej=Ye+32|0;o[ej>>2]=0;o[ej+4>>2]=0;o[Ye+24>>2]=dj;o[Ye+28>>2]=ij;o[Ye+16>>2]=aj;o[Ye+20>>2]=cj;o[Ye+8>>2]=jj;o[Ye+12>>2]=kj;a:{aj=o[bj+28>>2]-o[bj+24>>2]|0;b:{if(!aj){break b}cj=aj>>2;if(cj>>>0>=1073741824){break a}aj=Hk(aj);o[Ye+32>>2]=aj;dj=Ye+36|0;o[dj>>2]=aj;o[Ye+40>>2]=aj+(cj<<2);cj=o[bj+24>>2];bj=o[bj+28>>2]-cj|0;if((bj|0)<1){break b}lj=dj,mj=wl(aj,cj,bj)+bj|0,o[lj>>2]=mj}o[Ye>>2]=5368;return}Yk();D()}function ne(Ye,aj,bj,nj,oj){var pj=0;a:{aj=aj+ -1|0;b:{if(aj>>>0>5){break b}c:{switch(aj-1|0){default:aj=Hk(60);pe(aj,bj,nj,oj);o[aj>>2]=2024;break a;case 2:aj=Hk(112);pe(aj,bj,nj,oj);o[aj>>2]=2788;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj+68>>2]=0;o[aj+72>>2]=0;o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+84>>2]=0;o[aj+88>>2]=0;o[aj+92>>2]=0;o[aj+96>>2]=0;o[aj+100>>2]=0;o[aj+104>>2]=0;o[aj+108>>2]=0;break a;case 3:aj=Hk(104);pe(aj,bj,nj,oj);o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj>>2]=3036;o[aj+84>>2]=0;bj=o[oj+4>>2];o[aj+88>>2]=o[oj>>2];o[aj+92>>2]=bj;bj=o[oj+12>>2];o[aj+96>>2]=o[oj+8>>2];o[aj+100>>2]=bj;break a;case 0:case 1:break b;case 4:break c}}pj=Hk(124);pe(pj,bj,nj,oj);o[pj>>2]=3272;aj=pj- -64|0;o[aj>>2]=0;o[aj+4>>2]=0;aj=o[oj+4>>2];o[pj+72>>2]=o[oj>>2];o[pj+76>>2]=aj;aj=o[oj+12>>2];o[pj+80>>2]=o[oj+8>>2];o[pj+84>>2]=aj;o[pj+92>>2]=-1;o[pj+96>>2]=-1;o[pj+88>>2]=1;o[pj+60>>2]=3508;o[pj+100>>2]=-1;o[pj+104>>2]=-1;Mf(pj+108|0)}o[Ye>>2]=pj;return}o[Ye>>2]=aj}function oe(Ye,aj,bj,nj,oj){var qj=0;a:{aj=aj+ -1|0;b:{if(aj>>>0>5){break b}c:{switch(aj-1|0){default:aj=Hk(60);Xe(aj,bj,nj,oj);o[aj>>2]=3900;break a;case 2:aj=Hk(112);Xe(aj,bj,nj,oj);o[aj>>2]=4324;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj+68>>2]=0;o[aj+72>>2]=0;o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+84>>2]=0;o[aj+88>>2]=0;o[aj+92>>2]=0;o[aj+96>>2]=0;o[aj+100>>2]=0;o[aj+104>>2]=0;o[aj+108>>2]=0;break a;case 3:aj=Hk(104);Xe(aj,bj,nj,oj);o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj>>2]=4560;o[aj+84>>2]=0;bj=o[oj+4>>2];o[aj+88>>2]=o[oj>>2];o[aj+92>>2]=bj;bj=o[oj+12>>2];o[aj+96>>2]=o[oj+8>>2];o[aj+100>>2]=bj;break a;case 0:case 1:break b;case 4:break c}}qj=Hk(124);Xe(qj,bj,nj,oj);o[qj>>2]=4784;aj=qj- -64|0;o[aj>>2]=0;o[aj+4>>2]=0;aj=o[oj+4>>2];o[qj+72>>2]=o[oj>>2];o[qj+76>>2]=aj;aj=o[oj+12>>2];o[qj+80>>2]=o[oj+8>>2];o[qj+84>>2]=aj;o[qj+92>>2]=-1;o[qj+96>>2]=-1;o[qj+88>>2]=1;o[qj+60>>2]=5004;o[qj+100>>2]=-1;o[qj+104>>2]=-1;Mf(qj+108|0)}o[Ye>>2]=qj;return}o[Ye>>2]=aj}function pe(Ye,aj,bj,nj){var oj=0,rj=0,sj=0,tj=0,uj=0,vj=0,wj=0,xj=0;o[Ye>>2]=2732;o[Ye+4>>2]=aj;aj=o[bj+8>>2];oj=o[bj+12>>2];rj=o[bj+16>>2];tj=o[bj+20>>2];uj=o[bj>>2];vj=o[bj+4>>2];o[Ye+40>>2]=0;sj=Ye+32|0;o[sj>>2]=0;o[sj+4>>2]=0;o[Ye+24>>2]=rj;o[Ye+28>>2]=tj;o[Ye+16>>2]=aj;o[Ye+20>>2]=oj;o[Ye+8>>2]=uj;o[Ye+12>>2]=vj;a:{aj=o[bj+28>>2]-o[bj+24>>2]|0;b:{if(!aj){break b}oj=aj>>2;if(oj>>>0>=1073741824){break a}aj=Hk(aj);o[Ye+32>>2]=aj;rj=Ye+36|0;o[rj>>2]=aj;o[Ye+40>>2]=aj+(oj<<2);oj=o[bj+24>>2];bj=o[bj+28>>2]-oj|0;if((bj|0)<1){break b}wj=rj,xj=wl(aj,oj,bj)+bj|0,o[wj>>2]=xj}o[Ye>>2]=2676;aj=o[nj+4>>2];o[Ye+44>>2]=o[nj>>2];o[Ye+48>>2]=aj;aj=o[nj+12>>2];o[Ye+52>>2]=o[nj+8>>2];o[Ye+56>>2]=aj;return}Yk();D()}function qe(Ye){Ye=Ye|0;var aj=0;o[Ye>>2]=2732;aj=o[Ye+32>>2];if(aj){o[Ye+36>>2]=aj;ul(aj)}return Ye|0}function re(Ye){Ye=Ye|0;var bj=0;o[Ye>>2]=2732;bj=o[Ye+32>>2];if(bj){o[Ye+36>>2]=bj;ul(bj)}ul(Ye)}function se(Ye){Ye=Ye|0;var nj=0;if(!(!o[Ye+52>>2]|(!o[Ye+44>>2]|!o[Ye+48>>2]))){nj=o[Ye+56>>2]!=0}return nj|0}function te(o){o=o|0;return 0}function ue(o,Ye){o=o|0;Ye=Ye|0;return-1}function ve(Ye,y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kj+20>>2]=bk;if((Mj|0)>(Lj|0)){break a}o[Ye+16>>2]=Lj;o[Ye+12>>2]=Mj;Kj=Mj;Mj=(Lj>>31)-((Lj>>>0>>0)+(Kj>>31)|0)|0;Kj=Lj-Kj|0;if(!Mj&Kj>>>0>2147483646|Mj>>>0>0){break a}dk=1;Kj=Kj+1|0;o[Ye+20>>2]=Kj;Mj=Ye+24|0;Lj=(Kj|0)/2|0;o[Mj>>2]=Lj;o[Ye+28>>2]=0-Lj;if(Kj&1){break a}o[Mj>>2]=Lj+ -1;break a}dk=0}R=fk+32|0;return dk|0}function Be(Ye,Kj,kk){var lk=0,mk=0,nk=0,ok=0;a:{if(Ye>>>0>5){break a}nk=o[kk+16>>2];lk=o[kk+12>>2];mk=o[kk+20>>2];if((lk|0)<(mk|0)?1:(lk|0)<=(mk|0)?r[kk+8>>2]>nk>>>0?0:1:0){break a}lk=p[nk+o[kk>>2]|0];nk=nk+1|0;if(nk>>>0<1){mk=mk+1|0}o[kk+16>>2]=nk;o[kk+20>>2]=mk;mk=Kj;if(lk&128){if(!Be(Ye+1|0,Kj,kk)){break a}Ye=o[Kj>>2]<<7;o[Kj>>2]=Ye;lk=Ye|lk&127}o[mk>>2]=lk;ok=1}return ok}function Ce(Ye,Kj){var kk=0,pk=0,qk=0,rk=0,sk=0,tk=0;pk=R-32|0;R=pk;a:{kk=o[Ye+4>>2];b:{if(kk>>>0>>0){sk=o[Ye+8>>2];qk=sk<<5;rk=Kj-kk|0;c:{if(!(qk>>>0>>0|kk>>>0>qk-rk>>>0)){o[Ye+4>>2]=Kj;Kj=kk&31;Ye=o[Ye>>2]+(kk>>>3&536870908)|0;break c}o[pk+24>>2]=0;o[pk+16>>2]=0;o[pk+20>>2]=0;if((Kj|0)<=-1){break a}kk=pk+16|0;if(qk>>>0<=1073741822){Kj=Kj+31&-32;qk=sk<<6;Kj=qk>>>0>>0?Kj:qk}else{Kj=2147483647}ab(kk,Kj);kk=o[Ye+4>>2];o[pk+20>>2]=k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((yk>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if((yk|0)>=(Dk|0)){break p}if((wk|0)>=1){Kk=o[(Ak+16|0)+u(xk,12)>>2];yk=u(wk,yk);Jk=u(wk,Jk);Lk=u(wk,Lk);zk=0;while(1){o[Kk+(zk<<2)>>2]=(o[(yk+zk<<2)+uk>>2]+o[(zk+Jk<<2)+uk>>2]|0)-o[(zk+Lk<<2)+uk>>2];zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}yk=4;xk=xk+1|0;if((xk|0)==4){break o}}q:{if(Ck&1){zk=-1;yk=vk+1|0;vk=(yk>>>0)%3|0?yk:vk+ -2|0;if((vk|0)==-1|o[o[Ek>>2]+(vk>>>3&536870908)>>2]>>>(vk&31)&1){break q}vk=o[o[o[Ek+64>>2]+12>>2]+(vk<<2)>>2];if((vk|0)==-1){break q}yk=vk+1|0;zk=(yk>>>0)%3|0?yk:vk+ -2|0;break q}zk=-1;vk=((vk>>>0)%3|0?-1:2)+vk|0;if((vk|0)==-1|o[o[Ek>>2]+(vk>>>3&536870908)>>2]>>>(vk&31)&1){break q}vk=o[o[o[Ek+64>>2]+12>>2]+(vk<<2)>>2];if((vk|0)==-1){break q}if((vk>>>0)%3){zk=vk+ -1|0;break q}zk=vk+2|0}r:{if((zk|0)==(Bk|0)){break r}vk=zk;yk=(zk|0)!=-1;zk=(yk|Ck^-1)&1;vk=zk?vk:-1;Ck=yk&Ck;if(!((Fk|0)==-1|zk)){if(o[o[Ek>>2]+(Rk<<2)>>2]&Sk){break r}yk=o[o[o[Ek+64>>2]+12>>2]+(Fk<<2)>>2];if((yk|0)==-1){break r}Ck=0;if((yk>>>0)%3){vk=yk+ -1|0}else{vk=yk+2|0}}if((vk|0)!=-1){continue}}break}yk=xk;if((yk|0)<1){break n}}Fk=(wk|0)<1;if(!Fk){xl(Mk,0,Xk)}vk=yk+ -1|0;Ck=(vk<<2)+Qk|0;vk=u(vk,12)+Ye|0;Kk=vk+60|0;Rk=o[vk- -64>>2];vk=0;Sk=o[Ak>>2];Bk=0;xk=0;while(1){zk=o[Ck>>2];o[Ck>>2]=zk+1;if(Rk>>>0<=zk>>>0){break i}s:{if(o[o[Kk>>2]+(zk>>>3&536870908)>>2]>>>(zk&31)&1){break s}xk=xk+1|0;if(Fk){break s}Tk=o[(Ak+16|0)+u(Bk,12)>>2];zk=0;while(1){Lk=zk<<2;Jk=Lk+Sk|0;o[Jk>>2]=o[Jk>>2]+o[Lk+Tk>>2];zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}Bk=Bk+1|0;if((yk|0)!=(Bk|0)){continue}break}Ck=u(wk,Dk);yk=Ck;if(!xk){break m}zk=0;if((wk|0)>0){break l}break k}yk=u(wk,Dk)}if(o[Gk>>2]<1){break j}Ck=(u(Dk+ -1|0,wk)<<2)+uk|0;zk=0;while(1){vk=zk<<2;xk=o[vk+Ck>>2];Fk=o[Ik>>2];t:{if((xk|0)>(Fk|0)){Bk=o[Nk>>2];o[vk+Bk>>2]=Fk;break t}Bk=o[Nk>>2];vk=vk+Bk|0;Fk=o[Pk>>2];if((xk|0)<(Fk|0)){o[vk>>2]=Fk;break t}o[vk>>2]=xk}zk=zk+1|0;xk=o[Gk>>2];if((zk|0)<(xk|0)){continue}break}vk=0;if((xk|0)<1){break j}xk=yk<<2;zk=xk+uk|0;Ck=Kj+xk|0;while(1){yk=vk<<2;xk=yk+zk|0;yk=o[yk+Ck>>2]+o[yk+Bk>>2]|0;o[xk>>2]=yk;u:{if((yk|0)>o[Ik>>2]){yk=yk-o[Ok>>2]|0}else{if((yk|0)>=o[Pk>>2]){break u}yk=yk+o[Ok>>2]|0}o[xk>>2]=yk}vk=vk+1|0;if((vk|0)>2]){continue}break}break j}Zk();D()}while(1){vk=(zk<<2)+Mk|0;o[vk>>2]=o[vk>>2]/(xk|0);zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}if(o[Gk>>2]<1){break j}zk=0;while(1){vk=zk<<2;xk=o[vk+Mk>>2];yk=o[Ik>>2];v:{if((xk|0)>(yk|0)){Bk=o[Nk>>2];o[vk+Bk>>2]=yk;break v}Bk=o[Nk>>2];vk=vk+Bk|0;yk=o[Pk>>2];if((xk|0)<(yk|0)){o[vk>>2]=yk;break v}o[vk>>2]=xk}zk=zk+1|0;xk=o[Gk>>2];if((zk|0)<(xk|0)){continue}break}vk=0;if((xk|0)<1){break j}xk=Ck<<2;zk=xk+uk|0;Ck=Kj+xk|0;while(1){yk=vk<<2;xk=yk+zk|0;yk=o[yk+Ck>>2]+o[yk+Bk>>2]|0;o[xk>>2]=yk;w:{if((yk|0)>o[Ik>>2]){yk=yk-o[Ok>>2]|0}else{if((yk|0)>=o[Pk>>2]){break w}yk=yk+o[Ok>>2]|0}o[xk>>2]=yk}vk=vk+1|0;if((vk|0)>2]){continue}break}}vk=1;Dk=Dk+1|0;if((Dk|0)<(Vk|0)){continue}break}}Ye=o[Ak>>2];if(Ye){o[Ak+4>>2]=Ye;ul(Ye)}ul(Qk);Ye=o[Ak+52>>2];if(Ye){o[Ak+56>>2]=Ye;ul(Ye)}Ye=o[Ak+40>>2];if(Ye){o[Ak+44>>2]=Ye;ul(Ye)}Ye=o[Ak+28>>2];if(Ye){o[Ak+32>>2]=Ye;ul(Ye)}Ye=o[Ak+16>>2];if(Ye){o[Ak+20>>2]=Ye;ul(Ye)}R=Ak- -64|0;return vk|0}Yk();D()}function Ee(Ye){Ye=Ye|0;var Kj=0;o[Ye>>2]=3036;Kj=o[Ye+76>>2];if(Kj){ul(Kj)}o[Ye>>2]=2732;Kj=o[Ye+32>>2];if(Kj){o[Ye+36>>2]=Kj;ul(Kj)}return Ye|0}function Fe(Ye){Ye=Ye|0;var uk=0;o[Ye>>2]=3036;uk=o[Ye+76>>2];if(uk){ul(uk)}o[Ye>>2]=2732;uk=o[Ye+32>>2];if(uk){o[Ye+36>>2]=uk;ul(uk)}ul(Ye)}function Ge(o){o=o|0;return 5}function He(Ye){Ye=Ye|0;if(!(!o[Ye+60>>2]|!o[Ye+44>>2]|(!o[Ye+48>>2]|!o[Ye+52>>2]))){return o[Ye+56>>2]!=0|0}return 0}function Ie(Ye,vk){Ye=Ye|0;vk=vk|0;var wk=0;if(!(o[vk+56>>2]|!vk|p[vk+24|0]!=3)){o[Ye+60>>2]=vk;wk=1}return wk|0}function Je(Ye,vk){Ye=Ye|0;vk=vk|0;var xk=0,Hk=0,Yk=0,Zk=0,$k=0,al=0,bl=0,cl=0,dl=0,el=0,fl=0;cl=R-16|0;R=cl;Yk=o[vk+12>>2];xk=o[vk+20>>2];Zk=o[vk+16>>2];Hk=Zk+4|0;if(Hk>>>0<4){xk=xk+1|0}$k=Hk;Hk=xk;a:{if((Yk|0)<(xk|0)?1:(Yk|0)<=(xk|0)?r[vk+8>>2]>=$k>>>0?0:1:0){break a}xk=Zk+o[vk>>2]|0;xk=p[xk|0]|p[xk+1|0]<<8|(p[xk+2|0]<<16|p[xk+3|0]<<24);o[vk+16>>2]=$k;o[vk+20>>2]=Hk;if((xk|0)<0){break a}Ce(Ye+76|0,xk);$k=Mf(cl);b:{if(!Nf($k,vk)){break b}if((xk|0)>=1){Yk=1;while(1){Zk=1<<(bl&31);al=Pf($k);Hk=o[Ye+76>>2]+(bl>>>3&536870908)|0;Yk=Yk^al;al=o[Hk>>2]|Zk;c:{if(!(Yk&1)){break c}al=o[Hk>>2]&(Zk^-1)}Zk=al;Yk=Yk^1;o[Hk>>2]=Zk;bl=bl+1|0;if((xk|0)!=(bl|0)){continue}break}}Hk=o[vk+12>>2];bl=Hk;xk=o[vk+20>>2];Yk=xk;$k=o[vk+16>>2];Zk=$k+4|0;if(Zk>>>0<4){xk=xk+1|0}dl=o[vk+8>>2];al=Zk;Zk=xk;if((Hk|0)<(xk|0)?1:(Hk|0)<=(xk|0)?dl>>>0>=al>>>0?0:1:0){break b}el=o[vk>>2];xk=el+$k|0;Hk=p[xk|0]|p[xk+1|0]<<8|(p[xk+2|0]<<16|p[xk+3|0]<<24);o[vk+16>>2]=al;o[vk+20>>2]=Zk;xk=Yk;Yk=$k+8|0;if(Yk>>>0<8){xk=xk+1|0}Zk=Yk;Yk=xk;if((bl|0)<(xk|0)?1:(bl|0)<=(xk|0)?dl>>>0>=Zk>>>0?0:1:0){break b}xk=al+el|0;xk=p[xk|0]|p[xk+1|0]<<8|(p[xk+2|0]<<16|p[xk+3|0]<<24);o[vk+16>>2]=Zk;o[vk+20>>2]=Yk;if((Hk|0)>(xk|0)){break b}o[Ye+16>>2]=xk;o[Ye+12>>2]=Hk;vk=Hk;Hk=(xk>>31)-((xk>>>0>>0)+(vk>>31)|0)|0;vk=xk-vk|0;if(!Hk&vk>>>0>2147483646|Hk>>>0>0){break b}fl=1;vk=vk+1|0;o[Ye+20>>2]=vk;Hk=Ye+24|0;xk=(vk|0)/2|0;o[Hk>>2]=xk;o[Ye+28>>2]=0-xk;if(vk&1){break b}o[Hk>>2]=xk+ -1}}R=cl+16|0;return fl|0}function Ke(Ye,vk,gl,hl,il,jl){Ye=Ye|0;vk=vk|0;gl=gl|0;hl=hl|0;il=il|0;jl=jl|0;var kl=0,ll=0,ml=0,nl=0,ol=0,pl=0,ql=0,rl=0,sl=0,tl=0,ul=0,vl=0;hl=0;a:{if((il|0)!=2){break a}o[Ye+8>>2]=2;o[Ye- -64>>2]=jl;hl=Ye+32|0;il=o[hl>>2];jl=o[Ye+36>>2]-il|0;kl=jl>>2;b:{if(kl>>>0<=1){Da(hl,2-kl|0);break b}if((jl|0)==8){break b}o[Ye+36>>2]=il+8}hl=1;il=o[Ye+56>>2];jl=o[il+4>>2];il=o[il>>2];kl=jl-il|0;if((kl|0)<1){break a}if((il|0)!=(jl|0)){sl=Ye+60|0;tl=kl>>2;kl=Ye+8|0;ol=Ye+16|0;pl=Ye+32|0;ql=Ye+20|0;rl=Ye+12|0;ul=Ye+56|0;while(1){if(!Le(sl,o[(ml<<2)+il>>2],gl,ml)){hl=0;break a}c:{if(o[kl>>2]<1){break c}il=0;while(1){hl=il<<2;jl=o[(hl+Ye|0)+68>>2];ll=o[ol>>2];d:{if((jl|0)>(ll|0)){nl=o[pl>>2];o[hl+nl>>2]=ll;break d}nl=o[pl>>2];hl=hl+nl|0;ll=o[rl>>2];if((jl|0)<(ll|0)){o[hl>>2]=ll;break d}o[hl>>2]=jl}il=il+1|0;hl=o[kl>>2];if((il|0)<(hl|0)){continue}break}jl=0;if((hl|0)<1){break c}hl=ml<<3;ll=hl+gl|0;vl=vk+hl|0;while(1){il=jl<<2;hl=il+ll|0;il=o[il+vl>>2]+o[il+nl>>2]|0;o[hl>>2]=il;e:{if((il|0)>o[ol>>2]){il=il-o[ql>>2]|0}else{if((il|0)>=o[rl>>2]){break e}il=il+o[ql>>2]|0}o[hl>>2]=il}jl=jl+1|0;if((jl|0)>2]){continue}break}}hl=1;ml=ml+1|0;if((ml|0)>=(tl|0)){break a}hl=o[ul>>2];il=o[hl>>2];if(o[hl+4>>2]-il>>2>>>0>ml>>>0){continue}break}}Zk();D()}return hl|0}function Le(Ye,vk,gl,hl){var il=0,jl=0,wl=0,xl=0,yl=0,zl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0,Ml=0,Nl=0,Ol=0,Pl=0,Ql=0,Rl=0,Sl=0;wl=R-80|0;R=wl;jl=-1;il=-1;a:{if((vk|0)==-1){break a}il=vk+1|0;jl=(il>>>0)%3|0?il:vk+ -2|0;il=vk+ -1|0;if((vk>>>0)%3){break a}il=vk+2|0}xl=o[Ye+36>>2];vk=o[xl>>2];b:{c:{d:{e:{f:{xl=o[xl+4>>2]-vk>>2;yl=jl<<2;jl=o[o[Ye+32>>2]+28>>2];zl=o[yl+jl>>2];if(xl>>>0<=zl>>>0){break f}il=o[jl+(il<<2)>>2];if(xl>>>0<=il>>>0){break f}g:{h:{Cl=o[vk+(zl<<2)>>2];Fl=(Cl|0)>=(hl|0);if(Fl){break h}jl=o[vk+(il<<2)>>2];if((jl|0)>=(hl|0)){break h}vk=jl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ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 2:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;o[Tl>>2]=q[vk>>1];o[Tl+4>>2]=0;vk=vk+2|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 3:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;Xl=o[vk>>2];o[Tl>>2]=Xl;o[Tl+4>>2]=Xl>>31;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 4:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=0;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 5:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Xl=o[vk+4>>2];Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 6:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Xl=o[vk+4>>2];Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 7:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24<1){break c}Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;Wl=Tl;Yl=s[vk>>2];f:{if(v(w(Yl))=v(1)?Yl>v(0)?~~v(y(v(A(v(Yl/v(4294967296)))),v(4294967296)))>>>0:~~v(B(v(v(Yl-v(~~Yl>>>0>>>0))/v(4294967296))))>>>0:0;_l=~~Yl>>>0;break f}Xl=-2147483648;_l=0}o[Wl>>2]=_l;o[Tl+4>>2]=Xl;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}break c;case 8:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24<1){break d}Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;Wl=Tl;Zl=t[vk>>3];g:{if(w(Zl)<0x8000000000000000){Xl=w(Zl)>=1?Zl>0?~~y(A(Zl/4294967296),4294967295)>>>0:~~B((Zl- +(~~Zl>>>0>>>0))/4294967296)>>>0:0;_l=~~Zl>>>0;break g}Xl=-2147483648;_l=0}o[Wl>>2]=_l;o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}break d;case 9:break e}}Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;o[Tl>>2]=p[vk|0];o[Tl+4>>2]=0;vk=vk+1|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}xl((Tl<<3)+hl|0,0,gl-Tl<<3);break b}if((Tl|0)>=(gl|0)){break b}break a}if((Tl|0)>=(gl|0)){break b}xl((Tl<<3)+hl|0,0,gl-Tl<<3)}return}xl((Tl<<3)+hl|0,0,gl-Tl<<3)}function Ne(Ye){Ye=Ye|0;var vk=0;o[Ye>>2]=3272;o[Ye>>2]=2732;vk=o[Ye+32>>2];if(vk){o[Ye+36>>2]=vk;ul(vk)}return Ye|0}function Oe(Ye){Ye=Ye|0;var gl=0;o[Ye>>2]=3272;o[Ye>>2]=2732;gl=o[Ye+32>>2];if(gl){o[Ye+36>>2]=gl;ul(gl)}ul(Ye)}function Pe(o){o=o|0;return 6}function Qe(Ye){Ye=Ye|0;var hl=0;a:{if(!o[Ye- -64>>2]|!o[Ye+68>>2]|(!o[Ye+44>>2]|!o[Ye+48>>2])){break a}if(!o[Ye+52>>2]|!o[Ye+56>>2]){break a}hl=o[Ye+92>>2]!=-1}return hl|0}function Re(Ye,Vl){Ye=Ye|0;Vl=Vl|0;var $l=0;if(!(o[Vl+56>>2]|p[Vl+24|0]!=3)){o[Ye- -64>>2]=Vl;$l=1}return $l|0}function Se(Ye,Vl){Ye=Ye|0;Vl=Vl|0;var am=0,bm=0,cm=0,dm=0,em=0,fm=0,gm=0,hm=0,im=0,jm=0;bm=o[Vl+12>>2];cm=bm;am=o[Vl+20>>2];em=am;fm=o[Vl+16>>2];dm=fm+4|0;if(dm>>>0<4){am=am+1|0}hm=o[Vl+8>>2];gm=dm;dm=am;a:{if((bm|0)<(am|0)?1:(bm|0)<=(am|0)?hm>>>0>=gm>>>0?0:1:0){break a}im=o[Vl>>2];am=im+fm|0;bm=p[am|0]|p[am+1|0]<<8|(p[am+2|0]<<16|p[am+3|0]<<24);o[Vl+16>>2]=gm;o[Vl+20>>2]=dm;am=em;em=fm+8|0;if(em>>>0<8){am=am+1|0}dm=em;em=am;if((cm|0)<(am|0)?1:(cm|0)<=(am|0)?hm>>>0>=dm>>>0?0:1:0){break a}am=gm+im|0;am=p[am|0]|p[am+1|0]<<8|(p[am+2|0]<<16|p[am+3|0]<<24);o[Vl+16>>2]=dm;o[Vl+20>>2]=em;if((bm|0)>(am|0)){break a}o[Ye+16>>2]=am;o[Ye+12>>2]=bm;cm=bm;bm=(am>>31)-((bm>>31)+(am>>>0>>0)|0)|0;am=am-cm|0;if(!bm&am>>>0>2147483646|bm>>>0>0){break a}am=am+1|0;o[Ye+20>>2]=am;cm=Ye+24|0;bm=(am|0)/2|0;o[cm>>2]=bm;o[Ye+28>>2]=0-bm;if(!(am&1)){o[cm>>2]=bm+ -1}jm=Nf(Ye+108|0,Vl)}return jm|0}function Te(Ye,km,lm,mm,nm,om){Ye=Ye|0;km=km|0;lm=lm|0;mm=mm|0;nm=nm|0;om=om|0;var pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0,Cm=0,Dm=0;qm=R-32|0;R=qm;o[Ye+68>>2]=om;mm=o[Ye+56>>2];nm=o[mm>>2];om=mm+4|0;pm=o[om>>2];o[qm+24>>2]=0;o[qm+16>>2]=0;o[qm+20>>2]=0;a:{nm=pm-nm|0;if((nm|0)<1){break a}mm=o[mm>>2];if((mm|0)!=o[om>>2]){Am=nm>>2;Bm=Ye+60|0;Cm=Ye+108|0;vm=Ye+8|0;wm=Ye+16|0;xm=Ye+32|0;ym=Ye+20|0;zm=Ye+12|0;Dm=Ye+56|0;while(1){Ue(Bm,o[(tm<<2)+mm>>2],qm+16|0);nm=o[qm+20>>2];pm=nm>>31;om=o[qm+16>>2];rm=om>>31;um=o[qm+24>>2];sm=um>>31;mm=0;sm=sm^sm+um;pm=sm+((pm^nm+pm)+(rm^om+rm)|0)|0;if(pm>>>0>>0){mm=1}b:{if(!(mm|pm)){o[qm+16>>2]=o[Ye+104>>2];break b}rm=o[Ye+104>>2];sm=rm>>31;nm=Wl(Vl(rm,sm,nm,nm>>31),T,pm,mm);o[qm+20>>2]=nm;mm=Wl(Vl(rm,sm,om,om>>31),T,pm,mm);o[qm+16>>2]=mm;om=mm;mm=mm>>31;mm=(rm-(om+mm^mm)|0)+((nm|0)<0?nm:0-nm|0)|0;if((um|0)>=0){o[qm+24>>2]=mm;break b}o[qm+24>>2]=0-mm}mm=Pf(Cm);om=o[qm+16>>2];c:{if(!mm){nm=o[qm+20>>2];break c}o[qm+24>>2]=0-o[qm+24>>2];nm=0-o[qm+20>>2]|0;o[qm+20>>2]=nm;om=0-om|0;o[qm+16>>2]=om}d:{if((om|0)>=0){mm=o[Ye+104>>2];om=mm+o[qm+24>>2]|0;mm=mm+nm|0;break d}e:{if((nm|0)<=-1){om=o[qm+24>>2];mm=om>>31;mm=mm^mm+om;break e}om=o[qm+24>>2];mm=om>>31;mm=o[Ye+100>>2]-(mm^mm+om)|0}if((om|0)<=-1){om=nm;nm=nm>>31;om=om+nm^nm;break d}om=nm;nm=nm>>31;om=o[Ye+100>>2]-(om+nm^nm)|0}nm=o[Ye+100>>2];f:{if(!(mm|om)){om=nm;mm=nm;break f}if(!((nm|0)!=(om|0)|mm)){mm=om;break f}if(!((mm|0)!=(nm|0)|om)){om=mm;break f}g:{if(mm){break g}pm=o[Ye+104>>2];if((pm|0)>=(om|0)){break g}om=(pm<<1)-om|0;mm=0;break f}h:{if((mm|0)!=(nm|0)){break h}pm=o[Ye+104>>2];if((pm|0)<=(om|0)){break h}om=(pm<<1)-om|0;break f}i:{if((nm|0)!=(om|0)){break i}nm=o[Ye+104>>2];if((nm|0)<=(mm|0)){break i}mm=(nm<<1)-mm|0;break f}if(om){break f}om=0;nm=o[Ye+104>>2];if((nm|0)>=(mm|0)){break f}mm=(nm<<1)-mm|0}o[qm+12>>2]=om;o[qm+8>>2]=mm;j:{if(o[vm>>2]<1){break j}om=0;while(1){pm=o[wm>>2];k:{if((mm|0)>(pm|0)){nm=o[xm>>2];o[nm+(om<<2)>>2]=pm;break k}nm=o[xm>>2];pm=nm+(om<<2)|0;rm=o[zm>>2];if((mm|0)<(rm|0)){o[pm>>2]=rm;break k}o[pm>>2]=mm}om=om+1|0;pm=o[vm>>2];if((om|0)<(pm|0)){mm=o[(qm+8|0)+(om<<2)>>2];continue}break}mm=0;if((pm|0)<1){break j}om=tm<<3;rm=om+lm|0;um=km+om|0;while(1){pm=mm<<2;om=pm+rm|0;pm=o[pm+um>>2]+o[nm+pm>>2]|0;o[om>>2]=pm;l:{if((pm|0)>o[wm>>2]){sm=pm-o[ym>>2]|0}else{if((pm|0)>=o[zm>>2]){break l}sm=pm+o[ym>>2]|0}o[om>>2]=sm}mm=mm+1|0;if((mm|0)>2]){continue}break}}tm=tm+1|0;if((tm|0)>=(Am|0)){break a}nm=o[Dm>>2];mm=o[nm>>2];if(o[nm+4>>2]-mm>>2>>>0>tm>>>0){continue}break}}Zk();D()}R=qm+32|0;return 1}function Ue(Ye,km,lm){Ye=Ye|0;km=km|0;lm=lm|0;var mm=0,nm=0,om=0,Em=0,Fm=0,Gm=0,Hm=0,Im=0,Jm=0,Km=0,Lm=0,Mm=0,Nm=0,Om=0,Pm=0,Qm=0,Rm=0,Sm=0,Tm=0,Um=0,Vm=0,Wm=0,Xm=0,Ym=0,Zm=0,_m=0;nm=R-96|0;R=nm;mm=o[Ye+16>>2];m[nm+92|0]=1;o[nm+88>>2]=km;o[nm+84>>2]=km;o[nm+80>>2]=mm;Em=o[Ye+20>>2];om=o[Em>>2];a:{b:{c:{d:{mm=o[o[mm+28>>2]+(km<<2)>>2];if(o[Em+4>>2]-om>>2>>>0>mm>>>0){mm=o[o[Ye+8>>2]+(o[om+(mm<<2)>>2]<<2)>>2];om=o[Ye+4>>2];if(!p[om+84|0]){mm=o[o[om+68>>2]+(mm<<2)>>2]}o[nm+72>>2]=0;o[nm+76>>2]=0;Em=nm- -64|0;o[Em>>2]=0;o[Em+4>>2]=0;o[nm+56>>2]=0;o[nm+60>>2]=0;Me(om,mm,m[om+24|0],nm+56|0);if((km|0)==-1){break a}mm=km+1|0;Em=(mm>>>0)%3|0?mm:km+ -2|0;Om=((km>>>0)%3|0?-1:2)+km|0;Vm=Ye+28|0;Fm=!o[Vm>>2];Wm=Ye+20|0;Xm=Ye+16|0;Ym=Ye+8|0;while(1){om=Em;mm=Om;e:{if(Fm){break e}mm=km+1|0;om=(mm>>>0)%3|0?mm:km+ -2|0;mm=km+ -1|0;if((km>>>0)%3){break e}mm=km+2|0}Fm=o[Wm>>2];km=o[Fm>>2];om=o[o[o[Xm>>2]+28>>2]+(om<<2)>>2];if(o[Fm+4>>2]-km>>2>>>0<=om>>>0){break d}om=o[o[Ym>>2]+(o[km+(om<<2)>>2]<<2)>>2];Fm=Ye+4|0;km=o[Fm>>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wl(Hm,Mm,Ye,km);Km=Wl(Km,Nm,Ye,km)}o[lm+8>>2]=Gm;o[lm+4>>2]=Hm;o[lm>>2]=Km;R=nm+96|0}function Ve(Ye,Vl){Ye=Ye|0;Vl=Vl|0;if(Vl>>>0<=1){o[Ye+28>>2]=Vl;Ye=1}else{Ye=0}return Ye|0}function We(Ye){var Vl=0,km=0,lm=0;Vl=o[Ye+8>>2];lm=o[Ye>>2];a:{if(p[Ye+12|0]){b:{c:{d:{e:{if((Vl|0)==-1){break e}km=Vl+1|0;Vl=(km>>>0)%3|0?km:Vl+ -2|0;if((Vl|0)==-1|o[o[lm>>2]+(Vl>>>3&536870908)>>2]>>>(Vl&31)&1){break e}Vl=o[o[o[lm+64>>2]+12>>2]+(Vl<<2)>>2];if((Vl|0)!=-1){break d}}o[Ye+8>>2]=-1;break c}km=Vl+1|0;Vl=(km>>>0)%3|0?km:Vl+ -2|0;o[Ye+8>>2]=Vl;if((Vl|0)!=-1){break b}}Vl=-1;km=o[Ye+4>>2];f:{if((km|0)==-1){break f}km=km+((km>>>0)%3|0?-1:2)|0;if((km|0)==-1|o[o[lm>>2]+(km>>>3&536870908)>>2]>>>(km&31)&1){break f}lm=o[o[o[lm+64>>2]+12>>2]+(km<<2)>>2];if((lm|0)==-1){break f}if((lm>>>0)%3){Vl=lm+ -1|0;break f}Vl=lm+2|0}m[Ye+12|0]=0;o[Ye+8>>2]=Vl;return}if((Vl|0)!=o[Ye+4>>2]){break a}o[Ye+8>>2]=-1;return}km=-1;g:{if((Vl|0)==-1){break g}Vl=Vl+((Vl>>>0)%3|0?-1:2)|0;if((Vl|0)==-1|o[o[lm>>2]+(Vl>>>3&536870908)>>2]>>>(Vl&31)&1){break g}Vl=o[o[o[lm+64>>2]+12>>2]+(Vl<<2)>>2];if((Vl|0)==-1){break g}if((Vl>>>0)%3){km=Vl+ -1|0;break g}km=Vl+2|0}o[Ye+8>>2]=km}}function Xe(Ye,$m,an,bn){var cn=0,dn=0,en=0,fn=0,gn=0,hn=0,jn=0,kn=0;o[Ye>>2]=2732;o[Ye+4>>2]=$m;$m=o[an+8>>2];cn=o[an+12>>2];dn=o[an+16>>2];fn=o[an+20>>2];gn=o[an>>2];hn=o[an+4>>2];o[Ye+40>>2]=0;en=Ye+32|0;o[en>>2]=0;o[en+4>>2]=0;o[Ye+24>>2]=dn;o[Ye+28>>2]=fn;o[Ye+16>>2]=$m;o[Ye+20>>2]=cn;o[Ye+8>>2]=gn;o[Ye+12>>2]=hn;a:{$m=o[an+28>>2]-o[an+24>>2]|0;b:{if(!$m){break b}cn=$m>>2;if(cn>>>0>=1073741824){break a}$m=Hk($m);o[Ye+32>>2]=$m;dn=Ye+36|0;o[dn>>2]=$m;o[Ye+40>>2]=$m+(cn<<2);cn=o[an+24>>2];an=o[an+28>>2]-cn|0;if((an|0)<1){break b}jn=dn,kn=wl($m,cn,an)+an|0,o[jn>>2]=kn}o[Ye>>2]=4268;$m=o[bn+4>>2];o[Ye+44>>2]=o[bn>>2];o[Ye+48>>2]=$m;$m=o[bn+12>>2];o[Ye+52>>2]=o[bn+8>>2];o[Ye+56>>2]=$m;return}Yk();D()}function Ye(Ye,$m,an,bn,ln,mn){Ye=Ye|0;$m=$m|0;an=an|0;bn=bn|0;ln=ln|0;mn=mn|0;var nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0,wn=0,xn=0,yn=0,zn=0,An=0,Bn=0,Cn=0;o[Ye+8>>2]=ln;mn=Ye+32|0;on=o[mn>>2];bn=o[Ye+36>>2]-on>>2;a:{if(bn>>>0>>0){Da(mn,ln-bn|0);break a}if(bn>>>0<=ln>>>0){break a}o[Ye+36>>2]=on+(ln<<2)}Cn=o[Ye+52>>2];zn=o[Ye+48>>2];bn=0;mn=(ln&1073741823)!=(ln|0)?-1:ln<<2;yn=xl(Hk(mn),0,mn);rn=Ye+8|0;mn=o[rn>>2];b:{if((mn|0)<1){break b}tn=Ye+16|0;on=Ye+32|0;un=Ye+12|0;while(1){mn=bn<<2;nn=o[mn+yn>>2];qn=o[tn>>2];c:{if((nn|0)>(qn|0)){sn=o[on>>2];o[mn+sn>>2]=qn;break c}sn=o[on>>2];mn=mn+sn|0;qn=o[un>>2];if((nn|0)<(qn|0)){o[mn>>2]=qn;break c}o[mn>>2]=nn}bn=bn+1|0;mn=o[rn>>2];if((bn|0)<(mn|0)){continue}break}if((mn|0)<1){break b}on=0;rn=Ye+16|0;nn=Ye+20|0;tn=Ye+8|0;un=Ye+12|0;while(1){mn=on<<2;bn=mn+an|0;mn=o[$m+mn>>2]+o[mn+sn>>2]|0;o[bn>>2]=mn;d:{if((mn|0)>o[rn>>2]){mn=mn-o[nn>>2]|0}else{if((mn|0)>=o[un>>2]){break d}mn=mn+o[nn>>2]|0}o[bn>>2]=mn}on=on+1|0;mn=o[tn>>2];if((on|0)<(mn|0)){continue}break}}bn=o[Ye+56>>2];An=o[bn>>2];bn=o[bn+4>>2]-An|0;if((bn|0)>=5){Bn=bn>>2;sn=Ye+16|0;rn=Ye+32|0;tn=Ye+8|0;un=Ye+20|0;qn=Ye+12|0;on=1;while(1){e:{f:{if(Bn>>>0>on>>>0){xn=u(ln,on);Ye=o[(on<<2)+An>>2];if((Ye|0)==-1){break f}Ye=o[o[zn+12>>2]+(Ye<<2)>>2];if((Ye|0)==-1){break f}bn=-1;pn=o[Cn>>2];nn=o[zn>>2];vn=o[pn+(o[nn+(Ye<<2)>>2]<<2)>>2];wn=Ye+1|0;wn=(wn>>>0)%3|0?wn:Ye+ -2|0;if((wn|0)!=-1){wn=o[nn+(wn<<2)>>2]}else{wn=-1}Ye=Ye+((Ye>>>0)%3|0?-1:2)|0;if((Ye|0)!=-1){bn=o[nn+(Ye<<2)>>2]}if((vn|0)>=(on|0)){break f}Ye=o[(wn<<2)+pn>>2];if((Ye|0)>=(on|0)){break f}bn=o[pn+(bn<<2)>>2];if((bn|0)>=(on|0)){break f}if((ln|0)>=1){nn=u(bn,ln);Ye=u(Ye,ln);pn=u(ln,vn);bn=0;while(1){o[(bn<<2)+yn>>2]=(o[(bn+nn<<2)+an>>2]+o[(Ye+bn<<2)+an>>2]|0)-o[(bn+pn<<2)+an>>2];bn=bn+1|0;if((ln|0)!=(bn|0)){continue}break}}if((mn|0)<1){break e}bn=0;while(1){Ye=bn<<2;mn=o[Ye+yn>>2];pn=o[sn>>2];g:{if((mn|0)>(pn|0)){nn=o[rn>>2];o[Ye+nn>>2]=pn;break g}nn=o[rn>>2];Ye=Ye+nn|0;pn=o[qn>>2];if((mn|0)<(pn|0)){o[Ye>>2]=pn;break g}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}bn=0;if((mn|0)<1){break e}Ye=xn<<2;xn=Ye+an|0;pn=Ye+$m|0;while(1){mn=bn<<2;Ye=mn+xn|0;mn=o[mn+pn>>2]+o[mn+nn>>2]|0;o[Ye>>2]=mn;h:{if((mn|0)>o[sn>>2]){mn=mn-o[un>>2]|0}else{if((mn|0)>=o[qn>>2]){break h}mn=mn+o[un>>2]|0}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}break e}Zk();D()}if((mn|0)<1){break e}pn=(u(on+ -1|0,ln)<<2)+an|0;bn=0;while(1){Ye=bn<<2;mn=o[Ye+pn>>2];vn=o[sn>>2];i:{if((mn|0)>(vn|0)){nn=o[rn>>2];o[Ye+nn>>2]=vn;break i}nn=o[rn>>2];Ye=Ye+nn|0;vn=o[qn>>2];if((mn|0)<(vn|0)){o[Ye>>2]=vn;break i}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}bn=0;if((mn|0)<1){break e}Ye=xn<<2;xn=Ye+an|0;pn=Ye+$m|0;while(1){mn=bn<<2;Ye=mn+xn|0;mn=o[mn+pn>>2]+o[mn+nn>>2]|0;o[Ye>>2]=mn;j:{if((mn|0)>o[sn>>2]){mn=mn-o[un>>2]|0}else{if((mn|0)>=o[qn>>2]){break j}mn=mn+o[un>>2]|0}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}}on=on+1|0;if((on|0)<(Bn|0)){continue}break}}ul(yn);return 1}function Ze(Ye){Ye=Ye|0;var $m=0;o[Ye>>2]=4324;$m=o[Ye+96>>2];if($m){ul($m)}$m=o[Ye+84>>2];if($m){ul($m)}$m=o[Ye+72>>2];if($m){ul($m)}$m=o[Ye+60>>2];if($m){ul($m)}o[Ye>>2]=2732;$m=o[Ye+32>>2];if($m){o[Ye+36>>2]=$m;ul($m)}return Ye|0}function _e(Ye){Ye=Ye|0;var an=0;o[Ye>>2]=4324;an=o[Ye+96>>2];if(an){ul(an)}an=o[Ye+84>>2];if(an){ul(an)}an=o[Ye+72>>2];if(an){ul(an)}an=o[Ye+60>>2];if(an){ul(an)}o[Ye>>2]=2732;an=o[Ye+32>>2];if(an){o[Ye+36>>2]=an;ul(an)}ul(Ye)}function $e(Ye,bn,ln,mn,Dn,En){Ye=Ye|0;bn=bn|0;ln=ln|0;mn=mn|0;Dn=Dn|0;En=En|0;var Fn=0,Gn=0,Hn=0,In=0,Jn=0,Kn=0,Ln=0,Mn=0,Nn=0,On=0,Pn=0,Qn=0,Rn=0,Sn=0,Tn=0,Un=0,Vn=0,Wn=0,Xn=0,Yn=0,Zn=0,_n=0,$n=0,ao=0,bo=0;Hn=R+ -64|0;R=Hn;o[Ye+8>>2]=Dn;En=Ye+32|0;In=o[En>>2];mn=o[Ye+36>>2]-In>>2;a:{if(mn>>>0>>0){Da(En,Dn-mn|0);break a}if(mn>>>0<=Dn>>>0){break a}o[Ye+36>>2]=In+(Dn<<2)}o[Hn+56>>2]=0;o[Hn+60>>2]=0;o[Hn+48>>2]=0;o[Hn+52>>2]=0;o[Hn+40>>2]=0;o[Hn+44>>2]=0;mn=Hn+32|0;o[mn>>2]=0;o[mn+4>>2]=0;o[Hn+24>>2]=0;o[Hn+28>>2]=0;o[Hn+16>>2]=0;o[H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2)+ln>>2]+o[(Fn+Gn<<2)+ln>>2]|0)-o[(Gn+Tn<<2)+ln>>2];Gn=Gn+1|0;if((Gn|0)!=(Dn|0)){continue}break}}Fn=4;En=En+1|0;if((En|0)==4){break o}}q:{if(Jn&1){On=mn+1|0;mn=(On>>>0)%3|0?On:mn+ -2|0;Fn=-1;if((mn|0)==-1){break q}mn=o[Ln+(mn<<2)>>2];Fn=-1;if((mn|0)==-1){break q}Fn=mn+1|0;Fn=(Fn>>>0)%3|0?Fn:mn+ -2|0;break q}mn=((mn>>>0)%3|0?-1:2)+mn|0;Fn=-1;if((mn|0)==-1){break q}mn=o[Ln+(mn<<2)>>2];Fn=-1;if((mn|0)==-1){break q}Fn=mn+ -1|0;if((mn>>>0)%3){break q}Fn=mn+2|0}r:{if((Fn|0)==(In|0)){break r}mn=Fn;Fn=(Fn|0)!=-1;Gn=(Fn|Jn^-1)&1;mn=Gn?mn:-1;Jn=Fn&Jn;if(!((Un|0)==-1|Gn)){Fn=o[Xn>>2];if((Fn|0)==-1){break r}Jn=0;if((Fn>>>0)%3){mn=Fn+ -1|0}else{mn=Fn+2|0}}if((mn|0)!=-1){continue}}break}Fn=En;if((Fn|0)<1){break n}}Ln=(Dn|0)<1;if(!Ln){xl(Sn,0,bo)}mn=Fn+ -1|0;Jn=(mn<<2)+Yn|0;mn=u(mn,12)+Ye|0;On=mn+60|0;Qn=o[mn- -64>>2];In=0;Tn=o[Hn>>2];mn=0;En=0;while(1){Gn=o[Jn>>2];o[Jn>>2]=Gn+1;if(Qn>>>0<=Gn>>>0){break i}s:{if(o[o[On>>2]+(Gn>>>3&536870908)>>2]>>>(Gn&31)&1){break s}En=En+1|0;if(Ln){break s}Pn=o[(Hn+16|0)+u(mn,12)>>2];Gn=0;while(1){Un=Gn<<2;Xn=Un+Tn|0;o[Xn>>2]=o[Xn>>2]+o[Pn+Un>>2];Gn=Gn+1|0;if((Gn|0)!=(Dn|0)){continue}break}}mn=mn+1|0;if((Fn|0)!=(mn|0)){continue}break}Fn=u(Dn,Kn);mn=Fn;if(!En){break m}Gn=0;if((Dn|0)>0){break l}break k}mn=u(Dn,Kn)}if(o[Mn>>2]<1){break j}Jn=(u(Kn+ -1|0,Dn)<<2)+ln|0;Gn=0;while(1){En=Gn<<2;Fn=o[En+Jn>>2];Ln=o[Rn>>2];t:{if((Fn|0)>(Ln|0)){In=o[Nn>>2];o[En+In>>2]=Ln;break t}In=o[Nn>>2];En=En+In|0;Ln=o[Wn>>2];if((Fn|0)<(Ln|0)){o[En>>2]=Ln;break t}o[En>>2]=Fn}Gn=Gn+1|0;Fn=o[Mn>>2];if((Gn|0)<(Fn|0)){continue}break}En=0;if((Fn|0)<1){break j}mn=mn<<2;Gn=mn+ln|0;Jn=bn+mn|0;while(1){Fn=En<<2;mn=Fn+Gn|0;Fn=o[Fn+Jn>>2]+o[Fn+In>>2]|0;o[mn>>2]=Fn;u:{if((Fn|0)>o[Rn>>2]){Fn=Fn-o[Vn>>2]|0}else{if((Fn|0)>=o[Wn>>2]){break u}Fn=Fn+o[Vn>>2]|0}o[mn>>2]=Fn}En=En+1|0;if((En|0)>2]){continue}break}break j}Zk();D()}while(1){mn=(Gn<<2)+Sn|0;o[mn>>2]=o[mn>>2]/(En|0);Gn=Gn+1|0;if((Gn|0)!=(Dn|0)){continue}break}}if(o[Mn>>2]<1){break j}Gn=0;while(1){mn=Gn<<2;En=o[mn+Sn>>2];Jn=o[Rn>>2];v:{if((En|0)>(Jn|0)){In=o[Nn>>2];o[mn+In>>2]=Jn;break v}In=o[Nn>>2];mn=mn+In|0;Jn=o[Wn>>2];if((En|0)<(Jn|0)){o[mn>>2]=Jn;break v}o[mn>>2]=En}Gn=Gn+1|0;mn=o[Mn>>2];if((Gn|0)<(mn|0)){continue}break}En=0;if((mn|0)<1){break j}mn=Fn<<2;Gn=mn+ln|0;Jn=bn+mn|0;while(1){Fn=En<<2;mn=Fn+Gn|0;Fn=o[Fn+Jn>>2]+o[Fn+In>>2]|0;o[mn>>2]=Fn;w:{if((Fn|0)>o[Rn>>2]){Fn=Fn-o[Vn>>2]|0}else{if((Fn|0)>=o[Wn>>2]){break w}Fn=Fn+o[Vn>>2]|0}o[mn>>2]=Fn}En=En+1|0;if((En|0)>2]){continue}break}}In=1;Kn=Kn+1|0;if((Kn|0)<($n|0)){continue}break}}Ye=o[Hn>>2];if(Ye){o[Hn+4>>2]=Ye;ul(Ye)}ul(Yn);Ye=o[Hn+52>>2];if(Ye){o[Hn+56>>2]=Ye;ul(Ye)}Ye=o[Hn+40>>2];if(Ye){o[Hn+44>>2]=Ye;ul(Ye)}Ye=o[Hn+28>>2];if(Ye){o[Hn+32>>2]=Ye;ul(Ye)}Ye=o[Hn+16>>2];if(Ye){o[Hn+20>>2]=Ye;ul(Ye)}R=Hn- -64|0;return In|0}Yk();D()}function af(Ye){Ye=Ye|0;var bn=0;o[Ye>>2]=4560;bn=o[Ye+76>>2];if(bn){ul(bn)}o[Ye>>2]=2732;bn=o[Ye+32>>2];if(bn){o[Ye+36>>2]=bn;ul(bn)}return Ye|0}function bf(Ye){Ye=Ye|0;var ln=0;o[Ye>>2]=4560;ln=o[Ye+76>>2];if(ln){ul(ln)}o[Ye>>2]=2732;ln=o[Ye+32>>2];if(ln){o[Ye+36>>2]=ln;ul(ln)}ul(Ye)}function cf(Ye,mn,Dn,En,co,eo){Ye=Ye|0;mn=mn|0;Dn=Dn|0;En=En|0;co=co|0;eo=eo|0;var fo=0,go=0,ho=0,io=0,jo=0,ko=0,lo=0,mo=0,no=0,oo=0,po=0,qo=0;En=0;a:{if((co|0)!=2){break a}o[Ye+8>>2]=2;o[Ye- -64>>2]=eo;En=Ye+32|0;co=o[En>>2];eo=o[Ye+36>>2]-co|0;fo=eo>>2;b:{if(fo>>>0<=1){Da(En,2-fo|0);break b}if((eo|0)==8){break b}o[Ye+36>>2]=co+8}En=1;co=o[Ye+56>>2];eo=o[co+4>>2];co=o[co>>2];fo=eo-co|0;if((fo|0)<1){break a}if((co|0)!=(eo|0)){no=Ye+60|0;oo=fo>>2;fo=Ye+8|0;jo=Ye+16|0;ko=Ye+32|0;lo=Ye+20|0;mo=Ye+12|0;po=Ye+56|0;while(1){if(!df(no,o[(ho<<2)+co>>2],Dn,ho)){En=0;break a}c:{if(o[fo>>2]<1){break c}co=0;while(1){En=co<<2;eo=o[(En+Ye|0)+68>>2];go=o[jo>>2];d:{if((eo|0)>(go|0)){io=o[ko>>2];o[En+io>>2]=go;break d}io=o[ko>>2];En=En+io|0;go=o[mo>>2];if((eo|0)<(go|0)){o[En>>2]=go;break d}o[En>>2]=eo}co=co+1|0;En=o[fo>>2];if((co|0)<(En|0)){continue}break}eo=0;if((En|0)<1){break c}En=ho<<3;go=En+Dn|0;qo=mn+En|0;while(1){co=eo<<2;En=co+go|0;co=o[co+qo>>2]+o[co+io>>2]|0;o[En>>2]=co;e:{if((co|0)>o[jo>>2]){co=co-o[lo>>2]|0}else{if((co|0)>=o[mo>>2]){break e}co=co+o[lo>>2]|0}o[En>>2]=co}eo=eo+1|0;if((eo|0)>2]){continue}break}}En=1;ho=ho+1|0;if((ho|0)>=(oo|0)){break a}En=o[po>>2];co=o[En>>2];if(o[En+4>>2]-co>>2>>>0>ho>>>0){continue}break}}Zk();D()}return En|0}function df(Ye,mn,Dn,En){var co=0,eo=0,ro=0,so=0,to=0,uo=0,vo=0,wo=0,xo=0,yo=0,zo=0,Ao=0,Bo=0,Co=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0,No=0;ro=R-80|0;R=ro;co=-1;eo=-1;a:{if((mn|0)==-1){break a}so=((mn>>>0)%3|0?-1:2)+mn|0;to=o[Ye+32>>2];vo=mn+1|0;mn=(vo>>>0)%3|0?vo:mn+ -2|0;if((mn|0)!=-1){co=o[o[to>>2]+(mn<<2)>>2]}if((so|0)==-1){break a}eo=o[o[to>>2]+(so<<2)>>2]}so=o[Ye+36>>2];mn=o[so>>2];b:{c:{d:{e:{so=o[so+4>>2]-mn>>2;if(!(so>>>0<=co>>>0|so>>>0<=eo>>>0)){f:{g:{yo=o[mn+(co<<2)>>2];Ao=(yo|0)>=(En|0);if(Ao){break g}eo=o[mn+(eo<<2)>>2];if((eo|0)>=(En|0)){break g}mn=eo<<3;Fo=o[(mn|4)+Dn>>2];co=yo<<3;vo=o[(co|4)+Dn>>2];Co=o[mn+Dn>>2];Eo=o[Dn+co>>2];if(!((Co|0)!=(Eo|0)|(vo|0)!=(Fo|0))){o[Ye+8>>2]=Eo;o[Ye+12>>2]=vo;break f}mn=o[o[Ye+4>>2]+(En<<2)>>2];o[ro+72>>2]=0;o[ro+76>>2]=0;co=ro- -64|0;o[co>>2]=0;o[co+4>>2]=0;o[ro+56>>2]=0;o[ro+60>>2]=0;co=o[Ye>>2];if(!p[co+84|0]){mn=o[o[co+68>>2]+(mn<<2)>>2]}Me(co,mn,m[co+24|0],ro+56|0);mn=o[o[Ye+4>>2]+(yo<<2)>>2];o[ro+48>>2]=0;o[ro+52>>2]=0;o[ro+40>>2]=0;o[ro+44>>2]=0;o[ro+32>>2]=0;o[ro+36>>2]=0;co=o[Ye>>2];if(!p[co+84|0]){mn=o[o[co+68>>2]+(mn<<2)>>2]}Me(co,mn,m[co+24|0],ro+32|0);mn=o[o[Ye+4>>2]+(eo<<2)>>2];o[ro+24>>2]=0;o[ro+28>>2]=0;o[ro+16>>2]=0;o[ro+20>>2]=0;o[ro+8>>2]=0;o[ro+12>>2]=0;co=o[Ye>>2];if(!p[co+84|0]){mn=o[o[co+68>>2]+(mn<<2)>>2]}Me(co,mn,m[co+24|0],ro+8|0);Go=o[ro+44>>2];mn=o[ro+16>>2];uo=o[ro+40>>2];co=uo;eo=o[ro+20>>2]-(Go+(mn>>>0>>0)|0)|0;Io=mn-co|0;mn=Vl(Io,eo,Io,eo);co=T;xo=mn;Ho=o[ro+36>>2];mn=o[ro+8>>2];wo=o[ro+32>>2];to=wo;so=o[ro+12>>2]-(Ho+(mn>>>0>>0)|0)|0;Jo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dn>>>0<0){break e}zo=eo;Dn=so;while(1){co=mn<<1|En>>>31;En=En<<1;mn=co;wo=!Dn&zo>>>0>7|Dn>>>0>0;zo=(Dn&3)<<30|zo>>>2;Dn=Dn>>>2;if(wo){continue}break}break d}co=Ye;if(Ao){if((En|0)<=0){o[Ye+8>>2]=0;o[Ye+12>>2]=0;break f}mn=(En<<1)+ -2|0}else{mn=yo<<1}mn=(mn<<2)+Dn|0;o[co+8>>2]=o[mn>>2];o[Ye+12>>2]=o[mn+4>>2]}Dn=1;break b}Zk();D()}En=eo;mn=so;if(eo-1){break c}}while(1){Dn=Xl(eo,so,En,mn)+En|0;co=mn+T|0;co=Dn>>>0>>0?co+1|0:co;En=(co&1)<<31|Dn>>>1;mn=co>>>1;Dn=Vl(En,mn,En,mn);co=T;if((so|0)==(co|0)&Dn>>>0>eo>>>0|co>>>0>so>>>0){continue}break}}co=o[Ye+20>>2];Dn=0;if(!co){break b}so=co+ -1|0;zo=o[o[Ye+16>>2]+(so>>>3&536870908)>>2];o[Ye+20>>2]=so;Dn=Fo;co=vo;wo=Dn-co|0;vo=co>>31;Fo=(Dn>>31)-(vo+(Dn>>>0>>0)|0)|0;Dn=Vl(xo,uo,wo,Fo);eo=T;vo=Vl(co,vo,Do,to);Dn=vo+Dn|0;co=T+eo|0;co=Dn>>>0>>0?co+1|0:co;Bo=Dn;Dn=Co;eo=Eo;yo=Dn-eo|0;Eo=eo>>31;vo=(Dn>>31)-(Eo+(Dn>>>0>>0)|0)|0;Dn=Vl(En,mn,yo,vo);Co=Dn;Dn=zo>>>(so&31)&1;Ao=Dn?0-Co|0:Co;so=Bo+Ao|0;zo=co;co=T;co=zo+(Dn?0-(co+(0>>0)|0)|0:co)|0;Mo=Ye,No=Wl(so,so>>>0>>0?co+1|0:co,Do,to),o[Mo+12>>2]=No;co=Vl(xo,uo,yo,vo);so=T;Co=Ye;eo=Vl(eo,Eo,Do,to);Ye=eo+co|0;co=T+so|0;co=Ye>>>0>>0?co+1|0:co;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Ye+104>>2];Vo=Uo>>31;Qo=Wl(Vl(Uo,Vo,Qo,Qo>>31),T,So,Po);o[To+20>>2]=Qo;Po=Wl(Vl(Uo,Vo,Ro,Ro>>31),T,So,Po);o[To+16>>2]=Po;Ro=Po;Po=Po>>31;Po=(Uo-(Ro+Po^Po)|0)+((Qo|0)<0?Qo:0-Qo|0)|0;if((Xo|0)>=0){o[To+24>>2]=Po;break b}o[To+24>>2]=0-Po}Po=Pf(dp);Ro=o[To+16>>2];c:{if(!Po){Qo=o[To+20>>2];break c}o[To+24>>2]=0-o[To+24>>2];Qo=0-o[To+20>>2]|0;o[To+20>>2]=Qo;Ro=0-Ro|0;o[To+16>>2]=Ro}d:{if((Ro|0)>=0){Po=o[Ye+104>>2];Ro=Po+o[To+24>>2]|0;Po=Po+Qo|0;break d}e:{if((Qo|0)<=-1){Ro=o[To+24>>2];Po=Ro>>31;Po=Po^Po+Ro;break e}Ro=o[To+24>>2];Po=Ro>>31;Po=o[Ye+100>>2]-(Po^Po+Ro)|0}if((Ro|0)<=-1){Ro=Qo;Qo=Qo>>31;Ro=Ro+Qo^Qo;break d}Ro=Qo;Qo=Qo>>31;Ro=o[Ye+100>>2]-(Ro+Qo^Qo)|0}Qo=o[Ye+100>>2];f:{if(!(Po|Ro)){Ro=Qo;Po=Qo;break f}if(!((Qo|0)!=(Ro|0)|Po)){Po=Ro;break f}if(!((Po|0)!=(Qo|0)|Ro)){Ro=Po;break f}g:{if(Po){break g}So=o[Ye+104>>2];if((So|0)>=(Ro|0)){break g}Ro=(So<<1)-Ro|0;Po=0;break f}h:{if((Po|0)!=(Qo|0)){break h}So=o[Ye+104>>2];if((So|0)<=(Ro|0)){break h}Ro=(So<<1)-Ro|0;break f}i:{if((Qo|0)!=(Ro|0)){break i}Qo=o[Ye+104>>2];if((Qo|0)<=(Po|0)){break i}Po=(Qo<<1)-Po|0;break f}if(Ro){break f}Ro=0;Qo=o[Ye+104>>2];if((Qo|0)>=(Po|0)){break f}Po=(Qo<<1)-Po|0}o[To+12>>2]=Ro;o[To+8>>2]=Po;j:{if(o[Yo>>2]<1){break j}Ro=0;while(1){So=o[Zo>>2];k:{if((Po|0)>(So|0)){Qo=o[_o>>2];o[Qo+(Ro<<2)>>2]=So;break k}Qo=o[_o>>2];So=Qo+(Ro<<2)|0;Uo=o[ap>>2];if((Po|0)<(Uo|0)){o[So>>2]=Uo;break k}o[So>>2]=Po}Ro=Ro+1|0;So=o[Yo>>2];if((Ro|0)<(So|0)){Po=o[(To+8|0)+(Ro<<2)>>2];continue}break}Po=0;if((So|0)<1){break j}Ro=Wo<<3;Uo=Ro+Oo|0;Xo=En+Ro|0;while(1){So=Po<<2;Ro=So+Uo|0;So=o[So+Xo>>2]+o[Qo+So>>2]|0;o[Ro>>2]=So;l:{if((So|0)>o[Zo>>2]){Vo=So-o[$o>>2]|0}else{if((So|0)>=o[ap>>2]){break l}Vo=So+o[$o>>2]|0}o[Ro>>2]=Vo}Po=Po+1|0;if((Po|0)>2]){continue}break}}Wo=Wo+1|0;if((Wo|0)>=(bp|0)){break a}Qo=o[ep>>2];Po=o[Qo>>2];if(o[Qo+4>>2]-Po>>2>>>0>Wo>>>0){continue}break}}Zk();D()}R=To+32|0;return 1}function hf(Ye,En,Oo){Ye=Ye|0;En=En|0;Oo=Oo|0;var Po=0,Qo=0,Ro=0,fp=0,gp=0,hp=0,ip=0,jp=0,kp=0,lp=0,mp=0,np=0,op=0,pp=0,qp=0,rp=0,sp=0,tp=0,up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0;Ro=R-96|0;R=Ro;Qo=o[Ye+16>>2];m[Ro+92|0]=1;o[Ro+88>>2]=En;o[Ro+84>>2]=En;o[Ro+80>>2]=Qo;Po=-1;Po=(En|0)!=-1?o[o[Qo>>2]+(En<<2)>>2]:Po;fp=o[Ye+20>>2];Qo=o[fp>>2];a:{b:{c:{d:{if(o[fp+4>>2]-Qo>>2>>>0>Po>>>0){Qo=o[o[Ye+8>>2]+(o[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Ye|0;Qo=En+lp|0;if(Qo>>>0>>0){pp=pp+1|0}Ye=En^Qo;Qo=fp^pp;f:{if((kp|0)<-1?1:(kp|0)<=-1?hp>>>0>4294967295?0:1:0){En=hp;fp=Ye+(Po-En|0)|0;En=Qo+(gp-((Po>>>0>>0)+kp|0)|0)|0;Po=fp;Ye=Po>>>0>>0?En+1|0:En;if(!jp){break f}break b}En=gp+kp|0;fp=Po;Po=hp;fp=fp+Po|0;if(fp>>>0>>0){En=En+1|0}Po=Ye;fp=Po+fp|0;Ye=En+Qo|0;Ye=fp>>>0>>0?Ye+1|0:Ye;Po=fp;if(jp){break b}}if((Po|0)<536870913){break a}Ye=((Ye&536870911)<<3|Po>>>29)&7;En=0;hp=Wl(hp,kp,Ye,En);ip=Wl(ip,np,Ye,En);lp=Wl(lp,op,Ye,En);break a}Zk();D()}Zk();D()}Zk();D()}if((Ye|0)<0?1:(Ye|0)<=0?Po>>>0>=536870913?0:1:0){break a}En=Ye>>>29;Ye=(Ye&536870911)<<3|Po>>>29;hp=Wl(hp,kp,Ye,En);ip=Wl(ip,np,Ye,En);lp=Wl(lp,op,Ye,En)}o[Oo+8>>2]=hp;o[Oo+4>>2]=ip;o[Oo>>2]=lp;R=Ro+96|0}function jf(Ye){var En=0,Oo=0,Cp=0;En=o[Ye+8>>2];Cp=o[Ye>>2];a:{if(p[Ye+12|0]){b:{c:{d:{e:{if((En|0)==-1){break e}Oo=En+1|0;En=(Oo>>>0)%3|0?Oo:En+ -2|0;if((En|0)==-1){break e}En=o[o[Cp+12>>2]+(En<<2)>>2];if((En|0)!=-1){break d}}o[Ye+8>>2]=-1;break c}Oo=En+1|0;En=(Oo>>>0)%3|0?Oo:En+ -2|0;o[Ye+8>>2]=En;if((En|0)!=-1){break b}}Oo=o[Ye+4>>2];En=-1;f:{if((Oo|0)==-1){break f}Oo=Oo+((Oo>>>0)%3|0?-1:2)|0;En=-1;if((Oo|0)==-1){break f}Oo=o[o[Cp+12>>2]+(Oo<<2)>>2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])),v(bq*v(o[(_p|4)+aq>>2])),Zp+20|0);wl(o[o[o[dq>>2]- -64>>2]>>2]+Ye|0,Zp+20|0,$p);_p=1;cq=cq+1|0;if((cq|0)==(Dp|0)){break a}Ep=Ep+2|0;Ye=Ye+$p|0;_p=o[Zp+8>>2];continue}}R=Zp+32|0;return _p|0}function pf(Ye,Dp,eq){var fq=0,gq=0,hq=v(0),iq=v(0),jq=v(0),kq=0,lq=0;hq=v(Ye+Dp);a:{b:{jq=v(Ye-Dp);if(jq<=v(.5)^1|jq>=v(-.5)^1|hq>=v(.5)^1){break b}gq=1;if(!(hq<=v(1.5))){break b}iq=Dp;break a}c:{if(!!(hq<=v(.5))){iq=v(v(.5)-Ye);Ye=v(v(.5)-Dp);break c}if(!!(hq>=v(1.5))){iq=v(v(1.5)-Ye);Ye=v(v(1.5)-Dp);break c}if(!!(jq<=v(-.5))){iq=v(Ye+v(.5));Ye=v(Dp+v(-.5));break c}iq=v(Ye+v(-.5));Ye=v(Dp+v(.5))}jq=v(Ye-iq);hq=v(iq+Ye);gq=-1}fq=+iq;Dp=v(fq+fq+ -1);fq=+Ye;Ye=v(fq+fq+ -1);lq=gq;gq=+jq;gq=gq+gq;fq=1-gq;gq=gq+1;gq=fq>2]=0;hq=v(0);Ye=v(0);break d}jq=v(v(1)/v(C(hq)));s[eq>>2]=jq*iq;hq=v(jq*Dp);Ye=v(jq*Ye)}s[eq+8>>2]=hq;s[eq+4>>2]=Ye}function qf(Ye,Dp,eq,mq){Ye=Ye|0;Dp=Dp|0;eq=eq|0;mq=mq|0;var nq=0,oq=0,pq=0;nq=R-32|0;R=nq;a:{if((mq|0)==3){mq=o[Dp+4>>2];Dp=o[Dp+12>>2];o[nq+24>>2]=-1;o[nq+28>>2]=-1;o[nq+16>>2]=-1;o[nq+20>>2]=-1;if((eq|0)==-2){o[nq+8>>2]=0;o[Ye>>2]=0;break a}oq=o[o[o[mq+4>>2]+8>>2]+(Dp<<2)>>2];if((l[o[o[mq>>2]+8>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]=o[qq>>2];o[Dp+12>>2]=eq;eq=o[qq+12>>2];o[Dp+16>>2]=o[qq+8>>2];o[Dp+20>>2]=eq;o[Dp+36>>2]=rq;o[Dp+32>>2]=mq;o[Dp+28>>2]=tq;o[Dp+24>>2]=sq;o[Dp+64>>2]=rq;o[Dp+60>>2]=mq;o[Dp+56>>2]=tq;o[Dp+52>>2]=sq;o[Dp+44>>2]=0;o[Dp+48>>2]=0;o[Dp>>2]=6648;o[Dp+72>>2]=-1;o[Dp+76>>2]=-1;o[Dp+68>>2]=1;o[Dp+40>>2]=7068;break a}o[Ye>>2]=0}o[Ye>>2]=0;return}o[Dp+80>>2]=-1;o[Dp+84>>2]=-1;Mf(Dp+88|0);o[Ye>>2]=Dp}function sf(Ye){Ye=Ye|0;o[Ye>>2]=5644;return Ye|0}function tf(Ye){Ye=Ye|0;o[Ye>>2]=5644;ul(Ye)}function uf(Ye){Ye=Ye|0;var Dp=0;a:{if(!o[Ye+44>>2]|!o[Ye+48>>2]|(!o[Ye+24>>2]|!o[Ye+28>>2])){break a}if(!o[Ye+32>>2]|!o[Ye+36>>2]){break a}Dp=o[Ye+72>>2]!=-1}return Dp|0}function vf(Ye,eq){Ye=Ye|0;eq=eq|0;var mq=0;if(!(o[eq+56>>2]|p[eq+24|0]!=3)){o[Ye+44>>2]=eq;mq=1}return mq|0}function wf(o){o=o|0;return 3}function xf(Ye,eq){Ye=Ye|0;eq=eq|0;var qq=0,rq=0,wq=0,xq=0,yq=0,zq=0,Aq=0,Bq=0,Cq=0;qq=o[eq+12>>2];zq=qq;wq=qq;qq=o[eq+20>>2];xq=qq;yq=o[eq+16>>2];rq=yq+4|0;if(rq>>>0<4){qq=qq+1|0}Aq=o[eq+8>>2];Bq=rq;rq=qq;a:{if((wq|0)<(qq|0)?1:(wq|0)<=(qq|0)?Aq>>>0>=Bq>>>0?0:1:0){break a}qq=yq+o[eq>>2]|0;wq=p[qq|0]|p[qq+1|0]<<8|(p[qq+2|0]<<16|p[qq+3|0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(Ye){Ye=Ye|0;o[Ye>>2]=6648;return Ye|0}function Cf(Ye){Ye=Ye|0;o[Ye>>2]=6648;ul(Ye)}function Df(Ye,eq,dr,er,fr,gr){Ye=Ye|0;eq=eq|0;dr=dr|0;er=er|0;fr=fr|0;gr=gr|0;var hr=0,ir=0,jr=0,kr=0,lr=0,mr=0,nr=0,or=0,pr=0,qr=0,rr=0;hr=R-48|0;R=hr;nr=Ye+8|0;er=o[nr>>2];if(er+ -2>>>0<=28){o[Ye+72>>2]=er;er=-1<>2]=fr;o[Ye+76>>2]=er^-1;o[Ye+84>>2]=(fr|0)/2}o[Ye+48>>2]=gr;er=o[Ye+36>>2];fr=o[er>>2];gr=er+4|0;ir=o[gr>>2];o[hr+16>>2]=0;o[hr+8>>2]=0;o[hr+12>>2]=0;a:{fr=ir-fr|0;if((fr|0)<1){break a}er=o[er>>2];if((er|0)!=o[gr>>2]){or=fr>>2;pr=Ye+40|0;qr=Ye+88|0;rr=Ye+36|0;while(1){hf(pr,o[(lr<<2)+er>>2],hr+8|0);fr=o[hr+12>>2];ir=fr>>31;gr=o[hr+8>>2];kr=gr>>31;mr=o[hr+16>>2];jr=mr>>31;er=0;jr=jr^jr+mr;ir=jr+((ir^fr+ir)+(kr^gr+kr)|0)|0;if(ir>>>0>>0){er=1}b:{if(!(er|ir)){o[hr+8>>2]=o[Ye+84>>2];break b}kr=o[Ye+84>>2];jr=kr;jr=jr>>31;fr=Wl(Vl(kr,jr,fr,fr>>31),T,ir,er);o[hr+12>>2]=fr;er=Wl(Vl(kr,jr,gr,gr>>31),T,ir,er);o[hr+8>>2]=er;gr=er;er=er>>31;er=(kr-(gr+er^er)|0)+((fr|0)<0?fr:0-fr|0)|0;if((mr|0)>=0){o[hr+16>>2]=er;break b}o[hr+16>>2]=0-er}er=Pf(qr);gr=o[hr+8>>2];c:{if(!er){fr=o[hr+12>>2];break c}o[hr+16>>2]=0-o[hr+16>>2];fr=0-o[hr+12>>2]|0;o[hr+12>>2]=fr;gr=0-gr|0;o[hr+8>>2]=gr}d:{if((gr|0)>=0){gr=o[Ye+84>>2];er=gr+o[hr+16>>2]|0;gr=fr+gr|0;break d}e:{if((fr|0)<=-1){er=o[hr+16>>2];gr=er>>31;gr=gr^er+gr;break e}er=o[hr+16>>2];gr=er>>31;gr=o[Ye+80>>2]-(gr^er+gr)|0}if((er|0)<=-1){er=fr>>31;er=er+fr^er;break d}er=fr>>31;er=o[Ye+80>>2]-(er+fr^er)|0}fr=o[Ye+80>>2];f:{if(!(er|gr)){er=fr;gr=er;break f}if(!((er|0)!=(fr|0)|gr)){gr=er;break f}if(!((fr|0)!=(gr|0)|er)){er=gr;break f}g:{if(gr){break g}ir=o[Ye+84>>2];if((ir|0)>=(er|0)){break g}er=(ir<<1)-er|0;gr=0;break f}h:{if((fr|0)!=(gr|0)){break h}ir=o[Ye+84>>2];if((ir|0)<=(er|0)){break h}er=(ir<<1)-er|0;break f}i:{if((er|0)!=(fr|0)){break i}fr=o[Ye+84>>2];if((fr|0)<=(gr|0)){break i}gr=(fr<<1)-gr|0;break f}if(er){break f}er=0;fr=o[Ye+84>>2];if((fr|0)>=(gr|0)){break f}gr=(fr<<1)-gr|0}fr=lr<<3;ir=fr+eq|0;kr=o[ir+4>>2];ir=o[ir>>2];o[hr+36>>2]=er;o[hr+32>>2]=gr;o[hr+24>>2]=ir;o[hr+28>>2]=kr;zf(hr+40|0,nr,hr+32|0,hr+24|0);er=dr+fr|0;o[er>>2]=o[hr+40>>2];o[er+4>>2]=o[hr+44>>2];lr=lr+1|0;if((lr|0)>=(or|0)){break a}fr=o[rr>>2];er=o[fr>>2];if(o[fr+4>>2]-er>>2>>>0>lr>>>0){continue}break}}Zk();D()}R=hr+48|0;return 1}function Ef(Ye,eq,dr,er,fr,gr){Ye=Ye|0;eq=eq|0;dr=dr|0;er=er|0;fr=fr|0;gr=gr|0;var sr=0,tr=0,ur=0,vr=0,wr=0,xr=0,yr=0,zr=0;gr=R-32|0;R=gr;tr=(fr&1073741823)!=(fr|0)?-1:fr<<2;tr=xl(Hk(tr),0,tr);sr=o[eq>>2];ur=o[eq+4>>2];wr=o[tr+4>>2];o[gr+16>>2]=o[tr>>2];o[gr+20>>2]=wr;o[gr+8>>2]=sr;o[gr+12>>2]=ur;ur=Ye+8|0;zf(gr+24|0,ur,gr+16|0,gr+8|0);o[dr>>2]=o[gr+24>>2];o[dr+4>>2]=o[gr+28>>2];if((fr|0)<(er|0)){wr=0-fr<<2;Ye=fr;while(1){sr=Ye<<2;vr=sr+eq|0;yr=o[vr>>2];vr=o[vr+4>>2];sr=dr+sr|0;xr=sr+wr|0;zr=o[xr+4>>2];o[gr+16>>2]=o[xr>>2];o[gr+20>>2]=zr;o[gr+8>>2]=yr;o[gr+12>>2]=vr;zf(gr+24|0,ur,gr+16|0,gr+8|0);o[sr>>2]=o[gr+24>>2];o[sr+4>>2]=o[gr+28>>2];Ye=Ye+fr|0;if((Ye|0)<(er|0)){continue}break}}ul(tr);R=gr+32|0;return 1}function Ff(Ye,eq,dr){Ye=Ye|0;eq=eq|0;dr=dr|0;if(ae(Ye,eq,dr)){Ye=o[o[o[o[eq+4>>2]+8>>2]+(dr<<2)>>2]+28>>2]==9}else{Ye=0}return Ye|0}function Gf(Ye,eq,dr){Ye=Ye|0;eq=eq|0;dr=dr|0;eq=R-32|0;R=eq;a:{if(p[o[Ye+4>>2]+36|0]>=2){dr=0;if(!l[o[o[Ye>>2]+52>>2]](Ye)){break a}}o[eq+24>>2]=0;o[eq+28>>2]=0;o[eq+16>>2]=0;o[eq+20>>2]=0;o[eq+12>>2]=-1;o[eq+8>>2]=1232;ed(eq+8|0,o[Ye+24>>2],o[Ye+28>>2],m[o[Ye+8>>2]+24|0],s[Ye+32>>2]);dr=jd(eq+8|0,o[Ye+16>>2]);o[eq+8>>2]=1232;Ye=o[eq+16>>2];if(!Ye){break a}o[eq+20>>2]=Ye;ul(Ye)}R=eq+32|0;return dr|0}function Hf(Ye,eq){Ye=Ye|0;eq=eq|0;return l[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63;break b;case 0:if(($r|0)<2){break a}o[Ye+4>>2]=$r+ -2;Ye=(Zr+$r|0)+ -2|0;Ye=p[Ye+1|0]<<8&16128|p[Ye|0];break b;case 1:break c}}if(($r|0)<3){break a}o[Ye+4>>2]=$r+ -3;Ye=(Zr+$r|0)+ -3|0;Ye=p[Ye+1|0]<<8|p[Ye+2|0]<<16&4128768|p[Ye|0]}Ye=Ye+4096|0;o[ds+8>>2]=Ye;if(Ye>>>0>1048575){break a}Ye=_r;_r=as+cs|0;if(_r>>>0>>0){Ye=Ye+1|0}o[Yr+16>>2]=_r;o[Yr+20>>2]=Ye;hs=1}R=bs+16|0;return hs}function Of(Ye,Yr,is){var js=0,ks=0,ls=0,ms=0;a:{if(Ye>>>0>5){break a}ls=o[is+16>>2];js=o[is+12>>2];ks=o[is+20>>2];if((js|0)<(ks|0)?1:(js|0)<=(ks|0)?r[is+8>>2]>ls>>>0?0:1:0){break a}js=p[ls+o[is>>2]|0];ls=ls+1|0;if(ls>>>0<1){ks=ks+1|0}o[is+16>>2]=ls;o[is+20>>2]=ks;ks=Yr;if(js&128){if(!Of(Ye+1|0,Yr,is)){break a}Ye=o[Yr>>2]<<7;o[Yr>>2]=Ye;js=Ye|js&127}o[ks>>2]=js;ms=1}return ms}function Pf(Ye){var Yr=0,is=0,ns=0,os=0,ps=0;ns=0-p[Ye+12|0]|0;is=o[Ye+8>>2];a:{if(is>>>0>4095){break a}Yr=o[Ye+4>>2];if((Yr|0)<1){break a}Yr=Yr+ -1|0;o[Ye+4>>2]=Yr;is=p[Yr+o[Ye>>2]|0]|is<<8;o[Ye+8>>2]=is}ns=ns&255;Yr=u(ns,is>>>8);os=is&255;ps=os>>>0>>0;o[Ye+8>>2]=ps?Yr+os|0:(is-ns|0)-Yr|0;return ps}function Qf(Ye,qs){var rs=0,ss=0,ts=0;ts=R-32|0;R=ts;a:{if(qs>>>0<=1){if(qs-1){qs=Hk(48);ug(qs);o[qs>>2]=9816;o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;break a}qs=Hk(52);ug(qs);o[qs+48>>2]=0;o[qs>>2]=8064;o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;break a}qs=Hk(32);o[ts>>2]=qs;o[ts+4>>2]=28;o[ts+8>>2]=-2147483616;m[qs+28|0]=0;rs=p[7812]|p[7813]<<8|(p[7814]<<16|p[7815]<<24);m[qs+24|0]=rs;m[qs+25|0]=rs>>>8;m[qs+26|0]=rs>>>16;m[qs+27|0]=rs>>>24;rs=p[7808]|p[7809]<<8|(p[7810]<<16|p[7811]<<24);ss=p[7804]|p[7805]<<8|(p[7806]<<16|p[7807]<<24);m[qs+16|0]=ss;m[qs+17|0]=ss>>>8;m[qs+18|0]=ss>>>16;m[qs+19|0]=ss>>>24;m[qs+20|0]=rs;m[qs+21|0]=rs>>>8;m[qs+22|0]=rs>>>16;m[qs+23|0]=rs>>>24;rs=p[7800]|p[7801]<<8|(p[7802]<<16|p[7803]<<24);ss=p[7796]|p[7797]<<8|(p[7798]<<16|p[7799]<<24);m[qs+8|0]=ss;m[qs+9|0]=ss>>>8;m[qs+10|0]=ss>>>16;m[qs+11|0]=ss>>>24;m[qs+12|0]=rs;m[qs+13|0]=rs>>>8;m[qs+14|0]=rs>>>16;m[qs+15|0]=rs>>>24;rs=p[7792]|p[7793]<<8|(p[7794]<<16|p[7795]<<24);ss=p[7788]|p[7789]<<8|(p[7790]<<16|p[7791]<<24);m[qs|0]=ss;m[qs+1|0]=ss>>>8;m[qs+2|0]=ss>>>16;m[qs+3|0]=ss>>>24;m[qs+4|0]=rs;m[qs+5|0]=rs>>>8;m[qs+6|0]=rs>>>16;m[qs+7|0]=rs>>>24;o[ts+16>>2]=-1;qs=Mk(ts+16|4,ts);o[Ye>>2]=o[ts+16>>2];Mk(Ye+4|0,qs);o[Ye+16>>2]=0;if(m[qs+11|0]<=-1){ul(o[qs>>2])}if(m[ts+11|0]>-1){break a}ul(o[ts>>2])}R=ts+32|0}function Rf(Ye,qs){var us=0,vs=0,ws=0;us=R-80|0;R=us;vs=o[qs+36>>2];o[us+72>>2]=o[qs+32>>2];o[us+76>>2]=vs;ws=o[qs+28>>2];vs=us- -64|0;o[vs>>2]=o[qs+24>>2];o[vs+4>>2]=ws;vs=o[qs+20>>2];o[us+56>>2]=o[qs+16>>2];o[us+60>>2]=vs;vs=o[qs+12>>2];o[us+48>>2]=o[qs+8>>2];o[us+52>>2]=vs;vs=o[qs+4>>2];o[us+40>>2]=o[qs>>2];o[us+44>>2]=vs;ci(us+8|0,us+40|0,us+24|0);qs=o[us+8>>2];a:{if(qs){o[Ye>>2]=qs;Mk(Ye+4|0,us+8|4);if(m[us+23|0]>=0){break a}ul(o[us+12>>2]);break a}if(m[us+23|0]<=-1){ul(o[us+12>>2])}qs=p[us+31|0];o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;o[Ye+8>>2]=0;o[Ye+12>>2]=0}R=us+80|0}function Sf(Ye,qs,xs,ys){var zs=0,As=0,Bs=0;zs=R-80|0;R=zs;As=o[xs+36>>2];o[zs+72>>2]=o[xs+32>>2];o[zs+76>>2]=As;Bs=o[xs+28>>2];As=zs- -64|0;o[As>>2]=o[xs+24>>2];o[As+4>>2]=Bs;As=o[xs+20>>2];o[zs+56>>2]=o[xs+16>>2];o[zs+60>>2]=As;As=o[xs+12>>2];o[zs+48>>2]=o[xs+8>>2];o[zs+52>>2]=As;As=o[xs+4>>2];o[zs+40>>2]=o[xs>>2];o[zs+44>>2]=As;ci(Ye,zs+40|0,zs+24|0);a:{if(o[Ye>>2]){break a}As=Ye+4|0;if(m[Ye+15|0]<=-1){ul(o[As>>2])}if(p[zs+31|0]!=1){o[zs+8>>2]=0;o[zs>>2]=0;o[zs+4>>2]=0;qs=Hk(32);o[zs>>2]=qs;o[zs+4>>2]=20;o[zs+8>>2]=-2147483616;m[qs+20|0]=0;xs=p[7860]|p[7861]<<8|(p[7862]<<16|p[7863]<<24);m[qs+16|0]=xs;m[qs+17|0]=xs>>>8;m[qs+18|0]=xs>>>16;m[qs+19|0]=xs>>>24;xs=p[7856]|p[7857]<<8|(p[7858]<<16|p[7859]<<24);ys=p[7852]|p[7853]<<8|(p[7854]<<16|p[7855]<<24);m[qs+8|0]=ys;m[qs+9|0]=ys>>>8;m[qs+10|0]=ys>>>16;m[qs+11|0]=ys>>>24;m[qs+12|0]=xs;m[qs+13|0]=xs>>>8;m[qs+14|0]=xs>>>16;m[qs+15|0]=xs>>>24;xs=p[7848]|p[7849]<<8|(p[7850]<<16|p[7851]<<24);ys=p[7844]|p[7845]<<8|(p[7846]<<16|p[7847]<<24);m[qs|0]=ys;m[qs+1|0]=ys>>>8;m[qs+2|0]=ys>>>16;m[qs+3|0]=ys>>>24;m[qs+4|0]=xs;m[qs+5|0]=xs>>>8;m[qs+6|0]=xs>>>16;m[qs+7|0]=xs>>>24;o[Ye>>2]=-1;Mk(As,zs);if(m[zs+11|0]>-1){break a}ul(o[zs>>2]);break a}Qf(zs,p[zs+32|0]);Bs=o[zs>>2];b:{if(Bs){o[Ye>>2]=Bs;Mk(As,zs|4);break b}Bs=o[zs+16>>2];o[zs+16>>2]=0;o[Bs+44>>2]=ys;fi(Ye,Bs,qs,xs,ys);if(!o[Ye>>2]){if(m[As+11|0]<=-1){ul(o[As>>2])}o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+8>>2]=0;o[Ye+12>>2]=0}if(!Bs){break b}l[o[o[Bs>>2]+4>>2]](Bs)}Ye=o[zs+16>>2];o[zs+16>>2]=0;if(Ye){l[o[o[Ye>>2]+4>>2]](Ye)}if(m[zs+15|0]>-1){break a}ul(o[zs+4>>2])}R=zs+80|0}function Tf(Ye){var qs=0,xs=0,ys=0,Cs=0;Cs=R-16|0;R=Cs;qs=Hk(32);o[Cs>>2]=qs;o[Cs+4>>2]=26;o[Cs+8>>2]=-2147483616;m[qs+26|0]=0;xs=p[7841]|p[7842]<<8;m[qs+24|0]=xs;m[qs+25|0]=xs>>>8;ys=p[7837]|p[7838]<<8|(p[7839]<<16|p[7840]<<24);xs=p[7833]|p[7834]<<8|(p[7835]<<16|p[7836]<<24);m[qs+16|0]=xs;m[qs+17|0]=xs>>>8;m[qs+18|0]=xs>>>16;m[qs+19|0]=xs>>>24;m[qs+20|0]=ys;m[qs+21|0]=ys>>>8;m[qs+22|0]=ys>>>16;m[qs+23|0]=ys>>>24;ys=p[7829]|p[7830]<<8|(p[7831]<<16|p[7832]<<24);xs=p[7825]|p[7826]<<8|(p[7827]<<16|p[7828]<<24);m[qs+8|0]=xs;m[qs+9|0]=xs>>>8;m[qs+10|0]=xs>>>16;m[qs+11|0]=xs>>>24;m[qs+12|0]=ys;m[qs+13|0]=ys>>>8;m[qs+14|0]=ys>>>16;m[qs+15|0]=ys>>>24;ys=p[7821]|p[7822]<<8|(p[7823]<<16|p[7824]<<24);xs=p[7817]|p[7818]<<8|(p[7819]<<16|p[7820]<<24);m[qs|0]=xs;m[qs+1|0]=xs>>>8;m[qs+2|0]=xs>>>16;m[qs+3|0]=xs>>>24;m[qs+4|0]=ys;m[qs+5|0]=ys>>>8;m[qs+6|0]=ys>>>16;m[qs+7|0]=ys>>>24;o[Ye>>2]=-1;Mk(Ye+4|0,Cs);if(m[Cs+11|0]<=-1){ul(o[Cs>>2])}R=Cs+16|0}function Uf(Ye,Ds){var Es=0,Fs=0,Gs=0;Gs=R-16|0;R=Gs;o[Gs+12>>2]=Ds;Ds=Hk(32);o[Gs>>2]=Ds;o[Gs+4>>2]=24;o[Gs+8>>2]=-2147483616;m[Ds+24|0]=0;Es=p[7885]|p[7886]<<8|(p[7887]<<16|p[7888]<<24);Fs=p[7881]|p[7882]<<8|(p[7883]<<16|p[7884]<<24);m[Ds+16|0]=Fs;m[Ds+17|0]=Fs>>>8;m[Ds+18|0]=Fs>>>16;m[Ds+19|0]=Fs>>>24;m[Ds+20|0]=Es;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20>>2]:_s;$s=Xs>>>0<_s>>>0?Xs:_s;if($s){at=Ws+16|0;Us=Zj(Zs?o[at>>2]:at,Us?o[Vs>>2]:Vs,$s);if(Us){break k}}if(_s>>>0>>0){break i}break h}if((Us|0)>-1){break h}}if(!Ys){o[Ts>>2]=Ds;return Ds}o[Ts>>2]=Ws;return Ws+4|0}return Zf(Ye,Ts,Vs)}Ws=Zj(Xs,$s,Ys);if(Ws){break c}}if(bt){break b}break a}if((Ws|0)>-1){break a}}$s=Ds+4|0;Ys=o[$s>>2];l:{if(Ys){Ws=Ys;while(1){Us=Ws;Ws=o[Ws>>2];if(Ws){continue}break}break l}Us=o[Ds+8>>2];if(o[Us>>2]==(Ds|0)){break l}Ws=Ds+8|0;while(1){Xs=o[Ws>>2];Ws=Xs+8|0;Us=o[Xs+8>>2];if((Xs|0)!=o[Us>>2]){continue}break}}m:{n:{if((Us|0)==(ct|0)){break n}Xs=p[Us+27|0];Ws=Xs<<24>>24<0;o:{Xs=Ws?o[Us+20>>2]:Xs;at=Xs>>>0>>0?Xs:Zs;if(at){bt=(_s|0)<0?o[Vs>>2]:Vs;_s=Us+16|0;Ws=Zj(bt,Ws?o[_s>>2]:_s,at);if(Ws){break o}}if(Zs>>>0>>0){break n}break m}if((Ws|0)>-1){break m}}if(!Ys){o[Ts>>2]=Ds;return $s}o[Ts>>2]=Us;return Us}return Zf(Ye,Ts,Vs)}o[Ts>>2]=Ds;o[Us>>2]=Ds;return Us}function Zf(Ye,Ds,Ts){var Us=0,Vs=0,ft=0,gt=0,ht=0,it=0,jt=0,kt=0,lt=0;a:{Us=Ye+4|0;Ye=o[Us>>2];if(Ye){ft=p[Ts+11|0];gt=ft<<24>>24<0;ft=gt?o[Ts+4>>2]:ft;jt=gt?o[Ts>>2]:Ts;while(1){Ts=Ye+16|0;Vs=p[Ye+27|0];gt=Vs<<24>>24<0;ht=gt?o[Ye+20>>2]:Vs;kt=ht>>>0>>0;b:{c:{d:{e:{f:{g:{h:{Vs=kt?ht:ft;if(Vs){it=gt?o[Ts>>2]:Ts;lt=Zj(jt,it,Vs);if(lt){break h}}if(ft>>>0>>0){break g}if(!Vs){break e}it=gt?o[Ts>>2]:Ts;break f}if((lt|0)>-1){break f}}Ts=o[Ye>>2];if(Ts){break b}o[Ds>>2]=Ye;return Ye}Ts=Zj(it,jt,Vs);if(Ts){break d}}if(kt){break c}break a}if((Ts|0)>-1){break a}}Us=Ye+4|0;Ts=o[Ye+4>>2];if(!Ts){break a}Ye=Us}Us=Ye;Ye=Ts;continue}}o[Ds>>2]=Us;return Us}o[Ds>>2]=Ye;return Us}function _f(Ye,Ds,Ts,mt){var nt=0,ot=0,pt=0,qt=0,rt=0;if(!Ye){return 1}nt=o[Ts+16>>2];qt=o[Ts+12>>2];pt=o[Ts+20>>2];ot=pt;a:{if((qt|0)<(ot|0)?1:(qt|0)<=(ot|0)?r[Ts+8>>2]>nt>>>0?0:1:0){break a}ot=p[nt+o[Ts>>2]|0];nt=nt+1|0;if(nt>>>0<1){pt=pt+1|0}o[Ts+16>>2]=nt;o[Ts+20>>2]=pt;if(ot>>>0>1){break a}if(ot-1){return $f(Ye,Ds,Ts,mt)}rt=ag(Ye,Ts,mt)}return rt}function $f(Ye,Ds,Ts,mt){var st=0,tt=0,ut=0,vt=0,wt=0,xt=0,yt=0,zt=0,At=0,Bt=0,Ct=0,Dt=0,Et=0,Ft=0,Gt=0,Ht=0;st=R+ -64|0;R=st;o[st+56>>2]=0;o[st+48>>2]=0;o[st+52>>2]=0;o[st+40>>2]=0;o[st+44>>2]=0;o[st+32>>2]=0;o[st+36>>2]=0;o[st+24>>2]=0;o[st+28>>2]=0;o[st+16>>2]=0;o[st+20>>2]=0;o[st+8>>2]=0;o[st+12>>2]=0;a:{if(!bg(st+8|0,Ts)){break a}if(!cg(st+8|0,Ts)|(o[st+20>>2]?0:Ye)){break a}qi(Ts,0,0);if(Ye){vt=o[st+56>>2];Dt=o[st+36>>2];Et=o[st+48>>2];Ft=o[st+24>>2];while(1){b:{if(vt>>>0>16383){break b}tt=o[st+52>>2];while(1){if((tt|0)<1){break b}tt=tt+ -1|0;o[st+52>>2]=tt;vt=p[tt+Et|0]|vt<<8;o[st+56>>2]=vt;if(vt>>>0<16384){continue}break}}ut=vt&4095;Bt=o[(ut<<2)+Ft>>2];wt=(Bt<<3)+Dt|0;vt=(u(o[wt>>2],vt>>>12)+ut|0)-o[wt+4>>2]|0;o[st+56>>2]=vt;if((Ds|0)>=1){if(!p[Ts+36|0]){ut=0;break a}wt=Ds+xt|0;while(1){c:{if((Bt|0)<1){zt=0;break c}ut=o[Ts+32>>2];Gt=o[Ts+28>>2];Ht=o[Ts+24>>2];tt=0;zt=0;while(1){yt=(ut>>>3)+Ht|0;d:{if(yt>>>0>=Gt>>>0){At=0;break d}At=p[yt|0];yt=ut+1|0;o[Ts+32>>2]=yt;At=At>>>(ut&7)&1;ut=yt}zt=At<>2]=zt;xt=xt+1|0;if((wt|0)!=(xt|0)){continue}break}xt=wt}Ct=Ds+Ct|0;if(Ct>>>0>>0){continue}break}}si(Ts);ut=1}Ye=o[st+36>>2];if(Ye){o[st+40>>2]=Ye;ul(Ye)}Ye=o[st+24>>2];if(Ye){o[st+28>>2]=Ye;ul(Ye)}Ye=o[st+8>>2];if(Ye){o[st+12>>2]=Ye;ul(Ye)}R=st- -64|0;return ut}function ag(Ye,Ds,Ts){var mt=0,It=0,Jt=0,Kt=0;a:{b:{It=o[Ds+16>>2];Jt=o[Ds+12>>2];mt=o[Ds+20>>2];c:{if((Jt|0)<(mt|0)?1:(Jt|0)<=(mt|0)?r[Ds+8>>2]>It>>>0?0:1:0){break c}Jt=p[It+o[Ds>>2]|0];It=It+1|0;if(It>>>0<1){mt=mt+1|0}o[Ds+16>>2]=It;o[Ds+20>>2]=mt;mt=Jt+ -1|0;if(mt>>>0>17){break c}d:{e:{f:{g:{h:{i:{j:{switch(mt-1|0){case 12:case 13:case 14:case 15:break a;case 8:break h;case 7:break i;case 3:break j;case 16:break d;case 11:break e;case 10:break f;case 9:break g;default:break b}}return eg(Ye,Ds,Ts)}return fg(Ye,Ds,Ts)}return gg(Ye,Ds,Ts)}return hg(Ye,Ds,Ts)}return ig(Ye,Ds,Ts)}return jg(Ye,Ds,Ts)}Kt=kg(Ye,Ds,Ts)}return Kt}return dg(Ye,Ds,Ts)}return kg(Ye,Ds,Ts)}function bg(Ye,Ds){var Ts=0,Lt=0,Mt=0,Nt=0,Ot=0,Pt=0,Qt=0,Rt=0,St=0,Tt=0,Ut=0,Vt=0,Wt=0;a:{if(!q[Ds+38>>1]){break a}Tt=Ye+12|0;if(!lg(1,Tt,Ds)){break a}Nt=o[Ye+12>>2];Ts=o[Ye>>2];Lt=o[Ye+4>>2]-Ts>>2;b:{if(Nt>>>0>Lt>>>0){Da(Ye,Nt-Lt|0);Nt=o[Ye+12>>2];break b}if(Nt>>>0>=Lt>>>0){break b}o[Ye+4>>2]=Ts+(Nt<<2)}if(!Nt){Wt=1;break a}Ut=o[Ds+8>>2];Qt=o[Ds+12>>2];while(1){Mt=o[Ds+16>>2];Lt=o[Ds+20>>2];Ts=Lt;if((Qt|0)<(Ts|0)?1:(Qt|0)<=(Ts|0)?Ut>>>0>Mt>>>0?0:1:0){break a}Vt=o[Ds>>2];Rt=p[Vt+Mt|0];Mt=Mt+1|0;if(Mt>>>0<1){Lt=Lt+1|0}Ts=Ds;Pt=Mt;o[Ts+16>>2]=Mt;o[Ts+20>>2]=Lt;Mt=Rt>>>2;c:{d:{e:{St=Rt&3;if(St>>>0>3){Ts=0;break e}Ts=0;f:{switch(St-1|0){case 2:break f;case 0:case 1:break e;default:break d}}Lt=Mt+Ot|0;if(Lt>>>0>=Nt>>>0){return 0}xl(o[Ye>>2]+(Ot<<2)|0,0,(Rt&252)+4|0);Ot=Lt;break c}while(1){if((Qt|0)<(Lt|0)?1:(Qt|0)<=(Lt|0)?Ut>>>0>Pt>>>0?0:1:0){return 0}Rt=p[Pt+Vt|0];Pt=Pt+1|0;if(Pt>>>0<1){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Zt=Zt+bu|0;_t=Xt+Yt|0;if(_t>>>0>>0){Zt=Zt+1|0}o[Ds+16>>2]=_t;o[Ds+20>>2]=Zt;if((Xt|0)<1){break a}Yt=Yt+o[Ds>>2]|0;o[Ye+40>>2]=Yt;Ds=Ye;b:{c:{d:{e:{f:{_t=Xt+ -1|0;au=Yt+_t|0;switch((p[au|0]>>>6)-1|0){case 2:break c;case 1:break d;case 0:break e;default:break f}}o[Ye+44>>2]=_t;Ye=p[au|0]&63;break b}if((Xt|0)<2){break a}o[Ye+44>>2]=Xt+ -2;Ye=(Xt+Yt|0)+ -2|0;Ye=p[Ye+1|0]<<8&16128|p[Ye|0];break b}if((Xt|0)<3){break a}o[Ye+44>>2]=Xt+ -3;Ye=(Xt+Yt|0)+ -3|0;Ye=p[Ye+1|0]<<8|p[Ye+2|0]<<16&4128768|p[Ye|0];break b}o[Ye+44>>2]=Xt+ -4;Ye=(Xt+Yt|0)+ -4|0;Ye=p[Ye+2|0]<<16|p[Ye+3|0]<<24&1056964608|p[Ye+1|0]<<8|p[Ye|0]}Ye=Ye+16384|0;o[Ds+48>>2]=Ye;cu=Ye>>>0<4194304}R=$t+16|0;return cu}function dg(Ye,Ds,du){var eu=0,fu=0,gu=0,hu=0,iu=0,ju=0,ku=0,lu=0,mu=0,nu=0;eu=R+ -64|0;R=eu;o[eu+48>>2]=0;o[eu+40>>2]=0;o[eu+44>>2]=0;o[eu+32>>2]=0;o[eu+36>>2]=0;o[eu+24>>2]=0;o[eu+28>>2]=0;o[eu+16>>2]=0;o[eu+20>>2]=0;o[eu+8>>2]=0;o[eu+12>>2]=0;o[eu>>2]=0;o[eu+4>>2]=0;a:{if(!bg(eu,Ds)|(o[eu+12>>2]?0:Ye)){break a}if(!ng(1,eu+56|0,Ds)){break a}gu=o[Ds+8>>2];mu=o[Ds+16>>2];hu=mu;ku=gu-hu|0;ju=o[eu+60>>2];fu=ju;lu=o[Ds+20>>2];hu=o[Ds+12>>2]-(lu+(gu>>>0>>0)|0)|0;gu=o[eu+56>>2];if((fu|0)==(hu|0)&gu>>>0>ku>>>0|fu>>>0>hu>>>0){break a}ju=ju+lu|0;hu=mu;lu=hu+gu|0;if(lu>>>0>>0){ju=ju+1|0}o[Ds+16>>2]=lu;o[Ds+20>>2]=ju;if((gu|0)<1){break a}ku=mu+o[Ds>>2]|0;o[eu+40>>2]=ku;hu=eu;b:{c:{d:{e:{f:{Ds=gu+ -1|0;fu=ku+Ds|0;switch((p[fu|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((gu|0)<2){break a}Ds=gu+ -2|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -2|0;fu=p[fu+1|0]<<8&16128|p[fu|0];break b}if((gu|0)<3){break a}Ds=gu+ -3|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -3|0;fu=p[fu+1|0]<<8|p[fu+2|0]<<16&4128768|p[fu|0];break b}Ds=gu+ -4|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -4|0;fu=p[fu+2|0]<<16|p[fu+3|0]<<24&1056964608|p[fu+1|0]<<8|p[fu|0];break b}o[eu+44>>2]=Ds;fu=p[fu|0]&63}iu=fu+16384|0;o[hu+48>>2]=iu;nu=iu>>>0<4194304;if(!Ye|iu>>>0>4194303){break a}lu=o[eu+28>>2];ju=0;mu=o[eu+16>>2];while(1){g:{if(iu>>>0>16383){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[eu+44>>2]=Ds;iu=p[Ds+ku|0]|iu<<8;o[eu+48>>2]=iu;if(iu>>>0<16384){continue}break}}gu=iu&4095;fu=o[(gu<<2)+mu>>2];hu=(fu<<3)+lu|0;iu=(u(o[hu>>2],iu>>>12)+gu|0)-o[hu+4>>2]|0;o[eu+48>>2]=iu;o[(ju<<2)+du>>2]=fu;nu=1;ju=ju+1|0;if((ju|0)!=(Ye|0)){continue}break}}Ye=o[eu+28>>2];if(Ye){o[eu+32>>2]=Ye;ul(Ye)}Ye=o[eu+16>>2];if(Ye){o[eu+20>>2]=Ye;ul(Ye)}Ye=o[eu>>2];if(Ye){o[eu+4>>2]=Ye;ul(Ye)}R=eu- -64|0;return nu}function eg(Ye,Ds,du){var ou=0,pu=0,qu=0,ru=0,su=0,tu=0,uu=0,vu=0;ou=R+ -64|0;R=ou;o[ou+56>>2]=0;o[ou+48>>2]=0;o[ou+52>>2]=0;o[ou+40>>2]=0;o[ou+44>>2]=0;o[ou+32>>2]=0;o[ou+36>>2]=0;o[ou+24>>2]=0;o[ou+28>>2]=0;o[ou+16>>2]=0;o[ou+20>>2]=0;o[ou+8>>2]=0;o[ou+12>>2]=0;a:{if(!bg(ou+8|0,Ds)|(o[ou+20>>2]?0:Ye)){break a}pu=cg(ou+8|0,Ds);if(!Ye|!pu){break a}Ds=o[ou+56>>2];tu=o[ou+36>>2];uu=o[ou+48>>2];vu=o[ou+24>>2];while(1){b:{if(Ds>>>0>16383){break b}pu=o[ou+52>>2];while(1){if((pu|0)<1){break b}pu=pu+ -1|0;o[ou+52>>2]=pu;Ds=p[pu+uu|0]|Ds<<8;o[ou+56>>2]=Ds;if(Ds>>>0<16384){continue}break}}pu=Ds&4095;ru=o[(pu<<2)+vu>>2];su=(ru<<3)+tu|0;Ds=(u(o[su>>2],Ds>>>12)+pu|0)-o[su+4>>2]|0;o[ou+56>>2]=Ds;o[(qu<<2)+du>>2]=ru;pu=1;qu=qu+1|0;if((qu|0)!=(Ye|0)){continue}break}}Ye=o[ou+36>>2];if(Ye){o[ou+40>>2]=Ye;ul(Ye)}Ye=o[ou+24>>2];if(Ye){o[ou+28>>2]=Ye;ul(Ye)}Ye=o[ou+8>>2];if(Ye){o[ou+12>>2]=Ye;ul(Ye)}R=ou- -64|0;return pu}function fg(Ye,Ds,du){var wu=0,xu=0,yu=0,zu=0,Au=0,Bu=0,Cu=0,Du=0,Eu=0,Fu=0;wu=R+ -64|0;R=wu;o[wu+48>>2]=0;o[wu+40>>2]=0;o[wu+44>>2]=0;o[wu+32>>2]=0;o[wu+36>>2]=0;o[wu+24>>2]=0;o[wu+28>>2]=0;o[wu+16>>2]=0;o[wu+20>>2]=0;o[wu+8>>2]=0;o[wu+12>>2]=0;o[wu>>2]=0;o[wu+4>>2]=0;a:{if(!og(wu,Ds)|(o[wu+12>>2]?0:Ye)){break a}if(!ng(1,wu+56|0,Ds)){break a}yu=o[Ds+8>>2];Eu=o[Ds+16>>2];zu=Eu;Cu=yu-zu|0;Bu=o[wu+60>>2];xu=Bu;Du=o[Ds+20>>2];zu=o[Ds+12>>2]-(Du+(yu>>>0>>0)|0)|0;yu=o[wu+56>>2];if((xu|0)==(zu|0)&yu>>>0>Cu>>>0|xu>>>0>zu>>>0){break a}Bu=Bu+Du|0;zu=Eu;Du=zu+yu|0;if(Du>>>0>>0){Bu=Bu+1|0}o[Ds+16>>2]=Du;o[Ds+20>>2]=Bu;if((yu|0)<1){break a}Cu=Eu+o[Ds>>2]|0;o[wu+40>>2]=Cu;zu=wu;b:{c:{d:{e:{f:{Ds=yu+ -1|0;xu=Cu+Ds|0;switch((p[xu|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((yu|0)<2){break a}Ds=yu+ -2|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -2|0;xu=p[xu+1|0]<<8&16128|p[xu|0];break b}if((yu|0)<3){break a}Ds=yu+ -3|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -3|0;xu=p[xu+1|0]<<8|p[xu+2|0]<<16&4128768|p[xu|0];break b}Ds=yu+ -4|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -4|0;xu=p[xu+2|0]<<16|p[xu+3|0]<<24&1056964608|p[xu+1|0]<<8|p[xu|0];break b}o[wu+44>>2]=Ds;xu=p[xu|0]&63}Au=xu+32768|0;o[zu+48>>2]=Au;Fu=Au>>>0<8388608;if(!Ye|Au>>>0>8388607){break a}Du=o[wu+28>>2];Bu=0;Eu=o[wu+16>>2];while(1){g:{if(Au>>>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];gv=o[Ds+16>>2];bv=gv;ev=av-bv|0;dv=o[_u+60>>2];$u=dv;fv=o[Ds+20>>2];bv=o[Ds+12>>2]-(fv+(av>>>0>>0)|0)|0;av=o[_u+56>>2];if(($u|0)==(bv|0)&av>>>0>ev>>>0|$u>>>0>bv>>>0){break a}dv=dv+fv|0;bv=gv;fv=bv+av|0;if(fv>>>0>>0){dv=dv+1|0}o[Ds+16>>2]=fv;o[Ds+20>>2]=dv;if((av|0)<1){break a}ev=gv+o[Ds>>2]|0;o[_u+40>>2]=ev;bv=_u;b:{c:{d:{e:{f:{Ds=av+ -1|0;$u=ev+Ds|0;switch((p[$u|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((av|0)<2){break a}Ds=av+ -2|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -2|0;$u=p[$u+1|0]<<8&16128|p[$u|0];break b}if((av|0)<3){break a}Ds=av+ -3|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -3|0;$u=p[$u+1|0]<<8|p[$u+2|0]<<16&4128768|p[$u|0];break b}Ds=av+ -4|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -4|0;$u=p[$u+2|0]<<16|p[$u+3|0]<<24&1056964608|p[$u+1|0]<<8|p[$u|0];break b}o[_u+44>>2]=Ds;$u=p[$u|0]&63}cv=$u- -1048576|0;o[bv+48>>2]=cv;hv=cv>>>0<268435456;if(!Ye|cv>>>0>268435455){break a}fv=o[_u+28>>2];dv=0;gv=o[_u+16>>2];while(1){g:{if(cv>>>0>1048575){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[_u+44>>2]=Ds;cv=p[Ds+ev|0]|cv<<8;o[_u+48>>2]=cv;if(cv>>>0<1048576){continue}break}}av=cv&262143;$u=o[(av<<2)+gv>>2];bv=($u<<3)+fv|0;cv=(u(o[bv>>2],cv>>>18)+av|0)-o[bv+4>>2]|0;o[_u+48>>2]=cv;o[(dv<<2)+du>>2]=$u;hv=1;dv=dv+1|0;if((dv|0)!=(Ye|0)){continue}break}}Ye=o[_u+28>>2];if(Ye){o[_u+32>>2]=Ye;ul(Ye)}Ye=o[_u+16>>2];if(Ye){o[_u+20>>2]=Ye;ul(Ye)}Ye=o[_u>>2];if(Ye){o[_u+4>>2]=Ye;ul(Ye)}R=_u- -64|0;return hv}function jg(Ye,Ds,du){var iv=0,jv=0,kv=0,lv=0,mv=0,nv=0,ov=0,pv=0,qv=0,rv=0;iv=R+ -64|0;R=iv;o[iv+48>>2]=0;o[iv+40>>2]=0;o[iv+44>>2]=0;o[iv+32>>2]=0;o[iv+36>>2]=0;o[iv+24>>2]=0;o[iv+28>>2]=0;o[iv+16>>2]=0;o[iv+20>>2]=0;o[iv+8>>2]=0;o[iv+12>>2]=0;o[iv>>2]=0;o[iv+4>>2]=0;a:{if(!sg(iv,Ds)|(o[iv+12>>2]?0:Ye)){break a}if(!ng(1,iv+56|0,Ds)){break a}kv=o[Ds+8>>2];qv=o[Ds+16>>2];lv=qv;ov=kv-lv|0;nv=o[iv+60>>2];jv=nv;pv=o[Ds+20>>2];lv=o[Ds+12>>2]-(pv+(kv>>>0>>0)|0)|0;kv=o[iv+56>>2];if((jv|0)==(lv|0)&kv>>>0>ov>>>0|jv>>>0>lv>>>0){break a}nv=nv+pv|0;lv=qv;pv=lv+kv|0;if(pv>>>0>>0){nv=nv+1|0}o[Ds+16>>2]=pv;o[Ds+20>>2]=nv;if((kv|0)<1){break a}ov=qv+o[Ds>>2]|0;o[iv+40>>2]=ov;lv=iv;b:{c:{d:{e:{f:{Ds=kv+ -1|0;jv=ov+Ds|0;switch((p[jv|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((kv|0)<2){break a}Ds=kv+ -2|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -2|0;jv=p[jv+1|0]<<8&16128|p[jv|0];break b}if((kv|0)<3){break a}Ds=kv+ -3|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -3|0;jv=p[jv+1|0]<<8|p[jv+2|0]<<16&4128768|p[jv|0];break b}Ds=kv+ -4|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -4|0;jv=p[jv+2|0]<<16|p[jv+3|0]<<24&1056964608|p[jv+1|0]<<8|p[jv|0];break b}o[iv+44>>2]=Ds;jv=p[jv|0]&63}mv=jv+2097152|0;o[lv+48>>2]=mv;rv=mv>>>0<536870912;if(!Ye|mv>>>0>536870911){break a}pv=o[iv+28>>2];nv=0;qv=o[iv+16>>2];while(1){g:{if(mv>>>0>2097151){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[iv+44>>2]=Ds;mv=p[Ds+ov|0]|mv<<8;o[iv+48>>2]=mv;if(mv>>>0<2097152){continue}break}}kv=mv&524287;jv=o[(kv<<2)+qv>>2];lv=(jv<<3)+pv|0;mv=(u(o[lv>>2],mv>>>19)+kv|0)-o[lv+4>>2]|0;o[iv+48>>2]=mv;o[(nv<<2)+du>>2]=jv;rv=1;nv=nv+1|0;if((nv|0)!=(Ye|0)){continue}break}}Ye=o[iv+28>>2];if(Ye){o[iv+32>>2]=Ye;ul(Ye)}Ye=o[iv+16>>2];if(Ye){o[iv+20>>2]=Ye;ul(Ye)}Ye=o[iv>>2];if(Ye){o[iv+4>>2]=Ye;ul(Ye)}R=iv- -64|0;return rv}function kg(Ye,Ds,du){var sv=0,tv=0,uv=0,vv=0,wv=0,xv=0,yv=0,zv=0,Av=0,Bv=0;sv=R+ -64|0;R=sv;o[sv+48>>2]=0;o[sv+40>>2]=0;o[sv+44>>2]=0;o[sv+32>>2]=0;o[sv+36>>2]=0;o[sv+24>>2]=0;o[sv+28>>2]=0;o[sv+16>>2]=0;o[sv+20>>2]=0;o[sv+8>>2]=0;o[sv+12>>2]=0;o[sv>>2]=0;o[sv+4>>2]=0;a:{if(!tg(sv,Ds)|(o[sv+12>>2]?0:Ye)){break a}if(!ng(1,sv+56|0,Ds)){break a}uv=o[Ds+8>>2];Av=o[Ds+16>>2];vv=Av;yv=uv-vv|0;xv=o[sv+60>>2];tv=xv;zv=o[Ds+20>>2];vv=o[Ds+12>>2]-(zv+(uv>>>0>>0)|0)|0;uv=o[sv+56>>2];if((tv|0)==(vv|0)&uv>>>0>yv>>>0|tv>>>0>vv>>>0){break a}xv=xv+zv|0;vv=Av;zv=vv+uv|0;if(zv>>>0>>0){xv=xv+1|0}o[Ds+16>>2]=zv;o[Ds+20>>2]=xv;if((uv|0)<1){break a}yv=Av+o[Ds>>2]|0;o[sv+40>>2]=yv;vv=sv;b:{c:{d:{e:{f:{Ds=uv+ -1|0;tv=yv+Ds|0;switch((p[tv|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((uv|0)<2){break a}Ds=uv+ -2|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -2|0;tv=p[tv+1|0]<<8&16128|p[tv|0];break b}if((uv|0)<3){break a}Ds=uv+ -3|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -3|0;tv=p[tv+1|0]<<8|p[tv+2|0]<<16&4128768|p[tv|0];break b}Ds=uv+ -4|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -4|0;tv=p[tv+2|0]<<16|p[tv+3|0]<<24&1056964608|p[tv+1|0]<<8|p[tv|0];break b}o[sv+44>>2]=Ds;tv=p[tv|0]&63}wv=tv+4194304|0;o[vv+48>>2]=wv;Bv=wv>>>0<1073741824;if(!Ye|wv>>>0>1073741823){break a}zv=o[sv+28>>2];xv=0;Av=o[sv+16>>2];while(1){g:{if(wv>>>0>4194303){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[sv+44>>2]=Ds;wv=p[Ds+yv|0]|wv<<8;o[sv+48>>2]=wv;if(wv>>>0<4194304){continue}break}}uv=wv&1048575;tv=o[(uv<<2)+Av>>2];vv=(tv<<3)+zv|0;wv=(u(o[vv>>2],wv>>>20)+uv|0)-o[vv+4>>2]|0;o[sv+48>>2]=wv;o[(xv<<2)+du>>2]=tv;Bv=1;xv=xv+1|0;if((xv|0)!=(Ye|0)){continue}break}}Ye=o[sv+28>>2];if(Ye){o[sv+32>>2]=Ye;ul(Ye)}Ye=o[sv+16>>2];if(Ye){o[sv+20>>2]=Ye;ul(Ye)}Ye=o[sv>>2];if(Ye){o[sv+4>>2]=Ye;ul(Ye)}R=sv- -64|0;return Bv}function lg(Ye,Ds,du){var Cv=0,Dv=0,Ev=0,Fv=0;a:{if(Ye>>>0>5){break a}Ev=o[du+16>>2];Cv=o[du+12>>2];Dv=o[du+20>>2];if((Cv|0)<(Dv|0)?1:(Cv|0)<=(Dv|0)?r[du+8>>2]>Ev>>>0?0:1:0){break a}Cv=p[Ev+o[du>>2]|0];Ev=Ev+1|0;if(Ev>>>0<1){Dv=Dv+1|0}o[du+16>>2]=Ev;o[du+20>>2]=Dv;Dv=Ds;if(Cv&128){if(!lg(Ye+1|0,Ds,du)){break a}Ye=o[Ds>>2]<<7;o[Ds>>2]=Ye;Cv=Ye|Cv&127}o[Dv>>2]=Cv;Fv=1}return Fv}function mg(Ye,Ds){var du=0,Gv=0,Hv=0,Iv=0,Jv=0,Kv=0,Lv=0;a:{b:{Hv=o[Ye+8>>2];du=Ye+4|0;Gv=o[du>>2];c:{if(Hv-Gv>>3>>>0>=Ds>>>0){while(1){o[Gv>>2]=0;o[Gv+4>>2]=0;Gv=o[du>>2]+8|0;o[du>>2]=Gv;Ds=Ds+ -1|0;if(Ds){continue}break c}}Iv=o[Ye>>2];Jv=Gv-Iv|0;du=Jv>>3;Gv=du+Ds|0;if(Gv>>>0>=536870912){break b}Lv=du<<3;Hv=Hv-Iv|0;du=Hv>>2;Hv=Hv>>3>>>0<268435455?du>>>0>>0?Gv:du:536870911;du=0;d:{if(!Hv){break d}if(Hv>>>0>=536870912){break a}Kv=Hk(Hv<<3);du=Kv}Gv=Lv+du|0;xl(Gv,0,Ds<<3);Hv=du+(Hv<<3)|0;while(1){Gv=Gv+8|0;Ds=Ds+ -1|0;if(Ds){continue}break}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if(Ye>>>0>8192){break a}if(Mv>>>0>>0){Wv=o[Tv>>2];while(1){o[Wv+(Mv<<2)>>2]=Uv;Mv=Mv+1|0;if((Ye|0)!=(Mv|0)){continue}break}}Mv=Ye;Uv=Uv+1|0;if((Vv|0)!=(Uv|0)){continue}break}return(Ye|0)==8192}return cw}function pg(Ye,Ds){var dw=0,ew=0,fw=0,gw=0,hw=0,iw=0,jw=0,kw=0,lw=0,mw=0,nw=0,ow=0,pw=0;a:{if(!q[Ds+38>>1]){break a}mw=Ye+12|0;if(!lg(1,mw,Ds)){break a}gw=o[Ye+12>>2];dw=o[Ye>>2];ew=o[Ye+4>>2]-dw>>2;b:{if(gw>>>0>ew>>>0){Da(Ye,gw-ew|0);gw=o[Ye+12>>2];break b}if(gw>>>0>=ew>>>0){break b}o[Ye+4>>2]=dw+(gw<<2)}if(!gw){pw=1;break a}nw=o[Ds+8>>2];jw=o[Ds+12>>2];while(1){fw=o[Ds+16>>2];ew=o[Ds+20>>2];dw=ew;if((jw|0)<(dw|0)?1:(jw|0)<=(dw|0)?nw>>>0>fw>>>0?0:1:0){break a}ow=o[Ds>>2];kw=p[ow+fw|0];fw=fw+1|0;if(fw>>>0<1){ew=ew+1|0}dw=Ds;iw=fw;o[dw+16>>2]=fw;o[dw+20>>2]=ew;fw=kw>>>2;c:{d:{e:{lw=kw&3;if(lw>>>0>3){dw=0;break e}dw=0;f:{switch(lw-1|0){case 2:break f;case 0:case 1:break e;default:break d}}ew=fw+hw|0;if(ew>>>0>=gw>>>0){return 0}xl(o[Ye>>2]+(hw<<2)|0,0,(kw&252)+4|0);hw=ew;break c}while(1){if((jw|0)<(ew|0)?1:(jw|0)<=(ew|0)?nw>>>0>iw>>>0?0:1:0){return 0}kw=p[iw+ow|0];iw=iw+1|0;if(iw>>>0<1){ew=ew+1|0}gw=Ds;o[gw+16>>2]=iw;o[gw+20>>2]=ew;fw=kw<<(dw<<3|6)|fw;dw=dw+1|0;if((lw|0)!=(dw|0)){continue}break}}o[o[Ye>>2]+(hw<<2)>>2]=fw}hw=hw+1|0;gw=o[mw>>2];if(hw>>>0>>0){continue}break}ew=Ye+16|0;jw=o[Ye>>2];Ds=o[Ye+16>>2];dw=o[Ye+20>>2]-Ds|0;hw=dw>>2;g:{if(hw>>>0<=32767){Da(ew,32768-hw|0);break g}if((dw|0)==131072){break g}o[Ye+20>>2]=Ds+131072}h:{dw=Ye+28|0;Ds=o[dw>>2];hw=o[Ye+32>>2]-Ds>>3;if(gw>>>0>hw>>>0){mg(dw,gw-hw|0);Ds=o[dw>>2];break h}if(gw>>>0>>0){o[Ye+32>>2]=(gw<<3)+Ds}if(gw){break h}return 0}fw=0;dw=0;while(1){Ye=jw+(fw<<2)|0;hw=o[Ye>>2];iw=(fw<<3)+Ds|0;o[iw+4>>2]=dw;o[iw>>2]=hw;Ye=o[Ye>>2]+dw|0;if(Ye>>>0>32768){break a}if(dw>>>0>>0){hw=o[ew>>2];while(1){o[hw+(dw<<2)>>2]=fw;dw=dw+1|0;if((Ye|0)!=(dw|0)){continue}break}}dw=Ye;fw=fw+1|0;if((gw|0)!=(fw|0)){continue}break}return(Ye|0)==32768}return pw}function qg(Ye,Ds){var qw=0,rw=0,sw=0,tw=0,uw=0,vw=0,ww=0,xw=0,yw=0,zw=0,Aw=0,Bw=0,Cw=0;a:{if(!q[Ds+38>>1]){break a}zw=Ye+12|0;if(!lg(1,zw,Ds)){break a}tw=o[Ye+12>>2];qw=o[Ye>>2];rw=o[Ye+4>>2]-qw>>2;b:{if(tw>>>0>rw>>>0){Da(Ye,tw-rw|0);tw=o[Ye+12>>2];break b}if(tw>>>0>=rw>>>0){break b}o[Ye+4>>2]=qw+(tw<<2)}if(!tw){Cw=1;break a}Aw=o[Ds+8>>2];ww=o[Ds+12>>2];while(1){sw=o[Ds+16>>2];rw=o[Ds+20>>2];qw=rw;if((ww|0)<(qw|0)?1:(ww|0)<=(qw|0)?Aw>>>0>sw>>>0?0:1:0){break a}Bw=o[Ds>>2];xw=p[Bw+sw|0];sw=sw+1|0;if(sw>>>0<1){rw=rw+1|0}qw=Ds;vw=sw;o[qw+16>>2]=sw;o[qw+20>>2]=rw;sw=xw>>>2;c:{d:{e:{yw=xw&3;if(yw>>>0>3){qw=0;break e}qw=0;f:{switch(yw-1|0){case 2:break f;case 0:case 1:break e;default:break d}}rw=sw+uw|0;if(rw>>>0>=tw>>>0){return 0}xl(o[Ye>>2]+(uw<<2)|0,0,(xw&252)+4|0);uw=rw;break c}while(1){if((ww|0)<(rw|0)?1:(ww|0)<=(rw|0)?Aw>>>0>vw>>>0?0:1:0){return 0}xw=p[vw+Bw|0];vw=vw+1|0;if(vw>>>0<1){rw=rw+1|0}tw=Ds;o[tw+16>>2]=vw;o[tw+20>>2]=rw;sw=xw<<(qw<<3|6)|sw;qw=qw+1|0;if((yw|0)!=(qw|0)){continue}break}}o[o[Ye>>2]+(uw<<2)>>2]=sw}uw=uw+1|0;tw=o[zw>>2];if(uw>>>0>>0){continue}break}rw=Ye+16|0;ww=o[Ye>>2];Ds=o[Ye+16>>2];qw=o[Ye+20>>2]-Ds|0;uw=qw>>2;g:{if(uw>>>0<=65535){Da(rw,65536-uw|0);break g}if((qw|0)==262144){break g}o[Ye+20>>2]=Ds+262144}h:{qw=Ye+28|0;Ds=o[qw>>2];uw=o[Ye+32>>2]-Ds>>3;if(tw>>>0>uw>>>0){mg(qw,tw-uw|0);Ds=o[qw>>2];break h}if(tw>>>0>>0){o[Ye+32>>2]=(tw<<3)+Ds}if(tw){break h}return 0}sw=0;qw=0;while(1){Ye=ww+(sw<<2)|0;uw=o[Ye>>2];vw=(sw<<3)+Ds|0;o[vw+4>>2]=qw;o[vw>>2]=uw;Ye=o[Ye>>2]+qw|0;if(Ye>>>0>65536){break a}if(qw>>>0>>0){uw=o[rw>>2];while(1){o[uw+(qw<<2)>>2]=sw;qw=qw+1|0;if((Ye|0)!=(qw|0)){continue}break}}qw=Ye;sw=sw+1|0;if((tw|0)!=(sw|0)){continue}break}return(Ye|0)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break a}if(Qw>>>0>>0){Uw=o[Rw>>2];while(1){o[Uw+(Qw<<2)>>2]=Sw;Qw=Qw+1|0;if((Ye|0)!=(Qw|0)){continue}break}}Qw=Ye;Sw=Sw+1|0;if((Tw|0)!=(Sw|0)){continue}break}return(Ye|0)==524288}return ax}function tg(Ye,Ds){var bx=0,cx=0,dx=0,ex=0,fx=0,gx=0,hx=0,ix=0,jx=0,kx=0,lx=0,mx=0,nx=0;a:{if(!q[Ds+38>>1]){break a}kx=Ye+12|0;if(!lg(1,kx,Ds)){break a}ex=o[Ye+12>>2];bx=o[Ye>>2];cx=o[Ye+4>>2]-bx>>2;b:{if(ex>>>0>cx>>>0){Da(Ye,ex-cx|0);ex=o[Ye+12>>2];break b}if(ex>>>0>=cx>>>0){break b}o[Ye+4>>2]=bx+(ex<<2)}if(!ex){nx=1;break a}lx=o[Ds+8>>2];hx=o[Ds+12>>2];while(1){dx=o[Ds+16>>2];cx=o[Ds+20>>2];bx=cx;if((hx|0)<(bx|0)?1:(hx|0)<=(bx|0)?lx>>>0>dx>>>0?0:1:0){break a}mx=o[Ds>>2];ix=p[mx+dx|0];dx=dx+1|0;if(dx>>>0<1){cx=cx+1|0}bx=Ds;gx=dx;o[bx+16>>2]=dx;o[bx+20>>2]=cx;dx=ix>>>2;c:{d:{e:{jx=ix&3;if(jx>>>0>3){bx=0;break e}bx=0;f:{switch(jx-1|0){case 2:break f;case 0:case 1:break e;default:break d}}cx=dx+fx|0;if(cx>>>0>=ex>>>0){return 0}xl(o[Ye>>2]+(fx<<2)|0,0,(ix&252)+4|0);fx=cx;break c}while(1){if((hx|0)<(cx|0)?1:(hx|0)<=(cx|0)?lx>>>0>gx>>>0?0:1:0){return 0}ix=p[gx+mx|0];gx=gx+1|0;if(gx>>>0<1){cx=cx+1|0}ex=Ds;o[ex+16>>2]=gx;o[ex+20>>2]=cx;dx=ix<<(bx<<3|6)|dx;bx=bx+1|0;if((jx|0)!=(bx|0)){continue}break}}o[o[Ye>>2]+(fx<<2)>>2]=dx}fx=fx+1|0;ex=o[kx>>2];if(fx>>>0>>0){continue}break}cx=Ye+16|0;hx=o[Ye>>2];Ds=o[Ye+16>>2];bx=o[Ye+20>>2]-Ds|0;fx=bx>>2;g:{if(fx>>>0<=1048575){Da(cx,1048576-fx|0);break g}if((bx|0)==4194304){break g}o[Ye+20>>2]=Ds+4194304}h:{bx=Ye+28|0;Ds=o[bx>>2];fx=o[Ye+32>>2]-Ds>>3;if(ex>>>0>fx>>>0){mg(bx,ex-fx|0);Ds=o[bx>>2];break h}if(ex>>>0>>0){o[Ye+32>>2]=(ex<<3)+Ds}if(ex){break h}return 0}dx=0;bx=0;while(1){Ye=hx+(dx<<2)|0;fx=o[Ye>>2];gx=(dx<<3)+Ds|0;o[gx+4>>2]=bx;o[gx>>2]=fx;Ye=o[Ye>>2]+bx|0;if(Ye>>>0>1048576){break a}if(bx>>>0>>0){fx=o[cx>>2];while(1){o[fx+(bx<<2)>>2]=dx;bx=bx+1|0;if((Ye|0)!=(bx|0)){continue}break}}bx=Ye;dx=dx+1|0;if((ex|0)!=(dx|0)){continue}break}return(Ye|0)==1048576}return nx}function ug(Ye){bi(Ye);o[Ye+44>>2]=0;o[Ye>>2]=7968}function vg(Ye){Ye=Ye|0;if(o[Ye+44>>2]){return l[o[o[Ye>>2]+48>>2]](Ye)|0}return 0}function wg(Ye){Ye=Ye|0;var Ds=0,ox=0,px=0,qx=0,rx=0;o[Ye>>2]=10052;Ds=o[Ye+20>>2];if(Ds){o[Ye+24>>2]=Ds;ul(Ds)}px=o[Ye+8>>2];if(px){Ds=px;rx=Ye+12|0;ox=o[rx>>2];qx=Ds;a:{if((Ds|0)==(ox|0)){break a}while(1){ox=ox+ -4|0;Ds=o[ox>>2];o[ox>>2]=0;if(Ds){l[o[o[Ds>>2]+4>>2]](Ds)}if((ox|0)!=(px|0)){continue}break}qx=o[Ye+8>>2]}Ds=qx;o[rx>>2]=px;ul(Ds)}return Ye|0}function xg(Ye,sx){Ye=Ye|0;sx=sx|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+20>>2]](Ye,sx)|0}function yg(Ye){Ye=Ye|0;var sx=0,tx=0,ux=0,vx=0;sx=o[Ye+32>>2];ux=o[sx+16>>2];vx=o[sx+12>>2];tx=o[sx+20>>2];if((vx|0)>(tx|0)?1:(vx|0)>=(tx|0)?r[sx+8>>2]<=ux>>>0?0:1:0){vx=p[ux+o[sx>>2]|0];ux=ux+1|0;if(ux>>>0<1){tx=tx+1|0}o[sx+16>>2]=ux;o[sx+20>>2]=tx;sx=o[Ye+48>>2];o[Ye+48>>2]=0;if(sx){l[o[o[sx>>2]+4>>2]](sx)}a:{b:{if(vx>>>0>2){break b}c:{switch(vx-1|0){default:tx=Hk(384);Gg(tx);sx=o[Ye+48>>2];o[Ye+48>>2]=tx;if(!sx){break a}l[o[o[sx>>2]+4>>2]](sx);break b;case 0:break b;case 1:break c}}tx=Hk(440);fh(tx);sx=o[Ye+48>>2];o[Ye+48>>2]=tx;if(!sx){break a}l[o[o[sx>>2]+4>>2]](sx)}tx=o[Ye+48>>2];if(tx){break a}return 0}Ye=l[o[o[tx>>2]+8>>2]](tx,Ye)|0}else{Ye=0}return Ye|0}function zg(Ye){Ye=Ye|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+24>>2]](Ye)|0}function Ag(Ye){Ye=Ye|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+28>>2]](Ye)|0}function Bg(Ye){Ye=Ye|0;var wx=0,xx=0,yx=0,zx=0,Ax=0;o[Ye>>2]=8064;wx=Ye+48|0;xx=o[wx>>2];o[wx>>2]=0;if(xx){l[o[o[xx>>2]+4>>2]](xx)}o[Ye>>2]=10052;wx=o[Ye+20>>2];if(wx){o[Ye+24>>2]=wx;ul(wx)}xx=o[Ye+8>>2];if(xx){wx=xx;Ax=Ye+12|0;yx=o[Ax>>2];zx=wx;a:{if((wx|0)==(yx|0)){break a}while(1){yx=yx+ -4|0;wx=o[yx>>2];o[yx>>2]=0;if(wx){l[o[o[wx>>2]+4>>2]](wx)}if((xx|0)!=(yx|0)){continue}break}zx=o[Ye+8>>2]}wx=zx;o[Ax>>2]=xx;ul(wx)}return Ye|0} + + + +function Cg(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;o[a>>2]=8064;b=a+48|0;c=o[b>>2];o[b>>2]=0;if(c){l[o[o[c>>2]+4>>2]](c)}o[a>>2]=10052;b=o[a+20>>2];if(b){o[a+24>>2]=b;ul(b)}c=o[a+8>>2];if(c){b=c;f=a+12|0;d=o[f>>2];e=b;a:{if((b|0)==(d|0)){break a}while(1){d=d+ -4|0;b=o[d>>2];o[d>>2]=0;if(b){l[o[o[b>>2]+4>>2]](b)}if((c|0)!=(d|0)){continue}break}e=o[a+8>>2]}b=e;o[f>>2]=c;ul(b)}ul(a)}function Dg(a){a=a|0;a=o[a+48>>2];return l[o[o[a>>2]+36>>2]](a)|0}function Eg(a,g){a=a|0;g=g|0;a=o[a+48>>2];return l[o[o[a>>2]+12>>2]](a,g)|0}function Fg(a,g){a=a|0;g=g|0;a=o[a+48>>2];return l[o[o[a>>2]+16>>2]](a,g)|0}function Gg(a){o[a>>2]=8172;xl(a+4|0,0,80);o[a+96>>2]=0;o[a+100>>2]=0;o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+104>>2]=0;o[a+108>>2]=0;o[a+112>>2]=0;o[a+116>>2]=0;o[a+120>>2]=0;o[a+124>>2]=0;o[a+128>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0;o[a+144>>2]=0;o[a+148>>2]=0;o[a+156>>2]=0;o[a+160>>2]=0;o[a+152>>2]=1065353216;o[a+164>>2]=0;o[a+168>>2]=0;o[a+172>>2]=0;o[a+176>>2]=0;o[a+180>>2]=0;o[a+184>>2]=0;o[a+188>>2]=0;o[a+192>>2]=0;o[a+196>>2]=0;o[a+200>>2]=0;o[a+204>>2]=0;o[a+208>>2]=0;o[a+212>>2]=-1;o[a+216>>2]=0;o[a+220>>2]=0;o[a+224>>2]=0;Hg(a+232|0)}function Hg(a){oi(a);oi(a+40|0);Mf(a+80|0);oi(a+96|0);o[a+144>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0}function Ig(a,g){a=a|0;g=g|0;o[a+4>>2]=g;return 1}function Jg(a,g){a=a|0;g=g|0;var h=0,i=0,j=0,k=0,m=0;h=o[a+216>>2];k=a+220|0;if((h|0)!=o[k>>2]){while(1){a:{h=o[u(j,144)+h>>2];if((h|0)<0){break a}m=o[a+4>>2];i=o[m+8>>2];if((h|0)>=o[m+12>>2]-i>>2){break a}h=o[i+(h<<2)>>2];if((l[o[o[h>>2]+24>>2]](h)|0)<1){break a}i=0;while(1){if((l[o[o[h>>2]+20>>2]](h,i)|0)!=(g|0)){i=i+1|0;if((i|0)<(l[o[o[h>>2]+24>>2]](h)|0)){continue}break a}break}a=o[a+216>>2]+u(j,144)|0;return(p[a+100|0]?a+4|0:0)|0}j=j+1|0;h=o[a+216>>2];if(j>>>0<(o[k>>2]-h|0)/144>>>0){continue}break}}return 0}function Kg(a,g){a=a|0;g=g|0;var n=0,p=0,q=0,r=0,s=0;n=o[a+216>>2];r=a+220|0;if((n|0)!=o[r>>2]){while(1){a:{n=o[u(q,144)+n>>2];if((n|0)<0){break a}s=o[a+4>>2];p=o[s+8>>2];if((n|0)>=o[s+12>>2]-p>>2){break a}n=o[p+(n<<2)>>2];if((l[o[o[n>>2]+24>>2]](n)|0)<1){break a}p=0;while(1){if((l[o[o[n>>2]+20>>2]](n,p)|0)!=(g|0)){p=p+1|0;if((p|0)<(l[o[o[n>>2]+24>>2]](n)|0)){continue}break a}break}return(o[a+216>>2]+u(q,144)|0)+104|0}q=q+1|0;n=o[a+216>>2];if(q>>>0<(o[r>>2]-n|0)/144>>>0){continue}break}}return a+184|0}function Lg(a,g){a=a|0;g=g|0;var t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0;x=R-80|0;R=x;a:{b:{H=o[a+4>>2];t=o[H+32>>2];C=o[t+8>>2];B=o[t+16>>2];F=o[t+12>>2];v=F;z=o[t+20>>2];y=z;c:{if((v|0)<(y|0)?1:(v|0)<=(y|0)?C>>>0>B>>>0?0:1:0){break c}I=o[t>>2];E=p[I+B|0];v=z;A=B+1|0;if(A>>>0<1){v=v+1|0}y=t;o[t+16>>2]=A;o[t+20>>2]=v;if((F|0)<(v|0)?1:(F|0)<=(v|0)?C>>>0>A>>>0?0:1:0){break c}J=p[A+I|0];v=z;A=B+2|0;if(A>>>0<2){v=v+1|0}o[t+16>>2]=A;o[y+20>>2]=v;G=E<<24>>24;d:{if((G|0)>=0){y=o[a+216>>2];if((o[a+220>>2]-y|0)/144>>>0<=E>>>0){break c}y=y+u(E,144)|0;if(o[y>>2]<=-1){break d}break c}if(o[a+212>>2]>-1){break c}y=a+212|0}o[y>>2]=g;y=0;w=q[H+36>>1];if((w<<24|w<<8&16711680)>>>16>>>0>=258){w=0;if((F|0)<(v|0)?1:(F|0)<=(v|0)?C>>>0>A>>>0?0:1:0){break c}y=p[A+I|0];v=B+3|0;if(v>>>0<3){z=z+1|0}o[t+16>>2]=v;o[t+20>>2]=z}e:{f:{g:{if(!J){if((G|0)<=-1){t=a+184|0}else{t=o[a+216>>2]+u(E,144)|0;m[t+100|0]=0;t=t+104|0}w=0;if(y>>>0>1){break c}if(!(y-1)){break g}Mg(x+16|0,a,t);break f}w=0;if(y|(G|0)<0){break c}z=o[H+44>>2];w=o[a+216>>2];t=Hk(80);o[t>>2]=9636;o[t+76>>2]=0;o[t+68>>2]=z;v=t+12|0;o[v>>2]=0;o[v+4>>2]=0;o[t+4>>2]=0;y=t+20|0;o[y>>2]=0;o[y+4>>2]=0;F=t+28|0;B=F;o[B>>2]=0;o[B+4>>2]=0;o[t+36>>2]=0;o[t+40>>2]=0;B=t+44|0;o[B>>2]=0;o[B+4>>2]=0;o[t+52>>2]=0;w=w+u(E,144)|0;E=w+104|0;o[t+72>>2]=E;o[t- -64>>2]=0;H=t+56|0;C=H;o[C>>2]=0;o[C+4>>2]=0;o[t+8>>2]=8512;C=x+56|0;o[C>>2]=0;o[C+4>>2]=0;o[x+48>>2]=0;o[x+52>>2]=0;I=x+32|0;A=I;o[A>>2]=0;o[A+4>>2]=0;o[x+72>>2]=0;o[x+40>>2]=0;o[x+44>>2]=0;o[x+24>>2]=0;o[x+28>>2]=0;o[x+64>>2]=0;o[x+68>>2]=0;o[x+16>>2]=8512;A=w+4|0;o[x+20>>2]=A;w=o[w+68>>2];G=o[w>>2];w=o[w+4>>2];m[x+79|0]=0;$a(x+40|0,(w-G>>2>>>0)/3|0,x+79|0);w=o[x+20>>2];G=o[w+56>>2];w=o[w+52>>2];m[x+79|0]=0;$a(x+52|0,G-w>>2,x+79|0);o[x+36>>2]=t;o[I>>2]=z;z=x+28|0;o[z>>2]=E;o[x+24>>2]=A;o[F>>2]=t;w=o[z+4>>2];o[y>>2]=o[z>>2];o[y+4>>2]=w;z=o[x+24>>2];o[v>>2]=o[x+20>>2];o[v+4>>2]=z;z=t;w=o[x+44>>2];if(w){v=t+32|0;h:{if(w>>>0<=o[t+40>>2]<<5>>>0){y=w+ -1>>>5;w=o[v>>2];break h}v=o[v>>2];if(v){ul(v);o[t+40>>2]=0;o[t+32>>2]=0;o[t+36>>2]=0;w=o[x+44>>2]}if((w|0)<=-1){break b}y=w+ -1>>>5;v=y+1|0;w=Hk(v<<2);o[t+40>>2]=v;o[t+36>>2]=0;o[t+32>>2]=w}yl(w,o[x+40>>2],(y<<2)+4|0);v=o[x+44>>2]}else{v=0}o[z+36>>2]=v;z=t;w=o[C>>2];if(w){i:{if(w>>>0<=o[t+52>>2]<<5>>>0){v=w+ -1>>>5;w=o[B>>2];break i}v=o[B>>2];if(v){ul(v);o[t+52>>2]=0;o[t+44>>2]=0;o[t+48>>2]=0;w=o[x+56>>2]}if((w|0)<=-1){break a}v=w+ -1>>>5;y=v+1|0;w=Hk(y<<2);o[t+52>>2]=y;o[t+48>>2]=0;o[t+44>>2]=w}yl(w,o[x+52>>2],(v<<2)+4|0);v=o[x+56>>2]}else{v=0}o[z+48>>2]=v;td(H,o[x+64>>2],o[x+68>>2]);o[x+16>>2]=8512;z=o[x+64>>2];if(z){o[x+68>>2]=z;ul(z)}o[x+16>>2]=8764;z=o[x+52>>2];if(z){ul(z)}z=o[x+40>>2];if(!z){break e}ul(z);break e}Ng(x+16|0,a,t)}t=o[x+16>>2];if(!t){break c}}z=Hk(64);o[x+8>>2]=t;Qd(z,x+8|0);t=o[x+8>>2];o[x+8>>2]=0;if(t){l[o[o[t>>2]+4>>2]](t)}if((g|0)>=0){a=o[a+4>>2];w=a+8|0;t=o[a+12>>2];E=o[a+8>>2];v=t-E>>2;j:{if((v|0)>(g|0)){break j}y=g+1|0;if(v>>>0<=g>>>0){Og(w,y-v|0);break j}if(y>>>0>=v>>>0){break j}y=E+(y<<2)|0;if((y|0)!=(t|0)){while(1){t=t+ -4|0;v=o[t>>2];o[t>>2]=0;if(v){l[o[o[v>>2]+4>>2]](v)}if((t|0)!=(y|0)){continue}break}}o[a+12>>2]=y}g=o[w>>2]+(g<<2)|0;a=o[g>>2];o[g>>2]=z;w=1;if(!a){break c}l[o[o[a>>2]+4>>2]](a);break c}l[o[o[z>>2]+4>>2]](z);w=0}R=x+80|0;return w|0}Yk();D()}Yk();D()}function Mg(a,g,l){var u=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,S=0,T=0,U=0,V=0;u=R+ -64|0;R=u;L=o[o[g+4>>2]+44>>2];K=Hk(80);o[K>>2]=9344;o[K+76>>2]=0;o[K+72>>2]=l;o[K+68>>2]=L;M=K+12|0;o[M>>2]=0;o[M+4>>2]=0;o[K+4>>2]=0;Q=K+20|0;N=Q;o[N>>2]=0;o[N+4>>2]=0;T=K+28|0;N=T;o[N>>2]=0;o[N+4>>2]=0;o[K+36>>2]=0;o[K+40>>2]=0;N=K+44|0;o[N>>2]=0;o[N+4>>2]=0;o[K+52>>2]=0;o[K- -64>>2]=0;U=K+56|0;P=U;o[P>>2]=0;o[P+4>>2]=0;o[K+8>>2]=9508;g=o[g+8>>2];P=u+40|0;o[P>>2]=0;o[P+4>>2]=0;o[u+32>>2]=0;o[u+36>>2]=0;V=u+16|0;O=V;o[O>>2]=0;o[O+4>>2]=0;o[u+56>>2]=0;o[u+24>>2]=0;o[u+28>>2]=0;o[u+8>>2]=0;o[u+12>>2]=0;o[u+48>>2]=0;o[u+52>>2]=0;o[u>>2]=9508;o[u+4>>2]=g;O=o[g>>2];S=o[g+4>>2];m[u+63|0]=0;$a(u+24|0,(S-O>>2>>>0)/3|0,u+63|0);O=o[u+4>>2];S=o[O+28>>2];O=o[O+24>>2];m[u+63|0]=0;$a(u+36|0,S-O>>2,u+63|0);o[u+20>>2]=K;o[V>>2]=L;L=u+12|0;o[L>>2]=l;o[u+8>>2]=g;o[T>>2]=K;g=o[L+4>>2];o[Q>>2]=o[L>>2];o[Q+4>>2]=g;g=o[u+8>>2];o[M>>2]=o[u+4>>2];o[M+4>>2]=g;a:{b:{l=K;g=o[u+28>>2];if(g){L=K+32|0;c:{if(g>>>0<=o[K+40>>2]<<5>>>0){M=g+ -1>>>5;g=o[L>>2];break c}L=o[L>>2];if(L){ul(L);o[K+40>>2]=0;o[K+32>>2]=0;o[K+36>>2]=0;g=o[u+28>>2]}if((g|0)<=-1){break b}M=g+ -1>>>5;L=M+1|0;g=Hk(L<<2);o[K+40>>2]=L;o[K+36>>2]=0;o[K+32>>2]=g}yl(g,o[u+24>>2],(M<<2)+4|0);g=o[u+28>>2]}else{g=0}o[l+36>>2]=g;Q=K;g=o[P>>2];if(g){d:{if(g>>>0<=o[K+52>>2]<<5>>>0){l=g+ -1>>>5;g=o[N>>2];break d}l=o[N>>2];if(l){ul(l);o[K+52>>2]=0;o[K+44>>2]=0;o[K+48>>2]=0;g=o[u+40>>2]}if((g|0)<=-1){break a}l=g+ -1>>>5;M=l+1|0;g=Hk(M<<2);o[K+52>>2]=M;o[K+48>>2]=0;o[K+44>>2]=g}yl(g,o[u+36>>2],(l<<2)+4|0);g=o[u+40>>2]}else{g=0}o[Q+48>>2]=g;td(U,o[u+48>>2],o[u+52>>2]);o[a>>2]=K;o[u>>2]=9508;a=o[u+48>>2];if(a){o[u+52>>2]=a;ul(a)}o[u>>2]=9324;a=o[u+36>>2];if(a){ul(a)}a=o[u+24>>2];if(a){ul(a)}R=u- -64|0;return}Yk();D()}Yk();D()}function Ng(a,g,l){var D=0,W=0,X=0,Y=0,Z=0,_=0,$=0;D=R-112|0;R=D;$=o[o[g+4>>2]+44>>2];W=Hk(120);o[W>>2]=8876;o[W+116>>2]=0;o[W+112>>2]=l;o[W+108>>2]=$;o[W+12>>2]=0;o[W+16>>2]=0;o[W+4>>2]=0;o[W+20>>2]=0;o[W+24>>2]=0;o[W+28>>2]=0;o[W+32>>2]=0;o[W+36>>2]=0;o[W+40>>2]=0;o[W+44>>2]=0;o[W+48>>2]=0;o[W+52>>2]=0;o[W+56>>2]=0;o[W+60>>2]=0;o[W+8>>2]=9088;Z=W- -64|0;o[Z>>2]=0;o[Z+4>>2]=0;o[W+72>>2]=0;o[W+76>>2]=0;o[W+80>>2]=0;o[W+84>>2]=0;o[W+88>>2]=0;o[W+104>>2]=0;o[W+96>>2]=0;o[W+100>>2]=0;g=o[g+8>>2];o[D+48>>2]=0;o[D+52>>2]=0;o[D+40>>2]=0;o[D+44>>2]=0;Z=D+24|0;X=Z;o[X>>2]=0;o[X+4>>2]=0;X=D- -64|0;o[X>>2]=0;o[X+4>>2]=0;o[D+72>>2]=0;o[D+76>>2]=0;X=D+80|0;o[X>>2]=0;o[X+4>>2]=0;o[D+88>>2]=0;o[D+104>>2]=0;o[D+32>>2]=0;o[D+36>>2]=0;o[D+16>>2]=0;o[D+20>>2]=0;o[D+56>>2]=0;o[D+60>>2]=0;o[D+8>>2]=9088;o[D+96>>2]=0;o[D+100>>2]=0;o[D+12>>2]=g;Y=o[g>>2];_=o[g+4>>2];m[D+111|0]=0;$a(D+32|0,(_-Y>>2>>>0)/3|0,D+111|0);Y=o[D+12>>2];_=o[Y+28>>2];Y=o[Y+24>>2];m[D+111|0]=0;$a(D+44|0,_-Y>>2,D+111|0);o[D+28>>2]=W;o[Z>>2]=$;o[D+20>>2]=l;o[D+16>>2]=g;Pg(W,D+8|0);o[a>>2]=W;o[D+8>>2]=9088;a=o[D+96>>2];if(a){o[D+100>>2]=a;ul(a)}a=o[X>>2];if(a){o[D+84>>2]=a;ul(a)}a=o[D+68>>2];if(a){o[D+72>>2]=a;ul(a)}a=o[D+56>>2];if(a){o[D+60>>2]=a;ul(a)}o[D+8>>2]=9324;a=o[D+44>>2];if(a){ul(a)}a=o[D+32>>2];if(a){ul(a)}R=D+112|0}function Og(a,g){var R=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;aa=o[a+8>>2];ba=a+4|0;R=o[ba>>2];if(aa-R>>2>>>0>=g>>>0){a=g<<2;ga=ba,ha=xl(R,0,a)+a|0,o[ga>>2]=ha;return}a:{ba=o[a>>2];ca=R-ba>>2;da=ca+g|0;if(da>>>0<1073741824){ca=ca<<2;aa=aa-ba|0;fa=aa>>1;aa=aa>>2>>>0<536870911?fa>>>0>>0?da:fa:1073741823;if(aa){if(aa>>>0>=1073741824){break a}ea=Hk(aa<<2)}ca=ca+ea|0;xl(ca,0,g<<2);g=(da<<2)+ea|0;da=(aa<<2)+ea|0;if((R|0)!=(ba|0)){while(1){R=R+ -4|0;aa=o[R>>2];o[R>>2]=0;ca=ca+ -4|0;o[ca>>2]=aa;if((R|0)!=(ba|0)){continue}break}ba=o[a>>2];R=o[a+4>>2]}o[a>>2]=ca;o[a+8>>2]=da;o[a+4>>2]=g;if((R|0)!=(ba|0)){while(1){R=R+ -4|0;a=o[R>>2];o[R>>2]=0;if(a){l[o[o[a>>2]+4>>2]](a)}if((R|0)!=(ba|0)){continue}break}}if(ba){ul(ba)}return}Yk();D()}_a(8776);D()}function Pg(a,g){var l=0;l=o[g+8>>2];o[a+12>>2]=o[g+4>>2];o[a+16>>2]=l;o[a+28>>2]=o[g+20>>2];l=o[g+16>>2];o[a+20>>2]=o[g+12>>2];o[a+24>>2]=l;uh(a+32|0,g+24|0);uh(a+44|0,g+36|0);if((a+8|0)==(g|0)){o[a+92>>2]=o[g+84>>2];return}td(a+56|0,o[g+48>>2],o[g+52>>2]);td(a+68|0,o[g+60>>2],o[g- -64>>2]);td(a+80|0,o[g+72>>2],o[g+76>>2]);o[a+92>>2]=o[g+84>>2];fd(a+96|0,o[g+88>>2],o[g+92>>2])}function Qg(a,g,ia){a=a|0;g=g|0;ia=ia|0;var ja=0,ka=0;ja=R-16|0;R=ja;o[a+4>>2]=g;g=o[g+64>>2];ka=o[g+4>>2];g=o[g>>2];m[ja+15|0]=0;$a(a+24|0,(ka-g>>2>>>0)/3|0,ja+15|0);g=o[a+4>>2];ka=o[g+56>>2];g=o[g+52>>2];m[ja+14|0]=0;$a(a+36|0,ka-g>>2,ja+14|0);g=o[ia+12>>2];o[a+16>>2]=o[ia+8>>2];o[a+20>>2]=g;g=o[ia+4>>2];o[a+8>>2]=o[ia>>2];o[a+12>>2]=g;R=ja+16|0}function Rg(a){a=a|0;var g=0;o[a>>2]=8512;g=o[a+48>>2];if(g){o[a+52>>2]=g;ul(g)}o[a>>2]=8764;g=o[a+36>>2];if(g){ul(g)}g=o[a+24>>2];if(g){ul(g)}return a|0}function Sg(a){a=a|0;var ia=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,va=0,wa=0,xa=0,ya=0;qa=R+ -64|0;R=qa;o[a+132>>2]=0;if(o[a+148>>2]){ma=a+144|0;la=o[ma>>2];if(la){while(1){ia=o[la>>2];ul(la);la=ia;if(ia){continue}break}}o[ma>>2]=0;ia=o[a+140>>2];if(ia){ma=a+136|0;la=0;while(1){o[o[ma>>2]+(la<<2)>>2]=0;la=la+1|0;if((ia|0)!=(la|0)){continue}break}}o[a+148>>2]=0}a:{if(!Tg(1,qa+52|0,o[o[a+4>>2]+32>>2])){break a}o[a+156>>2]=o[qa+52>>2];if(!Tg(1,qa+48|0,o[o[a+4>>2]+32>>2])){break a}na=o[qa+48>>2];if(na>>>0>1431655765|r[a+156>>2]>u(na,3)>>>0){break a}la=o[o[a+4>>2]+32>>2];ra=o[la+16>>2];ma=o[la+12>>2];ia=o[la+20>>2];if((ma|0)<(ia|0)?1:(ma|0)<=(ia|0)?r[la+8>>2]>ra>>>0?0:1:0){break a}pa=p[ra+o[la>>2]|0];ra=ra+1|0;if(ra>>>0<1){ia=ia+1|0}o[la+16>>2]=ra;o[la+20>>2]=ia;if(!Tg(1,qa+44|0,la)){break a}ta=o[qa+44>>2];if(na>>>0>>0|na>>>0>ta+((ta>>>0)/3|0)>>>0){break a}if(!Tg(1,qa+40|0,o[o[a+4>>2]+32>>2])){break a}sa=o[qa+40>>2];if(sa>>>0>ta>>>0){break a}o[a+28>>2]=o[a+24>>2];ia=Hk(88);zi(ia);la=o[a+8>>2];o[a+8>>2]=ia;ra=a+8|0;if(la){ua(ra,la);if(!o[ra>>2]){break a}}la=o[a+160>>2];o[a+164>>2]=la;b:{c:{d:{e:{f:{if(o[a+168>>2]-la>>2>>>0>=na>>>0){break f}if(na>>>0>=1073741824){break e}ma=na<<2;ia=Hk(ma);o[a+164>>2]=ia;o[a+160>>2]=ia;o[a+168>>2]=ia+ma;if(!la){break f}ul(la)}la=o[a+172>>2];o[a+176>>2]=la;g:{if(o[a+180>>2]-la>>2>>>0>=na>>>0){break g}if(na>>>0>=1073741824){break d}ma=na<<2;ia=Hk(ma);o[a+176>>2]=ia;o[a+172>>2]=ia;o[a+180>>2]=ia+ma;if(!la){break g}ul(la)}o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+40>>2]=o[a+36>>2];o[a- -64>>2]=0;o[a+52>>2]=o[a+48>>2];o[a+76>>2]=o[a+72>>2];va=a+216|0;ia=o[a+220>>2];la=o[a+216>>2];if((ia|0)==(la|0)){break c}while(1){ma=o[ia+ -12>>2];if(ma){o[ia+ -8>>2]=ma;ul(ma)}ma=o[ia+ -28>>2];if(ma){o[ia+ -24>>2]=ma;ul(ma)}ma=ia+ -144|0;oa=o[ia+ -40>>2];if(oa){o[ia+ -36>>2]=oa;ul(oa)}Ug(ia+ -140|0);ia=ma;if((la|0)!=(ia|0)){continue}break}ia=o[va>>2];break b}_a(8776);D()}_a(8776);D()}ia=la}o[a+220>>2]=la;ma=(la-ia|0)/144|0;h:{if(ma>>>0>>0){Vg(va,pa-ma|0);break h}if(ma>>>0<=pa>>>0){break h}ma=ia+u(pa,144)|0;if((ma|0)!=(la|0)){while(1){ia=o[la+ -12>>2];if(ia){o[la+ -8>>2]=ia;ul(ia)}ia=o[la+ -28>>2];if(ia){o[la+ -24>>2]=ia;ul(ia)}ia=la+ -144|0;oa=o[la+ -40>>2];if(oa){o[la+ -36>>2]=oa;ul(oa)}Ug(la+ -140|0);la=ia;if((ia|0)!=(ma|0)){continue}break}}o[a+220>>2]=ma}oa=0;if(!Ji(o[a+8>>2],na,sa+o[a+156>>2]|0)){break a}la=o[a+156>>2];m[qa|0]=1;$a(a+120|0,la+sa|0,qa);if((Wg(a,o[o[a+4>>2]+32>>2])|0)==-1){break a}o[a+376>>2]=a;na=a+232|0;la=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];oa=o[la>>2]+o[la+16>>2]|0;ma=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];la=o[ma+8>>2];ia=o[ma+16>>2];pi(na,oa,la-ia|0,q[o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);o[a+372>>2]=pa;la=oi(qa);ia=o[a+268>>2];o[a+304>>2]=o[a+264>>2];o[a+308>>2]=ia;ia=o[a+260>>2];o[a+296>>2]=o[a+256>>2];o[a+300>>2]=ia;ma=a+248|0;ia=o[ma+4>>2];o[a+288>>2]=o[ma>>2];o[a+292>>2]=ia;oa=a+240|0;ia=oa;pa=o[ia+4>>2];o[a+280>>2]=o[ia>>2];o[a+284>>2]=pa;ia=o[a+236>>2];pa=a+272|0;o[pa>>2]=o[a+232>>2];o[pa+4>>2]=ia;i:{j:{if(qi(pa,1,qa+56|0)){ia=o[pa+4>>2];o[na>>2]=o[pa>>2];o[na+4>>2]=ia;ia=o[pa+36>>2];o[na+32>>2]=o[pa+32>>2];o[na+36>>2]=ia;ia=o[pa+28>>2];o[na+24>>2]=o[pa+24>>2];o[na+28>>2]=ia;ia=o[pa+20>>2];o[na+16>>2]=o[pa+16>>2];o[na+20>>2]=ia;ia=o[pa+12>>2];o[na+8>>2]=o[pa+8>>2];o[na+12>>2]=ia;sa=o[oa>>2];ia=o[ma>>2];xa=sa-ia|0;wa=o[qa+60>>2];ya=o[oa+4>>2];oa=o[ma+4>>2];ma=ya-(oa+(sa>>>0>>0)|0)|0;sa=o[qa+56>>2];if((wa|0)==(ma|0)&sa>>>0<=xa>>>0|wa>>>0>>0){break j}}oa=0;break i}oa=oa+wa|0;sa=ia+sa|0;if(sa>>>0>>0){oa=oa+1|0}o[a+248>>2]=sa;o[a+252>>2]=oa;oa=0;if(!Nf(a+312|0,na)){break i}if(!Xg(na)){break i}ia=o[na+36>>2];o[qa+32>>2]=o[na+32>>2];o[qa+36>>2]=ia;ia=o[na+28>>2];o[qa+24>>2]=o[na+24>>2];o[qa+28>>2]=ia;ia=o[na+20>>2];o[qa+16>>2]=o[na+16>>2];o[qa+20>>2]=ia;ia=o[na+12>>2];o[qa+8>>2]=o[na+8>>2];o[qa+12>>2]=ia;ia=o[na+4>>2];o[qa>>2]=o[na>>2];o[qa+4>>2]=ia;ta=Yg(a,ta);if((ta|0)==-1){break i}ma=o[o[a+4>>2]+32>>2];ia=o[la+16>>2];na=ia+o[la>>2]|0;la=o[la+8>>2];pi(ma,na,la-ia|0,q[ma+38>>1]);k:{if(o[a+220>>2]==o[a+216>>2]){break k}la=o[ra>>2];if(o[la+4>>2]==o[la>>2]){break k}ia=0;while(1){if(Zg(a,ia)){ia=ia+3|0;la=o[ra>>2];if(ia>>>0>2]-o[la>>2]>>2>>>0){continue}break k}break}break i}if(p[a+308|0]){si(pa)}la=o[a+216>>2];pa=a+220|0;if((la|0)!=o[pa>>2]){ma=0;while(1){na=u(ma,144);Ui((na+la|0)+4|0,o[ra>>2]);ia=o[va>>2];oa=na+ia|0;la=o[oa+132>>2];oa=o[oa+136>>2];if((la|0)!=(oa|0)){while(1){Wi((ia+na|0)+4|0,o[la>>2]);ia=o[va>>2];la=la+4|0;if((oa|0)!=(la|0)){continue}break}}Vi((ia+na|0)+4|0);ma=ma+1|0;la=o[a+216>>2];if(ma>>>0<(o[pa>>2]-la|0)/144>>>0){continue}break}}la=o[a+8>>2];_g(a+184|0,o[la+28>>2]-o[la+24>>2]>>2);ia=o[a+216>>2];if((ia|0)!=o[pa>>2]){la=0;na=a+220|0;while(1){ia=u(la,144)+ia|0;ma=o[ia+60>>2]-o[ia+56>>2]>>2;pa=ia+104|0;ia=o[ra>>2];ia=o[ia+28>>2]-o[ia+24>>2]>>2;_g(pa,(ma|0)<(ia|0)?ia:ma);la=la+1|0;ia=o[a+216>>2];if(la>>>0<(o[na>>2]-ia|0)/144>>>0){continue}break}}oa=$g(a,ta)}}R=qa- -64|0;return oa|0}function Tg(a,ua,za){var Aa=0,Ba=0,Ca=0,Da=0;a:{if(a>>>0>5){break a}Ca=o[za+16>>2];Aa=o[za+12>>2];Ba=o[za+20>>2];if((Aa|0)<(Ba|0)?1:(Aa|0)<=(Ba|0)?r[za+8>>2]>Ca>>>0?0:1:0){break a}Aa=p[Ca+o[za>>2]|0];Ca=Ca+1|0;if(Ca>>>0<1){Ba=Ba+1|0}o[za+16>>2]=Ca;o[za+20>>2]=Ba;Ba=ua;if(Aa&128){if(!Tg(a+1|0,ua,za)){break a}a=o[ua>>2]<<7;o[ua>>2]=a;Aa=a|Aa&127}o[Ba>>2]=Aa;Da=1}return Da}function Ug(a){var ua=0;ua=o[a+84>>2];if(ua){o[a+88>>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=0;o[Ea+136>>2]=0;o[Ea+140>>2]=0;Ea=o[Fa+16>>2]+144|0;o[Fa+16>>2]=Ea;za=za+ -1|0;if(za){continue}break}za=o[a+4>>2];Ga=o[a>>2];d:{if((za|0)==(Ga|0)){Ha=o[Fa+12>>2];break d}Ha=o[Fa+12>>2];while(1){za=za+ -144|0;Ha=Qh(Ha+ -144|0,za);if((za|0)!=(Ga|0)){continue}break}o[Fa+12>>2]=Ha;za=o[a+4>>2];Ga=o[a>>2]}o[a>>2]=Ha;o[Fa+12>>2]=Ga;o[a+4>>2]=Ea;o[Fa+16>>2]=za;a=a+8|0;za=o[a>>2];o[a>>2]=o[Fa+20>>2];o[Fa+8>>2]=Ga;o[Fa+20>>2]=za;Rh(Fa+8|0)}R=Fa+32|0;return}Yk();D()}_a(8776);D()}function Wg(a,za){var Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0;Ma=R-32|0;R=Ma;Pa=-1;a:{if(!Tg(1,Ma+28|0,za)){break a}Qa=o[Ma+28>>2];if(Qa){La=o[a+8>>2];if(Qa>>>0>(o[La+4>>2]-o[La>>2]>>2>>>0)/3>>>0){break a}Ta=a+36|0;Ra=a+44|0;La=a+40|0;while(1){Tg(1,Ma+12|0,za);o[Ma+20>>2]=o[Ma+12>>2]+Oa;Tg(1,Ma+12|0,za);Oa=o[Ma+20>>2];Ka=o[Ma+12>>2];if(Oa>>>0>>0){break a}o[Ma+16>>2]=Oa-Ka;Ka=o[La>>2];b:{if((Ka|0)!=o[Ra>>2]){Sa=o[Ma+20>>2];o[Ka>>2]=o[Ma+16>>2];o[Ka+4>>2]=Sa;o[Ka+8>>2]=o[Ma+24>>2];o[La>>2]=o[La>>2]+12;break b}ah(Ta,Ma+16|0)}Na=Na+1|0;if((Qa|0)!=(Na|0)){continue}break}Oa=0;qi(za,0,0);Ta=a+36|0;while(1){La=p[za+36|0];Ka=q[o[a+4>>2]+36>>1];c:{if((Ka<<24|Ka<<8&16711680)>>>16>>>0<=513){if(!La){break c}Na=0;La=o[za+32>>2];Pa=La>>>3;Ra=o[za+24>>2];Ka=Pa+Ra|0;Sa=o[za+28>>2];d:{if(Ka>>>0>=Sa>>>0){Ka=La;break d}Na=p[Ka|0];Ka=La+1|0;o[za+32>>2]=Ka;Pa=Ka>>>3;Na=Na>>>(La&7)&1}if(Pa+Ra>>>0>=Sa>>>0){break c}o[za+32>>2]=Ka+1;break c}if(!La){break c}Na=0;La=o[za+32>>2];Ka=o[za+24>>2]+(La>>>3)|0;if(Ka>>>0>=r[za+28>>2]){break c}Ka=p[Ka|0];o[za+32>>2]=La+1;Na=Ka>>>(La&7)&1}La=o[Ta>>2]+u(Oa,12)|0;m[La+8|0]=p[La+8|0]&254|Na&1;Oa=Oa+1|0;if((Qa|0)!=(Oa|0)){continue}break}si(za)}Pa=o[za+16>>2]}R=Ma+32|0;return Pa}function Xg(a){var za=0,Ua=0,Va=0,Wa=0;Ua=1;Va=o[a+140>>2];a:{if((Va|0)<1){break a}za=Va<<4;Ua=Hk((Va|0)!=(Va&268435455)?-1:za|4);o[Ua>>2]=Va;Ua=Ua+4|0;Va=Ua+za|0;za=Ua;while(1){za=Mf(za)+16|0;if((Va|0)!=(za|0)){continue}break}Wa=o[a+136>>2];o[a+136>>2]=Ua;if(Wa){Va=Wa+ -4|0;Ua=o[Va>>2];if(Ua){za=Wa+(Ua<<4)|0;while(1){za=za+ -16|0;if((Wa|0)!=(za|0)){continue}break}}ul(Va)}Ua=1;if(o[a+140>>2]<1){break a}Ua=0;za=0;while(1){if(!Nf(o[a+136>>2]+(za<<4)|0,a)){break a}za=za+1|0;if((za|0)>2]){continue}break}Ua=1}return Ua}function Yg(a,Xa){var Ya=0,Za=0,_a=0,$a=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,mb=0,nb=0,ob=0,pb=0,qb=0,rb=0,sb=0,tb=0;$a=R-96|0;R=$a;o[$a+72>>2]=0;o[$a+64>>2]=0;o[$a+68>>2]=0;o[$a+48>>2]=0;o[$a+52>>2]=0;o[$a+40>>2]=0;o[$a+44>>2]=0;o[$a+56>>2]=1065353216;o[$a+32>>2]=0;o[$a+24>>2]=0;o[$a+28>>2]=0;rb=o[a+124>>2];a:{b:{c:{d:{if((Xa|0)>=1){qb=a+8|0;nb=o[a+216>>2]!=o[a+220>>2];ob=a+40|0;while(1){e:{f:{g:{h:{i:{j:{k:{if(!p[a+308|0]){break k}l:{m:{eb=o[a+296>>2];gb=o[a+304>>2];Ya=eb+(gb>>>3)|0;cb=o[a+300>>2];if(Ya>>>0>=cb>>>0){break m}Ya=p[Ya|0];Za=gb+1|0;o[a+304>>2]=Za;if(!(Ya>>>(gb&7)&1)){break m}Ya=Za>>>3;_a=eb+Ya|0;n:{if(_a>>>0>=cb>>>0){_a=Za;Za=0;break n}db=p[_a|0];_a=gb+2|0;o[a+304>>2]=_a;Ya=_a>>>3;Za=db>>>(Za&7)&1}Ya=Ya+eb|0;if(Ya>>>0>>0){Ya=p[Ya|0];o[a+304>>2]=_a+1;Ya=Ya>>>(_a&7)<<1&2}else{Ya=0}Ya=(Za|Ya)<<1|1;switch(Ya+ -2|0){case 0:case 2:case 4:break h;case 5:break j;case 1:case 3:break l;default:break k}}Za=o[$a+68>>2];if((Za|0)==o[$a+64>>2]){break d}eb=-1;ib=o[qb>>2];cb=o[ib+24>>2];_a=cb;db=Za+ -4|0;lb=o[db>>2];Ya=-1;o:{if((lb|0)==-1){break o}Za=lb+1|0;Za=(Za>>>0)%3|0?Za:lb+ -2|0;Ya=-1;if((Za|0)==-1){break o}Ya=o[o[ib>>2]+(Za<<2)>>2]}_a=o[_a+(Ya<<2)>>2];if((_a|0)!=-1){Za=_a+1|0;eb=(Za>>>0)%3|0?Za:_a+ -2|0}_a=o[ib+12>>2];jb=u(bb,3);Za=jb+1|0;o[_a+(lb<<2)>>2]=Za;Za=Za<<2;o[Za+_a>>2]=lb;hb=jb+2|0;o[_a+(eb<<2)>>2]=hb;gb=hb<<2;o[gb+_a>>2]=eb;kb=o[ib>>2];o[kb+(jb<<2)>>2]=Ya;_a=Za+kb|0;fb=-1;p:{if((eb|0)==-1){break p}Za=eb+1|0;Za=(Za>>>0)%3|0?Za:eb+ -2|0;fb=-1;if((Za|0)==-1){break p}fb=o[kb+(Za<<2)>>2]}o[_a>>2]=fb;q:{r:{if((lb|0)!=-1){Za=lb+((lb>>>0)%3|0?-1:2)|0;if((Za|0)!=-1){break r}}o[gb+kb>>2]=-1;break q}Za=o[kb+(Za<<2)>>2];o[gb+kb>>2]=Za;if((Za|0)==-1){break q}o[cb+(Za<<2)>>2]=hb}_a=o[a+120>>2]+(Ya>>>3&536870908)|0;Za=o[_a>>2];sb=_a,tb=Zl(Ya)&Za,o[sb>>2]=tb;o[db>>2]=jb;break e}_a=o[$a+68>>2];if((_a|0)==o[$a+64>>2]){break d}gb=o[qb>>2];Za=o[gb+12>>2];hb=u(bb,3);eb=(Ya|0)==5;cb=hb+(eb?2:1)|0;Ya=cb<<2;kb=o[_a+ -4>>2];o[Za+Ya>>2]=kb;o[Za+(kb<<2)>>2]=cb;db=gb+24|0;_a=gb+28|0;Za=o[_a>>2];s:{if((Za|0)!=o[gb+32>>2]){o[Za>>2]=-1;ib=Za+4|0;o[_a>>2]=ib;break s}bh(db,8212);ib=o[_a>>2]}_a=-1;Za=o[qb>>2];gb=o[Za+24>>2];if(o[Za+28>>2]-gb>>2>(rb|0)){break c}_a=hb+2|0;jb=o[Za>>2];fb=jb+Ya|0;Za=ib-o[db>>2]|0;Ya=(Za>>2)+ -1|0;o[fb>>2]=Ya;if(Za){o[gb+(Ya<<2)>>2]=cb}_a=eb?hb:_a;Za=jb+(eb+hb<<2)|0;t:{u:{v:{if((kb|0)!=-1){Ya=kb+((kb>>>0)%3|0?-1:2)|0;if((Ya|0)==-1){break v}Ya=o[jb+(Ya<<2)>>2];o[jb+(_a<<2)>>2]=Ya;if((Ya|0)==-1){break u}o[gb+(Ya<<2)>>2]=_a;break u}o[jb+(_a<<2)>>2]=-1;_a=-1;break t}o[jb+(_a<<2)>>2]=-1}Ya=kb+1|0;Ya=(Ya>>>0)%3|0?Ya:kb+ -2|0;_a=-1;if((Ya|0)==-1){break t}_a=o[jb+(Ya<<2)>>2]}o[Za>>2]=_a;o[o[$a+68>>2]+ -4>>2]=hb;break i}_a=-1;Ya=o[$a+68>>2];ib=o[$a+64>>2];if((Ya|0)==(ib|0)){break c}Za=Ya+ -4|0;mb=o[Za>>2];o[$a+68>>2]=Za;hb=o[$a+44>>2];w:{if(!hb){Ya=Za;break w}cb=o[$a+40>>2];gb=Yl(hb)>>>0>1;db=hb+2147483647&bb;x:{if(!gb){break x}db=bb;if(bb>>>0>>0){break x}db=(bb>>>0)%(hb>>>0)|0}cb=o[cb+(db<<2)>>2];if(!cb){Ya=Za;break w}fb=o[cb>>2];if(!fb){Ya=Za;break w}cb=hb+ -1|0;y:{while(1){eb=o[fb+4>>2];z:{if((eb|0)!=(bb|0)){A:{if(!gb){eb=eb&cb;break A}if(eb>>>0>>0){break A}eb=(eb>>>0)%(hb>>>0)|0}if((eb|0)==(db|0)){break z}Ya=Za;break w}if(o[fb+8>>2]==(bb|0)){break y}}fb=o[fb>>2];if(fb){continue}break}Ya=Za;break w}db=fb+12|0;if((Za|0)!=o[$a+72>>2]){o[Za>>2]=o[db>>2];o[$a+68>>2]=Ya;break w}bh($a- -64|0,db);Ya=o[$a+68>>2];ib=o[$a+64>>2]}if((Ya|0)==(ib|0)){break c}lb=o[Ya+ -4>>2];db=(lb|0)==-1;pb=o[qb>>2];if(o[o[pb+12>>2]+(lb<<2)>>2]!=-1?!db:0){break c}gb=(mb|0)==-1;hb=pb+12|0;cb=o[hb>>2];if(o[cb+(mb<<2)>>2]!=-1?!gb:0){break c}kb=u(bb,3);ib=kb+2|0;o[cb+(lb<<2)>>2]=ib;jb=ib<<2;o[jb+cb>>2]=lb;Za=kb+1|0;o[cb+(mb<<2)>>2]=Za;eb=cb;cb=Za<<2;o[eb+cb>>2]=mb;if(db){break g}eb=-1;db=o[pb>>2];fb=db+(kb<<2)|0;Za=lb+((lb>>>0)%3|0?-1:2)|0;if((Za|0)!=-1){eb=o[(Za<<2)+db>>2]}o[fb>>2]=eb;Za=lb+1|0;Za=(Za>>>0)%3|0?Za:lb+ -2|0;if((Za|0)==-1){break f}_a=o[(Za<<2)+db>>2];break f}o[$a>>2]=u(bb,3);Ya=o[qb>>2];_a=Ya+24|0;cb=o[Ya+32>>2];Za=Ya+28|0;Ya=o[Za>>2];B:{if((cb|0)!=(Ya|0)){o[Ya>>2]=-1;Ya=Ya+4|0;o[Za>>2]=Ya;break B}bh(_a,8212);Ya=o[Za>>2]}ib=o[qb>>2];eb=o[ib>>2];Za=o[$a>>2];gb=Ya-o[_a>>2]|0;hb=gb>>2;_a=hb+ -1|0;o[eb+(Za<<2)>>2]=_a;Za=Za+1|0;cb=ib+24|0;db=ib+28|0;Ya=o[db>>2];C:{if((Ya|0)!=o[ib+32>>2]){o[Ya>>2]=-1;Ya=Ya+4|0;o[db>>2]=Ya;break C}bh(cb,8212);Ya=o[db>>2];eb=o[ib>>2]}o[(Za<<2)+eb>>2]=(Ya-o[cb>>2]>>2)+ -1;Ya=o[$a>>2]+2|0;cb=o[qb>>2];Za=cb+28|0;db=o[Za>>2];D:{if((db|0)!=o[cb+32>>2]){o[db>>2]=-1;eb=db+4|0;o[Za>>2]=eb;break D}bh(cb+24|0,8212);eb=o[Za>>2]}o[o[cb>>2]+(Ya<<2)>>2]=(eb-o[cb+24>>2]>>2)+ -1;Ya=o[qb>>2];Za=o[Ya+24>>2];if(o[Ya+28>>2]-Za>>2>(rb|0)){break d}Ya=o[$a>>2];E:{F:{if(!gb){eb=1;o[Za+(hb<<2)>>2]=Ya+1;break F}o[Za+(_a<<2)>>2]=Ya;eb=0;if((gb|0)==-4){break F}o[Za+(hb<<2)>>2]=o[$a>>2]+1;eb=hb+1|0;if((eb|0)==-1){break E}}o[Za+(eb<<2)>>2]=o[$a>>2]+2}Ya=o[$a+68>>2];if((Ya|0)!=o[$a+72>>2]){o[Ya>>2]=o[$a>>2];o[$a+68>>2]=Ya+4;break i}bh($a- -64|0,$a)}fb=o[ob>>2];if((fb|0)==o[a+36>>2]){break e}cb=(bb^-1)+Xa|0;while(1){_a=-1;Ya=o[fb+ -8>>2];if(Ya>>>0>cb>>>0){break c}if((Ya|0)!=(cb|0)){break e}Za=p[fb+ -4|0];Ya=fb+ -12|0;db=o[Ya>>2];o[ob>>2]=Ya;if((db|0)<0){break c}_a=o[o[$a+68>>2]+ -4>>2];o[$a+20>>2]=(db^-1)+Xa;o[$a+88>>2]=$a+20;ch($a,$a+40|0,$a+20|0,$a+88|0);db=o[$a>>2];G:{if(Za&1){Ya=-1;if((_a|0)==-1){break G}Ya=_a+1|0;Ya=(Ya>>>0)%3|0?Ya:_a+ -2|0;break G}Ya=-1;if((_a|0)==-1){break G}Ya=_a+ -1|0;if((_a>>>0)%3){break G}Ya=_a+2|0}o[db+12>>2]=Ya;fb=o[ob>>2];if((fb|0)!=o[a+36>>2]){continue}break}break e}D()}eb=-1;db=o[pb>>2];o[db+(kb<<2)>>2]=-1}o[cb+db>>2]=_a;H:{I:{J:{if(!gb){Za=mb+((mb>>>0)%3|0?-1:2)|0;if((Za|0)==-1){break J}Za=o[(Za<<2)+db>>2];o[db+jb>>2]=Za;if((Za|0)==-1){break I}o[o[pb+24>>2]+(Za<<2)>>2]=ib;break I}o[db+jb>>2]=-1;fb=-1;_a=-1;break H}o[db+jb>>2]=-1}fb=-1;Za=mb+1|0;Za=(Za>>>0)%3|0?Za:mb+ -2|0;_a=-1;if((Za|0)==-1){break H}fb=o[(Za<<2)+db>>2];_a=Za}o[$a>>2]=fb;cb=o[pb+24>>2];if((eb|0)!=-1){o[cb+(eb<<2)>>2]=o[cb+(fb<<2)>>2]}K:{if((_a|0)==-1){break K}db=o[pb>>2];while(1){o[db+(_a<<2)>>2]=eb;Za=_a+1|0;Za=(Za>>>0)%3|0?Za:_a+ -2|0;if((Za|0)==-1){break K}_a=o[o[hb>>2]+(Za<<2)>>2];if((_a|0)==-1){break K}Za=_a+1|0;_a=(Za>>>0)%3|0?Za:_a+ -2|0;if((_a|0)!=-1){continue}break}}o[cb+(o[$a>>2]<<2)>>2]=-1;L:{if(nb){break L}Za=o[$a+28>>2];if((Za|0)!=o[$a+32>>2]){o[Za>>2]=o[$a>>2];o[$a+28>>2]=Za+4;break L}bh($a+24|0,$a);Ya=o[$a+68>>2]}o[Ya+ -4>>2]=kb}bb=bb+1|0;if((bb|0)!=(Xa|0)){continue}break}eb=Xa}_a=-1;fb=o[a+8>>2];if(o[fb+28>>2]-o[fb+24>>2]>>2>(rb|0)){break c}bb=o[$a+68>>2];if((bb|0)!=o[$a+64>>2]){lb=a+72|0;Za=a+60|0;ib=a+312|0;nb=a+8|0;kb=a+68|0;rb=a+80|0;pb=a+76|0;while(1){Ya=bb+ -4|0;Xa=o[Ya>>2];o[$a+68>>2]=Ya;o[$a>>2]=Xa;M:{if(Pf(ib)){hb=o[nb>>2];mb=o[hb>>2];if((eb|0)>=((o[hb+4>>2]-mb>>2>>>0)/3|0)){break d}Ya=-1;fb=-1;bb=o[hb+24>>2];cb=bb;ob=o[$a>>2];db=-1;N:{if((ob|0)==-1){break N}Xa=ob+1|0;Xa=(Xa>>>0)%3|0?Xa:ob+ -2|0;db=-1;if((Xa|0)==-1){break N}db=o[mb+(Xa<<2)>>2]}cb=o[cb+(db<<2)>>2];O:{if((cb|0)==-1){break O}Xa=cb+1|0;Xa=(Xa>>>0)%3|0?Xa:cb+ -2|0;if((Xa|0)==-1){break O}Ya=Xa+1|0;Ya=(Ya>>>0)%3|0?Ya:Xa+ -2|0;if((Ya|0)!=-1){fb=o[mb+(Ya<<2)>>2]}Ya=Xa}Xa=-1;jb=-1;gb=o[bb+(fb<<2)>>2];cb=-1;P:{if((gb|0)==-1){break P}bb=gb+1|0;bb=(bb>>>0)%3|0?bb:gb+ -2|0;cb=-1;if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ya=o[kb>>2];if((bb|0)==Ya<<5){if((bb+1|0)<=-1){break a}Xa=Za;if(bb>>>0<=1073741822){db=bb+32&-32;Ya=Ya<<6;Ya=Ya>>>0>>0?db:Ya}else{Ya=2147483647}ab(Xa,Ya);bb=o[a+64>>2]}o[a+64>>2]=bb+1;Ya=o[a+60>>2]+(bb>>>3&536870908)|0;Xa=o[Ya>>2];sb=Ya,tb=Zl(bb)&Xa,o[sb>>2]=tb;Xa=o[pb>>2];if((Xa|0)!=o[rb>>2]){o[Xa>>2]=o[$a>>2];o[pb>>2]=Xa+4;break M}bh(lb,$a)}bb=o[$a+68>>2];if((bb|0)!=o[$a+64>>2]){continue}break}fb=o[a+8>>2]}if(((o[fb+4>>2]-o[fb>>2]>>2>>>0)/3|0)!=(eb|0)){break c}_a=o[fb+28>>2]-o[fb+24>>2]>>2;nb=o[$a+24>>2];cb=o[$a+28>>2];if((nb|0)==(cb|0)){break b}db=a+8|0;while(1){hb=o[nb>>2];eb=o[fb+24>>2];bb=_a+ -1|0;Q:{if(o[eb+(bb<<2)>>2]!=-1){Ya=_a;break Q}eb=o[fb+24>>2];while(1){bb=_a+ -2|0;Ya=_a+ -1|0;_a=Ya;if(o[(bb<<2)+eb>>2]==-1){continue}break}}if(!(bb>>>0>>0)){o[$a>>2]=fb;Xa=bb<<2;_a=o[Xa+eb>>2];m[$a+12|0]=1;o[$a+8>>2]=_a;o[$a+4>>2]=_a;if((_a|0)!=-1){while(1){o[o[fb>>2]+(_a<<2)>>2]=hb;jf($a);fb=o[db>>2];_a=o[$a+8>>2];if((_a|0)!=-1){continue}break}}Za=Xa;Xa=o[fb+24>>2];Za=Za+Xa|0;if((hb|0)!=-1){o[Xa+(hb<<2)>>2]=o[Za>>2]}o[Za>>2]=-1;gb=1<<(hb&31);Xa=o[a+120>>2];_a=Xa+(hb>>>3&536870908)|0;Za=_a;eb=Xa+(bb>>>3&536870908)|0;Xa=1<<(bb&31);bb=gb|o[_a>>2];R:{if(o[eb>>2]&Xa){break R}bb=o[_a>>2]&(gb^-1)}o[Za>>2]=bb;o[eb>>2]=o[eb>>2]&(Xa^-1);Ya=Ya+ -1|0}_a=Ya;nb=nb+4|0;if((cb|0)!=(nb|0)){continue}break}break c}_a=-1}nb=o[$a+24>>2]}if(nb){o[$a+28>>2]=nb;ul(nb)}bb=o[$a+48>>2];if(bb){while(1){a=o[bb>>2];ul(bb);bb=a;if(bb){continue}break}}a=o[$a+40>>2];o[$a+40>>2]=0;if(a){ul(a)}a=o[$a+64>>2];if(a){o[$a+68>>2]=a;ul(a)}R=$a+96|0;return _a}Yk();D()}function Zg(a,Xa){var ab=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0;ub=R-32|0;R=ub;o[ub+16>>2]=Xa;ab=-1;a:{if((Xa|0)==-1){o[ub+20>>2]=-1;break a}ab=Xa+1|0;o[ub+20>>2]=(ab>>>0)%3|0?ab:Xa+ -2|0;if((Xa>>>0)%3){ab=Xa+ -1|0;break a}ab=Xa+2|0}o[ub+24>>2]=ab;Cb=(Xa|0)==-1?-1:(Xa>>>0)/3|0;yb=a+220|0;Db=a+8|0;Eb=a+368|0;while(1){b:{c:{if((Xa|0)!=-1){ab=o[o[o[Db>>2]+12>>2]+(Xa<<2)>>2];if((ab|0)!=-1){break c}}ab=0;vb=o[a+216>>2];wb=o[yb>>2];if((vb|0)==(wb|0)){break b}while(1){o[ub+12>>2]=Xa;xb=u(ab,144)+vb|0;Bb=xb+136|0;zb=o[Bb>>2];d:{if(zb>>>0>2]){o[zb>>2]=Xa;o[Bb>>2]=zb+4;break d}wa(xb+132|0,ub+12|0);wb=o[yb>>2];vb=o[a+216>>2]}ab=ab+1|0;if(ab>>>0<(wb-vb|0)/144>>>0){continue}break}break b}if((ab>>>0)/3>>>0>>0){break b}ab=0;if(o[yb>>2]==o[a+216>>2]){break b}while(1){e:{if(!Pf(o[Eb>>2]+(ab<<4)|0)){break e}vb=o[a+216>>2];o[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b|0)==-1){break i}j:{if(o[o[a+120>>2]+(Qb>>>3&536870908)>>2]>>>(Qb&31)&1){break j}Xa=o[Sb>>2];Ub=o[a+216>>2];if((Xa|0)==(Ub|0)){break j}Vb=(Xa-Ub|0)/144|0;Wb=((Mb>>>0)%3|0?-1:2)+Mb|0;Pb=0;while(1){Xb=Mb<<2;Rb=Ub+u(Pb,144)|0;Xa=o[Xb+o[o[Rb+68>>2]>>2]>>2];k:{if(!(o[o[Rb+16>>2]+(Xa>>>3&536870908)>>2]>>>(Xa&31)&1)){break k}Xa=Mb;Kb=-1;l:{if((Wb|0)==-1){break l}Ob=o[o[Nb+12>>2]+(Wb<<2)>>2];Kb=-1;if((Ob|0)==-1){break l}Kb=Ob+ -1|0;if((Ob>>>0)%3){break l}Kb=Ob+2|0}if((Xa|0)==(Kb|0)){break k}Rb=o[Rb+32>>2];Xb=o[Rb+Xb>>2];while(1){Xa=0;if((Kb|0)==-1){break f}if((Xb|0)!=o[Rb+(Kb<<2)>>2]){Mb=Kb;break j}Ob=Mb;Kb=((Kb>>>0)%3|0?-1:2)+Kb|0;Xa=-1;m:{if((Kb|0)==-1){break m}Kb=o[o[Nb+12>>2]+(Kb<<2)>>2];Xa=-1;if((Kb|0)==-1){break m}Xa=Kb+ -1|0;if((Kb>>>0)%3){break m}Xa=Kb+2|0}Kb=Xa;if((Ob|0)!=(Kb|0)){continue}break}}Pb=Pb+1|0;if(Pb>>>0>>0){continue}break}}Xa=o[Lb+36>>2];o[o[Lb+16>>2]+(Mb<<2)>>2]=Xa-o[Lb+32>>2]>>2;o[Lb>>2]=Mb;n:{if(r[Lb+40>>2]>Xa>>>0){o[Xa>>2]=Mb;o[Lb+36>>2]=Xa+4;break n}wa(Lb+32|0,Lb);Nb=o[Tb>>2]}if((Mb|0)==-1){break i}Xa=((Mb>>>0)%3|0?-1:2)+Mb|0;if((Xa|0)==-1){break i}Xa=o[o[Nb+12>>2]+(Xa<<2)>>2];if((Xa|0)==-1){break i}Kb=Xa+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kb>>>0>>0){continue}break}}o[o[Mb+4>>2]+80>>2]=o[Lb+36>>2]-o[Lb+32>>2]>>2;Xa=1}Kb=Xa;a=o[Lb+16>>2];if(a){o[Lb+20>>2]=a;ul(a)}a=o[Lb+32>>2];if(!a){break b}o[Lb+36>>2]=a;ul(a)}R=Lb+48|0;return Kb}function ah(a,Xa){var _b=0,$b=0,ac=0,bc=0,cc=0,dc=0;a:{bc=o[a>>2];cc=o[a+4>>2]-bc|0;_b=(cc|0)/12|0;$b=_b+1|0;if($b>>>0<357913942){dc=u(_b,12);ac=(o[a+8>>2]-bc|0)/12|0;_b=ac<<1;ac=ac>>>0<178956970?_b>>>0<$b>>>0?$b:_b:357913941;_b=0;b:{if(!ac){break b}if(ac>>>0>=357913942){break a}_b=Hk(u(ac,12))}$b=dc+_b|0;dc=o[Xa+4>>2];o[$b>>2]=o[Xa>>2];o[$b+4>>2]=dc;o[$b+8>>2]=o[Xa+8>>2];Xa=$b+u((cc|0)/-12|0,12)|0;_b=_b+u(ac,12)|0;$b=$b+12|0;if((cc|0)>=1){wl(Xa,bc,cc)}o[a>>2]=Xa;o[a+8>>2]=_b;o[a+4>>2]=$b;if(bc){ul(bc)}return}Yk();D()}_a(8776);D()}function bh(a,Xa){var ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;a:{gc=o[a>>2];ic=o[a+4>>2]-gc|0;ec=ic>>2;fc=ec+1|0;if(fc>>>0<1073741824){jc=ec<<2;ec=o[a+8>>2]-gc|0;hc=ec>>1;fc=ec>>2>>>0<536870911?hc>>>0>>0?fc:hc:1073741823;ec=0;b:{if(!fc){break b}if(fc>>>0>=1073741824){break a}ec=Hk(fc<<2)}hc=jc+ec|0;o[hc>>2]=o[Xa>>2];Xa=ec+(fc<<2)|0;fc=hc+4|0;if((ic|0)>=1){wl(ec,gc,ic)}o[a>>2]=ec;o[a+8>>2]=Xa;o[a+4>>2]=fc;if(gc){ul(gc)}return}Yk();D()}_a(8776);D()}function ch(a,Xa,kc,lc){var mc=0,nc=0,oc=0,pc=0,qc=0,rc=v(0),sc=0,tc=v(0),uc=0;mc=o[kc>>2];uc=a;a:{b:{nc=o[Xa+4>>2];if(!nc){break b}sc=o[Xa>>2];pc=Yl(nc);kc=nc+ -1&mc;c:{if(pc>>>0<=1){break c}kc=mc;if(mc>>>0>>0){break c}kc=(mc>>>0)%(nc>>>0)|0}oc=kc;kc=o[(kc<<2)+sc>>2];if(!kc){break b}sc=nc+ -1|0;pc=pc>>>0>1;while(1){kc=o[kc>>2];if(!kc){break b}qc=o[kc+4>>2];if((qc|0)!=(mc|0)){d:{if(!pc){qc=qc≻break d}if(qc>>>0>>0){break d}qc=(qc>>>0)%(nc>>>0)|0}if((oc|0)!=(qc|0)){break b}}if(o[kc+8>>2]!=(mc|0)){continue}break}Xa=0;break a}kc=Hk(16);lc=o[o[lc>>2]>>2];o[kc+12>>2]=0;o[kc+8>>2]=lc;o[kc+4>>2]=mc;o[kc>>2]=0;tc=s[Xa+16>>2];rc=v(o[Xa+12>>2]+1>>>0);e:{if(!(!nc|!!(v(tc*v(nc>>>0))>>0<3|nc<<1;lc=Xa;rc=v(B(v(rc/tc)));f:{if(rc=v(0)){pc=~~rc>>>0;break f}pc=0}Sh(lc,oc>>>0>>0?pc:oc);nc=o[Xa+4>>2];if(!(nc&nc+ -1)){mc=nc+ -1&mc;break e}if(mc>>>0>>0){break e}mc=(mc>>>0)%(nc>>>0)|0}lc=o[Xa>>2]+(mc<<2)|0;mc=o[lc>>2];g:{h:{if(!mc){oc=Xa+8|0;o[kc>>2]=o[oc>>2];o[oc>>2]=kc;o[lc>>2]=oc;lc=o[kc>>2];if(!lc){break g}mc=o[lc+4>>2];lc=nc+ -1|0;i:{if(!(lc&nc)){mc=lc&mc;break i}if(mc>>>0>>0){break i}mc=(mc>>>0)%(nc>>>0)|0}mc=o[Xa>>2]+(mc<<2)|0;break h}o[kc>>2]=o[mc>>2]}o[mc>>2]=kc}Xa=Xa+12|0;o[Xa>>2]=o[Xa>>2]+1;Xa=1}m[uc+4|0]=Xa;o[a>>2]=kc}function dh(a,Xa,kc){var lc=0,vc=0,wc=0,xc=0,yc=0;a:{b:{xc=o[a+8>>2];vc=a+4|0;lc=o[vc>>2];c:{if((xc-lc|0)/12>>>0>=Xa>>>0){while(1){a=o[kc+4>>2];o[lc>>2]=o[kc>>2];o[lc+4>>2]=a;o[lc+8>>2]=o[kc+8>>2];lc=o[vc>>2]+12|0;o[vc>>2]=lc;Xa=Xa+ -1|0;if(Xa){continue}break c}}wc=o[a>>2];yc=(lc-wc|0)/12|0;vc=yc+Xa|0;if(vc>>>0>=357913942){break b}xc=(xc-wc|0)/12|0;wc=xc<<1;vc=xc>>>0<178956970?wc>>>0>>0?vc:wc:357913941;lc=0;d:{if(!vc){break d}if(vc>>>0>=357913942){break a}lc=Hk(u(vc,12))}xc=lc+u(vc,12)|0;vc=lc+u(yc,12)|0;lc=vc;while(1){wc=o[kc+4>>2];o[lc>>2]=o[kc>>2];o[lc+4>>2]=wc;o[lc+8>>2]=o[kc+8>>2];lc=lc+12|0;Xa=Xa+ -1|0;if(Xa){continue}break}wc=a+4|0;Xa=o[a>>2];kc=o[wc>>2]-Xa|0;vc=vc+u((kc|0)/-12|0,12)|0;if((kc|0)>=1){wl(vc,Xa,kc)}o[a>>2]=vc;o[a+8>>2]=xc;o[wc>>2]=lc;if(!Xa){break c}ul(Xa)}return}Yk();D()}_a(8776);D()}function eh(a){a=a|0;return o[a+8>>2]}function fh(a){o[a>>2]=8224;xl(a+4|0,0,80);o[a+96>>2]=0;o[a+100>>2]=0;o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+104>>2]=0;o[a+108>>2]=0;o[a+112>>2]=0;o[a+116>>2]=0;o[a+120>>2]=0;o[a+124>>2]=0;o[a+128>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0;o[a+144>>2]=0;o[a+148>>2]=0;o[a+156>>2]=0;o[a+160>>2]=0;o[a+152>>2]=1065353216;o[a+164>>2]=0;o[a+168>>2]=0;o[a+172>>2]=0;o[a+176>>2]=0;o[a+180>>2]=0;o[a+184>>2]=0;o[a+188>>2]=0;o[a+192>>2]=0;o[a+196>>2]=0;o[a+200>>2]=0;o[a+204>>2]=0;o[a+208>>2]=0;o[a+212>>2]=-1;o[a+216>>2]=0;o[a+220>>2]=0;o[a+224>>2]=0;Hg(a+232|0);o[a+388>>2]=0;o[a+392>>2]=0;o[a+380>>2]=0;o[a+384>>2]=0;o[a+416>>2]=0;o[a+420>>2]=0;o[a+412>>2]=7;o[a+404>>2]=-1;o[a+408>>2]=2;o[a+396>>2]=0;o[a+400>>2]=-1;o[a+424>>2]=0;o[a+428>>2]=0;o[a+432>>2]=0;o[a+436>>2]=0}function gh(a){a=a|0;var Xa=0,kc=0,zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0,Fc=0,Gc=0,Hc=0,Ic=0,Jc=0,Kc=0;Bc=R+ -64|0;R=Bc;o[a+132>>2]=0;if(o[a+148>>2]){zc=a+144|0;Xa=o[zc>>2];if(Xa){while(1){kc=o[Xa>>2];ul(Xa);Xa=kc;if(Xa){continue}break}}o[zc>>2]=0;kc=o[a+140>>2];if(kc){zc=a+136|0;Xa=0;while(1){o[o[zc>>2]+(Xa<<2)>>2]=0;Xa=Xa+1|0;if((kc|0)!=(Xa|0)){continue}break}}o[a+148>>2]=0}a:{if(!Tg(1,Bc+60|0,o[o[a+4>>2]+32>>2])){break a}o[a+156>>2]=o[Bc+60>>2];if(!Tg(1,Bc+56|0,o[o[a+4>>2]+32>>2])){break a}Ac=o[Bc+56>>2];if(Ac>>>0>1431655765|r[a+156>>2]>u(Ac,3)>>>0){break a}Xa=o[o[a+4>>2]+32>>2];Cc=o[Xa+16>>2];zc=o[Xa+12>>2];kc=o[Xa+20>>2];if((zc|0)<(kc|0)?1:(zc|0)<=(kc|0)?r[Xa+8>>2]>Cc>>>0?0:1:0){break a}Dc=p[Cc+o[Xa>>2]|0];Cc=Cc+1|0;if(Cc>>>0<1){kc=kc+1|0}o[Xa+16>>2]=Cc;o[Xa+20>>2]=kc;if(!Tg(1,Bc+52|0,Xa)){break a}Gc=o[Bc+52>>2];if(Ac>>>0>>0|Ac>>>0>Gc+((Gc>>>0)/3|0)>>>0){break a}if(!Tg(1,Bc+48|0,o[o[a+4>>2]+32>>2])){break a}Ec=o[Bc+48>>2];if(Ec>>>0>Gc>>>0){break a}o[a+28>>2]=o[a+24>>2];kc=Hk(88);zi(kc);Xa=o[a+8>>2];o[a+8>>2]=kc;Cc=a+8|0;if(Xa){ua(Cc,Xa);if(!o[Cc>>2]){break a}}Xa=o[a+160>>2];o[a+164>>2]=Xa;b:{c:{d:{e:{f:{if(o[a+168>>2]-Xa>>2>>>0>=Ac>>>0){break f}if(Ac>>>0>=1073741824){break e}zc=Ac<<2;kc=Hk(zc);o[a+164>>2]=kc;o[a+160>>2]=kc;o[a+168>>2]=kc+zc;if(!Xa){break f}ul(Xa)}Xa=o[a+172>>2];o[a+176>>2]=Xa;g:{if(o[a+180>>2]-Xa>>2>>>0>=Ac>>>0){break g}if(Ac>>>0>=1073741824){break d}zc=Ac<<2;kc=Hk(zc);o[a+176>>2]=kc;o[a+172>>2]=kc;o[a+180>>2]=kc+zc;if(!Xa){break g}ul(Xa)}o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+40>>2]=o[a+36>>2];o[a- -64>>2]=0;o[a+52>>2]=o[a+48>>2];o[a+76>>2]=o[a+72>>2];Hc=a+216|0;kc=o[a+220>>2];Xa=o[a+216>>2];if((kc|0)==(Xa|0)){break c}while(1){zc=o[kc+ -12>>2];if(zc){o[kc+ -8>>2]=zc;ul(zc)}zc=o[kc+ -28>>2];if(zc){o[kc+ -24>>2]=zc;ul(zc)}zc=kc+ -144|0;Fc=o[kc+ -40>>2];if(Fc){o[kc+ -36>>2]=Fc;ul(Fc)}Ug(kc+ -140|0);kc=zc;if((Xa|0)!=(kc|0)){continue}break}kc=o[Hc>>2];break b}_a(8776);D()}_a(8776);D()}kc=Xa}o[a+220>>2]=Xa;zc=(Xa-kc|0)/144|0;h:{if(zc>>>0>>0){Vg(Hc,Dc-zc|0);break h}if(zc>>>0<=Dc>>>0){break h}zc=kc+u(Dc,144)|0;if((zc|0)!=(Xa|0)){while(1){kc=o[Xa+ -12>>2];if(kc){o[Xa+ -8>>2]=kc;ul(kc)}kc=o[Xa+ -28>>2];if(kc){o[Xa+ -24>>2]=kc;ul(kc)}kc=Xa+ -144|0;Fc=o[Xa+ -40>>2];if(Fc){o[Xa+ -36>>2]=Fc;ul(Fc)}Ug(Xa+ -140|0);Xa=kc;if((Xa|0)!=(zc|0)){continue}break}}o[a+220>>2]=zc}Fc=0;if(!Ji(o[a+8>>2],Ac,Ec+o[a+156>>2]|0)){break a}Xa=o[a+156>>2];m[Bc+8|0]=1;$a(a+120|0,Xa+Ec|0,Bc+8|0);if((Wg(a,o[o[a+4>>2]+32>>2])|0)==-1){break a}o[a+376>>2]=a;Ac=a+232|0;Xa=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];Ic=o[Xa>>2]+o[Xa+16>>2]|0;zc=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];Xa=o[zc+8>>2];kc=o[zc+16>>2];pi(Ac,Ic,Xa-kc|0,q[o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);Jc=a,Kc=l[o[o[a>>2]+36>>2]](a)|0,o[Jc+380>>2]=Kc;o[a+372>>2]=Dc;o[a+384>>2]=Ec+o[a+156>>2];Xa=oi(Bc+8|0);i:{if(!hh(Ac,Xa)){break i}Gc=ih(a,Gc);if((Gc|0)==-1){break i}zc=o[o[a+4>>2]+32>>2];kc=o[Xa+16>>2];Dc=kc+o[Xa>>2]|0;Xa=o[Xa+8>>2];pi(zc,Dc,Xa-kc|0,q[zc+38>>1]);j:{if(o[a+220>>2]==o[a+216>>2]){break j}Xa=o[Cc>>2];if(o[Xa+4>>2]==o[Xa>>2]){break j}Xa=0;while(1){if(Zg(a,Xa)){Xa=Xa+3|0;kc=o[Cc>>2];if(Xa>>>0>2]-o[kc>>2]>>2>>>0){continue}break j}break}break i}if(p[a+308|0]){si(a+272|0)}Xa=o[a+216>>2];Dc=a+220|0;if((Xa|0)!=o[Dc>>2]){zc=0;while(1){Ac=u(zc,144);Ui((Ac+Xa|0)+4|0,o[Cc>>2]);kc=o[Hc>>2];Ec=Ac+kc|0;Xa=o[Ec+132>>2];Ec=o[Ec+136>>2];if((Xa|0)!=(Ec|0)){while(1){Wi((kc+Ac|0)+4|0,o[Xa>>2]);kc=o[Hc>>2];Xa=Xa+4|0;if((Ec|0)!=(Xa|0)){continue}break}}Vi((kc+Ac|0)+4|0);zc=zc+1|0;Xa=o[a+216>>2];if(zc>>>0<(o[Dc>>2]-Xa|0)/144>>>0){continue}break}}Xa=o[a+8>>2];_g(a+184|0,o[Xa+28>>2]-o[Xa+24>>2]>>2);kc=o[a+216>>2];if((kc|0)!=o[Dc>>2]){Xa=0;Ac=a+220|0;while(1){kc=u(Xa,144)+kc|0;zc=o[kc+60>>2]-o[kc+56>>2]>>2;Dc=kc+104|0;kc=o[Cc>>2];kc=o[kc+28>>2]-o[kc+24>>2]>>2;_g(Dc,(zc|0)<(kc|0)?kc:zc);Xa=Xa+1|0;kc=o[a+216>>2];if(Xa>>>0<(o[Ac>>2]-kc|0)/144>>>0){continue}break}}Fc=$g(a,Gc)}}R=Bc- -64|0;return Fc|0}function hh(a,Lc){var Mc=0,Nc=0,Oc=0,Pc=0,Qc=0,Rc=0,Sc=0,Tc=0,Uc=0,Vc=0,Wc=0,Xc=0;Sc=R-16|0;R=Sc;a:{if(!Nf(a+80|0,a)){break a}if(!Xg(a)){break a}Mc=o[a+4>>2];o[Lc>>2]=o[a>>2];o[Lc+4>>2]=Mc;Mc=o[a+36>>2];o[Lc+32>>2]=o[a+32>>2];o[Lc+36>>2]=Mc;Mc=o[a+28>>2];o[Lc+24>>2]=o[a+24>>2];o[Lc+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nc>>>0>Tc>>>0){Da(Qc,Nc-Tc|0);Oc=o[Rc>>2];break e}if(Nc>>>0>=Tc>>>0){break e}o[Vc>>2]=(Nc<<2)+Wc}_f(Nc,1,Lc,o[Oc+Uc>>2]);o[o[Pc>>2]+(Mc<<2)>>2]=Nc}Oc=1;Mc=Mc+1|0;if(Mc>>>0<(o[Xc>>2]-o[a+184>>2]|0)/12>>>0){continue}break}}R=Sc+16|0;return Oc}function ih(a,Lc){var Yc=0,Zc=0,_c=0,$c=0,ad=0,bd=0,cd=0,dd=0,ed=0,fd=0,gd=0,hd=0,id=0,jd=0,kd=0,ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0,sd=0,td=0,ud=0,vd=0,wd=0;ad=R-96|0;R=ad;o[ad+72>>2]=0;o[ad+64>>2]=0;o[ad+68>>2]=0;o[ad+48>>2]=0;o[ad+52>>2]=0;o[ad+40>>2]=0;o[ad+44>>2]=0;o[ad+56>>2]=1065353216;o[ad+32>>2]=0;o[ad+24>>2]=0;o[ad+28>>2]=0;jd=o[a+124>>2];a:{b:{c:{if((Lc|0)>=1){qd=a+232|0;hd=a+8|0;nd=a+40|0;rd=a+428|0;ld=a+416|0;sd=a+388|0;td=o[a+216>>2]!=o[a+220>>2];while(1){d:{e:{f:{Yc=o[a+404>>2];g:{h:{if((Yc|0)!=-1){$c=-1;Zc=o[rd>>2]+(Yc<<2)|0;_c=o[Zc>>2];Yc=_c+ -1|0;o[Zc>>2]=Yc;if((_c|0)<1){break c}Yc=o[o[o[ld>>2]+u(o[a+404>>2],12)>>2]+(Yc<<2)>>2];Zc=o[(Yc<<2)+8848>>2];o[a+400>>2]=Zc;if(!Yc){Yc=o[ad+68>>2];if((Yc|0)==o[ad+64>>2]){break c}cd=-1;_c=o[hd>>2];id=o[_c+24>>2];bd=id;md=Yc+ -4|0;$c=o[md>>2];Zc=-1;i:{if(($c|0)==-1){break i}fd=$c+1|0;fd=(fd>>>0)%3|0?fd:$c+ -2|0;Zc=-1;if((fd|0)==-1){break i}Zc=o[o[_c>>2]+(fd<<2)>>2]}bd=o[bd+(Zc<<2)>>2];if((bd|0)!=-1){cd=bd+1|0;cd=(cd>>>0)%3|0?cd:bd+ -2|0}bd=o[_c+12>>2];fd=u(dd,3);ed=fd+1|0;o[bd+($c<<2)>>2]=ed;kd=ed<<2;o[kd+bd>>2]=$c;ed=fd+2|0;o[bd+(cd<<2)>>2]=ed;gd=ed<<2;o[gd+bd>>2]=cd;_c=o[_c>>2];o[_c+(fd<<2)>>2]=Zc;bd=_c+kd|0;kd=-1;j:{if((cd|0)==-1){break j}od=cd+1|0;cd=(od>>>0)%3|0?od:cd+ -2|0;kd=-1;if((cd|0)==-1){break j}kd=o[_c+(cd<<2)>>2]}o[bd>>2]=kd;k:{l:{if(($c|0)!=-1){$c=$c+(($c>>>0)%3|0?-1:2)|0;if(($c|0)!=-1){break l}}o[_c+gd>>2]=-1;break k}$c=o[_c+($c<<2)>>2];o[_c+gd>>2]=$c;if(($c|0)==-1){break k}o[id+($c<<2)>>2]=ed}$c=o[a+120>>2]+(Zc>>>3&536870908)|0;_c=o[$c>>2];vd=$c,wd=Zl(Zc)&_c,o[vd>>2]=wd;o[md>>2]=fd;Zc=0;break d}Zc=Zc+ -1|0;if(Zc>>>0>6){break c}m:{switch(Zc-1|0){case 1:case 3:cd=o[ad+68>>2];if((cd|0)==o[ad+64>>2]){break c}Zc=o[hd>>2];$c=o[Zc+12>>2];_c=u(dd,3);bd=(Yc|0)==3;fd=_c+(bd?2:1)|0;id=fd<<2;Yc=o[cd+ -4>>2];o[$c+id>>2]=Yc;o[$c+(Yc<<2)>>2]=fd;ed=Zc+24|0;cd=o[Zc+32>>2];Zc=Zc+28|0;$c=o[Zc>>2];n:{if((cd|0)!=($c|0)){o[$c>>2]=-1;gd=$c+4|0;o[Zc>>2]=gd;break n}bh(ed,8212);gd=o[Zc>>2]}$c=-1;Zc=o[hd>>2];cd=o[Zc+24>>2];if(o[Zc+28>>2]-cd>>2>(jd|0)){break c}$c=_c+2|0;Zc=o[Zc>>2];ed=gd-o[ed>>2]|0;gd=(ed>>2)+ -1|0;o[Zc+id>>2]=gd;if(ed){o[cd+(gd<<2)>>2]=fd}$c=bd?_c:$c;id=Zc+(_c+bd<<2)|0;o:{p:{q:{if((Yc|0)!=-1){bd=Yc+((Yc>>>0)%3|0?-1:2)|0;if((bd|0)==-1){break q}bd=o[Zc+(bd<<2)>>2];o[Zc+($c<<2)>>2]=bd;if((bd|0)==-1){break p}o[cd+(bd<<2)>>2]=$c;break p}o[Zc+($c<<2)>>2]=-1;$c=-1;break o}o[Zc+($c<<2)>>2]=-1}cd=Yc+1|0;Yc=(cd>>>0)%3|0?cd:Yc+ -2|0;$c=-1;if((Yc|0)==-1){break o}$c=o[Zc+(Yc<<2)>>2]}o[id>>2]=$c;Yc=o[ad+68>>2];o[Yc+ -4>>2]=_c;break g;case 5:break h;case 0:case 2:case 4:break c;default:break m}}Yc=o[ad+68>>2];gd=o[ad+64>>2];if((Yc|0)==(gd|0)){break c}Zc=Yc+ -4|0;fd=o[Zc>>2];o[ad+68>>2]=Zc;ed=o[ad+44>>2];r:{if(!ed){Yc=Zc;break r}id=Yl(ed)>>>0>1;s:{if(!id){_c=ed+2147483647ⅆbreak s}_c=dd;if(_c>>>0>>0){break s}_c=(dd>>>0)%(ed>>>0)|0}cd=o[o[ad+40>>2]+(_c<<2)>>2];if(!cd){Yc=Zc;break r}bd=o[cd>>2];if(!bd){Yc=Zc;break r}md=ed+ -1|0;t:{while(1){cd=o[bd+4>>2];u:{if((dd|0)!=(cd|0)){v:{if(!id){cd=cd&md;break v}if(cd>>>0>>0){break v}cd=(cd>>>0)%(ed>>>0)|0}if((_c|0)==(cd|0)){break u}Yc=Zc;break r}if(o[bd+8>>2]==(dd|0)){break t}}bd=o[bd>>2];if(bd){continue}break}Yc=Zc;break r}_c=bd+12|0;if((Zc|0)!=o[ad+72>>2]){o[Zc>>2]=o[_c>>2];o[ad+68>>2]=Yc;break r}bh(ad- -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while(1){o[_c+($c<<2)>>2]=cd;bd=$c+1|0;$c=(bd>>>0)%3|0?bd:$c+ -2|0;if(($c|0)==-1){break F}$c=o[o[md>>2]+($c<<2)>>2];if(($c|0)==-1){break F}bd=$c+1|0;$c=(bd>>>0)%3|0?bd:$c+ -2|0;if(($c|0)!=-1){continue}break}}o[Zc+(o[ad>>2]<<2)>>2]=-1;G:{if(td){break G}Zc=o[ad+28>>2];if((Zc|0)!=o[ad+32>>2]){o[Zc>>2]=o[ad>>2];o[ad+28>>2]=Zc+4;break G}bh(ad+24|0,ad);Yc=o[ad+68>>2]}o[Yc+ -4>>2]=gd;Zc=0}kh(qd,o[Yc+ -4>>2]);H:{if(!Zc){break H}Yc=o[nd>>2];if((Yc|0)==o[a+36>>2]){break H}_c=(dd^-1)+Lc|0;while(1){$c=-1;Zc=o[Yc+ -8>>2];if(Zc>>>0>_c>>>0){break c}if((Zc|0)!=(_c|0)){break H}Zc=p[Yc+ -4|0];Yc=Yc+ -12|0;cd=o[Yc>>2];o[nd>>2]=Yc;if((cd|0)<0){break c}Yc=o[o[ad+68>>2]+ -4>>2];o[ad+20>>2]=(cd^-1)+Lc;o[ad+88>>2]=ad+20;ch(ad,ad+40|0,ad+20|0,ad+88|0);$c=o[ad>>2];I:{if(Zc&1){Zc=-1;if((Yc|0)==-1){break I}Zc=Yc+1|0;Zc=(Zc>>>0)%3|0?Zc:Yc+ -2|0;break I}Zc=-1;if((Yc|0)==-1){break I}Zc=Yc+ -1|0;if((Yc>>>0)%3){break I}Zc=Yc+2|0}o[$c+12>>2]=Zc;Yc=o[nd>>2];if((Yc|0)!=o[a+36>>2]){continue}break}}dd=dd+1|0;if((dd|0)!=(Lc|0)){continue}break}Zc=Lc}$c=-1;bd=o[a+8>>2];if(o[bd+28>>2]-o[bd+24>>2]>>2>(jd|0)){break c}Yc=o[ad+68>>2];if((Yc|0)!=o[ad+64>>2]){nd=a+72|0;Lc=a+60|0;sd=a+312|0;td=a+8|0;id=a+68|0;qd=a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d,wd=Zl(Yc)&bd,o[vd>>2]=wd;jd=(dd|0)!=-1?o[ed>>2]:jd;Yc=_c+(jd>>>3&536870908)|0;dd=o[Yc>>2];vd=Yc,wd=Zl(jd)&dd,o[vd>>2]=wd;Yc=-1;Yc=(gd|0)!=-1?o[hd>>2]:Yc;dd=_c+(Yc>>>3&536870908)|0;_c=o[dd>>2];vd=dd,wd=Zl(Yc)&_c,o[vd>>2]=wd;Yc=o[a+64>>2];_c=o[id>>2];if((Yc|0)==_c<<5){if((Yc+1|0)<=-1){break a}dd=Lc;if(Yc>>>0<=1073741822){Yc=Yc+32&-32;_c=_c<<6;Yc=_c>>>0>>0?Yc:_c}else{Yc=2147483647}ab(dd,Yc);Yc=o[a+64>>2]}Zc=Zc+1|0;o[a+64>>2]=Yc+1;dd=o[a+60>>2]+(Yc>>>3&536870908)|0;o[dd>>2]=o[dd>>2]|1<<(Yc&31);Yc=o[fd>>2];if((Yc|0)!=o[qd>>2]){o[Yc>>2]=o[ad+88>>2];o[fd>>2]=Yc+4;break J}bh(nd,ad+88|0);break J}Yc=o[a+64>>2];_c=o[id>>2];if((Yc|0)==_c<<5){if((Yc+1|0)<=-1){break a}dd=Lc;if(Yc>>>0<=1073741822){Yc=Yc+32&-32;_c=_c<<6;Yc=_c>>>0>>0?Yc:_c}else{Yc=2147483647}ab(dd,Yc);Yc=o[a+64>>2]}o[a+64>>2]=Yc+1;dd=o[a+60>>2]+(Yc>>>3&536870908)|0;_c=o[dd>>2];vd=dd,wd=Zl(Yc)&_c,o[vd>>2]=wd;Yc=o[fd>>2];if((Yc|0)!=o[qd>>2]){o[Yc>>2]=o[ad>>2];o[fd>>2]=Yc+4;break J}bh(nd,ad)}Yc=o[ad+68>>2];if((Yc|0)!=o[ad+64>>2]){continue}break}bd=o[a+8>>2]}if(((o[bd+4>>2]-o[bd>>2]>>2>>>0)/3|0)!=(Zc|0)){break c}$c=o[bd+28>>2]-o[bd+24>>2]>>2;Lc=o[ad+24>>2];cd=o[ad+28>>2];if((Lc|0)==(cd|0)){break b}hd=a+8|0;while(1){_c=o[Lc>>2];Zc=o[bd+24>>2];Yc=$c+ -1|0;N:{if(o[Zc+(Yc<<2)>>2]!=-1){dd=$c;break N}Zc=o[bd+24>>2];while(1){Yc=$c+ -2|0;dd=$c+ -1|0;$c=dd;if(o[(Yc<<2)+Zc>>2]==-1){continue}break}}if(!(Yc>>>0<_c>>>0)){o[ad>>2]=bd;$c=Zc;Zc=Yc<<2;$c=o[$c+Zc>>2];m[ad+12|0]=1;o[ad+8>>2]=$c;o[ad+4>>2]=$c;if(($c|0)!=-1){while(1){o[o[bd>>2]+($c<<2)>>2]=_c;jf(ad);bd=o[hd>>2];$c=o[ad+8>>2];if(($c|0)!=-1){continue}break}}$c=o[bd+24>>2];Zc=$c+Zc|0;if((_c|0)!=-1){o[$c+(_c<<2)>>2]=o[Zc>>2]}o[Zc>>2]=-1;Zc=1<<(_c&31);$c=_c>>>3&536870908;_c=o[a+120>>2];$c=$c+_c|0;id=$c;ed=1<<(Yc&31);_c=_c+(Yc>>>3&536870908)|0;Yc=Zc|o[$c>>2];O:{if(ed&o[_c>>2]){break O}Yc=o[$c>>2]&(Zc^-1)}o[id>>2]=Yc;o[_c>>2]=o[_c>>2]&(ed^-1);dd=dd+ -1|0}$c=dd;Lc=Lc+4|0;if((cd|0)!=(Lc|0)){continue}break}}Lc=o[ad+24>>2]}if(Lc){o[ad+28>>2]=Lc;ul(Lc)}Yc=o[ad+48>>2];if(Yc){while(1){a=o[Yc>>2];ul(Yc);Yc=a;if(Yc){continue}break}}a=o[ad+40>>2];o[ad+40>>2]=0;if(a){ul(a)}a=o[ad+64>>2];if(a){o[ad+68>>2]=a;ul(a)}R=ad+96|0;return $c}Yk();D()}function jh(a,Lc){var xd=0,yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0;zd=o[a+8>>2];Ad=a+4|0;xd=o[Ad>>2];if((zd-xd|0)/12>>>0>=Lc>>>0){a=u(Lc,12);Ed=Ad,Fd=xl(xd,0,a)+a|0,o[Ed>>2]=Fd;return}a:{Ad=o[a>>2];yd=(xd-Ad|0)/12|0;Bd=yd+Lc|0;if(Bd>>>0<357913942){Dd=u(yd,12);zd=(zd-Ad|0)/12|0;yd=zd<<1;yd=zd>>>0<178956970?yd>>>0>>0?Bd:yd:357913941;if(yd){if(yd>>>0>=357913942){break a}Cd=Hk(u(yd,12))}zd=Cd+Dd|0;xl(zd,0,u(Lc,12));Lc=u(Bd,12)+Cd|0;Bd=u(yd,12)+Cd|0;if((xd|0)!=(Ad|0)){while(1){zd=zd+ -12|0;o[zd>>2]=0;o[zd+4>>2]=0;yd=zd+8|0;o[yd>>2]=0;xd=xd+ -12|0;o[zd>>2]=o[xd>>2];o[zd+4>>2]=o[xd+4>>2];Cd=yd;yd=xd+8|0;o[Cd>>2]=o[yd>>2];o[yd>>2]=0;o[xd>>2]=0;o[xd+4>>2]=0;if((xd|0)!=(Ad|0)){continue}break}Ad=o[a>>2];xd=o[a+4>>2]}o[a>>2]=zd;o[a+8>>2]=Bd;o[a+4>>2]=Lc;if((xd|0)!=(Ad|0)){while(1){a=xd+ -12|0;Lc=o[a>>2];if(Lc){o[xd+ -8>>2]=Lc;ul(Lc)}xd=a;if((xd|0)!=(Ad|0)){continue}break}}if(Ad){ul(Ad)}return}Yk();D()}_a(8776);D()}function kh(a,Lc){var Gd=0,Hd=0,Id=0,Jd=0,Kd=0;Jd=-1;Hd=-1;a:{if((Lc|0)==-1){break a}Hd=Lc+1|0;Jd=(Hd>>>0)%3|0?Hd:Lc+ -2|0;Hd=Lc+ -1|0;if((Lc>>>0)%3){break a}Hd=Lc+2|0}Gd=o[a+168>>2];b:{if(Gd>>>0>7){break b}c:{d:{switch(Gd-2|0){default:Gd=o[a+148>>2];Id=1;Lc=o[a+156>>2];Kd=Lc+(((Jd|0)!=-1?o[o[Gd>>2]+(Jd<<2)>>2]:-1)<<2)|0;o[Kd>>2]=o[Kd>>2]+1;Lc=(((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2];if(Pd){o[a+52>>2]=Pd;ul(Pd)}Pd=o[a+36>>2];if(Pd){o[a+40>>2]=Pd;ul(Pd)}Pd=o[a+24>>2];if(Pd){o[a+28>>2]=Pd;ul(Pd)}Pd=o[a+12>>2];if(Pd){o[a+16>>2]=Pd;ul(Pd)}Pd=o[a+8>>2];o[a+8>>2]=0;if(Pd){ua(a+8|0,Pd)}return a|0}function oh(a){var Ud=0,Vd=0,Wd=0,Xd=0,Yd=0;Ud=o[a+196>>2];if(Ud){o[a+200>>2]=Ud;ul(Ud)}Ud=o[a+184>>2];if(Ud){Yd=a+188|0;Vd=o[Yd>>2];Wd=Ud;a:{if((Ud|0)==(Vd|0)){break a}while(1){Wd=Vd+ -12|0;Xd=o[Wd>>2];if(Xd){o[Vd+ -8>>2]=Xd;ul(Xd)}Vd=Wd;if((Vd|0)!=(Ud|0)){continue}break}Wd=o[a+184>>2]}o[Yd>>2]=Ud;ul(Wd)}Ud=o[a+156>>2];if(Ud){o[a+160>>2]=Ud;ul(Ud)}Ud=a+136|0;a=o[Ud>>2];o[Ud>>2]=0;if(a){Vd=a+ -4|0;Ud=o[Vd>>2];if(Ud){Ud=a+(Ud<<4)|0;while(1){Ud=Ud+ -16|0;if((a|0)!=(Ud|0)){continue}break}}ul(Vd)}}function ph(a){a=a|0;ul(nh(a))}function qh(a){a=a|0;var Zd=0;o[a>>2]=8512;Zd=o[a+48>>2];if(Zd){o[a+52>>2]=Zd;ul(Zd)}o[a>>2]=8764;Zd=o[a+36>>2];if(Zd){ul(Zd)}Zd=o[a+24>>2];if(Zd){ul(Zd)}ul(a)}function rh(a){a=a|0;var _d=0;o[a>>2]=8764;_d=o[a+36>>2];if(_d){ul(_d)}_d=o[a+24>>2];if(_d){ul(_d)}return a|0}function sh(a){a=a|0;var $d=0;o[a>>2]=8764;$d=o[a+36>>2];if($d){ul($d)}$d=o[a+24>>2];if($d){ul($d)}ul(a)}function th(a,ae,be){a=a|0;ae=ae|0;be=be|0;var ce=0,de=0;ce=R-16|0;R=ce;o[a+4>>2]=ae;de=o[ae+4>>2];ae=o[ae>>2];m[ce+15|0]=0;$a(a+24|0,(de-ae>>2>>>0)/3|0,ce+15|0);ae=o[a+4>>2];de=o[ae+28>>2];ae=o[ae+24>>2];m[ce+14|0]=0;$a(a+36|0,de-ae>>2,ce+14|0);ae=o[be+12>>2];o[a+16>>2]=o[be+8>>2];o[a+20>>2]=ae;ae=o[be+4>>2];o[a+8>>2]=o[be>>2];o[a+12>>2]=ae;R=ce+16|0}function uh(a,ae){var be=0,ee=0,fe=0;a:{if((a|0)!=(ae|0)){fe=a;be=o[ae+4>>2];ee=0;b:{if(!be){break b}c:{if(be>>>0<=o[a+8>>2]<<5>>>0){ee=o[a>>2];break c}ee=o[a>>2];if(ee){ul(ee);o[a+8>>2]=0;o[a>>2]=0;o[a+4>>2]=0;be=o[ae+4>>2]}if((be|0)<=-1){break a}be=(be+ -1>>>5)+1|0;ee=Hk(be<<2);o[a+8>>2]=be;o[a+4>>2]=0;o[a>>2]=ee;be=o[ae+4>>2]}yl(ee,o[ae>>2],(be+ -1>>>3&536870908)+4|0);ee=o[ae+4>>2]}o[fe+4>>2]=ee}return}Yk();D()}function vh(a){a=a|0;var ae=0;o[a>>2]=9088;ae=o[a+88>>2];if(ae){o[a+92>>2]=ae;ul(ae)}ae=o[a+72>>2];if(ae){o[a+76>>2]=ae;ul(ae)}ae=o[a+60>>2];if(ae){o[a- -64>>2]=ae;ul(ae)}ae=o[a+48>>2];if(ae){o[a+52>>2]=ae;ul(ae)}o[a>>2]=9324;ae=o[a+36>>2];if(ae){ul(ae)}ae=o[a+24>>2];if(ae){ul(ae)}return a|0}function wh(a){a=a|0;var ge=0;o[a>>2]=8876;o[a+8>>2]=9088;ge=o[a+96>>2];if(ge){o[a+100>>2]=ge;ul(ge)}ge=o[a+80>>2];if(ge){o[a+84>>2]=ge;ul(ge)}ge=o[a+68>>2];if(ge){o[a+72>>2]=ge;ul(ge)}ge=o[a+56>>2];if(ge){o[a+60>>2]=ge;ul(ge)}o[a+8>>2]=9324;ge=o[a+44>>2];if(ge){ul(ge)}ge=o[a+32>>2];if(ge){ul(ge)}return a|0}function xh(a){a=a|0;var he=0;o[a>>2]=8876;o[a+8>>2]=9088;he=o[a+96>>2];if(he){o[a+100>>2]=he;ul(he)}he=o[a+80>>2];if(he){o[a+84>>2]=he;ul(he)}he=o[a+68>>2];if(he){o[a+72>>2]=he;ul(he)}he=o[a+56>>2];if(he){o[a+60>>2]=he;ul(he)}o[a+8>>2]=9324;he=o[a+44>>2];if(he){ul(he)}he=o[a+32>>2];if(he){ul(he)}ul(a)}function yh(a,ie){a=a|0;ie=ie|0;var je=0,ke=0,le=0,me=0,ne=0,oe=0,pe=0,qe=0,re=0,se=0,te=0;re=o[a+12>>2];je=o[a+108>>2];ke=o[je+80>>2];m[ie+84|0]=0;ne=o[ie+68>>2];le=o[ie+72>>2]-ne>>2;a:{if(ke>>>0>le>>>0){kd(ie+68|0,ke-le|0,9076);je=o[a+108>>2];ke=o[je+80>>2];break a}if(ke>>>0>=le>>>0){break a}o[ie+72>>2]=ne+(ke<<2)}qe=o[je+96>>2];je=o[je+100>>2]-qe|0;se=(je|0)/12|0;if(!je){return 1}te=ie+68|0;ie=0;b:{while(1){c:{if((ie|0)==1431655765){break c}je=o[re>>2]+(u(ie,3)<<2)|0;ne=o[je>>2];if((ne|0)==-1){break c}le=u(ie,12)+qe|0;oe=o[le>>2];if(oe>>>0>=ke>>>0){break c}me=ne<<2;ne=o[o[a+112>>2]+12>>2];me=o[me+ne>>2];if(me>>>0>=ke>>>0){break c}pe=oe<<2;oe=o[te>>2];o[pe+oe>>2]=me;me=o[je+4>>2];if((me|0)==-1){break c}pe=o[le+4>>2];if(pe>>>0>=ke>>>0){break c}me=o[ne+(me<<2)>>2];if(me>>>0>=ke>>>0){break c}o[oe+(pe<<2)>>2]=me;je=o[je+8>>2];if((je|0)==-1){break c}le=o[le+8>>2];if(le>>>0>=ke>>>0){break c}je=o[ne+(je<<2)>>2];if(je>>>0>=ke>>>0){break c}o[oe+(le<<2)>>2]=je;je=1;ie=ie+1|0;if(ie>>>0>>0){continue}break b}break}je=0}return je|0}function zh(a){a=a|0;var ie=0,ue=0,ve=0,we=0,xe=0,ye=0,ze=0,Ae=0,Be=0;xe=R-16|0;R=xe;ue=o[a+4>>2];ie=o[ue>>2];a:{Ae=a+12|0;ve=o[Ae>>2];we=o[ve+28>>2]-o[ve+24>>2]|0;ve=we>>2;b:{if(o[ue+8>>2]-ie>>2>>>0>=ve>>>0){break b}if(ve>>>0>=1073741824){break a}Be=ue+4|0;ye=o[Be>>2];ze=ve<<2;ve=Hk(we);ze=ze+ve|0;we=ye-ie|0;ye=we+ve|0;if((we|0)>=1){wl(ve,ie,we)}o[ue>>2]=ve;o[ue+8>>2]=ze;o[Be>>2]=ye;if(!ie){break b}ul(ie)}ie=o[Ae>>2];ue=o[ie+24>>2];ie=o[ie+28>>2];o[xe+12>>2]=0;ie=ie-ue>>2;ve=a+96|0;we=o[ve>>2];ue=o[a+100>>2]-we>>2;c:{if(ie>>>0>ue>>>0){yd(ve,ie-ue|0,xe+12|0);break c}if(ie>>>0>=ue>>>0){break c}o[a+100>>2]=we+(ie<<2)}we=a+8|0;d:{e:{ie=o[a+116>>2];if(ie){ve=o[ie>>2];ue=1;if((ve|0)==o[ie+4>>2]){break d}ie=0;while(1){if(!Ah(we,o[(ie<<2)+ve>>2])){break e}ue=o[a+116>>2];ve=o[ue>>2];ie=ie+1|0;if(ie>>>0>2]-ve>>2>>>0){continue}break}ue=1;break d}ie=0;a=o[a+12>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;ue=1;if((a|0)<=0){break d}while(1){if(!Ah(we,u(ie,3))){break e}ie=ie+1|0;if(ie>>>0>>0){continue}break}ue=1;break d}ue=0}R=xe+16|0;return ue|0}_a(8776);D()}function Ah(a,Ce){var De=0,Ee=0,Fe=0,Ge=0,He=0,Ie=0,Je=0,Ke=0,Le=0,Me=0,Ne=0,Oe=0,Pe=0;Ge=R-32|0;R=Ge;o[Ge+8>>2]=Ce;a:{if(o[a+92>>2]==o[a+88>>2]){break a}Fe=a+52|0;De=o[Fe>>2];b:{if((De|0)!=o[a+56>>2]){o[De>>2]=Ce;o[Fe>>2]=De+4;break b}bh(a+48|0,Ge+8|0)}o[a+84>>2]=0;Ce=-1;Fe=-1;De=o[Ge+8>>2];c:{if((De|0)==-1){break c}Ee=o[a+4>>2];He=De+1|0;He=(He>>>0)%3|0?He:De+ -2|0;if((He|0)!=-1){Ce=o[o[Ee>>2]+(He<<2)>>2]}De=De+((De>>>0)%3|0?-1:2)|0;if((De|0)==-1){break c}Fe=o[o[Ee>>2]+(De<<2)>>2]}De=o[a+36>>2];Ee=De+(Ce>>>3&536870908)|0;He=o[Ee>>2];Je=1<<(Ce&31);if(!(He&Je)){o[Ee>>2]=He|Je;De=-1;Ee=o[Ge+8>>2];if((Ee|0)!=-1){De=Ee+1|0;De=(De>>>0)%3|0?De:Ee+ -2|0}o[Ge+16>>2]=De;Ee=o[a+20>>2];He=(De>>>0)/3|0;He=o[(o[o[a+16>>2]+96>>2]+u(He,12)|0)+(De-u(He,3)<<2)>>2];o[Ge+24>>2]=He;Ee=o[Ee+4>>2];Je=Ee+4|0;De=o[Je>>2];d:{if((De|0)!=o[Ee+8>>2]){o[De>>2]=He;o[Je>>2]=De+4;break d}bh(Ee,Ge+24|0)}He=a+12|0;De=o[He>>2];Je=De+4|0;Ee=o[Je>>2];e:{if((Ee|0)!=o[De+8>>2]){o[Ee>>2]=o[Ge+16>>2];o[Je>>2]=Ee+4;break e}bh(De,Ge+16|0);De=o[He>>2]}o[o[De+12>>2]+(Ce<<2)>>2]=o[De+24>>2];o[De+24>>2]=o[De+24>>2]+1;De=o[a+36>>2]}Ce=De+(Fe>>>3&536870908)|0;De=o[Ce>>2];Ee=1<<(Fe&31);if(!(De&Ee)){o[Ce>>2]=De|Ee;Ce=Ge;Ke=Ce;Ee=o[Ce+8>>2];De=-1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ge+24>>2]=De;Ee=u(Fe,12)+a|0;Ie=Ee+52|0;Ce=o[Ie>>2];v:{if((Ce|0)!=o[Ee+56>>2]){o[Ce>>2]=De;o[Ie>>2]=Ce+4;break v}bh(Ee+48|0,Ge+24|0)}De=o[a+84>>2];if((De|0)<=(Fe|0)){break l}o[a+84>>2]=Fe;De=Fe;break l}De=o[a+84>>2]}if((De|0)<3){continue}break}}o[Ge+8>>2]=-1}R=Ge+32|0;return 1}function Bh(a){a=a|0;var Ce=0;o[a>>2]=9088;Ce=o[a+88>>2];if(Ce){o[a+92>>2]=Ce;ul(Ce)}Ce=o[a+72>>2];if(Ce){o[a+76>>2]=Ce;ul(Ce)}Ce=o[a+60>>2];if(Ce){o[a- -64>>2]=Ce;ul(Ce)}Ce=o[a+48>>2];if(Ce){o[a+52>>2]=Ce;ul(Ce)}o[a>>2]=9324;Ce=o[a+36>>2];if(Ce){ul(Ce)}Ce=o[a+24>>2];if(Ce){ul(Ce)}ul(a)}function Ch(a){a=a|0;var Qe=0;o[a>>2]=9324;Qe=o[a+36>>2];if(Qe){ul(Qe)}Qe=o[a+24>>2];if(Qe){ul(Qe)}return a|0}function Dh(a){a=a|0;var Re=0;o[a>>2]=9324;Re=o[a+36>>2];if(Re){ul(Re)}Re=o[a+24>>2];if(Re){ul(Re)}ul(a)}function Eh(a){a=a|0;var Se=0;o[a>>2]=9508;Se=o[a+48>>2];if(Se){o[a+52>>2]=Se;ul(Se)}o[a>>2]=9324;Se=o[a+36>>2];if(Se){ul(Se)}Se=o[a+24>>2];if(Se){ul(Se)}return a|0}function Fh(a){a=a|0;var Te=0,Ue=0;o[a>>2]=9344;Ue=a+8|0;o[Ue>>2]=9508;Te=o[a+56>>2];if(Te){o[a+60>>2]=Te;ul(Te)}o[Ue>>2]=9324;Te=o[a+44>>2];if(Te){ul(Te)}Te=o[a+32>>2];if(Te){ul(Te)}return a|0}function Gh(a){a=a|0;var Ve=0,We=0;o[a>>2]=9344;We=a+8|0;o[We>>2]=9508;Ve=o[a+56>>2];if(Ve){o[a+60>>2]=Ve;ul(Ve)}o[We>>2]=9324;Ve=o[a+44>>2];if(Ve){ul(Ve)}Ve=o[a+32>>2];if(Ve){ul(Ve)}ul(a)}function Hh(a,Xe){a=a|0;Xe=Xe|0;var Ye=0,Ze=0,_e=0,$e=0,af=0,bf=0,cf=0,df=0,ef=0,ff=0,gf=0;ef=o[a+12>>2];Ye=o[a+68>>2];Ze=o[Ye+80>>2];m[Xe+84|0]=0;af=o[Xe+68>>2];_e=o[Xe+72>>2]-af>>2;a:{if(Ze>>>0>_e>>>0){kd(Xe+68|0,Ze-_e|0,9076);Ye=o[a+68>>2];Ze=o[Ye+80>>2];break a}if(Ze>>>0>=_e>>>0){break a}o[Xe+72>>2]=af+(Ze<<2)}df=o[Ye+96>>2];Ye=o[Ye+100>>2]-df|0;ff=(Ye|0)/12|0;if(!Ye){return 1}gf=Xe+68|0;Xe=0;b:{while(1){c:{if((Xe|0)==1431655765){break c}Ye=o[ef>>2]+(u(Xe,3)<<2)|0;af=o[Ye>>2];if((af|0)==-1){break c}_e=u(Xe,12)+df|0;bf=o[_e>>2];if(bf>>>0>=Ze>>>0){break c}$e=af<<2;af=o[o[a+72>>2]+12>>2];$e=o[$e+af>>2];if($e>>>0>=Ze>>>0){break c}cf=bf<<2;bf=o[gf>>2];o[cf+bf>>2]=$e;$e=o[Ye+4>>2];if(($e|0)==-1){break c}cf=o[_e+4>>2];if(cf>>>0>=Ze>>>0){break c}$e=o[af+($e<<2)>>2];if($e>>>0>=Ze>>>0){break c}o[bf+(cf<<2)>>2]=$e;Ye=o[Ye+8>>2];if((Ye|0)==-1){break c}_e=o[_e+8>>2];if(_e>>>0>=Ze>>>0){break c}Ye=o[af+(Ye<<2)>>2];if(Ye>>>0>=Ze>>>0){break c}o[bf+(_e<<2)>>2]=Ye;Ye=1;Xe=Xe+1|0;if(Xe>>>0>>0){continue}break b}break}Ye=0}return Ye|0}function Ih(a){a=a|0;var Xe=0,hf=0,jf=0,kf=0,lf=0,mf=0,nf=0;kf=o[a+4>>2];Xe=o[kf>>2];a:{hf=o[a+12>>2];jf=o[hf+28>>2]-o[hf+24>>2]|0;hf=jf>>2;b:{if(o[kf+8>>2]-Xe>>2>>>0>=hf>>>0){break b}if(hf>>>0>=1073741824){break a}nf=kf+4|0;lf=o[nf>>2];mf=hf<<2;hf=Hk(jf);mf=mf+hf|0;jf=lf-Xe|0;lf=jf+hf|0;if((jf|0)>=1){wl(hf,Xe,jf)}o[kf>>2]=hf;o[kf+8>>2]=mf;o[nf>>2]=lf;if(!Xe){break b}ul(Xe)}hf=a+8|0;c:{d:{Xe=o[a+76>>2];if(Xe){kf=o[Xe>>2];jf=1;if((kf|0)==o[Xe+4>>2]){break c}Xe=0;while(1){if(!Jh(hf,o[(Xe<<2)+kf>>2])){break d}jf=o[a+76>>2];kf=o[jf>>2];Xe=Xe+1|0;if(Xe>>>0>2]-kf>>2>>>0){continue}break}return 1}Xe=0;a=o[a+12>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!Jh(hf,u(Xe,3))){break d}Xe=Xe+1|0;if(Xe>>>0>>0){continue}break}return 1}jf=0}return jf|0}_a(8776);D()}function Jh(a,of){var pf=0,qf=0,rf=0,sf=0,tf=0,uf=0,vf=0,wf=0,xf=0,yf=0,zf=0,Af=0,Bf=0,Cf=0,Df=0;tf=R-32|0;R=tf;o[tf+8>>2]=of;a:{if((of|0)==-1){sf=1;break a}sf=1;pf=(of>>>0)/3|0;if(o[o[a+24>>2]+(pf>>>3&268435452)>>2]>>>(pf&31)&1){break a}pf=a+52|0;rf=o[a+48>>2];o[pf>>2]=rf;yf=a+48|0;b:{if((rf|0)!=o[a+56>>2]){o[rf>>2]=of;o[pf>>2]=rf+4;break b}bh(yf,tf+8|0)}sf=-1;rf=o[tf+8>>2];if((rf|0)==-1){sf=0;break a}pf=o[a+4>>2];of=rf+1|0;of=(of>>>0)%3|0?of:rf+ -2|0;if((of|0)!=-1){sf=o[o[pf>>2]+(of<<2)>>2]}of=rf+((rf>>>0)%3|0?-1:2)|0;if((of|0)==-1){sf=0;break a}if((sf|0)==-1){sf=0;break a}uf=o[o[pf>>2]+(of<<2)>>2];if((uf|0)==-1){sf=0;break a}of=o[a+36>>2];qf=of+(sf>>>3&536870908)|0;rf=o[qf>>2];pf=1<<(sf&31);if(!(rf&pf)){o[qf>>2]=pf|rf;qf=-1;pf=o[tf+8>>2];if((pf|0)!=-1){of=pf+1|0;qf=(of>>>0)%3|0?of:pf+ -2|0}o[tf+16>>2]=qf;rf=o[a+20>>2];of=(qf>>>0)/3|0;pf=o[(o[o[a+16>>2]+96>>2]+u(of,12)|0)+(qf-u(of,3)<<2)>>2];o[tf+24>>2]=pf;rf=o[rf+4>>2];of=rf+4|0;qf=o[of>>2];c:{if((qf|0)!=o[rf+8>>2]){o[qf>>2]=pf;o[of>>2]=qf+4;break c}bh(rf,tf+24|0)}pf=a+12|0;qf=o[pf>>2];of=qf+4|0;rf=o[of>>2];d:{if((rf|0)!=o[qf+8>>2]){o[rf>>2]=o[tf+16>>2];o[of>>2]=rf+4;break d}bh(qf,tf+16|0);qf=o[pf>>2]}o[o[qf+12>>2]+(sf<<2)>>2]=o[qf+24>>2];o[qf+24>>2]=o[qf+24>>2]+1;of=o[a+36>>2]}rf=(uf>>>3&536870908)+of|0;pf=o[rf>>2];of=1<<(uf&31);if(!(pf&of)){o[rf>>2]=of|pf;of=tf;rf=of;pf=o[of+8>>2];qf=-1;e:{if((pf|0)==-1){break e}qf=pf+ -1|0;if((pf>>>0)%3){break e}qf=pf+2|0}o[rf+16>>2]=qf;rf=o[a+20>>2];of=(qf>>>0)/3|0;pf=o[(o[o[a+16>>2]+96>>2]+u(of,12)|0)+(qf-u(of,3)<<2)>>2];o[tf+24>>2]=pf;rf=o[rf+4>>2];of=rf+4|0;qf=o[of>>2];f:{if((qf|0)!=o[rf+8>>2]){o[qf>>2]=pf;o[of>>2]=qf+4;break f}bh(rf,tf+24|0)}pf=a+12|0;sf=o[pf>>2];of=sf+4|0;rf=o[of>>2];g:{if((rf|0)!=o[sf+8>>2]){o[rf>>2]=o[tf+16>>2];o[of>>2]=rf+4;break g}bh(sf,tf+16|0);sf=o[pf>>2]}o[o[sf+12>>2]+(uf<<2)>>2]=o[sf+24>>2];o[sf+24>>2]=o[sf+24>>2]+1}wf=a+52|0;of=o[wf>>2];if((of|0)==o[a+48>>2]){sf=1;break a}xf=a+24|0;zf=a+4|0;Af=a+36|0;Bf=a+16|0;Cf=a+20|0;Df=a+56|0;while(1){qf=of+ -4|0;pf=o[qf>>2];o[tf+8>>2]=pf;of=(pf>>>0)/3|0;h:{i:{j:{if((pf|0)==-1){break j}rf=o[xf>>2]+(of>>>3&268435452)|0;pf=o[rf>>2];of=1<<(of&31);if(pf&of){break j}o[rf>>2]=of|pf;of=o[tf+8>>2];if((of|0)!=-1){break i}sf=0;break a}o[wf>>2]=qf;break h}k:{l:{m:{while(1){vf=o[zf>>2];pf=o[o[vf>>2]+(of<<2)>>2];if((pf|0)==-1){sf=0;break a}uf=o[Af>>2]+(pf>>>3&536870908)|0;qf=o[uf>>2];rf=1<<(pf&31);n:{if(!(qf&rf)){sf=pf<<2;pf=o[sf+o[vf+24>>2]>>2];o:{p:{if((pf|0)==-1){break p}of=pf+1|0;of=(of>>>0)%3|0?of:pf+ -2|0;if((of|0)==-1){break p}vf=o[o[vf+12>>2]+(of<<2)>>2];if((vf|0)==-1){break p}of=vf+1|0;pf=0;if((((of>>>0)%3|0?of:vf+ -2|0)|0)!=-1){break o}}pf=1}o[uf>>2]=rf|qf;rf=o[tf+8>>2];o[tf+16>>2]=rf;qf=o[Cf>>2];of=(rf>>>0)/3|0;rf=o[(o[o[Bf>>2]+96>>2]+u(of,12)|0)+(rf-u(of,3)<<2)>>2];o[tf+24>>2]=rf;qf=o[qf+4>>2];of=qf+4|0;uf=o[of>>2];q:{if((uf|0)!=o[qf+8>>2]){o[uf>>2]=rf;o[of>>2]=uf+4;break q}bh(qf,tf+24|0)}qf=a+12|0;of=o[qf>>2];rf=of+4|0;uf=o[rf>>2];r:{if((uf|0)!=o[of+8>>2]){o[uf>>2]=o[tf+16>>2];o[rf>>2]=uf+4;break r}bh(of,tf+16|0);of=o[qf>>2]}o[o[of+12>>2]+sf>>2]=o[of+24>>2];o[of+24>>2]=o[of+24>>2]+1;vf=o[zf>>2];of=o[tf+8>>2];if(!pf){pf=tf;qf=-1;s:{if((of|0)==-1){break s}rf=of+1|0;of=(rf>>>0)%3|0?rf:of+ -2|0;qf=-1;if((of|0)==-1){break s}qf=o[o[vf+12>>2]+(of<<2)>>2]}o[pf+8>>2]=qf;of=(qf>>>0)/3|0;break n}if((of|0)==-1){break l}}qf=-1;sf=-1;pf=of+1|0;pf=(pf>>>0)%3|0?pf:of+ -2|0;if((pf|0)!=-1){sf=o[o[vf+12>>2]+(pf<<2)>>2]}o[tf+24>>2]=sf;of=((of>>>0)%3|0?-1:2)+of|0;if((of|0)!=-1){qf=o[o[vf+12>>2]+(of<<2)>>2]}rf=(qf>>>0)/3|0;of=(sf>>>0)/3|0;pf=(sf|0)==-1;t:{if(pf){of=-1;pf=1;break t}pf=pf?-1:of;pf=o[o[xf>>2]+(pf>>>3&536870908)>>2]>>>(pf&31)&1}u:{if((qf|0)!=-1){uf=(qf|0)==-1?-1:rf;uf=o[o[xf>>2]+(uf>>>3&536870908)>>2]&1<<(uf&31);if(pf){sf=qf;of=rf;if(!uf){break u}break k}if(uf){break u}of=o[wf>>2];o[of+ -4>>2]=qf;if((of|0)==o[Df>>2]){break m}o[of>>2]=o[tf+24>>2];o[wf>>2]=of+4;break h}if(pf){break k}}o[tf+8>>2]=sf}pf=o[xf>>2]+(of>>>3&536870908)|0;o[pf>>2]=o[pf>>2]|1<<(of&31);of=o[tf+8>>2];if((of|0)!=-1){continue}break}sf=0;break a}bh(yf,tf+24|0);break h}o[tf+24>>2]=-1}o[wf>>2]=o[wf>>2]+ -4}sf=1;of=o[wf>>2];if((of|0)!=o[a+48>>2]){continue}break}}R=tf+32|0;return sf}function Kh(a){a=a|0;var of=0;o[a>>2]=9508;of=o[a+48>>2];if(of){o[a+52>>2]=of;ul(of)}o[a>>2]=9324;of=o[a+36>>2];if(of){ul(of)}of=o[a+24>>2];if(of){ul(of)}ul(a)}function Lh(a){a=a|0;var Ef=0,Ff=0;o[a>>2]=9636;Ff=a+8|0;o[Ff>>2]=8512;Ef=o[a+56>>2];if(Ef){o[a+60>>2]=Ef;ul(Ef)}o[Ff>>2]=8764;Ef=o[a+44>>2];if(Ef){ul(Ef)}Ef=o[a+32>>2];if(Ef){ul(Ef)}return a|0}function Mh(a){a=a|0;var Gf=0,Hf=0;o[a>>2]=9636;Hf=a+8|0;o[Hf>>2]=8512;Gf=o[a+56>>2];if(Gf){o[a+60>>2]=Gf;ul(Gf)}o[Hf>>2]=8764;Gf=o[a+44>>2];if(Gf){ul(Gf)}Gf=o[a+32>>2];if(Gf){ul(Gf)}ul(a)}function Nh(a,If){a=a|0;If=If|0;var Jf=0,Kf=0,Lf=0,Mf=0,Nf=0,Of=0,Pf=0,Qf=0,Rf=0,Sf=0,Tf=0;Of=o[a+12>>2];Jf=o[a+68>>2];Kf=o[Jf+80>>2];m[If+84|0]=0;Nf=o[If+68>>2];Lf=o[If+72>>2]-Nf>>2;a:{if(Kf>>>0>Lf>>>0){kd(If+68|0,Kf-Lf|0,9076);Jf=o[a+68>>2];Kf=o[Jf+80>>2];break a}if(Kf>>>0>=Lf>>>0){break a}o[If+72>>2]=Nf+(Kf<<2)}Qf=o[Jf+96>>2];Jf=o[Jf+100>>2]-Qf|0;Rf=(Jf|0)/12|0;if(!Jf){return 1}Sf=o[Of+28>>2];Tf=If+68|0;If=0;b:{while(1){c:{Jf=(u(If,3)<<2)+Sf|0;Of=o[Jf>>2];if((Of|0)==-1){break c}Lf=u(If,12)+Qf|0;Nf=o[Lf>>2];if(Nf>>>0>=Kf>>>0){break c}Mf=Of<<2;Of=o[o[a+72>>2]+12>>2];Mf=o[Mf+Of>>2];if(Mf>>>0>=Kf>>>0){break c}Pf=Nf<<2;Nf=o[Tf>>2];o[Pf+Nf>>2]=Mf;Mf=o[Jf+4>>2];if((Mf|0)==-1){break c}Pf=o[Lf+4>>2];if(Pf>>>0>=Kf>>>0){break c}Mf=o[Of+(Mf<<2)>>2];if(Mf>>>0>=Kf>>>0){break c}o[Nf+(Pf<<2)>>2]=Mf;Jf=o[Jf+8>>2];if((Jf|0)==-1){break c}Lf=o[Lf+8>>2];if(Lf>>>0>=Kf>>>0){break c}Jf=o[Of+(Jf<<2)>>2];if(Jf>>>0>=Kf>>>0){break c}o[Nf+(Lf<<2)>>2]=Jf;Jf=1;If=If+1|0;if(If>>>0>>0){continue}break b}break}Jf=0}return Jf|0}function Oh(a){a=a|0;var If=0,Uf=0,Vf=0,Wf=0,Xf=0,Yf=0,Zf=0;Wf=o[a+4>>2];If=o[Wf>>2];a:{Uf=o[a+12>>2];Vf=o[Uf+56>>2]-o[Uf+52>>2]|0;Uf=Vf>>2;b:{if(o[Wf+8>>2]-If>>2>>>0>=Uf>>>0){break b}if(Uf>>>0>=1073741824){break a}Zf=Wf+4|0;Xf=o[Zf>>2];Yf=Uf<<2;Uf=Hk(Vf);Yf=Yf+Uf|0;Vf=Xf-If|0;Xf=Vf+Uf|0;if((Vf|0)>=1){wl(Uf,If,Vf)}o[Wf>>2]=Uf;o[Wf+8>>2]=Yf;o[Zf>>2]=Xf;if(!If){break b}ul(If)}Uf=a+8|0;c:{d:{If=o[a+76>>2];if(If){Wf=o[If>>2];Vf=1;if((Wf|0)==o[If+4>>2]){break c}If=0;while(1){if(!Ph(Uf,o[(If<<2)+Wf>>2])){break d}Vf=o[a+76>>2];Wf=o[Vf>>2];If=If+1|0;if(If>>>0>2]-Wf>>2>>>0){continue}break}return 1}If=0;a=o[o[a+12>>2]+64>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!Ph(Uf,u(If,3))){break d}If=If+1|0;if(If>>>0>>0){continue}break}return 1}Vf=0}return Vf|0}_a(8776);D()}function Ph(a,_f){var $f=0,ag=0,bg=0,cg=0,dg=0,eg=0,fg=0,gg=0,hg=0,ig=0,jg=0,kg=0,lg=0,mg=0,ng=0;dg=R-32|0;R=dg;o[dg+8>>2]=_f;a:{if((_f|0)==-1){$f=1;break a}$f=1;cg=(_f>>>0)/3|0;if(o[o[a+24>>2]+(cg>>>3&268435452)>>2]>>>(cg&31)&1){break a}cg=a+52|0;$f=o[a+48>>2];o[cg>>2]=$f;ig=a+48|0;b:{if(($f|0)!=o[a+56>>2]){o[$f>>2]=_f;o[cg>>2]=$f+4;break b}bh(ig,dg+8|0)}ag=-1;$f=o[a+4>>2];_f=o[dg+8>>2];c:{if((_f|0)==-1){cg=o[$f+28>>2];$f=o[cg+ -4>>2];break c}cg=o[$f+28>>2];$f=_f+1|0;$f=o[cg+((($f>>>0)%3|0?$f:_f+ -2|0)<<2)>>2];if((_f>>>0)%3){ag=_f+ -1|0;break c}ag=_f+2|0}if(($f|0)==-1){$f=0;break a}cg=o[(ag<<2)+cg>>2];if((cg|0)==-1){$f=0;break a}_f=o[a+36>>2];bg=_f+($f>>>3&536870908)|0;ag=o[bg>>2];eg=1<<($f&31);if(!(ag&eg)){o[bg>>2]=ag|eg;ag=-1;_f=o[dg+8>>2];if((_f|0)!=-1){bg=_f+1|0;ag=(bg>>>0)%3|0?bg:_f+ -2|0}o[dg+16>>2]=ag;_f=o[a+20>>2];bg=(ag>>>0)/3|0;ag=o[(o[o[a+16>>2]+96>>2]+u(bg,12)|0)+(ag-u(bg,3)<<2)>>2];o[dg+24>>2]=ag;bg=o[_f+4>>2];eg=bg+4|0;_f=o[eg>>2];d:{if((_f|0)!=o[bg+8>>2]){o[_f>>2]=ag;o[eg>>2]=_f+4;break d}bh(bg,dg+24|0)}bg=a+12|0;ag=o[bg>>2];eg=ag+4|0;_f=o[eg>>2];e:{if((_f|0)!=o[ag+8>>2]){o[_f>>2]=o[dg+16>>2];o[eg>>2]=_f+4;break e}bh(ag,dg+16|0);ag=o[bg>>2]}o[o[ag+12>>2]+($f<<2)>>2]=o[ag+24>>2];o[ag+24>>2]=o[ag+24>>2]+1;_f=o[a+36>>2]}_f=(cg>>>3&536870908)+_f|0;$f=o[_f>>2];bg=1<<(cg&31);if(!($f&bg)){o[_f>>2]=$f|bg;_f=dg;ag=_f;bg=o[_f+8>>2];$f=-1;f:{if((bg|0)==-1){break f}$f=bg+ -1|0;if((bg>>>0)%3){break f}$f=bg+2|0}o[ag+16>>2]=$f;_f=o[a+20>>2];bg=($f>>>0)/3|0;bg=o[(o[o[a+16>>2]+96>>2]+u(bg,12)|0)+($f-u(bg,3)<<2)>>2];o[dg+24>>2]=bg;$f=o[_f+4>>2];ag=$f+4|0;_f=o[ag>>2];g:{if((_f|0)!=o[$f+8>>2]){o[_f>>2]=bg;o[ag>>2]=_f+4;break g}bh($f,dg+24|0)}bg=a+12|0;$f=o[bg>>2];ag=$f+4|0;_f=o[ag>>2];h:{if((_f|0)!=o[$f+8>>2]){o[_f>>2]=o[dg+16>>2];o[ag>>2]=_f+4;break h}bh($f,dg+16|0);$f=o[bg>>2]}o[o[$f+12>>2]+(cg<<2)>>2]=o[$f+24>>2];o[$f+24>>2]=o[$f+24>>2]+1}eg=a+52|0;_f=o[eg>>2];if((_f|0)==o[a+48>>2]){$f=1;break a}gg=a+24|0;hg=a+4|0;kg=a+36|0;lg=a+16|0;mg=a+20|0;ng=a+56|0;while(1){cg=_f+ -4|0;_f=o[cg>>2];o[dg+8>>2]=_f;$f=(_f>>>0)/3|0;i:{j:{k:{if((_f|0)==-1){break k}_f=o[gg>>2]+($f>>>3&268435452)|0;bg=o[_f>>2];$f=1<<($f&31);if(bg&$f){break k}o[_f>>2]=$f|bg;ag=o[hg>>2];_f=o[dg+8>>2];$f=o[o[ag+28>>2]+(_f<<2)>>2];if(($f|0)!=-1){break j}$f=0;break a}o[eg>>2]=cg;break i}l:{m:{n:{while(1){o:{p:{cg=o[kg>>2]+($f>>>3&536870908)|0;bg=o[cg>>2];fg=1<<($f&31);if(bg&fg){break p}jg=$f<<2;$f=o[jg+o[ag+40>>2]>>2];_f=1;q:{if(($f|0)==-1){break q}_f=$f+1|0;_f=(_f>>>0)%3|0?_f:$f+ -2|0;r:{if((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1){break r}$f=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2];if(($f|0)==-1){break r}ag=$f+1|0;_f=0;if((((ag>>>0)%3|0?ag:$f+ -2|0)|0)!=-1){break q}}_f=1}$f=_f;o[cg>>2]=bg|fg;_f=o[dg+8>>2];o[dg+16>>2]=_f;cg=o[mg>>2];bg=(_f>>>0)/3|0;bg=o[(o[o[lg>>2]+96>>2]+u(bg,12)|0)+(_f-u(bg,3)<<2)>>2];o[dg+24>>2]=bg;cg=o[cg+4>>2];ag=cg+4|0;_f=o[ag>>2];s:{if((_f|0)!=o[cg+8>>2]){o[_f>>2]=bg;o[ag>>2]=_f+4;break s}bh(cg,dg+24|0)}bg=a+12|0;_f=o[bg>>2];ag=_f+4|0;cg=o[ag>>2];t:{if((cg|0)!=o[_f+8>>2]){o[cg>>2]=o[dg+16>>2];o[ag>>2]=cg+4;break t}bh(_f,dg+16|0);_f=o[bg>>2]}o[o[_f+12>>2]+jg>>2]=o[_f+24>>2];o[_f+24>>2]=o[_f+24>>2]+1;ag=o[hg>>2];_f=o[dg+8>>2];if($f){break p}$f=-1;u:{if((_f|0)==-1){break u}cg=_f+1|0;_f=(cg>>>0)%3|0?cg:_f+ -2|0;if((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1){break u}$f=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2]}o[dg+8>>2]=$f;_f=($f>>>0)/3|0;break o}if((_f|0)==-1){break m}cg=-1;bg=dg;fg=_f+1|0;fg=(fg>>>0)%3|0?fg:_f+ -2|0;$f=-1;v:{if((fg|0)==-1){break v}$f=-1;if(o[o[ag>>2]+(fg>>>3&536870908)>>2]>>>(fg&31)&1){break v}$f=o[o[o[ag+64>>2]+12>>2]+(fg<<2)>>2]}o[bg+24>>2]=$f;_f=((_f>>>0)%3|0?-1:2)+_f|0;if(!((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1)){cg=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2]}bg=(cg>>>0)/3|0;_f=($f>>>0)/3|0;ag=($f|0)==-1;w:{if(ag){_f=-1;ag=1;break w}ag=ag?-1:_f;ag=o[o[gg>>2]+(ag>>>3&536870908)>>2]>>>(ag&31)&1}x:{if((cg|0)!=-1){fg=(cg|0)==-1?-1:bg;fg=o[o[gg>>2]+(fg>>>3&536870908)>>2]&1<<(fg&31);if(ag){$f=cg;_f=bg;if(!fg){break x}break l}if(fg){break x}_f=o[eg>>2];o[_f+ -4>>2]=cg;if((_f|0)==o[ng>>2]){break n}o[_f>>2]=o[dg+24>>2];o[eg>>2]=_f+4;break i}if(ag){break l}}o[dg+8>>2]=$f}$f=o[gg>>2]+(_f>>>3&536870908)|0;o[$f>>2]=o[$f>>2]|1<<(_f&31);ag=o[hg>>2];_f=o[dg+8>>2];$f=o[o[ag+28>>2]+(_f<<2)>>2];if(($f|0)!=-1){continue}break}$f=0;break a}bh(ig,dg+24|0);break i}o[dg+24>>2]=-1}o[eg>>2]=o[eg>>2]+ -4}$f=1;_f=o[eg>>2];if((_f|0)!=o[a+48>>2]){continue}break}}R=dg+32|0;return $f}function Qh(a,_f){var og=0,pg=0,qg=0;o[a>>2]=o[_f>>2];o[a+4>>2]=o[_f+4>>2];o[a+8>>2]=o[_f+8>>2];og=_f+12|0;o[a+12>>2]=o[og>>2];o[og>>2]=0;o[_f+4>>2]=0;o[_f+8>>2]=0;og=_f+16|0;o[a+16>>2]=o[og>>2];o[a+20>>2]=o[_f+20>>2];pg=_f+24|0;o[a+24>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=p[_f+28|0];qg=a+40|0;o[qg>>2]=0;og=a+32|0;o[og>>2]=0;o[og+4>>2]=0;m[a+28|0]=pg;pg=og;og=_f+32|0;o[pg>>2]=o[og>>2];o[a+36>>2]=o[_f+36>>2];pg=_f+40|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a+52|0;o[pg>>2]=0;og=a+44|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+44|0;o[qg>>2]=o[og>>2];o[a+48>>2]=o[_f+48>>2];qg=pg;pg=_f+52|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a- -64|0;o[pg>>2]=0;og=a+56|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+56|0;o[qg>>2]=o[og>>2];o[a+60>>2]=o[_f+60>>2];qg=pg;pg=_f- -64|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;o[a+68>>2]=o[_f+68>>2];pg=o[_f+72>>2];qg=a+84|0;o[qg>>2]=0;og=a+76|0;o[og>>2]=0;o[og+4>>2]=0;o[a+72>>2]=pg;pg=og;og=_f+76|0;o[pg>>2]=o[og>>2];o[a+80>>2]=o[_f+80>>2];pg=_f+84|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a+96|0;o[pg>>2]=0;og=a+88|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+88|0;o[qg>>2]=o[og>>2];o[a+92>>2]=o[_f+92>>2];qg=pg;pg=_f+96|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;og=p[_f+100|0];pg=a+112|0;o[pg>>2]=0;o[a+104>>2]=0;o[a+108>>2]=0;m[a+100|0]=og;o[a+104>>2]=o[_f+104>>2];o[a+108>>2]=o[_f+108>>2];og=_f+112|0;o[pg>>2]=o[og>>2];o[og>>2]=0;o[_f+104>>2]=0;o[_f+108>>2]=0;pg=a+124|0;o[pg>>2]=0;og=a+116|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+116|0;o[qg>>2]=o[og>>2];o[a+120>>2]=o[_f+120>>2];qg=pg;pg=_f+124|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;og=o[_f+128>>2];pg=a+140|0;o[pg>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+128>>2]=og;o[a+132>>2]=o[_f+132>>2];o[a+136>>2]=o[_f+136>>2];og=_f+140|0;o[pg>>2]=o[og>>2];o[og>>2]=0;o[_f+132>>2]=0;o[_f+136>>2]=0;return a}function Rh(a){var _f=0,rg=0,sg=0;rg=o[a+8>>2];sg=o[a+4>>2];if((rg|0)!=(sg|0)){while(1){_f=rg+ -144|0;o[a+8>>2]=_f;_f=o[_f+132>>2];if(_f){o[rg+ -8>>2]=_f;ul(_f)}_f=o[rg+ -28>>2];if(_f){o[rg+ -24>>2]=_f;ul(_f)}_f=o[rg+ -40>>2];if(_f){o[rg+ -36>>2]=_f;ul(_f)}Ug(rg+ -140|0);rg=o[a+8>>2];if((sg|0)!=(rg|0)){continue}break}}a=o[a>>2];if(a){ul(a)}}function Sh(a,tg){var ug=0,vg=0,wg=v(0);ug=2;a:{if((tg|0)==1){break a}ug=tg;if(!(tg+ -1&tg)){break a}ug=ek(tg)}vg=o[a+4>>2];if(ug>>>0>vg>>>0){Th(a,ug);return}b:{if(ug>>>0>=vg>>>0){break b}wg=v(B(v(v(r[a+12>>2])/s[a+16>>2])));c:{if(wg=v(0)){tg=~~wg>>>0;break c}tg=0}d:{e:{if(vg>>>0<3){break e}if(Yl(vg)>>>0>1){break e}tg=tg>>>0<2?tg:1<<32-x(tg+ -1|0);break d}tg=ek(tg)}tg=ug>>>0>>0?tg:ug;if(tg>>>0>=vg>>>0){break b}Th(a,tg)}}function Th(a,tg){var xg=0,yg=0,zg=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0;a:{b:{if(tg){if(tg>>>0>=1073741824){break a}xg=Hk(tg<<2);yg=o[a>>2];o[a>>2]=xg;if(yg){ul(yg)}o[a+4>>2]=tg;xg=0;while(1){o[o[a>>2]+(xg<<2)>>2]=0;xg=xg+1|0;if((xg|0)!=(tg|0)){continue}break}yg=a+8|0;Ag=o[yg>>2];if(!Ag){break b}Bg=o[Ag+4>>2];xg=Yl(tg);c:{if(xg>>>0<=1){Bg=tg+ -1&Bg;break c}if(Bg>>>0>>0){break c}Bg=(Bg>>>0)%(tg>>>0)|0}o[o[a>>2]+(Bg<<2)>>2]=yg;yg=o[Ag>>2];if(!yg){break b}Eg=tg+ -1|0;Fg=xg>>>0>1;while(1){zg=o[yg+4>>2];d:{if(!Fg){zg=zg&Eg;break d}if(zg>>>0>>0){break d}zg=(zg>>>0)%(tg>>>0)|0}e:{if((zg|0)==(Bg|0)){Ag=yg;break e}xg=yg;Cg=zg<<2;Dg=Cg+o[a>>2]|0;if(!o[Dg>>2]){o[Dg>>2]=Ag;Ag=yg;Bg=zg;break e}while(1){zg=xg;xg=o[xg>>2];if(o[yg+8>>2]==o[xg+8>>2]?xg:0){continue}break}o[Ag>>2]=xg;o[zg>>2]=o[o[o[a>>2]+Cg>>2]>>2];o[o[o[a>>2]+Cg>>2]>>2]=yg}yg=o[Ag>>2];if(yg){continue}break}break b}tg=o[a>>2];o[a>>2]=0;if(tg){ul(tg)}o[a+4>>2]=0}return}_a(8776);D()}function Uh(a){a=a|0;var tg=0,Gg=0,Hg=0,Ig=0,Jg=0,Kg=0,Lg=0,Mg=0,Ng=0,Og=0,Pg=0,Qg=0,Rg=0,Sg=0,Tg=0,Ug=0,Vg=0,Wg=0;Hg=R-32|0;R=Hg;Gg=a+32|0;a:{if(!Vh(1,Hg+28|0,o[Gg>>2])){break a}if(!Vh(1,Hg+24|0,o[Gg>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if(!_f(dh,1,o[a+32>>2],eh)){break b}ch=1;if(!Xg){break b}hh=a+44|0;eh=0;while(1){dh=Yg+8|0;o[dh>>2]=0;o[Yg>>2]=0;o[Yg+4>>2]=0;a=o[Yg+16>>2]+(eh<<2)|0;bh=o[a>>2];ch=bh>>>1;bh=(bh&1?0-ch|0:ch)+fh|0;o[Yg>>2]=bh;ch=o[a+4>>2];fh=ch>>>1;bh=bh+(ch&1?0-fh|0:fh)|0;o[Yg+4>>2]=bh;a=o[a+8>>2];ch=a>>>1;fh=bh+(a&1?0-ch|0:ch)|0;o[dh>>2]=fh;bh=o[hh>>2];ch=bh+100|0;a=o[ch>>2];c:{if((a|0)!=o[bh+104>>2]){bh=o[Yg+4>>2];o[a>>2]=o[Yg>>2];o[a+4>>2]=bh;o[a+8>>2]=o[dh>>2];o[ch>>2]=o[ch>>2]+12;break c}Xh(bh+96|0,Yg)}eh=eh+3|0;ch=1;gh=gh+1|0;if((gh|0)!=(Xg|0)){continue}break}}a=o[Yg+16>>2];if(a){o[Yg+20>>2]=a;ul(a)}R=Yg+32|0;return ch}Yk();D()}function Xh(a,Xg){var kh=0,lh=0,mh=0,nh=0,oh=0,ph=0;a:{nh=o[a>>2];oh=o[a+4>>2]-nh|0;kh=(oh|0)/12|0;lh=kh+1|0;if(lh>>>0<357913942){ph=u(kh,12);mh=(o[a+8>>2]-nh|0)/12|0;kh=mh<<1;mh=mh>>>0<178956970?kh>>>0>>0?lh:kh:357913941;kh=0;b:{if(!mh){break b}if(mh>>>0>=357913942){break a}kh=Hk(u(mh,12))}lh=ph+kh|0;ph=o[Xg+4>>2];o[lh>>2]=o[Xg>>2];o[lh+4>>2]=ph;o[lh+8>>2]=o[Xg+8>>2];Xg=lh+u((oh|0)/-12|0,12)|0;kh=kh+u(mh,12)|0;lh=lh+12|0;if((oh|0)>=1){wl(Xg,nh,oh)}o[a>>2]=Xg;o[a+8>>2]=kh;o[a+4>>2]=lh;if(nh){ul(nh)}return}Yk();D()}_a(9912);D()}function Yh(a,Xg){a=a|0;Xg=Xg|0;var qh=0,rh=0,sh=0,th=0,uh=0,vh=0,wh=0;th=R-16|0;R=th;uh=Hk(64);qh=Hk(12);o[qh+8>>2]=o[o[a+4>>2]+80>>2];o[qh>>2]=9988;o[qh+4>>2]=0;o[th+8>>2]=qh;Qd(uh,th+8|0);a:{if((Xg|0)>=0){qh=o[a+12>>2];vh=a+8|0;wh=o[vh>>2];rh=qh-wh>>2;b:{if((rh|0)>(Xg|0)){break b}sh=Xg+1|0;if(rh>>>0<=Xg>>>0){Og(vh,sh-rh|0);break b}if(sh>>>0>=rh>>>0){break b}sh=wh+(sh<<2)|0;if((sh|0)!=(qh|0)){while(1){qh=qh+ -4|0;rh=o[qh>>2];o[qh>>2]=0;if(rh){l[o[o[rh>>2]+4>>2]](rh)}if((qh|0)!=(sh|0)){continue}break}}o[a+12>>2]=sh}Xg=o[vh>>2]+(Xg<<2)|0;a=o[Xg>>2];o[Xg>>2]=uh;rh=1;if(!a){break a}l[o[o[a>>2]+4>>2]](a);break a}l[o[o[uh>>2]+4>>2]](uh)}a=o[th+8>>2];o[th+8>>2]=0;if(a){l[o[o[a>>2]+4>>2]](a)}R=th+16|0;return rh|0}function Zh(a){a=a|0;var Xg=0,xh=0,yh=0,zh=0,Ah=0;o[a>>2]=10052;Xg=o[a+20>>2];if(Xg){o[a+24>>2]=Xg;ul(Xg)}yh=o[a+8>>2];if(yh){Xg=yh;Ah=a+12|0;xh=o[Ah>>2];zh=Xg;a:{if((Xg|0)==(xh|0)){break a}while(1){xh=xh+ -4|0;Xg=o[xh>>2];o[xh>>2]=0;if(Xg){l[o[o[Xg>>2]+4>>2]](Xg)}if((xh|0)!=(yh|0)){continue}break}zh=o[a+8>>2]}Xg=zh;o[Ah>>2]=yh;ul(Xg)}ul(a)}function _h(a,Bh){a=a|0;Bh=Bh|0;m[Bh+84|0]=1;o[Bh+72>>2]=o[Bh+68>>2];return 1}function $h(a){a=a|0;var Bh=0,Ch=0,Dh=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+8>>2]=-2147483584;m[bi+50|0]=0;fi=p[10225]|p[10226]<<8;m[bi+48|0]=fi;m[bi+49|0]=fi>>>8;fi=p[10221]|p[10222]<<8|(p[10223]<<16|p[10224]<<24);gi=p[10217]|p[10218]<<8|(p[10219]<<16|p[10220]<<24);m[bi+40|0]=gi;m[bi+41|0]=gi>>>8;m[bi+42|0]=gi>>>16;m[bi+43|0]=gi>>>24;m[bi+44|0]=fi;m[bi+45|0]=fi>>>8;m[bi+46|0]=fi>>>16;m[bi+47|0]=fi>>>24;fi=p[10213]|p[10214]<<8|(p[10215]<<16|p[10216]<<24);gi=p[10209]|p[10210]<<8|(p[10211]<<16|p[10212]<<24);m[bi+32|0]=gi;m[bi+33|0]=gi>>>8;m[bi+34|0]=gi>>>16;m[bi+35|0]=gi>>>24;m[bi+36|0]=fi;m[bi+37|0]=fi>>>8;m[bi+38|0]=fi>>>16;m[bi+39|0]=fi>>>24;fi=p[10205]|p[10206]<<8|(p[10207]<<16|p[10208]<<24);gi=p[10201]|p[10202]<<8|(p[10203]<<16|p[10204]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10197]|p[10198]<<8|(p[10199]<<16|p[10200]<<24);gi=p[10193]|p[10194]<<8|(p[10195]<<16|p[10196]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10189]|p[10190]<<8|(p[10191]<<16|p[10192]<<24);gi=p[10185]|p[10186]<<8|(p[10187]<<16|p[10188]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10181]|p[10182]<<8|(p[10183]<<16|p[10184]<<24);gi=p[10177]|p[10178]<<8|(p[10179]<<16|p[10180]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}fi=p[hi+21|0];m[bi+36|0]=fi;ii=p[hi+22|0];m[bi+37|0]=ii;if((fi+ -1&255)>>>0>=2){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=22;o[hi+8>>2]=-2147483616;m[bi+22|0]=0;fi=p[10246]|p[10247]<<8|(p[10248]<<16|p[10249]<<24);gi=p[10242]|p[10243]<<8|(p[10244]<<16|p[10245]<<24);m[bi+14|0]=gi;m[bi+15|0]=gi>>>8;m[bi+16|0]=gi>>>16;m[bi+17|0]=gi>>>24;m[bi+18|0]=fi;m[bi+19|0]=fi>>>8;m[bi+20|0]=fi>>>16;m[bi+21|0]=fi>>>24;fi=p[10240]|p[10241]<<8|(p[10242]<<16|p[10243]<<24);gi=p[10236]|p[10237]<<8|(p[10238]<<16|p[10239]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10232]|p[10233]<<8|(p[10234]<<16|p[10235]<<24);gi=p[10228]|p[10229]<<8|(p[10230]<<16|p[10231]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-5;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!((fi|0)!=2|(gi?2:3)>>>0>=ii>>>0)){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=22;o[hi+8>>2]=-2147483616;m[bi+22|0]=0;fi=p[10269]|p[10270]<<8|(p[10271]<<16|p[10272]<<24);gi=p[10265]|p[10266]<<8|(p[10267]<<16|p[10268]<<24);m[bi+14|0]=gi;m[bi+15|0]=gi>>>8;m[bi+16|0]=gi>>>16;m[bi+17|0]=gi>>>24;m[bi+18|0]=fi;m[bi+19|0]=fi>>>8;m[bi+20|0]=fi>>>16;m[bi+21|0]=fi>>>24;fi=p[10263]|p[10264]<<8|(p[10265]<<16|p[10266]<<24);gi=p[10259]|p[10260]<<8|(p[10261]<<16|p[10262]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10255]|p[10256]<<8|(p[10257]<<16|p[10258]<<24);gi=p[10251]|p[10252]<<8|(p[10253]<<16|p[10254]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-5;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}fi=fi<<8|ii;n[o[bi+32>>2]+38>>1]=fi;b:{if((fi&65535)>>>0<259|n[hi+26>>1]>-1){break b}di(a,bi);if(o[a>>2]){break a}if(m[ei+11|0]>-1){break b}ul(o[ei>>2])}if(!l[o[o[bi>>2]+12>>2]](bi)){bi=Hk(48);o[hi>>2]=bi;o[hi+4>>2]=33;o[hi+8>>2]=-2147483600;m[bi+33|0]=0;m[bi+32|0]=p[10306];fi=p[10302]|p[10303]<<8|(p[10304]<<16|p[10305]<<24);gi=p[10298]|p[10299]<<8|(p[10300]<<16|p[10301]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10294]|p[10295]<<8|(p[10296]<<16|p[10297]<<24);gi=p[10290]|p[10291]<<8|(p[10292]<<16|p[10293]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10286]|p[10287]<<8|(p[10288]<<16|p[10289]<<24);gi=p[10282]|p[10283]<<8|(p[10284]<<16|p[10285]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10278]|p[10279]<<8|(p[10280]<<16|p[10281]<<24);gi=p[10274]|p[10275]<<8|(p[10276]<<16|p[10277]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!l[o[o[bi>>2]+20>>2]](bi)){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=31;o[hi+8>>2]=-2147483616;m[bi+31|0]=0;fi=p[10335]|p[10336]<<8|(p[10337]<<16|p[10338]<<24);gi=p[10331]|p[10332]<<8|(p[10333]<<16|p[10334]<<24);m[bi+23|0]=gi;m[bi+24|0]=gi>>>8;m[bi+25|0]=gi>>>16;m[bi+26|0]=gi>>>24;m[bi+27|0]=fi;m[bi+28|0]=fi>>>8;m[bi+29|0]=fi>>>16;m[bi+30|0]=fi>>>24;fi=p[10328]|p[10329]<<8|(p[10330]<<16|p[10331]<<24);gi=p[10324]|p[10325]<<8|(p[10326]<<16|p[10327]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10320]|p[10321]<<8|(p[10322]<<16|p[10323]<<24);gi=p[10316]|p[10317]<<8|(p[10318]<<16|p[10319]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10312]|p[10313]<<8|(p[10314]<<16|p[10315]<<24);gi=p[10308]|p[10309]<<8|(p[10310]<<16|p[10311]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!l[o[o[bi>>2]+24>>2]](bi)){bi=Hk(48);o[hi>>2]=bi;o[hi+4>>2]=34;o[hi+8>>2]=-2147483600;m[bi+34|0]=0;fi=p[10372]|p[10373]<<8;m[bi+32|0]=fi;m[bi+33|0]=fi>>>8;fi=p[10368]|p[10369]<<8|(p[10370]<<16|p[10371]<<24);gi=p[10364]|p[10365]<<8|(p[10366]<<16|p[10367]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10360]|p[10361]<<8|(p[10362]<<16|p[10363]<<24);gi=p[10356]|p[10357]<<8|(p[10358]<<16|p[10359]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10352]|p[10353]<<8|(p[10354]<<16|p[10355]<<24);gi=p[10348]|p[10349]<<8|(p[10350]<<16|p[10351]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10344]|p[10345]<<8|(p[10346]<<16|p[10347]<<24);gi=p[10340]|p[10341]<<8|(p[10342]<<16|p[10343]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0}R=hi+32|0}function gi(a){a=a|0;var bi=0,ci=0,di=0,ei=0,fi=0,gi=0,ji=0,ki=0,li=0,mi=0,ni=0,oi=0;a:{bi=o[a+32>>2];ei=o[bi+16>>2];gi=o[bi+12>>2];di=o[bi+20>>2];b:{if((gi|0)<(di|0)?1:(gi|0)<=(di|0)?r[bi+8>>2]>ei>>>0?0:1:0){break b}fi=p[ei+o[bi>>2]|0];ji=ei+1|0;if(ji>>>0<1){di=di+1|0}o[bi+16>>2]=ji;o[bi+20>>2]=di;c:{if(!fi){break c}while(1){if(l[o[o[a>>2]+16>>2]](a,ci)){ci=ci+1|0;if((fi|0)!=(ci|0)){continue}break c}break}return 0}ci=o[a+8>>2];di=o[a+12>>2];if((ci|0)!=(di|0)){while(1){bi=o[ci>>2];if(!l[o[o[bi>>2]+8>>2]](bi,a,o[a+4>>2])){break b}ci=ci+4|0;if((di|0)!=(ci|0)){continue}break}}d:{if(!fi){break d}ci=0;di=a+8|0;while(1){bi=o[o[di>>2]+(ci<<2)>>2];if(!l[o[o[bi>>2]+12>>2]](bi,o[a+32>>2])){break a}ci=ci+1|0;if((fi|0)!=(ci|0)){continue}break}if(!fi){break d}ei=a+20|0;ki=a+8|0;gi=a+24|0;while(1){ci=0;ji=li<<2;bi=o[ji+o[ki>>2]>>2];di=l[o[o[bi>>2]+24>>2]](bi)|0;if((di|0)>0){while(1){bi=o[o[ki>>2]+ji>>2];bi=l[o[o[bi>>2]+20>>2]](bi,ci)|0;mi=o[a+20>>2];ni=o[gi>>2]-mi>>2;e:{if(bi>>>0>>0){break e}oi=bi+1|0;if(oi>>>0>ni>>>0){Da(ei,oi-ni|0);mi=o[ei>>2];break e}if(oi>>>0>=ni>>>0){break e}o[gi>>2]=(oi<<2)+mi}o[(bi<<2)+mi>>2]=li;ci=ci+1|0;if((di|0)!=(ci|0)){continue}break}}li=li+1|0;if((li|0)!=(fi|0)){continue}break}}ki=0;if(!l[o[o[a>>2]+28>>2]](a)){break b}ki=l[o[o[a>>2]+32>>2]](a)|0}return ki|0}return 0}function hi(a){a=a|0;var pi=0,qi=0,ri=0,si=0;qi=1;pi=o[a+8>>2];ri=o[a+12>>2];a:{if((pi|0)==(ri|0)){break a}while(1){si=o[pi>>2];if(l[o[o[si>>2]+16>>2]](si,o[a+32>>2])){pi=pi+4|0;if((ri|0)!=(pi|0)){continue}break a}break}qi=0}return qi|0}function ii(a,ti){var ui=0,vi=0;a:{if((ti|0)<0){break a}ui=o[a+4>>2];if(o[ui+12>>2]-o[ui+8>>2]>>2<=(ti|0)){break a}a=o[o[a+8>>2]+(o[o[a+20>>2]+(ti<<2)>>2]<<2)>>2];vi=l[o[o[a>>2]+32>>2]](a,ti)|0}return vi}function ji(a,ti,wi){var xi=0,yi=0,zi=0;if((ti|0)>0){while(1){yi=xi<<2;zi=o[yi+a>>2];o[wi+yi>>2]=0-(zi&1)^zi>>>1;xi=xi+1|0;if((xi|0)!=(ti|0)){continue}break}}}function ki(a){o[a+16>>2]=0;o[a+20>>2]=0;o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0}function li(a,o,ti,wi){return mi(a,o,ti,wi)}function mi(a,ti,wi,Ai){var Bi=0,Ci=0,Di=0;a:{if(!ti){ti=wi;Ai=ti>>>0<0?Ai+1|0:Ai;if((Ai|0)<0?1:(Ai|0)<=0?ti>>>0>=0?0:1:0){return 0}Ai=o[a>>2];wi=o[a+4>>2]-Ai|0;if(wi>>>0>>0){Fa(a,ti-wi|0);break a}if(wi>>>0<=ti>>>0){break a}o[a+4>>2]=ti+Ai;break a}if((Ai|0)<0?1:(Ai|0)<=0?wi>>>0>=0?0:1:0){return 0}Ci=wi;if(wi>>>0<0){Ai=Ai+1|0}Di=o[a>>2];Bi=o[a+4>>2]-Di|0;b:{if((Ai|0)<0?1:(Ai|0)<=0?Ci>>>0>Bi>>>0?0:1:0){break b}Ai=Ci;if(Bi>>>0>>0){Fa(a,Ai-Bi|0);break b}if(Bi>>>0<=Ai>>>0){break b}o[a+4>>2]=Ai+Di}if(!wi){break a}yl(o[a>>2],ti,wi)}ti=a+24|0;wi=ti;Ai=ti;a=o[ti+4>>2];ti=o[ti>>2]+1|0;if(ti>>>0<1){a=a+1|0}o[Ai>>2]=ti;o[wi+4>>2]=a;return 1}function ni(a,ti){var wi=0,Ai=0;Ai=o[a>>2];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36>>2]=0}a=o[Si+12>>2];o[Ri>>2]=o[Si+8>>2];o[Ri+4>>2]=a;o[Ri+8>>2]=o[Si+16>>2];R=Si+48|0}function xi(a,Ri){var Ti=0,Yi=0,Zi=0,_i=0,$i=0,aj=0,bj=0,cj=0;$i=a+4|0;a=o[$i>>2];a:{b:{if(!a){break b}Ti=p[Ri+11|0];Yi=Ti<<24>>24<0;Zi=Yi?o[Ri+4>>2]:Ti;bj=Yi?o[Ri>>2]:Ri;Ti=$i;while(1){Ri=p[a+27|0];cj=Ri<<24>>24<0;aj=cj?o[a+20>>2]:Ri;_i=Zi>>>0>>0;Yi=_i?Zi:aj;c:{if(Yi){Ri=a+16|0;Ri=Zj(cj?o[Ri>>2]:Ri,bj,Yi);if(Ri){break c}}Ri=aj>>>0>>0?-1:_i}Ti=(Ri|0)<0?Ti:a;a=o[(Ri>>>29&4)+a>>2];if(a){continue}break}if((Ti|0)==($i|0)){break b}a=p[Ti+27|0];_i=a<<24>>24<0;d:{Yi=_i?o[Ti+20>>2]:a;Ri=Yi>>>0>>0?Yi:Zi;if(Ri){a=Ti+16|0;a=Zj(bj,_i?o[a>>2]:a,Ri);if(a){break d}}if(Zi>>>0>>0){break b}break a}if((a|0)>-1){break a}}Ti=$i}return Ti}function yi(a,Ri){var dj=0;Ri=xi(a,Ri);a:{if((Ri|0)==(a+4|0)){break a}a=Ri+28|0;if(m[Ri+39|0]<=-1){a=o[a>>2]}a=Yj(a);if((a|0)==-1){break a}dj=(a|0)!=0}return dj}function zi(a){var Ri=0;o[a>>2]=0;o[a+4>>2]=0;o[a+56>>2]=0;o[a+48>>2]=0;o[a+52>>2]=0;o[a+40>>2]=0;o[a+44>>2]=0;o[a+32>>2]=0;o[a+36>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0;o[a+16>>2]=0;o[a+20>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0;Ri=a- -64|0;o[Ri>>2]=0;o[Ri+4>>2]=0;o[a+72>>2]=0;o[a+76>>2]=0;o[a+80>>2]=0;o[a+84>>2]=0;o[a+60>>2]=a}function Ai(a,ej){var fj=0,gj=0,hj=0;hj=R-16|0;R=hj;gj=Hk(88);fj=gj;o[fj>>2]=0;o[fj+4>>2]=0;o[fj+56>>2]=0;o[fj+48>>2]=0;o[fj+52>>2]=0;o[fj+40>>2]=0;o[fj+44>>2]=0;o[fj+32>>2]=0;o[fj+36>>2]=0;o[fj+24>>2]=0;o[fj+28>>2]=0;o[fj+16>>2]=0;o[fj+20>>2]=0;o[fj+8>>2]=0;o[fj+12>>2]=0;fj=fj- -64|0;o[fj>>2]=0;o[fj+4>>2]=0;o[gj+72>>2]=0;o[gj+76>>2]=0;o[gj+80>>2]=0;o[gj+84>>2]=0;o[gj+60>>2]=gj;o[hj+8>>2]=gj;a:{if(Bi(gj,ej)){o[a>>2]=o[hj+8>>2];o[hj+8>>2]=0;break a}o[a>>2]=0;a=o[hj+8>>2];o[hj+8>>2]=0;if(!a){break a}ua(hj+8|0,a)}R=hj+16|0}function Bi(a,ej){var ij=0,jj=0,kj=0,lj=0,mj=0,nj=0,oj=0;lj=R-16|0;R=lj;o[a+80>>2]=0;o[a+84>>2]=0;ij=a+76|0;jj=o[ij>>2];o[ij>>2]=0;if(jj){ul(jj)}o[a+68>>2]=0;o[a+72>>2]=0;ij=a- -64|0;jj=o[ij>>2];o[ij>>2]=0;if(jj){ul(jj)}nj=ej+4|0;ij=o[nj>>2];jj=o[ej>>2];kj=u((ij-jj|0)/12|0,3);oj=o[a>>2];mj=o[a+4>>2]-oj>>2;a:{if(kj>>>0>mj>>>0){Ci(a,kj-mj|0);ij=o[nj>>2];jj=o[ej>>2];break a}if(kj>>>0>=mj>>>0){break a}o[a+4>>2]=(kj<<2)+oj}if((ij|0)!=(jj|0)){mj=(ij-jj|0)/12|0;nj=o[a>>2];ej=0;while(1){kj=u(ej,12);ij=kj+nj|0;kj=jj+kj|0;o[ij>>2]=o[kj>>2];o[ij+4>>2]=o[kj+4>>2];o[ij+8>>2]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j=Bj+1|0;if((Cj|0)!=(Bj|0)){continue}break}}}Ej=zj;if(Ej>>>0>>0){continue}break}break b}Yk();D()}Yk();D()}_a(10468);D()}o[ej>>2]=Mj;if(Jj){o[Aj+4>>2]=Jj;ul(Jj)}a=o[Aj+16>>2];if(a){o[Aj+20>>2]=a;ul(a)}a=o[Aj+32>>2];if(a){o[Aj+36>>2]=a;ul(a)}a=1}else{a=0}R=Aj+48|0;return a}function Ei(a){var ej=0,Tj=0,Uj=0,Vj=0,Wj=0,Xj=0,Yj=0,Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0;Uj=R-48|0;R=Uj;ak=a+4|0;ej=o[ak>>2];_j=o[a>>2];m[Uj+16|0]=0;bk=Hi(Uj+32|0,ej-_j>>2,Uj+16|0);o[Uj+24>>2]=0;o[Uj+16>>2]=0;o[Uj+20>>2]=0;ej=o[ak>>2];Yj=o[a>>2];Zj=a+12|0;while(1){ck=0;Xj=0;a:{if((ej|0)==(Yj|0)){break a}while(1){Vj=o[bk>>2];b:{if(o[Vj+(Xj>>>3&536870908)>>2]>>>(Xj&31)&1){break b}Wj=o[Uj+16>>2];o[Uj+20>>2]=Wj;ej=Xj;while(1){Tj=ej+1|0;_j=ej;ej=(Tj>>>0)%3|0?Tj:ej+ -2|0;c:{if((ej|0)==-1){break c}ej=o[o[Zj>>2]+(ej<<2)>>2];if((ej|0)==-1){break c}Tj=ej+1|0;ej=(Tj>>>0)%3|0?Tj:ej+ -2|0;if((Xj|0)==(ej|0)|(ej|0)==-1){break c}if(!(o[(ej>>>3&536870908)+Vj>>2]>>>(ej&31)&1)){continue}}break}ej=Wj;Tj=_j;while(1){Vj=(Tj>>>3&536870908)+Vj|0;o[Vj>>2]=o[Vj>>2]|1<<(Tj&31);Vj=Tj+1|0;dk=(Vj>>>0)%3|0?Vj:Tj+ -2|0;Vj=((Tj>>>0)%3|0?-1:2)+Tj|0;if((ej|0)!=(Wj|0)){ek=o[(dk<<2)+Yj>>2];while(1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{if(gk>>>0>>0){Gi(rk,fk-gk|0);break a}if(gk>>>0<=fk>>>0){break a}o[a+28>>2]=ik+(fk<<2)}m[lk+16|0]=0;mk=Hi(lk+32|0,fk,lk+16|0);sk=a+4|0;gk=o[sk>>2];ik=o[a>>2];m[lk+8|0]=0;ok=Hi(lk+16|0,gk-ik>>2,lk+8|0);b:{gk=o[a>>2];if(o[sk>>2]-gk>>2>>>0<3){break b}yk=a+48|0;tk=a+12|0;zk=a+32|0;vk=a+28|0;Ak=a+56|0;wk=a+52|0;while(1){pk=u(uk,3);jk=o[(pk<<2)+gk>>2];kk=0;hk=-1;ik=pk+1|0;c:{if((ik|0)!=-1){hk=o[(ik<<2)+gk>>2];kk=pk+2|0;ik=-1;if((kk|0)==-1){break c}}ik=o[(kk<<2)+gk>>2]}d:{if(!((ik|0)==(hk|0)|(hk|0)==(jk|0)|(ik|0)==(jk|0))){nk=o[ok>>2];qk=0;while(1){ik=pk+qk|0;e:{if(o[(ik>>>3&536870908)+nk>>2]>>>(ik&31)&1){break e}kk=o[o[a>>2]+(ik<<2)>>2];o[lk+8>>2]=kk;gk=1<<(kk&31);hk=o[mk>>2];kk=kk>>>5;nk=o[hk+(kk<<2)>>2];jk=0;f:{if(!(gk&nk)){break f}gk=o[vk>>2];g:{if((gk|0)!=o[zk>>2]){o[gk>>2]=-1;o[vk>>2]=gk+4;break g}bh(rk,10464)}gk=o[wk>>2];h:{if((gk|0)!=o[Ak>>2]){o[gk>>2]=o[lk+8>>2];o[wk>>2]=gk+4;break h}bh(yk,lk+8|0)}gk=o[mk+4>>2];jk=o[mk+8>>2];if((gk|0)==jk<<5){if((gk+1|0)<=-1){break d}hk=mk;if(gk>>>0<=1073741822){gk=gk+32&-32;jk=jk<<6;gk=jk>>>0>>0?gk:jk}else{gk=2147483647}ab(hk,gk);gk=o[mk+4>>2]}o[mk+4>>2]=gk+1;hk=o[mk>>2];jk=hk+(gk>>>3&536870908)|0;kk=o[jk>>2];Bk=jk,Ck=Zl(gk)&kk,o[Bk>>2]=Ck;o[lk+8>>2]=fk;gk=1<<(fk&31);kk=fk>>>5;nk=o[(kk<<2)+hk>>2];fk=fk+1|0;jk=1}o[(kk<<2)+hk>>2]=gk|nk;nk=o[ok>>2];gk=ik;i:{while(1){if((gk|0)==-1){break i}hk=(gk>>>3&536870908)+nk|0;o[hk>>2]=o[hk>>2]|1<<(gk&31);hk=o[lk+8>>2];o[o[rk>>2]+(hk<<2)>>2]=gk;if(jk){o[o[a>>2]+(gk<<2)>>2]=hk}kk=ik;hk=gk+1|0;gk=(hk>>>0)%3|0?hk:gk+ -2|0;hk=-1;j:{if((gk|0)==-1){break j}gk=o[o[tk>>2]+(gk<<2)>>2];hk=-1;if((gk|0)==-1){break j}hk=gk+1|0;hk=(hk>>>0)%3|0?hk:gk+ -2|0}gk=hk;if((kk|0)!=(gk|0)){continue}break}if((ik|0)!=-1){break e}}gk=ik+((ik>>>0)%3|0?-1:2)|0;if((gk|0)==-1){break e}gk=o[o[tk>>2]+(gk<<2)>>2];if((gk|0)==-1){break e}gk=gk+((gk>>>0)%3|0?-1:2)|0;if((gk|0)==-1){break e}nk=o[ok>>2];while(1){ik=(gk>>>3&536870908)+nk|0;o[ik>>2]=o[ik>>2]|1<<(gk&31);if(jk){o[o[a>>2]+(gk<<2)>>2]=o[lk+8>>2]}gk=((gk>>>0)%3|0?-1:2)+gk|0;if((gk|0)==-1){break e}gk=o[o[tk>>2]+(gk<<2)>>2];if((gk|0)==-1){break e}gk=gk+((gk>>>0)%3|0?-1:2)|0;if((gk|0)!=-1){continue}break}}qk=qk+1|0;if((qk|0)!=3){continue}break}}uk=uk+1|0;gk=o[a>>2];if(uk>>>0<(o[sk>>2]-gk>>2>>>0)/3>>>0){continue}break b}break}Yk();D()}o[a+44>>2]=0;fk=o[mk>>2];gk=o[mk+4>>2];ik=gk>>>5;jk=gk&31;if(ik|jk){ik=(ik<<2)+fk|0;hk=fk;gk=0;while(1){if(!(o[hk>>2]>>>gk&1)){xk=x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o[fk>>2]=0;Uk=1;if(!a){break b}ul(a)}return Uk}_a(10468);D()}function Ki(a,fk,Tk){var Zk=0,_k=0,$k=0,al=0,bl=0;Zk=o[a+8>>2];_k=o[a>>2];if(Zk-_k>>2>>>0>=fk>>>0){$k=o[a+4>>2];al=$k-_k>>2;bl=al>>>0>>0?al:fk;if(bl){Zk=_k;while(1){o[Zk>>2]=o[Tk>>2];Zk=Zk+4|0;bl=bl+ -1|0;if(bl){continue}break}}if(al>>>0>>0){Zk=fk-al|0;while(1){o[$k>>2]=o[Tk>>2];$k=$k+4|0;Zk=Zk+ -1|0;if(Zk){continue}break}o[a+4>>2]=$k;return}o[a+4>>2]=(fk<<2)+_k;return}if(_k){o[a+4>>2]=_k;ul(_k);o[a+8>>2]=0;o[a>>2]=0;o[a+4>>2]=0;Zk=0}a:{if(fk>>>0>=1073741824){break a}_k=Zk>>1;_k=Zk>>2>>>0<536870911?_k>>>0>>0?fk:_k:1073741823;if(_k>>>0>=1073741824){break a}_k=_k<<2;Zk=Hk(_k);o[a>>2]=Zk;o[a+4>>2]=Zk;o[a+8>>2]=Zk+_k;while(1){o[Zk>>2]=o[Tk>>2];Zk=Zk+4|0;fk=fk+ -1|0;if(fk){continue}break}o[a+4>>2]=Zk;return}Yk();D()}function Li(a){qj(a);o[a+84>>2]=0;o[a+88>>2]=0;o[a>>2]=10544;o[a+92>>2]=0;o[a+96>>2]=0;o[a+100>>2]=0;o[a+104>>2]=0;return a}function Mi(a){a=a|0;var fk=0,Hk=0,Tk=0,Yk=0,cl=0;o[a>>2]=10944;fk=o[a+68>>2];if(fk){o[a+72>>2]=fk;ul(fk)}fk=o[a+56>>2];if(fk){o[a+60>>2]=fk;ul(fk)}fk=o[a+44>>2];if(fk){o[a+48>>2]=fk;ul(fk)}fk=o[a+32>>2];if(fk){o[a+36>>2]=fk;ul(fk)}fk=o[a+20>>2];if(fk){o[a+24>>2]=fk;ul(fk)}Tk=o[a+8>>2];if(Tk){fk=Tk;cl=a+12|0;Hk=o[cl>>2];Yk=fk;a:{if((fk|0)==(Hk|0)){break a}while(1){Hk=Hk+ -4|0;fk=o[Hk>>2];o[Hk>>2]=0;if(fk){Fb(fk)}if((Hk|0)!=(Tk|0)){continue}break}Yk=o[a+8>>2]}fk=Yk;o[cl>>2]=Tk;ul(fk)}fk=o[a+4>>2];o[a+4>>2]=0;if(fk){ei(fk)}return a|0}function Ni(a){a=a|0;var dl=0;o[a>>2]=10544;dl=o[a+96>>2];if(dl){o[a+100>>2]=dl;ul(dl)}dl=o[a+84>>2];if(dl){o[a+88>>2]=dl;ul(dl)}Mi(a);return a|0}function Oi(a){a=a|0;var el=0;o[a>>2]=10544;el=o[a+96>>2];if(el){o[a+100>>2]=el;ul(el)}el=o[a+84>>2];if(el){o[a+88>>2]=el;ul(el)}Mi(a);ul(a)}function Pi(a,fl,gl){a=a|0;fl=fl|0;gl=gl|0;var hl=0,il=0;hl=R-16|0;R=hl;il=o[gl>>2];o[gl>>2]=0;o[hl+8>>2]=il;wj(a,fl,hl+8|0);gl=o[hl+8>>2];o[hl+8>>2]=0;if(gl){Fb(gl)}il=o[a+84>>2];gl=o[a+88>>2]-il>>2;a:{if((gl|0)>(fl|0)){break a}fl=fl+1|0;if(fl>>>0>gl>>>0){Qi(a+84|0,fl-gl|0);break a}if(fl>>>0>=gl>>>0){break a}o[a+88>>2]=il+(fl<<2)}R=hl+16|0}function Qi(a,fl){var gl=0,jl=0,kl=0,ll=0,ml=0,nl=0;kl=o[a+8>>2];gl=o[a+4>>2];if(kl-gl>>2>>>0>=fl>>>0){while(1){o[gl>>2]=1;gl=gl+4|0;fl=fl+ -1|0;if(fl){continue}break}o[a+4>>2]=gl;return}a:{ll=o[a>>2];ml=gl-ll|0;nl=ml>>2;gl=nl+fl|0;if(gl>>>0<1073741824){kl=kl-ll|0;jl=kl>>1;gl=kl>>2>>>0<536870911?jl>>>0>>0?gl:jl:1073741823;jl=0;b:{if(!gl){break b}if(gl>>>0>=1073741824){break a}jl=Hk(gl<<2)}kl=jl+(gl<<2)|0;gl=jl+(nl<<2)|0;while(1){o[gl>>2]=1;gl=gl+4|0;fl=fl+ -1|0;if(fl){continue}break}if((ml|0)>=1){wl(jl,ll,ml)}o[a>>2]=jl;o[a+8>>2]=kl;o[a+4>>2]=gl;if(ll){ul(ll)}return}Yk();D()}_a(10588);D()}function Ri(a,fl){a=a|0;fl=fl|0;var ol=0,pl=0,ql=0;zj(a,fl);a:{if((fl|0)<0){break a}ol=o[a+88>>2];pl=o[a+84>>2];if(ol-pl>>2<=(fl|0)){break a}fl=pl+(fl<<2)|0;pl=fl+4|0;ol=ol-pl|0;ql=ol>>2;if(ol){yl(fl,pl,ol)}o[a+88>>2]=fl+(ql<<2)}}function Si(a,fl){var rl=0,sl=0,tl=0,vl=0,xl=0,yl=0;a:{tl=o[a>>2];xl=o[a+4>>2]-tl|0;rl=xl>>2;sl=rl+1|0;if(sl>>>0<1073741824){yl=rl<<2;rl=o[a+8>>2]-tl|0;vl=rl>>1;sl=rl>>2>>>0<536870911?vl>>>0>>0?sl:vl:1073741823;rl=0;b:{if(!sl){break b}if(sl>>>0>=1073741824){break a}rl=Hk(sl<<2)}vl=yl+rl|0;o[vl>>2]=o[fl>>2];fl=rl+(sl<<2)|0;sl=vl+4|0;if((xl|0)>=1){wl(rl,tl,xl)}o[a>>2]=rl;o[a+8>>2]=fl;o[a+4>>2]=sl;if(tl){ul(tl)}return}Yk();D()}_a(10656);D()}function Ti(a){o[a>>2]=0;o[a+4>>2]=0;m[a+24|0]=1;o[a+16>>2]=0;o[a+20>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0;o[a+28>>2]=0;o[a+32>>2]=0;o[a+36>>2]=0;o[a+40>>2]=0;o[a+44>>2]=0;o[a+48>>2]=0;o[a+52>>2]=0;o[a+56>>2]=0;o[a+60>>2]=0;o[a+64>>2]=0;o[a+72>>2]=0;o[a+76>>2]=0;o[a+80>>2]=0;o[a+84>>2]=0;o[a+88>>2]=0;o[a+92>>2]=0;o[a+68>>2]=a}function Ui(a,fl){var zl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0;El=R-16|0;R=El;a:{b:{if(fl){o[a+88>>2]=0;o[a+92>>2]=0;zl=a+84|0;Al=o[zl>>2];o[zl>>2]=0;if(Al){ul(Al)}o[a+76>>2]=0;o[a+80>>2]=0;zl=a+72|0;Al=o[zl>>2];o[zl>>2]=0;if(Al){ul(Al)}Al=fl+4|0;zl=o[Al>>2];Bl=o[fl>>2];m[El+15|0]=0;$a(a,zl-Bl>>2,El+15|0);Bl=fl+28|0;zl=o[Bl>>2];Cl=o[fl+24>>2];m[El+14|0]=0;$a(a+12|0,zl-Cl>>2,El+14|0);Ki(a+28|0,o[Al>>2]-o[fl>>2]>>2,10724);Al=o[a+52>>2];Cl=o[Bl>>2]-o[fl+24>>2]|0;zl=Cl>>2;c:{if(o[a+60>>2]-Al>>2>>>0>=zl>>>0){break c}if(zl>>>0>=1073741824){break b}Fl=a+56|0;Dl=o[Fl>>2];Gl=zl<<2;zl=Hk(Cl);Gl=Gl+zl|0;Cl=Dl-Al|0;Dl=Cl+zl|0;if((Cl|0)>=1){wl(zl,Al,Cl)}o[a+52>>2]=zl;o[a+60>>2]=Gl;o[Fl>>2]=Dl;if(!Al){break c}ul(Al)}Al=o[a+40>>2];Bl=o[Bl>>2]-o[fl+24>>2]|0;zl=Bl>>2;d:{if(o[a+48>>2]-Al>>2>>>0>=zl>>>0){break d}if(zl>>>0>=1073741824){break a}Cl=a+44|0;Fl=o[Cl>>2];Dl=zl<<2;zl=Hk(Bl);Dl=Dl+zl|0;Bl=Fl-Al|0;Fl=Bl+zl|0;if((Bl|0)>=1){wl(zl,Al,Bl)}o[a+40>>2]=zl;o[a+48>>2]=Dl;o[Cl>>2]=Fl;if(!Al){break d}ul(Al)}m[a+24|0]=1;o[a+64>>2]=fl}R=El+16|0;return}_a(10728);D()}_a(10728);D()}function Vi(a){var fl=0,ul=0,wl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0,Ml=0,Nl=0,Ol=0,Pl=0,Ql=0;wl=R-32|0;R=wl;Jl=a+56|0;o[Jl>>2]=o[a+52>>2];Kl=a+44|0;o[Kl>>2]=o[a+40>>2];fl=o[a+64>>2];if(o[fl+28>>2]!=o[fl+24>>2]){Ml=a+40|0;Nl=a+52|0;Ol=a+60|0;Pl=a+48|0;while(1){ul=o[o[fl+24>>2]+(Ll<<2)>>2];a:{if((ul|0)==-1){break a}o[wl+24>>2]=Il;fl=o[Jl>>2];b:{if((fl|0)!=o[Ol>>2]){o[fl>>2]=Il;o[Jl>>2]=fl+4;break b}Xi(Nl,wl+24|0)}o[wl+16>>2]=ul;o[wl+8>>2]=0;c:{if(!(o[o[a+12>>2]+(Ll>>>3&536870908)>>2]>>>(Ll&31)&1)){break c}d:{fl=ul+1|0;fl=(fl>>>0)%3|0?fl:ul+ -2|0;if(!((fl|0)==-1|o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){fl=o[o[o[a+64>>2]+12>>2]+(fl<<2)>>2];if((fl|0)!=-1){break d}}o[wl+8>>2]=-1;break c}Hl=fl+1|0;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;o[wl+8>>2]=fl;if((fl|0)==-1){break c}while(1){o[wl+16>>2]=fl;e:{Hl=fl+1|0;ul=fl;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;if(!((fl|0)==-1|o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){fl=o[o[o[a+64>>2]+12>>2]+(fl<<2)>>2];if((fl|0)!=-1){break e}}o[wl+8>>2]=-1;break c}Hl=fl+1|0;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;o[wl+8>>2]=fl;if((fl|0)!=-1){continue}break}}Ql=a+28|0;o[o[Ql>>2]+(ul<<2)>>2]=o[wl+24>>2];fl=o[Kl>>2];f:{if((fl|0)!=o[Pl>>2]){o[fl>>2]=o[wl+16>>2];o[Kl>>2]=fl+4;break f}bh(Ml,wl+16|0)}Il=Il+1|0;fl=o[a+64>>2];g:{Hl=o[wl+16>>2];if((Hl|0)==-1){break g}ul=Hl+((Hl>>>0)%3|0?-1:2)|0;if((ul|0)==-1){break g}ul=o[o[fl+12>>2]+(ul<<2)>>2];if((ul|0)==-1){break g}ul=ul+((ul>>>0)%3|0?-1:2)|0;o[wl+8>>2]=ul;if((ul|0)==-1|(ul|0)==(Hl|0)){break a}while(1){fl=ul+1|0;fl=(fl>>>0)%3|0?fl:ul+ -2|0;h:{if(!(o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){break h}o[wl+24>>2]=Il;fl=o[Jl>>2];i:{if((fl|0)!=o[Ol>>2]){o[fl>>2]=Il;o[Jl>>2]=fl+4;break i}Xi(Nl,wl+24|0)}Il=Il+1|0;fl=o[Kl>>2];if((fl|0)!=o[Pl>>2]){o[fl>>2]=o[wl+8>>2];o[Kl>>2]=fl+4;break h}bh(Ml,wl+8|0)}o[o[Ql>>2]+(o[wl+8>>2]<<2)>>2]=o[wl+24>>2];fl=o[a+64>>2];ul=o[wl+8>>2];if((ul|0)==-1){break g}ul=ul+((ul>>>0)%3|0?-1:2)|0;if((ul|0)==-1){break g}ul=o[o[fl+12>>2]+(ul<<2)>>2];if((ul|0)==-1){break g}ul=ul+((ul>>>0)%3|0?-1:2)|0;o[wl+8>>2]=ul;if((ul|0)==-1){break a}if(o[wl+16>>2]!=(ul|0)){continue}break}break a}o[wl+8>>2]=-1}Ll=Ll+1|0;if(Ll>>>0>2]-o[fl+24>>2]>>2>>>0){continue}break}}R=wl+32|0}function Wi(a,Rl){var Sl=0,Tl=0,Ul=0,Vl=0,Wl=0,Xl=0;Ul=o[a>>2];Sl=Ul+(Rl>>>3&536870908)|0;o[Sl>>2]=o[Sl>>2]|1<<(Rl&31);Wl=o[a+64>>2];Vl=(Rl|0)==-1;Sl=-1;a:{if(Vl){break a}Tl=Rl+1|0;Tl=(Tl>>>0)%3|0?Tl:Rl+ -2|0;Sl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yl;o[a+8>>2]=Rl;o[a+4>>2]=Zl;if(_l){ul(_l)}return}Yk();D()}_a(10728);D()}function Yi(a,Rl){var cm=0,dm=0,em=0,fm=0,gm=0,hm=0,im=0,jm=0,km=0,lm=0,mm=0;dm=R-16|0;R=dm;a:{em=sj(Rl);if(!em){o[a>>2]=0;break a}fm=o[Rl+100>>2];jm=o[Rl+96>>2];o[dm+8>>2]=0;o[dm>>2]=0;o[dm+4>>2]=0;Rl=fm-jm|0;im=(Rl|0)/12|0;b:{if(Rl){if(im>>>0>=357913942){break b}gm=Hk(Rl);o[dm>>2]=gm;o[dm+4>>2]=gm;o[dm+8>>2]=u(im,12)+gm;Rl=xl(gm,0,Rl);cm=im;while(1){Rl=Rl+12|0;cm=cm+ -1|0;if(cm){continue}break}o[dm+4>>2]=Rl}if((fm|0)!=(jm|0)){Rl=0;lm=p[em+84|0];mm=em+68|0;while(1){km=u(Rl,12);cm=km+jm|0;em=o[cm>>2];c:{if(lm){fm=cm+8|0;cm=cm+4|0;break c}hm=o[mm>>2];fm=hm+(o[cm+8>>2]<<2)|0;em=o[hm+(em<<2)>>2];cm=hm+(o[cm+4>>2]<<2)|0}hm=o[cm>>2];cm=gm+km|0;o[cm+8>>2]=o[fm>>2];o[cm+4>>2]=hm;o[cm>>2]=em;Rl=Rl+1|0;if(Rl>>>0>>0){continue}break}}Ai(a,dm);a=o[dm>>2];if(!a){break a}o[dm+4>>2]=a;ul(a);break a}Yk();D()}R=dm+16|0}function Zi(a,Rl,nm){var om=0,pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0,Cm=0,Dm=0;tm=R-16|0;R=tm;sm=u(Rl,12)+a|0;um=sm+12|0;zm=sm+8|0;o[um>>2]=o[zm>>2];o[tm+8>>2]=(nm|0)==-1?-1:(nm>>>0)/3|0;Am=sm+16|0;Bm=a+4|0;qm=nm;while(1){sm=pm;vm=(pm|0)==1;a:{b:{if(!vm){pm=o[tm+8>>2];break b}if((qm|0)==-1){qm=-1;_i(a,-1);break a}if((qm|0)==-1|(_i(a,((qm>>>0)%3|0?-1:2)+qm|0)|0)==-1){break a}nm=qm+1|0;om=(nm>>>0)%3|0?nm:qm+ -2|0;if((om|0)==-1){break a}nm=om+1|0;nm=(nm>>>0)%3|0?nm:om+ -2|0;if((nm|0)==-1){break a}om=o[o[o[Bm>>2]+12>>2]+(nm<<2)>>2];if((om|0)==-1){break a}nm=om+1|0;nm=(nm>>>0)%3|0?nm:om+ -2|0;if((nm|0)==-1){break a}pm=(nm>>>0)/3|0;o[tm+8>>2]=pm}wm=1<<(pm&31);xm=o[a+56>>2]+(pm>>>3&536870908)|0;ym=o[xm>>2];c:{if(wm&ym){break c}rm=0;while(1){o[xm>>2]=wm|ym;om=o[um>>2];d:{if((om|0)!=o[Am>>2]){o[om>>2]=pm;o[um>>2]=om+4;break d}Si(zm,tm+8|0)}om=rm+1|0;e:{if(!rm){break e}if(om&1){if((nm|0)==-1){nm=-1;break e}rm=nm+1|0;nm=(rm>>>0)%3|0?rm:nm+ -2|0;break e}qm=vm?nm:qm;if((nm|0)==-1){nm=-1;break e}if((nm>>>0)%3){nm=nm+ -1|0;break e}nm=nm+2|0}nm=_i(a,nm);if((nm|0)!=-1){pm=(nm>>>0)/3|0;o[tm+8>>2]=pm;rm=om;wm=1<<(pm&31);xm=o[a+56>>2]+(pm>>>3&268435452)|0;ym=o[xm>>2];if(!(wm&ym)){continue}}break}if(!(om&1)|(sm|0)!=1){break c}vm=o[um>>2]+ -4|0;pm=o[vm>>2];rm=o[a+56>>2]+(pm>>>3&536870908)|0;om=o[rm>>2];Cm=rm,Dm=Zl(pm)&om,o[Cm>>2]=Dm;o[um>>2]=vm}pm=1;if(!sm){continue}}break}o[((Rl<<2)+a|0)+44>>2]=qm;Rl=o[um>>2];qm=o[zm>>2];if((Rl|0)!=(qm|0)){rm=Rl-qm>>2;om=o[a+56>>2];nm=0;while(1){sm=o[qm+(nm<<2)>>2];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2])){break b}Rl=0;Im=o[Jm+16>>2];if(Im){while(1){if(!bj(a,Nm)){break b}Rl=Rl+1|0;if(Rl>>>0>>0){continue}break}}o[Jm+4>>2]=0;if(!aj(1,Jm+4|0,o[a>>2])){break b}Mm=o[Jm+4>>2];if(Mm){Pm=0;while(1){Rl=o[Jm+36>>2];Im=o[Jm+40>>2];f:{if(Rl>>>0>>0){o[Rl+4>>2]=0;o[Rl>>2]=Nm;o[Jm+36>>2]=o[Jm+36>>2]+8;break f}Om=o[Jm+32>>2];Rm=Rl-Om|0;Rl=Rm>>3;Qm=Rl+1|0;if(Qm>>>0>=536870912){break d}Lm=Rl<<3;Km=Im-Om|0;Im=Km>>2;Km=Km>>3>>>0<268435455?Im>>>0>>0?Qm:Im:536870911;Rl=0;g:{if(!Km){break g}if(Km>>>0>=536870912){break c}Rl=Hk(Km<<3)}Im=Lm+Rl|0;o[Im+4>>2]=0;o[Im>>2]=Nm;Km=Rl+(Km<<3)|0;Im=Im+8|0;if((Rm|0)>=1){wl(Rl,Om,Rm)}o[Jm+40>>2]=Km;o[Jm+36>>2]=Im;o[Jm+32>>2]=Rl;if(!Om){break f}ul(Om)}Pm=Pm+1|0;if(Pm>>>0>>0){continue}break}}Rl=o[Jm+36>>2];Im=o[Jm+32>>2];if((Rl|0)!=(Im|0)){continue}break}a=1;break a}Yk();D()}_a(10796);D()}Im=o[Jm+32>>2];a=0}if(Im){o[Jm+36>>2]=Im;ul(Im)}R=Jm+48|0;return a}function aj(a,Rl,Tm){var Um=0,Vm=0,Wm=0,Xm=0;a:{if(a>>>0>5){break a}Wm=o[Tm+16>>2];Um=o[Tm+12>>2];Vm=o[Tm+20>>2];if((Um|0)<(Vm|0)?1:(Um|0)<=(Vm|0)?r[Tm+8>>2]>Wm>>>0?0:1:0){break a}Um=p[Wm+o[Tm>>2]|0];Wm=Wm+1|0;if(Wm>>>0<1){Vm=Vm+1|0}o[Tm+16>>2]=Wm;o[Tm+20>>2]=Vm;Vm=Rl;if(Um&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n=o[Tm+12>>2];_m=a;cn=o[Tm+20>>2];$m=o[Tm+16>>2];a=Zm;an=$m+Zm|0;if(an>>>0>>0){cn=cn+1|0}if((dn|0)>(cn|0)?1:(dn|0)>=(cn|0)?_m>>>0>>0?0:1:0){wl(o[Ym>>2],$m+o[Tm>>2]|0,Zm);Zm=Tm;an=Tm;_m=o[Tm+20>>2];Tm=a+o[Tm+16>>2]|0;if(Tm>>>0>>0){_m=_m+1|0}o[an+16>>2]=Tm;o[Zm+20>>2]=_m;nj(Rl,Ym+16|0,Ym);bn=1}a=o[Ym>>2];if(!a){break b}o[Ym+4>>2]=a;ul(a)}if(m[Ym+27|0]<=-1){ul(o[Ym+16>>2])}R=Ym+32|0;return bn}Yk();D()}function cj(a,Rl,fn){var gn=0,hn=0,jn=0,kn=0,ln=0;hn=R-16|0;R=hn;a:{b:{if(!fn){break b}o[a>>2]=Rl;o[hn+12>>2]=0;gn=0;if(!aj(1,hn+12|0,Rl)){break a}c:{ln=o[hn+12>>2];if(ln){Rl=0;while(1){if(!aj(1,hn+8|0,o[a>>2])){break b}gn=Hk(28);jn=gn+4|0;o[jn>>2]=0;o[jn+4>>2]=0;kn=gn+16|0;o[kn>>2]=0;o[kn+4>>2]=0;o[gn>>2]=jn;jn=gn+12|0;o[jn>>2]=kn;o[gn+24>>2]=o[hn+8>>2];if(!$i(a,gn)){break c}o[hn>>2]=gn;ej(fn,hn);gn=o[hn>>2];o[hn>>2]=0;if(gn){Fc(gn+12|0,o[gn+16>>2]);Gc(gn,o[gn+4>>2]);ul(gn)}Rl=Rl+1|0;if(Rl>>>0>>0){continue}break}}gn=$i(a,fn);break a}Fc(jn,o[gn+16>>2]);Gc(gn,o[gn+4>>2]);ul(gn)}gn=0}R=hn+16|0;return gn}function dj(a,Rl,fn){var mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0,wn=0,xn=0;mn=R-16|0;R=mn;pn=o[a+24>>2];un=o[a+28>>2];a:{if((pn|0)!=(un|0)){wn=mn+8|0;xn=fn+4|0;while(1){o[wn>>2]=0;o[mn>>2]=0;o[mn+4>>2]=0;a=mj(o[pn>>2],Rl,mn);qn=p[mn+11|0];tn=qn<<24>>24;b:{c:{d:{if(!a){a=3;break d}a=0;nn=p[fn+11|0];on=nn<<24>>24;sn=(tn|0)<0?o[mn+4>>2]:qn;if((sn|0)!=(((on|0)<0?o[xn>>2]:nn)|0)){break d}rn=(on|0)<0?o[fn>>2]:fn;on=o[mn>>2];nn=(tn|0)<0;e:{if(!nn){if(!sn){break e}nn=mn;if(p[rn|0]!=(on&255)){break d}while(1){qn=qn+ -1|0;if(!qn){break e}on=p[rn+1|0];rn=rn+1|0;nn=nn+1|0;if((on|0)==p[nn|0]){continue}break}break d}if(!sn){break e}if(Zj(nn?on:mn,rn,sn)){break c}}vn=o[pn>>2];a=1}if((tn|0)>-1){break b}}ul(o[mn>>2])}if(a>>>0>3){break a}f:{switch(a-1|0){case 0:case 1:break a;default:break f}}pn=pn+4|0;if((un|0)!=(pn|0)){continue}break}}vn=0}R=mn+16|0;return vn}function ej(a,Rl){var fn=0,yn=0,zn=0;yn=o[Rl>>2];if(!yn){return}fn=a+28|0;zn=o[fn>>2];if(zn>>>0>2]){o[Rl>>2]=0;o[zn>>2]=yn;o[fn>>2]=o[fn>>2]+4;return}fj(a+24|0,Rl)}function fj(a,Rl){var An=0,Bn=0,Cn=0,Dn=0,En=0;a:{b:{c:{Cn=o[a>>2];Dn=o[a+4>>2]-Cn>>2;An=Dn+1|0;if(An>>>0<1073741824){Cn=o[a+8>>2]-Cn|0;En=Cn>>1;An=Cn>>2>>>0<536870911?En>>>0>>0?An:En:1073741823;if(An){if(An>>>0>=1073741824){break c}Bn=Hk(An<<2)}Cn=o[Rl>>2];o[Rl>>2]=0;Rl=(Dn<<2)+Bn|0;o[Rl>>2]=Cn;Cn=(An<<2)+Bn|0;Dn=Rl+4|0;An=o[a+4>>2];Bn=o[a>>2];if((An|0)==(Bn|0)){break b}while(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}if(m[$n+35|0]<=-1){ul(o[$n+24>>2])}a=o[$n+8>>2];if(a){o[$n+12>>2]=a;ul(a)}R=$n- -64|0}function oj(a,Rl,Mn){var eo=0,fo=0;eo=R-32|0;R=eo;fo=a+12|0;a:{if((xi(fo,Rl)|0)!=(a+16|0)){break a}o[eo+16>>2]=Rl;gj(eo+24|0,fo,Rl,eo+16|0);a=o[eo+24>>2];Rl=o[Mn>>2];o[Mn>>2]=0;Mn=a+28|0;a=o[Mn>>2];o[Mn>>2]=Rl;if(!a){break a}Fc(a+12|0,o[a+16>>2]);Gc(a,o[a+4>>2]);ul(a)}R=eo+32|0}function pj(a,Rl){var Mn=0,go=0,ho=0,io=0,jo=0,ko=0;a:{b:{go=Rl;ho=o[Rl>>2];if(ho){Mn=o[Rl+4>>2];if(!Mn){break b}while(1){go=Mn;Mn=o[Mn>>2];if(Mn){continue}break}}ho=o[go+4>>2];if(ho){break b}ho=0;jo=0;break a}o[ho+8>>2]=o[go+8>>2];jo=1}io=o[go+8>>2];Mn=o[io>>2];c:{if((Mn|0)==(go|0)){o[io>>2]=ho;if((a|0)==(go|0)){Mn=0;a=ho;break c}Mn=o[io+4>>2];break c}o[io+4>>2]=ho}d:{e:{f:{ko=!p[go+12|0];if((Rl|0)!=(go|0)){io=o[Rl+8>>2];o[go+8>>2]=io;o[io+((o[o[Rl+8>>2]>>2]!=(Rl|0))<<2)>>2]=go;io=o[Rl>>2];o[go>>2]=io;o[io+8>>2]=go;io=o[Rl+4>>2];o[go+4>>2]=io;if(io){o[io+8>>2]=go}m[go+12|0]=p[Rl+12|0];a=(a|0)==(Rl|0)?go:a}if(!(ko|!a)){if(!jo){while(1){Rl=p[Mn+12|0];g:{ho=o[Mn+8>>2];if(o[ho>>2]!=(Mn|0)){if(!Rl){m[Mn+12|0]=1;m[ho+12|0]=0;Rl=ho+4|0;jo=o[Rl>>2];go=o[jo>>2];o[Rl>>2]=go;if(go){o[go+8>>2]=ho}o[jo+8>>2]=o[ho+8>>2];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(a){o[a+8>>2]=Mn}o[Rl+8>>2]=o[Mn+8>>2];a=o[Mn+8>>2];o[((Mn|0)==o[a>>2]?a:a+4|0)>>2]=Rl;o[Rl+4>>2]=Mn;o[Mn+8>>2]=Rl;return}Rl=o[Mn+8>>2];Mn=o[(o[Rl>>2]==(Mn|0)?Rl+4|0:Rl)>>2];continue}}m[ho+12|0]=1}return}if(p[Rl+12|0]){break e}go=Mn;break d}m[go+12|0]=1;m[Mn+12|0]=0;a=o[go+4>>2];o[Mn>>2]=a;if(a){o[a+8>>2]=Mn}o[go+8>>2]=o[Mn+8>>2];a=o[Mn+8>>2];o[(o[a>>2]==(Mn|0)?a:a+4|0)>>2]=go;o[go+4>>2]=Mn;o[Mn+8>>2]=go;Rl=Mn}Mn=o[go+8>>2];m[go+12|0]=p[Mn+12|0];m[Mn+12|0]=1;m[Rl+12|0]=1;Rl=o[Mn+4>>2];a=o[Rl>>2];o[Mn+4>>2]=a;if(a){o[a+8>>2]=Mn}o[Rl+8>>2]=o[Mn+8>>2];a=o[Mn+8>>2];o[((Mn|0)==o[a>>2]?a:a+4|0)>>2]=Rl;o[Rl>>2]=Mn;o[Mn+8>>2]=Rl}function qj(a){o[a>>2]=10944;xl(a+4|0,0,80);return a}function rj(a,Rl){var lo=0;lo=-1;a:{if((Rl|0)==-1|(Rl|0)>4){break a}Rl=u(Rl,12)+a|0;a=o[Rl+20>>2];if((o[Rl+24>>2]-a|0)<1){break a}lo=o[a>>2]}return lo}function sj(a){var Rl=0,mo=0;Rl=o[a+20>>2];a:{if((o[a+24>>2]-Rl|0)<1){break a}Rl=o[Rl>>2];if((Rl|0)==-1){break a}mo=o[o[a+8>>2]+(Rl<<2)>>2]}return mo}function tj(a,no){var oo=0,po=0,qo=0;oo=o[a+8>>2];a=o[a+12>>2];a:{if((oo|0)==(a|0)){break a}qo=a-oo>>2;a=0;while(1){po=o[(a<<2)+oo>>2];if(o[po+60>>2]==(no|0)){break a}a=a+1|0;if(a>>>0>>0){continue}break}po=0}return po}function uj(a,no){var ro=0,so=0;ro=o[a+8>>2];a=o[a+12>>2];if((ro|0)!=(a|0)){so=a-ro>>2;a=0;while(1){if(o[o[(a<<2)+ro>>2]+60>>2]==(no|0)){return a}a=a+1|0;if(a>>>0>>0){continue}break}}return-1}function vj(a,no){var to=0,uo=0,vo=0,wo=0,xo=0;to=R-16|0;R=to;uo=a+12|0;vo=o[uo>>2];wo=o[a+8>>2];xo=o[no>>2];o[no>>2]=0;o[to+8>>2]=xo;l[o[o[a>>2]+8>>2]](a,vo-wo>>2,to+8|0);no=o[to+8>>2];o[to+8>>2]=0;if(no){Fb(no)}R=to+16|0;return(o[uo>>2]-o[a+8>>2]>>2)+ -1|0}function wj(a,no,yo){a=a|0;no=no|0;yo=yo|0;var zo=0,Ao=0,Bo=0,Co=0,Do=0,Eo=0;Co=R-16|0;R=Co;o[Co+12>>2]=no;Do=a+8|0;zo=o[a+12>>2];Eo=o[a+8>>2];Ao=zo-Eo>>2;a:{if((Ao|0)>(no|0)){break a}Bo=no+1|0;if(Bo>>>0>Ao>>>0){xj(Do,Bo-Ao|0);break a}if(Bo>>>0>=Ao>>>0){break a}Ao=Eo+(Bo<<2)|0;if((Ao|0)!=(zo|0)){while(1){zo=zo+ -4|0;Bo=o[zo>>2];o[zo>>2]=0;if(Bo){Fb(Bo)}if((zo|0)!=(Ao|0)){continue}break}}o[a+12>>2]=Ao}zo=o[o[yo>>2]+56>>2];b:{if((zo|0)>4){break b}zo=u(zo,12)+a|0;Ao=zo+24|0;a=o[Ao>>2];if((a|0)!=o[zo+28>>2]){o[a>>2]=no;o[Ao>>2]=a+4;break b}yj(zo+20|0,Co+12|0)}no=o[yo>>2];a=o[Co+12>>2];o[no+60>>2]=a;zo=o[Do>>2];o[yo>>2]=0;yo=zo+(a<<2)|0;a=o[yo>>2];o[yo>>2]=no;if(a){Fb(a)}R=Co+16|0}function xj(a,no){var yo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0;Fo=o[a+8>>2];Go=a+4|0;yo=o[Go>>2];if(Fo-yo>>2>>>0>=no>>>0){a=no<<2;Lo=Go,Mo=xl(yo,0,a)+a|0,o[Lo>>2]=Mo;return}a:{Go=o[a>>2];Ho=yo-Go>>2;Io=Ho+no|0;if(Io>>>0<1073741824){Ho=Ho<<2;Fo=Fo-Go|0;Ko=Fo>>1;Fo=Fo>>2>>>0<536870911?Ko>>>0>>0?Io:Ko:1073741823;if(Fo){if(Fo>>>0>=1073741824){break a}Jo=Hk(Fo<<2)}Ho=Ho+Jo|0;xl(Ho,0,no<<2);no=(Io<<2)+Jo|0;Io=(Fo<<2)+Jo|0;if((yo|0)!=(Go|0)){while(1){yo=yo+ -4|0;Fo=o[yo>>2];o[yo>>2]=0;Ho=Ho+ -4|0;o[Ho>>2]=Fo;if((yo|0)!=(Go|0)){continue}break}Go=o[a>>2];yo=o[a+4>>2]}o[a>>2]=Ho;o[a+8>>2]=Io;o[a+4>>2]=no;if((yo|0)!=(Go|0)){while(1){yo=yo+ -4|0;a=o[yo>>2];o[yo>>2]=0;if(a){Fb(a)}if((yo|0)!=(Go|0)){continue}break}}if(Go){ul(Go)}return}Yk();D()}_a(10992);D()}function yj(a,no){var No=0,Oo=0,Po=0,Qo=0,Ro=0,So=0;a:{Po=o[a>>2];Ro=o[a+4>>2]-Po|0;No=Ro>>2;Oo=No+1|0;if(Oo>>>0<1073741824){So=No<<2;No=o[a+8>>2]-Po|0;Qo=No>>1;Oo=No>>2>>>0<536870911?Qo>>>0>>0?Oo:Qo:1073741823;No=0;b:{if(!Oo){break b}if(Oo>>>0>=1073741824){break a}No=Hk(Oo<<2)}Qo=So+No|0;o[Qo>>2]=o[no>>2];no=No+(Oo<<2)|0;Oo=Qo+4|0;if((Ro|0)>=1){wl(No,Po,Ro)}o[a>>2]=No;o[a+8>>2]=no;o[a+4>>2]=Oo;if(Po){ul(Po)}return}Yk();D()}_a(10992);D()}function zj(a,no){a=a|0;no=no|0;var To=0,Uo=0,Vo=0,Wo=0,Xo=0,Yo=0,Zo=0;a:{if((no|0)<0){break a}To=o[a+12>>2];Uo=o[a+8>>2];if(To-Uo>>2>>>0<=no>>>0){break a}Uo=Uo+(no<<2)|0;Vo=o[Uo>>2];Yo=o[Vo+60>>2];Wo=o[Vo+56>>2];Vo=Uo+4|0;b:{if((Vo|0)!=(To|0)){while(1){Zo=o[Vo>>2];o[Vo>>2]=0;Xo=o[Uo>>2];o[Uo>>2]=Zo;if(Xo){Fb(Xo)}Uo=Uo+4|0;Vo=Vo+4|0;if((Vo|0)!=(To|0)){continue}break}To=o[a+12>>2];if((Uo|0)==(To|0)){break b}}while(1){To=To+ -4|0;Vo=o[To>>2];o[To>>2]=0;if(Vo){Fb(Vo)}if((To|0)!=(Uo|0)){continue}break}}o[a+12>>2]=Uo;To=o[a+4>>2];if(To){Aj(To,Yo)}c:{if((Wo|0)>4){break c}d:{Uo=u(Wo,12)+a|0;To=o[Uo+20>>2];Vo=Uo+24|0;Uo=o[Vo>>2];if((To|0)==(Uo|0)){break d}while(1){if(o[To>>2]==(no|0)){break d}To=To+4|0;if((Uo|0)!=(To|0)){continue}break}break c}if((To|0)==(Uo|0)){break c}Wo=To+4|0;Uo=Uo-Wo|0;Xo=Uo>>2;if(Uo){yl(To,Wo,Uo)}o[Vo>>2]=(Xo<<2)+To}To=o[a+24>>2];Uo=o[a+20>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+36>>2];Uo=o[a+32>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+48>>2];Uo=o[a+44>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+60>>2];Uo=o[a+56>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+72>>2];a=o[a+68>>2];if((To|0)==(a|0)){break a}Uo=To-a>>2;To=0;while(1){Vo=a+(To<<2)|0;Wo=o[Vo>>2];if((Wo|0)>(no|0)){o[Vo>>2]=Wo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}}function Aj(a,no){var _o=0,$o=0,ap=0,bp=0;a:{if((no|0)<0){break a}_o=o[a+28>>2];ap=o[a+24>>2];while(1){$o=ap;if((_o|0)==($o|0)){break a}ap=$o+4|0;if(o[o[$o>>2]+24>>2]!=(no|0)){continue}break}b:{if((_o|0)!=(ap|0)){while(1){no=o[ap>>2];o[ap>>2]=0;bp=o[$o>>2];o[$o>>2]=no;if(bp){Fc(bp+12|0,o[bp+16>>2]);Gc(bp,o[bp+4>>2]);ul(bp)}$o=$o+4|0;ap=ap+4|0;if((_o|0)!=(ap|0)){continue}break}_o=o[a+28>>2];if((_o|0)==($o|0)){break b}}while(1){_o=_o+ -4|0;no=o[_o>>2];o[_o>>2]=0;if(no){Fc(no+12|0,o[no+16>>2]);Gc(no,o[no+4>>2]);ul(no)}if(($o|0)!=(_o|0)){continue}break}}o[a+28>>2]=$o}}function Bj(a){a=a|0;ul(Mi(a))}function Cj(a){a=a|0}function Dj(a){var no=0;no=p[a+74|0];m[a+74|0]=no+ -1|no;no=o[a>>2];if(no&8){o[a>>2]=no|32;return-1}o[a+4>>2]=0;o[a+8>>2]=0;no=o[a+44>>2];o[a+28>>2]=no;o[a+20>>2]=no;o[a+16>>2]=no+o[a+48>>2];return 0}function Ej(a,cp,dp){var ep=0,fp=0,gp=0;ep=o[dp+16>>2];a:{if(!ep){if(Dj(dp)){break a}ep=o[dp+16>>2]}gp=o[dp+20>>2];if(ep-gp>>>0>>0){l[o[dp+36>>2]](dp,a,cp)|0;return}b:{if(m[dp+75|0]<0){break b}ep=cp;while(1){fp=ep;if(!fp){break b}ep=fp+ -1|0;if(p[ep+a|0]!=10){continue}break}if(l[o[dp+36>>2]](dp,a,fp)>>>0>>0){break a}cp=cp-fp|0;a=a+fp|0;gp=o[dp+20>>2]}wl(gp,a,cp);o[dp+20>>2]=o[dp+20>>2]+cp}}function Fj(a,cp,dp){var hp=0,ip=0,jp=0,kp=0;hp=R-208|0;R=hp;o[hp+204>>2]=dp;dp=0;xl(hp+160|0,0,40);o[hp+200>>2]=o[hp+204>>2];a:{if((Gj(0,cp,hp+200|0,hp+80|0,hp+160|0)|0)<0){cp=-1;break a}dp=o[a+76>>2]>=0?1:dp;ip=o[a>>2];if(m[a+74|0]<=0){o[a>>2]=ip&-33}kp=ip&32;b:{if(o[a+48>>2]){cp=Gj(a,cp,hp+200|0,hp+80|0,hp+160|0);break b}o[a+48>>2]=80;o[a+16>>2]=hp+80;o[a+28>>2]=hp;o[a+20>>2]=hp;ip=o[a+44>>2];o[a+44>>2]=hp;jp=Gj(a,cp,hp+200|0,hp+80|0,hp+160|0);cp=jp;if(!ip){break b}l[o[a+36>>2]](a,0,0)|0;o[a+48>>2]=0;o[a+44>>2]=ip;o[a+28>>2]=0;o[a+16>>2]=0;cp=o[a+20>>2];o[a+20>>2]=0;cp=cp?jp:-1}jp=a;a=o[a>>2];o[jp>>2]=a|kp;cp=a&32?-1:cp;if(!dp){break a}}R=hp+208|0;return cp}function Gj(a,cp,dp,lp,mp){var np=0,op=0,pp=0,qp=0,rp=0,sp=0,tp=0,up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0;np=R-80|0;R=np;o[np+76>>2]=cp;Bp=np+55|0;yp=np+56|0;cp=0;a:{b:while(1){c:{if((vp|0)<0){break c}if((cp|0)>(2147483647-vp|0)){o[3269]=61;vp=-1;break c}vp=cp+vp|0}d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:{q:{rp=o[np+76>>2];cp=rp;qp=p[cp|0];if(qp){while(1){r:{s:{op=qp&255;t:{if(!op){qp=cp;break t}if((op|0)!=37){break s}qp=cp;while(1){if(p[cp+1|0]!=37){break t}op=cp+2|0;o[np+76>>2]=op;qp=qp+1|0;pp=p[cp+2|0];cp=op;if((pp|0)==37){continue}break}}cp=qp-rp|0;if(a){Hj(a,rp,cp)}if(cp){continue b}wp=-1;qp=1;op=np;sp=!Uj(m[o[np+76>>2]+1|0]);cp=o[np+76>>2];if(!(sp|p[cp+2|0]!=36)){wp=m[cp+1|0]+ -48|0;zp=1;qp=3}cp=qp+cp|0;o[op+76>>2]=cp;qp=0;xp=m[cp|0];pp=xp+ -32|0;u:{if(pp>>>0>31){op=cp;break u}op=cp;pp=1<>2]=op;qp=pp|qp;xp=m[cp+1|0];pp=xp+ -32|0;if(pp>>>0>31){break u}cp=op;pp=1<>2];if(p[cp+2|0]!=36){break x}o[((m[cp+1|0]<<2)+mp|0)+ -192>>2]=10;tp=o[((m[cp+1|0]<<3)+lp|0)+ -384>>2];zp=1;cp=cp+3|0;break w}if(zp){break q}zp=0;tp=0;if(a){cp=o[dp>>2];o[dp>>2]=cp+4;tp=o[cp>>2]}cp=o[np+76>>2]+1|0}o[sp+76>>2]=cp;if((tp|0)>-1){break v}tp=0-tp|0;qp=qp|8192;break v}tp=Ij(np+76|0);if((tp|0)<0){break q}cp=o[np+76>>2]}pp=-1;y:{if(p[cp|0]!=46){break y}if(p[cp+1|0]==42){z:{if(!Uj(m[cp+2|0])){break z}cp=o[np+76>>2];if(p[cp+3|0]!=36){break z}o[((m[cp+2|0]<<2)+mp|0)+ -192>>2]=10;pp=o[((m[cp+2|0]<<3)+lp|0)+ -384>>2];cp=cp+4|0;o[np+76>>2]=cp;break y}if(zp){break q}if(a){cp=o[dp>>2];o[dp>>2]=cp+4;pp=o[cp>>2]}else{pp=0}cp=o[np+76>>2]+2|0;o[np+76>>2]=cp;break y}o[np+76>>2]=cp+1;pp=Ij(np+76|0);cp=o[np+76>>2]}op=0;while(1){Ap=op;up=-1;if(m[cp|0]+ -65>>>0>57){break a}xp=cp+1|0;o[np+76>>2]=xp;op=m[cp|0];cp=xp;op=p[(op+u(Ap,58)|0)+11023|0];if(op+ -1>>>0<8){continue}break}if(!op){break a}A:{B:{C:{if((op|0)==19){if((wp|0)<=-1){break C}break a}if((wp|0)<0){break B}o[(wp<<2)+mp>>2]=op;cp=(wp<<3)+lp|0;op=o[cp+4>>2];o[np+64>>2]=o[cp>>2];o[np+68>>2]=op}cp=0;if(!a){continue b}break A}if(!a){break d}Jj(np- -64|0,op,dp);xp=o[np+76>>2]}sp=qp&-65537;qp=qp&8192?sp:qp;up=0;wp=11060;op=yp;cp=m[xp+ -1|0];cp=Ap?(cp&15)==3?cp&-33:cp:cp;xp=cp+ -88|0;if(xp>>>0<=32){break r}D:{E:{F:{G:{sp=cp+ -65|0;if(sp>>>0>6){if((cp|0)!=83){break e}if(!pp){break G}op=o[np+64>>2];break E}switch(sp-1|0){case 1:break F;case 0:case 2:break e;default:break p}}cp=0;Kj(a,32,tp,0,qp);break D}o[np+12>>2]=0;o[np+8>>2]=o[np+64>>2];o[np+64>>2]=np+8;pp=-1;op=np+8|0}cp=0;H:{while(1){rp=o[op>>2];if(!rp){break H}rp=Vj(np+4|0,rp);sp=(rp|0)<0;if(!(sp|rp>>>0>pp-cp>>>0)){op=op+4|0;cp=cp+rp|0;if(pp>>>0>cp>>>0){continue}break H}break}up=-1;if(sp){break a}}Kj(a,32,tp,cp,qp);if(!cp){cp=0;break D}pp=0;op=o[np+64>>2];while(1){rp=o[op>>2];if(!rp){break D}rp=Vj(np+4|0,rp);pp=rp+pp|0;if((pp|0)>(cp|0)){break D}Hj(a,np+4|0,rp);op=op+4|0;if(pp>>>0>>0){continue}break}}Kj(a,32,tp,cp,qp^8192);cp=(tp|0)>(cp|0)?tp:cp;continue b}op=cp+1|0;o[np+76>>2]=op;qp=p[cp+1|0];cp=op;continue}break}switch(xp-1|0){case 21:break i;case 23:break k;case 22:break l;case 11:case 16:break m;case 10:break n;case 26:break o;case 8:case 12:case 13:case 14:break p;case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 9:case 15:case 17:case 18:case 19:case 20:case 24:case 25:case 27:case 29:case 30:break e;case 28:break h;default:break j}}up=vp;if(a){break a}if(!zp){break d}cp=1;while(1){a=o[(cp<<2)+mp>>2];if(a){Jj((cp<<3)+lp|0,a,dp);up=1;cp=cp+1|0;if((cp|0)!=10){continue}break a}break}up=1;if(cp>>>0>=10){break a}while(1){if(o[(cp<<2)+mp>>2]){break q}a=cp>>>0>8;cp=cp+1|0;if(!a){continue}break}break a}up=-1;break a}cp=l[269](a,t[np+64>>3],tp,pp,qp,cp)|0;continue}cp=o[np+64>>2];rp=cp?cp:11070;cp=$j(rp,pp);op=cp?cp:pp+rp|0;qp=sp;pp=cp?cp-rp|0:pp;break e}m[np+55|0]=o[np+64>>2];pp=1;rp=Bp;qp=sp;break e}sp=o[np+68>>2];cp=sp;rp=o[np+64>>2];if((cp|0)<-1?1:(cp|0)<=-1?rp>>>0>4294967295?0:1:0){cp=0-(cp+(0>>0)|0)|0;rp=0-rp|0;o[np+64>>2]=rp;o[np+68>>2]=cp;up=1;wp=11060;break g}if(qp&2048){up=1;wp=11061;break g}up=qp&1;wp=up?11062:11060;break g}rp=Lj(o[np+64>>2],o[np+68>>2],yp);if(!(qp&8)){break f}cp=yp-rp|0;pp=(pp|0)>(cp|0)?pp:cp+1|0;break f}pp=pp>>>0>8?pp:8;qp=qp|8;cp=120}rp=Mj(o[np+64>>2],o[np+68>>2],yp,cp&32);if(!(qp&8)|!(o[np+64>>2]|o[np+68>>2])){break f}wp=(cp>>>4)+11060|0;up=2;break f}cp=0;op=Ap&255;if(op>>>0>7){continue}I:{switch(op-1|0){default:o[o[np+64>>2]>>2]=vp;continue;case 0:o[o[np+64>>2]>>2]=vp;continue;case 1:op=o[np+64>>2];o[op>>2]=vp;o[op+4>>2]=vp>>31;continue;case 2:n[o[np+64>>2]>>1]=vp;continue;case 3:m[o[np+64>>2]]=vp;continue;case 5:o[o[np+64>>2]>>2]=vp;continue;case 4:continue;case 6:break I}}op=o[np+64>>2];o[op>>2]=vp;o[op+4>>2]=vp>>31;continue}rp=o[np+64>>2];cp=o[np+68>>2];wp=11060}rp=Nj(rp,cp,yp)}qp=(pp|0)>-1?qp&-65537:qp;cp=o[np+64>>2];sp=o[np+68>>2];J:{if(!(!!(cp|sp)|pp)){rp=yp;pp=0;break J}cp=!(cp|sp)+(yp-rp|0)|0;pp=(pp|0)>(cp|0)?pp:cp}}sp=op-rp|0;pp=(pp|0)<(sp|0)?sp:pp;op=pp+up|0;cp=(tp|0)<(op|0)?op:tp;Kj(a,32,cp,op,qp);Hj(a,wp,up);Kj(a,48,cp,op,qp^65536);Kj(a,48,pp,sp,0);Hj(a,rp,sp);Kj(a,32,cp,op,qp^8192);continue}break}up=0}R=np+80|0;return up}function Hj(a,o,cp){if(!(p[a|0]&32)){Ej(o,cp,a)}}function Ij(a){var cp=0,dp=0,lp=0;if(Uj(m[o[a>>2]])){while(1){cp=o[a>>2];lp=m[cp|0];o[a>>2]=cp+1;dp=(u(dp,10)+lp|0)+ -48|0;if(Uj(m[cp+1|0])){continue}break}}return dp}function Jj(a,mp,Cp){a:{b:{if(mp>>>0>20){break b}mp=mp+ -9|0;if(mp>>>0>9){break b}c:{switch(mp-1|0){default:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=o[mp>>2];return;case 0:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=o[mp>>2];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 1:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=o[mp>>2];o[a+4>>2]=0;return;case 3:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=n[mp>>1];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 4:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=q[mp>>1];o[a+4>>2]=0;return;case 5:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=m[mp|0];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 6:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=p[mp|0];o[a+4>>2]=0;return;case 2:case 7:break a;case 8:break c}}l[270](a,Cp)}return}mp=o[Cp>>2]+7&-8;o[Cp>>2]=mp+8;Cp=o[mp+4>>2];o[a>>2]=o[mp>>2];o[a+4>>2]=Cp}function Kj(a,o,mp,Cp,Dp){var Ep=0,Fp=0,Gp=0;Ep=R-256|0;R=Ep;if(!(Dp&73728|(mp|0)<=(Cp|0))){Dp=mp-Cp|0;Fp=Dp>>>0<256;xl(Ep,o,Fp?Dp:256);o=a;Gp=Ep;if(!Fp){mp=mp-Cp|0;while(1){Hj(a,Ep,256);Dp=Dp+ -256|0;if(Dp>>>0>255){continue}break}Dp=mp&255}Hj(o,Gp,Dp)}R=Ep+256|0}function Lj(a,o,mp){if(a|o){while(1){mp=mp+ -1|0;m[mp|0]=a&7|48;a=(o&7)<<29|a>>>3;o=o>>>3;if(a|o){continue}break}}return mp}function Mj(a,o,mp,Cp){if(a|o){while(1){mp=mp+ -1|0;m[mp|0]=p[(a&15)+11552|0]|Cp;a=(o&15)<<28|a>>>4;o=o>>>4;if(a|o){continue}break}}return mp}function Nj(a,o,mp){var Cp=0,Dp=0,Hp=0;a:{if((o|0)==1&a>>>0<0|o>>>0<1){Cp=a;break a}while(1){Cp=Xl(a,o,10,0);Dp=T;Hp=Dp;Dp=Vl(Cp,Dp,10,0);mp=mp+ -1|0;m[mp|0]=a-Dp|48;Dp=(o|0)==9&a>>>0>4294967295|o>>>0>9;a=Cp;o=Hp;if(Dp){continue}break}}if(Cp){while(1){mp=mp+ -1|0;a=(Cp>>>0)/10|0;m[mp|0]=Cp-u(a,10)|48;o=Cp>>>0>9;Cp=a;if(o){continue}break}}return mp}function Oj(a,o,mp){return Fj(a,o,mp)}function Pj(a,mp,Ip,Jp,Kp,Lp){a=a|0;mp=+mp;Ip=Ip|0;Jp=Jp|0;Kp=Kp|0;Lp=Lp|0;var Mp=0,Np=0,Op=0,Pp=0,Qp=0,Rp=0,Sp=0,Tp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0,eq=0,fq=0,gq=0,hq=0,iq=0;Qp=R-560|0;R=Qp;o[Qp+44>>2]=0;h(+mp);Mp=e(1)|0;a:{if(dq=1,eq=(gq=e(0)>>>0>4294967295?0:1,hq=0,iq=(Mp|0)<=-1,iq?gq:hq),fq=(Mp|0)<-1,fq?dq:eq){mp=-mp;h(+mp);Mp=e(1)|0;e(0)|0;_p=1;$p=11568;break a}if(Kp&2048){_p=1;$p=11571;break a}_p=Kp&1;$p=_p?11574:11569}b:{if((Mp&2146435072)==2146435072){Sp=_p+3|0;Kj(a,32,Ip,Sp,Kp&-65537);Hj(a,$p,_p);Jp=Lp>>>5&1;Hj(a,mp!=mp?Jp?11595:11599:Jp?11587:11591,3);break b}mp=Xj(mp,Qp+44|0);mp=mp+mp;if(mp!=0){o[Qp+44>>2]=o[Qp+44>>2]+ -1}Xp=Qp+16|0;aq=Lp|32;if((aq|0)==97){Rp=Lp&32;Np=Rp?$p+9|0:$p;c:{if(Jp>>>0>11){break c}Mp=12-Jp|0;if(!Mp){break c}Yp=8;while(1){Yp=Yp*16;Mp=Mp+ -1|0;if(Mp){continue}break}if(p[Np|0]==45){mp=-(Yp+(-mp-Yp));break c}mp=mp+Yp-Yp}Pp=o[Qp+44>>2];Mp=Pp>>31;Mp=Nj(Mp^Mp+Pp,0,Xp);if((Xp|0)==(Mp|0)){m[Qp+15|0]=48;Mp=Qp+15|0}Pp=_p|2;Op=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);Wp=Sp;Sp=Vl(Np,T,1e9,0);o[Wp>>2]=Vp-Sp;Mp=Mp+ -4|0;if(Mp>>>0>=Op>>>0){continue}break}if(!Np){break f}Op=Op+ -4|0;o[Op>>2]=Np}while(1){Mp=Pp;if(Mp>>>0>Op>>>0){Pp=Mp+ -4|0;if(!o[Pp>>2]){continue}}break}Np=o[Qp+44>>2]-Tp|0;o[Qp+44>>2]=Np;Pp=Mp;if((Np|0)>0){continue}break}}if((Np|0)<=-1){Zp=((Rp+25|0)/9|0)+1|0;Tp=(aq|0)==102;while(1){Jp=(Np|0)<-9?9:0-Np|0;g:{if(Op>>>0>=Mp>>>0){Op=o[Op>>2]?Op:Op+4|0;break g}Sp=1e9>>>Jp;Vp=-1<>2];o[Pp>>2]=Wp+(Np>>>Jp);Np=u(Sp,Np&Vp);Pp=Pp+4|0;if(Pp>>>0>>0){continue}break}Op=o[Op>>2]?Op:Op+4|0;if(!Np){break g}o[Mp>>2]=Np;Mp=Mp+4|0}Np=Jp+o[Qp+44>>2]|0;o[Qp+44>>2]=Np;Jp=Tp?Up:Op;Mp=Mp-Jp>>2>(Zp|0)?Jp+(Zp<<2)|0:Mp;if((Np|0)<0){continue}break}}Pp=0;h:{if(Op>>>0>=Mp>>>0){break h}Pp=u(Up-Op>>2,9);Np=10;Jp=o[Op>>2];if(Jp>>>0<10){break h}while(1){Pp=Pp+1|0;Np=u(Np,10);if(Jp>>>0>=Np>>>0){continue}break}}Jp=(Rp-((aq|0)==102?0:Pp)|0)-((aq|0)==103&(Rp|0)!=0)|0;if((Jp|0)<(u(Mp-Up>>2,9)+ -9|0)){Np=Jp+9216|0;Sp=(Np|0)/9|0;Tp=(Up+(Sp<<2)|0)+ -4092|0;Jp=10;Np=Np-u(Sp,9)|0;if((Np|0)<=7){while(1){Jp=u(Jp,10);Sp=(Np|0)<7;Np=Np+1|0;if(Sp){continue}break}}Sp=o[Tp>>2];Vp=(Sp>>>0)/(Jp>>>0)|0;Zp=Tp+4|0;Np=S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+24|0]=48;Mp=Jp}s:{if((Op|0)!=(Pp|0)){if(Mp>>>0<=Qp+16>>>0){break s}while(1){Mp=Mp+ -1|0;m[Mp|0]=48;if(Mp>>>0>Qp+16>>>0){continue}break}break s}Hj(a,Mp,1);Mp=Mp+1|0;if((Rp|0)<1?!Vp:0){break s}Hj(a,11603,1)}Np=Mp;Mp=Lp-Mp|0;Hj(a,Np,(Rp|0)>(Mp|0)?Mp:Rp);Rp=Rp-Mp|0;Pp=Pp+4|0;if(Pp>>>0>=Up>>>0){break r}if((Rp|0)>-1){continue}break}}Kj(a,48,Rp+18|0,18,0);Hj(a,Zp,Xp-Zp|0);break n}Mp=Rp}Kj(a,48,Mp+9|0,9,0)}}Kj(a,32,Ip,Sp,Kp^8192);R=Qp+560|0;return((Sp|0)<(Ip|0)?Ip:Sp)|0}function Qj(a,mp){a=a|0;mp=mp|0;var Ip=0,Jp=0,Kp=0;Ip=mp;mp=o[mp>>2]+15&-16;o[Ip>>2]=mp+16;Jp=a,Kp=dk(o[mp>>2],o[mp+4>>2],o[mp+8>>2],o[mp+12>>2]),t[Jp>>3]=Kp}function Rj(a,mp,Lp){a=a|0;mp=mp|0;Lp=Lp|0;var jq=0,kq=0,lq=0,mq=0,nq=0,oq=0;jq=R-32|0;R=jq;kq=o[a+28>>2];o[jq+16>>2]=kq;lq=o[a+20>>2];o[jq+28>>2]=Lp;o[jq+24>>2]=mp;mp=lq-kq|0;o[jq+20>>2]=mp;lq=mp+Lp|0;nq=2;mp=jq+16|0;while(1){a:{b:{if(ak(I(o[a+60>>2],mp|0,nq|0,jq+12|0)|0)){o[jq+12>>2]=-1;kq=-1;break b}kq=o[jq+12>>2]}c:{if((kq|0)==(lq|0)){mp=o[a+44>>2];o[a+28>>2]=mp;o[a+20>>2]=mp;o[a+16>>2]=mp+o[a+48>>2];a=Lp;break c}if((kq|0)>-1){break a}o[a+28>>2]=0;o[a+16>>2]=0;o[a+20>>2]=0;o[a>>2]=o[a>>2]|32;a=0;if((nq|0)==2){break c}a=Lp-o[mp+4>>2]|0}R=jq+32|0;return a|0}mq=o[mp+4>>2];oq=kq>>>0>mq>>>0;mp=oq?mp+8|0:mp;mq=kq-(oq?mq:0)|0;o[mp>>2]=mq+o[mp>>2];o[mp+4>>2]=o[mp+4>>2]-mq;lq=lq-kq|0;nq=nq-oq|0;continue}}function Sj(a,mp,Lp,pq){a=a|0;mp=mp|0;Lp=Lp|0;pq=pq|0;var qq=0;qq=R-16|0;R=qq;a:{if(!ak(Q(o[a+60>>2],mp|0,Lp|0,pq&255,qq+8|0)|0)){mp=o[qq+12>>2];a=o[qq+8>>2];break a}o[qq+8>>2]=-1;o[qq+12>>2]=-1;mp=-1;a=-1}R=qq+16|0;T=mp;return a|0}function Tj(a){a=a|0;return J(o[a+60>>2])|0}function Uj(a){return a+ -48>>>0<10}function Vj(a,o){if(!a){return 0}return Wj(a,o)}function Wj(a,mp){a:{if(a){if(mp>>>0<=127){break a}b:{if(!o[o[3253]>>2]){if((mp&-128)==57216){break a}break b}if(mp>>>0<=2047){m[a+1|0]=mp&63|128;m[a|0]=mp>>>6|192;return 2}if(!((mp&-8192)!=57344?mp>>>0>=55296:0)){m[a+2|0]=mp&63|128;m[a|0]=mp>>>12|224;m[a+1|0]=mp>>>6&63|128;return 3}if(mp+ -65536>>>0<=1048575){m[a+3|0]=mp&63|128;m[a|0]=mp>>>18|240;m[a+2|0]=mp>>>6&63|128;m[a+1|0]=mp>>>12&63|128;return 4}}o[3269]=25;a=-1}else{a=1}return a}m[a|0]=mp;return 1}function Xj(a,mp){var Lp=0,pq=0,rq=0;h(+a);Lp=e(1)|0;pq=e(0)|0;rq=Lp;Lp=Lp>>>20&2047;if((Lp|0)!=2047){if(!Lp){Lp=mp;if(a==0){mp=0}else{a=Xj(a*0x10000000000000000,mp);mp=o[mp>>2]+ -64|0}o[Lp>>2]=mp;return a}o[mp>>2]=Lp+ -1022;f(0,pq|0);f(1,rq&-2146435073|1071644672);a=+g()}return a}function Yj(a){var o=0,mp=0,sq=0,tq=0,uq=0,vq=0;while(1){o=a;a=o+1|0;mp=m[o|0];if((mp|0)==32|mp+ -9>>>0<5){continue}break}mp=m[o|0];tq=mp+ -43|0;a:{if(tq>>>0>2){break a}b:{switch(tq-1|0){case 1:uq=1;break;case 0:break a;default:break b}}mp=m[a|0];o=a;vq=uq}if(Uj(mp)){while(1){sq=(u(sq,10)-m[o|0]|0)+48|0;a=m[o+1|0];o=o+1|0;if(Uj(a)){continue}break}}return vq?sq:0-sq|0}function Zj(a,wq,xq){var yq=0,zq=0,Aq=0;a:{if(!xq){break a}while(1){yq=p[a|0];zq=p[wq|0];if((yq|0)==(zq|0)){wq=wq+1|0;a=a+1|0;xq=xq+ -1|0;if(xq){continue}break a}break}Aq=yq-zq|0}return Aq}function _j(a){var wq=0,xq=0,Bq=0;a:{b:{wq=a;if(!(wq&3)){break b}if(!p[a|0]){break a}while(1){wq=wq+1|0;if(!(wq&3)){break b}if(p[wq|0]){continue}break}break a}while(1){xq=wq;wq=wq+4|0;Bq=o[xq>>2];if(!((Bq^-1)&Bq+ -16843009&-2139062144)){continue}break}if(!(Bq&255)){wq=xq;break a}while(1){Bq=p[xq+1|0];wq=xq+1|0;xq=wq;if(Bq){continue}break}}return wq-a|0}function $j(a,Cq){var Dq=0,Eq=0,Fq=0;Dq=(Cq|0)!=0;a:{b:{c:{d:{if(!Cq|!(a&3)){break d}while(1){if(!p[a|0]){break c}a=a+1|0;Cq=Cq+ -1|0;Dq=(Cq|0)!=0;if(!Cq){break d}if(a&3){continue}break}}if(!Dq){break b}}if(!p[a|0]){break a}e:{if(Cq>>>0>=4){Dq=Cq+ -4|0;Eq=Dq&-4;Dq=Dq-Eq|0;Eq=(a+Eq|0)+4|0;while(1){Fq=o[a>>2];if((Fq^-1)&Fq+ -16843009&-2139062144){break e}a=a+4|0;Cq=Cq+ -4|0;if(Cq>>>0>3){continue}break}Cq=Dq;a=Eq}if(!Cq){break b}}while(1){if(!p[a|0]){break a}a=a+1|0;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iq+1|0}Vq=Jq;Jq=Iq;Iq=Uq+ -1140785152|0;Wq=Tq;if(Tq>>>0<0){Iq=Iq+1|0}a:{if((Iq|0)==(Jq|0)&Vq>>>0>>0|Jq>>>0>>0){Iq=Hq<<4|Gq>>>28;Gq=Gq<<4|Cq>>>28;Cq=Cq&268435455;Tq=Cq;if((Cq|0)==134217728&a>>>0>=1|Cq>>>0>134217728){Iq=Iq+1073741824|0;a=Gq+1|0;if(a>>>0<1){Iq=Iq+1|0}Jq=a;break a}Jq=Gq;Iq=Iq-((Gq>>>0<0)+ -1073741824|0)|0;if(a|Tq^134217728){break a}a=Jq+(Jq&1)|0;if(a>>>0>>0){Iq=Iq+1|0}Jq=a;break a}if(!(!Tq&(Uq|0)==2147418112?!(a|Cq):(Uq|0)==2147418112&Tq>>>0<0|Uq>>>0<2147418112)){Iq=Hq<<4|Gq>>>28;Jq=Gq<<4|Cq>>>28;Iq=Iq&524287|2146959360;break a}Jq=0;Iq=2146435072;if((Uq|0)==1140785151&Tq>>>0>4294967295|Uq>>>0>1140785151){break a}Iq=0;Tq=Uq>>>16;if(Tq>>>0<15249){break a}Iq=Hq&65535|65536;ck(Sq,a,Cq,Gq,Iq,15361-Tq|0);bk(Sq+16|0,a,Cq,Gq,Iq,Tq+ -15233|0);Gq=o[Sq+4>>2];a=o[Sq+8>>2];Iq=o[Sq+12>>2]<<4|a>>>28;Jq=a<<4|Gq>>>28;a=Gq&268435455;Gq=a;Cq=o[Sq>>2]|((o[Sq+16>>2]|o[Sq+24>>2])!=0|(o[Sq+20>>2]|o[Sq+28>>2])!=0);if((a|0)==134217728&Cq>>>0>=1|a>>>0>134217728){a=Jq+1|0;if(a>>>0<1){Iq=Iq+1|0}Jq=a;break a}if(Cq|Gq^134217728){break a}a=Jq+(Jq&1)|0;if(a>>>0>>0){Iq=Iq+1|0}Jq=a}R=Sq+32|0;f(0,Jq|0);f(1,Hq&-2147483648|Iq);return+g()}function ek(a){var Cq=0,Gq=0,Hq=0,Xq=0,Yq=0,Zq=0,_q=0,$q=0;Xq=R-16|0;R=Xq;o[Xq+12>>2]=a;a:{if(a>>>0<=211){a=o[fk(11616,11808,Xq+12|0)>>2];break a}Yq=(a>>>0)/210|0;Hq=u(Yq,210);o[Xq+8>>2]=a-Hq;Zq=fk(11808,12e3,Xq+8|0)-11808>>2;b:{while(1){a=o[(Zq<<2)+11808>>2]+Hq|0;Hq=5;c:{d:{e:{while(1){if((Hq|0)==47){break e}Cq=o[(Hq<<2)+11616>>2];Gq=(a>>>0)/(Cq>>>0)|0;_q=Gq>>>0>>0;$q=_q?a:$q;Hq=Hq+1|0;Cq=_q?1:(u(Cq,Gq)|0)==(a|0)?7:0;if(!Cq){continue}break}Hq=Cq+ -4|0;if(Hq>>>0>3){break b}switch(Hq-1|0){case 0:case 1:break b;case 2:break d;default:break e}}Hq=211;while(1){Cq=(a>>>0)/(Hq>>>0)|0;if(Cq>>>0>>0){break c}if((u(Cq,Hq)|0)==(a|0)){break d}Cq=Hq+10|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+12|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+16|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+18|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+22|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+28|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+30|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+36|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+40|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+42|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+46|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+52|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+58|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+60|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+66|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+70|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+72|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+78|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+82|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+88|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+96|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+100|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+102|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+106|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+108|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+112|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+120|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+126|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+130|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+136|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+138|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+142|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+148|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+150|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+156|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+162|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+166|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+168|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+172|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+178|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+180|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+186|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+190|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+192|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+196|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+198|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+208|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}Hq=Hq+210|0;if((u(Cq,Gq)|0)!=(a|0)){continue}break}}Hq=Zq+1|0;a=(Hq|0)==48;Zq=a?0:Hq;Yq=a+Yq|0;Hq=u(Yq,210);continue}break}o[Xq+12>>2]=a;break a}o[Xq+12>>2]=a;a=$q}R=Xq+16|0;return a}function fk(a,ar,br){return gk(a,ar,br)}function gk(a,ar,br){var cr=0;cr=R-16|0;R=cr;a=hk(a,ar,br);R=cr+16|0;return a}function hk(a,ar,br){var dr=0,er=0,fr=0,gr=0;dr=R-16|0;R=dr;ar=ar-a>>2;while(1){if(ar){o[dr+12>>2]=a;er=dr+12|0;fr=er;gr=o[er>>2];er=ar>>>1;o[fr>>2]=gr+(er<<2);if(ik(o[dr+12>>2],br)){a=o[dr+12>>2]+4|0;o[dr+12>>2]=a;ar=(er^-1)+ar|0}else{ar=er}continue}break}R=dr+16|0;return a}function ik(a,ar){return r[a>>2]>2]}function jk(a,ar,br){if(br){wl(a,ar,br)}}function kk(a,ar){return lk(a,ar)}function lk(a,ar){var br=0,hr=0;br=R-16|0;R=br;hr=ik(a,ar);R=br+16|0;return hr?ar:a}function mk(a){o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0}function nk(a,ar){var ir=0,jr=0;ir=p[a|0];jr=p[ar|0];a:{if(!ir|(ir|0)!=(jr|0)){break a}while(1){jr=p[ar+1|0];ir=p[a+1|0];if(!ir){break a}ar=ar+1|0;a=a+1|0;if((ir|0)==(jr|0)){continue}break}}return ir-jr|0}function ok(){var a=0,ar=0,kr=0;a=R-16|0;R=a;a:{if(K(a+12|0,a+8|0)){break a}ar=tl((o[a+12>>2]<<2)+4|0);o[3286]=ar;if(!ar){break a}b:{ar=tl(o[a+8>>2]);if(ar){kr=o[3286];if(kr){break b}}o[3286]=0;break a}o[(o[a+12>>2]<<2)+kr>>2]=0;if(!L(o[3286],ar|0)){break a}o[3286]=0}R=a+16|0}function pk(lr,mr,nr){var or=0,pr=0;or=R-160|0;R=or;wl(or+8|0,12e3,144);a:{b:{if(mr+ -1>>>0>=2147483647){if(mr){break b}mr=1;lr=or+159|0}o[or+52>>2]=lr;o[or+28>>2]=lr;pr=-2-lr|0;mr=mr>>>0>pr>>>0?pr:mr;o[or+56>>2]=mr;lr=lr+mr|0;o[or+36>>2]=lr;o[or+24>>2]=lr;lr=Oj(or+8|0,12225,nr);if(!mr){break a}mr=o[or+28>>2];m[mr-((mr|0)==o[or+24>>2])|0]=0;break a}o[3269]=61;lr=-1}R=or+160|0;return lr}function qk(lr,mr,nr){lr=lr|0;mr=mr|0;nr=nr|0;var qr=0,rr=0;rr=o[lr+20>>2];qr=o[lr+16>>2]-rr|0;qr=qr>>>0>nr>>>0?nr:qr;wl(rr,mr,qr);o[lr+20>>2]=qr+o[lr+20>>2];return nr|0}function rk(lr,mr,nr){var sr=0;sr=R-16|0;R=sr;o[sr+12>>2]=nr;lr=pk(lr,mr,nr);R=sr+16|0;return lr}function sk(lr){if(wk(lr)){return o[lr+4>>2]}return p[lr+11|0]}function tk(lr){if(wk(lr)){lr=xk(lr)+ -1|0}else{lr=10}return lr}function uk(lr,mr){Rk(lr,mr)}function vk(lr){var mr=0;mr=lr;lr=0;while(1){if((lr|0)!=3){o[(lr<<2)+mr>>2]=0;lr=lr+1|0;continue}break}}function wk(lr){return m[lr+11|0]<0}function xk(lr){return o[lr+8>>2]&2147483647}function yk(lr){if(wk(lr)){return o[lr>>2]}return lr}function zk(lr,nr){m[lr|0]=p[nr|0]}function Ak(lr,nr){o[lr+4>>2]=nr}function Bk(lr,nr){m[lr+11|0]=nr}function Ck(lr){var nr=0;if(lr>>>0>=11){nr=lr+16&-16;lr=nr+ -1|0;lr=(lr|0)==11?nr:lr}else{lr=10}return lr}function Dk(lr){if(4294967295>>0){_a(12144);D()}return Hk(lr)}function Ek(lr,tr){o[lr>>2]=tr}function Fk(lr,tr){o[lr+8>>2]=tr|-2147483648}function Gk(lr,tr){if(wk(lr)){Ak(lr,tr);return}Bk(lr,tr)}function Hk(lr){var tr=0,ur=0;lr=lr?lr:1;while(1){a:{tr=tl(lr);if(tr){break a}ur=o[3287];if(!ur){break a}l[ur]();continue}break}return tr}function Ik(lr,vr){var wr=0,xr=0,yr=0,zr=0;wr=_j(vr);xr=Hk(wr+13|0);o[xr+8>>2]=0;o[xr+4>>2]=wr;o[xr>>2]=wr;yr=lr,zr=wl(xr+12|0,vr,wr+1|0),o[yr>>2]=zr}function Jk(lr){var vr=0,Ar=0,Br=0;vr=R-16|0;R=vr;m[vr+15|0]=10;Ar=o[lr+16>>2];a:{if(!Ar){if(Dj(lr)){break a}Ar=o[lr+16>>2]}Br=o[lr+20>>2];if(!(m[lr+75|0]==10|Br>>>0>=Ar>>>0)){o[lr+20>>2]=Br+1;m[Br|0]=10;break a}if((l[o[lr+36>>2]](lr,vr+15|0,1)|0)!=1){break a}}R=vr+16|0}function Kk(){_a(12212);D()}function Lk(){M();D()}function Mk(lr,Cr){var Dr=0,Er=0,Fr=0;Er=R-16|0;R=Er;mk(lr);Dr=lr;a:{if(!wk(Cr)){o[Dr+8>>2]=o[Cr+8>>2];Fr=o[Cr+4>>2];o[Dr>>2]=o[Cr>>2];o[Dr+4>>2]=Fr;break a}Nk(lr,o[Cr>>2],o[Cr+4>>2])}R=Er+16|0;return lr}function Nk(lr,Cr,Gr){var Hr=0,Ir=0,Jr=0;Hr=R-16|0;R=Hr;if(4294967279>=Gr>>>0){a:{if(Gr>>>0<=10){Bk(lr,Gr);Ir=lr;break a}Jr=Ck(Gr)+1|0;Ir=Dk(Jr);Ek(lr,Ir);Fk(lr,Jr);Ak(lr,Gr)}jk(Ir,Cr,Gr);m[Hr+15|0]=0;zk(Gr+Ir|0,Hr+15|0);R=Hr+16|0;return}Kk();D()}function Ok(lr,Cr){if((lr|0)!=(Cr|0)){Pk(lr,yk(Cr),sk(Cr))}}function Pk(lr,Cr,Gr){var Kr=0,Lr=0,Mr=0,Nr=0;Lr=R-16|0;R=Lr;Kr=tk(lr);a:{if(Kr>>>0>=Gr>>>0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k(lr+Cr|0,Vr+14|0);Bk(lr,Cr)}R=Vr+16|0}function Uk(lr,Cr,Xr,Yr,Zr){var _r=0,$r=0,as=0;_r=R-16|0;R=_r;if(-17-Cr>>>0>=Xr>>>0){$r=yk(lr);a:{if(2147483623>Cr>>>0){o[_r+8>>2]=Cr<<1;o[_r+12>>2]=Cr+Xr;Xr=Ck(o[kk(_r+12|0,_r+8|0)>>2]);break a}Xr=-18}as=Xr+1|0;Xr=Dk(as);if(Zr){jk(Xr,$r,Zr)}Yr=Yr-Zr|0;if(Yr){jk(Xr+Zr|0,Zr+$r|0,Yr)}if((Cr|0)!=10){ul($r)}Ek(lr,Xr);Fk(lr,as);R=_r+16|0;return}Kk();D()}function Vk(lr){if(sk(lr)>>>0<=0){Lk();D()}return yk(lr)}function Wk(lr){var Cr=0,Xr=0;Cr=R-16|0;R=Cr;mk(Cr);vk(Cr);uk(Cr,tk(Cr));Xk(lr,Cr);lr=Cr;if(wk(Cr)){Xr=o[lr>>2];xk(lr);ul(Xr)}R=Cr+16|0}function Xk(lr,Yr){var Zr=0,bs=0,cs=0,ds=0;cs=R-16|0;R=cs;Zr=sk(Yr);while(1){a:{bs=yk(Yr);o[cs>>2]=1;ds=Yr;bs=rk(bs,Zr+1|0,cs);b:{if((bs|0)>=0){if(bs>>>0<=Zr>>>0){break a}Zr=bs;break b}Zr=Zr<<1|1}uk(ds,Zr);continue}break}uk(Yr,bs);Zr=o[Yr+4>>2];o[lr>>2]=o[Yr>>2];o[lr+4>>2]=Zr;o[lr+8>>2]=o[Yr+8>>2];vk(Yr);R=cs+16|0}function Yk(){_a(12228);D()}function Zk(){Lk();D()}function _k(lr){var Yr=0;if(o[lr+76>>2]<0){a:{if(m[lr+75|0]==10){break a}Yr=o[lr+20>>2];if(Yr>>>0>=r[lr+16>>2]){break a}o[lr+20>>2]=Yr+1;m[Yr|0]=10;return}Jk(lr);return}b:{c:{if(m[lr+75|0]==10){break c}Yr=o[lr+20>>2];if(Yr>>>0>=r[lr+16>>2]){break c}o[lr+20>>2]=Yr+1;m[Yr|0]=10;break b}Jk(lr)}}function $k(){var lr=0;lr=R-16|0;R=lr;o[lr+12>>2]=0;lr=o[2902];Oj(lr,12235,0);_k(lr);M();D()}function al(){$k();D()}function bl(es){es=es|0;return 12265}function cl(es){es=es|0;o[es>>2]=12332;dl(es+4|0);return es|0}function dl(es){var fs=0,gs=0;fs=o[es>>2]+ -12|0;gs=fs+8|0;es=o[gs>>2]+ -1|0;o[gs>>2]=es;a:{if((es|0)>-1){break a}ul(fs)}}function el(es){es=es|0;ul(cl(es))}function fl(es){es=es|0;return o[es+4>>2]}function gl(es){es=es|0;cl(es);ul(es)}function hl(es,hs,is){if(!is){return(es|0)==(hs|0)}return!nk(o[es+4>>2],o[hs+4>>2])}function il(es,hs,is){es=es|0;hs=hs|0;is=is|0;var js=0,ks=0;js=R+ -64|0;R=js;ks=1;a:{if(hl(es,hs,0)){break a}ks=0;if(!hs){break a}hs=jl(hs);ks=0;if(!hs){break a}o[js+20>>2]=-1;o[js+16>>2]=es;o[js+12>>2]=0;o[js+8>>2]=hs;xl(js+24|0,0,39);o[js+56>>2]=1;l[o[o[hs>>2]+28>>2]](hs,js+8|0,o[is>>2],1);ks=0;if(o[js+32>>2]!=1){break a}o[is>>2]=o[js+24>>2];ks=1}R=js- -64|0;return ks|0}function jl(es){var hs=0,is=0,ls=0,ms=0;hs=R+ -64|0;R=hs;is=o[es>>2];ms=o[is+ -8>>2];is=o[is+ -4>>2];o[hs+20>>2]=0;o[hs+16>>2]=12484;o[hs+12>>2]=es;o[hs+8>>2]=12532;xl(hs+24|0,0,39);es=es+ms|0;a:{if(hl(is,12532,0)){o[hs+56>>2]=1;l[o[o[is>>2]+20>>2]](is,hs+8|0,es,es,1,0);ls=o[hs+32>>2]==1?es:0;break a}l[o[o[is>>2]+24>>2]](is,hs+8|0,es,1,0);es=o[hs+44>>2];if(es>>>0>1){break a}if(es-1){ls=o[hs+48>>2]==1?o[hs+36>>2]==1?o[hs+40>>2]==1?o[hs+28>>2]:0:0:0;break a}if(o[hs+32>>2]!=1){if(o[hs+48>>2]|o[hs+36>>2]!=1|o[hs+40>>2]!=1){break a}}ls=o[hs+24>>2]}R=hs- -64|0;return ls}function kl(es,ns,os){var ps=0;ps=o[es+16>>2];if(!ps){o[es+36>>2]=1;o[es+24>>2]=os;o[es+16>>2]=ns;return}a:{if((ns|0)==(ps|0)){if(o[es+24>>2]!=2){break a}o[es+24>>2]=os;return}m[es+54|0]=1;o[es+24>>2]=2;o[es+36>>2]=o[es+36>>2]+1}}function ll(es,ns,os,qs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;if(hl(es,o[ns+8>>2],0)){kl(ns,os,qs)}}function ml(es,ns,os,qs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;if(hl(es,o[ns+8>>2],0)){kl(ns,os,qs);return}es=o[es+8>>2];l[o[o[es>>2]+28>>2]](es,ns,os,qs)}function nl(es,ns,os,qs){m[es+53|0]=1;a:{if(o[es+4>>2]!=(os|0)){break a}m[es+52|0]=1;os=o[es+16>>2];if(!os){o[es+36>>2]=1;o[es+24>>2]=qs;o[es+16>>2]=ns;if((qs|0)!=1|o[es+48>>2]!=1){break a}m[es+54|0]=1;return}if((ns|0)==(os|0)){os=o[es+24>>2];if((os|0)==2){o[es+24>>2]=qs;os=qs}if(o[es+48>>2]!=1|(os|0)!=1){break a}m[es+54|0]=1;return}m[es+54|0]=1;o[es+36>>2]=o[es+36>>2]+1}}function ol(es,ns,os){if(!(o[es+28>>2]==1|o[es+4>>2]!=(ns|0))){o[es+28>>2]=os}}function pl(es,ns,os,qs,rs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;if(hl(es,o[ns+8>>2],rs)){ol(ns,os,qs);return}a:{if(hl(es,o[ns>>2],rs)){if(!(o[ns+20>>2]!=(os|0)?o[ns+16>>2]!=(os|0):0)){if((qs|0)!=1){break a}o[ns+32>>2]=1;return}o[ns+32>>2]=qs;b:{if(o[ns+44>>2]==4){break b}n[ns+52>>1]=0;es=o[es+8>>2];l[o[o[es>>2]+20>>2]](es,ns,os,os,1,rs);if(p[ns+53|0]){o[ns+44>>2]=3;if(!p[ns+52|0]){break b}break a}o[ns+44>>2]=4}o[ns+20>>2]=os;o[ns+40>>2]=o[ns+40>>2]+1;if(o[ns+36>>2]!=1|o[ns+24>>2]!=2){break a}m[ns+54|0]=1;return}es=o[es+8>>2];l[o[o[es>>2]+24>>2]](es,ns,os,qs,rs)}}function ql(es,ns,os,qs,rs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;if(hl(es,o[ns+8>>2],rs)){ol(ns,os,qs);return}a:{if(!hl(es,o[ns>>2],rs)){break a}if(!(o[ns+20>>2]!=(os|0)?o[ns+16>>2]!=(os|0):0)){if((qs|0)!=1){break a}o[ns+32>>2]=1;return}o[ns+20>>2]=os;o[ns+32>>2]=qs;o[ns+40>>2]=o[ns+40>>2]+1;if(!(o[ns+36>>2]!=1|o[ns+24>>2]!=2)){m[ns+54|0]=1}o[ns+44>>2]=4}}function rl(es,ns,os,qs,rs,ss){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;ss=ss|0;if(hl(es,o[ns+8>>2],ss)){nl(ns,os,qs,rs);return}es=o[es+8>>2];l[o[o[es>>2]+20>>2]](es,ns,os,qs,rs,ss)}function sl(es,ns,os,qs,rs,ss){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;ss=ss|0;if(hl(es,o[ns+8>>2],ss)){nl(ns,os,qs,rs)}} + + + +function tl(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;l=R-16|0;R=l;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{if(a>>>0<=244){f=o[3288];h=a>>>0<11?16:a+11&-8;b=h>>>3;a=f>>>b;if(a&3){d=b+((a^-1)&1)|0;b=d<<3;e=o[b+13200>>2];a=e+8|0;c=o[e+8>>2];b=b+13192|0;l:{if((c|0)==(b|0)){m=13152,n=Zl(d)&f,o[m>>2]=n;break l}o[c+12>>2]=b;o[b+8>>2]=c}b=d<<3;o[e+4>>2]=b|3;b=b+e|0;o[b+4>>2]=o[b+4>>2]|1;break a}k=o[3290];if(h>>>0<=k>>>0){break k}if(a){c=a<>>12&16;c=a;b=b>>>a;a=b>>>5&8;c=c|a;b=b>>>a;a=b>>>2&4;c=c|a;b=b>>>a;a=b>>>1&2;c=c|a;b=b>>>a;a=b>>>1&1;c=(c|a)+(b>>>a)|0;a=c<<3;g=o[a+13200>>2];b=o[g+8>>2];a=a+13192|0;m:{if((b|0)==(a|0)){f=Zl(c)&f;o[3288]=f;break m}o[b+12>>2]=a;o[a+8>>2]=b}a=g+8|0;o[g+4>>2]=h|3;d=g+h|0;b=c<<3;e=b-h|0;o[d+4>>2]=e|1;o[b+g>>2]=e;if(k){b=k>>>3;c=(b<<3)+13192|0;h=o[3293];b=1<>2]}o[c+8>>2]=h;o[b+12>>2]=h;o[h+12>>2]=c;o[h+8>>2]=b}o[3293]=d;o[3290]=e;break a}i=o[3289];if(!i){break k}b=(i&0-i)+ -1|0;a=b>>>12&16;c=a;b=b>>>a;a=b>>>5&8;c=c|a;b=b>>>a;a=b>>>2&4;c=c|a;b=b>>>a;a=b>>>1&2;c=c|a;b=b>>>a;a=b>>>1&1;b=o[((c|a)+(b>>>a)<<2)+13456>>2];d=(o[b+4>>2]&-8)-h|0;c=b;while(1){o:{a=o[c+16>>2];if(!a){a=o[c+20>>2];if(!a){break o}}c=(o[a+4>>2]&-8)-h|0;e=c>>>0>>0;d=e?c:d;b=e?a:b;c=a;continue}break}j=o[b+24>>2];e=o[b+12>>2];if((e|0)!=(b|0)){a=o[b+8>>2];o[a+12>>2]=e;o[e+8>>2]=a;break b}c=b+20|0;a=o[c>>2];if(!a){a=o[b+16>>2];if(!a){break j}c=b+16|0}while(1){g=c;e=a;c=a+20|0;a=o[c>>2];if(a){continue}c=e+16|0;a=o[e+16>>2];if(a){continue}break}o[g>>2]=0;break b}h=-1;if(a>>>0>4294967231){break k}a=a+11|0;h=a&-8;i=o[3289];if(!i){break k}a=a>>>8;g=0;p:{if(!a){break p}g=31;if(h>>>0>16777215){break p}b=a+1048320>>>16&8;a=a<>>16&4;a=a<>>16&2;a=(a<>>15)-(c|(b|d))|0;g=(a<<1|h>>>a+21&1)+28|0}c=0-h|0;d=o[(g<<2)+13456>>2];q:{r:{s:{if(!d){a=0;break s}b=h<<((g|0)==31?0:25-(g>>>1)|0);a=0;while(1){t:{f=(o[d+4>>2]&-8)-h|0;if(f>>>0>=c>>>0){break t}e=d;c=f;if(c){break t}c=0;a=d;break r}f=o[d+20>>2];d=o[((b>>>29&4)+d|0)+16>>2];a=f?(f|0)==(d|0)?a:f:a;b=b<<((d|0)!=0);if(d){continue}break}}if(!(a|e)){a=2<>>12&16;d=a;b=b>>>a;a=b>>>5&8;d=d|a;b=b>>>a;a=b>>>2&4;d=d|a;b=b>>>a;a=b>>>1&2;d=d|a;b=b>>>a;a=b>>>1&1;a=o[((d|a)+(b>>>a)<<2)+13456>>2]}if(!a){break q}}while(1){b=(o[a+4>>2]&-8)-h|0;d=b>>>0>>0;c=d?b:c;e=d?a:e;b=o[a+16>>2];if(b){a=b}else{a=o[a+20>>2]}if(a){continue}break}}if(!e|c>>>0>=o[3290]-h>>>0){break k}g=o[e+24>>2];b=o[e+12>>2];if((e|0)!=(b|0)){a=o[e+8>>2];o[a+12>>2]=b;o[b+8>>2]=a;break c}d=e+20|0;a=o[d>>2];if(!a){a=o[e+16>>2];if(!a){break i}d=e+16|0}while(1){f=d;b=a;d=a+20|0;a=o[d>>2];if(a){continue}d=b+16|0;a=o[b+16>>2];if(a){continue}break}o[f>>2]=0;break c}c=o[3290];if(c>>>0>=h>>>0){d=o[3293];b=c-h|0;u:{if(b>>>0>=16){o[3290]=b;a=d+h|0;o[3293]=a;o[a+4>>2]=b|1;o[c+d>>2]=b;o[d+4>>2]=h|3;break u}o[3293]=0;o[3290]=0;o[d+4>>2]=c|3;a=c+d|0;o[a+4>>2]=o[a+4>>2]|1}a=d+8|0;break a}j=o[3291];if(j>>>0>h>>>0){b=j-h|0;o[3291]=b;c=o[3294];a=c+h|0;o[3294]=a;o[a+4>>2]=b|1;o[c+4>>2]=h|3;a=c+8|0;break a}a=0;i=h+47|0;b=i;if(o[3406]){c=o[3408]}else{o[3409]=-1;o[3410]=-1;o[3407]=4096;o[3408]=4096;o[3406]=l+12&-16^1431655768;o[3411]=0;o[3399]=0;c=4096}g=b+c|0;f=0-c|0;c=g&f;if(c>>>0<=h>>>0){break a}e=o[3398];if(e){d=o[3396];b=d+c|0;if(b>>>0<=d>>>0|b>>>0>e>>>0){break a}}if(p[13596]&4){break f}v:{w:{d=o[3294];if(d){a=13600;while(1){b=o[a>>2];if(b+o[a+4>>2]>>>0>d>>>0?b>>>0<=d>>>0:0){break w}a=o[a+8>>2];if(a){continue}break}}b=vl(0);if((b|0)==-1){break g}f=c;d=o[3407];a=d+ -1|0;if(a&b){f=(c-b|0)+(a+b&0-d)|0}if(f>>>0<=h>>>0|f>>>0>2147483646){break g}e=o[3398];if(e){d=o[3396];a=d+f|0;if(a>>>0<=d>>>0|a>>>0>e>>>0){break g}}a=vl(f);if((b|0)!=(a|0)){break v}break e}f=f&g-j;if(f>>>0>2147483646){break g}b=vl(f);if((b|0)==(o[a>>2]+o[a+4>>2]|0)){break h}a=b}b=a;if(!(h+48>>>0<=f>>>0|f>>>0>2147483646|(a|0)==-1)){a=o[3408];a=a+(i-f|0)&0-a;if(a>>>0>2147483646){break e}if((vl(a)|0)!=-1){f=a+f|0;break e}vl(0-f|0);break g}if((b|0)!=-1){break e}break g}e=0;break b}b=0;break c}if((b|0)!=-1){break e}}o[3399]=o[3399]|4}if(c>>>0>2147483646){break d}b=vl(c);a=vl(0);if(b>>>0>=a>>>0|(b|0)==-1|(a|0)==-1){break d}f=a-b|0;if(f>>>0<=h+40>>>0){break d}}a=o[3396]+f|0;o[3396]=a;if(a>>>0>r[3397]){o[3397]=a}x:{y:{z:{d=o[3294];if(d){a=13600;while(1){e=o[a>>2];c=o[a+4>>2];if((e+c|0)==(b|0)){break z}a=o[a+8>>2];if(a){continue}break}break y}a=o[3292];if(!(b>>>0>=a>>>0?a:0)){o[3292]=b}a=0;o[3401]=f;o[3400]=b;o[3296]=-1;o[3297]=o[3406];o[3403]=0;while(1){d=a<<3;c=d+13192|0;o[d+13200>>2]=c;o[d+13204>>2]=c;a=a+1|0;if((a|0)!=32){continue}break}d=f+ -40|0;a=b+8&7?-8-b&7:0;c=d-a|0;o[3291]=c;a=a+b|0;o[3294]=a;o[a+4>>2]=c|1;o[(b+d|0)+4>>2]=40;o[3295]=o[3410];break x}if(p[a+12|0]&8|b>>>0<=d>>>0|e>>>0>d>>>0){break y}o[a+4>>2]=c+f;a=d+8&7?-8-d&7:0;c=a+d|0;o[3294]=c;b=o[3291]+f|0;a=b-a|0;o[3291]=a;o[c+4>>2]=a|1;o[(b+d|0)+4>>2]=40;o[3295]=o[3410];break x}e=o[3292];if(b>>>0>>0){o[3292]=b;e=0}c=b+f|0;a=13600;A:{B:{C:{D:{E:{F:{while(1){if((c|0)!=o[a>>2]){a=o[a+8>>2];if(a){continue}break F}break}if(!(p[a+12|0]&8)){break E}}a=13600;while(1){c=o[a>>2];if(c>>>0<=d>>>0){g=c+o[a+4>>2]|0;if(g>>>0>d>>>0){break D}}a=o[a+8>>2];continue}}o[a>>2]=b;o[a+4>>2]=o[a+4>>2]+f;j=(b+8&7?-8-b&7:0)+b|0;o[j+4>>2]=h|3;b=c+(c+8&7?-8-c&7:0)|0;a=(b-j|0)-h|0;g=h+j|0;if((b|0)==(d|0)){o[3294]=g;a=o[3291]+a|0;o[3291]=a;o[g+4>>2]=a|1;break B}if(o[3293]==(b|0)){o[3293]=g;a=o[3290]+a|0;o[3290]=a;o[g+4>>2]=a|1;o[a+g>>2]=a;break B}c=o[b+4>>2];if((c&3)==1){i=c&-8;G:{if(c>>>0<=255){e=o[b+8>>2];c=c>>>3;d=o[b+12>>2];if((d|0)==(e|0)){m=13152,n=o[3288]&Zl(c),o[m>>2]=n;break G}o[e+12>>2]=d;o[d+8>>2]=e;break G}k=o[b+24>>2];f=o[b+12>>2];H:{if((f|0)!=(b|0)){c=o[b+8>>2];o[c+12>>2]=f;o[f+8>>2]=c;break H}I:{d=b+20|0;h=o[d>>2];if(h){break I}d=b+16|0;h=o[d>>2];if(h){break I}f=0;break H}while(1){c=d;f=h;d=f+20|0;h=o[d>>2];if(h){continue}d=f+16|0;h=o[f+16>>2];if(h){continue}break}o[c>>2]=0}if(!k){break G}d=o[b+28>>2];c=(d<<2)+13456|0;J:{if(o[c>>2]==(b|0)){o[c>>2]=f;if(f){break J}m=13156,n=o[3289]&Zl(d),o[m>>2]=n;break G}o[k+(o[k+16>>2]==(b|0)?16:20)>>2]=f;if(!f){break G}}o[f+24>>2]=k;c=o[b+16>>2];if(c){o[f+16>>2]=c;o[c+24>>2]=f}c=o[b+20>>2];if(!c){break G}o[f+20>>2]=c;o[c+24>>2]=f}b=b+i|0;a=a+i|0}o[b+4>>2]=o[b+4>>2]&-2;o[g+4>>2]=a|1;o[a+g>>2]=a;if(a>>>0<=255){a=a>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=g;o[a+12>>2]=g;o[g+12>>2]=b;o[g+8>>2]=a;break B}b=g;d=a>>>8;c=0;L:{if(!d){break L}c=31;if(a>>>0>16777215){break L}c=d;d=d+1048320>>>16&8;c=c<>>16&4;c=c<>>16&2;c=(c<>>15)-(e|(d|f))|0;c=(c<<1|a>>>c+21&1)+28|0}o[b+28>>2]=c;o[g+16>>2]=0;o[g+20>>2]=0;e=(c<<2)+13456|0;d=o[3289];b=1<>2]=g;o[g+24>>2]=e;break M}d=a<<((c|0)==31?0:25-(c>>>1)|0);b=o[e>>2];while(1){c=b;if((o[b+4>>2]&-8)==(a|0)){break C}b=d>>>29;d=d<<1;e=(c+(b&4)|0)+16|0;b=o[e>>2];if(b){continue}break}o[e>>2]=g;o[g+24>>2]=c}o[g+12>>2]=g;o[g+8>>2]=g;break B}e=f+ -40|0;a=b+8&7?-8-b&7:0;c=e-a|0;o[3291]=c;a=a+b|0;o[3294]=a;o[a+4>>2]=c|1;o[(b+e|0)+4>>2]=40;o[3295]=o[3410];a=(g+(g+ -39&7?39-g&7:0)|0)+ -47|0;c=a>>>0>>0?d:a;o[c+4>>2]=27;a=o[3403];o[c+16>>2]=o[3402];o[c+20>>2]=a;a=o[3401];o[c+8>>2]=o[3400];o[c+12>>2]=a;o[3402]=c+8;o[3401]=f;o[3400]=b;o[3403]=0;a=c+24|0;while(1){o[a+4>>2]=7;b=a+8|0;a=a+4|0;if(b>>>0>>0){continue}break}if((c|0)==(d|0)){break x}o[c+4>>2]=o[c+4>>2]&-2;g=c-d|0;o[d+4>>2]=g|1;o[c>>2]=g;if(g>>>0<=255){a=g>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=d;o[a+12>>2]=d;o[d+12>>2]=b;o[d+8>>2]=a;break x}o[d+16>>2]=0;o[d+20>>2]=0;a=d;c=g>>>8;b=0;O:{if(!c){break O}b=31;if(g>>>0>16777215){break O}b=c;c=c+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15)-(e|(c|f))|0;b=(b<<1|g>>>b+21&1)+28|0}o[a+28>>2]=b;e=(b<<2)+13456|0;c=o[3289];a=1<>2]=d;o[d+24>>2]=e;break P}a=g<<((b|0)==31?0:25-(b>>>1)|0);b=o[e>>2];while(1){c=b;if((g|0)==(o[b+4>>2]&-8)){break A}b=a>>>29;a=a<<1;e=(c+(b&4)|0)+16|0;b=o[e>>2];if(b){continue}break}o[e>>2]=d;o[d+24>>2]=c}o[d+12>>2]=d;o[d+8>>2]=d;break x}a=o[c+8>>2];o[a+12>>2]=g;o[c+8>>2]=g;o[g+24>>2]=0;o[g+12>>2]=c;o[g+8>>2]=a}a=j+8|0;break a}a=o[c+8>>2];o[a+12>>2]=d;o[c+8>>2]=d;o[d+24>>2]=0;o[d+12>>2]=c;o[d+8>>2]=a}a=o[3291];if(a>>>0<=h>>>0){break d}b=a-h|0;o[3291]=b;c=o[3294];a=c+h|0;o[3294]=a;o[a+4>>2]=b|1;o[c+4>>2]=h|3;a=c+8|0;break a}o[3269]=48;a=0;break a}Q:{if(!g){break Q}d=o[e+28>>2];a=(d<<2)+13456|0;R:{if(o[a>>2]==(e|0)){o[a>>2]=b;if(b){break R}i=Zl(d)&i;o[3289]=i;break Q}o[g+(o[g+16>>2]==(e|0)?16:20)>>2]=b;if(!b){break Q}}o[b+24>>2]=g;a=o[e+16>>2];if(a){o[b+16>>2]=a;o[a+24>>2]=b}a=o[e+20>>2];if(!a){break Q}o[b+20>>2]=a;o[a+24>>2]=b}S:{if(c>>>0<=15){a=c+h|0;o[e+4>>2]=a|3;a=a+e|0;o[a+4>>2]=o[a+4>>2]|1;break S}o[e+4>>2]=h|3;d=e+h|0;o[d+4>>2]=c|1;o[c+d>>2]=c;if(c>>>0<=255){a=c>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=d;o[a+12>>2]=d;o[d+12>>2]=b;o[d+8>>2]=a;break S}a=d;f=c>>>8;b=0;U:{if(!f){break U}b=31;if(c>>>0>16777215){break U}b=f;f=f+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15)-(h|(f|g))|0;b=(b<<1|c>>>b+21&1)+28|0}o[a+28>>2]=b;o[d+16>>2]=0;o[d+20>>2]=0;f=(b<<2)+13456|0;V:{a=1<>2]=d;o[d+24>>2]=f;break W}a=c<<((b|0)==31?0:25-(b>>>1)|0);h=o[f>>2];while(1){b=h;if((o[b+4>>2]&-8)==(c|0)){break V}f=a>>>29;a=a<<1;f=(b+(f&4)|0)+16|0;h=o[f>>2];if(h){continue}break}o[f>>2]=d;o[d+24>>2]=b}o[d+12>>2]=d;o[d+8>>2]=d;break S}a=o[b+8>>2];o[a+12>>2]=d;o[b+8>>2]=d;o[d+24>>2]=0;o[d+12>>2]=b;o[d+8>>2]=a}a=e+8|0;break a}X:{if(!j){break X}c=o[b+28>>2];a=(c<<2)+13456|0;Y:{if(o[a>>2]==(b|0)){o[a>>2]=e;if(e){break Y}m=13156,n=Zl(c)&i,o[m>>2]=n;break X}o[(o[j+16>>2]==(b|0)?16:20)+j>>2]=e;if(!e){break X}}o[e+24>>2]=j;a=o[b+16>>2];if(a){o[e+16>>2]=a;o[a+24>>2]=e}a=o[b+20>>2];if(!a){break X}o[e+20>>2]=a;o[a+24>>2]=e}Z:{if(d>>>0<=15){a=d+h|0;o[b+4>>2]=a|3;a=a+b|0;o[a+4>>2]=o[a+4>>2]|1;break Z}o[b+4>>2]=h|3;e=b+h|0;o[e+4>>2]=d|1;o[d+e>>2]=d;if(k){a=k>>>3;c=(a<<3)+13192|0;h=o[3293];a=1<>2]}o[c+8>>2]=h;o[a+12>>2]=h;o[h+12>>2]=c;o[h+8>>2]=a}o[3293]=e;o[3290]=d}a=b+8|0}R=l+16|0;return a|0}function ul(a){a=a|0;var p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;a:{if(!a){break a}s=a+ -8|0;q=o[a+ -4>>2];a=q&-8;u=s+a|0;b:{if(q&1){break b}if(!(q&3)){break a}q=o[s>>2];s=s-q|0;if(s>>>0>>0<=255){t=o[s+8>>2];q=q>>>3;p=o[s+12>>2];if((p|0)==(t|0)){x=13152,y=o[3288]&Zl(q),o[x>>2]=y;break b}o[t+12>>2]=p;o[p+8>>2]=t;break b}w=o[s+24>>2];q=o[s+12>>2];c:{if((q|0)!=(s|0)){p=o[s+8>>2];o[p+12>>2]=q;o[q+8>>2]=p;break c}d:{t=s+20|0;p=o[t>>2];if(p){break d}t=s+16|0;p=o[t>>2];if(p){break d}q=0;break c}while(1){v=t;q=p;t=q+20|0;p=o[t>>2];if(p){continue}t=q+16|0;p=o[q+16>>2];if(p){continue}break}o[v>>2]=0}if(!w){break b}t=o[s+28>>2];p=(t<<2)+13456|0;e:{if(o[p>>2]==(s|0)){o[p>>2]=q;if(q){break e}x=13156,y=o[3289]&Zl(t),o[x>>2]=y;break b}o[w+(o[w+16>>2]==(s|0)?16:20)>>2]=q;if(!q){break b}}o[q+24>>2]=w;p=o[s+16>>2];if(p){o[q+16>>2]=p;o[p+24>>2]=q}p=o[s+20>>2];if(!p){break b}o[q+20>>2]=p;o[p+24>>2]=q;break b}q=o[u+4>>2];if((q&3)!=3){break b}o[3290]=a;o[u+4>>2]=q&-2;o[s+4>>2]=a|1;o[a+s>>2]=a;return}if(u>>>0<=s>>>0){break a}q=o[u+4>>2];if(!(q&1)){break a}f:{if(!(q&2)){if((u|0)==o[3294]){o[3294]=s;a=o[3291]+a|0;o[3291]=a;o[s+4>>2]=a|1;if(o[3293]!=(s|0)){break a}o[3290]=0;o[3293]=0;return}if((u|0)==o[3293]){o[3293]=s;a=o[3290]+a|0;o[3290]=a;o[s+4>>2]=a|1;o[a+s>>2]=a;return}a=(q&-8)+a|0;g:{if(q>>>0<=255){p=o[u+8>>2];q=q>>>3;t=o[u+12>>2];if((p|0)==(t|0)){x=13152,y=o[3288]&Zl(q),o[x>>2]=y;break g}o[p+12>>2]=t;o[t+8>>2]=p;break g}w=o[u+24>>2];q=o[u+12>>2];h:{if((u|0)!=(q|0)){p=o[u+8>>2];o[p+12>>2]=q;o[q+8>>2]=p;break h}i:{t=u+20|0;p=o[t>>2];if(p){break i}t=u+16|0;p=o[t>>2];if(p){break i}q=0;break h}while(1){v=t;q=p;t=q+20|0;p=o[t>>2];if(p){continue}t=q+16|0;p=o[q+16>>2];if(p){continue}break}o[v>>2]=0}if(!w){break g}t=o[u+28>>2];p=(t<<2)+13456|0;j:{if((u|0)==o[p>>2]){o[p>>2]=q;if(q){break j}x=13156,y=o[3289]&Zl(t),o[x>>2]=y;break g}o[w+((u|0)==o[w+16>>2]?16:20)>>2]=q;if(!q){break g}}o[q+24>>2]=w;p=o[u+16>>2];if(p){o[q+16>>2]=p;o[p+24>>2]=q}p=o[u+20>>2];if(!p){break g}o[q+20>>2]=p;o[p+24>>2]=q}o[s+4>>2]=a|1;o[a+s>>2]=a;if(o[3293]!=(s|0)){break f}o[3290]=a;return}o[u+4>>2]=q&-2;o[s+4>>2]=a|1;o[a+s>>2]=a}if(a>>>0<=255){a=a>>>3;q=(a<<3)+13192|0;p=o[3288];a=1<>2]}o[q+8>>2]=s;o[a+12>>2]=s;o[s+12>>2]=q;o[s+8>>2]=a;return}o[s+16>>2]=0;o[s+20>>2]=0;q=s;t=a>>>8;p=0;l:{if(!t){break l}p=31;if(a>>>0>16777215){break l}p=t;t=t+1048320>>>16&8;p=p<>>16&4;p=p<>>16&2;p=(p<>>15)-(v|(t|w))|0;p=(p<<1|a>>>p+21&1)+28|0}o[q+28>>2]=p;v=(p<<2)+13456|0;t=o[3289];q=1<>2]=s;o[s+12>>2]=s;o[s+24>>2]=v;o[s+8>>2]=s;break m}t=a<<((p|0)==31?0:25-(p>>>1)|0);q=o[v>>2];n:{while(1){p=q;if((o[q+4>>2]&-8)==(a|0)){break n}q=t>>>29;t=t<<1;v=(p+(q&4)|0)+16|0;q=o[v>>2];if(q){continue}break}o[v>>2]=s;o[s+12>>2]=s;o[s+24>>2]=p;o[s+8>>2]=s;break m}a=o[p+8>>2];o[a+12>>2]=s;o[p+8>>2]=s;o[s+24>>2]=0;o[s+12>>2]=p;o[s+8>>2]=a}a=o[3296]+ -1|0;o[3296]=a;if(a){break a}s=13608;while(1){a=o[s>>2];s=a+8|0;if(a){continue}break}o[3296]=-1}}function vl(a){var r=0;r=o[3416];a=r+a|0;if((a|0)<=-1){o[3269]=48;return-1}a:{if(a>>>0<=U()<<16>>>0){break a}if(N(a|0)){break a}o[3269]=48;return-1}o[3416]=a;return r}function wl(a,z,A){var B=0,C=0,D=0;if(A>>>0>=8192){O(a|0,z|0,A|0)|0;return a}C=a+A|0;a:{if(!((a^z)&3)){b:{if((A|0)<1){A=a;break b}if(!(a&3)){A=a;break b}A=a;while(1){m[A|0]=p[z|0];z=z+1|0;A=A+1|0;if(A>>>0>=C>>>0){break b}if(A&3){continue}break}}B=C&-4;c:{if(B>>>0<64){break c}D=B+ -64|0;if(A>>>0>D>>>0){break c}while(1){o[A>>2]=o[z>>2];o[A+4>>2]=o[z+4>>2];o[A+8>>2]=o[z+8>>2];o[A+12>>2]=o[z+12>>2];o[A+16>>2]=o[z+16>>2];o[A+20>>2]=o[z+20>>2];o[A+24>>2]=o[z+24>>2];o[A+28>>2]=o[z+28>>2];o[A+32>>2]=o[z+32>>2];o[A+36>>2]=o[z+36>>2];o[A+40>>2]=o[z+40>>2];o[A+44>>2]=o[z+44>>2];o[A+48>>2]=o[z+48>>2];o[A+52>>2]=o[z+52>>2];o[A+56>>2]=o[z+56>>2];o[A+60>>2]=o[z+60>>2];z=z- -64|0;A=A- -64|0;if(A>>>0<=D>>>0){continue}break}}if(A>>>0>=B>>>0){break a}while(1){o[A>>2]=o[z>>2];z=z+4|0;A=A+4|0;if(A>>>0>>0){continue}break}break a}if(C>>>0<4){A=a;break a}B=C+ -4|0;if(B>>>0>>0){A=a;break a}A=a;while(1){m[A|0]=p[z|0];m[A+1|0]=p[z+1|0];m[A+2|0]=p[z+2|0];m[A+3|0]=p[z+3|0];z=z+4|0;A=A+4|0;if(A>>>0<=B>>>0){continue}break}}if(A>>>0>>0){while(1){m[A|0]=p[z|0];z=z+1|0;A=A+1|0;if((C|0)!=(A|0)){continue}break}}return a}function xl(a,z,A){var E=0,F=0,G=0,H=0;a:{if(!A){break a}E=a+A|0;m[E+ -1|0]=z;m[a|0]=z;if(A>>>0<3){break a}m[E+ -2|0]=z;m[a+1|0]=z;m[E+ -3|0]=z;m[a+2|0]=z;if(A>>>0<7){break a}m[E+ -4|0]=z;m[a+3|0]=z;if(A>>>0<9){break a}E=0-a&3;F=E+a|0;z=u(z&255,16843009);o[F>>2]=z;A=A-E&-4;E=A+F|0;o[E+ -4>>2]=z;if(A>>>0<9){break a}o[F+8>>2]=z;o[F+4>>2]=z;o[E+ -8>>2]=z;o[E+ -12>>2]=z;if(A>>>0<25){break a}o[F+24>>2]=z;o[F+20>>2]=z;o[F+16>>2]=z;o[F+12>>2]=z;o[E+ -16>>2]=z;o[E+ -20>>2]=z;o[E+ -24>>2]=z;o[E+ -28>>2]=z;H=F&4|24;A=A-H|0;if(A>>>0<32){break a}E=z;G=z;z=F+H|0;while(1){o[z+24>>2]=G;o[z+28>>2]=E;o[z+16>>2]=G;o[z+20>>2]=E;o[z+8>>2]=G;o[z+12>>2]=E;o[z>>2]=G;o[z+4>>2]=E;z=z+32|0;A=A+ -32|0;if(A>>>0>31){continue}break}}return a}function yl(a,z,A){var I=0,J=0;a:{if((a|0)==(z|0)){break a}b:{if(z+A>>>0>a>>>0){J=a+A|0;if(J>>>0>z>>>0){break b}}return wl(a,z,A)}I=(a^z)&3;c:{d:{if(a>>>0>>0){if(I){I=a;break c}if(!(a&3)){I=a;break d}I=a;while(1){if(!A){break a}m[I|0]=p[z|0];z=z+1|0;A=A+ -1|0;I=I+1|0;if(I&3){continue}break}break d}e:{if(I){break e}if(J&3){while(1){if(!A){break a}A=A+ -1|0;I=A+a|0;m[I|0]=p[z+A|0];if(I&3){continue}break}}if(A>>>0<=3){break e}while(1){A=A+ -4|0;o[A+a>>2]=o[z+A>>2];if(A>>>0>3){continue}break}}if(!A){break a}while(1){A=A+ -1|0;m[A+a|0]=p[z+A|0];if(A){continue}break}break a}if(A>>>0<=3){break c}J=A;while(1){o[I>>2]=o[z>>2];z=z+4|0;I=I+4|0;J=J+ -4|0;if(J>>>0>3){continue}break}A=A&3}if(!A){break a}while(1){m[I|0]=p[z|0];I=I+1|0;z=z+1|0;A=A+ -1|0;if(A){continue}break}}return a}function zl(a,z){a=a|0;z=z|0;if(!o[3412]){o[3413]=z;o[3412]=a}}function Al(){return R|0}function Bl(a){a=a|0;a=R-a&-16;R=a;return a|0}function Cl(a){a=a|0;R=a}function Dl(a){a=a|0;return V(a|0)|0}function El(a,o){a=a|0;o=o|0;return l[a](o)|0}function Fl(a,o){a=a|0;o=o|0;l[a](o)}function Gl(a,o,z){a=a|0;o=o|0;z=z|0;return l[a](o,z)|0}function Hl(a,o,z){a=a|0;o=o|0;z=z|0;l[a](o,z)}function Il(a,o,z,A){a=a|0;o=o|0;z=z|0;A=A|0;return l[a](o,z,A)|0}function Jl(a){a=a|0;l[a]()}function Kl(a,o,z,A){a=a|0;o=o|0;z=z|0;A=A|0;l[a](o,z,A)}function Ll(a,o,z,A,K){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;l[a](o,z,A,K)}function Ml(a,o,z,A,K,L,M){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;M=M|0;return l[a](o,z,A,K,L,M)|0}function Nl(a,o,z,A,K,L,M){a=a|0;o=o|0;z=+z;A=A|0;K=K|0;L=L|0;M=M|0;return l[a](o,z,A,K,L,M)|0}function Ol(a,o,z,A,K,L,M){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;M=M|0;l[a](o,z,A,K,L,M)}function Pl(a,o,z,A,K,L){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;l[a](o,z,A,K,L)}function Ql(a,o,z,A,K){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;a=l[a](o,z,A,K)|0;P(T|0);return a|0}function Rl(a,o){i(a|0,o|0)}function Sl(a,o,z,A){var K=0,L=0,M=0,N=0,O=0,P=0;K=z>>>16;L=a>>>16;P=u(K,L);M=z&65535;N=a&65535;O=u(M,N);L=(O>>>16)+u(L,M)|0;K=(L&65535)+u(K,N)|0;a=(((u(o,z)+P|0)+u(a,A)|0)+(L>>>16)|0)+(K>>>16)|0;o=O&65535|K<<16;T=a;return o}function Tl(a,o,z,A){var Q=0,R=0,S=0,U=0;Q=o;R=Q>>31;Q=Q>>31;a=a^Q;S=a-Q|0;U=(o^R)-((a>>>0>>0)+R|0)|0;Q=A;R=Q>>31;Q=Q>>31;a=z^Q;Q=Xl(S,U,a-Q|0,(A^R)-((a>>>0>>0)+R|0)|0);o=o^A;z=o>>31;a=o>>31;o=Q^a;A=o-a|0;T=(z^T)-((o>>>0>>0)+z|0)|0;return A}function Ul(a,o,z,A){var V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{X=o;if(X){V=z;if(!V){break j}W=A;if(!W){break i}W=x(W)-x(X)|0;if(W>>>0<=31){break h}break b}if((A|0)==1&z>>>0>=0|A>>>0>1){break b}o=(a>>>0)/(z>>>0)|0;Rl(a-u(o,z)|0,0);T=0;return o}V=A;if(!a){break g}if(!V){break f}W=V+ -1|0;if(W&V){break f}Rl(a,W&X);a=X>>>(_l(V)&31);T=0;return a}W=V+ -1|0;if(!(W&V)){break e}_=(x(V)+33|0)-x(X)|0;Y=0-_|0;break c}_=W+1|0;Y=63-W|0;break c}a=(X>>>0)/(V>>>0)|0;Rl(0,X-u(a,V)|0);T=0;return a}W=x(V)-x(X)|0;if(W>>>0<31){break d}break b}Rl(a&W,0);if((V|0)==1){break a}z=a;a=_l(V);A=a&31;if(32<=(a&63)>>>0){W=0;a=o>>>A}else{W=o>>>A;a=((1<>>A}T=W;return a}_=W+1|0;Y=63-W|0}V=o;X=a;W=_&63;Z=W&31;if(32<=(W&63)>>>0){W=0;aa=V>>>Z}else{W=V>>>Z;aa=((1<>>Z}a=Y&63;Y=a&31;if(32<=(a&63)>>>0){V=X<>>32-Y|o<>>0<4294967295){X=X+1|0}Y=V;while(1){V=aa;W=W<<1|V>>>31;V=V<<1;$=W;W=o>>>31|V;ba=$;V=$;$=W;Z=X-((Y>>>0>>0)+V|0)|0;V=Z>>31;Z=Z>>31;W=z&Z;aa=$-W|0;W=ba-((A&V)+($>>>0>>0)|0)|0;V=o<<1|a>>>31;a=ca|a<<1;o=V|da;V=0;ba=V;$=Z&1;ca=$;_=_+ -1|0;if(_){continue}break}}Rl(aa,W);V=o<<1|a>>>31;a=$|a<<1;T=V|ba;return a}Rl(a,o);a=0;o=0}T=o;return a}function Vl(a,o,z,A){a=Sl(a,o,z,A);return a}function Wl(a,o,z,A){a=Tl(a,o,z,A);return a}function Xl(a,o,z,A){a=Ul(a,o,z,A);return a}function Yl(a){var o=0,z=0;while(1){z=o;if(a){a=a-1&a;o=o+1|0;continue}break}return z}function Zl(a){var A=0;A=a&31;a=0-a&31;return(-1>>>A&-2)<>>a}function _l(a){if(a){return 31-x(a+ -1^a)|0}return 32} + + + + +// EMSCRIPTEN_END_FUNCS +l[1]=cl;l[2]=$c;l[3]=ad;l[4]=bd;l[5]=Zc;l[6]=_c;l[7]=gd;l[8]=hd;l[9]=id;l[10]=cd;l[11]=dd;l[12]=zd;l[13]=Ad;l[14]=vd;l[15]=wd;l[16]=Bd;l[17]=Cd;l[18]=Dd;l[19]=zb;l[20]=Ed;l[21]=al;l[22]=Fd;l[23]=id;l[24]=Od;l[25]=Pd;l[26]=Hd;l[27]=Id;l[28]=Jd;l[29]=Kd;l[30]=Fd;l[31]=Md;l[32]=Nd;l[33]=Yd;l[34]=Zd;l[35]=Rd;l[36]=Td;l[37]=_d;l[38]=Ud;l[39]=Vd;l[40]=Wd;l[41]=Xd;l[42]=ie;l[43]=je;l[44]=ae;l[45]=be;l[46]=ce;l[47]=fe;l[48]=de;l[49]=ke;l[50]=he;l[51]=qe;l[52]=re;l[53]=id;l[54]=vb;l[55]=se;l[56]=te;l[57]=ue;l[58]=Ed;l[59]=te;l[60]=id;l[61]=ve;l[62]=we;l[63]=Ad;l[64]=Ad;l[65]=xe;l[66]=ye;l[67]=ze;l[68]=se;l[69]=Ae;l[70]=De;l[71]=Ee;l[72]=Fe;l[73]=Ge;l[74]=He;l[75]=id;l[76]=Ed;l[77]=Ie;l[78]=Je;l[79]=Ke;l[80]=Ne;l[81]=Oe;l[82]=Pe;l[83]=Qe;l[84]=id;l[85]=Ed;l[86]=Re;l[87]=Se;l[88]=Te;l[89]=$c;l[90]=ad;l[91]=Ve;l[92]=zb;l[93]=Ue;l[94]=re;l[95]=id;l[96]=se;l[97]=Ye;l[98]=Ad;l[99]=Ze;l[100]=_e;l[101]=ze;l[102]=se;l[103]=Ae;l[104]=$e;l[105]=af;l[106]=bf;l[107]=Ge;l[108]=He;l[109]=id;l[110]=Ed;l[111]=Ie;l[112]=Je;l[113]=cf;l[114]=ef;l[115]=ff;l[116]=Pe;l[117]=Qe;l[118]=id;l[119]=Ed;l[120]=Re;l[121]=Se;l[122]=gf;l[123]=$c;l[124]=ad;l[125]=Ve;l[126]=zb;l[127]=hf;l[128]=re;l[129]=te;l[130]=id;l[131]=kf;l[132]=je;l[133]=lf;l[134]=nf;l[135]=mf;l[136]=qf;l[137]=bd;l[138]=of;l[139]=sf;l[140]=tf;l[141]=Pe;l[142]=vb;l[143]=uf;l[144]=id;l[145]=Ed;l[146]=vf;l[147]=id;l[148]=wf;l[149]=xf;l[150]=yf;l[151]=$c;l[152]=ad;l[153]=Ve;l[154]=zb;l[155]=Ue;l[156]=Bf;l[157]=Cf;l[158]=Pe;l[159]=uf;l[160]=id;l[161]=Ed;l[162]=vf;l[163]=xf;l[164]=Df;l[165]=$c;l[166]=ad;l[167]=Ve;l[168]=zb;l[169]=hf;l[170]=$c;l[171]=ad;l[172]=te;l[173]=id;l[174]=te;l[175]=ue;l[176]=Ed;l[177]=Af;l[178]=Ef;l[179]=Kf;l[180]=Lf;l[181]=Ff;l[182]=Gf;l[183]=mf;l[184]=Hf;l[185]=If;l[186]=Jf;l[187]=wg;l[188]=Ad;l[189]=id;l[190]=id;l[191]=vg;l[192]=gi;l[193]=hi;l[194]=id;l[195]=te;l[196]=Ed;l[197]=Ed;l[198]=Bg;l[199]=Cg;l[200]=yg;l[201]=xg;l[202]=Ag;l[203]=Dg;l[204]=Eg;l[205]=Fg;l[206]=zg;l[207]=lh;l[208]=mh;l[209]=Ig;l[210]=Jg;l[211]=Kg;l[212]=Lg;l[213]=Sg;l[214]=id;l[215]=vb;l[216]=eh;l[217]=nh;l[218]=ph;l[219]=Ig;l[220]=Jg;l[221]=Kg;l[222]=Lg;l[223]=gh;l[224]=id;l[225]=vb;l[226]=eh;l[227]=Rg;l[228]=qh;l[229]=Qg;l[230]=rh;l[231]=sh;l[232]=wh;l[233]=xh;l[234]=yh;l[235]=zh;l[236]=vh;l[237]=Bh;l[238]=th;l[239]=Ch;l[240]=Dh;l[241]=Fh;l[242]=Gh;l[243]=Hh;l[244]=Ih;l[245]=Eh;l[246]=Kh;l[247]=Lh;l[248]=Mh;l[249]=Nh;l[250]=Oh;l[251]=Zh;l[252]=Yh;l[253]=Uh;l[254]=$c;l[255]=ad;l[256]=_h;l[257]=$h;l[258]=Ad;l[259]=te;l[260]=id;l[261]=Ni;l[262]=Oi;l[263]=Pi;l[264]=Ri;l[265]=Mi;l[266]=Bj;l[267]=wj;l[268]=zj;l[269]=Pj;l[270]=Qj;l[271]=Tj;l[272]=Rj;l[273]=Sj;l[274]=qk;l[275]=$c;l[276]=ad;l[277]=bl;l[278]=el;l[279]=fl;l[280]=gl;l[281]=$c;l[282]=ad;l[283]=Cj;l[284]=Cj;l[285]=il;l[286]=sl;l[287]=ql;l[288]=ll;l[289]=ad;l[290]=rl;l[291]=pl;l[292]=ml;function U(){return buffer.byteLength/65536|0}function V(pagesToAdd){pagesToAdd=pagesToAdd|0;var W=U()|0;var X=W+pagesToAdd|0;if(W>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":293,"maximum":293+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i=endIdx))++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var STACK_BASE=5256704,DYNAMIC_BASE=5256704,DYNAMICTOP_PTR=13664;var INITIAL_TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_TOTAL_MEMORY/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_TOTAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;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){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";out(what);err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";throw new WebAssembly.RuntimeError(what)}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var wasmBinaryFile="draco_decoder.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}var binary=tryParseAsDataURI(wasmBinaryFile);if(binary){return binary}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"env":asmLibraryArg,"wasi_unstable":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function demangle(func){return func}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function ___cxa_allocate_exception(size){return _malloc(size)}var ___exception_infos={};var ___exception_last=0;function ___cxa_throw(ptr,type,destructor){___exception_infos[ptr]={ptr:ptr,adjusted:[ptr],type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};___exception_last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exceptions=1}else{__ZSt18uncaught_exceptionv.uncaught_exceptions++}throw ptr}function _abort(){abort()}function _emscripten_get_heap_size(){return HEAP8.length}function _emscripten_get_sbrk_ptr(){return 13664}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=_emscripten_get_heap_size();var PAGE_MULTIPLE=65536;var LIMIT=2147483648-PAGE_MULTIPLE;if(requestedSize>LIMIT){return false}var MIN_TOTAL_MEMORY=16777216;var newSize=Math.max(oldSize,MIN_TOTAL_MEMORY);while(newSize>2];return ret},getStr:function(){var ret=UTF8ToString(SYSCALLS.get());return ret},get64:function(){var low=SYSCALLS.get(),high=SYSCALLS.get();return low},getZero:function(){SYSCALLS.get()}};function _fd_close(fd){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}noExitRuntime=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret},copy:function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;i3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",(function(reason,p){process["exit"](1)}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}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}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(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){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}Module["print"]=typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null;Module["printErr"]=typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||Module["print"];Module.print=Module["print"];Module.printErr=Module["printErr"];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){assert(!staticSealed);var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){assert(DYNAMICTOP_PTR);var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(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 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;Module.printErr(text)}}var jsCallStartIndex=1;var functionPointers=new Array(0);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;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=[typeof _malloc==="function"?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;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 allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{if(ArrayBuffer.transfer){ret=ArrayBuffer.transfer(buffer,size)}else{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}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_round=Math.round;var Math_min=Math.min;var Math_max=Math.max;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+19728;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,HBwAAGQcAAAYAAAAAAAAAPQbAACLHAAAHBwAAKgcAAAYAAAAAAAAAPQbAADRHAAAHBwAAO0cAAAwAAAAAAAAAPQbAAAPHQAAHBwAADQdAAAwAAAAAAAAABwcAADsKQAASAAAAAAAAAAcHAAAZB0AAIAAAAAAAAAAHBwAAL0dAACQAAAAAAAAABwcAAARHgAAoAAAAAAAAAAcHAAARR4AALAAAAAAAAAA9BsAAHAeAAAcHAAAlB4AAMgAAAAAAAAA9BsAADIfAAAcHAAA0B8AAOAAAAAAAAAAHBwAAGggAACAAAAAAAAAABwcAADxIAAA4AAAAAAAAAAcHAAAiyEAAOAAAAAAAAAAHBwAAB0iAADgAAAAAAAAABwcAADDIgAA4AAAAAAAAAAcHAAAXiMAAOAAAAAAAAAAHBwAAPQjAABQAQAAAAAAAPQbAACfJAAAHBwAAEolAABoAQAAAAAAABwcAADvJQAAgAAAAAAAAAAcHAAAhSYAAGgBAAAAAAAA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ZXJvIG91dCB0aHJlYWQgdmFsdWUgZm9yIF9fY3hhX2dldF9nbG9iYWxzKCkAdGVybWluYXRlX2hhbmRsZXIgdW5leHBlY3RlZGx5IHJldHVybmVkAFN0MTFsb2dpY19lcnJvcgBTdDEybGVuZ3RoX2Vycm9yAE4xMF9fY3h4YWJpdjExOV9fcG9pbnRlcl90eXBlX2luZm9FAE4xMF9fY3h4YWJpdjExN19fcGJhc2VfdHlwZV9pbmZvRQ==";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___cxa_allocate_exception(size){return _malloc(size)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___cxa_begin_catch(ptr){var info=EXCEPTIONS.infos[ptr];if(info&&!info.caught){info.caught=true;__ZSt18uncaught_exceptionv.uncaught_exception--}if(info)info.rethrown=false;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(setTempRet0(throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___gxx_personality_v0(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function flush_NO_FILESYSTEM(){var fflush=Module["_fflush"];if(fflush)fflush(0);var printChar=___syscall146.printChar;if(!printChar)return;var buffers=___syscall146.buffers;if(buffers[1].length)printChar(1,10);if(buffers[2].length)printChar(2,10)}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffers){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Module["dynCall_v"](func);_pthread_once.seen[ptr]=1}function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function be(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;f[a+72>>2]=e;f[a+64>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;k=a+68|0;l=f[k>>2]|0;f[k>>2]=g;if(l|0)Mq(l);l=a+8|0;Mh(l,b,d,e);d=a+56|0;g=f[d>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+16|0;q=a+32|0;r=a+12|0;s=a+28|0;t=a+20|0;v=a+24|0;if(m-n>>2>>>0>p>>>0){w=p;x=n}else{y=g;aq(y)}while(1){f[j>>2]=f[x+(w<<2)>>2];f[i>>2]=f[j>>2];Cc(a,i,b,w);g=X(w,e)|0;n=b+(g<<2)|0;p=c+(g<<2)|0;g=f[l>>2]|0;if((g|0)>0){m=0;z=f[k>>2]|0;A=g;while(1){if((A|0)>0){g=0;do{B=f[z+(g<<2)>>2]|0;C=f[o>>2]|0;if((B|0)>(C|0)){D=f[q>>2]|0;f[D+(g<<2)>>2]=C;E=D}else{D=f[r>>2]|0;C=f[q>>2]|0;f[C+(g<<2)>>2]=(B|0)<(D|0)?D:B;E=C}g=g+1|0}while((g|0)<(f[l>>2]|0));F=E}else F=f[q>>2]|0;g=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);return 0}function ce(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;Uc(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=4194304;if(d){d=c;c=4194304;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<20)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Mf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function de(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0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=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=4194304;if(d){d=c;c=4194304;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<20)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Mf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function he(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)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s>>>0)/(q>>>0)|0)<<18)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Of(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function je(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=Oa,t=Oa,u=Oa,v=0,w=0,x=0,y=0,z=0;c=f[b>>2]|0;b=a+4|0;d=f[b>>2]|0;e=(d|0)==0;a:do if(!e){g=d+-1|0;h=(g&d|0)==0;if(!h)if(c>>>0>>0)i=c;else i=(c>>>0)%(d>>>0)|0;else i=g&c;j=f[(f[a>>2]|0)+(i<<2)>>2]|0;if(!j)k=i;else{if(h){h=j;while(1){l=f[h>>2]|0;if(!l){k=i;break a}m=f[l+4>>2]|0;if(!((m|0)==(c|0)|(m&g|0)==(i|0))){k=i;break a}if((f[l+8>>2]|0)==(c|0)){o=l;break}else h=l}p=o+12|0;return p|0}else q=j;while(1){h=f[q>>2]|0;if(!h){k=i;break a}g=f[h+4>>2]|0;if((g|0)!=(c|0)){if(g>>>0>>0)r=g;else r=(g>>>0)%(d>>>0)|0;if((r|0)!=(i|0)){k=i;break a}}if((f[h+8>>2]|0)==(c|0)){o=h;break}else q=h}p=o+12|0;return p|0}}else k=0;while(0);q=ln(16)|0;f[q+8>>2]=c;f[q+12>>2]=0;f[q+4>>2]=c;f[q>>2]=0;i=a+12|0;s=$(((f[i>>2]|0)+1|0)>>>0);t=$(d>>>0);u=$(n[a+16>>2]);do if(e|$(u*t)>>0<3|(d+-1&d|0)!=0)&1;j=~~$(W($(s/u)))>>>0;Hi(a,r>>>0>>0?j:r);r=f[b>>2]|0;j=r+-1|0;if(!(j&r)){v=r;w=j&c;break}if(c>>>0>>0){v=r;w=c}else{v=r;w=(c>>>0)%(r>>>0)|0}}else{v=d;w=k}while(0);k=(f[a>>2]|0)+(w<<2)|0;w=f[k>>2]|0;if(!w){d=a+8|0;f[q>>2]=f[d>>2];f[d>>2]=q;f[k>>2]=d;d=f[q>>2]|0;if(d|0){k=f[d+4>>2]|0;d=v+-1|0;if(d&v)if(k>>>0>>0)x=k;else x=(k>>>0)%(v>>>0)|0;else x=k&d;y=(f[a>>2]|0)+(x<<2)|0;z=30}}else{f[q>>2]=f[w>>2];y=w;z=30}if((z|0)==30)f[y>>2]=q;f[i>>2]=(f[i>>2]|0)+1;o=q;p=o+12|0;return p|0}function ke(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;$c(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=262144;if(d){d=c;c=262144;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<16)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Rf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function le(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<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j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function oe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;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>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function se(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l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+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function ve(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;c=u;u=u+16|0;d=c+4|0;e=c;f[a+64>>2]=b;g=a+128|0;f[g>>2]=2;h=a+132|0;f[h>>2]=7;i=Qa[f[(f[b>>2]|0)+32>>2]&127](b)|0;b=a+88|0;f[b>>2]=i;j=a+104|0;k=(f[i+28>>2]|0)-(f[i+24>>2]|0)>>2;i=a+108|0;l=f[i>>2]|0;m=f[j>>2]|0;n=l-m>>2;o=m;p=l;if(k>>>0<=n>>>0)if(k>>>0>>0?(q=o+(k<<2)|0,(q|0)!=(p|0)):0){o=p+(~((p+-4-q|0)>>>2)<<2)|0;f[i>>2]=o;r=o;s=m}else{r=l;s=m}else{Ci(j,k-n|0);r=f[i>>2]|0;s=f[j>>2]|0}if((r|0)!=(s|0)){s=0;do{r=f[b>>2]|0;f[e>>2]=s;f[d>>2]=f[e>>2];n=hh(r,d)|0;r=f[j>>2]|0;f[r+(s<<2)>>2]=n;s=s+1|0}while(s>>>0<(f[i>>2]|0)-r>>2>>>0)}i=a+92|0;s=f[b>>2]|0;j=f[s>>2]|0;d=(f[s+4>>2]|0)-j>>2;e=a+96|0;r=f[e>>2]|0;n=f[i>>2]|0;k=r-n>>2;m=n;n=r;if(d>>>0<=k>>>0)if(d>>>0>>0?(r=m+(d<<2)|0,(r|0)!=(n|0)):0){f[e>>2]=n+(~((n+-4-r|0)>>>2)<<2);t=s;v=j}else{t=s;v=j}else{Ci(i,d-k|0);k=f[b>>2]|0;t=k;v=f[k>>2]|0}k=f[t+4>>2]|0;if((k|0)!=(v|0)){v=f[i>>2]|0;i=f[t>>2]|0;t=k-i>>2;k=0;do{f[v+(k<<2)>>2]=f[i+(k<<2)>>2];k=k+1|0}while(k>>>0>>0)}t=(f[h>>2]|0)-(f[g>>2]|0)+1|0;g=a+136|0;h=a+140|0;a=f[h>>2]|0;k=f[g>>2]|0;i=(a-k|0)/12|0;v=a;if(t>>>0>i>>>0){Kf(g,t-i|0);u=c;return 1}if(t>>>0>=i>>>0){u=c;return 1}i=k+(t*12|0)|0;if((i|0)==(v|0)){u=c;return 1}else w=v;while(1){v=w+-12|0;f[h>>2]=v;t=f[v>>2]|0;if(!t)x=v;else{v=w+-8|0;k=f[v>>2]|0;if((k|0)!=(t|0))f[v>>2]=k+(~((k+-4-t|0)>>>2)<<2);Oq(t);x=f[h>>2]|0}if((x|0)==(i|0))break;else w=x}u=c;return 1}function we(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=f[b>>2]|0;g=f[b+4>>2]|0;h=((f[c>>2]|0)-e<<3)+(f[c+4>>2]|0)-g|0;c=e;if((h|0)<=0){i=d+4|0;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[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0;y=i}else{x=n;y=p}if((x|0)<=0){j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}p=f[y>>2]&-1>>>(32-x|0);y=(w|0)<(x|0)?w:x;n=f[d>>2]|0;i=f[n>>2]&~(-1<>2]&-1>>>(w-y|0));f[n>>2]=i;f[n>>2]=i|p<>2];i=(f[o>>2]|0)+y|0;w=n+(i>>>5<<2)|0;f[d>>2]=w;f[o>>2]=i&31;i=x-y|0;if((i|0)<=0){j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}f[w>>2]=f[w>>2]&~(-1>>>(32-i|0))|p>>>y;f[o>>2]=i;j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}function ye(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+9|0;i=d+8|0;j=f[(f[a+184>>2]|0)+(c<<2)>>2]&255;b[h>>0]=j;c=a+4|0;k=f[(f[c>>2]|0)+44>>2]|0;l=k+16|0;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0)n=j;else{f[g>>2]=f[k+4>>2];f[e>>2]=f[g>>2];Me(k,e,h,h+1|0)|0;n=b[h>>0]|0}a:do if(n<<24>>24>-1){k=a+172|0;j=f[(f[k>>2]|0)+((n<<24>>24)*136|0)>>2]|0;l=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;m=b[h>>0]|0;o=f[k>>2]|0;k=f[o+(m*136|0)+132>>2]|0;switch(f[(f[(f[l>>2]|0)+84>>2]|0)+(j<<2)>>2]|0){case 0:{p=k;q=7;break a;break}case 1:{if(b[o+(m*136|0)+28>>0]|0){p=k;q=7;break a}break}default:{}}m=f[(f[c>>2]|0)+44>>2]|0;b[i>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[q>>2]|0;if((B|0)>(C|0)){D=f[r>>2]|0;f[D+(l<<2)>>2]=C;E=D}else{D=f[s>>2]|0;C=f[r>>2]|0;f[C+(l<<2)>>2]=(B|0)<(D|0)?D:B;E=C}l=l+1|0}while((l|0)<(f[g>>2]|0));F=E}else F=f[r>>2]|0;l=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=l;if((l|0)>=(f[t>>2]|0)){if((l|0)>(f[w>>2]|0)){G=l-(f[v>>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Ae(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;k=a+60|0;f[a+64>>2]=g;g=a+8|0;Mh(g,b,d,e);d=a+56|0;l=f[d>>2]|0;m=f[l+4>>2]|0;n=f[l>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+68|0;q=a+16|0;r=a+32|0;s=a+12|0;t=a+28|0;v=a+20|0;w=a+24|0;if(m-n>>2>>>0>p>>>0){x=p;y=n}else{z=l;aq(z)}while(1){f[j>>2]=f[y+(x<<2)>>2];f[i>>2]=f[j>>2];tb(k,i,b,x);l=X(x,e)|0;n=b+(l<<2)|0;p=c+(l<<2)|0;l=f[g>>2]|0;if((l|0)>0){m=0;a=o;A=l;while(1){if((A|0)>0){l=0;do{B=f[a+(l<<2)>>2]|0;C=f[q>>2]|0;if((B|0)>(C|0)){D=f[r>>2]|0;f[D+(l<<2)>>2]=C;E=D}else{D=f[s>>2]|0;C=f[r>>2]|0;f[C+(l<<2)>>2]=(B|0)<(D|0)?D:B;E=C}l=l+1|0}while((l|0)<(f[g>>2]|0));F=E}else F=f[r>>2]|0;l=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=l;if((l|0)>=(f[t>>2]|0)){if((l|0)>(f[w>>2]|0)){G=l-(f[v>>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Be(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+12|0;g=f[e>>2]|0;h=(f[g+4>>2]|0)-(f[g>>2]|0)>>2;if(!h){u=b;return 1}i=a+152|0;j=a+140|0;k=a+144|0;l=a+148|0;a=0;m=g;while(1){f[d>>2]=(a>>>0)/3|0;f[c>>2]=f[d>>2];if(!(_j(m,c)|0)?(g=f[e>>2]|0,(f[(f[g+12>>2]|0)+(a<<2)>>2]|0)==-1):0){n=a+1|0;o=((n>>>0)%3|0|0)==0?a+-2|0:n;if((o|0)==-1)p=-1;else p=f[(f[g>>2]|0)+(o<<2)>>2]|0;o=f[i>>2]|0;if((f[o+(p<<2)>>2]|0)==-1){g=f[k>>2]|0;n=f[l>>2]|0;if((g|0)==(n<<5|0)){if((g+1|0)<0){q=11;break}r=n<<6;n=g+32&-32;vi(j,g>>>0<1073741823?(r>>>0>>0?n:r):2147483647);s=f[k>>2]|0;t=f[i>>2]|0}else{s=g;t=o}f[k>>2]=s+1;o=(f[j>>2]|0)+(s>>>5<<2)|0;f[o>>2]=f[o>>2]&~(1<<(s&31));o=t+(p<<2)|0;if((f[o>>2]|0)==-1){r=a;n=o;while(1){f[n>>2]=g;o=r+1|0;a:do if((r|0)!=-1?(v=((o>>>0)%3|0|0)==0?r+-2|0:o,(v|0)!=-1):0){w=f[e>>2]|0;x=f[w+12>>2]|0;y=v;while(1){v=f[x+(y<<2)>>2]|0;if((v|0)==-1)break;z=v+1|0;A=((z>>>0)%3|0|0)==0?v+-2|0:z;if((A|0)==-1){B=-1;C=-1;break a}else y=A}x=y+1|0;A=((x>>>0)%3|0|0)==0?y+-2|0:x;if((A|0)==-1){B=y;C=-1}else{B=y;C=f[(f[w>>2]|0)+(A<<2)>>2]|0}}else{B=-1;C=-1}while(0);n=t+(C<<2)|0;if((f[n>>2]|0)!=-1)break;else r=B}}}}r=a+1|0;if(r>>>0>=h>>>0){q=3;break}a=r;m=f[e>>2]|0}if((q|0)==3){u=b;return 1}else if((q|0)==11)aq(j);return 0}function Ce(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+32|0;e=d+8|0;g=d;h=a+4|0;i=f[h>>2]|0;if(i>>>0>=b>>>0){f[h>>2]=b;u=d;return}j=a+8|0;k=f[j>>2]|0;l=k<<5;m=b-i|0;if(l>>>0>>0|i>>>0>(l-m|0)>>>0){f[e>>2]=0;n=e+4|0;f[n>>2]=0;o=e+8|0;f[o>>2]=0;if((b|0)<0)aq(a);p=k<<6;k=b+31&-32;vi(e,l>>>0<1073741823?(p>>>0>>0?k:p):2147483647);p=f[h>>2]|0;f[n>>2]=p+m;k=f[a>>2]|0;l=k;q=f[e>>2]|0;r=(l+(p>>>5<<2)-k<<3)+(p&31)|0;if((r|0)>0){p=r>>>5;im(q|0,k|0,p<<2|0)|0;k=r&31;r=q+(p<<2)|0;s=r;if(!k){t=0;v=s}else{w=-1>>>(32-k|0);f[r>>2]=f[r>>2]&~w|f[l+(p<<2)>>2]&w;t=k;v=s}}else{t=0;v=q}f[g>>2]=v;f[g+4>>2]=t;t=g;g=f[t>>2]|0;v=f[t+4>>2]|0;t=f[a>>2]|0;f[a>>2]=f[e>>2];f[e>>2]=t;e=f[h>>2]|0;f[h>>2]=f[n>>2];f[n>>2]=e;e=f[j>>2]|0;f[j>>2]=f[o>>2];f[o>>2]=e;if(t|0)Oq(t);x=g;y=v}else{v=(f[a>>2]|0)+(i>>>5<<2)|0;f[h>>2]=b;x=v;y=i&31}if(!m){u=d;return}i=(y|0)==0;v=x;if(c){if(i){z=m;A=x;B=v}else{c=32-y|0;b=c>>>0>m>>>0?m:c;f[v>>2]=f[v>>2]|-1>>>(c-b|0)&-1<>>5;sj(A|0,-1,c<<2|0)|0;A=z&31;z=B+(c<<2)|0;if(!A){u=d;return}f[z>>2]=f[z>>2]|-1>>>(32-A|0);u=d;return}else{if(i){C=m;D=x;E=v}else{x=32-y|0;i=x>>>0>m>>>0?m:x;f[v>>2]=f[v>>2]&~(-1>>>(x-i|0)&-1<>>5;sj(D|0,0,y<<2|0)|0;D=C&31;C=E+(y<<2)|0;if(!D){u=d;return}f[C>>2]=f[C>>2]&~(-1>>>(32-D|0));u=d;return}}function De(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;a=u;u=u+48|0;g=a+36|0;h=a+24|0;i=a+12|0;j=a;if(!c){k=0;u=a;return k|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(g);if(l>>>0<11){b[g+11>>0]=l;if(!l)m=g;else{n=g;o=7}}else{p=l+16&-16;q=ln(p)|0;f[g>>2]=q;f[g+8>>2]=p|-2147483648;f[g+4>>2]=l;n=q;o=7}if((o|0)==7){kh(n|0,d|0,l|0)|0;m=n}b[m+l>>0]=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(h);if(l>>>0<11){b[h+11>>0]=l;if(!l)r=h;else{s=h;o=13}}else{m=l+16&-16;n=ln(m)|0;f[h>>2]=n;f[h+8>>2]=m|-2147483648;f[h+4>>2]=l;s=n;o=13}if((o|0)==13){kh(s|0,e|0,l|0)|0;r=s}b[r+l>>0]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(i);if(l>>>0<11){b[i+11>>0]=l;if(!l)t=i;else{v=i;o=19}}else{r=l+16&-16;s=ln(r)|0;f[i>>2]=s;f[i+8>>2]=r|-2147483648;f[i+4>>2]=l;v=s;o=19}if((o|0)==19){kh(v|0,d|0,l|0)|0;t=v}b[t+l>>0]=0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(j);if(l>>>0<11){b[j+11>>0]=l;if(!l)w=j;else{x=j;o=25}}else{t=l+16&-16;v=ln(t)|0;f[j>>2]=v;f[j+8>>2]=t|-2147483648;f[j+4>>2]=l;x=v;o=25}if((o|0)==25){kh(x|0,e|0,l|0)|0;w=x}b[w+l>>0]=0;mn(c,i,j);if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);k=1;u=a;return k|0}function Ee(a,c){a=a|0;c=c|0;var d=0,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Vn(C|0,I|0,z|0,A|0)|0;kh(j|0,(f[f[d>>2]>>2]|0)+p|0,B|0)|0;rf(k,j,l,m);f[o+(w<<2)>>2]=f[l>>2];f[o+((w|1)<<2)>>2]=f[m>>2];v=v+1|0;x=f[e>>2]|0;if(v>>>0>=(f[n>>2]|0)-x>>2>>>0)break;else w=w+2|0}q=f[i>>2]|0}f[a>>2]=q;f[i>>2]=0;u=h;return}f[a>>2]=0;f[i>>2]=0;if(!g){u=h;return}i=g+88|0;a=f[i>>2]|0;f[i>>2]=0;if(a|0){i=f[a+8>>2]|0;if(i|0){q=a+12|0;if((f[q>>2]|0)!=(i|0))f[q>>2]=i;Oq(i)}Oq(a)}a=f[g+68>>2]|0;if(a|0){i=g+72|0;q=f[i>>2]|0;if((q|0)!=(a|0))f[i>>2]=q+(~((q+-4-a|0)>>>2)<<2);Oq(a)}a=g+64|0;q=f[a>>2]|0;f[a>>2]=0;if(q|0){a=f[q>>2]|0;if(a|0){i=q+4|0;if((f[i>>2]|0)!=(a|0))f[i>>2]=a;Oq(a)}Oq(q)}Oq(g);u=h;return}function Ge(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/136|0)>>>0>=c>>>0){i=c;j=h;do{f[j>>2]=-1;Ok(j+4|0);b[j+100>>0]=1;k=j+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;j=(f[g>>2]|0)+136|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/136|0;h=j+c|0;if(h>>>0>31580641)aq(a);k=(e-i|0)/136|0;i=k<<1;e=k>>>0<15790320?(i>>>0>>0?h:i):31580641;do if(e)if(e>>>0>31580641){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*136|0)|0;break}else l=0;while(0);i=l+(j*136|0)|0;j=i;h=l+(e*136|0)|0;e=c;c=j;l=i;do{f[l>>2]=-1;Ok(l+4|0);b[l+100>>0]=1;k=l+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;l=c+136|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=f[g>>2]|0;if((l|0)==(e|0)){m=j;n=e;o=e}else{k=l;l=j;j=i;do{k=k+-136|0;Ee(j+-136|0,k);j=l+-136|0;l=j}while((k|0)!=(e|0));m=l;n=f[a>>2]|0;o=f[g>>2]|0}f[a>>2]=m;f[g>>2]=c;f[d>>2]=h;h=n;if((o|0)!=(h|0)){d=o;do{o=f[d+-20>>2]|0;if(o|0){c=d+-16|0;g=f[c>>2]|0;if((g|0)!=(o|0))f[c>>2]=g+(~((g+-4-o|0)>>>2)<<2);Oq(o)}o=f[d+-32>>2]|0;if(o|0){g=d+-28|0;c=f[g>>2]|0;if((c|0)!=(o|0))f[g>>2]=c+(~((c+-4-o|0)>>>2)<<2);Oq(o)}Mi(d+-132|0);d=d+-136|0}while((d|0)!=(h|0))}if(!n)return;Oq(n);return}function He(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=f[b>>2]|0;b=a+12|0;d=(c|0)==-1;e=c+1|0;do if(!d){g=((e>>>0)%3|0|0)==0?c+-2|0:e;if(!((c>>>0)%3|0)){h=g;i=c+2|0;break}else{h=g;i=c+-1|0;break}}else{h=-1;i=-1}while(0);e=d?-1:(c>>>0)/3|0;g=a+28|0;j=(f[g>>2]|0)+(e>>>5<<2)|0;f[j>>2]=1<<(e&31)|f[j>>2];j=a+172|0;e=a+176|0;k=a+280|0;if(((!d?(d=f[(f[(f[b>>2]|0)+12>>2]|0)+(c<<2)>>2]|0,(d|0)!=-1):0)?(a=(d>>>0)/3|0,(f[(f[g>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0):0)?(a=f[j>>2]|0,(f[e>>2]|0)!=(a|0)):0){d=c>>>5;l=1<<(c&31);c=0;m=a;do{a=(f[k>>2]|0)+(c<<5)|0;if(!(l&f[(f[m+(c*136|0)+4>>2]|0)+(d<<2)>>2]))fj(a,0);else fj(a,1);c=c+1|0;m=f[j>>2]|0}while(c>>>0<(((f[e>>2]|0)-m|0)/136|0)>>>0)}if((((h|0)!=-1?(m=f[(f[(f[b>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,(m|0)!=-1):0)?(c=(m>>>0)/3|0,(f[(f[g>>2]|0)+(c>>>5<<2)>>2]&1<<(c&31)|0)==0):0)?(c=f[j>>2]|0,(f[e>>2]|0)!=(c|0)):0){m=h>>>5;d=1<<(h&31);h=0;l=c;do{c=(f[k>>2]|0)+(h<<5)|0;if(!(d&f[(f[l+(h*136|0)+4>>2]|0)+(m<<2)>>2]))fj(c,0);else fj(c,1);h=h+1|0;l=f[j>>2]|0}while(h>>>0<(((f[e>>2]|0)-l|0)/136|0)>>>0)}if((i|0)==-1)return 1;l=f[(f[(f[b>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;if((l|0)==-1)return 1;b=(l>>>0)/3|0;if(f[(f[g>>2]|0)+(b>>>5<<2)>>2]&1<<(b&31)|0)return 1;b=f[j>>2]|0;if((f[e>>2]|0)==(b|0))return 1;g=i>>>5;l=1<<(i&31);i=0;h=b;do{b=(f[k>>2]|0)+(i<<5)|0;if(!(l&f[(f[h+(i*136|0)+4>>2]|0)+(g<<2)>>2]))fj(b,0);else fj(b,1);i=i+1|0;h=f[j>>2]|0}while(i>>>0<(((f[e>>2]|0)-h|0)/136|0)>>>0);return 1}function Ie(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=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>>24;Rh(a,c,(f[j>>2]|0)-(f[e>>2]|0)>>2,l,g,d,1);g=f[a>>2]|0;a=(f[f[g>>2]>>2]|0)+(f[g+48>>2]|0)|0;g=f[c+4>>2]|0;Ap(i);Ko(i,$(n[c+20>>2]),(1<>>0>1073741823?-1:l<<2)|0;m=f[j>>2]|0;j=f[e>>2]|0;e=j;if((m|0)==(j|0)){Mq(g);u=h;return}o=d+68|0;p=d+48|0;q=d+40|0;r=c+8|0;c=i+4|0;s=(b[d+84>>0]|0)==0;t=m-j>>2;if(k<<24>>24>0){v=0;w=0}else{k=0;do{j=f[e+(k<<2)>>2]|0;if(s)x=f[(f[o>>2]|0)+(j<<2)>>2]|0;else x=j;j=p;m=f[j>>2]|0;y=f[j+4>>2]|0;j=q;z=f[j>>2]|0;A=un(z|0,f[j+4>>2]|0,x|0,0)|0;j=Vn(A|0,I|0,m|0,y|0)|0;kh(g|0,(f[f[d>>2]>>2]|0)+j|0,z|0)|0;k=k+1|0}while(k>>>0>>0);Mq(g);u=h;return}while(1){k=f[e+(v<<2)>>2]|0;if(s)B=f[(f[o>>2]|0)+(k<<2)>>2]|0;else B=k;k=p;x=f[k>>2]|0;z=f[k+4>>2]|0;k=q;j=f[k>>2]|0;y=un(j|0,f[k+4>>2]|0,B|0,0)|0;k=Vn(y|0,I|0,x|0,z|0)|0;kh(g|0,(f[f[d>>2]>>2]|0)+k|0,j|0)|0;j=f[r>>2]|0;C=$(n[i>>2]);k=0;z=w;while(1){D=$(n[g+(k<<2)>>2]);E=$(D-$(n[j+(k<<2)>>2]));x=E<$(0.0);D=$(-E);F=$((x?D:E)/C);y=~~$(J($($(F*$(f[c>>2]|0))+$(.5))));f[a+(z<<2)>>2]=x?0-y|0:y;k=k+1|0;if((k|0)==(l|0))break;else z=z+1|0}v=v+1|0;if(v>>>0>=t>>>0)break;else w=w+l|0}Mq(g);u=h;return}function Ke(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;d=u;u=u+32|0;e=d+16|0;g=d+12|0;h=d+8|0;i=d+4|0;j=d;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;k=a+24|0;lp(k);if((a|0)!=(b|0)){f[h>>2]=f[b>>2];f[i>>2]=b+4;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(a,g,e)}l=b+24|0;if((k|0)!=(l|0)){f[h>>2]=f[l>>2];f[i>>2]=b+28;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k,g,e)}f[j>>2]=0;k=c+8|0;l=c+12|0;c=f[l>>2]|0;m=f[k>>2]|0;if((c-m|0)<=0){u=d;return}n=b+16|0;b=m;m=c;c=0;while(1){o=f[(f[b+(c<<2)>>2]|0)+56>>2]|0;p=f[n>>2]|0;if(p){q=n;r=p;a:while(1){p=r;while(1){if((f[p+16>>2]|0)>=(o|0))break;s=f[p+4>>2]|0;if(!s){t=q;break a}else p=s}r=f[p>>2]|0;if(!r){t=p;break}else q=p}if((t|0)!=(n|0)?(o|0)>=(f[t+16>>2]|0):0){q=t+20|0;r=Hd(a,j)|0;if((r|0)!=(q|0)){f[h>>2]=f[q>>2];f[i>>2]=t+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(r,g,e)}v=f[j>>2]|0;w=f[k>>2]|0;x=f[l>>2]|0}else{v=c;w=b;x=m}}else{v=c;w=b;x=m}c=v+1|0;f[j>>2]=c;if((c|0)>=(x-w>>2|0))break;else{b=w;m=x}}u=d;return}function Le(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+12|0;ci(f[i>>2]|0,c)|0;if(!(f[i>>2]|0)){j=1;u=d;return j|0}k=c+16|0;l=c+4|0;m=h+1|0;n=h+1|0;o=h+1|0;p=0;while(1){q=f[a>>2]|0;r=f[q+(p<<3)>>2]|0;if(r>>>0>63)if(r>>>0>16383)if(r>>>0>4194303){j=0;s=20;break}else{t=2;s=13}else{t=1;s=13}else if(!r){v=p+1|0;w=0;while(1){if(f[q+(v+w<<3)>>2]|0){x=w;break}y=w+1|0;if(y>>>0<63)w=y;else{x=y;break}}b[h>>0]=x<<2|3;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,o)|0}z=x+p|0}else{t=0;s=13}if((s|0)==13){s=0;b[h>>0]=t|r<<2;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}if(!t)z=p;else{w=0;do{w=w+1|0;b[h>>0]=r>>>((w<<3)+-2|0);v=k;q=f[v+4>>2]|0;if(!((q|0)>0|(q|0)==0&(f[v>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,m)|0}}while((w|0)<(t|0));z=p}}p=z+1|0;if(p>>>0>=(f[i>>2]|0)>>>0){j=1;s=20;break}}if((s|0)==20){u=d;return j|0}return 0}function Me(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;g=f[a>>2]|0;h=g;i=(f[c>>2]|0)-h|0;c=g+i|0;j=e-d|0;if((j|0)<=0){k=c;return k|0}l=a+8|0;m=f[l>>2]|0;n=a+4|0;o=f[n>>2]|0;p=o;if((j|0)<=(m-p|0)){q=p-c|0;if((j|0)>(q|0)){r=d+q|0;if((r|0)==(e|0))s=o;else{t=r;u=o;while(1){b[u>>0]=b[t>>0]|0;t=t+1|0;v=(f[n>>2]|0)+1|0;f[n>>2]=v;if((t|0)==(e|0)){s=v;break}else u=v}}if((q|0)>0){w=r;x=s}else{k=c;return k|0}}else{w=e;x=o}s=x-(c+j)|0;r=c+s|0;if(r>>>0>>0){q=r;r=x;do{b[r>>0]=b[q>>0]|0;q=q+1|0;r=(f[n>>2]|0)+1|0;f[n>>2]=r}while((q|0)!=(o|0))}if(s|0)im(x+(0-s)|0,c|0,s|0)|0;if((w|0)==(d|0)){k=c;return k|0}else{y=d;z=c}while(1){b[z>>0]=b[y>>0]|0;y=y+1|0;if((y|0)==(w|0)){k=c;break}else z=z+1|0}return k|0}z=p-h+j|0;if((z|0)<0)aq(a);j=m-h|0;h=j<<1;m=j>>>0<1073741823?(h>>>0>>0?z:h):2147483647;h=c;if(!m)A=0;else A=ln(m)|0;z=A+i|0;i=z;j=A+m|0;if((d|0)==(e|0)){B=i;C=g}else{g=d;d=i;i=z;do{b[i>>0]=b[g>>0]|0;i=d+1|0;d=i;g=g+1|0}while((g|0)!=(e|0));B=d;C=f[a>>2]|0}d=h-C|0;e=z+(0-d)|0;if((d|0)>0)kh(e|0,C|0,d|0)|0;d=(f[n>>2]|0)-h|0;if((d|0)>0){h=B;kh(h|0,c|0,d|0)|0;D=h+d|0;E=f[a>>2]|0}else{D=B;E=C}f[a>>2]=e;f[n>>2]=D;f[l>>2]=j;if(!E){k=z;return k|0}Oq(E);k=z;return k|0}function Ne(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+16|0;g=e;h=f[(f[c+4>>2]|0)+(d<<2)>>2]|0;d=f[c+28>>2]|0;c=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(h<<2)>>2]|0;switch(f[c+28>>2]|0){case 5:case 6:case 3:case 4:case 1:case 2:{i=ln(40)|0;zo(i);j=i;k=j;f[a>>2]=k;u=e;return}case 9:{l=3;break}default:{}}if((l|0)==3){i=f[d+48>>2]|0;d=ln(32)|0;f[g>>2]=d;f[g+8>>2]=-2147483616;f[g+4>>2]=17;m=d;n=14495;o=m+17|0;do{b[m>>0]=b[n>>0]|0;m=m+1|0;n=n+1|0}while((m|0)<(o|0));b[d+17>>0]=0;d=i+16|0;n=f[d>>2]|0;if(n){p=d;q=n;a:while(1){n=q;while(1){if((f[n+16>>2]|0)>=(h|0))break;r=f[n+4>>2]|0;if(!r){s=p;break a}else n=r}q=f[n>>2]|0;if(!q){s=n;break}else p=n}if(((s|0)!=(d|0)?(h|0)>=(f[s+16>>2]|0):0)?(h=s+20|0,(Jh(h,g)|0)!=0):0)t=Hk(h,g,-1)|0;else l=12}else l=12;if((l|0)==12)t=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((t|0)>0)if((f[c+56>>2]|0)==1){c=ln(48)|0;m=c;o=m+48|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(o|0));zo(c);f[c>>2]=2496;f[c+40>>2]=1168;f[c+44>>2]=-1;j=c;k=j;f[a>>2]=k;u=e;return}else{c=ln(64)|0;ym(c);j=c;k=j;f[a>>2]=k;u=e;return}}c=ln(36)|0;Hm(c);j=c;k=j;f[a>>2]=k;u=e;return}function Oe(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=(c|0)==(a|0);b[c+12>>0]=d&1;if(d)return;else e=c;while(1){g=e+8|0;h=f[g>>2]|0;c=h+12|0;if(b[c>>0]|0){i=23;break}j=h+8|0;k=f[j>>2]|0;d=f[k>>2]|0;if((d|0)==(h|0)){l=f[k+4>>2]|0;if(!l){i=7;break}m=l+12|0;if(!(b[m>>0]|0))n=m;else{i=7;break}}else{if(!d){i=16;break}m=d+12|0;if(!(b[m>>0]|0))n=m;else{i=16;break}}b[c>>0]=1;c=(k|0)==(a|0);b[k+12>>0]=c&1;b[n>>0]=1;if(c){i=23;break}else e=k}if((i|0)==7){if((f[h>>2]|0)==(e|0)){o=h;p=k}else{n=h+4|0;a=f[n>>2]|0;c=f[a>>2]|0;f[n>>2]=c;if(!c)q=k;else{f[c+8>>2]=h;q=f[j>>2]|0}f[a+8>>2]=q;q=f[j>>2]|0;f[((f[q>>2]|0)==(h|0)?q:q+4|0)>>2]=a;f[a>>2]=h;f[j>>2]=a;o=a;p=f[a+8>>2]|0}b[o+12>>0]=1;b[p+12>>0]=0;o=f[p>>2]|0;a=o+4|0;q=f[a>>2]|0;f[p>>2]=q;if(q|0)f[q+8>>2]=p;q=p+8|0;f[o+8>>2]=f[q>>2];c=f[q>>2]|0;f[((f[c>>2]|0)==(p|0)?c:c+4|0)>>2]=o;f[a>>2]=p;f[q>>2]=o;return}else if((i|0)==16){if((f[h>>2]|0)==(e|0)){o=e+4|0;q=f[o>>2]|0;f[h>>2]=q;if(!q)r=k;else{f[q+8>>2]=h;r=f[j>>2]|0}f[g>>2]=r;r=f[j>>2]|0;f[((f[r>>2]|0)==(h|0)?r:r+4|0)>>2]=e;f[o>>2]=h;f[j>>2]=e;s=e;t=f[e+8>>2]|0}else{s=h;t=k}b[s+12>>0]=1;b[t+12>>0]=0;s=t+4|0;k=f[s>>2]|0;h=f[k>>2]|0;f[s>>2]=h;if(h|0)f[h+8>>2]=t;h=t+8|0;f[k+8>>2]=f[h>>2];s=f[h>>2]|0;f[((f[s>>2]|0)==(t|0)?s:s+4|0)>>2]=k;f[k>>2]=t;f[h>>2]=k;return}else if((i|0)==23)return}function Pe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;d=f[b>>2]|0;b=a+12|0;e=(d|0)==-1;do if(e){g=1;h=-1;i=-1}else{j=d+(((d>>>0)%3|0|0)==0?2:-1)|0;if((j|0)!=-1){k=f[(f[b>>2]|0)+12>>2]|0;l=j;while(1){j=f[k+(l<<2)>>2]|0;if((j|0)==-1){m=0;n=l;break}o=j+1|0;l=((o>>>0)%3|0|0)==0?j+-2|0:o;if((l|0)==-1){m=1;n=-1;break}}if(e){g=m;h=-1;i=n;break}else{p=m;q=n}}else{p=1;q=-1}g=p;h=f[(f[f[b>>2]>>2]|0)+(d<<2)>>2]|0;i=q}while(0);if(c){c=(f[a+84>>2]|0)+(h>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(h&31);r=1}else r=0;c=f[(f[a+152>>2]|0)+(h<<2)>>2]|0;q=(f[a+140>>2]|0)+(c>>>5<<2)|0;f[q>>2]=f[q>>2]|1<<(c&31);if(!g){g=(((i>>>0)%3|0|0)==0?2:-1)+i|0;if((g|0)==-1){s=-1;t=i}else{s=f[(f[f[b>>2]>>2]|0)+(g<<2)>>2]|0;t=i}}else{s=-1;t=-1}if((s|0)==(h|0)){u=r;return u|0}i=f[a+84>>2]|0;a=r;r=s;s=t;while(1){t=i+(r>>>5<<2)|0;f[t>>2]=f[t>>2]|1<<(r&31);t=a+1|0;g=s+1|0;a:do if((s|0)!=-1?(c=((g>>>0)%3|0|0)==0?s+-2|0:g,(c|0)!=-1):0){q=f[b>>2]|0;d=f[q+12>>2]|0;p=c;while(1){c=f[d+(p<<2)>>2]|0;if((c|0)==-1)break;n=c+1|0;m=((n>>>0)%3|0|0)==0?c+-2|0:n;if((m|0)==-1){v=-1;w=-1;break a}else p=m}d=(((p>>>0)%3|0|0)==0?2:-1)+p|0;if((d|0)==-1){v=-1;w=p}else{v=f[(f[q>>2]|0)+(d<<2)>>2]|0;w=p}}else{v=-1;w=-1}while(0);if((v|0)==(h|0)){u=t;break}else{a=t;r=v;s=w}}return u|0}function Qe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa;g=u;u=u+16|0;h=g;i=b[d+24>>0]|0;j=i<<24>>24;Rh(a,c,e,j,0,d,1);k=f[a>>2]|0;a=(f[f[k>>2]>>2]|0)+(f[k+48>>2]|0)|0;k=f[c+4>>2]|0;Ap(h);Ko(h,$(n[c+20>>2]),(1<>>0>1073741823?-1:j<<2)|0;if(!e){Mq(k);u=g;return}l=d+68|0;m=d+48|0;o=d+40|0;p=c+8|0;c=h+4|0;q=(b[d+84>>0]|0)==0;if(i<<24>>24>0){r=0;s=0}else{i=0;do{if(q)t=f[(f[l>>2]|0)+(i<<2)>>2]|0;else t=i;v=m;w=f[v>>2]|0;x=f[v+4>>2]|0;v=o;y=f[v>>2]|0;z=un(y|0,f[v+4>>2]|0,t|0,0)|0;v=Vn(z|0,I|0,w|0,x|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+v|0,y|0)|0;i=i+1|0}while((i|0)!=(e|0));Mq(k);u=g;return}while(1){if(q)A=f[(f[l>>2]|0)+(s<<2)>>2]|0;else A=s;i=m;t=f[i>>2]|0;y=f[i+4>>2]|0;i=o;v=f[i>>2]|0;x=un(v|0,f[i+4>>2]|0,A|0,0)|0;i=Vn(x|0,I|0,t|0,y|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+i|0,v|0)|0;v=f[p>>2]|0;B=$(n[h>>2]);i=0;y=r;while(1){C=$(n[k+(i<<2)>>2]);D=$(C-$(n[v+(i<<2)>>2]));t=D<$(0.0);C=$(-D);E=$((t?C:D)/B);x=~~$(J($($(E*$(f[c>>2]|0))+$(.5))));f[a+(y<<2)>>2]=t?0-x|0:x;i=i+1|0;if((i|0)==(j|0))break;else y=y+1|0}s=s+1|0;if((s|0)==(e|0))break;else r=r+j|0}Mq(k);u=g;return}function Re(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;c=a+4|0;d=f[c>>2]|0;e=a+100|0;if(d>>>0<(f[e>>2]|0)>>>0){f[c>>2]=d+1;g=h[d>>0]|0}else g=Si(a)|0;switch(g|0){case 43:case 45:{d=(g|0)==45&1;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;j=h[i>>0]|0}else j=Si(a)|0;if((b|0)!=0&(j+-48|0)>>>0>9?(f[e>>2]|0)!=0:0){f[c>>2]=(f[c>>2]|0)+-1;k=d;l=j}else{k=d;l=j}break}default:{k=0;l=g}}if((l+-48|0)>>>0>9)if(!(f[e>>2]|0)){m=-2147483648;n=0}else{f[c>>2]=(f[c>>2]|0)+-1;m=-2147483648;n=0}else{g=0;j=l;while(1){g=j+-48+(g*10|0)|0;l=f[c>>2]|0;if(l>>>0<(f[e>>2]|0)>>>0){f[c>>2]=l+1;o=h[l>>0]|0}else o=Si(a)|0;if(!((o+-48|0)>>>0<10&(g|0)<214748364))break;else j=o}j=((g|0)<0)<<31>>31;if((o+-48|0)>>>0<10){l=o;d=g;b=j;while(1){i=un(d|0,b|0,10,0)|0;p=I;q=Vn(l|0,((l|0)<0)<<31>>31|0,-48,-1)|0;r=Vn(q|0,I|0,i|0,p|0)|0;p=I;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;s=h[i>>0]|0}else s=Si(a)|0;if((s+-48|0)>>>0<10&((p|0)<21474836|(p|0)==21474836&r>>>0<2061584302)){l=s;d=r;b=p}else{t=s;u=r;v=p;break}}}else{t=o;u=g;v=j}if((t+-48|0)>>>0<10)do{t=f[c>>2]|0;if(t>>>0<(f[e>>2]|0)>>>0){f[c>>2]=t+1;w=h[t>>0]|0}else w=Si(a)|0}while((w+-48|0)>>>0<10);if(f[e>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;c=(k|0)!=0;k=Xn(0,0,u|0,v|0)|0;m=c?I:v;n=c?k:u}I=m;return n|0}function Se(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;b=a+1176|0;c=f[b>>2]|0;if(c|0){d=a+1180|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+1164|0;b=f[g>>2]|0;if(b|0){j=a+1168|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+1152>>2]|0;if(l|0){g=a+1156|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1140>>2]|0;if(l|0){m=a+1144|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1128>>2]|0;if(!l){n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}g=a+1132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}function Te(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d;g=a+4|0;h=f[g>>2]|0;i=f[(f[a>>2]|0)+52>>2]|0;if(!h){if(!(Sa[i&31](a,c,0)|0)){j=0;u=d;return j|0}}else if(!(Sa[i&31](a,c,f[(f[h+4>>2]|0)+80>>2]|0)|0)){j=0;u=d;return j|0}if(!(b[a+28>>0]|0)){j=1;u=d;return j|0}h=f[a+8>>2]|0;i=f[a+32>>2]|0;a=f[h+80>>2]|0;f[e>>2]=0;k=e+4|0;f[k>>2]=0;f[e+8>>2]=0;do if(a)if(a>>>0>1073741823)aq(e);else{l=a<<2;m=ln(l)|0;f[e>>2]=m;n=m+(a<<2)|0;f[e+8>>2]=n;sj(m|0,0,l|0)|0;f[k>>2]=n;o=m;p=n;q=m;break}else{o=0;p=0;q=0}while(0);e=f[c+4>>2]|0;a=f[c>>2]|0;c=a;a:do if((e|0)!=(a|0)){m=e-a>>2;if(b[h+84>>0]|0){n=0;while(1){f[o+(f[c+(n<<2)>>2]<<2)>>2]=n;n=n+1|0;if(n>>>0>=m>>>0)break a}}n=f[h+68>>2]|0;l=0;do{f[o+(f[n+(f[c+(l<<2)>>2]<<2)>>2]<<2)>>2]=l;l=l+1|0}while(l>>>0>>0)}while(0);c=f[(f[(f[g>>2]|0)+4>>2]|0)+80>>2]|0;b:do if(c|0){g=f[i+68>>2]|0;if(b[h+84>>0]|0){a=0;while(1){f[g+(a<<2)>>2]=f[o+(a<<2)>>2];a=a+1|0;if(a>>>0>=c>>>0)break b}}a=f[h+68>>2]|0;e=0;do{f[g+(e<<2)>>2]=f[o+(f[a+(e<<2)>>2]<<2)>>2];e=e+1|0}while(e>>>0>>0)}while(0);if(o|0){if((p|0)!=(o|0))f[k>>2]=p+(~((p+-4-o|0)>>>2)<<2);Oq(q)}j=1;u=d;return j|0}function Ue(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;Oh(a+12|0);wn(a+1036|0);vo(a+1068|0);vo(a+1088|0);vo(a+1108|0);e=a+1128|0;f[e>>2]=0;g=a+1132|0;f[g>>2]=0;f[a+1136>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+1136>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+1140|0;f[g>>2]=0;e=a+1144|0;f[e>>2]=0;f[a+1148>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+1148>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+1152|0;f[g>>2]=0;e=a+1156|0;f[e>>2]=0;f[a+1160>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+1160>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+1164|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+1176|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function Ve(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0;g=u;u=u+16|0;h=g;i=b+16|0;f[a>>2]=f[i>>2];f[a+4>>2]=f[i+4>>2];f[a+8>>2]=f[i+8>>2];f[a+12>>2]=f[i+12>>2];f[a+16>>2]=f[i+16>>2];f[a+20>>2]=f[i+20>>2];j=a+8|0;f[j>>2]=(f[j>>2]|0)+d;j=(d|0)>0;if(j){k=b+4|0;l=a+16|0;m=a+12|0;n=f[b>>2]|0;o=n;q=0;r=o;s=n;n=o;while(1){o=f[c+(q<<2)>>2]|0;t=f[k>>2]|0;if(t-s>>2>>>0>o>>>0){v=r;w=n}else{x=o+1|0;f[h>>2]=0;y=t-s>>2;z=s;A=t;if(x>>>0<=y>>>0)if(x>>>0>>0?(t=z+(x<<2)|0,(t|0)!=(A|0)):0){f[k>>2]=A+(~((A+-4-t|0)>>>2)<<2);B=r}else B=r;else{Ch(b,x-y|0,h);B=f[b>>2]|0}v=B;w=B}y=w+(o<<2)|0;x=f[y>>2]|0;s=w;if((x|0)<=1)if((x|0)==0?(f[l>>2]=(f[l>>2]|0)+1,o>>>0>(f[m>>2]|0)>>>0):0){f[m>>2]=o;C=0.0}else C=0.0;else{D=+(x|0);C=+Zg(D)*D}x=(f[y>>2]|0)+1|0;f[y>>2]=x;D=+(x|0);E=+Zg(D)*D-C;p[a>>3]=+p[a>>3]+E;q=q+1|0;if((q|0)==(d|0))break;else{r=v;n=w}}}if(e){f[i>>2]=f[a>>2];f[i+4>>2]=f[a+4>>2];f[i+8>>2]=f[a+8>>2];f[i+12>>2]=f[a+12>>2];f[i+16>>2]=f[a+16>>2];u=g;return}if(!j){u=g;return}j=f[b>>2]|0;b=0;do{a=j+(f[c+(b<<2)>>2]<<2)|0;f[a>>2]=(f[a>>2]|0)+-1;b=b+1|0}while((b|0)!=(d|0));u=g;return}function We(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;f[a>>2]=e;break a;break}case 10:{e=(f[c>>2]|0)+(4-1)&~(4-1);d=f[e>>2]|0;f[c>>2]=e+4;e=a;f[e>>2]=d;f[e+4>>2]=((d|0)<0)<<31>>31;break a;break}case 11:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;d=a;f[d>>2]=e;f[d+4>>2]=0;break a;break}case 12:{d=(f[c>>2]|0)+(8-1)&~(8-1);e=d;g=f[e>>2]|0;h=f[e+4>>2]|0;f[c>>2]=d+8;d=a;f[d>>2]=g;f[d+4>>2]=h;break a;break}case 13:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&65535)<<16>>16;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 14:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&65535;f[h+4>>2]=0;break a;break}case 15:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&255)<<24>>24;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 16:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&255;f[h+4>>2]=0;break a;break}case 17:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}case 18:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}default:break a}while(0);while(0);return}function Xe(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+16|0;d=c+4|0;e=c;g=c+8|0;if(!(Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)){h=0;u=c;return h|0}i=a+44|0;j=f[i>>2]|0;k=a+8|0;l=a+12|0;m=f[l>>2]|0;n=f[k>>2]|0;b[g>>0]=(m-n|0)>>>2;o=j+16|0;p=f[o+4>>2]|0;if((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0){q=k;r=n;s=m}else{f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0;q=k;r=f[k>>2]|0;s=f[l>>2]|0}a:do if((r|0)!=(s|0)){l=a+4|0;k=r;while(1){g=f[k>>2]|0;k=k+4|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,a,f[l>>2]|0)|0)){h=0;break}if((k|0)==(s|0))break a}u=c;return h|0}while(0);if(!(xc(a)|0)){h=0;u=c;return h|0}s=a+32|0;r=f[s>>2]|0;k=a+36|0;l=f[k>>2]|0;b:do if((r|0)!=(l|0)){g=r;do{if(!(Ra[f[(f[a>>2]|0)+40>>2]&127](a,f[g>>2]|0)|0)){h=0;t=18;break}g=g+4|0}while((g|0)!=(l|0));if((t|0)==18){u=c;return h|0}g=f[s>>2]|0;d=f[k>>2]|0;if((g|0)!=(d|0)){j=g;while(1){g=f[(f[q>>2]|0)+(f[j>>2]<<2)>>2]|0;j=j+4|0;if(!(Ra[f[(f[g>>2]|0)+12>>2]&127](g,f[i>>2]|0)|0)){h=0;break}if((j|0)==(d|0))break b}u=c;return h|0}}while(0);h=Qa[f[(f[a>>2]|0)+44>>2]&127](a)|0;u=c;return h|0}function Ye(a,b){a=a|0;b=b|0;ld(a,b);ld(a+32|0,b);ld(a+64|0,b);ld(a+96|0,b);ld(a+128|0,b);ld(a+160|0,b);ld(a+192|0,b);ld(a+224|0,b);ld(a+256|0,b);ld(a+288|0,b);ld(a+320|0,b);ld(a+352|0,b);ld(a+384|0,b);ld(a+416|0,b);ld(a+448|0,b);ld(a+480|0,b);ld(a+512|0,b);ld(a+544|0,b);ld(a+576|0,b);ld(a+608|0,b);ld(a+640|0,b);ld(a+672|0,b);ld(a+704|0,b);ld(a+736|0,b);ld(a+768|0,b);ld(a+800|0,b);ld(a+832|0,b);ld(a+864|0,b);ld(a+896|0,b);ld(a+928|0,b);ld(a+960|0,b);ld(a+992|0,b);ld(a+1024|0,b);return}function Ze(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;c=u;u=u+32|0;d=c;e=a+4|0;g=f[a>>2]|0;h=(f[e>>2]|0)-g>>2;i=h+1|0;if(i>>>0>1073741823)aq(a);j=a+8|0;k=(f[j>>2]|0)-g|0;g=k>>1;l=k>>2>>>0<536870911?(g>>>0>>0?i:g):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(l)if(l>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}else{m=ln(l<<2)|0;break}else m=0;while(0);f[d>>2]=m;g=m+(h<<2)|0;h=d+8|0;i=d+4|0;f[i>>2]=g;k=m+(l<<2)|0;l=d+12|0;f[l>>2]=k;m=f[b>>2]|0;f[b>>2]=0;f[g>>2]=m;m=g+4|0;f[h>>2]=m;b=f[a>>2]|0;n=f[e>>2]|0;if((n|0)==(b|0)){o=g;p=l;q=h;r=b;s=m;t=n;v=k;w=o;f[a>>2]=w;f[i>>2]=r;f[e>>2]=s;f[q>>2]=t;x=f[j>>2]|0;f[j>>2]=v;f[p>>2]=x;f[d>>2]=r;ki(d);u=c;return}else{y=n;z=g}do{y=y+-4|0;g=f[y>>2]|0;f[y>>2]=0;f[z+-4>>2]=g;z=(f[i>>2]|0)+-4|0;f[i>>2]=z}while((y|0)!=(b|0));o=z;p=l;q=h;r=f[a>>2]|0;s=f[h>>2]|0;t=f[e>>2]|0;v=f[l>>2]|0;w=o;f[a>>2]=w;f[i>>2]=r;f[e>>2]=s;f[q>>2]=t;x=f[j>>2]|0;f[j>>2]=v;f[p>>2]=x;f[d>>2]=r;ki(d);u=c;return}function _e(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+32|0;e=d+12|0;g=d;h=nl(c,0)|0;if(!h){f[a>>2]=0;u=d;return}i=f[c+100>>2]|0;j=f[c+96>>2]|0;c=i-j|0;k=(c|0)/12|0;f[e>>2]=0;l=e+4|0;f[l>>2]=0;f[e+8>>2]=0;m=j;do if(c)if(k>>>0>357913941)aq(e);else{n=ln(c)|0;f[e>>2]=n;f[e+8>>2]=n+(k*12|0);sj(n|0,0,c|0)|0;f[l>>2]=n+c;o=n;break}else o=0;while(0);f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;a:do if((i|0)!=(j|0)){c=g+4|0;n=g+8|0;if(b[h+84>>0]|0){p=0;while(1){q=m+(p*12|0)|0;f[g>>2]=f[q>>2];f[g+4>>2]=f[q+4>>2];f[g+8>>2]=f[q+8>>2];f[o+(p*12|0)>>2]=f[g>>2];f[o+(p*12|0)+4>>2]=f[c>>2];f[o+(p*12|0)+8>>2]=f[n>>2];p=p+1|0;if(p>>>0>=k>>>0)break a}}p=f[h+68>>2]|0;q=0;do{r=f[p+(f[m+(q*12|0)>>2]<<2)>>2]|0;f[g>>2]=r;s=f[p+(f[m+(q*12|0)+4>>2]<<2)>>2]|0;f[c>>2]=s;t=f[p+(f[m+(q*12|0)+8>>2]<<2)>>2]|0;f[n>>2]=t;f[o+(q*12|0)>>2]=r;f[o+(q*12|0)+4>>2]=s;f[o+(q*12|0)+8>>2]=t;q=q+1|0}while(q>>>0>>0)}while(0);Kj(a,e);a=f[e>>2]|0;if(a|0){e=f[l>>2]|0;if((e|0)!=(a|0))f[l>>2]=e+(~(((e+-12-a|0)>>>0)/12|0)*12|0);Oq(a)}u=d;return}function $e(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;wn(a+12|0);vo(a+44|0);vo(a+64|0);vo(a+84|0);e=a+104|0;f[e>>2]=0;g=a+108|0;f[g>>2]=0;f[a+112>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+112>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+116|0;f[g>>2]=0;e=a+120|0;f[e>>2]=0;f[a+124>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+124>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+128|0;f[g>>2]=0;e=a+132|0;f[e>>2]=0;f[a+136>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+136>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+140|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+152|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function af(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;vo(a+12|0);vo(a+32|0);vo(a+52|0);vo(a+72|0);e=a+92|0;f[e>>2]=0;g=a+96|0;f[g>>2]=0;f[a+100>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+100>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+104|0;f[g>>2]=0;e=a+108|0;f[e>>2]=0;f[a+112>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+112>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+116|0;f[g>>2]=0;e=a+120|0;f[e>>2]=0;f[a+124>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+124>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+128|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+140|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function bf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;d=ln(40)|0;e=d+16|0;pj(e,c);pj(d+28|0,c+12|0);c=a+4|0;g=f[c>>2]|0;do if(g){h=b[d+27>>0]|0;i=h<<24>>24<0;j=i?f[d+20>>2]|0:h&255;h=i?f[e>>2]|0:e;i=g;while(1){k=i+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[i+20>>2]|0:l&255;l=n>>>0>>0?n:j;if((l|0)!=0?(o=Vk(h,m?f[k>>2]|0:k,l)|0,(o|0)!=0):0)if((o|0)<0)p=7;else p=9;else if(j>>>0>>0)p=7;else p=9;if((p|0)==7){p=0;n=f[i>>2]|0;if(!n){p=8;break}else q=n}else if((p|0)==9){p=0;r=i+4|0;n=f[r>>2]|0;if(!n){p=11;break}else q=n}i=q}if((p|0)==8){s=i;t=i;break}else if((p|0)==11){s=i;t=r;break}}else{s=c;t=c}while(0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=s;f[t>>2]=d;s=f[f[a>>2]>>2]|0;if(!s){u=d;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}f[a>>2]=s;u=f[t>>2]|0;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}function cf(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3680;wi(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function df(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+140|0;c=f[b>>2]|0;if(c|0){d=a+144|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+128|0;b=f[g>>2]|0;if(b|0){j=a+132|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+116>>2]|0;if(l|0){g=a+120|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(l|0){m=a+108|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+92>>2]|0;if(!l){n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}g=a+96|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}function ef(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+152|0;c=f[b>>2]|0;if(c|0){d=a+156|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+140|0;b=f[g>>2]|0;if(b|0){j=a+144|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+128>>2]|0;if(l|0){g=a+132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+116>>2]|0;if(l|0){m=a+120|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(!l){n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}g=a+108|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}function ff(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3480;uj(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function gf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=u;u=u+144|0;g=e+136|0;h=e+104|0;i=e;j=ln(124)|0;k=f[c+8>>2]|0;f[j+4>>2]=0;f[j>>2]=3656;f[j+12>>2]=3636;f[j+100>>2]=0;f[j+104>>2]=0;f[j+108>>2]=0;l=j+16|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));f[j+112>>2]=k;f[j+116>>2]=d;n=j+120|0;f[n>>2]=0;o=j;f[h>>2]=3636;p=h+4|0;q=p+4|0;f[q>>2]=0;f[q+4>>2]=0;f[q+8>>2]=0;f[q+12>>2]=0;f[q+16>>2]=0;f[q+20>>2]=0;q=f[c+12>>2]|0;f[i+4>>2]=3636;f[i+92>>2]=0;f[i+96>>2]=0;f[i+100>>2]=0;l=i+8|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));l=q;f[p>>2]=l;m=((f[l+4>>2]|0)-(f[q>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;qh(h+8|0,m,g);Va[f[(f[h>>2]|0)+8>>2]&127](h);f[i>>2]=f[p>>2];fg(i+4|0,h)|0;f[i+36>>2]=q;f[i+40>>2]=d;f[i+44>>2]=k;f[i+48>>2]=j;f[n>>2]=c+72;Sg(j,i);f[a>>2]=o;Qi(i);f[h>>2]=3636;i=f[h+20>>2]|0;if(i|0)Oq(i);i=f[h+8>>2]|0;if(!i){u=e;return}Oq(i);u=e;return}function hf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+48|0;d=c+44|0;e=c+40|0;g=c+36|0;h=c+32|0;i=c;f[h>>2]=f[a+60>>2];j=b+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,h,h+4|0)|0}wn(i);tk(i);if((f[h>>2]|0)>0){k=a+56|0;l=1;m=0;do{n=l;l=(f[(f[k>>2]|0)+(m>>>5<<2)>>2]&1<<(m&31)|0)!=0;fj(i,n^l^1);m=m+1|0}while((m|0)<(f[h>>2]|0))}ld(i,b);f[g>>2]=f[a+12>>2];h=j;m=f[h>>2]|0;l=f[h+4>>2]|0;if((l|0)>0|(l|0)==0&m>>>0>0){o=l;p=m}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;m=j;o=f[m+4>>2]|0;p=f[m>>2]|0}f[g>>2]=f[a+20>>2];if((o|0)>0|(o|0)==0&p>>>0>0){Fj(i);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(i);u=c;return 1}function jf(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,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+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;f[a+52>>2]=e;f[a+44>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;l=a+48|0;m=f[l>>2]|0;f[l>>2]=g;if(m|0)Mq(m);m=a+36|0;g=f[m>>2]|0;n=f[g+4>>2]|0;o=f[g>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=i+4|0;s=j+4|0;t=h+4|0;if(n-o>>2>>>0>q>>>0){v=q;w=o}else{x=g;aq(x)}while(1){f[k>>2]=f[w+(v<<2)>>2];f[h>>2]=f[k>>2];Bc(a,h,b,v);g=X(v,e)|0;o=b+(g<<2)|0;q=f[l>>2]|0;n=c+(g<<2)|0;g=f[o+4>>2]|0;y=f[q>>2]|0;z=f[q+4>>2]|0;f[i>>2]=f[o>>2];f[r>>2]=g;f[j>>2]=y;f[s>>2]=z;Od(h,p,i,j);f[n>>2]=f[h>>2];f[n+4>>2]=f[t>>2];v=v+-1|0;if((v|0)<=-1){A=5;break}n=f[m>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function lf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=f[c>>2]|0;c=f[d>>2]|0;e=f[a+4>>2]|0;g=f[d+4>>2]|0;h=e+-1|0;i=(h&e|0)==0;if(!i)if(g>>>0>>0)j=g;else j=(g>>>0)%(e>>>0)|0;else j=h&g;g=(f[a>>2]|0)+(j<<2)|0;k=f[g>>2]|0;while(1){l=f[k>>2]|0;if((l|0)==(d|0))break;else k=l}if((k|0)!=(a+8|0)){l=f[k+4>>2]|0;if(!i)if(l>>>0>>0)m=l;else m=(l>>>0)%(e>>>0)|0;else m=l&h;if((m|0)==(j|0)){n=c;o=21}else o=13}else o=13;do if((o|0)==13){if(c|0){m=f[c+4>>2]|0;if(!i)if(m>>>0>>0)p=m;else p=(m>>>0)%(e>>>0)|0;else p=m&h;if((p|0)==(j|0)){q=c;r=c;o=22;break}}f[g>>2]=0;n=f[d>>2]|0;o=21}while(0);if((o|0)==21){g=n;if(!n)s=g;else{q=n;r=g;o=22}}if((o|0)==22){o=f[q+4>>2]|0;if(!i)if(o>>>0>>0)t=o;else t=(o>>>0)%(e>>>0)|0;else t=o&h;if((t|0)==(j|0))s=r;else{f[(f[a>>2]|0)+(t<<2)>>2]=k;s=f[d>>2]|0}}f[k>>2]=s;f[d>>2]=0;s=a+12|0;f[s>>2]=(f[s>>2]|0)+-1;if(!d)return c|0;s=d+8|0;a=f[d+20>>2]|0;if(a|0){k=d+24|0;if((f[k>>2]|0)!=(a|0))f[k>>2]=a;Oq(a)}if((b[s+11>>0]|0)<0)Oq(f[s>>2]|0);Oq(d);return c|0}function mf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;b=u;u=u+16|0;c=b+4|0;d=b;f[c>>2]=0;e=c+4|0;f[e>>2]=0;f[c+8>>2]=0;g=a+52|0;h=f[g>>2]|0;i=(f[h+100>>2]|0)-(f[h+96>>2]|0)|0;j=(i|0)/12|0;if(!i){k=0;l=0}else{i=c+8|0;m=0;n=0;o=h;h=0;p=0;while(1){q=f[o+96>>2]|0;r=f[q+(n*12|0)>>2]|0;s=r-m|0;t=((s|0)>-1?s:0-s|0)<<1|s>>>31;f[d>>2]=t;if((h|0)==(p|0)){Ri(c,d);v=f[e>>2]|0;w=f[i>>2]|0}else{f[h>>2]=t;t=h+4|0;f[e>>2]=t;v=t;w=p}t=f[q+(n*12|0)+4>>2]|0;s=t-r|0;r=((s|0)>-1?s:0-s|0)<<1|s>>>31;f[d>>2]=r;if((v|0)==(w|0)){Ri(c,d);x=f[e>>2]|0;y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me(b,d,g,g+4|0)|0;Fj(i);u=c;return 1}function of(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c+12|0;e=c+8|0;g=c+4|0;h=c;if(!b){i=ln(76)|0;j=ln(12)|0;k=f[(f[a+4>>2]|0)+80>>2]|0;f[j+4>>2]=0;f[j>>2]=3908;f[j+8>>2]=k;f[h>>2]=j;rl(i,h,0);j=i;f[g>>2]=j;i=a+12|0;k=f[i>>2]|0;if(k>>>0<(f[a+16>>2]|0)>>>0){f[g>>2]=0;f[k>>2]=j;f[i>>2]=k+4;l=g}else{Qg(a+8|0,g);l=g}g=f[l>>2]|0;f[l>>2]=0;if(g|0)Va[f[(f[g>>2]|0)+4>>2]&127](g);g=f[h>>2]|0;f[h>>2]=0;if(!g){u=c;return 1}Va[f[(f[g>>2]|0)+4>>2]&127](g);u=c;return 1}g=f[f[a+8>>2]>>2]|0;f[d>>2]=b;a=g+4|0;h=g+8|0;l=f[h>>2]|0;if((l|0)==(f[g+12>>2]|0))Ri(a,d);else{f[l>>2]=b;f[h>>2]=l+4}l=f[d>>2]|0;b=g+16|0;k=g+20|0;g=f[k>>2]|0;i=f[b>>2]|0;j=g-i>>2;m=i;if((l|0)<(j|0)){n=m;o=l}else{i=l+1|0;f[e>>2]=-1;p=g;if(i>>>0<=j>>>0)if(i>>>0>>0?(g=m+(i<<2)|0,(g|0)!=(p|0)):0){f[k>>2]=p+(~((p+-4-g|0)>>>2)<<2);q=l;r=m}else{q=l;r=m}else{Ch(b,i-j|0,e);q=f[d>>2]|0;r=f[b>>2]|0}n=r;o=q}f[n+(o<<2)>>2]=((f[h>>2]|0)-(f[a>>2]|0)>>2)+-1;u=c;return 1}function pf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;d=u;u=u+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;f[a+52>>2]=e;f[a+44>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;l=a+48|0;m=f[l>>2]|0;f[l>>2]=g;if(m|0)Mq(m);m=a+36|0;g=f[m>>2]|0;n=f[g+4>>2]|0;o=f[g>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=i+4|0;s=j+4|0;t=h+4|0;if(n-o>>2>>>0>q>>>0){v=q;w=o}else{x=g;aq(x)}while(1){f[k>>2]=f[w+(v<<2)>>2];f[h>>2]=f[k>>2];Ac(a,h,b,v);g=X(v,e)|0;o=b+(g<<2)|0;q=f[l>>2]|0;n=c+(g<<2)|0;g=f[o+4>>2]|0;y=f[q>>2]|0;z=f[q+4>>2]|0;f[i>>2]=f[o>>2];f[r>>2]=g;f[j>>2]=y;f[s>>2]=z;Od(h,p,i,j);f[n>>2]=f[h>>2];f[n+4>>2]=f[t>>2];v=v+-1|0;if((v|0)<=-1){A=5;break}n=f[m>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function qf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>3>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>3;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){o=c;p=f[o+4>>2]|0;q=m;f[q>>2]=f[o>>2];f[q+4>>2]=p;j=j+-1|0;if(!j)break;else m=m+8|0}}if(!l){m=h+(b<<3)|0;if((m|0)==(n|0))return;else{r=i;s=n+(~((n+-8-m|0)>>>3)<<3)|0;break}}else{m=b-k|0;j=m;p=n;while(1){q=c;o=f[q+4>>2]|0;t=p;f[t>>2]=f[q>>2];f[t+4>>2]=o;j=j+-1|0;if(!j)break;else p=p+8|0}r=i;s=n+(m<<3)|0;break}}else{p=g;if(!g)u=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-8-g|0)>>>3)<<3);Oq(p);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;u=0}if(b>>>0>536870911)aq(a);j=u>>2;p=u>>3>>>0<268435455?(j>>>0>>0?b:j):536870911;if(p>>>0>536870911)aq(a);j=ln(p<<3)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(p<<3);p=b;l=j;while(1){o=c;t=f[o+4>>2]|0;q=l;f[q>>2]=f[o>>2];f[q+4>>2]=t;p=p+-1|0;if(!p)break;else l=l+8|0}r=k;s=j+(b<<3)|0}while(0);f[r>>2]=s;return}function rf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,g=0.0,h=0.0,i=0.0,j=0.0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;e=+$(n[b>>2]);g=+K(+e);h=+$(n[b+4>>2]);i=g+ +K(+h);g=+$(n[b+8>>2]);j=i+ +K(+g);b=j>1.0e-06;i=1.0/j;k=f[a+12>>2]|0;j=+(k|0);l=~~+J(+((b?i*e:1.0)*j+.5));m=~~+J(+((b?i*h:0.0)*j+.5));o=(l|0)>-1;p=k-(o?l:0-l|0)-((m|0)>-1?m:0-m|0)|0;l=(p|0)<0;q=(l?((m|0)>0?p:0-p|0):0)+m|0;m=l?0:p;p=(b?i*g:0.0)<0.0?0-m|0:m;do if(!o){if((q|0)<0)r=(p|0)>-1?p:0-p|0;else r=(f[a+8>>2]|0)-((p|0)>-1?p:0-p|0)|0;if((p|0)<0){s=(q|0)>-1?q:0-q|0;t=r;break}else{s=(f[a+8>>2]|0)-((q|0)>-1?q:0-q|0)|0;t=r;break}}else{s=k+p|0;t=k+q|0}while(0);q=(t|0)==0;p=(s|0)==0;r=f[a+8>>2]|0;if(!(s|t)){u=r;v=r;f[c>>2]=u;f[d>>2]=v;return}a=(r|0)==(s|0);if(q&a){u=s;v=s;f[c>>2]=u;f[d>>2]=v;return}o=(r|0)==(t|0);if(p&o){u=t;v=t;f[c>>2]=u;f[d>>2]=v;return}if(q&(k|0)<(s|0)){u=0;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(o&(k|0)>(s|0)){u=t;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(a&(k|0)>(t|0)){u=(k<<1)-t|0;v=s;f[c>>2]=u;f[d>>2]=v;return}if(!p){u=t;v=s;f[c>>2]=u;f[d>>2]=v;return}u=(k|0)<(t|0)?(k<<1)-t|0:t;v=0;f[c>>2]=u;f[d>>2]=v;return}function sf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|0)|0;m=i}else m=i;if(!(f[d>>2]|0)){u=g;return 1}d=a+12|0;Gg(d);m=a+1068|0;Mm(m);k=a+1088|0;Mm(k);l=a+1108|0;Mm(l);f[i>>2]=f[b>>2];f[i+4>>2]=f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4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073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(q)if(q>>>0>1073741823){p=ra(8)|0;Oo(p,16035);f[p>>2]=7256;va(p|0,1112,110)}else{r=ln(q<<2)|0;break}else r=0;while(0);f[d>>2]=r;p=r+(l<<2)|0;l=d+8|0;m=d+4|0;f[m>>2]=p;o=r+(q<<2)|0;q=d+12|0;f[q>>2]=o;r=p+(b<<2)|0;sj(p|0,0,b<<2|0)|0;f[l>>2]=r;if((j|0)==(n|0)){s=p;t=q;v=l;w=k;x=r;y=i;z=o;A=g}else{g=j;j=p;do{g=g+-4|0;p=f[g>>2]|0;f[g>>2]=0;f[j+-4>>2]=p;j=(f[m>>2]|0)+-4|0;f[m>>2]=j}while((g|0)!=(n|0));s=j;t=q;v=l;w=f[a>>2]|0;x=f[l>>2]|0;y=f[h>>2]|0;z=f[q>>2]|0;A=f[e>>2]|0}f[a>>2]=s;f[m>>2]=w;f[h>>2]=x;f[v>>2]=y;f[e>>2]=z;f[t>>2]=A;f[d>>2]=w;ki(d);u=c;return}function vf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function wf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+112|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+116|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function xf(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=u;u=u+16|0;h=d;i=f[a+124>>2]|0;if(!i){u=d;return}j=i+-1|0;k=(j&i|0)==0;if(!k)if(i>>>0>g>>>0)l=g;else l=(g>>>0)%(i>>>0)|0;else l=j&g;m=f[(f[a+120>>2]|0)+(l<<2)>>2]|0;if(!m){u=d;return}n=f[m>>2]|0;if(!n){u=d;return}a:do if(k){m=n;while(1){o=f[m+4>>2]|0;p=(o|0)==(g|0);if(!(p|(o&j|0)==(l|0))){q=24;break}if(p?(f[m+8>>2]|0)==(g|0):0){r=m;break a}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}else{m=n;while(1){p=f[m+4>>2]|0;if((p|0)==(g|0)){if((f[m+8>>2]|0)==(g|0)){r=m;break a}}else{if(p>>>0>>0)s=p;else s=(p>>>0)%(i>>>0)|0;if((s|0)!=(l|0)){q=24;break}}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}while(0);q=f[r+12>>2]|0;if((q|0)==-1){u=d;return}f[h>>2]=q;f[h+4>>2]=c;b[h+8>>0]=e&1;e=a+112|0;c=f[e>>2]|0;if((c|0)==(f[a+116>>2]|0))yi(a+108|0,h);else{f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];f[c+8>>2]=f[h+8>>2];f[e>>2]=(f[e>>2]|0)+12}u=d;return}function yf(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=d[b>>1]|0;e=d[b+2>>1]|0;g=d[b+4>>1]|0;h=d[b+6>>1]|0;b=((((c^318)&65535)+239^e&65535)+239^g&65535)+239^h&65535;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(b>>>0>>0)m=b;else m=(b>>>0)%(i>>>0)|0;else m=b&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(b|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(d[o>>1]|0)==c<<16>>16):0)?(d[o+2>>1]|0)==e<<16>>16:0)?(d[l+12>>1]|0)==g<<16>>16:0)?(d[o+6>>1]|0)==h<<16>>16:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(b|0)){l=q+8|0;if((((d[l>>1]|0)==c<<16>>16?(d[l+2>>1]|0)==e<<16>>16:0)?(d[q+12>>1]|0)==g<<16>>16:0)?(d[l+6>>1]|0)==h<<16>>16:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function zf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[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2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];lb(a,i,h);ld(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function Bf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;a=u;u=u+16|0;e=a+4|0;g=a;h=a+8|0;i=d+11|0;j=b[i>>0]|0;k=j<<24>>24<0;if(k){l=f[d+4>>2]|0;if(l>>>0>255){m=0;u=a;return m|0}else n=l}else n=j&255;if(!n){b[h>>0]=0;n=c+16|0;l=f[n+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}m=1;u=a;return m|0}n=d+4|0;l=f[n>>2]|0;b[h>>0]=k?l:j&255;k=c+16|0;o=k;p=f[o>>2]|0;q=f[o+4>>2]|0;if((q|0)>0|(q|0)==0&p>>>0>0){r=j;s=q;t=p;v=l}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;h=k;r=b[i>>0]|0;s=f[h+4>>2]|0;t=f[h>>2]|0;v=f[n>>2]|0}n=r<<24>>24<0;h=n?f[d>>2]|0:d;if(!((s|0)>0|(s|0)==0&t>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+(n?v:r&255)|0)|0}m=1;u=a;return m|0}function Cf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+4|0;d=f[a>>2]|0;e=((f[c>>2]|0)-d|0)/24|0;g=e+1|0;if(g>>>0>178956970)aq(a);h=a+8|0;i=((f[h>>2]|0)-d|0)/24|0;d=i<<1;j=i>>>0<89478485?(d>>>0>>0?g:d):178956970;do if(j)if(j>>>0>178956970){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j*24|0)|0;break}else k=0;while(0);d=k+(e*24|0)|0;g=d;i=k+(j*24|0)|0;f[d>>2]=1196;f[k+(e*24|0)+4>>2]=f[b+4>>2];fk(k+(e*24|0)+8|0,b+8|0);f[k+(e*24|0)+20>>2]=f[b+20>>2];b=d+24|0;e=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(e|0)){l=g;m=e;n=e}else{j=k;k=g;g=d;do{f[g+-24>>2]=1196;f[g+-20>>2]=f[j+-20>>2];d=g+-16|0;o=j+-16|0;f[d>>2]=0;p=g+-12|0;f[p>>2]=0;f[g+-8>>2]=0;f[d>>2]=f[o>>2];d=j+-12|0;f[p>>2]=f[d>>2];p=j+-8|0;f[g+-8>>2]=f[p>>2];f[p>>2]=0;f[d>>2]=0;f[o>>2]=0;f[g+-4>>2]=f[j+-4>>2];j=j+-24|0;g=k+-24|0;k=g}while((j|0)!=(e|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=b;f[h>>2]=i;i=m;if((n|0)!=(i|0)){h=n;do{h=h+-24|0;Va[f[f[h>>2]>>2]&127](h)}while((h|0)!=(i|0))}if(!m)return;Oq(m);return}function Df(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+32|0;d=c+24|0;e=c+16|0;g=c+8|0;h=c;f[a>>2]=3588;f[a+4>>2]=f[b+4>>2];i=a+8|0;j=b+8|0;f[i>>2]=0;k=a+12|0;f[k>>2]=0;l=a+16|0;f[l>>2]=0;m=b+12|0;n=f[m>>2]|0;do if(n|0)if((n|0)<0)aq(i);else{o=((n+-1|0)>>>5)+1|0;p=ln(o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;f[g>>2]=o;f[g+4>>2]=0;p=f[m>>2]|0;f[h>>2]=o+(p>>>5<<2);f[h+4>>2]=p&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);break}while(0);i=a+20|0;f[i>>2]=0;m=a+24|0;f[m>>2]=0;j=a+28|0;f[j>>2]=0;a=b+24|0;l=f[a>>2]|0;if(!l){u=c;return}if((l|0)<0)aq(i);k=((l+-1|0)>>>5)+1|0;l=ln(k<<2)|0;f[i>>2]=l;f[m>>2]=0;f[j>>2]=k;k=f[b+20>>2]|0;f[g>>2]=k;f[g+4>>2]=0;b=f[a>>2]|0;f[h>>2]=k+(b>>>5<<2);f[h+4>>2]=b&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);u=c;return}function Ef(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;h=b[c+3>>0]|0;c=(((d&255^318)+239^e&255)+239^g&255)+239^h&255;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(c>>>0>>0)m=c;else m=(c>>>0)%(i>>>0)|0;else m=c&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(c|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(b[o>>0]|0)==d<<24>>24):0)?(b[o+1>>0]|0)==e<<24>>24:0)?(b[o+2>>0]|0)==g<<24>>24:0)?(b[o+3>>0]|0)==h<<24>>24:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(c|0)){l=q+8|0;if((((b[l>>0]|0)==d<<24>>24?(b[l+1>>0]|0)==e<<24>>24:0)?(b[l+2>>0]|0)==g<<24>>24:0)?(b[l+3>>0]|0)==h<<24>>24:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function Ff(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+32|0;d=c+24|0;e=c+16|0;g=c+8|0;h=c;f[a>>2]=3636;f[a+4>>2]=f[b+4>>2];i=a+8|0;j=b+8|0;f[i>>2]=0;k=a+12|0;f[k>>2]=0;l=a+16|0;f[l>>2]=0;m=b+12|0;n=f[m>>2]|0;do if(n|0)if((n|0)<0)aq(i);else{o=((n+-1|0)>>>5)+1|0;p=ln(o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;f[g>>2]=o;f[g+4>>2]=0;p=f[m>>2]|0;f[h>>2]=o+(p>>>5<<2);f[h+4>>2]=p&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);break}while(0);i=a+20|0;f[i>>2]=0;m=a+24|0;f[m>>2]=0;j=a+28|0;f[j>>2]=0;a=b+24|0;l=f[a>>2]|0;if(!l){u=c;return}if((l|0)<0)aq(i);k=((l+-1|0)>>>5)+1|0;l=ln(k<<2)|0;f[i>>2]=l;f[m>>2]=0;f[j>>2]=k;k=f[b+20>>2]|0;f[g>>2]=k;f[g+4>>2]=0;b=f[a>>2]|0;f[h>>2]=k+(b>>>5<<2);f[h+4>>2]=b&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);u=c;return}function Gf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;d=u;u=u+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;l=a+40|0;f[a+44>>2]=g;g=a+36|0;m=f[g>>2]|0;n=f[m+4>>2]|0;o=f[m>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=a+48|0;s=a+52|0;a=i+4|0;t=j+4|0;v=h+4|0;if(n-o>>2>>>0>q>>>0){w=q;x=o}else{y=m;aq(y)}while(1){f[k>>2]=f[x+(w<<2)>>2];f[h>>2]=f[k>>2];ub(l,h,b,w);m=X(w,e)|0;o=b+(m<<2)|0;q=c+(m<<2)|0;m=f[o+4>>2]|0;n=f[r>>2]|0;z=f[s>>2]|0;f[i>>2]=f[o>>2];f[a>>2]=m;f[j>>2]=n;f[t>>2]=z;Od(h,p,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Hf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;Cd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;Ad(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function If(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;d=u;u=u+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;l=a+40|0;f[a+44>>2]=g;g=a+36|0;m=f[g>>2]|0;n=f[m+4>>2]|0;o=f[m>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=a+48|0;s=a+52|0;a=i+4|0;t=j+4|0;v=h+4|0;if(n-o>>2>>>0>q>>>0){w=q;x=o}else{y=m;aq(y)}while(1){f[k>>2]=f[x+(w<<2)>>2];f[h>>2]=f[k>>2];tb(l,h,b,w);m=X(w,e)|0;o=b+(m<<2)|0;q=c+(m<<2)|0;m=f[o+4>>2]|0;n=f[r>>2]|0;z=f[s>>2]|0;f[i>>2]=f[o>>2];f[a>>2]=m;f[j>>2]=n;f[t>>2]=z;Od(h,p,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Jf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=f[b>>2]|0;b=f[c>>2]|0;e=b-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;k=b;if(e>>>0<=h-i>>2>>>0){l=a+4|0;m=(f[l>>2]|0)-i>>2;n=e>>>0>m>>>0;o=n?d+(m<<2)|0:b;b=o-d|0;m=b>>2;if(m|0)im(i|0,d|0,b|0)|0;b=j+(m<<2)|0;if(!n){n=f[l>>2]|0;if((n|0)==(b|0))return;f[l>>2]=n+(~((n+-4-b|0)>>>2)<<2);return}b=f[c>>2]|0;c=o;if((b|0)==(c|0))return;n=f[l>>2]|0;m=b+-4-o|0;o=c;c=n;while(1){f[c>>2]=f[o>>2];o=o+4|0;if((o|0)==(b|0))break;else c=c+4|0}f[l>>2]=n+((m>>>2)+1<<2);return}m=i;if(!i)p=h;else{h=a+4|0;n=f[h>>2]|0;if((n|0)!=(j|0))f[h>>2]=n+(~((n+-4-i|0)>>>2)<<2);Oq(m);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;p=0}if(e>>>0>1073741823)aq(a);h=p>>1;m=p>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(m>>>0>1073741823)aq(a);h=ln(m<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(m<<2);m=d;if((k|0)==(m|0))return;g=k+-4-d|0;d=m;m=h;while(1){f[m>>2]=f[d>>2];d=d+4|0;if((d|0)==(k|0))break;else m=m+4|0}f[e>>2]=h+((g>>>2)+1<<2);return}function Kf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(((d-g|0)/12|0)>>>0>=b>>>0){sj(g|0,0,b*12|0)|0;f[e>>2]=h+(b*12|0);return}i=f[a>>2]|0;j=(g-i|0)/12|0;g=j+b|0;k=i;if(g>>>0>357913941)aq(a);l=(d-i|0)/12|0;d=l<<1;m=l>>>0<178956970?(d>>>0>>0?g:d):357913941;do if(m)if(m>>>0>357913941){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m*12|0)|0;break}else n=0;while(0);d=n+(j*12|0)|0;j=d;g=n+(m*12|0)|0;sj(d|0,0,b*12|0)|0;m=d+(b*12|0)|0;if((h|0)==(k|0)){o=j;p=i;q=h}else{i=h;h=j;j=d;do{d=j+-12|0;b=i;i=i+-12|0;f[d>>2]=0;n=j+-8|0;f[n>>2]=0;f[j+-4>>2]=0;f[d>>2]=f[i>>2];d=b+-8|0;f[n>>2]=f[d>>2];n=b+-4|0;f[j+-4>>2]=f[n>>2];f[n>>2]=0;f[d>>2]=0;f[i>>2]=0;j=h+-12|0;h=j}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=g;g=p;if((q|0)!=(g|0)){c=q;do{q=c;c=c+-12|0;m=f[c>>2]|0;if(m|0){e=q+-8|0;q=f[e>>2]|0;if((q|0)!=(m|0))f[e>>2]=q+(~((q+-4-m|0)>>>2)<<2);Oq(m)}}while((c|0)!=(g|0))}if(!p)return;Oq(p);return}function Lf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+100|0;h=f[e>>2]|0;i=(f[h+28>>2]|0)-(f[h+24>>2]|0)>>2;f[c>>2]=0;h=a+104|0;j=f[h>>2]|0;k=f[g>>2]|0;l=j-k>>2;m=k;k=j;if(i>>>0<=l>>>0){if(i>>>0>>0?(j=m+(i<<2)|0,(j|0)!=(k|0)):0)f[h>>2]=k+(~((k+-4-j|0)>>>2)<<2)}else Ch(g,i-l|0,c);l=a+120|0;a=f[l>>2]|0;if(!a){i=f[e>>2]|0;g=(f[i+4>>2]|0)-(f[i>>2]|0)>>2;i=(g>>>0)/3|0;if(g>>>0<=2){u=b;return 1}g=0;do{f[d>>2]=g*3;f[c>>2]=f[d>>2];wb(e,c);g=g+1|0}while((g|0)<(i|0));u=b;return 1}else{i=f[a>>2]|0;if((f[a+4>>2]|0)==(i|0)){u=b;return 1}a=0;g=i;do{f[d>>2]=f[g+(a<<2)>>2];f[c>>2]=f[d>>2];wb(e,c);a=a+1|0;i=f[l>>2]|0;g=f[i>>2]|0}while(a>>>0<(f[i+4>>2]|0)-g>>2>>>0);u=b;return 1}return 0}function Mf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-4194304|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-4177920|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+4194304|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1077936128|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Nf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-2097152|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-2080768|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+6291456|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1075838976|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Of(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-1048576|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1032192|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+7340032|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074790400|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Pf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<1,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<1)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Qf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<2,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<2)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Rf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-262144|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-245760|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8126464|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074003968|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Sf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-131072|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-114688|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8257536|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073872896|0;b[m>>0]=n;b[m+1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&-1<>2]=f[l>>2]&~e|f[n>>2]&e;e=p+o|0;b=n+4|0;r=j-p|0;s=e&31;t=l+(e>>>5<<2)|0;v=b;w=b}b=(r|0)/32|0;im(t|0,v|0,b<<2|0)|0;v=r-(b<<5)|0;r=t+(b<<2)|0;t=r;if((v|0)>0){e=-1>>>(32-v|0);f[r>>2]=f[r>>2]&~e|f[w+(b<<2)>>2]&e;x=v;y=t}else{x=s;y=t}}else{x=o;y=m}f[k>>2]=y;f[k+4>>2]=x;u=d;return}function Uf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-32768|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-16384|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8355840|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073774592|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Vf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;g=f[b+12>>2]|0;b=(((c^318)+239^d)+239^e)+239^g;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=25;break}if((((n?(f[k+8>>2]|0)==(c|0):0)?(f[k+12>>2]|0)==(d|0):0)?(f[k+16>>2]|0)==(e|0):0)?(f[k+20>>2]|0)==(g|0):0){i=k;o=25;break}k=f[k>>2]|0;if(!k){i=0;o=25;break}}if((o|0)==25)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){if((((f[p+8>>2]|0)==(c|0)?(f[p+12>>2]|0)==(d|0):0)?(f[p+16>>2]|0)==(e|0):0)?(f[p+20>>2]|0)==(g|0):0){i=p;o=25;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=25;break}}p=f[p>>2]|0;if(!p){i=0;o=25;break}}if((o|0)==25)return i|0;return 0}function Wf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+(X(d,g)|0)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Xf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;qd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;pd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function Yf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=f[d>>2]|0;g=f[d+4>>2]|0;if((e|0)==(g|0)){h=0;i=a+12|0;j=a+8|0}else{d=f[c>>2]|0;c=a+8|0;k=a+12|0;a=0;l=e;while(1){e=f[l>>2]|0;m=f[d+(e<<2)>>2]|0;if(m>>>0>>0)n=a;else{o=f[c>>2]|0;p=(f[k>>2]|0)-o|0;q=o;if((p|0)>0){o=p>>>2;p=0;do{r=f[q+(p<<2)>>2]|0;s=f[r+68>>2]|0;if(!(b[r+84>>0]|0))t=f[s+(e<<2)>>2]|0;else t=e;f[s+(m<<2)>>2]=t;p=p+1|0}while((p|0)<(o|0))}n=m+1|0}l=l+4|0;if((l|0)==(g|0)){h=n;i=k;j=c;break}else a=n}}n=f[i>>2]|0;a=f[j>>2]|0;if((n-a|0)>0){u=0;v=a;w=n}else return;while(1){n=f[v+(u<<2)>>2]|0;b[n+84>>0]=0;a=n+68|0;c=n+72|0;n=f[c>>2]|0;k=f[a>>2]|0;g=n-k>>2;l=k;k=n;if(h>>>0<=g>>>0)if(h>>>0>>0?(n=l+(h<<2)|0,(n|0)!=(k|0)):0){f[c>>2]=k+(~((k+-4-n|0)>>>2)<<2);x=v;y=w}else{x=v;y=w}else{Ch(a,h-g|0,6220);x=f[j>>2]|0;y=f[i>>2]|0}u=u+1|0;if((u|0)>=(y-x>>2|0))break;else{v=x;w=y}}return}function Zf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=((c+-4-o|0)>>>2)+1|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+(p<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=((c+-4-d|0)>>>2)+1|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+(p<<2);return}function _f(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-16384|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;b[m>>0]=j;b[m+1>>0]=j>>>8;n=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;o=j+8372224|0;b[m>>0]=o;b[m+1>>0]=o>>>8;b[m+2>>0]=o>>>16;n=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;o=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+-1073758208|0;b[o>>0]=m;b[o+1>>0]=m>>>8;b[o+2>>0]=m>>>16;b[o+3>>0]=m>>>24;n=(f[l>>2]|0)+4|0;break}else{n=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;n=(f[l>>2]|0)+1|0}while(0);k=((n|0)<0)<<31>>31;Gn(e);yh(n,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,n|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,n|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function $f(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=c+-4-o|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+((p>>>2)+1<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=c+-4-d|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+((p>>>2)+1<<2);return}function ag(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0;g=u;u=u+80|0;h=g;i=g+64|0;Il(h);j=f[(f[a+8>>2]|0)+56>>2]|0;k=X(Vl(5)|0,d)|0;Jj(h,j,0,d&255,5,0,k,((k|0)<0)<<31>>31,0,0);k=ln(96)|0;tl(k,h);Bj(k,c)|0;f[i>>2]=k;gj(a,i);k=f[i>>2]|0;f[i>>2]=0;if(k|0){i=k+88|0;c=f[i>>2]|0;f[i>>2]=0;if(c|0){i=f[c+8>>2]|0;if(i|0){h=c+12|0;if((f[h>>2]|0)!=(i|0))f[h>>2]=i;Oq(i)}Oq(c)}c=f[k+68>>2]|0;if(c|0){i=k+72|0;h=f[i>>2]|0;if((h|0)!=(c|0))f[i>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=k+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){i=h+4|0;if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c)}Oq(h)}Oq(k)}if(!e){u=g;return}k=f[a+32>>2]|0;b[k+84>>0]=0;a=k+68|0;h=k+72|0;k=f[h>>2]|0;c=f[a>>2]|0;i=k-c>>2;d=k;if(i>>>0>>0){Ch(a,e-i|0,1532);u=g;return}if(i>>>0<=e>>>0){u=g;return}i=c+(e<<2)|0;if((i|0)==(d|0)){u=g;return}f[h>>2]=d+(~((d+-4-i|0)>>>2)<<2);u=g;return}function bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+16|0;d=c+4|0;e=c;g=a+4|0;h=f[g>>2]|0;i=a+8|0;j=f[i>>2]|0;if((j|0)==(h|0))k=h;else{l=j+(~((j+-4-h|0)>>>2)<<2)|0;f[i>>2]=l;k=l}l=a+16|0;h=f[l>>2]|0;j=a+20|0;m=f[j>>2]|0;n=h;if((m|0)!=(h|0))f[j>>2]=m+(~((m+-4-n|0)>>>2)<<2);m=f[b>>2]|0;h=f[b+4>>2]|0;if((m|0)==(h|0)){u=c;return}b=a+12|0;a=m;m=k;k=n;while(1){n=f[a>>2]|0;f[d>>2]=n;if((m|0)==(f[b>>2]|0)){Ri(g,d);o=f[l>>2]|0}else{f[m>>2]=n;f[i>>2]=m+4;o=k}n=f[d>>2]|0;p=f[j>>2]|0;q=p-o>>2;r=o;if((n|0)<(q|0)){s=r;t=n;v=o}else{w=n+1|0;f[e>>2]=-1;x=p;if(w>>>0<=q>>>0)if(w>>>0>>0?(p=r+(w<<2)|0,(p|0)!=(x|0)):0){f[j>>2]=x+(~((x+-4-p|0)>>>2)<<2);y=n;z=r;A=o}else{y=n;z=r;A=o}else{Ch(l,w-q|0,e);q=f[l>>2]|0;y=f[d>>2]|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=d[b+2>>1]|0;g=d[b+4>>1]|0;b=(((c^318)&65535)+239^e&65535)+239^g&65535;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(d[n>>1]|0)==c<<16>>16):0)?(d[n+2>>1]|0)==e<<16>>16:0)?(d[k+12>>1]|0)==g<<16>>16:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){k=p+8|0;if(((d[k>>1]|0)==c<<16>>16?(d[k+2>>1]|0)==e<<16>>16:0)?(d[p+12>>1]|0)==g<<16>>16:0){i=p;o=23;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=23;break}}p=f[p>>2]|0;if(!p){i=0;o=23;break}}if((o|0)==23)return i|0;return 0}function eg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=u;u=u+32|0;d=c;e=a+16|0;g=e;h=f[g>>2]|0;i=f[g+4>>2]|0;if(!((i|0)>0|(i|0)==0&h>>>0>0)){u=c;return}g=Vn(f[(f[a+12>>2]|0)+4>>2]|0,0,7,0)|0;j=Yn(g|0,I|0,3)|0;g=I;if(!(b[a+24>>0]|0)){k=a+4|0;l=k;m=k;n=h;o=i}else{k=f[a>>2]|0;p=a+4|0;q=k+((f[p>>2]|0)-k)|0;k=Vn(h|0,i|0,8,0)|0;i=q+(0-k)|0;f[d>>2]=0;f[d+4>>2]=0;f[d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24|0;b=f[m>>2]|0;if(!b)o=0;else{d=a+28|0;do if(b>>>0>f[d>>2]<<5>>>0){n=f[h>>2]|0;if(!n)p=b;else{Oq(n);f[h>>2]=0;f[d>>2]=0;f[a+24>>2]=0;p=f[m>>2]|0}if((p|0)<0)aq(h);else{n=((p+-1|0)>>>5)+1|0;c=ln(n<<2)|0;f[h>>2]=c;f[a+24>>2]=0;f[d>>2]=n;q=f[m>>2]|0;r=c;break}}else{q=b;r=f[h>>2]|0}while(0);im(r|0,f[e>>2]|0,((q+-1|0)>>>5<<2)+4|0)|0;o=f[m>>2]|0}f[a+24>>2]=o;return a|0}function gg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f[c>>2]=1;d=a+4|0;e=c+8|0;g=c+12|0;c=f[e>>2]|0;i=(f[g>>2]|0)-c|0;if(i>>>0<4294967292){Lk(e,i+4|0,0);j=f[e>>2]|0}else j=c;c=j+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[c>>0]=i;b[c+1>>0]=i>>8;b[c+2>>0]=i>>16;b[c+3>>0]=i>>24;i=a+8|0;c=a+12|0;d=f[i>>2]|0;if((f[c>>2]|0)!=(d|0)){j=0;k=d;do{d=k+(j<<2)|0;l=f[e>>2]|0;m=(f[g>>2]|0)-l|0;if(m>>>0<4294967292){Lk(e,m+4|0,0);n=f[e>>2]|0}else n=l;l=n+m|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;j=j+1|0;k=f[i>>2]|0}while(j>>>0<(f[c>>2]|0)-k>>2>>>0)}k=a+20|0;a=f[e>>2]|0;c=(f[g>>2]|0)-a|0;if(c>>>0<4294967292){Lk(e,c+4|0,0);o=f[e>>2]|0;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}else{o=a;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}}function hg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>2>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>2;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){f[m>>2]=f[c>>2];j=j+-1|0;if(!j)break;else m=m+4|0}}if(!l){m=h+(b<<2)|0;if((m|0)==(n|0))return;else{o=i;p=n+(~((n+-4-m|0)>>>2)<<2)|0;break}}else{m=b-k|0;j=m;q=n;while(1){f[q>>2]=f[c>>2];j=j+-1|0;if(!j)break;else q=q+4|0}o=i;p=n+(m<<2)|0;break}}else{q=g;if(!g)r=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(q);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;r=0}if(b>>>0>1073741823)aq(a);j=r>>1;q=r>>2>>>0<536870911?(j>>>0>>0?b:j):1073741823;if(q>>>0>1073741823)aq(a);j=ln(q<<2)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(q<<2);q=b;l=j;while(1){f[l>>2]=f[c>>2];q=q+-1|0;if(!q)break;else l=l+4|0}o=k;p=j+(b<<2)|0}while(0);f[o>>2]=p;return}function ig(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=jh(a,b,c,d,g)|0;i=f[e>>2]|0;j=f[d>>2]|0;k=f[g>>2]|0;g=f[k>>2]|0;l=(f[k+4>>2]|0)-g>>3;if(l>>>0<=i>>>0)aq(k);m=g;if(l>>>0<=j>>>0)aq(k);if((f[m+(i<<3)>>2]|0)>>>0>=(f[m+(j<<3)>>2]|0)>>>0){n=h;return n|0}f[d>>2]=i;f[e>>2]=j;j=f[d>>2]|0;e=f[c>>2]|0;if(l>>>0<=j>>>0)aq(k);if(l>>>0<=e>>>0)aq(k);if((f[m+(j<<3)>>2]|0)>>>0>=(f[m+(e<<3)>>2]|0)>>>0){n=h+1|0;return n|0}f[c>>2]=j;f[d>>2]=e;e=f[c>>2]|0;d=f[b>>2]|0;if(l>>>0<=e>>>0)aq(k);if(l>>>0<=d>>>0)aq(k);if((f[m+(e<<3)>>2]|0)>>>0>=(f[m+(d<<3)>>2]|0)>>>0){n=h+2|0;return n|0}f[b>>2]=e;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(l>>>0<=d>>>0)aq(k);if(l>>>0<=c>>>0)aq(k);if((f[m+(d<<3)>>2]|0)>>>0>=(f[m+(c<<3)>>2]|0)>>>0){n=h+3|0;return n|0}f[a>>2]=d;f[b>>2]=c;n=h+4|0;return n|0}function jg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;c=((d&255^318)+239^e&255)+239^g&255;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(c>>>0>>0)l=c;else l=(c>>>0)%(h>>>0)|0;else l=c&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(c|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(b[n>>0]|0)==d<<24>>24):0)?(b[n+1>>0]|0)==e<<24>>24:0)?(b[n+2>>0]|0)==g<<24>>24:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(c|0)){k=p+8|0;if(((b[k>>0]|0)==d<<24>>24?(b[k+1>>0]|0)==e<<24>>24:0)?(b[k+2>>0]|0)==g<<24>>24:0){i=p;o=23;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=23;break}}p=f[p>>2]|0;if(!p){i=0;o=23;break}}if((o|0)==23)return i|0;return 0}function kg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;b=u;u=u+16|0;c=b;d=a+36|0;e=a+4|0;g=a+8|0;h=(f[g>>2]|0)-(f[e>>2]|0)>>2;i=a+40|0;j=f[i>>2]|0;k=f[d>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0){if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){m=k;do{k=m+-4|0;f[i>>2]=k;n=f[k>>2]|0;f[k>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);m=f[i>>2]|0}while((m|0)!=(j|0))}}else Eg(d,h-l|0);if((f[g>>2]|0)==(f[e>>2]|0)){o=1;u=b;return o|0}l=a+52|0;h=a+48|0;j=0;while(1){Xa[f[(f[a>>2]|0)+56>>2]&15](c,a,j);m=(f[d>>2]|0)+(j<<2)|0;i=f[c>>2]|0;f[c>>2]=0;n=f[m>>2]|0;f[m>>2]=i;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[c>>2]|0;f[c>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[(f[d>>2]|0)+(j<<2)>>2]|0;if(!n){o=0;p=19;break}if(j>>>0<(f[l>>2]|0)>>>0?f[(f[h>>2]|0)+(j>>>5<<2)>>2]&1<<(j&31)|0:0)Bp(n);j=j+1|0;if(j>>>0>=(f[g>>2]|0)-(f[e>>2]|0)>>2>>>0){o=1;p=19;break}}if((p|0)==19){u=b;return o|0}return 0}function lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d+4|0;g=d;ci(f[c+12>>2]|0,b)|0;h=f[c+8>>2]|0;a:do if(h|0){i=b+16|0;j=b+4|0;k=h;while(1){l=k;if(!(Bf(0,b,l+8|0)|0)){m=0;break}n=l+20|0;o=(f[l+24>>2]|0)-(f[n>>2]|0)|0;ci(o,b)|0;l=f[n>>2]|0;n=i;p=f[n+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[j>>2];f[e>>2]=f[g>>2];Me(b,e,l,l+o|0)|0}k=f[k>>2]|0;if(!k)break a}u=d;return m|0}while(0);ci(f[c+32>>2]|0,b)|0;e=f[c+28>>2]|0;if(!e){m=1;u=d;return m|0}else q=e;while(1){e=q;if(!(Bf(0,b,e+8|0)|0)){m=0;r=10;break}lg(a,b,f[e+20>>2]|0)|0;q=f[q>>2]|0;if(!q){m=1;r=10;break}}if((r|0)==10){u=d;return m|0}return 0}function mg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+8|0;i=a+12|0;j=f[h>>2]|0;if((f[i>>2]|0)==(j|0)){k=ln(76)|0;vn(k,b);l=k;f[g>>2]=l;k=f[i>>2]|0;if(k>>>0<(f[a+16>>2]|0)>>>0){f[g>>2]=0;f[k>>2]=l;f[i>>2]=k+4;m=g}else{Qg(h,g);m=g}g=f[m>>2]|0;f[m>>2]=0;if(!g){u=c;return 1}Va[f[(f[g>>2]|0)+4>>2]&127](g);u=c;return 1}g=f[j>>2]|0;f[d>>2]=b;j=g+4|0;m=g+8|0;h=f[m>>2]|0;if((h|0)==(f[g+12>>2]|0))Ri(j,d);else{f[h>>2]=b;f[m>>2]=h+4}h=f[d>>2]|0;b=g+16|0;k=g+20|0;g=f[k>>2]|0;i=f[b>>2]|0;l=g-i>>2;a=i;if((h|0)<(l|0)){n=a;o=h}else{i=h+1|0;f[e>>2]=-1;p=g;if(i>>>0<=l>>>0)if(i>>>0>>0?(g=a+(i<<2)|0,(g|0)!=(p|0)):0){f[k>>2]=p+(~((p+-4-g|0)>>>2)<<2);q=h;r=a}else{q=h;r=a}else{Ch(b,i-l|0,e);q=f[d>>2]|0;r=f[b>>2]|0}n=r;o=q}f[n+(o<<2)>>2]=((f[m>>2]|0)-(f[j>>2]|0)>>2)+-1;u=c;return 1}function ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0>j-k>>2>>>0){m=k;if(!k)n=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(m);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;n=0}if(h>>>0>1073741823)aq(a);j=n>>1;m=n>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(m>>>0>1073741823)aq(a);j=ln(m<<2)|0;n=a+4|0;f[n>>2]=j;f[a>>2]=j;f[i>>2]=j+(m<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[n>>2]=j+(g>>>2<<2);return}g=a+4|0;a=f[g>>2]|0;j=a-k>>2;k=h>>>0>j>>>0;h=k?b+(j<<2)|0:c;c=a;j=a;if((h|0)==(b|0))p=l;else{a=h+-4-e|0;e=b;b=l;while(1){f[b>>2]=f[e>>2];e=e+4|0;if((e|0)==(h|0))break;else b=b+4|0}p=l+((a>>>2)+1<<2)|0}if(k){k=d-h|0;if((k|0)<=0)return;kh(j|0,h|0,k|0)|0;f[g>>2]=(f[g>>2]|0)+(k>>>2<<2);return}else{if((p|0)==(c|0))return;f[g>>2]=c+(~((c+-4-p|0)>>>2)<<2);return}}function og(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=c+68|0;c=f[o+96>>2]|0;o=f[d+28>>2]|0;d=f[(f[a+80>>2]|0)+12>>2]|0;a=0;while(1){h=a*3|0;i=f[d+(f[o+(h<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}g=f[m>>2]|0;f[g+(f[c+(a*12|0)>>2]<<2)>>2]=i;i=f[d+(f[o+(h+1<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+4>>2]<<2)>>2]=i;i=f[d+(f[o+(h+2<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+8>>2]<<2)>>2]=i;a=a+1|0;if(a>>>0>=e>>>0){q=1;r=10;break}}if((r|0)==10)return q|0;return 0}function pg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=u;u=u+16|0;g=e;if(!(xh(a,c,d)|0)){h=0;u=e;return h|0}if((b[(f[a+8>>2]|0)+24>>0]|0)!=3){h=0;u=e;return h|0}i=f[c+48>>2]|0;c=ln(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=17;j=c;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[c+17>>0]=0;c=i+16|0;k=f[c>>2]|0;if(k){j=c;l=k;a:while(1){k=l;while(1){if((f[k+16>>2]|0)>=(d|0))break;m=f[k+4>>2]|0;if(!m){n=j;break a}else k=m}l=f[k>>2]|0;if(!l){n=k;break}else j=k}if(((n|0)!=(c|0)?(f[n+16>>2]|0)<=(d|0):0)?(d=n+20|0,(Jh(d,g)|0)!=0):0)o=Hk(d,g,-1)|0;else p=12}else p=12;if((p|0)==12)o=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((o|0)<1){h=0;u=e;return h|0}ip(a+40|0,o);h=1;u=e;return h|0}function qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;b=((c^318)+239^d)+239^e;g=f[a+4>>2]|0;if(!g){h=0;return h|0}i=g+-1|0;j=(i&g|0)==0;if(!j)if(b>>>0>>0)k=b;else k=(b>>>0)%(g>>>0)|0;else k=b&i;l=f[(f[a>>2]|0)+(k<<2)>>2]|0;if(!l){h=0;return h|0}a=f[l>>2]|0;if(!a){h=0;return h|0}if(j){j=a;while(1){l=f[j+4>>2]|0;m=(l|0)==(b|0);if(!(m|(l&i|0)==(k|0))){h=0;n=23;break}if(((m?(f[j+8>>2]|0)==(c|0):0)?(f[j+12>>2]|0)==(d|0):0)?(f[j+16>>2]|0)==(e|0):0){h=j;n=23;break}j=f[j>>2]|0;if(!j){h=0;n=23;break}}if((n|0)==23)return h|0}else o=a;while(1){a=f[o+4>>2]|0;if((a|0)==(b|0)){if(((f[o+8>>2]|0)==(c|0)?(f[o+12>>2]|0)==(d|0):0)?(f[o+16>>2]|0)==(e|0):0){h=o;n=23;break}}else{if(a>>>0>>0)p=a;else p=(a>>>0)%(g>>>0)|0;if((p|0)!=(k|0)){h=0;n=23;break}}o=f[o>>2]|0;if(!o){h=0;n=23;break}}if((n|0)==23)return h|0;return 0}function rg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;Oq(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)aq(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)aq(a);i=ln(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;if((a|0)==(c|0))p=k;else{o=c;c=k;while(1){b[c>>0]=b[o>>0]|0;o=o+1|0;if((o|0)==(a|0))break;else c=c+1|0}p=k+(a-e)|0}if(!j){if((f[n>>2]|0)==(p|0))return;f[n>>2]=p;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}function sg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=c>>>1&1431655765|c<<1&-1431655766;c=d>>>2&858993459|d<<2&-858993460;d=c>>>4&252645135|c<<4&-252645136;c=d>>>8&16711935|d<<8&-16711936;d=32-b|0;e=(c>>>16|c<<16)>>>d;c=e-(e>>>1&1431655765)|0;g=(c>>>2&858993459)+(c&858993459)|0;c=(X((g>>>4)+g&252645135,16843009)|0)>>>24;g=b-c|0;h=f[a>>2]|0;i=h;j=Vn(f[i>>2]|0,f[i+4>>2]|0,g|0,((g|0)<0)<<31>>31|0)|0;g=h;f[g>>2]=j;f[g+4>>2]=I;g=h+8|0;h=g;j=Vn(f[h>>2]|0,f[h+4>>2]|0,c|0,0)|0;c=g;f[c>>2]=j;f[c+4>>2]=I;c=a+28|0;j=f[c>>2]|0;g=32-j|0;h=a+24|0;do if((g|0)>=(b|0)){i=-1>>>d<>2]&~i|i&e<>2]=k;i=j+b|0;f[c>>2]=i;if((i|0)!=32)return;i=a+16|0;l=f[i>>2]|0;if((l|0)==(f[a+20>>2]|0)){Ri(a+12|0,h);m=0;n=0;break}else{f[l>>2]=k;f[i>>2]=l+4;m=0;n=0;break}}else{l=-1>>>j<>2]&~l|l&e<>2]=i;l=a+16|0;k=f[l>>2]|0;if((k|0)==(f[a+20>>2]|0))Ri(a+12|0,h);else{f[k>>2]=i;f[l>>2]=k+4}k=b-g|0;m=k;n=-1>>>(32-k|0)&e>>>g}while(0);f[h>>2]=n;f[c>>2]=m;return}function tg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c&255;g=(d|0)!=0;a:do if(g&(a&3|0)!=0){h=c&255;i=a;j=d;while(1){if((b[i>>0]|0)==h<<24>>24){k=i;l=j;m=6;break a}n=i+1|0;o=j+-1|0;p=(o|0)!=0;if(p&(n&3|0)!=0){i=n;j=o}else{q=n;r=o;s=p;m=5;break}}}else{q=a;r=d;s=g;m=5}while(0);if((m|0)==5)if(s){k=q;l=r;m=6}else{t=q;u=0}b:do if((m|0)==6){q=c&255;if((b[k>>0]|0)==q<<24>>24){t=k;u=l}else{r=X(e,16843009)|0;c:do if(l>>>0>3){s=k;g=l;while(1){d=f[s>>2]^r;if((d&-2139062144^-2139062144)&d+-16843009|0)break;d=s+4|0;a=g+-4|0;if(a>>>0>3){s=d;g=a}else{v=d;w=a;m=11;break c}}x=s;y=g}else{v=k;w=l;m=11}while(0);if((m|0)==11)if(!w){t=v;u=0;break}else{x=v;y=w}while(1){if((b[x>>0]|0)==q<<24>>24){t=x;u=y;break b}r=x+1|0;y=y+-1|0;if(!y){t=r;u=0;break}else x=r}}}while(0);return (u|0?t:0)|0}function ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=e;do if((d|0)==(e|0)){h=a+8|0;i=f[h>>2]|0;j=a+12|0;k=f[j>>2]|0;l=k;if(i>>>0>>0){k=i;m=((l-k>>2)+1|0)/2|0;n=i+(m<<2)|0;o=k-d|0;k=o>>2;p=n+(0-k<<2)|0;if(!k){q=n;r=i}else{im(p|0,d|0,o|0)|0;q=p;r=f[h>>2]|0}f[c>>2]=q;f[h>>2]=r+(m<<2);s=q;break}m=l-g>>1;l=(m|0)==0?1:m;if(l>>>0>1073741823){m=ra(8)|0;Oo(m,16035);f[m>>2]=7256;va(m|0,1112,110)}m=ln(l<<2)|0;p=m;o=m+((l+3|0)>>>2<<2)|0;n=o;k=m+(l<<2)|0;if((d|0)==(i|0)){t=n;u=d}else{l=o;m=n;v=d;do{f[l>>2]=f[v>>2];l=m+4|0;m=l;v=v+4|0}while((v|0)!=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;a=m;while(1){m=f[r+(j<<2)>>2]|0;if(!(b[n+84>>0]|0))t=f[(f[n+68>>2]|0)+(m<<2)>>2]|0;else t=m;m=s+48|0;v=f[m>>2]|0;w=f[m+4>>2]|0;m=s+40|0;x=f[m>>2]|0;y=un(x|0,f[m+4>>2]|0,t|0,0)|0;m=Vn(y|0,I|0,v|0,w|0)|0;kh(k|0,(f[f[s>>2]>>2]|0)+m|0,x|0)|0;x=o;m=f[x+4>>2]|0;if((m|0)>0|(m|0)==0&(f[x>>2]|0)>>>0>0){z=r;A=a}else{f[h>>2]=f[p>>2];f[g>>2]=f[h>>2];Me(d,g,k,q)|0;z=f[c>>2]|0;A=f[l>>2]|0}x=j+1|0;if(x>>>0>=A-z>>2>>>0)break;m=f[i>>2]|0;j=x;r=z;n=m;s=m;a=A}Mq(k);u=e;return 1}function xg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=(f[b>>2]|0)*3|0;if((d|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}b=f[a+12>>2]|0;h=f[b+12>>2]|0;if((f[h+(d<<2)>>2]|0)==-1){e=0;g=d;f[c>>2]=g;return e|0}i=f[b>>2]|0;b=f[a+152>>2]|0;if((f[b+(f[i+(d<<2)>>2]<<2)>>2]|0)==-1){a=d+1|0;j=((a>>>0)%3|0|0)==0?d+-2|0:a;if((j|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(j<<2)>>2]|0)==-1){e=0;g=j;f[c>>2]=g;return e|0}if((f[b+(f[i+(j<<2)>>2]<<2)>>2]|0)==-1){a=j+1|0;k=((a>>>0)%3|0|0)==0?j+-2|0:a;if((k|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(k<<2)>>2]|0)==-1){e=0;g=k;f[c>>2]=g;return e|0}if((f[b+(f[i+(k<<2)>>2]<<2)>>2]|0)==-1){i=k+1|0;e=1;g=((i>>>0)%3|0|0)==0?k+-2|0:i;f[c>>2]=g;return e|0}else l=k}else l=j}else l=d;while(1){d=(((l>>>0)%3|0|0)==0?2:-1)+l|0;if((d|0)==-1)break;j=f[h+(d<<2)>>2]|0;if((j|0)==-1)break;d=j+(((j>>>0)%3|0|0)==0?2:-1)|0;if((d|0)==-1)break;else l=d}e=0;g=(((l>>>0)%3|0|0)==0?2:-1)+l|0;f[c>>2]=g;return e|0}function yg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=a+4|0;g=f[e>>2]|0;if(!g){f[c>>2]=e;h=e;return h|0}e=b[d+11>>0]|0;i=e<<24>>24<0;j=i?f[d+4>>2]|0:e&255;e=i?f[d>>2]|0:d;d=a+4|0;a=g;while(1){g=a+16|0;i=b[g+11>>0]|0;k=i<<24>>24<0;l=k?f[a+20>>2]|0:i&255;i=l>>>0>>0;m=i?l:j;if((m|0)!=0?(n=Vk(e,k?f[g>>2]|0:g,m)|0,(n|0)!=0):0)if((n|0)<0)o=8;else o=10;else if(j>>>0>>0)o=8;else o=10;if((o|0)==8){o=0;n=f[a>>2]|0;if(!n){o=9;break}else{p=a;q=n}}else if((o|0)==10){o=0;n=j>>>0>>0?j:l;if((n|0)!=0?(l=Vk(k?f[g>>2]|0:g,e,n)|0,(l|0)!=0):0){if((l|0)>=0){o=16;break}}else o=12;if((o|0)==12?(o=0,!i):0){o=16;break}r=a+4|0;i=f[r>>2]|0;if(!i){o=15;break}else{p=r;q=i}}d=p;a=q}if((o|0)==9){f[c>>2]=a;h=a;return h|0}else if((o|0)==15){f[c>>2]=a;h=r;return h|0}else if((o|0)==16){f[c>>2]=a;h=d;return h|0}return 0}function zg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;d=u;u=u+32|0;e=d+24|0;g=d+16|0;h=d+8|0;i=d;j=a+4|0;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|0;o=m;s=p+(l<<2)|0;if((j|0)==(d|0)){t=o;u=k}else{k=m;m=o;l=j;do{f[k>>2]=f[l>>2];k=m+4|0;m=k;l=l+4|0}while((l|0)!=(d|0));t=m;u=f[a>>2]|0}f[a>>2]=n;f[i>>2]=o;f[c>>2]=t;f[e>>2]=s;if(!u)r=t;else{Oq(u);r=f[c>>2]|0}}else r=d;while(0);f[r>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+4;return}function Bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+12|0;i=a+4|0;j=f[i>>2]|0;if((j|0)==(f[a+8>>2]|0)){Ri(a,h);k=f[i>>2]|0}else{f[j>>2]=f[h>>2];l=j+4|0;f[i>>2]=l;k=l}l=f[a>>2]|0;f[g>>2]=k-l;k=b+16|0;j=k;m=f[j+4>>2]|0;if(!((m|0)>0|(m|0)==0&(f[j>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=f[a>>2]|0;m=f[g>>2]|0;g=k;k=f[g+4>>2]|0;if((k|0)>0|(k|0)==0&(f[g>>2]|0)>>>0>0){n=j;o=e}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,j,j+m|0)|0;n=f[a>>2]|0;o=e}}else{n=l;o=e}e=f[i>>2]|0;if((e|0)==(n|0)){f[h>>2]=0;p=a+16|0;f[p>>2]=0;u=c;return}f[i>>2]=e+(~((e+-4-n|0)>>>2)<<2);f[h>>2]=0;p=a+16|0;f[p>>2]=0;u=c;return}function Cg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;Oq(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)aq(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)aq(a);i=ln(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}else{n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;o=a-e|0;if(o|0)im(k|0,c|0,o|0)|0;c=k+o|0;if(!j){if((f[n>>2]|0)==(c|0))return;f[n>>2]=c;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}}function Dg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+352>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Eg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}i=f[a>>2]|0;j=g-i>>2;g=j+b|0;k=i;if(g>>>0>1073741823)aq(a);l=d-i|0;d=l>>1;m=l>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(m)if(m>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m<<2)|0;break}else n=0;while(0);d=n+(j<<2)|0;sj(d|0,0,b<<2|0)|0;b=d;j=n+(m<<2)|0;m=n+(g<<2)|0;if((h|0)==(k|0)){o=b;p=i;q=h}else{i=h;h=b;b=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[b+-4>>2]=d;b=h+-4|0;h=b}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=j;j=p;if((q|0)!=(j|0)){c=q;do{c=c+-4|0;q=f[c>>2]|0;f[c>>2]=0;if(q|0)Va[f[(f[q>>2]|0)+4>>2]&127](q)}while((c|0)!=(j|0))}if(!p)return;Oq(p);return}function Fg(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=$(h);var i=0,j=0,k=0,l=0,m=0,n=0;i=u;u=u+16|0;j=i;k=i+4|0;f[j>>2]=c;c=ln(32)|0;f[k>>2]=c;f[k+8>>2]=-2147483616;f[k+4>>2]=17;l=c;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+17>>0]=0;Xj(Hd(a,j)|0,k,d);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);d=ln(32)|0;f[k>>2]=d;f[k+8>>2]=-2147483616;f[k+4>>2]=19;l=d;m=14438;n=l+19|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[d+19>>0]=0;si(Hd(a,j)|0,k,g,e);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);e=ln(32)|0;f[k>>2]=e;f[k+8>>2]=-2147483616;f[k+4>>2]=18;l=e;m=14458;n=l+18|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+18>>0]=0;Tj(Hd(a,j)|0,k,h);if((b[k+11>>0]|0)>=0){u=i;return}Oq(f[k>>2]|0);u=i;return}function Gg(a){a=a|0;tk(a);tk(a+32|0);tk(a+64|0);tk(a+96|0);tk(a+128|0);tk(a+160|0);tk(a+192|0);tk(a+224|0);tk(a+256|0);tk(a+288|0);tk(a+320|0);tk(a+352|0);tk(a+384|0);tk(a+416|0);tk(a+448|0);tk(a+480|0);tk(a+512|0);tk(a+544|0);tk(a+576|0);tk(a+608|0);tk(a+640|0);tk(a+672|0);tk(a+704|0);tk(a+736|0);tk(a+768|0);tk(a+800|0);tk(a+832|0);tk(a+864|0);tk(a+896|0);tk(a+928|0);tk(a+960|0);tk(a+992|0);tk(a+1024|0);return}function Hg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+288>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Ig(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>2>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>2;o=h>>>0>n>>>0;p=o?b+(n<<2)|0:c;c=p;n=c-e|0;e=n>>2;if(e|0)im(k|0,b|0,n|0)|0;n=l+(e<<2)|0;if(o){o=d-c|0;if((o|0)<=0)return;kh(f[m>>2]|0,p|0,o|0)|0;f[m>>2]=(f[m>>2]|0)+(o>>>2<<2);return}else{o=f[m>>2]|0;if((o|0)==(n|0))return;f[m>>2]=o+(~((o+-4-n|0)>>>2)<<2);return}}n=k;if(!k)q=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(n);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;q=0}if(h>>>0>1073741823)aq(a);j=q>>1;n=q>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(n>>>0>1073741823)aq(a);j=ln(n<<2)|0;h=a+4|0;f[h>>2]=j;f[a>>2]=j;f[i>>2]=j+(n<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[h>>2]=j+(g>>>2<<2);return}function Jg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0,v=0.0;e=u;u=u+16|0;g=e;h=c+1|0;f[g>>2]=0;i=g+4|0;f[i>>2]=0;f[g+8>>2]=0;do if(h)if(h>>>0>1073741823)aq(g);else{j=ln(h<<2)|0;f[g>>2]=j;k=j+(h<<2)|0;f[g+8>>2]=k;sj(j|0,0,(c<<2)+4|0)|0;f[i>>2]=k;l=j;m=k;n=j;break}else{l=0;m=0;n=0}while(0);if((b|0)>0){g=0;do{j=l+(f[a+(g<<2)>>2]<<2)|0;f[j>>2]=(f[j>>2]|0)+1;g=g+1|0}while((g|0)!=(b|0))}o=+(b|0);if((c|0)<0){p=0;q=0.0}else{c=0;r=0.0;b=0;while(1){g=f[l+(b<<2)>>2]|0;s=+(g|0);if((g|0)>0){t=c+1|0;v=r+ +Zg(s/o)*s}else{t=c;v=r}b=b+1|0;if((b|0)==(h|0)){p=t;q=v;break}else{c=t;r=v}}}if(d|0)f[d>>2]=p;v=-q;p=~~v>>>0;d=+K(v)>=1.0?(v>0.0?~~+Y(+J(v/4294967296.0),4294967295.0)>>>0:~~+W((v-+(~~v>>>0))/4294967296.0)>>>0):0;if(!l){I=d;u=e;return p|0}if((m|0)!=(l|0))f[i>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(n);I=d;u=e;return p|0}function Kg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e+4|0;h=e;i=ln(32)|0;f[a>>2]=i;f[a+4>>2]=c+4;c=a+8|0;b[c>>0]=0;f[i+16>>2]=f[d>>2];a=i+20|0;f[i+24>>2]=0;f[i+28>>2]=0;j=i+24|0;f[a>>2]=j;i=f[d+4>>2]|0;k=d+8|0;if((i|0)==(k|0)){b[c>>0]=1;u=e;return}d=j;j=i;while(1){i=j+16|0;f[h>>2]=d;f[g>>2]=f[h>>2];ph(a,g,i,i)|0;i=f[j+4>>2]|0;if(!i){l=j+8|0;m=f[l>>2]|0;if((f[m>>2]|0)==(j|0))n=m;else{m=l;do{l=f[m>>2]|0;m=l+8|0;o=f[m>>2]|0}while((f[o>>2]|0)!=(l|0));n=o}}else{m=i;while(1){o=f[m>>2]|0;if(!o)break;else m=o}n=m}if((n|0)==(k|0))break;else j=n}b[c>>0]=1;u=e;return}function Lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[e>>2]=b;g=a+8|0;if(((f[a+12>>2]|0)-(f[g>>2]|0)>>2|0)<=(b|0))Bh(g,b+1|0);h=f[(f[c>>2]|0)+56>>2]|0;do if((h|0)<5){i=a+20+(h*12|0)+4|0;j=f[i>>2]|0;if((j|0)==(f[a+20+(h*12|0)+8>>2]|0)){Ri(a+20+(h*12|0)|0,e);break}else{f[j>>2]=b;f[i>>2]=j+4;break}}while(0);b=f[c>>2]|0;h=f[e>>2]|0;f[b+60>>2]=h;e=(f[g>>2]|0)+(h<<2)|0;f[c>>2]=0;c=f[e>>2]|0;f[e>>2]=b;if(!c){u=d;return}b=c+88|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0){b=f[e+8>>2]|0;if(b|0){h=e+12|0;if((f[h>>2]|0)!=(b|0))f[h>>2]=b;Oq(b)}Oq(e)}e=f[c+68>>2]|0;if(e|0){b=c+72|0;h=f[b>>2]|0;if((h|0)!=(e|0))f[b>>2]=h+(~((h+-4-e|0)>>>2)<<2);Oq(e)}e=c+64|0;h=f[e>>2]|0;f[e>>2]=0;if(h|0){e=f[h>>2]|0;if(e|0){b=h+4|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(h)}Oq(c);u=d;return}function Mg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+56>>2]|0)-(f[g+52>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[(f[e>>2]|0)+64>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];Zb(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];Zb(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;d=u;u=u+48|0;e=d+16|0;g=d;h=d+32|0;i=a+28|0;j=f[i>>2]|0;f[h>>2]=j;k=a+20|0;l=(f[k>>2]|0)-j|0;f[h+4>>2]=l;f[h+8>>2]=b;f[h+12>>2]=c;b=l+c|0;l=a+60|0;f[g>>2]=f[l>>2];f[g+4>>2]=h;f[g+8>>2]=2;j=to(Aa(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=2;m=b;n=h;o=j;while(1){if((o|0)<0)break;m=m-o|0;p=f[n+4>>2]|0;q=o>>>0>p>>>0;r=q?n+8|0:n;s=g+(q<<31>>31)|0;t=o-(q?p:0)|0;f[r>>2]=(f[r>>2]|0)+t;p=r+4|0;f[p>>2]=(f[p>>2]|0)-t;f[e>>2]=f[l>>2];f[e+4>>2]=r;f[e+8>>2]=s;o=to(Aa(146,e|0)|0)|0;if((m|0)==(o|0)){v=3;break a}else{g=s;n=r}}f[a+16>>2]=0;f[i>>2]=0;f[k>>2]=0;f[a>>2]=f[a>>2]|32;if((g|0)==2)w=0;else w=c-(f[n+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=f[a+44>>2]|0;f[a+16>>2]=v+(f[a+48>>2]|0);a=v;f[i>>2]=a;f[k>>2]=a;w=c}u=d;return w|0}function Og(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=6192;b=f[a+68>>2]|0;if(b|0){c=a+72|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+56>>2]|0;if(b|0){d=a+60|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+44>>2]|0;if(b|0){c=a+48|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+32>>2]|0;if(b|0){d=a+36|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}hi(a+8|0);b=a+4|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+40|0;d=f[b>>2]|0;if(d|0){c=a+44|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){bj(i);Oq(i)}h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}bj(a);Oq(a);return}function Pg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if(((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(f[(f[d>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)==0:0)?(j=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if(((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(f[(f[d>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)==0:0)?(k=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if((((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(f[(f[d>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0:0)?(h=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n)}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Rg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+4|0;a=f[d>>2]|0;do if(a|0){e=b[c+11>>0]|0;g=e<<24>>24<0;h=g?f[c+4>>2]|0:e&255;e=g?f[c>>2]|0:c;g=d;i=a;a:while(1){j=i;while(1){k=j+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[j+20>>2]|0:l&255;l=h>>>0>>0?h:n;if((l|0)!=0?(o=Vk(m?f[k>>2]|0:k,e,l)|0,(o|0)!=0):0){if((o|0)>=0)break}else p=6;if((p|0)==6?(p=0,n>>>0>=h>>>0):0)break;n=f[j+4>>2]|0;if(!n){q=g;break a}else j=n}i=f[j>>2]|0;if(!i){q=j;break}else g=j}if((q|0)!=(d|0)){g=q+16|0;i=b[g+11>>0]|0;n=i<<24>>24<0;o=n?f[q+20>>2]|0:i&255;i=o>>>0>>0?o:h;if(i|0?(l=Vk(e,n?f[g>>2]|0:g,i)|0,l|0):0){if((l|0)<0)break;else r=q;return r|0}if(h>>>0>=o>>>0){r=q;return r|0}}}while(0);r=d;return r|0}function Sg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=a+8|0;f[c>>2]=f[b>>2];fg(a+12|0,b+4|0)|0;d=a+44|0;e=b+36|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];if((c|0)==(b|0)){f[a+96>>2]=f[b+88>>2];return}else{ng(a+60|0,f[b+52>>2]|0,f[b+56>>2]|0);ng(a+72|0,f[b+64>>2]|0,f[b+68>>2]|0);ng(a+84|0,f[b+76>>2]|0,f[b+80>>2]|0);f[a+96>>2]=f[b+88>>2];Ig(a+100|0,f[b+92>>2]|0,f[b+96>>2]|0);return}}function Tg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/12|0)>>>0>=b>>>0){i=b;j=h;do{f[j>>2]=f[c>>2];f[j+4>>2]=f[c+4>>2];f[j+8>>2]=f[c+8>>2];j=(f[g>>2]|0)+12|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/12|0;h=j+b|0;if(h>>>0>357913941)aq(a);k=(e-i|0)/12|0;i=k<<1;e=k>>>0<178956970?(i>>>0>>0?h:i):357913941;do if(e)if(e>>>0>357913941){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*12|0)|0;break}else l=0;while(0);i=l+(j*12|0)|0;j=l+(e*12|0)|0;e=b;b=i;l=i;do{f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];b=l+12|0;l=b;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;b=(f[g>>2]|0)-e|0;c=i+(((b|0)/-12|0)*12|0)|0;if((b|0)>0)kh(c|0,e|0,b|0)|0;f[a>>2]=c;f[g>>2]=l;f[d>>2]=j;if(!e)return;Oq(e);return}function Ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0){bj(n);Oq(n)}}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Vg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=f[b>>2]|0;g=f[a>>2]|0;h=f[d>>2]|0;d=f[h>>2]|0;i=(f[h+4>>2]|0)-d>>3;if(i>>>0<=e>>>0)aq(h);j=d;if(i>>>0<=g>>>0)aq(h);d=f[j+(e<<3)>>2]|0;k=f[c>>2]|0;if(i>>>0<=k>>>0)aq(h);l=j+(g<<3)|0;m=(f[j+(k<<3)>>2]|0)>>>0>>0;if(d>>>0<(f[l>>2]|0)>>>0){if(m){f[a>>2]=k;f[c>>2]=g;n=1;return n|0}f[a>>2]=e;f[b>>2]=g;d=f[c>>2]|0;if(i>>>0<=d>>>0)aq(h);if((f[j+(d<<3)>>2]|0)>>>0>=(f[l>>2]|0)>>>0){n=1;return n|0}f[b>>2]=d;f[c>>2]=g;n=2;return n|0}if(!m){n=0;return n|0}f[b>>2]=k;f[c>>2]=e;e=f[b>>2]|0;c=f[a>>2]|0;if(i>>>0<=e>>>0)aq(h);if(i>>>0<=c>>>0)aq(h);if((f[j+(e<<3)>>2]|0)>>>0>=(f[j+(c<<3)>>2]|0)>>>0){n=1;return n|0}f[a>>2]=e;f[b>>2]=c;n=2;return n|0}function Wg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[e>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];dc(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];dc(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Xg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;a=u;u=u+16|0;e=a;if(!b){g=0;u=a;return g|0}h=b+96|0;i=b+100|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;b=f[i>>2]|0;j=f[h>>2]|0;k=(b-j|0)/12|0;l=j;j=b;if(k>>>0>=c>>>0){if(k>>>0>c>>>0?(b=l+(c*12|0)|0,(b|0)!=(j|0)):0)f[i>>2]=j+(~(((j+-12-b|0)>>>0)/12|0)*12|0);if(!c){g=1;u=a;return g|0}}else Tg(h,c-k|0,e);k=0;b=f[h>>2]|0;while(1){j=k*3|0;l=f[d+(j<<2)>>2]|0;m=f[d+(j+1<<2)>>2]|0;n=f[d+(j+2<<2)>>2]|0;j=((f[i>>2]|0)-b|0)/12|0;o=k;k=k+1|0;if(o>>>0>>0){p=b;q=b}else{f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;Tg(h,k-j|0,e);j=f[h>>2]|0;p=j;q=j}f[p+(o*12|0)>>2]=l;f[p+(o*12|0)+4>>2]=m;f[p+(o*12|0)+8>>2]=n;if((k|0)==(c|0)){g=1;break}else b=q}u=a;return g|0}function Yg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;ao(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function Zg(a){a=+a;var b=0,c=0,d=0,e=0.0,g=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,q=0.0,r=0.0,t=0.0;p[s>>3]=a;b=f[s>>2]|0;c=f[s+4>>2]|0;d=(c|0)<0;do if(d|c>>>0<1048576){if((b|0)==0&(c&2147483647|0)==0){e=-1.0/(a*a);break}if(d){e=(a-a)/0.0;break}else{p[s>>3]=a*18014398509481984.0;g=f[s+4>>2]|0;h=-1077;i=g;j=f[s>>2]|0;k=g;l=9;break}}else if(c>>>0<=2146435071)if((b|0)==0&0==0&(c|0)==1072693248)e=0.0;else{h=-1023;i=c;j=b;k=c;l=9}else e=a;while(0);if((l|0)==9){l=i+614242|0;f[s>>2]=j;f[s+4>>2]=(l&1048575)+1072079006;a=+p[s>>3]+-1.0;m=a*a*.5;n=a/(a+2.0);o=n*n;q=o*o;p[s>>3]=a-m;j=f[s+4>>2]|0;f[s>>2]=0;f[s+4>>2]=j;r=+p[s>>3];t=a-r-m+n*(m+(q*(q*(q*.15313837699209373+.22222198432149784)+.3999999999940942)+o*(q*(q*(q*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)));q=r*1.4426950407214463;o=+(h+(l>>>20)|0);m=q+o;e=m+(q+(o-m)+(t*1.4426950407214463+(t+r)*1.6751713164886512e-10))}return +e}function _g(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=17;h=g;i=14390;j=h+17|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+17>>0]=0;g=c+16|0;i=f[g>>2]|0;if(i){h=g;j=i;a:while(1){i=j;while(1){if((f[i+16>>2]|0)>=(a|0))break;k=f[i+4>>2]|0;if(!k){l=h;break a}else i=k}j=f[i>>2]|0;if(!j){l=i;break}else h=i}if(((l|0)!=(g|0)?(f[l+16>>2]|0)<=(a|0):0)?(a=l+20|0,(Jh(a,e)|0)!=0):0)m=a;else n=10}else n=10;if((n|0)==10)m=c;c=Hk(m,e,-1)|0;if((b[e+11>>0]|0)>=0){o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}Oq(f[e>>2]|0);o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}function $g(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[c>>2]|0;f[c>>2]=0;f[e>>2]=g;Lg(a,b,e);g=f[e>>2]|0;f[e>>2]=0;if(g|0){e=g+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){h=c+12|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(c)}c=f[g+68>>2]|0;if(c|0){e=g+72|0;h=f[e>>2]|0;if((h|0)!=(c|0))f[e>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=g+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){e=h+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(h)}Oq(g)}g=a+84|0;h=a+88|0;a=f[h>>2]|0;c=f[g>>2]|0;e=a-c>>2;if((e|0)>(b|0)){u=d;return}i=b+1|0;b=a;if(i>>>0>e>>>0){Fh(g,i-e|0);u=d;return}if(i>>>0>=e>>>0){u=d;return}e=c+(i<<2)|0;if((e|0)==(b|0)){u=d;return}f[h>>2]=b+(~((b+-4-e|0)>>>2)<<2);u=d;return}function ah(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+352>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+352>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function bh(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0;c=a+108|0;d=(f[a+112>>2]|0)-(f[c>>2]|0)|0;e=(d|0)/12|0;g=a+4|0;ci(e,f[(f[g>>2]|0)+44>>2]|0)|0;if(!d)return 1;d=0;a=0;while(1){i=f[c>>2]|0;j=i+(d*12|0)+4|0;ci((f[j>>2]|0)-a|0,f[(f[g>>2]|0)+44>>2]|0)|0;ci((f[j>>2]|0)-(f[i+(d*12|0)>>2]|0)|0,f[(f[g>>2]|0)+44>>2]|0)|0;d=d+1|0;if(d>>>0>=e>>>0)break;else a=f[j>>2]|0}zi(f[(f[g>>2]|0)+44>>2]|0,e,0,0)|0;a=0;do{d=f[(f[g>>2]|0)+44>>2]|0;j=d+16|0;i=f[j+4>>2]|0;if((i|0)>0|(i|0)==0&(f[j>>2]|0)>>>0>0){j=f[d+12>>2]|0;d=j+4|0;i=f[d>>2]|0;k=b[(f[c>>2]|0)+(a*12|0)+8>>0]&1;l=i>>>3;m=i&7;i=(f[j>>2]|0)+l|0;b[i>>0]=(1<>0]|0);i=(f[j>>2]|0)+l|0;b[i>>0]=k<>0]|0);f[d>>2]=(f[d>>2]|0)+1}a=a+1|0}while(a>>>0>>0);eg(f[(f[g>>2]|0)+44>>2]|0);return 1}function ch(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;io(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function dh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+288>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+288>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function eh(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;g=u;u=u+32|0;h=g+16|0;i=g+8|0;j=g;k=d-e|0;d=a+8|0;if((k|0)>0){a=0-e|0;l=i+4|0;m=j+4|0;n=h+4|0;o=k;do{k=b+(o<<2)|0;p=k+(a<<2)|0;q=c+(o<<2)|0;r=f[k+4>>2]|0;s=f[p>>2]|0;t=f[p+4>>2]|0;f[i>>2]=f[k>>2];f[l>>2]=r;f[j>>2]=s;f[m>>2]=t;Od(h,d,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[n>>2];o=o-e|0}while((o|0)>0)}o=e>>>0>1073741823?-1:e<<2;e=Lq(o)|0;sj(e|0,0,o|0)|0;o=f[b+4>>2]|0;n=f[e>>2]|0;m=f[e+4>>2]|0;f[i>>2]=f[b>>2];f[i+4>>2]=o;f[j>>2]=n;f[j+4>>2]=m;Od(h,d,i,j);f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];Mq(e);u=g;return 1}function fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+32|0;d=c+12|0;e=c;g=f[b+100>>2]|0;h=f[b+96>>2]|0;b=g-h|0;i=(b|0)/12|0;f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;k=h;do if(b)if(i>>>0>357913941)aq(d);else{l=ln(b)|0;f[d>>2]=l;f[d+8>>2]=l+(i*12|0);sj(l|0,0,b|0)|0;f[j>>2]=l+b;m=l;break}else m=0;while(0);f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;if((g|0)!=(h|0)){h=e+4|0;g=e+8|0;b=0;do{l=k+(b*12|0)|0;f[e>>2]=f[l>>2];f[e+4>>2]=f[l+4>>2];f[e+8>>2]=f[l+8>>2];f[m+(b*12|0)>>2]=f[e>>2];f[m+(b*12|0)+4>>2]=f[h>>2];f[m+(b*12|0)+8>>2]=f[g>>2];b=b+1|0}while(b>>>0>>0)}Kj(a,d);a=f[d>>2]|0;if(!a){u=c;return}d=f[j>>2]|0;if((d|0)!=(a|0))f[j>>2]=d+(~(((d+-12-a|0)>>>0)/12|0)*12|0);Oq(a);u=c;return}function gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;if(c>>>0>4294967279)aq(a);d=a+11|0;e=b[d>>0]|0;g=e<<24>>24<0;if(g){h=f[a+4>>2]|0;i=(f[a+8>>2]&2147483647)+-1|0}else{h=e&255;i=10}j=h>>>0>c>>>0?h:c;c=j>>>0<11;k=c?10:(j+16&-16)+-1|0;do if((k|0)!=(i|0)){do if(c){j=f[a>>2]|0;if(g){l=0;m=j;n=a;o=13}else{Fo(a,j,(e&255)+1|0)|0;Oq(j);o=16}}else{j=k+1|0;p=ln(j)|0;if(g){l=1;m=f[a>>2]|0;n=p;o=13;break}else{Fo(p,a,(e&255)+1|0)|0;q=p;r=j;s=a+4|0;o=15;break}}while(0);if((o|0)==13){j=a+4|0;Fo(n,m,(f[j>>2]|0)+1|0)|0;Oq(m);if(l){q=n;r=k+1|0;s=j;o=15}else o=16}if((o|0)==15){f[a+8>>2]=r|-2147483648;f[s>>2]=h;f[a>>2]=q;break}else if((o|0)==16){b[d>>0]=h;break}}while(0);return}function hh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=f[b>>2]|0;if((c|0)==-1){d=-1;return d|0}b=f[(f[a+24>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1){d=0;return d|0}c=a+12|0;a=0;e=0;g=b;a:while(1){b:do if(e){h=a+1|0;i=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((i|0)==-1){d=h;j=15;break a}k=f[(f[c>>2]|0)+(i<<2)>>2]|0;if((k|0)==-1){d=h;j=15;break a}if(!((k>>>0)%3|0)){l=k+2|0;m=h;break}else{l=k+-1|0;m=h;break}}else{h=a;k=g;while(1){i=h+1|0;n=k+1|0;o=((n>>>0)%3|0|0)==0?k+-2|0:n;if((o|0)==-1){l=b;m=i;break b}n=f[(f[c>>2]|0)+(o<<2)>>2]|0;o=n+1|0;if((n|0)==-1){l=b;m=i;break b}k=((o>>>0)%3|0|0)==0?n+-2|0:o;if((k|0)==-1){l=b;m=i;break b}if((k|0)==(b|0)){d=i;j=15;break a}else h=i}}while(0);if((l|0)==-1){d=m;j=15;break}else{a=m;e=1;g=l}}if((j|0)==15)return d|0;return 0}function ih(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=a+8|0;Vg(a,a+4|0,d,c)|0;e=a+12|0;if((e|0)==(b|0))return;g=f[c>>2]|0;c=f[g>>2]|0;h=(f[g+4>>2]|0)-c>>3;i=c;c=e;e=d;a:while(1){d=f[c>>2]|0;j=f[e>>2]|0;if(h>>>0<=d>>>0){k=5;break}if(h>>>0<=j>>>0){k=7;break}l=i+(d<<3)|0;if((f[l>>2]|0)>>>0<(f[i+(j<<3)>>2]|0)>>>0){m=e;n=c;o=j;while(1){f[n>>2]=o;if((m|0)==(a|0)){p=a;break}j=m+-4|0;o=f[j>>2]|0;if(h>>>0<=o>>>0){k=11;break a}if((f[l>>2]|0)>>>0>=(f[i+(o<<3)>>2]|0)>>>0){p=m;break}else{q=m;m=j;n=q}}f[p>>2]=d}n=c+4|0;if((n|0)==(b|0)){k=3;break}else{m=c;c=n;e=m}}if((k|0)==3)return;else if((k|0)==5)aq(g);else if((k|0)==7)aq(g);else if((k|0)==11)aq(g)}function jh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=Vg(a,b,c,e)|0;h=f[d>>2]|0;i=f[c>>2]|0;j=f[e>>2]|0;e=f[j>>2]|0;k=(f[j+4>>2]|0)-e>>3;if(k>>>0<=h>>>0)aq(j);l=e;if(k>>>0<=i>>>0)aq(j);if((f[l+(h<<3)>>2]|0)>>>0>=(f[l+(i<<3)>>2]|0)>>>0){m=g;return m|0}f[c>>2]=h;f[d>>2]=i;i=f[c>>2]|0;d=f[b>>2]|0;if(k>>>0<=i>>>0)aq(j);if(k>>>0<=d>>>0)aq(j);if((f[l+(i<<3)>>2]|0)>>>0>=(f[l+(d<<3)>>2]|0)>>>0){m=g+1|0;return m|0}f[b>>2]=i;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(k>>>0<=d>>>0)aq(j);if(k>>>0<=c>>>0)aq(j);if((f[l+(d<<3)>>2]|0)>>>0>=(f[l+(c<<3)>>2]|0)>>>0){m=g+2|0;return m|0}f[a>>2]=d;f[b>>2]=c;m=g+3|0;return m|0}function kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return Da(a|0,c|0,d|0)|0;e=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return e|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}h=g&-4|0;d=h-64|0;while((a|0)<=(d|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(h|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{h=g-4|0;while((a|0)<(h|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return e|0}function lh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+16|0;d=c+4|0;e=c;f[a>>2]=1232;g=a+4|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;f[g+16>>2]=0;f[g+20>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;f[d>>2]=b;b=a+4|0;g=a+8|0;Ri(b,d);h=f[d>>2]|0;i=a+20|0;j=f[i>>2]|0;k=a+16|0;a=f[k>>2]|0;l=j-a>>2;m=a;if((h|0)<(l|0)){n=m;o=h;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}a=h+1|0;f[e>>2]=-1;w=j;if(a>>>0<=l>>>0)if(a>>>0>>0?(j=m+(a<<2)|0,(j|0)!=(w|0)):0){f[i>>2]=w+(~((w+-4-j|0)>>>2)<<2);x=h;y=m}else{x=h;y=m}else{Ch(k,a-l|0,e);x=f[d>>2]|0;y=f[k>>2]|0}n=y;o=x;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}function mh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+4|0;c=f[b>>2]|0;d=(f[c+12>>2]|0)-(f[c+8>>2]|0)|0;c=d>>2;a:do if((d|0)>0){e=0;while(1){if(!(Ra[f[(f[a>>2]|0)+36>>2]&127](a,e)|0)){g=0;break}e=e+1|0;h=f[b>>2]|0;i=(f[h+12>>2]|0)-(f[h+8>>2]|0)>>2;if((e|0)>=(i|0)){j=i;break a}}return g|0}else j=c;while(0);c=a+20|0;b=a+24|0;d=f[b>>2]|0;e=f[c>>2]|0;i=d-e>>2;h=e;e=d;if(j>>>0<=i>>>0){if(j>>>0>>0?(d=h+(j<<2)|0,(d|0)!=(e|0)):0)f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2)}else Ci(c,j-i|0);i=f[a+12>>2]|0;j=f[a+8>>2]|0;a=j;if((i|0)==(j|0)){g=1;return g|0}d=i-j>>2;j=0;do{i=f[a+(j<<2)>>2]|0;e=f[i+8>>2]|0;b=f[i+4>>2]|0;i=b;if((e|0)!=(b|0)?(h=f[c>>2]|0,k=e-b>>2,f[h+(f[i>>2]<<2)>>2]=j,k>>>0>1):0){b=1;do{f[h+(f[i+(b<<2)>>2]<<2)>>2]=j;b=b+1|0}while(b>>>0>>0)}j=j+1|0}while(j>>>0>>0);g=1;return g|0}function nh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=f[c+88>>2]|0;if(!d){e=0;return e|0}if((f[d>>2]|0)!=1){e=0;return e|0}g=d+8|0;d=f[g>>2]|0;f[a+4>>2]=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;i=a+8|0;j=c+24|0;c=b[j>>0]|0;k=c<<24>>24;l=a+12|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=k>>>0)if(o>>>0>k>>>0?(m=p+(k<<2)|0,(m|0)!=(n|0)):0){f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2);q=c;r=d}else{q=c;r=d}else{Ci(i,k-o|0);q=b[j>>0]|0;r=f[g>>2]|0}g=r+4|0;j=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;if(q<<24>>24>0){g=f[i>>2]|0;i=q<<24>>24;q=j;o=4;k=0;while(1){f[g+(k<<2)>>2]=q;o=o+4|0;k=k+1|0;d=r+o|0;c=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;if((k|0)>=(i|0)){s=c;break}else q=c}}else s=j;f[a+20>>2]=s;e=1;return e|0}function oh(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(!(fp(a,f[c>>2]|0,g)|0)){h=f[a+8>>2]|0;Za[f[(f[h>>2]|0)+24>>2]&3](h,c,d,e,g);break}if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;i=c+44|0;if((f[i>>2]|0)==4)break;j=c+52|0;b[j>>0]=0;k=c+53|0;b[k>>0]=0;l=f[a+8>>2]|0;_a[f[(f[l>>2]|0)+20>>2]&3](l,c,d,d,1,g);if(b[k>>0]|0)if(!(b[j>>0]|0)){m=3;n=11}else o=3;else{m=4;n=11}if((n|0)==11){f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0){b[c+54>>0]=1;o=m}else o=m}f[i>>2]=o;break}if((e|0)==1)f[c+32>>2]=1}else Vm(0,c,d,e);while(0);return}function ph(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e+12|0;h=e+8|0;i=e;f[i>>2]=f[b>>2];f[g>>2]=f[i>>2];i=Kd(a,g,h,e+4|0,c)|0;c=f[i>>2]|0;if(c|0){j=c;u=e;return j|0}c=ln(40)|0;pj(c+16|0,d);pj(c+28|0,d+12|0);d=f[h>>2]|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=d;f[i>>2]=c;d=f[f[a>>2]>>2]|0;if(!d)k=c;else{f[a>>2]=d;k=f[i>>2]|0}Oe(f[a+4>>2]|0,k);k=a+8|0;f[k>>2]=(f[k>>2]|0)+1;j=c;u=e;return j|0}function qh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=a+4|0;f[h>>2]=0;if(!c){u=e;return}i=a+8|0;j=f[i>>2]|0;k=j<<5;if(k>>>0>>0){f[g>>2]=0;l=g+4|0;f[l>>2]=0;m=g+8|0;f[m>>2]=0;if((c|0)<0)aq(a);n=j<<6;j=c+31&-32;vi(g,k>>>0<1073741823?(n>>>0>>0?j:n):2147483647);n=f[a>>2]|0;f[a>>2]=f[g>>2];f[g>>2]=n;g=f[h>>2]|0;f[h>>2]=c;f[l>>2]=g;g=f[i>>2]|0;f[i>>2]=f[m>>2];f[m>>2]=g;if(n|0)Oq(n);o=a}else{f[h>>2]=c;o=a}a=f[o>>2]|0;o=a;h=a;a=c>>>5;n=a<<2;if(!(b[d>>0]|0)){sj(h|0,0,n|0)|0;d=c&31;g=o+(a<<2)|0;if(!d){u=e;return}f[g>>2]=f[g>>2]&~(-1>>>(32-d|0));u=e;return}else{sj(h|0,-1,n|0)|0;n=c&31;c=o+(a<<2)|0;if(!n){u=e;return}f[c>>2]=f[c>>2]|-1>>>(32-n|0);u=e;return}}function rh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+88|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+88|0;ld(n,b);u=c;return 1}function sh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+108|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+108|0;ld(n,b);u=c;return 1}function th(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=a+32|0;d=f[a+64>>2]|0;e=(Qa[f[(f[d>>2]|0)+40>>2]&127](d)|0)+52|0;d=f[e>>2]|0;zi(c,(((f[d+100>>2]|0)-(f[d+96>>2]|0)|0)/12|0)*3|0,0,1)|0;d=a+68|0;e=f[d>>2]|0;g=(f[a+72>>2]|0)-e|0;if((g|0)<=0){eg(c);return}i=a+48|0;j=a+44|0;a=(g>>>2)+-1|0;g=e;while(1){e=f[g+(a<<2)>>2]|0;k=f[3524+(e<<2)>>2]|0;l=i;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0?(l=f[j>>2]|0,171>>>e&1|0):0){m=l+4|0;n=0;o=f[m>>2]|0;do{p=o>>>3;q=o&7;r=(f[l>>2]|0)+p|0;b[r>>0]=(1<>0]|0);r=(f[l>>2]|0)+p|0;b[r>>0]=(e>>>n&1)<>0]|0);o=(f[m>>2]|0)+1|0;f[m>>2]=o;n=n+1|0}while((n|0)!=(k|0))}k=a+-1|0;if((k|0)<=-1)break;a=k;g=f[d>>2]|0}eg(c);return}function uh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+48|0;h=g;i=g+32|0;if(!c){j=0;u=g;return j|0}Gn(h);do if((dm(c,0)|0)!=-1){if(d){if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){k=0;break}Va[f[(f[c>>2]|0)+20>>2]&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if(d-g>>3>>>0>=b>>>0){h=b;i=g;do{j=i;f[j>>2]=0;f[j+4>>2]=0;i=(f[e>>2]|0)+8|0;f[e>>2]=i;h=h+-1|0}while((h|0)!=0);return}h=f[a>>2]|0;i=g-h>>3;g=i+b|0;if(g>>>0>536870911)aq(a);j=d-h|0;h=j>>2;d=j>>3>>>0<268435455?(h>>>0>>0?g:h):536870911;do if(d)if(d>>>0>536870911){h=ra(8)|0;Oo(h,16035);f[h>>2]=7256;va(h|0,1112,110)}else{k=ln(d<<3)|0;break}else k=0;while(0);h=k+(i<<3)|0;i=k+(d<<3)|0;d=b;b=h;k=h;do{g=b;f[g>>2]=0;f[g+4>>2]=0;b=k+8|0;k=b;d=d+-1|0}while((d|0)!=0);d=f[a>>2]|0;b=(f[e>>2]|0)-d|0;g=h+(0-(b>>3)<<3)|0;if((b|0)>0)kh(g|0,d|0,b|0)|0;f[a>>2]=g;f[e>>2]=k;f[c>>2]=i;if(!d)return;Oq(d);return}function xh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;if(!(bn(a,b,c)|0)){g=0;u=d;return g|0}if((Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)<<24>>24==1?((f[(f[a+8>>2]|0)+28>>2]|0)+-1|0)>>>0>=6:0){g=0;u=d;return g|0}h=_g(c,f[b+48>>2]|0)|0;Xa[f[(f[a>>2]|0)+48>>2]&15](e,a,h);h=a+36|0;b=f[e>>2]|0;f[e>>2]=0;c=f[h>>2]|0;f[h>>2]=b;if(!c){f[e>>2]=0;i=b}else{Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[e>>2]|0;f[e>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);i=f[h>>2]|0}if(!i){g=1;u=d;return g|0}if(Ra[f[(f[a>>2]|0)+36>>2]&127](a,i)|0){g=1;u=d;return g|0}i=f[h>>2]|0;f[h>>2]=0;if(!i){g=1;u=d;return g|0}Va[f[(f[i>>2]|0)+4>>2]&127](i);g=1;u=d;return g|0}function yh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e+4|0;h=e;i=e+8|0;j=a&255;b[i>>0]=j&127;do if(c>>>0>0|(c|0)==0&a>>>0>127){b[i>>0]=j|-128;k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;k=Yn(a|0,c|0,7)|0;m=yh(k,I,d)|0;break}}else{k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;n=1;u=e;return n|0}while(0);n=m;u=e;return n|0}function zh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;g=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1)h=Xi(c,d)|0;else h=b;if((h|0)==-2)i=0;else{do if((Qa[f[(f[d>>2]|0)+8>>2]&127](d)|0)==1){Xf(a,d,h,c,e,514);if(!(f[a>>2]|0)){f[a>>2]=0;break}else return}while(0);c=ln(44)|0;f[c>>2]=1544;f[c+4>>2]=g;g=c+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[g+16>>2]=f[e+16>>2];f[g+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);f[c>>2]=1600;i=c}f[a>>2]=i;return}function Ah(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+224|0;g=e+120|0;h=e+80|0;i=e;j=e+136|0;k=h;l=k+40|0;do{f[k>>2]=0;k=k+4|0}while((k|0)<(l|0));f[g>>2]=f[d>>2];if((qb(0,c,g,i,h)|0)<0)m=-1;else{if((f[a+76>>2]|0)>-1)n=Tq(a)|0;else n=0;d=f[a>>2]|0;k=d&32;if((b[a+74>>0]|0)<1)f[a>>2]=d&-33;d=a+48|0;if(!(f[d>>2]|0)){l=a+44|0;o=f[l>>2]|0;f[l>>2]=j;p=a+28|0;f[p>>2]=j;q=a+20|0;f[q>>2]=j;f[d>>2]=80;r=a+16|0;f[r>>2]=j+80;j=qb(a,c,g,i,h)|0;if(!o)s=j;else{Sa[f[a+36>>2]&31](a,0,0)|0;t=(f[q>>2]|0)==0?-1:j;f[l>>2]=o;f[d>>2]=0;f[r>>2]=0;f[p>>2]=0;f[q>>2]=0;s=t}}else s=qb(a,c,g,i,h)|0;h=f[a>>2]|0;f[a>>2]=h|k;if(n|0)Sq(a);m=(h&32|0)==0?s:-1}u=e;return m|0}function Bh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e>>2;h=d;if(g>>>0>>0){uf(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b<<2)|0;if((g|0)==(h|0))return;else i=h;do{h=i+-4|0;f[c>>2]=h;b=f[h>>2]|0;f[h>>2]=0;if(b|0){h=b+88|0;e=f[h>>2]|0;f[h>>2]=0;if(e|0){h=f[e+8>>2]|0;if(h|0){a=e+12|0;if((f[a>>2]|0)!=(h|0))f[a>>2]=h;Oq(h)}Oq(e)}e=f[b+68>>2]|0;if(e|0){h=b+72|0;a=f[h>>2]|0;if((a|0)!=(e|0))f[h>>2]=a+(~((a+-4-e|0)>>>2)<<2);Oq(e)}e=b+64|0;a=f[e>>2]|0;f[e>>2]=0;if(a|0){e=f[a>>2]|0;if(e|0){h=a+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(a)}Oq(b)}i=f[c>>2]|0}while((i|0)!=(g|0));return}function Ch(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;i=h;if(e-h>>2>>>0>=b>>>0){j=b;k=i;while(1){f[k>>2]=f[c>>2];j=j+-1|0;if(!j)break;else k=k+4|0}f[g>>2]=i+(b<<2);return}i=f[a>>2]|0;k=h-i|0;h=k>>2;j=h+b|0;if(j>>>0>1073741823)aq(a);l=e-i|0;e=l>>1;m=l>>2>>>0<536870911?(e>>>0>>0?j:e):1073741823;do if(m)if(m>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}else{e=ln(m<<2)|0;n=e;o=e;break}else{n=0;o=0}while(0);e=n+(h<<2)|0;h=n+(m<<2)|0;m=b;j=e;while(1){f[j>>2]=f[c>>2];m=m+-1|0;if(!m)break;else j=j+4|0}if((k|0)>0)kh(o|0,i|0,k|0)|0;f[a>>2]=n;f[g>>2]=e+(b<<2);f[d>>2]=h;if(!i)return;Oq(i);return}function Dh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=(f[a>>2]|0)+1794895138|0;g=gp(f[a+8>>2]|0,e)|0;h=gp(f[a+12>>2]|0,e)|0;i=gp(f[a+16>>2]|0,e)|0;a:do if((g>>>0>>2>>>0?(j=c-(g<<2)|0,h>>>0>>0&i>>>0>>0):0)?((i|h)&3|0)==0:0){j=h>>>2;k=i>>>2;l=0;m=g;while(1){n=m>>>1;o=l+n|0;p=o<<1;q=p+j|0;r=gp(f[a+(q<<2)>>2]|0,e)|0;s=gp(f[a+(q+1<<2)>>2]|0,e)|0;if(!(s>>>0>>0&r>>>0<(c-s|0)>>>0)){t=0;break a}if(b[a+(s+r)>>0]|0){t=0;break a}r=hl(d,a+s|0)|0;if(!r)break;s=(r|0)<0;if((m|0)==1){t=0;break a}else{l=s?l:o;m=s?n:m-n|0}}m=p+k|0;l=gp(f[a+(m<<2)>>2]|0,e)|0;j=gp(f[a+(m+1<<2)>>2]|0,e)|0;if(j>>>0>>0&l>>>0<(c-j|0)>>>0)t=(b[a+(j+l)>>0]|0)==0?a+j|0:0;else t=0}else t=0;while(0);return t|0}function Eh(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=u;u=u+64|0;i=h;j=f[a>>2]|0;k=a+(f[j+-8>>2]|0)|0;l=f[j+-4>>2]|0;f[i>>2]=e;f[i+4>>2]=a;f[i+8>>2]=c;f[i+12>>2]=g;g=i+16|0;c=i+20|0;a=i+24|0;j=i+28|0;m=i+32|0;n=i+40|0;o=g;p=o+36|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));d[g+36>>1]=0;b[g+38>>0]=0;a:do if(fp(l,e,0)|0){f[i+48>>2]=1;_a[f[(f[l>>2]|0)+20>>2]&3](l,i,k,k,1,0);q=(f[a>>2]|0)==1?k:0}else{Za[f[(f[l>>2]|0)+24>>2]&3](l,i,k,1,0);switch(f[i+36>>2]|0){case 0:{q=(f[n>>2]|0)==1&(f[j>>2]|0)==1&(f[m>>2]|0)==1?f[c>>2]|0:0;break a;break}case 1:break;default:{q=0;break a}}if((f[a>>2]|0)!=1?!((f[n>>2]|0)==0&(f[j>>2]|0)==1&(f[m>>2]|0)==1):0){q=0;break}q=f[g>>2]|0}while(0);u=h;return q|0}function Fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){i=b;j=h;while(1){f[j>>2]=1;i=i+-1|0;if(!i)break;else j=j+4|0}f[e>>2]=h+(b<<2);return}h=f[a>>2]|0;j=g-h|0;g=j>>2;i=g+b|0;if(i>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?i:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;g=m+(l<<2)|0;l=b;i=d;while(1){f[i>>2]=1;l=l+-1|0;if(!l)break;else i=i+4|0}if((j|0)>0)kh(n|0,h|0,j|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=g;if(!h)return;Oq(h);return}function Gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(!c){g=0;u=d;return g|0}h=a+84|0;i=f[h>>2]|0;j=a+88|0;k=f[j>>2]|0;if((k|0)!=(i|0))f[j>>2]=k+(~((k+-4-i|0)>>>2)<<2);f[h>>2]=0;f[j>>2]=0;f[a+92>>2]=0;if(i|0)Oq(i);i=a+72|0;j=f[i>>2]|0;h=a+76|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;f[i>>2]=0;f[h>>2]=0;f[a+80>>2]=0;if(j|0)Oq(j);j=c+4|0;h=(f[j>>2]|0)-(f[c>>2]|0)>>2;b[e>>0]=0;qh(a,h,e);h=c+24|0;i=c+28|0;k=(f[i>>2]|0)-(f[h>>2]|0)>>2;b[e>>0]=0;qh(a+12|0,k,e);hg(a+28|0,(f[j>>2]|0)-(f[c>>2]|0)>>2,6180);gk(a+52|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);gk(a+40|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);f[a+64>>2]=c;b[a+24>>0]=1;g=1;u=d;return g|0}function Hh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(j=f[(f[d+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(k=f[(f[d+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if(((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(h=f[(f[d+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Ih(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Td(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+20>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Td(a,e);return}function Jh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=f[a+4>>2]|0;if(!d){e=0;return e|0}a=b[c+11>>0]|0;g=a<<24>>24<0;h=g?f[c+4>>2]|0:a&255;a=g?f[c>>2]|0:c;c=d;while(1){d=c+16|0;g=b[d+11>>0]|0;i=g<<24>>24<0;j=i?f[c+20>>2]|0:g&255;g=j>>>0>>0;k=g?j:h;if((k|0)!=0?(l=Vk(a,i?f[d>>2]|0:d,k)|0,(l|0)!=0):0)if((l|0)<0)m=7;else m=8;else if(h>>>0>>0)m=7;else m=8;if((m|0)==7){m=0;n=c}else if((m|0)==8){m=0;l=h>>>0>>0?h:j;if((l|0)!=0?(j=Vk(i?f[d>>2]|0:d,a,l)|0,(j|0)!=0):0){if((j|0)>=0){e=1;m=14;break}}else m=10;if((m|0)==10?(m=0,!g):0){e=1;m=14;break}n=c+4|0}c=f[n>>2]|0;if(!c){e=0;m=14;break}}if((m|0)==14)return e|0;return 0}function Kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=u;u=u+16|0;g=e+4|0;h=e;i=f[a+8>>2]|0;j=i+24|0;k=b[j>>0]|0;l=c+4|0;ag(a,(f[l>>2]|0)-(f[c>>2]|0)>>2,k,d);d=f[a+32>>2]|0;a=(f[f[d>>2]>>2]|0)+(f[d+48>>2]|0)|0;d=f[c>>2]|0;c=f[l>>2]|0;if((d|0)==(c|0)){m=1;u=e;return m|0}l=i+84|0;n=i+68|0;o=0;p=d;while(1){d=f[p>>2]|0;if(!(b[l>>0]|0))q=f[(f[n>>2]|0)+(d<<2)>>2]|0;else q=d;f[h>>2]=q;d=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(Qb(i,g,d,a+(o<<2)|0)|0)){m=0;r=7;break}p=p+4|0;if((p|0)==(c|0)){m=1;r=7;break}else o=o+k|0}if((r|0)==7){u=e;return m|0}return 0}function Lh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=1408;b=a+72|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[a+60>>2]|0;if(c|0){b=a+64|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=f[a+48>>2]|0;if(c|0)Oq(c);c=a+36|0;d=f[c>>2]|0;if(d|0){b=a+40|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Va[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(g|0))f[c>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function Mh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f[a>>2]=d;e=a+24|0;g=a+28|0;h=f[g>>2]|0;i=f[e>>2]|0;j=h-i>>2;k=i;i=h;if(j>>>0>=d>>>0){if(j>>>0>d>>>0?(h=k+(d<<2)|0,(h|0)!=(i|0)):0)f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2)}else Ci(e,d-j|0);if(!c)return;j=f[b>>2]|0;if((c|0)>1){d=j;e=j;h=1;while(1){i=f[b+(h<<2)>>2]|0;g=(i|0)<(e|0);k=g?i:e;l=g?d:(i|0)>(d|0)?i:d;h=h+1|0;if((h|0)==(c|0)){m=l;n=k;break}else{d=l;e=k}}}else{m=j;n=j}f[a+4>>2]=n;f[a+8>>2]=m;j=Xn(m|0,((m|0)<0)<<31>>31|0,n|0,((n|0)<0)<<31>>31|0)|0;n=I;if(!(n>>>0<0|(n|0)==0&j>>>0<2147483647))return;n=j+1|0;f[a+12>>2]=n;j=(n|0)/2|0;m=a+16|0;f[m>>2]=j;f[a+20>>2]=0-j;if(n&1|0)return;f[m>>2]=j+-1;return}function Nh(a){a=a|0;Fj(a+992|0);Fj(a+960|0);Fj(a+928|0);Fj(a+896|0);Fj(a+864|0);Fj(a+832|0);Fj(a+800|0);Fj(a+768|0);Fj(a+736|0);Fj(a+704|0);Fj(a+672|0);Fj(a+640|0);Fj(a+608|0);Fj(a+576|0);Fj(a+544|0);Fj(a+512|0);Fj(a+480|0);Fj(a+448|0);Fj(a+416|0);Fj(a+384|0);Fj(a+352|0);Fj(a+320|0);Fj(a+288|0);Fj(a+256|0);Fj(a+224|0);Fj(a+192|0);Fj(a+160|0);Fj(a+128|0);Fj(a+96|0);Fj(a+64|0);Fj(a+32|0);Fj(a);return}function Oh(a){a=a|0;wn(a);wn(a+32|0);wn(a+64|0);wn(a+96|0);wn(a+128|0);wn(a+160|0);wn(a+192|0);wn(a+224|0);wn(a+256|0);wn(a+288|0);wn(a+320|0);wn(a+352|0);wn(a+384|0);wn(a+416|0);wn(a+448|0);wn(a+480|0);wn(a+512|0);wn(a+544|0);wn(a+576|0);wn(a+608|0);wn(a+640|0);wn(a+672|0);wn(a+704|0);wn(a+736|0);wn(a+768|0);wn(a+800|0);wn(a+832|0);wn(a+864|0);wn(a+896|0);wn(a+928|0);wn(a+960|0);wn(a+992|0);return}function Ph(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c+12|0;e=c+8|0;g=c+4|0;h=c;i=(a|0)==(b|0);if(!i){f[g>>2]=f[b>>2];f[h>>2]=b+4;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a,e,d)}if(!i){f[g>>2]=f[b+12>>2];f[h>>2]=b+16;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Hc(a+12|0,e,d)}if(i){u=c;return}f[g>>2]=f[b+24>>2];f[h>>2]=b+28;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a+24|0,e,d);u=c;return}function Qh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+16|0;e=a;if((c|0)<0|((b|0)==0|(d|0)==0)){g=0;u=a;return g|0}h=f[b+8>>2]|0;if(((f[b+12>>2]|0)-h>>2|0)<=(c|0)){g=0;u=a;return g|0}i=b+4|0;if(!(f[i>>2]|0)){j=ln(52)|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;n[j+16>>2]=$(1.0);k=j+20|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;n[j+36>>2]=$(1.0);f[j+40>>2]=0;f[j+44>>2]=0;f[j+48>>2]=0;f[b+4>>2]=j}j=f[(f[h+(c<<2)>>2]|0)+60>>2]|0;c=ln(44)|0;Ub(c,d);f[c+40>>2]=j;j=f[i>>2]|0;f[e>>2]=c;mk(j,e)|0;j=f[e>>2]|0;f[e>>2]=0;if(!j){g=1;u=a;return g|0}bj(j);Oq(j);g=1;u=a;return g|0}function Rh(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0;c=u;u=u+64|0;j=c;k=i?6:5;Il(j);i=f[h+56>>2]|0;h=X(Vl(k)|0,e)|0;Jj(j,i,0,e&255,k,0,h,((h|0)<0)<<31>>31,0,0);h=ln(96)|0;tl(h,j);f[a>>2]=h;Bj(h,d)|0;d=h+84|0;if(!g){b[d>>0]=1;a=f[h+68>>2]|0;j=h+72|0;k=f[j>>2]|0;if((k|0)==(a|0)){u=c;return}f[j>>2]=k+(~((k+-4-a|0)>>>2)<<2);u=c;return}b[d>>0]=0;d=h+68|0;a=h+72|0;h=f[a>>2]|0;k=f[d>>2]|0;j=h-k>>2;e=h;if(j>>>0>>0){Ch(d,g-j|0,1216);u=c;return}if(j>>>0<=g>>>0){u=c;return}j=k+(g<<2)|0;if((j|0)==(e|0)){u=c;return}f[a>>2]=e+(~((e+-4-j|0)>>>2)<<2);u=c;return}function Sh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){rd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;rd(a,e);return}function Th(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){vd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;vd(a,e);return}function Uh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Fd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Fd(a,e);return}function Vh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Pd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Pd(a,e);return}function Wh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){ud(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;ud(a,e);return}function Xh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){zd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;zd(a,e);return}function Yh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Jd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Jd(a,e);return}function Zh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;sd(a,e);return}function _h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){wd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;wd(a,e);return}function $h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Gd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Gd(a,e);return}function ai(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Qd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Qd(a,e);return}function bi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case -1:{if((mi(c)|0)==10)m=6;else m=5;break}case 1:{m=5;break}default:m=6}if((m|0)==5){i=ln(60)|0;Lo(i);n=i}else if((m|0)==6){m=ln(56)|0;tp(m);n=m}xo(n,d);Md(a,n,c,e);Va[f[(f[n>>2]|0)+4>>2]&127](n);u=g;return}function ci(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;b[h>>0]=a&127;do if(a>>>0>127){b[h>>0]=a|128;i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;k=ci(a>>>7,c)|0;break}}else{i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;l=1;u=d;return l|0}while(0);l=k;u=d;return l|0} +function vc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+8|0;j=e+4|0;k=e;switch(f[c+28>>2]|0){case 9:{l=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=l;f[g>>2]=f[h>>2];m=hc(a,c,g)|0;break}case 2:{f[i>>2]=l;f[g>>2]=f[i>>2];m=Wb(a,c,g)|0;break}case 3:{f[j>>2]=l;f[g>>2]=f[j>>2];m=uc(a,c,g)|0;break}case 4:{f[k>>2]=l;f[g>>2]=f[k>>2];m=mc(a,c,g)|0;break}default:m=0}n=m;break}case 1:{m=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=m;f[g>>2]=f[h>>2];o=gc(a,c,g)|0;break}case 2:{f[i>>2]=m;f[g>>2]=f[i>>2];o=Xb(a,c,g)|0;break}case 3:{f[j>>2]=m;f[g>>2]=f[j>>2];o=sc(a,c,g)|0;break}case 4:{f[k>>2]=m;f[g>>2]=f[k>>2];o=lc(a,c,g)|0;break}default:o=0}n=o;break}case 11:case 2:{o=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=o;f[g>>2]=f[h>>2];p=gc(a,c,g)|0;break}case 2:{f[i>>2]=o;f[g>>2]=f[i>>2];p=Xb(a,c,g)|0;break}case 3:{f[j>>2]=o;f[g>>2]=f[j>>2];p=sc(a,c,g)|0;break}case 4:{f[k>>2]=o;f[g>>2]=f[k>>2];p=lc(a,c,g)|0;break}default:p=0}n=p;break}case 4:{p=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=p;f[g>>2]=f[h>>2];q=ec(a,c,g)|0;break}case 2:{f[i>>2]=p;f[g>>2]=f[i>>2];q=Vb(a,c,g)|0;break}case 3:{f[j>>2]=p;f[g>>2]=f[j>>2];q=nc(a,c,g)|0;break}case 4:{f[k>>2]=p;f[g>>2]=f[k>>2];q=jc(a,c,g)|0;break}default:q=0}n=q;break}case 3:{q=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=q;f[g>>2]=f[h>>2];r=ec(a,c,g)|0;break}case 2:{f[i>>2]=q;f[g>>2]=f[i>>2];r=Vb(a,c,g)|0;break}case 3:{f[j>>2]=q;f[g>>2]=f[j>>2];r=nc(a,c,g)|0;break}case 4:{f[k>>2]=q;f[g>>2]=f[k>>2];r=jc(a,c,g)|0;break}default:r=0}n=r;break}case 6:{r=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=r;f[g>>2]=f[h>>2];s=hc(a,c,g)|0;break}case 2:{f[i>>2]=r;f[g>>2]=f[i>>2];s=Wb(a,c,g)|0;break}case 3:{f[j>>2]=r;f[g>>2]=f[j>>2];s=uc(a,c,g)|0;break}case 4:{f[k>>2]=r;f[g>>2]=f[k>>2];s=mc(a,c,g)|0;break}default:s=0}n=s;break}case 5:{s=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=s;f[g>>2]=f[h>>2];t=hc(a,c,g)|0;break}case 2:{f[i>>2]=s;f[g>>2]=f[i>>2];t=Wb(a,c,g)|0;break}case 3:{f[j>>2]=s;f[g>>2]=f[j>>2];t=uc(a,c,g)|0;break}case 4:{f[k>>2]=s;f[g>>2]=f[k>>2];t=mc(a,c,g)|0;break}default:t=0}n=t;break}default:{v=-1;u=e;return v|0}}v=(n|0)==0?-1:n;u=e;return v|0}function wc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+29|0;j=e;k=e+28|0;if(!(f[(f[a+8>>2]|0)+80>>2]|0)){l=1;u=e;return l|0}b[i>>0]=-2;m=a+36|0;n=f[m>>2]|0;if(n)if(Ra[f[(f[a>>2]|0)+40>>2]&127](a,n)|0){n=f[m>>2]|0;o=(Qa[f[(f[n>>2]|0)+8>>2]&127](n)|0)&255;b[i>>0]=o;p=5}else q=0;else p=5;if((p|0)==5){o=d+16|0;n=o;r=f[n+4>>2]|0;if(!((r|0)>0|(r|0)==0&(f[n>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0}i=f[m>>2]|0;if(i|0?(n=(Qa[f[(f[i>>2]|0)+36>>2]&127](i)|0)&255,b[j>>0]=n,n=o,i=f[n+4>>2]|0,!((i|0)>0|(i|0)==0&(f[n>>2]|0)>>>0>0)):0){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,j,j+1|0)|0}n=f[a+32>>2]|0;i=b[n+24>>0]|0;r=X(f[n+80>>2]|0,i)|0;s=(f[f[n>>2]>>2]|0)+(f[n+48>>2]|0)|0;f[j>>2]=0;n=j+4|0;f[n>>2]=0;f[j+8>>2]=0;t=(r|0)==0;do if(!t)if(r>>>0>1073741823)aq(j);else{v=r<<2;w=ln(v)|0;f[j>>2]=w;x=w+(r<<2)|0;f[j+8>>2]=x;sj(w|0,0,v|0)|0;f[n>>2]=x;y=w;break}else y=0;while(0);w=f[m>>2]|0;do if(w){Ta[f[(f[w>>2]|0)+44>>2]&31](w,s,y,r,i,f[c>>2]|0)|0;x=f[m>>2]|0;if(!x){z=s;A=f[j>>2]|0;p=20;break}if(!(Qa[f[(f[x>>2]|0)+32>>2]&127](x)|0)){x=f[j>>2]|0;z=f[m>>2]|0?x:s;A=x;p=20}}else{z=s;A=y;p=20}while(0);if((p|0)==20)xm(z,r,A);A=a+4|0;a=f[A>>2]|0;do if(a){z=f[a+48>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;y=ln(48)|0;f[g>>2]=y;f[g+8>>2]=-2147483600;f[g+4>>2]=34;s=y;w=10697;x=s+34|0;do{b[s>>0]=b[w>>0]|0;s=s+1|0;w=w+1|0}while((s|0)<(x|0));b[y+34>>0]=0;w=Yj(z,g,1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!w){if(!t){w=f[j>>2]|0;s=0;x=0;do{x=f[w+(s<<2)>>2]|x;s=s+1|0}while((s|0)!=(r|0));if(x)B=((_(x|0)|0)>>>3^3)+1|0;else B=1}else B=1;b[k>>0]=0;s=o;w=f[s>>2]|0;z=f[s+4>>2]|0;if((z|0)>0|(z|0)==0&w>>>0>0){C=z;D=w}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0;w=o;C=f[w+4>>2]|0;D=f[w>>2]|0}b[k>>0]=B;if(!((C|0)>0|(C|0)==0&D>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}if((B|0)==(Vl(5)|0)){w=f[j>>2]|0;z=o;s=f[z+4>>2]|0;if(!((s|0)>0|(s|0)==0&(f[z>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,w,w+(r<<2)|0)|0}p=48;break}if(t)p=48;else{w=d+4|0;z=0;do{s=(f[j>>2]|0)+(z<<2)|0;y=o;v=f[y+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[y>>2]|0)>>>0>0)){f[h>>2]=f[w>>2];f[g>>2]=f[h>>2];Me(d,g,s,s+B|0)|0}z=z+1|0}while(z>>>0>>0);p=48}}else p=27}else p=27;while(0);if((p|0)==27){b[k>>0]=1;r=o;o=f[r+4>>2]|0;if(!((o|0)>0|(o|0)==0&(f[r>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}lp(g);k=f[A>>2]|0;if(k|0)Zj(g,10-(mi(f[k+48>>2]|0)|0)|0)|0;k=Mc(f[j>>2]|0,X((f[c+4>>2]|0)-(f[c>>2]|0)>>2,i)|0,i,g,d)|0;Ej(g,f[g+4>>2]|0);if(k)p=48;else E=0}if((p|0)==48){p=f[m>>2]|0;if(!p)E=1;else{Ra[f[(f[p>>2]|0)+40>>2]&127](p,d)|0;E=1}}d=f[j>>2]|0;if(d|0){j=f[n>>2]|0;if((j|0)!=(d|0))f[n>>2]=j+(~((j+-4-d|0)>>>2)<<2);Oq(d)}q=E}l=q;u=e;return l|0}function xc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0;b=u;u=u+48|0;c=b+24|0;d=b+12|0;e=b;g=a+32|0;h=a+8|0;i=a+12|0;j=f[i>>2]|0;k=f[h>>2]|0;l=j-k>>2;m=a+36|0;n=f[m>>2]|0;o=f[g>>2]|0;p=n-o>>2;q=o;o=n;n=k;if(l>>>0<=p>>>0)if(l>>>0

    >>0:0)break;s=yg(a,d,g)|0;return s|0}while(0);if(m){f[d>>2]=c;s=i+4|0;return s|0}else{f[d>>2]=t;s=t;return s|0}}while(0);t=f[i>>2]|0;do if((f[a>>2]|0)==(i|0))v=c;else{if(!t){h=i;while(1){e=f[h+8>>2]|0;if((f[e>>2]|0)==(h|0))h=e;else{w=e;break}}}else{h=t;while(1){m=f[h+4>>2]|0;if(!m){w=h;break}else h=m}}h=w;m=w+16|0;e=b[g+11>>0]|0;o=e<<24>>24<0;n=o?f[g+4>>2]|0:e&255;e=b[m+11>>0]|0;j=e<<24>>24<0;p=j?f[w+20>>2]|0:e&255;e=n>>>0

    >>0?n:p;if((e|0)!=0?(u=Vk(j?f[m>>2]|0:m,o?f[g>>2]|0:g,e)|0,(u|0)!=0):0){if((u|0)<0){v=h;break}}else r=13;if((r|0)==13?p>>>0>>0:0){v=h;break}s=yg(a,d,g)|0;return s|0}while(0);if(!t){f[d>>2]=i;s=i;return s|0}else{f[d>>2]=v;s=v+4|0;return s|0}return 0}function Ld(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a;h=b;i=h;j=c;k=d;l=k;if(!i){m=(e|0)!=0;if(!l){if(m){f[e>>2]=(g>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(g>>>0)/(j>>>0)>>>0;return (I=n,o)|0}else{if(!m){n=0;o=0;return (I=n,o)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;n=0;o=0;return (I=n,o)|0}}m=(l|0)==0;do if(j){if(!m){p=(_(l|0)|0)-(_(i|0)|0)|0;if(p>>>0<=31){q=p+1|0;r=31-p|0;s=p-31>>31;t=q;u=g>>>(q>>>0)&s|i<>>(q>>>0)&s;w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}r=j-1|0;if(r&j|0){s=(_(j|0)|0)+33-(_(i|0)|0)|0;q=64-s|0;p=32-s|0;y=p>>31;z=s-32|0;A=z>>31;t=s;u=p-1>>31&i>>>(z>>>0)|(i<>>(s>>>0))&A;v=A&i>>>(s>>>0);w=g<>>(z>>>0))&y|g<>31;break}if(e|0){f[e>>2]=r&g;f[e+4>>2]=0}if((j|0)==1){n=h|b&0;o=a|0|0;return (I=n,o)|0}else{r=vm(j|0)|0;n=i>>>(r>>>0)|0;o=i<<32-r|g>>>(r>>>0)|0;return (I=n,o)|0}}else{if(m){if(e|0){f[e>>2]=(i>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(i>>>0)/(j>>>0)>>>0;return (I=n,o)|0}if(!g){if(e|0){f[e>>2]=0;f[e+4>>2]=(i>>>0)%(l>>>0)}n=0;o=(i>>>0)/(l>>>0)>>>0;return (I=n,o)|0}r=l-1|0;if(!(r&l)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=r&i|b&0}n=0;o=i>>>((vm(l|0)|0)>>>0);return (I=n,o)|0}r=(_(l|0)|0)-(_(i|0)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2]=23;l=e;m=15706;n=l+23|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+23>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}Ud(a,c);if(f[a>>2]|0){u=g;return}e=a+4|0;j=e+11|0;if((b[j>>0]|0)<0)Oq(f[e>>2]|0);Wi(a,c);if(f[a>>2]|0){u=g;return}if((b[j>>0]|0)<0)Oq(f[e>>2]|0);if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=29;l=j;m=15730;n=l+29|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+29>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+20>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15760;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+24>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15792;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(Qa[f[(f[c>>2]|0)+28>>2]&127](c)|0){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=g;return}c=ln(48)|0;f[h>>2]=c;f[h+8>>2]=-2147483600;f[h+4>>2]=34;l=c;m=15824;n=l+34|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+34>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}function Nd(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+32|0;d=c+4|0;e=c;g=c+16|0;h=a+48|0;i=f[h>>2]|0;j=ln(32)|0;f[d>>2]=j;f[d+8>>2]=-2147483616;f[d+4>>2]=20;k=j;l=14538;m=k+20|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[j+20>>0]=0;j=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=f[h>>2]|0;n=ln(32)|0;f[d>>2]=n;f[d+8>>2]=-2147483616;f[d+4>>2]=22;k=n;l=14559;m=k+22|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[n+22>>0]=0;n=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=a+56|0;o=f[i>>2]|0;f[i>>2]=0;if(o|0)Va[f[(f[o>>2]|0)+4>>2]&127](o);o=f[a+52>>2]|0;p=(((f[o+100>>2]|0)-(f[o+96>>2]|0)|0)/12|0)>>>0<1e3;o=f[h>>2]|0;q=ln(32)|0;f[d>>2]=q;f[d+8>>2]=-2147483616;f[d+4>>2]=18;k=q;l=14582;m=k+18|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[q+18>>0]=0;q=Hk(o,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);switch(q|0){case -1:{if(j?p|((mi(f[h>>2]|0)|0)>4|n^1):0)r=13;else r=17;break}case 0:{if(j)r=13;else r=21;break}case 2:{r=17;break}default:r=21}if((r|0)==13){j=f[a+44>>2]|0;b[g>>0]=0;n=j+16|0;h=f[n+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[n>>2]|0)>>>0>0)){f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0}j=ln(296)|0;_i(j);n=f[i>>2]|0;f[i>>2]=j;if(!n)s=j;else{Va[f[(f[n>>2]|0)+4>>2]&127](n);r=21}}else if((r|0)==17){n=f[a+44>>2]|0;b[g>>0]=2;j=n+16|0;h=f[j+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[j>>2]|0)>>>0>0)){f[e>>2]=f[n+4>>2];f[d>>2]=f[e>>2];Me(n,d,g,g+1|0)|0}g=ln(360)|0;xi(g);d=f[i>>2]|0;f[i>>2]=g;if(!d)s=g;else{Va[f[(f[d>>2]|0)+4>>2]&127](d);r=21}}if((r|0)==21){r=f[i>>2]|0;if(!r){t=0;u=c;return t|0}else s=r}t=Ra[f[(f[s>>2]|0)+8>>2]&127](s,a)|0;u=c;return t|0}function Od(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;e=b+12|0;g=f[e>>2]|0;h=c+4|0;i=(f[h>>2]|0)-g|0;j=c;f[j>>2]=(f[c>>2]|0)-g;f[j+4>>2]=i;i=(f[d>>2]|0)-g|0;j=d+4|0;k=(f[j>>2]|0)-g|0;g=d;f[g>>2]=i;f[g+4>>2]=k;g=f[e>>2]|0;if((((k|0)>-1?k:0-k|0)+((i|0)>-1?i:0-i|0)|0)>(g|0)){l=f[c>>2]|0;m=f[h>>2]|0;if((l|0)>-1)if((m|0)<=-1)if((l|0)<1){n=-1;o=-1}else p=6;else{n=1;o=1}else if((m|0)<1){n=-1;o=-1}else p=6;if((p|0)==6){n=(l|0)>0?1:-1;o=(m|0)>0?1:-1}q=X(g,n)|0;r=X(g,o)|0;g=(l<<1)-q|0;f[c>>2]=g;l=(m<<1)-r|0;f[h>>2]=l;if((X(n,o)|0)>-1){o=0-l|0;f[c>>2]=o;s=0-g|0;t=o}else{f[c>>2]=l;s=g;t=l}f[c>>2]=(t+q|0)/2|0;f[h>>2]=(s+r|0)/2|0;r=f[d>>2]|0;s=f[j>>2]|0;if((r|0)>-1)if((s|0)<=-1)if((r|0)<1){u=-1;v=-1}else p=14;else{u=1;v=1}else if((s|0)<1){u=-1;v=-1}else p=14;if((p|0)==14){u=(r|0)>0?1:-1;v=(s|0)>0?1:-1}q=f[e>>2]|0;e=X(q,u)|0;t=X(q,v)|0;q=(r<<1)-e|0;f[d>>2]=q;r=(s<<1)-t|0;f[j>>2]=r;if((X(u,v)|0)>-1){v=0-r|0;f[d>>2]=v;w=0-q|0;x=v}else{f[d>>2]=r;w=q;x=r}r=(x+e|0)/2|0;f[d>>2]=r;e=(w+t|0)/2|0;f[j>>2]=e;y=r;z=e}else{y=i;z=k}if(!y)if(!z){A=y;B=z}else p=22;else if((y|0)<0&(z|0)<1){A=y;B=z}else p=22;if((p|0)==22){if(!y)C=(z|0)==0?0:(z|0)>0?3:1;else C=(y|0)>0?(z>>31)+2|0:(z|0)<1?0:3;z=f[c>>2]|0;y=f[h>>2]|0;switch(C|0){case 1:{C=c;f[C>>2]=y;f[C+4>>2]=0-z;D=f[j>>2]|0;E=0-(f[d>>2]|0)|0;break}case 2:{C=c;f[C>>2]=0-z;f[C+4>>2]=0-y;D=0-(f[d>>2]|0)|0;E=0-(f[j>>2]|0)|0;break}case 3:{C=c;f[C>>2]=0-y;f[C+4>>2]=z;D=0-(f[j>>2]|0)|0;E=f[d>>2]|0;break}default:{C=c;f[C>>2]=z;f[C+4>>2]=y;D=f[d>>2]|0;E=f[j>>2]|0}}j=d;f[j>>2]=D;f[j+4>>2]=E;A=D;B=E}E=(f[c>>2]|0)-A|0;f[a>>2]=E;A=(f[h>>2]|0)-B|0;B=a+4|0;f[B>>2]=A;if((E|0)<0)F=(f[b+4>>2]|0)+E|0;else F=E;f[a>>2]=F;if((A|0)>=0){G=A;f[B>>2]=G;return}G=(f[b+4>>2]|0)+A|0;f[B>>2]=G;return}function Pd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){b:do if(i){g=l;c=m;j=n;while(1){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((d[p>>1]|0)==(d[v+8>>1]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}c=f[e>>2]|0;if(!c){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;c=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(b>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=c;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((d[x>>1]|0)==(d[A+8>>1]|0))z=A;else break}f[c>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;c=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Qd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){b:do if(i){g=l;d=m;j=n;while(1){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((b[p>>0]|0)==(b[v+8>>0]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}d=f[e>>2]|0;if(!d){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;d=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(c>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=d;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((b[x>>0]|0)==(b[A+8>>0]|0))z=A;else break}f[d>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;d=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Rd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;g=f[c>>2]|0;c=f[b>>2]|0;h=g-c|0;i=a+8|0;j=f[i>>2]|0;if(h>>>0<64){if(j>>>0<=1){k=0;return k|0}l=f[e>>2]|0;m=0;n=1;while(1){o=(f[l+(m<<2)>>2]|0)>>>0>(f[l+(n<<2)>>2]|0)>>>0?n:m;n=n+1|0;if(n>>>0>=j>>>0){k=o;break}else m=o}return k|0}if(j){j=f[a+1128>>2]|0;m=f[e>>2]|0;e=f[a+1140>>2]|0;n=f[d>>2]|0;d=b+4|0;l=b+8|0;if((g|0)==(c|0)){b=0;do{o=j+(b<<2)|0;f[o>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){p=f[o>>2]|0;q=h-p|0;f[o>>2]=q>>>0

    >>0?p:q}b=b+1|0;q=f[i>>2]|0}while(b>>>0>>0);r=q}else{b=0;do{q=j+(b<<2)|0;f[q>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){o=(f[n+(b<<2)>>2]|0)+(1<>2]|0;s=f[(f[d>>2]|0)+24>>2]|0;t=c;u=f[q>>2]|0;do{v=s+((X(t,p)|0)<<2)+(b<<2)|0;u=u+((f[v>>2]|0)>>>0>>0&1)|0;f[q>>2]=u;t=t+1|0}while((t|0)!=(g|0));t=h-u|0;f[q>>2]=t>>>0>>0?u:t}b=b+1|0;t=f[i>>2]|0}while(b>>>0>>0);r=t}if(r){b=f[a+1140>>2]|0;i=a+1128|0;h=0;g=0;c=0;while(1){if(!(f[b+(g<<2)>>2]|0)){w=h;x=c}else{d=f[(f[i>>2]|0)+(g<<2)>>2]|0;l=h>>>0>>0;w=l?d:h;x=l?g:c}g=g+1|0;if(g>>>0>=r>>>0){y=x;break}else{h=w;c=x}}}else y=0}else y=0;x=a+1088|0;c=a+1104|0;w=f[c>>2]|0;h=32-w|0;if((h|0)<4){r=y&15;g=4-h|0;f[c>>2]=g;h=a+1100|0;i=f[h>>2]|r>>>g;f[h>>2]=i;g=a+1092|0;b=f[g>>2]|0;if((b|0)==(f[a+1096>>2]|0))Ri(x,h);else{f[b>>2]=i;f[g>>2]=b+4}f[h>>2]=r<<32-(f[c>>2]|0);k=y;return k|0}r=a+1100|0;h=f[r>>2]|y<<28>>>w;f[r>>2]=h;b=w+4|0;f[c>>2]=b;if((b|0)!=32){k=y;return k|0}b=a+1092|0;w=f[b>>2]|0;if((w|0)==(f[a+1096>>2]|0))Ri(x,r);else{f[w>>2]=h;f[b>>2]=w+4}f[r>>2]=0;f[c>>2]=0;k=y;return k|0}function Sd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){b:do if(h){e=k;c=l;i=m;while(1){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0))break;o=(f[a>>2]|0)+(n<<2)|0;if(!(f[o>>2]|0)){p=d;q=i;r=n;s=o;break b}o=d+8|0;t=d;while(1){u=f[t>>2]|0;if(!u)break;if((f[o>>2]|0)==(f[u+8>>2]|0))t=u;else break}f[i>>2]=u;f[t>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;o=f[e>>2]|0;if(!o){v=37;break a}else d=o}c=f[d>>2]|0;if(!c){v=37;break a}else{e=d;i=d}}}else{i=k;e=l;c=m;while(1){o=e;while(1){w=f[o+4>>2]|0;if(w>>>0>>0)x=w;else x=(w>>>0)%(b>>>0)|0;if((x|0)==(j|0))break;w=(f[a>>2]|0)+(x<<2)|0;if(!(f[w>>2]|0)){p=o;q=c;r=x;s=w;break b}w=o+8|0;y=o;while(1){z=f[y>>2]|0;if(!z)break;if((f[w>>2]|0)==(f[z+8>>2]|0))y=z;else break}f[c>>2]=z;f[y>>2]=f[f[(f[a>>2]|0)+(x<<2)>>2]>>2];f[f[(f[a>>2]|0)+(x<<2)>>2]>>2]=o;w=f[i>>2]|0;if(!w){v=37;break a}else o=w}e=f[o>>2]|0;if(!e){v=37;break a}else{i=o;c=o}}}while(0);f[s>>2]=q;l=f[p>>2]|0;if(!l){v=37;break}else{j=r;k=p;m=p}}if((v|0)==37)return}function Td(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;e=a+24|0;k=j;j=g;l=d;d=g;a:while(1){g=j;m=l;n=d;b:while(1){o=m;while(1){p=f[o+4>>2]|0;if(!i)if(p>>>0>>0)q=p;else q=(p>>>0)%(c>>>0)|0;else q=p&h;if((q|0)==(k|0))break;r=(f[a>>2]|0)+(q<<2)|0;if(!(f[r>>2]|0))break b;p=f[o>>2]|0;c:do if(!p)s=o;else{t=f[o+8>>2]|0;u=f[e>>2]|0;v=f[u+8>>2]|0;w=(f[u+12>>2]|0)-v|0;u=v;v=w>>>2;if((w|0)>0){x=o;y=p}else{w=p;while(1){z=f[w>>2]|0;if(!z){s=w;break c}else w=z}}while(1){w=f[y+8>>2]|0;z=0;do{A=f[u+(z<<2)>>2]|0;if(!(b[A+84>>0]|0)){B=f[A+68>>2]|0;C=f[B+(w<<2)>>2]|0;D=f[B+(t<<2)>>2]|0}else{C=w;D=t}z=z+1|0;if((D|0)!=(C|0)){s=x;break c}}while((z|0)<(v|0));z=f[y>>2]|0;if(!z){s=y;break}else{w=y;y=z;x=w}}}while(0);f[n>>2]=f[s>>2];f[s>>2]=f[f[(f[a>>2]|0)+(q<<2)>>2]>>2];f[f[(f[a>>2]|0)+(q<<2)>>2]>>2]=o;p=f[g>>2]|0;if(!p){E=38;break a}else o=p}m=f[o>>2]|0;if(!m){E=38;break a}else{g=o;n=o}}f[r>>2]=n;l=f[o>>2]|0;if(!l){E=38;break}else{k=q;j=o;d=o}}if((E|0)==38)return}function Ud(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;e=u;u=u+16|0;g=e+4|0;h=e;i=e+12|0;j=e+11|0;k=e+10|0;l=e+8|0;m=c+44|0;n=f[m>>2]|0;o=n+16|0;p=f[o+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0)){f[h>>2]=f[n+4>>2];f[g>>2]=f[h>>2];Me(n,g,15886,15891)|0}n=Qa[f[(f[c>>2]|0)+8>>2]&127](c)|0;b[i>>0]=n;b[j>>0]=2;b[k>>0]=(n&255|0)==0?3:2;n=f[m>>2]|0;o=n+16|0;p=f[o+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0)){f[h>>2]=f[n+4>>2];f[g>>2]=f[h>>2];Me(n,g,j,j+1|0)|0;j=f[m>>2]|0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(m|0,I|0,r|0,o|0)|0;kh(q|0,(f[a>>2]|0)+v|0,g|0)|0;v=0;do{m=c+(v<<2)|0;w=$(n[m>>2]);x=q+(v<<2)|0;y=$(n[x>>2]);if(w>y){n[m>>2]=y;z=$(n[x>>2])}else z=y;x=s+(v<<2)|0;if($(n[x>>2])>2]=z;v=v+1|0}while((v|0)!=(h|0));t=t+1|0}while(t>>>0

    >>0)}while(0);if(d<<24>>24>0){d=f[k>>2]|0;k=0;z=$(n[j>>2]);while(1){y=$(n[s+(k<<2)>>2]);w=$(y-$(n[d+(k<<2)>>2]));if(w>z){n[j>>2]=w;A=w}else A=z;k=k+1|0;if((k|0)==(h|0))break;else z=A}}Mq(q);Mq(s);i=1;u=e;return i|0}function Xd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a+8|0;Mh(g,b,d,e);h=d-e|0;if((h|0)>0){d=0-e|0;i=a+16|0;j=a+32|0;k=a+12|0;l=a+28|0;m=a+20|0;n=a+24|0;o=h;h=f[g>>2]|0;while(1){p=b+(o<<2)|0;q=c+(o<<2)|0;if((h|0)>0){r=0;s=p+(d<<2)|0;t=h;while(1){if((t|0)>0){u=0;do{v=f[s+(u<<2)>>2]|0;w=f[i>>2]|0;if((v|0)>(w|0)){x=f[j>>2]|0;f[x+(u<<2)>>2]=w;y=x}else{x=f[k>>2]|0;w=f[j>>2]|0;f[w+(u<<2)>>2]=(v|0)<(x|0)?x:v;y=w}u=u+1|0}while((u|0)<(f[g>>2]|0));z=y}else z=f[j>>2]|0;u=(f[p+(r<<2)>>2]|0)-(f[z+(r<<2)>>2]|0)|0;w=q+(r<<2)|0;f[w>>2]=u;if((u|0)>=(f[l>>2]|0)){if((u|0)>(f[n>>2]|0)){A=u-(f[m>>2]|0)|0;B=31}}else{A=(f[m>>2]|0)+u|0;B=31}if((B|0)==31){B=0;f[w>>2]=A}r=r+1|0;w=f[g>>2]|0;if((r|0)>=(w|0)){C=w;break}else{s=z;t=w}}}else C=h;o=o-e|0;if((o|0)<=0){D=C;break}else h=C}}else D=f[g>>2]|0;C=e>>>0>1073741823?-1:e<<2;e=Lq(C)|0;sj(e|0,0,C|0)|0;if((D|0)<=0){Mq(e);return 1}C=a+16|0;h=a+32|0;o=a+12|0;z=a+28|0;A=a+20|0;m=a+24|0;a=0;n=e;l=D;while(1){if((l|0)>0){D=0;do{j=f[n+(D<<2)>>2]|0;y=f[C>>2]|0;if((j|0)>(y|0)){k=f[h>>2]|0;f[k+(D<<2)>>2]=y;E=k}else{k=f[o>>2]|0;y=f[h>>2]|0;f[y+(D<<2)>>2]=(j|0)<(k|0)?k:j;E=y}D=D+1|0}while((D|0)<(f[g>>2]|0));F=E}else F=f[h>>2]|0;D=(f[b+(a<<2)>>2]|0)-(f[F+(a<<2)>>2]|0)|0;y=c+(a<<2)|0;f[y>>2]=D;if((D|0)>=(f[z>>2]|0)){if((D|0)>(f[m>>2]|0)){G=D-(f[A>>2]|0)|0;B=16}}else{G=(f[A>>2]|0)+D|0;B=16}if((B|0)==16){B=0;f[y>>2]=G}a=a+1|0;l=f[g>>2]|0;if((a|0)>=(l|0))break;else n=F}Mq(e);return 1}function Yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;e=f[a>>2]|0;g=e;h=(f[b>>2]|0)-g|0;b=e+(h>>2<<2)|0;i=f[c>>2]|0;c=f[d>>2]|0;d=c-i|0;j=d>>2;k=i;l=c;if((d|0)<=0){m=b;return m|0}d=a+8|0;n=f[d>>2]|0;o=a+4|0;p=f[o>>2]|0;q=p;if((j|0)<=(n-q>>2|0)){r=b;s=q-r|0;t=s>>2;if((j|0)>(t|0)){u=k+(t<<2)|0;t=u;if((u|0)==(l|0))v=p;else{w=l+-4-t|0;x=u;u=p;while(1){f[u>>2]=f[x>>2];x=x+4|0;if((x|0)==(l|0))break;else u=u+4|0}u=p+((w>>>2)+1<<2)|0;f[o>>2]=u;v=u}if((s|0)>0){y=t;z=v}else{m=b;return m|0}}else{y=c;z=p}c=z-(b+(j<<2))>>2;v=b+(c<<2)|0;if(v>>>0

    >>0){t=(p+(0-c<<2)+~r|0)>>>2;r=v;s=z;while(1){f[s>>2]=f[r>>2];r=r+4|0;if(r>>>0>=p>>>0)break;else s=s+4|0}f[o>>2]=z+(t+1<<2)}if(c|0){c=v;v=z;do{c=c+-4|0;v=v+-4|0;f[v>>2]=f[c>>2]}while((c|0)!=(b|0))}c=y;if((k|0)==(c|0)){m=b;return m|0}else{A=b;B=k}while(1){f[A>>2]=f[B>>2];B=B+4|0;if((B|0)==(c|0)){m=b;break}else A=A+4|0}return m|0}A=(q-g>>2)+j|0;if(A>>>0>1073741823)aq(a);j=n-g|0;g=j>>1;n=j>>2>>>0<536870911?(g>>>0>>0?A:g):1073741823;g=b;A=h>>2;do if(n)if(n>>>0>1073741823){j=ra(8)|0;Oo(j,16035);f[j>>2]=7256;va(j|0,1112,110)}else{j=ln(n<<2)|0;C=j;D=j;break}else{C=0;D=0}while(0);j=D+(A<<2)|0;A=D+(n<<2)|0;if((l|0)==(k|0))E=j;else{n=((l+-4-i|0)>>>2)+1|0;i=k;k=j;while(1){f[k>>2]=f[i>>2];i=i+4|0;if((i|0)==(l|0))break;else k=k+4|0}E=j+(n<<2)|0}if((h|0)>0)kh(C|0,e|0,h|0)|0;h=q-g|0;if((h|0)>0){kh(E|0,b|0,h|0)|0;F=E+(h>>>2<<2)|0}else F=E;f[a>>2]=D;f[o>>2]=F;f[d>>2]=A;if(!e){m=j;return m|0}Oq(e);m=j;return m|0}function Zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+60|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+56>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=j;y=v}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;v=m;x=f[v+4>>2]|0;y=f[v>>2]|0}f[g>>2]=f[a+20>>2];if((x|0)>0|(x|0)==0&y>>>0>0){Fj(h);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(h);u=c;return 1}function _d(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;switch(b-a>>2|0){case 2:{d=b+-4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=f[c>>2]|0;i=f[h>>2]|0;j=(f[h+4>>2]|0)-i>>3;if(j>>>0<=e>>>0)aq(h);k=i;if(j>>>0<=g>>>0)aq(h);if((f[k+(e<<3)>>2]|0)>>>0>=(f[k+(g<<3)>>2]|0)>>>0){l=1;return l|0}f[a>>2]=e;f[d>>2]=g;l=1;return l|0}case 3:{Vg(a,a+4|0,b+-4|0,c)|0;l=1;return l|0}case 4:{jh(a,a+4|0,a+8|0,b+-4|0,c)|0;l=1;return l|0}case 5:{ig(a,a+4|0,a+8|0,a+12|0,b+-4|0,c)|0;l=1;return l|0}case 1:case 0:{l=1;return l|0}default:{g=a+8|0;Vg(a,a+4|0,g,c)|0;d=a+12|0;a:do if((d|0)!=(b|0)){e=f[c>>2]|0;k=f[e>>2]|0;h=(f[e+4>>2]|0)-k>>3;j=k;k=d;i=0;m=g;b:while(1){n=f[k>>2]|0;o=f[m>>2]|0;if(h>>>0<=n>>>0){p=14;break}if(h>>>0<=o>>>0){p=16;break}q=j+(n<<3)|0;if((f[q>>2]|0)>>>0<(f[j+(o<<3)>>2]|0)>>>0){r=m;s=k;t=o;while(1){f[s>>2]=t;if((r|0)==(a|0)){u=a;break}o=r+-4|0;t=f[o>>2]|0;if(h>>>0<=t>>>0){p=20;break b}if((f[q>>2]|0)>>>0>=(f[j+(t<<3)>>2]|0)>>>0){u=r;break}else{v=r;r=o;s=v}}f[u>>2]=n;s=i+1|0;if((s|0)==8){w=0;x=(k+4|0)==(b|0);break a}else y=s}else y=i;s=k+4|0;if((s|0)==(b|0)){w=1;x=0;break a}else{r=k;k=s;i=y;m=r}}if((p|0)==14)aq(e);else if((p|0)==16)aq(e);else if((p|0)==20)aq(e)}else{w=1;x=0}while(0);l=x|w;return l|0}}return 0}function $d(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+80|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+76>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=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]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);return 0} +function $a(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0;b=u;u=u+16|0;c=b;do if(a>>>0<245){d=a>>>0<11?16:a+11&-8;e=d>>>3;g=f[4784]|0;h=g>>>e;if(h&3|0){i=(h&1^1)+e|0;j=19176+(i<<1<<2)|0;k=j+8|0;l=f[k>>2]|0;m=l+8|0;n=f[m>>2]|0;if((n|0)==(j|0))f[4784]=g&~(1<>2]=j;f[k>>2]=n}n=i<<3;f[l+4>>2]=n|3;i=l+n+4|0;f[i>>2]=f[i>>2]|1;o=m;u=b;return o|0}m=f[4786]|0;if(d>>>0>m>>>0){if(h|0){i=2<>>12&16;e=i>>>n;i=e>>>5&8;h=e>>>i;e=h>>>2&4;l=h>>>e;h=l>>>1&2;k=l>>>h;l=k>>>1&1;j=(i|n|e|h|l)+(k>>>l)|0;l=19176+(j<<1<<2)|0;k=l+8|0;h=f[k>>2]|0;e=h+8|0;n=f[e>>2]|0;if((n|0)==(l|0)){i=g&~(1<>2]=l;f[k>>2]=n;p=g}n=j<<3;j=n-d|0;f[h+4>>2]=d|3;k=h+d|0;f[k+4>>2]=j|1;f[h+n>>2]=j;if(m|0){n=f[4789]|0;h=m>>>3;l=19176+(h<<1<<2)|0;i=1<>2]|0;r=i}f[r>>2]=n;f[q+12>>2]=n;f[n+8>>2]=q;f[n+12>>2]=l}f[4786]=j;f[4789]=k;o=e;u=b;return o|0}e=f[4785]|0;if(e){k=(e&0-e)+-1|0;j=k>>>12&16;l=k>>>j;k=l>>>5&8;n=l>>>k;l=n>>>2&4;i=n>>>l;n=i>>>1&2;h=i>>>n;i=h>>>1&1;s=f[19440+((k|j|l|n|i)+(h>>>i)<<2)>>2]|0;i=(f[s+4>>2]&-8)-d|0;h=f[s+16+(((f[s+16>>2]|0)==0&1)<<2)>>2]|0;if(!h){t=s;v=i}else{n=s;s=i;i=h;while(1){h=(f[i+4>>2]&-8)-d|0;l=h>>>0>>0;j=l?h:s;h=l?i:n;i=f[i+16+(((f[i+16>>2]|0)==0&1)<<2)>>2]|0;if(!i){t=h;v=j;break}else{n=h;s=j}}}s=t+d|0;if(s>>>0>t>>>0){n=f[t+24>>2]|0;i=f[t+12>>2]|0;do if((i|0)==(t|0)){j=t+20|0;h=f[j>>2]|0;if(!h){l=t+16|0;k=f[l>>2]|0;if(!k){w=0;break}else{x=k;y=l}}else{x=h;y=j}while(1){j=x+20|0;h=f[j>>2]|0;if(h|0){x=h;y=j;continue}j=x+16|0;h=f[j>>2]|0;if(!h)break;else{x=h;y=j}}f[y>>2]=0;w=x}else{j=f[t+8>>2]|0;f[j+12>>2]=i;f[i+8>>2]=j;w=i}while(0);do if(n|0){i=f[t+28>>2]|0;j=19440+(i<<2)|0;if((t|0)==(f[j>>2]|0)){f[j>>2]=w;if(!w){f[4785]=e&~(1<>2]|0)!=(t|0)&1)<<2)>>2]=w;if(!w)break}f[w+24>>2]=n;i=f[t+16>>2]|0;if(i|0){f[w+16>>2]=i;f[i+24>>2]=w}i=f[t+20>>2]|0;if(i|0){f[w+20>>2]=i;f[i+24>>2]=w}}while(0);if(v>>>0<16){n=v+d|0;f[t+4>>2]=n|3;e=t+n+4|0;f[e>>2]=f[e>>2]|1}else{f[t+4>>2]=d|3;f[s+4>>2]=v|1;f[s+v>>2]=v;if(m|0){e=f[4789]|0;n=m>>>3;i=19176+(n<<1<<2)|0;j=1<>2]|0;A=j}f[A>>2]=e;f[z+12>>2]=e;f[e+8>>2]=z;f[e+12>>2]=i}f[4786]=v;f[4789]=s}o=t+8|0;u=b;return o|0}else B=d}else B=d}else B=d}else if(a>>>0<=4294967231){i=a+11|0;e=i&-8;j=f[4785]|0;if(j){n=0-e|0;h=i>>>8;if(h)if(e>>>0>16777215)C=31;else{i=(h+1048320|0)>>>16&8;l=h<>>16&4;k=l<>>16&2;D=14-(h|i|l)+(k<>>15)|0;C=e>>>(D+7|0)&1|D<<1}else C=0;D=f[19440+(C<<2)>>2]|0;a:do if(!D){E=0;F=0;G=n;H=57}else{l=0;k=n;i=D;h=e<<((C|0)==31?0:25-(C>>>1)|0);I=0;while(1){J=(f[i+4>>2]&-8)-e|0;if(J>>>0>>0)if(!J){K=0;L=i;M=i;H=61;break a}else{N=i;O=J}else{N=l;O=k}J=f[i+20>>2]|0;i=f[i+16+(h>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(i|0)?I:J;J=(i|0)==0;if(J){E=P;F=N;G=O;H=57;break}else{l=N;k=O;h=h<<((J^1)&1);I=P}}}while(0);if((H|0)==57){if((E|0)==0&(F|0)==0){D=2<>>12&16;d=D>>>n;D=d>>>5&8;s=d>>>D;d=s>>>2&4;g=s>>>d;s=g>>>1&2;m=g>>>s;g=m>>>1&1;Q=0;R=f[19440+((D|n|d|s|g)+(m>>>g)<<2)>>2]|0}else{Q=F;R=E}if(!R){S=Q;T=G}else{K=G;L=R;M=Q;H=61}}if((H|0)==61)while(1){H=0;g=(f[L+4>>2]&-8)-e|0;m=g>>>0>>0;s=m?g:K;g=m?L:M;L=f[L+16+(((f[L+16>>2]|0)==0&1)<<2)>>2]|0;if(!L){S=g;T=s;break}else{K=s;M=g;H=61}}if((S|0)!=0?T>>>0<((f[4786]|0)-e|0)>>>0:0){g=S+e|0;if(g>>>0<=S>>>0){o=0;u=b;return o|0}s=f[S+24>>2]|0;m=f[S+12>>2]|0;do if((m|0)==(S|0)){d=S+20|0;n=f[d>>2]|0;if(!n){D=S+16|0;I=f[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=n;W=d}while(1){d=V+20|0;n=f[d>>2]|0;if(n|0){V=n;W=d;continue}d=V+16|0;n=f[d>>2]|0;if(!n)break;else{V=n;W=d}}f[W>>2]=0;U=V}else{d=f[S+8>>2]|0;f[d+12>>2]=m;f[m+8>>2]=d;U=m}while(0);do if(s){m=f[S+28>>2]|0;d=19440+(m<<2)|0;if((S|0)==(f[d>>2]|0)){f[d>>2]=U;if(!U){d=j&~(1<>2]|0)!=(S|0)&1)<<2)>>2]=U;if(!U){X=j;break}}f[U+24>>2]=s;d=f[S+16>>2]|0;if(d|0){f[U+16>>2]=d;f[d+24>>2]=U}d=f[S+20>>2]|0;if(d){f[U+20>>2]=d;f[d+24>>2]=U;X=j}else X=j}else X=j;while(0);do if(T>>>0>=16){f[S+4>>2]=e|3;f[g+4>>2]=T|1;f[g+T>>2]=T;j=T>>>3;if(T>>>0<256){s=19176+(j<<1<<2)|0;d=f[4784]|0;m=1<>2]|0;Z=m}f[Z>>2]=g;f[Y+12>>2]=g;f[g+8>>2]=Y;f[g+12>>2]=s;break}s=T>>>8;if(s)if(T>>>0>16777215)_=31;else{m=(s+1048320|0)>>>16&8;d=s<>>16&4;j=d<>>16&2;n=14-(s|m|d)+(j<>>15)|0;_=T>>>(n+7|0)&1|n<<1}else _=0;n=19440+(_<<2)|0;f[g+28>>2]=_;d=g+16|0;f[d+4>>2]=0;f[d>>2]=0;d=1<<_;if(!(X&d)){f[4785]=X|d;f[n>>2]=g;f[g+24>>2]=n;f[g+12>>2]=g;f[g+8>>2]=g;break}d=T<<((_|0)==31?0:25-(_>>>1)|0);j=f[n>>2]|0;while(1){if((f[j+4>>2]&-8|0)==(T|0)){H=97;break}$=j+16+(d>>>31<<2)|0;n=f[$>>2]|0;if(!n){H=96;break}else{d=d<<1;j=n}}if((H|0)==96){f[$>>2]=g;f[g+24>>2]=j;f[g+12>>2]=g;f[g+8>>2]=g;break}else if((H|0)==97){d=j+8|0;n=f[d>>2]|0;f[n+12>>2]=g;f[d>>2]=g;f[g+8>>2]=n;f[g+12>>2]=j;f[g+24>>2]=0;break}}else{n=T+e|0;f[S+4>>2]=n|3;d=S+n+4|0;f[d>>2]=f[d>>2]|1}while(0);o=S+8|0;u=b;return o|0}else B=e}else B=e}else B=-1;while(0);S=f[4786]|0;if(S>>>0>=B>>>0){T=S-B|0;$=f[4789]|0;if(T>>>0>15){_=$+B|0;f[4789]=_;f[4786]=T;f[_+4>>2]=T|1;f[$+S>>2]=T;f[$+4>>2]=B|3}else{f[4786]=0;f[4789]=0;f[$+4>>2]=S|3;T=$+S+4|0;f[T>>2]=f[T>>2]|1}o=$+8|0;u=b;return o|0}$=f[4787]|0;if($>>>0>B>>>0){T=$-B|0;f[4787]=T;S=f[4790]|0;_=S+B|0;f[4790]=_;f[_+4>>2]=T|1;f[S+4>>2]=B|3;o=S+8|0;u=b;return o|0}if(!(f[4902]|0)){f[4904]=4096;f[4903]=4096;f[4905]=-1;f[4906]=-1;f[4907]=0;f[4895]=0;f[4902]=c&-16^1431655768;aa=4096}else aa=f[4904]|0;c=B+48|0;S=B+47|0;T=aa+S|0;_=0-aa|0;aa=T&_;if(aa>>>0<=B>>>0){o=0;u=b;return o|0}X=f[4894]|0;if(X|0?(Y=f[4892]|0,Z=Y+aa|0,Z>>>0<=Y>>>0|Z>>>0>X>>>0):0){o=0;u=b;return o|0}b:do if(!(f[4895]&4)){X=f[4790]|0;c:do if(X){Z=19584;while(1){Y=f[Z>>2]|0;if(Y>>>0<=X>>>0?(ba=Z+4|0,(Y+(f[ba>>2]|0)|0)>>>0>X>>>0):0)break;Y=f[Z+8>>2]|0;if(!Y){H=118;break c}else Z=Y}j=T-$&_;if(j>>>0<2147483647){Y=Nl(j|0)|0;if((Y|0)==((f[Z>>2]|0)+(f[ba>>2]|0)|0))if((Y|0)==(-1|0))ca=j;else{da=j;ea=Y;H=135;break b}else{fa=Y;ga=j;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=Nl(0)|0;if((X|0)!=(-1|0)?(e=X,j=f[4903]|0,Y=j+-1|0,U=((Y&e|0)==0?0:(Y+e&0-j)-e|0)+aa|0,e=f[4892]|0,j=U+e|0,U>>>0>B>>>0&U>>>0<2147483647):0){Y=f[4894]|0;if(Y|0?j>>>0<=e>>>0|j>>>0>Y>>>0:0){ca=0;break}Y=Nl(U|0)|0;if((Y|0)==(X|0)){da=U;ea=X;H=135;break b}else{fa=Y;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(c>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=ga;ea=fa;H=135;break b}Y=f[4904]|0;X=S-ga+Y&0-Y;if(X>>>0>=2147483647){da=ga;ea=fa;H=135;break b}if((Nl(X|0)|0)==(-1|0)){Nl(U|0)|0;ca=0;break}else{da=X+ga|0;ea=fa;H=135;break b}}while(0);f[4895]=f[4895]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=Nl(aa|0)|0,aa=Nl(0)|0,fa=aa-ca|0,ga=fa>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|ga^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ga?fa:ha;ea=ca;H=135}if((H|0)==135){ca=(f[4892]|0)+da|0;f[4892]=ca;if(ca>>>0>(f[4893]|0)>>>0)f[4893]=ca;ca=f[4790]|0;do if(ca){ha=19584;while(1){ia=f[ha>>2]|0;ja=ha+4|0;ka=f[ja>>2]|0;if((ea|0)==(ia+ka|0)){H=143;break}fa=f[ha+8>>2]|0;if(!fa)break;else ha=fa}if(((H|0)==143?(f[ha+12>>2]&8|0)==0:0)?ea>>>0>ca>>>0&ia>>>0<=ca>>>0:0){f[ja>>2]=ka+da;fa=(f[4787]|0)+da|0;ga=ca+8|0;aa=(ga&7|0)==0?0:0-ga&7;ga=ca+aa|0;S=fa-aa|0;f[4790]=ga;f[4787]=S;f[ga+4>>2]=S|1;f[ca+fa+4>>2]=40;f[4791]=f[4906];break}if(ea>>>0<(f[4788]|0)>>>0)f[4788]=ea;fa=ea+da|0;S=19584;while(1){if((f[S>>2]|0)==(fa|0)){H=151;break}ga=f[S+8>>2]|0;if(!ga){la=19584;break}else S=ga}if((H|0)==151)if(!(f[S+12>>2]&8)){f[S>>2]=ea;ha=S+4|0;f[ha>>2]=(f[ha>>2]|0)+da;ha=ea+8|0;ga=ea+((ha&7|0)==0?0:0-ha&7)|0;ha=fa+8|0;aa=fa+((ha&7|0)==0?0:0-ha&7)|0;ha=ga+B|0;c=aa-ga-B|0;f[ga+4>>2]=B|3;do if((ca|0)!=(aa|0)){if((f[4789]|0)==(aa|0)){ba=(f[4786]|0)+c|0;f[4786]=ba;f[4789]=ha;f[ha+4>>2]=ba|1;f[ha+ba>>2]=ba;break}ba=f[aa+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){T=f[aa+8>>2]|0;X=f[aa+12>>2]|0;if((X|0)==(T|0)){f[4784]=f[4784]&~(1<<$);break}else{f[T+12>>2]=X;f[X+8>>2]=T;break}}else{T=f[aa+24>>2]|0;X=f[aa+12>>2]|0;do if((X|0)==(aa|0)){U=aa+16|0;Y=U+4|0;j=f[Y>>2]|0;if(!j){e=f[U>>2]|0;if(!e){ma=0;break}else{na=e;oa=U}}else{na=j;oa=Y}while(1){Y=na+20|0;j=f[Y>>2]|0;if(j|0){na=j;oa=Y;continue}Y=na+16|0;j=f[Y>>2]|0;if(!j)break;else{na=j;oa=Y}}f[oa>>2]=0;ma=na}else{Y=f[aa+8>>2]|0;f[Y+12>>2]=X;f[X+8>>2]=Y;ma=X}while(0);if(!T)break;X=f[aa+28>>2]|0;Y=19440+(X<<2)|0;do if((f[Y>>2]|0)!=(aa|0)){f[T+16+(((f[T+16>>2]|0)!=(aa|0)&1)<<2)>>2]=ma;if(!ma)break d}else{f[Y>>2]=ma;if(ma|0)break;f[4785]=f[4785]&~(1<>2]=T;X=aa+16|0;Y=f[X>>2]|0;if(Y|0){f[ma+16>>2]=Y;f[Y+24>>2]=ma}Y=f[X+4>>2]|0;if(!Y)break;f[ma+20>>2]=Y;f[Y+24>>2]=ma}while(0);pa=aa+_|0;qa=_+c|0}else{pa=aa;qa=c}$=pa+4|0;f[$>>2]=f[$>>2]&-2;f[ha+4>>2]=qa|1;f[ha+qa>>2]=qa;$=qa>>>3;if(qa>>>0<256){ba=19176+($<<1<<2)|0;Z=f[4784]|0;Y=1<<$;if(!(Z&Y)){f[4784]=Z|Y;ra=ba;sa=ba+8|0}else{Y=ba+8|0;ra=f[Y>>2]|0;sa=Y}f[sa>>2]=ha;f[ra+12>>2]=ha;f[ha+8>>2]=ra;f[ha+12>>2]=ba;break}ba=qa>>>8;do if(!ba)ta=0;else{if(qa>>>0>16777215){ta=31;break}Y=(ba+1048320|0)>>>16&8;Z=ba<>>16&4;X=Z<<$;Z=(X+245760|0)>>>16&2;j=14-($|Y|Z)+(X<>>15)|0;ta=qa>>>(j+7|0)&1|j<<1}while(0);ba=19440+(ta<<2)|0;f[ha+28>>2]=ta;_=ha+16|0;f[_+4>>2]=0;f[_>>2]=0;_=f[4785]|0;j=1<>2]=ha;f[ha+24>>2]=ba;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}j=qa<<((ta|0)==31?0:25-(ta>>>1)|0);_=f[ba>>2]|0;while(1){if((f[_+4>>2]&-8|0)==(qa|0)){H=192;break}ua=_+16+(j>>>31<<2)|0;ba=f[ua>>2]|0;if(!ba){H=191;break}else{j=j<<1;_=ba}}if((H|0)==191){f[ua>>2]=ha;f[ha+24>>2]=_;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}else if((H|0)==192){j=_+8|0;ba=f[j>>2]|0;f[ba+12>>2]=ha;f[j>>2]=ha;f[ha+8>>2]=ba;f[ha+12>>2]=_;f[ha+24>>2]=0;break}}else{ba=(f[4787]|0)+c|0;f[4787]=ba;f[4790]=ha;f[ha+4>>2]=ba|1}while(0);o=ga+8|0;u=b;return o|0}else la=19584;while(1){ha=f[la>>2]|0;if(ha>>>0<=ca>>>0?(va=ha+(f[la+4>>2]|0)|0,va>>>0>ca>>>0):0)break;la=f[la+8>>2]|0}ga=va+-47|0;ha=ga+8|0;c=ga+((ha&7|0)==0?0:0-ha&7)|0;ha=ca+16|0;ga=c>>>0>>0?ca:c;c=ga+8|0;aa=da+-40|0;fa=ea+8|0;S=(fa&7|0)==0?0:0-fa&7;fa=ea+S|0;ba=aa-S|0;f[4790]=fa;f[4787]=ba;f[fa+4>>2]=ba|1;f[ea+aa+4>>2]=40;f[4791]=f[4906];aa=ga+4|0;f[aa>>2]=27;f[c>>2]=f[4896];f[c+4>>2]=f[4897];f[c+8>>2]=f[4898];f[c+12>>2]=f[4899];f[4896]=ea;f[4897]=da;f[4899]=0;f[4898]=c;c=ga+24|0;do{ba=c;c=c+4|0;f[c>>2]=7}while((ba+8|0)>>>0>>0);if((ga|0)!=(ca|0)){c=ga-ca|0;f[aa>>2]=f[aa>>2]&-2;f[ca+4>>2]=c|1;f[ga>>2]=c;ba=c>>>3;if(c>>>0<256){fa=19176+(ba<<1<<2)|0;S=f[4784]|0;j=1<>2]|0;xa=j}f[xa>>2]=ca;f[wa+12>>2]=ca;f[ca+8>>2]=wa;f[ca+12>>2]=fa;break}fa=c>>>8;if(fa)if(c>>>0>16777215)ya=31;else{j=(fa+1048320|0)>>>16&8;S=fa<>>16&4;ba=S<>>16&2;Z=14-(fa|j|S)+(ba<>>15)|0;ya=c>>>(Z+7|0)&1|Z<<1}else ya=0;Z=19440+(ya<<2)|0;f[ca+28>>2]=ya;f[ca+20>>2]=0;f[ha>>2]=0;S=f[4785]|0;ba=1<>2]=ca;f[ca+24>>2]=Z;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}ba=c<<((ya|0)==31?0:25-(ya>>>1)|0);S=f[Z>>2]|0;while(1){if((f[S+4>>2]&-8|0)==(c|0)){H=213;break}za=S+16+(ba>>>31<<2)|0;Z=f[za>>2]|0;if(!Z){H=212;break}else{ba=ba<<1;S=Z}}if((H|0)==212){f[za>>2]=ca;f[ca+24>>2]=S;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}else if((H|0)==213){ba=S+8|0;c=f[ba>>2]|0;f[c+12>>2]=ca;f[ba>>2]=ca;f[ca+8>>2]=c;f[ca+12>>2]=S;f[ca+24>>2]=0;break}}}else{c=f[4788]|0;if((c|0)==0|ea>>>0>>0)f[4788]=ea;f[4896]=ea;f[4897]=da;f[4899]=0;f[4793]=f[4902];f[4792]=-1;f[4797]=19176;f[4796]=19176;f[4799]=19184;f[4798]=19184;f[4801]=19192;f[4800]=19192;f[4803]=19200;f[4802]=19200;f[4805]=19208;f[4804]=19208;f[4807]=19216;f[4806]=19216;f[4809]=19224;f[4808]=19224;f[4811]=19232;f[4810]=19232;f[4813]=19240;f[4812]=19240;f[4815]=19248;f[4814]=19248;f[4817]=19256;f[4816]=19256;f[4819]=19264;f[4818]=19264;f[4821]=19272;f[4820]=19272;f[4823]=19280;f[4822]=19280;f[4825]=19288;f[4824]=19288;f[4827]=19296;f[4826]=19296;f[4829]=19304;f[4828]=19304;f[4831]=19312;f[4830]=19312;f[4833]=19320;f[4832]=19320;f[4835]=19328;f[4834]=19328;f[4837]=19336;f[4836]=19336;f[4839]=19344;f[4838]=19344;f[4841]=19352;f[4840]=19352;f[4843]=19360;f[4842]=19360;f[4845]=19368;f[4844]=19368;f[4847]=19376;f[4846]=19376;f[4849]=19384;f[4848]=19384;f[4851]=19392;f[4850]=19392;f[4853]=19400;f[4852]=19400;f[4855]=19408;f[4854]=19408;f[4857]=19416;f[4856]=19416;f[4859]=19424;f[4858]=19424;c=da+-40|0;ba=ea+8|0;ha=(ba&7|0)==0?0:0-ba&7;ba=ea+ha|0;ga=c-ha|0;f[4790]=ba;f[4787]=ga;f[ba+4>>2]=ga|1;f[ea+c+4>>2]=40;f[4791]=f[4906]}while(0);ea=f[4787]|0;if(ea>>>0>B>>>0){da=ea-B|0;f[4787]=da;ea=f[4790]|0;ca=ea+B|0;f[4790]=ca;f[ca+4>>2]=da|1;f[ea+4>>2]=B|3;o=ea+8|0;u=b;return o|0}}ea=Vq()|0;f[ea>>2]=12;o=0;u=b;return o|0}function ab(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Va=0.0,Wa=0.0,Xa=0.0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,g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0)/(hb|0)|0;lb=lb+1|0}while((lb|0)!=(g|0));lb=f[_>>2]|0;if(T)sb=lb;else{tb=0;ub=lb;break}}else sb=f[_>>2]|0;lb=0;jb=0;while(1){nb=(f[kb+(lb<<2)>>2]|0)-(f[Ea+(lb<<2)>>2]|0)|0;mb=((nb|0)>-1?nb:0-nb|0)+jb|0;f[pa+(lb<<2)>>2]=nb;f[sb+(lb<<2)>>2]=nb<<1^nb>>31;lb=lb+1|0;if((lb|0)==(g|0)){tb=mb;ub=sb;break}else jb=mb}}else{tb=0;ub=f[_>>2]|0}while(0);mo(j,$,ub,g);kb=Zk(j)|0;jb=I;lb=Bm(j)|0;mb=I;Xa=+wm(Ca,ib);nb=Vn(lb|0,mb|0,kb|0,jb|0)|0;Va=+W(+(Xa*Wa));jb=Vn(nb|0,I|0,~~Va>>>0|0,(+K(Va)>=1.0?(Va>0.0?~~+Y(+J(Va/4294967296.0),4294967295.0)>>>0:~~+W((Va-+(~~Va>>>0))/4294967296.0)>>>0):0)|0)|0;nb=f[r>>2]|0;if(!((nb|0)<=(jb|0)?!((nb|0)>=(jb|0)?(tb|0)<(f[U>>2]|0):0):0)){nb=r;f[nb>>2]=jb;f[nb+4>>2]=tb;b[V>>0]=qb;f[Z>>2]=hb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[k>>2]=f[v>>2];f[j>>2]=f[w>>2];Jf(aa,k,j);f[x>>2]=Ja;f[y>>2]=Ia;f[k>>2]=f[x>>2];f[j>>2]=f[y>>2];Jf(ba,k,j)}if(La)break;vb=b[Ha>>0]|0;nb=-1;jb=vb;while(1){kb=nb+-1|0;wb=Ma+kb|0;mb=jb;jb=b[wb>>0]|0;if((jb&255)<(mb&255))break;if((wb|0)==(n|0)){xb=84;break d}else nb=kb}kb=Ma+nb|0;if((jb&255)<(vb&255)){yb=Ha;zb=vb}else{mb=Ma;lb=Ha;while(1){ob=lb+-1|0;if((jb&255)<(h[mb+-2>>0]|0)){yb=ob;zb=1;break}else{Ab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z>>2]|0}while(0);mo(j,_,wb,g);mb=Zk(j)|0;lb=I;nb=Bm(j)|0;ob=I;Xa=+wm(Aa,kb);pb=Vn(nb|0,ob|0,mb|0,lb|0)|0;Va=+W(+(Xa*Wa));lb=Vn(pb|0,I|0,~~Va>>>0|0,(+K(Va)>=1.0?(Va>0.0?~~+Y(+J(Va/4294967296.0),4294967295.0)>>>0:~~+W((Va-+(~~Va>>>0))/4294967296.0)>>>0):0)|0)|0;pb=f[r>>2]|0;if(!((pb|0)<=(lb|0)?!((pb|0)>=(lb|0)?(vb|0)<(f[T>>2]|0):0):0)){pb=r;f[pb>>2]=lb;f[pb+4>>2]=vb;b[U>>0]=sb;f[V>>2]=jb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[k>>2]=f[v>>2];f[j>>2]=f[w>>2];Jf($,k,j);f[x>>2]=Ea;f[y>>2]=Oa;f[k>>2]=f[x>>2];f[j>>2]=f[y>>2];Jf(aa,k,j)}if(Ka)break;xb=b[Ma>>0]|0;pb=-1;lb=xb;while(1){mb=pb+-1|0;yb=Pa+mb|0;ob=lb;lb=b[yb>>0]|0;if((lb&255)<(ob&255))break;if((yb|0)==(n|0)){zb=84;break d}else pb=mb}mb=Pa+pb|0;if((lb&255)<(xb&255)){Ab=Ma;Bb=xb}else{ob=Pa;nb=Ma;while(1){qb=nb+-1|0;if((lb&255)<(h[ob+-2>>0]|0)){Ab=qb;Bb=1;break}else{Cb=nb;nb=qb;ob=Cb}}}b[yb>>0]=Bb;b[Ab>>0]=lb;if((pb|0)<-1){Db=mb;Eb=Ma}else continue;while(1){ob=b[Db>>0]|0;b[Db>>0]=b[Eb>>0]|0;b[Eb>>0]=ob;ob=Db+1|0;nb=Eb+-1|0;if(ob>>>0>>0){Db=ob;Eb=nb}else continue d}}if(((zb|0)==84?(zb=0,hb):0)?(kb=b[n>>0]|0,b[n>>0]=xb,b[Ma>>0]=kb,eb):0){kb=db;mb=la;do{pb=b[mb>>0]|0;b[mb>>0]=b[kb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q(Mb)}Mb=f[l>>2]|0;if(!Mb){u=i;return 1}E=l+4|0;l=f[E>>2]|0;if((l|0)!=(Mb|0))f[E>>2]=l+(~((l+-4-Mb|0)>>>2)<<2);Oq(Mb);u=i;return 1}function cb(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;b=u;u=u+16|0;c=b;d=b+8|0;e=b+4|0;f[d>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;h=g*210|0;f[e>>2]=a-h;i=0;j=g;g=(Hl(6952,7144,e,c)|0)-6952>>2;k=h;a:while(1){l=(f[6952+(g<<2)>>2]|0)+k|0;h=5;while(1){if(h>>>0>=47){m=211;n=i;o=8;break}p=f[6760+(h<<2)>>2]|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0

    >>0){o=106;break a}if((l|0)==(X(q,p)|0)){r=i;break}else h=h+1|0}b:do if((o|0)==8){c:while(1){o=0;h=(l>>>0)/(m>>>0)|0;do if(h>>>0>=m>>>0)if((l|0)!=(X(h,m)|0)){p=m+10|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0>=p>>>0)if((l|0)!=(X(q,p)|0)){q=m+12|0;s=(l>>>0)/(q>>>0)|0;if(s>>>0>=q>>>0)if((l|0)!=(X(s,q)|0)){s=m+16|0;t=(l>>>0)/(s>>>0)|0;if(t>>>0>=s>>>0)if((l|0)!=(X(t,s)|0)){t=m+18|0;v=(l>>>0)/(t>>>0)|0;if(v>>>0>=t>>>0)if((l|0)!=(X(v,t)|0)){v=m+22|0;w=(l>>>0)/(v>>>0)|0;if(w>>>0>=v>>>0)if((l|0)!=(X(w,v)|0)){w=m+28|0;x=(l>>>0)/(w>>>0)|0;if(x>>>0>=w>>>0)if((l|0)==(X(x,w)|0)){y=w;z=9;A=n}else{x=m+30|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+36|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+40|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+42|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+46|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+52|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+58|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+60|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+66|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+70|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+72|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+78|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+82|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+88|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+96|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+100|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+102|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+106|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+108|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+112|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+120|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+126|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+130|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+136|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+138|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+142|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+148|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+150|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+156|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+162|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+166|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+168|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+172|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+178|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+180|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+186|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+190|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+192|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+196|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+198|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+208|0;B=(l>>>0)/(x>>>0)|0;C=B>>>0>>0;D=(l|0)==(X(B,x)|0);y=C|D?x:m+210|0;z=C?1:D?9:0;A=C?l:n}else{y=w;z=1;A=l}}else{y=v;z=9;A=n}else{y=v;z=1;A=l}}else{y=t;z=9;A=n}else{y=t;z=1;A=l}}else{y=s;z=9;A=n}else{y=s;z=1;A=l}}else{y=q;z=9;A=n}else{y=q;z=1;A=l}}else{y=p;z=9;A=n}else{y=p;z=1;A=l}}else{y=m;z=9;A=n}else{y=m;z=1;A=l}while(0);switch(z&15){case 9:{r=A;break b;break}case 0:{m=y;n=A;o=8;break}default:break c}}if(!z)r=A;else{o=107;break a}}while(0);h=g+1|0;p=(h|0)==48;q=j+(p&1)|0;i=r;j=q;g=p?0:h;k=q*210|0}if((o|0)==106){f[d>>2]=l;E=l;break}else if((o|0)==107){f[d>>2]=l;E=A;break}}else{k=Hl(6760,6952,d,c)|0;E=f[k>>2]|0}while(0);u=b;return E|0}function db(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0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;kb=hb;hb=b[ub>>0]|0;if((hb&255)<(kb&255))break;if((ub|0)==(n|0)){vb=84;break d}else lb=ib}ib=Ka+lb|0;if((hb&255)<(tb&255)){wb=Fa;xb=tb}else{kb=Ka;jb=Fa;while(1){mb=jb+-1|0;if((hb&255)<(h[kb+-2>>0]|0)){wb=mb;xb=1;break}else{yb=jb;jb=mb;kb=yb}}}b[ub>>0]=xb;b[wb>>0]=hb;if((lb|0)<-1){zb=ib;Ab=Fa}else continue;while(1){kb=b[zb>>0]|0;b[zb>>0]=b[Ab>>0]|0;b[Ab>>0]=kb;kb=zb+1|0;jb=Ab+-1|0;if(kb>>>0>>0){zb=kb;Ab=jb}else continue d}}if(((vb|0)==84?(vb=0,db):0)?(gb=b[n>>0]|0,b[n>>0]=tb,b[Fa>>0]=gb,Ma):0){gb=La;ib=ka;do{lb=b[ib>>0]|0;b[ib>>0]=b[gb>>0]|0;b[gb>>0]=lb;ib=ib+1|0;gb=gb+-1|0}while(ib>>>0>>0)}if((fb|0)>=(Ia|0)){Wa=bb;Xa=na;Ya=bb;Za=na;_a=Ga;$a=Ha;ab=na;break}else fb=fb+1|0}}fb=f[Z>>2]|0;na=Vn(Na|0,Pa|0,fb|0,((fb|0)<0)<<31>>31|0)|0;fb=Oa;f[fb>>2]=na;f[fb+4>>2]=I;if(T){fb=f[ba>>2]|0;na=f[C>>2]|0;Ha=0;do{Ga=f[fb+(Ha<<2)>>2]|0;f[na+(Ha<<2)>>2]=Ga<<1^Ga>>31;Ha=Ha+1|0}while((Ha|0)!=(g|0));Bb=na}else Bb=f[C>>2]|0;lo(e,$,Bb,g);if((Ia|0)>0){Cb=a+40+(Da*12|0)|0;na=a+40+(Da*12|0)+4|0;Ha=a+40+(Da*12|0)+8|0;fb=0;do{Oa=f[na>>2]|0;Pa=f[Ha>>2]|0;Na=(Oa|0)==(Pa<<5|0);if(!(1<>0])){if(Na){if((Oa+1|0)<0){vb=95;break b}Ga=Pa<<6;bb=Oa+32&-32;vi(Cb,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>2]=0;do if(o){if((n|0)<0)aq(e);v=((o+-1|0)>>>5)+1|0;w=ln(v<<2)|0;f[e>>2]=w;f[t>>2]=v;f[s>>2]=o;v=o>>>5;sj(w|0,0,v<<2|0)|0;x=o&31;y=w+(v<<2)|0;if(x|0)f[y>>2]=f[y>>2]&~(-1>>>(32-x|0));if(o>>>0>2){x=a+12|0;y=a+32|0;v=a+52|0;w=a+56|0;z=a+48|0;A=b;B=k;C=0;D=q;E=r;a:while(1){F=B;G=C*3|0;if((G|0)!=-1){H=f[F+(G<<2)>>2]|0;I=G+1|0;J=((I>>>0)%3|0|0)==0?G+-2|0:I;if((J|0)==-1)K=-1;else K=f[F+(J<<2)>>2]|0;J=(((G>>>0)%3|0|0)==0?2:-1)+G|0;if((J|0)==-1)L=-1;else L=f[F+(J<<2)>>2]|0;if((H|0)!=(K|0)?!((H|0)==(L|0)|(K|0)==(L|0)):0){H=0;J=A;F=E;I=D;while(1){M=H+G|0;if(!(f[(f[e>>2]|0)+(M>>>5<<2)>>2]&1<<(M&31))){N=f[(f[a>>2]|0)+(M<<2)>>2]|0;f[g>>2]=N;if(!(f[F+(N>>>5<<2)>>2]&1<<(N&31))){O=0;P=J;Q=N}else{N=f[i>>2]|0;if((N|0)==(f[y>>2]|0))Ri(h,6140);else{f[N>>2]=-1;f[i>>2]=N+4}N=f[v>>2]|0;if((N|0)==(f[w>>2]|0))Ri(z,g);else{f[N>>2]=f[g>>2];f[v>>2]=N+4}N=f[l>>2]|0;R=f[j>>2]|0;if((N|0)==(R<<5|0)){if((N+1|0)<0){S=50;break a}T=R<<6;R=N+32&-32;vi(d,N>>>0<1073741823?(T>>>0>>0?R:T):2147483647);U=f[l>>2]|0}else U=N;f[l>>2]=U+1;N=(f[d>>2]|0)+(U>>>5<<2)|0;f[N>>2]=f[N>>2]&~(1<<(U&31));f[g>>2]=J;O=1;P=J+1|0;Q=J}N=f[d>>2]|0;T=N+(Q>>>5<<2)|0;f[T>>2]=f[T>>2]|1<<(Q&31);T=N;b:do if(O){R=M;while(1){if((R|0)==-1){S=64;break b}V=(f[e>>2]|0)+(R>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(R&31);V=f[g>>2]|0;f[(f[h>>2]|0)+(V<<2)>>2]=R;f[(f[a>>2]|0)+(R<<2)>>2]=V;V=R+1|0;W=((V>>>0)%3|0|0)==0?R+-2|0:V;do if((W|0)==-1)X=-1;else{V=f[(f[x>>2]|0)+(W<<2)>>2]|0;Y=V+1|0;if((V|0)==-1){X=-1;break}X=((Y>>>0)%3|0|0)==0?V+-2|0:Y}while(0);if((X|0)==(M|0))break;else R=X}}else{R=M;while(1){if((R|0)==-1){S=64;break b}W=(f[e>>2]|0)+(R>>>5<<2)|0;f[W>>2]=f[W>>2]|1<<(R&31);f[(f[h>>2]|0)+(f[g>>2]<<2)>>2]=R;W=R+1|0;Y=((W>>>0)%3|0|0)==0?R+-2|0:W;do if((Y|0)==-1)Z=-1;else{W=f[(f[x>>2]|0)+(Y<<2)>>2]|0;V=W+1|0;if((W|0)==-1){Z=-1;break}Z=((V>>>0)%3|0|0)==0?W+-2|0:V}while(0);if((Z|0)==(M|0))break;else R=Z}}while(0);c:do if((S|0)==64){S=0;if((M|0)==-1)break;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((R|0)==-1)break;Y=f[(f[x>>2]|0)+(R<<2)>>2]|0;if((Y|0)==-1)break;R=Y+(((Y>>>0)%3|0|0)==0?2:-1)|0;if((R|0)==-1)break;if(!O){Y=R;while(1){V=(f[e>>2]|0)+(Y>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(Y&31);V=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((V|0)==-1)break c;W=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((W|0)==-1)break c;Y=W+(((W>>>0)%3|0|0)==0?2:-1)|0;if((Y|0)==-1)break c}}Y=f[a>>2]|0;W=R;do{V=(f[e>>2]|0)+(W>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(W&31);f[Y+(W<<2)>>2]=f[g>>2];V=(((W>>>0)%3|0|0)==0?2:-1)+W|0;if((V|0)==-1)break c;_=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((_|0)==-1)break c;W=_+(((_>>>0)%3|0|0)==0?2:-1)|0}while((W|0)!=-1)}while(0);$=P;aa=T;ba=N}else{$=J;aa=I;ba=F}if((H|0)<2){H=H+1|0;J=$;F=ba;I=aa}else{ca=$;da=aa;ea=ba;break}}}else{ca=A;da=D;ea=E}}else{ca=A;da=D;ea=E}C=C+1|0;B=f[a>>2]|0;if(C>>>0>=(((f[m>>2]|0)-B>>2>>>0)/3|0)>>>0){S=18;break}else{A=ca;D=da;E=ea}}if((S|0)==18){fa=da;ga=f[l>>2]|0;break}else if((S|0)==50)aq(d)}else{fa=q;ga=p}}else{fa=q;ga=p}while(0);p=a+44|0;f[p>>2]=0;a=fa;fa=ga>>>5;q=a+(fa<<2)|0;S=ga&31;ga=(fa|0)!=0;d:do if(fa|S|0)if(!S){l=a;da=0;ea=ga;while(1){e:do if(ea){if(!(f[l>>2]&1)){ca=da+1|0;f[p>>2]=ca;ha=ca}else ha=da;if(!(f[l>>2]&2)){ca=ha+1|0;f[p>>2]=ca;ia=ca}else ia=ha;if(!(f[l>>2]&4)){ca=ia+1|0;f[p>>2]=ca;ja=ca}else ja=ia;if(!(f[l>>2]&8)){ca=ja+1|0;f[p>>2]=ca;ka=ca}else ka=ja;if(!(f[l>>2]&16)){ca=ka+1|0;f[p>>2]=ca;la=ca}else la=ka;if(!(f[l>>2]&32)){ca=la+1|0;f[p>>2]=ca;ma=ca}else ma=la;if(!(f[l>>2]&64)){ca=ma+1|0;f[p>>2]=ca;na=ca}else na=ma;if(!(f[l>>2]&128)){ca=na+1|0;f[p>>2]=ca;oa=ca}else oa=na;if(!(f[l>>2]&256)){ca=oa+1|0;f[p>>2]=ca;pa=ca}else pa=oa;if(!(f[l>>2]&512)){ca=pa+1|0;f[p>>2]=ca;qa=ca}else qa=pa;if(!(f[l>>2]&1024)){ca=qa+1|0;f[p>>2]=ca;ra=ca}else ra=qa;if(!(f[l>>2]&2048)){ca=ra+1|0;f[p>>2]=ca;sa=ca}else sa=ra;if(!(f[l>>2]&4096)){ca=sa+1|0;f[p>>2]=ca;ta=ca}else ta=sa;if(!(f[l>>2]&8192)){ca=ta+1|0;f[p>>2]=ca;ua=ca}else ua=ta;if(!(f[l>>2]&16384)){ca=ua+1|0;f[p>>2]=ca;va=ca}else va=ua;if(!(f[l>>2]&32768)){ca=va+1|0;f[p>>2]=ca;wa=ca}else wa=va;if(!(f[l>>2]&65536)){ca=wa+1|0;f[p>>2]=ca;xa=ca}else xa=wa;if(!(f[l>>2]&131072)){ca=xa+1|0;f[p>>2]=ca;ya=ca}else ya=xa;if(!(f[l>>2]&262144)){ca=ya+1|0;f[p>>2]=ca;za=ca}else za=ya;if(!(f[l>>2]&524288)){ca=za+1|0;f[p>>2]=ca;Aa=ca}else Aa=za;if(!(f[l>>2]&1048576)){ca=Aa+1|0;f[p>>2]=ca;Ba=ca}else Ba=Aa;if(!(f[l>>2]&2097152)){ca=Ba+1|0;f[p>>2]=ca;Ca=ca}else Ca=Ba;if(!(f[l>>2]&4194304)){ca=Ca+1|0;f[p>>2]=ca;Da=ca}else Da=Ca;if(!(f[l>>2]&8388608)){ca=Da+1|0;f[p>>2]=ca;Ea=ca}else Ea=Da;if(!(f[l>>2]&16777216)){ca=Ea+1|0;f[p>>2]=ca;Fa=ca}else Fa=Ea;if(!(f[l>>2]&33554432)){ca=Fa+1|0;f[p>>2]=ca;Ga=ca}else Ga=Fa;if(!(f[l>>2]&67108864)){ca=Ga+1|0;f[p>>2]=ca;Ha=ca}else Ha=Ga;if(!(f[l>>2]&134217728)){ca=Ha+1|0;f[p>>2]=ca;Ia=ca}else Ia=Ha;if(!(f[l>>2]&268435456)){ca=Ia+1|0;f[p>>2]=ca;Ja=ca}else Ja=Ia;if(!(f[l>>2]&536870912)){ca=Ja+1|0;f[p>>2]=ca;Ka=ca}else Ka=Ja;if(!(f[l>>2]&1073741824)){ca=Ka+1|0;f[p>>2]=ca;La=ca}else La=Ka;if((f[l>>2]|0)<=-1){Ma=La;break}ca=La+1|0;f[p>>2]=ca;Ma=ca}else{ca=0;m=da;while(1){if(!(f[l>>2]&1<>2]=ba;Na=ba}else Na=m;if((ca|0)==31){Ma=Na;break e}ca=ca+1|0;if(!ca)break d;else m=Na}}while(0);l=l+4|0;if((q|0)==(l|0))break;else{da=Ma;ea=1}}}else{if(ga){ea=0;da=a;l=0;while(1){if(!(f[da>>2]&1)){m=l+1|0;f[p>>2]=m;Oa=m;Pa=m}else{Oa=l;Pa=ea}if(!(f[da>>2]&2)){m=Oa+1|0;f[p>>2]=m;Qa=m;Ra=m}else{Qa=Oa;Ra=Pa}if(!(f[da>>2]&4)){m=Qa+1|0;f[p>>2]=m;Sa=m;Ta=m}else{Sa=Qa;Ta=Ra}if(!(f[da>>2]&8)){m=Sa+1|0;f[p>>2]=m;Ua=m;Va=m}else{Ua=Sa;Va=Ta}if(!(f[da>>2]&16)){m=Ua+1|0;f[p>>2]=m;Wa=m;Xa=m}else{Wa=Ua;Xa=Va}if(!(f[da>>2]&32)){m=Wa+1|0;f[p>>2]=m;Ya=m;Za=m}else{Ya=Wa;Za=Xa}if(!(f[da>>2]&64)){m=Ya+1|0;f[p>>2]=m;_a=m;$a=m}else{_a=Ya;$a=Za}if(!(f[da>>2]&128)){m=_a+1|0;f[p>>2]=m;ab=m;bb=m}else{ab=_a;bb=$a}if(!(f[da>>2]&256)){m=ab+1|0;f[p>>2]=m;cb=m;db=m}else{cb=ab;db=bb}if(!(f[da>>2]&512)){m=cb+1|0;f[p>>2]=m;eb=m;fb=m}else{eb=cb;fb=db}if(!(f[da>>2]&1024)){m=eb+1|0;f[p>>2]=m;gb=m;hb=m}else{gb=eb;hb=fb}if(!(f[da>>2]&2048)){m=gb+1|0;f[p>>2]=m;ib=m;jb=m}else{ib=gb;jb=hb}if(!(f[da>>2]&4096)){m=ib+1|0;f[p>>2]=m;kb=m;lb=m}else{kb=ib;lb=jb}if(!(f[da>>2]&8192)){m=kb+1|0;f[p>>2]=m;mb=m;nb=m}else{mb=kb;nb=lb}if(!(f[da>>2]&16384)){m=mb+1|0;f[p>>2]=m;ob=m;pb=m}else{ob=mb;pb=nb}if(!(f[da>>2]&32768)){m=ob+1|0;f[p>>2]=m;qb=m;rb=m}else{qb=ob;rb=pb}if(!(f[da>>2]&65536)){m=qb+1|0;f[p>>2]=m;sb=m;tb=m}else{sb=qb;tb=rb}if(!(f[da>>2]&131072)){m=sb+1|0;f[p>>2]=m;ub=m;vb=m}else{ub=sb;vb=tb}if(!(f[da>>2]&262144)){m=ub+1|0;f[p>>2]=m;wb=m;xb=m}else{wb=ub;xb=vb}if(!(f[da>>2]&524288)){m=wb+1|0;f[p>>2]=m;yb=m;zb=m}else{yb=wb;zb=xb}if(!(f[da>>2]&1048576)){m=yb+1|0;f[p>>2]=m;Ab=m;Bb=m}else{Ab=yb;Bb=zb}if(!(f[da>>2]&2097152)){m=Ab+1|0;f[p>>2]=m;Cb=m;Db=m}else{Cb=Ab;Db=Bb}if(!(f[da>>2]&4194304)){m=Cb+1|0;f[p>>2]=m;Eb=m;Fb=m}else{Eb=Cb;Fb=Db}if(!(f[da>>2]&8388608)){m=Eb+1|0;f[p>>2]=m;Gb=m;Hb=m}else{Gb=Eb;Hb=Fb}if(!(f[da>>2]&16777216)){m=Gb+1|0;f[p>>2]=m;Ib=m;Jb=m}else{Ib=Gb;Jb=Hb}if(!(f[da>>2]&33554432)){m=Ib+1|0;f[p>>2]=m;Kb=m;Lb=m}else{Kb=Ib;Lb=Jb}if(!(f[da>>2]&67108864)){m=Kb+1|0;f[p>>2]=m;Mb=m;Nb=m}else{Mb=Kb;Nb=Lb}if(!(f[da>>2]&134217728)){m=Mb+1|0;f[p>>2]=m;Ob=m;Pb=m}else{Ob=Mb;Pb=Nb}if(!(f[da>>2]&268435456)){m=Ob+1|0;f[p>>2]=m;Qb=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|0,~~Ta>>>0|0,(+K(Ta)>=1.0?(Ta>0.0?~~+Y(+J(Ta/4294967296.0),4294967295.0)>>>0:~~+W((Ta-+(~~Ta>>>0))/4294967296.0)>>>0):0)|0)|0;nb=f[r>>2]|0;if(!((nb|0)<=(jb|0)?!((nb|0)>=(jb|0)?(tb|0)<(f[T>>2]|0):0):0)){nb=r;f[nb>>2]=jb;f[nb+4>>2]=tb;b[U>>0]=qb;f[V>>2]=hb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[j>>2]=f[v>>2];f[e>>2]=f[w>>2];Jf($,j,e);f[x>>2]=Ca;f[y>>2]=Ma;f[j>>2]=f[x>>2];f[e>>2]=f[y>>2];Jf(aa,j,e)}if(Ia)break;vb=b[Ka>>0]|0;nb=-1;jb=vb;while(1){kb=nb+-1|0;wb=Na+kb|0;mb=jb;jb=b[wb>>0]|0;if((jb&255)<(mb&255))break;if((wb|0)==(n|0)){xb=84;break d}else nb=kb}kb=Na+nb|0;if((jb&255)<(vb&255)){yb=Ka;zb=vb}else{mb=Na;lb=Ka;while(1){ob=lb+-1|0;if((jb&255)<(h[mb+-2>>0]|0)){yb=ob;zb=1;break}else{Ab=lb;lb=ob;mb=Ab}}}b[wb>>0]=zb;b[yb>>0]=jb;if((nb|0)<-1){Bb=kb;Cb=Ka}else continue;while(1){mb=b[Bb>>0]|0;b[Bb>>0]=b[Cb>>0]|0;b[Cb>>0]=mb;mb=Bb+1|0;lb=Cb+-1|0;if(mb>>>0>>0){Bb=mb;Cb=lb}else continue d}}if(((xb|0)==84?(xb=0,fb):0)?(ib=b[n>>0]|0,b[n>>0]=vb,b[Ka>>0]=ib,cb):0){ib=bb;kb=ja;do{nb=b[kb>>0]|0;b[kb>>0]=b[ib>>0]|0;b[ib>>0]=nb;kb=kb+1|0;ib=ib+-1|0}while(kb>>>0>>0)}if((hb|0)>=(Fa|0)){Wa=db;Xa=Da;Ya=db;Za=Da;_a=Ma;$a=Ca;ab=Da;break}else hb=hb+1|0}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+11|0;N=d+4|0;O=h+8|0;P=a+40|0;Q=a+44|0;R=a+36|0;S=a+64|0;T=a+68|0;U=a+60|0;V=g+8|0;W=g+20|0;X=e+8|0;Y=e+4|0;Z=e+11|0;_=g+4|0;aa=g+8|0;ba=h+4|0;ca=h+8|0;da=h+8|0;ea=a+52|0;fa=a+56|0;ga=a+48|0;a=g+8|0;ha=0;ia=t;t=l;l=k;a:while(1){k=f[ia+(ha<<2)>>2]|0;ja=f[(f[t+8>>2]|0)+(k<<2)>>2]|0;switch(f[ja+28>>2]|0){case 9:{f[g>>2]=1196;f[s>>2]=-1;f[r>>2]=0;f[r+4>>2]=0;f[r+8>>2]=0;f[r+12>>2]=0;ka=f[l+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;la=ln(32)|0;f[d>>2]=la;f[x>>2]=-2147483616;f[q>>2]=17;ma=la;na=14495;oa=ma+17|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[la+17>>0]=0;pa=ka+16|0;qa=f[pa>>2]|0;if(qa){ra=pa;sa=qa;b:while(1){qa=sa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;ta=f[qa+4>>2]|0;if(!ta){ua=ra;break b}else qa=ta}sa=f[qa>>2]|0;if(!sa){ua=qa;break}else ra=qa}if(((ua|0)!=(pa|0)?(k|0)>=(f[ua+16>>2]|0):0)?(ra=ua+20|0,(Jh(ra,d)|0)!=0):0)va=Hk(ra,d,-1)|0;else wa=17}else wa=17;if((wa|0)==17){wa=0;va=Hk(ka,d,-1)|0}if((b[w>>0]|0)<0)Oq(f[d>>2]|0);if((va|0)<1)xa=1;else{ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;sa=ln(32)|0;f[d>>2]=sa;f[z>>2]=-2147483616;f[A>>2]=19;ma=sa;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[sa+19>>0]=0;ka=ra+16|0;pa=f[ka>>2]|0;if(pa){la=ka;ta=pa;c:while(1){pa=ta;while(1){if((f[pa+16>>2]|0)>=(k|0))break;ya=f[pa+4>>2]|0;if(!ya){za=la;break c}else pa=ya}ta=f[pa>>2]|0;if(!ta){za=pa;break}else la=pa}if((za|0)!=(ka|0)?(k|0)>=(f[za+16>>2]|0):0)Aa=za+20|0;else wa=29}else wa=29;if((wa|0)==29){wa=0;Aa=ra}if(!(Jh(Aa,d)|0))Ba=0;else{la=f[(f[j>>2]|0)+48>>2]|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;ta=ln(32)|0;f[e>>2]=ta;f[X>>2]=-2147483616;f[Y>>2]=18;ma=ta;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ta+18>>0]=0;ra=la+16|0;ka=f[ra>>2]|0;if(ka){sa=ra;qa=ka;d:while(1){ka=qa;while(1){if((f[ka+16>>2]|0)>=(k|0))break;ya=f[ka+4>>2]|0;if(!ya){Ca=sa;break d}else ka=ya}qa=f[ka>>2]|0;if(!qa){Ca=ka;break}else sa=ka}if((Ca|0)!=(ra|0)?(k|0)>=(f[Ca+16>>2]|0):0)Da=Ca+20|0;else wa=39}else wa=39;if((wa|0)==39){wa=0;Da=la}sa=(Jh(Da,e)|0)!=0;if((b[Z>>0]|0)<0)Oq(f[e>>2]|0);Ba=sa}if((b[B>>0]|0)<0)Oq(f[d>>2]|0);if(Ba){sa=ja+24|0;qa=b[sa>>0]|0;ta=qa<<24>>24;f[h>>2]=0;f[C>>2]=0;f[D>>2]=0;if(!(qa<<24>>24))Ea=0;else{if(qa<<24>>24<0){wa=48;break a}qa=ta<<2;pa=ln(qa)|0;f[h>>2]=pa;ya=pa+(ta<<2)|0;f[O>>2]=ya;sj(pa|0,0,qa|0)|0;f[C>>2]=ya;Ea=pa}pa=f[(f[j>>2]|0)+48>>2]|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;ya=ln(32)|0;f[i>>2]=ya;f[E>>2]=-2147483616;f[F>>2]=19;ma=ya;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+19>>0]=0;la=b[sa>>0]|0;ra=la<<24>>24;qa=pa+16|0;ta=f[qa>>2]|0;if(ta){Fa=qa;Ga=ta;e:while(1){ta=Ga;while(1){if((f[ta+16>>2]|0)>=(k|0))break;Ha=f[ta+4>>2]|0;if(!Ha){Ia=Fa;break e}else ta=Ha}Ga=f[ta>>2]|0;if(!Ga){Ia=ta;break}else Fa=ta}if(((Ia|0)!=(qa|0)?(k|0)>=(f[Ia+16>>2]|0):0)?(Fa=Ia+20|0,(Jh(Fa,i)|0)!=0):0){Ga=Rg(Fa,i)|0;if((Ga|0)!=(Ia+24|0)){pj(d,Ga+28|0);Ga=b[M>>0]|0;Fa=Ga<<24>>24<0;if(!((Fa?f[N>>2]|0:Ga&255)|0))Ja=Ga;else{if(la<<24>>24>0){ya=Fa?f[d>>2]|0:d;Fa=0;do{Ka=$(bq(ya,e));ka=ya;ya=f[e>>2]|0;if((ka|0)==(ya|0))break;n[Ea+(Fa<<2)>>2]=Ka;Fa=Fa+1|0}while((Fa|0)<(ra|0));La=b[M>>0]|0}else La=Ga;Ja=La}if(Ja<<24>>24<0)Oq(f[d>>2]|0)}}else wa=69}else wa=69;if((wa|0)==69?(wa=0,Fa=Rg(pa,i)|0,(Fa|0)!=(pa+4|0)):0){pj(d,Fa+28|0);Fa=b[G>>0]|0;ya=Fa<<24>>24<0;if(!((ya?f[H>>2]|0:Fa&255)|0))Ma=Fa;else{if(la<<24>>24>0){qa=ya?f[d>>2]|0:d;ya=0;do{Ka=$(bq(qa,e));ka=qa;qa=f[e>>2]|0;if((ka|0)==(qa|0))break;n[Ea+(ya<<2)>>2]=Ka;ya=ya+1|0}while((ya|0)<(ra|0));Na=b[G>>0]|0}else Na=Fa;Ma=Na}if(Ma<<24>>24<0)Oq(f[d>>2]|0)}if((b[I>>0]|0)<0)Oq(f[i>>2]|0);ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;ya=ln(32)|0;f[d>>2]=ya;f[J>>2]=-2147483616;f[K>>2]=18;ma=ya;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+18>>0]=0;na=ra+16|0;ma=f[na>>2]|0;do if(ma){oa=na;Fa=ma;f:while(1){qa=Fa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;la=f[qa+4>>2]|0;if(!la){Pa=oa;break f}else qa=la}Fa=f[qa>>2]|0;if(!Fa){Pa=qa;break}else oa=qa}if((Pa|0)!=(na|0)?(k|0)>=(f[Pa+16>>2]|0):0){oa=Pa+20|0;if(!(Jh(oa,d)|0)){wa=91;break}Qa=$(sk(oa,d,$(1.0)))}else wa=91}else wa=91;while(0);if((wa|0)==91){wa=0;Qa=$(sk(ra,d,$(1.0)))}if((b[L>>0]|0)<0)Oq(f[d>>2]|0);Dl(g,va,f[h>>2]|0,b[sa>>0]|0,Qa);k=f[h>>2]|0;if(k|0){na=f[C>>2]|0;if((na|0)!=(k|0))f[C>>2]=na+(~((na+-4-k|0)>>>2)<<2);Oq(k)}}else Wd(g,ja,va)|0;k=f[P>>2]|0;if((k|0)==(f[Q>>2]|0))Cf(R,g);else{f[k>>2]=1196;f[k+4>>2]=f[s>>2];Ra=k+8|0;f[Ra>>2]=0;na=k+12|0;f[na>>2]=0;f[k+16>>2]=0;ma=(f[y>>2]|0)-(f[V>>2]|0)|0;ya=ma>>2;if(ya|0){if(ya>>>0>1073741823){wa=103;break a}oa=ln(ma)|0;f[na>>2]=oa;f[Ra>>2]=oa;f[k+16>>2]=oa+(ya<<2);ya=f[V>>2]|0;ma=(f[y>>2]|0)-ya|0;if((ma|0)>0){kh(oa|0,ya|0,ma|0)|0;f[na>>2]=oa+(ma>>>2<<2)}}f[k+20>>2]=f[W>>2];f[P>>2]=(f[P>>2]|0)+24}Qe(d,g,ja,m);k=f[S>>2]|0;if(k>>>0<(f[T>>2]|0)>>>0){ma=f[d>>2]|0;f[d>>2]=0;f[k>>2]=ma;f[S>>2]=k+4}else Ze(U,d);k=f[d>>2]|0;f[d>>2]=0;if(k|0){ma=k+88|0;oa=f[ma>>2]|0;f[ma>>2]=0;if(oa|0){ma=f[oa+8>>2]|0;if(ma|0){na=oa+12|0;if((f[na>>2]|0)!=(ma|0))f[na>>2]=ma;Oq(ma)}Oq(oa)}oa=f[k+68>>2]|0;if(oa|0){ma=k+72|0;na=f[ma>>2]|0;if((na|0)!=(oa|0))f[ma>>2]=na+(~((na+-4-oa|0)>>>2)<<2);Oq(oa)}oa=k+64|0;na=f[oa>>2]|0;f[oa>>2]=0;if(na|0){oa=f[na>>2]|0;if(oa|0){ma=na+4|0;if((f[ma>>2]|0)!=(oa|0))f[ma>>2]=oa;Oq(oa)}Oq(na)}Oq(k)}xa=0}f[g>>2]=1196;k=f[r>>2]|0;if(k|0){na=f[y>>2]|0;if((na|0)!=(k|0))f[y>>2]=na+(~((na+-4-k|0)>>>2)<<2);Oq(k)}if(xa|0){v=0;wa=169;break a}break}case 1:case 3:case 5:{k=ja+24|0;na=b[k>>0]|0;oa=na<<24>>24;f[g>>2]=0;f[_>>2]=0;f[aa>>2]=0;if(!(na<<24>>24))Sa=0;else{if(na<<24>>24<0){wa=137;break a}na=ln(oa<<2)|0;f[_>>2]=na;f[g>>2]=na;ma=na+(oa<<2)|0;f[a>>2]=ma;ya=oa;oa=na;while(1){f[oa>>2]=2147483647;ya=ya+-1|0;if(!ya)break;else oa=oa+4|0}f[_>>2]=ma;Sa=b[k>>0]|0}oa=Sa<<24>>24;f[h>>2]=0;f[ba>>2]=0;f[ca>>2]=0;if(!(Sa<<24>>24))Ta=0;else{if(Sa<<24>>24<0){wa=144;break a}ya=oa<<2;sa=ln(ya)|0;f[h>>2]=sa;ra=sa+(oa<<2)|0;f[da>>2]=ra;sj(sa|0,0,ya|0)|0;f[ba>>2]=ra;Ta=sa}sa=ja+80|0;ra=b[k>>0]|0;g:do if(!(f[sa>>2]|0))Ua=ra;else{ya=0;oa=ra;na=Ta;while(1){f[e>>2]=ya;f[d>>2]=f[e>>2];Qb(ja,d,oa,na)|0;Fa=b[k>>0]|0;if(Fa<<24>>24>0){ta=f[g>>2]|0;la=f[h>>2]|0;pa=Fa<<24>>24;Ga=0;do{ka=ta+(Ga<<2)|0;Ha=f[la+(Ga<<2)>>2]|0;if((f[ka>>2]|0)>(Ha|0))f[ka>>2]=Ha;Ga=Ga+1|0}while((Ga|0)<(pa|0))}pa=ya+1|0;if(pa>>>0>=(f[sa>>2]|0)>>>0){Ua=Fa;break g}ya=pa;oa=Fa;na=f[h>>2]|0}}while(0);if(Ua<<24>>24>0){sa=0;ja=Ua;while(1){ra=(f[g>>2]|0)+(sa<<2)|0;ma=f[ea>>2]|0;if((ma|0)==(f[fa>>2]|0)){Ri(ga,ra);Va=b[k>>0]|0}else{f[ma>>2]=f[ra>>2];f[ea>>2]=ma+4;Va=ja}sa=sa+1|0;if((sa|0)>=(Va<<24>>24|0))break;else ja=Va}}ja=f[h>>2]|0;if(ja|0){sa=f[ba>>2]|0;if((sa|0)!=(ja|0))f[ba>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}ja=f[g>>2]|0;if(ja|0){sa=f[_>>2]|0;if((sa|0)!=(ja|0))f[_>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}break}default:{}}ja=ha+1|0;sa=f[o>>2]|0;if(ja>>>0>=(f[p>>2]|0)-sa>>2>>>0){v=1;wa=169;break}k=f[j>>2]|0;ha=ja;ia=sa;t=f[k+4>>2]|0;l=k}if((wa|0)==48)aq(h);else if((wa|0)==103)aq(Ra);else if((wa|0)==137)aq(g);else if((wa|0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>>2]|0;V=(S>>>0)%113|0;S=f[U+(V*36|0)>>2]|0;W=f[U+(V*36|0)+12>>2]|0;Y=f[U+(V*36|0)+24>>2]|0;Z=f[U+(V*36|0)+32>>2]|0;f[l>>2]=R;R=f[o>>2]|0;V=R-T>>2;if((1-Q-z+((V|0)==0?0:(V*113|0)+-1|0)|0)>>>0>225){Oq(f[R+-4>>2]|0);f[o>>2]=(f[o>>2]|0)+-4}f[b>>2]=S;f[c>>2]=W;R=f[k>>2]|0;V=((f[g>>2]|0)+-1|0)==(Y|0)?0:Y+1|0;Y=(f[s>>2]|0)+(Z*12|0)|0;z=W-S|0;T=(f[a>>2]|0)-(f[(f[Y>>2]|0)+(V<<2)>>2]|0)|0;a:do if(T){if(z>>>0<3){U=f[w>>2]|0;f[U>>2]=V;$=f[g>>2]|0;if($>>>0>1){aa=1;ba=$;ca=V;while(1){ca=(ca|0)==(ba+-1|0)?0:ca+1|0;f[U+(aa<<2)>>2]=ca;aa=aa+1|0;da=f[g>>2]|0;if(aa>>>0>=da>>>0){ea=da;break}else ba=da}}else ea=$;if(!z){fa=99;break}else{ga=0;ha=ea}while(1){ba=(f[N>>2]|0)+((X(f[M>>2]|0,S+ga|0)|0)<<2)|0;if(!ha)ia=0;else{aa=0;do{ca=f[(f[w>>2]|0)+(aa<<2)>>2]|0;U=(f[a>>2]|0)-(f[(f[Y>>2]|0)+(ca<<2)>>2]|0)|0;do if(U|0){da=f[y>>2]|0;ja=32-da|0;ka=32-U|0;la=f[ba+(ca<<2)>>2]<(ja|0)){ma=la>>>ka;ka=U-ja|0;f[y>>2]=ka;ja=f[h>>2]|ma>>>ka;f[h>>2]=ja;ka=f[j>>2]|0;if((ka|0)==(f[m>>2]|0))Ri(n,h);else{f[ka>>2]=ja;f[j>>2]=ka+4}f[h>>2]=ma<<32-(f[y>>2]|0);break}ma=f[h>>2]|la>>>da;f[h>>2]=ma;la=da+U|0;f[y>>2]=la;if((la|0)!=32)break;la=f[j>>2]|0;if((la|0)==(f[m>>2]|0))Ri(n,h);else{f[la>>2]=ma;f[j>>2]=la+4}f[h>>2]=0;f[y>>2]=0}while(0);aa=aa+1|0;U=f[g>>2]|0}while(aa>>>0>>0);ia=U}ga=ga+1|0;if(ga>>>0>=z>>>0){fa=99;break a}else ha=ia}}$=Z+1|0;Ig(R+($*12|0)|0,f[R+(Z*12|0)>>2]|0,f[R+(Z*12|0)+4>>2]|0);aa=(f[(f[k>>2]|0)+($*12|0)>>2]|0)+(V<<2)|0;ba=(f[aa>>2]|0)+(1<>2]=ba;aa=f[A>>2]|0;U=f[B>>2]|0;b:do if((W|0)==(S|0))na=S;else{ca=f[O>>2]|0;if(!aa){if((f[ca+(V<<2)>>2]|0)>>>0>>0){na=W;break}else{oa=W;pa=S}while(1){la=oa;do{la=la+-1|0;if((pa|0)==(la|0)){na=pa;break b}ma=(f[P>>2]|0)+((X(la,U)|0)<<2)+(V<<2)|0}while((f[ma>>2]|0)>>>0>=ba>>>0);pa=pa+1|0;if((pa|0)==(la|0)){na=la;break b}else oa=la}}else{qa=W;ra=S}while(1){ma=ra;while(1){sa=ca+((X(ma,aa)|0)<<2)|0;if((f[sa+(V<<2)>>2]|0)>>>0>=ba>>>0){ta=qa;break}da=ma+1|0;if((da|0)==(qa|0)){na=qa;break b}else ma=da}while(1){ta=ta+-1|0;if((ma|0)==(ta|0)){na=ma;break b}ua=(f[P>>2]|0)+((X(ta,U)|0)<<2)|0;if((f[ua+(V<<2)>>2]|0)>>>0>>0){va=0;break}}do{la=sa+(va<<2)|0;da=ua+(va<<2)|0;ka=f[la>>2]|0;f[la>>2]=f[da>>2];f[da>>2]=ka;va=va+1|0}while((va|0)!=(aa|0));ra=ma+1|0;if((ra|0)==(ta|0)){na=ta;break}else qa=ta}}while(0);ba=(_(z|0)|0)^31;U=na-S|0;ca=W-na|0;ka=U>>>0>>0;if((U|0)!=(ca|0)){da=f[H>>2]|0;if(ka)f[I>>2]=f[I>>2]|1<<31-da;la=da+1|0;f[H>>2]=la;if((la|0)==32){la=f[J>>2]|0;if((la|0)==(f[K>>2]|0))Ri(L,I);else{f[la>>2]=f[I>>2];f[J>>2]=la+4}f[H>>2]=0;f[I>>2]=0}}la=z>>>1;do if(ka){da=f[C>>2]|0;ja=32-da|0;wa=32-ba|0;xa=la-U<(ja|0)){ya=xa>>>wa;wa=ba-ja|0;f[C>>2]=wa;ja=f[D>>2]|ya>>>wa;f[D>>2]=ja;wa=f[E>>2]|0;if((wa|0)==(f[F>>2]|0))Ri(G,D);else{f[wa>>2]=ja;f[E>>2]=wa+4}f[D>>2]=ya<<32-(f[C>>2]|0);break}ya=f[D>>2]|xa>>>da;f[D>>2]=ya;xa=da+ba|0;f[C>>2]=xa;if((xa|0)==32){xa=f[E>>2]|0;if((xa|0)==(f[F>>2]|0))Ri(G,D);else{f[xa>>2]=ya;f[E>>2]=xa+4}f[D>>2]=0;f[C>>2]=0}}else{xa=f[C>>2]|0;ya=32-xa|0;da=32-ba|0;wa=la-ca<(ya|0)){ja=wa>>>da;da=ba-ya|0;f[C>>2]=da;ya=f[D>>2]|ja>>>da;f[D>>2]=ya;da=f[E>>2]|0;if((da|0)==(f[F>>2]|0))Ri(G,D);else{f[da>>2]=ya;f[E>>2]=da+4}f[D>>2]=ja<<32-(f[C>>2]|0);break}ja=f[D>>2]|wa>>>xa;f[D>>2]=ja;wa=xa+ba|0;f[C>>2]=wa;if((wa|0)==32){wa=f[E>>2]|0;if((wa|0)==(f[F>>2]|0))Ri(G,D);else{f[wa>>2]=ja;f[E>>2]=wa+4}f[D>>2]=0;f[C>>2]=0}}while(0);ba=f[s>>2]|0;la=f[ba+(Z*12|0)>>2]|0;ka=la+(V<<2)|0;f[ka>>2]=(f[ka>>2]|0)+1;Ig(ba+($*12|0)|0,la,f[ba+(Z*12|0)+4>>2]|0);if((na|0)!=(S|0)){ba=f[o>>2]|0;la=f[t>>2]|0;ka=ba-la>>2;wa=f[v>>2]|0;ja=f[l>>2]|0;if((((ka|0)==0?0:(ka*113|0)+-1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)==($+-1|0)?0:aa+1|0;f[W+(Z<<2)>>2]=aa;Z=Z+1|0;ba=f[i>>2]|0;if(Z>>>0>=ba>>>0){ca=ba;break}else $=ba}}else ca=Y;if(!U){da=87;break}else{ea=0;fa=ca}while(1){$=(f[K>>2]|0)+((X(f[J>>2]|0,P+ea|0)|0)<<2)|0;if(!fa)ga=0;else{Z=0;do{aa=f[(f[y>>2]|0)+(Z<<2)>>2]|0;W=(f[a>>2]|0)-(f[(f[B>>2]|0)+(aa<<2)>>2]|0)|0;do if(W|0){ba=f[A>>2]|0;ha=32-ba|0;ia=32-W|0;ja=f[$+(aa<<2)>>2]<(ha|0)){ka=ja>>>ia;ia=W-ha|0;f[A>>2]=ia;ha=f[j>>2]|ka>>>ia;f[j>>2]=ha;ia=f[l>>2]|0;if((ia|0)==(f[o>>2]|0))Ri(p,j);else{f[ia>>2]=ha;f[l>>2]=ia+4}f[j>>2]=ka<<32-(f[A>>2]|0);break}ka=f[j>>2]|ja>>>ba;f[j>>2]=ka;ja=ba+W|0;f[A>>2]=ja;if((ja|0)!=32)break;ja=f[l>>2]|0;if((ja|0)==(f[o>>2]|0))Ri(p,j);else{f[ja>>2]=ka;f[l>>2]=ja+4}f[j>>2]=0;f[A>>2]=0}while(0);Z=Z+1|0;W=f[i>>2]|0}while(Z>>>0>>0);ga=W}ea=ea+1|0;if(ea>>>0>=U>>>0){da=87;break a}else fa=ga}}Y=V+1|0;Z=f[m>>2]|0;$=Z+(Y*12|0)|0;if(($|0)==(S|0))la=Z;else{Ig($,f[S>>2]|0,f[O+(V*12|0)+4>>2]|0);la=f[m>>2]|0}$=(f[la+(Y*12|0)>>2]|0)+(Q<<2)|0;Z=(f[$>>2]|0)+(1<>2]=Z;$=f[C>>2]|0;W=f[D>>2]|0;b:do if((T|0)==(P|0))ma=P;else{aa=f[L>>2]|0;if(!$){if((f[aa+(Q<<2)>>2]|0)>>>0>>0){ma=T;break}else{na=T;oa=P}while(1){ja=na;do{ja=ja+-1|0;if((oa|0)==(ja|0)){ma=oa;break b}ka=(f[M>>2]|0)+((X(ja,W)|0)<<2)+(Q<<2)|0}while((f[ka>>2]|0)>>>0>=Z>>>0);oa=oa+1|0;if((oa|0)==(ja|0)){ma=ja;break b}else na=ja}}else{pa=T;qa=P}while(1){ka=qa;while(1){ra=aa+((X(ka,$)|0)<<2)|0;if((f[ra+(Q<<2)>>2]|0)>>>0>=Z>>>0){sa=pa;break}ba=ka+1|0;if((ba|0)==(pa|0)){ma=pa;break b}else ka=ba}while(1){sa=sa+-1|0;if((ka|0)==(sa|0)){ma=ka;break b}ta=(f[M>>2]|0)+((X(sa,W)|0)<<2)|0;if((f[ta+(Q<<2)>>2]|0)>>>0>>0){ua=0;break}}do{ja=ra+(ua<<2)|0;ba=ta+(ua<<2)|0;ia=f[ja>>2]|0;f[ja>>2]=f[ba>>2];f[ba>>2]=ia;ua=ua+1|0}while((ua|0)!=($|0));qa=ka+1|0;if((qa|0)==(sa|0)){ma=sa;break}else pa=sa}}while(0);Z=(_(U|0)|0)^31;W=ma-P|0;aa=T-ma|0;ia=W>>>0>>0;if((W|0)!=(aa|0)){ba=f[E>>2]|0;if(ia)f[F>>2]=f[F>>2]|1<<31-ba;ja=ba+1|0;f[E>>2]=ja;if((ja|0)==32){ja=f[G>>2]|0;if((ja|0)==(f[H>>2]|0))Ri(I,F);else{f[ja>>2]=f[F>>2];f[G>>2]=ja+4}f[E>>2]=0;f[F>>2]=0}}ja=U>>>1;if(ia){ia=ja-W|0;if(Z|0){ba=0;ha=1<>>1}}}else{ha=ja-aa|0;if(Z|0){ba=0;ia=1<>>1}}}ia=f[v>>2]|0;Z=f[ia+(V*12|0)>>2]|0;ba=Z+(Q<<2)|0;f[ba>>2]=(f[ba>>2]|0)+1;Ig(ia+(Y*12|0)|0,Z,f[ia+(V*12|0)+4>>2]|0);if((ma|0)!=(P|0)){ia=f[q>>2]|0;Z=f[w>>2]|0;ba=ia-Z>>2;ha=f[x>>2]|0;ja=f[n>>2]|0;if((((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360|0;o=d+1348|0;p=d+1336|0;q=d+1324|0;r=d+1312|0;s=d+1300|0;t=d+1288|0;v=d+1276|0;w=d+1264|0;x=d+1252|0;y=d+1240|0;z=d+1228|0;A=a+28|0;B=10-(mi(f[(f[A>>2]|0)+48>>2]|0)|0)|0;C=(B|0)<6?B:6;b[h>>0]=C;if((C&255|0)==6?(f[a+72>>2]|0)>15:0)b[h>>0]=5;C=c+16|0;B=f[C+4>>2]|0;if(!((B|0)>0|(B|0)==0&(f[C>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}C=f[A>>2]|0;B=f[(f[C+4>>2]|0)+80>>2]|0;D=a+72|0;E=f[D>>2]|0;f[i>>2]=B;F=i+4|0;f[F>>2]=E;f[i+8>>2]=E<<2;G=i+12|0;H=X(E,B)|0;f[G>>2]=0;J=i+16|0;f[J>>2]=0;f[i+20>>2]=0;do if(H)if(H>>>0>1073741823)aq(G);else{K=H<<2;L=ln(K)|0;f[G>>2]=L;M=L+(H<<2)|0;f[i+20>>2]=M;sj(L|0,0,K|0)|0;f[J>>2]=M;N=L;break}else N=0;while(0);H=i+24|0;f[H>>2]=N;G=a+4|0;L=a+8|0;M=f[G>>2]|0;a:do if((f[L>>2]|0)!=(M|0)){K=j+4|0;O=j+8|0;P=j+8|0;Q=(B|0)==0;R=j+4|0;S=j+8|0;T=k+4|0;U=k+8|0;V=k+8|0;W=a+48|0;Y=j+8|0;Z=a+60|0;$=0;aa=0;ba=0;ca=0;da=M;ea=C;b:while(1){fa=f[(f[(f[ea+4>>2]|0)+8>>2]|0)+(f[da+(ca<<2)>>2]<<2)>>2]|0;switch(f[fa+28>>2]|0){case 1:case 3:case 5:case 2:case 4:case 6:{ga=fa;ha=aa;break}case 9:{ga=f[(f[Z>>2]|0)+(aa<<2)>>2]|0;ha=aa+1|0;break}default:{ia=0;break a}}if(!ga){ia=0;break a}c:do switch(f[ga+28>>2]|0){case 6:{if(Q){ja=ba;ka=ga+24|0;break c}fa=ga+84|0;la=ga+68|0;ma=ga+48|0;na=ga+40|0;oa=ga+24|0;pa=0;do{if(!(b[fa>>0]|0))qa=f[(f[la>>2]|0)+(pa<<2)>>2]|0;else qa=pa;ra=ma;sa=f[ra>>2]|0;ta=f[ra+4>>2]|0;ra=na;ua=un(f[ra>>2]|0,f[ra+4>>2]|0,qa|0,0)|0;ra=Vn(ua|0,I|0,sa|0,ta|0)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,(f[f[ga>>2]>>2]|0)+ra|0,b[oa>>0]<<2|0)|0;pa=pa+1|0}while((pa|0)!=(B|0));ja=ba;ka=oa;break}case 1:case 3:case 5:{oa=ga+24|0;pa=b[oa>>0]|0;na=pa<<24>>24;f[j>>2]=0;f[R>>2]=0;f[S>>2]=0;if(!(pa<<24>>24))va=0;else{if(pa<<24>>24<0){wa=24;break b}pa=na<<2;ma=ln(pa)|0;f[j>>2]=ma;la=ma+(na<<2)|0;f[Y>>2]=la;sj(ma|0,0,pa|0)|0;f[R>>2]=la;va=b[oa>>0]|0}la=va<<24>>24;f[k>>2]=0;f[T>>2]=0;f[U>>2]=0;if(!(va<<24>>24)){xa=0;ya=0}else{if(va<<24>>24<0){wa=30;break b}pa=la<<2;ma=ln(pa)|0;f[k>>2]=ma;na=ma+(la<<2)|0;f[V>>2]=na;sj(ma|0,0,pa|0)|0;f[T>>2]=na;xa=ma;ya=ma}if(Q){za=ya;Aa=xa}else{ma=ga+84|0;na=ga+68|0;pa=0;do{if(!(b[ma>>0]|0))Ba=f[(f[na>>2]|0)+(pa<<2)>>2]|0;else Ba=pa;la=f[j>>2]|0;f[g>>2]=Ba;fa=b[oa>>0]|0;f[e>>2]=f[g>>2];Qb(ga,e,fa,la)|0;la=b[oa>>0]|0;fa=la<<24>>24;if(la<<24>>24>0){la=f[j>>2]|0;ra=f[W>>2]|0;ta=f[k>>2]|0;sa=0;do{f[ta+(sa<<2)>>2]=(f[la+(sa<<2)>>2]|0)-(f[ra+(sa+ba<<2)>>2]|0);sa=sa+1|0}while((sa|0)<(fa|0));Ca=ta}else Ca=f[k>>2]|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,Ca|0,fa<<2|0)|0;pa=pa+1|0}while(pa>>>0>>0);pa=f[k>>2]|0;za=pa;Aa=pa}pa=ba+(b[oa>>0]|0)|0;if(za|0){na=f[T>>2]|0;if((na|0)!=(za|0))f[T>>2]=na+(~((na+-4-za|0)>>>2)<<2);Oq(Aa)}na=f[j>>2]|0;if(na|0){ma=f[R>>2]|0;if((ma|0)!=(na|0))f[R>>2]=ma+(~((ma+-4-na|0)>>>2)<<2);Oq(na)}ja=pa;ka=oa;break}default:{pa=ga+24|0;na=b[pa>>0]|0;ma=na<<24>>24;f[j>>2]=0;f[K>>2]=0;f[O>>2]=0;if(!(na<<24>>24)){Da=0;Ea=0}else{if(na<<24>>24<0){wa=53;break b}na=ma<<2;ta=ln(na)|0;f[j>>2]=ta;sa=ta+(ma<<2)|0;f[P>>2]=sa;sj(ta|0,0,na|0)|0;f[K>>2]=sa;Da=ta;Ea=ta}if(Q){Fa=Ea;Ga=Da}else{ta=ga+84|0;sa=ga+68|0;na=0;do{if(!(b[ta>>0]|0))Ha=f[(f[sa>>2]|0)+(na<<2)>>2]|0;else Ha=na;ma=f[j>>2]|0;f[g>>2]=Ha;ra=b[pa>>0]|0;f[e>>2]=f[g>>2];Pb(ga,e,ra,ma)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,na)|0)<<2)+($<<2)|0,f[j>>2]|0,b[pa>>0]<<2|0)|0;na=na+1|0}while(na>>>0>>0);na=f[j>>2]|0;Fa=na;Ga=na}if(Fa|0){na=f[K>>2]|0;if((na|0)!=(Fa|0))f[K>>2]=na+(~((na+-4-Fa|0)>>>2)<<2);Oq(Ga)}ja=ba;ka=pa}}while(0);na=ca+1|0;sa=f[G>>2]|0;if(na>>>0>=(f[L>>2]|0)-sa>>2>>>0){wa=66;break}$=$+(b[ka>>0]|0)|0;aa=ha;ba=ja;ca=na;da=sa;ea=f[A>>2]|0}if((wa|0)==24)aq(j);else if((wa|0)==30)aq(k);else if((wa|0)==53)aq(j);else if((wa|0)==66){Ia=f[D>>2]|0;Ja=f[H>>2]|0;wa=67;break}}else{Ia=E;Ja=N;wa=67}while(0);d:do if((wa|0)==67){N=X(Ia,B)|0;if((N|0)>0){E=0;H=0;while(1){D=f[Ja+(E<<2)>>2]|0;if(!D)Ka=H;else{A=(_(D|0)|0)^31;Ka=(A|0)<(H|0)?H:A+1|0}E=E+1|0;if((E|0)>=(N|0)){La=Ka;break}else H=Ka}}else La=0;switch(b[h>>0]|0){case 6:{Ue(j,Ia);f[l>>2]=0;f[l+4>>2]=i;H=f[F>>2]|0;f[l+8>>2]=H;f[m>>2]=f[i>>2];f[m+4>>2]=i;f[m+8>>2]=H;f[k>>2]=La;f[g>>2]=f[l>>2];f[g+4>>2]=f[l+4>>2];f[g+8>>2]=f[l+8>>2];f[e>>2]=f[m>>2];f[e+4>>2]=f[m+4>>2];f[e+8>>2]=f[m+8>>2];H=sf(j,g,e,k,c)|0;Se(j);if(!H){ia=0;break d}break}case 5:{Ue(j,Ia);f[n>>2]=0;f[n+4>>2]=i;H=f[F>>2]|0;f[n+8>>2]=H;f[o>>2]=f[i>>2];f[o+4>>2]=i;f[o+8>>2]=H;f[k>>2]=La;f[g>>2]=f[n>>2];f[g+4>>2]=f[n+4>>2];f[g+8>>2]=f[n+8>>2];f[e>>2]=f[o>>2];f[e+4>>2]=f[o+4>>2];f[e+8>>2]=f[o+8>>2];H=tf(j,g,e,k,c)|0;Se(j);if(!H){ia=0;break d}break}case 4:{Ue(j,Ia);f[p>>2]=0;f[p+4>>2]=i;H=f[F>>2]|0;f[p+8>>2]=H;f[q>>2]=f[i>>2];f[q+4>>2]=i;f[q+8>>2]=H;f[k>>2]=La;f[g>>2]=f[p>>2];f[g+4>>2]=f[p+4>>2];f[g+8>>2]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<<32-(f[y>>2]|0);break}ha=f[h>>2]|ga>>>Z;f[h>>2]=ha;ga=Z+P|0;f[y>>2]=ga;if((ga|0)!=32)break;ga=f[j>>2]|0;if((ga|0)==(f[m>>2]|0))Ri(n,h);else{f[ga>>2]=ha;f[j>>2]=ga+4}f[h>>2]=0;f[y>>2]=0}while(0);V=V+1|0;P=f[g>>2]|0}while(V>>>0

    >>0);da=P}ba=ba+1|0;if(ba>>>0>=z>>>0){aa=85;break a}else ca=da}}U=T+1|0;Ig(M+(U*12|0)|0,f[M+(T*12|0)>>2]|0,f[M+(T*12|0)+4>>2]|0);V=(f[(f[k>>2]|0)+(U*12|0)>>2]|0)+(Q<<2)|0;W=(f[V>>2]|0)+(1<>2]=W;V=f[A>>2]|0;P=f[B>>2]|0;b:do if((R|0)==(N|0))ia=N;else{Y=f[J>>2]|0;if(!V){if((f[Y+(Q<<2)>>2]|0)>>>0>>0){ia=R;break}else{ja=R;ka=N}while(1){ga=ja;do{ga=ga+-1|0;if((ka|0)==(ga|0)){ia=ka;break b}ha=(f[K>>2]|0)+((X(ga,P)|0)<<2)+(Q<<2)|0}while((f[ha>>2]|0)>>>0>=W>>>0);ka=ka+1|0;if((ka|0)==(ga|0)){ia=ga;break b}else ja=ga}}else{la=R;ma=N}while(1){ha=ma;while(1){na=Y+((X(ha,V)|0)<<2)|0;if((f[na+(Q<<2)>>2]|0)>>>0>=W>>>0){oa=la;break}Z=ha+1|0;if((Z|0)==(la|0)){ia=la;break b}else ha=Z}while(1){oa=oa+-1|0;if((ha|0)==(oa|0)){ia=ha;break b}pa=(f[K>>2]|0)+((X(oa,P)|0)<<2)|0;if((f[pa+(Q<<2)>>2]|0)>>>0>>0){qa=0;break}}do{ga=na+(qa<<2)|0;Z=pa+(qa<<2)|0;fa=f[ga>>2]|0;f[ga>>2]=f[Z>>2];f[Z>>2]=fa;qa=qa+1|0}while((qa|0)!=(V|0));ma=ha+1|0;if((ma|0)==(oa|0)){ia=oa;break}else la=oa}}while(0);W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>0);ea=Q}ca=ca+1|0;if(ca>>>0>=z>>>0){ba=81;break a}else da=ea}}V=U+1|0;Ig(N+(V*12|0)|0,f[N+(U*12|0)>>2]|0,f[N+(U*12|0)+4>>2]|0);W=(f[(f[k>>2]|0)+(V*12|0)>>2]|0)+(R<<2)|0;Y=(f[W>>2]|0)+(1<>2]=Y;W=f[A>>2]|0;Q=f[B>>2]|0;b:do if((S|0)==(O|0))ja=O;else{Z=f[K>>2]|0;if(!W){if((f[Z+(R<<2)>>2]|0)>>>0>>0){ja=S;break}else{ka=S;la=O}while(1){ha=ka;do{ha=ha+-1|0;if((la|0)==(ha|0)){ja=la;break b}ia=(f[L>>2]|0)+((X(ha,Q)|0)<<2)+(R<<2)|0}while((f[ia>>2]|0)>>>0>=Y>>>0);la=la+1|0;if((la|0)==(ha|0)){ja=ha;break b}else ka=ha}}else{ma=S;na=O}while(1){ia=na;while(1){oa=Z+((X(ia,W)|0)<<2)|0;if((f[oa+(R<<2)>>2]|0)>>>0>=Y>>>0){pa=ma;break}$=ia+1|0;if(($|0)==(ma|0)){ja=ma;break b}else ia=$}while(1){pa=pa+-1|0;if((ia|0)==(pa|0)){ja=ia;break b}qa=(f[L>>2]|0)+((X(pa,Q)|0)<<2)|0;if((f[qa+(R<<2)>>2]|0)>>>0>>0){ra=0;break}}do{ha=oa+(ra<<2)|0;$=qa+(ra<<2)|0;ga=f[ha>>2]|0;f[ha>>2]=f[$>>2];f[$>>2]=ga;ra=ra+1|0}while((ra|0)!=(W|0));na=ia+1|0;if((na|0)==(pa|0)){ja=pa;break}else ma=pa}}while(0);Y=(_(z|0)|0)^31;Q=ja-O|0;Z=S-ja|0;ga=Q>>>0>>0;if((Q|0)!=(Z|0)){$=f[D>>2]|0;if(ga)f[E>>2]=f[E>>2]|1<<31-$;ha=$+1|0;f[D>>2]=ha;if((ha|0)==32){ha=f[F>>2]|0;if((ha|0)==(f[G>>2]|0))Ri(H,E);else{f[ha>>2]=f[E>>2];f[F>>2]=ha+4}f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f[Ba+32>>2]=V;Z=(f[l>>2]|0)+1|0;f[l>>2]=Z;Ca=Z}else ba=81}else ba=81;while(0);if((ba|0)==81){ba=0;Ca=f[l>>2]|0}if(!Ca)break;else M=Ca}}Ca=f[t>>2]|0;M=f[v>>2]|0;Ba=Ca+(((M>>>0)/113|0)<<2)|0;q=f[o>>2]|0;p=q;i=Ca;if((q|0)==(Ca|0)){Da=0;Ea=0}else{ja=(f[Ba>>2]|0)+(((M>>>0)%113|0)*36|0)|0;Da=ja;Ea=ja}ja=Ba;Ba=Ea;c:while(1){Ea=Ba;do{M=Ea;if((Da|0)==(M|0))break c;Ea=M+36|0}while((Ea-(f[ja>>2]|0)|0)!=4068);Ea=ja+4|0;ja=Ea;Ba=f[Ea>>2]|0}f[l>>2]=0;l=p-i>>2;if(l>>>0>2){i=Ca;do{Oq(f[i>>2]|0);i=(f[t>>2]|0)+4|0;f[t>>2]=i;Fa=f[o>>2]|0;Ga=Fa-i>>2}while(Ga>>>0>2);Ha=Ga;Ia=i;Ja=Fa}else{Ha=l;Ia=Ca;Ja=q}switch(Ha|0){case 1:{Ka=56;ba=95;break}case 2:{Ka=113;ba=95;break}default:{}}if((ba|0)==95)f[v>>2]=Ka;if((Ia|0)!=(Ja|0)){Ka=Ia;do{Oq(f[Ka>>2]|0);Ka=Ka+4|0}while((Ka|0)!=(Ja|0));Ja=f[t>>2]|0;t=f[o>>2]|0;if((t|0)!=(Ja|0))f[o>>2]=t+(~((t+-4-Ja|0)>>>2)<<2)}Ja=f[e>>2]|0;if(!Ja){u=d;return}Oq(Ja);u=d;return}function mb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=Oa,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;if(!(b[a+32>>0]|0)){r=o;m=0;while(1){s=$(b[r>>0]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}else{r=o;m=0;while(1){s=$($(b[r>>0]|0)/$(127.0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}}else t=l;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 2:{r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;u=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+u|0;if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(h[u>>0]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){v=q;break}else u=u+1|0}}else{u=o;k=0;while(1){s=$($(h[u>>0]|0)/$(255.0));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else u=u+1|0}}}else v=m;u=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 3:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$(d[u>>1]|0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else u=u+2|0}}else{u=o;l=0;while(1){s=$($(d[u>>1]|0)/$(32767.0));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else u=u+2|0}}else w=k;u=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 4:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){s=$(j[u>>1]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else u=u+2|0}}else{u=o;m=0;while(1){s=$($(j[u>>1]|0)/$(65535.0));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){x=k;break}else u=u+2|0}}else x=l;u=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 5:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(f[u>>2]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){y=q;break}else u=u+4|0}}else{u=o;k=0;while(1){s=$($(f[u>>2]|0)*$(4.65661287e-10));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){y=l;break}else u=u+4|0}}else y=m;u=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 6:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$((f[u>>2]|0)>>>0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){z=q;break}else u=u+4|0}}else{u=o;l=0;while(1){s=$($((f[u>>2]|0)>>>0)*$(2.32830644e-10));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){z=m;break}else u=u+4|0}}else z=k;u=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 7:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+(f[q+4>>2]|0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else u=u+8|0}}else{u=o;m=0;while(1){k=u;s=$($(+((f[k>>2]|0)>>>0)+4294967296.0*+(f[k+4>>2]|0))*$(1.08420217e-19));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){A=k;break}else u=u+8|0}}else A=l;u=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 8:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+((f[q+4>>2]|0)>>>0));n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){B=q;break}else u=u+8|0}}else{u=o;k=0;while(1){l=u;s=$($(+((f[l>>2]|0)>>>0)+4294967296.0*+((f[l+4>>2]|0)>>>0))*$(5.42101086e-20));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){B=l;break}else u=u+8|0}}else B=m;u=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 9:{u=a+24|0;k=b[u>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;l=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Vn(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=r+q|0;q=0;while(1){f[g+(q<<2)>>2]=f[o>>2];q=q+1|0;r=b[u>>0]|0;if((q|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){C=r;break}else o=o+4|0}}else C=k;o=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 10:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){u=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;l=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=u+l|0;l=0;while(1){s=$(+p[m>>3]);n[g+(l<<2)>>2]=s;l=l+1|0;u=b[o>>0]|0;if((l|0)>=((u<<24>>24>e<<24>>24?e:u)<<24>>24|0)){D=u;break}else m=m+8|0}}else D=q;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|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b=0;i=u;u=u+512|0;j=i;k=d+c|0;l=0-k|0;m=a+4|0;n=a+100|0;o=b;b=0;a:while(1){switch(o|0){case 46:{p=6;break a;break}case 48:break;default:{q=0;r=o;s=b;t=0;v=0;break a}}w=f[m>>2]|0;if(w>>>0<(f[n>>2]|0)>>>0){f[m>>2]=w+1;o=h[w>>0]|0;b=1;continue}else{o=Si(a)|0;b=1;continue}}if((p|0)==6){o=f[m>>2]|0;if(o>>>0<(f[n>>2]|0)>>>0){f[m>>2]=o+1;x=h[o>>0]|0}else x=Si(a)|0;if((x|0)==48){o=0;w=0;while(1){y=Vn(o|0,w|0,-1,-1)|0;z=I;A=f[m>>2]|0;if(A>>>0<(f[n>>2]|0)>>>0){f[m>>2]=A+1;B=h[A>>0]|0}else B=Si(a)|0;if((B|0)==48){o=y;w=z}else{q=1;r=B;s=1;t=y;v=z;break}}}else{q=1;r=x;s=b;t=0;v=0}}f[j>>2]=0;b=r+-48|0;x=(r|0)==46;b:do if(x|b>>>0<10){B=j+496|0;w=0;o=0;z=0;y=q;A=s;C=r;D=x;E=b;F=t;G=v;H=0;J=0;c:while(1){do if(D)if(!y){L=w;M=o;N=1;O=z;P=A;Q=H;R=J;S=H;T=J}else break c;else{U=Vn(H|0,J|0,1,0)|0;V=I;W=(C|0)!=48;if((o|0)>=125){if(!W){L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}f[B>>2]=f[B>>2]|1;L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}Y=j+(o<<2)|0;if(!w)Z=E;else Z=C+-48+((f[Y>>2]|0)*10|0)|0;f[Y>>2]=Z;Y=w+1|0;_=(Y|0)==9;L=_?0:Y;M=o+(_&1)|0;N=y;O=W?U:z;P=1;Q=F;R=G;S=U;T=V}while(0);V=f[m>>2]|0;if(V>>>0<(f[n>>2]|0)>>>0){f[m>>2]=V+1;$=h[V>>0]|0}else $=Si(a)|0;E=$+-48|0;D=($|0)==46;if(!(D|E>>>0<10)){aa=L;ba=M;ca=O;da=N;ea=$;fa=P;ga=S;ha=Q;ia=T;ja=R;p=29;break b}else{w=L;o=M;z=O;y=N;A=P;C=$;F=Q;G=R;H=S;J=T}}ka=w;la=o;ma=z;na=H;oa=J;pa=F;qa=G;ra=(A|0)!=0;p=37}else{aa=0;ba=0;ca=0;da=q;ea=r;fa=s;ga=0;ha=t;ia=0;ja=v;p=29}while(0);do if((p|0)==29){v=(da|0)==0;t=v?ga:ha;s=v?ia:ja;v=(fa|0)!=0;if(!(v&(ea|32|0)==101))if((ea|0)>-1){ka=aa;la=ba;ma=ca;na=ga;oa=ia;pa=t;qa=s;ra=v;p=37;break}else{sa=aa;ta=ba;ua=ca;va=ga;wa=ia;xa=v;ya=t;za=s;p=39;break}v=Re(a,g)|0;r=I;if((v|0)==0&(r|0)==-2147483648){if(!g){Ym(a,0);Aa=0.0;break}if(!(f[n>>2]|0)){Ba=0;Ca=0}else{f[m>>2]=(f[m>>2]|0)+-1;Ba=0;Ca=0}}else{Ba=v;Ca=r}r=Vn(Ba|0,Ca|0,t|0,s|0)|0;Da=aa;Ea=ba;Fa=ca;Ga=r;Ha=ga;Ia=I;Ja=ia;p=41}while(0);if((p|0)==37)if(f[n>>2]|0){f[m>>2]=(f[m>>2]|0)+-1;if(ra){Da=ka;Ea=la;Fa=ma;Ga=pa;Ha=na;Ia=qa;Ja=oa;p=41}else p=40}else{sa=ka;ta=la;ua=ma;va=na;wa=oa;xa=ra;ya=pa;za=qa;p=39}if((p|0)==39)if(xa){Da=sa;Ea=ta;Fa=ua;Ga=ya;Ha=va;Ia=za;Ja=wa;p=41}else p=40;do if((p|0)==40){wa=Vq()|0;f[wa>>2]=22;Ym(a,0);Aa=0.0}else if((p|0)==41){wa=f[j>>2]|0;if(!wa){Aa=+(e|0)*0.0;break}if(((Ja|0)<0|(Ja|0)==0&Ha>>>0<10)&((Ga|0)==(Ha|0)&(Ia|0)==(Ja|0))?(c|0)>30|(wa>>>c|0)==0:0){Aa=+(e|0)*+(wa>>>0);break}wa=(d|0)/-2|0;za=((wa|0)<0)<<31>>31;if((Ia|0)>(za|0)|(Ia|0)==(za|0)&Ga>>>0>wa>>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}wa=d+-106|0;za=((wa|0)<0)<<31>>31;if((Ia|0)<(za|0)|(Ia|0)==(za|0)&Ga>>>0>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if(!Da)Ka=Ea;else{if((Da|0)<9){wa=j+(Ea<<2)|0;za=Da;va=f[wa>>2]|0;while(1){va=va*10|0;if((za|0)>=8)break;else za=za+1|0}f[wa>>2]=va}Ka=Ea+1|0}if((Fa|0)<9?(Fa|0)<=(Ga|0)&(Ga|0)<18:0){if((Ga|0)==9){Aa=+(e|0)*+((f[j>>2]|0)>>>0);break}if((Ga|0)<9){Aa=+(e|0)*+((f[j>>2]|0)>>>0)/+(f[6720+(8-Ga<<2)>>2]|0);break}za=c+27+(X(Ga,-3)|0)|0;A=f[j>>2]|0;if((za|0)>30|(A>>>za|0)==0){Aa=+(e|0)*+(A>>>0)*+(f[6720+(Ga+-10<<2)>>2]|0);break}}A=(Ga|0)%9|0;if(!A){La=0;Ma=Ka;Na=0;Oa=Ga}else{za=(Ga|0)>-1?A:A+9|0;A=f[6720+(8-za<<2)>>2]|0;if(Ka){G=1e9/(A|0)|0;F=0;J=0;H=Ga;z=0;do{o=j+(z<<2)|0;w=f[o>>2]|0;ya=((w>>>0)/(A>>>0)|0)+F|0;f[o>>2]=ya;F=X(G,(w>>>0)%(A>>>0)|0)|0;w=(z|0)==(J|0)&(ya|0)==0;H=w?H+-9|0:H;J=w?J+1&127:J;z=z+1|0}while((z|0)!=(Ka|0));if(!F){Pa=J;Qa=Ka;Ra=H}else{f[j+(Ka<<2)>>2]=F;Pa=J;Qa=Ka+1|0;Ra=H}}else{Pa=0;Qa=0;Ra=Ga}La=0;Ma=Qa;Na=Pa;Oa=9-za+Ra|0}d:while(1){z=(Oa|0)<18;A=(Oa|0)==18;G=j+(Na<<2)|0;va=La;wa=Ma;while(1){if(!z){if(!A){Sa=va;Ta=Na;Ua=Oa;Va=wa;break d}if((f[G>>2]|0)>>>0>=9007199){Sa=va;Ta=Na;Ua=18;Va=wa;break d}}w=0;Wa=wa;ya=wa+127|0;while(1){o=ya&127;ua=j+(o<<2)|0;ta=Tn(f[ua>>2]|0,0,29)|0;sa=Vn(ta|0,I|0,w|0,0)|0;ta=I;if(ta>>>0>0|(ta|0)==0&sa>>>0>1e9){xa=jp(sa|0,ta|0,1e9,0)|0;qa=hn(sa|0,ta|0,1e9,0)|0;Xa=xa;Ya=qa}else{Xa=0;Ya=sa}f[ua>>2]=Ya;ua=(o|0)==(Na|0);Wa=(Ya|0)==0&(((o|0)!=(Wa+127&127|0)|ua)^1)?o:Wa;if(ua)break;else{w=Xa;ya=o+-1|0}}va=va+-29|0;if(Xa|0)break;else wa=Wa}wa=Na+127&127;G=Wa+127&127;A=j+((Wa+126&127)<<2)|0;if((wa|0)==(Wa|0)){f[A>>2]=f[A>>2]|f[j+(G<<2)>>2];Za=G}else Za=Wa;f[j+(wa<<2)>>2]=Xa;La=va;Ma=Za;Na=wa;Oa=Oa+9|0}e:while(1){za=Va+1&127;H=j+((Va+127&127)<<2)|0;J=Sa;F=Ta;wa=Ua;while(1){G=(wa|0)==18;A=(wa|0)>27?9:1;_a=J;$a=F;while(1){z=0;while(1){ya=z+$a&127;if((ya|0)==(Va|0)){ab=2;p=88;break}w=f[j+(ya<<2)>>2]|0;ya=f[6752+(z<<2)>>2]|0;if(w>>>0>>0){ab=2;p=88;break}if(w>>>0>ya>>>0)break;ya=z+1|0;if((z|0)<1)z=ya;else{ab=ya;p=88;break}}if((p|0)==88?(p=0,G&(ab|0)==2):0){bb=0.0;cb=0;db=Va;break e}eb=A+_a|0;if(($a|0)==(Va|0)){_a=eb;$a=Va}else break}G=(1<>>A;fb=0;gb=$a;hb=wa;ya=$a;do{w=j+(ya<<2)|0;o=f[w>>2]|0;ua=(o>>>A)+fb|0;f[w>>2]=ua;fb=X(o&G,z)|0;o=(ya|0)==(gb|0)&(ua|0)==0;hb=o?hb+-9|0:hb;gb=o?gb+1&127:gb;ya=ya+1&127}while((ya|0)!=(Va|0));if(!fb){J=eb;F=gb;wa=hb;continue}if((za|0)!=(gb|0))break;f[H>>2]=f[H>>2]|1;J=eb;F=gb;wa=hb}f[j+(Va<<2)>>2]=fb;Sa=eb;Ta=gb;Ua=hb;Va=za}while(1){wa=cb+$a&127;F=db+1&127;if((wa|0)==(db|0)){f[j+(F+-1<<2)>>2]=0;ib=F}else ib=db;bb=bb*1.0e9+ +((f[j+(wa<<2)>>2]|0)>>>0);cb=cb+1|0;if((cb|0)==2)break;else db=ib}jb=+(e|0);kb=bb*jb;wa=_a+53|0;F=wa-d|0;J=(F|0)<(c|0);H=J?((F|0)>0?F:0):c;if((H|0)<53){lb=+rq(+bk(1.0,105-H|0),kb);mb=+Dq(kb,+bk(1.0,53-H|0));nb=lb;ob=mb;pb=lb+(kb-mb)}else{nb=0.0;ob=0.0;pb=kb}va=$a+2&127;if((va|0)!=(ib|0)){ya=f[j+(va<<2)>>2]|0;do if(ya>>>0>=5e8){if((ya|0)!=5e8){qb=jb*.75+ob;break}if(($a+3&127|0)==(ib|0)){qb=jb*.5+ob;break}else{qb=jb*.75+ob;break}}else{if((ya|0)==0?($a+3&127|0)==(ib|0):0){qb=ob;break}qb=jb*.25+ob}while(0);if((53-H|0)>1?!(+Dq(qb,1.0)!=0.0):0)rb=qb+1.0;else rb=qb}else rb=ob;jb=pb+rb-nb;do if((wa&2147483647|0)>(-2-k|0)){ya=!(+K(+jb)>=9007199254740992.0);va=_a+((ya^1)&1)|0;kb=ya?jb:jb*.5;if((va+50|0)<=(l|0)?!(rb!=0.0&(J&((H|0)!=(F|0)|ya))):0){sb=kb;tb=va;break}ya=Vq()|0;f[ya>>2]=34;sb=kb;tb=va}else{sb=jb;tb=_a}while(0);Aa=+sq(sb,tb)}while(0);u=i;return +Aa}function ob(a,c,d,e,g,i){a=a|0;c=+c;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0,D=0.0,E=0,F=0,G=0,H=0.0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0.0,ga=0.0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0;j=u;u=u+560|0;k=j+8|0;l=j;m=j+524|0;n=m;o=j+512|0;f[l>>2]=0;p=o+12|0;yo(c)|0;if((I|0)<0){q=-c;r=1;s=16605}else{q=c;r=(g&2049|0)!=0&1;s=(g&2048|0)==0?((g&1|0)==0?16606:16611):16608}yo(q)|0;do if(0==0&(I&2146435072|0)==2146435072){t=(i&32|0)!=0;v=r+3|0;Qk(a,32,d,v,g&-65537);Xo(a,s,r);Xo(a,q!=q|0.0!=0.0?(t?18555:16632):t?16624:16628,3);Qk(a,32,d,v,g^8192);w=v}else{c=+tq(q,l)*2.0;v=c!=0.0;if(v)f[l>>2]=(f[l>>2]|0)+-1;t=i|32;if((t|0)==97){x=i&32;y=(x|0)==0?s:s+9|0;z=r|2;A=12-e|0;do if(!(e>>>0>11|(A|0)==0)){B=8.0;C=A;do{C=C+-1|0;B=B*16.0}while((C|0)!=0);if((b[y>>0]|0)==45){D=-(B+(-c-B));break}else{D=c+B-B;break}}else D=c;while(0);A=f[l>>2]|0;C=(A|0)<0?0-A|0:A;E=Rj(C,((C|0)<0)<<31>>31,p)|0;if((E|0)==(p|0)){C=o+11|0;b[C>>0]=48;F=C}else F=E;b[F+-1>>0]=(A>>31&2)+43;A=F+-2|0;b[A>>0]=i+15;E=(e|0)<1;C=(g&8|0)==0;G=m;H=D;while(1){J=~~H;K=G+1|0;b[G>>0]=x|h[16636+J>>0];H=(H-+(J|0))*16.0;if((K-n|0)==1?!(C&(E&H==0.0)):0){b[K>>0]=46;L=G+2|0}else L=K;if(!(H!=0.0))break;else G=L}G=L;if((e|0)!=0?(-2-n+G|0)<(e|0):0){M=G-n|0;N=e+2|0}else{E=G-n|0;M=E;N=E}E=p-A|0;G=E+z+N|0;Qk(a,32,d,G,g);Xo(a,y,z);Qk(a,48,d,G,g^65536);Xo(a,m,M);Qk(a,48,N-M|0,0,0);Xo(a,A,E);Qk(a,32,d,G,g^8192);w=G;break}G=(e|0)<0?6:e;if(v){E=(f[l>>2]|0)+-28|0;f[l>>2]=E;O=c*268435456.0;P=E}else{O=c;P=f[l>>2]|0}E=(P|0)<0?k:k+288|0;C=E;H=O;do{x=~~H>>>0;f[C>>2]=x;C=C+4|0;H=(H-+(x>>>0))*1.0e9}while(H!=0.0);if((P|0)>0){v=E;A=C;z=P;while(1){y=(z|0)<29?z:29;x=A+-4|0;if(x>>>0>=v>>>0){K=x;x=0;do{J=Tn(f[K>>2]|0,0,y|0)|0;Q=Vn(J|0,I|0,x|0,0)|0;J=I;R=hn(Q|0,J|0,1e9,0)|0;f[K>>2]=R;x=jp(Q|0,J|0,1e9,0)|0;K=K+-4|0}while(K>>>0>=v>>>0);if(x){K=v+-4|0;f[K>>2]=x;S=K}else S=v}else S=v;K=A;while(1){if(K>>>0<=S>>>0)break;J=K+-4|0;if(!(f[J>>2]|0))K=J;else break}x=(f[l>>2]|0)-y|0;f[l>>2]=x;if((x|0)>0){v=S;A=K;z=x}else{T=S;U=K;V=x;break}}}else{T=E;U=C;V=P}if((V|0)<0){z=((G+25|0)/9|0)+1|0;A=(t|0)==102;v=T;x=U;J=V;while(1){Q=0-J|0;R=(Q|0)<9?Q:9;if(v>>>0>>0){Q=(1<>>R;Y=0;Z=v;do{_=f[Z>>2]|0;f[Z>>2]=(_>>>R)+Y;Y=X(_&Q,W)|0;Z=Z+4|0}while(Z>>>0>>0);Z=(f[v>>2]|0)==0?v+4|0:v;if(!Y){$=Z;aa=x}else{f[x>>2]=Y;$=Z;aa=x+4|0}}else{$=(f[v>>2]|0)==0?v+4|0:v;aa=x}Z=A?E:$;W=(aa-Z>>2|0)>(z|0)?Z+(z<<2)|0:aa;J=(f[l>>2]|0)+R|0;f[l>>2]=J;if((J|0)>=0){ba=$;ca=W;break}else{v=$;x=W}}}else{ba=T;ca=U}x=E;if(ba>>>0>>0){v=(x-ba>>2)*9|0;J=f[ba>>2]|0;if(J>>>0<10)da=v;else{z=v;v=10;while(1){v=v*10|0;A=z+1|0;if(J>>>0>>0){da=A;break}else z=A}}}else da=0;z=(t|0)==103;v=(G|0)!=0;J=G-((t|0)!=102?da:0)+((v&z)<<31>>31)|0;if((J|0)<(((ca-x>>2)*9|0)+-9|0)){A=J+9216|0;J=E+4+(((A|0)/9|0)+-1024<<2)|0;C=(A|0)%9|0;if((C|0)<8){A=C;C=10;while(1){W=C*10|0;if((A|0)<7){A=A+1|0;C=W}else{ea=W;break}}}else ea=10;C=f[J>>2]|0;A=(C>>>0)%(ea>>>0)|0;t=(J+4|0)==(ca|0);if(!(t&(A|0)==0)){B=(((C>>>0)/(ea>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;W=(ea|0)/2|0;H=A>>>0>>0?.5:t&(A|0)==(W|0)?1.0:1.5;if(!r){fa=H;ga=B}else{W=(b[s>>0]|0)==45;fa=W?-H:H;ga=W?-B:B}W=C-A|0;f[J>>2]=W;if(ga+fa!=ga){A=W+ea|0;f[J>>2]=A;if(A>>>0>999999999){A=ba;W=J;while(1){C=W+-4|0;f[W>>2]=0;if(C>>>0>>0){t=A+-4|0;f[t>>2]=0;ha=t}else ha=A;t=(f[C>>2]|0)+1|0;f[C>>2]=t;if(t>>>0>999999999){A=ha;W=C}else{ia=ha;ja=C;break}}}else{ia=ba;ja=J}W=(x-ia>>2)*9|0;A=f[ia>>2]|0;if(A>>>0<10){ka=ja;la=W;ma=ia}else{C=W;W=10;while(1){W=W*10|0;t=C+1|0;if(A>>>0>>0){ka=ja;la=t;ma=ia;break}else C=t}}}else{ka=J;la=da;ma=ba}}else{ka=J;la=da;ma=ba}C=ka+4|0;na=la;oa=ca>>>0>C>>>0?C:ca;pa=ma}else{na=da;oa=ca;pa=ba}C=oa;while(1){if(C>>>0<=pa>>>0){qa=0;break}W=C+-4|0;if(!(f[W>>2]|0))C=W;else{qa=1;break}}J=0-na|0;do if(z){W=G+((v^1)&1)|0;if((W|0)>(na|0)&(na|0)>-5){ra=i+-1|0;sa=W+-1-na|0}else{ra=i+-2|0;sa=W+-1|0}W=g&8;if(!W){if(qa?(A=f[C+-4>>2]|0,(A|0)!=0):0)if(!((A>>>0)%10|0)){t=0;Z=10;while(1){Z=Z*10|0;Q=t+1|0;if((A>>>0)%(Z>>>0)|0|0){ta=Q;break}else t=Q}}else ta=0;else ta=9;t=((C-x>>2)*9|0)+-9|0;if((ra|32|0)==102){Z=t-ta|0;A=(Z|0)>0?Z:0;ua=ra;va=(sa|0)<(A|0)?sa:A;wa=0;break}else{A=t+na-ta|0;t=(A|0)>0?A:0;ua=ra;va=(sa|0)<(t|0)?sa:t;wa=0;break}}else{ua=ra;va=sa;wa=W}}else{ua=i;va=G;wa=g&8}while(0);G=va|wa;x=(G|0)!=0&1;v=(ua|32|0)==102;if(v){xa=0;ya=(na|0)>0?na:0}else{z=(na|0)<0?J:na;t=Rj(z,((z|0)<0)<<31>>31,p)|0;z=p;if((z-t|0)<2){A=t;while(1){Z=A+-1|0;b[Z>>0]=48;if((z-Z|0)<2)A=Z;else{za=Z;break}}}else za=t;b[za+-1>>0]=(na>>31&2)+43;A=za+-2|0;b[A>>0]=ua;xa=A;ya=z-A|0}A=r+1+va+x+ya|0;Qk(a,32,d,A,g);Xo(a,s,r);Qk(a,48,d,A,g^65536);if(v){J=pa>>>0>E>>>0?E:pa;Z=m+9|0;R=Z;Y=m+8|0;Q=J;do{K=Rj(f[Q>>2]|0,0,Z)|0;if((Q|0)==(J|0))if((K|0)==(Z|0)){b[Y>>0]=48;Aa=Y}else Aa=K;else if(K>>>0>m>>>0){sj(m|0,48,K-n|0)|0;y=K;while(1){_=y+-1|0;if(_>>>0>m>>>0)y=_;else{Aa=_;break}}}else Aa=K;Xo(a,Aa,R-Aa|0);Q=Q+4|0}while(Q>>>0<=E>>>0);if(G|0)Xo(a,16652,1);if(Q>>>0>>0&(va|0)>0){E=va;R=Q;while(1){Y=Rj(f[R>>2]|0,0,Z)|0;if(Y>>>0>m>>>0){sj(m|0,48,Y-n|0)|0;J=Y;while(1){v=J+-1|0;if(v>>>0>m>>>0)J=v;else{Ba=v;break}}}else Ba=Y;Xo(a,Ba,(E|0)<9?E:9);R=R+4|0;J=E+-9|0;if(!(R>>>0>>0&(E|0)>9)){Ca=J;break}else E=J}}else Ca=va;Qk(a,48,Ca+9|0,9,0)}else{E=qa?C:pa+4|0;if((va|0)>-1){R=m+9|0;Z=(wa|0)==0;Q=R;G=0-n|0;J=m+8|0;K=va;v=pa;while(1){x=Rj(f[v>>2]|0,0,R)|0;if((x|0)==(R|0)){b[J>>0]=48;Da=J}else Da=x;do if((v|0)==(pa|0)){x=Da+1|0;Xo(a,Da,1);if(Z&(K|0)<1){Ea=x;break}Xo(a,16652,1);Ea=x}else{if(Da>>>0<=m>>>0){Ea=Da;break}sj(m|0,48,Da+G|0)|0;x=Da;while(1){z=x+-1|0;if(z>>>0>m>>>0)x=z;else{Ea=z;break}}}while(0);Y=Q-Ea|0;Xo(a,Ea,(K|0)>(Y|0)?Y:K);x=K-Y|0;v=v+4|0;if(!(v>>>0>>0&(x|0)>-1)){Fa=x;break}else K=x}}else Fa=va;Qk(a,48,Fa+18|0,18,0);Xo(a,xa,p-xa|0)}Qk(a,32,d,A,g^8192);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-(f[z+96>>2]|0)|0)/12|0;b[d>>0]=0;qh(t,A,d);A=f[s>>2]|0;z=(f[A+28>>2]|0)-(f[A+24>>2]|0)>>2;f[d>>2]=-1;hg(a+52|0,z,d);z=a+40|0;A=f[z>>2]|0;B=a+44|0;C=f[B>>2]|0;if((C|0)!=(A|0))f[B>>2]=C+(~((C+-4-A|0)>>>2)<<2);A=f[s>>2]|0;C=(f[A+4>>2]|0)-(f[A>>2]|0)>>2;gk(z,C-((C>>>0)%3|0)|0);C=a+84|0;z=f[s>>2]|0;A=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2;b[d>>0]=0;qh(C,A,d);A=a+96|0;z=f[A>>2]|0;B=a+100|0;D=f[B>>2]|0;if((D|0)!=(z|0))f[B>>2]=D+(~((D+-4-z|0)>>>2)<<2);f[a+164>>2]=-1;z=a+168|0;f[z>>2]=0;D=f[a+108>>2]|0;E=a+112|0;F=f[E>>2]|0;if((F|0)!=(D|0))f[E>>2]=F+(~(((F+-12-D|0)>>>0)/12|0)*12|0);D=a+132|0;if(f[D>>2]|0){F=a+128|0;E=f[F>>2]|0;if(E|0){G=E;do{E=G;G=f[G>>2]|0;Oq(E)}while((G|0)!=0)}f[F>>2]=0;F=f[a+124>>2]|0;if(F|0){G=a+120|0;E=0;do{f[(f[G>>2]|0)+(E<<2)>>2]=0;E=E+1|0}while((E|0)!=(F|0))}f[D>>2]=0}f[a+144>>2]=0;D=f[s>>2]|0;F=(f[D+28>>2]|0)-(f[D+24>>2]|0)>>2;f[d>>2]=-1;hg(a+152|0,F,d);F=a+72|0;D=f[F>>2]|0;E=a+76|0;G=f[E>>2]|0;if((G|0)!=(D|0))f[E>>2]=G+(~((G+-4-D|0)>>>2)<<2);D=f[s>>2]|0;gk(F,((f[D+4>>2]|0)-(f[D>>2]|0)>>2>>>0)/3|0);f[a+64>>2]=0;if(!(Be(a)|0)){w=0;u=c;return w|0}if(!(Hg(a)|0)){w=0;u=c;return w|0}D=a+172|0;G=a+176|0;H=(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V>>2]=f[V>>2]|P;V=Q+1|0;if(R)_=-1;else _=((V>>>0)%3|0|0)==0?Q+-2|0:V;f[d>>2]=_;Y=f[H>>2]|0;if(Y>>>0<(f[K>>2]|0)>>>0){f[Y>>2]=_;f[H>>2]=Y+4}else Ri(i,d);if(R)break;Y=((V>>>0)%3|0|0)==0?Q+-2|0:V;if((Y|0)==-1)break;V=f[(f[(f[s>>2]|0)+12>>2]|0)+(Y<<2)>>2]|0;Y=(V|0)==-1;W=Y?-1:(V>>>0)/3|0;if(Y)break;if(f[(f[t>>2]|0)+(W>>>5<<2)>>2]&1<<(W&31)|0)break;f[l>>2]=V;f[d>>2]=f[l>>2];if(!(kc(a,d)|0))break b}else{V=Q+1|0;if(R)$=-1;else $=((V>>>0)%3|0|0)==0?Q+-2|0:V;f[m>>2]=$;f[d>>2]=f[m>>2];Pe(a,d,1)|0;f[n>>2]=f[e>>2];f[d>>2]=f[n>>2];if(!(kc(a,d)|0))break b}while(0)}M=M+1|0;if((M|0)>=(L|0)){aa=62;break a}}ba=0}else aa=62;while(0);if((aa|0)==62){aa=f[F>>2]|0;L=f[E>>2]|0;n=L;if((aa|0)!=(L|0)?(m=L+-4|0,aa>>>0>>0):0){L=aa;aa=m;do{m=f[L>>2]|0;f[L>>2]=f[aa>>2];f[aa>>2]=m;L=L+4|0;aa=aa+-4|0}while(L>>>0>>0)}f[o>>2]=n;f[p>>2]=f[i>>2];f[q>>2]=f[H>>2];f[g>>2]=f[o>>2];f[e>>2]=f[p>>2];f[d>>2]=f[q>>2];Yd(F,g,e,d)|0;if((f[G>>2]|0)!=(f[D>>2]|0)?(D=f[y>>2]|0,y=((f[D+100>>2]|0)-(f[D+96>>2]|0)|0)/12|0,b[d>>0]=0,qh(t,y,d),y=f[F>>2]|0,F=f[E>>2]|0,(y|0)!=(F|0)):0){E=y;do{f[r>>2]=f[E>>2];f[d>>2]=f[r>>2];He(a,d)|0;E=E+4|0}while((E|0)!=(F|0))}th(v);F=a+232|0;ld(v,F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>-1)if((s|0)>(2147483647-t|0)){w=Vq()|0;f[w>>2]=75;x=-1;break}else{x=s+t|0;break}else x=t;while(0);w=f[j>>2]|0;y=b[w>>0]|0;if(!(y<<24>>24)){z=88;break}else{A=y;B=w}b:while(1){switch(A<<24>>24){case 37:{C=B;D=B;z=9;break b;break}case 0:{E=B;break b;break}default:{}}y=B+1|0;f[j>>2]=y;A=b[y>>0]|0;B=y}c:do if((z|0)==9)while(1){z=0;if((b[D+1>>0]|0)!=37){E=C;break c}y=C+1|0;D=D+2|0;f[j>>2]=D;if((b[D>>0]|0)!=37){E=y;break}else{C=y;z=9}}while(0);y=E-w|0;if(c)Xo(a,w,y);if(y|0){s=y;t=x;continue}y=(Aq(b[(f[j>>2]|0)+1>>0]|0)|0)==0;F=f[j>>2]|0;if(!y?(b[F+2>>0]|0)==36:0){G=(b[F+1>>0]|0)+-48|0;H=1;J=3}else{G=-1;H=v;J=1}y=F+J|0;f[j>>2]=y;F=b[y>>0]|0;K=(F<<24>>24)+-32|0;if(K>>>0>31|(1<>24)+-32|K;P=F+1|0;f[j>>2]=P;Q=b[P>>0]|0;R=(Q<<24>>24)+-32|0;if(R>>>0>31|(1<>24==42){if((Aq(b[N+1>>0]|0)|0)!=0?(F=f[j>>2]|0,(b[F+2>>0]|0)==36):0){O=F+1|0;f[h+((b[O>>0]|0)+-48<<2)>>2]=10;S=f[g+((b[O>>0]|0)+-48<<3)>>2]|0;T=1;U=F+3|0}else{if(H|0){V=-1;break}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);O=f[F>>2]|0;f[e>>2]=F+4;W=O}else W=0;S=W;T=0;U=(f[j>>2]|0)+1|0}f[j>>2]=U;O=(S|0)<0;X=O?0-S|0:S;Y=O?L|8192:L;Z=T;_=U}else{O=Ll(j)|0;if((O|0)<0){V=-1;break}X=O;Y=L;Z=H;_=f[j>>2]|0}do if((b[_>>0]|0)==46){if((b[_+1>>0]|0)!=42){f[j>>2]=_+1;O=Ll(j)|0;$=O;aa=f[j>>2]|0;break}if(Aq(b[_+2>>0]|0)|0?(O=f[j>>2]|0,(b[O+3>>0]|0)==36):0){F=O+2|0;f[h+((b[F>>0]|0)+-48<<2)>>2]=10;K=f[g+((b[F>>0]|0)+-48<<3)>>2]|0;F=O+4|0;f[j>>2]=F;$=K;aa=F;break}if(Z|0){V=-1;break a}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);K=f[F>>2]|0;f[e>>2]=F+4;ba=K}else ba=0;K=(f[j>>2]|0)+2|0;f[j>>2]=K;$=ba;aa=K}else{$=-1;aa=_}while(0);K=0;F=aa;while(1){if(((b[F>>0]|0)+-65|0)>>>0>57){V=-1;break a}O=F;F=F+1|0;f[j>>2]=F;ca=b[(b[O>>0]|0)+-65+(16124+(K*58|0))>>0]|0;da=ca&255;if((da+-1|0)>>>0>=8)break;else K=da}if(!(ca<<24>>24)){V=-1;break}O=(G|0)>-1;do if(ca<<24>>24==19)if(O){V=-1;break a}else z=50;else{if(O){f[h+(G<<2)>>2]=da;P=g+(G<<3)|0;Q=f[P+4>>2]|0;y=k;f[y>>2]=f[P>>2];f[y+4>>2]=Q;z=50;break}if(!c){V=0;break a}We(k,da,e);ea=f[j>>2]|0}while(0);if((z|0)==50){z=0;if(c)ea=F;else{s=0;t=x;v=Z;continue}}O=b[ea+-1>>0]|0;Q=(K|0)!=0&(O&15|0)==3?O&-33:O;O=Y&-65537;y=(Y&8192|0)==0?Y:O;d:do switch(Q|0){case 110:{switch((K&255)<<24>>24){case 0:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 1:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 2:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}case 3:{d[f[k>>2]>>1]=x;s=0;t=x;v=Z;continue a;break}case 4:{b[f[k>>2]>>0]=x;s=0;t=x;v=Z;continue a;break}case 6:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 7:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}default:{s=0;t=x;v=Z;continue a}}break}case 112:{fa=120;ga=$>>>0>8?$:8;ha=y|8;z=62;break}case 88:case 120:{fa=Q;ga=$;ha=y;z=62;break}case 111:{P=k;R=f[P>>2]|0;ia=f[P+4>>2]|0;P=Ol(R,ia,o)|0;ja=q-P|0;ka=P;la=0;ma=16588;na=(y&8|0)==0|($|0)>(ja|0)?$:ja+1|0;oa=y;pa=R;qa=ia;z=68;break}case 105:case 100:{ia=k;R=f[ia>>2]|0;ja=f[ia+4>>2]|0;if((ja|0)<0){ia=Xn(0,0,R|0,ja|0)|0;P=I;ra=k;f[ra>>2]=ia;f[ra+4>>2]=P;sa=1;ta=16588;ua=ia;va=P;z=67;break d}else{sa=(y&2049|0)!=0&1;ta=(y&2048|0)==0?((y&1|0)==0?16588:16590):16589;ua=R;va=ja;z=67;break d}break}case 117:{ja=k;sa=0;ta=16588;ua=f[ja>>2]|0;va=f[ja+4>>2]|0;z=67;break}case 99:{b[r>>0]=f[k>>2];wa=r;xa=0;ya=16588;za=o;Aa=1;Ba=O;break}case 109:{ja=Vq()|0;Ca=$o(f[ja>>2]|0)|0;z=72;break}case 115:{ja=f[k>>2]|0;Ca=ja|0?ja:16598;z=72;break}case 67:{f[m>>2]=f[k>>2];f[l>>2]=0;f[k>>2]=m;Da=-1;Ea=m;z=76;break}case 83:{ja=f[k>>2]|0;if(!$){Qk(a,32,X,0,y);Fa=0;z=85}else{Da=$;Ea=ja;z=76}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{s=ob(a,+p[k>>3],X,$,y,Q)|0;t=x;v=Z;continue a;break}default:{wa=w;xa=0;ya=16588;za=o;Aa=$;Ba=y}}while(0);e:do if((z|0)==62){z=0;w=k;Q=f[w>>2]|0;K=f[w+4>>2]|0;w=ul(Q,K,o,fa&32)|0;F=(ha&8|0)==0|(Q|0)==0&(K|0)==0;ka=w;la=F?0:2;ma=F?16588:16588+(fa>>4)|0;na=ga;oa=ha;pa=Q;qa=K;z=68}else if((z|0)==67){z=0;ka=Rj(ua,va,o)|0;la=sa;ma=ta;na=$;oa=y;pa=ua;qa=va;z=68}else if((z|0)==72){z=0;K=tg(Ca,0,$)|0;Q=(K|0)==0;wa=Ca;xa=0;ya=16588;za=Q?Ca+$|0:K;Aa=Q?$:K-Ca|0;Ba=O}else if((z|0)==76){z=0;K=Ea;Q=0;F=0;while(1){w=f[K>>2]|0;if(!w){Ga=Q;Ha=F;break}ja=Po(n,w)|0;if((ja|0)<0|ja>>>0>(Da-Q|0)>>>0){Ga=Q;Ha=ja;break}w=ja+Q|0;if(Da>>>0>w>>>0){K=K+4|0;Q=w;F=ja}else{Ga=w;Ha=ja;break}}if((Ha|0)<0){V=-1;break a}Qk(a,32,X,Ga,y);if(!Ga){Fa=0;z=85}else{F=Ea;Q=0;while(1){K=f[F>>2]|0;if(!K){Fa=Ga;z=85;break e}ja=Po(n,K)|0;Q=ja+Q|0;if((Q|0)>(Ga|0)){Fa=Ga;z=85;break e}Xo(a,n,ja);if(Q>>>0>=Ga>>>0){Fa=Ga;z=85;break}else F=F+4|0}}}while(0);if((z|0)==68){z=0;O=(pa|0)!=0|(qa|0)!=0;F=(na|0)!=0|O;Q=q-ka+((O^1)&1)|0;wa=F?ka:o;xa=la;ya=ma;za=o;Aa=F?((na|0)>(Q|0)?na:Q):na;Ba=(na|0)>-1?oa&-65537:oa}else if((z|0)==85){z=0;Qk(a,32,X,Fa,y^8192);s=(X|0)>(Fa|0)?X:Fa;t=x;v=Z;continue}Q=za-wa|0;F=(Aa|0)<(Q|0)?Q:Aa;O=F+xa|0;ja=(X|0)<(O|0)?O:X;Qk(a,32,ja,O,Ba);Xo(a,ya,xa);Qk(a,48,ja,O,Ba^65536);Qk(a,48,F,Q,0);Xo(a,wa,Q);Qk(a,32,ja,O,Ba^8192);s=ja;t=x;v=Z}f:do if((z|0)==88)if(!a)if(v){Z=1;while(1){t=f[h+(Z<<2)>>2]|0;if(!t){Ia=Z;break}We(g+(Z<<3)|0,t,e);t=Z+1|0;if((Z|0)<9)Z=t;else{Ia=t;break}}if((Ia|0)<10){Z=Ia;while(1){if(f[h+(Z<<2)>>2]|0){V=-1;break f}if((Z|0)<9)Z=Z+1|0;else{V=1;break}}}else V=1}else V=0;else V=x;while(0);u=i;return V|0}function rb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0;c=u;u=u+64|0;d=c+56|0;e=c+52|0;g=c+48|0;h=c+60|0;i=c;j=c+44|0;k=c+40|0;l=c+36|0;m=c+32|0;n=c+28|0;o=c+24|0;p=c+20|0;q=c+16|0;r=c+12|0;if(!(b[a+352>>0]|0)){_e(d,f[a+8>>2]|0);s=a+12|0;t=f[d>>2]|0;f[d>>2]=0;v=f[s>>2]|0;f[s>>2]=t;if(v){Ii(v);Oq(v);v=f[d>>2]|0;f[d>>2]=0;if(v|0){Ii(v);Oq(v)}}else f[d>>2]=0}else{fh(d,f[a+8>>2]|0);v=a+12|0;t=f[d>>2]|0;f[d>>2]=0;s=f[v>>2]|0;f[v>>2]=t;if(s){Ii(s);Oq(s);s=f[d>>2]|0;f[d>>2]=0;if(s|0){Ii(s);Oq(s)}}else f[d>>2]=0}s=a+12|0;t=f[s>>2]|0;if(!t){w=0;u=c;return w|0}if((((f[t+4>>2]|0)-(f[t>>2]|0)>>2>>>0)/3|0|0)==(f[t+40>>2]|0)){w=0;u=c;return w|0}t=a+200|0;ve(t,a)|0;v=f[s>>2]|0;x=a+4|0;ci(((f[v+28>>2]|0)-(f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2)|0;f[X>>2]=f[X>>2]|1<<(S&31);X=V+(R>>>5<<2)|0;f[X>>2]=f[X>>2]|1<<(R&31);f[d>>2]=1;X=f[B>>2]|0;if(X>>>0<(f[H>>2]|0)>>>0){f[X>>2]=1;f[B>>2]=X+4}else Ri(A,d);X=(f[v>>2]|0)+(N<<2)|0;f[X>>2]=f[X>>2]|O;X=P+1|0;if(Q)Z=-1;else Z=((X>>>0)%3|0|0)==0?P+-2|0:X;f[d>>2]=Z;V=f[I>>2]|0;if(V>>>0<(f[J>>2]|0)>>>0){f[V>>2]=Z;f[I>>2]=V+4}else Ri(i,d);if(Q)break;V=((X>>>0)%3|0|0)==0?P+-2|0:X;if((V|0)==-1)break;X=f[(f[(f[s>>2]|0)+12>>2]|0)+(V<<2)>>2]|0;V=(X|0)==-1;U=V?-1:(X>>>0)/3|0;if(V)break;if(f[(f[v>>2]|0)+(U>>>5<<2)>>2]&1<<(U&31)|0)break;f[l>>2]=X;f[d>>2]=f[l>>2];if(!(Yb(a,d)|0))break b}else{X=P+1|0;if(Q)_=-1;else _=((X>>>0)%3|0|0)==0?P+-2|0:X;f[m>>2]=_;f[d>>2]=f[m>>2];Pe(a,d,1)|0;f[n>>2]=f[e>>2];f[d>>2]=f[n>>2];if(!(Yb(a,d)|0))break b}while(0)}K=K+1|0;if((K|0)>=(L|0)){$=62;break a}}aa=0}else $=62;while(0);if(($|0)==62){$=f[F>>2]|0;L=f[E>>2]|0;n=L;if(($|0)!=(L|0)?(m=L+-4|0,$>>>0>>0):0){L=$;$=m;do{m=f[L>>2]|0;f[L>>2]=f[$>>2];f[$>>2]=m;L=L+4|0;$=$+-4|0}while(L>>>0<$>>>0)}f[o>>2]=n;f[p>>2]=f[i>>2];f[q>>2]=f[I>>2];f[g>>2]=f[o>>2];f[e>>2]=f[p>>2];f[d>>2]=f[q>>2];Yd(F,g,e,d)|0;if((f[G>>2]|0)!=(f[D>>2]|0)?(D=f[y>>2]|0,y=((f[D+100>>2]|0)-(f[D+96>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m=(k|0)==0;do if(!m)if(k>>>0>1073741823)aq(e);else{o=k<<2;p=ln(o)|0;f[e>>2]=p;q=p+(k<<2)|0;f[e+8>>2]=q;sj(p|0,0,o|0)|0;f[i>>2]=q;break}while(0);f[g>>2]=0;k=g+4|0;f[k>>2]=0;f[g+8>>2]=0;f[h>>2]=0;if(!m){m=d+16|0;q=d+4|0;o=d+12|0;p=d+8|0;r=g+8|0;s=d+24|0;t=0;v=0;while(1){w=f[m>>2]|0;x=f[w+8>>2]|0;y=(f[w+12>>2]|0)-x|0;w=(y|0)>0;z=x;if(w){x=y>>>2;A=0;B=0;while(1){C=f[z+(A<<2)>>2]|0;if(!(b[C+84>>0]|0))D=f[(f[C+68>>2]|0)+(v<<2)>>2]|0;else D=v;C=D+239^B;A=A+1|0;if((A|0)>=(x|0)){E=C;break}else B=C}}else E=0;B=f[q>>2]|0;x=(B|0)==0;a:do if(!x){A=B+-1|0;C=(A&B|0)==0;if(!C)if(E>>>0>>0)F=E;else F=(E>>>0)%(B>>>0)|0;else F=A&E;G=f[(f[d>>2]|0)+(F<<2)>>2]|0;if((G|0)!=0?(H=f[G>>2]|0,(H|0)!=0):0){G=f[s>>2]|0;I=G+8|0;J=G+12|0;b:do if(C){G=H;while(1){K=f[G+4>>2]|0;L=(K|0)==(E|0);if(!(L|(K&A|0)==(F|0))){M=44;break a}c:do if(L){K=f[G+8>>2]|0;N=f[I>>2]|0;O=(f[J>>2]|0)-N|0;P=N;if((O|0)<=0){Q=G;break b}N=O>>>2;O=0;while(1){R=f[P+(O<<2)>>2]|0;if(!(b[R+84>>0]|0)){S=f[R+68>>2]|0;T=f[S+(v<<2)>>2]|0;U=f[S+(K<<2)>>2]|0}else{T=v;U=K}O=O+1|0;if((U|0)!=(T|0))break c;if((O|0)>=(N|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}else{G=H;while(1){L=f[G+4>>2]|0;d:do if((L|0)!=(E|0)){if(L>>>0>>0)X=L;else X=(L>>>0)%(B>>>0)|0;if((X|0)!=(F|0)){M=44;break a}}else{N=f[G+8>>2]|0;O=f[I>>2]|0;K=(f[J>>2]|0)-O|0;P=O;if((K|0)<=0){Q=G;break b}O=K>>>2;K=0;while(1){S=f[P+(K<<2)>>2]|0;if(!(b[S+84>>0]|0)){R=f[S+68>>2]|0;Y=f[R+(v<<2)>>2]|0;Z=f[R+(N<<2)>>2]|0}else{Y=v;Z=N}K=K+1|0;if((Z|0)!=(Y|0))break d;if((K|0)>=(O|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}while(0);if((M|0)==42){M=0;if(!V){M=44;break}else Q=V}f[(f[e>>2]|0)+(v<<2)>>2]=f[Q+12>>2];_=t}else M=44}else M=44;while(0);do if((M|0)==44){M=0;if(w){J=y>>>2;I=0;H=0;while(1){A=f[z+(I<<2)>>2]|0;if(!(b[A+84>>0]|0))aa=f[(f[A+68>>2]|0)+(v<<2)>>2]|0;else aa=v;A=aa+239^H;I=I+1|0;if((I|0)>=(J|0)){ba=A;break}else H=A}}else ba=0;e:do if(!x){H=B+-1|0;J=(H&B|0)==0;if(!J)if(ba>>>0>>0)ca=ba;else ca=(ba>>>0)%(B>>>0)|0;else ca=H&ba;I=f[(f[d>>2]|0)+(ca<<2)>>2]|0;if((I|0)!=0?(A=f[I>>2]|0,(A|0)!=0):0){I=f[s>>2]|0;C=I+8|0;G=I+12|0;if(J){J=A;while(1){I=f[J+4>>2]|0;if(!((I|0)==(ba|0)|(I&H|0)==(ca|0))){da=ca;M=76;break e}I=f[J+8>>2]|0;L=f[C>>2]|0;O=(f[G>>2]|0)-L|0;K=L;if((O|0)<=0){ea=v;break e}L=O>>>2;O=0;while(1){N=f[K+(O<<2)>>2]|0;if(!(b[N+84>>0]|0)){P=f[N+68>>2]|0;fa=f[P+(v<<2)>>2]|0;ga=f[P+(I<<2)>>2]|0}else{fa=v;ga=I}O=O+1|0;if((ga|0)!=(fa|0))break;if((O|0)>=(L|0)){ea=v;break e}}J=f[J>>2]|0;if(!J){da=ca;M=76;break e}}}else ha=A;while(1){J=f[ha+4>>2]|0;if((J|0)!=(ba|0)){if(J>>>0>>0)ia=J;else ia=(J>>>0)%(B>>>0)|0;if((ia|0)!=(ca|0)){da=ca;M=76;break e}}J=f[ha+8>>2]|0;H=f[C>>2]|0;L=(f[G>>2]|0)-H|0;O=H;if((L|0)<=0){ea=v;break e}H=L>>>2;L=0;while(1){I=f[O+(L<<2)>>2]|0;if(!(b[I+84>>0]|0)){K=f[I+68>>2]|0;ja=f[K+(v<<2)>>2]|0;ka=f[K+(J<<2)>>2]|0}else{ja=v;ka=J}L=L+1|0;if((ka|0)!=(ja|0))break;if((L|0)>=(H|0)){ea=v;break e}}ha=f[ha>>2]|0;if(!ha){da=ca;M=76;break}}}else{da=ca;M=76}}else{da=0;M=76}while(0);if((M|0)==76){M=0;G=ln(16)|0;f[G+8>>2]=v;f[G+12>>2]=t;f[G+4>>2]=ba;f[G>>2]=0;la=$(((f[o>>2]|0)+1|0)>>>0);ma=$(B>>>0);na=$(n[l>>2]);do if(x|$(na*ma)>>0<3|(B+-1&B|0)!=0)&1;A=~~$(W($(la/na)))>>>0;Ih(d,C>>>0>>0?A:C);C=f[q>>2]|0;A=C+-1|0;if(!(A&C)){oa=C;pa=A&ba;break}if(ba>>>0>>0){oa=C;pa=ba}else{oa=C;pa=(ba>>>0)%(C>>>0)|0}}else{oa=B;pa=da}while(0);C=(f[d>>2]|0)+(pa<<2)|0;A=f[C>>2]|0;if(!A){f[G>>2]=f[p>>2];f[p>>2]=G;f[C>>2]=p;C=f[G>>2]|0;if(C|0){H=f[C+4>>2]|0;C=oa+-1|0;if(C&oa)if(H>>>0>>0)qa=H;else qa=(H>>>0)%(oa>>>0)|0;else qa=H&C;ra=(f[d>>2]|0)+(qa<<2)|0;M=89}}else{f[G>>2]=f[A>>2];ra=A;M=89}if((M|0)==89){M=0;f[ra>>2]=G}f[o>>2]=(f[o>>2]|0)+1;ea=f[h>>2]|0}A=t+1|0;f[(f[e>>2]|0)+(ea<<2)>>2]=t;C=f[k>>2]|0;if((C|0)==(f[r>>2]|0)){Ri(g,h);_=A;break}else{f[C>>2]=f[h>>2];f[k>>2]=C+4;_=A;break}}while(0);v=(f[h>>2]|0)+1|0;f[h>>2]=v;sa=f[j>>2]|0;if(v>>>0>=sa>>>0)break;else t=_}if((_|0)!=(sa|0)){Xa[f[(f[a>>2]|0)+24>>2]&15](a,e,g);f[j>>2]=_}}_=f[g>>2]|0;if(_|0){g=f[k>>2]|0;if((g|0)!=(_|0))f[k>>2]=g+(~((g+-4-_|0)>>>2)<<2);Oq(_)}_=f[e>>2]|0;if(_|0){e=f[i>>2]|0;if((e|0)!=(_|0))f[i>>2]=e+(~((e+-4-_|0)>>>2)<<2);Oq(_)}_=f[d+8>>2]|0;if(_|0){e=_;do{_=e;e=f[e>>2]|0;Oq(_)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return}Oq(e);u=c;return}function tb(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;g=u;u=u+80|0;h=g+76|0;i=g+72|0;j=g+48|0;k=g+24|0;l=g;m=a+32|0;n=f[c>>2]|0;c=n+1|0;if((n|0)!=-1){o=((c>>>0)%3|0|0)==0?n+-2|0:c;c=(((n>>>0)%3|0|0)==0?2:-1)+n|0;if((o|0)==-1)p=-1;else p=f[(f[f[m>>2]>>2]|0)+(o<<2)>>2]|0;if((c|0)==-1){q=p;r=-1}else{q=p;r=f[(f[f[m>>2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0,G|0,C|0)|0;C=I;G=Ik(H|0,s|0,N|0,L|0)|0;s=I;H=Ik(E|0,C|0,N|0,L|0)|0;C=I;E=e<<1;F=f[d+(E<<2)>>2]|0;M=((F|0)<0)<<31>>31;B=f[d+((E|1)<<2)>>2]|0;E=((B|0)<0)<<31>>31;O=Xn(F|0,M|0,x|0,D|0)|0;J=I;P=Xn(B|0,E|0,p|0,K|0)|0;U=I;T=un(O|0,J|0,O|0,J|0)|0;J=I;O=un(P|0,U|0,P|0,U|0)|0;U=Vn(O|0,I|0,T|0,J|0)|0;J=I;T=Xn(F|0,M|0,G|0,s|0)|0;M=I;F=Xn(B|0,E|0,H|0,C|0)|0;E=I;B=un(T|0,M|0,T|0,M|0)|0;M=I;T=un(F|0,E|0,F|0,E|0)|0;E=Vn(T|0,I|0,B|0,M|0)|0;M=I;B=a+16|0;T=a+20|0;F=f[T>>2]|0;O=f[a+24>>2]|0;P=(F|0)==(O<<5|0);if(J>>>0>>0|(J|0)==(M|0)&U>>>0>>0){do if(P)if((F+1|0)<0)aq(B);else{E=O<<6;U=F+32&-32;vi(B,F>>>0<1073741823?(E>>>0>>0?U:E):2147483647);da=f[T>>2]|0;break}else da=F;while(0);f[T>>2]=da+1;L=(f[B>>2]|0)+(da>>>5<<2)|0;f[L>>2]=f[L>>2]|1<<(da&31);ea=x;fa=p;ga=K;ha=D}else{do if(P)if((F+1|0)<0)aq(B);else{L=O<<6;N=F+32&-32;vi(B,F>>>0<1073741823?(L>>>0>>0?N:L):2147483647);ia=f[T>>2]|0;break}else ia=F;while(0);f[T>>2]=ia+1;F=(f[B>>2]|0)+(ia>>>5<<2)|0;f[F>>2]=f[F>>2]&~(1<<(ia&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(r)ja=m<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+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(J|0)==(M|0)&U>>>0>>0){do if(P)if((F+1|0)<0)aq(B);else{E=O<<6;U=F+32&-32;vi(B,F>>>0<1073741823?(E>>>0>>0?U:E):2147483647);da=f[T>>2]|0;break}else da=F;while(0);f[T>>2]=da+1;L=(f[B>>2]|0)+(da>>>5<<2)|0;f[L>>2]=f[L>>2]|1<<(da&31);ea=x;fa=c;ga=K;ha=D}else{do if(P)if((F+1|0)<0)aq(B);else{L=O<<6;N=F+32&-32;vi(B,F>>>0<1073741823?(L>>>0>>0?N:L):2147483647);ia=f[T>>2]|0;break}else ia=F;while(0);f[T>>2]=ia+1;F=(f[B>>2]|0)+(ia>>>5<<2)|0;f[F>>2]=f[F>>2]&~(1<<(ia&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(q)ja=n<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(ja<<2)>>2];f[a+12>>2]=f[d+(ja+1<<2)>>2];u=g;return}function vb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=Oa,D=0,E=0.0,F=0,G=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){m=b[o>>0]|0;q=g+(r<<3)|0;f[q>>2]=m;f[q+4>>2]=((m|0)<0)<<31>>31;r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=g+(t<<3)|0;f[k>>2]=h[m>>0];f[k+4>>2]=0;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){o=d[l>>1]|0;k=g+(q<<3)|0;f[k>>2]=o;f[k+4>>2]=((o|0)<0)<<31>>31;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=j[r>>1];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<3)|0,0,(e<<24>>24)-r<<3|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){l=f[t>>2]|0;m=g+(o<<3)|0;f[m>>2]=l;f[m+4>>2]=((l|0)<0)<<31>>31;o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){r=g+(m<<3)|0;f[r>>2]=f[q>>2];f[r+4>>2]=0;m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){t=k;r=f[t+4>>2]|0;z=g+(l<<3)|0;f[z>>2]=f[t>>2];f[z+4>>2]=r;l=l+1|0;r=b[q>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=m;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;r=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;z=Vn(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+z|0;z=0;while(1){q=o;r=f[q+4>>2]|0;t=g+(z<<3)|0;f[t>>2]=f[q>>2];f[t+4>>2]=r;z=z+1|0;r=b[k>>0]|0;if((z|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){B=r;break}else o=o+8|0}}else B=l;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 9:{o=a+24|0;z=b[o>>0]|0;if((z<<24>>24>e<<24>>24?e:z)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){C=$(n[m>>2]);k=+K(+C)>=1.0?(+C>0.0?~~+Y(+J(+C/4294967296.0),4294967295.0)>>>0:~~+W((+C-+(~~+C>>>0))/4294967296.0)>>>0):0;r=g+(t<<3)|0;f[r>>2]=~~+C>>>0;f[r+4>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else m=m+4|0}}else D=z;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+r|0;r=0;while(1){E=+p[l>>3];o=+K(E)>=1.0?(E>0.0?~~+Y(+J(E/4294967296.0),4294967295.0)>>>0:~~+W((E-+(~~E>>>0))/4294967296.0)>>>0):0;k=g+(r<<3)|0;f[k>>2]=~~E>>>0;f[k+4>>2]=o;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){F=o;break}else l=l+8|0}}else F=t;l=F<<24>>24;if(F<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 11:{l=a+24|0;r=b[l>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){m=f[f[a>>2]>>2]|0;z=a+40|0;o=un(f[z>>2]|0,f[z+4>>2]|0,f[c>>2]|0,0)|0;z=a+48|0;k=Vn(o|0,I|0,f[z>>2]|0,f[z+4>>2]|0)|0;z=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=h[z>>0];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){G=m;break}else z=z+1|0}}else G=r;z=G<<24>>24;if(G<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(z<<3)|0,0,(e<<24>>24)-z<<3|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;c=u;u=u+16|0;d=c+8|0;e=c;if((f[a+96>>2]|0)==(f[a+92>>2]|0)){u=c;return}g=a+56|0;h=f[g>>2]|0;if((h|0)==(f[a+60>>2]|0)){Ri(a+52|0,b);i=b}else{f[h>>2]=f[b>>2];f[g>>2]=h+4;i=b}b=a+88|0;f[b>>2]=0;h=f[a>>2]|0;g=f[i>>2]|0;j=g+1|0;if((g|0)!=-1){k=((j>>>0)%3|0|0)==0?g+-2|0:j;if((k|0)==-1)l=-1;else l=f[(f[h>>2]|0)+(k<<2)>>2]|0;k=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((k|0)==-1){m=l;n=-1}else{m=l;n=f[(f[h>>2]|0)+(k<<2)>>2]|0}}else{m=-1;n=-1}k=a+24|0;h=f[k>>2]|0;l=h+(m>>>5<<2)|0;g=1<<(m&31);j=f[l>>2]|0;if(!(j&g)){f[l>>2]=j|g;g=f[i>>2]|0;j=g+1|0;if((g|0)==-1)o=-1;else o=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=o;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((o>>>0)/3|0)*12|0)+(((o>>>0)%3|0)<<2)>>2]|0;o=f[a+48>>2]|0;f[d>>2]=j;g=f[o+4>>2]|0;o=g+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+4>>2]|0;n=r+4|0;o=f[n>>2]|0;if((o|0)==(f[r+8>>2]|0))Ri(r,d);else{f[o>>2]=s;f[n>>2]=o+4}o=a+40|0;n=f[o>>2]|0;s=n+4|0;r=f[s>>2]|0;if((r|0)==(f[n+8>>2]|0)){Ri(n,e);v=f[o>>2]|0}else{f[r>>2]=f[e>>2];f[s>>2]=r+4;v=n}n=v+24|0;f[(f[v+12>>2]|0)+(t<<2)>>2]=f[n>>2];f[n>>2]=(f[n>>2]|0)+1}n=f[b>>2]|0;a:do if((n|0)<3){t=a+12|0;v=a+44|0;r=a+48|0;s=a+40|0;o=a+92|0;q=n;while(1){h=q;while(1){w=a+52+(h*12|0)+4|0;x=f[w>>2]|0;if((f[a+52+(h*12|0)>>2]|0)!=(x|0))break;if((h|0)<2)h=h+1|0;else break a}m=x+-4|0;p=f[m>>2]|0;f[w>>2]=m;f[b>>2]=h;f[i>>2]=p;if((p|0)==-1)break;m=(p>>>0)/3|0;g=f[t>>2]|0;do if(!(f[g+(m>>>5<<2)>>2]&1<<(m&31))){j=p;l=g;b:while(1){y=(j>>>0)/3|0;z=l+(y>>>5<<2)|0;f[z>>2]=1<<(y&31)|f[z>>2];z=f[i>>2]|0;if((z|0)==-1)A=-1;else A=f[(f[f[a>>2]>>2]|0)+(z<<2)>>2]|0;y=(f[k>>2]|0)+(A>>>5<<2)|0;B=1<<(A&31);C=f[y>>2]|0;if(!(B&C)){f[y>>2]=C|B;B=f[i>>2]|0;f[e>>2]=B;C=f[(f[(f[v>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=C;y=f[B+4>>2]|0;B=y+4|0;D=f[B>>2]|0;if((D|0)==(f[y+8>>2]|0))Ri(y,d);else{f[D>>2]=C;f[B>>2]=D+4}D=f[s>>2]|0;B=D+4|0;C=f[B>>2]|0;if((C|0)==(f[D+8>>2]|0)){Ri(D,e);E=f[s>>2]|0}else{f[C>>2]=f[e>>2];f[B>>2]=C+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(A<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;F=f[i>>2]|0}else F=z;z=f[a>>2]|0;if((F|0)==-1){G=93;break}D=F+1|0;C=((D>>>0)%3|0|0)==0?F+-2|0:D;if((C|0)==-1)H=-1;else H=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((C|0)==-1)I=-1;else I=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(H|0)==-1;D=C?-1:(H>>>0)/3|0;B=(I|0)==-1;y=B?-1:(I>>>0)/3|0;if(C)J=1;else J=(f[(f[t>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)|0)!=0;do if(B)if(J){G=93;break b}else G=82;else{if(f[(f[t>>2]|0)+(y>>>5<<2)>>2]&1<<(y&31)|0)if(J){G=93;break b}else{G=82;break}D=f[(f[z>>2]|0)+(I<<2)>>2]|0;if(!(1<<(D&31)&f[(f[k>>2]|0)+(D>>>5<<2)>>2])){K=(f[o>>2]|0)+(D<<2)|0;D=f[K>>2]|0;f[K>>2]=D+1;L=(D|0)>0?1:2}else L=0;if(J?(L|0)<=(f[b>>2]|0):0){M=I;break}f[d>>2]=I;D=a+52+(L*12|0)+4|0;K=f[D>>2]|0;if((K|0)==(f[a+52+(L*12|0)+8>>2]|0))Ri(a+52+(L*12|0)|0,d);else{f[K>>2]=I;f[D>>2]=K+4}if((f[b>>2]|0)>(L|0))f[b>>2]=L;if(J){G=93;break b}else G=82}while(0);if((G|0)==82){G=0;if(C)N=-1;else N=f[(f[f[a>>2]>>2]|0)+(H<<2)>>2]|0;if(!(1<<(N&31)&f[(f[k>>2]|0)+(N>>>5<<2)>>2])){z=(f[o>>2]|0)+(N<<2)|0;y=f[z>>2]|0;f[z>>2]=y+1;O=(y|0)>0?1:2}else O=0;if((O|0)>(f[b>>2]|0))break;else M=H}f[i>>2]=M;j=M;l=f[t>>2]|0}if((G|0)==93){G=0;P=f[b>>2]|0;break}f[d>>2]=H;l=a+52+(O*12|0)+4|0;j=f[l>>2]|0;if((j|0)==(f[a+52+(O*12|0)+8>>2]|0))Ri(a+52+(O*12|0)|0,d);else{f[j>>2]=H;f[l>>2]=j+4}j=f[b>>2]|0;if((j|0)>(O|0)){f[b>>2]=O;Q=O}else Q=j;P=Q}else P=h;while(0);if((P|0)<3)q=P;else break a}u=c;return}while(0);f[i>>2]=-1;u=c;return}function xb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}xb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;xb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function yb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}yb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;yb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function zb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}zb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;zb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ab(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ab(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ab(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}} +function Bb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Bb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Bb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Cb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Cb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Cb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Db(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Db(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Db(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Eb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Eb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Eb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Fb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Fb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Gb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Gb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Gb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Hb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Hb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Hb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ib(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ib(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ib(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Jb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Jb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Jb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Kb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Kb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Kb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Lb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Lb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Lb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Mb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Mb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Mb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Nb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Nb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Nb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ob(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ob(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ob(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Pb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2])>>>0;f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3]>>>0;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Qb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2]);f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Rb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=Oa,J=0,K=0,L=0,M=0,N=Oa;e=u;u=u+48|0;g=e+36|0;h=e+24|0;i=e+12|0;j=e;if(!(xh(a,c,d)|0)){k=0;u=e;return k|0}l=f[(f[(f[c+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;if((f[l+28>>2]|0)!=9){k=0;u=e;return k|0}m=c+48|0;c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=17;p=o;q=14495;r=p+17|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+17>>0]=0;o=c+16|0;s=f[o>>2]|0;if(s){t=o;v=s;a:while(1){s=v;while(1){if((f[s+16>>2]|0)>=(d|0))break;w=f[s+4>>2]|0;if(!w){x=t;break a}else s=w}v=f[s>>2]|0;if(!v){x=s;break}else t=s}if(((x|0)!=(o|0)?(f[x+16>>2]|0)<=(d|0):0)?(o=x+20|0,(Jh(o,g)|0)!=0):0)y=Hk(o,g,-1)|0;else z=12}else z=12;if((z|0)==12)y=Hk(c,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((y|0)<1){k=0;u=e;return k|0}c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=19;p=o;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+19>>0]=0;o=c+16|0;x=f[o>>2]|0;if(x){t=o;v=x;b:while(1){x=v;while(1){if((f[x+16>>2]|0)>=(d|0))break;w=f[x+4>>2]|0;if(!w){A=t;break b}else x=w}v=f[x>>2]|0;if(!v){A=x;break}else t=x}if((A|0)!=(o|0)?(f[A+16>>2]|0)<=(d|0):0)B=A+20|0;else z=24}else z=24;if((z|0)==24)B=c;if(!(Jh(B,g)|0))C=0;else{B=f[m>>2]|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=18;p=c;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[c+18>>0]=0;c=B+16|0;A=f[c>>2]|0;if(A){o=c;t=A;c:while(1){A=t;while(1){if((f[A+16>>2]|0)>=(d|0))break;v=f[A+4>>2]|0;if(!v){D=o;break c}else A=v}t=f[A>>2]|0;if(!t){D=A;break}else o=A}if((D|0)!=(c|0)?(f[D+16>>2]|0)<=(d|0):0)E=D+20|0;else z=34}else z=34;if((z|0)==34)E=B;B=(Jh(E,h)|0)!=0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);C=B}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!C){Wd(a+40|0,l,y)|0;k=1;u=e;return k|0}C=l+24|0;l=b[C>>0]|0;B=l<<24>>24;f[i>>2]=0;E=i+4|0;f[E>>2]=0;f[i+8>>2]=0;do if(l<<24>>24)if(l<<24>>24<0)aq(i);else{D=B<<2;c=ln(D)|0;f[i>>2]=c;o=c+(B<<2)|0;f[i+8>>2]=o;sj(c|0,0,D|0)|0;f[E>>2]=o;F=c;break}else F=0;while(0);B=f[m>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=ln(32)|0;f[j>>2]=l;f[j+8>>2]=-2147483616;f[j+4>>2]=19;p=l;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[l+19>>0]=0;l=b[C>>0]|0;c=l<<24>>24;o=B+16|0;D=f[o>>2]|0;if(D){t=o;x=D;d:while(1){D=x;while(1){if((f[D+16>>2]|0)>=(d|0))break;v=f[D+4>>2]|0;if(!v){G=t;break d}else D=v}x=f[D>>2]|0;if(!x){G=D;break}else t=D}if(((G|0)!=(o|0)?(f[G+16>>2]|0)<=(d|0):0)?(o=G+20|0,(Jh(o,j)|0)!=0):0){t=Rg(o,j)|0;if((t|0)!=(G+24|0)){pj(g,t+28|0);t=g+11|0;G=b[t>>0]|0;o=G<<24>>24<0;if(!((o?f[g+4>>2]|0:G&255)|0))H=G;else{if(l<<24>>24>0){x=o?f[g>>2]|0:g;o=0;do{I=$(bq(x,h));A=x;x=f[h>>2]|0;if((A|0)==(x|0))break;n[F+(o<<2)>>2]=I;o=o+1|0}while((o|0)<(c|0));J=b[t>>0]|0}else J=G;H=J}if(H<<24>>24<0)Oq(f[g>>2]|0)}}else z=64}else z=64;if((z|0)==64?(H=Rg(B,j)|0,(H|0)!=(B+4|0)):0){pj(g,H+28|0);H=g+11|0;B=b[H>>0]|0;J=B<<24>>24<0;if(!((J?f[g+4>>2]|0:B&255)|0))K=B;else{if(l<<24>>24>0){l=J?f[g>>2]|0:g;J=0;do{I=$(bq(l,h));G=l;l=f[h>>2]|0;if((G|0)==(l|0))break;n[F+(J<<2)>>2]=I;J=J+1|0}while((J|0)<(c|0));L=b[H>>0]|0}else L=B;K=L}if(K<<24>>24<0)Oq(f[g>>2]|0)}if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);j=f[m>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;m=ln(32)|0;f[g>>2]=m;f[g+8>>2]=-2147483616;f[g+4>>2]=18;p=m;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[m+18>>0]=0;m=j+16|0;q=f[m>>2]|0;if(q){p=m;r=q;e:while(1){q=r;while(1){if((f[q+16>>2]|0)>=(d|0))break;K=f[q+4>>2]|0;if(!K){M=p;break e}else q=K}r=f[q>>2]|0;if(!r){M=q;break}else p=q}if(((M|0)!=(m|0)?(f[M+16>>2]|0)<=(d|0):0)?(d=M+20|0,(Jh(d,g)|0)!=0):0)N=$(sk(d,g,$(1.0)));else z=86}else z=86;if((z|0)==86)N=$(sk(j,g,$(1.0)));if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Dl(a+40|0,y,f[i>>2]|0,b[C>>0]|0,N);C=f[i>>2]|0;if(C|0){i=f[E>>2]|0;if((i|0)!=(C|0))f[E>>2]=i+(~((i+-4-C|0)>>>2)<<2);Oq(C)}k=1;u=e;return k|0}function Sb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0;e=u;u=u+64|0;d=e+48|0;h=e+36|0;i=e+24|0;j=e+16|0;k=e+8|0;l=e;m=e+32|0;n=a+60|0;f[a+68>>2]=g;g=a+108|0;tk(g);o=a+56|0;p=f[o>>2]|0;q=(f[p+4>>2]|0)-(f[p>>2]|0)|0;r=q>>2;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;s=i;f[s>>2]=0;f[s+4>>2]=0;s=j;f[s>>2]=0;f[s+4>>2]=0;s=k;f[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=M}while(0);M=(Z|0)==0;P=(Y|0)==0;N=f[w>>2]|0;do if(Y|Z){H=(N|0)==(Y|0);if(!(M&H)){p=(N|0)==(Z|0);if(!(P&p)){if(M&(T|0)<(Y|0)){$=0;aa=(T<<1)-Y|0;break}if(p&(T|0)>(Y|0)){$=Z;aa=(T<<1)-Y|0;break}if(H&(T|0)>(Z|0)){$=(T<<1)-Z|0;aa=Y;break}if(P){$=(T|0)<(Z|0)?(T<<1)-Z|0:Z;aa=0}else{$=Z;aa=Y}}else{$=Z;aa=Z}}else{$=Y;aa=Y}}else{$=N;aa=N}while(0);f[i>>2]=$;f[v>>2]=aa;P=0-S|0;M=0-_|0;f[h>>2]=0-O;f[q>>2]=P;f[s>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(p=(N|0)==(ca|0),!(M&p)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>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while(0);M=(Z|0)==0;P=(Y|0)==0;N=f[w>>2]|0;do if(Y|Z){H=(N|0)==(Y|0);if(!(M&H)){p=(N|0)==(Z|0);if(!(P&p)){if(M&(T|0)<(Y|0)){$=0;aa=(T<<1)-Y|0;break}if(p&(T|0)>(Y|0)){$=Z;aa=(T<<1)-Y|0;break}if(H&(T|0)>(Z|0)){$=(T<<1)-Z|0;aa=Y;break}if(P){$=(T|0)<(Z|0)?(T<<1)-Z|0:Z;aa=0}else{$=Z;aa=Y}}else{$=Z;aa=Z}}else{$=Y;aa=Y}}else{$=N;aa=N}while(0);f[i>>2]=$;f[v>>2]=aa;P=0-S|0;M=0-_|0;f[h>>2]=0-O;f[q>>2]=P;f[s>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(p=(N|0)==(ca|0),!(M&p)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>>2]|0)+U|0;else ta=U;else ta=U-(f[F>>2]|0)|0;f[G>>2]=ta;if((((ra|0)>-1?ra:0-ra|0)+((qa|0)>-1?qa:0-qa|0)|0)<(((sa|0)>-1?sa:0-sa|0)+((ta|0)>-1?ta:0-ta|0)|0)){fj(g,0);ua=k}else{fj(g,1);ua=l}U=f[ua>>2]|0;if((U|0)<0)va=(f[F>>2]|0)+U|0;else va=U;U=c+(N<<2)|0;f[U>>2]=va;O=f[ua+4>>2]|0;if((O|0)<0)wa=(f[F>>2]|0)+O|0;else wa=O;f[U+4>>2]=wa;K=K+1|0;if((K|0)>=(r|0)){la=3;break}U=f[o>>2]|0;L=f[U>>2]|0;if((f[U+4>>2]|0)-L>>2>>>0<=K>>>0){J=U;la=4;break}}if((la|0)==3){u=e;return 1}else if((la|0)==4)aq(J);return 0}function Ub(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=Oa,V=Oa,Y=Oa,Z=0,_=0,aa=0,ba=0;d=u;u=u+16|0;e=d;g=a+16|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[g>>2]=$(1.0);i=a+20|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[a+36>>2]=$(1.0);j=f[c+8>>2]|0;a:do if(j|0){k=a+4|0;l=a+12|0;m=a+8|0;o=j;p=j;while(1){q=o+8|0;r=b[q+11>>0]|0;s=r<<24>>24<0;t=s?f[q>>2]|0:q;v=s?f[o+12>>2]|0:r&255;if(v>>>0>3){r=t;s=v;w=v;while(1){x=X(h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24,1540483477)|0;s=(X(x>>>24^x,1540483477)|0)^(X(s,1540483477)|0);w=w+-4|0;if(w>>>0<=3)break;else r=r+4|0}r=v+-4|0;w=r&-4;y=r-w|0;z=t+(w+4)|0;A=s}else{y=v;z=t;A=v}switch(y|0){case 3:{B=h[z+2>>0]<<16^A;C=8;break}case 2:{B=A;C=8;break}case 1:{D=A;C=9;break}default:E=A}if((C|0)==8){C=0;D=h[z+1>>0]<<8^B;C=9}if((C|0)==9){C=0;E=X(D^h[z>>0],1540483477)|0}w=X(E>>>13^E,1540483477)|0;r=w>>>15^w;w=f[k>>2]|0;x=(w|0)==0;b:do if(!x){F=w+-1|0;G=(F&w|0)==0;if(!G)if(r>>>0>>0)H=r;else H=(r>>>0)%(w>>>0)|0;else H=r&F;I=f[(f[a>>2]|0)+(H<<2)>>2]|0;if((I|0)!=0?(J=f[I>>2]|0,(J|0)!=0):0){I=(v|0)==0;if(G){if(I){G=J;while(1){K=f[G+4>>2]|0;if(!((K|0)==(r|0)|(K&F|0)==(H|0))){L=H;C=50;break b}K=b[G+8+11>>0]|0;if(!((K<<24>>24<0?f[G+12>>2]|0:K&255)|0))break b;G=f[G>>2]|0;if(!G){L=H;C=50;break b}}}else M=J;while(1){G=f[M+4>>2]|0;if(!((G|0)==(r|0)|(G&F|0)==(H|0))){L=H;C=50;break b}G=M+8|0;K=b[G+11>>0]|0;N=K<<24>>24<0;O=K&255;do if(((N?f[M+12>>2]|0:O)|0)==(v|0)){K=f[G>>2]|0;if(N)if(!(Vk(K,t,v)|0))break b;else break;if((b[t>>0]|0)==(K&255)<<24>>24){K=G;P=O;Q=t;do{P=P+-1|0;K=K+1|0;if(!P)break b;Q=Q+1|0}while((b[K>>0]|0)==(b[Q>>0]|0))}}while(0);M=f[M>>2]|0;if(!M){L=H;C=50;break b}}}if(I){F=J;while(1){O=f[F+4>>2]|0;if((O|0)!=(r|0)){if(O>>>0>>0)R=O;else R=(O>>>0)%(w>>>0)|0;if((R|0)!=(H|0)){L=H;C=50;break b}}O=b[F+8+11>>0]|0;if(!((O<<24>>24<0?f[F+12>>2]|0:O&255)|0))break b;F=f[F>>2]|0;if(!F){L=H;C=50;break b}}}else S=J;while(1){F=f[S+4>>2]|0;if((F|0)!=(r|0)){if(F>>>0>>0)T=F;else T=(F>>>0)%(w>>>0)|0;if((T|0)!=(H|0)){L=H;C=50;break b}}F=S+8|0;I=b[F+11>>0]|0;O=I<<24>>24<0;G=I&255;do if(((O?f[S+12>>2]|0:G)|0)==(v|0)){I=f[F>>2]|0;if(O)if(!(Vk(I,t,v)|0))break b;else break;if((b[t>>0]|0)==(I&255)<<24>>24){I=F;N=G;Q=t;do{N=N+-1|0;I=I+1|0;if(!N)break b;Q=Q+1|0}while((b[I>>0]|0)==(b[Q>>0]|0))}}while(0);S=f[S>>2]|0;if(!S){L=H;C=50;break}}}else{L=H;C=50}}else{L=0;C=50}while(0);if((C|0)==50){C=0;Di(e,a,r,q);U=$(((f[l>>2]|0)+1|0)>>>0);V=$(w>>>0);Y=$(n[g>>2]);do if(x|$(Y*V)>>0<3|(w+-1&w|0)!=0)&1;v=~~$(W($(U/Y)))>>>0;ei(a,t>>>0>>0?v:t);t=f[k>>2]|0;v=t+-1|0;if(!(v&t)){Z=t;_=v&r;break}if(r>>>0>>0){Z=t;_=r}else{Z=t;_=(r>>>0)%(t>>>0)|0}}else{Z=w;_=L}while(0);w=f[(f[a>>2]|0)+(_<<2)>>2]|0;if(!w){f[f[e>>2]>>2]=f[m>>2];f[m>>2]=f[e>>2];f[(f[a>>2]|0)+(_<<2)>>2]=m;r=f[e>>2]|0;x=f[r>>2]|0;if(x|0){q=f[x+4>>2]|0;x=Z+-1|0;if(x&Z)if(q>>>0>>0)aa=q;else aa=(q>>>0)%(Z>>>0)|0;else aa=q&x;f[(f[a>>2]|0)+(aa<<2)>>2]=r}}else{f[f[e>>2]>>2]=f[w>>2];f[w>>2]=f[e>>2]}f[l>>2]=(f[l>>2]|0)+1}w=f[p>>2]|0;if(!w)break a;else{o=w;p=w}}}while(0);e=f[c+28>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;q=c+40|0;o=i+4|0;t=i+12|0;v=i+8|0;w=a+40|0;x=a+64|0;y=f[e>>2]|0;e=r;z=0;A=0;B=r;C=r;D=0;E=r;while(1){r=s;F=f[r>>2]|0;G=f[r+4>>2]|0;r=q;H=un(f[r>>2]|0,f[r+4>>2]|0,y+z|0,0)|0;r=Vn(H|0,I|0,F|0,G|0)|0;G=(f[f[c>>2]>>2]|0)+r|0;r=h[G>>0]|h[G+1>>0]<<8|h[G+2>>0]<<16|h[G+3>>0]<<24;f[j>>2]=r;G=r&65535;F=r>>>16;H=F&65535;J=(r&65535^318)+239^F;F=(D|0)==0;a:do if(!F){K=D+-1|0;L=(K&D|0)==0;if(!L)if(J>>>0>>0)M=J;else M=(J>>>0)%(D>>>0)|0;else M=J&K;N=f[(f[i>>2]|0)+(M<<2)>>2]|0;do if(N|0?(O=f[N>>2]|0,O|0):0){b:do if(L){P=O;while(1){Q=f[P+4>>2]|0;R=(Q|0)==(J|0);if(!(R|(Q&K|0)==(M|0))){S=27;break b}if((R?(R=P+8|0,(d[R>>1]|0)==G<<16>>16):0)?(d[R+2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((d[Q>>1]|0)==G<<16>>16?(d[Q+2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(J>>>0>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((d[N>>1]|0)==G<<16>>16?(d[N+2>>1]|0)==H<<16>>16:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((d[L>>1]|0)==G<<16>>16?(d[L+2>>1]|0)==H<<16>>16:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;d[G>>1]=r;d[G+2>>1]=r>>>16;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(D>>>0);ga=$(n[l>>2]);do if(F|$(ga*fa)>>0<3|(D+-1&D|0)!=0)&1;O=~~$(W($(ea/ga)))>>>0;Uh(i,G>>>0>>0?O:G);G=f[o>>2]|0;O=G+-1|0;if(!(O&G)){ha=G;ia=O&J;break}if(J>>>0>>0){ha=G;ia=J}else{ha=G;ia=(J>>>0)%(G>>>0)|0}}else{ha=D;ia=aa}while(0);J=(f[i>>2]|0)+(ia<<2)|0;F=f[J>>2]|0;if(!F){f[H>>2]=f[v>>2];f[v>>2]=H;f[J>>2]=v;J=f[H>>2]|0;if(J|0){r=f[J+4>>2]|0;J=ha+-1|0;if(J&ha)if(r>>>0>>0)ja=r;else ja=(r>>>0)%(ha>>>0)|0;else ja=r&J;ka=(f[i>>2]|0)+(ja<<2)|0;S=59}}else{f[H>>2]=f[F>>2];ka=F;S=59}if((S|0)==59){S=0;f[ka>>2]=H}f[t>>2]=(f[t>>2]|0)+1;S=61}if((S|0)==61){S=0;F=w;J=f[F>>2]|0;r=un(J|0,f[F+4>>2]|0,A|0,0)|0;kh((f[f[x>>2]>>2]|0)+r|0,j|0,J|0)|0;J=f[k>>2]|0;f[J+(z<<2)>>2]=A;V=J;X=A+1|0;Y=J;Z=J;_=J}J=z+1|0;la=f[m>>2]|0;if(J>>>0>=la>>>0)break;e=V;z=J;A=X;B=Z;C=Y;D=f[o>>2]|0;E=_}if((X|0)==(la|0))ma=Z;else{Z=a+84|0;if(!(b[Z>>0]|0)){_=f[a+72>>2]|0;E=f[a+68>>2]|0;o=E;if((_|0)==(E|0))na=V;else{D=_-E>>2;E=0;do{_=o+(E<<2)|0;f[_>>2]=f[Y+(f[_>>2]<<2)>>2];E=E+1|0}while(E>>>0>>0);na=V}}else{b[Z>>0]=0;Z=a+68|0;V=a+72|0;D=f[V>>2]|0;E=f[Z>>2]|0;Y=D-E>>2;o=E;E=D;if(la>>>0<=Y>>>0)if(la>>>0>>0?(D=o+(la<<2)|0,(D|0)!=(E|0)):0){f[V>>2]=E+(~((E+-4-D|0)>>>2)<<2);oa=la}else oa=la;else{Ch(Z,la-Y|0,1220);oa=f[m>>2]|0}Y=f[k>>2]|0;if(!oa)na=Y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[Y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);na=Y}}f[m>>2]=X;ma=na}if(!ma)pa=X;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=X}}else pa=0;X=f[i+8>>2]|0;if(X|0){ma=X;do{X=ma;ma=f[ma>>2]|0;Oq(X)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function Wb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=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[N+8>>2]|0)==(E|0):0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}N=f[N>>2]|0;if(!N){Q=27;break}}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(D|0)){if((f[N+8>>2]|0)==(E|0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}}else{if(P>>>0>>0)S=P;else S=(P>>>0)%(q>>>0)|0;if((S|0)!=(K|0)){Q=27;break b}}N=f[N>>2]|0;if(!N){Q=27;break}}}while(0);if((Q|0)==26){Q=0;f[A+(y<<2)>>2]=f[R+16>>2];T=d;U=z;V=C;X=B;Y=A;break a}else if((Q|0)==27){Q=0;if(G){Z=0;Q=46;break a}else break}}while(0);H=q+-1|0;J=(H&q|0)==0;if(!J)if(D>>>0>>0)_=D;else _=(D>>>0)%(q>>>0)|0;else _=H&D;L=f[(f[g>>2]|0)+(_<<2)>>2]|0;if((L|0)!=0?(M=f[L>>2]|0,(M|0)!=0):0){if(J){J=M;while(1){L=f[J+4>>2]|0;if(!((L|0)==(D|0)|(L&H|0)==(_|0))){Z=_;Q=46;break a}if((f[J+8>>2]|0)==(E|0)?(f[J+12>>2]|0)==(F|0):0){Q=61;break a}J=f[J>>2]|0;if(!J){Z=_;Q=46;break a}}}else aa=M;while(1){J=f[aa+4>>2]|0;if((J|0)!=(D|0)){if(J>>>0>>0)ba=J;else ba=(J>>>0)%(q>>>0)|0;if((ba|0)!=(_|0)){Z=_;Q=46;break a}}if((f[aa+8>>2]|0)==(E|0)?(f[aa+12>>2]|0)==(F|0):0){Q=61;break a}aa=f[aa>>2]|0;if(!aa){Z=_;Q=46;break}}}else{Z=_;Q=46}}else{Z=0;Q=46}while(0);if((Q|0)==46){Q=0;M=ln(20)|0;J=M+8|0;f[J>>2]=E;f[J+4>>2]=F;f[M+16>>2]=z;f[M+4>>2]=D;f[M>>2]=0;ca=$(((f[s>>2]|0)+1|0)>>>0);da=$(q>>>0);ea=$(n[k>>2]);do if(G|$(ea*da)>>0<3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H=un(f[r>>2]|0,f[r+4>>2]|0,y+z|0,0)|0;r=Vn(H|0,I|0,F|0,G|0)|0;G=(f[f[c>>2]>>2]|0)+r|0;r=h[G>>0]|h[G+1>>0]<<8;d[j>>1]=r;G=r&255;F=(r&65535)>>>8;H=F&255;J=((r&255^318)+239<<16>>16^F)&65535;F=(D|0)==0;a:do if(!F){K=D+-1|0;L=(K&D|0)==0;if(!L)if(D>>>0>J>>>0)M=J;else M=(J>>>0)%(D>>>0)|0;else M=K&J;N=f[(f[i>>2]|0)+(M<<2)>>2]|0;do if(N|0?(O=f[N>>2]|0,O|0):0){b:do if(L){P=O;while(1){Q=f[P+4>>2]|0;R=(Q|0)==(J|0);if(!(R|(Q&K|0)==(M|0))){S=27;break b}if((R?(R=P+8|0,(b[R>>0]|0)==G<<24>>24):0)?(b[R+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((b[Q>>0]|0)==G<<24>>24?(b[Q+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(D>>>0>J>>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((b[N>>0]|0)==G<<24>>24?(b[N+1>>0]|0)==H<<24>>24:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((b[L>>0]|0)==G<<24>>24?(b[L+1>>0]|0)==H<<24>>24:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;b[G>>0]=r;b[G+1>>0]=r>>8;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(D>>>0);ga=$(n[l>>2]);do if(F|$(ga*fa)>>0<3|(D+-1&D|0)!=0)&1;O=~~$(W($(ea/ga)))>>>0;$h(i,G>>>0>>0?O:G);G=f[o>>2]|0;O=G+-1|0;if(!(O&G)){ha=G;ia=O&J;break}if(G>>>0>J>>>0){ha=G;ia=J}else{ha=G;ia=(J>>>0)%(G>>>0)|0}}else{ha=D;ia=aa}while(0);J=(f[i>>2]|0)+(ia<<2)|0;F=f[J>>2]|0;if(!F){f[H>>2]=f[v>>2];f[v>>2]=H;f[J>>2]=v;J=f[H>>2]|0;if(J|0){r=f[J+4>>2]|0;J=ha+-1|0;if(J&ha)if(r>>>0>>0)ja=r;else ja=(r>>>0)%(ha>>>0)|0;else ja=r&J;ka=(f[i>>2]|0)+(ja<<2)|0;S=59}}else{f[H>>2]=f[F>>2];ka=F;S=59}if((S|0)==59){S=0;f[ka>>2]=H}f[t>>2]=(f[t>>2]|0)+1;S=61}if((S|0)==61){S=0;F=w;J=f[F>>2]|0;r=un(J|0,f[F+4>>2]|0,A|0,0)|0;kh((f[f[x>>2]>>2]|0)+r|0,j|0,J|0)|0;J=f[k>>2]|0;f[J+(z<<2)>>2]=A;V=J;X=A+1|0;Y=J;Z=J;_=J}J=z+1|0;la=f[m>>2]|0;if(J>>>0>=la>>>0)break;e=V;z=J;A=X;B=Z;C=Y;D=f[o>>2]|0;E=_}if((X|0)==(la|0))ma=Z;else{Z=a+84|0;if(!(b[Z>>0]|0)){_=f[a+72>>2]|0;E=f[a+68>>2]|0;o=E;if((_|0)==(E|0))na=V;else{D=_-E>>2;E=0;do{_=o+(E<<2)|0;f[_>>2]=f[Y+(f[_>>2]<<2)>>2];E=E+1|0}while(E>>>0>>0);na=V}}else{b[Z>>0]=0;Z=a+68|0;V=a+72|0;D=f[V>>2]|0;E=f[Z>>2]|0;Y=D-E>>2;o=E;E=D;if(la>>>0<=Y>>>0)if(la>>>0>>0?(D=o+(la<<2)|0,(D|0)!=(E|0)):0){f[V>>2]=E+(~((E+-4-D|0)>>>2)<<2);oa=la}else oa=la;else{Ch(Z,la-Y|0,1220);oa=f[m>>2]|0}Y=f[k>>2]|0;if(!oa)na=Y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[Y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);na=Y}}f[m>>2]=X;ma=na}if(!ma)pa=X;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=X}}else pa=0;X=f[i+8>>2]|0;if(X|0){ma=X;do{X=ma;ma=f[ma>>2]|0;Oq(X)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function Yb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+200|0;v=a+320|0;w=a+152|0;x=a+84|0;y=a+324|0;z=a+292|0;A=a+304|0;B=a+316|0;C=a+328|0;D=a+336|0;E=a+332|0;F=a+168|0;G=a+140|0;H=a+120|0;I=o;do{o=f[I+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(J=(o>>>0)/3|0,K=f[n>>2]|0,(f[K+(J>>>5<<2)>>2]&1<<(J&31)|0)==0):0){if(l){J=0;L=K;b:while(1){K=J+1|0;f[i>>2]=(f[i>>2]|0)+1;M=f[b>>2]|0;N=(M|0)==-1?-1:(M>>>0)/3|0;M=L+(N>>>5<<2)|0;f[M>>2]=1<<(N&31)|f[M>>2];M=f[q>>2]|0;if((M|0)==(f[r>>2]|0))Ri(s,b);else{f[M>>2]=f[b>>2];f[q>>2]=M+4}f[v>>2]=f[b>>2];M=f[b>>2]|0;if((M|0)==-1)O=-1;else O=f[(f[f[p>>2]>>2]|0)+(M<<2)>>2]|0;P=(f[(f[w>>2]|0)+(O<<2)>>2]|0)!=-1;Q=(f[x>>2]|0)+(O>>>5<<2)|0;R=1<<(O&31);S=f[Q>>2]|0;do if(!(S&R)){f[Q>>2]=S|R;if(P){T=f[b>>2]|0;U=38;break}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12>>2]|0,aa=f[M+(Q<<2)>>2]|0,(aa|0)!=-1):0)?(Q=(aa>>>0)/3|0,aa=f[n>>2]|0,(f[aa+(Q>>>5<<2)>>2]&1<<(Q&31)|0)==0):0){Q=(((T>>>0)%3|0|0)==0?2:-1)+T|0;do if((Q|0)!=-1){V=f[M+(Q<<2)>>2]|0;if((V|0)==-1)break;_=(V>>>0)/3|0;if(!(f[aa+(_>>>5<<2)>>2]&1<<(_&31))){U=62;break b}}while(0);if(!ea)xf(a,f[i>>2]|0,N,0,fa);nd(t,3);ga=f[e>>2]|0}else{if(!R){xf(a,f[i>>2]|0,N,1,S);aa=f[b>>2]|0;if((aa|0)==-1){U=52;break}else ha=aa}else ha=T;aa=(((ha>>>0)%3|0|0)==0?2:-1)+ha|0;if((aa|0)==-1){U=52;break}Q=f[(f[(f[p>>2]|0)+12>>2]|0)+(aa<<2)>>2]|0;if((Q|0)==-1){U=52;break}aa=(Q>>>0)/3|0;if(f[(f[n>>2]|0)+(aa>>>5<<2)>>2]&1<<(aa&31)|0){U=52;break}nd(t,5);ga=da}f[b>>2]=ga}if((K|0)>=(k|0))break a;J=K;L=f[n>>2]|0}do if((U|0)==43){U=0;f[e>>2]=-1;U=54}else if((U|0)==52){U=0;if(ea)U=54;else{xf(a,f[i>>2]|0,N,0,fa);U=54}}else if((U|0)==62){U=0;nd(t,1);f[F>>2]=(f[F>>2]|0)+1;if(P?(L=f[(f[w>>2]|0)+(O<<2)>>2]|0,(1<<(L&31)&f[(f[G>>2]|0)+(L>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}L=f[i>>2]|0;f[d>>2]=N;J=je(H,d)|0;f[J>>2]=L;L=f[j>>2]|0;f[L+-4>>2]=da;if((L|0)==(f[m>>2]|0)){Ri(h,e);break}else{f[L>>2]=f[e>>2];f[j>>2]=L+4;break}}while(0);if((U|0)==54){U=0;nd(t,7);f[j>>2]=(f[j>>2]|0)+-4}}}else U=11;while(0);if((U|0)==11){U=0;f[j>>2]=I+-4}I=f[j>>2]|0}while((f[h>>2]|0)!=(I|0));u=c;return 1}function Zb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;do if((g|0)!=-1){l=f[m+28>>2]|0;o=f[l+((((j>>>0)%3|0|0)==0?g+-2|0:j)<<2)>>2]|0;if(!((g>>>0)%3|0)){p=o;q=g+2|0;r=l;break}else{p=o;q=g+-1|0;r=l;break}}else{l=f[m+28>>2]|0;p=f[l+-4>>2]|0;q=-1;r=l}while(0);m=f[r+(q<<2)>>2]|0;q=a+24|0;r=f[q>>2]|0;g=r+(p>>>5<<2)|0;j=1<<(p&31);l=f[g>>2]|0;if(!(l&j)){f[g>>2]=l|j;j=f[b>>2]|0;l=j+1|0;if((j|0)==-1)s=-1;else s=((l>>>0)%3|0|0)==0?j+-2|0:l;f[e>>2]=s;l=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((s>>>0)/3|0)*12|0)+(((s>>>0)%3|0)<<2)>>2]|0;s=f[a+48>>2]|0;f[d>>2]=l;j=f[s+4>>2]|0;s=j+4|0;g=f[s>>2]|0;if((g|0)==(f[j+8>>2]|0))Ri(j,d);else{f[g>>2]=l;f[s>>2]=g+4}g=a+40|0;s=f[g>>2]|0;l=s+4|0;j=f[l>>2]|0;if((j|0)==(f[s+8>>2]|0)){Ri(s,e);t=f[g>>2]|0}else{f[j>>2]=f[e>>2];f[l>>2]=j+4;t=s}s=t+24|0;f[(f[t+12>>2]|0)+(p<<2)>>2]=f[s>>2];f[s>>2]=(f[s>>2]|0)+1;v=f[q>>2]|0}else v=r;r=v+(m>>>5<<2)|0;v=1<<(m&31);s=f[r>>2]|0;if(!(s&v)){f[r>>2]=s|v;v=f[b>>2]|0;do if((v|0)!=-1)if(!((v>>>0)%3|0)){w=v+2|0;break}else{w=v+-1|0;break}else w=-1;while(0);f[e>>2]=w;v=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((w>>>0)/3|0)*12|0)+(((w>>>0)%3|0)<<2)>>2]|0;w=f[a+48>>2]|0;f[d>>2]=v;s=f[w+4>>2]|0;w=s+4|0;r=f[w>>2]|0;if((r|0)==(f[s+8>>2]|0))Ri(s,d);else{f[r>>2]=v;f[w>>2]=r+4}r=a+40|0;w=f[r>>2]|0;v=w+4|0;s=f[v>>2]|0;if((s|0)==(f[w+8>>2]|0)){Ri(w,e);x=f[r>>2]|0}else{f[s>>2]=f[e>>2];f[v>>2]=s+4;x=w}w=x+24|0;f[(f[x+12>>2]|0)+(m<<2)>>2]=f[w>>2];f[w>>2]=(f[w>>2]|0)+1}w=f[h>>2]|0;m=f[k>>2]|0;if((w|0)==(m|0)){u=c;return}x=a+44|0;s=a+48|0;v=a+40|0;r=m;m=w;while(1){w=f[r+-4>>2]|0;f[b>>2]=w;p=(w>>>0)/3|0;if((w|0)!=-1?(w=f[i>>2]|0,(f[w+(p>>>5<<2)>>2]&1<<(p&31)|0)==0):0){t=p;p=w;w=f[a>>2]|0;a:while(1){j=p+(t>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(t&31);j=f[b>>2]|0;l=f[(f[w+28>>2]|0)+(j<<2)>>2]|0;g=(f[q>>2]|0)+(l>>>5<<2)|0;o=1<<(l&31);y=f[g>>2]|0;if(!(o&y)){z=f[(f[w+40>>2]|0)+(l<<2)>>2]|0;if((z|0)==-1)A=1;else{B=f[(f[f[w+64>>2]>>2]|0)+(z<<2)>>2]|0;A=(1<<(B&31)&f[(f[w+12>>2]|0)+(B>>>5<<2)>>2]|0)!=0}f[g>>2]=y|o;o=f[b>>2]|0;f[e>>2]=o;y=f[(f[(f[x>>2]|0)+96>>2]|0)+(((o>>>0)/3|0)*12|0)+(((o>>>0)%3|0)<<2)>>2]|0;o=f[s>>2]|0;f[d>>2]=y;g=f[o+4>>2]|0;o=g+4|0;B=f[o>>2]|0;if((B|0)==(f[g+8>>2]|0))Ri(g,d);else{f[B>>2]=y;f[o>>2]=B+4}B=f[v>>2]|0;o=B+4|0;y=f[o>>2]|0;if((y|0)==(f[B+8>>2]|0)){Ri(B,e);C=f[v>>2]|0}else{f[y>>2]=f[e>>2];f[o>>2]=y+4;C=B}B=C+24|0;f[(f[C+12>>2]|0)+(l<<2)>>2]=f[B>>2];f[B>>2]=(f[B>>2]|0)+1;B=f[a>>2]|0;l=f[b>>2]|0;if(A){D=l;E=B;F=57}else{y=l+1|0;do if((l|0)==-1)G=-1;else{o=((y>>>0)%3|0|0)==0?l+-2|0:y;if((o|0)==-1){G=-1;break}if(f[(f[B>>2]|0)+(o>>>5<<2)>>2]&1<<(o&31)|0){G=-1;break}G=f[(f[(f[B+64>>2]|0)+12>>2]|0)+(o<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0;I=B}}else{D=j;E=w;F=57}if((F|0)==57){F=0;y=D+1|0;if((D|0)==-1){F=58;break}l=((y>>>0)%3|0|0)==0?D+-2|0:y;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)J=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else J=-1;f[d>>2]=J;l=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)K=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else K=-1;l=(J|0)==-1;y=(J>>>0)/3|0;o=l?-1:y;g=(K|0)==-1;z=(K>>>0)/3|0;L=g?-1:z;do if(!l){M=f[i>>2]|0;if(f[M+(o>>>5<<2)>>2]&1<<(o&31)|0){F=67;break}if(g){N=J;O=y;break}if(!(f[M+(L>>>5<<2)>>2]&1<<(L&31))){F=72;break a}else{N=J;O=y}}else F=67;while(0);if((F|0)==67){F=0;if(g){F=69;break}if(!(f[(f[i>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31))){N=K;O=z}else{F=69;break}}f[b>>2]=N;H=O;I=E}t=H;p=f[i>>2]|0;w=I}do if((F|0)==58){F=0;f[d>>2]=-1;F=69}else if((F|0)==72){F=0;w=f[k>>2]|0;f[w+-4>>2]=K;if((w|0)==(f[n>>2]|0)){Ri(h,d);P=f[k>>2]|0;break}else{f[w>>2]=f[d>>2];p=w+4|0;f[k>>2]=p;P=p;break}}while(0);if((F|0)==69){F=0;p=(f[k>>2]|0)+-4|0;f[k>>2]=p;P=p}Q=f[h>>2]|0;R=P}else{p=r+-4|0;f[k>>2]=p;Q=m;R=p}if((Q|0)==(R|0))break;else{r=R;m=Q}}u=c;return}function _b(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=Oa,K=Oa,L=Oa,M=0,N=0,O=0,P=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=Id(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];lf(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;Fi(j,8);l=d;d=l;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=l+4|0;l=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=f[j>>2]|0;o=d;b[o>>0]=m;b[o+1>>0]=m>>8;b[o+2>>0]=m>>16;b[o+3>>0]=m>>24;m=d+4|0;b[m>>0]=l;b[m+1>>0]=l>>8;b[m+2>>0]=l>>16;b[m+3>>0]=l>>24;pj(i,c);c=i+12|0;f[c>>2]=0;l=i+16|0;f[l>>2]=0;f[i+20>>2]=0;m=f[k>>2]|0;d=f[j>>2]|0;o=m-d|0;if(!o){p=d;q=m;r=0}else{Fi(c,o);p=f[j>>2]|0;q=f[k>>2]|0;r=f[c>>2]|0}kh(r|0,p|0,q-p|0)|0;p=i+11|0;q=b[p>>0]|0;r=q<<24>>24<0;c=r?f[i>>2]|0:i;o=r?f[i+4>>2]|0:q&255;if(o>>>0>3){q=c;r=o;m=o;while(1){d=X(h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);m=m+-4|0;if(m>>>0<=3)break;else q=q+4|0}q=o+-4|0;m=q&-4;s=q-m|0;t=c+(m+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(m=f[r>>2]|0,(m|0)!=0):0){r=(o|0)==0;if(s){if(r){s=m;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=m;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=m;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=m;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=$(y>>>0);L=$(n[a+16>>2]);do if(w|$(L*K)>>0<3|(y+-1&y|0)!=0)&1;H=~~$(W($(J/L)))>>>0;ei(a,A>>>0>>0?H:A);A=f[t>>2]|0;H=A+-1|0;if(!(H&A)){M=A;N=H&z;break}if(z>>>0>>0){M=A;N=z}else{M=A;N=(z>>>0)%(A>>>0)|0}}else{M=y;N=B}while(0);B=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!B){y=a+8|0;f[f[g>>2]>>2]=f[y>>2];f[y>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>2]=y;y=f[g>>2]|0;N=f[y>>2]|0;if(!N)O=g;else{z=f[N+4>>2]|0;N=M+-1|0;if(N&M)if(z>>>0>>0)P=z;else P=(z>>>0)%(M>>>0)|0;else P=z&N;f[(f[a>>2]|0)+(P<<2)>>2]=y;O=g}}else{f[f[g>>2]>>2]=f[B>>2];f[B>>2]=f[g>>2];O=g}f[x>>2]=(f[x>>2]|0)+1;f[O>>2]=0}O=f[i+12>>2]|0;if(O|0){if((f[l>>2]|0)!=(O|0))f[l>>2]=O;Oq(O)}if((b[p>>0]|0)<0)Oq(f[i>>2]|0);i=f[j>>2]|0;if(!i){u=e;return}if((f[k>>2]|0)!=(i|0))f[k>>2]=i;Oq(i);u=e;return}function $b(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0;e=u;u=u+96|0;g=e+92|0;h=e+88|0;i=e+72|0;j=e+48|0;k=e+24|0;l=e;m=a+16|0;n=f[m>>2]|0;o=f[c>>2]|0;f[i>>2]=n;f[i+4>>2]=o;c=i+8|0;f[c>>2]=o;b[i+12>>0]=1;p=(o|0)==-1;if(p)q=-1;else q=f[(f[n>>2]|0)+(o<<2)>>2]|0;n=a+20|0;r=f[n>>2]|0;s=f[r>>2]|0;if((f[r+4>>2]|0)-s>>2>>>0<=q>>>0)aq(r);r=a+8|0;t=f[(f[r>>2]|0)+(f[s+(q<<2)>>2]<<2)>>2]|0;q=a+4|0;s=f[q>>2]|0;if(!(b[s+84>>0]|0))v=f[(f[s+68>>2]|0)+(t<<2)>>2]|0;else v=t;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=v;v=b[s+24>>0]|0;f[g>>2]=f[h>>2];vb(s,g,v,j)|0;v=a+28|0;a=(f[v>>2]|0)==0;a:do if(!p){s=k+8|0;t=j+8|0;w=k+16|0;x=j+16|0;y=l+8|0;z=l+16|0;A=o;B=o;C=0;D=0;E=0;F=0;G=0;H=0;J=a;K=o;while(1){do if(J){L=K+1|0;if((K|0)==-1){M=A;N=-1;O=-1;P=-1;break}Q=((L>>>0)%3|0|0)==0?K+-2|0:L;if((A|0)!=-1)if(!((A>>>0)%3|0)){R=A;S=A+2|0;T=Q;U=A;V=19;break}else{R=A;S=A+-1|0;T=Q;U=A;V=19;break}else{R=-1;S=-1;T=Q;U=-1;V=19}}else{Q=B+1|0;L=((Q>>>0)%3|0|0)==0?B+-2|0:Q;if(!((B>>>0)%3|0)){R=A;S=B+2|0;T=L;U=K;V=19;break}else{R=A;S=B+-1|0;T=L;U=K;V=19;break}}while(0);if((V|0)==19){V=0;if((T|0)==-1){M=R;N=-1;O=S;P=U}else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){v=o;w=s;x=0}else{Fi(c,d);v=f[j>>2]|0;w=f[k>>2]|0;x=f[c>>2]|0}kh(x|0,v|0,w-v|0)|0;v=i+11|0;w=b[v>>0]|0;x=w<<24>>24<0;c=x?f[i>>2]|0:i;d=x?f[i+4>>2]|0:w&255;if(d>>>0>3){w=c;x=d;s=d;while(1){o=X(h[w>>0]|h[w+1>>0]<<8|h[w+2>>0]<<16|h[w+3>>0]<<24,1540483477)|0;x=(X(o>>>24^o,1540483477)|0)^(X(x,1540483477)|0);s=s+-4|0;if(s>>>0<=3)break;else w=w+4|0}w=d+-4|0;s=w&-4;y=w-s|0;z=c+(s+4)|0;A=x}else{y=d;z=c;A=d}switch(y|0){case 3:{B=h[z+2>>0]<<16^A;C=12;break}case 2:{B=A;C=12;break}case 1:{D=A;C=13;break}default:E=A}if((C|0)==12){D=h[z+1>>0]<<8^B;C=13}if((C|0)==13)E=X(D^h[z>>0],1540483477)|0;z=X(E>>>13^E,1540483477)|0;E=z>>>15^z;z=a+4|0;D=f[z>>2]|0;B=(D|0)==0;a:do if(!B){A=D+-1|0;y=(A&D|0)==0;if(!y)if(E>>>0>>0)F=E;else F=(E>>>0)%(D>>>0)|0;else F=E&A;x=f[(f[a>>2]|0)+(F<<2)>>2]|0;if((x|0)!=0?(s=f[x>>2]|0,(s|0)!=0):0){x=(d|0)==0;if(y){if(x){y=s;while(1){w=f[y+4>>2]|0;if(!((w|0)==(E|0)|(w&A|0)==(F|0))){G=F;C=54;break a}w=b[y+8+11>>0]|0;if(!((w<<24>>24<0?f[y+12>>2]|0:w&255)|0))break a;y=f[y>>2]|0;if(!y){G=F;C=54;break a}}}else H=s;while(1){y=f[H+4>>2]|0;if(!((y|0)==(E|0)|(y&A|0)==(F|0))){G=F;C=54;break a}y=H+8|0;w=b[y+11>>0]|0;o=w<<24>>24<0;t=w&255;do if(((o?f[H+12>>2]|0:t)|0)==(d|0)){w=f[y>>2]|0;if(o)if(!(Vk(w,c,d)|0))break a;else break;if((b[c>>0]|0)==(w&255)<<24>>24){w=y;l=t;q=c;do{l=l+-1|0;w=w+1|0;if(!l)break a;q=q+1|0}while((b[w>>0]|0)==(b[q>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){G=F;C=54;break a}}}if(x){A=s;while(1){t=f[A+4>>2]|0;if((t|0)!=(E|0)){if(t>>>0>>0)I=t;else I=(t>>>0)%(D>>>0)|0;if((I|0)!=(F|0)){G=F;C=54;break a}}t=b[A+8+11>>0]|0;if(!((t<<24>>24<0?f[A+12>>2]|0:t&255)|0))break a;A=f[A>>2]|0;if(!A){G=F;C=54;break a}}}else J=s;while(1){A=f[J+4>>2]|0;if((A|0)!=(E|0)){if(A>>>0>>0)K=A;else K=(A>>>0)%(D>>>0)|0;if((K|0)!=(F|0)){G=F;C=54;break a}}A=J+8|0;x=b[A+11>>0]|0;t=x<<24>>24<0;y=x&255;do if(((t?f[J+12>>2]|0:y)|0)==(d|0)){x=f[A>>2]|0;if(t)if(!(Vk(x,c,d)|0))break a;else break;if((b[c>>0]|0)==(x&255)<<24>>24){x=A;o=y;q=c;do{o=o+-1|0;x=x+1|0;if(!o)break a;q=q+1|0}while((b[x>>0]|0)==(b[q>>0]|0))}}while(0);J=f[J>>2]|0;if(!J){G=F;C=54;break}}}else{G=F;C=54}}else{G=0;C=54}while(0);if((C|0)==54){oi(g,a,E,i);C=a+12|0;L=$(((f[C>>2]|0)+1|0)>>>0);M=$(D>>>0);N=$(n[a+16>>2]);do if(B|$(N*M)>>0<3|(D+-1&D|0)!=0)&1;J=~~$(W($(L/N)))>>>0;ei(a,F>>>0>>0?J:F);F=f[z>>2]|0;J=F+-1|0;if(!(J&F)){O=F;P=J&E;break}if(E>>>0>>0){O=F;P=E}else{O=F;P=(E>>>0)%(F>>>0)|0}}else{O=D;P=G}while(0);G=f[(f[a>>2]|0)+(P<<2)>>2]|0;if(!G){D=a+8|0;f[f[g>>2]>>2]=f[D>>2];f[D>>2]=f[g>>2];f[(f[a>>2]|0)+(P<<2)>>2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[s>>2]=z+(~((z+-4-o|0)>>>2)<<2);A=q;B=w}else{A=q;B=w}else{Ch(r,t-v|0,g);A=f[e>>2]|0;B=f[r>>2]|0}x=B;y=A}f[x+(y<<2)>>2]=((f[p>>2]|0)-(f[n>>2]|0)>>2)+-1;C=1;u=d;return C|0}n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;p=f[(f[(f[n>>2]|0)+84>>2]|0)+(c<<2)>>2]|0;n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+4|0;y=f[(f[(f[n>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;f[g>>2]=-1;n=a+172|0;x=f[a+176>>2]|0;A=f[n>>2]|0;B=A;a:do if((x|0)==(A|0))D=-1;else{r=(x-A|0)/136|0;v=0;while(1){if((f[B+(v*136|0)>>2]|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0]|0:0)break;x=ln(88)|0;r=f[a+8>>2]|0;t=B+(D*136|0)+104|0;f[x+4>>2]=0;f[x>>2]=3564;w=x+12|0;f[w>>2]=3588;q=x+64|0;f[q>>2]=0;f[x+68>>2]=0;f[x+72>>2]=0;o=x+16|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[x+76>>2]=r;f[x+80>>2]=t;s=x+84|0;f[s>>2]=0;f[h>>2]=3588;E=h+4|0;F=E+4|0;f[F>>2]=0;f[F+4>>2]=0;f[F+8>>2]=0;f[F+12>>2]=0;f[F+16>>2]=0;f[F+20>>2]=0;F=B+(D*136|0)+4|0;G=i+4|0;f[G>>2]=3588;H=i+56|0;f[H>>2]=0;I=i+60|0;f[I>>2]=0;f[i+64>>2]=0;o=i+8|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[E>>2]=F;o=f[B+(D*136|0)+68>>2]|0;z=((f[o+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;qh(h+8|0,z,e);Va[f[(f[h>>2]|0)+8>>2]&127](h);Df(j,h);Df(e,j);f[i>>2]=f[e+4>>2];z=i+4|0;fg(z,e)|0;f[e>>2]=3588;o=f[e+20>>2]|0;if(o|0)Oq(o);o=f[e+8>>2]|0;if(o|0)Oq(o);f[i+36>>2]=F;f[i+40>>2]=t;f[i+44>>2]=r;f[i+48>>2]=x;f[j>>2]=3588;o=f[j+20>>2]|0;if(o|0)Oq(o);o=f[j+8>>2]|0;if(o|0)Oq(o);f[s>>2]=a+72;f[x+8>>2]=f[i>>2];fg(w,z)|0;z=x+44|0;o=i+36|0;f[z>>2]=f[o>>2];f[z+4>>2]=f[o+4>>2];f[z+8>>2]=f[o+8>>2];f[z+12>>2]=f[o+12>>2];b[z+16>>0]=b[o+16>>0]|0;ng(q,f[H>>2]|0,f[I>>2]|0);o=x;z=f[H>>2]|0;if(z|0){J=f[I>>2]|0;if((J|0)!=(z|0))f[I>>2]=J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16>>2]|0)>>>0){f[l>>2]=0;f[K>>2]=c;f[a>>2]=K+4;S=l}else{Qg(k+8|0,l);S=l}l=f[S>>2]|0;f[S>>2]=0;if(!l)Q=1;else{Va[f[(f[l>>2]|0)+4>>2]&127](l);Q=1}}C=Q;u=d;return C|0}function cc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;d=u;u=u+192|0;e=d+152|0;g=d+144|0;h=d+72|0;i=d;j=d+112|0;k=d+108|0;l=d+104|0;m=a+288|0;if(b[m>>0]|0?(n=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0,((f[n+12>>2]|0)-(f[n+8>>2]|0)|0)>0):0){n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+8|0;o=f[f[n>>2]>>2]|0;f[e>>2]=c;n=o+4|0;p=o+8|0;q=f[p>>2]|0;if((q|0)==(f[o+12>>2]|0))Ri(n,e);else{f[q>>2]=c;f[p>>2]=q+4}q=f[e>>2]|0;r=o+16|0;s=o+20|0;o=f[s>>2]|0;t=f[r>>2]|0;v=o-t>>2;w=t;if((q|0)<(v|0)){x=w;y=q}else{t=q+1|0;f[g>>2]=-1;z=o;if(t>>>0<=v>>>0)if(t>>>0>>0?(o=w+(t<<2)|0,(o|0)!=(z|0)):0){f[s>>2]=z+(~((z+-4-o|0)>>>2)<<2);A=q;B=w}else{A=q;B=w}else{Ch(r,t-v|0,g);A=f[e>>2]|0;B=f[r>>2]|0}x=B;y=A}f[x+(y<<2)>>2]=((f[p>>2]|0)-(f[n>>2]|0)>>2)+-1;C=1;u=d;return C|0}n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;p=f[(f[(f[n>>2]|0)+84>>2]|0)+(c<<2)>>2]|0;n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+4|0;y=f[(f[(f[n>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;f[g>>2]=-1;n=a+172|0;x=f[a+176>>2]|0;A=f[n>>2]|0;B=A;a:do if((x|0)==(A|0))D=-1;else{r=(x-A|0)/136|0;v=0;while(1){if((f[B+(v*136|0)>>2]|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0]|0:0)break;x=ln(88)|0;r=f[a+8>>2]|0;t=B+(D*136|0)+104|0;f[x+4>>2]=0;f[x>>2]=3564;w=x+12|0;f[w>>2]=3588;q=x+64|0;f[q>>2]=0;f[x+68>>2]=0;f[x+72>>2]=0;o=x+16|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[x+76>>2]=r;f[x+80>>2]=t;s=x+84|0;f[s>>2]=0;f[h>>2]=3588;E=h+4|0;F=E+4|0;f[F>>2]=0;f[F+4>>2]=0;f[F+8>>2]=0;f[F+12>>2]=0;f[F+16>>2]=0;f[F+20>>2]=0;F=B+(D*136|0)+4|0;G=i+4|0;f[G>>2]=3588;H=i+56|0;f[H>>2]=0;I=i+60|0;f[I>>2]=0;f[i+64>>2]=0;o=i+8|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[E>>2]=F;o=f[B+(D*136|0)+68>>2]|0;z=((f[o+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;qh(h+8|0,z,e);Va[f[(f[h>>2]|0)+8>>2]&127](h);Df(j,h);Df(e,j);f[i>>2]=f[e+4>>2];z=i+4|0;fg(z,e)|0;f[e>>2]=3588;o=f[e+20>>2]|0;if(o|0)Oq(o);o=f[e+8>>2]|0;if(o|0)Oq(o);f[i+36>>2]=F;f[i+40>>2]=t;f[i+44>>2]=r;f[i+48>>2]=x;f[j>>2]=3588;o=f[j+20>>2]|0;if(o|0)Oq(o);o=f[j+8>>2]|0;if(o|0)Oq(o);f[s>>2]=a+72;f[x+8>>2]=f[i>>2];fg(w,z)|0;z=x+44|0;o=i+36|0;f[z>>2]=f[o>>2];f[z+4>>2]=f[o+4>>2];f[z+8>>2]=f[o+8>>2];f[z+12>>2]=f[o+12>>2];b[z+16>>0]=b[o+16>>0]|0;ng(q,f[H>>2]|0,f[I>>2]|0);o=x;z=f[H>>2]|0;if(z|0){J=f[I>>2]|0;if((J|0)!=(z|0))f[I>>2]=J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16>>2]|0)>>>0){f[l>>2]=0;f[K>>2]=c;f[a>>2]=K+4;S=l}else{Qg(k+8|0,l);S=l}l=f[S>>2]|0;f[S>>2]=0;if(!l)Q=1;else{Va[f[(f[l>>2]|0)+4>>2]&127](l);Q=1}}C=Q;u=d;return C|0}function dc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;if((g|0)!=-1){l=((j>>>0)%3|0|0)==0?g+-2|0:j;if((l|0)==-1)o=-1;else o=f[(f[m>>2]|0)+(l<<2)>>2]|0;l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1){p=o;q=-1}else{p=o;q=f[(f[m>>2]|0)+(l<<2)>>2]|0}}else{p=-1;q=-1}l=a+24|0;m=f[l>>2]|0;o=m+(p>>>5<<2)|0;g=1<<(p&31);j=f[o>>2]|0;if(!(j&g)){f[o>>2]=j|g;g=f[b>>2]|0;j=g+1|0;if((g|0)==-1)r=-1;else r=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=r;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=j;g=f[r+4>>2]|0;r=g+4|0;o=f[r>>2]|0;if((o|0)==(f[g+8>>2]|0))Ri(g,d);else{f[o>>2]=j;f[r>>2]=o+4}o=a+40|0;r=f[o>>2]|0;j=r+4|0;g=f[j>>2]|0;if((g|0)==(f[r+8>>2]|0)){Ri(r,e);s=f[o>>2]|0}else{f[g>>2]=f[e>>2];f[j>>2]=g+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(p<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1;t=f[l>>2]|0}else t=m;m=t+(q>>>5<<2)|0;t=1<<(q&31);r=f[m>>2]|0;if(!(r&t)){f[m>>2]=r|t;t=f[b>>2]|0;do if((t|0)!=-1)if(!((t>>>0)%3|0)){v=t+2|0;break}else{v=t+-1|0;break}else v=-1;while(0);f[e>>2]=v;t=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((v>>>0)/3|0)*12|0)+(((v>>>0)%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(f[y+8>>2]|0))Ri(y,d);else{f[z>>2]=A;f[B>>2]=z+4}z=f[t>>2]|0;B=z+4|0;A=f[B>>2]|0;if((A|0)==(f[z+8>>2]|0)){Ri(z,e);D=f[t>>2]|0}else{f[A>>2]=f[e>>2];f[B>>2]=A+4;D=z}z=D+24|0;f[(f[D+12>>2]|0)+(x<<2)>>2]=f[z>>2];f[z>>2]=(f[z>>2]|0)+1;if(C){E=f[b>>2]|0;F=60;break}z=f[a>>2]|0;A=f[b>>2]|0;do if((A|0)==-1)G=-1;else{B=A+1|0;y=((B>>>0)%3|0|0)==0?A+-2|0:B;if((y|0)==-1){G=-1;break}G=f[(f[z+12>>2]|0)+(y<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0}else{E=v;F=60}while(0);if((F|0)==60){F=0;v=f[a>>2]|0;if((E|0)==-1){F=61;break}j=E+1|0;o=((j>>>0)%3|0|0)==0?E+-2|0:j;if((o|0)==-1)I=-1;else I=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;f[d>>2]=I;o=(((E>>>0)%3|0|0)==0?2:-1)+E|0;if((o|0)==-1)J=-1;else J=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;o=(I|0)==-1;v=(I>>>0)/3|0;j=o?-1:v;g=(J|0)==-1;z=(J>>>0)/3|0;A=g?-1:z;do if(!o){y=f[i>>2]|0;if(f[y+(j>>>5<<2)>>2]&1<<(j&31)|0){F=68;break}if(g){K=I;L=v;break}if(!(f[y+(A>>>5<<2)>>2]&1<<(A&31))){F=73;break a}else{K=I;L=v}}else F=68;while(0);if((F|0)==68){F=0;if(g){F=70;break}if(!(f[(f[i>>2]|0)+(A>>>5<<2)>>2]&1<<(A&31))){K=J;L=z}else{F=70;break}}f[b>>2]=K;H=L}s=H;p=f[i>>2]|0}do if((F|0)==61){F=0;f[d>>2]=-1;F=70}else if((F|0)==73){F=0;p=f[k>>2]|0;f[p+-4>>2]=J;if((p|0)==(f[n>>2]|0)){Ri(h,d);M=f[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0>G>>>0)J=G;else J=(G>>>0)%(e>>>0)|0;else J=F&G;K=f[i>>2]|0;L=f[K+(J<<2)>>2]|0;b:do if(L|0?(M=f[L>>2]|0,M|0):0){c:do if(H){N=M;while(1){O=f[N+4>>2]|0;P=(O|0)==(G|0);if(!(P|(O&F|0)==(J|0)))break b;if(P?(d[N+8>>1]|0)==r<<16>>16:0){Q=N;break c}N=f[N>>2]|0;if(!N)break b}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(G|0)){if((d[N+8>>1]|0)==r<<16>>16){Q=N;break c}}else{if(P>>>0>>0)R=P;else R=(P>>>0)%(e>>>0)|0;if((R|0)!=(J|0))break b}N=f[N>>2]|0;if(!N)break b}}while(0);f[E+(A<<2)>>2]=f[Q+12>>2];S=z;T=B;U=D;V=C;X=E;break a}while(0);if(!H)if(e>>>0>G>>>0)Y=G;else Y=(G>>>0)%(e>>>0)|0;else Y=F&G;L=f[K+(Y<<2)>>2]|0;if(!L){Z=Y;_=e;aa=0;ba=40}else{if(H){M=L;while(1){M=f[M>>2]|0;if(!M){Z=Y;_=e;aa=0;ba=40;break a}N=f[M+4>>2]|0;if(!((N|0)==(G|0)|(N&F|0)==(Y|0))){Z=Y;_=e;aa=0;ba=40;break a}if((d[M+8>>1]|0)==r<<16>>16){ba=55;break a}}}else ca=L;while(1){ca=f[ca>>2]|0;if(!ca){Z=Y;_=e;aa=0;ba=40;break a}M=f[ca+4>>2]|0;if((M|0)!=(G|0)){if(M>>>0>>0)da=M;else da=(M>>>0)%(e>>>0)|0;if((da|0)!=(Y|0)){Z=Y;_=e;aa=0;ba=40;break a}}if((d[ca+8>>1]|0)==r<<16>>16){ba=55;break}}}}else{Z=0;_=0;aa=1;ba=40}while(0);if((ba|0)==40){ba=0;L=ln(16)|0;d[L+8>>1]=r;f[L+12>>2]=B;f[L+4>>2]=G;f[L>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(_>>>0);ga=$(n[l>>2]);do if(aa|$(ga*fa)>>0<3|(_+-1&_|0)!=0)&1;F=~~$(W($(ea/ga)))>>>0;Vh(i,M>>>0>>0?F:M);M=f[o>>2]|0;F=M+-1|0;if(!(F&M)){ha=M;ia=F&G;break}if(M>>>0>G>>>0){ha=M;ia=G}else{ha=M;ia=(G>>>0)%(M>>>0)|0}}else{ha=_;ia=Z}while(0);G=(f[i>>2]|0)+(ia<<2)|0;r=f[G>>2]|0;if(!r){f[L>>2]=f[v>>2];f[v>>2]=L;f[G>>2]=v;G=f[L>>2]|0;if(G|0){M=f[G+4>>2]|0;G=ha+-1|0;if(G&ha)if(M>>>0>>0)ja=M;else ja=(M>>>0)%(ha>>>0)|0;else ja=M&G;ka=(f[i>>2]|0)+(ja<<2)|0;ba=53}}else{f[L>>2]=f[r>>2];ka=r;ba=53}if((ba|0)==53){ba=0;f[ka>>2]=L}f[t>>2]=(f[t>>2]|0)+1;ba=55}if((ba|0)==55){ba=0;r=w;G=f[r>>2]|0;M=un(G|0,f[r+4>>2]|0,B|0,0)|0;kh((f[f[x>>2]>>2]|0)+M|0,j|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=B;S=G;T=B+1|0;U=G;V=G;X=G}G=A+1|0;la=f[m>>2]|0;if(G>>>0>=la>>>0)break;e=f[o>>2]|0;z=S;A=G;B=T;C=V;D=U;E=X}if((T|0)==(la|0))ma=V;else{V=a+84|0;if(!(b[V>>0]|0)){X=f[a+72>>2]|0;E=f[a+68>>2]|0;D=E;if((X|0)==(E|0))na=S;else{C=X-E>>2;E=0;do{X=D+(E<<2)|0;f[X>>2]=f[U+(f[X>>2]<<2)>>2];E=E+1|0}while(E>>>0>>0);na=S}}else{b[V>>0]=0;V=a+68|0;S=a+72|0;C=f[S>>2]|0;E=f[V>>2]|0;U=C-E>>2;D=E;E=C;if(la>>>0<=U>>>0)if(la>>>0>>0?(C=D+(la<<2)|0,(C|0)!=(E|0)):0){f[S>>2]=E+(~((E+-4-C|0)>>>2)<<2);oa=la}else oa=la;else{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;l=o;while(1){d=X(h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);l=l+-4|0;if(l>>>0<=3)break;else q=q+4|0}q=o+-4|0;l=q&-4;s=q-l|0;t=c+(l+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(l=f[r>>2]|0,(l|0)!=0):0){r=(o|0)==0;if(s){if(r){s=l;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=l;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=l;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=l;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=$(y>>>0);L=$(n[a+16>>2]);do if(w|$(L*K)>>0<3|(y+-1&y|0)!=0)&1;H=~~$(W($(J/L)))>>>0;ei(a,A>>>0>>0?H:A);A=f[t>>2]|0;H=A+-1|0;if(!(H&A)){M=A;N=H&z;break}if(z>>>0>>0){M=A;N=z}else{M=A;N=(z>>>0)%(A>>>0)|0}}else{M=y;N=B}while(0);B=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!B){y=a+8|0;f[f[g>>2]>>2]=f[y>>2];f[y>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>2]=y;y=f[g>>2]|0;N=f[y>>2]|0;if(!N)O=g;else{z=f[N+4>>2]|0;N=M+-1|0;if(N&M)if(z>>>0>>0)P=z;else P=(z>>>0)%(M>>>0)|0;else P=z&N;f[(f[a>>2]|0)+(P<<2)>>2]=y;O=g}}else{f[f[g>>2]>>2]=f[B>>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>>0>>0)G=p;else G=(p>>>0)%(d>>>0)|0;else G=D&p;H=f[g>>2]|0;J=f[H+(G<<2)>>2]|0;b:do if(J|0?(K=f[J>>2]|0,K|0):0){c:do if(F){L=K;while(1){M=f[L+4>>2]|0;N=(M|0)==(p|0);if(!(N|(M&D|0)==(G|0)))break b;if(N?(b[L+8>>0]|0)==E<<24>>24:0){O=L;break c}L=f[L>>2]|0;if(!L)break b}}else{L=K;while(1){N=f[L+4>>2]|0;if((N|0)==(p|0)){if((b[L+8>>0]|0)==E<<24>>24){O=L;break c}}else{if(N>>>0>>0)P=N;else P=(N>>>0)%(d>>>0)|0;if((P|0)!=(G|0))break b}L=f[L>>2]|0;if(!L)break b}}while(0);f[C+(y<<2)>>2]=f[O+12>>2];Q=x;R=z;S=B;T=A;U=C;break a}while(0);if(!F)if(p>>>0>>0)V=p;else V=(p>>>0)%(d>>>0)|0;else V=D&p;J=f[H+(V<<2)>>2]|0;if(!J){X=V;Y=d;Z=0;_=40}else{if(F){K=J;while(1){K=f[K>>2]|0;if(!K){X=V;Y=d;Z=0;_=40;break a}L=f[K+4>>2]|0;if(!((L|0)==(p|0)|(L&D|0)==(V|0))){X=V;Y=d;Z=0;_=40;break a}if((b[K+8>>0]|0)==E<<24>>24){_=55;break a}}}else aa=J;while(1){aa=f[aa>>2]|0;if(!aa){X=V;Y=d;Z=0;_=40;break a}K=f[aa+4>>2]|0;if((K|0)!=(p|0)){if(K>>>0>>0)ba=K;else ba=(K>>>0)%(d>>>0)|0;if((ba|0)!=(V|0)){X=V;Y=d;Z=0;_=40;break a}}if((b[aa+8>>0]|0)==E<<24>>24){_=55;break}}}}else{X=0;Y=0;Z=1;_=40}while(0);if((_|0)==40){_=0;J=ln(16)|0;b[J+8>>0]=E;f[J+12>>2]=z;f[J+4>>2]=p;f[J>>2]=0;ca=$(((f[r>>2]|0)+1|0)>>>0);da=$(Y>>>0);ea=$(n[j>>2]);do if(Z|$(ea*da)>>0<3|(Y+-1&Y|0)!=0)&1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]|0,x+z|0,0)|0;q=Vn(G|0,I|0,E|0,F|0)|0;F=(f[f[c>>2]>>2]|0)+q|0;q=h[F>>0]|h[F+1>>0]<<8|h[F+2>>0]<<16|h[F+3>>0]<<24;f[i>>2]=q;F=q^318;a:do if(d){E=d+-1|0;G=(E&d|0)==0;if(!G)if(F>>>0>>0)H=F;else H=(F>>>0)%(d>>>0)|0;else H=E&F;J=f[g>>2]|0;K=f[J+(H<<2)>>2]|0;b:do if(K|0?(L=f[K>>2]|0,L|0):0){c:do if(G){M=L;while(1){N=f[M+4>>2]|0;O=(N|0)==(F|0);if(!(O|(N&E|0)==(H|0)))break b;if(O?(f[M+8>>2]|0)==(q|0):0){P=M;break c}M=f[M>>2]|0;if(!M)break b}}else{M=L;while(1){O=f[M+4>>2]|0;if((O|0)==(F|0)){if((f[M+8>>2]|0)==(q|0)){P=M;break c}}else{if(O>>>0>>0)Q=O;else Q=(O>>>0)%(d>>>0)|0;if((Q|0)!=(H|0))break b}M=f[M>>2]|0;if(!M)break b}}while(0);f[D+(z<<2)>>2]=f[P+12>>2];R=y;S=A;T=C;U=B;V=D;break a}while(0);if(!G)if(F>>>0>>0)X=F;else X=(F>>>0)%(d>>>0)|0;else X=E&F;K=f[J+(X<<2)>>2]|0;if(!K){Y=X;Z=d;_=0;aa=40}else{if(G){L=K;while(1){L=f[L>>2]|0;if(!L){Y=X;Z=d;_=0;aa=40;break a}M=f[L+4>>2]|0;if(!((M|0)==(F|0)|(M&E|0)==(X|0))){Y=X;Z=d;_=0;aa=40;break a}if((f[L+8>>2]|0)==(q|0)){aa=55;break a}}}else ba=K;while(1){ba=f[ba>>2]|0;if(!ba){Y=X;Z=d;_=0;aa=40;break a}L=f[ba+4>>2]|0;if((L|0)!=(F|0)){if(L>>>0>>0)ca=L;else ca=(L>>>0)%(d>>>0)|0;if((ca|0)!=(X|0)){Y=X;Z=d;_=0;aa=40;break a}}if((f[ba+8>>2]|0)==(q|0)){aa=55;break}}}}else{Y=0;Z=0;_=1;aa=40}while(0);if((aa|0)==40){aa=0;K=ln(16)|0;f[K+8>>2]=q;f[K+12>>2]=A;f[K+4>>2]=F;f[K>>2]=0;da=$(((f[s>>2]|0)+1|0)>>>0);ea=$(Z>>>0);fa=$(n[k>>2]);do if(_|$(fa*ea)>>0<3|(Z+-1&Z|0)!=0)&1;E=~~$(W($(da/fa)))>>>0;Hi(g,L>>>0>>0?E:L);L=f[m>>2]|0;E=L+-1|0;if(!(E&L)){ga=L;ha=E&F;break}if(F>>>0>>0){ga=L;ha=F}else{ga=L;ha=(F>>>0)%(L>>>0)|0}}else{ga=Z;ha=Y}while(0);F=(f[g>>2]|0)+(ha<<2)|0;q=f[F>>2]|0;if(!q){f[K>>2]=f[t>>2];f[t>>2]=K;f[F>>2]=t;F=f[K>>2]|0;if(F|0){L=f[F+4>>2]|0;F=ga+-1|0;if(F&ga)if(L>>>0>>0)ia=L;else ia=(L>>>0)%(ga>>>0)|0;else ia=L&F;ja=(f[g>>2]|0)+(ia<<2)|0;aa=53}}else{f[K>>2]=f[q>>2];ja=q;aa=53}if((aa|0)==53){aa=0;f[ja>>2]=K}f[s>>2]=(f[s>>2]|0)+1;aa=55}if((aa|0)==55){aa=0;q=v;F=f[q>>2]|0;L=un(F|0,f[q+4>>2]|0,A|0,0)|0;kh((f[f[w>>2]>>2]|0)+L|0,i|0,F|0)|0;F=f[j>>2]|0;f[F+(z<<2)>>2]=A;R=F;S=A+1|0;T=F;U=F;V=F}F=z+1|0;ka=f[l>>2]|0;if(F>>>0>=ka>>>0)break;d=f[m>>2]|0;y=R;z=F;A=S;B=U;C=T;D=V}if((S|0)==(ka|0))la=U;else{U=a+84|0;if(!(b[U>>0]|0)){V=f[a+72>>2]|0;D=f[a+68>>2]|0;C=D;if((V|0)==(D|0))ma=R;else{B=V-D>>2;D=0;do{V=C+(D<<2)|0;f[V>>2]=f[T+(f[V>>2]<<2)>>2];D=D+1|0}while(D>>>0>>0);ma=R}}else{b[U>>0]=0;U=a+68|0;R=a+72|0;B=f[R>>2]|0;D=f[U>>2]|0;T=B-D>>2;C=D;D=B;if(ka>>>0<=T>>>0)if(ka>>>0>>0?(B=C+(ka<<2)|0,(B|0)!=(D|0)):0){f[R>>2]=D+(~((D+-4-B|0)>>>2)<<2);na=ka}else na=ka;else{Ch(U,ka-T|0,1220);na=f[l>>2]|0}T=f[j>>2]|0;if(!na)ma=T;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[T+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);ma=T}}f[l>>2]=S;la=ma}if(!la)oa=S;else{ma=f[o>>2]|0;if((ma|0)!=(la|0))f[o>>2]=ma+(~((ma+-4-la|0)>>>2)<<2);Oq(la);oa=S}}else oa=0;S=f[g+8>>2]|0;if(S|0){la=S;do{S=la;la=f[la>>2]|0;Oq(S)}while((la|0)!=0)}la=f[g>>2]|0;f[g>>2]=0;if(!la){u=e;return oa|0}Oq(la);u=e;return oa|0}function ic(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0;e=u;u=u+96|0;g=e+92|0;h=e+88|0;i=e+72|0;j=e+48|0;k=e+24|0;l=e;m=a+16|0;n=f[m>>2]|0;o=f[c>>2]|0;f[i>>2]=n;f[i+4>>2]=o;c=i+8|0;f[c>>2]=o;b[i+12>>0]=1;p=f[(f[n+28>>2]|0)+(o<<2)>>2]|0;n=a+20|0;q=f[n>>2]|0;r=f[q>>2]|0;if((f[q+4>>2]|0)-r>>2>>>0<=p>>>0)aq(q);q=a+8|0;s=f[(f[q>>2]|0)+(f[r+(p<<2)>>2]<<2)>>2]|0;p=a+4|0;r=f[p>>2]|0;if(!(b[r+84>>0]|0))t=f[(f[r+68>>2]|0)+(s<<2)>>2]|0;else t=s;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=t;t=b[r+24>>0]|0;f[g>>2]=f[h>>2];vb(r,g,t,j)|0;t=a+28|0;a=(f[t>>2]|0)==0;a:do if((o|0)!=-1){r=k+8|0;s=j+8|0;v=k+16|0;w=j+16|0;x=l+8|0;y=l+16|0;z=o;A=o;B=0;C=0;D=0;E=0;F=0;G=0;H=a;J=o;while(1){do if(H){K=J+1|0;if((J|0)!=-1){L=((K>>>0)%3|0|0)==0?J+-2|0:K;if((z|0)!=-1)if(!((z>>>0)%3|0)){M=z;N=z+2|0;O=L;P=z;break}else{M=z;N=z+-1|0;O=L;P=z;break}else{M=-1;N=-1;O=L;P=-1}}else{M=z;N=-1;O=-1;P=-1}}else{L=A+1|0;K=((L>>>0)%3|0|0)==0?A+-2|0:L;if(!((A>>>0)%3|0)){M=z;N=A+2|0;O=K;P=J;break}else{M=z;N=A+-1|0;O=K;P=J;break}}while(0);K=f[(f[(f[m>>2]|0)+28>>2]|0)+(O<<2)>>2]|0;Q=f[n>>2]|0;L=f[Q>>2]|0;if((f[Q+4>>2]|0)-L>>2>>>0<=K>>>0){R=17;break}S=f[(f[q>>2]|0)+(f[L+(K<<2)>>2]<<2)>>2]|0;K=f[p>>2]|0;if(!(b[K+84>>0]|0))T=f[(f[K+68>>2]|0)+(S<<2)>>2]|0;else T=S;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[h>>2]=T;S=b[K+24>>0]|0;f[g>>2]=f[h>>2];vb(K,g,S,k)|0;S=f[(f[(f[m>>2]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=((((A^318)&65535)+239^E&65535)+239^D&65535)+239^H&65535;H=f[s>>2]|0;E=(H|0)==0;a:do if(!E){L=H+-1|0;M=(L&H|0)==0;if(!M)if(K>>>0>>0)N=K;else N=(K>>>0)%(H>>>0)|0;else N=K&L;O=f[(f[i>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(K|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((d[O>>1]|0)==A<<16>>16?(d[O+2>>1]|0)==F<<16>>16:0)?(d[M+12>>1]|0)==G<<16>>16:0)?(d[O+6>>1]|0)==J<<16>>16:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(K|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(H>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((d[M>>1]|0)==A<<16>>16?(d[M+2>>1]|0)==F<<16>>16:0)?(d[S+12>>1]|0)==G<<16>>16:0)?(d[M+6>>1]|0)==J<<16>>16:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;J=ln(20)|0;G=J+8|0;F=G;d[F>>1]=B;d[F+2>>1]=B>>>16;F=G+4|0;d[F>>1]=D;d[F+2>>1]=D>>>16;f[J+16>>2]=z;f[J+4>>2]=K;f[J>>2]=0;U=$(((f[p>>2]|0)+1|0)>>>0);V=$(H>>>0);X=$(n[m>>2]);do if(E|$(X*V)>>0<3|(H+-1&H|0)!=0)&1;G=~~$(W($(U/X)))>>>0;Sh(i,F>>>0>>0?G:F);F=f[s>>2]|0;G=F+-1|0;if(!(G&F)){Y=F;Z=G&K;break}if(K>>>0>>0){Y=F;Z=K}else{Y=F;Z=(K>>>0)%(F>>>0)|0}}else{Y=H;Z=Q}while(0);H=(f[i>>2]|0)+(Z<<2)|0;K=f[H>>2]|0;if(!K){f[J>>2]=f[v>>2];f[v>>2]=J;f[H>>2]=v;H=f[J>>2]|0;if(H|0){E=f[H+4>>2]|0;H=Y+-1|0;if(H&Y)if(E>>>0>>0)_=E;else _=(E>>>0)%(Y>>>0)|0;else _=E&H;aa=(f[i>>2]|0)+(_<<2)|0;R=44}}else{f[J>>2]=f[K>>2];aa=K;R=44}if((R|0)==44){R=0;f[aa>>2]=J}f[p>>2]=(f[p>>2]|0)+1}K=w;H=f[K>>2]|0;E=un(H|0,f[K+4>>2]|0,z|0,0)|0;kh((f[f[x>>2]>>2]|0)+E|0,j|0,H|0)|0;H=f[l>>2]|0;f[H+(y<<2)>>2]=z;ba=z+1|0;ca=H}else{H=f[l>>2]|0;f[H+(y<<2)>>2]=f[C+16>>2];ba=z;ca=H}y=y+1|0;da=f[o>>2]|0;if(y>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){y=f[a+72>>2]|0;j=f[a+68>>2]|0;x=j;if((y|0)==(j|0))fa=ca;else{w=y-j>>2;j=0;do{y=x+(j<<2)|0;f[y>>2]=f[ca+(f[y>>2]<<2)>>2];j=j+1|0}while(j>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;w=f[ca>>2]|0;j=f[z>>2]|0;x=w-j>>2;y=j;j=w;if(da>>>0<=x>>>0)if(da>>>0>>0?(w=y+(da<<2)|0,(w|0)!=(j|0)):0){f[ca>>2]=j+(~((j+-4-w|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-x|0,1220);ga=f[o>>2]|0}x=f[l>>2]|0;if(!ga)fa=x;else{l=f[a+68>>2]|0;a=0;do{f[l+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=x}}f[o>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[q>>2]|0;if((fa|0)!=(ea|0))f[q>>2]=fa+(~((fa+-4-ea|0)>>>2)<<2);Oq(ea);ha=ba}}else ha=0;ba=f[i+8>>2]|0;if(ba|0){ea=ba;do{ba=ea;ea=f[ea>>2]|0;Oq(ba)}while((ea|0)!=0)}ea=f[i>>2]|0;f[i>>2]=0;if(!ea){u=g;return ha|0}Oq(ea);u=g;return ha|0}function kc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+152|0;v=a+84|0;w=a+272|0;x=a+276|0;y=a+268|0;z=a+168|0;A=a+140|0;B=a+120|0;C=o;do{o=f[C+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(D=(o>>>0)/3|0,E=f[n>>2]|0,(f[E+(D>>>5<<2)>>2]&1<<(D&31)|0)==0):0){if(l){D=0;F=E;b:while(1){E=D+1|0;f[i>>2]=(f[i>>2]|0)+1;G=f[b>>2]|0;H=(G|0)==-1?-1:(G>>>0)/3|0;G=F+(H>>>5<<2)|0;f[G>>2]=1<<(H&31)|f[G>>2];G=f[q>>2]|0;if((G|0)==(f[r>>2]|0))Ri(s,b);else{f[G>>2]=f[b>>2];f[q>>2]=G+4}G=f[b>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[f[p>>2]>>2]|0)+(G<<2)>>2]|0;J=(f[(f[t>>2]|0)+(I<<2)>>2]|0)!=-1;K=(f[v>>2]|0)+(I>>>5<<2)|0;L=1<<(I&31);M=f[K>>2]|0;do if(!(M&L)){f[K>>2]=M|L;if(J){N=f[b>>2]|0;O=30;break}f[d>>2]=0;P=f[w>>2]|0;if((P|0)==(f[x>>2]|0))Ri(y,d);else{f[P>>2]=0;f[w>>2]=P+4}P=f[b>>2]|0;Q=P+1|0;if((P|0)!=-1?(R=((Q>>>0)%3|0|0)==0?P+-2|0:Q,(R|0)!=-1):0)S=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;else S=-1;f[b>>2]=S}else{N=G;O=30}while(0);if((O|0)==30){O=0;G=N+1|0;if((N|0)==-1){O=35;break}L=((G>>>0)%3|0|0)==0?N+-2|0:G;if((L|0)==-1)T=-1;else T=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;f[e>>2]=T;L=(((N>>>0)%3|0|0)==0?2:-1)+N|0;if((L|0)==-1)U=-1;else U=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;L=(T|0)==-1;M=L?-1:(T>>>0)/3|0;V=(U|0)==-1;W=V?-1:(U>>>0)/3|0;K=((G>>>0)%3|0|0)==0?N+-2|0:G;if(((K|0)!=-1?(G=f[(f[p>>2]|0)+12>>2]|0,R=f[G+(K<<2)>>2]|0,(R|0)!=-1):0)?(K=(R>>>0)/3|0,R=f[n>>2]|0,(f[R+(K>>>5<<2)>>2]&1<<(K&31)|0)==0):0){K=(((N>>>0)%3|0|0)==0?2:-1)+N|0;do if((K|0)!=-1){Q=f[G+(K<<2)>>2]|0;if((Q|0)==-1)break;P=(Q>>>0)/3|0;if(!(f[R+(P>>>5<<2)>>2]&1<<(P&31))){O=63;break b}}while(0);if(!V)xf(a,f[i>>2]|0,H,0,W);f[d>>2]=3;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=3;f[w>>2]=R+4}X=f[e>>2]|0}else{if(!L){xf(a,f[i>>2]|0,H,1,M);R=f[b>>2]|0;if((R|0)==-1){O=44;break}else Y=R}else Y=N;R=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((R|0)==-1){O=44;break}K=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;if((K|0)==-1){O=44;break}R=(K>>>0)/3|0;if(f[(f[n>>2]|0)+(R>>>5<<2)>>2]&1<<(R&31)|0){O=44;break}f[d>>2]=5;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=5;f[w>>2]=R+4}X=U}f[b>>2]=X}if((E|0)>=(k|0))break a;D=E;F=f[n>>2]|0}do if((O|0)==35){O=0;f[e>>2]=-1;O=46}else if((O|0)==44){O=0;if(V)O=46;else{xf(a,f[i>>2]|0,H,0,W);O=46}}else if((O|0)==63){O=0;f[d>>2]=1;F=f[w>>2]|0;if((F|0)==(f[x>>2]|0))Ri(y,d);else{f[F>>2]=1;f[w>>2]=F+4}f[z>>2]=(f[z>>2]|0)+1;if(J?(F=f[(f[t>>2]|0)+(I<<2)>>2]|0,(1<<(F&31)&f[(f[A>>2]|0)+(F>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}F=f[i>>2]|0;f[d>>2]=H;D=je(B,d)|0;f[D>>2]=F;F=f[j>>2]|0;f[F+-4>>2]=U;if((F|0)==(f[m>>2]|0)){Ri(h,e);break}else{f[F>>2]=f[e>>2];f[j>>2]=F+4;break}}while(0);if((O|0)==46){O=0;f[d>>2]=7;F=f[w>>2]|0;if((F|0)==(f[x>>2]|0))Ri(y,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G;G=f[r>>2]|0;K=(G|0)==0;a:do if(!K){L=G+-1|0;M=(L&G|0)==0;if(!M)if(E>>>0>>0)N=E;else N=(E>>>0)%(G>>>0)|0;else N=E&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(E|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((b[O>>0]|0)==A<<24>>24?(b[O+1>>0]|0)==D<<24>>24:0)?(b[O+2>>0]|0)==F<<24>>24:0)?(b[O+3>>0]|0)==H<<24>>24:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(E|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(G>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((b[M>>0]|0)==A<<24>>24?(b[M+1>>0]|0)==D<<24>>24:0)?(b[M+2>>0]|0)==F<<24>>24:0)?(b[M+3>>0]|0)==H<<24>>24:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;H=ln(16)|0;F=H+8|0;D=B&-16776961|C<<16|J<<8;b[F>>0]=D;b[F+1>>0]=D>>8;b[F+2>>0]=D>>16;b[F+3>>0]=D>>24;f[H+12>>2]=y;f[H+4>>2]=E;f[H>>2]=0;U=$(((f[o>>2]|0)+1|0)>>>0);V=$(G>>>0);X=$(n[l>>2]);do if(K|$(X*V)>>0<3|(G+-1&G|0)!=0)&1;F=~~$(W($(U/X)))>>>0;Zh(g,D>>>0>>0?F:D);D=f[r>>2]|0;F=D+-1|0;if(!(F&D)){Y=D;Z=F&E;break}if(E>>>0>>0){Y=D;Z=E}else{Y=D;Z=(E>>>0)%(D>>>0)|0}}else{Y=G;Z=Q}while(0);G=(f[g>>2]|0)+(Z<<2)|0;E=f[G>>2]|0;if(!E){f[H>>2]=f[t>>2];f[t>>2]=H;f[G>>2]=t;G=f[H>>2]|0;if(G|0){K=f[G+4>>2]|0;G=Y+-1|0;if(G&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&G;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[H>>2]=f[E>>2];aa=E;R=44}if((R|0)==44){R=0;f[aa>>2]=H}f[o>>2]=(f[o>>2]|0)+1}E=v;G=f[E>>2]|0;K=un(G|0,f[E+4>>2]|0,y|0,0)|0;kh((f[f[w>>2]>>2]|0)+K|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(x<<2)>>2]=y;ba=y+1|0;ca=G}else{G=f[k>>2]|0;f[G+(x<<2)>>2]=f[z+12>>2];ba=y;ca=G}x=x+1|0;da=f[m>>2]|0;if(x>>>0>=da>>>0)break;else y=ba}if((ba|0)==(da|0))ea=ca;else{y=a+84|0;if(!(b[y>>0]|0)){x=f[a+72>>2]|0;i=f[a+68>>2]|0;w=i;if((x|0)==(i|0))fa=ca;else{v=x-i>>2;i=0;do{x=w+(i<<2)|0;f[x>>2]=f[ca+(f[x>>2]<<2)>>2];i=i+1|0}while(i>>>0>>0);fa=ca}}else{b[y>>0]=0;y=a+68|0;ca=a+72|0;v=f[ca>>2]|0;i=f[y>>2]|0;w=v-i>>2;x=i;i=v;if(da>>>0<=w>>>0)if(da>>>0>>0?(v=x+(da<<2)|0,(v|0)!=(i|0)):0){f[ca>>2]=i+(~((i+-4-v|0)>>>2)<<2);ga=da}else ga=da;else{Ch(y,da-w|0,1220);ga=f[m>>2]|0}w=f[k>>2]|0;if(!ga)fa=w;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[w+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=w}}f[m>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[p>>2]|0;if((fa|0)!=(ea|0))f[p>>2]=fa+(~((fa+-4-ea|0)>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m>>2]|0;G=f[s>>2]|0;H=(((B^318)+239^E)+239^F)+239^G;J=f[t>>2]|0;K=(J|0)==0;a:do if(!K){L=J+-1|0;M=(L&J|0)==0;if(!M)if(H>>>0>>0)N=H;else N=(H>>>0)%(J>>>0)|0;else N=H&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(H|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}if((((f[M+8>>2]|0)==(B|0)?(f[M+12>>2]|0)==(E|0):0)?(f[M+16>>2]|0)==(F|0):0)?(f[M+20>>2]|0)==(G|0):0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(H|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(J>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}if((((f[S+8>>2]|0)==(B|0)?(f[S+12>>2]|0)==(E|0):0)?(f[S+16>>2]|0)==(F|0):0)?(f[S+20>>2]|0)==(G|0):0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;D=ln(28)|0;f[D+8>>2]=B;f[D+12>>2]=E;f[D+16>>2]=F;f[D+20>>2]=G;f[D+24>>2]=z;f[D+4>>2]=H;f[D>>2]=0;U=$(((f[v>>2]|0)+1|0)>>>0);V=$(J>>>0);X=$(n[k>>2]);do if(K|$(X*V)>>0<3|(J+-1&J|0)!=0)&1;M=~~$(W($(U/X)))>>>0;Wh(g,P>>>0>>0?M:P);P=f[t>>2]|0;M=P+-1|0;if(!(M&P)){Y=P;Z=M&H;break}if(H>>>0

    >>0){Y=P;Z=H}else{Y=P;Z=(H>>>0)%(P>>>0)|0}}else{Y=J;Z=Q}while(0);J=(f[g>>2]|0)+(Z<<2)|0;H=f[J>>2]|0;if(!H){f[D>>2]=f[w>>2];f[w>>2]=D;f[J>>2]=w;J=f[D>>2]|0;if(J|0){K=f[J+4>>2]|0;J=Y+-1|0;if(J&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&J;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[D>>2]=f[H>>2];aa=H;R=44}if((R|0)==44){R=0;f[aa>>2]=D}f[v>>2]=(f[v>>2]|0)+1}H=x;J=f[H>>2]|0;K=un(J|0,f[H+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+K|0,h|0,J|0)|0;J=f[j>>2]|0;f[J+(A<<2)>>2]=z;ba=z+1|0;ca=J}else{J=f[j>>2]|0;f[J+(A<<2)>>2]=f[C+24>>2];ba=z;ca=J}A=A+1|0;da=f[l>>2]|0;if(A>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;h=f[a+68>>2]|0;y=h;if((A|0)==(h|0))fa=ca;else{x=A-h>>2;h=0;do{A=y+(h<<2)|0;f[A>>2]=f[ca+(f[A>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;x=f[ca>>2]|0;h=f[z>>2]|0;y=x-h>>2;A=h;h=x;if(da>>>0<=y>>>0)if(da>>>0>>0?(x=A+(da<<2)|0,(x|0)!=(h|0)):0){f[ca>>2]=h+(~((h+-4-x|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-y|0,1220);ga=f[l>>2]|0}y=f[j>>2]|0;if(!ga)fa=y;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=y}}f[l>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[o>>2]|0;if((fa|0)!=(ea|0))f[o>>2]=fa+(~((fa+-4-ea|0)>>>2)<<2);Oq(ea);ha=ba}}else ha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C=d[r>>1]|0;E=d[o>>1]|0;F=(((B^318)&65535)+239^C&65535)+239^E&65535;G=f[t>>2]|0;H=(G|0)==0;a:do if(!H){J=G+-1|0;K=(J&G|0)==0;if(!K)if(F>>>0>>0)L=F;else L=(F>>>0)%(G>>>0)|0;else L=F&J;M=f[(f[h>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}M=K+8|0;if(((d[M>>1]|0)==B<<16>>16?(d[M+2>>1]|0)==C<<16>>16:0)?(d[K+12>>1]|0)==E<<16>>16:0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}K=Q+8|0;if(((d[K>>1]|0)==B<<16>>16?(d[K+2>>1]|0)==C<<16>>16:0)?(d[Q+12>>1]|0)==E<<16>>16:0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;N=ln(20)|0;d[N+8>>1]=B;d[N+10>>1]=C;d[N+12>>1]=E;f[N+16>>2]=z;f[N+4>>2]=F;f[N>>2]=0;S=$(((f[v>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[l>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;J=~~$(W($(S/U)))>>>0;Th(h,K>>>0>>0?J:K);K=f[t>>2]|0;J=K+-1|0;if(!(J&K)){V=K;X=J&F;break}if(F>>>0>>0){V=K;X=F}else{V=K;X=(F>>>0)%(K>>>0)|0}}else{V=G;X=O}while(0);G=(f[h>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[N>>2]=f[w>>2];f[w>>2]=N;f[G>>2]=w;G=f[N>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[h>>2]|0)+(Y<<2)|0;P=42}}else{f[N>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=N}f[v>>2]=(f[v>>2]|0)+1}F=x;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+H|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=z;_=z+1|0;aa=G}else{G=f[k>>2]|0;f[G+(A<<2)>>2]=f[D+16>>2];_=z;aa=G}A=A+1|0;ba=f[m>>2]|0;if(A>>>0>=ba>>>0)break;else z=_}if((_|0)==(ba|0))ca=aa;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;i=f[a+68>>2]|0;y=i;if((A|0)==(i|0))da=aa;else{x=A-i>>2;i=0;do{A=y+(i<<2)|0;f[A>>2]=f[aa+(f[A>>2]<<2)>>2];i=i+1|0}while(i>>>0>>0);da=aa}}else{b[z>>0]=0;z=a+68|0;aa=a+72|0;x=f[aa>>2]|0;i=f[z>>2]|0;y=x-i>>2;A=i;i=x;if(ba>>>0<=y>>>0)if(ba>>>0>>0?(x=A+(ba<<2)|0,(x|0)!=(i|0)):0){f[aa>>2]=i+(~((i+-4-x|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(z,ba-y|0,1220);ea=f[m>>2]|0}y=f[k>>2]|0;if(!ea)da=y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=y}}f[m>>2]=_;ca=da}if(!ca)fa=_;else{da=f[p>>2]|0;if((da|0)!=(ca|0))f[p>>2]=da+(~((da+-4-ca|0)>>>2)<<2);Oq(ca);fa=_}}else fa=0;_=f[h+8>>2]|0;if(_|0){ca=_;do{_=ca;ca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I=X(K,e)|0;K=X(J,e)|0;if(q){J=0;do{f[k+(J<<2)>>2]=(f[b+(J+K<<2)>>2]|0)+(f[b+(J+I<<2)>>2]|0)-(f[b+(J+H<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0));if(q){J=0;do{H=j+(J<<2)|0;f[H>>2]=(f[H>>2]|0)+(f[k+(J<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0))}}N=D+1|0}else N=D}else N=D;J=(((E>>>0)%3|0|0)==0?2:-1)+E|0;do if((J|0)!=-1?(H=f[p+(J<<2)>>2]|0,(H|0)!=-1):0)if(!((H>>>0)%3|0)){O=H+2|0;break}else{O=H+-1|0;break}else O=-1;while(0);E=(O|0)==(z|0)?-1:O;if((E|0)==-1)break;else D=N}D=X(B,e)|0;if(N){if(q){E=0;do{z=j+(E<<2)|0;f[z>>2]=(f[z>>2]|0)/(N|0)|0;E=E+1|0}while((E|0)!=(e|0))}E=b+(D<<2)|0;z=c+(D<<2)|0;p=f[g>>2]|0;if((p|0)>0){J=0;H=j;I=p;while(1){if((I|0)>0){p=0;do{K=f[H+(p<<2)>>2]|0;G=f[r>>2]|0;if((K|0)>(G|0)){F=f[s>>2]|0;f[F+(p<<2)>>2]=G;P=F}else{F=f[t>>2]|0;G=f[s>>2]|0;f[G+(p<<2)>>2]=(K|0)<(F|0)?F:K;P=G}p=p+1|0}while((p|0)<(f[g>>2]|0));Q=P}else Q=f[s>>2]|0;p=(f[E+(J<<2)>>2]|0)-(f[Q+(J<<2)>>2]|0)|0;G=z+(J<<2)|0;f[G>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){R=p-(f[v>>2]|0)|0;S=57}}else{R=(f[v>>2]|0)+p|0;S=57}if((S|0)==57){S=0;f[G>>2]=R}J=J+1|0;I=f[g>>2]|0;if((J|0)>=(I|0))break;else H=Q}}}else{T=D;S=30}}else{T=X(B,e)|0;S=30}if((S|0)==30?(S=0,H=b+(T<<2)|0,I=c+(T<<2)|0,J=f[g>>2]|0,(J|0)>0):0){z=0;E=b+((X(A+-2|0,e)|0)<<2)|0;G=J;while(1){if((G|0)>0){J=0;do{p=f[E+(J<<2)>>2]|0;K=f[r>>2]|0;if((p|0)>(K|0)){F=f[s>>2]|0;f[F+(J<<2)>>2]=K;U=F}else{F=f[t>>2]|0;K=f[s>>2]|0;f[K+(J<<2)>>2]=(p|0)<(F|0)?F:p;U=K}J=J+1|0}while((J|0)<(f[g>>2]|0));V=U}else V=f[s>>2]|0;J=(f[H+(z<<2)>>2]|0)-(f[V+(z<<2)>>2]|0)|0;K=I+(z<<2)|0;f[K>>2]=J;if((J|0)>=(f[u>>2]|0)){if((J|0)>(f[w>>2]|0)){W=J-(f[v>>2]|0)|0;S=42}}else{W=(f[v>>2]|0)+J|0;S=42}if((S|0)==42){S=0;f[K>>2]=W}z=z+1|0;G=f[g>>2]|0;if((z|0)>=(G|0))break;else E=V}}if((A|0)<=2)break a;C=f[i>>2]|0;E=B+-1|0;if((f[l>>2]|0)-C>>2>>>0<=E>>>0)break;else{G=B;B=E;A=G}}aq(i)}while(0);if((e|0)>0)sj(j|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(k);Mq(j);return 1}i=a+16|0;A=a+32|0;B=a+12|0;C=a+28|0;l=a+20|0;V=a+24|0;a=0;W=j;U=e;while(1){if((U|0)>0){e=0;do{T=f[W+(e<<2)>>2]|0;Q=f[i>>2]|0;if((T|0)>(Q|0)){R=f[A>>2]|0;f[R+(e<<2)>>2]=Q;Y=R}else{R=f[B>>2]|0;Q=f[A>>2]|0;f[Q+(e<<2)>>2]=(T|0)<(R|0)?R:T;Y=Q}e=e+1|0}while((e|0)<(f[g>>2]|0));Z=Y}else Z=f[A>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[Z+(a<<2)>>2]|0)|0;Q=c+(a<<2)|0;f[Q>>2]=e;if((e|0)>=(f[C>>2]|0)){if((e|0)>(f[V>>2]|0)){_=e-(f[l>>2]|0)|0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(L|0)<(C|0)&(K|0)<(C|0)):0){G=X(J,e)|0;J=X(L,e)|0;L=X(K,e)|0;if(q){K=0;do{f[k+(K<<2)>>2]=(f[b+(K+L<<2)>>2]|0)+(f[b+(K+J<<2)>>2]|0)-(f[b+(K+G<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0));if(q){K=0;do{G=j+(K<<2)|0;f[G>>2]=(f[G>>2]|0)+(f[k+(K<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0))}}M=E+1|0}else M=E;K=(((F>>>0)%3|0|0)==0?2:-1)+F|0;do if(((K|0)!=-1?(f[p+(K>>>5<<2)>>2]&1<<(K&31)|0)==0:0)?(G=f[(f[(f[x>>2]|0)+12>>2]|0)+(K<<2)>>2]|0,(G|0)!=-1):0)if(!((G>>>0)%3|0)){N=G+2|0;break}else{N=G+-1|0;break}else N=-1;while(0);F=(N|0)==(A|0)?-1:N;if((F|0)==-1)break;else E=M}E=X(C,e)|0;if(M){if(q){F=0;do{A=j+(F<<2)|0;f[A>>2]=(f[A>>2]|0)/(M|0)|0;F=F+1|0}while((F|0)!=(e|0))}F=b+(E<<2)|0;A=c+(E<<2)|0;p=f[g>>2]|0;if((p|0)>0){K=0;G=j;J=p;while(1){if((J|0)>0){p=0;do{L=f[G+(p<<2)>>2]|0;H=f[r>>2]|0;if((L|0)>(H|0)){I=f[s>>2]|0;f[I+(p<<2)>>2]=H;O=I}else{I=f[t>>2]|0;H=f[s>>2]|0;f[H+(p<<2)>>2]=(L|0)<(I|0)?I:L;O=H}p=p+1|0}while((p|0)<(f[g>>2]|0));P=O}else P=f[s>>2]|0;p=(f[F+(K<<2)>>2]|0)-(f[P+(K<<2)>>2]|0)|0;H=A+(K<<2)|0;f[H>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){Q=p-(f[v>>2]|0)|0;R=55}}else{Q=(f[v>>2]|0)+p|0;R=55}if((R|0)==55){R=0;f[H>>2]=Q}K=K+1|0;J=f[g>>2]|0;if((K|0)>=(J|0))break;else G=P}}}else{S=E;R=28}}else{S=X(C,e)|0;R=28}if((R|0)==28?(R=0,G=b+(S<<2)|0,J=c+(S<<2)|0,K=f[g>>2]|0,(K|0)>0):0){A=0;F=b+((X(B+-2|0,e)|0)<<2)|0;H=K;while(1){if((H|0)>0){K=0;do{p=f[F+(K<<2)>>2]|0;L=f[r>>2]|0;if((p|0)>(L|0)){I=f[s>>2]|0;f[I+(K<<2)>>2]=L;T=I}else{I=f[t>>2]|0;L=f[s>>2]|0;f[L+(K<<2)>>2]=(p|0)<(I|0)?I:p;T=L}K=K+1|0}while((K|0)<(f[g>>2]|0));U=T}else U=f[s>>2]|0;K=(f[G+(A<<2)>>2]|0)-(f[U+(A<<2)>>2]|0)|0;L=J+(A<<2)|0;f[L>>2]=K;if((K|0)>=(f[u>>2]|0)){if((K|0)>(f[w>>2]|0)){V=K-(f[v>>2]|0)|0;R=40}}else{V=(f[v>>2]|0)+K|0;R=40}if((R|0)==40){R=0;f[L>>2]=V}A=A+1|0;H=f[g>>2]|0;if((A|0)>=(H|0))break;else F=U}}if((B|0)<=2)break a;D=f[i>>2]|0;F=C+-1|0;if((f[l>>2]|0)-D>>2>>>0<=F>>>0)break;else{H=C;C=F;B=H}}aq(i)}while(0);if((e|0)>0)sj(j|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(k);Mq(j);return 1}i=a+16|0;B=a+32|0;C=a+12|0;D=a+28|0;l=a+20|0;U=a+24|0;a=0;V=j;T=e;while(1){if((T|0)>0){e=0;do{S=f[V+(e<<2)>>2]|0;P=f[i>>2]|0;if((S|0)>(P|0)){Q=f[B>>2]|0;f[Q+(e<<2)>>2]=P;W=Q}else{Q=f[C>>2]|0;P=f[B>>2]|0;f[P+(e<<2)>>2]=(S|0)<(Q|0)?Q:S;W=P}e=e+1|0}while((e|0)<(f[g>>2]|0));Y=W}else Y=f[B>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[Y+(a<<2)>>2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-Z|0:Z;aa=0}else{$=Z;aa=Y}}else{$=Z;aa=Z}}else{$=Y;aa=Y}}else{$=N;aa=N}while(0);P=0-S|0;M=0-_|0;f[j>>2]=0-O;f[r>>2]=P;f[t>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(q=(N|0)==(ca|0),!(M&q)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(q&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);N=K<<1;M=b+(N<<2)|0;H=M+4|0;O=f[H>>2]|0;f[h>>2]=f[M>>2];f[x>>2]=O;f[i>>2]=$;f[y>>2]=aa;Od(d,n,h,i);O=f[d>>2]|0;f[k>>2]=O;P=f[z>>2]|0;f[A>>2]=P;q=f[H>>2]|0;f[h>>2]=f[M>>2];f[B>>2]=q;f[i>>2]=da;f[C>>2]=ea;Od(d,n,h,i);q=f[d>>2]|0;f[l>>2]=q;M=f[D>>2]|0;f[E>>2]=M;H=f[v>>2]|0;if((H|0)>=(O|0))if((O|0)<(0-H|0))fa=(f[F>>2]|0)+O|0;else fa=O;else fa=O-(f[F>>2]|0)|0;f[k>>2]=fa;if((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)-L>>2>>>0<=K>>>0){J=M;ma=6;break}}if((ma|0)==5){u=e;return 1}else if((ma|0)==6)aq(J);return 0}function rc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;c=u;u=u+48|0;d=c+24|0;e=c+12|0;g=c;if(!b){h=0;u=c;return h|0}i=a+12|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=a+16|0;o=f[n>>2]|0;p=f[i>>2]|0;q=o-p>>2;r=p;p=o;if(m>>>0<=q>>>0)if(m>>>0>>0?(o=r+(m<<2)|0,(o|0)!=(p|0)):0){f[n>>2]=p+(~((p+-4-o|0)>>>2)<<2);s=l;t=k}else{s=l;t=k}else{Ch(i,m-q|0,6140);s=f[a>>2]|0;t=f[j>>2]|0}f[d>>2]=0;q=d+4|0;f[q>>2]=0;f[d+8>>2]=0;gk(d,t-s>>2);s=f[j>>2]|0;t=f[a>>2]|0;if((s|0)==(t|0)){v=s;w=s}else{m=f[d>>2]|0;k=m;l=k;o=0;p=s;s=k;k=t;t=m;while(1){m=f[k+(o<<2)>>2]|0;n=f[q>>2]|0;if(m>>>0>2>>>0){x=l;y=s;z=k;A=p}else{r=m+1|0;f[e>>2]=0;B=n-t>>2;C=t;D=n;if(r>>>0<=B>>>0)if(r>>>0>>0?(n=C+(r<<2)|0,(n|0)!=(D|0)):0){f[q>>2]=D+(~((D+-4-n|0)>>>2)<<2);E=l;F=p;G=k}else{E=l;F=p;G=k}else{Ch(d,r-B|0,e);E=f[d>>2]|0;F=f[j>>2]|0;G=f[a>>2]|0}x=E;y=E;z=G;A=F}B=y+(m<<2)|0;f[B>>2]=(f[B>>2]|0)+1;o=o+1|0;if(o>>>0>=A-z>>2>>>0){v=z;w=A;break}else{l=x;p=A;s=y;k=z;t=y}}}y=w-v|0;v=y>>2;f[e>>2]=0;w=e+4|0;f[w>>2]=0;f[e+8>>2]=0;if(!v){H=0;I=0}else{if(v>>>0>536870911)aq(e);t=ln(y<<1)|0;f[w>>2]=t;f[e>>2]=t;y=t+(v<<3)|0;f[e+8>>2]=y;z=v;v=t;k=t;while(1){s=v;f[s>>2]=-1;f[s+4>>2]=-1;s=k+8|0;A=z+-1|0;if(!A)break;else{z=A;v=s;k=s}}f[w>>2]=y;H=t;I=t}t=f[q>>2]|0;y=f[d>>2]|0;k=t-y|0;v=k>>2;f[g>>2]=0;z=g+4|0;f[z>>2]=0;f[g+8>>2]=0;s=y;do if(v)if(v>>>0>1073741823)aq(g);else{A=ln(k)|0;f[g>>2]=A;p=A+(v<<2)|0;f[g+8>>2]=p;sj(A|0,0,k|0)|0;f[z>>2]=p;J=A;K=p;L=A;break}else{J=0;K=0;L=0}while(0);if((t|0)!=(y|0)){y=0;t=0;while(1){f[J+(t<<2)>>2]=y;k=t+1|0;if(k>>>0>>0){y=(f[s+(t<<2)>>2]|0)+y|0;t=k}else break}}t=f[j>>2]|0;j=f[a>>2]|0;y=j;if((t|0)!=(j|0)){k=a+40|0;a=t-j>>2;j=H;t=H;g=H;A=H;p=H;x=H;l=0;o=J;while(1){F=f[y+(l<<2)>>2]|0;G=l+1|0;E=((G>>>0)%3|0|0)==0?l+-2|0:G;if((E|0)==-1)M=-1;else M=f[y+(E<<2)>>2]|0;E=((l>>>0)%3|0|0)==0;G=(E?2:-1)+l|0;if((G|0)==-1)N=-1;else N=f[y+(G<<2)>>2]|0;if(E?(M|0)==(N|0)|((F|0)==(M|0)|(F|0)==(N|0)):0){f[k>>2]=(f[k>>2]|0)+1;O=j;P=t;Q=g;R=A;S=p;T=x;U=l+2|0;V=o}else W=51;a:do if((W|0)==51){W=0;E=f[s+(N<<2)>>2]|0;b:do if((E|0)>0){G=0;B=f[o+(N<<2)>>2]|0;while(1){m=f[p+(B<<3)>>2]|0;if((m|0)==-1){X=j;Y=t;Z=A;_=p;break b}if((m|0)==(M|0)){m=f[p+(B<<3)+4>>2]|0;if((m|0)==-1)$=-1;else $=f[y+(m<<2)>>2]|0;if((F|0)!=($|0))break}m=G+1|0;if((m|0)<(E|0)){G=m;B=B+1|0}else{X=j;Y=t;Z=A;_=p;break b}}m=f[A+(B<<3)+4>>2]|0;r=G;n=B;D=t;while(1){r=r+1|0;if((r|0)>=(E|0))break;C=n+1|0;f[D+(n<<3)>>2]=f[D+(C<<3)>>2];f[D+(n<<3)+4>>2]=f[D+(C<<3)+4>>2];if((f[j+(n<<3)>>2]|0)==-1)break;else{n=C;D=j}}f[g+(n<<3)>>2]=-1;if((m|0)==-1){X=g;Y=g;Z=g;_=g}else{D=f[i>>2]|0;f[D+(l<<2)>>2]=m;f[D+(m<<2)>>2]=l;O=g;P=g;Q=g;R=g;S=g;T=x;U=l;V=o;break a}}else{X=j;Y=t;Z=A;_=p}while(0);E=f[s+(M<<2)>>2]|0;if((E|0)>0){D=0;r=f[J+(M<<2)>>2]|0;while(1){aa=x+(r<<3)|0;if((f[aa>>2]|0)==-1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c+48|0;p=c+40|0;q=i+1|0;m=i+2|0;s=g+4|0;t=g+12|0;v=g+8|0;w=a+40|0;x=a+64|0;y=0;z=0;while(1){A=d;B=f[A>>2]|0;C=f[A+4>>2]|0;A=p;D=un(f[A>>2]|0,f[A+4>>2]|0,r+y|0,0)|0;A=Vn(D|0,I|0,B|0,C|0)|0;C=(f[f[c>>2]>>2]|0)+A|0;b[h>>0]=b[C>>0]|0;b[h+1>>0]=b[C+1>>0]|0;b[h+2>>0]=b[C+2>>0]|0;im(i|0,C|0,3)|0;C=jg(g,i)|0;if(!C){A=b[i>>0]|0;B=b[q>>0]|0;D=b[m>>0]|0;E=((A&255^318)+239^B&255)+239^D&255;F=f[s>>2]|0;G=(F|0)==0;a:do if(!G){H=F+-1|0;J=(H&F|0)==0;if(!J)if(E>>>0>>0)K=E;else K=(E>>>0)%(F>>>0)|0;else K=E&H;L=f[(f[g>>2]|0)+(K<<2)>>2]|0;if((L|0)!=0?(M=f[L>>2]|0,(M|0)!=0):0){if(J){J=M;while(1){L=f[J+4>>2]|0;if(!((L|0)==(E|0)|(L&H|0)==(K|0))){N=K;O=29;break a}L=J+8|0;if(((b[L>>0]|0)==A<<24>>24?(b[L+1>>0]|0)==B<<24>>24:0)?(b[L+2>>0]|0)==D<<24>>24:0)break a;J=f[J>>2]|0;if(!J){N=K;O=29;break a}}}else P=M;while(1){J=f[P+4>>2]|0;if((J|0)!=(E|0)){if(J>>>0>>0)Q=J;else Q=(J>>>0)%(F>>>0)|0;if((Q|0)!=(K|0)){N=K;O=29;break a}}J=P+8|0;if(((b[J>>0]|0)==A<<24>>24?(b[J+1>>0]|0)==B<<24>>24:0)?(b[J+2>>0]|0)==D<<24>>24:0)break a;P=f[P>>2]|0;if(!P){N=K;O=29;break}}}else{N=K;O=29}}else{N=0;O=29}while(0);if((O|0)==29){O=0;M=ln(16)|0;b[M+8>>0]=A;b[M+9>>0]=B;b[M+10>>0]=D;f[M+12>>2]=z;f[M+4>>2]=E;f[M>>2]=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((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)-L>>2>>>0<=K>>>0){J=M;ma=6;break}}if((ma|0)==5){u=e;return 1}else if((ma|0)==6)aq(J);return 0}function uc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=Oa,T=Oa,U=Oa,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0;e=u;u=u+64|0;g=e+36|0;h=e+24|0;i=e+12|0;j=e;k=g+16|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;n[k>>2]=$(1.0);l=a+80|0;m=f[l>>2]|0;f[j>>2]=0;o=j+4|0;f[o>>2]=0;f[j+8>>2]=0;if(m){if(m>>>0>1073741823)aq(j);p=m<<2;q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=f[d>>2]|0;d=c+48|0;p=c+40|0;q=i+4|0;m=i+8|0;s=g+4|0;t=g+12|0;v=g+8|0;w=a+40|0;x=a+64|0;y=0;z=0;while(1){A=d;B=f[A>>2]|0;C=f[A+4>>2]|0;A=p;D=un(f[A>>2]|0,f[A+4>>2]|0,r+z|0,0)|0;A=Vn(D|0,I|0,B|0,C|0)|0;C=(f[f[c>>2]>>2]|0)+A|0;A=h;B=C;D=A+12|0;do{b[A>>0]=b[B>>0]|0;A=A+1|0;B=B+1|0}while((A|0)<(D|0));im(i|0,C|0,12)|0;B=qg(g,i)|0;if(!B){A=f[i>>2]|0;D=f[q>>2]|0;E=f[m>>2]|0;F=((A^318)+239^D)+239^E;G=f[s>>2]|0;H=(G|0)==0;a:do if(!H){J=G+-1|0;K=(J&G|0)==0;if(!K)if(F>>>0>>0)L=F;else L=(F>>>0)%(G>>>0)|0;else L=F&J;M=f[(f[g>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}if(((f[K+8>>2]|0)==(A|0)?(f[K+12>>2]|0)==(D|0):0)?(f[K+16>>2]|0)==(E|0):0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}if(((f[Q+8>>2]|0)==(A|0)?(f[Q+12>>2]|0)==(D|0):0)?(f[Q+16>>2]|0)==(E|0):0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;C=ln(24)|0;f[C+8>>2]=A;f[C+12>>2]=D;f[C+16>>2]=E;f[C+20>>2]=y;f[C+4>>2]=F;f[C>>2]=0;S=$(((f[t>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[k>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;K=~~$(W($(S/U)))>>>0;Xh(g,N>>>0>>0?K:N);N=f[s>>2]|0;K=N+-1|0;if(!(K&N)){V=N;X=K&F;break}if(F>>>0>>0){V=N;X=F}else{V=N;X=(F>>>0)%(N>>>0)|0}}else{V=G;X=O}while(0);G=(f[g>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[C>>2]=f[v>>2];f[v>>2]=C;f[G>>2]=v;G=f[C>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[g>>2]|0)+(Y<<2)|0;P=42}}else{f[C>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=C}f[t>>2]=(f[t>>2]|0)+1}F=w;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,y|0,0)|0;kh((f[f[x>>2]>>2]|0)+H|0,h|0,G|0)|0;G=f[j>>2]|0;f[G+(z<<2)>>2]=y;_=y+1|0;aa=G}else{G=f[j>>2]|0;f[G+(z<<2)>>2]=f[B+20>>2];_=y;aa=G}z=z+1|0;ba=f[l>>2]|0;if(z>>>0>=ba>>>0)break;else y=_}if((_|0)==(ba|0))ca=aa;else{y=a+84|0;if(!(b[y>>0]|0)){z=f[a+72>>2]|0;h=f[a+68>>2]|0;x=h;if((z|0)==(h|0))da=aa;else{w=z-h>>2;h=0;do{z=x+(h<<2)|0;f[z>>2]=f[aa+(f[z>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);da=aa}}else{b[y>>0]=0;y=a+68|0;aa=a+72|0;w=f[aa>>2]|0;h=f[y>>2]|0;x=w-h>>2;z=h;h=w;if(ba>>>0<=x>>>0)if(ba>>>0>>0?(w=z+(ba<<2)|0,(w|0)!=(h|0)):0){f[aa>>2]=h+(~((h+-4-w|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(y,ba-x|0,1220);ea=f[l>>2]|0}x=f[j>>2]|0;if(!ea)da=x;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=x}}f[l>>2]=_;ca=da}if(!ca)fa=_;else{da=f[o>>2]|0;if((da|0)!=(ca|0))f[o>>2]=da+(~((da+-4-ca|0)>>>2)<<2);Oq(ca);fa=_}}else fa=0;_=f[g+8>>2]|0;if(_|0){ca=_;do{_=ca;ca=f[ca>>2]|0;Oq(_)}while((ca|0)!=0)}ca=f[g>>2]|0;f[g>>2]=0;if(!ca){u=e;return fa|0}Oq(ca);u=e;return fa|0} +function di(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Je(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function ei(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Bd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Bd(a,e);return}function fi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+48|0;g=e;h=e+32|0;if(!c){i=0;u=e;return i|0}Gn(g);if((dm(c,0)|0)!=-1?Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0:0){Va[f[(f[c>>2]|0)+20>>2]&127](c);ch(h,a,c,g);c=(f[h>>2]|0)==0;a=h+4|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);if(c){c=f[g>>2]|0;a=g+4|0;rg(d,c,c+((f[a>>2]|0)-c)|0);j=(f[a>>2]|0)-(f[g>>2]|0)|0}else j=0}else j=0;a=g+12|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0)Oq(c);c=f[g>>2]|0;if(c|0){a=g+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}i=j;u=e;return i|0}function gi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Fe(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function hi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{d=g+-4|0;f[c>>2]=d;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=h+88|0;i=f[d>>2]|0;f[d>>2]=0;if(i|0){d=f[i+8>>2]|0;if(d|0){j=i+12|0;if((f[j>>2]|0)!=(d|0))f[j>>2]=d;Oq(d)}Oq(i)}i=f[h+68>>2]|0;if(i|0){d=h+72|0;j=f[d>>2]|0;if((j|0)!=(i|0))f[d>>2]=j+(~((j+-4-i|0)>>>2)<<2);Oq(i)}i=h+64|0;j=f[i>>2]|0;f[i>>2]=0;if(j|0){i=f[j>>2]|0;if(i|0){d=j+4|0;if((f[d>>2]|0)!=(i|0))f[d>>2]=i;Oq(i)}Oq(j)}Oq(h)}g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function ii(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;if(!(Ie(a,c)|0)){i=0;u=d;return i|0}j=a+36|0;k=a+40|0;a=f[j>>2]|0;if((f[k>>2]|0)==(a|0)){i=1;u=d;return i|0}l=c+16|0;m=c+4|0;n=h+1|0;o=0;p=a;do{a=f[p+(o<<2)>>2]|0;q=Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0;b[h>>0]=q;q=l;a=f[q+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[q>>2]|0)>>>0>0)){f[g>>2]=f[m>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}o=o+1|0;p=f[j>>2]|0}while(o>>>0<(f[k>>2]|0)-p>>2>>>0);i=1;u=d;return i|0}function ji(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;e=a+24|0;lp(e);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=20;g=a;h=14538;i=g+20|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+20>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=22;g=a;h=14559;i=g+22|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+22>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)>=0){u=c;return}Oq(f[d>>2]|0);u=c;return}function ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{d=e+-4|0;f[c>>2]=d;g=f[d>>2]|0;f[d>>2]=0;if(g|0){d=g+88|0;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=f[h+8>>2]|0;if(d|0){i=h+12|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;Oq(d)}Oq(h)}h=f[g+68>>2]|0;if(h|0){d=g+72|0;i=f[d>>2]|0;if((i|0)!=(h|0))f[d>>2]=i+(~((i+-4-h|0)>>>2)<<2);Oq(h)}h=g+64|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0){h=f[i>>2]|0;if(h|0){d=i+4|0;if((f[d>>2]|0)!=(h|0))f[d>>2]=h;Oq(h)}Oq(i)}Oq(g)}e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;Oq(b);return}function li(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function mi(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c;e=ln(16)|0;f[d>>2]=e;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=e;h=14408;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[e+14>>0]=0;e=Hk(a,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);j=ln(16)|0;f[d>>2]=j;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=j;h=14423;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[j+14>>0]=0;j=Hk(a,d,-1)|0;if((b[d+11>>0]|0)>=0){k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}Oq(f[d>>2]|0);k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}function ni(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function oi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;h=g+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function pi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=a+32|0;ld(a,b);c=a+80|0;d=f[c>>2]|0;if((d|0?(e=a+84|0,(f[e>>2]|0)>0):0)?(ld(d,b),(f[e>>2]|0)>1):0){d=1;do{ld((f[c>>2]|0)+(d<<5)|0,b);d=d+1|0}while((d|0)<(f[e>>2]|0))}e=a+136|0;d=a+140|0;a=f[e>>2]|0;if((f[d>>2]|0)==(a|0))return;c=0;g=a;while(1){a=g;ci((f[a+(c*12|0)+4>>2]|0)-(f[a+(c*12|0)>>2]|0)>>2,b)|0;a=f[e>>2]|0;h=f[a+(c*12|0)>>2]|0;i=(f[a+(c*12|0)+4>>2]|0)-h>>2;if(!i)j=a;else{Mc(h,i,1,0,b)|0;j=f[e>>2]|0}c=c+1|0;if(c>>>0>=(((f[d>>2]|0)-j|0)/12|0)>>>0)break;else g=j}return}function qi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=d+16|0;g=f[e>>2]|0;if(!g)if(!(vl(d)|0)){h=f[e>>2]|0;i=5}else j=0;else{h=g;i=5}a:do if((i|0)==5){g=d+20|0;e=f[g>>2]|0;k=e;if((h-e|0)>>>0>>0){j=Sa[f[d+36>>2]&31](d,a,c)|0;break}b:do if((b[d+75>>0]|0)>-1){e=c;while(1){if(!e){l=0;m=a;n=c;o=k;break b}p=e+-1|0;if((b[a+p>>0]|0)==10)break;else e=p}p=Sa[f[d+36>>2]&31](d,a,e)|0;if(p>>>0>>0){j=p;break a}l=e;m=a+e|0;n=c-e|0;o=f[g>>2]|0}else{l=0;m=a;n=c;o=k}while(0);kh(o|0,m|0,n|0)|0;f[g>>2]=(f[g>>2]|0)+n;j=l+n|0}while(0);return j|0}function ri(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+12|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d+28>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;ri(c+8|0);Oq(c)}while((e|0)!=0)}e=d+20|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0)Oq(c);c=f[d+8>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;g=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;Oq(h)}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Oq(c)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(e|0)Oq(e);Oq(d)}if((b[a+11>>0]|0)>=0)return;Oq(f[a>>2]|0);return}function si(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0;g=u;u=u+32|0;h=g+12|0;i=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;if((e|0)>0){j=i+11|0;k=i+4|0;l=0;do{if((l|0)>0)An(h,14477)|0;il(i,$(n[d+(l<<2)>>2]));m=b[j>>0]|0;o=m<<24>>24<0;lj(h,o?f[i>>2]|0:i,o?f[k>>2]|0:m&255)|0;if((b[j>>0]|0)<0)Oq(f[i>>2]|0);l=l+1|0}while((l|0)<(e|0))}am(Ai(a,c)|0,h)|0;if((b[h+11>>0]|0)>=0){u=g;return}Oq(f[h>>2]|0);u=g;return}function ti(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){e=1;u=c;return e|0}g=a+4|0;h=a+20|0;i=a+24|0;j=a+16|0;a=0;while(1){k=f[(f[g>>2]|0)+4>>2]|0;l=dm(k,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;f[d>>2]=l;if((l|0)==-1)break;k=f[h>>2]|0;if((k|0)==(f[i>>2]|0))Ri(j,d);else{f[k>>2]=l;f[h>>2]=k+4}gl(f[g>>2]|0,f[d>>2]|0)|0;a=a+1|0;if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){e=1;m=9;break}}if((m|0)==9){u=c;return e|0}e=0;u=c;return e|0}function ui(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=1292;hi(a+60|0);b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=a+36|0;d=f[b>>2]|0;if(d|0){c=a+40|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-24|0;f[c>>2]=e;Va[f[f[e>>2]>>2]&127](e);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){b=a+20|0;d=f[b>>2]|0;if((d|0)!=(g|0))f[b>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function vi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+32|0;d=c+16|0;e=c+8|0;g=c;h=a+8|0;if(f[h>>2]<<5>>>0>=b>>>0){u=c;return}f[d>>2]=0;i=d+4|0;f[i>>2]=0;j=d+8|0;f[j>>2]=0;if((b|0)<0)aq(d);k=((b+-1|0)>>>5)+1|0;b=ln(k<<2)|0;f[d>>2]=b;f[i>>2]=0;f[j>>2]=k;k=f[a>>2]|0;f[e>>2]=k;f[e+4>>2]=0;b=a+4|0;l=f[b>>2]|0;f[g>>2]=k+(l>>>5<<2);f[g+4>>2]=l&31;zg(d,e,g);g=f[a>>2]|0;f[a>>2]=f[d>>2];f[d>>2]=g;d=f[b>>2]|0;f[b>>2]=f[i>>2];f[i>>2]=d;d=f[h>>2]|0;f[h>>2]=f[j>>2];f[j>>2]=d;if(g|0)Oq(g);u=c;return}function wi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+136|0;c=f[b>>2]|0;if(c|0){d=a+140|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=f[a+104>>2]|0;if(g|0){b=a+108|0;j=f[b>>2]|0;if((j|0)!=(g|0))f[b>>2]=j+(~((j+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+92>>2]|0;if(!g){uj(a);return}j=a+96|0;b=f[j>>2]|0;if((b|0)!=(g|0))f[j>>2]=b+(~((b+-4-g|0)>>>2)<<2);Oq(g);uj(a);return}function xi(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3680;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+316|0;e=a+264|0;g=e+52|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=-1;f[a+320>>2]=-1;f[a+324>>2]=0;f[a+328>>2]=2;f[a+332>>2]=7;f[a+336>>2]=0;f[a+340>>2]=0;f[a+344>>2]=0;b[a+352>>0]=0;return}function yi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=(e|0)/12|0;h=g+1|0;if(h>>>0>357913941)aq(a);i=a+8|0;j=((f[i>>2]|0)-d|0)/12|0;k=j<<1;l=j>>>0<178956970?(k>>>0>>0?h:k):357913941;do if(l)if(l>>>0>357913941){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{m=ln(l*12|0)|0;break}else m=0;while(0);k=m+(g*12|0)|0;f[k>>2]=f[b>>2];f[k+4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g;i=h+28|0;u=c;return i|0}function Bi(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=u;u=u+16|0;l=k;if((-18-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)m=f[a>>2]|0;else m=a;if(c>>>0<2147483623){n=d+c|0;d=c<<1;o=n>>>0>>0?d:n;p=o>>>0<11?11:o+16&-16}else p=-17;o=ln(p)|0;if(g|0)Fo(o,m,g)|0;if(i|0)Fo(o+g|0,j,i)|0;j=e-h|0;e=j-g|0;if(e|0)Fo(o+g+i|0,m+g+h|0,e)|0;if((c|0)!=10)Oq(m);f[a>>2]=o;f[a+8>>2]=p|-2147483648;p=j+i|0;f[a+4>>2]=p;b[l>>0]=0;up(o+p|0,l);u=k;return}function Ci(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;sj(d|0,0,b<<2|0)|0;if((i|0)>0)kh(n|0,h|0,i|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=m+(l<<2);if(!h)return;Oq(h);return}function Di(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;pj(g+8|0,e);h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function Ei(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=+d;l=j;j=i;while(1){if(j<<24>>24<0)m=f[c>>2]|0;else m=c;p[g>>3]=k;n=Bn(m,l+1|0,18562,g)|0;if((n|0)>-1)if(n>>>0>l>>>0)o=n;else break;else o=l<<1|1;Hj(c,o,0);l=o;j=b[h>>0]|0}Hj(c,n,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Fi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if((e-h|0)>>>0>=c>>>0){i=c;j=h;do{b[j>>0]=0;j=(f[g>>2]|0)+1|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=h-i|0;h=j+c|0;if((h|0)<0)aq(a);k=e-i|0;i=k<<1;e=k>>>0<1073741823?(i>>>0>>0?h:i):2147483647;if(!e)l=0;else l=ln(e)|0;i=l+j|0;j=l+e|0;e=c;c=i;l=i;do{b[l>>0]=0;l=c+1|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=(f[g>>2]|0)-e|0;h=i+(0-l)|0;if((l|0)>0)kh(h|0,e|0,l|0)|0;f[a>>2]=h;f[g>>2]=c;f[d>>2]=j;if(!e)return;Oq(e);return}function Gi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/136|0;h=d;if(g>>>0>>0){Ge(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b*136|0)|0;if((g|0)==(h|0))return;else i=h;do{f[c>>2]=i+-136;h=f[i+-20>>2]|0;if(h|0){b=i+-16|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);Oq(h)}h=f[i+-32>>2]|0;if(h|0){e=i+-28|0;b=f[e>>2]|0;if((b|0)!=(h|0))f[e>>2]=b+(~((b+-4-h|0)>>>2)<<2);Oq(h)}Mi(i+-132|0);i=f[c>>2]|0}while((i|0)!=(g|0));return}function Hi(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Sd(a,e);return}function Ii(a){a=a|0;var b=0,c=0,d=0;b=f[a+76>>2]|0;if(b|0){c=a+80|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){d=a+68|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+24>>2]|0;if(b|0){c=a+28|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0){d=a+16|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Ji(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=j;j=i;while(1){if(j<<24>>24<0)l=f[c>>2]|0;else l=c;f[g>>2]=d;m=Bn(l,k+1|0,18559,g)|0;if((m|0)>-1)if(m>>>0>k>>>0)n=m;else break;else n=k<<1|1;Hj(c,n,0);k=n;j=b[h>>0]|0}Hj(c,m,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;c=f[b>>2]|0;if((c|0)<0){d=0;return d|0}e=a+4|0;a=f[e>>2]|0;g=a+4|0;h=f[g>>2]|0;i=f[a>>2]|0;j=h-i>>2;k=i;i=h;if(c>>>0<=j>>>0)if(c>>>0>>0?(h=k+(c<<2)|0,(h|0)!=(i|0)):0){f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2);l=c}else l=c;else{Ci(a,c-j|0);l=f[b>>2]|0}if((l|0)<=0){d=1;return d|0}b=f[e>>2]|0;e=f[b>>2]|0;j=(f[b+4>>2]|0)-e>>2;c=e;e=0;while(1){if(j>>>0<=e>>>0){m=10;break}f[c+(e<<2)>>2]=e;e=e+1|0;if((e|0)>=(l|0)){d=1;m=12;break}}if((m|0)==10)aq(b);else if((m|0)==12)return d|0;return 0}function Li(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=ln(16)|0;f[g>>2]=h;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=h;j=14408;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+14>>0]=0;Xj(a,g,c);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);c=ln(16)|0;f[g>>2]=c;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=c;j=14423;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+14>>0]=0;Xj(a,g,d);if((b[g+11>>0]|0)>=0){u=e;return}Oq(f[g>>2]|0);u=e;return}function Mi(a){a=a|0;var b=0,c=0,d=0;b=f[a+84>>2]|0;if(b|0){c=a+88|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+72>>2]|0;if(b|0){d=a+76|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0){d=a+32|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0)Oq(b);b=f[a>>2]|0;if(!b)return;Oq(b);return}function Ni(a){a=a|0;var b=0,c=0,d=0,e=0;f[a>>2]=1352;b=a+32|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+88|0;d=f[b>>2]|0;f[b>>2]=0;if(d|0){b=f[d+8>>2]|0;if(b|0){e=d+12|0;if((f[e>>2]|0)!=(b|0))f[e>>2]=b;Oq(b)}Oq(d)}d=f[c+68>>2]|0;if(d|0){b=c+72|0;e=f[b>>2]|0;if((e|0)!=(d|0))f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2);Oq(d)}d=c+64|0;e=f[d>>2]|0;f[d>>2]=0;if(e|0){d=f[e>>2]|0;if(d|0){b=e+4|0;if((f[b>>2]|0)!=(d|0))f[b>>2]=d;Oq(d)}Oq(e)}Oq(c)}c=f[a+16>>2]|0;if(!c)return;e=a+20|0;a=f[e>>2]|0;if((a|0)!=(c|0))f[e>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Oi(){var a=0,b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+48|0;b=a+32|0;c=a+24|0;d=a+16|0;e=a;g=a+36|0;a=sn()|0;if(a|0?(h=f[a>>2]|0,h|0):0){a=h+48|0;i=f[a>>2]|0;j=f[a+4>>2]|0;if(!((i&-256|0)==1126902528&(j|0)==1129074247)){f[c>>2]=18701;Hn(18651,c)}if((i|0)==1126902529&(j|0)==1129074247)k=f[h+44>>2]|0;else k=h+80|0;f[g>>2]=k;k=f[h>>2]|0;h=f[k+4>>2]|0;if(Sa[f[(f[258]|0)+16>>2]&31](1032,k,g)|0){k=f[g>>2]|0;g=Qa[f[(f[k>>2]|0)+8>>2]&127](k)|0;f[e>>2]=18701;f[e+4>>2]=h;f[e+8>>2]=g;Hn(18565,e)}else{f[d>>2]=18701;f[d+4>>2]=h;Hn(18610,d)}}Hn(18689,b)}function Pi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;do if(a){if(c>>>0<128){b[a>>0]=c;e=1;break}d=(Jq()|0)+188|0;if(!(f[f[d>>2]>>2]|0))if((c&-128|0)==57216){b[a>>0]=c;e=1;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}if(c>>>0<2048){b[a>>0]=c>>>6|192;b[a+1>>0]=c&63|128;e=2;break}if(c>>>0<55296|(c&-8192|0)==57344){b[a>>0]=c>>>12|224;b[a+1>>0]=c>>>6&63|128;b[a+2>>0]=c&63|128;e=3;break}if((c+-65536|0)>>>0<1048576){b[a>>0]=c>>>18|240;b[a+1>>0]=c>>>12&63|128;b[a+2>>0]=c>>>6&63|128;b[a+3>>0]=c&63|128;e=4;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}}else e=1;while(0);return e|0}function Qi(a){a=a|0;var b=0,c=0,d=0;b=f[a+92>>2]|0;if(b|0){c=a+96|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0){d=a+80|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}f[a+4>>2]=3636;b=f[a+24>>2]|0;if(b|0)Oq(b);b=f[a+12>>2]|0;if(!b)return;Oq(b);return}function Ri(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=e>>2;h=g+1|0;if(h>>>0>1073741823)aq(a);i=a+8|0;j=(f[i>>2]|0)-d|0;k=j>>1;l=j>>2>>>0<536870911?(k>>>0>>0?h:k):1073741823;do if(l)if(l>>>0>1073741823){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{k=ln(l<<2)|0;m=k;n=k;break}else{m=0;n=0}while(0);k=m+(g<<2)|0;f[k>>2]=f[b>>2];if((e|0)>0)kh(n|0,d|0,e|0)|0;f[a>>2]=m;f[c>>2]=k+4;f[i>>2]=m+(l<<2);if(!d)return;Oq(d);return}function Si(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=a+104|0;d=f[c>>2]|0;if((d|0)!=0?(f[a+108>>2]|0)>=(d|0):0)e=4;else{d=Wm(a)|0;if((d|0)>=0){g=f[c>>2]|0;c=a+8|0;if(g){i=f[c>>2]|0;j=f[a+4>>2]|0;k=g-(f[a+108>>2]|0)|0;g=i;if((i-j|0)<(k|0)){l=g;m=g}else{l=j+(k+-1)|0;m=g}}else{g=f[c>>2]|0;l=g;m=g}f[a+100>>2]=l;l=a+4|0;if(!m)n=f[l>>2]|0;else{g=f[l>>2]|0;l=a+108|0;f[l>>2]=m+1-g+(f[l>>2]|0);n=g}g=n+-1|0;if((d|0)==(h[g>>0]|0|0))o=d;else{b[g>>0]=d;o=d}}else e=4}if((e|0)==4){f[a+100>>2]=0;o=-1}return o|0}function Ti(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=2384;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2440;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Ui(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=1964;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2020;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Vi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2440;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Wi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[(f[c+4>>2]|0)+4>>2]|0;if(!g){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=d;return}if(!(Dj(d+12|0,f[c+44>>2]|0,g)|0)){g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=26;c=g;h=15859;i=c+26|0;do{b[c>>0]=b[h>>0]|0;c=c+1|0;h=h+1|0}while((c|0)<(i|0));b[g+26>>0]=0;f[a>>2]=-1;pj(a+4|0,e);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0)}else{f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}u=d;return}function Xi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=b+48|0;if((mi(f[c>>2]|0)|0)>9){d=0;return d|0}if((Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)!=1){d=0;return d|0}e=b+4|0;b=(f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0)+56|0;a=f[b>>2]|0;do if((a|0)==3)if((mi(f[c>>2]|0)|0)<4){d=5;return d|0}else{g=f[b>>2]|0;break}else g=a;while(0);a=mi(f[c>>2]|0)|0;if((g|0)==1){d=(a|0)<4?6:0;return d|0}if((a|0)>7){d=0;return d|0}if((mi(f[c>>2]|0)|0)>1){d=1;return d|0}else return ((f[(f[e>>2]|0)+80>>2]|0)>>>0<40?1:4)|0;return 0}function Yi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2020;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Zi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=u;u=u+128|0;h=g+124|0;i=g;j=i;k=6596;l=j+124|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));if((c+-1|0)>>>0>2147483646)if(!c){m=h;n=1;o=4}else{h=Vq()|0;f[h>>2]=75;p=-1}else{m=a;n=c;o=4}if((o|0)==4){o=-2-m|0;c=n>>>0>o>>>0?o:n;f[i+48>>2]=c;n=i+20|0;f[n>>2]=m;f[i+44>>2]=m;o=m+c|0;m=i+16|0;f[m>>2]=o;f[i+28>>2]=o;o=Ah(i,d,e)|0;if(!c)p=o;else{c=f[n>>2]|0;b[c+(((c|0)==(f[m>>2]|0))<<31>>31)>>0]=0;p=o}}u=g;return p|0}function _i(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3480;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+264|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;b[d+24>>0]=0;return}function $i(a,c,d,e){a=a|0;c=c|0;d=d|0;e=+e;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;Zl(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function aj(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;$l(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function bj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+28>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;g=c+20|0;h=f[g>>2]|0;f[g>>2]=0;if(h|0){bj(h);Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=a+20|0;c=f[d>>2]|0;f[d>>2]=0;if(c|0)Oq(c);c=f[a+8>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){g=c+24|0;if((f[g>>2]|0)!=(h|0))f[g>>2]=h;Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=f[a>>2]|0;f[a>>2]=0;if(!d)return;Oq(d);return}function cj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;e=u;u=u+16|0;g=e;h=f[c+36>>2]|0;if(!h){i=ln(32)|0;f[g>>2]=i;f[g+8>>2]=-2147483616;f[g+4>>2]=23;j=i;k=15706;l=j+23|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+23>>0]=0;f[a>>2]=-1;pj(a+4|0,g);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);u=e;return}g=f[c+40>>2]|0;if(!g){Sc(a,c,h,d);u=e;return}else{bi(a,c,g,d);u=e;return}}function dj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;tk(a);b=a+84|0;c=f[b>>2]|0;if((c|0)<=0)return;d=c<<5;e=Lq(c>>>0>134217727|d>>>0>4294967291?-1:d+4|0)|0;f[e>>2]=c;d=e+4|0;e=d+(c<<5)|0;c=d;do{wn(c);c=c+32|0}while((c|0)!=(e|0));e=a+80|0;a=f[e>>2]|0;f[e>>2]=d;if(a|0){d=a+-4|0;c=f[d>>2]|0;if(c|0){g=a+(c<<5)|0;do{g=g+-32|0;Fj(g)}while((g|0)!=(a|0))}Mq(d)}if((f[b>>2]|0)>0)h=0;else return;do{tk((f[e>>2]|0)+(h<<5)|0);h=h+1|0}while((h|0)<(f[b>>2]|0));return}function ej(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!b){d=0;return d|0}if(f[b+4>>2]|0){d=0;return d|0}a=ln(52)|0;Ub(a,c);f[a+40>>2]=0;f[a+44>>2]=0;f[a+48>>2]=0;c=b+4|0;b=f[c>>2]|0;f[c>>2]=a;if(!b){d=1;return d|0}a=b+40|0;c=f[a>>2]|0;if(c|0){e=b+44|0;g=f[e>>2]|0;if((g|0)==(c|0))h=c;else{i=g;do{g=i+-4|0;f[e>>2]=g;j=f[g>>2]|0;f[g>>2]=0;if(j|0){bj(j);Oq(j)}i=f[e>>2]|0}while((i|0)!=(c|0));h=f[a>>2]|0}Oq(h)}bj(b);Oq(b);d=1;return d|0}function fj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;if(b){b=c+8|0;d=b;e=Vn(f[d>>2]|0,f[d+4>>2]|0,1,0)|0;d=b;f[d>>2]=e;f[d+4>>2]=I;d=a+28|0;e=f[d>>2]|0;b=a+24|0;f[b>>2]=f[b>>2]|1<>2]|0,f[e+4>>2]|0,1,0)|0;e=c;f[e>>2]=d;f[e+4>>2]=I;e=a+28|0;g=e;h=f[e>>2]|0}e=h+1|0;f[g>>2]=e;if((e|0)!=32)return;e=a+24|0;h=a+16|0;d=f[h>>2]|0;if((d|0)==(f[a+20>>2]|0))Ri(a+12|0,e);else{f[d>>2]=f[e>>2];f[h>>2]=d+4}f[g>>2]=0;f[e>>2]=0;return}function gj(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+32|0;a=f[b>>2]|0;f[b>>2]=0;b=f[c>>2]|0;f[c>>2]=a;if(!b)return;a=b+88|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0){a=f[c+8>>2]|0;if(a|0){d=c+12|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;Oq(a)}Oq(c)}c=f[b+68>>2]|0;if(c|0){a=b+72|0;d=f[a>>2]|0;if((d|0)!=(c|0))f[a>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=b+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){a=d+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}Oq(d)}Oq(b);return}function hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;if(c|0){h=a+11|0;i=b[h>>0]|0;if(i<<24>>24<0){j=f[a+4>>2]|0;k=(f[a+8>>2]&2147483647)+-1|0}else{j=i&255;k=10}if((k-j|0)>>>0>>0){xj(a,k,c-k+j|0,j,j,0,0);l=b[h>>0]|0}else l=i;if(l<<24>>24<0)m=f[a>>2]|0;else m=a;Qn(m+j|0,c,d)|0;d=j+c|0;if((b[h>>0]|0)<0)f[a+4>>2]=d;else b[h>>0]=d;b[g>>0]=0;up(m+d|0,g)}u=e;return a|0}function ij(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+48|0;e=d+4|0;g=d;h=f[b+12>>2]|0;i=f[b+4>>2]|0;b=e;j=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));zh(g,c,h,i,e);i=f[e+24>>2]|0;if(!i){k=f[g>>2]|0;f[a>>2]=k;u=d;return}h=e+28|0;e=f[h>>2]|0;if((e|0)!=(i|0))f[h>>2]=e+(~((e+-4-i|0)>>>2)<<2);Oq(i);k=f[g>>2]|0;f[a>>2]=k;u=d;return}function jj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=(f[a+8>>2]&2147483647)+-1|0;else k=10;do if(k>>>0>=d>>>0){if(j)l=f[a>>2]|0;else l=a;Eo(l,c,d)|0;b[g>>0]=0;up(l+d|0,g);if((b[h>>0]|0)<0){f[a+4>>2]=d;break}else{b[h>>0]=d;break}}else{if(j)m=f[a+4>>2]|0;else m=i&255;Bi(a,k,d-k|0,m,0,m,d,c)}while(0);u=e;return a|0}function kj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{f[c>>2]=g+-136;d=f[g+-20>>2]|0;if(d|0){h=g+-16|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d)}d=f[g+-32>>2]|0;if(d|0){i=g+-28|0;h=f[i>>2]|0;if((h|0)!=(d|0))f[i>>2]=h+(~((h+-4-d|0)>>>2)<<2);Oq(d)}Mi(g+-132|0);g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function lj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j){k=f[a+4>>2]|0;l=(f[a+8>>2]&2147483647)+-1|0}else{k=i&255;l=10}if((l-k|0)>>>0>=d>>>0){if(d|0){if(j)m=f[a>>2]|0;else m=a;Fo(m+k|0,c,d)|0;j=k+d|0;if((b[h>>0]|0)<0)f[a+4>>2]=j;else b[h>>0]=j;b[g>>0]=0;up(m+j|0,g)}}else Bi(a,l,d-l+k|0,k,k,0,d,c);u=e;return a|0}function mj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=3932;b=f[a+32>>2]|0;if(b|0){c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){d=a+24|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+8|0;c=f[b>>2]|0;if(!c)return;d=a+12|0;a=f[d>>2]|0;if((a|0)==(c|0))e=c;else{g=a;do{a=g+-4|0;f[d>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Va[f[(f[h>>2]|0)+4>>2]&127](h);g=f[d>>2]|0}while((g|0)!=(c|0));e=f[b>>2]|0}Oq(e);return}function nj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){d=1;return d|0}a=0;while(1){e=f[(f[c>>2]|0)+4>>2]|0;g=dm(e,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;if((g|0)==-1){d=0;h=6;break}e=f[(f[b>>2]|0)+28>>2]|0;i=fl(f[c>>2]|0,g)|0;a=a+1|0;if(!(Ra[e&127](b,i)|0)){d=0;h=6;break}if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){d=1;h=6;break}}if((h|0)==6)return d|0;return 0}function oj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!(ho(a,b,c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+52>>2]&127](a)|0)){d=0;return d|0}c=a+4|0;e=a+8|0;g=f[c>>2]|0;if((f[e>>2]|0)==(g|0)){d=1;return d|0}h=a+36|0;a=0;i=g;while(1){g=f[(f[h>>2]|0)+(a<<2)>>2]|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,b,f[i+(a<<2)>>2]|0)|0)){d=0;j=7;break}a=a+1|0;i=f[c>>2]|0;if(a>>>0>=(f[e>>2]|0)-i>>2>>>0){d=1;j=7;break}}if((j|0)==7)return d|0;return 0}function pj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;if((b[c+11>>0]|0)<0){g=f[c>>2]|0;h=f[c+4>>2]|0;if(h>>>0>4294967279)aq(a);if(h>>>0<11){b[a+11>>0]=h;i=a}else{j=h+16&-16;k=ln(j)|0;f[a>>2]=k;f[a+8>>2]=j|-2147483648;f[a+4>>2]=h;i=k}Fo(i,g,h)|0;b[e>>0]=0;up(i+h|0,e)}else{f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2]}u=d;return}function qj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;b[c+53>>0]=1;do if((f[c+4>>2]|0)==(e|0)){b[c+52>>0]=1;a=c+16|0;h=f[a>>2]|0;if(!h){f[a>>2]=d;f[c+24>>2]=g;f[c+36>>2]=1;if(!((g|0)==1?(f[c+48>>2]|0)==1:0))break;b[c+54>>0]=1;break}if((h|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;b[c+54>>0]=1;break}h=c+24|0;a=f[h>>2]|0;if((a|0)==2){f[h>>2]=g;i=g}else i=a;if((i|0)==1?(f[c+48>>2]|0)==1:0)b[c+54>>0]=1}while(0);return}function rj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)!=(e|0)){g=0;h=e;do{vg(h+(g*24|0)|0,b)|0;g=g+1|0;h=f[c>>2]|0}while(g>>>0<(((f[d>>2]|0)-h|0)/24|0)>>>0)}h=a+48|0;d=a+52|0;a=f[h>>2]|0;if((f[d>>2]|0)==(a|0))return 1;else{i=0;j=a}do{a=f[j+(i<<2)>>2]|0;ci(a<<1^a>>31,b)|0;i=i+1|0;j=f[h>>2]|0}while(i>>>0<(f[d>>2]|0)-j>>2>>>0);return 1}function sj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=e&-4|0;h=g-64|0;i=c|c<<8|c<<16|c<<24;while((a|0)<=(h|0)){f[a>>2]=i;f[a+4>>2]=i;f[a+8>>2]=i;f[a+12>>2]=i;f[a+16>>2]=i;f[a+20>>2]=i;f[a+24>>2]=i;f[a+28>>2]=i;f[a+32>>2]=i;f[a+36>>2]=i;f[a+40>>2]=i;f[a+44>>2]=i;f[a+48>>2]=i;f[a+52>>2]=i;f[a+56>>2]=i;f[a+60>>2]=i;a=a+64|0}while((a|0)<(g|0)){f[a>>2]=i;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function tj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(fp(a,f[c>>2]|0,g)|0){if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0)b[c+54>>0]=1;f[c+44>>2]=4;break}if((e|0)==1)f[c+32>>2]=1}}else Vm(0,c,d,e);while(0);return}function uj(a){a=a|0;var b=0,c=0,d=0,e=0;b=a+80|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+-4|0;d=f[b>>2]|0;if(d|0){e=c+(d<<5)|0;do{e=e+-32|0;Fj(e)}while((e|0)!=(c|0))}Mq(b)}b=f[a+68>>2]|0;if(b|0){c=a+72|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b)}b=a+44|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0)Oq(e);e=f[a+32>>2]|0;if(!e){Fj(a);return}b=a+36|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e);Fj(a);return}function vj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3092;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function wj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if((d|0)<0){e=0;return e|0}do if(!b){d=a+4|0;g=f[d>>2]|0;h=f[a>>2]|0;i=g-h|0;if(i>>>0>>0){Fi(a,c-i|0);break}if(i>>>0>c>>>0?(i=h+c|0,(i|0)!=(g|0)):0)f[d>>2]=i}else Cg(a,b,b+c|0);while(0);c=a+24|0;a=c;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=c;f[a>>2]=b;f[a+4>>2]=I;e=1;return e|0}function xj(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((-17-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)j=f[a>>2]|0;else j=a;if(c>>>0<2147483623){k=d+c|0;d=c<<1;l=k>>>0>>0?d:k;m=l>>>0<11?11:l+16&-16}else m=-17;l=ln(m)|0;if(g|0)Fo(l,j,g)|0;k=e-h-g|0;if(k|0)Fo(l+g+i|0,j+g+h|0,k)|0;if((c|0)!=10)Oq(j);f[a>>2]=l;f[a+8>>2]=m|-2147483648;return}function yj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2728;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function zj(a,b){a=a|0;b=b|0;if(!b)return;else{zj(a,f[b>>2]|0);zj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Aj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;Yf(a,b,c);c=f[a+100>>2]|0;d=f[a+96>>2]|0;a=d;if((c|0)==(d|0))return;e=f[b>>2]|0;b=(c-d|0)/12|0;d=0;do{c=a+(d*12|0)|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+4|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+8|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];d=d+1|0}while(d>>>0>>0);return}function Bj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=a+64|0;if((f[d>>2]|0)==0?(e=ln(32)|0,yn(e),g=f[d>>2]|0,f[d>>2]=e,g|0):0){e=f[g>>2]|0;if(e|0){h=g+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(g)}g=Vl(f[a+28>>2]|0)|0;e=X(g,b[a+24>>0]|0)|0;g=((e|0)<0)<<31>>31;h=f[d>>2]|0;i=un(e|0,g|0,c|0,0)|0;if(!(wj(h,0,i,I)|0)){j=0;return j|0}Kk(a,f[d>>2]|0,e,g,0,0);f[a+80>>2]=c;j=1;return j|0}function Cj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+64|0;e=d;if(!(fp(a,b,0)|0))if((b|0)!=0?(g=Eh(b,1056,1040,0)|0,(g|0)!=0):0){b=e+4|0;h=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(h|0));f[e>>2]=g;f[e+8>>2]=a;f[e+12>>2]=-1;f[e+48>>2]=1;Ya[f[(f[g>>2]|0)+28>>2]&3](g,e,f[c>>2]|0,1);if((f[e+24>>2]|0)==1){f[c>>2]=f[e+16>>2];i=1}else i=0;j=i}else j=0;else j=1;u=d;return j|0}function Dj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;if(!c){d=0;return d|0}e=c+40|0;g=c+44|0;ci((f[g>>2]|0)-(f[e>>2]|0)>>2,b)|0;h=f[e>>2]|0;e=f[g>>2]|0;if((h|0)!=(e|0)){g=h;do{h=f[g>>2]|0;if(h|0){ci(f[h+40>>2]|0,b)|0;lg(a,b,h)|0}g=g+4|0}while((g|0)!=(e|0))}lg(a,b,c)|0;d=1;return d|0}function Ej(a,c){a=a|0;c=c|0;var d=0;if(!c)return;Ej(a,f[c>>2]|0);Ej(a,f[c+4>>2]|0);a=c+16|0;d=c+28|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);Oq(c);return}function Fj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e+(~((e+-4-c|0)>>>2)<<2)|0;f[d>>2]=h;g=h}f[a+24>>2]=0;f[a+28>>2]=0;if(c|0){if((g|0)!=(c|0))f[d>>2]=g+(~((g+-4-c|0)>>>2)<<2);Oq(c)}c=f[a>>2]|0;if(!c){u=b;return}g=a+4|0;a=f[g>>2]|0;if((a|0)!=(c|0))f[g>>2]=a+(~((a+-8-c|0)>>>3)<<3);Oq(c);u=b;return}function Gj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;a:do if(!(c&3)){d=a;e=4}else{g=a;h=c;while(1){if(!(b[g>>0]|0)){i=h;break a}j=g+1|0;h=j;if(!(h&3)){d=j;e=4;break}else g=j}}while(0);if((e|0)==4){e=d;while(1){k=f[e>>2]|0;if(!((k&-2139062144^-2139062144)&k+-16843009))e=e+4|0;else break}if(!((k&255)<<24>>24))l=e;else{k=e;while(1){e=k+1|0;if(!(b[e>>0]|0)){l=e;break}else k=e}}i=l}return i-c|0}function Hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=f[a+4>>2]|0;else k=i&255;do if(k>>>0>=c>>>0)if(j){i=(f[a>>2]|0)+c|0;b[g>>0]=0;up(i,g);f[a+4>>2]=c;break}else{b[g>>0]=0;up(a+c|0,g);b[h>>0]=c;break}else hj(a,c-k|0,d)|0;while(0);u=e;return}function Ij(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}Oq(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;Oq(c)}Oq(d)}Oq(a);return}function Jj(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;f[a>>2]=d;if(d|0){m=d+16|0;n=f[m+4>>2]|0;o=a+8|0;f[o>>2]=f[m>>2];f[o+4>>2]=n;n=d+24|0;d=f[n+4>>2]|0;o=a+16|0;f[o>>2]=f[n>>2];f[o+4>>2]=d}b[a+24>>0]=e;f[a+28>>2]=g;b[a+32>>0]=h&1;h=a+40|0;f[h>>2]=i;f[h+4>>2]=j;j=a+48|0;f[j>>2]=k;f[j+4>>2]=l;f[a+56>>2]=c;return}function Kj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=ln(88)|0;d=c+60|0;e=c;g=e+60|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=c;d=c+64|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;d=cg(c,b)|0;f[a>>2]=d?c:0;a=d?0:c;if(d)return;Ii(a);Oq(a);return}function Lj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;if((f[c+76>>2]|0)>=0?(Tq(c)|0)!=0:0){d=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(g=c+20|0,h=f[g>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[g>>2]=h+1;b[h>>0]=d;i=e}else i=Nj(c,a)|0;Sq(c);j=i}else k=3;do if((k|0)==3){i=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(d=c+20|0,h=f[d>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[d>>2]=h+1;b[h>>0]=i;j=e;break}j=Nj(c,a)|0}while(0);return j|0}function Mj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=f[a+4>>2]|0;if((i|0)==-1){j=0;u=d;return j|0}b[h>>0]=i;i=c+16|0;a=f[i+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[i>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}j=1;u=d;return j|0}function Nj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+16|0;e=d;g=c&255;b[e>>0]=g;i=a+16|0;j=f[i>>2]|0;if(!j)if(!(vl(a)|0)){k=f[i>>2]|0;l=4}else m=-1;else{k=j;l=4}do if((l|0)==4){j=a+20|0;i=f[j>>2]|0;if(i>>>0>>0?(n=c&255,(n|0)!=(b[a+75>>0]|0)):0){f[j>>2]=i+1;b[i>>0]=g;m=n;break}if((Sa[f[a+36>>2]&31](a,e,1)|0)==1)m=h[e>>0]|0;else m=-1}while(0);u=d;return m|0}function Oj(a,b){a=a|0;b=b|0;if(!b)return;else{Oj(a,f[b>>2]|0);Oj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Pj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=e+4|0;f[g>>2]=c;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=17;i=c;j=14495;k=i+17|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+17>>0]=0;Xj(Hd(a,g)|0,h,d);if((b[h+11>>0]|0)>=0){u=e;return}Oq(f[h>>2]|0);u=e;return}function Qj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=a+48|0;if((f[a+52>>2]|0)>>>0<=e>>>0)Ce(b,e+1|0,0);c=(f[b>>2]|0)+(e>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(e&31);c=f[a+36>>2]|0;if((f[a+40>>2]|0)-c>>2>>>0<=e>>>0){d=1;return d|0}Bp(f[c+(e<<2)>>2]|0);d=1;return d|0}function Rj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if(c>>>0>0|(c|0)==0&a>>>0>4294967295){e=d;f=a;g=c;while(1){c=hn(f|0,g|0,10,0)|0;e=e+-1|0;b[e>>0]=c&255|48;c=f;f=jp(f|0,g|0,10,0)|0;if(!(g>>>0>9|(g|0)==9&c>>>0>4294967295))break;else g=I}h=f;i=e}else{h=a;i=d}if(!h)j=i;else{d=h;h=i;while(1){i=h+-1|0;b[i>>0]=(d>>>0)%10|0|48;if(d>>>0<10){j=i;break}else{d=(d>>>0)/10|0;h=i}}}return j|0}function Sj(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=a;while(1){d=c+1|0;if(!(eq(b[c>>0]|0)|0))break;else c=d}a=b[c>>0]|0;switch(a<<24>>24|0){case 45:{e=1;f=5;break}case 43:{e=0;f=5;break}default:{g=0;h=c;i=a}}if((f|0)==5){g=e;h=d;i=b[d>>0]|0}if(!(Aq(i<<24>>24)|0))j=0;else{i=0;d=h;while(1){h=(i*10|0)+48-(b[d>>0]|0)|0;d=d+1|0;if(!(Aq(b[d>>0]|0)|0)){j=h;break}else i=h}}return (g|0?j:0-j|0)|0}function Tj(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0;e=u;u=u+16|0;g=e;il(g,d);h=Ai(a,c)|0;c=h+11|0;if((b[c>>0]|0)<0){b[f[h>>2]>>0]=0;f[h+4>>2]=0}else{b[h>>0]=0;b[c>>0]=0}gh(h,0);f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];u=e;return}function Uj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b+8|0;d=b+4|0;e=b;f[e>>2]=f[(f[a+4>>2]|0)+80>>2];g=f[a+44>>2]|0;a=g+16|0;h=f[a+4>>2]|0;if((h|0)>0|(h|0)==0&(f[a>>2]|0)>>>0>0){u=b;return 1}f[d>>2]=f[g+4>>2];f[c>>2]=f[d>>2];Me(g,c,e,e+4|0)|0;u=b;return 1}function Vj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d&1);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Wj(a){a=a|0;if(!a)return;Ej(a+24|0,f[a+28>>2]|0);zj(a+12|0,f[a+16>>2]|0);Ej(a,f[a+4>>2]|0);Oq(a);return}function Xj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Yj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=-1;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}a=e+28|0;if((b[a+11>>0]|0)<0)k=f[a>>2]|0;else k=a;g=Sj(k)|0;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}function Zj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(c>>>0>10){g=0;u=d;return g|0}h=ln(48)|0;f[e>>2]=h;f[e+8>>2]=-2147483600;f[e+4>>2]=33;i=h;j=15987;k=i+33|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+33>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);g=1;u=d;return g|0}function _j(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[b>>2]|0;if((c|0)==-1)return 1;b=c*3|0;if((b|0)==-1)return 1;c=f[a>>2]|0;a=f[c+(b<<2)>>2]|0;d=b+1|0;e=((d>>>0)%3|0|0)==0?b+-2|0:d;if((e|0)==-1)g=-1;else g=f[c+(e<<2)>>2]|0;e=(((b>>>0)%3|0|0)==0?2:-1)+b|0;if((e|0)==-1)h=-1;else h=f[c+(e<<2)>>2]|0;if((a|0)==(g|0))return 1;else return (a|0)==(h|0)|(g|0)==(h|0)|0;return 0}function $j(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=0;while(1){if((h[16654+d>>0]|0)==(a|0)){e=2;break}g=d+1|0;if((g|0)==87){i=16742;j=87;e=5;break}else d=g}if((e|0)==2)if(!d)k=16742;else{i=16742;j=d;e=5}if((e|0)==5)while(1){e=0;d=i;do{a=d;d=d+1|0}while((b[a>>0]|0)!=0);j=j+-1|0;if(!j){k=d;break}else{i=d;e=5}}return jq(k,f[c+20>>2]|0)|0}function ak(a,b){a=+a;b=b|0;var c=0,d=0,e=0,g=0.0,h=0.0,i=0,j=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;e=Yn(c|0,d|0,52)|0;switch(e&2047){case 0:{if(a!=0.0){g=+ak(a*18446744073709551616.0,b);h=g;i=(f[b>>2]|0)+-64|0}else{h=a;i=0}f[b>>2]=i;j=h;break}case 2047:{j=a;break}default:{f[b>>2]=(e&2047)+-1022;f[s>>2]=c;f[s+4>>2]=d&-2146435073|1071644672;j=+p[s>>3]}}return +j}function bk(a,b){a=+a;b=b|0;var c=0.0,d=0,e=0,g=0.0,h=0;if((b|0)<=1023)if((b|0)<-1022){c=a*2.2250738585072014e-308;d=(b|0)<-2044;e=b+2044|0;g=d?c*2.2250738585072014e-308:c;h=d?((e|0)>-1022?e:-1022):b+1022|0}else{g=a;h=b}else{c=a*8988465674311579538646525.0e283;e=(b|0)>2046;d=b+-2046|0;g=e?c*8988465674311579538646525.0e283:c;h=e?((d|0)<1023?d:1023):b+-1023|0}b=Tn(h+1023|0,0,52)|0;h=I;f[s>>2]=b;f[s+4>>2]=h;return +(g*+p[s>>3])}function ck(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;if(!(f[a+80>>2]|0)){b=0;return b|0}c=a+8|0;d=a+12|0;a=f[c>>2]|0;if(((f[d>>2]|0)-a|0)>0){e=0;g=a}else{b=1;return b|0}while(1){a=f[g+(e<<2)>>2]|0;e=e+1|0;if(!(Gl(a,a)|0)){b=0;h=5;break}g=f[c>>2]|0;if((e|0)>=((f[d>>2]|0)-g>>2|0)){b=1;h=5;break}}if((h|0)==5)return b|0;return 0}function dk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)==(e|0)){g=1;return g|0}h=a+60|0;a=0;i=e;while(1){e=f[i+(a<<2)>>2]|0;a=a+1|0;if(!(Sa[f[(f[e>>2]|0)+20>>2]&31](e,h,b)|0)){g=0;j=5;break}i=f[c>>2]|0;if(a>>>0>=(f[d>>2]|0)-i>>2>>>0){g=1;j=5;break}}if((j|0)==5)return g|0;return 0}function ek(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+36|0;d=a+40|0;a=f[c>>2]|0;if((f[d>>2]|0)==(a|0)){e=1;return e|0}else{g=0;h=a}while(1){a=f[h+(g<<2)>>2]|0;g=g+1|0;if(!(Ra[f[(f[a>>2]|0)+24>>2]&127](a,b)|0)){e=0;i=4;break}h=f[c>>2]|0;if(g>>>0>=(f[d>>2]|0)-h>>2>>>0){e=1;i=4;break}}if((i|0)==4)return e|0;return 0}function fk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=e>>2;if(!g)return;if(g>>>0>1073741823)aq(a);h=ln(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g<<2);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;kh(h|0,g|0,b|0)|0;f[c>>2]=h+(b>>>2<<2);return}function gk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=a+8|0;d=f[a>>2]|0;if((f[c>>2]|0)-d>>2>>>0>=b>>>0)return;e=a+4|0;if(b>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=(f[e>>2]|0)-d|0;h=ln(b<<2)|0;if((g|0)>0)kh(h|0,d|0,g|0)|0;f[a>>2]=h;f[e>>2]=h+(g>>2<<2);f[c>>2]=h+(b<<2);if(!d)return;Oq(d);return}function hk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=a+36|0;c=a+40|0;d=f[b>>2]|0;if((f[c>>2]|0)==(d|0)){e=1;return e|0}g=a+60|0;a=0;h=d;while(1){d=f[h+(a<<2)>>2]|0;a=a+1|0;if(!(Ra[f[(f[d>>2]|0)+16>>2]&127](d,g)|0)){e=0;i=5;break}h=f[b>>2]|0;if(a>>>0>=(f[c>>2]|0)-h>>2>>>0){e=1;i=5;break}}if((i|0)==5)return e|0;return 0}function ik(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=f[a+176>>2]|0;e=f[a+172>>2]|0;a=e;if((d|0)==(e|0))return 0;g=(d-e|0)/136|0;e=0;while(1){if((f[a+(e*136|0)>>2]|0)==(c|0)){h=4;break}d=e+1|0;if(d>>>0>>0)e=d;else{h=6;break}}if((h|0)==4)return ((b[a+(e*136|0)+100>>0]|0)==0?0:a+(e*136|0)+4|0)|0;else if((h|0)==6)return 0;return 0}function jk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;g=ln(16)|0;f[e>>2]=g;f[e+8>>2]=-2147483632;f[e+4>>2]=15;h=g;i=14479;j=h+15|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+15>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)>=0){u=d;return}Oq(f[e>>2]|0);u=d;return}function kk(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[a+72>>2]|0;if(!c){d=0;return d|0}f[c+4>>2]=a+60;if(!(Qa[f[(f[c>>2]|0)+12>>2]&127](c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){d=0;return d|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){d=0;return d|0}d=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return d|0}function lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;f[a>>2]=0;d=a+4|0;f[d>>2]=0;f[a+8>>2]=0;if(!b)return;if(b>>>0>357913941)aq(a);e=ln(b*12|0)|0;f[d>>2]=e;f[a>>2]=e;f[a+8>>2]=e+(b*12|0);a=b;b=e;do{fk(b,c);b=(f[d>>2]|0)+12|0;f[d>>2]=b;a=a+-1|0}while((a|0)!=0);return}function mk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=f[b>>2]|0;if(!c){d=0;return d|0}e=a+44|0;g=f[e>>2]|0;if(g>>>0<(f[a+48>>2]|0)>>>0){f[b>>2]=0;f[g>>2]=c;f[e>>2]=(f[e>>2]|0)+4;d=1;return d|0}else{Ug(a+40|0,b);d=1;return d|0}return 0}function nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function ok(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);Oq(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);Oq(a);return}function pk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;f[c>>2]=2;d=a+4|0;a=c+8|0;e=f[a>>2]|0;g=(f[c+12>>2]|0)-e|0;if(g>>>0<4294967292){Lk(a,g+4|0,0);i=f[a>>2]|0}else i=e;e=i+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[e>>0]=g;b[e+1>>0]=g>>8;b[e+2>>0]=g>>16;b[e+3>>0]=g>>24;return}function qk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function sk(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=Oa,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return $(g)}a=e+28|0;if((b[a+11>>0]|0)<0)h=f[a>>2]|0;else h=a;g=$(+Iq(h));return $(g)}function tk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0)){g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}f[d>>2]=e+(~((e+-4-c|0)>>>2)<<2);g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}function uk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=f[a+176>>2]|0;d=f[a+172>>2]|0;e=d;a:do if((c|0)!=(d|0)){g=(c-d|0)/136|0;h=0;while(1){if((f[e+(h*136|0)>>2]|0)==(b|0))break;i=h+1|0;if(i>>>0>>0)h=i;else break a}j=e+(h*136|0)+104|0;return j|0}while(0);j=a+40|0;return j|0}function vk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function wk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function xk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);return}function yk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;Nc(a,b);if((b|0)<=-1)return;c=a+88|0;d=f[c>>2]|0;e=f[a+84>>2]|0;if((d-e>>2|0)<=(b|0))return;a=e+(b<<2)|0;b=a+4|0;e=d-b|0;g=e>>2;if(!g)h=d;else{im(a|0,b|0,e|0)|0;h=f[c>>2]|0}e=a+(g<<2)|0;if((h|0)==(e|0))return;f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);return}function zk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a+32>>2]|0;c=f[a+36>>2]|0;if((b|0)==(c|0)){d=1;return d|0}e=a+8|0;g=a+44|0;a=b;while(1){b=f[(f[e>>2]|0)+(f[a>>2]<<2)>>2]|0;a=a+4|0;if(!(Ra[f[(f[b>>2]|0)+20>>2]&127](b,f[g>>2]|0)|0)){d=0;h=5;break}if((a|0)==(c|0)){d=1;h=5;break}}if((h|0)==5)return d|0;return 0}function Ak(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function Bk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;d=u;u=u+128|0;e=d;g=e;h=g+124|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(h|0));g=e+4|0;f[g>>2]=a;h=e+8|0;f[h>>2]=-1;f[e+44>>2]=a;f[e+76>>2]=-1;Ym(e,0);i=+Rc(e,c,1);c=(f[g>>2]|0)-(f[h>>2]|0)+(f[e+108>>2]|0)|0;if(b|0)f[b>>2]=c|0?a+c|0:a;u=d;return +i}function Ck(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0;a=c+16|0;g=f[a>>2]|0;do if(g){if((g|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;f[c+24>>2]=2;b[c+54>>0]=1;break}h=c+24|0;if((f[h>>2]|0)==2)f[h>>2]=e}else{f[a>>2]=d;f[c+24>>2]=e;f[c+36>>2]=1}while(0);return}function Dk(a){a=a|0;var b=0,c=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Ek(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=a+20|0;c=a+28|0;if((f[d>>2]|0)>>>0>(f[c>>2]|0)>>>0)Sa[f[a+36>>2]&31](a,0,0)|0;f[a+16>>2]=0;f[c>>2]=0;f[d>>2]=0;d=f[a>>2]|0;if(!(d&4)){c=(f[a+44>>2]|0)+(f[a+48>>2]|0)|0;f[a+8>>2]=c;f[a+4>>2]=c;e=d<<27>>31}else{f[a>>2]=d|32;e=-1}return e|0}function Fk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=0;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=((Sj(g)|0)+1|0)>>>0>1;return e|0}function Gk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);Oq(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);Oq(a);return}function Hk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return g|0}d=e+28|0;if((b[d+11>>0]|0)<0)h=f[d>>2]|0;else h=d;g=Sj(h)|0;return g|0}function Ik(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;g=d>>31|((d|0)<0?-1:0)<<1;h=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;i=Xn(e^a|0,f^b|0,e|0,f|0)|0;b=I;a=g^e;e=h^f;return Xn((Ld(i,b,Xn(g^c|0,h^d|0,g|0,h|0)|0,I,0)|0)^a|0,I^e|0,a|0,e|0)|0}function Jk(a){a=a|0;var b=0,c=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Kk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;f[a>>2]=b;h=b+16|0;i=f[h+4>>2]|0;j=a+8|0;f[j>>2]=f[h>>2];f[j+4>>2]=i;i=b+24|0;b=f[i+4>>2]|0;j=a+16|0;f[j>>2]=f[i>>2];f[j+4>>2]=b;b=a+40|0;f[b>>2]=c;f[b+4>>2]=d;d=a+48|0;f[d>>2]=e;f[d+4>>2]=g;return}function Lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;h=e;e=d;if(g>>>0>=b>>>0){if(g>>>0>b>>>0?(d=h+b|0,(d|0)!=(e|0)):0)f[c>>2]=d}else Fi(a,b-g|0);g=a+24|0;a=g;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=g;f[a>>2]=b;f[a+4>>2]=I;return}function Mk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=-1;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=Sj(g)|0;return e|0}function Nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);return}function Ok(a){a=a|0;var c=0,d=0,e=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=1;c=a+68|0;d=a+28|0;e=d+40|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(e|0));f[c>>2]=a;c=a+72|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;return}function Pk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Qk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=u;u=u+256|0;g=f;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;sj(g|0,b<<24>>24|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;d=e;do{Xo(a,g,256);d=d+-256|0}while(d>>>0>255);h=b&255}else h=e;Xo(a,g,h)}u=f;return}function Rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Sk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);else{h=f[a+8>>2]|0;_a[f[(f[h>>2]|0)+20>>2]&3](h,b,c,d,e,g)}return}function Tk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Uk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Vk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;a:do if(!d)e=0;else{f=a;g=d;h=c;while(1){i=b[f>>0]|0;j=b[h>>0]|0;if(i<<24>>24!=j<<24>>24)break;g=g+-1|0;if(!g){e=0;break a}else{f=f+1|0;h=h+1|0}}e=(i&255)-(j&255)|0}while(0);return e|0}function Wk(a){a=a|0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function Xk(a){a=a|0;var b=0,c=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Yk(a){a=a|0;var c=0,d=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;c=0;while(1){if((c|0)==3)break;f[a+(c<<2)>>2]=0;c=c+1|0}if((b[a+11>>0]|0)<0)d=(f[a+8>>2]&2147483647)+-1|0;else d=10;Hj(a,d,0);return}function Zk(a){a=a|0;var b=0,c=0,d=0,e=0.0,g=0.0;b=f[a+8>>2]|0;if((b|0)<2){c=0;d=0;I=c;return d|0}e=+(b|0);g=+Zg(e)*e;e=+W(+(g-+p[a>>3]));c=+K(e)>=1.0?(e>0.0?~~+Y(+J(e/4294967296.0),4294967295.0)>>>0:~~+W((e-+(~~e>>>0))/4294967296.0)>>>0):0;d=~~e>>>0;I=c;return d|0}function _k(a){a=a|0;var b=0,c=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function $k(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;e=f[b+32>>2]|0;if(e|0){d=e;return d|0}d=f[b+8>>2]|0;return d|0}function al(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1232;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+4>>2]|0;if(!b)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(b|0))f[d>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function bl(a){a=a|0;var b=0,c=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function cl(a){a=a|0;if(!(f[a+64>>2]|0))return 0;if(!(f[a+68>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function dl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);else{e=f[a+8>>2]|0;Ya[f[(f[e>>2]|0)+28>>2]&3](e,b,c,d)}return}function el(a){a=a|0;var b=0,c=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function fl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+36>>2]&127](d,b)|0;return c|0}function gl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+32>>2]&127](d,b)|0;return c|0}function hl(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0;d=b[a>>0]|0;e=b[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24){f=e;g=d}else{d=c;c=a;do{c=c+1|0;d=d+1|0;a=b[c>>0]|0;e=b[d>>0]|0}while(!(a<<24>>24==0?1:a<<24>>24!=e<<24>>24));f=e;g=a}return (g&255)-(f&255)|0}function il(a,b){a=a|0;b=$(b);var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ei(a,d,b);Bo(d);u=c;return}function jl(a){a=a|0;var b=0,c=0,d=0,e=0,g=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d+(~((d+-4-b|0)>>>2)<<2)|0;f[c>>2]=g;e=g}f[a+12>>2]=0;f[a+16>>2]=0;if(!b)return;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b);return}function kl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=f[a+16>>2]|0;if(((f[a+20>>2]|0)-d>>2|0)<=(b|0)){e=-1;return e|0}g=f[d+(b<<2)>>2]|0;if((g|0)<0){e=-1;return e|0}e=f[(f[(f[(f[a+36>>2]|0)+(g<<2)>>2]|0)+16>>2]|0)+(c<<2)>>2]|0;return e|0}function ll(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ji(a,d,b);Bo(d);u=c;return}function ml(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;d=u;u=u+32|0;e=d;g=d+20|0;f[e>>2]=f[a+60>>2];f[e+4>>2]=0;f[e+8>>2]=b;f[e+12>>2]=g;f[e+16>>2]=c;if((to(za(140,e|0)|0)|0)<0){f[g>>2]=-1;h=-1}else h=f[g>>2]|0;u=d;return h|0}function nl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=0;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=0;return c|0}b=f[d>>2]|0;if((b|0)==-1){c=0;return c|0}c=f[(f[a+8>>2]|0)+(b<<2)>>2]|0;return c|0}function ol(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;d=(f[b+20>>2]|0)-(f[b+16>>2]|0)>>2;return d|0}function pl(a){a=a|0;if(!(f[a+40>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function ql(a){a=a|0;var b=0;if(!(f[a+24>>2]|0)){b=0;return b|0}if(!(f[a+28>>2]|0)){b=0;return b|0}if(!(f[a+32>>2]|0)){b=0;return b|0}b=(f[a+36>>2]|0)!=0;return b|0}function rl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;lh(a,c);f[a>>2]=1408;c=a+72|0;d=a+36|0;a=d+36|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(a|0));d=f[b>>2]|0;f[b>>2]=0;f[c>>2]=d;return}function sl(a){a=a|0;var b=0,c=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function tl(a,c){a=a|0;c=c|0;var d=0,e=0;d=a;e=c;c=d+64|0;do{f[d>>2]=f[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(c|0));e=a+64|0;f[a+88>>2]=0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[e+12>>2]=0;f[e+16>>2]=0;b[e+20>>0]=0;return}function ul(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if((a|0)==0&(c|0)==0)f=d;else{g=d;d=c;c=a;while(1){a=g+-1|0;b[a>>0]=h[16636+(c&15)>>0]|0|e;c=Yn(c|0,d|0,4)|0;d=I;if((c|0)==0&(d|0)==0){f=a;break}else g=a}}return f|0}function vl(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=f[a>>2]|0;if(!(d&8)){f[a+8>>2]=0;f[a+4>>2]=0;c=f[a+44>>2]|0;f[a+28>>2]=c;f[a+20>>2]=c;f[a+16>>2]=c+(f[a+48>>2]|0);e=0}else{f[a>>2]=d|32;e=-1}return e|0}function wl(a){a=a|0;if(!(f[a+60>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function xl(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[b+88>>2]|0;if(!c){d=0;return d|0}if((f[c>>2]|0)!=2){d=0;return d|0}b=f[c+8>>2]|0;f[a+4>>2]=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;d=1;return d|0}function yl(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}b=(f[a+56>>2]|0)!=0;return b|0}function zl(a){a=a|0;vj(a);Oq(a);return}function Al(a){a=a|0;var b=0,c=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function Bl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+44>>2]=c;d=1;return d|0}function Cl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;if(g>>>0>>0){Fi(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+b|0;if((g|0)==(d|0))return;f[c>>2]=g;return}function Dl(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=$(e);f[a+4>>2]=b;Zf(a+8|0,c,c+(d<<2)|0);n[a+20>>2]=e;return}function El(a,b){a=a|0;b=b|0;var c=0;if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){c=0;return c|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){c=0;return c|0}c=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return c|0}function Fl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+40>>2]=c;d=1;return d|0}function Gl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=u;u=u+16|0;d=c+4|0;e=c;f[e>>2]=0;f[d>>2]=f[e>>2];e=vc(a,b,d)|0;u=c;return e|0}function Hl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;d=f[c>>2]|0;c=a;e=b-a>>2;while(1){if(!e)break;a=(e|0)/2|0;b=c+(a<<2)|0;g=(f[b>>2]|0)>>>0>>0;c=g?b+4|0:c;e=g?e+-1-a|0:a}return c|0}function Il(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;b[a+24>>0]=1;f[a+28>>2]=9;c=a+40|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[a+56>>2]=-1;f[a+60>>2]=0;return}function Jl(a){a=a|0;yj(a);Oq(a);return}function Kl(a){a=a|0;var b=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Ll(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;if(!(Aq(b[f[a>>2]>>0]|0)|0))c=0;else{d=0;while(1){e=f[a>>2]|0;g=(d*10|0)+-48+(b[e>>0]|0)|0;h=e+1|0;f[a>>2]=h;if(!(Aq(b[h>>0]|0)|0)){c=g;break}else d=g}}return c|0}function Ml(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+64>>2]=c;d=1;return d|0}function Nl(a){a=a|0;var b=0,c=0;b=f[r>>2]|0;c=b+a|0;if((a|0)>0&(c|0)<(b|0)|(c|0)<0){ea()|0;ya(12);return -1}f[r>>2]=c;if((c|0)>(da()|0)?(ca()|0)==0:0){f[r>>2]=b;ya(12);return -1}return b|0}function Ol(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;if((a|0)==0&(c|0)==0)e=d;else{f=d;d=c;c=a;while(1){a=f+-1|0;b[a>>0]=c&7|48;c=Yn(c|0,d|0,3)|0;d=I;if((c|0)==0&(d|0)==0){e=a;break}else f=a}}return e|0}function Pl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+60>>2]=c;d=1;return d|0}function Ql(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Rl(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);return}function Sl(a){a=a|0;var b=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Tl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+56>>2]|0)-(f[e+52>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Ul(a){a=a|0;Vi(a);Oq(a);return}function Vl(a){a=a|0;var b=0;switch(a|0){case 11:case 2:case 1:{b=1;break}case 4:case 3:{b=2;break}case 6:case 5:{b=4;break}case 8:case 7:{b=8;break}case 9:{b=4;break}case 10:{b=8;break}default:b=-1}return b|0}function Wl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+28>>2]|0)-(f[e+24>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Xl(){var a=0,b=0;a=ln(40)|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[a+16>>2]=$(1.0);b=a+20|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;n[a+36>>2]=$(1.0);return a|0}function Yl(a,b){a=+a;b=+b;var c=0,d=0,e=0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s+4>>2]&-2147483648|d&2147483647;f[s>>2]=c;f[s+4>>2]=e;return +(+p[s>>3])}function Zl(a,b,c){a=a|0;b=b|0;c=+c;var d=0,e=0;d=u;u=u+16|0;e=d;p[e>>3]=c;_b(a,b,e);u=d;return}function _l(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);Oq(a);return}function $l(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;f[e>>2]=c;fc(a,b,e);u=d;return}function am(a,c){a=a|0;c=c|0;var d=0,e=0;if((a|0)!=(c|0)){d=b[c+11>>0]|0;e=d<<24>>24<0;jj(a,e?f[c>>2]|0:c,e?f[c+4>>2]|0:d&255)|0}return a|0}function bm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=X(d,c)|0;f=a>>>16;a=(e>>>16)+(X(d,f)|0)|0;d=b>>>16;b=X(d,c)|0;return (I=(a>>>16)+(X(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function cm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=Gj(b)|0;d=ln(c+13|0)|0;f[d>>2]=c;f[d+4>>2]=c;f[d+8>>2]=0;e=Fp(d)|0;kh(e|0,b|0,c+1|0)|0;f[a>>2]=e;return}function dm(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=-1;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=-1;return c|0}c=f[d>>2]|0;return c|0}function em(a){a=a|0;Yi(a);Oq(a);return}function fm(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);return}function gm(a){a=a|0;var b=0,c=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function hm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);return}function im(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else kh(a,c,d)|0;return a|0}function jm(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b){Oq(a);return}c=a+12|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function km(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function lm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=u;u=u+16|0;e=d;f[e>>2]=f[c>>2];g=Sa[f[(f[a>>2]|0)+16>>2]&31](a,b,e)|0;if(g)f[c>>2]=f[e>>2];u=d;return g&1|0}function mm(a,b){a=a|0;b=b|0;var c=0;if(b>>>0>=2){c=0;return c|0}f[a+28>>2]=b;c=1;return c|0}function nm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){mj(a);return}Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);return}function om(){var a=0,b=0;a=sn()|0;if((a|0?(b=f[a>>2]|0,b|0):0)?(a=b+48|0,(f[a>>2]&-256|0)==1126902528?(f[a+4>>2]|0)==1129074247:0):0)Ho(f[b+12>>2]|0);Ho(Qp()|0)}function pm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,6)|0}function qm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,4)|0}function rm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,2)|0}function sm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,3)|0}function tm(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function um(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,1)|0}function vm(a){a=a|0;var c=0;c=b[w+(a&255)>>0]|0;if((c|0)<8)return c|0;c=b[w+(a>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=b[w+(a>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (b[w+(a>>>24)>>0]|0)+24|0}function wm(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0;if(!a){c=0.0;return +c}if((b|0)==0|(a|0)==(b|0)){c=0.0;return +c}d=+(b>>>0)/+(a>>>0);e=1.0-d;f=d*+Zg(d);c=-(f+e*+Zg(e));return +c}function xm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b|0)>0)d=0;else return;do{e=f[a+(d<<2)>>2]|0;f[c+(d<<2)>>2]=e<<1^e>>31;d=d+1|0}while((d|0)!=(b|0));return}function ym(a){a=a|0;var b=0;zo(a);f[a>>2]=3344;f[a+40>>2]=1196;f[a+44>>2]=-1;b=a+48|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zm(a,c){a=a|0;c=c|0;var d=0;b[c+84>>0]=1;a=f[c+68>>2]|0;d=c+72|0;c=f[d>>2]|0;if((c|0)==(a|0))return 1;f[d>>2]=c+(~((c+-4-a|0)>>>2)<<2);return 1}function Am(a){a=a|0;var b=0,c=0;if(pq(a)|0?(b=Mp(f[a>>2]|0)|0,a=b+8|0,c=f[a>>2]|0,f[a>>2]=c+-1,(c+-1|0)<0):0)Oq(b);return}function Bm(a){a=a|0;var b=0,c=0;b=f[a+16>>2]|0;c=(((f[a+12>>2]|0)+1-b|0)/64|0)+b<<3;a=b<<3;b=Vn(c|0,((c|0)<0)<<31>>31|0,a|0,((a|0)<0)<<31>>31|0)|0;return b|0}function Cm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,5)|0}function Dm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,9)|0}function Em(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Fm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);Oq(a);return}function Gm(a){a=a|0;var b=0,c=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b)return;c=a+12|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Hm(a){a=a|0;var c=0;f[a>>2]=1352;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=-1;c=a+16|0;f[a+32>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;b[c+12>>0]=0;return}function Im(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Jm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);return}function Km(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Fg(a,b,c,d,e,f);return}function Lm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);Oq(a);return}function Mm(a){a=a|0;var b=0,c=0,d=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);f[a+12>>2]=0;f[a+16>>2]=0;return}function Nm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=a+20|0;e=f[d>>2]|0;g=(f[a+16>>2]|0)-e|0;a=g>>>0>c>>>0?c:g;kh(e|0,b|0,a|0)|0;f[d>>2]=(f[d>>2]|0)+a;return c|0}function Om(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Pm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-8-b|0)>>>3)<<3);Oq(b);return}function Qm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Rm(a,b){a=a|0;b=b|0;var c=0;c=f[b>>2]|0;return (1<<(c&31)&f[(f[a+28>>2]|0)+(c>>>5<<2)>>2]|0)!=0|0}function Sm(a,b,c){a=a|0;b=b|0;c=c|0;return Sa[f[(f[a>>2]|0)+44>>2]&31](a,b,c)|0}function Tm(a){a=a|0;var c=0;Il(a);c=a+64|0;f[a+88>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;b[c+20>>0]=0;return}function Um(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);Oq(a);return}function Vm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((f[b+4>>2]|0)==(c|0)?(c=b+28|0,(f[c>>2]|0)!=1):0)f[c>>2]=d;return}function Wm(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;if((Ek(a)|0)==0?(Sa[f[a+32>>2]&31](a,c,1)|0)==1:0)d=h[c>>0]|0;else d=-1;u=b;return d|0}function Xm(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Ym(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;f[a+104>>2]=b;c=f[a+8>>2]|0;d=f[a+4>>2]|0;e=c-d|0;f[a+108>>2]=e;f[a+100>>2]=(b|0)!=0&(e|0)>(b|0)?d+b|0:c;return}function Zm(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;return}function _m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Km(a,b,c,d,e,f);return}function $m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return pm(a,b,c,d,e,f)|0}function an(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return qm(a,b,c,d,e,f)|0}function bn(a,b,c){a=a|0;b=b|0;c=c|0;f[a+4>>2]=b;f[a+8>>2]=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2];f[a+12>>2]=c;return 1}function cn(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;Oq(b)}Oq(a);return}function dn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);Oq(a);return}function en(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return rm(a,b,c,d,e,f)|0}function fn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return sm(a,b,c,d,e,f)|0}function gn(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);return}function hn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e|0;Ld(a,b,c,d,g)|0;u=e;return (I=f[g+4>>2]|0,f[g>>2]|0)|0}function jn(a){a=a|0;var b=0;eo(a);f[a>>2]=6152;b=a+84|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function kn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return um(a,b,c,d,e,f)|0}function ln(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=$a(b)|0;if(a|0){c=a;break}a=Op()|0;if(!a){c=0;break}Ua[a&3]()}return c|0}function mn(a,b,c){a=a|0;b=b|0;c=c|0;ac(a,b,c);return}function nn(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function on(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Cm(a,b,c,d,e,f)|0}function pn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Dm(a,b,c,d,e,f)|0}function qn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);return}function rn(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;d=Qq(f[a+60>>2]|0)|0;f[c>>2]=d;d=to(Ba(6,c|0)|0)|0;u=b;return d|0}function sn(){var a=0,b=0;a=u;u=u+16|0;if(!(Ka(19700,3)|0)){b=Ia(f[4926]|0)|0;u=a;return b|0}else Hn(18840,a);return 0}function tn(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function un(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=bm(e,a)|0;f=I;return (I=(X(b,a)|0)+(X(d,e)|0)+f|f&0,c|0|0)|0}function vn(a,b){a=a|0;b=b|0;lh(a,b);f[a>>2]=1292;b=a+36|0;a=b+40|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function wn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;f[a+24>>2]=0;f[a+28>>2]=0;return}function xn(a){a=a|0;var b=0;b=u;u=u+16|0;yc(a);if(!(La(f[4926]|0,0)|0)){u=b;return}else Hn(18939,b)}function yn(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zn(a,b){a=a|0;b=b|0;return vg(a+40|0,b)|0}function An(a,b){a=a|0;b=b|0;return lj(a,b,lq(b)|0)|0}function Bn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;f[g>>2]=d;d=Zi(a,b,c,g)|0;u=e;return d|0}function Cn(a,b){a=a|0;b=b|0;return Mj(a+40|0,b)|0}function Dn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qh(a,b,c,d)|0}function En(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return uh(a,b,c,d)|0}function Fn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+24>>2]&127](c,b)|0}function Gn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=0;return}function Hn(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=f[1556]|0;Ah(b,a,d)|0;Lj(10,b)|0;Ca()}function In(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Ta[a&31](b|0,c|0,d|0,e|0,f|0,g|0)|0}function Jn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+16>>2]&127](c,b)|0}function Kn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+20>>2]&127](c,b)|0}function Ln(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+12>>2]&127](c,b)|0}function Mn(){var a=0;a=u;u=u+16|0;if(!(Ja(19704,113)|0)){u=a;return}else Hn(18889,a)}function Nn(a,b,c){a=a|0;b=b|0;c=c|0;Pj(a,b,c);return}function On(a){a=a|0;cf(a);Oq(a);return}function Pn(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;_a[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Qn(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)sj(a|0,(kq(c)|0)&255|0,b|0)|0;return a|0}function Rn(a){a=a|0;return 4}function Sn(a,b,c){a=a|0;b=b|0;c=c|0;return ej(0,b,c)|0}function Tn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b<>>32-c;return a<>>0;return (I=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function Wn(a,b){a=a|0;b=b|0;var c=0;if(!b)c=0;else c=Dh(f[b>>2]|0,f[b+4>>2]|0,a)|0;return (c|0?c:a)|0}function Xn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=b-d>>>0;e=b-d-(c>>>0>a>>>0|0)>>>0;return (I=e,a-c>>>0|0)|0}function Yn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b>>>c;return a>>>c|(b&(1<>>c-32|0}function Zn(a){a=a|0;var b=0;f[a>>2]=3932;b=a+4|0;a=b+44|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function _n(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return De(a,b,c,d)|0}function $n(a){a=a|0;ff(a);Oq(a);return}function ao(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=0;return}function bo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return $i(a,b,c,d)|0}function co(a){a=a|0;return 5}function eo(a){a=a|0;var b=0;f[a>>2]=6192;b=a+4|0;a=b+80|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function fo(a){a=a|0;return 6}function go(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return aj(a,b,c,d)|0}function ho(a,b,c){a=a|0;b=b|0;c=c|0;f[a+28>>2]=b;f[a+32>>2]=c;return 1}function io(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=b;return}function jo(a,b,c){a=a|0;b=b|0;c=c|0;Nn(a,b,c);return}function ko(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+28>>2]&127](b)|0}function lo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,1);return}function mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,0);return}function no(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Xg(a,b,c,d)|0}function oo(a,b,c){a=a|0;b=b|0;c=c|0;return fi(a,b,c)|0}function po(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+32>>2]&127](b)|0}function qo(a,b,c){a=a|0;b=b|0;c=c|0;return ej(a,b,c)|0}function ro(a,b,c){a=a|0;b=b|0;c=c|0;return Sn(a,b,c)|0}function so(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Za[a&3](b|0,c|0,d|0,e|0,f|0)}function to(a){a=a|0;var b=0,c=0;if(a>>>0>4294963200){b=Vq()|0;f[b>>2]=0-a;c=-1}else c=a;return c|0}function uo(a,b,c){a=a|0;b=b|0;c=c|0;Li(a,b,c);return}function vo(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;return}function wo(a,b){a=a|0;b=b|0;f[a+8>>2]=b;f[a+12>>2]=-1;return 1}function xo(a,b){a=a|0;b=b|0;f[a+52>>2]=b;ip(a,b);return}function yo(a){a=+a;var b=0;p[s>>3]=a;b=f[s>>2]|0;I=f[s+4>>2]|0;return b|0}function zo(a){a=a|0;Hm(a);f[a>>2]=1476;f[a+36>>2]=0;return}function Ao(a){a=a|0;var b=0;if(!a)b=0;else b=(Eh(a,1056,1144,0)|0)!=0&1;return b|0}function Bo(a){a=a|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);return}function Co(a){a=a|0;if(!a)return;Va[f[(f[a>>2]|0)+4>>2]&127](a);return}function Do(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Ya[a&3](b|0,c|0,d|0,e|0)}function Eo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)im(a|0,b|0,c|0)|0;return a|0}function Fo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)kh(a|0,b|0,c|0)|0;return a|0}function Go(a,b){a=a|0;b=b|0;return -1}function Ho(a){a=a|0;var b=0;b=u;u=u+16|0;Ua[a&3]();Hn(18992,b)}function Io(a){a=a|0;Lh(a);Oq(a);return}function Jo(a,b,c){a=a|0;b=b|0;c=c|0;Ro(a,b,c);return}function Ko(a,b,c){a=a|0;b=$(b);c=c|0;f[a+4>>2]=c;n[a>>2]=b;return}function Lo(a){a=a|0;To(a);f[a>>2]=3408;f[a+56>>2]=0;return}function Mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Sa[a&31](b|0,c|0,d|0)|0}function No(a,b){a=a|0;b=b|0;return (wp(a,b)|0)<<24>>24|0}function Oo(a,b){a=a|0;b=b|0;f[a>>2]=7236;cm(a+4|0,b);return}function Po(a,b){a=a|0;b=b|0;var c=0;if(!a)c=0;else c=Pi(a,b,0)|0;return c|0}function Qo(a){a=a|0;return f[a+12>>2]|0}function Ro(a,b,c){a=a|0;b=b|0;c=c|0;uo(a,b,c);return}function So(){var a=0;a=ln(64)|0;Il(a);return a|0}function To(a){a=a|0;Zn(a);f[a>>2]=3764;f[a+52>>2]=0;return}function Uo(a){a=a|0;if(!a)return;bj(a);Oq(a);return}function Vo(a){a=a|0;return Qa[f[(f[a>>2]|0)+60>>2]&127](a)|0}function Wo(a){a=a|0;return f[a+4>>2]|0}function Xo(a,b,c){a=a|0;b=b|0;c=c|0;if(!(f[a>>2]&32))qi(b,c,a)|0;return}function Yo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Xa[a&15](b|0,c|0,d|0)}function Zo(){var a=0;a=ln(96)|0;Tm(a);return a|0}function _o(a){a=a|0;var b=0;b=u;u=u+a|0;u=u+15&-16;return b|0}function $o(a){a=a|0;var b=0;b=(Jq()|0)+188|0;return $j(a,f[b>>2]|0)|0}function ap(a){a=a|0;return ((f[a+100>>2]|0)-(f[a+96>>2]|0)|0)/12|0|0}function bp(a,b){a=a|0;b=b|0;kp(a,b);return}function cp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(3);return 0}function dp(){var a=0;a=ln(12)|0;op(a);return a|0}function ep(a){a=a|0;Ni(a);Oq(a);return}function fp(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function gp(a,b){a=a|0;b=b|0;var c=0;c=sp(a|0)|0;return ((b|0)==0?a:c)|0}function hp(a){a=a|0;return (f[a+12>>2]|0)-(f[a+8>>2]|0)>>2|0}function ip(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return}function jp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ld(a,b,c,d,0)|0}function kp(a,b){a=a|0;b=b|0;jk(a,b);return}function lp(a){a=a|0;f[a+4>>2]=0;f[a+8>>2]=0;f[a>>2]=a+4;return}function mp(){var a=0;a=ln(84)|0;eo(a);return a|0}function np(a){a=a|0;ui(a);Oq(a);return}function op(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;return}function pp(a){a=a|0;f[a>>2]=7236;Am(a+4|0);return}function qp(a,b,c){a=a|0;b=b|0;c=c|0;return Ra[a&127](b|0,c|0)|0}function rp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(10)}function sp(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function tp(a){a=a|0;To(a);f[a>>2]=3836;return}function up(a,c){a=a|0;c=c|0;b[a>>0]=b[c>>0]|0;return}function vp(a,b,c){a=a|0;b=b|0;c=c|0;return -1}function wp(a,c){a=a|0;c=c|0;return b[(f[a>>2]|0)+c>>0]|0}function xp(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)|0}function yp(a){a=a|0;mj(a);Oq(a);return}function zp(a){a=a|0;if(!a)return;Oq(a);return}function Ap(a){a=a|0;n[a>>2]=$(1.0);f[a+4>>2]=1;return}function Bp(a){a=a|0;b[a+28>>0]=1;return}function Cp(a,b){a=a|0;b=b|0;if(!x){x=a;y=b}}function Dp(a){a=a|0;ji(a);return}function Ep(a,b){a=a|0;b=b|0;return 1}function Fp(a){a=a|0;return a+12|0}function Gp(a,b){a=a|0;b=b|0;f[a+80>>2]=b;return}function Hp(a,b,c){a=a|0;b=b|0;c=c|0;Wa[a&7](b|0,c|0)}function Ip(){var a=0;a=ln(36)|0;qq(a);return a|0}function Jp(a){a=a|0;return gq(a+4|0)|0}function Kp(){var a=0;a=ln(108)|0;jn(a);return a|0}function Lp(a){a=a|0;return (b[a+32>>0]|0)!=0|0}function Mp(a){a=a|0;return a+-12|0}function Np(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(9)}function Op(){var a=0;a=f[4927]|0;f[4927]=a+0;return a|0}function Pp(a){a=a|0;return f[a+56>>2]|0}function Qp(){var a=0;a=f[1786]|0;f[1786]=a+0;return a|0}function Rp(a){a=a|0;Og(a);Oq(a);return}function Sp(a){a=a|0;Sq(a);Oq(a);return}function Tp(a){a=a|0;return b[a+24>>0]|0}function Up(a,b){a=a|0;b=b|0;return 0}function Vp(a){a=a|0;return f[a+40>>2]|0}function Wp(a){a=a|0;return f[a+48>>2]|0}function Xp(a,b){a=a|0;b=b|0;return Qa[a&127](b|0)|0}function Yp(a){a=a|0;return f[a+60>>2]|0}function Zp(a){a=a|0;return f[a+28>>2]|0}function _p(a){a=a|0;sa(a|0)|0;om()}function $p(a){a=a|0;pp(a);Oq(a);return}function aq(a){a=a|0;Ca()}function bq(a,b){a=a|0;b=b|0;return $(+Bk(a,b,0))}function cq(a){a=a|0;return 3}function dq(a,b){a=a|0;b=b|0;u=a;v=b}function eq(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function fq(a){a=a|0;return f[a+80>>2]|0}function gq(a){a=a|0;return f[a>>2]|0}function hq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8)}function iq(a,b){a=a|0;b=b|0;Va[a&127](b|0)}function jq(a,b){a=a|0;b=b|0;return Wn(a,b)|0}function kq(a){a=a|0;return a&255|0}function lq(a){a=a|0;return Gj(a)|0}function mq(a,b){a=a|0;b=b|0;return +(+Bk(a,b,1))}function nq(a,b,c){a=a|0;b=b|0;c=c|0;aa(2);return 0}function oq(a){a=a|0;return 2}function pq(a){a=a|0;return 1}function qq(a){a=a|0;Dp(a);return}function rq(a,b){a=+a;b=+b;return +(+Yl(a,b))}function sq(a,b){a=+a;b=b|0;return +(+bk(a,b))}function tq(a,b){a=+a;b=b|0;return +(+ak(a,b))}function uq(){return 3}function vq(a,b,c){a=a|0;b=b|0;c=c|0;aa(7)}function wq(){return 0}function xq(){return -1}function yq(){return ln(1)|0}function zq(){return 4}function Aq(a){a=a|0;return (a+-48|0)>>>0<10|0}function Bq(){return 1}function Cq(){return 2}function Dq(a,b){a=+a;b=+b;return +(+xd(a,b))}function Eq(a,b){a=a|0;b=b|0;aa(1);return 0}function Fq(a){a=a|0;Ha()}function Gq(a){a=a|0;Ua[a&3]()}function Hq(){ua()}function Iq(a){a=a|0;return +(+mq(a,0))}function Jq(){return Yq()|0}function Kq(a,b){a=a|0;b=b|0;aa(6)}function Lq(a){a=a|0;return ln(a)|0}function Mq(a){a=a|0;Oq(a);return}function Nq(a){a=a|0;u=a}function Oq(a){a=a|0;yc(a);return}function Pq(a){a=a|0;I=a}function Qq(a){a=a|0;return a|0}function Rq(a){a=a|0;aa(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Array_size_0:xp,_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2:oo,_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3:En,_emscripten_bind_Encoder_Encoder_0:Ip,_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5:_m,_emscripten_bind_Encoder_SetAttributeQuantization_2:jo,_emscripten_bind_Encoder_SetEncodingMethod_1:bp,_emscripten_bind_Encoder_SetSpeedOptions_2:Jo,_emscripten_bind_Encoder___destroy___0:Wj,_emscripten_bind_GeometryAttribute_GeometryAttribute_0:So,_emscripten_bind_GeometryAttribute___destroy___0:zp,_emscripten_bind_MeshBuilder_AddFacesToMesh_3:no,_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5:pn,_emscripten_bind_MeshBuilder_AddFloatAttribute_5:pn,_emscripten_bind_MeshBuilder_AddInt16Attribute_5:fn,_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5:on,_emscripten_bind_MeshBuilder_AddInt32Attribute_5:on,_emscripten_bind_MeshBuilder_AddInt8Attribute_5:kn,_emscripten_bind_MeshBuilder_AddMetadataToMesh_2:ro,_emscripten_bind_MeshBuilder_AddMetadata_2:qo,_emscripten_bind_MeshBuilder_AddUInt16Attribute_5:an,_emscripten_bind_MeshBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_MeshBuilder_AddUInt8Attribute_5:en,_emscripten_bind_MeshBuilder_MeshBuilder_0:yq,_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_MeshBuilder___destroy___0:zp,_emscripten_bind_Mesh_Mesh_0:Kp,_emscripten_bind_Mesh___destroy___0:Co,_emscripten_bind_Mesh_num_attributes_0:hp,_emscripten_bind_Mesh_num_faces_0:ap,_emscripten_bind_Mesh_num_points_0:fq,_emscripten_bind_Mesh_set_num_points_1:Gp,_emscripten_bind_MetadataBuilder_AddDoubleEntry_3:bo,_emscripten_bind_MetadataBuilder_AddIntEntry_3:go,_emscripten_bind_MetadataBuilder_AddStringEntry_3:_n,_emscripten_bind_MetadataBuilder_MetadataBuilder_0:yq,_emscripten_bind_MetadataBuilder___destroy___0:zp,_emscripten_bind_Metadata_Metadata_0:Xl,_emscripten_bind_Metadata___destroy___0:Uo,_emscripten_bind_PointAttribute_PointAttribute_0:Zo,_emscripten_bind_PointAttribute___destroy___0:Ij,_emscripten_bind_PointAttribute_attribute_type_0:Pp,_emscripten_bind_PointAttribute_byte_offset_0:Wp,_emscripten_bind_PointAttribute_byte_stride_0:Vp,_emscripten_bind_PointAttribute_data_type_0:Zp,_emscripten_bind_PointAttribute_normalized_0:Lp,_emscripten_bind_PointAttribute_num_components_0:Tp,_emscripten_bind_PointAttribute_size_0:fq,_emscripten_bind_PointAttribute_unique_id_0:Yp,_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5:pn,_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5:fn,_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5:on,_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5:kn,_emscripten_bind_PointCloudBuilder_AddMetadata_2:qo,_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5:an,_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5:en,_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0:yq,_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_PointCloudBuilder___destroy___0:zp,_emscripten_bind_PointCloud_PointCloud_0:mp,_emscripten_bind_PointCloud___destroy___0:Co,_emscripten_bind_PointCloud_num_attributes_0:hp,_emscripten_bind_PointCloud_num_points_0:fq,_emscripten_bind_VoidPtr___destroy___0:zp,_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE:xq,_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD:wq,_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH:Bq,_emscripten_enum_draco_GeometryAttribute_Type_COLOR:Cq,_emscripten_enum_draco_GeometryAttribute_Type_GENERIC:zq,_emscripten_enum_draco_GeometryAttribute_Type_INVALID:xq,_emscripten_enum_draco_GeometryAttribute_Type_NORMAL:Bq,_emscripten_enum_draco_GeometryAttribute_Type_POSITION:wq,_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD:uq,_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING:Bq,_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING:wq,_emscripten_replace_memory:Pa,_free:yc,_i64Add:Vn,_i64Subtract:Xn,_llvm_bswap_i32:sp,_malloc:$a,_memcpy:kh,_memmove:im,_memset:sj,_sbrk:Nl,dynCall_ii:Xp,dynCall_iii:qp,dynCall_iiii:Mo,dynCall_iiiiiii:In,dynCall_v:Gq,dynCall_vi:iq,dynCall_vii:Hp,dynCall_viii:Yo,dynCall_viiii:Do,dynCall_viiiii:so,dynCall_viiiiii:Pn,establishStackSpace:dq,getTempRet0:Uq,runPostSets:Un,setTempRet0:Pq,setThrew:Cp,stackAlloc:_o,stackRestore:Nq,stackSave:Wq}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var ___divdi3=Module["___divdi3"]=asm["___divdi3"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_DracoInt8Array_DracoInt8Array_0=Module["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"]=asm["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"];var _emscripten_bind_DracoInt8Array_GetValue_1=Module["_emscripten_bind_DracoInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoInt8Array_GetValue_1"];var _emscripten_bind_DracoInt8Array___destroy___0=Module["_emscripten_bind_DracoInt8Array___destroy___0"]=asm["_emscripten_bind_DracoInt8Array___destroy___0"];var _emscripten_bind_DracoInt8Array_size_0=Module["_emscripten_bind_DracoInt8Array_size_0"]=asm["_emscripten_bind_DracoInt8Array_size_0"];var _emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2=Module["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"]=asm["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"];var _emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3=Module["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"]=asm["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"];var _emscripten_bind_Encoder_Encoder_0=Module["_emscripten_bind_Encoder_Encoder_0"]=asm["_emscripten_bind_Encoder_Encoder_0"];var _emscripten_bind_Encoder_SetAttributeExplicitQuantization_5=Module["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"]=asm["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"];var _emscripten_bind_Encoder_SetAttributeQuantization_2=Module["_emscripten_bind_Encoder_SetAttributeQuantization_2"]=asm["_emscripten_bind_Encoder_SetAttributeQuantization_2"];var _emscripten_bind_Encoder_SetEncodingMethod_1=Module["_emscripten_bind_Encoder_SetEncodingMethod_1"]=asm["_emscripten_bind_Encoder_SetEncodingMethod_1"];var _emscripten_bind_Encoder_SetSpeedOptions_2=Module["_emscripten_bind_Encoder_SetSpeedOptions_2"]=asm["_emscripten_bind_Encoder_SetSpeedOptions_2"];var _emscripten_bind_Encoder___destroy___0=Module["_emscripten_bind_Encoder___destroy___0"]=asm["_emscripten_bind_Encoder___destroy___0"];var _emscripten_bind_GeometryAttribute_GeometryAttribute_0=Module["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"]=asm["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"];var _emscripten_bind_GeometryAttribute___destroy___0=Module["_emscripten_bind_GeometryAttribute___destroy___0"]=asm["_emscripten_bind_GeometryAttribute___destroy___0"];var _emscripten_bind_MeshBuilder_AddFacesToMesh_3=Module["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"]=asm["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"];var _emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddFloatAttribute_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"];var _emscripten_bind_MeshBuilder_AddInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"];var _emscripten_bind_MeshBuilder_AddMetadataToMesh_2=Module["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"];var _emscripten_bind_MeshBuilder_AddMetadata_2=Module["_emscripten_bind_MeshBuilder_AddMetadata_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadata_2"];var _emscripten_bind_MeshBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"];var _emscripten_bind_MeshBuilder_MeshBuilder_0=Module["_emscripten_bind_MeshBuilder_MeshBuilder_0"]=asm["_emscripten_bind_MeshBuilder_MeshBuilder_0"];var _emscripten_bind_MeshBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_MeshBuilder___destroy___0=Module["_emscripten_bind_MeshBuilder___destroy___0"]=asm["_emscripten_bind_MeshBuilder___destroy___0"];var _emscripten_bind_Mesh_Mesh_0=Module["_emscripten_bind_Mesh_Mesh_0"]=asm["_emscripten_bind_Mesh_Mesh_0"];var _emscripten_bind_Mesh___destroy___0=Module["_emscripten_bind_Mesh___destroy___0"]=asm["_emscripten_bind_Mesh___destroy___0"];var _emscripten_bind_Mesh_num_attributes_0=Module["_emscripten_bind_Mesh_num_attributes_0"]=asm["_emscripten_bind_Mesh_num_attributes_0"];var _emscripten_bind_Mesh_num_faces_0=Module["_emscripten_bind_Mesh_num_faces_0"]=asm["_emscripten_bind_Mesh_num_faces_0"];var _emscripten_bind_Mesh_num_points_0=Module["_emscripten_bind_Mesh_num_points_0"]=asm["_emscripten_bind_Mesh_num_points_0"];var _emscripten_bind_Mesh_set_num_points_1=Module["_emscripten_bind_Mesh_set_num_points_1"]=asm["_emscripten_bind_Mesh_set_num_points_1"];var _emscripten_bind_MetadataBuilder_AddDoubleEntry_3=Module["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"];var _emscripten_bind_MetadataBuilder_AddIntEntry_3=Module["_emscripten_bind_MetadataBuilder_AddIntEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddIntEntry_3"];var _emscripten_bind_MetadataBuilder_AddStringEntry_3=Module["_emscripten_bind_MetadataBuilder_AddStringEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddStringEntry_3"];var _emscripten_bind_MetadataBuilder_MetadataBuilder_0=Module["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"]=asm["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"];var _emscripten_bind_MetadataBuilder___destroy___0=Module["_emscripten_bind_MetadataBuilder___destroy___0"]=asm["_emscripten_bind_MetadataBuilder___destroy___0"];var _emscripten_bind_Metadata_Metadata_0=Module["_emscripten_bind_Metadata_Metadata_0"]=asm["_emscripten_bind_Metadata_Metadata_0"];var _emscripten_bind_Metadata___destroy___0=Module["_emscripten_bind_Metadata___destroy___0"]=asm["_emscripten_bind_Metadata___destroy___0"];var _emscripten_bind_PointAttribute_PointAttribute_0=Module["_emscripten_bind_PointAttribute_PointAttribute_0"]=asm["_emscripten_bind_PointAttribute_PointAttribute_0"];var _emscripten_bind_PointAttribute___destroy___0=Module["_emscripten_bind_PointAttribute___destroy___0"]=asm["_emscripten_bind_PointAttribute___destroy___0"];var _emscripten_bind_PointAttribute_attribute_type_0=Module["_emscripten_bind_PointAttribute_attribute_type_0"]=asm["_emscripten_bind_PointAttribute_attribute_type_0"];var _emscripten_bind_PointAttribute_byte_offset_0=Module["_emscripten_bind_PointAttribute_byte_offset_0"]=asm["_emscripten_bind_PointAttribute_byte_offset_0"];var _emscripten_bind_PointAttribute_byte_stride_0=Module["_emscripten_bind_PointAttribute_byte_stride_0"]=asm["_emscripten_bind_PointAttribute_byte_stride_0"];var _emscripten_bind_PointAttribute_data_type_0=Module["_emscripten_bind_PointAttribute_data_type_0"]=asm["_emscripten_bind_PointAttribute_data_type_0"];var _emscripten_bind_PointAttribute_normalized_0=Module["_emscripten_bind_PointAttribute_normalized_0"]=asm["_emscripten_bind_PointAttribute_normalized_0"];var _emscripten_bind_PointAttribute_num_components_0=Module["_emscripten_bind_PointAttribute_num_components_0"]=asm["_emscripten_bind_PointAttribute_num_components_0"];var _emscripten_bind_PointAttribute_size_0=Module["_emscripten_bind_PointAttribute_size_0"]=asm["_emscripten_bind_PointAttribute_size_0"];var _emscripten_bind_PointAttribute_unique_id_0=Module["_emscripten_bind_PointAttribute_unique_id_0"]=asm["_emscripten_bind_PointAttribute_unique_id_0"];var _emscripten_bind_PointCloudBuilder_AddFloatAttribute_5=Module["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddMetadata_2=Module["_emscripten_bind_PointCloudBuilder_AddMetadata_2"]=asm["_emscripten_bind_PointCloudBuilder_AddMetadata_2"];var _emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_PointCloudBuilder_0=Module["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"]=asm["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"];var _emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_PointCloudBuilder___destroy___0=Module["_emscripten_bind_PointCloudBuilder___destroy___0"]=asm["_emscripten_bind_PointCloudBuilder___destroy___0"];var _emscripten_bind_PointCloud_PointCloud_0=Module["_emscripten_bind_PointCloud_PointCloud_0"]=asm["_emscripten_bind_PointCloud_PointCloud_0"];var _emscripten_bind_PointCloud___destroy___0=Module["_emscripten_bind_PointCloud___destroy___0"]=asm["_emscripten_bind_PointCloud___destroy___0"];var _emscripten_bind_PointCloud_num_attributes_0=Module["_emscripten_bind_PointCloud_num_attributes_0"]=asm["_emscripten_bind_PointCloud_num_attributes_0"];var _emscripten_bind_PointCloud_num_points_0=Module["_emscripten_bind_PointCloud_num_points_0"]=asm["_emscripten_bind_PointCloud_num_points_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Module["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"]=asm["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"];var _emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Module["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"]=asm["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"];var _emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Module["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"]=asm["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"];var _emscripten_enum_draco_GeometryAttribute_Type_COLOR=Module["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"];var _emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Module["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"];var _emscripten_enum_draco_GeometryAttribute_Type_INVALID=Module["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"];var _emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Module["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"];var _emscripten_enum_draco_GeometryAttribute_Type_POSITION=Module["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"];var _emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Module["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Module["asm"]=asm;if(memoryInitializer){if(!isDataURI(memoryInitializer)){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});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;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]&&status===0){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret}),copy:(function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;i=d);)++b;if(16k?d+=String.fromCharCode(k):(k-=65536,d+=String.fromCharCode(55296|k>>10,56320|k&1023))}}else d+=String.fromCharCode(k)}return d}function X(a,c){return a?h(ca,a,c):""}function e(a,c){0=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++b)&1023);127>=d?++c:c=2047>=d?c+2:65535>=d?c+3:c+4}c=Array(c+1);b=0;d=c.length;if(0=e){var f=a.charCodeAt(++k);e=65536+((e&1023)<<10)|f&1023}if(127>=e){if(b>=d)break;c[b++]=e}else{if(2047>=e){if(b+1>=d)break;c[b++]=192|e>>6}else{if(65535>=e){if(b+2>=d)break;c[b++]=224|e>>12}else{if(b+3>=d)break;c[b++]=240|e>>18;c[b++]=128|e>>12&63}c[b++]=128|e>>6&63}c[b++]=128| +e&63}}c[b]=0}a=n.alloc(c,T);n.copy(c,T,a)}return a}function x(){throw"cannot construct a Status, no constructor in IDL";}function A(){this.ptr=Oa();u(A)[this.ptr]=this}function B(){this.ptr=Pa();u(B)[this.ptr]=this}function C(){this.ptr=Qa();u(C)[this.ptr]=this}function D(){this.ptr=Ra();u(D)[this.ptr]=this}function E(){this.ptr=Sa();u(E)[this.ptr]=this}function q(){this.ptr=Ta();u(q)[this.ptr]=this}function J(){this.ptr=Ua();u(J)[this.ptr]=this}function w(){this.ptr=Va();u(w)[this.ptr]=this}function F(){this.ptr= +Wa();u(F)[this.ptr]=this}function r(){this.ptr=Xa();u(r)[this.ptr]=this}function G(){this.ptr=Ya();u(G)[this.ptr]=this}function H(){this.ptr=Za();u(H)[this.ptr]=this}function O(){this.ptr=$a();u(O)[this.ptr]=this}function K(){this.ptr=ab();u(K)[this.ptr]=this}function g(){this.ptr=bb();u(g)[this.ptr]=this}function y(){this.ptr=cb();u(y)[this.ptr]=this}function Q(){throw"cannot construct a VoidPtr, no constructor in IDL";}function I(){this.ptr=db();u(I)[this.ptr]=this}function L(){this.ptr=eb();u(L)[this.ptr]= +this}m=m||{};var a="undefined"!==typeof m?m:{},Ga=!1,Ha=!1;a.onRuntimeInitialized=function(){Ga=!0;if(Ha&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.onModuleParsed=function(){Ha=!0;if(Ga&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.isVersionSupported=function(a){if("string"!==typeof a)return!1;a=a.split(".");return 2>a.length||3=a[1]?!0:0!=a[0]||10>2]},getStr:function(){return X(R.get())}, +get64:function(){var a=R.get();R.get();return a},getZero:function(){R.get()}},Ka={__cxa_allocate_exception:function(a){return ib(a)},__cxa_throw:function(a,c,b){"uncaught_exception"in ta?ta.uncaught_exceptions++:ta.uncaught_exceptions=1;throw a;},abort:function(){z()},emscripten_get_sbrk_ptr:function(){return 13664},emscripten_memcpy_big:function(a,c,b){ca.set(ca.subarray(c,c+b),a)},emscripten_resize_heap:function(a){if(2147418112= +c?e(2*c,65536):Math.min(e((3*c+2147483648)/4,65536),2147418112);a:{try{ia.grow(c-ka.byteLength+65535>>16);l(ia.buffer);var b=1;break a}catch(d){}b=void 0}return b?!0:!1},environ_get:function(a,c){var b=0;ba().forEach(function(d,e){var f=c+b;e=P[a+4*e>>2]=f;for(f=0;f>0]=d.charCodeAt(f);T[e>>0]=0;b+=d.length+1});return 0},environ_sizes_get:function(a,c){var b=ba();P[a>>2]=b.length;var d=0;b.forEach(function(a){d+=a.length+1});P[c>>2]=d;return 0},fd_close:function(a){return 0},fd_seek:function(a, +c,b,d,e){return 0},fd_write:function(a,c,b,d){try{for(var e=0,f=0;f>2],k=P[c+(8*f+4)>>2],h=0;h>2]=e;return 0}catch(ua){return"undefined"!==typeof FS&&ua instanceof FS.ErrnoError||z(ua),ua.errno}},memory:ia,setTempRet0:function(a){},table:gb},La=function(){function e(c,b){a.asm=c.exports;aa--;a.monitorRunDependencies&&a.monitorRunDependencies(aa);0==aa&&(null!==sa&&(clearInterval(sa),sa=null),ja&&(c=ja,ja=null,c()))}function c(a){e(a.instance)} +function b(a){return Ma().then(function(a){return WebAssembly.instantiate(a,d)}).then(a,function(a){Y("failed to asynchronously prepare wasm: "+a);z(a)})}var d={env:Ka,wasi_unstable:Ka};aa++;a.monitorRunDependencies&&a.monitorRunDependencies(aa);if(a.instantiateWasm)try{return a.instantiateWasm(d,e)}catch(Na){return Y("Module.instantiateWasm callback failed with error: "+Na),!1}(function(){if(da||"function"!==typeof WebAssembly.instantiateStreaming||va(U)||"function"!==typeof fetch)return b(c);fetch(U, +{credentials:"same-origin"}).then(function(a){return WebAssembly.instantiateStreaming(a,d).then(c,function(a){Y("wasm streaming compile failed: "+a);Y("falling back to ArrayBuffer instantiation");b(c)})})})();return{}}();a.asm=La;var hb=a.___wasm_call_ctors=function(){return a.asm.__wasm_call_ctors.apply(null,arguments)},jb=a._emscripten_bind_Status_code_0=function(){return a.asm.emscripten_bind_Status_code_0.apply(null,arguments)},kb=a._emscripten_bind_Status_ok_0=function(){return a.asm.emscripten_bind_Status_ok_0.apply(null, +arguments)},lb=a._emscripten_bind_Status_error_msg_0=function(){return a.asm.emscripten_bind_Status_error_msg_0.apply(null,arguments)},mb=a._emscripten_bind_Status___destroy___0=function(){return a.asm.emscripten_bind_Status___destroy___0.apply(null,arguments)},Oa=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return a.asm.emscripten_bind_DracoUInt16Array_DracoUInt16Array_0.apply(null,arguments)},nb=a._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt16Array_GetValue_1.apply(null, +arguments)},ob=a._emscripten_bind_DracoUInt16Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt16Array_size_0.apply(null,arguments)},pb=a._emscripten_bind_DracoUInt16Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt16Array___destroy___0.apply(null,arguments)},Pa=a._emscripten_bind_PointCloud_PointCloud_0=function(){return a.asm.emscripten_bind_PointCloud_PointCloud_0.apply(null,arguments)},qb=a._emscripten_bind_PointCloud_num_attributes_0=function(){return a.asm.emscripten_bind_PointCloud_num_attributes_0.apply(null, +arguments)},rb=a._emscripten_bind_PointCloud_num_points_0=function(){return a.asm.emscripten_bind_PointCloud_num_points_0.apply(null,arguments)},sb=a._emscripten_bind_PointCloud___destroy___0=function(){return a.asm.emscripten_bind_PointCloud___destroy___0.apply(null,arguments)},Qa=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return a.asm.emscripten_bind_DracoUInt8Array_DracoUInt8Array_0.apply(null,arguments)},tb=a._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt8Array_GetValue_1.apply(null, +arguments)},ub=a._emscripten_bind_DracoUInt8Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt8Array_size_0.apply(null,arguments)},vb=a._emscripten_bind_DracoUInt8Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt8Array___destroy___0.apply(null,arguments)},Ra=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return a.asm.emscripten_bind_DracoUInt32Array_DracoUInt32Array_0.apply(null,arguments)},wb=a._emscripten_bind_DracoUInt32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt32Array_GetValue_1.apply(null, +arguments)},xb=a._emscripten_bind_DracoUInt32Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt32Array_size_0.apply(null,arguments)},yb=a._emscripten_bind_DracoUInt32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt32Array___destroy___0.apply(null,arguments)},Sa=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0.apply(null,arguments)},zb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1= +function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1.apply(null,arguments)},Ab=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_quantization_bits_0.apply(null,arguments)},Bb=a._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform___destroy___0.apply(null,arguments)},Ta=a._emscripten_bind_PointAttribute_PointAttribute_0= +function(){return a.asm.emscripten_bind_PointAttribute_PointAttribute_0.apply(null,arguments)},Cb=a._emscripten_bind_PointAttribute_size_0=function(){return a.asm.emscripten_bind_PointAttribute_size_0.apply(null,arguments)},Db=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=function(){return a.asm.emscripten_bind_PointAttribute_GetAttributeTransformData_0.apply(null,arguments)},Eb=a._emscripten_bind_PointAttribute_attribute_type_0=function(){return a.asm.emscripten_bind_PointAttribute_attribute_type_0.apply(null, +arguments)},Fb=a._emscripten_bind_PointAttribute_data_type_0=function(){return a.asm.emscripten_bind_PointAttribute_data_type_0.apply(null,arguments)},Gb=a._emscripten_bind_PointAttribute_num_components_0=function(){return a.asm.emscripten_bind_PointAttribute_num_components_0.apply(null,arguments)},Hb=a._emscripten_bind_PointAttribute_normalized_0=function(){return a.asm.emscripten_bind_PointAttribute_normalized_0.apply(null,arguments)},Ib=a._emscripten_bind_PointAttribute_byte_stride_0=function(){return a.asm.emscripten_bind_PointAttribute_byte_stride_0.apply(null, +arguments)},Jb=a._emscripten_bind_PointAttribute_byte_offset_0=function(){return a.asm.emscripten_bind_PointAttribute_byte_offset_0.apply(null,arguments)},Kb=a._emscripten_bind_PointAttribute_unique_id_0=function(){return a.asm.emscripten_bind_PointAttribute_unique_id_0.apply(null,arguments)},Lb=a._emscripten_bind_PointAttribute___destroy___0=function(){return a.asm.emscripten_bind_PointAttribute___destroy___0.apply(null,arguments)},Ua=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0= +function(){return a.asm.emscripten_bind_AttributeTransformData_AttributeTransformData_0.apply(null,arguments)},Mb=a._emscripten_bind_AttributeTransformData_transform_type_0=function(){return a.asm.emscripten_bind_AttributeTransformData_transform_type_0.apply(null,arguments)},Nb=a._emscripten_bind_AttributeTransformData___destroy___0=function(){return a.asm.emscripten_bind_AttributeTransformData___destroy___0.apply(null,arguments)},Va=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0= +function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0.apply(null,arguments)},Ob=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1.apply(null,arguments)},Pb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_quantization_bits_0.apply(null,arguments)}, +Qb=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_min_value_1.apply(null,arguments)},Rb=a._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_range_0.apply(null,arguments)},Sb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform___destroy___0.apply(null,arguments)}, +Wa=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return a.asm.emscripten_bind_DracoInt8Array_DracoInt8Array_0.apply(null,arguments)},Tb=a._emscripten_bind_DracoInt8Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoInt8Array_GetValue_1.apply(null,arguments)},Ub=a._emscripten_bind_DracoInt8Array_size_0=function(){return a.asm.emscripten_bind_DracoInt8Array_size_0.apply(null,arguments)},Vb=a._emscripten_bind_DracoInt8Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt8Array___destroy___0.apply(null, +arguments)},Xa=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return a.asm.emscripten_bind_MetadataQuerier_MetadataQuerier_0.apply(null,arguments)},Wb=a._emscripten_bind_MetadataQuerier_HasEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_HasEntry_2.apply(null,arguments)},Xb=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetIntEntry_2.apply(null,arguments)},Yb=a._emscripten_bind_MetadataQuerier_GetIntEntryArray_3= +function(){return a.asm.emscripten_bind_MetadataQuerier_GetIntEntryArray_3.apply(null,arguments)},Zb=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetDoubleEntry_2.apply(null,arguments)},$b=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetStringEntry_2.apply(null,arguments)},ac=a._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return a.asm.emscripten_bind_MetadataQuerier_NumEntries_1.apply(null, +arguments)},bc=a._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetEntryName_2.apply(null,arguments)},cc=a._emscripten_bind_MetadataQuerier___destroy___0=function(){return a.asm.emscripten_bind_MetadataQuerier___destroy___0.apply(null,arguments)},Ya=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return a.asm.emscripten_bind_DracoInt16Array_DracoInt16Array_0.apply(null,arguments)},dc=a._emscripten_bind_DracoInt16Array_GetValue_1= +function(){return a.asm.emscripten_bind_DracoInt16Array_GetValue_1.apply(null,arguments)},ec=a._emscripten_bind_DracoInt16Array_size_0=function(){return a.asm.emscripten_bind_DracoInt16Array_size_0.apply(null,arguments)},fc=a._emscripten_bind_DracoInt16Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt16Array___destroy___0.apply(null,arguments)},Za=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return a.asm.emscripten_bind_DracoFloat32Array_DracoFloat32Array_0.apply(null, +arguments)},gc=a._emscripten_bind_DracoFloat32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoFloat32Array_GetValue_1.apply(null,arguments)},hc=a._emscripten_bind_DracoFloat32Array_size_0=function(){return a.asm.emscripten_bind_DracoFloat32Array_size_0.apply(null,arguments)},ic=a._emscripten_bind_DracoFloat32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoFloat32Array___destroy___0.apply(null,arguments)},$a=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return a.asm.emscripten_bind_GeometryAttribute_GeometryAttribute_0.apply(null, +arguments)},jc=a._emscripten_bind_GeometryAttribute___destroy___0=function(){return a.asm.emscripten_bind_GeometryAttribute___destroy___0.apply(null,arguments)},ab=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=function(){return a.asm.emscripten_bind_DecoderBuffer_DecoderBuffer_0.apply(null,arguments)},kc=a._emscripten_bind_DecoderBuffer_Init_2=function(){return a.asm.emscripten_bind_DecoderBuffer_Init_2.apply(null,arguments)},lc=a._emscripten_bind_DecoderBuffer___destroy___0=function(){return a.asm.emscripten_bind_DecoderBuffer___destroy___0.apply(null, +arguments)},bb=a._emscripten_bind_Decoder_Decoder_0=function(){return a.asm.emscripten_bind_Decoder_Decoder_0.apply(null,arguments)},mc=a._emscripten_bind_Decoder_GetEncodedGeometryType_1=function(){return a.asm.emscripten_bind_Decoder_GetEncodedGeometryType_1.apply(null,arguments)},nc=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return a.asm.emscripten_bind_Decoder_DecodeBufferToPointCloud_2.apply(null,arguments)},oc=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return a.asm.emscripten_bind_Decoder_DecodeBufferToMesh_2.apply(null, +arguments)},pc=a._emscripten_bind_Decoder_GetAttributeId_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeId_2.apply(null,arguments)},qc=a._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIdByName_2.apply(null,arguments)},rc=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3.apply(null,arguments)},sc=a._emscripten_bind_Decoder_GetAttribute_2= +function(){return a.asm.emscripten_bind_Decoder_GetAttribute_2.apply(null,arguments)},tc=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeByUniqueId_2.apply(null,arguments)},uc=a._emscripten_bind_Decoder_GetMetadata_1=function(){return a.asm.emscripten_bind_Decoder_GetMetadata_1.apply(null,arguments)},vc=a._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeMetadata_2.apply(null, +arguments)},wc=a._emscripten_bind_Decoder_GetFaceFromMesh_3=function(){return a.asm.emscripten_bind_Decoder_GetFaceFromMesh_3.apply(null,arguments)},xc=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return a.asm.emscripten_bind_Decoder_GetTriangleStripsFromMesh_2.apply(null,arguments)},yc=a._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=function(){return a.asm.emscripten_bind_Decoder_GetTrianglesUInt16Array_3.apply(null,arguments)},zc=a._emscripten_bind_Decoder_GetTrianglesUInt32Array_3= +function(){return a.asm.emscripten_bind_Decoder_GetTrianglesUInt32Array_3.apply(null,arguments)},Ac=a._emscripten_bind_Decoder_GetAttributeFloat_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeFloat_3.apply(null,arguments)},Bc=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3.apply(null,arguments)},Cc=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIntForAllPoints_3.apply(null, +arguments)},Dc=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3.apply(null,arguments)},Ec=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3.apply(null,arguments)},Fc=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3.apply(null,arguments)}, +Gc=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3.apply(null,arguments)},Hc=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3.apply(null,arguments)},Ic=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3.apply(null,arguments)},Jc= +a._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=function(){return a.asm.emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5.apply(null,arguments)},Kc=a._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return a.asm.emscripten_bind_Decoder_SkipAttributeTransform_1.apply(null,arguments)},Lc=a._emscripten_bind_Decoder___destroy___0=function(){return a.asm.emscripten_bind_Decoder___destroy___0.apply(null,arguments)},cb=a._emscripten_bind_Mesh_Mesh_0=function(){return a.asm.emscripten_bind_Mesh_Mesh_0.apply(null, +arguments)},Mc=a._emscripten_bind_Mesh_num_faces_0=function(){return a.asm.emscripten_bind_Mesh_num_faces_0.apply(null,arguments)},Nc=a._emscripten_bind_Mesh_num_attributes_0=function(){return a.asm.emscripten_bind_Mesh_num_attributes_0.apply(null,arguments)},Oc=a._emscripten_bind_Mesh_num_points_0=function(){return a.asm.emscripten_bind_Mesh_num_points_0.apply(null,arguments)},Pc=a._emscripten_bind_Mesh___destroy___0=function(){return a.asm.emscripten_bind_Mesh___destroy___0.apply(null,arguments)}, +Qc=a._emscripten_bind_VoidPtr___destroy___0=function(){return a.asm.emscripten_bind_VoidPtr___destroy___0.apply(null,arguments)},db=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=function(){return a.asm.emscripten_bind_DracoInt32Array_DracoInt32Array_0.apply(null,arguments)},Rc=a._emscripten_bind_DracoInt32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoInt32Array_GetValue_1.apply(null,arguments)},Sc=a._emscripten_bind_DracoInt32Array_size_0=function(){return a.asm.emscripten_bind_DracoInt32Array_size_0.apply(null, +arguments)},Tc=a._emscripten_bind_DracoInt32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt32Array___destroy___0.apply(null,arguments)},eb=a._emscripten_bind_Metadata_Metadata_0=function(){return a.asm.emscripten_bind_Metadata_Metadata_0.apply(null,arguments)},Uc=a._emscripten_bind_Metadata___destroy___0=function(){return a.asm.emscripten_bind_Metadata___destroy___0.apply(null,arguments)},Vc=a._emscripten_enum_draco_StatusCode_OK=function(){return a.asm.emscripten_enum_draco_StatusCode_OK.apply(null, +arguments)},Wc=a._emscripten_enum_draco_StatusCode_DRACO_ERROR=function(){return a.asm.emscripten_enum_draco_StatusCode_DRACO_ERROR.apply(null,arguments)},Xc=a._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return a.asm.emscripten_enum_draco_StatusCode_IO_ERROR.apply(null,arguments)},Yc=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=function(){return a.asm.emscripten_enum_draco_StatusCode_INVALID_PARAMETER.apply(null,arguments)},Zc=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION= +function(){return a.asm.emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION.apply(null,arguments)},$c=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return a.asm.emscripten_enum_draco_StatusCode_UNKNOWN_VERSION.apply(null,arguments)},ad=a._emscripten_enum_draco_DataType_DT_INVALID=function(){return a.asm.emscripten_enum_draco_DataType_DT_INVALID.apply(null,arguments)},bd=a._emscripten_enum_draco_DataType_DT_INT8=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT8.apply(null, +arguments)},cd=a._emscripten_enum_draco_DataType_DT_UINT8=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT8.apply(null,arguments)},dd=a._emscripten_enum_draco_DataType_DT_INT16=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT16.apply(null,arguments)},ed=a._emscripten_enum_draco_DataType_DT_UINT16=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT16.apply(null,arguments)},fd=a._emscripten_enum_draco_DataType_DT_INT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT32.apply(null, +arguments)},gd=a._emscripten_enum_draco_DataType_DT_UINT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT32.apply(null,arguments)},hd=a._emscripten_enum_draco_DataType_DT_INT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT64.apply(null,arguments)},id=a._emscripten_enum_draco_DataType_DT_UINT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT64.apply(null,arguments)},jd=a._emscripten_enum_draco_DataType_DT_FLOAT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_FLOAT32.apply(null, +arguments)},kd=a._emscripten_enum_draco_DataType_DT_FLOAT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_FLOAT64.apply(null,arguments)},ld=a._emscripten_enum_draco_DataType_DT_BOOL=function(){return a.asm.emscripten_enum_draco_DataType_DT_BOOL.apply(null,arguments)},md=a._emscripten_enum_draco_DataType_DT_TYPES_COUNT=function(){return a.asm.emscripten_enum_draco_DataType_DT_TYPES_COUNT.apply(null,arguments)},nd=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE.apply(null, +arguments)},od=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD.apply(null,arguments)},pd=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH.apply(null,arguments)},qd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM.apply(null, +arguments)},rd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM.apply(null,arguments)},sd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM.apply(null,arguments)},td=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM.apply(null, +arguments)},ud=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_INVALID.apply(null,arguments)},vd=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_POSITION.apply(null,arguments)},wd=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_NORMAL.apply(null,arguments)},xd=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR= +function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_COLOR.apply(null,arguments)},yd=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD.apply(null,arguments)},zd=a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_GENERIC.apply(null,arguments)};a._setThrew=function(){return a.asm.setThrew.apply(null,arguments)};var ta=a.__ZSt18uncaught_exceptionv= +function(){return a.asm._ZSt18uncaught_exceptionv.apply(null,arguments)};a._free=function(){return a.asm.free.apply(null,arguments)};var ib=a._malloc=function(){return a.asm.malloc.apply(null,arguments)};a.stackSave=function(){return a.asm.stackSave.apply(null,arguments)};a.stackAlloc=function(){return a.asm.stackAlloc.apply(null,arguments)};a.stackRestore=function(){return a.asm.stackRestore.apply(null,arguments)};a.__growWasmMemory=function(){return a.asm.__growWasmMemory.apply(null,arguments)}; +a.dynCall_ii=function(){return a.asm.dynCall_ii.apply(null,arguments)};a.dynCall_vi=function(){return a.asm.dynCall_vi.apply(null,arguments)};a.dynCall_iii=function(){return a.asm.dynCall_iii.apply(null,arguments)};a.dynCall_vii=function(){return a.asm.dynCall_vii.apply(null,arguments)};a.dynCall_iiii=function(){return a.asm.dynCall_iiii.apply(null,arguments)};a.dynCall_v=function(){return a.asm.dynCall_v.apply(null,arguments)};a.dynCall_viii=function(){return a.asm.dynCall_viii.apply(null,arguments)}; +a.dynCall_viiii=function(){return a.asm.dynCall_viiii.apply(null,arguments)};a.dynCall_iiiiiii=function(){return a.asm.dynCall_iiiiiii.apply(null,arguments)};a.dynCall_iidiiii=function(){return a.asm.dynCall_iidiiii.apply(null,arguments)};a.dynCall_jiji=function(){return a.asm.dynCall_jiji.apply(null,arguments)};a.dynCall_viiiiii=function(){return a.asm.dynCall_viiiiii.apply(null,arguments)};a.dynCall_viiiii=function(){return a.asm.dynCall_viiiii.apply(null,arguments)};a.asm=La;var fa;a.then=function(e){if(fa)e(a); +else{var c=a.onRuntimeInitialized;a.onRuntimeInitialized=function(){c&&c();e(a)}}return a};ja=function c(){fa||ma();fa||(ja=c)};a.run=ma;if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0=n.size?(t(0>=1;break;case 4:d>>=2;break;case 8:d>>=3}for(var c=0;c> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' + + _lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' + + _lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] + + _lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ]; + + // .toUpperCase() here flattens concatenated strings to save heap memory space. + return uuid.toUpperCase(); + +} + +function clamp( value, min, max ) { + + return Math.max( min, Math.min( max, value ) ); + +} + +// compute euclidian modulo of m % n +// https://en.wikipedia.org/wiki/Modulo_operation +function euclideanModulo( n, m ) { + + return ( ( n % m ) + m ) % m; + +} + +// Linear mapping from range to range +function mapLinear( x, a1, a2, b1, b2 ) { + + return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); + +} + +// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/ +function inverseLerp( x, y, value ) { + + if ( x !== y ) { + + return ( value - x ) / ( y - x ); + + } else { + + return 0; + + } + +} + +// https://en.wikipedia.org/wiki/Linear_interpolation +function lerp( x, y, t ) { + + return ( 1 - t ) * x + t * y; + +} + +// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/ +function damp( x, y, lambda, dt ) { + + return lerp( x, y, 1 - Math.exp( - lambda * dt ) ); + +} + +// https://www.desmos.com/calculator/vcsjnyz7x4 +function pingpong( x, length = 1 ) { + + return length - Math.abs( euclideanModulo( x, length * 2 ) - length ); + +} + +// http://en.wikipedia.org/wiki/Smoothstep +function smoothstep( x, min, max ) { + + if ( x <= min ) return 0; + if ( x >= max ) return 1; + + x = ( x - min ) / ( max - min ); + + return x * x * ( 3 - 2 * x ); + +} + +function smootherstep( x, min, max ) { + + if ( x <= min ) return 0; + if ( x >= max ) return 1; + + x = ( x - min ) / ( max - min ); + + return x * x * x * ( x * ( x * 6 - 15 ) + 10 ); + +} + +// Random integer from interval +function randInt( low, high ) { + + return low + Math.floor( Math.random() * ( high - low + 1 ) ); + +} + +// Random float from interval +function randFloat( low, high ) { + + return low + Math.random() * ( high - low ); + +} + +// Random float from <-range/2, range/2> interval +function randFloatSpread( range ) { + + return range * ( 0.5 - Math.random() ); + +} + +// Deterministic pseudo-random float in the interval [ 0, 1 ] +function seededRandom( s ) { + + if ( s !== undefined ) _seed = s % 2147483647; + + // Park-Miller algorithm + + _seed = _seed * 16807 % 2147483647; + + return ( _seed - 1 ) / 2147483646; + +} + +function degToRad( degrees ) { + + return degrees * DEG2RAD; + +} + +function radToDeg( radians ) { + + return radians * RAD2DEG; + +} + +function isPowerOfTwo( value ) { + + return ( value & ( value - 1 ) ) === 0 && value !== 0; + +} + +function ceilPowerOfTwo( value ) { + + return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) ); + +} + +function floorPowerOfTwo( value ) { + + return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) ); + +} + +function setQuaternionFromProperEuler( q, a, b, c, order ) { + + // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles + + // rotations are applied to the axes in the order specified by 'order' + // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c' + // angles are in radians + + const cos = Math.cos; + const sin = Math.sin; + + const c2 = cos( b / 2 ); + const s2 = sin( b / 2 ); + + const c13 = cos( ( a + c ) / 2 ); + const s13 = sin( ( a + c ) / 2 ); + + const c1_3 = cos( ( a - c ) / 2 ); + const s1_3 = sin( ( a - c ) / 2 ); + + const c3_1 = cos( ( c - a ) / 2 ); + const s3_1 = sin( ( c - a ) / 2 ); + + switch ( order ) { + + case 'XYX': + q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 ); + break; + + case 'YZY': + q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 ); + break; + + case 'ZXZ': + q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 ); + break; + + case 'XZX': + q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 ); + break; + + case 'YXY': + q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 ); + break; + + case 'ZYZ': + q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 ); + break; + + default: + console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order ); + + } + +} + +var MathUtils = /*#__PURE__*/Object.freeze({ + __proto__: null, + DEG2RAD: DEG2RAD, + RAD2DEG: RAD2DEG, + generateUUID: generateUUID, + clamp: clamp, + euclideanModulo: euclideanModulo, + mapLinear: mapLinear, + inverseLerp: inverseLerp, + lerp: lerp, + damp: damp, + pingpong: pingpong, + smoothstep: smoothstep, + smootherstep: smootherstep, + randInt: randInt, + randFloat: randFloat, + randFloatSpread: randFloatSpread, + seededRandom: seededRandom, + degToRad: degToRad, + radToDeg: radToDeg, + isPowerOfTwo: isPowerOfTwo, + ceilPowerOfTwo: ceilPowerOfTwo, + floorPowerOfTwo: floorPowerOfTwo, + setQuaternionFromProperEuler: setQuaternionFromProperEuler +}); + +class Vector2 { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + get width() { + + return this.x; + + } + + set width( value ) { + + this.x = value; + + } + + get height() { + + return this.y; + + } + + set height( value ) { + + this.y = value; + + } + + set( x, y ) { + + this.x = x; + this.y = y; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + + return this; + + } + + multiply( v ) { + + this.x *= v.x; + this.y *= v.y; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + + return this; + + } + + divide( v ) { + + this.x /= v.x; + this.y /= v.y; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + applyMatrix3( m ) { + + const x = this.x, y = this.y; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ]; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ]; + + return this; + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y; + + } + + cross( v ) { + + return this.x * v.y - this.y * v.x; + + } + + lengthSq() { + + return this.x * this.x + this.y * this.y; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + angle() { + + // computes the angle in radians with respect to the positive x-axis + + const angle = Math.atan2( - this.y, - this.x ) + Math.PI; + + return angle; + + } + + distanceTo( v ) { + + return Math.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y; + return dx * dx + dy * dy; + + } + + manhattanDistanceTo( v ) { + + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + + return this; + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + + return this; + + } + + rotateAround( center, angle ) { + + const c = Math.cos( angle ), s = Math.sin( angle ); + + const x = this.x - center.x; + const y = this.y - center.y; + + this.x = x * c - y * s + center.x; + this.y = x * s + y * c + center.y; + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + + } + +} + +Vector2.prototype.isVector2 = true; + +class Matrix3 { + + constructor() { + + this.elements = [ + + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + + ]; + + if ( arguments.length > 0 ) { + + console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); + + } + + } + + set( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { + + const te = this.elements; + + te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; + te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; + te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; + + return this; + + } + + identity() { + + this.set( + + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + + ); + + return this; + + } + + copy( m ) { + + const te = this.elements; + const me = m.elements; + + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; + te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; + te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; + + return this; + + } + + extractBasis( xAxis, yAxis, zAxis ) { + + xAxis.setFromMatrix3Column( this, 0 ); + yAxis.setFromMatrix3Column( this, 1 ); + zAxis.setFromMatrix3Column( this, 2 ); + + return this; + + } + + setFromMatrix4( m ) { + + const me = m.elements; + + this.set( + + me[ 0 ], me[ 4 ], me[ 8 ], + me[ 1 ], me[ 5 ], me[ 9 ], + me[ 2 ], me[ 6 ], me[ 10 ] + + ); + + return this; + + } + + multiply( m ) { + + return this.multiplyMatrices( this, m ); + + } + + premultiply( m ) { + + return this.multiplyMatrices( m, this ); + + } + + multiplyMatrices( a, b ) { + + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; + const a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; + const a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; + + const b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; + const b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; + const b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; + + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; + te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; + te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; + + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; + te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; + te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; + + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; + te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; + te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + + return this; + + } + + multiplyScalar( s ) { + + const te = this.elements; + + te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; + te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; + te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; + + return this; + + } + + determinant() { + + const te = this.elements; + + const a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], + d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], + g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; + + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; + + } + + invert() { + + const te = this.elements, + + n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], + n12 = te[ 3 ], n22 = te[ 4 ], n32 = te[ 5 ], + n13 = te[ 6 ], n23 = te[ 7 ], n33 = te[ 8 ], + + t11 = n33 * n22 - n32 * n23, + t12 = n32 * n13 - n33 * n12, + t13 = n23 * n12 - n22 * n13, + + det = n11 * t11 + n21 * t12 + n31 * t13; + + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 ); + + const detInv = 1 / det; + + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; + te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; + + te[ 3 ] = t12 * detInv; + te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; + te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + + te[ 6 ] = t13 * detInv; + te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; + te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; + + return this; + + } + + transpose() { + + let tmp; + const m = this.elements; + + tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; + tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; + tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; + + return this; + + } + + getNormalMatrix( matrix4 ) { + + return this.setFromMatrix4( matrix4 ).invert().transpose(); + + } + + transposeIntoArray( r ) { + + const m = this.elements; + + r[ 0 ] = m[ 0 ]; + r[ 1 ] = m[ 3 ]; + r[ 2 ] = m[ 6 ]; + r[ 3 ] = m[ 1 ]; + r[ 4 ] = m[ 4 ]; + r[ 5 ] = m[ 7 ]; + r[ 6 ] = m[ 2 ]; + r[ 7 ] = m[ 5 ]; + r[ 8 ] = m[ 8 ]; + + return this; + + } + + setUvTransform( tx, ty, sx, sy, rotation, cx, cy ) { + + const c = Math.cos( rotation ); + const s = Math.sin( rotation ); + + this.set( + sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, + - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, + 0, 0, 1 + ); + + return this; + + } + + scale( sx, sy ) { + + const te = this.elements; + + te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; + te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; + + return this; + + } + + rotate( theta ) { + + const c = Math.cos( theta ); + const s = Math.sin( theta ); + + const te = this.elements; + + const a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; + const a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; + + te[ 0 ] = c * a11 + s * a21; + te[ 3 ] = c * a12 + s * a22; + te[ 6 ] = c * a13 + s * a23; + + te[ 1 ] = - s * a11 + c * a21; + te[ 4 ] = - s * a12 + c * a22; + te[ 7 ] = - s * a13 + c * a23; + + return this; + + } + + translate( tx, ty ) { + + const te = this.elements; + + te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; + te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; + + return this; + + } + + equals( matrix ) { + + const te = this.elements; + const me = matrix.elements; + + for ( let i = 0; i < 9; i ++ ) { + + if ( te[ i ] !== me[ i ] ) return false; + + } + + return true; + + } + + fromArray( array, offset = 0 ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.elements[ i ] = array[ i + offset ]; + + } + + return this; + + } + + toArray( array = [], offset = 0 ) { + + const te = this.elements; + + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + + array[ offset + 3 ] = te[ 3 ]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + array[ offset + 8 ] = te[ 8 ]; + + return array; + + } + + clone() { + + return new this.constructor().fromArray( this.elements ); + + } + +} + +Matrix3.prototype.isMatrix3 = true; + +function arrayMax( array ) { + + if ( array.length === 0 ) return - Infinity; + + let max = array[ 0 ]; + + for ( let i = 1, l = array.length; i < l; ++ i ) { + + if ( array[ i ] > max ) max = array[ i ]; + + } + + return max; + +} + +const TYPED_ARRAYS = { + Int8Array: Int8Array, + Uint8Array: Uint8Array, + Uint8ClampedArray: Uint8ClampedArray, + Int16Array: Int16Array, + Uint16Array: Uint16Array, + Int32Array: Int32Array, + Uint32Array: Uint32Array, + Float32Array: Float32Array, + Float64Array: Float64Array +}; + +function getTypedArray( type, buffer ) { + + return new TYPED_ARRAYS[ type ]( buffer ); + +} + +function createElementNS( name ) { + + return document.createElementNS( 'http://www.w3.org/1999/xhtml', name ); + +} + +const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF, + 'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2, + 'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50, + 'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B, + 'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B, + 'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F, + 'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3, + 'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222, + 'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700, + 'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4, + 'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00, + 'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3, + 'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA, + 'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32, + 'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3, + 'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC, + 'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD, + 'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6, + 'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9, + 'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F, + 'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE, + 'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA, + 'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0, + 'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 }; + +const _hslA = { h: 0, s: 0, l: 0 }; +const _hslB = { h: 0, s: 0, l: 0 }; + +function hue2rgb( p, q, t ) { + + if ( t < 0 ) t += 1; + if ( t > 1 ) t -= 1; + if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t; + if ( t < 1 / 2 ) return q; + if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t ); + return p; + +} + +function SRGBToLinear( c ) { + + return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 ); + +} + +function LinearToSRGB( c ) { + + return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055; + +} + +class Color { + + constructor( r, g, b ) { + + if ( g === undefined && b === undefined ) { + + // r is THREE.Color, hex or string + return this.set( r ); + + } + + return this.setRGB( r, g, b ); + + } + + set( value ) { + + if ( value && value.isColor ) { + + this.copy( value ); + + } else if ( typeof value === 'number' ) { + + this.setHex( value ); + + } else if ( typeof value === 'string' ) { + + this.setStyle( value ); + + } + + return this; + + } + + setScalar( scalar ) { + + this.r = scalar; + this.g = scalar; + this.b = scalar; + + return this; + + } + + setHex( hex ) { + + hex = Math.floor( hex ); + + this.r = ( hex >> 16 & 255 ) / 255; + this.g = ( hex >> 8 & 255 ) / 255; + this.b = ( hex & 255 ) / 255; + + return this; + + } + + setRGB( r, g, b ) { + + this.r = r; + this.g = g; + this.b = b; + + return this; + + } + + setHSL( h, s, l ) { + + // h,s,l ranges are in 0.0 - 1.0 + h = euclideanModulo( h, 1 ); + s = clamp( s, 0, 1 ); + l = clamp( l, 0, 1 ); + + if ( s === 0 ) { + + this.r = this.g = this.b = l; + + } else { + + const p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s ); + const q = ( 2 * l ) - p; + + this.r = hue2rgb( q, p, h + 1 / 3 ); + this.g = hue2rgb( q, p, h ); + this.b = hue2rgb( q, p, h - 1 / 3 ); + + } + + return this; + + } + + setStyle( style ) { + + function handleAlpha( string ) { + + if ( string === undefined ) return; + + if ( parseFloat( string ) < 1 ) { + + console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' ); + + } + + } + + + let m; + + if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) { + + // rgb / hsl + + let color; + const name = m[ 1 ]; + const components = m[ 2 ]; + + switch ( name ) { + + case 'rgb': + case 'rgba': + + if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // rgb(255,0,0) rgba(255,0,0,0.5) + this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255; + this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255; + this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255; + + handleAlpha( color[ 4 ] ); + + return this; + + } + + if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5) + this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100; + this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100; + this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100; + + handleAlpha( color[ 4 ] ); + + return this; + + } + + break; + + case 'hsl': + case 'hsla': + + if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) { + + // hsl(120,50%,50%) hsla(120,50%,50%,0.5) + const h = parseFloat( color[ 1 ] ) / 360; + const s = parseInt( color[ 2 ], 10 ) / 100; + const l = parseInt( color[ 3 ], 10 ) / 100; + + handleAlpha( color[ 4 ] ); + + return this.setHSL( h, s, l ); + + } + + break; + + } + + } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) { + + // hex color + + const hex = m[ 1 ]; + const size = hex.length; + + if ( size === 3 ) { + + // #ff0 + this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255; + this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255; + this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255; + + return this; + + } else if ( size === 6 ) { + + // #ff0000 + this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255; + this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255; + this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255; + + return this; + + } + + } + + if ( style && style.length > 0 ) { + + return this.setColorName( style ); + + } + + return this; + + } + + setColorName( style ) { + + // color keywords + const hex = _colorKeywords[ style.toLowerCase() ]; + + if ( hex !== undefined ) { + + // red + this.setHex( hex ); + + } else { + + // unknown color + console.warn( 'THREE.Color: Unknown color ' + style ); + + } + + return this; + + } + + clone() { + + return new this.constructor( this.r, this.g, this.b ); + + } + + copy( color ) { + + this.r = color.r; + this.g = color.g; + this.b = color.b; + + return this; + + } + + copySRGBToLinear( color ) { + + this.r = SRGBToLinear( color.r ); + this.g = SRGBToLinear( color.g ); + this.b = SRGBToLinear( color.b ); + + return this; + + } + + copyLinearToSRGB( color ) { + + this.r = LinearToSRGB( color.r ); + this.g = LinearToSRGB( color.g ); + this.b = LinearToSRGB( color.b ); + + return this; + + } + + convertSRGBToLinear() { + + this.copySRGBToLinear( this ); + + return this; + + } + + convertLinearToSRGB() { + + this.copyLinearToSRGB( this ); + + return this; + + } + + getHex() { + + return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0; + + } + + getHexString() { + + return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 ); + + } + + getHSL( target ) { + + // h,s,l ranges are in 0.0 - 1.0 + + const r = this.r, g = this.g, b = this.b; + + const max = Math.max( r, g, b ); + const min = Math.min( r, g, b ); + + let hue, saturation; + const lightness = ( min + max ) / 2.0; + + if ( min === max ) { + + hue = 0; + saturation = 0; + + } else { + + const delta = max - min; + + saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min ); + + switch ( max ) { + + case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break; + case g: hue = ( b - r ) / delta + 2; break; + case b: hue = ( r - g ) / delta + 4; break; + + } + + hue /= 6; + + } + + target.h = hue; + target.s = saturation; + target.l = lightness; + + return target; + + } + + getStyle() { + + return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')'; + + } + + offsetHSL( h, s, l ) { + + this.getHSL( _hslA ); + + _hslA.h += h; _hslA.s += s; _hslA.l += l; + + this.setHSL( _hslA.h, _hslA.s, _hslA.l ); + + return this; + + } + + add( color ) { + + this.r += color.r; + this.g += color.g; + this.b += color.b; + + return this; + + } + + addColors( color1, color2 ) { + + this.r = color1.r + color2.r; + this.g = color1.g + color2.g; + this.b = color1.b + color2.b; + + return this; + + } + + addScalar( s ) { + + this.r += s; + this.g += s; + this.b += s; + + return this; + + } + + sub( color ) { + + this.r = Math.max( 0, this.r - color.r ); + this.g = Math.max( 0, this.g - color.g ); + this.b = Math.max( 0, this.b - color.b ); + + return this; + + } + + multiply( color ) { + + this.r *= color.r; + this.g *= color.g; + this.b *= color.b; + + return this; + + } + + multiplyScalar( s ) { + + this.r *= s; + this.g *= s; + this.b *= s; + + return this; + + } + + lerp( color, alpha ) { + + this.r += ( color.r - this.r ) * alpha; + this.g += ( color.g - this.g ) * alpha; + this.b += ( color.b - this.b ) * alpha; + + return this; + + } + + lerpColors( color1, color2, alpha ) { + + this.r = color1.r + ( color2.r - color1.r ) * alpha; + this.g = color1.g + ( color2.g - color1.g ) * alpha; + this.b = color1.b + ( color2.b - color1.b ) * alpha; + + return this; + + } + + lerpHSL( color, alpha ) { + + this.getHSL( _hslA ); + color.getHSL( _hslB ); + + const h = lerp( _hslA.h, _hslB.h, alpha ); + const s = lerp( _hslA.s, _hslB.s, alpha ); + const l = lerp( _hslA.l, _hslB.l, alpha ); + + this.setHSL( h, s, l ); + + return this; + + } + + equals( c ) { + + return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b ); + + } + + fromArray( array, offset = 0 ) { + + this.r = array[ offset ]; + this.g = array[ offset + 1 ]; + this.b = array[ offset + 2 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.r; + array[ offset + 1 ] = this.g; + array[ offset + 2 ] = this.b; + + return array; + + } + + fromBufferAttribute( attribute, index ) { + + this.r = attribute.getX( index ); + this.g = attribute.getY( index ); + this.b = attribute.getZ( index ); + + if ( attribute.normalized === true ) { + + // assuming Uint8Array + + this.r /= 255; + this.g /= 255; + this.b /= 255; + + } + + return this; + + } + + toJSON() { + + return this.getHex(); + + } + +} + +Color.NAMES = _colorKeywords; + +Color.prototype.isColor = true; +Color.prototype.r = 1; +Color.prototype.g = 1; +Color.prototype.b = 1; + +let _canvas; + +class ImageUtils { + + static getDataURL( image ) { + + if ( /^data:/i.test( image.src ) ) { + + return image.src; + + } + + if ( typeof HTMLCanvasElement == 'undefined' ) { + + return image.src; + + } + + let canvas; + + if ( image instanceof HTMLCanvasElement ) { + + canvas = image; + + } else { + + if ( _canvas === undefined ) _canvas = createElementNS( 'canvas' ); + + _canvas.width = image.width; + _canvas.height = image.height; + + const context = _canvas.getContext( '2d' ); + + if ( image instanceof ImageData ) { + + context.putImageData( image, 0, 0 ); + + } else { + + context.drawImage( image, 0, 0, image.width, image.height ); + + } + + canvas = _canvas; + + } + + if ( canvas.width > 2048 || canvas.height > 2048 ) { + + console.warn( 'THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image ); + + return canvas.toDataURL( 'image/jpeg', 0.6 ); + + } else { + + return canvas.toDataURL( 'image/png' ); + + } + + } + + static sRGBToLinear( image ) { + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + const canvas = createElementNS( 'canvas' ); + + canvas.width = image.width; + canvas.height = image.height; + + const context = canvas.getContext( '2d' ); + context.drawImage( image, 0, 0, image.width, image.height ); + + const imageData = context.getImageData( 0, 0, image.width, image.height ); + const data = imageData.data; + + for ( let i = 0; i < data.length; i ++ ) { + + data[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255; + + } + + context.putImageData( imageData, 0, 0 ); + + return canvas; + + } else if ( image.data ) { + + const data = image.data.slice( 0 ); + + for ( let i = 0; i < data.length; i ++ ) { + + if ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) { + + data[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 ); + + } else { + + // assuming float + + data[ i ] = SRGBToLinear( data[ i ] ); + + } + + } + + return { + data: data, + width: image.width, + height: image.height + }; + + } else { + + console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' ); + return image; + + } + + } + +} + +let textureId = 0; + +class Texture extends EventDispatcher { + + constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) { + + super(); + + Object.defineProperty( this, 'id', { value: textureId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + + this.image = image; + this.mipmaps = []; + + this.mapping = mapping; + + this.wrapS = wrapS; + this.wrapT = wrapT; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.anisotropy = anisotropy; + + this.format = format; + this.internalFormat = null; + this.type = type; + + this.offset = new Vector2( 0, 0 ); + this.repeat = new Vector2( 1, 1 ); + this.center = new Vector2( 0, 0 ); + this.rotation = 0; + + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); + + this.generateMipmaps = true; + this.premultiplyAlpha = false; + this.flipY = true; + this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) + + // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. + // + // Also changing the encoding after already used by a Material will not automatically make the Material + // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. + this.encoding = encoding; + + this.userData = {}; + + this.version = 0; + this.onUpdate = null; + + this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not + this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures) + + } + + updateMatrix() { + + this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.name = source.name; + + this.image = source.image; + this.mipmaps = source.mipmaps.slice( 0 ); + + this.mapping = source.mapping; + + this.wrapS = source.wrapS; + this.wrapT = source.wrapT; + + this.magFilter = source.magFilter; + this.minFilter = source.minFilter; + + this.anisotropy = source.anisotropy; + + this.format = source.format; + this.internalFormat = source.internalFormat; + this.type = source.type; + + this.offset.copy( source.offset ); + this.repeat.copy( source.repeat ); + this.center.copy( source.center ); + this.rotation = source.rotation; + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrix.copy( source.matrix ); + + this.generateMipmaps = source.generateMipmaps; + this.premultiplyAlpha = source.premultiplyAlpha; + this.flipY = source.flipY; + this.unpackAlignment = source.unpackAlignment; + this.encoding = source.encoding; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + return this; + + } + + toJSON( meta ) { + + const isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { + + return meta.textures[ this.uuid ]; + + } + + const output = { + + metadata: { + version: 4.5, + type: 'Texture', + generator: 'Texture.toJSON' + }, + + uuid: this.uuid, + name: this.name, + + mapping: this.mapping, + + repeat: [ this.repeat.x, this.repeat.y ], + offset: [ this.offset.x, this.offset.y ], + center: [ this.center.x, this.center.y ], + rotation: this.rotation, + + wrap: [ this.wrapS, this.wrapT ], + + format: this.format, + type: this.type, + encoding: this.encoding, + + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, + + flipY: this.flipY, + + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment + + }; + + if ( this.image !== undefined ) { + + // TODO: Move to THREE.Image + + const image = this.image; + + if ( image.uuid === undefined ) { + + image.uuid = generateUUID(); // UGH + + } + + if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + + let url; + + if ( Array.isArray( image ) ) { + + // process array of images e.g. CubeTexture + + url = []; + + for ( let i = 0, l = image.length; i < l; i ++ ) { + + // check cube texture with data textures + + if ( image[ i ].isDataTexture ) { + + url.push( serializeImage( image[ i ].image ) ); + + } else { + + url.push( serializeImage( image[ i ] ) ); + + } + + } + + } else { + + // process single image + + url = serializeImage( image ); + + } + + meta.images[ image.uuid ] = { + uuid: image.uuid, + url: url + }; + + } + + output.image = image.uuid; + + } + + if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData; + + if ( ! isRootObject ) { + + meta.textures[ this.uuid ] = output; + + } + + return output; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + + transformUv( uv ) { + + if ( this.mapping !== UVMapping ) return uv; + + uv.applyMatrix3( this.matrix ); + + if ( uv.x < 0 || uv.x > 1 ) { + + switch ( this.wrapS ) { + + case RepeatWrapping: + + uv.x = uv.x - Math.floor( uv.x ); + break; + + case ClampToEdgeWrapping: + + uv.x = uv.x < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + + if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) { + + uv.x = Math.ceil( uv.x ) - uv.x; + + } else { + + uv.x = uv.x - Math.floor( uv.x ); + + } + + break; + + } + + } + + if ( uv.y < 0 || uv.y > 1 ) { + + switch ( this.wrapT ) { + + case RepeatWrapping: + + uv.y = uv.y - Math.floor( uv.y ); + break; + + case ClampToEdgeWrapping: + + uv.y = uv.y < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + + if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) { + + uv.y = Math.ceil( uv.y ) - uv.y; + + } else { + + uv.y = uv.y - Math.floor( uv.y ); + + } + + break; + + } + + } + + if ( this.flipY ) { + + uv.y = 1 - uv.y; + + } + + return uv; + + } + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + +} + +Texture.DEFAULT_IMAGE = undefined; +Texture.DEFAULT_MAPPING = UVMapping; + +Texture.prototype.isTexture = true; + +function serializeImage( image ) { + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + // default images + + return ImageUtils.getDataURL( image ); + + } else { + + if ( image.data ) { + + // images of DataTexture + + return { + data: Array.prototype.slice.call( image.data ), + width: image.width, + height: image.height, + type: image.data.constructor.name + }; + + } else { + + console.warn( 'THREE.Texture: Unable to serialize Texture.' ); + return {}; + + } + + } + +} + +class Vector4 { + + constructor( x = 0, y = 0, z = 0, w = 1 ) { + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + } + + get width() { + + return this.z; + + } + + set width( value ) { + + this.z = value; + + } + + get height() { + + return this.w; + + } + + set height( value ) { + + this.w = value; + + } + + set( x, y, z, w ) { + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + this.z = scalar; + this.w = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setZ( z ) { + + this.z = z; + + return this; + + } + + setW( w ) { + + this.w = w; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + case 2: this.z = value; break; + case 3: this.w = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + case 2: return this.z; + case 3: return this.w; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y, this.z, this.w ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this.z = v.z; + this.w = ( v.w !== undefined ) ? v.w : 1; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + this.z += s; + this.w += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + this.w = a.w + b.w; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + this.w += v.w * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + this.z -= s; + this.w -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + this.w = a.w - b.w; + + return this; + + } + + multiply( v ) { + + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + this.w *= v.w; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + this.w *= scalar; + + return this; + + } + + applyMatrix4( m ) { + + const x = this.x, y = this.y, z = this.z, w = this.w; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w; + this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + setAxisAngleFromQuaternion( q ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + + // q is assumed to be normalized + + this.w = 2 * Math.acos( q.w ); + + const s = Math.sqrt( 1 - q.w * q.w ); + + if ( s < 0.0001 ) { + + this.x = 1; + this.y = 0; + this.z = 0; + + } else { + + this.x = q.x / s; + this.y = q.y / s; + this.z = q.z / s; + + } + + return this; + + } + + setAxisAngleFromRotationMatrix( m ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + let angle, x, y, z; // variables for result + const epsilon = 0.01, // margin to allow for rounding errors + epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees + + te = m.elements, + + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; + + if ( ( Math.abs( m12 - m21 ) < epsilon ) && + ( Math.abs( m13 - m31 ) < epsilon ) && + ( Math.abs( m23 - m32 ) < epsilon ) ) { + + // singularity found + // first check for identity matrix which must have +1 for all terms + // in leading diagonal and zero in other terms + + if ( ( Math.abs( m12 + m21 ) < epsilon2 ) && + ( Math.abs( m13 + m31 ) < epsilon2 ) && + ( Math.abs( m23 + m32 ) < epsilon2 ) && + ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { + + // this singularity is identity matrix so angle = 0 + + this.set( 1, 0, 0, 0 ); + + return this; // zero angle, arbitrary axis + + } + + // otherwise this singularity is angle = 180 + + angle = Math.PI; + + const xx = ( m11 + 1 ) / 2; + const yy = ( m22 + 1 ) / 2; + const zz = ( m33 + 1 ) / 2; + const xy = ( m12 + m21 ) / 4; + const xz = ( m13 + m31 ) / 4; + const yz = ( m23 + m32 ) / 4; + + if ( ( xx > yy ) && ( xx > zz ) ) { + + // m11 is the largest diagonal term + + if ( xx < epsilon ) { + + x = 0; + y = 0.707106781; + z = 0.707106781; + + } else { + + x = Math.sqrt( xx ); + y = xy / x; + z = xz / x; + + } + + } else if ( yy > zz ) { + + // m22 is the largest diagonal term + + if ( yy < epsilon ) { + + x = 0.707106781; + y = 0; + z = 0.707106781; + + } else { + + y = Math.sqrt( yy ); + x = xy / y; + z = yz / y; + + } + + } else { + + // m33 is the largest diagonal term so base result on this + + if ( zz < epsilon ) { + + x = 0.707106781; + y = 0.707106781; + z = 0; + + } else { + + z = Math.sqrt( zz ); + x = xz / z; + y = yz / z; + + } + + } + + this.set( x, y, z, angle ); + + return this; // return 180 deg rotation + + } + + // as we have reached here there are no singularities so we can handle normally + + let s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) + + ( m13 - m31 ) * ( m13 - m31 ) + + ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize + + if ( Math.abs( s ) < 0.001 ) s = 1; + + // prevent divide by zero, should not happen if matrix is orthogonal and should be + // caught by singularity test above, but I've left it in just in case + + this.x = ( m32 - m23 ) / s; + this.y = ( m13 - m31 ) / s; + this.z = ( m21 - m12 ) / s; + this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 ); + + return this; + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + this.z = Math.min( this.z, v.z ); + this.w = Math.min( this.w, v.w ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + this.z = Math.max( this.z, v.z ); + this.w = Math.max( this.w, v.w ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + this.z = Math.max( min.z, Math.min( max.z, this.z ) ); + this.w = Math.max( min.w, Math.min( max.w, this.w ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + this.z = Math.floor( this.z ); + this.w = Math.floor( this.w ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + this.z = Math.ceil( this.z ); + this.w = Math.ceil( this.w ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + this.z = Math.round( this.z ); + this.w = Math.round( this.w ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + this.z = - this.z; + this.w = - this.w; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + + } + + lengthSq() { + + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + this.z += ( v.z - this.z ) * alpha; + this.w += ( v.w - this.w ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + this.z = v1.z + ( v2.z - v1.z ) * alpha; + this.w = v1.w + ( v2.w - v1.w ) * alpha; + + return this; + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + this.w = array[ offset + 3 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + array[ offset + 3 ] = this.w; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + this.w = attribute.getW( index ); + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + this.w = Math.random(); + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + yield this.z; + yield this.w; + + } + +} + +Vector4.prototype.isVector4 = true; + +/* + In options, we can specify: + * Texture parameters for an auto-generated target texture + * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers +*/ +class WebGLRenderTarget extends EventDispatcher { + + constructor( width, height, options = {} ) { + + super(); + + this.width = width; + this.height = height; + this.depth = 1; + + this.scissor = new Vector4( 0, 0, width, height ); + this.scissorTest = false; + + this.viewport = new Vector4( 0, 0, width, height ); + + this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + this.texture.isRenderTargetTexture = true; + + this.texture.image = { width: width, height: height, depth: 1 }; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + + this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; + this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false; + this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + + } + + setTexture( texture ) { + + texture.image = { + width: this.width, + height: this.height, + depth: this.depth + }; + + this.texture = texture; + + } + + setSize( width, height, depth = 1 ) { + + if ( this.width !== width || this.height !== height || this.depth !== depth ) { + + this.width = width; + this.height = height; + this.depth = depth; + + this.texture.image.width = width; + this.texture.image.height = height; + this.texture.image.depth = depth; + + this.dispose(); + + } + + this.viewport.set( 0, 0, width, height ); + this.scissor.set( 0, 0, width, height ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.width = source.width; + this.height = source.height; + this.depth = source.depth; + + this.viewport.copy( source.viewport ); + + this.texture = source.texture.clone(); + + // ensure image object is not shared, see #20328 + + this.texture.image = Object.assign( {}, source.texture.image ); + + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + +} + +WebGLRenderTarget.prototype.isWebGLRenderTarget = true; + +class WebGLMultipleRenderTargets extends WebGLRenderTarget { + + constructor( width, height, count ) { + + super( width, height ); + + const texture = this.texture; + + this.texture = []; + + for ( let i = 0; i < count; i ++ ) { + + this.texture[ i ] = texture.clone(); + + } + + } + + setSize( width, height, depth = 1 ) { + + if ( this.width !== width || this.height !== height || this.depth !== depth ) { + + this.width = width; + this.height = height; + this.depth = depth; + + for ( let i = 0, il = this.texture.length; i < il; i ++ ) { + + this.texture[ i ].image.width = width; + this.texture[ i ].image.height = height; + this.texture[ i ].image.depth = depth; + + } + + this.dispose(); + + } + + this.viewport.set( 0, 0, width, height ); + this.scissor.set( 0, 0, width, height ); + + return this; + + } + + copy( source ) { + + this.dispose(); + + this.width = source.width; + this.height = source.height; + this.depth = source.depth; + + this.viewport.set( 0, 0, this.width, this.height ); + this.scissor.set( 0, 0, this.width, this.height ); + + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; + + this.texture.length = 0; + + for ( let i = 0, il = source.texture.length; i < il; i ++ ) { + + this.texture[ i ] = source.texture[ i ].clone(); + + } + + return this; + + } + +} + +WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true; + +class WebGLMultisampleRenderTarget extends WebGLRenderTarget { + + constructor( width, height, options = {} ) { + + super( width, height, options ); + + this.samples = 4; + + this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true; + this.useRenderToTexture = ( options.useRenderToTexture !== undefined ) ? options.useRenderToTexture : false; + this.useRenderbuffer = this.useRenderToTexture === false; + + } + + copy( source ) { + + super.copy.call( this, source ); + + this.samples = source.samples; + this.useRenderToTexture = source.useRenderToTexture; + this.useRenderbuffer = source.useRenderbuffer; + + return this; + + } + +} + +WebGLMultisampleRenderTarget.prototype.isWebGLMultisampleRenderTarget = true; + +class Quaternion { + + constructor( x = 0, y = 0, z = 0, w = 1 ) { + + this._x = x; + this._y = y; + this._z = z; + this._w = w; + + } + + static slerp( qa, qb, qm, t ) { + + console.warn( 'THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.' ); + return qm.slerpQuaternions( qa, qb, t ); + + } + + static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { + + // fuzz-free, array-based Quaternion SLERP operation + + let x0 = src0[ srcOffset0 + 0 ], + y0 = src0[ srcOffset0 + 1 ], + z0 = src0[ srcOffset0 + 2 ], + w0 = src0[ srcOffset0 + 3 ]; + + const x1 = src1[ srcOffset1 + 0 ], + y1 = src1[ srcOffset1 + 1 ], + z1 = src1[ srcOffset1 + 2 ], + w1 = src1[ srcOffset1 + 3 ]; + + if ( t === 0 ) { + + dst[ dstOffset + 0 ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; + return; + + } + + if ( t === 1 ) { + + dst[ dstOffset + 0 ] = x1; + dst[ dstOffset + 1 ] = y1; + dst[ dstOffset + 2 ] = z1; + dst[ dstOffset + 3 ] = w1; + return; + + } + + if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { + + let s = 1 - t; + const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, + dir = ( cos >= 0 ? 1 : - 1 ), + sqrSin = 1 - cos * cos; + + // Skip the Slerp for tiny steps to avoid numeric problems: + if ( sqrSin > Number.EPSILON ) { + + const sin = Math.sqrt( sqrSin ), + len = Math.atan2( sin, cos * dir ); + + s = Math.sin( s * len ) / sin; + t = Math.sin( t * len ) / sin; + + } + + const tDir = t * dir; + + x0 = x0 * s + x1 * tDir; + y0 = y0 * s + y1 * tDir; + z0 = z0 * s + z1 * tDir; + w0 = w0 * s + w1 * tDir; + + // Normalize in case we just did a lerp: + if ( s === 1 - t ) { + + const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); + + x0 *= f; + y0 *= f; + z0 *= f; + w0 *= f; + + } + + } + + dst[ dstOffset ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; + + } + + static multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) { + + const x0 = src0[ srcOffset0 ]; + const y0 = src0[ srcOffset0 + 1 ]; + const z0 = src0[ srcOffset0 + 2 ]; + const w0 = src0[ srcOffset0 + 3 ]; + + const x1 = src1[ srcOffset1 ]; + const y1 = src1[ srcOffset1 + 1 ]; + const z1 = src1[ srcOffset1 + 2 ]; + const w1 = src1[ srcOffset1 + 3 ]; + + dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1; + dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1; + dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1; + dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1; + + return dst; + + } + + get x() { + + return this._x; + + } + + set x( value ) { + + this._x = value; + this._onChangeCallback(); + + } + + get y() { + + return this._y; + + } + + set y( value ) { + + this._y = value; + this._onChangeCallback(); + + } + + get z() { + + return this._z; + + } + + set z( value ) { + + this._z = value; + this._onChangeCallback(); + + } + + get w() { + + return this._w; + + } + + set w( value ) { + + this._w = value; + this._onChangeCallback(); + + } + + set( x, y, z, w ) { + + this._x = x; + this._y = y; + this._z = z; + this._w = w; + + this._onChangeCallback(); + + return this; + + } + + clone() { + + return new this.constructor( this._x, this._y, this._z, this._w ); + + } + + copy( quaternion ) { + + this._x = quaternion.x; + this._y = quaternion.y; + this._z = quaternion.z; + this._w = quaternion.w; + + this._onChangeCallback(); + + return this; + + } + + setFromEuler( euler, update ) { + + if ( ! ( euler && euler.isEuler ) ) { + + throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + + } + + const x = euler._x, y = euler._y, z = euler._z, order = euler._order; + + // http://www.mathworks.com/matlabcentral/fileexchange/ + // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ + // content/SpinCalc.m + + const cos = Math.cos; + const sin = Math.sin; + + const c1 = cos( x / 2 ); + const c2 = cos( y / 2 ); + const c3 = cos( z / 2 ); + + const s1 = sin( x / 2 ); + const s2 = sin( y / 2 ); + const s3 = sin( z / 2 ); + + switch ( order ) { + + case 'XYZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'YXZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'ZXY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'ZYX': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'YZX': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'XZY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + default: + console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order ); + + } + + if ( update !== false ) this._onChangeCallback(); + + return this; + + } + + setFromAxisAngle( axis, angle ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + + // assumes axis is normalized + + const halfAngle = angle / 2, s = Math.sin( halfAngle ); + + this._x = axis.x * s; + this._y = axis.y * s; + this._z = axis.z * s; + this._w = Math.cos( halfAngle ); + + this._onChangeCallback(); + + return this; + + } + + setFromRotationMatrix( m ) { + + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements, + + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ], + + trace = m11 + m22 + m33; + + if ( trace > 0 ) { + + const s = 0.5 / Math.sqrt( trace + 1.0 ); + + this._w = 0.25 / s; + this._x = ( m32 - m23 ) * s; + this._y = ( m13 - m31 ) * s; + this._z = ( m21 - m12 ) * s; + + } else if ( m11 > m22 && m11 > m33 ) { + + const s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); + + this._w = ( m32 - m23 ) / s; + this._x = 0.25 * s; + this._y = ( m12 + m21 ) / s; + this._z = ( m13 + m31 ) / s; + + } else if ( m22 > m33 ) { + + const s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); + + this._w = ( m13 - m31 ) / s; + this._x = ( m12 + m21 ) / s; + this._y = 0.25 * s; + this._z = ( m23 + m32 ) / s; + + } else { + + const s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + + this._w = ( m21 - m12 ) / s; + this._x = ( m13 + m31 ) / s; + this._y = ( m23 + m32 ) / s; + this._z = 0.25 * s; + + } + + this._onChangeCallback(); + + return this; + + } + + setFromUnitVectors( vFrom, vTo ) { + + // assumes direction vectors vFrom and vTo are normalized + + let r = vFrom.dot( vTo ) + 1; + + if ( r < Number.EPSILON ) { + + // vFrom and vTo point in opposite directions + + r = 0; + + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + + this._x = - vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; + + } else { + + this._x = 0; + this._y = - vFrom.z; + this._z = vFrom.y; + this._w = r; + + } + + } else { + + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 + + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; + + } + + return this.normalize(); + + } + + angleTo( q ) { + + return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) ); + + } + + rotateTowards( q, step ) { + + const angle = this.angleTo( q ); + + if ( angle === 0 ) return this; + + const t = Math.min( 1, step / angle ); + + this.slerp( q, t ); + + return this; + + } + + identity() { + + return this.set( 0, 0, 0, 1 ); + + } + + invert() { + + // quaternion is assumed to have unit length + + return this.conjugate(); + + } + + conjugate() { + + this._x *= - 1; + this._y *= - 1; + this._z *= - 1; + + this._onChangeCallback(); + + return this; + + } + + dot( v ) { + + return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; + + } + + lengthSq() { + + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + + } + + length() { + + return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); + + } + + normalize() { + + let l = this.length(); + + if ( l === 0 ) { + + this._x = 0; + this._y = 0; + this._z = 0; + this._w = 1; + + } else { + + l = 1 / l; + + this._x = this._x * l; + this._y = this._y * l; + this._z = this._z * l; + this._w = this._w * l; + + } + + this._onChangeCallback(); + + return this; + + } + + multiply( q, p ) { + + if ( p !== undefined ) { + + console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); + return this.multiplyQuaternions( q, p ); + + } + + return this.multiplyQuaternions( this, q ); + + } + + premultiply( q ) { + + return this.multiplyQuaternions( q, this ); + + } + + multiplyQuaternions( a, b ) { + + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + + const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; + const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; + + this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + + this._onChangeCallback(); + + return this; + + } + + slerp( qb, t ) { + + if ( t === 0 ) return this; + if ( t === 1 ) return this.copy( qb ); + + const x = this._x, y = this._y, z = this._z, w = this._w; + + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + + let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; + + if ( cosHalfTheta < 0 ) { + + this._w = - qb._w; + this._x = - qb._x; + this._y = - qb._y; + this._z = - qb._z; + + cosHalfTheta = - cosHalfTheta; + + } else { + + this.copy( qb ); + + } + + if ( cosHalfTheta >= 1.0 ) { + + this._w = w; + this._x = x; + this._y = y; + this._z = z; + + return this; + + } + + const sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; + + if ( sqrSinHalfTheta <= Number.EPSILON ) { + + const s = 1 - t; + this._w = s * w + t * this._w; + this._x = s * x + t * this._x; + this._y = s * y + t * this._y; + this._z = s * z + t * this._z; + + this.normalize(); + this._onChangeCallback(); + + return this; + + } + + const sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); + const halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); + const ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + + this._w = ( w * ratioA + this._w * ratioB ); + this._x = ( x * ratioA + this._x * ratioB ); + this._y = ( y * ratioA + this._y * ratioB ); + this._z = ( z * ratioA + this._z * ratioB ); + + this._onChangeCallback(); + + return this; + + } + + slerpQuaternions( qa, qb, t ) { + + return this.copy( qa ).slerp( qb, t ); + + } + + random() { + + // Derived from http://planning.cs.uiuc.edu/node198.html + // Note, this source uses w, x, y, z ordering, + // so we swap the order below. + + const u1 = Math.random(); + const sqrt1u1 = Math.sqrt( 1 - u1 ); + const sqrtu1 = Math.sqrt( u1 ); + + const u2 = 2 * Math.PI * Math.random(); + + const u3 = 2 * Math.PI * Math.random(); + + return this.set( + sqrt1u1 * Math.cos( u2 ), + sqrtu1 * Math.sin( u3 ), + sqrtu1 * Math.cos( u3 ), + sqrt1u1 * Math.sin( u2 ), + ); + + } + + equals( quaternion ) { + + return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); + + } + + fromArray( array, offset = 0 ) { + + this._x = array[ offset ]; + this._y = array[ offset + 1 ]; + this._z = array[ offset + 2 ]; + this._w = array[ offset + 3 ]; + + this._onChangeCallback(); + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._w; + + return array; + + } + + fromBufferAttribute( attribute, index ) { + + this._x = attribute.getX( index ); + this._y = attribute.getY( index ); + this._z = attribute.getZ( index ); + this._w = attribute.getW( index ); + + return this; + + } + + _onChange( callback ) { + + this._onChangeCallback = callback; + + return this; + + } + + _onChangeCallback() {} + +} + +Quaternion.prototype.isQuaternion = true; + +class Vector3 { + + constructor( x = 0, y = 0, z = 0 ) { + + this.x = x; + this.y = y; + this.z = z; + + } + + set( x, y, z ) { + + if ( z === undefined ) z = this.z; // sprite.scale.set(x,y) + + this.x = x; + this.y = y; + this.z = z; + + return this; + + } + + setScalar( scalar ) { + + this.x = scalar; + this.y = scalar; + this.z = scalar; + + return this; + + } + + setX( x ) { + + this.x = x; + + return this; + + } + + setY( y ) { + + this.y = y; + + return this; + + } + + setZ( z ) { + + this.z = z; + + return this; + + } + + setComponent( index, value ) { + + switch ( index ) { + + case 0: this.x = value; break; + case 1: this.y = value; break; + case 2: this.z = value; break; + default: throw new Error( 'index is out of range: ' + index ); + + } + + return this; + + } + + getComponent( index ) { + + switch ( index ) { + + case 0: return this.x; + case 1: return this.y; + case 2: return this.z; + default: throw new Error( 'index is out of range: ' + index ); + + } + + } + + clone() { + + return new this.constructor( this.x, this.y, this.z ); + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this.z = v.z; + + return this; + + } + + add( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + return this.addVectors( v, w ); + + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + + return this; + + } + + addScalar( s ) { + + this.x += s; + this.y += s; + this.z += s; + + return this; + + } + + addVectors( a, b ) { + + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + + return this; + + } + + addScaledVector( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + + return this; + + } + + sub( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + return this.subVectors( v, w ); + + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + + return this; + + } + + subScalar( s ) { + + this.x -= s; + this.y -= s; + this.z -= s; + + return this; + + } + + subVectors( a, b ) { + + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + + return this; + + } + + multiply( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); + return this.multiplyVectors( v, w ); + + } + + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + + return this; + + } + + multiplyScalar( scalar ) { + + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + + return this; + + } + + multiplyVectors( a, b ) { + + this.x = a.x * b.x; + this.y = a.y * b.y; + this.z = a.z * b.z; + + return this; + + } + + applyEuler( euler ) { + + if ( ! ( euler && euler.isEuler ) ) { + + console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + + } + + return this.applyQuaternion( _quaternion$4.setFromEuler( euler ) ); + + } + + applyAxisAngle( axis, angle ) { + + return this.applyQuaternion( _quaternion$4.setFromAxisAngle( axis, angle ) ); + + } + + applyMatrix3( m ) { + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; + this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; + + return this; + + } + + applyNormalMatrix( m ) { + + return this.applyMatrix3( m ).normalize(); + + } + + applyMatrix4( m ) { + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + const w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); + + this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w; + this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w; + this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w; + + return this; + + } + + applyQuaternion( q ) { + + const x = this.x, y = this.y, z = this.z; + const qx = q.x, qy = q.y, qz = q.z, qw = q.w; + + // calculate quat * vector + + const ix = qw * x + qy * z - qz * y; + const iy = qw * y + qz * x - qx * z; + const iz = qw * z + qx * y - qy * x; + const iw = - qx * x - qy * y - qz * z; + + // calculate result * inverse quat + + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; + + return this; + + } + + project( camera ) { + + return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); + + } + + unproject( camera ) { + + return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); + + } + + transformDirection( m ) { + + // input: THREE.Matrix4 affine matrix + // vector interpreted as a direction + + const x = this.x, y = this.y, z = this.z; + const e = m.elements; + + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; + + return this.normalize(); + + } + + divide( v ) { + + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; + + return this; + + } + + divideScalar( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + min( v ) { + + this.x = Math.min( this.x, v.x ); + this.y = Math.min( this.y, v.y ); + this.z = Math.min( this.z, v.z ); + + return this; + + } + + max( v ) { + + this.x = Math.max( this.x, v.x ); + this.y = Math.max( this.y, v.y ); + this.z = Math.max( this.z, v.z ); + + return this; + + } + + clamp( min, max ) { + + // assumes min < max, componentwise + + this.x = Math.max( min.x, Math.min( max.x, this.x ) ); + this.y = Math.max( min.y, Math.min( max.y, this.y ) ); + this.z = Math.max( min.z, Math.min( max.z, this.z ) ); + + return this; + + } + + clampScalar( minVal, maxVal ) { + + this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); + this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); + this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + + return this; + + } + + clampLength( min, max ) { + + const length = this.length(); + + return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + + } + + floor() { + + this.x = Math.floor( this.x ); + this.y = Math.floor( this.y ); + this.z = Math.floor( this.z ); + + return this; + + } + + ceil() { + + this.x = Math.ceil( this.x ); + this.y = Math.ceil( this.y ); + this.z = Math.ceil( this.z ); + + return this; + + } + + round() { + + this.x = Math.round( this.x ); + this.y = Math.round( this.y ); + this.z = Math.round( this.z ); + + return this; + + } + + roundToZero() { + + this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); + this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); + this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + + return this; + + } + + negate() { + + this.x = - this.x; + this.y = - this.y; + this.z = - this.z; + + return this; + + } + + dot( v ) { + + return this.x * v.x + this.y * v.y + this.z * v.z; + + } + + // TODO lengthSquared? + + lengthSq() { + + return this.x * this.x + this.y * this.y + this.z * this.z; + + } + + length() { + + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + + } + + manhattanLength() { + + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); + + } + + normalize() { + + return this.divideScalar( this.length() || 1 ); + + } + + setLength( length ) { + + return this.normalize().multiplyScalar( length ); + + } + + lerp( v, alpha ) { + + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + this.z += ( v.z - this.z ) * alpha; + + return this; + + } + + lerpVectors( v1, v2, alpha ) { + + this.x = v1.x + ( v2.x - v1.x ) * alpha; + this.y = v1.y + ( v2.y - v1.y ) * alpha; + this.z = v1.z + ( v2.z - v1.z ) * alpha; + + return this; + + } + + cross( v, w ) { + + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); + return this.crossVectors( v, w ); + + } + + return this.crossVectors( this, v ); + + } + + crossVectors( a, b ) { + + const ax = a.x, ay = a.y, az = a.z; + const bx = b.x, by = b.y, bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + + } + + projectOnVector( v ) { + + const denominator = v.lengthSq(); + + if ( denominator === 0 ) return this.set( 0, 0, 0 ); + + const scalar = v.dot( this ) / denominator; + + return this.copy( v ).multiplyScalar( scalar ); + + } + + projectOnPlane( planeNormal ) { + + _vector$c.copy( this ).projectOnVector( planeNormal ); + + return this.sub( _vector$c ); + + } + + reflect( normal ) { + + // reflect incident vector off plane orthogonal to normal + // normal is assumed to have unit length + + return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); + + } + + angleTo( v ) { + + const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); + + if ( denominator === 0 ) return Math.PI / 2; + + const theta = this.dot( v ) / denominator; + + // clamp, to handle numerical problems + + return Math.acos( clamp( theta, - 1, 1 ) ); + + } + + distanceTo( v ) { + + return Math.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + + return dx * dx + dy * dy + dz * dz; + + } + + manhattanDistanceTo( v ) { + + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); + + } + + setFromSpherical( s ) { + + return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); + + } + + setFromSphericalCoords( radius, phi, theta ) { + + const sinPhiRadius = Math.sin( phi ) * radius; + + this.x = sinPhiRadius * Math.sin( theta ); + this.y = Math.cos( phi ) * radius; + this.z = sinPhiRadius * Math.cos( theta ); + + return this; + + } + + setFromCylindrical( c ) { + + return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); + + } + + setFromCylindricalCoords( radius, theta, y ) { + + this.x = radius * Math.sin( theta ); + this.y = y; + this.z = radius * Math.cos( theta ); + + return this; + + } + + setFromMatrixPosition( m ) { + + const e = m.elements; + + this.x = e[ 12 ]; + this.y = e[ 13 ]; + this.z = e[ 14 ]; + + return this; + + } + + setFromMatrixScale( m ) { + + const sx = this.setFromMatrixColumn( m, 0 ).length(); + const sy = this.setFromMatrixColumn( m, 1 ).length(); + const sz = this.setFromMatrixColumn( m, 2 ).length(); + + this.x = sx; + this.y = sy; + this.z = sz; + + return this; + + } + + setFromMatrixColumn( m, index ) { + + return this.fromArray( m.elements, index * 4 ); + + } + + setFromMatrix3Column( m, index ) { + + return this.fromArray( m.elements, index * 3 ); + + } + + equals( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); + + } + + fromArray( array, offset = 0 ) { + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + + return array; + + } + + fromBufferAttribute( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + + return this; + + } + + random() { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + + return this; + + } + + randomDirection() { + + // Derived from https://mathworld.wolfram.com/SpherePointPicking.html + + const u = ( Math.random() - 0.5 ) * 2; + const t = Math.random() * Math.PI * 2; + const f = Math.sqrt( 1 - u ** 2 ); + + this.x = f * Math.cos( t ); + this.y = f * Math.sin( t ); + this.z = u; + + return this; + + } + + *[ Symbol.iterator ]() { + + yield this.x; + yield this.y; + yield this.z; + + } + +} + +Vector3.prototype.isVector3 = true; + +const _vector$c = /*@__PURE__*/ new Vector3(); +const _quaternion$4 = /*@__PURE__*/ new Quaternion(); + +class Box3 { + + constructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) { + + this.min = min; + this.max = max; + + } + + set( min, max ) { + + this.min.copy( min ); + this.max.copy( max ); + + return this; + + } + + setFromArray( array ) { + + let minX = + Infinity; + let minY = + Infinity; + let minZ = + Infinity; + + let maxX = - Infinity; + let maxY = - Infinity; + let maxZ = - Infinity; + + for ( let i = 0, l = array.length; i < l; i += 3 ) { + + const x = array[ i ]; + const y = array[ i + 1 ]; + const z = array[ i + 2 ]; + + if ( x < minX ) minX = x; + if ( y < minY ) minY = y; + if ( z < minZ ) minZ = z; + + if ( x > maxX ) maxX = x; + if ( y > maxY ) maxY = y; + if ( z > maxZ ) maxZ = z; + + } + + this.min.set( minX, minY, minZ ); + this.max.set( maxX, maxY, maxZ ); + + return this; + + } + + setFromBufferAttribute( attribute ) { + + let minX = + Infinity; + let minY = + Infinity; + let minZ = + Infinity; + + let maxX = - Infinity; + let maxY = - Infinity; + let maxZ = - Infinity; + + for ( let i = 0, l = attribute.count; i < l; i ++ ) { + + const x = attribute.getX( i ); + const y = attribute.getY( i ); + const z = attribute.getZ( i ); + + if ( x < minX ) minX = x; + if ( y < minY ) minY = y; + if ( z < minZ ) minZ = z; + + if ( x > maxX ) maxX = x; + if ( y > maxY ) maxY = y; + if ( z > maxZ ) maxZ = z; + + } + + this.min.set( minX, minY, minZ ); + this.max.set( maxX, maxY, maxZ ); + + return this; + + } + + setFromPoints( points ) { + + this.makeEmpty(); + + for ( let i = 0, il = points.length; i < il; i ++ ) { + + this.expandByPoint( points[ i ] ); + + } + + return this; + + } + + setFromCenterAndSize( center, size ) { + + const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 ); + + this.min.copy( center ).sub( halfSize ); + this.max.copy( center ).add( halfSize ); + + return this; + + } + + setFromObject( object ) { + + this.makeEmpty(); + + return this.expandByObject( object ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( box ) { + + this.min.copy( box.min ); + this.max.copy( box.max ); + + return this; + + } + + makeEmpty() { + + this.min.x = this.min.y = this.min.z = + Infinity; + this.max.x = this.max.y = this.max.z = - Infinity; + + return this; + + } + + isEmpty() { + + // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes + + return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z ); + + } + + getCenter( target ) { + + return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 ); + + } + + getSize( target ) { + + return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min ); + + } + + expandByPoint( point ) { + + this.min.min( point ); + this.max.max( point ); + + return this; + + } + + expandByVector( vector ) { + + this.min.sub( vector ); + this.max.add( vector ); + + return this; + + } + + expandByScalar( scalar ) { + + this.min.addScalar( - scalar ); + this.max.addScalar( scalar ); + + return this; + + } + + expandByObject( object ) { + + // Computes the world-axis-aligned bounding box of an object (including its children), + // accounting for both the object's, and children's, world transforms + + object.updateWorldMatrix( false, false ); + + const geometry = object.geometry; + + if ( geometry !== undefined ) { + + if ( geometry.boundingBox === null ) { + + geometry.computeBoundingBox(); + + } + + _box$3.copy( geometry.boundingBox ); + _box$3.applyMatrix4( object.matrixWorld ); + + this.union( _box$3 ); + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + this.expandByObject( children[ i ] ); + + } + + return this; + + } + + containsPoint( point ) { + + return point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y || + point.z < this.min.z || point.z > this.max.z ? false : true; + + } + + containsBox( box ) { + + return this.min.x <= box.min.x && box.max.x <= this.max.x && + this.min.y <= box.min.y && box.max.y <= this.max.y && + this.min.z <= box.min.z && box.max.z <= this.max.z; + + } + + getParameter( point, target ) { + + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + + return target.set( + ( point.x - this.min.x ) / ( this.max.x - this.min.x ), + ( point.y - this.min.y ) / ( this.max.y - this.min.y ), + ( point.z - this.min.z ) / ( this.max.z - this.min.z ) + ); + + } + + intersectsBox( box ) { + + // using 6 splitting planes to rule out intersections. + return box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y || + box.max.z < this.min.z || box.min.z > this.max.z ? false : true; + + } + + intersectsSphere( sphere ) { + + // Find the point on the AABB closest to the sphere center. + this.clampPoint( sphere.center, _vector$b ); + + // If that point is inside the sphere, the AABB and sphere intersect. + return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + + } + + intersectsPlane( plane ) { + + // We compute the minimum and maximum dot product values. If those values + // are on the same side (back or front) of the plane, then there is no intersection. + + let min, max; + + if ( plane.normal.x > 0 ) { + + min = plane.normal.x * this.min.x; + max = plane.normal.x * this.max.x; + + } else { + + min = plane.normal.x * this.max.x; + max = plane.normal.x * this.min.x; + + } + + if ( plane.normal.y > 0 ) { + + min += plane.normal.y * this.min.y; + max += plane.normal.y * this.max.y; + + } else { + + min += plane.normal.y * this.max.y; + max += plane.normal.y * this.min.y; + + } + + if ( plane.normal.z > 0 ) { + + min += plane.normal.z * this.min.z; + max += plane.normal.z * this.max.z; + + } else { + + min += plane.normal.z * this.max.z; + max += plane.normal.z * this.min.z; + + } + + return ( min <= - plane.constant && max >= - plane.constant ); + + } + + intersectsTriangle( triangle ) { + + if ( this.isEmpty() ) { + + return false; + + } + + // compute box center and extents + this.getCenter( _center ); + _extents.subVectors( this.max, _center ); + + // translate triangle to aabb origin + _v0$2.subVectors( triangle.a, _center ); + _v1$7.subVectors( triangle.b, _center ); + _v2$3.subVectors( triangle.c, _center ); + + // compute edge vectors for triangle + _f0.subVectors( _v1$7, _v0$2 ); + _f1.subVectors( _v2$3, _v1$7 ); + _f2.subVectors( _v0$2, _v2$3 ); + + // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb + // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation + // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned) + let axes = [ + 0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y, + _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x, + - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0 + ]; + if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) { + + return false; + + } + + // test 3 face normals from the aabb + axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ]; + if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) { + + return false; + + } + + // finally testing the face normal of the triangle + // use already existing triangle edge vectors here + _triangleNormal.crossVectors( _f0, _f1 ); + axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ]; + + return satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ); + + } + + clampPoint( point, target ) { + + return target.copy( point ).clamp( this.min, this.max ); + + } + + distanceToPoint( point ) { + + const clampedPoint = _vector$b.copy( point ).clamp( this.min, this.max ); + + return clampedPoint.sub( point ).length(); + + } + + getBoundingSphere( target ) { + + this.getCenter( target.center ); + + target.radius = this.getSize( _vector$b ).length() * 0.5; + + return target; + + } + + intersect( box ) { + + this.min.max( box.min ); + this.max.min( box.max ); + + // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values. + if ( this.isEmpty() ) this.makeEmpty(); + + return this; + + } + + union( box ) { + + this.min.min( box.min ); + this.max.max( box.max ); + + return this; + + } + + applyMatrix4( matrix ) { + + // transform of empty box is an empty box. + if ( this.isEmpty() ) return this; + + // NOTE: I am using a binary pattern to specify all 2^3 combinations below + _points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000 + _points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001 + _points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010 + _points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011 + _points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100 + _points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101 + _points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110 + _points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111 + + this.setFromPoints( _points ); + + return this; + + } + + translate( offset ) { + + this.min.add( offset ); + this.max.add( offset ); + + return this; + + } + + equals( box ) { + + return box.min.equals( this.min ) && box.max.equals( this.max ); + + } + +} + +Box3.prototype.isBox3 = true; + +const _points = [ + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3() +]; + +const _vector$b = /*@__PURE__*/ new Vector3(); + +const _box$3 = /*@__PURE__*/ new Box3(); + +// triangle centered vertices + +const _v0$2 = /*@__PURE__*/ new Vector3(); +const _v1$7 = /*@__PURE__*/ new Vector3(); +const _v2$3 = /*@__PURE__*/ new Vector3(); + +// triangle edge vectors + +const _f0 = /*@__PURE__*/ new Vector3(); +const _f1 = /*@__PURE__*/ new Vector3(); +const _f2 = /*@__PURE__*/ new Vector3(); + +const _center = /*@__PURE__*/ new Vector3(); +const _extents = /*@__PURE__*/ new Vector3(); +const _triangleNormal = /*@__PURE__*/ new Vector3(); +const _testAxis = /*@__PURE__*/ new Vector3(); + +function satForAxes( axes, v0, v1, v2, extents ) { + + for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) { + + _testAxis.fromArray( axes, i ); + // project the aabb onto the seperating axis + const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z ); + // project all 3 vertices of the triangle onto the seperating axis + const p0 = v0.dot( _testAxis ); + const p1 = v1.dot( _testAxis ); + const p2 = v2.dot( _testAxis ); + // actual test, basically see if either of the most extreme of the triangle points intersects r + if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) { + + // points of the projected triangle are outside the projected half-length of the aabb + // the axis is seperating and we can exit + return false; + + } + + } + + return true; + +} + +const _box$2 = /*@__PURE__*/ new Box3(); +const _v1$6 = /*@__PURE__*/ new Vector3(); +const _toFarthestPoint = /*@__PURE__*/ new Vector3(); +const _toPoint = /*@__PURE__*/ new Vector3(); + +class Sphere { + + constructor( center = new Vector3(), radius = - 1 ) { + + this.center = center; + this.radius = radius; + + } + + set( center, radius ) { + + this.center.copy( center ); + this.radius = radius; + + return this; + + } + + setFromPoints( points, optionalCenter ) { + + const center = this.center; + + if ( optionalCenter !== undefined ) { + + center.copy( optionalCenter ); + + } else { + + _box$2.setFromPoints( points ).getCenter( center ); + + } + + let maxRadiusSq = 0; + + for ( let i = 0, il = points.length; i < il; i ++ ) { + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) ); + + } + + this.radius = Math.sqrt( maxRadiusSq ); + + return this; + + } + + copy( sphere ) { + + this.center.copy( sphere.center ); + this.radius = sphere.radius; + + return this; + + } + + isEmpty() { + + return ( this.radius < 0 ); + + } + + makeEmpty() { + + this.center.set( 0, 0, 0 ); + this.radius = - 1; + + return this; + + } + + containsPoint( point ) { + + return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) ); + + } + + distanceToPoint( point ) { + + return ( point.distanceTo( this.center ) - this.radius ); + + } + + intersectsSphere( sphere ) { + + const radiusSum = this.radius + sphere.radius; + + return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum ); + + } + + intersectsBox( box ) { + + return box.intersectsSphere( this ); + + } + + intersectsPlane( plane ) { + + return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius; + + } + + clampPoint( point, target ) { + + const deltaLengthSq = this.center.distanceToSquared( point ); + + target.copy( point ); + + if ( deltaLengthSq > ( this.radius * this.radius ) ) { + + target.sub( this.center ).normalize(); + target.multiplyScalar( this.radius ).add( this.center ); + + } + + return target; + + } + + getBoundingBox( target ) { + + if ( this.isEmpty() ) { + + // Empty sphere produces empty bounding box + target.makeEmpty(); + return target; + + } + + target.set( this.center, this.center ); + target.expandByScalar( this.radius ); + + return target; + + } + + applyMatrix4( matrix ) { + + this.center.applyMatrix4( matrix ); + this.radius = this.radius * matrix.getMaxScaleOnAxis(); + + return this; + + } + + translate( offset ) { + + this.center.add( offset ); + + return this; + + } + + expandByPoint( point ) { + + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671 + + _toPoint.subVectors( point, this.center ); + + const lengthSq = _toPoint.lengthSq(); + + if ( lengthSq > ( this.radius * this.radius ) ) { + + const length = Math.sqrt( lengthSq ); + const missingRadiusHalf = ( length - this.radius ) * 0.5; + + // Nudge this sphere towards the target point. Add half the missing distance to radius, + // and the other half to position. This gives a tighter enclosure, instead of if + // the whole missing distance were just added to radius. + + this.center.add( _toPoint.multiplyScalar( missingRadiusHalf / length ) ); + this.radius += missingRadiusHalf; + + } + + return this; + + } + + union( sphere ) { + + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769 + + // To enclose another sphere into this sphere, we only need to enclose two points: + // 1) Enclose the farthest point on the other sphere into this sphere. + // 2) Enclose the opposite point of the farthest point into this sphere. + + if ( this.center.equals( sphere.center ) === true ) { + + _toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius ); + + + } else { + + _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius ); + + } + + this.expandByPoint( _v1$6.copy( sphere.center ).add( _toFarthestPoint ) ); + this.expandByPoint( _v1$6.copy( sphere.center ).sub( _toFarthestPoint ) ); + + return this; + + } + + equals( sphere ) { + + return sphere.center.equals( this.center ) && ( sphere.radius === this.radius ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +const _vector$a = /*@__PURE__*/ new Vector3(); +const _segCenter = /*@__PURE__*/ new Vector3(); +const _segDir = /*@__PURE__*/ new Vector3(); +const _diff = /*@__PURE__*/ new Vector3(); + +const _edge1 = /*@__PURE__*/ new Vector3(); +const _edge2 = /*@__PURE__*/ new Vector3(); +const _normal$1 = /*@__PURE__*/ new Vector3(); + +class Ray { + + constructor( origin = new Vector3(), direction = new Vector3( 0, 0, - 1 ) ) { + + this.origin = origin; + this.direction = direction; + + } + + set( origin, direction ) { + + this.origin.copy( origin ); + this.direction.copy( direction ); + + return this; + + } + + copy( ray ) { + + this.origin.copy( ray.origin ); + this.direction.copy( ray.direction ); + + return this; + + } + + at( t, target ) { + + return target.copy( this.direction ).multiplyScalar( t ).add( this.origin ); + + } + + lookAt( v ) { + + this.direction.copy( v ).sub( this.origin ).normalize(); + + return this; + + } + + recast( t ) { + + this.origin.copy( this.at( t, _vector$a ) ); + + return this; + + } + + closestPointToPoint( point, target ) { + + target.subVectors( point, this.origin ); + + const directionDistance = target.dot( this.direction ); + + if ( directionDistance < 0 ) { + + return target.copy( this.origin ); + + } + + return target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + + } + + distanceToPoint( point ) { + + return Math.sqrt( this.distanceSqToPoint( point ) ); + + } + + distanceSqToPoint( point ) { + + const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction ); + + // point behind the ray + + if ( directionDistance < 0 ) { + + return this.origin.distanceToSquared( point ); + + } + + _vector$a.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + + return _vector$a.distanceToSquared( point ); + + } + + distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { + + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h + // It returns the min distance between the ray and the segment + // defined by v0 and v1 + // It can also set two optional targets : + // - The closest point on the ray + // - The closest point on the segment + + _segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 ); + _segDir.copy( v1 ).sub( v0 ).normalize(); + _diff.copy( this.origin ).sub( _segCenter ); + + const segExtent = v0.distanceTo( v1 ) * 0.5; + const a01 = - this.direction.dot( _segDir ); + const b0 = _diff.dot( this.direction ); + const b1 = - _diff.dot( _segDir ); + const c = _diff.lengthSq(); + const det = Math.abs( 1 - a01 * a01 ); + let s0, s1, sqrDist, extDet; + + if ( det > 0 ) { + + // The ray and segment are not parallel. + + s0 = a01 * b1 - b0; + s1 = a01 * b0 - b1; + extDet = segExtent * det; + + if ( s0 >= 0 ) { + + if ( s1 >= - extDet ) { + + if ( s1 <= extDet ) { + + // region 0 + // Minimum at interior points of ray and segment. + + const invDet = 1 / det; + s0 *= invDet; + s1 *= invDet; + sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c; + + } else { + + // region 1 + + s1 = segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } else { + + // region 5 + + s1 = - segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } else { + + if ( s1 <= - extDet ) { + + // region 4 + + s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) ); + s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } else if ( s1 <= extDet ) { + + // region 3 + + s0 = 0; + s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = s1 * ( s1 + 2 * b1 ) + c; + + } else { + + // region 2 + + s0 = Math.max( 0, - ( a01 * segExtent + b0 ) ); + s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + } + + } else { + + // Ray and segment are parallel. + + s1 = ( a01 > 0 ) ? - segExtent : segExtent; + s0 = Math.max( 0, - ( a01 * s1 + b0 ) ); + sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c; + + } + + if ( optionalPointOnRay ) { + + optionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin ); + + } + + if ( optionalPointOnSegment ) { + + optionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter ); + + } + + return sqrDist; + + } + + intersectSphere( sphere, target ) { + + _vector$a.subVectors( sphere.center, this.origin ); + const tca = _vector$a.dot( this.direction ); + const d2 = _vector$a.dot( _vector$a ) - tca * tca; + const radius2 = sphere.radius * sphere.radius; + + if ( d2 > radius2 ) return null; + + const thc = Math.sqrt( radius2 - d2 ); + + // t0 = first intersect point - entrance on front of sphere + const t0 = tca - thc; + + // t1 = second intersect point - exit point on back of sphere + const t1 = tca + thc; + + // test to see if both t0 and t1 are behind the ray - if so, return null + if ( t0 < 0 && t1 < 0 ) return null; + + // test to see if t0 is behind the ray: + // if it is, the ray is inside the sphere, so return the second exit point scaled by t1, + // in order to always return an intersect point that is in front of the ray. + if ( t0 < 0 ) return this.at( t1, target ); + + // else t0 is in front of the ray, so return the first collision point scaled by t0 + return this.at( t0, target ); + + } + + intersectsSphere( sphere ) { + + return this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius ); + + } + + distanceToPlane( plane ) { + + const denominator = plane.normal.dot( this.direction ); + + if ( denominator === 0 ) { + + // line is coplanar, return origin + if ( plane.distanceToPoint( this.origin ) === 0 ) { + + return 0; + + } + + // Null is preferable to undefined since undefined means.... it is undefined + + return null; + + } + + const t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator; + + // Return if the ray never intersects the plane + + return t >= 0 ? t : null; + + } + + intersectPlane( plane, target ) { + + const t = this.distanceToPlane( plane ); + + if ( t === null ) { + + return null; + + } + + return this.at( t, target ); + + } + + intersectsPlane( plane ) { + + // check if the ray lies on the plane first + + const distToPoint = plane.distanceToPoint( this.origin ); + + if ( distToPoint === 0 ) { + + return true; + + } + + const denominator = plane.normal.dot( this.direction ); + + if ( denominator * distToPoint < 0 ) { + + return true; + + } + + // ray origin is behind the plane (and is pointing behind it) + + return false; + + } + + intersectBox( box, target ) { + + let tmin, tmax, tymin, tymax, tzmin, tzmax; + + const invdirx = 1 / this.direction.x, + invdiry = 1 / this.direction.y, + invdirz = 1 / this.direction.z; + + const origin = this.origin; + + if ( invdirx >= 0 ) { + + tmin = ( box.min.x - origin.x ) * invdirx; + tmax = ( box.max.x - origin.x ) * invdirx; + + } else { + + tmin = ( box.max.x - origin.x ) * invdirx; + tmax = ( box.min.x - origin.x ) * invdirx; + + } + + if ( invdiry >= 0 ) { + + tymin = ( box.min.y - origin.y ) * invdiry; + tymax = ( box.max.y - origin.y ) * invdiry; + + } else { + + tymin = ( box.max.y - origin.y ) * invdiry; + tymax = ( box.min.y - origin.y ) * invdiry; + + } + + if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null; + + // These lines also handle the case where tmin or tmax is NaN + // (result of 0 * Infinity). x !== x returns true if x is NaN + + if ( tymin > tmin || tmin !== tmin ) tmin = tymin; + + if ( tymax < tmax || tmax !== tmax ) tmax = tymax; + + if ( invdirz >= 0 ) { + + tzmin = ( box.min.z - origin.z ) * invdirz; + tzmax = ( box.max.z - origin.z ) * invdirz; + + } else { + + tzmin = ( box.max.z - origin.z ) * invdirz; + tzmax = ( box.min.z - origin.z ) * invdirz; + + } + + if ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null; + + if ( tzmin > tmin || tmin !== tmin ) tmin = tzmin; + + if ( tzmax < tmax || tmax !== tmax ) tmax = tzmax; + + //return point closest to the ray (positive side) + + if ( tmax < 0 ) return null; + + return this.at( tmin >= 0 ? tmin : tmax, target ); + + } + + intersectsBox( box ) { + + return this.intersectBox( box, _vector$a ) !== null; + + } + + intersectTriangle( a, b, c, backfaceCulling, target ) { + + // Compute the offset origin, edges, and normal. + + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h + + _edge1.subVectors( b, a ); + _edge2.subVectors( c, a ); + _normal$1.crossVectors( _edge1, _edge2 ); + + // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction, + // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by + // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2)) + // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q)) + // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N) + let DdN = this.direction.dot( _normal$1 ); + let sign; + + if ( DdN > 0 ) { + + if ( backfaceCulling ) return null; + sign = 1; + + } else if ( DdN < 0 ) { + + sign = - 1; + DdN = - DdN; + + } else { + + return null; + + } + + _diff.subVectors( this.origin, a ); + const DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) ); + + // b1 < 0, no intersection + if ( DdQxE2 < 0 ) { + + return null; + + } + + const DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) ); + + // b2 < 0, no intersection + if ( DdE1xQ < 0 ) { + + return null; + + } + + // b1+b2 > 1, no intersection + if ( DdQxE2 + DdE1xQ > DdN ) { + + return null; + + } + + // Line intersects triangle, check if ray does. + const QdN = - sign * _diff.dot( _normal$1 ); + + // t < 0, no intersection + if ( QdN < 0 ) { + + return null; + + } + + // Ray intersects triangle. + return this.at( QdN / DdN, target ); + + } + + applyMatrix4( matrix4 ) { + + this.origin.applyMatrix4( matrix4 ); + this.direction.transformDirection( matrix4 ); + + return this; + + } + + equals( ray ) { + + return ray.origin.equals( this.origin ) && ray.direction.equals( this.direction ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +class Matrix4 { + + constructor() { + + this.elements = [ + + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ]; + + if ( arguments.length > 0 ) { + + console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' ); + + } + + } + + set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { + + const te = this.elements; + + te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14; + te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24; + te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34; + te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44; + + return this; + + } + + identity() { + + this.set( + + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + clone() { + + return new Matrix4().fromArray( this.elements ); + + } + + copy( m ) { + + const te = this.elements; + const me = m.elements; + + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ]; + te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; + te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ]; + te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ]; + + return this; + + } + + copyPosition( m ) { + + const te = this.elements, me = m.elements; + + te[ 12 ] = me[ 12 ]; + te[ 13 ] = me[ 13 ]; + te[ 14 ] = me[ 14 ]; + + return this; + + } + + setFromMatrix3( m ) { + + const me = m.elements; + + this.set( + + me[ 0 ], me[ 3 ], me[ 6 ], 0, + me[ 1 ], me[ 4 ], me[ 7 ], 0, + me[ 2 ], me[ 5 ], me[ 8 ], 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + extractBasis( xAxis, yAxis, zAxis ) { + + xAxis.setFromMatrixColumn( this, 0 ); + yAxis.setFromMatrixColumn( this, 1 ); + zAxis.setFromMatrixColumn( this, 2 ); + + return this; + + } + + makeBasis( xAxis, yAxis, zAxis ) { + + this.set( + xAxis.x, yAxis.x, zAxis.x, 0, + xAxis.y, yAxis.y, zAxis.y, 0, + xAxis.z, yAxis.z, zAxis.z, 0, + 0, 0, 0, 1 + ); + + return this; + + } + + extractRotation( m ) { + + // this method does not support reflection matrices + + const te = this.elements; + const me = m.elements; + + const scaleX = 1 / _v1$5.setFromMatrixColumn( m, 0 ).length(); + const scaleY = 1 / _v1$5.setFromMatrixColumn( m, 1 ).length(); + const scaleZ = 1 / _v1$5.setFromMatrixColumn( m, 2 ).length(); + + te[ 0 ] = me[ 0 ] * scaleX; + te[ 1 ] = me[ 1 ] * scaleX; + te[ 2 ] = me[ 2 ] * scaleX; + te[ 3 ] = 0; + + te[ 4 ] = me[ 4 ] * scaleY; + te[ 5 ] = me[ 5 ] * scaleY; + te[ 6 ] = me[ 6 ] * scaleY; + te[ 7 ] = 0; + + te[ 8 ] = me[ 8 ] * scaleZ; + te[ 9 ] = me[ 9 ] * scaleZ; + te[ 10 ] = me[ 10 ] * scaleZ; + te[ 11 ] = 0; + + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; + + return this; + + } + + makeRotationFromEuler( euler ) { + + if ( ! ( euler && euler.isEuler ) ) { + + console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' ); + + } + + const te = this.elements; + + const x = euler.x, y = euler.y, z = euler.z; + const a = Math.cos( x ), b = Math.sin( x ); + const c = Math.cos( y ), d = Math.sin( y ); + const e = Math.cos( z ), f = Math.sin( z ); + + if ( euler.order === 'XYZ' ) { + + const ae = a * e, af = a * f, be = b * e, bf = b * f; + + te[ 0 ] = c * e; + te[ 4 ] = - c * f; + te[ 8 ] = d; + + te[ 1 ] = af + be * d; + te[ 5 ] = ae - bf * d; + te[ 9 ] = - b * c; + + te[ 2 ] = bf - ae * d; + te[ 6 ] = be + af * d; + te[ 10 ] = a * c; + + } else if ( euler.order === 'YXZ' ) { + + const ce = c * e, cf = c * f, de = d * e, df = d * f; + + te[ 0 ] = ce + df * b; + te[ 4 ] = de * b - cf; + te[ 8 ] = a * d; + + te[ 1 ] = a * f; + te[ 5 ] = a * e; + te[ 9 ] = - b; + + te[ 2 ] = cf * b - de; + te[ 6 ] = df + ce * b; + te[ 10 ] = a * c; + + } else if ( euler.order === 'ZXY' ) { + + const ce = c * e, cf = c * f, de = d * e, df = d * f; + + te[ 0 ] = ce - df * b; + te[ 4 ] = - a * f; + te[ 8 ] = de + cf * b; + + te[ 1 ] = cf + de * b; + te[ 5 ] = a * e; + te[ 9 ] = df - ce * b; + + te[ 2 ] = - a * d; + te[ 6 ] = b; + te[ 10 ] = a * c; + + } else if ( euler.order === 'ZYX' ) { + + const ae = a * e, af = a * f, be = b * e, bf = b * f; + + te[ 0 ] = c * e; + te[ 4 ] = be * d - af; + te[ 8 ] = ae * d + bf; + + te[ 1 ] = c * f; + te[ 5 ] = bf * d + ae; + te[ 9 ] = af * d - be; + + te[ 2 ] = - d; + te[ 6 ] = b * c; + te[ 10 ] = a * c; + + } else if ( euler.order === 'YZX' ) { + + const ac = a * c, ad = a * d, bc = b * c, bd = b * d; + + te[ 0 ] = c * e; + te[ 4 ] = bd - ac * f; + te[ 8 ] = bc * f + ad; + + te[ 1 ] = f; + te[ 5 ] = a * e; + te[ 9 ] = - b * e; + + te[ 2 ] = - d * e; + te[ 6 ] = ad * f + bc; + te[ 10 ] = ac - bd * f; + + } else if ( euler.order === 'XZY' ) { + + const ac = a * c, ad = a * d, bc = b * c, bd = b * d; + + te[ 0 ] = c * e; + te[ 4 ] = - f; + te[ 8 ] = d * e; + + te[ 1 ] = ac * f + bd; + te[ 5 ] = a * e; + te[ 9 ] = ad * f - bc; + + te[ 2 ] = bc * f - ad; + te[ 6 ] = b * e; + te[ 10 ] = bd * f + ac; + + } + + // bottom row + te[ 3 ] = 0; + te[ 7 ] = 0; + te[ 11 ] = 0; + + // last column + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; + + return this; + + } + + makeRotationFromQuaternion( q ) { + + return this.compose( _zero, q, _one ); + + } + + lookAt( eye, target, up ) { + + const te = this.elements; + + _z.subVectors( eye, target ); + + if ( _z.lengthSq() === 0 ) { + + // eye and target are in the same position + + _z.z = 1; + + } + + _z.normalize(); + _x.crossVectors( up, _z ); + + if ( _x.lengthSq() === 0 ) { + + // up and z are parallel + + if ( Math.abs( up.z ) === 1 ) { + + _z.x += 0.0001; + + } else { + + _z.z += 0.0001; + + } + + _z.normalize(); + _x.crossVectors( up, _z ); + + } + + _x.normalize(); + _y.crossVectors( _z, _x ); + + te[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x; + te[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y; + te[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z; + + return this; + + } + + multiply( m, n ) { + + if ( n !== undefined ) { + + console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' ); + return this.multiplyMatrices( m, n ); + + } + + return this.multiplyMatrices( this, m ); + + } + + premultiply( m ) { + + return this.multiplyMatrices( m, this ); + + } + + multiplyMatrices( a, b ) { + + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ]; + const a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ]; + const a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ]; + const a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ]; + + const b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ]; + const b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ]; + const b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ]; + const b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ]; + + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; + te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; + te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; + te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; + + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; + te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; + te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; + te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; + + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; + te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; + te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; + te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; + + te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; + te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; + te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; + te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + + return this; + + } + + multiplyScalar( s ) { + + const te = this.elements; + + te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s; + te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s; + te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s; + te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s; + + return this; + + } + + determinant() { + + const te = this.elements; + + const n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ]; + const n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ]; + const n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ]; + const n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ]; + + //TODO: make this more efficient + //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm ) + + return ( + n41 * ( + + n14 * n23 * n32 + - n13 * n24 * n32 + - n14 * n22 * n33 + + n12 * n24 * n33 + + n13 * n22 * n34 + - n12 * n23 * n34 + ) + + n42 * ( + + n11 * n23 * n34 + - n11 * n24 * n33 + + n14 * n21 * n33 + - n13 * n21 * n34 + + n13 * n24 * n31 + - n14 * n23 * n31 + ) + + n43 * ( + + n11 * n24 * n32 + - n11 * n22 * n34 + - n14 * n21 * n32 + + n12 * n21 * n34 + + n14 * n22 * n31 + - n12 * n24 * n31 + ) + + n44 * ( + - n13 * n22 * n31 + - n11 * n23 * n32 + + n11 * n22 * n33 + + n13 * n21 * n32 + - n12 * n21 * n33 + + n12 * n23 * n31 + ) + + ); + + } + + transpose() { + + const te = this.elements; + let tmp; + + tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp; + tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp; + tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp; + + tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp; + tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp; + tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp; + + return this; + + } + + setPosition( x, y, z ) { + + const te = this.elements; + + if ( x.isVector3 ) { + + te[ 12 ] = x.x; + te[ 13 ] = x.y; + te[ 14 ] = x.z; + + } else { + + te[ 12 ] = x; + te[ 13 ] = y; + te[ 14 ] = z; + + } + + return this; + + } + + invert() { + + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + const te = this.elements, + + n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], n41 = te[ 3 ], + n12 = te[ 4 ], n22 = te[ 5 ], n32 = te[ 6 ], n42 = te[ 7 ], + n13 = te[ 8 ], n23 = te[ 9 ], n33 = te[ 10 ], n43 = te[ 11 ], + n14 = te[ 12 ], n24 = te[ 13 ], n34 = te[ 14 ], n44 = te[ 15 ], + + t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, + t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, + t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, + t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34; + + const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14; + + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); + + const detInv = 1 / det; + + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv; + te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv; + te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv; + + te[ 4 ] = t12 * detInv; + te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv; + te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv; + te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv; + + te[ 8 ] = t13 * detInv; + te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv; + te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv; + te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv; + + te[ 12 ] = t14 * detInv; + te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv; + te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv; + te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv; + + return this; + + } + + scale( v ) { + + const te = this.elements; + const x = v.x, y = v.y, z = v.z; + + te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z; + te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z; + te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z; + te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z; + + return this; + + } + + getMaxScaleOnAxis() { + + const te = this.elements; + + const scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ]; + const scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ]; + const scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ]; + + return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) ); + + } + + makeTranslation( x, y, z ) { + + this.set( + + 1, 0, 0, x, + 0, 1, 0, y, + 0, 0, 1, z, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationX( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + 1, 0, 0, 0, + 0, c, - s, 0, + 0, s, c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationY( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + c, 0, s, 0, + 0, 1, 0, 0, + - s, 0, c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationZ( theta ) { + + const c = Math.cos( theta ), s = Math.sin( theta ); + + this.set( + + c, - s, 0, 0, + s, c, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeRotationAxis( axis, angle ) { + + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + const c = Math.cos( angle ); + const s = Math.sin( angle ); + const t = 1 - c; + const x = axis.x, y = axis.y, z = axis.z; + const tx = t * x, ty = t * y; + + this.set( + + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeScale( x, y, z ) { + + this.set( + + x, 0, 0, 0, + 0, y, 0, 0, + 0, 0, z, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + makeShear( xy, xz, yx, yz, zx, zy ) { + + this.set( + + 1, yx, zx, 0, + xy, 1, zy, 0, + xz, yz, 1, 0, + 0, 0, 0, 1 + + ); + + return this; + + } + + compose( position, quaternion, scale ) { + + const te = this.elements; + + const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w; + const x2 = x + x, y2 = y + y, z2 = z + z; + const xx = x * x2, xy = x * y2, xz = x * z2; + const yy = y * y2, yz = y * z2, zz = z * z2; + const wx = w * x2, wy = w * y2, wz = w * z2; + + const sx = scale.x, sy = scale.y, sz = scale.z; + + te[ 0 ] = ( 1 - ( yy + zz ) ) * sx; + te[ 1 ] = ( xy + wz ) * sx; + te[ 2 ] = ( xz - wy ) * sx; + te[ 3 ] = 0; + + te[ 4 ] = ( xy - wz ) * sy; + te[ 5 ] = ( 1 - ( xx + zz ) ) * sy; + te[ 6 ] = ( yz + wx ) * sy; + te[ 7 ] = 0; + + te[ 8 ] = ( xz + wy ) * sz; + te[ 9 ] = ( yz - wx ) * sz; + te[ 10 ] = ( 1 - ( xx + yy ) ) * sz; + te[ 11 ] = 0; + + te[ 12 ] = position.x; + te[ 13 ] = position.y; + te[ 14 ] = position.z; + te[ 15 ] = 1; + + return this; + + } + + decompose( position, quaternion, scale ) { + + const te = this.elements; + + let sx = _v1$5.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length(); + const sy = _v1$5.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length(); + const sz = _v1$5.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length(); + + // if determine is negative, we need to invert one scale + const det = this.determinant(); + if ( det < 0 ) sx = - sx; + + position.x = te[ 12 ]; + position.y = te[ 13 ]; + position.z = te[ 14 ]; + + // scale the rotation part + _m1$2.copy( this ); + + const invSX = 1 / sx; + const invSY = 1 / sy; + const invSZ = 1 / sz; + + _m1$2.elements[ 0 ] *= invSX; + _m1$2.elements[ 1 ] *= invSX; + _m1$2.elements[ 2 ] *= invSX; + + _m1$2.elements[ 4 ] *= invSY; + _m1$2.elements[ 5 ] *= invSY; + _m1$2.elements[ 6 ] *= invSY; + + _m1$2.elements[ 8 ] *= invSZ; + _m1$2.elements[ 9 ] *= invSZ; + _m1$2.elements[ 10 ] *= invSZ; + + quaternion.setFromRotationMatrix( _m1$2 ); + + scale.x = sx; + scale.y = sy; + scale.z = sz; + + return this; + + } + + makePerspective( left, right, top, bottom, near, far ) { + + if ( far === undefined ) { + + console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' ); + + } + + const te = this.elements; + const x = 2 * near / ( right - left ); + const y = 2 * near / ( top - bottom ); + + const a = ( right + left ) / ( right - left ); + const b = ( top + bottom ) / ( top - bottom ); + const c = - ( far + near ) / ( far - near ); + const d = - 2 * far * near / ( far - near ); + + te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0; + te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0; + + return this; + + } + + makeOrthographic( left, right, top, bottom, near, far ) { + + const te = this.elements; + const w = 1.0 / ( right - left ); + const h = 1.0 / ( top - bottom ); + const p = 1.0 / ( far - near ); + + const x = ( right + left ) * w; + const y = ( top + bottom ) * h; + const z = ( far + near ) * p; + + te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x; + te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1; + + return this; + + } + + equals( matrix ) { + + const te = this.elements; + const me = matrix.elements; + + for ( let i = 0; i < 16; i ++ ) { + + if ( te[ i ] !== me[ i ] ) return false; + + } + + return true; + + } + + fromArray( array, offset = 0 ) { + + for ( let i = 0; i < 16; i ++ ) { + + this.elements[ i ] = array[ i + offset ]; + + } + + return this; + + } + + toArray( array = [], offset = 0 ) { + + const te = this.elements; + + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + array[ offset + 3 ] = te[ 3 ]; + + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + + array[ offset + 8 ] = te[ 8 ]; + array[ offset + 9 ] = te[ 9 ]; + array[ offset + 10 ] = te[ 10 ]; + array[ offset + 11 ] = te[ 11 ]; + + array[ offset + 12 ] = te[ 12 ]; + array[ offset + 13 ] = te[ 13 ]; + array[ offset + 14 ] = te[ 14 ]; + array[ offset + 15 ] = te[ 15 ]; + + return array; + + } + +} + +Matrix4.prototype.isMatrix4 = true; + +const _v1$5 = /*@__PURE__*/ new Vector3(); +const _m1$2 = /*@__PURE__*/ new Matrix4(); +const _zero = /*@__PURE__*/ new Vector3( 0, 0, 0 ); +const _one = /*@__PURE__*/ new Vector3( 1, 1, 1 ); +const _x = /*@__PURE__*/ new Vector3(); +const _y = /*@__PURE__*/ new Vector3(); +const _z = /*@__PURE__*/ new Vector3(); + +const _matrix$1 = /*@__PURE__*/ new Matrix4(); +const _quaternion$3 = /*@__PURE__*/ new Quaternion(); + +class Euler { + + constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) { + + this._x = x; + this._y = y; + this._z = z; + this._order = order; + + } + + get x() { + + return this._x; + + } + + set x( value ) { + + this._x = value; + this._onChangeCallback(); + + } + + get y() { + + return this._y; + + } + + set y( value ) { + + this._y = value; + this._onChangeCallback(); + + } + + get z() { + + return this._z; + + } + + set z( value ) { + + this._z = value; + this._onChangeCallback(); + + } + + get order() { + + return this._order; + + } + + set order( value ) { + + this._order = value; + this._onChangeCallback(); + + } + + set( x, y, z, order = this._order ) { + + this._x = x; + this._y = y; + this._z = z; + this._order = order; + + this._onChangeCallback(); + + return this; + + } + + clone() { + + return new this.constructor( this._x, this._y, this._z, this._order ); + + } + + copy( euler ) { + + this._x = euler._x; + this._y = euler._y; + this._z = euler._z; + this._order = euler._order; + + this._onChangeCallback(); + + return this; + + } + + setFromRotationMatrix( m, order = this._order, update = true ) { + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements; + const m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ]; + const m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ]; + const m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; + + switch ( order ) { + + case 'XYZ': + + this._y = Math.asin( clamp( m13, - 1, 1 ) ); + + if ( Math.abs( m13 ) < 0.9999999 ) { + + this._x = Math.atan2( - m23, m33 ); + this._z = Math.atan2( - m12, m11 ); + + } else { + + this._x = Math.atan2( m32, m22 ); + this._z = 0; + + } + + break; + + case 'YXZ': + + this._x = Math.asin( - clamp( m23, - 1, 1 ) ); + + if ( Math.abs( m23 ) < 0.9999999 ) { + + this._y = Math.atan2( m13, m33 ); + this._z = Math.atan2( m21, m22 ); + + } else { + + this._y = Math.atan2( - m31, m11 ); + this._z = 0; + + } + + break; + + case 'ZXY': + + this._x = Math.asin( clamp( m32, - 1, 1 ) ); + + if ( Math.abs( m32 ) < 0.9999999 ) { + + this._y = Math.atan2( - m31, m33 ); + this._z = Math.atan2( - m12, m22 ); + + } else { + + this._y = 0; + this._z = Math.atan2( m21, m11 ); + + } + + break; + + case 'ZYX': + + this._y = Math.asin( - clamp( m31, - 1, 1 ) ); + + if ( Math.abs( m31 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m33 ); + this._z = Math.atan2( m21, m11 ); + + } else { + + this._x = 0; + this._z = Math.atan2( - m12, m22 ); + + } + + break; + + case 'YZX': + + this._z = Math.asin( clamp( m21, - 1, 1 ) ); + + if ( Math.abs( m21 ) < 0.9999999 ) { + + this._x = Math.atan2( - m23, m22 ); + this._y = Math.atan2( - m31, m11 ); + + } else { + + this._x = 0; + this._y = Math.atan2( m13, m33 ); + + } + + break; + + case 'XZY': + + this._z = Math.asin( - clamp( m12, - 1, 1 ) ); + + if ( Math.abs( m12 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m22 ); + this._y = Math.atan2( m13, m11 ); + + } else { + + this._x = Math.atan2( - m23, m33 ); + this._y = 0; + + } + + break; + + default: + + console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order ); + + } + + this._order = order; + + if ( update === true ) this._onChangeCallback(); + + return this; + + } + + setFromQuaternion( q, order, update ) { + + _matrix$1.makeRotationFromQuaternion( q ); + + return this.setFromRotationMatrix( _matrix$1, order, update ); + + } + + setFromVector3( v, order = this._order ) { + + return this.set( v.x, v.y, v.z, order ); + + } + + reorder( newOrder ) { + + // WARNING: this discards revolution information -bhouston + + _quaternion$3.setFromEuler( this ); + + return this.setFromQuaternion( _quaternion$3, newOrder ); + + } + + equals( euler ) { + + return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order ); + + } + + fromArray( array ) { + + this._x = array[ 0 ]; + this._y = array[ 1 ]; + this._z = array[ 2 ]; + if ( array[ 3 ] !== undefined ) this._order = array[ 3 ]; + + this._onChangeCallback(); + + return this; + + } + + toArray( array = [], offset = 0 ) { + + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._order; + + return array; + + } + + toVector3( optionalResult ) { + + if ( optionalResult ) { + + return optionalResult.set( this._x, this._y, this._z ); + + } else { + + return new Vector3( this._x, this._y, this._z ); + + } + + } + + _onChange( callback ) { + + this._onChangeCallback = callback; + + return this; + + } + + _onChangeCallback() {} + +} + +Euler.prototype.isEuler = true; + +Euler.DefaultOrder = 'XYZ'; +Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ]; + +class Layers { + + constructor() { + + this.mask = 1 | 0; + + } + + set( channel ) { + + this.mask = ( 1 << channel | 0 ) >>> 0; + + } + + enable( channel ) { + + this.mask |= 1 << channel | 0; + + } + + enableAll() { + + this.mask = 0xffffffff | 0; + + } + + toggle( channel ) { + + this.mask ^= 1 << channel | 0; + + } + + disable( channel ) { + + this.mask &= ~ ( 1 << channel | 0 ); + + } + + disableAll() { + + this.mask = 0; + + } + + test( layers ) { + + return ( this.mask & layers.mask ) !== 0; + + } + + isEnabled( channel ) { + + return ( this.mask & ( 1 << channel | 0 ) ) !== 0; + + } + +} + +let _object3DId = 0; + +const _v1$4 = /*@__PURE__*/ new Vector3(); +const _q1 = /*@__PURE__*/ new Quaternion(); +const _m1$1 = /*@__PURE__*/ new Matrix4(); +const _target = /*@__PURE__*/ new Vector3(); + +const _position$3 = /*@__PURE__*/ new Vector3(); +const _scale$2 = /*@__PURE__*/ new Vector3(); +const _quaternion$2 = /*@__PURE__*/ new Quaternion(); + +const _xAxis = /*@__PURE__*/ new Vector3( 1, 0, 0 ); +const _yAxis = /*@__PURE__*/ new Vector3( 0, 1, 0 ); +const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 ); + +const _addedEvent = { type: 'added' }; +const _removedEvent = { type: 'removed' }; + +class Object3D extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: _object3DId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'Object3D'; + + this.parent = null; + this.children = []; + + this.up = Object3D.DefaultUp.clone(); + + const position = new Vector3(); + const rotation = new Euler(); + const quaternion = new Quaternion(); + const scale = new Vector3( 1, 1, 1 ); + + function onRotationChange() { + + quaternion.setFromEuler( rotation, false ); + + } + + function onQuaternionChange() { + + rotation.setFromQuaternion( quaternion, undefined, false ); + + } + + rotation._onChange( onRotationChange ); + quaternion._onChange( onQuaternionChange ); + + Object.defineProperties( this, { + position: { + configurable: true, + enumerable: true, + value: position + }, + rotation: { + configurable: true, + enumerable: true, + value: rotation + }, + quaternion: { + configurable: true, + enumerable: true, + value: quaternion + }, + scale: { + configurable: true, + enumerable: true, + value: scale + }, + modelViewMatrix: { + value: new Matrix4() + }, + normalMatrix: { + value: new Matrix3() + } + } ); + + this.matrix = new Matrix4(); + this.matrixWorld = new Matrix4(); + + this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate; + this.matrixWorldNeedsUpdate = false; + + this.layers = new Layers(); + this.visible = true; + + this.castShadow = false; + this.receiveShadow = false; + + this.frustumCulled = true; + this.renderOrder = 0; + + this.animations = []; + + this.userData = {}; + + } + + onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {} + + onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {} + + applyMatrix4( matrix ) { + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + this.matrix.premultiply( matrix ); + + this.matrix.decompose( this.position, this.quaternion, this.scale ); + + } + + applyQuaternion( q ) { + + this.quaternion.premultiply( q ); + + return this; + + } + + setRotationFromAxisAngle( axis, angle ) { + + // assumes axis is normalized + + this.quaternion.setFromAxisAngle( axis, angle ); + + } + + setRotationFromEuler( euler ) { + + this.quaternion.setFromEuler( euler, true ); + + } + + setRotationFromMatrix( m ) { + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + this.quaternion.setFromRotationMatrix( m ); + + } + + setRotationFromQuaternion( q ) { + + // assumes q is normalized + + this.quaternion.copy( q ); + + } + + rotateOnAxis( axis, angle ) { + + // rotate object on axis in object space + // axis is assumed to be normalized + + _q1.setFromAxisAngle( axis, angle ); + + this.quaternion.multiply( _q1 ); + + return this; + + } + + rotateOnWorldAxis( axis, angle ) { + + // rotate object on axis in world space + // axis is assumed to be normalized + // method assumes no rotated parent + + _q1.setFromAxisAngle( axis, angle ); + + this.quaternion.premultiply( _q1 ); + + return this; + + } + + rotateX( angle ) { + + return this.rotateOnAxis( _xAxis, angle ); + + } + + rotateY( angle ) { + + return this.rotateOnAxis( _yAxis, angle ); + + } + + rotateZ( angle ) { + + return this.rotateOnAxis( _zAxis, angle ); + + } + + translateOnAxis( axis, distance ) { + + // translate object by distance along axis in object space + // axis is assumed to be normalized + + _v1$4.copy( axis ).applyQuaternion( this.quaternion ); + + this.position.add( _v1$4.multiplyScalar( distance ) ); + + return this; + + } + + translateX( distance ) { + + return this.translateOnAxis( _xAxis, distance ); + + } + + translateY( distance ) { + + return this.translateOnAxis( _yAxis, distance ); + + } + + translateZ( distance ) { + + return this.translateOnAxis( _zAxis, distance ); + + } + + localToWorld( vector ) { + + return vector.applyMatrix4( this.matrixWorld ); + + } + + worldToLocal( vector ) { + + return vector.applyMatrix4( _m1$1.copy( this.matrixWorld ).invert() ); + + } + + lookAt( x, y, z ) { + + // This method does not support objects having non-uniformly-scaled parent(s) + + if ( x.isVector3 ) { + + _target.copy( x ); + + } else { + + _target.set( x, y, z ); + + } + + const parent = this.parent; + + this.updateWorldMatrix( true, false ); + + _position$3.setFromMatrixPosition( this.matrixWorld ); + + if ( this.isCamera || this.isLight ) { + + _m1$1.lookAt( _position$3, _target, this.up ); + + } else { + + _m1$1.lookAt( _target, _position$3, this.up ); + + } + + this.quaternion.setFromRotationMatrix( _m1$1 ); + + if ( parent ) { + + _m1$1.extractRotation( parent.matrixWorld ); + _q1.setFromRotationMatrix( _m1$1 ); + this.quaternion.premultiply( _q1.invert() ); + + } + + } + + add( object ) { + + if ( arguments.length > 1 ) { + + for ( let i = 0; i < arguments.length; i ++ ) { + + this.add( arguments[ i ] ); + + } + + return this; + + } + + if ( object === this ) { + + console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object ); + return this; + + } + + if ( object && object.isObject3D ) { + + if ( object.parent !== null ) { + + object.parent.remove( object ); + + } + + object.parent = this; + this.children.push( object ); + + object.dispatchEvent( _addedEvent ); + + } else { + + console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object ); + + } + + return this; + + } + + remove( object ) { + + if ( arguments.length > 1 ) { + + for ( let i = 0; i < arguments.length; i ++ ) { + + this.remove( arguments[ i ] ); + + } + + return this; + + } + + const index = this.children.indexOf( object ); + + if ( index !== - 1 ) { + + object.parent = null; + this.children.splice( index, 1 ); + + object.dispatchEvent( _removedEvent ); + + } + + return this; + + } + + removeFromParent() { + + const parent = this.parent; + + if ( parent !== null ) { + + parent.remove( this ); + + } + + return this; + + } + + clear() { + + for ( let i = 0; i < this.children.length; i ++ ) { + + const object = this.children[ i ]; + + object.parent = null; + + object.dispatchEvent( _removedEvent ); + + } + + this.children.length = 0; + + return this; + + + } + + attach( object ) { + + // adds object as a child of this, while maintaining the object's world transform + + // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s) + + this.updateWorldMatrix( true, false ); + + _m1$1.copy( this.matrixWorld ).invert(); + + if ( object.parent !== null ) { + + object.parent.updateWorldMatrix( true, false ); + + _m1$1.multiply( object.parent.matrixWorld ); + + } + + object.applyMatrix4( _m1$1 ); + + this.add( object ); + + object.updateWorldMatrix( false, true ); + + return this; + + } + + getObjectById( id ) { + + return this.getObjectByProperty( 'id', id ); + + } + + getObjectByName( name ) { + + return this.getObjectByProperty( 'name', name ); + + } + + getObjectByProperty( name, value ) { + + if ( this[ name ] === value ) return this; + + for ( let i = 0, l = this.children.length; i < l; i ++ ) { + + const child = this.children[ i ]; + const object = child.getObjectByProperty( name, value ); + + if ( object !== undefined ) { + + return object; + + } + + } + + return undefined; + + } + + getWorldPosition( target ) { + + this.updateWorldMatrix( true, false ); + + return target.setFromMatrixPosition( this.matrixWorld ); + + } + + getWorldQuaternion( target ) { + + this.updateWorldMatrix( true, false ); + + this.matrixWorld.decompose( _position$3, target, _scale$2 ); + + return target; + + } + + getWorldScale( target ) { + + this.updateWorldMatrix( true, false ); + + this.matrixWorld.decompose( _position$3, _quaternion$2, target ); + + return target; + + } + + getWorldDirection( target ) { + + this.updateWorldMatrix( true, false ); + + const e = this.matrixWorld.elements; + + return target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize(); + + } + + raycast( /* raycaster, intersects */ ) {} + + traverse( callback ) { + + callback( this ); + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].traverse( callback ); + + } + + } + + traverseVisible( callback ) { + + if ( this.visible === false ) return; + + callback( this ); + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].traverseVisible( callback ); + + } + + } + + traverseAncestors( callback ) { + + const parent = this.parent; + + if ( parent !== null ) { + + callback( parent ); + + parent.traverseAncestors( callback ); + + } + + } + + updateMatrix() { + + this.matrix.compose( this.position, this.quaternion, this.scale ); + + this.matrixWorldNeedsUpdate = true; + + } + + updateMatrixWorld( force ) { + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + if ( this.matrixWorldNeedsUpdate || force ) { + + if ( this.parent === null ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + this.matrixWorldNeedsUpdate = false; + + force = true; + + } + + // update children + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateMatrixWorld( force ); + + } + + } + + updateWorldMatrix( updateParents, updateChildren ) { + + const parent = this.parent; + + if ( updateParents === true && parent !== null ) { + + parent.updateWorldMatrix( true, false ); + + } + + if ( this.matrixAutoUpdate ) this.updateMatrix(); + + if ( this.parent === null ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + // update children + + if ( updateChildren === true ) { + + const children = this.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateWorldMatrix( false, true ); + + } + + } + + } + + toJSON( meta ) { + + // meta is a string when called from JSON.stringify + const isRootObject = ( meta === undefined || typeof meta === 'string' ); + + const output = {}; + + // meta is a hash used to collect geometries, materials. + // not providing it implies that this is the root object + // being serialized. + if ( isRootObject ) { + + // initialize meta obj + meta = { + geometries: {}, + materials: {}, + textures: {}, + images: {}, + shapes: {}, + skeletons: {}, + animations: {} + }; + + output.metadata = { + version: 4.5, + type: 'Object', + generator: 'Object3D.toJSON' + }; + + } + + // standard Object3D serialization + + const object = {}; + + object.uuid = this.uuid; + object.type = this.type; + + if ( this.name !== '' ) object.name = this.name; + if ( this.castShadow === true ) object.castShadow = true; + if ( this.receiveShadow === true ) object.receiveShadow = true; + if ( this.visible === false ) object.visible = false; + if ( this.frustumCulled === false ) object.frustumCulled = false; + if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder; + if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData; + + object.layers = this.layers.mask; + object.matrix = this.matrix.toArray(); + + if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false; + + // object specific properties + + if ( this.isInstancedMesh ) { + + object.type = 'InstancedMesh'; + object.count = this.count; + object.instanceMatrix = this.instanceMatrix.toJSON(); + if ( this.instanceColor !== null ) object.instanceColor = this.instanceColor.toJSON(); + + } + + // + + function serialize( library, element ) { + + if ( library[ element.uuid ] === undefined ) { + + library[ element.uuid ] = element.toJSON( meta ); + + } + + return element.uuid; + + } + + if ( this.isScene ) { + + if ( this.background ) { + + if ( this.background.isColor ) { + + object.background = this.background.toJSON(); + + } else if ( this.background.isTexture ) { + + object.background = this.background.toJSON( meta ).uuid; + + } + + } + + if ( this.environment && this.environment.isTexture ) { + + object.environment = this.environment.toJSON( meta ).uuid; + + } + + } else if ( this.isMesh || this.isLine || this.isPoints ) { + + object.geometry = serialize( meta.geometries, this.geometry ); + + const parameters = this.geometry.parameters; + + if ( parameters !== undefined && parameters.shapes !== undefined ) { + + const shapes = parameters.shapes; + + if ( Array.isArray( shapes ) ) { + + for ( let i = 0, l = shapes.length; i < l; i ++ ) { + + const shape = shapes[ i ]; + + serialize( meta.shapes, shape ); + + } + + } else { + + serialize( meta.shapes, shapes ); + + } + + } + + } + + if ( this.isSkinnedMesh ) { + + object.bindMode = this.bindMode; + object.bindMatrix = this.bindMatrix.toArray(); + + if ( this.skeleton !== undefined ) { + + serialize( meta.skeletons, this.skeleton ); + + object.skeleton = this.skeleton.uuid; + + } + + } + + if ( this.material !== undefined ) { + + if ( Array.isArray( this.material ) ) { + + const uuids = []; + + for ( let i = 0, l = this.material.length; i < l; i ++ ) { + + uuids.push( serialize( meta.materials, this.material[ i ] ) ); + + } + + object.material = uuids; + + } else { + + object.material = serialize( meta.materials, this.material ); + + } + + } + + // + + if ( this.children.length > 0 ) { + + object.children = []; + + for ( let i = 0; i < this.children.length; i ++ ) { + + object.children.push( this.children[ i ].toJSON( meta ).object ); + + } + + } + + // + + if ( this.animations.length > 0 ) { + + object.animations = []; + + for ( let i = 0; i < this.animations.length; i ++ ) { + + const animation = this.animations[ i ]; + + object.animations.push( serialize( meta.animations, animation ) ); + + } + + } + + if ( isRootObject ) { + + const geometries = extractFromCache( meta.geometries ); + const materials = extractFromCache( meta.materials ); + const textures = extractFromCache( meta.textures ); + const images = extractFromCache( meta.images ); + const shapes = extractFromCache( meta.shapes ); + const skeletons = extractFromCache( meta.skeletons ); + const animations = extractFromCache( meta.animations ); + + if ( geometries.length > 0 ) output.geometries = geometries; + if ( materials.length > 0 ) output.materials = materials; + if ( textures.length > 0 ) output.textures = textures; + if ( images.length > 0 ) output.images = images; + if ( shapes.length > 0 ) output.shapes = shapes; + if ( skeletons.length > 0 ) output.skeletons = skeletons; + if ( animations.length > 0 ) output.animations = animations; + + } + + output.object = object; + + return output; + + // extract data from the cache hash + // remove metadata on each item + // and return as array + function extractFromCache( cache ) { + + const values = []; + for ( const key in cache ) { + + const data = cache[ key ]; + delete data.metadata; + values.push( data ); + + } + + return values; + + } + + } + + clone( recursive ) { + + return new this.constructor().copy( this, recursive ); + + } + + copy( source, recursive = true ) { + + this.name = source.name; + + this.up.copy( source.up ); + + this.position.copy( source.position ); + this.rotation.order = source.rotation.order; + this.quaternion.copy( source.quaternion ); + this.scale.copy( source.scale ); + + this.matrix.copy( source.matrix ); + this.matrixWorld.copy( source.matrixWorld ); + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate; + + this.layers.mask = source.layers.mask; + this.visible = source.visible; + + this.castShadow = source.castShadow; + this.receiveShadow = source.receiveShadow; + + this.frustumCulled = source.frustumCulled; + this.renderOrder = source.renderOrder; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + if ( recursive === true ) { + + for ( let i = 0; i < source.children.length; i ++ ) { + + const child = source.children[ i ]; + this.add( child.clone() ); + + } + + } + + return this; + + } + +} + +Object3D.DefaultUp = new Vector3( 0, 1, 0 ); +Object3D.DefaultMatrixAutoUpdate = true; + +Object3D.prototype.isObject3D = true; + +const _v0$1 = /*@__PURE__*/ new Vector3(); +const _v1$3 = /*@__PURE__*/ new Vector3(); +const _v2$2 = /*@__PURE__*/ new Vector3(); +const _v3$1 = /*@__PURE__*/ new Vector3(); + +const _vab = /*@__PURE__*/ new Vector3(); +const _vac = /*@__PURE__*/ new Vector3(); +const _vbc = /*@__PURE__*/ new Vector3(); +const _vap = /*@__PURE__*/ new Vector3(); +const _vbp = /*@__PURE__*/ new Vector3(); +const _vcp = /*@__PURE__*/ new Vector3(); + +class Triangle { + + constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) { + + this.a = a; + this.b = b; + this.c = c; + + } + + static getNormal( a, b, c, target ) { + + target.subVectors( c, b ); + _v0$1.subVectors( a, b ); + target.cross( _v0$1 ); + + const targetLengthSq = target.lengthSq(); + if ( targetLengthSq > 0 ) { + + return target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) ); + + } + + return target.set( 0, 0, 0 ); + + } + + // static/instance method to calculate barycentric coordinates + // based on: http://www.blackpawn.com/texts/pointinpoly/default.html + static getBarycoord( point, a, b, c, target ) { + + _v0$1.subVectors( c, a ); + _v1$3.subVectors( b, a ); + _v2$2.subVectors( point, a ); + + const dot00 = _v0$1.dot( _v0$1 ); + const dot01 = _v0$1.dot( _v1$3 ); + const dot02 = _v0$1.dot( _v2$2 ); + const dot11 = _v1$3.dot( _v1$3 ); + const dot12 = _v1$3.dot( _v2$2 ); + + const denom = ( dot00 * dot11 - dot01 * dot01 ); + + // collinear or singular triangle + if ( denom === 0 ) { + + // arbitrary location outside of triangle? + // not sure if this is the best idea, maybe should be returning undefined + return target.set( - 2, - 1, - 1 ); + + } + + const invDenom = 1 / denom; + const u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom; + const v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom; + + // barycentric coordinates must always sum to 1 + return target.set( 1 - u - v, v, u ); + + } + + static containsPoint( point, a, b, c ) { + + this.getBarycoord( point, a, b, c, _v3$1 ); + + return ( _v3$1.x >= 0 ) && ( _v3$1.y >= 0 ) && ( ( _v3$1.x + _v3$1.y ) <= 1 ); + + } + + static getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) { + + this.getBarycoord( point, p1, p2, p3, _v3$1 ); + + target.set( 0, 0 ); + target.addScaledVector( uv1, _v3$1.x ); + target.addScaledVector( uv2, _v3$1.y ); + target.addScaledVector( uv3, _v3$1.z ); + + return target; + + } + + static isFrontFacing( a, b, c, direction ) { + + _v0$1.subVectors( c, b ); + _v1$3.subVectors( a, b ); + + // strictly front facing + return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false; + + } + + set( a, b, c ) { + + this.a.copy( a ); + this.b.copy( b ); + this.c.copy( c ); + + return this; + + } + + setFromPointsAndIndices( points, i0, i1, i2 ) { + + this.a.copy( points[ i0 ] ); + this.b.copy( points[ i1 ] ); + this.c.copy( points[ i2 ] ); + + return this; + + } + + setFromAttributeAndIndices( attribute, i0, i1, i2 ) { + + this.a.fromBufferAttribute( attribute, i0 ); + this.b.fromBufferAttribute( attribute, i1 ); + this.c.fromBufferAttribute( attribute, i2 ); + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( triangle ) { + + this.a.copy( triangle.a ); + this.b.copy( triangle.b ); + this.c.copy( triangle.c ); + + return this; + + } + + getArea() { + + _v0$1.subVectors( this.c, this.b ); + _v1$3.subVectors( this.a, this.b ); + + return _v0$1.cross( _v1$3 ).length() * 0.5; + + } + + getMidpoint( target ) { + + return target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 ); + + } + + getNormal( target ) { + + return Triangle.getNormal( this.a, this.b, this.c, target ); + + } + + getPlane( target ) { + + return target.setFromCoplanarPoints( this.a, this.b, this.c ); + + } + + getBarycoord( point, target ) { + + return Triangle.getBarycoord( point, this.a, this.b, this.c, target ); + + } + + getUV( point, uv1, uv2, uv3, target ) { + + return Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target ); + + } + + containsPoint( point ) { + + return Triangle.containsPoint( point, this.a, this.b, this.c ); + + } + + isFrontFacing( direction ) { + + return Triangle.isFrontFacing( this.a, this.b, this.c, direction ); + + } + + intersectsBox( box ) { + + return box.intersectsTriangle( this ); + + } + + closestPointToPoint( p, target ) { + + const a = this.a, b = this.b, c = this.c; + let v, w; + + // algorithm thanks to Real-Time Collision Detection by Christer Ericson, + // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc., + // under the accompanying license; see chapter 5.1.5 for detailed explanation. + // basically, we're distinguishing which of the voronoi regions of the triangle + // the point lies in with the minimum amount of redundant computation. + + _vab.subVectors( b, a ); + _vac.subVectors( c, a ); + _vap.subVectors( p, a ); + const d1 = _vab.dot( _vap ); + const d2 = _vac.dot( _vap ); + if ( d1 <= 0 && d2 <= 0 ) { + + // vertex region of A; barycentric coords (1, 0, 0) + return target.copy( a ); + + } + + _vbp.subVectors( p, b ); + const d3 = _vab.dot( _vbp ); + const d4 = _vac.dot( _vbp ); + if ( d3 >= 0 && d4 <= d3 ) { + + // vertex region of B; barycentric coords (0, 1, 0) + return target.copy( b ); + + } + + const vc = d1 * d4 - d3 * d2; + if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) { + + v = d1 / ( d1 - d3 ); + // edge region of AB; barycentric coords (1-v, v, 0) + return target.copy( a ).addScaledVector( _vab, v ); + + } + + _vcp.subVectors( p, c ); + const d5 = _vab.dot( _vcp ); + const d6 = _vac.dot( _vcp ); + if ( d6 >= 0 && d5 <= d6 ) { + + // vertex region of C; barycentric coords (0, 0, 1) + return target.copy( c ); + + } + + const vb = d5 * d2 - d1 * d6; + if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) { + + w = d2 / ( d2 - d6 ); + // edge region of AC; barycentric coords (1-w, 0, w) + return target.copy( a ).addScaledVector( _vac, w ); + + } + + const va = d3 * d6 - d5 * d4; + if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) { + + _vbc.subVectors( c, b ); + w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) ); + // edge region of BC; barycentric coords (0, 1-w, w) + return target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC + + } + + // face region + const denom = 1 / ( va + vb + vc ); + // u = va * denom + v = vb * denom; + w = vc * denom; + + return target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w ); + + } + + equals( triangle ) { + + return triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c ); + + } + +} + +let materialId = 0; + +class Material extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: materialId ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'Material'; + + this.fog = true; + + this.blending = NormalBlending; + this.side = FrontSide; + this.vertexColors = false; + + this.opacity = 1; + this.transparent = false; + + this.blendSrc = SrcAlphaFactor; + this.blendDst = OneMinusSrcAlphaFactor; + this.blendEquation = AddEquation; + this.blendSrcAlpha = null; + this.blendDstAlpha = null; + this.blendEquationAlpha = null; + + this.depthFunc = LessEqualDepth; + this.depthTest = true; + this.depthWrite = true; + + this.stencilWriteMask = 0xff; + this.stencilFunc = AlwaysStencilFunc; + this.stencilRef = 0; + this.stencilFuncMask = 0xff; + this.stencilFail = KeepStencilOp; + this.stencilZFail = KeepStencilOp; + this.stencilZPass = KeepStencilOp; + this.stencilWrite = false; + + this.clippingPlanes = null; + this.clipIntersection = false; + this.clipShadows = false; + + this.shadowSide = null; + + this.colorWrite = true; + this.alphaWrite = true; + + this.precision = null; // override the renderer's default precision for this material + + this.polygonOffset = false; + this.polygonOffsetFactor = 0; + this.polygonOffsetUnits = 0; + + this.dithering = false; + + this.alphaToCoverage = false; + this.premultipliedAlpha = false; + + this.visible = true; + + this.toneMapped = true; + + this.userData = {}; + + this.version = 0; + + this._alphaTest = 0; + + } + + get alphaTest() { + + return this._alphaTest; + + } + + set alphaTest( value ) { + + if ( this._alphaTest > 0 !== value > 0 ) { + + this.version ++; + + } + + this._alphaTest = value; + + } + + onBuild( /* shaderobject, renderer */ ) {} + + onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {} + + onBeforeCompile( /* shaderobject, renderer */ ) {} + + customProgramCacheKey() { + + return this.onBeforeCompile.toString(); + + } + + setValues( values ) { + + if ( values === undefined ) return; + + for ( const key in values ) { + + const newValue = values[ key ]; + + if ( newValue === undefined ) { + + console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' ); + continue; + + } + + // for backward compatability if shading is set in the constructor + if ( key === 'shading' ) { + + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( newValue === FlatShading ) ? true : false; + continue; + + } + + const currentValue = this[ key ]; + + if ( currentValue === undefined ) { + + console.warn( 'THREE.' + this.type + ': \'' + key + '\' is not a property of this material.' ); + continue; + + } + + if ( currentValue && currentValue.isColor ) { + + currentValue.set( newValue ); + + } else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) { + + currentValue.copy( newValue ); + + } else { + + this[ key ] = newValue; + + } + + } + + } + + toJSON( meta ) { + + const isRoot = ( meta === undefined || typeof meta === 'string' ); + + if ( isRoot ) { + + meta = { + textures: {}, + images: {} + }; + + } + + const data = { + metadata: { + version: 4.5, + type: 'Material', + generator: 'Material.toJSON' + } + }; + + // standard Material serialization + data.uuid = this.uuid; + data.type = this.type; + + if ( this.name !== '' ) data.name = this.name; + + if ( this.color && this.color.isColor ) data.color = this.color.getHex(); + + if ( this.roughness !== undefined ) data.roughness = this.roughness; + if ( this.metalness !== undefined ) data.metalness = this.metalness; + + if ( this.sheen !== undefined ) data.sheen = this.sheen; + if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex(); + if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness; + if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex(); + if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity; + + if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex(); + if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity; + if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex(); + if ( this.shininess !== undefined ) data.shininess = this.shininess; + if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat; + if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness; + + if ( this.clearcoatMap && this.clearcoatMap.isTexture ) { + + data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) { + + data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) { + + data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid; + data.clearcoatNormalScale = this.clearcoatNormalScale.toArray(); + + } + + if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid; + if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid; + if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; + + if ( this.lightMap && this.lightMap.isTexture ) { + + data.lightMap = this.lightMap.toJSON( meta ).uuid; + data.lightMapIntensity = this.lightMapIntensity; + + } + + if ( this.aoMap && this.aoMap.isTexture ) { + + data.aoMap = this.aoMap.toJSON( meta ).uuid; + data.aoMapIntensity = this.aoMapIntensity; + + } + + if ( this.bumpMap && this.bumpMap.isTexture ) { + + data.bumpMap = this.bumpMap.toJSON( meta ).uuid; + data.bumpScale = this.bumpScale; + + } + + if ( this.normalMap && this.normalMap.isTexture ) { + + data.normalMap = this.normalMap.toJSON( meta ).uuid; + data.normalMapType = this.normalMapType; + data.normalScale = this.normalScale.toArray(); + + } + + if ( this.displacementMap && this.displacementMap.isTexture ) { + + data.displacementMap = this.displacementMap.toJSON( meta ).uuid; + data.displacementScale = this.displacementScale; + data.displacementBias = this.displacementBias; + + } + + if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid; + if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid; + + if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid; + if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid; + if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid; + if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid; + + if ( this.envMap && this.envMap.isTexture ) { + + data.envMap = this.envMap.toJSON( meta ).uuid; + + if ( this.combine !== undefined ) data.combine = this.combine; + + } + + if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity; + if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity; + if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio; + + if ( this.gradientMap && this.gradientMap.isTexture ) { + + data.gradientMap = this.gradientMap.toJSON( meta ).uuid; + + } + + if ( this.transmission !== undefined ) data.transmission = this.transmission; + if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid; + if ( this.thickness !== undefined ) data.thickness = this.thickness; + if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid; + if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance; + if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex(); + + if ( this.size !== undefined ) data.size = this.size; + if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide; + if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; + + if ( this.blending !== NormalBlending ) data.blending = this.blending; + if ( this.side !== FrontSide ) data.side = this.side; + if ( this.vertexColors ) data.vertexColors = true; + + if ( this.opacity < 1 ) data.opacity = this.opacity; + if ( this.transparent === true ) data.transparent = this.transparent; + + data.depthFunc = this.depthFunc; + data.depthTest = this.depthTest; + data.depthWrite = this.depthWrite; + data.colorWrite = this.colorWrite; + data.alphaWrite = this.alphaWrite; + + data.stencilWrite = this.stencilWrite; + data.stencilWriteMask = this.stencilWriteMask; + data.stencilFunc = this.stencilFunc; + data.stencilRef = this.stencilRef; + data.stencilFuncMask = this.stencilFuncMask; + data.stencilFail = this.stencilFail; + data.stencilZFail = this.stencilZFail; + data.stencilZPass = this.stencilZPass; + + // rotation (SpriteMaterial) + if ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation; + + if ( this.polygonOffset === true ) data.polygonOffset = true; + if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor; + if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits; + + if ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth; + if ( this.dashSize !== undefined ) data.dashSize = this.dashSize; + if ( this.gapSize !== undefined ) data.gapSize = this.gapSize; + if ( this.scale !== undefined ) data.scale = this.scale; + + if ( this.dithering === true ) data.dithering = true; + + if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest; + if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage; + if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha; + + if ( this.wireframe === true ) data.wireframe = this.wireframe; + if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth; + if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap; + if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin; + + if ( this.flatShading === true ) data.flatShading = this.flatShading; + + if ( this.visible === false ) data.visible = false; + + if ( this.toneMapped === false ) data.toneMapped = false; + + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + // TODO: Copied from Object3D.toJSON + + function extractFromCache( cache ) { + + const values = []; + + for ( const key in cache ) { + + const data = cache[ key ]; + delete data.metadata; + values.push( data ); + + } + + return values; + + } + + if ( isRoot ) { + + const textures = extractFromCache( meta.textures ); + const images = extractFromCache( meta.images ); + + if ( textures.length > 0 ) data.textures = textures; + if ( images.length > 0 ) data.images = images; + + } + + return data; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.name = source.name; + + this.fog = source.fog; + + this.blending = source.blending; + this.side = source.side; + this.vertexColors = source.vertexColors; + + this.opacity = source.opacity; + this.transparent = source.transparent; + + this.blendSrc = source.blendSrc; + this.blendDst = source.blendDst; + this.blendEquation = source.blendEquation; + this.blendSrcAlpha = source.blendSrcAlpha; + this.blendDstAlpha = source.blendDstAlpha; + this.blendEquationAlpha = source.blendEquationAlpha; + + this.depthFunc = source.depthFunc; + this.depthTest = source.depthTest; + this.depthWrite = source.depthWrite; + + this.stencilWriteMask = source.stencilWriteMask; + this.stencilFunc = source.stencilFunc; + this.stencilRef = source.stencilRef; + this.stencilFuncMask = source.stencilFuncMask; + this.stencilFail = source.stencilFail; + this.stencilZFail = source.stencilZFail; + this.stencilZPass = source.stencilZPass; + this.stencilWrite = source.stencilWrite; + + const srcPlanes = source.clippingPlanes; + let dstPlanes = null; + + if ( srcPlanes !== null ) { + + const n = srcPlanes.length; + dstPlanes = new Array( n ); + + for ( let i = 0; i !== n; ++ i ) { + + dstPlanes[ i ] = srcPlanes[ i ].clone(); + + } + + } + + this.clippingPlanes = dstPlanes; + this.clipIntersection = source.clipIntersection; + this.clipShadows = source.clipShadows; + + this.shadowSide = source.shadowSide; + + this.colorWrite = source.colorWrite; + this.alphaWrite = source.alphaWrite; + + this.precision = source.precision; + + this.polygonOffset = source.polygonOffset; + this.polygonOffsetFactor = source.polygonOffsetFactor; + this.polygonOffsetUnits = source.polygonOffsetUnits; + + this.dithering = source.dithering; + + this.alphaTest = source.alphaTest; + this.alphaToCoverage = source.alphaToCoverage; + this.premultipliedAlpha = source.premultipliedAlpha; + + this.visible = source.visible; + + this.toneMapped = source.toneMapped; + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + +} + +Material.prototype.isMaterial = true; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + * + * depthTest: , + * depthWrite: , + * + * wireframe: , + * wireframeLinewidth: , + * } + */ + +class MeshBasicMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshBasicMaterial'; + + this.color = new Color( 0xffffff ); // emissive + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + + } + +} + +MeshBasicMaterial.prototype.isMeshBasicMaterial = true; + +const _vector$9 = /*@__PURE__*/ new Vector3(); +const _vector2$1 = /*@__PURE__*/ new Vector2(); + +class BufferAttribute { + + constructor( array, itemSize, normalized ) { + + if ( Array.isArray( array ) ) { + + throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' ); + + } + + this.name = ''; + + this.array = array; + this.itemSize = itemSize; + this.count = array !== undefined ? array.length / itemSize : 0; + this.normalized = normalized === true; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: - 1 }; + + this.version = 0; + + } + + onUploadCallback() {} + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + + setUsage( value ) { + + this.usage = value; + + return this; + + } + + copy( source ) { + + this.name = source.name; + this.array = new source.array.constructor( source.array ); + this.itemSize = source.itemSize; + this.count = source.count; + this.normalized = source.normalized; + + this.usage = source.usage; + + return this; + + } + + copyAt( index1, attribute, index2 ) { + + index1 *= this.itemSize; + index2 *= attribute.itemSize; + + for ( let i = 0, l = this.itemSize; i < l; i ++ ) { + + this.array[ index1 + i ] = attribute.array[ index2 + i ]; + + } + + return this; + + } + + copyArray( array ) { + + this.array.set( array ); + + return this; + + } + + copyColorsArray( colors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = colors.length; i < l; i ++ ) { + + let color = colors[ i ]; + + if ( color === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i ); + color = new Color(); + + } + + array[ offset ++ ] = color.r; + array[ offset ++ ] = color.g; + array[ offset ++ ] = color.b; + + } + + return this; + + } + + copyVector2sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i ); + vector = new Vector2(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + + } + + return this; + + } + + copyVector3sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i ); + vector = new Vector3(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + array[ offset ++ ] = vector.z; + + } + + return this; + + } + + copyVector4sArray( vectors ) { + + const array = this.array; + let offset = 0; + + for ( let i = 0, l = vectors.length; i < l; i ++ ) { + + let vector = vectors[ i ]; + + if ( vector === undefined ) { + + console.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i ); + vector = new Vector4(); + + } + + array[ offset ++ ] = vector.x; + array[ offset ++ ] = vector.y; + array[ offset ++ ] = vector.z; + array[ offset ++ ] = vector.w; + + } + + return this; + + } + + applyMatrix3( m ) { + + if ( this.itemSize === 2 ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector2$1.fromBufferAttribute( this, i ); + _vector2$1.applyMatrix3( m ); + + this.setXY( i, _vector2$1.x, _vector2$1.y ); + + } + + } else if ( this.itemSize === 3 ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.fromBufferAttribute( this, i ); + _vector$9.applyMatrix3( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + } + + return this; + + } + + applyMatrix4( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.applyMatrix4( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + applyNormalMatrix( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.applyNormalMatrix( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + transformDirection( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$9.x = this.getX( i ); + _vector$9.y = this.getY( i ); + _vector$9.z = this.getZ( i ); + + _vector$9.transformDirection( m ); + + this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z ); + + } + + return this; + + } + + set( value, offset = 0 ) { + + this.array.set( value, offset ); + + return this; + + } + + getX( index ) { + + return this.array[ index * this.itemSize ]; + + } + + setX( index, x ) { + + this.array[ index * this.itemSize ] = x; + + return this; + + } + + getY( index ) { + + return this.array[ index * this.itemSize + 1 ]; + + } + + setY( index, y ) { + + this.array[ index * this.itemSize + 1 ] = y; + + return this; + + } + + getZ( index ) { + + return this.array[ index * this.itemSize + 2 ]; + + } + + setZ( index, z ) { + + this.array[ index * this.itemSize + 2 ] = z; + + return this; + + } + + getW( index ) { + + return this.array[ index * this.itemSize + 3 ]; + + } + + setW( index, w ) { + + this.array[ index * this.itemSize + 3 ] = w; + + return this; + + } + + setXY( index, x, y ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + + return this; + + } + + setXYZ( index, x, y, z ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + this.array[ index + 2 ] = z; + + return this; + + } + + setXYZW( index, x, y, z, w ) { + + index *= this.itemSize; + + this.array[ index + 0 ] = x; + this.array[ index + 1 ] = y; + this.array[ index + 2 ] = z; + this.array[ index + 3 ] = w; + + return this; + + } + + onUpload( callback ) { + + this.onUploadCallback = callback; + + return this; + + } + + clone() { + + return new this.constructor( this.array, this.itemSize ).copy( this ); + + } + + toJSON() { + + const data = { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: Array.prototype.slice.call( this.array ), + normalized: this.normalized + }; + + if ( this.name !== '' ) data.name = this.name; + if ( this.usage !== StaticDrawUsage ) data.usage = this.usage; + if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange; + + return data; + + } + +} + +BufferAttribute.prototype.isBufferAttribute = true; + +// + +class Int8BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Int8Array( array ), itemSize, normalized ); + + } + +} + +class Uint8BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint8Array( array ), itemSize, normalized ); + + } + +} + +class Uint8ClampedBufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint8ClampedArray( array ), itemSize, normalized ); + + } + +} + +class Int16BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Int16Array( array ), itemSize, normalized ); + + } + +} + +class Uint16BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint16Array( array ), itemSize, normalized ); + + } + +} + +class Int32BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Int32Array( array ), itemSize, normalized ); + + } + +} + +class Uint32BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint32Array( array ), itemSize, normalized ); + + } + +} + +class Float16BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Uint16Array( array ), itemSize, normalized ); + + } + +} + +Float16BufferAttribute.prototype.isFloat16BufferAttribute = true; + +class Float32BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Float32Array( array ), itemSize, normalized ); + + } + +} + +class Float64BufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized ) { + + super( new Float64Array( array ), itemSize, normalized ); + + } + +} + +let _id$1 = 0; + +const _m1 = /*@__PURE__*/ new Matrix4(); +const _obj = /*@__PURE__*/ new Object3D(); +const _offset = /*@__PURE__*/ new Vector3(); +const _box$1 = /*@__PURE__*/ new Box3(); +const _boxMorphTargets = /*@__PURE__*/ new Box3(); +const _vector$8 = /*@__PURE__*/ new Vector3(); + +class BufferGeometry extends EventDispatcher { + + constructor() { + + super(); + + Object.defineProperty( this, 'id', { value: _id$1 ++ } ); + + this.uuid = generateUUID(); + + this.name = ''; + this.type = 'BufferGeometry'; + + this.index = null; + this.attributes = {}; + + this.morphAttributes = {}; + this.morphTargetsRelative = false; + + this.groups = []; + + this.boundingBox = null; + this.boundingSphere = null; + + this.drawRange = { start: 0, count: Infinity }; + + this.userData = {}; + + } + + getIndex() { + + return this.index; + + } + + setIndex( index ) { + + if ( Array.isArray( index ) ) { + + this.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 ); + + } else { + + this.index = index; + + } + + return this; + + } + + getAttribute( name ) { + + return this.attributes[ name ]; + + } + + setAttribute( name, attribute ) { + + this.attributes[ name ] = attribute; + + return this; + + } + + deleteAttribute( name ) { + + delete this.attributes[ name ]; + + return this; + + } + + hasAttribute( name ) { + + return this.attributes[ name ] !== undefined; + + } + + addGroup( start, count, materialIndex = 0 ) { + + this.groups.push( { + + start: start, + count: count, + materialIndex: materialIndex + + } ); + + } + + clearGroups() { + + this.groups = []; + + } + + setDrawRange( start, count ) { + + this.drawRange.start = start; + this.drawRange.count = count; + + } + + applyMatrix4( matrix ) { + + const position = this.attributes.position; + + if ( position !== undefined ) { + + position.applyMatrix4( matrix ); + + position.needsUpdate = true; + + } + + const normal = this.attributes.normal; + + if ( normal !== undefined ) { + + const normalMatrix = new Matrix3().getNormalMatrix( matrix ); + + normal.applyNormalMatrix( normalMatrix ); + + normal.needsUpdate = true; + + } + + const tangent = this.attributes.tangent; + + if ( tangent !== undefined ) { + + tangent.transformDirection( matrix ); + + tangent.needsUpdate = true; + + } + + if ( this.boundingBox !== null ) { + + this.computeBoundingBox(); + + } + + if ( this.boundingSphere !== null ) { + + this.computeBoundingSphere(); + + } + + return this; + + } + + applyQuaternion( q ) { + + _m1.makeRotationFromQuaternion( q ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateX( angle ) { + + // rotate geometry around world x-axis + + _m1.makeRotationX( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateY( angle ) { + + // rotate geometry around world y-axis + + _m1.makeRotationY( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + rotateZ( angle ) { + + // rotate geometry around world z-axis + + _m1.makeRotationZ( angle ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + translate( x, y, z ) { + + // translate geometry + + _m1.makeTranslation( x, y, z ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + scale( x, y, z ) { + + // scale geometry + + _m1.makeScale( x, y, z ); + + this.applyMatrix4( _m1 ); + + return this; + + } + + lookAt( vector ) { + + _obj.lookAt( vector ); + + _obj.updateMatrix(); + + this.applyMatrix4( _obj.matrix ); + + return this; + + } + + center() { + + this.computeBoundingBox(); + + this.boundingBox.getCenter( _offset ).negate(); + + this.translate( _offset.x, _offset.y, _offset.z ); + + return this; + + } + + setFromPoints( points ) { + + const position = []; + + for ( let i = 0, l = points.length; i < l; i ++ ) { + + const point = points[ i ]; + position.push( point.x, point.y, point.z || 0 ); + + } + + this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) ); + + return this; + + } + + computeBoundingBox() { + + if ( this.boundingBox === null ) { + + this.boundingBox = new Box3(); + + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if ( position && position.isGLBufferAttribute ) { + + console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this ); + + this.boundingBox.set( + new Vector3( - Infinity, - Infinity, - Infinity ), + new Vector3( + Infinity, + Infinity, + Infinity ) + ); + + return; + + } + + if ( position !== undefined ) { + + this.boundingBox.setFromBufferAttribute( position ); + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + _box$1.setFromBufferAttribute( morphAttribute ); + + if ( this.morphTargetsRelative ) { + + _vector$8.addVectors( this.boundingBox.min, _box$1.min ); + this.boundingBox.expandByPoint( _vector$8 ); + + _vector$8.addVectors( this.boundingBox.max, _box$1.max ); + this.boundingBox.expandByPoint( _vector$8 ); + + } else { + + this.boundingBox.expandByPoint( _box$1.min ); + this.boundingBox.expandByPoint( _box$1.max ); + + } + + } + + } + + } else { + + this.boundingBox.makeEmpty(); + + } + + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { + + console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); + + } + + } + + computeBoundingSphere() { + + if ( this.boundingSphere === null ) { + + this.boundingSphere = new Sphere(); + + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if ( position && position.isGLBufferAttribute ) { + + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this ); + + this.boundingSphere.set( new Vector3(), Infinity ); + + return; + + } + + if ( position ) { + + // first, find the center of the bounding sphere + + const center = this.boundingSphere.center; + + _box$1.setFromBufferAttribute( position ); + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + _boxMorphTargets.setFromBufferAttribute( morphAttribute ); + + if ( this.morphTargetsRelative ) { + + _vector$8.addVectors( _box$1.min, _boxMorphTargets.min ); + _box$1.expandByPoint( _vector$8 ); + + _vector$8.addVectors( _box$1.max, _boxMorphTargets.max ); + _box$1.expandByPoint( _vector$8 ); + + } else { + + _box$1.expandByPoint( _boxMorphTargets.min ); + _box$1.expandByPoint( _boxMorphTargets.max ); + + } + + } + + } + + _box$1.getCenter( center ); + + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + + let maxRadiusSq = 0; + + for ( let i = 0, il = position.count; i < il; i ++ ) { + + _vector$8.fromBufferAttribute( position, i ); + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) ); + + } + + // process morph attributes if present + + if ( morphAttributesPosition ) { + + for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + + const morphAttribute = morphAttributesPosition[ i ]; + const morphTargetsRelative = this.morphTargetsRelative; + + for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) { + + _vector$8.fromBufferAttribute( morphAttribute, j ); + + if ( morphTargetsRelative ) { + + _offset.fromBufferAttribute( position, j ); + _vector$8.add( _offset ); + + } + + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) ); + + } + + } + + } + + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + + if ( isNaN( this.boundingSphere.radius ) ) { + + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); + + } + + } + + } + + computeTangents() { + + const index = this.index; + const attributes = this.attributes; + + // based on http://www.terathon.com/code/tangent.html + // (per vertex tangents) + + if ( index === null || + attributes.position === undefined || + attributes.normal === undefined || + attributes.uv === undefined ) { + + console.error( 'THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' ); + return; + + } + + const indices = index.array; + const positions = attributes.position.array; + const normals = attributes.normal.array; + const uvs = attributes.uv.array; + + const nVertices = positions.length / 3; + + if ( attributes.tangent === undefined ) { + + this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) ); + + } + + const tangents = attributes.tangent.array; + + const tan1 = [], tan2 = []; + + for ( let i = 0; i < nVertices; i ++ ) { + + tan1[ i ] = new Vector3(); + tan2[ i ] = new Vector3(); + + } + + const vA = new Vector3(), + vB = new Vector3(), + vC = new Vector3(), + + uvA = new Vector2(), + uvB = new Vector2(), + uvC = new Vector2(), + + sdir = new Vector3(), + tdir = new Vector3(); + + function handleTriangle( a, b, c ) { + + vA.fromArray( positions, a * 3 ); + vB.fromArray( positions, b * 3 ); + vC.fromArray( positions, c * 3 ); + + uvA.fromArray( uvs, a * 2 ); + uvB.fromArray( uvs, b * 2 ); + uvC.fromArray( uvs, c * 2 ); + + vB.sub( vA ); + vC.sub( vA ); + + uvB.sub( uvA ); + uvC.sub( uvA ); + + const r = 1.0 / ( uvB.x * uvC.y - uvC.x * uvB.y ); + + // silently ignore degenerate uv triangles having coincident or colinear vertices + + if ( ! isFinite( r ) ) return; + + sdir.copy( vB ).multiplyScalar( uvC.y ).addScaledVector( vC, - uvB.y ).multiplyScalar( r ); + tdir.copy( vC ).multiplyScalar( uvB.x ).addScaledVector( vB, - uvC.x ).multiplyScalar( r ); + + tan1[ a ].add( sdir ); + tan1[ b ].add( sdir ); + tan1[ c ].add( sdir ); + + tan2[ a ].add( tdir ); + tan2[ b ].add( tdir ); + tan2[ c ].add( tdir ); + + } + + let groups = this.groups; + + if ( groups.length === 0 ) { + + groups = [ { + start: 0, + count: indices.length + } ]; + + } + + for ( let i = 0, il = groups.length; i < il; ++ i ) { + + const group = groups[ i ]; + + const start = group.start; + const count = group.count; + + for ( let j = start, jl = start + count; j < jl; j += 3 ) { + + handleTriangle( + indices[ j + 0 ], + indices[ j + 1 ], + indices[ j + 2 ] + ); + + } + + } + + const tmp = new Vector3(), tmp2 = new Vector3(); + const n = new Vector3(), n2 = new Vector3(); + + function handleVertex( v ) { + + n.fromArray( normals, v * 3 ); + n2.copy( n ); + + const t = tan1[ v ]; + + // Gram-Schmidt orthogonalize + + tmp.copy( t ); + tmp.sub( n.multiplyScalar( n.dot( t ) ) ).normalize(); + + // Calculate handedness + + tmp2.crossVectors( n2, t ); + const test = tmp2.dot( tan2[ v ] ); + const w = ( test < 0.0 ) ? - 1.0 : 1.0; + + tangents[ v * 4 ] = tmp.x; + tangents[ v * 4 + 1 ] = tmp.y; + tangents[ v * 4 + 2 ] = tmp.z; + tangents[ v * 4 + 3 ] = w; + + } + + for ( let i = 0, il = groups.length; i < il; ++ i ) { + + const group = groups[ i ]; + + const start = group.start; + const count = group.count; + + for ( let j = start, jl = start + count; j < jl; j += 3 ) { + + handleVertex( indices[ j + 0 ] ); + handleVertex( indices[ j + 1 ] ); + handleVertex( indices[ j + 2 ] ); + + } + + } + + } + + computeVertexNormals() { + + const index = this.index; + const positionAttribute = this.getAttribute( 'position' ); + + if ( positionAttribute !== undefined ) { + + let normalAttribute = this.getAttribute( 'normal' ); + + if ( normalAttribute === undefined ) { + + normalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 ); + this.setAttribute( 'normal', normalAttribute ); + + } else { + + // reset existing normals to zero + + for ( let i = 0, il = normalAttribute.count; i < il; i ++ ) { + + normalAttribute.setXYZ( i, 0, 0, 0 ); + + } + + } + + const pA = new Vector3(), pB = new Vector3(), pC = new Vector3(); + const nA = new Vector3(), nB = new Vector3(), nC = new Vector3(); + const cb = new Vector3(), ab = new Vector3(); + + // indexed elements + + if ( index ) { + + for ( let i = 0, il = index.count; i < il; i += 3 ) { + + const vA = index.getX( i + 0 ); + const vB = index.getX( i + 1 ); + const vC = index.getX( i + 2 ); + + pA.fromBufferAttribute( positionAttribute, vA ); + pB.fromBufferAttribute( positionAttribute, vB ); + pC.fromBufferAttribute( positionAttribute, vC ); + + cb.subVectors( pC, pB ); + ab.subVectors( pA, pB ); + cb.cross( ab ); + + nA.fromBufferAttribute( normalAttribute, vA ); + nB.fromBufferAttribute( normalAttribute, vB ); + nC.fromBufferAttribute( normalAttribute, vC ); + + nA.add( cb ); + nB.add( cb ); + nC.add( cb ); + + normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z ); + normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z ); + normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z ); + + } + + } else { + + // non-indexed elements (unconnected triangle soup) + + for ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) { + + pA.fromBufferAttribute( positionAttribute, i + 0 ); + pB.fromBufferAttribute( positionAttribute, i + 1 ); + pC.fromBufferAttribute( positionAttribute, i + 2 ); + + cb.subVectors( pC, pB ); + ab.subVectors( pA, pB ); + cb.cross( ab ); + + normalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z ); + normalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z ); + normalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z ); + + } + + } + + this.normalizeNormals(); + + normalAttribute.needsUpdate = true; + + } + + } + + merge( geometry, offset ) { + + if ( ! ( geometry && geometry.isBufferGeometry ) ) { + + console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry ); + return; + + } + + if ( offset === undefined ) { + + offset = 0; + + console.warn( + 'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. ' + + 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.' + ); + + } + + const attributes = this.attributes; + + for ( const key in attributes ) { + + if ( geometry.attributes[ key ] === undefined ) continue; + + const attribute1 = attributes[ key ]; + const attributeArray1 = attribute1.array; + + const attribute2 = geometry.attributes[ key ]; + const attributeArray2 = attribute2.array; + + const attributeOffset = attribute2.itemSize * offset; + const length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset ); + + for ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) { + + attributeArray1[ j ] = attributeArray2[ i ]; + + } + + } + + return this; + + } + + normalizeNormals() { + + const normals = this.attributes.normal; + + for ( let i = 0, il = normals.count; i < il; i ++ ) { + + _vector$8.fromBufferAttribute( normals, i ); + + _vector$8.normalize(); + + normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z ); + + } + + } + + toNonIndexed() { + + function convertBufferAttribute( attribute, indices ) { + + const array = attribute.array; + const itemSize = attribute.itemSize; + const normalized = attribute.normalized; + + const array2 = new array.constructor( indices.length * itemSize ); + + let index = 0, index2 = 0; + + for ( let i = 0, l = indices.length; i < l; i ++ ) { + + if ( attribute.isInterleavedBufferAttribute ) { + + index = indices[ i ] * attribute.data.stride + attribute.offset; + + } else { + + index = indices[ i ] * itemSize; + + } + + for ( let j = 0; j < itemSize; j ++ ) { + + array2[ index2 ++ ] = array[ index ++ ]; + + } + + } + + return new BufferAttribute( array2, itemSize, normalized ); + + } + + // + + if ( this.index === null ) { + + console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' ); + return this; + + } + + const geometry2 = new BufferGeometry(); + + const indices = this.index.array; + const attributes = this.attributes; + + // attributes + + for ( const name in attributes ) { + + const attribute = attributes[ name ]; + + const newAttribute = convertBufferAttribute( attribute, indices ); + + geometry2.setAttribute( name, newAttribute ); + + } + + // morph attributes + + const morphAttributes = this.morphAttributes; + + for ( const name in morphAttributes ) { + + const morphArray = []; + const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes + + for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) { + + const attribute = morphAttribute[ i ]; + + const newAttribute = convertBufferAttribute( attribute, indices ); + + morphArray.push( newAttribute ); + + } + + geometry2.morphAttributes[ name ] = morphArray; + + } + + geometry2.morphTargetsRelative = this.morphTargetsRelative; + + // groups + + const groups = this.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + geometry2.addGroup( group.start, group.count, group.materialIndex ); + + } + + return geometry2; + + } + + toJSON() { + + const data = { + metadata: { + version: 4.5, + type: 'BufferGeometry', + generator: 'BufferGeometry.toJSON' + } + }; + + // standard BufferGeometry serialization + + data.uuid = this.uuid; + data.type = this.type; + if ( this.name !== '' ) data.name = this.name; + if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData; + + if ( this.parameters !== undefined ) { + + const parameters = this.parameters; + + for ( const key in parameters ) { + + if ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ]; + + } + + return data; + + } + + // for simplicity the code assumes attributes are not shared across geometries, see #15811 + + data.data = { attributes: {} }; + + const index = this.index; + + if ( index !== null ) { + + data.data.index = { + type: index.array.constructor.name, + array: Array.prototype.slice.call( index.array ) + }; + + } + + const attributes = this.attributes; + + for ( const key in attributes ) { + + const attribute = attributes[ key ]; + + data.data.attributes[ key ] = attribute.toJSON( data.data ); + + } + + const morphAttributes = {}; + let hasMorphAttributes = false; + + for ( const key in this.morphAttributes ) { + + const attributeArray = this.morphAttributes[ key ]; + + const array = []; + + for ( let i = 0, il = attributeArray.length; i < il; i ++ ) { + + const attribute = attributeArray[ i ]; + + array.push( attribute.toJSON( data.data ) ); + + } + + if ( array.length > 0 ) { + + morphAttributes[ key ] = array; + + hasMorphAttributes = true; + + } + + } + + if ( hasMorphAttributes ) { + + data.data.morphAttributes = morphAttributes; + data.data.morphTargetsRelative = this.morphTargetsRelative; + + } + + const groups = this.groups; + + if ( groups.length > 0 ) { + + data.data.groups = JSON.parse( JSON.stringify( groups ) ); + + } + + const boundingSphere = this.boundingSphere; + + if ( boundingSphere !== null ) { + + data.data.boundingSphere = { + center: boundingSphere.center.toArray(), + radius: boundingSphere.radius + }; + + } + + return data; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + // reset + + this.index = null; + this.attributes = {}; + this.morphAttributes = {}; + this.groups = []; + this.boundingBox = null; + this.boundingSphere = null; + + // used for storing cloned, shared data + + const data = {}; + + // name + + this.name = source.name; + + // index + + const index = source.index; + + if ( index !== null ) { + + this.setIndex( index.clone( data ) ); + + } + + // attributes + + const attributes = source.attributes; + + for ( const name in attributes ) { + + const attribute = attributes[ name ]; + this.setAttribute( name, attribute.clone( data ) ); + + } + + // morph attributes + + const morphAttributes = source.morphAttributes; + + for ( const name in morphAttributes ) { + + const array = []; + const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes + + for ( let i = 0, l = morphAttribute.length; i < l; i ++ ) { + + array.push( morphAttribute[ i ].clone( data ) ); + + } + + this.morphAttributes[ name ] = array; + + } + + this.morphTargetsRelative = source.morphTargetsRelative; + + // groups + + const groups = source.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + this.addGroup( group.start, group.count, group.materialIndex ); + + } + + // bounding box + + const boundingBox = source.boundingBox; + + if ( boundingBox !== null ) { + + this.boundingBox = boundingBox.clone(); + + } + + // bounding sphere + + const boundingSphere = source.boundingSphere; + + if ( boundingSphere !== null ) { + + this.boundingSphere = boundingSphere.clone(); + + } + + // draw range + + this.drawRange.start = source.drawRange.start; + this.drawRange.count = source.drawRange.count; + + // user data + + this.userData = source.userData; + + // geometry generator parameters + + if ( source.parameters !== undefined ) this.parameters = Object.assign( {}, source.parameters ); + + return this; + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + +} + +BufferGeometry.prototype.isBufferGeometry = true; + +const _inverseMatrix$2 = /*@__PURE__*/ new Matrix4(); +const _ray$2 = /*@__PURE__*/ new Ray(); +const _sphere$3 = /*@__PURE__*/ new Sphere(); + +const _vA$1 = /*@__PURE__*/ new Vector3(); +const _vB$1 = /*@__PURE__*/ new Vector3(); +const _vC$1 = /*@__PURE__*/ new Vector3(); + +const _tempA = /*@__PURE__*/ new Vector3(); +const _tempB = /*@__PURE__*/ new Vector3(); +const _tempC = /*@__PURE__*/ new Vector3(); + +const _morphA = /*@__PURE__*/ new Vector3(); +const _morphB = /*@__PURE__*/ new Vector3(); +const _morphC = /*@__PURE__*/ new Vector3(); + +const _uvA$1 = /*@__PURE__*/ new Vector2(); +const _uvB$1 = /*@__PURE__*/ new Vector2(); +const _uvC$1 = /*@__PURE__*/ new Vector2(); + +const _intersectionPoint = /*@__PURE__*/ new Vector3(); +const _intersectionPointWorld = /*@__PURE__*/ new Vector3(); + +class Mesh extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) { + + super(); + + this.type = 'Mesh'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + if ( source.morphTargetInfluences !== undefined ) { + + this.morphTargetInfluences = source.morphTargetInfluences.slice(); + + } + + if ( source.morphTargetDictionary !== undefined ) { + + this.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary ); + + } + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const material = this.material; + const matrixWorld = this.matrixWorld; + + if ( material === undefined ) return; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$3.copy( geometry.boundingSphere ); + _sphere$3.applyMatrix4( matrixWorld ); + + if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return; + + // + + _inverseMatrix$2.copy( matrixWorld ).invert(); + _ray$2.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$2 ); + + // Check boundingBox before continuing + + if ( geometry.boundingBox !== null ) { + + if ( _ray$2.intersectsBox( geometry.boundingBox ) === false ) return; + + } + + let intersection; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const position = geometry.attributes.position; + const morphPosition = geometry.morphAttributes.position; + const morphTargetsRelative = geometry.morphTargetsRelative; + const uv = geometry.attributes.uv; + const uv2 = geometry.attributes.uv2; + const groups = geometry.groups; + const drawRange = geometry.drawRange; + + if ( index !== null ) { + + // indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( let i = 0, il = groups.length; i < il; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + const start = Math.max( group.start, drawRange.start ); + const end = Math.min( index.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) ); + + for ( let j = start, jl = end; j < jl; j += 3 ) { + + const a = index.getX( j ); + const b = index.getX( j + 1 ); + const c = index.getX( j + 2 ); + + intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push( intersection ); + + } + + } + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i += 3 ) { + + const a = index.getX( i ); + const b = index.getX( i + 1 ); + const c = index.getX( i + 2 ); + + intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics + intersects.push( intersection ); + + } + + } + + } + + } else if ( position !== undefined ) { + + // non-indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( let i = 0, il = groups.length; i < il; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + const start = Math.max( group.start, drawRange.start ); + const end = Math.min( position.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) ); + + for ( let j = start, jl = end; j < jl; j += 3 ) { + + const a = j; + const b = j + 1; + const c = j + 2; + + intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push( intersection ); + + } + + } + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( position.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i += 3 ) { + + const a = i; + const b = i + 1; + const c = i + 2; + + intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); + + if ( intersection ) { + + intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics + intersects.push( intersection ); + + } + + } + + } + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + +} + +Mesh.prototype.isMesh = true; + +function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) { + + let intersect; + + if ( material.side === BackSide ) { + + intersect = ray.intersectTriangle( pC, pB, pA, true, point ); + + } else { + + intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point ); + + } + + if ( intersect === null ) return null; + + _intersectionPointWorld.copy( point ); + _intersectionPointWorld.applyMatrix4( object.matrixWorld ); + + const distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld ); + + if ( distance < raycaster.near || distance > raycaster.far ) return null; + + return { + distance: distance, + point: _intersectionPointWorld.clone(), + object: object + }; + +} + +function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) { + + _vA$1.fromBufferAttribute( position, a ); + _vB$1.fromBufferAttribute( position, b ); + _vC$1.fromBufferAttribute( position, c ); + + const morphInfluences = object.morphTargetInfluences; + + if ( morphPosition && morphInfluences ) { + + _morphA.set( 0, 0, 0 ); + _morphB.set( 0, 0, 0 ); + _morphC.set( 0, 0, 0 ); + + for ( let i = 0, il = morphPosition.length; i < il; i ++ ) { + + const influence = morphInfluences[ i ]; + const morphAttribute = morphPosition[ i ]; + + if ( influence === 0 ) continue; + + _tempA.fromBufferAttribute( morphAttribute, a ); + _tempB.fromBufferAttribute( morphAttribute, b ); + _tempC.fromBufferAttribute( morphAttribute, c ); + + if ( morphTargetsRelative ) { + + _morphA.addScaledVector( _tempA, influence ); + _morphB.addScaledVector( _tempB, influence ); + _morphC.addScaledVector( _tempC, influence ); + + } else { + + _morphA.addScaledVector( _tempA.sub( _vA$1 ), influence ); + _morphB.addScaledVector( _tempB.sub( _vB$1 ), influence ); + _morphC.addScaledVector( _tempC.sub( _vC$1 ), influence ); + + } + + } + + _vA$1.add( _morphA ); + _vB$1.add( _morphB ); + _vC$1.add( _morphC ); + + } + + if ( object.isSkinnedMesh ) { + + object.boneTransform( a, _vA$1 ); + object.boneTransform( b, _vB$1 ); + object.boneTransform( c, _vC$1 ); + + } + + const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint ); + + if ( intersection ) { + + if ( uv ) { + + _uvA$1.fromBufferAttribute( uv, a ); + _uvB$1.fromBufferAttribute( uv, b ); + _uvC$1.fromBufferAttribute( uv, c ); + + intersection.uv = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + + } + + if ( uv2 ) { + + _uvA$1.fromBufferAttribute( uv2, a ); + _uvB$1.fromBufferAttribute( uv2, b ); + _uvC$1.fromBufferAttribute( uv2, c ); + + intersection.uv2 = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + + } + + const face = { + a: a, + b: b, + c: c, + normal: new Vector3(), + materialIndex: 0 + }; + + Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal ); + + intersection.face = face; + + } + + return intersection; + +} + +class BoxGeometry extends BufferGeometry { + + constructor( width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1 ) { + + super(); + + this.type = 'BoxGeometry'; + + this.parameters = { + width: width, + height: height, + depth: depth, + widthSegments: widthSegments, + heightSegments: heightSegments, + depthSegments: depthSegments + }; + + const scope = this; + + // segments + + widthSegments = Math.floor( widthSegments ); + heightSegments = Math.floor( heightSegments ); + depthSegments = Math.floor( depthSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let numberOfVertices = 0; + let groupStart = 0; + + // build each side of the box geometry + + buildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px + buildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx + buildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py + buildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny + buildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz + buildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + function buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) { + + const segmentWidth = width / gridX; + const segmentHeight = height / gridY; + + const widthHalf = width / 2; + const heightHalf = height / 2; + const depthHalf = depth / 2; + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + let vertexCounter = 0; + let groupCount = 0; + + const vector = new Vector3(); + + // generate vertices, normals and uvs + + for ( let iy = 0; iy < gridY1; iy ++ ) { + + const y = iy * segmentHeight - heightHalf; + + for ( let ix = 0; ix < gridX1; ix ++ ) { + + const x = ix * segmentWidth - widthHalf; + + // set values to correct vector component + + vector[ u ] = x * udir; + vector[ v ] = y * vdir; + vector[ w ] = depthHalf; + + // now apply vector to vertex buffer + + vertices.push( vector.x, vector.y, vector.z ); + + // set values to correct vector component + + vector[ u ] = 0; + vector[ v ] = 0; + vector[ w ] = depth > 0 ? 1 : - 1; + + // now apply vector to normal buffer + + normals.push( vector.x, vector.y, vector.z ); + + // uvs + + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); + + // counters + + vertexCounter += 1; + + } + + } + + // indices + + // 1. you need three indices to draw a single face + // 2. a single segment consists of two faces + // 3. so we need to generate six (2*3) indices per segment + + for ( let iy = 0; iy < gridY; iy ++ ) { + + for ( let ix = 0; ix < gridX; ix ++ ) { + + const a = numberOfVertices + ix + gridX1 * iy; + const b = numberOfVertices + ix + gridX1 * ( iy + 1 ); + const c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 ); + const d = numberOfVertices + ( ix + 1 ) + gridX1 * iy; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + // increase counter + + groupCount += 6; + + } + + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup( groupStart, groupCount, materialIndex ); + + // calculate new start value for groups + + groupStart += groupCount; + + // update total number of vertices + + numberOfVertices += vertexCounter; + + } + + } + + static fromJSON( data ) { + + return new BoxGeometry( data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments ); + + } + +} + +/** + * Uniform Utilities + */ + +function cloneUniforms( src ) { + + const dst = {}; + + for ( const u in src ) { + + dst[ u ] = {}; + + for ( const p in src[ u ] ) { + + const property = src[ u ][ p ]; + + if ( property && ( property.isColor || + property.isMatrix3 || property.isMatrix4 || + property.isVector2 || property.isVector3 || property.isVector4 || + property.isTexture || property.isQuaternion ) ) { + + dst[ u ][ p ] = property.clone(); + + } else if ( Array.isArray( property ) ) { + + dst[ u ][ p ] = property.slice(); + + } else { + + dst[ u ][ p ] = property; + + } + + } + + } + + return dst; + +} + +function mergeUniforms( uniforms ) { + + const merged = {}; + + for ( let u = 0; u < uniforms.length; u ++ ) { + + const tmp = cloneUniforms( uniforms[ u ] ); + + for ( const p in tmp ) { + + merged[ p ] = tmp[ p ]; + + } + + } + + return merged; + +} + +// Legacy + +const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms }; + +var default_vertex = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"; + +var default_fragment = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}"; + +/** + * parameters = { + * defines: { "label" : "value" }, + * uniforms: { "parameter1": { value: 1.0 }, "parameter2": { value2: 2 } }, + * + * fragmentShader: , + * vertexShader: , + * + * wireframe: , + * wireframeLinewidth: , + * + * lights: + * } + */ + +class ShaderMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'ShaderMaterial'; + + this.defines = {}; + this.uniforms = {}; + + this.vertexShader = default_vertex; + this.fragmentShader = default_fragment; + + this.linewidth = 1; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; // set to use scene fog + this.lights = false; // set to use scene lights + this.clipping = false; // set to use user-defined clipping planes + + this.extensions = { + derivatives: false, // set to use derivatives + fragDepth: false, // set to use fragment depth values + drawBuffers: false, // set to use draw buffers + shaderTextureLOD: false // set to use shader texture LOD + }; + + // When rendered geometry doesn't include these attributes but the material does, + // use these default values in WebGL. This avoids errors when buffer data is missing. + this.defaultAttributeValues = { + 'color': [ 1, 1, 1 ], + 'uv': [ 0, 0 ], + 'uv2': [ 0, 0 ] + }; + + this.index0AttributeName = undefined; + this.uniformsNeedUpdate = false; + + this.glslVersion = null; + + if ( parameters !== undefined ) { + + if ( parameters.attributes !== undefined ) { + + console.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' ); + + } + + this.setValues( parameters ); + + } + + } + + copy( source ) { + + super.copy( source ); + + this.fragmentShader = source.fragmentShader; + this.vertexShader = source.vertexShader; + + this.uniforms = cloneUniforms( source.uniforms ); + + this.defines = Object.assign( {}, source.defines ); + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + this.lights = source.lights; + this.clipping = source.clipping; + + this.extensions = Object.assign( {}, source.extensions ); + + this.glslVersion = source.glslVersion; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.glslVersion = this.glslVersion; + data.uniforms = {}; + + for ( const name in this.uniforms ) { + + const uniform = this.uniforms[ name ]; + const value = uniform.value; + + if ( value && value.isTexture ) { + + data.uniforms[ name ] = { + type: 't', + value: value.toJSON( meta ).uuid + }; + + } else if ( value && value.isColor ) { + + data.uniforms[ name ] = { + type: 'c', + value: value.getHex() + }; + + } else if ( value && value.isVector2 ) { + + data.uniforms[ name ] = { + type: 'v2', + value: value.toArray() + }; + + } else if ( value && value.isVector3 ) { + + data.uniforms[ name ] = { + type: 'v3', + value: value.toArray() + }; + + } else if ( value && value.isVector4 ) { + + data.uniforms[ name ] = { + type: 'v4', + value: value.toArray() + }; + + } else if ( value && value.isMatrix3 ) { + + data.uniforms[ name ] = { + type: 'm3', + value: value.toArray() + }; + + } else if ( value && value.isMatrix4 ) { + + data.uniforms[ name ] = { + type: 'm4', + value: value.toArray() + }; + + } else { + + data.uniforms[ name ] = { + value: value + }; + + // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far + + } + + } + + if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines; + + data.vertexShader = this.vertexShader; + data.fragmentShader = this.fragmentShader; + + const extensions = {}; + + for ( const key in this.extensions ) { + + if ( this.extensions[ key ] === true ) extensions[ key ] = true; + + } + + if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions; + + return data; + + } + +} + +ShaderMaterial.prototype.isShaderMaterial = true; + +class Camera extends Object3D { + + constructor() { + + super(); + + this.type = 'Camera'; + + this.matrixWorldInverse = new Matrix4(); + + this.projectionMatrix = new Matrix4(); + this.projectionMatrixInverse = new Matrix4(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.matrixWorldInverse.copy( source.matrixWorldInverse ); + + this.projectionMatrix.copy( source.projectionMatrix ); + this.projectionMatrixInverse.copy( source.projectionMatrixInverse ); + + return this; + + } + + getWorldDirection( target ) { + + this.updateWorldMatrix( true, false ); + + const e = this.matrixWorld.elements; + + return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize(); + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + this.matrixWorldInverse.copy( this.matrixWorld ).invert(); + + } + + updateWorldMatrix( updateParents, updateChildren ) { + + super.updateWorldMatrix( updateParents, updateChildren ); + + this.matrixWorldInverse.copy( this.matrixWorld ).invert(); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +Camera.prototype.isCamera = true; + +class PerspectiveCamera extends Camera { + + constructor( fov = 50, aspect = 1, near = 0.1, far = 2000 ) { + + super(); + + this.type = 'PerspectiveCamera'; + + this.fov = fov; + this.zoom = 1; + + this.near = near; + this.far = far; + this.focus = 10; + + this.aspect = aspect; + this.view = null; + + this.filmGauge = 35; // width of the film (default in millimeters) + this.filmOffset = 0; // horizontal film offset (same unit as gauge) + + this.updateProjectionMatrix(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.fov = source.fov; + this.zoom = source.zoom; + + this.near = source.near; + this.far = source.far; + this.focus = source.focus; + + this.aspect = source.aspect; + this.view = source.view === null ? null : Object.assign( {}, source.view ); + + this.filmGauge = source.filmGauge; + this.filmOffset = source.filmOffset; + + return this; + + } + + /** + * Sets the FOV by focal length in respect to the current .filmGauge. + * + * The default film gauge is 35, so that the focal length can be specified for + * a 35mm (full frame) camera. + * + * Values for focal length and film gauge must have the same unit. + */ + setFocalLength( focalLength ) { + + /** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */ + const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength; + + this.fov = RAD2DEG * 2 * Math.atan( vExtentSlope ); + this.updateProjectionMatrix(); + + } + + /** + * Calculates the focal length from the current .fov and .filmGauge. + */ + getFocalLength() { + + const vExtentSlope = Math.tan( DEG2RAD * 0.5 * this.fov ); + + return 0.5 * this.getFilmHeight() / vExtentSlope; + + } + + getEffectiveFOV() { + + return RAD2DEG * 2 * Math.atan( + Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom ); + + } + + getFilmWidth() { + + // film not completely covered in portrait format (aspect < 1) + return this.filmGauge * Math.min( this.aspect, 1 ); + + } + + getFilmHeight() { + + // film not completely covered in landscape format (aspect > 1) + return this.filmGauge / Math.max( this.aspect, 1 ); + + } + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. + * + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and + * the monitors are in grid like this + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this + * + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * --A-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * --B-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * --C-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * --D-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * --E-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * --F-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); + * + * Note there is no reason monitors have to be the same size or in a grid. + */ + setViewOffset( fullWidth, fullHeight, x, y, width, height ) { + + this.aspect = fullWidth / fullHeight; + + if ( this.view === null ) { + + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }; + + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + + } + + clearViewOffset() { + + if ( this.view !== null ) { + + this.view.enabled = false; + + } + + this.updateProjectionMatrix(); + + } + + updateProjectionMatrix() { + + const near = this.near; + let top = near * Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom; + let height = 2 * top; + let width = this.aspect * height; + let left = - 0.5 * width; + const view = this.view; + + if ( this.view !== null && this.view.enabled ) { + + const fullWidth = view.fullWidth, + fullHeight = view.fullHeight; + + left += view.offsetX * width / fullWidth; + top -= view.offsetY * height / fullHeight; + width *= view.width / fullWidth; + height *= view.height / fullHeight; + + } + + const skew = this.filmOffset; + if ( skew !== 0 ) left += near * skew / this.getFilmWidth(); + + this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far ); + + this.projectionMatrixInverse.copy( this.projectionMatrix ).invert(); + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.fov = this.fov; + data.object.zoom = this.zoom; + + data.object.near = this.near; + data.object.far = this.far; + data.object.focus = this.focus; + + data.object.aspect = this.aspect; + + if ( this.view !== null ) data.object.view = Object.assign( {}, this.view ); + + data.object.filmGauge = this.filmGauge; + data.object.filmOffset = this.filmOffset; + + return data; + + } + +} + +PerspectiveCamera.prototype.isPerspectiveCamera = true; + +const fov = 90, aspect = 1; + +class CubeCamera extends Object3D { + + constructor( near, far, renderTarget ) { + + super(); + + this.type = 'CubeCamera'; + + if ( renderTarget.isWebGLCubeRenderTarget !== true ) { + + console.error( 'THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.' ); + return; + + } + + this.renderTarget = renderTarget; + + const cameraPX = new PerspectiveCamera( fov, aspect, near, far ); + cameraPX.layers = this.layers; + cameraPX.up.set( 0, - 1, 0 ); + cameraPX.lookAt( new Vector3( 1, 0, 0 ) ); + this.add( cameraPX ); + + const cameraNX = new PerspectiveCamera( fov, aspect, near, far ); + cameraNX.layers = this.layers; + cameraNX.up.set( 0, - 1, 0 ); + cameraNX.lookAt( new Vector3( - 1, 0, 0 ) ); + this.add( cameraNX ); + + const cameraPY = new PerspectiveCamera( fov, aspect, near, far ); + cameraPY.layers = this.layers; + cameraPY.up.set( 0, 0, 1 ); + cameraPY.lookAt( new Vector3( 0, 1, 0 ) ); + this.add( cameraPY ); + + const cameraNY = new PerspectiveCamera( fov, aspect, near, far ); + cameraNY.layers = this.layers; + cameraNY.up.set( 0, 0, - 1 ); + cameraNY.lookAt( new Vector3( 0, - 1, 0 ) ); + this.add( cameraNY ); + + const cameraPZ = new PerspectiveCamera( fov, aspect, near, far ); + cameraPZ.layers = this.layers; + cameraPZ.up.set( 0, - 1, 0 ); + cameraPZ.lookAt( new Vector3( 0, 0, 1 ) ); + this.add( cameraPZ ); + + const cameraNZ = new PerspectiveCamera( fov, aspect, near, far ); + cameraNZ.layers = this.layers; + cameraNZ.up.set( 0, - 1, 0 ); + cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) ); + this.add( cameraNZ ); + + } + + update( renderer, scene ) { + + if ( this.parent === null ) this.updateMatrixWorld(); + + const renderTarget = this.renderTarget; + + const [ cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ ] = this.children; + + const currentXrEnabled = renderer.xr.enabled; + const currentRenderTarget = renderer.getRenderTarget(); + + renderer.xr.enabled = false; + + const generateMipmaps = renderTarget.texture.generateMipmaps; + + renderTarget.texture.generateMipmaps = false; + + renderer.setRenderTarget( renderTarget, 0 ); + renderer.render( scene, cameraPX ); + + renderer.setRenderTarget( renderTarget, 1 ); + renderer.render( scene, cameraNX ); + + renderer.setRenderTarget( renderTarget, 2 ); + renderer.render( scene, cameraPY ); + + renderer.setRenderTarget( renderTarget, 3 ); + renderer.render( scene, cameraNY ); + + renderer.setRenderTarget( renderTarget, 4 ); + renderer.render( scene, cameraPZ ); + + renderTarget.texture.generateMipmaps = generateMipmaps; + + renderer.setRenderTarget( renderTarget, 5 ); + renderer.render( scene, cameraNZ ); + + renderer.setRenderTarget( currentRenderTarget ); + + renderer.xr.enabled = currentXrEnabled; + + renderTarget.texture.needsPMREMUpdate = true; + + } + +} + +class CubeTexture extends Texture { + + constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { + + images = images !== undefined ? images : []; + mapping = mapping !== undefined ? mapping : CubeReflectionMapping; + + super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + + this.flipY = false; + + } + + get images() { + + return this.image; + + } + + set images( value ) { + + this.image = value; + + } + +} + +CubeTexture.prototype.isCubeTexture = true; + +class WebGLCubeRenderTarget extends WebGLRenderTarget { + + constructor( size, options, dummy ) { + + if ( Number.isInteger( options ) ) { + + console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' ); + + options = dummy; + + } + + super( size, size, options ); + + options = options || {}; + + // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) + // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words, + // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly. + + // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped + // and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture + // as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures). + + this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + this.texture.isRenderTargetTexture = true; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + + } + + fromEquirectangularTexture( renderer, texture ) { + + this.texture.type = texture.type; + this.texture.format = RGBAFormat; // see #18859 + this.texture.encoding = texture.encoding; + + this.texture.generateMipmaps = texture.generateMipmaps; + this.texture.minFilter = texture.minFilter; + this.texture.magFilter = texture.magFilter; + + const shader = { + + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: /* glsl */` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `, + + fragmentShader: /* glsl */` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + ` + }; + + const geometry = new BoxGeometry( 5, 5, 5 ); + + const material = new ShaderMaterial( { + + name: 'CubemapFromEquirect', + + uniforms: cloneUniforms( shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + side: BackSide, + blending: NoBlending + + } ); + + material.uniforms.tEquirect.value = texture; + + const mesh = new Mesh( geometry, material ); + + const currentMinFilter = texture.minFilter; + + // Avoid blurred poles + if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter; + + const camera = new CubeCamera( 1, 10, this ); + camera.update( renderer, mesh ); + + texture.minFilter = currentMinFilter; + + mesh.geometry.dispose(); + mesh.material.dispose(); + + return this; + + } + + clear( renderer, color, depth, stencil ) { + + const currentRenderTarget = renderer.getRenderTarget(); + + for ( let i = 0; i < 6; i ++ ) { + + renderer.setRenderTarget( this, i ); + + renderer.clear( color, depth, stencil ); + + } + + renderer.setRenderTarget( currentRenderTarget ); + + } + +} + +WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true; + +const _vector1 = /*@__PURE__*/ new Vector3(); +const _vector2 = /*@__PURE__*/ new Vector3(); +const _normalMatrix = /*@__PURE__*/ new Matrix3(); + +class Plane { + + constructor( normal = new Vector3( 1, 0, 0 ), constant = 0 ) { + + // normal is assumed to be normalized + + this.normal = normal; + this.constant = constant; + + } + + set( normal, constant ) { + + this.normal.copy( normal ); + this.constant = constant; + + return this; + + } + + setComponents( x, y, z, w ) { + + this.normal.set( x, y, z ); + this.constant = w; + + return this; + + } + + setFromNormalAndCoplanarPoint( normal, point ) { + + this.normal.copy( normal ); + this.constant = - point.dot( this.normal ); + + return this; + + } + + setFromCoplanarPoints( a, b, c ) { + + const normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize(); + + // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? + + this.setFromNormalAndCoplanarPoint( normal, a ); + + return this; + + } + + copy( plane ) { + + this.normal.copy( plane.normal ); + this.constant = plane.constant; + + return this; + + } + + normalize() { + + // Note: will lead to a divide by zero if the plane is invalid. + + const inverseNormalLength = 1.0 / this.normal.length(); + this.normal.multiplyScalar( inverseNormalLength ); + this.constant *= inverseNormalLength; + + return this; + + } + + negate() { + + this.constant *= - 1; + this.normal.negate(); + + return this; + + } + + distanceToPoint( point ) { + + return this.normal.dot( point ) + this.constant; + + } + + distanceToSphere( sphere ) { + + return this.distanceToPoint( sphere.center ) - sphere.radius; + + } + + projectPoint( point, target ) { + + return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point ); + + } + + intersectLine( line, target ) { + + const direction = line.delta( _vector1 ); + + const denominator = this.normal.dot( direction ); + + if ( denominator === 0 ) { + + // line is coplanar, return origin + if ( this.distanceToPoint( line.start ) === 0 ) { + + return target.copy( line.start ); + + } + + // Unsure if this is the correct method to handle this case. + return null; + + } + + const t = - ( line.start.dot( this.normal ) + this.constant ) / denominator; + + if ( t < 0 || t > 1 ) { + + return null; + + } + + return target.copy( direction ).multiplyScalar( t ).add( line.start ); + + } + + intersectsLine( line ) { + + // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it. + + const startSign = this.distanceToPoint( line.start ); + const endSign = this.distanceToPoint( line.end ); + + return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 ); + + } + + intersectsBox( box ) { + + return box.intersectsPlane( this ); + + } + + intersectsSphere( sphere ) { + + return sphere.intersectsPlane( this ); + + } + + coplanarPoint( target ) { + + return target.copy( this.normal ).multiplyScalar( - this.constant ); + + } + + applyMatrix4( matrix, optionalNormalMatrix ) { + + const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix ); + + const referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix ); + + const normal = this.normal.applyMatrix3( normalMatrix ).normalize(); + + this.constant = - referencePoint.dot( normal ); + + return this; + + } + + translate( offset ) { + + this.constant -= offset.dot( this.normal ); + + return this; + + } + + equals( plane ) { + + return plane.normal.equals( this.normal ) && ( plane.constant === this.constant ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +Plane.prototype.isPlane = true; + +const _sphere$2 = /*@__PURE__*/ new Sphere(); +const _vector$7 = /*@__PURE__*/ new Vector3(); + +class Frustum { + + constructor( p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane() ) { + + this.planes = [ p0, p1, p2, p3, p4, p5 ]; + + } + + set( p0, p1, p2, p3, p4, p5 ) { + + const planes = this.planes; + + planes[ 0 ].copy( p0 ); + planes[ 1 ].copy( p1 ); + planes[ 2 ].copy( p2 ); + planes[ 3 ].copy( p3 ); + planes[ 4 ].copy( p4 ); + planes[ 5 ].copy( p5 ); + + return this; + + } + + copy( frustum ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + planes[ i ].copy( frustum.planes[ i ] ); + + } + + return this; + + } + + setFromProjectionMatrix( m ) { + + const planes = this.planes; + const me = m.elements; + const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ]; + const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ]; + const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ]; + const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ]; + + planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize(); + planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize(); + planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize(); + planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize(); + planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); + planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); + + return this; + + } + + intersectsObject( object ) { + + const geometry = object.geometry; + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$2.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld ); + + return this.intersectsSphere( _sphere$2 ); + + } + + intersectsSprite( sprite ) { + + _sphere$2.center.set( 0, 0, 0 ); + _sphere$2.radius = 0.7071067811865476; + _sphere$2.applyMatrix4( sprite.matrixWorld ); + + return this.intersectsSphere( _sphere$2 ); + + } + + intersectsSphere( sphere ) { + + const planes = this.planes; + const center = sphere.center; + const negRadius = - sphere.radius; + + for ( let i = 0; i < 6; i ++ ) { + + const distance = planes[ i ].distanceToPoint( center ); + + if ( distance < negRadius ) { + + return false; + + } + + } + + return true; + + } + + intersectsBox( box ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + const plane = planes[ i ]; + + // corner at max distance + + _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z; + + if ( plane.distanceToPoint( _vector$7 ) < 0 ) { + + return false; + + } + + } + + return true; + + } + + containsPoint( point ) { + + const planes = this.planes; + + for ( let i = 0; i < 6; i ++ ) { + + if ( planes[ i ].distanceToPoint( point ) < 0 ) { + + return false; + + } + + } + + return true; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +function WebGLAnimation() { + + let context = null; + let isAnimating = false; + let animationLoop = null; + let requestId = null; + + function onAnimationFrame( time, frame ) { + + animationLoop( time, frame ); + + requestId = context.requestAnimationFrame( onAnimationFrame ); + + } + + return { + + start: function () { + + if ( isAnimating === true ) return; + if ( animationLoop === null ) return; + + requestId = context.requestAnimationFrame( onAnimationFrame ); + + isAnimating = true; + + }, + + stop: function () { + + context.cancelAnimationFrame( requestId ); + + isAnimating = false; + + }, + + setAnimationLoop: function ( callback ) { + + animationLoop = callback; + + }, + + setContext: function ( value ) { + + context = value; + + } + + }; + +} + +function WebGLAttributes( gl, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + const buffers = new WeakMap(); + + function createBuffer( attribute, bufferType ) { + + const array = attribute.array; + const usage = attribute.usage; + + const buffer = gl.createBuffer(); + + gl.bindBuffer( bufferType, buffer ); + gl.bufferData( bufferType, array, usage ); + + attribute.onUploadCallback(); + + let type = 5126; + + if ( array instanceof Float32Array ) { + + type = 5126; + + } else if ( array instanceof Float64Array ) { + + console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); + + } else if ( array instanceof Uint16Array ) { + + if ( attribute.isFloat16BufferAttribute ) { + + if ( isWebGL2 ) { + + type = 5131; + + } else { + + console.warn( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' ); + + } + + } else { + + type = 5123; + + } + + } else if ( array instanceof Int16Array ) { + + type = 5122; + + } else if ( array instanceof Uint32Array ) { + + type = 5125; + + } else if ( array instanceof Int32Array ) { + + type = 5124; + + } else if ( array instanceof Int8Array ) { + + type = 5120; + + } else if ( array instanceof Uint8Array ) { + + type = 5121; + + } else if ( array instanceof Uint8ClampedArray ) { + + type = 5121; + + } + + return { + buffer: buffer, + type: type, + bytesPerElement: array.BYTES_PER_ELEMENT, + version: attribute.version + }; + + } + + function updateBuffer( buffer, attribute, bufferType ) { + + const array = attribute.array; + const updateRange = attribute.updateRange; + + gl.bindBuffer( bufferType, buffer ); + + if ( updateRange.count === - 1 ) { + + // Not using update ranges + + gl.bufferSubData( bufferType, 0, array ); + + } else { + + if ( isWebGL2 ) { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array, updateRange.offset, updateRange.count ); + + } else { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); + + } + + updateRange.count = - 1; // reset range + + } + + } + + // + + function get( attribute ) { + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + return buffers.get( attribute ); + + } + + function remove( attribute ) { + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + const data = buffers.get( attribute ); + + if ( data ) { + + gl.deleteBuffer( data.buffer ); + + buffers.delete( attribute ); + + } + + } + + function update( attribute, bufferType ) { + + if ( attribute.isGLBufferAttribute ) { + + const cached = buffers.get( attribute ); + + if ( ! cached || cached.version < attribute.version ) { + + buffers.set( attribute, { + buffer: attribute.buffer, + type: attribute.type, + bytesPerElement: attribute.elementSize, + version: attribute.version + } ); + + } + + return; + + } + + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + + const data = buffers.get( attribute ); + + if ( data === undefined ) { + + buffers.set( attribute, createBuffer( attribute, bufferType ) ); + + } else if ( data.version < attribute.version ) { + + updateBuffer( data.buffer, attribute, bufferType ); + + data.version = attribute.version; + + } + + } + + return { + + get: get, + remove: remove, + update: update + + }; + +} + +class PlaneGeometry extends BufferGeometry { + + constructor( width = 1, height = 1, widthSegments = 1, heightSegments = 1 ) { + + super(); + this.type = 'PlaneGeometry'; + + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; + + const width_half = width / 2; + const height_half = height / 2; + + const gridX = Math.floor( widthSegments ); + const gridY = Math.floor( heightSegments ); + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + const segment_width = width / gridX; + const segment_height = height / gridY; + + // + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + for ( let iy = 0; iy < gridY1; iy ++ ) { + + const y = iy * segment_height - height_half; + + for ( let ix = 0; ix < gridX1; ix ++ ) { + + const x = ix * segment_width - width_half; + + vertices.push( x, - y, 0 ); + + normals.push( 0, 0, 1 ); + + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); + + } + + } + + for ( let iy = 0; iy < gridY; iy ++ ) { + + for ( let ix = 0; ix < gridX; ix ++ ) { + + const a = ix + gridX1 * iy; + const b = ix + gridX1 * ( iy + 1 ); + const c = ( ix + 1 ) + gridX1 * ( iy + 1 ); + const d = ( ix + 1 ) + gridX1 * iy; + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new PlaneGeometry( data.width, data.height, data.widthSegments, data.heightSegments ); + + } + +} + +var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; + +var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + +var alphatest_fragment = "#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif"; + +var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif"; + +var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif"; + +var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; + +var begin_vertex = "vec3 transformed = vec3( position );"; + +var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; + +var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif"; + +var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; + +var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; + +var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; + +var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif"; + +var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif"; + +var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif"; + +var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif"; + +var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif"; + +var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif"; + +var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}"; + +var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif"; + +var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; + +var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; + +var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; + +var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; + +var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; + +var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; + +var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}"; + +var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; + +var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; + +var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; + +var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; + +var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; + +var fog_vertex = "#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif"; + +var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif"; + +var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; + +var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; + +var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; + +var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif"; + +var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; + +var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif"; + +var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif"; + +var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif"; + +var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;"; + +var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; + +var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + +var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; + +var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif"; + +var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; + +var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; + +var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif"; + +var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; + +var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; + +var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; + +var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; + +var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; + +var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif"; + +var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; + +var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; + +var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + +var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; + +var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; + +var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif"; + +var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif"; + +var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif"; + +var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; + +var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif"; + +var normal_pars_fragment = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif"; + +var normal_pars_vertex = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif"; + +var normal_vertex = "#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif"; + +var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif"; + +var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; + +var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif"; + +var clearcoat_pars_fragment = "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; + +var output_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );"; + +var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; + +var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; + +var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; + +var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; + +var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; + +var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; + +var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; + +var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; + +var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; + +var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif"; + +var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}"; + +var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; + +var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; + +var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; + +var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; + +var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; + +var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; + +var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; + +var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }"; + +var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif"; + +var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif"; + +var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; + +var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; + +var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; + +var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; + +var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; + +var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; + +var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; + +const vertex$g = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; + +const fragment$g = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#include \n\t#include \n}"; + +const vertex$f = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; + +const fragment$f = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; + +const vertex$e = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}"; + +const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}"; + +const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; + +const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; + +const vertex$c = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; + +const fragment$c = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}"; + +const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$a = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$9 = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$9 = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; + +const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; + +const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; + +const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}"; + +const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + +const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$3 = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const vertex$2 = "#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}"; + +const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + +const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + +const ShaderChunk = { + alphamap_fragment: alphamap_fragment, + alphamap_pars_fragment: alphamap_pars_fragment, + alphatest_fragment: alphatest_fragment, + alphatest_pars_fragment: alphatest_pars_fragment, + aomap_fragment: aomap_fragment, + aomap_pars_fragment: aomap_pars_fragment, + begin_vertex: begin_vertex, + beginnormal_vertex: beginnormal_vertex, + bsdfs: bsdfs, + bumpmap_pars_fragment: bumpmap_pars_fragment, + clipping_planes_fragment: clipping_planes_fragment, + clipping_planes_pars_fragment: clipping_planes_pars_fragment, + clipping_planes_pars_vertex: clipping_planes_pars_vertex, + clipping_planes_vertex: clipping_planes_vertex, + color_fragment: color_fragment, + color_pars_fragment: color_pars_fragment, + color_pars_vertex: color_pars_vertex, + color_vertex: color_vertex, + common: common, + cube_uv_reflection_fragment: cube_uv_reflection_fragment, + defaultnormal_vertex: defaultnormal_vertex, + displacementmap_pars_vertex: displacementmap_pars_vertex, + displacementmap_vertex: displacementmap_vertex, + emissivemap_fragment: emissivemap_fragment, + emissivemap_pars_fragment: emissivemap_pars_fragment, + encodings_fragment: encodings_fragment, + encodings_pars_fragment: encodings_pars_fragment, + envmap_fragment: envmap_fragment, + envmap_common_pars_fragment: envmap_common_pars_fragment, + envmap_pars_fragment: envmap_pars_fragment, + envmap_pars_vertex: envmap_pars_vertex, + envmap_physical_pars_fragment: envmap_physical_pars_fragment, + envmap_vertex: envmap_vertex, + fog_vertex: fog_vertex, + fog_pars_vertex: fog_pars_vertex, + fog_fragment: fog_fragment, + fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, + lightmap_fragment: lightmap_fragment, + lightmap_pars_fragment: lightmap_pars_fragment, + lights_lambert_vertex: lights_lambert_vertex, + lights_pars_begin: lights_pars_begin, + lights_toon_fragment: lights_toon_fragment, + lights_toon_pars_fragment: lights_toon_pars_fragment, + lights_phong_fragment: lights_phong_fragment, + lights_phong_pars_fragment: lights_phong_pars_fragment, + lights_physical_fragment: lights_physical_fragment, + lights_physical_pars_fragment: lights_physical_pars_fragment, + lights_fragment_begin: lights_fragment_begin, + lights_fragment_maps: lights_fragment_maps, + lights_fragment_end: lights_fragment_end, + logdepthbuf_fragment: logdepthbuf_fragment, + logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, + logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, + logdepthbuf_vertex: logdepthbuf_vertex, + map_fragment: map_fragment, + map_pars_fragment: map_pars_fragment, + map_particle_fragment: map_particle_fragment, + map_particle_pars_fragment: map_particle_pars_fragment, + metalnessmap_fragment: metalnessmap_fragment, + metalnessmap_pars_fragment: metalnessmap_pars_fragment, + morphnormal_vertex: morphnormal_vertex, + morphtarget_pars_vertex: morphtarget_pars_vertex, + morphtarget_vertex: morphtarget_vertex, + normal_fragment_begin: normal_fragment_begin, + normal_fragment_maps: normal_fragment_maps, + normal_pars_fragment: normal_pars_fragment, + normal_pars_vertex: normal_pars_vertex, + normal_vertex: normal_vertex, + normalmap_pars_fragment: normalmap_pars_fragment, + clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, + clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, + clearcoat_pars_fragment: clearcoat_pars_fragment, + output_fragment: output_fragment, + packing: packing, + premultiplied_alpha_fragment: premultiplied_alpha_fragment, + project_vertex: project_vertex, + dithering_fragment: dithering_fragment, + dithering_pars_fragment: dithering_pars_fragment, + roughnessmap_fragment: roughnessmap_fragment, + roughnessmap_pars_fragment: roughnessmap_pars_fragment, + shadowmap_pars_fragment: shadowmap_pars_fragment, + shadowmap_pars_vertex: shadowmap_pars_vertex, + shadowmap_vertex: shadowmap_vertex, + shadowmask_pars_fragment: shadowmask_pars_fragment, + skinbase_vertex: skinbase_vertex, + skinning_pars_vertex: skinning_pars_vertex, + skinning_vertex: skinning_vertex, + skinnormal_vertex: skinnormal_vertex, + specularmap_fragment: specularmap_fragment, + specularmap_pars_fragment: specularmap_pars_fragment, + tonemapping_fragment: tonemapping_fragment, + tonemapping_pars_fragment: tonemapping_pars_fragment, + transmission_fragment: transmission_fragment, + transmission_pars_fragment: transmission_pars_fragment, + uv_pars_fragment: uv_pars_fragment, + uv_pars_vertex: uv_pars_vertex, + uv_vertex: uv_vertex, + uv2_pars_fragment: uv2_pars_fragment, + uv2_pars_vertex: uv2_pars_vertex, + uv2_vertex: uv2_vertex, + worldpos_vertex: worldpos_vertex, + + background_vert: vertex$g, + background_frag: fragment$g, + cube_vert: vertex$f, + cube_frag: fragment$f, + depth_vert: vertex$e, + depth_frag: fragment$e, + distanceRGBA_vert: vertex$d, + distanceRGBA_frag: fragment$d, + equirect_vert: vertex$c, + equirect_frag: fragment$c, + linedashed_vert: vertex$b, + linedashed_frag: fragment$b, + meshbasic_vert: vertex$a, + meshbasic_frag: fragment$a, + meshlambert_vert: vertex$9, + meshlambert_frag: fragment$9, + meshmatcap_vert: vertex$8, + meshmatcap_frag: fragment$8, + meshnormal_vert: vertex$7, + meshnormal_frag: fragment$7, + meshphong_vert: vertex$6, + meshphong_frag: fragment$6, + meshphysical_vert: vertex$5, + meshphysical_frag: fragment$5, + meshtoon_vert: vertex$4, + meshtoon_frag: fragment$4, + points_vert: vertex$3, + points_frag: fragment$3, + shadow_vert: vertex$2, + shadow_frag: fragment$2, + sprite_vert: vertex$1, + sprite_frag: fragment$1 +}; + +/** + * Uniforms library for shared webgl shaders + */ + +const UniformsLib = { + + common: { + + diffuse: { value: new Color( 0xffffff ) }, + opacity: { value: 1.0 }, + + map: { value: null }, + uvTransform: { value: new Matrix3() }, + uv2Transform: { value: new Matrix3() }, + + alphaMap: { value: null }, + alphaTest: { value: 0 } + + }, + + specularmap: { + + specularMap: { value: null }, + + }, + + envmap: { + + envMap: { value: null }, + flipEnvMap: { value: - 1 }, + reflectivity: { value: 1.0 }, // basic, lambert, phong + ior: { value: 1.5 }, // standard, physical + refractionRatio: { value: 0.98 } + + }, + + aomap: { + + aoMap: { value: null }, + aoMapIntensity: { value: 1 } + + }, + + lightmap: { + + lightMap: { value: null }, + lightMapIntensity: { value: 1 } + + }, + + emissivemap: { + + emissiveMap: { value: null } + + }, + + bumpmap: { + + bumpMap: { value: null }, + bumpScale: { value: 1 } + + }, + + normalmap: { + + normalMap: { value: null }, + normalScale: { value: new Vector2( 1, 1 ) } + + }, + + displacementmap: { + + displacementMap: { value: null }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 } + + }, + + roughnessmap: { + + roughnessMap: { value: null } + + }, + + metalnessmap: { + + metalnessMap: { value: null } + + }, + + gradientmap: { + + gradientMap: { value: null } + + }, + + fog: { + + fogDensity: { value: 0.00025 }, + fogNear: { value: 1 }, + fogFar: { value: 2000 }, + fogColor: { value: new Color( 0xffffff ) } + + }, + + lights: { + + ambientLightColor: { value: [] }, + + lightProbe: { value: [] }, + + directionalLights: { value: [], properties: { + direction: {}, + color: {} + } }, + + directionalLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, + + spotLights: { value: [], properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } }, + + spotLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + + spotShadowMap: { value: [] }, + spotShadowMatrix: { value: [] }, + + pointLights: { value: [], properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } }, + + pointLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } }, + + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, + + hemisphereLights: { value: [], properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } }, + + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {} + } }, + + ltc_1: { value: null }, + ltc_2: { value: null } + + }, + + points: { + + diffuse: { value: new Color( 0xffffff ) }, + opacity: { value: 1.0 }, + size: { value: 1.0 }, + scale: { value: 1.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() } + + }, + + sprite: { + + diffuse: { value: new Color( 0xffffff ) }, + opacity: { value: 1.0 }, + center: { value: new Vector2( 0.5, 0.5 ) }, + rotation: { value: 0.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() } + + } + +}; + +const ShaderLib = { + + basic: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.meshbasic_vert, + fragmentShader: ShaderChunk.meshbasic_frag + + }, + + lambert: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) } + } + ] ), + + vertexShader: ShaderChunk.meshlambert_vert, + fragmentShader: ShaderChunk.meshlambert_frag + + }, + + phong: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + specular: { value: new Color( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), + + vertexShader: ShaderChunk.meshphong_vert, + fragmentShader: ShaderChunk.meshphong_frag + + }, + + standard: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.roughnessmap, + UniformsLib.metalnessmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + roughness: { value: 1.0 }, + metalness: { value: 0.0 }, + envMapIntensity: { value: 1 } // temporary + } + ] ), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + + }, + + toon: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.gradientmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) } + } + ] ), + + vertexShader: ShaderChunk.meshtoon_vert, + fragmentShader: ShaderChunk.meshtoon_frag + + }, + + matcap: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + { + matcap: { value: null } + } + ] ), + + vertexShader: ShaderChunk.meshmatcap_vert, + fragmentShader: ShaderChunk.meshmatcap_frag + + }, + + points: { + + uniforms: mergeUniforms( [ + UniformsLib.points, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.points_vert, + fragmentShader: ShaderChunk.points_frag + + }, + + dashed: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 } + } + ] ), + + vertexShader: ShaderChunk.linedashed_vert, + fragmentShader: ShaderChunk.linedashed_frag + + }, + + depth: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap + ] ), + + vertexShader: ShaderChunk.depth_vert, + fragmentShader: ShaderChunk.depth_frag + + }, + + normal: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + { + opacity: { value: 1.0 } + } + ] ), + + vertexShader: ShaderChunk.meshnormal_vert, + fragmentShader: ShaderChunk.meshnormal_frag + + }, + + sprite: { + + uniforms: mergeUniforms( [ + UniformsLib.sprite, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.sprite_vert, + fragmentShader: ShaderChunk.sprite_frag + + }, + + background: { + + uniforms: { + uvTransform: { value: new Matrix3() }, + t2D: { value: null }, + }, + + vertexShader: ShaderChunk.background_vert, + fragmentShader: ShaderChunk.background_frag + + }, + /* ------------------------------------------------------------------------- + // Cube map shader + ------------------------------------------------------------------------- */ + + cube: { + + uniforms: mergeUniforms( [ + UniformsLib.envmap, + { + opacity: { value: 1.0 } + } + ] ), + + vertexShader: ShaderChunk.cube_vert, + fragmentShader: ShaderChunk.cube_frag + + }, + + equirect: { + + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: ShaderChunk.equirect_vert, + fragmentShader: ShaderChunk.equirect_frag + + }, + + distanceRGBA: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap, + { + referencePosition: { value: new Vector3() }, + nearDistance: { value: 1 }, + farDistance: { value: 1000 } + } + ] ), + + vertexShader: ShaderChunk.distanceRGBA_vert, + fragmentShader: ShaderChunk.distanceRGBA_frag + + }, + + shadow: { + + uniforms: mergeUniforms( [ + UniformsLib.lights, + UniformsLib.fog, + { + color: { value: new Color( 0x00000 ) }, + opacity: { value: 1.0 } + }, + ] ), + + vertexShader: ShaderChunk.shadow_vert, + fragmentShader: ShaderChunk.shadow_frag + + } + +}; + +ShaderLib.physical = { + + uniforms: mergeUniforms( [ + ShaderLib.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, + clearcoatNormalMap: { value: null }, + sheen: { value: 0 }, + sheenColor: { value: new Color( 0x000000 ) }, + sheenColorMap: { value: null }, + sheenRoughness: { value: 1 }, + sheenRoughnessMap: { value: null }, + transmission: { value: 0 }, + transmissionMap: { value: null }, + transmissionSamplerSize: { value: new Vector2() }, + transmissionSamplerMap: { value: null }, + thickness: { value: 0 }, + thicknessMap: { value: null }, + attenuationDistance: { value: 0 }, + attenuationColor: { value: new Color( 0x000000 ) }, + specularIntensity: { value: 1 }, + specularIntensityMap: { value: null }, + specularColor: { value: new Color( 1, 1, 1 ) }, + specularColorMap: { value: null }, + } + ] ), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + +}; + +function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipliedAlpha ) { + + const clearColor = new Color( 0x000000 ); + let clearAlpha = alpha === true ? 0 : 1; + + let planeMesh; + let boxMesh; + + let currentBackground = null; + let currentBackgroundVersion = 0; + let currentTonemapping = null; + + function render( renderList, scene ) { + + let forceClear = false; + let background = scene.isScene === true ? scene.background : null; + + if ( background && background.isTexture ) { + + background = cubemaps.get( background ); + + } + + // Ignore background in AR + // TODO: Reconsider this. + + const xr = renderer.xr; + const session = xr.getSession && xr.getSession(); + + if ( session && session.environmentBlendMode === 'additive' ) { + + background = null; + + } + + if ( background === null ) { + + setClear( clearColor, clearAlpha ); + + } else if ( background && background.isColor ) { + + setClear( background, 1 ); + forceClear = true; + + } + + if ( renderer.autoClear || forceClear ) { + + renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil ); + + } + + if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) { + + if ( boxMesh === undefined ) { + + boxMesh = new Mesh( + new BoxGeometry( 1, 1, 1 ), + new ShaderMaterial( { + name: 'BackgroundCubeMaterial', + uniforms: cloneUniforms( ShaderLib.cube.uniforms ), + vertexShader: ShaderLib.cube.vertexShader, + fragmentShader: ShaderLib.cube.fragmentShader, + side: BackSide, + depthTest: false, + depthWrite: false, + fog: false + } ) + ); + + boxMesh.geometry.deleteAttribute( 'normal' ); + boxMesh.geometry.deleteAttribute( 'uv' ); + + boxMesh.onBeforeRender = function ( renderer, scene, camera ) { + + this.matrixWorld.copyPosition( camera.matrixWorld ); + + }; + + // enable code injection for non-built-in material + Object.defineProperty( boxMesh.material, 'envMap', { + + get: function () { + + return this.uniforms.envMap.value; + + } + + } ); + + objects.update( boxMesh ); + + } + + boxMesh.material.uniforms.envMap.value = background; + boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1; + + if ( currentBackground !== background || + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { + + boxMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + + } + + // push to the pre-sorted opaque render list + renderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null ); + + } else if ( background && background.isTexture ) { + + if ( planeMesh === undefined ) { + + planeMesh = new Mesh( + new PlaneGeometry( 2, 2 ), + new ShaderMaterial( { + name: 'BackgroundMaterial', + uniforms: cloneUniforms( ShaderLib.background.uniforms ), + vertexShader: ShaderLib.background.vertexShader, + fragmentShader: ShaderLib.background.fragmentShader, + side: FrontSide, + depthTest: false, + depthWrite: false, + fog: false + } ) + ); + + planeMesh.geometry.deleteAttribute( 'normal' ); + + // enable code injection for non-built-in material + Object.defineProperty( planeMesh.material, 'map', { + + get: function () { + + return this.uniforms.t2D.value; + + } + + } ); + + objects.update( planeMesh ); + + } + + planeMesh.material.uniforms.t2D.value = background; + + if ( background.matrixAutoUpdate === true ) { + + background.updateMatrix(); + + } + + planeMesh.material.uniforms.uvTransform.value.copy( background.matrix ); + + if ( currentBackground !== background || + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { + + planeMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + + } + + + // push to the pre-sorted opaque render list + renderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null ); + + } + + } + + function setClear( color, alpha ) { + + state.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha ); + + } + + return { + + getClearColor: function () { + + return clearColor; + + }, + setClearColor: function ( color, alpha = 1 ) { + + clearColor.set( color ); + clearAlpha = alpha; + setClear( clearColor, clearAlpha ); + + }, + getClearAlpha: function () { + + return clearAlpha; + + }, + setClearAlpha: function ( alpha ) { + + clearAlpha = alpha; + setClear( clearColor, clearAlpha ); + + }, + render: render + + }; + +} + +function WebGLBindingStates( gl, extensions, attributes, capabilities ) { + + const maxVertexAttributes = gl.getParameter( 34921 ); + + const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' ); + const vaoAvailable = capabilities.isWebGL2 || extension !== null; + + const bindingStates = {}; + + const defaultState = createBindingState( null ); + let currentState = defaultState; + + function setup( object, material, program, geometry, index ) { + + let updateBuffers = false; + + if ( vaoAvailable ) { + + const state = getBindingState( geometry, program, material ); + + if ( currentState !== state ) { + + currentState = state; + bindVertexArrayObject( currentState.object ); + + } + + updateBuffers = needsUpdate( geometry, index ); + + if ( updateBuffers ) saveCache( geometry, index ); + + } else { + + const wireframe = ( material.wireframe === true ); + + if ( currentState.geometry !== geometry.id || + currentState.program !== program.id || + currentState.wireframe !== wireframe ) { + + currentState.geometry = geometry.id; + currentState.program = program.id; + currentState.wireframe = wireframe; + + updateBuffers = true; + + } + + } + + if ( object.isInstancedMesh === true ) { + + updateBuffers = true; + + } + + if ( index !== null ) { + + attributes.update( index, 34963 ); + + } + + if ( updateBuffers ) { + + setupVertexAttributes( object, material, program, geometry ); + + if ( index !== null ) { + + gl.bindBuffer( 34963, attributes.get( index ).buffer ); + + } + + } + + } + + function createVertexArrayObject() { + + if ( capabilities.isWebGL2 ) return gl.createVertexArray(); + + return extension.createVertexArrayOES(); + + } + + function bindVertexArrayObject( vao ) { + + if ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao ); + + return extension.bindVertexArrayOES( vao ); + + } + + function deleteVertexArrayObject( vao ) { + + if ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao ); + + return extension.deleteVertexArrayOES( vao ); + + } + + function getBindingState( geometry, program, material ) { + + const wireframe = ( material.wireframe === true ); + + let programMap = bindingStates[ geometry.id ]; + + if ( programMap === undefined ) { + + programMap = {}; + bindingStates[ geometry.id ] = programMap; + + } + + let stateMap = programMap[ program.id ]; + + if ( stateMap === undefined ) { + + stateMap = {}; + programMap[ program.id ] = stateMap; + + } + + let state = stateMap[ wireframe ]; + + if ( state === undefined ) { + + state = createBindingState( createVertexArrayObject() ); + stateMap[ wireframe ] = state; + + } + + return state; + + } + + function createBindingState( vao ) { + + const newAttributes = []; + const enabledAttributes = []; + const attributeDivisors = []; + + for ( let i = 0; i < maxVertexAttributes; i ++ ) { + + newAttributes[ i ] = 0; + enabledAttributes[ i ] = 0; + attributeDivisors[ i ] = 0; + + } + + return { + + // for backward compatibility on non-VAO support browser + geometry: null, + program: null, + wireframe: false, + + newAttributes: newAttributes, + enabledAttributes: enabledAttributes, + attributeDivisors: attributeDivisors, + object: vao, + attributes: {}, + index: null + + }; + + } + + function needsUpdate( geometry, index ) { + + const cachedAttributes = currentState.attributes; + const geometryAttributes = geometry.attributes; + + let attributesNum = 0; + + for ( const key in geometryAttributes ) { + + const cachedAttribute = cachedAttributes[ key ]; + const geometryAttribute = geometryAttributes[ key ]; + + if ( cachedAttribute === undefined ) return true; + + if ( cachedAttribute.attribute !== geometryAttribute ) return true; + + if ( cachedAttribute.data !== geometryAttribute.data ) return true; + + attributesNum ++; + + } + + if ( currentState.attributesNum !== attributesNum ) return true; + + if ( currentState.index !== index ) return true; + + return false; + + } + + function saveCache( geometry, index ) { + + const cache = {}; + const attributes = geometry.attributes; + let attributesNum = 0; + + for ( const key in attributes ) { + + const attribute = attributes[ key ]; + + const data = {}; + data.attribute = attribute; + + if ( attribute.data ) { + + data.data = attribute.data; + + } + + cache[ key ] = data; + + attributesNum ++; + + } + + currentState.attributes = cache; + currentState.attributesNum = attributesNum; + + currentState.index = index; + + } + + function initAttributes() { + + const newAttributes = currentState.newAttributes; + + for ( let i = 0, il = newAttributes.length; i < il; i ++ ) { + + newAttributes[ i ] = 0; + + } + + } + + function enableAttribute( attribute ) { + + enableAttributeAndDivisor( attribute, 0 ); + + } + + function enableAttributeAndDivisor( attribute, meshPerAttribute ) { + + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + const attributeDivisors = currentState.attributeDivisors; + + newAttributes[ attribute ] = 1; + + if ( enabledAttributes[ attribute ] === 0 ) { + + gl.enableVertexAttribArray( attribute ); + enabledAttributes[ attribute ] = 1; + + } + + if ( attributeDivisors[ attribute ] !== meshPerAttribute ) { + + const extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' ); + + extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute ); + attributeDivisors[ attribute ] = meshPerAttribute; + + } + + } + + function disableUnusedAttributes() { + + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + + for ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) { + + if ( enabledAttributes[ i ] !== newAttributes[ i ] ) { + + gl.disableVertexAttribArray( i ); + enabledAttributes[ i ] = 0; + + } + + } + + } + + function vertexAttribPointer( index, size, type, normalized, stride, offset ) { + + if ( capabilities.isWebGL2 === true && ( type === 5124 || type === 5125 ) ) { + + gl.vertexAttribIPointer( index, size, type, stride, offset ); + + } else { + + gl.vertexAttribPointer( index, size, type, normalized, stride, offset ); + + } + + } + + function setupVertexAttributes( object, material, program, geometry ) { + + if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) { + + if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return; + + } + + initAttributes(); + + const geometryAttributes = geometry.attributes; + + const programAttributes = program.getAttributes(); + + const materialDefaultAttributeValues = material.defaultAttributeValues; + + for ( const name in programAttributes ) { + + const programAttribute = programAttributes[ name ]; + + if ( programAttribute.location >= 0 ) { + + let geometryAttribute = geometryAttributes[ name ]; + + if ( geometryAttribute === undefined ) { + + if ( name === 'instanceMatrix' && object.instanceMatrix ) geometryAttribute = object.instanceMatrix; + if ( name === 'instanceColor' && object.instanceColor ) geometryAttribute = object.instanceColor; + + } + + if ( geometryAttribute !== undefined ) { + + const normalized = geometryAttribute.normalized; + const size = geometryAttribute.itemSize; + + const attribute = attributes.get( geometryAttribute ); + + // TODO Attribute may not be available on context restore + + if ( attribute === undefined ) continue; + + const buffer = attribute.buffer; + const type = attribute.type; + const bytesPerElement = attribute.bytesPerElement; + + if ( geometryAttribute.isInterleavedBufferAttribute ) { + + const data = geometryAttribute.data; + const stride = data.stride; + const offset = geometryAttribute.offset; + + if ( data && data.isInstancedInterleavedBuffer ) { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttributeAndDivisor( programAttribute.location + i, data.meshPerAttribute ); + + } + + if ( object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined ) { + + geometry._maxInstanceCount = data.meshPerAttribute * data.count; + + } + + } else { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttribute( programAttribute.location + i ); + + } + + } + + gl.bindBuffer( 34962, buffer ); + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + stride * bytesPerElement, + ( offset + ( size / programAttribute.locationSize ) * i ) * bytesPerElement + ); + + } + + } else { + + if ( geometryAttribute.isInstancedBufferAttribute ) { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttributeAndDivisor( programAttribute.location + i, geometryAttribute.meshPerAttribute ); + + } + + if ( object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined ) { + + geometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count; + + } + + } else { + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + enableAttribute( programAttribute.location + i ); + + } + + } + + gl.bindBuffer( 34962, buffer ); + + for ( let i = 0; i < programAttribute.locationSize; i ++ ) { + + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + size * bytesPerElement, + ( size / programAttribute.locationSize ) * i * bytesPerElement + ); + + } + + } + + } else if ( materialDefaultAttributeValues !== undefined ) { + + const value = materialDefaultAttributeValues[ name ]; + + if ( value !== undefined ) { + + switch ( value.length ) { + + case 2: + gl.vertexAttrib2fv( programAttribute.location, value ); + break; + + case 3: + gl.vertexAttrib3fv( programAttribute.location, value ); + break; + + case 4: + gl.vertexAttrib4fv( programAttribute.location, value ); + break; + + default: + gl.vertexAttrib1fv( programAttribute.location, value ); + + } + + } + + } + + } + + } + + disableUnusedAttributes(); + + } + + function dispose() { + + reset(); + + for ( const geometryId in bindingStates ) { + + const programMap = bindingStates[ geometryId ]; + + for ( const programId in programMap ) { + + const stateMap = programMap[ programId ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ programId ]; + + } + + delete bindingStates[ geometryId ]; + + } + + } + + function releaseStatesOfGeometry( geometry ) { + + if ( bindingStates[ geometry.id ] === undefined ) return; + + const programMap = bindingStates[ geometry.id ]; + + for ( const programId in programMap ) { + + const stateMap = programMap[ programId ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ programId ]; + + } + + delete bindingStates[ geometry.id ]; + + } + + function releaseStatesOfProgram( program ) { + + for ( const geometryId in bindingStates ) { + + const programMap = bindingStates[ geometryId ]; + + if ( programMap[ program.id ] === undefined ) continue; + + const stateMap = programMap[ program.id ]; + + for ( const wireframe in stateMap ) { + + deleteVertexArrayObject( stateMap[ wireframe ].object ); + + delete stateMap[ wireframe ]; + + } + + delete programMap[ program.id ]; + + } + + } + + function reset() { + + resetDefaultState(); + + if ( currentState === defaultState ) return; + + currentState = defaultState; + bindVertexArrayObject( currentState.object ); + + } + + // for backward-compatilibity + + function resetDefaultState() { + + defaultState.geometry = null; + defaultState.program = null; + defaultState.wireframe = false; + + } + + return { + + setup: setup, + reset: reset, + resetDefaultState: resetDefaultState, + dispose: dispose, + releaseStatesOfGeometry: releaseStatesOfGeometry, + releaseStatesOfProgram: releaseStatesOfProgram, + + initAttributes: initAttributes, + enableAttribute: enableAttribute, + disableUnusedAttributes: disableUnusedAttributes + + }; + +} + +function WebGLBufferRenderer( gl, extensions, info, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode( value ) { + + mode = value; + + } + + function render( start, count ) { + + gl.drawArrays( mode, start, count ); + + info.update( count, mode, 1 ); + + } + + function renderInstances( start, count, primcount ) { + + if ( primcount === 0 ) return; + + let extension, methodName; + + if ( isWebGL2 ) { + + extension = gl; + methodName = 'drawArraysInstanced'; + + } else { + + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawArraysInstancedANGLE'; + + if ( extension === null ) { + + console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); + return; + + } + + } + + extension[ methodName ]( mode, start, count, primcount ); + + info.update( count, mode, primcount ); + + } + + // + + this.setMode = setMode; + this.render = render; + this.renderInstances = renderInstances; + +} + +function WebGLCapabilities( gl, extensions, parameters ) { + + let maxAnisotropy; + + function getMaxAnisotropy() { + + if ( maxAnisotropy !== undefined ) return maxAnisotropy; + + if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) { + + const extension = extensions.get( 'EXT_texture_filter_anisotropic' ); + + maxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT ); + + } else { + + maxAnisotropy = 0; + + } + + return maxAnisotropy; + + } + + function getMaxPrecision( precision ) { + + if ( precision === 'highp' ) { + + if ( gl.getShaderPrecisionFormat( 35633, 36338 ).precision > 0 && + gl.getShaderPrecisionFormat( 35632, 36338 ).precision > 0 ) { + + return 'highp'; + + } + + precision = 'mediump'; + + } + + if ( precision === 'mediump' ) { + + if ( gl.getShaderPrecisionFormat( 35633, 36337 ).precision > 0 && + gl.getShaderPrecisionFormat( 35632, 36337 ).precision > 0 ) { + + return 'mediump'; + + } + + } + + return 'lowp'; + + } + + const isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) || + ( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext ); + + let precision = parameters.precision !== undefined ? parameters.precision : 'highp'; + const maxPrecision = getMaxPrecision( precision ); + + if ( maxPrecision !== precision ) { + + console.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' ); + precision = maxPrecision; + + } + + const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' ); + + const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true; + + const maxTextures = gl.getParameter( 34930 ); + const maxVertexTextures = gl.getParameter( 35660 ); + const maxTextureSize = gl.getParameter( 3379 ); + const maxCubemapSize = gl.getParameter( 34076 ); + + const maxAttributes = gl.getParameter( 34921 ); + const maxVertexUniforms = gl.getParameter( 36347 ); + const maxVaryings = gl.getParameter( 36348 ); + const maxFragmentUniforms = gl.getParameter( 36349 ); + + const vertexTextures = maxVertexTextures > 0; + const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' ); + const floatVertexTextures = vertexTextures && floatFragmentTextures; + + const maxSamples = isWebGL2 ? gl.getParameter( 36183 ) : 0; + + return { + + isWebGL2: isWebGL2, + + drawBuffers: drawBuffers, + + getMaxAnisotropy: getMaxAnisotropy, + getMaxPrecision: getMaxPrecision, + + precision: precision, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + maxTextures: maxTextures, + maxVertexTextures: maxVertexTextures, + maxTextureSize: maxTextureSize, + maxCubemapSize: maxCubemapSize, + + maxAttributes: maxAttributes, + maxVertexUniforms: maxVertexUniforms, + maxVaryings: maxVaryings, + maxFragmentUniforms: maxFragmentUniforms, + + vertexTextures: vertexTextures, + floatFragmentTextures: floatFragmentTextures, + floatVertexTextures: floatVertexTextures, + + maxSamples: maxSamples + + }; + +} + +function WebGLClipping( properties ) { + + const scope = this; + + let globalState = null, + numGlobalPlanes = 0, + localClippingEnabled = false, + renderingShadows = false; + + const plane = new Plane(), + viewNormalMatrix = new Matrix3(), + + uniform = { value: null, needsUpdate: false }; + + this.uniform = uniform; + this.numPlanes = 0; + this.numIntersection = 0; + + this.init = function ( planes, enableLocalClipping, camera ) { + + const enabled = + planes.length !== 0 || + enableLocalClipping || + // enable state of previous frame - the clipping code has to + // run another frame in order to reset the state: + numGlobalPlanes !== 0 || + localClippingEnabled; + + localClippingEnabled = enableLocalClipping; + + globalState = projectPlanes( planes, camera, 0 ); + numGlobalPlanes = planes.length; + + return enabled; + + }; + + this.beginShadows = function () { + + renderingShadows = true; + projectPlanes( null ); + + }; + + this.endShadows = function () { + + renderingShadows = false; + resetGlobalState(); + + }; + + this.setState = function ( material, camera, useCache ) { + + const planes = material.clippingPlanes, + clipIntersection = material.clipIntersection, + clipShadows = material.clipShadows; + + const materialProperties = properties.get( material ); + + if ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) { + + // there's no local clipping + + if ( renderingShadows ) { + + // there's no global clipping + + projectPlanes( null ); + + } else { + + resetGlobalState(); + + } + + } else { + + const nGlobal = renderingShadows ? 0 : numGlobalPlanes, + lGlobal = nGlobal * 4; + + let dstArray = materialProperties.clippingState || null; + + uniform.value = dstArray; // ensure unique state + + dstArray = projectPlanes( planes, camera, lGlobal, useCache ); + + for ( let i = 0; i !== lGlobal; ++ i ) { + + dstArray[ i ] = globalState[ i ]; + + } + + materialProperties.clippingState = dstArray; + this.numIntersection = clipIntersection ? this.numPlanes : 0; + this.numPlanes += nGlobal; + + } + + + }; + + function resetGlobalState() { + + if ( uniform.value !== globalState ) { + + uniform.value = globalState; + uniform.needsUpdate = numGlobalPlanes > 0; + + } + + scope.numPlanes = numGlobalPlanes; + scope.numIntersection = 0; + + } + + function projectPlanes( planes, camera, dstOffset, skipTransform ) { + + const nPlanes = planes !== null ? planes.length : 0; + let dstArray = null; + + if ( nPlanes !== 0 ) { + + dstArray = uniform.value; + + if ( skipTransform !== true || dstArray === null ) { + + const flatSize = dstOffset + nPlanes * 4, + viewMatrix = camera.matrixWorldInverse; + + viewNormalMatrix.getNormalMatrix( viewMatrix ); + + if ( dstArray === null || dstArray.length < flatSize ) { + + dstArray = new Float32Array( flatSize ); + + } + + for ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) { + + plane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix ); + + plane.normal.toArray( dstArray, i4 ); + dstArray[ i4 + 3 ] = plane.constant; + + } + + } + + uniform.value = dstArray; + uniform.needsUpdate = true; + + } + + scope.numPlanes = nPlanes; + scope.numIntersection = 0; + + return dstArray; + + } + +} + +function WebGLCubeMaps( renderer ) { + + let cubemaps = new WeakMap(); + + function mapTextureMapping( texture, mapping ) { + + if ( mapping === EquirectangularReflectionMapping ) { + + texture.mapping = CubeReflectionMapping; + + } else if ( mapping === EquirectangularRefractionMapping ) { + + texture.mapping = CubeRefractionMapping; + + } + + return texture; + + } + + function get( texture ) { + + if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) { + + const mapping = texture.mapping; + + if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) { + + if ( cubemaps.has( texture ) ) { + + const cubemap = cubemaps.get( texture ).texture; + return mapTextureMapping( cubemap, texture.mapping ); + + } else { + + const image = texture.image; + + if ( image && image.height > 0 ) { + + const renderTarget = new WebGLCubeRenderTarget( image.height / 2 ); + renderTarget.fromEquirectangularTexture( renderer, texture ); + cubemaps.set( texture, renderTarget ); + + texture.addEventListener( 'dispose', onTextureDispose ); + + return mapTextureMapping( renderTarget.texture, texture.mapping ); + + } else { + + // image not yet ready. try the conversion next frame + + return null; + + } + + } + + } + + } + + return texture; + + } + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + const cubemap = cubemaps.get( texture ); + + if ( cubemap !== undefined ) { + + cubemaps.delete( texture ); + cubemap.dispose(); + + } + + } + + function dispose() { + + cubemaps = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +class OrthographicCamera extends Camera { + + constructor( left = - 1, right = 1, top = 1, bottom = - 1, near = 0.1, far = 2000 ) { + + super(); + + this.type = 'OrthographicCamera'; + + this.zoom = 1; + this.view = null; + + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + + this.near = near; + this.far = far; + + this.updateProjectionMatrix(); + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + this.left = source.left; + this.right = source.right; + this.top = source.top; + this.bottom = source.bottom; + this.near = source.near; + this.far = source.far; + + this.zoom = source.zoom; + this.view = source.view === null ? null : Object.assign( {}, source.view ); + + return this; + + } + + setViewOffset( fullWidth, fullHeight, x, y, width, height ) { + + if ( this.view === null ) { + + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }; + + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + + } + + clearViewOffset() { + + if ( this.view !== null ) { + + this.view.enabled = false; + + } + + this.updateProjectionMatrix(); + + } + + updateProjectionMatrix() { + + const dx = ( this.right - this.left ) / ( 2 * this.zoom ); + const dy = ( this.top - this.bottom ) / ( 2 * this.zoom ); + const cx = ( this.right + this.left ) / 2; + const cy = ( this.top + this.bottom ) / 2; + + let left = cx - dx; + let right = cx + dx; + let top = cy + dy; + let bottom = cy - dy; + + if ( this.view !== null && this.view.enabled ) { + + const scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom; + const scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom; + + left += scaleW * this.view.offsetX; + right = left + scaleW * this.view.width; + top -= scaleH * this.view.offsetY; + bottom = top - scaleH * this.view.height; + + } + + this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far ); + + this.projectionMatrixInverse.copy( this.projectionMatrix ).invert(); + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.zoom = this.zoom; + data.object.left = this.left; + data.object.right = this.right; + data.object.top = this.top; + data.object.bottom = this.bottom; + data.object.near = this.near; + data.object.far = this.far; + + if ( this.view !== null ) data.object.view = Object.assign( {}, this.view ); + + return data; + + } + +} + +OrthographicCamera.prototype.isOrthographicCamera = true; + +class RawShaderMaterial extends ShaderMaterial { + + constructor( parameters ) { + + super( parameters ); + + this.type = 'RawShaderMaterial'; + + } + +} + +RawShaderMaterial.prototype.isRawShaderMaterial = true; + +const LOD_MIN = 4; +const LOD_MAX = 8; +const SIZE_MAX = Math.pow( 2, LOD_MAX ); + +// The standard deviations (radians) associated with the extra mips. These are +// chosen to approximate a Trowbridge-Reitz distribution function times the +// geometric shadowing function. These sigma values squared must match the +// variance #defines in cube_uv_reflection_fragment.glsl.js. +const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ]; + +const TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; + +// The maximum length of the blur for loop. Smaller sigmas will use fewer +// samples and exit early, but not recompile the shader. +const MAX_SAMPLES = 20; + +const _flatCamera = /*@__PURE__*/ new OrthographicCamera(); +const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes(); +const _clearColor = /*@__PURE__*/ new Color(); +let _oldTarget = null; + +// Golden Ratio +const PHI = ( 1 + Math.sqrt( 5 ) ) / 2; +const INV_PHI = 1 / PHI; + +// Vertices of a dodecahedron (except the opposites, which represent the +// same axis), used as axis directions evenly spread on a sphere. +const _axisDirections = [ + /*@__PURE__*/ new Vector3( 1, 1, 1 ), + /*@__PURE__*/ new Vector3( - 1, 1, 1 ), + /*@__PURE__*/ new Vector3( 1, 1, - 1 ), + /*@__PURE__*/ new Vector3( - 1, 1, - 1 ), + /*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ), + /*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ), + /*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ), + /*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ), + /*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ), + /*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ) ]; + +/** + * This class generates a Prefiltered, Mipmapped Radiance Environment Map + * (PMREM) from a cubeMap environment texture. This allows different levels of + * blur to be quickly accessed based on material roughness. It is packed into a + * special CubeUV format that allows us to perform custom interpolation so that + * we can support nonlinear formats such as RGBE. Unlike a traditional mipmap + * chain, it only goes down to the LOD_MIN level (above), and then creates extra + * even more filtered 'mips' at the same LOD_MIN resolution, associated with + * higher roughness levels. In this way we maintain resolution to smoothly + * interpolate diffuse lighting while limiting sampling computation. + * + * Paper: Fast, Accurate Image-Based Lighting + * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view +*/ + +class PMREMGenerator { + + constructor( renderer ) { + + this._renderer = renderer; + this._pingPongRenderTarget = null; + + this._blurMaterial = _getBlurShader( MAX_SAMPLES ); + this._equirectShader = null; + this._cubemapShader = null; + + this._compileMaterial( this._blurMaterial ); + + } + + /** + * Generates a PMREM from a supplied Scene, which can be faster than using an + * image if networking bandwidth is low. Optional sigma specifies a blur radius + * in radians to be applied to the scene before PMREM generation. Optional near + * and far planes ensure the scene is rendered in its entirety (the cubeCamera + * is placed at the origin). + */ + fromScene( scene, sigma = 0, near = 0.1, far = 100 ) { + + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = this._allocateTargets(); + + this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); + if ( sigma > 0 ) { + + this._blur( cubeUVRenderTarget, 0, 0, sigma ); + + } + + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); + + return cubeUVRenderTarget; + + } + + /** + * Generates a PMREM from an equirectangular texture, which can be either LDR + * or HDR. The ideal input image size is 1k (1024 x 512), + * as this matches best with the 256 x 256 cubemap output. + */ + fromEquirectangular( equirectangular, renderTarget = null ) { + + return this._fromTexture( equirectangular, renderTarget ); + + } + + /** + * Generates a PMREM from an cubemap texture, which can be either LDR + * or HDR. The ideal input cube size is 256 x 256, + * as this matches best with the 256 x 256 cubemap output. + */ + fromCubemap( cubemap, renderTarget = null ) { + + return this._fromTexture( cubemap, renderTarget ); + + } + + /** + * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileCubemapShader() { + + if ( this._cubemapShader === null ) { + + this._cubemapShader = _getCubemapShader(); + this._compileMaterial( this._cubemapShader ); + + } + + } + + /** + * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileEquirectangularShader() { + + if ( this._equirectShader === null ) { + + this._equirectShader = _getEquirectShader(); + this._compileMaterial( this._equirectShader ); + + } + + } + + /** + * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, + * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on + * one of them will cause any others to also become unusable. + */ + dispose() { + + this._blurMaterial.dispose(); + + if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose(); + + if ( this._cubemapShader !== null ) this._cubemapShader.dispose(); + if ( this._equirectShader !== null ) this._equirectShader.dispose(); + + for ( let i = 0; i < _lodPlanes.length; i ++ ) { + + _lodPlanes[ i ].dispose(); + + } + + } + + // private interface + + _cleanup( outputTarget ) { + + this._renderer.setRenderTarget( _oldTarget ); + outputTarget.scissorTest = false; + _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height ); + + } + + _fromTexture( texture, renderTarget ) { + + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = renderTarget || this._allocateTargets( texture ); + this._textureToCubeUV( texture, cubeUVRenderTarget ); + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); + + return cubeUVRenderTarget; + + } + + _allocateTargets( texture ) { // warning: null texture is valid + + const params = { + magFilter: LinearFilter, + minFilter: LinearFilter, + generateMipmaps: false, + type: HalfFloatType, + format: RGBAFormat, + encoding: LinearEncoding, + depthBuffer: false + }; + + const cubeUVRenderTarget = _createRenderTarget( params ); + cubeUVRenderTarget.depthBuffer = texture ? false : true; + + if ( this._pingPongRenderTarget === null ) { + + this._pingPongRenderTarget = _createRenderTarget( params ); + + } + + return cubeUVRenderTarget; + + } + + _compileMaterial( material ) { + + const tmpMesh = new Mesh( _lodPlanes[ 0 ], material ); + this._renderer.compile( tmpMesh, _flatCamera ); + + } + + _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ) { + + const fov = 90; + const aspect = 1; + const cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); + const upSign = [ 1, - 1, 1, 1, 1, 1 ]; + const forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ]; + const renderer = this._renderer; + + const originalAutoClear = renderer.autoClear; + const toneMapping = renderer.toneMapping; + renderer.getClearColor( _clearColor ); + + renderer.toneMapping = NoToneMapping; + renderer.autoClear = false; + + const backgroundMaterial = new MeshBasicMaterial( { + name: 'PMREM.Background', + side: BackSide, + depthWrite: false, + depthTest: false, + } ); + + const backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial ); + + let useSolidColor = false; + const background = scene.background; + + if ( background ) { + + if ( background.isColor ) { + + backgroundMaterial.color.copy( background ); + scene.background = null; + useSolidColor = true; + + } + + } else { + + backgroundMaterial.color.copy( _clearColor ); + useSolidColor = true; + + } + + for ( let i = 0; i < 6; i ++ ) { + + const col = i % 3; + if ( col === 0 ) { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + + } else if ( col === 1 ) { + + cubeCamera.up.set( 0, 0, upSign[ i ] ); + cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + + } else { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + + } + + _setViewport( cubeUVRenderTarget, + col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); + renderer.setRenderTarget( cubeUVRenderTarget ); + + if ( useSolidColor ) { + + renderer.render( backgroundBox, cubeCamera ); + + } + + renderer.render( scene, cubeCamera ); + + } + + backgroundBox.geometry.dispose(); + backgroundBox.material.dispose(); + + renderer.toneMapping = toneMapping; + renderer.autoClear = originalAutoClear; + scene.background = background; + + } + + _textureToCubeUV( texture, cubeUVRenderTarget ) { + + const renderer = this._renderer; + + const isCubeTexture = ( texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping ); + + if ( isCubeTexture ) { + + if ( this._cubemapShader === null ) { + + this._cubemapShader = _getCubemapShader(); + + } + + this._cubemapShader.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? - 1 : 1; + + } else { + + if ( this._equirectShader === null ) { + + this._equirectShader = _getEquirectShader(); + + } + + } + + const material = isCubeTexture ? this._cubemapShader : this._equirectShader; + const mesh = new Mesh( _lodPlanes[ 0 ], material ); + + const uniforms = material.uniforms; + + uniforms[ 'envMap' ].value = texture; + + if ( ! isCubeTexture ) { + + uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); + + } + + _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); + + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( mesh, _flatCamera ); + + } + + _applyPMREM( cubeUVRenderTarget ) { + + const renderer = this._renderer; + const autoClear = renderer.autoClear; + renderer.autoClear = false; + + for ( let i = 1; i < TOTAL_LODS; i ++ ) { + + const sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); + + const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ]; + + this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); + + } + + renderer.autoClear = autoClear; + + } + + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { + + const pingPongRenderTarget = this._pingPongRenderTarget; + + this._halfBlur( + cubeUVRenderTarget, + pingPongRenderTarget, + lodIn, + lodOut, + sigma, + 'latitudinal', + poleAxis ); + + this._halfBlur( + pingPongRenderTarget, + cubeUVRenderTarget, + lodOut, + lodOut, + sigma, + 'longitudinal', + poleAxis ); + + } + + _halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { + + const renderer = this._renderer; + const blurMaterial = this._blurMaterial; + + if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { + + console.error( + 'blur direction must be either latitudinal or longitudinal!' ); + + } + + // Number of standard deviations at which to cut off the discrete approximation. + const STANDARD_DEVIATIONS = 3; + + const blurMesh = new Mesh( _lodPlanes[ lodOut ], blurMaterial ); + const blurUniforms = blurMaterial.uniforms; + + const pixels = _sizeLods[ lodIn ] - 1; + const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); + const sigmaPixels = sigmaRadians / radiansPerPixel; + const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; + + if ( samples > MAX_SAMPLES ) { + + console.warn( `sigmaRadians, ${ + sigmaRadians}, is too large and will clip, as it requested ${ + samples} samples when the maximum is set to ${MAX_SAMPLES}` ); + + } + + const weights = []; + let sum = 0; + + for ( let i = 0; i < MAX_SAMPLES; ++ i ) { + + const x = i / sigmaPixels; + const weight = Math.exp( - x * x / 2 ); + weights.push( weight ); + + if ( i === 0 ) { + + sum += weight; + + } else if ( i < samples ) { + + sum += 2 * weight; + + } + + } + + for ( let i = 0; i < weights.length; i ++ ) { + + weights[ i ] = weights[ i ] / sum; + + } + + blurUniforms[ 'envMap' ].value = targetIn.texture; + blurUniforms[ 'samples' ].value = samples; + blurUniforms[ 'weights' ].value = weights; + blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; + + if ( poleAxis ) { + + blurUniforms[ 'poleAxis' ].value = poleAxis; + + } + + blurUniforms[ 'dTheta' ].value = radiansPerPixel; + blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; + + const outputSize = _sizeLods[ lodOut ]; + const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); + const y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); + + _setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize ); + renderer.setRenderTarget( targetOut ); + renderer.render( blurMesh, _flatCamera ); + + } + +} + +function _createPlanes() { + + const _lodPlanes = []; + const _sizeLods = []; + const _sigmas = []; + + let lod = LOD_MAX; + + for ( let i = 0; i < TOTAL_LODS; i ++ ) { + + const sizeLod = Math.pow( 2, lod ); + _sizeLods.push( sizeLod ); + let sigma = 1.0 / sizeLod; + + if ( i > LOD_MAX - LOD_MIN ) { + + sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; + + } else if ( i === 0 ) { + + sigma = 0; + + } + + _sigmas.push( sigma ); + + const texelSize = 1.0 / ( sizeLod - 1 ); + const min = - texelSize / 2; + const max = 1 + texelSize / 2; + const uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; + + const cubeFaces = 6; + const vertices = 6; + const positionSize = 3; + const uvSize = 2; + const faceIndexSize = 1; + + const position = new Float32Array( positionSize * vertices * cubeFaces ); + const uv = new Float32Array( uvSize * vertices * cubeFaces ); + const faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); + + for ( let face = 0; face < cubeFaces; face ++ ) { + + const x = ( face % 3 ) * 2 / 3 - 1; + const y = face > 2 ? 0 : - 1; + const coordinates = [ + x, y, 0, + x + 2 / 3, y, 0, + x + 2 / 3, y + 1, 0, + x, y, 0, + x + 2 / 3, y + 1, 0, + x, y + 1, 0 + ]; + position.set( coordinates, positionSize * vertices * face ); + uv.set( uv1, uvSize * vertices * face ); + const fill = [ face, face, face, face, face, face ]; + faceIndex.set( fill, faceIndexSize * vertices * face ); + + } + + const planes = new BufferGeometry(); + planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); + planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); + planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); + _lodPlanes.push( planes ); + + if ( lod > LOD_MIN ) { + + lod --; + + } + + } + + return { _lodPlanes, _sizeLods, _sigmas }; + +} + +function _createRenderTarget( params ) { + + const cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); + cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; + cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; + cubeUVRenderTarget.scissorTest = true; + return cubeUVRenderTarget; + +} + +function _setViewport( target, x, y, width, height ) { + + target.viewport.set( x, y, width, height ); + target.scissor.set( x, y, width, height ); + +} + +function _getBlurShader( maxSamples ) { + + const weights = new Float32Array( maxSamples ); + const poleAxis = new Vector3( 0, 1, 0 ); + const shaderMaterial = new RawShaderMaterial( { + + name: 'SphericalGaussianBlur', + + defines: { 'n': maxSamples }, + + uniforms: { + 'envMap': { value: null }, + 'samples': { value: 1 }, + 'weights': { value: weights }, + 'latitudinal': { value: false }, + 'dTheta': { value: 0 }, + 'mipInt': { value: 0 }, + 'poleAxis': { value: poleAxis } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getEquirectShader() { + + const texelSize = new Vector2( 1, 1 ); + const shaderMaterial = new RawShaderMaterial( { + + name: 'EquirectangularToCubeUV', + + uniforms: { + 'envMap': { value: null }, + 'texelSize': { value: texelSize } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform vec2 texelSize; + + #include + + void main() { + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + vec2 f = fract( uv / texelSize - 0.5 ); + uv -= f * texelSize; + vec3 tl = texture2D ( envMap, uv ).rgb; + uv.x += texelSize.x; + vec3 tr = texture2D ( envMap, uv ).rgb; + uv.y += texelSize.y; + vec3 br = texture2D ( envMap, uv ).rgb; + uv.x -= texelSize.x; + vec3 bl = texture2D ( envMap, uv ).rgb; + + vec3 tm = mix( tl, tr, f.x ); + vec3 bm = mix( bl, br, f.x ); + gl_FragColor.rgb = mix( tm, bm, f.y ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getCubemapShader() { + + const shaderMaterial = new RawShaderMaterial( { + + name: 'CubemapToCubeUV', + + uniforms: { + 'envMap': { value: null }, + 'flipEnvMap': { value: - 1 } + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false + + } ); + + return shaderMaterial; + +} + +function _getCommonVertexShader() { + + return /* glsl */` + + precision mediump float; + precision mediump int; + + attribute vec3 position; + attribute vec2 uv; + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `; + +} + +function WebGLCubeUVMaps( renderer ) { + + let cubeUVmaps = new WeakMap(); + + let pmremGenerator = null; + + function get( texture ) { + + if ( texture && texture.isTexture ) { + + const mapping = texture.mapping; + + const isEquirectMap = ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ); + const isCubeMap = ( mapping === CubeReflectionMapping || mapping === CubeRefractionMapping ); + + // equirect/cube map to cubeUV conversion + + if ( isEquirectMap || isCubeMap ) { + + if ( texture.isRenderTargetTexture && texture.needsPMREMUpdate === true ) { + + texture.needsPMREMUpdate = false; + + let renderTarget = cubeUVmaps.get( texture ); + + if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer ); + + renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget ); + cubeUVmaps.set( texture, renderTarget ); + + return renderTarget.texture; + + } else { + + if ( cubeUVmaps.has( texture ) ) { + + return cubeUVmaps.get( texture ).texture; + + } else { + + const image = texture.image; + + if ( ( isEquirectMap && image && image.height > 0 ) || ( isCubeMap && image && isCubeTextureComplete( image ) ) ) { + + if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer ); + + const renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture ); + cubeUVmaps.set( texture, renderTarget ); + + texture.addEventListener( 'dispose', onTextureDispose ); + + return renderTarget.texture; + + } else { + + // image not yet ready. try the conversion next frame + + return null; + + } + + } + + } + + } + + } + + return texture; + + } + + function isCubeTextureComplete( image ) { + + let count = 0; + const length = 6; + + for ( let i = 0; i < length; i ++ ) { + + if ( image[ i ] !== undefined ) count ++; + + } + + return count === length; + + + } + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + const cubemapUV = cubeUVmaps.get( texture ); + + if ( cubemapUV !== undefined ) { + + cubeUVmaps.delete( texture ); + cubemapUV.dispose(); + + } + + } + + function dispose() { + + cubeUVmaps = new WeakMap(); + + if ( pmremGenerator !== null ) { + + pmremGenerator.dispose(); + pmremGenerator = null; + + } + + } + + return { + get: get, + dispose: dispose + }; + +} + +function WebGLExtensions( gl ) { + + const extensions = {}; + + function getExtension( name ) { + + if ( extensions[ name ] !== undefined ) { + + return extensions[ name ]; + + } + + let extension; + + switch ( name ) { + + case 'WEBGL_depth_texture': + extension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' ); + break; + + case 'EXT_texture_filter_anisotropic': + extension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' ); + break; + + case 'WEBGL_compressed_texture_s3tc': + extension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' ); + break; + + case 'WEBGL_compressed_texture_pvrtc': + extension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' ); + break; + + default: + extension = gl.getExtension( name ); + + } + + extensions[ name ] = extension; + + return extension; + + } + + return { + + has: function ( name ) { + + return getExtension( name ) !== null; + + }, + + init: function ( capabilities ) { + + if ( capabilities.isWebGL2 ) { + + getExtension( 'EXT_color_buffer_float' ); + + } else { + + getExtension( 'WEBGL_depth_texture' ); + getExtension( 'OES_texture_float' ); + getExtension( 'OES_texture_half_float' ); + getExtension( 'OES_texture_half_float_linear' ); + getExtension( 'OES_standard_derivatives' ); + getExtension( 'OES_element_index_uint' ); + getExtension( 'OES_vertex_array_object' ); + getExtension( 'ANGLE_instanced_arrays' ); + + } + + getExtension( 'OES_texture_float_linear' ); + getExtension( 'EXT_color_buffer_half_float' ); + getExtension( 'WEBGL_multisampled_render_to_texture' ); + + }, + + get: function ( name ) { + + const extension = getExtension( name ); + + if ( extension === null ) { + + console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' ); + + } + + return extension; + + } + + }; + +} + +function WebGLGeometries( gl, attributes, info, bindingStates ) { + + const geometries = {}; + const wireframeAttributes = new WeakMap(); + + function onGeometryDispose( event ) { + + const geometry = event.target; + + if ( geometry.index !== null ) { + + attributes.remove( geometry.index ); + + } + + for ( const name in geometry.attributes ) { + + attributes.remove( geometry.attributes[ name ] ); + + } + + geometry.removeEventListener( 'dispose', onGeometryDispose ); + + delete geometries[ geometry.id ]; + + const attribute = wireframeAttributes.get( geometry ); + + if ( attribute ) { + + attributes.remove( attribute ); + wireframeAttributes.delete( geometry ); + + } + + bindingStates.releaseStatesOfGeometry( geometry ); + + if ( geometry.isInstancedBufferGeometry === true ) { + + delete geometry._maxInstanceCount; + + } + + // + + info.memory.geometries --; + + } + + function get( object, geometry ) { + + if ( geometries[ geometry.id ] === true ) return geometry; + + geometry.addEventListener( 'dispose', onGeometryDispose ); + + geometries[ geometry.id ] = true; + + info.memory.geometries ++; + + return geometry; + + } + + function update( geometry ) { + + const geometryAttributes = geometry.attributes; + + // Updating index buffer in VAO now. See WebGLBindingStates. + + for ( const name in geometryAttributes ) { + + attributes.update( geometryAttributes[ name ], 34962 ); + + } + + // morph targets + + const morphAttributes = geometry.morphAttributes; + + for ( const name in morphAttributes ) { + + const array = morphAttributes[ name ]; + + for ( let i = 0, l = array.length; i < l; i ++ ) { + + attributes.update( array[ i ], 34962 ); + + } + + } + + } + + function updateWireframeAttribute( geometry ) { + + const indices = []; + + const geometryIndex = geometry.index; + const geometryPosition = geometry.attributes.position; + let version = 0; + + if ( geometryIndex !== null ) { + + const array = geometryIndex.array; + version = geometryIndex.version; + + for ( let i = 0, l = array.length; i < l; i += 3 ) { + + const a = array[ i + 0 ]; + const b = array[ i + 1 ]; + const c = array[ i + 2 ]; + + indices.push( a, b, b, c, c, a ); + + } + + } else { + + const array = geometryPosition.array; + version = geometryPosition.version; + + for ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) { + + const a = i + 0; + const b = i + 1; + const c = i + 2; + + indices.push( a, b, b, c, c, a ); + + } + + } + + const attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ); + attribute.version = version; + + // Updating index buffer in VAO now. See WebGLBindingStates + + // + + const previousAttribute = wireframeAttributes.get( geometry ); + + if ( previousAttribute ) attributes.remove( previousAttribute ); + + // + + wireframeAttributes.set( geometry, attribute ); + + } + + function getWireframeAttribute( geometry ) { + + const currentAttribute = wireframeAttributes.get( geometry ); + + if ( currentAttribute ) { + + const geometryIndex = geometry.index; + + if ( geometryIndex !== null ) { + + // if the attribute is obsolete, create a new one + + if ( currentAttribute.version < geometryIndex.version ) { + + updateWireframeAttribute( geometry ); + + } + + } + + } else { + + updateWireframeAttribute( geometry ); + + } + + return wireframeAttributes.get( geometry ); + + } + + return { + + get: get, + update: update, + + getWireframeAttribute: getWireframeAttribute + + }; + +} + +function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode( value ) { + + mode = value; + + } + + let type, bytesPerElement; + + function setIndex( value ) { + + type = value.type; + bytesPerElement = value.bytesPerElement; + + } + + function render( start, count ) { + + gl.drawElements( mode, count, type, start * bytesPerElement ); + + info.update( count, mode, 1 ); + + } + + function renderInstances( start, count, primcount ) { + + if ( primcount === 0 ) return; + + let extension, methodName; + + if ( isWebGL2 ) { + + extension = gl; + methodName = 'drawElementsInstanced'; + + } else { + + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawElementsInstancedANGLE'; + + if ( extension === null ) { + + console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); + return; + + } + + } + + extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount ); + + info.update( count, mode, primcount ); + + } + + // + + this.setMode = setMode; + this.setIndex = setIndex; + this.render = render; + this.renderInstances = renderInstances; + +} + +function WebGLInfo( gl ) { + + const memory = { + geometries: 0, + textures: 0 + }; + + const render = { + frame: 0, + calls: 0, + triangles: 0, + points: 0, + lines: 0 + }; + + function update( count, mode, instanceCount ) { + + render.calls ++; + + switch ( mode ) { + + case 4: + render.triangles += instanceCount * ( count / 3 ); + break; + + case 1: + render.lines += instanceCount * ( count / 2 ); + break; + + case 3: + render.lines += instanceCount * ( count - 1 ); + break; + + case 2: + render.lines += instanceCount * count; + break; + + case 0: + render.points += instanceCount * count; + break; + + default: + console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode ); + break; + + } + + } + + function reset() { + + render.frame ++; + render.calls = 0; + render.triangles = 0; + render.points = 0; + render.lines = 0; + + } + + return { + memory: memory, + render: render, + programs: null, + autoReset: true, + reset: reset, + update: update + }; + +} + +class DataTexture2DArray extends Texture { + + constructor( data = null, width = 1, height = 1, depth = 1 ) { + + super( null ); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture2DArray.prototype.isDataTexture2DArray = true; + +function numericalSort( a, b ) { + + return a[ 0 ] - b[ 0 ]; + +} + +function absNumericalSort( a, b ) { + + return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] ); + +} + +function denormalize( morph, attribute ) { + + let denominator = 1; + const array = attribute.isInterleavedBufferAttribute ? attribute.data.array : attribute.array; + + if ( array instanceof Int8Array ) denominator = 127; + else if ( array instanceof Int16Array ) denominator = 32767; + else if ( array instanceof Int32Array ) denominator = 2147483647; + else console.error( 'THREE.WebGLMorphtargets: Unsupported morph attribute data type: ', array ); + + morph.divideScalar( denominator ); + +} + +function WebGLMorphtargets( gl, capabilities, textures ) { + + const influencesList = {}; + const morphInfluences = new Float32Array( 8 ); + const morphTextures = new WeakMap(); + const morph = new Vector3(); + + const workInfluences = []; + + for ( let i = 0; i < 8; i ++ ) { + + workInfluences[ i ] = [ i, 0 ]; + + } + + function update( object, geometry, material, program ) { + + const objectInfluences = object.morphTargetInfluences; + + if ( capabilities.isWebGL2 === true ) { + + // instead of using attributes, the WebGL 2 code path encodes morph targets + // into an array of data textures. Each layer represents a single morph target. + + const numberOfMorphTargets = geometry.morphAttributes.position.length; + + let entry = morphTextures.get( geometry ); + + if ( entry === undefined || entry.count !== numberOfMorphTargets ) { + + if ( entry !== undefined ) entry.texture.dispose(); + + const hasMorphNormals = geometry.morphAttributes.normal !== undefined; + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal || []; + + const numberOfVertices = geometry.attributes.position.count; + const numberOfVertexData = ( hasMorphNormals === true ) ? 2 : 1; // (v,n) vs. (v) + + let width = numberOfVertices * numberOfVertexData; + let height = 1; + + if ( width > capabilities.maxTextureSize ) { + + height = Math.ceil( width / capabilities.maxTextureSize ); + width = capabilities.maxTextureSize; + + } + + const buffer = new Float32Array( width * height * 4 * numberOfMorphTargets ); + + const texture = new DataTexture2DArray( buffer, width, height, numberOfMorphTargets ); + texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower) + texture.type = FloatType; + texture.needsUpdate = true; + + // fill buffer + + const vertexDataStride = numberOfVertexData * 4; + + for ( let i = 0; i < numberOfMorphTargets; i ++ ) { + + const morphTarget = morphTargets[ i ]; + const morphNormal = morphNormals[ i ]; + + const offset = width * height * 4 * i; + + for ( let j = 0; j < morphTarget.count; j ++ ) { + + morph.fromBufferAttribute( morphTarget, j ); + + if ( morphTarget.normalized === true ) denormalize( morph, morphTarget ); + + const stride = j * vertexDataStride; + + buffer[ offset + stride + 0 ] = morph.x; + buffer[ offset + stride + 1 ] = morph.y; + buffer[ offset + stride + 2 ] = morph.z; + buffer[ offset + stride + 3 ] = 0; + + if ( hasMorphNormals === true ) { + + morph.fromBufferAttribute( morphNormal, j ); + + if ( morphNormal.normalized === true ) denormalize( morph, morphNormal ); + + buffer[ offset + stride + 4 ] = morph.x; + buffer[ offset + stride + 5 ] = morph.y; + buffer[ offset + stride + 6 ] = morph.z; + buffer[ offset + stride + 7 ] = 0; + + } + + } + + } + + entry = { + count: numberOfMorphTargets, + texture: texture, + size: new Vector2( width, height ) + }; + + morphTextures.set( geometry, entry ); + + function disposeTexture() { + + texture.dispose(); + + morphTextures.delete( geometry ); + + geometry.removeEventListener( 'dispose', disposeTexture ); + + } + + geometry.addEventListener( 'dispose', disposeTexture ); + + } + + // + + let morphInfluencesSum = 0; + + for ( let i = 0; i < objectInfluences.length; i ++ ) { + + morphInfluencesSum += objectInfluences[ i ]; + + } + + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence ); + program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences ); + + program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures ); + program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size ); + + + } else { + + // When object doesn't have morph target influences defined, we treat it as a 0-length array + // This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences + + const length = objectInfluences === undefined ? 0 : objectInfluences.length; + + let influences = influencesList[ geometry.id ]; + + if ( influences === undefined || influences.length !== length ) { + + // initialise list + + influences = []; + + for ( let i = 0; i < length; i ++ ) { + + influences[ i ] = [ i, 0 ]; + + } + + influencesList[ geometry.id ] = influences; + + } + + // Collect influences + + for ( let i = 0; i < length; i ++ ) { + + const influence = influences[ i ]; + + influence[ 0 ] = i; + influence[ 1 ] = objectInfluences[ i ]; + + } + + influences.sort( absNumericalSort ); + + for ( let i = 0; i < 8; i ++ ) { + + if ( i < length && influences[ i ][ 1 ] ) { + + workInfluences[ i ][ 0 ] = influences[ i ][ 0 ]; + workInfluences[ i ][ 1 ] = influences[ i ][ 1 ]; + + } else { + + workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER; + workInfluences[ i ][ 1 ] = 0; + + } + + } + + workInfluences.sort( numericalSort ); + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal; + + let morphInfluencesSum = 0; + + for ( let i = 0; i < 8; i ++ ) { + + const influence = workInfluences[ i ]; + const index = influence[ 0 ]; + const value = influence[ 1 ]; + + if ( index !== Number.MAX_SAFE_INTEGER && value ) { + + if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) { + + geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] ); + + } + + if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) { + + geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] ); + + } + + morphInfluences[ i ] = value; + morphInfluencesSum += value; + + } else { + + if ( morphTargets && geometry.hasAttribute( 'morphTarget' + i ) === true ) { + + geometry.deleteAttribute( 'morphTarget' + i ); + + } + + if ( morphNormals && geometry.hasAttribute( 'morphNormal' + i ) === true ) { + + geometry.deleteAttribute( 'morphNormal' + i ); + + } + + morphInfluences[ i ] = 0; + + } + + } + + // GLSL shader uses formula baseinfluence * base + sum(target * influence) + // This allows us to switch between absolute morphs and relative morphs without changing shader code + // When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence) + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence ); + program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences ); + + } + + } + + return { + + update: update + + }; + +} + +function WebGLObjects( gl, geometries, attributes, info ) { + + let updateMap = new WeakMap(); + + function update( object ) { + + const frame = info.render.frame; + + const geometry = object.geometry; + const buffergeometry = geometries.get( object, geometry ); + + // Update once per frame + + if ( updateMap.get( buffergeometry ) !== frame ) { + + geometries.update( buffergeometry ); + + updateMap.set( buffergeometry, frame ); + + } + + if ( object.isInstancedMesh ) { + + if ( object.hasEventListener( 'dispose', onInstancedMeshDispose ) === false ) { + + object.addEventListener( 'dispose', onInstancedMeshDispose ); + + } + + attributes.update( object.instanceMatrix, 34962 ); + + if ( object.instanceColor !== null ) { + + attributes.update( object.instanceColor, 34962 ); + + } + + } + + return buffergeometry; + + } + + function dispose() { + + updateMap = new WeakMap(); + + } + + function onInstancedMeshDispose( event ) { + + const instancedMesh = event.target; + + instancedMesh.removeEventListener( 'dispose', onInstancedMeshDispose ); + + attributes.remove( instancedMesh.instanceMatrix ); + + if ( instancedMesh.instanceColor !== null ) attributes.remove( instancedMesh.instanceColor ); + + } + + return { + + update: update, + dispose: dispose + + }; + +} + +class DataTexture3D extends Texture { + + constructor( data = null, width = 1, height = 1, depth = 1 ) { + + // We're going to add .setXXX() methods for setting properties later. + // Users can still set in DataTexture3D directly. + // + // const texture = new THREE.DataTexture3D( data, width, height, depth ); + // texture.anisotropy = 16; + // + // See #14839 + + super( null ); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture3D.prototype.isDataTexture3D = true; + +/** + * Uniforms of a program. + * Those form a tree structure with a special top-level container for the root, + * which you get by calling 'new WebGLUniforms( gl, program )'. + * + * + * Properties of inner nodes including the top-level container: + * + * .seq - array of nested uniforms + * .map - nested uniforms by name + * + * + * Methods of all nodes except the top-level container: + * + * .setValue( gl, value, [textures] ) + * + * uploads a uniform value(s) + * the 'textures' parameter is needed for sampler uniforms + * + * + * Static methods of the top-level container (textures factorizations): + * + * .upload( gl, seq, values, textures ) + * + * sets uniforms in 'seq' to 'values[id].value' + * + * .seqWithValue( seq, values ) : filteredSeq + * + * filters 'seq' entries with corresponding entry in values + * + * + * Methods of the top-level container (textures factorizations): + * + * .setValue( gl, name, value, textures ) + * + * sets uniform with name 'name' to 'value' + * + * .setOptional( gl, obj, prop ) + * + * like .set for an optional property of the object + * + */ + +const emptyTexture = new Texture(); +const emptyTexture2dArray = new DataTexture2DArray(); +const emptyTexture3d = new DataTexture3D(); +const emptyCubeTexture = new CubeTexture(); + +// --- Utilities --- + +// Array Caches (provide typed arrays for temporary by size) + +const arrayCacheF32 = []; +const arrayCacheI32 = []; + +// Float32Array caches used for uploading Matrix uniforms + +const mat4array = new Float32Array( 16 ); +const mat3array = new Float32Array( 9 ); +const mat2array = new Float32Array( 4 ); + +// Flattening for arrays of vectors and matrices + +function flatten( array, nBlocks, blockSize ) { + + const firstElem = array[ 0 ]; + + if ( firstElem <= 0 || firstElem > 0 ) return array; + // unoptimized: ! isNaN( firstElem ) + // see http://jacksondunstan.com/articles/983 + + const n = nBlocks * blockSize; + let r = arrayCacheF32[ n ]; + + if ( r === undefined ) { + + r = new Float32Array( n ); + arrayCacheF32[ n ] = r; + + } + + if ( nBlocks !== 0 ) { + + firstElem.toArray( r, 0 ); + + for ( let i = 1, offset = 0; i !== nBlocks; ++ i ) { + + offset += blockSize; + array[ i ].toArray( r, offset ); + + } + + } + + return r; + +} + +function arraysEqual( a, b ) { + + if ( a.length !== b.length ) return false; + + for ( let i = 0, l = a.length; i < l; i ++ ) { + + if ( a[ i ] !== b[ i ] ) return false; + + } + + return true; + +} + +function copyArray( a, b ) { + + for ( let i = 0, l = b.length; i < l; i ++ ) { + + a[ i ] = b[ i ]; + + } + +} + +// Texture unit allocation + +function allocTexUnits( textures, n ) { + + let r = arrayCacheI32[ n ]; + + if ( r === undefined ) { + + r = new Int32Array( n ); + arrayCacheI32[ n ] = r; + + } + + for ( let i = 0; i !== n; ++ i ) { + + r[ i ] = textures.allocateTextureUnit(); + + } + + return r; + +} + +// --- Setters --- + +// Note: Defining these methods externally, because they come in a bunch +// and this way their names minify. + +// Single scalar + +function setValueV1f( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1f( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single float vector (from flat array or THREE.VectorN) + +function setValueV2f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) { + + gl.uniform2f( this.addr, v.x, v.y ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +function setValueV3f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) { + + gl.uniform3f( this.addr, v.x, v.y, v.z ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + cache[ 2 ] = v.z; + + } + + } else if ( v.r !== undefined ) { + + if ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) { + + gl.uniform3f( this.addr, v.r, v.g, v.b ); + + cache[ 0 ] = v.r; + cache[ 1 ] = v.g; + cache[ 2 ] = v.b; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +function setValueV4f( gl, v ) { + + const cache = this.cache; + + if ( v.x !== undefined ) { + + if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) { + + gl.uniform4f( this.addr, v.x, v.y, v.z, v.w ); + + cache[ 0 ] = v.x; + cache[ 1 ] = v.y; + cache[ 2 ] = v.z; + cache[ 3 ] = v.w; + + } + + } else { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4fv( this.addr, v ); + + copyArray( cache, v ); + + } + +} + +// Single matrix (from flat array or THREE.MatrixN) + +function setValueM2( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix2fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat2array.set( elements ); + + gl.uniformMatrix2fv( this.addr, false, mat2array ); + + copyArray( cache, elements ); + + } + +} + +function setValueM3( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix3fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat3array.set( elements ); + + gl.uniformMatrix3fv( this.addr, false, mat3array ); + + copyArray( cache, elements ); + + } + +} + +function setValueM4( gl, v ) { + + const cache = this.cache; + const elements = v.elements; + + if ( elements === undefined ) { + + if ( arraysEqual( cache, v ) ) return; + + gl.uniformMatrix4fv( this.addr, false, v ); + + copyArray( cache, v ); + + } else { + + if ( arraysEqual( cache, elements ) ) return; + + mat4array.set( elements ); + + gl.uniformMatrix4fv( this.addr, false, mat4array ); + + copyArray( cache, elements ); + + } + +} + +// Single integer / boolean + +function setValueV1i( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1i( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single integer / boolean vector (from flat array) + +function setValueV2i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2iv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV3i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3iv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV4i( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4iv( this.addr, v ); + + copyArray( cache, v ); + +} + +// Single unsigned integer + +function setValueV1ui( gl, v ) { + + const cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1ui( this.addr, v ); + + cache[ 0 ] = v; + +} + +// Single unsigned integer vector (from flat array) + +function setValueV2ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform2uiv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV3ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform3uiv( this.addr, v ); + + copyArray( cache, v ); + +} + +function setValueV4ui( gl, v ) { + + const cache = this.cache; + + if ( arraysEqual( cache, v ) ) return; + + gl.uniform4uiv( this.addr, v ); + + copyArray( cache, v ); + +} + + +// Single texture (2D / Cube) + +function setValueT1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.safeSetTexture2D( v || emptyTexture, unit ); + +} + +function setValueT3D1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.setTexture3D( v || emptyTexture3d, unit ); + +} + +function setValueT6( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.safeSetTextureCube( v || emptyCubeTexture, unit ); + +} + +function setValueT2DArray1( gl, v, textures ) { + + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if ( cache[ 0 ] !== unit ) { + + gl.uniform1i( this.addr, unit ); + cache[ 0 ] = unit; + + } + + textures.setTexture2DArray( v || emptyTexture2dArray, unit ); + +} + +// Helper to pick the right setter for the singular case + +function getSingularSetter( type ) { + + switch ( type ) { + + case 0x1406: return setValueV1f; // FLOAT + case 0x8b50: return setValueV2f; // _VEC2 + case 0x8b51: return setValueV3f; // _VEC3 + case 0x8b52: return setValueV4f; // _VEC4 + + case 0x8b5a: return setValueM2; // _MAT2 + case 0x8b5b: return setValueM3; // _MAT3 + case 0x8b5c: return setValueM4; // _MAT4 + + case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4 + + case 0x1405: return setValueV1ui; // UINT + case 0x8dc6: return setValueV2ui; // _VEC2 + case 0x8dc7: return setValueV3ui; // _VEC3 + case 0x8dc8: return setValueV4ui; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3D1; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArray1; + + } + +} + + +// Array of scalars + +function setValueV1fArray( gl, v ) { + + gl.uniform1fv( this.addr, v ); + +} + +// Array of vectors (from flat array or array of THREE.VectorN) + +function setValueV2fArray( gl, v ) { + + const data = flatten( v, this.size, 2 ); + + gl.uniform2fv( this.addr, data ); + +} + +function setValueV3fArray( gl, v ) { + + const data = flatten( v, this.size, 3 ); + + gl.uniform3fv( this.addr, data ); + +} + +function setValueV4fArray( gl, v ) { + + const data = flatten( v, this.size, 4 ); + + gl.uniform4fv( this.addr, data ); + +} + +// Array of matrices (from flat array or array of THREE.MatrixN) + +function setValueM2Array( gl, v ) { + + const data = flatten( v, this.size, 4 ); + + gl.uniformMatrix2fv( this.addr, false, data ); + +} + +function setValueM3Array( gl, v ) { + + const data = flatten( v, this.size, 9 ); + + gl.uniformMatrix3fv( this.addr, false, data ); + +} + +function setValueM4Array( gl, v ) { + + const data = flatten( v, this.size, 16 ); + + gl.uniformMatrix4fv( this.addr, false, data ); + +} + +// Array of integer / boolean + +function setValueV1iArray( gl, v ) { + + gl.uniform1iv( this.addr, v ); + +} + +// Array of integer / boolean vectors (from flat array) + +function setValueV2iArray( gl, v ) { + + gl.uniform2iv( this.addr, v ); + +} + +function setValueV3iArray( gl, v ) { + + gl.uniform3iv( this.addr, v ); + +} + +function setValueV4iArray( gl, v ) { + + gl.uniform4iv( this.addr, v ); + +} + +// Array of unsigned integer + +function setValueV1uiArray( gl, v ) { + + gl.uniform1uiv( this.addr, v ); + +} + +// Array of unsigned integer vectors (from flat array) + +function setValueV2uiArray( gl, v ) { + + gl.uniform2uiv( this.addr, v ); + +} + +function setValueV3uiArray( gl, v ) { + + gl.uniform3uiv( this.addr, v ); + +} + +function setValueV4uiArray( gl, v ) { + + gl.uniform4uiv( this.addr, v ); + +} + + +// Array of textures (2D / 3D / Cube / 2DArray) + +function setValueT1Array( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] ); + + } + +} + +function setValueT3DArray( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.setTexture3D( v[ i ] || emptyTexture3d, units[ i ] ); + + } + +} + +function setValueT6Array( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] ); + + } + +} + +function setValueT2DArrayArray( gl, v, textures ) { + + const n = v.length; + + const units = allocTexUnits( textures, n ); + + gl.uniform1iv( this.addr, units ); + + for ( let i = 0; i !== n; ++ i ) { + + textures.setTexture2DArray( v[ i ] || emptyTexture2dArray, units[ i ] ); + + } + +} + + +// Helper to pick the right setter for a pure (bottom-level) array + +function getPureArraySetter( type ) { + + switch ( type ) { + + case 0x1406: return setValueV1fArray; // FLOAT + case 0x8b50: return setValueV2fArray; // _VEC2 + case 0x8b51: return setValueV3fArray; // _VEC3 + case 0x8b52: return setValueV4fArray; // _VEC4 + + case 0x8b5a: return setValueM2Array; // _MAT2 + case 0x8b5b: return setValueM3Array; // _MAT3 + case 0x8b5c: return setValueM4Array; // _MAT4 + + case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 + + case 0x1405: return setValueV1uiArray; // UINT + case 0x8dc6: return setValueV2uiArray; // _VEC2 + case 0x8dc7: return setValueV3uiArray; // _VEC3 + case 0x8dc8: return setValueV4uiArray; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1Array; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3DArray; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6Array; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArrayArray; + + } + +} + +// --- Uniform Classes --- + +function SingleUniform( id, activeInfo, addr ) { + + this.id = id; + this.addr = addr; + this.cache = []; + this.setValue = getSingularSetter( activeInfo.type ); + + // this.path = activeInfo.name; // DEBUG + +} + +function PureArrayUniform( id, activeInfo, addr ) { + + this.id = id; + this.addr = addr; + this.cache = []; + this.size = activeInfo.size; + this.setValue = getPureArraySetter( activeInfo.type ); + + // this.path = activeInfo.name; // DEBUG + +} + +PureArrayUniform.prototype.updateCache = function ( data ) { + + const cache = this.cache; + + if ( data instanceof Float32Array && cache.length !== data.length ) { + + this.cache = new Float32Array( data.length ); + + } + + copyArray( cache, data ); + +}; + +function StructuredUniform( id ) { + + this.id = id; + + this.seq = []; + this.map = {}; + +} + +StructuredUniform.prototype.setValue = function ( gl, value, textures ) { + + const seq = this.seq; + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ]; + u.setValue( gl, value[ u.id ], textures ); + + } + +}; + +// --- Top-level --- + +// Parser - builds up the property tree from the path strings + +const RePathPart = /(\w+)(\])?(\[|\.)?/g; + +// extracts +// - the identifier (member name or array index) +// - followed by an optional right bracket (found when array index) +// - followed by an optional left bracket or dot (type of subscript) +// +// Note: These portions can be read in a non-overlapping fashion and +// allow straightforward parsing of the hierarchy that WebGL encodes +// in the uniform names. + +function addUniform( container, uniformObject ) { + + container.seq.push( uniformObject ); + container.map[ uniformObject.id ] = uniformObject; + +} + +function parseUniform( activeInfo, addr, container ) { + + const path = activeInfo.name, + pathLength = path.length; + + // reset RegExp object, because of the early exit of a previous run + RePathPart.lastIndex = 0; + + while ( true ) { + + const match = RePathPart.exec( path ), + matchEnd = RePathPart.lastIndex; + + let id = match[ 1 ]; + const idIsIndex = match[ 2 ] === ']', + subscript = match[ 3 ]; + + if ( idIsIndex ) id = id | 0; // convert to integer + + if ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) { + + // bare name or "pure" bottom-level array "[0]" suffix + + addUniform( container, subscript === undefined ? + new SingleUniform( id, activeInfo, addr ) : + new PureArrayUniform( id, activeInfo, addr ) ); + + break; + + } else { + + // step into inner node / create it in case it doesn't exist + + const map = container.map; + let next = map[ id ]; + + if ( next === undefined ) { + + next = new StructuredUniform( id ); + addUniform( container, next ); + + } + + container = next; + + } + + } + +} + +// Root Container + +function WebGLUniforms( gl, program ) { + + this.seq = []; + this.map = {}; + + const n = gl.getProgramParameter( program, 35718 ); + + for ( let i = 0; i < n; ++ i ) { + + const info = gl.getActiveUniform( program, i ), + addr = gl.getUniformLocation( program, info.name ); + + parseUniform( info, addr, this ); + + } + +} + +WebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) { + + const u = this.map[ name ]; + + if ( u !== undefined ) u.setValue( gl, value, textures ); + +}; + +WebGLUniforms.prototype.setOptional = function ( gl, object, name ) { + + const v = object[ name ]; + + if ( v !== undefined ) this.setValue( gl, name, v ); + +}; + + +// Static interface + +WebGLUniforms.upload = function ( gl, seq, values, textures ) { + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ], + v = values[ u.id ]; + + if ( v.needsUpdate !== false ) { + + // note: always updating when .needsUpdate is undefined + u.setValue( gl, v.value, textures ); + + } + + } + +}; + +WebGLUniforms.seqWithValue = function ( seq, values ) { + + const r = []; + + for ( let i = 0, n = seq.length; i !== n; ++ i ) { + + const u = seq[ i ]; + if ( u.id in values ) r.push( u ); + + } + + return r; + +}; + +function WebGLShader( gl, type, string ) { + + const shader = gl.createShader( type ); + + gl.shaderSource( shader, string ); + gl.compileShader( shader ); + + return shader; + +} + +let programIdCount = 0; + +function addLineNumbers( string ) { + + const lines = string.split( '\n' ); + + for ( let i = 0; i < lines.length; i ++ ) { + + lines[ i ] = ( i + 1 ) + ': ' + lines[ i ]; + + } + + return lines.join( '\n' ); + +} + +function getEncodingComponents( encoding ) { + + switch ( encoding ) { + + case LinearEncoding: + return [ 'Linear', '( value )' ]; + case sRGBEncoding: + return [ 'sRGB', '( value )' ]; + default: + console.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding ); + return [ 'Linear', '( value )' ]; + + } + +} + +function getShaderErrors( gl, shader, type ) { + + const status = gl.getShaderParameter( shader, 35713 ); + const errors = gl.getShaderInfoLog( shader ).trim(); + + if ( status && errors === '' ) return ''; + + // --enable-privileged-webgl-extension + // console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) ); + + return type.toUpperCase() + '\n\n' + errors + '\n\n' + addLineNumbers( gl.getShaderSource( shader ) ); + +} + +function getTexelEncodingFunction( functionName, encoding ) { + + const components = getEncodingComponents( encoding ); + return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }'; + +} + +function getToneMappingFunction( functionName, toneMapping ) { + + let toneMappingName; + + switch ( toneMapping ) { + + case LinearToneMapping: + toneMappingName = 'Linear'; + break; + + case ReinhardToneMapping: + toneMappingName = 'Reinhard'; + break; + + case CineonToneMapping: + toneMappingName = 'OptimizedCineon'; + break; + + case ACESFilmicToneMapping: + toneMappingName = 'ACESFilmic'; + break; + + case CustomToneMapping: + toneMappingName = 'Custom'; + break; + + default: + console.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping ); + toneMappingName = 'Linear'; + + } + + return 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }'; + +} + +function generateExtensions( parameters ) { + + const chunks = [ + ( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', + ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', + ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '', + ( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : '' + ]; + + return chunks.filter( filterEmptyLine ).join( '\n' ); + +} + +function generateDefines( defines ) { + + const chunks = []; + + for ( const name in defines ) { + + const value = defines[ name ]; + + if ( value === false ) continue; + + chunks.push( '#define ' + name + ' ' + value ); + + } + + return chunks.join( '\n' ); + +} + +function fetchAttributeLocations( gl, program ) { + + const attributes = {}; + + const n = gl.getProgramParameter( program, 35721 ); + + for ( let i = 0; i < n; i ++ ) { + + const info = gl.getActiveAttrib( program, i ); + const name = info.name; + + let locationSize = 1; + if ( info.type === 35674 ) locationSize = 2; + if ( info.type === 35675 ) locationSize = 3; + if ( info.type === 35676 ) locationSize = 4; + + // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i ); + + attributes[ name ] = { + type: info.type, + location: gl.getAttribLocation( program, name ), + locationSize: locationSize + }; + + } + + return attributes; + +} + +function filterEmptyLine( string ) { + + return string !== ''; + +} + +function replaceLightNums( string, parameters ) { + + return string + .replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights ) + .replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights ) + .replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights ) + .replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights ) + .replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights ) + .replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows ) + .replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows ) + .replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows ); + +} + +function replaceClippingPlaneNums( string, parameters ) { + + return string + .replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes ) + .replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) ); + +} + +// Resolve Includes + +const includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm; + +function resolveIncludes( string ) { + + return string.replace( includePattern, includeReplacer ); + +} + +function includeReplacer( match, include ) { + + const string = ShaderChunk[ include ]; + + if ( string === undefined ) { + + throw new Error( 'Can not resolve #include <' + include + '>' ); + + } + + return resolveIncludes( string ); + +} + +// Unroll Loops + +const deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; +const unrollLoopPattern = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; + +function unrollLoops( string ) { + + return string + .replace( unrollLoopPattern, loopReplacer ) + .replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer ); + +} + +function deprecatedLoopReplacer( match, start, end, snippet ) { + + console.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' ); + return loopReplacer( match, start, end, snippet ); + +} + +function loopReplacer( match, start, end, snippet ) { + + let string = ''; + + for ( let i = parseInt( start ); i < parseInt( end ); i ++ ) { + + string += snippet + .replace( /\[\s*i\s*\]/g, '[ ' + i + ' ]' ) + .replace( /UNROLLED_LOOP_INDEX/g, i ); + + } + + return string; + +} + +// + +function generatePrecision( parameters ) { + + let precisionstring = 'precision ' + parameters.precision + ' float;\nprecision ' + parameters.precision + ' int;'; + + if ( parameters.precision === 'highp' ) { + + precisionstring += '\n#define HIGH_PRECISION'; + + } else if ( parameters.precision === 'mediump' ) { + + precisionstring += '\n#define MEDIUM_PRECISION'; + + } else if ( parameters.precision === 'lowp' ) { + + precisionstring += '\n#define LOW_PRECISION'; + + } + + return precisionstring; + +} + +function generateShadowMapTypeDefine( parameters ) { + + let shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC'; + + if ( parameters.shadowMapType === PCFShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF'; + + } else if ( parameters.shadowMapType === PCFSoftShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT'; + + } else if ( parameters.shadowMapType === VSMShadowMap ) { + + shadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM'; + + } + + return shadowMapTypeDefine; + +} + +function generateEnvMapTypeDefine( parameters ) { + + let envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + + if ( parameters.envMap ) { + + switch ( parameters.envMapMode ) { + + case CubeReflectionMapping: + case CubeRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + break; + + case CubeUVReflectionMapping: + case CubeUVRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV'; + break; + + } + + } + + return envMapTypeDefine; + +} + +function generateEnvMapModeDefine( parameters ) { + + let envMapModeDefine = 'ENVMAP_MODE_REFLECTION'; + + if ( parameters.envMap ) { + + switch ( parameters.envMapMode ) { + + case CubeRefractionMapping: + case CubeUVRefractionMapping: + + envMapModeDefine = 'ENVMAP_MODE_REFRACTION'; + break; + + } + + } + + return envMapModeDefine; + +} + +function generateEnvMapBlendingDefine( parameters ) { + + let envMapBlendingDefine = 'ENVMAP_BLENDING_NONE'; + + if ( parameters.envMap ) { + + switch ( parameters.combine ) { + + case MultiplyOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY'; + break; + + case MixOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MIX'; + break; + + case AddOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_ADD'; + break; + + } + + } + + return envMapBlendingDefine; + +} + +function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) { + + // TODO Send this event to Three.js DevTools + // console.log( 'WebGLProgram', cacheKey ); + + const gl = renderer.getContext(); + + const defines = parameters.defines; + + let vertexShader = parameters.vertexShader; + let fragmentShader = parameters.fragmentShader; + + const shadowMapTypeDefine = generateShadowMapTypeDefine( parameters ); + const envMapTypeDefine = generateEnvMapTypeDefine( parameters ); + const envMapModeDefine = generateEnvMapModeDefine( parameters ); + const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters ); + + const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters ); + + const customDefines = generateDefines( defines ); + + const program = gl.createProgram(); + + let prefixVertex, prefixFragment; + let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : ''; + + if ( parameters.isRawShaderMaterial ) { + + prefixVertex = [ + + customDefines + + ].filter( filterEmptyLine ).join( '\n' ); + + if ( prefixVertex.length > 0 ) { + + prefixVertex += '\n'; + + } + + prefixFragment = [ + + customExtensions, + customDefines + + ].filter( filterEmptyLine ).join( '\n' ); + + if ( prefixFragment.length > 0 ) { + + prefixFragment += '\n'; + + } + + } else { + + prefixVertex = [ + + generatePrecision( parameters ), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + parameters.instancing ? '#define USE_INSTANCING' : '', + parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', + + parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', + + '#define MAX_BONES ' + parameters.maxBones, + ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', + ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.skinning ? '#define USE_SKINNING' : '', + parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', + + parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', + parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', + ( parameters.morphTargets && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE' : '', + ( parameters.morphTargets && parameters.isWebGL2 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + + 'uniform mat4 modelMatrix;', + 'uniform mat4 modelViewMatrix;', + 'uniform mat4 projectionMatrix;', + 'uniform mat4 viewMatrix;', + 'uniform mat3 normalMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + '#ifdef USE_INSTANCING', + + ' attribute mat4 instanceMatrix;', + + '#endif', + + '#ifdef USE_INSTANCING_COLOR', + + ' attribute vec3 instanceColor;', + + '#endif', + + 'attribute vec3 position;', + 'attribute vec3 normal;', + 'attribute vec2 uv;', + + '#ifdef USE_TANGENT', + + ' attribute vec4 tangent;', + + '#endif', + + '#if defined( USE_COLOR_ALPHA )', + + ' attribute vec4 color;', + + '#elif defined( USE_COLOR )', + + ' attribute vec3 color;', + + '#endif', + + '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', + + ' attribute vec3 morphTarget0;', + ' attribute vec3 morphTarget1;', + ' attribute vec3 morphTarget2;', + ' attribute vec3 morphTarget3;', + + ' #ifdef USE_MORPHNORMALS', + + ' attribute vec3 morphNormal0;', + ' attribute vec3 morphNormal1;', + ' attribute vec3 morphNormal2;', + ' attribute vec3 morphNormal3;', + + ' #else', + + ' attribute vec3 morphTarget4;', + ' attribute vec3 morphTarget5;', + ' attribute vec3 morphTarget6;', + ' attribute vec3 morphTarget7;', + + ' #endif', + + '#endif', + + '#ifdef USE_SKINNING', + + ' attribute vec4 skinIndex;', + ' attribute vec4 skinWeight;', + + '#endif', + + '\n' + + ].filter( filterEmptyLine ).join( '\n' ); + + prefixFragment = [ + + customExtensions, + + generatePrecision( parameters ), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.matcap ? '#define USE_MATCAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapTypeDefine : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.envMap ? '#define ' + envMapBlendingDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', + ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoat ? '#define USE_CLEARCOAT' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + parameters.alphaTest ? '#define USE_ALPHATEST' : '', + + parameters.sheen ? '#define USE_SHEEN' : '', + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', + + parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + + ( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '', + + 'uniform mat4 viewMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + ( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '', + ( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below + ( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '', + + parameters.dithering ? '#define DITHERING' : '', + parameters.alphaWrite ? '' : '#define OPAQUE', + + ShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below + getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ), + + parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', + + '\n' + + ].filter( filterEmptyLine ).join( '\n' ); + + } + + vertexShader = resolveIncludes( vertexShader ); + vertexShader = replaceLightNums( vertexShader, parameters ); + vertexShader = replaceClippingPlaneNums( vertexShader, parameters ); + + fragmentShader = resolveIncludes( fragmentShader ); + fragmentShader = replaceLightNums( fragmentShader, parameters ); + fragmentShader = replaceClippingPlaneNums( fragmentShader, parameters ); + + vertexShader = unrollLoops( vertexShader ); + fragmentShader = unrollLoops( fragmentShader ); + + if ( parameters.isWebGL2 && parameters.isRawShaderMaterial !== true ) { + + // GLSL 3.0 conversion for built-in materials and ShaderMaterial + + versionString = '#version 300 es\n'; + + prefixVertex = [ + 'precision mediump sampler2DArray;', + '#define attribute in', + '#define varying out', + '#define texture2D texture' + ].join( '\n' ) + '\n' + prefixVertex; + + prefixFragment = [ + '#define varying in', + ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', + ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor', + '#define gl_FragDepthEXT gl_FragDepth', + '#define texture2D texture', + '#define textureCube texture', + '#define texture2DProj textureProj', + '#define texture2DLodEXT textureLod', + '#define texture2DProjLodEXT textureProjLod', + '#define textureCubeLodEXT textureLod', + '#define texture2DGradEXT textureGrad', + '#define texture2DProjGradEXT textureProjGrad', + '#define textureCubeGradEXT textureGrad' + ].join( '\n' ) + '\n' + prefixFragment; + + } + + const vertexGlsl = versionString + prefixVertex + vertexShader; + const fragmentGlsl = versionString + prefixFragment + fragmentShader; + + // console.log( '*VERTEX*', vertexGlsl ); + // console.log( '*FRAGMENT*', fragmentGlsl ); + + const glVertexShader = WebGLShader( gl, 35633, vertexGlsl ); + const glFragmentShader = WebGLShader( gl, 35632, fragmentGlsl ); + + gl.attachShader( program, glVertexShader ); + gl.attachShader( program, glFragmentShader ); + + // Force a particular attribute to index 0. + + if ( parameters.index0AttributeName !== undefined ) { + + gl.bindAttribLocation( program, 0, parameters.index0AttributeName ); + + } else if ( parameters.morphTargets === true ) { + + // programs with morphTargets displace position out of attribute 0 + gl.bindAttribLocation( program, 0, 'position' ); + + } + + gl.linkProgram( program ); + + // check for link errors + if ( renderer.debug.checkShaderErrors ) { + + const programLog = gl.getProgramInfoLog( program ).trim(); + const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim(); + const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim(); + + let runnable = true; + let haveDiagnostics = true; + + if ( gl.getProgramParameter( program, 35714 ) === false ) { + + runnable = false; + + const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' ); + const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' ); + + console.error( + 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' + + 'VALIDATE_STATUS ' + gl.getProgramParameter( program, 35715 ) + '\n\n' + + 'Program Info Log: ' + programLog + '\n' + + vertexErrors + '\n' + + fragmentErrors + ); + + } else if ( programLog !== '' ) { + + console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog ); + + } else if ( vertexLog === '' || fragmentLog === '' ) { + + haveDiagnostics = false; + + } + + if ( haveDiagnostics ) { + + this.diagnostics = { + + runnable: runnable, + + programLog: programLog, + + vertexShader: { + + log: vertexLog, + prefix: prefixVertex + + }, + + fragmentShader: { + + log: fragmentLog, + prefix: prefixFragment + + } + + }; + + } + + } + + // Clean up + + // Crashes in iOS9 and iOS10. #18402 + // gl.detachShader( program, glVertexShader ); + // gl.detachShader( program, glFragmentShader ); + + gl.deleteShader( glVertexShader ); + gl.deleteShader( glFragmentShader ); + + // set up caching for uniform locations + + let cachedUniforms; + + this.getUniforms = function () { + + if ( cachedUniforms === undefined ) { + + cachedUniforms = new WebGLUniforms( gl, program ); + + } + + return cachedUniforms; + + }; + + // set up caching for attribute locations + + let cachedAttributes; + + this.getAttributes = function () { + + if ( cachedAttributes === undefined ) { + + cachedAttributes = fetchAttributeLocations( gl, program ); + + } + + return cachedAttributes; + + }; + + // free resource + + this.destroy = function () { + + bindingStates.releaseStatesOfProgram( this ); + + gl.deleteProgram( program ); + this.program = undefined; + + }; + + // + + this.name = parameters.shaderName; + this.id = programIdCount ++; + this.cacheKey = cacheKey; + this.usedTimes = 1; + this.program = program; + this.vertexShader = glVertexShader; + this.fragmentShader = glFragmentShader; + + return this; + +} + +let _id = 0; + +class WebGLShaderCache { + + constructor() { + + this.shaderCache = new Map(); + this.materialCache = new Map(); + + } + + update( material ) { + + const vertexShader = material.vertexShader; + const fragmentShader = material.fragmentShader; + + const vertexShaderStage = this._getShaderStage( vertexShader ); + const fragmentShaderStage = this._getShaderStage( fragmentShader ); + + const materialShaders = this._getShaderCacheForMaterial( material ); + + if ( materialShaders.has( vertexShaderStage ) === false ) { + + materialShaders.add( vertexShaderStage ); + vertexShaderStage.usedTimes ++; + + } + + if ( materialShaders.has( fragmentShaderStage ) === false ) { + + materialShaders.add( fragmentShaderStage ); + fragmentShaderStage.usedTimes ++; + + } + + return this; + + } + + remove( material ) { + + const materialShaders = this.materialCache.get( material ); + + for ( const shaderStage of materialShaders ) { + + shaderStage.usedTimes --; + + if ( shaderStage.usedTimes === 0 ) this.shaderCache.delete( shaderStage ); + + } + + this.materialCache.delete( material ); + + return this; + + } + + getVertexShaderID( material ) { + + return this._getShaderStage( material.vertexShader ).id; + + } + + getFragmentShaderID( material ) { + + return this._getShaderStage( material.fragmentShader ).id; + + } + + dispose() { + + this.shaderCache.clear(); + this.materialCache.clear(); + + } + + _getShaderCacheForMaterial( material ) { + + const cache = this.materialCache; + + if ( cache.has( material ) === false ) { + + cache.set( material, new Set() ); + + } + + return cache.get( material ); + + } + + _getShaderStage( code ) { + + const cache = this.shaderCache; + + if ( cache.has( code ) === false ) { + + const stage = new WebGLShaderStage(); + cache.set( code, stage ); + + } + + return cache.get( code ); + + } + +} + +class WebGLShaderStage { + + constructor() { + + this.id = _id ++; + + this.usedTimes = 0; + + } + +} + +function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ) { + + const _programLayers = new Layers(); + const _customShaders = new WebGLShaderCache(); + const programs = []; + + const isWebGL2 = capabilities.isWebGL2; + const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer; + const floatVertexTextures = capabilities.floatVertexTextures; + const maxVertexUniforms = capabilities.maxVertexUniforms; + const vertexTextures = capabilities.vertexTextures; + let precision = capabilities.precision; + + const shaderIDs = { + MeshDepthMaterial: 'depth', + MeshDistanceMaterial: 'distanceRGBA', + MeshNormalMaterial: 'normal', + MeshBasicMaterial: 'basic', + MeshLambertMaterial: 'lambert', + MeshPhongMaterial: 'phong', + MeshToonMaterial: 'toon', + MeshStandardMaterial: 'physical', + MeshPhysicalMaterial: 'physical', + MeshMatcapMaterial: 'matcap', + LineBasicMaterial: 'basic', + LineDashedMaterial: 'dashed', + PointsMaterial: 'points', + ShadowMaterial: 'shadow', + SpriteMaterial: 'sprite' + }; + + function getMaxBones( object ) { + + const skeleton = object.skeleton; + const bones = skeleton.bones; + + if ( floatVertexTextures ) { + + return 1024; + + } else { + + // default for when object is not specified + // ( for example when prebuilding shader to be used with multiple objects ) + // + // - leave some extra space for other uniforms + // - limit here is ANGLE's 254 max uniform vectors + // (up to 54 should be safe) + + const nVertexUniforms = maxVertexUniforms; + const nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 ); + + const maxBones = Math.min( nVertexMatrices, bones.length ); + + if ( maxBones < bones.length ) { + + console.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' ); + return 0; + + } + + return maxBones; + + } + + } + + function getParameters( material, lights, shadows, scene, object ) { + + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + + const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment ); + + const shaderID = shaderIDs[ material.type ]; + + // heuristics to create shader parameters according to lights in the scene + // (not to blow over maxLights budget) + + const maxBones = object.isSkinnedMesh ? getMaxBones( object ) : 0; + + if ( material.precision !== null ) { + + precision = capabilities.getMaxPrecision( material.precision ); + + if ( precision !== material.precision ) { + + console.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' ); + + } + + } + + let vertexShader, fragmentShader; + let customVertexShaderID, customFragmentShaderID; + + if ( shaderID ) { + + const shader = ShaderLib[ shaderID ]; + + vertexShader = shader.vertexShader; + fragmentShader = shader.fragmentShader; + + } else { + + vertexShader = material.vertexShader; + fragmentShader = material.fragmentShader; + + _customShaders.update( material ); + + customVertexShaderID = _customShaders.getVertexShaderID( material ); + customFragmentShaderID = _customShaders.getFragmentShaderID( material ); + + } + + const currentRenderTarget = renderer.getRenderTarget(); + + const useAlphaTest = material.alphaTest > 0; + const useClearcoat = material.clearcoat > 0; + + const parameters = { + + isWebGL2: isWebGL2, + + shaderID: shaderID, + shaderName: material.type, + + vertexShader: vertexShader, + fragmentShader: fragmentShader, + defines: material.defines, + + customVertexShaderID: customVertexShaderID, + customFragmentShaderID: customFragmentShaderID, + + isRawShaderMaterial: material.isRawShaderMaterial === true, + glslVersion: material.glslVersion, + + precision: precision, + + instancing: object.isInstancedMesh === true, + instancingColor: object.isInstancedMesh === true && object.instanceColor !== null, + + supportsVertexTextures: vertexTextures, + outputEncoding: ( currentRenderTarget !== null ) ? currentRenderTarget.texture.encoding : renderer.outputEncoding, + map: !! material.map, + matcap: !! material.matcap, + envMap: !! envMap, + envMapMode: envMap && envMap.mapping, + envMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ), + lightMap: !! material.lightMap, + aoMap: !! material.aoMap, + emissiveMap: !! material.emissiveMap, + bumpMap: !! material.bumpMap, + normalMap: !! material.normalMap, + objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap, + tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap, + + decodeVideoTexture: !! material.map && ( material.map.isVideoTexture === true ) && ( material.map.encoding === sRGBEncoding ), + + clearcoat: useClearcoat, + clearcoatMap: useClearcoat && !! material.clearcoatMap, + clearcoatRoughnessMap: useClearcoat && !! material.clearcoatRoughnessMap, + clearcoatNormalMap: useClearcoat && !! material.clearcoatNormalMap, + + displacementMap: !! material.displacementMap, + roughnessMap: !! material.roughnessMap, + metalnessMap: !! material.metalnessMap, + specularMap: !! material.specularMap, + specularIntensityMap: !! material.specularIntensityMap, + specularColorMap: !! material.specularColorMap, + + alphaMap: !! material.alphaMap, + alphaTest: useAlphaTest, + alphaWrite: material.alphaWrite || material.transparent, + + gradientMap: !! material.gradientMap, + + sheen: material.sheen > 0, + sheenColorMap: !! material.sheenColorMap, + sheenRoughnessMap: !! material.sheenRoughnessMap, + + transmission: material.transmission > 0, + transmissionMap: !! material.transmissionMap, + thicknessMap: !! material.thicknessMap, + + combine: material.combine, + + vertexTangents: ( !! material.normalMap && !! object.geometry && !! object.geometry.attributes.tangent ), + vertexColors: material.vertexColors, + vertexAlphas: material.vertexColors === true && !! object.geometry && !! object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheenColorMap || !! material.sheenRoughnessMap, + uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || material.sheen > 0 || !! material.sheenColorMap || !! material.sheenRoughnessMap ) && !! material.displacementMap, + + fog: !! fog, + useFog: material.fog, + fogExp2: ( fog && fog.isFogExp2 ), + + flatShading: !! material.flatShading, + + sizeAttenuation: material.sizeAttenuation, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + skinning: object.isSkinnedMesh === true && maxBones > 0, + maxBones: maxBones, + useVertexTexture: floatVertexTextures, + + morphTargets: !! object.geometry && !! object.geometry.morphAttributes.position, + morphNormals: !! object.geometry && !! object.geometry.morphAttributes.normal, + morphTargetsCount: ( !! object.geometry && !! object.geometry.morphAttributes.position ) ? object.geometry.morphAttributes.position.length : 0, + + numDirLights: lights.directional.length, + numPointLights: lights.point.length, + numSpotLights: lights.spot.length, + numRectAreaLights: lights.rectArea.length, + numHemiLights: lights.hemi.length, + + numDirLightShadows: lights.directionalShadowMap.length, + numPointLightShadows: lights.pointShadowMap.length, + numSpotLightShadows: lights.spotShadowMap.length, + + numClippingPlanes: clipping.numPlanes, + numClipIntersection: clipping.numIntersection, + + dithering: material.dithering, + + shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0, + shadowMapType: renderer.shadowMap.type, + + toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping, + physicallyCorrectLights: renderer.physicallyCorrectLights, + + premultipliedAlpha: material.premultipliedAlpha, + + doubleSided: material.side === DoubleSide, + flipSided: material.side === BackSide, + + depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false, + + index0AttributeName: material.index0AttributeName, + + extensionDerivatives: material.extensions && material.extensions.derivatives, + extensionFragDepth: material.extensions && material.extensions.fragDepth, + extensionDrawBuffers: material.extensions && material.extensions.drawBuffers, + extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD, + + rendererExtensionFragDepth: isWebGL2 || extensions.has( 'EXT_frag_depth' ), + rendererExtensionDrawBuffers: isWebGL2 || extensions.has( 'WEBGL_draw_buffers' ), + rendererExtensionShaderTextureLod: isWebGL2 || extensions.has( 'EXT_shader_texture_lod' ), + + customProgramCacheKey: material.customProgramCacheKey() + + }; + + return parameters; + + } + + function getProgramCacheKey( parameters ) { + + const array = []; + + if ( parameters.shaderID ) { + + array.push( parameters.shaderID ); + + } else { + + array.push( parameters.customVertexShaderID ); + array.push( parameters.customFragmentShaderID ); + + } + + if ( parameters.defines !== undefined ) { + + for ( const name in parameters.defines ) { + + array.push( name ); + array.push( parameters.defines[ name ] ); + + } + + } + + if ( parameters.isRawShaderMaterial === false ) { + + getProgramCacheKeyParameters( array, parameters ); + getProgramCacheKeyBooleans( array, parameters ); + array.push( renderer.outputEncoding ); + + } + + array.push( parameters.customProgramCacheKey ); + + return array.join(); + + } + + function getProgramCacheKeyParameters( array, parameters ) { + + array.push( parameters.precision ); + array.push( parameters.outputEncoding ); + array.push( parameters.envMapMode ); + array.push( parameters.combine ); + array.push( parameters.vertexUvs ); + array.push( parameters.fogExp2 ); + array.push( parameters.sizeAttenuation ); + array.push( parameters.maxBones ); + array.push( parameters.morphTargetsCount ); + array.push( parameters.numDirLights ); + array.push( parameters.numPointLights ); + array.push( parameters.numSpotLights ); + array.push( parameters.numHemiLights ); + array.push( parameters.numRectAreaLights ); + array.push( parameters.numDirLightShadows ); + array.push( parameters.numPointLightShadows ); + array.push( parameters.numSpotLightShadows ); + array.push( parameters.shadowMapType ); + array.push( parameters.toneMapping ); + array.push( parameters.numClippingPlanes ); + array.push( parameters.numClipIntersection ); + array.push( parameters.alphaWrite ); + + } + + function getProgramCacheKeyBooleans( array, parameters ) { + + _programLayers.disableAll(); + + if ( parameters.isWebGL2 ) + _programLayers.enable( 0 ); + if ( parameters.supportsVertexTextures ) + _programLayers.enable( 1 ); + if ( parameters.instancing ) + _programLayers.enable( 2 ); + if ( parameters.instancingColor ) + _programLayers.enable( 3 ); + if ( parameters.map ) + _programLayers.enable( 4 ); + if ( parameters.matcap ) + _programLayers.enable( 5 ); + if ( parameters.envMap ) + _programLayers.enable( 6 ); + if ( parameters.envMapCubeUV ) + _programLayers.enable( 7 ); + if ( parameters.lightMap ) + _programLayers.enable( 8 ); + if ( parameters.aoMap ) + _programLayers.enable( 9 ); + if ( parameters.emissiveMap ) + _programLayers.enable( 10 ); + if ( parameters.bumpMap ) + _programLayers.enable( 11 ); + if ( parameters.normalMap ) + _programLayers.enable( 12 ); + if ( parameters.objectSpaceNormalMap ) + _programLayers.enable( 13 ); + if ( parameters.tangentSpaceNormalMap ) + _programLayers.enable( 14 ); + if ( parameters.clearcoat ) + _programLayers.enable( 15 ); + if ( parameters.clearcoatMap ) + _programLayers.enable( 16 ); + if ( parameters.clearcoatRoughnessMap ) + _programLayers.enable( 17 ); + if ( parameters.clearcoatNormalMap ) + _programLayers.enable( 18 ); + if ( parameters.displacementMap ) + _programLayers.enable( 19 ); + if ( parameters.specularMap ) + _programLayers.enable( 20 ); + if ( parameters.roughnessMap ) + _programLayers.enable( 21 ); + if ( parameters.metalnessMap ) + _programLayers.enable( 22 ); + if ( parameters.gradientMap ) + _programLayers.enable( 23 ); + if ( parameters.alphaMap ) + _programLayers.enable( 24 ); + if ( parameters.alphaTest ) + _programLayers.enable( 25 ); + if ( parameters.vertexColors ) + _programLayers.enable( 26 ); + if ( parameters.vertexAlphas ) + _programLayers.enable( 27 ); + if ( parameters.vertexUvs ) + _programLayers.enable( 28 ); + if ( parameters.vertexTangents ) + _programLayers.enable( 29 ); + if ( parameters.uvsVertexOnly ) + _programLayers.enable( 30 ); + if ( parameters.fog ) + _programLayers.enable( 31 ); + + array.push( _programLayers.mask ); + _programLayers.disableAll(); + + if ( parameters.useFog ) + _programLayers.enable( 0 ); + if ( parameters.flatShading ) + _programLayers.enable( 1 ); + if ( parameters.logarithmicDepthBuffer ) + _programLayers.enable( 2 ); + if ( parameters.skinning ) + _programLayers.enable( 3 ); + if ( parameters.useVertexTexture ) + _programLayers.enable( 4 ); + if ( parameters.morphTargets ) + _programLayers.enable( 5 ); + if ( parameters.morphNormals ) + _programLayers.enable( 6 ); + if ( parameters.premultipliedAlpha ) + _programLayers.enable( 7 ); + if ( parameters.shadowMapEnabled ) + _programLayers.enable( 8 ); + if ( parameters.physicallyCorrectLights ) + _programLayers.enable( 9 ); + if ( parameters.doubleSided ) + _programLayers.enable( 10 ); + if ( parameters.flipSided ) + _programLayers.enable( 11 ); + if ( parameters.depthPacking ) + _programLayers.enable( 12 ); + if ( parameters.dithering ) + _programLayers.enable( 13 ); + if ( parameters.specularIntensityMap ) + _programLayers.enable( 14 ); + if ( parameters.specularColorMap ) + _programLayers.enable( 15 ); + if ( parameters.transmission ) + _programLayers.enable( 16 ); + if ( parameters.transmissionMap ) + _programLayers.enable( 17 ); + if ( parameters.thicknessMap ) + _programLayers.enable( 18 ); + if ( parameters.sheen ) + _programLayers.enable( 19 ); + if ( parameters.sheenColorMap ) + _programLayers.enable( 20 ); + if ( parameters.sheenRoughnessMap ) + _programLayers.enable( 21 ); + if ( parameters.decodeVideoTexture ) + _programLayers.enable( 22 ); + + array.push( _programLayers.mask ); + + } + + function getUniforms( material ) { + + const shaderID = shaderIDs[ material.type ]; + let uniforms; + + if ( shaderID ) { + + const shader = ShaderLib[ shaderID ]; + uniforms = UniformsUtils.clone( shader.uniforms ); + + } else { + + uniforms = material.uniforms; + + } + + return uniforms; + + } + + function acquireProgram( parameters, cacheKey ) { + + let program; + + // Check if code has been already compiled + for ( let p = 0, pl = programs.length; p < pl; p ++ ) { + + const preexistingProgram = programs[ p ]; + + if ( preexistingProgram.cacheKey === cacheKey ) { + + program = preexistingProgram; + ++ program.usedTimes; + + break; + + } + + } + + if ( program === undefined ) { + + program = new WebGLProgram( renderer, cacheKey, parameters, bindingStates ); + programs.push( program ); + + } + + return program; + + } + + function releaseProgram( program ) { + + if ( -- program.usedTimes === 0 ) { + + // Remove from unordered set + const i = programs.indexOf( program ); + programs[ i ] = programs[ programs.length - 1 ]; + programs.pop(); + + // Free WebGL resources + program.destroy(); + + } + + } + + function releaseShaderCache( material ) { + + _customShaders.remove( material ); + + } + + function dispose() { + + _customShaders.dispose(); + + } + + return { + getParameters: getParameters, + getProgramCacheKey: getProgramCacheKey, + getUniforms: getUniforms, + acquireProgram: acquireProgram, + releaseProgram: releaseProgram, + releaseShaderCache: releaseShaderCache, + // Exposed for resource monitoring & error feedback via renderer.info: + programs: programs, + dispose: dispose + }; + +} + +function WebGLProperties() { + + let properties = new WeakMap(); + + function get( object ) { + + let map = properties.get( object ); + + if ( map === undefined ) { + + map = {}; + properties.set( object, map ); + + } + + return map; + + } + + function remove( object ) { + + properties.delete( object ); + + } + + function update( object, key, value ) { + + properties.get( object )[ key ] = value; + + } + + function dispose() { + + properties = new WeakMap(); + + } + + return { + get: get, + remove: remove, + update: update, + dispose: dispose + }; + +} + +function painterSortStable( a, b ) { + + if ( a.groupOrder !== b.groupOrder ) { + + return a.groupOrder - b.groupOrder; + + } else if ( a.renderOrder !== b.renderOrder ) { + + return a.renderOrder - b.renderOrder; + + } else if ( a.material.id !== b.material.id ) { + + return a.material.id - b.material.id; + + } else if ( a.z !== b.z ) { + + return a.z - b.z; + + } else { + + return a.id - b.id; + + } + +} + +function reversePainterSortStable( a, b ) { + + if ( a.groupOrder !== b.groupOrder ) { + + return a.groupOrder - b.groupOrder; + + } else if ( a.renderOrder !== b.renderOrder ) { + + return a.renderOrder - b.renderOrder; + + } else if ( a.z !== b.z ) { + + return b.z - a.z; + + } else { + + return a.id - b.id; + + } + +} + + +function WebGLRenderList() { + + const renderItems = []; + let renderItemsIndex = 0; + + const opaque = []; + const transmissive = []; + const transparent = []; + + function init() { + + renderItemsIndex = 0; + + opaque.length = 0; + transmissive.length = 0; + transparent.length = 0; + + } + + function getNextRenderItem( object, geometry, material, groupOrder, z, group ) { + + let renderItem = renderItems[ renderItemsIndex ]; + + if ( renderItem === undefined ) { + + renderItem = { + id: object.id, + object: object, + geometry: geometry, + material: material, + groupOrder: groupOrder, + renderOrder: object.renderOrder, + z: z, + group: group + }; + + renderItems[ renderItemsIndex ] = renderItem; + + } else { + + renderItem.id = object.id; + renderItem.object = object; + renderItem.geometry = geometry; + renderItem.material = material; + renderItem.groupOrder = groupOrder; + renderItem.renderOrder = object.renderOrder; + renderItem.z = z; + renderItem.group = group; + + } + + renderItemsIndex ++; + + return renderItem; + + } + + function push( object, geometry, material, groupOrder, z, group ) { + + const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group ); + + if ( material.transmission > 0.0 ) { + + transmissive.push( renderItem ); + + } else if ( material.transparent === true ) { + + transparent.push( renderItem ); + + } else { + + opaque.push( renderItem ); + + } + + } + + function unshift( object, geometry, material, groupOrder, z, group ) { + + const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group ); + + if ( material.transmission > 0.0 ) { + + transmissive.unshift( renderItem ); + + } else if ( material.transparent === true ) { + + transparent.unshift( renderItem ); + + } else { + + opaque.unshift( renderItem ); + + } + + } + + function sort( customOpaqueSort, customTransparentSort ) { + + if ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable ); + if ( transmissive.length > 1 ) transmissive.sort( customTransparentSort || reversePainterSortStable ); + if ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable ); + + } + + function finish() { + + // Clear references from inactive renderItems in the list + + for ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) { + + const renderItem = renderItems[ i ]; + + if ( renderItem.id === null ) break; + + renderItem.id = null; + renderItem.object = null; + renderItem.geometry = null; + renderItem.material = null; + renderItem.group = null; + + } + + } + + return { + + opaque: opaque, + transmissive: transmissive, + transparent: transparent, + + init: init, + push: push, + unshift: unshift, + finish: finish, + + sort: sort + }; + +} + +function WebGLRenderLists() { + + let lists = new WeakMap(); + + function get( scene, renderCallDepth ) { + + let list; + + if ( lists.has( scene ) === false ) { + + list = new WebGLRenderList(); + lists.set( scene, [ list ] ); + + } else { + + if ( renderCallDepth >= lists.get( scene ).length ) { + + list = new WebGLRenderList(); + lists.get( scene ).push( list ); + + } else { + + list = lists.get( scene )[ renderCallDepth ]; + + } + + } + + return list; + + } + + function dispose() { + + lists = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +function UniformsCache() { + + const lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + let uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + direction: new Vector3(), + color: new Color() + }; + break; + + case 'SpotLight': + uniforms = { + position: new Vector3(), + direction: new Vector3(), + color: new Color(), + distance: 0, + coneCos: 0, + penumbraCos: 0, + decay: 0 + }; + break; + + case 'PointLight': + uniforms = { + position: new Vector3(), + color: new Color(), + distance: 0, + decay: 0 + }; + break; + + case 'HemisphereLight': + uniforms = { + direction: new Vector3(), + skyColor: new Color(), + groundColor: new Color() + }; + break; + + case 'RectAreaLight': + uniforms = { + color: new Color(), + position: new Vector3(), + halfWidth: new Vector3(), + halfHeight: new Vector3() + }; + break; + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + +} + +function ShadowUniformsCache() { + + const lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + let uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'SpotLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'PointLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + shadowCameraNear: 1, + shadowCameraFar: 1000 + }; + break; + + // TODO (abelnation): set RectAreaLight shadow uniforms + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + +} + + + +let nextVersion = 0; + +function shadowCastingLightsFirst( lightA, lightB ) { + + return ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 ); + +} + +function WebGLLights( extensions, capabilities ) { + + const cache = new UniformsCache(); + + const shadowCache = ShadowUniformsCache(); + + const state = { + + version: 0, + + hash: { + directionalLength: - 1, + pointLength: - 1, + spotLength: - 1, + rectAreaLength: - 1, + hemiLength: - 1, + + numDirectionalShadows: - 1, + numPointShadows: - 1, + numSpotShadows: - 1 + }, + + ambient: [ 0, 0, 0 ], + probe: [], + directional: [], + directionalShadow: [], + directionalShadowMap: [], + directionalShadowMatrix: [], + spot: [], + spotShadow: [], + spotShadowMap: [], + spotShadowMatrix: [], + rectArea: [], + rectAreaLTC1: null, + rectAreaLTC2: null, + point: [], + pointShadow: [], + pointShadowMap: [], + pointShadowMatrix: [], + hemi: [] + + }; + + for ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() ); + + const vector3 = new Vector3(); + const matrix4 = new Matrix4(); + const matrix42 = new Matrix4(); + + function setup( lights, physicallyCorrectLights ) { + + let r = 0, g = 0, b = 0; + + for ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 ); + + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + let numDirectionalShadows = 0; + let numPointShadows = 0; + let numSpotShadows = 0; + + lights.sort( shadowCastingLightsFirst ); + + // artist-friendly light intensity scaling factor + const scaleFactor = ( physicallyCorrectLights !== true ) ? Math.PI : 1; + + for ( let i = 0, l = lights.length; i < l; i ++ ) { + + const light = lights[ i ]; + + const color = light.color; + const intensity = light.intensity; + const distance = light.distance; + + const shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null; + + if ( light.isAmbientLight ) { + + r += color.r * intensity * scaleFactor; + g += color.g * intensity * scaleFactor; + b += color.b * intensity * scaleFactor; + + } else if ( light.isLightProbe ) { + + for ( let j = 0; j < 9; j ++ ) { + + state.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity ); + + } + + } else if ( light.isDirectionalLight ) { + + const uniforms = cache.get( light ); + + uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor ); + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.directionalShadow[ directionalLength ] = shadowUniforms; + state.directionalShadowMap[ directionalLength ] = shadowMap; + state.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix; + + numDirectionalShadows ++; + + } + + state.directional[ directionalLength ] = uniforms; + + directionalLength ++; + + } else if ( light.isSpotLight ) { + + const uniforms = cache.get( light ); + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + + uniforms.color.copy( color ).multiplyScalar( intensity * scaleFactor ); + uniforms.distance = distance; + + uniforms.coneCos = Math.cos( light.angle ); + uniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) ); + uniforms.decay = light.decay; + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.spotShadow[ spotLength ] = shadowUniforms; + state.spotShadowMap[ spotLength ] = shadowMap; + state.spotShadowMatrix[ spotLength ] = light.shadow.matrix; + + numSpotShadows ++; + + } + + state.spot[ spotLength ] = uniforms; + + spotLength ++; + + } else if ( light.isRectAreaLight ) { + + const uniforms = cache.get( light ); + + // (a) intensity is the total visible light emitted + //uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) ); + + // (b) intensity is the brightness of the light + uniforms.color.copy( color ).multiplyScalar( intensity ); + + uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 ); + uniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 ); + + state.rectArea[ rectAreaLength ] = uniforms; + + rectAreaLength ++; + + } else if ( light.isPointLight ) { + + const uniforms = cache.get( light ); + + uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor ); + uniforms.distance = light.distance; + uniforms.decay = light.decay; + + if ( light.castShadow ) { + + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + shadowUniforms.shadowCameraNear = shadow.camera.near; + shadowUniforms.shadowCameraFar = shadow.camera.far; + + state.pointShadow[ pointLength ] = shadowUniforms; + state.pointShadowMap[ pointLength ] = shadowMap; + state.pointShadowMatrix[ pointLength ] = light.shadow.matrix; + + numPointShadows ++; + + } + + state.point[ pointLength ] = uniforms; + + pointLength ++; + + } else if ( light.isHemisphereLight ) { + + const uniforms = cache.get( light ); + + uniforms.skyColor.copy( light.color ).multiplyScalar( intensity * scaleFactor ); + uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity * scaleFactor ); + + state.hemi[ hemiLength ] = uniforms; + + hemiLength ++; + + } + + } + + if ( rectAreaLength > 0 ) { + + if ( capabilities.isWebGL2 ) { + + // WebGL 2 + + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + + } else { + + // WebGL 1 + + if ( extensions.has( 'OES_texture_float_linear' ) === true ) { + + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + + } else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) { + + state.rectAreaLTC1 = UniformsLib.LTC_HALF_1; + state.rectAreaLTC2 = UniformsLib.LTC_HALF_2; + + } else { + + console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' ); + + } + + } + + } + + state.ambient[ 0 ] = r; + state.ambient[ 1 ] = g; + state.ambient[ 2 ] = b; + + const hash = state.hash; + + if ( hash.directionalLength !== directionalLength || + hash.pointLength !== pointLength || + hash.spotLength !== spotLength || + hash.rectAreaLength !== rectAreaLength || + hash.hemiLength !== hemiLength || + hash.numDirectionalShadows !== numDirectionalShadows || + hash.numPointShadows !== numPointShadows || + hash.numSpotShadows !== numSpotShadows ) { + + state.directional.length = directionalLength; + state.spot.length = spotLength; + state.rectArea.length = rectAreaLength; + state.point.length = pointLength; + state.hemi.length = hemiLength; + + state.directionalShadow.length = numDirectionalShadows; + state.directionalShadowMap.length = numDirectionalShadows; + state.pointShadow.length = numPointShadows; + state.pointShadowMap.length = numPointShadows; + state.spotShadow.length = numSpotShadows; + state.spotShadowMap.length = numSpotShadows; + state.directionalShadowMatrix.length = numDirectionalShadows; + state.pointShadowMatrix.length = numPointShadows; + state.spotShadowMatrix.length = numSpotShadows; + + hash.directionalLength = directionalLength; + hash.pointLength = pointLength; + hash.spotLength = spotLength; + hash.rectAreaLength = rectAreaLength; + hash.hemiLength = hemiLength; + + hash.numDirectionalShadows = numDirectionalShadows; + hash.numPointShadows = numPointShadows; + hash.numSpotShadows = numSpotShadows; + + state.version = nextVersion ++; + + } + + } + + function setupView( lights, camera ) { + + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + const viewMatrix = camera.matrixWorldInverse; + + for ( let i = 0, l = lights.length; i < l; i ++ ) { + + const light = lights[ i ]; + + if ( light.isDirectionalLight ) { + + const uniforms = state.directional[ directionalLength ]; + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + vector3.setFromMatrixPosition( light.target.matrixWorld ); + uniforms.direction.sub( vector3 ); + uniforms.direction.transformDirection( viewMatrix ); + + directionalLength ++; + + } else if ( light.isSpotLight ) { + + const uniforms = state.spot[ spotLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + vector3.setFromMatrixPosition( light.target.matrixWorld ); + uniforms.direction.sub( vector3 ); + uniforms.direction.transformDirection( viewMatrix ); + + spotLength ++; + + } else if ( light.isRectAreaLight ) { + + const uniforms = state.rectArea[ rectAreaLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + // extract local rotation of light to derive width/height half vectors + matrix42.identity(); + matrix4.copy( light.matrixWorld ); + matrix4.premultiply( viewMatrix ); + matrix42.extractRotation( matrix4 ); + + uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 ); + uniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 ); + + uniforms.halfWidth.applyMatrix4( matrix42 ); + uniforms.halfHeight.applyMatrix4( matrix42 ); + + rectAreaLength ++; + + } else if ( light.isPointLight ) { + + const uniforms = state.point[ pointLength ]; + + uniforms.position.setFromMatrixPosition( light.matrixWorld ); + uniforms.position.applyMatrix4( viewMatrix ); + + pointLength ++; + + } else if ( light.isHemisphereLight ) { + + const uniforms = state.hemi[ hemiLength ]; + + uniforms.direction.setFromMatrixPosition( light.matrixWorld ); + uniforms.direction.transformDirection( viewMatrix ); + uniforms.direction.normalize(); + + hemiLength ++; + + } + + } + + } + + return { + setup: setup, + setupView: setupView, + state: state + }; + +} + +function WebGLRenderState( extensions, capabilities ) { + + const lights = new WebGLLights( extensions, capabilities ); + + const lightsArray = []; + const shadowsArray = []; + + function init() { + + lightsArray.length = 0; + shadowsArray.length = 0; + + } + + function pushLight( light ) { + + lightsArray.push( light ); + + } + + function pushShadow( shadowLight ) { + + shadowsArray.push( shadowLight ); + + } + + function setupLights( physicallyCorrectLights ) { + + lights.setup( lightsArray, physicallyCorrectLights ); + + } + + function setupLightsView( camera ) { + + lights.setupView( lightsArray, camera ); + + } + + const state = { + lightsArray: lightsArray, + shadowsArray: shadowsArray, + + lights: lights + }; + + return { + init: init, + state: state, + setupLights: setupLights, + setupLightsView: setupLightsView, + + pushLight: pushLight, + pushShadow: pushShadow + }; + +} + +function WebGLRenderStates( extensions, capabilities ) { + + let renderStates = new WeakMap(); + + function get( scene, renderCallDepth = 0 ) { + + let renderState; + + if ( renderStates.has( scene ) === false ) { + + renderState = new WebGLRenderState( extensions, capabilities ); + renderStates.set( scene, [ renderState ] ); + + } else { + + if ( renderCallDepth >= renderStates.get( scene ).length ) { + + renderState = new WebGLRenderState( extensions, capabilities ); + renderStates.get( scene ).push( renderState ); + + } else { + + renderState = renderStates.get( scene )[ renderCallDepth ]; + + } + + } + + return renderState; + + } + + function dispose() { + + renderStates = new WeakMap(); + + } + + return { + get: get, + dispose: dispose + }; + +} + +/** + * parameters = { + * + * opacity: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * wireframe: , + * wireframeLinewidth: + * } + */ + +class MeshDepthMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshDepthMaterial'; + + this.depthPacking = BasicDepthPacking; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.depthPacking = source.depthPacking; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + return this; + + } + +} + +MeshDepthMaterial.prototype.isMeshDepthMaterial = true; + +/** + * parameters = { + * + * referencePosition: , + * nearDistance: , + * farDistance: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: + * + * } + */ + +class MeshDistanceMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshDistanceMaterial'; + + this.referencePosition = new Vector3(); + this.nearDistance = 1; + this.farDistance = 1000; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.fog = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.referencePosition.copy( source.referencePosition ); + this.nearDistance = source.nearDistance; + this.farDistance = source.farDistance; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + return this; + + } + +} + +MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true; + +const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}"; + +const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"; + +function WebGLShadowMap( _renderer, _objects, _capabilities ) { + + let _frustum = new Frustum(); + + const _shadowMapSize = new Vector2(), + _viewportSize = new Vector2(), + + _viewport = new Vector4(), + + _depthMaterial = new MeshDepthMaterial( { depthPacking: RGBADepthPacking } ), + _distanceMaterial = new MeshDistanceMaterial(), + + _materialCache = {}, + + _maxTextureSize = _capabilities.maxTextureSize; + + const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide }; + + const shadowMaterialVertical = new ShaderMaterial( { + defines: { + VSM_SAMPLES: 8 + }, + uniforms: { + shadow_pass: { value: null }, + resolution: { value: new Vector2() }, + radius: { value: 4.0 } + }, + + vertexShader: vertex, + fragmentShader: fragment + + } ); + + const shadowMaterialHorizontal = shadowMaterialVertical.clone(); + shadowMaterialHorizontal.defines.HORIZONTAL_PASS = 1; + + const fullScreenTri = new BufferGeometry(); + fullScreenTri.setAttribute( + 'position', + new BufferAttribute( + new Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ), + 3 + ) + ); + + const fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical ); + + const scope = this; + + this.enabled = false; + + this.autoUpdate = true; + this.needsUpdate = false; + + this.type = PCFShadowMap; + + this.render = function ( lights, scene, camera ) { + + if ( scope.enabled === false ) return; + if ( scope.autoUpdate === false && scope.needsUpdate === false ) return; + + if ( lights.length === 0 ) return; + + const currentRenderTarget = _renderer.getRenderTarget(); + const activeCubeFace = _renderer.getActiveCubeFace(); + const activeMipmapLevel = _renderer.getActiveMipmapLevel(); + + const _state = _renderer.state; + + // Set GL state for depth map. + _state.setBlending( NoBlending ); + _state.buffers.color.setClear( 1, 1, 1, 1 ); + _state.buffers.depth.setTest( true ); + _state.setScissorTest( false ); + + // render depth map + + for ( let i = 0, il = lights.length; i < il; i ++ ) { + + const light = lights[ i ]; + const shadow = light.shadow; + + if ( shadow === undefined ) { + + console.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' ); + continue; + + } + + if ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue; + + _shadowMapSize.copy( shadow.mapSize ); + + const shadowFrameExtents = shadow.getFrameExtents(); + + _shadowMapSize.multiply( shadowFrameExtents ); + + _viewportSize.copy( shadow.mapSize ); + + if ( _shadowMapSize.x > _maxTextureSize || _shadowMapSize.y > _maxTextureSize ) { + + if ( _shadowMapSize.x > _maxTextureSize ) { + + _viewportSize.x = Math.floor( _maxTextureSize / shadowFrameExtents.x ); + _shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x; + shadow.mapSize.x = _viewportSize.x; + + } + + if ( _shadowMapSize.y > _maxTextureSize ) { + + _viewportSize.y = Math.floor( _maxTextureSize / shadowFrameExtents.y ); + _shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y; + shadow.mapSize.y = _viewportSize.y; + + } + + } + + if ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) { + + const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + + shadow.camera.updateProjectionMatrix(); + + } + + if ( shadow.map === null ) { + + const pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.camera.updateProjectionMatrix(); + + } + + _renderer.setRenderTarget( shadow.map ); + _renderer.clear(); + + const viewportCount = shadow.getViewportCount(); + + for ( let vp = 0; vp < viewportCount; vp ++ ) { + + const viewport = shadow.getViewport( vp ); + + _viewport.set( + _viewportSize.x * viewport.x, + _viewportSize.y * viewport.y, + _viewportSize.x * viewport.z, + _viewportSize.y * viewport.w + ); + + _state.viewport( _viewport ); + + shadow.updateMatrices( light, vp ); + + _frustum = shadow.getFrustum(); + + renderObject( scene, camera, shadow.camera, light, this.type ); + + } + + // do blur pass for VSM + + if ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) { + + VSMPass( shadow, camera ); + + } + + shadow.needsUpdate = false; + + } + + scope.needsUpdate = false; + + _renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel ); + + }; + + function VSMPass( shadow, camera ) { + + const geometry = _objects.update( fullScreenMesh ); + + if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) { + + shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples; + shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples; + + shadowMaterialVertical.needsUpdate = true; + shadowMaterialHorizontal.needsUpdate = true; + + } + + // vertical pass + + shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture; + shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize; + shadowMaterialVertical.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget( shadow.mapPass ); + _renderer.clear(); + _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null ); + + // horizontal pass + + shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture; + shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize; + shadowMaterialHorizontal.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget( shadow.map ); + _renderer.clear(); + _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null ); + + } + + function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) { + + let result = null; + + const customMaterial = ( light.isPointLight === true ) ? object.customDistanceMaterial : object.customDepthMaterial; + + if ( customMaterial !== undefined ) { + + result = customMaterial; + + } else { + + result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial; + + } + + if ( ( _renderer.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0 ) || + ( material.displacementMap && material.displacementScale !== 0 ) || + ( material.alphaMap && material.alphaTest > 0 ) ) { + + // in this case we need a unique material instance reflecting the + // appropriate state + + const keyA = result.uuid, keyB = material.uuid; + + let materialsForVariant = _materialCache[ keyA ]; + + if ( materialsForVariant === undefined ) { + + materialsForVariant = {}; + _materialCache[ keyA ] = materialsForVariant; + + } + + let cachedMaterial = materialsForVariant[ keyB ]; + + if ( cachedMaterial === undefined ) { + + cachedMaterial = result.clone(); + materialsForVariant[ keyB ] = cachedMaterial; + + } + + result = cachedMaterial; + + } + + result.visible = material.visible; + result.wireframe = material.wireframe; + + if ( type === VSMShadowMap ) { + + result.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side; + + } else { + + result.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ]; + + } + + result.alphaMap = material.alphaMap; + result.alphaTest = material.alphaTest; + + result.clipShadows = material.clipShadows; + result.clippingPlanes = material.clippingPlanes; + result.clipIntersection = material.clipIntersection; + + result.displacementMap = material.displacementMap; + result.displacementScale = material.displacementScale; + result.displacementBias = material.displacementBias; + + result.wireframeLinewidth = material.wireframeLinewidth; + result.linewidth = material.linewidth; + + if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) { + + result.referencePosition.setFromMatrixPosition( light.matrixWorld ); + result.nearDistance = shadowCameraNear; + result.farDistance = shadowCameraFar; + + } + + return result; + + } + + function renderObject( object, camera, shadowCamera, light, type ) { + + if ( object.visible === false ) return; + + const visible = object.layers.test( camera.layers ); + + if ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) { + + if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) { + + object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld ); + + const geometry = _objects.update( object ); + const material = object.material; + + if ( Array.isArray( material ) ) { + + const groups = geometry.groups; + + for ( let k = 0, kl = groups.length; k < kl; k ++ ) { + + const group = groups[ k ]; + const groupMaterial = material[ group.materialIndex ]; + + if ( groupMaterial && groupMaterial.visible ) { + + const depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); + + _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group ); + + } + + } + + } else if ( material.visible ) { + + const depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type ); + + _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null ); + + } + + } + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + renderObject( children[ i ], camera, shadowCamera, light, type ); + + } + + } + +} + +function WebGLState( gl, extensions, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + function ColorBuffer() { + + let locked = false; + + const color = new Vector4(); + let currentColorMask = null; + const currentColorClear = new Vector4( 0, 0, 0, 0 ); + + return { + + setMask: function ( colorMask ) { + + if ( currentColorMask !== colorMask && ! locked ) { + + gl.colorMask( colorMask, colorMask, colorMask, colorMask ); + currentColorMask = colorMask; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( r, g, b, a, premultipliedAlpha ) { + + if ( premultipliedAlpha === true ) { + + r *= a; g *= a; b *= a; + + } + + color.set( r, g, b, a ); + + if ( currentColorClear.equals( color ) === false ) { + + gl.clearColor( r, g, b, a ); + currentColorClear.copy( color ); + + } + + }, + + reset: function () { + + locked = false; + + currentColorMask = null; + currentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state + + } + + }; + + } + + function DepthBuffer() { + + let locked = false; + + let currentDepthMask = null; + let currentDepthFunc = null; + let currentDepthClear = null; + + return { + + setTest: function ( depthTest ) { + + if ( depthTest ) { + + enable( 2929 ); + + } else { + + disable( 2929 ); + + } + + }, + + setMask: function ( depthMask ) { + + if ( currentDepthMask !== depthMask && ! locked ) { + + gl.depthMask( depthMask ); + currentDepthMask = depthMask; + + } + + }, + + setFunc: function ( depthFunc ) { + + if ( currentDepthFunc !== depthFunc ) { + + if ( depthFunc ) { + + switch ( depthFunc ) { + + case NeverDepth: + + gl.depthFunc( 512 ); + break; + + case AlwaysDepth: + + gl.depthFunc( 519 ); + break; + + case LessDepth: + + gl.depthFunc( 513 ); + break; + + case LessEqualDepth: + + gl.depthFunc( 515 ); + break; + + case EqualDepth: + + gl.depthFunc( 514 ); + break; + + case GreaterEqualDepth: + + gl.depthFunc( 518 ); + break; + + case GreaterDepth: + + gl.depthFunc( 516 ); + break; + + case NotEqualDepth: + + gl.depthFunc( 517 ); + break; + + default: + + gl.depthFunc( 515 ); + + } + + } else { + + gl.depthFunc( 515 ); + + } + + currentDepthFunc = depthFunc; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( depth ) { + + if ( currentDepthClear !== depth ) { + + gl.clearDepth( depth ); + currentDepthClear = depth; + + } + + }, + + reset: function () { + + locked = false; + + currentDepthMask = null; + currentDepthFunc = null; + currentDepthClear = null; + + } + + }; + + } + + function StencilBuffer() { + + let locked = false; + + let currentStencilMask = null; + let currentStencilFunc = null; + let currentStencilRef = null; + let currentStencilFuncMask = null; + let currentStencilFail = null; + let currentStencilZFail = null; + let currentStencilZPass = null; + let currentStencilClear = null; + + return { + + setTest: function ( stencilTest ) { + + if ( ! locked ) { + + if ( stencilTest ) { + + enable( 2960 ); + + } else { + + disable( 2960 ); + + } + + } + + }, + + setMask: function ( stencilMask ) { + + if ( currentStencilMask !== stencilMask && ! locked ) { + + gl.stencilMask( stencilMask ); + currentStencilMask = stencilMask; + + } + + }, + + setFunc: function ( stencilFunc, stencilRef, stencilMask ) { + + if ( currentStencilFunc !== stencilFunc || + currentStencilRef !== stencilRef || + currentStencilFuncMask !== stencilMask ) { + + gl.stencilFunc( stencilFunc, stencilRef, stencilMask ); + + currentStencilFunc = stencilFunc; + currentStencilRef = stencilRef; + currentStencilFuncMask = stencilMask; + + } + + }, + + setOp: function ( stencilFail, stencilZFail, stencilZPass ) { + + if ( currentStencilFail !== stencilFail || + currentStencilZFail !== stencilZFail || + currentStencilZPass !== stencilZPass ) { + + gl.stencilOp( stencilFail, stencilZFail, stencilZPass ); + + currentStencilFail = stencilFail; + currentStencilZFail = stencilZFail; + currentStencilZPass = stencilZPass; + + } + + }, + + setLocked: function ( lock ) { + + locked = lock; + + }, + + setClear: function ( stencil ) { + + if ( currentStencilClear !== stencil ) { + + gl.clearStencil( stencil ); + currentStencilClear = stencil; + + } + + }, + + reset: function () { + + locked = false; + + currentStencilMask = null; + currentStencilFunc = null; + currentStencilRef = null; + currentStencilFuncMask = null; + currentStencilFail = null; + currentStencilZFail = null; + currentStencilZPass = null; + currentStencilClear = null; + + } + + }; + + } + + // + + const colorBuffer = new ColorBuffer(); + const depthBuffer = new DepthBuffer(); + const stencilBuffer = new StencilBuffer(); + + let enabledCapabilities = {}; + + let currentBoundFramebuffers = {}; + let currentDrawbuffers = new WeakMap(); + let defaultDrawbuffers = []; + + let currentProgram = null; + + let currentBlendingEnabled = false; + let currentBlending = null; + let currentBlendEquation = null; + let currentBlendSrc = null; + let currentBlendDst = null; + let currentBlendEquationAlpha = null; + let currentBlendSrcAlpha = null; + let currentBlendDstAlpha = null; + let currentPremultipledAlpha = false; + + let currentFlipSided = null; + let currentCullFace = null; + + let currentLineWidth = null; + + let currentPolygonOffsetFactor = null; + let currentPolygonOffsetUnits = null; + + const maxTextures = gl.getParameter( 35661 ); + + let lineWidthAvailable = false; + let version = 0; + const glVersion = gl.getParameter( 7938 ); + + if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) { + + version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] ); + lineWidthAvailable = ( version >= 1.0 ); + + } else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) { + + version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] ); + lineWidthAvailable = ( version >= 2.0 ); + + } + + let currentTextureSlot = null; + let currentBoundTextures = {}; + + const scissorParam = gl.getParameter( 3088 ); + const viewportParam = gl.getParameter( 2978 ); + + const currentScissor = new Vector4().fromArray( scissorParam ); + const currentViewport = new Vector4().fromArray( viewportParam ); + + function createTexture( type, target, count ) { + + const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4. + const texture = gl.createTexture(); + + gl.bindTexture( type, texture ); + gl.texParameteri( type, 10241, 9728 ); + gl.texParameteri( type, 10240, 9728 ); + + for ( let i = 0; i < count; i ++ ) { + + gl.texImage2D( target + i, 0, 6408, 1, 1, 0, 6408, 5121, data ); + + } + + return texture; + + } + + const emptyTextures = {}; + emptyTextures[ 3553 ] = createTexture( 3553, 3553, 1 ); + emptyTextures[ 34067 ] = createTexture( 34067, 34069, 6 ); + + // init + + colorBuffer.setClear( 0, 0, 0, 1 ); + depthBuffer.setClear( 1 ); + stencilBuffer.setClear( 0 ); + + enable( 2929 ); + depthBuffer.setFunc( LessEqualDepth ); + + setFlipSided( false ); + setCullFace( CullFaceBack ); + enable( 2884 ); + + setBlending( NoBlending ); + + // + + function enable( id ) { + + if ( enabledCapabilities[ id ] !== true ) { + + gl.enable( id ); + enabledCapabilities[ id ] = true; + + } + + } + + function disable( id ) { + + if ( enabledCapabilities[ id ] !== false ) { + + gl.disable( id ); + enabledCapabilities[ id ] = false; + + } + + } + + function bindFramebuffer( target, framebuffer ) { + + if ( currentBoundFramebuffers[ target ] !== framebuffer ) { + + gl.bindFramebuffer( target, framebuffer ); + + currentBoundFramebuffers[ target ] = framebuffer; + + if ( isWebGL2 ) { + + // 36009 is equivalent to 36160 + + if ( target === 36009 ) { + + currentBoundFramebuffers[ 36160 ] = framebuffer; + + } + + if ( target === 36160 ) { + + currentBoundFramebuffers[ 36009 ] = framebuffer; + + } + + } + + return true; + + } + + return false; + + } + + function drawBuffers( renderTarget, framebuffer ) { + + let drawBuffers = defaultDrawbuffers; + + let needsUpdate = false; + + if ( renderTarget ) { + + drawBuffers = currentDrawbuffers.get( framebuffer ); + + if ( drawBuffers === undefined ) { + + drawBuffers = []; + currentDrawbuffers.set( framebuffer, drawBuffers ); + + } + + if ( renderTarget.isWebGLMultipleRenderTargets ) { + + const textures = renderTarget.texture; + + if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== 36064 ) { + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + drawBuffers[ i ] = 36064 + i; + + } + + drawBuffers.length = textures.length; + + needsUpdate = true; + + } + + } else { + + if ( drawBuffers[ 0 ] !== 36064 ) { + + drawBuffers[ 0 ] = 36064; + + needsUpdate = true; + + } + + } + + } else { + + if ( drawBuffers[ 0 ] !== 1029 ) { + + drawBuffers[ 0 ] = 1029; + + needsUpdate = true; + + } + + } + + if ( needsUpdate ) { + + if ( capabilities.isWebGL2 ) { + + gl.drawBuffers( drawBuffers ); + + } else { + + extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers ); + + } + + } + + + } + + function useProgram( program ) { + + if ( currentProgram !== program ) { + + gl.useProgram( program ); + + currentProgram = program; + + return true; + + } + + return false; + + } + + const equationToGL = { + [ AddEquation ]: 32774, + [ SubtractEquation ]: 32778, + [ ReverseSubtractEquation ]: 32779 + }; + + if ( isWebGL2 ) { + + equationToGL[ MinEquation ] = 32775; + equationToGL[ MaxEquation ] = 32776; + + } else { + + const extension = extensions.get( 'EXT_blend_minmax' ); + + if ( extension !== null ) { + + equationToGL[ MinEquation ] = extension.MIN_EXT; + equationToGL[ MaxEquation ] = extension.MAX_EXT; + + } + + } + + const factorToGL = { + [ ZeroFactor ]: 0, + [ OneFactor ]: 1, + [ SrcColorFactor ]: 768, + [ SrcAlphaFactor ]: 770, + [ SrcAlphaSaturateFactor ]: 776, + [ DstColorFactor ]: 774, + [ DstAlphaFactor ]: 772, + [ OneMinusSrcColorFactor ]: 769, + [ OneMinusSrcAlphaFactor ]: 771, + [ OneMinusDstColorFactor ]: 775, + [ OneMinusDstAlphaFactor ]: 773 + }; + + function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) { + + if ( blending === NoBlending ) { + + if ( currentBlendingEnabled === true ) { + + disable( 3042 ); + currentBlendingEnabled = false; + + } + + return; + + } + + if ( currentBlendingEnabled === false ) { + + enable( 3042 ); + currentBlendingEnabled = true; + + } + + if ( blending !== CustomBlending ) { + + if ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) { + + if ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) { + + gl.blendEquation( 32774 ); + + currentBlendEquation = AddEquation; + currentBlendEquationAlpha = AddEquation; + + } + + if ( premultipliedAlpha ) { + + switch ( blending ) { + + case NormalBlending: + gl.blendFuncSeparate( 1, 771, 1, 771 ); + break; + + case AdditiveBlending: + gl.blendFunc( 1, 1 ); + break; + + case SubtractiveBlending: + gl.blendFuncSeparate( 0, 0, 769, 771 ); + break; + + case MultiplyBlending: + gl.blendFuncSeparate( 0, 768, 0, 770 ); + break; + + default: + console.error( 'THREE.WebGLState: Invalid blending: ', blending ); + break; + + } + + } else { + + switch ( blending ) { + + case NormalBlending: + gl.blendFuncSeparate( 770, 771, 1, 771 ); + break; + + case AdditiveBlending: + gl.blendFunc( 770, 1 ); + break; + + case SubtractiveBlending: + gl.blendFunc( 0, 769 ); + break; + + case MultiplyBlending: + gl.blendFunc( 0, 768 ); + break; + + default: + console.error( 'THREE.WebGLState: Invalid blending: ', blending ); + break; + + } + + } + + currentBlendSrc = null; + currentBlendDst = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + + currentBlending = blending; + currentPremultipledAlpha = premultipliedAlpha; + + } + + return; + + } + + // custom blending + + blendEquationAlpha = blendEquationAlpha || blendEquation; + blendSrcAlpha = blendSrcAlpha || blendSrc; + blendDstAlpha = blendDstAlpha || blendDst; + + if ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) { + + gl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] ); + + currentBlendEquation = blendEquation; + currentBlendEquationAlpha = blendEquationAlpha; + + } + + if ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) { + + gl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] ); + + currentBlendSrc = blendSrc; + currentBlendDst = blendDst; + currentBlendSrcAlpha = blendSrcAlpha; + currentBlendDstAlpha = blendDstAlpha; + + } + + currentBlending = blending; + currentPremultipledAlpha = null; + + } + + function setMaterial( material, frontFaceCW ) { + + material.side === DoubleSide + ? disable( 2884 ) + : enable( 2884 ); + + let flipSided = ( material.side === BackSide ); + if ( frontFaceCW ) flipSided = ! flipSided; + + setFlipSided( flipSided ); + + ( material.blending === NormalBlending && material.transparent === false ) + ? setBlending( NoBlending ) + : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha ); + + depthBuffer.setFunc( material.depthFunc ); + depthBuffer.setTest( material.depthTest ); + depthBuffer.setMask( material.depthWrite ); + colorBuffer.setMask( material.colorWrite ); + + const stencilWrite = material.stencilWrite; + stencilBuffer.setTest( stencilWrite ); + if ( stencilWrite ) { + + stencilBuffer.setMask( material.stencilWriteMask ); + stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask ); + stencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass ); + + } + + setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits ); + + material.alphaToCoverage === true + ? enable( 32926 ) + : disable( 32926 ); + + } + + // + + function setFlipSided( flipSided ) { + + if ( currentFlipSided !== flipSided ) { + + if ( flipSided ) { + + gl.frontFace( 2304 ); + + } else { + + gl.frontFace( 2305 ); + + } + + currentFlipSided = flipSided; + + } + + } + + function setCullFace( cullFace ) { + + if ( cullFace !== CullFaceNone ) { + + enable( 2884 ); + + if ( cullFace !== currentCullFace ) { + + if ( cullFace === CullFaceBack ) { + + gl.cullFace( 1029 ); + + } else if ( cullFace === CullFaceFront ) { + + gl.cullFace( 1028 ); + + } else { + + gl.cullFace( 1032 ); + + } + + } + + } else { + + disable( 2884 ); + + } + + currentCullFace = cullFace; + + } + + function setLineWidth( width ) { + + if ( width !== currentLineWidth ) { + + if ( lineWidthAvailable ) gl.lineWidth( width ); + + currentLineWidth = width; + + } + + } + + function setPolygonOffset( polygonOffset, factor, units ) { + + if ( polygonOffset ) { + + enable( 32823 ); + + if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) { + + gl.polygonOffset( factor, units ); + + currentPolygonOffsetFactor = factor; + currentPolygonOffsetUnits = units; + + } + + } else { + + disable( 32823 ); + + } + + } + + function setScissorTest( scissorTest ) { + + if ( scissorTest ) { + + enable( 3089 ); + + } else { + + disable( 3089 ); + + } + + } + + // texture + + function activeTexture( webglSlot ) { + + if ( webglSlot === undefined ) webglSlot = 33984 + maxTextures - 1; + + if ( currentTextureSlot !== webglSlot ) { + + gl.activeTexture( webglSlot ); + currentTextureSlot = webglSlot; + + } + + } + + function bindTexture( webglType, webglTexture ) { + + if ( currentTextureSlot === null ) { + + activeTexture(); + + } + + let boundTexture = currentBoundTextures[ currentTextureSlot ]; + + if ( boundTexture === undefined ) { + + boundTexture = { type: undefined, texture: undefined }; + currentBoundTextures[ currentTextureSlot ] = boundTexture; + + } + + if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) { + + gl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] ); + + boundTexture.type = webglType; + boundTexture.texture = webglTexture; + + } + + } + + function unbindTexture() { + + const boundTexture = currentBoundTextures[ currentTextureSlot ]; + + if ( boundTexture !== undefined && boundTexture.type !== undefined ) { + + gl.bindTexture( boundTexture.type, null ); + + boundTexture.type = undefined; + boundTexture.texture = undefined; + + } + + } + + function compressedTexImage2D() { + + try { + + gl.compressedTexImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texSubImage2D() { + + try { + + gl.texSubImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texSubImage3D() { + + try { + + gl.texSubImage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function compressedTexSubImage2D() { + + try { + + gl.compressedTexSubImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texStorage2D() { + + try { + + gl.texStorage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texStorage3D() { + + try { + + gl.texStorage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texImage2D() { + + try { + + gl.texImage2D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + function texImage3D() { + + try { + + gl.texImage3D.apply( gl, arguments ); + + } catch ( error ) { + + console.error( 'THREE.WebGLState:', error ); + + } + + } + + // + + function scissor( scissor ) { + + if ( currentScissor.equals( scissor ) === false ) { + + gl.scissor( scissor.x, scissor.y, scissor.z, scissor.w ); + currentScissor.copy( scissor ); + + } + + } + + function viewport( viewport ) { + + if ( currentViewport.equals( viewport ) === false ) { + + gl.viewport( viewport.x, viewport.y, viewport.z, viewport.w ); + currentViewport.copy( viewport ); + + } + + } + + // + + function reset() { + + // reset state + + gl.disable( 3042 ); + gl.disable( 2884 ); + gl.disable( 2929 ); + gl.disable( 32823 ); + gl.disable( 3089 ); + gl.disable( 2960 ); + gl.disable( 32926 ); + + gl.blendEquation( 32774 ); + gl.blendFunc( 1, 0 ); + gl.blendFuncSeparate( 1, 0, 1, 0 ); + + gl.colorMask( true, true, true, true ); + gl.clearColor( 0, 0, 0, 0 ); + + gl.depthMask( true ); + gl.depthFunc( 513 ); + gl.clearDepth( 1 ); + + gl.stencilMask( 0xffffffff ); + gl.stencilFunc( 519, 0, 0xffffffff ); + gl.stencilOp( 7680, 7680, 7680 ); + gl.clearStencil( 0 ); + + gl.cullFace( 1029 ); + gl.frontFace( 2305 ); + + gl.polygonOffset( 0, 0 ); + + gl.activeTexture( 33984 ); + + gl.bindFramebuffer( 36160, null ); + + if ( isWebGL2 === true ) { + + gl.bindFramebuffer( 36009, null ); + gl.bindFramebuffer( 36008, null ); + + } + + gl.useProgram( null ); + + gl.lineWidth( 1 ); + + gl.scissor( 0, 0, gl.canvas.width, gl.canvas.height ); + gl.viewport( 0, 0, gl.canvas.width, gl.canvas.height ); + + // reset internals + + enabledCapabilities = {}; + + currentTextureSlot = null; + currentBoundTextures = {}; + + currentBoundFramebuffers = {}; + currentDrawbuffers = new WeakMap(); + defaultDrawbuffers = []; + + currentProgram = null; + + currentBlendingEnabled = false; + currentBlending = null; + currentBlendEquation = null; + currentBlendSrc = null; + currentBlendDst = null; + currentBlendEquationAlpha = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + currentPremultipledAlpha = false; + + currentFlipSided = null; + currentCullFace = null; + + currentLineWidth = null; + + currentPolygonOffsetFactor = null; + currentPolygonOffsetUnits = null; + + currentScissor.set( 0, 0, gl.canvas.width, gl.canvas.height ); + currentViewport.set( 0, 0, gl.canvas.width, gl.canvas.height ); + + colorBuffer.reset(); + depthBuffer.reset(); + stencilBuffer.reset(); + + } + + return { + + buffers: { + color: colorBuffer, + depth: depthBuffer, + stencil: stencilBuffer + }, + + enable: enable, + disable: disable, + + bindFramebuffer: bindFramebuffer, + drawBuffers: drawBuffers, + + useProgram: useProgram, + + setBlending: setBlending, + setMaterial: setMaterial, + + setFlipSided: setFlipSided, + setCullFace: setCullFace, + + setLineWidth: setLineWidth, + setPolygonOffset: setPolygonOffset, + + setScissorTest: setScissorTest, + + activeTexture: activeTexture, + bindTexture: bindTexture, + unbindTexture: unbindTexture, + compressedTexImage2D: compressedTexImage2D, + texImage2D: texImage2D, + texImage3D: texImage3D, + + texStorage2D: texStorage2D, + texStorage3D: texStorage3D, + texSubImage2D: texSubImage2D, + texSubImage3D: texSubImage3D, + compressedTexSubImage2D: compressedTexSubImage2D, + + scissor: scissor, + viewport: viewport, + + reset: reset + + }; + +} + +function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { + + const isWebGL2 = capabilities.isWebGL2; + const maxTextures = capabilities.maxTextures; + const maxCubemapSize = capabilities.maxCubemapSize; + const maxTextureSize = capabilities.maxTextureSize; + const maxSamples = capabilities.maxSamples; + const hasMultisampledRenderToTexture = extensions.has( 'WEBGL_multisampled_render_to_texture' ); + const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : undefined; + + const _videoTextures = new WeakMap(); + let _canvas; + + // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas, + // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")! + // Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d). + + let useOffscreenCanvas = false; + + try { + + useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' + && ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null; + + } catch ( err ) { + + // Ignore any errors + + } + + function createCanvas( width, height ) { + + // Use OffscreenCanvas when available. Specially needed in web workers + + return useOffscreenCanvas ? + new OffscreenCanvas( width, height ) : createElementNS( 'canvas' ); + + } + + function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) { + + let scale = 1; + + // handle case if texture exceeds max size + + if ( image.width > maxSize || image.height > maxSize ) { + + scale = maxSize / Math.max( image.width, image.height ); + + } + + // only perform resize if necessary + + if ( scale < 1 || needsPowerOfTwo === true ) { + + // only perform resize for certain image types + + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { + + const floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor; + + const width = floor( scale * image.width ); + const height = floor( scale * image.height ); + + if ( _canvas === undefined ) _canvas = createCanvas( width, height ); + + // cube textures can't reuse the same canvas + + const canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas; + + canvas.width = width; + canvas.height = height; + + const context = canvas.getContext( '2d' ); + context.drawImage( image, 0, 0, width, height ); + + console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' ); + + return canvas; + + } else { + + if ( 'data' in image ) { + + console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' ); + + } + + return image; + + } + + } + + return image; + + } + + function isPowerOfTwo$1( image ) { + + return isPowerOfTwo( image.width ) && isPowerOfTwo( image.height ); + + } + + function textureNeedsPowerOfTwo( texture ) { + + if ( isWebGL2 ) return false; + + return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || + ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ); + + } + + function textureNeedsGenerateMipmaps( texture, supportsMips ) { + + return texture.generateMipmaps && supportsMips && + texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter; + + } + + function generateMipmap( target ) { + + _gl.generateMipmap( target ); + + } + + function getInternalFormat( internalFormatName, glFormat, glType, encoding, isVideoTexture = false ) { + + if ( isWebGL2 === false ) return glFormat; + + if ( internalFormatName !== null ) { + + if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ]; + + console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' ); + + } + + let internalFormat = glFormat; + + if ( glFormat === 6403 ) { + + if ( glType === 5126 ) internalFormat = 33326; + if ( glType === 5131 ) internalFormat = 33325; + if ( glType === 5121 ) internalFormat = 33321; + + } + + if ( glFormat === 6407 ) { + + if ( glType === 5126 ) internalFormat = 34837; + if ( glType === 5131 ) internalFormat = 34843; + if ( glType === 5121 ) internalFormat = 32849; + + } + + if ( glFormat === 6408 ) { + + if ( glType === 5126 ) internalFormat = 34836; + if ( glType === 5131 ) internalFormat = 34842; + if ( glType === 5121 ) internalFormat = ( encoding === sRGBEncoding && isVideoTexture === false ) ? 35907 : 32856; + + } + + if ( internalFormat === 33325 || internalFormat === 33326 || + internalFormat === 34842 || internalFormat === 34836 ) { + + extensions.get( 'EXT_color_buffer_float' ); + + } + + return internalFormat; + + } + + function getMipLevels( texture, image, supportsMips ) { + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) { + + return Math.log2( Math.max( image.width, image.height ) ) + 1; + + } else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) { + + // user-defined mipmaps + + return texture.mipmaps.length; + + } else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) { + + return image.mipmaps.length; + + } else { + + // texture without mipmaps (only base level) + + return 1; + + } + + } + + // Fallback filters for non-power-of-2 textures + + function filterFallback( f ) { + + if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) { + + return 9728; + + } + + return 9729; + + } + + // + + function onTextureDispose( event ) { + + const texture = event.target; + + texture.removeEventListener( 'dispose', onTextureDispose ); + + deallocateTexture( texture ); + + if ( texture.isVideoTexture ) { + + _videoTextures.delete( texture ); + + } + + info.memory.textures --; + + } + + function onRenderTargetDispose( event ) { + + const renderTarget = event.target; + + renderTarget.removeEventListener( 'dispose', onRenderTargetDispose ); + + deallocateRenderTarget( renderTarget ); + + } + + // + + function deallocateTexture( texture ) { + + const textureProperties = properties.get( texture ); + + if ( textureProperties.__webglInit === undefined ) return; + + _gl.deleteTexture( textureProperties.__webglTexture ); + + properties.remove( texture ); + + } + + function deallocateRenderTarget( renderTarget ) { + + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get( renderTarget ); + const textureProperties = properties.get( texture ); + + if ( ! renderTarget ) return; + + if ( textureProperties.__webglTexture !== undefined ) { + + _gl.deleteTexture( textureProperties.__webglTexture ); + + info.memory.textures --; + + } + + if ( renderTarget.depthTexture ) { + + renderTarget.depthTexture.dispose(); + + } + + if ( renderTarget.isWebGLCubeRenderTarget ) { + + for ( let i = 0; i < 6; i ++ ) { + + _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] ); + + } + + } else { + + _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); + if ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer ); + if ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer ); + if ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer ); + + } + + if ( renderTarget.isWebGLMultipleRenderTargets ) { + + for ( let i = 0, il = texture.length; i < il; i ++ ) { + + const attachmentProperties = properties.get( texture[ i ] ); + + if ( attachmentProperties.__webglTexture ) { + + _gl.deleteTexture( attachmentProperties.__webglTexture ); + + info.memory.textures --; + + } + + properties.remove( texture[ i ] ); + + } + + } + + properties.remove( texture ); + properties.remove( renderTarget ); + + } + + // + + let textureUnits = 0; + + function resetTextureUnits() { + + textureUnits = 0; + + } + + function allocateTextureUnit() { + + const textureUnit = textureUnits; + + if ( textureUnit >= maxTextures ) { + + console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures ); + + } + + textureUnits += 1; + + return textureUnit; + + } + + // + + function setTexture2D( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.isVideoTexture ) updateVideoTexture( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + const image = texture.image; + + if ( image === undefined ) { + + console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' ); + + } else if ( image.complete === false ) { + + console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' ); + + } else { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 3553, textureProperties.__webglTexture ); + + } + + function setTexture2DArray( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 35866, textureProperties.__webglTexture ); + + } + + function setTexture3D( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 32879, textureProperties.__webglTexture ); + + } + + function setTextureCube( texture, slot ) { + + const textureProperties = properties.get( texture ); + + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + + uploadCubeTexture( textureProperties, texture, slot ); + return; + + } + + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); + + } + + const wrappingToGL = { + [ RepeatWrapping ]: 10497, + [ ClampToEdgeWrapping ]: 33071, + [ MirroredRepeatWrapping ]: 33648 + }; + + const filterToGL = { + [ NearestFilter ]: 9728, + [ NearestMipmapNearestFilter ]: 9984, + [ NearestMipmapLinearFilter ]: 9986, + + [ LinearFilter ]: 9729, + [ LinearMipmapNearestFilter ]: 9985, + [ LinearMipmapLinearFilter ]: 9987 + }; + + function setTextureParameters( textureType, texture, supportsMips ) { + + if ( supportsMips ) { + + _gl.texParameteri( textureType, 10242, wrappingToGL[ texture.wrapS ] ); + _gl.texParameteri( textureType, 10243, wrappingToGL[ texture.wrapT ] ); + + if ( textureType === 32879 || textureType === 35866 ) { + + _gl.texParameteri( textureType, 32882, wrappingToGL[ texture.wrapR ] ); + + } + + _gl.texParameteri( textureType, 10240, filterToGL[ texture.magFilter ] ); + _gl.texParameteri( textureType, 10241, filterToGL[ texture.minFilter ] ); + + } else { + + _gl.texParameteri( textureType, 10242, 33071 ); + _gl.texParameteri( textureType, 10243, 33071 ); + + if ( textureType === 32879 || textureType === 35866 ) { + + _gl.texParameteri( textureType, 32882, 33071 ); + + } + + if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) { + + console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' ); + + } + + _gl.texParameteri( textureType, 10240, filterFallback( texture.magFilter ) ); + _gl.texParameteri( textureType, 10241, filterFallback( texture.minFilter ) ); + + if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) { + + console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' ); + + } + + } + + if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) { + + const extension = extensions.get( 'EXT_texture_filter_anisotropic' ); + + if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2 + if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only + + if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) { + + _gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) ); + properties.get( texture ).__currentAnisotropy = texture.anisotropy; + + } + + } + + } + + function initTexture( textureProperties, texture ) { + + if ( textureProperties.__webglInit === undefined ) { + + textureProperties.__webglInit = true; + + texture.addEventListener( 'dispose', onTextureDispose ); + + textureProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures ++; + + } + + } + + function uploadTexture( textureProperties, texture, slot ) { + + let textureType = 3553; + + if ( texture.isDataTexture2DArray ) textureType = 35866; + if ( texture.isDataTexture3D ) textureType = 32879; + + initTexture( textureProperties, texture ); + + state.activeTexture( 33984 + slot ); + state.bindTexture( textureType, textureProperties.__webglTexture ); + + _gl.pixelStorei( 37440, texture.flipY ); + _gl.pixelStorei( 37441, texture.premultiplyAlpha ); + _gl.pixelStorei( 3317, texture.unpackAlignment ); + _gl.pixelStorei( 37443, 0 ); + + const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false; + let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize ); + image = verifyColorSpace( texture, image ); + + const supportsMips = isPowerOfTwo$1( image ) || isWebGL2, + glFormat = utils.convert( texture.format, texture.encoding ); + + let glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture ); + + setTextureParameters( textureType, texture, supportsMips ); + + let mipmap; + const mipmaps = texture.mipmaps; + + const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true ); + const allocateMemory = ( textureProperties.__version === undefined ); + const levels = getMipLevels( texture, image, supportsMips ); + + if ( texture.isDepthTexture ) { + + // populate depth texture with dummy data + + glInternalFormat = 6402; + + if ( isWebGL2 ) { + + if ( texture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( texture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } else if ( texture.type === UnsignedInt248Type ) { + + glInternalFormat = 35056; + + } else { + + glInternalFormat = 33189; // WebGL2 requires sized internalformat for glTexImage2D + + } + + } else { + + if ( texture.type === FloatType ) { + + console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' ); + + } + + } + + // validation checks for WebGL 1 + + if ( texture.format === DepthFormat && glInternalFormat === 6402 ) { + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' ); + + texture.type = UnsignedShortType; + glType = utils.convert( texture.type ); + + } + + } + + if ( texture.format === DepthStencilFormat && glInternalFormat === 6402 ) { + + // Depth stencil textures need the DEPTH_STENCIL internal format + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + glInternalFormat = 34041; + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL. + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedInt248Type ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' ); + + texture.type = UnsignedInt248Type; + glType = utils.convert( texture.type ); + + } + + } + + // + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); + + } + + } else if ( texture.isDataTexture ) { + + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if ( mipmaps.length > 0 && supportsMips ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + texture.generateMipmaps = false; + + } else { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } + + state.texSubImage2D( 3553, 0, 0, 0, image.width, image.height, glFormat, glType, image.data ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data ); + + } + + } + + } else if ( texture.isCompressedTexture ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( texture.format !== RGBAFormat ) { + + if ( glFormat !== null ) { + + if ( useTexStorage ) { + + state.compressedTexSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data ); + + } else { + + state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' ); + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + } + + } else if ( texture.isDataTexture2DArray ) { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage3D( 35866, levels, glInternalFormat, image.width, image.height, image.depth ); + + } + + state.texSubImage3D( 35866, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); + + } else { + + state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data ); + + } + + } else if ( texture.isDataTexture3D ) { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage3D( 32879, levels, glInternalFormat, image.width, image.height, image.depth ); + + } + + state.texSubImage3D( 32879, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); + + } else { + + state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data ); + + } + + } else if ( texture.isFramebufferTexture ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); + + } + + } else { + + // regular Texture (image, video, canvas) + + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if ( mipmaps.length > 0 && supportsMips ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height ); + + } + + for ( let i = 0, il = mipmaps.length; i < il; i ++ ) { + + mipmap = mipmaps[ i ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 3553, i, 0, 0, glFormat, glType, mipmap ); + + } else { + + state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap ); + + } + + } + + texture.generateMipmaps = false; + + } else { + + if ( useTexStorage ) { + + if ( allocateMemory ) { + + state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height ); + + } + + state.texSubImage2D( 3553, 0, 0, 0, glFormat, glType, image ); + + } else { + + state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image ); + + } + + } + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( textureType ); + + } + + textureProperties.__version = texture.version; + + if ( texture.onUpdate ) texture.onUpdate( texture ); + + } + + function uploadCubeTexture( textureProperties, texture, slot ) { + + if ( texture.image.length !== 6 ) return; + + initTexture( textureProperties, texture ); + + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); + + _gl.pixelStorei( 37440, texture.flipY ); + _gl.pixelStorei( 37441, texture.premultiplyAlpha ); + _gl.pixelStorei( 3317, texture.unpackAlignment ); + _gl.pixelStorei( 37443, 0 ); + + const isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) ); + const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); + + const cubeImage = []; + + for ( let i = 0; i < 6; i ++ ) { + + if ( ! isCompressed && ! isDataTexture ) { + + cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize ); + + } else { + + cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; + + } + + cubeImage[ i ] = verifyColorSpace( texture, cubeImage[ i ] ); + + } + + const image = cubeImage[ 0 ], + supportsMips = isPowerOfTwo$1( image ) || isWebGL2, + glFormat = utils.convert( texture.format, texture.encoding ), + glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + + const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true ); + const allocateMemory = ( textureProperties.__version === undefined ); + let levels = getMipLevels( texture, image, supportsMips ); + + setTextureParameters( 34067, texture, supportsMips ); + + let mipmaps; + + if ( isCompressed ) { + + if ( useTexStorage && allocateMemory ) { + + state.texStorage2D( 34067, levels, glInternalFormat, image.width, image.height ); + + } + + for ( let i = 0; i < 6; i ++ ) { + + mipmaps = cubeImage[ i ].mipmaps; + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + + if ( texture.format !== RGBAFormat ) { + + if ( glFormat !== null ) { + + if ( useTexStorage ) { + + state.compressedTexSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data ); + + } else { + + state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data ); + + } else { + + state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + + } + + } + + } + + } + + } else { + + mipmaps = texture.mipmaps; + + if ( useTexStorage && allocateMemory ) { + + // TODO: Uniformly handle mipmap definitions + // Normal textures and compressed cube textures define base level + mips with their mipmap array + // Uncompressed cube textures use their mipmap array only for mips (no base level) + + if ( mipmaps.length > 0 ) levels ++; + + state.texStorage2D( 34067, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height ); + + } + + for ( let i = 0; i < 6; i ++ ) { + + if ( isDataTexture ) { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data ); + + } else { + + state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); + + } + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + const mipmapImage = mipmap.image[ i ].image; + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data ); + + } else { + + state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data ); + + } + + } + + } else { + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] ); + + } else { + + state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); + + } + + for ( let j = 0; j < mipmaps.length; j ++ ) { + + const mipmap = mipmaps[ j ]; + + if ( useTexStorage ) { + + state.texSubImage2D( 34069 + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] ); + + } else { + + state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); + + } + + } + + } + + } + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + // We assume images for cube map have the same size. + generateMipmap( 34067 ); + + } + + textureProperties.__version = texture.version; + + if ( texture.onUpdate ) texture.onUpdate( texture ); + + } + + // Render targets + + // Setup storage for target texture and bind it to correct framebuffer + function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget ) { + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const renderTargetProperties = properties.get( renderTarget ); + + if ( ! renderTargetProperties.__hasExternalTextures ) { + + if ( textureTarget === 32879 || textureTarget === 35866 ) { + + state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null ); + + } else { + + state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null ); + + } + + } + + state.bindFramebuffer( 36160, framebuffer ); + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) ); + + } else { + + _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 ); + + } + + state.bindFramebuffer( 36160, null ); + + } + + + // Setup storage for internal depth/stencil buffers and bind to correct framebuffer + function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) { + + _gl.bindRenderbuffer( 36161, renderbuffer ); + + if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) { + + let glInternalFormat = 33189; + + if ( isMultisample || renderTarget.useRenderToTexture ) { + + const depthTexture = renderTarget.depthTexture; + + if ( depthTexture && depthTexture.isDepthTexture ) { + + if ( depthTexture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( depthTexture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } + + } + + const samples = getRenderTargetSamples( renderTarget ); + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + } else { + + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + _gl.framebufferRenderbuffer( 36160, 36096, 36161, renderbuffer ); + + } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) { + + const samples = getRenderTargetSamples( renderTarget ); + + if ( isMultisample && renderTarget.useRenderbuffer ) { + + _gl.renderbufferStorageMultisample( 36161, samples, 35056, renderTarget.width, renderTarget.height ); + + } else if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, 35056, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorage( 36161, 34041, renderTarget.width, renderTarget.height ); + + } + + + _gl.framebufferRenderbuffer( 36160, 33306, 36161, renderbuffer ); + + } else { + + // Use the first texture for MRT so far + const texture = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture[ 0 ] : renderTarget.texture; + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const samples = getRenderTargetSamples( renderTarget ); + + if ( isMultisample && renderTarget.useRenderbuffer ) { + + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + } else { + + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); + + } + + } + + _gl.bindRenderbuffer( 36161, null ); + + } + + // Setup resources for a Depth Texture for a FBO (needs an extension) + function setupDepthTexture( framebuffer, renderTarget ) { + + const isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget ); + if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' ); + + state.bindFramebuffer( 36160, framebuffer ); + + if ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) { + + throw new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' ); + + } + + // upload an empty depth texture with framebuffer size + if ( ! properties.get( renderTarget.depthTexture ).__webglTexture || + renderTarget.depthTexture.image.width !== renderTarget.width || + renderTarget.depthTexture.image.height !== renderTarget.height ) { + + renderTarget.depthTexture.image.width = renderTarget.width; + renderTarget.depthTexture.image.height = renderTarget.height; + renderTarget.depthTexture.needsUpdate = true; + + } + + setTexture2D( renderTarget.depthTexture, 0 ); + + const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture; + const samples = getRenderTargetSamples( renderTarget ); + + if ( renderTarget.depthTexture.format === DepthFormat ) { + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 36096, 3553, webglDepthTexture, 0, samples ); + + } else { + + _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 ); + + } + + } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) { + + if ( renderTarget.useRenderToTexture ) { + + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 33306, 3553, webglDepthTexture, 0, samples ); + + } else { + + _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 ); + + } + + } else { + + throw new Error( 'Unknown depthTexture format' ); + + } + + } + + // Setup GL resources for a non-texture depth buffer + function setupDepthRenderbuffer( renderTarget ) { + + const renderTargetProperties = properties.get( renderTarget ); + const isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); + + if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) { + + if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' ); + + setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget ); + + } else { + + if ( isCube ) { + + renderTargetProperties.__webglDepthbuffer = []; + + for ( let i = 0; i < 6; i ++ ) { + + state.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer[ i ] ); + renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false ); + + } + + } else { + + state.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); + renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false ); + + } + + } + + state.bindFramebuffer( 36160, null ); + + } + + // rebind framebuffer with external textures + function rebindTextures( renderTarget, colorTexture, depthTexture ) { + + const renderTargetProperties = properties.get( renderTarget ); + + if ( colorTexture !== undefined ) { + + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, 36064, 3553 ); + + } + + if ( depthTexture !== undefined ) { + + setupDepthRenderbuffer( renderTarget ); + + } + + } + + // Set up GL resources for the render target + function setupRenderTarget( renderTarget ) { + + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get( renderTarget ); + const textureProperties = properties.get( texture ); + + renderTarget.addEventListener( 'dispose', onRenderTargetDispose ); + + if ( renderTarget.isWebGLMultipleRenderTargets !== true ) { + + if ( textureProperties.__webglTexture === undefined ) { + + textureProperties.__webglTexture = _gl.createTexture(); + + } + + textureProperties.__version = texture.version; + info.memory.textures ++; + + } + + const isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); + const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true ); + const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray; + const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2; + + // Setup framebuffer + + if ( isCube ) { + + renderTargetProperties.__webglFramebuffer = []; + + for ( let i = 0; i < 6; i ++ ) { + + renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer(); + + } + + } else { + + renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer(); + + if ( isMultipleRenderTargets ) { + + if ( capabilities.drawBuffers ) { + + const textures = renderTarget.texture; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const attachmentProperties = properties.get( textures[ i ] ); + + if ( attachmentProperties.__webglTexture === undefined ) { + + attachmentProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures ++; + + } + + } + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' ); + + } + + } else if ( renderTarget.useRenderbuffer ) { + + if ( isWebGL2 ) { + + renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer(); + renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer(); + + _gl.bindRenderbuffer( 36161, renderTargetProperties.__webglColorRenderbuffer ); + + const glFormat = utils.convert( texture.format, texture.encoding ); + const glType = utils.convert( texture.type ); + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); + const samples = getRenderTargetSamples( renderTarget ); + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); + + state.bindFramebuffer( 36160, renderTargetProperties.__webglMultisampledFramebuffer ); + _gl.framebufferRenderbuffer( 36160, 36064, 36161, renderTargetProperties.__webglColorRenderbuffer ); + _gl.bindRenderbuffer( 36161, null ); + + if ( renderTarget.depthBuffer ) { + + renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true ); + + } + + state.bindFramebuffer( 36160, null ); + + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); + + } + + } + + } + + // Setup color buffer + + if ( isCube ) { + + state.bindTexture( 34067, textureProperties.__webglTexture ); + setTextureParameters( 34067, texture, supportsMips ); + + for ( let i = 0; i < 6; i ++ ) { + + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, texture, 36064, 34069 + i ); + + } + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( 34067 ); + + } + + state.unbindTexture(); + + } else if ( isMultipleRenderTargets ) { + + const textures = renderTarget.texture; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const attachment = textures[ i ]; + const attachmentProperties = properties.get( attachment ); + + state.bindTexture( 3553, attachmentProperties.__webglTexture ); + setTextureParameters( 3553, attachment, supportsMips ); + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, 36064 + i, 3553 ); + + if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) { + + generateMipmap( 3553 ); + + } + + } + + state.unbindTexture(); + + } else { + + let glTextureType = 3553; + + if ( isRenderTarget3D ) { + + // Render targets containing layers, i.e: Texture 3D and 2d arrays + + if ( isWebGL2 ) { + + const isTexture3D = texture.isDataTexture3D; + glTextureType = isTexture3D ? 32879 : 35866; + + } else { + + console.warn( 'THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.' ); + + } + + } + + state.bindTexture( glTextureType, textureProperties.__webglTexture ); + setTextureParameters( glTextureType, texture, supportsMips ); + setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, texture, 36064, glTextureType ); + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + generateMipmap( glTextureType ); + + } + + state.unbindTexture(); + + } + + // Setup depth and stencil buffers + + if ( renderTarget.depthBuffer ) { + + setupDepthRenderbuffer( renderTarget ); + + } + + } + + function updateRenderTargetMipmap( renderTarget ) { + + const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2; + + const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ]; + + for ( let i = 0, il = textures.length; i < il; i ++ ) { + + const texture = textures[ i ]; + + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + + const target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553; + const webglTexture = properties.get( texture ).__webglTexture; + + state.bindTexture( target, webglTexture ); + generateMipmap( target ); + state.unbindTexture(); + + } + + } + + } + + function updateMultisampleRenderTarget( renderTarget ) { + + if ( renderTarget.useRenderbuffer ) { + + if ( isWebGL2 ) { + + const width = renderTarget.width; + const height = renderTarget.height; + let mask = 16384; + const invalidationArray = [ 36064 ]; + const depthStyle = renderTarget.stencilBuffer ? 33306 : 36096; + + if ( renderTarget.depthBuffer ) { + + invalidationArray.push( depthStyle ); + + } + + if ( ! renderTarget.ignoreDepthForMultisampleCopy ) { + + if ( renderTarget.depthBuffer ) mask |= 256; + if ( renderTarget.stencilBuffer ) mask |= 1024; + + } + + const renderTargetProperties = properties.get( renderTarget ); + + state.bindFramebuffer( 36008, renderTargetProperties.__webglMultisampledFramebuffer ); + state.bindFramebuffer( 36009, renderTargetProperties.__webglFramebuffer ); + + if ( renderTarget.ignoreDepthForMultisampleCopy ) { + + _gl.invalidateFramebuffer( 36008, [ depthStyle ] ); + _gl.invalidateFramebuffer( 36009, [ depthStyle ] ); + + } + + _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 ); + _gl.invalidateFramebuffer( 36008, invalidationArray ); + + state.bindFramebuffer( 36008, null ); + state.bindFramebuffer( 36009, renderTargetProperties.__webglMultisampledFramebuffer ); + + } else { + + console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); + + } + + } + + } + + function getRenderTargetSamples( renderTarget ) { + + return ( isWebGL2 && ( renderTarget.useRenderbuffer || renderTarget.useRenderToTexture ) ) ? + Math.min( maxSamples, renderTarget.samples ) : 0; + + } + + function updateVideoTexture( texture ) { + + const frame = info.render.frame; + + // Check the last frame we updated the VideoTexture + + if ( _videoTextures.get( texture ) !== frame ) { + + _videoTextures.set( texture, frame ); + texture.update(); + + } + + } + + function verifyColorSpace( texture, image ) { + + const encoding = texture.encoding; + const format = texture.format; + const type = texture.type; + + if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image; + + if ( encoding !== LinearEncoding ) { + + // sRGB + + if ( encoding === sRGBEncoding && texture.isVideoTexture !== true ) { + + if ( isWebGL2 === false ) { + + // in WebGL 1, try to use EXT_sRGB extension and unsized formats + + if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) { + + texture.format = _SRGBAFormat; + + // it's not possible to generate mips in WebGL 1 with this extension + + texture.minFilter = LinearFilter; + texture.generateMipmaps = false; + + } else { + + // slow fallback (CPU decode) + + image = ImageUtils.sRGBToLinear( image ); + + } + + } else { + + // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format + + if ( format !== RGBAFormat || type !== UnsignedByteType ) { + + console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' ); + + } + + } + + } else { + + console.error( 'THREE.WebGLTextures: Unsupported texture encoding:', encoding ); + + } + + } + + return image; + + } + + // backwards compatibility + + let warnedTexture2D = false; + let warnedTextureCube = false; + + function safeSetTexture2D( texture, slot ) { + + if ( texture && texture.isWebGLRenderTarget ) { + + if ( warnedTexture2D === false ) { + + console.warn( 'THREE.WebGLTextures.safeSetTexture2D: don\'t use render targets as textures. Use their .texture property instead.' ); + warnedTexture2D = true; + + } + + texture = texture.texture; + + } + + setTexture2D( texture, slot ); + + } + + function safeSetTextureCube( texture, slot ) { + + if ( texture && texture.isWebGLCubeRenderTarget ) { + + if ( warnedTextureCube === false ) { + + console.warn( 'THREE.WebGLTextures.safeSetTextureCube: don\'t use cube render targets as textures. Use their .texture property instead.' ); + warnedTextureCube = true; + + } + + texture = texture.texture; + + } + + + setTextureCube( texture, slot ); + + } + + // + + this.allocateTextureUnit = allocateTextureUnit; + this.resetTextureUnits = resetTextureUnits; + + this.setTexture2D = setTexture2D; + this.setTexture2DArray = setTexture2DArray; + this.setTexture3D = setTexture3D; + this.setTextureCube = setTextureCube; + this.rebindTextures = rebindTextures; + this.setupRenderTarget = setupRenderTarget; + this.updateRenderTargetMipmap = updateRenderTargetMipmap; + this.updateMultisampleRenderTarget = updateMultisampleRenderTarget; + this.setupDepthRenderbuffer = setupDepthRenderbuffer; + this.setupFrameBufferTexture = setupFrameBufferTexture; + + this.safeSetTexture2D = safeSetTexture2D; + this.safeSetTextureCube = safeSetTextureCube; + +} + +function WebGLUtils( gl, extensions, capabilities ) { + + const isWebGL2 = capabilities.isWebGL2; + + function convert( p, encoding = null ) { + + let extension; + + if ( p === UnsignedByteType ) return 5121; + if ( p === UnsignedShort4444Type ) return 32819; + if ( p === UnsignedShort5551Type ) return 32820; + if ( p === UnsignedShort565Type ) return 33635; + + if ( p === ByteType ) return 5120; + if ( p === ShortType ) return 5122; + if ( p === UnsignedShortType ) return 5123; + if ( p === IntType ) return 5124; + if ( p === UnsignedIntType ) return 5125; + if ( p === FloatType ) return 5126; + + if ( p === HalfFloatType ) { + + if ( isWebGL2 ) return 5131; + + extension = extensions.get( 'OES_texture_half_float' ); + + if ( extension !== null ) { + + return extension.HALF_FLOAT_OES; + + } else { + + return null; + + } + + } + + if ( p === AlphaFormat ) return 6406; + if ( p === RGBAFormat ) return 6408; + if ( p === LuminanceFormat ) return 6409; + if ( p === LuminanceAlphaFormat ) return 6410; + if ( p === DepthFormat ) return 6402; + if ( p === DepthStencilFormat ) return 34041; + if ( p === RedFormat ) return 6403; + + // WebGL 1 sRGB fallback + + if ( p === _SRGBAFormat ) { + + extension = extensions.get( 'EXT_sRGB' ); + + if ( extension !== null ) { + + return extension.SRGB_ALPHA_EXT; + + } else { + + return null; + + } + + } + + // WebGL2 formats. + + if ( p === RedIntegerFormat ) return 36244; + if ( p === RGFormat ) return 33319; + if ( p === RGIntegerFormat ) return 33320; + if ( p === RGBIntegerFormat ) return 36248; + if ( p === RGBAIntegerFormat ) return 36249; + + // S3TC + + if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) { + + if ( encoding === sRGBEncoding ) { + + extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' ); + + if ( extension !== null ) { + + if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + + } else { + + return null; + + } + + } else { + + extension = extensions.get( 'WEBGL_compressed_texture_s3tc' ); + + if ( extension !== null ) { + + if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT; + + } else { + + return null; + + } + + } + + } + + // PVRTC + + if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + + if ( extension !== null ) { + + if ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + + } else { + + return null; + + } + + } + + // ETC1 + + if ( p === RGB_ETC1_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc1' ); + + if ( extension !== null ) { + + return extension.COMPRESSED_RGB_ETC1_WEBGL; + + } else { + + return null; + + } + + } + + // ETC2 + + if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc' ); + + if ( extension !== null ) { + + if ( p === RGB_ETC2_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2; + if ( p === RGBA_ETC2_EAC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC; + + } else { + + return null; + + } + + } + + // ASTC + + if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || + p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || + p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || + p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || + p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_astc' ); + + if ( extension !== null ) { + + if ( p === RGBA_ASTC_4x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR; + if ( p === RGBA_ASTC_5x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR; + if ( p === RGBA_ASTC_5x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR; + if ( p === RGBA_ASTC_6x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR; + if ( p === RGBA_ASTC_6x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR; + if ( p === RGBA_ASTC_8x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR; + if ( p === RGBA_ASTC_8x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR; + if ( p === RGBA_ASTC_8x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR; + if ( p === RGBA_ASTC_10x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR; + if ( p === RGBA_ASTC_10x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR; + if ( p === RGBA_ASTC_10x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR; + if ( p === RGBA_ASTC_10x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR; + if ( p === RGBA_ASTC_12x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR; + if ( p === RGBA_ASTC_12x12_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR; + + } else { + + return null; + + } + + } + + // BPTC + + if ( p === RGBA_BPTC_Format ) { + + extension = extensions.get( 'EXT_texture_compression_bptc' ); + + if ( extension !== null ) { + + if ( p === RGBA_BPTC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT; + + } else { + + return null; + + } + + } + + // + + if ( p === UnsignedInt248Type ) { + + if ( isWebGL2 ) return 34042; + + extension = extensions.get( 'WEBGL_depth_texture' ); + + if ( extension !== null ) { + + return extension.UNSIGNED_INT_24_8_WEBGL; + + } else { + + return null; + + } + + } + + } + + return { convert: convert }; + +} + +class ArrayCamera extends PerspectiveCamera { + + constructor( array = [] ) { + + super(); + + this.cameras = array; + + } + +} + +ArrayCamera.prototype.isArrayCamera = true; + +class Group extends Object3D { + + constructor() { + + super(); + + this.type = 'Group'; + + } + +} + +Group.prototype.isGroup = true; + +const _moveEvent = { type: 'move' }; + +class WebXRController { + + constructor() { + + this._targetRay = null; + this._grip = null; + this._hand = null; + + } + + getHandSpace() { + + if ( this._hand === null ) { + + this._hand = new Group(); + this._hand.matrixAutoUpdate = false; + this._hand.visible = false; + + this._hand.joints = {}; + this._hand.inputState = { pinching: false }; + + } + + return this._hand; + + } + + getTargetRaySpace() { + + if ( this._targetRay === null ) { + + this._targetRay = new Group(); + this._targetRay.matrixAutoUpdate = false; + this._targetRay.visible = false; + this._targetRay.hasLinearVelocity = false; + this._targetRay.linearVelocity = new Vector3(); + this._targetRay.hasAngularVelocity = false; + this._targetRay.angularVelocity = new Vector3(); + + } + + return this._targetRay; + + } + + getGripSpace() { + + if ( this._grip === null ) { + + this._grip = new Group(); + this._grip.matrixAutoUpdate = false; + this._grip.visible = false; + this._grip.hasLinearVelocity = false; + this._grip.linearVelocity = new Vector3(); + this._grip.hasAngularVelocity = false; + this._grip.angularVelocity = new Vector3(); + + } + + return this._grip; + + } + + dispatchEvent( event ) { + + if ( this._targetRay !== null ) { + + this._targetRay.dispatchEvent( event ); + + } + + if ( this._grip !== null ) { + + this._grip.dispatchEvent( event ); + + } + + if ( this._hand !== null ) { + + this._hand.dispatchEvent( event ); + + } + + return this; + + } + + disconnect( inputSource ) { + + this.dispatchEvent( { type: 'disconnected', data: inputSource } ); + + if ( this._targetRay !== null ) { + + this._targetRay.visible = false; + + } + + if ( this._grip !== null ) { + + this._grip.visible = false; + + } + + if ( this._hand !== null ) { + + this._hand.visible = false; + + } + + return this; + + } + + update( inputSource, frame, referenceSpace ) { + + let inputPose = null; + let gripPose = null; + let handPose = null; + + const targetRay = this._targetRay; + const grip = this._grip; + const hand = this._hand; + + if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) { + + if ( targetRay !== null ) { + + inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); + + if ( inputPose !== null ) { + + targetRay.matrix.fromArray( inputPose.transform.matrix ); + targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale ); + + if ( inputPose.linearVelocity ) { + + targetRay.hasLinearVelocity = true; + targetRay.linearVelocity.copy( inputPose.linearVelocity ); + + } else { + + targetRay.hasLinearVelocity = false; + + } + + if ( inputPose.angularVelocity ) { + + targetRay.hasAngularVelocity = true; + targetRay.angularVelocity.copy( inputPose.angularVelocity ); + + } else { + + targetRay.hasAngularVelocity = false; + + } + + this.dispatchEvent( _moveEvent ); + + } + + } + + if ( hand && inputSource.hand ) { + + handPose = true; + + for ( const inputjoint of inputSource.hand.values() ) { + + // Update the joints groups with the XRJoint poses + const jointPose = frame.getJointPose( inputjoint, referenceSpace ); + + if ( hand.joints[ inputjoint.jointName ] === undefined ) { + + // The transform of this joint will be updated with the joint pose on each frame + const joint = new Group(); + joint.matrixAutoUpdate = false; + joint.visible = false; + hand.joints[ inputjoint.jointName ] = joint; + // ?? + hand.add( joint ); + + } + + const joint = hand.joints[ inputjoint.jointName ]; + + if ( jointPose !== null ) { + + joint.matrix.fromArray( jointPose.transform.matrix ); + joint.matrix.decompose( joint.position, joint.rotation, joint.scale ); + joint.jointRadius = jointPose.radius; + + } + + joint.visible = jointPose !== null; + + } + + // Custom events + + // Check pinchz + const indexTip = hand.joints[ 'index-finger-tip' ]; + const thumbTip = hand.joints[ 'thumb-tip' ]; + const distance = indexTip.position.distanceTo( thumbTip.position ); + + const distanceToPinch = 0.02; + const threshold = 0.005; + + if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) { + + hand.inputState.pinching = false; + this.dispatchEvent( { + type: 'pinchend', + handedness: inputSource.handedness, + target: this + } ); + + } else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) { + + hand.inputState.pinching = true; + this.dispatchEvent( { + type: 'pinchstart', + handedness: inputSource.handedness, + target: this + } ); + + } + + } else { + + if ( grip !== null && inputSource.gripSpace ) { + + gripPose = frame.getPose( inputSource.gripSpace, referenceSpace ); + + if ( gripPose !== null ) { + + grip.matrix.fromArray( gripPose.transform.matrix ); + grip.matrix.decompose( grip.position, grip.rotation, grip.scale ); + + if ( gripPose.linearVelocity ) { + + grip.hasLinearVelocity = true; + grip.linearVelocity.copy( gripPose.linearVelocity ); + + } else { + + grip.hasLinearVelocity = false; + + } + + if ( gripPose.angularVelocity ) { + + grip.hasAngularVelocity = true; + grip.angularVelocity.copy( gripPose.angularVelocity ); + + } else { + + grip.hasAngularVelocity = false; + + } + + } + + } + + } + + } + + if ( targetRay !== null ) { + + targetRay.visible = ( inputPose !== null ); + + } + + if ( grip !== null ) { + + grip.visible = ( gripPose !== null ); + + } + + if ( hand !== null ) { + + hand.visible = ( handPose !== null ); + + } + + return this; + + } + +} + +class DepthTexture extends Texture { + + constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { + + format = format !== undefined ? format : DepthFormat; + + if ( format !== DepthFormat && format !== DepthStencilFormat ) { + + throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); + + } + + if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; + if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; + + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + + this.image = { width: width, height: height }; + + this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; + + this.flipY = false; + this.generateMipmaps = false; + + } + + +} + +DepthTexture.prototype.isDepthTexture = true; + +class WebXRManager extends EventDispatcher { + + constructor( renderer, gl ) { + + super(); + + const scope = this; + + let session = null; + let framebufferScaleFactor = 1.0; + + let referenceSpace = null; + let referenceSpaceType = 'local-floor'; + const hasMultisampledRenderToTexture = renderer.extensions.has( 'WEBGL_multisampled_render_to_texture' ); + + let pose = null; + let glBinding = null; + let glProjLayer = null; + let glBaseLayer = null; + let isMultisample = false; + let xrFrame = null; + const attributes = gl.getContextAttributes(); + let initialRenderTarget = null; + let newRenderTarget = null; + + const controllers = []; + const inputSourcesMap = new Map(); + + // + + const cameraL = new PerspectiveCamera(); + cameraL.layers.enable( 1 ); + cameraL.viewport = new Vector4(); + + const cameraR = new PerspectiveCamera(); + cameraR.layers.enable( 2 ); + cameraR.viewport = new Vector4(); + + const cameras = [ cameraL, cameraR ]; + + const cameraVR = new ArrayCamera(); + cameraVR.layers.enable( 1 ); + cameraVR.layers.enable( 2 ); + + let _currentDepthNear = null; + let _currentDepthFar = null; + + // + + this.cameraAutoUpdate = true; + this.enabled = false; + + this.isPresenting = false; + + this.getController = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getTargetRaySpace(); + + }; + + this.getControllerGrip = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getGripSpace(); + + }; + + this.getHand = function ( index ) { + + let controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getHandSpace(); + + }; + + // + + function onSessionEvent( event ) { + + const controller = inputSourcesMap.get( event.inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: event.type, data: event.inputSource } ); + + } + + } + + function onSessionEnd() { + + inputSourcesMap.forEach( function ( controller, inputSource ) { + + controller.disconnect( inputSource ); + + } ); + + inputSourcesMap.clear(); + + _currentDepthNear = null; + _currentDepthFar = null; + + // restore framebuffer/rendering state + + renderer.setRenderTarget( initialRenderTarget ); + + glBaseLayer = null; + glProjLayer = null; + glBinding = null; + session = null; + newRenderTarget = null; + + // + + animation.stop(); + + scope.isPresenting = false; + + scope.dispatchEvent( { type: 'sessionend' } ); + + } + + this.setFramebufferScaleFactor = function ( value ) { + + framebufferScaleFactor = value; + + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' ); + + } + + }; + + this.setReferenceSpaceType = function ( value ) { + + referenceSpaceType = value; + + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' ); + + } + + }; + + this.getReferenceSpace = function () { + + return referenceSpace; + + }; + + this.getBaseLayer = function () { + + return glProjLayer !== null ? glProjLayer : glBaseLayer; + + }; + + this.getBinding = function () { + + return glBinding; + + }; + + this.getFrame = function () { + + return xrFrame; + + }; + + this.getSession = function () { + + return session; + + }; + + this.setSession = async function ( value ) { + + session = value; + + if ( session !== null ) { + + initialRenderTarget = renderer.getRenderTarget(); + + session.addEventListener( 'select', onSessionEvent ); + session.addEventListener( 'selectstart', onSessionEvent ); + session.addEventListener( 'selectend', onSessionEvent ); + session.addEventListener( 'squeeze', onSessionEvent ); + session.addEventListener( 'squeezestart', onSessionEvent ); + session.addEventListener( 'squeezeend', onSessionEvent ); + session.addEventListener( 'end', onSessionEnd ); + session.addEventListener( 'inputsourceschange', onInputSourcesChange ); + + if ( attributes.xrCompatible !== true ) { + + await gl.makeXRCompatible(); + + } + + if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) { + + const layerInit = { + antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true, + alpha: attributes.alpha, + depth: attributes.depth, + stencil: attributes.stencil, + framebufferScaleFactor: framebufferScaleFactor + }; + + glBaseLayer = new XRWebGLLayer( session, gl, layerInit ); + + session.updateRenderState( { baseLayer: glBaseLayer } ); + + newRenderTarget = new WebGLRenderTarget( + glBaseLayer.framebufferWidth, + glBaseLayer.framebufferHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + encoding: renderer.outputEncoding + } + ); + + } else { + + isMultisample = attributes.antialias; + let depthFormat = null; + let depthType = null; + let glDepthFormat = null; + + if ( attributes.depth ) { + + glDepthFormat = attributes.stencil ? 35056 : 33190; + depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat; + depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType; + + } + + const projectionlayerInit = { + colorFormat: ( renderer.outputEncoding === sRGBEncoding ) ? 35907 : 32856, + depthFormat: glDepthFormat, + scaleFactor: framebufferScaleFactor + }; + + glBinding = new XRWebGLBinding( session, gl ); + + glProjLayer = glBinding.createProjectionLayer( projectionlayerInit ); + + session.updateRenderState( { layers: [ glProjLayer ] } ); + + if ( isMultisample ) { + + newRenderTarget = new WebGLMultisampleRenderTarget( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + useRenderToTexture: hasMultisampledRenderToTexture, + encoding: renderer.outputEncoding + } ); + + } else { + + newRenderTarget = new WebGLRenderTarget( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + encoding: renderer.outputEncoding + } ); + + } + + } + + // Set foveation to maximum. + this.setFoveation( 1.0 ); + + referenceSpace = await session.requestReferenceSpace( referenceSpaceType ); + + animation.setContext( session ); + animation.start(); + + scope.isPresenting = true; + + scope.dispatchEvent( { type: 'sessionstart' } ); + + } + + }; + + function onInputSourcesChange( event ) { + + const inputSources = session.inputSources; + + // Assign inputSources to available controllers + + for ( let i = 0; i < controllers.length; i ++ ) { + + inputSourcesMap.set( inputSources[ i ], controllers[ i ] ); + + } + + // Notify disconnected + + for ( let i = 0; i < event.removed.length; i ++ ) { + + const inputSource = event.removed[ i ]; + const controller = inputSourcesMap.get( inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: 'disconnected', data: inputSource } ); + inputSourcesMap.delete( inputSource ); + + } + + } + + // Notify connected + + for ( let i = 0; i < event.added.length; i ++ ) { + + const inputSource = event.added[ i ]; + const controller = inputSourcesMap.get( inputSource ); + + if ( controller ) { + + controller.dispatchEvent( { type: 'connected', data: inputSource } ); + + } + + } + + } + + // + + const cameraLPos = new Vector3(); + const cameraRPos = new Vector3(); + + /** + * Assumes 2 cameras that are parallel and share an X-axis, and that + * the cameras' projection and world matrices have already been set. + * And that near and far planes are identical for both cameras. + * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765 + */ + function setProjectionFromUnion( camera, cameraL, cameraR ) { + + cameraLPos.setFromMatrixPosition( cameraL.matrixWorld ); + cameraRPos.setFromMatrixPosition( cameraR.matrixWorld ); + + const ipd = cameraLPos.distanceTo( cameraRPos ); + + const projL = cameraL.projectionMatrix.elements; + const projR = cameraR.projectionMatrix.elements; + + // VR systems will have identical far and near planes, and + // most likely identical top and bottom frustum extents. + // Use the left camera for these values. + const near = projL[ 14 ] / ( projL[ 10 ] - 1 ); + const far = projL[ 14 ] / ( projL[ 10 ] + 1 ); + const topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ]; + const bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ]; + + const leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ]; + const rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ]; + const left = near * leftFov; + const right = near * rightFov; + + // Calculate the new camera's position offset from the + // left camera. xOffset should be roughly half `ipd`. + const zOffset = ipd / ( - leftFov + rightFov ); + const xOffset = zOffset * - leftFov; + + // TODO: Better way to apply this offset? + cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale ); + camera.translateX( xOffset ); + camera.translateZ( zOffset ); + camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale ); + camera.matrixWorldInverse.copy( camera.matrixWorld ).invert(); + + // Find the union of the frustum values of the cameras and scale + // the values so that the near plane's position does not change in world space, + // although must now be relative to the new union camera. + const near2 = near + zOffset; + const far2 = far + zOffset; + const left2 = left - xOffset; + const right2 = right + ( ipd - xOffset ); + const top2 = topFov * far / far2 * near2; + const bottom2 = bottomFov * far / far2 * near2; + + camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 ); + + } + + function updateCamera( camera, parent ) { + + if ( parent === null ) { + + camera.matrixWorld.copy( camera.matrix ); + + } else { + + camera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix ); + + } + + camera.matrixWorldInverse.copy( camera.matrixWorld ).invert(); + + } + + this.updateCamera = function ( camera ) { + + if ( session === null ) return; + + cameraVR.near = cameraR.near = cameraL.near = camera.near; + cameraVR.far = cameraR.far = cameraL.far = camera.far; + + if ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) { + + // Note that the new renderState won't apply until the next frame. See #18320 + + session.updateRenderState( { + depthNear: cameraVR.near, + depthFar: cameraVR.far + } ); + + _currentDepthNear = cameraVR.near; + _currentDepthFar = cameraVR.far; + + } + + const parent = camera.parent; + const cameras = cameraVR.cameras; + + updateCamera( cameraVR, parent ); + + for ( let i = 0; i < cameras.length; i ++ ) { + + updateCamera( cameras[ i ], parent ); + + } + + cameraVR.matrixWorld.decompose( cameraVR.position, cameraVR.quaternion, cameraVR.scale ); + + // update user camera and its children + + camera.position.copy( cameraVR.position ); + camera.quaternion.copy( cameraVR.quaternion ); + camera.scale.copy( cameraVR.scale ); + camera.matrix.copy( cameraVR.matrix ); + camera.matrixWorld.copy( cameraVR.matrixWorld ); + + const children = camera.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateMatrixWorld( true ); + + } + + // update projection matrix for proper view frustum culling + + if ( cameras.length === 2 ) { + + setProjectionFromUnion( cameraVR, cameraL, cameraR ); + + } else { + + // assume single camera setup (AR) + + cameraVR.projectionMatrix.copy( cameraL.projectionMatrix ); + + } + + }; + + this.getCamera = function () { + + return cameraVR; + + }; + + this.getFoveation = function () { + + if ( glProjLayer !== null ) { + + return glProjLayer.fixedFoveation; + + } + + if ( glBaseLayer !== null ) { + + return glBaseLayer.fixedFoveation; + + } + + return undefined; + + }; + + this.setFoveation = function ( foveation ) { + + // 0 = no foveation = full resolution + // 1 = maximum foveation = the edges render at lower resolution + + if ( glProjLayer !== null ) { + + glProjLayer.fixedFoveation = foveation; + + } + + if ( glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined ) { + + glBaseLayer.fixedFoveation = foveation; + + } + + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame( time, frame ) { + + pose = frame.getViewerPose( referenceSpace ); + xrFrame = frame; + + if ( pose !== null ) { + + const views = pose.views; + + if ( glBaseLayer !== null ) { + + renderer.setRenderTargetFramebuffer( newRenderTarget, glBaseLayer.framebuffer ); + renderer.setRenderTarget( newRenderTarget ); + + } + + let cameraVRNeedsUpdate = false; + + // check if it's necessary to rebuild cameraVR's camera list + + if ( views.length !== cameraVR.cameras.length ) { + + cameraVR.cameras.length = 0; + cameraVRNeedsUpdate = true; + + } + + for ( let i = 0; i < views.length; i ++ ) { + + const view = views[ i ]; + + let viewport = null; + + if ( glBaseLayer !== null ) { + + viewport = glBaseLayer.getViewport( view ); + + } else { + + const glSubImage = glBinding.getViewSubImage( glProjLayer, view ); + viewport = glSubImage.viewport; + + // For side-by-side projection, we only produce a single texture for both eyes. + if ( i === 0 ) { + + renderer.setRenderTargetTextures( + newRenderTarget, + glSubImage.colorTexture, + glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture ); + + renderer.setRenderTarget( newRenderTarget ); + + } + + } + + const camera = cameras[ i ]; + + camera.matrix.fromArray( view.transform.matrix ); + camera.projectionMatrix.fromArray( view.projectionMatrix ); + camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height ); + + if ( i === 0 ) { + + cameraVR.matrix.copy( camera.matrix ); + + } + + if ( cameraVRNeedsUpdate === true ) { + + cameraVR.cameras.push( camera ); + + } + + } + + } + + // + + const inputSources = session.inputSources; + + for ( let i = 0; i < controllers.length; i ++ ) { + + const controller = controllers[ i ]; + const inputSource = inputSources[ i ]; + + controller.update( inputSource, frame, referenceSpace ); + + } + + if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame ); + + xrFrame = null; + + } + + const animation = new WebGLAnimation(); + + animation.setAnimationLoop( onAnimationFrame ); + + this.setAnimationLoop = function ( callback ) { + + onAnimationFrameCallback = callback; + + }; + + this.dispose = function () {}; + + } + +} + +function WebGLMaterials( properties ) { + + function refreshFogUniforms( uniforms, fog ) { + + uniforms.fogColor.value.copy( fog.color ); + + if ( fog.isFog ) { + + uniforms.fogNear.value = fog.near; + uniforms.fogFar.value = fog.far; + + } else if ( fog.isFogExp2 ) { + + uniforms.fogDensity.value = fog.density; + + } + + } + + function refreshMaterialUniforms( uniforms, material, pixelRatio, height, transmissionRenderTarget ) { + + if ( material.isMeshBasicMaterial ) { + + refreshUniformsCommon( uniforms, material ); + + } else if ( material.isMeshLambertMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsLambert( uniforms, material ); + + } else if ( material.isMeshToonMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsToon( uniforms, material ); + + } else if ( material.isMeshPhongMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsPhong( uniforms, material ); + + } else if ( material.isMeshStandardMaterial ) { + + refreshUniformsCommon( uniforms, material ); + + if ( material.isMeshPhysicalMaterial ) { + + refreshUniformsPhysical( uniforms, material, transmissionRenderTarget ); + + } else { + + refreshUniformsStandard( uniforms, material ); + + } + + } else if ( material.isMeshMatcapMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsMatcap( uniforms, material ); + + } else if ( material.isMeshDepthMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsDepth( uniforms, material ); + + } else if ( material.isMeshDistanceMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsDistance( uniforms, material ); + + } else if ( material.isMeshNormalMaterial ) { + + refreshUniformsCommon( uniforms, material ); + refreshUniformsNormal( uniforms, material ); + + } else if ( material.isLineBasicMaterial ) { + + refreshUniformsLine( uniforms, material ); + + if ( material.isLineDashedMaterial ) { + + refreshUniformsDash( uniforms, material ); + + } + + } else if ( material.isPointsMaterial ) { + + refreshUniformsPoints( uniforms, material, pixelRatio, height ); + + } else if ( material.isSpriteMaterial ) { + + refreshUniformsSprites( uniforms, material ); + + } else if ( material.isShadowMaterial ) { + + uniforms.color.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + + } else if ( material.isShaderMaterial ) { + + material.uniformsNeedUpdate = false; // #15581 + + } + + } + + function refreshUniformsCommon( uniforms, material ) { + + uniforms.opacity.value = material.opacity; + + if ( material.color ) { + + uniforms.diffuse.value.copy( material.color ); + + } + + if ( material.emissive ) { + + uniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity ); + + } + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.specularMap ) { + + uniforms.specularMap.value = material.specularMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + const envMap = properties.get( material ).envMap; + + if ( envMap ) { + + uniforms.envMap.value = envMap; + + uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1; + + uniforms.reflectivity.value = material.reflectivity; + uniforms.ior.value = material.ior; + uniforms.refractionRatio.value = material.refractionRatio; + + } + + if ( material.lightMap ) { + + uniforms.lightMap.value = material.lightMap; + uniforms.lightMapIntensity.value = material.lightMapIntensity; + + } + + if ( material.aoMap ) { + + uniforms.aoMap.value = material.aoMap; + uniforms.aoMapIntensity.value = material.aoMapIntensity; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. specular map + // 3. displacementMap map + // 4. normal map + // 5. bump map + // 6. roughnessMap map + // 7. metalnessMap map + // 8. alphaMap map + // 9. emissiveMap map + // 10. clearcoat map + // 11. clearcoat normal map + // 12. clearcoat roughnessMap map + // 13. specular intensity map + // 14. specular tint map + // 15. transmission map + // 16. thickness map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.specularMap ) { + + uvScaleMap = material.specularMap; + + } else if ( material.displacementMap ) { + + uvScaleMap = material.displacementMap; + + } else if ( material.normalMap ) { + + uvScaleMap = material.normalMap; + + } else if ( material.bumpMap ) { + + uvScaleMap = material.bumpMap; + + } else if ( material.roughnessMap ) { + + uvScaleMap = material.roughnessMap; + + } else if ( material.metalnessMap ) { + + uvScaleMap = material.metalnessMap; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } else if ( material.emissiveMap ) { + + uvScaleMap = material.emissiveMap; + + } else if ( material.clearcoatMap ) { + + uvScaleMap = material.clearcoatMap; + + } else if ( material.clearcoatNormalMap ) { + + uvScaleMap = material.clearcoatNormalMap; + + } else if ( material.clearcoatRoughnessMap ) { + + uvScaleMap = material.clearcoatRoughnessMap; + + } else if ( material.specularIntensityMap ) { + + uvScaleMap = material.specularIntensityMap; + + } else if ( material.specularColorMap ) { + + uvScaleMap = material.specularColorMap; + + } else if ( material.transmissionMap ) { + + uvScaleMap = material.transmissionMap; + + } else if ( material.thicknessMap ) { + + uvScaleMap = material.thicknessMap; + + } else if ( material.sheenColorMap ) { + + uvScaleMap = material.sheenColorMap; + + } else if ( material.sheenRoughnessMap ) { + + uvScaleMap = material.sheenRoughnessMap; + + } + + if ( uvScaleMap !== undefined ) { + + // backwards compatibility + if ( uvScaleMap.isWebGLRenderTarget ) { + + uvScaleMap = uvScaleMap.texture; + + } + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + // uv repeat and offset setting priorities for uv2 + // 1. ao map + // 2. light map + + let uv2ScaleMap; + + if ( material.aoMap ) { + + uv2ScaleMap = material.aoMap; + + } else if ( material.lightMap ) { + + uv2ScaleMap = material.lightMap; + + } + + if ( uv2ScaleMap !== undefined ) { + + // backwards compatibility + if ( uv2ScaleMap.isWebGLRenderTarget ) { + + uv2ScaleMap = uv2ScaleMap.texture; + + } + + if ( uv2ScaleMap.matrixAutoUpdate === true ) { + + uv2ScaleMap.updateMatrix(); + + } + + uniforms.uv2Transform.value.copy( uv2ScaleMap.matrix ); + + } + + } + + function refreshUniformsLine( uniforms, material ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + + } + + function refreshUniformsDash( uniforms, material ) { + + uniforms.dashSize.value = material.dashSize; + uniforms.totalSize.value = material.dashSize + material.gapSize; + uniforms.scale.value = material.scale; + + } + + function refreshUniformsPoints( uniforms, material, pixelRatio, height ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + uniforms.size.value = material.size * pixelRatio; + uniforms.scale.value = height * 0.5; + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } + + if ( uvScaleMap !== undefined ) { + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + } + + function refreshUniformsSprites( uniforms, material ) { + + uniforms.diffuse.value.copy( material.color ); + uniforms.opacity.value = material.opacity; + uniforms.rotation.value = material.rotation; + + if ( material.map ) { + + uniforms.map.value = material.map; + + } + + if ( material.alphaMap ) { + + uniforms.alphaMap.value = material.alphaMap; + + } + + if ( material.alphaTest > 0 ) { + + uniforms.alphaTest.value = material.alphaTest; + + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } + + if ( uvScaleMap !== undefined ) { + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + } + + function refreshUniformsLambert( uniforms, material ) { + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + } + + function refreshUniformsPhong( uniforms, material ) { + + uniforms.specular.value.copy( material.specular ); + uniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 ) + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsToon( uniforms, material ) { + + if ( material.gradientMap ) { + + uniforms.gradientMap.value = material.gradientMap; + + } + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsStandard( uniforms, material ) { + + uniforms.roughness.value = material.roughness; + uniforms.metalness.value = material.metalness; + + if ( material.roughnessMap ) { + + uniforms.roughnessMap.value = material.roughnessMap; + + } + + if ( material.metalnessMap ) { + + uniforms.metalnessMap.value = material.metalnessMap; + + } + + if ( material.emissiveMap ) { + + uniforms.emissiveMap.value = material.emissiveMap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + const envMap = properties.get( material ).envMap; + + if ( envMap ) { + + //uniforms.envMap.value = material.envMap; // part of uniforms common + uniforms.envMapIntensity.value = material.envMapIntensity; + + } + + } + + function refreshUniformsPhysical( uniforms, material, transmissionRenderTarget ) { + + refreshUniformsStandard( uniforms, material ); + + uniforms.ior.value = material.ior; // also part of uniforms common + + if ( material.sheen > 0 ) { + + uniforms.sheenColor.value.copy( material.sheenColor ).multiplyScalar( material.sheen ); + + uniforms.sheenRoughness.value = material.sheenRoughness; + + if ( material.sheenColorMap ) { + + uniforms.sheenColorMap.value = material.sheenColorMap; + + } + + if ( material.sheenRoughnessMap ) { + + uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap; + + } + + } + + if ( material.clearcoat > 0 ) { + + uniforms.clearcoat.value = material.clearcoat; + uniforms.clearcoatRoughness.value = material.clearcoatRoughness; + + if ( material.clearcoatMap ) { + + uniforms.clearcoatMap.value = material.clearcoatMap; + + } + + if ( material.clearcoatRoughnessMap ) { + + uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap; + + } + + if ( material.clearcoatNormalMap ) { + + uniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale ); + uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap; + + if ( material.side === BackSide ) { + + uniforms.clearcoatNormalScale.value.negate(); + + } + + } + + } + + if ( material.transmission > 0 ) { + + uniforms.transmission.value = material.transmission; + uniforms.transmissionSamplerMap.value = transmissionRenderTarget.texture; + uniforms.transmissionSamplerSize.value.set( transmissionRenderTarget.width, transmissionRenderTarget.height ); + + if ( material.transmissionMap ) { + + uniforms.transmissionMap.value = material.transmissionMap; + + } + + uniforms.thickness.value = material.thickness; + + if ( material.thicknessMap ) { + + uniforms.thicknessMap.value = material.thicknessMap; + + } + + uniforms.attenuationDistance.value = material.attenuationDistance; + uniforms.attenuationColor.value.copy( material.attenuationColor ); + + } + + uniforms.specularIntensity.value = material.specularIntensity; + uniforms.specularColor.value.copy( material.specularColor ); + + if ( material.specularIntensityMap ) { + + uniforms.specularIntensityMap.value = material.specularIntensityMap; + + } + + if ( material.specularColorMap ) { + + uniforms.specularColorMap.value = material.specularColorMap; + + } + + } + + function refreshUniformsMatcap( uniforms, material ) { + + if ( material.matcap ) { + + uniforms.matcap.value = material.matcap; + + } + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsDepth( uniforms, material ) { + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + function refreshUniformsDistance( uniforms, material ) { + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + uniforms.referencePosition.value.copy( material.referencePosition ); + uniforms.nearDistance.value = material.nearDistance; + uniforms.farDistance.value = material.farDistance; + + } + + function refreshUniformsNormal( uniforms, material ) { + + if ( material.bumpMap ) { + + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1; + + } + + if ( material.normalMap ) { + + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy( material.normalScale ); + if ( material.side === BackSide ) uniforms.normalScale.value.negate(); + + } + + if ( material.displacementMap ) { + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + } + + } + + return { + refreshFogUniforms: refreshFogUniforms, + refreshMaterialUniforms: refreshMaterialUniforms + }; + +} + +function createCanvasElement() { + + const canvas = createElementNS( 'canvas' ); + canvas.style.display = 'block'; + return canvas; + +} + +function WebGLRenderer( parameters = {} ) { + + const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(), + _context = parameters.context !== undefined ? parameters.context : null, + + _alpha = parameters.alpha !== undefined ? parameters.alpha : false, + _depth = parameters.depth !== undefined ? parameters.depth : true, + _stencil = parameters.stencil !== undefined ? parameters.stencil : true, + _antialias = parameters.antialias !== undefined ? parameters.antialias : false, + _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, + _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false, + _powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default', + _failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false; + + let currentRenderList = null; + let currentRenderState = null; + + // render() can be called from within a callback triggered by another render. + // We track this so that the nested render call gets its list and state isolated from the parent render call. + + const renderListStack = []; + const renderStateStack = []; + + // public properties + + this.domElement = _canvas; + + // Debug configuration container + this.debug = { + + /** + * Enables error checking and reporting when shader programs are being compiled + * @type {boolean} + */ + checkShaderErrors: true + }; + + // clearing + + this.autoClear = true; + this.autoClearColor = true; + this.autoClearDepth = true; + this.autoClearStencil = true; + + // scene graph + + this.sortObjects = true; + + // user-defined clipping + + this.clippingPlanes = []; + this.localClippingEnabled = false; + + // physically based shading + + this.outputEncoding = LinearEncoding; + + // physical lights + + this.physicallyCorrectLights = false; + + // tone mapping + + this.toneMapping = NoToneMapping; + this.toneMappingExposure = 1.0; + + // internal properties + + const _this = this; + + let _isContextLost = false; + + // internal state cache + + let _currentActiveCubeFace = 0; + let _currentActiveMipmapLevel = 0; + let _currentRenderTarget = null; + let _currentMaterialId = - 1; + + let _currentCamera = null; + + const _currentViewport = new Vector4(); + const _currentScissor = new Vector4(); + let _currentScissorTest = null; + + // + + let _width = _canvas.width; + let _height = _canvas.height; + + let _pixelRatio = 1; + let _opaqueSort = null; + let _transparentSort = null; + + const _viewport = new Vector4( 0, 0, _width, _height ); + const _scissor = new Vector4( 0, 0, _width, _height ); + let _scissorTest = false; + + // frustum + + const _frustum = new Frustum(); + + // clipping + + let _clippingEnabled = false; + let _localClippingEnabled = false; + + // transmission + + let _transmissionRenderTarget = null; + + // camera matrices cache + + const _projScreenMatrix = new Matrix4(); + + const _vector3 = new Vector3(); + + const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true }; + + function getTargetPixelRatio() { + + return _currentRenderTarget === null ? _pixelRatio : 1; + + } + + // initialize + + let _gl = _context; + + function getContext( contextNames, contextAttributes ) { + + for ( let i = 0; i < contextNames.length; i ++ ) { + + const contextName = contextNames[ i ]; + const context = _canvas.getContext( contextName, contextAttributes ); + if ( context !== null ) return context; + + } + + return null; + + } + + try { + + const contextAttributes = { + alpha: true, + depth: _depth, + stencil: _stencil, + antialias: _antialias, + premultipliedAlpha: _premultipliedAlpha, + preserveDrawingBuffer: _preserveDrawingBuffer, + powerPreference: _powerPreference, + failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat + }; + + // OffscreenCanvas does not have setAttribute, see #22811 + if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` ); + + // event listeners must be registered before WebGL context is created, see #12753 + _canvas.addEventListener( 'webglcontextlost', onContextLost, false ); + _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false ); + + if ( _gl === null ) { + + const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ]; + + if ( _this.isWebGL1Renderer === true ) { + + contextNames.shift(); + + } + + _gl = getContext( contextNames, contextAttributes ); + + if ( _gl === null ) { + + if ( getContext( contextNames ) ) { + + throw new Error( 'Error creating WebGL context with your selected attributes.' ); + + } else { + + throw new Error( 'Error creating WebGL context.' ); + + } + + } + + } + + // Some experimental-webgl implementations do not have getShaderPrecisionFormat + + if ( _gl.getShaderPrecisionFormat === undefined ) { + + _gl.getShaderPrecisionFormat = function () { + + return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 }; + + }; + + } + + } catch ( error ) { + + console.error( 'THREE.WebGLRenderer: ' + error.message ); + throw error; + + } + + let extensions, capabilities, state, info; + let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects; + let programCache, materials, renderLists, renderStates, clipping, shadowMap; + + let background, morphtargets, bufferRenderer, indexedBufferRenderer; + + let utils, bindingStates; + + function initGLContext() { + + extensions = new WebGLExtensions( _gl ); + + capabilities = new WebGLCapabilities( _gl, extensions, parameters ); + + extensions.init( capabilities ); + + utils = new WebGLUtils( _gl, extensions, capabilities ); + + state = new WebGLState( _gl, extensions, capabilities ); + + info = new WebGLInfo( _gl ); + properties = new WebGLProperties(); + textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ); + cubemaps = new WebGLCubeMaps( _this ); + cubeuvmaps = new WebGLCubeUVMaps( _this ); + attributes = new WebGLAttributes( _gl, capabilities ); + bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities ); + geometries = new WebGLGeometries( _gl, attributes, info, bindingStates ); + objects = new WebGLObjects( _gl, geometries, attributes, info ); + morphtargets = new WebGLMorphtargets( _gl, capabilities, textures ); + clipping = new WebGLClipping( properties ); + programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ); + materials = new WebGLMaterials( properties ); + renderLists = new WebGLRenderLists(); + renderStates = new WebGLRenderStates( extensions, capabilities ); + background = new WebGLBackground( _this, cubemaps, state, objects, _alpha, _premultipliedAlpha ); + shadowMap = new WebGLShadowMap( _this, objects, capabilities ); + + bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities ); + indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities ); + + info.programs = programCache.programs; + + _this.capabilities = capabilities; + _this.extensions = extensions; + _this.properties = properties; + _this.renderLists = renderLists; + _this.shadowMap = shadowMap; + _this.state = state; + _this.info = info; + + } + + initGLContext(); + + // xr + + const xr = new WebXRManager( _this, _gl ); + + this.xr = xr; + + // API + + this.getContext = function () { + + return _gl; + + }; + + this.getContextAttributes = function () { + + return _gl.getContextAttributes(); + + }; + + this.forceContextLoss = function () { + + const extension = extensions.get( 'WEBGL_lose_context' ); + if ( extension ) extension.loseContext(); + + }; + + this.forceContextRestore = function () { + + const extension = extensions.get( 'WEBGL_lose_context' ); + if ( extension ) extension.restoreContext(); + + }; + + this.getPixelRatio = function () { + + return _pixelRatio; + + }; + + this.setPixelRatio = function ( value ) { + + if ( value === undefined ) return; + + _pixelRatio = value; + + this.setSize( _width, _height, false ); + + }; + + this.getSize = function ( target ) { + + return target.set( _width, _height ); + + }; + + this.setSize = function ( width, height, updateStyle ) { + + if ( xr.isPresenting ) { + + console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' ); + return; + + } + + _width = width; + _height = height; + + _canvas.width = Math.floor( width * _pixelRatio ); + _canvas.height = Math.floor( height * _pixelRatio ); + + if ( updateStyle !== false ) { + + _canvas.style.width = width + 'px'; + _canvas.style.height = height + 'px'; + + } + + this.setViewport( 0, 0, width, height ); + + }; + + this.getDrawingBufferSize = function ( target ) { + + return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor(); + + }; + + this.setDrawingBufferSize = function ( width, height, pixelRatio ) { + + _width = width; + _height = height; + + _pixelRatio = pixelRatio; + + _canvas.width = Math.floor( width * pixelRatio ); + _canvas.height = Math.floor( height * pixelRatio ); + + this.setViewport( 0, 0, width, height ); + + }; + + this.getCurrentViewport = function ( target ) { + + return target.copy( _currentViewport ); + + }; + + this.getViewport = function ( target ) { + + return target.copy( _viewport ); + + }; + + this.setViewport = function ( x, y, width, height ) { + + if ( x.isVector4 ) { + + _viewport.set( x.x, x.y, x.z, x.w ); + + } else { + + _viewport.set( x, y, width, height ); + + } + + state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() ); + + }; + + this.getScissor = function ( target ) { + + return target.copy( _scissor ); + + }; + + this.setScissor = function ( x, y, width, height ) { + + if ( x.isVector4 ) { + + _scissor.set( x.x, x.y, x.z, x.w ); + + } else { + + _scissor.set( x, y, width, height ); + + } + + state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() ); + + }; + + this.getScissorTest = function () { + + return _scissorTest; + + }; + + this.setScissorTest = function ( boolean ) { + + state.setScissorTest( _scissorTest = boolean ); + + }; + + this.setOpaqueSort = function ( method ) { + + _opaqueSort = method; + + }; + + this.setTransparentSort = function ( method ) { + + _transparentSort = method; + + }; + + // Clearing + + this.getClearColor = function ( target ) { + + return target.copy( background.getClearColor() ); + + }; + + this.setClearColor = function () { + + background.setClearColor.apply( background, arguments ); + + }; + + this.getClearAlpha = function () { + + return background.getClearAlpha(); + + }; + + this.setClearAlpha = function () { + + background.setClearAlpha.apply( background, arguments ); + + }; + + this.clear = function ( color, depth, stencil ) { + + let bits = 0; + + if ( color === undefined || color ) bits |= 16384; + if ( depth === undefined || depth ) bits |= 256; + if ( stencil === undefined || stencil ) bits |= 1024; + + _gl.clear( bits ); + + }; + + this.clearColor = function () { + + this.clear( true, false, false ); + + }; + + this.clearDepth = function () { + + this.clear( false, true, false ); + + }; + + this.clearStencil = function () { + + this.clear( false, false, true ); + + }; + + // + + this.dispose = function () { + + _canvas.removeEventListener( 'webglcontextlost', onContextLost, false ); + _canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false ); + + renderLists.dispose(); + renderStates.dispose(); + properties.dispose(); + cubemaps.dispose(); + cubeuvmaps.dispose(); + objects.dispose(); + bindingStates.dispose(); + programCache.dispose(); + + xr.dispose(); + + xr.removeEventListener( 'sessionstart', onXRSessionStart ); + xr.removeEventListener( 'sessionend', onXRSessionEnd ); + + if ( _transmissionRenderTarget ) { + + _transmissionRenderTarget.dispose(); + _transmissionRenderTarget = null; + + } + + animation.stop(); + + }; + + // Events + + function onContextLost( event ) { + + event.preventDefault(); + + console.log( 'THREE.WebGLRenderer: Context Lost.' ); + + _isContextLost = true; + + } + + function onContextRestore( /* event */ ) { + + console.log( 'THREE.WebGLRenderer: Context Restored.' ); + + _isContextLost = false; + + const infoAutoReset = info.autoReset; + const shadowMapEnabled = shadowMap.enabled; + const shadowMapAutoUpdate = shadowMap.autoUpdate; + const shadowMapNeedsUpdate = shadowMap.needsUpdate; + const shadowMapType = shadowMap.type; + + initGLContext(); + + info.autoReset = infoAutoReset; + shadowMap.enabled = shadowMapEnabled; + shadowMap.autoUpdate = shadowMapAutoUpdate; + shadowMap.needsUpdate = shadowMapNeedsUpdate; + shadowMap.type = shadowMapType; + + } + + function onMaterialDispose( event ) { + + const material = event.target; + + material.removeEventListener( 'dispose', onMaterialDispose ); + + deallocateMaterial( material ); + + } + + // Buffer deallocation + + function deallocateMaterial( material ) { + + releaseMaterialProgramReferences( material ); + + properties.remove( material ); + + } + + + function releaseMaterialProgramReferences( material ) { + + const programs = properties.get( material ).programs; + + if ( programs !== undefined ) { + + programs.forEach( function ( program ) { + + programCache.releaseProgram( program ); + + } ); + + if ( material.isShaderMaterial ) { + + programCache.releaseShaderCache( material ); + + } + + } + + } + + // Buffer rendering + + this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) { + + if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null) + + const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 ); + + const program = setProgram( camera, scene, geometry, material, object ); + + state.setMaterial( material, frontFaceCW ); + + // + + let index = geometry.index; + const position = geometry.attributes.position; + + // + + if ( index === null ) { + + if ( position === undefined || position.count === 0 ) return; + + } else if ( index.count === 0 ) { + + return; + + } + + // + + let rangeFactor = 1; + + if ( material.wireframe === true ) { + + index = geometries.getWireframeAttribute( geometry ); + rangeFactor = 2; + + } + + bindingStates.setup( object, material, program, geometry, index ); + + let attribute; + let renderer = bufferRenderer; + + if ( index !== null ) { + + attribute = attributes.get( index ); + + renderer = indexedBufferRenderer; + renderer.setIndex( attribute ); + + } + + // + + const dataCount = ( index !== null ) ? index.count : position.count; + + const rangeStart = geometry.drawRange.start * rangeFactor; + const rangeCount = geometry.drawRange.count * rangeFactor; + + const groupStart = group !== null ? group.start * rangeFactor : 0; + const groupCount = group !== null ? group.count * rangeFactor : Infinity; + + const drawStart = Math.max( rangeStart, groupStart ); + const drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1; + + const drawCount = Math.max( 0, drawEnd - drawStart + 1 ); + + if ( drawCount === 0 ) return; + + // + + if ( object.isMesh ) { + + if ( material.wireframe === true ) { + + state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() ); + renderer.setMode( 1 ); + + } else { + + renderer.setMode( 4 ); + + } + + } else if ( object.isLine ) { + + let lineWidth = material.linewidth; + + if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material + + state.setLineWidth( lineWidth * getTargetPixelRatio() ); + + if ( object.isLineSegments ) { + + renderer.setMode( 1 ); + + } else if ( object.isLineLoop ) { + + renderer.setMode( 2 ); + + } else { + + renderer.setMode( 3 ); + + } + + } else if ( object.isPoints ) { + + renderer.setMode( 0 ); + + } else if ( object.isSprite ) { + + renderer.setMode( 4 ); + + } + + if ( object.isInstancedMesh ) { + + renderer.renderInstances( drawStart, drawCount, object.count ); + + } else if ( geometry.isInstancedBufferGeometry ) { + + const instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount ); + + renderer.renderInstances( drawStart, drawCount, instanceCount ); + + } else { + + renderer.render( drawStart, drawCount ); + + } + + }; + + // Compile + + this.compile = function ( scene, camera ) { + + currentRenderState = renderStates.get( scene ); + currentRenderState.init(); + + renderStateStack.push( currentRenderState ); + + scene.traverseVisible( function ( object ) { + + if ( object.isLight && object.layers.test( camera.layers ) ) { + + currentRenderState.pushLight( object ); + + if ( object.castShadow ) { + + currentRenderState.pushShadow( object ); + + } + + } + + } ); + + currentRenderState.setupLights( _this.physicallyCorrectLights ); + + scene.traverse( function ( object ) { + + const material = object.material; + + if ( material ) { + + if ( Array.isArray( material ) ) { + + for ( let i = 0; i < material.length; i ++ ) { + + const material2 = material[ i ]; + + getProgram( material2, scene, object ); + + } + + } else { + + getProgram( material, scene, object ); + + } + + } + + } ); + + renderStateStack.pop(); + currentRenderState = null; + + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame( time ) { + + if ( onAnimationFrameCallback ) onAnimationFrameCallback( time ); + + } + + function onXRSessionStart() { + + animation.stop(); + + } + + function onXRSessionEnd() { + + animation.start(); + + } + + const animation = new WebGLAnimation(); + animation.setAnimationLoop( onAnimationFrame ); + + if ( typeof window !== 'undefined' ) animation.setContext( window ); + + this.setAnimationLoop = function ( callback ) { + + onAnimationFrameCallback = callback; + xr.setAnimationLoop( callback ); + + ( callback === null ) ? animation.stop() : animation.start(); + + }; + + xr.addEventListener( 'sessionstart', onXRSessionStart ); + xr.addEventListener( 'sessionend', onXRSessionEnd ); + + // Rendering + + this.render = function ( scene, camera ) { + + if ( camera !== undefined && camera.isCamera !== true ) { + + console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' ); + return; + + } + + if ( _isContextLost === true ) return; + + // update scene graph + + if ( scene.autoUpdate === true ) scene.updateMatrixWorld(); + + // update camera matrices and frustum + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + if ( xr.enabled === true && xr.isPresenting === true ) { + + if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera ); + + camera = xr.getCamera(); // use XR camera for rendering + + } + + // + if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget ); + + currentRenderState = renderStates.get( scene, renderStateStack.length ); + currentRenderState.init(); + + renderStateStack.push( currentRenderState ); + + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); + _frustum.setFromProjectionMatrix( _projScreenMatrix ); + + _localClippingEnabled = this.localClippingEnabled; + _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled, camera ); + + currentRenderList = renderLists.get( scene, renderListStack.length ); + currentRenderList.init(); + + renderListStack.push( currentRenderList ); + + projectObject( scene, camera, 0, _this.sortObjects ); + + currentRenderList.finish(); + + if ( _this.sortObjects === true ) { + + currentRenderList.sort( _opaqueSort, _transparentSort ); + + } + + // + + if ( _clippingEnabled === true ) clipping.beginShadows(); + + const shadowsArray = currentRenderState.state.shadowsArray; + + shadowMap.render( shadowsArray, scene, camera ); + + if ( _clippingEnabled === true ) clipping.endShadows(); + + // + + if ( this.info.autoReset === true ) this.info.reset(); + + // + + background.render( currentRenderList, scene ); + + // render scene + + currentRenderState.setupLights( _this.physicallyCorrectLights ); + + if ( camera.isArrayCamera ) { + + const cameras = camera.cameras; + + for ( let i = 0, l = cameras.length; i < l; i ++ ) { + + const camera2 = cameras[ i ]; + + renderScene( currentRenderList, scene, camera2, camera2.viewport ); + + } + + } else { + + renderScene( currentRenderList, scene, camera ); + + } + + // + + if ( _currentRenderTarget !== null ) { + + // resolve multisample renderbuffers to a single-sample texture if necessary + + textures.updateMultisampleRenderTarget( _currentRenderTarget ); + + // Generate mipmap if we're using any kind of mipmap filtering + + textures.updateRenderTargetMipmap( _currentRenderTarget ); + + } + + // + + if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera ); + + // Ensure depth buffer writing is enabled so it can be cleared on next render + + state.buffers.depth.setTest( true ); + state.buffers.depth.setMask( true ); + state.buffers.color.setMask( true ); + + state.setPolygonOffset( false ); + + // _gl.finish(); + + bindingStates.resetDefaultState(); + _currentMaterialId = - 1; + _currentCamera = null; + + renderStateStack.pop(); + + if ( renderStateStack.length > 0 ) { + + currentRenderState = renderStateStack[ renderStateStack.length - 1 ]; + + } else { + + currentRenderState = null; + + } + + renderListStack.pop(); + + if ( renderListStack.length > 0 ) { + + currentRenderList = renderListStack[ renderListStack.length - 1 ]; + + } else { + + currentRenderList = null; + + } + + }; + + function projectObject( object, camera, groupOrder, sortObjects ) { + + if ( object.visible === false ) return; + + const visible = object.layers.test( camera.layers ); + + if ( visible ) { + + if ( object.isGroup ) { + + groupOrder = object.renderOrder; + + } else if ( object.isLOD ) { + + if ( object.autoUpdate === true ) object.update( camera ); + + } else if ( object.isLight ) { + + currentRenderState.pushLight( object ); + + if ( object.castShadow ) { + + currentRenderState.pushShadow( object ); + + } + + } else if ( object.isSprite ) { + + if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) { + + if ( sortObjects ) { + + _vector3.setFromMatrixPosition( object.matrixWorld ) + .applyMatrix4( _projScreenMatrix ); + + } + + const geometry = objects.update( object ); + const material = object.material; + + if ( material.visible ) { + + currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null ); + + } + + } + + } else if ( object.isMesh || object.isLine || object.isPoints ) { + + if ( object.isSkinnedMesh ) { + + // update skeleton only once in a frame + + if ( object.skeleton.frame !== info.render.frame ) { + + object.skeleton.update(); + object.skeleton.frame = info.render.frame; + + } + + } + + if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) { + + if ( sortObjects ) { + + _vector3.setFromMatrixPosition( object.matrixWorld ) + .applyMatrix4( _projScreenMatrix ); + + } + + const geometry = objects.update( object ); + const material = object.material; + + if ( Array.isArray( material ) ) { + + const groups = geometry.groups; + + for ( let i = 0, l = groups.length; i < l; i ++ ) { + + const group = groups[ i ]; + const groupMaterial = material[ group.materialIndex ]; + + if ( groupMaterial && groupMaterial.visible ) { + + currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group ); + + } + + } + + } else if ( material.visible ) { + + currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null ); + + } + + } + + } + + } + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + projectObject( children[ i ], camera, groupOrder, sortObjects ); + + } + + } + + function renderScene( currentRenderList, scene, camera, viewport ) { + + const opaqueObjects = currentRenderList.opaque; + const transmissiveObjects = currentRenderList.transmissive; + const transparentObjects = currentRenderList.transparent; + + currentRenderState.setupLightsView( camera ); + + if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, scene, camera ); + + if ( viewport ) state.viewport( _currentViewport.copy( viewport ) ); + + if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera ); + if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera ); + if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera ); + + } + + function renderTransmissionPass( opaqueObjects, scene, camera ) { + + if ( _transmissionRenderTarget === null ) { + + const needsAntialias = _antialias === true && capabilities.isWebGL2 === true; + const renderTargetType = needsAntialias ? WebGLMultisampleRenderTarget : WebGLRenderTarget; + + _transmissionRenderTarget = new renderTargetType( 1024, 1024, { + generateMipmaps: true, + type: utils.convert( HalfFloatType ) !== null ? HalfFloatType : UnsignedByteType, + minFilter: LinearMipmapLinearFilter, + magFilter: NearestFilter, + wrapS: ClampToEdgeWrapping, + wrapT: ClampToEdgeWrapping, + useRenderToTexture: extensions.has( 'WEBGL_multisampled_render_to_texture' ) + } ); + + } + + const currentRenderTarget = _this.getRenderTarget(); + _this.setRenderTarget( _transmissionRenderTarget ); + _this.clear(); + + // Turn off the features which can affect the frag color for opaque objects pass. + // Otherwise they are applied twice in opaque objects pass and transmission objects pass. + const currentToneMapping = _this.toneMapping; + _this.toneMapping = NoToneMapping; + + renderObjects( opaqueObjects, scene, camera ); + + _this.toneMapping = currentToneMapping; + + textures.updateMultisampleRenderTarget( _transmissionRenderTarget ); + textures.updateRenderTargetMipmap( _transmissionRenderTarget ); + + _this.setRenderTarget( currentRenderTarget ); + + } + + function renderObjects( renderList, scene, camera ) { + + const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null; + + for ( let i = 0, l = renderList.length; i < l; i ++ ) { + + const renderItem = renderList[ i ]; + + const object = renderItem.object; + const geometry = renderItem.geometry; + const material = overrideMaterial === null ? renderItem.material : overrideMaterial; + const group = renderItem.group; + + if ( object.layers.test( camera.layers ) ) { + + renderObject( object, scene, camera, geometry, material, group ); + + } + + } + + } + + function renderObject( object, scene, camera, geometry, material, group ) { + + object.onBeforeRender( _this, scene, camera, geometry, material, group ); + + object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld ); + object.normalMatrix.getNormalMatrix( object.modelViewMatrix ); + + material.onBeforeRender( _this, scene, camera, geometry, object, group ); + + if ( material.transparent === true && material.side === DoubleSide ) { + + material.side = BackSide; + material.needsUpdate = true; + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + material.side = FrontSide; + material.needsUpdate = true; + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + material.side = DoubleSide; + + } else { + + _this.renderBufferDirect( camera, scene, geometry, material, object, group ); + + } + + object.onAfterRender( _this, scene, camera, geometry, material, group ); + + } + + function getProgram( material, scene, object ) { + + if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + const materialProperties = properties.get( material ); + + const lights = currentRenderState.state.lights; + const shadowsArray = currentRenderState.state.shadowsArray; + + const lightsStateVersion = lights.state.version; + + const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object ); + const programCacheKey = programCache.getProgramCacheKey( parameters ); + + let programs = materialProperties.programs; + + // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change + + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; + materialProperties.fog = scene.fog; + materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment ); + + if ( programs === undefined ) { + + // new material + + material.addEventListener( 'dispose', onMaterialDispose ); + + programs = new Map(); + materialProperties.programs = programs; + + } + + let program = programs.get( programCacheKey ); + + if ( program !== undefined ) { + + // early out if program and light state is identical + + if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) { + + updateCommonMaterialProperties( material, parameters ); + + return program; + + } + + } else { + + parameters.uniforms = programCache.getUniforms( material ); + + material.onBuild( object, parameters, _this ); + + material.onBeforeCompile( parameters, _this ); + + program = programCache.acquireProgram( parameters, programCacheKey ); + programs.set( programCacheKey, program ); + + materialProperties.uniforms = parameters.uniforms; + + } + + const uniforms = materialProperties.uniforms; + + if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) { + + uniforms.clippingPlanes = clipping.uniform; + + } + + updateCommonMaterialProperties( material, parameters ); + + // store the light setup it was created for + + materialProperties.needsLights = materialNeedsLights( material ); + materialProperties.lightsStateVersion = lightsStateVersion; + + if ( materialProperties.needsLights ) { + + // wire up the material to this renderer's lighting state + + uniforms.ambientLightColor.value = lights.state.ambient; + uniforms.lightProbe.value = lights.state.probe; + uniforms.directionalLights.value = lights.state.directional; + uniforms.directionalLightShadows.value = lights.state.directionalShadow; + uniforms.spotLights.value = lights.state.spot; + uniforms.spotLightShadows.value = lights.state.spotShadow; + uniforms.rectAreaLights.value = lights.state.rectArea; + uniforms.ltc_1.value = lights.state.rectAreaLTC1; + uniforms.ltc_2.value = lights.state.rectAreaLTC2; + uniforms.pointLights.value = lights.state.point; + uniforms.pointLightShadows.value = lights.state.pointShadow; + uniforms.hemisphereLights.value = lights.state.hemi; + + uniforms.directionalShadowMap.value = lights.state.directionalShadowMap; + uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix; + uniforms.spotShadowMap.value = lights.state.spotShadowMap; + uniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix; + uniforms.pointShadowMap.value = lights.state.pointShadowMap; + uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix; + // TODO (abelnation): add area lights shadow info to uniforms + + } + + const progUniforms = program.getUniforms(); + const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms ); + + materialProperties.currentProgram = program; + materialProperties.uniformsList = uniformsList; + + return program; + + } + + function updateCommonMaterialProperties( material, parameters ) { + + const materialProperties = properties.get( material ); + + materialProperties.outputEncoding = parameters.outputEncoding; + materialProperties.instancing = parameters.instancing; + materialProperties.skinning = parameters.skinning; + materialProperties.morphTargets = parameters.morphTargets; + materialProperties.morphNormals = parameters.morphNormals; + materialProperties.morphTargetsCount = parameters.morphTargetsCount; + materialProperties.numClippingPlanes = parameters.numClippingPlanes; + materialProperties.numIntersection = parameters.numClipIntersection; + materialProperties.vertexAlphas = parameters.vertexAlphas; + materialProperties.vertexTangents = parameters.vertexTangents; + materialProperties.toneMapping = parameters.toneMapping; + + } + + function setProgram( camera, scene, geometry, material, object ) { + + if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + textures.resetTextureUnits(); + + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding; + const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment ); + const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4; + const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent; + const morphTargets = !! geometry.morphAttributes.position; + const morphNormals = !! geometry.morphAttributes.normal; + const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0; + const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping; + + const materialProperties = properties.get( material ); + const lights = currentRenderState.state.lights; + + if ( _clippingEnabled === true ) { + + if ( _localClippingEnabled === true || camera !== _currentCamera ) { + + const useCache = + camera === _currentCamera && + material.id === _currentMaterialId; + + // we might want to call this function with some ClippingGroup + // object instead of the material, once it becomes feasible + // (#8465, #8379) + clipping.setState( material, camera, useCache ); + + } + + } + + // + + let needsProgramChange = false; + + if ( material.version === materialProperties.__version ) { + + if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) { + + needsProgramChange = true; + + } else if ( materialProperties.outputEncoding !== encoding ) { + + needsProgramChange = true; + + } else if ( object.isInstancedMesh && materialProperties.instancing === false ) { + + needsProgramChange = true; + + } else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) { + + needsProgramChange = true; + + } else if ( object.isSkinnedMesh && materialProperties.skinning === false ) { + + needsProgramChange = true; + + } else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) { + + needsProgramChange = true; + + } else if ( materialProperties.envMap !== envMap ) { + + needsProgramChange = true; + + } else if ( material.fog && materialProperties.fog !== fog ) { + + needsProgramChange = true; + + } else if ( materialProperties.numClippingPlanes !== undefined && + ( materialProperties.numClippingPlanes !== clipping.numPlanes || + materialProperties.numIntersection !== clipping.numIntersection ) ) { + + needsProgramChange = true; + + } else if ( materialProperties.vertexAlphas !== vertexAlphas ) { + + needsProgramChange = true; + + } else if ( materialProperties.vertexTangents !== vertexTangents ) { + + needsProgramChange = true; + + } else if ( materialProperties.morphTargets !== morphTargets ) { + + needsProgramChange = true; + + } else if ( materialProperties.morphNormals !== morphNormals ) { + + needsProgramChange = true; + + } else if ( materialProperties.toneMapping !== toneMapping ) { + + needsProgramChange = true; + + } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) { + + needsProgramChange = true; + + } + + } else { + + needsProgramChange = true; + materialProperties.__version = material.version; + + } + + // + + let program = materialProperties.currentProgram; + + if ( needsProgramChange === true ) { + + program = getProgram( material, scene, object ); + + } + + let refreshProgram = false; + let refreshMaterial = false; + let refreshLights = false; + + const p_uniforms = program.getUniforms(), + m_uniforms = materialProperties.uniforms; + + if ( state.useProgram( program.program ) ) { + + refreshProgram = true; + refreshMaterial = true; + refreshLights = true; + + } + + if ( material.id !== _currentMaterialId ) { + + _currentMaterialId = material.id; + + refreshMaterial = true; + + } + + if ( refreshProgram || _currentCamera !== camera ) { + + p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); + + if ( capabilities.logarithmicDepthBuffer ) { + + p_uniforms.setValue( _gl, 'logDepthBufFC', + 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) ); + + } + + if ( _currentCamera !== camera ) { + + _currentCamera = camera; + + // lighting uniforms depend on the camera so enforce an update + // now, in case this material supports lights - or later, when + // the next material that does gets activated: + + refreshMaterial = true; // set to true on material change + refreshLights = true; // remains set until update done + + } + + // load material specific uniforms + // (shader material also gets them for the sake of genericity) + + if ( material.isShaderMaterial || + material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshStandardMaterial || + material.envMap ) { + + const uCamPos = p_uniforms.map.cameraPosition; + + if ( uCamPos !== undefined ) { + + uCamPos.setValue( _gl, + _vector3.setFromMatrixPosition( camera.matrixWorld ) ); + + } + + } + + if ( material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial ) { + + p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true ); + + } + + if ( material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial || + material.isShadowMaterial || + object.isSkinnedMesh ) { + + p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); + + } + + } + + // skinning and morph target uniforms must be set even if material didn't change + // auto-setting of texture unit for bone and morph texture must go before other textures + // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures + + if ( object.isSkinnedMesh ) { + + p_uniforms.setOptional( _gl, object, 'bindMatrix' ); + p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' ); + + const skeleton = object.skeleton; + + if ( skeleton ) { + + if ( capabilities.floatVertexTextures ) { + + if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture(); + + p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures ); + p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize ); + + } else { + + p_uniforms.setOptional( _gl, skeleton, 'boneMatrices' ); + + } + + } + + } + + if ( !! geometry && ( geometry.morphAttributes.position !== undefined || geometry.morphAttributes.normal !== undefined ) ) { + + morphtargets.update( object, geometry, material, program ); + + } + + + if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) { + + materialProperties.receiveShadow = object.receiveShadow; + p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow ); + + } + + if ( refreshMaterial ) { + + p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure ); + + if ( materialProperties.needsLights ) { + + // the current material requires lighting info + + // note: all lighting uniforms are always set correctly + // they simply reference the renderer's state for their + // values + // + // use the current material's .needsUpdate flags to set + // the GL state when required + + markUniformsLightsNeedsUpdate( m_uniforms, refreshLights ); + + } + + // refresh uniforms common to several materials + + if ( fog && material.fog ) { + + materials.refreshFogUniforms( m_uniforms, fog ); + + } + + materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget ); + + WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures ); + + } + + if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) { + + WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures ); + material.uniformsNeedUpdate = false; + + } + + if ( material.isSpriteMaterial ) { + + p_uniforms.setValue( _gl, 'center', object.center ); + + } + + // common matrices + + p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); + p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); + p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); + + return program; + + } + + // If uniforms are marked as clean, they don't need to be loaded to the GPU. + + function markUniformsLightsNeedsUpdate( uniforms, value ) { + + uniforms.ambientLightColor.needsUpdate = value; + uniforms.lightProbe.needsUpdate = value; + + uniforms.directionalLights.needsUpdate = value; + uniforms.directionalLightShadows.needsUpdate = value; + uniforms.pointLights.needsUpdate = value; + uniforms.pointLightShadows.needsUpdate = value; + uniforms.spotLights.needsUpdate = value; + uniforms.spotLightShadows.needsUpdate = value; + uniforms.rectAreaLights.needsUpdate = value; + uniforms.hemisphereLights.needsUpdate = value; + + } + + function materialNeedsLights( material ) { + + return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || + material.isMeshStandardMaterial || material.isShadowMaterial || + ( material.isShaderMaterial && material.lights === true ); + + } + + this.getActiveCubeFace = function () { + + return _currentActiveCubeFace; + + }; + + this.getActiveMipmapLevel = function () { + + return _currentActiveMipmapLevel; + + }; + + this.getRenderTarget = function () { + + return _currentRenderTarget; + + }; + + this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) { + + properties.get( renderTarget.texture ).__webglTexture = colorTexture; + properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture; + + const renderTargetProperties = properties.get( renderTarget ); + renderTargetProperties.__hasExternalTextures = true; + + if ( renderTargetProperties.__hasExternalTextures ) { + + renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined; + + if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) { + + // The multisample_render_to_texture extension doesn't work properly if there + // are midframe flushes and an external depth buffer. Disable use of the extension. + if ( renderTarget.useRenderToTexture ) { + + console.warn( 'render-to-texture extension was disabled because an external texture was provided' ); + renderTarget.useRenderToTexture = false; + renderTarget.useRenderbuffer = true; + + } + + } + + } + + }; + + this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) { + + const renderTargetProperties = properties.get( renderTarget ); + renderTargetProperties.__webglFramebuffer = defaultFramebuffer; + renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined; + + }; + + this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) { + + _currentRenderTarget = renderTarget; + _currentActiveCubeFace = activeCubeFace; + _currentActiveMipmapLevel = activeMipmapLevel; + let useDefaultFramebuffer = true; + + if ( renderTarget ) { + + const renderTargetProperties = properties.get( renderTarget ); + + if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) { + + // We need to make sure to rebind the framebuffer. + state.bindFramebuffer( 36160, null ); + useDefaultFramebuffer = false; + + } else if ( renderTargetProperties.__webglFramebuffer === undefined ) { + + textures.setupRenderTarget( renderTarget ); + + } else if ( renderTargetProperties.__hasExternalTextures ) { + + // Color and depth texture must be rebound in order for the swapchain to update. + textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture ); + + } + + } + + let framebuffer = null; + let isCube = false; + let isRenderTarget3D = false; + + if ( renderTarget ) { + + const texture = renderTarget.texture; + + if ( texture.isDataTexture3D || texture.isDataTexture2DArray ) { + + isRenderTarget3D = true; + + } + + const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer; + + if ( renderTarget.isWebGLCubeRenderTarget ) { + + framebuffer = __webglFramebuffer[ activeCubeFace ]; + isCube = true; + + } else if ( renderTarget.useRenderbuffer ) { + + framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer; + + } else { + + framebuffer = __webglFramebuffer; + + } + + _currentViewport.copy( renderTarget.viewport ); + _currentScissor.copy( renderTarget.scissor ); + _currentScissorTest = renderTarget.scissorTest; + + } else { + + _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor(); + _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor(); + _currentScissorTest = _scissorTest; + + } + + const framebufferBound = state.bindFramebuffer( 36160, framebuffer ); + + if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) { + + state.drawBuffers( renderTarget, framebuffer ); + + } + + state.viewport( _currentViewport ); + state.scissor( _currentScissor ); + state.setScissorTest( _currentScissorTest ); + + if ( isCube ) { + + const textureProperties = properties.get( renderTarget.texture ); + _gl.framebufferTexture2D( 36160, 36064, 34069 + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel ); + + } else if ( isRenderTarget3D ) { + + const textureProperties = properties.get( renderTarget.texture ); + const layer = activeCubeFace || 0; + _gl.framebufferTextureLayer( 36160, 36064, textureProperties.__webglTexture, activeMipmapLevel || 0, layer ); + + } + + _currentMaterialId = - 1; // reset current material to ensure correct uniform bindings + + }; + + this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) { + + if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' ); + return; + + } + + let framebuffer = properties.get( renderTarget ).__webglFramebuffer; + + if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) { + + framebuffer = framebuffer[ activeCubeFaceIndex ]; + + } + + if ( framebuffer ) { + + state.bindFramebuffer( 36160, framebuffer ); + + try { + + const texture = renderTarget.texture; + const textureFormat = texture.format; + const textureType = texture.type; + + if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( 35739 ) ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' ); + return; + + } + + const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) ); + + if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( 35738 ) && // Edge and Chrome Mac < 52 (#9513) + ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox + ! halfFloatSupportedByExt ) { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' ); + return; + + } + + if ( _gl.checkFramebufferStatus( 36160 ) === 36053 ) { + + // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604) + + if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) { + + _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer ); + + } + + } else { + + console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' ); + + } + + } finally { + + // restore framebuffer of current render target if necessary + + const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null; + state.bindFramebuffer( 36160, framebuffer ); + + } + + } + + }; + + this.copyFramebufferToTexture = function ( position, texture, level = 0 ) { + + if ( texture.isFramebufferTexture !== true ) { + + console.error( 'THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.' ); + return; + + } + + const levelScale = Math.pow( 2, - level ); + const width = Math.floor( texture.image.width * levelScale ); + const height = Math.floor( texture.image.height * levelScale ); + + textures.setTexture2D( texture, 0 ); + + _gl.copyTexSubImage2D( 3553, level, 0, 0, position.x, position.y, width, height ); + + state.unbindTexture(); + + }; + + this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) { + + const width = srcTexture.image.width; + const height = srcTexture.image.height; + const glFormat = utils.convert( dstTexture.format ); + const glType = utils.convert( dstTexture.type ); + + textures.setTexture2D( dstTexture, 0 ); + + // As another texture upload may have changed pixelStorei + // parameters, make sure they are correct for the dstTexture + _gl.pixelStorei( 37440, dstTexture.flipY ); + _gl.pixelStorei( 37441, dstTexture.premultiplyAlpha ); + _gl.pixelStorei( 3317, dstTexture.unpackAlignment ); + + if ( srcTexture.isDataTexture ) { + + _gl.texSubImage2D( 3553, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); + + } else { + + if ( srcTexture.isCompressedTexture ) { + + _gl.compressedTexSubImage2D( 3553, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data ); + + } else { + + _gl.texSubImage2D( 3553, level, position.x, position.y, glFormat, glType, srcTexture.image ); + + } + + } + + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( 3553 ); + + state.unbindTexture(); + + }; + + this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) { + + if ( _this.isWebGL1Renderer ) { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' ); + return; + + } + + const width = sourceBox.max.x - sourceBox.min.x + 1; + const height = sourceBox.max.y - sourceBox.min.y + 1; + const depth = sourceBox.max.z - sourceBox.min.z + 1; + const glFormat = utils.convert( dstTexture.format ); + const glType = utils.convert( dstTexture.type ); + let glTarget; + + if ( dstTexture.isDataTexture3D ) { + + textures.setTexture3D( dstTexture, 0 ); + glTarget = 32879; + + } else if ( dstTexture.isDataTexture2DArray ) { + + textures.setTexture2DArray( dstTexture, 0 ); + glTarget = 35866; + + } else { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' ); + return; + + } + + _gl.pixelStorei( 37440, dstTexture.flipY ); + _gl.pixelStorei( 37441, dstTexture.premultiplyAlpha ); + _gl.pixelStorei( 3317, dstTexture.unpackAlignment ); + + const unpackRowLen = _gl.getParameter( 3314 ); + const unpackImageHeight = _gl.getParameter( 32878 ); + const unpackSkipPixels = _gl.getParameter( 3316 ); + const unpackSkipRows = _gl.getParameter( 3315 ); + const unpackSkipImages = _gl.getParameter( 32877 ); + + const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image; + + _gl.pixelStorei( 3314, image.width ); + _gl.pixelStorei( 32878, image.height ); + _gl.pixelStorei( 3316, sourceBox.min.x ); + _gl.pixelStorei( 3315, sourceBox.min.y ); + _gl.pixelStorei( 32877, sourceBox.min.z ); + + if ( srcTexture.isDataTexture || srcTexture.isDataTexture3D ) { + + _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data ); + + } else { + + if ( srcTexture.isCompressedTexture ) { + + console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' ); + _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data ); + + } else { + + _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image ); + + } + + } + + _gl.pixelStorei( 3314, unpackRowLen ); + _gl.pixelStorei( 32878, unpackImageHeight ); + _gl.pixelStorei( 3316, unpackSkipPixels ); + _gl.pixelStorei( 3315, unpackSkipRows ); + _gl.pixelStorei( 32877, unpackSkipImages ); + + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget ); + + state.unbindTexture(); + + }; + + this.initTexture = function ( texture ) { + + textures.setTexture2D( texture, 0 ); + + state.unbindTexture(); + + }; + + this.resetState = function () { + + _currentActiveCubeFace = 0; + _currentActiveMipmapLevel = 0; + _currentRenderTarget = null; + + state.reset(); + bindingStates.reset(); + + }; + + if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); + + } + +} + +WebGLRenderer.prototype.isWebGLRenderer = true; + +class WebGL1Renderer extends WebGLRenderer {} + +WebGL1Renderer.prototype.isWebGL1Renderer = true; + +class FogExp2 { + + constructor( color, density = 0.00025 ) { + + this.name = ''; + + this.color = new Color( color ); + this.density = density; + + } + + clone() { + + return new FogExp2( this.color, this.density ); + + } + + toJSON( /* meta */ ) { + + return { + type: 'FogExp2', + color: this.color.getHex(), + density: this.density + }; + + } + +} + +FogExp2.prototype.isFogExp2 = true; + +class Fog { + + constructor( color, near = 1, far = 1000 ) { + + this.name = ''; + + this.color = new Color( color ); + + this.near = near; + this.far = far; + + } + + clone() { + + return new Fog( this.color, this.near, this.far ); + + } + + toJSON( /* meta */ ) { + + return { + type: 'Fog', + color: this.color.getHex(), + near: this.near, + far: this.far + }; + + } + +} + +Fog.prototype.isFog = true; + +class Scene extends Object3D { + + constructor() { + + super(); + + this.type = 'Scene'; + + this.background = null; + this.environment = null; + this.fog = null; + + this.overrideMaterial = null; + + this.autoUpdate = true; // checked by the renderer + + if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); + + } + + } + + copy( source, recursive ) { + + super.copy( source, recursive ); + + if ( source.background !== null ) this.background = source.background.clone(); + if ( source.environment !== null ) this.environment = source.environment.clone(); + if ( source.fog !== null ) this.fog = source.fog.clone(); + + if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone(); + + this.autoUpdate = source.autoUpdate; + this.matrixAutoUpdate = source.matrixAutoUpdate; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + if ( this.fog !== null ) data.object.fog = this.fog.toJSON(); + + return data; + + } + +} + +Scene.prototype.isScene = true; + +class InterleavedBuffer { + + constructor( array, stride ) { + + this.array = array; + this.stride = stride; + this.count = array !== undefined ? array.length / stride : 0; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: - 1 }; + + this.version = 0; + + this.uuid = generateUUID(); + + } + + onUploadCallback() {} + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + + setUsage( value ) { + + this.usage = value; + + return this; + + } + + copy( source ) { + + this.array = new source.array.constructor( source.array ); + this.count = source.count; + this.stride = source.stride; + this.usage = source.usage; + + return this; + + } + + copyAt( index1, attribute, index2 ) { + + index1 *= this.stride; + index2 *= attribute.stride; + + for ( let i = 0, l = this.stride; i < l; i ++ ) { + + this.array[ index1 + i ] = attribute.array[ index2 + i ]; + + } + + return this; + + } + + set( value, offset = 0 ) { + + this.array.set( value, offset ); + + return this; + + } + + clone( data ) { + + if ( data.arrayBuffers === undefined ) { + + data.arrayBuffers = {}; + + } + + if ( this.array.buffer._uuid === undefined ) { + + this.array.buffer._uuid = generateUUID(); + + } + + if ( data.arrayBuffers[ this.array.buffer._uuid ] === undefined ) { + + data.arrayBuffers[ this.array.buffer._uuid ] = this.array.slice( 0 ).buffer; + + } + + const array = new this.array.constructor( data.arrayBuffers[ this.array.buffer._uuid ] ); + + const ib = new this.constructor( array, this.stride ); + ib.setUsage( this.usage ); + + return ib; + + } + + onUpload( callback ) { + + this.onUploadCallback = callback; + + return this; + + } + + toJSON( data ) { + + if ( data.arrayBuffers === undefined ) { + + data.arrayBuffers = {}; + + } + + // generate UUID for array buffer if necessary + + if ( this.array.buffer._uuid === undefined ) { + + this.array.buffer._uuid = generateUUID(); + + } + + if ( data.arrayBuffers[ this.array.buffer._uuid ] === undefined ) { + + data.arrayBuffers[ this.array.buffer._uuid ] = Array.prototype.slice.call( new Uint32Array( this.array.buffer ) ); + + } + + // + + return { + uuid: this.uuid, + buffer: this.array.buffer._uuid, + type: this.array.constructor.name, + stride: this.stride + }; + + } + +} + +InterleavedBuffer.prototype.isInterleavedBuffer = true; + +const _vector$6 = /*@__PURE__*/ new Vector3(); + +class InterleavedBufferAttribute { + + constructor( interleavedBuffer, itemSize, offset, normalized = false ) { + + this.name = ''; + + this.data = interleavedBuffer; + this.itemSize = itemSize; + this.offset = offset; + + this.normalized = normalized === true; + + } + + get count() { + + return this.data.count; + + } + + get array() { + + return this.data.array; + + } + + set needsUpdate( value ) { + + this.data.needsUpdate = value; + + } + + applyMatrix4( m ) { + + for ( let i = 0, l = this.data.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.applyMatrix4( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + applyNormalMatrix( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.applyNormalMatrix( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + transformDirection( m ) { + + for ( let i = 0, l = this.count; i < l; i ++ ) { + + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); + + _vector$6.transformDirection( m ); + + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); + + } + + return this; + + } + + setX( index, x ) { + + this.data.array[ index * this.data.stride + this.offset ] = x; + + return this; + + } + + setY( index, y ) { + + this.data.array[ index * this.data.stride + this.offset + 1 ] = y; + + return this; + + } + + setZ( index, z ) { + + this.data.array[ index * this.data.stride + this.offset + 2 ] = z; + + return this; + + } + + setW( index, w ) { + + this.data.array[ index * this.data.stride + this.offset + 3 ] = w; + + return this; + + } + + getX( index ) { + + return this.data.array[ index * this.data.stride + this.offset ]; + + } + + getY( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 1 ]; + + } + + getZ( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 2 ]; + + } + + getW( index ) { + + return this.data.array[ index * this.data.stride + this.offset + 3 ]; + + } + + setXY( index, x, y ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + + return this; + + } + + setXYZ( index, x, y, z ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + this.data.array[ index + 2 ] = z; + + return this; + + } + + setXYZW( index, x, y, z, w ) { + + index = index * this.data.stride + this.offset; + + this.data.array[ index + 0 ] = x; + this.data.array[ index + 1 ] = y; + this.data.array[ index + 2 ] = z; + this.data.array[ index + 3 ] = w; + + return this; + + } + + clone( data ) { + + if ( data === undefined ) { + + console.log( 'THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.' ); + + const array = []; + + for ( let i = 0; i < this.count; i ++ ) { + + const index = i * this.data.stride + this.offset; + + for ( let j = 0; j < this.itemSize; j ++ ) { + + array.push( this.data.array[ index + j ] ); + + } + + } + + return new BufferAttribute( new this.array.constructor( array ), this.itemSize, this.normalized ); + + } else { + + if ( data.interleavedBuffers === undefined ) { + + data.interleavedBuffers = {}; + + } + + if ( data.interleavedBuffers[ this.data.uuid ] === undefined ) { + + data.interleavedBuffers[ this.data.uuid ] = this.data.clone( data ); + + } + + return new InterleavedBufferAttribute( data.interleavedBuffers[ this.data.uuid ], this.itemSize, this.offset, this.normalized ); + + } + + } + + toJSON( data ) { + + if ( data === undefined ) { + + console.log( 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.' ); + + const array = []; + + for ( let i = 0; i < this.count; i ++ ) { + + const index = i * this.data.stride + this.offset; + + for ( let j = 0; j < this.itemSize; j ++ ) { + + array.push( this.data.array[ index + j ] ); + + } + + } + + // deinterleave data and save it as an ordinary buffer attribute for now + + return { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: array, + normalized: this.normalized + }; + + } else { + + // save as true interlaved attribtue + + if ( data.interleavedBuffers === undefined ) { + + data.interleavedBuffers = {}; + + } + + if ( data.interleavedBuffers[ this.data.uuid ] === undefined ) { + + data.interleavedBuffers[ this.data.uuid ] = this.data.toJSON( data ); + + } + + return { + isInterleavedBufferAttribute: true, + itemSize: this.itemSize, + data: this.data.uuid, + offset: this.offset, + normalized: this.normalized + }; + + } + + } + +} + +InterleavedBufferAttribute.prototype.isInterleavedBufferAttribute = true; + +/** + * parameters = { + * color: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * rotation: , + * sizeAttenuation: + * } + */ + +class SpriteMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'SpriteMaterial'; + + this.color = new Color( 0xffffff ); + + this.map = null; + + this.alphaMap = null; + + this.rotation = 0; + + this.sizeAttenuation = true; + + this.transparent = true; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.rotation = source.rotation; + + this.sizeAttenuation = source.sizeAttenuation; + + return this; + + } + +} + +SpriteMaterial.prototype.isSpriteMaterial = true; + +let _geometry; + +const _intersectPoint = /*@__PURE__*/ new Vector3(); +const _worldScale = /*@__PURE__*/ new Vector3(); +const _mvPosition = /*@__PURE__*/ new Vector3(); + +const _alignedPosition = /*@__PURE__*/ new Vector2(); +const _rotatedPosition = /*@__PURE__*/ new Vector2(); +const _viewWorldMatrix = /*@__PURE__*/ new Matrix4(); + +const _vA = /*@__PURE__*/ new Vector3(); +const _vB = /*@__PURE__*/ new Vector3(); +const _vC = /*@__PURE__*/ new Vector3(); + +const _uvA = /*@__PURE__*/ new Vector2(); +const _uvB = /*@__PURE__*/ new Vector2(); +const _uvC = /*@__PURE__*/ new Vector2(); + +class Sprite extends Object3D { + + constructor( material ) { + + super(); + + this.type = 'Sprite'; + + if ( _geometry === undefined ) { + + _geometry = new BufferGeometry(); + + const float32Array = new Float32Array( [ + - 0.5, - 0.5, 0, 0, 0, + 0.5, - 0.5, 0, 1, 0, + 0.5, 0.5, 0, 1, 1, + - 0.5, 0.5, 0, 0, 1 + ] ); + + const interleavedBuffer = new InterleavedBuffer( float32Array, 5 ); + + _geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] ); + _geometry.setAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) ); + _geometry.setAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) ); + + } + + this.geometry = _geometry; + this.material = ( material !== undefined ) ? material : new SpriteMaterial(); + + this.center = new Vector2( 0.5, 0.5 ); + + } + + raycast( raycaster, intersects ) { + + if ( raycaster.camera === null ) { + + console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' ); + + } + + _worldScale.setFromMatrixScale( this.matrixWorld ); + + _viewWorldMatrix.copy( raycaster.camera.matrixWorld ); + this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld ); + + _mvPosition.setFromMatrixPosition( this.modelViewMatrix ); + + if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { + + _worldScale.multiplyScalar( - _mvPosition.z ); + + } + + const rotation = this.material.rotation; + let sin, cos; + + if ( rotation !== 0 ) { + + cos = Math.cos( rotation ); + sin = Math.sin( rotation ); + + } + + const center = this.center; + + transformVertex( _vA.set( - 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + transformVertex( _vB.set( 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + transformVertex( _vC.set( 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + + _uvA.set( 0, 0 ); + _uvB.set( 1, 0 ); + _uvC.set( 1, 1 ); + + // check first triangle + let intersect = raycaster.ray.intersectTriangle( _vA, _vB, _vC, false, _intersectPoint ); + + if ( intersect === null ) { + + // check second triangle + transformVertex( _vB.set( - 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos ); + _uvB.set( 0, 1 ); + + intersect = raycaster.ray.intersectTriangle( _vA, _vC, _vB, false, _intersectPoint ); + if ( intersect === null ) { + + return; + + } + + } + + const distance = raycaster.ray.origin.distanceTo( _intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + point: _intersectPoint.clone(), + uv: Triangle.getUV( _intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() ), + face: null, + object: this + + } ); + + } + + copy( source ) { + + super.copy( source ); + + if ( source.center !== undefined ) this.center.copy( source.center ); + + this.material = source.material; + + return this; + + } + +} + +Sprite.prototype.isSprite = true; + +function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) { + + // compute position in camera space + _alignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale ); + + // to check if rotation is not zero + if ( sin !== undefined ) { + + _rotatedPosition.x = ( cos * _alignedPosition.x ) - ( sin * _alignedPosition.y ); + _rotatedPosition.y = ( sin * _alignedPosition.x ) + ( cos * _alignedPosition.y ); + + } else { + + _rotatedPosition.copy( _alignedPosition ); + + } + + + vertexPosition.copy( mvPosition ); + vertexPosition.x += _rotatedPosition.x; + vertexPosition.y += _rotatedPosition.y; + + // transform to world space + vertexPosition.applyMatrix4( _viewWorldMatrix ); + +} + +const _v1$2 = /*@__PURE__*/ new Vector3(); +const _v2$1 = /*@__PURE__*/ new Vector3(); + +class LOD extends Object3D { + + constructor() { + + super(); + + this._currentLevel = 0; + + this.type = 'LOD'; + + Object.defineProperties( this, { + levels: { + enumerable: true, + value: [] + }, + isLOD: { + value: true, + } + } ); + + this.autoUpdate = true; + + } + + copy( source ) { + + super.copy( source, false ); + + const levels = source.levels; + + for ( let i = 0, l = levels.length; i < l; i ++ ) { + + const level = levels[ i ]; + + this.addLevel( level.object.clone(), level.distance ); + + } + + this.autoUpdate = source.autoUpdate; + + return this; + + } + + addLevel( object, distance = 0 ) { + + distance = Math.abs( distance ); + + const levels = this.levels; + + let l; + + for ( l = 0; l < levels.length; l ++ ) { + + if ( distance < levels[ l ].distance ) { + + break; + + } + + } + + levels.splice( l, 0, { distance: distance, object: object } ); + + this.add( object ); + + return this; + + } + + getCurrentLevel() { + + return this._currentLevel; + + } + + getObjectForDistance( distance ) { + + const levels = this.levels; + + if ( levels.length > 0 ) { + + let i, l; + + for ( i = 1, l = levels.length; i < l; i ++ ) { + + if ( distance < levels[ i ].distance ) { + + break; + + } + + } + + return levels[ i - 1 ].object; + + } + + return null; + + } + + raycast( raycaster, intersects ) { + + const levels = this.levels; + + if ( levels.length > 0 ) { + + _v1$2.setFromMatrixPosition( this.matrixWorld ); + + const distance = raycaster.ray.origin.distanceTo( _v1$2 ); + + this.getObjectForDistance( distance ).raycast( raycaster, intersects ); + + } + + } + + update( camera ) { + + const levels = this.levels; + + if ( levels.length > 1 ) { + + _v1$2.setFromMatrixPosition( camera.matrixWorld ); + _v2$1.setFromMatrixPosition( this.matrixWorld ); + + const distance = _v1$2.distanceTo( _v2$1 ) / camera.zoom; + + levels[ 0 ].object.visible = true; + + let i, l; + + for ( i = 1, l = levels.length; i < l; i ++ ) { + + if ( distance >= levels[ i ].distance ) { + + levels[ i - 1 ].object.visible = false; + levels[ i ].object.visible = true; + + } else { + + break; + + } + + } + + this._currentLevel = i - 1; + + for ( ; i < l; i ++ ) { + + levels[ i ].object.visible = false; + + } + + } + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + if ( this.autoUpdate === false ) data.object.autoUpdate = false; + + data.object.levels = []; + + const levels = this.levels; + + for ( let i = 0, l = levels.length; i < l; i ++ ) { + + const level = levels[ i ]; + + data.object.levels.push( { + object: level.object.uuid, + distance: level.distance + } ); + + } + + return data; + + } + +} + +const _basePosition = /*@__PURE__*/ new Vector3(); + +const _skinIndex = /*@__PURE__*/ new Vector4(); +const _skinWeight = /*@__PURE__*/ new Vector4(); + +const _vector$5 = /*@__PURE__*/ new Vector3(); +const _matrix = /*@__PURE__*/ new Matrix4(); + +class SkinnedMesh extends Mesh { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'SkinnedMesh'; + + this.bindMode = 'attached'; + this.bindMatrix = new Matrix4(); + this.bindMatrixInverse = new Matrix4(); + + } + + copy( source ) { + + super.copy( source ); + + this.bindMode = source.bindMode; + this.bindMatrix.copy( source.bindMatrix ); + this.bindMatrixInverse.copy( source.bindMatrixInverse ); + + this.skeleton = source.skeleton; + + return this; + + } + + bind( skeleton, bindMatrix ) { + + this.skeleton = skeleton; + + if ( bindMatrix === undefined ) { + + this.updateMatrixWorld( true ); + + this.skeleton.calculateInverses(); + + bindMatrix = this.matrixWorld; + + } + + this.bindMatrix.copy( bindMatrix ); + this.bindMatrixInverse.copy( bindMatrix ).invert(); + + } + + pose() { + + this.skeleton.pose(); + + } + + normalizeSkinWeights() { + + const vector = new Vector4(); + + const skinWeight = this.geometry.attributes.skinWeight; + + for ( let i = 0, l = skinWeight.count; i < l; i ++ ) { + + vector.x = skinWeight.getX( i ); + vector.y = skinWeight.getY( i ); + vector.z = skinWeight.getZ( i ); + vector.w = skinWeight.getW( i ); + + const scale = 1.0 / vector.manhattanLength(); + + if ( scale !== Infinity ) { + + vector.multiplyScalar( scale ); + + } else { + + vector.set( 1, 0, 0, 0 ); // do something reasonable + + } + + skinWeight.setXYZW( i, vector.x, vector.y, vector.z, vector.w ); + + } + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + if ( this.bindMode === 'attached' ) { + + this.bindMatrixInverse.copy( this.matrixWorld ).invert(); + + } else if ( this.bindMode === 'detached' ) { + + this.bindMatrixInverse.copy( this.bindMatrix ).invert(); + + } else { + + console.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode ); + + } + + } + + boneTransform( index, target ) { + + const skeleton = this.skeleton; + const geometry = this.geometry; + + _skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index ); + _skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index ); + + _basePosition.copy( target ).applyMatrix4( this.bindMatrix ); + + target.set( 0, 0, 0 ); + + for ( let i = 0; i < 4; i ++ ) { + + const weight = _skinWeight.getComponent( i ); + + if ( weight !== 0 ) { + + const boneIndex = _skinIndex.getComponent( i ); + + _matrix.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] ); + + target.addScaledVector( _vector$5.copy( _basePosition ).applyMatrix4( _matrix ), weight ); + + } + + } + + return target.applyMatrix4( this.bindMatrixInverse ); + + } + +} + +SkinnedMesh.prototype.isSkinnedMesh = true; + +class Bone extends Object3D { + + constructor() { + + super(); + + this.type = 'Bone'; + + } + +} + +Bone.prototype.isBone = true; + +class DataTexture extends Texture { + + constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding ) { + + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + + this.image = { data: data, width: width, height: height }; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + + } + +} + +DataTexture.prototype.isDataTexture = true; + +const _offsetMatrix = /*@__PURE__*/ new Matrix4(); +const _identityMatrix = /*@__PURE__*/ new Matrix4(); + +class Skeleton { + + constructor( bones = [], boneInverses = [] ) { + + this.uuid = generateUUID(); + + this.bones = bones.slice( 0 ); + this.boneInverses = boneInverses; + this.boneMatrices = null; + + this.boneTexture = null; + this.boneTextureSize = 0; + + this.frame = - 1; + + this.init(); + + } + + init() { + + const bones = this.bones; + const boneInverses = this.boneInverses; + + this.boneMatrices = new Float32Array( bones.length * 16 ); + + // calculate inverse bone matrices if necessary + + if ( boneInverses.length === 0 ) { + + this.calculateInverses(); + + } else { + + // handle special case + + if ( bones.length !== boneInverses.length ) { + + console.warn( 'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.' ); + + this.boneInverses = []; + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + this.boneInverses.push( new Matrix4() ); + + } + + } + + } + + } + + calculateInverses() { + + this.boneInverses.length = 0; + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const inverse = new Matrix4(); + + if ( this.bones[ i ] ) { + + inverse.copy( this.bones[ i ].matrixWorld ).invert(); + + } + + this.boneInverses.push( inverse ); + + } + + } + + pose() { + + // recover the bind-time world matrices + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone ) { + + bone.matrixWorld.copy( this.boneInverses[ i ] ).invert(); + + } + + } + + // compute the local matrices, positions, rotations and scales + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone ) { + + if ( bone.parent && bone.parent.isBone ) { + + bone.matrix.copy( bone.parent.matrixWorld ).invert(); + bone.matrix.multiply( bone.matrixWorld ); + + } else { + + bone.matrix.copy( bone.matrixWorld ); + + } + + bone.matrix.decompose( bone.position, bone.quaternion, bone.scale ); + + } + + } + + } + + update() { + + const bones = this.bones; + const boneInverses = this.boneInverses; + const boneMatrices = this.boneMatrices; + const boneTexture = this.boneTexture; + + // flatten bone matrices to array + + for ( let i = 0, il = bones.length; i < il; i ++ ) { + + // compute the offset between the current and the original transform + + const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix; + + _offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] ); + _offsetMatrix.toArray( boneMatrices, i * 16 ); + + } + + if ( boneTexture !== null ) { + + boneTexture.needsUpdate = true; + + } + + } + + clone() { + + return new Skeleton( this.bones, this.boneInverses ); + + } + + computeBoneTexture() { + + // layout (1 matrix = 4 pixels) + // RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4) + // with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8) + // 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16) + // 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32) + // 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64) + + let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix + size = ceilPowerOfTwo( size ); + size = Math.max( size, 4 ); + + const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel + boneMatrices.set( this.boneMatrices ); // copy current values + + const boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType ); + boneTexture.needsUpdate = true; + + this.boneMatrices = boneMatrices; + this.boneTexture = boneTexture; + this.boneTextureSize = size; + + return this; + + } + + getBoneByName( name ) { + + for ( let i = 0, il = this.bones.length; i < il; i ++ ) { + + const bone = this.bones[ i ]; + + if ( bone.name === name ) { + + return bone; + + } + + } + + return undefined; + + } + + dispose( ) { + + if ( this.boneTexture !== null ) { + + this.boneTexture.dispose(); + + this.boneTexture = null; + + } + + } + + fromJSON( json, bones ) { + + this.uuid = json.uuid; + + for ( let i = 0, l = json.bones.length; i < l; i ++ ) { + + const uuid = json.bones[ i ]; + let bone = bones[ uuid ]; + + if ( bone === undefined ) { + + console.warn( 'THREE.Skeleton: No bone found with UUID:', uuid ); + bone = new Bone(); + + } + + this.bones.push( bone ); + this.boneInverses.push( new Matrix4().fromArray( json.boneInverses[ i ] ) ); + + } + + this.init(); + + return this; + + } + + toJSON() { + + const data = { + metadata: { + version: 4.5, + type: 'Skeleton', + generator: 'Skeleton.toJSON' + }, + bones: [], + boneInverses: [] + }; + + data.uuid = this.uuid; + + const bones = this.bones; + const boneInverses = this.boneInverses; + + for ( let i = 0, l = bones.length; i < l; i ++ ) { + + const bone = bones[ i ]; + data.bones.push( bone.uuid ); + + const boneInverse = boneInverses[ i ]; + data.boneInverses.push( boneInverse.toArray() ); + + } + + return data; + + } + +} + +class InstancedBufferAttribute extends BufferAttribute { + + constructor( array, itemSize, normalized, meshPerAttribute = 1 ) { + + if ( typeof normalized === 'number' ) { + + meshPerAttribute = normalized; + + normalized = false; + + console.error( 'THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.' ); + + } + + super( array, itemSize, normalized ); + + this.meshPerAttribute = meshPerAttribute; + + } + + copy( source ) { + + super.copy( source ); + + this.meshPerAttribute = source.meshPerAttribute; + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.meshPerAttribute = this.meshPerAttribute; + + data.isInstancedBufferAttribute = true; + + return data; + + } + +} + +InstancedBufferAttribute.prototype.isInstancedBufferAttribute = true; + +const _instanceLocalMatrix = /*@__PURE__*/ new Matrix4(); +const _instanceWorldMatrix = /*@__PURE__*/ new Matrix4(); + +const _instanceIntersects = []; + +const _mesh = /*@__PURE__*/ new Mesh(); + +class InstancedMesh extends Mesh { + + constructor( geometry, material, count ) { + + super( geometry, material ); + + this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 ); + this.instanceColor = null; + + this.count = count; + + this.frustumCulled = false; + + } + + copy( source ) { + + super.copy( source ); + + this.instanceMatrix.copy( source.instanceMatrix ); + + if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone(); + + this.count = source.count; + + return this; + + } + + getColorAt( index, color ) { + + color.fromArray( this.instanceColor.array, index * 3 ); + + } + + getMatrixAt( index, matrix ) { + + matrix.fromArray( this.instanceMatrix.array, index * 16 ); + + } + + raycast( raycaster, intersects ) { + + const matrixWorld = this.matrixWorld; + const raycastTimes = this.count; + + _mesh.geometry = this.geometry; + _mesh.material = this.material; + + if ( _mesh.material === undefined ) return; + + for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) { + + // calculate the world matrix for each instance + + this.getMatrixAt( instanceId, _instanceLocalMatrix ); + + _instanceWorldMatrix.multiplyMatrices( matrixWorld, _instanceLocalMatrix ); + + // the mesh represents this single instance + + _mesh.matrixWorld = _instanceWorldMatrix; + + _mesh.raycast( raycaster, _instanceIntersects ); + + // process the result of raycast + + for ( let i = 0, l = _instanceIntersects.length; i < l; i ++ ) { + + const intersect = _instanceIntersects[ i ]; + intersect.instanceId = instanceId; + intersect.object = this; + intersects.push( intersect ); + + } + + _instanceIntersects.length = 0; + + } + + } + + setColorAt( index, color ) { + + if ( this.instanceColor === null ) { + + this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ), 3 ); + + } + + color.toArray( this.instanceColor.array, index * 3 ); + + } + + setMatrixAt( index, matrix ) { + + matrix.toArray( this.instanceMatrix.array, index * 16 ); + + } + + updateMorphTargets() { + + } + + dispose() { + + this.dispatchEvent( { type: 'dispose' } ); + + } + +} + +InstancedMesh.prototype.isInstancedMesh = true; + +/** + * parameters = { + * color: , + * opacity: , + * + * linewidth: , + * linecap: "round", + * linejoin: "round" + * } + */ + +class LineBasicMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'LineBasicMaterial'; + + this.color = new Color( 0xffffff ); + + this.linewidth = 1; + this.linecap = 'round'; + this.linejoin = 'round'; + + this.setValues( parameters ); + + } + + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.linewidth = source.linewidth; + this.linecap = source.linecap; + this.linejoin = source.linejoin; + + return this; + + } + +} + +LineBasicMaterial.prototype.isLineBasicMaterial = true; + +const _start$1 = /*@__PURE__*/ new Vector3(); +const _end$1 = /*@__PURE__*/ new Vector3(); +const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4(); +const _ray$1 = /*@__PURE__*/ new Ray(); +const _sphere$1 = /*@__PURE__*/ new Sphere(); + +class Line extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) { + + super(); + + this.type = 'Line'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + computeLineDistances() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + // we assume non-indexed geometry + + if ( geometry.index === null ) { + + const positionAttribute = geometry.attributes.position; + const lineDistances = [ 0 ]; + + for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) { + + _start$1.fromBufferAttribute( positionAttribute, i - 1 ); + _end$1.fromBufferAttribute( positionAttribute, i ); + + lineDistances[ i ] = lineDistances[ i - 1 ]; + lineDistances[ i ] += _start$1.distanceTo( _end$1 ); + + } + + geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); + + } else { + + console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + return this; + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Line.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere$1.copy( geometry.boundingSphere ); + _sphere$1.applyMatrix4( matrixWorld ); + _sphere$1.radius += threshold; + + if ( raycaster.ray.intersectsSphere( _sphere$1 ) === false ) return; + + // + + _inverseMatrix$1.copy( matrixWorld ).invert(); + _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 ); + + const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + const localThresholdSq = localThreshold * localThreshold; + + const vStart = new Vector3(); + const vEnd = new Vector3(); + const interSegment = new Vector3(); + const interRay = new Vector3(); + const step = this.isLineSegments ? 2 : 1; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if ( index !== null ) { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end - 1; i < l; i += step ) { + + const a = index.getX( i ); + const b = index.getX( i + 1 ); + + vStart.fromBufferAttribute( positionAttribute, a ); + vEnd.fromBufferAttribute( positionAttribute, b ); + + const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); + + if ( distSq > localThresholdSq ) continue; + + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo( interRay ); + + if ( distance < raycaster.near || distance > raycaster.far ) continue; + + intersects.push( { + + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), + index: i, + face: null, + faceIndex: null, + object: this + + } ); + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end - 1; i < l; i += step ) { + + vStart.fromBufferAttribute( positionAttribute, i ); + vEnd.fromBufferAttribute( positionAttribute, i + 1 ); + + const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); + + if ( distSq > localThresholdSq ) continue; + + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo( interRay ); + + if ( distance < raycaster.near || distance > raycaster.far ) continue; + + intersects.push( { + + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), + index: i, + face: null, + faceIndex: null, + object: this + + } ); + + } + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + +} + +Line.prototype.isLine = true; + +const _start = /*@__PURE__*/ new Vector3(); +const _end = /*@__PURE__*/ new Vector3(); + +class LineSegments extends Line { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'LineSegments'; + + } + + computeLineDistances() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + // we assume non-indexed geometry + + if ( geometry.index === null ) { + + const positionAttribute = geometry.attributes.position; + const lineDistances = []; + + for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) { + + _start.fromBufferAttribute( positionAttribute, i ); + _end.fromBufferAttribute( positionAttribute, i + 1 ); + + lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ]; + lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end ); + + } + + geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); + + } else { + + console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); + + } + + } else if ( geometry.isGeometry ) { + + console.error( 'THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + return this; + + } + +} + +LineSegments.prototype.isLineSegments = true; + +class LineLoop extends Line { + + constructor( geometry, material ) { + + super( geometry, material ); + + this.type = 'LineLoop'; + + } + +} + +LineLoop.prototype.isLineLoop = true; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * + * size: , + * sizeAttenuation: + * + * } + */ + +class PointsMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'PointsMaterial'; + + this.color = new Color( 0xffffff ); + + this.map = null; + + this.alphaMap = null; + + this.size = 1; + this.sizeAttenuation = true; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.size = source.size; + this.sizeAttenuation = source.sizeAttenuation; + + return this; + + } + +} + +PointsMaterial.prototype.isPointsMaterial = true; + +const _inverseMatrix = /*@__PURE__*/ new Matrix4(); +const _ray = /*@__PURE__*/ new Ray(); +const _sphere = /*@__PURE__*/ new Sphere(); +const _position$2 = /*@__PURE__*/ new Vector3(); + +class Points extends Object3D { + + constructor( geometry = new BufferGeometry(), material = new PointsMaterial() ) { + + super(); + + this.type = 'Points'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + + } + + copy( source ) { + + super.copy( source ); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + + } + + raycast( raycaster, intersects ) { + + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Points.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); + + _sphere.copy( geometry.boundingSphere ); + _sphere.applyMatrix4( matrixWorld ); + _sphere.radius += threshold; + + if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return; + + // + + _inverseMatrix.copy( matrixWorld ).invert(); + _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix ); + + const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + const localThresholdSq = localThreshold * localThreshold; + + if ( geometry.isBufferGeometry ) { + + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if ( index !== null ) { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, il = end; i < il; i ++ ) { + + const a = index.getX( i ); + + _position$2.fromBufferAttribute( positionAttribute, a ); + + testPoint( _position$2, a, localThresholdSq, matrixWorld, raycaster, intersects, this ); + + } + + } else { + + const start = Math.max( 0, drawRange.start ); + const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) ); + + for ( let i = start, l = end; i < l; i ++ ) { + + _position$2.fromBufferAttribute( positionAttribute, i ); + + testPoint( _position$2, i, localThresholdSq, matrixWorld, raycaster, intersects, this ); + + } + + } + + } else { + + console.error( 'THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + updateMorphTargets() { + + const geometry = this.geometry; + + if ( geometry.isBufferGeometry ) { + + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys( morphAttributes ); + + if ( keys.length > 0 ) { + + const morphAttribute = morphAttributes[ keys[ 0 ] ]; + + if ( morphAttribute !== undefined ) { + + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) { + + const name = morphAttribute[ m ].name || String( m ); + + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; + + } + + } + + } + + } else { + + const morphTargets = geometry.morphTargets; + + if ( morphTargets !== undefined && morphTargets.length > 0 ) { + + console.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' ); + + } + + } + + } + +} + +Points.prototype.isPoints = true; + +function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) { + + const rayPointDistanceSq = _ray.distanceSqToPoint( point ); + + if ( rayPointDistanceSq < localThresholdSq ) { + + const intersectPoint = new Vector3(); + + _ray.closestPointToPoint( point, intersectPoint ); + intersectPoint.applyMatrix4( matrixWorld ); + + const distance = raycaster.ray.origin.distanceTo( intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + distanceToRay: Math.sqrt( rayPointDistanceSq ), + point: intersectPoint, + index: index, + face: null, + object: object + + } ); + + } + +} + +class VideoTexture extends Texture { + + constructor( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { + + super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + + this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + + this.generateMipmaps = false; + + const scope = this; + + function updateVideo() { + + scope.needsUpdate = true; + video.requestVideoFrameCallback( updateVideo ); + + } + + if ( 'requestVideoFrameCallback' in video ) { + + video.requestVideoFrameCallback( updateVideo ); + + } + + } + + clone() { + + return new this.constructor( this.image ).copy( this ); + + } + + update() { + + const video = this.image; + const hasVideoFrameCallback = 'requestVideoFrameCallback' in video; + + if ( hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA ) { + + this.needsUpdate = true; + + } + + } + +} + +VideoTexture.prototype.isVideoTexture = true; + +class FramebufferTexture extends Texture { + + constructor( width, height, format ) { + + super( { width, height } ); + + this.format = format; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.generateMipmaps = false; + + this.needsUpdate = true; + + } + +} + +FramebufferTexture.prototype.isFramebufferTexture = true; + +class CompressedTexture extends Texture { + + constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { + + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + + this.image = { width: width, height: height }; + this.mipmaps = mipmaps; + + // no flipping for cube textures + // (also flipping doesn't work for compressed textures ) + + this.flipY = false; + + // can't generate mipmaps for compressed textures + // mips must be embedded in DDS files + + this.generateMipmaps = false; + + } + +} + +CompressedTexture.prototype.isCompressedTexture = true; + +class CanvasTexture extends Texture { + + constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { + + super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + + this.needsUpdate = true; + + } + +} + +CanvasTexture.prototype.isCanvasTexture = true; + +class CircleGeometry extends BufferGeometry { + + constructor( radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2 ) { + + super(); + + this.type = 'CircleGeometry'; + + this.parameters = { + radius: radius, + segments: segments, + thetaStart: thetaStart, + thetaLength: thetaLength + }; + + segments = Math.max( 3, segments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const vertex = new Vector3(); + const uv = new Vector2(); + + // center point + + vertices.push( 0, 0, 0 ); + normals.push( 0, 0, 1 ); + uvs.push( 0.5, 0.5 ); + + for ( let s = 0, i = 3; s <= segments; s ++, i += 3 ) { + + const segment = thetaStart + s / segments * thetaLength; + + // vertex + + vertex.x = radius * Math.cos( segment ); + vertex.y = radius * Math.sin( segment ); + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + normals.push( 0, 0, 1 ); + + // uvs + + uv.x = ( vertices[ i ] / radius + 1 ) / 2; + uv.y = ( vertices[ i + 1 ] / radius + 1 ) / 2; + + uvs.push( uv.x, uv.y ); + + } + + // indices + + for ( let i = 1; i <= segments; i ++ ) { + + indices.push( i, i + 1, 0 ); + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new CircleGeometry( data.radius, data.segments, data.thetaStart, data.thetaLength ); + + } + +} + +class CylinderGeometry extends BufferGeometry { + + constructor( radiusTop = 1, radiusBottom = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { + + super(); + this.type = 'CylinderGeometry'; + + this.parameters = { + radiusTop: radiusTop, + radiusBottom: radiusBottom, + height: height, + radialSegments: radialSegments, + heightSegments: heightSegments, + openEnded: openEnded, + thetaStart: thetaStart, + thetaLength: thetaLength + }; + + const scope = this; + + radialSegments = Math.floor( radialSegments ); + heightSegments = Math.floor( heightSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let index = 0; + const indexArray = []; + const halfHeight = height / 2; + let groupStart = 0; + + // generate geometry + + generateTorso(); + + if ( openEnded === false ) { + + if ( radiusTop > 0 ) generateCap( true ); + if ( radiusBottom > 0 ) generateCap( false ); + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + function generateTorso() { + + const normal = new Vector3(); + const vertex = new Vector3(); + + let groupCount = 0; + + // this will be used to calculate the normal + const slope = ( radiusBottom - radiusTop ) / height; + + // generate vertices, normals and uvs + + for ( let y = 0; y <= heightSegments; y ++ ) { + + const indexRow = []; + + const v = y / heightSegments; + + // calculate the radius of the current row + + const radius = v * ( radiusBottom - radiusTop ) + radiusTop; + + for ( let x = 0; x <= radialSegments; x ++ ) { + + const u = x / radialSegments; + + const theta = u * thetaLength + thetaStart; + + const sinTheta = Math.sin( theta ); + const cosTheta = Math.cos( theta ); + + // vertex + + vertex.x = radius * sinTheta; + vertex.y = - v * height + halfHeight; + vertex.z = radius * cosTheta; + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + normal.set( sinTheta, slope, cosTheta ).normalize(); + normals.push( normal.x, normal.y, normal.z ); + + // uv + + uvs.push( u, 1 - v ); + + // save index of vertex in respective row + + indexRow.push( index ++ ); + + } + + // now save vertices of the row in our index array + + indexArray.push( indexRow ); + + } + + // generate indices + + for ( let x = 0; x < radialSegments; x ++ ) { + + for ( let y = 0; y < heightSegments; y ++ ) { + + // we use the index array to access the correct indices + + const a = indexArray[ y ][ x ]; + const b = indexArray[ y + 1 ][ x ]; + const c = indexArray[ y + 1 ][ x + 1 ]; + const d = indexArray[ y ][ x + 1 ]; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + // update group counter + + groupCount += 6; + + } + + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup( groupStart, groupCount, 0 ); + + // calculate new start value for groups + + groupStart += groupCount; + + } + + function generateCap( top ) { + + // save the index of the first center vertex + const centerIndexStart = index; + + const uv = new Vector2(); + const vertex = new Vector3(); + + let groupCount = 0; + + const radius = ( top === true ) ? radiusTop : radiusBottom; + const sign = ( top === true ) ? 1 : - 1; + + // first we generate the center vertex data of the cap. + // because the geometry needs one set of uvs per face, + // we must generate a center vertex per face/segment + + for ( let x = 1; x <= radialSegments; x ++ ) { + + // vertex + + vertices.push( 0, halfHeight * sign, 0 ); + + // normal + + normals.push( 0, sign, 0 ); + + // uv + + uvs.push( 0.5, 0.5 ); + + // increase index + + index ++; + + } + + // save the index of the last center vertex + const centerIndexEnd = index; + + // now we generate the surrounding vertices, normals and uvs + + for ( let x = 0; x <= radialSegments; x ++ ) { + + const u = x / radialSegments; + const theta = u * thetaLength + thetaStart; + + const cosTheta = Math.cos( theta ); + const sinTheta = Math.sin( theta ); + + // vertex + + vertex.x = radius * sinTheta; + vertex.y = halfHeight * sign; + vertex.z = radius * cosTheta; + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + normals.push( 0, sign, 0 ); + + // uv + + uv.x = ( cosTheta * 0.5 ) + 0.5; + uv.y = ( sinTheta * 0.5 * sign ) + 0.5; + uvs.push( uv.x, uv.y ); + + // increase index + + index ++; + + } + + // generate indices + + for ( let x = 0; x < radialSegments; x ++ ) { + + const c = centerIndexStart + x; + const i = centerIndexEnd + x; + + if ( top === true ) { + + // face top + + indices.push( i, i + 1, c ); + + } else { + + // face bottom + + indices.push( i + 1, i, c ); + + } + + groupCount += 3; + + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup( groupStart, groupCount, top === true ? 1 : 2 ); + + // calculate new start value for groups + + groupStart += groupCount; + + } + + } + + static fromJSON( data ) { + + return new CylinderGeometry( data.radiusTop, data.radiusBottom, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength ); + + } + +} + +class ConeGeometry extends CylinderGeometry { + + constructor( radius = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { + + super( 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ); + + this.type = 'ConeGeometry'; + + this.parameters = { + radius: radius, + height: height, + radialSegments: radialSegments, + heightSegments: heightSegments, + openEnded: openEnded, + thetaStart: thetaStart, + thetaLength: thetaLength + }; + + } + + static fromJSON( data ) { + + return new ConeGeometry( data.radius, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength ); + + } + +} + +class PolyhedronGeometry extends BufferGeometry { + + constructor( vertices = [], indices = [], radius = 1, detail = 0 ) { + + super(); + + this.type = 'PolyhedronGeometry'; + + this.parameters = { + vertices: vertices, + indices: indices, + radius: radius, + detail: detail + }; + + // default buffer data + + const vertexBuffer = []; + const uvBuffer = []; + + // the subdivision creates the vertex buffer data + + subdivide( detail ); + + // all vertices should lie on a conceptual sphere with a given radius + + applyRadius( radius ); + + // finally, create the uv data + + generateUVs(); + + // build non-indexed geometry + + this.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) ); + + if ( detail === 0 ) { + + this.computeVertexNormals(); // flat normals + + } else { + + this.normalizeNormals(); // smooth normals + + } + + // helper functions + + function subdivide( detail ) { + + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + // iterate over all faces and apply a subdivison with the given detail value + + for ( let i = 0; i < indices.length; i += 3 ) { + + // get the vertices of the face + + getVertexByIndex( indices[ i + 0 ], a ); + getVertexByIndex( indices[ i + 1 ], b ); + getVertexByIndex( indices[ i + 2 ], c ); + + // perform subdivision + + subdivideFace( a, b, c, detail ); + + } + + } + + function subdivideFace( a, b, c, detail ) { + + const cols = detail + 1; + + // we use this multidimensional array as a data structure for creating the subdivision + + const v = []; + + // construct all of the vertices for this subdivision + + for ( let i = 0; i <= cols; i ++ ) { + + v[ i ] = []; + + const aj = a.clone().lerp( c, i / cols ); + const bj = b.clone().lerp( c, i / cols ); + + const rows = cols - i; + + for ( let j = 0; j <= rows; j ++ ) { + + if ( j === 0 && i === cols ) { + + v[ i ][ j ] = aj; + + } else { + + v[ i ][ j ] = aj.clone().lerp( bj, j / rows ); + + } + + } + + } + + // construct all of the faces + + for ( let i = 0; i < cols; i ++ ) { + + for ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) { + + const k = Math.floor( j / 2 ); + + if ( j % 2 === 0 ) { + + pushVertex( v[ i ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k ] ); + pushVertex( v[ i ][ k ] ); + + } else { + + pushVertex( v[ i ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k + 1 ] ); + pushVertex( v[ i + 1 ][ k ] ); + + } + + } + + } + + } + + function applyRadius( radius ) { + + const vertex = new Vector3(); + + // iterate over the entire buffer and apply the radius to each vertex + + for ( let i = 0; i < vertexBuffer.length; i += 3 ) { + + vertex.x = vertexBuffer[ i + 0 ]; + vertex.y = vertexBuffer[ i + 1 ]; + vertex.z = vertexBuffer[ i + 2 ]; + + vertex.normalize().multiplyScalar( radius ); + + vertexBuffer[ i + 0 ] = vertex.x; + vertexBuffer[ i + 1 ] = vertex.y; + vertexBuffer[ i + 2 ] = vertex.z; + + } + + } + + function generateUVs() { + + const vertex = new Vector3(); + + for ( let i = 0; i < vertexBuffer.length; i += 3 ) { + + vertex.x = vertexBuffer[ i + 0 ]; + vertex.y = vertexBuffer[ i + 1 ]; + vertex.z = vertexBuffer[ i + 2 ]; + + const u = azimuth( vertex ) / 2 / Math.PI + 0.5; + const v = inclination( vertex ) / Math.PI + 0.5; + uvBuffer.push( u, 1 - v ); + + } + + correctUVs(); + + correctSeam(); + + } + + function correctSeam() { + + // handle case when face straddles the seam, see #3269 + + for ( let i = 0; i < uvBuffer.length; i += 6 ) { + + // uv data of a single face + + const x0 = uvBuffer[ i + 0 ]; + const x1 = uvBuffer[ i + 2 ]; + const x2 = uvBuffer[ i + 4 ]; + + const max = Math.max( x0, x1, x2 ); + const min = Math.min( x0, x1, x2 ); + + // 0.9 is somewhat arbitrary + + if ( max > 0.9 && min < 0.1 ) { + + if ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1; + if ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1; + if ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1; + + } + + } + + } + + function pushVertex( vertex ) { + + vertexBuffer.push( vertex.x, vertex.y, vertex.z ); + + } + + function getVertexByIndex( index, vertex ) { + + const stride = index * 3; + + vertex.x = vertices[ stride + 0 ]; + vertex.y = vertices[ stride + 1 ]; + vertex.z = vertices[ stride + 2 ]; + + } + + function correctUVs() { + + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + const centroid = new Vector3(); + + const uvA = new Vector2(); + const uvB = new Vector2(); + const uvC = new Vector2(); + + for ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) { + + a.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] ); + b.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] ); + c.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] ); + + uvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] ); + uvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] ); + uvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] ); + + centroid.copy( a ).add( b ).add( c ).divideScalar( 3 ); + + const azi = azimuth( centroid ); + + correctUV( uvA, j + 0, a, azi ); + correctUV( uvB, j + 2, b, azi ); + correctUV( uvC, j + 4, c, azi ); + + } + + } + + function correctUV( uv, stride, vector, azimuth ) { + + if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) { + + uvBuffer[ stride ] = uv.x - 1; + + } + + if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) { + + uvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5; + + } + + } + + // Angle around the Y axis, counter-clockwise when looking from above. + + function azimuth( vector ) { + + return Math.atan2( vector.z, - vector.x ); + + } + + + // Angle above the XZ plane. + + function inclination( vector ) { + + return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) ); + + } + + } + + static fromJSON( data ) { + + return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details ); + + } + +} + +class DodecahedronGeometry extends PolyhedronGeometry { + + constructor( radius = 1, detail = 0 ) { + + const t = ( 1 + Math.sqrt( 5 ) ) / 2; + const r = 1 / t; + + const vertices = [ + + // (±1, ±1, ±1) + - 1, - 1, - 1, - 1, - 1, 1, + - 1, 1, - 1, - 1, 1, 1, + 1, - 1, - 1, 1, - 1, 1, + 1, 1, - 1, 1, 1, 1, + + // (0, ±1/φ, ±φ) + 0, - r, - t, 0, - r, t, + 0, r, - t, 0, r, t, + + // (±1/φ, ±φ, 0) + - r, - t, 0, - r, t, 0, + r, - t, 0, r, t, 0, + + // (±φ, 0, ±1/φ) + - t, 0, - r, t, 0, - r, + - t, 0, r, t, 0, r + ]; + + const indices = [ + 3, 11, 7, 3, 7, 15, 3, 15, 13, + 7, 19, 17, 7, 17, 6, 7, 6, 15, + 17, 4, 8, 17, 8, 10, 17, 10, 6, + 8, 0, 16, 8, 16, 2, 8, 2, 10, + 0, 12, 1, 0, 1, 18, 0, 18, 16, + 6, 10, 2, 6, 2, 13, 6, 13, 15, + 2, 16, 18, 2, 18, 3, 2, 3, 13, + 18, 1, 9, 18, 9, 11, 18, 11, 3, + 4, 14, 12, 4, 12, 0, 4, 0, 8, + 11, 9, 5, 11, 5, 19, 11, 19, 7, + 19, 5, 14, 19, 14, 4, 19, 4, 17, + 1, 12, 14, 1, 14, 5, 1, 5, 9 + ]; + + super( vertices, indices, radius, detail ); + + this.type = 'DodecahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail + }; + + } + + static fromJSON( data ) { + + return new DodecahedronGeometry( data.radius, data.detail ); + + } + +} + +const _v0 = new Vector3(); +const _v1$1 = new Vector3(); +const _normal = new Vector3(); +const _triangle = new Triangle(); + +class EdgesGeometry extends BufferGeometry { + + constructor( geometry = null, thresholdAngle = 1 ) { + + super(); + this.type = 'EdgesGeometry'; + + this.parameters = { + geometry: geometry, + thresholdAngle: thresholdAngle + }; + + if ( geometry !== null ) { + + const precisionPoints = 4; + const precision = Math.pow( 10, precisionPoints ); + const thresholdDot = Math.cos( DEG2RAD * thresholdAngle ); + + const indexAttr = geometry.getIndex(); + const positionAttr = geometry.getAttribute( 'position' ); + const indexCount = indexAttr ? indexAttr.count : positionAttr.count; + + const indexArr = [ 0, 0, 0 ]; + const vertKeys = [ 'a', 'b', 'c' ]; + const hashes = new Array( 3 ); + + const edgeData = {}; + const vertices = []; + for ( let i = 0; i < indexCount; i += 3 ) { + + if ( indexAttr ) { + + indexArr[ 0 ] = indexAttr.getX( i ); + indexArr[ 1 ] = indexAttr.getX( i + 1 ); + indexArr[ 2 ] = indexAttr.getX( i + 2 ); + + } else { + + indexArr[ 0 ] = i; + indexArr[ 1 ] = i + 1; + indexArr[ 2 ] = i + 2; + + } + + const { a, b, c } = _triangle; + a.fromBufferAttribute( positionAttr, indexArr[ 0 ] ); + b.fromBufferAttribute( positionAttr, indexArr[ 1 ] ); + c.fromBufferAttribute( positionAttr, indexArr[ 2 ] ); + _triangle.getNormal( _normal ); + + // create hashes for the edge from the vertices + hashes[ 0 ] = `${ Math.round( a.x * precision ) },${ Math.round( a.y * precision ) },${ Math.round( a.z * precision ) }`; + hashes[ 1 ] = `${ Math.round( b.x * precision ) },${ Math.round( b.y * precision ) },${ Math.round( b.z * precision ) }`; + hashes[ 2 ] = `${ Math.round( c.x * precision ) },${ Math.round( c.y * precision ) },${ Math.round( c.z * precision ) }`; + + // skip degenerate triangles + if ( hashes[ 0 ] === hashes[ 1 ] || hashes[ 1 ] === hashes[ 2 ] || hashes[ 2 ] === hashes[ 0 ] ) { + + continue; + + } + + // iterate over every edge + for ( let j = 0; j < 3; j ++ ) { + + // get the first and next vertex making up the edge + const jNext = ( j + 1 ) % 3; + const vecHash0 = hashes[ j ]; + const vecHash1 = hashes[ jNext ]; + const v0 = _triangle[ vertKeys[ j ] ]; + const v1 = _triangle[ vertKeys[ jNext ] ]; + + const hash = `${ vecHash0 }_${ vecHash1 }`; + const reverseHash = `${ vecHash1 }_${ vecHash0 }`; + + if ( reverseHash in edgeData && edgeData[ reverseHash ] ) { + + // if we found a sibling edge add it into the vertex array if + // it meets the angle threshold and delete the edge from the map. + if ( _normal.dot( edgeData[ reverseHash ].normal ) <= thresholdDot ) { + + vertices.push( v0.x, v0.y, v0.z ); + vertices.push( v1.x, v1.y, v1.z ); + + } + + edgeData[ reverseHash ] = null; + + } else if ( ! ( hash in edgeData ) ) { + + // if we've already got an edge here then skip adding a new one + edgeData[ hash ] = { + + index0: indexArr[ j ], + index1: indexArr[ jNext ], + normal: _normal.clone(), + + }; + + } + + } + + } + + // iterate over all remaining, unmatched edges and add them to the vertex array + for ( const key in edgeData ) { + + if ( edgeData[ key ] ) { + + const { index0, index1 } = edgeData[ key ]; + _v0.fromBufferAttribute( positionAttr, index0 ); + _v1$1.fromBufferAttribute( positionAttr, index1 ); + + vertices.push( _v0.x, _v0.y, _v0.z ); + vertices.push( _v1$1.x, _v1$1.y, _v1$1.z ); + + } + + } + + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + + } + + } + +} + +/** + * Extensible curve object. + * + * Some common of curve methods: + * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget ) + * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget ) + * .getPoints(), .getSpacedPoints() + * .getLength() + * .updateArcLengths() + * + * This following curves inherit from THREE.Curve: + * + * -- 2D curves -- + * THREE.ArcCurve + * THREE.CubicBezierCurve + * THREE.EllipseCurve + * THREE.LineCurve + * THREE.QuadraticBezierCurve + * THREE.SplineCurve + * + * -- 3D curves -- + * THREE.CatmullRomCurve3 + * THREE.CubicBezierCurve3 + * THREE.LineCurve3 + * THREE.QuadraticBezierCurve3 + * + * A series of curves can be represented as a THREE.CurvePath. + * + **/ + +class Curve { + + constructor() { + + this.type = 'Curve'; + + this.arcLengthDivisions = 200; + + } + + // Virtual base class method to overwrite and implement in subclasses + // - t [0 .. 1] + + getPoint( /* t, optionalTarget */ ) { + + console.warn( 'THREE.Curve: .getPoint() not implemented.' ); + return null; + + } + + // Get point at relative position in curve according to arc length + // - u [0 .. 1] + + getPointAt( u, optionalTarget ) { + + const t = this.getUtoTmapping( u ); + return this.getPoint( t, optionalTarget ); + + } + + // Get sequence of points using getPoint( t ) + + getPoints( divisions = 5 ) { + + const points = []; + + for ( let d = 0; d <= divisions; d ++ ) { + + points.push( this.getPoint( d / divisions ) ); + + } + + return points; + + } + + // Get sequence of points using getPointAt( u ) + + getSpacedPoints( divisions = 5 ) { + + const points = []; + + for ( let d = 0; d <= divisions; d ++ ) { + + points.push( this.getPointAt( d / divisions ) ); + + } + + return points; + + } + + // Get total curve arc length + + getLength() { + + const lengths = this.getLengths(); + return lengths[ lengths.length - 1 ]; + + } + + // Get list of cumulative segment lengths + + getLengths( divisions = this.arcLengthDivisions ) { + + if ( this.cacheArcLengths && + ( this.cacheArcLengths.length === divisions + 1 ) && + ! this.needsUpdate ) { + + return this.cacheArcLengths; + + } + + this.needsUpdate = false; + + const cache = []; + let current, last = this.getPoint( 0 ); + let sum = 0; + + cache.push( 0 ); + + for ( let p = 1; p <= divisions; p ++ ) { + + current = this.getPoint( p / divisions ); + sum += current.distanceTo( last ); + cache.push( sum ); + last = current; + + } + + this.cacheArcLengths = cache; + + return cache; // { sums: cache, sum: sum }; Sum is in the last element. + + } + + updateArcLengths() { + + this.needsUpdate = true; + this.getLengths(); + + } + + // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant + + getUtoTmapping( u, distance ) { + + const arcLengths = this.getLengths(); + + let i = 0; + const il = arcLengths.length; + + let targetArcLength; // The targeted u distance value to get + + if ( distance ) { + + targetArcLength = distance; + + } else { + + targetArcLength = u * arcLengths[ il - 1 ]; + + } + + // binary search for the index with largest value smaller than target u distance + + let low = 0, high = il - 1, comparison; + + while ( low <= high ) { + + i = Math.floor( low + ( high - low ) / 2 ); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats + + comparison = arcLengths[ i ] - targetArcLength; + + if ( comparison < 0 ) { + + low = i + 1; + + } else if ( comparison > 0 ) { + + high = i - 1; + + } else { + + high = i; + break; + + // DONE + + } + + } + + i = high; + + if ( arcLengths[ i ] === targetArcLength ) { + + return i / ( il - 1 ); + + } + + // we could get finer grain at lengths, or use simple interpolation between two points + + const lengthBefore = arcLengths[ i ]; + const lengthAfter = arcLengths[ i + 1 ]; + + const segmentLength = lengthAfter - lengthBefore; + + // determine where we are between the 'before' and 'after' points + + const segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength; + + // add that fractional amount to t + + const t = ( i + segmentFraction ) / ( il - 1 ); + + return t; + + } + + // Returns a unit vector tangent at t + // In case any sub curve does not implement its tangent derivation, + // 2 points a small delta apart will be used to find its gradient + // which seems to give a reasonable approximation + + getTangent( t, optionalTarget ) { + + const delta = 0.0001; + let t1 = t - delta; + let t2 = t + delta; + + // Capping in case of danger + + if ( t1 < 0 ) t1 = 0; + if ( t2 > 1 ) t2 = 1; + + const pt1 = this.getPoint( t1 ); + const pt2 = this.getPoint( t2 ); + + const tangent = optionalTarget || ( ( pt1.isVector2 ) ? new Vector2() : new Vector3() ); + + tangent.copy( pt2 ).sub( pt1 ).normalize(); + + return tangent; + + } + + getTangentAt( u, optionalTarget ) { + + const t = this.getUtoTmapping( u ); + return this.getTangent( t, optionalTarget ); + + } + + computeFrenetFrames( segments, closed ) { + + // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf + + const normal = new Vector3(); + + const tangents = []; + const normals = []; + const binormals = []; + + const vec = new Vector3(); + const mat = new Matrix4(); + + // compute the tangent vectors for each segment on the curve + + for ( let i = 0; i <= segments; i ++ ) { + + const u = i / segments; + + tangents[ i ] = this.getTangentAt( u, new Vector3() ); + + } + + // select an initial normal vector perpendicular to the first tangent vector, + // and in the direction of the minimum tangent xyz component + + normals[ 0 ] = new Vector3(); + binormals[ 0 ] = new Vector3(); + let min = Number.MAX_VALUE; + const tx = Math.abs( tangents[ 0 ].x ); + const ty = Math.abs( tangents[ 0 ].y ); + const tz = Math.abs( tangents[ 0 ].z ); + + if ( tx <= min ) { + + min = tx; + normal.set( 1, 0, 0 ); + + } + + if ( ty <= min ) { + + min = ty; + normal.set( 0, 1, 0 ); + + } + + if ( tz <= min ) { + + normal.set( 0, 0, 1 ); + + } + + vec.crossVectors( tangents[ 0 ], normal ).normalize(); + + normals[ 0 ].crossVectors( tangents[ 0 ], vec ); + binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] ); + + + // compute the slowly-varying normal and binormal vectors for each segment on the curve + + for ( let i = 1; i <= segments; i ++ ) { + + normals[ i ] = normals[ i - 1 ].clone(); + + binormals[ i ] = binormals[ i - 1 ].clone(); + + vec.crossVectors( tangents[ i - 1 ], tangents[ i ] ); + + if ( vec.length() > Number.EPSILON ) { + + vec.normalize(); + + const theta = Math.acos( clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors + + normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) ); + + } + + binormals[ i ].crossVectors( tangents[ i ], normals[ i ] ); + + } + + // if the curve is closed, postprocess the vectors so the first and last normal vectors are the same + + if ( closed === true ) { + + let theta = Math.acos( clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) ); + theta /= segments; + + if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) { + + theta = - theta; + + } + + for ( let i = 1; i <= segments; i ++ ) { + + // twist a little... + normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) ); + binormals[ i ].crossVectors( tangents[ i ], normals[ i ] ); + + } + + } + + return { + tangents: tangents, + normals: normals, + binormals: binormals + }; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( source ) { + + this.arcLengthDivisions = source.arcLengthDivisions; + + return this; + + } + + toJSON() { + + const data = { + metadata: { + version: 4.5, + type: 'Curve', + generator: 'Curve.toJSON' + } + }; + + data.arcLengthDivisions = this.arcLengthDivisions; + data.type = this.type; + + return data; + + } + + fromJSON( json ) { + + this.arcLengthDivisions = json.arcLengthDivisions; + + return this; + + } + +} + +class EllipseCurve extends Curve { + + constructor( aX = 0, aY = 0, xRadius = 1, yRadius = 1, aStartAngle = 0, aEndAngle = Math.PI * 2, aClockwise = false, aRotation = 0 ) { + + super(); + + this.type = 'EllipseCurve'; + + this.aX = aX; + this.aY = aY; + + this.xRadius = xRadius; + this.yRadius = yRadius; + + this.aStartAngle = aStartAngle; + this.aEndAngle = aEndAngle; + + this.aClockwise = aClockwise; + + this.aRotation = aRotation; + + } + + getPoint( t, optionalTarget ) { + + const point = optionalTarget || new Vector2(); + + const twoPi = Math.PI * 2; + let deltaAngle = this.aEndAngle - this.aStartAngle; + const samePoints = Math.abs( deltaAngle ) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while ( deltaAngle < 0 ) deltaAngle += twoPi; + while ( deltaAngle > twoPi ) deltaAngle -= twoPi; + + if ( deltaAngle < Number.EPSILON ) { + + if ( samePoints ) { + + deltaAngle = 0; + + } else { + + deltaAngle = twoPi; + + } + + } + + if ( this.aClockwise === true && ! samePoints ) { + + if ( deltaAngle === twoPi ) { + + deltaAngle = - twoPi; + + } else { + + deltaAngle = deltaAngle - twoPi; + + } + + } + + const angle = this.aStartAngle + t * deltaAngle; + let x = this.aX + this.xRadius * Math.cos( angle ); + let y = this.aY + this.yRadius * Math.sin( angle ); + + if ( this.aRotation !== 0 ) { + + const cos = Math.cos( this.aRotation ); + const sin = Math.sin( this.aRotation ); + + const tx = x - this.aX; + const ty = y - this.aY; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.aX; + y = tx * sin + ty * cos + this.aY; + + } + + return point.set( x, y ); + + } + + copy( source ) { + + super.copy( source ); + + this.aX = source.aX; + this.aY = source.aY; + + this.xRadius = source.xRadius; + this.yRadius = source.yRadius; + + this.aStartAngle = source.aStartAngle; + this.aEndAngle = source.aEndAngle; + + this.aClockwise = source.aClockwise; + + this.aRotation = source.aRotation; + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.aX = this.aX; + data.aY = this.aY; + + data.xRadius = this.xRadius; + data.yRadius = this.yRadius; + + data.aStartAngle = this.aStartAngle; + data.aEndAngle = this.aEndAngle; + + data.aClockwise = this.aClockwise; + + data.aRotation = this.aRotation; + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.aX = json.aX; + this.aY = json.aY; + + this.xRadius = json.xRadius; + this.yRadius = json.yRadius; + + this.aStartAngle = json.aStartAngle; + this.aEndAngle = json.aEndAngle; + + this.aClockwise = json.aClockwise; + + this.aRotation = json.aRotation; + + return this; + + } + +} + +EllipseCurve.prototype.isEllipseCurve = true; + +class ArcCurve extends EllipseCurve { + + constructor( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { + + super( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); + + this.type = 'ArcCurve'; + + } + +} + +ArcCurve.prototype.isArcCurve = true; + +/** + * Centripetal CatmullRom Curve - which is useful for avoiding + * cusps and self-intersections in non-uniform catmull rom curves. + * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf + * + * curve.type accepts centripetal(default), chordal and catmullrom + * curve.tension is used for catmullrom which defaults to 0.5 + */ + + +/* +Based on an optimized c++ solution in + - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/ + - http://ideone.com/NoEbVM + +This CubicPoly class could be used for reusing some variables and calculations, +but for three.js curve use, it could be possible inlined and flatten into a single function call +which can be placed in CurveUtils. +*/ + +function CubicPoly() { + + let c0 = 0, c1 = 0, c2 = 0, c3 = 0; + + /* + * Compute coefficients for a cubic polynomial + * p(s) = c0 + c1*s + c2*s^2 + c3*s^3 + * such that + * p(0) = x0, p(1) = x1 + * and + * p'(0) = t0, p'(1) = t1. + */ + function init( x0, x1, t0, t1 ) { + + c0 = x0; + c1 = t0; + c2 = - 3 * x0 + 3 * x1 - 2 * t0 - t1; + c3 = 2 * x0 - 2 * x1 + t0 + t1; + + } + + return { + + initCatmullRom: function ( x0, x1, x2, x3, tension ) { + + init( x1, x2, tension * ( x2 - x0 ), tension * ( x3 - x1 ) ); + + }, + + initNonuniformCatmullRom: function ( x0, x1, x2, x3, dt0, dt1, dt2 ) { + + // compute tangents when parameterized in [t1,t2] + let t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1; + let t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2; + + // rescale tangents for parametrization in [0,1] + t1 *= dt1; + t2 *= dt1; + + init( x1, x2, t1, t2 ); + + }, + + calc: function ( t ) { + + const t2 = t * t; + const t3 = t2 * t; + return c0 + c1 * t + c2 * t2 + c3 * t3; + + } + + }; + +} + +// + +const tmp = new Vector3(); +const px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly(); + +class CatmullRomCurve3 extends Curve { + + constructor( points = [], closed = false, curveType = 'centripetal', tension = 0.5 ) { + + super(); + + this.type = 'CatmullRomCurve3'; + + this.points = points; + this.closed = closed; + this.curveType = curveType; + this.tension = tension; + + } + + getPoint( t, optionalTarget = new Vector3() ) { + + const point = optionalTarget; + + const points = this.points; + const l = points.length; + + const p = ( l - ( this.closed ? 0 : 1 ) ) * t; + let intPoint = Math.floor( p ); + let weight = p - intPoint; + + if ( this.closed ) { + + intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / l ) + 1 ) * l; + + } else if ( weight === 0 && intPoint === l - 1 ) { + + intPoint = l - 2; + weight = 1; + + } + + let p0, p3; // 4 points (p1 & p2 defined below) + + if ( this.closed || intPoint > 0 ) { + + p0 = points[ ( intPoint - 1 ) % l ]; + + } else { + + // extrapolate first point + tmp.subVectors( points[ 0 ], points[ 1 ] ).add( points[ 0 ] ); + p0 = tmp; + + } + + const p1 = points[ intPoint % l ]; + const p2 = points[ ( intPoint + 1 ) % l ]; + + if ( this.closed || intPoint + 2 < l ) { + + p3 = points[ ( intPoint + 2 ) % l ]; + + } else { + + // extrapolate last point + tmp.subVectors( points[ l - 1 ], points[ l - 2 ] ).add( points[ l - 1 ] ); + p3 = tmp; + + } + + if ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) { + + // init Centripetal / Chordal Catmull-Rom + const pow = this.curveType === 'chordal' ? 0.5 : 0.25; + let dt0 = Math.pow( p0.distanceToSquared( p1 ), pow ); + let dt1 = Math.pow( p1.distanceToSquared( p2 ), pow ); + let dt2 = Math.pow( p2.distanceToSquared( p3 ), pow ); + + // safety check for repeated points + if ( dt1 < 1e-4 ) dt1 = 1.0; + if ( dt0 < 1e-4 ) dt0 = dt1; + if ( dt2 < 1e-4 ) dt2 = dt1; + + px.initNonuniformCatmullRom( p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2 ); + py.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 ); + pz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 ); + + } else if ( this.curveType === 'catmullrom' ) { + + px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension ); + py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension ); + pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension ); + + } + + point.set( + px.calc( weight ), + py.calc( weight ), + pz.calc( weight ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.points = []; + + for ( let i = 0, l = source.points.length; i < l; i ++ ) { + + const point = source.points[ i ]; + + this.points.push( point.clone() ); + + } + + this.closed = source.closed; + this.curveType = source.curveType; + this.tension = source.tension; + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.points = []; + + for ( let i = 0, l = this.points.length; i < l; i ++ ) { + + const point = this.points[ i ]; + data.points.push( point.toArray() ); + + } + + data.closed = this.closed; + data.curveType = this.curveType; + data.tension = this.tension; + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.points = []; + + for ( let i = 0, l = json.points.length; i < l; i ++ ) { + + const point = json.points[ i ]; + this.points.push( new Vector3().fromArray( point ) ); + + } + + this.closed = json.closed; + this.curveType = json.curveType; + this.tension = json.tension; + + return this; + + } + +} + +CatmullRomCurve3.prototype.isCatmullRomCurve3 = true; + +/** + * Bezier Curves formulas obtained from + * https://en.wikipedia.org/wiki/B%C3%A9zier_curve + */ + +function CatmullRom( t, p0, p1, p2, p3 ) { + + const v0 = ( p2 - p0 ) * 0.5; + const v1 = ( p3 - p1 ) * 0.5; + const t2 = t * t; + const t3 = t * t2; + return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1; + +} + +// + +function QuadraticBezierP0( t, p ) { + + const k = 1 - t; + return k * k * p; + +} + +function QuadraticBezierP1( t, p ) { + + return 2 * ( 1 - t ) * t * p; + +} + +function QuadraticBezierP2( t, p ) { + + return t * t * p; + +} + +function QuadraticBezier( t, p0, p1, p2 ) { + + return QuadraticBezierP0( t, p0 ) + QuadraticBezierP1( t, p1 ) + + QuadraticBezierP2( t, p2 ); + +} + +// + +function CubicBezierP0( t, p ) { + + const k = 1 - t; + return k * k * k * p; + +} + +function CubicBezierP1( t, p ) { + + const k = 1 - t; + return 3 * k * k * t * p; + +} + +function CubicBezierP2( t, p ) { + + return 3 * ( 1 - t ) * t * t * p; + +} + +function CubicBezierP3( t, p ) { + + return t * t * t * p; + +} + +function CubicBezier( t, p0, p1, p2, p3 ) { + + return CubicBezierP0( t, p0 ) + CubicBezierP1( t, p1 ) + CubicBezierP2( t, p2 ) + + CubicBezierP3( t, p3 ); + +} + +class CubicBezierCurve extends Curve { + + constructor( v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2() ) { + + super(); + + this.type = 'CubicBezierCurve'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + + } + + getPoint( t, optionalTarget = new Vector2() ) { + + const point = optionalTarget; + + const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; + + point.set( + CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), + CubicBezier( t, v0.y, v1.y, v2.y, v3.y ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.v0.copy( source.v0 ); + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + this.v3.copy( source.v3 ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + data.v3 = this.v3.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.v0.fromArray( json.v0 ); + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + this.v3.fromArray( json.v3 ); + + return this; + + } + +} + +CubicBezierCurve.prototype.isCubicBezierCurve = true; + +class CubicBezierCurve3 extends Curve { + + constructor( v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3(), v3 = new Vector3() ) { + + super(); + + this.type = 'CubicBezierCurve3'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + + } + + getPoint( t, optionalTarget = new Vector3() ) { + + const point = optionalTarget; + + const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; + + point.set( + CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), + CubicBezier( t, v0.y, v1.y, v2.y, v3.y ), + CubicBezier( t, v0.z, v1.z, v2.z, v3.z ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.v0.copy( source.v0 ); + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + this.v3.copy( source.v3 ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + data.v3 = this.v3.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.v0.fromArray( json.v0 ); + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + this.v3.fromArray( json.v3 ); + + return this; + + } + +} + +CubicBezierCurve3.prototype.isCubicBezierCurve3 = true; + +class LineCurve extends Curve { + + constructor( v1 = new Vector2(), v2 = new Vector2() ) { + + super(); + + this.type = 'LineCurve'; + + this.v1 = v1; + this.v2 = v2; + + } + + getPoint( t, optionalTarget = new Vector2() ) { + + const point = optionalTarget; + + if ( t === 1 ) { + + point.copy( this.v2 ); + + } else { + + point.copy( this.v2 ).sub( this.v1 ); + point.multiplyScalar( t ).add( this.v1 ); + + } + + return point; + + } + + // Line curve is linear, so we can overwrite default getPointAt + getPointAt( u, optionalTarget ) { + + return this.getPoint( u, optionalTarget ); + + } + + getTangent( t, optionalTarget ) { + + const tangent = optionalTarget || new Vector2(); + + tangent.copy( this.v2 ).sub( this.v1 ).normalize(); + + return tangent; + + } + + copy( source ) { + + super.copy( source ); + + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + + return this; + + } + +} + +LineCurve.prototype.isLineCurve = true; + +class LineCurve3 extends Curve { + + constructor( v1 = new Vector3(), v2 = new Vector3() ) { + + super(); + + this.type = 'LineCurve3'; + this.isLineCurve3 = true; + + this.v1 = v1; + this.v2 = v2; + + } + getPoint( t, optionalTarget = new Vector3() ) { + + const point = optionalTarget; + + if ( t === 1 ) { + + point.copy( this.v2 ); + + } else { + + point.copy( this.v2 ).sub( this.v1 ); + point.multiplyScalar( t ).add( this.v1 ); + + } + + return point; + + } + // Line curve is linear, so we can overwrite default getPointAt + getPointAt( u, optionalTarget ) { + + return this.getPoint( u, optionalTarget ); + + } + copy( source ) { + + super.copy( source ); + + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + + return this; + + } + toJSON() { + + const data = super.toJSON(); + + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + + } + fromJSON( json ) { + + super.fromJSON( json ); + + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + + return this; + + } + +} + +class QuadraticBezierCurve extends Curve { + + constructor( v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2() ) { + + super(); + + this.type = 'QuadraticBezierCurve'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + + } + + getPoint( t, optionalTarget = new Vector2() ) { + + const point = optionalTarget; + + const v0 = this.v0, v1 = this.v1, v2 = this.v2; + + point.set( + QuadraticBezier( t, v0.x, v1.x, v2.x ), + QuadraticBezier( t, v0.y, v1.y, v2.y ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.v0.copy( source.v0 ); + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.v0.fromArray( json.v0 ); + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + + return this; + + } + +} + +QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true; + +class QuadraticBezierCurve3 extends Curve { + + constructor( v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3() ) { + + super(); + + this.type = 'QuadraticBezierCurve3'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + + } + + getPoint( t, optionalTarget = new Vector3() ) { + + const point = optionalTarget; + + const v0 = this.v0, v1 = this.v1, v2 = this.v2; + + point.set( + QuadraticBezier( t, v0.x, v1.x, v2.x ), + QuadraticBezier( t, v0.y, v1.y, v2.y ), + QuadraticBezier( t, v0.z, v1.z, v2.z ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.v0.copy( source.v0 ); + this.v1.copy( source.v1 ); + this.v2.copy( source.v2 ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.v0.fromArray( json.v0 ); + this.v1.fromArray( json.v1 ); + this.v2.fromArray( json.v2 ); + + return this; + + } + +} + +QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true; + +class SplineCurve extends Curve { + + constructor( points = [] ) { + + super(); + + this.type = 'SplineCurve'; + + this.points = points; + + } + + getPoint( t, optionalTarget = new Vector2() ) { + + const point = optionalTarget; + + const points = this.points; + const p = ( points.length - 1 ) * t; + + const intPoint = Math.floor( p ); + const weight = p - intPoint; + + const p0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ]; + const p1 = points[ intPoint ]; + const p2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ]; + const p3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ]; + + point.set( + CatmullRom( weight, p0.x, p1.x, p2.x, p3.x ), + CatmullRom( weight, p0.y, p1.y, p2.y, p3.y ) + ); + + return point; + + } + + copy( source ) { + + super.copy( source ); + + this.points = []; + + for ( let i = 0, l = source.points.length; i < l; i ++ ) { + + const point = source.points[ i ]; + + this.points.push( point.clone() ); + + } + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.points = []; + + for ( let i = 0, l = this.points.length; i < l; i ++ ) { + + const point = this.points[ i ]; + data.points.push( point.toArray() ); + + } + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.points = []; + + for ( let i = 0, l = json.points.length; i < l; i ++ ) { + + const point = json.points[ i ]; + this.points.push( new Vector2().fromArray( point ) ); + + } + + return this; + + } + +} + +SplineCurve.prototype.isSplineCurve = true; + +var Curves = /*#__PURE__*/Object.freeze({ + __proto__: null, + ArcCurve: ArcCurve, + CatmullRomCurve3: CatmullRomCurve3, + CubicBezierCurve: CubicBezierCurve, + CubicBezierCurve3: CubicBezierCurve3, + EllipseCurve: EllipseCurve, + LineCurve: LineCurve, + LineCurve3: LineCurve3, + QuadraticBezierCurve: QuadraticBezierCurve, + QuadraticBezierCurve3: QuadraticBezierCurve3, + SplineCurve: SplineCurve +}); + +/************************************************************** + * Curved Path - a curve path is simply a array of connected + * curves, but retains the api of a curve + **************************************************************/ + +class CurvePath extends Curve { + + constructor() { + + super(); + + this.type = 'CurvePath'; + + this.curves = []; + this.autoClose = false; // Automatically closes the path + + } + + add( curve ) { + + this.curves.push( curve ); + + } + + closePath() { + + // Add a line curve if start and end of lines are not connected + const startPoint = this.curves[ 0 ].getPoint( 0 ); + const endPoint = this.curves[ this.curves.length - 1 ].getPoint( 1 ); + + if ( ! startPoint.equals( endPoint ) ) { + + this.curves.push( new LineCurve( endPoint, startPoint ) ); + + } + + } + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + getPoint( t, optionalTarget ) { + + const d = t * this.getLength(); + const curveLengths = this.getCurveLengths(); + let i = 0; + + // To think about boundaries points. + + while ( i < curveLengths.length ) { + + if ( curveLengths[ i ] >= d ) { + + const diff = curveLengths[ i ] - d; + const curve = this.curves[ i ]; + + const segmentLength = curve.getLength(); + const u = segmentLength === 0 ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt( u, optionalTarget ); + + } + + i ++; + + } + + return null; + + // loop where sum != 0, sum > d , sum+1 1 && ! points[ points.length - 1 ].equals( points[ 0 ] ) ) { + + points.push( points[ 0 ] ); + + } + + return points; + + } + + copy( source ) { + + super.copy( source ); + + this.curves = []; + + for ( let i = 0, l = source.curves.length; i < l; i ++ ) { + + const curve = source.curves[ i ]; + + this.curves.push( curve.clone() ); + + } + + this.autoClose = source.autoClose; + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.autoClose = this.autoClose; + data.curves = []; + + for ( let i = 0, l = this.curves.length; i < l; i ++ ) { + + const curve = this.curves[ i ]; + data.curves.push( curve.toJSON() ); + + } + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.autoClose = json.autoClose; + this.curves = []; + + for ( let i = 0, l = json.curves.length; i < l; i ++ ) { + + const curve = json.curves[ i ]; + this.curves.push( new Curves[ curve.type ]().fromJSON( curve ) ); + + } + + return this; + + } + +} + +class Path extends CurvePath { + + constructor( points ) { + + super(); + this.type = 'Path'; + + this.currentPoint = new Vector2(); + + if ( points ) { + + this.setFromPoints( points ); + + } + + } + + setFromPoints( points ) { + + this.moveTo( points[ 0 ].x, points[ 0 ].y ); + + for ( let i = 1, l = points.length; i < l; i ++ ) { + + this.lineTo( points[ i ].x, points[ i ].y ); + + } + + return this; + + } + + moveTo( x, y ) { + + this.currentPoint.set( x, y ); // TODO consider referencing vectors instead of copying? + + return this; + + } + + lineTo( x, y ) { + + const curve = new LineCurve( this.currentPoint.clone(), new Vector2( x, y ) ); + this.curves.push( curve ); + + this.currentPoint.set( x, y ); + + return this; + + } + + quadraticCurveTo( aCPx, aCPy, aX, aY ) { + + const curve = new QuadraticBezierCurve( + this.currentPoint.clone(), + new Vector2( aCPx, aCPy ), + new Vector2( aX, aY ) + ); + + this.curves.push( curve ); + + this.currentPoint.set( aX, aY ); + + return this; + + } + + bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) { + + const curve = new CubicBezierCurve( + this.currentPoint.clone(), + new Vector2( aCP1x, aCP1y ), + new Vector2( aCP2x, aCP2y ), + new Vector2( aX, aY ) + ); + + this.curves.push( curve ); + + this.currentPoint.set( aX, aY ); + + return this; + + } + + splineThru( pts /*Array of Vector*/ ) { + + const npts = [ this.currentPoint.clone() ].concat( pts ); + + const curve = new SplineCurve( npts ); + this.curves.push( curve ); + + this.currentPoint.copy( pts[ pts.length - 1 ] ); + + return this; + + } + + arc( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { + + const x0 = this.currentPoint.x; + const y0 = this.currentPoint.y; + + this.absarc( aX + x0, aY + y0, aRadius, + aStartAngle, aEndAngle, aClockwise ); + + return this; + + } + + absarc( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { + + this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); + + return this; + + } + + ellipse( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) { + + const x0 = this.currentPoint.x; + const y0 = this.currentPoint.y; + + this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ); + + return this; + + } + + absellipse( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) { + + const curve = new EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ); + + if ( this.curves.length > 0 ) { + + // if a previous curve is present, attempt to join + const firstPoint = curve.getPoint( 0 ); + + if ( ! firstPoint.equals( this.currentPoint ) ) { + + this.lineTo( firstPoint.x, firstPoint.y ); + + } + + } + + this.curves.push( curve ); + + const lastPoint = curve.getPoint( 1 ); + this.currentPoint.copy( lastPoint ); + + return this; + + } + + copy( source ) { + + super.copy( source ); + + this.currentPoint.copy( source.currentPoint ); + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.currentPoint = this.currentPoint.toArray(); + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.currentPoint.fromArray( json.currentPoint ); + + return this; + + } + +} + +class Shape extends Path { + + constructor( points ) { + + super( points ); + + this.uuid = generateUUID(); + + this.type = 'Shape'; + + this.holes = []; + + } + + getPointsHoles( divisions ) { + + const holesPts = []; + + for ( let i = 0, l = this.holes.length; i < l; i ++ ) { + + holesPts[ i ] = this.holes[ i ].getPoints( divisions ); + + } + + return holesPts; + + } + + // get points of shape and holes (keypoints based on segments parameter) + + extractPoints( divisions ) { + + return { + + shape: this.getPoints( divisions ), + holes: this.getPointsHoles( divisions ) + + }; + + } + + copy( source ) { + + super.copy( source ); + + this.holes = []; + + for ( let i = 0, l = source.holes.length; i < l; i ++ ) { + + const hole = source.holes[ i ]; + + this.holes.push( hole.clone() ); + + } + + return this; + + } + + toJSON() { + + const data = super.toJSON(); + + data.uuid = this.uuid; + data.holes = []; + + for ( let i = 0, l = this.holes.length; i < l; i ++ ) { + + const hole = this.holes[ i ]; + data.holes.push( hole.toJSON() ); + + } + + return data; + + } + + fromJSON( json ) { + + super.fromJSON( json ); + + this.uuid = json.uuid; + this.holes = []; + + for ( let i = 0, l = json.holes.length; i < l; i ++ ) { + + const hole = json.holes[ i ]; + this.holes.push( new Path().fromJSON( hole ) ); + + } + + return this; + + } + +} + +/** + * Port from https://github.com/mapbox/earcut (v2.2.2) + */ + +const Earcut = { + + triangulate: function ( data, holeIndices, dim = 2 ) { + + const hasHoles = holeIndices && holeIndices.length; + const outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length; + let outerNode = linkedList( data, 0, outerLen, dim, true ); + const triangles = []; + + if ( ! outerNode || outerNode.next === outerNode.prev ) return triangles; + + let minX, minY, maxX, maxY, x, y, invSize; + + if ( hasHoles ) outerNode = eliminateHoles( data, holeIndices, outerNode, dim ); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if ( data.length > 80 * dim ) { + + minX = maxX = data[ 0 ]; + minY = maxY = data[ 1 ]; + + for ( let i = dim; i < outerLen; i += dim ) { + + x = data[ i ]; + y = data[ i + 1 ]; + if ( x < minX ) minX = x; + if ( y < minY ) minY = y; + if ( x > maxX ) maxX = x; + if ( y > maxY ) maxY = y; + + } + + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max( maxX - minX, maxY - minY ); + invSize = invSize !== 0 ? 1 / invSize : 0; + + } + + earcutLinked( outerNode, triangles, dim, minX, minY, invSize ); + + return triangles; + + } + +}; + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList( data, start, end, dim, clockwise ) { + + let i, last; + + if ( clockwise === ( signedArea( data, start, end, dim ) > 0 ) ) { + + for ( i = start; i < end; i += dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last ); + + } else { + + for ( i = end - dim; i >= start; i -= dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last ); + + } + + if ( last && equals( last, last.next ) ) { + + removeNode( last ); + last = last.next; + + } + + return last; + +} + +// eliminate colinear or duplicate points +function filterPoints( start, end ) { + + if ( ! start ) return start; + if ( ! end ) end = start; + + let p = start, + again; + do { + + again = false; + + if ( ! p.steiner && ( equals( p, p.next ) || area( p.prev, p, p.next ) === 0 ) ) { + + removeNode( p ); + p = end = p.prev; + if ( p === p.next ) break; + again = true; + + } else { + + p = p.next; + + } + + } while ( again || p !== end ); + + return end; + +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) { + + if ( ! ear ) return; + + // interlink polygon nodes in z-order + if ( ! pass && invSize ) indexCurve( ear, minX, minY, invSize ); + + let stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while ( ear.prev !== ear.next ) { + + prev = ear.prev; + next = ear.next; + + if ( invSize ? isEarHashed( ear, minX, minY, invSize ) : isEar( ear ) ) { + + // cut off the triangle + triangles.push( prev.i / dim ); + triangles.push( ear.i / dim ); + triangles.push( next.i / dim ); + + removeNode( ear ); + + // skipping the next vertex leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if ( ear === stop ) { + + // try filtering points and slicing again + if ( ! pass ) { + + earcutLinked( filterPoints( ear ), triangles, dim, minX, minY, invSize, 1 ); + + // if this didn't work, try curing all small self-intersections locally + + } else if ( pass === 1 ) { + + ear = cureLocalIntersections( filterPoints( ear ), triangles, dim ); + earcutLinked( ear, triangles, dim, minX, minY, invSize, 2 ); + + // as a last resort, try splitting the remaining polygon into two + + } else if ( pass === 2 ) { + + splitEarcut( ear, triangles, dim, minX, minY, invSize ); + + } + + break; + + } + + } + +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar( ear ) { + + const a = ear.prev, + b = ear, + c = ear.next; + + if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + let p = ear.next.next; + + while ( p !== ear.prev ) { + + if ( pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) && + area( p.prev, p, p.next ) >= 0 ) return false; + p = p.next; + + } + + return true; + +} + +function isEarHashed( ear, minX, minY, invSize ) { + + const a = ear.prev, + b = ear, + c = ear.next; + + if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + const minTX = a.x < b.x ? ( a.x < c.x ? a.x : c.x ) : ( b.x < c.x ? b.x : c.x ), + minTY = a.y < b.y ? ( a.y < c.y ? a.y : c.y ) : ( b.y < c.y ? b.y : c.y ), + maxTX = a.x > b.x ? ( a.x > c.x ? a.x : c.x ) : ( b.x > c.x ? b.x : c.x ), + maxTY = a.y > b.y ? ( a.y > c.y ? a.y : c.y ) : ( b.y > c.y ? b.y : c.y ); + + // z-order range for the current triangle bbox; + const minZ = zOrder( minTX, minTY, minX, minY, invSize ), + maxZ = zOrder( maxTX, maxTY, minX, minY, invSize ); + + let p = ear.prevZ, + n = ear.nextZ; + + // look for points inside the triangle in both directions + while ( p && p.z >= minZ && n && n.z <= maxZ ) { + + if ( p !== ear.prev && p !== ear.next && + pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) && + area( p.prev, p, p.next ) >= 0 ) return false; + p = p.prevZ; + + if ( n !== ear.prev && n !== ear.next && + pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y ) && + area( n.prev, n, n.next ) >= 0 ) return false; + n = n.nextZ; + + } + + // look for remaining points in decreasing z-order + while ( p && p.z >= minZ ) { + + if ( p !== ear.prev && p !== ear.next && + pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) && + area( p.prev, p, p.next ) >= 0 ) return false; + p = p.prevZ; + + } + + // look for remaining points in increasing z-order + while ( n && n.z <= maxZ ) { + + if ( n !== ear.prev && n !== ear.next && + pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y ) && + area( n.prev, n, n.next ) >= 0 ) return false; + n = n.nextZ; + + } + + return true; + +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections( start, triangles, dim ) { + + let p = start; + do { + + const a = p.prev, + b = p.next.next; + + if ( ! equals( a, b ) && intersects( a, p, p.next, b ) && locallyInside( a, b ) && locallyInside( b, a ) ) { + + triangles.push( a.i / dim ); + triangles.push( p.i / dim ); + triangles.push( b.i / dim ); + + // remove two nodes involved + removeNode( p ); + removeNode( p.next ); + + p = start = b; + + } + + p = p.next; + + } while ( p !== start ); + + return filterPoints( p ); + +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut( start, triangles, dim, minX, minY, invSize ) { + + // look for a valid diagonal that divides the polygon into two + let a = start; + do { + + let b = a.next.next; + while ( b !== a.prev ) { + + if ( a.i !== b.i && isValidDiagonal( a, b ) ) { + + // split the polygon in two by the diagonal + let c = splitPolygon( a, b ); + + // filter colinear points around the cuts + a = filterPoints( a, a.next ); + c = filterPoints( c, c.next ); + + // run earcut on each half + earcutLinked( a, triangles, dim, minX, minY, invSize ); + earcutLinked( c, triangles, dim, minX, minY, invSize ); + return; + + } + + b = b.next; + + } + + a = a.next; + + } while ( a !== start ); + +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles( data, holeIndices, outerNode, dim ) { + + const queue = []; + let i, len, start, end, list; + + for ( i = 0, len = holeIndices.length; i < len; i ++ ) { + + start = holeIndices[ i ] * dim; + end = i < len - 1 ? holeIndices[ i + 1 ] * dim : data.length; + list = linkedList( data, start, end, dim, false ); + if ( list === list.next ) list.steiner = true; + queue.push( getLeftmost( list ) ); + + } + + queue.sort( compareX ); + + // process holes from left to right + for ( i = 0; i < queue.length; i ++ ) { + + eliminateHole( queue[ i ], outerNode ); + outerNode = filterPoints( outerNode, outerNode.next ); + + } + + return outerNode; + +} + +function compareX( a, b ) { + + return a.x - b.x; + +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole( hole, outerNode ) { + + outerNode = findHoleBridge( hole, outerNode ); + if ( outerNode ) { + + const b = splitPolygon( outerNode, hole ); + + // filter collinear points around the cuts + filterPoints( outerNode, outerNode.next ); + filterPoints( b, b.next ); + + } + +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge( hole, outerNode ) { + + let p = outerNode; + const hx = hole.x; + const hy = hole.y; + let qx = - Infinity, m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + + if ( hy <= p.y && hy >= p.next.y && p.next.y !== p.y ) { + + const x = p.x + ( hy - p.y ) * ( p.next.x - p.x ) / ( p.next.y - p.y ); + if ( x <= hx && x > qx ) { + + qx = x; + if ( x === hx ) { + + if ( hy === p.y ) return p; + if ( hy === p.next.y ) return p.next; + + } + + m = p.x < p.next.x ? p : p.next; + + } + + } + + p = p.next; + + } while ( p !== outerNode ); + + if ( ! m ) return null; + + if ( hx === qx ) return m; // hole touches outer segment; pick leftmost endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + const stop = m, + mx = m.x, + my = m.y; + let tanMin = Infinity, tan; + + p = m; + + do { + + if ( hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) { + + tan = Math.abs( hy - p.y ) / ( hx - p.x ); // tangential + + if ( locallyInside( p, hole ) && ( tan < tanMin || ( tan === tanMin && ( p.x > m.x || ( p.x === m.x && sectorContainsSector( m, p ) ) ) ) ) ) { + + m = p; + tanMin = tan; + + } + + } + + p = p.next; + + } while ( p !== stop ); + + return m; + +} + +// whether sector in vertex m contains sector in vertex p in the same coordinates +function sectorContainsSector( m, p ) { + + return area( m.prev, m, p.prev ) < 0 && area( p.next, m, m.next ) < 0; + +} + +// interlink polygon nodes in z-order +function indexCurve( start, minX, minY, invSize ) { + + let p = start; + do { + + if ( p.z === null ) p.z = zOrder( p.x, p.y, minX, minY, invSize ); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + + } while ( p !== start ); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked( p ); + +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked( list ) { + + let i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + + p = list; + list = null; + tail = null; + numMerges = 0; + + while ( p ) { + + numMerges ++; + q = p; + pSize = 0; + for ( i = 0; i < inSize; i ++ ) { + + pSize ++; + q = q.nextZ; + if ( ! q ) break; + + } + + qSize = inSize; + + while ( pSize > 0 || ( qSize > 0 && q ) ) { + + if ( pSize !== 0 && ( qSize === 0 || ! q || p.z <= q.z ) ) { + + e = p; + p = p.nextZ; + pSize --; + + } else { + + e = q; + q = q.nextZ; + qSize --; + + } + + if ( tail ) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + + } + + p = q; + + } + + tail.nextZ = null; + inSize *= 2; + + } while ( numMerges > 1 ); + + return list; + +} + +// z-order of a point given coords and inverse of the longer side of data bbox +function zOrder( x, y, minX, minY, invSize ) { + + // coords are transformed into non-negative 15-bit integer range + x = 32767 * ( x - minX ) * invSize; + y = 32767 * ( y - minY ) * invSize; + + x = ( x | ( x << 8 ) ) & 0x00FF00FF; + x = ( x | ( x << 4 ) ) & 0x0F0F0F0F; + x = ( x | ( x << 2 ) ) & 0x33333333; + x = ( x | ( x << 1 ) ) & 0x55555555; + + y = ( y | ( y << 8 ) ) & 0x00FF00FF; + y = ( y | ( y << 4 ) ) & 0x0F0F0F0F; + y = ( y | ( y << 2 ) ) & 0x33333333; + y = ( y | ( y << 1 ) ) & 0x55555555; + + return x | ( y << 1 ); + +} + +// find the leftmost node of a polygon ring +function getLeftmost( start ) { + + let p = start, + leftmost = start; + do { + + if ( p.x < leftmost.x || ( p.x === leftmost.x && p.y < leftmost.y ) ) leftmost = p; + p = p.next; + + } while ( p !== start ); + + return leftmost; + +} + +// check if a point lies within a convex triangle +function pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) { + + return ( cx - px ) * ( ay - py ) - ( ax - px ) * ( cy - py ) >= 0 && + ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 && + ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0; + +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal( a, b ) { + + return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // dones't intersect other edges + ( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible + ( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors + equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case + +} + +// signed area of a triangle +function area( p, q, r ) { + + return ( q.y - p.y ) * ( r.x - q.x ) - ( q.x - p.x ) * ( r.y - q.y ); + +} + +// check if two points are equal +function equals( p1, p2 ) { + + return p1.x === p2.x && p1.y === p2.y; + +} + +// check if two segments intersect +function intersects( p1, q1, p2, q2 ) { + + const o1 = sign( area( p1, q1, p2 ) ); + const o2 = sign( area( p1, q1, q2 ) ); + const o3 = sign( area( p2, q2, p1 ) ); + const o4 = sign( area( p2, q2, q1 ) ); + + if ( o1 !== o2 && o3 !== o4 ) return true; // general case + + if ( o1 === 0 && onSegment( p1, p2, q1 ) ) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if ( o2 === 0 && onSegment( p1, q2, q1 ) ) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if ( o3 === 0 && onSegment( p2, p1, q2 ) ) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if ( o4 === 0 && onSegment( p2, q1, q2 ) ) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; + +} + +// for collinear points p, q, r, check if point q lies on segment pr +function onSegment( p, q, r ) { + + return q.x <= Math.max( p.x, r.x ) && q.x >= Math.min( p.x, r.x ) && q.y <= Math.max( p.y, r.y ) && q.y >= Math.min( p.y, r.y ); + +} + +function sign( num ) { + + return num > 0 ? 1 : num < 0 ? - 1 : 0; + +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon( a, b ) { + + let p = a; + do { + + if ( p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects( p, p.next, a, b ) ) return true; + p = p.next; + + } while ( p !== a ); + + return false; + +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside( a, b ) { + + return area( a.prev, a, a.next ) < 0 ? + area( a, b, a.next ) >= 0 && area( a, a.prev, b ) >= 0 : + area( a, b, a.prev ) < 0 || area( a, a.next, b ) < 0; + +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside( a, b ) { + + let p = a, + inside = false; + const px = ( a.x + b.x ) / 2, + py = ( a.y + b.y ) / 2; + do { + + if ( ( ( p.y > py ) !== ( p.next.y > py ) ) && p.next.y !== p.y && + ( px < ( p.next.x - p.x ) * ( py - p.y ) / ( p.next.y - p.y ) + p.x ) ) + inside = ! inside; + p = p.next; + + } while ( p !== a ); + + return inside; + +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon( a, b ) { + + const a2 = new Node( a.i, a.x, a.y ), + b2 = new Node( b.i, b.x, b.y ), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; + +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode( i, x, y, last ) { + + const p = new Node( i, x, y ); + + if ( ! last ) { + + p.prev = p; + p.next = p; + + } else { + + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + + } + + return p; + +} + +function removeNode( p ) { + + p.next.prev = p.prev; + p.prev.next = p.next; + + if ( p.prevZ ) p.prevZ.nextZ = p.nextZ; + if ( p.nextZ ) p.nextZ.prevZ = p.prevZ; + +} + +function Node( i, x, y ) { + + // vertex index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertex nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; + +} + +function signedArea( data, start, end, dim ) { + + let sum = 0; + for ( let i = start, j = end - dim; i < end; i += dim ) { + + sum += ( data[ j ] - data[ i ] ) * ( data[ i + 1 ] + data[ j + 1 ] ); + j = i; + + } + + return sum; + +} + +class ShapeUtils { + + // calculate area of the contour polygon + + static area( contour ) { + + const n = contour.length; + let a = 0.0; + + for ( let p = n - 1, q = 0; q < n; p = q ++ ) { + + a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; + + } + + return a * 0.5; + + } + + static isClockWise( pts ) { + + return ShapeUtils.area( pts ) < 0; + + } + + static triangulateShape( contour, holes ) { + + const vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ] + const holeIndices = []; // array of hole indices + const faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ] + + removeDupEndPts( contour ); + addContour( vertices, contour ); + + // + + let holeIndex = contour.length; + + holes.forEach( removeDupEndPts ); + + for ( let i = 0; i < holes.length; i ++ ) { + + holeIndices.push( holeIndex ); + holeIndex += holes[ i ].length; + addContour( vertices, holes[ i ] ); + + } + + // + + const triangles = Earcut.triangulate( vertices, holeIndices ); + + // + + for ( let i = 0; i < triangles.length; i += 3 ) { + + faces.push( triangles.slice( i, i + 3 ) ); + + } + + return faces; + + } + +} + +function removeDupEndPts( points ) { + + const l = points.length; + + if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) { + + points.pop(); + + } + +} + +function addContour( vertices, contour ) { + + for ( let i = 0; i < contour.length; i ++ ) { + + vertices.push( contour[ i ].x ); + vertices.push( contour[ i ].y ); + + } + +} + +/** + * Creates extruded geometry from a path shape. + * + * parameters = { + * + * curveSegments: , // number of points on the curves + * steps: , // number of points for z-side extrusions / used for subdividing segments of extrude spline too + * depth: , // Depth to extrude the shape + * + * bevelEnabled: , // turn on bevel + * bevelThickness: , // how deep into the original shape bevel goes + * bevelSize: , // how far from shape outline (including bevelOffset) is bevel + * bevelOffset: , // how far from shape outline does bevel start + * bevelSegments: , // number of bevel layers + * + * extrudePath: // curve to extrude shape along + * + * UVGenerator: // object that provides UV generator functions + * + * } + */ + +class ExtrudeGeometry extends BufferGeometry { + + constructor( shapes = new Shape( [ new Vector2( 0.5, 0.5 ), new Vector2( - 0.5, 0.5 ), new Vector2( - 0.5, - 0.5 ), new Vector2( 0.5, - 0.5 ) ] ), options = {} ) { + + super(); + + this.type = 'ExtrudeGeometry'; + + this.parameters = { + shapes: shapes, + options: options + }; + + shapes = Array.isArray( shapes ) ? shapes : [ shapes ]; + + const scope = this; + + const verticesArray = []; + const uvArray = []; + + for ( let i = 0, l = shapes.length; i < l; i ++ ) { + + const shape = shapes[ i ]; + addShape( shape ); + + } + + // build geometry + + this.setAttribute( 'position', new Float32BufferAttribute( verticesArray, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvArray, 2 ) ); + + this.computeVertexNormals(); + + // functions + + function addShape( shape ) { + + const placeholder = []; + + // options + + const curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12; + const steps = options.steps !== undefined ? options.steps : 1; + let depth = options.depth !== undefined ? options.depth : 1; + + let bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true; + let bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 0.2; + let bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 0.1; + let bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0; + let bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3; + + const extrudePath = options.extrudePath; + + const uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator; + + // deprecated options + + if ( options.amount !== undefined ) { + + console.warn( 'THREE.ExtrudeBufferGeometry: amount has been renamed to depth.' ); + depth = options.amount; + + } + + // + + let extrudePts, extrudeByPath = false; + let splineTube, binormal, normal, position2; + + if ( extrudePath ) { + + extrudePts = extrudePath.getSpacedPoints( steps ); + + extrudeByPath = true; + bevelEnabled = false; // bevels not supported for path extrusion + + // SETUP TNB variables + + // TODO1 - have a .isClosed in spline? + + splineTube = extrudePath.computeFrenetFrames( steps, false ); + + // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length); + + binormal = new Vector3(); + normal = new Vector3(); + position2 = new Vector3(); + + } + + // Safeguards if bevels are not enabled + + if ( ! bevelEnabled ) { + + bevelSegments = 0; + bevelThickness = 0; + bevelSize = 0; + bevelOffset = 0; + + } + + // Variables initialization + + const shapePoints = shape.extractPoints( curveSegments ); + + let vertices = shapePoints.shape; + const holes = shapePoints.holes; + + const reverse = ! ShapeUtils.isClockWise( vertices ); + + if ( reverse ) { + + vertices = vertices.reverse(); + + // Maybe we should also check if holes are in the opposite direction, just to be safe ... + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + + if ( ShapeUtils.isClockWise( ahole ) ) { + + holes[ h ] = ahole.reverse(); + + } + + } + + } + + + const faces = ShapeUtils.triangulateShape( vertices, holes ); + + /* Vertices */ + + const contour = vertices; // vertices has all points but contour has only points of circumference + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + + vertices = vertices.concat( ahole ); + + } + + + function scalePt2( pt, vec, size ) { + + if ( ! vec ) console.error( 'THREE.ExtrudeGeometry: vec does not exist' ); + + return vec.clone().multiplyScalar( size ).add( pt ); + + } + + const vlen = vertices.length, flen = faces.length; + + + // Find directions for point movement + + + function getBevelVec( inPt, inPrev, inNext ) { + + // computes for inPt the corresponding point inPt' on a new contour + // shifted by 1 unit (length of normalized vector) to the left + // if we walk along contour clockwise, this new contour is outside the old one + // + // inPt' is the intersection of the two lines parallel to the two + // adjacent edges of inPt at a distance of 1 unit on the left side. + + let v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt + + // good reading for geometry algorithms (here: line-line intersection) + // http://geomalgorithms.com/a05-_intersect-1.html + + const v_prev_x = inPt.x - inPrev.x, + v_prev_y = inPt.y - inPrev.y; + const v_next_x = inNext.x - inPt.x, + v_next_y = inNext.y - inPt.y; + + const v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y ); + + // check for collinear edges + const collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x ); + + if ( Math.abs( collinear0 ) > Number.EPSILON ) { + + // not collinear + + // length of vectors for normalizing + + const v_prev_len = Math.sqrt( v_prev_lensq ); + const v_next_len = Math.sqrt( v_next_x * v_next_x + v_next_y * v_next_y ); + + // shift adjacent points by unit vectors to the left + + const ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len ); + const ptPrevShift_y = ( inPrev.y + v_prev_x / v_prev_len ); + + const ptNextShift_x = ( inNext.x - v_next_y / v_next_len ); + const ptNextShift_y = ( inNext.y + v_next_x / v_next_len ); + + // scaling factor for v_prev to intersection point + + const sf = ( ( ptNextShift_x - ptPrevShift_x ) * v_next_y - + ( ptNextShift_y - ptPrevShift_y ) * v_next_x ) / + ( v_prev_x * v_next_y - v_prev_y * v_next_x ); + + // vector from inPt to intersection point + + v_trans_x = ( ptPrevShift_x + v_prev_x * sf - inPt.x ); + v_trans_y = ( ptPrevShift_y + v_prev_y * sf - inPt.y ); + + // Don't normalize!, otherwise sharp corners become ugly + // but prevent crazy spikes + const v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y ); + if ( v_trans_lensq <= 2 ) { + + return new Vector2( v_trans_x, v_trans_y ); + + } else { + + shrink_by = Math.sqrt( v_trans_lensq / 2 ); + + } + + } else { + + // handle special case of collinear edges + + let direction_eq = false; // assumes: opposite + + if ( v_prev_x > Number.EPSILON ) { + + if ( v_next_x > Number.EPSILON ) { + + direction_eq = true; + + } + + } else { + + if ( v_prev_x < - Number.EPSILON ) { + + if ( v_next_x < - Number.EPSILON ) { + + direction_eq = true; + + } + + } else { + + if ( Math.sign( v_prev_y ) === Math.sign( v_next_y ) ) { + + direction_eq = true; + + } + + } + + } + + if ( direction_eq ) { + + // console.log("Warning: lines are a straight sequence"); + v_trans_x = - v_prev_y; + v_trans_y = v_prev_x; + shrink_by = Math.sqrt( v_prev_lensq ); + + } else { + + // console.log("Warning: lines are a straight spike"); + v_trans_x = v_prev_x; + v_trans_y = v_prev_y; + shrink_by = Math.sqrt( v_prev_lensq / 2 ); + + } + + } + + return new Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by ); + + } + + + const contourMovements = []; + + for ( let i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) { + + if ( j === il ) j = 0; + if ( k === il ) k = 0; + + // (j)---(i)---(k) + // console.log('i,j,k', i, j , k) + + contourMovements[ i ] = getBevelVec( contour[ i ], contour[ j ], contour[ k ] ); + + } + + const holesMovements = []; + let oneHoleMovements, verticesMovements = contourMovements.concat(); + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + + oneHoleMovements = []; + + for ( let i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) { + + if ( j === il ) j = 0; + if ( k === il ) k = 0; + + // (j)---(i)---(k) + oneHoleMovements[ i ] = getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] ); + + } + + holesMovements.push( oneHoleMovements ); + verticesMovements = verticesMovements.concat( oneHoleMovements ); + + } + + + // Loop bevelSegments, 1 for the front, 1 for the back + + for ( let b = 0; b < bevelSegments; b ++ ) { + + //for ( b = bevelSegments; b > 0; b -- ) { + + const t = b / bevelSegments; + const z = bevelThickness * Math.cos( t * Math.PI / 2 ); + const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset; + + // contract shape + + for ( let i = 0, il = contour.length; i < il; i ++ ) { + + const vert = scalePt2( contour[ i ], contourMovements[ i ], bs ); + + v( vert.x, vert.y, - z ); + + } + + // expand holes + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + oneHoleMovements = holesMovements[ h ]; + + for ( let i = 0, il = ahole.length; i < il; i ++ ) { + + const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); + + v( vert.x, vert.y, - z ); + + } + + } + + } + + const bs = bevelSize + bevelOffset; + + // Back facing vertices + + for ( let i = 0; i < vlen; i ++ ) { + + const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ]; + + if ( ! extrudeByPath ) { + + v( vert.x, vert.y, 0 ); + + } else { + + // v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x ); + + normal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x ); + binormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y ); + + position2.copy( extrudePts[ 0 ] ).add( normal ).add( binormal ); + + v( position2.x, position2.y, position2.z ); + + } + + } + + // Add stepped vertices... + // Including front facing vertices + + for ( let s = 1; s <= steps; s ++ ) { + + for ( let i = 0; i < vlen; i ++ ) { + + const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ]; + + if ( ! extrudeByPath ) { + + v( vert.x, vert.y, depth / steps * s ); + + } else { + + // v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x ); + + normal.copy( splineTube.normals[ s ] ).multiplyScalar( vert.x ); + binormal.copy( splineTube.binormals[ s ] ).multiplyScalar( vert.y ); + + position2.copy( extrudePts[ s ] ).add( normal ).add( binormal ); + + v( position2.x, position2.y, position2.z ); + + } + + } + + } + + + // Add bevel segments planes + + //for ( b = 1; b <= bevelSegments; b ++ ) { + for ( let b = bevelSegments - 1; b >= 0; b -- ) { + + const t = b / bevelSegments; + const z = bevelThickness * Math.cos( t * Math.PI / 2 ); + const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset; + + // contract shape + + for ( let i = 0, il = contour.length; i < il; i ++ ) { + + const vert = scalePt2( contour[ i ], contourMovements[ i ], bs ); + v( vert.x, vert.y, depth + z ); + + } + + // expand holes + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + oneHoleMovements = holesMovements[ h ]; + + for ( let i = 0, il = ahole.length; i < il; i ++ ) { + + const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); + + if ( ! extrudeByPath ) { + + v( vert.x, vert.y, depth + z ); + + } else { + + v( vert.x, vert.y + extrudePts[ steps - 1 ].y, extrudePts[ steps - 1 ].x + z ); + + } + + } + + } + + } + + /* Faces */ + + // Top and bottom faces + + buildLidFaces(); + + // Sides faces + + buildSideFaces(); + + + ///// Internal functions + + function buildLidFaces() { + + const start = verticesArray.length / 3; + + if ( bevelEnabled ) { + + let layer = 0; // steps + 1 + let offset = vlen * layer; + + // Bottom faces + + for ( let i = 0; i < flen; i ++ ) { + + const face = faces[ i ]; + f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset ); + + } + + layer = steps + bevelSegments * 2; + offset = vlen * layer; + + // Top faces + + for ( let i = 0; i < flen; i ++ ) { + + const face = faces[ i ]; + f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset ); + + } + + } else { + + // Bottom faces + + for ( let i = 0; i < flen; i ++ ) { + + const face = faces[ i ]; + f3( face[ 2 ], face[ 1 ], face[ 0 ] ); + + } + + // Top faces + + for ( let i = 0; i < flen; i ++ ) { + + const face = faces[ i ]; + f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps ); + + } + + } + + scope.addGroup( start, verticesArray.length / 3 - start, 0 ); + + } + + // Create faces for the z-sides of the shape + + function buildSideFaces() { + + const start = verticesArray.length / 3; + let layeroffset = 0; + sidewalls( contour, layeroffset ); + layeroffset += contour.length; + + for ( let h = 0, hl = holes.length; h < hl; h ++ ) { + + const ahole = holes[ h ]; + sidewalls( ahole, layeroffset ); + + //, true + layeroffset += ahole.length; + + } + + + scope.addGroup( start, verticesArray.length / 3 - start, 1 ); + + + } + + function sidewalls( contour, layeroffset ) { + + let i = contour.length; + + while ( -- i >= 0 ) { + + const j = i; + let k = i - 1; + if ( k < 0 ) k = contour.length - 1; + + //console.log('b', i,j, i-1, k,vertices.length); + + for ( let s = 0, sl = ( steps + bevelSegments * 2 ); s < sl; s ++ ) { + + const slen1 = vlen * s; + const slen2 = vlen * ( s + 1 ); + + const a = layeroffset + j + slen1, + b = layeroffset + k + slen1, + c = layeroffset + k + slen2, + d = layeroffset + j + slen2; + + f4( a, b, c, d ); + + } + + } + + } + + function v( x, y, z ) { + + placeholder.push( x ); + placeholder.push( y ); + placeholder.push( z ); + + } + + + function f3( a, b, c ) { + + addVertex( a ); + addVertex( b ); + addVertex( c ); + + const nextIndex = verticesArray.length / 3; + const uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 ); + + addUV( uvs[ 0 ] ); + addUV( uvs[ 1 ] ); + addUV( uvs[ 2 ] ); + + } + + function f4( a, b, c, d ) { + + addVertex( a ); + addVertex( b ); + addVertex( d ); + + addVertex( b ); + addVertex( c ); + addVertex( d ); + + + const nextIndex = verticesArray.length / 3; + const uvs = uvgen.generateSideWallUV( scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1 ); + + addUV( uvs[ 0 ] ); + addUV( uvs[ 1 ] ); + addUV( uvs[ 3 ] ); + + addUV( uvs[ 1 ] ); + addUV( uvs[ 2 ] ); + addUV( uvs[ 3 ] ); + + } + + function addVertex( index ) { + + verticesArray.push( placeholder[ index * 3 + 0 ] ); + verticesArray.push( placeholder[ index * 3 + 1 ] ); + verticesArray.push( placeholder[ index * 3 + 2 ] ); + + } + + + function addUV( vector2 ) { + + uvArray.push( vector2.x ); + uvArray.push( vector2.y ); + + } + + } + + } + + toJSON() { + + const data = super.toJSON(); + + const shapes = this.parameters.shapes; + const options = this.parameters.options; + + return toJSON$1( shapes, options, data ); + + } + + static fromJSON( data, shapes ) { + + const geometryShapes = []; + + for ( let j = 0, jl = data.shapes.length; j < jl; j ++ ) { + + const shape = shapes[ data.shapes[ j ] ]; + + geometryShapes.push( shape ); + + } + + const extrudePath = data.options.extrudePath; + + if ( extrudePath !== undefined ) { + + data.options.extrudePath = new Curves[ extrudePath.type ]().fromJSON( extrudePath ); + + } + + return new ExtrudeGeometry( geometryShapes, data.options ); + + } + +} + +const WorldUVGenerator = { + + generateTopUV: function ( geometry, vertices, indexA, indexB, indexC ) { + + const a_x = vertices[ indexA * 3 ]; + const a_y = vertices[ indexA * 3 + 1 ]; + const b_x = vertices[ indexB * 3 ]; + const b_y = vertices[ indexB * 3 + 1 ]; + const c_x = vertices[ indexC * 3 ]; + const c_y = vertices[ indexC * 3 + 1 ]; + + return [ + new Vector2( a_x, a_y ), + new Vector2( b_x, b_y ), + new Vector2( c_x, c_y ) + ]; + + }, + + generateSideWallUV: function ( geometry, vertices, indexA, indexB, indexC, indexD ) { + + const a_x = vertices[ indexA * 3 ]; + const a_y = vertices[ indexA * 3 + 1 ]; + const a_z = vertices[ indexA * 3 + 2 ]; + const b_x = vertices[ indexB * 3 ]; + const b_y = vertices[ indexB * 3 + 1 ]; + const b_z = vertices[ indexB * 3 + 2 ]; + const c_x = vertices[ indexC * 3 ]; + const c_y = vertices[ indexC * 3 + 1 ]; + const c_z = vertices[ indexC * 3 + 2 ]; + const d_x = vertices[ indexD * 3 ]; + const d_y = vertices[ indexD * 3 + 1 ]; + const d_z = vertices[ indexD * 3 + 2 ]; + + if ( Math.abs( a_y - b_y ) < Math.abs( a_x - b_x ) ) { + + return [ + new Vector2( a_x, 1 - a_z ), + new Vector2( b_x, 1 - b_z ), + new Vector2( c_x, 1 - c_z ), + new Vector2( d_x, 1 - d_z ) + ]; + + } else { + + return [ + new Vector2( a_y, 1 - a_z ), + new Vector2( b_y, 1 - b_z ), + new Vector2( c_y, 1 - c_z ), + new Vector2( d_y, 1 - d_z ) + ]; + + } + + } + +}; + +function toJSON$1( shapes, options, data ) { + + data.shapes = []; + + if ( Array.isArray( shapes ) ) { + + for ( let i = 0, l = shapes.length; i < l; i ++ ) { + + const shape = shapes[ i ]; + + data.shapes.push( shape.uuid ); + + } + + } else { + + data.shapes.push( shapes.uuid ); + + } + + if ( options.extrudePath !== undefined ) data.options.extrudePath = options.extrudePath.toJSON(); + + return data; + +} + +class IcosahedronGeometry extends PolyhedronGeometry { + + constructor( radius = 1, detail = 0 ) { + + const t = ( 1 + Math.sqrt( 5 ) ) / 2; + + const vertices = [ + - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0, + 0, - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, + t, 0, - 1, t, 0, 1, - t, 0, - 1, - t, 0, 1 + ]; + + const indices = [ + 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, + 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, + 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, + 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 + ]; + + super( vertices, indices, radius, detail ); + + this.type = 'IcosahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail + }; + + } + + static fromJSON( data ) { + + return new IcosahedronGeometry( data.radius, data.detail ); + + } + +} + +class LatheGeometry extends BufferGeometry { + + constructor( points = [ new Vector2( 0, 0.5 ), new Vector2( 0.5, 0 ), new Vector2( 0, - 0.5 ) ], segments = 12, phiStart = 0, phiLength = Math.PI * 2 ) { + + super(); + + this.type = 'LatheGeometry'; + + this.parameters = { + points: points, + segments: segments, + phiStart: phiStart, + phiLength: phiLength + }; + + segments = Math.floor( segments ); + + // clamp phiLength so it's in range of [ 0, 2PI ] + + phiLength = clamp( phiLength, 0, Math.PI * 2 ); + + // buffers + + const indices = []; + const vertices = []; + const uvs = []; + const initNormals = []; + const normals = []; + + // helper variables + + const inverseSegments = 1.0 / segments; + const vertex = new Vector3(); + const uv = new Vector2(); + const normal = new Vector3(); + const curNormal = new Vector3(); + const prevNormal = new Vector3(); + let dx = 0; + let dy = 0; + + // pre-compute normals for initial "meridian" + + for ( let j = 0; j <= ( points.length - 1 ); j ++ ) { + + switch ( j ) { + + case 0: // special handling for 1st vertex on path + + dx = points[ j + 1 ].x - points[ j ].x; + dy = points[ j + 1 ].y - points[ j ].y; + + normal.x = dy * 1.0; + normal.y = - dx; + normal.z = dy * 0.0; + + prevNormal.copy( normal ); + + normal.normalize(); + + initNormals.push( normal.x, normal.y, normal.z ); + + break; + + case ( points.length - 1 ): // special handling for last Vertex on path + + initNormals.push( prevNormal.x, prevNormal.y, prevNormal.z ); + + break; + + default: // default handling for all vertices in between + + dx = points[ j + 1 ].x - points[ j ].x; + dy = points[ j + 1 ].y - points[ j ].y; + + normal.x = dy * 1.0; + normal.y = - dx; + normal.z = dy * 0.0; + + curNormal.copy( normal ); + + normal.x += prevNormal.x; + normal.y += prevNormal.y; + normal.z += prevNormal.z; + + normal.normalize(); + + initNormals.push( normal.x, normal.y, normal.z ); + + prevNormal.copy( curNormal ); + + } + + } + + // generate vertices, uvs and normals + + for ( let i = 0; i <= segments; i ++ ) { + + const phi = phiStart + i * inverseSegments * phiLength; + + const sin = Math.sin( phi ); + const cos = Math.cos( phi ); + + for ( let j = 0; j <= ( points.length - 1 ); j ++ ) { + + // vertex + + vertex.x = points[ j ].x * sin; + vertex.y = points[ j ].y; + vertex.z = points[ j ].x * cos; + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // uv + + uv.x = i / segments; + uv.y = j / ( points.length - 1 ); + + uvs.push( uv.x, uv.y ); + + // normal + + const x = initNormals[ 3 * j + 0 ] * sin; + const y = initNormals[ 3 * j + 1 ]; + const z = initNormals[ 3 * j + 0 ] * cos; + + normals.push( x, y, z ); + + } + + } + + // indices + + for ( let i = 0; i < segments; i ++ ) { + + for ( let j = 0; j < ( points.length - 1 ); j ++ ) { + + const base = j + i * points.length; + + const a = base; + const b = base + points.length; + const c = base + points.length + 1; + const d = base + 1; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + + } + + static fromJSON( data ) { + + return new LatheGeometry( data.points, data.segments, data.phiStart, data.phiLength ); + + } + +} + +class OctahedronGeometry extends PolyhedronGeometry { + + constructor( radius = 1, detail = 0 ) { + + const vertices = [ + 1, 0, 0, - 1, 0, 0, 0, 1, 0, + 0, - 1, 0, 0, 0, 1, 0, 0, - 1 + ]; + + const indices = [ + 0, 2, 4, 0, 4, 3, 0, 3, 5, + 0, 5, 2, 1, 2, 5, 1, 5, 3, + 1, 3, 4, 1, 4, 2 + ]; + + super( vertices, indices, radius, detail ); + + this.type = 'OctahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail + }; + + } + + static fromJSON( data ) { + + return new OctahedronGeometry( data.radius, data.detail ); + + } + +} + +class RingGeometry extends BufferGeometry { + + constructor( innerRadius = 0.5, outerRadius = 1, thetaSegments = 8, phiSegments = 1, thetaStart = 0, thetaLength = Math.PI * 2 ) { + + super(); + + this.type = 'RingGeometry'; + + this.parameters = { + innerRadius: innerRadius, + outerRadius: outerRadius, + thetaSegments: thetaSegments, + phiSegments: phiSegments, + thetaStart: thetaStart, + thetaLength: thetaLength + }; + + thetaSegments = Math.max( 3, thetaSegments ); + phiSegments = Math.max( 1, phiSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // some helper variables + + let radius = innerRadius; + const radiusStep = ( ( outerRadius - innerRadius ) / phiSegments ); + const vertex = new Vector3(); + const uv = new Vector2(); + + // generate vertices, normals and uvs + + for ( let j = 0; j <= phiSegments; j ++ ) { + + for ( let i = 0; i <= thetaSegments; i ++ ) { + + // values are generate from the inside of the ring to the outside + + const segment = thetaStart + i / thetaSegments * thetaLength; + + // vertex + + vertex.x = radius * Math.cos( segment ); + vertex.y = radius * Math.sin( segment ); + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + normals.push( 0, 0, 1 ); + + // uv + + uv.x = ( vertex.x / outerRadius + 1 ) / 2; + uv.y = ( vertex.y / outerRadius + 1 ) / 2; + + uvs.push( uv.x, uv.y ); + + } + + // increase the radius for next row of vertices + + radius += radiusStep; + + } + + // indices + + for ( let j = 0; j < phiSegments; j ++ ) { + + const thetaSegmentLevel = j * ( thetaSegments + 1 ); + + for ( let i = 0; i < thetaSegments; i ++ ) { + + const segment = i + thetaSegmentLevel; + + const a = segment; + const b = segment + thetaSegments + 1; + const c = segment + thetaSegments + 2; + const d = segment + 1; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new RingGeometry( data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength ); + + } + +} + +class ShapeGeometry extends BufferGeometry { + + constructor( shapes = new Shape( [ new Vector2( 0, 0.5 ), new Vector2( - 0.5, - 0.5 ), new Vector2( 0.5, - 0.5 ) ] ), curveSegments = 12 ) { + + super(); + this.type = 'ShapeGeometry'; + + this.parameters = { + shapes: shapes, + curveSegments: curveSegments + }; + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let groupStart = 0; + let groupCount = 0; + + // allow single and array values for "shapes" parameter + + if ( Array.isArray( shapes ) === false ) { + + addShape( shapes ); + + } else { + + for ( let i = 0; i < shapes.length; i ++ ) { + + addShape( shapes[ i ] ); + + this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support + + groupStart += groupCount; + groupCount = 0; + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + + // helper functions + + function addShape( shape ) { + + const indexOffset = vertices.length / 3; + const points = shape.extractPoints( curveSegments ); + + let shapeVertices = points.shape; + const shapeHoles = points.holes; + + // check direction of vertices + + if ( ShapeUtils.isClockWise( shapeVertices ) === false ) { + + shapeVertices = shapeVertices.reverse(); + + } + + for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) { + + const shapeHole = shapeHoles[ i ]; + + if ( ShapeUtils.isClockWise( shapeHole ) === true ) { + + shapeHoles[ i ] = shapeHole.reverse(); + + } + + } + + const faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles ); + + // join vertices of inner and outer paths to a single array + + for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) { + + const shapeHole = shapeHoles[ i ]; + shapeVertices = shapeVertices.concat( shapeHole ); + + } + + // vertices, normals, uvs + + for ( let i = 0, l = shapeVertices.length; i < l; i ++ ) { + + const vertex = shapeVertices[ i ]; + + vertices.push( vertex.x, vertex.y, 0 ); + normals.push( 0, 0, 1 ); + uvs.push( vertex.x, vertex.y ); // world uvs + + } + + // incides + + for ( let i = 0, l = faces.length; i < l; i ++ ) { + + const face = faces[ i ]; + + const a = face[ 0 ] + indexOffset; + const b = face[ 1 ] + indexOffset; + const c = face[ 2 ] + indexOffset; + + indices.push( a, b, c ); + groupCount += 3; + + } + + } + + } + + toJSON() { + + const data = super.toJSON(); + + const shapes = this.parameters.shapes; + + return toJSON( shapes, data ); + + } + + static fromJSON( data, shapes ) { + + const geometryShapes = []; + + for ( let j = 0, jl = data.shapes.length; j < jl; j ++ ) { + + const shape = shapes[ data.shapes[ j ] ]; + + geometryShapes.push( shape ); + + } + + return new ShapeGeometry( geometryShapes, data.curveSegments ); + + } + +} + +function toJSON( shapes, data ) { + + data.shapes = []; + + if ( Array.isArray( shapes ) ) { + + for ( let i = 0, l = shapes.length; i < l; i ++ ) { + + const shape = shapes[ i ]; + + data.shapes.push( shape.uuid ); + + } + + } else { + + data.shapes.push( shapes.uuid ); + + } + + return data; + +} + +class SphereGeometry extends BufferGeometry { + + constructor( radius = 1, widthSegments = 32, heightSegments = 16, phiStart = 0, phiLength = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI ) { + + super(); + this.type = 'SphereGeometry'; + + this.parameters = { + radius: radius, + widthSegments: widthSegments, + heightSegments: heightSegments, + phiStart: phiStart, + phiLength: phiLength, + thetaStart: thetaStart, + thetaLength: thetaLength + }; + + widthSegments = Math.max( 3, Math.floor( widthSegments ) ); + heightSegments = Math.max( 2, Math.floor( heightSegments ) ); + + const thetaEnd = Math.min( thetaStart + thetaLength, Math.PI ); + + let index = 0; + const grid = []; + + const vertex = new Vector3(); + const normal = new Vector3(); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // generate vertices, normals and uvs + + for ( let iy = 0; iy <= heightSegments; iy ++ ) { + + const verticesRow = []; + + const v = iy / heightSegments; + + // special case for the poles + + let uOffset = 0; + + if ( iy == 0 && thetaStart == 0 ) { + + uOffset = 0.5 / widthSegments; + + } else if ( iy == heightSegments && thetaEnd == Math.PI ) { + + uOffset = - 0.5 / widthSegments; + + } + + for ( let ix = 0; ix <= widthSegments; ix ++ ) { + + const u = ix / widthSegments; + + // vertex + + vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); + vertex.y = radius * Math.cos( thetaStart + v * thetaLength ); + vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + normal.copy( vertex ).normalize(); + normals.push( normal.x, normal.y, normal.z ); + + // uv + + uvs.push( u + uOffset, 1 - v ); + + verticesRow.push( index ++ ); + + } + + grid.push( verticesRow ); + + } + + // indices + + for ( let iy = 0; iy < heightSegments; iy ++ ) { + + for ( let ix = 0; ix < widthSegments; ix ++ ) { + + const a = grid[ iy ][ ix + 1 ]; + const b = grid[ iy ][ ix ]; + const c = grid[ iy + 1 ][ ix ]; + const d = grid[ iy + 1 ][ ix + 1 ]; + + if ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d ); + if ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d ); + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new SphereGeometry( data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength ); + + } + +} + +class TetrahedronGeometry extends PolyhedronGeometry { + + constructor( radius = 1, detail = 0 ) { + + const vertices = [ + 1, 1, 1, - 1, - 1, 1, - 1, 1, - 1, 1, - 1, - 1 + ]; + + const indices = [ + 2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1 + ]; + + super( vertices, indices, radius, detail ); + + this.type = 'TetrahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail + }; + + } + + static fromJSON( data ) { + + return new TetrahedronGeometry( data.radius, data.detail ); + + } + +} + +class TorusGeometry extends BufferGeometry { + + constructor( radius = 1, tube = 0.4, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2 ) { + + super(); + this.type = 'TorusGeometry'; + + this.parameters = { + radius: radius, + tube: tube, + radialSegments: radialSegments, + tubularSegments: tubularSegments, + arc: arc + }; + + radialSegments = Math.floor( radialSegments ); + tubularSegments = Math.floor( tubularSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const center = new Vector3(); + const vertex = new Vector3(); + const normal = new Vector3(); + + // generate vertices, normals and uvs + + for ( let j = 0; j <= radialSegments; j ++ ) { + + for ( let i = 0; i <= tubularSegments; i ++ ) { + + const u = i / tubularSegments * arc; + const v = j / radialSegments * Math.PI * 2; + + // vertex + + vertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u ); + vertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u ); + vertex.z = tube * Math.sin( v ); + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal + + center.x = radius * Math.cos( u ); + center.y = radius * Math.sin( u ); + normal.subVectors( vertex, center ).normalize(); + + normals.push( normal.x, normal.y, normal.z ); + + // uv + + uvs.push( i / tubularSegments ); + uvs.push( j / radialSegments ); + + } + + } + + // generate indices + + for ( let j = 1; j <= radialSegments; j ++ ) { + + for ( let i = 1; i <= tubularSegments; i ++ ) { + + // indices + + const a = ( tubularSegments + 1 ) * j + i - 1; + const b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1; + const c = ( tubularSegments + 1 ) * ( j - 1 ) + i; + const d = ( tubularSegments + 1 ) * j + i; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + } + + static fromJSON( data ) { + + return new TorusGeometry( data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc ); + + } + +} + +class TorusKnotGeometry extends BufferGeometry { + + constructor( radius = 1, tube = 0.4, tubularSegments = 64, radialSegments = 8, p = 2, q = 3 ) { + + super(); + this.type = 'TorusKnotGeometry'; + + this.parameters = { + radius: radius, + tube: tube, + tubularSegments: tubularSegments, + radialSegments: radialSegments, + p: p, + q: q + }; + + tubularSegments = Math.floor( tubularSegments ); + radialSegments = Math.floor( radialSegments ); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const vertex = new Vector3(); + const normal = new Vector3(); + + const P1 = new Vector3(); + const P2 = new Vector3(); + + const B = new Vector3(); + const T = new Vector3(); + const N = new Vector3(); + + // generate vertices, normals and uvs + + for ( let i = 0; i <= tubularSegments; ++ i ) { + + // the radian "u" is used to calculate the position on the torus curve of the current tubular segement + + const u = i / tubularSegments * p * Math.PI * 2; + + // now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead. + // these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions + + calculatePositionOnCurve( u, p, q, radius, P1 ); + calculatePositionOnCurve( u + 0.01, p, q, radius, P2 ); + + // calculate orthonormal basis + + T.subVectors( P2, P1 ); + N.addVectors( P2, P1 ); + B.crossVectors( T, N ); + N.crossVectors( B, T ); + + // normalize B, N. T can be ignored, we don't use it + + B.normalize(); + N.normalize(); + + for ( let j = 0; j <= radialSegments; ++ j ) { + + // now calculate the vertices. they are nothing more than an extrusion of the torus curve. + // because we extrude a shape in the xy-plane, there is no need to calculate a z-value. + + const v = j / radialSegments * Math.PI * 2; + const cx = - tube * Math.cos( v ); + const cy = tube * Math.sin( v ); + + // now calculate the final vertex position. + // first we orient the extrusion with our basis vectos, then we add it to the current position on the curve + + vertex.x = P1.x + ( cx * N.x + cy * B.x ); + vertex.y = P1.y + ( cx * N.y + cy * B.y ); + vertex.z = P1.z + ( cx * N.z + cy * B.z ); + + vertices.push( vertex.x, vertex.y, vertex.z ); + + // normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal) + + normal.subVectors( vertex, P1 ).normalize(); + + normals.push( normal.x, normal.y, normal.z ); + + // uv + + uvs.push( i / tubularSegments ); + uvs.push( j / radialSegments ); + + } + + } + + // generate indices + + for ( let j = 1; j <= tubularSegments; j ++ ) { + + for ( let i = 1; i <= radialSegments; i ++ ) { + + // indices + + const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 ); + const b = ( radialSegments + 1 ) * j + ( i - 1 ); + const c = ( radialSegments + 1 ) * j + i; + const d = ( radialSegments + 1 ) * ( j - 1 ) + i; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + // this function calculates the current position on the torus curve + + function calculatePositionOnCurve( u, p, q, radius, position ) { + + const cu = Math.cos( u ); + const su = Math.sin( u ); + const quOverP = q / p * u; + const cs = Math.cos( quOverP ); + + position.x = radius * ( 2 + cs ) * 0.5 * cu; + position.y = radius * ( 2 + cs ) * su * 0.5; + position.z = radius * Math.sin( quOverP ) * 0.5; + + } + + } + + static fromJSON( data ) { + + return new TorusKnotGeometry( data.radius, data.tube, data.tubularSegments, data.radialSegments, data.p, data.q ); + + } + +} + +class TubeGeometry extends BufferGeometry { + + constructor( path = new QuadraticBezierCurve3( new Vector3( - 1, - 1, 0 ), new Vector3( - 1, 1, 0 ), new Vector3( 1, 1, 0 ) ), tubularSegments = 64, radius = 1, radialSegments = 8, closed = false ) { + + super(); + this.type = 'TubeGeometry'; + + this.parameters = { + path: path, + tubularSegments: tubularSegments, + radius: radius, + radialSegments: radialSegments, + closed: closed + }; + + const frames = path.computeFrenetFrames( tubularSegments, closed ); + + // expose internals + + this.tangents = frames.tangents; + this.normals = frames.normals; + this.binormals = frames.binormals; + + // helper variables + + const vertex = new Vector3(); + const normal = new Vector3(); + const uv = new Vector2(); + let P = new Vector3(); + + // buffer + + const vertices = []; + const normals = []; + const uvs = []; + const indices = []; + + // create buffer data + + generateBufferData(); + + // build geometry + + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + + // functions + + function generateBufferData() { + + for ( let i = 0; i < tubularSegments; i ++ ) { + + generateSegment( i ); + + } + + // if the geometry is not closed, generate the last row of vertices and normals + // at the regular position on the given path + // + // if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ) + + generateSegment( ( closed === false ) ? tubularSegments : 0 ); + + // uvs are generated in a separate function. + // this makes it easy compute correct values for closed geometries + + generateUVs(); + + // finally create faces + + generateIndices(); + + } + + function generateSegment( i ) { + + // we use getPointAt to sample evenly distributed points from the given path + + P = path.getPointAt( i / tubularSegments, P ); + + // retrieve corresponding normal and binormal + + const N = frames.normals[ i ]; + const B = frames.binormals[ i ]; + + // generate normals and vertices for the current segment + + for ( let j = 0; j <= radialSegments; j ++ ) { + + const v = j / radialSegments * Math.PI * 2; + + const sin = Math.sin( v ); + const cos = - Math.cos( v ); + + // normal + + normal.x = ( cos * N.x + sin * B.x ); + normal.y = ( cos * N.y + sin * B.y ); + normal.z = ( cos * N.z + sin * B.z ); + normal.normalize(); + + normals.push( normal.x, normal.y, normal.z ); + + // vertex + + vertex.x = P.x + radius * normal.x; + vertex.y = P.y + radius * normal.y; + vertex.z = P.z + radius * normal.z; + + vertices.push( vertex.x, vertex.y, vertex.z ); + + } + + } + + function generateIndices() { + + for ( let j = 1; j <= tubularSegments; j ++ ) { + + for ( let i = 1; i <= radialSegments; i ++ ) { + + const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 ); + const b = ( radialSegments + 1 ) * j + ( i - 1 ); + const c = ( radialSegments + 1 ) * j + i; + const d = ( radialSegments + 1 ) * ( j - 1 ) + i; + + // faces + + indices.push( a, b, d ); + indices.push( b, c, d ); + + } + + } + + } + + function generateUVs() { + + for ( let i = 0; i <= tubularSegments; i ++ ) { + + for ( let j = 0; j <= radialSegments; j ++ ) { + + uv.x = i / tubularSegments; + uv.y = j / radialSegments; + + uvs.push( uv.x, uv.y ); + + } + + } + + } + + } + + toJSON() { + + const data = super.toJSON(); + + data.path = this.parameters.path.toJSON(); + + return data; + + } + + static fromJSON( data ) { + + // This only works for built-in curves (e.g. CatmullRomCurve3). + // User defined curves or instances of CurvePath will not be deserialized. + return new TubeGeometry( + new Curves[ data.path.type ]().fromJSON( data.path ), + data.tubularSegments, + data.radius, + data.radialSegments, + data.closed + ); + + } + +} + +class WireframeGeometry extends BufferGeometry { + + constructor( geometry = null ) { + + super(); + this.type = 'WireframeGeometry'; + + this.parameters = { + geometry: geometry + }; + + if ( geometry !== null ) { + + // buffer + + const vertices = []; + const edges = new Set(); + + // helper variables + + const start = new Vector3(); + const end = new Vector3(); + + if ( geometry.index !== null ) { + + // indexed BufferGeometry + + const position = geometry.attributes.position; + const indices = geometry.index; + let groups = geometry.groups; + + if ( groups.length === 0 ) { + + groups = [ { start: 0, count: indices.count, materialIndex: 0 } ]; + + } + + // create a data structure that contains all eges without duplicates + + for ( let o = 0, ol = groups.length; o < ol; ++ o ) { + + const group = groups[ o ]; + + const groupStart = group.start; + const groupCount = group.count; + + for ( let i = groupStart, l = ( groupStart + groupCount ); i < l; i += 3 ) { + + for ( let j = 0; j < 3; j ++ ) { + + const index1 = indices.getX( i + j ); + const index2 = indices.getX( i + ( j + 1 ) % 3 ); + + start.fromBufferAttribute( position, index1 ); + end.fromBufferAttribute( position, index2 ); + + if ( isUniqueEdge( start, end, edges ) === true ) { + + vertices.push( start.x, start.y, start.z ); + vertices.push( end.x, end.y, end.z ); + + } + + } + + } + + } + + } else { + + // non-indexed BufferGeometry + + const position = geometry.attributes.position; + + for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) { + + for ( let j = 0; j < 3; j ++ ) { + + // three edges per triangle, an edge is represented as (index1, index2) + // e.g. the first triangle has the following edges: (0,1),(1,2),(2,0) + + const index1 = 3 * i + j; + const index2 = 3 * i + ( ( j + 1 ) % 3 ); + + start.fromBufferAttribute( position, index1 ); + end.fromBufferAttribute( position, index2 ); + + if ( isUniqueEdge( start, end, edges ) === true ) { + + vertices.push( start.x, start.y, start.z ); + vertices.push( end.x, end.y, end.z ); + + } + + } + + } + + } + + // build geometry + + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + + } + + } + +} + +function isUniqueEdge( start, end, edges ) { + + const hash1 = `${start.x},${start.y},${start.z}-${end.x},${end.y},${end.z}`; + const hash2 = `${end.x},${end.y},${end.z}-${start.x},${start.y},${start.z}`; // coincident edge + + if ( edges.has( hash1 ) === true || edges.has( hash2 ) === true ) { + + return false; + + } else { + + edges.add( hash1, hash2 ); + return true; + + } + +} + +var Geometries = /*#__PURE__*/Object.freeze({ + __proto__: null, + BoxGeometry: BoxGeometry, + BoxBufferGeometry: BoxGeometry, + CircleGeometry: CircleGeometry, + CircleBufferGeometry: CircleGeometry, + ConeGeometry: ConeGeometry, + ConeBufferGeometry: ConeGeometry, + CylinderGeometry: CylinderGeometry, + CylinderBufferGeometry: CylinderGeometry, + DodecahedronGeometry: DodecahedronGeometry, + DodecahedronBufferGeometry: DodecahedronGeometry, + EdgesGeometry: EdgesGeometry, + ExtrudeGeometry: ExtrudeGeometry, + ExtrudeBufferGeometry: ExtrudeGeometry, + IcosahedronGeometry: IcosahedronGeometry, + IcosahedronBufferGeometry: IcosahedronGeometry, + LatheGeometry: LatheGeometry, + LatheBufferGeometry: LatheGeometry, + OctahedronGeometry: OctahedronGeometry, + OctahedronBufferGeometry: OctahedronGeometry, + PlaneGeometry: PlaneGeometry, + PlaneBufferGeometry: PlaneGeometry, + PolyhedronGeometry: PolyhedronGeometry, + PolyhedronBufferGeometry: PolyhedronGeometry, + RingGeometry: RingGeometry, + RingBufferGeometry: RingGeometry, + ShapeGeometry: ShapeGeometry, + ShapeBufferGeometry: ShapeGeometry, + SphereGeometry: SphereGeometry, + SphereBufferGeometry: SphereGeometry, + TetrahedronGeometry: TetrahedronGeometry, + TetrahedronBufferGeometry: TetrahedronGeometry, + TorusGeometry: TorusGeometry, + TorusBufferGeometry: TorusGeometry, + TorusKnotGeometry: TorusKnotGeometry, + TorusKnotBufferGeometry: TorusKnotGeometry, + TubeGeometry: TubeGeometry, + TubeBufferGeometry: TubeGeometry, + WireframeGeometry: WireframeGeometry +}); + +/** + * parameters = { + * color: + * } + */ + +class ShadowMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'ShadowMaterial'; + + this.color = new Color( 0x000000 ); + this.transparent = true; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + return this; + + } + +} + +ShadowMaterial.prototype.isShadowMaterial = true; + +/** + * parameters = { + * color: , + * roughness: , + * metalness: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * roughnessMap: new THREE.Texture( ), + * + * metalnessMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * envMapIntensity: + * + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * flatShading: + * } + */ + +class MeshStandardMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.defines = { 'STANDARD': '' }; + + this.type = 'MeshStandardMaterial'; + + this.color = new Color( 0xffffff ); // diffuse + this.roughness = 1.0; + this.metalness = 0.0; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.roughnessMap = null; + + this.metalnessMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.envMapIntensity = 1.0; + + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.flatShading = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.defines = { 'STANDARD': '' }; + + this.color.copy( source.color ); + this.roughness = source.roughness; + this.metalness = source.metalness; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.roughnessMap = source.roughnessMap; + + this.metalnessMap = source.metalnessMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.envMapIntensity = source.envMapIntensity; + + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.flatShading = source.flatShading; + + return this; + + } + +} + +MeshStandardMaterial.prototype.isMeshStandardMaterial = true; + +/** + * parameters = { + * clearcoat: , + * clearcoatMap: new THREE.Texture( ), + * clearcoatRoughness: , + * clearcoatRoughnessMap: new THREE.Texture( ), + * clearcoatNormalScale: , + * clearcoatNormalMap: new THREE.Texture( ), + * + * ior: , + * reflectivity: , + * + * sheen: , + * sheenColor: , + * sheenColorMap: new THREE.Texture( ), + * sheenRoughness: , + * sheenRoughnessMap: new THREE.Texture( ), + * + * transmission: , + * transmissionMap: new THREE.Texture( ), + * + * thickness: , + * thicknessMap: new THREE.Texture( ), + * attenuationDistance: , + * attenuationColor: , + * + * specularIntensity: , + * specularIntensityMap: new THREE.Texture( ), + * specularColor: , + * specularColorMap: new THREE.Texture( ) + * } + */ + +class MeshPhysicalMaterial extends MeshStandardMaterial { + + constructor( parameters ) { + + super(); + + this.defines = { + + 'STANDARD': '', + 'PHYSICAL': '' + + }; + + this.type = 'MeshPhysicalMaterial'; + + this.clearcoatMap = null; + this.clearcoatRoughness = 0.0; + this.clearcoatRoughnessMap = null; + this.clearcoatNormalScale = new Vector2( 1, 1 ); + this.clearcoatNormalMap = null; + + this.ior = 1.5; + + Object.defineProperty( this, 'reflectivity', { + get: function () { + + return ( clamp( 2.5 * ( this.ior - 1 ) / ( this.ior + 1 ), 0, 1 ) ); + + }, + set: function ( reflectivity ) { + + this.ior = ( 1 + 0.4 * reflectivity ) / ( 1 - 0.4 * reflectivity ); + + } + } ); + + this.sheenColor = new Color( 0x000000 ); + this.sheenColorMap = null; + this.sheenRoughness = 1.0; + this.sheenRoughnessMap = null; + + this.transmissionMap = null; + + this.thickness = 0; + this.thicknessMap = null; + this.attenuationDistance = 0.0; + this.attenuationColor = new Color( 1, 1, 1 ); + + this.specularIntensity = 1.0; + this.specularIntensityMap = null; + this.specularColor = new Color( 1, 1, 1 ); + this.specularColorMap = null; + + this._sheen = 0.0; + this._clearcoat = 0; + this._transmission = 0; + + this.setValues( parameters ); + + } + + get sheen() { + + return this._sheen; + + } + + set sheen( value ) { + + if ( this._sheen > 0 !== value > 0 ) { + + this.version ++; + + } + + this._sheen = value; + + } + + get clearcoat() { + + return this._clearcoat; + + } + + set clearcoat( value ) { + + if ( this._clearcoat > 0 !== value > 0 ) { + + this.version ++; + + } + + this._clearcoat = value; + + } + + get transmission() { + + return this._transmission; + + } + + set transmission( value ) { + + if ( this._transmission > 0 !== value > 0 ) { + + this.version ++; + + } + + this._transmission = value; + + } + + copy( source ) { + + super.copy( source ); + + this.defines = { + + 'STANDARD': '', + 'PHYSICAL': '' + + }; + + this.clearcoat = source.clearcoat; + this.clearcoatMap = source.clearcoatMap; + this.clearcoatRoughness = source.clearcoatRoughness; + this.clearcoatRoughnessMap = source.clearcoatRoughnessMap; + this.clearcoatNormalMap = source.clearcoatNormalMap; + this.clearcoatNormalScale.copy( source.clearcoatNormalScale ); + + this.ior = source.ior; + + this.sheen = source.sheen; + this.sheenColor.copy( source.sheenColor ); + this.sheenColorMap = source.sheenColorMap; + this.sheenRoughness = source.sheenRoughness; + this.sheenRoughnessMap = source.sheenRoughnessMap; + + this.transmission = source.transmission; + this.transmissionMap = source.transmissionMap; + + this.thickness = source.thickness; + this.thicknessMap = source.thicknessMap; + this.attenuationDistance = source.attenuationDistance; + this.attenuationColor.copy( source.attenuationColor ); + + this.specularIntensity = source.specularIntensity; + this.specularIntensityMap = source.specularIntensityMap; + this.specularColor.copy( source.specularColor ); + this.specularColorMap = source.specularColorMap; + + return this; + + } + +} + +MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true; + +/** + * parameters = { + * color: , + * specular: , + * shininess: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.MultiplyOperation, + * reflectivity: , + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * flatShading: + * } + */ + +class MeshPhongMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshPhongMaterial'; + + this.color = new Color( 0xffffff ); // diffuse + this.specular = new Color( 0x111111 ); + this.shininess = 30; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.flatShading = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + this.specular.copy( source.specular ); + this.shininess = source.shininess; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.flatShading = source.flatShading; + + return this; + + } + +} + +MeshPhongMaterial.prototype.isMeshPhongMaterial = true; + +/** + * parameters = { + * color: , + * + * map: new THREE.Texture( ), + * gradientMap: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * alphaMap: new THREE.Texture( ), + * + * wireframe: , + * wireframeLinewidth: , + * + * } + */ + +class MeshToonMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.defines = { 'TOON': '' }; + + this.type = 'MeshToonMaterial'; + + this.color = new Color( 0xffffff ); + + this.map = null; + this.gradientMap = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.alphaMap = null; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + this.gradientMap = source.gradientMap; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.alphaMap = source.alphaMap; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + + } + +} + +MeshToonMaterial.prototype.isMeshToonMaterial = true; + +/** + * parameters = { + * opacity: , + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * wireframe: , + * wireframeLinewidth: + * + * flatShading: + * } + */ + +class MeshNormalMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshNormalMaterial'; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; + + this.flatShading = false; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + this.flatShading = source.flatShading; + + return this; + + } + +} + +MeshNormalMaterial.prototype.isMeshNormalMaterial = true; + +/** + * parameters = { + * color: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * } + */ + +class MeshLambertMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.type = 'MeshLambertMaterial'; + + this.color = new Color( 0xffffff ); // diffuse + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + + } + +} + +MeshLambertMaterial.prototype.isMeshLambertMaterial = true; + +/** + * parameters = { + * color: , + * opacity: , + * + * matcap: new THREE.Texture( ), + * + * map: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * alphaMap: new THREE.Texture( ), + * + * flatShading: + * } + */ + +class MeshMatcapMaterial extends Material { + + constructor( parameters ) { + + super(); + + this.defines = { 'MATCAP': '' }; + + this.type = 'MeshMatcapMaterial'; + + this.color = new Color( 0xffffff ); // diffuse + + this.matcap = null; + + this.map = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.alphaMap = null; + + this.flatShading = false; + + this.setValues( parameters ); + + } + + + copy( source ) { + + super.copy( source ); + + this.defines = { 'MATCAP': '' }; + + this.color.copy( source.color ); + + this.matcap = source.matcap; + + this.map = source.map; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.alphaMap = source.alphaMap; + + this.flatShading = source.flatShading; + + return this; + + } + +} + +MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true; + +/** + * parameters = { + * color: , + * opacity: , + * + * linewidth: , + * + * scale: , + * dashSize: , + * gapSize: + * } + */ + +class LineDashedMaterial extends LineBasicMaterial { + + constructor( parameters ) { + + super(); + + this.type = 'LineDashedMaterial'; + + this.scale = 1; + this.dashSize = 3; + this.gapSize = 1; + + this.setValues( parameters ); + + } + + copy( source ) { + + super.copy( source ); + + this.scale = source.scale; + this.dashSize = source.dashSize; + this.gapSize = source.gapSize; + + return this; + + } + +} + +LineDashedMaterial.prototype.isLineDashedMaterial = true; + +var Materials = /*#__PURE__*/Object.freeze({ + __proto__: null, + ShadowMaterial: ShadowMaterial, + SpriteMaterial: SpriteMaterial, + RawShaderMaterial: RawShaderMaterial, + ShaderMaterial: ShaderMaterial, + PointsMaterial: PointsMaterial, + MeshPhysicalMaterial: MeshPhysicalMaterial, + MeshStandardMaterial: MeshStandardMaterial, + MeshPhongMaterial: MeshPhongMaterial, + MeshToonMaterial: MeshToonMaterial, + MeshNormalMaterial: MeshNormalMaterial, + MeshLambertMaterial: MeshLambertMaterial, + MeshDepthMaterial: MeshDepthMaterial, + MeshDistanceMaterial: MeshDistanceMaterial, + MeshBasicMaterial: MeshBasicMaterial, + MeshMatcapMaterial: MeshMatcapMaterial, + LineDashedMaterial: LineDashedMaterial, + LineBasicMaterial: LineBasicMaterial, + Material: Material +}); + +const AnimationUtils = { + + // same as Array.prototype.slice, but also works on typed arrays + arraySlice: function ( array, from, to ) { + + if ( AnimationUtils.isTypedArray( array ) ) { + + // in ios9 array.subarray(from, undefined) will return empty array + // but array.subarray(from) or array.subarray(from, len) is correct + return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) ); + + } + + return array.slice( from, to ); + + }, + + // converts an array to a specific type + convertArray: function ( array, type, forceClone ) { + + if ( ! array || // let 'undefined' and 'null' pass + ! forceClone && array.constructor === type ) return array; + + if ( typeof type.BYTES_PER_ELEMENT === 'number' ) { + + return new type( array ); // create typed array + + } + + return Array.prototype.slice.call( array ); // create Array + + }, + + isTypedArray: function ( object ) { + + return ArrayBuffer.isView( object ) && + ! ( object instanceof DataView ); + + }, + + // returns an array by which times and values can be sorted + getKeyframeOrder: function ( times ) { + + function compareTime( i, j ) { + + return times[ i ] - times[ j ]; + + } + + const n = times.length; + const result = new Array( n ); + for ( let i = 0; i !== n; ++ i ) result[ i ] = i; + + result.sort( compareTime ); + + return result; + + }, + + // uses the array previously returned by 'getKeyframeOrder' to sort data + sortedArray: function ( values, stride, order ) { + + const nValues = values.length; + const result = new values.constructor( nValues ); + + for ( let i = 0, dstOffset = 0; dstOffset !== nValues; ++ i ) { + + const srcOffset = order[ i ] * stride; + + for ( let j = 0; j !== stride; ++ j ) { + + result[ dstOffset ++ ] = values[ srcOffset + j ]; + + } + + } + + return result; + + }, + + // function for parsing AOS keyframe formats + flattenJSON: function ( jsonKeys, times, values, valuePropertyName ) { + + let i = 1, key = jsonKeys[ 0 ]; + + while ( key !== undefined && key[ valuePropertyName ] === undefined ) { + + key = jsonKeys[ i ++ ]; + + } + + if ( key === undefined ) return; // no data + + let value = key[ valuePropertyName ]; + if ( value === undefined ) return; // no data + + if ( Array.isArray( value ) ) { + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + values.push.apply( values, value ); // push all elements + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } else if ( value.toArray !== undefined ) { + + // ...assume THREE.Math-ish + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + value.toArray( values, values.length ); + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } else { + + // otherwise push as-is + + do { + + value = key[ valuePropertyName ]; + + if ( value !== undefined ) { + + times.push( key.time ); + values.push( value ); + + } + + key = jsonKeys[ i ++ ]; + + } while ( key !== undefined ); + + } + + }, + + subclip: function ( sourceClip, name, startFrame, endFrame, fps = 30 ) { + + const clip = sourceClip.clone(); + + clip.name = name; + + const tracks = []; + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + const track = clip.tracks[ i ]; + const valueSize = track.getValueSize(); + + const times = []; + const values = []; + + for ( let j = 0; j < track.times.length; ++ j ) { + + const frame = track.times[ j ] * fps; + + if ( frame < startFrame || frame >= endFrame ) continue; + + times.push( track.times[ j ] ); + + for ( let k = 0; k < valueSize; ++ k ) { + + values.push( track.values[ j * valueSize + k ] ); + + } + + } + + if ( times.length === 0 ) continue; + + track.times = AnimationUtils.convertArray( times, track.times.constructor ); + track.values = AnimationUtils.convertArray( values, track.values.constructor ); + + tracks.push( track ); + + } + + clip.tracks = tracks; + + // find minimum .times value across all tracks in the trimmed clip + + let minStartTime = Infinity; + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + if ( minStartTime > clip.tracks[ i ].times[ 0 ] ) { + + minStartTime = clip.tracks[ i ].times[ 0 ]; + + } + + } + + // shift all tracks such that clip begins at t=0 + + for ( let i = 0; i < clip.tracks.length; ++ i ) { + + clip.tracks[ i ].shift( - 1 * minStartTime ); + + } + + clip.resetDuration(); + + return clip; + + }, + + makeClipAdditive: function ( targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30 ) { + + if ( fps <= 0 ) fps = 30; + + const numTracks = referenceClip.tracks.length; + const referenceTime = referenceFrame / fps; + + // Make each track's values relative to the values at the reference frame + for ( let i = 0; i < numTracks; ++ i ) { + + const referenceTrack = referenceClip.tracks[ i ]; + const referenceTrackType = referenceTrack.ValueTypeName; + + // Skip this track if it's non-numeric + if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) continue; + + // Find the track in the target clip whose name and type matches the reference track + const targetTrack = targetClip.tracks.find( function ( track ) { + + return track.name === referenceTrack.name + && track.ValueTypeName === referenceTrackType; + + } ); + + if ( targetTrack === undefined ) continue; + + let referenceOffset = 0; + const referenceValueSize = referenceTrack.getValueSize(); + + if ( referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { + + referenceOffset = referenceValueSize / 3; + + } + + let targetOffset = 0; + const targetValueSize = targetTrack.getValueSize(); + + if ( targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { + + targetOffset = targetValueSize / 3; + + } + + const lastIndex = referenceTrack.times.length - 1; + let referenceValue; + + // Find the value to subtract out of the track + if ( referenceTime <= referenceTrack.times[ 0 ] ) { + + // Reference frame is earlier than the first keyframe, so just use the first keyframe + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); + + } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { + + // Reference frame is after the last keyframe, so just use the last keyframe + const startIndex = lastIndex * referenceValueSize + referenceOffset; + const endIndex = startIndex + referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); + + } else { + + // Interpolate to the reference value + const interpolant = referenceTrack.createInterpolant(); + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + interpolant.evaluate( referenceTime ); + referenceValue = AnimationUtils.arraySlice( interpolant.resultBuffer, startIndex, endIndex ); + + } + + // Conjugate the quaternion + if ( referenceTrackType === 'quaternion' ) { + + const referenceQuat = new Quaternion().fromArray( referenceValue ).normalize().conjugate(); + referenceQuat.toArray( referenceValue ); + + } + + // Subtract the reference value from all of the track values + + const numTimes = targetTrack.times.length; + for ( let j = 0; j < numTimes; ++ j ) { + + const valueStart = j * targetValueSize + targetOffset; + + if ( referenceTrackType === 'quaternion' ) { + + // Multiply the conjugate for quaternion track types + Quaternion.multiplyQuaternionsFlat( + targetTrack.values, + valueStart, + referenceValue, + 0, + targetTrack.values, + valueStart + ); + + } else { + + const valueEnd = targetValueSize - targetOffset * 2; + + // Subtract each value for all other numeric track types + for ( let k = 0; k < valueEnd; ++ k ) { + + targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; + + } + + } + + } + + } + + targetClip.blendMode = AdditiveAnimationBlendMode; + + return targetClip; + + } + +}; + +/** + * Abstract base class of interpolants over parametric samples. + * + * The parameter domain is one dimensional, typically the time or a path + * along a curve defined by the data. + * + * The sample values can have any dimensionality and derived classes may + * apply special interpretations to the data. + * + * This class provides the interval seek in a Template Method, deferring + * the actual interpolation to derived classes. + * + * Time complexity is O(1) for linear access crossing at most two points + * and O(log N) for random access, where N is the number of positions. + * + * References: + * + * http://www.oodesign.com/template-method-pattern.html + * + */ + +class Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + this.parameterPositions = parameterPositions; + this._cachedIndex = 0; + + this.resultBuffer = resultBuffer !== undefined ? + resultBuffer : new sampleValues.constructor( sampleSize ); + this.sampleValues = sampleValues; + this.valueSize = sampleSize; + + this.settings = null; + this.DefaultSettings_ = {}; + + } + + evaluate( t ) { + + const pp = this.parameterPositions; + let i1 = this._cachedIndex, + t1 = pp[ i1 ], + t0 = pp[ i1 - 1 ]; + + validate_interval: { + + seek: { + + let right; + + linear_scan: { + + //- See http://jsperf.com/comparison-to-undefined/3 + //- slower code: + //- + //- if ( t >= t1 || t1 === undefined ) { + forward_scan: if ( ! ( t < t1 ) ) { + + for ( let giveUpAt = i1 + 2; ; ) { + + if ( t1 === undefined ) { + + if ( t < t0 ) break forward_scan; + + // after end + + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t, t0 ); + + } + + if ( i1 === giveUpAt ) break; // this loop + + t0 = t1; + t1 = pp[ ++ i1 ]; + + if ( t < t1 ) { + + // we have arrived at the sought interval + break seek; + + } + + } + + // prepare binary search on the right side of the index + right = pp.length; + break linear_scan; + + } + + //- slower code: + //- if ( t < t0 || t0 === undefined ) { + if ( ! ( t >= t0 ) ) { + + // looping? + + const t1global = pp[ 1 ]; + + if ( t < t1global ) { + + i1 = 2; // + 1, using the scan for the details + t0 = t1global; + + } + + // linear reverse scan + + for ( let giveUpAt = i1 - 2; ; ) { + + if ( t0 === undefined ) { + + // before start + + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); + + } + + if ( i1 === giveUpAt ) break; // this loop + + t1 = t0; + t0 = pp[ -- i1 - 1 ]; + + if ( t >= t0 ) { + + // we have arrived at the sought interval + break seek; + + } + + } + + // prepare binary search on the left side of the index + right = i1; + i1 = 0; + break linear_scan; + + } + + // the interval is valid + + break validate_interval; + + } // linear scan + + // binary search + + while ( i1 < right ) { + + const mid = ( i1 + right ) >>> 1; + + if ( t < pp[ mid ] ) { + + right = mid; + + } else { + + i1 = mid + 1; + + } + + } + + t1 = pp[ i1 ]; + t0 = pp[ i1 - 1 ]; + + // check boundary cases, again + + if ( t0 === undefined ) { + + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); + + } + + if ( t1 === undefined ) { + + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t0, t ); + + } + + } // seek + + this._cachedIndex = i1; + + this.intervalChanged_( i1, t0, t1 ); + + } // validate_interval + + return this.interpolate_( i1, t0, t, t1 ); + + } + + getSettings_() { + + return this.settings || this.DefaultSettings_; + + } + + copySampleValue_( index ) { + + // copies a sample value to the result buffer + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + offset = index * stride; + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = values[ offset + i ]; + + } + + return result; + + } + + // Template methods for derived classes: + + interpolate_( /* i1, t0, t, t1 */ ) { + + throw new Error( 'call to abstract method' ); + // implementations shall return this.resultBuffer + + } + + intervalChanged_( /* i1, t0, t1 */ ) { + + // empty + + } + +} + +// ALIAS DEFINITIONS + +Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_; +Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_; + +/** + * Fast and simple cubic spline interpolant. + * + * It was derived from a Hermitian construction setting the first derivative + * at each sample position to the linear slope between neighboring positions + * over their parameter interval. + */ + +class CubicInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + this._weightPrev = - 0; + this._offsetPrev = - 0; + this._weightNext = - 0; + this._offsetNext = - 0; + + this.DefaultSettings_ = { + + endingStart: ZeroCurvatureEnding, + endingEnd: ZeroCurvatureEnding + + }; + + } + + intervalChanged_( i1, t0, t1 ) { + + const pp = this.parameterPositions; + let iPrev = i1 - 2, + iNext = i1 + 1, + + tPrev = pp[ iPrev ], + tNext = pp[ iNext ]; + + if ( tPrev === undefined ) { + + switch ( this.getSettings_().endingStart ) { + + case ZeroSlopeEnding: + + // f'(t0) = 0 + iPrev = i1; + tPrev = 2 * t0 - t1; + + break; + + case WrapAroundEnding: + + // use the other end of the curve + iPrev = pp.length - 2; + tPrev = t0 + pp[ iPrev ] - pp[ iPrev + 1 ]; + + break; + + default: // ZeroCurvatureEnding + + // f''(t0) = 0 a.k.a. Natural Spline + iPrev = i1; + tPrev = t1; + + } + + } + + if ( tNext === undefined ) { + + switch ( this.getSettings_().endingEnd ) { + + case ZeroSlopeEnding: + + // f'(tN) = 0 + iNext = i1; + tNext = 2 * t1 - t0; + + break; + + case WrapAroundEnding: + + // use the other end of the curve + iNext = 1; + tNext = t1 + pp[ 1 ] - pp[ 0 ]; + + break; + + default: // ZeroCurvatureEnding + + // f''(tN) = 0, a.k.a. Natural Spline + iNext = i1 - 1; + tNext = t0; + + } + + } + + const halfDt = ( t1 - t0 ) * 0.5, + stride = this.valueSize; + + this._weightPrev = halfDt / ( t0 - tPrev ); + this._weightNext = halfDt / ( tNext - t1 ); + this._offsetPrev = iPrev * stride; + this._offsetNext = iNext * stride; + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + o1 = i1 * stride, o0 = o1 - stride, + oP = this._offsetPrev, oN = this._offsetNext, + wP = this._weightPrev, wN = this._weightNext, + + p = ( t - t0 ) / ( t1 - t0 ), + pp = p * p, + ppp = pp * p; + + // evaluate polynomials + + const sP = - wP * ppp + 2 * wP * pp - wP * p; + const s0 = ( 1 + wP ) * ppp + ( - 1.5 - 2 * wP ) * pp + ( - 0.5 + wP ) * p + 1; + const s1 = ( - 1 - wN ) * ppp + ( 1.5 + wN ) * pp + 0.5 * p; + const sN = wN * ppp - wN * pp; + + // combine data linearly + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = + sP * values[ oP + i ] + + s0 * values[ o0 + i ] + + s1 * values[ o1 + i ] + + sN * values[ oN + i ]; + + } + + return result; + + } + +} + +class LinearInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + offset1 = i1 * stride, + offset0 = offset1 - stride, + + weight1 = ( t - t0 ) / ( t1 - t0 ), + weight0 = 1 - weight1; + + for ( let i = 0; i !== stride; ++ i ) { + + result[ i ] = + values[ offset0 + i ] * weight0 + + values[ offset1 + i ] * weight1; + + } + + return result; + + } + +} + +/** + * + * Interpolant that evaluates to the sample value at the position preceeding + * the parameter. + */ + +class DiscreteInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1 /*, t0, t, t1 */ ) { + + return this.copySampleValue_( i1 - 1 ); + + } + +} + +class KeyframeTrack { + + constructor( name, times, values, interpolation ) { + + if ( name === undefined ) throw new Error( 'THREE.KeyframeTrack: track name is undefined' ); + if ( times === undefined || times.length === 0 ) throw new Error( 'THREE.KeyframeTrack: no keyframes in track named ' + name ); + + this.name = name; + + this.times = AnimationUtils.convertArray( times, this.TimeBufferType ); + this.values = AnimationUtils.convertArray( values, this.ValueBufferType ); + + this.setInterpolation( interpolation || this.DefaultInterpolation ); + + } + + // Serialization (in static context, because of constructor invocation + // and automatic invocation of .toJSON): + + static toJSON( track ) { + + const trackType = track.constructor; + + let json; + + // derived classes can define a static toJSON method + if ( trackType.toJSON !== this.toJSON ) { + + json = trackType.toJSON( track ); + + } else { + + // by default, we assume the data can be serialized as-is + json = { + + 'name': track.name, + 'times': AnimationUtils.convertArray( track.times, Array ), + 'values': AnimationUtils.convertArray( track.values, Array ) + + }; + + const interpolation = track.getInterpolation(); + + if ( interpolation !== track.DefaultInterpolation ) { + + json.interpolation = interpolation; + + } + + } + + json.type = track.ValueTypeName; // mandatory + + return json; + + } + + InterpolantFactoryMethodDiscrete( result ) { + + return new DiscreteInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + InterpolantFactoryMethodLinear( result ) { + + return new LinearInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + InterpolantFactoryMethodSmooth( result ) { + + return new CubicInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + + setInterpolation( interpolation ) { + + let factoryMethod; + + switch ( interpolation ) { + + case InterpolateDiscrete: + + factoryMethod = this.InterpolantFactoryMethodDiscrete; + + break; + + case InterpolateLinear: + + factoryMethod = this.InterpolantFactoryMethodLinear; + + break; + + case InterpolateSmooth: + + factoryMethod = this.InterpolantFactoryMethodSmooth; + + break; + + } + + if ( factoryMethod === undefined ) { + + const message = 'unsupported interpolation for ' + + this.ValueTypeName + ' keyframe track named ' + this.name; + + if ( this.createInterpolant === undefined ) { + + // fall back to default, unless the default itself is messed up + if ( interpolation !== this.DefaultInterpolation ) { + + this.setInterpolation( this.DefaultInterpolation ); + + } else { + + throw new Error( message ); // fatal, in this case + + } + + } + + console.warn( 'THREE.KeyframeTrack:', message ); + return this; + + } + + this.createInterpolant = factoryMethod; + + return this; + + } + + getInterpolation() { + + switch ( this.createInterpolant ) { + + case this.InterpolantFactoryMethodDiscrete: + + return InterpolateDiscrete; + + case this.InterpolantFactoryMethodLinear: + + return InterpolateLinear; + + case this.InterpolantFactoryMethodSmooth: + + return InterpolateSmooth; + + } + + } + + getValueSize() { + + return this.values.length / this.times.length; + + } + + // move all keyframes either forwards or backwards in time + shift( timeOffset ) { + + if ( timeOffset !== 0.0 ) { + + const times = this.times; + + for ( let i = 0, n = times.length; i !== n; ++ i ) { + + times[ i ] += timeOffset; + + } + + } + + return this; + + } + + // scale all keyframe times by a factor (useful for frame <-> seconds conversions) + scale( timeScale ) { + + if ( timeScale !== 1.0 ) { + + const times = this.times; + + for ( let i = 0, n = times.length; i !== n; ++ i ) { + + times[ i ] *= timeScale; + + } + + } + + return this; + + } + + // removes keyframes before and after animation without changing any values within the range [startTime, endTime]. + // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values + trim( startTime, endTime ) { + + const times = this.times, + nKeys = times.length; + + let from = 0, + to = nKeys - 1; + + while ( from !== nKeys && times[ from ] < startTime ) { + + ++ from; + + } + + while ( to !== - 1 && times[ to ] > endTime ) { + + -- to; + + } + + ++ to; // inclusive -> exclusive bound + + if ( from !== 0 || to !== nKeys ) { + + // empty tracks are forbidden, so keep at least one keyframe + if ( from >= to ) { + + to = Math.max( to, 1 ); + from = to - 1; + + } + + const stride = this.getValueSize(); + this.times = AnimationUtils.arraySlice( times, from, to ); + this.values = AnimationUtils.arraySlice( this.values, from * stride, to * stride ); + + } + + return this; + + } + + // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable + validate() { + + let valid = true; + + const valueSize = this.getValueSize(); + if ( valueSize - Math.floor( valueSize ) !== 0 ) { + + console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this ); + valid = false; + + } + + const times = this.times, + values = this.values, + + nKeys = times.length; + + if ( nKeys === 0 ) { + + console.error( 'THREE.KeyframeTrack: Track is empty.', this ); + valid = false; + + } + + let prevTime = null; + + for ( let i = 0; i !== nKeys; i ++ ) { + + const currTime = times[ i ]; + + if ( typeof currTime === 'number' && isNaN( currTime ) ) { + + console.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime ); + valid = false; + break; + + } + + if ( prevTime !== null && prevTime > currTime ) { + + console.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime ); + valid = false; + break; + + } + + prevTime = currTime; + + } + + if ( values !== undefined ) { + + if ( AnimationUtils.isTypedArray( values ) ) { + + for ( let i = 0, n = values.length; i !== n; ++ i ) { + + const value = values[ i ]; + + if ( isNaN( value ) ) { + + console.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value ); + valid = false; + break; + + } + + } + + } + + } + + return valid; + + } + + // removes equivalent sequential keys as common in morph target sequences + // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) + optimize() { + + // times or values may be shared with other tracks, so overwriting is unsafe + const times = AnimationUtils.arraySlice( this.times ), + values = AnimationUtils.arraySlice( this.values ), + stride = this.getValueSize(), + + smoothInterpolation = this.getInterpolation() === InterpolateSmooth, + + lastIndex = times.length - 1; + + let writeIndex = 1; + + for ( let i = 1; i < lastIndex; ++ i ) { + + let keep = false; + + const time = times[ i ]; + const timeNext = times[ i + 1 ]; + + // remove adjacent keyframes scheduled at the same time + + if ( time !== timeNext && ( i !== 1 || time !== times[ 0 ] ) ) { + + if ( ! smoothInterpolation ) { + + // remove unnecessary keyframes same as their neighbors + + const offset = i * stride, + offsetP = offset - stride, + offsetN = offset + stride; + + for ( let j = 0; j !== stride; ++ j ) { + + const value = values[ offset + j ]; + + if ( value !== values[ offsetP + j ] || + value !== values[ offsetN + j ] ) { + + keep = true; + break; + + } + + } + + } else { + + keep = true; + + } + + } + + // in-place compaction + + if ( keep ) { + + if ( i !== writeIndex ) { + + times[ writeIndex ] = times[ i ]; + + const readOffset = i * stride, + writeOffset = writeIndex * stride; + + for ( let j = 0; j !== stride; ++ j ) { + + values[ writeOffset + j ] = values[ readOffset + j ]; + + } + + } + + ++ writeIndex; + + } + + } + + // flush last keyframe (compaction looks ahead) + + if ( lastIndex > 0 ) { + + times[ writeIndex ] = times[ lastIndex ]; + + for ( let readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j ) { + + values[ writeOffset + j ] = values[ readOffset + j ]; + + } + + ++ writeIndex; + + } + + if ( writeIndex !== times.length ) { + + this.times = AnimationUtils.arraySlice( times, 0, writeIndex ); + this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride ); + + } else { + + this.times = times; + this.values = values; + + } + + return this; + + } + + clone() { + + const times = AnimationUtils.arraySlice( this.times, 0 ); + const values = AnimationUtils.arraySlice( this.values, 0 ); + + const TypedKeyframeTrack = this.constructor; + const track = new TypedKeyframeTrack( this.name, times, values ); + + // Interpolant argument to constructor is not saved, so copy the factory method directly. + track.createInterpolant = this.createInterpolant; + + return track; + + } + +} + +KeyframeTrack.prototype.TimeBufferType = Float32Array; +KeyframeTrack.prototype.ValueBufferType = Float32Array; +KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; + +/** + * A Track of Boolean keyframe values. + */ +class BooleanKeyframeTrack extends KeyframeTrack {} + +BooleanKeyframeTrack.prototype.ValueTypeName = 'bool'; +BooleanKeyframeTrack.prototype.ValueBufferType = Array; +BooleanKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track of keyframe values that represent color. + */ +class ColorKeyframeTrack extends KeyframeTrack {} + +ColorKeyframeTrack.prototype.ValueTypeName = 'color'; + +/** + * A Track of numeric keyframe values. + */ +class NumberKeyframeTrack extends KeyframeTrack {} + +NumberKeyframeTrack.prototype.ValueTypeName = 'number'; + +/** + * Spherical linear unit quaternion interpolant. + */ + +class QuaternionLinearInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + interpolate_( i1, t0, t, t1 ) { + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + + alpha = ( t - t0 ) / ( t1 - t0 ); + + let offset = i1 * stride; + + for ( let end = offset + stride; offset !== end; offset += 4 ) { + + Quaternion.slerpFlat( result, 0, values, offset - stride, values, offset, alpha ); + + } + + return result; + + } + +} + +/** + * A Track of quaternion keyframe values. + */ +class QuaternionKeyframeTrack extends KeyframeTrack { + + InterpolantFactoryMethodLinear( result ) { + + return new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result ); + + } + +} + +QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion'; +// ValueBufferType is inherited +QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; +QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track that interpolates Strings + */ +class StringKeyframeTrack extends KeyframeTrack {} + +StringKeyframeTrack.prototype.ValueTypeName = 'string'; +StringKeyframeTrack.prototype.ValueBufferType = Array; +StringKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +/** + * A Track of vectored keyframe values. + */ +class VectorKeyframeTrack extends KeyframeTrack {} + +VectorKeyframeTrack.prototype.ValueTypeName = 'vector'; + +class AnimationClip { + + constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) { + + this.name = name; + this.tracks = tracks; + this.duration = duration; + this.blendMode = blendMode; + + this.uuid = generateUUID(); + + // this means it should figure out its duration by scanning the tracks + if ( this.duration < 0 ) { + + this.resetDuration(); + + } + + } + + + static parse( json ) { + + const tracks = [], + jsonTracks = json.tracks, + frameTime = 1.0 / ( json.fps || 1.0 ); + + for ( let i = 0, n = jsonTracks.length; i !== n; ++ i ) { + + tracks.push( parseKeyframeTrack( jsonTracks[ i ] ).scale( frameTime ) ); + + } + + const clip = new this( json.name, json.duration, tracks, json.blendMode ); + clip.uuid = json.uuid; + + return clip; + + } + + static toJSON( clip ) { + + const tracks = [], + clipTracks = clip.tracks; + + const json = { + + 'name': clip.name, + 'duration': clip.duration, + 'tracks': tracks, + 'uuid': clip.uuid, + 'blendMode': clip.blendMode + + }; + + for ( let i = 0, n = clipTracks.length; i !== n; ++ i ) { + + tracks.push( KeyframeTrack.toJSON( clipTracks[ i ] ) ); + + } + + return json; + + } + + static CreateFromMorphTargetSequence( name, morphTargetSequence, fps, noLoop ) { + + const numMorphTargets = morphTargetSequence.length; + const tracks = []; + + for ( let i = 0; i < numMorphTargets; i ++ ) { + + let times = []; + let values = []; + + times.push( + ( i + numMorphTargets - 1 ) % numMorphTargets, + i, + ( i + 1 ) % numMorphTargets ); + + values.push( 0, 1, 0 ); + + const order = AnimationUtils.getKeyframeOrder( times ); + times = AnimationUtils.sortedArray( times, 1, order ); + values = AnimationUtils.sortedArray( values, 1, order ); + + // if there is a key at the first frame, duplicate it as the + // last frame as well for perfect loop. + if ( ! noLoop && times[ 0 ] === 0 ) { + + times.push( numMorphTargets ); + values.push( values[ 0 ] ); + + } + + tracks.push( + new NumberKeyframeTrack( + '.morphTargetInfluences[' + morphTargetSequence[ i ].name + ']', + times, values + ).scale( 1.0 / fps ) ); + + } + + return new this( name, - 1, tracks ); + + } + + static findByName( objectOrClipArray, name ) { + + let clipArray = objectOrClipArray; + + if ( ! Array.isArray( objectOrClipArray ) ) { + + const o = objectOrClipArray; + clipArray = o.geometry && o.geometry.animations || o.animations; + + } + + for ( let i = 0; i < clipArray.length; i ++ ) { + + if ( clipArray[ i ].name === name ) { + + return clipArray[ i ]; + + } + + } + + return null; + + } + + static CreateClipsFromMorphTargetSequences( morphTargets, fps, noLoop ) { + + const animationToMorphTargets = {}; + + // tested with https://regex101.com/ on trick sequences + // such flamingo_flyA_003, flamingo_run1_003, crdeath0059 + const pattern = /^([\w-]*?)([\d]+)$/; + + // sort morph target names into animation groups based + // patterns like Walk_001, Walk_002, Run_001, Run_002 + for ( let i = 0, il = morphTargets.length; i < il; i ++ ) { + + const morphTarget = morphTargets[ i ]; + const parts = morphTarget.name.match( pattern ); + + if ( parts && parts.length > 1 ) { + + const name = parts[ 1 ]; + + let animationMorphTargets = animationToMorphTargets[ name ]; + + if ( ! animationMorphTargets ) { + + animationToMorphTargets[ name ] = animationMorphTargets = []; + + } + + animationMorphTargets.push( morphTarget ); + + } + + } + + const clips = []; + + for ( const name in animationToMorphTargets ) { + + clips.push( this.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps, noLoop ) ); + + } + + return clips; + + } + + // parse the animation.hierarchy format + static parseAnimation( animation, bones ) { + + if ( ! animation ) { + + console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' ); + return null; + + } + + const addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) { + + // only return track if there are actually keys. + if ( animationKeys.length !== 0 ) { + + const times = []; + const values = []; + + AnimationUtils.flattenJSON( animationKeys, times, values, propertyName ); + + // empty keys are filtered out, so check again + if ( times.length !== 0 ) { + + destTracks.push( new trackType( trackName, times, values ) ); + + } + + } + + }; + + const tracks = []; + + const clipName = animation.name || 'default'; + const fps = animation.fps || 30; + const blendMode = animation.blendMode; + + // automatic length determination in AnimationClip. + let duration = animation.length || - 1; + + const hierarchyTracks = animation.hierarchy || []; + + for ( let h = 0; h < hierarchyTracks.length; h ++ ) { + + const animationKeys = hierarchyTracks[ h ].keys; + + // skip empty tracks + if ( ! animationKeys || animationKeys.length === 0 ) continue; + + // process morph targets + if ( animationKeys[ 0 ].morphTargets ) { + + // figure out all morph targets used in this track + const morphTargetNames = {}; + + let k; + + for ( k = 0; k < animationKeys.length; k ++ ) { + + if ( animationKeys[ k ].morphTargets ) { + + for ( let m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) { + + morphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1; + + } + + } + + } + + // create a track for each morph target with all zero + // morphTargetInfluences except for the keys in which + // the morphTarget is named. + for ( const morphTargetName in morphTargetNames ) { + + const times = []; + const values = []; + + for ( let m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) { + + const animationKey = animationKeys[ k ]; + + times.push( animationKey.time ); + values.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 ); + + } + + tracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) ); + + } + + duration = morphTargetNames.length * ( fps || 1.0 ); + + } else { + + // ...assume skeletal animation + + const boneName = '.bones[' + bones[ h ].name + ']'; + + addNonemptyTrack( + VectorKeyframeTrack, boneName + '.position', + animationKeys, 'pos', tracks ); + + addNonemptyTrack( + QuaternionKeyframeTrack, boneName + '.quaternion', + animationKeys, 'rot', tracks ); + + addNonemptyTrack( + VectorKeyframeTrack, boneName + '.scale', + animationKeys, 'scl', tracks ); + + } + + } + + if ( tracks.length === 0 ) { + + return null; + + } + + const clip = new this( clipName, duration, tracks, blendMode ); + + return clip; + + } + + resetDuration() { + + const tracks = this.tracks; + let duration = 0; + + for ( let i = 0, n = tracks.length; i !== n; ++ i ) { + + const track = this.tracks[ i ]; + + duration = Math.max( duration, track.times[ track.times.length - 1 ] ); + + } + + this.duration = duration; + + return this; + + } + + trim() { + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + this.tracks[ i ].trim( 0, this.duration ); + + } + + return this; + + } + + validate() { + + let valid = true; + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + valid = valid && this.tracks[ i ].validate(); + + } + + return valid; + + } + + optimize() { + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + this.tracks[ i ].optimize(); + + } + + return this; + + } + + clone() { + + const tracks = []; + + for ( let i = 0; i < this.tracks.length; i ++ ) { + + tracks.push( this.tracks[ i ].clone() ); + + } + + return new this.constructor( this.name, this.duration, tracks, this.blendMode ); + + } + + toJSON() { + + return this.constructor.toJSON( this ); + + } + +} + +function getTrackTypeForValueTypeName( typeName ) { + + switch ( typeName.toLowerCase() ) { + + case 'scalar': + case 'double': + case 'float': + case 'number': + case 'integer': + + return NumberKeyframeTrack; + + case 'vector': + case 'vector2': + case 'vector3': + case 'vector4': + + return VectorKeyframeTrack; + + case 'color': + + return ColorKeyframeTrack; + + case 'quaternion': + + return QuaternionKeyframeTrack; + + case 'bool': + case 'boolean': + + return BooleanKeyframeTrack; + + case 'string': + + return StringKeyframeTrack; + + } + + throw new Error( 'THREE.KeyframeTrack: Unsupported typeName: ' + typeName ); + +} + +function parseKeyframeTrack( json ) { + + if ( json.type === undefined ) { + + throw new Error( 'THREE.KeyframeTrack: track type undefined, can not parse' ); + + } + + const trackType = getTrackTypeForValueTypeName( json.type ); + + if ( json.times === undefined ) { + + const times = [], values = []; + + AnimationUtils.flattenJSON( json.keys, times, values, 'value' ); + + json.times = times; + json.values = values; + + } + + // derived classes can define a static parse method + if ( trackType.parse !== undefined ) { + + return trackType.parse( json ); + + } else { + + // by default, we assume a constructor compatible with the base + return new trackType( json.name, json.times, json.values, json.interpolation ); + + } + +} + +const Cache = { + + enabled: false, + + files: {}, + + add: function ( key, file ) { + + if ( this.enabled === false ) return; + + // console.log( 'THREE.Cache', 'Adding key:', key ); + + this.files[ key ] = file; + + }, + + get: function ( key ) { + + if ( this.enabled === false ) return; + + // console.log( 'THREE.Cache', 'Checking key:', key ); + + return this.files[ key ]; + + }, + + remove: function ( key ) { + + delete this.files[ key ]; + + }, + + clear: function () { + + this.files = {}; + + } + +}; + +class LoadingManager { + + constructor( onLoad, onProgress, onError ) { + + const scope = this; + + let isLoading = false; + let itemsLoaded = 0; + let itemsTotal = 0; + let urlModifier = undefined; + const handlers = []; + + // Refer to #5689 for the reason why we don't set .onStart + // in the constructor + + this.onStart = undefined; + this.onLoad = onLoad; + this.onProgress = onProgress; + this.onError = onError; + + this.itemStart = function ( url ) { + + itemsTotal ++; + + if ( isLoading === false ) { + + if ( scope.onStart !== undefined ) { + + scope.onStart( url, itemsLoaded, itemsTotal ); + + } + + } + + isLoading = true; + + }; + + this.itemEnd = function ( url ) { + + itemsLoaded ++; + + if ( scope.onProgress !== undefined ) { + + scope.onProgress( url, itemsLoaded, itemsTotal ); + + } + + if ( itemsLoaded === itemsTotal ) { + + isLoading = false; + + if ( scope.onLoad !== undefined ) { + + scope.onLoad(); + + } + + } + + }; + + this.itemError = function ( url ) { + + if ( scope.onError !== undefined ) { + + scope.onError( url ); + + } + + }; + + this.resolveURL = function ( url ) { + + if ( urlModifier ) { + + return urlModifier( url ); + + } + + return url; + + }; + + this.setURLModifier = function ( transform ) { + + urlModifier = transform; + + return this; + + }; + + this.addHandler = function ( regex, loader ) { + + handlers.push( regex, loader ); + + return this; + + }; + + this.removeHandler = function ( regex ) { + + const index = handlers.indexOf( regex ); + + if ( index !== - 1 ) { + + handlers.splice( index, 2 ); + + } + + return this; + + }; + + this.getHandler = function ( file ) { + + for ( let i = 0, l = handlers.length; i < l; i += 2 ) { + + const regex = handlers[ i ]; + const loader = handlers[ i + 1 ]; + + if ( regex.global ) regex.lastIndex = 0; // see #17920 + + if ( regex.test( file ) ) { + + return loader; + + } + + } + + return null; + + }; + + } + +} + +const DefaultLoadingManager = new LoadingManager(); + +class Loader { + + constructor( manager ) { + + this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + + this.crossOrigin = 'anonymous'; + this.withCredentials = false; + this.path = ''; + this.resourcePath = ''; + this.requestHeader = {}; + + } + + load( /* url, onLoad, onProgress, onError */ ) {} + + loadAsync( url, onProgress ) { + + const scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.load( url, resolve, onProgress, reject ); + + } ); + + } + + parse( /* data */ ) {} + + setCrossOrigin( crossOrigin ) { + + this.crossOrigin = crossOrigin; + return this; + + } + + setWithCredentials( value ) { + + this.withCredentials = value; + return this; + + } + + setPath( path ) { + + this.path = path; + return this; + + } + + setResourcePath( resourcePath ) { + + this.resourcePath = resourcePath; + return this; + + } + + setRequestHeader( requestHeader ) { + + this.requestHeader = requestHeader; + return this; + + } + +} + +const loading = {}; + +class FileLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + if ( url === undefined ) url = ''; + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + this.manager.itemStart( url ); + + setTimeout( () => { + + if ( onLoad ) onLoad( cached ); + + this.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + // Check if request is duplicate + + if ( loading[ url ] !== undefined ) { + + loading[ url ].push( { + + onLoad: onLoad, + onProgress: onProgress, + onError: onError + + } ); + + return; + + } + + // Initialise array for duplicate requests + loading[ url ] = []; + + loading[ url ].push( { + onLoad: onLoad, + onProgress: onProgress, + onError: onError, + } ); + + // create request + const req = new Request( url, { + headers: new Headers( this.requestHeader ), + credentials: this.withCredentials ? 'include' : 'same-origin', + // An abort controller could be added within a future PR + } ); + + // start the fetch + fetch( req ) + .then( response => { + + if ( response.status === 200 || response.status === 0 ) { + + // Some browsers return HTTP Status 0 when using non-http protocol + // e.g. 'file://' or 'data://'. Handle as success. + + if ( response.status === 0 ) { + + console.warn( 'THREE.FileLoader: HTTP Status 0 received.' ); + + } + + if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) { + + return response; + + } + + const callbacks = loading[ url ]; + const reader = response.body.getReader(); + const contentLength = response.headers.get( 'Content-Length' ); + const total = contentLength ? parseInt( contentLength ) : 0; + const lengthComputable = total !== 0; + let loaded = 0; + + // periodically read data into the new stream tracking while download progress + const stream = new ReadableStream( { + start( controller ) { + + readData(); + + function readData() { + + reader.read().then( ( { done, value } ) => { + + if ( done ) { + + controller.close(); + + } else { + + loaded += value.byteLength; + + const event = new ProgressEvent( 'progress', { lengthComputable, loaded, total } ); + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onProgress ) callback.onProgress( event ); + + } + + controller.enqueue( value ); + readData(); + + } + + } ); + + } + + } + + } ); + + return new Response( stream ); + + } else { + + throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` ); + + } + + } ) + .then( response => { + + switch ( this.responseType ) { + + case 'arraybuffer': + + return response.arrayBuffer(); + + case 'blob': + + return response.blob(); + + case 'document': + + return response.text() + .then( text => { + + const parser = new DOMParser(); + return parser.parseFromString( text, this.mimeType ); + + } ); + + case 'json': + + return response.json(); + + default: + + return response.text(); + + } + + } ) + .then( data => { + + // Add to cache only on HTTP success, so that we do not cache + // error response bodies as proper responses to requests. + Cache.add( url, data ); + + const callbacks = loading[ url ]; + delete loading[ url ]; + + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onLoad ) callback.onLoad( data ); + + } + + } ) + .catch( err => { + + // Abort errors and other errors are handled the same + + const callbacks = loading[ url ]; + + if ( callbacks === undefined ) { + + // When onLoad was called and url was deleted in `loading` + this.manager.itemError( url ); + throw err; + + } + + delete loading[ url ]; + + for ( let i = 0, il = callbacks.length; i < il; i ++ ) { + + const callback = callbacks[ i ]; + if ( callback.onError ) callback.onError( err ); + + } + + this.manager.itemError( url ); + + } ) + .finally( () => { + + this.manager.itemEnd( url ); + + } ); + + this.manager.itemStart( url ); + + } + + setResponseType( value ) { + + this.responseType = value; + return this; + + } + + setMimeType( value ) { + + this.mimeType = value; + return this; + + } + +} + +class AnimationLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const loader = new FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + loader.load( url, function ( text ) { + + try { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + } catch ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + + } + + }, onProgress, onError ); + + } + + parse( json ) { + + const animations = []; + + for ( let i = 0; i < json.length; i ++ ) { + + const clip = AnimationClip.parse( json[ i ] ); + + animations.push( clip ); + + } + + return animations; + + } + +} + +/** + * Abstract Base class to block based textures loader (dds, pvr, ...) + * + * Sub classes have to implement the parse() method which will be used in load(). + */ + +class CompressedTextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const images = []; + + const texture = new CompressedTexture(); + + const loader = new FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( scope.withCredentials ); + + let loaded = 0; + + function loadTexture( i ) { + + loader.load( url[ i ], function ( buffer ) { + + const texDatas = scope.parse( buffer, true ); + + images[ i ] = { + width: texDatas.width, + height: texDatas.height, + format: texDatas.format, + mipmaps: texDatas.mipmaps + }; + + loaded += 1; + + if ( loaded === 6 ) { + + if ( texDatas.mipmapCount === 1 ) texture.minFilter = LinearFilter; + + texture.image = images; + texture.format = texDatas.format; + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture ); + + } + + }, onProgress, onError ); + + } + + if ( Array.isArray( url ) ) { + + for ( let i = 0, il = url.length; i < il; ++ i ) { + + loadTexture( i ); + + } + + } else { + + // compressed cubemap texture stored in a single DDS file + + loader.load( url, function ( buffer ) { + + const texDatas = scope.parse( buffer, true ); + + if ( texDatas.isCubemap ) { + + const faces = texDatas.mipmaps.length / texDatas.mipmapCount; + + for ( let f = 0; f < faces; f ++ ) { + + images[ f ] = { mipmaps: [] }; + + for ( let i = 0; i < texDatas.mipmapCount; i ++ ) { + + images[ f ].mipmaps.push( texDatas.mipmaps[ f * texDatas.mipmapCount + i ] ); + images[ f ].format = texDatas.format; + images[ f ].width = texDatas.width; + images[ f ].height = texDatas.height; + + } + + } + + texture.image = images; + + } else { + + texture.image.width = texDatas.width; + texture.image.height = texDatas.height; + texture.mipmaps = texDatas.mipmaps; + + } + + if ( texDatas.mipmapCount === 1 ) { + + texture.minFilter = LinearFilter; + + } + + texture.format = texDatas.format; + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture ); + + }, onProgress, onError ); + + } + + return texture; + + } + +} + +class ImageLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const scope = this; + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + scope.manager.itemStart( url ); + + setTimeout( function () { + + if ( onLoad ) onLoad( cached ); + + scope.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + const image = createElementNS( 'img' ); + + function onImageLoad() { + + removeEventListeners(); + + Cache.add( url, this ); + + if ( onLoad ) onLoad( this ); + + scope.manager.itemEnd( url ); + + } + + function onImageError( event ) { + + removeEventListeners(); + + if ( onError ) onError( event ); + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + } + + function removeEventListeners() { + + image.removeEventListener( 'load', onImageLoad, false ); + image.removeEventListener( 'error', onImageError, false ); + + } + + image.addEventListener( 'load', onImageLoad, false ); + image.addEventListener( 'error', onImageError, false ); + + if ( url.substr( 0, 5 ) !== 'data:' ) { + + if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin; + + } + + scope.manager.itemStart( url ); + + image.src = url; + + return image; + + } + +} + +class CubeTextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( urls, onLoad, onProgress, onError ) { + + const texture = new CubeTexture(); + + const loader = new ImageLoader( this.manager ); + loader.setCrossOrigin( this.crossOrigin ); + loader.setPath( this.path ); + + let loaded = 0; + + function loadTexture( i ) { + + loader.load( urls[ i ], function ( image ) { + + texture.images[ i ] = image; + + loaded ++; + + if ( loaded === 6 ) { + + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture ); + + } + + }, undefined, onError ); + + } + + for ( let i = 0; i < urls.length; ++ i ) { + + loadTexture( i ); + + } + + return texture; + + } + +} + +/** + * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...) + * + * Sub classes have to implement the parse() method which will be used in load(). + */ + +class DataTextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const texture = new DataTexture(); + + const loader = new FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setPath( this.path ); + loader.setWithCredentials( scope.withCredentials ); + loader.load( url, function ( buffer ) { + + const texData = scope.parse( buffer ); + + if ( ! texData ) return; + + if ( texData.image !== undefined ) { + + texture.image = texData.image; + + } else if ( texData.data !== undefined ) { + + texture.image.width = texData.width; + texture.image.height = texData.height; + texture.image.data = texData.data; + + } + + texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping; + texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping; + + texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter; + texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter; + + texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1; + + if ( texData.encoding !== undefined ) { + + texture.encoding = texData.encoding; + + } + + if ( texData.flipY !== undefined ) { + + texture.flipY = texData.flipY; + + } + + if ( texData.format !== undefined ) { + + texture.format = texData.format; + + } + + if ( texData.type !== undefined ) { + + texture.type = texData.type; + + } + + if ( texData.mipmaps !== undefined ) { + + texture.mipmaps = texData.mipmaps; + texture.minFilter = LinearMipmapLinearFilter; // presumably... + + } + + if ( texData.mipmapCount === 1 ) { + + texture.minFilter = LinearFilter; + + } + + if ( texData.generateMipmaps !== undefined ) { + + texture.generateMipmaps = texData.generateMipmaps; + + } + + texture.needsUpdate = true; + + if ( onLoad ) onLoad( texture, texData ); + + }, onProgress, onError ); + + + return texture; + + } + +} + +class TextureLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const texture = new Texture(); + + const loader = new ImageLoader( this.manager ); + loader.setCrossOrigin( this.crossOrigin ); + loader.setPath( this.path ); + + loader.load( url, function ( image ) { + + texture.image = image; + texture.needsUpdate = true; + + if ( onLoad !== undefined ) { + + onLoad( texture ); + + } + + }, onProgress, onError ); + + return texture; + + } + +} + +class Light extends Object3D { + + constructor( color, intensity = 1 ) { + + super(); + + this.type = 'Light'; + + this.color = new Color( color ); + this.intensity = intensity; + + } + + dispose() { + + // Empty here in base class; some subclasses override. + + } + + copy( source ) { + + super.copy( source ); + + this.color.copy( source.color ); + this.intensity = source.intensity; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.color = this.color.getHex(); + data.object.intensity = this.intensity; + + if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex(); + + if ( this.distance !== undefined ) data.object.distance = this.distance; + if ( this.angle !== undefined ) data.object.angle = this.angle; + if ( this.decay !== undefined ) data.object.decay = this.decay; + if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra; + + if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON(); + + return data; + + } + +} + +Light.prototype.isLight = true; + +class HemisphereLight extends Light { + + constructor( skyColor, groundColor, intensity ) { + + super( skyColor, intensity ); + + this.type = 'HemisphereLight'; + + this.position.copy( Object3D.DefaultUp ); + this.updateMatrix(); + + this.groundColor = new Color( groundColor ); + + } + + copy( source ) { + + Light.prototype.copy.call( this, source ); + + this.groundColor.copy( source.groundColor ); + + return this; + + } + +} + +HemisphereLight.prototype.isHemisphereLight = true; + +const _projScreenMatrix$1 = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld$1 = /*@__PURE__*/ new Vector3(); +const _lookTarget$1 = /*@__PURE__*/ new Vector3(); + +class LightShadow { + + constructor( camera ) { + + this.camera = camera; + + this.bias = 0; + this.normalBias = 0; + this.radius = 1; + this.blurSamples = 8; + + this.mapSize = new Vector2( 512, 512 ); + + this.map = null; + this.mapPass = null; + this.matrix = new Matrix4(); + + this.autoUpdate = true; + this.needsUpdate = false; + + this._frustum = new Frustum(); + this._frameExtents = new Vector2( 1, 1 ); + + this._viewportCount = 1; + + this._viewports = [ + + new Vector4( 0, 0, 1, 1 ) + + ]; + + } + + getViewportCount() { + + return this._viewportCount; + + } + + getFrustum() { + + return this._frustum; + + } + + updateMatrices( light ) { + + const shadowCamera = this.camera; + const shadowMatrix = this.matrix; + + _lightPositionWorld$1.setFromMatrixPosition( light.matrixWorld ); + shadowCamera.position.copy( _lightPositionWorld$1 ); + + _lookTarget$1.setFromMatrixPosition( light.target.matrixWorld ); + shadowCamera.lookAt( _lookTarget$1 ); + shadowCamera.updateMatrixWorld(); + + _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse ); + this._frustum.setFromProjectionMatrix( _projScreenMatrix$1 ); + + shadowMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + + shadowMatrix.multiply( shadowCamera.projectionMatrix ); + shadowMatrix.multiply( shadowCamera.matrixWorldInverse ); + + } + + getViewport( viewportIndex ) { + + return this._viewports[ viewportIndex ]; + + } + + getFrameExtents() { + + return this._frameExtents; + + } + + dispose() { + + if ( this.map ) { + + this.map.dispose(); + + } + + if ( this.mapPass ) { + + this.mapPass.dispose(); + + } + + } + + copy( source ) { + + this.camera = source.camera.clone(); + + this.bias = source.bias; + this.radius = source.radius; + + this.mapSize.copy( source.mapSize ); + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + toJSON() { + + const object = {}; + + if ( this.bias !== 0 ) object.bias = this.bias; + if ( this.normalBias !== 0 ) object.normalBias = this.normalBias; + if ( this.radius !== 1 ) object.radius = this.radius; + if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray(); + + object.camera = this.camera.toJSON( false ).object; + delete object.camera.matrix; + + return object; + + } + +} + +class SpotLightShadow extends LightShadow { + + constructor() { + + super( new PerspectiveCamera( 50, 1, 0.5, 500 ) ); + + this.focus = 1; + + } + + updateMatrices( light ) { + + const camera = this.camera; + + const fov = RAD2DEG * 2 * light.angle * this.focus; + const aspect = this.mapSize.width / this.mapSize.height; + const far = light.distance || camera.far; + + if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) { + + camera.fov = fov; + camera.aspect = aspect; + camera.far = far; + camera.updateProjectionMatrix(); + + } + + super.updateMatrices( light ); + + } + + copy( source ) { + + super.copy( source ); + + this.focus = source.focus; + + return this; + + } + +} + +SpotLightShadow.prototype.isSpotLightShadow = true; + +class SpotLight extends Light { + + constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1 ) { + + super( color, intensity ); + + this.type = 'SpotLight'; + + this.position.copy( Object3D.DefaultUp ); + this.updateMatrix(); + + this.target = new Object3D(); + + this.distance = distance; + this.angle = angle; + this.penumbra = penumbra; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new SpotLightShadow(); + + } + + get power() { + + // compute the light's luminous power (in lumens) from its intensity (in candela) + // by convention for a spotlight, luminous power (lm) = π * luminous intensity (cd) + return this.intensity * Math.PI; + + } + + set power( power ) { + + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / Math.PI; + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.distance = source.distance; + this.angle = source.angle; + this.penumbra = source.penumbra; + this.decay = source.decay; + + this.target = source.target.clone(); + + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +SpotLight.prototype.isSpotLight = true; + +const _projScreenMatrix = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld = /*@__PURE__*/ new Vector3(); +const _lookTarget = /*@__PURE__*/ new Vector3(); + +class PointLightShadow extends LightShadow { + + constructor() { + + super( new PerspectiveCamera( 90, 1, 0.5, 500 ) ); + + this._frameExtents = new Vector2( 4, 2 ); + + this._viewportCount = 6; + + this._viewports = [ + // These viewports map a cube-map onto a 2D texture with the + // following orientation: + // + // xzXZ + // y Y + // + // X - Positive x direction + // x - Negative x direction + // Y - Positive y direction + // y - Negative y direction + // Z - Positive z direction + // z - Negative z direction + + // positive X + new Vector4( 2, 1, 1, 1 ), + // negative X + new Vector4( 0, 1, 1, 1 ), + // positive Z + new Vector4( 3, 1, 1, 1 ), + // negative Z + new Vector4( 1, 1, 1, 1 ), + // positive Y + new Vector4( 3, 0, 1, 1 ), + // negative Y + new Vector4( 1, 0, 1, 1 ) + ]; + + this._cubeDirections = [ + new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ), + new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 ) + ]; + + this._cubeUps = [ + new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), + new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, - 1 ) + ]; + + } + + updateMatrices( light, viewportIndex = 0 ) { + + const camera = this.camera; + const shadowMatrix = this.matrix; + + const far = light.distance || camera.far; + + if ( far !== camera.far ) { + + camera.far = far; + camera.updateProjectionMatrix(); + + } + + _lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); + camera.position.copy( _lightPositionWorld ); + + _lookTarget.copy( camera.position ); + _lookTarget.add( this._cubeDirections[ viewportIndex ] ); + camera.up.copy( this._cubeUps[ viewportIndex ] ); + camera.lookAt( _lookTarget ); + camera.updateMatrixWorld(); + + shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z ); + + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); + this._frustum.setFromProjectionMatrix( _projScreenMatrix ); + + } + +} + +PointLightShadow.prototype.isPointLightShadow = true; + +class PointLight extends Light { + + constructor( color, intensity, distance = 0, decay = 1 ) { + + super( color, intensity ); + + this.type = 'PointLight'; + + this.distance = distance; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new PointLightShadow(); + + } + + get power() { + + // compute the light's luminous power (in lumens) from its intensity (in candela) + // for an isotropic light source, luminous power (lm) = 4 π luminous intensity (cd) + return this.intensity * 4 * Math.PI; + + } + + set power( power ) { + + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / ( 4 * Math.PI ); + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.distance = source.distance; + this.decay = source.decay; + + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +PointLight.prototype.isPointLight = true; + +class DirectionalLightShadow extends LightShadow { + + constructor() { + + super( new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) ); + + } + +} + +DirectionalLightShadow.prototype.isDirectionalLightShadow = true; + +class DirectionalLight extends Light { + + constructor( color, intensity ) { + + super( color, intensity ); + + this.type = 'DirectionalLight'; + + this.position.copy( Object3D.DefaultUp ); + this.updateMatrix(); + + this.target = new Object3D(); + + this.shadow = new DirectionalLightShadow(); + + } + + dispose() { + + this.shadow.dispose(); + + } + + copy( source ) { + + super.copy( source ); + + this.target = source.target.clone(); + this.shadow = source.shadow.clone(); + + return this; + + } + +} + +DirectionalLight.prototype.isDirectionalLight = true; + +class AmbientLight extends Light { + + constructor( color, intensity ) { + + super( color, intensity ); + + this.type = 'AmbientLight'; + + } + +} + +AmbientLight.prototype.isAmbientLight = true; + +class RectAreaLight extends Light { + + constructor( color, intensity, width = 10, height = 10 ) { + + super( color, intensity ); + + this.type = 'RectAreaLight'; + + this.width = width; + this.height = height; + + } + + get power() { + + // compute the light's luminous power (in lumens) from its intensity (in nits) + return this.intensity * this.width * this.height * Math.PI; + + } + + set power( power ) { + + // set the light's intensity (in nits) from the desired luminous power (in lumens) + this.intensity = power / ( this.width * this.height * Math.PI ); + + } + + copy( source ) { + + super.copy( source ); + + this.width = source.width; + this.height = source.height; + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.width = this.width; + data.object.height = this.height; + + return data; + + } + +} + +RectAreaLight.prototype.isRectAreaLight = true; + +/** + * Primary reference: + * https://graphics.stanford.edu/papers/envmap/envmap.pdf + * + * Secondary reference: + * https://www.ppsloan.org/publications/StupidSH36.pdf + */ + +// 3-band SH defined by 9 coefficients + +class SphericalHarmonics3 { + + constructor() { + + this.coefficients = []; + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients.push( new Vector3() ); + + } + + } + + set( coefficients ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].copy( coefficients[ i ] ); + + } + + return this; + + } + + zero() { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].set( 0, 0, 0 ); + + } + + return this; + + } + + // get the radiance in the direction of the normal + // target is a Vector3 + getAt( normal, target ) { + + // normal is assumed to be unit length + + const x = normal.x, y = normal.y, z = normal.z; + + const coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.282095 ); + + // band 1 + target.addScaledVector( coeff[ 1 ], 0.488603 * y ); + target.addScaledVector( coeff[ 2 ], 0.488603 * z ); + target.addScaledVector( coeff[ 3 ], 0.488603 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 1.092548 * ( x * y ) ); + target.addScaledVector( coeff[ 5 ], 1.092548 * ( y * z ) ); + target.addScaledVector( coeff[ 6 ], 0.315392 * ( 3.0 * z * z - 1.0 ) ); + target.addScaledVector( coeff[ 7 ], 1.092548 * ( x * z ) ); + target.addScaledVector( coeff[ 8 ], 0.546274 * ( x * x - y * y ) ); + + return target; + + } + + // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal + // target is a Vector3 + // https://graphics.stanford.edu/papers/envmap/envmap.pdf + getIrradianceAt( normal, target ) { + + // normal is assumed to be unit length + + const x = normal.x, y = normal.y, z = normal.z; + + const coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.886227 ); // π * 0.282095 + + // band 1 + target.addScaledVector( coeff[ 1 ], 2.0 * 0.511664 * y ); // ( 2 * π / 3 ) * 0.488603 + target.addScaledVector( coeff[ 2 ], 2.0 * 0.511664 * z ); + target.addScaledVector( coeff[ 3 ], 2.0 * 0.511664 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 2.0 * 0.429043 * x * y ); // ( π / 4 ) * 1.092548 + target.addScaledVector( coeff[ 5 ], 2.0 * 0.429043 * y * z ); + target.addScaledVector( coeff[ 6 ], 0.743125 * z * z - 0.247708 ); // ( π / 4 ) * 0.315392 * 3 + target.addScaledVector( coeff[ 7 ], 2.0 * 0.429043 * x * z ); + target.addScaledVector( coeff[ 8 ], 0.429043 * ( x * x - y * y ) ); // ( π / 4 ) * 0.546274 + + return target; + + } + + add( sh ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].add( sh.coefficients[ i ] ); + + } + + return this; + + } + + addScaledSH( sh, s ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].addScaledVector( sh.coefficients[ i ], s ); + + } + + return this; + + } + + scale( s ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].multiplyScalar( s ); + + } + + return this; + + } + + lerp( sh, alpha ) { + + for ( let i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].lerp( sh.coefficients[ i ], alpha ); + + } + + return this; + + } + + equals( sh ) { + + for ( let i = 0; i < 9; i ++ ) { + + if ( ! this.coefficients[ i ].equals( sh.coefficients[ i ] ) ) { + + return false; + + } + + } + + return true; + + } + + copy( sh ) { + + return this.set( sh.coefficients ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + fromArray( array, offset = 0 ) { + + const coefficients = this.coefficients; + + for ( let i = 0; i < 9; i ++ ) { + + coefficients[ i ].fromArray( array, offset + ( i * 3 ) ); + + } + + return this; + + } + + toArray( array = [], offset = 0 ) { + + const coefficients = this.coefficients; + + for ( let i = 0; i < 9; i ++ ) { + + coefficients[ i ].toArray( array, offset + ( i * 3 ) ); + + } + + return array; + + } + + // evaluate the basis functions + // shBasis is an Array[ 9 ] + static getBasisAt( normal, shBasis ) { + + // normal is assumed to be unit length + + const x = normal.x, y = normal.y, z = normal.z; + + // band 0 + shBasis[ 0 ] = 0.282095; + + // band 1 + shBasis[ 1 ] = 0.488603 * y; + shBasis[ 2 ] = 0.488603 * z; + shBasis[ 3 ] = 0.488603 * x; + + // band 2 + shBasis[ 4 ] = 1.092548 * x * y; + shBasis[ 5 ] = 1.092548 * y * z; + shBasis[ 6 ] = 0.315392 * ( 3 * z * z - 1 ); + shBasis[ 7 ] = 1.092548 * x * z; + shBasis[ 8 ] = 0.546274 * ( x * x - y * y ); + + } + +} + +SphericalHarmonics3.prototype.isSphericalHarmonics3 = true; + +class LightProbe extends Light { + + constructor( sh = new SphericalHarmonics3(), intensity = 1 ) { + + super( undefined, intensity ); + + this.sh = sh; + + } + + copy( source ) { + + super.copy( source ); + + this.sh.copy( source.sh ); + + return this; + + } + + fromJSON( json ) { + + this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); + this.sh.fromArray( json.sh ); + + return this; + + } + + toJSON( meta ) { + + const data = super.toJSON( meta ); + + data.object.sh = this.sh.toArray(); + + return data; + + } + +} + +LightProbe.prototype.isLightProbe = true; + +class MaterialLoader extends Loader { + + constructor( manager ) { + + super( manager ); + this.textures = {}; + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const loader = new FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setRequestHeader( scope.requestHeader ); + loader.setWithCredentials( scope.withCredentials ); + loader.load( url, function ( text ) { + + try { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + } catch ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + + } + + }, onProgress, onError ); + + } + + parse( json ) { + + const textures = this.textures; + + function getTexture( name ) { + + if ( textures[ name ] === undefined ) { + + console.warn( 'THREE.MaterialLoader: Undefined texture', name ); + + } + + return textures[ name ]; + + } + + const material = new Materials[ json.type ](); + + if ( json.uuid !== undefined ) material.uuid = json.uuid; + if ( json.name !== undefined ) material.name = json.name; + if ( json.color !== undefined && material.color !== undefined ) material.color.setHex( json.color ); + if ( json.roughness !== undefined ) material.roughness = json.roughness; + if ( json.metalness !== undefined ) material.metalness = json.metalness; + if ( json.sheen !== undefined ) material.sheen = json.sheen; + if ( json.sheenColor !== undefined ) material.sheenColor = new Color().setHex( json.sheenColor ); + if ( json.sheenRoughness !== undefined ) material.sheenRoughness = json.sheenRoughness; + if ( json.emissive !== undefined && material.emissive !== undefined ) material.emissive.setHex( json.emissive ); + if ( json.specular !== undefined && material.specular !== undefined ) material.specular.setHex( json.specular ); + if ( json.specularIntensity !== undefined ) material.specularIntensity = json.specularIntensity; + if ( json.specularColor !== undefined && material.specularColor !== undefined ) material.specularColor.setHex( json.specularColor ); + if ( json.shininess !== undefined ) material.shininess = json.shininess; + if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat; + if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness; + if ( json.transmission !== undefined ) material.transmission = json.transmission; + if ( json.thickness !== undefined ) material.thickness = json.thickness; + if ( json.attenuationDistance !== undefined ) material.attenuationDistance = json.attenuationDistance; + if ( json.attenuationColor !== undefined && material.attenuationColor !== undefined ) material.attenuationColor.setHex( json.attenuationColor ); + if ( json.fog !== undefined ) material.fog = json.fog; + if ( json.flatShading !== undefined ) material.flatShading = json.flatShading; + if ( json.blending !== undefined ) material.blending = json.blending; + if ( json.combine !== undefined ) material.combine = json.combine; + if ( json.side !== undefined ) material.side = json.side; + if ( json.shadowSide !== undefined ) material.shadowSide = json.shadowSide; + if ( json.opacity !== undefined ) material.opacity = json.opacity; + if ( json.transparent !== undefined ) material.transparent = json.transparent; + if ( json.alphaTest !== undefined ) material.alphaTest = json.alphaTest; + if ( json.depthTest !== undefined ) material.depthTest = json.depthTest; + if ( json.depthWrite !== undefined ) material.depthWrite = json.depthWrite; + if ( json.colorWrite !== undefined ) material.colorWrite = json.colorWrite; + if ( json.alphaWrite !== undefined ) material.alphaWrite = json.alphaWrite; + + if ( json.stencilWrite !== undefined ) material.stencilWrite = json.stencilWrite; + if ( json.stencilWriteMask !== undefined ) material.stencilWriteMask = json.stencilWriteMask; + if ( json.stencilFunc !== undefined ) material.stencilFunc = json.stencilFunc; + if ( json.stencilRef !== undefined ) material.stencilRef = json.stencilRef; + if ( json.stencilFuncMask !== undefined ) material.stencilFuncMask = json.stencilFuncMask; + if ( json.stencilFail !== undefined ) material.stencilFail = json.stencilFail; + if ( json.stencilZFail !== undefined ) material.stencilZFail = json.stencilZFail; + if ( json.stencilZPass !== undefined ) material.stencilZPass = json.stencilZPass; + + if ( json.wireframe !== undefined ) material.wireframe = json.wireframe; + if ( json.wireframeLinewidth !== undefined ) material.wireframeLinewidth = json.wireframeLinewidth; + if ( json.wireframeLinecap !== undefined ) material.wireframeLinecap = json.wireframeLinecap; + if ( json.wireframeLinejoin !== undefined ) material.wireframeLinejoin = json.wireframeLinejoin; + + if ( json.rotation !== undefined ) material.rotation = json.rotation; + + if ( json.linewidth !== 1 ) material.linewidth = json.linewidth; + if ( json.dashSize !== undefined ) material.dashSize = json.dashSize; + if ( json.gapSize !== undefined ) material.gapSize = json.gapSize; + if ( json.scale !== undefined ) material.scale = json.scale; + + if ( json.polygonOffset !== undefined ) material.polygonOffset = json.polygonOffset; + if ( json.polygonOffsetFactor !== undefined ) material.polygonOffsetFactor = json.polygonOffsetFactor; + if ( json.polygonOffsetUnits !== undefined ) material.polygonOffsetUnits = json.polygonOffsetUnits; + + if ( json.dithering !== undefined ) material.dithering = json.dithering; + + if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage; + if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha; + + if ( json.visible !== undefined ) material.visible = json.visible; + + if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped; + + if ( json.userData !== undefined ) material.userData = json.userData; + + if ( json.vertexColors !== undefined ) { + + if ( typeof json.vertexColors === 'number' ) { + + material.vertexColors = ( json.vertexColors > 0 ) ? true : false; + + } else { + + material.vertexColors = json.vertexColors; + + } + + } + + // Shader Material + + if ( json.uniforms !== undefined ) { + + for ( const name in json.uniforms ) { + + const uniform = json.uniforms[ name ]; + + material.uniforms[ name ] = {}; + + switch ( uniform.type ) { + + case 't': + material.uniforms[ name ].value = getTexture( uniform.value ); + break; + + case 'c': + material.uniforms[ name ].value = new Color().setHex( uniform.value ); + break; + + case 'v2': + material.uniforms[ name ].value = new Vector2().fromArray( uniform.value ); + break; + + case 'v3': + material.uniforms[ name ].value = new Vector3().fromArray( uniform.value ); + break; + + case 'v4': + material.uniforms[ name ].value = new Vector4().fromArray( uniform.value ); + break; + + case 'm3': + material.uniforms[ name ].value = new Matrix3().fromArray( uniform.value ); + break; + + case 'm4': + material.uniforms[ name ].value = new Matrix4().fromArray( uniform.value ); + break; + + default: + material.uniforms[ name ].value = uniform.value; + + } + + } + + } + + if ( json.defines !== undefined ) material.defines = json.defines; + if ( json.vertexShader !== undefined ) material.vertexShader = json.vertexShader; + if ( json.fragmentShader !== undefined ) material.fragmentShader = json.fragmentShader; + + if ( json.extensions !== undefined ) { + + for ( const key in json.extensions ) { + + material.extensions[ key ] = json.extensions[ key ]; + + } + + } + + // Deprecated + + if ( json.shading !== undefined ) material.flatShading = json.shading === 1; // THREE.FlatShading + + // for PointsMaterial + + if ( json.size !== undefined ) material.size = json.size; + if ( json.sizeAttenuation !== undefined ) material.sizeAttenuation = json.sizeAttenuation; + + // maps + + if ( json.map !== undefined ) material.map = getTexture( json.map ); + if ( json.matcap !== undefined ) material.matcap = getTexture( json.matcap ); + + if ( json.alphaMap !== undefined ) material.alphaMap = getTexture( json.alphaMap ); + + if ( json.bumpMap !== undefined ) material.bumpMap = getTexture( json.bumpMap ); + if ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale; + + if ( json.normalMap !== undefined ) material.normalMap = getTexture( json.normalMap ); + if ( json.normalMapType !== undefined ) material.normalMapType = json.normalMapType; + if ( json.normalScale !== undefined ) { + + let normalScale = json.normalScale; + + if ( Array.isArray( normalScale ) === false ) { + + // Blender exporter used to export a scalar. See #7459 + + normalScale = [ normalScale, normalScale ]; + + } + + material.normalScale = new Vector2().fromArray( normalScale ); + + } + + if ( json.displacementMap !== undefined ) material.displacementMap = getTexture( json.displacementMap ); + if ( json.displacementScale !== undefined ) material.displacementScale = json.displacementScale; + if ( json.displacementBias !== undefined ) material.displacementBias = json.displacementBias; + + if ( json.roughnessMap !== undefined ) material.roughnessMap = getTexture( json.roughnessMap ); + if ( json.metalnessMap !== undefined ) material.metalnessMap = getTexture( json.metalnessMap ); + + if ( json.emissiveMap !== undefined ) material.emissiveMap = getTexture( json.emissiveMap ); + if ( json.emissiveIntensity !== undefined ) material.emissiveIntensity = json.emissiveIntensity; + + if ( json.specularMap !== undefined ) material.specularMap = getTexture( json.specularMap ); + if ( json.specularIntensityMap !== undefined ) material.specularIntensityMap = getTexture( json.specularIntensityMap ); + if ( json.specularColorMap !== undefined ) material.specularColorMap = getTexture( json.specularColorMap ); + + if ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap ); + if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity; + + if ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity; + if ( json.refractionRatio !== undefined ) material.refractionRatio = json.refractionRatio; + + if ( json.lightMap !== undefined ) material.lightMap = getTexture( json.lightMap ); + if ( json.lightMapIntensity !== undefined ) material.lightMapIntensity = json.lightMapIntensity; + + if ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap ); + if ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity; + + if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + + if ( json.clearcoatMap !== undefined ) material.clearcoatMap = getTexture( json.clearcoatMap ); + if ( json.clearcoatRoughnessMap !== undefined ) material.clearcoatRoughnessMap = getTexture( json.clearcoatRoughnessMap ); + if ( json.clearcoatNormalMap !== undefined ) material.clearcoatNormalMap = getTexture( json.clearcoatNormalMap ); + if ( json.clearcoatNormalScale !== undefined ) material.clearcoatNormalScale = new Vector2().fromArray( json.clearcoatNormalScale ); + + if ( json.transmissionMap !== undefined ) material.transmissionMap = getTexture( json.transmissionMap ); + if ( json.thicknessMap !== undefined ) material.thicknessMap = getTexture( json.thicknessMap ); + + if ( json.sheenColorMap !== undefined ) material.sheenColorMap = getTexture( json.sheenColorMap ); + if ( json.sheenRoughnessMap !== undefined ) material.sheenRoughnessMap = getTexture( json.sheenRoughnessMap ); + + return material; + + } + + setTextures( value ) { + + this.textures = value; + return this; + + } + +} + +class LoaderUtils { + + static decodeText( array ) { + + if ( typeof TextDecoder !== 'undefined' ) { + + return new TextDecoder().decode( array ); + + } + + // Avoid the String.fromCharCode.apply(null, array) shortcut, which + // throws a "maximum call stack size exceeded" error for large arrays. + + let s = ''; + + for ( let i = 0, il = array.length; i < il; i ++ ) { + + // Implicitly assumes little-endian. + s += String.fromCharCode( array[ i ] ); + + } + + try { + + // merges multi-byte utf-8 characters. + + return decodeURIComponent( escape( s ) ); + + } catch ( e ) { // see #16358 + + return s; + + } + + } + + static extractUrlBase( url ) { + + const index = url.lastIndexOf( '/' ); + + if ( index === - 1 ) return './'; + + return url.substr( 0, index + 1 ); + + } + + static resolveURL( url, path ) { + + // Invalid URL + if ( typeof url !== 'string' || url === '' ) return ''; + + // Host Relative URL + if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) { + + path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); + + } + + // Absolute URL http://,https://,// + if ( /^(https?:)?\/\//i.test( url ) ) return url; + + // Data URI + if ( /^data:.*,.*$/i.test( url ) ) return url; + + // Blob URL + if ( /^blob:.*$/i.test( url ) ) return url; + + // Relative URL + return path + url; + + } + +} + +class InstancedBufferGeometry extends BufferGeometry { + + constructor() { + + super(); + + this.type = 'InstancedBufferGeometry'; + this.instanceCount = Infinity; + + } + + copy( source ) { + + super.copy( source ); + + this.instanceCount = source.instanceCount; + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + toJSON() { + + const data = super.toJSON( this ); + + data.instanceCount = this.instanceCount; + + data.isInstancedBufferGeometry = true; + + return data; + + } + +} + +InstancedBufferGeometry.prototype.isInstancedBufferGeometry = true; + +class BufferGeometryLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const loader = new FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setRequestHeader( scope.requestHeader ); + loader.setWithCredentials( scope.withCredentials ); + loader.load( url, function ( text ) { + + try { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + } catch ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + + } + + }, onProgress, onError ); + + } + + parse( json ) { + + const interleavedBufferMap = {}; + const arrayBufferMap = {}; + + function getInterleavedBuffer( json, uuid ) { + + if ( interleavedBufferMap[ uuid ] !== undefined ) return interleavedBufferMap[ uuid ]; + + const interleavedBuffers = json.interleavedBuffers; + const interleavedBuffer = interleavedBuffers[ uuid ]; + + const buffer = getArrayBuffer( json, interleavedBuffer.buffer ); + + const array = getTypedArray( interleavedBuffer.type, buffer ); + const ib = new InterleavedBuffer( array, interleavedBuffer.stride ); + ib.uuid = interleavedBuffer.uuid; + + interleavedBufferMap[ uuid ] = ib; + + return ib; + + } + + function getArrayBuffer( json, uuid ) { + + if ( arrayBufferMap[ uuid ] !== undefined ) return arrayBufferMap[ uuid ]; + + const arrayBuffers = json.arrayBuffers; + const arrayBuffer = arrayBuffers[ uuid ]; + + const ab = new Uint32Array( arrayBuffer ).buffer; + + arrayBufferMap[ uuid ] = ab; + + return ab; + + } + + const geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry(); + + const index = json.data.index; + + if ( index !== undefined ) { + + const typedArray = getTypedArray( index.type, index.array ); + geometry.setIndex( new BufferAttribute( typedArray, 1 ) ); + + } + + const attributes = json.data.attributes; + + for ( const key in attributes ) { + + const attribute = attributes[ key ]; + let bufferAttribute; + + if ( attribute.isInterleavedBufferAttribute ) { + + const interleavedBuffer = getInterleavedBuffer( json.data, attribute.data ); + bufferAttribute = new InterleavedBufferAttribute( interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized ); + + } else { + + const typedArray = getTypedArray( attribute.type, attribute.array ); + const bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute; + bufferAttribute = new bufferAttributeConstr( typedArray, attribute.itemSize, attribute.normalized ); + + } + + if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name; + if ( attribute.usage !== undefined ) bufferAttribute.setUsage( attribute.usage ); + + if ( attribute.updateRange !== undefined ) { + + bufferAttribute.updateRange.offset = attribute.updateRange.offset; + bufferAttribute.updateRange.count = attribute.updateRange.count; + + } + + geometry.setAttribute( key, bufferAttribute ); + + } + + const morphAttributes = json.data.morphAttributes; + + if ( morphAttributes ) { + + for ( const key in morphAttributes ) { + + const attributeArray = morphAttributes[ key ]; + + const array = []; + + for ( let i = 0, il = attributeArray.length; i < il; i ++ ) { + + const attribute = attributeArray[ i ]; + let bufferAttribute; + + if ( attribute.isInterleavedBufferAttribute ) { + + const interleavedBuffer = getInterleavedBuffer( json.data, attribute.data ); + bufferAttribute = new InterleavedBufferAttribute( interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized ); + + } else { + + const typedArray = getTypedArray( attribute.type, attribute.array ); + bufferAttribute = new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized ); + + } + + if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name; + array.push( bufferAttribute ); + + } + + geometry.morphAttributes[ key ] = array; + + } + + } + + const morphTargetsRelative = json.data.morphTargetsRelative; + + if ( morphTargetsRelative ) { + + geometry.morphTargetsRelative = true; + + } + + const groups = json.data.groups || json.data.drawcalls || json.data.offsets; + + if ( groups !== undefined ) { + + for ( let i = 0, n = groups.length; i !== n; ++ i ) { + + const group = groups[ i ]; + + geometry.addGroup( group.start, group.count, group.materialIndex ); + + } + + } + + const boundingSphere = json.data.boundingSphere; + + if ( boundingSphere !== undefined ) { + + const center = new Vector3(); + + if ( boundingSphere.center !== undefined ) { + + center.fromArray( boundingSphere.center ); + + } + + geometry.boundingSphere = new Sphere( center, boundingSphere.radius ); + + } + + if ( json.name ) geometry.name = json.name; + if ( json.userData ) geometry.userData = json.userData; + + return geometry; + + } + +} + +class ObjectLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path; + this.resourcePath = this.resourcePath || path; + + const loader = new FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + loader.load( url, function ( text ) { + + let json = null; + + try { + + json = JSON.parse( text ); + + } catch ( error ) { + + if ( onError !== undefined ) onError( error ); + + console.error( 'THREE:ObjectLoader: Can\'t parse ' + url + '.', error.message ); + + return; + + } + + const metadata = json.metadata; + + if ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) { + + console.error( 'THREE.ObjectLoader: Can\'t load ' + url ); + return; + + } + + scope.parse( json, onLoad ); + + }, onProgress, onError ); + + } + + async loadAsync( url, onProgress ) { + + const scope = this; + + const path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path; + this.resourcePath = this.resourcePath || path; + + const loader = new FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + + const text = await loader.loadAsync( url, onProgress ); + + const json = JSON.parse( text ); + + const metadata = json.metadata; + + if ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) { + + throw new Error( 'THREE.ObjectLoader: Can\'t load ' + url ); + + } + + return await scope.parseAsync( json ); + + } + + parse( json, onLoad ) { + + const animations = this.parseAnimations( json.animations ); + const shapes = this.parseShapes( json.shapes ); + const geometries = this.parseGeometries( json.geometries, shapes ); + + const images = this.parseImages( json.images, function () { + + if ( onLoad !== undefined ) onLoad( object ); + + } ); + + const textures = this.parseTextures( json.textures, images ); + const materials = this.parseMaterials( json.materials, textures ); + + const object = this.parseObject( json.object, geometries, materials, textures, animations ); + const skeletons = this.parseSkeletons( json.skeletons, object ); + + this.bindSkeletons( object, skeletons ); + + // + + if ( onLoad !== undefined ) { + + let hasImages = false; + + for ( const uuid in images ) { + + if ( images[ uuid ] instanceof HTMLImageElement ) { + + hasImages = true; + break; + + } + + } + + if ( hasImages === false ) onLoad( object ); + + } + + return object; + + } + + async parseAsync( json ) { + + const animations = this.parseAnimations( json.animations ); + const shapes = this.parseShapes( json.shapes ); + const geometries = this.parseGeometries( json.geometries, shapes ); + + const images = await this.parseImagesAsync( json.images ); + + const textures = this.parseTextures( json.textures, images ); + const materials = this.parseMaterials( json.materials, textures ); + + const object = this.parseObject( json.object, geometries, materials, textures, animations ); + const skeletons = this.parseSkeletons( json.skeletons, object ); + + this.bindSkeletons( object, skeletons ); + + return object; + + } + + parseShapes( json ) { + + const shapes = {}; + + if ( json !== undefined ) { + + for ( let i = 0, l = json.length; i < l; i ++ ) { + + const shape = new Shape().fromJSON( json[ i ] ); + + shapes[ shape.uuid ] = shape; + + } + + } + + return shapes; + + } + + parseSkeletons( json, object ) { + + const skeletons = {}; + const bones = {}; + + // generate bone lookup table + + object.traverse( function ( child ) { + + if ( child.isBone ) bones[ child.uuid ] = child; + + } ); + + // create skeletons + + if ( json !== undefined ) { + + for ( let i = 0, l = json.length; i < l; i ++ ) { + + const skeleton = new Skeleton().fromJSON( json[ i ], bones ); + + skeletons[ skeleton.uuid ] = skeleton; + + } + + } + + return skeletons; + + } + + parseGeometries( json, shapes ) { + + const geometries = {}; + + if ( json !== undefined ) { + + const bufferGeometryLoader = new BufferGeometryLoader(); + + for ( let i = 0, l = json.length; i < l; i ++ ) { + + let geometry; + const data = json[ i ]; + + switch ( data.type ) { + + case 'BufferGeometry': + case 'InstancedBufferGeometry': + + geometry = bufferGeometryLoader.parse( data ); + + break; + + case 'Geometry': + + console.error( 'THREE.ObjectLoader: The legacy Geometry type is no longer supported.' ); + + break; + + default: + + if ( data.type in Geometries ) { + + geometry = Geometries[ data.type ].fromJSON( data, shapes ); + + } else { + + console.warn( `THREE.ObjectLoader: Unsupported geometry type "${ data.type }"` ); + + } + + } + + geometry.uuid = data.uuid; + + if ( data.name !== undefined ) geometry.name = data.name; + if ( geometry.isBufferGeometry === true && data.userData !== undefined ) geometry.userData = data.userData; + + geometries[ data.uuid ] = geometry; + + } + + } + + return geometries; + + } + + parseMaterials( json, textures ) { + + const cache = {}; // MultiMaterial + const materials = {}; + + if ( json !== undefined ) { + + const loader = new MaterialLoader(); + loader.setTextures( textures ); + + for ( let i = 0, l = json.length; i < l; i ++ ) { + + const data = json[ i ]; + + if ( data.type === 'MultiMaterial' ) { + + // Deprecated + + const array = []; + + for ( let j = 0; j < data.materials.length; j ++ ) { + + const material = data.materials[ j ]; + + if ( cache[ material.uuid ] === undefined ) { + + cache[ material.uuid ] = loader.parse( material ); + + } + + array.push( cache[ material.uuid ] ); + + } + + materials[ data.uuid ] = array; + + } else { + + if ( cache[ data.uuid ] === undefined ) { + + cache[ data.uuid ] = loader.parse( data ); + + } + + materials[ data.uuid ] = cache[ data.uuid ]; + + } + + } + + } + + return materials; + + } + + parseAnimations( json ) { + + const animations = {}; + + if ( json !== undefined ) { + + for ( let i = 0; i < json.length; i ++ ) { + + const data = json[ i ]; + + const clip = AnimationClip.parse( data ); + + animations[ clip.uuid ] = clip; + + } + + } + + return animations; + + } + + parseImages( json, onLoad ) { + + const scope = this; + const images = {}; + + let loader; + + function loadImage( url ) { + + scope.manager.itemStart( url ); + + return loader.load( url, function () { + + scope.manager.itemEnd( url ); + + }, undefined, function () { + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + } ); + + } + + function deserializeImage( image ) { + + if ( typeof image === 'string' ) { + + const url = image; + + const path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( url ) ? url : scope.resourcePath + url; + + return loadImage( path ); + + } else { + + if ( image.data ) { + + return { + data: getTypedArray( image.type, image.data ), + width: image.width, + height: image.height + }; + + } else { + + return null; + + } + + } + + } + + if ( json !== undefined && json.length > 0 ) { + + const manager = new LoadingManager( onLoad ); + + loader = new ImageLoader( manager ); + loader.setCrossOrigin( this.crossOrigin ); + + for ( let i = 0, il = json.length; i < il; i ++ ) { + + const image = json[ i ]; + const url = image.url; + + if ( Array.isArray( url ) ) { + + // load array of images e.g CubeTexture + + images[ image.uuid ] = []; + + for ( let j = 0, jl = url.length; j < jl; j ++ ) { + + const currentUrl = url[ j ]; + + const deserializedImage = deserializeImage( currentUrl ); + + if ( deserializedImage !== null ) { + + if ( deserializedImage instanceof HTMLImageElement ) { + + images[ image.uuid ].push( deserializedImage ); + + } else { + + // special case: handle array of data textures for cube textures + + images[ image.uuid ].push( new DataTexture( deserializedImage.data, deserializedImage.width, deserializedImage.height ) ); + + } + + } + + } + + } else { + + // load single image + + const deserializedImage = deserializeImage( image.url ); + + if ( deserializedImage !== null ) { + + images[ image.uuid ] = deserializedImage; + + } + + } + + } + + } + + return images; + + } + + async parseImagesAsync( json ) { + + const scope = this; + const images = {}; + + let loader; + + async function deserializeImage( image ) { + + if ( typeof image === 'string' ) { + + const url = image; + + const path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( url ) ? url : scope.resourcePath + url; + + return await loader.loadAsync( path ); + + } else { + + if ( image.data ) { + + return { + data: getTypedArray( image.type, image.data ), + width: image.width, + height: image.height + }; + + } else { + + return null; + + } + + } + + } + + if ( json !== undefined && json.length > 0 ) { + + loader = new ImageLoader( this.manager ); + loader.setCrossOrigin( this.crossOrigin ); + + for ( let i = 0, il = json.length; i < il; i ++ ) { + + const image = json[ i ]; + const url = image.url; + + if ( Array.isArray( url ) ) { + + // load array of images e.g CubeTexture + + images[ image.uuid ] = []; + + for ( let j = 0, jl = url.length; j < jl; j ++ ) { + + const currentUrl = url[ j ]; + + const deserializedImage = await deserializeImage( currentUrl ); + + if ( deserializedImage !== null ) { + + if ( deserializedImage instanceof HTMLImageElement ) { + + images[ image.uuid ].push( deserializedImage ); + + } else { + + // special case: handle array of data textures for cube textures + + images[ image.uuid ].push( new DataTexture( deserializedImage.data, deserializedImage.width, deserializedImage.height ) ); + + } + + } + + } + + } else { + + // load single image + + const deserializedImage = await deserializeImage( image.url ); + + if ( deserializedImage !== null ) { + + images[ image.uuid ] = deserializedImage; + + } + + } + + } + + } + + return images; + + } + + parseTextures( json, images ) { + + function parseConstant( value, type ) { + + if ( typeof value === 'number' ) return value; + + console.warn( 'THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value ); + + return type[ value ]; + + } + + const textures = {}; + + if ( json !== undefined ) { + + for ( let i = 0, l = json.length; i < l; i ++ ) { + + const data = json[ i ]; + + if ( data.image === undefined ) { + + console.warn( 'THREE.ObjectLoader: No "image" specified for', data.uuid ); + + } + + if ( images[ data.image ] === undefined ) { + + console.warn( 'THREE.ObjectLoader: Undefined image', data.image ); + + } + + let texture; + const image = images[ data.image ]; + + if ( Array.isArray( image ) ) { + + texture = new CubeTexture( image ); + + if ( image.length === 6 ) texture.needsUpdate = true; + + } else { + + if ( image && image.data ) { + + texture = new DataTexture( image.data, image.width, image.height ); + + } else { + + texture = new Texture( image ); + + } + + if ( image ) texture.needsUpdate = true; // textures can have undefined image data + + } + + texture.uuid = data.uuid; + + if ( data.name !== undefined ) texture.name = data.name; + + if ( data.mapping !== undefined ) texture.mapping = parseConstant( data.mapping, TEXTURE_MAPPING ); + + if ( data.offset !== undefined ) texture.offset.fromArray( data.offset ); + if ( data.repeat !== undefined ) texture.repeat.fromArray( data.repeat ); + if ( data.center !== undefined ) texture.center.fromArray( data.center ); + if ( data.rotation !== undefined ) texture.rotation = data.rotation; + + if ( data.wrap !== undefined ) { + + texture.wrapS = parseConstant( data.wrap[ 0 ], TEXTURE_WRAPPING ); + texture.wrapT = parseConstant( data.wrap[ 1 ], TEXTURE_WRAPPING ); + + } + + if ( data.format !== undefined ) texture.format = data.format; + if ( data.type !== undefined ) texture.type = data.type; + if ( data.encoding !== undefined ) texture.encoding = data.encoding; + + if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER ); + if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER ); + if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy; + + if ( data.flipY !== undefined ) texture.flipY = data.flipY; + + if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha; + if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment; + + if ( data.userData !== undefined ) texture.userData = data.userData; + + textures[ data.uuid ] = texture; + + } + + } + + return textures; + + } + + parseObject( data, geometries, materials, textures, animations ) { + + let object; + + function getGeometry( name ) { + + if ( geometries[ name ] === undefined ) { + + console.warn( 'THREE.ObjectLoader: Undefined geometry', name ); + + } + + return geometries[ name ]; + + } + + function getMaterial( name ) { + + if ( name === undefined ) return undefined; + + if ( Array.isArray( name ) ) { + + const array = []; + + for ( let i = 0, l = name.length; i < l; i ++ ) { + + const uuid = name[ i ]; + + if ( materials[ uuid ] === undefined ) { + + console.warn( 'THREE.ObjectLoader: Undefined material', uuid ); + + } + + array.push( materials[ uuid ] ); + + } + + return array; + + } + + if ( materials[ name ] === undefined ) { + + console.warn( 'THREE.ObjectLoader: Undefined material', name ); + + } + + return materials[ name ]; + + } + + function getTexture( uuid ) { + + if ( textures[ uuid ] === undefined ) { + + console.warn( 'THREE.ObjectLoader: Undefined texture', uuid ); + + } + + return textures[ uuid ]; + + } + + let geometry, material; + + switch ( data.type ) { + + case 'Scene': + + object = new Scene(); + + if ( data.background !== undefined ) { + + if ( Number.isInteger( data.background ) ) { + + object.background = new Color( data.background ); + + } else { + + object.background = getTexture( data.background ); + + } + + } + + if ( data.environment !== undefined ) { + + object.environment = getTexture( data.environment ); + + } + + if ( data.fog !== undefined ) { + + if ( data.fog.type === 'Fog' ) { + + object.fog = new Fog( data.fog.color, data.fog.near, data.fog.far ); + + } else if ( data.fog.type === 'FogExp2' ) { + + object.fog = new FogExp2( data.fog.color, data.fog.density ); + + } + + } + + break; + + case 'PerspectiveCamera': + + object = new PerspectiveCamera( data.fov, data.aspect, data.near, data.far ); + + if ( data.focus !== undefined ) object.focus = data.focus; + if ( data.zoom !== undefined ) object.zoom = data.zoom; + if ( data.filmGauge !== undefined ) object.filmGauge = data.filmGauge; + if ( data.filmOffset !== undefined ) object.filmOffset = data.filmOffset; + if ( data.view !== undefined ) object.view = Object.assign( {}, data.view ); + + break; + + case 'OrthographicCamera': + + object = new OrthographicCamera( data.left, data.right, data.top, data.bottom, data.near, data.far ); + + if ( data.zoom !== undefined ) object.zoom = data.zoom; + if ( data.view !== undefined ) object.view = Object.assign( {}, data.view ); + + break; + + case 'AmbientLight': + + object = new AmbientLight( data.color, data.intensity ); + + break; + + case 'DirectionalLight': + + object = new DirectionalLight( data.color, data.intensity ); + + break; + + case 'PointLight': + + object = new PointLight( data.color, data.intensity, data.distance, data.decay ); + + break; + + case 'RectAreaLight': + + object = new RectAreaLight( data.color, data.intensity, data.width, data.height ); + + break; + + case 'SpotLight': + + object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay ); + + break; + + case 'HemisphereLight': + + object = new HemisphereLight( data.color, data.groundColor, data.intensity ); + + break; + + case 'LightProbe': + + object = new LightProbe().fromJSON( data ); + + break; + + case 'SkinnedMesh': + + geometry = getGeometry( data.geometry ); + material = getMaterial( data.material ); + + object = new SkinnedMesh( geometry, material ); + + if ( data.bindMode !== undefined ) object.bindMode = data.bindMode; + if ( data.bindMatrix !== undefined ) object.bindMatrix.fromArray( data.bindMatrix ); + if ( data.skeleton !== undefined ) object.skeleton = data.skeleton; + + break; + + case 'Mesh': + + geometry = getGeometry( data.geometry ); + material = getMaterial( data.material ); + + object = new Mesh( geometry, material ); + + break; + + case 'InstancedMesh': + + geometry = getGeometry( data.geometry ); + material = getMaterial( data.material ); + const count = data.count; + const instanceMatrix = data.instanceMatrix; + const instanceColor = data.instanceColor; + + object = new InstancedMesh( geometry, material, count ); + object.instanceMatrix = new InstancedBufferAttribute( new Float32Array( instanceMatrix.array ), 16 ); + if ( instanceColor !== undefined ) object.instanceColor = new InstancedBufferAttribute( new Float32Array( instanceColor.array ), instanceColor.itemSize ); + + break; + + case 'LOD': + + object = new LOD(); + + break; + + case 'Line': + + object = new Line( getGeometry( data.geometry ), getMaterial( data.material ) ); + + break; + + case 'LineLoop': + + object = new LineLoop( getGeometry( data.geometry ), getMaterial( data.material ) ); + + break; + + case 'LineSegments': + + object = new LineSegments( getGeometry( data.geometry ), getMaterial( data.material ) ); + + break; + + case 'PointCloud': + case 'Points': + + object = new Points( getGeometry( data.geometry ), getMaterial( data.material ) ); + + break; + + case 'Sprite': + + object = new Sprite( getMaterial( data.material ) ); + + break; + + case 'Group': + + object = new Group(); + + break; + + case 'Bone': + + object = new Bone(); + + break; + + default: + + object = new Object3D(); + + } + + object.uuid = data.uuid; + + if ( data.name !== undefined ) object.name = data.name; + + if ( data.matrix !== undefined ) { + + object.matrix.fromArray( data.matrix ); + + if ( data.matrixAutoUpdate !== undefined ) object.matrixAutoUpdate = data.matrixAutoUpdate; + if ( object.matrixAutoUpdate ) object.matrix.decompose( object.position, object.quaternion, object.scale ); + + } else { + + if ( data.position !== undefined ) object.position.fromArray( data.position ); + if ( data.rotation !== undefined ) object.rotation.fromArray( data.rotation ); + if ( data.quaternion !== undefined ) object.quaternion.fromArray( data.quaternion ); + if ( data.scale !== undefined ) object.scale.fromArray( data.scale ); + + } + + if ( data.castShadow !== undefined ) object.castShadow = data.castShadow; + if ( data.receiveShadow !== undefined ) object.receiveShadow = data.receiveShadow; + + if ( data.shadow ) { + + if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias; + if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias; + if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius; + if ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize ); + if ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera ); + + } + + if ( data.visible !== undefined ) object.visible = data.visible; + if ( data.frustumCulled !== undefined ) object.frustumCulled = data.frustumCulled; + if ( data.renderOrder !== undefined ) object.renderOrder = data.renderOrder; + if ( data.userData !== undefined ) object.userData = data.userData; + if ( data.layers !== undefined ) object.layers.mask = data.layers; + + if ( data.children !== undefined ) { + + const children = data.children; + + for ( let i = 0; i < children.length; i ++ ) { + + object.add( this.parseObject( children[ i ], geometries, materials, textures, animations ) ); + + } + + } + + if ( data.animations !== undefined ) { + + const objectAnimations = data.animations; + + for ( let i = 0; i < objectAnimations.length; i ++ ) { + + const uuid = objectAnimations[ i ]; + + object.animations.push( animations[ uuid ] ); + + } + + } + + if ( data.type === 'LOD' ) { + + if ( data.autoUpdate !== undefined ) object.autoUpdate = data.autoUpdate; + + const levels = data.levels; + + for ( let l = 0; l < levels.length; l ++ ) { + + const level = levels[ l ]; + const child = object.getObjectByProperty( 'uuid', level.object ); + + if ( child !== undefined ) { + + object.addLevel( child, level.distance ); + + } + + } + + } + + return object; + + } + + bindSkeletons( object, skeletons ) { + + if ( Object.keys( skeletons ).length === 0 ) return; + + object.traverse( function ( child ) { + + if ( child.isSkinnedMesh === true && child.skeleton !== undefined ) { + + const skeleton = skeletons[ child.skeleton ]; + + if ( skeleton === undefined ) { + + console.warn( 'THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton ); + + } else { + + child.bind( skeleton, child.bindMatrix ); + + } + + } + + } ); + + } + + /* DEPRECATED */ + + setTexturePath( value ) { + + console.warn( 'THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().' ); + return this.setResourcePath( value ); + + } + +} + +const TEXTURE_MAPPING = { + UVMapping: UVMapping, + CubeReflectionMapping: CubeReflectionMapping, + CubeRefractionMapping: CubeRefractionMapping, + EquirectangularReflectionMapping: EquirectangularReflectionMapping, + EquirectangularRefractionMapping: EquirectangularRefractionMapping, + CubeUVReflectionMapping: CubeUVReflectionMapping, + CubeUVRefractionMapping: CubeUVRefractionMapping +}; + +const TEXTURE_WRAPPING = { + RepeatWrapping: RepeatWrapping, + ClampToEdgeWrapping: ClampToEdgeWrapping, + MirroredRepeatWrapping: MirroredRepeatWrapping +}; + +const TEXTURE_FILTER = { + NearestFilter: NearestFilter, + NearestMipmapNearestFilter: NearestMipmapNearestFilter, + NearestMipmapLinearFilter: NearestMipmapLinearFilter, + LinearFilter: LinearFilter, + LinearMipmapNearestFilter: LinearMipmapNearestFilter, + LinearMipmapLinearFilter: LinearMipmapLinearFilter +}; + +class ImageBitmapLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + if ( typeof createImageBitmap === 'undefined' ) { + + console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' ); + + } + + if ( typeof fetch === 'undefined' ) { + + console.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' ); + + } + + this.options = { premultiplyAlpha: 'none' }; + + } + + setOptions( options ) { + + this.options = options; + + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + if ( url === undefined ) url = ''; + + if ( this.path !== undefined ) url = this.path + url; + + url = this.manager.resolveURL( url ); + + const scope = this; + + const cached = Cache.get( url ); + + if ( cached !== undefined ) { + + scope.manager.itemStart( url ); + + setTimeout( function () { + + if ( onLoad ) onLoad( cached ); + + scope.manager.itemEnd( url ); + + }, 0 ); + + return cached; + + } + + const fetchOptions = {}; + fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include'; + fetchOptions.headers = this.requestHeader; + + fetch( url, fetchOptions ).then( function ( res ) { + + return res.blob(); + + } ).then( function ( blob ) { + + return createImageBitmap( blob, Object.assign( scope.options, { colorSpaceConversion: 'none' } ) ); + + } ).then( function ( imageBitmap ) { + + Cache.add( url, imageBitmap ); + + if ( onLoad ) onLoad( imageBitmap ); + + scope.manager.itemEnd( url ); + + } ).catch( function ( e ) { + + if ( onError ) onError( e ); + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + } ); + + scope.manager.itemStart( url ); + + } + +} + +ImageBitmapLoader.prototype.isImageBitmapLoader = true; + +let _context; + +const AudioContext = { + + getContext: function () { + + if ( _context === undefined ) { + + _context = new ( window.AudioContext || window.webkitAudioContext )(); + + } + + return _context; + + }, + + setContext: function ( value ) { + + _context = value; + + } + +}; + +class AudioLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + const loader = new FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + loader.load( url, function ( buffer ) { + + try { + + // Create a copy of the buffer. The `decodeAudioData` method + // detaches the buffer when complete, preventing reuse. + const bufferCopy = buffer.slice( 0 ); + + const context = AudioContext.getContext(); + context.decodeAudioData( bufferCopy, function ( audioBuffer ) { + + onLoad( audioBuffer ); + + } ); + + } catch ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + + } + + }, onProgress, onError ); + + } + +} + +class HemisphereLightProbe extends LightProbe { + + constructor( skyColor, groundColor, intensity = 1 ) { + + super( undefined, intensity ); + + const color1 = new Color().set( skyColor ); + const color2 = new Color().set( groundColor ); + + const sky = new Vector3( color1.r, color1.g, color1.b ); + const ground = new Vector3( color2.r, color2.g, color2.b ); + + // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI ); + const c0 = Math.sqrt( Math.PI ); + const c1 = c0 * Math.sqrt( 0.75 ); + + this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 ); + this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 ); + + } + +} + +HemisphereLightProbe.prototype.isHemisphereLightProbe = true; + +class AmbientLightProbe extends LightProbe { + + constructor( color, intensity = 1 ) { + + super( undefined, intensity ); + + const color1 = new Color().set( color ); + + // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI ); + this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) ); + + } + +} + +AmbientLightProbe.prototype.isAmbientLightProbe = true; + +const _eyeRight = /*@__PURE__*/ new Matrix4(); +const _eyeLeft = /*@__PURE__*/ new Matrix4(); +const _projectionMatrix = /*@__PURE__*/ new Matrix4(); + +class StereoCamera { + + constructor() { + + this.type = 'StereoCamera'; + + this.aspect = 1; + + this.eyeSep = 0.064; + + this.cameraL = new PerspectiveCamera(); + this.cameraL.layers.enable( 1 ); + this.cameraL.matrixAutoUpdate = false; + + this.cameraR = new PerspectiveCamera(); + this.cameraR.layers.enable( 2 ); + this.cameraR.matrixAutoUpdate = false; + + this._cache = { + focus: null, + fov: null, + aspect: null, + near: null, + far: null, + zoom: null, + eyeSep: null + }; + + } + + update( camera ) { + + const cache = this._cache; + + const needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || + cache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near || + cache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep; + + if ( needsUpdate ) { + + cache.focus = camera.focus; + cache.fov = camera.fov; + cache.aspect = camera.aspect * this.aspect; + cache.near = camera.near; + cache.far = camera.far; + cache.zoom = camera.zoom; + cache.eyeSep = this.eyeSep; + + // Off-axis stereoscopic effect based on + // http://paulbourke.net/stereographics/stereorender/ + + _projectionMatrix.copy( camera.projectionMatrix ); + const eyeSepHalf = cache.eyeSep / 2; + const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus; + const ymax = ( cache.near * Math.tan( DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom; + let xmin, xmax; + + // translate xOffset + + _eyeLeft.elements[ 12 ] = - eyeSepHalf; + _eyeRight.elements[ 12 ] = eyeSepHalf; + + // for left eye + + xmin = - ymax * cache.aspect + eyeSepOnProjection; + xmax = ymax * cache.aspect + eyeSepOnProjection; + + _projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin ); + _projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin ); + + this.cameraL.projectionMatrix.copy( _projectionMatrix ); + + // for right eye + + xmin = - ymax * cache.aspect - eyeSepOnProjection; + xmax = ymax * cache.aspect - eyeSepOnProjection; + + _projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin ); + _projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin ); + + this.cameraR.projectionMatrix.copy( _projectionMatrix ); + + } + + this.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeLeft ); + this.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeRight ); + + } + +} + +class Clock { + + constructor( autoStart = true ) { + + this.autoStart = autoStart; + + this.startTime = 0; + this.oldTime = 0; + this.elapsedTime = 0; + + this.running = false; + + } + + start() { + + this.startTime = now(); + + this.oldTime = this.startTime; + this.elapsedTime = 0; + this.running = true; + + } + + stop() { + + this.getElapsedTime(); + this.running = false; + this.autoStart = false; + + } + + getElapsedTime() { + + this.getDelta(); + return this.elapsedTime; + + } + + getDelta() { + + let diff = 0; + + if ( this.autoStart && ! this.running ) { + + this.start(); + return 0; + + } + + if ( this.running ) { + + const newTime = now(); + + diff = ( newTime - this.oldTime ) / 1000; + this.oldTime = newTime; + + this.elapsedTime += diff; + + } + + return diff; + + } + +} + +function now() { + + return ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732 + +} + +const _position$1 = /*@__PURE__*/ new Vector3(); +const _quaternion$1 = /*@__PURE__*/ new Quaternion(); +const _scale$1 = /*@__PURE__*/ new Vector3(); +const _orientation$1 = /*@__PURE__*/ new Vector3(); + +class AudioListener extends Object3D { + + constructor() { + + super(); + + this.type = 'AudioListener'; + + this.context = AudioContext.getContext(); + + this.gain = this.context.createGain(); + this.gain.connect( this.context.destination ); + + this.filter = null; + + this.timeDelta = 0; + + // private + + this._clock = new Clock(); + + } + + getInput() { + + return this.gain; + + } + + removeFilter() { + + if ( this.filter !== null ) { + + this.gain.disconnect( this.filter ); + this.filter.disconnect( this.context.destination ); + this.gain.connect( this.context.destination ); + this.filter = null; + + } + + return this; + + } + + getFilter() { + + return this.filter; + + } + + setFilter( value ) { + + if ( this.filter !== null ) { + + this.gain.disconnect( this.filter ); + this.filter.disconnect( this.context.destination ); + + } else { + + this.gain.disconnect( this.context.destination ); + + } + + this.filter = value; + this.gain.connect( this.filter ); + this.filter.connect( this.context.destination ); + + return this; + + } + + getMasterVolume() { + + return this.gain.gain.value; + + } + + setMasterVolume( value ) { + + this.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 ); + + return this; + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + const listener = this.context.listener; + const up = this.up; + + this.timeDelta = this._clock.getDelta(); + + this.matrixWorld.decompose( _position$1, _quaternion$1, _scale$1 ); + + _orientation$1.set( 0, 0, - 1 ).applyQuaternion( _quaternion$1 ); + + if ( listener.positionX ) { + + // code path for Chrome (see #14393) + + const endTime = this.context.currentTime + this.timeDelta; + + listener.positionX.linearRampToValueAtTime( _position$1.x, endTime ); + listener.positionY.linearRampToValueAtTime( _position$1.y, endTime ); + listener.positionZ.linearRampToValueAtTime( _position$1.z, endTime ); + listener.forwardX.linearRampToValueAtTime( _orientation$1.x, endTime ); + listener.forwardY.linearRampToValueAtTime( _orientation$1.y, endTime ); + listener.forwardZ.linearRampToValueAtTime( _orientation$1.z, endTime ); + listener.upX.linearRampToValueAtTime( up.x, endTime ); + listener.upY.linearRampToValueAtTime( up.y, endTime ); + listener.upZ.linearRampToValueAtTime( up.z, endTime ); + + } else { + + listener.setPosition( _position$1.x, _position$1.y, _position$1.z ); + listener.setOrientation( _orientation$1.x, _orientation$1.y, _orientation$1.z, up.x, up.y, up.z ); + + } + + } + +} + +class Audio extends Object3D { + + constructor( listener ) { + + super(); + + this.type = 'Audio'; + + this.listener = listener; + this.context = listener.context; + + this.gain = this.context.createGain(); + this.gain.connect( listener.getInput() ); + + this.autoplay = false; + + this.buffer = null; + this.detune = 0; + this.loop = false; + this.loopStart = 0; + this.loopEnd = 0; + this.offset = 0; + this.duration = undefined; + this.playbackRate = 1; + this.isPlaying = false; + this.hasPlaybackControl = true; + this.source = null; + this.sourceType = 'empty'; + + this._startedAt = 0; + this._progress = 0; + this._connected = false; + + this.filters = []; + + } + + getOutput() { + + return this.gain; + + } + + setNodeSource( audioNode ) { + + this.hasPlaybackControl = false; + this.sourceType = 'audioNode'; + this.source = audioNode; + this.connect(); + + return this; + + } + + setMediaElementSource( mediaElement ) { + + this.hasPlaybackControl = false; + this.sourceType = 'mediaNode'; + this.source = this.context.createMediaElementSource( mediaElement ); + this.connect(); + + return this; + + } + + setMediaStreamSource( mediaStream ) { + + this.hasPlaybackControl = false; + this.sourceType = 'mediaStreamNode'; + this.source = this.context.createMediaStreamSource( mediaStream ); + this.connect(); + + return this; + + } + + setBuffer( audioBuffer ) { + + this.buffer = audioBuffer; + this.sourceType = 'buffer'; + + if ( this.autoplay ) this.play(); + + return this; + + } + + play( delay = 0 ) { + + if ( this.isPlaying === true ) { + + console.warn( 'THREE.Audio: Audio is already playing.' ); + return; + + } + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + + } + + this._startedAt = this.context.currentTime + delay; + + const source = this.context.createBufferSource(); + source.buffer = this.buffer; + source.loop = this.loop; + source.loopStart = this.loopStart; + source.loopEnd = this.loopEnd; + source.onended = this.onEnded.bind( this ); + source.start( this._startedAt, this._progress + this.offset, this.duration ); + + this.isPlaying = true; + + this.source = source; + + this.setDetune( this.detune ); + this.setPlaybackRate( this.playbackRate ); + + return this.connect(); + + } + + pause() { + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + + } + + if ( this.isPlaying === true ) { + + // update current progress + + this._progress += Math.max( this.context.currentTime - this._startedAt, 0 ) * this.playbackRate; + + if ( this.loop === true ) { + + // ensure _progress does not exceed duration with looped audios + + this._progress = this._progress % ( this.duration || this.buffer.duration ); + + } + + this.source.stop(); + this.source.onended = null; + + this.isPlaying = false; + + } + + return this; + + } + + stop() { + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + + } + + this._progress = 0; + + this.source.stop(); + this.source.onended = null; + this.isPlaying = false; + + return this; + + } + + connect() { + + if ( this.filters.length > 0 ) { + + this.source.connect( this.filters[ 0 ] ); + + for ( let i = 1, l = this.filters.length; i < l; i ++ ) { + + this.filters[ i - 1 ].connect( this.filters[ i ] ); + + } + + this.filters[ this.filters.length - 1 ].connect( this.getOutput() ); + + } else { + + this.source.connect( this.getOutput() ); + + } + + this._connected = true; + + return this; + + } + + disconnect() { + + if ( this.filters.length > 0 ) { + + this.source.disconnect( this.filters[ 0 ] ); + + for ( let i = 1, l = this.filters.length; i < l; i ++ ) { + + this.filters[ i - 1 ].disconnect( this.filters[ i ] ); + + } + + this.filters[ this.filters.length - 1 ].disconnect( this.getOutput() ); + + } else { + + this.source.disconnect( this.getOutput() ); + + } + + this._connected = false; + + return this; + + } + + getFilters() { + + return this.filters; + + } + + setFilters( value ) { + + if ( ! value ) value = []; + + if ( this._connected === true ) { + + this.disconnect(); + this.filters = value.slice(); + this.connect(); + + } else { + + this.filters = value.slice(); + + } + + return this; + + } + + setDetune( value ) { + + this.detune = value; + + if ( this.source.detune === undefined ) return; // only set detune when available + + if ( this.isPlaying === true ) { + + this.source.detune.setTargetAtTime( this.detune, this.context.currentTime, 0.01 ); + + } + + return this; + + } + + getDetune() { + + return this.detune; + + } + + getFilter() { + + return this.getFilters()[ 0 ]; + + } + + setFilter( filter ) { + + return this.setFilters( filter ? [ filter ] : [] ); + + } + + setPlaybackRate( value ) { + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + + } + + this.playbackRate = value; + + if ( this.isPlaying === true ) { + + this.source.playbackRate.setTargetAtTime( this.playbackRate, this.context.currentTime, 0.01 ); + + } + + return this; + + } + + getPlaybackRate() { + + return this.playbackRate; + + } + + onEnded() { + + this.isPlaying = false; + + } + + getLoop() { + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return false; + + } + + return this.loop; + + } + + setLoop( value ) { + + if ( this.hasPlaybackControl === false ) { + + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + + } + + this.loop = value; + + if ( this.isPlaying === true ) { + + this.source.loop = this.loop; + + } + + return this; + + } + + setLoopStart( value ) { + + this.loopStart = value; + + return this; + + } + + setLoopEnd( value ) { + + this.loopEnd = value; + + return this; + + } + + getVolume() { + + return this.gain.gain.value; + + } + + setVolume( value ) { + + this.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 ); + + return this; + + } + +} + +const _position = /*@__PURE__*/ new Vector3(); +const _quaternion = /*@__PURE__*/ new Quaternion(); +const _scale = /*@__PURE__*/ new Vector3(); +const _orientation = /*@__PURE__*/ new Vector3(); + +class PositionalAudio extends Audio { + + constructor( listener ) { + + super( listener ); + + this.panner = this.context.createPanner(); + this.panner.panningModel = 'HRTF'; + this.panner.connect( this.gain ); + + } + + getOutput() { + + return this.panner; + + } + + getRefDistance() { + + return this.panner.refDistance; + + } + + setRefDistance( value ) { + + this.panner.refDistance = value; + + return this; + + } + + getRolloffFactor() { + + return this.panner.rolloffFactor; + + } + + setRolloffFactor( value ) { + + this.panner.rolloffFactor = value; + + return this; + + } + + getDistanceModel() { + + return this.panner.distanceModel; + + } + + setDistanceModel( value ) { + + this.panner.distanceModel = value; + + return this; + + } + + getMaxDistance() { + + return this.panner.maxDistance; + + } + + setMaxDistance( value ) { + + this.panner.maxDistance = value; + + return this; + + } + + setDirectionalCone( coneInnerAngle, coneOuterAngle, coneOuterGain ) { + + this.panner.coneInnerAngle = coneInnerAngle; + this.panner.coneOuterAngle = coneOuterAngle; + this.panner.coneOuterGain = coneOuterGain; + + return this; + + } + + updateMatrixWorld( force ) { + + super.updateMatrixWorld( force ); + + if ( this.hasPlaybackControl === true && this.isPlaying === false ) return; + + this.matrixWorld.decompose( _position, _quaternion, _scale ); + + _orientation.set( 0, 0, 1 ).applyQuaternion( _quaternion ); + + const panner = this.panner; + + if ( panner.positionX ) { + + // code path for Chrome and Firefox (see #14393) + + const endTime = this.context.currentTime + this.listener.timeDelta; + + panner.positionX.linearRampToValueAtTime( _position.x, endTime ); + panner.positionY.linearRampToValueAtTime( _position.y, endTime ); + panner.positionZ.linearRampToValueAtTime( _position.z, endTime ); + panner.orientationX.linearRampToValueAtTime( _orientation.x, endTime ); + panner.orientationY.linearRampToValueAtTime( _orientation.y, endTime ); + panner.orientationZ.linearRampToValueAtTime( _orientation.z, endTime ); + + } else { + + panner.setPosition( _position.x, _position.y, _position.z ); + panner.setOrientation( _orientation.x, _orientation.y, _orientation.z ); + + } + + } + +} + +class AudioAnalyser { + + constructor( audio, fftSize = 2048 ) { + + this.analyser = audio.context.createAnalyser(); + this.analyser.fftSize = fftSize; + + this.data = new Uint8Array( this.analyser.frequencyBinCount ); + + audio.getOutput().connect( this.analyser ); + + } + + + getFrequencyData() { + + this.analyser.getByteFrequencyData( this.data ); + + return this.data; + + } + + getAverageFrequency() { + + let value = 0; + const data = this.getFrequencyData(); + + for ( let i = 0; i < data.length; i ++ ) { + + value += data[ i ]; + + } + + return value / data.length; + + } + +} + +class PropertyMixer { + + constructor( binding, typeName, valueSize ) { + + this.binding = binding; + this.valueSize = valueSize; + + let mixFunction, + mixFunctionAdditive, + setIdentity; + + // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ] + // + // interpolators can use .buffer as their .result + // the data then goes to 'incoming' + // + // 'accu0' and 'accu1' are used frame-interleaved for + // the cumulative result and are compared to detect + // changes + // + // 'orig' stores the original state of the property + // + // 'add' is used for additive cumulative results + // + // 'work' is optional and is only present for quaternion types. It is used + // to store intermediate quaternion multiplication results + + switch ( typeName ) { + + case 'quaternion': + mixFunction = this._slerp; + mixFunctionAdditive = this._slerpAdditive; + setIdentity = this._setAdditiveIdentityQuaternion; + + this.buffer = new Float64Array( valueSize * 6 ); + this._workIndex = 5; + break; + + case 'string': + case 'bool': + mixFunction = this._select; + + // Use the regular mix function and for additive on these types, + // additive is not relevant for non-numeric types + mixFunctionAdditive = this._select; + + setIdentity = this._setAdditiveIdentityOther; + + this.buffer = new Array( valueSize * 5 ); + break; + + default: + mixFunction = this._lerp; + mixFunctionAdditive = this._lerpAdditive; + setIdentity = this._setAdditiveIdentityNumeric; + + this.buffer = new Float64Array( valueSize * 5 ); + + } + + this._mixBufferRegion = mixFunction; + this._mixBufferRegionAdditive = mixFunctionAdditive; + this._setIdentity = setIdentity; + this._origIndex = 3; + this._addIndex = 4; + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + + this.useCount = 0; + this.referenceCount = 0; + + } + + // accumulate data in the 'incoming' region into 'accu' + accumulate( accuIndex, weight ) { + + // note: happily accumulating nothing when weight = 0, the caller knows + // the weight and shouldn't have made the call in the first place + + const buffer = this.buffer, + stride = this.valueSize, + offset = accuIndex * stride + stride; + + let currentWeight = this.cumulativeWeight; + + if ( currentWeight === 0 ) { + + // accuN := incoming * weight + + for ( let i = 0; i !== stride; ++ i ) { + + buffer[ offset + i ] = buffer[ i ]; + + } + + currentWeight = weight; + + } else { + + // accuN := accuN + incoming * weight + + currentWeight += weight; + const mix = weight / currentWeight; + this._mixBufferRegion( buffer, offset, 0, mix, stride ); + + } + + this.cumulativeWeight = currentWeight; + + } + + // accumulate data in the 'incoming' region into 'add' + accumulateAdditive( weight ) { + + const buffer = this.buffer, + stride = this.valueSize, + offset = stride * this._addIndex; + + if ( this.cumulativeWeightAdditive === 0 ) { + + // add = identity + + this._setIdentity(); + + } + + // add := add + incoming * weight + + this._mixBufferRegionAdditive( buffer, offset, 0, weight, stride ); + this.cumulativeWeightAdditive += weight; + + } + + // apply the state of 'accu' to the binding when accus differ + apply( accuIndex ) { + + const stride = this.valueSize, + buffer = this.buffer, + offset = accuIndex * stride + stride, + + weight = this.cumulativeWeight, + weightAdditive = this.cumulativeWeightAdditive, + + binding = this.binding; + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + + if ( weight < 1 ) { + + // accuN := accuN + original * ( 1 - cumulativeWeight ) + + const originalValueOffset = stride * this._origIndex; + + this._mixBufferRegion( + buffer, offset, originalValueOffset, 1 - weight, stride ); + + } + + if ( weightAdditive > 0 ) { + + // accuN := accuN + additive accuN + + this._mixBufferRegionAdditive( buffer, offset, this._addIndex * stride, 1, stride ); + + } + + for ( let i = stride, e = stride + stride; i !== e; ++ i ) { + + if ( buffer[ i ] !== buffer[ i + stride ] ) { + + // value has changed -> update scene graph + + binding.setValue( buffer, offset ); + break; + + } + + } + + } + + // remember the state of the bound property and copy it to both accus + saveOriginalState() { + + const binding = this.binding; + + const buffer = this.buffer, + stride = this.valueSize, + + originalValueOffset = stride * this._origIndex; + + binding.getValue( buffer, originalValueOffset ); + + // accu[0..1] := orig -- initially detect changes against the original + for ( let i = stride, e = originalValueOffset; i !== e; ++ i ) { + + buffer[ i ] = buffer[ originalValueOffset + ( i % stride ) ]; + + } + + // Add to identity for additive + this._setIdentity(); + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + + } + + // apply the state previously taken via 'saveOriginalState' to the binding + restoreOriginalState() { + + const originalValueOffset = this.valueSize * 3; + this.binding.setValue( this.buffer, originalValueOffset ); + + } + + _setAdditiveIdentityNumeric() { + + const startIndex = this._addIndex * this.valueSize; + const endIndex = startIndex + this.valueSize; + + for ( let i = startIndex; i < endIndex; i ++ ) { + + this.buffer[ i ] = 0; + + } + + } + + _setAdditiveIdentityQuaternion() { + + this._setAdditiveIdentityNumeric(); + this.buffer[ this._addIndex * this.valueSize + 3 ] = 1; + + } + + _setAdditiveIdentityOther() { + + const startIndex = this._origIndex * this.valueSize; + const targetIndex = this._addIndex * this.valueSize; + + for ( let i = 0; i < this.valueSize; i ++ ) { + + this.buffer[ targetIndex + i ] = this.buffer[ startIndex + i ]; + + } + + } + + + // mix functions + + _select( buffer, dstOffset, srcOffset, t, stride ) { + + if ( t >= 0.5 ) { + + for ( let i = 0; i !== stride; ++ i ) { + + buffer[ dstOffset + i ] = buffer[ srcOffset + i ]; + + } + + } + + } + + _slerp( buffer, dstOffset, srcOffset, t ) { + + Quaternion.slerpFlat( buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t ); + + } + + _slerpAdditive( buffer, dstOffset, srcOffset, t, stride ) { + + const workOffset = this._workIndex * stride; + + // Store result in intermediate buffer offset + Quaternion.multiplyQuaternionsFlat( buffer, workOffset, buffer, dstOffset, buffer, srcOffset ); + + // Slerp to the intermediate result + Quaternion.slerpFlat( buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t ); + + } + + _lerp( buffer, dstOffset, srcOffset, t, stride ) { + + const s = 1 - t; + + for ( let i = 0; i !== stride; ++ i ) { + + const j = dstOffset + i; + + buffer[ j ] = buffer[ j ] * s + buffer[ srcOffset + i ] * t; + + } + + } + + _lerpAdditive( buffer, dstOffset, srcOffset, t, stride ) { + + for ( let i = 0; i !== stride; ++ i ) { + + const j = dstOffset + i; + + buffer[ j ] = buffer[ j ] + buffer[ srcOffset + i ] * t; + + } + + } + +} + +// Characters [].:/ are reserved for track binding syntax. +const _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +const _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' ); + +// Attempts to allow node names from any language. ES5's `\w` regexp matches +// only latin characters, and the unicode \p{L} is not yet supported. So +// instead, we exclude reserved characters and match everything else. +const _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; +const _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; + +// Parent directories, delimited by '/' or ':'. Currently unused, but must +// be matched to parse the rest of the track name. +const _directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', _wordChar ); + +// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. +const _nodeRe = /(WCOD+)?/.source.replace( 'WCOD', _wordCharOrDot ); + +// Object on target node, and accessor. May not contain reserved +// characters. Accessor may contain any character except closing bracket. +const _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', _wordChar ); + +// Property and accessor. May not contain reserved characters. Accessor may +// contain any non-bracket characters. +const _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', _wordChar ); + +const _trackRe = new RegExp( '' + + '^' + + _directoryRe + + _nodeRe + + _objectRe + + _propertyRe + + '$' +); + +const _supportedObjectNames = [ 'material', 'materials', 'bones' ]; + +class Composite { + + constructor( targetGroup, path, optionalParsedPath ) { + + const parsedPath = optionalParsedPath || PropertyBinding.parseTrackName( path ); + + this._targetGroup = targetGroup; + this._bindings = targetGroup.subscribe_( path, parsedPath ); + + } + + getValue( array, offset ) { + + this.bind(); // bind all binding + + const firstValidIndex = this._targetGroup.nCachedObjects_, + binding = this._bindings[ firstValidIndex ]; + + // and only call .getValue on the first + if ( binding !== undefined ) binding.getValue( array, offset ); + + } + + setValue( array, offset ) { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].setValue( array, offset ); + + } + + } + + bind() { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].bind(); + + } + + } + + unbind() { + + const bindings = this._bindings; + + for ( let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) { + + bindings[ i ].unbind(); + + } + + } + +} + +// Note: This class uses a State pattern on a per-method basis: +// 'bind' sets 'this.getValue' / 'setValue' and shadows the +// prototype version of these methods with one that represents +// the bound state. When the property is not found, the methods +// become no-ops. +class PropertyBinding { + + constructor( rootNode, path, parsedPath ) { + + this.path = path; + this.parsedPath = parsedPath || PropertyBinding.parseTrackName( path ); + + this.node = PropertyBinding.findNode( rootNode, this.parsedPath.nodeName ) || rootNode; + + this.rootNode = rootNode; + + // initial state of these methods that calls 'bind' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + + } + + + static create( root, path, parsedPath ) { + + if ( ! ( root && root.isAnimationObjectGroup ) ) { + + return new PropertyBinding( root, path, parsedPath ); + + } else { + + return new PropertyBinding.Composite( root, path, parsedPath ); + + } + + } + + /** + * Replaces spaces with underscores and removes unsupported characters from + * node names, to ensure compatibility with parseTrackName(). + * + * @param {string} name Node name to be sanitized. + * @return {string} + */ + static sanitizeNodeName( name ) { + + return name.replace( /\s/g, '_' ).replace( _reservedRe, '' ); + + } + + static parseTrackName( trackName ) { + + const matches = _trackRe.exec( trackName ); + + if ( ! matches ) { + + throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); + + } + + const results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[ 2 ], + objectName: matches[ 3 ], + objectIndex: matches[ 4 ], + propertyName: matches[ 5 ], // required + propertyIndex: matches[ 6 ] + }; + + const lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); + + if ( lastDot !== undefined && lastDot !== - 1 ) { + + const objectName = results.nodeName.substring( lastDot + 1 ); + + // Object names must be checked against an allowlist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) { + + results.nodeName = results.nodeName.substring( 0, lastDot ); + results.objectName = objectName; + + } + + } + + if ( results.propertyName === null || results.propertyName.length === 0 ) { + + throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); + + } + + return results; + + } + + static findNode( root, nodeName ) { + + if ( ! nodeName || nodeName === '' || nodeName === '.' || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { + + return root; + + } + + // search into skeleton bones. + if ( root.skeleton ) { + + const bone = root.skeleton.getBoneByName( nodeName ); + + if ( bone !== undefined ) { + + return bone; + + } + + } + + // search into node subtree. + if ( root.children ) { + + const searchNodeSubtree = function ( children ) { + + for ( let i = 0; i < children.length; i ++ ) { + + const childNode = children[ i ]; + + if ( childNode.name === nodeName || childNode.uuid === nodeName ) { + + return childNode; + + } + + const result = searchNodeSubtree( childNode.children ); + + if ( result ) return result; + + } + + return null; + + }; + + const subTreeNode = searchNodeSubtree( root.children ); + + if ( subTreeNode ) { + + return subTreeNode; + + } + + } + + return null; + + } + + // these are used to "bind" a nonexistent property + _getValue_unavailable() {} + _setValue_unavailable() {} + + // Getters + + _getValue_direct( buffer, offset ) { + + buffer[ offset ] = this.targetObject[ this.propertyName ]; + + } + + _getValue_array( buffer, offset ) { + + const source = this.resolvedProperty; + + for ( let i = 0, n = source.length; i !== n; ++ i ) { + + buffer[ offset ++ ] = source[ i ]; + + } + + } + + _getValue_arrayElement( buffer, offset ) { + + buffer[ offset ] = this.resolvedProperty[ this.propertyIndex ]; + + } + + _getValue_toArray( buffer, offset ) { + + this.resolvedProperty.toArray( buffer, offset ); + + } + + // Direct + + _setValue_direct( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + + } + + _setValue_direct_setNeedsUpdate( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + this.targetObject.needsUpdate = true; + + } + + _setValue_direct_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.targetObject[ this.propertyName ] = buffer[ offset ]; + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // EntireArray + + _setValue_array( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + } + + _setValue_array_setNeedsUpdate( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + this.targetObject.needsUpdate = true; + + } + + _setValue_array_setMatrixWorldNeedsUpdate( buffer, offset ) { + + const dest = this.resolvedProperty; + + for ( let i = 0, n = dest.length; i !== n; ++ i ) { + + dest[ i ] = buffer[ offset ++ ]; + + } + + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // ArrayElement + + _setValue_arrayElement( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + + } + + _setValue_arrayElement_setNeedsUpdate( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + this.targetObject.needsUpdate = true; + + } + + _setValue_arrayElement_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.resolvedProperty[ this.propertyIndex ] = buffer[ offset ]; + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + // HasToFromArray + + _setValue_fromArray( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + + } + + _setValue_fromArray_setNeedsUpdate( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + this.targetObject.needsUpdate = true; + + } + + _setValue_fromArray_setMatrixWorldNeedsUpdate( buffer, offset ) { + + this.resolvedProperty.fromArray( buffer, offset ); + this.targetObject.matrixWorldNeedsUpdate = true; + + } + + _getValue_unbound( targetArray, offset ) { + + this.bind(); + this.getValue( targetArray, offset ); + + } + + _setValue_unbound( sourceArray, offset ) { + + this.bind(); + this.setValue( sourceArray, offset ); + + } + + // create getter / setter pair for a property in the scene graph + bind() { + + let targetObject = this.node; + const parsedPath = this.parsedPath; + + const objectName = parsedPath.objectName; + const propertyName = parsedPath.propertyName; + let propertyIndex = parsedPath.propertyIndex; + + if ( ! targetObject ) { + + targetObject = PropertyBinding.findNode( this.rootNode, parsedPath.nodeName ) || this.rootNode; + + this.node = targetObject; + + } + + // set fail state so we can just 'return' on error + this.getValue = this._getValue_unavailable; + this.setValue = this._setValue_unavailable; + + // ensure there is a value node + if ( ! targetObject ) { + + console.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\'t found.' ); + return; + + } + + if ( objectName ) { + + let objectIndex = parsedPath.objectIndex; + + // special cases were we need to reach deeper into the hierarchy to get the face materials.... + switch ( objectName ) { + + case 'materials': + + if ( ! targetObject.material ) { + + console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this ); + return; + + } + + if ( ! targetObject.material.materials ) { + + console.error( 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this ); + return; + + } + + targetObject = targetObject.material.materials; + + break; + + case 'bones': + + if ( ! targetObject.skeleton ) { + + console.error( 'THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this ); + return; + + } + + // potential future optimization: skip this if propertyIndex is already an integer + // and convert the integer string to a true integer. + + targetObject = targetObject.skeleton.bones; + + // support resolving morphTarget names into indices. + for ( let i = 0; i < targetObject.length; i ++ ) { + + if ( targetObject[ i ].name === objectIndex ) { + + objectIndex = i; + break; + + } + + } + + break; + + default: + + if ( targetObject[ objectName ] === undefined ) { + + console.error( 'THREE.PropertyBinding: Can not bind to objectName of node undefined.', this ); + return; + + } + + targetObject = targetObject[ objectName ]; + + } + + + if ( objectIndex !== undefined ) { + + if ( targetObject[ objectIndex ] === undefined ) { + + console.error( 'THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject ); + return; + + } + + targetObject = targetObject[ objectIndex ]; + + } + + } + + // resolve property + const nodeProperty = targetObject[ propertyName ]; + + if ( nodeProperty === undefined ) { + + const nodeName = parsedPath.nodeName; + + console.error( 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName + + '.' + propertyName + ' but it wasn\'t found.', targetObject ); + return; + + } + + // determine versioning scheme + let versioning = this.Versioning.None; + + this.targetObject = targetObject; + + if ( targetObject.needsUpdate !== undefined ) { // material + + versioning = this.Versioning.NeedsUpdate; + + } else if ( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform + + versioning = this.Versioning.MatrixWorldNeedsUpdate; + + } + + // determine how the property gets bound + let bindingType = this.BindingType.Direct; + + if ( propertyIndex !== undefined ) { + + // access a sub element of the property array (only primitives are supported right now) + + if ( propertyName === 'morphTargetInfluences' ) { + + // potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. + + // support resolving morphTarget names into indices. + if ( ! targetObject.geometry ) { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this ); + return; + + } + + if ( targetObject.geometry.isBufferGeometry ) { + + if ( ! targetObject.geometry.morphAttributes ) { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this ); + return; + + } + + if ( targetObject.morphTargetDictionary[ propertyIndex ] !== undefined ) { + + propertyIndex = targetObject.morphTargetDictionary[ propertyIndex ]; + + } + + + } else { + + console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.', this ); + return; + + } + + } + + bindingType = this.BindingType.ArrayElement; + + this.resolvedProperty = nodeProperty; + this.propertyIndex = propertyIndex; + + } else if ( nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined ) { + + // must use copy for Object3D.Euler/Quaternion + + bindingType = this.BindingType.HasFromToArray; + + this.resolvedProperty = nodeProperty; + + } else if ( Array.isArray( nodeProperty ) ) { + + bindingType = this.BindingType.EntireArray; + + this.resolvedProperty = nodeProperty; + + } else { + + this.propertyName = propertyName; + + } + + // select getter / setter + this.getValue = this.GetterByBindingType[ bindingType ]; + this.setValue = this.SetterByBindingTypeAndVersioning[ bindingType ][ versioning ]; + + } + + unbind() { + + this.node = null; + + // back to the prototype version of getValue / setValue + // note: avoiding to mutate the shape of 'this' via 'delete' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + + } + +} + +PropertyBinding.Composite = Composite; + +PropertyBinding.prototype.BindingType = { + Direct: 0, + EntireArray: 1, + ArrayElement: 2, + HasFromToArray: 3 +}; + +PropertyBinding.prototype.Versioning = { + None: 0, + NeedsUpdate: 1, + MatrixWorldNeedsUpdate: 2 +}; + +PropertyBinding.prototype.GetterByBindingType = [ + + PropertyBinding.prototype._getValue_direct, + PropertyBinding.prototype._getValue_array, + PropertyBinding.prototype._getValue_arrayElement, + PropertyBinding.prototype._getValue_toArray, + +]; + +PropertyBinding.prototype.SetterByBindingTypeAndVersioning = [ + + [ + // Direct + PropertyBinding.prototype._setValue_direct, + PropertyBinding.prototype._setValue_direct_setNeedsUpdate, + PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate, + + ], [ + + // EntireArray + + PropertyBinding.prototype._setValue_array, + PropertyBinding.prototype._setValue_array_setNeedsUpdate, + PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate, + + ], [ + + // ArrayElement + PropertyBinding.prototype._setValue_arrayElement, + PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate, + PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate, + + ], [ + + // HasToFromArray + PropertyBinding.prototype._setValue_fromArray, + PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate, + PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate, + + ] + +]; + +/** + * + * A group of objects that receives a shared animation state. + * + * Usage: + * + * - Add objects you would otherwise pass as 'root' to the + * constructor or the .clipAction method of AnimationMixer. + * + * - Instead pass this object as 'root'. + * + * - You can also add and remove objects later when the mixer + * is running. + * + * Note: + * + * Objects of this class appear as one object to the mixer, + * so cache control of the individual objects must be done + * on the group. + * + * Limitation: + * + * - The animated properties must be compatible among the + * all objects in the group. + * + * - A single property can either be controlled through a + * target group or directly, but not both. + */ + +class AnimationObjectGroup { + + constructor() { + + this.uuid = generateUUID(); + + // cached objects followed by the active ones + this._objects = Array.prototype.slice.call( arguments ); + + this.nCachedObjects_ = 0; // threshold + // note: read by PropertyBinding.Composite + + const indices = {}; + this._indicesByUUID = indices; // for bookkeeping + + for ( let i = 0, n = arguments.length; i !== n; ++ i ) { + + indices[ arguments[ i ].uuid ] = i; + + } + + this._paths = []; // inside: string + this._parsedPaths = []; // inside: { we don't care, here } + this._bindings = []; // inside: Array< PropertyBinding > + this._bindingsIndicesByPath = {}; // inside: indices in these arrays + + const scope = this; + + this.stats = { + + objects: { + get total() { + + return scope._objects.length; + + }, + get inUse() { + + return this.total - scope.nCachedObjects_; + + } + }, + get bindingsPerObject() { + + return scope._bindings.length; + + } + + }; + + } + + add() { + + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + paths = this._paths, + parsedPaths = this._parsedPaths, + bindings = this._bindings, + nBindings = bindings.length; + + let knownObject = undefined, + nObjects = objects.length, + nCachedObjects = this.nCachedObjects_; + + for ( let i = 0, n = arguments.length; i !== n; ++ i ) { + + const object = arguments[ i ], + uuid = object.uuid; + let index = indicesByUUID[ uuid ]; + + if ( index === undefined ) { + + // unknown object -> add it to the ACTIVE region + + index = nObjects ++; + indicesByUUID[ uuid ] = index; + objects.push( object ); + + // accounting is done, now do the same for all bindings + + for ( let j = 0, m = nBindings; j !== m; ++ j ) { + + bindings[ j ].push( new PropertyBinding( object, paths[ j ], parsedPaths[ j ] ) ); + + } + + } else if ( index < nCachedObjects ) { + + knownObject = objects[ index ]; + + // move existing object to the ACTIVE region + + const firstActiveIndex = -- nCachedObjects, + lastCachedObject = objects[ firstActiveIndex ]; + + indicesByUUID[ lastCachedObject.uuid ] = index; + objects[ index ] = lastCachedObject; + + indicesByUUID[ uuid ] = firstActiveIndex; + objects[ firstActiveIndex ] = object; + + // accounting is done, now do the same for all bindings + + for ( let j = 0, m = nBindings; j !== m; ++ j ) { + + const bindingsForPath = bindings[ j ], + lastCached = bindingsForPath[ firstActiveIndex ]; + + let binding = bindingsForPath[ index ]; + + bindingsForPath[ index ] = lastCached; + + if ( binding === undefined ) { + + // since we do not bother to create new bindings + // for objects that are cached, the binding may + // or may not exist + + binding = new PropertyBinding( object, paths[ j ], parsedPaths[ j ] ); + + } + + bindingsForPath[ firstActiveIndex ] = binding; + + } + + } else if ( objects[ index ] !== knownObject ) { + + console.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' + + 'detected. Clean the caches or recreate your infrastructure when reloading scenes.' ); + + } // else the object is already where we want it to be + + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + + } + + remove() { + + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + bindings = this._bindings, + nBindings = bindings.length; + + let nCachedObjects = this.nCachedObjects_; + + for ( let i = 0, n = arguments.length; i !== n; ++ i ) { + + const object = arguments[ i ], + uuid = object.uuid, + index = indicesByUUID[ uuid ]; + + if ( index !== undefined && index >= nCachedObjects ) { + + // move existing object into the CACHED region + + const lastCachedIndex = nCachedObjects ++, + firstActiveObject = objects[ lastCachedIndex ]; + + indicesByUUID[ firstActiveObject.uuid ] = index; + objects[ index ] = firstActiveObject; + + indicesByUUID[ uuid ] = lastCachedIndex; + objects[ lastCachedIndex ] = object; + + // accounting is done, now do the same for all bindings + + for ( let j = 0, m = nBindings; j !== m; ++ j ) { + + const bindingsForPath = bindings[ j ], + firstActive = bindingsForPath[ lastCachedIndex ], + binding = bindingsForPath[ index ]; + + bindingsForPath[ index ] = firstActive; + bindingsForPath[ lastCachedIndex ] = binding; + + } + + } + + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + + } + + // remove & forget + uncache() { + + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + bindings = this._bindings, + nBindings = bindings.length; + + let nCachedObjects = this.nCachedObjects_, + nObjects = objects.length; + + for ( let i = 0, n = arguments.length; i !== n; ++ i ) { + + const object = arguments[ i ], + uuid = object.uuid, + index = indicesByUUID[ uuid ]; + + if ( index !== undefined ) { + + delete indicesByUUID[ uuid ]; + + if ( index < nCachedObjects ) { + + // object is cached, shrink the CACHED region + + const firstActiveIndex = -- nCachedObjects, + lastCachedObject = objects[ firstActiveIndex ], + lastIndex = -- nObjects, + lastObject = objects[ lastIndex ]; + + // last cached object takes this object's place + indicesByUUID[ lastCachedObject.uuid ] = index; + objects[ index ] = lastCachedObject; + + // last object goes to the activated slot and pop + indicesByUUID[ lastObject.uuid ] = firstActiveIndex; + objects[ firstActiveIndex ] = lastObject; + objects.pop(); + + // accounting is done, now do the same for all bindings + + for ( let j = 0, m = nBindings; j !== m; ++ j ) { + + const bindingsForPath = bindings[ j ], + lastCached = bindingsForPath[ firstActiveIndex ], + last = bindingsForPath[ lastIndex ]; + + bindingsForPath[ index ] = lastCached; + bindingsForPath[ firstActiveIndex ] = last; + bindingsForPath.pop(); + + } + + } else { + + // object is active, just swap with the last and pop + + const lastIndex = -- nObjects, + lastObject = objects[ lastIndex ]; + + if ( lastIndex > 0 ) { + + indicesByUUID[ lastObject.uuid ] = index; + + } + + objects[ index ] = lastObject; + objects.pop(); + + // accounting is done, now do the same for all bindings + + for ( let j = 0, m = nBindings; j !== m; ++ j ) { + + const bindingsForPath = bindings[ j ]; + + bindingsForPath[ index ] = bindingsForPath[ lastIndex ]; + bindingsForPath.pop(); + + } + + } // cached or active + + } // if object is known + + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + + } + + // Internal interface used by befriended PropertyBinding.Composite: + + subscribe_( path, parsedPath ) { + + // returns an array of bindings for the given path that is changed + // according to the contained objects in the group + + const indicesByPath = this._bindingsIndicesByPath; + let index = indicesByPath[ path ]; + const bindings = this._bindings; + + if ( index !== undefined ) return bindings[ index ]; + + const paths = this._paths, + parsedPaths = this._parsedPaths, + objects = this._objects, + nObjects = objects.length, + nCachedObjects = this.nCachedObjects_, + bindingsForPath = new Array( nObjects ); + + index = bindings.length; + + indicesByPath[ path ] = index; + + paths.push( path ); + parsedPaths.push( parsedPath ); + bindings.push( bindingsForPath ); + + for ( let i = nCachedObjects, n = objects.length; i !== n; ++ i ) { + + const object = objects[ i ]; + bindingsForPath[ i ] = new PropertyBinding( object, path, parsedPath ); + + } + + return bindingsForPath; + + } + + unsubscribe_( path ) { + + // tells the group to forget about a property path and no longer + // update the array previously obtained with 'subscribe_' + + const indicesByPath = this._bindingsIndicesByPath, + index = indicesByPath[ path ]; + + if ( index !== undefined ) { + + const paths = this._paths, + parsedPaths = this._parsedPaths, + bindings = this._bindings, + lastBindingsIndex = bindings.length - 1, + lastBindings = bindings[ lastBindingsIndex ], + lastBindingsPath = path[ lastBindingsIndex ]; + + indicesByPath[ lastBindingsPath ] = index; + + bindings[ index ] = lastBindings; + bindings.pop(); + + parsedPaths[ index ] = parsedPaths[ lastBindingsIndex ]; + parsedPaths.pop(); + + paths[ index ] = paths[ lastBindingsIndex ]; + paths.pop(); + + } + + } + +} + +AnimationObjectGroup.prototype.isAnimationObjectGroup = true; + +class AnimationAction { + + constructor( mixer, clip, localRoot = null, blendMode = clip.blendMode ) { + + this._mixer = mixer; + this._clip = clip; + this._localRoot = localRoot; + this.blendMode = blendMode; + + const tracks = clip.tracks, + nTracks = tracks.length, + interpolants = new Array( nTracks ); + + const interpolantSettings = { + endingStart: ZeroCurvatureEnding, + endingEnd: ZeroCurvatureEnding + }; + + for ( let i = 0; i !== nTracks; ++ i ) { + + const interpolant = tracks[ i ].createInterpolant( null ); + interpolants[ i ] = interpolant; + interpolant.settings = interpolantSettings; + + } + + this._interpolantSettings = interpolantSettings; + + this._interpolants = interpolants; // bound by the mixer + + // inside: PropertyMixer (managed by the mixer) + this._propertyBindings = new Array( nTracks ); + + this._cacheIndex = null; // for the memory manager + this._byClipCacheIndex = null; // for the memory manager + + this._timeScaleInterpolant = null; + this._weightInterpolant = null; + + this.loop = LoopRepeat; + this._loopCount = - 1; + + // global mixer time when the action is to be started + // it's set back to 'null' upon start of the action + this._startTime = null; + + // scaled local time of the action + // gets clamped or wrapped to 0..clip.duration according to loop + this.time = 0; + + this.timeScale = 1; + this._effectiveTimeScale = 1; + + this.weight = 1; + this._effectiveWeight = 1; + + this.repetitions = Infinity; // no. of repetitions when looping + + this.paused = false; // true -> zero effective time scale + this.enabled = true; // false -> zero effective weight + + this.clampWhenFinished = false;// keep feeding the last frame? + + this.zeroSlopeAtStart = true;// for smooth interpolation w/o separate + this.zeroSlopeAtEnd = true;// clips for start, loop and end + + } + + // State & Scheduling + + play() { + + this._mixer._activateAction( this ); + + return this; + + } + + stop() { + + this._mixer._deactivateAction( this ); + + return this.reset(); + + } + + reset() { + + this.paused = false; + this.enabled = true; + + this.time = 0; // restart clip + this._loopCount = - 1;// forget previous loops + this._startTime = null;// forget scheduling + + return this.stopFading().stopWarping(); + + } + + isRunning() { + + return this.enabled && ! this.paused && this.timeScale !== 0 && + this._startTime === null && this._mixer._isActiveAction( this ); + + } + + // return true when play has been called + isScheduled() { + + return this._mixer._isActiveAction( this ); + + } + + startAt( time ) { + + this._startTime = time; + + return this; + + } + + setLoop( mode, repetitions ) { + + this.loop = mode; + this.repetitions = repetitions; + + return this; + + } + + // Weight + + // set the weight stopping any scheduled fading + // although .enabled = false yields an effective weight of zero, this + // method does *not* change .enabled, because it would be confusing + setEffectiveWeight( weight ) { + + this.weight = weight; + + // note: same logic as when updated at runtime + this._effectiveWeight = this.enabled ? weight : 0; + + return this.stopFading(); + + } + + // return the weight considering fading and .enabled + getEffectiveWeight() { + + return this._effectiveWeight; + + } + + fadeIn( duration ) { + + return this._scheduleFading( duration, 0, 1 ); + + } + + fadeOut( duration ) { + + return this._scheduleFading( duration, 1, 0 ); + + } + + crossFadeFrom( fadeOutAction, duration, warp ) { + + fadeOutAction.fadeOut( duration ); + this.fadeIn( duration ); + + if ( warp ) { + + const fadeInDuration = this._clip.duration, + fadeOutDuration = fadeOutAction._clip.duration, + + startEndRatio = fadeOutDuration / fadeInDuration, + endStartRatio = fadeInDuration / fadeOutDuration; + + fadeOutAction.warp( 1.0, startEndRatio, duration ); + this.warp( endStartRatio, 1.0, duration ); + + } + + return this; + + } + + crossFadeTo( fadeInAction, duration, warp ) { + + return fadeInAction.crossFadeFrom( this, duration, warp ); + + } + + stopFading() { + + const weightInterpolant = this._weightInterpolant; + + if ( weightInterpolant !== null ) { + + this._weightInterpolant = null; + this._mixer._takeBackControlInterpolant( weightInterpolant ); + + } + + return this; + + } + + // Time Scale Control + + // set the time scale stopping any scheduled warping + // although .paused = true yields an effective time scale of zero, this + // method does *not* change .paused, because it would be confusing + setEffectiveTimeScale( timeScale ) { + + this.timeScale = timeScale; + this._effectiveTimeScale = this.paused ? 0 : timeScale; + + return this.stopWarping(); + + } + + // return the time scale considering warping and .paused + getEffectiveTimeScale() { + + return this._effectiveTimeScale; + + } + + setDuration( duration ) { + + this.timeScale = this._clip.duration / duration; + + return this.stopWarping(); + + } + + syncWith( action ) { + + this.time = action.time; + this.timeScale = action.timeScale; + + return this.stopWarping(); + + } + + halt( duration ) { + + return this.warp( this._effectiveTimeScale, 0, duration ); + + } + + warp( startTimeScale, endTimeScale, duration ) { + + const mixer = this._mixer, + now = mixer.time, + timeScale = this.timeScale; + + let interpolant = this._timeScaleInterpolant; + + if ( interpolant === null ) { + + interpolant = mixer._lendControlInterpolant(); + this._timeScaleInterpolant = interpolant; + + } + + const times = interpolant.parameterPositions, + values = interpolant.sampleValues; + + times[ 0 ] = now; + times[ 1 ] = now + duration; + + values[ 0 ] = startTimeScale / timeScale; + values[ 1 ] = endTimeScale / timeScale; + + return this; + + } + + stopWarping() { + + const timeScaleInterpolant = this._timeScaleInterpolant; + + if ( timeScaleInterpolant !== null ) { + + this._timeScaleInterpolant = null; + this._mixer._takeBackControlInterpolant( timeScaleInterpolant ); + + } + + return this; + + } + + // Object Accessors + + getMixer() { + + return this._mixer; + + } + + getClip() { + + return this._clip; + + } + + getRoot() { + + return this._localRoot || this._mixer._root; + + } + + // Interna + + _update( time, deltaTime, timeDirection, accuIndex ) { + + // called by the mixer + + if ( ! this.enabled ) { + + // call ._updateWeight() to update ._effectiveWeight + + this._updateWeight( time ); + return; + + } + + const startTime = this._startTime; + + if ( startTime !== null ) { + + // check for scheduled start of action + + const timeRunning = ( time - startTime ) * timeDirection; + if ( timeRunning < 0 || timeDirection === 0 ) { + + return; // yet to come / don't decide when delta = 0 + + } + + // start + + this._startTime = null; // unschedule + deltaTime = timeDirection * timeRunning; + + } + + // apply time scale and advance time + + deltaTime *= this._updateTimeScale( time ); + const clipTime = this._updateTime( deltaTime ); + + // note: _updateTime may disable the action resulting in + // an effective weight of 0 + + const weight = this._updateWeight( time ); + + if ( weight > 0 ) { + + const interpolants = this._interpolants; + const propertyMixers = this._propertyBindings; + + switch ( this.blendMode ) { + + case AdditiveAnimationBlendMode: + + for ( let j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulateAdditive( weight ); + + } + + break; + + case NormalAnimationBlendMode: + default: + + for ( let j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulate( accuIndex, weight ); + + } + + } + + } + + } + + _updateWeight( time ) { + + let weight = 0; + + if ( this.enabled ) { + + weight = this.weight; + const interpolant = this._weightInterpolant; + + if ( interpolant !== null ) { + + const interpolantValue = interpolant.evaluate( time )[ 0 ]; + + weight *= interpolantValue; + + if ( time > interpolant.parameterPositions[ 1 ] ) { + + this.stopFading(); + + if ( interpolantValue === 0 ) { + + // faded out, disable + this.enabled = false; + + } + + } + + } + + } + + this._effectiveWeight = weight; + return weight; + + } + + _updateTimeScale( time ) { + + let timeScale = 0; + + if ( ! this.paused ) { + + timeScale = this.timeScale; + + const interpolant = this._timeScaleInterpolant; + + if ( interpolant !== null ) { + + const interpolantValue = interpolant.evaluate( time )[ 0 ]; + + timeScale *= interpolantValue; + + if ( time > interpolant.parameterPositions[ 1 ] ) { + + this.stopWarping(); + + if ( timeScale === 0 ) { + + // motion has halted, pause + this.paused = true; + + } else { + + // warp done - apply final time scale + this.timeScale = timeScale; + + } + + } + + } + + } + + this._effectiveTimeScale = timeScale; + return timeScale; + + } + + _updateTime( deltaTime ) { + + const duration = this._clip.duration; + const loop = this.loop; + + let time = this.time + deltaTime; + let loopCount = this._loopCount; + + const pingPong = ( loop === LoopPingPong ); + + if ( deltaTime === 0 ) { + + if ( loopCount === - 1 ) return time; + + return ( pingPong && ( loopCount & 1 ) === 1 ) ? duration - time : time; + + } + + if ( loop === LoopOnce ) { + + if ( loopCount === - 1 ) { + + // just started + + this._loopCount = 0; + this._setEndings( true, true, false ); + + } + + handle_stop: { + + if ( time >= duration ) { + + time = duration; + + } else if ( time < 0 ) { + + time = 0; + + } else { + + this.time = time; + + break handle_stop; + + } + + if ( this.clampWhenFinished ) this.paused = true; + else this.enabled = false; + + this.time = time; + + this._mixer.dispatchEvent( { + type: 'finished', action: this, + direction: deltaTime < 0 ? - 1 : 1 + } ); + + } + + } else { // repetitive Repeat or PingPong + + if ( loopCount === - 1 ) { + + // just started + + if ( deltaTime >= 0 ) { + + loopCount = 0; + + this._setEndings( true, this.repetitions === 0, pingPong ); + + } else { + + // when looping in reverse direction, the initial + // transition through zero counts as a repetition, + // so leave loopCount at -1 + + this._setEndings( this.repetitions === 0, true, pingPong ); + + } + + } + + if ( time >= duration || time < 0 ) { + + // wrap around + + const loopDelta = Math.floor( time / duration ); // signed + time -= duration * loopDelta; + + loopCount += Math.abs( loopDelta ); + + const pending = this.repetitions - loopCount; + + if ( pending <= 0 ) { + + // have to stop (switch state, clamp time, fire event) + + if ( this.clampWhenFinished ) this.paused = true; + else this.enabled = false; + + time = deltaTime > 0 ? duration : 0; + + this.time = time; + + this._mixer.dispatchEvent( { + type: 'finished', action: this, + direction: deltaTime > 0 ? 1 : - 1 + } ); + + } else { + + // keep running + + if ( pending === 1 ) { + + // entering the last round + + const atStart = deltaTime < 0; + this._setEndings( atStart, ! atStart, pingPong ); + + } else { + + this._setEndings( false, false, pingPong ); + + } + + this._loopCount = loopCount; + + this.time = time; + + this._mixer.dispatchEvent( { + type: 'loop', action: this, loopDelta: loopDelta + } ); + + } + + } else { + + this.time = time; + + } + + if ( pingPong && ( loopCount & 1 ) === 1 ) { + + // invert time for the "pong round" + + return duration - time; + + } + + } + + return time; + + } + + _setEndings( atStart, atEnd, pingPong ) { + + const settings = this._interpolantSettings; + + if ( pingPong ) { + + settings.endingStart = ZeroSlopeEnding; + settings.endingEnd = ZeroSlopeEnding; + + } else { + + // assuming for LoopOnce atStart == atEnd == true + + if ( atStart ) { + + settings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding; + + } else { + + settings.endingStart = WrapAroundEnding; + + } + + if ( atEnd ) { + + settings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding; + + } else { + + settings.endingEnd = WrapAroundEnding; + + } + + } + + } + + _scheduleFading( duration, weightNow, weightThen ) { + + const mixer = this._mixer, now = mixer.time; + let interpolant = this._weightInterpolant; + + if ( interpolant === null ) { + + interpolant = mixer._lendControlInterpolant(); + this._weightInterpolant = interpolant; + + } + + const times = interpolant.parameterPositions, + values = interpolant.sampleValues; + + times[ 0 ] = now; + values[ 0 ] = weightNow; + times[ 1 ] = now + duration; + values[ 1 ] = weightThen; + + return this; + + } + +} + +class AnimationMixer extends EventDispatcher { + + constructor( root ) { + + super(); + + this._root = root; + this._initMemoryManager(); + this._accuIndex = 0; + this.time = 0; + this.timeScale = 1.0; + + } + + _bindAction( action, prototypeAction ) { + + const root = action._localRoot || this._root, + tracks = action._clip.tracks, + nTracks = tracks.length, + bindings = action._propertyBindings, + interpolants = action._interpolants, + rootUuid = root.uuid, + bindingsByRoot = this._bindingsByRootAndName; + + let bindingsByName = bindingsByRoot[ rootUuid ]; + + if ( bindingsByName === undefined ) { + + bindingsByName = {}; + bindingsByRoot[ rootUuid ] = bindingsByName; + + } + + for ( let i = 0; i !== nTracks; ++ i ) { + + const track = tracks[ i ], + trackName = track.name; + + let binding = bindingsByName[ trackName ]; + + if ( binding !== undefined ) { + + ++ binding.referenceCount; + bindings[ i ] = binding; + + } else { + + binding = bindings[ i ]; + + if ( binding !== undefined ) { + + // existing binding, make sure the cache knows + + if ( binding._cacheIndex === null ) { + + ++ binding.referenceCount; + this._addInactiveBinding( binding, rootUuid, trackName ); + + } + + continue; + + } + + const path = prototypeAction && prototypeAction. + _propertyBindings[ i ].binding.parsedPath; + + binding = new PropertyMixer( + PropertyBinding.create( root, trackName, path ), + track.ValueTypeName, track.getValueSize() ); + + ++ binding.referenceCount; + this._addInactiveBinding( binding, rootUuid, trackName ); + + bindings[ i ] = binding; + + } + + interpolants[ i ].resultBuffer = binding.buffer; + + } + + } + + _activateAction( action ) { + + if ( ! this._isActiveAction( action ) ) { + + if ( action._cacheIndex === null ) { + + // this action has been forgotten by the cache, but the user + // appears to be still using it -> rebind + + const rootUuid = ( action._localRoot || this._root ).uuid, + clipUuid = action._clip.uuid, + actionsForClip = this._actionsByClip[ clipUuid ]; + + this._bindAction( action, + actionsForClip && actionsForClip.knownActions[ 0 ] ); + + this._addInactiveAction( action, clipUuid, rootUuid ); + + } + + const bindings = action._propertyBindings; + + // increment reference counts / sort out state + for ( let i = 0, n = bindings.length; i !== n; ++ i ) { + + const binding = bindings[ i ]; + + if ( binding.useCount ++ === 0 ) { + + this._lendBinding( binding ); + binding.saveOriginalState(); + + } + + } + + this._lendAction( action ); + + } + + } + + _deactivateAction( action ) { + + if ( this._isActiveAction( action ) ) { + + const bindings = action._propertyBindings; + + // decrement reference counts / sort out state + for ( let i = 0, n = bindings.length; i !== n; ++ i ) { + + const binding = bindings[ i ]; + + if ( -- binding.useCount === 0 ) { + + binding.restoreOriginalState(); + this._takeBackBinding( binding ); + + } + + } + + this._takeBackAction( action ); + + } + + } + + // Memory manager + + _initMemoryManager() { + + this._actions = []; // 'nActiveActions' followed by inactive ones + this._nActiveActions = 0; + + this._actionsByClip = {}; + // inside: + // { + // knownActions: Array< AnimationAction > - used as prototypes + // actionByRoot: AnimationAction - lookup + // } + + + this._bindings = []; // 'nActiveBindings' followed by inactive ones + this._nActiveBindings = 0; + + this._bindingsByRootAndName = {}; // inside: Map< name, PropertyMixer > + + + this._controlInterpolants = []; // same game as above + this._nActiveControlInterpolants = 0; + + const scope = this; + + this.stats = { + + actions: { + get total() { + + return scope._actions.length; + + }, + get inUse() { + + return scope._nActiveActions; + + } + }, + bindings: { + get total() { + + return scope._bindings.length; + + }, + get inUse() { + + return scope._nActiveBindings; + + } + }, + controlInterpolants: { + get total() { + + return scope._controlInterpolants.length; + + }, + get inUse() { + + return scope._nActiveControlInterpolants; + + } + } + + }; + + } + + // Memory management for AnimationAction objects + + _isActiveAction( action ) { + + const index = action._cacheIndex; + return index !== null && index < this._nActiveActions; + + } + + _addInactiveAction( action, clipUuid, rootUuid ) { + + const actions = this._actions, + actionsByClip = this._actionsByClip; + + let actionsForClip = actionsByClip[ clipUuid ]; + + if ( actionsForClip === undefined ) { + + actionsForClip = { + + knownActions: [ action ], + actionByRoot: {} + + }; + + action._byClipCacheIndex = 0; + + actionsByClip[ clipUuid ] = actionsForClip; + + } else { + + const knownActions = actionsForClip.knownActions; + + action._byClipCacheIndex = knownActions.length; + knownActions.push( action ); + + } + + action._cacheIndex = actions.length; + actions.push( action ); + + actionsForClip.actionByRoot[ rootUuid ] = action; + + } + + _removeInactiveAction( action ) { + + const actions = this._actions, + lastInactiveAction = actions[ actions.length - 1 ], + cacheIndex = action._cacheIndex; + + lastInactiveAction._cacheIndex = cacheIndex; + actions[ cacheIndex ] = lastInactiveAction; + actions.pop(); + + action._cacheIndex = null; + + + const clipUuid = action._clip.uuid, + actionsByClip = this._actionsByClip, + actionsForClip = actionsByClip[ clipUuid ], + knownActionsForClip = actionsForClip.knownActions, + + lastKnownAction = + knownActionsForClip[ knownActionsForClip.length - 1 ], + + byClipCacheIndex = action._byClipCacheIndex; + + lastKnownAction._byClipCacheIndex = byClipCacheIndex; + knownActionsForClip[ byClipCacheIndex ] = lastKnownAction; + knownActionsForClip.pop(); + + action._byClipCacheIndex = null; + + + const actionByRoot = actionsForClip.actionByRoot, + rootUuid = ( action._localRoot || this._root ).uuid; + + delete actionByRoot[ rootUuid ]; + + if ( knownActionsForClip.length === 0 ) { + + delete actionsByClip[ clipUuid ]; + + } + + this._removeInactiveBindingsForAction( action ); + + } + + _removeInactiveBindingsForAction( action ) { + + const bindings = action._propertyBindings; + + for ( let i = 0, n = bindings.length; i !== n; ++ i ) { + + const binding = bindings[ i ]; + + if ( -- binding.referenceCount === 0 ) { + + this._removeInactiveBinding( binding ); + + } + + } + + } + + _lendAction( action ) { + + // [ active actions | inactive actions ] + // [ active actions >| inactive actions ] + // s a + // <-swap-> + // a s + + const actions = this._actions, + prevIndex = action._cacheIndex, + + lastActiveIndex = this._nActiveActions ++, + + firstInactiveAction = actions[ lastActiveIndex ]; + + action._cacheIndex = lastActiveIndex; + actions[ lastActiveIndex ] = action; + + firstInactiveAction._cacheIndex = prevIndex; + actions[ prevIndex ] = firstInactiveAction; + + } + + _takeBackAction( action ) { + + // [ active actions | inactive actions ] + // [ active actions |< inactive actions ] + // a s + // <-swap-> + // s a + + const actions = this._actions, + prevIndex = action._cacheIndex, + + firstInactiveIndex = -- this._nActiveActions, + + lastActiveAction = actions[ firstInactiveIndex ]; + + action._cacheIndex = firstInactiveIndex; + actions[ firstInactiveIndex ] = action; + + lastActiveAction._cacheIndex = prevIndex; + actions[ prevIndex ] = lastActiveAction; + + } + + // Memory management for PropertyMixer objects + + _addInactiveBinding( binding, rootUuid, trackName ) { + + const bindingsByRoot = this._bindingsByRootAndName, + bindings = this._bindings; + + let bindingByName = bindingsByRoot[ rootUuid ]; + + if ( bindingByName === undefined ) { + + bindingByName = {}; + bindingsByRoot[ rootUuid ] = bindingByName; + + } + + bindingByName[ trackName ] = binding; + + binding._cacheIndex = bindings.length; + bindings.push( binding ); + + } + + _removeInactiveBinding( binding ) { + + const bindings = this._bindings, + propBinding = binding.binding, + rootUuid = propBinding.rootNode.uuid, + trackName = propBinding.path, + bindingsByRoot = this._bindingsByRootAndName, + bindingByName = bindingsByRoot[ rootUuid ], + + lastInactiveBinding = bindings[ bindings.length - 1 ], + cacheIndex = binding._cacheIndex; + + lastInactiveBinding._cacheIndex = cacheIndex; + bindings[ cacheIndex ] = lastInactiveBinding; + bindings.pop(); + + delete bindingByName[ trackName ]; + + if ( Object.keys( bindingByName ).length === 0 ) { + + delete bindingsByRoot[ rootUuid ]; + + } + + } + + _lendBinding( binding ) { + + const bindings = this._bindings, + prevIndex = binding._cacheIndex, + + lastActiveIndex = this._nActiveBindings ++, + + firstInactiveBinding = bindings[ lastActiveIndex ]; + + binding._cacheIndex = lastActiveIndex; + bindings[ lastActiveIndex ] = binding; + + firstInactiveBinding._cacheIndex = prevIndex; + bindings[ prevIndex ] = firstInactiveBinding; + + } + + _takeBackBinding( binding ) { + + const bindings = this._bindings, + prevIndex = binding._cacheIndex, + + firstInactiveIndex = -- this._nActiveBindings, + + lastActiveBinding = bindings[ firstInactiveIndex ]; + + binding._cacheIndex = firstInactiveIndex; + bindings[ firstInactiveIndex ] = binding; + + lastActiveBinding._cacheIndex = prevIndex; + bindings[ prevIndex ] = lastActiveBinding; + + } + + + // Memory management of Interpolants for weight and time scale + + _lendControlInterpolant() { + + const interpolants = this._controlInterpolants, + lastActiveIndex = this._nActiveControlInterpolants ++; + + let interpolant = interpolants[ lastActiveIndex ]; + + if ( interpolant === undefined ) { + + interpolant = new LinearInterpolant( + new Float32Array( 2 ), new Float32Array( 2 ), + 1, this._controlInterpolantsResultBuffer ); + + interpolant.__cacheIndex = lastActiveIndex; + interpolants[ lastActiveIndex ] = interpolant; + + } + + return interpolant; + + } + + _takeBackControlInterpolant( interpolant ) { + + const interpolants = this._controlInterpolants, + prevIndex = interpolant.__cacheIndex, + + firstInactiveIndex = -- this._nActiveControlInterpolants, + + lastActiveInterpolant = interpolants[ firstInactiveIndex ]; + + interpolant.__cacheIndex = firstInactiveIndex; + interpolants[ firstInactiveIndex ] = interpolant; + + lastActiveInterpolant.__cacheIndex = prevIndex; + interpolants[ prevIndex ] = lastActiveInterpolant; + + } + + // return an action for a clip optionally using a custom root target + // object (this method allocates a lot of dynamic memory in case a + // previously unknown clip/root combination is specified) + clipAction( clip, optionalRoot, blendMode ) { + + const root = optionalRoot || this._root, + rootUuid = root.uuid; + + let clipObject = typeof clip === 'string' ? AnimationClip.findByName( root, clip ) : clip; + + const clipUuid = clipObject !== null ? clipObject.uuid : clip; + + const actionsForClip = this._actionsByClip[ clipUuid ]; + let prototypeAction = null; + + if ( blendMode === undefined ) { + + if ( clipObject !== null ) { + + blendMode = clipObject.blendMode; + + } else { + + blendMode = NormalAnimationBlendMode; + + } + + } + + if ( actionsForClip !== undefined ) { + + const existingAction = actionsForClip.actionByRoot[ rootUuid ]; + + if ( existingAction !== undefined && existingAction.blendMode === blendMode ) { + + return existingAction; + + } + + // we know the clip, so we don't have to parse all + // the bindings again but can just copy + prototypeAction = actionsForClip.knownActions[ 0 ]; + + // also, take the clip from the prototype action + if ( clipObject === null ) + clipObject = prototypeAction._clip; + + } + + // clip must be known when specified via string + if ( clipObject === null ) return null; + + // allocate all resources required to run it + const newAction = new AnimationAction( this, clipObject, optionalRoot, blendMode ); + + this._bindAction( newAction, prototypeAction ); + + // and make the action known to the memory manager + this._addInactiveAction( newAction, clipUuid, rootUuid ); + + return newAction; + + } + + // get an existing action + existingAction( clip, optionalRoot ) { + + const root = optionalRoot || this._root, + rootUuid = root.uuid, + + clipObject = typeof clip === 'string' ? + AnimationClip.findByName( root, clip ) : clip, + + clipUuid = clipObject ? clipObject.uuid : clip, + + actionsForClip = this._actionsByClip[ clipUuid ]; + + if ( actionsForClip !== undefined ) { + + return actionsForClip.actionByRoot[ rootUuid ] || null; + + } + + return null; + + } + + // deactivates all previously scheduled actions + stopAllAction() { + + const actions = this._actions, + nActions = this._nActiveActions; + + for ( let i = nActions - 1; i >= 0; -- i ) { + + actions[ i ].stop(); + + } + + return this; + + } + + // advance the time and update apply the animation + update( deltaTime ) { + + deltaTime *= this.timeScale; + + const actions = this._actions, + nActions = this._nActiveActions, + + time = this.time += deltaTime, + timeDirection = Math.sign( deltaTime ), + + accuIndex = this._accuIndex ^= 1; + + // run active actions + + for ( let i = 0; i !== nActions; ++ i ) { + + const action = actions[ i ]; + + action._update( time, deltaTime, timeDirection, accuIndex ); + + } + + // update scene graph + + const bindings = this._bindings, + nBindings = this._nActiveBindings; + + for ( let i = 0; i !== nBindings; ++ i ) { + + bindings[ i ].apply( accuIndex ); + + } + + return this; + + } + + // Allows you to seek to a specific time in an animation. + setTime( timeInSeconds ) { + + this.time = 0; // Zero out time attribute for AnimationMixer object; + for ( let i = 0; i < this._actions.length; i ++ ) { + + this._actions[ i ].time = 0; // Zero out time attribute for all associated AnimationAction objects. + + } + + return this.update( timeInSeconds ); // Update used to set exact time. Returns "this" AnimationMixer object. + + } + + // return this mixer's root target object + getRoot() { + + return this._root; + + } + + // free all resources specific to a particular clip + uncacheClip( clip ) { + + const actions = this._actions, + clipUuid = clip.uuid, + actionsByClip = this._actionsByClip, + actionsForClip = actionsByClip[ clipUuid ]; + + if ( actionsForClip !== undefined ) { + + // note: just calling _removeInactiveAction would mess up the + // iteration state and also require updating the state we can + // just throw away + + const actionsToRemove = actionsForClip.knownActions; + + for ( let i = 0, n = actionsToRemove.length; i !== n; ++ i ) { + + const action = actionsToRemove[ i ]; + + this._deactivateAction( action ); + + const cacheIndex = action._cacheIndex, + lastInactiveAction = actions[ actions.length - 1 ]; + + action._cacheIndex = null; + action._byClipCacheIndex = null; + + lastInactiveAction._cacheIndex = cacheIndex; + actions[ cacheIndex ] = lastInactiveAction; + actions.pop(); + + this._removeInactiveBindingsForAction( action ); + + } + + delete actionsByClip[ clipUuid ]; + + } + + } + + // free all resources specific to a particular root target object + uncacheRoot( root ) { + + const rootUuid = root.uuid, + actionsByClip = this._actionsByClip; + + for ( const clipUuid in actionsByClip ) { + + const actionByRoot = actionsByClip[ clipUuid ].actionByRoot, + action = actionByRoot[ rootUuid ]; + + if ( action !== undefined ) { + + this._deactivateAction( action ); + this._removeInactiveAction( action ); + + } + + } + + const bindingsByRoot = this._bindingsByRootAndName, + bindingByName = bindingsByRoot[ rootUuid ]; + + if ( bindingByName !== undefined ) { + + for ( const trackName in bindingByName ) { + + const binding = bindingByName[ trackName ]; + binding.restoreOriginalState(); + this._removeInactiveBinding( binding ); + + } + + } + + } + + // remove a targeted clip from the cache + uncacheAction( clip, optionalRoot ) { + + const action = this.existingAction( clip, optionalRoot ); + + if ( action !== null ) { + + this._deactivateAction( action ); + this._removeInactiveAction( action ); + + } + + } + +} + +AnimationMixer.prototype._controlInterpolantsResultBuffer = new Float32Array( 1 ); + +class Uniform { + + constructor( value ) { + + if ( typeof value === 'string' ) { + + console.warn( 'THREE.Uniform: Type parameter is no longer needed.' ); + value = arguments[ 1 ]; + + } + + this.value = value; + + } + + clone() { + + return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); + + } + +} + +class InstancedInterleavedBuffer extends InterleavedBuffer { + + constructor( array, stride, meshPerAttribute = 1 ) { + + super( array, stride ); + + this.meshPerAttribute = meshPerAttribute; + + } + + copy( source ) { + + super.copy( source ); + + this.meshPerAttribute = source.meshPerAttribute; + + return this; + + } + + clone( data ) { + + const ib = super.clone( data ); + + ib.meshPerAttribute = this.meshPerAttribute; + + return ib; + + } + + toJSON( data ) { + + const json = super.toJSON( data ); + + json.isInstancedInterleavedBuffer = true; + json.meshPerAttribute = this.meshPerAttribute; + + return json; + + } + +} + +InstancedInterleavedBuffer.prototype.isInstancedInterleavedBuffer = true; + +class GLBufferAttribute { + + constructor( buffer, type, itemSize, elementSize, count ) { + + this.buffer = buffer; + this.type = type; + this.itemSize = itemSize; + this.elementSize = elementSize; + this.count = count; + + this.version = 0; + + } + + set needsUpdate( value ) { + + if ( value === true ) this.version ++; + + } + + setBuffer( buffer ) { + + this.buffer = buffer; + + return this; + + } + + setType( type, elementSize ) { + + this.type = type; + this.elementSize = elementSize; + + return this; + + } + + setItemSize( itemSize ) { + + this.itemSize = itemSize; + + return this; + + } + + setCount( count ) { + + this.count = count; + + return this; + + } + +} + +GLBufferAttribute.prototype.isGLBufferAttribute = true; + +class Raycaster { + + constructor( origin, direction, near = 0, far = Infinity ) { + + this.ray = new Ray( origin, direction ); + // direction is assumed to be normalized (for accurate distance calculations) + + this.near = near; + this.far = far; + this.camera = null; + this.layers = new Layers(); + + this.params = { + Mesh: {}, + Line: { threshold: 1 }, + LOD: {}, + Points: { threshold: 1 }, + Sprite: {} + }; + + } + + set( origin, direction ) { + + // direction is assumed to be normalized (for accurate distance calculations) + + this.ray.set( origin, direction ); + + } + + setFromCamera( coords, camera ) { + + if ( camera && camera.isPerspectiveCamera ) { + + this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); + this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); + this.camera = camera; + + } else if ( camera && camera.isOrthographicCamera ) { + + this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera + this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ); + this.camera = camera; + + } else { + + console.error( 'THREE.Raycaster: Unsupported camera type: ' + camera.type ); + + } + + } + + intersectObject( object, recursive = true, intersects = [] ) { + + intersectObject( object, this, intersects, recursive ); + + intersects.sort( ascSort ); + + return intersects; + + } + + intersectObjects( objects, recursive = true, intersects = [] ) { + + for ( let i = 0, l = objects.length; i < l; i ++ ) { + + intersectObject( objects[ i ], this, intersects, recursive ); + + } + + intersects.sort( ascSort ); + + return intersects; + + } + +} + +function ascSort( a, b ) { + + return a.distance - b.distance; + +} + +function intersectObject( object, raycaster, intersects, recursive ) { + + if ( object.layers.test( raycaster.layers ) ) { + + object.raycast( raycaster, intersects ); + + } + + if ( recursive === true ) { + + const children = object.children; + + for ( let i = 0, l = children.length; i < l; i ++ ) { + + intersectObject( children[ i ], raycaster, intersects, true ); + + } + + } + +} + +/** + * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system + * + * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up. + * The azimuthal angle (theta) is measured from the positive z-axis. + */ + +class Spherical { + + constructor( radius = 1, phi = 0, theta = 0 ) { + + this.radius = radius; + this.phi = phi; // polar angle + this.theta = theta; // azimuthal angle + + return this; + + } + + set( radius, phi, theta ) { + + this.radius = radius; + this.phi = phi; + this.theta = theta; + + return this; + + } + + copy( other ) { + + this.radius = other.radius; + this.phi = other.phi; + this.theta = other.theta; + + return this; + + } + + // restrict phi to be betwee EPS and PI-EPS + makeSafe() { + + const EPS = 0.000001; + this.phi = Math.max( EPS, Math.min( Math.PI - EPS, this.phi ) ); + + return this; + + } + + setFromVector3( v ) { + + return this.setFromCartesianCoords( v.x, v.y, v.z ); + + } + + setFromCartesianCoords( x, y, z ) { + + this.radius = Math.sqrt( x * x + y * y + z * z ); + + if ( this.radius === 0 ) { + + this.theta = 0; + this.phi = 0; + + } else { + + this.theta = Math.atan2( x, z ); + this.phi = Math.acos( clamp( y / this.radius, - 1, 1 ) ); + + } + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +/** + * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system + */ + +class Cylindrical { + + constructor( radius = 1, theta = 0, y = 0 ) { + + this.radius = radius; // distance from the origin to a point in the x-z plane + this.theta = theta; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis + this.y = y; // height above the x-z plane + + return this; + + } + + set( radius, theta, y ) { + + this.radius = radius; + this.theta = theta; + this.y = y; + + return this; + + } + + copy( other ) { + + this.radius = other.radius; + this.theta = other.theta; + this.y = other.y; + + return this; + + } + + setFromVector3( v ) { + + return this.setFromCartesianCoords( v.x, v.y, v.z ); + + } + + setFromCartesianCoords( x, y, z ) { + + this.radius = Math.sqrt( x * x + z * z ); + this.theta = Math.atan2( x, z ); + this.y = y; + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +const _vector$4 = /*@__PURE__*/ new Vector2(); + +class Box2 { + + constructor( min = new Vector2( + Infinity, + Infinity ), max = new Vector2( - Infinity, - Infinity ) ) { + + this.min = min; + this.max = max; + + } + + set( min, max ) { + + this.min.copy( min ); + this.max.copy( max ); + + return this; + + } + + setFromPoints( points ) { + + this.makeEmpty(); + + for ( let i = 0, il = points.length; i < il; i ++ ) { + + this.expandByPoint( points[ i ] ); + + } + + return this; + + } + + setFromCenterAndSize( center, size ) { + + const halfSize = _vector$4.copy( size ).multiplyScalar( 0.5 ); + this.min.copy( center ).sub( halfSize ); + this.max.copy( center ).add( halfSize ); + + return this; + + } + + clone() { + + return new this.constructor().copy( this ); + + } + + copy( box ) { + + this.min.copy( box.min ); + this.max.copy( box.max ); + + return this; + + } + + makeEmpty() { + + this.min.x = this.min.y = + Infinity; + this.max.x = this.max.y = - Infinity; + + return this; + + } + + isEmpty() { + + // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes + + return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ); + + } + + getCenter( target ) { + + return this.isEmpty() ? target.set( 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 ); + + } + + getSize( target ) { + + return this.isEmpty() ? target.set( 0, 0 ) : target.subVectors( this.max, this.min ); + + } + + expandByPoint( point ) { + + this.min.min( point ); + this.max.max( point ); + + return this; + + } + + expandByVector( vector ) { + + this.min.sub( vector ); + this.max.add( vector ); + + return this; + + } + + expandByScalar( scalar ) { + + this.min.addScalar( - scalar ); + this.max.addScalar( scalar ); + + return this; + + } + + containsPoint( point ) { + + return point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y ? false : true; + + } + + containsBox( box ) { + + return this.min.x <= box.min.x && box.max.x <= this.max.x && + this.min.y <= box.min.y && box.max.y <= this.max.y; + + } + + getParameter( point, target ) { + + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + + return target.set( + ( point.x - this.min.x ) / ( this.max.x - this.min.x ), + ( point.y - this.min.y ) / ( this.max.y - this.min.y ) + ); + + } + + intersectsBox( box ) { + + // using 4 splitting planes to rule out intersections + + return box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y ? false : true; + + } + + clampPoint( point, target ) { + + return target.copy( point ).clamp( this.min, this.max ); + + } + + distanceToPoint( point ) { + + const clampedPoint = _vector$4.copy( point ).clamp( this.min, this.max ); + return clampedPoint.sub( point ).length(); + + } + + intersect( box ) { + + this.min.max( box.min ); + this.max.min( box.max ); + + return this; + + } + + union( box ) { + + this.min.min( box.min ); + this.max.max( box.max ); + + return this; + + } + + translate( offset ) { + + this.min.add( offset ); + this.max.add( offset ); + + return this; + + } + + equals( box ) { + + return box.min.equals( this.min ) && box.max.equals( this.max ); + + } + +} + +Box2.prototype.isBox2 = true; + +const _startP = /*@__PURE__*/ new Vector3(); +const _startEnd = /*@__PURE__*/ new Vector3(); + +class Line3 { + + constructor( start = new Vector3(), end = new Vector3() ) { + + this.start = start; + this.end = end; + + } + + set( start, end ) { + + this.start.copy( start ); + this.end.copy( end ); + + return this; + + } + + copy( line ) { + + this.start.copy( line.start ); + this.end.copy( line.end ); + + return this; + + } + + getCenter( target ) { + + return target.addVectors( this.start, this.end ).multiplyScalar( 0.5 ); + + } + + delta( target ) { + + return target.subVectors( this.end, this.start ); + + } + + distanceSq() { + + return this.start.distanceToSquared( this.end ); + + } + + distance() { + + return this.start.distanceTo( this.end ); + + } + + at( t, target ) { + + return this.delta( target ).multiplyScalar( t ).add( this.start ); + + } + + closestPointToPointParameter( point, clampToLine ) { + + _startP.subVectors( point, this.start ); + _startEnd.subVectors( this.end, this.start ); + + const startEnd2 = _startEnd.dot( _startEnd ); + const startEnd_startP = _startEnd.dot( _startP ); + + let t = startEnd_startP / startEnd2; + + if ( clampToLine ) { + + t = clamp( t, 0, 1 ); + + } + + return t; + + } + + closestPointToPoint( point, clampToLine, target ) { + + const t = this.closestPointToPointParameter( point, clampToLine ); + + return this.delta( target ).multiplyScalar( t ).add( this.start ); + + } + + applyMatrix4( matrix ) { + + this.start.applyMatrix4( matrix ); + this.end.applyMatrix4( matrix ); + + return this; + + } + + equals( line ) { + + return line.start.equals( this.start ) && line.end.equals( this.end ); + + } + + clone() { + + return new this.constructor().copy( this ); + + } + +} + +const _vector$3 = /*@__PURE__*/ new Vector3(); + +class SpotLightHelper extends Object3D { + + constructor( light, color ) { + + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + const geometry = new BufferGeometry(); + + const positions = [ + 0, 0, 0, 0, 0, 1, + 0, 0, 0, 1, 0, 1, + 0, 0, 0, - 1, 0, 1, + 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, - 1, 1 + ]; + + for ( let i = 0, j = 1, l = 32; i < l; i ++, j ++ ) { + + const p1 = ( i / l ) * Math.PI * 2; + const p2 = ( j / l ) * Math.PI * 2; + + positions.push( + Math.cos( p1 ), Math.sin( p1 ), 1, + Math.cos( p2 ), Math.sin( p2 ), 1 + ); + + } + + geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); + + const material = new LineBasicMaterial( { fog: false, toneMapped: false } ); + + this.cone = new LineSegments( geometry, material ); + this.add( this.cone ); + + this.update(); + + } + + dispose() { + + this.cone.geometry.dispose(); + this.cone.material.dispose(); + + } + + update() { + + this.light.updateMatrixWorld(); + + const coneLength = this.light.distance ? this.light.distance : 1000; + const coneWidth = coneLength * Math.tan( this.light.angle ); + + this.cone.scale.set( coneWidth, coneWidth, coneLength ); + + _vector$3.setFromMatrixPosition( this.light.target.matrixWorld ); + + this.cone.lookAt( _vector$3 ); + + if ( this.color !== undefined ) { + + this.cone.material.color.set( this.color ); + + } else { + + this.cone.material.color.copy( this.light.color ); + + } + + } + +} + +const _vector$2 = /*@__PURE__*/ new Vector3(); +const _boneMatrix = /*@__PURE__*/ new Matrix4(); +const _matrixWorldInv = /*@__PURE__*/ new Matrix4(); + + +class SkeletonHelper extends LineSegments { + + constructor( object ) { + + const bones = getBoneList( object ); + + const geometry = new BufferGeometry(); + + const vertices = []; + const colors = []; + + const color1 = new Color( 0, 0, 1 ); + const color2 = new Color( 0, 1, 0 ); + + for ( let i = 0; i < bones.length; i ++ ) { + + const bone = bones[ i ]; + + if ( bone.parent && bone.parent.isBone ) { + + vertices.push( 0, 0, 0 ); + vertices.push( 0, 0, 0 ); + colors.push( color1.r, color1.g, color1.b ); + colors.push( color2.r, color2.g, color2.b ); + + } + + } + + geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + const material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } ); + + super( geometry, material ); + + this.type = 'SkeletonHelper'; + this.isSkeletonHelper = true; + + this.root = object; + this.bones = bones; + + this.matrix = object.matrixWorld; + this.matrixAutoUpdate = false; + + } + + updateMatrixWorld( force ) { + + const bones = this.bones; + + const geometry = this.geometry; + const position = geometry.getAttribute( 'position' ); + + _matrixWorldInv.copy( this.root.matrixWorld ).invert(); + + for ( let i = 0, j = 0; i < bones.length; i ++ ) { + + const bone = bones[ i ]; + + if ( bone.parent && bone.parent.isBone ) { + + _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld ); + _vector$2.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j, _vector$2.x, _vector$2.y, _vector$2.z ); + + _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld ); + _vector$2.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j + 1, _vector$2.x, _vector$2.y, _vector$2.z ); + + j += 2; + + } + + } + + geometry.getAttribute( 'position' ).needsUpdate = true; + + super.updateMatrixWorld( force ); + + } + +} + + +function getBoneList( object ) { + + const boneList = []; + + if ( object && object.isBone ) { + + boneList.push( object ); + + } + + for ( let i = 0; i < object.children.length; i ++ ) { + + boneList.push.apply( boneList, getBoneList( object.children[ i ] ) ); + + } + + return boneList; + +} + +class PointLightHelper extends Mesh { + + constructor( light, sphereSize, color ) { + + const geometry = new SphereGeometry( sphereSize, 4, 2 ); + const material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); + + super( geometry, material ); + + this.light = light; + this.light.updateMatrixWorld(); + + this.color = color; + + this.type = 'PointLightHelper'; + + this.matrix = this.light.matrixWorld; + this.matrixAutoUpdate = false; + + this.update(); + + + /* + // TODO: delete this comment? + const distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 ); + const distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } ); + + this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial ); + this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial ); + + const d = light.distance; + + if ( d === 0.0 ) { + + this.lightDistance.visible = false; + + } else { + + this.lightDistance.scale.set( d, d, d ); + + } + + this.add( this.lightDistance ); + */ + + } + + dispose() { + + this.geometry.dispose(); + this.material.dispose(); + + } + + update() { + + if ( this.color !== undefined ) { + + this.material.color.set( this.color ); + + } else { + + this.material.color.copy( this.light.color ); + + } + + /* + const d = this.light.distance; + + if ( d === 0.0 ) { + + this.lightDistance.visible = false; + + } else { + + this.lightDistance.visible = true; + this.lightDistance.scale.set( d, d, d ); + + } + */ + + } + +} + +const _vector$1 = /*@__PURE__*/ new Vector3(); +const _color1 = /*@__PURE__*/ new Color(); +const _color2 = /*@__PURE__*/ new Color(); + +class HemisphereLightHelper extends Object3D { + + constructor( light, size, color ) { + + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + const geometry = new OctahedronGeometry( size ); + geometry.rotateY( Math.PI * 0.5 ); + + this.material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); + if ( this.color === undefined ) this.material.vertexColors = true; + + const position = geometry.getAttribute( 'position' ); + const colors = new Float32Array( position.count * 3 ); + + geometry.setAttribute( 'color', new BufferAttribute( colors, 3 ) ); + + this.add( new Mesh( geometry, this.material ) ); + + this.update(); + + } + + dispose() { + + this.children[ 0 ].geometry.dispose(); + this.children[ 0 ].material.dispose(); + + } + + update() { + + const mesh = this.children[ 0 ]; + + if ( this.color !== undefined ) { + + this.material.color.set( this.color ); + + } else { + + const colors = mesh.geometry.getAttribute( 'color' ); + + _color1.copy( this.light.color ); + _color2.copy( this.light.groundColor ); + + for ( let i = 0, l = colors.count; i < l; i ++ ) { + + const color = ( i < ( l / 2 ) ) ? _color1 : _color2; + + colors.setXYZ( i, color.r, color.g, color.b ); + + } + + colors.needsUpdate = true; + + } + + mesh.lookAt( _vector$1.setFromMatrixPosition( this.light.matrixWorld ).negate() ); + + } + +} + +class GridHelper extends LineSegments { + + constructor( size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888 ) { + + color1 = new Color( color1 ); + color2 = new Color( color2 ); + + const center = divisions / 2; + const step = size / divisions; + const halfSize = size / 2; + + const vertices = [], colors = []; + + for ( let i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) { + + vertices.push( - halfSize, 0, k, halfSize, 0, k ); + vertices.push( k, 0, - halfSize, k, 0, halfSize ); + + const color = i === center ? color1 : color2; + + color.toArray( colors, j ); j += 3; + color.toArray( colors, j ); j += 3; + color.toArray( colors, j ); j += 3; + color.toArray( colors, j ); j += 3; + + } + + const geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); + + super( geometry, material ); + + this.type = 'GridHelper'; + + } + +} + +class PolarGridHelper extends LineSegments { + + constructor( radius = 10, radials = 16, circles = 8, divisions = 64, color1 = 0x444444, color2 = 0x888888 ) { + + color1 = new Color( color1 ); + color2 = new Color( color2 ); + + const vertices = []; + const colors = []; + + // create the radials + + for ( let i = 0; i <= radials; i ++ ) { + + const v = ( i / radials ) * ( Math.PI * 2 ); + + const x = Math.sin( v ) * radius; + const z = Math.cos( v ) * radius; + + vertices.push( 0, 0, 0 ); + vertices.push( x, 0, z ); + + const color = ( i & 1 ) ? color1 : color2; + + colors.push( color.r, color.g, color.b ); + colors.push( color.r, color.g, color.b ); + + } + + // create the circles + + for ( let i = 0; i <= circles; i ++ ) { + + const color = ( i & 1 ) ? color1 : color2; + + const r = radius - ( radius / circles * i ); + + for ( let j = 0; j < divisions; j ++ ) { + + // first vertex + + let v = ( j / divisions ) * ( Math.PI * 2 ); + + let x = Math.sin( v ) * r; + let z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + // second vertex + + v = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + } + + } + + const geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); + + super( geometry, material ); + + this.type = 'PolarGridHelper'; + + } + +} + +const _v1 = /*@__PURE__*/ new Vector3(); +const _v2 = /*@__PURE__*/ new Vector3(); +const _v3 = /*@__PURE__*/ new Vector3(); + +class DirectionalLightHelper extends Object3D { + + constructor( light, size, color ) { + + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + if ( size === undefined ) size = 1; + + let geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( [ + - size, size, 0, + size, size, 0, + size, - size, 0, + - size, - size, 0, + - size, size, 0 + ], 3 ) ); + + const material = new LineBasicMaterial( { fog: false, toneMapped: false } ); + + this.lightPlane = new Line( geometry, material ); + this.add( this.lightPlane ); + + geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); + + this.targetLine = new Line( geometry, material ); + this.add( this.targetLine ); + + this.update(); + + } + + dispose() { + + this.lightPlane.geometry.dispose(); + this.lightPlane.material.dispose(); + this.targetLine.geometry.dispose(); + this.targetLine.material.dispose(); + + } + + update() { + + _v1.setFromMatrixPosition( this.light.matrixWorld ); + _v2.setFromMatrixPosition( this.light.target.matrixWorld ); + _v3.subVectors( _v2, _v1 ); + + this.lightPlane.lookAt( _v2 ); + + if ( this.color !== undefined ) { + + this.lightPlane.material.color.set( this.color ); + this.targetLine.material.color.set( this.color ); + + } else { + + this.lightPlane.material.color.copy( this.light.color ); + this.targetLine.material.color.copy( this.light.color ); + + } + + this.targetLine.lookAt( _v2 ); + this.targetLine.scale.z = _v3.length(); + + } + +} + +const _vector = /*@__PURE__*/ new Vector3(); +const _camera = /*@__PURE__*/ new Camera(); + +/** + * - shows frustum, line of sight and up of the camera + * - suitable for fast updates + * - based on frustum visualization in lightgl.js shadowmap example + * https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html + */ + +class CameraHelper extends LineSegments { + + constructor( camera ) { + + const geometry = new BufferGeometry(); + const material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } ); + + const vertices = []; + const colors = []; + + const pointMap = {}; + + // colors + + const colorFrustum = new Color( 0xffaa00 ); + const colorCone = new Color( 0xff0000 ); + const colorUp = new Color( 0x00aaff ); + const colorTarget = new Color( 0xffffff ); + const colorCross = new Color( 0x333333 ); + + // near + + addLine( 'n1', 'n2', colorFrustum ); + addLine( 'n2', 'n4', colorFrustum ); + addLine( 'n4', 'n3', colorFrustum ); + addLine( 'n3', 'n1', colorFrustum ); + + // far + + addLine( 'f1', 'f2', colorFrustum ); + addLine( 'f2', 'f4', colorFrustum ); + addLine( 'f4', 'f3', colorFrustum ); + addLine( 'f3', 'f1', colorFrustum ); + + // sides + + addLine( 'n1', 'f1', colorFrustum ); + addLine( 'n2', 'f2', colorFrustum ); + addLine( 'n3', 'f3', colorFrustum ); + addLine( 'n4', 'f4', colorFrustum ); + + // cone + + addLine( 'p', 'n1', colorCone ); + addLine( 'p', 'n2', colorCone ); + addLine( 'p', 'n3', colorCone ); + addLine( 'p', 'n4', colorCone ); + + // up + + addLine( 'u1', 'u2', colorUp ); + addLine( 'u2', 'u3', colorUp ); + addLine( 'u3', 'u1', colorUp ); + + // target + + addLine( 'c', 't', colorTarget ); + addLine( 'p', 'c', colorCross ); + + // cross + + addLine( 'cn1', 'cn2', colorCross ); + addLine( 'cn3', 'cn4', colorCross ); + + addLine( 'cf1', 'cf2', colorCross ); + addLine( 'cf3', 'cf4', colorCross ); + + function addLine( a, b, color ) { + + addPoint( a, color ); + addPoint( b, color ); + + } + + function addPoint( id, color ) { + + vertices.push( 0, 0, 0 ); + colors.push( color.r, color.g, color.b ); + + if ( pointMap[ id ] === undefined ) { + + pointMap[ id ] = []; + + } + + pointMap[ id ].push( ( vertices.length / 3 ) - 1 ); + + } + + geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + super( geometry, material ); + + this.type = 'CameraHelper'; + + this.camera = camera; + if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); + + this.matrix = camera.matrixWorld; + this.matrixAutoUpdate = false; + + this.pointMap = pointMap; + + this.update(); + + } + + update() { + + const geometry = this.geometry; + const pointMap = this.pointMap; + + const w = 1, h = 1; + + // we need just camera projection matrix inverse + // world matrix must be identity + + _camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse ); + + // center / target + + setPoint( 'c', pointMap, geometry, _camera, 0, 0, - 1 ); + setPoint( 't', pointMap, geometry, _camera, 0, 0, 1 ); + + // near + + setPoint( 'n1', pointMap, geometry, _camera, - w, - h, - 1 ); + setPoint( 'n2', pointMap, geometry, _camera, w, - h, - 1 ); + setPoint( 'n3', pointMap, geometry, _camera, - w, h, - 1 ); + setPoint( 'n4', pointMap, geometry, _camera, w, h, - 1 ); + + // far + + setPoint( 'f1', pointMap, geometry, _camera, - w, - h, 1 ); + setPoint( 'f2', pointMap, geometry, _camera, w, - h, 1 ); + setPoint( 'f3', pointMap, geometry, _camera, - w, h, 1 ); + setPoint( 'f4', pointMap, geometry, _camera, w, h, 1 ); + + // up + + setPoint( 'u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, - 1 ); + setPoint( 'u2', pointMap, geometry, _camera, - w * 0.7, h * 1.1, - 1 ); + setPoint( 'u3', pointMap, geometry, _camera, 0, h * 2, - 1 ); + + // cross + + setPoint( 'cf1', pointMap, geometry, _camera, - w, 0, 1 ); + setPoint( 'cf2', pointMap, geometry, _camera, w, 0, 1 ); + setPoint( 'cf3', pointMap, geometry, _camera, 0, - h, 1 ); + setPoint( 'cf4', pointMap, geometry, _camera, 0, h, 1 ); + + setPoint( 'cn1', pointMap, geometry, _camera, - w, 0, - 1 ); + setPoint( 'cn2', pointMap, geometry, _camera, w, 0, - 1 ); + setPoint( 'cn3', pointMap, geometry, _camera, 0, - h, - 1 ); + setPoint( 'cn4', pointMap, geometry, _camera, 0, h, - 1 ); + + geometry.getAttribute( 'position' ).needsUpdate = true; + + } + + dispose() { + + this.geometry.dispose(); + this.material.dispose(); + + } + +} + + +function setPoint( point, pointMap, geometry, camera, x, y, z ) { + + _vector.set( x, y, z ).unproject( camera ); + + const points = pointMap[ point ]; + + if ( points !== undefined ) { + + const position = geometry.getAttribute( 'position' ); + + for ( let i = 0, l = points.length; i < l; i ++ ) { + + position.setXYZ( points[ i ], _vector.x, _vector.y, _vector.z ); + + } + + } + +} + +const _box = /*@__PURE__*/ new Box3(); + +class BoxHelper extends LineSegments { + + constructor( object, color = 0xffff00 ) { + + const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] ); + const positions = new Float32Array( 8 * 3 ); + + const geometry = new BufferGeometry(); + geometry.setIndex( new BufferAttribute( indices, 1 ) ); + geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) ); + + super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.object = object; + this.type = 'BoxHelper'; + + this.matrixAutoUpdate = false; + + this.update(); + + } + + update( object ) { + + if ( object !== undefined ) { + + console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' ); + + } + + if ( this.object !== undefined ) { + + _box.setFromObject( this.object ); + + } + + if ( _box.isEmpty() ) return; + + const min = _box.min; + const max = _box.max; + + /* + 5____4 + 1/___0/| + | 6__|_7 + 2/___3/ + + 0: max.x, max.y, max.z + 1: min.x, max.y, max.z + 2: min.x, min.y, max.z + 3: max.x, min.y, max.z + 4: max.x, max.y, min.z + 5: min.x, max.y, min.z + 6: min.x, min.y, min.z + 7: max.x, min.y, min.z + */ + + const position = this.geometry.attributes.position; + const array = position.array; + + array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z; + array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z; + array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z; + array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z; + array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z; + array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z; + array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z; + array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z; + + position.needsUpdate = true; + + this.geometry.computeBoundingSphere(); + + + } + + setFromObject( object ) { + + this.object = object; + this.update(); + + return this; + + } + + copy( source ) { + + LineSegments.prototype.copy.call( this, source ); + + this.object = source.object; + + return this; + + } + +} + +class Box3Helper extends LineSegments { + + constructor( box, color = 0xffff00 ) { + + const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] ); + + const positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ]; + + const geometry = new BufferGeometry(); + + geometry.setIndex( new BufferAttribute( indices, 1 ) ); + + geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); + + super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.box = box; + + this.type = 'Box3Helper'; + + this.geometry.computeBoundingSphere(); + + } + + updateMatrixWorld( force ) { + + const box = this.box; + + if ( box.isEmpty() ) return; + + box.getCenter( this.position ); + + box.getSize( this.scale ); + + this.scale.multiplyScalar( 0.5 ); + + super.updateMatrixWorld( force ); + + } + +} + +class PlaneHelper extends Line { + + constructor( plane, size = 1, hex = 0xffff00 ) { + + const color = hex; + + const positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ]; + + const geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); + geometry.computeBoundingSphere(); + + super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'PlaneHelper'; + + this.plane = plane; + + this.size = size; + + const positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ]; + + const geometry2 = new BufferGeometry(); + geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); + geometry2.computeBoundingSphere(); + + this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false } ) ) ); + + } + + updateMatrixWorld( force ) { + + let scale = - this.plane.constant; + + if ( Math.abs( scale ) < 1e-8 ) scale = 1e-8; // sign does not matter + + this.scale.set( 0.5 * this.size, 0.5 * this.size, scale ); + + this.children[ 0 ].material.side = ( scale < 0 ) ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here + + this.lookAt( this.plane.normal ); + + super.updateMatrixWorld( force ); + + } + +} + +const _axis = /*@__PURE__*/ new Vector3(); +let _lineGeometry, _coneGeometry; + +class ArrowHelper extends Object3D { + + // dir is assumed to be normalized + + constructor( dir = new Vector3( 0, 0, 1 ), origin = new Vector3( 0, 0, 0 ), length = 1, color = 0xffff00, headLength = length * 0.2, headWidth = headLength * 0.2 ) { + + super(); + + this.type = 'ArrowHelper'; + + if ( _lineGeometry === undefined ) { + + _lineGeometry = new BufferGeometry(); + _lineGeometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) ); + + _coneGeometry = new CylinderGeometry( 0, 0.5, 1, 5, 1 ); + _coneGeometry.translate( 0, - 0.5, 0 ); + + } + + this.position.copy( origin ); + + this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + this.line.matrixAutoUpdate = false; + this.add( this.line ); + + this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color, toneMapped: false } ) ); + this.cone.matrixAutoUpdate = false; + this.add( this.cone ); + + this.setDirection( dir ); + this.setLength( length, headLength, headWidth ); + + } + + setDirection( dir ) { + + // dir is assumed to be normalized + + if ( dir.y > 0.99999 ) { + + this.quaternion.set( 0, 0, 0, 1 ); + + } else if ( dir.y < - 0.99999 ) { + + this.quaternion.set( 1, 0, 0, 0 ); + + } else { + + _axis.set( dir.z, 0, - dir.x ).normalize(); + + const radians = Math.acos( dir.y ); + + this.quaternion.setFromAxisAngle( _axis, radians ); + + } + + } + + setLength( length, headLength = length * 0.2, headWidth = headLength * 0.2 ) { + + this.line.scale.set( 1, Math.max( 0.0001, length - headLength ), 1 ); // see #17458 + this.line.updateMatrix(); + + this.cone.scale.set( headWidth, headLength, headWidth ); + this.cone.position.y = length; + this.cone.updateMatrix(); + + } + + setColor( color ) { + + this.line.material.color.set( color ); + this.cone.material.color.set( color ); + + } + + copy( source ) { + + super.copy( source, false ); + + this.line.copy( source.line ); + this.cone.copy( source.cone ); + + return this; + + } + +} + +class AxesHelper extends LineSegments { + + constructor( size = 1 ) { + + const vertices = [ + 0, 0, 0, size, 0, 0, + 0, 0, 0, 0, size, 0, + 0, 0, 0, 0, 0, size + ]; + + const colors = [ + 1, 0, 0, 1, 0.6, 0, + 0, 1, 0, 0.6, 1, 0, + 0, 0, 1, 0, 0.6, 1 + ]; + + const geometry = new BufferGeometry(); + geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); + + super( geometry, material ); + + this.type = 'AxesHelper'; + + } + + setColors( xAxisColor, yAxisColor, zAxisColor ) { + + const color = new Color(); + const array = this.geometry.attributes.color.array; + + color.set( xAxisColor ); + color.toArray( array, 0 ); + color.toArray( array, 3 ); + + color.set( yAxisColor ); + color.toArray( array, 6 ); + color.toArray( array, 9 ); + + color.set( zAxisColor ); + color.toArray( array, 12 ); + color.toArray( array, 15 ); + + this.geometry.attributes.color.needsUpdate = true; + + return this; + + } + + dispose() { + + this.geometry.dispose(); + this.material.dispose(); + + } + +} + +class ShapePath { + + constructor() { + + this.type = 'ShapePath'; + + this.color = new Color(); + + this.subPaths = []; + this.currentPath = null; + + } + + moveTo( x, y ) { + + this.currentPath = new Path(); + this.subPaths.push( this.currentPath ); + this.currentPath.moveTo( x, y ); + + return this; + + } + + lineTo( x, y ) { + + this.currentPath.lineTo( x, y ); + + return this; + + } + + quadraticCurveTo( aCPx, aCPy, aX, aY ) { + + this.currentPath.quadraticCurveTo( aCPx, aCPy, aX, aY ); + + return this; + + } + + bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) { + + this.currentPath.bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ); + + return this; + + } + + splineThru( pts ) { + + this.currentPath.splineThru( pts ); + + return this; + + } + + toShapes( isCCW, noHoles ) { + + function toShapesNoHoles( inSubpaths ) { + + const shapes = []; + + for ( let i = 0, l = inSubpaths.length; i < l; i ++ ) { + + const tmpPath = inSubpaths[ i ]; + + const tmpShape = new Shape(); + tmpShape.curves = tmpPath.curves; + + shapes.push( tmpShape ); + + } + + return shapes; + + } + + function isPointInsidePolygon( inPt, inPolygon ) { + + const polyLen = inPolygon.length; + + // inPt on polygon contour => immediate success or + // toggling of inside/outside at every single! intersection point of an edge + // with the horizontal line through inPt, left of inPt + // not counting lowerY endpoints of edges and whole edges on that line + let inside = false; + for ( let p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) { + + let edgeLowPt = inPolygon[ p ]; + let edgeHighPt = inPolygon[ q ]; + + let edgeDx = edgeHighPt.x - edgeLowPt.x; + let edgeDy = edgeHighPt.y - edgeLowPt.y; + + if ( Math.abs( edgeDy ) > Number.EPSILON ) { + + // not parallel + if ( edgeDy < 0 ) { + + edgeLowPt = inPolygon[ q ]; edgeDx = - edgeDx; + edgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy; + + } + + if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue; + + if ( inPt.y === edgeLowPt.y ) { + + if ( inPt.x === edgeLowPt.x ) return true; // inPt is on contour ? + // continue; // no intersection or edgeLowPt => doesn't count !!! + + } else { + + const perpEdge = edgeDy * ( inPt.x - edgeLowPt.x ) - edgeDx * ( inPt.y - edgeLowPt.y ); + if ( perpEdge === 0 ) return true; // inPt is on contour ? + if ( perpEdge < 0 ) continue; + inside = ! inside; // true intersection left of inPt + + } + + } else { + + // parallel or collinear + if ( inPt.y !== edgeLowPt.y ) continue; // parallel + // edge lies on the same horizontal line as inPt + if ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) || + ( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) ) return true; // inPt: Point on contour ! + // continue; + + } + + } + + return inside; + + } + + const isClockWise = ShapeUtils.isClockWise; + + const subPaths = this.subPaths; + if ( subPaths.length === 0 ) return []; + + if ( noHoles === true ) return toShapesNoHoles( subPaths ); + + + let solid, tmpPath, tmpShape; + const shapes = []; + + if ( subPaths.length === 1 ) { + + tmpPath = subPaths[ 0 ]; + tmpShape = new Shape(); + tmpShape.curves = tmpPath.curves; + shapes.push( tmpShape ); + return shapes; + + } + + let holesFirst = ! isClockWise( subPaths[ 0 ].getPoints() ); + holesFirst = isCCW ? ! holesFirst : holesFirst; + + // console.log("Holes first", holesFirst); + + const betterShapeHoles = []; + const newShapes = []; + let newShapeHoles = []; + let mainIdx = 0; + let tmpPoints; + + newShapes[ mainIdx ] = undefined; + newShapeHoles[ mainIdx ] = []; + + for ( let i = 0, l = subPaths.length; i < l; i ++ ) { + + tmpPath = subPaths[ i ]; + tmpPoints = tmpPath.getPoints(); + solid = isClockWise( tmpPoints ); + solid = isCCW ? ! solid : solid; + + if ( solid ) { + + if ( ( ! holesFirst ) && ( newShapes[ mainIdx ] ) ) mainIdx ++; + + newShapes[ mainIdx ] = { s: new Shape(), p: tmpPoints }; + newShapes[ mainIdx ].s.curves = tmpPath.curves; + + if ( holesFirst ) mainIdx ++; + newShapeHoles[ mainIdx ] = []; + + //console.log('cw', i); + + } else { + + newShapeHoles[ mainIdx ].push( { h: tmpPath, p: tmpPoints[ 0 ] } ); + + //console.log('ccw', i); + + } + + } + + // only Holes? -> probably all Shapes with wrong orientation + if ( ! newShapes[ 0 ] ) return toShapesNoHoles( subPaths ); + + + if ( newShapes.length > 1 ) { + + let ambiguous = false; + const toChange = []; + + for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { + + betterShapeHoles[ sIdx ] = []; + + } + + for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { + + const sho = newShapeHoles[ sIdx ]; + + for ( let hIdx = 0; hIdx < sho.length; hIdx ++ ) { + + const ho = sho[ hIdx ]; + let hole_unassigned = true; + + for ( let s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) { + + if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) { + + if ( sIdx !== s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } ); + if ( hole_unassigned ) { + + hole_unassigned = false; + betterShapeHoles[ s2Idx ].push( ho ); + + } else { + + ambiguous = true; + + } + + } + + } + + if ( hole_unassigned ) { + + betterShapeHoles[ sIdx ].push( ho ); + + } + + } + + } + // console.log("ambiguous: ", ambiguous); + + if ( toChange.length > 0 ) { + + // console.log("to change: ", toChange); + if ( ! ambiguous ) newShapeHoles = betterShapeHoles; + + } + + } + + let tmpHoles; + + for ( let i = 0, il = newShapes.length; i < il; i ++ ) { + + tmpShape = newShapes[ i ].s; + shapes.push( tmpShape ); + tmpHoles = newShapeHoles[ i ]; + + for ( let j = 0, jl = tmpHoles.length; j < jl; j ++ ) { + + tmpShape.holes.push( tmpHoles[ j ].h ); + + } + + } + + //console.log("shape", shapes); + + return shapes; + + } + +} + +const _floatView = new Float32Array( 1 ); +const _int32View = new Int32Array( _floatView.buffer ); + +class DataUtils { + + // Converts float32 to float16 (stored as uint16 value). + + static toHalfFloat( val ) { + + if ( val > 65504 ) { + + console.warn( 'THREE.DataUtils.toHalfFloat(): value exceeds 65504.' ); + + val = 65504; // maximum representable value in float16 + + } + + // Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410 + + /* This method is faster than the OpenEXR implementation (very often + * used, eg. in Ogre), with the additional benefit of rounding, inspired + * by James Tursa?s half-precision code. */ + + _floatView[ 0 ] = val; + const x = _int32View[ 0 ]; + + let bits = ( x >> 16 ) & 0x8000; /* Get the sign */ + let m = ( x >> 12 ) & 0x07ff; /* Keep one extra bit for rounding */ + const e = ( x >> 23 ) & 0xff; /* Using int is faster here */ + + /* If zero, or denormal, or exponent underflows too much for a denormal + * half, return signed zero. */ + if ( e < 103 ) return bits; + + /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */ + if ( e > 142 ) { + + bits |= 0x7c00; + /* If exponent was 0xff and one mantissa bit was set, it means NaN, + * not Inf, so make sure we set one mantissa bit too. */ + bits |= ( ( e == 255 ) ? 0 : 1 ) && ( x & 0x007fffff ); + return bits; + + } + + /* If exponent underflows but not too much, return a denormal */ + if ( e < 113 ) { + + m |= 0x0800; + /* Extra rounding may overflow and set mantissa to 0 and exponent + * to 1, which is OK. */ + bits |= ( m >> ( 114 - e ) ) + ( ( m >> ( 113 - e ) ) & 1 ); + return bits; + + } + + bits |= ( ( e - 112 ) << 10 ) | ( m >> 1 ); + /* Extra rounding. An overflow will set mantissa to 0 and increment + * the exponent, which is OK. */ + bits += m & 1; + return bits; + + } + +} + +const LineStrip = 0; +const LinePieces = 1; +const NoColors = 0; +const FaceColors = 1; +const VertexColors = 2; + +function MeshFaceMaterial( materials ) { + + console.warn( 'THREE.MeshFaceMaterial has been removed. Use an Array instead.' ); + return materials; + +} + +function MultiMaterial( materials = [] ) { + + console.warn( 'THREE.MultiMaterial has been removed. Use an Array instead.' ); + materials.isMultiMaterial = true; + materials.materials = materials; + materials.clone = function () { + + return materials.slice(); + + }; + + return materials; + +} + +function PointCloud( geometry, material ) { + + console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); + return new Points( geometry, material ); + +} + +function Particle( material ) { + + console.warn( 'THREE.Particle has been renamed to THREE.Sprite.' ); + return new Sprite( material ); + +} + +function ParticleSystem( geometry, material ) { + + console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); + return new Points( geometry, material ); + +} + +function PointCloudMaterial( parameters ) { + + console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); + +} + +function ParticleBasicMaterial( parameters ) { + + console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); + +} + +function ParticleSystemMaterial( parameters ) { + + console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); + +} + +function Vertex( x, y, z ) { + + console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); + return new Vector3( x, y, z ); + +} + +// + +function DynamicBufferAttribute( array, itemSize ) { + + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.' ); + return new BufferAttribute( array, itemSize ).setUsage( DynamicDrawUsage ); + +} + +function Int8Attribute( array, itemSize ) { + + console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' ); + return new Int8BufferAttribute( array, itemSize ); + +} + +function Uint8Attribute( array, itemSize ) { + + console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' ); + return new Uint8BufferAttribute( array, itemSize ); + +} + +function Uint8ClampedAttribute( array, itemSize ) { + + console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' ); + return new Uint8ClampedBufferAttribute( array, itemSize ); + +} + +function Int16Attribute( array, itemSize ) { + + console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' ); + return new Int16BufferAttribute( array, itemSize ); + +} + +function Uint16Attribute( array, itemSize ) { + + console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' ); + return new Uint16BufferAttribute( array, itemSize ); + +} + +function Int32Attribute( array, itemSize ) { + + console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' ); + return new Int32BufferAttribute( array, itemSize ); + +} + +function Uint32Attribute( array, itemSize ) { + + console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' ); + return new Uint32BufferAttribute( array, itemSize ); + +} + +function Float32Attribute( array, itemSize ) { + + console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' ); + return new Float32BufferAttribute( array, itemSize ); + +} + +function Float64Attribute( array, itemSize ) { + + console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' ); + return new Float64BufferAttribute( array, itemSize ); + +} + +// + +Curve.create = function ( construct, getPoint ) { + + console.log( 'THREE.Curve.create() has been deprecated' ); + + construct.prototype = Object.create( Curve.prototype ); + construct.prototype.constructor = construct; + construct.prototype.getPoint = getPoint; + + return construct; + +}; + +// + +Path.prototype.fromPoints = function ( points ) { + + console.warn( 'THREE.Path: .fromPoints() has been renamed to .setFromPoints().' ); + return this.setFromPoints( points ); + +}; + +// + +function AxisHelper( size ) { + + console.warn( 'THREE.AxisHelper has been renamed to THREE.AxesHelper.' ); + return new AxesHelper( size ); + +} + +function BoundingBoxHelper( object, color ) { + + console.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' ); + return new BoxHelper( object, color ); + +} + +function EdgesHelper( object, hex ) { + + console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' ); + return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + +} + +GridHelper.prototype.setColors = function () { + + console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); + +}; + +SkeletonHelper.prototype.update = function () { + + console.error( 'THREE.SkeletonHelper: update() no longer needs to be called.' ); + +}; + +function WireframeHelper( object, hex ) { + + console.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' ); + return new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + +} + +// + +Loader.prototype.extractUrlBase = function ( url ) { + + console.warn( 'THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.' ); + return LoaderUtils.extractUrlBase( url ); + +}; + +Loader.Handlers = { + + add: function ( /* regex, loader */ ) { + + console.error( 'THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.' ); + + }, + + get: function ( /* file */ ) { + + console.error( 'THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.' ); + + } + +}; + +function XHRLoader( manager ) { + + console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' ); + return new FileLoader( manager ); + +} + +function BinaryTextureLoader( manager ) { + + console.warn( 'THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.' ); + return new DataTextureLoader( manager ); + +} + +// + +Box2.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +Box2.prototype.empty = function () { + + console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + +}; + +Box2.prototype.isIntersectionBox = function ( box ) { + + console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' ); + return this.intersectsBox( box ); + +}; + +Box2.prototype.size = function ( optionalTarget ) { + + console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' ); + return this.getSize( optionalTarget ); + +}; + +// + +Box3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +Box3.prototype.empty = function () { + + console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + +}; + +Box3.prototype.isIntersectionBox = function ( box ) { + + console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' ); + return this.intersectsBox( box ); + +}; + +Box3.prototype.isIntersectionSphere = function ( sphere ) { + + console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); + return this.intersectsSphere( sphere ); + +}; + +Box3.prototype.size = function ( optionalTarget ) { + + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); + return this.getSize( optionalTarget ); + +}; + +// + +Sphere.prototype.empty = function () { + + console.warn( 'THREE.Sphere: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + +}; + +// + +Frustum.prototype.setFromMatrix = function ( m ) { + + console.warn( 'THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().' ); + return this.setFromProjectionMatrix( m ); + +}; + +// + +Line3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +// + +Matrix3.prototype.flattenToArrayOffset = function ( array, offset ) { + + console.warn( 'THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); + return this.toArray( array, offset ); + +}; + +Matrix3.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); + return vector.applyMatrix3( this ); + +}; + +Matrix3.prototype.multiplyVector3Array = function ( /* a */ ) { + + console.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' ); + +}; + +Matrix3.prototype.applyToBufferAttribute = function ( attribute ) { + + console.warn( 'THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.' ); + return attribute.applyMatrix3( this ); + +}; + +Matrix3.prototype.applyToVector3Array = function ( /* array, offset, length */ ) { + + console.error( 'THREE.Matrix3: .applyToVector3Array() has been removed.' ); + +}; + +Matrix3.prototype.getInverse = function ( matrix ) { + + console.warn( 'THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.' ); + return this.copy( matrix ).invert(); + +}; + +// + +Matrix4.prototype.extractPosition = function ( m ) { + + console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); + return this.copyPosition( m ); + +}; + +Matrix4.prototype.flattenToArrayOffset = function ( array, offset ) { + + console.warn( 'THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); + return this.toArray( array, offset ); + +}; + +Matrix4.prototype.getPosition = function () { + + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return new Vector3().setFromMatrixColumn( this, 3 ); + +}; + +Matrix4.prototype.setRotationFromQuaternion = function ( q ) { + + console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); + return this.makeRotationFromQuaternion( q ); + +}; + +Matrix4.prototype.multiplyToArray = function () { + + console.warn( 'THREE.Matrix4: .multiplyToArray() has been removed.' ); + +}; + +Matrix4.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.multiplyVector4 = function ( vector ) { + + console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.multiplyVector3Array = function ( /* a */ ) { + + console.error( 'THREE.Matrix4: .multiplyVector3Array() has been removed.' ); + +}; + +Matrix4.prototype.rotateAxis = function ( v ) { + + console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' ); + v.transformDirection( this ); + +}; + +Matrix4.prototype.crossVector = function ( vector ) { + + console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); + return vector.applyMatrix4( this ); + +}; + +Matrix4.prototype.translate = function () { + + console.error( 'THREE.Matrix4: .translate() has been removed.' ); + +}; + +Matrix4.prototype.rotateX = function () { + + console.error( 'THREE.Matrix4: .rotateX() has been removed.' ); + +}; + +Matrix4.prototype.rotateY = function () { + + console.error( 'THREE.Matrix4: .rotateY() has been removed.' ); + +}; + +Matrix4.prototype.rotateZ = function () { + + console.error( 'THREE.Matrix4: .rotateZ() has been removed.' ); + +}; + +Matrix4.prototype.rotateByAxis = function () { + + console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); + +}; + +Matrix4.prototype.applyToBufferAttribute = function ( attribute ) { + + console.warn( 'THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.' ); + return attribute.applyMatrix4( this ); + +}; + +Matrix4.prototype.applyToVector3Array = function ( /* array, offset, length */ ) { + + console.error( 'THREE.Matrix4: .applyToVector3Array() has been removed.' ); + +}; + +Matrix4.prototype.makeFrustum = function ( left, right, bottom, top, near, far ) { + + console.warn( 'THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.' ); + return this.makePerspective( left, right, top, bottom, near, far ); + +}; + +Matrix4.prototype.getInverse = function ( matrix ) { + + console.warn( 'THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.' ); + return this.copy( matrix ).invert(); + +}; + +// + +Plane.prototype.isIntersectionLine = function ( line ) { + + console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); + return this.intersectsLine( line ); + +}; + +// + +Quaternion.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); + return vector.applyQuaternion( this ); + +}; + +Quaternion.prototype.inverse = function ( ) { + + console.warn( 'THREE.Quaternion: .inverse() has been renamed to invert().' ); + return this.invert(); + +}; + +// + +Ray.prototype.isIntersectionBox = function ( box ) { + + console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); + return this.intersectsBox( box ); + +}; + +Ray.prototype.isIntersectionPlane = function ( plane ) { + + console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' ); + return this.intersectsPlane( plane ); + +}; + +Ray.prototype.isIntersectionSphere = function ( sphere ) { + + console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); + return this.intersectsSphere( sphere ); + +}; + +// + +Triangle.prototype.area = function () { + + console.warn( 'THREE.Triangle: .area() has been renamed to .getArea().' ); + return this.getArea(); + +}; + +Triangle.prototype.barycoordFromPoint = function ( point, target ) { + + console.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' ); + return this.getBarycoord( point, target ); + +}; + +Triangle.prototype.midpoint = function ( target ) { + + console.warn( 'THREE.Triangle: .midpoint() has been renamed to .getMidpoint().' ); + return this.getMidpoint( target ); + +}; + +Triangle.prototypenormal = function ( target ) { + + console.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' ); + return this.getNormal( target ); + +}; + +Triangle.prototype.plane = function ( target ) { + + console.warn( 'THREE.Triangle: .plane() has been renamed to .getPlane().' ); + return this.getPlane( target ); + +}; + +Triangle.barycoordFromPoint = function ( point, a, b, c, target ) { + + console.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' ); + return Triangle.getBarycoord( point, a, b, c, target ); + +}; + +Triangle.normal = function ( a, b, c, target ) { + + console.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' ); + return Triangle.getNormal( a, b, c, target ); + +}; + +// + +Shape.prototype.extractAllPoints = function ( divisions ) { + + console.warn( 'THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.' ); + return this.extractPoints( divisions ); + +}; + +Shape.prototype.extrude = function ( options ) { + + console.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' ); + return new ExtrudeGeometry( this, options ); + +}; + +Shape.prototype.makeGeometry = function ( options ) { + + console.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' ); + return new ShapeGeometry( this, options ); + +}; + +// + +Vector2.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector2.prototype.distanceToManhattan = function ( v ) { + + console.warn( 'THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' ); + return this.manhattanDistanceTo( v ); + +}; + +Vector2.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Vector3.prototype.setEulerFromRotationMatrix = function () { + + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + +}; + +Vector3.prototype.setEulerFromQuaternion = function () { + + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + +}; + +Vector3.prototype.getPositionFromMatrix = function ( m ) { + + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); + return this.setFromMatrixPosition( m ); + +}; + +Vector3.prototype.getScaleFromMatrix = function ( m ) { + + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); + return this.setFromMatrixScale( m ); + +}; + +Vector3.prototype.getColumnFromMatrix = function ( index, matrix ) { + + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); + return this.setFromMatrixColumn( matrix, index ); + +}; + +Vector3.prototype.applyProjection = function ( m ) { + + console.warn( 'THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.' ); + return this.applyMatrix4( m ); + +}; + +Vector3.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector3.prototype.distanceToManhattan = function ( v ) { + + console.warn( 'THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' ); + return this.manhattanDistanceTo( v ); + +}; + +Vector3.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Vector4.prototype.fromAttribute = function ( attribute, index, offset ) { + + console.warn( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' ); + return this.fromBufferAttribute( attribute, index, offset ); + +}; + +Vector4.prototype.lengthManhattan = function () { + + console.warn( 'THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().' ); + return this.manhattanLength(); + +}; + +// + +Object3D.prototype.getChildByName = function ( name ) { + + console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); + return this.getObjectByName( name ); + +}; + +Object3D.prototype.renderDepth = function () { + + console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' ); + +}; + +Object3D.prototype.translate = function ( distance, axis ) { + + console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' ); + return this.translateOnAxis( axis, distance ); + +}; + +Object3D.prototype.getWorldRotation = function () { + + console.error( 'THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.' ); + +}; + +Object3D.prototype.applyMatrix = function ( matrix ) { + + console.warn( 'THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + +}; + +Object.defineProperties( Object3D.prototype, { + + eulerOrder: { + get: function () { + + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); + return this.rotation.order; + + }, + set: function ( value ) { + + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); + this.rotation.order = value; + + } + }, + useQuaternion: { + get: function () { + + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + + }, + set: function () { + + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + + } + } + +} ); + +Mesh.prototype.setDrawMode = function () { + + console.error( 'THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + +}; + +Object.defineProperties( Mesh.prototype, { + + drawMode: { + get: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.' ); + return TrianglesDrawMode; + + }, + set: function () { + + console.error( 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' ); + + } + } + +} ); + +SkinnedMesh.prototype.initBones = function () { + + console.error( 'THREE.SkinnedMesh: initBones() has been removed.' ); + +}; + +// + +PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { + + console.warn( 'THREE.PerspectiveCamera.setLens is deprecated. ' + + 'Use .setFocalLength and .filmGauge for a photographic setup.' ); + + if ( filmGauge !== undefined ) this.filmGauge = filmGauge; + this.setFocalLength( focalLength ); + +}; + +// + +Object.defineProperties( Light.prototype, { + onlyShadow: { + set: function () { + + console.warn( 'THREE.Light: .onlyShadow has been removed.' ); + + } + }, + shadowCameraFov: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' ); + this.shadow.camera.fov = value; + + } + }, + shadowCameraLeft: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' ); + this.shadow.camera.left = value; + + } + }, + shadowCameraRight: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' ); + this.shadow.camera.right = value; + + } + }, + shadowCameraTop: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' ); + this.shadow.camera.top = value; + + } + }, + shadowCameraBottom: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' ); + this.shadow.camera.bottom = value; + + } + }, + shadowCameraNear: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' ); + this.shadow.camera.near = value; + + } + }, + shadowCameraFar: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' ); + this.shadow.camera.far = value; + + } + }, + shadowCameraVisible: { + set: function () { + + console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' ); + + } + }, + shadowBias: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' ); + this.shadow.bias = value; + + } + }, + shadowDarkness: { + set: function () { + + console.warn( 'THREE.Light: .shadowDarkness has been removed.' ); + + } + }, + shadowMapWidth: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' ); + this.shadow.mapSize.width = value; + + } + }, + shadowMapHeight: { + set: function ( value ) { + + console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' ); + this.shadow.mapSize.height = value; + + } + } +} ); + +// + +Object.defineProperties( BufferAttribute.prototype, { + + length: { + get: function () { + + console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' ); + return this.array.length; + + } + }, + dynamic: { + get: function () { + + console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' ); + return this.usage === DynamicDrawUsage; + + }, + set: function ( /* value */ ) { + + console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' ); + this.setUsage( DynamicDrawUsage ); + + } + } + +} ); + +BufferAttribute.prototype.setDynamic = function ( value ) { + + console.warn( 'THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.' ); + this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage ); + return this; + +}; + +BufferAttribute.prototype.copyIndicesArray = function ( /* indices */ ) { + + console.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' ); + +}, + +BufferAttribute.prototype.setArray = function ( /* array */ ) { + + console.error( 'THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers' ); + +}; + +// + +BufferGeometry.prototype.addIndex = function ( index ) { + + console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); + this.setIndex( index ); + +}; + +BufferGeometry.prototype.addAttribute = function ( name, attribute ) { + + console.warn( 'THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().' ); + + if ( ! ( attribute && attribute.isBufferAttribute ) && ! ( attribute && attribute.isInterleavedBufferAttribute ) ) { + + console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' ); + + return this.setAttribute( name, new BufferAttribute( arguments[ 1 ], arguments[ 2 ] ) ); + + } + + if ( name === 'index' ) { + + console.warn( 'THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.' ); + this.setIndex( attribute ); + + return this; + + } + + return this.setAttribute( name, attribute ); + +}; + +BufferGeometry.prototype.addDrawCall = function ( start, count, indexOffset ) { + + if ( indexOffset !== undefined ) { + + console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); + + } + + console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); + this.addGroup( start, count ); + +}; + +BufferGeometry.prototype.clearDrawCalls = function () { + + console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' ); + this.clearGroups(); + +}; + +BufferGeometry.prototype.computeOffsets = function () { + + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); + +}; + +BufferGeometry.prototype.removeAttribute = function ( name ) { + + console.warn( 'THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().' ); + + return this.deleteAttribute( name ); + +}; + +BufferGeometry.prototype.applyMatrix = function ( matrix ) { + + console.warn( 'THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + +}; + +Object.defineProperties( BufferGeometry.prototype, { + + drawcalls: { + get: function () { + + console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); + return this.groups; + + } + }, + offsets: { + get: function () { + + console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' ); + return this.groups; + + } + } + +} ); + +InterleavedBuffer.prototype.setDynamic = function ( value ) { + + console.warn( 'THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.' ); + this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage ); + return this; + +}; + +InterleavedBuffer.prototype.setArray = function ( /* array */ ) { + + console.error( 'THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers' ); + +}; + +// + +ExtrudeGeometry.prototype.getArrays = function () { + + console.error( 'THREE.ExtrudeGeometry: .getArrays() has been removed.' ); + +}; + +ExtrudeGeometry.prototype.addShapeList = function () { + + console.error( 'THREE.ExtrudeGeometry: .addShapeList() has been removed.' ); + +}; + +ExtrudeGeometry.prototype.addShape = function () { + + console.error( 'THREE.ExtrudeGeometry: .addShape() has been removed.' ); + +}; + +// + +Scene.prototype.dispose = function () { + + console.error( 'THREE.Scene: .dispose() has been removed.' ); + +}; + +// + +Uniform.prototype.onUpdate = function () { + + console.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' ); + return this; + +}; + +// + +Object.defineProperties( Material.prototype, { + + wrapAround: { + get: function () { + + console.warn( 'THREE.Material: .wrapAround has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.Material: .wrapAround has been removed.' ); + + } + }, + + overdraw: { + get: function () { + + console.warn( 'THREE.Material: .overdraw has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.Material: .overdraw has been removed.' ); + + } + }, + + wrapRGB: { + get: function () { + + console.warn( 'THREE.Material: .wrapRGB has been removed.' ); + return new Color(); + + } + }, + + shading: { + get: function () { + + console.error( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + + }, + set: function ( value ) { + + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( value === FlatShading ); + + } + }, + + stencilMask: { + get: function () { + + console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' ); + return this.stencilFuncMask; + + }, + set: function ( value ) { + + console.warn( 'THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.' ); + this.stencilFuncMask = value; + + } + }, + + vertexTangents: { + get: function () { + + console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' ); + + }, + set: function () { + + console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' ); + + } + }, + +} ); + +Object.defineProperties( ShaderMaterial.prototype, { + + derivatives: { + get: function () { + + console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); + return this.extensions.derivatives; + + }, + set: function ( value ) { + + console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); + this.extensions.derivatives = value; + + } + } + +} ); + +// + +WebGLRenderer.prototype.clearTarget = function ( renderTarget, color, depth, stencil ) { + + console.warn( 'THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.' ); + this.setRenderTarget( renderTarget ); + this.clear( color, depth, stencil ); + +}; + +WebGLRenderer.prototype.animate = function ( callback ) { + + console.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' ); + this.setAnimationLoop( callback ); + +}; + +WebGLRenderer.prototype.getCurrentRenderTarget = function () { + + console.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' ); + return this.getRenderTarget(); + +}; + +WebGLRenderer.prototype.getMaxAnisotropy = function () { + + console.warn( 'THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().' ); + return this.capabilities.getMaxAnisotropy(); + +}; + +WebGLRenderer.prototype.getPrecision = function () { + + console.warn( 'THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.' ); + return this.capabilities.precision; + +}; + +WebGLRenderer.prototype.resetGLState = function () { + + console.warn( 'THREE.WebGLRenderer: .resetGLState() is now .state.reset().' ); + return this.state.reset(); + +}; + +WebGLRenderer.prototype.supportsFloatTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); + return this.extensions.get( 'OES_texture_float' ); + +}; + +WebGLRenderer.prototype.supportsHalfFloatTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' ); + return this.extensions.get( 'OES_texture_half_float' ); + +}; + +WebGLRenderer.prototype.supportsStandardDerivatives = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' ); + return this.extensions.get( 'OES_standard_derivatives' ); + +}; + +WebGLRenderer.prototype.supportsCompressedTextureS3TC = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' ); + return this.extensions.get( 'WEBGL_compressed_texture_s3tc' ); + +}; + +WebGLRenderer.prototype.supportsCompressedTexturePVRTC = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' ); + return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + +}; + +WebGLRenderer.prototype.supportsBlendMinMax = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' ); + return this.extensions.get( 'EXT_blend_minmax' ); + +}; + +WebGLRenderer.prototype.supportsVertexTextures = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' ); + return this.capabilities.vertexTextures; + +}; + +WebGLRenderer.prototype.supportsInstancedArrays = function () { + + console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' ); + return this.extensions.get( 'ANGLE_instanced_arrays' ); + +}; + +WebGLRenderer.prototype.enableScissorTest = function ( boolean ) { + + console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' ); + this.setScissorTest( boolean ); + +}; + +WebGLRenderer.prototype.initMaterial = function () { + + console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' ); + +}; + +WebGLRenderer.prototype.addPrePlugin = function () { + + console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' ); + +}; + +WebGLRenderer.prototype.addPostPlugin = function () { + + console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' ); + +}; + +WebGLRenderer.prototype.updateShadowMap = function () { + + console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' ); + +}; + +WebGLRenderer.prototype.setFaceCulling = function () { + + console.warn( 'THREE.WebGLRenderer: .setFaceCulling() has been removed.' ); + +}; + +WebGLRenderer.prototype.allocTextureUnit = function () { + + console.warn( 'THREE.WebGLRenderer: .allocTextureUnit() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTexture = function () { + + console.warn( 'THREE.WebGLRenderer: .setTexture() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTexture2D = function () { + + console.warn( 'THREE.WebGLRenderer: .setTexture2D() has been removed.' ); + +}; + +WebGLRenderer.prototype.setTextureCube = function () { + + console.warn( 'THREE.WebGLRenderer: .setTextureCube() has been removed.' ); + +}; + +WebGLRenderer.prototype.getActiveMipMapLevel = function () { + + console.warn( 'THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().' ); + return this.getActiveMipmapLevel(); + +}; + +Object.defineProperties( WebGLRenderer.prototype, { + + shadowMapEnabled: { + get: function () { + + return this.shadowMap.enabled; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); + this.shadowMap.enabled = value; + + } + }, + shadowMapType: { + get: function () { + + return this.shadowMap.type; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); + this.shadowMap.type = value; + + } + }, + shadowMapCullFace: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function ( /* value */ ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' ); + + } + }, + context: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.' ); + return this.getContext(); + + } + }, + vr: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .vr has been renamed to .xr' ); + return this.xr; + + } + }, + gammaInput: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.' ); + return false; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.' ); + + } + }, + gammaOutput: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.' ); + return false; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.' ); + this.outputEncoding = ( value === true ) ? sRGBEncoding : LinearEncoding; + + } + }, + toneMappingWhitePoint: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.' ); + return 1.0; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.' ); + + } + }, + gammaFactor: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' ); + return 2; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' ); + + } + } +} ); + +Object.defineProperties( WebGLShadowMap.prototype, { + + cullFace: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function ( /* cullFace */ ) { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' ); + + } + }, + renderReverseSided: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' ); + + } + }, + renderSingleSided: { + get: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' ); + return undefined; + + }, + set: function () { + + console.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' ); + + } + } + +} ); + +function WebGLRenderTargetCube( width, height, options ) { + + console.warn( 'THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).' ); + return new WebGLCubeRenderTarget( width, options ); + +} + +// + +Object.defineProperties( WebGLRenderTarget.prototype, { + + wrapS: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); + return this.texture.wrapS; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); + this.texture.wrapS = value; + + } + }, + wrapT: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); + return this.texture.wrapT; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); + this.texture.wrapT = value; + + } + }, + magFilter: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); + return this.texture.magFilter; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); + this.texture.magFilter = value; + + } + }, + minFilter: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); + return this.texture.minFilter; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); + this.texture.minFilter = value; + + } + }, + anisotropy: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); + return this.texture.anisotropy; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); + this.texture.anisotropy = value; + + } + }, + offset: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); + return this.texture.offset; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); + this.texture.offset = value; + + } + }, + repeat: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); + return this.texture.repeat; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); + this.texture.repeat = value; + + } + }, + format: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); + return this.texture.format; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); + this.texture.format = value; + + } + }, + type: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); + return this.texture.type; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); + this.texture.type = value; + + } + }, + generateMipmaps: { + get: function () { + + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); + return this.texture.generateMipmaps; + + }, + set: function ( value ) { + + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); + this.texture.generateMipmaps = value; + + } + } + +} ); + +// + +Audio.prototype.load = function ( file ) { + + console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' ); + const scope = this; + const audioLoader = new AudioLoader(); + audioLoader.load( file, function ( buffer ) { + + scope.setBuffer( buffer ); + + } ); + return this; + +}; + + +AudioAnalyser.prototype.getData = function () { + + console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); + return this.getFrequencyData(); + +}; + +// + +CubeCamera.prototype.updateCubeMap = function ( renderer, scene ) { + + console.warn( 'THREE.CubeCamera: .updateCubeMap() is now .update().' ); + return this.update( renderer, scene ); + +}; + +CubeCamera.prototype.clear = function ( renderer, color, depth, stencil ) { + + console.warn( 'THREE.CubeCamera: .clear() is now .renderTarget.clear().' ); + return this.renderTarget.clear( renderer, color, depth, stencil ); + +}; + +ImageUtils.crossOrigin = undefined; + +ImageUtils.loadTexture = function ( url, mapping, onLoad, onError ) { + + console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' ); + + const loader = new TextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); + + const texture = loader.load( url, onLoad, undefined, onError ); + + if ( mapping ) texture.mapping = mapping; + + return texture; + +}; + +ImageUtils.loadTextureCube = function ( urls, mapping, onLoad, onError ) { + + console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' ); + + const loader = new CubeTextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); + + const texture = loader.load( urls, onLoad, undefined, onError ); + + if ( mapping ) texture.mapping = mapping; + + return texture; + +}; + +ImageUtils.loadCompressedTexture = function () { + + console.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' ); + +}; + +ImageUtils.loadCompressedTextureCube = function () { + + console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' ); + +}; + +// + +function CanvasRenderer() { + + console.error( 'THREE.CanvasRenderer has been removed' ); + +} + +// + +function JSONLoader() { + + console.error( 'THREE.JSONLoader has been removed.' ); + +} + +// + +const SceneUtils = { + + createMultiMaterialObject: function ( /* geometry, materials */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); + + }, + + detach: function ( /* child, parent, scene */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); + + }, + + attach: function ( /* child, scene, parent */ ) { + + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); + + } + +}; + +// + +function LensFlare() { + + console.error( 'THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js' ); + +} + +// + +function ParametricGeometry() { + + console.error( 'THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js' ); + return new BufferGeometry(); + +} + +function TextGeometry() { + + console.error( 'THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js' ); + return new BufferGeometry(); + +} + +function FontLoader() { + + console.error( 'THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js' ); + +} + +function Font() { + + console.error( 'THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js' ); + +} + +function ImmediateRenderObject() { + + console.error( 'THREE.ImmediateRenderObject has been removed.' ); + +} + +if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: { + revision: REVISION, + } } ) ); + +} + +if ( typeof window !== 'undefined' ) { + + if ( window.__THREE__ ) { + + console.warn( 'WARNING: Multiple instances of Three.js being imported.' ); + + } else { + + window.__THREE__ = REVISION; + + } + +} + +export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxGeometry as BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleGeometry as CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeGeometry as ConeBufferGeometry, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry as CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry as DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry as ExtrudeBufferGeometry, ExtrudeGeometry, FaceColors, FileLoader, FlatShading, Float16BufferAttribute, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronGeometry as IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry as LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils as Math, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry as OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneGeometry as PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry as PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBIntegerFormat, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry as RingBufferGeometry, RingGeometry, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry as ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereGeometry as SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry as TetrahedronBufferGeometry, TetrahedronGeometry, TextGeometry, Texture, TextureLoader, TorusGeometry as TorusBufferGeometry, TorusGeometry, TorusKnotGeometry as TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry as TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGL1Renderer, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, _SRGBAFormat, sRGBEncoding }; diff --git a/games/3dcity/build/uil.module.js b/games/3dcity/build/uil.module.js new file mode 100644 index 0000000..1643cd0 --- /dev/null +++ b/games/3dcity/build/uil.module.js @@ -0,0 +1,8677 @@ +/** + * @license + * Copyright 2010-2021 Uil.js Authors + * SPDX-License-Identifier: MIT + */ +/** + * @author lth / https://github.com/lo-th + */ + +// INTENAL FUNCTION + +const R = { + + ui: [], + + dom:null, + + ID: null, + lock:false, + wlock:false, + current:-1, + + needReZone: true, + isEventsInit: false, + isLeave:false, + + downTime:0, + prevTime:0, + + prevDefault: ['contextmenu', 'wheel'], + pointerEvent: ['pointerdown', 'pointermove', 'pointerup'], + eventOut: ['pointercancel', 'pointerout', 'pointerleave'], + + xmlserializer: null, + tmpTime: null, + tmpImage: null, + + oldCursor:'auto', + + input: null, + parent: null, + firstImput: true, + + hiddenImput:null, + hiddenSizer:null, + hasFocus:false, + startInput:false, + inputRange : [0,0], + cursorId : 0, + str:'', + pos:0, + startX:-1, + moveX:-1, + + debugInput:false, + + isLoop: false, + listens: [], + + e:{ + type:null, + clientX:0, + clientY:0, + keyCode:NaN, + key:null, + delta:0, + }, + + isMobile: false, + + now: null, + + getTime: function() { + return ( self.performance && self.performance.now ) ? self.performance.now.bind( performance ) : Date.now; + }, + + add: function ( o ) { + + R.ui.push( o ); + R.getZone( o ); + + if( !R.isEventsInit ) R.initEvents(); + + }, + + testMobile: function () { + + let n = navigator.userAgent; + if (n.match(/Android/i) || n.match(/webOS/i) || n.match(/iPhone/i) || n.match(/iPad/i) || n.match(/iPod/i) || n.match(/BlackBerry/i) || n.match(/Windows Phone/i)) return true; + else return false; + + }, + + remove: function ( o ) { + + let i = R.ui.indexOf( o ); + + if ( i !== -1 ) { + R.removeListen( o ); + R.ui.splice( i, 1 ); + } + + if( R.ui.length === 0 ){ + R.removeEvents(); + } + + }, + + // ---------------------- + // EVENTS + // ---------------------- + + initEvents: function () { + + if( R.isEventsInit ) return; + + let dom = document.body; + + R.isMobile = R.testMobile(); + R.now = R.getTime(); + + + if(!R.isMobile){ + dom.addEventListener( 'wheel', R, { passive: false } ); + } else { + dom.style.touchAction = 'none'; + } + + + dom.addEventListener( 'pointercancel', R ); + dom.addEventListener( 'pointerleave', R ); + //dom.addEventListener( 'pointerout', R ) + + dom.addEventListener( 'pointermove', R ); + dom.addEventListener( 'pointerdown', R ); + dom.addEventListener( 'pointerup', R ); + + + dom.addEventListener( 'keydown', R, false ); + dom.addEventListener( 'keyup', R, false ); + window.addEventListener( 'resize', R.resize , false ); + + //window.onblur = R.out; + //window.onfocus = R.in; + + + R.isEventsInit = true; + R.dom = dom; + + }, + + removeEvents: function () { + + if( !R.isEventsInit ) return; + + let dom = document.body; + + if(!R.isMobile){ + dom.removeEventListener( 'wheel', R ); + } + + + dom.removeEventListener( 'pointercancel', R ); + dom.removeEventListener( 'pointerleave', R ); + //dom.removeEventListener( 'pointerout', R ); + + dom.removeEventListener( 'pointermove', R ); + dom.removeEventListener( 'pointerdown', R ); + dom.removeEventListener( 'pointerup', R ); + + + dom.removeEventListener( 'keydown', R ); + dom.removeEventListener( 'keyup', R ); + window.removeEventListener( 'resize', R.resize ); + + R.isEventsInit = false; + + }, + + resize: function () { + + R.needReZone = true; + + let i = R.ui.length, u; + + while( i-- ){ + + u = R.ui[i]; + if( u.isGui && !u.isCanvasOnly && u.autoResize ) u.calc(); + + } + + }, + + out: function () { + + console.log('im am out'); + R.clearOldID(); + + }, + + in: function () { + + console.log('im am in'); + // R.clearOldID(); + + }, + + // ---------------------- + // HANDLE EVENTS + // ---------------------- + + fakeUp: function(){ + + this.handleEvent( {type:'pointerup'} ); + + }, + + + handleEvent: function ( event ) { + + //if(!event.type) return; + + if( R.prevDefault.indexOf( event.type ) !== -1 ) event.preventDefault(); + + R.findZone(); + + let e = R.e; + let leave = false; + + if( event.type === 'keydown') R.keydown( event ); + if( event.type === 'keyup') R.keyup( event ); + + if( event.type === 'wheel' ) e.delta = event.deltaY > 0 ? 1 : -1; + else e.delta = 0; + + let ptype = event.pointerType; // mouse, pen, touch + + e.clientX = ( ptype === 'touch' ? event.pageX : event.clientX ) || 0; + e.clientY = ( ptype === 'touch' ? event.pageY : event.clientY ) || 0; + + e.type = event.type; + + if( R.eventOut.indexOf( event.type ) !== -1 ){ + leave = true; + e.type = 'mouseup'; + } + + if( event.type === 'pointerleave'){ R.isLeave = true; } + + if( event.type === 'pointerdown') e.type = 'mousedown'; + if( event.type === 'pointerup') e.type = 'mouseup'; + if( event.type === 'pointermove'){ + if( R.isLeave ){ + // if user resize outside this document + R.isLeave = false; + R.resize(); + } + e.type = 'mousemove'; + } + + // double click test + if( e.type === 'mousedown' ) { + R.downTime = R.now(); + let time = R.downTime - R.prevTime; + + // double click on imput + if( time < 200 ) { R.selectAll(); return false } + + R.prevTime = R.downTime; + } + + // for imput + if( e.type === 'mousedown' ) R.clearInput(); + + // mouse lock + if( e.type === 'mousedown' ) R.lock = true; + if( e.type === 'mouseup' ) R.lock = false; + + //if( R.current !== null && R.current.neverlock ) R.lock = false; + + /*if( e.type === 'mousedown' && event.button === 1){ + R.cursor() + e.preventDefault(); + e.stopPropagation(); + }*/ + + if( R.isMobile && e.type === 'mousedown' ) R.findID( e ); + if( e.type === 'mousemove' && !R.lock ) R.findID( e ); + + if( R.ID !== null ){ + + if( R.ID.isCanvasOnly ) { + + e.clientX = R.ID.mouse.x; + e.clientY = R.ID.mouse.y; + + } + + R.ID.handleEvent( e ); + + } + + if( R.isMobile && e.type === 'mouseup' ) R.clearOldID(); + if( leave ) R.clearOldID(); + + + }, + + // ---------------------- + // ID + // ---------------------- + + findID: function ( e ) { + + let i = R.ui.length, next = -1, u, x, y; + + while( i-- ){ + + u = R.ui[i]; + + if( u.isCanvasOnly ) { + + x = u.mouse.x; + y = u.mouse.y; + + } else { + + x = e.clientX; + y = e.clientY; + + } + + if( R.onZone( u, x, y ) ){ + + next = i; + + if( next !== R.current ){ + R.clearOldID(); + R.current = next; + R.ID = u; + } + break; + } + + } + + if( next === -1 ) R.clearOldID(); + + }, + + clearOldID: function () { + + if( !R.ID ) return; + R.current = -1; + R.ID.reset(); + R.ID = null; + R.cursor(); + + }, + + // ---------------------- + // GUI / GROUP FUNCTION + // ---------------------- + + calcUis: function ( uis, zone, py ) { + + //console.log('calc_uis') + + let i = uis.length, u, px = 0, n = 0, tw; + let height = 0; + let m = 1; + + while( i-- ){ + + u = uis[n]; + n++; + + if( u.isGroup ) u.calcUis(); + + u.zone.w = u.w; + u.zone.h = u.h; + m = u.margin; + + if( !u.autoWidth ){ + + if( px===0 ){ + height += u.h + m; + + } + + u.zone.x = zone.x + px; + u.zone.y = py; + + tw = R.getWidth(u); + if( tw ) u.zone.w = u.w = tw; + // focrce width if content is canvas + else if( u.fw ) u.zone.w = u.w = u.fw; + + + //console.log( u.name, u.zone.w, u.w, zone, tw ) + //console.log( tw ) + px += u.zone.w; + + if( px >= zone.w ) { + py += u.h + m; + px = 0; + } + + } else { + + px = 0; + + u.zone.x = zone.x; + u.zone.y = py; + py += u.h + m; + + height += u.h + m; + + } + + } + + return height + + }, + + + findTarget: function ( uis, e ) { + + let i = uis.length; + + while( i-- ){ + if( R.onZone( uis[i], e.clientX, e.clientY ) ) return i + } + + return -1; + + }, + + // ---------------------- + // ZONE + // ---------------------- + + findZone: function ( force ) { + + if( !R.needReZone && !force ) return; + + var i = R.ui.length, u; + + while( i-- ){ + + u = R.ui[i]; + R.getZone( u ); + if( u.isGui ) u.calcUis(); + + } + + R.needReZone = false; + + }, + + onZone: function ( o, x, y ) { + + if( x === undefined || y === undefined ) return false; + + let z = o.zone; + let mx = x - z.x; + let my = y - z.y; + + let over = ( mx >= 0 ) && ( my >= 0 ) && ( mx <= z.w ) && ( my <= z.h ); + + if( over ) o.local.set( mx, my ); + else o.local.neg(); + + return over; + + }, + + getWidth: function ( o ) { + + + + //return o.getDom().offsetWidth + return o.getDom().clientWidth + + //let r = o.getDom().getBoundingClientRect(); + //return (r.width) + //return Math.floor(r.width) + + }, + + getZone: function ( o ) { + + if( o.isCanvasOnly ) return; + let r = o.getDom().getBoundingClientRect(); + + //if( !r.width ) return + //o.zone = { x:Math.floor(r.left), y:Math.floor(r.top), w:Math.floor(r.width), h:Math.floor(r.height) }; + //o.zone = { x:Math.round(r.left), y:Math.round(r.top), w:Math.round(r.width), h:Math.round(r.height) }; + o.zone = { x:r.left, y:r.top, w:r.width, h:r.height }; + + //console.log(o.name, o.zone) + + }, + + // ---------------------- + // CURSOR + // ---------------------- + + cursor: function ( name ) { + + name = name ? name : 'auto'; + if( name !== R.oldCursor ){ + document.body.style.cursor = name; + R.oldCursor = name; + } + + }, + + // ---------------------- + // CANVAS + // ---------------------- + + toCanvas: function ( o, w, h, force ) { + + if( !R.xmlserializer ) R.xmlserializer = new XMLSerializer(); + + // prevent exesive redraw + + if( force && R.tmpTime !== null ) { clearTimeout(R.tmpTime); R.tmpTime = null; } + + if( R.tmpTime !== null ) return; + + if( R.lock ) R.tmpTime = setTimeout( function(){ R.tmpTime = null; }, 10 ); + + /// + + let isNewSize = false; + if( w !== o.canvas.width || h !== o.canvas.height ) isNewSize = true; + + if( R.tmpImage === null ) R.tmpImage = new Image(); + + let img = R.tmpImage; //new Image(); + + let htmlString = R.xmlserializer.serializeToString( o.content ); + + let svg = ''+ htmlString +''; + + img.onload = function() { + + let ctx = o.canvas.getContext("2d"); + + if( isNewSize ){ + o.canvas.width = w; + o.canvas.height = h; + }else { + ctx.clearRect( 0, 0, w, h ); + } + ctx.drawImage( this, 0, 0 ); + + o.onDraw(); + + }; + + img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg); + //img.src = 'data:image/svg+xml;base64,'+ window.btoa( svg ); + img.crossOrigin = ''; + + + }, + + // ---------------------- + // INPUT + // ---------------------- + + setHidden: function () { + + + if( R.hiddenImput === null ){ + + //let css = R.parent.css.txtselect + 'padding:0; width:auto; height:auto; ' + //let css = R.parent.css.txt + 'padding:0; width:auto; height:auto; text-shadow:none;' + //css += 'left:10px; top:auto; border:none; color:#FFF; background:#000;' + hide; + + R.hiddenImput = document.createElement('input'); + R.hiddenImput.type = 'text'; + //R.hiddenImput.style.cssText = css + 'bottom:30px;' + (R.debugInput ? '' : 'transform:scale(0);'); + + R.hiddenSizer = document.createElement('div'); + //R.hiddenSizer.style.cssText = css + 'bottom:60px;'; + + document.body.appendChild( R.hiddenImput ); + document.body.appendChild( R.hiddenSizer ); + + } + + let hide = R.debugInput ? '' : 'opacity:0; zIndex:0;'; + let css = R.parent.css.txtselect + 'padding:0; width:auto; height:auto; left:10px; top:auto; color:#FFF; background:#000;'+ hide; + R.hiddenImput.style.cssText = css + 'bottom:10px;' + (R.debugInput ? '' : 'transform:scale(0);'); + R.hiddenSizer.style.cssText = css + 'bottom:40px;'; + + R.hiddenImput.style.width = R.input.clientWidth + 'px'; + R.hiddenImput.value = R.str; + R.hiddenSizer.innerHTML = R.str; + + R.hasFocus = true; + + }, + + clearHidden: function ( p ) { + + if( R.hiddenImput === null ) return; + R.hasFocus = false; + + }, + + clickPos: function( x ){ + + let i = R.str.length, l = 0, n = 0; + while( i-- ){ + l += R.textWidth( R.str[n] ); + if( l >= x ) break; + n++; + } + return n; + + }, + + upInput: function ( x, down ) { + + if( R.parent === null ) return false; + + let up = false; + + if( down ){ + + let id = R.clickPos( x ); + + R.moveX = id; + + if( R.startX === -1 ){ + + R.startX = id; + R.cursorId = id; + R.inputRange = [ R.startX, R.startX ]; + + } else { + + let isSelection = R.moveX !== R.startX; + + if( isSelection ){ + if( R.startX > R.moveX ) R.inputRange = [ R.moveX, R.startX ]; + else R.inputRange = [ R.startX, R.moveX ]; + } + } + + up = true; + + } else { + + if( R.startX !== -1 ){ + + R.hasFocus = true; + R.hiddenImput.focus(); + R.hiddenImput.selectionStart = R.inputRange[0]; + R.hiddenImput.selectionEnd = R.inputRange[1]; + R.startX = -1; + + up = true; + + } + + } + + if( up ) R.selectParent(); + + return up; + + }, + + selectAll: function (){ + + if(!R.parent) return + + R.str = R.input.textContent; + R.inputRange = [0, R.str.length ]; + R.hasFocus = true; + R.hiddenImput.focus(); + R.hiddenImput.selectionStart = R.inputRange[0]; + R.hiddenImput.selectionEnd = R.inputRange[1]; + R.cursorId = R.inputRange[1]; + R.selectParent(); + + }, + + selectParent: function (){ + + var c = R.textWidth( R.str.substring( 0, R.cursorId )); + var e = R.textWidth( R.str.substring( 0, R.inputRange[0] )); + var s = R.textWidth( R.str.substring( R.inputRange[0], R.inputRange[1] )); + + R.parent.select( c, e, s, R.hiddenSizer.innerHTML ); + + }, + + textWidth: function ( text ){ + + if( R.hiddenSizer === null ) return 0; + text = text.replace(/ /g, ' '); + R.hiddenSizer.innerHTML = text; + return R.hiddenSizer.clientWidth; + + }, + + + clearInput: function () { + + if( R.parent === null ) return; + if( !R.firstImput ) R.parent.validate( true ); + + R.clearHidden(); + R.parent.unselect(); + + //R.input.style.background = 'none'; + R.input.style.background = R.parent.colors.back; + R.input.style.borderColor = R.parent.colors.border; + //R.input.style.color = R.parent.colors.text; + R.parent.isEdit = false; + + R.input = null; + R.parent = null; + R.str = '', + R.firstImput = true; + + }, + + setInput: function ( Input, parent ) { + + R.clearInput(); + + R.input = Input; + R.parent = parent; + + R.input.style.background = R.parent.colors.backoff; + R.input.style.borderColor = R.parent.colors.select; + //R.input.style.color = R.parent.colors.textSelect; + R.str = R.input.textContent; + + R.setHidden(); + + }, + + keydown: function ( e ) { + + if( R.parent === null ) return; + + let keyCode = e.which; e.shiftKey; + + //console.log( keyCode ) + + R.firstImput = false; + + + if (R.hasFocus) { + // hack to fix touch event bug in iOS Safari + window.focus(); + R.hiddenImput.focus(); + + } + + + R.parent.isEdit = true; + + // e.preventDefault(); + + // add support for Ctrl/Cmd+A selection + //if ( keyCode === 65 && (e.ctrlKey || e.metaKey )) { + //R.selectText(); + //e.preventDefault(); + //return self.render(); + //} + + if( keyCode === 13 ){ //enter + + R.clearInput(); + + //} else if( keyCode === 9 ){ //tab key + + // R.input.textContent = ''; + + } else { + + if( R.input.isNum ){ + if ( ((e.keyCode > 47) && (e.keyCode < 58)) || ((e.keyCode > 95) && (e.keyCode < 106)) || e.keyCode === 190 || e.keyCode === 110 || e.keyCode === 8 || e.keyCode === 109 ){ + R.hiddenImput.readOnly = false; + } else { + R.hiddenImput.readOnly = true; + } + } else { + R.hiddenImput.readOnly = false; + } + + } + + }, + + keyup: function ( e ) { + + if( R.parent === null ) return; + + R.str = R.hiddenImput.value; + + if( R.parent.allEqual ) R.parent.sameStr( R.str );// numeric samùe value + else R.input.textContent = R.str; + + R.cursorId = R.hiddenImput.selectionStart; + R.inputRange = [ R.hiddenImput.selectionStart, R.hiddenImput.selectionEnd ]; + + R.selectParent(); + + //if( R.parent.allway ) + R.parent.validate(); + + }, + + // ---------------------- + // + // LISTENING + // + // ---------------------- + + loop: function () { + + if( R.isLoop ) requestAnimationFrame( R.loop ); + R.update(); + + }, + + update: function () { + + let i = R.listens.length; + while( i-- ) R.listens[i].listening(); + + }, + + removeListen: function ( proto ) { + + let id = R.listens.indexOf( proto ); + if( id !== -1 ) R.listens.splice(id, 1); + if( R.listens.length === 0 ) R.isLoop = false; + + }, + + addListen: function ( proto ) { + + let id = R.listens.indexOf( proto ); + + if( id !== -1 ) return false; + + R.listens.push( proto ); + + if( !R.isLoop ){ + R.isLoop = true; + R.loop(); + } + + return true; + + }, + +}; + +const Roots = R; + +/** + * @author lth / https://github.com/lo-th + */ + +const T = { + + transition: 0.2, + + frag: document.createDocumentFragment(), + + colorRing: null, + joystick_0: null, + joystick_1: null, + circular: null, + knob: null, + pad2d: null, + + svgns: "http://www.w3.org/2000/svg", + links: "http://www.w3.org/1999/xlink", + htmls: "http://www.w3.org/1999/xhtml", + + DOM_SIZE: [ 'height', 'width', 'top', 'left', 'bottom', 'right', 'margin-left', 'margin-right', 'margin-top', 'margin-bottom'], + SVG_TYPE_D: [ 'pattern', 'defs', 'transform', 'stop', 'animate', 'radialGradient', 'linearGradient', 'animateMotion', 'use', 'filter', 'feColorMatrix' ], + SVG_TYPE_G: [ 'svg', 'rect', 'circle', 'path', 'polygon', 'text', 'g', 'line', 'foreignObject' ], + + PI: Math.PI, + TwoPI: Math.PI*2, + pi90: Math.PI * 0.5, + pi60: Math.PI/3, + + torad: Math.PI / 180, + todeg: 180 / Math.PI, + + clamp: function (v, min, max) { + + v = v < min ? min : v; + v = v > max ? max : v; + return v; + + }, + + size: { w: 240, h: 20, p: 30, s: 8 }, + + // ---------------------- + // COLOR + // ---------------------- + + defineColor: function( o, cc = T.colors ) { + + let color = { ...cc }; + + let textChange = ['fontFamily', 'fontWeight', 'fontShadow', 'fontSize' ]; + let changeText = false; + + if( o.font ) o.fontFamily = o.font; + if( o.shadow ) o.fontShadow = o.shadow; + if( o.weight ) o.fontWeight = o.weight; + + if( o.fontColor ) o.text = o.fontColor; + if( o.color ) o.text = o.color; + + if( o.text ){ + color.text = o.text; + if( !o.fontColor && !o.color ){ + color.title = T.ColorLuma( o.text, -0.25 ); + color.titleoff = T.ColorLuma( o.text, -0.5 ); + } + color.textOver = T.ColorLuma( o.text, 0.25 ); + color.textSelect = T.ColorLuma( o.text, 0.5 ); + } + + if( o.button ){ + color.button = o.button; + color.border = T.ColorLuma( o.button, 0.1 ); + color.overoff = T.ColorLuma( o.button, 0.2 ); + } + + if( o.select ){ + color.select = o.select; + color.over = T.ColorLuma( o.select, -0.1 ); + } + + if( o.itemBg ) o.back = o.itemBg; + + if( o.back ){ + color.back = o.back; + color.backoff = T.ColorLuma( o.back, -0.1 ); + } + + if( o.fontSelect ) color.textSelect = o.fontSelect; + if( o.groupBorder ) color.gborder = o.groupBorder; + + if( o.transparent ) o.bg = 'none'; + if( o.bg ) color.background = color.backgroundOver = o.bg; + if( o.bgOver ) color.backgroundOver = o.bgOver; + + for( let m in color ){ + if(o[m]) color[m] = o[m]; + } + + for( let m in o ){ + if( textChange.indexOf(m) !== -1 ) changeText = true; + } + + if( changeText ) T.defineText( color ); + + return color + + }, + + colors: { + + content:'none', + background: 'rgba(50,50,50,0.3)', + backgroundOver: 'rgba(50,50,50,0.4)', + + title : '#CCC', + titleoff : '#BBB', + text : '#DDD', + textOver : '#EEE', + textSelect : '#FFF', + + //inputBg: 'rgba(0,0,0,0.25)', + //itemBg:'rgba(0,0,0,0.25)', + + back:'rgba(0,0,0,0.2)', + backoff:'rgba(0,0,0,0.3)', + //inputOver: 'rgba(0,0,0,0.2)', + + // input and button border + border : '#4c4c4c', + borderSize : 1, + gborder : 'none', + + button : '#3c3c3c', + overoff : '#5c5c5c', + over : '#024699', + select : '#308AFF', + action: '#FF3300', + + + //fontFamily: 'Tahoma', + fontFamily: 'Consolas,monaco,monospace', + fontWeight: 'normal', + fontShadow: '#000', + fontSize:12, + + + radius:4, + hide: 'rgba(0,0,0,0)', + + }, + + // style css + + css : { + + //unselect: '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;', + basic: 'position:absolute; pointer-events:none; box-sizing:border-box; margin:0; padding:0; overflow:hidden; ' + '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;', + button:'display:flex; justify-content:center; align-items:center; text-align:center;', + + /*txt: T.css.basic + 'font-family:'+ T.colors.fontFamily +'; font-size:'+T.colors.fontSize+'px; color:'+T.colors.text+'; padding:2px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;', + txtselect: T.css.txt + 'display:flex; justify-content:left; align-items:center; text-align:left;' +'padding:2px 5px; border:1px dashed ' + T.colors.border + '; background:'+ T.colors.txtselectbg+';', + item: T.css.txt + 'position:relative; background:rgba(0,0,0,0.2); margin-bottom:1px;',*/ + }, + + // svg path + + svgs: { + + group:'M 7 7 L 7 8 8 8 8 7 7 7 M 5 7 L 5 8 6 8 6 7 5 7 M 3 7 L 3 8 4 8 4 7 3 7 M 7 5 L 7 6 8 6 8 5 7 5 M 6 6 L 6 5 5 5 5 6 6 6 M 7 3 L 7 4 8 4 8 3 7 3 M 6 4 L 6 3 5 3 5 4 6 4 M 3 5 L 3 6 4 6 4 5 3 5 M 3 3 L 3 4 4 4 4 3 3 3 Z', + arrow:'M 3 8 L 8 5 3 2 3 8 Z', + arrowDown:'M 5 8 L 8 3 2 3 5 8 Z', + arrowUp:'M 5 2 L 2 7 8 7 5 2 Z', + + solid:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 Z', + body:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 M 5 4 L 4 5 4 10 9 10 10 9 10 4 5 4 Z', + vehicle:'M 13 6 L 11 1 3 1 1 6 1 13 3 13 3 11 11 11 11 13 13 13 13 6 M 2.4 6 L 4 2 10 2 11.6 6 2.4 6 M 12 8 L 12 10 10 10 10 8 12 8 M 4 8 L 4 10 2 10 2 8 4 8 Z', + articulation:'M 13 9 L 12 9 9 2 9 1 5 1 5 2 2 9 1 9 1 13 5 13 5 9 4 9 6 5 8 5 10 9 9 9 9 13 13 13 13 9 Z', + character:'M 13 4 L 12 3 9 4 5 4 2 3 1 4 5 6 5 8 4 13 6 13 7 9 8 13 10 13 9 8 9 6 13 4 M 6 1 L 6 3 8 3 8 1 6 1 Z', + terrain:'M 13 8 L 12 7 Q 9.06 -3.67 5.95 4.85 4.04 3.27 2 7 L 1 8 7 13 13 8 M 3 8 Q 3.78 5.420 5.4 6.6 5.20 7.25 5 8 L 7 8 Q 8.39 -0.16 11 8 L 7 11 3 8 Z', + joint:'M 7.7 7.7 Q 8 7.45 8 7 8 6.6 7.7 6.3 7.45 6 7 6 6.6 6 6.3 6.3 6 6.6 6 7 6 7.45 6.3 7.7 6.6 8 7 8 7.45 8 7.7 7.7 M 3.35 8.65 L 1 11 3 13 5.35 10.65 Q 6.1 11 7 11 8.28 11 9.25 10.25 L 7.8 8.8 Q 7.45 9 7 9 6.15 9 5.55 8.4 5 7.85 5 7 5 6.54 5.15 6.15 L 3.7 4.7 Q 3 5.712 3 7 3 7.9 3.35 8.65 M 10.25 9.25 Q 11 8.28 11 7 11 6.1 10.65 5.35 L 13 3 11 1 8.65 3.35 Q 7.9 3 7 3 5.7 3 4.7 3.7 L 6.15 5.15 Q 6.54 5 7 5 7.85 5 8.4 5.55 9 6.15 9 7 9 7.45 8.8 7.8 L 10.25 9.25 Z', + ray:'M 9 11 L 5 11 5 12 9 12 9 11 M 12 5 L 11 5 11 9 12 9 12 5 M 11.5 10 Q 10.9 10 10.45 10.45 10 10.9 10 11.5 10 12.2 10.45 12.55 10.9 13 11.5 13 12.2 13 12.55 12.55 13 12.2 13 11.5 13 10.9 12.55 10.45 12.2 10 11.5 10 M 9 10 L 10 9 2 1 1 2 9 10 Z', + collision:'M 11 12 L 13 10 10 7 13 4 11 2 7.5 5.5 9 7 7.5 8.5 11 12 M 3 2 L 1 4 4 7 1 10 3 12 8 7 3 2 Z', + map:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z', + material:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z', + texture:'M 13 4 L 13 1 1 1 1 4 5 4 5 13 9 13 9 4 13 4 Z', + object:'M 10 1 L 7 4 4 1 1 1 1 13 4 13 4 5 7 8 10 5 10 13 13 13 13 1 10 1 Z', + none:'M 9 5 L 5 5 5 9 9 9 9 5 Z', + cursor:'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z', + + }, + + + getImput: function(){ + + return Roots.input ? true : false + + }, + + setStyle : function ( data ){ + + for ( var o in data ){ + if( T.colors[o] ) T.colors[o] = data[o]; + } + + T.setText(); + + }, + + // ---------------------- + // custom text + // ---------------------- + + defineText: function( o ){ + + T.setText( o.fontSize, o.text, o.fontFamily, o.fontShadow, o.fontWeight ); + + }, + + setText: function( size, color, font, shadow, weight ){ + + let cc = T.colors; + + if( font === undefined ) font = cc.fontFamily; + if( size === undefined ) size = cc.fontSize; + if( shadow === undefined ) shadow = cc.fontShadow; + if( weight === undefined ) weight = cc.fontWeight; + if( color === undefined ) color = cc.text; + + + let align = 'display:flex; justify-content:left; align-items:center; text-align:left;'; + + T.css.txt = T.css.basic + align + 'font-family:'+ font +'; font-weight:'+weight+'; font-size:'+size+'px; color:'+cc.text+'; padding:0px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;'; + if( shadow !== 'none' ) T.css.txt += ' text-shadow: 1px 1px 1px '+shadow+';'; + + T.css.txtselect = T.css.txt + 'padding:0px 4px; border:1px dashed ' + cc.border + ';'; + //T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; '//display:block; padding:4px 4px;';// + T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; display:block; padding:2px 4px;';// + + }, + + + // note + + //https://developer.mozilla.org/fr/docs/Web/CSS/css_flexible_box_layout/aligning_items_in_a_flex_container + + /*cloneColor: function () { + + let cc = Object.assign({}, T.colors ); + return cc; + + },*/ + + // intern function + + cloneCss: function () { + + //let cc = Object.assign({}, T.css ); + return { ...T.css }; + + }, + + clone: function ( o ) { + + return o.cloneNode( true ); + + }, + + setSvg: function( dom, type, value, id, id2 ){ + + if( id === -1 ) dom.setAttributeNS( null, type, value ); + else if( id2 !== undefined ) dom.childNodes[ id || 0 ].childNodes[ id2 || 0 ].setAttributeNS( null, type, value ); + else dom.childNodes[ id || 0 ].setAttributeNS( null, type, value ); + + }, + + setCss: function( dom, css ){ + + for( let r in css ){ + if( T.DOM_SIZE.indexOf(r) !== -1 ) dom.style[r] = css[r] + 'px'; + else dom.style[r] = css[r]; + } + + }, + + set: function( g, o ){ + + for( let att in o ){ + if( att === 'txt' ) g.textContent = o[ att ]; + if( att === 'link' ) g.setAttributeNS( T.links, 'xlink:href', o[ att ] ); + else g.setAttributeNS( null, att, o[ att ] ); + } + + }, + + get: function( dom, id ){ + + if( id === undefined ) return dom; // root + else if( !isNaN( id ) ) return dom.childNodes[ id ]; // first child + else if( id instanceof Array ){ + if(id.length === 2) return dom.childNodes[ id[0] ].childNodes[ id[1] ]; + if(id.length === 3) return dom.childNodes[ id[0] ].childNodes[ id[1] ].childNodes[ id[2] ]; + } + + }, + + dom : function ( type, css, obj, dom, id ) { + + type = type || 'div'; + + if( T.SVG_TYPE_D.indexOf(type) !== -1 || T.SVG_TYPE_G.indexOf(type) !== -1 ){ // is svg element + + if( type ==='svg' ){ + + dom = document.createElementNS( T.svgns, 'svg' ); + T.set( dom, obj ); + + /* } else if ( type === 'use' ) { + + dom = document.createElementNS( T.svgns, 'use' ); + T.set( dom, obj ); +*/ + } else { + // create new svg if not def + if( dom === undefined ) dom = document.createElementNS( T.svgns, 'svg' ); + T.addAttributes( dom, type, obj, id ); + + } + + } else { // is html element + + if( dom === undefined ) dom = document.createElementNS( T.htmls, type ); + else dom = dom.appendChild( document.createElementNS( T.htmls, type ) ); + + } + + if( css ) dom.style.cssText = css; + + if( id === undefined ) return dom; + else return dom.childNodes[ id || 0 ]; + + }, + + addAttributes : function( dom, type, o, id ){ + + let g = document.createElementNS( T.svgns, type ); + T.set( g, o ); + T.get( dom, id ).appendChild( g ); + if( T.SVG_TYPE_G.indexOf(type) !== -1 ) g.style.pointerEvents = 'none'; + return g; + + }, + + clear : function( dom ){ + + T.purge( dom ); + while (dom.firstChild) { + if ( dom.firstChild.firstChild ) T.clear( dom.firstChild ); + dom.removeChild( dom.firstChild ); + } + + }, + + purge : function ( dom ) { + + let a = dom.attributes, i, n; + if (a) { + i = a.length; + while(i--){ + n = a[i].name; + if (typeof dom[n] === 'function') dom[n] = null; + } + } + a = dom.childNodes; + if (a) { + i = a.length; + while(i--){ + T.purge( dom.childNodes[i] ); + } + } + + }, + + // ---------------------- + // SVG Effects function + // ---------------------- + + addSVGGlowEffect: function () { + + if ( document.getElementById( 'UILGlow') !== null ) return; + + let svgFilter = T.initUILEffects(); + + let filter = T.addAttributes( svgFilter, 'filter', { id: 'UILGlow', x: '-20%', y: '-20%', width: '140%', height: '140%' } ); + T.addAttributes( filter, 'feGaussianBlur', { in: 'SourceGraphic', stdDeviation: '3', result: 'uilBlur' } ); + let feMerge = T.addAttributes( filter, 'feMerge', { } ); + + for( let i = 0; i <= 3; i++ ) { + + T.addAttributes( feMerge, 'feMergeNode', { in: 'uilBlur' } ); + + } + + T.addAttributes( feMerge, 'feMergeNode', { in: 'SourceGraphic' } ); + + }, + + initUILEffects: function () { + + let svgFilter = document.getElementById( 'UILSVGEffects'); + + if ( svgFilter === null ) { + + svgFilter = T.dom( 'svg', undefined , { id: 'UILSVGEffects', width: '0', height: '0' } ); + document.body.appendChild( svgFilter ); + + } + + return svgFilter; + + }, + + // ---------------------- + // Color function + // ---------------------- + + ColorLuma : function ( hex, l ) { + + if( hex === 'n' ) hex = '#000'; + + // validate hex string + hex = String(hex).replace(/[^0-9a-f]/gi, ''); + if (hex.length < 6) { + hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; + } + l = l || 0; + + // convert to decimal and change luminosity + let rgb = "#", c, i; + for (i = 0; i < 3; i++) { + c = parseInt(hex.substr(i*2,2), 16); + c = Math.round(Math.min(Math.max(0, c + (c * l)), 255)).toString(16); + rgb += ("00"+c).substr(c.length); + } + + return rgb; + + }, + + findDeepInver: function ( c ) { + + return (c[0] * 0.3 + c[1] * .59 + c[2] * .11) <= 0.6; + + }, + + lerpColor: function( c1, c2, factor ) { + let newColor = {}; + for ( let i = 0; i < 3; i++ ) { + newColor[i] = c1[ i ] + ( c2[ i ] - c1[ i ] ) * factor; + } + return newColor; + }, + + hexToHtml: function ( v ) { + v = v === undefined ? 0x000000 : v; + return "#" + ("000000" + v.toString(16)).substr(-6); + + }, + + htmlToHex: function ( v ) { + + return v.toUpperCase().replace("#", "0x"); + + }, + + u255: function (c, i) { + + return parseInt(c.substring(i, i + 2), 16) / 255; + + }, + + u16: function ( c, i ) { + + return parseInt(c.substring(i, i + 1), 16) / 15; + + }, + + unpack: function( c ){ + + if (c.length == 7) return [ T.u255(c, 1), T.u255(c, 3), T.u255(c, 5) ]; + else if (c.length == 4) return [ T.u16(c,1), T.u16(c,2), T.u16(c,3) ]; + + }, + + p255: function ( c ) { + let h = Math.round( ( c * 255 ) ).toString( 16 ); + if ( h.length < 2 ) h = '0' + h; + return h; + }, + + pack: function ( c ) { + + return '#' + T.p255( c[ 0 ] ) + T.p255( c[ 1 ] ) + T.p255( c[ 2 ] ); + + }, + + htmlRgb: function( c ){ + + return 'rgb(' + Math.round(c[0] * 255) + ','+ Math.round(c[1] * 255) + ','+ Math.round(c[2] * 255) + ')'; + + }, + + pad: function( n ){ + if(n.length == 1)n = '0' + n; + return n; + }, + + rgbToHex : function( c ){ + + let r = Math.round(c[0] * 255).toString(16); + let g = Math.round(c[1] * 255).toString(16); + let b = Math.round(c[2] * 255).toString(16); + return '#' + T.pad(r) + T.pad(g) + T.pad(b); + + // return '#' + ( '000000' + ( ( c[0] * 255 ) << 16 ^ ( c[1] * 255 ) << 8 ^ ( c[2] * 255 ) << 0 ).toString( 16 ) ).slice( - 6 ); + + }, + + hueToRgb: function( p, q, t ){ + + if ( t < 0 ) t += 1; + if ( t > 1 ) t -= 1; + if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t; + if ( t < 1 / 2 ) return q; + if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t ); + return p; + + }, + + rgbToHsl: function ( c ) { + + let r = c[0], g = c[1], b = c[2], min = Math.min(r, g, b), max = Math.max(r, g, b), delta = max - min, h = 0, s = 0, l = (min + max) / 2; + if (l > 0 && l < 1) s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); + if (delta > 0) { + if (max == r && max != g) h += (g - b) / delta; + if (max == g && max != b) h += (2 + (b - r) / delta); + if (max == b && max != r) h += (4 + (r - g) / delta); + h /= 6; + } + return [ h, s, l ]; + + }, + + hslToRgb: function ( c ) { + + let p, q, h = c[0], s = c[1], l = c[2]; + + if ( s === 0 ) return [ l, l, l ]; + else { + q = l <= 0.5 ? l * (s + 1) : l + s - ( l * s ); + p = l * 2 - q; + return [ T.hueToRgb(p, q, h + 0.33333), T.hueToRgb(p, q, h), T.hueToRgb(p, q, h - 0.33333) ]; + } + + }, + + // ---------------------- + // SVG MODEL + // ---------------------- + + makeGradiant: function ( type, settings, parent, colors ) { + + T.dom( type, null, settings, parent, 0 ); + + let n = parent.childNodes[0].childNodes.length - 1, c; + + for( let i = 0; i < colors.length; i++ ){ + + c = colors[i]; + //T.dom( 'stop', null, { offset:c[0]+'%', style:'stop-color:'+c[1]+'; stop-opacity:'+c[2]+';' }, parent, [0,n] ); + T.dom( 'stop', null, { offset:c[0]+'%', 'stop-color':c[1], 'stop-opacity':c[2] }, parent, [0,n] ); + + } + + }, + + /*makeGraph: function () { + + let w = 128; + let radius = 34; + let svg = T.dom( 'svg', T.css.basic , { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'butt' }, svg );//0 + //T.dom( 'rect', '', { x:10, y:10, width:108, height:108, stroke:'rgba(0,0,0,0.3)', 'stroke-width':2 , fill:'none'}, svg );//1 + //T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0 + + //T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.3)', 'stroke-width':7 , fill:'none'}, svg );//2 + //T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3 + T.graph = svg; + + },*/ + + makePad: function ( model ) { + + let ww = 256; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+ww+' '+ww, width:ww, height:ww, preserveAspectRatio:'none' } ); + let w = 200; + let d = (ww-w)*0.5, m = 20; + Tools.dom( 'rect', '', { x: d, y: d, width: w, height: w, fill:T.colors.back }, svg ); // 0 + Tools.dom( 'rect', '', { x: d+m*0.5, y: d+m*0.5, width: w - m , height: w - m, fill:T.colors.button }, svg ); // 1 + // Pointer + Tools.dom( 'line', '', { x1: d+(m*0.5), y1: ww *0.5, x2: d+(w-m*0.5), y2: ww * 0.5, stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 2 + Tools.dom( 'line', '', { x1: ww * 0.5, x2: ww * 0.5, y1: d+(m*0.5), y2: d+(w-m*0.5), stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 3 + Tools.dom( 'circle', '', { cx: ww * 0.5, cy: ww * 0.5, r:5, stroke: T.colors.text, 'stroke-width': 5, fill:'none' }, svg ); // 4 + T.pad2d = svg; + + }, + + makeKnob: function ( model ) { + + let w = 128; + let radius = 34; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0 + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'round' }, svg );//1 + T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.1)', 'stroke-width':7 , fill:'none'}, svg );//2 + T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3 + T.knob = svg; + + }, + + makeCircular: function ( model ) { + + let w = 128; + let radius = 40; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'circle', '', { cx:64, cy:64, r:radius, stroke:'rgba(0,0,0,0.1)', 'stroke-width':10, fill:'none' }, svg );//0 + T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':7, fill:'none', 'stroke-linecap':'butt' }, svg );//1 + T.circular = svg; + + }, + + makeJoystick: function ( model ) { + + //+' background:#f00;' + + let w = 128, ccc; + let radius = Math.floor((w-30)*0.5); + let innerRadius = Math.floor(radius*0.6); + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'defs', null, {}, svg ); + T.dom( 'g', null, {}, svg ); + + if( model === 0 ){ + + + + // gradian background + ccc = [ [40, 'rgb(0,0,0)', 0.3], [80, 'rgb(0,0,0)', 0], [90, 'rgb(50,50,50)', 0.4], [100, 'rgb(50,50,50)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'grad', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // gradian shadow + ccc = [ [60, 'rgb(0,0,0)', 0.5], [100, 'rgb(0,0,0)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'gradS', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // gradian stick + let cc0 = ['rgb(40,40,40)', 'rgb(48,48,48)', 'rgb(30,30,30)']; + let cc1 = ['rgb(1,90,197)', 'rgb(3,95,207)', 'rgb(0,65,167)']; + + ccc = [ [30, cc0[0], 1], [60, cc0[1], 1], [80, cc0[1], 1], [100, cc0[2], 1] ]; + T.makeGradiant( 'radialGradient', { id:'gradIn', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + ccc = [ [30, cc1[0], 1], [60, cc1[1], 1], [80, cc1[1], 1], [100, cc1[2], 1] ]; + T.makeGradiant( 'radialGradient', { id:'gradIn2', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + // graph + + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'url(#grad)' }, svg );//2 + T.dom( 'circle', '', { cx:64+5, cy:64+10, r:innerRadius+10, fill:'url(#gradS)' }, svg );//3 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'url(#gradIn)' }, svg );//4 + + T.joystick_0 = svg; + + } else { + // gradian shadow + ccc = [ [69, 'rgb(0,0,0)', 0],[70, 'rgb(0,0,0)', 0.3], [100, 'rgb(0,0,0)', 0] ]; + T.makeGradiant( 'radialGradient', { id:'gradX', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc ); + + T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'none', stroke:'rgba(100,100,100,0.25)', 'stroke-width':'4' }, svg );//2 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius+14, fill:'url(#gradX)' }, svg );//3 + T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'none', stroke:'rgb(100,100,100)', 'stroke-width':'4' }, svg );//4 + + T.joystick_1 = svg; + } + + + + }, + + makeColorRing: function () { + + let w = 256; + let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } ); + T.dom( 'defs', null, {}, svg ); + T.dom( 'g', null, {}, svg ); + + let s = 30;//stroke + let r =( w-s )*0.5; + let mid = w*0.5; + let n = 24, nudge = 8 / r / n * Math.PI, a1 = 0; + let am, tan, d2, a2, ar, i, j, path, ccc; + let color = []; + + for ( i = 0; i <= n; ++i) { + + d2 = i / n; + a2 = d2 * T.TwoPI; + am = (a1 + a2) * 0.5; + tan = 1 / Math.cos((a2 - a1) * 0.5); + + ar = [ + Math.sin(a1), -Math.cos(a1), + Math.sin(am) * tan, -Math.cos(am) * tan, + Math.sin(a2), -Math.cos(a2) + ]; + + color[1] = T.rgbToHex( T.hslToRgb([d2, 1, 0.5]) ); + + if (i > 0) { + + j = 6; + while(j--){ + ar[j] = ((ar[j]*r)+mid).toFixed(2); + } + + path = ' M' + ar[0] + ' ' + ar[1] + ' Q' + ar[2] + ' ' + ar[3] + ' ' + ar[4] + ' ' + ar[5]; + + ccc = [ [0,color[0],1], [100,color[1],1] ]; + T.makeGradiant( 'linearGradient', { id:'G'+i, x1:ar[0], y1:ar[1], x2:ar[4], y2:ar[5], gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + T.dom( 'path', '', { d:path, 'stroke-width':s, stroke:'url(#G'+i+')', 'stroke-linecap':"butt" }, svg, 1 ); + + } + a1 = a2 - nudge; + color[0] = color[1]; + } + + let tw = 84.90; + + // black / white + ccc = [ [0, '#FFFFFF', 1], [50, '#FFFFFF', 0], [50, '#000000', 0], [100, '#000000', 1] ]; + T.makeGradiant( 'linearGradient', { id:'GL0', x1:0, y1:mid-tw, x2:0, y2:mid+tw, gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + ccc = [ [0, '#7f7f7f', 1], [50, '#7f7f7f', 0.5], [100, '#7f7f7f', 0] ]; + T.makeGradiant( 'linearGradient', { id:'GL1', x1:mid-49.05, y1:0, x2:mid+98, y2:0, gradientUnits:"userSpaceOnUse" }, svg, ccc ); + + T.dom( 'g', null, { 'transform-origin': '128px 128px', 'transform':'rotate(0)' }, svg );//2 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'red' }, svg, 2 );// 2,0 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL1)','stroke-width':1, stroke:'url(#GL1)' }, svg, 2 );//2,1 + T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL0)','stroke-width':1, stroke:'url(#GL0)' }, svg, 2 );//2,2 + T.dom( 'path', '', { d:'M 255.75 136.5 Q 256 132.3 256 128 256 123.7 255.75 119.5 L 241 128 255.75 136.5 Z', fill:'none','stroke-width':2, stroke:'#000' }, svg, 2 );//2,3 + //T.dom( 'circle', '', { cx:128+113, cy:128, r:6, 'stroke-width':3, stroke:'#000', fill:'none' }, svg, 2 );//2.3 + + T.dom( 'circle', '', { cx:128, cy:128, r:6, 'stroke-width':2, stroke:'#000', fill:'none' }, svg );//3 + + T.colorRing = svg; + + }, + + icon: function ( type, color, w ){ + + w = w || 40; + //color = color || '#DEDEDE'; + let viewBox = '0 0 256 256'; + //let viewBox = '0 0 '+ w +' '+ w; + let t = [""]; + switch(type){ + case 'logo': + t[1]=""; + break; + case 'donate': + t[1]=""; + break; + case 'neo': + t[1]=""; + break; + case 'github': + t[1]=""; + break; + case 'save': + t[1]=""; + break; + } + t[2] = ""; + return t.join("\n"); + + }, + + logoFill_d:` + M 171 150.75 L 171 33.25 155.5 33.25 155.5 150.75 Q 155.5 162.2 147.45 170.2 139.45 178.25 128 178.25 116.6 178.25 108.55 170.2 100.5 162.2 100.5 150.75 + L 100.5 33.25 85 33.25 85 150.75 Q 85 168.65 97.55 181.15 110.15 193.75 128 193.75 145.9 193.75 158.4 181.15 171 168.65 171 150.75 + M 200 33.25 L 184 33.25 184 150.8 Q 184 174.1 167.6 190.4 151.3 206.8 128 206.8 104.75 206.8 88.3 190.4 72 174.1 72 150.8 L 72 33.25 56 33.25 56 150.75 + Q 56 180.55 77.05 201.6 98.2 222.75 128 222.75 157.8 222.75 178.9 201.6 200 180.55 200 150.75 L 200 33.25 Z + `, + + logo_github:` + M 180.5 70 Q 186.3 82.4 181.55 96.55 196.5 111.5 189.7 140.65 183.65 168.35 146 172.7 152.5 178.7 152.55 185.9 L 152.55 218.15 Q 152.84 224.56 159.15 223.3 + 159.21 223.3 159.25 223.3 181.14 216.25 198.7 198.7 228 169.4 228 128 228 86.6 198.7 57.3 169.4 28 128 28 86.6 28 57.3 57.3 28 86.6 28 128 28 169.4 57.3 198.7 74.85 + 216.25 96.75 223.3 96.78 223.3 96.8 223.3 103.16 224.54 103.45 218.15 L 103.45 200 Q 82.97 203.1 75.1 196.35 69.85 191.65 68.4 185.45 64.27 177.055 59.4 174.15 49.20 + 166.87 60.8 167.8 69.85 169.61 75.7 180 81.13 188.09 90 188.55 98.18 188.86 103.45 185.9 103.49 178.67 110 172.7 72.33 168.33 66.3 140.65 59.48 111.49 74.45 96.55 69.7 + 82.41 75.5 70 84.87 68.74 103.15 80 115.125 76.635 128 76.85 140.85 76.65 152.85 80 171.1 68.75 180.5 70 Z + `, + + logo_neo:` + M 219 52 L 206 52 206 166 Q 206 183.4 193.75 195.65 181.4 208 164 208 146.6 208 134.35 195.65 122 183.4 122 166 L 122 90 Q 122 77.6 113.15 68.85 104.4 60 92 60 79.55 + 60 70.75 68.85 62 77.6 62 90 L 62 204 75 204 75 90 Q 75 83 79.95 78 84.95 73 92 73 99 73 104 78 109 83 109 90 L 109 166 Q 109 188.8 125.15 204.85 141.2 221 164 221 + 186.75 221 202.95 204.85 219 188.8 219 166 L 219 52 M 194 52 L 181 52 181 166 Q 181 173 176.05 178 171.05 183 164 183 157 183 152 178 147 173 147 166 L 147 90 Q 147 + 67.2 130.85 51.15 114.8 35 92 35 69.25 35 53.05 51.15 37 67.2 37 90 L 37 204 50 204 50 90 Q 50 72.6 62.25 60.35 74.6 48 92 48 109.4 48 121.65 60.35 134 72.6 134 90 L + 134 166 Q 134 178.4 142.85 187.15 151.6 196 164 196 176.45 196 185.25 187.15 194 178.4 194 166 L 194 52 Z + `, + + logo_donate:` + M 171.3 80.3 Q 179.5 62.15 171.3 45.8 164.1 32.5 141.35 30.1 L 94.35 30.1 Q 89.35 30.4 88.3 35.15 L 70.5 148.05 Q 70.2 152.5 73.7 152.6 L 100.95 152.6 107 111.6 Q 108.75 + 106.55 112.6 106.45 130.45 108.05 145.3 103.9 163.35 98.75 171.3 80.3 M 179.8 71.5 Q 178.6 79.75 174.9 87.85 168.45 102.9 151.9 109.15 140.65 113.95 117.55 113 113.15 + 112.75 111 117.45 L 102.7 169.95 Q 102.45 173.8 105.5 173.85 L 128.95 173.85 Q 132.2 174.2 133.35 169.65 L 138.3 139.95 Q 139.75 135.6 143.1 135.5 146.6 135.75 150.6 135.65 + 154.55 135.5 157.35 135.1 160.15 134.7 166.75 132.35 181.35 127.4 187.9 111.2 194.25 95.75 189.5 81.95 186.75 74.85 179.8 71.5 M 103.5 209.9 Q 103.5 202.85 99.7 198.85 95.95 + 194.75 89.4 194.75 82.8 194.75 79.05 198.85 75.3 202.9 75.3 209.9 75.3 216.85 79.05 220.95 82.8 225.05 89.4 225.05 95.95 225.05 99.7 221 103.5 216.95 103.5 209.9 M 95.45 205.5 + Q 95.95 207.3 95.95 209.9 95.95 212.65 95.45 214.35 94.95 216 94 217.3 93.1 218.45 91.9 219 90.7 219.55 89.4 219.55 88.15 219.55 86.95 219.05 85.75 218.55 84.8 217.3 83.9 216.15 + 83.4 214.35 82.85 212.6 82.85 209.9 82.85 207.3 83.4 205.45 83.95 203.55 84.85 202.45 85.9 201.2 86.95 200.75 88.05 200.25 89.4 200.25 90.7 200.25 91.85 200.8 93.05 201.3 94 202.5 + 94.9 203.65 95.45 205.5 M 153.3 195.35 L 145.3 195.35 135.5 224.45 142.8 224.45 144.6 218.5 153.75 218.5 155.6 224.45 163.1 224.45 153.3 195.35 M 152.15 213.25 L 146.25 213.25 + 149.2 203.65 152.15 213.25 M 116.75 195.35 L 107.8 195.35 107.8 224.45 114.5 224.45 114.5 204.2 125.7 224.45 132.75 224.45 132.75 195.35 126.05 195.35 126.05 212.05 116.75 195.35 M + 66.5 197.65 Q 64.15 196.15 61.45 195.75 58.8 195.35 55.75 195.35 L 46.7 195.35 46.7 224.45 55.8 224.45 Q 58.8 224.45 61.5 224.05 64.15 223.6 66.4 222.15 69.15 220.45 70.9 217.2 + 72.7 214 72.7 209.95 72.7 205.7 71 202.6 69.35 199.5 66.5 197.65 M 64.2 205 Q 65.2 207 65.2 209.9 65.2 212.75 64.25 214.75 63.3 216.75 61.5 217.85 60 218.85 58.3 218.9 56.6 219 + 54.15 219 L 54 219 54 200.8 54.15 200.8 Q 56.4 200.8 58.05 200.9 59.7 200.95 61.15 201.75 63.2 202.95 64.2 205 M 210.2 195.35 L 190.5 195.35 190.5 224.45 210.2 224.45 210.2 218.9 + 197.75 218.9 197.75 211.55 209.2 211.55 209.2 206 197.75 206 197.75 200.9 210.2 200.9 210.2 195.35 M 187.5 195.35 L 163 195.35 163 200.9 171.6 200.9 171.6 224.45 178.9 224.45 178.9 + 200.9 187.5 200.9 187.5 195.35 Z + `, + +}; + +T.setText(); + +const Tools = T; + +///https://wicg.github.io/file-system-access/#api-filesystemfilehandle-getfile + + +class Files { + + //----------------------------- + // FILE TYPE + //----------------------------- + + static autoTypes( type ) { + + let t = []; + + switch( type ){ + case 'json': + t = [ { accept: { 'image/svg+xml': '.svg'} }, ]; + break; + case 'text': + t = [ { description: 'Text Files', accept: { 'text/plain': ['.txt', '.text'], 'text/html': ['.html', '.htm'] } }, ]; + break; + case 'json': + t = [ { description: 'JSON Files', accept: { 'text/plain': ['.json'] } }, ]; + break; + case 'image': + t = [ { description: 'Images', accept: { 'image/*': ['.png', '.gif', '.jpeg', '.jpg'] } }, ]; + break; + + } + + return t + + } + + + //----------------------------- + // LOAD + //----------------------------- + + static async load( o = {} ) { + + if (typeof window.showOpenFilePicker !== 'function') { + window.showOpenFilePicker = this.showOpenFilePickerPolyfill; + } + + try { + + let type = o.type || ''; + + const options = { + excludeAcceptAllOption: type ? true : false, + multiple: false, + //startIn:'./assets' + }; + + options.types = this.autoTypes( type ); + + // create a new handle + const handle = await window.showOpenFilePicker( options ); + const file = await handle[0].getFile(); + //let content = await file.text() + + if( !file ) return null + + let fname = file.name; + let ftype = fname.substring( fname.lastIndexOf('.')+1, fname.length ); + + const dataUrl = [ 'png', 'jpg', 'jpeg', 'mp4', 'webm', 'ogg', 'mp3' ]; + const dataBuf = [ 'sea', 'z', 'hex', 'bvh', 'BVH', 'glb', 'gltf' ]; + const reader = new FileReader(); + + if( dataUrl.indexOf( ftype ) !== -1 ) reader.readAsDataURL( file ); + else if( dataBuf.indexOf( ftype ) !== -1 ) reader.readAsArrayBuffer( file ); + else reader.readAsText( file ); + + reader.onload = function(e) { + + let content = e.target.result; + + if( type === 'image' ){ + var img = new Image; + img.onload = function() { + if( o.callback ) o.callback( img, fname ); + }; + img.src = content; + } else { + if( o.callback ) o.callback( content, fname ); + } + + }; + + } catch(e) { + + console.log(e); + + } + + } + + static showOpenFilePickerPolyfill( options ) { + return new Promise((resolve) => { + const input = document.createElement("input"); + input.type = "file"; + input.multiple = options.multiple; + input.accept = options.types + .map((type) => type.accept) + .flatMap((inst) => Object.keys(inst).flatMap((key) => inst[key])) + .join(","); + + input.addEventListener("change", () => { + resolve( + [...input.files].map((file) => { + return { + getFile: async () => + new Promise((resolve) => { + resolve(file); + }), + }; + }) + ); + }); + + input.click(); + }) + } + + + //----------------------------- + // SAVE + //----------------------------- + + static async save( o = {} ) { + + this.usePoly = false; + + if (typeof window.showSaveFilePicker !== 'function') { + window.showSaveFilePicker = this.showSaveFilePickerPolyfill; + this.usePoly = true; + } + + try { + + let type = o.type || ''; + + const options = { + suggestedName: o.name || 'hello', + data: o.data || '' + }; + + + options.types = this.autoTypes( type ); + options.finalType = Object.keys(options.types[0].accept )[0]; + options.suggestedName += options.types[0].accept[options.finalType][0]; + + + // create a new handle + const handle = await window.showSaveFilePicker( options ); + + if( this.usePoly ) return + + // create a FileSystemWritableFileStream to write to + const file = await handle.createWritable(); + + let blob = new Blob([ options.data ], { type: option.finalType }); + + // write our file + await file.write(blob); + + // close the file and write the contents to disk. + await file.close(); + + } catch(e) { + + console.log(e); + + } + + } + + static showSaveFilePickerPolyfill( options ) { + return new Promise((resolve) => { + const a = document.createElement("a"); + a.download = options.suggestedName || "my-file.txt"; + let blob = new Blob([ options.data ], { type:options.finalType }); + a.href = URL.createObjectURL( blob ); + + a.addEventListener("click", () => { + resolve( + setTimeout( () => URL.revokeObjectURL(a.href), 1000 ) + ); + }); + a.click(); + }) + } + + + //----------------------------- + // FOLDER not possible in poly + //----------------------------- + + static async getFolder() { + + try { + + const handle = await window.showDirectoryPicker(); + const files = []; + for await (const entry of handle.values()) { + const file = await entry.getFile(); + files.push(file); + } + + console.log(files); + return files; + + } catch(e) { + + console.log(e); + + } + + } + + + + + + + + + + +} + +class V2 { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + set ( x, y ) { + + this.x = x; + this.y = y; + return this; + + } + + divide ( v ) { + + this.x /= v.x; + this.y /= v.y; + return this; + + } + + multiply ( v ) { + + this.x *= v.x; + this.y *= v.y; + return this; + + } + + multiplyScalar ( scalar ) { + + this.x *= scalar; + this.y *= scalar; + return this; + + } + + divideScalar ( scalar ) { + + return this.multiplyScalar( 1 / scalar ); + + } + + length () { + + return Math.sqrt( this.x * this.x + this.y * this.y ); + + } + + angle () { + + // computes the angle in radians with respect to the positive x-axis + + var angle = Math.atan2( this.y, this.x ); + + if ( angle < 0 ) angle += 2 * Math.PI; + + return angle; + + } + + addScalar ( s ) { + + this.x += s; + this.y += s; + return this; + + } + + negate () { + + this.x *= -1; + this.y *= -1; + return this; + + } + + neg () { + + this.x = -1; + this.y = -1; + return this; + + } + + isZero () { + + return ( this.x === 0 && this.y === 0 ); + + } + + copy ( v ) { + + this.x = v.x; + this.y = v.y; + + return this; + + } + + equals ( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) ); + + } + + nearEquals ( v, n ) { + + return ( ( v.x.toFixed(n) === this.x.toFixed(n) ) && ( v.y.toFixed(n) === this.y.toFixed(n) ) ); + + } + + lerp ( v, alpha ) { + + if( v === null ){ + this.x -= this.x * alpha; + this.y -= this.y * alpha; + } else { + this.x += ( v.x - this.x ) * alpha; + this.y += ( v.y - this.y ) * alpha; + } + + return this; + + } + +} + +/** + * @author lth / https://github.com/lo-th + */ + +class Proto { + + constructor( o = {} ) { + + + + // disable mouse controle + this.lock = o.lock || false; + + // for button + this.neverlock = false; + + // only simple space + this.isSpace = o.isSpace || false; + + // if is on gui or group + this.main = o.main || null; + this.isUI = o.isUI || false; + this.group = o.group || null; + + this.isListen = false; + + this.isSelectable = o.selectable !== undefined ? o.selectable : false; + this.unselectable = o.unselect !== undefined ? o.unselect : this.isSelectable; + + this.ontop = o.ontop ? o.ontop : false; // 'beforebegin' 'afterbegin' 'beforeend' 'afterend' + + this.css = this.main ? this.main.css : Tools.css; + + this.colors = Tools.defineColor( o, this.main ? ( this.group ? this.group.colors : this.main.colors ) : Tools.colors ); + + this.svgs = Tools.svgs; + + this.zone = { x:0, y:0, w:0, h:0 }; + this.local = new V2().neg(); + + this.isCanvasOnly = false; + this.isSelect = false; + + // percent of title + this.p = o.p !== undefined ? o.p : Tools.size.p; + + this.w = this.isUI ? this.main.size.w : Tools.size.w; + if( o.w !== undefined ) this.w = o.w; + + this.h = this.isUI ? this.main.size.h : Tools.size.h; + if( o.h !== undefined ) this.h = o.h; + if( !this.isSpace ) this.h = this.h < 11 ? 11 : this.h; + else this.lock = true; + + + // decale for canvas only + this.fw = o.fw || 0; + + this.autoWidth = o.auto || true;// auto width or flex + this.isOpen = false;// open statu + + // radius for toolbox + this.radius = o.radius || this.colors.radius; + + this.transition = o.transition || Tools.transition; + + // only for number + this.isNumber = false; + this.noNeg = o.noNeg || false; + this.allEqual = o.allEqual || false; + + // only most simple + this.mono = false; + + // stop listening for edit slide text + this.isEdit = false; + + // no title + this.simple = o.simple || false; + if( this.simple ) this.sa = 0; + + + // define obj size + this.setSize( this.w ); + + // title size + if( o.sa !== undefined ) this.sa = o.sa; + if( o.sb !== undefined ) this.sb = o.sb; + if( this.simple ) this.sb = this.w - this.sa; + + // last number size for slide + this.sc = o.sc === undefined ? 47 : o.sc; + + // for listening object + this.objectLink = null; + this.isSend = false; + this.val = null; + + this.txt = o.name || ''; + this.name = o.rename || this.txt; + this.target = o.target || null; + + // callback + this.callback = o.callback === undefined ? null : o.callback; + this.endCallback = null; + this.openCallback = o.openCallback === undefined ? null : o.openCallback; + this.closeCallback = o.closeCallback === undefined ? null : o.closeCallback; + + // if no callback take one from group or gui + if( this.callback === null && this.isUI && this.main.callback !== null ){ + this.callback = this.group ? this.group.callback : this.main.callback; + } + + // elements + this.c = []; + + // style + this.s = []; + + + this.useFlex = this.isUI ? this.main.useFlex : false; + let flexible = this.useFlex ? 'display:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;'; + + this.c[0] = Tools.dom( 'div', this.css.basic + flexible + 'position:relative; height:20px;'); + + + this.s[0] = this.c[0].style; + + // bottom margin + this.margin = o.margin || 1; + if( this.isUI && this.margin ){ + this.s[0].boxSizing = 'content-box'; + //this.s[0].marginBottom = this.margin + 'px'; + if( this.margin*0.5===Math.floor(this.margin*0.5) ){ + this.s[0].borderTop = (this.margin*0.5) + 'px solid transparent'; + this.s[0].borderBottom = (this.margin*0.5) + 'px solid transparent'; + } else { + this.s[0].borderBottom = this.margin + 'px solid transparent'; + } + + } + + // with title + if( !this.simple ){ + this.c[1] = Tools.dom( 'div', this.css.txt ); + this.s[1] = this.c[1].style; + this.c[1].textContent = this.name; + this.s[1].color = this.lock ? this.colors.titleoff : this.colors.title; + } + + if( o.pos ){ + this.s[0].position = 'absolute'; + for(let p in o.pos){ + this.s[0][p] = o.pos[p]; + } + this.mono = true; + } + + + + + if( o.css ) this.s[0].cssText = o.css; + + + } + + // ---------------------- + // make the node + // ---------------------- + + init() { + + this.zone.h = this.h; + this.zone.w = this.w; + + let s = this.s; // style cache + let c = this.c; // div cach + + s[0].height = this.h + 'px'; + + if( this.isUI ) s[0].background = this.colors.background; + + if(!this.autoWidth && this.useFlex ){ + s[0].flex = '1 0 auto'; + s[0].minWidth = this.minw+'px'; + s[0].textAlign = 'center'; + } else { + if( this.isUI ) s[0].width = '100%'; + } + + //if( this.autoHeight ) s[0].transition = 'height 0.01s ease-out'; + if( c[1] !== undefined && this.autoWidth ){ + s[1] = c[1].style; + s[1].height = (this.h-4) + 'px'; + s[1].lineHeight = (this.h-8) + 'px'; + } + + let frag = Tools.frag; + + for( let i = 1, lng = c.length; i !== lng; i++ ){ + if( c[i] !== undefined ) { + frag.appendChild( c[i] ); + s[i] = c[i].style; + } + } + + let pp = this.target !== null ? this.target : ( this.isUI ? this.main.inner : document.body ); + + if( this.ontop ) pp.insertAdjacentElement( 'afterbegin', c[0] ); + else pp.appendChild( c[0] ); + + c[0].appendChild( frag ); + + this.rSize(); + + // ! solo proto + if( !this.isUI ){ + + this.c[0].style.pointerEvents = 'auto'; + Roots.add( this ); + + } + + + if( this.baseH && this.transition && this.isUI ){ + this.c[0].style.transition = 'height '+this.transition+'s ease-out'; + } + + } + + // from Tools + + dom( type, css, obj, dom, id ) { + + return Tools.dom( type, css, obj, dom, id ); + + } + + setSvg( dom, type, value, id, id2 ) { + + Tools.setSvg( dom, type, value, id, id2 ); + + } + + setCss( dom, css ) { + + Tools.setCss( dom, css ); + + } + + clamp( value, min, max ) { + + return Tools.clamp( value, min, max ); + + } + + getColorRing() { + + if( !Tools.colorRing ) Tools.makeColorRing(); + return Tools.clone( Tools.colorRing ); + + } + + getJoystick( model ) { + + if( !Tools[ 'joystick_'+ model ] ) Tools.makeJoystick( model ); + return Tools.clone( Tools[ 'joystick_'+ model ] ) + + } + + getCircular( model ) { + + if( !Tools.circular ) Tools.makeCircular( model ); + return Tools.clone( Tools.circular ) + + } + + getKnob( model ) { + + if( !Tools.knob ) Tools.makeKnob( model ); + return Tools.clone( Tools.knob ) + + } + + getPad2d( model ) { + + if( !Tools.pad2d ) Tools.makePad( model ); + return Tools.clone( Tools.pad2d ) + + } + + // from Roots + + cursor( name ) { + + Roots.cursor( name ); + + } + + + + ///////// + + update() {} + + reset() {} + + ///////// + + getDom() { + + return this.c[0] + + } + + uiout() { + + if( this.lock ) return; + + if(this.s) this.s[0].background = this.colors.background; + + } + + uiover() { + + if( this.lock ) return; + + if(this.s) this.s[0].background = this.colors.backgroundOver; + + } + + rename( s ) { + + if( this.c[1] !== undefined) this.c[1].textContent = s; + + } + + listen() { + + this.isListen = Roots.addListen( this ); + return this; + + } + + listening() { + + if( this.objectLink === null ) return; + if( this.isSend ) return; + if( this.isEdit ) return; + + this.setValue( this.objectLink[ this.val ] ); + + } + + setValue( v ) { + + if( this.isNumber ) this.value = this.numValue( v ); + //else if( v instanceof Array && v.length === 1 ) v = v[0]; + else this.value = v; + this.update(); + + } + + // ---------------------- + // update every change + // ---------------------- + + onChange( f ) { + + if( this.isSpace ) return + this.callback = f || null; + return this + + } + + // ---------------------- + // update only on end + // ---------------------- + + onFinishChange( f ) { + + if( this.isSpace ) return; + this.callback = null; + this.endCallback = f; + return this + + } + + // ---------------------- + // event on open close + // ---------------------- + + onOpen( f ) { + + this.openCallback = f; + return this + + } + + onClose( f ) { + + this.closeCallback = f; + return this + + } + + // ---------------------- + // send back value + // ---------------------- + + send( v ) { + + v = v || this.value; + if( v instanceof Array && v.length === 1 ) v = v[0]; + + this.isSend = true; + if( this.objectLink !== null ) this.objectLink[ this.val ] = v; + if( this.callback ) this.callback( v, this.val ); + this.isSend = false; + + } + + sendEnd( v ) { + + v = v || this.value; + if( v instanceof Array && v.length === 1 ) v = v[0]; + + if( this.endCallback ) this.endCallback( v ); + if( this.objectLink !== null ) this.objectLink[ this.val ] = v; + + } + + // ---------------------- + // clear node + // ---------------------- + + dispose(){ + + if( this.isListen ) Roots.removeListen( this ); + + Tools.clear( this.c[0] ); + + if( this.target !== null ){ + + if( this.group !== null ) this.group.clearOne( this ); + else this.target.removeChild( this.c[0] ); + + } else { + + if( this.isUI ) this.main.clearOne( this ); + else document.body.removeChild( this.c[0] ); + + } + + if( !this.isUI ) Roots.remove( this ); + + this.c = null; + this.s = null; + this.callback = null; + this.target = null; + this.isListen = false; + + } + + clear() { + + } + + // ---------------------- + // change size + // ---------------------- + + getWidth() { + + let nw = Roots.getWidth( this ); + if(nw) this.w = nw; + + } + + setSize( sx ) { + + if( !this.autoWidth ) return; + + this.w = sx; + + if( this.simple ){ + this.sb = this.w - this.sa; + } else { + let pp = this.w * ( this.p / 100 ); + this.sa = Math.floor( pp + 10 ); + this.sb = Math.floor( this.w - pp - 20 ); + } + + } + + rSize() { + + if( !this.autoWidth ) return; + + if( !this.isUI ) this.s[0].width = this.w + 'px'; + if( !this.simple ) this.s[1].width = this.sa + 'px'; + + } + + // ---------------------- + // for numeric value + // ---------------------- + + setTypeNumber( o ) { + + this.isNumber = true; + + this.value = 0; + if( o.value !== undefined ){ + if( typeof o.value === 'string' ) this.value = o.value * 1; + else this.value = o.value; + } + + this.min = o.min === undefined ? -Infinity : o.min; + this.max = o.max === undefined ? Infinity : o.max; + this.precision = o.precision === undefined ? 2 : o.precision; + + let s; + + switch(this.precision){ + case 0: s = 1; break; + case 1: s = 0.1; break; + case 2: s = 0.01; break; + case 3: s = 0.001; break; + case 4: s = 0.0001; break; + case 5: s = 0.00001; break; + } + + this.step = o.step === undefined ? s : o.step; + this.range = this.max - this.min; + this.value = this.numValue( this.value ); + + } + + numValue( n ) { + + if( this.noNeg ) n = Math.abs( n ); + return Math.min( this.max, Math.max( this.min, n ) ).toFixed( this.precision ) * 1; + + } + + + // ---------------------- + // EVENTS DEFAULT + // ---------------------- + + handleEvent( e ) { + + if( this.lock ) return + + if( this.neverlock ) Roots.lock = false; + + if( !this[e.type] ) return console.error(e.type, 'this type of event no existe !') + + return this[e.type](e) + + } + + wheel( e ) { return false; } + mousedown( e ) { return false; } + mousemove( e ) { return false; } + mouseup( e ) { return false; } + keydown( e ) { return false; } + keyup( e ) { return false; } + + + // ---------------------- + // object referency + // ---------------------- + + setReferency( obj, val ) { + + this.objectLink = obj; + this.val = val; + + } + + display( v = false ) { + this.s[0].visibility = v ? 'visible' : 'hidden'; + } + + // ---------------------- + // resize height + // ---------------------- + + open () { + + if( this.isOpen ) return; + this.isOpen = true; + if( this.openCallback ) this.openCallback(); + + } + + close () { + + if( !this.isOpen ) return + this.isOpen = false; + if( this.closeCallback ) this.closeCallback(); + + } + + needZone() { + + Roots.needReZone = true; + + } + + rezone() { + + Roots.needReZone = true; + + } + + // ---------------------- + // INPUT + // ---------------------- + + select() { + + } + + unselect() { + + } + + setInput( Input ) { + + Roots.setInput( Input, this ); + + } + + upInput( x, down ) { + + return Roots.upInput( x, down ); + + } + + // ---------------------- + // special item + // ---------------------- + + selected( b ){ + + this.isSelect = b || false; + + } + +} + +class Bool extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || false; + this.model = o.mode !== undefined ? o.mode : 0; + + this.onName = o.rename || this.txt; + if( o.onName ) o.onname = o.onName; + if( o.onname ) this.onName = o.onname; + + this.inh = o.inh || Math.floor( this.h*0.8 ); + this.inw = o.inw || 36; + + let cc = this.colors; + + if( this.model === 0 ){ + let t = Math.floor(this.h*0.5)-((this.inh-2)*0.5); + this.c[2] = this.dom( 'div', this.css.basic + 'background:'+ cc.inputBg +'; height:'+(this.inh-2)+'px; width:'+this.inw+'px; top:'+t+'px; border-radius:10px; border:2px solid '+ cc.back ); + this.c[3] = this.dom( 'div', this.css.basic + 'height:'+(this.inh-6)+'px; width:16px; top:'+(t+2)+'px; border-radius:10px; background:'+ cc.button+';' ); + } else { + this.p = 0; + if( this.c[1] !== undefined ) this.c[1].textContent = ''; + this.c[2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; background:'+cc.button+'; height:'+(this.h-2)+'px; border:1px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + } + + this.stat = -1; + + this.init(); + this.update(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousedown ( e ) { + + this.value = !this.value; + this.update( true ); + return this.mousemove( e ) + + } + + mousemove ( e ) { + + this.cursor('pointer'); + return this.mode( true ) + + } + + reset () { + + this.cursor(); + return this.mode() + + } + + // ---------------------- + // MODE + // ---------------------- + + mode ( over ) { + + let change = false; + let cc = this.colors, s, s2, n, v = this.value; + + if( over ) n = v ? 4 : 3; + else n = v ? 2 : 1; + + if( this.stat !== n ){ + + this.stat = n; + + if( this.model !== 0 ){ + + s = this.s[2]; + + switch( n ){ + + case 1: s.color = cc.text; s.background = cc.button; break; + case 2: s.color = cc.textSelect; s.background = cc.select; break; + case 3: s.color = cc.textOver; s.background = cc.overoff; break; + case 4: s.color = cc.textOver; s.background = cc.over; break; + + } + + this.c[2].innerHTML = v ? this.onName : this.name; + + } else { + + s = this.s[2]; + s2 = this.s[3]; + + switch( n ){ + + case 1: s.background = s.borderColor = cc.back; s2.background = cc.button; break; + case 2: s.background = s.borderColor = cc.select; s2.background = cc.button; break; + case 3: s.background = s.borderColor = cc.back; s2.background = cc.overoff; break; + case 4: s.background = s.borderColor = cc.select; s2.background = cc.over; break; + + } + + this.s[3].marginLeft = v ? '17px' : '2px'; + this.c[1].textContent = v ? this.onName : this.name; + + } + + change = true; + + } + + return change + + } + + // ---------------------- + + update ( up ) { + + this.mode(); + if( up ) this.send(); + + } + + rSize () { + + super.rSize(); + + let s = this.s; + let w = (this.w - 10 ) - this.inw; + if( this.model === 0 ){ + s[2].left = w + 'px'; + s[3].left = w + 'px'; + } else { + s[2].left = this.sa + 'px'; + s[2].width = (this.w- 20) + 'px'; + } + + } + +} + +class Button extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || ''; + + this.values = o.value || this.txt; + if( o.values ) this.values = o.values; + + + + this.onName = o.onName || null; + + this.on = false; + + // force button width + this.bw = o.forceWidth || 0; + if(o.bw) this.bw = o.bw; + this.space = o.space || 3; + + if( typeof this.values === 'string' ) this.values = [ this.values ]; + + this.isDown = false; + this.neverlock = true; + this.res = 0; + + this.lng = this.values.length; + this.tmp = []; + this.stat = []; + + let sel, cc = this.colors; + + for( let i = 0; i < this.lng; i++ ){ + + sel = false; + if( this.values[i] === this.value && this.isSelectable ) sel = true; + + this.c[i+2] = this.dom( 'div', this.css.txt + this.css.button + 'top:1px; height:'+(this.h-2)+'px; border:'+cc.borderSize+'px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[i+2].style.background = sel ? cc.select : cc.button; + this.c[i+2].style.color = sel ? cc.textSelect : cc.text; + this.c[i+2].innerHTML = this.values[i]; + this.stat[i] = sel ? 3:1; + + } + + if( !o.value && !o.values ){ + if( this.c[1] !== undefined ) { + this.c[1].textContent = ''; + this.txt = ''; + } + } + if( !this.txt ) this.p = 0; + + this.init(); + + } + + onOff() { + + this.on = !this.on; + this.label( this.on ? this.onName : this.txt ); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return -1 + + let i = this.lng; + let t = this.tmp; + + while( i-- ){ + if( l.x>t[i][0] && l.x 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.text; + this.setSvg( this.c[3], 'stroke', color, 1 ); + + break; + case 1: // down + + this.s[2].color = cc.textOver; + this.setSvg( this.c[3], 'stroke', cc.backoff, 0); + color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.textOver; + this.setSvg( this.c[3], 'stroke', color, 1 ); + + break; + } + + this.cmode = mode; + return true; + + } + + reset () { + + this.isDown = false; + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'circular'; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.sendEnd(); + return this.mode(0); + + } + + mousedown ( e ) { + + this.isDown = true; + this.old = this.value; + this.oldr = null; + this.mousemove( e ); + return this.mode(1); + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + //console.log('over') + + let off = this.offset; + off.x = (this.w*0.5) - ( e.clientX - this.zone.x ); + off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + + this.r = off.angle() - this.pi90; + this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi); + + if( this.oldr !== null ){ + + let dif = this.r - this.oldr; + this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r; + + if( dif > 6 ) this.r = 0; + if( dif < -6 ) this.r = this.twoPi; + + } + + let steps = 1 / this.twoPi; + let value = this.r * steps; + + let n = ( ( this.range * value ) + this.min ) - this.old; + + if(n >= this.step || n <= this.step){ + n = ~~ ( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + this.oldr = this.r; + } + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'circular' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue( v ); + this.old = v; + this.update( true ); + + return true; + + } + return false; + + } + + // ---------------------- + + makePath () { + + let r = 40; + let d = 24; + let a = this.percent * this.twoPi - 0.001; + let x2 = (r + r * Math.sin(a)) + d; + let y2 = (r - r * Math.cos(a)) + d; + let big = a > Math.PI ? 1 : 0; + return "M " + (r+d) + "," + d + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2; + + } + + update ( up ) { + + this.c[2].textContent = this.value; + this.percent = ( this.value - this.min ) / this.range; + + this.setSvg( this.c[3], 'd', this.makePath(), 1 ); + + if ( this.model > 0 ) { + + let cc = this.colors; + let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ); + this.setSvg( this.c[3], 'stroke', color, 1 ); + + } + + if( up ) this.send(); + + } + +} + +class Color extends Proto { + + constructor( o = {} ) { + + super( o ); + + //this.autoHeight = true; + + this.ctype = o.ctype || 'hex'; + + this.wfixe = 256; + + this.cw = this.sb > 256 ? 256 : this.sb; + if(o.cw != undefined ) this.cw = o.cw; + + // color up or down + this.side = o.side || 'down'; + this.up = this.side === 'down' ? 0 : 1; + + this.baseH = this.h; + + this.offset = new V2(); + this.decal = new V2(); + this.pp = new V2(); + + this.c[2] = this.dom( 'div', this.css.txt + 'height:'+(this.h-4)+'px;' + 'border-radius:'+this.radius+'px; line-height:'+(this.h-8)+'px;' ); + this.s[2] = this.c[2].style; + + this.s[2].textShadow = 'none'; + + if( this.up ){ + this.s[2].top = 'auto'; + this.s[2].bottom = '2px'; + } + + //this.c[0].style.textAlign = 'center'; + //this.c[0].style.flex = '1 0 auto' + + this.c[3] = this.getColorRing(); + this.c[3].style.visibility = 'hidden'; + + this.hsl = null; + this.value = '#ffffff'; + if( o.value !== undefined ){ + if( o.value instanceof Array ) this.value = Tools.rgbToHex( o.value ); + else if(!isNaN(o.value)) this.value = Tools.hexToHtml( o.value ); + else this.value = o.value; + } + + this.bcolor = null; + this.isDown = false; + this.fistDown = false; + + this.notext = o.notext || false; + + this.tr = 98; + this.tsl = Math.sqrt(3) * this.tr; + + this.hue = 0; + this.d = 256; + + this.setColor( this.value ); + + this.init(); + + if( o.open !== undefined ) this.open(); + + } + + testZone ( mx, my ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + + + if( this.up && this.isOpen ){ + + if( l.y > this.wfixe ) return 'title'; + else return 'color'; + + } else { + + if( l.y < this.baseH+2 ) return 'title'; + else if( this.isOpen ) return 'color'; + + + } + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.d = 256; + + } + + mousedown ( e ) { + + + let name = this.testZone( e.clientX, e.clientY ); + + + //if( !name ) return; + if(name === 'title'){ + if( !this.isOpen ) this.open(); + else this.close(); + return true; + } + + + if( name === 'color' ){ + + this.isDown = true; + this.fistDown = true; + this.mousemove( e ); + } + } + + mousemove ( e ) { + + let name = this.testZone( e.clientX, e.clientY ); + + let off, d, hue, sat, lum, rad, x, y, rr, T = Tools; + + if( name === 'title' ) this.cursor('pointer'); + + if( name === 'color' ){ + + off = this.offset; + off.x = e.clientX - ( this.zone.x + this.decal.x + this.mid ); + off.y = e.clientY - ( this.zone.y + this.decal.y + this.mid ); + d = off.length() * this.ratio; + rr = off.angle(); + if(rr < 0) rr += 2 * T.PI; + + + if ( d < 128 ) this.cursor('crosshair'); + else if( !this.isDown ) this.cursor(); + + if( this.isDown ){ + + if( this.fistDown ){ + this.d = d; + this.fistDown = false; + } + + if ( this.d < 128 ) { + + if ( this.d > this.tr ) { // outside hue + + hue = ( rr + T.pi90 ) / T.TwoPI; + this.hue = (hue + 1) % 1; + this.setHSL([(hue + 1) % 1, this.hsl[1], this.hsl[2]]); + + } else { // triangle + + x = off.x * this.ratio; + y = off.y * this.ratio; + + let rr = (this.hue * T.TwoPI) + T.PI; + if(rr < 0) rr += 2 * T.PI; + + rad = Math.atan2(-y, x); + if(rad < 0) rad += 2 * T.PI; + + let rad0 = ( rad + T.pi90 + T.TwoPI + rr ) % (T.TwoPI), + rad1 = rad0 % ((2/3) * T.PI) - (T.pi60), + a = 0.5 * this.tr, + b = Math.tan(rad1) * a, + r = Math.sqrt(x*x + y*y), + maxR = Math.sqrt(a*a + b*b); + + if( r > maxR ) { + let dx = Math.tan(rad1) * r; + let rad2 = Math.atan(dx / maxR); + if(rad2 > T.pi60) rad2 = T.pi60; + else if( rad2 < -T.pi60 ) rad2 = -T.pi60; + + rad += rad2 - rad1; + + rad0 = (rad + T.pi90 + T.TwoPI + rr) % (T.TwoPI), + rad1 = rad0 % ((2/3) * T.PI) - (T.pi60); + b = Math.tan(rad1) * a; + r = maxR = Math.sqrt(a*a + b*b); + } + + lum = ((Math.sin(rad0) * r) / this.tsl) + 0.5; + + let w = 1 - (Math.abs(lum - 0.5) * 2); + sat = (((Math.cos(rad0) * r) + (this.tr / 2)) / (1.5 * this.tr)) / w; + sat = T.clamp( sat, 0, 1 ); + + this.setHSL([this.hsl[0], sat, lum]); + + } + } + } + } + + } + + // ---------------------- + + setHeight () { + + this.h = this.isOpen ? this.wfixe + this.baseH + 5 : this.baseH; + this.s[0].height = this.h + 'px'; + this.zone.h = this.h; + + } + + parentHeight ( t ) { + + if ( this.group !== null ) this.group.calc( t ); + else if ( this.isUI ) this.main.calc( t ); + + } + + open () { + + super.open(); + + this.setHeight(); + + if( this.up ) this.zone.y -= this.wfixe + 5; + + let t = this.h - this.baseH; + + this.s[3].visibility = 'visible'; + //this.s[3].display = 'block'; + this.parentHeight( t ); + + } + + close () { + + super.close(); + + if( this.up ) this.zone.y += this.wfixe + 5; + + let t = this.h - this.baseH; + + this.setHeight(); + + this.s[3].visibility = 'hidden'; + //this.s[3].display = 'none'; + this.parentHeight( -t ); + + } + + update ( up ) { + + let cc = Tools.rgbToHex( Tools.hslToRgb([ this.hsl[0], 1, 0.5 ]) ); + + this.moveMarkers(); + + this.value = this.bcolor; + + this.setSvg( this.c[3], 'fill', cc, 2, 0 ); + + + this.s[2].background = this.bcolor; + if(!this.notext) this.c[2].textContent = Tools.htmlToHex( this.bcolor ); + + this.invert = Tools.findDeepInver( this.rgb ); + this.s[2].color = this.invert ? '#fff' : '#000'; + + if(!up) return; + + if( this.ctype === 'array' ) this.send( this.rgb ); + if( this.ctype === 'rgb' ) this.send( Tools.htmlRgb( this.rgb ) ); + if( this.ctype === 'hex' ) this.send( Tools.htmlToHex( this.value ) ); + if( this.ctype === 'html' ) this.send(); + + } + + setValue ( v ){ + + if( v instanceof Array ) this.value = Tools.rgbToHex( v ); + else if(!isNaN(v)) this.value = Tools.hexToHtml( v ); + else this.value = v; + + this.setColor( this.value ); + this.update(); + + } + + setColor ( color ) { + + let unpack = Tools.unpack(color); + if (this.bcolor !== color && unpack) { + + this.bcolor = color; + this.rgb = unpack; + this.hsl = Tools.rgbToHsl( this.rgb ); + + this.hue = this.hsl[0]; + + this.update(); + } + return this; + + } + + setHSL ( hsl ) { + + this.hsl = hsl; + this.rgb = Tools.hslToRgb( hsl ); + this.bcolor = Tools.rgbToHex( this.rgb ); + this.update( true ); + return this; + + } + + moveMarkers () { + + let p = this.pp; + let T = Tools; + + this.invert ? '#fff' : '#000'; + let a = this.hsl[0] * T.TwoPI; + let third = (2/3) * T.PI; + let r = this.tr; + let h = this.hsl[0]; + let s = this.hsl[1]; + let l = this.hsl[2]; + + let angle = ( a - T.pi90 ) * T.todeg; + + h = - a + T.pi90; + + let hx = Math.cos(h) * r; + let hy = -Math.sin(h) * r; + let sx = Math.cos(h - third) * r; + let sy = -Math.sin(h - third) * r; + let vx = Math.cos(h + third) * r; + let vy = -Math.sin(h + third) * r; + let mx = (sx + vx) / 2, my = (sy + vy) / 2; + a = (1 - 2 * Math.abs(l - .5)) * s; + let x = sx + (vx - sx) * l + (hx - mx) * a; + let y = sy + (vy - sy) * l + (hy - my) * a; + + p.set( x, y ).addScalar(128); + + //let ff = (1-l)*255; + // this.setSvg( this.c[3], 'stroke', 'rgb('+ff+','+ff+','+ff+')', 3 ); + + this.setSvg( this.c[3], 'transform', 'rotate('+angle+' )', 2 ); + + this.setSvg( this.c[3], 'cx', p.x, 3 ); + this.setSvg( this.c[3], 'cy', p.y, 3 ); + + this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 2, 3 ); + this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 3 ); + this.setSvg( this.c[3], 'fill',this.bcolor, 3 ); + + } + + rSize () { + + //Proto.prototype.rSize.call( this ); + super.rSize(); + + let s = this.s; + + s[2].width = this.sb + 'px'; + s[2].left = this.sa + 'px'; + + this.rSizeColor( this.cw ); + + this.decal.x = Math.floor((this.w - this.wfixe) * 0.5); + //s[3].left = this.decal.x + 'px'; + + } + + rSizeColor ( w ) { + + if( w === this.wfixe ) return; + + this.wfixe = w; + + let s = this.s; + + //this.decal.x = Math.floor((this.w - this.wfixe) * 0.5); + this.decal.y = this.side === 'up' ? 2 : this.baseH + 2; + this.mid = Math.floor( this.wfixe * 0.5 ); + + this.setSvg( this.c[3], 'viewBox', '0 0 '+ this.wfixe + ' '+ this.wfixe ); + s[3].width = this.wfixe + 'px'; + s[3].height = this.wfixe + 'px'; + //s[3].left = this.decal.x + 'px'; + s[3].top = this.decal.y + 'px'; + + this.ratio = 256 / this.wfixe; + this.square = 1 / (60*(this.wfixe/256)); + this.setHeight(); + + } + + +} + +class Fps extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.round = Math.round; + + //this.autoHeight = true; + + this.baseH = this.h; + this.hplus = o.hplus || 50; + + this.res = o.res || 40; + this.l = 1; + + this.precision = o.precision || 0; + + + this.custom = o.custom || false; + this.names = o.names || ['FPS', 'MS']; + let cc = o.cc || ['220,220,220', '255,255,0']; + + // this.divid = [ 100, 100, 100 ]; + // this.multy = [ 30, 30, 30 ]; + + this.adding = o.adding || false; + + this.range = o.range || [ 165, 100, 100 ]; + + this.alpha = o.alpha || 0.25; + + this.values = []; + this.points = []; + this.textDisplay = []; + + if(!this.custom){ + + this.now = Roots.getTime(); + this.startTime = 0;//this.now() + this.prevTime = 0;//this.startTime; + this.frames = 0; + + this.ms = 0; + this.fps = 0; + this.mem = 0; + this.mm = 0; + + this.isMem = ( self.performance && self.performance.memory ) ? true : false; + + // this.divid = [ 100, 200, 1 ]; + // this.multy = [ 30, 30, 30 ]; + + if( this.isMem ){ + + this.names.push('MEM'); + cc.push('0,255,255'); + + } + + this.txt = o.name || 'Fps'; + + } + + + let fltop = Math.floor(this.h*0.5)-6; + + this.c[1].textContent = this.txt; + this.c[0].style.cursor = 'pointer'; + this.c[0].style.pointerEvents = 'auto'; + + let panelCss = 'display:none; left:10px; top:'+ this.h + 'px; height:'+(this.hplus - 8)+'px; box-sizing:border-box; background: rgba(0, 0, 0, 0.2); border:1px solid '+ this.colors.border +';'; + + if( this.radius !== 0 ) panelCss += 'border-radius:' + this.radius+'px;'; + + this.c[2] = this.dom( 'path', this.css.basic + panelCss , {} ); + + this.c[2].setAttribute('viewBox', '0 0 '+this.res+' 50' ); + this.c[2].setAttribute('height', '100%' ); + this.c[2].setAttribute('width', '100%' ); + this.c[2].setAttribute('preserveAspectRatio', 'none' ); + + + //this.dom( 'path', null, { fill:'rgba(255,255,0,0.3)', 'stroke-width':1, stroke:'#FF0', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + //this.dom( 'path', null, { fill:'rgba(0,255,255,0.3)', 'stroke-width':1, stroke:'#0FF', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + + // arrow + this.c[3] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; left:4px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:this.colors.text, stroke:'none'}); + + // result test + this.c[4] = this.dom( 'div', this.css.txt + 'position:absolute; left:10px; top:'+(this.h+2) +'px; display:none; width:100%; text-align:center;' ); + + // bottom line + if( o.bottomLine ) this.c[4] = this.dom( 'div', this.css.basic + 'width:100%; bottom:0px; height:1px; background: rgba(255, 255, 255, 0.2);'); + + this.isShow = false; + + let s = this.s; + + s[1].marginLeft = '10px'; + s[1].lineHeight = this.h-4; + s[1].color = this.colors.text; + s[1].fontWeight = 'bold'; + + if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px'; + if( this.colors.gborder!=='none') s[0].border = '1px solid ' + this.colors.gborder; + + + + + let j = 0; + + for( j=0; j " + this.names[j] +" "); + + } + + j = this.names.length; + while(j--){ + this.dom( 'path', null, { fill:'rgba('+cc[j]+','+this.alpha+')', 'stroke-width':1, stroke:'rgba('+cc[j]+',1)', 'vector-effect':'non-scaling-stroke' }, this.c[2] ); + } + + + this.init(); + + //if( this.isShow ) this.show(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousedown ( e ) { + + if( this.isShow ) this.close(); + else this.open(); + + } + + // ---------------------- + + /*mode: function ( mode ) { + + let s = this.s; + + switch(mode){ + case 0: // base + s[1].color = this.colors.text; + //s[1].background = 'none'; + break; + case 1: // over + s[1].color = '#FFF'; + //s[1].background = UIL.SELECT; + break; + case 2: // edit / down + s[1].color = this.colors.text; + //s[1].background = UIL.SELECTDOWN; + break; + + } + },*/ + + tick ( v ) { + + this.values = v; + if( !this.isShow ) return; + this.drawGraph(); + this.upText(); + + } + + makePath ( point ) { + + let p = ''; + p += 'M ' + (-1) + ' ' + 50; + for ( let i = 0; i < this.res + 1; i ++ ) { p += ' L ' + i + ' ' + point[i]; } + p += ' L ' + (this.res + 1) + ' ' + 50; + return p; + + } + + upText ( val ) { + + let v = val || this.values, t = ''; + for( let j=0, lng =this.names.length; j'; + this.c[4].innerHTML = t; + + } + + drawGraph () { + + let svg = this.c[2]; + let i = this.names.length, v, old = 0, n = 0; + + while( i-- ){ + if( this.adding ) v = (this.values[n]+old) * this.range[n]; + else v = (this.values[n] * this.range[n]); + this.points[n].shift(); + this.points[n].push( 50 - v ); + this.setSvg( svg, 'd', this.makePath( this.points[n] ), i+1 ); + old += this.values[n]; + n++; + + } + + } + + open () { + + super.open(); + + this.h = this.hplus + this.baseH; + + this.setSvg( this.c[3], 'd', this.svgs.arrowDown ); + + if( this.group !== null ){ this.group.calc( this.hplus );} + else if( this.isUI ) this.main.calc( this.hplus ); + + this.s[0].height = this.h +'px'; + this.s[2].display = 'block'; + this.s[4].display = 'block'; + this.isShow = true; + + if( !this.custom ) Roots.addListen( this ); + + } + + close () { + + super.close(); + + this.h = this.baseH; + + this.setSvg( this.c[3], 'd', this.svgs.arrow ); + + if( this.group !== null ){ this.group.calc( -this.hplus );} + else if( this.isUI ) this.main.calc( -this.hplus ); + + this.s[0].height = this.h +'px'; + this.s[2].display = 'none'; + this.s[4].display = 'none'; + this.isShow = false; + + if( !this.custom ) Roots.removeListen( this ); + + this.c[4].innerHTML = ''; + + } + + + ///// AUTO FPS ////// + + begin () { + + this.startTime = this.now(); + + } + + end () { + + let time = this.now(); + this.ms = time - this.startTime; + + this.frames ++; + + if ( time > this.prevTime + 1000 ) { + + this.fps = this.round( ( this.frames * 1000 ) / ( time - this.prevTime ) ); + + this.prevTime = time; + this.frames = 0; + + if ( this.isMem ) { + + let heapSize = performance.memory.usedJSHeapSize; + let heapSizeLimit = performance.memory.jsHeapSizeLimit; + + this.mem = this.round( heapSize * 0.000000954 ); + this.mm = heapSize / heapSizeLimit; + + } + + } + + this.values = [ this.fps, this.ms , this.mm ]; + + this.drawGraph(); + this.upText( [ this.fps, this.ms, this.mem ] ); + + return time; + + } + + listening () { + + if( !this.custom ) this.startTime = this.end(); + + } + + rSize () { + + let s = this.s; + let w = this.w; + + s[0].width = w + 'px'; + s[1].width = w + 'px'; + s[2].left = 10 + 'px'; + s[2].width = (w-20) + 'px'; + s[4].width = (w-20) + 'px'; + + } + +} + +class Graph extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value !== undefined ? o.value : [0,0,0]; + this.lng = this.value.length; + + this.precision = o.precision !== undefined ? o.precision : 2; + this.multiplicator = o.multiplicator || 1; + this.neg = o.neg || false; + + this.line = o.line !== undefined ? o.line : true; + + //if(this.neg)this.multiplicator*=2; + + this.autoWidth = o.autoWidth !== undefined ? o.autoWidth : true; + this.isNumber = false; + + this.isDown = false; + + this.h = o.h || 128 + 10; + this.rh = this.h - 10; + this.top = 0; + + this.c[0].style.width = this.w +'px'; + + if( this.c[1] !== undefined ) { // with title + + this.c[1].style.width = this.w +'px'; + + if(!this.autoWidth){ + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + } + + + //this.c[1].style.background = '#ff0000'; + //this.c[1].style.textAlign = 'center'; + this.top = 10; + this.h += 10; + + } + + this.gh = this.rh - 28; + this.gw = this.w - 28; + + //this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; text-align: justify; column-count:'+this.lng+'; top:'+(this.h-20)+'px; width:100%; color:'+ this.colors.text ); + + //let colum = 'column-count:'+this.lng+'; column:'+this.lng+'; break-inside: column; top:' + this.c[2] = this.dom( 'div', this.css.txt + 'display:block; text-align:center; padding:0px 0px; top:'+(this.h-20)+'px; left:14px; width:'+this.gw+'px; color:'+ this.colors.text ); + + //this.c[2].textContent = this.value; + this.c[2].innerHTML = this.valueToHtml(); + + let svg = this.dom( 'svg', this.css.basic , { viewBox:'0 0 '+this.w+' '+this.rh, width:this.w, height:this.rh, preserveAspectRatio:'none' } ); + this.setCss( svg, { width:this.w, height:this.rh, left:0, top:this.top }); + + this.dom( 'path', '', { d:'', stroke:this.colors.text, 'stroke-width':2, fill:'none', 'stroke-linecap':'butt' }, svg ); + this.dom( 'rect', '', { x:10, y:10, width:this.gw+8, height:this.gh+8, stroke:'rgba(0,0,0,0.3)', 'stroke-width':1 , fill:'none'}, svg ); + + this.iw = ((this.gw-(4*(this.lng-1)))/this.lng); + let t = []; + this.cMode = []; + + this.v = []; + + for( let i = 0; i < this.lng; i++ ){ + + t[i] = [ 14 + (i*this.iw) + (i*4), this.iw ]; + t[i][2] = t[i][0] + t[i][1]; + this.cMode[i] = 0; + + if( this.neg ) this.v[i] = ((1+(this.value[i] / this.multiplicator))*0.5); + else this.v[i] = this.value[i] / this.multiplicator; + + this.dom( 'rect', '', { x:t[i][0], y:14, width:t[i][1], height:1, fill:this.colors.text, 'fill-opacity':0.3 }, svg ); + + } + + this.tmp = t; + this.c[3] = svg; + + //console.log(this.w) + + this.init(); + + if( this.c[1] !== undefined ){ + this.c[1].style.top = 0 +'px'; + this.c[1].style.height = 20 +'px'; + this.s[1].lineHeight = (20-5)+'px'; + } + + this.update( false ); + + } + + setValue ( value ) { + + this.value = value; + this.lng = this.value.length; + for (var i = 0; i < this.lng; i++) { + if (this.neg) this.v[i] = (1 + value[i] / this.multiplicator) * 0.5; + else this.v[i] = value[i] / this.multiplicator; + } + this.update(); + + } + + valueToHtml() { + + let i = this.lng, n=0, r = ''; + let w = 100 / this.lng; + let style = 'width:'+ w +'%;';//' text-align:center;' + while(i--){ + if(n===this.lng-1) r += '
    ' + this.value[n] + '
    '; + else r += '' + this.value[n] + ''; + n++; + } + return r + } + + updateSVG () { + + if( this.line ) this.setSvg( this.c[3], 'd', this.makePath(), 0 ); + + for(let i = 0; ithis.top && l.yt[i][0] && l.x this.distance ) { + let angle = Math.atan2(this.tmp.x, this.tmp.y); + this.tmp.x = Math.sin( angle ) * this.distance; + this.tmp.y = Math.cos( angle ) * this.distance; + } + + this.pos.copy( this.tmp ).divideScalar( this.distance ).negate(); + + this.update(); + + } + + setValue ( v ) { + + if(v===undefined) v=[0,0]; + + this.pos.set( v[0] || 0, v[1] || 0 ); + this.updateSVG(); + + } + + update ( up ) { + + if( up === undefined ) up = true; + + if( this.interval !== null ){ + + if( !this.isDown ){ + + this.pos.lerp( null, 0.3 ); + + this.pos.x = Math.abs( this.pos.x ) < 0.01 ? 0 : this.pos.x; + this.pos.y = Math.abs( this.pos.y ) < 0.01 ? 0 : this.pos.y; + + if( this.isUI && this.main.isCanvas ) this.main.draw(); + + } + + } + + this.updateSVG(); + + if( up ) this.send(); + + + if( this.pos.isZero() ) this.stopInterval(); + + } + + updateSVG () { + + //let x = this.radius - ( -this.pos.x * this.distance ); + //let y = this.radius - ( -this.pos.y * this.distance ); + + let x = (this.diam*0.5) - ( -this.pos.x * this.distance ); + let y = (this.diam*0.5) - ( -this.pos.y * this.distance ); + + if(this.model === 0){ + + let sx = x + ((this.pos.x)*5) + 5; + let sy = y + ((this.pos.y)*5) + 10; + + this.setSvg( this.c[3], 'cx', sx*this.ratio, 3 ); + this.setSvg( this.c[3], 'cy', sy*this.ratio, 3 ); + } else { + this.setSvg( this.c[3], 'cx', x*this.ratio, 3 ); + this.setSvg( this.c[3], 'cy', y*this.ratio, 3 ); + } + + + + this.setSvg( this.c[3], 'cx', x*this.ratio, 4 ); + this.setSvg( this.c[3], 'cy', y*this.ratio, 4 ); + + this.value[0] = ( this.pos.x * this.multiplicator ).toFixed( this.precision ) * 1; + this.value[1] = ( this.pos.y * this.multiplicator ).toFixed( this.precision ) * 1; + + this.c[2].textContent = this.value; + + } + + clear () { + + this.stopInterval(); + super.clear(); + + } + +} + +class Knob extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.isCyclic = o.cyclic || false; + this.model = o.stype || 0; + if( o.mode !== undefined ) this.model = o.mode; + + this.autoWidth = false; + + this.setTypeNumber( o ); + + this.minw = this.w; + this.diam = o.diam || this.w; + + this.mPI = Math.PI * 0.8; + this.toDeg = 180 / Math.PI; + this.cirRange = this.mPI * 2; + + this.offset = new V2(); + + this.h = o.h || this.w + 10; + this.top = 0; + + this.c[0].style.width = this.w +'px'; + + if(this.c[1] !== undefined) { + + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + this.top = 10; + this.h += 10; + + } + + this.percent = 0; + + this.cmode = 0; + let cc = this.colors; + + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text ); + + this.c[3] = this.getKnob(); + this.setSvg( this.c[3], 'fill', cc.button, 0 ); + this.setSvg( this.c[3], 'stroke', cc.text, 1 ); + this.setSvg( this.c[3], 'stroke', cc.text, 3 ); + this.setSvg( this.c[3], 'd', this.makeGrad(), 3 ); + + this.setSvg( this.c[3], 'viewBox', '0 0 ' + this.diam + ' ' + this.diam ); + this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top }); + + if ( this.model > 0 ) { + + Tools.dom( 'path', '', { d: '', stroke:cc.text, 'stroke-width': 2, fill: 'none', 'stroke-linecap': 'round' }, this.c[3] ); //4 + + if ( this.model == 2) { + + Tools.addSVGGlowEffect(); + this.setSvg( this.c[3], 'style', 'filter: url("#UILGlow");', 4 ); + + } + + } + + this.r = 0; + + this.init(); + + this.update(); + + } + + mode ( mode ) { + + let cc = this.colors; + + if( this.cmode === mode ) return false; + + switch( mode ) { + case 0: // base + this.s[2].color = cc.text; + this.setSvg( this.c[3], 'fill', cc.button, 0); + //this.setSvg( this.c[3], 'stroke','rgba(255,0,0,0.2)', 2); + this.setSvg( this.c[3], 'stroke', cc.text, 1 ); + break; + case 1: // down + this.s[2].color = cc.textOver; + this.setSvg( this.c[3], 'fill', cc.select, 0); + //this.setSvg( this.c[3], 'stroke','rgba(0,0,0,0.6)', 2); + this.setSvg( this.c[3], 'stroke', cc.textOver, 1 ); + break; + } + + this.cmode = mode; + return true; + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'knob'; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + this.isDown = false; + this.sendEnd(); + return this.mode(0) + + } + + mousedown ( e ) { + + this.isDown = true; + this.old = this.value; + this.oldr = null; + this.mousemove( e ); + return this.mode(1) + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + let off = this.offset; + + //off.x = this.radius - ( e.clientX - this.zone.x ); + //off.y = this.radius - ( e.clientY - this.zone.y - this.top ); + + off.x = (this.w*0.5) - ( e.clientX - this.zone.x ); + off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + + this.r = - Math.atan2( off.x, off.y ); + + if( this.oldr !== null ) this.r = Math.abs(this.r - this.oldr) > Math.PI ? this.oldr : this.r; + + this.r = this.r > this.mPI ? this.mPI : this.r; + this.r = this.r < -this.mPI ? -this.mPI : this.r; + + let steps = 1 / this.cirRange; + let value = (this.r + this.mPI) * steps; + + let n = ( ( this.range * value ) + this.min ) - this.old; + + if(n >= this.step || n <= this.step){ + n = Math.floor( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + this.oldr = this.r; + } + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'knob' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue( v ); + this.old = v; + this.update( true ); + + return true; + + } + return false; + + } + + makeGrad () { + + let d = '', step, range, a, x, y, x2, y2, r = 64; + let startangle = Math.PI + this.mPI; + let endangle = Math.PI - this.mPI; + //let step = this.step>5 ? this.step : 1; + + if(this.step>5){ + range = this.range / this.step; + step = ( startangle - endangle ) / range; + } else { + step = (( startangle - endangle ) / r)*2; + range = r*0.5; + } + + for ( let i = 0; i <= range; ++i ) { + + a = startangle - ( step * i ); + x = r + Math.sin( a ) * ( r - 20 ); + y = r + Math.cos( a ) * ( r - 20 ); + x2 = r + Math.sin( a ) * ( r - 24 ); + y2 = r + Math.cos( a ) * ( r - 24 ); + d += 'M' + x + ' ' + y + ' L' + x2 + ' '+y2 + ' '; + + } + + return d; + + } + + update ( up ) { + + this.c[2].textContent = this.value; + this.percent = (this.value - this.min) / this.range; + + let sa = Math.PI + this.mPI; + let ea = ( ( this.percent * this.cirRange ) - ( this.mPI ) ); + + let sin = Math.sin( ea ); + let cos = Math.cos( ea ); + + let x1 = ( 25 * sin ) + 64; + let y1 = -( 25 * cos ) + 64; + let x2 = ( 20 * sin ) + 64; + let y2 = -( 20 * cos ) + 64; + + this.setSvg( this.c[3], 'd', 'M ' + x1 +' ' + y1 + ' L ' + x2 +' ' + y2, 1 ); + + if ( this.model > 0 ) { + + let x1 = 36 * Math.sin( sa ) + 64; + let y1 = 36 * Math.cos( sa ) + 64; + let x2 = 36 * sin + 64; + let y2 = -36 * cos + 64; + let big = ea <= Math.PI - this.mPI ? 0 : 1; + this.setSvg( this.c[3], 'd', 'M ' + x1 + ',' + y1 + ' A ' + 36 + ',' + 36 + ' 1 ' + big + ' 1 ' + x2 + ',' + y2, 4 ); + + let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( this.colors.text, -0.75) ), Tools.unpack( this.colors.text ), this.percent ) ); + this.setSvg( this.c[3], 'stroke', color, 4 ); + + } + + if( up ) this.send(); + + } + +} + +class List extends Proto { + + constructor( o = {} ) { + + super( o ); + + // images + this.path = o.path || ''; + this.format = o.format || ''; + + + this.isWithImage = this.path !== '' ? true:false; + this.preLoadComplete = false; + + this.tmpImage = {}; + this.tmpUrl = []; + + //this.autoHeight = false; + + let align = o.align || 'center'; + + // scroll size + let ss = o.scrollSize || 10; + this.ss = ss+1; + + this.sMode = 0; + this.tMode = 0; + + this.listOnly = o.listOnly || false; + this.staticTop = o.staticTop || false; + + this.isSelectable = this.listOnly; + if( o.select !== undefined ) o.selectable = o.select; + if( o.selectable !== undefined ) this.isSelectable = o.selectable; + + if( this.txt === '' ) this.p = 0; + + + let fltop = Math.floor(this.h*0.5)-5; + let cc = this.colors; + + + + this.c[2] = this.dom( 'div', this.css.basic + 'top:0; display:none; border-radius:'+this.radius+'px;' ); + this.c[3] = this.dom( 'div', this.css.item + 'position:absolute; text-align:'+align+'; line-height:'+(this.h-4)+'px; top:1px; background:'+cc.button+'; height:'+(this.h-2)+'px; border:1px solid '+cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:cc.text, stroke:'none'}); + + this.scrollerBack = this.dom( 'div', this.css.basic + 'right:0px; width:'+ss+'px; background:'+cc.back+'; display:none;'); + this.scroller = this.dom( 'div', this.css.basic + 'right:'+((ss-(ss*0.25))*0.5)+'px; width:'+(ss*0.25)+'px; background:'+cc.text+'; display:none; '); + + this.c[3].style.color = cc.text; + + + this.list = []; + this.refObject = null; + + if(o.list){ + if( o.list instanceof Array ){ + this.list = o.list; + } else { + this.refObject = o.list; + for( let g in this.refObject ) this.list.push(g); + } + } + + this.items = []; + + this.prevName = ''; + + this.baseH = this.h; + + this.itemHeight = o.itemHeight || (this.h-3); + + // force full list + this.full = o.full || false; + + this.py = 0; + this.ww = this.sb; + this.scroll = false; + this.isDown = false; + + this.current = null; + + // list up or down + this.side = o.side || 'down'; + this.up = this.side === 'down' ? 0 : 1; + + if( this.up ){ + + this.c[2].style.top = 'auto'; + this.c[3].style.top = 'auto'; + this.c[4].style.top = 'auto'; + //this.c[5].style.top = 'auto'; + + this.c[2].style.bottom = this.h-2 + 'px'; + this.c[3].style.bottom = '1px'; + this.c[4].style.bottom = fltop + 'px'; + + } else { + this.c[2].style.top = this.baseH + 'px'; + } + + this.listIn = this.dom( 'div', this.css.basic + 'left:0; top:0; width:100%; background:none;'); + this.listIn.name = 'list'; + + + + this.topList = 0; + + this.c[2].appendChild( this.listIn ); + this.c[2].appendChild( this.scrollerBack ); + this.c[2].appendChild( this.scroller ); + + if( o.value !== undefined ){ + if(!isNaN(o.value)) this.value = this.list[ o.value ]; + else this.value = o.value; + }else { + this.value = this.list[0]; + } + + this.isOpenOnStart = o.open || false; + + if( this.listOnly ){ + this.baseH = 5; + this.c[3].style.display = 'none'; + this.c[4].style.display = 'none'; + this.c[2].style.top = this.baseH+'px'; + this.isOpenOnStart = true; + } + + + this.miniCanvas = o.miniCanvas || false; + this.canvasBg = o.canvasBg || 'rgba(0,0,0,0)'; + this.imageSize = o.imageSize || [20,20]; + + // dragout function + this.drag = o.drag || false; + this.dragout = o.dragout || false; + this.dragstart = o.dragstart || null; + this.dragend = o.dragend || null; + + + + //this.c[0].style.background = '#FF0000' + if( this.isWithImage ) this.preloadImage(); + // } else { + // populate list + this.setList( this.list ); + this.init(); + if( this.isOpenOnStart ) this.open( true ); + // } + + } + + /*send ( v ) { + + super.send( v ); + + //Proto.prototype.send.call( this, v ); + }*/ + + // image list + + preloadImage () { + + this.preLoadComplete = false; + + this.tmpImage = {}; + for( let i=0; i this.h - this.baseH ) return 'title'; + else { + if( this.scroll && ( l.x > (this.sa+this.sb-this.ss)) ) return 'scroll'; + if(l.x > this.sa) return this.testItems( l.y-this.baseH ); + } + + } else { + if( l.y < this.baseH+2 ) return 'title'; + else { + if( this.isOpen ){ + if( this.scroll && ( l.x > (this.sa+this.sb-this.ss)) ) return 'scroll'; + if(l.x > this.sa) return this.testItems( l.y-this.baseH ); + } + } + + } + + return ''; + + } + + testItems ( y ) { + + let name = ''; + + let i = this.items.length, item, a, b; + while(i--){ + item = this.items[i]; + a = item.posy + this.topList; + b = item.posy + this.itemHeight + 1 + this.topList; + if( y >= a && y <= b ){ + name = 'item' + i; + this.modeItem(0); + this.current = item; + this.modeItem(1); + return name; + } + + } + + return name; + + } + + modeItem ( mode ) { + + if( !this.current ) return + + if( this.current.select && mode===0) mode = 2; + let cc = this.colors; + + switch( mode ){ + + case 0: // base + this.current.style.background = cc.back; + this.current.style.color = cc.text; + break; + case 1: // over + this.current.style.background = cc.over; + this.current.style.color = cc.textOver; + break; + case 2: // edit / down + this.current.style.background = cc.select; + this.current.style.color = cc.textSelect; + break; + + } + } + + unSelected() { + + if( !this.current ) return + this.modeItem(0); + this.current = null; + + } + + selected() { + + if( !this.current ) return + this.resetItems(); + this.modeItem(2); + this.current.select = true; + + } + + resetItems() { + + let i = this.items.length; + while(i--){ + this.items[i].select = false; + this.items[i].style.background = this.colors.back; + this.items[i].style.color = this.colors.text; + } + + } + + // ---------------------- + // EVENTS + // ---------------------- + + + mouseup ( e ) { + + this.isDown = false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + if( name === 'scroll' ){ + + this.isDown = true; + this.mousemove( e ); + + } else if( name === 'title' ){ + + this.modeTitle(2); + if( !this.listOnly ){ + if( !this.isOpen ) this.open(); + else this.close(); + } + } else { + // is item + if( this.current ){ + + this.value = this.list[ this.current.id ]; + + if( this.isSelectable ) this.selected(); + //this.value = this.refObject !== null ? this.refObject[this.list[this.current.id]] : this.list[this.current.id] + //this.value = this.current.textContent; + this.send( this.refObject !== null ? this.refObject[this.list[this.current.id]] : this.value ); + + if( !this.listOnly ) { + this.close(); + this.setTopItem(); + } + } + + } + + return true; + + } + + mousemove ( e ) { + + let nup = false; + let name = this.testZone( e ); + + if( !name ) return nup; + + if( name === 'title' ){ + this.unSelected(); + this.modeTitle(1); + this.cursor('pointer'); + + } else if( name === 'scroll' ){ + + this.cursor('s-resize'); + this.modeScroll(1); + if( this.isDown ){ + this.modeScroll(2); + let top = this.zone.y+this.baseH-2; + this.update( ( e.clientY - top ) - ( this.sh*0.5 ) ); + } + //if(this.isDown) this.listmove(e); + } else { + + // is item + this.modeTitle(0); + this.modeScroll(0); + this.cursor('pointer'); + + } + + if( name !== this.prevName ) nup = true; + this.prevName = name; + + return nup; + + } + + wheel ( e ) { + + let name = this.testZone( e ); + if( name === 'title' ) return false; + this.py += e.delta*10; + this.update(this.py); + return true; + + } + + + + // ---------------------- + + reset () { + + this.prevName = ''; + this.unSelected(); + this.modeTitle(0); + this.modeScroll(0); + + //console.log('this is reset') + + } + + modeScroll ( mode ) { + + if( mode === this.sMode ) return; + + let s = this.scroller.style; + let cc = this.colors; + + switch(mode){ + case 0: // base + s.background = cc.text; + break; + case 1: // over + s.background = cc.select; + break; + case 2: // edit / down + s.background = cc.select; + break; + + } + + this.sMode = mode; + } + + modeTitle ( mode ) { + + if( mode === this.tMode ) return; + + let s = this.s; + let cc = this.colors; + + switch(mode){ + case 0: // base + s[3].color = cc.text; + s[3].background = cc.button; + break; + case 1: // over + s[3].color = cc.textOver; + s[3].background = cc.overoff; + break; + case 2: // edit / down + s[3].color = cc.textSelect; + s[3].background = cc.overoff; + break; + + } + + this.tMode = mode; + + } + + clearList () { + + while ( this.listIn.children.length ) this.listIn.removeChild( this.listIn.lastChild ); + this.items = []; + + } + + setList ( list ) { + + this.clearList(); + + this.list = list; + this.length = this.list.length; + + this.maxItem = this.full ? this.length : 5; + this.maxItem = this.length < this.maxItem ? this.length : this.maxItem; + + this.maxHeight = this.maxItem * (this.itemHeight+1) + 2; + + this.max = this.length * (this.itemHeight+1) + 2; + this.ratio = this.maxHeight / this.max; + this.sh = this.maxHeight * this.ratio; + this.range = this.maxHeight - this.sh; + + this.c[2].style.height = this.maxHeight + 'px'; + this.scrollerBack.style.height = this.maxHeight + 'px'; + this.scroller.style.height = this.sh + 'px'; + + if( this.max > this.maxHeight ){ + this.ww = this.sb - this.ss; + this.scroll = true; + } + + if( this.miniCanvas ) { + + this.tmpCanvas = document.createElement('canvas'); + this.tmpCanvas.width = this.imageSize[0]; + this.tmpCanvas.height = this.imageSize[1]; + this.tmpCtx = this.tmpCanvas.getContext("2d"); + this.tmpCtx.fillStyle = this.canvasBg; + this.tmpCtx.fillRect(0, 0, this.imageSize[0], this.imageSize[1]); + + } + + let item, n;//, l = this.sb; + for( let i=0; i this.range ? this.range : y; + + this.topList = -Math.floor( y / this.ratio ); + + this.listIn.style.top = this.topList+'px'; + this.scroller.style.top = Math.floor( y ) + 'px'; + + this.py = y; + + } + + parentHeight ( t ) { + + if ( this.group !== null ) this.group.calc( t ); + else if ( this.isUI ) this.main.calc( t ); + + } + + open ( first ) { + + super.open(); + + this.update( 0 ); + + this.h = this.maxHeight + this.baseH + 5; + if( !this.scroll ){ + this.topList = 0; + this.h = this.baseH + 5 + this.max; + this.scroller.style.display = 'none'; + this.scrollerBack.style.display = 'none'; + } else { + this.scroller.style.display = 'block'; + this.scrollerBack.style.display = 'block'; + } + this.s[0].height = this.h + 'px'; + this.s[2].display = 'block'; + + if( this.up ){ + this.zone.y -= this.h - (this.baseH-10); + this.setSvg( this.c[4], 'd', this.svgs.arrowUp ); + } else { + this.setSvg( this.c[4], 'd', this.svgs.arrowDown ); + } + + this.rSizeContent(); + + let t = this.h - this.baseH; + + this.zone.h = this.h; + + if(!first) this.parentHeight( t ); + + } + + close () { + + super.close(); + + if( this.up ) this.zone.y += this.h - (this.baseH-10); + + let t = this.h - this.baseH; + + this.h = this.baseH; + this.s[0].height = this.h + 'px'; + this.s[2].display = 'none'; + this.setSvg( this.c[4], 'd', this.svgs.arrow ); + + this.zone.h = this.h; + + this.parentHeight( -t ); + + } + + // ----- + + text ( txt ) { + + this.c[3].textContent = txt; + + } + + rSizeContent () { + + let i = this.length; + while(i--) this.listIn.children[i].style.width = this.ww + 'px'; + + } + + rSize () { + + super.rSize(); + + //Proto.prototype.rSize.call( this ); + + let s = this.s; + let w = this.sb; + let d = this.sa; + + if(s[2]=== undefined) return; + + s[2].width = w + 'px'; + s[2].left = d +'px'; + + s[3].width = w + 'px'; + s[3].left = d + 'px'; + + s[4].left = d + w - 17 + 'px'; + + this.ww = w; + if( this.max > this.maxHeight ) this.ww = w-this.ss; + if(this.isOpen) this.rSizeContent(); + + } + +} + +class Numeric extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.setTypeNumber( o ); + + this.allway = o.allway || false; + + this.isDown = false; + + this.value = [0]; + this.multy = 1; + this.invmulty = 1; + this.isSingle = true; + this.isAngle = false; + this.isVector = false; + + if( o.isAngle ){ + this.isAngle = true; + this.multy = Tools.torad; + this.invmulty = Tools.todeg; + } + + this.isDrag = o.drag || false; + + if( o.value !== undefined ){ + if(!isNaN(o.value)){ + this.value = [o.value]; + } else if( o.value instanceof Array ){ + this.value = o.value; + this.isSingle = false; + } else if( o.value instanceof Object ){ + this.value = []; + if( o.value.x !== undefined ) this.value[0] = o.value.x; + if( o.value.y !== undefined ) this.value[1] = o.value.y; + if( o.value.z !== undefined ) this.value[2] = o.value.z; + if( o.value.w !== undefined ) this.value[3] = o.value.w; + this.isVector = true; + this.isSingle = false; + } + } + + this.lng = this.value.length; + this.tmp = []; + + + + this.current = -1; + this.prev = { x:0, y:0, d:0, v:0 }; + + let cc = this.colors; + + // bg + this.c[2] = this.dom( 'div', this.css.basic + ' background:' + cc.select + '; top:4px; width:0px; height:' + (this.h-8) + 'px;' ); + + this.cMode = []; + + let i = this.lng; + while(i--){ + + if(this.isAngle) this.value[i] = (this.value[i] * 180 / Math.PI).toFixed( this.precision ); + this.c[3+i] = this.dom( 'div', this.css.txtselect + ' height:'+(this.h-4)+'px; color:' + cc.text + '; background:' + cc.back + '; borderColor:' + cc.border+'; border-radius:'+this.radius+'px;'); + if(o.center) this.c[2+i].style.textAlign = 'center'; + this.c[3+i].textContent = this.value[i]; + this.c[3+i].style.color = this.colors.text; + this.c[3+i].isNum = true; + + this.cMode[i] = 0; + + } + + // selection + this.selectId = 3 + this.lng; + this.c[this.selectId] = this.dom( 'div', this.css.txtselect + 'position:absolute; top:4px; height:' + (this.h-8) + 'px; padding:0px 0px; width:0px; color:' + cc.textSelect + '; background:' + cc.select + '; border:none; border-radius:0px;'); + + // cursor + this.cursorId = 4 + this.lng; + this.c[ this.cursorId ] = this.dom( 'div', this.css.basic + 'top:4px; height:' + (this.h-8) + 'px; width:0px; background:'+cc.text+';' ); + + this.init(); + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + let i = this.lng; + let t = this.tmp; + + + while( i-- ){ + if( l.x>t[i][0] && l.x= this.txl ) return 'text'; + else if( l.x >= this.sa ) return 'scroll'; + else return ''; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( this.isDown ) this.isDown = false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + if( name === 'scroll' ){ + this.isDown = true; + this.old = this.value; + this.mousemove( e ); + + } + + /*if( name === 'text' ){ + this.setInput( this.c[2], function(){ this.validate() }.bind(this) ); + }*/ + + return true; + + } + + mousemove ( e ) { + + let nup = false; + + let name = this.testZone( e ); + + if( name === 'scroll' ) { + this.mode(1); + this.cursor('w-resize'); + //} else if(name === 'text'){ + //this.cursor('pointer'); + } else { + this.cursor(); + } + + if( this.isDown ){ + + let n = ((( e.clientX - (this.zone.x+this.sa) - 3 ) / this.ww ) * this.range + this.min ) - this.old; + if(n >= this.step || n <= this.step){ + n = Math.floor( n / this.step ); + this.value = this.numValue( this.old + ( n * this.step ) ); + this.update( true ); + this.old = this.value; + } + nup = true; + } + + return nup; + + } + + wheel ( e ) { + + let name = this.testZone( e ); + + if( name === 'scroll' ) { + + let v = this.value - this.step * e.delta; + + if ( v > this.max ) { + v = this.isCyclic ? this.min : this.max; + } else if ( v < this.min ) { + v = this.isCyclic ? this.max : this.min; + } + + this.setValue(v); + this.old = v; + this.update( true ); + + return true; + + } + + return false; + + } + + //keydown: function ( e ) { return true; }, + + // ---------------------- + + validate () { + + let n = this.c[2].textContent; + + if(!isNaN( n )){ + this.value = this.numValue( n ); + this.update(true); + } + + else this.c[2].textContent = this.value + (this.isDeg ? '°':''); + + } + + + reset () { + + //this.clearInput(); + this.isDown = false; + this.mode(0); + + } + + mode ( mode ) { + + let s = this.s; + let cc = this.colors; + + switch(mode){ + case 0: // base + // s[2].border = '1px solid ' + this.colors.hide; + s[2].color = cc.text; + s[4].background = cc.back; + s[5].background = cc.text; + break; + case 1: // scroll over + //s[2].border = '1px dashed ' + this.colors.hide; + s[2].color = cc.textOver; + s[4].background = cc.back; + s[5].background = cc.textOver; + break; + /* case 2: + s[2].border = '1px solid ' + this.colors.borderSelect; + break; + case 3: + s[2].border = '1px dashed ' + this.colors.text;//this.colors.borderSelect; + break; + case 4: + s[2].border = '1px dashed ' + this.colors.hide; + break;*/ + + + } + } + + update ( up ) { + + let ww = Math.floor( this.ww * (( this.value - this.min ) / this.range )); + + if(this.model !== 3) this.s[5].width = ww + 'px'; + if(this.s[6]) this.s[6].left = ( this.sa + ww + 3 ) + 'px'; + this.c[2].textContent = this.value + (this.isDeg ? '°':''); + + if( up ) this.send(); + + } + + rSize () { + + super.rSize(); + + let w = this.sb - this.sc; + this.ww = w - 6; + + let tx = this.sc; + if(this.isUI || !this.simple) tx = this.sc+10; + this.txl = this.w - tx + 2; + + //let ty = Math.floor(this.h * 0.5) - 8; + + let s = this.s; + + s[2].width = (this.sc -6 )+ 'px'; + s[2].left = (this.txl +4) + 'px'; + //s[2].top = ty + 'px'; + s[3].left = this.sa + 'px'; + s[3].width = w + 'px'; + s[4].left = this.sa + 'px'; + s[4].width = w + 'px'; + s[5].left = (this.sa + 3) + 'px'; + + this.update(); + + } + +} + +class TextInput extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.cmode = 0; + + this.value = o.value || ''; + this.placeHolder = o.placeHolder || ''; + + this.allway = o.allway || false; + this.editable = o.edit !== undefined ? o.edit : true; + + this.isDown = false; + + let cc = this.colors; + + // text + this.c[2] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; color:' + cc.text + '; background:' + cc.back + '; borderColor:' + cc.border+'; border-radius:'+this.radius+'px;' ); + this.c[2].textContent = this.value; + + // selection + this.c[3] = this.dom( 'div', this.css.txtselect + 'position:absolute; top:4px; height:' + (this.h-8) + 'px; padding:0px 0px; width:0px; color:' + cc.textSelect + '; background:' + cc.select + '; border:none; border-radius:0px;'); + + // cursor + this.c[4] = this.dom( 'div', this.css.basic + 'top:4px; height:' + (this.h-8) + 'px; width:0px; background:'+cc.text+';' ); + + // fake + this.c[5] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; justify-content: center; font-style: italic; color:'+cc.border+';' ); + if( this.value === '' ) this.c[5].textContent = this.placeHolder; + + + + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.x >= this.sa ) return 'text'; + return ''; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if(!this.editable) return; + + if( this.isDown ){ + this.isDown = false; + return this.mousemove( e ); + } + + return false; + + } + + mousedown ( e ) { + + if(!this.editable) return; + + let name = this.testZone( e ); + + if( !this.isDown ){ + this.isDown = true; + if( name === 'text' ) this.setInput( this.c[2] ); + return this.mousemove( e ); + } + + return false; + + } + + mousemove ( e ) { + + if(!this.editable) return; + + let name = this.testZone( e ); + + //let l = this.local; + //if( l.x === -1 && l.y === -1 ){ return;} + + //if( l.x >= this.sa ) this.cursor('text'); + //else this.cursor(); + + let x = 0; + + if( name === 'text' ) this.cursor('text'); + else this.cursor(); + + if( this.isDown ) x = e.clientX - this.zone.x; + + return this.upInput( x - this.sa -3, this.isDown ); + + } + + update ( ) { + + this.c[2].textContent = this.value; + + } + + // ---------------------- + + reset () { + + this.cursor(); + + } + + // ---------------------- + // INPUT + // ---------------------- + + select ( c, e, w, t ) { + + let s = this.s; + let d = this.sa + 5; + s[4].width = '1px'; + s[4].left = ( d + e ) + 'px'; + + s[3].left = ( d + e ) + 'px'; + s[3].width = w + 'px'; + this.c[3].innerHTML = t; + + } + + unselect () { + + let s = this.s; + if(!s) return; + s[3].width = 0 + 'px'; + this.c[3].innerHTML = 't'; + s[4].width = 0 + 'px'; + + } + + validate ( force ) { + + if( this.allway ) force = true; + + this.value = this.c[2].textContent; + + if(this.value !== '') this.c[5].textContent = ''; + else this.c[5].textContent = this.placeHolder; + + if( !force ) return; + + this.send(); + + } + + // ---------------------- + // REZISE + // ---------------------- + + rSize () { + + super.rSize(); + + let s = this.s; + s[2].left = this.sa + 'px'; + s[2].width = this.sb + 'px'; + + s[5].left = this.sa + 'px'; + s[5].width = this.sb + 'px'; + + } + + +} + +class Title extends Proto { + + constructor( o = {} ) { + + super( o ); + + let prefix = o.prefix || ''; + + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:right; width:60px; line-height:'+ (this.h-8) + 'px; color:' + this.colors.text ); + + if( this.h === 31 ){ + + this.s[0].height = this.h + 'px'; + this.s[1].top = 8 + 'px'; + this.c[2].style.top = 8 + 'px'; + + } + + let s = this.s; + + s[1].justifyContent = o.align || 'left'; + //s[1].textAlign = o.align || 'left'; + s[1].fontWeight = o.fontWeight || 'bold'; + + + this.c[1].textContent = this.txt.substring(0,1).toUpperCase() + this.txt.substring(1).replace("-", " "); + this.c[2].textContent = prefix; + + this.init(); + + } + + text( txt ) { + + this.c[1].textContent = txt; + + } + + text2( txt ) { + + this.c[2].textContent = txt; + + } + + rSize() { + + super.rSize(); + this.s[1].width = this.w + 'px'; //- 50 + 'px'; + this.s[2].left = this.w + 'px';//- ( 50 + 26 ) + 'px'; + + } + + setColor( c ) { + this.s[1].color = c; + this.s[2].color = c; + } + +} + +class Select extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.value = o.value || ''; + + this.isDown = false; + + this.onActif = o.onActif || function(){}; + + o.prefix || ''; + + this.c[2] = this.dom( 'div', this.css.txt + this.css.button + ' top:1px; background:'+this.colors.button+'; height:'+(this.h-2)+'px; border:'+this.colors.buttonBorder+'; border-radius:15px; width:30px; left:10px;' ); + this.c[2].style.color = this.fontColor; + + this.c[3] = this.dom( 'div', this.css.txtselect + 'height:' + (this.h-4) + 'px; background:' + this.colors.inputBg + '; borderColor:' + this.colors.inputBorder+'; border-radius:'+this.radius+'px;' ); + this.c[3].textContent = this.value; + + let fltop = Math.floor(this.h*0.5)-7; + this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.svgs[ 'cursor' ], fill:this.fontColor, stroke:'none'}); + + this.stat = 1; + this.isActif = false; + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + if( l.x > this.sa && l.x < this.sa+30 ) return 'over'; + return '0' + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( this.isDown ){ + //this.value = false; + this.isDown = false; + //this.send(); + return this.mousemove( e ); + } + + return false; + + } + + mousedown ( e ) { + + let name = this.testZone( e ); + + if( !name ) return false; + + this.isDown = true; + //this.value = this.values[ name-2 ]; + //this.send(); + return this.mousemove( e ); + + } + + mousemove ( e ) { + + let up = false; + + let name = this.testZone( e ); + //let sel = false; + + + + //console.log(name) + + if( name === 'over' ){ + this.cursor('pointer'); + up = this.mode( this.isDown ? 3 : 2 ); + } else { + up = this.reset(); + } + + return up; + + } + + // ---------------------- + + apply ( v ) { + + v = v || ''; + + if( v !== this.value ) { + this.value = v; + this.c[3].textContent = this.value; + this.send(); + } + + this.mode(1); + + } + + update () { + + this.mode( 3 ); + + } + + mode ( n ) { + + let change = false; + let cc = this.colors; + + if( this.stat !== n ){ + + if( n===1 ) this.isActif = false; + if( n===3 ){ + if( !this.isActif ){ this.isActif = true; n=4; this.onActif( this ); } + else { this.isActif = false; } + } + + if( n===2 && this.isActif ) n = 4; + + this.stat = n; + + switch( n ){ + + case 1: this.s[ 2 ].color = cc.text; this.s[ 2 ].background = cc.button; break; // base + case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.over; break; // over + case 3: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.select; break; // down + case 4: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.action; break; // actif + + } + + change = true; + + } + + return change; + + + + } + + reset () { + + this.cursor(); + return this.mode( this.isActif ? 4 : 1 ); + + } + + text ( txt ) { + + this.c[3].textContent = txt; + + } + + rSize () { + + super.rSize(); + + let s = this.s; + s[2].left = this.sa + 'px'; + s[3].left = (this.sa + 40) + 'px'; + s[3].width = (this.sb - 40) + 'px'; + s[4].left = (this.sa+8) + 'px'; + + } + +} + +//import { Proto } from '../core/Proto.js'; + +class Selector extends Button { + + constructor( o = {} ) { + + if( o.selectable === undefined ) o.selectable = true; + super( o ); + + } + +} + +class Empty extends Proto { + + constructor( o = {} ) { + + o.isSpace = true; + o.margin = 0; + if(!o.h) o.h = 10; + super( o ); + this.init(); + + } + +} + +class Item extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.p = 100; + this.value = this.txt; + this.status = 1; + + this.itype = o.itype || 'none'; + this.val = this.itype; + + this.graph = this.svgs[ this.itype ]; + + let fltop = Math.floor(this.h*0.5)-7; + + this.c[2] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.graph, fill:this.colors.text, stroke:'none'}); + + this.s[1].marginLeft = 20 + 'px'; + + this.init(); + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mousemove ( e ) { + + this.cursor('pointer'); + + //up = this.modes( this.isDown ? 3 : 2, name ); + + } + + mousedown ( e ) { + + if( this.isUI ) this.main.resetItem(); + + this.selected( true ); + + this.send(); + + return true; + + } + + uiout () { + + if( this.isSelect ) this.mode(3); + else this.mode(1); + + } + + uiover () { + + if( this.isSelect ) this.mode(4); + else this.mode(2); + + } + + update () { + + } + + /*rSize () { + + super.rSize(); + + }*/ + + mode ( n ) { + + let change = false; + + if( this.status !== n ){ + + this.status = n; + let s = this.s, cc = this.colors; + + switch( n ){ + + case 1: this.status = 1; s[1].color = cc.text; s[0].background = 'none'; break; + case 2: this.status = 2; s[1].color = cc.textOver; s[0].background = cc.back; break; + case 3: this.status = 3; s[1].color = cc.textSelect; s[0].background = cc.select; break; + case 4: this.status = 4; s[1].color = cc.textOver; s[0].background = cc.over; break; + + } + + change = true; + + } + + return change; + + } + + reset () { + + this.cursor(); + // return this.mode( 1 ); + + } + + selected ( b ){ + + if( this.isSelect ) this.mode(1); + + this.isSelect = b || false; + + if( this.isSelect ) this.mode(3); + + } + + +} + +class Grid extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.values = o.values || []; + + if( typeof this.values === 'string' ) this.values = [ this.values ]; + this.lng = this.values.length; + + this.value = o.value || null; + + + this.isSelectable = o.selectable || false; + this.spaces = o.spaces || [5,3]; + this.bsize = o.bsize || [90,20]; + + if(o.h) this.bsize[1] = o.h; + this.bsizeMax = this.bsize[0]; + + + this.tmp = []; + this.stat = []; + this.grid = [ 2, Math.round( this.lng * 0.5 ) ]; + this.h = this.grid[1] * ( this.bsize[1] + this.spaces[1] ) + this.spaces[1]; + + this.c[1].textContent = ''; + this.c[2] = this.dom( 'table', this.css.basic + 'width:100%; top:'+(this.spaces[1]-2)+'px; height:auto; border-collapse:separate; border:none; border-spacing: '+(this.spaces[0]-2)+'px '+(this.spaces[1]-2)+'px;' ); + + let n = 0, b, td, tr, sel; + + this.res = -1; + this.isDown = false; + this.neverlock = true; + + this.buttons = []; + this.stat = []; + this.tmpX = []; + this.tmpY = []; + + let cc = this.colors; + + for( let i = 0; i < this.grid[1]; i++ ){ + + tr = this.c[2].insertRow(); + tr.style.cssText = 'pointer-events:none;'; + for( let j = 0; j < this.grid[0]; j++ ){ + + td = tr.insertCell(); + td.style.cssText = 'pointer-events:none;'; + + if( this.values[n] ){ + + sel = false; + if( this.values[n] === this.value && this.isSelectable ) sel = true; + + b = document.createElement( 'div' ); + b.style.cssText = this.css.txt + this.css.button + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; border:'+cc.borderSize+'px solid '+cc.border+'; left:auto; right:auto; border-radius:'+this.radius+'px;'; + b.style.background = sel ? cc.select : cc.button; + b.style.color = sel ? cc.textSelect : cc.text; + b.innerHTML = this.values[n]; + td.appendChild( b ); + + this.buttons.push(b); + this.stat.push(1); + + } else { + + b = document.createElement( 'div' ); + b.style.cssText = this.css.txt + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; text-align:center; left:auto; right:auto; background:none;'; + td.appendChild( b ); + + } + + if(j===0) b.style.cssText += 'float:right;'; + else b.style.cssText += 'float:left;'; + + n++; + + } + } + + this.init(); + + } + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return -1; + + let tx = this.tmpX; + let ty = this.tmpY; + + let id = -1; + let c = -1; + let line = -1; + let i = this.grid[0]; + while( i-- ){ + if( l.x > tx[i][0] && l.x < tx[i][1] ) c = i; + } + + i = this.grid[1]; + while( i-- ){ + if( l.y > ty[i][0] && l.y < ty[i][1] ) line = i; + } + + if(c!==-1 && line!==-1){ + id = c + (line*2); + if(id>this.lng-1) id = -1; + } + + return id; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + mouseup ( e ) { + + if( !this.isDown ) return false + + this.isDown = false; + if( this.res !== -1 ){ + this.value = this.values[this.res]; + this.send(); + } + + return this.mousemove( e ) + + } + + mousedown ( e ) { + + if( this.isDown ) return false + this.isDown = true; + return this.mousemove( e ) + + } + + mousemove ( e ) { + + let up = false; + this.res = this.testZone( e ); + + if( this.res !== -1 ){ + this.cursor('pointer'); + up = this.modes( this.isDown ? 3 : 2, this.res ); + } else { + up = this.reset(); + } + + return up; + + } + + // ---------------------- + // MODE + // ----------------------- + + modes ( N = 1, id = -1 ) { + + let i = this.lng, w, n, r = false; + + while( i-- ){ + + n = N; + w = this.isSelectable ? this.values[ i ] === this.value : false; + + if( i === id ){ + if( w && n === 2 ) n = 3; + } else { + n = 1; + if( w ) n = 4; + } + + if( this.mode( n, i ) ) r = true; + + } + + return r + + } + + mode ( n, id ) { + + let change = false; + let cc = this.colors, s = this.buttons; + let i = id; + + if( this.stat[id] !== n ){ + + this.stat[id] = n; + + switch( n ){ + + case 1: s[i].style.color = cc.text; s[i].style.background = cc.button; break; + case 2: s[i].style.color = cc.textOver; s[i].style.background = cc.overoff; break; + case 3: s[i].style.color = cc.textOver; s[i].style.background = cc.over; break; + case 4: s[i].style.color = cc.textSelect; s[i].style.background = cc.select; break; + + } + + change = true; + + } + + return change; + + } + + // ---------------------- + + reset () { + + this.res = -1; + this.cursor(); + return this.modes() + + } + + + label ( string, n ) { + + this.buttons[n].textContent = string; + + } + + icon ( string, y, n ) { + + this.buttons[n].style.padding = ( y || 0 ) +'px 0px'; + this.buttons[n].innerHTML = string; + + } + + testW () { + + let vw = this.spaces[0]*3 + this.bsizeMax*2, rz = false; + if( vw > this.w ) { + this.bsize[0] = ( this.w-(this.spaces[0]*3) ) * 0.5; + rz = true; + } else { + if( this.bsize[0] !== this.bsizeMax ) { + this.bsize[0] = this.bsizeMax; + rz = true; + } + } + + if( !rz ) return; + + let i = this.buttons.length; + while(i--) this.buttons[i].style.width = this.bsize[0] + 'px'; + + } + + rSize () { + + super.rSize(); + + this.testW(); + + let mid; + + this.tmpX = []; + this.tmpY = []; + + for( let j = 0; j < this.grid[0]; j++ ){ + + if(j===0){ + mid = ( this.w*0.5 ) - ( this.spaces[0]*0.5 ); + this.tmpX.push( [ mid-this.bsize[0], mid ] ); + } else { + mid = ( this.w*0.5 ) + ( this.spaces[0]*0.5 ); + this.tmpX.push( [ mid, mid+this.bsize[0] ] ); + } + + } + + mid = this.spaces[1]; + + for( let i = 0; i < this.grid[1]; i++ ){ + + this.tmpY.push( [ mid, mid + this.bsize[1] ] ); + mid += this.bsize[1] + this.spaces[1]; + + } + + } + +} + +class Pad2D extends Proto { + + constructor( o = {} ) { + + super( o ); + + this.autoWidth = false; + this.minw = this.w; + this.diam = o.diam || this.w; + + //this.margin = 15; + this.pos = new V2(0,0); + this.maxPos = 90; + + this.model = o.stype || 0; + if( o.mode !== undefined ) this.model = o.mode; + + this.min = o.min === undefined ? -1 : o.min; + this.max = o.max === undefined ? 1 : o.max; + + this.range = (this.max - this.min)*0.5; + + this.cmode = 0; + + + //console.log(this.range) + + + + + + this.precision = o.precision === undefined ? 2 : o.precision; + + /*this.bounds = {}; + this.bounds.x1 = o.x1 || -1; + this.bounds.x2 = o.x2 || 1; + this.bounds.y1 = o.y1 || -1; + this.bounds.y2 = o.y2 || 1; + + this.lerpX = this.lerp( this.margin, this.w - this.margin , this.bounds.x1, this.bounds.x2 ); + this.lerpY = this.lerp( this.margin, this.w - this.margin , this.bounds.y1, this.bounds.y2 ); + + this.alerpX = this.lerp( this.bounds.x1, this.bounds.x2, this.margin, this.w - this.margin ); + this.alerpY = this.lerp( this.bounds.y1, this.bounds.y2, this.margin, this.w - this.margin );*/ + + this.value = ( Array.isArray( o.value ) && o.value.length == 2 ) ? o.value : [ 0, 0 ]; + + + this.h = o.h || this.w + 10; + this.top = 0; + + this.c[0].style.width = this.w + 'px'; + + // Title + if( this.c[1] !== undefined ) { // with title + + this.c[1].style.width = '100%'; + this.c[1].style.justifyContent = 'center'; + this.top = 10; + this.h += 10; + + } + + let cc = this.colors; + + + // Value + this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+ ( this.h - 20 ) + 'px; width:100%; color:' + cc.text ); + this.c[2].textContent = this.value; + + // Pad + + let pad = this.getPad2d(); + + this.setSvg( pad, 'fill', cc.back, 0 ); + this.setSvg( pad, 'fill', cc.button, 1 ); + this.setSvg( pad, 'stroke', cc.back, 2 ); + this.setSvg( pad, 'stroke', cc.back, 3 ); + this.setSvg( pad, 'stroke', cc.text, 4 ); + + this.setSvg( pad, 'viewBox', '0 0 '+this.diam+' '+this.diam ); + this.setCss( pad, { width:this.diam, height:this.diam, left:0, top:this.top }); + + this.c[3] = pad; + + this.init(); + this.setValue(); + + } + + testZone ( e ) { + + let l = this.local; + + if( l.x === -1 && l.y === -1 ) return ''; + + if( l.y <= this.c[ 1 ].offsetHeight ) return 'title'; + else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text'; + else return 'pad'; + + /*if( ( l.x >= this.margin ) && ( l.x <= this.w - this.margin ) && ( l.y >= this.top + this.margin ) && ( l.y <= this.top + this.w - this.margin ) ) { + return 'pad'; + }*/ + + //return ''; + + } + + mouseup ( e ) { + + this.isDown = false; + return this.mode(0); + + } + + mousedown ( e ) { + + if ( this.testZone(e) === 'pad' ) { + + this.isDown = true; + this.mousemove( e ); + return this.mode(1); + } + + } + + mousemove ( e ) { + + if( !this.isDown ) return; + + let x = (this.w*0.5) - ( e.clientX - this.zone.x ); + let y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top ); + let r = 256 / this.diam; + + x = -(x*r); + y = -(y*r); + + x = Tools.clamp( x, -this.maxPos, this.maxPos ); + y = Tools.clamp( y, -this.maxPos, this.maxPos ); + + //let x = e.clientX - this.zone.x; + //let y = e.clientY - this.zone.y - this.top; + + /*if( x < this.margin ) x = this.margin; + if( x > this.w - this.margin ) x = this.w - this.margin; + if( y < this.margin ) y = this.margin; + if( y > this.w - this.margin ) y = this.w - this.margin;*/ + + //console.log(x,y) + + this.setPos( [ x , y ] ); + + this.update( true ); + + } + + mode ( mode ) { + + if( this.cmode === mode ) return false; + + let cc = this.colors; + + switch( mode ){ + case 0: // base + + this.s[2].color = cc.text; + this.setSvg( this.c[3], 'fill', cc.back, 0); + this.setSvg( this.c[3], 'fill', cc.button, 1); + this.setSvg( this.c[3], 'stroke', cc.back, 2); + this.setSvg( this.c[3], 'stroke', cc.back, 3); + this.setSvg( this.c[3], 'stroke', cc.text, 4 ); + + break; + case 1: // down + + this.s[2].color = cc.textSelect; + this.setSvg( this.c[3], 'fill', cc.backoff, 0); + this.setSvg( this.c[3], 'fill', cc.overoff, 1); + this.setSvg( this.c[3], 'stroke', cc.backoff, 2); + this.setSvg( this.c[3], 'stroke', cc.backoff, 3); + this.setSvg( this.c[3], 'stroke', cc.textSelect, 4 ); + + break; + } + + this.cmode = mode; + return true; + + + + } + + update ( up ) { + + //if( up === undefined ) up = true; + + this.c[2].textContent = this.value; + + this.updateSVG(); + + if( up ) this.send(); + + } + + updateSVG() { + + if ( this.model == 1 ) { + + this.setSvg( this.c[3], 'y1', this.pos.y, 2 ); + this.setSvg( this.c[3], 'y2', this.pos.y, 2 ); + + this.setSvg( this.c[3], 'x1', this.pos.x, 3 ); + this.setSvg( this.c[3], 'x2', this.pos.x, 3 ); + + } + + this.setSvg( this.c[3], 'cx', this.pos.x, 4 ); + this.setSvg( this.c[3], 'cy', this.pos.y, 4 ); + + } + + setPos ( p ) { + + //if( p === undefined ) p = [ this.w / 2, this.w / 2 ]; + + this.pos.set( p[0]+128 , p[1]+128 ); + + let r = 1/this.maxPos; + + this.value[0] = ((p[0]*r)*this.range).toFixed( this.precision ); + this.value[1] = ((p[1]*r)*this.range).toFixed( this.precision ); + + } + + setValue ( v, up = false ) { + + if( v === undefined ) v = this.value; + + /*if ( v[0] < this.bounds.x1 ) v[0] = this.bounds.x1; + if ( v[0] > this.bounds.x2 ) v[0] = this.bounds.x2; + if ( v[1] < this.bounds.y1 ) v[1] = this.bounds.y1; + if ( v[1] > this.bounds.y2 ) v[1] = this.bounds.y2;*/ + + this.value[0] = Math.min( this.max, Math.max( this.min, v[0] ) ).toFixed( this.precision ) * 1; + this.value[1] = Math.min( this.max, Math.max( this.min, v[1] ) ).toFixed( this.precision ) * 1; + + this.pos.set( ((this.value[0]/this.range)*this.maxPos)+128 , ((this.value[1]/this.range)*this.maxPos)+128 ); + + //console.log(this.pos) + + this.update( up ); + + } + + /*lerp( s1, s2, d1, d2, c = true ) { + + let s = ( d2 - d1 ) / ( s2 - s1 ); + + return c ? ( v ) => { + return ( ( v < s1 ? s1 : v > s2 ? s2 : v ) - s1 ) * s + d1 + } : ( v ) => { + return ( v - s1 ) * s + d1 + } + + }*/ + +} + +const add = function () { + + let a = arguments; + + let type, o, ref = false, n = null; + + if( typeof a[0] === 'string' ){ + + type = a[0]; + o = a[1] || {}; + + } else if ( typeof a[0] === 'object' ){ // like dat gui + + ref = true; + if( a[2] === undefined ) [].push.call(a, {}); + + type = a[2].type ? a[2].type : autoType( a[0][a[1]], a[2] ); + + o = a[2]; + o.name = a[1]; + if( type === 'list' ){ o.list = a[0][a[1]]; } + else o.value = a[0][a[1]]; + + } + + + + let name = type.toLowerCase(); + + if( name === 'group' ) o.add = add; + + switch( name ){ + + case 'bool': case 'boolean': n = new Bool(o); break; + case 'button': n = new Button(o); break; + case 'circular': n = new Circular(o); break; + case 'color': n = new Color(o); break; + case 'fps': n = new Fps(o); break; + case 'graph': n = new Graph(o); break; + case 'group': n = new Group(o); break; + case 'joystick': n = new Joystick(o); break; + case 'knob': n = new Knob(o); break; + case 'list': n = new List(o); break; + case 'numeric': case 'number': n = new Numeric(o); break; + case 'slide': n = new Slide(o); break; + case 'textInput': case 'string': n = new TextInput(o); break; + case 'title': case 'text': n = new Title(o); break; + case 'select': n = new Select(o); break; + case 'selector': n = new Selector(o); break; + case 'empty': case 'space': n = new Empty(o); break; + case 'item': n = new Item(o); break; + case 'grid': n = new Grid(o); break; + case 'pad2d': case 'pad': n = new Pad2D(o); break; + + } + + if( n !== null ){ + + if( ref ) n.setReferency( a[0], a[1] ); + return n; + + } + +}; + +const autoType = function ( v, o ) { + + let type = 'slide'; + + if( typeof v === 'boolean' ) type = 'bool'; + else if( typeof v === 'string' ){ + + if( v.substring(0,1) === '#' ) type = 'color'; + else type = 'string'; + + } else if( typeof v === 'number' ){ + + if( o.ctype ) type = 'color'; + else type = 'slide'; + + } else if( typeof v === 'array' && v instanceof Array ){ + + if( typeof v[0] === 'number' ) type = 'number'; + else if( typeof v[0] === 'string' ) type = 'list'; + + } else if( typeof v === 'object' && v instanceof Object ){ + + if( v.x !== undefined ) type = 'number'; + else type = 'list'; + + } + + return type + +}; + +/** + * @author lth / https://github.com/lo-th + */ + +class Gui { + + constructor( o = {} ) { + + this.isGui = true; + + this.name = 'gui'; + + // for 3d + this.canvas = null; + this.screen = null; + this.plane = o.plane || null; + + + + // color + if( o.config ) o.colors = o.config; + + if ( o.colors ) this.setConfig( o.colors ); + else this.colors = Tools.defineColor( o ); + + // style + this.css = Tools.cloneCss(); + + this.isReset = true; + this.tmpAdd = null; + //this.tmpH = 0 + + this.isCanvas = o.isCanvas || false; + this.isCanvasOnly = false; + + this.callback = o.callback === undefined ? null : o.callback; + + this.forceHeight = o.maxHeight || 0; + this.lockHeight = o.lockHeight || false; + + this.isItemMode = o.itemMode !== undefined ? o.itemMode : false; + + this.cn = ''; + + // size define + this.size = Tools.size; + if( o.p !== undefined ) this.size.p = o.p; + if( o.w !== undefined ) this.size.w = o.w; + if( o.h !== undefined ) this.size.h = o.h; + if( o.s !== undefined ) this.size.s = o.s; + + this.size.h = this.size.h < 11 ? 11 : this.size.h; + + // local mouse and zone + this.local = new V2().neg(); + this.zone = { x:0, y:0, w:this.size.w, h:0 }; + + // virtual mouse + this.mouse = new V2().neg(); + + this.h = 0; + //this.prevY = -1; + this.sw = 0; + + + + // bottom and close height + this.isWithClose = o.close !== undefined ? o.close : true; + this.bh = !this.isWithClose ? 0 : this.size.h; + + this.autoResize = o.autoResize === undefined ? true : o.autoResize; + + // default position + this.isCenter = o.center || false; + this.cssGui = o.css !== undefined ? o.css : (this.isCenter ? '' : 'right:10px;'); + + this.isOpen = o.open !== undefined ? o.open : true; + this.isDown = false; + this.isScroll = false; + + this.uis = []; + this.current = -1; + this.proto = null; + this.isEmpty = true; + this.decal = 0; + this.ratio = 1; + this.oy = 0; + + + this.isNewTarget = false; + + let cc = this.colors; + + this.content = Tools.dom( 'div', this.css.basic + ' width:0px; height:auto; top:0px; background:'+cc.content+'; ' + this.cssGui ); + + this.innerContent = Tools.dom( 'div', this.css.basic + 'width:100%; top:0; left:0; height:auto; overflow:hidden;'); + //this.innerContent = Tools.dom( 'div', this.css.basic + this.css.button + 'width:100%; top:0; left:0; height:auto; overflow:hidden;'); + this.content.appendChild( this.innerContent ); + + //this.inner = Tools.dom( 'div', this.css.basic + 'width:100%; left:0; ') + this.useFlex = true; + let flexible = this.useFlex ? 'display:flex; flex-flow: row wrap;' : ''; //' display:flex; justify-content:start; align-items:start;flex-direction: column; justify-content: center; align-items: center;'; + this.inner = Tools.dom( 'div', this.css.basic + flexible + 'width:100%; left:0; '); + this.innerContent.appendChild(this.inner); + + // scroll + this.scrollBG = Tools.dom( 'div', this.css.basic + 'right:0; top:0; width:'+ (this.size.s - 1) +'px; height:10px; display:none; background:'+cc.background+';'); + this.content.appendChild( this.scrollBG ); + + this.scroll = Tools.dom( 'div', this.css.basic + 'background:'+cc.button+'; right:2px; top:0; width:'+(this.size.s-4)+'px; height:10px;'); + this.scrollBG.appendChild( this.scroll ); + + // bottom button + this.bottomText = o.bottomText || ['open', 'close']; + + let r = cc.radius; + this.bottom = Tools.dom( 'div', this.css.txt + 'width:100%; top:auto; bottom:0; left:0; border-bottom-right-radius:'+r+'px; border-bottom-left-radius:'+r+'px; justify-content:center; height:'+this.bh+'px; line-height:'+(this.bh-5)+'px; color:' + cc.text+';' );// border-top:1px solid '+Tools.colors.stroke+';'); + this.content.appendChild( this.bottom ); + this.bottom.textContent = this.isOpen ? this.bottomText[1] : this.bottomText[0]; + this.bottom.style.background = cc.background; + + // + + this.parent = o.parent !== undefined ? o.parent : null; + this.parent = o.target !== undefined ? o.target : this.parent; + + if( this.parent === null && !this.isCanvas ){ + this.parent = document.body; + } + + if( this.parent !== null ) this.parent.appendChild( this.content ); + + if( this.isCanvas && this.parent === null ) this.isCanvasOnly = true; + + if( !this.isCanvasOnly ){ + this.content.style.pointerEvents = 'auto'; + } else { + this.content.style.left = '0px'; + this.content.style.right = 'auto'; + o.transition = 0; + } + + + // height transition + this.transition = o.transition || Tools.transition; + if( this.transition ) setTimeout( this.addTransition.bind( this ), 0 ); + + + this.setWidth(); + + if( this.isCanvas ) this.makeCanvas(); + + Roots.add( this ); + + } + + setTop( t, h ) { + + this.content.style.top = t + 'px'; + if( h !== undefined ) this.forceHeight = h; + this.calc(); + + Roots.needReZone = true; + + } + + addTransition(){ + + if( this.transition && !this.isCanvas ){ + this.innerContent.style.transition = 'height '+this.transition+'s ease-out'; + this.content.style.transition = 'height '+this.transition+'s ease-out'; + this.bottom.style.transition = 'top '+this.transition+'s ease-out'; + //this.bottom.addEventListener("transitionend", Roots.resize, true); + } + + } + + // ---------------------- + // CANVAS + // ---------------------- + + onDraw () {} + + makeCanvas () { + + this.canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', "canvas" ); + this.canvas.width = this.zone.w; + this.canvas.height = this.forceHeight ? this.forceHeight : this.zone.h; + + //console.log( this.canvas.width, this.canvas.height ) + + } + + draw ( force ) { + + if( this.canvas === null ) return; + + let w = this.zone.w; + let h = this.forceHeight ? this.forceHeight : this.zone.h; + Roots.toCanvas( this, w, h, force ); + + } + + ////// + + getDom () { + + return this.content; + + } + + noMouse () { + + this.mouse.neg(); + + } + + setMouse ( uv, flip = true ) { + + if(flip) this.mouse.set( Math.round( uv.x * this.canvas.width ), this.canvas.height - Math.round( uv.y * this.canvas.height ) ); + else this.mouse.set( Math.round( uv.x * this.canvas.width ), Math.round( uv.y * this.canvas.height ) ); + //this.mouse.set( m.x, m.y ); + + } + + setConfig ( o ) { + + // reset to default text + Tools.setText(); + this.colors = Tools.defineColor( o ); + + } + + setColors ( o ) { + + for( let c in o ){ + if( this.colors[c] ) this.colors[c] = o[c]; + } + + } + + setText ( size, color, font, shadow ) { + + Tools.setText( size, color, font, shadow ); + + } + + hide ( b ) { + this.content.style.visibility = b ? 'hidden' : 'visible'; + } + + display( v = false ) { + this.content.style.visibility = v ? 'visible' : 'hidden'; + } + + onChange ( f ) { + + this.callback = f || null; + return this; + + } + + // ---------------------- + // STYLES + // ---------------------- + + mode ( n ) { + + let needChange = false; + let cc = this.colors; + + if( n !== this.cn ){ + + this.cn = n; + + switch( n ){ + + case 'def': + Roots.cursor(); + this.scroll.style.background = cc.button; + this.bottom.style.background = cc.background; + this.bottom.style.color = cc.text; + break; + + //case 'scrollDef': this.scroll.style.background = this.colors.scroll; break; + case 'scrollOver': + Roots.cursor('ns-resize'); + this.scroll.style.background = cc.select; + break; + case 'scrollDown': + this.scroll.style.background = cc.select; + break; + + //case 'bottomDef': this.bottom.style.background = this.colors.background; break; + case 'bottomOver': + Roots.cursor('pointer'); + this.bottom.style.background = cc.backgroundOver; + this.bottom.style.color = cc.textOver; + break; + //case 'bottomDown': this.bottom.style.background = this.colors.select; this.bottom.style.color = '#000'; break; + + } + + needChange = true; + + } + + return needChange; + + } + + // ---------------------- + // TARGET + // ---------------------- + + clearTarget () { + + if( this.current === -1 ) return false; + if( this.proto.s ){ + // if no s target is delete !! + this.proto.uiout(); + this.proto.reset(); + } + + this.proto = null; + this.current = -1; + + ///console.log(this.isDown)//if(this.isDown)Roots.clearInput(); + + + + Roots.cursor(); + return true; + + } + + // ---------------------- + // ZONE TEST + // ---------------------- + + testZone ( e ) { + + let l = this.local; + if( l.x === -1 && l.y === -1 ) return ''; + + this.isReset = false; + + let name = ''; + + let s = this.isScroll ? this.zone.w - this.size.s : this.zone.w; + + if( l.y > this.zone.h - this.bh && l.y < this.zone.h ) name = 'bottom'; + else name = l.x > s ? 'scroll' : 'content'; + + return name; + + } + + // ---------------------- + // EVENTS + // ---------------------- + + handleEvent ( e ) { + + let type = e.type; + + let change = false; + let protoChange = false; + + let name = this.testZone( e ); + + if( type === 'mouseup' && this.isDown ) this.isDown = false; + if( type === 'mousedown' && !this.isDown ) this.isDown = true; + + if( this.isDown && this.isNewTarget ){ Roots.clearInput(); this.isNewTarget=false; } + + if( !name ) return; + + switch( name ){ + + case 'content': + + e.clientY = this.isScroll ? e.clientY + this.decal : e.clientY; + + if( Roots.isMobile && type === 'mousedown' ) this.getNext( e, change ); + + if( this.proto ) protoChange = this.proto.handleEvent( e ); + + if( type === 'mousemove' ) change = this.mode('def'); + if( type === 'wheel' && !protoChange && this.isScroll ) change = this.onWheel( e ); + + if( !Roots.lock ) { + this.getNext( e, change ); + } + + break; + case 'bottom': + + this.clearTarget(); + if( type === 'mousemove' ) change = this.mode('bottomOver'); + if( type === 'mousedown' ) { + this.isOpen = this.isOpen ? false : true; + this.bottom.textContent = this.isOpen ? this.bottomText[1] : this.bottomText[0]; + //this.setHeight(); + this.calc(); + this.mode('def'); + change = true; + } + + break; + case 'scroll': + + this.clearTarget(); + if( type === 'mousemove' ) change = this.mode('scrollOver'); + if( type === 'mousedown' ) change = this.mode('scrollDown'); + if( type === 'wheel' ) change = this.onWheel( e ); + if( this.isDown ) this.update( (e.clientY-this.zone.y)-(this.sh*0.5) ); + + break; + + + } + + if( this.isDown ) change = true; + if( protoChange ) change = true; + + if( type === 'keyup' ) change = true; + if( type === 'keydown' ) change = true; + + if( change ) this.draw(); + + } + + getNext ( e, change ) { + + + + let next = Roots.findTarget( this.uis, e ); + + if( next !== this.current ){ + this.clearTarget(); + this.current = next; + + this.isNewTarget = true; + + } + + if( next !== -1 ){ + this.proto = this.uis[ this.current ]; + this.proto.uiover(); + } + + } + + onWheel ( e ) { + + this.oy += 20*e.delta; + this.update( this.oy ); + return true; + + } + + // ---------------------- + // RESET + // ---------------------- + + reset ( force ) { + + if( this.isReset ) return; + + //this.resetItem(); + + this.mouse.neg(); + this.isDown = false; + + //Roots.clearInput(); + let r = this.mode('def'); + let r2 = this.clearTarget(); + + if( r || r2 ) this.draw( true ); + + this.isReset = true; + + //Roots.lock = false; + + } + + // ---------------------- + // ADD NODE + // ---------------------- + + add () { + + let a = arguments; + let ontop = false; + + if( typeof a[1] === 'object' ){ + + a[1].isUI = true; + a[1].main = this; + + ontop = a[1].ontop ? a[1].ontop : false; + + } else if( typeof a[1] === 'string' ){ + + if( a[2] === undefined ) [].push.call(a, { isUI:true, main:this }); + else { + a[2].isUI = true; + a[2].main = this; + //ontop = a[1].ontop ? a[1].ontop : false; + ontop = a[2].ontop ? a[2].ontop : false; + } + + } + + let u = add.apply( this, a ); + + if( u === null ) return; + + if( ontop ) this.uis.unshift( u ); + else this.uis.push( u ); + + this.calc(); + + this.isEmpty = false; + + return u + + } + + // remove one node + + remove ( n ) { + + if( n.dispose ) n.dispose(); + + } + + // call after uis clear + + clearOne ( n ) { + + let id = this.uis.indexOf( n ); + if ( id !== -1 ) { + //this.calc( - (this.uis[ id ].h + 1 ) ); + this.inner.removeChild( this.uis[ id ].c[0] ); + this.uis.splice( id, 1 ); + this.calc(); + } + + } + + // clear all gui + + empty() { + + //this.close(); + + let i = this.uis.length, item; + + while( i-- ){ + item = this.uis.pop(); + this.inner.removeChild( item.c[0] ); + item.dispose(); + } + + this.uis = []; + this.isEmpty = true; + this.calc(); + + } + + clear() { + + this.empty(); + + } + + dispose() { + + this.clear(); + if( this.parent !== null ) this.parent.removeChild( this.content ); + Roots.remove( this ); + + } + + + // ---------------------- + // ITEMS SPECIAL + // ---------------------- + + resetItem () { + + if( !this.isItemMode ) return; + + let i = this.uis.length; + while(i--) this.uis[i].selected(); + + } + + setItem ( name ) { + + if( !this.isItemMode ) return; + + name = name || ''; + this.resetItem(); + + if( !name ){ + this.update(0); + return + } + + let i = this.uis.length; + while(i--){ + if( this.uis[i].value === name ){ + this.uis[i].selected( true ); + if( this.isScroll ) this.update( ( i*(this.uis[i].h+1) )*this.ratio ); + } + } + + } + + + + // ---------------------- + // SCROLL + // ---------------------- + + upScroll ( b ) { + + this.sw = b ? this.size.s : 0; + this.oy = b ? this.oy : 0; + this.scrollBG.style.display = b ? 'block' : 'none'; + + if( b ){ + + this.total = this.h; + + this.maxView = this.maxHeight; + + this.ratio = this.maxView / this.total; + this.sh = this.maxView * this.ratio; + + this.range = this.maxView - this.sh; + + this.oy = Tools.clamp( this.oy, 0, this.range ); + + this.scrollBG.style.height = this.maxView + 'px'; + this.scroll.style.height = this.sh + 'px'; + + } + + this.setItemWidth( this.zone.w - this.sw ); + this.update( this.oy ); + + } + + update ( y ) { + + y = Tools.clamp( y, 0, this.range ); + + this.decal = Math.floor( y / this.ratio ); + this.inner.style.top = - this.decal + 'px'; + this.scroll.style.top = Math.floor( y ) + 'px'; + this.oy = y; + + } + + // ---------------------- + // RESIZE FUNCTION + // ---------------------- + + calcUis() { + + return Roots.calcUis( this.uis, this.zone, this.zone.y ) + } + + calc() { + + clearTimeout( this.tmp ); + this.tmp = setTimeout( this.setHeight.bind( this ), 10 ); + + } + + setHeight() { + + if( this.tmp ) clearTimeout( this.tmp ); + + this.zone.h = this.bh; + this.isScroll = false; + + if( this.isOpen ){ + + this.h = this.calcUis(); + + let hhh = this.forceHeight ? this.forceHeight + this.zone.y : window.innerHeight; + + this.maxHeight = hhh - this.zone.y - this.bh; + + let diff = this.h - this.maxHeight; + + if( diff > 1 ){ + + this.isScroll = true; + this.zone.h = this.maxHeight + this.bh; + + } else { + + this.zone.h = this.h + this.bh; + + } + + } + + this.upScroll( this.isScroll ); + + this.innerContent.style.height = this.zone.h - this.bh + 'px'; + this.content.style.height = this.zone.h + 'px'; + this.bottom.style.top = this.zone.h - this.bh + 'px'; + + + if( this.forceHeight && this.lockHeight ) this.content.style.height = this.forceHeight + 'px'; + + if( this.isCanvas ) this.draw( true ); + + } + + rezone () { + Roots.needReZone = true; + } + + setWidth ( w ) { + + if( w ) this.zone.w = w; + + this.zone.w = Math.floor( this.zone.w ); + + this.content.style.width = this.zone.w + 'px'; + + if( this.isCenter ) this.content.style.marginLeft = -(Math.floor(this.zone.w*0.5)) + 'px'; + + this.setItemWidth( this.zone.w - this.sw ); + + } + + setItemWidth ( w ) { + + let i = this.uis.length; + while(i--){ + this.uis[i].setSize( w ); + this.uis[i].rSize(); + } + + } + +} + +const REVISION = '4.0.8'; + +export { Files, Gui, Proto, REVISION, Tools, add }; diff --git a/games/3dcity/favicon.ico b/games/3dcity/favicon.ico new file mode 100644 index 0000000..3fb4ef8 Binary files /dev/null and b/games/3dcity/favicon.ico differ diff --git a/games/3dcity/index.html b/games/3dcity/index.html new file mode 100644 index 0000000..ea59f53 --- /dev/null +++ b/games/3dcity/index.html @@ -0,0 +1,166 @@ + + + +3D.CITY + + + + + + + + + + + +
    +
    + + + +
    +
    +
    +
    +
    +
    + + + + + diff --git a/games/3dcity/index_low.html b/games/3dcity/index_low.html new file mode 100644 index 0000000..475493c --- /dev/null +++ b/games/3dcity/index_low.html @@ -0,0 +1,236 @@ + + + +3D.CITY + + + + + + + + + + + + + + +
    +
    v 0.4
    + + +
    + + \ No newline at end of file diff --git a/games/3dcity/package.json b/games/3dcity/package.json new file mode 100644 index 0000000..21a2ddf --- /dev/null +++ b/games/3dcity/package.json @@ -0,0 +1,53 @@ +{ + "name": "3d.city", + "version": "0.8.0", + "description": "JavaScript city builder game", + "main": "build/Main.js", + "repository": "lo-th/3d.city", + "jsnext:main": "build/citygame.module.js", + "module": "build/citygame.module.js", + "files": [ + "package.json", + "LICENSE", + "README.md", + "build/citygame.js", + "build/citygame.min.js", + "build/citygame.module.js" + ], + "directories": { + "doc": "docs", + "example": "examples" + }, + "eslintConfig": { + "extends": "mdcs" + }, + "scripts": { + "build": "rollup -c utils/rollup.config.js", + "buildm": "rollup -c utils/Main_rollup.config.js", + "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/rollup.config.js -w -m inline\" \"servez -p 8111 --index\"", + "start": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/rollup.config.js -w -m inline\" \"http-server -c-1 -p 8111 -o index.html\"" + }, + "keywords": [ + "3d.city", + "city", + "builder" + ], + "author": "lo-th", + "license": "MIT", + "bugs": { + "url": "https://github.com/lo-th/3d.city/issues" + }, + "homepage": "http://lo-th.github.io/uil/", + "devDependencies": { + "@babel/core": "^7.12.16", + "@babel/plugin-proposal-class-properties": "^7.12.13", + "@babel/preset-env": "^7.12.16", + "@rollup/plugin-babel": "^5.3.0", + "@rollup/plugin-node-resolve": "^11.2.0", + "concurrently": "^5.3.0", + "regenerator-runtime": "^0.13.7", + "rollup": "^2.39.0", + "rollup-plugin-terser": "^7.0.2", + "servez": "^1.11.0" + } +} diff --git a/games/3dcity/sound/bop.mp3 b/games/3dcity/sound/bop.mp3 new file mode 100644 index 0000000..4b806fe Binary files /dev/null and b/games/3dcity/sound/bop.mp3 differ diff --git a/games/3dcity/sound/explosion-high.mp3 b/games/3dcity/sound/explosion-high.mp3 new file mode 100644 index 0000000..b1bb0a7 Binary files /dev/null and b/games/3dcity/sound/explosion-high.mp3 differ diff --git a/games/3dcity/sound/explosion-low.mp3 b/games/3dcity/sound/explosion-low.mp3 new file mode 100644 index 0000000..9eb60f3 Binary files /dev/null and b/games/3dcity/sound/explosion-low.mp3 differ diff --git a/games/3dcity/sound/heavytraffic.mp3 b/games/3dcity/sound/heavytraffic.mp3 new file mode 100644 index 0000000..3f53b88 Binary files /dev/null and b/games/3dcity/sound/heavytraffic.mp3 differ diff --git a/games/3dcity/sound/helico/1128.mp3 b/games/3dcity/sound/helico/1128.mp3 new file mode 100644 index 0000000..f4466e2 Binary files /dev/null and b/games/3dcity/sound/helico/1128.mp3 differ diff --git a/games/3dcity/sound/helico/1140.mp3 b/games/3dcity/sound/helico/1140.mp3 new file mode 100644 index 0000000..d8baaaf Binary files /dev/null and b/games/3dcity/sound/helico/1140.mp3 differ diff --git a/games/3dcity/sound/helico/2831.mp3 b/games/3dcity/sound/helico/2831.mp3 new file mode 100644 index 0000000..83bd223 Binary files /dev/null and b/games/3dcity/sound/helico/2831.mp3 differ diff --git a/games/3dcity/sound/helico/409801_SOUNDDOGS__ba.mp3 b/games/3dcity/sound/helico/409801_SOUNDDOGS__ba.mp3 new file mode 100644 index 0000000..cd3f4a1 Binary files /dev/null and b/games/3dcity/sound/helico/409801_SOUNDDOGS__ba.mp3 differ diff --git a/games/3dcity/sound/helico/409802_SOUNDDOGS__ba.mp3 b/games/3dcity/sound/helico/409802_SOUNDDOGS__ba.mp3 new file mode 100644 index 0000000..71c0258 Binary files /dev/null and b/games/3dcity/sound/helico/409802_SOUNDDOGS__ba.mp3 differ diff --git a/games/3dcity/sound/helico/8534.mp3 b/games/3dcity/sound/helico/8534.mp3 new file mode 100644 index 0000000..db4220a Binary files /dev/null and b/games/3dcity/sound/helico/8534.mp3 differ diff --git a/games/3dcity/sound/helico/8535.mp3 b/games/3dcity/sound/helico/8535.mp3 new file mode 100644 index 0000000..101f5b2 Binary files /dev/null and b/games/3dcity/sound/helico/8535.mp3 differ diff --git a/games/3dcity/sound/honkhonk-hi.mp3 b/games/3dcity/sound/honkhonk-hi.mp3 new file mode 100644 index 0000000..fcdcd1e Binary files /dev/null and b/games/3dcity/sound/honkhonk-hi.mp3 differ diff --git a/games/3dcity/sound/honkhonk-high.mp3 b/games/3dcity/sound/honkhonk-high.mp3 new file mode 100644 index 0000000..4ff39db Binary files /dev/null and b/games/3dcity/sound/honkhonk-high.mp3 differ diff --git a/games/3dcity/sound/honkhonk-low.mp3 b/games/3dcity/sound/honkhonk-low.mp3 new file mode 100644 index 0000000..47dc224 Binary files /dev/null and b/games/3dcity/sound/honkhonk-low.mp3 differ diff --git a/games/3dcity/sound/honkhonk-med.mp3 b/games/3dcity/sound/honkhonk-med.mp3 new file mode 100644 index 0000000..756a667 Binary files /dev/null and b/games/3dcity/sound/honkhonk-med.mp3 differ diff --git a/games/3dcity/sound/layzone.mp3 b/games/3dcity/sound/layzone.mp3 new file mode 100644 index 0000000..be71fa1 Binary files /dev/null and b/games/3dcity/sound/layzone.mp3 differ diff --git a/games/3dcity/sound/monster.mp3 b/games/3dcity/sound/monster.mp3 new file mode 100644 index 0000000..f3aec70 Binary files /dev/null and b/games/3dcity/sound/monster.mp3 differ diff --git a/games/3dcity/sound/original/bop.wav b/games/3dcity/sound/original/bop.wav new file mode 100644 index 0000000..a2cd48c Binary files /dev/null and b/games/3dcity/sound/original/bop.wav differ diff --git a/games/3dcity/sound/original/explosion-high.wav b/games/3dcity/sound/original/explosion-high.wav new file mode 100644 index 0000000..04fdc8f Binary files /dev/null and b/games/3dcity/sound/original/explosion-high.wav differ diff --git a/games/3dcity/sound/original/explosion-low.wav b/games/3dcity/sound/original/explosion-low.wav new file mode 100644 index 0000000..d9605d7 Binary files /dev/null and b/games/3dcity/sound/original/explosion-low.wav differ diff --git a/games/3dcity/sound/original/heavytraffic.wav b/games/3dcity/sound/original/heavytraffic.wav new file mode 100644 index 0000000..1c53cf7 Binary files /dev/null and b/games/3dcity/sound/original/heavytraffic.wav differ diff --git a/games/3dcity/sound/original/honkhonk-hi.wav b/games/3dcity/sound/original/honkhonk-hi.wav new file mode 100644 index 0000000..9eda496 Binary files /dev/null and b/games/3dcity/sound/original/honkhonk-hi.wav differ diff --git a/games/3dcity/sound/original/honkhonk-high.wav b/games/3dcity/sound/original/honkhonk-high.wav new file mode 100644 index 0000000..358eb55 Binary files /dev/null and b/games/3dcity/sound/original/honkhonk-high.wav differ diff --git a/games/3dcity/sound/original/honkhonk-low.wav b/games/3dcity/sound/original/honkhonk-low.wav new file mode 100644 index 0000000..d406be7 Binary files /dev/null and b/games/3dcity/sound/original/honkhonk-low.wav differ diff --git a/games/3dcity/sound/original/honkhonk-med.wav b/games/3dcity/sound/original/honkhonk-med.wav new file mode 100644 index 0000000..028d8e6 Binary files /dev/null and b/games/3dcity/sound/original/honkhonk-med.wav differ diff --git a/games/3dcity/sound/original/layzone.wav b/games/3dcity/sound/original/layzone.wav new file mode 100644 index 0000000..034e236 Binary files /dev/null and b/games/3dcity/sound/original/layzone.wav differ diff --git a/games/3dcity/sound/original/monster.wav b/games/3dcity/sound/original/monster.wav new file mode 100644 index 0000000..d9b02b4 Binary files /dev/null and b/games/3dcity/sound/original/monster.wav differ diff --git a/games/3dcity/sound/original/siren.wav b/games/3dcity/sound/original/siren.wav new file mode 100644 index 0000000..349ddcc Binary files /dev/null and b/games/3dcity/sound/original/siren.wav differ diff --git a/games/3dcity/sound/original/sorry.wav b/games/3dcity/sound/original/sorry.wav new file mode 100644 index 0000000..ce01b84 Binary files /dev/null and b/games/3dcity/sound/original/sorry.wav differ diff --git a/games/3dcity/sound/original/uhuh.wav b/games/3dcity/sound/original/uhuh.wav new file mode 100644 index 0000000..b05c02d Binary files /dev/null and b/games/3dcity/sound/original/uhuh.wav differ diff --git a/games/3dcity/sound/original/zombie-roar-5.wav b/games/3dcity/sound/original/zombie-roar-5.wav new file mode 100644 index 0000000..8182925 Binary files /dev/null and b/games/3dcity/sound/original/zombie-roar-5.wav differ diff --git a/games/3dcity/sound/siren.mp3 b/games/3dcity/sound/siren.mp3 new file mode 100644 index 0000000..42219ad Binary files /dev/null and b/games/3dcity/sound/siren.mp3 differ diff --git a/games/3dcity/sound/sorry.mp3 b/games/3dcity/sound/sorry.mp3 new file mode 100644 index 0000000..f853b41 Binary files /dev/null and b/games/3dcity/sound/sorry.mp3 differ diff --git a/games/3dcity/sound/uhuh.mp3 b/games/3dcity/sound/uhuh.mp3 new file mode 100644 index 0000000..96e85ae Binary files /dev/null and b/games/3dcity/sound/uhuh.mp3 differ diff --git a/games/3dcity/sound/zombie-roar-5.mp3 b/games/3dcity/sound/zombie-roar-5.mp3 new file mode 100644 index 0000000..7a6e922 Binary files /dev/null and b/games/3dcity/sound/zombie-roar-5.mp3 differ diff --git a/games/3dcity/src/Main.js b/games/3dcity/src/Main.js new file mode 100644 index 0000000..7089178 --- /dev/null +++ b/games/3dcity/src/Main.js @@ -0,0 +1,336 @@ + +import { Hub } from './city3d/Hub.js' +import { View } from './city3d/View.js' +import { saveAs } from './saveAs.js'; + + + +var d = document.getElementById('debug'); +const simulation_timestep = 30; +var stats = null; + +window.tilesData = null; +window.spriteData = null; +window.gameData = null; +window.powerData = null; +window.layerData = []; + +window.isMobile = false; + +window.trans = false; +window.newup = false; +window.powerup = false; + +//var storage; +window.directMessage = null +window.isWorker = true + +window.withHeight = false + +export class Main { + + static init ( DirectMessage ){ + + if( DirectMessage !== undefined ){ + + directMessage = DirectMessage; + isWorker = false + + } + + isMobile = testMobile(); + + //storage = window.localStorage; + + this.initWorker() + window.hub = new Hub() + window.view3d = new View( isMobile ); + + } + + // viex3d + + static initWorker (){ + + if( isWorker ){ + + window.cityWorker = new Worker( './build/citygame.min.js' ); + + //window.cityWorker = new Worker( 'js/worker.city.js' ); + cityWorker.postMessage = cityWorker.webkitPostMessage || cityWorker.postMessage; + //post({tell:"INIT", url:document.location.href.replace(/\/[^/]*$/,"/") + "build/city.3d.js", timestep:simulation_timestep }); + cityWorker.onmessage = message; + + post({ tell:"INIT", timestep:simulation_timestep }); + + } else { + + post({ tell:"INIT", timestep:simulation_timestep, returnMessage:message }); + + } + + } + + static start (){ + + hub.start(); + + //hub.message('Generating world...') + //post({ tell:"NEWMAP"}) + + } + + static sendTool( name ) { + post({tell:"TOOL", name:name}); + } + + static destroy( x, y ) { + + // TODO SOUND EXPLOSION + + post({tell:"MAPCLICK", x:x, y:y, single:true }); + } + + static mapClick( tool ) { + var p = view3d.raypos; + + if( p.x<0 && p.z<0 ) return + + //if( tool === 'bulldozer' ) view3d.testDestruct( p.x, p.y ) + post({tell:"MAPCLICK", x:p.x, y:p.z }); + } + + // HUB + + static selectTool( id ) { + view3d.selectTool( id ); + } + + static setTimeColors( id ) { + view3d.setTimeColors(id); + } + + static newMap( t ) { + + if( view3d.inMapGenation ) return; + + hub.generate( true ); + withHeight = t!=='NEW'; + view3d.inMapGenation = true; + setTimeout( post, 1000, {tell:"NEWMAP"}); + + } + + static playMap() { + + hub.initGameHub(); + view3d.startZoom(); + post({tell:"PLAYMAP"}); + + } + + static selectTool( id ) { + view3d.selectTool(id); + } + + static setDifficulty( t ) { + + //console.log( t ) + let n = 0; + if(t === 'MEDIUM') n = 1 + if(t === 'HARD') n = 2 + post({tell:"DIFFICULTY", n:n }); + } + + static setSpeed( n ) { + post({tell:"SPEED", n:n }); + } + + static getBudjet() { + post({ tell:"BUDGET" }); + } + + static setBudjet( budgetData ) { + post({ tell:"NEWBUDGET", budgetData:budgetData }); + } + + static getEval() { + post({ tell:"EVAL" }); + } + + static setDisaster(disaster){ + console.log(disaster); + post({ tell:"DISASTER", disaster:disaster }); + } + + static setOverlays( type ) { + //cityWorker.postMessage({ tell:"OVERLAYS", type:type }); + } + + static saveGame() { + var saveCity = []; + view3d.saveCityBuild(saveCity); + saveCity = JSON.stringify(saveCity); + // var cityData = view3d.saveCityBuild(); + post({ tell:"SAVEGAME", saveCity:saveCity }); + } + + static loadGame( atStart ) { + var isStart = atStart || false; + if( isStart ){ + hub.generate( true ); + view3d.inMapGenation = true; + } + post({ tell:"LOADGAME", isStart:isStart }); + } + + static newGameMap() { + console.log("new map"); + + //saveTextAsFile('test', 'game is saved'); + } + + static showStats() { + view3d.isWithStats = true; + } + + static hideStats() { + view3d.isWithStats = false; + } + + + + + +} + +function debug( txt ) { d.innerHTML += "
    "+txt; } + +function testMobile() { + if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) + || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) return true; + else return false; +} + + + +//======================================= +// SAVE LOAD +//======================================= + +function makeGameSave( gameData, key ) { + window.localStorage.setItem(key, gameData); + console.log("game is save", key); + + if( !view3d.isMobile ){ + var blob = new Blob([gameData], {type: "text/plain;charset=utf-8"}); + saveAs(blob, "city3d.json"); + } + +} + +function makeLoadGame( key, atStart ) { + + var isStart = atStart || false; + if(isStart){ + + // hub.initGameHub(); + } + + let savegame + if( view3d.tmpGameData ){ + savegame = view3d.tmpGameData + } else { + savegame = window.localStorage.getItem( key ) + } + + if(savegame){ + console.log("game is load"); + post({tell:"MAKELOADGAME", savegame:savegame, isStart:isStart}); + view3d.tmpGameData = null + + } else { + console.log("No loading game found"); + } +} + + +//======================================= +// CITY FLOW +//======================================= + +function post( e, buffer ) { + + if( isWorker ) cityWorker.postMessage( e, buffer ); + else directMessage( { data : e } ) + +} + +function message( e ) { + + var phase = e.data.tell; + if( phase == "READY"){ + + console.log(isWorker ? 'is Worker !!' : 'is Direct !!') + + } + if( phase == "NEWMAP"){ + + hub.generate( false ); + tilesData = e.data.tilesData; + view3d.paintMap( e.data.mapSize, e.data.island, withHeight ); + + } + + if( phase == "FULLREBUILD"){ + + //console.log('fullrebuild') + + if(e.data.isStart){ + hub.generate( false ); + } + view3d.fullRedraw = true; + tilesData = e.data.tilesData; + view3d.paintMap( e.data.mapSize, e.data.island, withHeight ); + view3d.loadCityBuild( e.data.cityData ); + + if( e.data.isStart ) view3d.startPlay() + } + if( phase == "BUILD"){ + view3d.build(e.data.x, e.data.y); + } + if( phase == "RUN"){ + tilesData = e.data.tilesData; + powerData = e.data.powerData; + spriteData = e.data.sprites; + layerData = e.data.layer; + + hub.updateCITYinfo(e.data.infos); + + newup = true; + powerup = e.data.infos[9] + + // update only layer change + view3d.updateLayer(); + view3d.moveSprite(); + view3d.showPower(); + + } + if( phase == "BUDGET"){ + hub.openBudget(e.data.budgetData); + } + if( phase == "QUERY"){ + hub.openQuery(e.data.queryTxt); + } + if( phase == "EVAL"){ + hub.openEval(e.data.evalData); + } + if( phase == "SAVEGAME"){ + makeGameSave(e.data.gameData, e.data.key); + + + } + if( phase == "LOADGAME"){ + makeLoadGame(e.data.key, e.data.isStart); + } +} \ No newline at end of file diff --git a/games/3dcity/src/Main_Traffic.js b/games/3dcity/src/Main_Traffic.js new file mode 100644 index 0000000..b00a19f --- /dev/null +++ b/games/3dcity/src/Main_Traffic.js @@ -0,0 +1,84 @@ + +import * as THREE from '../build/three.module.js' +import * as UIL from '../build/uil.module.js' +import { OrbitControls } from './jsm/controls/OrbitControls.js'; + +import { TrafficBase } from './TrafficBase.js' + + +let camera, scene, renderer, controls, traffic + +export class Main { + + static init (){ + + let grid = 1 + + renderer = new THREE.WebGLRenderer({antialias:true, alpha: true}); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + document.body.appendChild( renderer.domElement ); + + camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 200 ); + controls = new OrbitControls( camera, renderer.domElement ); + scene = new THREE.Scene(); + + let t = 19 + let decal = (t*0.5)-(grid*0.5) + let gridMesh = new THREE.GridHelper(t, t, 0x000000, 0x202020) + gridMesh.position.set(decal, -0.01, decal); + scene.add(gridMesh); + + camera.position.set( decal, 20, decal + 20 ) + controls.target.set( decal, 0, decal ) + controls.update() + + window.addEventListener( 'resize', onWindowResize, false ); + + const cgeo = new THREE.BoxGeometry( 1, 1, 1 ); + const cmat = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); + let cubemesh = new THREE.Mesh( cgeo, cmat ); + scene.add( cubemesh ); + + traffic = new TrafficBase( { callback:addGui } ) + scene.add( traffic ) + + + animate(); + + + //loadCarsModel() + + } + +} + +function onWindowResize() { + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize( window.innerWidth, window.innerHeight ); + +} + +function animate( t ) { + + requestAnimationFrame( animate ); + renderer.render( scene, camera ); + +} + + + +function addGui(){ + + let ui = new UIL.Gui( { w:300, h:26, close:true } ); + + ui.add( traffic.sets, 'timeFactor', { min:0.1, max:10, precision:2 } ).listen(); + ui.add( traffic.world, 'carsNumber', { min:0, max:500, precision:0 } ).listen(); + ui.add( traffic.world, 'instantSpeed', { min:0, max:1, precision:2, lock:true } ).listen(); + ui.add( traffic.sets, 'lightsFlip', { min:0, max:200, precision:0 } ).listen(); + + //ui.add( 'button', { name:'clear' } ).onChange( function(){ traffic.clearAll() } ); + +} diff --git a/games/3dcity/src/TrafficBase.js b/games/3dcity/src/TrafficBase.js new file mode 100644 index 0000000..0f9da8d --- /dev/null +++ b/games/3dcity/src/TrafficBase.js @@ -0,0 +1,446 @@ +import * as THREE from '../build/three.module.js' +import { GLTFLoader } from './jsm/loaders/GLTFLoader.js'; +import { DRACOLoader } from './jsm/loaders/DRACOLoader.js'; +import { OrbitControls } from './jsm/controls/OrbitControls.js'; +import { mergeBufferGeometries } from './jsm/utils/BufferGeometryUtils.js'; + +import { TrafficWorld, Traffic } from './traffic/Traffic.js'; + + +export class TrafficBase extends THREE.Group { + + constructor( o = {} ) { + + super() + + let isStandard = o.isStandard !== undefined ? o.isStandard : true + + this.position.y = 0.01 + + this.callback = o.callback || null + + this.cars = []; + this.roads = []; + this.inter = []; + this.mats = {} + + this.mapPath = './assets/textures/' + this.modelPath = './assets/models/' + + const loader = new THREE.TextureLoader() + this.grid = Traffic.settings.gridSize; + + this.sets = { + timeFactor:5, + lightsFlip:0 + } + + + + //const MATYPE = THREE.MeshBasicMaterial + const MATYPE = isStandard ? THREE.MeshStandardMaterial : THREE.MeshBasicMaterial + let op = isStandard ? { metalness:0.8, roughness:0.2 } : {} + + this.car_geo = {} + this.car_mat = []; + + + + this.car_mat[0] = new MATYPE( op ); + this.car_mat[1] = new MATYPE( op ); + this.car_mat[2] = new MATYPE( op ); + + let tx; + let img = new Image(); + img.onload = function(){ + this.generateRandomColor( img, this.car_mat[0] ); + this.generateRandomColor( img, this.car_mat[1] ); + this.generateRandomColor( img, this.car_mat[2] ); + }.bind(this) + img.src = this.mapPath + 'cars.png'; + + this.inter_geo = new THREE.PlaneGeometry( this.grid, this.grid ); + this.inter_geo.applyMatrix4(new THREE.Matrix4().makeRotationX(-Math.PI*0.5)); + + this.road_geo = new THREE.PlaneGeometry( this.grid, this.grid ); + this.road_geo.applyMatrix4(new THREE.Matrix4().makeRotationX(-Math.PI*0.5)); + + this.mats['inter_mat'] = new MATYPE( { map:loader.load( this.mapPath + 'roadx.png' ), ...op } ); + this.mats['road_mat'] = new MATYPE( { map:loader.load( this.mapPath + 'road.png' ), ...op } ); + + let debug = false + + if(debug){ + let t = 19//128//32 + let decal = (t*0.5)-(this.grid*0.5) + let gridMesh = new THREE.GridHelper(t, t, 0x000000, 0x202020) + gridMesh.position.set(decal, -0.01, decal); + this.add(gridMesh); + } + + + + this.loadCarsModel() + + + } + + clearAll(){ + + clearInterval( this.interval ) + + let i = this.children.length + while(i--){ + this.remove(this.children[i]) + } + + // geometry + + for(let g in this.car_geo){ + + this.car_geo[g].dispose() + + } + this.road_geo.dispose() + this.inter_geo.dispose() + + // material + + this.car_mat[0].dispose() + this.car_mat[1].dispose() + this.car_mat[2] + + this.mats['inter_mat'].dispose() + this.mats['road_mat'].dispose() + + this.cars = []; + this.roads = []; + this.inter = []; + this.mats = {} + + this.parent.remove(this) + + } + + init(){ + + Traffic.settings.gridSize = 1 + Traffic.settings.carScale = 0.05 + Traffic.settings.carSpeed = 0.05 + Traffic.settings.defaultTimeFactor = 5 + + this.world = new TrafficWorld(); + this.world.generateMap( 2, 2, 4, 1, 100 ); + //world.generateMap( 6, 6, 2, 1, 100 ); + //world.generateMap( 1, 1, 10, 0.5, 100 ); + //world.carsNumber = 100; + this.previousTime = 0; + this.sets.timeFactor = Traffic.settings.defaultTimeFactor; + this.sets.lightsFlip = Traffic.settings.lightsFlipInterval + + + this.interval = setInterval( this.update.bind(this), 1000/60); + + + if(this.callback) this.callback() + + //setTimeout(function(){ world.roadFromTo({x:4, y:3},{x:4,y:8}); }, 3000); + //setTimeout(function(){ world.roadFromTo({x:4, y:8},{x:10,y:8}); }, 4000); + //setTimeout(function(){ world.generateMap( 1, 1, 8, 1, 100 );; }, 6000); + + } + + update(){ + + Traffic.settings.lightsFlipInterval = this.sets.lightsFlip + + let now = Date.now(); + let dt = now - this.lastUpdate; + this.lastUpdate = now; + let time = Date.now(); + + let delta = (time - this.previousTime) || 0; + //if (delta > 1) { + if (delta > 100) { delta = 100; } + this.previousTime = time; + this.world.onTick( this.sets.timeFactor * delta / 1000 ); + //console.log(dt) + //var dt = 0.1; + //var dt = Math.random() + //world.onTick(0.1); + + let o0, o1, o2, o3, id; + + o0 = this.world.intersections.all(); + for (id in o0) { + this.addInter(o0[id]); + } + o1 = this.world.roads.all(); + for (id in o1) { + this.addRoad(o1[id]); + this.addSignals(o1[id]); + } + /*o2 = this.world.roads.all(); + for (id in o2) { + //road = _ref2[id]; + this.drawSignals(road); + }*/ + + // remove car + let i = this.world.toRemove.length; + while(i--){ this.removeCar( this.world.toRemove[i]); }; + this.world.clearTmpRemove(); + + o3 = this.world.cars.all(); + for (id in o3) { + this.addCar( o3[id], id ); + } + //} + + // window.requestAnimationFrame(update); + } + + generateRandomColor( img, mat ) { + + const canvas = document.createElement( 'canvas' ); + canvas.width = canvas.height = 1024; + const ctx = canvas.getContext('2d'); + let i, n=0, j=0; + + for( i=0; i<16; i++ ){ + ctx.beginPath(); + if(i!==11 && i!==15) ctx.fillStyle = this.randCarColor(); + ctx.rect(n*256, j*256, 256, 256); + ctx.fill(); + n++ + if(n==4){ n=0; j++; } + } + + ctx.drawImage(img, 0, 0, 1024,1024); + let tx = new THREE.Texture(canvas); + tx.needsUpdate = true; + tx.flipY = false; + mat.map = tx; + mat.needsUpdate = true; + + } + + loadCarsModel() { + + let geo = this.car_geo + let glbLoader = new GLTFLoader(); + let dracoLoader = new DRACOLoader().setDecoderPath( './build/draco/' ) + glbLoader.setDRACOLoader( dracoLoader ) + + glbLoader.load( this.modelPath + 'cars.glb', function ( gltf ) { + + gltf.scene.traverse( function ( node ) { + + if( node.isMesh ) geo[node.name] = node.geometry + + }) + + this.init() + + }.bind(this)) + + } + + addRoad( road ) { + + if ((road.source == null) || (road.target == null)) throw Error('invalid road'); + let id = road.id.substring(4); + if(this.roads[id]==null){ + //var sourceSide = road.sourceSide; + // var targetSide = road.targetSide + + let p0 = road.source.rect.pos(); + let p1 = road.target.rect.pos(); + let lngx = ((p1.x-p0.x)/this.grid); + let lngy = ((p1.y-p0.y)/this.grid); + let side = 0; + let dir = 1; + + //if( lngy===0 && lngx=== 0 ) return; + + if(lngy!=0) side=1; + let i; + + if(side==0){ + i = Math.abs(lngx)-1; + if(lngx<0) dir = -1; + }else{ + i = Math.abs(lngy)-1; + if(lngy<0) dir = -1; + } + + if( i<=0 ) return; + + //var g = new THREE.BufferGeometry(); + let m = new THREE.Matrix4(); + + let ng + let geoms = [] + + while(i--){ + if(side==0){ + m.makeTranslation((p0.x+(this.grid*dir)+((i*this.grid)*dir)), 0, p0.y); + m.multiply(new THREE.Matrix4().makeRotationY(Math.PI*0.5)); + }else{ + m.makeTranslation(p0.x, 0, (p0.y+(this.grid*dir)+((i*this.grid)*dir))); + } + + ng = this.road_geo.clone() + ng.applyMatrix4( m ) + + geoms.push( ng ) + + + //g.merge( road_geo, m ); + } + + + + let g = mergeBufferGeometries( geoms ) + + //var mtx = new THREE.Matrix4().makeScale(scaler,scaler,scaler) + //g.applyMatrix4( mtx ) + + + let c = new THREE.Mesh( g, this.mats['road_mat'] ); + this.add( c ); + + + /*var dir = 0, lng; + if(lng1>lng0) dir=1; + + if(dir == 0 ) lng = lng0/14; + else lng = lng1/14;*/ + + //console.log(lngx, lngy) + + //c.position.set(p0.x, 0.8,p0.y); + this.roads[id] = c; + } + /*; + var start = sourceSide.source.x;*/ + //var end = targetSide.target.center(); + //console.log(sourceSide) + + + + //(sourceSide.source, sourceSide.target, targetSide.source, targetSide.target) + } + + addSignals(cc, id) { + } + + + addCar( car ) { + + let id = car.id.substring(3); + if( this.cars[id]==null ){ + let r = this.randInt(0,2); + let c = new THREE.Mesh( this.car_geo[ Traffic.TYPE_OF_CARS[ car.type].m ], this.car_mat[r] ); + + this.add( c ); + c.position.set(10000, 0,0); + c.scale.set(5, 5, 5); + //c.scale.set(car.length, car.length/2, car.width); + this.cars[id] = c; + } else { + let p = car.pos; + let r = car.direction; + this.cars[id].position.set(p.x,0,p.y); + this.cars[id].rotation.y = -r+(Math.PI*0.5); + } + } + + removeCar( id ) { + + id = id.substring(3); + if(this.cars[id]!=null){ + this.remove( this.cars[id] ); + this.cars[id] = null; + } + + } + + addInter( intersection ) {//intersection + + let id = intersection.id.substring(12); + if( this.inter[id]==null ){ + this.inter[id] = new THREE.Mesh( this.inter_geo, this.mats['inter_mat'] ); + this.add( this.inter[id] ); + let type = intersection.roads.length; + // console.log(intersection.inRoads.length) + /*var i = type; + while(i){ + var sideId = intersection.roads[i].targetSideId; + console.log(sideId) + }*/ + /*switch(type){ + case 4: inter[id].material = inter_matx; break; + case 3: inter[id].material = inter_maty; break; + case 2: inter[id].material = inter_matz; break; + case 1: inter[id].material = inter_mate; break; + }*/ + let c = intersection.rect.pos(); + this.inter[id].position.set(c.x,0,c.y); + //inter[id].scale.set(1, 1, 1).multiplyScalar(scaler); + } else { + //var c = cc.rect; + let l = intersection.controlSignals.state[0]; + //if(l[0]==1)inter[id].material = inter_mat; + //else inter[id].material = inter_mat0; + + } + + } + + // some math function + + randColor() { return '#'+Math.floor(Math.random()*16777215).toString(16); } + + randCarColor () { + + let carcolors = [ + [0xFFFFFF, 0xD0D1D3, 0XEFEFEF, 0xEEEEEE],//white + [0x252122, 0x302A2B, 0x27362B, 0x2F312B],//black + [0x8D9495, 0xC1C0BC, 0xCED4D4, 0xBEC4C4],//silver + [0x939599, 0x424242, 0x5A5A5A, 0x747675],//gray + [0xC44920, 0xFF4421, 0x600309, 0xD9141E],//red + [0x4AD1FB, 0x275A63, 0x118DDC, 0x2994A6],//blue + [0xA67936, 0x874921, 0xD7A56B, 0x550007],//brown + [0x5FF12C, 0x188047, 0x8DAE29, 0x1AB619],//green + [0xFFF10A, 0xFFFFBD, 0xFCFADF, 0xFFBD0A],//yellow/gold + [0xB92968, 0x5C1A4F, 0x001255, 0xFFB7E7]//other + ]; + + let l, p = this.randInt(0,100), n = this.randInt(0,3); + + if(p<23)l=0; + else if(p<44)l=1; + else if(p<62)l=2; + else if(p<76)l=3; + else if(p<84)l=4; + else if(p<90)l=5; + else if(p<96)l=6; + else if(p<97)l=7; + else if(p<98)l=8; + else l=9; + + let base = carcolors[l][n]; + + let resl = base.toString(16); + if(resl.length<6) resl = '#0'+resl; + else resl = '#'+resl; + return resl; + } + + randInt( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + + + +} \ No newline at end of file diff --git a/games/3dcity/src/city3d/Base.js b/games/3dcity/src/city3d/Base.js new file mode 100644 index 0000000..416b2bc --- /dev/null +++ b/games/3dcity/src/city3d/Base.js @@ -0,0 +1,37 @@ +export const Base = { + + version: '0.8.0', + + toolSet: [ + {id:0, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 }, + {id:1, tool:'residential', geo:1, name:'R', build:1, size:3, sy:0.2, price:100, color:'lime' ,drag:1 }, + {id:2, tool:'commercial', geo:2, name:'C', build:1, size:3, sy:0.2, price:100, color:'blue' ,drag:1 }, + {id:3, tool:'industrial', geo:3, name:'I', build:1, size:3, sy:0.2, price:100, color:'yellow' ,drag:1 }, + + {id:4, tool:'police', geo:4, name:'', build:1, size:3, sy:1.2, price:500, color:'blue' ,drag:0 }, + {id:5, tool:'park', geo:5, name:'', build:1, size:1, sy:0.02, price:10, color:'darkgreen' ,drag:0 }, + {id:6, tool:'fire', geo:7, name:'', build:1, size:3, sy:1.2, price:500, color:'red' ,drag:0 }, + + {id:7, tool:'road', geo:0, name:'', build:0, size:1, sy:0.1, price:10, color:'black' ,drag:1 }, + {id:8, tool:'bulldozer', geo:0, name:'', build:0, size:1, sy:0, price:1, color:'deeppink' ,drag:1 }, + {id:9, tool:'rail', geo:0, name:'', build:0, size:1, sy:0.15, price:20, color:'brown' ,drag:1 }, + + {id:10, tool:'coal', geo:8, name:'', build:1, size:4, sy:2, price:3000, color:'gray' ,drag:0 }, + {id:11, tool:'wire', geo:0, name:'', build:0, size:1, sy:0.05, price:5 , color:'khaki' ,drag:1 }, + {id:12, tool:'nuclear', geo:9, name:'', build:1, size:4, sy:2, price:5000, color:'orange' ,drag:0 }, + + {id:13, tool:'port', geo:10, name:'', build:1, size:4, sy:0.5, price:3000, color:'dodgerblue' ,drag:0 }, + {id:14, tool:'stadium', geo:11, name:'', build:1, size:4, sy:2, price:5000, color:'yellowgreen',drag:0 }, + {id:15, tool:'airport', geo:12, name:'', build:1, size:6, sy:0.5, price:10000, color:'lightblue' ,drag:0 }, + + {id:16, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 }, + {id:17, tool:'query', geo:0, name:'?', build:0, size:1, sy:0, price:0, color:'cyan' ,drag:0 }, + {id:18, tool:'none', geo:0, name:'', build:0, size:0, sy:0, price:0, color:'none' ,drag:0 } + ], + + H: [ 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260 ], + R: [ 244, 265, 274, 283, 292, 301, 310, 319, 328, 337, 346, 355, 364, 373, 382, 391, 400, 409, 418 ], + C: [ 427, 436, 445, 454, 463, 475, 481, 490, 499, 508, 517, 526, 535, 544, 553, 562, 571, 580, 589, 598, 607 ], + I: [ 616, 625, 634, 643, 652, 661, 670, 679, 688 ], + +} \ No newline at end of file diff --git a/games/3dcity/src/city3d/BuildTool.js b/games/3dcity/src/city3d/BuildTool.js new file mode 100644 index 0000000..9c2772a --- /dev/null +++ b/games/3dcity/src/city3d/BuildTool.js @@ -0,0 +1,76 @@ +import * as THREE from '../../build/three.module.js' + +export class BuildTool extends THREE.Object3D { + + constructor () { + + super() + + + this.space = 0.075; + + let geo = new THREE.BufferGeometry() + let p1 = 0.5+(this.space*0.5); + let p2 = 0.5-(this.space*0.5); + let v = [-p2, 0, p2, -p1, 0, p1, p2, 0, p2, p1, 0, p1, p1, 0, -p1, p2, 0, -p2, -p2, 0, -p2, -p1, 0, -p1]; + let indices = [0, 1, 2, 1, 3, 2, 3, 4, 2, 2, 4, 5, 5, 4, 6, 4, 7, 6, 7, 1, 6, 1, 0, 6]; + let n = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]; + let uv = [1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0]; + + geo.setIndex( indices ); + geo.setAttribute( 'position', new THREE.Float32BufferAttribute( v, 3 ) ); + geo.setAttribute( 'normal', new THREE.Float32BufferAttribute( n, 3 ) ); + geo.setAttribute( 'uv', new THREE.Float32BufferAttribute( uv, 2 ) ); + + geo.morphAttributes.position = []; + + geo.morphAttributes.position.push( this.makeMorph(3) ); + geo.morphAttributes.position.push( this.makeMorph(4, 0.5) ); + geo.morphAttributes.position.push( this.makeMorph(6, 1.5) ); + + this.mesh = new THREE.Mesh( geo ) + + this.mesh.material.depthWrite = true; + this.mesh.material.depthTest = false; + //this.mesh.material.toneMapped = false; + this.mesh.material.morphTargets = false; + this.mesh.material.transparent = true; + this.mesh.material.renderOrder = 1 + + this.type = 'Tool'; + this.add(this.mesh) + + } + + makeMorph ( s, d = 0 ) { + + let p1 = (s*0.5)+(this.space*0.5); + let p2 = (s*0.5)-(this.space*0.5); + + let v = [-p2, 0, p2, -p1, 0, p1, p2, 0, p2, p1, 0, p1, p1, 0, -p1, p2, 0, -p2, -p2, 0, -p2, -p1, 0, -p1]; + + let i = v.length/3, n + while(i--){ n=i*3; v[n] += d; v[n+2] += d; } + + return new THREE.Float32BufferAttribute( v, 3 ); + + } + + set color( c ) { + this.mesh.material.color.set(c).convertSRGBToLinear() + } + + set resize ( s ) { + + this.mesh.morphTargetInfluences[ 0 ] = 0; + this.mesh.morphTargetInfluences[ 1 ] = 0; + this.mesh.morphTargetInfluences[ 2 ] = 0; + + if( s==3 ) this.mesh.morphTargetInfluences[ 0 ] = 1; + if( s==4 ) this.mesh.morphTargetInfluences[ 1 ] = 1; + if( s==6 ) this.mesh.morphTargetInfluences[ 2 ] = 1; + + } + +} + diff --git a/games/3dcity/src/city3d/Hub.js b/games/3dcity/src/city3d/Hub.js new file mode 100644 index 0000000..1619b5d --- /dev/null +++ b/games/3dcity/src/city3d/Hub.js @@ -0,0 +1,1227 @@ +import * as UIL from '../../build/uil.module.js' + +import { Main } from '../Main.js'; +import { Base } from './Base.js'; + + +//------------------------------------------------------// +// HUB INTERFACE // +//------------------------------------------------------// + + +export class Hub { + + constructor () { + + this.mapPath = './assets/textures/' + + // Mobile detection + this.isMobile = this.checkMobile(); + this.isSmallScreen = window.innerWidth < 768; + + // Listen for resize + window.addEventListener('resize', () => { + this.isSmallScreen = window.innerWidth < 768; + this.updateLayout(); + }); + + this.round = [ + '', + '', + '' + ].join("\n"); + + this.roundSelected = [ + '', + '', + '' + ].join("\n"); + + this.roundSelect = [ + '', + '', + '' + ].join("\n"); + + this.hub = document.getElementById('hub'); + this.full = null; + this.title = null; + + this.isIntro = true; + + this.timer = null; + this.bg = 1; + + this.R=null; + this.C=null; + this.I=null; + + this.isGen = false + + //this.rrr= null; + + //this.colors = ['#ffffff', '#338099']; + this.colors = ['rgba(255,255,255,1)', 'rgba(0,0,0,0.2)', 'rgba(0,0,0,1)', 'rgba(0,0,0,0.5)', 'rgba(0,0,0,0.8)', 'rgba(255,255,255,0.5)']; + + //this.radius = "-moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px;"; + this.radius = "-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;"; + this.radiusL = "-moz-border-top-left-radius: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px;"; + this.radiusL += "-moz-border-bottom-left-radius: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;"; + this.radiusR = "-moz-border-top-right-radius: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px;"; + this.radiusR += "-moz-border-bottom-right-radius: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px;"; + + this.radiusB = "-moz-border-bottom-left-radius: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;"; + this.radiusB += "-moz-border-bottom-right-radius: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px;"; + + this.windowsStyle = ' top:40px; left:10px; border:1px solid '+this.colors[1]+'; background:'+this.colors[3]+';'; + + + this.budgetWindow = null; + this.evaluationWindow = null; + this.disasterWindow = null; + this.exitWindow = null; + this.queryWindow = null; + this.overlaysWindow = null; + this.aboutWindow = null; + + + this.selector = null; + this.select = null; + + this.currentToolName = 0; + + this.disasterTypes = ['None', 'Monster', 'Fire', 'Flood', 'Crash', 'Meltdown', 'Tornado']; + this.disasterButtons = []; + + this.overlaysTypes = ['None', 'Density', 'Growth', 'Land value', 'Crime Rate', 'Pollution', 'Traffic', 'Power Grid', 'Fire', 'Police']; + this.overlaysButtons = []; + + + //this.intro(); + + + + this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:0px; left:0px; width:100%; height:100%; pointer-events:none; display:block; background:rgba(144,163,183,1); ' //+ this.degrade(); + + this.text = document.createElement('div'); + this.text.style.cssText = 'position:absolute; font-size:18px; left:calc(50% - 150px); top:calc(50% + 80px); width:300px; height:80px; pointer-events:none; text-align:center; font-weight: bold;'; + this.text.innerHTML = "欢迎"; + + + this.loader = document.getElementById('loader'); + this.loader.style.cssText = 'pointer-events:none; position:absolute; left:calc(50% - 100px); top:calc(50% - 100px); width:200px; height:200px;'; + + + /*this.link = document.createElement('div'); + this.link.style.cssText = 'position:absolute; left:10px; bottom:10px; width:50px; height:50px; pointer-events:auto; display:block;'; + this.link.innerHTML = '' + UIL.Tools.icon('github', '#DEDEDE', 50) + ''; + this.hub.appendChild( this.link )*/ + + this.link = UIL.add('button', { + target:this.hub, w:64, h:64, pos:{left:'10px', bottom:'10px'}, simple:true, + button:'#8397ac' + }).icon( UIL.Tools.icon('github', '#DEDEDE', 50) ).onChange( function(v){ let w = window.open('https://github.com/lo-th/3d.city','_blank'); } ) + + this.donate = UIL.add('button', { + target:this.hub, w:64, h:64, pos:{left:'84px', bottom:'10px'}, simple:true, + button:'#8397ac' + }).icon( UIL.Tools.icon('donate', '#DEDEDE', 50) ).onChange( function(v){ let w = window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8KTXA987XHYNQ','_blank'); } ) + + + + this.version = document.createElement('div'); + this.version.style.cssText = 'position:absolute; font-size:14px; right:10px; bottom:10px; text-align:right; width:100px; pointer-events:none; display:block;'; + this.version.innerHTML = "v " + Base.version; + this.hub.appendChild( this.version ) + + + + /*this.fullMid.appendChild( this.logo ); + this.fullMid.appendChild( this.title ); + this.fullMid.appendChild( this.subtitle );*/ + + this.hub.appendChild( this.full ); + this.hub.appendChild( this.loader ); + this.hub.appendChild( this.text ); + } + + message ( s ){ + + if( this.text ) this.text.innerHTML = s; + + } + + /*intro (){ + + this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:0px; left:0px; width:100%; height:100%; pointer-events:none; display:block; background:rgba(102,102,230,1); ' //+ this.degrade(); + + this.fullMid = document.createElement('div'); + this.fullMid.style.cssText ='position:absolute; top:10px; left:50%; width:300px; height:300px; margin-left:-150px; pointer-events:none; display:block;'; + + this.title = document.createElement('div'); + this.title.innerHTML = "3D.CITY"; + this.title.style.cssText = 'position:absolute; font-size:44px; top:50%; left:0; margin-top:-30px; width:300px; height:60px; pointer-events:none; text-align:center;'; + + this.subtitle = document.createElement('div'); + this.subtitle.style.cssText = 'position:absolute; font-size:14px; top:50%; left:0; margin-top:20px; width:300px; height:80px; pointer-events:none; text-align:center;'; + this.subtitle.innerHTML = "正在生成世界..."; + + this.logo = document.getElementById('logo'); + this.logo.style.display = 'block'; + + this.full.appendChild( this.fullMid ); + + this.fullMid.appendChild( this.logo ); + this.fullMid.appendChild( this.title ); + this.fullMid.appendChild( this.subtitle ); + + this.hub.appendChild( this.full ); + + }*/ + + start (){ + if(this.isIntro){ + this.timer = setInterval(this.fadding, 100, this); + } + } + + fadding (t){ + t.bg -= 0.1; + t.full.style.background = 'rgba(144,163,183,'+t.bg+')'; + // background-image:linear-gradient(60deg, white, black); + if(t.bg<=0){ + clearInterval(t.timer); + t.hub.removeChild(t.loader); + t.hub.removeChild(t.text); + t.hub.removeChild(t.full); + + console.log('done') + + //t.initPrevHub(); + t.isIntro = false; + } + } + + generate( b ) { + + if( b ){ + if(!this.isGen) { + this.hub.appendChild( this.loader ); + this.hub.appendChild( this.text ); + this.text.innerHTML = '正在生成地图...' + this.isGen = true + } + } else { + if( this.isGen ){ + this.hub.removeChild( this.loader ); + this.hub.removeChild( this.text ); + this.isGen = false + } + } + + } + + + + /*degrade (){ + var a = -160; + var p = [0, 30, 100] + var c0 = '#BFDDFF'; + var c1 = '#3C89CD'; + var c2 = '#214F77'; + var deg = [ + 'background:-webkit-gradient(linear, top, bottom, color-stop('+p[0]+'%,'+c0+'), color-stop('+p[1]+'%,'+c1+'), color-stop('+p[2]+'%,'+c2+'));', + 'background:-moz-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:-webkit-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:-o-linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);', + 'background:linear-gradient('+a+'deg, '+c0+' '+p[0]+'%, '+c1+' '+p[1]+'%, '+c2+' '+p[2]+'%);' + ].join("\n"); + return deg; + },*/ + + initPrevHub() { + + /*this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:10px; left:50%; margin-left:-150px; width:300px; height:300px; pointer-events:none;'; + this.full.id = 'fullStart';*/ + + //this.hub.appendChild( this.full ); + //var b1 = this.addButton(this.full, 'Play Game', [276,48,40], 'position:absolute; top:10px; left:0px;'); + //let b2 = this.addButton(this.full, 'New Map', [276, 26, 22], 'position:absolute; top:150px; left:0px;'); + //var b3 = this.addButton(this.full, 'Height Map', [120, 26, 22], 'position:absolute; top:150px; right:0px;'); + //let b4 = this.addButton(this.full, 'Load Map', [276, 26, 22], 'position:absolute; top:90px; left:0px;'); + //this.addSelector("DIFFICULTY", ['LOW', 'MEDIUM', 'HARD'], Main.setDifficulty, 0); + + //b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.playMap(); }, false); + //b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.newMap(); }, false); + // b3.addEventListener('click', function ( e ) { e.preventDefault(); Main.newHeightMap(); }, false); + //b4.addEventListener('click', function ( e ) { e.preventDefault(); Main.loadGame(true); }, false); + + } + + //--------------------------------------start hub + + initStartHub() { + + /* this.full = document.createElement('div'); + this.full.style.cssText ='position:absolute; top:10px; left:50%; margin-left:-150px; width:300px; height:300px; pointer-events:none;'; + this.full.id = 'fullStart'; + + this.hub.appendChild( this.full ); + var b1 = this.addButton(this.full, 'Play Game', [276,48,40], 'position:absolute; top:10px; left:0px;'); + var b2 = this.addButton(this.full, 'New Map', [120, 26, 22], 'position:absolute; top:150px; left:0px;'); + var b3 = this.addButton(this.full, 'Height Map', [120, 26, 22], 'position:absolute; top:150px; right:0px;'); + var b4 = this.addButton(this.full, 'Load Map', [276, 26, 22], 'position:absolute; top:90px; left:0px;'); + this.addSelector("DIFFICULTY", ['LOW', 'MEDIUM', 'HARD'], Main.setDifficulty, 0); + + b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.playMap(); }, false); + b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.newMap(); }, false); + b3.addEventListener('click', function ( e ) { e.preventDefault(); Main.newHeightMap(); }, false); + b4.addEventListener('click', function ( e ) { e.preventDefault(); Main.loadGame(true); }, false);*/ + + } + + + //--------------------------------------game hub + + initGameHub (){ + + this.link.dispose() + this.donate.dispose() + + var _this = this; + //this.removeSelector("DIFFICULTY"); + //this.clearElement('fullStart'); + + this.toolScroll = document.createElement('div'); + this.toolScroll.style.cssText = 'position:absolute; margin:0px; padding:0px; top:60px; right:12px; width:198px; max-height:calc(100% - 80px); overflow-y:auto; overflow-x:hidden; pointer-events:auto; touch-action:pan-y; -webkit-overflow-scrolling:touch;'; + this.hub.appendChild( this.toolScroll ); + + // prevent camera gestures when scrolling tools on mobile + this.toolScroll.addEventListener('touchstart', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('touchmove', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('pointerdown', (e) => e.stopPropagation(), { passive: true }); + this.toolScroll.addEventListener('pointermove', (e) => e.stopPropagation(), { passive: true }); + + this.toolSet = document.createElement('div'); + this.toolSet.style.cssText ='position:relative; margin:0px; padding:0px; width:198px; height:456px; pointer-events:none;'; + this.toolScroll.appendChild( this.toolSet ); + this.toolInfo = document.createElement('div'); + this.toolInfo.style.cssText ='position:absolute; top:15px; right:12px; width:198px; height:50px; pointer-events:none; font-size:16px;'; + this.hub.appendChild( this.toolInfo ); + this.toolInfo.innerHTML = "选择
    工具"; + + var b; + for(var i = 0; i<18; i++){ + b = this.addSVGButton(this.toolSet); + b.name = i+1; + } + + this.selector = document.createElement('div'); + this.selector.style.cssText = "position:absolute; top:0px; left:0px; pointer-events:none; display:none;" + this.selector.innerHTML = this.roundSelected; + this.toolSet.appendChild( this.selector ); + + this.select = document.createElement('div'); + this.select.style.cssText = "position:absolute; top:0px; left:0px; pointer-events:none; display:none;" + this.select.innerHTML = this.roundSelect; + this.toolSet.appendChild( this.select ); + + var img = document.createElement("img"); + img.src = this.mapPath + "interface.png"; + this.toolSet.appendChild(img); + img.style.cssText ='position:absolute; margin:0px; padding:0px; top:0px; right:0px; width:198px; height:396px; pointer-events:none;'; + + this.addSelector("Speed", ['II', '>', '>>', '>>>', '>>>'], Main.setSpeed, 2, [20,20,20,20,20]); + + var b1 = this.addButton(this.hub, '预算', [75,16,14], 'position:absolute; left:10px; top:-7px; font-weight:bold;', true); + b1.addEventListener('click', function ( e ) { e.preventDefault(); Main.getBudjet(); }, false); + + var b2 = this.addButton(this.hub, '评估', [75,16,14], 'position:absolute; left:110px; top:-7px; font-weight:bold;', true); + b2.addEventListener('click', function ( e ) { e.preventDefault(); Main.getEval(); }, false); + + /*var b3 = this.addButton(this.hub, 'Disaster', [75,16,14], 'position:absolute; left:210px; top:-7px; font-weight:bold;', true); + b3.addEventListener('click', function ( e ) { e.preventDefault(); _this.openDisaster(); }, false);*/ + + var b4 = this.addButton(this.hub, '退出', [75,16,14], 'position:absolute; left:310px; top:-7px; font-weight:bold;', true); + b4.addEventListener('click', function ( e ) { e.preventDefault(); _this.openExit(); }, false); + + var b5 = this.addButton(this.hub, '关于', [75,16,14], 'position:absolute; left:410px; top:-7px; font-weight:bold;', true); + b5.addEventListener('click', function ( e ) { e.preventDefault(); _this.openAbout(); }, false); + + + this.H = []; + + + this.roo = document.createElement('div'); + this.roo.style.cssText = "position:absolute; bottom:11px; left:10px; width:60px; height:60px; pointer-events:none; transform:rotate(45deg); "; + this.roo.style.cssText += "-moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; overflow:hidden; "; + this.hub.appendChild( this.roo ); + + var dd; + for(i = 0; i<4; i++){ + dd = document.createElement('div'); + if(i==0)dd.style.cssText = "position:absolute; top:0px; left:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer; background:#ffffff;"; + if(i==1)dd.style.cssText = "position:absolute; top:0px; right:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + if(i==2)dd.style.cssText = "position:absolute; bottom:0px; right:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + if(i==3)dd.style.cssText = "position:absolute; bottom:0px; left:0px; width:30px; height:30px; pointer-events:auto; cursor:pointer;"; + dd.name = i; + this.roo.appendChild( dd ); + dd.addEventListener('click', function ( e ) { + e.preventDefault(); + _this.hideoldSel(); + _this.H[this.name].style.background = '#ffffff'; + Main.setTimeColors(this.name); + }, false); + this.H[i]=dd; + } + + + var winter = document.createElement("div"); + winter.style.cssText = "position:absolute; bottom:80px; left:25px; width:30px; height:30px; pointer-events:auto; cursor:pointer; background:rgba(0,0,0,0); "; + winter.style.cssText += "-moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; "; + this.hub.appendChild(winter); + + winter.addEventListener('click', function ( e ) { + view3d.winterSwitch(); + if(view3d.isWinter) this.style.background = 'rgba(255,255,255,0.5);'; + else this.style.background = 'rgba(0,0,0,0);'; + }, false); + + this.bottomMenuImg = document.createElement("img"); + this.bottomMenuImg.src = this.mapPath + "basemenu.png"; + this.hub.appendChild(this.bottomMenuImg); + this.bottomMenuImg.style.cssText ='position:absolute; margin:0px; padding:0px; bottom:0px; left:0px; width:630px; height:120px; pointer-events:none;'; + + this.initCITYinfo(); + + // Apply responsive layout + this.updateLayout(); + } + + hideoldSel (){ + for(var i = 0; i<4; i++){ + this.H[i].style.background = 'none'; + } + } + + //-----------------------------------CITY INFO + + initCITYinfo (){ + + this.date = document.createElement('div'); + this.date.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:65px; text-align:right; font-weight:bold;'; + + this.money = document.createElement('div'); + this.money.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:295px; text-align:right; font-weight:bold;'; + + this.population = document.createElement('div'); + this.population.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:180px; text-align:right; font-weight:bold;'; + + this.score = document.createElement('div'); + this.score.style.cssText = 'font-size:14px; position:absolute; width:70px; height:19px; bottom:15px; left:410px; text-align:right; font-weight:bold;'; + + this.msg = document.createElement('div'); + this.msg.style.cssText = 'font-size:14px; letter-spacing:0.02em; position:absolute; width:420px; height:20px; bottom:44px; left:76px; text-align:left; color:'+this.colors[4]+'; font-weight:bold;'; + + this.hub.appendChild( this.date ); + this.hub.appendChild( this.money ); + this.hub.appendChild( this.population ); + this.hub.appendChild( this.score ); + this.hub.appendChild( this.msg ); + + this.initRCI(); + } + + updateCITYinfo (infos){ + this.date.innerHTML = infos[0]; + this.money.innerHTML = infos[4]; + this.population.innerHTML = infos[3]; + this.score.innerHTML = infos[2]; + + this.msg.innerHTML = infos[8]; + + this.updateRCI( infos[5], infos[6], infos[7] ); + } + + //-----------------------------------QUERY + + //-----------------------------------ALL WINDOW + + testOpen (){ + var t = ""; + if(this.budgetWindow !== null && this.budgetWindow.className == "open"){ + this.closeBudget(); + t = 'budget'; + } + if(this.evaluationWindow !== null && this.evaluationWindow.className == "open"){ + this.closeEval(); + t = 'evaluation'; + } + if(this.disasterWindow !== null && this.disasterWindow.className == "open"){ + this.closeDisaster(); + t = 'disaster'; + } + if(this.exitWindow !== null && this.exitWindow.className == "open"){ + this.closeExit(); + t = 'exit'; + } + if(this.queryWindow !== null && this.queryWindow.className == "open"){ + this.closeQuery(); + t = 'query'; + } + if(this.overlaysWindow !== null && this.overlaysWindow.className == "open"){ + this.closeOverlays(); + t = 'overlays'; + } + if(this.aboutWindow !== null && this.aboutWindow.className == "open"){ + this.closeAbout(); + t = 'about'; + } + + return t; + + } + + //-----------------------------------ABOUT WINDOW + + openAbout (data){ + var _this = this; + + var test = this.testOpen(); + if(test == 'about') return; + + if(this.aboutWindow == null){ + this.aboutWindow = document.createElement('div'); + this.aboutWindow.style.cssText = this.radius+ 'position:absolute; width:200px; height:210px; pointer-events:none; display:block;'+ this.getWindowStyle(200, 210); + this.hub.appendChild( this.aboutWindow ); + var bg1 = this.addButton(this.aboutWindow, 'X', [16,16,14], 'position:absolute; left:10px; top:10px;'); + bg1.addEventListener('click', function(e){ e.preventDefault(); _this.closeAbout(); }, false); + + this.fps = document.createElement('div'); + this.fps.style.cssText ='position:absolute; top:20px; left:60px; width:120px; height:20px; pointer-events:none; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.fps ); + this.abb = document.createElement('div'); + this.abb.style.cssText ='position:absolute; top:60px; left:10px; width:180px; height:180px; pointer-events:none; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.abb ); + this.linke = document.createElement('div'); + this.linke.style.cssText ='position:absolute; top:160px; left:10px; width:180px; height:20px; pointer-events:auto; font-size:12px; text-align:center; color:'+this.colors[0]+';'; + this.aboutWindow.appendChild( this.linke ); + + this.abb.innerHTML = "3D CITY

    All 3d side made by Lo.th
    Simulation from MicropolisJS


    More info and source
    "; + this.linke.innerHTML = "https://github.com/lo-th/3d.city"; + + + + } else { + this.aboutWindow.style.display = 'block'; + } + + Main.showStats(); + + this.aboutWindow.className = "open"; + + } + + upStats (fps, memory){ + this.fps.innerHTML = 'Fps: '+ fps + '
    geometry: ' + memory; + } + + closeAbout (){ + Main.hideStats(); + + this.aboutWindow.style.display = 'none'; + this.aboutWindow.className = "close"; + } + + + //-----------------------------------OVERLAYS WINDOW + + openOverlays (data){ + var _this = this; + + var test = this.testOpen(); + if(test == 'overlays') return; + + if(this.overlaysWindow == null){ + this.overlaysWindow = document.createElement('div'); + this.overlaysWindow.style.cssText = this.radius+ 'position:absolute; width:140px; height:420px; pointer-events:none; display:block;'+ this.getWindowStyle(140, 420); + this.hub.appendChild( this.overlaysWindow ); + + //var bg1 = this.addButton(this.overlaysWindow, 'X', [16,16,14], 'position:absolute; left:50px; top:10px;'); + //bg1.addEventListener('click', function(e){ e.preventDefault(); _this.closeQuery(); }, false); + + for(var i=0; i税收:" + taxesCollected + "¥"; + + this.budgetWindow.className = "open"; + + } + + applyBudget (){ + this.budgetWindow.style.display = 'none'; + this.budgetWindow.className = "close"; + + Main.setBudjet([this.taxRate, this.roadRate, this.fireRate, this.policeRate ]); + } + + closeBudget (){ + this.budgetWindow.style.display = 'none'; + this.budgetWindow.className = "close"; + } + + setBudgetValue (){ + this.setSliderValue('Tax', this.taxRate, 20, null); + this.setSliderValue('Roads', this.roadRate, 100, this.roadFund); + this.setSliderValue('Fire', this.fireRate, 100, this.fireFund); + this.setSliderValue('Police', this.policeRate, 100, this.policeFund); + } + + //-----------------------------------DISASTER WINDOW + + openDisaster (){ + var _this = this; + var test = this.testOpen(); + if(test == 'disaster') return; + if(this.disasterWindow == null){ + this.disasterWindow = document.createElement('div'); + this.disasterWindow.style.cssText =this.radius+ 'position:absolute; width:140px; height:300px; pointer-events:none; display:block;'+ this.getWindowStyle(140, 300); + this.hub.appendChild( this.disasterWindow ); + + for(var i=0; imax) value = max; + children[0].style.width = 170*(value/max)+'px'; + var labelMap = { Tax:'税率', Roads:'道路', Fire:'消防', Police:'警察' }; + var label = labelMap[t.name] || t.name; + + switch(t.name){ + case 'Tax': children[1].innerHTML = label+" "+value+'%'; this.taxRate = value; break; + case 'Roads': children[1].innerHTML = label+" "+value+'%('+this.roadFund+"¥ × "+value+"% = " + Math.floor(this.roadFund * (value / 100))+"¥)"; this.roadRate = value; break; + case 'Fire': children[1].innerHTML = label+" "+value+'%('+this.fireFund+"¥ × "+value+"% = " + Math.floor(this.fireFund * (value / 100))+"¥)"; this.fireRate = value; break; + case 'Police': children[1].innerHTML = label+" "+value+'%('+this.policeFund+"¥ × "+value+"% = " + Math.floor(this.policeFund * (value / 100))+"¥)"; this.policeRate = value; break; + } + } + } + + + //-----------------------------------RCI + + initRCI (){ + + var cont = document.createElement('div'); + cont.id = 'RCI'; + cont.style.cssText = 'font-size:10px; position:absolute; width:70px; height:70px; bottom:20px; right:20px;'; + + var txt = document.createElement('div'); + txt.style.cssText = 'font-size:10px; position:absolute; width:46px; height:14px; bottom:28px; left:10px; background:#cccccc; padding:0px 2px; letter-spacing:12px; text-align:center; color:#000000;'; + txt.innerHTML = "RCI"; + + this.R = document.createElement('div'); + this.R.id = 'R'; + this.R.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:10px; background:#30ff30;'; + cont.appendChild( this.R ); + + this.C = document.createElement('div'); + this.C.id = 'C'; + this.C.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:30px; background:#3030ff;'; + cont.appendChild( this.C ); + + this.I = document.createElement('div'); + this.I.id = 'I'; + this.I.style.cssText = 'position:absolute; width:10px; height:20px; bottom:42px; left:50px; background:#ffff30;'; + cont.appendChild( this.I ); + + cont.appendChild( txt ); + this.hub.appendChild( cont ); + } + + updateRCI (r,c,i){ + this.R.style.height = r/100+'px'; + this.C.style.height = c/100+'px'; + this.I.style.height = i/100+'px'; + //console.log(r/100) + if(r>0){ this.R.style.bottom ='42px';} + else { this.R.style.bottom =28+(r/100)+'px';} + + if(c>0){ this.C.style.bottom ='42px';} + else { this.C.style.bottom =28+(c/100)+'px'; } + + if(i>0){ this.I.style.bottom ='42px';;} + else { this.I.style.bottom =28+(i/100)+'px'; } + } + + //---------------------------------- SELECTOR + + addSelector ( type, names, fun, current, size){ + var _this = this; + var cont = document.createElement('div'); + //cont.style.cssText = 'position:absolute; width:300px; height:50px; font-size:16px; top:0; left:webkit-clac(50% -150px);'; + cont.style.cssText = 'font-size:14px; margin-top:10px; color:'+this.colors[0]+';'; + if(type=='Speed') cont.style.cssText = 'font-size:20px; position:absolute; bottom:8px; left:497px; '; + else cont.innerHTML = type+"
    "; + cont.id = type; + var t = []; + for(var i=0; i!==names.length; i++){ + t[i] = document.createElement( 'div' ); + // t[i].style.cssText = 'font-size:14px; border:4px solid '+this.colors[1]+'; background:'+this.colors[1]+';' + // t[i].style.cssText +=' width:70px; height:16px; margin:4px; padding:4px; pointer-events:auto; cursor:pointer; display:inline-block; font-weight:bold;' + this.radius; + t[i].style.cssText = 'font-size:14px; border:1px solid '+this.colors[5]+'; background:'+this.colors[1]+'; color:'+this.colors[0]+';'; + if(type=='Speed')t[i].style.cssText +=' width:70px; height:16px; margin-left:2px; padding:6px; pointer-events:auto; cursor:pointer; display:inline-block; '; + else t[i].style.cssText +=' width:70px; height:16px; margin:2px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; '; + + if(i==0) t[i].style.cssText += this.radiusL; + if(i==names.length-1)t[i].style.cssText += this.radiusR; + // if(type=='Speed'){ if(i>0) t[i].style.width = '16px'; else t[i].style.width = '60px'; } + if(size){if(size[i]){t[i].style.width = size[i] + 'px'; t[i].style.height = size[i] + 'px'; t[i].style.padding ='0px'; } else t[i].style.width = '60px';} + else t[i].style.width = '60px'; + t[i].className = "none"; + if(type!=='Speed')t[i].textContent = names[i]; + if(i==current){ + //t[i].style.border = '4px solid '+this.colors[0]; + t[i].style.backgroundColor = this.colors[5]; + t[i].style.color = this.colors[2]; + t[i].className = "select"; + } + t[i].name = i; + t[i].id = type+i; + cont.appendChild( t[i] ); + //t[i].addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[0]; }, false ); + //t[i].addEventListener( 'mouseout', function ( e ) { e.preventDefault(); if(this.className == 'none')this.style.border = '4px solid '+_this.colors[1]; }, false ); + + t[i].addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '1px solid '+_this.colors[0]; }, false ); + t[i].addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.border = '1px solid '+_this.colors[5]; }, false ); + + t[i].addEventListener( 'click', function ( e ) { e.preventDefault(); fun( this.name ); _this.setActiveSelector(this.name, type); }, false ); + } + //this.hub.appendChild( cont ); + if(type=='DIFFICULTY'){this.full.appendChild( cont ); cont.style.position = 'absolute'; cont.style.top = '200px';cont.style.width = '300px';} + else this.hub.appendChild( cont ); + } + + setActiveSelector (n, type) { + var h = 10, def; + while(h--){ + if(document.getElementById(type+h)){ + def = document.getElementById(type+h); + def.style.color = this.colors[0]; + // def.style.border = '4px solid '+_this.colors[1]; + def.style.backgroundColor = this.colors[1]; + def.className = "none"; + } + } + var select = document.getElementById(type+n); + //select.style.border = '4px solid '+_this.colors[0]; + select.style.backgroundColor = this.colors[5]; + select.style.color = this.colors[2]; + select.className = "select"; + } + + removeSelector (type){ + var h = 10, def; + var target = document.getElementById(type); + while(h--){ + if(document.getElementById(type+h)){ + def = document.getElementById(type+h); + target.removeChild(def); + } + } + this.full.removeChild(target); + } + + //------------------------------------------ TOOLS MENU + + showToolSelect (id){ + if(id.name !== this.currentToolName){ + this.currentToolName = id.name; + // var px = (id.getBoundingClientRect().left - _this.toolSet.getBoundingClientRect().left ); + //var py= (id.getBoundingClientRect().top - _this.toolSet.getBoundingClientRect().top ); + var px = (id.getBoundingClientRect().left - this.toolSet.getBoundingClientRect().left ); + var py= (id.getBoundingClientRect().top - this.toolSet.getBoundingClientRect().top ); + this.select.style.left = px + 'px'; + this.select.style.top = py + 'px'; + this.select.style.display = 'block'; + } else { + this.select.style.display = 'none'; + this.currentToolName = 0; + } + + Main.selectTool(this.currentToolName); + + } + + showToolInfo (id, t){ + const toolNameMap = { + none: '无', + residential: '住宅区', + commercial: '商业区', + industrial: '工业区', + police: '警察局', + park: '公园', + fire: '消防局', + road: '道路', + bulldozer: '推土机', + rail: '铁路', + coal: '煤电厂', + wire: '电线', + nuclear: '核电站', + port: '港口', + stadium: '体育场', + airport: '机场', + query: '查询', + }; + + const toolKey = Base.toolSet[id.name]?.tool; + const name = toolNameMap[toolKey] || toolKey || ''; + + if(id.name===16) t.toolInfo.innerHTML = '拖拽视角'; + else if(id.name===17) t.toolInfo.innerHTML = '查询信息'; + else if(id.name===18) t.toolInfo.innerHTML = '旋转视角'; + else t.toolInfo.innerHTML = name + '
    价格:' + Base.toolSet[id.name].price + "¥"; + } + + addSVGButton (target){ + var _this = this; + var b = document.createElement( 'div' ); + b.style.cssText =" margin:0px; padding:0px; width:66px; height:66px; pointer-events:auto; cursor:pointer; display:inline-block; line-height:0px; vertical-align: top;"; + b.innerHTML = this.round; + b.addEventListener( 'mouseover', function ( e ) { + e.preventDefault(); + var px = (this.getBoundingClientRect().left - _this.toolSet.getBoundingClientRect().left ); + var py= (this.getBoundingClientRect().top - _this.toolSet.getBoundingClientRect().top ) + _this.selector.style.left = px+ 'px'; + _this.selector.style.top = py + 'px'; + _this.selector.style.display = 'block'; + _this.showToolInfo(this, _this); + }, false ); + b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); _this.selector.style.display = 'none';}, false ); + b.addEventListener('click', function(e){ e.preventDefault(); _this.showToolSelect(this); }, false); + target.appendChild( b ); + return b; + } + + //------------------------------------------ DEF BUTTON + + addButton (target, name, size, style, top){ + var _this = this; + if(!size) size = [128, 30, 22]; + //var b = this.createLabel(name, size, true); + var b = document.createElement( 'div' ); + + //var defStyle = 'font-size:'+size[2]+'px; border:4px solid '+this.colors[1]+'; background:'+this.colors[1]+'; width:'+size[0]+'px; height:'+size[1]+'px;' + //defStyle += 'margin:4px; padding:4px; pointer-events:auto; cursor:pointer; display:inline-block; font-weight:bold;' + this.radius; + + var defStyle = 'font-size:'+size[2]+'px; border:1px solid '+this.colors[5]+'; background:'+this.colors[1]+'; width:'+size[0]+'px; height:'+size[1]+'px; color:'+this.colors[0]+';'; + if(top)defStyle += 'margin:4px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; ' + this.radiusB; + else defStyle += 'margin:4px; padding:7px; pointer-events:auto; cursor:pointer; display:inline-block; ' + this.radius; + + b.textContent = name; + if(style) b.style.cssText = defStyle+ style; + else b.style.cssText = defStyle+ 'margin-top:20px;'; + + // b.addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[0]; this.style.backgroundColor = _this.colors[0]; this.style.color = _this.colors[1]; }, false ); + // b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.border = '4px solid '+_this.colors[1]; this.style.backgroundColor = _this.colors[1]; this.style.color = _this.colors[0]; }, false ); + + b.addEventListener( 'mouseover', function ( e ) { e.preventDefault(); this.style.backgroundColor = _this.colors[5];this.style.color = _this.colors[2]; }, false ); + b.addEventListener( 'mouseout', function ( e ) { e.preventDefault(); this.style.backgroundColor = _this.colors[1];this.style.color = _this.colors[0]; }, false ); + + target.appendChild( b ); + + return b; + } + + clearElement (id){ + var el = document.getElementById(id); + var children = el.childNodes; + var i = children.length; + while(i--) el.removeChild( children[i] ); + this.hub.removeChild( el ); + } + + //------------------------------------------ MOBILE SUPPORT + + getWindowStyle(width, height) { + const w = window.innerWidth; + const h = window.innerHeight; + + // On small screens, center the window + if (w < 500 || this.isMobile) { + const left = Math.max(10, (w - width) / 2); + const top = Math.max(60, (h - height) / 3); + return ` top:${top}px; left:${left}px; border:1px solid ${this.colors[1]}; background:${this.colors[3]};`; + } + return this.windowsStyle; + } + + checkMobile() { + return navigator.userAgent.match(/Android/i) || + navigator.userAgent.match(/webOS/i) || + navigator.userAgent.match(/iPhone/i) || + navigator.userAgent.match(/iPad/i) || + navigator.userAgent.match(/iPod/i) || + navigator.userAgent.match(/BlackBerry/i) || + navigator.userAgent.match(/Windows Phone/i) || + window.innerWidth < 768; + } + + updateLayout() { + if (!this.toolSet && !this.toolScroll) return; + + const w = window.innerWidth; + const h = window.innerHeight; + + // Tool list: keep buttons large, scroll vertically when space is limited + if (this.toolScroll) { + const top = w < 600 ? 40 : w < 768 ? 50 : 60; + this.toolScroll.style.top = `${top}px`; + this.toolScroll.style.maxHeight = `${Math.max(240, h - top - 20)}px`; + } + + // Update tool info + if (this.toolInfo) { + if (w < 600) { + this.toolInfo.style.transform = 'scale(0.6)'; + this.toolInfo.style.transformOrigin = 'top right'; + } else if (w < 768) { + this.toolInfo.style.transform = 'scale(0.75)'; + this.toolInfo.style.transformOrigin = 'top right'; + } else { + this.toolInfo.style.transform = 'scale(1)'; + } + } + + // Update bottom menu image + if (this.bottomMenuImg) { + if (w < 630) { + const menuScale = w / 630; + this.bottomMenuImg.style.transform = `scale(${menuScale})`; + this.bottomMenuImg.style.transformOrigin = 'bottom left'; + } else { + this.bottomMenuImg.style.transform = 'scale(1)'; + } + } + + // Update city info positions for small screens + this.updateCityInfoLayout(w); + } + + updateCityInfoLayout(w) { + if (!this.date) return; + + if (w < 480) { + const scale = w / 480; + if (this.date) this.date.style.transform = `scale(${scale})`; + if (this.money) this.money.style.transform = `scale(${scale})`; + if (this.population) this.population.style.transform = `scale(${scale})`; + if (this.score) this.score.style.transform = `scale(${scale})`; + if (this.msg) { + this.msg.style.width = (w - 80) + 'px'; + this.msg.style.fontSize = '12px'; + } + } else if (w < 630) { + const scale = w / 630; + if (this.date) { + this.date.style.transform = `scale(${scale})`; + this.date.style.transformOrigin = 'bottom left'; + } + if (this.money) { + this.money.style.transform = `scale(${scale})`; + this.money.style.transformOrigin = 'bottom left'; + } + if (this.population) { + this.population.style.transform = `scale(${scale})`; + this.population.style.transformOrigin = 'bottom left'; + } + if (this.score) { + this.score.style.transform = `scale(${scale})`; + this.score.style.transformOrigin = 'bottom left'; + } + if (this.msg) { + this.msg.style.width = (w - 80) + 'px'; + } + } else { + if (this.date) this.date.style.transform = 'scale(1)'; + if (this.money) this.money.style.transform = 'scale(1)'; + if (this.population) this.population.style.transform = 'scale(1)'; + if (this.score) this.score.style.transform = 'scale(1)'; + if (this.msg) this.msg.style.width = '420px'; + } + } +} diff --git a/games/3dcity/src/city3d/Pool.js b/games/3dcity/src/city3d/Pool.js new file mode 100644 index 0000000..b8ef4a6 --- /dev/null +++ b/games/3dcity/src/city3d/Pool.js @@ -0,0 +1,543 @@ +import * as THREE from '../../build/three.module.js' +import { GLTFLoader } from '../jsm/loaders/GLTFLoader.js'; +import { DRACOLoader } from '../jsm/loaders/DRACOLoader.js'; +import { RGBELoader } from '../jsm/loaders/RGBELoader.js'; + +export class Pool { + + constructor( callback, tileSize=64, normal=true, roughness=false, pixel=false, env=true ) { + + this.sky = 'day'; + + this.callback = callback; + + this.tileSize = tileSize + this.isWithNormal = normal + this.isWithRoughness = roughness + this.isPixelStyle = pixel + this.isWithEnv = env + + this.loaderGLB = new GLTFLoader(); + let dracoLoader = new DRACOLoader().setDecoderPath( './build/draco/' ) + this.loaderGLB.setDRACOLoader( dracoLoader ) + + this.mapPath = './assets/textures/' + this.modelPath = './assets/models/' + + this.modelSrc = [ 'cars', 'world' ]; + + this.imgSrc = ['tiles.png','town.png','building.png', 'cars.png' ]; + + if( this.isWithNormal ) this.imgSrc.push( 'tiles_n.png', 'building_n.png', 'town_n.png' ) + if( this.isWithRoughness ) this.imgSrc.push( 'tiles_r.png', 'building_r.png', 'town_r.png' ) + this.imgSrc.push( 'border.jpg', 'border_a.jpg' ) + + this.imgs = []; + this.num = 0; + + this.tiles = { + normal:[], + roughness:[], + texture:[], + } + + this.color = { + ground:'#c68564', + normal:'#8080ff', + snow:'#e6f0ff', + white:'#ffffff', + lightGrey:'#CCCCCC', + metal:'#AAAAAA', + sky:'#8397ac', + } + + this.textures = {} + this.geos = {} + + if (this.isWithEnv) this.loadEnvmap() + else this.loadImages() + + } + + displayMessage( str ){ + + if( hub ) hub.message( str ) + + } + + + //----------------------------------- ENVMAP + + loadEnvmap() { + + this.displayMessage( 'Loading envmap ...' ) + + new RGBELoader().load( + this.mapPath + this.sky + '.hdr', + function ( texture ) { + + this.env = texture; + this.loadImages(); + + }.bind(this), + undefined, + function ( err ) { + console.warn('[3dcity] Failed to load envmap, continuing without it:', err); + this.env = null; + this.loadImages(); + }.bind(this) + ); + + } + + + //----------------------------------- TEXTURES + + loadImages() { + + this.displayMessage( 'Loading images ...' ) + + let n = this.num; + let url = this.imgSrc[n] + let name = url.substring( url.lastIndexOf('/')+1, url.lastIndexOf('.') ); + + + this.imgs[name] = new Image(); + this.imgs[name].onload = function(){ + this.num++; + if( this.num === this.imgSrc.length ) this.defineCanvas(); + else this.loadImages(); + }.bind(this); + this.imgs[name].onerror = function(err){ + console.warn('[3dcity] Failed to load image:', url, err); + this.num++; + if( this.num === this.imgSrc.length ) this.defineCanvas(); + else this.loadImages(); + }.bind(this); + this.imgs[name].src = this.mapPath + url; + + } + + + + defineCanvas() { + + this.num = 0; + + this.canvas = { + town: this.makeCanvas( 'town' ), + building: this.makeCanvas( 'building' ), + tiles: this.makeCanvas( 'tiles', true ), + } + + if( this.isWithNormal ) this.canvas[ 'tiles_n' ] = this.makeCanvas( 'tiles_n', true ) + if( this.isWithRoughness ) { + this.canvas[ 'tiles_r' ] = this.makeCanvas( 'tiles_r', true ) + this.canvas[ 'town_r' ] = this.makeCanvas( 'town_r' ) + this.canvas[ 'building_r' ] = this.makeCanvas( 'building_r' ) + } + + this.drawCanvas() + + this.makeCarColor() + + } + + makeCanvas( name, resize ) { + + let r = 1; + if (resize) { + if (this.tileSize === 32) r = 0.5; + else if (this.tileSize === 16) r = 0.25; + } + + let img = this.imgs[name]; + let c = document.createElement("canvas") + c.width = img.width*r + c.height = img.height*r + return c + + } + + drawCanvas() { + + let c, ctx; + + // TODO add color effect on canvas + + for( let name in this.canvas ){ + + c = this.canvas[name]; + + ctx = c.getContext('2d'); + ctx.clearRect ( 0 , 0, c.width, c.height ); + if( name === 'tiles' || name === 'town' || name === 'building'){ + ctx.fillStyle = this.color.ground; + ctx.fillRect( 0, 0, c.width, c.height ) + } + if( name === 'tiles_n' ){ + ctx.fillStyle = this.color.normal; + ctx.fillRect( 0, 0, c.width, c.height ) + } + if( name === 'tiles_r' || name === 'town_r' || name === 'building_r'){ + ctx.fillStyle = this.color.lightGrey; + ctx.fillRect( 0, 0, c.width, c.height ) + } + + ctx.drawImage( this.imgs[ name ], 0, 0, c.width, c.height ); + + } + + this.defineTextures() + + } + + //this.tint( this.townCanvas, this.imgs[1], this.imgs[4] ); + //this.tint( this.buildingCanvas, this.imgs[2], this.imgs[3] ); + + + defineTextures() { + + this.makePixelData( 'tiles' ) + + this.textures['town'] = new THREE.Texture( this.canvas.town ); + this.filterTexture( this.textures['town'], { flip:false } ) + + this.textures['building'] = new THREE.Texture( this.canvas.building ); + this.filterTexture( this.textures['building'], { flip:false } ) + + if( this.isWithNormal ){ + + this.makePixelData( 'tiles_n' ) + + this.textures['town_n'] = new THREE.Texture( this.imgs['town_n'] ); + this.filterTexture( this.textures['town_n'], { flip:false, normal:true } ) + + this.textures['building_n'] = new THREE.Texture( this.imgs['building_n'] ); + this.filterTexture( this.textures['building_n'], { flip:false, normal:true } ) + + } + + if( this.isWithRoughness ){ + + this.makePixelData( 'tiles_r' ) + + this.textures['town_r'] = new THREE.Texture( this.canvas.town_r ); + this.filterTexture( this.textures['town_r'], { flip:false, normal:true } ) + + this.textures['building_r'] = new THREE.Texture( this.canvas.building_r ); + this.filterTexture( this.textures['building_r'], { flip:false, normal:true } ) + + } + + this.textures['border'] = new THREE.Texture( this.imgs['border'] ); + this.filterTexture( this.textures['border'], { flip:false } ) + + this.textures['border_a'] = new THREE.Texture( this.imgs['border_a'] ); + this.filterTexture( this.textures['border_a'], { flip:false } ) + + this.loadModel() + + } + + filterTexture ( texture, o = {} ){ + + if( !o.normal ) texture.encoding = THREE.sRGBEncoding + if( o.flip !== undefined ) texture.flipY = o.flip + if( o.midmap !== undefined ) texture.generateMipmaps = o.midmap; + if( o.alpha !== undefined ) texture.premultiplyAlpha = o.alpha; + + if( this.isPixelStyle ){ + texture.magFilter = THREE.NearestFilter; + texture.minFilter = THREE.LinearMipMapLinearFilter; + } else { + texture.magFilter = THREE.LinearFilter; + texture.minFilter = THREE.LinearMipmapLinearFilter; + } + + //texture.anisotropy = this.anisotropy; + texture.needsUpdate = true; + + } + + + makePixelData( name ) { + + let ctx = this.canvas[ name ].getContext('2d') + let pix = this.tileSize, x, y + + for ( let i = 0; i < 240; i++ ){ + + x = ( i % 32 ) * pix; + y = Math.floor( i / 32 ) * pix; + let data = ctx.getImageData(x, y, pix, pix).data; + if ( name === 'tiles_n' ) this.tiles.normal[i] = new THREE.DataTexture( data, pix, pix ); + else if ( name === 'tiles_r' ) this.tiles.roughness[i] = new THREE.DataTexture( data, pix, pix ); + else this.tiles.texture[i] = new THREE.DataTexture( data, pix, pix ); + + } + + } + + + tint( canvas, image, supImage ) { + + let data, i, n; + let pixels = canvas.width*canvas.height; + let ctx = canvas.getContext('2d'); + + // draw windows + let topData = null; + let newImg = null; + if(supImage && this.dayTime!==0 && this.dayTime!==1){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(supImage, 0, 0); + topData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = topData.data; + i = pixels; + while(i--){ + n = i<<2; + if(data[n+3] !== 0){ + if(data[n+0]==0 && data[n+1]==0 && data[n+2]==0){// black + data[n+3]=60; + } + if(data[n+1]==0){ + //if(data[n+0]==255 && data[n+1]==0 && data[n+2]==0){// red + if(this.dayTime==3) data[n+1]=255; + if(this.dayTime==2) {data[n+0]=0; data[n+3]=60;} + } + + } + } + ctx.putImageData(topData, 0, 0); + newImg = document.createElement('img'); + newImg.src = canvas.toDataURL("image/png"); + } + + if(image){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(image, 0, 0); + } else { + ctx.drawImage(this.skyCanvasBasic, 0, 0); + } + + if( this.dayTime!==0 ){ + let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = imageData.data; + i = pixels; + let c = this.tcolor; + while(i--){ + n = i<<2;//i*4; + data[n+0] = data[n+0] * (1-c.a) + (c.r*c.a); + data[n+1] = data[n+1] * (1-c.a) + (c.g*c.a); + data[n+2] = data[n+2] * (1-c.a) + (c.b*c.a); + } + ctx.putImageData(imageData, 0, 0); + if(newImg){ + ctx.drawImage(newImg, 0, 0); + } + } + + } + + //----------------------------------- TITLE + + rand ( low, high ) { return low + Math.random() * ( high - low ); } + + makeTitleTexture ( n = 0 ) { + + let color = [ this.color.metal, '#fff' ] + if(n===1) color = [ '#333333', '#999999' ] + if(n===2) color = [ '#000', '#999999' ] + + let s = 0.25 + + let c = document.createElement( 'canvas' ); + c.width = c.height = 1024*s; + let ctx = c.getContext('2d'); + + ctx.beginPath(); + ctx.fillStyle = color[0]; + ctx.rect(0, 0, 1024*s, 1024*s); + ctx.fill(); + + let i = 8, r1, r2 + while(i--){ + r1 = this.rand( 150, 255 ) + r2 = this.rand( r1-60, r1-20 ) + ctx.beginPath(); + ctx.fillStyle = n!==1 ? 'rgb('+r1+','+r1+','+r2+')': color[1]; + ctx.rect( i*146*s, 0, 146*s, 200*s); + ctx.fill(); + } + + let t = new THREE.Texture( c ) + this.filterTexture( t, { flip:false } ) + return t; + + } + + + + + //----------------------------------- CARS + + makeCarColor () { + + let c = document.createElement( 'canvas' ); + c.width = c.height = 1024; + let ctx = c.getContext('2d'); + let i, n=0, j=0, k = 3; + + while(k--){ + + ctx.clearRect ( 0 , 0, c.width, c.height ); + + for( i=0; i<16; i++ ){ + ctx.beginPath(); + if(i!==11 && i!==15) ctx.fillStyle = this.carColor(); + ctx.rect(n*256, j*256, 256, 256); + ctx.fill(); + n++ + if(n==4){ n=0; j++; } + } + + ctx.drawImage( this.imgs.cars, 0, 0 ); + let name = 'cars_' + k + this.textures[name] = new THREE.Texture( c ); + this.filterTexture( this.textures[name], { flip:false } ) + + } + + } + + carColor () { + + let carcolors = [ + [0xFFFFFF, 0xD0D1D3, 0XEFEFEF, 0xEEEEEE],//white + [0x252122, 0x302A2B, 0x27362B, 0x2F312B],//black + [0x8D9495, 0xC1C0BC, 0xCED4D4, 0xBEC4C4],//silver + [0x939599, 0x424242, 0x5A5A5A, 0x747675],//gray + [0xC44920, 0xFF4421, 0x600309, 0xD9141E],//red + [0x4AD1FB, 0x275A63, 0x118DDC, 0x2994A6],//blue + [0xA67936, 0x874921, 0xD7A56B, 0x550007],//brown + [0x5FF12C, 0x188047, 0x8DAE29, 0x1AB619],//green + [0xFFF10A, 0xFFFFBD, 0xFCFADF, 0xFFBD0A],//yellow/gold + [0xB92968, 0x5C1A4F, 0x001255, 0xFFB7E7]//other + ]; + + let l = this.randInt(0,9), n = this.randInt(0,3); + let base = carcolors[l][n]; + let resl = base.toString(16); + if(resl.length<6) resl = '#0'+resl; + else resl = '#'+resl; + return resl; + + } + + randInt( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + tile( type, id ) { + return this.tiles[type][id]; + } + + texture( name ) { + return this.textures[name]; + } + + + //----------------------------------- 3D MODEL + + loadModel() { + + this.displayMessage( 'Loading 3d model ...' ) + + let n = this.num; + let name = this.modelSrc[n] + + this.loaderGLB.load( this.modelPath + name + '.glb', function ( gltf ) { + + let o = {}, b1, b2, t; + gltf.scene.traverse( function ( node ) { + if( node.name === 'title' ) t = node; + if( node.name === 'border' ) b1 = node; + if( node.name === 'border_min' ) b2 = node; + if( node.isMesh && !o[node.name] ) o[node.name] = node.geometry; + }) + if(b1) this.border = b1; + if(b2) this.border_min = b2; + if(t) this.title = t; + this.defineGeometry( o, name ) + + this.num++; + if( this.num === this.modelSrc.length ){ + this.displayMessage( '...' ) + this.callback() + } else { + this.loadModel() + } + + }.bind(this)) + + } + + defineGeometry ( o, name ){ + + let g, n; + + switch( name ){ + case 'cars': + + g = { cars:[] } + for( let c in o ){ + n = Number( c.substring(4) ) + g.cars[n] = o[c] + } + + break; + case 'world': + + g = { + town:[ + null, null, null, null, + o.police, o.park_1, o.park_2, o.fire, + o.coal, o.nuclear, o.port, o.stadium, o.airport + ], + tree:[ + o.ttt3, o.ttt3, o.ttt4, o.ttt4, + o.ttt0, o.ttt1, o.ttt2, o.ttt5 + ], + sprite:[ + o.train, o.elico.clone(), o.plane.clone() + ], + + residential:[], + commercial:[], + industrial:[], + house:[] + } + + // BASIC + let i = 9; + while(i--) g.industrial[i] = o['i_0'+i] + i = 19; + while(i--) g.residential[i] = i<10 ? o['r_0'+i] : o['r_'+i] + i = 21; + while(i--) g.commercial[i] = i<10 ? o['c_0'+i] : o['c_'+i] + i = 12; + while(i--) g.house[i] = i<10 ? o['rh_0'+i] : o['rh_'+i] + + break; + } + + // ADD TO GEOS POOL + this.geos = { ...this.geos, ...g } + + } + + geo ( type, id ){ + return this.geos[type][id] || null; + } + + +} diff --git a/games/3dcity/src/city3d/View.js b/games/3dcity/src/city3d/View.js new file mode 100644 index 0000000..96a4351 --- /dev/null +++ b/games/3dcity/src/city3d/View.js @@ -0,0 +1,2743 @@ +import * as THREE from '../../build/three.module.js' +import * as UIL from '../../build/uil.module.js' +import { GLTFLoader } from '../jsm/loaders/GLTFLoader.js'; +import { DRACOLoader } from '../jsm/loaders/DRACOLoader.js'; +import { RGBELoader } from '../jsm/loaders/RGBELoader.js'; +import { ImprovedNoise } from '../jsm/math/ImprovedNoise.js'; +//import { BufferGeometryUtils } from './jsm/utils/BufferGeometryUtils.js'; + +import { Main } from '../Main.js'; + +import { Base } from './Base.js'; +import { BuildTool } from './BuildTool.js'; +import { Pool } from './Pool.js'; + + +import { TrafficBase } from '../TrafficBase.js' + +//let Audio; + +export class View { + + constructor ( isMobile, Hub, pix, isLow ) { + + this.container = document.getElementById( 'container' ); + + this.mapPath = './assets/textures/' + this.modelPath = './assets/models/' + this.rootModel = this.modelPath + 'world.glb'; + + this.hub = null; + + this.isMenu = false; + + this.inMapGenation = false; + + this.isPixelStyle = false; + + this.metalness = 0.6; + this.roughness = 0.3; + this.wireframe = false; + + this.loadGame = null + + + this.M_list = ['treeLists' , 'townLists' , 'houseLists' , 'buildingLists' ]; + this.M_temp = ['tempTreeLayers', 'temptownLayers', 'tempHouseLayers' , 'tempBuildingLayers' ]; + //this.M_geom = ['treeGeo' , 'buildingGeo' , 'houseGeo' , 'X' ]; + this.M_mesh = ['treeMeshs' , 'townMeshs' , 'houseMeshs' , 'buildingMeshs' ]; + this.M_mats = ['townMaterial' , 'townMaterial' , 'buildingMaterial' , 'buildingMaterial' ]; + + this.pix = window.devicePixelRatio; + if( this.pix > 2 ) this.pix = 2; + + this.isLow = isLow || false; + + this.isMobile = isMobile || false; + + this.ARRAY_TYPE = ( typeof Float32Array !== 'undefined' ) ? Float32Array : Array; + + this.isWithTree = true; + this.isWithLight = true; + + this.isStandardMaterial = true; + + this.isWithEnv = true; + this.isWithNormal = true; + this.isWithRoughness = true + this.isWithFog = true; + this.isIsland = false; + this.isWinter = false; + + this.isComputeVertex = true; + this.isTransGeo = true; + + //this.tmpCanvas = null; + //this.tilesDataNormal = []; + //this.tilesDataTextures = []; + + this.key = [0,0,0,0,0,0,0]; + + this.oldData = []; + + this.tileSize = 64//64; + + + if(this.isMobile || this.isLow){ + this.pix = 1 + this.isWithTree = !this.isLow; + this.isWithEnv = false; + this.isWithNormal = false; + this.isWithLight = false; + this.isStandardMaterial = false; + this.tileSize = 32; + } + + // Terrain layer texture scale (16px * mu per tile). + // Default tiles are 64px (mu=4) or 32px (mu=2). + // On mobile we downgrade tiles to 16px (mu=1) to reduce GPU/memory load. + this.poolTileSize = this.tileSize; + if (this.isMobile) this.poolTileSize = 16; + this.mu = Math.max(1, Math.round(this.poolTileSize / 16)); + + this.f = [0,0,0]; + this.stats = [0,0]; + this.isWithStats = false; + + + this.dayTime = 0; + + this.tcolor = {r:10, g: 15, b: 80, a: 0.9}; + + this.snd_layzone = new Audio("./sound/layzone.mp3"); + + this.imgSrc = ['tiles'+this.tileSize+'.png','town.jpg','building.jpg','building_win.png','town_win.png' ]; + if( this.isWithNormal ) { + this.imgSrc.push( 'building_n.png', 'town_n.png', 'tiles'+this.tileSize+'_n.png' ) + } + this.imgSrcPlus = ['tiles'+this.tileSize+'_w.png','town_w.jpg','building_w.jpg']; + + let j = this.imgSrc.length + while(j--) this.imgSrc[j] = this.mapPath + this.imgSrc[j] + + j = this.imgSrcPlus.length + while(j--) this.imgSrcPlus[j] = this.mapPath + this.imgSrcPlus[j] + + this.winterMapLoaded = false; + + this.tmpGameData = null + + + this.imgs = []; + this.num = 0; + + this.fullRedraw = false; + this._layerDrawQueue = null; + this._layerDrawRaf = 0; + this._treeBuildQueue = null; + this._treeBuildRaf = 0; + + this.isWithBackground = false; + this.isWithHeight = false; + + + // camera + this.ToRad = Math.PI / 180; + this.camera = null; + + + this.scene = null; + this.renderer = null; + this.timer = null; + + + this.miniTerrain = []; + this.terrainTxt = []; + this.terrainTxtN = []; + this.terrainTxtR = []; + + this.forceUpdate = { x:-1, y:-1 }; + + this.cam = { horizontal:90, vertical:60, distance:120 }; + const rect = this.container.getBoundingClientRect(); + this.vsize = { x:rect.width || window.innerWidth, y:rect.height || window.innerHeight, z:(rect.width || window.innerWidth)/(rect.height || window.innerHeight)}; + this.mouse = { ox:0, oy:0, h:0, v:0, mx:0, my:0, dx:0, dy:0, down:false, over:false, drag:false, click:false, move:true, dragView:false, button:0 }; + this.raypos = {x:-1, y:0, z:-1}; + + this.select = ''; + this.meshs = {}; + + this.mapSize = [128,128]; + this.nlayers = 64; + + //this.terrain = null; + + this.tool = null; + + this.currentTool = null; + + this.heightData = null; + + // textures + this.worldTexture = null; + this.centralTexture = null; + this.serviceTexture = null; + this.buildingTexture = null; + this.skyTexture = null; + + // material + this.townMaterial = null; + this.buildingMaterial = null; + + this.townCanvas = null; + this.buildingCanvas = null; + //this.groundCanvas = null; + this.skyCanvas = null; + this.skyCanvasBasic = null; + + this.buildingHeigth = null; + this.townMap = null; + this.buildingMap = null; + + // geometry + this.buildingGeo = null; + this.residentialGeo = null; + this.commercialGeo = null; + this.industrialGeo = null; + this.spriteGeo = null; + this.treeGeo = null; + this.houseGeo = null; + + + + this.treeMeshs = []; + this.treeLists = []; + this.tempTreeLayers = []; + this.treeValue = []; + + this.powerMeshs = []; + this.powerMaterial = null; + + this.buildingMeshs = []; + this.buildingLists = []; + this.tempBuildingLayers = []; + + this.townMeshs = []; + this.townLists = []; + this.temptownLayers = []; + + this.houseMeshs = []; + this.houseLists = []; + this.tempHouseLayers = []; + + + this.tempDestruct = []; + + this.currentLayer = 0; + + this.needResize = false; + + this.env = null + + this.ease_p = -1 + this.onEase = null; + + + this.spriteLists = ['train', 'elico', 'plane', 'boat', 'monster', 'tornado', 'sparks']; + //this.spriteLists = []; + this.spriteMeshs = []; + this.spriteObjs = {}; + + this.terrainMaterials = [] + + + this.pool = new Pool( + function() { this.done() }.bind(this), + this.poolTileSize, + this.isWithNormal, + this.isWithRoughness, + this.isPixelStyle, + this.isWithEnv + ) + + + } + + preIntro() { + + this.center.x = 19*0.5; + this.center.z = 19*0.5; + this.cam.distance = 30 + this.moveCamera(); + + this.addBorder() + + const cgeo = new THREE.PlaneGeometry( 19, 19, 3, 3 ); + cgeo.rotateX( -Math.PI * 0.5 ); + + this.basePlane = new THREE.Mesh( cgeo, this.planeMat ); + this.basePlane.position.copy( this.center ) + this.scene.add( this.basePlane ); + + this.title = this.pool.title; + this.title.material = this.titleMat + + + + this.title.position.copy( this.center ) + this.scene.add( this.title ) + + + // traffic map + this.traffic = new TrafficBase({ isStandard:this.isStandardMaterial }) + this.scene.add( this.traffic ) + + // add random building + this.buildings = new THREE.Group() + let j = 16, m, px = 0, pz = 0 + while(j--){ + if(px === 4){ pz ++; px = 0 } + m = this.getRandomObject() + m.position.set( (px*4)+3, 0.01,( pz*4)+3) + this.buildings.add(m) + px++ + } + this.scene.add( this.buildings ) + + this.plane = new THREE.Mesh( new THREE.PlaneGeometry( 18, 4.5, 5, 1 ), new THREE.MeshBasicMaterial( { transparent:true, alphaToCoverage: true } ) ); + this.plane.geometry.rotateX( -Math.PI * 0.4 ); + this.plane.position.copy(this.center) + this.plane.position.y = 0.8 + this.plane.position.z = 19+3.2 + this.plane.name = 'p1'; + this.scene.add( this.plane ) + + UIL.Tools.setStyle({ + fontFamily: 'sans-serif', + fontWeight:'bold', + fontShadow: 'none', + button : '#c1cbd7', + overoff : '#223143', + over : '#6c819a', + select : '#45586f', + text : '#223143', + textOver : '#FFFFFF', + border: '#6c819a', + borderSize: 3, + fontSize: 20, + }) + + this.ui = new UIL.Gui( { w:512, maxHeight:128, parent:null, isCanvas:true, close:false, transparent:true, plane:this.plane } ) + let gg = this.ui.add('grid', { values:['新建','读取'], selectable:false, bsize:[200, 40 ], spaces:[ 18,2 ], radius:40 }).onChange( this.openMap.bind(this) ); + + //let loaderButton = gg.c[3] + + //console.log(loaderButton) + //loaderButton.type = "file"; + // loaderButton.addEventListener( 'change', function(e){ this.fileSelect( e.target.files[0] ); }.bind(this), false ); + + this.ui.onDraw = function () { + + if( this.screen === null ){ + + this.screen = new THREE.Texture( this.canvas ); + //this.screen.minFilter = THREE.LinearFilter; + this.screen.encoding = THREE.sRGBEncoding; + this.plane.material.map = this.screen; + this.plane.material.needsUpdate = true; + + } + + this.screen.needsUpdate = true; + + } + + this.isMenu = true; + + } + + fileSelect( e ){ + + hub.generate( true ); + this.inMapGenation = true; + + const file = e.target.files[0] + const reader = new FileReader(); + let fname = file.name; + let type = fname.substring(fname.lastIndexOf('.')+1, fname.length ); + if( type !== 'json' ) return + reader.readAsText( file ); + + reader.onload = function (e) { + + + this.tmpGameData = e.target.result + this.openMap( 'LOADDONE' ) + + }.bind(this); + + } + + openMap( type ){ + const menuMap = { + '新建': 'NEW', + '读取': 'LOAD', + '平面': 'NEW', + '高度': 'HIGH', + } + type = menuMap[type] || type; + + if( this.isMobile && type==='LOAD' ){ + if( window.localStorage.getItem( 'micropolisJSGame' ) ) type = 'LOADDONE' + else return + } + + if( type==='LOAD' ){ + + if(!this.fileInput){ + + this.fileInput = document.createElement("input") + this.fileInput.type ='file' + this.fileInput.style.display='none' + this.fileInput.onchange = this.fileSelect.bind(this) + //fileInput.func=func + document.body.appendChild( this.fileInput ) + + + } + + let eventMouse = document.createEvent("MouseEvents") + eventMouse.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) + this.fileInput.dispatchEvent(eventMouse) + + return + } + + if( this.fileInput ) document.body.removeChild(this.fileInput) + + this.command = type; + + this.isMenu = false; + + this.ease_p = 0; + this.onEase = this.easing; + + this.scene.remove( this.title ) + this.scene.remove( this.plane ) + + this.traffic.clearAll() + this.scene.remove( this.buildings ) + + this.ui.clear() + + } + + endOpen() { + + if( this.command === 'LOADDONE' ){ + + //this.loadGame( e.target.result ) + + //this.paintMap() + + this.isMenu = false; + setTimeout( function(){ this.ui.dispose() }.bind(this), 100 ) + + Main.loadGame( true ) + + + } + + if( this.command === 'NEW' ){ + + Main.newMap('NEW') + + this.scene.add( this.plane ) + this.plane.position.copy(this.center) + this.plane.position.y = 4 + this.plane.position.z = 128-5 + this.isMenu = true; + + this.plane.scale.set(4,4,4) + + this.ui.add('grid', { values:['平面','高度'], selectable:false, bsize:[140, 30 ], spaces:[ 18,2 ], radius:30 }).onChange( function(t){ + const m = { '平面':'NEW', '高度':'HIGH', 'NEW':'NEW', 'HIGH':'HIGH' }; + setTimeout( Main.newMap, 1000, m[t] || t ); + } ); + this.ui.add('selector', { name:'', h:30, values:['简单', '普通', '困难'], radius:30, value:'普通', p:0 }).onChange( function(v){ + const d = { '简单':'LOW', '普通':'MEDIUM', '困难':'HARD', 'LOW':'LOW', 'MEDIUM':'MEDIUM', 'HARD':'HARD' }; + Main.setDifficulty( d[v] || v ); + } ) + this.ui.add('button', { name:'开始游戏', h:40, radius:40, p:20, forceWidth: 300 }).onChange( this.startPlay.bind(this) ); + + } + + } + + startPlay(){ + + this.isMenu = false; + if(this.plane) this.scene.remove( this.plane ) + setTimeout( function(){ this.ui.dispose() }.bind(this), 100 ) + + // + + Main.playMap() + + } + + easing() { + + let v = this.ease_p; + if( v >= 1 ) { + this.onEase = null + v = 1; + this.endOpen() + } + + let p = 19*0.5 + this.center.x = this.center.z = p + ( (this.mapSize[0]*0.5) - p ) * v; + this.cam.distance = 40 + ( 150 - 40 ) * v; + this.moveCamera(); + + this.basePlane.position.copy( this.center ) + let s = 1 + ( (128/19) - 1 ) * v; + this.basePlane.scale.set( s, 1, s ) + + this.border.morphTargetInfluences[ 0 ] = 1 - v + + this.ease_p = v + 0.01 + + } + + + + //----------------------------------- BORDER + + addBorder() { + + this.border = this.pool.border; + this.border_m = this.pool.border_min; + this.border_m.position.set( 0, 0, 0 ) + this.border.position.set( 0, 0, 0 ) + this.scene.add( this.border ) + + this.border.material = this.borderMat + this.border.geometry.morphAttributes.position = [ this.border_m.geometry.attributes.position ] + this.border.updateMorphTargets(); + this.border.morphTargetInfluences[ 0 ] = 1; + + } + + done() { + + + + //console.log( 'pool full loaded !!!' ) + + this.init(); + this.createMaterial() + + Main.start(); + + } + + createMaterial() { + + this.colors = { + ground: new THREE.Color( this.pool.color.ground ).convertSRGBToLinear(), + metal: new THREE.Color( this.pool.color.metal ).convertSRGBToLinear(), + sky: new THREE.Color( this.pool.color.sky ).convertSRGBToLinear() + } + + let i = this.nlayers; + let option = this.isStandardMaterial ? { roughness:1, metalness:1, envMapIntensity:1 } : {} + let Type = this.isStandardMaterial ? THREE.MeshStandardMaterial : THREE.MeshBasicMaterial; + + while(i--){ + this.terrainMaterials[i] = new Type({ color:0xffffff, vertexColors:true, ...option }) + this.modifyShader( this.terrainMaterials[i] ) + } + + this.townMaterial = new Type( { map: this.pool.texture('town'), ...option } ); + this.modifyShader( this.townMaterial ) + this.buildingMaterial = new Type( { map: this.pool.texture('building'), ...option } ) + this.modifyShader( this.buildingMaterial ) + + this.titleMat = new Type( { map: this.pool.makeTitleTexture(), ...option } ) + if( this.isStandardMaterial ){ + this.titleMat.roughnessMap = this.pool.makeTitleTexture(1) + this.titleMat.emissiveMap = this.pool.makeTitleTexture(2) + this.titleMat.emissive = new THREE.Color( 0x666622 ) + } + this.modifyShader( this.titleMat ) + + if( this.isStandardMaterial ) option.roughness = 0 + this.waterMat = new Type({ color:0x645cab, transparent:true, opacity:0.8, ...option }) + + if( this.isStandardMaterial ) { option.roughness = 0.2; option.metalness = 0.8 } + //this.borderMat = new Type({ map:this.pool.texture('border'), alphaMap:this.pool.texture('border_a'), transparent:true, ...option }) + this.borderMat = new Type({ color:this.colors.metal , alphaMap:this.pool.texture('border_a'), transparent:true, ...option }) + + if( this.isStandardMaterial ) { option.roughness = 0.8; option.metalness = 0.2 } + this.planeMat = new Type({ color:this.colors.ground, depthWrite:false, ...option }) + + + if( this.isStandardMaterial ){ + + if( this.isWithRoughness ){ + this.townMaterial.roughnessMap = this.pool.texture('town_r'); + this.buildingMaterial.roughnessMap = this.pool.texture('building_r'); + } + + if( this.isWithNormal ){ + this.townMaterial.normalMap = this.pool.texture('town_n'); + this.buildingMaterial.normalMap = this.pool.texture('building_n'); + } + + } + + this.powerMaterial = new THREE.SpriteMaterial({ map:this.powerTexture(), transparent:true, depthTest: false, toneMapped:false }) + + this.preIntro() + + } + + modifyShader( m ) { + + if( !this.isStandardMaterial ) return + + m.onBeforeCompile = function ( s ) { + s.fragmentShader = s.fragmentShader.replace( '#include ', ` + float metalnessFactor = metalness; + #ifdef USE_ROUGHNESSMAP + metalnessFactor *= 1.0 - texelRoughness.g; + #endif + `); + } + + } + + + + + //----------------------------------- INIT + + init () { + + this.tmpPos = new THREE.Vector2( 0, 0 ); + + //if(this.isMobile) this.pix = 0.5; + //this.clock = new THREE.Clock(); + + this.scene = new THREE.Scene(); + + + this.camera = new THREE.PerspectiveCamera( 50, this.vsize.z, 0.1, 1000 ); + this.scene.add( this.camera ); + + this.rayVector = new THREE.Vector2( 0, 0 ); + this.raycaster = new THREE.Raycaster(); + + this.land = new THREE.Group(); + this.scene.add( this.land ); + + if( this.isWithFog ){ + + //this.fog = new THREE.Fog( 0xCC7F66, 1, 100 ); + this.fog = new THREE.Fog( 0x90a3b7, 1, 100 ); + this.scene.fog = this.fog; + + } + + this.center = new THREE.Vector3(); + this.center.x = this.mapSize[0]*0.5; + this.center.z = this.mapSize[1]*0.5; + this.moveCamera(); + + this.ease = new THREE.Vector3(); + this.easeRot = new THREE.Vector3(); + + + //this.renderer = new THREE.WebGLRenderer({ canvas:this.canvas, antialias:false }); + let renderer = new THREE.WebGLRenderer({ antialias:false }); + renderer.setSize( this.vsize.x, this.vsize.y ); + renderer.setPixelRatio( this.pix ) + //renderer.sortObjects = false; + //renderer.sortElements = false; + //renderer.autoClear = this.isWithBackground; + + renderer.outputEncoding = THREE.sRGBEncoding + renderer.toneMapping = THREE.ACESFilmicToneMapping + //renderer.physicallyCorrectLights = true + renderer.toneMappingExposure = 1.0 + + this.anisotropy = renderer.capabilities.getMaxAnisotropy(); + + //this.renderer.autoClear = false; + this.container.appendChild( renderer.domElement ); + + this.renderer = renderer + + if( this.isWithEnv ){ + + let envmap = this.pool.env; + let pmremGenerator = new THREE.PMREMGenerator( renderer ); + this.env = pmremGenerator.fromEquirectangular( envmap ).texture; + this.scene.background = this.env; + this.scene.environment = this.env; + envmap.dispose() + pmremGenerator.dispose() + + } + + + if( this.isWithLight ){ + + /*let light = new THREE.DirectionalLight( 0xffffff, 0.5 );//new THREE.SpotLight( 0xffffff, 1, 0, Math.PI / 2, 10, 2 ); + light.position.set( this.center.x+100 , 300, this.center.z-100 ); + light.target.position.set( this.center.x, this.center.y, this.center.z ); + this.scene.add( light );*/ + + //let hemiLight = new THREE.HemisphereLight( 0xCC7F66, 0xEFEFFF, 0.8 ); + //let hemiLight = new THREE.HemisphereLight( 0xffff00, 0xff8000, 1 ); + //hemiLight.color.setHSL( 0.6, 1, 0.6 ); + //hemiLight.groundColor.setHSL( 0.095, 1, 0.75 ); + // hemiLight.position.set( 0, 20, 0 ); + //this.scene.add( hemiLight ); + + + //this.hemiLight = hemiLight; + + + + /*let pointLight = new THREE.PointLight( 0xFFFFFF, 1 ); + pointLight.position.set( this.center.x, 10, this.center.x ); + this.scene.add( pointLight );*/ + + //this.scene.add( new THREE.AmbientLight( 0xcc7f66 ) ); + + + } + + //let _this = this; + + + if( this.isWithBackground ){ + + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], ['#cc7f66','#A7DCFA', 'deepskyblue']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], ['#cc7f66','#A7DCFA', 'deepskyblue']]); + this.skyTexture = new THREE.Texture(this.skyCanvas); + this.skyTexture.encoding = THREE.sRGBEncoding + this.skyTexture.needsUpdate = true; + this.back = new THREE.Mesh( new THREE.IcosahedronGeometry(300,1), new THREE.MeshBasicMaterial( { map:this.skyTexture, side:THREE.BackSide, depthWrite: false, fog:false } )); + this.scene.add( this.back ); + //this.renderer.autoClear = false; + + } else { + + this.renderer.setClearColor( this.pool.color.sky, 1 ); + + } + + + window.addEventListener( 'resize', function(e) { this.resize() }.bind(this), false ); + + // disable context menu + document.addEventListener("contextmenu", function(e){ e.preventDefault(); }, false); + + document.addEventListener( 'mousewheel', this, false ); + + // Prefer pointer events on mobile (needed so UIL canvas UI gets mouse set before Roots handles pointerdown) + this.container.addEventListener( 'pointerdown', this, { capture:true, passive:false } ); + this.container.addEventListener( 'pointermove', this, { capture:true, passive:false } ); + this.container.addEventListener( 'pointerup', this, { capture:true, passive:false } ); + + this.container.addEventListener( 'mousemove', this, false ); + this.container.addEventListener( 'mousedown', this, false ); + //this.container.addEventListener( 'mouseup', this, false ); + //this.container.addEventListener( 'mouseout', this, false ); + + this.container.addEventListener( 'touchmove', this, false ); + this.container.addEventListener( 'touchstart', this, false ); + this.container.addEventListener( 'touchend', this, false ); + + document.addEventListener( 'mouseup', this, false ); + + this.initLayer() + + + // new Tool + this.tool = new BuildTool() + this.scene.add( this.tool ); + this.tool.visible = false; + + + + + + // active key (移动端也启用,支持虚拟方向键) + this.bindKeys(); + + + this.loop(0) + + } + + //----------------------------------- RENDER + + loop( time ) { + + requestAnimationFrame( this.loop.bind(this) ); + + //requestAnimationFrame( function(t){ this.loop(t) }.bind(this) ); + + if( this.onEase !== null ) this.onEase() + + if( this.dragMode() ){ + this.dragCenterposition(); + }else{ + this.updateKey(); + } + + this.render( time ); + + } + + + //----------------------------------- RENDER + + render( time ) { + + this.doResize() + this.renderer.render( this.scene, this.camera ) + + } + + + //----------------------------------- EVENT + + handleEvent( e ) { + + switch( e.type ) { + case 'pointerup': this.onMouseUp( e ); break; + case 'pointerdown': this.onMouseDown( e ); break; + case 'pointermove': this.onMouseMove( e ); break; + case 'mouseup': case 'mouseout': case 'touchend':this.onMouseUp( e ); break; + case 'mousedown': case 'touchstart': this.onMouseDown( e ); break; + case 'mousemove': case 'touchmove': this.onMouseMove( e ); break; + case 'mousewheel': this.onMouseWheel( e ); break; + } + + } + + + //----------------------------------- RESIZE + + resize( e ) { this.needResize = true; } + + doResize() { + + if( !this.needResize ) return; + + const rect = this.container.getBoundingClientRect(); + const w = Math.max(1, Math.round(rect.width || window.innerWidth)); + const h = Math.max(1, Math.round(rect.height || window.innerHeight)); + + this.vsize = { x:w, y:h, z:w/h }; + this.camera.aspect = this.vsize.z; + this.camera.updateProjectionMatrix(); + this.renderer.setSize( this.vsize.x, this.vsize.y ); + this.needResize = false; + + } + + + //----------------------------------- ZOOM + + startZoom() { + this.timer = setInterval( this.faddingZoom, 1000/60, this ); + } + + faddingZoom( t ) { + if(t.cam.distance>20){ + t.cam.distance--; + t.moveCamera(); + }else clearInterval(t.timer); + } + + + //----------------------------------- MATH + + clamp( value, min, max ) { + + if (value < min) return min; + if (value > max) return max; + return value; + + } + + randRange( min, max ) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + unwrapDegrees( r ) { + r = r % 360; + if (r > 180) r -= 360; + if (r < -180) r += 360; + return r; + } + + + //----------------------------------- LOAD IMAGES + + + + winterSwitch() { + /*if(!this.isWinter && this.winterMapLoaded) this.isWinter = true; + else this.isWinter = false; + + this.updateBackground(); + this.setTimeColors(this.dayTime);*/ + } + + textureSwitch( type ) { + /*switch(type){ + case 'normal': + this.townMaterial.map = this.townTexture; + this.buildingMaterial.map = this.buildingTexture; + break; + case 'white': + + break; + }*/ + + } + + setTimeColors( id ) { + + /*this.dayTime = id; + if(this.dayTime==1)this.tcolor = {r:100, g: 15, b: 80, a: 0.3}; + if(this.dayTime==2)this.tcolor = {r:10, g: 15, b: 80, a: 0.8}; + if(this.dayTime==3)this.tcolor = {r:10, g: 15, b: 80, a: 0.6}; + + this.tint(this.skyCanvas); + + if(!this.isWinter){ + //this.tint(this.groundCanvas, this.imgs[0]); + this.tint(this.townCanvas, this.imgs[1], this.imgs[4]); + this.tint(this.buildingCanvas, this.imgs[2], this.imgs[3]); + } else { + //this.tint(this.groundCanvas, this.imgs[5]); + this.tint(this.townCanvas, this.imgs[6], this.imgs[4]); + this.tint(this.buildingCanvas, this.imgs[7], this.imgs[3]); + } + + if(this.isWithFog){ + if(this.isIsland){ + if(this.isWinter){ + if(this.dayTime==0)this.fog.color.setHex(0xAFEEEE); + if(this.dayTime==1)this.fog.color.setHex(0x98ABBF); + if(this.dayTime==2)this.fog.color.setHex(0x2B3C70); + if(this.dayTime==3)this.fog.color.setHex(0x4C688F); + }else{ + if(this.dayTime==0)this.fog.color.setHex(0x6666e6); + if(this.dayTime==1)this.fog.color.setHex(0x654CB9); + if(this.dayTime==2)this.fog.color.setHex(0x1C206E); + if(this.dayTime==3)this.fog.color.setHex(0x2F328C); + } + } else { + if(this.isWinter){ + if(this.dayTime==0)this.fog.color.setHex(0xE6F0FF); + if(this.dayTime==1)this.fog.color.setHex(0xBFACCA); + if(this.dayTime==2)this.fog.color.setHex(0x363C73); + if(this.dayTime==3)this.fog.color.setHex(0x626996); + }else{ + if(this.dayTime==0)this.fog.color.setHex(0xE2946D); + if(this.dayTime==1)this.fog.color.setHex(0xBC6C64); + if(this.dayTime==2)this.fog.color.setHex(0x352A56); + if(this.dayTime==3)this.fog.color.setHex(0x60445C); + } + } + } + this.buildingTexture.needsUpdate = true; + this.townTexture.needsUpdate = true; + this.skyTexture.needsUpdate = true; + this.fullRedraw = true;*/ + + } + + //----------------------------------- 3D GEOMETRY + + getRandomObject( nn ) { + + nn = nn || this.randRange(0,2); + let geo, mat, r, n; + switch(nn){ + + case 0: geo = this.pool.geo('residential', this.randRange(1,18) ); break; + case 1: geo = this.pool.geo('commercial', this.randRange(1,20) ); break; + case 2: geo = this.pool.geo('industrial', this.randRange(1,8) ); break; + + /*case 0: geo = this.buildingGeo[this.randRange(4,12)]; mat = this.townMaterial; break; + case 1: geo = this.residentialGeo[this.randRange(1, this.residentialGeo.length-1)]; mat = this.buildingMaterial; break; + case 2: geo = this.commercialGeo[this.randRange(1, this.commercialGeo.length-1)]; mat = this.buildingMaterial; break; + case 3: geo = this.industrialGeo[this.randRange(1, this.industrialGeo.length-1)]; mat = this.buildingMaterial; break; + case 4: geo = this.houseGeo[this.randRange(0, this.houseGeo.length-1)]; mat = this.buildingMaterial; break; + case 5: geo = this.spriteGeo[this.randRange(0, this.spriteGeo.length-1)]; mat = this.townMaterial; break; + case 6: + r = this.randRange(0,2); + n = 0; + if(r==1) n= 4; + if(r==2) n= 6; + geo = this.treeGeo[n]; + mat = this.townMaterial; + break;*/ + } + + // + + + let mesh = new THREE.Mesh( geo, this.buildingMaterial ); + //mesh.name = geo.name; + return mesh; + + } + + + + + //----------------------------------- MESH CONSTRUCTOR + + buildMeshLayer( layer, type = 'tree' ) { + + type = type; + + let id = 0; + + if( type === 'tree' ) id = 0; + if( type === 'town' ) id = 1; + if( type === 'house' ) id = 2; + if( type === 'building' ) id = 3; + + let list = this.M_list[id]; + let temp = this.M_temp[id]; + //let geom = this.M_geom[id]; + let mesh = this.M_mesh[id]; + let mats = this.M_mats[id]; + + let isIndexed = false, index, indexOffset = 0; + + let _g, v, nr, uv, t, i, j, lng, n, ar, k, decal = 0; + + if( this[list][layer] ){ + + i = this[list][layer].length; + + v = []; + uv = []; + nr = []; + index = []; + + while( i-- ){ + + ar = this[list][layer][i]; + + if( id === 3 ){ // building + + k = Base.R.length; + while(k--){ + if( ar[3] === Base.R[k] ){ + _g = this.pool.geo('residential', k); + // remove little house + if(k===0 && ar[5]===0){ this.buildingLists[layer][i][5] = 1; this.addBaseHouse( ar[0], ar[1], ar[2] ); } + else if(k>0 && ar[5]===1){ this.buildingLists[layer][i][5] = 0; this.removeBaseHouse( ar[0], ar[1], ar[2] ); } + } + + } + + k = Base.C.length; + while(k--){ if( ar[3] === Base.C[k] ) _g = this.pool.geo('commercial', k) } + + k = Base.I.length; + while(k--){ if( ar[3] === Base.I[k] ) _g = this.pool.geo('industrial', k) } + + } else if( id === 2 ){ // house + + k = Base.H.length; + while(k--){ if( ar[3] === Base.H[k] ) _g = this.pool.geo('house', k) } + + } else { // other + + _g = this.pool.geo( type, ar[3] ) + + } + + // add to temp array if geometry + + if( _g ){ + + // index + if( _g.index !== null ){ + + isIndexed = true + lng = _g.index.count + + for ( j = 0; j < lng; ++ j ) index.push( _g.index.getX( j ) + indexOffset ) + indexOffset += _g.attributes.position.count + + } + + // position + t = _g.attributes.position.array + lng = _g.attributes.position.count + + for( j = 0; j < lng; ++ j ){ + n = j * 3 + v.push( t[n] + ar[0], t[n+1] + ar[1], t[n+2] + ar[2] + decal ) + } + + // normal + nr = [ ...nr, ..._g.attributes.normal.array ] + // uv + uv = [ ...uv, ..._g.attributes.uv.array ] + + } + + } + + // remove old mesh + + if( this[mesh][layer] ){ + + this[mesh][layer].geometry.dispose(); + this.scene.remove( this[mesh][layer] ); + + } + + if( v.length > 0 ){ + + // final geometry + + let g = new THREE.BufferGeometry(); + + if( isIndexed ) g.setIndex( index ); + g.setAttribute( 'position', new THREE.Float32BufferAttribute( v , 3 ) ); + g.setAttribute( 'normal', new THREE.Float32BufferAttribute( nr, 3 ) ); + g.setAttribute( 'uv', new THREE.Float32BufferAttribute( uv, 2 ) ); + + // final mesh + this[mesh][layer] = new THREE.Mesh( g, this[mats] ); + this.scene.add( this[mesh][layer] ); + + } + + // clear temp + this[temp][layer] = 0; + + } + + } + + //----------------------------------- TREE TEST + + addTree ( x, y = 0, z, v, layer ) { + + if( !this.isWithTree ) return; + // v 21 to 43 + if( !this.treeLists[layer] ) this.treeLists[layer]=[]; + this.treeLists[layer].push([x,y,z,v]); + + } + + populateTree (){ + + if(!this.isWithTree) return; + + if (this.isMobile || this.isLow) { + this.startTreeBuild(); + return; + } + + let l = this.nlayers; + while( l-- ) this.buildMeshLayer( l ); + + } + + cancelTreeBuild() { + if (this._treeBuildRaf) { + cancelAnimationFrame(this._treeBuildRaf); + this._treeBuildRaf = 0; + } + this._treeBuildQueue = null; + } + + startTreeBuild() { + this.cancelTreeBuild(); + if (!this.isWithTree) return; + + this._treeBuildQueue = []; + for (let i = this.nlayers - 1; i >= 0; i--) { + if (this.treeLists[i] && this.treeLists[i].length) this._treeBuildQueue.push(i); + } + this.processTreeBuild(); + } + + processTreeBuild() { + if (!this._treeBuildQueue || this._treeBuildQueue.length === 0) { + this.cancelTreeBuild(); + return; + } + + const start = (self.performance && performance.now) ? performance.now() : Date.now(); + let processed = 0; + + while (this._treeBuildQueue.length) { + const layer = this._treeBuildQueue.shift(); + this.buildMeshLayer(layer); + processed++; + + const now = (self.performance && performance.now) ? performance.now() : Date.now(); + if (processed >= 1 && (now - start) > 10) break; + } + + this._treeBuildRaf = requestAnimationFrame(this.processTreeBuild.bind(this)); + } + + clearAllTrees () { + + this.cancelTreeBuild(); + if(!this.isWithTree) return; + let l = this.nlayers; + while(l--){ + if( this.treeMeshs[l] ){ + this.scene.remove( this.treeMeshs[l] ); + if(this.treeMeshs[l].geometry) this.treeMeshs[l].geometry.dispose(); + } + } + this.treeMeshs = []; + this.treeLists = []; + this.tempTreeLayers = []; + this.treeValue = []; + + } + + removeTreePack ( ar ) { + + if(!this.isWithTree) return; + //this.tempTreeLayers = []; + let i = ar.length; + while(i--){ + this.removeTree(ar[i][0], ar[i][1], true); + } + // rebuild layers + i = this.tempTreeLayers.length; + while(i--){ + if(this.tempTreeLayers[i] === 1){ this.rebuildTreeLayer(i); } + } + } + + removeTree ( x, z, m ) { + + let l = this.findLayer(x, z), ar; + if(this.treeLists[l]){ + let i = this.treeLists[l].length; + while(i--){ + ar = this.treeLists[l][i]; + if(ar[0] == x && ar[2]==z){ + this.treeLists[l].splice(i, 1); + if(!m){ + this.rebuildTreeLayer(l); + return; + } else { + // multy trees + this.tempTreeLayers[l] = 1; + } + } + } + } + } + + rebuildTreeLayer ( l ) { + + if(!this.isWithTree) return; + this.scene.remove(this.treeMeshs[l]); + this.treeMeshs[l].geometry.dispose(); + + this.buildMeshLayer(l); + + } + + + //------------------------------------ BACKGROUND MAP + + updateBackground () { + + let rootColors; + let fogColors; + if(this.isWithBackground ){ + if(this.isIsland){ + rootColors = '#6666e6'; + fogColors = 0x6666e6; + if(this.isWinter){ + rootColors = '#AFEEEE'; + fogColors = 0xAFEEEE; + } + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + if(this.isWithFog){ + this.fog.color.setHex(fogColors); + //this.fog.color.convertSRGBToLinear() + } + } + else{ + rootColors = '#E2946D'; + fogColors = 0xE2946D; + if(this.isWinter){ + rootColors = '#E6F0FF'; + fogColors = 0xE6F0FF; + } + this.skyCanvasBasic = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + this.skyCanvas = this.gradTexture([[0.51,0.49, 0.3], [rootColors,'#BFDDFF', '#4A65FF']]); + if(this.isWithFog){ + this.fog.color.setHex(fogColors); + //this.fog.color.convertSRGBToLinear() + } + } + this.skyTexture = new THREE.Texture(this.skyCanvas); + this.skyTexture.encoding = THREE.sRGBEncoding + this.skyTexture.needsUpdate = true; + this.back.material.map = this.skyTexture; + } else { + if(this.isIsland) this.renderer.setClearColor( 0x6666e6, 1 ); + else this.renderer.setClearColor( 0xcc7f66, 1 ); + } + + if(this.isWithLight){ + + //this.hemiLight.groundColor.setHex( fogColors ); + + } + } + + + + //------------------------------------ TERRAIN MAP + + clearTerrain () { + + if( this.miniTerrain.length !== 0 ){ + let e = this.miniTerrain.length; + while(e--){ this.land.remove( this.miniTerrain[e] ); } + this.miniTerrain = []; + } + + } + + initTerrain() { + + this.center.x = this.mapSize[0]*0.5; + this.center.z = this.mapSize[1]*0.5; + + // create terrain if not existe + if( this.miniTerrain.length === 0 ){ + + let n = 0, i, j, k, geo, mesh; + + let divid = this.isWithHeight ? 16 : 1; + + let colors; + + for( i=0; i<8; i++){ + for( j=0; j<8; j++){ + + geo = new THREE.PlaneBufferGeometry( 16, 16, divid, divid ); + geo.rotateX( -Math.PI * 0.5 ); + geo.translate( (8+j*16)-0.5, 0, (8+i*16)-0.5 ); + + k = geo.attributes.position.array.length + colors = [];//new Float32Array( lng ); + while( k-- ) colors[k] = 1.0 + geo.setAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + mesh = new THREE.Mesh( geo, this.terrainMaterials[ n ] ) + + // if( this.isWithLight ) mesh = new THREE.Mesh( geo, new THREE.MeshStandardMaterial({ color:0xffffff, metalness:this.metalness, roughness:this.roughness, wireframe:this.wireframe, vertexColors:true }) ); + //else mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial({ color:0xffffff, vertexColors:true }) ); + + mesh.name = 'terrain_' + n; + this.land.add( mesh ); + this.miniTerrain[n] = mesh; + n++; + + } + } + } + + // update start map texture + + if( this.isWithHeight ){ + + this.applyHeight(); + //this.center.y = this.heightData[this.findId(this.center.x,this.center.z)]; + this.center.y = this.heightData[this.findHeightId(this.center.x,this.center.z)]; + + } else { + + this.center.y = 0; + + } + + + this.initTerrainTexture() + + this.moveCamera(); + if( this.isWithBackground ) this.back.position.copy(this.center); + + + } + + initTerrainTexture () { + + let n = this.nlayers; + let texture, textureN, textureR; + let canvas = document.createElement('canvas'); + canvas.width = canvas.height = 256*this.mu; + + while( n-- ){ + + texture = new THREE.Texture( canvas ); + this.pool.filterTexture( texture, {} ) + + this.miniTerrain[n].material.map = texture; + this.terrainTxt[n] = texture; + + if( this.isWithNormal ){ + + textureN = new THREE.Texture( canvas ); + this.pool.filterTexture( textureN, { normal:true } ) + + this.miniTerrain[n].material.normalMap = textureN; + this.terrainTxtN[n] = textureN; + + } + + if( this.isWithRoughness ){ + + textureR = new THREE.Texture( canvas ); + this.pool.filterTexture( textureR, { normal:true } ) + + this.miniTerrain[n].material.roughnessMap = textureR; + //this.miniTerrain[n].material.metalnessMap = textureR; + this.terrainTxtR[n] = textureR; + + } + + } + + } + + //------------------------------------------HEIGHT + + generateHeight() { + + let d = this.mapSize[0]+1; + let size = d * d; + + this.heightData = new this.ARRAY_TYPE(size); + + let perlin = new ImprovedNoise() + + let noise; + + let r = 1 / d; + let quality = 1 / 20; + let i = size, x, y, min = 0, max = 0 + + while( i-- ){ + + x = i % d; + y = Math.floor( i * r ); + noise = (perlin.noise( x * quality, 0, y * quality ) + 1)*0.5; + noise *= 2; + noise = Math.pow( noise, 3 ); + this.heightData[ i ] = noise + + + + if(noisemax) max = noise + + } + + //console.log(min, max) + this.isWithHeight = true; + + } + + clearHeight() { + + if( this.water ) this.scene.remove( this.water ); + this.heightData = null + this.isWithHeight = false; + + } + + applyHeight() { + + let i, j, gr, gn, gc; + let lng = this.heightData.length; + let pos, layer, h, v, d=0, n, nn, geo, id, deep; + this.Gtmp = []; + + let big = new THREE.PlaneGeometry( 16*8, 16*8, 16*8, 16*8 ); + big.rotateX( -Math.PI * 0.5 ); + big.translate( this.center.x, 0, this.center.z ); + + gr = big.attributes.position.array; + + i = lng; + while(i--){ + n = i*3; + gr[n+1] = this.heightData[i]; + } + + big.attributes.position.needUpdate = true; + big.computeVertexNormals(); + let rn = big.attributes.normal.array; + + i = 64; + while (i--){ + + geo = this.miniTerrain[i].geometry + + gr = geo.attributes.position.array; + gn = geo.attributes.normal.array; + gc = geo.attributes.color.array; + + j = gr.length/3; + + this.Gtmp[i] = new this.ARRAY_TYPE(j); + + while(j--){ + + n = j * 3; + //id = this.findHeightId( gr[n], gr[n+2] ) + id = this.findHeightId( gr[n]+0.5, gr[n+2]+0.5 ) + + gr[n+1] = this.Gtmp[i][j] = this.heightData[ id ]; + + nn = id*3; + gn[n] = rn[nn]; + gn[n+1] = rn[nn+1]; + gn[n+2] = rn[nn+2]; + + deep = 0.5 + this.clamp( this.heightData[ id ]/3, -1, 1) * 0.5; + + gc[n] = gc[n+1] = gc[n+2] = deep; + + if( gr[n+1]<0 ){ // under sea + gc[n] -= deep * 0.5 + gc[n+1] -= deep * 0.4 + } + + // border smooth + if(gr[n]===-0.5 || gr[n+2]===-0.5 || gr[n]===128-0.5 || gr[n+2]===128-0.5){ + if( gr[n+1]>0 ) gr[n+1] = this.heightData[ id ] = 0.25 + if( gr[n+1]<0 ) gr[n+1] = this.heightData[ id ] = 0 + } + + } + + + geo.attributes.position.needsUpdate = true; + geo.attributes.normal.needsUpdate = true; + geo.attributes.color.needsUpdate = true; + //geo.computeVertexNormals(); + + } + + big.dispose(); + big = null; + + // add water mesh + + let waterGeo = new THREE.PlaneGeometry( 16*8, 16*8, 1, 1 ); + waterGeo.rotateX( -Math.PI * 0.5 ); + waterGeo.translate( this.center.x-0.5, 0, this.center.z-0.5 ); + + + this.water = new THREE.Mesh( waterGeo, this.waterMat ) + this.scene.add( this.water ); + + } + + makePlanar( ar, y ) { + + let layer, v, x, z, id; + let tmp = []; + let i = ar.length; + let tempHeightLayers = [] + + while( i-- ) { + x = ar[i][0]; + z = ar[i][1]; + id = this.findHeightId(x, z) + + this.heightData[ id ] = y + + layer = this.findLayer(x, z); + + //v = this.findVertices( layer, [x, z] );//findVertices(layer, [x, z] ); + //this.Gtmp[layer][v] = y; + tempHeightLayers[layer] = 1; + } + + // rebuild layers + i = tempHeightLayers.length; + while ( i-- ) { + if(tempHeightLayers[i] === 1) this.updateVertices( i ); + } + + } + + updateVertices ( layer ){ + + let g = this.miniTerrain[ layer ].geometry; + //let ar = this.Gtmp[ layer ]; + + let v = g.attributes.position.array; + let c = g.attributes.color.array; + let i = v.length/3, n, id; + + while(i--){ + + n = i*3; + id = this.findHeightId( v[n]+0.5, v[n+2]+0.5 ) + v[n+1] = this.heightData[ id ]; + + + /*v[n+1] = ar[i]; + c[n+1] = 0; + c[n+2] = 0;*/ + } + + g.attributes.position.needsUpdate = true; + //g.attributes.color.needsUpdate = true; + //g.computeBoundingSphere(); + //g.computeVertexNormals(); + + console.log('updated !!') + + } + + + //------------------------------------------LAYER TOOL 8X8 + + findLayer( x, y ) { + let cx = Math.floor(x/16) + let cy = Math.floor(y/16) + return cx+(cy*8) + } + + findLayerPos( x, y, layer ) { + let cy = Math.floor(layer/8) + let cx = Math.floor(layer-(cy*8)) + let py = y-(16*cy) + let px = x-(16*cx) + return [px,py] + } + + findPosition( id ) { + let y = Math.floor(id/this.mapSize[1]) + let x = id-(y*this.mapSize[1]) + return [x,y] + } + + findId( x, y ) { + return x+(y*this.mapSize[1]) + } + + findVertices( layer, pos ){ + let cy = Math.floor(layer/8) + let cx = Math.floor(layer-(cy*8)) + let py = pos[1]-(16*cy) + let px = pos[0]-(16*cx) + return px + (py*16) + } + + findHeightId( x, y ) { + return x+(y*(this.mapSize[0]+1)) + } + + + //------------------------------------------RAY + + rayTest () { + + let intersects; + + this.raycaster.setFromCamera( this.rayVector, this.camera ); + + if( this.isMenu && !this.inMapGenation ){ + + this.ui.noMouse(); + + intersects = this.raycaster.intersectObjects( this.scene.children ); + + if ( intersects.length > 0 ){ + if( intersects[ 0 ].object.name === 'p1' ){ + this.ui.setMouse( intersects[ 0 ].uv ); + } + } + + } + + if ( this.land.children.length > 0 ) { + intersects = this.raycaster.intersectObjects( this.land.children ); + if ( intersects.length > 0 ) { + + this.raypos.x = Math.round( intersects[0].point.x ); + this.raypos.z = Math.round( intersects[0].point.z ); + + if( this.isWithHeight ) this.raypos.y = Math.round( intersects[0].point.y ); + else this.raypos.y = 0; + + if( this.currentTool ){ + + this.tool.position.set(this.raypos.x, this.raypos.y, this.raypos.z); + + //this.tool.position.set(this.raypos.x, this.raypos.y, this.raypos.z); + if(this.mouse.click || this.mouse.drag){ + Main.mapClick( this.currentTool.tool ); + + } + //if(this.mouse.click || this.currentTool.drag) mapClick(); + + this.mouse.click=false; + } + } else { + this.raypos.x = -1; + this.raypos.z = -1; + } + } + } + + + //------------------------------------------TOOL + + selectTool ( id ) { + + this.tool.visible = false; + this.raypos.x = -1; + this.raypos.z = -1; + + if( id === 0 || id === 18){ + this.currentTool = null; + this.mouse.dragView = false; + this.mouse.move = true; + } else if ( id === 16 ){ + this.currentTool = null; + this.mouse.move = false; + this.mouse.dragView = true; + } else { + this.currentTool = Base.toolSet[id]; + this.mouse.move = false; + this.mouse.dragView = false; + + this.tool.visible = true; + this.tool.color = this.currentTool.color; + this.tool.resize = this.currentTool.size; + + } + + Main.sendTool( Base.toolSet[id].tool ); + + } + + + //------------------------------------------BUILD + + build( x, y ) { + + if( this.currentTool.tool==='query' ) return; + + if( this.currentTool.build ){ + + let size = this.currentTool.size; + let sizey = this.currentTool.sy; + + let py = 0; + + if( this.isWithHeight ) py = this.heightData[ this.findHeightId(x,y) ]; + + let zone; + if(size == 1 ) zone = [ [x, y] ]; + else if(size == 3) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1] ]; + else if(size == 4) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1], [x+2, y-1], [x+2, y] , [x+2, y+1] , [x+2, y+2], [x-1, y+2], [x, y+2], [x+1, y+2] ]; + else if(size == 6) zone = [ [x, y], [x-1, y], [x+1, y], [x, y-1], [x-1, y-1], [x+1, y-1], [x, y+1], [x-1, y+1], [x+1, y+1], [x+2, y-1], [x+2, y] , [x+2, y+1] , [x+2, y+2], [x-1, y+2], [x, y+2], [x+1, y+2], + [x+3, y-1], [x+4, y-1], [x+3, y], [x+4, y], [x+3, y+1], [x+4, y+1], [x+3, y+2], [x+4, y+2], [x+3, y+3], [x+4, y+3], [x+3, y+4], [x+4, y+4], + [x-1, y+3], [x-1, y+4], [x, y+3], [x, y+4], [x+1, y+3], [x+1, y+4], [x+2, y+3], [x+2, y+4] + ]; + + this.removeTreePack(zone); + + if( this.isWithHeight && size !== 1 ) this.makePlanar( zone, py ); + + let v = this.currentTool.geo; + + // standard building + if(v<4 && v!==0){ + this.addBaseBuilding(x, py, y, v, zone); + this.snd_layzone.play(); + } + // town building + if(v==8 || v==9 || v==4 || v==5 || v==7 || v==10 || v==11 || v==12){ + this.addBaseTown(x,py,y,v,zone); + this.snd_layzone.play(); + } + + } else { + this.removeTree(x,y); + if( this.isWithHeight ){ + let py = this.heightData[this.findHeightId(x,y)]; + this.makePlanar( [[x,y]], py ); + } + if( this.currentTool.tool === 'bulldozer' ){ + this.forceUpdate.x = x; + this.forceUpdate.y = y; + this.testDestruct(x,y); + } + } + } + + + + //--------------------------------------------------TEST DESTRUCT + + testLayer( x, y ) { + + let l = this.findLayer(x,y); + let list = [l]; + let pos = this.findLayerPos(x,y,l); + let a = 0,b = 0; + + if(pos[0]<4) a=1; + else if(pos[0]>13) a=2; + + if(pos[1]<4) b=1; + else if(pos[1]>13) b=2; + + if(b==1) if(l-8>-1) list.push(l-8); + if(b==2) if(l+8<64) list.push(l+8); + + if(a==1) if(l-1>-1) list.push(l-1); + if(a==2) if(l+1<64) list.push(l+1); + + if(a==1 && b==1) if(l-9>-1) list.push(l-9); + if(a==2 && b==2) if(l+9<64) list.push(l+9); + + if(a==1 && b==2) if(l+7<64) list.push(l+7); + if(a==2 && b==1) if(l-7>-1) list.push(l-7); + + //console.log(list); + return list; + } + + testDestruct( x, y ){ + + let i, j, ar, ar2, l; + let list = this.testLayer(x,y); + + for(let h= 0; h87)vertical=87; + if(vertical<1)vertical=1; + let phi = vertical*this.ToRad ; + let theta = horizontal*this.ToRad; + p.x = (distance * Math.sin(phi) * Math.cos(theta)) + origine.x; + p.z = (distance * Math.sin(phi) * Math.sin(theta)) + origine.z; + p.y = (distance * Math.cos(phi)) + origine.y; + return p; + + } + + moveCamera () { + + this.camera.position.copy(this.Orbit(this.center, this.cam.horizontal, this.cam.vertical, this.cam.distance)); + this.camera.lookAt(this.center); + + if(this.isWithFog){ + this.fog.far=this.cam.distance*4; + if(this.fog.far<20)this.fog.far=20; + } + + } + + dragCenterposition (){ + + if ( this.ease.x == 0 && this.ease.z == 0 ) return; + this.easeRot.y = this.cam.horizontal*this.ToRad; + let rot = this.unwrapDegrees(Math.round(this.cam.horizontal)); + this.easeRot.x = Math.sin(this.easeRot.y) * this.ease.x + Math.cos(this.easeRot.y) * this.ease.z; + this.easeRot.z = Math.cos(this.easeRot.y) * this.ease.x - Math.sin(this.easeRot.y) * this.ease.z; + + this.center.x += this.easeRot.x; + this.center.z -= this.easeRot.z; + + if(this.center.x<0) this.center.x = 0; + if(this.center.x>128) this.center.x = 128; + if(this.center.z<0) this.center.z = 0; + if(this.center.z>128) this.center.z = 128; + + this.moveCamera(); + + } + + onMouseDown (e) { + + e.preventDefault(); + + // Handle pinch-to-zoom for mobile (two finger touch) + if(e.touches && e.touches.length === 2) { + const dx = e.touches[0].pageX - e.touches[1].pageX; + const dy = e.touches[0].pageY - e.touches[1].pageY; + this.pinchStartDistance = Math.sqrt(dx * dx + dy * dy); + this.pinchStartZoom = this.cam.distance; + this.isPinching = true; + return; + } + + const rect = (this.renderer && this.renderer.domElement) ? this.renderer.domElement.getBoundingClientRect() : this.container.getBoundingClientRect(); + let clientX, clientY; + if (e.touches && e.touches[0]) { + clientX = e.touches[0].clientX; + clientY = e.touches[0].clientY; + } else { + clientX = e.clientX; + clientY = e.clientY; + } + let px = clientX - rect.left; + let py = clientY - rect.top; + if (!e.touches) { + // 0: default 1: left 2: middle 3: right + this.mouse.button = e.which || e.button || 0; + } + + //if(this.mouse.button===1 && this.currentTool) this.mouse.move = true; + + this.mouse.ox = px; + this.mouse.oy = py; + this.rayVector.x = ( px / rect.width ) * 2 - 1; + this.rayVector.y = - ( py / rect.height ) * 2 + 1; + this.mouse.h = this.cam.horizontal; + this.mouse.v = this.cam.vertical; + this.mouse.down = true; + // Ensure menu UI can be clicked on mobile: setMouse(uv) must be available before UIL Roots handles pointerdown. + if ( this.isMenu ) this.rayTest(); + + if(this.currentTool && this.mouse.button<2){// only for tool + this.mouse.click = true; + if(this.currentTool.drag){ this.mouse.drag = true;} + if (e.touches || e.pointerType === 'touch') this.rayTest(); + + } + + } + + onMouseUp (e) { + e.preventDefault(); + this.isPinching = false; + this.mouse.button = 0; + this.mouse.down = false; + this.mouse.drag = false; + if(this.currentTool==null)this.mouse.move = true; + this.ease.x = 0; + this.ease.z = 0; + document.body.style.cursor = 'auto'; + } + + onMouseMove (e) { + e.preventDefault(); + + // Handle pinch-to-zoom movement + if(e.touches && e.touches.length === 2 && this.isPinching) { + const dx = e.touches[0].pageX - e.touches[1].pageX; + const dy = e.touches[0].pageY - e.touches[1].pageY; + const distance = Math.sqrt(dx * dx + dy * dy); + const scale = this.pinchStartDistance / distance; + this.cam.distance = Math.max(1, Math.min(150, this.pinchStartZoom * scale)); + this.moveCamera(); + return; + } + + const rect = (this.renderer && this.renderer.domElement) ? this.renderer.domElement.getBoundingClientRect() : this.container.getBoundingClientRect(); + let clientX, clientY; + if (e.touches && e.touches[0]) { + clientX = e.touches[0].clientX; + clientY = e.touches[0].clientY; + } else { + clientX = e.clientX; + clientY = e.clientY; + } + let px = clientX - rect.left; + let py = clientY - rect.top; + + if (this.mouse.down) { + if(this.mouse.move || this.mouse.button===2){ + this.mouse.dragView = false; + document.body.style.cursor = 'crosshair'; + this.cam.horizontal = ((px - this.mouse.ox) * 0.3) + this.mouse.h; + this.cam.vertical = (-(py -this. mouse.oy) * 0.3) + this.mouse.v; + this.moveCamera(); + } + if(this.mouse.dragView || this.mouse.button===3){ + document.body.style.cursor = 'move'; + this.mouse.move = false; + this.ease.x = (px - this.mouse.ox)/1000; + this.ease.z = (py - this. mouse.oy)/1000; + } + } + + if(this.currentTool !== null || this.isMenu ){ + this.rayVector.x = ( px / rect.width ) * 2 - 1; + this.rayVector.y = - ( py / rect.height ) * 2 + 1; + this.rayTest(); + } + } + + onMouseWheel (e) { + //e.preventDefault(); + let delta = 0; + if(e.wheelDelta){delta=e.wheelDelta*-1;} + else if(e.detail){delta=e.detail*20;} + this.cam.distance+=(delta/80); + if(this.cam.distance<1)this.cam.distance = 1; + if(this.cam.distance>150)this.cam.distance = 150; + this.moveCamera(); + + } + + + // ----------------------- + // GROUND TEXTURE + // ----------------------- + + paintMap ( mapSize, island = false, withHeight = false ) { + + this.isIsland = island; + + if( mapSize ) this.mapSize = mapSize; + + if( this.basePlane ) this.scene.remove( this.basePlane ) + + //console.log(tilesData.length) + this.cancelLayerDraw(); + this.clearTerrain() + this.clearAllTrees() + this.clearHeight() + + if( withHeight ) this.generateHeight() + + //this.initTerrain(); + + let y = this.mapSize[1]; + let x, v, px, py, n = tilesData.length, cy, cx, layer, ar, r, ty = 0, id; + + while( y-- ){ + x = this.mapSize[0]; + while( x-- ){ + + // find layer + cy = Math.floor(y/16); + cx = Math.floor(x/16); + layer = cx+(cy*8); + + n--; + v = tilesData[n]; + + if( this.isWithHeight ){ + + if( v > 1 && v < 5 ){ // water + id = this.findHeightId(x, y) + this.heightData[ id ] *= -1; + if( x === this.mapSize[0]-1 ) this.heightData[ id+1 ] *= -1; + if( y === this.mapSize[1]-1 ) this.heightData[ id+this.mapSize[1] ] *= -1; + tilesData[n] = 0 + } + if( v > 4 && v < 21 ){ // water border + this.heightData[ this.findHeightId(x, y) ] *= 0.5; + tilesData[n] = 0 + } + } + if( v > 20 && v < 30 ){// tree 44 + + if( this.isWithHeight ) ty = this.heightData[ this.findHeightId(x, y) ]-0.1; + + r = v-21; + if(r===8) r = Math.floor(Math.random()*7)//r=8// big middle tree + + if( withHeight && ty > 0.5 ){ + if( x===0 || y===0 || x===this.mapSize[0]-1 || y===this.mapSize[0]-1) ty = 0.5 + } + + + + this.addTree( x, ty, y, r, layer ); + this.treeValue[n] = v; + + } + + } + } + + this.updateBackground(); + + this.initTerrain(); + + if (this.isMobile || this.isLow) { + if (typeof hub !== 'undefined' && hub.generate) hub.generate(true); + this.startLayerDraw(true); + return; + } + + let i = this.nlayers; + while(i--){ + this.drawLayer( i, true ) + } + this.finishPaintMap(); + + } + + cancelLayerDraw() { + if (this._layerDrawRaf) { + cancelAnimationFrame(this._layerDrawRaf); + this._layerDrawRaf = 0; + } + this._layerDrawQueue = null; + } + + startLayerDraw(full) { + this.cancelLayerDraw(); + this._layerDrawQueue = []; + for (let i = this.nlayers - 1; i >= 0; i--) this._layerDrawQueue.push(i); + this._layerDrawFull = !!full; + this.processLayerDraw(); + } + + processLayerDraw() { + if (!this._layerDrawQueue || this._layerDrawQueue.length === 0) { + this.finishPaintMap(); + return; + } + + const start = (self.performance && performance.now) ? performance.now() : Date.now(); + let processed = 0; + + while (this._layerDrawQueue.length) { + const layer = this._layerDrawQueue.shift(); + this.drawLayer(layer, this._layerDrawFull); + processed++; + + const now = (self.performance && performance.now) ? performance.now() : Date.now(); + if (processed >= 1 && (now - start) > 10) break; + } + + this._layerDrawRaf = requestAnimationFrame(this.processLayerDraw.bind(this)); + } + + finishPaintMap() { + this.populateTree(); + + if(this.fullRedraw){ + this.fullRedraw = false; + } + + this.inMapGenation = false; + if (typeof hub !== 'undefined' && hub.generate) hub.generate(false); + } + + initLayer() { + + let i = this.nlayers; + while(i--){ + this.tempHouseLayers[i] = 0; + this.tempBuildingLayers[i] = 0; + } + + } + + updateLayer() { + + let i = this.nlayers; + + while(i--){ + + if( layerData[i] === 1 ) this.drawLayer( i ) + if(this.tempHouseLayers[i] === 1){ this.rebuildHouseLayer(i); this.tempHouseLayers[i] = 0 } + if(this.tempBuildingLayers[i] === 1){ this.rebuildBuildingLayer(i); this.tempBuildingLayers[i] = 0; } + + } + + } + + drawLayer ( layer, full ){ + + let y = 16, x, v, n, cy, cx, ar, i, vx, vy, g; + let ly = Math.floor(layer/8) + let lx = Math.floor(layer-(ly*8)) + + let pix = 32; + let mid = pix * 0.5; + + while( y-- ){ + + x = 16; + while(x--){ + + vx = (lx*16)+x + vy = (ly*16)+y + + n = vx+(vy*this.mapSize[1]) + v = tilesData[n]; + + g = v < 240 ? v : 0; + + if( !full && v === this.oldData[n] ) continue; + this.oldData[n] = v; + + if( g < 240 ){ + + this.tmpPos.x = x*mid*this.mu + this.tmpPos.y = (240 - y*mid)*this.mu + + // apply tile change + this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('texture', g), this.terrainTxt[layer] ); + if( this.isWithNormal ) this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('normal', g), this.terrainTxtN[layer] ); + if( this.isWithRoughness ) this.renderer.copyTextureToTexture( this.tmpPos, this.pool.tile('roughness', g), this.terrainTxtR[layer] ); + + } + + if( v > 239 ){ + + // MESH BUILD + if((v>248 && v<261) || v==0){ + if(this.houseLists[layer]){ + i = this.houseLists[layer].length; + while(i--){ + ar = this.houseLists[layer][i]; + if( ar[0] === vx && ar[2] === vy ){ + if( ar[3] !== v ){ + this.houseLists[layer][i][3] = v; + this.tempHouseLayers[layer] = 1; + } + } + } + } + } else { + if(this.buildingLists[layer]){ + i = this.buildingLists[layer].length; + while(i--){ + ar = this.buildingLists[layer][i]; + if( ar[0] === vx && ar[2] === vy ){ + if( ar[3] !== v ){ + this.buildingLists[layer][i][3] = v; + this.tempBuildingLayers[layer] = 1; + } + } + } + } + } + + } + + + } + } + } + + + // ----------------------- + // SPRITE + // ----------------------- + + moveSprite () { + + if(!spriteData) return + + let i = spriteData.length; + let pos = new THREE.Vector3(); + let v, frame, c; + + while(i--){ + c = spriteData[i] + frame = c[1] + v = c[0] + pos.x = Math.round((c[2]-8)/16); + pos.z = Math.round((c[3]-8)/16); + pos.y = 0; + + + if( this.isWithHeight ) pos.y = this.heightData[ this.findHeightId(pos.x,pos.z) ]; + + + if( c[0] == 2) pos.y += 5; + if( c[0] == 3){ + if(frame==11)pos.y += 0; + else if(frame==10)pos.y += 1; + else if (frame==9)pos.y += 3; + else pos.y += 6; + } + + //if(this.spriteMeshs[i] == null) this.addSprite( i, c[0], pos ); + //this.spriteMeshs[i].position.lerp(pos, 0.6); + //this.spriteMeshs[i].rotation.y = this.rotationSprite(c[0], frame); + + /*if(this.spriteObjs[this.spriteLists[v]] == null) this.spriteObjs[this.spriteLists[v]] = this.addSprite( v, pos ); + this.spriteObjs[this.spriteLists[v]].position.lerp(pos, 0.6); + this.spriteObjs[this.spriteLists[v]].rotation.y = this.rotationSprite(c[0], frame);*/ + + if(this.spriteObjs[this.spriteLists[v]] == null) this.spriteObjs[this.spriteLists[v]] = this.addSprite( v, pos ); + + // underwater train + if(v===1 && frame===5)this.spriteObjs[this.spriteLists[v]].visible = false; + else this.spriteObjs[this.spriteLists[v]].visible = true; + + this.spriteObjs[this.spriteLists[v]].position.lerp(pos, 0.6); + this.spriteObjs[this.spriteLists[v]].rotation.y = this.rotationSprite(c[0], frame); + } + } + + rotationSprite ( v, f ) { + + let r = 0; + if(v===1){// train + if(f===1) r = 0; + else if(f===2) r = 90*this.ToRad; + else if(f===3) r = 45*this.ToRad; + else if(f===4) r = -45*this.ToRad; + }else if(v===2 || v===3){// elico plane + if(f===1) r = 0; + else if(f===2) r = -45*this.ToRad; + else if(f===3) r = -90*this.ToRad; + else if(f===4) r = -135*this.ToRad; + else if(f===5) r = -180*this.ToRad; + else if(f===6) r = -225*this.ToRad; + else if(f===7) r = -270*this.ToRad; + else if(f===8) r = -315*this.ToRad; + + else if(f===9) r = -90*this.ToRad; + else if(f===10) r = -90*this.ToRad; + else if(f===11) r = -90*this.ToRad; + } + return r + + } + + addSprite ( v, p ) { + + let m; + if(v===1){// train + m = new THREE.Mesh(this.pool.geo('sprite',0), this.townMaterial ); + //m.scale.set(1, 1, -1 ) + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + //this.spriteObjs[this.spriteLists[v]] = m; + }else if(v===2){// elico + m = new THREE.Mesh(this.pool.geo('sprite',1), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + }else if(v===3){// plane + m = new THREE.Mesh(this.pool.geo('sprite',2), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + } else { + m = new THREE.Mesh(new THREE.BoxGeometry(1,1,1), this.townMaterial ); + m.position.copy(p); + this.scene.add(m); + //this.spriteMeshs[i] = m; + } + return m; + + //this.spriteObjs[this.spriteLists[v]] = m; + } + + + + // ----------------------- + // POWER SPRITE + // ----------------------- + + showPower (){ + + //if( !powerData ) return + + let i = powerData.length, pos; + while(i--){ + if(powerData[i]===0) continue;//{ if( this.powerMeshs[i] !== null ) this.removePowerMesh(i); } + else if(powerData[i]===2){ if(this.powerMeshs[i] == null) this.addPowerMesh(i, this.findPosition(i)); } + else if(powerData[i]===1){ if(this.powerMeshs[i] !== null) this.removePowerMesh(i); } + } + + } + + addPowerMesh ( i, ar ) { + + let py = 0; + + if( this.isWithHeight ) py = this.heightData[ this.findHeightId(ar[0],ar[1])]; + + let m = new THREE.Sprite( this.powerMaterial ); + //m.scale.set( 2, 2, 1 ); + m.position.set(ar[0], py+1, ar[1]); + this.scene.add(m); + this.powerMeshs[i] = m; + } + + removePowerMesh ( i ) { + this.scene.remove(this.powerMeshs[i]); + this.powerMeshs[i] = null; + } + + + + // ----------------------- + // AUTO TEXTURE + // ----------------------- + + powerTexture () { + + let c = document.createElement("canvas"); + let ctx = c.getContext("2d"); + c.width = c.height = 64; + let grd = ctx.createLinearGradient(0,0,64,64); + grd.addColorStop(0.3,"yellow"); + grd.addColorStop(1,"red"); + ctx.beginPath(); + ctx.moveTo(44,0); + ctx.lineTo(10,34); + ctx.lineTo(34,34); + ctx.lineTo(20,64); + ctx.lineTo(54,30); + ctx.lineTo(30,30); + ctx.lineTo(44,0); + ctx.closePath(); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.fillStyle = grd; + ctx.fill(); + let texture = new THREE.Texture(c); + texture.needsUpdate = true; + return texture; + + } + + gradTexture (color) { + let c = document.createElement("canvas"); + let ctx = c.getContext("2d"); + c.width = 16; c.height = 256; + let gradient = ctx.createLinearGradient(0,0,0,256); + let i = color[0].length; + while(i--){ gradient.addColorStop(color[0][i],color[1][i]); } + ctx.fillStyle = gradient; + ctx.fillRect(0,0,16,256); + //this.tint(c); + //let texture = new THREE.Texture(c); + //texture.needsUpdate = true; + return c; + } + + tint (canvas, image, supImage) { + let data, i, n; + let pixels = canvas.width*canvas.height; + let ctx = canvas.getContext('2d'); + + // draw windows + let topData = null; + let newImg = null; + if(supImage && this.dayTime!==0 && this.dayTime!==1){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(supImage, 0, 0); + topData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = topData.data; + i = pixels; + while(i--){ + n = i<<2; + if(data[n+3] !== 0){ + if(data[n+0]==0 && data[n+1]==0 && data[n+2]==0){// black + data[n+3]=60; + } + if(data[n+1]==0){ + //if(data[n+0]==255 && data[n+1]==0 && data[n+2]==0){// red + if(this.dayTime==3) data[n+1]=255; + if(this.dayTime==2) {data[n+0]=0; data[n+3]=60;} + } + + } + } + ctx.putImageData(topData, 0, 0); + newImg = document.createElement('img'); + newImg.src = canvas.toDataURL("image/png"); + } + + if(image){ + ctx.clearRect ( 0 , 0 , canvas.width, canvas.height ); + ctx.drawImage(image, 0, 0); + } else { + ctx.drawImage(this.skyCanvasBasic, 0, 0); + } + + if(this.dayTime!==0){ + let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + data = imageData.data; + i = pixels; + let c = this.tcolor; + while(i--){ + n = i<<2;//i*4; + data[n+0] = data[n+0] * (1-c.a) + (c.r*c.a); + data[n+1] = data[n+1] * (1-c.a) + (c.g*c.a); + data[n+2] = data[n+2] * (1-c.a) + (c.b*c.a); + } + ctx.putImageData(imageData, 0, 0); + if(newImg){ + ctx.drawImage(newImg, 0, 0); + } + } + } + + // ----------------------- + // KEYBOARD + // ----------------------- + + updateKey (){ + + // 移除移动端限制,支持虚拟方向键 + + let f = 0.3, d = false; + + if(this.key[0] == 1 || this.key[1] == 1 ){ + if(this.key[0] == 1)this.ease.z = -f; + if(this.key[1] == 1)this.ease.z = f; + d = true; + } + else this.ease.z = 0; + + if(this.key[2] == 1 || this.key[3] == 1 ){ + if(this.key[2] == 1)this.ease.x = -f; + if(this.key[3] == 1)this.ease.x = f; + d = true; + } + else this.ease.x = 0; + if( d ) this.dragCenterposition(); + + } + + bindKeys (){ + + let _this = this; + + document.onkeydown = function(e) { + e = e || window.event; + switch ( e.keyCode ) { + case 38: case 87: case 90: _this.key[0] = 1; break; // up, W, Z + case 40: case 83: _this.key[1] = 1; break; // down, S + case 37: case 65: case 81: _this.key[2] = 1; break; // left, A, Q + case 39: case 68: _this.key[3] = 1; break; // right, D + //case 17: case 67: _this.key[4] = 1; break; // ctrl, C + //case 69: _this.key[5] = 1; break; // E + //case 32: _this.key[6] = 1; break; // space + } + } + document.onkeyup = function(e) { + e = e || window.event; + switch( e.keyCode ) { + case 38: case 87: case 90: _this.key[0] = 0; break; // up, W, Z + case 40: case 83: _this.key[1] = 0; break; // down, S + case 37: case 65: case 81: _this.key[2] = 0; break; // left, A, Q + case 39: case 68: _this.key[3] = 0; break; // right, D + //case 17: case 67: _this.key[4] = 0; break; // ctrl, C + //case 69: _this.key[5] = 0; break; // E + //case 32: _this.key[6] = 0; break; // space + } + } + self.focus(); + + } + + +} diff --git a/games/3dcity/src/destructor.js b/games/3dcity/src/destructor.js new file mode 100644 index 0000000..c58344b --- /dev/null +++ b/games/3dcity/src/destructor.js @@ -0,0 +1,83 @@ + +//------------------------------------------------------// +// DESTRUCTOR // +//------------------------------------------------------// + +'use strict'; + +V3D.Destructor = function(){ + this.emitter = null; + this.particleGroup = null; + this.atmosphereBurnEmitter = null; + + this.obj = []; + this.objInfo = []; + + this.timestep = 1000/60; + this.timer; + this.time; + this.maxDecal; + this.posDecal; + this.reflectionCube = null; + this.smokeTexture = null; + this.isDestroy = false; + this.isBurn = false; + + + this.snd_destroy = null; + this.snd_destroy2 = null; + + init(); +} + + +V3D.Destructor.prototype = { + constructor: V3D.Destructor, + init:function() { + + // environement + var c3 = document.createElement("canvas"); + var ctx = c3.getContext("2d"); + c3.width = c3.height = 64; + ctx.rect(0, 0, 64, 64); + ctx.fillStyle = "#cc7f66"; + ctx.fill(); + + this.reflectionCube = new THREE.Texture([c3,c3,c3,c3,c3,c3]); + this.reflectionCube.needsUpdate = true; + + // texture + this.smokeTexture = THREE.ImageUtils.loadTexture('./img/smoke.png'); + + // sound + this.snd_destroy = new Audio("./sound/explosion-low.mp3"); + this.snd_destroy2 = new Audio("./sound/explosion-high.mp3"); + }, + destruct : function(geo, mat, position){ + var material = mat.clone() + material.reflectivity = 0; + material.combine = THREE.MixOperation; + material.envMap = this.reflectionCube; + material.side = THREE.DoubleSide; + + var geometry = geo.clone(); + geometry.computeBoundingBox(); + var box = geometry.boundingBox; + + var mesh = new THREE.Mesh(geometry, material); + mesh.position.copy(position); + + this.objInfo.push( [Number(box.max.y.toFixed(2)), Number(box.min.y.toFixed(2)), Number((box.max.x + Math.abs(box.min.x)).toFixed(2)), Number((box.max.z + Math.abs(box.min.z)).toFixed(2)), geometry.vertices.length]); + this.obj.push(mesh); + + view3d.scene.add(mesh); + } + + + + + + + + +} \ No newline at end of file diff --git a/games/3dcity/src/draco/draco_decoder.js b/games/3dcity/src/draco/draco_decoder.js new file mode 100644 index 0000000..e58cce9 --- /dev/null +++ b/games/3dcity/src/draco/draco_decoder.js @@ -0,0 +1,48 @@ + +var DracoDecoderModule = (function() { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(DracoDecoderModule) { + DracoDecoderModule = DracoDecoderModule || {}; + +var Module=typeof DracoDecoderModule!=="undefined"?DracoDecoderModule:{};var isRuntimeInitialized=false;var isModuleParsed=false;Module["onRuntimeInitialized"]=function(){isRuntimeInitialized=true;if(isModuleParsed){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};Module["onModuleParsed"]=function(){isModuleParsed=true;if(isRuntimeInitialized){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};function isVersionSupported(versionString){if(typeof versionString!=="string")return false;const version=versionString.split(".");if(version.length<2||version.length>3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(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){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;if(end>_emscripten_get_heap_size()){abort()}HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(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 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}function convertJsFunctionToWasm(func,sig){return func}function addFunctionWasm(func,sig){var table=wasmTable;var ret=table.length;try{table.grow(1)}catch(err){if(!err instanceof RangeError){throw err}throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{table.set(ret,func)}catch(err){if(!err instanceof TypeError){throw err}assert(typeof sig!=="undefined","Missing signature argument to addFunction");var wrapped=convertJsFunctionToWasm(func,sig);table.set(ret,wrapped)}return ret}function removeFunctionWasm(index){}var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];var WebAssembly={Memory:function(opts){return{buffer:new ArrayBuffer(opts["initial"]*65536),grow:function(amount){var ret=__growWasmMemory(amount);return ret}}},Table:function(opts){var ret=new Array(opts["initial"]);ret.grow=function(by){if(ret.length>=293+0){abort("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.")}ret.push(null)};ret.set=function(i,func){ret[i]=func};ret.get=function(i){return ret[i]};return ret},Module:function(binary){return{}},Instance:function(module,info){var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=0;o[c>>2]=0;o[c+4>>2]=0;d=_j(b);if(d>>>0<4294967280){a:{b:{if(d>>>0>=11){f=d+16&-16;e=Hk(f);o[c+8>>2]=f|-2147483648;o[c>>2]=e;o[c+4>>2]=d;break b}m[c+11|0]=d;e=c;if(!d){break a}}wl(e,b,d)}m[d+e|0]=0;a=ea(a,c);if(m[c+11|0]<=-1){ul(o[c>>2])}R=c+16|0;return(a|0)!=0}Kk();D()}function ea(a,b){var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=o[a+4>>2];if(a){h=p[b+11|0];i=h<<24>>24<0;h=i?o[b+4>>2]:h;l=i?o[b>>2]:b;while(1){b=a+16|0;g=p[a+27|0];i=g<<24>>24<0;j=i?o[a+20>>2]:g;m=j>>>0>>0;a:{b:{c:{d:{e:{f:{g=m?j:h;if(g){k=i?o[b>>2]:b;n=Zj(l,k,g);if(n){break f}}if(h>>>0>>0){break a}if(!g){break d}k=i?o[b>>2]:b;break e}if((n|0)<=-1){break a}}b=Zj(k,l,g);if(b){break c}}if(m){break b}return 1}if((b|0)<=-1){break b}return 1}a=a+4|0}a=o[a>>2];if(a){continue}break}}return 0}function fa(a,b){var p=0,q=0,r=0,s=0;p=R-16|0;R=p;o[p+12>>2]=0;o[p+8>>2]=0;o[p>>2]=0;o[p+4>>2]=0;q=_j(b);if(q>>>0<4294967280){a:{b:{if(q>>>0>=11){s=q+16&-16;r=Hk(s);o[p+8>>2]=s|-2147483648;o[p>>2]=r;o[p+4>>2]=q;break b}m[p+11|0]=q;r=p;if(!q){break a}}wl(r,b,q)}m[q+r|0]=0;jj(a,p,p+12|0);a=o[p+12>>2];if(m[p+11|0]<=-1){ul(o[p>>2])}R=p+16|0;return a}Kk();D()}function ga(a,b,t){var u=0,v=0,w=0,x=0;u=R-32|0;R=u;o[u+24>>2]=0;o[u+16>>2]=0;o[u+20>>2]=0;v=_j(b);if(v>>>0<4294967280){a:{b:{if(v>>>0>=11){x=v+16&-16;w=Hk(x);o[u+24>>2]=x|-2147483648;o[u+16>>2]=w;o[u+20>>2]=v;break b}m[u+27|0]=v;w=u+16|0;if(!v){break a}}wl(w,b,v)}m[v+w|0]=0;o[u+8>>2]=0;o[u>>2]=0;o[u+4>>2]=0;kj(a,u+16|0,u);a=o[t>>2];if(a){o[t+4>>2]=a;ul(a);o[t+8>>2]=0;o[t>>2]=0;o[t+4>>2]=0}o[t>>2]=o[u>>2];o[t+4>>2]=o[u+4>>2];o[t+8>>2]=o[u+8>>2];if(m[u+27|0]<=-1){ul(o[u+16>>2])}R=u+32|0;return}Kk();D()}function ha(a,b){var y=0,z=0,A=0,B=0,C=0;y=R-32|0;R=y;o[y+24>>2]=0;o[y+28>>2]=0;o[y+16>>2]=0;o[y+8>>2]=0;o[y+12>>2]=0;z=_j(b);if(z>>>0<4294967280){a:{b:{if(z>>>0>=11){B=z+16&-16;A=Hk(B);o[y+16>>2]=B|-2147483648;o[y+8>>2]=A;o[y+12>>2]=z;break b}m[y+19|0]=z;A=y+8|0;if(!z){break a}}wl(A,b,z)}m[z+A|0]=0;lj(a,y+8|0,y+24|0);C=t[y+24>>3];if(m[y+19|0]<=-1){ul(o[y+8>>2])}R=y+32|0;return C}Kk();D()}function ia(a,b,t){var E=0,F=0,G=0,H=0;E=R-16|0;R=E;o[E+8>>2]=0;o[E>>2]=0;o[E+4>>2]=0;F=_j(t);if(F>>>0<4294967280){a:{b:{if(F>>>0>=11){H=F+16&-16;G=Hk(H);o[E+8>>2]=H|-2147483648;o[E>>2]=G;o[E+4>>2]=F;break b}m[E+11|0]=F;G=E;if(!F){break a}}wl(G,t,F)}m[F+G|0]=0;a=a+16|0;t=0;c:{if(!mj(b,E,a)){break c}t=o[a>>2];if(m[a+11|0]<=-1){break c}t=a}if(m[E+11|0]<=-1){ul(o[E>>2])}R=E+16|0;return t}Kk();D()}function ja(a,b,t){var D=0,I=0,J=0,K=0;a:{if(o[a+12>>2]==(b|0)){break a}D=o[a>>2];J=a+4|0;I=o[J>>2];if((D|0)!=(I|0)){while(1){K=I+ -12|0;if(m[I+ -1|0]<=-1){ul(o[K>>2])}I=K;if((I|0)!=(D|0)){continue}break}}o[a+12>>2]=b;o[J>>2]=D;I=o[b>>2];J=b+4|0;if((I|0)==(J|0)){break a}K=a+8|0;while(1){b=I+16|0;b:{if(o[K>>2]!=(D|0)){Mk(D,b);b=a+4|0;o[b>>2]=o[b>>2]+12;break b}ka(a,b)}D=o[I+4>>2];c:{if(!D){b=o[I+8>>2];if(o[b>>2]==(I|0)){break c}I=I+8|0;while(1){D=o[I>>2];I=D+8|0;b=o[D+8>>2];if((D|0)!=o[b>>2]){continue}break}break c}while(1){b=D;D=o[D>>2];if(D){continue}break}}if((b|0)==(J|0)){break a}D=o[a+4>>2];I=b;continue}}D=0;d:{if((t|0)<0){break d}b=o[a+4>>2];a=o[a>>2];if((b-a|0)/12>>>0<=t>>>0){break d}D=a+u(t,12)|0;if(m[D+11|0]>-1){break d}D=o[D>>2]}return D}function ka(a,b){var t=0,L=0,M=0,N=0,O=0;a:{b:{c:{M=o[a>>2];O=(o[a+4>>2]-M|0)/12|0;t=O+1|0;if(t>>>0<357913942){M=(o[a+8>>2]-M|0)/12|0;N=M<<1;t=M>>>0<178956970?N>>>0>>0?t:N:357913941;L=0;d:{if(!t){break d}if(t>>>0>=357913942){break c}L=Hk(u(t,12))}M=L+u(t,12)|0;b=Mk(L+u(O,12)|0,b);O=b+12|0;t=o[a+4>>2];L=o[a>>2];if((t|0)==(L|0)){break b}while(1){t=t+ -12|0;N=o[t+4>>2];b=b+ -12|0;o[b>>2]=o[t>>2];o[b+4>>2]=N;N=t+8|0;o[b+8>>2]=o[N>>2];o[t>>2]=0;o[t+4>>2]=0;o[N>>2]=0;if((t|0)!=(L|0)){continue}break}L=o[a+4>>2];t=o[a>>2];break a}Yk();D()}_a(1040);D()}t=L}o[a>>2]=b;o[a+8>>2]=M;o[a+4>>2]=O;if((t|0)!=(L|0)){while(1){a=L+ -12|0;if(m[L+ -1|0]<=-1){ul(o[a>>2])}L=a;if((a|0)!=(t|0)){continue}break}}if(t){ul(t)}}function la(a){var b=0;ui(a);b=a+16|0;o[b>>2]=0;o[b+4>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0;o[a+12>>2]=b;o[a+32>>2]=0;o[a+36>>2]=0;return a}function ma(a){var P=0;P=R-32|0;R=P;Rf(P+8|0,a);a=o[P+24>>2];if(m[P+23|0]<=-1){ul(o[P+12>>2])}R=P+32|0;return a}function na(a){var Q=0;Q=R-16|0;R=Q;Tf(Q);o[a+24>>2]=o[Q>>2];Ok(a+28|0,Q|4);a=a+24|0;if(m[Q+15|0]<=-1){ul(o[Q+4>>2])}R=Q+16|0;return a}function oa(a,S,T){var U=0;U=R-16|0;R=U;Sf(U,a,S,T);o[a+24>>2]=o[U>>2];Ok(a+28|0,U|4);a=a+24|0;if(m[U+15|0]<=-1){ul(o[U+4>>2])}R=U+16|0;return a}function pa(a,S){var T=0,V=0,W=0,X=0;T=R-32|0;R=T;o[T+24>>2]=0;o[T+16>>2]=0;o[T+20>>2]=0;V=_j(S);if(V>>>0<4294967280){a:{b:{if(V>>>0>=11){X=V+16&-16;W=Hk(X);o[T+24>>2]=X|-2147483648;o[T+16>>2]=W;o[T+20>>2]=V;break b}m[T+27|0]=V;W=T+16|0;if(!V){break a}}wl(W,S,V)}m[V+W|0]=0;o[T+8>>2]=67108864;o[T>>2]=0;o[T+4>>2]=0;m[T+4|0]=0;o[T>>2]=1701667182;V=o[a+4>>2];S=-1;c:{if(!V){break c}V=dj(V,T,T+16|0);S=-1;if(!V){break c}S=uj(a,o[V+24>>2])}if(m[T+11|0]<=-1){ul(o[T>>2])}if(m[T+27|0]<=-1){ul(o[T+16>>2])}R=T+32|0;return S}Kk();D()}function qa(a,S,Y){var Z=0,_=0,$=0,aa=0;Z=R-32|0;R=Z;o[Z+24>>2]=0;o[Z+16>>2]=0;o[Z+20>>2]=0;a:{aa=_j(S);if(aa>>>0<4294967280){b:{c:{if(aa>>>0>=11){_=aa+16&-16;$=Hk(_);o[Z+24>>2]=_|-2147483648;o[Z+16>>2]=$;o[Z+20>>2]=aa;break c}m[Z+27|0]=aa;$=Z+16|0;if(!aa){break b}}wl($,S,aa)}m[$+aa|0]=0;o[Z+8>>2]=0;o[Z>>2]=0;o[Z+4>>2]=0;_=_j(Y);if(_>>>0>=4294967280){break a}d:{e:{if(_>>>0>=11){S=_+16&-16;$=Hk(S);o[Z+8>>2]=S|-2147483648;o[Z>>2]=$;o[Z+4>>2]=_;break e}m[Z+11|0]=_;$=Z;if(!_){break d}}wl($,Y,_)}m[_+$|0]=0;Y=o[a+4>>2];S=-1;f:{if(!Y){break f}Y=dj(Y,Z+16|0,Z);S=-1;if(!Y){break f}S=uj(a,o[Y+24>>2])}a=S;if(m[Z+11|0]<=-1){ul(o[Z>>2])}if(m[Z+27|0]<=-1){ul(o[Z+16>>2])}R=Z+32|0;return a}Kk();D()}Kk();D()}function ra(a,S,Y){var ba=0,ca=0,da=0;ba=R-16|0;R=ba;ca=o[a+96>>2];o[ba+8>>2]=0;o[ba>>2]=0;o[ba+4>>2]=0;a=Hk(12);o[ba>>2]=a;o[ba+4>>2]=a;da=a+12|0;o[ba+8>>2]=da;ca=wl(a,ca+u(S,12)|0,12)+12|0;o[ba+4>>2]=ca;S=o[Y>>2];if(S){o[Y+4>>2]=S;ul(S);o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0}o[Y>>2]=a;o[Y+8>>2]=da;o[Y+4>>2]=ca;R=ba+16|0;return 1}function sa(a,S){var Y=0,ea=0;Y=R-96|0;R=Y;xl(Y+16|0,0,76);o[Y+92>>2]=-1;o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0;a:{if(ta(Y+16|0,a,Y)){a=o[S>>2];if(a){o[S+4>>2]=a;ul(a);o[S+8>>2]=0;o[S>>2]=0;o[S+4>>2]=0}o[S>>2]=o[Y>>2];o[S+4>>2]=o[Y+4>>2];o[S+8>>2]=o[Y+8>>2];o[Y+8>>2]=0;o[Y>>2]=0;o[Y+4>>2]=0;ea=o[Y+84>>2];break a}a=o[Y>>2];if(!a){break a}o[Y+4>>2]=a;ul(a)}a=o[Y+72>>2];if(a){ul(a)}a=o[Y+48>>2];if(a){o[Y+52>>2]=a;ul(a)}a=o[Y+36>>2];if(a){o[Y+40>>2]=a;ul(a)}a=o[Y+24>>2];if(a){o[Y+28>>2]=a;ul(a)}a=o[Y+20>>2];o[Y+20>>2]=0;if(a){ua(Y+16|4,a)}R=Y+96|0;return ea}function ta(a,S,fa){var ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0;ja=R-16|0;R=ja;a:{if(!va(a,S)){break a}ia=1;ha=o[S+96>>2];oa=S+100|0;ga=o[oa>>2];if((ha|0)==(ga|0)){break a}pa=a+12|0;qa=a+24|0;ra=a+36|0;na=fa+8|0;la=fa+4|0;while(1){if(!(o[o[a+56>>2]+(ma>>>3&536870908)>>2]>>>(ma&31)&1)){ia=u(ma,3);Zi(a,0,ia);sa=o[pa>>2];ka=o[a+8>>2];Zi(a,1,ia+1|0);ha=o[qa>>2];ga=o[a+20>>2];Zi(a,2,ia+2|0);ia=ha-ga>>2;ha=sa-ka|0;ga=ha>>2;ka=ia>>>0>ga>>>0;ka=o[ra>>2]-o[a+32>>2]>>2>>>0>(ka?ia:ga)>>>0?2:ka?1:ha?0:-1;b:{if(o[a+68>>2]<1){break b}ga=o[a+76>>2];o[ja+12>>2]=ga;ha=o[la>>2];c:{if(ha>>>0>2]){o[ha>>2]=ga;o[la>>2]=ha+4;break c}wa(fa,ja+12|0)}ga=ja;ia=o[((ka<<2)+a|0)+44>>2];ha=-1;d:{if((ia|0)<0){break d}ha=(ia>>>0)/3|0;ha=o[(o[o[a>>2]+96>>2]+u(ha,12)|0)+(ia-u(ha,3)<<2)>>2]}o[ga+8>>2]=ha;ga=o[la>>2];e:{if(ga>>>0>2]){o[ga>>2]=ha;o[la>>2]=ga+4;break e}wa(fa,ja+8|0)}ga=o[a+72>>2]+2|0;o[a+72>>2]=ga;if(!(ga&1)){break b}o[ja+4>>2]=ha;ga=o[la>>2];f:{if(ga>>>0>2]){o[ga>>2]=ha;o[la>>2]=ga+4;break f}wa(fa,ja+4|0)}o[a+72>>2]=o[a+72>>2]+1}xa(a,ka,fa);ha=o[S+96>>2];ga=o[oa>>2]}ia=1;ma=ma+1|0;if(ma>>>0<(ga-ha|0)/12>>>0){continue}break}}R=ja+16|0;return ia}function ua(a,R){if(R){a=o[R+76>>2];if(a){o[R+80>>2]=a;ul(a)}a=o[R- -64>>2];if(a){o[R+68>>2]=a;ul(a)}a=o[R+48>>2];if(a){o[R+52>>2]=a;ul(a)}a=o[R+24>>2];if(a){o[R+28>>2]=a;ul(a)}a=o[R+12>>2];if(a){o[R+16>>2]=a;ul(a)}a=o[R>>2];if(a){o[R+4>>2]=a;ul(a)}ul(R)}}function va(a,S){var fa=0,ta=0,va=0;fa=R-16|0;R=fa;o[a+68>>2]=0;o[a+72>>2]=0;o[a>>2]=S;Yi(fa+8|0,S);ta=o[fa+8>>2];o[fa+8>>2]=0;va=o[a+4>>2];o[a+4>>2]=ta;a:{if(!va){o[fa+8>>2]=0;break a}ta=a+4|0;ua(ta,va);va=o[fa+8>>2];o[fa+8>>2]=0;if(va){ua(fa+8|0,va)}ta=o[ta>>2]}if(ta){ta=o[S+100>>2];S=o[S+96>>2];m[fa+7|0]=0;$a(a+56|0,(ta-S|0)/12|0,fa+7|0);a=1}else{a=0}R=fa+16|0;return a}function wa(a,R){var S=0,ua=0,wa=0,xa=0,ya=0,za=0;a:{wa=o[a>>2];ya=o[a+4>>2]-wa|0;S=ya>>2;ua=S+1|0;if(ua>>>0<1073741824){za=S<<2;S=o[a+8>>2]-wa|0;xa=S>>1;ua=S>>2>>>0<536870911?xa>>>0>>0?ua:xa:1073741823;S=0;b:{if(!ua){break b}if(ua>>>0>=1073741824){break a}S=Hk(ua<<2)}xa=za+S|0;o[xa>>2]=o[R>>2];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>>2]}o[Da+76>>2]=Ca;o[Ea+12>>2]=Ca;Da=o[Fa>>2];if(Da>>>0>2]){o[Da>>2]=Ca;o[Fa>>2]=Da+4;break b}wa(Ba,Ea+12|0);break b}Ca=(Aa|0)<0?-1:o[(o[o[a>>2]+96>>2]+u(Ga,12)|0)+((Aa>>>0)%3<<2)>>2];o[a+76>>2]=Ca;o[Ea+12>>2]=Ca;Da=o[Fa>>2];g:{if(Da>>>0>2]){o[Da>>2]=Ca;o[Fa>>2]=Da+4;break g}wa(Ba,Ea+12|0)}if(Ia&1){Ca=-1;if((Aa|0)==-1){break a}if(Aa-u(Ga,3)){Aa=Aa+ -1|0;break b}Aa=Aa+2|0;break b}Ca=-1;if((Aa|0)==-1){break a}Ca=Aa+1|0;Aa=(Ca>>>0)%3|0?Ca:Aa+ -2|0}Ca=-1;if((Aa|0)==-1){break a}Ca=o[o[o[a+4>>2]+12>>2]+(Aa<<2)>>2]}Ia=Ia+1|0;if((Ia|0)<(Ja|0)){continue}break}}R=Ea+16|0}function ya(a,R,Aa){var Ba=0,Ka=0,La=0;a:{if(r[a+80>>2]>65535){break a}Ka=o[a+96>>2];a=o[a+100>>2]-Ka|0;La=(a|0)/12|0;if((u(La,6)|0)!=(R|0)){break a}if(!a){return 1}a=0;while(1){R=u(a,6)+Aa|0;Ba=u(a,12)+Ka|0;n[R>>1]=o[Ba>>2];n[R+2>>1]=o[Ba+4>>2];n[R+4>>1]=o[Ba+8>>2];Ba=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ba}function za(a,R,Aa){var Ma=0,Na=0,Oa=0;Na=o[a+96>>2];a=o[a+100>>2]-Na|0;Oa=(a|0)/12|0;if((a|0)==(R|0)){if(!R){return 1}a=0;while(1){Ma=u(a,12);R=Ma+Aa|0;Ma=Ma+Na|0;o[R>>2]=o[Ma>>2];o[R+4>>2]=o[Ma+4>>2];o[R+8>>2]=o[Ma+8>>2];Ma=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ma}function Aa(a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=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(p[R|0]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(255)):Wa;R=R+1|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 1:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(n[R>>1]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(32767)):Wa;R=R+2|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 2:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(q[R>>1]);s[(Va<<2)+Pa>>2]=Xa?v(Wa/v(65535)):Wa;R=R+2|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 3:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(o[R>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(4.656612873077393e-10)):Wa;R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 4:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(r[R>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(2.3283064365386963e-10)):Wa;R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 5:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(+r[R>>2]+4294967296*+o[R+4>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(1.0842021724855044e-19)):Wa;R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 6:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;Xa=p[a+32|0];while(1){Wa=v(+r[R>>2]+4294967296*+r[R+4>>2]);s[(Va<<2)+Pa>>2]=Xa?v(Wa*v(5.421010862427522e-20)):Wa;R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 7:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){o[(Va<<2)+Pa>>2]=o[R>>2];R=R+4|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 8:Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){s[(Va<<2)+Pa>>2]=t[R>>3];R=R+8|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}break a;case 9:break c}}Ya=1;Ua=m[a+24|0];if(((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24>=1){Ua=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Ua+R|0;while(1){s[(Va<<2)+Pa>>2]=p[R|0]?v(1):v(0);R=R+1|0;Va=Va+1|0;Ua=m[a+24|0];if((Va|0)<((Ua|0)>(Aa|0)?Aa:Ua)<<24>>24){continue}break}}if((Ua|0)>=(Aa|0)){break b}xl((Ua<<2)+Pa|0,0,Aa-Ua<<2)}return Ya}xl((Ua<<2)+Pa|0,0,Aa-Ua<<2);return 1}function Ca(a,Aa,Pa){var Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0;Za=R-16|0;R=Za;bb=o[a+80>>2];cb=m[Aa+24|0];a=o[259];o[Za+8>>2]=o[258];o[Za+12>>2]=a;a=o[257];o[Za>>2]=o[256];o[Za+4>>2]=a;a=u(bb,cb);$a=o[Pa>>2];_a=o[Pa+4>>2]-$a>>2;a:{if(a>>>0>_a>>>0){Da(Pa,a-_a|0);break a}if(a>>>0>=_a>>>0){break a}o[Pa+4>>2]=$a+(a<<2)}b:{if(!bb){a=1;break b}$a=0;db=Aa+68|0;eb=(cb|0)<1;while(1){a=ab;_a=Aa;if(!p[_a+84|0]){a=o[o[db>>2]+(ab<<2)>>2]}if(!Ba(_a,a,m[Aa+24|0],Za)){a=0;break b}if(!eb){_a=o[Pa>>2];a=0;while(1){o[_a+($a<<2)>>2]=o[(a<<2)+Za>>2];$a=$a+1|0;a=a+1|0;if((cb|0)!=(a|0)){continue}break}}a=1;ab=ab+1|0;if((bb|0)!=(ab|0)){continue}break}}R=Za+16|0;return a}function Da(a,R){var Aa=0,Pa=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0;Pa=o[a+8>>2];fb=a+4|0;Aa=o[fb>>2];if(Pa-Aa>>2>>>0>=R>>>0){a=R<<2;kb=fb,lb=xl(Aa,0,a)+a|0,o[kb>>2]=lb;return}a:{fb=o[a>>2];hb=Aa-fb|0;Aa=hb>>2;gb=Aa+R|0;if(gb>>>0<1073741824){jb=Aa<<2;Pa=Pa-fb|0;Aa=Pa>>1;Pa=Pa>>2>>>0<536870911?Aa>>>0>>0?gb:Aa:1073741823;Aa=0;b:{if(!Pa){break b}if(Pa>>>0>=1073741824){break a}ib=Hk(Pa<<2);Aa=ib}xl(jb+Aa|0,0,R<<2);R=Aa+(gb<<2)|0;gb=Aa+(Pa<<2)|0;if((hb|0)>=1){wl(ib,fb,hb)}o[a>>2]=Aa;o[a+8>>2]=gb;o[a+4>>2]=R;if(fb){ul(fb)}return}Yk();D()}_a(1040);D()}function Ea(a,mb,nb){var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0;pb=R-16|0;R=pb;sb=o[a+80>>2];rb=m[mb+24|0];qb=u(sb,rb);a:{a=o[mb+28>>2];b:{if(!(!p[mb+84|0]|((a|0)!=2?(a|0)!=1:0))){rb=o[mb+48>>2];mb=o[o[mb>>2]>>2];o[pb+8>>2]=0;o[pb>>2]=0;o[pb+4>>2]=0;a=0;if(qb){if((qb|0)<=-1){break a}a=Hk(qb);o[pb>>2]=a;ob=a+qb|0;o[pb+8>>2]=ob;wl(a,mb+rb|0,qb);o[pb+4>>2]=ob}mb=o[nb>>2];if(mb){o[nb+4>>2]=mb;ul(mb);o[nb+8>>2]=0;o[nb>>2]=0;o[nb+4>>2]=0}o[nb>>2]=a;o[nb+8>>2]=ob;o[nb+4>>2]=ob;ob=1;break b}o[pb+8>>2]=0;o[pb>>2]=0;o[pb+4>>2]=0;if(rb){if((rb|0)<=-1){break a}ob=Hk(rb);o[pb>>2]=ob;o[pb+4>>2]=ob;o[pb+8>>2]=ob+rb;a=rb;while(1){m[ob|0]=0;ob=o[pb+4>>2]+1|0;o[pb+4>>2]=ob;a=a+ -1|0;if(a){continue}break}}ob=o[nb>>2];a=o[nb+4>>2]-ob|0;c:{if(qb>>>0>a>>>0){Fa(nb,qb-a|0);break c}if(qb>>>0>=a>>>0){break c}o[nb+4>>2]=ob+qb}d:{if(!sb){ob=1;break d}a=0;tb=mb+68|0;ub=(rb|0)<1;qb=0;while(1){ob=qb;vb=mb;if(!p[mb+84|0]){ob=o[o[tb>>2]+(qb<<2)>>2]}if(!Ga(vb,ob,m[mb+24|0],o[pb>>2])){ob=0;break d}ob=0;if(!ub){while(1){m[o[nb>>2]+a|0]=p[o[pb>>2]+ob|0];a=a+1|0;ob=ob+1|0;if((rb|0)!=(ob|0)){continue}break}}ob=1;qb=qb+1|0;if((sb|0)!=(qb|0)){continue}break}}a=o[pb>>2];if(!a){break b}o[pb+4>>2]=a;ul(a)}R=pb+16|0;return ob}Yk();D()}function Fa(a,R){var mb=0,nb=0,wb=0,xb=0,yb=0,zb=0;a:{nb=o[a+8>>2];wb=a+4|0;mb=o[wb>>2];b:{if(nb-mb>>>0>=R>>>0){while(1){m[mb|0]=0;mb=o[wb>>2]+1|0;o[wb>>2]=mb;R=R+ -1|0;if(R){continue}break b}}xb=o[a>>2];yb=mb-xb|0;mb=yb+R|0;if((mb|0)<=-1){break a}wb=0;nb=nb-xb|0;zb=nb<<1;nb=nb>>>0<1073741823?zb>>>0>>0?mb:zb:2147483647;if(nb){wb=Hk(nb)}mb=wb+yb|0;xl(mb,0,R);nb=nb+wb|0;while(1){mb=mb+1|0;R=R+ -1|0;if(R){continue}break}if((yb|0)>=1){wl(wb,xb,yb)}o[a>>2]=wb;o[a+8>>2]=nb;o[a+4>>2]=mb;if(!xb){break b}ul(xb)}return}Yk();D()}function Ga(a,R,Ab,Bb){var Cb=0,Db=0,Eb=0,Fb=0,Gb=v(0),Hb=0;a:{b:{if(!Bb){break b}Cb=o[a+28>>2]+ -1|0;if(Cb>>>0>10){break b}c:{d:{e:{switch(Cb-1|0){default:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 0:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 1:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+2|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 2:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+2|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 3:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+4|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 4:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+4|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 5:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 6:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=o[R>>2];R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}}if((Cb|0)>=(Ab|0)){break b}break a;case 7:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24<1){break c}Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){Cb=Bb+Db|0;Gb=s[R>>2];f:{if(v(w(Gb))(Ab|0)?Ab:Cb)<<24>>24){continue}break}break c;case 8:Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24<1){break d}Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){Cb=Bb+Db|0;Hb=t[R>>3];g:{if(w(Hb)<2147483648){Fb=~~Hb;break g}Fb=-2147483648}m[Cb|0]=Fb;R=R+8|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)<((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24){continue}break}break d;case 9:break e}}Eb=1;Cb=m[a+24|0];if(((Cb|0)>(Ab|0)?Ab:Cb)<<24>>24>=1){Cb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Cb+R|0;while(1){m[Bb+Db|0]=p[R|0];R=R+1|0;Db=Db+1|0;Cb=m[a+24|0];if((Db|0)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<1;Kb=0;while(1){Ib=Kb;Pb=Ab;if(!p[Ab+84|0]){Ib=o[o[Nb>>2]+(Kb<<2)>>2]}if(!Ia(Pb,Ib,m[Ab+24|0],o[Jb>>2])){Ib=0;break d}Ib=0;if(!Ob){while(1){m[o[Bb>>2]+a|0]=p[o[Jb>>2]+Ib|0];a=a+1|0;Ib=Ib+1|0;if((Lb|0)!=(Ib|0)){continue}break}}Ib=1;Kb=Kb+1|0;if((Mb|0)!=(Kb|0)){continue}break}}a=o[Jb>>2];if(!a){break b}o[Jb+4>>2]=a;ul(a)}R=Jb+16|0;return Ib}Yk();D()}function Ia(a,R,Ab,Bb){var Qb=0,Rb=0,Sb=0,Tb=0,Ub=v(0),Vb=0;a:{b:{if(!Bb){break b}Qb=o[a+28>>2]+ -1|0;if(Qb>>>0>10){break b}c:{d:{e:{switch(Qb-1|0){default:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+1|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 0:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+1|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 1:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+2|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 2:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=p[R|0];R=R+2|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 3:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 4:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 5:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 6:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24>=1){Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){m[Bb+Rb|0]=o[R>>2];R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}}if((Qb|0)>=(Ab|0)){break b}break a;case 7:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24<1){break c}Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){Qb=Bb+Rb|0;Ub=s[R>>2];f:{if(Ub=v(0)){Tb=~~Ub>>>0;break f}Tb=0}m[Qb|0]=Tb;R=R+4|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}break c;case 8:Sb=1;Qb=m[a+24|0];if(((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24<1){break d}Qb=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qb+R|0;while(1){Qb=Bb+Rb|0;Vb=t[R>>3];g:{if(Vb<4294967296&Vb>=0){Tb=~~Vb>>>0;break g}Tb=0}m[Qb|0]=Tb;R=R+8|0;Rb=Rb+1|0;Qb=m[a+24|0];if((Rb|0)<((Qb|0)>(Ab|0)?Ab:Qb)<<24>>24){continue}break}break d;case 9:break e}}Sb=1;Qb=m[a+24|0];if(((Qb|0)>(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1;c:{if(a>>>0>Xb>>>0){Ka(Bb,a-Xb|0);break c}if(a>>>0>=Xb>>>0){break c}o[Bb+4>>2]=Yb+(a<<1)}d:{if(!ac){a=1;break d}Yb=0;Zb=Ab+68|0;bc=(_b|0)<1;while(1){a=$b;Xb=Ab;if(!p[Ab+84|0]){a=o[o[Zb>>2]+($b<<2)>>2]}if(!La(Xb,a,m[Ab+24|0],o[Wb>>2])){a=0;break d}if(!bc){Xb=o[Bb>>2];a=0;cc=o[Wb>>2];while(1){n[Xb+(Yb<<1)>>1]=q[cc+(a<<1)>>1];Yb=Yb+1|0;a=a+1|0;if((_b|0)!=(a|0)){continue}break}}a=1;$b=$b+1|0;if((ac|0)!=($b|0)){continue}break}}Ab=o[Wb>>2];if(!Ab){break b}o[Wb+4>>2]=Ab;ul(Ab)}R=Wb+16|0;return a}Yk();D()}function Ka(a,R){var Ab=0,Bb=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;Bb=o[a+8>>2];dc=a+4|0;Ab=o[dc>>2];if(Bb-Ab>>1>>>0>=R>>>0){a=R<<1;ic=dc,jc=xl(Ab,0,a)+a|0,o[ic>>2]=jc;return}a:{dc=o[a>>2];fc=Ab-dc|0;Ab=fc>>1;ec=Ab+R|0;if((ec|0)>-1){hc=Ab<<1;Bb=Bb-dc|0;Bb=Bb>>1>>>0<1073741823?Bb>>>0>>0?ec:Bb:2147483647;Ab=0;b:{if(!Bb){break b}if((Bb|0)<=-1){break a}gc=Hk(Bb<<1);Ab=gc}xl(hc+Ab|0,0,R<<1);R=Ab+(ec<<1)|0;ec=Ab+(Bb<<1)|0;if((fc|0)>=1){wl(gc,dc,fc)}o[a>>2]=Ab;o[a+8>>2]=ec;o[a+4>>2]=R;if(dc){ul(dc)}return}Yk();D()}_a(1040);D()}function La(a,R,kc,lc){var mc=0,nc=0,oc=0,pc=0,qc=v(0),rc=0;a:{b:{if(!lc){break b}mc=o[a+28>>2]+ -1|0;if(mc>>>0>10){break b}c:{d:{e:{switch(mc-1|0){default:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=m[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 0:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=p[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 1:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=q[R>>1];R=R+2|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 2:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=q[R>>1];R=R+2|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 3:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 4:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 5:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 6:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=o[R>>2];R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}break a;case 7:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24<1){break c}mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){mc=(nc<<1)+lc|0;qc=s[R>>2];f:{if(v(w(qc))>1]=pc;R=R+4|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}break c;case 8:oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24<1){break d}mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){mc=(nc<<1)+lc|0;rc=t[R>>3];g:{if(w(rc)<2147483648){pc=~~rc;break g}pc=-2147483648}n[mc>>1]=pc;R=R+8|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}break d;case 9:break e}}oc=1;mc=m[a+24|0];if(((mc|0)>(kc|0)?kc:mc)<<24>>24>=1){mc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=mc+R|0;while(1){n[(nc<<1)+lc>>1]=p[R|0];R=R+1|0;nc=nc+1|0;mc=m[a+24|0];if((nc|0)<((mc|0)>(kc|0)?kc:mc)<<24>>24){continue}break}}if((mc|0)>=(kc|0)){break b}xl((mc<<1)+lc|0,0,kc-mc<<1);break b}if((mc|0)>=(kc|0)){break b}break a}if((mc|0)>=(kc|0)){break b}break a}return oc}xl((mc<<1)+lc|0,0,kc-mc<<1);return 1}function Ma(a,kc,lc){var sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0;sc=R-16|0;R=sc;yc=o[a+80>>2];wc=m[kc+24|0];a=u(yc,wc);a:{tc=o[kc+28>>2];b:{if(!(!p[kc+84|0]|((tc|0)!=4?(tc|0)!=3:0))){xc=o[kc+48>>2];tc=o[o[kc>>2]>>2];o[sc+8>>2]=0;o[sc>>2]=0;o[sc+4>>2]=0;kc=0;a=a<<1;if(a){if((a|0)<=-1){break a}uc=Hk(a);o[sc>>2]=uc;vc=(a>>1<<1)+uc|0;o[sc+8>>2]=vc;kc=wl(uc,tc+xc|0,a)+a|0;o[sc+4>>2]=kc}a=o[lc>>2];if(a){o[lc+4>>2]=a;ul(a);o[lc+8>>2]=0;o[lc>>2]=0;o[lc+4>>2]=0}o[lc>>2]=uc;o[lc+8>>2]=vc;o[lc+4>>2]=kc;a=1;break b}o[sc+8>>2]=0;o[sc>>2]=0;o[sc+4>>2]=0;if(wc){if((wc|0)<=-1){break a}tc=wc<<1;uc=Hk(tc);o[sc>>2]=uc;vc=tc+uc|0;o[sc+8>>2]=vc;xl(uc,0,tc);o[sc+4>>2]=vc}uc=o[lc>>2];tc=o[lc+4>>2]-uc>>1;c:{if(a>>>0>tc>>>0){Ka(lc,a-tc|0);break c}if(a>>>0>=tc>>>0){break c}o[lc+4>>2]=uc+(a<<1)}d:{if(!yc){a=1;break d}uc=0;vc=kc+68|0;zc=(wc|0)<1;while(1){a=xc;tc=kc;if(!p[kc+84|0]){a=o[o[vc>>2]+(xc<<2)>>2]}if(!Na(tc,a,m[kc+24|0],o[sc>>2])){a=0;break d}if(!zc){tc=o[lc>>2];a=0;Ac=o[sc>>2];while(1){n[tc+(uc<<1)>>1]=q[Ac+(a<<1)>>1];uc=uc+1|0;a=a+1|0;if((wc|0)!=(a|0)){continue}break}}a=1;xc=xc+1|0;if((yc|0)!=(xc|0)){continue}break}}kc=o[sc>>2];if(!kc){break b}o[sc+4>>2]=kc;ul(kc)}R=sc+16|0;return a}Yk();D()}function Na(a,R,kc,lc){var Bc=0,Cc=0,Dc=0,Ec=0,Fc=v(0),Gc=0;a:{b:{if(!lc){break b}Bc=o[a+28>>2]+ -1|0;if(Bc>>>0>10){break b}c:{d:{e:{switch(Bc-1|0){default:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=m[R|0];R=R+1|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 0:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=p[R|0];R=R+1|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 1:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=q[R>>1];R=R+2|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 2:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=q[R>>1];R=R+2|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 3:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 4:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 5:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 6:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=o[R>>2];R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}break a;case 7:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24<1){break c}Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){Bc=(Cc<<1)+lc|0;Fc=s[R>>2];f:{if(Fc=v(0)){Ec=~~Fc>>>0;break f}Ec=0}n[Bc>>1]=Ec;R=R+4|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}break c;case 8:Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24<1){break d}Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){Bc=(Cc<<1)+lc|0;Gc=t[R>>3];g:{if(Gc<4294967296&Gc>=0){Ec=~~Gc>>>0;break g}Ec=0}n[Bc>>1]=Ec;R=R+8|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}break d;case 9:break e}}Dc=1;Bc=m[a+24|0];if(((Bc|0)>(kc|0)?kc:Bc)<<24>>24>=1){Bc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Bc+R|0;while(1){n[(Cc<<1)+lc>>1]=p[R|0];R=R+1|0;Cc=Cc+1|0;Bc=m[a+24|0];if((Cc|0)<((Bc|0)>(kc|0)?kc:Bc)<<24>>24){continue}break}}if((Bc|0)>=(kc|0)){break b}xl((Bc<<1)+lc|0,0,kc-Bc<<1);break b}if((Bc|0)>=(kc|0)){break b}break a}if((Bc|0)>=(kc|0)){break b}break a}return Dc}xl((Bc<<1)+lc|0,0,kc-Bc<<1);return 1}function Oa(a,kc,lc){var Hc=0,Ic=0,Jc=0,Kc=0,Lc=0,Mc=0,Nc=0,Oc=0,Pc=0;Hc=R-16|0;R=Hc;Nc=o[a+80>>2];Kc=m[kc+24|0];Jc=u(Nc,Kc);a:{a=o[kc+28>>2];b:{if(!(!p[kc+84|0]|((a|0)!=6?(a|0)!=5:0))){Mc=o[kc+48>>2];Kc=o[o[kc>>2]>>2];o[Hc+8>>2]=0;o[Hc>>2]=0;o[Hc+4>>2]=0;a=0;kc=Jc<<2;c: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d:{e:{switch(Qc-1|0){default:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=m[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 0:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=p[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 1:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=n[R>>1];R=R+2|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 2:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=q[R>>1];R=R+2|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 3:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 4:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 5:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 6:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=o[R>>2];R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}break a;case 7:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24<1){break c}Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){Qc=(Rc<<2)+lc|0;Uc=s[R>>2];f:{if(v(w(Uc))>2]=Tc;R=R+4|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}break c;case 8:Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24<1){break d}Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){Qc=(Rc<<2)+lc|0;Vc=t[R>>3];g:{if(w(Vc)<2147483648){Tc=~~Vc;break g}Tc=-2147483648}o[Qc>>2]=Tc;R=R+8|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}break d;case 9:break e}}Sc=1;Qc=m[a+24|0];if(((Qc|0)>(kc|0)?kc:Qc)<<24>>24>=1){Qc=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=Qc+R|0;while(1){o[(Rc<<2)+lc>>2]=p[R|0];R=R+1|0;Rc=Rc+1|0;Qc=m[a+24|0];if((Rc|0)<((Qc|0)>(kc|0)?kc:Qc)<<24>>24){continue}break}}if((Qc|0)>=(kc|0)){break b}xl((Qc<<2)+lc|0,0,kc-Qc<<2);break b}if((Qc|0)>=(kc|0)){break b}break a}if((Qc|0)>=(kc|0)){break b}break a}return Sc}xl((Qc<<2)+lc|0,0,kc-Qc<<2);return 1}function Qa(a,kc,lc){var Wc=0,Xc=0,Yc=0,Zc=0,_c=0,$c=0,ad=0,bd=0,cd=0;Wc=R-16|0;R=Wc;ad=o[a+80>>2];Zc=m[kc+24|0];Yc=u(ad,Zc);a:{a=o[kc+28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}function Ra(a,R,kc,lc){var dd=0,ed=0,fd=0,gd=0,hd=v(0),id=0;a:{b:{if(!lc){break b}dd=o[a+28>>2]+ -1|0;if(dd>>>0>10){break b}c:{d:{e:{switch(dd-1|0){default:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=m[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 0:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=p[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 1:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=n[R>>1];R=R+2|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 2:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=q[R>>1];R=R+2|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 3:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 4:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 5:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 6:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=o[R>>2];R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}break a;case 7:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24<1){break c}dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){dd=(ed<<2)+lc|0;hd=s[R>>2];f:{if(hd=v(0)){gd=~~hd>>>0;break f}gd=0}o[dd>>2]=gd;R=R+4|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}break c;case 8:fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24<1){break d}dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){dd=(ed<<2)+lc|0;id=t[R>>3];g:{if(id<4294967296&id>=0){gd=~~id>>>0;break g}gd=0}o[dd>>2]=gd;R=R+8|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}break d;case 9:break e}}fd=1;dd=m[a+24|0];if(((dd|0)>(kc|0)?kc:dd)<<24>>24>=1){dd=o[o[a>>2]>>2];R=o[a+48>>2]+Vl(o[a+40>>2],o[a+44>>2],R,0)|0;R=dd+R|0;while(1){o[(ed<<2)+lc>>2]=p[R|0];R=R+1|0;ed=ed+1|0;dd=m[a+24|0];if((ed|0)<((dd|0)>(kc|0)?kc:dd)<<24>>24){continue}break}}if((dd|0)>=(kc|0)){break b}xl((dd<<2)+lc|0,0,kc-dd<<2);break b}if((dd|0)>=(kc|0)){break b}break a}if((dd|0)>=(kc|0)){break b}break a}return fd}xl((dd<<2)+lc|0,0,kc-dd<<2);return 1}function Sa(a,kc,lc,jd,kd){var ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0;md=R-16|0;R=md;lc=lc+ -1|0;a:{if(lc>>>0>8){break a}b:{switch(lc-1|0){default:ld=Ta(a,kc,jd,kd);break a;case 1:ld=Ua(a,kc,jd,kd);break a;case 3:ld=Va(a,kc,jd,kd);break a;case 0:ld=Wa(a,kc,jd,kd);break a;case 2:ld=Xa(a,kc,jd,kd);break a;case 4:ld=Ya(a,kc,jd,kd);break a;case 5:case 6:break a;case 7:break b}}nd=o[a+80>>2];od=m[kc+24|0];pd=od<<2;if((u(nd,pd)|0)!=(jd|0)){break a}a=0;lc=o[259];o[md+8>>2]=o[258];o[md+12>>2]=lc;lc=o[257];o[md>>2]=o[256];o[md+4>>2]=lc;if(!nd){ld=1;break a}qd=kc+68|0;rd=(od|0)<1;lc=0;while(1){jd=lc;ld=kc;if(!p[kc+84|0]){jd=o[o[qd>>2]+(lc<<2)>>2]}if(!Ba(ld,jd,m[kc+24|0],md)){ld=0;break a}if(!rd){wl((a<<2)+kd|0,md,pd);a=a+od|0}ld=1;lc=lc+1|0;if((nd|0)!=(lc|0)){continue}break}}R=md+16|0;return ld}function Ta(a,kc,lc,jd){var kd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0;sd=R-16|0;R=sd;a:{vd=o[a+80>>2];td=m[kc+24|0];b:{if((u(vd,td)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=1)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);kd=1;break b}o[sd+8>>2]=0;o[sd>>2]=0;o[sd+4>>2]=0;if(td){if((td|0)<=-1){break a}kd=Hk(td);o[sd>>2]=kd;o[sd+4>>2]=kd;o[sd+8>>2]=kd+td;lc=td;while(1){m[kd|0]=0;kd=o[sd+4>>2]+1|0;o[sd+4>>2]=kd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!vd){kd=1;break c}lc=0;wd=kc+68|0;xd=(td|0)<1;while(1){a=ud;kd=kc;if(!p[kd+84|0]){a=o[o[wd>>2]+(ud<<2)>>2]}if(!Ga(kd,a,m[kc+24|0],o[sd>>2])){kd=0;break c}if(!xd){kd=0;a=o[sd>>2];while(1){m[lc+jd|0]=p[a+kd|0];lc=lc+1|0;kd=kd+1|0;if((td|0)!=(kd|0)){continue}break}}kd=1;ud=ud+1|0;if((vd|0)!=(ud|0)){continue}break}}a=o[sd>>2];if(!a){break b}o[sd+4>>2]=a;ul(a)}R=sd+16|0;return kd}Yk();D()}function Ua(a,kc,lc,jd){var yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;yd=R-16|0;R=yd;a:{Cd=o[a+80>>2];Ad=m[kc+24|0];a=Ad<<1;b:{if((u(Cd,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=3)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);zd=1;break b}lc=0;o[yd+8>>2]=0;o[yd>>2]=0;o[yd+4>>2]=0;if(Ad){if((Ad|0)<=-1){break a}lc=Hk(a);o[yd>>2]=lc;o[yd+8>>2]=(Ad<<1)+lc;Fd=yd,Gd=xl(lc,0,a)+a|0,o[Fd+4>>2]=Gd}c:{if(!Cd){zd=1;break c}lc=0;Dd=kc+68|0;Ed=(Ad|0)<1;while(1){a=Bd;zd=kc;if(!p[kc+84|0]){a=o[o[Dd>>2]+(Bd<<2)>>2]}d:{if(!La(zd,a,m[kc+24|0],o[yd>>2])){zd=0;break d}if(!Ed){zd=0;a=o[yd>>2];while(1){n[(lc<<1)+jd>>1]=q[a+(zd<<1)>>1];lc=lc+1|0;zd=zd+1|0;if((Ad|0)!=(zd|0)){continue}break}}zd=1;Bd=Bd+1|0;if((Cd|0)!=(Bd|0)){continue}}break}lc=o[yd>>2]}if(!lc){break b}o[yd+4>>2]=lc;ul(lc)}R=yd+16|0;return zd}Yk();D()}function Va(a,kc,lc,jd){var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0,Od=0,Pd=0;Hd=R-16|0;R=Hd;a:{Ld=o[a+80>>2];Jd=m[kc+24|0];a=Jd<<2;b:{if((u(Ld,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=5)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>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d>>2]+(Td<<2)>>2]}if(!Ia(Qd,a,m[kc+24|0],o[Rd>>2])){Qd=0;break c}if(!Wd){Qd=0;a=o[Rd>>2];while(1){m[lc+jd|0]=p[a+Qd|0];lc=lc+1|0;Qd=Qd+1|0;if((Sd|0)!=(Qd|0)){continue}break}}Qd=1;Td=Td+1|0;if((Ud|0)!=(Td|0)){continue}break}}a=o[Rd>>2];if(!a){break b}o[Rd+4>>2]=a;ul(a)}R=Rd+16|0;return Qd}Yk();D()}function Xa(a,kc,lc,jd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Xd=R-16|0;R=Xd;a:{$d=o[a+80>>2];Zd=m[kc+24|0];a=Zd<<1;b:{if((u($d,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=4)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);Yd=1;break b}lc=0;o[Xd+8>>2]=0;o[Xd>>2]=0;o[Xd+4>>2]=0;if(Zd){if((Zd|0)<=-1){break a}lc=Hk(a);o[Xd>>2]=lc;o[Xd+8>>2]=(Zd<<1)+lc;ce=Xd,de=xl(lc,0,a)+a|0,o[ce+4>>2]=de}c:{if(!$d){Yd=1;break c}lc=0;ae=kc+68|0;be=(Zd|0)<1;while(1){a=_d;Yd=kc;if(!p[kc+84|0]){a=o[o[ae>>2]+(_d<<2)>>2]}d:{if(!Na(Yd,a,m[kc+24|0],o[Xd>>2])){Yd=0;break d}if(!be){Yd=0;a=o[Xd>>2];while(1){n[(lc<<1)+jd>>1]=q[a+(Yd<<1)>>1];lc=lc+1|0;Yd=Yd+1|0;if((Zd|0)!=(Yd|0)){continue}break}}Yd=1;_d=_d+1|0;if(($d|0)!=(_d|0)){continue}}break}lc=o[Xd>>2]}if(!lc){break b}o[Xd+4>>2]=lc;ul(lc)}R=Xd+16|0;return Yd}Yk();D()}function Ya(a,kc,lc,jd){var ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0;ee=R-16|0;R=ee;a:{ie=o[a+80>>2];ge=m[kc+24|0];a=ge<<2;b:{if((u(ie,a)|0)!=(lc|0)){break b}if(!(!p[kc+84|0]|o[kc+28>>2]!=6)){wl(jd,o[o[kc>>2]>>2]+o[kc+48>>2]|0,lc);fe=1;break b}lc=0;o[ee+8>>2]=0;o[ee>>2]=0;o[ee+4>>2]=0;if(ge){if((ge|0)<=-1){break a}lc=Hk(a);o[ee>>2]=lc;o[ee+8>>2]=(ge<<2)+lc;le=ee,me=xl(lc,0,a)+a|0,o[le+4>>2]=me}c:{if(!ie){fe=1;break c}lc=0;je=kc+68|0;ke=(ge|0)<1;while(1){a=he;fe=kc;if(!p[kc+84|0]){a=o[o[je>>2]+(he<<2)>>2]}d:{if(!Ra(fe,a,m[kc+24|0],o[ee>>2])){fe=0;break d}if(!ke){fe=0;a=o[ee>>2];while(1){o[(lc<<2)+jd>>2]=o[a+(fe<<2)>>2];lc=lc+1|0;fe=fe+1|0;if((ge|0)!=(fe|0)){continue}break}}fe=1;he=he+1|0;if((ie|0)!=(he|0)){continue}}break}lc=o[ee>>2]}if(!lc){break b}o[ee+4>>2]=lc;ul(lc)}R=ee+16|0;return fe}Yk();D()}function Za(a,R){var kc=0,lc=0;kc=o[a+4>>2];if(!kc){return 0}R=o[o[o[a+8>>2]+(R<<2)>>2]+60>>2];if((R|0)<0){return 0}a=o[kc+24>>2];kc=o[kc+28>>2];if((a|0)==(kc|0)){return 0}a:{while(1){lc=o[a>>2];if((R|0)==o[lc+24>>2]){break a}a=a+4|0;if((kc|0)!=(a|0)){continue}break}return 0}return lc}function _a(a){var R=0;R=G(8)|0;o[R>>2]=12288;o[R>>2]=12332;Ik(R+4|0,a);o[R>>2]=12380;H(R|0,12412,1);D()}function $a(a,jd,ne){var oe=0,pe=0,qe=0,re=0,se=0;pe=R-16|0;R=pe;o[a+4>>2]=0;a:{b:{if(!jd){break b}qe=o[a+8>>2];oe=qe<<5;c:{if(oe>>>0>=jd>>>0){o[a+4>>2]=jd;break c}o[pe+8>>2]=0;o[pe>>2]=0;o[pe+4>>2]=0;if((jd|0)<=-1){break a}se=pe;if(oe>>>0<=1073741822){re=jd+31&-32;oe=qe<<6;re=oe>>>0>>0?re:oe}else{re=2147483647}ab(se,re);re=o[a>>2];o[a>>2]=o[pe>>2];o[pe>>2]=re;qe=o[a+4>>2];o[a+4>>2]=jd;o[pe+4>>2]=qe;oe=a+8|0;qe=o[oe>>2];o[oe>>2]=o[pe+8>>2];o[pe+8>>2]=qe;if(!re){break c}ul(re)}oe=jd>>>5;qe=oe<<2;a=o[a>>2];if(p[ne|0]){a=xl(a,255,qe);jd=jd&31;if(!jd){break b}a=a+(oe<<2)|0;o[a>>2]=o[a>>2]|-1>>>32-jd;break b}a=xl(a,0,qe);jd=jd&31;if(!jd){break b}a=a+(oe<<2)|0;o[a>>2]=o[a>>2]&(-1>>>32-jd^-1)}R=pe+16|0;return}Yk();D()}function ab(a,jd){var ne=0,te=0;ne=R-32|0;R=ne;a:{b:{if(o[a+8>>2]<<5>>>0>=jd>>>0){break b}o[ne+24>>2]=0;o[ne+16>>2]=0;o[ne+20>>2]=0;if((jd|0)<=-1){break a}jd=(jd+ -1>>>5)+1|0;te=Hk(jd<<2);o[ne+24>>2]=jd;o[ne+20>>2]=0;o[ne+16>>2]=te;jd=o[a>>2];o[ne+12>>2]=0;o[ne+8>>2]=jd;te=o[a+4>>2];o[ne+4>>2]=te&31;o[ne>>2]=jd+(te>>>3&536870908);bb(ne+16|0,ne+8|0,ne);jd=o[a>>2];o[a>>2]=o[ne+16>>2];o[ne+16>>2]=jd;te=o[a+4>>2];o[a+4>>2]=o[ne+20>>2];o[ne+20>>2]=te;a=a+8|0;te=o[a>>2];o[a>>2]=o[ne+24>>2];o[ne+24>>2]=te;if(!jd){break b}ul(jd)}R=ne+32|0;return}Yk();D()}function bb(a,jd,ue){var ve=0,we=0,xe=0,ye=0,ze=0,Ae=0;xe=R-32|0;R=xe;ze=o[ue+4>>2];ve=o[jd+4>>2];Ae=o[ue>>2];ye=o[jd>>2];jd=(ze-ve|0)+(Ae-ye<<3)|0;ue=o[a+4>>2];we=jd+ue|0;o[a+4>>2]=we;a:{if(!(!ue|(we+ -1^ue+ -1)>>>0>31)){a=o[a>>2];break a}a=o[a>>2];if(we>>>0<=32){o[a>>2]=0;break a}o[(we+ -1>>>3&536870908)+a>>2]=0}a=(ue>>>3&536870908)+a|0;ue=ue&31;b:{if((ue|0)==(ve|0)){c:{if((jd|0)<1){break c}d:{if(!ve){ue=0;break d}we=32-ve|0;ue=(jd|0)<(we|0)?jd:we;we=-1<>>we-ue;o[a>>2]=o[a>>2]&(we^-1)|we&o[ye>>2];jd=jd-ue|0;ve=ue+ve|0;ue=ve&31;a=(ve>>>3&536870908)+a|0;ye=ye+4|0}ve=(jd|0)/32|0;we=ve<<2;a=yl(a,ye,we)+we|0;ve=jd-(ve<<5)|0;if((ve|0)<1){ve=ue;break c}jd=-1>>>32-ve;o[a>>2]=o[a>>2]&(jd^-1)|jd&o[we+ye>>2]}o[xe+4>>2]=ve;o[xe>>2]=a;break b}o[xe+28>>2]=ve;o[xe+24>>2]=ye;o[xe+20>>2]=ze;o[xe+16>>2]=Ae;o[xe+12>>2]=ue;o[xe+8>>2]=a;cb(xe,xe+24|0,xe+16|0,xe+8|0)}R=xe+32|0}function cb(a,jd,ue,Be){var Ce=0,De=0,Ee=0,Fe=0,Ge=0,He=0,Ie=0,Je=0;De=o[jd>>2];Ce=o[ue+4>>2]+(o[ue>>2]-De<<3)|0;ue=o[jd+4>>2];Ee=Ce-ue|0;a:{if((Ee|0)<=0){ue=o[Be+4>>2];break a}b:{if(!ue){ue=o[Be+4>>2];break b}Ce=o[Be+4>>2];He=32-Ce|0;Ie=32-ue|0;Fe=(Ee|0)<(Ie|0)?Ee:Ie;Ge=He>>>0>>0?He:Fe;Je=o[Be>>2];De=o[De>>2]&(-1<>>Ie-Fe);o[Je>>2]=o[Je>>2]&(-1<>>He-Ge^-1)|(Ce>>>0>ue>>>0?De<>>ue-Ce);Ce=Ce+Ge|0;ue=Ce&31;o[Be+4>>2]=ue;He=Je+(Ce>>>3&536870908)|0;o[Be>>2]=He;Ce=Fe-Ge|0;if((Ce|0)>=1){o[He>>2]=o[He>>2]&(-1>>>32-Ce^-1)|De>>>Ge+o[jd+4>>2];o[Be+4>>2]=Ce;ue=Ce}Ee=Ee-Fe|0;De=o[jd>>2]+4|0;o[jd>>2]=De}Ge=-1<>2];De=o[De>>2];o[Ce>>2]=He&o[Ce>>2]|De<>2]=Ce+4;o[Ce+4>>2]=Ge&o[Ce+4>>2]|De>>>Fe;De=o[jd>>2]+4|0;o[jd>>2]=De;Ie=(Ee|0)>63;Ce=Ee+ -32|0;Ee=Ce;if(Ie){continue}break}}if((Ce|0)<1){break a}jd=o[Be>>2];Ee=(Fe|0)<(Ce|0)?Fe:Ce;Ge=o[jd>>2]&(Ge&-1>>>Fe-Ee^-1);Fe=o[De>>2]&-1>>>32-Ce;o[jd>>2]=Ge|Fe<>2]=ue;De=jd+(De>>>3&536870908)|0;o[Be>>2]=De;jd=Ce-Ee|0;if((jd|0)<1){break a}o[De>>2]=o[De>>2]&(-1>>>32-jd^-1)|Fe>>>Ee;o[Be+4>>2]=jd;ue=jd}jd=o[Be>>2];o[a+4>>2]=ue;o[a>>2]=jd}function db(a){a=a|0;return o[a>>2]}function eb(a){a=a|0;return!o[a>>2]|0}function fb(a){a=a|0;var jd=0;jd=a+4|0;if(m[a+15|0]<=-1){jd=o[jd>>2]}return jd|0}function gb(a){a=a|0;if(a){if(m[a+15|0]<=-1){ul(o[a+4>>2])}ul(a)}}function hb(){var a=0;a=Hk(12);o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;return a|0}function ib(ue,Be){ue=ue|0;Be=Be|0;return q[o[ue>>2]+(Be<<1)>>1]}function jb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]>>1}function kb(ue){ue=ue|0;var Be=0;if(ue){Be=o[ue>>2];if(Be){o[ue+4>>2]=Be;ul(Be)}ul(ue)}}function lb(){return qj(Hk(84))|0}function mb(ue){ue=ue|0;return o[ue+12>>2]-o[ue+8>>2]>>2}function nb(ue){ue=ue|0;return o[ue+80>>2]}function ob(ue){ue=ue|0;if(ue){l[o[o[ue>>2]+4>>2]](ue)}}function pb(ue,Ke){ue=ue|0;Ke=Ke|0;return p[o[ue>>2]+Ke|0]}function qb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]|0}function rb(ue,Ke){ue=ue|0;Ke=Ke|0;return o[o[ue>>2]+(Ke<<2)>>2]}function sb(ue){ue=ue|0;return o[ue+4>>2]-o[ue>>2]>>2}function tb(){var ue=0;ue=Hk(8);o[ue+4>>2]=-1;o[ue>>2]=1116;return ue|0}function ub(Ke,Le){Ke=Ke|0;Le=Le|0;return l[o[o[Ke>>2]+12>>2]](Ke,Le)|0}function vb(Ke){Ke=Ke|0;return o[Ke+4>>2]}function wb(){return pd(Hk(96))|0}function xb(Ke){Ke=Ke|0;return o[Ke+88>>2]}function yb(Ke){Ke=Ke|0;return o[Ke+56>>2]}function zb(Ke){Ke=Ke|0;return o[Ke+28>>2]}function Ab(o){o=o|0;return m[o+24|0]}function Bb(o){o=o|0;return p[o+32|0]}function Cb(Ke){Ke=Ke|0;return o[Ke+40>>2]}function Db(Ke){Ke=Ke|0;return o[Ke+48>>2]}function Eb(Ke){Ke=Ke|0;return o[Ke+60>>2]}function Fb(Ke){Ke=Ke|0;var Le=0,Me=0;if(Ke){Le=Ke+88|0;Me=o[Le>>2];o[Le>>2]=0;if(Me){Le=o[Me+8>>2];if(Le){o[Me+12>>2]=Le;ul(Le)}ul(Me)}Me=o[Ke+68>>2];if(Me){o[Ke+72>>2]=Me;ul(Me)}Le=Ke- -64|0;Me=o[Le>>2];o[Le>>2]=0;if(Me){Le=o[Me>>2];if(Le){o[Me+4>>2]=Le;ul(Le)}ul(Me)}ul(Ke)}}function Gb(){var Ke=0;Ke=Hk(40);o[Ke>>2]=-1;ki(Ke+8|0);return Ke|0}function Hb(Ne){Ne=Ne|0;var Oe=0;if(Ne){Oe=o[Ne+8>>2];if(Oe){o[Ne+12>>2]=Oe;ul(Oe)}ul(Ne)}}function Ib(){var Ne=0;Ne=Hk(24);o[Ne+4>>2]=-1;o[Ne>>2]=1232;o[Ne+8>>2]=0;o[Ne+12>>2]=0;o[Ne+16>>2]=0;o[Ne+20>>2]=0;return Ne|0}function Jb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return v(s[o[Pe+8>>2]+(Qe<<2)>>2])}function Kb(o){o=o|0;return v(s[o+20>>2])}function Lb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return m[o[Pe>>2]+Qe|0]}function Mb(){var Pe=0;Pe=Hk(28);o[Pe>>2]=0;o[Pe+4>>2]=0;o[Pe+24>>2]=0;o[Pe+16>>2]=0;o[Pe+20>>2]=0;o[Pe+8>>2]=0;o[Pe+12>>2]=0;return Pe|0}function Nb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return da(Qe,Re)|0}function Ob(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return fa(Qe,Re)|0}function Pb(o,Qe,Re,Se){o=o|0;Qe=Qe|0;Re=Re|0;Se=Se|0;ga(Qe,Re,Se)}function Qb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return+ha(Qe,Re)}function Rb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return ia(o,Qe,Re)|0}function Sb(Qe,Re){Qe=Qe|0;Re=Re|0;return o[Re+8>>2]}function Tb(o,Qe,Re){o=o|0;Qe=Qe|0;Re=Re|0;return ja(o,Qe,Re)|0}function Ub(Qe){Qe=Qe|0;var Re=0,Se=0,Te=0,Ue=0,Ve=0;if(Qe){if(m[Qe+27|0]<=-1){ul(o[Qe+16>>2])}Se=o[Qe>>2];if(Se){Re=Se;Ve=Qe+4|0;Te=o[Ve>>2];Ue=Re;a:{if((Te|0)==(Re|0)){break a}while(1){Re=Te+ -12|0;if(m[Te+ -1|0]<=-1){ul(o[Re>>2])}Te=Re;if((Re|0)!=(Se|0)){continue}break}Ue=o[Qe>>2]}Re=Ue;o[Ve>>2]=Se;ul(Re)}ul(Qe)}}function Vb(Qe,We){Qe=Qe|0;We=We|0;return n[o[Qe>>2]+(We<<1)>>1]}function Wb(Qe,We){Qe=Qe|0;We=We|0;return v(s[o[Qe>>2]+(We<<2)>>2])}function Xb(){return ld(Hk(64))|0}function Yb(o){o=o|0;if(o){ul(o)}}function Zb(){return oi(Hk(40))|0}function _b(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;o[Qe+16>>2]=0;o[Qe+20>>2]=0;o[Qe>>2]=We;o[Qe+8>>2]=Xe;o[Qe+12>>2]=0}function $b(){return la(Hk(40))|0}function ac(o,Qe){o=o|0;Qe=Qe|0;return ma(Qe)|0}function bc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return na(o)|0}function cc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return oa(o,Qe,We)|0}function dc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return rj(Qe,We)|0}function ec(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return pa(Qe,We)|0}function fc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return qa(Qe,We,Xe)|0}function gc(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;return o[o[We+8>>2]+(Xe<<2)>>2]}function hc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return tj(Qe,We)|0}function ic(Qe,We){Qe=Qe|0;We=We|0;return o[We+4>>2]}function jc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return Za(Qe,We)|0}function kc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ra(Qe,We,Xe)|0}function lc(o,Qe,We){o=o|0;Qe=Qe|0;We=We|0;return sa(Qe,We)|0}function mc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ya(Qe,We,Xe)|0}function nc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return za(Qe,We,Xe)|0}function oc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Aa(Qe,We,Xe)|0}function pc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ca(Qe,We,Xe)|0}function qc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Oa(Qe,We,Xe)|0}function rc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ea(Qe,We,Xe)|0}function sc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ha(Qe,We,Xe)|0}function tc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ja(Qe,We,Xe)|0}function uc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ma(Qe,We,Xe)|0}function vc(o,Qe,We,Xe){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Qa(Qe,We,Xe)|0}function wc(o,Qe,We,Xe,Ye,Ze){o=o|0;Qe=Qe|0;We=We|0;Xe=Xe|0;Ye=Ye|0;Ze=Ze|0;return Sa(Qe,We,Xe,Ye,Ze)|0}function xc(o,Qe){o=o|0;Qe=Qe|0;Uf(o,Qe)}function yc(Qe){Qe=Qe|0;if(Qe){if(m[Qe+39|0]<=-1){ul(o[Qe+28>>2])}zc(Qe+12|0,o[Qe+16>>2]);Ac(Qe,o[Qe+4>>2]);ul(Qe)}}function zc(Qe,We){if(We){zc(Qe,o[We>>2]);zc(Qe,o[We+4>>2]);Ac(We+20|0,o[We+24>>2]);ul(We)}}function Ac(Qe,We){if(We){Ac(Qe,o[We>>2]);Ac(Qe,o[We+4>>2]);if(m[We+39|0]<=-1){ul(o[We+28>>2])}if(m[We+27|0]<=-1){ul(o[We+16>>2])}ul(We)}}function Bc(){return Li(Hk(108))|0}function Cc(Qe){Qe=Qe|0;return(o[Qe+100>>2]-o[Qe+96>>2]|0)/12|0}function Dc(){var Qe=0,We=0,Xe=0;We=Hk(24);Xe=We+4|0;Qe=Xe;o[Qe>>2]=0;o[Qe+4>>2]=0;Qe=We+16|0;o[Qe>>2]=0;o[Qe+4>>2]=0;o[We>>2]=Xe;o[We+12>>2]=Qe;return We|0}function Ec(Ye){Ye=Ye|0;if(Ye){Fc(Ye+12|0,o[Ye+16>>2]);Gc(Ye,o[Ye+4>>2]);ul(Ye)}}function Fc(Ye,Ze){var _e=0;if(Ze){Fc(Ye,o[Ze>>2]);Fc(Ye,o[Ze+4>>2]);_e=Ze+28|0;Ye=o[_e>>2];o[_e>>2]=0;if(Ye){Fc(Ye+12|0,o[Ye+16>>2]);Gc(Ye,o[Ye+4>>2]);ul(Ye)}if(m[Ze+27|0]<=-1){ul(o[Ze+16>>2])}ul(Ze)}}function Gc(Ye,Ze){if(Ze){Gc(Ye,o[Ze>>2]);Gc(Ye,o[Ze+4>>2]);Ye=o[Ze+28>>2];if(Ye){o[Ze+32>>2]=Ye;ul(Ye)}if(m[Ze+27|0]<=-1){ul(o[Ze+16>>2])}ul(Ze)}}function Hc(){return 0}function Ic(){return-1}function Jc(){return-2}function Kc(){return-3}function Lc(){return-4}function Mc(){return-5}function Nc(){return 1}function Oc(){return 2}function Pc(){return 3}function Qc(){return 4}function Rc(){return 5}function Sc(){return 6}function Tc(){return 7}function Uc(){return 8}function Vc(){return 9}function Wc(){return 10}function Xc(){return 11}function Yc(){return 12}function Zc(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var $e=0;Ze=o[Ze+88>>2];if(!(!Ze|o[Ze>>2]!=2)){$e=Ye;Ye=o[Ze+8>>2];o[$e+4>>2]=p[Ye|0]|p[Ye+1|0]<<8|(p[Ye+2|0]<<16|p[Ye+3|0]<<24);$e=1}return $e|0}function _c(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var af=0,bf=0;o[Ze>>2]=2;af=o[Ze+8>>2];bf=o[Ze+12>>2]-af|0;if(bf>>>0<=4294967291){Ze=Ze+8|0;ni(Ze,bf+4|0);af=o[Ze>>2]}Ze=af+bf|0;Ye=p[Ye+4|0]|p[Ye+5|0]<<8|(p[Ye+6|0]<<16|p[Ye+7|0]<<24);m[Ze|0]=Ye;m[Ze+1|0]=Ye>>>8;m[Ze+2|0]=Ye>>>16;m[Ze+3|0]=Ye>>>24}function $c(o){o=o|0;return o|0}function ad(o){o=o|0;ul(o)}function bd(o){o=o|0;return 2}function cd(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var cf=0,df=0,ef=0,ff=0,gf=0,hf=0;ef=o[Ze+88>>2];if(!(!ef|o[ef>>2]!=1)){ff=ef+8|0;ef=o[ff>>2];cf=ef;o[Ye+4>>2]=p[cf|0]|p[cf+1|0]<<8|(p[cf+2|0]<<16|p[cf+3|0]<<24);gf=Ye+8|0;hf=o[Ye+8>>2];df=o[Ye+12>>2]-hf>>2;cf=m[Ze+24|0];a:{if(df>>>0>>0){Da(gf,cf-df|0);ef=o[ff>>2];cf=p[Ze+24|0];break a}if(df>>>0<=cf>>>0){break a}o[Ye+12>>2]=hf+(cf<<2)}ff=1;Ze=ef;df=p[Ze+4|0]|p[Ze+5|0]<<8|(p[Ze+6|0]<<16|p[Ze+7|0]<<24);if(cf<<24>>24>=1){hf=cf&255;gf=o[gf>>2];Ze=0;cf=4;while(1){o[gf+(Ze<<2)>>2]=df;cf=cf+4|0;df=ef+cf|0;df=p[df|0]|p[df+1|0]<<8|(p[df+2|0]<<16|p[df+3|0]<<24);Ze=Ze+1|0;if(Ze>>>0>>0){continue}break}}o[Ye+20>>2]=df}return ff|0}function dd(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var jf=0,kf=0,lf=0,mf=0,nf=0,of=0;o[Ze>>2]=1;mf=Ze+8|0;jf=o[Ze+8>>2];kf=o[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f>>>0){Ze=pf-qf|0;if((Ze|0)<1){break b}Ye=Ye+4|0;wl(o[Ye>>2],qf,Ze);o[Ye>>2]=Ze+o[Ye>>2];return}o[Ye+4>>2]=rf+(uf>>2<<2);return}if(rf){o[Ye+4>>2]=rf;ul(rf);o[Ye+8>>2]=0;o[Ye>>2]=0;o[Ye+4>>2]=0;qf=0}if(sf>>>0>=1073741824){break a}pf=qf>>1;pf=qf>>2>>>0<536870911?pf>>>0>>0?sf:pf:1073741823;if(pf>>>0>=1073741824){break a}rf=pf<<2;pf=Hk(rf);o[Ye>>2]=pf;sf=Ye+4|0;o[sf>>2]=pf;o[Ye+8>>2]=pf+rf;if((tf|0)<1){break b}vf=sf,wf=wl(pf,Ze,tf)+tf|0,o[vf>>2]=wf}return}Yk();D()}function gd(Ye){Ye=Ye|0;var Ze=0;o[Ye>>2]=1232;Ze=o[Ye+8>>2];if(Ze){o[Ye+12>>2]=Ze;ul(Ze)}return Ye|0}function hd(Ye){Ye=Ye|0;var pf=0;o[Ye>>2]=1232;pf=o[Ye+8>>2];if(pf){o[Ye+12>>2]=pf;ul(pf)}ul(Ye)}function id(o){o=o|0;return 1}function jd(Ye,xf){var yf=0;yf=Hk(40);o[yf>>2]=-1;ki(yf+8|0);l[o[o[Ye>>2]+16>>2]](Ye,yf);Ye=o[xf+88>>2];o[xf+88>>2]=yf;if(Ye){xf=o[Ye+8>>2];if(xf){o[Ye+12>>2]=xf;ul(xf)}ul(Ye)}return 1}function kd(Ye,xf,zf){var Af=0,Bf=0,Cf=0,Df=0,Ef=0,Ff=0;Cf=o[Ye+8>>2];Af=o[Ye+4>>2];if(Cf-Af>>2>>>0>=xf>>>0){while(1){o[Af>>2]=o[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}o[Ye+4>>2]=Af;return}a:{Df=o[Ye>>2];Ef=Af-Df|0;Ff=Ef>>2;Af=Ff+xf|0;if(Af>>>0<1073741824){Cf=Cf-Df|0;Bf=Cf>>1;Af=Cf>>2>>>0<536870911?Bf>>>0>>0?Af:Bf:1073741823;Bf=0;b:{if(!Af){break b}if(Af>>>0>=1073741824){break a}Bf=Hk(Af<<2)}Cf=Bf+(Af<<2)|0;Af=Bf+(Ff<<2)|0;while(1){o[Af>>2]=o[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}if((Ef|0)>=1){wl(Bf,Df,Ef)}o[Ye>>2]=Bf;o[Ye+8>>2]=Cf;o[Ye+4>>2]=Af;if(Df){ul(Df)}return}Yk();D()}_a(1308);D()}function ld(Ye){o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+40>>2]=0;o[Ye+44>>2]=0;o[Ye+28>>2]=9;m[Ye+24|0]=1;o[Ye+56>>2]=-1;o[Ye+60>>2]=0;o[Ye+16>>2]=0;o[Ye+20>>2]=0;o[Ye+48>>2]=0;o[Ye+52>>2]=0;return Ye}function md(Ye,xf,zf,Gf,Hf,If,Jf){o[Ye>>2]=0;o[Ye+56>>2]=xf;o[Ye+48>>2]=0;o[Ye+52>>2]=0;o[Ye+40>>2]=If;o[Ye+44>>2]=Jf;m[Ye+32|0]=Hf;o[Ye+28>>2]=Gf;m[Ye+24|0]=zf}function nd(Ye,xf){var zf=0,Gf=0,Hf=0;Gf=o[Ye>>2];a:{if(!Gf){break a}zf=o[xf>>2];if(!zf){break a}Hf=Gf;Gf=o[zf>>2];li(Hf,Gf,o[zf+4>>2]-Gf|0,0);m[Ye+24|0]=p[xf+24|0];o[Ye+28>>2]=o[xf+28>>2];m[Ye+32|0]=p[xf+32|0];zf=o[xf+44>>2];o[Ye+40>>2]=o[xf+40>>2];o[Ye+44>>2]=zf;zf=o[xf+52>>2];o[Ye+48>>2]=o[xf+48>>2];o[Ye+52>>2]=zf;o[Ye+56>>2]=o[xf+56>>2];zf=o[xf+12>>2];o[Ye+8>>2]=o[xf+8>>2];o[Ye+12>>2]=zf;zf=o[xf+20>>2];o[Ye+16>>2]=o[xf+16>>2];o[Ye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>>>0?0:1:0){$f=0;break a}bg=p[jg+ig|0];Tf=$f;$f=gg+4|0;if($f>>>0<4){Tf=Tf+1|0}o[xf+16>>2]=$f;o[cg+20>>2]=Tf;if(og>>>0>4){$f=0;break a}if((dg+ -1&255)>>>0>10){$f=0;break a}$f=ld(ag+24|0);Tf=u(ti(dg),eg);md($f,og,eg<<24>>24,dg,(bg|0)!=0,Tf,Tf>>31);xd(1,ag+20|0,xf);cg=o[ag+20>>2];o[ag+84>>2]=cg;Tf=Hk(96);qd(Tf,$f);o[ag+16>>2]=Tf;$f=vj(mg,ag+16|0);Tf=o[ag+16>>2];o[ag+16>>2]=0;if(Tf){Fb(Tf)}bg=$f<<2;o[o[bg+o[pg>>2]>>2]+60>>2]=cg;o[o[Ye+4>>2]+(kg<<2)>>2]=$f;Tf=o[Ye+16>>2];cg=o[ng>>2]-Tf>>2;c:{if(($f|0)<(cg|0)){break c}o[ag+12>>2]=-1;$f=$f+1|0;if($f>>>0>cg>>>0){yd(lg,$f-cg|0,ag+12|0);Tf=o[lg>>2];break c}if($f>>>0>=cg>>>0){break c}o[ng>>2]=($f<<2)+Tf}o[Tf+bg>>2]=kg;$f=1;kg=kg+1|0;if((fg|0)!=(kg|0)){continue}break}}R=ag+96|0;return $f|0}function xd(Ye,xf,qg){var rg=0,sg=0,tg=0,ug=0;a:{if(Ye>>>0>5){break a}tg=o[qg+16>>2];rg=o[qg+12>>2];sg=o[qg+20>>2];if((rg|0)<(sg|0)?1:(rg|0)<=(sg|0)?r[qg+8>>2]>tg>>>0?0:1:0){break a}rg=p[tg+o[qg>>2]|0];tg=tg+1|0;if(tg>>>0<1){sg=sg+1|0}o[qg+16>>2]=tg;o[qg+20>>2]=sg;sg=xf;if(rg&128){if(!xd(Ye+1|0,xf,qg)){break a}Ye=o[xf>>2]<<7;o[xf>>2]=Ye;rg=Ye|rg&127}o[sg>>2]=rg;ug=1}return ug}function yd(Ye,xf,qg){var vg=0,wg=0,xg=0,yg=0,zg=0,Ag=0;xg=o[Ye+8>>2];vg=o[Ye+4>>2];if(xg-vg>>2>>>0>=xf>>>0){while(1){o[vg>>2]=o[qg>>2];vg=vg+4|0;xf=xf+ -1|0;if(xf){continue}break}o[Ye+4>>2]=vg;return}a:{yg=o[Ye>>2];zg=vg-yg|0;Ag=zg>>2;vg=Ag+xf|0;if(vg>>>0<1073741824){xg=xg-yg|0;wg=xg>>1;vg=xg>>2>>>0<536870911?wg>>>0>>0?vg:wg:1073741823;wg=0;b:{if(!vg){break b}if(vg>>>0>=1073741824){break a}wg=Hk(vg<<2)}xg=wg+(vg<<2)|0;vg=wg+(Ag<<2)|0;while(1){o[vg>>2]=o[qg>>2];vg=vg+4|0;xf=xf+ -1|0;if(xf){continue}break}if((zg|0)>=1){wl(wg,yg,zg)}o[Ye>>2]=wg;o[Ye+8>>2]=xg;o[Ye+4>>2]=vg;if(yg){ul(yg)}return}Yk();D()}_a(1520);D()}function zd(Ye){Ye=Ye|0;var xf=0;o[Ye>>2]=1384;xf=o[Ye+16>>2];if(xf){o[Ye+20>>2]=xf;ul(xf)}xf=o[Ye+4>>2];if(xf){o[Ye+8>>2]=xf;ul(xf)}return Ye|0}function Ad(o){o=o|0;D()}function Bd(Ye,qg){Ye=Ye|0;qg=qg|0;var Bg=0;a:{if(!l[o[o[Ye>>2]+36>>2]](Ye,qg)){break a}if(!l[o[o[Ye>>2]+40>>2]](Ye,qg)){break a}Bg=l[o[o[Ye>>2]+44>>2]](Ye)|0}return Bg|0}function Cd(Ye,qg){Ye=Ye|0;qg=qg|0;return o[o[Ye+4>>2]+(qg<<2)>>2]}function Dd(Ye){Ye=Ye|0;return o[Ye+8>>2]-o[Ye+4>>2]>>2}function Ed(o,Ye){o=o|0;Ye=Ye|0;return 0}function Fd(o,Ye){o=o|0;Ye=Ye|0;return 1}function Gd(Ye){o[Ye+12>>2]=-1;o[Ye+16>>2]=0;o[Ye+4>>2]=0;o[Ye+8>>2]=0;o[Ye>>2]=1596}function Hd(Ye,qg,Cg){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ye+40>>2]=0;o[Ye>>2]=1692;o[Ye+44>>2]=0;o[Ye+48>>2]=0;o[Ye+52>>2]=0;o[Ye+56>>2]=0;ah=o[$g>>2];o[$g>>2]=0;o[Ye+60>>2]=ah}function Rd(Ye,$g){Ye=Ye|0;$g=$g|0;var bh=0,ch=0,dh=0,eh=0,fh=0,gh=0,hh=0,ih=0,jh=0,kh=0,lh=0,mh=0,nh=0;fh=R-16|0;R=fh;a:{if(!wd(Ye,$g)){break a}jh=Ye+36|0;gh=l[o[o[Ye>>2]+24>>2]](Ye)|0;dh=o[Ye+40>>2];ch=o[Ye+36>>2];bh=dh-ch>>2;b:{if(gh>>>0>bh>>>0){Sd(jh,gh-bh|0);break b}if(gh>>>0>=bh>>>0){break b}ch=ch+(gh<<2)|0;if((ch|0)!=(dh|0)){while(1){dh=dh+ -4|0;bh=o[dh>>2];o[dh>>2]=0;if(bh){l[o[o[bh>>2]+4>>2]](bh)}if((dh|0)!=(ch|0)){continue}break}}o[Ye+40>>2]=ch}ih=1;if((gh|0)<1){break a}ih=0;dh=0;while(1){eh=o[$g+16>>2];ch=o[$g+12>>2];bh=o[$g+20>>2];if((ch|0)<(bh|0)?1:(ch|0)<=(bh|0)?r[$g+8>>2]>eh>>>0?0:1:0){break a}hh=p[eh+o[$g>>2]|0];eh=eh+1|0;if(eh>>>0<1){bh=bh+1|0}ch=$g;o[ch+16>>2]=eh;o[ch+20>>2]=bh;l[o[o[Ye>>2]+48>>2]](fh+8|0,Ye,hh);bh=o[Ye+36>>2];ch=o[fh+8>>2];o[fh+8>>2]=0;eh=dh<<2;hh=bh+eh|0;bh=o[hh>>2];o[hh>>2]=ch;if(bh){l[o[o[bh>>2]+4>>2]](bh)}bh=o[fh+8>>2];o[fh+8>>2]=0;if(bh){l[o[o[bh>>2]+4>>2]](bh)}bh=o[o[jh>>2]+eh>>2];if(!bh){break a}if(!(lh=bh,mh=l[o[o[Ye>>2]+28>>2]](Ye)|0,nh=l[o[o[Ye>>2]+20>>2]](Ye,dh)|0,kh=o[o[bh>>2]+8>>2],l[kh](lh|0,mh|0,nh|0)|0)){break a}dh=dh+1|0;if((gh|0)!=(dh|0)){continue}break}ih=1}R=fh+16|0;return ih|0}function Sd(Ye,$g){var oh=0,ph=0,qh=0,rh=0,sh=0,th=0,uh=0,vh=0,wh=0;ph=o[Ye+8>>2];qh=Ye+4|0;oh=o[qh>>2];if(ph-oh>>2>>>0>=$g>>>0){Ye=$g<<2;vh=qh,wh=xl(oh,0,Ye)+Ye|0,o[vh>>2]=wh;return}a:{qh=o[Ye>>2];rh=oh-qh>>2;sh=rh+$g|0;if(sh>>>0<1073741824){rh=rh<<2;ph=ph-qh|0;uh=ph>>1;ph=ph>>2>>>0<536870911?uh>>>0>>0?sh:uh:1073741823;if(ph){if(ph>>>0>=1073741824){break a}th=Hk(ph<<2)}rh=rh+th|0;xl(rh,0,$g<<2);$g=(sh<<2)+th|0;sh=(ph<<2)+th|0;if((oh|0)!=(qh|0)){while(1){oh=oh+ -4|0;ph=o[oh>>2];o[oh>>2]=0;rh=rh+ -4|0;o[rh>>2]=ph;if((oh|0)!=(qh|0)){continue}break}qh=o[Ye>>2];oh=o[Ye+4>>2]}o[Ye>>2]=rh;o[Ye+8>>2]=sh;o[Ye+4>>2]=$g;if((oh|0)!=(qh|0)){while(1){oh=oh+ -4|0;Ye=o[oh>>2];o[oh>>2]=0;if(Ye){l[o[o[Ye>>2]+4>>2]](Ye)}if((oh|0)!=(qh|0)){continue}break}}if(qh){ul(qh)}return}Yk();D()}_a(1832);D()}function Td(Ye,$g){Ye=Ye|0;$g=$g|0;var xh=0,yh=0,zh=0,Ah=0,Bh=0,Ch=0,Dh=0;xh=o[Ye+60>>2];a:{if(!xh){break a}o[xh+4>>2]=Ye+48;if(!l[o[o[xh>>2]+12>>2]](xh)){break a}b:{yh=l[o[o[Ye>>2]+24>>2]](Ye)|0;if((yh|0)<1){break b}Ah=Ye+60|0;xh=0;while(1){c:{Bh=o[(l[o[o[Ye>>2]+28>>2]](Ye)|0)+4>>2];Ch=l[o[o[Ye>>2]+20>>2]](Ye,xh)|0;zh=o[Ah>>2];if(!l[o[o[zh>>2]+8>>2]](zh,o[o[Bh+8>>2]+(Ch<<2)>>2])){break c}xh=xh+1|0;if((yh|0)!=(xh|0)){continue}break b}break}return 0}if(!l[o[o[Ye>>2]+36>>2]](Ye,$g)){break a}if(!l[o[o[Ye>>2]+40>>2]](Ye,$g)){break a}Dh=l[o[o[Ye>>2]+44>>2]](Ye)|0}return Dh|0}function Ud(Ye,$g){Ye=Ye|0;$g=$g|0;var Eh=0,Fh=0,Gh=0,Hh=0,Ih=0;Eh=1;Fh=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Fh|0)<1){break a}Hh=Ye+48|0;Eh=0;Ih=Ye+36|0;Ye=0;while(1){Gh=o[o[Ih>>2]+(Ye<<2)>>2];if(!l[o[o[Gh>>2]+16>>2]](Gh,Hh,$g)){break a}Ye=Ye+1|0;if((Fh|0)!=(Ye|0)){continue}break}Eh=1}return Eh|0}function Vd(Ye,$g){Ye=Ye|0;$g=$g|0;var Jh=0,Kh=0,Lh=0,Mh=0,Nh=0;Jh=1;Kh=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Kh|0)<1){break a}Mh=Ye+48|0;Jh=0;Nh=Ye+36|0;Ye=0;while(1){Lh=o[o[Nh>>2]+(Ye<<2)>>2];if(!l[o[o[Lh>>2]+20>>2]](Lh,Mh,$g)){break a}Ye=Ye+1|0;if((Kh|0)!=(Ye|0)){continue}break}Jh=1}return Jh|0}function Wd(Ye){Ye=Ye|0;var $g=0,Oh=0,Ph=0,Qh=0,Rh=0,Sh=0,Th=0,Uh=0,Vh=0,Wh=0,Xh=0,Yh=0,Zh=0;Qh=R-16|0;R=Qh;$g=1;Th=l[o[o[Ye>>2]+24>>2]](Ye)|0;a:{if((Th|0)<1){break a}Zh=Ye+48|0;Sh=Ye+36|0;while(1){b:{c:{if(!o[(l[o[o[Ye>>2]+28>>2]](Ye)|0)+40>>2]){break c}Uh=Rh<<2;$g=o[Uh+o[Sh>>2]>>2];Oh=o[$g+8>>2];Vh=Ld($g);if(!Vh){break c}$g=l[o[o[Ye>>2]+28>>2]](Ye)|0;Wh=o[Oh+56>>2];Xh=o[$g+40>>2];$g=Hk(32);o[Qh>>2]=$g;o[Qh+4>>2]=24;o[Qh+8>>2]=-2147483616;m[$g+24|0]=0;Oh=p[1764]|p[1765]<<8|(p[1766]<<16|p[1767]<<24);Ph=p[1760]|p[1761]<<8|(p[1762]<<16|p[1763]<<24);m[$g+16|0]=Ph;m[$g+17|0]=Ph>>>8;m[$g+18|0]=Ph>>>16;m[$g+19|0]=Ph>>>24;m[$g+20|0]=Oh;m[$g+21|0]=Oh>>>8;m[$g+22|0]=Oh>>>16;m[$g+23|0]=Oh>>>24;Oh=p[1756]|p[1757]<<8|(p[1758]<<16|p[1759]<<24);Ph=p[1752]|p[1753]<<8|(p[1754]<<16|p[1755]<<24);m[$g+8|0]=Ph;m[$g+9|0]=Ph>>>8;m[$g+10|0]=Ph>>>16;m[$g+11|0]=Ph>>>24;m[$g+12|0]=Oh;m[$g+13|0]=Oh>>>8;m[$g+14|0]=Oh>>>16;m[$g+15|0]=Oh>>>24;Oh=p[1748]|p[1749]<<8|(p[1750]<<16|p[1751]<<24);Ph=p[1744]|p[1745]<<8|(p[1746]<<16|p[1747]<<24);m[$g|0]=Ph;m[$g+1|0]=Ph>>>8;m[$g+2|0]=Ph>>>16;m[$g+3|0]=Ph>>>24;m[$g+4|0]=Oh;m[$g+5|0]=Oh>>>8;m[$g+6|0]=Oh>>>16;m[$g+7|0]=Oh>>>24;d:{e:{Ph=Xh+16|0;Oh=Ph;$g=o[Oh>>2];if(!$g){break e}while(1){Yh=o[$g+16>>2]<(Wh|0);Oh=Yh?Oh:$g;$g=o[(Yh<<2)+$g>>2];if($g){continue}break}if((Oh|0)==(Ph|0)|(Wh|0)>2]){break e}$g=Oh+20|0;if(!ea($g,Qh)){break e}$g=yi($g,Qh);break d}$g=yi(Xh,Qh)}if(m[Qh+11|0]<=-1){ul(o[Qh>>2])}if(!$g){break c}sd(o[o[o[Sh>>2]+Uh>>2]+8>>2],Vh);break b}$g=o[o[Sh>>2]+(Rh<<2)>>2];if(l[o[o[$g>>2]+24>>2]]($g,Zh)){break b}$g=0;break a}$g=1;Rh=Rh+1|0;if((Th|0)!=(Rh|0)){continue}break}}R=Qh+16|0;return $g|0}function Xd(Ye,_h,$h){Ye=Ye|0;_h=_h|0;$h=$h|0;if($h>>>0>3){o[Ye>>2]=0;return}a:{b:{switch($h-1|0){default:_h=Hk(20);Gd(_h);break a;case 0:_h=Hk(24);$d(_h);break a;case 1:_h=Hk(36);$d(_h);o[_h+32>>2]=0;o[_h+24>>2]=-1;o[_h+28>>2]=0;o[_h>>2]=7664;break a;case 2:break b}}_h=Hk(28);$d(_h);o[_h+24>>2]=-1;o[_h>>2]=5528;o[Ye>>2]=_h;return}o[Ye>>2]=_h}function Yd(Ye){Ye=Ye|0;var _h=0,$h=0,ai=0,bi=0,ci=0;o[Ye>>2]=1692;_h=Ye+60|0;$h=o[_h>>2];o[_h>>2]=0;if($h){l[o[o[$h>>2]+4>>2]]($h)}_h=o[Ye+48>>2];if(_h){o[Ye+52>>2]=_h;ul(_h)}$h=o[Ye+36>>2];if($h){_h=$h;ci=Ye+40|0;ai=o[ci>>2];bi=_h;a:{if((_h|0)==(ai|0)){break a}while(1){ai=ai+ -4|0;_h=o[ai>>2];o[ai>>2]=0;if(_h){l[o[o[_h>>2]+4>>2]](_h)}if(($h|0)!=(ai|0)){continue}break}bi=o[Ye+36>>2]}_h=bi;o[ci>>2]=$h;ul(_h)}o[Ye>>2]=1384;_h=o[Ye+16>>2];if(_h){o[Ye+20>>2]=_h;ul(_h)}_h=o[Ye+4>>2];if(_h){o[Ye+8>>2]=_h;ul(_h)}return Ye|0}function Zd(Ye){Ye=Ye|0;var di=0,ei=0,fi=0,gi=0,hi=0;o[Ye>>2]=1692;di=Ye+60|0;ei=o[di>>2];o[di>>2]=0;if(ei){l[o[o[ei>>2]+4>>2]](ei)}di=o[Ye+48>>2];if(di){o[Ye+52>>2]=di;ul(di)}ei=o[Ye+36>>2];if(ei){di=ei;hi=Ye+40|0;fi=o[hi>>2];gi=di;a:{if((di|0)==(fi|0)){break a}while(1){fi=fi+ -4|0;di=o[fi>>2];o[fi>>2]=0;if(di){l[o[o[di>>2]+4>>2]](di)}if((ei|0)!=(fi|0)){continue}break}gi=o[Ye+36>>2]}di=gi;o[hi>>2]=ei;ul(di)}o[Ye>>2]=1384;di=o[Ye+16>>2];if(di){o[Ye+20>>2]=di;ul(di)}di=o[Ye+4>>2];if(di){o[Ye+8>>2]=di;ul(di)}ul(Ye)}function _d(Ye,ii){Ye=Ye|0;ii=ii|0;var ji=0,ki=0;ki=o[Ye+16>>2];ji=0;a:{if(o[Ye+20>>2]-ki>>2<=(ii|0)){break a}ii=o[(ii<<2)+ki>>2];ji=0;if((ii|0)<0){break a}ji=Ld(o[o[Ye+36>>2]+(ii<<2)>>2])}return ji|0}function $d(Ye){Gd(Ye);o[Ye+20>>2]=0;o[Ye>>2]=1908}function ae(o,Ye,ii){o=o|0;Ye=Ye|0;ii=ii|0;return Hd(o,Ye,ii)|0}function be(Ye,ii){Ye=Ye|0;ii=ii|0;return l[o[o[Ye>>2]+48>>2]](Ye,o[ii+4>>2]-o[ii>>2]>>2)|0}function ce(Ye,ii,li){Ye=Ye|0;ii=ii|0;li=li|0;var mi=0,ni=0,oi=0,pi=0,qi=0,ri=0,si=0,ti=0,ui=0,vi=0;oi=R-16|0;R=oi;si=o[li+8>>2];pi=o[li+16>>2];qi=o[li+12>>2];mi=qi;ni=o[li+20>>2];a:{if((mi|0)<(ni|0)?1:(mi|0)<=(ni|0)?si>>>0>pi>>>0?0:1:0){break a}ti=o[li>>2];ui=m[ti+pi|0];mi=ni;ri=pi+1|0;if(ri>>>0<1){mi=mi+1|0}o[li+16>>2]=ri;o[li+20>>2]=mi;b:{if((ui|0)==-2){break b}if((qi|0)<(mi|0)?1:(qi|0)<=(mi|0)?si>>>0>ri>>>0?0:1:0){break a}qi=m[ri+ti|0];pi=pi+2|0;if(pi>>>0<2){ni=ni+1|0}mi=li;o[mi+16>>2]=pi;o[mi+20>>2]=ni;l[o[o[Ye>>2]+40>>2]](oi+8|0,Ye,ui,qi);ni=o[oi+8>>2];o[oi+8>>2]=0;mi=o[Ye+20>>2];o[Ye+20>>2]=ni;if(!mi){o[oi+8>>2]=0;break b}l[o[o[mi>>2]+4>>2]](mi);mi=o[oi+8>>2];o[oi+8>>2]=0;if(!mi){break b}l[o[o[mi>>2]+4>>2]](mi)}mi=o[Ye+20>>2];if(mi){if(!l[o[o[Ye>>2]+28>>2]](Ye,mi)){break a}}vi=l[o[o[Ye>>2]+36>>2]](Ye,ii,li)|0}R=oi+16|0;return vi|0}function de(Ye,ii,li,wi){Ye=Ye|0;ii=ii|0;li=li|0;wi=wi|0;var xi=0,yi=0;xi=R-48|0;R=xi;a:{if((wi|0)!=1){o[Ye>>2]=0;break a}wi=o[ii+4>>2];ii=o[ii+12>>2];o[xi+40>>2]=0;yi=xi+32|0;o[yi>>2]=0;o[yi+4>>2]=0;o[xi+24>>2]=0;o[xi+28>>2]=0;o[xi+16>>2]=0;o[xi+20>>2]=0;o[xi+8>>2]=0;o[xi+12>>2]=0;ee(xi,li,ii,wi,xi+8|0);ii=o[yi>>2];if(ii){o[xi+36>>2]=ii;ul(ii)}o[Ye>>2]=o[xi>>2]}R=xi+48|0}function ee(Ye,ii,li,wi,zi){var Ai=0,Bi=0;a:{if((ii|0)!=-2){Bi=o[o[o[wi+4>>2]+8>>2]+(li<<2)>>2];if((l[o[o[wi>>2]+8>>2]](wi)|0)==1){Ai=ii;ii=q[wi+36>>1];le(Ye,wi,Ai,li,zi,(ii<<24|ii<<8&16711680)>>>16);if(o[Ye>>2]){break a}o[Ye>>2]=0}Ai=Hk(44);me(Ai,Bi,zi)}o[Ye>>2]=Ai}}function fe(Ye,ii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;Mi=Ci-Di>>>0>=Vl(zi,0,Hi,0)>>>0?0:1;Ci=Fi-(wi+(Ci>>>0>>0)|0)|0;Di=T;if((Ci|0)<(Di|0)?1:(Ci|0)<=(Di|0)?Mi:0){break a}Ci=0;if(!Hi){break c}Di=0;Ci=Gi;Gi=zi+Ii|0;if(Gi>>>0>>0){wi=wi+1|0}if((Fi|0)<(wi|0)?1:(Fi|0)<=(wi|0)?Ci>>>0>=Gi>>>0?0:1:0){break b}Gi=0;while(1){wl(Ji+(Gi<<2)|0,Ii+o[li>>2]|0,Ei);wi=o[li+20>>2];Ii=zi+o[li+16>>2]|0;if(Ii>>>0>>0){wi=wi+1|0}o[li+16>>2]=Ii;o[li+20>>2]=wi;Gi=Gi+1|0;if((Hi|0)==(Gi|0)){break d}Fi=o[li+12>>2];Li=zi+Ii|0;if(Li>>>0>>0){wi=wi+1|0}if((Fi|0)>(wi|0)?1:(Fi|0)>=(wi|0)?r[li+8>>2]
  • >>0?0:1:0){continue}break}break b}wl(Ji,Fi+o[li>>2]|0,Ei);wi=o[li+20>>2];Ci=zi+o[li+16>>2]|0;if(Ci>>>0>>0){wi=wi+1|0}o[li+16>>2]=Ci;o[li+20>>2]=wi}Ci=0;if(!Hi){break c}zi=o[Ye+20>>2];if(zi){Ci=1;if(l[o[o[zi>>2]+32>>2]](zi)){break c}}ji(Ji,Hi,Ji);Ci=1}zi=o[Ye+20>>2];f:{if(!zi){break f}if(!l[o[o[zi>>2]+40>>2]](zi,li)){break a}if(!Ci){break f}Di=0;Ye=o[Ye+20>>2];if(!l[o[o[Ye>>2]+44>>2]](Ye,Ji,Ji,Hi,Ki,o[ii>>2])){break b}}Di=1}return Di|0}return 0}function ge(Ye,ii,li){var Ni=0,Oi=0,Pi=0,Qi=0;Ni=R-80|0;R=Ni;Oi=ld(Ni+16|0);Pi=o[o[Ye+8>>2]+56>>2];Qi=li<<24>>24;li=u(ti(5),li);md(Oi,Pi,Qi,5,0,li,li>>31);li=Hk(96);qd(li,Oi);o[Ni+8>>2]=li;m[li+84|0]=1;o[li+72>>2]=o[li+68>>2];rd(li,ii);o[Ni>>2]=0;ii=o[Ni+8>>2];o[Ni+8>>2]=0;li=Ye+16|0;Ye=o[li>>2];o[li>>2]=ii;a:{if(!Ye){o[Ni>>2]=0;break a}Fb(Ye);Ye=o[Ni>>2];o[Ni>>2]=0;if(!Ye){break a}Fb(Ye)}Ye=o[Ni+8>>2];o[Ni+8>>2]=0;if(Ye){Fb(Ye)}R=Ni+80|0}function he(Ye,ii){Ye=Ye|0;ii=ii|0;var li=0,Ri=0,Si=0,Ti=0,Ui=0,Vi=0,Wi=0,Xi=0,Yi=0;Ri=o[Ye+8>>2];li=o[Ri+28>>2]+ -1|0;if(li>>>0>5){return 0}a:{b:{switch(li-1|0){case 0:Ti=m[Ri+24|0];Ui=Hk((Ti|0)>-1?Ti:-1);li=o[Ye+16>>2];Ri=0;c:{if(!o[li+80>>2]){break c}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=(Ti|0)<1;Xi=Ye+8|0;li=0;while(1){Ye=0;if(!Vi){while(1){m[Ye+Ui|0]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Ti|0)!=(Ye|0)){continue}break}}wl(o[o[o[Xi>>2]- -64>>2]>>2]+Wi|0,Ui,Ti);Wi=Ti+Wi|0;Si=Si+1|0;if((Si|0)!=(ii|0)){continue}break}break a;default:Ti=m[Ri+24|0];Ui=Hk((Ti|0)>-1?Ti:-1);li=o[Ye+16>>2];Ri=0;d:{if(!o[li+80>>2]){break d}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=(Ti|0)<1;Xi=Ye+8|0;li=0;while(1){Ye=0;if(!Vi){while(1){m[Ye+Ui|0]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Ti|0)!=(Ye|0)){continue}break}}wl(o[o[o[Xi>>2]- -64>>2]>>2]+Wi|0,Ui,Ti);Wi=Ti+Wi|0;Si=Si+1|0;if((Si|0)!=(ii|0)){continue}break}break a;case 2:Si=m[Ri+24|0];Ri=Si+Si|0;Ui=Hk(Ri>>>0>>0?-1:Ri);li=o[Ye+16>>2];Ri=0;e:{if(!o[li+80>>2]){break e}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=Si<<1;Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){n[(Ye<<1)+Ui>>1]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 1:Si=m[Ri+24|0];Ri=Si+Si|0;Ui=Hk(Ri>>>0>>0?-1:Ri);li=o[Ye+16>>2];Ri=0;f:{if(!o[li+80>>2]){break f}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Vi=Si<<1;Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){n[(Ye<<1)+Ui>>1]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 4:Si=m[Ri+24|0];Vi=Si<<2;Ui=Hk((Si|0)!=(Si&1073741823)?-1:Vi);li=o[Ye+16>>2];Ri=0;g:{if(!o[li+80>>2]){break g}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){o[(Ye<<2)+Ui>>2]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}break a;case 3:break b}}Si=m[Ri+24|0];Vi=Si<<2;Ui=Hk((Si|0)!=(Si&1073741823)?-1:Vi);li=o[Ye+16>>2];Ri=0;h:{if(!o[li+80>>2]){break h}Ri=o[o[li>>2]>>2]+o[li+48>>2]|0}if(!ii){break a}Xi=(Si|0)<1;Yi=Ye+8|0;li=0;while(1){Ye=0;if(!Xi){while(1){o[(Ye<<2)+Ui>>2]=o[Ri+(li<<2)>>2];li=li+1|0;Ye=Ye+1|0;if((Si|0)!=(Ye|0)){continue}break}}wl(o[o[o[Yi>>2]- -64>>2]>>2]+Wi|0,Ui,Vi);Wi=Wi+Vi|0;Ti=Ti+1|0;if((Ti|0)!=(ii|0)){continue}break}}ul(Ui);return 1}function ie(Ye){Ye=Ye|0;var ii=0,Zi=0;o[Ye>>2]=1908;Zi=Ye+20|0;ii=o[Zi>>2];o[Zi>>2]=0;if(ii){l[o[o[ii>>2]+4>>2]](ii)}o[Ye>>2]=1596;Zi=Ye+16|0;ii=o[Zi>>2];o[Zi>>2]=0;if(ii){Fb(ii)}return Ye|0}function je(Ye){Ye=Ye|0;var _i=0,$i=0;o[Ye>>2]=1908;$i=Ye+20|0;_i=o[$i>>2];o[$i>>2]=0;if(_i){l[o[o[_i>>2]+4>>2]](_i)}o[Ye>>2]=1596;$i=Ye+16|0;_i=o[$i>>2];o[$i>>2]=0;if(_i){Fb(_i)}ul(Ye)}function ke(Ye){Ye=Ye|0;return m[o[Ye+8>>2]+24|0]}function le(Ye,aj,bj,cj,dj,ej){var fj=0,gj=0,hj=0;ej=R-32|0;R=ej;gj=o[o[o[aj+4>>2]+8>>2]+(cj<<2)>>2];a:{b:{if((l[o[o[aj>>2]+8>>2]](aj)|0)!=1|bj+ -1>>>0>5){break b}hj=l[o[o[aj>>2]+36>>2]](aj)|0;fj=l[o[o[aj>>2]+44>>2]](aj,cj)|0;if(!(fj?hj:0)){o[Ye>>2]=0;break a}cj=l[o[o[aj>>2]+40>>2]](aj,cj)|0;if(cj){aj=o[aj+44>>2];o[ej+12>>2]=cj;o[ej+8>>2]=aj;o[ej+20>>2]=fj;o[ej+16>>2]=fj+12;ne(Ye,bj,gj,dj,ej+8|0);if(o[Ye>>2]){break a}o[Ye>>2]=0;break b}aj=o[aj+44>>2];o[ej+12>>2]=hj;o[ej+8>>2]=aj;o[ej+20>>2]=fj;o[ej+16>>2]=fj+12;oe(Ye,bj,gj,dj,ej+8|0);if(o[Ye>>2]){break a}o[Ye>>2]=0}o[Ye>>2]=0}R=ej+32|0}function me(Ye,aj,bj){var cj=0,dj=0,ej=0,ij=0,jj=0,kj=0,lj=0,mj=0;o[Ye>>2]=2732;o[Ye+4>>2]=aj;aj=o[bj+8>>2];cj=o[bj+12>>2];dj=o[bj+16>>2];ij=o[bj+20>>2];jj=o[bj>>2];kj=o[bj+4>>2];o[Ye+40>>2]=0;ej=Ye+32|0;o[ej>>2]=0;o[ej+4>>2]=0;o[Ye+24>>2]=dj;o[Ye+28>>2]=ij;o[Ye+16>>2]=aj;o[Ye+20>>2]=cj;o[Ye+8>>2]=jj;o[Ye+12>>2]=kj;a:{aj=o[bj+28>>2]-o[bj+24>>2]|0;b:{if(!aj){break b}cj=aj>>2;if(cj>>>0>=1073741824){break a}aj=Hk(aj);o[Ye+32>>2]=aj;dj=Ye+36|0;o[dj>>2]=aj;o[Ye+40>>2]=aj+(cj<<2);cj=o[bj+24>>2];bj=o[bj+28>>2]-cj|0;if((bj|0)<1){break b}lj=dj,mj=wl(aj,cj,bj)+bj|0,o[lj>>2]=mj}o[Ye>>2]=5368;return}Yk();D()}function ne(Ye,aj,bj,nj,oj){var pj=0;a:{aj=aj+ -1|0;b:{if(aj>>>0>5){break b}c:{switch(aj-1|0){default:aj=Hk(60);pe(aj,bj,nj,oj);o[aj>>2]=2024;break a;case 2:aj=Hk(112);pe(aj,bj,nj,oj);o[aj>>2]=2788;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj+68>>2]=0;o[aj+72>>2]=0;o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+84>>2]=0;o[aj+88>>2]=0;o[aj+92>>2]=0;o[aj+96>>2]=0;o[aj+100>>2]=0;o[aj+104>>2]=0;o[aj+108>>2]=0;break a;case 3:aj=Hk(104);pe(aj,bj,nj,oj);o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj>>2]=3036;o[aj+84>>2]=0;bj=o[oj+4>>2];o[aj+88>>2]=o[oj>>2];o[aj+92>>2]=bj;bj=o[oj+12>>2];o[aj+96>>2]=o[oj+8>>2];o[aj+100>>2]=bj;break a;case 0:case 1:break b;case 4:break c}}pj=Hk(124);pe(pj,bj,nj,oj);o[pj>>2]=3272;aj=pj- -64|0;o[aj>>2]=0;o[aj+4>>2]=0;aj=o[oj+4>>2];o[pj+72>>2]=o[oj>>2];o[pj+76>>2]=aj;aj=o[oj+12>>2];o[pj+80>>2]=o[oj+8>>2];o[pj+84>>2]=aj;o[pj+92>>2]=-1;o[pj+96>>2]=-1;o[pj+88>>2]=1;o[pj+60>>2]=3508;o[pj+100>>2]=-1;o[pj+104>>2]=-1;Mf(pj+108|0)}o[Ye>>2]=pj;return}o[Ye>>2]=aj}function oe(Ye,aj,bj,nj,oj){var qj=0;a:{aj=aj+ -1|0;b:{if(aj>>>0>5){break b}c:{switch(aj-1|0){default:aj=Hk(60);Xe(aj,bj,nj,oj);o[aj>>2]=3900;break a;case 2:aj=Hk(112);Xe(aj,bj,nj,oj);o[aj>>2]=4324;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj+68>>2]=0;o[aj+72>>2]=0;o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+84>>2]=0;o[aj+88>>2]=0;o[aj+92>>2]=0;o[aj+96>>2]=0;o[aj+100>>2]=0;o[aj+104>>2]=0;o[aj+108>>2]=0;break a;case 3:aj=Hk(104);Xe(aj,bj,nj,oj);o[aj+76>>2]=0;o[aj+80>>2]=0;o[aj+60>>2]=0;o[aj+64>>2]=0;o[aj>>2]=4560;o[aj+84>>2]=0;bj=o[oj+4>>2];o[aj+88>>2]=o[oj>>2];o[aj+92>>2]=bj;bj=o[oj+12>>2];o[aj+96>>2]=o[oj+8>>2];o[aj+100>>2]=bj;break a;case 0:case 1:break b;case 4:break c}}qj=Hk(124);Xe(qj,bj,nj,oj);o[qj>>2]=4784;aj=qj- -64|0;o[aj>>2]=0;o[aj+4>>2]=0;aj=o[oj+4>>2];o[qj+72>>2]=o[oj>>2];o[qj+76>>2]=aj;aj=o[oj+12>>2];o[qj+80>>2]=o[oj+8>>2];o[qj+84>>2]=aj;o[qj+92>>2]=-1;o[qj+96>>2]=-1;o[qj+88>>2]=1;o[qj+60>>2]=5004;o[qj+100>>2]=-1;o[qj+104>>2]=-1;Mf(qj+108|0)}o[Ye>>2]=qj;return}o[Ye>>2]=aj}function pe(Ye,aj,bj,nj){var oj=0,rj=0,sj=0,tj=0,uj=0,vj=0,wj=0,xj=0;o[Ye>>2]=2732;o[Ye+4>>2]=aj;aj=o[bj+8>>2];oj=o[bj+12>>2];rj=o[bj+16>>2];tj=o[bj+20>>2];uj=o[bj>>2];vj=o[bj+4>>2];o[Ye+40>>2]=0;sj=Ye+32|0;o[sj>>2]=0;o[sj+4>>2]=0;o[Ye+24>>2]=rj;o[Ye+28>>2]=tj;o[Ye+16>>2]=aj;o[Ye+20>>2]=oj;o[Ye+8>>2]=uj;o[Ye+12>>2]=vj;a:{aj=o[bj+28>>2]-o[bj+24>>2]|0;b:{if(!aj){break b}oj=aj>>2;if(oj>>>0>=1073741824){break a}aj=Hk(aj);o[Ye+32>>2]=aj;rj=Ye+36|0;o[rj>>2]=aj;o[Ye+40>>2]=aj+(oj<<2);oj=o[bj+24>>2];bj=o[bj+28>>2]-oj|0;if((bj|0)<1){break b}wj=rj,xj=wl(aj,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{if((Kj|0)>=o[Xj>>2]){break j}Kj=Kj+o[Rj>>2]|0}o[Ye>>2]=Kj}Nj=Nj+1|0;Mj=o[Uj>>2];if((Nj|0)<(Mj|0)){continue}break}}Pj=Pj+1|0;if((Pj|0)<(_j|0)){continue}break}}ul(Wj);return 1}function xe(Ye){Ye=Ye|0;var yj=0;o[Ye>>2]=2788;yj=o[Ye+96>>2];if(yj){ul(yj)}yj=o[Ye+84>>2];if(yj){ul(yj)}yj=o[Ye+72>>2];if(yj){ul(yj)}yj=o[Ye+60>>2];if(yj){ul(yj)}o[Ye>>2]=2732;yj=o[Ye+32>>2];if(yj){o[Ye+36>>2]=yj;ul(yj)}return Ye|0}function ye(Ye){Ye=Ye|0;var Jj=0;o[Ye>>2]=2788;Jj=o[Ye+96>>2];if(Jj){ul(Jj)}Jj=o[Ye+84>>2];if(Jj){ul(Jj)}Jj=o[Ye+72>>2];if(Jj){ul(Jj)}Jj=o[Ye+60>>2];if(Jj){ul(Jj)}o[Ye>>2]=2732;Jj=o[Ye+32>>2];if(Jj){o[Ye+36>>2]=Jj;ul(Jj)}ul(Ye)}function ze(o){o=o|0;return 4}function Ae(Ye,Kj){Ye=Ye|0;Kj=Kj|0;var Lj=0,Mj=0,bk=0,ck=0,dk=0,ek=0,fk=0,gk=0,hk=0,ik=0,jk=0;fk=R-32|0;R=fk;a:{b:{while(1){if(!Be(1,fk+28|0,Kj)){break b}Lj=o[fk+28>>2];if(Lj){ck=(u(Mj,12)+Ye|0)+60|0;Ce(ck,Lj);ek=Mf(fk+8|0);if(!Nf(ek,Kj)){break b}dk=0;while(1){gk=1<<(dk&31);hk=Pf(ek);bk=o[ck>>2]+(dk>>>3&536870908)|0;ik=bk;if(hk){bk=gk|o[bk>>2]}else{bk=o[bk>>2]&(gk^-1)}o[ik>>2]=bk;dk=dk+1|0;if((Lj|0)!=(dk|0)){continue}break}}Mj=Mj+1|0;if((Mj|0)!=4){continue}break}dk=0;Mj=o[Kj+12>>2];gk=Mj;Lj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|0;Dk=1;while(1){j:{k:{l:{if(Vk>>>0>Dk>>>0){m:{n:{Bk=o[(Dk<<2)+Uk>>2];if((Bk|0)==-1){break n}Fk=Bk+((Bk>>>0)%3|0?-1:2)|0;Rk=Fk>>>5;Ck=1;Sk=1<<(Fk&31);Tk=o[Ek>>2];xk=0;vk=Bk;o:{while(1){p:{if(o[Tk+(vk>>>3&536870908)>>2]>>>(vk&31)&1){break p}yk=o[o[o[Ek+64>>2]+12>>2]+(vk<<2)>>2];if((yk|0)==-1){break p}Kk=o[Wk>>2];zk=o[_k>>2];Lk=o[Kk+(o[zk+(yk<<2)>>2]<<2)>>2];if((Lk|0)>=(Dk|0)){break p}Jk=yk+1|0;Jk=o[Kk+(o[zk+(((Jk>>>0)%3|0?Jk:yk+ -2|0)<<2)>>2]<<2)>>2];if((Jk|0)>=(Dk|0)){break p}yk=o[Kk+(o[zk+(yk+((yk>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if((yk|0)>=(Dk|0)){break p}if((wk|0)>=1){Kk=o[(Ak+16|0)+u(xk,12)>>2];yk=u(wk,yk);Jk=u(wk,Jk);Lk=u(wk,Lk);zk=0;while(1){o[Kk+(zk<<2)>>2]=(o[(yk+zk<<2)+uk>>2]+o[(zk+Jk<<2)+uk>>2]|0)-o[(zk+Lk<<2)+uk>>2];zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}yk=4;xk=xk+1|0;if((xk|0)==4){break o}}q:{if(Ck&1){zk=-1;yk=vk+1|0;vk=(yk>>>0)%3|0?yk:vk+ -2|0;if((vk|0)==-1|o[o[Ek>>2]+(vk>>>3&536870908)>>2]>>>(vk&31)&1){break q}vk=o[o[o[Ek+64>>2]+12>>2]+(vk<<2)>>2];if((vk|0)==-1){break q}yk=vk+1|0;zk=(yk>>>0)%3|0?yk:vk+ -2|0;break q}zk=-1;vk=((vk>>>0)%3|0?-1:2)+vk|0;if((vk|0)==-1|o[o[Ek>>2]+(vk>>>3&536870908)>>2]>>>(vk&31)&1){break q}vk=o[o[o[Ek+64>>2]+12>>2]+(vk<<2)>>2];if((vk|0)==-1){break q}if((vk>>>0)%3){zk=vk+ -1|0;break q}zk=vk+2|0}r:{if((zk|0)==(Bk|0)){break r}vk=zk;yk=(zk|0)!=-1;zk=(yk|Ck^-1)&1;vk=zk?vk:-1;Ck=yk&Ck;if(!((Fk|0)==-1|zk)){if(o[o[Ek>>2]+(Rk<<2)>>2]&Sk){break r}yk=o[o[o[Ek+64>>2]+12>>2]+(Fk<<2)>>2];if((yk|0)==-1){break r}Ck=0;if((yk>>>0)%3){vk=yk+ -1|0}else{vk=yk+2|0}}if((vk|0)!=-1){continue}}break}yk=xk;if((yk|0)<1){break n}}Fk=(wk|0)<1;if(!Fk){xl(Mk,0,Xk)}vk=yk+ -1|0;Ck=(vk<<2)+Qk|0;vk=u(vk,12)+Ye|0;Kk=vk+60|0;Rk=o[vk- -64>>2];vk=0;Sk=o[Ak>>2];Bk=0;xk=0;while(1){zk=o[Ck>>2];o[Ck>>2]=zk+1;if(Rk>>>0<=zk>>>0){break i}s:{if(o[o[Kk>>2]+(zk>>>3&536870908)>>2]>>>(zk&31)&1){break s}xk=xk+1|0;if(Fk){break s}Tk=o[(Ak+16|0)+u(Bk,12)>>2];zk=0;while(1){Lk=zk<<2;Jk=Lk+Sk|0;o[Jk>>2]=o[Jk>>2]+o[Lk+Tk>>2];zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}Bk=Bk+1|0;if((yk|0)!=(Bk|0)){continue}break}Ck=u(wk,Dk);yk=Ck;if(!xk){break m}zk=0;if((wk|0)>0){break l}break k}yk=u(wk,Dk)}if(o[Gk>>2]<1){break j}Ck=(u(Dk+ -1|0,wk)<<2)+uk|0;zk=0;while(1){vk=zk<<2;xk=o[vk+Ck>>2];Fk=o[Ik>>2];t:{if((xk|0)>(Fk|0)){Bk=o[Nk>>2];o[vk+Bk>>2]=Fk;break t}Bk=o[Nk>>2];vk=vk+Bk|0;Fk=o[Pk>>2];if((xk|0)<(Fk|0)){o[vk>>2]=Fk;break t}o[vk>>2]=xk}zk=zk+1|0;xk=o[Gk>>2];if((zk|0)<(xk|0)){continue}break}vk=0;if((xk|0)<1){break j}xk=yk<<2;zk=xk+uk|0;Ck=Kj+xk|0;while(1){yk=vk<<2;xk=yk+zk|0;yk=o[yk+Ck>>2]+o[yk+Bk>>2]|0;o[xk>>2]=yk;u:{if((yk|0)>o[Ik>>2]){yk=yk-o[Ok>>2]|0}else{if((yk|0)>=o[Pk>>2]){break u}yk=yk+o[Ok>>2]|0}o[xk>>2]=yk}vk=vk+1|0;if((vk|0)>2]){continue}break}break j}Zk();D()}while(1){vk=(zk<<2)+Mk|0;o[vk>>2]=o[vk>>2]/(xk|0);zk=zk+1|0;if((zk|0)!=(wk|0)){continue}break}}if(o[Gk>>2]<1){break j}zk=0;while(1){vk=zk<<2;xk=o[vk+Mk>>2];yk=o[Ik>>2];v:{if((xk|0)>(yk|0)){Bk=o[Nk>>2];o[vk+Bk>>2]=yk;break v}Bk=o[Nk>>2];vk=vk+Bk|0;yk=o[Pk>>2];if((xk|0)<(yk|0)){o[vk>>2]=yk;break v}o[vk>>2]=xk}zk=zk+1|0;xk=o[Gk>>2];if((zk|0)<(xk|0)){continue}break}vk=0;if((xk|0)<1){break j}xk=Ck<<2;zk=xk+uk|0;Ck=Kj+xk|0;while(1){yk=vk<<2;xk=yk+zk|0;yk=o[yk+Ck>>2]+o[yk+Bk>>2]|0;o[xk>>2]=yk;w:{if((yk|0)>o[Ik>>2]){yk=yk-o[Ok>>2]|0}else{if((yk|0)>=o[Pk>>2]){break w}yk=yk+o[Ok>>2]|0}o[xk>>2]=yk}vk=vk+1|0;if((vk|0)>2]){continue}break}}vk=1;Dk=Dk+1|0;if((Dk|0)<(Vk|0)){continue}break}}Ye=o[Ak>>2];if(Ye){o[Ak+4>>2]=Ye;ul(Ye)}ul(Qk);Ye=o[Ak+52>>2];if(Ye){o[Ak+56>>2]=Ye;ul(Ye)}Ye=o[Ak+40>>2];if(Ye){o[Ak+44>>2]=Ye;ul(Ye)}Ye=o[Ak+28>>2];if(Ye){o[Ak+32>>2]=Ye;ul(Ye)}Ye=o[Ak+16>>2];if(Ye){o[Ak+20>>2]=Ye;ul(Ye)}R=Ak- -64|0;return vk|0}Yk();D()}function Ee(Ye){Ye=Ye|0;var Kj=0;o[Ye>>2]=3036;Kj=o[Ye+76>>2];if(Kj){ul(Kj)}o[Ye>>2]=2732;Kj=o[Ye+32>>2];if(Kj){o[Ye+36>>2]=Kj;ul(Kj)}return Ye|0}function Fe(Ye){Ye=Ye|0;var uk=0;o[Ye>>2]=3036;uk=o[Ye+76>>2];if(uk){ul(uk)}o[Ye>>2]=2732;uk=o[Ye+32>>2];if(uk){o[Ye+36>>2]=uk;ul(uk)}ul(Ye)}function Ge(o){o=o|0;return 5}function He(Ye){Ye=Ye|0;if(!(!o[Ye+60>>2]|!o[Ye+44>>2]|(!o[Ye+48>>2]|!o[Ye+52>>2]))){return o[Ye+56>>2]!=0|0}return 0}function Ie(Ye,vk){Ye=Ye|0;vk=vk|0;var wk=0;if(!(o[vk+56>>2]|!vk|p[vk+24|0]!=3)){o[Ye+60>>2]=vk;wk=1}return wk|0}function Je(Ye,vk){Ye=Ye|0;vk=vk|0;var xk=0,Hk=0,Yk=0,Zk=0,$k=0,al=0,bl=0,cl=0,dl=0,el=0,fl=0;cl=R-16|0;R=cl;Yk=o[vk+12>>2];xk=o[vk+20>>2];Zk=o[vk+16>>2];Hk=Zk+4|0;if(Hk>>>0<4){xk=xk+1|0}$k=Hk;Hk=xk;a:{if((Yk|0)<(xk|0)?1:(Yk|0)<=(xk|0)?r[vk+8>>2]>=$k>>>0?0:1:0){break a}xk=Zk+o[vk>>2]|0;xk=p[xk|0]|p[xk+1|0]<<8|(p[xk+2|0]<<16|p[xk+3|0]<<24);o[vk+16>>2]=$k;o[vk+20>>2]=Hk;if((xk|0)<0){break a}Ce(Ye+76|0,xk);$k=Mf(cl);b:{if(!Nf($k,vk)){break b}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nl=0,ol=0,pl=0,ql=0,rl=0,sl=0,tl=0,ul=0,vl=0;hl=0;a:{if((il|0)!=2){break a}o[Ye+8>>2]=2;o[Ye- -64>>2]=jl;hl=Ye+32|0;il=o[hl>>2];jl=o[Ye+36>>2]-il|0;kl=jl>>2;b:{if(kl>>>0<=1){Da(hl,2-kl|0);break b}if((jl|0)==8){break b}o[Ye+36>>2]=il+8}hl=1;il=o[Ye+56>>2];jl=o[il+4>>2];il=o[il>>2];kl=jl-il|0;if((kl|0)<1){break a}if((il|0)!=(jl|0)){sl=Ye+60|0;tl=kl>>2;kl=Ye+8|0;ol=Ye+16|0;pl=Ye+32|0;ql=Ye+20|0;rl=Ye+12|0;ul=Ye+56|0;while(1){if(!Le(sl,o[(ml<<2)+il>>2],gl,ml)){hl=0;break a}c:{if(o[kl>>2]<1){break c}il=0;while(1){hl=il<<2;jl=o[(hl+Ye|0)+68>>2];ll=o[ol>>2];d:{if((jl|0)>(ll|0)){nl=o[pl>>2];o[hl+nl>>2]=ll;break d}nl=o[pl>>2];hl=hl+nl|0;ll=o[rl>>2];if((jl|0)<(ll|0)){o[hl>>2]=ll;break d}o[hl>>2]=jl}il=il+1|0;hl=o[kl>>2];if((il|0)<(hl|0)){continue}break}jl=0;if((hl|0)<1){break c}hl=ml<<3;ll=hl+gl|0;vl=vk+hl|0;while(1){il=jl<<2;hl=il+ll|0;il=o[il+vl>>2]+o[il+nl>>2]|0;o[hl>>2]=il;e:{if((il|0)>o[ol>>2]){il=il-o[ql>>2]|0}else{if((il|0)>=o[rl>>2]){break e}il=il+o[ql>>2]|0}o[hl>>2]=il}jl=jl+1|0;if((jl|0)>2]){continue}break}}hl=1;ml=ml+1|0;if((ml|0)>=(tl|0)){break a}hl=o[ul>>2];il=o[hl>>2];if(o[hl+4>>2]-il>>2>>>0>ml>>>0){continue}break}}Zk();D()}return hl|0}function Le(Ye,vk,gl,hl){var il=0,jl=0,wl=0,xl=0,yl=0,zl=0,Al=0,Bl=0,Cl=0,D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jl=Cl-jl|0;jl=Vl(jl,Fl,jl,Fl);Cl=T;Gl=jl;il=Wl(Vl(Ol,xl,Bl,il),T,Il,zl);jl=Ll-(T+(gl>>>0>>0)|0)|0;gl=gl-il|0;jl=Vl(gl,jl,gl,jl);gl=Gl+jl|0;il=T+Cl|0;il=gl>>>0>>0?il+1|0:il;xl=gl;gl=Wl(Vl(Bl,yl,Pl,El),T,Il,zl);jl=Ml-(T+(Al>>>0>>0)|0)|0;gl=Al-gl|0;jl=Vl(gl,jl,gl,jl);gl=xl+jl|0;il=T+il|0;jl=Vl(gl,gl>>>0>>0?il+1|0:il,Il,zl);gl=T;xl=gl;if(!gl&jl>>>0<=1|gl>>>0<0){break e}El=jl;gl=xl;while(1){il=vk<<1|hl>>>31;hl=hl<<1;vk=il;Al=!gl&El>>>0>7|gl>>>0>0;El=(gl&3)<<30|El>>>2;gl=gl>>>2;if(Al){continue}break}break d}il=Ye;if(Fl){if((hl|0)<=0){o[Ye+8>>2]=0;o[Ye+12>>2]=0;break g}vk=(hl<<1)+ -2|0}else{vk=Cl<<1}vk=(vk<<2)+gl|0;o[il+8>>2]=o[vk>>2];o[Ye+12>>2]=o[vk+4>>2]}gl=1;break b}Zk();D()}hl=jl;vk=xl;if(jl-1){break c}}while(1){gl=Xl(jl,xl,hl,vk)+hl|0;il=vk+T|0;il=gl>>>0>>0?il+1|0:il;hl=(il&1)<<31|gl>>>1;vk=il>>>1;gl=Vl(hl,vk,hl,vk);il=T;if((xl|0)==(il|0)&gl>>>0>jl>>>0|il>>>0>xl>>>0){continue}break}}il=o[Ye+20>>2];gl=0;if(!il){break b}xl=il+ -1|0;El=o[o[Ye+16>>2]+(xl>>>3&536870908)>>2];o[Ye+20>>2]=xl;gl=Kl;il=Dl;Al=gl-il|0;Dl=il>>31;Kl=(gl>>31)-(Dl+(gl>>>0>>0)|0)|0;gl=Vl(Bl,yl,Al,Kl);jl=T;Dl=Vl(il,Dl,Il,zl);gl=Dl+gl|0;il=T+jl|0;il=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tl+4>>2]=Xl>>31;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 4:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=0;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 5:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Xl=o[vk+4>>2];Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 6:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Xl=o[vk+4>>2];Tl=(Ul<<3)+hl|0;o[Tl>>2]=o[vk>>2];o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}break a;case 7:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24<1){break c}Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;Wl=Tl;Yl=s[vk>>2];f:{if(v(w(Yl))=v(1)?Yl>v(0)?~~v(y(v(A(v(Yl/v(4294967296)))),v(4294967296)))>>>0:~~v(B(v(v(Yl-v(~~Yl>>>0>>>0))/v(4294967296))))>>>0:0;_l=~~Yl>>>0;break f}Xl=-2147483648;_l=0}o[Wl>>2]=_l;o[Tl+4>>2]=Xl;vk=vk+4|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}break c;case 8:Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24<1){break d}Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;Wl=Tl;Zl=t[vk>>3];g:{if(w(Zl)<0x8000000000000000){Xl=w(Zl)>=1?Zl>0?~~y(A(Zl/4294967296),4294967295)>>>0:~~B((Zl- +(~~Zl>>>0>>>0))/4294967296)>>>0:0;_l=~~Zl>>>0;break g}Xl=-2147483648;_l=0}o[Wl>>2]=_l;o[Tl+4>>2]=Xl;vk=vk+8|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}break d;case 9:break e}}Tl=m[Ye+24|0];if(((Tl|0)>(gl|0)?gl:Tl)<<24>>24>=1){Wl=o[o[Ye>>2]>>2];Tl=o[Ye+48>>2]+Vl(o[Ye+40>>2],o[Ye+44>>2],vk,0)|0;vk=Wl+Tl|0;while(1){Tl=(Ul<<3)+hl|0;o[Tl>>2]=p[vk|0];o[Tl+4>>2]=0;vk=vk+1|0;Ul=Ul+1|0;Tl=m[Ye+24|0];if((Ul|0)<((Tl|0)>(gl|0)?gl:Tl)<<24>>24){continue}break}}if((Tl|0)>=(gl|0)){break b}xl((Tl<<3)+hl|0,0,gl-Tl<<3);break b}if((Tl|0)>=(gl|0)){break b}break a}if((Tl|0)>=(gl|0)){break b}xl((Tl<<3)+hl|0,0,gl-Tl<<3)}return}xl((Tl<<3)+hl|0,0,gl-Tl<<3)}function Ne(Ye){Ye=Ye|0;var vk=0;o[Ye>>2]=3272;o[Ye>>2]=2732;vk=o[Ye+32>>2];if(vk){o[Ye+36>>2]=vk;ul(vk)}return Ye|0}function Oe(Ye){Ye=Ye|0;var gl=0;o[Ye>>2]=3272;o[Ye>>2]=2732;gl=o[Ye+32>>2];if(gl){o[Ye+36>>2]=gl;ul(gl)}ul(Ye)}function Pe(o){o=o|0;return 6}function Qe(Ye){Ye=Ye|0;var hl=0;a:{if(!o[Ye- -64>>2]|!o[Ye+68>>2]|(!o[Ye+44>>2]|!o[Ye+48>>2])){break a}if(!o[Ye+52>>2]|!o[Ye+56>>2]){break a}hl=o[Ye+92>>2]!=-1}return hl|0}function Re(Ye,Vl){Ye=Ye|0;Vl=Vl|0;var $l=0;if(!(o[Vl+56>>2]|p[Vl+24|0]!=3)){o[Ye- -64>>2]=Vl;$l=1}return $l|0}function Se(Ye,Vl){Ye=Ye|0;Vl=Vl|0;var am=0,bm=0,cm=0,dm=0,em=0,fm=0,gm=0,hm=0,im=0,jm=0;bm=o[Vl+12>>2];cm=bm;am=o[Vl+20>>2];em=am;fm=o[Vl+16>>2];dm=fm+4|0;if(dm>>>0<4){am=am+1|0}hm=o[Vl+8>>2];gm=dm;dm=am;a:{if((bm|0)<(am|0)?1:(bm|0)<=(am|0)?hm>>>0>=gm>>>0?0:1:0){break a}im=o[Vl>>2];am=im+fm|0;bm=p[am|0]|p[am+1|0]<<8|(p[am+2|0]<<16|p[am+3|0]<<24);o[Vl+16>>2]=gm;o[Vl+20>>2]=dm;am=em;em=fm+8|0;if(em>>>0<8){am=am+1|0}dm=em;em=am;if((cm|0)<(am|0)?1:(cm|0)<=(am|0)?hm>>>0>=dm>>>0?0:1:0){break a}am=gm+im|0;am=p[am|0]|p[am+1|0]<<8|(p[am+2|0]<<16|p[am+3|0]<<24);o[Vl+16>>2]=dm;o[Vl+20>>2]=em;if((bm|0)>(am|0)){break a}o[Ye+16>>2]=am;o[Ye+12>>2]=bm;cm=bm;bm=(am>>31)-((bm>>31)+(am>>>0>>0)|0)|0;am=am-cm|0;if(!bm&am>>>0>2147483646|bm>>>0>0){break a}am=am+1|0;o[Ye+20>>2]=am;cm=Ye+24|0;bm=(am|0)/2|0;o[cm>>2]=bm;o[Ye+28>>2]=0-bm;if(!(am&1)){o[cm>>2]=bm+ -1}jm=Nf(Ye+108|0,Vl)}return jm|0}function Te(Ye,km,lm,mm,nm,om){Ye=Ye|0;km=km|0;lm=lm|0;mm=mm|0;nm=nm|0;om=om|0;var pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0,Cm=0,Dm=0;qm=R-32|0;R=qm;o[Ye+68>>2]=om;mm=o[Ye+56>>2];nm=o[mm>>2];om=mm+4|0;pm=o[om>>2];o[qm+24>>2]=0;o[qm+16>>2]=0;o[qm+20>>2]=0;a:{nm=pm-nm|0;if((nm|0)<1){break a}mm=o[mm>>2];if((mm|0)!=o[om>>2]){Am=nm>>2;Bm=Ye+60|0;Cm=Ye+108|0;vm=Ye+8|0;wm=Ye+16|0;xm=Ye+32|0;ym=Ye+20|0;zm=Ye+12|0;Dm=Ye+56|0;while(1){Ue(Bm,o[(tm<<2)+mm>>2],qm+16|0);nm=o[qm+20>>2];pm=nm>>31;om=o[qm+16>>2];rm=om>>31;um=o[qm+24>>2];sm=um>>31;mm=0;sm=sm^sm+um;pm=sm+((pm^nm+pm)+(rm^om+rm)|0)|0;if(pm>>>0>>0){mm=1}b:{if(!(mm|pm)){o[qm+16>>2]=o[Ye+104>>2];break b}rm=o[Ye+104>>2];sm=rm>>31;nm=Wl(Vl(rm,sm,nm,nm>>31),T,pm,mm);o[qm+20>>2]=nm;mm=Wl(Vl(rm,sm,om,om>>31),T,pm,mm);o[qm+16>>2]=mm;om=mm;mm=mm>>31;mm=(rm-(om+mm^mm)|0)+((nm|0)<0?nm:0-nm|0)|0;if((um|0)>=0){o[qm+24>>2]=mm;break b}o[qm+24>>2]=0-mm}mm=Pf(Cm);om=o[qm+16>>2];c:{if(!mm){nm=o[qm+20>>2];break c}o[qm+24>>2]=0-o[qm+24>>2];nm=0-o[qm+20>>2]|0;o[qm+20>>2]=nm;om=0-om|0;o[qm+16>>2]=om}d:{if((om|0)>=0){mm=o[Ye+104>>2];om=mm+o[qm+24>>2]|0;mm=mm+nm|0;break d}e:{if((nm|0)<=-1){om=o[qm+24>>2];mm=om>>31;mm=mm^mm+om;break e}om=o[qm+24>>2];mm=om>>31;mm=o[Ye+100>>2]-(mm^mm+om)|0}if((om|0)<=-1){om=nm;nm=nm>>31;om=om+nm^nm;break d}om=nm;nm=nm>>31;om=o[Ye+100>>2]-(om+nm^nm)|0}nm=o[Ye+100>>2];f:{if(!(mm|om)){om=nm;mm=nm;break f}if(!((nm|0)!=(om|0)|mm)){mm=om;break f}if(!((mm|0)!=(nm|0)|om)){om=mm;break f}g:{if(mm){break g}pm=o[Ye+104>>2];if((pm|0)>=(om|0)){break g}om=(pm<<1)-om|0;mm=0;break f}h:{if((mm|0)!=(nm|0)){break h}pm=o[Ye+104>>2];if((pm|0)<=(om|0)){break h}om=(pm<<1)-om|0;break f}i:{if((nm|0)!=(om|0)){break i}nm=o[Ye+104>>2];if((nm|0)<=(mm|0)){break i}mm=(nm<<1)-mm|0;break f}if(om){break f}om=0;nm=o[Ye+104>>2];if((nm|0)>=(mm|0)){break f}mm=(nm<<1)-mm|0}o[qm+12>>2]=om;o[qm+8>>2]=mm;j:{if(o[vm>>2]<1){break j}om=0;while(1){pm=o[wm>>2];k:{if((mm|0)>(pm|0)){nm=o[xm>>2];o[nm+(om<<2)>>2]=pm;break k}nm=o[xm>>2];pm=nm+(om<<2)|0;rm=o[zm>>2];if((mm|0)<(rm|0)){o[pm>>2]=rm;break k}o[pm>>2]=mm}om=om+1|0;pm=o[vm>>2];if((om|0)<(pm|0)){mm=o[(qm+8|0)+(om<<2)>>2];continue}break}mm=0;if((pm|0)<1){break j}om=tm<<3;rm=om+lm|0;um=km+om|0;while(1){pm=mm<<2;om=pm+rm|0;pm=o[pm+um>>2]+o[nm+pm>>2]|0;o[om>>2]=pm;l:{if((pm|0)>o[wm>>2]){sm=pm-o[ym>>2]|0}else{if((pm|0)>=o[zm>>2]){break l}sm=pm+o[ym>>2]|0}o[om>>2]=sm}mm=mm+1|0;if((mm|0)>2]){continue}break}}tm=tm+1|0;if((tm|0)>=(Am|0)){break a}nm=o[Dm>>2];mm=o[nm>>2];if(o[nm+4>>2]-mm>>2>>>0>tm>>>0){continue}break}}Zk();D()}R=qm+32|0;return 1}function Ue(Ye,km,lm){Ye=Ye|0;km=km|0;lm=lm|0;var mm=0,nm=0,om=0,Em=0,Fm=0,Gm=0,Hm=0,Im=0,Jm=0,Km=0,Lm=0,Mm=0,Nm=0,Om=0,Pm=0,Qm=0,Rm=0,Sm=0,Tm=0,Um=0,Vm=0,Wm=0,Xm=0,Ym=0,Zm=0,_m=0;nm=R-96|0;R=nm;mm=o[Ye+16>>2];m[nm+92|0]=1;o[nm+88>>2]=km;o[nm+84>>2]=km;o[nm+80>>2]=mm;Em=o[Ye+20>>2];om=o[Em>>2];a:{b:{c:{d:{mm=o[o[mm+28>>2]+(km<<2)>>2];if(o[Em+4>>2]-om>>2>>>0>mm>>>0){mm=o[o[Ye+8>>2]+(o[om+(mm<<2)>>2]<<2)>>2];om=o[Ye+4>>2];if(!p[om+84|0]){mm=o[o[om+68>>2]+(mm<<2)>>2]}o[nm+72>>2]=0;o[nm+76>>2]=0;Em=nm- -64|0;o[Em>>2]=0;o[Em+4>>2]=0;o[nm+56>>2]=0;o[nm+60>>2]=0;Me(om,mm,m[om+24|0],nm+56|0);if((km|0)==-1){break a}mm=km+1|0;Em=(mm>>>0)%3|0?mm:km+ -2|0;Om=((km>>>0)%3|0?-1:2)+km|0;Vm=Ye+28|0;Fm=!o[Vm>>2];Wm=Ye+20|0;Xm=Ye+16|0;Ym=Ye+8|0;while(1){om=Em;mm=Om;e:{if(Fm){break e}mm=km+1|0;om=(mm>>>0)%3|0?mm:km+ -2|0;mm=km+ -1|0;if((km>>>0)%3){break e}mm=km+2|0}Fm=o[Wm>>2];km=o[Fm>>2];om=o[o[o[Xm>>2]+28>>2]+(om<<2)>>2];if(o[Fm+4>>2]-km>>2>>>0<=om>>>0){break d}om=o[o[Ym>>2]+(o[km+(om<<2)>>2]<<2)>>2];Fm=Ye+4|0;km=o[Fm>>2];if(!p[km+84|0]){om=o[o[km+68>>2]+(om<<2)>>2]}o[nm+48>>2]=0;o[nm+52>>2]=0;o[nm+40>>2]=0;o[nm+44>>2]=0;o[nm+32>>2]=0;o[nm+36>>2]=0;Me(km,om,m[km+24|0],nm+32|0);om=o[Wm>>2];km=o[om>>2];mm=o[o[o[Xm>>2]+28>>2]+(mm<<2)>>2];if(o[om+4>>2]-km>>2>>>0<=mm>>>0){break c}om=o[o[Ym>>2]+(o[km+(mm<<2)>>2]<<2)>>2];km=o[Fm>>2];if(!p[km+84|0]){om=o[o[km+68>>2]+(om<<2)>>2]}Fm=nm+24|0;mm=Fm;o[mm>>2]=0;o[mm+4>>2]=0;Im=nm+16|0;mm=Im;o[mm>>2]=0;o[mm+4>>2]=0;o[nm+8>>2]=0;o[nm+12>>2]=0;Me(km,om,m[km+24|0],nm+8|0);mm=o[nm+8>>2];km=o[nm+56>>2];Pm=mm-km|0;Qm=o[nm+60>>2];om=o[nm+12>>2]-(Qm+(mm>>>0>>0)|0)|0;Rm=o[nm+40>>2];mm=o[nm+64>>2];Zm=Rm-mm|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Gm;Em=Ye+(mm-km|0)|0;km=om+(Fm-((mm>>>0>>0)+Jm|0)|0)|0;mm=Em;Ye=mm>>>0>>0?km+1|0:km;if(!Im){break f}break b}km=Fm+Jm|0;Em=mm;mm=Gm;Em=Em+mm|0;if(Em>>>0>>0){km=km+1|0}mm=Ye;Em=mm+Em|0;Ye=km+om|0;Ye=Em>>>0>>0?Ye+1|0:Ye;mm=Em;if(Im){break b}}if((mm|0)<536870913){break a}Ye=((Ye&536870911)<<3|mm>>>29)&7;km=0;Gm=Wl(Gm,Jm,Ye,km);Hm=Wl(Hm,Mm,Ye,km);Km=Wl(Km,Nm,Ye,km);break a}Zk();D()}Zk();D()}Zk();D()}if((Ye|0)<0?1:(Ye|0)<=0?mm>>>0>=536870913?0:1:0){break a}km=Ye>>>29;Ye=(Ye&536870911)<<3|mm>>>29;Gm=Wl(Gm,Jm,Ye,km);Hm=Wl(Hm,Mm,Ye,km);Km=Wl(Km,Nm,Ye,km)}o[lm+8>>2]=Gm;o[lm+4>>2]=Hm;o[lm>>2]=Km;R=nm+96|0}function Ve(Ye,Vl){Ye=Ye|0;Vl=Vl|0;if(Vl>>>0<=1){o[Ye+28>>2]=Vl;Ye=1}else{Ye=0}return Ye|0}function We(Ye){var Vl=0,km=0,lm=0;Vl=o[Ye+8>>2];lm=o[Ye>>2];a:{if(p[Ye+12|0]){b:{c:{d:{e:{if((Vl|0)==-1){break e}km=Vl+1|0;Vl=(km>>>0)%3|0?km:Vl+ -2|0;if((Vl|0)==-1|o[o[lm>>2]+(Vl>>>3&536870908)>>2]>>>(Vl&31)&1){break e}Vl=o[o[o[lm+64>>2]+12>>2]+(Vl<<2)>>2];if((Vl|0)!=-1){break d}}o[Ye+8>>2]=-1;break c}km=Vl+1|0;Vl=(km>>>0)%3|0?km:Vl+ -2|0;o[Ye+8>>2]=Vl;if((Vl|0)!=-1){break b}}Vl=-1;km=o[Ye+4>>2];f:{if((km|0)==-1){break f}km=km+((km>>>0)%3|0?-1:2)|0;if((km|0)==-1|o[o[lm>>2]+(km>>>3&536870908)>>2]>>>(km&31)&1){break f}lm=o[o[o[lm+64>>2]+12>>2]+(km<<2)>>2];if((lm|0)==-1){break f}if((lm>>>0)%3){Vl=lm+ -1|0;break f}Vl=lm+2|0}m[Ye+12|0]=0;o[Ye+8>>2]=Vl;return}if((Vl|0)!=o[Ye+4>>2]){break a}o[Ye+8>>2]=-1;return}km=-1;g:{if((Vl|0)==-1){break g}Vl=Vl+((Vl>>>0)%3|0?-1:2)|0;if((Vl|0)==-1|o[o[lm>>2]+(Vl>>>3&536870908)>>2]>>>(Vl&31)&1){break g}Vl=o[o[o[lm+64>>2]+12>>2]+(Vl<<2)>>2];if((Vl|0)==-1){break g}if((Vl>>>0)%3){km=Vl+ -1|0;break g}km=Vl+2|0}o[Ye+8>>2]=km}}function Xe(Ye,$m,an,bn){var cn=0,dn=0,en=0,fn=0,gn=0,hn=0,jn=0,kn=0;o[Ye>>2]=2732;o[Ye+4>>2]=$m;$m=o[an+8>>2];cn=o[an+12>>2];dn=o[an+16>>2];fn=o[an+20>>2];gn=o[an>>2];hn=o[an+4>>2];o[Ye+40>>2]=0;en=Ye+32|0;o[en>>2]=0;o[en+4>>2]=0;o[Ye+24>>2]=dn;o[Ye+28>>2]=fn;o[Ye+16>>2]=$m;o[Ye+20>>2]=cn;o[Ye+8>>2]=gn;o[Ye+12>>2]=hn;a:{$m=o[an+28>>2]-o[an+24>>2]|0;b:{if(!$m){break b}cn=$m>>2;if(cn>>>0>=1073741824){break a}$m=Hk($m);o[Ye+32>>2]=$m;dn=Ye+36|0;o[dn>>2]=$m;o[Ye+40>>2]=$m+(cn<<2);cn=o[an+24>>2];an=o[an+28>>2]-cn|0;if((an|0)<1){break b}jn=dn,kn=wl($m,cn,an)+an|0,o[jn>>2]=kn}o[Ye>>2]=4268;$m=o[bn+4>>2];o[Ye+44>>2]=o[bn>>2];o[Ye+48>>2]=$m;$m=o[bn+12>>2];o[Ye+52>>2]=o[bn+8>>2];o[Ye+56>>2]=$m;return}Yk();D()}function Ye(Ye,$m,an,bn,ln,mn){Ye=Ye|0;$m=$m|0;an=an|0;bn=bn|0;ln=ln|0;mn=mn|0;var nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0,wn=0,xn=0,yn=0,zn=0,An=0,Bn=0,Cn=0;o[Ye+8>>2]=ln;mn=Ye+32|0;on=o[mn>>2];bn=o[Ye+36>>2]-on>>2;a:{if(bn>>>0>>0){Da(mn,ln-bn|0);break a}if(bn>>>0<=ln>>>0){break a}o[Ye+36>>2]=on+(ln<<2)}Cn=o[Ye+52>>2];zn=o[Ye+48>>2];bn=0;mn=(ln&1073741823)!=(ln|0)?-1:ln<<2;yn=xl(Hk(mn),0,mn);rn=Ye+8|0;mn=o[rn>>2];b:{if((mn|0)<1){break b}tn=Ye+16|0;on=Ye+32|0;un=Ye+12|0;while(1){mn=bn<<2;nn=o[mn+yn>>2];qn=o[tn>>2];c:{if((nn|0)>(qn|0)){sn=o[on>>2];o[mn+sn>>2]=qn;break c}sn=o[on>>2];mn=mn+sn|0;qn=o[un>>2];if((nn|0)<(qn|0)){o[mn>>2]=qn;break c}o[mn>>2]=nn}bn=bn+1|0;mn=o[rn>>2];if((bn|0)<(mn|0)){continue}break}if((mn|0)<1){break b}on=0;rn=Ye+16|0;nn=Ye+20|0;tn=Ye+8|0;un=Ye+12|0;while(1){mn=on<<2;bn=mn+an|0;mn=o[$m+mn>>2]+o[mn+sn>>2]|0;o[bn>>2]=mn;d:{if((mn|0)>o[rn>>2]){mn=mn-o[nn>>2]|0}else{if((mn|0)>=o[un>>2]){break d}mn=mn+o[nn>>2]|0}o[bn>>2]=mn}on=on+1|0;mn=o[tn>>2];if((on|0)<(mn|0)){continue}break}}bn=o[Ye+56>>2];An=o[bn>>2];bn=o[bn+4>>2]-An|0;if((bn|0)>=5){Bn=bn>>2;sn=Ye+16|0;rn=Ye+32|0;tn=Ye+8|0;un=Ye+20|0;qn=Ye+12|0;on=1;while(1){e:{f:{if(Bn>>>0>on>>>0){xn=u(ln,on);Ye=o[(on<<2)+An>>2];if((Ye|0)==-1){break f}Ye=o[o[zn+12>>2]+(Ye<<2)>>2];if((Ye|0)==-1){break f}bn=-1;pn=o[Cn>>2];nn=o[zn>>2];vn=o[pn+(o[nn+(Ye<<2)>>2]<<2)>>2];wn=Ye+1|0;wn=(wn>>>0)%3|0?wn:Ye+ -2|0;if((wn|0)!=-1){wn=o[nn+(wn<<2)>>2]}else{wn=-1}Ye=Ye+((Ye>>>0)%3|0?-1:2)|0;if((Ye|0)!=-1){bn=o[nn+(Ye<<2)>>2]}if((vn|0)>=(on|0)){break f}Ye=o[(wn<<2)+pn>>2];if((Ye|0)>=(on|0)){break f}bn=o[pn+(bn<<2)>>2];if((bn|0)>=(on|0)){break f}if((ln|0)>=1){nn=u(bn,ln);Ye=u(Ye,ln);pn=u(ln,vn);bn=0;while(1){o[(bn<<2)+yn>>2]=(o[(bn+nn<<2)+an>>2]+o[(Ye+bn<<2)+an>>2]|0)-o[(bn+pn<<2)+an>>2];bn=bn+1|0;if((ln|0)!=(bn|0)){continue}break}}if((mn|0)<1){break e}bn=0;while(1){Ye=bn<<2;mn=o[Ye+yn>>2];pn=o[sn>>2];g:{if((mn|0)>(pn|0)){nn=o[rn>>2];o[Ye+nn>>2]=pn;break g}nn=o[rn>>2];Ye=Ye+nn|0;pn=o[qn>>2];if((mn|0)<(pn|0)){o[Ye>>2]=pn;break g}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}bn=0;if((mn|0)<1){break e}Ye=xn<<2;xn=Ye+an|0;pn=Ye+$m|0;while(1){mn=bn<<2;Ye=mn+xn|0;mn=o[mn+pn>>2]+o[mn+nn>>2]|0;o[Ye>>2]=mn;h:{if((mn|0)>o[sn>>2]){mn=mn-o[un>>2]|0}else{if((mn|0)>=o[qn>>2]){break h}mn=mn+o[un>>2]|0}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}break e}Zk();D()}if((mn|0)<1){break e}pn=(u(on+ -1|0,ln)<<2)+an|0;bn=0;while(1){Ye=bn<<2;mn=o[Ye+pn>>2];vn=o[sn>>2];i:{if((mn|0)>(vn|0)){nn=o[rn>>2];o[Ye+nn>>2]=vn;break i}nn=o[rn>>2];Ye=Ye+nn|0;vn=o[qn>>2];if((mn|0)<(vn|0)){o[Ye>>2]=vn;break i}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}bn=0;if((mn|0)<1){break e}Ye=xn<<2;xn=Ye+an|0;pn=Ye+$m|0;while(1){mn=bn<<2;Ye=mn+xn|0;mn=o[mn+pn>>2]+o[mn+nn>>2]|0;o[Ye>>2]=mn;j:{if((mn|0)>o[sn>>2]){mn=mn-o[un>>2]|0}else{if((mn|0)>=o[qn>>2]){break j}mn=mn+o[un>>2]|0}o[Ye>>2]=mn}bn=bn+1|0;mn=o[tn>>2];if((bn|0)<(mn|0)){continue}break}}on=on+1|0;if((on|0)<(Bn|0)){continue}break}}ul(yn);return 1}function Ze(Ye){Ye=Ye|0;var $m=0;o[Ye>>2]=4324;$m=o[Ye+96>>2];if($m){ul($m)}$m=o[Ye+84>>2];if($m){ul($m)}$m=o[Ye+72>>2];if($m){ul($m)}$m=o[Ye+60>>2];if($m){ul($m)}o[Ye>>2]=2732;$m=o[Ye+32>>2];if($m){o[Ye+36>>2]=$m;ul($m)}return Ye|0}function _e(Ye){Ye=Ye|0;var an=0;o[Ye>>2]=4324;an=o[Ye+96>>2];if(an){ul(an)}an=o[Ye+84>>2];if(an){ul(an)}an=o[Ye+72>>2];if(an){ul(an)}an=o[Ye+60>>2];if(an){ul(an)}o[Ye>>2]=2732;an=o[Ye+32>>2];if(an){o[Ye+36>>2]=an;ul(an)}ul(Ye)}function $e(Ye,bn,ln,mn,Dn,En){Ye=Ye|0;bn=bn|0;ln=ln|0;mn=mn|0;Dn=Dn|0;En=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0}else{mn=Fn+2|0}}if((mn|0)!=-1){continue}}break}Fn=En;if((Fn|0)<1){break n}}Ln=(Dn|0)<1;if(!Ln){xl(Sn,0,bo)}mn=Fn+ -1|0;Jn=(mn<<2)+Yn|0;mn=u(mn,12)+Ye|0;On=mn+60|0;Qn=o[mn- -64>>2];In=0;Tn=o[Hn>>2];mn=0;En=0;while(1){Gn=o[Jn>>2];o[Jn>>2]=Gn+1;if(Qn>>>0<=Gn>>>0){break i}s:{if(o[o[On>>2]+(Gn>>>3&536870908)>>2]>>>(Gn&31)&1){break s}En=En+1|0;if(Ln){break s}Pn=o[(Hn+16|0)+u(mn,12)>>2];Gn=0;while(1){Un=Gn<<2;Xn=Un+Tn|0;o[Xn>>2]=o[Xn>>2]+o[Pn+Un>>2];Gn=Gn+1|0;if((Gn|0)!=(Dn|0)){continue}break}}mn=mn+1|0;if((Fn|0)!=(mn|0)){continue}break}Fn=u(Dn,Kn);mn=Fn;if(!En){break m}Gn=0;if((Dn|0)>0){break l}break k}mn=u(Dn,Kn)}if(o[Mn>>2]<1){break j}Jn=(u(Kn+ -1|0,Dn)<<2)+ln|0;Gn=0;while(1){En=Gn<<2;Fn=o[En+Jn>>2];Ln=o[Rn>>2];t:{if((Fn|0)>(Ln|0)){In=o[Nn>>2];o[En+In>>2]=Ln;break t}In=o[Nn>>2];En=En+In|0;Ln=o[Wn>>2];if((Fn|0)<(Ln|0)){o[En>>2]=Ln;break t}o[En>>2]=Fn}Gn=Gn+1|0;Fn=o[Mn>>2];if((Gn|0)<(Fn|0)){continue}break}En=0;if((Fn|0)<1){break j}mn=mn<<2;Gn=mn+ln|0;Jn=bn+mn|0;while(1){Fn=En<<2;mn=Fn+Gn|0;Fn=o[Fn+Jn>>2]+o[Fn+In>>2]|0;o[mn>>2]=Fn;u:{if((Fn|0)>o[Rn>>2]){Fn=Fn-o[Vn>>2]|0}else{if((Fn|0)>=o[Wn>>2]){break u}Fn=Fn+o[Vn>>2]|0}o[mn>>2]=Fn}En=En+1|0;if((En|0)>2]){continue}break}break j}Zk();D()}while(1){mn=(Gn<<2)+Sn|0;o[mn>>2]=o[mn>>2]/(En|0);Gn=Gn+1|0;if((Gn|0)!=(Dn|0)){continue}break}}if(o[Mn>>2]<1){break j}Gn=0;while(1){mn=Gn<<2;En=o[mn+Sn>>2];Jn=o[Rn>>2];v:{if((En|0)>(Jn|0)){In=o[Nn>>2];o[mn+In>>2]=Jn;break v}In=o[Nn>>2];mn=mn+In|0;Jn=o[Wn>>2];if((En|0)<(Jn|0)){o[mn>>2]=Jn;break v}o[mn>>2]=En}Gn=Gn+1|0;mn=o[Mn>>2];if((Gn|0)<(mn|0)){continue}break}En=0;if((mn|0)<1){break j}mn=Fn<<2;Gn=mn+ln|0;Jn=bn+mn|0;while(1){Fn=En<<2;mn=Fn+Gn|0;Fn=o[Fn+Jn>>2]+o[Fn+In>>2]|0;o[mn>>2]=Fn;w:{if((Fn|0)>o[Rn>>2]){Fn=Fn-o[Vn>>2]|0}else{if((Fn|0)>=o[Wn>>2]){break w}Fn=Fn+o[Vn>>2]|0}o[mn>>2]=Fn}En=En+1|0;if((En|0)>2]){continue}break}}In=1;Kn=Kn+1|0;if((Kn|0)<($n|0)){continue}break}}Ye=o[Hn>>2];if(Ye){o[Hn+4>>2]=Ye;ul(Ye)}ul(Yn);Ye=o[Hn+52>>2];if(Ye){o[Hn+56>>2]=Ye;ul(Ye)}Ye=o[Hn+40>>2];if(Ye){o[Hn+44>>2]=Ye;ul(Ye)}Ye=o[Hn+28>>2];if(Ye){o[Hn+32>>2]=Ye;ul(Ye)}Ye=o[Hn+16>>2];if(Ye){o[Hn+20>>2]=Ye;ul(Ye)}R=Hn- -64|0;return In|0}Yk();D()}function af(Ye){Ye=Ye|0;var bn=0;o[Ye>>2]=4560;bn=o[Ye+76>>2];if(bn){ul(bn)}o[Ye>>2]=2732;bn=o[Ye+32>>2];if(bn){o[Ye+36>>2]=bn;ul(bn)}return Ye|0}function bf(Ye){Ye=Ye|0;var ln=0;o[Ye>>2]=4560;ln=o[Ye+76>>2];if(ln){ul(ln)}o[Ye>>2]=2732;ln=o[Ye+32>>2];if(ln){o[Ye+36>>2]=ln;ul(ln)}ul(Ye)}function cf(Ye,mn,Dn,En,co,eo){Ye=Ye|0;mn=mn|0;Dn=Dn|0;En=En|0;co=co|0;eo=eo|0;var fo=0,go=0,ho=0,io=0,jo=0,ko=0,lo=0,mo=0,no=0,oo=0,po=0,qo=0;En=0;a:{if((co|0)!=2){break a}o[Ye+8>>2]=2;o[Ye- -64>>2]=eo;En=Ye+32|0;co=o[En>>2];eo=o[Ye+36>>2]-co|0;fo=eo>>2;b:{if(fo>>>0<=1){Da(En,2-fo|0);break b}if((eo|0)==8){break b}o[Ye+36>>2]=co+8}En=1;co=o[Ye+56>>2];eo=o[co+4>>2];co=o[co>>2];fo=eo-co|0;if((fo|0)<1){break a}if((co|0)!=(eo|0)){no=Ye+60|0;oo=fo>>2;fo=Ye+8|0;jo=Ye+16|0;ko=Ye+32|0;lo=Ye+20|0;mo=Ye+12|0;po=Ye+56|0;while(1){if(!df(no,o[(ho<<2)+co>>2],Dn,ho)){En=0;break a}c:{if(o[fo>>2]<1){break c}co=0;while(1){En=co<<2;eo=o[(En+Ye|0)+68>>2];go=o[jo>>2];d:{if((eo|0)>(go|0)){io=o[ko>>2];o[En+io>>2]=go;break d}io=o[ko>>2];En=En+io|0;go=o[mo>>2];if((eo|0)<(go|0)){o[En>>2]=go;break d}o[En>>2]=eo}co=co+1|0;En=o[fo>>2];if((co|0)<(En|0)){continue}break}eo=0;if((En|0)<1){break c}En=ho<<3;go=En+Dn|0;qo=mn+En|0;while(1){co=eo<<2;En=co+go|0;co=o[co+qo>>2]+o[co+io>>2]|0;o[En>>2]=co;e:{if((co|0)>o[jo>>2]){co=co-o[lo>>2]|0}else{if((co|0)>=o[mo>>2]){break e}co=co+o[lo>>2]|0}o[En>>2]=co}eo=eo+1|0;if((eo|0)>2]){continue}break}}En=1;ho=ho+1|0;if((ho|0)>=(oo|0)){break a}En=o[po>>2];co=o[En>>2];if(o[En+4>>2]-co>>2>>>0>ho>>>0){continue}break}}Zk();D()}return En|0}function df(Ye,mn,Dn,En){var co=0,eo=0,ro=0,so=0,to=0,uo=0,vo=0,wo=0,xo=0,yo=0,zo=0,Ao=0,Bo=0,Co=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0,No=0;ro=R-80|0;R=ro;co=-1;eo=-1;a:{if((mn|0)==-1){break a}so=((mn>>>0)%3|0?-1:2)+mn|0;to=o[Ye+32>>2];vo=mn+1|0;mn=(vo>>>0)%3|0?vo:mn+ -2|0;if((mn|0)!=-1){co=o[o[to>>2]+(mn<<2)>>2]}if((so|0)==-1){break a}eo=o[o[to>>2]+(so<<2)>>2]}so=o[Ye+36>>2];mn=o[so>>2];b:{c:{d:{e:{so=o[so+4>>2]-mn>>2;if(!(so>>>0<=co>>>0|so>>>0<=eo>>>0)){f:{g:{yo=o[mn+(co<<2)>>2];Ao=(yo|0)>=(En|0);if(Ao){break g}eo=o[mn+(eo<<2)>>2];if((eo|0)>=(En|0)){break g}mn=eo<<3;Fo=o[(mn|4)+Dn>>2];co=yo<<3;vo=o[(co|4)+Dn>>2];Co=o[mn+Dn>>2];Eo=o[Dn+co>>2];if(!((Co|0)!=(Eo|0)|(vo|0)!=(Fo|0))){o[Ye+8>>2]=Eo;o[Ye+12>>2]=vo;break f}mn=o[o[Ye+4>>2]+(En<<2)>>2];o[ro+72>>2]=0;o[ro+76>>2]=0;co=ro- -64|0;o[co>>2]=0;o[co+4>>2]=0;o[ro+56>>2]=0;o[ro+60>>2]=0;co=o[Ye>>2];if(!p[co+84|0]){mn=o[o[co+68>>2]+(mn<<2)>>2]}Me(co,mn,m[co+24|0],ro+56|0);mn=o[o[Ye+4>>2]+(yo<<2)>>2];o[ro+48>>2]=0;o[ro+52>>2]=0;o[ro+40>>2]=0;o[ro+44>>2]=0;o[ro+32>>2]=0;o[ro+36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+xo|0;co=T+co|0;co=uo>>>0>>0?co+1|0:co;xo=uo;uo=co;eo=Wl(Vl(xo,co,Io,eo),T,Do,to);Ao=Ao-(T+(yo>>>0>>0)|0)|0;eo=yo-eo|0;eo=Vl(eo,Ao,eo,Ao);yo=T;Bo=eo;co=Wl(Vl(Jo,so,xo,co),T,Do,to);eo=Go-(T+(Dn>>>0>>0)|0)|0;Dn=Dn-co|0;eo=Vl(Dn,eo,Dn,eo);Dn=Bo+eo|0;co=T+yo|0;co=Dn>>>0>>0?co+1|0:co;so=Dn;Dn=Wl(Vl(xo,uo,Ko,zo),T,Do,to);eo=Ho-(T+(wo>>>0>>0)|0)|0;Dn=wo-Dn|0;eo=Vl(Dn,eo,Dn,eo);Dn=so+eo|0;co=T+co|0;eo=Vl(Dn,Dn>>>0>>0?co+1|0:co,Do,to);Dn=T;so=Dn;if(!Dn&eo>>>0<=1|Dn>>>0<0){break e}zo=eo;Dn=so;while(1){co=mn<<1|En>>>31;En=En<<1;mn=co;wo=!Dn&zo>>>0>7|Dn>>>0>0;zo=(Dn&3)<<30|zo>>>2;Dn=Dn>>>2;if(wo){continue}break}break d}co=Ye;if(Ao){if((En|0)<=0){o[Ye+8>>2]=0;o[Ye+12>>2]=0;break f}mn=(En<<1)+ -2|0}else{mn=yo<<1}mn=(mn<<2)+Dn|0;o[co+8>>2]=o[mn>>2];o[Ye+12>>2]=o[mn+4>>2]}Dn=1;break b}Zk();D()}En=eo;mn=so;if(eo-1){break c}}while(1){Dn=Xl(eo,so,En,mn)+En|0;co=mn+T|0;co=Dn>>>0>>0?co+1|0:co;En=(co&1)<<31|Dn>>>1;mn=co>>>1;Dn=Vl(En,mn,En,mn);co=T;if((so|0)==(co|0)&Dn>>>0>eo>>>0|co>>>0>so>>>0){continue}break}}co=o[Ye+20>>2];Dn=0;if(!co){break b}so=co+ -1|0;zo=o[o[Ye+16>>2]+(so>>>3&536870908)>>2];o[Ye+20>>2]=so;Dn=Fo;co=vo;wo=Dn-co|0;vo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ro+Qo^Qo;break d}Ro=Qo;Qo=Qo>>31;Ro=o[Ye+100>>2]-(Ro+Qo^Qo)|0}Qo=o[Ye+100>>2];f:{if(!(Po|Ro)){Ro=Qo;Po=Qo;break f}if(!((Qo|0)!=(Ro|0)|Po)){Po=Ro;break f}if(!((Po|0)!=(Qo|0)|Ro)){Ro=Po;break f}g:{if(Po){break g}So=o[Ye+104>>2];if((So|0)>=(Ro|0)){break g}Ro=(So<<1)-Ro|0;Po=0;break f}h:{if((Po|0)!=(Qo|0)){break h}So=o[Ye+104>>2];if((So|0)<=(Ro|0)){break h}Ro=(So<<1)-Ro|0;break f}i:{if((Qo|0)!=(Ro|0)){break i}Qo=o[Ye+104>>2];if((Qo|0)<=(Po|0)){break i}Po=(Qo<<1)-Po|0;break f}if(Ro){break f}Ro=0;Qo=o[Ye+104>>2];if((Qo|0)>=(Po|0)){break f}Po=(Qo<<1)-Po|0}o[To+12>>2]=Ro;o[To+8>>2]=Po;j:{if(o[Yo>>2]<1){break j}Ro=0;while(1){So=o[Zo>>2];k:{if((Po|0)>(So|0)){Qo=o[_o>>2];o[Qo+(Ro<<2)>>2]=So;break k}Qo=o[_o>>2];So=Qo+(Ro<<2)|0;Uo=o[ap>>2];if((Po|0)<(Uo|0)){o[So>>2]=Uo;break k}o[So>>2]=Po}Ro=Ro+1|0;So=o[Yo>>2];if((Ro|0)<(So|0)){Po=o[(To+8|0)+(Ro<<2)>>2];continue}break}Po=0;if((So|0)<1){break j}Ro=Wo<<3;Uo=Ro+Oo|0;Xo=En+Ro|0;while(1){So=Po<<2;Ro=So+Uo|0;So=o[So+Xo>>2]+o[Qo+So>>2]|0;o[Ro>>2]=So;l:{if((So|0)>o[Zo>>2]){Vo=So-o[$o>>2]|0}else{if((So|0)>=o[ap>>2]){break l}Vo=So+o[$o>>2]|0}o[Ro>>2]=Vo}Po=Po+1|0;if((Po|0)>2]){continue}break}}Wo=Wo+1|0;if((Wo|0)>=(bp|0)){break a}Qo=o[ep>>2];Po=o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l(mp,Bp,jp,vp);ip=Po+mp|0;Po=T+np|0;Po=ip>>>0>>0?Po+1|0:Po;np=ip;ip=o[Qo>>2];mp=ip-En|0;En=o[Qo+4>>2]-((ip>>>0>>0)+qp|0)|0;Qo=Vl(mp,En,tp,rp);ip=np-Qo|0;np=Po-(T+(np>>>0>>0)|0)|0;Po=Vl(up,gp,jp,vp);Qo=lp-Po|0;op=op-(T+(lp>>>0>>0)|0)|0;Po=Vl(mp,En,Ap,sp);lp=Po+Qo|0;En=T+op|0;En=lp>>>0>>0?En+1|0:En;op=En;jf(Ro+80|0);jp=o[wp>>2];gp=!jp;En=o[Ro+88>>2];if((En|0)!=-1){continue}break}En=np;Po=En>>31;Ye=En>>31;En=Ye+En|0;fp=Po+ip|0;if(fp>>>0>>0){En=En+1|0}Po=Po^fp;gp=Ye^En;En=op;Ye=En>>31;En=En>>31;fp=Ye;pp=op+Ye|0;Qo=En+lp|0;if(Qo>>>0>>0){pp=pp+1|0}Ye=En^Qo;Qo=fp^pp;f:{if((kp|0)<-1?1:(kp|0)<=-1?hp>>>0>4294967295?0:1:0){En=hp;fp=Ye+(Po-En|0)|0;En=Qo+(gp-((Po>>>0>>0)+kp|0)|0)|0;Po=fp;Ye=Po>>>0>>0?En+1|0:En;if(!jp){break f}break b}En=gp+kp|0;fp=Po;Po=hp;fp=fp+Po|0;if(fp>>>0>>0){En=En+1|0}Po=Ye;fp=Po+fp|0;Ye=En+Qo|0;Ye=fp>>>0>>0?Ye+1|0:Ye;Po=fp;if(jp){break b}}if((Po|0)<536870913){break a}Ye=((Ye&536870911)<<3|Po>>>29)&7;En=0;hp=Wl(hp,kp,Ye,En);ip=Wl(ip,np,Ye,En);lp=Wl(lp,op,Ye,En);break a}Zk();D()}Zk();D()}Zk();D()}if((Ye|0)<0?1:(Ye|0)<=0?Po>>>0>=536870913?0:1:0){break a}En=Ye>>>29;Ye=(Ye&536870911)<<3|Po>>>29;hp=Wl(hp,kp,Ye,En);ip=Wl(ip,np,Ye,En);lp=Wl(lp,op,Ye,En)}o[Oo+8>>2]=hp;o[Oo+4>>2]=ip;o[Oo>>2]=lp;R=Ro+96|0}function jf(Ye){var En=0,Oo=0,Cp=0;En=o[Ye+8>>2];Cp=o[Ye>>2];a:{if(p[Ye+12|0]){b:{c:{d:{e:{if((En|0)==-1){break e}Oo=En+1|0;En=(Oo>>>0)%3|0?Oo:En+ -2|0;if((En|0)==-1){break e}En=o[o[Cp+12>>2]+(En<<2)>>2];if((En|0)!=-1){break d}}o[Ye+8>>2]=-1;break c}Oo=En+1|0;En=(Oo>>>0)%3|0?Oo:En+ -2|0;o[Ye+8>>2]=En;if((En|0)!=-1){break b}}Oo=o[Ye+4>>2];En=-1;f:{if((Oo|0)==-1){break f}Oo=Oo+((Oo>>>0)%3|0?-1:2)|0;En=-1;if((Oo|0)==-1){break f}Oo=o[o[Cp+12>>2]+(Oo<<2)>>2];En=-1;if((Oo|0)==-1){break f}En=Oo+ -1|0;if((Oo>>>0)%3){break f}En=Oo+2|0}m[Ye+12|0]=0;o[Ye+8>>2]=En;return}if((En|0)!=o[Ye+4>>2]){break a}o[Ye+8>>2]=-1;return}Oo=-1;g:{if((En|0)==-1){break g}En=En+((En>>>0)%3|0?-1:2)|0;Oo=-1;if((En|0)==-1){break g}En=o[o[Cp+12>>2]+(En<<2)>>2];Oo=-1;if((En|0)==-1){break g}Oo=En+ -1|0;if((En>>>0)%3){break g}Oo=En+2|0}o[Ye+8>>2]=Oo}}function kf(Ye,Dp,Ep,Fp,Gp,Hp){Ye=Ye|0;Dp=Dp|0;Ep=Ep|0;Fp=Fp|0;Gp=Gp|0;Hp=Hp|0;var Ip=0,Jp=0,Kp=0,Lp=0,Mp=0,Np=0,Op=0,Pp=0,Qp=0,Rp=0,Sp=0,Tp=0,Up=0,Vp=0;o[Ye+8>>2]=Gp;Jp=Ye+32|0;Ip=o[Jp>>2];Hp=o[Ye+36>>2]-Ip>>2;a:{if(Hp>>>0>>0){Da(Jp,Gp-Hp|0);break a}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hr+8>>2];kr=gr>>31;mr=o[hr+16>>2];jr=mr>>31;er=0;jr=jr^jr+mr;ir=jr+((ir^fr+ir)+(kr^gr+kr)|0)|0;if(ir>>>0>>0){er=1}b:{if(!(er|ir)){o[hr+8>>2]=o[Ye+84>>2];break b}kr=o[Ye+84>>2];jr=kr;jr=jr>>31;fr=Wl(Vl(kr,jr,fr,fr>>31),T,ir,er);o[hr+12>>2]=fr;er=Wl(Vl(kr,jr,gr,gr>>31),T,ir,er);o[hr+8>>2]=er;gr=er;er=er>>31;er=(kr-(gr+er^er)|0)+((fr|0)<0?fr:0-fr|0)|0;if((mr|0)>=0){o[hr+16>>2]=er;break b}o[hr+16>>2]=0-er}er=Pf(qr);gr=o[hr+8>>2];c:{if(!er){fr=o[hr+12>>2];break c}o[hr+16>>2]=0-o[hr+16>>2];fr=0-o[hr+12>>2]|0;o[hr+12>>2]=fr;gr=0-gr|0;o[hr+8>>2]=gr}d:{if((gr|0)>=0){gr=o[Ye+84>>2];er=gr+o[hr+16>>2]|0;gr=fr+gr|0;break d}e:{if((fr|0)<=-1){er=o[hr+16>>2];gr=er>>31;gr=gr^er+gr;break e}er=o[hr+16>>2];gr=er>>31;gr=o[Ye+80>>2]-(gr^er+gr)|0}if((er|0)<=-1){er=fr>>31;er=er+fr^er;break d}er=fr>>31;er=o[Ye+80>>2]-(er+fr^er)|0}fr=o[Ye+80>>2];f:{if(!(er|gr)){er=fr;gr=er;break f}if(!((er|0)!=(fr|0)|gr)){gr=er;break f}if(!((fr|0)!=(gr|0)|er)){er=gr;break f}g:{if(gr){break g}ir=o[Ye+84>>2];if((ir|0)>=(er|0)){break g}er=(ir<<1)-er|0;gr=0;break f}h:{if((fr|0)!=(gr|0)){break h}ir=o[Ye+84>>2];if((ir|0)<=(er|0)){break h}er=(ir<<1)-er|0;break f}i:{if((er|0)!=(fr|0)){break i}fr=o[Ye+84>>2];if((fr|0)<=(gr|0)){break i}gr=(fr<<1)-gr|0;break f}if(er){break f}er=0;fr=o[Ye+84>>2];if((fr|0)>=(gr|0)){break f}gr=(fr<<1)-gr|0}fr=lr<<3;ir=fr+eq|0;kr=o[ir+4>>2];ir=o[ir>>2];o[hr+36>>2]=er;o[hr+32>>2]=gr;o[hr+24>>2]=ir;o[hr+28>>2]=kr;zf(hr+40|0,nr,hr+32|0,hr+24|0);er=dr+fr|0;o[er>>2]=o[hr+40>>2];o[er+4>>2]=o[hr+44>>2];lr=lr+1|0;if((lr|0)>=(or|0)){break a}fr=o[rr>>2];er=o[fr>>2];if(o[fr+4>>2]-er>>2>>>0>lr>>>0){continue}break}}Zk();D()}R=hr+48|0;return 1}function Ef(Ye,eq,dr,er,fr,gr){Ye=Ye|0;eq=eq|0;dr=dr|0;er=er|0;fr=fr|0;gr=gr|0;var sr=0,tr=0,ur=0,vr=0,wr=0,xr=0,yr=0,zr=0;gr=R-32|0;R=gr;tr=(fr&1073741823)!=(fr|0)?-1:fr<<2;tr=xl(Hk(tr),0,tr);sr=o[eq>>2];ur=o[eq+4>>2];wr=o[tr+4>>2];o[gr+16>>2]=o[tr>>2];o[gr+20>>2]=wr;o[gr+8>>2]=sr;o[gr+12>>2]=ur;ur=Ye+8|0;zf(gr+24|0,ur,gr+16|0,gr+8|0);o[dr>>2]=o[gr+24>>2];o[dr+4>>2]=o[gr+28>>2];if((fr|0)<(er|0)){wr=0-fr<<2;Ye=fr;while(1){sr=Ye<<2;vr=sr+eq|0;yr=o[vr>>2];vr=o[vr+4>>2];sr=dr+sr|0;xr=sr+wr|0;zr=o[xr+4>>2];o[gr+16>>2]=o[xr>>2];o[gr+20>>2]=zr;o[gr+8>>2]=yr;o[gr+12>>2]=vr;zf(gr+24|0,ur,gr+16|0,gr+8|0);o[sr>>2]=o[gr+24>>2];o[sr+4>>2]=o[gr+28>>2];Ye=Ye+fr|0;if((Ye|0)<(er|0)){continue}break}}ul(tr);R=gr+32|0;return 1}function Ff(Ye,eq,dr){Ye=Ye|0;eq=eq|0;dr=dr|0;if(ae(Ye,eq,dr)){Ye=o[o[o[o[eq+4>>2]+8>>2]+(dr<<2)>>2]+28>>2]==9}else{Ye=0}return Ye|0}function Gf(Ye,eq,dr){Ye=Ye|0;eq=eq|0;dr=dr|0;eq=R-32|0;R=eq;a:{if(p[o[Ye+4>>2]+36|0]>=2){dr=0;if(!l[o[o[Ye>>2]+52>>2]](Ye)){break a}}o[eq+24>>2]=0;o[eq+28>>2]=0;o[eq+16>>2]=0;o[eq+20>>2]=0;o[eq+12>>2]=-1;o[eq+8>>2]=1232;ed(eq+8|0,o[Ye+24>>2],o[Ye+28>>2],m[o[Ye+8>>2]+24|0],s[Ye+32>>2]);dr=jd(eq+8|0,o[Ye+16>>2]);o[eq+8>>2]=1232;Ye=o[eq+16>>2];if(!Ye){break a}o[eq+20>>2]=Ye;ul(Ye)}R=eq+32|0;return dr|0}function Hf(Ye,eq){Ye=Ye|0;eq=eq|0;return l[o[o[Ye>>2]+56>>2]](Ye,eq)|0}function If(Ye){Ye=Ye|0;var eq=0,dr=0,er=0,fr=0,gr=0,Ar=0,Br=0,Cr=0,Dr=0,Er=0;eq=m[o[Ye+8>>2]+24|0];er=eq<<2;eq=Hk((eq|0)!=(eq&1073741823)?-1:er);dr=o[Ye+28>>2];o[Ye+28>>2]=eq;if(dr){ul(dr)}Cr=Ye+4|0;dr=o[o[Cr>>2]+32>>2];eq=o[dr+8>>2];Dr=o[dr+12>>2];Ar=eq;gr=o[dr+20>>2];Br=o[dr+16>>2];eq=er;fr=Br+eq|0;if(fr>>>0>>0){gr=gr+1|0}a:{if((Dr|0)<(gr|0)?1:(Dr|0)<=(gr|0)?Ar>>>0>=fr>>>0?0:1:0){break a}wl(o[Ye+28>>2],Br+o[dr>>2]|0,er);er=dr;Ar=dr;fr=o[dr+20>>2];dr=eq+o[dr+16>>2]|0;if(dr>>>0>>0){fr=fr+1|0}o[Ar+16>>2]=dr;o[er+20>>2]=fr;fr=o[Cr>>2];er=o[fr+32>>2];eq=o[er+8>>2];gr=o[er+12>>2];Ar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0?0:1:0){break a}m[Ye+12|0]=p[as+o[Yr>>2]|0];_r=o[Yr+20>>2];Zr=o[Yr+16>>2]+1|0;if(Zr>>>0<1){_r=_r+1|0}o[Yr+16>>2]=Zr;o[Yr+20>>2]=_r;if(!Of(1,bs+12|0,Yr)){break a}_r=o[Yr+8>>2];cs=o[Yr+16>>2];Zr=cs;$r=o[bs+12>>2];as=$r;ds=_r-Zr>>>0>=$r>>>0?0:1;Zr=_r>>>0>>0;_r=o[Yr+20>>2];Zr=o[Yr+12>>2]-(Zr+_r|0)|0;if(((Zr|0)<0?1:(Zr|0)<=0?ds:0)|($r|0)<1){break a}Zr=cs+o[Yr>>2]|0;o[Ye>>2]=Zr;es=$r+ -1|0;fs=es+Zr|0;gs=p[fs|0]>>>6;if((gs|0)==3){break a}ds=Ye;b:{c:{switch(gs-1|0){default:o[Ye+4>>2]=es;Ye=p[fs|0]&63;break b;case 0:if(($r|0)<2){break a}o[Ye+4>>2]=$r+ -2;Ye=(Zr+$r|0)+ -2|0;Ye=p[Ye+1|0]<<8&16128|p[Ye|0];break b;case 1:break c}}if(($r|0)<3){break a}o[Ye+4>>2]=$r+ -3;Ye=(Zr+$r|0)+ -3|0;Ye=p[Ye+1|0]<<8|p[Ye+2|0]<<16&4128768|p[Ye|0]}Ye=Ye+4096|0;o[ds+8>>2]=Ye;if(Ye>>>0>1048575){break a}Ye=_r;_r=as+cs|0;if(_r>>>0>>0){Ye=Ye+1|0}o[Yr+16>>2]=_r;o[Yr+20>>2]=Ye;hs=1}R=bs+16|0;return hs}function Of(Ye,Yr,is){var js=0,ks=0,ls=0,ms=0;a:{if(Ye>>>0>5){break a}ls=o[is+16>>2];js=o[is+12>>2];ks=o[is+20>>2];if((js|0)<(ks|0)?1:(js|0)<=(ks|0)?r[is+8>>2]>ls>>>0?0:1:0){break a}js=p[ls+o[is>>2]|0];ls=ls+1|0;if(ls>>>0<1){ks=ks+1|0}o[is+16>>2]=ls;o[is+20>>2]=ks;ks=Yr;if(js&128){if(!Of(Ye+1|0,Yr,is)){break a}Ye=o[Yr>>2]<<7;o[Yr>>2]=Ye;js=Ye|js&127}o[ks>>2]=js;ms=1}return ms}function Pf(Ye){var Yr=0,is=0,ns=0,os=0,ps=0;ns=0-p[Ye+12|0]|0;is=o[Ye+8>>2];a:{if(is>>>0>4095){break a}Yr=o[Ye+4>>2];if((Yr|0)<1){break a}Yr=Yr+ -1|0;o[Ye+4>>2]=Yr;is=p[Yr+o[Ye>>2]|0]|is<<8;o[Ye+8>>2]=is}ns=ns&255;Yr=u(ns,is>>>8);os=is&255;ps=os>>>0>>0;o[Ye+8>>2]=ps?Yr+os|0:(is-ns|0)-Yr|0;return ps}function Qf(Ye,qs){var rs=0,ss=0,ts=0;ts=R-32|0;R=ts;a:{if(qs>>>0<=1){if(qs-1){qs=Hk(48);ug(qs);o[qs>>2]=9816;o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;break a}qs=Hk(52);ug(qs);o[qs+48>>2]=0;o[qs>>2]=8064;o[Ye+8>>2]=0;o[Ye+12>>2]=0;o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;break a}qs=Hk(32);o[ts>>2]=qs;o[ts+4>>2]=28;o[ts+8>>2]=-2147483616;m[qs+28|0]=0;rs=p[7812]|p[7813]<<8|(p[7814]<<16|p[7815]<<24);m[qs+24|0]=rs;m[qs+25|0]=rs>>>8;m[qs+26|0]=rs>>>16;m[qs+27|0]=rs>>>24;rs=p[7808]|p[7809]<<8|(p[7810]<<16|p[7811]<<24);ss=p[7804]|p[7805]<<8|(p[7806]<<16|p[7807]<<24);m[qs+16|0]=ss;m[qs+17|0]=ss>>>8;m[qs+18|0]=ss>>>16;m[qs+19|0]=ss>>>24;m[qs+20|0]=rs;m[qs+21|0]=rs>>>8;m[qs+22|0]=rs>>>16;m[qs+23|0]=rs>>>24;rs=p[7800]|p[7801]<<8|(p[7802]<<16|p[7803]<<24);ss=p[7796]|p[7797]<<8|(p[7798]<<16|p[7799]<<24);m[qs+8|0]=ss;m[qs+9|0]=ss>>>8;m[qs+10|0]=ss>>>16;m[qs+11|0]=ss>>>24;m[qs+12|0]=rs;m[qs+13|0]=rs>>>8;m[qs+14|0]=rs>>>16;m[qs+15|0]=rs>>>24;rs=p[7792]|p[7793]<<8|(p[7794]<<16|p[7795]<<24);ss=p[7788]|p[7789]<<8|(p[7790]<<16|p[7791]<<24);m[qs|0]=ss;m[qs+1|0]=ss>>>8;m[qs+2|0]=ss>>>16;m[qs+3|0]=ss>>>24;m[qs+4|0]=rs;m[qs+5|0]=rs>>>8;m[qs+6|0]=rs>>>16;m[qs+7|0]=rs>>>24;o[ts+16>>2]=-1;qs=Mk(ts+16|4,ts);o[Ye>>2]=o[ts+16>>2];Mk(Ye+4|0,qs);o[Ye+16>>2]=0;if(m[qs+11|0]<=-1){ul(o[qs>>2])}if(m[ts+11|0]>-1){break a}ul(o[ts>>2])}R=ts+32|0}function Rf(Ye,qs){var us=0,vs=0,ws=0;us=R-80|0;R=us;vs=o[qs+36>>2];o[us+72>>2]=o[qs+32>>2];o[us+76>>2]=vs;ws=o[qs+28>>2];vs=us- -64|0;o[vs>>2]=o[qs+24>>2];o[vs+4>>2]=ws;vs=o[qs+20>>2];o[us+56>>2]=o[qs+16>>2];o[us+60>>2]=vs;vs=o[qs+12>>2];o[us+48>>2]=o[qs+8>>2];o[us+52>>2]=vs;vs=o[qs+4>>2];o[us+40>>2]=o[qs>>2];o[us+44>>2]=vs;ci(us+8|0,us+40|0,us+24|0);qs=o[us+8>>2];a:{if(qs){o[Ye>>2]=qs;Mk(Ye+4|0,us+8|4);if(m[us+23|0]>=0){break a}ul(o[us+12>>2]);break a}if(m[us+23|0]<=-1){ul(o[us+12>>2])}qs=p[us+31|0];o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+16>>2]=qs;o[Ye+8>>2]=0;o[Ye+12>>2]=0}R=us+80|0}function Sf(Ye,qs,xs,ys){var zs=0,As=0,Bs=0;zs=R-80|0;R=zs;As=o[xs+36>>2];o[zs+72>>2]=o[xs+32>>2];o[zs+76>>2]=As;Bs=o[xs+28>>2];As=zs- -64|0;o[As>>2]=o[xs+24>>2];o[As+4>>2]=Bs;As=o[xs+20>>2];o[zs+56>>2]=o[xs+16>>2];o[zs+60>>2]=As;As=o[xs+12>>2];o[zs+48>>2]=o[xs+8>>2];o[zs+52>>2]=As;As=o[xs+4>>2];o[zs+40>>2]=o[xs>>2];o[zs+44>>2]=As;ci(Ye,zs+40|0,zs+24|0);a:{if(o[Ye>>2]){break a}As=Ye+4|0;if(m[Ye+15|0]<=-1){ul(o[As>>2])}if(p[zs+31|0]!=1){o[zs+8>>2]=0;o[zs>>2]=0;o[zs+4>>2]=0;qs=Hk(32);o[zs>>2]=qs;o[zs+4>>2]=20;o[zs+8>>2]=-2147483616;m[qs+20|0]=0;xs=p[7860]|p[7861]<<8|(p[7862]<<16|p[7863]<<24);m[qs+16|0]=xs;m[qs+17|0]=xs>>>8;m[qs+18|0]=xs>>>16;m[qs+19|0]=xs>>>24;xs=p[7856]|p[7857]<<8|(p[7858]<<16|p[7859]<<24);ys=p[7852]|p[7853]<<8|(p[7854]<<16|p[7855]<<24);m[qs+8|0]=ys;m[qs+9|0]=ys>>>8;m[qs+10|0]=ys>>>16;m[qs+11|0]=ys>>>24;m[qs+12|0]=xs;m[qs+13|0]=xs>>>8;m[qs+14|0]=xs>>>16;m[qs+15|0]=xs>>>24;xs=p[7848]|p[7849]<<8|(p[7850]<<16|p[7851]<<24);ys=p[7844]|p[7845]<<8|(p[7846]<<16|p[7847]<<24);m[qs|0]=ys;m[qs+1|0]=ys>>>8;m[qs+2|0]=ys>>>16;m[qs+3|0]=ys>>>24;m[qs+4|0]=xs;m[qs+5|0]=xs>>>8;m[qs+6|0]=xs>>>16;m[qs+7|0]=xs>>>24;o[Ye>>2]=-1;Mk(As,zs);if(m[zs+11|0]>-1){break a}ul(o[zs>>2]);break a}Qf(zs,p[zs+32|0]);Bs=o[zs>>2];b:{if(Bs){o[Ye>>2]=Bs;Mk(As,zs|4);break b}Bs=o[zs+16>>2];o[zs+16>>2]=0;o[Bs+44>>2]=ys;fi(Ye,Bs,qs,xs,ys);if(!o[Ye>>2]){if(m[As+11|0]<=-1){ul(o[As>>2])}o[Ye>>2]=0;o[Ye+4>>2]=0;o[Ye+8>>2]=0;o[Ye+12>>2]=0}if(!Bs){break b}l[o[o[Bs>>2]+4>>2]](Bs)}Ye=o[zs+16>>2];o[zs+16>>2]=0;if(Ye){l[o[o[Ye>>2]+4>>2]](Ye)}if(m[zs+15|0]>-1){break a}ul(o[zs+4>>2])}R=zs+80|0}function Tf(Ye){var qs=0,xs=0,ys=0,Cs=0;Cs=R-16|0;R=Cs;qs=Hk(32);o[Cs>>2]=qs;o[Cs+4>>2]=26;o[Cs+8>>2]=-2147483616;m[qs+26|0]=0;xs=p[7841]|p[7842]<<8;m[qs+24|0]=xs;m[qs+25|0]=xs>>>8;ys=p[7837]|p[7838]<<8|(p[7839]<<16|p[7840]<<24);xs=p[7833]|p[7834]<<8|(p[7835]<<16|p[7836]<<24);m[qs+16|0]=xs;m[qs+17|0]=xs>>>8;m[qs+18|0]=xs>>>16;m[qs+19|0]=xs>>>24;m[qs+20|0]=ys;m[qs+21|0]=ys>>>8;m[qs+22|0]=ys>>>16;m[qs+23|0]=ys>>>24;ys=p[7829]|p[7830]<<8|(p[7831]<<16|p[7832]<<24);xs=p[7825]|p[7826]<<8|(p[7827]<<16|p[7828]<<24);m[qs+8|0]=xs;m[qs+9|0]=xs>>>8;m[qs+10|0]=xs>>>16;m[qs+11|0]=xs>>>24;m[qs+12|0]=ys;m[qs+13|0]=ys>>>8;m[qs+14|0]=ys>>>16;m[qs+15|0]=ys>>>24;ys=p[7821]|p[7822]<<8|(p[7823]<<16|p[7824]<<24);xs=p[7817]|p[7818]<<8|(p[7819]<<16|p[7820]<<24);m[qs|0]=xs;m[qs+1|0]=xs>>>8;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,Is=0,Js=0,Ks=0,Ls=0,Ms=0,Ns=0,Os=0;Js=R-32|0;R=Js;Ks=Ye+16|0;Is=o[Ks>>2];a:{b:{if(!Is){break b}Ms=o[Ds>>2];Hs=Ks;while(1){Ls=o[Is+16>>2]<(Ms|0);Hs=Ls?Hs:Is;Is=o[(Ls<<2)+Is>>2];if(Is){continue}break}if((Hs|0)==(Ks|0)){break b}if((Ms|0)>=o[Hs+16>>2]){break a}}Ms=ui(Js+16|0);Ds=o[Ds>>2];Ls=Js+8|0;o[Ls>>2]=0;o[Ls+4>>2]=0;o[Js>>2]=Ds;o[Js+4>>2]=Ls;Hs=o[Ms>>2];Ns=Ms+4|0;if((Hs|0)!=(Ns|0)){Os=Js|4;while(1){Ds=Hs;Is=Hs+16|0;Wf(Os,Ls,Is,Is);Is=o[Hs+4>>2];c:{if(!Is){Hs=o[Ds+8>>2];if((Ds|0)==o[Hs>>2]){break c}Ds=Ds+8|0;while(1){Is=o[Ds>>2];Ds=Is+8|0;Hs=o[Is+8>>2];if((Is|0)!=o[Hs>>2]){continue}break}break c}while(1){Hs=Is;Is=o[Hs>>2];if(Is){continue}break}}if((Hs|0)!=(Ns|0)){continue}break}}Ds=Ye+16|0;Is=o[Ds>>2];d:{if(Is){Ks=o[Js>>2];while(1){Hs=o[Is+16>>2];e:{if((Ks|0)<(Hs|0)){Hs=o[Is>>2];if(Hs){break e}Ds=Is;break d}if((Hs|0)>=(Ks|0)){break d}Ds=Is+4|0;Hs=o[Is+4>>2];if(!Hs){break d}Is=Ds}Ds=Is;Is=Hs;continue}}Is=Ks;Ds=Is}Hs=o[Ds>>2];if(!Hs){Hs=Hk(32);o[Hs+16>>2]=o[Js>>2];o[Hs+20>>2]=o[Js+4>>2];Ks=Hs+24|0;Ns=o[Js+8>>2];o[Ks>>2]=Ns;Os=o[Js+12>>2];o[Hs+28>>2]=Os;f:{if(!Os){o[Hs+20>>2]=Ks;break f}o[Ns+8>>2]=Ks;o[Js+8>>2]=0;o[Js+12>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t=at>>>0>>0;g:{Ys=bt?at:Zs;if(Ys){$s=$s?o[Vs>>2]:Vs;Xs=Xs?o[Ws>>2]:Ws;et=Zj($s,Xs,Ys);if(et){break g}}if(Zs>>>0>>0){break f}if(!Ys){break d}$s=(_s|0)<0?o[Vs>>2]:Vs;Xs=(dt|0)<0?o[Ws>>2]:Ws;break e}if((et|0)>-1){break e}}Ys=o[Ds>>2];h:{i:{if(o[Ye>>2]==(Ds|0)){Ws=Ds;break i}j:{if(!Ys){Us=Ds;while(1){Ws=o[Us+8>>2];Zs=o[Ws>>2]==(Us|0);Us=Ws;if(Zs){continue}break}break j}Us=Ys;while(1){Ws=Us;Us=o[Ws+4>>2];if(Us){continue}break}}Xs=p[Vs+11|0];Us=Xs<<24>>24<0;_s=p[Ws+27|0];Zs=_s<<24>>24<0;k:{Xs=Us?o[Vs+4>>2]:Xs;_s=Zs?o[Ws+20>>2]:_s;$s=Xs>>>0<_s>>>0?Xs:_s;if($s){at=Ws+16|0;Us=Zj(Zs?o[at>>2]:at,Us?o[Vs>>2]:Vs,$s);if(Us){break k}}if(_s>>>0>>0){break i}break h}if((Us|0)>-1){break h}}if(!Ys){o[Ts>>2]=Ds;return Ds}o[Ts>>2]=Ws;return Ws+4|0}return Zf(Ye,Ts,Vs)}Ws=Zj(Xs,$s,Ys);if(Ws){break c}}if(bt){break b}break a}if((Ws|0)>-1){break a}}$s=Ds+4|0;Ys=o[$s>>2];l:{if(Ys){Ws=Ys;while(1){Us=Ws;Ws=o[Ws>>2];if(Ws){continue}break}break l}Us=o[Ds+8>>2];if(o[Us>>2]==(Ds|0)){break l}Ws=Ds+8|0;while(1){Xs=o[Ws>>2];Ws=Xs+8|0;Us=o[Xs+8>>2];if((Xs|0)!=o[Us>>2]){continue}break}}m:{n:{if((Us|0)==(ct|0)){break n}Xs=p[Us+27|0];Ws=Xs<<24>>24<0;o:{Xs=Ws?o[Us+20>>2]:Xs;at=Xs>>>0>>0?Xs:Zs;if(at){bt=(_s|0)<0?o[Vs>>2]:Vs;_s=Us+16|0;Ws=Zj(bt,Ws?o[_s>>2]:_s,at);if(Ws){break o}}if(Zs>>>0>>0){break n}break m}if((Ws|0)>-1){break m}}if(!Ys){o[Ts>>2]=Ds;return $s}o[Ts>>2]=Us;return Us}return Zf(Ye,Ts,Vs)}o[Ts>>2]=Ds;o[Us>>2]=Ds;return Us}function Zf(Ye,Ds,Ts){var Us=0,Vs=0,ft=0,gt=0,ht=0,it=0,jt=0,kt=0,lt=0;a:{Us=Ye+4|0;Ye=o[Us>>2];if(Ye){ft=p[Ts+11|0];gt=ft<<24>>24<0;ft=gt?o[Ts+4>>2]:ft;jt=gt?o[Ts>>2]:Ts;while(1){Ts=Ye+16|0;Vs=p[Ye+27|0];gt=Vs<<24>>24<0;ht=gt?o[Ye+20>>2]:Vs;kt=ht>>>0>>0;b:{c:{d:{e:{f:{g:{h:{Vs=kt?ht:ft;if(Vs){it=gt?o[Ts>>2]:Ts;lt=Zj(jt,it,Vs);if(lt){break h}}if(ft>>>0>>0){break g}if(!Vs){break e}it=gt?o[Ts>>2]:Ts;break f}if((lt|0)>-1){break f}}Ts=o[Ye>>2];if(Ts){break b}o[Ds>>2]=Ye;return Ye}Ts=Zj(it,jt,Vs);if(Ts){break d}}if(kt){break c}break a}if((Ts|0)>-1){break a}}Us=Ye+4|0;Ts=o[Ye+4>>2];if(!Ts){break a}Ye=Us}Us=Ye;Ye=Ts;continue}}o[Ds>>2]=Us;return Us}o[Ds>>2]=Ye;return Us}function _f(Ye,Ds,Ts,mt){var nt=0,ot=0,pt=0,qt=0,rt=0;if(!Ye){return 1}nt=o[Ts+16>>2];qt=o[Ts+12>>2];pt=o[Ts+20>>2];ot=pt;a:{if((qt|0)<(ot|0)?1:(qt|0)<=(ot|0)?r[Ts+8>>2]>nt>>>0?0:1:0){break a}ot=p[nt+o[Ts>>2]|0];nt=nt+1|0;if(nt>>>0<1){pt=pt+1|0}o[Ts+16>>2]=nt;o[Ts+20>>2]=pt;if(ot>>>0>1){break a}if(ot-1){return $f(Ye,Ds,Ts,mt)}rt=ag(Ye,Ts,mt)}return rt}function $f(Ye,Ds,Ts,mt){var st=0,tt=0,ut=0,vt=0,wt=0,xt=0,yt=0,zt=0,At=0,Bt=0,Ct=0,Dt=0,Et=0,Ft=0,Gt=0,Ht=0;st=R+ -64|0;R=st;o[st+56>>2]=0;o[st+48>>2]=0;o[st+52>>2]=0;o[st+40>>2]=0;o[st+44>>2]=0;o[st+32>>2]=0;o[st+36>>2]=0;o[st+24>>2]=0;o[st+28>>2]=0;o[st+16>>2]=0;o[st+20>>2]=0;o[st+8>>2]=0;o[st+12>>2]=0;a:{if(!bg(st+8|0,Ts)){break a}if(!cg(st+8|0,Ts)|(o[st+20>>2]?0:Ye)){break a}qi(Ts,0,0);if(Ye){vt=o[st+56>>2];Dt=o[st+36>>2];Et=o[st+48>>2];Ft=o[st+24>>2];while(1){b:{if(vt>>>0>16383){break b}tt=o[st+52>>2];while(1){if((tt|0)<1){break b}tt=tt+ -1|0;o[st+52>>2]=tt;vt=p[tt+Et|0]|vt<<8;o[st+56>>2]=vt;if(vt>>>0<16384){continue}break}}ut=vt&4095;Bt=o[(ut<<2)+Ft>>2];wt=(Bt<<3)+Dt|0;vt=(u(o[wt>>2],vt>>>12)+ut|0)-o[wt+4>>2]|0;o[st+56>>2]=vt;if((Ds|0)>=1){if(!p[Ts+36|0]){ut=0;break a}wt=Ds+xt|0;while(1){c:{if((Bt|0)<1){zt=0;break c}ut=o[Ts+32>>2];Gt=o[Ts+28>>2];Ht=o[Ts+24>>2];tt=0;zt=0;while(1){yt=(ut>>>3)+Ht|0;d:{if(yt>>>0>=Gt>>>0){At=0;break d}At=p[yt|0];yt=ut+1|0;o[Ts+32>>2]=yt;At=At>>>(ut&7)&1;ut=yt}zt=At<>2]=zt;xt=xt+1|0;if((wt|0)!=(xt|0)){continue}break}xt=wt}Ct=Ds+Ct|0;if(Ct>>>0>>0){continue}break}}si(Ts);ut=1}Ye=o[st+36>>2];if(Ye){o[st+40>>2]=Ye;ul(Ye)}Ye=o[st+24>>2];if(Ye){o[st+28>>2]=Ye;ul(Ye)}Ye=o[st+8>>2];if(Ye){o[st+12>>2]=Ye;ul(Ye)}R=st- -64|0;return ut}function ag(Ye,Ds,Ts){var mt=0,It=0,Jt=0,Kt=0;a:{b:{It=o[Ds+16>>2];Jt=o[Ds+12>>2];mt=o[Ds+20>>2];c:{if((Jt|0)<(mt|0)?1:(Jt|0)<=(mt|0)?r[Ds+8>>2]>It>>>0?0:1:0){break c}Jt=p[It+o[Ds>>2]|0];It=It+1|0;if(It>>>0<1){mt=mt+1|0}o[Ds+16>>2]=It;o[Ds+20>>2]=mt;mt=Jt+ -1|0;if(mt>>>0>17){break c}d:{e:{f:{g:{h:{i:{j:{switch(mt-1|0){case 12:case 13:case 14:case 15:break a;case 8:break h;case 7:break i;case 3:break j;case 16:break d;case 11:break e;case 10:break f;case 9:break g;default:break b}}return eg(Ye,Ds,Ts)}return fg(Ye,Ds,Ts)}return gg(Ye,Ds,Ts)}return hg(Ye,Ds,Ts)}return ig(Ye,Ds,Ts)}return jg(Ye,Ds,Ts)}Kt=kg(Ye,Ds,Ts)}return Kt}return dg(Ye,Ds,Ts)}return kg(Ye,Ds,Ts)}function bg(Ye,Ds){var Ts=0,Lt=0,Mt=0,Nt=0,Ot=0,Pt=0,Qt=0,Rt=0,St=0,Tt=0,Ut=0,Vt=0,Wt=0;a:{if(!q[Ds+38>>1]){break a}Tt=Ye+12|0;if(!lg(1,Tt,Ds)){break a}Nt=o[Ye+12>>2];Ts=o[Ye>>2];Lt=o[Ye+4>>2]-Ts>>2;b:{if(Nt>>>0>Lt>>>0){Da(Ye,Nt-Lt|0);Nt=o[Ye+12>>2];break b}if(Nt>>>0>=Lt>>>0){break b}o[Ye+4>>2]=Ts+(Nt<<2)}if(!Nt){Wt=1;break a}Ut=o[Ds+8>>2];Qt=o[Ds+12>>2];while(1){Mt=o[Ds+16>>2];Lt=o[Ds+20>>2];Ts=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pt>>2]=Ot;Ye=o[Ye>>2]+Ts|0;if(Ye>>>0>4096){break a}if(Ts>>>0>>0){Ot=o[Lt>>2];while(1){o[Ot+(Ts<<2)>>2]=Mt;Ts=Ts+1|0;if((Ye|0)!=(Ts|0)){continue}break}}Ts=Ye;Mt=Mt+1|0;if((Nt|0)!=(Mt|0)){continue}break}return(Ye|0)==4096}return Wt}function cg(Ye,Ds){var Xt=0,Yt=0,Zt=0,_t=0,$t=0,au=0,bu=0,cu=0;$t=R-16|0;R=$t;a:{if(!ng(1,$t+8|0,Ds)){break a}Xt=o[Ds+8>>2];Yt=o[Ds+16>>2];au=Xt-Yt|0;Zt=o[$t+12>>2];bu=o[Ds+20>>2];_t=o[Ds+12>>2]-(bu+(Xt>>>0>>0)|0)|0;Xt=o[$t+8>>2];if((Zt|0)==(_t|0)&Xt>>>0>au>>>0|Zt>>>0>_t>>>0){break a}Zt=Zt+bu|0;_t=Xt+Yt|0;if(_t>>>0>>0){Zt=Zt+1|0}o[Ds+16>>2]=_t;o[Ds+20>>2]=Zt;if((Xt|0)<1){break a}Yt=Yt+o[Ds>>2]|0;o[Ye+40>>2]=Yt;Ds=Ye;b:{c:{d:{e:{f:{_t=Xt+ -1|0;au=Yt+_t|0;switch((p[au|0]>>>6)-1|0){case 2:break c;case 1:break d;case 0:break e;default:break f}}o[Ye+44>>2]=_t;Ye=p[au|0]&63;break b}if((Xt|0)<2){break a}o[Ye+44>>2]=Xt+ -2;Ye=(Xt+Yt|0)+ -2|0;Ye=p[Ye+1|0]<<8&16128|p[Ye|0];break b}if((Xt|0)<3){break a}o[Ye+44>>2]=Xt+ -3;Ye=(Xt+Yt|0)+ -3|0;Ye=p[Ye+1|0]<<8|p[Ye+2|0]<<16&4128768|p[Ye|0];break b}o[Ye+44>>2]=Xt+ -4;Ye=(Xt+Yt|0)+ -4|0;Ye=p[Ye+2|0]<<16|p[Ye+3|0]<<24&1056964608|p[Ye+1|0]<<8|p[Ye|0]}Ye=Ye+16384|0;o[Ds+48>>2]=Ye;cu=Ye>>>0<4194304}R=$t+16|0;return cu}function dg(Ye,Ds,du){var eu=0,fu=0,gu=0,hu=0,iu=0,ju=0,ku=0,lu=0,mu=0,nu=0;eu=R+ -64|0;R=eu;o[eu+48>>2]=0;o[eu+40>>2]=0;o[eu+44>>2]=0;o[eu+32>>2]=0;o[eu+36>>2]=0;o[eu+24>>2]=0;o[eu+28>>2]=0;o[eu+16>>2]=0;o[eu+20>>2]=0;o[eu+8>>2]=0;o[eu+12>>2]=0;o[eu>>2]=0;o[eu+4>>2]=0;a:{if(!bg(eu,Ds)|(o[eu+12>>2]?0:Ye)){break a}if(!ng(1,eu+56|0,Ds)){break a}gu=o[Ds+8>>2];mu=o[Ds+16>>2];hu=mu;ku=gu-hu|0;ju=o[eu+60>>2];fu=ju;lu=o[Ds+20>>2];hu=o[Ds+12>>2]-(lu+(gu>>>0>>0)|0)|0;gu=o[eu+56>>2];if((fu|0)==(hu|0)&gu>>>0>ku>>>0|fu>>>0>hu>>>0){break a}ju=ju+lu|0;hu=mu;lu=hu+gu|0;if(lu>>>0>>0){ju=ju+1|0}o[Ds+16>>2]=lu;o[Ds+20>>2]=ju;if((gu|0)<1){break a}ku=mu+o[Ds>>2]|0;o[eu+40>>2]=ku;hu=eu;b:{c:{d:{e:{f:{Ds=gu+ -1|0;fu=ku+Ds|0;switch((p[fu|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((gu|0)<2){break a}Ds=gu+ -2|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -2|0;fu=p[fu+1|0]<<8&16128|p[fu|0];break b}if((gu|0)<3){break a}Ds=gu+ -3|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -3|0;fu=p[fu+1|0]<<8|p[fu+2|0]<<16&4128768|p[fu|0];break b}Ds=gu+ -4|0;o[eu+44>>2]=Ds;fu=(gu+ku|0)+ -4|0;fu=p[fu+2|0]<<16|p[fu+3|0]<<24&1056964608|p[fu+1|0]<<8|p[fu|0];break b}o[eu+44>>2]=Ds;fu=p[fu|0]&63}iu=fu+16384|0;o[hu+48>>2]=iu;nu=iu>>>0<4194304;if(!Ye|iu>>>0>4194303){break a}lu=o[eu+28>>2];ju=0;mu=o[eu+16>>2];while(1){g:{if(iu>>>0>16383){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[eu+44>>2]=Ds;iu=p[Ds+ku|0]|iu<<8;o[eu+48>>2]=iu;if(iu>>>0<16384){continue}break}}gu=iu&4095;fu=o[(gu<<2)+mu>>2];hu=(fu<<3)+lu|0;iu=(u(o[hu>>2],iu>>>12)+gu|0)-o[hu+4>>2]|0;o[eu+48>>2]=iu;o[(ju<<2)+du>>2]=fu;nu=1;ju=ju+1|0;if((ju|0)!=(Ye|0)){continue}break}}Ye=o[eu+28>>2];if(Ye){o[eu+32>>2]=Ye;ul(Ye)}Ye=o[eu+16>>2];if(Ye){o[eu+20>>2]=Ye;ul(Ye)}Ye=o[eu>>2];if(Ye){o[eu+4>>2]=Ye;ul(Ye)}R=eu- -64|0;return nu}function eg(Ye,Ds,du){var ou=0,pu=0,qu=0,ru=0,su=0,tu=0,uu=0,vu=0;ou=R+ -64|0;R=ou;o[ou+56>>2]=0;o[ou+48>>2]=0;o[ou+52>>2]=0;o[ou+40>>2]=0;o[ou+44>>2]=0;o[ou+32>>2]=0;o[ou+36>>2]=0;o[ou+24>>2]=0;o[ou+28>>2]=0;o[ou+16>>2]=0;o[ou+20>>2]=0;o[ou+8>>2]=0;o[ou+12>>2]=0;a:{if(!bg(ou+8|0,Ds)|(o[ou+20>>2]?0:Ye)){break a}pu=cg(ou+8|0,Ds);if(!Ye|!pu){break a}Ds=o[ou+56>>2];tu=o[ou+36>>2];uu=o[ou+48>>2];vu=o[ou+24>>2];while(1){b:{if(Ds>>>0>16383){break b}pu=o[ou+52>>2];while(1){if((pu|0)<1){break b}pu=pu+ -1|0;o[ou+52>>2]=pu;Ds=p[pu+uu|0]|Ds<<8;o[ou+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2:break d;case 1:break e;case 0:break f;default:break c}}if((yu|0)<2){break a}Ds=yu+ -2|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -2|0;xu=p[xu+1|0]<<8&16128|p[xu|0];break b}if((yu|0)<3){break a}Ds=yu+ -3|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -3|0;xu=p[xu+1|0]<<8|p[xu+2|0]<<16&4128768|p[xu|0];break b}Ds=yu+ -4|0;o[wu+44>>2]=Ds;xu=(yu+Cu|0)+ -4|0;xu=p[xu+2|0]<<16|p[xu+3|0]<<24&1056964608|p[xu+1|0]<<8|p[xu|0];break b}o[wu+44>>2]=Ds;xu=p[xu|0]&63}Au=xu+32768|0;o[zu+48>>2]=Au;Fu=Au>>>0<8388608;if(!Ye|Au>>>0>8388607){break a}Du=o[wu+28>>2];Bu=0;Eu=o[wu+16>>2];while(1){g:{if(Au>>>0>32767){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[wu+44>>2]=Ds;Au=p[Ds+Cu|0]|Au<<8;o[wu+48>>2]=Au;if(Au>>>0<32768){continue}break}}yu=Au&8191;xu=o[(yu<<2)+Eu>>2];zu=(xu<<3)+Du|0;Au=(u(o[zu>>2],Au>>>13)+yu|0)-o[zu+4>>2]|0;o[wu+48>>2]=Au;o[(Bu<<2)+du>>2]=xu;Fu=1;Bu=Bu+1|0;if((Bu|0)!=(Ye|0)){continue}break}}Ye=o[wu+28>>2];if(Ye){o[wu+32>>2]=Ye;ul(Ye)}Ye=o[wu+16>>2];if(Ye){o[wu+20>>2]=Ye;ul(Ye)}Ye=o[wu>>2];if(Ye){o[wu+4>>2]=Ye;ul(Ye)}R=wu- -64|0;return Fu}function gg(Ye,Ds,du){var Gu=0,Hu=0,Iu=0,Ju=0,Ku=0,Lu=0,Mu=0,Nu=0,Ou=0,Pu=0;Gu=R+ -64|0;R=Gu;o[Gu+48>>2]=0;o[Gu+40>>2]=0;o[Gu+44>>2]=0;o[Gu+32>>2]=0;o[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|Ru>>>0>Tu>>>0){break a}Vu=Vu+Xu|0;Tu=Yu;Xu=Tu+Su|0;if(Xu>>>0>>0){Vu=Vu+1|0}o[Ds+16>>2]=Xu;o[Ds+20>>2]=Vu;if((Su|0)<1){break a}Wu=Yu+o[Ds>>2]|0;o[Qu+40>>2]=Wu;Tu=Qu;b:{c:{d:{e:{f:{Ds=Su+ -1|0;Ru=Wu+Ds|0;switch((p[Ru|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((Su|0)<2){break a}Ds=Su+ -2|0;o[Qu+44>>2]=Ds;Ru=(Su+Wu|0)+ -2|0;Ru=p[Ru+1|0]<<8&16128|p[Ru|0];break b}if((Su|0)<3){break a}Ds=Su+ -3|0;o[Qu+44>>2]=Ds;Ru=(Su+Wu|0)+ -3|0;Ru=p[Ru+1|0]<<8|p[Ru+2|0]<<16&4128768|p[Ru|0];break b}Ds=Su+ -4|0;o[Qu+44>>2]=Ds;Ru=(Su+Wu|0)+ -4|0;Ru=p[Ru+2|0]<<16|p[Ru+3|0]<<24&1056964608|p[Ru+1|0]<<8|p[Ru|0];break b}o[Qu+44>>2]=Ds;Ru=p[Ru|0]&63}Uu=Ru+262144|0;o[Tu+48>>2]=Uu;Zu=Uu>>>0<67108864;if(!Ye|Uu>>>0>67108863){break a}Xu=o[Qu+28>>2];Vu=0;Yu=o[Qu+16>>2];while(1){g:{if(Uu>>>0>262143){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[Qu+44>>2]=Ds;Uu=p[Ds+Wu|0]|Uu<<8;o[Qu+48>>2]=Uu;if(Uu>>>0<262144){continue}break}}Su=Uu&65535;Ru=o[(Su<<2)+Yu>>2];Tu=(Ru<<3)+Xu|0;Uu=(u(o[Tu>>2],Uu>>>16)+Su|0)-o[Tu+4>>2]|0;o[Qu+48>>2]=Uu;o[(Vu<<2)+du>>2]=Ru;Zu=1;Vu=Vu+1|0;if((Vu|0)!=(Ye|0)){continue}break}}Ye=o[Qu+28>>2];if(Ye){o[Qu+32>>2]=Ye;ul(Ye)}Ye=o[Qu+16>>2];if(Ye){o[Qu+20>>2]=Ye;ul(Ye)}Ye=o[Qu>>2];if(Ye){o[Qu+4>>2]=Ye;ul(Ye)}R=Qu- -64|0;return Zu}function ig(Ye,Ds,du){var _u=0,$u=0,av=0,bv=0,cv=0,dv=0,ev=0,fv=0,gv=0,hv=0;_u=R+ -64|0;R=_u;o[_u+48>>2]=0;o[_u+40>>2]=0;o[_u+44>>2]=0;o[_u+32>>2]=0;o[_u+36>>2]=0;o[_u+24>>2]=0;o[_u+28>>2]=0;o[_u+16>>2]=0;o[_u+20>>2]=0;o[_u+8>>2]=0;o[_u+12>>2]=0;o[_u>>2]=0;o[_u+4>>2]=0;a:{if(!rg(_u,Ds)|(o[_u+12>>2]?0:Ye)){break a}if(!ng(1,_u+56|0,Ds)){break a}av=o[Ds+8>>2];gv=o[Ds+16>>2];bv=gv;ev=av-bv|0;dv=o[_u+60>>2];$u=dv;fv=o[Ds+20>>2];bv=o[Ds+12>>2]-(fv+(av>>>0>>0)|0)|0;av=o[_u+56>>2];if(($u|0)==(bv|0)&av>>>0>ev>>>0|$u>>>0>bv>>>0){break a}dv=dv+fv|0;bv=gv;fv=bv+av|0;if(fv>>>0>>0){dv=dv+1|0}o[Ds+16>>2]=fv;o[Ds+20>>2]=dv;if((av|0)<1){break a}ev=gv+o[Ds>>2]|0;o[_u+40>>2]=ev;bv=_u;b:{c:{d:{e:{f:{Ds=av+ -1|0;$u=ev+Ds|0;switch((p[$u|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((av|0)<2){break a}Ds=av+ -2|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -2|0;$u=p[$u+1|0]<<8&16128|p[$u|0];break b}if((av|0)<3){break a}Ds=av+ -3|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -3|0;$u=p[$u+1|0]<<8|p[$u+2|0]<<16&4128768|p[$u|0];break b}Ds=av+ -4|0;o[_u+44>>2]=Ds;$u=(av+ev|0)+ -4|0;$u=p[$u+2|0]<<16|p[$u+3|0]<<24&1056964608|p[$u+1|0]<<8|p[$u|0];break b}o[_u+44>>2]=Ds;$u=p[$u|0]&63}cv=$u- -1048576|0;o[bv+48>>2]=cv;hv=cv>>>0<268435456;if(!Ye|cv>>>0>268435455){break a}fv=o[_u+28>>2];dv=0;gv=o[_u+16>>2];while(1){g:{if(cv>>>0>1048575){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[_u+44>>2]=Ds;cv=p[Ds+ev|0]|cv<<8;o[_u+48>>2]=cv;if(cv>>>0<1048576){continue}break}}av=cv&262143;$u=o[(av<<2)+gv>>2];bv=($u<<3)+fv|0;cv=(u(o[bv>>2],cv>>>18)+av|0)-o[bv+4>>2]|0;o[_u+48>>2]=cv;o[(dv<<2)+du>>2]=$u;hv=1;dv=dv+1|0;if((dv|0)!=(Ye|0)){continue}break}}Ye=o[_u+28>>2];if(Ye){o[_u+32>>2]=Ye;ul(Ye)}Ye=o[_u+16>>2];if(Ye){o[_u+20>>2]=Ye;ul(Ye)}Ye=o[_u>>2];if(Ye){o[_u+4>>2]=Ye;ul(Ye)}R=_u- -64|0;return hv}function jg(Ye,Ds,du){var iv=0,jv=0,kv=0,lv=0,mv=0,nv=0,ov=0,pv=0,qv=0,rv=0;iv=R+ -64|0;R=iv;o[iv+48>>2]=0;o[iv+40>>2]=0;o[iv+44>>2]=0;o[iv+32>>2]=0;o[iv+36>>2]=0;o[iv+24>>2]=0;o[iv+28>>2]=0;o[iv+16>>2]=0;o[iv+20>>2]=0;o[iv+8>>2]=0;o[iv+12>>2]=0;o[iv>>2]=0;o[iv+4>>2]=0;a:{if(!sg(iv,Ds)|(o[iv+12>>2]?0:Ye)){break a}if(!ng(1,iv+56|0,Ds)){break a}kv=o[Ds+8>>2];qv=o[Ds+16>>2];lv=qv;ov=kv-lv|0;nv=o[iv+60>>2];jv=nv;pv=o[Ds+20>>2];lv=o[Ds+12>>2]-(pv+(kv>>>0>>0)|0)|0;kv=o[iv+56>>2];if((jv|0)==(lv|0)&kv>>>0>ov>>>0|jv>>>0>lv>>>0){break a}nv=nv+pv|0;lv=qv;pv=lv+kv|0;if(pv>>>0>>0){nv=nv+1|0}o[Ds+16>>2]=pv;o[Ds+20>>2]=nv;if((kv|0)<1){break a}ov=qv+o[Ds>>2]|0;o[iv+40>>2]=ov;lv=iv;b:{c:{d:{e:{f:{Ds=kv+ -1|0;jv=ov+Ds|0;switch((p[jv|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((kv|0)<2){break a}Ds=kv+ -2|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -2|0;jv=p[jv+1|0]<<8&16128|p[jv|0];break b}if((kv|0)<3){break a}Ds=kv+ -3|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -3|0;jv=p[jv+1|0]<<8|p[jv+2|0]<<16&4128768|p[jv|0];break b}Ds=kv+ -4|0;o[iv+44>>2]=Ds;jv=(kv+ov|0)+ -4|0;jv=p[jv+2|0]<<16|p[jv+3|0]<<24&1056964608|p[jv+1|0]<<8|p[jv|0];break b}o[iv+44>>2]=Ds;jv=p[jv|0]&63}mv=jv+2097152|0;o[lv+48>>2]=mv;rv=mv>>>0<536870912;if(!Ye|mv>>>0>536870911){break a}pv=o[iv+28>>2];nv=0;qv=o[iv+16>>2];while(1){g:{if(mv>>>0>2097151){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[iv+44>>2]=Ds;mv=p[Ds+ov|0]|mv<<8;o[iv+48>>2]=mv;if(mv>>>0<2097152){continue}break}}kv=mv&524287;jv=o[(kv<<2)+qv>>2];lv=(jv<<3)+pv|0;mv=(u(o[lv>>2],mv>>>19)+kv|0)-o[lv+4>>2]|0;o[iv+48>>2]=mv;o[(nv<<2)+du>>2]=jv;rv=1;nv=nv+1|0;if((nv|0)!=(Ye|0)){continue}break}}Ye=o[iv+28>>2];if(Ye){o[iv+32>>2]=Ye;ul(Ye)}Ye=o[iv+16>>2];if(Ye){o[iv+20>>2]=Ye;ul(Ye)}Ye=o[iv>>2];if(Ye){o[iv+4>>2]=Ye;ul(Ye)}R=iv- -64|0;return rv}function kg(Ye,Ds,du){var sv=0,tv=0,uv=0,vv=0,wv=0,xv=0,yv=0,zv=0,Av=0,Bv=0;sv=R+ -64|0;R=sv;o[sv+48>>2]=0;o[sv+40>>2]=0;o[sv+44>>2]=0;o[sv+32>>2]=0;o[sv+36>>2]=0;o[sv+24>>2]=0;o[sv+28>>2]=0;o[sv+16>>2]=0;o[sv+20>>2]=0;o[sv+8>>2]=0;o[sv+12>>2]=0;o[sv>>2]=0;o[sv+4>>2]=0;a:{if(!tg(sv,Ds)|(o[sv+12>>2]?0:Ye)){break a}if(!ng(1,sv+56|0,Ds)){break a}uv=o[Ds+8>>2];Av=o[Ds+16>>2];vv=Av;yv=uv-vv|0;xv=o[sv+60>>2];tv=xv;zv=o[Ds+20>>2];vv=o[Ds+12>>2]-(zv+(uv>>>0>>0)|0)|0;uv=o[sv+56>>2];if((tv|0)==(vv|0)&uv>>>0>yv>>>0|tv>>>0>vv>>>0){break a}xv=xv+zv|0;vv=Av;zv=vv+uv|0;if(zv>>>0>>0){xv=xv+1|0}o[Ds+16>>2]=zv;o[Ds+20>>2]=xv;if((uv|0)<1){break a}yv=Av+o[Ds>>2]|0;o[sv+40>>2]=yv;vv=sv;b:{c:{d:{e:{f:{Ds=uv+ -1|0;tv=yv+Ds|0;switch((p[tv|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break c}}if((uv|0)<2){break a}Ds=uv+ -2|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -2|0;tv=p[tv+1|0]<<8&16128|p[tv|0];break b}if((uv|0)<3){break a}Ds=uv+ -3|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -3|0;tv=p[tv+1|0]<<8|p[tv+2|0]<<16&4128768|p[tv|0];break b}Ds=uv+ -4|0;o[sv+44>>2]=Ds;tv=(uv+yv|0)+ -4|0;tv=p[tv+2|0]<<16|p[tv+3|0]<<24&1056964608|p[tv+1|0]<<8|p[tv|0];break b}o[sv+44>>2]=Ds;tv=p[tv|0]&63}wv=tv+4194304|0;o[vv+48>>2]=wv;Bv=wv>>>0<1073741824;if(!Ye|wv>>>0>1073741823){break a}zv=o[sv+28>>2];xv=0;Av=o[sv+16>>2];while(1){g:{if(wv>>>0>4194303){break g}while(1){if((Ds|0)<1){break g}Ds=Ds+ -1|0;o[sv+44>>2]=Ds;wv=p[Ds+yv|0]|wv<<8;o[sv+48>>2]=wv;if(wv>>>0<4194304){continue}break}}uv=wv&1048575;tv=o[(uv<<2)+Av>>2];vv=(tv<<3)+zv|0;wv=(u(o[vv>>2],wv>>>20)+uv|0)-o[vv+4>>2]|0;o[sv+48>>2]=wv;o[(xv<<2)+du>>2]=tv;Bv=1;xv=xv+1|0;if((xv|0)!=(Ye|0)){continue}break}}Ye=o[sv+28>>2];if(Ye){o[sv+32>>2]=Ye;ul(Ye)}Ye=o[sv+16>>2];if(Ye){o[sv+20>>2]=Ye;ul(Ye)}Ye=o[sv>>2];if(Ye){o[sv+4>>2]=Ye;ul(Ye)}R=sv- -64|0;return Bv}function lg(Ye,Ds,du){var Cv=0,Dv=0,Ev=0,Fv=0;a:{if(Ye>>>0>5){break a}Ev=o[du+16>>2];Cv=o[du+12>>2];Dv=o[du+20>>2];if((Cv|0)<(Dv|0)?1:(Cv|0)<=(Dv|0)?r[du+8>>2]>Ev>>>0?0:1:0){break a}Cv=p[Ev+o[du>>2]|0];Ev=Ev+1|0;if(Ev>>>0<1){Dv=Dv+1|0}o[du+16>>2]=Ev;o[du+20>>2]=Dv;Dv=Ds;if(Cv&128){if(!lg(Ye+1|0,Ds,du)){break a}Ye=o[Ds>>2]<<7;o[Ds>>2]=Ye;Cv=Ye|Cv&127}o[Dv>>2]=Cv;Fv=1}return Fv}function mg(Ye,Ds){var du=0,Gv=0,Hv=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=Uv}Wv=Wv+1|0;Vv=o[$v>>2];if(Wv>>>0>>0){continue}break}Tv=Ye+16|0;Yv=o[Ye>>2];Ds=o[Ye+16>>2];Mv=o[Ye+20>>2]-Ds|0;Wv=Mv>>2;g:{if(Wv>>>0<=8191){Da(Tv,8192-Wv|0);break g}if((Mv|0)==32768){break g}o[Ye+20>>2]=Ds+32768}h:{Mv=Ye+28|0;Ds=o[Mv>>2];Wv=o[Ye+32>>2]-Ds>>3;if(Vv>>>0>Wv>>>0){mg(Mv,Vv-Wv|0);Ds=o[Mv>>2];break h}if(Vv>>>0>>0){o[Ye+32>>2]=(Vv<<3)+Ds}if(Vv){break h}return 0}Uv=0;Mv=0;while(1){Ye=Yv+(Uv<<2)|0;Wv=o[Ye>>2];Xv=(Uv<<3)+Ds|0;o[Xv+4>>2]=Mv;o[Xv>>2]=Wv;Ye=o[Ye>>2]+Mv|0;if(Ye>>>0>8192){break a}if(Mv>>>0>>0){Wv=o[Tv>>2];while(1){o[Wv+(Mv<<2)>>2]=Uv;Mv=Mv+1|0;if((Ye|0)!=(Mv|0)){continue}break}}Mv=Ye;Uv=Uv+1|0;if((Vv|0)!=(Uv|0)){continue}break}return(Ye|0)==8192}return cw}function pg(Ye,Ds){var dw=0,ew=0,fw=0,gw=0,hw=0,iw=0,jw=0,kw=0,lw=0,mw=0,nw=0,ow=0,pw=0;a:{if(!q[Ds+38>>1]){break a}mw=Ye+12|0;if(!lg(1,mw,Ds)){break a}gw=o[Ye+12>>2];dw=o[Ye>>2];ew=o[Ye+4>>2]-dw>>2;b:{if(gw>>>0>ew>>>0){Da(Ye,gw-ew|0);gw=o[Ye+12>>2];break b}if(gw>>>0>=ew>>>0){break b}o[Ye+4>>2]=dw+(gw<<2)}if(!gw){pw=1;break a}nw=o[Ds+8>>2];jw=o[Ds+12>>2];while(1){fw=o[Ds+16>>2];ew=o[Ds+20>>2];dw=ew;if((jw|0)<(dw|0)?1:(jw|0)<=(dw|0)?nw>>>0>fw>>>0?0:1:0){break a}ow=o[Ds>>2];kw=p[ow+fw|0];fw=fw+1|0;if(fw>>>0<1){ew=ew+1|0}dw=Ds;iw=fw;o[dw+16>>2]=fw;o[dw+20>>2]=ew;fw=kw>>>2;c:{d:{e:{lw=kw&3;if(lw>>>0>3){dw=0;break e}dw=0;f:{switch(lw-1|0){case 2:break f;case 0:case 1:break e;default:break d}}ew=fw+hw|0;if(ew>>>0>=gw>>>0){return 0}xl(o[Ye>>2]+(hw<<2)|0,0,(kw&252)+4|0);hw=ew;break c}while(1){if((jw|0)<(ew|0)?1:(jw|0)<=(ew|0)?nw>>>0>iw>>>0?0:1:0){return 0}kw=p[iw+ow|0];iw=iw+1|0;if(iw>>>0<1){ew=ew+1|0}gw=Ds;o[gw+16>>2]=iw;o[gw+20>>2]=ew;fw=kw<<(dw<<3|6)|fw;dw=dw+1|0;if((lw|0)!=(dw|0)){continue}break}}o[o[Ye>>2]+(hw<<2)>>2]=fw}hw=hw+1|0;gw=o[mw>>2];if(hw>>>0>>0){continue}break}ew=Ye+16|0;jw=o[Ye>>2];Ds=o[Ye+16>>2];dw=o[Ye+20>>2]-Ds|0;hw=dw>>2;g:{if(hw>>>0<=32767){Da(ew,32768-hw|0);break g}if((dw|0)==131072){break g}o[Ye+20>>2]=Ds+131072}h:{dw=Ye+28|0;Ds=o[dw>>2];hw=o[Ye+32>>2]-Ds>>3;if(gw>>>0>hw>>>0){mg(dw,gw-hw|0);Ds=o[dw>>2];break h}if(gw>>>0>>0){o[Ye+32>>2]=(gw<<3)+Ds}if(gw){break h}return 0}fw=0;dw=0;while(1){Ye=jw+(fw<<2)|0;hw=o[Ye>>2];iw=(fw<<3)+Ds|0;o[iw+4>>2]=dw;o[iw>>2]=hw;Ye=o[Ye>>2]+dw|0;if(Ye>>>0>32768){break a}if(dw>>>0>>0){hw=o[ew>>2];while(1){o[hw+(dw<<2)>>2]=fw;dw=dw+1|0;if((Ye|0)!=(dw|0)){continue}break}}dw=Ye;fw=fw+1|0;if((gw|0)!=(fw|0)){continue}break}return(Ye|0)==32768}return pw}function qg(Ye,Ds){var qw=0,rw=0,sw=0,tw=0,uw=0,vw=0,ww=0,xw=0,yw=0,zw=0,Aw=0,Bw=0,Cw=0;a:{if(!q[Ds+38>>1]){break a}zw=Ye+12|0;if(!lg(1,zw,Ds)){break a}tw=o[Ye+12>>2];qw=o[Ye>>2];rw=o[Ye+4>>2]-qw>>2;b:{if(tw>>>0>rw>>>0){Da(Ye,tw-rw|0);tw=o[Ye+12>>2];break b}if(tw>>>0>=rw>>>0){break b}o[Ye+4>>2]=qw+(tw<<2)}if(!tw){Cw=1;break a}Aw=o[Ds+8>>2];ww=o[Ds+12>>2];while(1){sw=o[Ds+16>>2];rw=o[Ds+20>>2];qw=rw;if((ww|0)<(qw|0)?1:(ww|0)<=(qw|0)?Aw>>>0>sw>>>0?0:1:0){break a}Bw=o[Ds>>2];xw=p[Bw+sw|0];sw=sw+1|0;if(sw>>>0<1){rw=rw+1|0}qw=Ds;vw=sw;o[qw+16>>2]=sw;o[qw+20>>2]=rw;sw=xw>>>2;c:{d:{e:{yw=xw&3;if(yw>>>0>3){qw=0;break e}qw=0;f:{switch(yw-1|0){case 2:break f;case 0:case 1:break e;default:break d}}rw=sw+uw|0;if(rw>>>0>=tw>>>0){return 0}xl(o[Ye>>2]+(uw<<2)|0,0,(xw&252)+4|0);uw=rw;break c}while(1){if((ww|0)<(rw|0)?1:(ww|0)<=(rw|0)?Aw>>>0>vw>>>0?0:1:0){return 0}xw=p[vw+Bw|0];vw=vw+1|0;if(vw>>>0<1){rw=rw+1|0}tw=Ds;o[tw+16>>2]=vw;o[tw+20>>2]=rw;sw=xw<<(qw<<3|6)|sw;qw=qw+1|0;if((yw|0)!=(qw|0)){continue}break}}o[o[Ye>>2]+(uw<<2)>>2]=sw}uw=uw+1|0;tw=o[zw>>2];if(uw>>>0>>0){continue}break}rw=Ye+16|0;ww=o[Ye>>2];Ds=o[Ye+16>>2];qw=o[Ye+20>>2]-Ds|0;uw=qw>>2;g:{if(uw>>>0<=65535){Da(rw,65536-uw|0);break g}if((qw|0)==262144){break g}o[Ye+20>>2]=Ds+262144}h:{qw=Ye+28|0;Ds=o[qw>>2];uw=o[Ye+32>>2]-Ds>>3;if(tw>>>0>uw>>>0){mg(qw,tw-uw|0);Ds=o[qw>>2];break h}if(tw>>>0>>0){o[Ye+32>>2]=(tw<<3)+Ds}if(tw){break h}return 0}sw=0;qw=0;while(1){Ye=ww+(sw<<2)|0;uw=o[Ye>>2];vw=(sw<<3)+Ds|0;o[vw+4>>2]=qw;o[vw>>2]=uw;Ye=o[Ye>>2]+qw|0;if(Ye>>>0>65536){break a}if(qw>>>0>>0){uw=o[rw>>2];while(1){o[uw+(qw<<2)>>2]=sw;qw=qw+1|0;if((Ye|0)!=(qw|0)){continue}break}}qw=Ye;sw=sw+1|0;if((tw|0)!=(sw|0)){continue}break}return(Ye|0)==65536}return Cw}function rg(Ye,Ds){var Dw=0,Ew=0,Fw=0,Gw=0,Hw=0,Iw=0,Jw=0,Kw=0,Lw=0,Mw=0,Nw=0,Ow=0,Pw=0;a:{if(!q[Ds+38>>1]){break a}Mw=Ye+12|0;if(!lg(1,Mw,Ds)){break a}Gw=o[Ye+12>>2];Dw=o[Ye>>2];Ew=o[Ye+4>>2]-Dw>>2;b:{if(Gw>>>0>Ew>>>0){Da(Ye,Gw-Ew|0);Gw=o[Ye+12>>2];break b}if(Gw>>>0>=Ew>>>0){break b}o[Ye+4>>2]=Dw+(Gw<<2)}if(!Gw){Pw=1;break a}Nw=o[Ds+8>>2];Jw=o[Ds+12>>2];while(1){Fw=o[Ds+16>>2];Ew=o[Ds+20>>2];Dw=Ew;if((Jw|0)<(Dw|0)?1:(Jw|0)<=(Dw|0)?Nw>>>0>Fw>>>0?0:1:0){break a}Ow=o[Ds>>2];Kw=p[Ow+Fw|0];Fw=Fw+1|0;if(Fw>>>0<1){Ew=Ew+1|0}Dw=Ds;Iw=Fw;o[Dw+16>>2]=Fw;o[Dw+20>>2]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;Tw=o[Zw>>2];if(Uw>>>0>>0){continue}break}Rw=Ye+16|0;Ww=o[Ye>>2];Ds=o[Ye+16>>2];Qw=o[Ye+20>>2]-Ds|0;Uw=Qw>>2;g:{if(Uw>>>0<=524287){Da(Rw,524288-Uw|0);break g}if((Qw|0)==2097152){break g}o[Ye+20>>2]=Ds+2097152}h:{Qw=Ye+28|0;Ds=o[Qw>>2];Uw=o[Ye+32>>2]-Ds>>3;if(Tw>>>0>Uw>>>0){mg(Qw,Tw-Uw|0);Ds=o[Qw>>2];break h}if(Tw>>>0>>0){o[Ye+32>>2]=(Tw<<3)+Ds}if(Tw){break h}return 0}Sw=0;Qw=0;while(1){Ye=Ww+(Sw<<2)|0;Uw=o[Ye>>2];Vw=(Sw<<3)+Ds|0;o[Vw+4>>2]=Qw;o[Vw>>2]=Uw;Ye=o[Ye>>2]+Qw|0;if(Ye>>>0>524288){break a}if(Qw>>>0>>0){Uw=o[Rw>>2];while(1){o[Uw+(Qw<<2)>>2]=Sw;Qw=Qw+1|0;if((Ye|0)!=(Qw|0)){continue}break}}Qw=Ye;Sw=Sw+1|0;if((Tw|0)!=(Sw|0)){continue}break}return(Ye|0)==524288}return ax}function tg(Ye,Ds){var bx=0,cx=0,dx=0,ex=0,fx=0,gx=0,hx=0,ix=0,jx=0,kx=0,lx=0,mx=0,nx=0;a:{if(!q[Ds+38>>1]){break a}kx=Ye+12|0;if(!lg(1,kx,Ds)){break a}ex=o[Ye+12>>2];bx=o[Ye>>2];cx=o[Ye+4>>2]-bx>>2;b:{if(ex>>>0>cx>>>0){Da(Ye,ex-cx|0);ex=o[Ye+12>>2];break b}if(ex>>>0>=cx>>>0){break b}o[Ye+4>>2]=bx+(ex<<2)}if(!ex){nx=1;break a}lx=o[Ds+8>>2];hx=o[Ds+12>>2];while(1){dx=o[Ds+16>>2];cx=o[Ds+20>>2];bx=cx;if((hx|0)<(bx|0)?1:(hx|0)<=(bx|0)?lx>>>0>dx>>>0?0:1:0){break a}mx=o[Ds>>2];ix=p[mx+dx|0];dx=dx+1|0;if(dx>>>0<1){cx=cx+1|0}bx=Ds;gx=dx;o[bx+16>>2]=dx;o[bx+20>>2]=cx;dx=ix>>>2;c:{d:{e:{jx=ix&3;if(jx>>>0>3){bx=0;break e}bx=0;f:{switch(jx-1|0){case 2:break f;case 0:case 1:break e;default:break d}}cx=dx+fx|0;if(cx>>>0>=ex>>>0){return 0}xl(o[Ye>>2]+(fx<<2)|0,0,(ix&252)+4|0);fx=cx;break c}while(1){if((hx|0)<(cx|0)?1:(hx|0)<=(cx|0)?lx>>>0>gx>>>0?0:1:0){return 0}ix=p[gx+mx|0];gx=gx+1|0;if(gx>>>0<1){cx=cx+1|0}ex=Ds;o[ex+16>>2]=gx;o[ex+20>>2]=cx;dx=ix<<(bx<<3|6)|dx;bx=bx+1|0;if((jx|0)!=(bx|0)){continue}break}}o[o[Ye>>2]+(fx<<2)>>2]=dx}fx=fx+1|0;ex=o[kx>>2];if(fx>>>0>>0){continue}break}cx=Ye+16|0;hx=o[Ye>>2];Ds=o[Ye+16>>2];bx=o[Ye+20>>2]-Ds|0;fx=bx>>2;g:{if(fx>>>0<=1048575){Da(cx,1048576-fx|0);break g}if((bx|0)==4194304){break g}o[Ye+20>>2]=Ds+4194304}h:{bx=Ye+28|0;Ds=o[bx>>2];fx=o[Ye+32>>2]-Ds>>3;if(ex>>>0>fx>>>0){mg(bx,ex-fx|0);Ds=o[bx>>2];break h}if(ex>>>0>>0){o[Ye+32>>2]=(ex<<3)+Ds}if(ex){break h}return 0}dx=0;bx=0;while(1){Ye=hx+(dx<<2)|0;fx=o[Ye>>2];gx=(dx<<3)+Ds|0;o[gx+4>>2]=bx;o[gx>>2]=fx;Ye=o[Ye>>2]+bx|0;if(Ye>>>0>1048576){break a}if(bx>>>0>>0){fx=o[cx>>2];while(1){o[fx+(bx<<2)>>2]=dx;bx=bx+1|0;if((Ye|0)!=(bx|0)){continue}break}}bx=Ye;dx=dx+1|0;if((ex|0)!=(dx|0)){continue}break}return(Ye|0)==1048576}return nx}function ug(Ye){bi(Ye);o[Ye+44>>2]=0;o[Ye>>2]=7968}function vg(Ye){Ye=Ye|0;if(o[Ye+44>>2]){return l[o[o[Ye>>2]+48>>2]](Ye)|0}return 0}function wg(Ye){Ye=Ye|0;var Ds=0,ox=0,px=0,qx=0,rx=0;o[Ye>>2]=10052;Ds=o[Ye+20>>2];if(Ds){o[Ye+24>>2]=Ds;ul(Ds)}px=o[Ye+8>>2];if(px){Ds=px;rx=Ye+12|0;ox=o[rx>>2];qx=Ds;a:{if((Ds|0)==(ox|0)){break a}while(1){ox=ox+ -4|0;Ds=o[ox>>2];o[ox>>2]=0;if(Ds){l[o[o[Ds>>2]+4>>2]](Ds)}if((ox|0)!=(px|0)){continue}break}qx=o[Ye+8>>2]}Ds=qx;o[rx>>2]=px;ul(Ds)}return Ye|0}function xg(Ye,sx){Ye=Ye|0;sx=sx|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+20>>2]](Ye,sx)|0}function yg(Ye){Ye=Ye|0;var sx=0,tx=0,ux=0,vx=0;sx=o[Ye+32>>2];ux=o[sx+16>>2];vx=o[sx+12>>2];tx=o[sx+20>>2];if((vx|0)>(tx|0)?1:(vx|0)>=(tx|0)?r[sx+8>>2]<=ux>>>0?0:1:0){vx=p[ux+o[sx>>2]|0];ux=ux+1|0;if(ux>>>0<1){tx=tx+1|0}o[sx+16>>2]=ux;o[sx+20>>2]=tx;sx=o[Ye+48>>2];o[Ye+48>>2]=0;if(sx){l[o[o[sx>>2]+4>>2]](sx)}a:{b:{if(vx>>>0>2){break b}c:{switch(vx-1|0){default:tx=Hk(384);Gg(tx);sx=o[Ye+48>>2];o[Ye+48>>2]=tx;if(!sx){break a}l[o[o[sx>>2]+4>>2]](sx);break b;case 0:break b;case 1:break c}}tx=Hk(440);fh(tx);sx=o[Ye+48>>2];o[Ye+48>>2]=tx;if(!sx){break a}l[o[o[sx>>2]+4>>2]](sx)}tx=o[Ye+48>>2];if(tx){break a}return 0}Ye=l[o[o[tx>>2]+8>>2]](tx,Ye)|0}else{Ye=0}return Ye|0}function zg(Ye){Ye=Ye|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+24>>2]](Ye)|0}function Ag(Ye){Ye=Ye|0;Ye=o[Ye+48>>2];return l[o[o[Ye>>2]+28>>2]](Ye)|0}function Bg(Ye){Ye=Ye|0;var wx=0,xx=0,yx=0,zx=0,Ax=0;o[Ye>>2]=8064;wx=Ye+48|0;xx=o[wx>>2];o[wx>>2]=0;if(xx){l[o[o[xx>>2]+4>>2]](xx)}o[Ye>>2]=10052;wx=o[Ye+20>>2];if(wx){o[Ye+24>>2]=wx;ul(wx)}xx=o[Ye+8>>2];if(xx){wx=xx;Ax=Ye+12|0;yx=o[Ax>>2];zx=wx;a:{if((wx|0)==(yx|0)){break a}while(1){yx=yx+ -4|0;wx=o[yx>>2];o[yx>>2]=0;if(wx){l[o[o[wx>>2]+4>>2]](wx)}if((xx|0)!=(yx|0)){continue}break}zx=o[Ye+8>>2]}wx=zx;o[Ax>>2]=xx;ul(wx)}return Ye|0} + + + +function Cg(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;o[a>>2]=8064;b=a+48|0;c=o[b>>2];o[b>>2]=0;if(c){l[o[o[c>>2]+4>>2]](c)}o[a>>2]=10052;b=o[a+20>>2];if(b){o[a+24>>2]=b;ul(b)}c=o[a+8>>2];if(c){b=c;f=a+12|0;d=o[f>>2];e=b;a:{if((b|0)==(d|0)){break a}while(1){d=d+ -4|0;b=o[d>>2];o[d>>2]=0;if(b){l[o[o[b>>2]+4>>2]](b)}if((c|0)!=(d|0)){continue}break}e=o[a+8>>2]}b=e;o[f>>2]=c;ul(b)}ul(a)}function Dg(a){a=a|0;a=o[a+48>>2];return l[o[o[a>>2]+36>>2]](a)|0}function Eg(a,g){a=a|0;g=g|0;a=o[a+48>>2];return l[o[o[a>>2]+12>>2]](a,g)|0}function Fg(a,g){a=a|0;g=g|0;a=o[a+48>>2];return l[o[o[a>>2]+16>>2]](a,g)|0}function Gg(a){o[a>>2]=8172;xl(a+4|0,0,80);o[a+96>>2]=0;o[a+100>>2]=0;o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+104>>2]=0;o[a+108>>2]=0;o[a+112>>2]=0;o[a+116>>2]=0;o[a+120>>2]=0;o[a+124>>2]=0;o[a+128>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0;o[a+144>>2]=0;o[a+148>>2]=0;o[a+156>>2]=0;o[a+160>>2]=0;o[a+152>>2]=1065353216;o[a+164>>2]=0;o[a+168>>2]=0;o[a+172>>2]=0;o[a+176>>2]=0;o[a+180>>2]=0;o[a+184>>2]=0;o[a+188>>2]=0;o[a+192>>2]=0;o[a+196>>2]=0;o[a+200>>2]=0;o[a+204>>2]=0;o[a+208>>2]=0;o[a+212>>2]=-1;o[a+216>>2]=0;o[a+220>>2]=0;o[a+224>>2]=0;Hg(a+232|0)}function Hg(a){oi(a);oi(a+40|0);Mf(a+80|0);oi(a+96|0);o[a+144>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0}function Ig(a,g){a=a|0;g=g|0;o[a+4>>2]=g;return 1}function Jg(a,g){a=a|0;g=g|0;var h=0,i=0,j=0,k=0,m=0;h=o[a+216>>2];k=a+220|0;if((h|0)!=o[k>>2]){while(1){a:{h=o[u(j,144)+h>>2];if((h|0)<0){break a}m=o[a+4>>2];i=o[m+8>>2];if((h|0)>=o[m+12>>2]-i>>2){break a}h=o[i+(h<<2)>>2];if((l[o[o[h>>2]+24>>2]](h)|0)<1){break a}i=0;while(1){if((l[o[o[h>>2]+20>>2]](h,i)|0)!=(g|0)){i=i+1|0;if((i|0)<(l[o[o[h>>2]+24>>2]](h)|0)){continue}break a}break}a=o[a+216>>2]+u(j,144)|0;return(p[a+100|0]?a+4|0:0)|0}j=j+1|0;h=o[a+216>>2];if(j>>>0<(o[k>>2]-h|0)/144>>>0){continue}break}}return 0}function Kg(a,g){a=a|0;g=g|0;var n=0,p=0,q=0,r=0,s=0;n=o[a+216>>2];r=a+220|0;if((n|0)!=o[r>>2]){while(1){a:{n=o[u(q,144)+n>>2];if((n|0)<0){break a}s=o[a+4>>2];p=o[s+8>>2];if((n|0)>=o[s+12>>2]-p>>2){break a}n=o[p+(n<<2)>>2];if((l[o[o[n>>2]+24>>2]](n)|0)<1){break a}p=0;while(1){if((l[o[o[n>>2]+20>>2]](n,p)|0)!=(g|0)){p=p+1|0;if((p|0)<(l[o[o[n>>2]+24>>2]](n)|0)){continue}break a}break}return(o[a+216>>2]+u(q,144)|0)+104|0}q=q+1|0;n=o[a+216>>2];if(q>>>0<(o[r>>2]-n|0)/144>>>0){continue}break}}return a+184|0}function Lg(a,g){a=a|0;g=g|0;var t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0;x=R-80|0;R=x;a:{b:{H=o[a+4>>2];t=o[H+32>>2];C=o[t+8>>2];B=o[t+16>>2];F=o[t+12>>2];v=F;z=o[t+20>>2];y=z;c:{if((v|0)<(y|0)?1:(v|0)<=(y|0)?C>>>0>B>>>0?0:1:0){break c}I=o[t>>2];E=p[I+B|0];v=z;A=B+1|0;if(A>>>0<1){v=v+1|0}y=t;o[t+16>>2]=A;o[t+20>>2]=v;if((F|0)<(v|0)?1:(F|0)<=(v|0)?C>>>0>A>>>0?0:1:0){break c}J=p[A+I|0];v=z;A=B+2|0;if(A>>>0<2){v=v+1|0}o[t+16>>2]=A;o[y+20>>2]=v;G=E<<24>>24;d:{if((G|0)>=0){y=o[a+216>>2];if((o[a+220>>2]-y|0)/144>>>0<=E>>>0){break c}y=y+u(E,144)|0;if(o[y>>2]<=-1){break d}break c}if(o[a+212>>2]>-1){break c}y=a+212|0}o[y>>2]=g;y=0;w=q[H+36>>1];if((w<<24|w<<8&16711680)>>>16>>>0>=258){w=0;if((F|0)<(v|0)?1:(F|0)<=(v|0)?C>>>0>A>>>0?0:1:0){break c}y=p[A+I|0];v=B+3|0;if(v>>>0<3){z=z+1|0}o[t+16>>2]=v;o[t+20>>2]=z}e:{f:{g:{if(!J){if((G|0)<=-1){t=a+184|0}else{t=o[a+216>>2]+u(E,144)|0;m[t+100|0]=0;t=t+104|0}w=0;if(y>>>0>1){break c}if(!(y-1)){break g}Mg(x+16|0,a,t);break f}w=0;if(y|(G|0)<0){break c}z=o[H+44>>2];w=o[a+216>>2];t=Hk(80);o[t>>2]=9636;o[t+76>>2]=0;o[t+68>>2]=z;v=t+12|0;o[v>>2]=0;o[v+4>>2]=0;o[t+4>>2]=0;y=t+20|0;o[y>>2]=0;o[y+4>>2]=0;F=t+28|0;B=F;o[B>>2]=0;o[B+4>>2]=0;o[t+36>>2]=0;o[t+40>>2]=0;B=t+44|0;o[B>>2]=0;o[B+4>>2]=0;o[t+52>>2]=0;w=w+u(E,144)|0;E=w+104|0;o[t+72>>2]=E;o[t- -64>>2]=0;H=t+56|0;C=H;o[C>>2]=0;o[C+4>>2]=0;o[t+8>>2]=8512;C=x+56|0;o[C>>2]=0;o[C+4>>2]=0;o[x+48>>2]=0;o[x+52>>2]=0;I=x+32|0;A=I;o[A>>2]=0;o[A+4>>2]=0;o[x+72>>2]=0;o[x+40>>2]=0;o[x+44>>2]=0;o[x+24>>2]=0;o[x+28>>2]=0;o[x+64>>2]=0;o[x+68>>2]=0;o[x+16>>2]=8512;A=w+4|0;o[x+20>>2]=A;w=o[w+68>>2];G=o[w>>2];w=o[w+4>>2];m[x+79|0]=0;$a(x+40|0,(w-G>>2>>>0)/3|0,x+79|0);w=o[x+20>>2];G=o[w+56>>2];w=o[w+52>>2];m[x+79|0]=0;$a(x+52|0,G-w>>2,x+79|0);o[x+36>>2]=t;o[I>>2]=z;z=x+28|0;o[z>>2]=E;o[x+24>>2]=A;o[F>>2]=t;w=o[z+4>>2];o[y>>2]=o[z>>2];o[y+4>>2]=w;z=o[x+24>>2];o[v>>2]=o[x+20>>2];o[v+4>>2]=z;z=t;w=o[x+44>>2];if(w){v=t+32|0;h:{if(w>>>0<=o[t+40>>2]<<5>>>0){y=w+ -1>>>5;w=o[v>>2];break h}v=o[v>>2];if(v){ul(v);o[t+40>>2]=0;o[t+32>>2]=0;o[t+36>>2]=0;w=o[x+44>>2]}if((w|0)<=-1){break b}y=w+ -1>>>5;v=y+1|0;w=Hk(v<<2);o[t+40>>2]=v;o[t+36>>2]=0;o[t+32>>2]=w}yl(w,o[x+40>>2],(y<<2)+4|0);v=o[x+44>>2]}else{v=0}o[z+36>>2]=v;z=t;w=o[C>>2];if(w){i:{if(w>>>0<=o[t+52>>2]<<5>>>0){v=w+ -1>>>5;w=o[B>>2];break i}v=o[B>>2];if(v){ul(v);o[t+52>>2]=0;o[t+44>>2]=0;o[t+48>>2]=0;w=o[x+56>>2]}if((w|0)<=-1){break a}v=w+ -1>>>5;y=v+1|0;w=Hk(y<<2);o[t+52>>2]=y;o[t+48>>2]=0;o[t+44>>2]=w}yl(w,o[x+52>>2],(v<<2)+4|0);v=o[x+56>>2]}else{v=0}o[z+48>>2]=v;td(H,o[x+64>>2],o[x+68>>2]);o[x+16>>2]=8512;z=o[x+64>>2];if(z){o[x+68>>2]=z;ul(z)}o[x+16>>2]=8764;z=o[x+52>>2];if(z){ul(z)}z=o[x+40>>2];if(!z){break e}ul(z);break e}Ng(x+16|0,a,t)}t=o[x+16>>2];if(!t){break c}}z=Hk(64);o[x+8>>2]=t;Qd(z,x+8|0);t=o[x+8>>2];o[x+8>>2]=0;if(t){l[o[o[t>>2]+4>>2]](t)}if((g|0)>=0){a=o[a+4>>2];w=a+8|0;t=o[a+12>>2];E=o[a+8>>2];v=t-E>>2;j:{if((v|0)>(g|0)){break j}y=g+1|0;if(v>>>0<=g>>>0){Og(w,y-v|0);break j}if(y>>>0>=v>>>0){break j}y=E+(y<<2)|0;if((y|0)!=(t|0)){while(1){t=t+ -4|0;v=o[t>>2];o[t>>2]=0;if(v){l[o[o[v>>2]+4>>2]](v)}if((t|0)!=(y|0)){continue}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if(g){L=K+32|0;c:{if(g>>>0<=o[K+40>>2]<<5>>>0){M=g+ -1>>>5;g=o[L>>2];break c}L=o[L>>2];if(L){ul(L);o[K+40>>2]=0;o[K+32>>2]=0;o[K+36>>2]=0;g=o[u+28>>2]}if((g|0)<=-1){break b}M=g+ -1>>>5;L=M+1|0;g=Hk(L<<2);o[K+40>>2]=L;o[K+36>>2]=0;o[K+32>>2]=g}yl(g,o[u+24>>2],(M<<2)+4|0);g=o[u+28>>2]}else{g=0}o[l+36>>2]=g;Q=K;g=o[P>>2];if(g){d:{if(g>>>0<=o[K+52>>2]<<5>>>0){l=g+ -1>>>5;g=o[N>>2];break d}l=o[N>>2];if(l){ul(l);o[K+52>>2]=0;o[K+44>>2]=0;o[K+48>>2]=0;g=o[u+40>>2]}if((g|0)<=-1){break a}l=g+ -1>>>5;M=l+1|0;g=Hk(M<<2);o[K+52>>2]=M;o[K+48>>2]=0;o[K+44>>2]=g}yl(g,o[u+36>>2],(l<<2)+4|0);g=o[u+40>>2]}else{g=0}o[Q+48>>2]=g;td(U,o[u+48>>2],o[u+52>>2]);o[a>>2]=K;o[u>>2]=9508;a=o[u+48>>2];if(a){o[u+52>>2]=a;ul(a)}o[u>>2]=9324;a=o[u+36>>2];if(a){ul(a)}a=o[u+24>>2];if(a){ul(a)}R=u- -64|0;return}Yk();D()}Yk();D()}function Ng(a,g,l){var D=0,W=0,X=0,Y=0,Z=0,_=0,$=0;D=R-112|0;R=D;$=o[o[g+4>>2]+44>>2];W=Hk(120);o[W>>2]=8876;o[W+116>>2]=0;o[W+112>>2]=l;o[W+108>>2]=$;o[W+12>>2]=0;o[W+16>>2]=0;o[W+4>>2]=0;o[W+20>>2]=0;o[W+24>>2]=0;o[W+28>>2]=0;o[W+32>>2]=0;o[W+36>>2]=0;o[W+40>>2]=0;o[W+44>>2]=0;o[W+48>>2]=0;o[W+52>>2]=0;o[W+56>>2]=0;o[W+60>>2]=0;o[W+8>>2]=9088;Z=W- -64|0;o[Z>>2]=0;o[Z+4>>2]=0;o[W+72>>2]=0;o[W+76>>2]=0;o[W+80>>2]=0;o[W+84>>2]=0;o[W+88>>2]=0;o[W+104>>2]=0;o[W+96>>2]=0;o[W+100>>2]=0;g=o[g+8>>2];o[D+48>>2]=0;o[D+52>>2]=0;o[D+40>>2]=0;o[D+44>>2]=0;Z=D+24|0;X=Z;o[X>>2]=0;o[X+4>>2]=0;X=D- -64|0;o[X>>2]=0;o[X+4>>2]=0;o[D+72>>2]=0;o[D+76>>2]=0;X=D+80|0;o[X>>2]=0;o[X+4>>2]=0;o[D+88>>2]=0;o[D+104>>2]=0;o[D+32>>2]=0;o[D+36>>2]=0;o[D+16>>2]=0;o[D+20>>2]=0;o[D+56>>2]=0;o[D+60>>2]=0;o[D+8>>2]=9088;o[D+96>>2]=0;o[D+100>>2]=0;o[D+12>>2]=g;Y=o[g>>2];_=o[g+4>>2];m[D+111|0]=0;$a(D+32|0,(_-Y>>2>>>0)/3|0,D+111|0);Y=o[D+12>>2];_=o[Y+28>>2];Y=o[Y+24>>2];m[D+111|0]=0;$a(D+44|0,_-Y>>2,D+111|0);o[D+28>>2]=W;o[Z>>2]=$;o[D+20>>2]=l;o[D+16>>2]=g;Pg(W,D+8|0);o[a>>2]=W;o[D+8>>2]=9088;a=o[D+96>>2];if(a){o[D+100>>2]=a;ul(a)}a=o[X>>2];if(a){o[D+84>>2]=a;ul(a)}a=o[D+68>>2];if(a){o[D+72>>2]=a;ul(a)}a=o[D+56>>2];if(a){o[D+60>>2]=a;ul(a)}o[D+8>>2]=9324;a=o[D+44>>2];if(a){ul(a)}a=o[D+32>>2];if(a){ul(a)}R=D+112|0}function Og(a,g){var R=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;aa=o[a+8>>2];ba=a+4|0;R=o[ba>>2];if(aa-R>>2>>>0>=g>>>0){a=g<<2;ga=ba,ha=xl(R,0,a)+a|0,o[ga>>2]=ha;return}a:{ba=o[a>>2];ca=R-ba>>2;da=ca+g|0;if(da>>>0<1073741824){ca=ca<<2;aa=aa-ba|0;fa=aa>>1;aa=aa>>2>>>0<536870911?fa>>>0>>0?da:fa:1073741823;if(aa){if(aa>>>0>=1073741824){break a}ea=Hk(aa<<2)}ca=ca+ea|0;xl(ca,0,g<<2);g=(da<<2)+ea|0;da=(aa<<2)+ea|0;if((R|0)!=(ba|0)){while(1){R=R+ -4|0;aa=o[R>>2];o[R>>2]=0;ca=ca+ -4|0;o[ca>>2]=aa;if((R|0)!=(ba|0)){continue}break}ba=o[a>>2];R=o[a+4>>2]}o[a>>2]=ca;o[a+8>>2]=da;o[a+4>>2]=g;if((R|0)!=(ba|0)){while(1){R=R+ -4|0;a=o[R>>2];o[R>>2]=0;if(a){l[o[o[a>>2]+4>>2]](a)}if((R|0)!=(ba|0)){continue}break}}if(ba){ul(ba)}return}Yk();D()}_a(8776);D()}function Pg(a,g){var l=0;l=o[g+8>>2];o[a+12>>2]=o[g+4>>2];o[a+16>>2]=l;o[a+28>>2]=o[g+20>>2];l=o[g+16>>2];o[a+20>>2]=o[g+12>>2];o[a+24>>2]=l;uh(a+32|0,g+24|0);uh(a+44|0,g+36|0);if((a+8|0)==(g|0)){o[a+92>>2]=o[g+84>>2];return}td(a+56|0,o[g+48>>2],o[g+52>>2]);td(a+68|0,o[g+60>>2],o[g- -64>>2]);td(a+80|0,o[g+72>>2],o[g+76>>2]);o[a+92>>2]=o[g+84>>2];fd(a+96|0,o[g+88>>2],o[g+92>>2])}function Qg(a,g,ia){a=a|0;g=g|0;ia=ia|0;var ja=0,ka=0;ja=R-16|0;R=ja;o[a+4>>2]=g;g=o[g+64>>2];ka=o[g+4>>2];g=o[g>>2];m[ja+15|0]=0;$a(a+24|0,(ka-g>>2>>>0)/3|0,ja+15|0);g=o[a+4>>2];ka=o[g+56>>2];g=o[g+52>>2];m[ja+14|0]=0;$a(a+36|0,ka-g>>2,ja+14|0);g=o[ia+12>>2];o[a+16>>2]=o[ia+8>>2];o[a+20>>2]=g;g=o[ia+4>>2];o[a+8>>2]=o[ia>>2];o[a+12>>2]=g;R=ja+16|0}function Rg(a){a=a|0;var g=0;o[a>>2]=8512;g=o[a+48>>2];if(g){o[a+52>>2]=g;ul(g)}o[a>>2]=8764;g=o[a+36>>2];if(g){ul(g)}g=o[a+24>>2];if(g){ul(g)}return a|0}function Sg(a){a=a|0;var ia=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,va=0,wa=0,xa=0,ya=0;qa=R+ -64|0;R=qa;o[a+132>>2]=0;if(o[a+148>>2]){ma=a+144|0;la=o[ma>>2];if(la){while(1){ia=o[la>>2];ul(la);la=ia;if(ia){continue}break}}o[ma>>2]=0;ia=o[a+140>>2];if(ia){ma=a+136|0;la=0;while(1){o[o[ma>>2]+(la<<2)>>2]=0;la=la+1|0;if((ia|0)!=(la|0)){continue}break}}o[a+148>>2]=0}a:{if(!Tg(1,qa+52|0,o[o[a+4>>2]+32>>2])){break a}o[a+156>>2]=o[qa+52>>2];if(!Tg(1,qa+48|0,o[o[a+4>>2]+32>>2])){break a}na=o[qa+48>>2];if(na>>>0>1431655765|r[a+156>>2]>u(na,3)>>>0){break a}la=o[o[a+4>>2]+32>>2];ra=o[la+16>>2];ma=o[la+12>>2];ia=o[la+20>>2];if((ma|0)<(ia|0)?1:(ma|0)<=(ia|0)?r[la+8>>2]>ra>>>0?0:1:0){break a}pa=p[ra+o[la>>2]|0];ra=ra+1|0;if(ra>>>0<1){ia=ia+1|0}o[la+16>>2]=ra;o[la+20>>2]=ia;if(!Tg(1,qa+44|0,la)){break a}ta=o[qa+44>>2];if(na>>>0>>0|na>>>0>ta+((ta>>>0)/3|0)>>>0){break a}if(!Tg(1,qa+40|0,o[o[a+4>>2]+32>>2])){break a}sa=o[qa+40>>2];if(sa>>>0>ta>>>0){break a}o[a+28>>2]=o[a+24>>2];ia=Hk(88);zi(ia);la=o[a+8>>2];o[a+8>>2]=ia;ra=a+8|0;if(la){ua(ra,la);if(!o[ra>>2]){break a}}la=o[a+160>>2];o[a+164>>2]=la;b:{c:{d:{e:{f:{if(o[a+168>>2]-la>>2>>>0>=na>>>0){break f}if(na>>>0>=1073741824){break e}ma=na<<2;ia=Hk(ma);o[a+164>>2]=ia;o[a+160>>2]=ia;o[a+168>>2]=ia+ma;if(!la){break f}ul(la)}la=o[a+172>>2];o[a+176>>2]=la;g:{if(o[a+180>>2]-la>>2>>>0>=na>>>0){break g}if(na>>>0>=1073741824){break d}ma=na<<2;ia=Hk(ma);o[a+176>>2]=ia;o[a+172>>2]=ia;o[a+180>>2]=ia+ma;if(!la){break g}ul(la)}o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+40>>2]=o[a+36>>2];o[a- -64>>2]=0;o[a+52>>2]=o[a+48>>2];o[a+76>>2]=o[a+72>>2];va=a+216|0;ia=o[a+220>>2];la=o[a+216>>2];if((ia|0)==(la|0)){break c}while(1){ma=o[ia+ -12>>2];if(ma){o[ia+ -8>>2]=ma;ul(ma)}ma=o[ia+ -28>>2];if(ma){o[ia+ -24>>2]=ma;ul(ma)}ma=ia+ -144|0;oa=o[ia+ -40>>2];if(oa){o[ia+ -36>>2]=oa;ul(oa)}Ug(ia+ -140|0);ia=ma;if((la|0)!=(ia|0)){continue}break}ia=o[va>>2];break b}_a(8776);D()}_a(8776);D()}ia=la}o[a+220>>2]=la;ma=(la-ia|0)/144|0;h:{if(ma>>>0>>0){Vg(va,pa-ma|0);break h}if(ma>>>0<=pa>>>0){break h}ma=ia+u(pa,144)|0;if((ma|0)!=(la|0)){while(1){ia=o[la+ -12>>2];if(ia){o[la+ -8>>2]=ia;ul(ia)}ia=o[la+ -28>>2];if(ia){o[la+ -24>>2]=ia;ul(ia)}ia=la+ -144|0;oa=o[la+ -40>>2];if(oa){o[la+ -36>>2]=oa;ul(oa)}Ug(la+ -140|0);la=ia;if((ia|0)!=(ma|0)){continue}break}}o[a+220>>2]=ma}oa=0;if(!Ji(o[a+8>>2],na,sa+o[a+156>>2]|0)){break a}la=o[a+156>>2];m[qa|0]=1;$a(a+120|0,la+sa|0,qa);if((Wg(a,o[o[a+4>>2]+32>>2])|0)==-1){break a}o[a+376>>2]=a;na=a+232|0;la=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];oa=o[la>>2]+o[la+16>>2]|0;ma=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];la=o[ma+8>>2];ia=o[ma+16>>2];pi(na,oa,la-ia|0,q[o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);o[a+372>>2]=pa;la=oi(qa);ia=o[a+268>>2];o[a+304>>2]=o[a+264>>2];o[a+308>>2]=ia;ia=o[a+260>>2];o[a+296>>2]=o[a+256>>2];o[a+300>>2]=ia;ma=a+248|0;ia=o[ma+4>>2];o[a+288>>2]=o[ma>>2];o[a+292>>2]=ia;oa=a+240|0;ia=oa;pa=o[ia+4>>2];o[a+280>>2]=o[ia>>2];o[a+284>>2]=pa;ia=o[a+236>>2];pa=a+272|0;o[pa>>2]=o[a+232>>2];o[pa+4>>2]=ia;i:{j:{if(qi(pa,1,qa+56|0)){ia=o[pa+4>>2];o[na>>2]=o[pa>>2];o[na+4>>2]=ia;ia=o[pa+36>>2];o[na+32>>2]=o[pa+32>>2];o[na+36>>2]=ia;ia=o[pa+28>>2];o[na+24>>2]=o[pa+24>>2];o[na+28>>2]=ia;ia=o[pa+20>>2];o[na+16>>2]=o[pa+16>>2];o[na+20>>2]=ia;ia=o[pa+12>>2];o[na+8>>2]=o[pa+8>>2];o[na+12>>2]=ia;sa=o[oa>>2];ia=o[ma>>2];xa=sa-ia|0;wa=o[qa+60>>2];ya=o[oa+4>>2];oa=o[ma+4>>2];ma=ya-(oa+(sa>>>0>>0)|0)|0;sa=o[qa+56>>2];if((wa|0)==(ma|0)&sa>>>0<=xa>>>0|wa>>>0>>0){break j}}oa=0;break i}oa=oa+wa|0;sa=ia+sa|0;if(sa>>>0>>0){oa=oa+1|0}o[a+248>>2]=sa;o[a+252>>2]=oa;oa=0;if(!Nf(a+312|0,na)){break i}if(!Xg(na)){break i}ia=o[na+36>>2];o[qa+32>>2]=o[na+32>>2];o[qa+36>>2]=ia;ia=o[na+28>>2];o[qa+24>>2]=o[na+24>>2];o[qa+28>>2]=ia;ia=o[na+20>>2];o[qa+16>>2]=o[na+16>>2];o[qa+20>>2]=ia;ia=o[na+12>>2];o[qa+8>>2]=o[na+8>>2];o[qa+12>>2]=ia;ia=o[na+4>>2];o[qa>>2]=o[na>>2];o[qa+4>>2]=ia;ta=Yg(a,ta);if((ta|0)==-1){break i}ma=o[o[a+4>>2]+32>>2];ia=o[la+16>>2];na=ia+o[la>>2]|0;la=o[la+8>>2];pi(ma,na,la-ia|0,q[ma+38>>1]);k:{if(o[a+220>>2]==o[a+216>>2]){break k}la=o[ra>>2];if(o[la+4>>2]==o[la>>2]){break k}ia=0;while(1){if(Zg(a,ia)){ia=ia+3|0;la=o[ra>>2];if(ia>>>0>2]-o[la>>2]>>2>>>0){continue}break k}break}break i}if(p[a+308|0]){si(pa)}la=o[a+216>>2];pa=a+220|0;if((la|0)!=o[pa>>2]){ma=0;while(1){na=u(ma,144);Ui((na+la|0)+4|0,o[ra>>2]);ia=o[va>>2];oa=na+ia|0;la=o[oa+132>>2];oa=o[oa+136>>2];if((la|0)!=(oa|0)){while(1){Wi((ia+na|0)+4|0,o[la>>2]);ia=o[va>>2];la=la+4|0;if((oa|0)!=(la|0)){continue}break}}Vi((ia+na|0)+4|0);ma=ma+1|0;la=o[a+216>>2];if(ma>>>0<(o[pa>>2]-la|0)/144>>>0){continue}break}}la=o[a+8>>2];_g(a+184|0,o[la+28>>2]-o[la+24>>2]>>2);ia=o[a+216>>2];if((ia|0)!=o[pa>>2]){la=0;na=a+220|0;while(1){ia=u(la,144)+ia|0;ma=o[ia+60>>2]-o[ia+56>>2]>>2;pa=ia+104|0;ia=o[ra>>2];ia=o[ia+28>>2]-o[ia+24>>2]>>2;_g(pa,(ma|0)<(ia|0)?ia:ma);la=la+1|0;ia=o[a+216>>2];if(la>>>0<(o[na>>2]-ia|0)/144>>>0){continue}break}}oa=$g(a,ta)}}R=qa- -64|0;return oa|0}function Tg(a,ua,za){var Aa=0,Ba=0,Ca=0,Da=0;a:{if(a>>>0>5){break a}Ca=o[za+16>>2];Aa=o[za+12>>2];Ba=o[za+20>>2];if((Aa|0)<(Ba|0)?1:(Aa|0)<=(Ba|0)?r[za+8>>2]>Ca>>>0?0:1:0){break a}Aa=p[Ca+o[za>>2]|0];Ca=Ca+1|0;if(Ca>>>0<1){Ba=Ba+1|0}o[za+16>>2]=Ca;o[za+20>>2]=Ba;Ba=ua;if(Aa&128){if(!Tg(a+1|0,ua,za)){break a}a=o[ua>>2]<<7;o[ua>>2]=a;Aa=a|Aa&127}o[Ba>>2]=Aa;Da=1}return Da}function Ug(a){var ua=0;ua=o[a+84>>2];if(ua){o[a+88>>2]=ua;ul(ua)}ua=o[a+72>>2];if(ua){o[a+76>>2]=ua;ul(ua)}ua=o[a+52>>2];if(ua){o[a+56>>2]=ua;ul(ua)}ua=o[a+40>>2];if(ua){o[a+44>>2]=ua;ul(ua)}ua=o[a+28>>2];if(ua){o[a+32>>2]=ua;ul(ua)}ua=o[a+12>>2];if(ua){ul(ua)}a=o[a>>2];if(a){ul(a)}}function Vg(a,za){var Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0;Fa=R-32|0;R=Fa;a:{b:{Ga=o[a+8>>2];Ha=a+4|0;Ea=o[Ha>>2];c:{if((Ga-Ea|0)/144>>>0>=za>>>0){while(1){o[Ea>>2]=-1;Ti(Ea+4|0);o[Ea+104>>2]=0;o[Ea+108>>2]=0;m[Ea+100|0]=1;o[Ea+112>>2]=0;o[Ea+116>>2]=0;o[Ea+120>>2]=0;o[Ea+124>>2]=0;o[Ea+128>>2]=0;o[Ea+132>>2]=0;o[Ea+136>>2]=0;o[Ea+140>>2]=0;Ea=o[Ha>>2]+144|0;o[Ha>>2]=Ea;za=za+ -1|0;if(za){continue}break c}}Ia=o[a>>2];Ja=(Ea-Ia|0)/144|0;Ea=Ja+za|0;if(Ea>>>0>=29826162){break b}o[Fa+24>>2]=a+8;Ha=0;o[Fa+20>>2]=0;Ga=(Ga-Ia|0)/144|0;Ia=Ga<<1;Ga=Ga>>>0<14913080?Ia>>>0>>0?Ea:Ia:29826161;if(Ga){if(Ga>>>0>=29826162){break a}Ha=Hk(u(Ga,144))}o[Fa+8>>2]=Ha;Ea=u(Ja,144)+Ha|0;o[Fa+16>>2]=Ea;o[Fa+20>>2]=u(Ga,144)+Ha;o[Fa+12>>2]=Ea;while(1){o[Ea>>2]=-1;Ti(Ea+4|0);o[Ea+104>>2]=0;o[Ea+108>>2]=0;m[Ea+100|0]=1;o[Ea+112>>2]=0;o[Ea+116>>2]=0;o[Ea+120>>2]=0;o[Ea+124>>2]=0;o[Ea+128>>2]=0;o[Ea+132>>2]=0;o[Ea+136>>2]=0;o[Ea+140>>2]=0;Ea=o[Fa+16>>2]+144|0;o[Fa+16>>2]=Ea;za=za+ -1|0;if(za){continue}break}za=o[a+4>>2];Ga=o[a>>2];d:{if((za|0)==(Ga|0)){Ha=o[Fa+12>>2];break d}Ha=o[Fa+12>>2];while(1){za=za+ -144|0;Ha=Qh(Ha+ -144|0,za);if((za|0)!=(Ga|0)){continue}break}o[Fa+12>>2]=Ha;za=o[a+4>>2];Ga=o[a>>2]}o[a>>2]=Ha;o[Fa+12>>2]=Ga;o[a+4>>2]=Ea;o[Fa+16>>2]=za;a=a+8|0;za=o[a>>2];o[a>>2]=o[Fa+20>>2];o[Fa+8>>2]=Ga;o[Fa+20>>2]=za;Rh(Fa+8|0)}R=Fa+32|0;return}Yk();D()}_a(8776);D()}function Wg(a,za){var Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0;Ma=R-32|0;R=Ma;Pa=-1;a:{if(!Tg(1,Ma+28|0,za)){break a}Qa=o[Ma+28>>2];if(Qa){La=o[a+8>>2];if(Qa>>>0>(o[La+4>>2]-o[La>>2]>>2>>>0)/3>>>0){break a}Ta=a+36|0;Ra=a+44|0;La=a+40|0;while(1){Tg(1,Ma+12|0,za);o[Ma+20>>2]=o[Ma+12>>2]+Oa;Tg(1,Ma+12|0,za);Oa=o[Ma+20>>2];Ka=o[Ma+12>>2];if(Oa>>>0>>0){break a}o[Ma+16>>2]=Oa-Ka;Ka=o[La>>2];b:{if((Ka|0)!=o[Ra>>2]){Sa=o[Ma+20>>2];o[Ka>>2]=o[Ma+16>>2];o[Ka+4>>2]=Sa;o[Ka+8>>2]=o[Ma+24>>2];o[La>>2]=o[La>>2]+12;break b}ah(Ta,Ma+16|0)}Na=Na+1|0;if((Qa|0)!=(Na|0)){continue}break}Oa=0;qi(za,0,0);Ta=a+36|0;while(1){La=p[za+36|0];Ka=q[o[a+4>>2]+36>>1];c:{if((Ka<<24|Ka<<8&16711680)>>>16>>>0<=513){if(!La){break c}Na=0;La=o[za+32>>2];Pa=La>>>3;Ra=o[za+24>>2];Ka=Pa+Ra|0;Sa=o[za+28>>2];d:{if(Ka>>>0>=Sa>>>0){Ka=La;break d}Na=p[Ka|0];Ka=La+1|0;o[za+32>>2]=Ka;Pa=Ka>>>3;Na=Na>>>(La&7)&1}if(Pa+Ra>>>0>=Sa>>>0){break c}o[za+32>>2]=Ka+1;break c}if(!La){break c}Na=0;La=o[za+32>>2];Ka=o[za+24>>2]+(La>>>3)|0;if(Ka>>>0>=r[za+28>>2]){break c}Ka=p[Ka|0];o[za+32>>2]=La+1;Na=Ka>>>(La&7)&1}La=o[Ta>>2]+u(Oa,12)|0;m[La+8|0]=p[La+8|0]&254|Na&1;Oa=Oa+1|0;if((Qa|0)!=(Oa|0)){continue}break}si(za)}Pa=o[za+16>>2]}R=Ma+32|0;return Pa}function Xg(a){var za=0,Ua=0,Va=0,Wa=0;Ua=1;Va=o[a+140>>2];a:{if((Va|0)<1){break a}za=Va<<4;Ua=Hk((Va|0)!=(Va&268435455)?-1:za|4);o[Ua>>2]=Va;Ua=Ua+4|0;Va=Ua+za|0;za=Ua;while(1){za=Mf(za)+16|0;if((Va|0)!=(za|0)){continue}break}Wa=o[a+136>>2];o[a+136>>2]=Ua;if(Wa){Va=Wa+ -4|0;Ua=o[Va>>2];if(Ua){za=Wa+(Ua<<4)|0;while(1){za=za+ -16|0;if((Wa|0)!=(za|0)){continue}break}}ul(Va)}Ua=1;if(o[a+140>>2]<1){break a}Ua=0;za=0;while(1){if(!Nf(o[a+136>>2]+(za<<4)|0,a)){break a}za=za+1|0;if((za|0)>2]){continue}break}Ua=1}return Ua}function Yg(a,Xa){var Ya=0,Za=0,_a=0,$a=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,mb=0,nb=0,ob=0,pb=0,qb=0,rb=0,sb=0,tb=0;$a=R-96|0;R=$a;o[$a+72>>2]=0;o[$a+64>>2]=0;o[$a+68>>2]=0;o[$a+48>>2]=0;o[$a+52>>2]=0;o[$a+40>>2]=0;o[$a+44>>2]=0;o[$a+56>>2]=1065353216;o[$a+32>>2]=0;o[$a+24>>2]=0;o[$a+28>>2]=0;rb=o[a+124>>2];a:{b:{c:{d:{if((Xa|0)>=1){qb=a+8|0;nb=o[a+216>>2]!=o[a+220>>2];ob=a+40|0;while(1){e:{f:{g:{h:{i:{j:{k:{if(!p[a+308|0]){break k}l:{m:{eb=o[a+296>>2];gb=o[a+304>>2];Ya=eb+(gb>>>3)|0;cb=o[a+300>>2];if(Ya>>>0>=cb>>>0){break m}Ya=p[Ya|0];Za=gb+1|0;o[a+304>>2]=Za;if(!(Ya>>>(gb&7)&1)){break m}Ya=Za>>>3;_a=eb+Ya|0;n:{if(_a>>>0>=cb>>>0){_a=Za;Za=0;break n}db=p[_a|0];_a=gb+2|0;o[a+304>>2]=_a;Ya=_a>>>3;Za=db>>>(Za&7)&1}Ya=Ya+eb|0;if(Ya>>>0>>0){Ya=p[Ya|0];o[a+304>>2]=_a+1;Ya=Ya>>>(_a&7)<<1&2}else{Ya=0}Ya=(Za|Ya)<<1|1;switch(Ya+ -2|0){case 0:case 2:case 4:break h;case 5:break j;case 1:case 3:break l;default:break k}}Za=o[$a+68>>2];if((Za|0)==o[$a+64>>2]){break d}eb=-1;ib=o[qb>>2];cb=o[ib+24>>2];_a=cb;db=Za+ -4|0;lb=o[db>>2];Ya=-1;o:{if((lb|0)==-1){break o}Za=lb+1|0;Za=(Za>>>0)%3|0?Za:lb+ -2|0;Ya=-1;if((Za|0)==-1){break o}Ya=o[o[ib>>2]+(Za<<2)>>2]}_a=o[_a+(Ya<<2)>>2];if((_a|0)!=-1){Za=_a+1|0;eb=(Za>>>0)%3|0?Za:_a+ -2|0}_a=o[ib+12>>2];jb=u(bb,3);Za=jb+1|0;o[_a+(lb<<2)>>2]=Za;Za=Za<<2;o[Za+_a>>2]=lb;hb=jb+2|0;o[_a+(eb<<2)>>2]=hb;gb=hb<<2;o[gb+_a>>2]=eb;kb=o[ib>>2];o[kb+(jb<<2)>>2]=Ya;_a=Za+kb|0;fb=-1;p:{if((eb|0)==-1){break p}Za=eb+1|0;Za=(Za>>>0)%3|0?Za:eb+ -2|0;fb=-1;if((Za|0)==-1){break p}fb=o[kb+(Za<<2)>>2]}o[_a>>2]=fb;q:{r:{if((lb|0)!=-1){Za=lb+((lb>>>0)%3|0?-1:2)|0;if((Za|0)!=-1){break r}}o[gb+kb>>2]=-1;break q}Za=o[kb+(Za<<2)>>2];o[gb+kb>>2]=Za;if((Za|0)==-1){break q}o[cb+(Za<<2)>>2]=hb}_a=o[a+120>>2]+(Ya>>>3&536870908)|0;Za=o[_a>>2];sb=_a,tb=Zl(Ya)&Za,o[sb>>2]=tb;o[db>>2]=jb;break e}_a=o[$a+68>>2];if((_a|0)==o[$a+64>>2]){break d}gb=o[qb>>2];Za=o[gb+12>>2];hb=u(bb,3);eb=(Ya|0)==5;cb=hb+(eb?2:1)|0;Ya=cb<<2;kb=o[_a+ -4>>2];o[Za+Ya>>2]=kb;o[Za+(kb<<2)>>2]=cb;db=gb+24|0;_a=gb+28|0;Za=o[_a>>2];s:{if((Za|0)!=o[gb+32>>2]){o[Za>>2]=-1;ib=Za+4|0;o[_a>>2]=ib;break s}bh(db,8212);ib=o[_a>>2]}_a=-1;Za=o[qb>>2];gb=o[Za+24>>2];if(o[Za+28>>2]-gb>>2>(rb|0)){break c}_a=hb+2|0;jb=o[Za>>2];fb=jb+Ya|0;Za=ib-o[db>>2]|0;Ya=(Za>>2)+ -1|0;o[fb>>2]=Ya;if(Za){o[gb+(Ya<<2)>>2]=cb}_a=eb?hb:_a;Za=jb+(eb+hb<<2)|0;t:{u:{v:{if((kb|0)!=-1){Ya=kb+((kb>>>0)%3|0?-1:2)|0;if((Ya|0)==-1){break v}Ya=o[jb+(Ya<<2)>>2];o[jb+(_a<<2)>>2]=Ya;if((Ya|0)==-1){break u}o[gb+(Ya<<2)>>2]=_a;break u}o[jb+(_a<<2)>>2]=-1;_a=-1;break t}o[jb+(_a<<2)>>2]=-1}Ya=kb+1|0;Ya=(Ya>>>0)%3|0?Ya:kb+ -2|0;_a=-1;if((Ya|0)==-1){break t}_a=o[jb+(Ya<<2)>>2]}o[Za>>2]=_a;o[o[$a+68>>2]+ -4>>2]=hb;break i}_a=-1;Ya=o[$a+68>>2];ib=o[$a+64>>2];if((Ya|0)==(ib|0)){break c}Za=Ya+ -4|0;mb=o[Za>>2];o[$a+68>>2]=Za;hb=o[$a+44>>2];w:{if(!hb){Ya=Za;break w}cb=o[$a+40>>2];gb=Yl(hb)>>>0>1;db=hb+2147483647&bb;x:{if(!gb){break x}db=bb;if(bb>>>0>>0){break x}db=(bb>>>0)%(hb>>>0)|0}cb=o[cb+(db<<2)>>2];if(!cb){Ya=Za;break w}fb=o[cb>>2];if(!fb){Ya=Za;break w}cb=hb+ -1|0;y:{while(1){eb=o[fb+4>>2];z:{if((eb|0)!=(bb|0)){A:{if(!gb){eb=eb&cb;break A}if(eb>>>0>>0){break A}eb=(eb>>>0)%(hb>>>0)|0}if((eb|0)==(db|0)){break z}Ya=Za;break w}if(o[fb+8>>2]==(bb|0)){break y}}fb=o[fb>>2];if(fb){continue}break}Ya=Za;break w}db=fb+12|0;if((Za|0)!=o[$a+72>>2]){o[Za>>2]=o[db>>2];o[$a+68>>2]=Ya;break w}bh($a- -64|0,db);Ya=o[$a+68>>2];ib=o[$a+64>>2]}if((Ya|0)==(ib|0)){break c}lb=o[Ya+ -4>>2];db=(lb|0)==-1;pb=o[qb>>2];if(o[o[pb+12>>2]+(lb<<2)>>2]!=-1?!db:0){break c}gb=(mb|0)==-1;hb=pb+12|0;cb=o[hb>>2];if(o[cb+(mb<<2)>>2]!=-1?!gb:0){break c}kb=u(bb,3);ib=kb+2|0;o[cb+(lb<<2)>>2]=ib;jb=ib<<2;o[jb+cb>>2]=lb;Za=kb+1|0;o[cb+(mb<<2)>>2]=Za;eb=cb;cb=Za<<2;o[eb+cb>>2]=mb;if(db){break g}eb=-1;db=o[pb>>2];fb=db+(kb<<2)|0;Za=lb+((lb>>>0)%3|0?-1:2)|0;if((Za|0)!=-1){eb=o[(Za<<2)+db>>2]}o[fb>>2]=eb;Za=lb+1|0;Za=(Za>>>0)%3|0?Za:lb+ -2|0;if((Za|0)==-1){break f}_a=o[(Za<<2)+db>>2];break f}o[$a>>2]=u(bb,3);Ya=o[qb>>2];_a=Ya+24|0;cb=o[Ya+32>>2];Za=Ya+28|0;Ya=o[Za>>2];B:{if((cb|0)!=(Ya|0)){o[Ya>>2]=-1;Ya=Ya+4|0;o[Za>>2]=Ya;break B}bh(_a,8212);Ya=o[Za>>2]}ib=o[qb>>2];eb=o[ib>>2];Za=o[$a>>2];gb=Ya-o[_a>>2]|0;hb=gb>>2;_a=hb+ -1|0;o[eb+(Za<<2)>>2]=_a;Za=Za+1|0;cb=ib+24|0;db=ib+28|0;Ya=o[db>>2];C:{if((Ya|0)!=o[ib+32>>2]){o[Ya>>2]=-1;Ya=Ya+4|0;o[db>>2]=Ya;break C}bh(cb,8212);Ya=o[db>>2];eb=o[ib>>2]}o[(Za<<2)+eb>>2]=(Ya-o[cb>>2]>>2)+ -1;Ya=o[$a>>2]+2|0;cb=o[qb>>2];Za=cb+28|0;db=o[Za>>2];D:{if((db|0)!=o[cb+32>>2]){o[db>>2]=-1;eb=db+4|0;o[Za>>2]=eb;break D}bh(cb+24|0,8212);eb=o[Za>>2]}o[o[cb>>2]+(Ya<<2)>>2]=(eb-o[cb+24>>2]>>2)+ -1;Ya=o[qb>>2];Za=o[Ya+24>>2];if(o[Ya+28>>2]-Za>>2>(rb|0)){break d}Ya=o[$a>>2];E:{F:{if(!gb){eb=1;o[Za+(hb<<2)>>2]=Ya+1;break F}o[Za+(_a<<2)>>2]=Ya;eb=0;if((gb|0)==-4){break F}o[Za+(hb<<2)>>2]=o[$a>>2]+1;eb=hb+1|0;if((eb|0)==-1){break E}}o[Za+(eb<<2)>>2]=o[$a>>2]+2}Ya=o[$a+68>>2];if((Ya|0)!=o[$a+72>>2]){o[Ya>>2]=o[$a>>2];o[$a+68>>2]=Ya+4;break i}bh($a- -64|0,$a)}fb=o[ob>>2];if((fb|0)==o[a+36>>2]){break e}cb=(bb^-1)+Xa|0;while(1){_a=-1;Ya=o[fb+ -8>>2];if(Ya>>>0>cb>>>0){break c}if((Ya|0)!=(cb|0)){break e}Za=p[fb+ -4|0];Ya=fb+ -12|0;db=o[Ya>>2];o[ob>>2]=Ya;if((db|0)<0){break c}_a=o[o[$a+68>>2]+ -4>>2];o[$a+20>>2]=(db^-1)+Xa;o[$a+88>>2]=$a+20;ch($a,$a+40|0,$a+20|0,$a+88|0);db=o[$a>>2];G:{if(Za&1){Ya=-1;if((_a|0)==-1){break G}Ya=_a+1|0;Ya=(Ya>>>0)%3|0?Ya:_a+ -2|0;break G}Ya=-1;if((_a|0)==-1){break G}Ya=_a+ -1|0;if((_a>>>0)%3){break G}Ya=_a+2|0}o[db+12>>2]=Ya;fb=o[ob>>2];if((fb|0)!=o[a+36>>2]){continue}break}break e}D()}eb=-1;db=o[pb>>2];o[db+(kb<<2)>>2]=-1}o[cb+db>>2]=_a;H:{I:{J:{if(!gb){Za=mb+((mb>>>0)%3|0?-1:2)|0;if((Za|0)==-1){break J}Za=o[(Za<<2)+db>>2];o[db+jb>>2]=Za;if((Za|0)==-1){break I}o[o[pb+24>>2]+(Za<<2)>>2]=ib;break I}o[db+jb>>2]=-1;fb=-1;_a=-1;break H}o[db+jb>>2]=-1}fb=-1;Za=mb+1|0;Za=(Za>>>0)%3|0?Za:mb+ -2|0;_a=-1;if((Za|0)==-1){break H}fb=o[(Za<<2)+db>>2];_a=Za}o[$a>>2]=fb;cb=o[pb+24>>2];if((eb|0)!=-1){o[cb+(eb<<2)>>2]=o[cb+(fb<<2)>>2]}K:{if((_a|0)==-1){break K}db=o[pb>>2];while(1){o[db+(_a<<2)>>2]=eb;Za=_a+1|0;Za=(Za>>>0)%3|0?Za:_a+ -2|0;if((Za|0)==-1){break K}_a=o[o[hb>>2]+(Za<<2)>>2];if((_a|0)==-1){break K}Za=_a+1|0;_a=(Za>>>0)%3|0?Za:_a+ -2|0;if((_a|0)!=-1){continue}break}}o[cb+(o[$a>>2]<<2)>>2]=-1;L:{if(nb){break L}Za=o[$a+28>>2];if((Za|0)!=o[$a+32>>2]){o[Za>>2]=o[$a>>2];o[$a+28>>2]=Za+4;break L}bh($a+24|0,$a);Ya=o[$a+68>>2]}o[Ya+ -4>>2]=kb}bb=bb+1|0;if((bb|0)!=(Xa|0)){continue}break}eb=Xa}_a=-1;fb=o[a+8>>2];if(o[fb+28>>2]-o[fb+24>>2]>>2>(rb|0)){break c}bb=o[$a+68>>2];if((bb|0)!=o[$a+64>>2]){lb=a+72|0;Za=a+60|0;ib=a+312|0;nb=a+8|0;kb=a+68|0;rb=a+80|0;pb=a+76|0;while(1){Ya=bb+ -4|0;Xa=o[Ya>>2];o[$a+68>>2]=Ya;o[$a>>2]=Xa;M:{if(Pf(ib)){hb=o[nb>>2];mb=o[hb>>2];if((eb|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(Xa)&Ya,o[sb>>2]=tb;bb=-1;bb=(gb|0)!=-1?o[cb>>2]:bb;Ya=jb+(bb>>>3&536870908)|0;Xa=o[Ya>>2];sb=Ya,tb=Zl(bb)&Xa,o[sb>>2]=tb;bb=o[a+64>>2];Ya=o[kb>>2];if((bb|0)==Ya<<5){if((bb+1|0)<=-1){break a}Xa=Za;if(bb>>>0<=1073741822){db=bb+32&-32;Ya=Ya<<6;Ya=Ya>>>0>>0?db:Ya}else{Ya=2147483647}ab(Xa,Ya);bb=o[a+64>>2]}eb=eb+1|0;o[a+64>>2]=bb+1;Xa=o[a+60>>2]+(bb>>>3&536870908)|0;o[Xa>>2]=o[Xa>>2]|1<<(bb&31);Xa=o[pb>>2];if((Xa|0)!=o[rb>>2]){o[Xa>>2]=o[$a+88>>2];o[pb>>2]=Xa+4;break M}bh(lb,$a+88|0);break M}bb=o[a+64>>2];Ya=o[kb>>2];if((bb|0)==Ya<<5){if((bb+1|0)<=-1){break a}Xa=Za;if(bb>>>0<=1073741822){db=bb+32&-32;Ya=Ya<<6;Ya=Ya>>>0>>0?db:Ya}else{Ya=2147483647}ab(Xa,Ya);bb=o[a+64>>2]}o[a+64>>2]=bb+1;Ya=o[a+60>>2]+(bb>>>3&536870908)|0;Xa=o[Ya>>2];sb=Ya,tb=Zl(bb)&Xa,o[sb>>2]=tb;Xa=o[pb>>2];if((Xa|0)!=o[rb>>2]){o[Xa>>2]=o[$a>>2];o[pb>>2]=Xa+4;break M}bh(lb,$a)}bb=o[$a+68>>2];if((bb|0)!=o[$a+64>>2]){continue}break}fb=o[a+8>>2]}if(((o[fb+4>>2]-o[fb>>2]>>2>>>0)/3|0)!=(eb|0)){break c}_a=o[fb+28>>2]-o[fb+24>>2]>>2;nb=o[$a+24>>2];cb=o[$a+28>>2];if((nb|0)==(cb|0)){break b}db=a+8|0;while(1){hb=o[nb>>2];eb=o[fb+24>>2];bb=_a+ -1|0;Q:{if(o[eb+(bb<<2)>>2]!=-1){Ya=_a;break Q}eb=o[fb+24>>2];while(1){bb=_a+ -2|0;Ya=_a+ -1|0;_a=Ya;if(o[(bb<<2)+eb>>2]==-1){continue}break}}if(!(bb>>>0>>0)){o[$a>>2]=fb;Xa=bb<<2;_a=o[Xa+eb>>2];m[$a+12|0]=1;o[$a+8>>2]=_a;o[$a+4>>2]=_a;if((_a|0)!=-1){while(1){o[o[fb>>2]+(_a<<2)>>2]=hb;jf($a);fb=o[db>>2];_a=o[$a+8>>2];if((_a|0)!=-1){continue}break}}Za=Xa;Xa=o[fb+24>>2];Za=Za+Xa|0;if((hb|0)!=-1){o[Xa+(hb<<2)>>2]=o[Za>>2]}o[Za>>2]=-1;gb=1<<(hb&31);Xa=o[a+120>>2];_a=Xa+(hb>>>3&536870908)|0;Za=_a;eb=Xa+(bb>>>3&536870908)|0;Xa=1<<(bb&31);bb=gb|o[_a>>2];R:{if(o[eb>>2]&Xa){break R}bb=o[_a>>2]&(gb^-1)}o[Za>>2]=bb;o[eb>>2]=o[eb>>2]&(Xa^-1);Ya=Ya+ -1|0}_a=Ya;nb=nb+4|0;if((cb|0)!=(nb|0)){continue}break}break c}_a=-1}nb=o[$a+24>>2]}if(nb){o[$a+28>>2]=nb;ul(nb)}bb=o[$a+48>>2];if(bb){while(1){a=o[bb>>2];ul(bb);bb=a;if(bb){continue}break}}a=o[$a+40>>2];o[$a+40>>2]=0;if(a){ul(a)}a=o[$a+64>>2];if(a){o[$a+68>>2]=a;ul(a)}R=$a+96|0;return _a}Yk();D()}function Zg(a,Xa){var ab=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0;ub=R-32|0;R=ub;o[ub+16>>2]=Xa;ab=-1;a:{if((Xa|0)==-1){o[ub+20>>2]=-1;break a}ab=Xa+1|0;o[ub+20>>2]=(ab>>>0)%3|0?ab:Xa+ -2|0;if((Xa>>>0)%3){ab=Xa+ -1|0;break a}ab=Xa+2|0}o[ub+24>>2]=ab;Cb=(Xa|0)==-1?-1:(Xa>>>0)/3|0;yb=a+220|0;Db=a+8|0;Eb=a+368|0;while(1){b:{c:{if((Xa|0)!=-1){ab=o[o[o[Db>>2]+12>>2]+(Xa<<2)>>2];if((ab|0)!=-1){break c}}ab=0;vb=o[a+216>>2];wb=o[yb>>2];if((vb|0)==(wb|0)){break b}while(1){o[ub+12>>2]=Xa;xb=u(ab,144)+vb|0;Bb=xb+136|0;zb=o[Bb>>2];d:{if(zb>>>0>2]){o[zb>>2]=Xa;o[Bb>>2]=zb+4;break d}wa(xb+132|0,ub+12|0);wb=o[yb>>2];vb=o[a+216>>2]}ab=ab+1|0;if(ab>>>0<(wb-vb|0)/144>>>0){continue}break}break b}if((ab>>>0)/3>>>0>>0){break b}ab=0;if(o[yb>>2]==o[a+216>>2]){break b}while(1){e:{if(!Pf(o[Eb>>2]+(ab<<4)|0)){break e}vb=o[a+216>>2];o[ub+12>>2]=Xa;vb=vb+u(ab,144)|0;xb=vb+136|0;wb=o[xb>>2];if(wb>>>0>2]){o[wb>>2]=Xa;o[xb>>2]=wb+4;break e}wa(vb+132|0,ub+12|0)}ab=ab+1|0;if(ab>>>0<(o[yb>>2]-o[a+216>>2]|0)/144>>>0){continue}break}}Ab=Ab+1|0;if((Ab|0)!=3){Xa=o[(ub+16|0)+(Ab<<2)>>2];continue}break}R=ub+32|0;return 1}function _g(a,Xa){var Fb=0,Gb=0,Hb=0,Ib=0,Jb=0;Gb=o[a+12>>2];Fb=o[a+16>>2]-Gb>>2;a:{if(Fb>>>0>>0){Da(a+12|0,Xa-Fb|0);break a}if(Fb>>>0<=Xa>>>0){break a}o[a+16>>2]=Gb+(Xa<<2)}b:{Fb=o[a>>2];c:{if(o[a+8>>2]-Fb>>2>>>0>=Xa>>>0){break c}if(Xa>>>0>=1073741824){break b}Ib=a+4|0;Gb=o[Ib>>2];Hb=Xa<<2;Xa=Hk(Hb);Hb=Xa+Hb|0;Gb=Gb-Fb|0;Jb=Gb+Xa|0;if((Gb|0)>=1){wl(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>2];if((Kb|0)==-1){break i}Kb=Kb+((Kb>>>0)%3|0?-1:2)|0;if((Kb|0)==-1){break i}Ob=Xa;if((Kb|0)!=(Mb|0)){continue}break}}Qb=Qb+1|0;if((Qb|0)>2]-o[Nb+24>>2]>>2){continue}break}break g}Yk();D()}Mb=o[a+4>>2];a=o[Mb+44>>2];Xa=o[a+100>>2];a=o[a+96>>2];if((Xa|0)!=(a|0)){Ob=(Xa-a|0)/12|0;Kb=0;Nb=o[Lb+16>>2];while(1){Qb=Lb+8|0;Pb=u(Kb,12);Xa=Pb+Nb|0;o[Qb>>2]=o[Xa+8>>2];Sb=o[Xa+4>>2];Tb=o[Xa>>2];o[Lb>>2]=Tb;o[Lb+4>>2]=Sb;Xa=a+Pb|0;o[Xa>>2]=Tb;o[Xa+4>>2]=o[Lb+4>>2];o[Xa+8>>2]=o[Qb>>2];Kb=Kb+1|0;if(Kb>>>0>>0){continue}break}}o[o[Mb+4>>2]+80>>2]=o[Lb+36>>2]-o[Lb+32>>2]>>2;Xa=1}Kb=Xa;a=o[Lb+16>>2];if(a){o[Lb+20>>2]=a;ul(a)}a=o[Lb+32>>2];if(!a){break b}o[Lb+36>>2]=a;ul(a)}R=Lb+48|0;return Kb}function ah(a,Xa){var _b=0,$b=0,ac=0,bc=0,cc=0,dc=0;a:{bc=o[a>>2];cc=o[a+4>>2]-bc|0;_b=(cc|0)/12|0;$b=_b+1|0;if($b>>>0<357913942){dc=u(_b,12);ac=(o[a+8>>2]-bc|0)/12|0;_b=ac<<1;ac=ac>>>0<178956970?_b>>>0<$b>>>0?$b:_b:357913941;_b=0;b:{if(!ac){break b}if(ac>>>0>=357913942){break a}_b=Hk(u(ac,12))}$b=dc+_b|0;dc=o[Xa+4>>2];o[$b>>2]=o[Xa>>2];o[$b+4>>2]=dc;o[$b+8>>2]=o[Xa+8>>2];Xa=$b+u((cc|0)/-12|0,12)|0;_b=_b+u(ac,12)|0;$b=$b+12|0;if((cc|0)>=1){wl(Xa,bc,cc)}o[a>>2]=Xa;o[a+8>>2]=_b;o[a+4>>2]=$b;if(bc){ul(bc)}return}Yk();D()}_a(8776);D()}function bh(a,Xa){var ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;a:{gc=o[a>>2];ic=o[a+4>>2]-gc|0;ec=ic>>2;fc=ec+1|0;if(fc>>>0<1073741824){jc=ec<<2;ec=o[a+8>>2]-gc|0;hc=ec>>1;fc=ec>>2>>>0<536870911?hc>>>0>>0?fc:hc:1073741823;ec=0;b:{if(!fc){break b}if(fc>>>0>=1073741824){break a}ec=Hk(fc<<2)}hc=jc+ec|0;o[hc>>2]=o[Xa>>2];Xa=ec+(fc<<2)|0;fc=hc+4|0;if((ic|0)>=1){wl(ec,gc,ic)}o[a>>2]=ec;o[a+8>>2]=Xa;o[a+4>>2]=fc;if(gc){ul(gc)}return}Yk();D()}_a(8776);D()}function ch(a,Xa,kc,lc){var mc=0,nc=0,oc=0,pc=0,qc=0,rc=v(0),sc=0,tc=v(0),uc=0;mc=o[kc>>2];uc=a;a:{b:{nc=o[Xa+4>>2];if(!nc){break b}sc=o[Xa>>2];pc=Yl(nc);kc=nc+ -1&mc;c:{if(pc>>>0<=1){break c}kc=mc;if(mc>>>0>>0){break c}kc=(mc>>>0)%(nc>>>0)|0}oc=kc;kc=o[(kc<<2)+sc>>2];if(!kc){break b}sc=nc+ -1|0;pc=pc>>>0>1;while(1){kc=o[kc>>2];if(!kc){break b}qc=o[kc+4>>2];if((qc|0)!=(mc|0)){d:{if(!pc){qc=qc≻break d}if(qc>>>0>>0){break d}qc=(qc>>>0)%(nc>>>0)|0}if((oc|0)!=(qc|0)){break b}}if(o[kc+8>>2]!=(mc|0)){continue}break}Xa=0;break a}kc=Hk(16);lc=o[o[lc>>2]>>2];o[kc+12>>2]=0;o[kc+8>>2]=lc;o[kc+4>>2]=mc;o[kc>>2]=0;tc=s[Xa+16>>2];rc=v(o[Xa+12>>2]+1>>>0);e:{if(!(!nc|!!(v(tc*v(nc>>>0))>>0<3|nc<<1;lc=Xa;rc=v(B(v(rc/tc)));f:{if(rc=v(0)){pc=~~rc>>>0;break f}pc=0}Sh(lc,oc>>>0>>0?pc:oc);nc=o[Xa+4>>2];if(!(nc&nc+ -1)){mc=nc+ -1&mc;break e}if(mc>>>0>>0){break e}mc=(mc>>>0)%(nc>>>0)|0}lc=o[Xa>>2]+(mc<<2)|0;mc=o[lc>>2];g:{h:{if(!mc){oc=Xa+8|0;o[kc>>2]=o[oc>>2];o[oc>>2]=kc;o[lc>>2]=oc;lc=o[kc>>2];if(!lc){break g}mc=o[lc+4>>2];lc=nc+ -1|0;i:{if(!(lc&nc)){mc=lc&mc;break i}if(mc>>>0>>0){break i}mc=(mc>>>0)%(nc>>>0)|0}mc=o[Xa>>2]+(mc<<2)|0;break h}o[kc>>2]=o[mc>>2]}o[mc>>2]=kc}Xa=Xa+12|0;o[Xa>>2]=o[Xa>>2]+1;Xa=1}m[uc+4|0]=Xa;o[a>>2]=kc}function dh(a,Xa,kc){var lc=0,vc=0,wc=0,xc=0,yc=0;a:{b:{xc=o[a+8>>2];vc=a+4|0;lc=o[vc>>2];c:{if((xc-lc|0)/12>>>0>=Xa>>>0){while(1){a=o[kc+4>>2];o[lc>>2]=o[kc>>2];o[lc+4>>2]=a;o[lc+8>>2]=o[kc+8>>2];lc=o[vc>>2]+12|0;o[vc>>2]=lc;Xa=Xa+ -1|0;if(Xa){continue}break c}}wc=o[a>>2];yc=(lc-wc|0)/12|0;vc=yc+Xa|0;if(vc>>>0>=357913942){break b}xc=(xc-wc|0)/12|0;wc=xc<<1;vc=xc>>>0<178956970?wc>>>0>>0?vc:wc:357913941;lc=0;d:{if(!vc){break d}if(vc>>>0>=357913942){break a}lc=Hk(u(vc,12))}xc=lc+u(vc,12)|0;vc=lc+u(yc,12)|0;lc=vc;while(1){wc=o[kc+4>>2];o[lc>>2]=o[kc>>2];o[lc+4>>2]=wc;o[lc+8>>2]=o[kc+8>>2];lc=lc+12|0;Xa=Xa+ -1|0;if(Xa){continue}break}wc=a+4|0;Xa=o[a>>2];kc=o[wc>>2]-Xa|0;vc=vc+u((kc|0)/-12|0,12)|0;if((kc|0)>=1){wl(vc,Xa,kc)}o[a>>2]=vc;o[a+8>>2]=xc;o[wc>>2]=lc;if(!Xa){break c}ul(Xa)}return}Yk();D()}_a(8776);D()}function eh(a){a=a|0;return o[a+8>>2]}function fh(a){o[a>>2]=8224;xl(a+4|0,0,80);o[a+96>>2]=0;o[a+100>>2]=0;o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+104>>2]=0;o[a+108>>2]=0;o[a+112>>2]=0;o[a+116>>2]=0;o[a+120>>2]=0;o[a+124>>2]=0;o[a+128>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+140>>2]=0;o[a+144>>2]=0;o[a+148>>2]=0;o[a+156>>2]=0;o[a+160>>2]=0;o[a+152>>2]=1065353216;o[a+164>>2]=0;o[a+168>>2]=0;o[a+172>>2]=0;o[a+176>>2]=0;o[a+180>>2]=0;o[a+184>>2]=0;o[a+188>>2]=0;o[a+192>>2]=0;o[a+196>>2]=0;o[a+200>>2]=0;o[a+204>>2]=0;o[a+208>>2]=0;o[a+212>>2]=-1;o[a+216>>2]=0;o[a+220>>2]=0;o[a+224>>2]=0;Hg(a+232|0);o[a+388>>2]=0;o[a+392>>2]=0;o[a+380>>2]=0;o[a+384>>2]=0;o[a+416>>2]=0;o[a+420>>2]=0;o[a+412>>2]=7;o[a+404>>2]=-1;o[a+408>>2]=2;o[a+396>>2]=0;o[a+400>>2]=-1;o[a+424>>2]=0;o[a+428>>2]=0;o[a+432>>2]=0;o[a+436>>2]=0}function gh(a){a=a|0;var Xa=0,kc=0,zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0,Fc=0,Gc=0,Hc=0,Ic=0,Jc=0,Kc=0;Bc=R+ -64|0;R=Bc;o[a+132>>2]=0;if(o[a+148>>2]){zc=a+144|0;Xa=o[zc>>2];if(Xa){while(1){kc=o[Xa>>2];ul(Xa);Xa=kc;if(Xa){continue}break}}o[zc>>2]=0;kc=o[a+140>>2];if(kc){zc=a+136|0;Xa=0;while(1){o[o[zc>>2]+(Xa<<2)>>2]=0;Xa=Xa+1|0;if((kc|0)!=(Xa|0)){continue}break}}o[a+148>>2]=0}a:{if(!Tg(1,Bc+60|0,o[o[a+4>>2]+32>>2])){break a}o[a+156>>2]=o[Bc+60>>2];if(!Tg(1,Bc+56|0,o[o[a+4>>2]+32>>2])){break a}Ac=o[Bc+56>>2];if(Ac>>>0>1431655765|r[a+156>>2]>u(Ac,3)>>>0){break a}Xa=o[o[a+4>>2]+32>>2];Cc=o[Xa+16>>2];zc=o[Xa+12>>2];kc=o[Xa+20>>2];if((zc|0)<(kc|0)?1:(zc|0)<=(kc|0)?r[Xa+8>>2]>Cc>>>0?0:1:0){break a}Dc=p[Cc+o[Xa>>2]|0];Cc=Cc+1|0;if(Cc>>>0<1){kc=kc+1|0}o[Xa+16>>2]=Cc;o[Xa+20>>2]=kc;if(!Tg(1,Bc+52|0,Xa)){break a}Gc=o[Bc+52>>2];if(Ac>>>0>>0|Ac>>>0>Gc+((Gc>>>0)/3|0)>>>0){break a}if(!Tg(1,Bc+48|0,o[o[a+4>>2]+32>>2])){break a}Ec=o[Bc+48>>2];if(Ec>>>0>Gc>>>0){break a}o[a+28>>2]=o[a+24>>2];kc=Hk(88);zi(kc);Xa=o[a+8>>2];o[a+8>>2]=kc;Cc=a+8|0;if(Xa){ua(Cc,Xa);if(!o[Cc>>2]){break a}}Xa=o[a+160>>2];o[a+164>>2]=Xa;b:{c:{d:{e:{f:{if(o[a+168>>2]-Xa>>2>>>0>=Ac>>>0){break f}if(Ac>>>0>=1073741824){break e}zc=Ac<<2;kc=Hk(zc);o[a+164>>2]=kc;o[a+160>>2]=kc;o[a+168>>2]=kc+zc;if(!Xa){break f}ul(Xa)}Xa=o[a+172>>2];o[a+176>>2]=Xa;g:{if(o[a+180>>2]-Xa>>2>>>0>=Ac>>>0){break g}if(Ac>>>0>=1073741824){break d}zc=Ac<<2;kc=Hk(zc);o[a+176>>2]=kc;o[a+172>>2]=kc;o[a+180>>2]=kc+zc;if(!Xa){break g}ul(Xa)}o[a+92>>2]=-1;o[a+84>>2]=-1;o[a+88>>2]=-1;o[a+40>>2]=o[a+36>>2];o[a- -64>>2]=0;o[a+52>>2]=o[a+48>>2];o[a+76>>2]=o[a+72>>2];Hc=a+216|0;kc=o[a+220>>2];Xa=o[a+216>>2];if((kc|0)==(Xa|0)){break c}while(1){zc=o[kc+ -12>>2];if(zc){o[kc+ -8>>2]=zc;ul(zc)}zc=o[kc+ -28>>2];if(zc){o[kc+ -24>>2]=zc;ul(zc)}zc=kc+ -144|0;Fc=o[kc+ -40>>2];if(Fc){o[kc+ -36>>2]=Fc;ul(Fc)}Ug(kc+ -140|0);kc=zc;if((Xa|0)!=(kc|0)){continue}break}kc=o[Hc>>2];break b}_a(8776);D()}_a(8776);D()}kc=Xa}o[a+220>>2]=Xa;zc=(Xa-kc|0)/144|0;h:{if(zc>>>0>>0){Vg(Hc,Dc-zc|0);break h}if(zc>>>0<=Dc>>>0){break h}zc=kc+u(Dc,144)|0;if((zc|0)!=(Xa|0)){while(1){kc=o[Xa+ -12>>2];if(kc){o[Xa+ -8>>2]=kc;ul(kc)}kc=o[Xa+ -28>>2];if(kc){o[Xa+ -24>>2]=kc;ul(kc)}kc=Xa+ -144|0;Fc=o[Xa+ -40>>2];if(Fc){o[Xa+ -36>>2]=Fc;ul(Fc)}Ug(Xa+ -140|0);Xa=kc;if((Xa|0)!=(zc|0)){continue}break}}o[a+220>>2]=zc}Fc=0;if(!Ji(o[a+8>>2],Ac,Ec+o[a+156>>2]|0)){break a}Xa=o[a+156>>2];m[Bc+8|0]=1;$a(a+120|0,Xa+Ec|0,Bc+8|0);if((Wg(a,o[o[a+4>>2]+32>>2])|0)==-1){break a}o[a+376>>2]=a;Ac=a+232|0;Xa=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];Ic=o[Xa>>2]+o[Xa+16>>2]|0;zc=o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2];Xa=o[zc+8>>2];kc=o[zc+16>>2];pi(Ac,Ic,Xa-kc|0,q[o[(l[o[o[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);Jc=a,Kc=l[o[o[a>>2]+36>>2]](a)|0,o[Jc+380>>2]=Kc;o[a+372>>2]=Dc;o[a+384>>2]=Ec+o[a+156>>2];Xa=oi(Bc+8|0);i:{if(!hh(Ac,Xa)){break i}Gc=ih(a,Gc);if((Gc|0)==-1){break i}zc=o[o[a+4>>2]+32>>2];kc=o[Xa+16>>2];Dc=kc+o[Xa>>2]|0;Xa=o[Xa+8>>2];pi(zc,Dc,Xa-kc|0,q[zc+38>>1]);j:{if(o[a+220>>2]==o[a+216>>2]){break j}Xa=o[Cc>>2];if(o[Xa+4>>2]==o[Xa>>2]){break j}Xa=0;while(1){if(Zg(a,Xa)){Xa=Xa+3|0;kc=o[Cc>>2];if(Xa>>>0>2]-o[kc>>2]>>2>>>0){continue}break j}break}break i}if(p[a+308|0]){si(a+272|0)}Xa=o[a+216>>2];Dc=a+220|0;if((Xa|0)!=o[Dc>>2]){zc=0;while(1){Ac=u(zc,144);Ui((Ac+Xa|0)+4|0,o[Cc>>2]);kc=o[Hc>>2];Ec=Ac+kc|0;Xa=o[Ec+132>>2];Ec=o[Ec+136>>2];if((Xa|0)!=(Ec|0)){while(1){Wi((kc+Ac|0)+4|0,o[Xa>>2]);kc=o[Hc>>2];Xa=Xa+4|0;if((Ec|0)!=(Xa|0)){continue}break}}Vi((kc+Ac|0)+4|0);zc=zc+1|0;Xa=o[a+216>>2];if(zc>>>0<(o[Dc>>2]-Xa|0)/144>>>0){continue}break}}Xa=o[a+8>>2];_g(a+184|0,o[Xa+28>>2]-o[Xa+24>>2]>>2);kc=o[a+216>>2];if((kc|0)!=o[Dc>>2]){Xa=0;Ac=a+220|0;while(1){kc=u(Xa,144)+kc|0;zc=o[kc+60>>2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){qd=a+232|0;hd=a+8|0;nd=a+40|0;rd=a+428|0;ld=a+416|0;sd=a+388|0;td=o[a+216>>2]!=o[a+220>>2];while(1){d:{e:{f:{Yc=o[a+404>>2];g:{h:{if((Yc|0)!=-1){$c=-1;Zc=o[rd>>2]+(Yc<<2)|0;_c=o[Zc>>2];Yc=_c+ -1|0;o[Zc>>2]=Yc;if((_c|0)<1){break c}Yc=o[o[o[ld>>2]+u(o[a+404>>2],12)>>2]+(Yc<<2)>>2];Zc=o[(Yc<<2)+8848>>2];o[a+400>>2]=Zc;if(!Yc){Yc=o[ad+68>>2];if((Yc|0)==o[ad+64>>2]){break c}cd=-1;_c=o[hd>>2];id=o[_c+24>>2];bd=id;md=Yc+ -4|0;$c=o[md>>2];Zc=-1;i:{if(($c|0)==-1){break i}fd=$c+1|0;fd=(fd>>>0)%3|0?fd:$c+ -2|0;Zc=-1;if((fd|0)==-1){break i}Zc=o[o[_c>>2]+(fd<<2)>>2]}bd=o[bd+(Zc<<2)>>2];if((bd|0)!=-1){cd=bd+1|0;cd=(cd>>>0)%3|0?cd:bd+ -2|0}bd=o[_c+12>>2];fd=u(dd,3);ed=fd+1|0;o[bd+($c<<2)>>2]=ed;kd=ed<<2;o[kd+bd>>2]=$c;ed=fd+2|0;o[bd+(cd<<2)>>2]=ed;gd=ed<<2;o[gd+bd>>2]=cd;_c=o[_c>>2];o[_c+(fd<<2)>>2]=Zc;bd=_c+kd|0;kd=-1;j:{if((cd|0)==-1){break j}od=cd+1|0;cd=(od>>>0)%3|0?od:cd+ -2|0;kd=-1;if((cd|0)==-1){break j}kd=o[_c+(cd<<2)>>2]}o[bd>>2]=kd;k:{l:{if(($c|0)!=-1){$c=$c+(($c>>>0)%3|0?-1:2)|0;if(($c|0)!=-1){break l}}o[_c+gd>>2]=-1;break k}$c=o[_c+($c<<2)>>2];o[_c+gd>>2]=$c;if(($c|0)==-1){break k}o[id+($c<<2)>>2]=ed}$c=o[a+120>>2]+(Zc>>>3&536870908)|0;_c=o[$c>>2];vd=$c,wd=Zl(Zc)&_c,o[vd>>2]=wd;o[md>>2]=fd;Zc=0;break d}Zc=Zc+ -1|0;if(Zc>>>0>6){break c}m:{switch(Zc-1|0){case 1:case 3:cd=o[ad+68>>2];if((cd|0)==o[ad+64>>2]){break c}Zc=o[hd>>2];$c=o[Zc+12>>2];_c=u(dd,3);bd=(Yc|0)==3;fd=_c+(bd?2:1)|0;id=fd<<2;Yc=o[cd+ -4>>2];o[$c+id>>2]=Yc;o[$c+(Yc<<2)>>2]=fd;ed=Zc+24|0;cd=o[Zc+32>>2];Zc=Zc+28|0;$c=o[Zc>>2];n:{if((cd|0)!=($c|0)){o[$c>>2]=-1;gd=$c+4|0;o[Zc>>2]=gd;break n}bh(ed,8212);gd=o[Zc>>2]}$c=-1;Zc=o[hd>>2];cd=o[Zc+24>>2];if(o[Zc+28>>2]-cd>>2>(jd|0)){break c}$c=_c+2|0;Zc=o[Zc>>2];ed=gd-o[ed>>2]|0;gd=(ed>>2)+ -1|0;o[Zc+id>>2]=gd;if(ed){o[cd+(gd<<2)>>2]=fd}$c=bd?_c:$c;id=Zc+(_c+bd<<2)|0;o:{p:{q:{if((Yc|0)!=-1){bd=Yc+((Yc>>>0)%3|0?-1:2)|0;if((bd|0)==-1){break q}bd=o[Zc+(bd<<2)>>2];o[Zc+($c<<2)>>2]=bd;if((bd|0)==-1){break p}o[cd+(bd<<2)>>2]=$c;break p}o[Zc+($c<<2)>>2]=-1;$c=-1;break o}o[Zc+($c<<2)>>2]=-1}cd=Yc+1|0;Yc=(cd>>>0)%3|0?cd:Yc+ -2|0;$c=-1;if((Yc|0)==-1){break o}$c=o[Zc+(Yc<<2)>>2]}o[id>>2]=$c;Yc=o[ad+68>>2];o[Yc+ -4>>2]=_c;break g;case 5:break h;case 0:case 2:case 4:break c;default:break m}}Yc=o[ad+68>>2];gd=o[ad+64>>2];if((Yc|0)==(gd|0)){break c}Zc=Yc+ -4|0;fd=o[Zc>>2];o[ad+68>>2]=Zc;ed=o[ad+44>>2];r:{if(!ed){Yc=Zc;break r}id=Yl(ed)>>>0>1;s:{if(!id){_c=ed+2147483647ⅆbreak s}_c=dd;if(_c>>>0>>0){break s}_c=(dd>>>0)%(ed>>>0)|0}cd=o[o[ad+40>>2]+(_c<<2)>>2];if(!cd){Yc=Zc;break r}bd=o[cd>>2];if(!bd){Yc=Zc;break r}md=ed+ -1|0;t:{while(1){cd=o[bd+4>>2];u:{if((dd|0)!=(cd|0)){v:{if(!id){cd=cd&md;break v}if(cd>>>0>>0){break v}cd=(cd>>>0)%(ed>>>0)|0}if((_c|0)==(cd|0)){break u}Yc=Zc;break r}if(o[bd+8>>2]==(dd|0)){break t}}bd=o[bd>>2];if(bd){continue}break}Yc=Zc;break r}_c=bd+12|0;if((Zc|0)!=o[ad+72>>2]){o[Zc>>2]=o[_c>>2];o[ad+68>>2]=Yc;break r}bh(ad- -64|0,_c);Yc=o[ad+68>>2];gd=o[ad+64>>2]}if((Yc|0)==(gd|0)){break c}Zc=o[Yc+ -4>>2];cd=(Zc|0)==-1;ed=o[hd>>2];if(o[o[ed+12>>2]+(Zc<<2)>>2]!=-1?!cd:0){break c}kd=(fd|0)==-1;md=ed+12|0;_c=o[md>>2];if(o[_c+(fd<<2)>>2]!=-1?!kd:0){break c}gd=u(dd,3);id=gd+2|0;o[_c+(Zc<<2)>>2]=id;bd=id<<2;o[bd+_c>>2]=Zc;$c=gd+1|0;o[_c+(fd<<2)>>2]=$c;od=$c<<2;o[od+_c>>2]=fd;if(cd){break f}$c=-1;cd=-1;_c=o[ed>>2];ud=_c+(gd<<2)|0;pd=Zc+((Zc>>>0)%3|0?-1:2)|0;if((pd|0)!=-1){cd=o[(pd<<2)+_c>>2]}o[ud>>2]=cd;pd=Zc+1|0;Zc=(pd>>>0)%3|0?pd:Zc+ -2|0;if((Zc|0)==-1){break e}$c=o[(Zc<<2)+_c>>2];break e}o[a+400>>2]=7}o[ad>>2]=u(dd,3);Yc=o[hd>>2];$c=Yc+24|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>2]=$c;C:{D:{E:{if(!kd){Zc=fd+((fd>>>0)%3|0?-1:2)|0;if((Zc|0)==-1){break E}Zc=o[(Zc<<2)+_c>>2];o[_c+bd>>2]=Zc;if((Zc|0)==-1){break D}o[o[ed+24>>2]+(Zc<<2)>>2]=id;break D}o[_c+bd>>2]=-1;bd=-1;$c=-1;break C}o[_c+bd>>2]=-1}bd=-1;Zc=fd+1|0;Zc=(Zc>>>0)%3|0?Zc:fd+ -2|0;$c=-1;if((Zc|0)==-1){break C}bd=o[(Zc<<2)+_c>>2];$c=Zc}o[ad>>2]=bd;Zc=o[sd>>2];_c=cd<<2;fd=Zc+_c|0;o[fd>>2]=o[fd>>2]+o[Zc+(bd<<2)>>2];Zc=o[ed+24>>2];if((cd|0)!=-1){o[Zc+_c>>2]=o[Zc+(o[ad>>2]<<2)>>2]}F:{if(($c|0)==-1){break F}_c=o[ed>>2];while(1){o[_c+($c<<2)>>2]=cd;bd=$c+1|0;$c=(bd>>>0)%3|0?bd:$c+ -2|0;if(($c|0)==-1){break F}$c=o[o[md>>2]+($c<<2)>>2];if(($c|0)==-1){break F}bd=$c+1|0;$c=(bd>>>0)%3|0?bd:$c+ -2|0;if(($c|0)!=-1){continue}break}}o[Zc+(o[ad>>2]<<2)>>2]=-1;G:{if(td){break G}Zc=o[ad+28>>2];if((Zc|0)!=o[ad+32>>2]){o[Zc>>2]=o[ad>>2];o[ad+28>>2]=Zc+4;break G}bh(ad+24|0,ad);Yc=o[ad+68>>2]}o[Yc+ -4>>2]=gd;Zc=0}kh(qd,o[Yc+ -4>>2]);H:{if(!Zc){break H}Yc=o[nd>>2];if((Yc|0)==o[a+36>>2]){break H}_c=(dd^-1)+Lc|0;while(1){$c=-1;Zc=o[Yc+ -8>>2];if(Zc>>>0>_c>>>0){break c}if((Zc|0)!=(_c|0)){break H}Zc=p[Yc+ -4|0];Yc=Yc+ -12|0;cd=o[Yc>>2];o[nd>>2]=Yc;if((cd|0)<0){break c}Yc=o[o[ad+68>>2]+ -4>>2];o[ad+20>>2]=(cd^-1)+Lc;o[ad+88>>2]=ad+20;ch(ad,ad+40|0,ad+20|0,ad+88|0);$c=o[ad>>2];I:{if(Zc&1){Zc=-1;if((Yc|0)==-1){break I}Zc=Yc+1|0;Zc=(Zc>>>0)%3|0?Zc:Yc+ -2|0;break I}Zc=-1;if((Yc|0)==-1){break I}Zc=Yc+ -1|0;if((Yc>>>0)%3){break I}Zc=Yc+2|0}o[$c+12>>2]=Zc;Yc=o[nd>>2];if((Yc|0)!=o[a+36>>2]){continue}break}}dd=dd+1|0;if((dd|0)!=(Lc|0)){continue}break}Zc=Lc}$c=-1;bd=o[a+8>>2];if(o[bd+28>>2]-o[bd+24>>2]>>2>(jd|0)){break c}Yc=o[ad+68>>2];if((Yc|0)!=o[ad+64>>2]){nd=a+72|0;Lc=a+60|0;sd=a+312|0;td=a+8|0;id=a+68|0;qd=a+80|0;fd=a+76|0;while(1){Yc=Yc+ -4|0;dd=o[Yc>>2];o[ad+68>>2]=Yc;o[ad>>2]=dd;J:{if(Pf(sd)){gd=o[td>>2];hd=o[gd>>2];if((Zc|0)>=((o[gd+4>>2]-hd>>2>>>0)/3|0)){break c}Yc=-1;bd=-1;ed=o[ad>>2];cd=-1;K:{if((ed|0)==-1){break K}_c=ed+1|0;_c=(_c>>>0)%3|0?_c:ed+ -2|0;cd=-1;if((_c|0)==-1){break K}cd=o[hd+(_c<<2)>>2]}_c=o[gd+24>>2];dd=o[(cd<<2)+_c>>2];L:{if((dd|0)==-1){break L}jd=dd+1|0;dd=(jd>>>0)%3|0?jd:dd+ -2|0;if((dd|0)==-1){break L}Yc=dd+1|0;Yc=(Yc>>>0)%3|0?Yc:dd+ -2|0;if((Yc|0)!=-1){bd=o[hd+(Yc<<2)>>2]}Yc=dd}jd=-1;rd=-1;_c=o[_c+(bd<<2)>>2];dd=-1;M:{if((_c|0)==-1){break M}ld=_c+1|0;_c=(ld>>>0)%3|0?ld:_c+ -2|0;dd=-1;if((_c|0)==-1){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c=o[id>>2];if((Yc|0)==_c<<5){if((Yc+1|0)<=-1){break a}dd=Lc;if(Yc>>>0<=1073741822){Yc=Yc+32&-32;_c=_c<<6;Yc=_c>>>0>>0?Yc:_c}else{Yc=2147483647}ab(dd,Yc);Yc=o[a+64>>2]}o[a+64>>2]=Yc+1;dd=o[a+60>>2]+(Yc>>>3&536870908)|0;_c=o[dd>>2];vd=dd,wd=Zl(Yc)&_c,o[vd>>2]=wd;Yc=o[fd>>2];if((Yc|0)!=o[qd>>2]){o[Yc>>2]=o[ad>>2];o[fd>>2]=Yc+4;break J}bh(nd,ad)}Yc=o[ad+68>>2];if((Yc|0)!=o[ad+64>>2]){continue}break}bd=o[a+8>>2]}if(((o[bd+4>>2]-o[bd>>2]>>2>>>0)/3|0)!=(Zc|0)){break c}$c=o[bd+28>>2]-o[bd+24>>2]>>2;Lc=o[ad+24>>2];cd=o[ad+28>>2];if((Lc|0)==(cd|0)){break b}hd=a+8|0;while(1){_c=o[Lc>>2];Zc=o[bd+24>>2];Yc=$c+ -1|0;N:{if(o[Zc+(Yc<<2)>>2]!=-1){dd=$c;break N}Zc=o[bd+24>>2];while(1){Yc=$c+ -2|0;dd=$c+ -1|0;$c=dd;if(o[(Yc<<2)+Zc>>2]==-1){continue}break}}if(!(Yc>>>0<_c>>>0)){o[ad>>2]=bd;$c=Zc;Zc=Yc<<2;$c=o[$c+Zc>>2];m[ad+12|0]=1;o[ad+8>>2]=$c;o[ad+4>>2]=$c;if(($c|0)!=-1){while(1){o[o[bd>>2]+($c<<2)>>2]=_c;jf(ad);bd=o[hd>>2];$c=o[ad+8>>2];if(($c|0)!=-1){continue}break}}$c=o[bd+24>>2];Zc=$c+Zc|0;if((_c|0)!=-1){o[$c+(_c<<2)>>2]=o[Zc>>2]}o[Zc>>2]=-1;Zc=1<<(_c&31);$c=_c>>>3&536870908;_c=o[a+120>>2];$c=$c+_c|0;id=$c;ed=1<<(Yc&31);_c=_c+(Yc>>>3&536870908)|0;Yc=Zc|o[$c>>2];O:{if(ed&o[_c>>2]){break O}Yc=o[$c>>2]&(Zc^-1)}o[id>>2]=Yc;o[_c>>2]=o[_c>>2]&(ed^-1);dd=dd+ -1|0}$c=dd;Lc=Lc+4|0;if((cd|0)!=(Lc|0)){continue}break}}Lc=o[ad+24>>2]}if(Lc){o[ad+28>>2]=Lc;ul(Lc)}Yc=o[ad+48>>2];if(Yc){while(1){a=o[Yc>>2];ul(Yc);Yc=a;if(Yc){continue}break}}a=o[ad+40>>2];o[ad+40>>2]=0;if(a){ul(a)}a=o[ad+64>>2];if(a){o[ad+68>>2]=a;ul(a)}R=ad+96|0;return $c}Yk();D()}function jh(a,Lc){var xd=0,yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0;zd=o[a+8>>2];Ad=a+4|0;xd=o[Ad>>2];if((zd-xd|0)/12>>>0>=Lc>>>0){a=u(Lc,12);Ed=Ad,Fd=xl(xd,0,a)+a|0,o[Ed>>2]=Fd;return}a:{Ad=o[a>>2];yd=(xd-Ad|0)/12|0;Bd=yd+Lc|0;if(Bd>>>0<357913942){Dd=u(yd,12);zd=(zd-Ad|0)/12|0;yd=zd<<1;yd=zd>>>0<178956970?yd>>>0>>0?Bd:yd:357913941;if(yd){if(yd>>>0>=357913942){break a}Cd=Hk(u(yd,12))}zd=Cd+Dd|0;xl(zd,0,u(Lc,12));Lc=u(Bd,12)+Cd|0;Bd=u(yd,12)+Cd|0;if((xd|0)!=(Ad|0)){while(1){zd=zd+ -12|0;o[zd>>2]=0;o[zd+4>>2]=0;yd=zd+8|0;o[yd>>2]=0;xd=xd+ -12|0;o[zd>>2]=o[xd>>2];o[zd+4>>2]=o[xd+4>>2];Cd=yd;yd=xd+8|0;o[Cd>>2]=o[yd>>2];o[yd>>2]=0;o[xd>>2]=0;o[xd+4>>2]=0;if((xd|0)!=(Ad|0)){continue}break}Ad=o[a>>2];xd=o[a+4>>2]}o[a>>2]=zd;o[a+8>>2]=Bd;o[a+4>>2]=L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d=a+ -4|0;Ud=o[Vd>>2];if(Ud){Ud=a+(Ud<<4)|0;while(1){Ud=Ud+ -16|0;if((a|0)!=(Ud|0)){continue}break}}ul(Vd)}}function ph(a){a=a|0;ul(nh(a))}function qh(a){a=a|0;var Zd=0;o[a>>2]=8512;Zd=o[a+48>>2];if(Zd){o[a+52>>2]=Zd;ul(Zd)}o[a>>2]=8764;Zd=o[a+36>>2];if(Zd){ul(Zd)}Zd=o[a+24>>2];if(Zd){ul(Zd)}ul(a)}function rh(a){a=a|0;var _d=0;o[a>>2]=8764;_d=o[a+36>>2];if(_d){ul(_d)}_d=o[a+24>>2];if(_d){ul(_d)}return a|0}function sh(a){a=a|0;var $d=0;o[a>>2]=8764;$d=o[a+36>>2];if($d){ul($d)}$d=o[a+24>>2];if($d){ul($d)}ul(a)}function th(a,ae,be){a=a|0;ae=ae|0;be=be|0;var ce=0,de=0;ce=R-16|0;R=ce;o[a+4>>2]=ae;de=o[ae+4>>2];ae=o[ae>>2];m[ce+15|0]=0;$a(a+24|0,(de-ae>>2>>>0)/3|0,ce+15|0);ae=o[a+4>>2];de=o[ae+28>>2];ae=o[ae+24>>2];m[ce+14|0]=0;$a(a+36|0,de-ae>>2,ce+14|0);ae=o[be+12>>2];o[a+16>>2]=o[be+8>>2];o[a+20>>2]=ae;ae=o[be+4>>2];o[a+8>>2]=o[be>>2];o[a+12>>2]=ae;R=ce+16|0}function uh(a,ae){var be=0,ee=0,fe=0;a:{if((a|0)!=(ae|0)){fe=a;be=o[ae+4>>2];ee=0;b:{if(!be){break b}c:{if(be>>>0<=o[a+8>>2]<<5>>>0){ee=o[a>>2];break c}ee=o[a>>2];if(ee){ul(ee);o[a+8>>2]=0;o[a>>2]=0;o[a+4>>2]=0;be=o[ae+4>>2]}if((be|0)<=-1){break a}be=(be+ -1>>>5)+1|0;ee=Hk(be<<2);o[a+8>>2]=be;o[a+4>>2]=0;o[a>>2]=ee;be=o[ae+4>>2]}yl(ee,o[ae>>2],(be+ -1>>>3&536870908)+4|0);ee=o[ae+4>>2]}o[fe+4>>2]=ee}return}Yk();D()}function vh(a){a=a|0;var ae=0;o[a>>2]=9088;ae=o[a+88>>2];if(ae){o[a+92>>2]=ae;ul(ae)}ae=o[a+72>>2];if(ae){o[a+76>>2]=ae;ul(ae)}ae=o[a+60>>2];if(ae){o[a- -64>>2]=ae;ul(ae)}ae=o[a+48>>2];if(ae){o[a+52>>2]=ae;ul(ae)}o[a>>2]=9324;ae=o[a+36>>2];if(ae){ul(ae)}ae=o[a+24>>2];if(ae){ul(ae)}return a|0}function wh(a){a=a|0;var ge=0;o[a>>2]=8876;o[a+8>>2]=9088;ge=o[a+96>>2];if(ge){o[a+100>>2]=ge;ul(ge)}ge=o[a+80>>2];if(ge){o[a+84>>2]=ge;ul(ge)}ge=o[a+68>>2];if(ge){o[a+72>>2]=ge;ul(ge)}ge=o[a+56>>2];if(ge){o[a+60>>2]=ge;ul(ge)}o[a+8>>2]=9324;ge=o[a+44>>2];if(ge){ul(ge)}ge=o[a+32>>2];if(ge){ul(ge)}return a|0}function xh(a){a=a|0;var he=0;o[a>>2]=8876;o[a+8>>2]=9088;he=o[a+96>>2];if(he){o[a+100>>2]=he;ul(he)}he=o[a+80>>2];if(he){o[a+84>>2]=he;ul(he)}he=o[a+68>>2];if(he){o[a+72>>2]=he;ul(he)}he=o[a+56>>2];if(he){o[a+60>>2]=he;ul(he)}o[a+8>>2]=9324;he=o[a+44>>2];if(he){ul(he)}he=o[a+32>>2];if(he){ul(he)}ul(a)}function yh(a,ie){a=a|0;ie=ie|0;var je=0,ke=0,le=0,me=0,ne=0,oe=0,pe=0,qe=0,re=0,se=0,te=0;re=o[a+12>>2];je=o[a+108>>2];ke=o[je+80>>2];m[ie+84|0]=0;ne=o[ie+68>>2];le=o[ie+72>>2]-ne>>2;a:{if(ke>>>0>le>>>0){kd(ie+68|0,ke-le|0,9076);je=o[a+108>>2];ke=o[je+80>>2];break a}if(ke>>>0>=le>>>0){break a}o[ie+72>>2]=ne+(ke<<2)}qe=o[je+96>>2];je=o[je+100>>2]-qe|0;se=(je|0)/12|0;if(!je){return 1}te=ie+68|0;ie=0;b:{while(1){c:{if((ie|0)==1431655765){break c}je=o[re>>2]+(u(ie,3)<<2)|0;ne=o[je>>2];if((ne|0)==-1){break c}le=u(ie,12)+qe|0;oe=o[le>>2];if(oe>>>0>=ke>>>0){break c}me=ne<<2;ne=o[o[a+112>>2]+12>>2];me=o[me+ne>>2];if(me>>>0>=ke>>>0){break c}pe=oe<<2;oe=o[te>>2];o[pe+oe>>2]=me;me=o[je+4>>2];if((me|0)==-1){break c}pe=o[le+4>>2];if(pe>>>0>=ke>>>0){break c}me=o[ne+(me<<2)>>2];if(me>>>0>=ke>>>0){break c}o[oe+(pe<<2)>>2]=me;je=o[je+8>>2];if((je|0)==-1){break c}le=o[le+8>>2];if(le>>>0>=ke>>>0){break c}je=o[ne+(je<<2)>>2];if(je>>>0>=ke>>>0){break c}o[oe+(le<<2)>>2]=je;je=1;ie=ie+1|0;if(ie>>>0>>0){continue}break b}break}je=0}return je|0}function zh(a){a=a|0;var ie=0,ue=0,ve=0,we=0,xe=0,ye=0,ze=0,Ae=0,Be=0;xe=R-16|0;R=xe;ue=o[a+4>>2];ie=o[ue>>2];a:{Ae=a+12|0;ve=o[Ae>>2];we=o[ve+28>>2]-o[ve+24>>2]|0;ve=we>>2;b:{if(o[ue+8>>2]-ie>>2>>>0>=ve>>>0){break b}if(ve>>>0>=1073741824){break a}Be=ue+4|0;ye=o[Be>>2];ze=ve<<2;ve=Hk(we);ze=ze+ve|0;we=ye-ie|0;ye=we+ve|0;if((we|0)>=1){wl(ve,ie,we)}o[ue>>2]=ve;o[ue+8>>2]=ze;o[Be>>2]=ye;if(!ie){break b}ul(ie)}ie=o[Ae>>2];ue=o[ie+24>>2];ie=o[ie+28>>2];o[xe+12>>2]=0;ie=ie-ue>>2;ve=a+96|0;we=o[ve>>2];ue=o[a+100>>2]-we>>2;c:{if(ie>>>0>ue>>>0){yd(ve,ie-ue|0,xe+12|0);break c}if(ie>>>0>=ue>>>0){break c}o[a+100>>2]=we+(ie<<2)}we=a+8|0;d:{e:{ie=o[a+116>>2];if(ie){ve=o[ie>>2];ue=1;if((ve|0)==o[ie+4>>2]){break d}ie=0;while(1){if(!Ah(we,o[(ie<<2)+ve>>2])){break e}ue=o[a+116>>2];ve=o[ue>>2];ie=ie+1|0;if(ie>>>0>2]-ve>>2>>>0){continue}break}ue=1;break d}ie=0;a=o[a+12>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;ue=1;if((a|0)<=0){break d}while(1){if(!Ah(we,u(ie,3))){break e}ie=ie+1|0;if(ie>>>0>>0){continue}break}ue=1;break d}ue=0}R=xe+16|0;return ue|0}_a(8776);D()}function Ah(a,Ce){var De=0,Ee=0,Fe=0,Ge=0,He=0,Ie=0,Je=0,Ke=0,Le=0,Me=0,Ne=0,Oe=0,Pe=0;Ge=R-32|0;R=Ge;o[Ge+8>>2]=Ce;a:{if(o[a+92>>2]==o[a+88>>2]){break a}Fe=a+52|0;De=o[Fe>>2];b:{if((De|0)!=o[a+56>>2]){o[De>>2]=Ce;o[Fe>>2]=De+4;break b}bh(a+48|0,Ge+8|0)}o[a+84>>2]=0;Ce=-1;Fe=-1;De=o[Ge+8>>2];c:{if((De|0)==-1){break c}Ee=o[a+4>>2];He=De+1|0;He=(He>>>0)%3|0?He:De+ -2|0;if((He|0)!=-1){Ce=o[o[Ee>>2]+(He<<2)>>2]}De=De+((De>>>0)%3|0?-1:2)|0;if((De|0)==-1){break c}Fe=o[o[Ee>>2]+(De<<2)>>2]}De=o[a+36>>2];Ee=De+(Ce>>>3&536870908)|0;He=o[Ee>>2];Je=1<<(Ce&31);if(!(He&Je)){o[Ee>>2]=He|Je;De=-1;Ee=o[Ge+8>>2];if((Ee|0)!=-1){De=Ee+1|0;De=(De>>>0)%3|0?De:Ee+ -2|0}o[Ge+16>>2]=De;Ee=o[a+20>>2];He=(De>>>0)/3|0;He=o[(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ee|0)<1?2:1}if((Ee|0)<=o[a+84>>2]?Ke:0){break r}o[Ge+24>>2]=Ce;Le=u(Ee,12)+a|0;Ke=Le+52|0;Ie=o[Ke>>2];u:{if((Ie|0)!=o[Le+56>>2]){o[Ie>>2]=Ce;o[Ke>>2]=Ie+4;break u}bh(Le+48|0,Ge+24|0)}if(o[a+84>>2]<=(Ee|0)){break t}o[a+84>>2]=Ee}if(Fe){break m}}Ce=-1;Fe=0;Ce=(De|0)!=-1?o[o[o[Ne>>2]>>2]+(De<<2)>>2]:Ce;if(!(o[o[Je>>2]+(Ce>>>3&536870908)>>2]>>>(Ce&31)&1)){Fe=o[Me>>2]+(Ce<<2)|0;Ce=o[Fe>>2];o[Fe>>2]=Ce+1;Fe=(Ce|0)<1?2:1}if((Fe|0)>o[a+84>>2]){break q}Ce=De}o[Ge+8>>2]=Ce;Fe=o[He>>2];continue}break}o[Ge+24>>2]=De;Ee=u(Fe,12)+a|0;Ie=Ee+52|0;Ce=o[Ie>>2];v:{if((Ce|0)!=o[Ee+56>>2]){o[Ce>>2]=De;o[Ie>>2]=Ce+4;break v}bh(Ee+48|0,Ge+24|0)}De=o[a+84>>2];if((De|0)<=(Fe|0)){break l}o[a+84>>2]=Fe;De=Fe;break l}De=o[a+84>>2]}if((De|0)<3){continue}break}}o[Ge+8>>2]=-1}R=Ge+32|0;return 1}function Bh(a){a=a|0;var Ce=0;o[a>>2]=9088;Ce=o[a+88>>2];if(Ce){o[a+92>>2]=Ce;ul(Ce)}Ce=o[a+72>>2];if(Ce){o[a+76>>2]=Ce;ul(Ce)}Ce=o[a+60>>2];if(Ce){o[a- -64>>2]=Ce;ul(Ce)}Ce=o[a+48>>2];if(Ce){o[a+52>>2]=Ce;ul(Ce)}o[a>>2]=9324;Ce=o[a+36>>2];if(Ce){ul(Ce)}Ce=o[a+24>>2];if(Ce){ul(Ce)}ul(a)}function Ch(a){a=a|0;var Qe=0;o[a>>2]=9324;Qe=o[a+36>>2];if(Qe){ul(Qe)}Qe=o[a+24>>2];if(Qe){ul(Qe)}return a|0}function Dh(a){a=a|0;var Re=0;o[a>>2]=9324;Re=o[a+36>>2];if(Re){ul(Re)}Re=o[a+24>>2];if(Re){ul(Re)}ul(a)}function Eh(a){a=a|0;var Se=0;o[a>>2]=9508;Se=o[a+48>>2];if(Se){o[a+52>>2]=Se;ul(Se)}o[a>>2]=9324;Se=o[a+36>>2];if(Se){ul(Se)}Se=o[a+24>>2];if(Se){ul(Se)}return a|0}function Fh(a){a=a|0;var Te=0,Ue=0;o[a>>2]=9344;Ue=a+8|0;o[Ue>>2]=9508;Te=o[a+56>>2];if(Te){o[a+60>>2]=Te;ul(Te)}o[Ue>>2]=9324;Te=o[a+44>>2];if(Te){ul(Te)}Te=o[a+32>>2];if(Te){ul(Te)}return a|0}function Gh(a){a=a|0;var Ve=0,We=0;o[a>>2]=9344;We=a+8|0;o[We>>2]=9508;Ve=o[a+56>>2];if(Ve){o[a+60>>2]=Ve;ul(Ve)}o[We>>2]=9324;Ve=o[a+44>>2];if(Ve){ul(Ve)}Ve=o[a+32>>2];if(Ve){ul(Ve)}ul(a)}function Hh(a,Xe){a=a|0;Xe=Xe|0;var Ye=0,Ze=0,_e=0,$e=0,af=0,bf=0,cf=0,df=0,ef=0,ff=0,gf=0;ef=o[a+12>>2];Ye=o[a+68>>2];Ze=o[Ye+80>>2];m[Xe+84|0]=0;af=o[Xe+68>>2];_e=o[Xe+72>>2]-af>>2;a:{if(Ze>>>0>_e>>>0){kd(Xe+68|0,Ze-_e|0,9076);Ye=o[a+68>>2];Ze=o[Ye+80>>2];break a}if(Ze>>>0>=_e>>>0){break a}o[Xe+72>>2]=af+(Ze<<2)}df=o[Ye+96>>2];Ye=o[Ye+100>>2]-df|0;ff=(Ye|0)/12|0;if(!Ye){return 1}gf=Xe+68|0;Xe=0;b:{while(1){c:{if((Xe|0)==1431655765){break c}Ye=o[ef>>2]+(u(Xe,3)<<2)|0;af=o[Ye>>2];if((af|0)==-1){break c}_e=u(Xe,12)+df|0;bf=o[_e>>2];if(bf>>>0>=Ze>>>0){break c}$e=af<<2;af=o[o[a+72>>2]+12>>2];$e=o[$e+af>>2];if($e>>>0>=Ze>>>0){break c}cf=bf<<2;bf=o[gf>>2];o[cf+bf>>2]=$e;$e=o[Ye+4>>2];if(($e|0)==-1){break c}cf=o[_e+4>>2];if(cf>>>0>=Ze>>>0){break c}$e=o[af+($e<<2)>>2];if($e>>>0>=Ze>>>0){break c}o[bf+(cf<<2)>>2]=$e;Ye=o[Ye+8>>2];if((Ye|0)==-1){break c}_e=o[_e+8>>2];if(_e>>>0>=Ze>>>0){break c}Ye=o[af+(Ye<<2)>>2];if(Ye>>>0>=Ze>>>0){break c}o[bf+(_e<<2)>>2]=Ye;Ye=1;Xe=Xe+1|0;if(Xe>>>0>>0){continue}break b}break}Ye=0}return Ye|0}function Ih(a){a=a|0;var Xe=0,hf=0,jf=0,kf=0,lf=0,mf=0,nf=0;kf=o[a+4>>2];Xe=o[kf>>2];a:{hf=o[a+12>>2];jf=o[hf+28>>2]-o[hf+24>>2]|0;hf=jf>>2;b:{if(o[kf+8>>2]-Xe>>2>>>0>=hf>>>0){break b}if(hf>>>0>=1073741824){break a}nf=kf+4|0;lf=o[nf>>2];mf=hf<<2;hf=Hk(jf);mf=mf+hf|0;jf=lf-Xe|0;lf=jf+hf|0;if((jf|0)>=1){wl(hf,Xe,jf)}o[kf>>2]=hf;o[kf+8>>2]=mf;o[nf>>2]=lf;if(!Xe){break b}ul(Xe)}hf=a+8|0;c:{d:{Xe=o[a+76>>2];if(Xe){kf=o[Xe>>2];jf=1;if((kf|0)==o[Xe+4>>2]){break c}Xe=0;while(1){if(!Jh(hf,o[(Xe<<2)+kf>>2])){break d}jf=o[a+76>>2];kf=o[jf>>2];Xe=Xe+1|0;if(Xe>>>0>2]-kf>>2>>>0){continue}break}return 1}Xe=0;a=o[a+12>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!Jh(hf,u(Xe,3))){break d}Xe=Xe+1|0;if(Xe>>>0>>0){continue}break}return 1}jf=0}return jf|0}_a(8776);D()}function Jh(a,of){var pf=0,qf=0,rf=0,sf=0,tf=0,uf=0,vf=0,wf=0,xf=0,yf=0,zf=0,Af=0,Bf=0,Cf=0,Df=0;tf=R-32|0;R=tf;o[tf+8>>2]=of;a:{if((of|0)==-1){sf=1;break a}sf=1;pf=(of>>>0)/3|0;if(o[o[a+24>>2]+(pf>>>3&268435452)>>2]>>>(pf&31)&1){break a}pf=a+52|0;rf=o[a+48>>2];o[pf>>2]=rf;yf=a+48|0;b:{if((rf|0)!=o[a+56>>2]){o[rf>>2]=of;o[pf>>2]=rf+4;break b}bh(yf,tf+8|0)}sf=-1;rf=o[tf+8>>2];if((rf|0)==-1){sf=0;break a}pf=o[a+4>>2];of=rf+1|0;of=(of>>>0)%3|0?of:rf+ -2|0;if((of|0)!=-1){sf=o[o[pf>>2]+(of<<2)>>2]}of=rf+((rf>>>0)%3|0?-1:2)|0;if((of|0)==-1){sf=0;break a}if((sf|0)==-1){sf=0;break a}uf=o[o[pf>>2]+(of<<2)>>2];if((uf|0)==-1){sf=0;break a}of=o[a+36>>2];qf=of+(sf>>>3&536870908)|0;rf=o[qf>>2];pf=1<<(sf&31);if(!(rf&pf)){o[qf>>2]=pf|rf;qf=-1;pf=o[tf+8>>2];if((pf|0)!=-1){of=pf+1|0;qf=(of>>>0)%3|0?of:pf+ -2|0}o[tf+16>>2]=qf;rf=o[a+20>>2];of=(qf>>>0)/3|0;pf=o[(o[o[a+16>>2]+96>>2]+u(of,12)|0)+(qf-u(of,3)<<2)>>2];o[tf+24>>2]=pf;rf=o[rf+4>>2];of=rf+4|0;qf=o[of>>2];c:{if((qf|0)!=o[rf+8>>2]){o[qf>>2]=pf;o[of>>2]=qf+4;break c}bh(rf,tf+24|0)}pf=a+12|0;qf=o[pf>>2];of=qf+4|0;rf=o[of>>2];d:{if((rf|0)!=o[qf+8>>2]){o[rf>>2]=o[tf+16>>2];o[of>>2]=rf+4;break d}bh(qf,tf+16|0);qf=o[pf>>2]}o[o[qf+12>>2]+(sf<<2)>>2]=o[qf+24>>2];o[qf+24>>2]=o[qf+24>>2]+1;of=o[a+36>>2]}rf=(uf>>>3&536870908)+of|0;pf=o[rf>>2];of=1<<(uf&31);if(!(pf&of)){o[rf>>2]=of|pf;of=tf;rf=of;pf=o[of+8>>2];qf=-1;e:{if((pf|0)==-1){break e}qf=pf+ -1|0;if((pf>>>0)%3){break e}qf=pf+2|0}o[rf+16>>2]=qf;rf=o[a+20>>2];of=(qf>>>0)/3|0;pf=o[(o[o[a+16>>2]+96>>2]+u(of,12)|0)+(qf-u(of,3)<<2)>>2];o[tf+24>>2]=pf;rf=o[rf+4>>2];of=rf+4|0;qf=o[of>>2];f:{if((qf|0)!=o[rf+8>>2]){o[qf>>2]=pf;o[of>>2]=qf+4;break f}bh(rf,tf+24|0)}pf=a+12|0;sf=o[pf>>2];of=sf+4|0;rf=o[of>>2];g:{if((rf|0)!=o[sf+8>>2]){o[rf>>2]=o[tf+16>>2];o[of>>2]=rf+4;break g}bh(sf,tf+16|0);sf=o[pf>>2]}o[o[sf+12>>2]+(uf<<2)>>2]=o[sf+24>>2];o[sf+24>>2]=o[sf+24>>2]+1}wf=a+52|0;of=o[wf>>2];if((of|0)==o[a+48>>2]){sf=1;break a}xf=a+24|0;zf=a+4|0;Af=a+36|0;Bf=a+16|0;Cf=a+20|0;Df=a+56|0;while(1){qf=of+ -4|0;pf=o[qf>>2];o[tf+8>>2]=pf;of=(pf>>>0)/3|0;h:{i:{j:{if((pf|0)==-1){break j}rf=o[xf>>2]+(of>>>3&268435452)|0;pf=o[rf>>2];of=1<<(of&31);if(pf&of){break j}o[rf>>2]=of|pf;of=o[tf+8>>2];if((of|0)!=-1){break i}sf=0;break a}o[wf>>2]=qf;break h}k:{l:{m:{while(1){vf=o[zf>>2];pf=o[o[vf>>2]+(of<<2)>>2];if((pf|0)==-1){sf=0;break a}uf=o[Af>>2]+(pf>>>3&536870908)|0;qf=o[uf>>2];rf=1<<(pf&31);n:{if(!(qf&rf)){sf=pf<<2;pf=o[sf+o[vf+24>>2]>>2];o:{p:{if((pf|0)==-1){break p}of=pf+1|0;of=(of>>>0)%3|0?of:pf+ -2|0;if((of|0)==-1){break p}vf=o[o[vf+12>>2]+(of<<2)>>2];if((vf|0)==-1){break p}of=vf+1|0;pf=0;if((((of>>>0)%3|0?of:vf+ -2|0)|0)!=-1){break o}}pf=1}o[uf>>2]=rf|qf;rf=o[tf+8>>2];o[tf+16>>2]=rf;qf=o[Cf>>2];of=(rf>>>0)/3|0;rf=o[(o[o[Bf>>2]+96>>2]+u(of,12)|0)+(rf-u(of,3)<<2)>>2];o[tf+24>>2]=rf;qf=o[qf+4>>2];of=qf+4|0;uf=o[of>>2];q:{if((uf|0)!=o[qf+8>>2]){o[uf>>2]=rf;o[of>>2]=uf+4;break q}bh(qf,tf+24|0)}qf=a+12|0;of=o[qf>>2];rf=of+4|0;uf=o[rf>>2];r:{if((uf|0)!=o[of+8>>2]){o[uf>>2]=o[tf+16>>2];o[rf>>2]=uf+4;break r}bh(of,tf+16|0);of=o[qf>>2]}o[o[of+12>>2]+sf>>2]=o[of+24>>2];o[of+24>>2]=o[of+24>>2]+1;vf=o[zf>>2];of=o[tf+8>>2];if(!pf){pf=tf;qf=-1;s:{if((of|0)==-1){break s}rf=of+1|0;of=(rf>>>0)%3|0?rf:of+ -2|0;qf=-1;if((of|0)==-1){break s}qf=o[o[vf+12>>2]+(of<<2)>>2]}o[pf+8>>2]=qf;of=(qf>>>0)/3|0;break n}if((of|0)==-1){break l}}qf=-1;sf=-1;pf=of+1|0;pf=(pf>>>0)%3|0?pf:of+ -2|0;if((pf|0)!=-1){sf=o[o[vf+12>>2]+(pf<<2)>>2]}o[tf+24>>2]=sf;of=((of>>>0)%3|0?-1:2)+of|0;if((of|0)!=-1){qf=o[o[vf+12>>2]+(of<<2)>>2]}rf=(qf>>>0)/3|0;of=(sf>>>0)/3|0;pf=(sf|0)==-1;t:{if(pf){of=-1;pf=1;break t}pf=pf?-1:of;pf=o[o[xf>>2]+(pf>>>3&536870908)>>2]>>>(pf&31)&1}u:{if((qf|0)!=-1){uf=(qf|0)==-1?-1:rf;uf=o[o[xf>>2]+(uf>>>3&536870908)>>2]&1<<(uf&31);if(pf){sf=qf;of=rf;if(!uf){break u}break k}if(uf){break u}of=o[wf>>2];o[of+ -4>>2]=qf;if((of|0)==o[Df>>2]){break m}o[of>>2]=o[tf+24>>2];o[wf>>2]=of+4;break h}if(pf){break k}}o[tf+8>>2]=sf}pf=o[xf>>2]+(of>>>3&536870908)|0;o[pf>>2]=o[pf>>2]|1<<(of&31);of=o[tf+8>>2];if((of|0)!=-1){continue}break}sf=0;break a}bh(yf,tf+24|0);break h}o[tf+24>>2]=-1}o[wf>>2]=o[wf>>2]+ -4}sf=1;of=o[wf>>2];if((of|0)!=o[a+48>>2]){continue}break}}R=tf+32|0;return sf}function Kh(a){a=a|0;var of=0;o[a>>2]=9508;of=o[a+48>>2];if(of){o[a+52>>2]=of;ul(of)}o[a>>2]=9324;of=o[a+36>>2];if(of){ul(of)}of=o[a+24>>2];if(of){ul(of)}ul(a)}function Lh(a){a=a|0;var Ef=0,Ff=0;o[a>>2]=9636;Ff=a+8|0;o[Ff>>2]=8512;Ef=o[a+56>>2];if(Ef){o[a+60>>2]=Ef;ul(Ef)}o[Ff>>2]=8764;Ef=o[a+44>>2];if(Ef){ul(Ef)}Ef=o[a+32>>2];if(Ef){ul(Ef)}return a|0}function Mh(a){a=a|0;var Gf=0,Hf=0;o[a>>2]=9636;Hf=a+8|0;o[Hf>>2]=8512;Gf=o[a+56>>2];if(Gf){o[a+60>>2]=Gf;ul(Gf)}o[Hf>>2]=8764;Gf=o[a+44>>2];if(Gf){ul(Gf)}Gf=o[a+32>>2];if(Gf){ul(Gf)}ul(a)}function Nh(a,If){a=a|0;If=If|0;var Jf=0,Kf=0,Lf=0,Mf=0,Nf=0,Of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uf>>>0){break b}if(Uf>>>0>=1073741824){break a}Zf=Wf+4|0;Xf=o[Zf>>2];Yf=Uf<<2;Uf=Hk(Vf);Yf=Yf+Uf|0;Vf=Xf-If|0;Xf=Vf+Uf|0;if((Vf|0)>=1){wl(Uf,If,Vf)}o[Wf>>2]=Uf;o[Wf+8>>2]=Yf;o[Zf>>2]=Xf;if(!If){break b}ul(If)}Uf=a+8|0;c:{d:{If=o[a+76>>2];if(If){Wf=o[If>>2];Vf=1;if((Wf|0)==o[If+4>>2]){break c}If=0;while(1){if(!Ph(Uf,o[(If<<2)+Wf>>2])){break d}Vf=o[a+76>>2];Wf=o[Vf>>2];If=If+1|0;if(If>>>0>2]-Wf>>2>>>0){continue}break}return 1}If=0;a=o[o[a+12>>2]+64>>2];a=(o[a+4>>2]-o[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!Ph(Uf,u(If,3))){break d}If=If+1|0;if(If>>>0>>0){continue}break}return 1}Vf=0}return Vf|0}_a(8776);D()}function Ph(a,_f){var $f=0,ag=0,bg=0,cg=0,dg=0,eg=0,fg=0,gg=0,hg=0,ig=0,jg=0,kg=0,lg=0,mg=0,ng=0;dg=R-32|0;R=dg;o[dg+8>>2]=_f;a:{if((_f|0)==-1){$f=1;break a}$f=1;cg=(_f>>>0)/3|0;if(o[o[a+24>>2]+(cg>>>3&268435452)>>2]>>>(cg&31)&1){break a}cg=a+52|0;$f=o[a+48>>2];o[cg>>2]=$f;ig=a+48|0;b:{if(($f|0)!=o[a+56>>2]){o[$f>>2]=_f;o[cg>>2]=$f+4;break b}bh(ig,dg+8|0)}ag=-1;$f=o[a+4>>2];_f=o[dg+8>>2];c:{if((_f|0)==-1){cg=o[$f+28>>2];$f=o[cg+ -4>>2];break c}cg=o[$f+28>>2];$f=_f+1|0;$f=o[cg+((($f>>>0)%3|0?$f:_f+ -2|0)<<2)>>2];if((_f>>>0)%3){ag=_f+ -1|0;break c}ag=_f+2|0}if(($f|0)==-1){$f=0;break a}cg=o[(ag<<2)+cg>>2];if((cg|0)==-1){$f=0;break a}_f=o[a+36>>2];bg=_f+($f>>>3&536870908)|0;ag=o[bg>>2];eg=1<<($f&31);if(!(ag&eg)){o[bg>>2]=ag|eg;ag=-1;_f=o[dg+8>>2];if((_f|0)!=-1){bg=_f+1|0;ag=(bg>>>0)%3|0?bg:_f+ -2|0}o[dg+16>>2]=ag;_f=o[a+20>>2];bg=(ag>>>0)/3|0;ag=o[(o[o[a+16>>2]+96>>2]+u(bg,12)|0)+(ag-u(bg,3)<<2)>>2];o[dg+24>>2]=ag;bg=o[_f+4>>2];eg=bg+4|0;_f=o[eg>>2];d:{if((_f|0)!=o[bg+8>>2]){o[_f>>2]=ag;o[eg>>2]=_f+4;break d}bh(bg,dg+24|0)}bg=a+12|0;ag=o[bg>>2];eg=ag+4|0;_f=o[eg>>2];e:{if((_f|0)!=o[ag+8>>2]){o[_f>>2]=o[dg+16>>2];o[eg>>2]=_f+4;break e}bh(ag,dg+16|0);ag=o[bg>>2]}o[o[ag+12>>2]+($f<<2)>>2]=o[ag+24>>2];o[ag+24>>2]=o[ag+24>>2]+1;_f=o[a+36>>2]}_f=(cg>>>3&536870908)+_f|0;$f=o[_f>>2];bg=1<<(cg&31);if(!($f&bg)){o[_f>>2]=$f|bg;_f=dg;ag=_f;bg=o[_f+8>>2];$f=-1;f:{if((bg|0)==-1){break f}$f=bg+ -1|0;if((bg>>>0)%3){break f}$f=bg+2|0}o[ag+16>>2]=$f;_f=o[a+20>>2];bg=($f>>>0)/3|0;bg=o[(o[o[a+16>>2]+96>>2]+u(bg,12)|0)+($f-u(bg,3)<<2)>>2];o[dg+24>>2]=bg;$f=o[_f+4>>2];ag=$f+4|0;_f=o[ag>>2];g:{if((_f|0)!=o[$f+8>>2]){o[_f>>2]=bg;o[ag>>2]=_f+4;break g}bh($f,dg+24|0)}bg=a+12|0;$f=o[bg>>2];ag=$f+4|0;_f=o[ag>>2];h:{if((_f|0)!=o[$f+8>>2]){o[_f>>2]=o[dg+16>>2];o[ag>>2]=_f+4;break h}bh($f,dg+16|0);$f=o[bg>>2]}o[o[$f+12>>2]+(cg<<2)>>2]=o[$f+24>>2];o[$f+24>>2]=o[$f+24>>2]+1}eg=a+52|0;_f=o[eg>>2];if((_f|0)==o[a+48>>2]){$f=1;break a}gg=a+24|0;hg=a+4|0;kg=a+36|0;lg=a+16|0;mg=a+20|0;ng=a+56|0;while(1){cg=_f+ -4|0;_f=o[cg>>2];o[dg+8>>2]=_f;$f=(_f>>>0)/3|0;i:{j:{k:{if((_f|0)==-1){break k}_f=o[gg>>2]+($f>>>3&268435452)|0;bg=o[_f>>2];$f=1<<($f&31);if(bg&$f){break k}o[_f>>2]=$f|bg;ag=o[hg>>2];_f=o[dg+8>>2];$f=o[o[ag+28>>2]+(_f<<2)>>2];if(($f|0)!=-1){break j}$f=0;break a}o[eg>>2]=cg;break i}l:{m:{n:{while(1){o:{p:{cg=o[kg>>2]+($f>>>3&536870908)|0;bg=o[cg>>2];fg=1<<($f&31);if(bg&fg){break p}jg=$f<<2;$f=o[jg+o[ag+40>>2]>>2];_f=1;q:{if(($f|0)==-1){break q}_f=$f+1|0;_f=(_f>>>0)%3|0?_f:$f+ -2|0;r:{if((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1){break r}$f=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2];if(($f|0)==-1){break r}ag=$f+1|0;_f=0;if((((ag>>>0)%3|0?ag:$f+ -2|0)|0)!=-1){break q}}_f=1}$f=_f;o[cg>>2]=bg|fg;_f=o[dg+8>>2];o[dg+16>>2]=_f;cg=o[mg>>2];bg=(_f>>>0)/3|0;bg=o[(o[o[lg>>2]+96>>2]+u(bg,12)|0)+(_f-u(bg,3)<<2)>>2];o[dg+24>>2]=bg;cg=o[cg+4>>2];ag=cg+4|0;_f=o[ag>>2];s:{if((_f|0)!=o[cg+8>>2]){o[_f>>2]=bg;o[ag>>2]=_f+4;break s}bh(cg,dg+24|0)}bg=a+12|0;_f=o[bg>>2];ag=_f+4|0;cg=o[ag>>2];t:{if((cg|0)!=o[_f+8>>2]){o[cg>>2]=o[dg+16>>2];o[ag>>2]=cg+4;break t}bh(_f,dg+16|0);_f=o[bg>>2]}o[o[_f+12>>2]+jg>>2]=o[_f+24>>2];o[_f+24>>2]=o[_f+24>>2]+1;ag=o[hg>>2];_f=o[dg+8>>2];if($f){break p}$f=-1;u:{if((_f|0)==-1){break u}cg=_f+1|0;_f=(cg>>>0)%3|0?cg:_f+ -2|0;if((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1){break u}$f=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2]}o[dg+8>>2]=$f;_f=($f>>>0)/3|0;break o}if((_f|0)==-1){break m}cg=-1;bg=dg;fg=_f+1|0;fg=(fg>>>0)%3|0?fg:_f+ -2|0;$f=-1;v:{if((fg|0)==-1){break v}$f=-1;if(o[o[ag>>2]+(fg>>>3&536870908)>>2]>>>(fg&31)&1){break v}$f=o[o[o[ag+64>>2]+12>>2]+(fg<<2)>>2]}o[bg+24>>2]=$f;_f=((_f>>>0)%3|0?-1:2)+_f|0;if(!((_f|0)==-1|o[o[ag>>2]+(_f>>>3&536870908)>>2]>>>(_f&31)&1)){cg=o[o[o[ag+64>>2]+12>>2]+(_f<<2)>>2]}bg=(cg>>>0)/3|0;_f=($f>>>0)/3|0;ag=($f|0)==-1;w:{if(ag){_f=-1;ag=1;break w}ag=ag?-1:_f;ag=o[o[gg>>2]+(ag>>>3&536870908)>>2]>>>(ag&31)&1}x:{if((cg|0)!=-1){fg=(cg|0)==-1?-1:bg;fg=o[o[gg>>2]+(fg>>>3&536870908)>>2]&1<<(fg&31);if(ag){$f=cg;_f=bg;if(!fg){break x}break l}if(fg){break x}_f=o[eg>>2];o[_f+ -4>>2]=cg;if((_f|0)==o[ng>>2]){break n}o[_f>>2]=o[dg+24>>2];o[eg>>2]=_f+4;break i}if(ag){break l}}o[dg+8>>2]=$f}$f=o[gg>>2]+(_f>>>3&536870908)|0;o[$f>>2]=o[$f>>2]|1<<(_f&31);ag=o[hg>>2];_f=o[dg+8>>2];$f=o[o[ag+28>>2]+(_f<<2)>>2];if(($f|0)!=-1){continue}break}$f=0;break a}bh(ig,dg+24|0);break i}o[dg+24>>2]=-1}o[eg>>2]=o[eg>>2]+ -4}$f=1;_f=o[eg>>2];if((_f|0)!=o[a+48>>2]){continue}break}}R=dg+32|0;return $f}function Qh(a,_f){var og=0,pg=0,qg=0;o[a>>2]=o[_f>>2];o[a+4>>2]=o[_f+4>>2];o[a+8>>2]=o[_f+8>>2];og=_f+12|0;o[a+12>>2]=o[og>>2];o[og>>2]=0;o[_f+4>>2]=0;o[_f+8>>2]=0;og=_f+16|0;o[a+16>>2]=o[og>>2];o[a+20>>2]=o[_f+20>>2];pg=_f+24|0;o[a+24>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=p[_f+28|0];qg=a+40|0;o[qg>>2]=0;og=a+32|0;o[og>>2]=0;o[og+4>>2]=0;m[a+28|0]=pg;pg=og;og=_f+32|0;o[pg>>2]=o[og>>2];o[a+36>>2]=o[_f+36>>2];pg=_f+40|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a+52|0;o[pg>>2]=0;og=a+44|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+44|0;o[qg>>2]=o[og>>2];o[a+48>>2]=o[_f+48>>2];qg=pg;pg=_f+52|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a- -64|0;o[pg>>2]=0;og=a+56|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+56|0;o[qg>>2]=o[og>>2];o[a+60>>2]=o[_f+60>>2];qg=pg;pg=_f- -64|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;o[a+68>>2]=o[_f+68>>2];pg=o[_f+72>>2];qg=a+84|0;o[qg>>2]=0;og=a+76|0;o[og>>2]=0;o[og+4>>2]=0;o[a+72>>2]=pg;pg=og;og=_f+76|0;o[pg>>2]=o[og>>2];o[a+80>>2]=o[_f+80>>2];pg=_f+84|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;pg=a+96|0;o[pg>>2]=0;og=a+88|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+88|0;o[qg>>2]=o[og>>2];o[a+92>>2]=o[_f+92>>2];qg=pg;pg=_f+96|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;og=p[_f+100|0];pg=a+112|0;o[pg>>2]=0;o[a+104>>2]=0;o[a+108>>2]=0;m[a+100|0]=og;o[a+104>>2]=o[_f+104>>2];o[a+108>>2]=o[_f+108>>2];og=_f+112|0;o[pg>>2]=o[og>>2];o[og>>2]=0;o[_f+104>>2]=0;o[_f+108>>2]=0;pg=a+124|0;o[pg>>2]=0;og=a+116|0;o[og>>2]=0;o[og+4>>2]=0;qg=og;og=_f+116|0;o[qg>>2]=o[og>>2];o[a+120>>2]=o[_f+120>>2];qg=pg;pg=_f+124|0;o[qg>>2]=o[pg>>2];o[pg>>2]=0;o[og>>2]=0;o[og+4>>2]=0;og=o[_f+128>>2];pg=a+140|0;o[pg>>2]=0;o[a+132>>2]=0;o[a+136>>2]=0;o[a+128>>2]=og;o[a+132>>2]=o[_f+132>>2];o[a+136>>2]=o[_f+136>>2];og=_f+140|0;o[pg>>2]=o[og>>2];o[og>>2]=0;o[_f+132>>2]=0;o[_f+136>>2]=0;return a}function Rh(a){var _f=0,rg=0,sg=0;rg=o[a+8>>2];sg=o[a+4>>2];if((rg|0)!=(sg|0)){while(1){_f=rg+ -144|0;o[a+8>>2]=_f;_f=o[_f+132>>2];if(_f){o[rg+ -8>>2]=_f;ul(_f)}_f=o[rg+ -28>>2];if(_f){o[rg+ -24>>2]=_f;ul(_f)}_f=o[rg+ -40>>2];if(_f){o[rg+ -36>>2]=_f;ul(_f)}Ug(rg+ -140|0);rg=o[a+8>>2];if((sg|0)!=(rg|0)){continue}break}}a=o[a>>2];if(a){ul(a)}}function Sh(a,tg){var ug=0,vg=0,wg=v(0);ug=2;a:{if((tg|0)==1){break a}ug=tg;if(!(tg+ -1&tg)){break a}ug=ek(tg)}vg=o[a+4>>2];if(ug>>>0>vg>>>0){Th(a,ug);return}b:{if(ug>>>0>=vg>>>0){break b}wg=v(B(v(v(r[a+12>>2])/s[a+16>>2])));c:{if(wg=v(0)){tg=~~wg>>>0;break c}tg=0}d:{e:{if(vg>>>0<3){break e}if(Yl(vg)>>>0>1){break e}tg=tg>>>0<2?tg:1<<32-x(tg+ -1|0);break d}tg=ek(tg)}tg=ug>>>0>>0?tg:ug;if(tg>>>0>=vg>>>0){break b}Th(a,tg)}}function Th(a,tg){var xg=0,yg=0,zg=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0;a:{b:{if(tg){if(tg>>>0>=1073741824){break a}xg=Hk(tg<<2);yg=o[a>>2];o[a>>2]=xg;if(yg){ul(yg)}o[a+4>>2]=tg;xg=0;while(1){o[o[a>>2]+(xg<<2)>>2]=0;xg=xg+1|0;if((xg|0)!=(tg|0)){continue}break}yg=a+8|0;Ag=o[yg>>2];if(!Ag){break b}Bg=o[Ag+4>>2];xg=Yl(tg);c:{if(xg>>>0<=1){Bg=tg+ -1&Bg;break c}if(Bg>>>0>>0){break c}Bg=(Bg>>>0)%(tg>>>0)|0}o[o[a>>2]+(Bg<<2)>>2]=yg;yg=o[Ag>>2];if(!yg){break b}Eg=tg+ -1|0;Fg=xg>>>0>1;while(1){zg=o[yg+4>>2];d:{if(!Fg){zg=zg&Eg;break d}if(zg>>>0>>0){break d}zg=(zg>>>0)%(tg>>>0)|0}e:{if((zg|0)==(Bg|0)){Ag=yg;break e}xg=yg;Cg=zg<<2;Dg=Cg+o[a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();D()}function Xh(a,Xg){var kh=0,lh=0,mh=0,nh=0,oh=0,ph=0;a:{nh=o[a>>2];oh=o[a+4>>2]-nh|0;kh=(oh|0)/12|0;lh=kh+1|0;if(lh>>>0<357913942){ph=u(kh,12);mh=(o[a+8>>2]-nh|0)/12|0;kh=mh<<1;mh=mh>>>0<178956970?kh>>>0>>0?lh:kh:357913941;kh=0;b:{if(!mh){break b}if(mh>>>0>=357913942){break a}kh=Hk(u(mh,12))}lh=ph+kh|0;ph=o[Xg+4>>2];o[lh>>2]=o[Xg>>2];o[lh+4>>2]=ph;o[lh+8>>2]=o[Xg+8>>2];Xg=lh+u((oh|0)/-12|0,12)|0;kh=kh+u(mh,12)|0;lh=lh+12|0;if((oh|0)>=1){wl(Xg,nh,oh)}o[a>>2]=Xg;o[a+8>>2]=kh;o[a+4>>2]=lh;if(nh){ul(nh)}return}Yk();D()}_a(9912);D()}function Yh(a,Xg){a=a|0;Xg=Xg|0;var qh=0,rh=0,sh=0,th=0,uh=0,vh=0,wh=0;th=R-16|0;R=th;uh=Hk(64);qh=Hk(12);o[qh+8>>2]=o[o[a+4>>2]+80>>2];o[qh>>2]=9988;o[qh+4>>2]=0;o[th+8>>2]=qh;Qd(uh,th+8|0);a:{if((Xg|0)>=0){qh=o[a+12>>2];vh=a+8|0;wh=o[vh>>2];rh=qh-wh>>2;b:{if((rh|0)>(Xg|0)){break b}sh=Xg+1|0;if(rh>>>0<=Xg>>>0){Og(vh,sh-rh|0);break b}if(sh>>>0>=rh>>>0){break b}sh=wh+(sh<<2)|0;if((sh|0)!=(qh|0)){while(1){qh=qh+ -4|0;rh=o[qh>>2];o[qh>>2]=0;if(rh){l[o[o[rh>>2]+4>>2]](rh)}if((qh|0)!=(sh|0)){continue}break}}o[a+12>>2]=sh}Xg=o[vh>>2]+(Xg<<2)|0;a=o[Xg>>2];o[Xg>>2]=uh;rh=1;if(!a){break a}l[o[o[a>>2]+4>>2]](a);break a}l[o[o[uh>>2]+4>>2]](uh)}a=o[th+8>>2];o[th+8>>2]=0;if(a){l[o[o[a>>2]+4>>2]](a)}R=th+16|0;return rh|0}function Zh(a){a=a|0;var Xg=0,xh=0,yh=0,zh=0,Ah=0;o[a>>2]=10052;Xg=o[a+20>>2];if(Xg){o[a+24>>2]=Xg;ul(Xg)}yh=o[a+8>>2];if(yh){Xg=yh;Ah=a+12|0;xh=o[Ah>>2];zh=Xg;a:{if((Xg|0)==(xh|0)){break a}while(1){xh=xh+ -4|0;Xg=o[xh>>2];o[xh>>2]=0;if(Xg){l[o[o[Xg>>2]+4>>2]](Xg)}if((xh|0)!=(yh|0)){continue}break}zh=o[a+8>>2]}Xg=zh;o[Ah>>2]=yh;ul(Xg)}ul(a)}function _h(a,Bh){a=a|0;Bh=Bh|0;m[Bh+84|0]=1;o[Bh+72>>2]=o[Bh+68>>2];return 1}function $h(a){a=a|0;var Bh=0,Ch=0,Dh=0,Eh=0;a:{Bh=o[a+8>>2];b:{if((Bh|0)<0){break b}Ch=o[a+4>>2];Eh=o[Ch>>2];Dh=o[Ch+4>>2]-Eh>>2;c:{if(Bh>>>0>Dh>>>0){ai(Ch,Bh-Dh|0);Bh=o[a+8>>2];break c}if(Bh>>>0>=Dh>>>0){break c}o[Ch+4>>2]=Eh+(Bh<<2)}Eh=1;if((Bh|0)<1){break b}a=o[a+4>>2];Ch=o[a>>2];Dh=o[a+4>>2]-Ch>>2;a=0;while(1){if((a|0)==(Dh|0)){break a}o[Ch+(a<<2)>>2]=a;a=a+1|0;if((a|0)<(Bh|0)){continue}break}}return Eh|0}Zk();D()}function ai(a,Fh){var Gh=0,Hh=0,Ih=0,Jh=0,Kh=0,Lh=0,Mh=0,Nh=0,Oh=0;Hh=o[a+8>>2];Ih=a+4|0;Gh=o[Ih>>2];if(Hh-Gh>>2>>>0>=Fh>>>0){a=Fh<<2;Nh=Ih,Oh=xl(Gh,0,a)+a|0,o[Nh>>2]=Oh;return}a:{Ih=o[a>>2];Kh=Gh-Ih|0;Gh=Kh>>2;Jh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h|0)==(Fh|0)){break a}while(1){Zh=Zh+ -4|0;Fh=o[Zh>>2];o[Zh>>2]=0;if(Fh){Fc(Fh+12|0,o[Fh+16>>2]);Gc(Fh,o[Fh+4>>2]);ul(Fh)}if((Zh|0)!=(_h|0)){continue}break}$h=o[a+24>>2]}Fh=$h;o[ai>>2]=_h;ul(Fh)}Fc(a+12|0,o[a+16>>2]);Gc(a,o[a+4>>2]);ul(a)}}function fi(a,bi,ei,fi,gi){var hi=0,ii=0;hi=R-32|0;R=hi;o[bi+32>>2]=fi;o[bi+40>>2]=ei;o[bi+4>>2]=gi;ci(a,fi,hi+16|0);a:{if(o[a>>2]){break a}ei=a+4|0;if(m[a+15|0]<=-1){ul(o[ei>>2])}gi=p[hi+23|0];if((l[o[o[bi>>2]+8>>2]](bi)|0)!=(gi|0)){bi=Hk(64);o[hi>>2]=bi;o[hi+4>>2]=50;o[hi+8>>2]=-2147483584;m[bi+50|0]=0;fi=p[10225]|p[10226]<<8;m[bi+48|0]=fi;m[bi+49|0]=fi>>>8;fi=p[10221]|p[10222]<<8|(p[10223]<<16|p[10224]<<24);gi=p[10217]|p[10218]<<8|(p[10219]<<16|p[10220]<<24);m[bi+40|0]=gi;m[bi+41|0]=gi>>>8;m[bi+42|0]=gi>>>16;m[bi+43|0]=gi>>>24;m[bi+44|0]=fi;m[bi+45|0]=fi>>>8;m[bi+46|0]=fi>>>16;m[bi+47|0]=fi>>>24;fi=p[10213]|p[10214]<<8|(p[10215]<<16|p[10216]<<24);gi=p[10209]|p[10210]<<8|(p[10211]<<16|p[10212]<<24);m[bi+32|0]=gi;m[bi+33|0]=gi>>>8;m[bi+34|0]=gi>>>16;m[bi+35|0]=gi>>>24;m[bi+36|0]=fi;m[bi+37|0]=fi>>>8;m[bi+38|0]=fi>>>16;m[bi+39|0]=fi>>>24;fi=p[10205]|p[10206]<<8|(p[10207]<<16|p[10208]<<24);gi=p[10201]|p[10202]<<8|(p[10203]<<16|p[10204]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10197]|p[10198]<<8|(p[10199]<<16|p[10200]<<24);gi=p[10193]|p[10194]<<8|(p[10195]<<16|p[10196]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10189]|p[10190]<<8|(p[10191]<<16|p[10192]<<24);gi=p[10185]|p[10186]<<8|(p[10187]<<16|p[10188]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10181]|p[10182]<<8|(p[10183]<<16|p[10184]<<24);gi=p[10177]|p[10178]<<8|(p[10179]<<16|p[10180]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}fi=p[hi+21|0];m[bi+36|0]=fi;ii=p[hi+22|0];m[bi+37|0]=ii;if((fi+ -1&255)>>>0>=2){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=22;o[hi+8>>2]=-2147483616;m[bi+22|0]=0;fi=p[10246]|p[10247]<<8|(p[10248]<<16|p[10249]<<24);gi=p[10242]|p[10243]<<8|(p[10244]<<16|p[10245]<<24);m[bi+14|0]=gi;m[bi+15|0]=gi>>>8;m[bi+16|0]=gi>>>16;m[bi+17|0]=gi>>>24;m[bi+18|0]=fi;m[bi+19|0]=fi>>>8;m[bi+20|0]=fi>>>16;m[bi+21|0]=fi>>>24;fi=p[10240]|p[10241]<<8|(p[10242]<<16|p[10243]<<24);gi=p[10236]|p[10237]<<8|(p[10238]<<16|p[10239]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10232]|p[10233]<<8|(p[10234]<<16|p[10235]<<24);gi=p[10228]|p[10229]<<8|(p[10230]<<16|p[10231]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-5;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!((fi|0)!=2|(gi?2:3)>>>0>=ii>>>0)){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=22;o[hi+8>>2]=-2147483616;m[bi+22|0]=0;fi=p[10269]|p[10270]<<8|(p[10271]<<16|p[10272]<<24);gi=p[10265]|p[10266]<<8|(p[10267]<<16|p[10268]<<24);m[bi+14|0]=gi;m[bi+15|0]=gi>>>8;m[bi+16|0]=gi>>>16;m[bi+17|0]=gi>>>24;m[bi+18|0]=fi;m[bi+19|0]=fi>>>8;m[bi+20|0]=fi>>>16;m[bi+21|0]=fi>>>24;fi=p[10263]|p[10264]<<8|(p[10265]<<16|p[10266]<<24);gi=p[10259]|p[10260]<<8|(p[10261]<<16|p[10262]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10255]|p[10256]<<8|(p[10257]<<16|p[10258]<<24);gi=p[10251]|p[10252]<<8|(p[10253]<<16|p[10254]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-5;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}fi=fi<<8|ii;n[o[bi+32>>2]+38>>1]=fi;b:{if((fi&65535)>>>0<259|n[hi+26>>1]>-1){break b}di(a,bi);if(o[a>>2]){break a}if(m[ei+11|0]>-1){break b}ul(o[ei>>2])}if(!l[o[o[bi>>2]+12>>2]](bi)){bi=Hk(48);o[hi>>2]=bi;o[hi+4>>2]=33;o[hi+8>>2]=-2147483600;m[bi+33|0]=0;m[bi+32|0]=p[10306];fi=p[10302]|p[10303]<<8|(p[10304]<<16|p[10305]<<24);gi=p[10298]|p[10299]<<8|(p[10300]<<16|p[10301]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10294]|p[10295]<<8|(p[10296]<<16|p[10297]<<24);gi=p[10290]|p[10291]<<8|(p[10292]<<16|p[10293]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10286]|p[10287]<<8|(p[10288]<<16|p[10289]<<24);gi=p[10282]|p[10283]<<8|(p[10284]<<16|p[10285]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10278]|p[10279]<<8|(p[10280]<<16|p[10281]<<24);gi=p[10274]|p[10275]<<8|(p[10276]<<16|p[10277]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!l[o[o[bi>>2]+20>>2]](bi)){bi=Hk(32);o[hi>>2]=bi;o[hi+4>>2]=31;o[hi+8>>2]=-2147483616;m[bi+31|0]=0;fi=p[10335]|p[10336]<<8|(p[10337]<<16|p[10338]<<24);gi=p[10331]|p[10332]<<8|(p[10333]<<16|p[10334]<<24);m[bi+23|0]=gi;m[bi+24|0]=gi>>>8;m[bi+25|0]=gi>>>16;m[bi+26|0]=gi>>>24;m[bi+27|0]=fi;m[bi+28|0]=fi>>>8;m[bi+29|0]=fi>>>16;m[bi+30|0]=fi>>>24;fi=p[10328]|p[10329]<<8|(p[10330]<<16|p[10331]<<24);gi=p[10324]|p[10325]<<8|(p[10326]<<16|p[10327]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10320]|p[10321]<<8|(p[10322]<<16|p[10323]<<24);gi=p[10316]|p[10317]<<8|(p[10318]<<16|p[10319]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10312]|p[10313]<<8|(p[10314]<<16|p[10315]<<24);gi=p[10308]|p[10309]<<8|(p[10310]<<16|p[10311]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}if(!l[o[o[bi>>2]+24>>2]](bi)){bi=Hk(48);o[hi>>2]=bi;o[hi+4>>2]=34;o[hi+8>>2]=-2147483600;m[bi+34|0]=0;fi=p[10372]|p[10373]<<8;m[bi+32|0]=fi;m[bi+33|0]=fi>>>8;fi=p[10368]|p[10369]<<8|(p[10370]<<16|p[10371]<<24);gi=p[10364]|p[10365]<<8|(p[10366]<<16|p[10367]<<24);m[bi+24|0]=gi;m[bi+25|0]=gi>>>8;m[bi+26|0]=gi>>>16;m[bi+27|0]=gi>>>24;m[bi+28|0]=fi;m[bi+29|0]=fi>>>8;m[bi+30|0]=fi>>>16;m[bi+31|0]=fi>>>24;fi=p[10360]|p[10361]<<8|(p[10362]<<16|p[10363]<<24);gi=p[10356]|p[10357]<<8|(p[10358]<<16|p[10359]<<24);m[bi+16|0]=gi;m[bi+17|0]=gi>>>8;m[bi+18|0]=gi>>>16;m[bi+19|0]=gi>>>24;m[bi+20|0]=fi;m[bi+21|0]=fi>>>8;m[bi+22|0]=fi>>>16;m[bi+23|0]=fi>>>24;fi=p[10352]|p[10353]<<8|(p[10354]<<16|p[10355]<<24);gi=p[10348]|p[10349]<<8|(p[10350]<<16|p[10351]<<24);m[bi+8|0]=gi;m[bi+9|0]=gi>>>8;m[bi+10|0]=gi>>>16;m[bi+11|0]=gi>>>24;m[bi+12|0]=fi;m[bi+13|0]=fi>>>8;m[bi+14|0]=fi>>>16;m[bi+15|0]=fi>>>24;fi=p[10344]|p[10345]<<8|(p[10346]<<16|p[10347]<<24);gi=p[10340]|p[10341]<<8|(p[10342]<<16|p[10343]<<24);m[bi|0]=gi;m[bi+1|0]=gi>>>8;m[bi+2|0]=gi>>>16;m[bi+3|0]=gi>>>24;m[bi+4|0]=fi;m[bi+5|0]=fi>>>8;m[bi+6|0]=fi>>>16;m[bi+7|0]=fi>>>24;o[a>>2]=-1;Mk(ei,hi);if(m[hi+11|0]>-1){break a}ul(o[hi>>2]);break a}o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0}R=hi+32|0}function gi(a){a=a|0;var bi=0,ci=0,di=0,ei=0,fi=0,gi=0,ji=0,ki=0,li=0,mi=0,ni=0,oi=0;a:{bi=o[a+32>>2];ei=o[bi+16>>2];gi=o[bi+12>>2];di=o[bi+20>>2];b:{if((gi|0)<(di|0)?1:(gi|0)<=(di|0)?r[bi+8>>2]>ei>>>0?0:1:0){break b}fi=p[ei+o[bi>>2]|0];ji=ei+1|0;if(ji>>>0<1){di=di+1|0}o[bi+16>>2]=ji;o[bi+20>>2]=di;c:{if(!fi){break c}while(1){if(l[o[o[a>>2]+16>>2]](a,ci)){ci=ci+1|0;if((fi|0)!=(ci|0)){continue}break c}break}return 0}ci=o[a+8>>2];di=o[a+12>>2];if((ci|0)!=(di|0)){while(1){bi=o[ci>>2];if(!l[o[o[bi>>2]+8>>2]](bi,a,o[a+4>>2])){break b}ci=ci+4|0;if((di|0)!=(ci|0)){continue}break}}d:{if(!fi){break d}ci=0;di=a+8|0;while(1){bi=o[o[di>>2]+(ci<<2)>>2];if(!l[o[o[bi>>2]+12>>2]](bi,o[a+32>>2])){break a}ci=ci+1|0;if((fi|0)!=(ci|0)){continue}break}if(!fi){break d}ei=a+20|0;ki=a+8|0;gi=a+24|0;while(1){ci=0;ji=li<<2;bi=o[ji+o[ki>>2]>>2];di=l[o[o[bi>>2]+24>>2]](bi)|0;if((di|0)>0){while(1){bi=o[o[ki>>2]+ji>>2];bi=l[o[o[bi>>2]+20>>2]](bi,ci)|0;mi=o[a+20>>2];ni=o[gi>>2]-mi>>2;e:{if(bi>>>0>>0){break e}oi=bi+1|0;if(oi>>>0>ni>>>0){Da(ei,oi-ni|0);mi=o[ei>>2];break e}if(oi>>>0>=ni>>>0){break e}o[gi>>2]=(oi<<2)+mi}o[(bi<<2)+mi>>2]=li;ci=ci+1|0;if((di|0)!=(ci|0)){continue}break}}li=li+1|0;if((li|0)!=(fi|0)){continue}break}}ki=0;if(!l[o[o[a>>2]+28>>2]](a)){break b}ki=l[o[o[a>>2]+32>>2]](a)|0}return ki|0}return 0}function hi(a){a=a|0;var pi=0,qi=0,ri=0,si=0;qi=1;pi=o[a+8>>2];ri=o[a+12>>2];a:{if((pi|0)==(ri|0)){break a}while(1){si=o[pi>>2];if(l[o[o[si>>2]+16>>2]](si,o[a+32>>2])){pi=pi+4|0;if((ri|0)!=(pi|0)){continue}break a}break}qi=0}return qi|0}function ii(a,ti){var ui=0,vi=0;a:{if((ti|0)<0){break a}ui=o[a+4>>2];if(o[ui+12>>2]-o[ui+8>>2]>>2<=(ti|0)){break a}a=o[o[a+8>>2]+(o[o[a+20>>2]+(ti<<2)>>2]<<2)>>2];vi=l[o[o[a>>2]+32>>2]](a,ti)|0}return vi}function ji(a,ti,wi){var xi=0,yi=0,zi=0;if((ti|0)>0){while(1){yi=xi<<2;zi=o[yi+a>>2];o[wi+yi>>2]=0-(zi&1)^zi>>>1;xi=xi+1|0;if((xi|0)!=(ti|0)){continue}break}}}function ki(a){o[a+16>>2]=0;o[a+20>>2]=0;o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0}function li(a,o,ti,wi){return mi(a,o,ti,wi)}function mi(a,ti,wi,Ai){var Bi=0,Ci=0,Di=0;a:{if(!ti){ti=wi;Ai=ti>>>0<0?Ai+1|0:Ai;if((Ai|0)<0?1:(Ai|0)<=0?ti>>>0>=0?0:1:0){return 0}Ai=o[a>>2];wi=o[a+4>>2]-Ai|0;if(wi>>>0>>0){Fa(a,ti-wi|0);break a}if(wi>>>0<=ti>>>0){break a}o[a+4>>2]=ti+Ai;break a}if((Ai|0)<0?1:(Ai|0)<=0?wi>>>0>=0?0:1:0){return 0}Ci=wi;if(wi>>>0<0){Ai=Ai+1|0}Di=o[a>>2];Bi=o[a+4>>2]-Di|0;b:{if((Ai|0)<0?1:(Ai|0)<=0?Ci>>>0>Bi>>>0?0:1:0){break b}Ai=Ci;if(Bi>>>0>>0){Fa(a,Ai-Bi|0);break b}if(Bi>>>0<=Ai>>>0){break b}o[a+4>>2]=Ai+Di}if(!wi){break a}yl(o[a>>2],ti,wi)}ti=a+24|0;wi=ti;Ai=ti;a=o[ti+4>>2];ti=o[ti>>2]+1|0;if(ti>>>0<1){a=a+1|0}o[Ai>>2]=ti;o[wi+4>>2]=a;return 1}function ni(a,ti){var wi=0,Ai=0;Ai=o[a>>2];wi=o[a+4>>2]-Ai|0;a:{if(wi>>>0>>0){Fa(a,ti-wi|0);break a}if(wi>>>0<=ti>>>0){break a}o[a+4>>2]=ti+Ai}ti=a+24|0;wi=ti;Ai=ti;a=o[ti+4>>2];ti=o[ti>>2]+1|0;if(ti>>>0<1){a=a+1|0}o[Ai>>2]=ti;o[wi+4>>2]=a}function oi(a){n[a+38>>1]=0;o[a>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0;o[a+16>>2]=0;o[a+20>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0;m[a+29|0]=0;m[a+30|0]=0;m[a+31|0]=0;m[a+32|0]=0;m[a+33|0]=0;m[a+34|0]=0;m[a+35|0]=0;m[a+36|0]=0;return a}function pi(a,ti,Ei,Fi){n[a+38>>1]=Fi;o[a>>2]=ti;o[a+16>>2]=0;o[a+20>>2]=0;o[a+8>>2]=Ei;o[a+12>>2]=0}function qi(a,ti,Ei){var Fi=0;a:{if(ti){ti=0;if(!ri(1,Ei,a)){break a}}m[a+36|0]=1;o[a+32>>2]=0;ti=o[a+16>>2];Ei=ti+o[a>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ti+16|0;a=Zj(bj,_i?o[a>>2]:a,Ri);if(a){break d}}if(Zi>>>0>>0){break b}break a}if((a|0)>-1){break a}}Ti=$i}return Ti}function yi(a,Ri){var dj=0;Ri=xi(a,Ri);a:{if((Ri|0)==(a+4|0)){break a}a=Ri+28|0;if(m[Ri+39|0]<=-1){a=o[a>>2]}a=Yj(a);if((a|0)==-1){break a}dj=(a|0)!=0}return dj}function zi(a){var Ri=0;o[a>>2]=0;o[a+4>>2]=0;o[a+56>>2]=0;o[a+48>>2]=0;o[a+52>>2]=0;o[a+40>>2]=0;o[a+44>>2]=0;o[a+32>>2]=0;o[a+36>>2]=0;o[a+24>>2]=0;o[a+28>>2]=0;o[a+16>>2]=0;o[a+20>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0;Ri=a- -64|0;o[Ri>>2]=0;o[Ri+4>>2]=0;o[a+72>>2]=0;o[a+76>>2]=0;o[a+80>>2]=0;o[a+84>>2]=0;o[a+60>>2]=a}function Ai(a,ej){var fj=0,gj=0,hj=0;hj=R-16|0;R=hj;gj=Hk(88);fj=gj;o[fj>>2]=0;o[fj+4>>2]=0;o[fj+56>>2]=0;o[fj+48>>2]=0;o[fj+52>>2]=0;o[fj+40>>2]=0;o[fj+44>>2]=0;o[fj+32>>2]=0;o[fj+36>>2]=0;o[fj+24>>2]=0;o[fj+28>>2]=0;o[fj+16>>2]=0;o[fj+20>>2]=0;o[fj+8>>2]=0;o[fj+12>>2]=0;fj=fj- -64|0;o[fj>>2]=0;o[fj+4>>2]=0;o[gj+72>>2]=0;o[gj+76>>2]=0;o[gj+80>>2]=0;o[gj+84>>2]=0;o[gj+60>>2]=gj;o[hj+8>>2]=gj;a:{if(Bi(gj,ej)){o[a>>2]=o[hj+8>>2];o[hj+8>>2]=0;break a}o[a>>2]=0;a=o[hj+8>>2];o[hj+8>>2]=0;if(!a){break a}ua(hj+8|0,a)}R=hj+16|0}function Bi(a,ej){var ij=0,jj=0,kj=0,lj=0,mj=0,nj=0,oj=0;lj=R-16|0;R=lj;o[a+80>>2]=0;o[a+84>>2]=0;ij=a+76|0;jj=o[ij>>2];o[ij>>2]=0;if(jj){ul(jj)}o[a+68>>2]=0;o[a+72>>2]=0;ij=a- -64|0;jj=o[ij>>2];o[ij>>2]=0;if(jj){ul(jj)}nj=ej+4|0;ij=o[nj>>2];jj=o[ej>>2];kj=u((ij-jj|0)/12|0,3);oj=o[a>>2];mj=o[a+4>>2]-oj>>2;a:{if(kj>>>0>mj>>>0){Ci(a,kj-mj|0);ij=o[nj>>2];jj=o[ej>>2];break a}if(kj>>>0>=mj>>>0){break a}o[a+4>>2]=(kj<<2)+oj}if((ij|0)!=(jj|0)){mj=(ij-jj|0)/12|0;nj=o[a>>2];ej=0;while(1){kj=u(ej,12);ij=kj+nj|0;kj=jj+kj|0;o[ij>>2]=o[kj>>2];o[ij+4>>2]=o[kj+4>>2];o[ij+8>>2]=o[kj+8>>2];ej=ej+1|0;if(ej>>>0>>0){continue}break}}o[lj+12>>2]=-1;ej=0;if(Di(a,lj+12|0)){Ei(a);Fi(a,o[lj+12>>2]);ej=1}R=lj+16|0;return ej}function Ci(a,ej){var pj=0,qj=0,rj=0,sj=0,tj=0,uj=0,vj=0,wj=0,xj=0;qj=o[a+8>>2];rj=a+4|0;pj=o[rj>>2];if(qj-pj>>2>>>0>=ej>>>0){a=ej<<2;wj=rj,xj=xl(pj,0,a)+a|0,o[wj>>2]=xj;return}a:{rj=o[a>>2];tj=pj-rj|0;pj=tj>>2;sj=pj+ej|0;if(sj>>>0<1073741824){vj=pj<<2;qj=qj-rj|0;pj=qj>>1;qj=qj>>2>>>0<536870911?pj>>>0>>0?sj:pj:1073741823;pj=0;b:{if(!qj){break b}if(qj>>>0>=1073741824){break a}uj=Hk(qj<<2);pj=uj}xl(vj+pj|0,0,ej<<2);ej=pj+(sj<<2)|0;sj=pj+(qj<<2)|0;if((tj|0)>=1){wl(uj,rj,tj)}o[a>>2]=pj;o[a+8>>2]=sj;o[a+4>>2]=ej;if(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j|0)==(Ij|0)){break n}while(1){Cj=yj;Bj=Bj+1|0;o:{if((Bj|0)>=(Oj|0)){break o}Rj=(Cj<<3)+Dj|0;yj=Cj+1|0;Ij=(yj<<3)+Dj|0;Hj=o[Ij>>2];o[Rj>>2]=Hj;o[Rj+4>>2]=o[Ij+4>>2];if((Hj|0)!=-1){continue}}break}o[(Cj<<3)+Dj>>2]=-1;if((Lj|0)==-1){break m}yj=o[Pj>>2];o[yj+Nj>>2]=Lj;o[yj+(Lj<<2)>>2]=Ej;break l}yj=yj+1|0;Bj=Bj+1|0;if((Oj|0)!=(Bj|0)){continue}break}}yj=Fj<<2;Cj=o[yj+Qj>>2];if((Cj|0)<1){break l}yj=o[yj+Jj>>2];Bj=0;while(1){Hj=(yj<<3)+Dj|0;if(o[Hj>>2]==-1){o[Hj>>2]=Kj;o[Hj+4>>2]=Ej;break l}yj=yj+1|0;Bj=Bj+1|0;if((Cj|0)!=(Bj|0)){continue}break}}}Ej=zj;if(Ej>>>0>>0){continue}break}break b}Yk();D()}Yk();D()}_a(10468);D()}o[ej>>2]=Mj;if(Jj){o[Aj+4>>2]=Jj;ul(Jj)}a=o[Aj+16>>2];if(a){o[Aj+20>>2]=a;ul(a)}a=o[Aj+32>>2];if(a){o[Aj+36>>2]=a;ul(a)}a=1}else{a=0}R=Aj+48|0;return a}function Ei(a){var ej=0,Tj=0,Uj=0,Vj=0,Wj=0,Xj=0,Yj=0,Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0;Uj=R-48|0;R=Uj;ak=a+4|0;ej=o[ak>>2];_j=o[a>>2];m[Uj+16|0]=0;bk=Hi(Uj+32|0,ej-_j>>2,Uj+16|0);o[Uj+24>>2]=0;o[Uj+16>>2]=0;o[Uj+20>>2]=0;ej=o[ak>>2];Yj=o[a>>2];Zj=a+12|0;while(1){ck=0;Xj=0;a:{if((ej|0)==(Yj|0)){break a}while(1){Vj=o[bk>>2];b:{if(o[Vj+(Xj>>>3&536870908)>>2]>>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((ej|0)==-1){break f}Tj=ej+((ej>>>0)%3|0?-1:2)|0;if((_j|0)==(Tj|0)|(Tj|0)==-1){break f}Yj=o[a>>2];Vj=o[bk>>2];Wj=o[Uj+20>>2];ej=o[Uj+16>>2];continue}break}Yj=o[a>>2]}Xj=Xj+1|0;ej=o[ak>>2];if(Xj>>>0>2>>>0){continue}break}if(ck){continue}}break}a=o[Uj+16>>2];if(a){o[Uj+20>>2]=a;ul(a)}a=o[bk>>2];if(a){ul(a)}R=Uj+48|0}function Fi(a,fk){var gk=0,hk=0,ik=0,jk=0,kk=0,lk=0,mk=0,nk=0,ok=0,pk=0,qk=0,rk=0,sk=0,tk=0,uk=0,vk=0,wk=0,xk=0,yk=0,zk=0,Ak=0,Bk=0,Ck=0;lk=R-48|0;R=lk;o[a+36>>2]=fk;rk=a+24|0;ik=o[a+24>>2];gk=o[a+28>>2]-ik>>2;a:{if(gk>>>0>>0){Gi(rk,fk-gk|0);break a}if(gk>>>0<=fk>>>0){break a}o[a+28>>2]=ik+(fk<<2)}m[lk+16|0]=0;mk=Hi(lk+32|0,fk,lk+16|0);sk=a+4|0;gk=o[sk>>2];ik=o[a>>2];m[lk+8|0]=0;ok=Hi(lk+16|0,gk-ik>>2,lk+8|0);b:{gk=o[a>>2];if(o[sk>>2]-gk>>2>>>0<3){break b}yk=a+48|0;tk=a+12|0;zk=a+32|0;vk=a+28|0;Ak=a+56|0;wk=a+52|0;while(1){pk=u(uk,3);jk=o[(pk<<2)+gk>>2];kk=0;hk=-1;ik=pk+1|0;c:{if((ik|0)!=-1){hk=o[(ik<<2)+gk>>2];kk=pk+2|0;ik=-1;if((kk|0)==-1){break c}}ik=o[(kk<<2)+gk>>2]}d:{if(!((ik|0)==(hk|0)|(hk|0)==(jk|0)|(ik|0)==(jk|0))){nk=o[ok>>2];qk=0;while(1){ik=pk+qk|0;e:{if(o[(ik>>>3&536870908)+nk>>2]>>>(ik&31)&1){break e}kk=o[o[a>>2]+(ik<<2)>>2];o[lk+8>>2]=kk;gk=1<<(kk&31);hk=o[mk>>2];kk=kk>>>5;nk=o[hk+(kk<<2)>>2];jk=0;f:{if(!(gk&nk)){break f}gk=o[vk>>2];g:{if((gk|0)!=o[zk>>2]){o[gk>>2]=-1;o[vk>>2]=gk+4;break g}bh(rk,10464)}gk=o[wk>>2];h:{if((gk|0)!=o[Ak>>2]){o[gk>>2]=o[lk+8>>2];o[wk>>2]=gk+4;break h}bh(yk,lk+8|0)}gk=o[mk+4>>2];jk=o[mk+8>>2];if((gk|0)==jk<<5){if((gk+1|0)<=-1){break d}hk=mk;if(gk>>>0<=1073741822){gk=gk+32&-32;jk=jk<<6;gk=jk>>>0>>0?gk:jk}else{gk=2147483647}ab(hk,gk);gk=o[mk+4>>2]}o[mk+4>>2]=gk+1;hk=o[mk>>2];jk=hk+(gk>>>3&536870908)|0;kk=o[jk>>2];Bk=jk,Ck=Zl(gk)&kk,o[Bk>>2]=Ck;o[lk+8>>2]=fk;gk=1<<(fk&31);kk=fk>>>5;nk=o[(kk<<2)+hk>>2];fk=fk+1|0;jk=1}o[(kk<<2)+hk>>2]=gk|nk;nk=o[ok>>2];gk=ik;i:{while(1){if((gk|0)==-1){break i}hk=(gk>>>3&536870908)+nk|0;o[hk>>2]=o[hk>>2]|1<<(gk&31);hk=o[lk+8>>2];o[o[rk>>2]+(hk<<2)>>2]=gk;if(jk){o[o[a>>2]+(gk<<2)>>2]=hk}kk=ik;hk=gk+1|0;gk=(hk>>>0)%3|0?hk:gk+ -2|0;hk=-1;j:{if((gk|0)==-1){break j}gk=o[o[tk>>2]+(gk<<2)>>2];hk=-1;if((gk|0)==-1){break j}hk=gk+1|0;hk=(hk>>>0)%3|0?hk:gk+ -2|0}gk=hk;if((kk|0)!=(gk|0)){continue}break}if((ik|0)!=-1){break e}}gk=ik+((ik>>>0)%3|0?-1:2)|0;if((gk|0)==-1){break e}gk=o[o[tk>>2]+(gk<<2)>>2];if((gk|0)==-1){break e}gk=gk+((gk>>>0)%3|0?-1:2)|0;if((gk|0)==-1){break e}nk=o[ok>>2];while(1){ik=(gk>>>3&536870908)+nk|0;o[ik>>2]=o[ik>>2]|1<<(gk&31);if(jk){o[o[a>>2]+(gk<<2)>>2]=o[lk+8>>2]}gk=((gk>>>0)%3|0?-1:2)+gk|0;if((gk|0)==-1){break e}gk=o[o[tk>>2]+(gk<<2)>>2];if((gk|0)==-1){break e}gk=gk+((gk>>>0)%3|0?-1:2)|0;if((gk|0)!=-1){continue}break}}qk=qk+1|0;if((qk|0)!=3){continue}break}}uk=uk+1|0;gk=o[a>>2];if(uk>>>0<(o[sk>>2]-gk>>2>>>0)/3>>>0){continue}break b}break}Yk();D()}o[a+44>>2]=0;fk=o[mk>>2];gk=o[mk+4>>2];ik=gk>>>5;jk=gk&31;if(ik|jk){ik=(ik<<2)+fk|0;hk=fk;gk=0;while(1){if(!(o[hk>>2]>>>gk&1)){xk=xk+1|0;o[a+44>>2]=xk}kk=(gk|0)==31;gk=kk?0:gk+1|0;hk=kk?hk+4|0:hk;if((ik|0)!=(hk|0)|(gk|0)!=(jk|0)){continue}break}}a=o[ok>>2];if(a){ul(a);fk=o[mk>>2]}if(fk){ul(fk)}R=lk+48|0}function Gi(a,fk){var Dk=0,Ek=0,Fk=0,Gk=0,Ik=0,Jk=0;Fk=o[a+8>>2];Dk=o[a+4>>2];if(Fk-Dk>>2>>>0>=fk>>>0){while(1){o[Dk>>2]=o[2616];Dk=Dk+4|0;fk=fk+ -1|0;if(fk){continue}break}o[a+4>>2]=Dk;return}a:{Gk=o[a>>2];Ik=Dk-Gk|0;Jk=Ik>>2;Dk=Jk+fk|0;if(Dk>>>0<1073741824){Fk=Fk-Gk|0;Ek=Fk>>1;Dk=Fk>>2>>>0<536870911?Ek>>>0>>0?Dk:Ek:1073741823;Ek=0;b:{if(!Dk){break b}if(Dk>>>0>=1073741824){break a}Ek=Hk(Dk<<2)}Fk=Ek+(Dk<<2)|0;Dk=Ek+(Jk<<2)|0;while(1){o[Dk>>2]=o[2616];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(a,fk,Tk){var Uk=0,Vk=0,Wk=0,Xk=0;a:{b:{if((fk|Tk)<0|fk>>>0>1431655765){break b}fk=u(fk,3);Ki(a,fk,10460);Ki(a+12|0,fk,10464);fk=o[a+24>>2];c:{if(o[a+32>>2]-fk>>2>>>0>=Tk>>>0){break c}if(Tk>>>0>=1073741824){break a}Wk=a+28|0;Uk=o[Wk>>2];Vk=Tk<<2;Tk=Hk(Vk);Vk=Tk+Vk|0;Uk=Uk-fk|0;Xk=Uk+Tk|0;if((Uk|0)>=1){wl(Tk,fk,Uk)}o[a+24>>2]=Tk;o[a+32>>2]=Vk;o[Wk>>2]=Xk;if(!fk){break c}ul(fk)}o[a+80>>2]=0;o[a+84>>2]=0;Tk=a+76|0;fk=o[Tk>>2];o[Tk>>2]=0;if(fk){ul(fk)}o[a+68>>2]=0;o[a+72>>2]=0;fk=a- -64|0;a=o[fk>>2];o[fk>>2]=0;Uk=1;if(!a){break b}ul(a)}return Uk}_a(10468);D()}function Ki(a,fk,Tk){var Zk=0,_k=0,$k=0,al=0,bl=0;Zk=o[a+8>>2];_k=o[a>>2];if(Zk-_k>>2>>>0>=fk>>>0){$k=o[a+4>>2];al=$k-_k>>2;bl=al>>>0>>0?al:fk;if(bl){Zk=_k;while(1){o[Zk>>2]=o[Tk>>2];Zk=Zk+4|0;bl=bl+ -1|0;if(bl){continue}break}}if(al>>>0>>0){Zk=fk-al|0;while(1){o[$k>>2]=o[Tk>>2];$k=$k+4|0;Zk=Zk+ -1|0;if(Zk){continue}break}o[a+4>>2]=$k;return}o[a+4>>2]=(fk<<2)+_k;return}if(_k){o[a+4>>2]=_k;ul(_k);o[a+8>>2]=0;o[a>>2]=0;o[a+4>>2]=0;Zk=0}a:{if(fk>>>0>=1073741824){break a}_k=Zk>>1;_k=Zk>>2>>>0<536870911?_k>>>0>>0?fk:_k:1073741823;if(_k>>>0>=1073741824){break a}_k=_k<<2;Zk=Hk(_k);o[a>>2]=Zk;o[a+4>>2]=Zk;o[a+8>>2]=Zk+_k;while(1){o[Zk>>2]=o[Tk>>2];Zk=Zk+4|0;fk=fk+ -1|0;if(fk){continue}break}o[a+4>>2]=Zk;return}Yk();D()}function Li(a){qj(a);o[a+84>>2]=0;o[a+88>>2]=0;o[a>>2]=10544;o[a+92>>2]=0;o[a+96>>2]=0;o[a+100>>2]=0;o[a+104>>2]=0;return a}function Mi(a){a=a|0;var fk=0,Hk=0,Tk=0,Yk=0,cl=0;o[a>>2]=10944;fk=o[a+68>>2];if(fk){o[a+72>>2]=fk;ul(fk)}fk=o[a+56>>2];if(fk){o[a+60>>2]=fk;ul(fk)}fk=o[a+44>>2];if(fk){o[a+48>>2]=fk;ul(fk)}fk=o[a+32>>2];if(fk){o[a+36>>2]=fk;ul(fk)}fk=o[a+20>>2];if(fk){o[a+24>>2]=fk;ul(fk)}Tk=o[a+8>>2];if(Tk){fk=Tk;cl=a+12|0;Hk=o[cl>>2];Yk=fk;a:{if((fk|0)==(Hk|0)){break a}while(1){Hk=Hk+ -4|0;fk=o[Hk>>2];o[Hk>>2]=0;if(fk){Fb(fk)}if((Hk|0)!=(Tk|0)){continue}break}Yk=o[a+8>>2]}fk=Yk;o[cl>>2]=Tk;ul(fk)}fk=o[a+4>>2];o[a+4>>2]=0;if(fk){ei(fk)}return a|0}function Ni(a){a=a|0;var dl=0;o[a>>2]=10544;dl=o[a+96>>2];if(dl){o[a+100>>2]=dl;ul(dl)}dl=o[a+84>>2];if(dl){o[a+88>>2]=dl;ul(dl)}Mi(a);return a|0}function Oi(a){a=a|0;var el=0;o[a>>2]=10544;el=o[a+96>>2];if(el){o[a+100>>2]=el;ul(el)}el=o[a+84>>2];if(el){o[a+88>>2]=el;ul(el)}Mi(a);ul(a)}function Pi(a,fl,gl){a=a|0;fl=fl|0;gl=gl|0;var hl=0,il=0;hl=R-16|0;R=hl;il=o[gl>>2];o[gl>>2]=0;o[hl+8>>2]=il;wj(a,fl,hl+8|0);gl=o[hl+8>>2];o[hl+8>>2]=0;if(gl){Fb(gl)}il=o[a+84>>2];gl=o[a+88>>2]-il>>2;a:{if((gl|0)>(fl|0)){break a}fl=fl+1|0;if(fl>>>0>gl>>>0){Qi(a+84|0,fl-gl|0);break a}if(fl>>>0>=gl>>>0){break a}o[a+88>>2]=il+(fl<<2)}R=hl+16|0}function Qi(a,fl){var gl=0,jl=0,kl=0,ll=0,ml=0,nl=0;kl=o[a+8>>2];gl=o[a+4>>2];if(kl-gl>>2>>>0>=fl>>>0){while(1){o[gl>>2]=1;gl=gl+4|0;fl=fl+ -1|0;if(fl){continue}break}o[a+4>>2]=gl;return}a:{ll=o[a>>2];ml=gl-ll|0;nl=ml>>2;gl=nl+fl|0;if(gl>>>0<1073741824){kl=kl-ll|0;jl=kl>>1;gl=kl>>2>>>0<536870911?jl>>>0>>0?gl:jl:1073741823;jl=0;b:{if(!gl){break b}if(gl>>>0>=1073741824){break a}jl=Hk(gl<<2)}kl=jl+(gl<<2)|0;gl=jl+(nl<<2)|0;while(1){o[gl>>2]=1;gl=gl+4|0;fl=fl+ -1|0;if(fl){continue}break}if((ml|0)>=1){wl(jl,ll,ml)}o[a>>2]=jl;o[a+8>>2]=kl;o[a+4>>2]=gl;if(ll){ul(ll)}return}Yk();D()}_a(10588);D()}function Ri(a,fl){a=a|0;fl=fl|0;var ol=0,pl=0,ql=0;zj(a,fl);a:{if((fl|0)<0){break a}ol=o[a+88>>2];pl=o[a+84>>2];if(ol-pl>>2<=(fl|0)){break a}fl=pl+(fl<<2)|0;pl=fl+4|0;ol=ol-pl|0;ql=ol>>2;if(ol){yl(fl,pl,ol)}o[a+88>>2]=fl+(ql<<2)}}function Si(a,fl){var rl=0,sl=0,tl=0,vl=0,xl=0,yl=0;a:{tl=o[a>>2];xl=o[a+4>>2]-tl|0;rl=xl>>2;sl=rl+1|0;if(sl>>>0<1073741824){yl=rl<<2;rl=o[a+8>>2]-tl|0;vl=rl>>1;sl=rl>>2>>>0<536870911?vl>>>0>>0?sl:vl:1073741823;rl=0;b:{if(!sl){break b}if(sl>>>0>=1073741824){break a}rl=Hk(sl<<2)}vl=yl+rl|0;o[vl>>2]=o[fl>>2];fl=rl+(sl<<2)|0;sl=vl+4|0;if((xl|0)>=1){wl(rl,tl,xl)}o[a>>2]=rl;o[a+8>>2]=fl;o[a+4>>2]=sl;if(tl){ul(tl)}return}Yk();D()}_a(10656);D()}function Ti(a){o[a>>2]=0;o[a+4>>2]=0;m[a+24|0]=1;o[a+16>>2]=0;o[a+20>>2]=0;o[a+8>>2]=0;o[a+12>>2]=0;o[a+28>>2]=0;o[a+32>>2]=0;o[a+36>>2]=0;o[a+40>>2]=0;o[a+44>>2]=0;o[a+48>>2]=0;o[a+52>>2]=0;o[a+56>>2]=0;o[a+60>>2]=0;o[a+64>>2]=0;o[a+72>>2]=0;o[a+76>>2]=0;o[a+80>>2]=0;o[a+84>>2]=0;o[a+88>>2]=0;o[a+92>>2]=0;o[a+68>>2]=a}function Ui(a,fl){var zl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0;El=R-16|0;R=El;a:{b:{if(fl){o[a+88>>2]=0;o[a+92>>2]=0;zl=a+84|0;Al=o[zl>>2];o[zl>>2]=0;if(Al){ul(Al)}o[a+76>>2]=0;o[a+80>>2]=0;zl=a+72|0;Al=o[zl>>2];o[zl>>2]=0;if(Al){ul(Al)}Al=fl+4|0;zl=o[Al>>2];Bl=o[fl>>2];m[El+15|0]=0;$a(a,zl-Bl>>2,El+15|0);Bl=fl+28|0;zl=o[Bl>>2];Cl=o[fl+24>>2];m[El+14|0]=0;$a(a+12|0,zl-Cl>>2,El+14|0);Ki(a+28|0,o[Al>>2]-o[fl>>2]>>2,10724);Al=o[a+52>>2];Cl=o[Bl>>2]-o[fl+24>>2]|0;zl=Cl>>2;c:{if(o[a+60>>2]-Al>>2>>>0>=zl>>>0){break c}if(zl>>>0>=1073741824){break b}Fl=a+56|0;Dl=o[Fl>>2];Gl=zl<<2;zl=Hk(Cl);Gl=Gl+zl|0;Cl=Dl-Al|0;Dl=Cl+zl|0;if((Cl|0)>=1){wl(zl,Al,Cl)}o[a+52>>2]=zl;o[a+60>>2]=Gl;o[Fl>>2]=Dl;if(!Al){break c}ul(Al)}Al=o[a+40>>2];Bl=o[Bl>>2]-o[fl+24>>2]|0;zl=Bl>>2;d:{if(o[a+48>>2]-Al>>2>>>0>=zl>>>0){break d}if(zl>>>0>=1073741824){break a}Cl=a+44|0;Fl=o[Cl>>2];Dl=zl<<2;zl=Hk(Bl);Dl=Dl+zl|0;Bl=Fl-Al|0;Fl=Bl+zl|0;if((Bl|0)>=1){wl(zl,Al,Bl)}o[a+40>>2]=zl;o[a+48>>2]=Dl;o[Cl>>2]=Fl;if(!Al){break d}ul(Al)}m[a+24|0]=1;o[a+64>>2]=fl}R=El+16|0;return}_a(10728);D()}_a(10728);D()}function Vi(a){var fl=0,ul=0,wl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0,Ml=0,Nl=0,Ol=0,Pl=0,Ql=0;wl=R-32|0;R=wl;Jl=a+56|0;o[Jl>>2]=o[a+52>>2];Kl=a+44|0;o[Kl>>2]=o[a+40>>2];fl=o[a+64>>2];if(o[fl+28>>2]!=o[fl+24>>2]){Ml=a+40|0;Nl=a+52|0;Ol=a+60|0;Pl=a+48|0;while(1){ul=o[o[fl+24>>2]+(Ll<<2)>>2];a:{if((ul|0)==-1){break a}o[wl+24>>2]=Il;fl=o[Jl>>2];b:{if((fl|0)!=o[Ol>>2]){o[fl>>2]=Il;o[Jl>>2]=fl+4;break b}Xi(Nl,wl+24|0)}o[wl+16>>2]=ul;o[wl+8>>2]=0;c:{if(!(o[o[a+12>>2]+(Ll>>>3&536870908)>>2]>>>(Ll&31)&1)){break c}d:{fl=ul+1|0;fl=(fl>>>0)%3|0?fl:ul+ -2|0;if(!((fl|0)==-1|o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){fl=o[o[o[a+64>>2]+12>>2]+(fl<<2)>>2];if((fl|0)!=-1){break d}}o[wl+8>>2]=-1;break c}Hl=fl+1|0;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;o[wl+8>>2]=fl;if((fl|0)==-1){break c}while(1){o[wl+16>>2]=fl;e:{Hl=fl+1|0;ul=fl;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;if(!((fl|0)==-1|o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){fl=o[o[o[a+64>>2]+12>>2]+(fl<<2)>>2];if((fl|0)!=-1){break e}}o[wl+8>>2]=-1;break c}Hl=fl+1|0;fl=(Hl>>>0)%3|0?Hl:fl+ -2|0;o[wl+8>>2]=fl;if((fl|0)!=-1){continue}break}}Ql=a+28|0;o[o[Ql>>2]+(ul<<2)>>2]=o[wl+24>>2];fl=o[Kl>>2];f:{if((fl|0)!=o[Pl>>2]){o[fl>>2]=o[wl+16>>2];o[Kl>>2]=fl+4;break f}bh(Ml,wl+16|0)}Il=Il+1|0;fl=o[a+64>>2];g:{Hl=o[wl+16>>2];if((Hl|0)==-1){break g}ul=Hl+((Hl>>>0)%3|0?-1:2)|0;if((ul|0)==-1){break g}ul=o[o[fl+12>>2]+(ul<<2)>>2];if((ul|0)==-1){break g}ul=ul+((ul>>>0)%3|0?-1:2)|0;o[wl+8>>2]=ul;if((ul|0)==-1|(ul|0)==(Hl|0)){break a}while(1){fl=ul+1|0;fl=(fl>>>0)%3|0?fl:ul+ -2|0;h:{if(!(o[o[a>>2]+(fl>>>3&536870908)>>2]>>>(fl&31)&1)){break h}o[wl+24>>2]=Il;fl=o[Jl>>2];i:{if((fl|0)!=o[Ol>>2]){o[fl>>2]=Il;o[Jl>>2]=fl+4;break i}Xi(Nl,wl+24|0)}Il=Il+1|0;fl=o[Kl>>2];if((fl|0)!=o[Pl>>2]){o[fl>>2]=o[wl+8>>2];o[Kl>>2]=fl+4;break h}bh(Ml,wl+8|0)}o[o[Ql>>2]+(o[wl+8>>2]<<2)>>2]=o[wl+24>>2];fl=o[a+64>>2];ul=o[wl+8>>2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o[Wl>>2]+(Rl<<2)>>2]}Rl=1<<(a&31);a=Tl+(a>>>3&536870908)|0;Sl=o[a>>2];break c}a=Tl+536870908|0;Rl=o[Tl+536870908>>2];Sl=-2147483648}o[a>>2]=Rl|Sl}}function Xi(a,Rl){var Yl=0,Zl=0,_l=0,$l=0,am=0,bm=0;a:{_l=o[a>>2];am=o[a+4>>2]-_l|0;Yl=am>>2;Zl=Yl+1|0;if(Zl>>>0<1073741824){bm=Yl<<2;Yl=o[a+8>>2]-_l|0;$l=Yl>>1;Zl=Yl>>2>>>0<536870911?$l>>>0>>0?Zl:$l:1073741823;Yl=0;b:{if(!Zl){break b}if(Zl>>>0>=1073741824){break a}Yl=Hk(Zl<<2)}$l=bm+Yl|0;o[$l>>2]=o[Rl>>2];Rl=Yl+(Zl<<2)|0;Zl=$l+4|0;if((am|0)>=1){wl(Yl,_l,am)}o[a>>2]=Yl;o[a+8>>2]=Rl;o[a+4>>2]=Zl;if(_l){ul(_l)}return}Yk();D()}_a(10728);D()}function Yi(a,Rl){var cm=0,dm=0,em=0,fm=0,gm=0,hm=0,im=0,jm=0,km=0,lm=0,mm=0;dm=R-16|0;R=dm;a:{em=sj(Rl);if(!em){o[a>>2]=0;break a}fm=o[Rl+100>>2];jm=o[Rl+96>>2];o[dm+8>>2]=0;o[dm>>2]=0;o[dm+4>>2]=0;Rl=fm-jm|0;im=(Rl|0)/12|0;b:{if(Rl){if(im>>>0>=357913942){break b}gm=Hk(Rl);o[dm>>2]=gm;o[dm+4>>2]=gm;o[dm+8>>2]=u(im,12)+gm;Rl=xl(gm,0,Rl);cm=im;while(1){Rl=Rl+12|0;cm=cm+ -1|0;if(cm){continue}break}o[dm+4>>2]=Rl}if((fm|0)!=(jm|0)){Rl=0;lm=p[em+84|0];mm=em+68|0;while(1){km=u(Rl,12);cm=km+jm|0;em=o[cm>>2];c:{if(lm){fm=cm+8|0;cm=cm+4|0;break c}hm=o[mm>>2];fm=hm+(o[cm+8>>2]<<2)|0;em=o[hm+(em<<2)>>2];cm=hm+(o[cm+4>>2]<<2)|0}hm=o[cm>>2];cm=gm+km|0;o[cm+8>>2]=o[fm>>2];o[cm+4>>2]=hm;o[cm>>2]=em;Rl=Rl+1|0;if(Rl>>>0>>0){continue}break}}Ai(a,dm);a=o[dm>>2];if(!a){break a}o[dm+4>>2]=a;ul(a);break a}Yk();D()}R=dm+16|0}function Zi(a,Rl,nm){var om=0,pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0,Cm=0,Dm=0;tm=R-16|0;R=tm;sm=u(Rl,12)+a|0;um=sm+12|0;zm=sm+8|0;o[um>>2]=o[zm>>2];o[tm+8>>2]=(nm|0)==-1?-1:(nm>>>0)/3|0;Am=sm+16|0;Bm=a+4|0;qm=nm;while(1){sm=pm;vm=(pm|0)==1;a:{b:{if(!vm){pm=o[tm+8>>2];break b}if((qm|0)==-1){qm=-1;_i(a,-1);break a}if((qm|0)==-1|(_i(a,((qm>>>0)%3|0?-1:2)+qm|0)|0)==-1){break a}nm=qm+1|0;om=(nm>>>0)%3|0?nm:qm+ -2|0;if((om|0)==-1){break a}nm=om+1|0;nm=(nm>>>0)%3|0?nm:om+ -2|0;if((nm|0)==-1){break a}om=o[o[o[Bm>>2]+12>>2]+(nm<<2)>>2];if((om|0)==-1){break a}nm=om+1|0;nm=(nm>>>0)%3|0?nm:om+ -2|0;if((nm|0)==-1){break a}pm=(nm>>>0)/3|0;o[tm+8>>2]=pm}wm=1<<(pm&31);xm=o[a+56>>2]+(pm>>>3&536870908)|0;ym=o[xm>>2];c:{if(wm&ym){break c}rm=0;while(1){o[xm>>2]=wm|ym;om=o[um>>2];d:{if((om|0)!=o[Am>>2]){o[om>>2]=pm;o[um>>2]=om+4;break d}Si(zm,tm+8|0)}om=rm+1|0;e:{if(!rm){break e}if(om&1){if((nm|0)==-1){nm=-1;break e}rm=nm+1|0;nm=(rm>>>0)%3|0?rm:nm+ -2|0;break e}qm=vm?nm:qm;if((nm|0)==-1){nm=-1;break e}if((nm>>>0)%3){nm=nm+ -1|0;break e}nm=nm+2|0}nm=_i(a,nm);if((nm|0)!=-1){pm=(nm>>>0)/3|0;o[tm+8>>2]=pm;rm=om;wm=1<<(pm&31);xm=o[a+56>>2]+(pm>>>3&268435452)|0;ym=o[xm>>2];if(!(wm&ym)){continue}}break}if(!(om&1)|(sm|0)!=1){break c}vm=o[um>>2]+ -4|0;pm=o[vm>>2];rm=o[a+56>>2]+(pm>>>3&536870908)|0;om=o[rm>>2];Cm=rm,Dm=Zl(pm)&om,o[Cm>>2]=Dm;o[um>>2]=vm}pm=1;if(!sm){continue}}break}o[((Rl<<2)+a|0)+44>>2]=qm;Rl=o[um>>2];qm=o[zm>>2];if((Rl|0)!=(qm|0)){rm=Rl-qm>>2;om=o[a+56>>2];nm=0;while(1){sm=o[qm+(nm<<2)>>2];Rl=om+(sm>>>3&536870908)|0;a=o[Rl>>2];Cm=Rl,Dm=Zl(sm)&a,o[Cm>>2]=Dm;nm=nm+1|0;if(nm>>>0>>0){continue}break}}R=tm+16|0}function _i(a,Rl){var nm=0,Em=0,Fm=0,Gm=0,Hm=0;Em=-1;Gm=-1;Fm=-1;a:{b:{if((Rl|0)==-1){break b}Hm=1;Gm=o[o[o[a+4>>2]+12>>2]+(Rl<<2)>>2];nm=Rl+1|0;nm=(nm>>>0)%3|0?nm:Rl+ -2|0;if((nm|0)>=0){Fm=(nm>>>0)/3|0;Fm=o[(o[o[a>>2]+96>>2]+u(Fm,12)|0)+(nm-u(Fm,3)<<2)>>2]}c:{if((Gm|0)==-1){break c}Hm=0;nm=((Gm>>>0)%3|0?-1:2)+Gm|0;if((nm|0)<0){break c}Em=(nm>>>0)/3|0;Em=o[(o[o[a>>2]+96>>2]+u(Em,12)|0)+(nm-u(Em,3)<<2)>>2]}nm=-1;if((Em|0)!=(Fm|0)){break a}Fm=-1;d:{Rl=((Rl>>>0)%3|0?-1:2)+Rl|0;if((Rl|0)>=0){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im;o[Jm+32>>2]=Rl;if(!Om){break f}ul(Om)}Pm=Pm+1|0;if(Pm>>>0>>0){continue}break}}Rl=o[Jm+36>>2];Im=o[Jm+32>>2];if((Rl|0)!=(Im|0)){continue}break}a=1;break a}Yk();D()}_a(10796);D()}Im=o[Jm+32>>2];a=0}if(Im){o[Jm+36>>2]=Im;ul(Im)}R=Jm+48|0;return a}function aj(a,Rl,Tm){var Um=0,Vm=0,Wm=0,Xm=0;a:{if(a>>>0>5){break a}Wm=o[Tm+16>>2];Um=o[Tm+12>>2];Vm=o[Tm+20>>2];if((Um|0)<(Vm|0)?1:(Um|0)<=(Vm|0)?r[Tm+8>>2]>Wm>>>0?0:1:0){break a}Um=p[Wm+o[Tm>>2]|0];Wm=Wm+1|0;if(Wm>>>0<1){Vm=Vm+1|0}o[Tm+16>>2]=Wm;o[Tm+20>>2]=Vm;Vm=Rl;if(Um&128){if(!aj(a+1|0,Rl,Tm)){break a}a=o[Rl>>2]<<7;o[Rl>>2]=a;Um=a|Um&127}o[Vm>>2]=Um;Xm=1}return Xm}function bj(a,Rl){var Tm=0,Ym=0,Zm=0,_m=0,$m=0,an=0,bn=0,cn=0,dn=0,en=0;Ym=R-32|0;R=Ym;o[Ym+24>>2]=0;o[Ym+16>>2]=0;o[Ym+20>>2]=0;a:{Zm=o[a>>2];Tm=Zm;$m=o[Tm+16>>2];an=r[Tm+8>>2]>$m>>>0?0:1;_m=o[Tm+12>>2];Tm=o[Tm+20>>2];b:{if((_m|0)<(Tm|0)?1:(_m|0)<=(Tm|0)?an:0){break b}an=p[$m+o[Zm>>2]|0];_m=Tm;Tm=$m+1|0;if(Tm>>>0<1){_m=_m+1|0}o[Zm+16>>2]=Tm;o[Zm+20>>2]=_m;Rk(Ym+16|0,an);if(an){_m=o[a>>2];cn=Vk(Ym+16|0);en=o[_m+12>>2];$m=o[_m+20>>2];dn=o[_m+16>>2];Zm=an;Tm=dn+Zm|0;if(Tm>>>0>>0){$m=$m+1|0}if((en|0)<($m|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28);jn=gn+4|0;o[jn>>2]=0;o[jn+4>>2]=0;kn=gn+16|0;o[kn>>2]=0;o[kn+4>>2]=0;o[gn>>2]=jn;jn=gn+12|0;o[jn>>2]=kn;o[gn+24>>2]=o[hn+8>>2];if(!$i(a,gn)){break c}o[hn>>2]=gn;ej(fn,hn);gn=o[hn>>2];o[hn>>2]=0;if(gn){Fc(gn+12|0,o[gn+16>>2]);Gc(gn,o[gn+4>>2]);ul(gn)}Rl=Rl+1|0;if(Rl>>>0>>0){continue}break}}gn=$i(a,fn);break a}Fc(jn,o[gn+16>>2]);Gc(gn,o[gn+4>>2]);ul(gn)}gn=0}R=hn+16|0;return gn}function dj(a,Rl,fn){var mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0,wn=0,xn=0;mn=R-16|0;R=mn;pn=o[a+24>>2];un=o[a+28>>2];a:{if((pn|0)!=(un|0)){wn=mn+8|0;xn=fn+4|0;while(1){o[wn>>2]=0;o[mn>>2]=0;o[mn+4>>2]=0;a=mj(o[pn>>2],Rl,mn);qn=p[mn+11|0];tn=qn<<24>>24;b:{c:{d:{if(!a){a=3;break d}a=0;nn=p[fn+11|0];on=nn<<24>>24;sn=(tn|0)<0?o[mn+4>>2]:qn;if((sn|0)!=(((on|0)<0?o[xn>>2]:nn)|0)){break d}rn=(on|0)<0?o[fn>>2]:fn;on=o[mn>>2];nn=(tn|0)<0;e:{if(!nn){if(!sn){break e}nn=mn;if(p[rn|0]!=(on&255)){break d}while(1){qn=qn+ -1|0;if(!qn){break e}on=p[rn+1|0];rn=rn+1|0;nn=nn+1|0;if((on|0)==p[nn|0]){continue}break}break d}if(!sn){break e}if(Zj(nn?on:mn,rn,sn)){break c}}vn=o[pn>>2];a=1}if((tn|0)>-1){break b}}ul(o[mn>>2])}if(a>>>0>3){break a}f:{switch(a-1|0){case 0:case 1:break a;default:break f}}pn=pn+4|0;if((un|0)!=(pn|0)){continue}break}}vn=0}R=mn+16|0;return vn}function ej(a,Rl){var fn=0,yn=0,zn=0;yn=o[Rl>>2];if(!yn){return}fn=a+28|0;zn=o[fn>>2];if(zn>>>0>2]){o[Rl>>2]=0;o[zn>>2]=yn;o[fn>>2]=o[fn>>2]+4;return}fj(a+24|0,Rl)}function fj(a,Rl){var An=0,Bn=0,Cn=0,Dn=0,En=0;a:{b:{c:{Cn=o[a>>2];Dn=o[a+4>>2]-Cn>>2;An=Dn+1|0;if(An>>>0<1073741824){Cn=o[a+8>>2]-Cn|0;En=Cn>>1;An=Cn>>2>>>0<536870911?En>>>0>>0?An:En:1073741823;if(An){if(An>>>0>=1073741824){break c}Bn=Hk(An<<2)}Cn=o[Rl>>2];o[Rl>>2]=0;Rl=(Dn<<2)+Bn|0;o[Rl>>2]=Cn;Cn=(An<<2)+Bn|0;Dn=Rl+4|0;An=o[a+4>>2];Bn=o[a>>2];if((An|0)==(Bn|0)){break b}while(1){An=An+ -4|0;En=o[An>>2];o[An>>2]=0;Rl=Rl+ -4|0;o[Rl>>2]=En;if((An|0)!=(Bn|0)){continue}break}Bn=o[a+4>>2];An=o[a>>2];break a}Yk();D()}_a(10864);D()}An=Bn}o[a>>2]=Rl;o[a+8>>2]=Cn;o[a+4>>2]=Dn;if((An|0)!=(Bn|0)){while(1){Bn=Bn+ -4|0;a=o[Bn>>2];o[Bn>>2]=0;if(a){Fc(a+12|0,o[a+16>>2]);Gc(a,o[a+4>>2]);ul(a)}if((An|0)!=(Bn|0)){continue}break}}if(An){ul(An)}}function gj(a,Rl,Fn,Gn){var Hn=0,In=0,Jn=0,Kn=0;Hn=R-16|0;R=Hn;Kn=a;In=Zf(Rl,Hn+12|0,Fn);Fn=o[In>>2];if(Fn){Rl=0}else{Fn=Hk(32);Mk(Fn+16|0,o[Gn>>2]);o[Fn+28>>2]=0;o[Fn+8>>2]=o[Hn+12>>2];o[Fn>>2]=0;o[Fn+4>>2]=0;o[In>>2]=Fn;Gn=Fn;Jn=o[o[Rl>>2]>>2];if(Jn){o[Rl>>2]=Jn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<<16|p[a+3|0]<<24)}}function kj(a,Rl,Mn){var Tn=0,Un=0,Vn=0,Wn=0;a:{Rl=xi(a,Rl);b:{if((Rl|0)==(a+4|0)){break b}a=o[Rl+28>>2];Tn=o[Rl+32>>2];if((a|0)==(Tn|0)){break b}a=Tn-a|0;if(a&3){break b}Tn=a>>>2;Wn=Mn+4|0;Un=o[Wn>>2];a=o[Mn>>2];Vn=Un-a>>2;c:{if(Tn>>>0>Vn>>>0){Da(Mn,Tn-Vn|0);Un=o[Wn>>2];a=o[Mn>>2];break c}if(Tn>>>0>=Vn>>>0){break c}Un=(Tn<<2)+a|0;o[Mn+4>>2]=Un}if((a|0)==(Un|0)){break a}Mn=a;a=o[Rl+28>>2];wl(Mn,a,o[Rl+32>>2]-a|0)}return}Zk();D()}function lj(a,Rl,Mn){var Xn=0;Xn=a+4|0;a=xi(a,Rl);a:{if((Xn|0)==(a|0)){break a}Rl=o[a+32>>2];a=o[a+28>>2];if((Rl-a|0)!=8){break a}Rl=p[a+4|0]|p[a+5|0]<<8|(p[a+6|0]<<16|p[a+7|0]<<24);o[Mn>>2]=p[a|0]|p[a+1|0]<<8|(p[a+2|0]<<16|p[a+3|0]<<24);o[Mn+4>>2]=Rl}}function mj(a,Rl,Mn){var Yn=0,Zn=0,_n=0;Yn=a+4|0;a=xi(a,Rl);a:{if((Yn|0)==(a|0)){break a}Rl=a+32|0;Yn=o[Rl>>2];Zn=o[a+28>>2];if((Yn|0)==(Zn|0)){break a}Rk(Mn,Yn-Zn|0);Mn=Vk(Mn);a=o[a+28>>2];wl(Mn,a,o[Rl>>2]-a|0);_n=1}return _n}function nj(a,Rl,Mn){var $n=0,ao=0,bo=0,co=0;$n=R+ -64|0;R=$n;ao=xi(a,Rl);if((ao|0)!=(a+4|0)){hj(a,ao)}ao=0;o[$n+16>>2]=0;o[$n+8>>2]=0;o[$n+12>>2]=0;co=o[Mn>>2];bo=o[Mn+4>>2]-co|0;if(bo){Fa($n+8|0,bo);co=o[Mn>>2];Mn=o[$n+8>>2]}else{Mn=0}wl(Mn,co,bo);co=Mk($n+24|0,Rl);o[$n+44>>2]=0;o[$n+36>>2]=0;o[$n+40>>2]=0;Rl=o[$n+12>>2];Mn=o[$n+8>>2];bo=Rl-Mn|0;if(bo){Fa($n+36|0,bo);Mn=o[$n+8>>2];ao=o[$n+36>>2];Rl=o[$n+12>>2]}wl(ao,Mn,Rl-Mn|0);Rl=Zf(a,$n+60|0,co);if(!o[Rl>>2]){ij($n+48|0,a,$n+24|0);Mn=o[$n+48>>2];o[Mn+8>>2]=o[$n+60>>2];o[Mn>>2]=0;o[Mn+4>>2]=0;o[Rl>>2]=Mn;ao=o[o[a>>2]>>2];if(ao){o[a>>2]=ao;Mn=o[Rl>>2]}Xf(o[a+4>>2],Mn);a=a+8|0;o[a>>2]=o[a>>2]+1}a=o[$n+36>>2];if(a){o[$n+40>>2]=a;ul(a)}if(m[$n+35|0]<=-1){ul(o[$n+24>>2])}a=o[$n+8>>2];if(a){o[$n+12>>2]=a;ul(a)}R=$n- -64|0}function oj(a,Rl,Mn){var eo=0,fo=0;eo=R-32|0;R=eo;fo=a+12|0;a:{if((xi(fo,Rl)|0)!=(a+16|0)){break a}o[eo+16>>2]=Rl;gj(eo+24|0,fo,Rl,eo+16|0);a=o[eo+24>>2];Rl=o[Mn>>2];o[Mn>>2]=0;Mn=a+28|0;a=o[Mn>>2];o[Mn>>2]=Rl;if(!a){break a}Fc(a+12|0,o[a+16>>2]);Gc(a,o[a+4>>2]);ul(a)}R=eo+32|0}function pj(a,Rl){var Mn=0,go=0,ho=0,io=0,jo=0,ko=0;a:{b:{go=Rl;ho=o[Rl>>2];if(ho){Mn=o[Rl+4>>2];if(!Mn){break b}while(1){go=Mn;Mn=o[Mn>>2];if(Mn){continue}break}}ho=o[go+4>>2];if(ho){break b}ho=0;jo=0;break a}o[ho+8>>2]=o[go+8>>2];jo=1}io=o[go+8>>2];Mn=o[io>>2];c:{if((Mn|0)==(go|0)){o[io>>2]=ho;if((a|0)==(go|0)){Mn=0;a=ho;break c}Mn=o[io+4>>2];break c}o[io+4>>2]=ho}d:{e:{f:{ko=!p[go+12|0];if((Rl|0)!=(go|0)){io=o[Rl+8>>2];o[go+8>>2]=io;o[io+((o[o[Rl+8>>2]>>2]!=(Rl|0))<<2)>>2]=go;io=o[Rl>>2];o[go>>2]=io;o[io+8>>2]=go;io=o[Rl+4>>2];o[go+4>>2]=io;if(io){o[io+8>>2]=go}m[go+12|0]=p[Rl+12|0];a=(a|0)==(Rl|0)?go:a}if(!(ko|!a)){if(!jo){while(1){Rl=p[Mn+12|0];g:{ho=o[Mn+8>>2];if(o[ho>>2]!=(Mn|0)){if(!Rl){m[Mn+12|0]=1;m[ho+12|0]=0;Rl=ho+4|0;jo=o[Rl>>2];go=o[jo>>2];o[Rl>>2]=go;if(go){o[go+8>>2]=ho}o[jo+8>>2]=o[ho+8>>2];Rl=o[ho+8>>2];o[((ho|0)==o[Rl>>2]?Rl:Rl+4|0)>>2]=jo;o[jo>>2]=ho;o[ho+8>>2]=jo;Rl=o[Mn>>2];a=(Rl|0)==(a|0)?Mn:a;Mn=o[Rl+4>>2]}go=o[Mn>>2];if(!(p[go+12|0]?0:go)){Rl=o[Mn+4>>2];if(p[Rl+12|0]?0:Rl){break f}m[Mn+12|0]=0;Mn=o[Mn+8>>2];h:{if((Mn|0)==(a|0)){Mn=a;break h}if(p[Mn+12|0]){break g}}m[Mn+12|0]=1;return}Rl=o[Mn+4>>2];if(Rl){break f}break e}i:{if(Rl){Rl=Mn;break i}m[Mn+12|0]=1;m[ho+12|0]=0;Rl=o[Mn+4>>2];o[ho>>2]=Rl;if(Rl){o[Rl+8>>2]=ho}o[Mn+8>>2]=o[ho+8>>2];go=o[ho+8>>2];j:{if((ho|0)==o[go>>2]){o[go>>2]=Mn;Rl=o[ho>>2];break j}o[go+4>>2]=Mn}o[Mn+4>>2]=ho;o[ho+8>>2]=Mn;a=(a|0)==(ho|0)?Mn:a}go=o[Rl>>2];k:{if(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4|0)>>2]=Rl;o[Rl>>2]=Mn;o[Mn+8>>2]=Rl}function qj(a){o[a>>2]=10944;xl(a+4|0,0,80);return a}function rj(a,Rl){var lo=0;lo=-1;a:{if((Rl|0)==-1|(Rl|0)>4){break a}Rl=u(Rl,12)+a|0;a=o[Rl+20>>2];if((o[Rl+24>>2]-a|0)<1){break a}lo=o[a>>2]}return lo}function sj(a){var Rl=0,mo=0;Rl=o[a+20>>2];a:{if((o[a+24>>2]-Rl|0)<1){break a}Rl=o[Rl>>2];if((Rl|0)==-1){break a}mo=o[o[a+8>>2]+(Rl<<2)>>2]}return mo}function tj(a,no){var oo=0,po=0,qo=0;oo=o[a+8>>2];a=o[a+12>>2];a:{if((oo|0)==(a|0)){break a}qo=a-oo>>2;a=0;while(1){po=o[(a<<2)+oo>>2];if(o[po+60>>2]==(no|0)){break a}a=a+1|0;if(a>>>0>>0){continue}break}po=0}return po}function uj(a,no){var ro=0,so=0;ro=o[a+8>>2];a=o[a+12>>2];if((ro|0)!=(a|0)){so=a-ro>>2;a=0;while(1){if(o[o[(a<<2)+ro>>2]+60>>2]==(no|0)){return a}a=a+1|0;if(a>>>0>>0){continue}break}}return-1}function vj(a,no){var to=0,uo=0,vo=0,wo=0,xo=0;to=R-16|0;R=to;uo=a+12|0;vo=o[uo>>2];wo=o[a+8>>2];xo=o[no>>2];o[no>>2]=0;o[to+8>>2]=xo;l[o[o[a>>2]+8>>2]](a,vo-wo>>2,to+8|0);no=o[to+8>>2];o[to+8>>2]=0;if(no){Fb(no)}R=to+16|0;return(o[uo>>2]-o[a+8>>2]>>2)+ -1|0}function wj(a,no,yo){a=a|0;no=no|0;yo=yo|0;var zo=0,Ao=0,Bo=0,Co=0,Do=0,Eo=0;Co=R-16|0;R=Co;o[Co+12>>2]=no;Do=a+8|0;zo=o[a+12>>2];Eo=o[a+8>>2];Ao=zo-Eo>>2;a:{if((Ao|0)>(no|0)){break a}Bo=no+1|0;if(Bo>>>0>Ao>>>0){xj(Do,Bo-Ao|0);break a}if(Bo>>>0>=Ao>>>0){break a}Ao=Eo+(Bo<<2)|0;if((Ao|0)!=(zo|0)){while(1){zo=zo+ -4|0;Bo=o[zo>>2];o[zo>>2]=0;if(Bo){Fb(Bo)}if((zo|0)!=(Ao|0)){continue}break}}o[a+12>>2]=Ao}zo=o[o[yo>>2]+56>>2];b:{if((zo|0)>4){break b}zo=u(zo,12)+a|0;Ao=zo+24|0;a=o[Ao>>2];if((a|0)!=o[zo+28>>2]){o[a>>2]=no;o[Ao>>2]=a+4;break b}yj(zo+20|0,Co+12|0)}no=o[yo>>2];a=o[Co+12>>2];o[no+60>>2]=a;zo=o[Do>>2];o[yo>>2]=0;yo=zo+(a<<2)|0;a=o[yo>>2];o[yo>>2]=no;if(a){Fb(a)}R=Co+16|0}function xj(a,no){var yo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0;Fo=o[a+8>>2];Go=a+4|0;yo=o[Go>>2];if(Fo-yo>>2>>>0>=no>>>0){a=no<<2;Lo=Go,Mo=xl(yo,0,a)+a|0,o[Lo>>2]=Mo;return}a:{Go=o[a>>2];Ho=yo-Go>>2;Io=Ho+no|0;if(Io>>>0<1073741824){Ho=Ho<<2;Fo=Fo-Go|0;Ko=Fo>>1;Fo=Fo>>2>>>0<536870911?Ko>>>0>>0?Io:Ko:1073741823;if(Fo){if(Fo>>>0>=1073741824){break a}Jo=Hk(Fo<<2)}Ho=Ho+Jo|0;xl(Ho,0,no<<2);no=(Io<<2)+Jo|0;Io=(Fo<<2)+Jo|0;if((yo|0)!=(Go|0)){while(1){yo=yo+ -4|0;Fo=o[yo>>2];o[yo>>2]=0;Ho=Ho+ -4|0;o[Ho>>2]=Fo;if((yo|0)!=(Go|0)){continue}break}Go=o[a>>2];yo=o[a+4>>2]}o[a>>2]=Ho;o[a+8>>2]=Io;o[a+4>>2]=no;if((yo|0)!=(Go|0)){while(1){yo=yo+ -4|0;a=o[yo>>2];o[yo>>2]=0;if(a){Fb(a)}if((yo|0)!=(Go|0)){continue}break}}if(Go){ul(Go)}return}Yk();D()}_a(10992);D()}function yj(a,no){var No=0,Oo=0,Po=0,Qo=0,Ro=0,So=0;a:{Po=o[a>>2];Ro=o[a+4>>2]-Po|0;No=Ro>>2;Oo=No+1|0;if(Oo>>>0<1073741824){So=No<<2;No=o[a+8>>2]-Po|0;Qo=No>>1;Oo=No>>2>>>0<536870911?Qo>>>0>>0?Oo:Qo:1073741823;No=0;b:{if(!Oo){break b}if(Oo>>>0>=1073741824){break a}No=Hk(Oo<<2)}Qo=So+No|0;o[Qo>>2]=o[no>>2];no=No+(Oo<<2)|0;Oo=Qo+4|0;if((Ro|0)>=1){wl(No,Po,Ro)}o[a>>2]=No;o[a+8>>2]=no;o[a+4>>2]=Oo;if(Po){ul(Po)}return}Yk();D()}_a(10992);D()}function zj(a,no){a=a|0;no=no|0;var To=0,Uo=0,Vo=0,Wo=0,Xo=0,Yo=0,Zo=0;a:{if((no|0)<0){break a}To=o[a+12>>2];Uo=o[a+8>>2];if(To-Uo>>2>>>0<=no>>>0){break a}Uo=Uo+(no<<2)|0;Vo=o[Uo>>2];Yo=o[Vo+60>>2];Wo=o[Vo+56>>2];Vo=Uo+4|0;b:{if((Vo|0)!=(To|0)){while(1){Zo=o[Vo>>2];o[Vo>>2]=0;Xo=o[Uo>>2];o[Uo>>2]=Zo;if(Xo){Fb(Xo)}Uo=Uo+4|0;Vo=Vo+4|0;if((Vo|0)!=(To|0)){continue}break}To=o[a+12>>2];if((Uo|0)==(To|0)){break b}}while(1){To=To+ -4|0;Vo=o[To>>2];o[To>>2]=0;if(Vo){Fb(Vo)}if((To|0)!=(Uo|0)){continue}break}}o[a+12>>2]=Uo;To=o[a+4>>2];if(To){Aj(To,Yo)}c:{if((Wo|0)>4){break c}d:{Uo=u(Wo,12)+a|0;To=o[Uo+20>>2];Vo=Uo+24|0;Uo=o[Vo>>2];if((To|0)==(Uo|0)){break d}while(1){if(o[To>>2]==(no|0)){break d}To=To+4|0;if((Uo|0)!=(To|0)){continue}break}break c}if((To|0)==(Uo|0)){break c}Wo=To+4|0;Uo=Uo-Wo|0;Xo=Uo>>2;if(Uo){yl(To,Wo,Uo)}o[Vo>>2]=(Xo<<2)+To}To=o[a+24>>2];Uo=o[a+20>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+36>>2];Uo=o[a+32>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+48>>2];Uo=o[a+44>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+60>>2];Uo=o[a+56>>2];if((To|0)!=(Uo|0)){Vo=To-Uo>>2;To=0;while(1){Wo=Uo+(To<<2)|0;Xo=o[Wo>>2];if((Xo|0)>(no|0)){o[Wo>>2]=Xo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}To=o[a+72>>2];a=o[a+68>>2];if((To|0)==(a|0)){break a}Uo=To-a>>2;To=0;while(1){Vo=a+(To<<2)|0;Wo=o[Vo>>2];if((Wo|0)>(no|0)){o[Vo>>2]=Wo+ -1}To=To+1|0;if(To>>>0>>0){continue}break}}}function Aj(a,no){var _o=0,$o=0,ap=0,bp=0;a:{if((no|0)<0){break a}_o=o[a+28>>2];ap=o[a+24>>2];while(1){$o=ap;if((_o|0)==($o|0)){break a}ap=$o+4|0;if(o[o[$o>>2]+24>>2]!=(no|0)){continue}break}b:{if((_o|0)!=(ap|0)){while(1){no=o[ap>>2];o[ap>>2]=0;bp=o[$o>>2];o[$o>>2]=no;if(bp){Fc(bp+12|0,o[bp+16>>2]);Gc(bp,o[bp+4>>2]);ul(bp)}$o=$o+4|0;ap=ap+4|0;if((_o|0)!=(ap|0)){continue}break}_o=o[a+28>>2];if((_o|0)==($o|0)){break b}}while(1){_o=_o+ -4|0;no=o[_o>>2];o[_o>>2]=0;if(no){Fc(no+12|0,o[no+16>>2]);Gc(no,o[no+4>>2]);ul(no)}if(($o|0)!=(_o|0)){continue}break}}o[a+28>>2]=$o}}function Bj(a){a=a|0;ul(Mi(a))}function Cj(a){a=a|0}function Dj(a){var no=0;no=p[a+74|0];m[a+74|0]=no+ -1|no;no=o[a>>2];if(no&8){o[a>>2]=no|32;return-1}o[a+4>>2]=0;o[a+8>>2]=0;no=o[a+44>>2];o[a+28>>2]=no;o[a+20>>2]=no;o[a+16>>2]=no+o[a+48>>2];return 0}function Ej(a,cp,dp){var ep=0,fp=0,gp=0;ep=o[dp+16>>2];a:{if(!ep){if(Dj(dp)){break a}ep=o[dp+16>>2]}gp=o[dp+20>>2];if(ep-gp>>>0>>0){l[o[dp+36>>2]](dp,a,cp)|0;return}b:{if(m[dp+75|0]<0){break b}ep=cp;while(1){fp=ep;if(!fp){break b}ep=fp+ -1|0;if(p[ep+a|0]!=10){continue}break}if(l[o[dp+36>>2]](dp,a,fp)>>>0>>0){break a}cp=cp-fp|0;a=a+fp|0;gp=o[dp+20>>2]}wl(gp,a,cp);o[dp+20>>2]=o[dp+20>>2]+cp}}function Fj(a,cp,dp){var hp=0,ip=0,jp=0,kp=0;hp=R-208|0;R=hp;o[hp+204>>2]=dp;dp=0;xl(hp+160|0,0,40);o[hp+200>>2]=o[hp+204>>2];a:{if((Gj(0,cp,hp+200|0,hp+80|0,hp+160|0)|0)<0){cp=-1;break a}dp=o[a+76>>2]>=0?1:dp;ip=o[a>>2];if(m[a+74|0]<=0){o[a>>2]=ip&-33}kp=ip&32;b:{if(o[a+48>>2]){cp=Gj(a,cp,hp+200|0,hp+80|0,hp+160|0);break b}o[a+48>>2]=80;o[a+16>>2]=hp+80;o[a+28>>2]=hp;o[a+20>>2]=hp;ip=o[a+44>>2];o[a+44>>2]=hp;jp=Gj(a,cp,hp+200|0,hp+80|0,hp+160|0);cp=jp;if(!ip){break b}l[o[a+36>>2]](a,0,0)|0;o[a+48>>2]=0;o[a+44>>2]=ip;o[a+28>>2]=0;o[a+16>>2]=0;cp=o[a+20>>2];o[a+20>>2]=0;cp=cp?jp:-1}jp=a;a=o[a>>2];o[jp>>2]=a|kp;cp=a&32?-1:cp;if(!dp){break a}}R=hp+208|0;return cp}function Gj(a,cp,dp,lp,mp){var np=0,op=0,pp=0,qp=0,rp=0,sp=0,tp=0,up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0;np=R-80|0;R=np;o[np+76>>2]=cp;Bp=np+55|0;yp=np+56|0;cp=0;a:{b:while(1){c:{if((vp|0)<0){break c}if((cp|0)>(2147483647-vp|0)){o[3269]=61;vp=-1;break c}vp=cp+vp|0}d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:{q:{rp=o[np+76>>2];cp=rp;qp=p[cp|0];if(qp){while(1){r:{s:{op=qp&255;t:{if(!op){qp=cp;break t}if((op|0)!=37){break s}qp=cp;while(1){if(p[cp+1|0]!=37){break t}op=cp+2|0;o[np+76>>2]=op;qp=qp+1|0;pp=p[cp+2|0];cp=op;if((pp|0)==37){continue}break}}cp=qp-rp|0;if(a){Hj(a,rp,cp)}if(cp){continue b}wp=-1;qp=1;op=np;sp=!Uj(m[o[np+76>>2]+1|0]);cp=o[np+76>>2];if(!(sp|p[cp+2|0]!=36)){wp=m[cp+1|0]+ -48|0;zp=1;qp=3}cp=qp+cp|0;o[op+76>>2]=cp;qp=0;xp=m[cp|0];pp=xp+ -32|0;u:{if(pp>>>0>31){op=cp;break u}op=cp;pp=1<>2]=op;qp=pp|qp;xp=m[cp+1|0];pp=xp+ -32|0;if(pp>>>0>31){break u}cp=op;pp=1<>2];if(p[cp+2|0]!=36){break x}o[((m[cp+1|0]<<2)+mp|0)+ -192>>2]=10;tp=o[((m[cp+1|0]<<3)+lp|0)+ -384>>2];zp=1;cp=cp+3|0;break w}if(zp){break q}zp=0;tp=0;if(a){cp=o[dp>>2];o[dp>>2]=cp+4;tp=o[cp>>2]}cp=o[np+76>>2]+1|0}o[sp+76>>2]=cp;if((tp|0)>-1){break v}tp=0-tp|0;qp=qp|8192;break v}tp=Ij(np+76|0);if((tp|0)<0){break q}cp=o[np+76>>2]}pp=-1;y:{if(p[cp|0]!=46){break y}if(p[cp+1|0]==42){z:{if(!Uj(m[cp+2|0])){break z}cp=o[np+76>>2];if(p[cp+3|0]!=36){break z}o[((m[cp+2|0]<<2)+mp|0)+ -192>>2]=10;pp=o[((m[cp+2|0]<<3)+lp|0)+ -384>>2];cp=cp+4|0;o[np+76>>2]=cp;break y}if(zp){break q}if(a){cp=o[dp>>2];o[dp>>2]=cp+4;pp=o[cp>>2]}else{pp=0}cp=o[np+76>>2]+2|0;o[np+76>>2]=cp;break y}o[np+76>>2]=cp+1;pp=Ij(np+76|0);cp=o[np+76>>2]}op=0;while(1){Ap=op;up=-1;if(m[cp|0]+ -65>>>0>57){break a}xp=cp+1|0;o[np+76>>2]=xp;op=m[cp|0];cp=xp;op=p[(op+u(Ap,58)|0)+11023|0];if(op+ -1>>>0<8){continue}break}if(!op){break a}A:{B:{C:{if((op|0)==19){if((wp|0)<=-1){break C}break a}if((wp|0)<0){break B}o[(wp<<2)+mp>>2]=op;cp=(wp<<3)+lp|0;op=o[cp+4>>2];o[np+64>>2]=o[cp>>2];o[np+68>>2]=op}cp=0;if(!a){continue b}break A}if(!a){break d}Jj(np- -64|0,op,dp);xp=o[np+76>>2]}sp=qp&-65537;qp=qp&8192?sp:qp;up=0;wp=11060;op=yp;cp=m[xp+ -1|0];cp=Ap?(cp&15)==3?cp&-33:cp:cp;xp=cp+ -88|0;if(xp>>>0<=32){break r}D:{E:{F:{G:{sp=cp+ -65|0;if(sp>>>0>6){if((cp|0)!=83){break e}if(!pp){break G}op=o[np+64>>2];break E}switch(sp-1|0){case 1:break F;case 0:case 2:break e;default:break p}}cp=0;Kj(a,32,tp,0,qp);break D}o[np+12>>2]=0;o[np+8>>2]=o[np+64>>2];o[np+64>>2]=np+8;pp=-1;op=np+8|0}cp=0;H:{while(1){rp=o[op>>2];if(!rp){break H}rp=Vj(np+4|0,rp);sp=(rp|0)<0;if(!(sp|rp>>>0>pp-cp>>>0)){op=op+4|0;cp=cp+rp|0;if(pp>>>0>cp>>>0){continue}break H}break}up=-1;if(sp){break a}}Kj(a,32,tp,cp,qp);if(!cp){cp=0;break D}pp=0;op=o[np+64>>2];while(1){rp=o[op>>2];if(!rp){break D}rp=Vj(np+4|0,rp);pp=rp+pp|0;if((pp|0)>(cp|0)){break D}Hj(a,np+4|0,rp);op=op+4|0;if(pp>>>0>>0){continue}break}}Kj(a,32,tp,cp,qp^8192);cp=(tp|0)>(cp|0)?tp:cp;continue b}op=cp+1|0;o[np+76>>2]=op;qp=p[cp+1|0];cp=op;continue}break}switch(xp-1|0){case 21:break i;case 23:break k;case 22:break l;case 11:case 16:break m;case 10:break n;case 26:break o;case 8:case 12:case 13:case 14:break p;case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 9:case 15:case 17:case 18:case 19:case 20:case 24:case 25:case 27:case 29:case 30:break e;case 28:break h;default:break j}}up=vp;if(a){break a}if(!zp){break d}cp=1;while(1){a=o[(cp<<2)+mp>>2];if(a){Jj((cp<<3)+lp|0,a,dp);up=1;cp=cp+1|0;if((cp|0)!=10){continue}break a}break}up=1;if(cp>>>0>=10){break a}while(1){if(o[(cp<<2)+mp>>2]){break q}a=cp>>>0>8;cp=cp+1|0;if(!a){continue}break}break a}up=-1;break a}cp=l[269](a,t[np+64>>3],tp,pp,qp,cp)|0;continue}cp=o[np+64>>2];rp=cp?cp:11070;cp=$j(rp,pp);op=cp?cp:pp+rp|0;qp=sp;pp=cp?cp-rp|0:pp;break e}m[np+55|0]=o[np+64>>2];pp=1;rp=Bp;qp=sp;break e}sp=o[np+68>>2];cp=sp;rp=o[np+64>>2];if((cp|0)<-1?1:(cp|0)<=-1?rp>>>0>4294967295?0:1:0){cp=0-(cp+(0>>0)|0)|0;rp=0-rp|0;o[np+64>>2]=rp;o[np+68>>2]=cp;up=1;wp=11060;break g}if(qp&2048){up=1;wp=11061;break g}up=qp&1;wp=up?11062:11060;break g}rp=Lj(o[np+64>>2],o[np+68>>2],yp);if(!(qp&8)){break f}cp=yp-rp|0;pp=(pp|0)>(cp|0)?pp:cp+1|0;break f}pp=pp>>>0>8?pp:8;qp=qp|8;cp=120}rp=Mj(o[np+64>>2],o[np+68>>2],yp,cp&32);if(!(qp&8)|!(o[np+64>>2]|o[np+68>>2])){break f}wp=(cp>>>4)+11060|0;up=2;break f}cp=0;op=Ap&255;if(op>>>0>7){continue}I:{switch(op-1|0){default:o[o[np+64>>2]>>2]=vp;continue;case 0:o[o[np+64>>2]>>2]=vp;continue;case 1:op=o[np+64>>2];o[op>>2]=vp;o[op+4>>2]=vp>>31;continue;case 2:n[o[np+64>>2]>>1]=vp;continue;case 3:m[o[np+64>>2]]=vp;continue;case 5:o[o[np+64>>2]>>2]=vp;continue;case 4:continue;case 6:break I}}op=o[np+64>>2];o[op>>2]=vp;o[op+4>>2]=vp>>31;continue}rp=o[np+64>>2];cp=o[np+68>>2];wp=11060}rp=Nj(rp,cp,yp)}qp=(pp|0)>-1?qp&-65537:qp;cp=o[np+64>>2];sp=o[np+68>>2];J:{if(!(!!(cp|sp)|pp)){rp=yp;pp=0;break J}cp=!(cp|sp)+(yp-rp|0)|0;pp=(pp|0)>(cp|0)?pp:cp}}sp=op-rp|0;pp=(pp|0)<(sp|0)?sp:pp;op=pp+up|0;cp=(tp|0)<(op|0)?op:tp;Kj(a,32,cp,op,qp);Hj(a,wp,up);Kj(a,48,cp,op,qp^65536);Kj(a,48,pp,sp,0);Hj(a,rp,sp);Kj(a,32,cp,op,qp^8192);continue}break}up=0}R=np+80|0;return up}function Hj(a,o,cp){if(!(p[a|0]&32)){Ej(o,cp,a)}}function Ij(a){var cp=0,dp=0,lp=0;if(Uj(m[o[a>>2]])){while(1){cp=o[a>>2];lp=m[cp|0];o[a>>2]=cp+1;dp=(u(dp,10)+lp|0)+ -48|0;if(Uj(m[cp+1|0])){continue}break}}return dp}function Jj(a,mp,Cp){a:{b:{if(mp>>>0>20){break b}mp=mp+ -9|0;if(mp>>>0>9){break b}c:{switch(mp-1|0){default:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=o[mp>>2];return;case 0:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=o[mp>>2];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 1:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=o[mp>>2];o[a+4>>2]=0;return;case 3:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=n[mp>>1];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 4:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=q[mp>>1];o[a+4>>2]=0;return;case 5:mp=o[Cp>>2];o[Cp>>2]=mp+4;mp=m[mp|0];o[a>>2]=mp;o[a+4>>2]=mp>>31;return;case 6:mp=o[Cp>>2];o[Cp>>2]=mp+4;o[a>>2]=p[mp|0];o[a+4>>2]=0;return;case 2:case 7:break a;case 8:break c}}l[270](a,Cp)}return}mp=o[Cp>>2]+7&-8;o[Cp>>2]=mp+8;Cp=o[mp+4>>2];o[a>>2]=o[mp>>2];o[a+4>>2]=Cp}function Kj(a,o,mp,Cp,Dp){var Ep=0,Fp=0,Gp=0;Ep=R-256|0;R=Ep;if(!(Dp&73728|(mp|0)<=(Cp|0))){Dp=mp-Cp|0;Fp=Dp>>>0<256;xl(Ep,o,Fp?Dp:256);o=a;Gp=Ep;if(!Fp){mp=mp-Cp|0;while(1){Hj(a,Ep,256);Dp=Dp+ -256|0;if(Dp>>>0>255){continue}break}Dp=mp&255}Hj(o,Gp,Dp)}R=Ep+256|0}function Lj(a,o,mp){if(a|o){while(1){mp=mp+ -1|0;m[mp|0]=a&7|48;a=(o&7)<<29|a>>>3;o=o>>>3;if(a|o){continue}break}}return mp}function Mj(a,o,mp,Cp){if(a|o){while(1){mp=mp+ -1|0;m[mp|0]=p[(a&15)+11552|0]|Cp;a=(o&15)<<28|a>>>4;o=o>>>4;if(a|o){continue}break}}return mp}function Nj(a,o,mp){var Cp=0,Dp=0,Hp=0;a:{if((o|0)==1&a>>>0<0|o>>>0<1){Cp=a;break a}while(1){Cp=Xl(a,o,10,0);Dp=T;Hp=Dp;Dp=Vl(Cp,Dp,10,0);mp=mp+ -1|0;m[mp|0]=a-Dp|48;Dp=(o|0)==9&a>>>0>4294967295|o>>>0>9;a=Cp;o=Hp;if(Dp){continue}break}}if(Cp){while(1){mp=mp+ -1|0;a=(Cp>>>0)/10|0;m[mp|0]=Cp-u(a,10)|48;o=Cp>>>0>9;Cp=a;if(o){continue}break}}return mp}function Oj(a,o,mp){return Fj(a,o,mp)}function Pj(a,mp,Ip,Jp,Kp,Lp){a=a|0;mp=+mp;Ip=Ip|0;Jp=Jp|0;Kp=Kp|0;Lp=Lp|0;var Mp=0,Np=0,Op=0,Pp=0,Qp=0,Rp=0,Sp=0,Tp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0,eq=0,fq=0,gq=0,hq=0,iq=0;Qp=R-560|0;R=Qp;o[Qp+44>>2]=0;h(+mp);Mp=e(1)|0;a:{if(dq=1,eq=(gq=e(0)>>>0>4294967295?0:1,hq=0,iq=(Mp|0)<=-1,iq?gq:hq),fq=(Mp|0)<-1,fq?dq:eq){mp=-mp;h(+mp);Mp=e(1)|0;e(0)|0;_p=1;$p=11568;break a}if(Kp&2048){_p=1;$p=11571;break a}_p=Kp&1;$p=_p?11574:11569}b:{if((Mp&2146435072)==2146435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mp-Jp>>2>(Zp|0)?Jp+(Zp<<2)|0:Mp;if((Np|0)<0){continue}break}}Pp=0;h:{if(Op>>>0>=Mp>>>0){break h}Pp=u(Up-Op>>2,9);Np=10;Jp=o[Op>>2];if(Jp>>>0<10){break h}while(1){Pp=Pp+1|0;Np=u(Np,10);if(Jp>>>0>=Np>>>0){continue}break}}Jp=(Rp-((aq|0)==102?0:Pp)|0)-((aq|0)==103&(Rp|0)!=0)|0;if((Jp|0)<(u(Mp-Up>>2,9)+ -9|0)){Np=Jp+9216|0;Sp=(Np|0)/9|0;Tp=(Up+(Sp<<2)|0)+ -4092|0;Jp=10;Np=Np-u(Sp,9)|0;if((Np|0)<=7){while(1){Jp=u(Jp,10);Sp=(Np|0)<7;Np=Np+1|0;if(Sp){continue}break}}Sp=o[Tp>>2];Vp=(Sp>>>0)/(Jp>>>0)|0;Zp=Tp+4|0;Np=Sp-u(Jp,Vp)|0;i:{if(Np?0:(Zp|0)==(Mp|0)){break i}Wp=Jp>>>1;Yp=Np>>>0>>0?.5:(Mp|0)==(Zp|0)?(Wp|0)==(Np|0)?1:1.5:1.5;mp=Vp&1?9007199254740994:9007199254740992;if(!(!_p|p[$p|0]!=45)){Yp=-Yp;mp=-mp}Np=Sp-Np|0;o[Tp>>2]=Np;if(mp+Yp==mp){break i}Jp=Jp+Np|0;o[Tp>>2]=Jp;if(Jp>>>0>=1e9){while(1){o[Tp>>2]=0;Tp=Tp+ -4|0;if(Tp>>>0>>0){Op=Op+ -4|0;o[Op>>2]=0}Jp=o[Tp>>2]+1|0;o[Tp>>2]=Jp;if(Jp>>>0>999999999){continue}break}}Pp=u(Up-Op>>2,9);Np=10;Jp=o[Op>>2];if(Jp>>>0<10){break i}while(1){Pp=Pp+1|0;Np=u(Np,10);if(Jp>>>0>=Np>>>0){continue}break}}Jp=Tp+4|0;Mp=Mp>>>0>Jp>>>0?Jp:Mp}j:{while(1){Np=Mp;Tp=0;if(Mp>>>0<=Op>>>0){break j}Mp=Np+ -4|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((Lp|0)!=(Mp|0)){break q}m[Qp+24|0]=48;Mp=Jp}Hj(a,Mp,Lp-Mp|0);Op=Op+4|0;if(Op>>>0<=Up>>>0){continue}break}if(aq){Hj(a,11603,1)}if((Rp|0)<1|Op>>>0>=Np>>>0){break p}while(1){Mp=Nj(o[Op>>2],0,Lp);if(Mp>>>0>Qp+16>>>0){while(1){Mp=Mp+ -1|0;m[Mp|0]=48;if(Mp>>>0>Qp+16>>>0){continue}break}}Hj(a,Mp,(Rp|0)<9?Rp:9);Mp=Rp+ -9|0;Op=Op+4|0;if(Op>>>0>=Np>>>0){break o}Jp=(Rp|0)>9;Rp=Mp;if(Jp){continue}break}break o}r:{if((Rp|0)<0){break r}Up=Tp?Np:Op+4|0;Jp=Qp+16|8;Lp=Qp+16|9;Pp=Op;while(1){Mp=Nj(o[Pp>>2],0,Lp);if((Lp|0)==(Mp|0)){m[Qp+24|0]=48;Mp=Jp}s:{if((Op|0)!=(Pp|0)){if(Mp>>>0<=Qp+16>>>0){break s}while(1){Mp=Mp+ -1|0;m[Mp|0]=48;if(Mp>>>0>Qp+16>>>0){continue}break}break s}Hj(a,Mp,1);Mp=Mp+1|0;if((Rp|0)<1?!Vp:0){break s}Hj(a,11603,1)}Np=Mp;Mp=Lp-Mp|0;Hj(a,Np,(Rp|0)>(Mp|0)?Mp:Rp);Rp=Rp-Mp|0;Pp=Pp+4|0;if(Pp>>>0>=Up>>>0){break r}if((Rp|0)>-1){continue}break}}Kj(a,48,Rp+18|0,18,0);Hj(a,Zp,Xp-Zp|0);break n}Mp=Rp}Kj(a,48,Mp+9|0,9,0)}}Kj(a,32,Ip,Sp,Kp^8192);R=Qp+560|0;return((Sp|0)<(Ip|0)?Ip:Sp)|0}function Qj(a,mp){a=a|0;mp=mp|0;var Ip=0,Jp=0,Kp=0;Ip=mp;mp=o[mp>>2]+15&-16;o[Ip>>2]=mp+16;Jp=a,Kp=dk(o[mp>>2],o[mp+4>>2],o[mp+8>>2],o[mp+12>>2]),t[Jp>>3]=Kp}function Rj(a,mp,Lp){a=a|0;mp=mp|0;Lp=Lp|0;var jq=0,kq=0,lq=0,mq=0,nq=0,oq=0;jq=R-32|0;R=jq;kq=o[a+28>>2];o[jq+16>>2]=kq;lq=o[a+20>>2];o[jq+28>>2]=Lp;o[jq+24>>2]=mp;mp=lq-kq|0;o[jq+20>>2]=mp;lq=mp+Lp|0;nq=2;mp=jq+16|0;while(1){a:{b:{if(ak(I(o[a+60>>2],mp|0,nq|0,jq+12|0)|0)){o[jq+12>>2]=-1;kq=-1;break b}kq=o[jq+12>>2]}c:{if((kq|0)==(lq|0)){mp=o[a+44>>2];o[a+28>>2]=mp;o[a+20>>2]=mp;o[a+16>>2]=mp+o[a+48>>2];a=Lp;break c}if((kq|0)>-1){break a}o[a+28>>2]=0;o[a+16>>2]=0;o[a+20>>2]=0;o[a>>2]=o[a>>2]|32;a=0;if((nq|0)==2){break c}a=Lp-o[mp+4>>2]|0}R=jq+32|0;return a|0}mq=o[mp+4>>2];oq=kq>>>0>mq>>>0;mp=oq?mp+8|0:mp;mq=kq-(oq?mq:0)|0;o[mp>>2]=mq+o[mp>>2];o[mp+4>>2]=o[mp+4>>2]-mq;lq=lq-kq|0;nq=nq-oq|0;continue}}function Sj(a,mp,Lp,pq){a=a|0;mp=mp|0;Lp=Lp|0;pq=pq|0;var qq=0;qq=R-16|0;R=qq;a:{if(!ak(Q(o[a+60>>2],mp|0,Lp|0,pq&255,qq+8|0)|0)){mp=o[qq+12>>2];a=o[qq+8>>2];break a}o[qq+8>>2]=-1;o[qq+12>>2]=-1;mp=-1;a=-1}R=qq+16|0;T=mp;return a|0}function Tj(a){a=a|0;return J(o[a+60>>2])|0}function Uj(a){return a+ -48>>>0<10}function Vj(a,o){if(!a){return 0}return Wj(a,o)}function Wj(a,mp){a:{if(a){if(mp>>>0<=127){break a}b:{if(!o[o[3253]>>2]){if((mp&-128)==57216){break a}break b}if(mp>>>0<=2047){m[a+1|0]=mp&63|128;m[a|0]=mp>>>6|192;return 2}if(!((mp&-8192)!=57344?mp>>>0>=55296:0)){m[a+2|0]=mp&63|128;m[a|0]=mp>>>12|224;m[a+1|0]=mp>>>6&63|128;return 3}if(mp+ -65536>>>0<=1048575){m[a+3|0]=mp&63|128;m[a|0]=mp>>>18|240;m[a+2|0]=mp>>>6&63|128;m[a+1|0]=mp>>>12&63|128;return 4}}o[3269]=25;a=-1}else{a=1}return a}m[a|0]=mp;return 1}function Xj(a,mp){var Lp=0,pq=0,rq=0;h(+a);Lp=e(1)|0;pq=e(0)|0;rq=Lp;Lp=Lp>>>20&2047;if((Lp|0)!=2047){if(!Lp){Lp=mp;if(a==0){mp=0}else{a=Xj(a*0x10000000000000000,mp);mp=o[mp>>2]+ -64|0}o[Lp>>2]=mp;return a}o[mp>>2]=Lp+ -1022;f(0,pq|0);f(1,rq&-2146435073|1071644672);a=+g()}return a}function Yj(a){var o=0,mp=0,sq=0,tq=0,uq=0,vq=0;while(1){o=a;a=o+1|0;mp=m[o|0];if((mp|0)==32|mp+ -9>>>0<5){continue}break}mp=m[o|0];tq=mp+ -43|0;a:{if(tq>>>0>2){break a}b:{switch(tq-1|0){case 1:uq=1;break;case 0:break a;default:break b}}mp=m[a|0];o=a;vq=uq}if(Uj(mp)){while(1){sq=(u(sq,10)-m[o|0]|0)+48|0;a=m[o+1|0];o=o+1|0;if(Uj(a)){continue}break}}return vq?sq:0-sq|0}function Zj(a,wq,xq){var yq=0,zq=0,Aq=0;a:{if(!xq){break a}while(1){yq=p[a|0];zq=p[wq|0];if((yq|0)==(zq|0)){wq=wq+1|0;a=a+1|0;xq=xq+ -1|0;if(xq){continue}break a}break}Aq=yq-zq|0}return Aq}function _j(a){var wq=0,xq=0,Bq=0;a:{b:{wq=a;if(!(wq&3)){break b}if(!p[a|0]){break a}while(1){wq=wq+1|0;if(!(wq&3)){break b}if(p[wq|0]){continue}break}break a}while(1){xq=wq;wq=wq+4|0;Bq=o[xq>>2];if(!((Bq^-1)&Bq+ -16843009&-2139062144)){continue}break}if(!(Bq&255)){wq=xq;break a}while(1){Bq=p[xq+1|0];wq=xq+1|0;xq=wq;if(Bq){continue}break}}return wq-a|0}function $j(a,Cq){var Dq=0,Eq=0,Fq=0;Dq=(Cq|0)!=0;a:{b:{c:{d:{if(!Cq|!(a&3)){break d}while(1){if(!p[a|0]){break c}a=a+1|0;Cq=Cq+ -1|0;Dq=(Cq|0)!=0;if(!Cq){break d}if(a&3){continue}break}}if(!Dq){break b}}if(!p[a|0]){break a}e:{if(Cq>>>0>=4){Dq=Cq+ -4|0;Eq=Dq&-4;Dq=Dq-Eq|0;Eq=(a+Eq|0)+4|0;while(1){Fq=o[a>>2];if((Fq^-1)&Fq+ -16843009&-2139062144){break e}a=a+4|0;Cq=Cq+ -4|0;if(Cq>>>0>3){continue}break}Cq=Dq;a=Eq}if(!Cq){break b}}while(1){if(!p[a|0]){break a}a=a+1|0;Cq=Cq+ -1|0;if(Cq){continue}break}}return 0}return a}function ak(a){if(!a){return 0}o[3269]=a;return-1}function bk(a,Cq,Gq,Hq,Iq,Jq){var Kq=0,Lq=0,Mq=0,Nq=0;a:{if(Jq&64){Hq=Cq;Iq=Jq+ -64|0;Cq=Iq&31;if(32<=(Iq&63)>>>0){Iq=Hq<>>32-Cq|Gq<>>0){Lq=Kq<>>32-Hq|Iq<>>0){Jq=0;Hq=Hq>>>Iq}else{Jq=Hq>>>Iq;Hq=((1<>>Iq}Hq=Nq|Hq;Iq=Jq|Lq;Jq=Cq;Cq=Mq&31;if(32<=(Mq&63)>>>0){Lq=Jq<>>32-Cq|Gq<>2]=Cq;o[a+4>>2]=Gq;o[a+8>>2]=Hq;o[a+12>>2]=Iq}function ck(a,Cq,Gq,Hq,Iq,Jq){var Oq=0,Pq=0,Qq=0,Rq=0;a:{b:{if(Jq&64){Gq=Jq+ -64|0;Cq=Gq&31;if(32<=(Gq&63)>>>0){Gq=0;Cq=Iq>>>Cq}else{Gq=Iq>>>Cq;Cq=((1<>>Cq}Hq=0;Iq=0;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;if(Tq>>>0<15249){break a}Iq=Hq&65535|65536;ck(Sq,a,Cq,Gq,Iq,15361-Tq|0);bk(Sq+16|0,a,Cq,Gq,Iq,Tq+ -15233|0);Gq=o[Sq+4>>2];a=o[Sq+8>>2];Iq=o[Sq+12>>2]<<4|a>>>28;Jq=a<<4|Gq>>>28;a=Gq&268435455;Gq=a;Cq=o[Sq>>2]|((o[Sq+16>>2]|o[Sq+24>>2])!=0|(o[Sq+20>>2]|o[Sq+28>>2])!=0);if((a|0)==134217728&Cq>>>0>=1|a>>>0>134217728){a=Jq+1|0;if(a>>>0<1){Iq=Iq+1|0}Jq=a;break a}if(Cq|Gq^134217728){break a}a=Jq+(Jq&1)|0;if(a>>>0>>0){Iq=Iq+1|0}Jq=a}R=Sq+32|0;f(0,Jq|0);f(1,Hq&-2147483648|Iq);return+g()}function ek(a){var Cq=0,Gq=0,Hq=0,Xq=0,Yq=0,Zq=0,_q=0,$q=0;Xq=R-16|0;R=Xq;o[Xq+12>>2]=a;a:{if(a>>>0<=211){a=o[fk(11616,11808,Xq+12|0)>>2];break a}Yq=(a>>>0)/210|0;Hq=u(Yq,210);o[Xq+8>>2]=a-Hq;Zq=fk(11808,12e3,Xq+8|0)-11808>>2;b:{while(1){a=o[(Zq<<2)+11808>>2]+Hq|0;Hq=5;c:{d:{e:{while(1){if((Hq|0)==47){break e}Cq=o[(Hq<<2)+11616>>2];Gq=(a>>>0)/(Cq>>>0)|0;_q=Gq>>>0>>0;$q=_q?a:$q;Hq=Hq+1|0;Cq=_q?1:(u(Cq,Gq)|0)==(a|0)?7:0;if(!Cq){continue}break}Hq=Cq+ -4|0;if(Hq>>>0>3){break b}switch(Hq-1|0){case 0:case 1:break b;case 2:break d;default:break e}}Hq=211;while(1){Cq=(a>>>0)/(Hq>>>0)|0;if(Cq>>>0>>0){break c}if((u(Cq,Hq)|0)==(a|0)){break d}Cq=Hq+10|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+12|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+16|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+18|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+22|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+28|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+30|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+36|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+40|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+42|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+46|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+52|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+58|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+60|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+66|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+70|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+72|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+78|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+82|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+88|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+96|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+100|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+102|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+106|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+108|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+112|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+120|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+126|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+130|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+136|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+138|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+142|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+148|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+150|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+156|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+162|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+166|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+168|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+172|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+178|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+180|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+186|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+190|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+192|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+196|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+198|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}if((u(Cq,Gq)|0)==(a|0)){break d}Cq=Hq+208|0;Gq=(a>>>0)/(Cq>>>0)|0;if(Gq>>>0>>0){break c}Hq=Hq+210|0;if((u(Cq,Gq)|0)!=(a|0)){continue}break}}Hq=Zq+1|0;a=(Hq|0)==48;Zq=a?0:Hq;Yq=a+Yq|0;Hq=u(Yq,210);continue}break}o[Xq+12>>2]=a;break a}o[Xq+12>>2]=a;a=$q}R=Xq+16|0;return a}function fk(a,ar,br){return gk(a,ar,br)}function gk(a,ar,br){var cr=0;cr=R-16|0;R=cr;a=hk(a,ar,br);R=cr+16|0;return a}function hk(a,ar,br){var dr=0,er=0,fr=0,gr=0;dr=R-16|0;R=dr;ar=ar-a>>2;while(1){if(ar){o[dr+12>>2]=a;er=dr+12|0;fr=er;gr=o[er>>2];er=ar>>>1;o[fr>>2]=gr+(er<<2);if(ik(o[dr+12>>2],br)){a=o[dr+12>>2]+4|0;o[dr+12>>2]=a;ar=(er^-1)+ar|0}else{ar=er}continue}break}R=dr+16|0;return a}function ik(a,ar){return r[a>>2]>2]}function jk(a,ar,br){if(br){wl(a,ar,br)}}function kk(a,ar){return lk(a,ar)}function lk(a,ar){var br=0,hr=0;br=R-16|0;R=br;hr=ik(a,ar);R=br+16|0;return hr?ar:a}function mk(a){o[a>>2]=0;o[a+4>>2]=0;o[a+8>>2]=0}function nk(a,ar){var ir=0,jr=0;ir=p[a|0];jr=p[ar|0];a:{if(!ir|(ir|0)!=(jr|0)){break a}while(1){jr=p[ar+1|0];ir=p[a+1|0];if(!ir){break a}ar=ar+1|0;a=a+1|0;if((ir|0)==(jr|0)){continue}break}}return ir-jr|0}function ok(){var a=0,ar=0,kr=0;a=R-16|0;R=a;a:{if(K(a+12|0,a+8|0)){break a}ar=tl((o[a+12>>2]<<2)+4|0);o[3286]=ar;if(!ar){break a}b:{ar=tl(o[a+8>>2]);if(ar){kr=o[3286];if(kr){break b}}o[3286]=0;break a}o[(o[a+12>>2]<<2)+kr>>2]=0;if(!L(o[3286],ar|0)){break a}o[3286]=0}R=a+16|0}function pk(lr,mr,nr){var or=0,pr=0;or=R-160|0;R=or;wl(or+8|0,12e3,144);a:{b:{if(mr+ -1>>>0>=2147483647){if(mr){break b}mr=1;lr=or+159|0}o[or+52>>2]=lr;o[or+28>>2]=lr;pr=-2-lr|0;mr=mr>>>0>pr>>>0?pr:mr;o[or+56>>2]=mr;lr=lr+mr|0;o[or+36>>2]=lr;o[or+24>>2]=lr;lr=Oj(or+8|0,12225,nr);if(!mr){break a}mr=o[or+28>>2];m[mr-((mr|0)==o[or+24>>2])|0]=0;break a}o[3269]=61;lr=-1}R=or+160|0;return lr}function qk(lr,mr,nr){lr=lr|0;mr=mr|0;nr=nr|0;var qr=0,rr=0;rr=o[lr+20>>2];qr=o[lr+16>>2]-rr|0;qr=qr>>>0>nr>>>0?nr:qr;wl(rr,mr,qr);o[lr+20>>2]=qr+o[lr+20>>2];return nr|0}function rk(lr,mr,nr){var sr=0;sr=R-16|0;R=sr;o[sr+12>>2]=nr;lr=pk(lr,mr,nr);R=sr+16|0;return lr}function sk(lr){if(wk(lr)){return o[lr+4>>2]}return p[lr+11|0]}function tk(lr){if(wk(lr)){lr=xk(lr)+ -1|0}else{lr=10}return lr}function uk(lr,mr){Rk(lr,mr)}function vk(lr){var mr=0;mr=lr;lr=0;while(1){if((lr|0)!=3){o[(lr<<2)+mr>>2]=0;lr=lr+1|0;continue}break}}function wk(lr){return m[lr+11|0]<0}function xk(lr){return o[lr+8>>2]&2147483647}function yk(lr){if(wk(lr)){return o[lr>>2]}return lr}function zk(lr,nr){m[lr|0]=p[nr|0]}function Ak(lr,nr){o[lr+4>>2]=nr}function Bk(lr,nr){m[lr+11|0]=nr}function Ck(lr){var nr=0;if(lr>>>0>=11){nr=lr+16&-16;lr=nr+ -1|0;lr=(lr|0)==11?nr:lr}else{lr=10}return lr}function Dk(lr){if(4294967295>>0){_a(12144);D()}return Hk(lr)}function Ek(lr,tr){o[lr>>2]=tr}function Fk(lr,tr){o[lr+8>>2]=tr|-2147483648}function Gk(lr,tr){if(wk(lr)){Ak(lr,tr);return}Bk(lr,tr)}function Hk(lr){var tr=0,ur=0;lr=lr?lr:1;while(1){a:{tr=tl(lr);if(tr){break a}ur=o[3287];if(!ur){break a}l[ur]();continue}break}return tr}function Ik(lr,vr){var wr=0,xr=0,yr=0,zr=0;wr=_j(vr);xr=Hk(wr+13|0);o[xr+8>>2]=0;o[xr+4>>2]=wr;o[xr>>2]=wr;yr=lr,zr=wl(xr+12|0,vr,wr+1|0),o[yr>>2]=zr}function Jk(lr){var vr=0,Ar=0,Br=0;vr=R-16|0;R=vr;m[vr+15|0]=10;Ar=o[lr+16>>2];a:{if(!Ar){if(Dj(lr)){break a}Ar=o[lr+16>>2]}Br=o[lr+20>>2];if(!(m[lr+75|0]==10|Br>>>0>=Ar>>>0)){o[lr+20>>2]=Br+1;m[Br|0]=10;break a}if((l[o[lr+36>>2]](lr,vr+15|0,1)|0)!=1){break a}}R=vr+16|0}function Kk(){_a(12212);D()}function Lk(){M();D()}function Mk(lr,Cr){var Dr=0,Er=0,Fr=0;Er=R-16|0;R=Er;mk(lr);Dr=lr;a:{if(!wk(Cr)){o[Dr+8>>2]=o[Cr+8>>2];Fr=o[Cr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ds=0;cs=R-16|0;R=cs;Zr=sk(Yr);while(1){a:{bs=yk(Yr);o[cs>>2]=1;ds=Yr;bs=rk(bs,Zr+1|0,cs);b:{if((bs|0)>=0){if(bs>>>0<=Zr>>>0){break a}Zr=bs;break b}Zr=Zr<<1|1}uk(ds,Zr);continue}break}uk(Yr,bs);Zr=o[Yr+4>>2];o[lr>>2]=o[Yr>>2];o[lr+4>>2]=Zr;o[lr+8>>2]=o[Yr+8>>2];vk(Yr);R=cs+16|0}function Yk(){_a(12228);D()}function Zk(){Lk();D()}function _k(lr){var Yr=0;if(o[lr+76>>2]<0){a:{if(m[lr+75|0]==10){break a}Yr=o[lr+20>>2];if(Yr>>>0>=r[lr+16>>2]){break a}o[lr+20>>2]=Yr+1;m[Yr|0]=10;return}Jk(lr);return}b:{c:{if(m[lr+75|0]==10){break c}Yr=o[lr+20>>2];if(Yr>>>0>=r[lr+16>>2]){break c}o[lr+20>>2]=Yr+1;m[Yr|0]=10;break b}Jk(lr)}}function $k(){var lr=0;lr=R-16|0;R=lr;o[lr+12>>2]=0;lr=o[2902];Oj(lr,12235,0);_k(lr);M();D()}function al(){$k();D()}function bl(es){es=es|0;return 12265}function cl(es){es=es|0;o[es>>2]=12332;dl(es+4|0);return es|0}function dl(es){var fs=0,gs=0;fs=o[es>>2]+ -12|0;gs=fs+8|0;es=o[gs>>2]+ -1|0;o[gs>>2]=es;a:{if((es|0)>-1){break a}ul(fs)}}function el(es){es=es|0;ul(cl(es))}function fl(es){es=es|0;return o[es+4>>2]}function gl(es){es=es|0;cl(es);ul(es)}function hl(es,hs,is){if(!is){return(es|0)==(hs|0)}return!nk(o[es+4>>2],o[hs+4>>2])}function il(es,hs,is){es=es|0;hs=hs|0;is=is|0;var js=0,ks=0;js=R+ -64|0;R=js;ks=1;a:{if(hl(es,hs,0)){break a}ks=0;if(!hs){break a}hs=jl(hs);ks=0;if(!hs){break a}o[js+20>>2]=-1;o[js+16>>2]=es;o[js+12>>2]=0;o[js+8>>2]=hs;xl(js+24|0,0,39);o[js+56>>2]=1;l[o[o[hs>>2]+28>>2]](hs,js+8|0,o[is>>2],1);ks=0;if(o[js+32>>2]!=1){break a}o[is>>2]=o[js+24>>2];ks=1}R=js- -64|0;return ks|0}function jl(es){var hs=0,is=0,ls=0,ms=0;hs=R+ -64|0;R=hs;is=o[es>>2];ms=o[is+ -8>>2];is=o[is+ -4>>2];o[hs+20>>2]=0;o[hs+16>>2]=12484;o[hs+12>>2]=es;o[hs+8>>2]=12532;xl(hs+24|0,0,39);es=es+ms|0;a:{if(hl(is,12532,0)){o[hs+56>>2]=1;l[o[o[is>>2]+20>>2]](is,hs+8|0,es,es,1,0);ls=o[hs+32>>2]==1?es:0;break a}l[o[o[is>>2]+24>>2]](is,hs+8|0,es,1,0);es=o[hs+44>>2];if(es>>>0>1){break a}if(es-1){ls=o[hs+48>>2]==1?o[hs+36>>2]==1?o[hs+40>>2]==1?o[hs+28>>2]:0:0:0;break a}if(o[hs+32>>2]!=1){if(o[hs+48>>2]|o[hs+36>>2]!=1|o[hs+40>>2]!=1){break a}}ls=o[hs+24>>2]}R=hs- -64|0;return ls}function kl(es,ns,os){var ps=0;ps=o[es+16>>2];if(!ps){o[es+36>>2]=1;o[es+24>>2]=os;o[es+16>>2]=ns;return}a:{if((ns|0)==(ps|0)){if(o[es+24>>2]!=2){break a}o[es+24>>2]=os;return}m[es+54|0]=1;o[es+24>>2]=2;o[es+36>>2]=o[es+36>>2]+1}}function ll(es,ns,os,qs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;if(hl(es,o[ns+8>>2],0)){kl(ns,os,qs)}}function ml(es,ns,os,qs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;if(hl(es,o[ns+8>>2],0)){kl(ns,os,qs);return}es=o[es+8>>2];l[o[o[es>>2]+28>>2]](es,ns,os,qs)}function nl(es,ns,os,qs){m[es+53|0]=1;a:{if(o[es+4>>2]!=(os|0)){break a}m[es+52|0]=1;os=o[es+16>>2];if(!os){o[es+36>>2]=1;o[es+24>>2]=qs;o[es+16>>2]=ns;if((qs|0)!=1|o[es+48>>2]!=1){break a}m[es+54|0]=1;return}if((ns|0)==(os|0)){os=o[es+24>>2];if((os|0)==2){o[es+24>>2]=qs;os=qs}if(o[es+48>>2]!=1|(os|0)!=1){break a}m[es+54|0]=1;return}m[es+54|0]=1;o[es+36>>2]=o[es+36>>2]+1}}function ol(es,ns,os){if(!(o[es+28>>2]==1|o[es+4>>2]!=(ns|0))){o[es+28>>2]=os}}function pl(es,ns,os,qs,rs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;if(hl(es,o[ns+8>>2],rs)){ol(ns,os,qs);return}a:{if(hl(es,o[ns>>2],rs)){if(!(o[ns+20>>2]!=(os|0)?o[ns+16>>2]!=(os|0):0)){if((qs|0)!=1){break a}o[ns+32>>2]=1;return}o[ns+32>>2]=qs;b:{if(o[ns+44>>2]==4){break b}n[ns+52>>1]=0;es=o[es+8>>2];l[o[o[es>>2]+20>>2]](es,ns,os,os,1,rs);if(p[ns+53|0]){o[ns+44>>2]=3;if(!p[ns+52|0]){break b}break a}o[ns+44>>2]=4}o[ns+20>>2]=os;o[ns+40>>2]=o[ns+40>>2]+1;if(o[ns+36>>2]!=1|o[ns+24>>2]!=2){break a}m[ns+54|0]=1;return}es=o[es+8>>2];l[o[o[es>>2]+24>>2]](es,ns,os,qs,rs)}}function ql(es,ns,os,qs,rs){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;if(hl(es,o[ns+8>>2],rs)){ol(ns,os,qs);return}a:{if(!hl(es,o[ns>>2],rs)){break a}if(!(o[ns+20>>2]!=(os|0)?o[ns+16>>2]!=(os|0):0)){if((qs|0)!=1){break a}o[ns+32>>2]=1;return}o[ns+20>>2]=os;o[ns+32>>2]=qs;o[ns+40>>2]=o[ns+40>>2]+1;if(!(o[ns+36>>2]!=1|o[ns+24>>2]!=2)){m[ns+54|0]=1}o[ns+44>>2]=4}}function rl(es,ns,os,qs,rs,ss){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;ss=ss|0;if(hl(es,o[ns+8>>2],ss)){nl(ns,os,qs,rs);return}es=o[es+8>>2];l[o[o[es>>2]+20>>2]](es,ns,os,qs,rs,ss)}function sl(es,ns,os,qs,rs,ss){es=es|0;ns=ns|0;os=os|0;qs=qs|0;rs=rs|0;ss=ss|0;if(hl(es,o[ns+8>>2],ss)){nl(ns,os,qs,rs)}} + + + +function tl(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;l=R-16|0;R=l;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{if(a>>>0<=244){f=o[3288];h=a>>>0<11?16:a+11&-8;b=h>>>3;a=f>>>b;if(a&3){d=b+((a^-1)&1)|0;b=d<<3;e=o[b+13200>>2];a=e+8|0;c=o[e+8>>2];b=b+13192|0;l:{if((c|0)==(b|0)){m=13152,n=Zl(d)&f,o[m>>2]=n;break l}o[c+12>>2]=b;o[b+8>>2]=c}b=d<<3;o[e+4>>2]=b|3;b=b+e|0;o[b+4>>2]=o[b+4>>2]|1;break a}k=o[3290];if(h>>>0<=k>>>0){break k}if(a){c=a<>>12&16;c=a;b=b>>>a;a=b>>>5&8;c=c|a;b=b>>>a;a=b>>>2&4;c=c|a;b=b>>>a;a=b>>>1&2;c=c|a;b=b>>>a;a=b>>>1&1;c=(c|a)+(b>>>a)|0;a=c<<3;g=o[a+13200>>2];b=o[g+8>>2];a=a+13192|0;m:{if((b|0)==(a|0)){f=Zl(c)&f;o[3288]=f;break m}o[b+12>>2]=a;o[a+8>>2]=b}a=g+8|0;o[g+4>>2]=h|3;d=g+h|0;b=c<<3;e=b-h|0;o[d+4>>2]=e|1;o[b+g>>2]=e;if(k){b=k>>>3;c=(b<<3)+13192|0;h=o[3293];b=1<>2]}o[c+8>>2]=h;o[b+12>>2]=h;o[h+12>>2]=c;o[h+8>>2]=b}o[3293]=d;o[3290]=e;break a}i=o[3289];if(!i){break k}b=(i&0-i)+ -1|0;a=b>>>12&16;c=a;b=b>>>a;a=b>>>5&8;c=c|a;b=b>>>a;a=b>>>2&4;c=c|a;b=b>>>a;a=b>>>1&2;c=c|a;b=b>>>a;a=b>>>1&1;b=o[((c|a)+(b>>>a)<<2)+13456>>2];d=(o[b+4>>2]&-8)-h|0;c=b;while(1){o:{a=o[c+16>>2];if(!a){a=o[c+20>>2];if(!a){break o}}c=(o[a+4>>2]&-8)-h|0;e=c>>>0>>0;d=e?c:d;b=e?a:b;c=a;continue}break}j=o[b+24>>2];e=o[b+12>>2];if((e|0)!=(b|0)){a=o[b+8>>2];o[a+12>>2]=e;o[e+8>>2]=a;break b}c=b+20|0;a=o[c>>2];if(!a){a=o[b+16>>2];if(!a){break j}c=b+16|0}while(1){g=c;e=a;c=a+20|0;a=o[c>>2];if(a){continue}c=e+16|0;a=o[e+16>>2];if(a){continue}break}o[g>>2]=0;break b}h=-1;if(a>>>0>4294967231){break k}a=a+11|0;h=a&-8;i=o[3289];if(!i){break k}a=a>>>8;g=0;p:{if(!a){break p}g=31;if(h>>>0>16777215){break p}b=a+1048320>>>16&8;a=a<>>16&4;a=a<>>16&2;a=(a<>>15)-(c|(b|d))|0;g=(a<<1|h>>>a+21&1)+28|0}c=0-h|0;d=o[(g<<2)+13456>>2];q:{r:{s:{if(!d){a=0;break s}b=h<<((g|0)==31?0:25-(g>>>1)|0);a=0;while(1){t:{f=(o[d+4>>2]&-8)-h|0;if(f>>>0>=c>>>0){break t}e=d;c=f;if(c){break t}c=0;a=d;break r}f=o[d+20>>2];d=o[((b>>>29&4)+d|0)+16>>2];a=f?(f|0)==(d|0)?a:f:a;b=b<<((d|0)!=0);if(d){continue}break}}if(!(a|e)){a=2<>>12&16;d=a;b=b>>>a;a=b>>>5&8;d=d|a;b=b>>>a;a=b>>>2&4;d=d|a;b=b>>>a;a=b>>>1&2;d=d|a;b=b>>>a;a=b>>>1&1;a=o[((d|a)+(b>>>a)<<2)+13456>>2]}if(!a){break q}}while(1){b=(o[a+4>>2]&-8)-h|0;d=b>>>0>>0;c=d?b:c;e=d?a:e;b=o[a+16>>2];if(b){a=b}else{a=o[a+20>>2]}if(a){continue}break}}if(!e|c>>>0>=o[3290]-h>>>0){break k}g=o[e+24>>2];b=o[e+12>>2];if((e|0)!=(b|0)){a=o[e+8>>2];o[a+12>>2]=b;o[b+8>>2]=a;break c}d=e+20|0;a=o[d>>2];if(!a){a=o[e+16>>2];if(!a){break i}d=e+16|0}while(1){f=d;b=a;d=a+20|0;a=o[d>>2];if(a){continue}d=b+16|0;a=o[b+16>>2];if(a){continue}break}o[f>>2]=0;break c}c=o[3290];if(c>>>0>=h>>>0){d=o[3293];b=c-h|0;u:{if(b>>>0>=16){o[3290]=b;a=d+h|0;o[3293]=a;o[a+4>>2]=b|1;o[c+d>>2]=b;o[d+4>>2]=h|3;break u}o[3293]=0;o[3290]=0;o[d+4>>2]=c|3;a=c+d|0;o[a+4>>2]=o[a+4>>2]|1}a=d+8|0;break a}j=o[3291];if(j>>>0>h>>>0){b=j-h|0;o[3291]=b;c=o[3294];a=c+h|0;o[3294]=a;o[a+4>>2]=b|1;o[c+4>>2]=h|3;a=c+8|0;break a}a=0;i=h+47|0;b=i;if(o[3406]){c=o[3408]}else{o[3409]=-1;o[3410]=-1;o[3407]=4096;o[3408]=4096;o[3406]=l+12&-16^1431655768;o[3411]=0;o[3399]=0;c=4096}g=b+c|0;f=0-c|0;c=g&f;if(c>>>0<=h>>>0){break a}e=o[3398];if(e){d=o[3396];b=d+c|0;if(b>>>0<=d>>>0|b>>>0>e>>>0){break a}}if(p[13596]&4){break f}v:{w:{d=o[3294];if(d){a=13600;while(1){b=o[a>>2];if(b+o[a+4>>2]>>>0>d>>>0?b>>>0<=d>>>0:0){break w}a=o[a+8>>2];if(a){continue}break}}b=vl(0);if((b|0)==-1){break g}f=c;d=o[3407];a=d+ -1|0;if(a&b){f=(c-b|0)+(a+b&0-d)|0}if(f>>>0<=h>>>0|f>>>0>2147483646){break g}e=o[3398];if(e){d=o[3396];a=d+f|0;if(a>>>0<=d>>>0|a>>>0>e>>>0){break g}}a=vl(f);if((b|0)!=(a|0)){break v}break e}f=f&g-j;if(f>>>0>2147483646){break g}b=vl(f);if((b|0)==(o[a>>2]+o[a+4>>2]|0)){break h}a=b}b=a;if(!(h+48>>>0<=f>>>0|f>>>0>2147483646|(a|0)==-1)){a=o[3408];a=a+(i-f|0)&0-a;if(a>>>0>2147483646){break e}if((vl(a)|0)!=-1){f=a+f|0;break e}vl(0-f|0);break g}if((b|0)!=-1){break e}break g}e=0;break b}b=0;break c}if((b|0)!=-1){break e}}o[3399]=o[3399]|4}if(c>>>0>2147483646){break d}b=vl(c);a=vl(0);if(b>>>0>=a>>>0|(b|0)==-1|(a|0)==-1){break d}f=a-b|0;if(f>>>0<=h+40>>>0){break d}}a=o[3396]+f|0;o[3396]=a;if(a>>>0>r[3397]){o[3397]=a}x:{y:{z:{d=o[3294];if(d){a=13600;while(1){e=o[a>>2];c=o[a+4>>2];if((e+c|0)==(b|0)){break z}a=o[a+8>>2];if(a){continue}break}break y}a=o[3292];if(!(b>>>0>=a>>>0?a:0)){o[3292]=b}a=0;o[3401]=f;o[3400]=b;o[3296]=-1;o[3297]=o[3406];o[3403]=0;while(1){d=a<<3;c=d+13192|0;o[d+13200>>2]=c;o[d+13204>>2]=c;a=a+1|0;if((a|0)!=32){continue}break}d=f+ -40|0;a=b+8&7?-8-b&7:0;c=d-a|0;o[3291]=c;a=a+b|0;o[3294]=a;o[a+4>>2]=c|1;o[(b+d|0)+4>>2]=40;o[3295]=o[3410];break x}if(p[a+12|0]&8|b>>>0<=d>>>0|e>>>0>d>>>0){break y}o[a+4>>2]=c+f;a=d+8&7?-8-d&7:0;c=a+d|0;o[3294]=c;b=o[3291]+f|0;a=b-a|0;o[3291]=a;o[c+4>>2]=a|1;o[(b+d|0)+4>>2]=40;o[3295]=o[3410];break x}e=o[3292];if(b>>>0>>0){o[3292]=b;e=0}c=b+f|0;a=13600;A:{B:{C:{D:{E:{F:{while(1){if((c|0)!=o[a>>2]){a=o[a+8>>2];if(a){continue}break F}break}if(!(p[a+12|0]&8)){break E}}a=13600;while(1){c=o[a>>2];if(c>>>0<=d>>>0){g=c+o[a+4>>2]|0;if(g>>>0>d>>>0){break D}}a=o[a+8>>2];continue}}o[a>>2]=b;o[a+4>>2]=o[a+4>>2]+f;j=(b+8&7?-8-b&7:0)+b|0;o[j+4>>2]=h|3;b=c+(c+8&7?-8-c&7:0)|0;a=(b-j|0)-h|0;g=h+j|0;if((b|0)==(d|0)){o[3294]=g;a=o[3291]+a|0;o[3291]=a;o[g+4>>2]=a|1;break B}if(o[3293]==(b|0)){o[3293]=g;a=o[3290]+a|0;o[3290]=a;o[g+4>>2]=a|1;o[a+g>>2]=a;break B}c=o[b+4>>2];if((c&3)==1){i=c&-8;G:{if(c>>>0<=255){e=o[b+8>>2];c=c>>>3;d=o[b+12>>2];if((d|0)==(e|0)){m=13152,n=o[3288]&Zl(c),o[m>>2]=n;break G}o[e+12>>2]=d;o[d+8>>2]=e;break G}k=o[b+24>>2];f=o[b+12>>2];H:{if((f|0)!=(b|0)){c=o[b+8>>2];o[c+12>>2]=f;o[f+8>>2]=c;break H}I:{d=b+20|0;h=o[d>>2];if(h){break I}d=b+16|0;h=o[d>>2];if(h){break I}f=0;break H}while(1){c=d;f=h;d=f+20|0;h=o[d>>2];if(h){continue}d=f+16|0;h=o[f+16>>2];if(h){continue}break}o[c>>2]=0}if(!k){break G}d=o[b+28>>2];c=(d<<2)+13456|0;J:{if(o[c>>2]==(b|0)){o[c>>2]=f;if(f){break J}m=13156,n=o[3289]&Zl(d),o[m>>2]=n;break G}o[k+(o[k+16>>2]==(b|0)?16:20)>>2]=f;if(!f){break G}}o[f+24>>2]=k;c=o[b+16>>2];if(c){o[f+16>>2]=c;o[c+24>>2]=f}c=o[b+20>>2];if(!c){break G}o[f+20>>2]=c;o[c+24>>2]=f}b=b+i|0;a=a+i|0}o[b+4>>2]=o[b+4>>2]&-2;o[g+4>>2]=a|1;o[a+g>>2]=a;if(a>>>0<=255){a=a>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=g;o[a+12>>2]=g;o[g+12>>2]=b;o[g+8>>2]=a;break B}b=g;d=a>>>8;c=0;L:{if(!d){break L}c=31;if(a>>>0>16777215){break L}c=d;d=d+1048320>>>16&8;c=c<>>16&4;c=c<>>16&2;c=(c<>>15)-(e|(d|f))|0;c=(c<<1|a>>>c+21&1)+28|0}o[b+28>>2]=c;o[g+16>>2]=0;o[g+20>>2]=0;e=(c<<2)+13456|0;d=o[3289];b=1<>2]=g;o[g+24>>2]=e;break M}d=a<<((c|0)==31?0:25-(c>>>1)|0);b=o[e>>2];while(1){c=b;if((o[b+4>>2]&-8)==(a|0)){break C}b=d>>>29;d=d<<1;e=(c+(b&4)|0)+16|0;b=o[e>>2];if(b){continue}break}o[e>>2]=g;o[g+24>>2]=c}o[g+12>>2]=g;o[g+8>>2]=g;break B}e=f+ -40|0;a=b+8&7?-8-b&7:0;c=e-a|0;o[3291]=c;a=a+b|0;o[3294]=a;o[a+4>>2]=c|1;o[(b+e|0)+4>>2]=40;o[3295]=o[3410];a=(g+(g+ -39&7?39-g&7:0)|0)+ -47|0;c=a>>>0>>0?d:a;o[c+4>>2]=27;a=o[3403];o[c+16>>2]=o[3402];o[c+20>>2]=a;a=o[3401];o[c+8>>2]=o[3400];o[c+12>>2]=a;o[3402]=c+8;o[3401]=f;o[3400]=b;o[3403]=0;a=c+24|0;while(1){o[a+4>>2]=7;b=a+8|0;a=a+4|0;if(b>>>0>>0){continue}break}if((c|0)==(d|0)){break x}o[c+4>>2]=o[c+4>>2]&-2;g=c-d|0;o[d+4>>2]=g|1;o[c>>2]=g;if(g>>>0<=255){a=g>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=d;o[a+12>>2]=d;o[d+12>>2]=b;o[d+8>>2]=a;break x}o[d+16>>2]=0;o[d+20>>2]=0;a=d;c=g>>>8;b=0;O:{if(!c){break O}b=31;if(g>>>0>16777215){break O}b=c;c=c+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15)-(e|(c|f))|0;b=(b<<1|g>>>b+21&1)+28|0}o[a+28>>2]=b;e=(b<<2)+13456|0;c=o[3289];a=1<>2]=d;o[d+24>>2]=e;break P}a=g<<((b|0)==31?0:25-(b>>>1)|0);b=o[e>>2];while(1){c=b;if((g|0)==(o[b+4>>2]&-8)){break A}b=a>>>29;a=a<<1;e=(c+(b&4)|0)+16|0;b=o[e>>2];if(b){continue}break}o[e>>2]=d;o[d+24>>2]=c}o[d+12>>2]=d;o[d+8>>2]=d;break x}a=o[c+8>>2];o[a+12>>2]=g;o[c+8>>2]=g;o[g+24>>2]=0;o[g+12>>2]=c;o[g+8>>2]=a}a=j+8|0;break a}a=o[c+8>>2];o[a+12>>2]=d;o[c+8>>2]=d;o[d+24>>2]=0;o[d+12>>2]=c;o[d+8>>2]=a}a=o[3291];if(a>>>0<=h>>>0){break d}b=a-h|0;o[3291]=b;c=o[3294];a=c+h|0;o[3294]=a;o[a+4>>2]=b|1;o[c+4>>2]=h|3;a=c+8|0;break a}o[3269]=48;a=0;break a}Q:{if(!g){break Q}d=o[e+28>>2];a=(d<<2)+13456|0;R:{if(o[a>>2]==(e|0)){o[a>>2]=b;if(b){break R}i=Zl(d)&i;o[3289]=i;break Q}o[g+(o[g+16>>2]==(e|0)?16:20)>>2]=b;if(!b){break Q}}o[b+24>>2]=g;a=o[e+16>>2];if(a){o[b+16>>2]=a;o[a+24>>2]=b}a=o[e+20>>2];if(!a){break Q}o[b+20>>2]=a;o[a+24>>2]=b}S:{if(c>>>0<=15){a=c+h|0;o[e+4>>2]=a|3;a=a+e|0;o[a+4>>2]=o[a+4>>2]|1;break S}o[e+4>>2]=h|3;d=e+h|0;o[d+4>>2]=c|1;o[c+d>>2]=c;if(c>>>0<=255){a=c>>>3;b=(a<<3)+13192|0;c=o[3288];a=1<>2]}o[b+8>>2]=d;o[a+12>>2]=d;o[d+12>>2]=b;o[d+8>>2]=a;break S}a=d;f=c>>>8;b=0;U:{if(!f){break U}b=31;if(c>>>0>16777215){break U}b=f;f=f+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15)-(h|(f|g))|0;b=(b<<1|c>>>b+21&1)+28|0}o[a+28>>2]=b;o[d+16>>2]=0;o[d+20>>2]=0;f=(b<<2)+13456|0;V:{a=1<>2]=d;o[d+24>>2]=f;break W}a=c<<((b|0)==31?0:25-(b>>>1)|0);h=o[f>>2];while(1){b=h;if((o[b+4>>2]&-8)==(c|0)){break V}f=a>>>29;a=a<<1;f=(b+(f&4)|0)+16|0;h=o[f>>2];if(h){continue}break}o[f>>2]=d;o[d+24>>2]=b}o[d+12>>2]=d;o[d+8>>2]=d;break S}a=o[b+8>>2];o[a+12>>2]=d;o[b+8>>2]=d;o[d+24>>2]=0;o[d+12>>2]=b;o[d+8>>2]=a}a=e+8|0;break a}X:{if(!j){break X}c=o[b+28>>2];a=(c<<2)+13456|0;Y:{if(o[a>>2]==(b|0)){o[a>>2]=e;if(e){break Y}m=13156,n=Zl(c)&i,o[m>>2]=n;break X}o[(o[j+16>>2]==(b|0)?16:20)+j>>2]=e;if(!e){break X}}o[e+24>>2]=j;a=o[b+16>>2];if(a){o[e+16>>2]=a;o[a+24>>2]=e}a=o[b+20>>2];if(!a){break X}o[e+20>>2]=a;o[a+24>>2]=e}Z:{if(d>>>0<=15){a=d+h|0;o[b+4>>2]=a|3;a=a+b|0;o[a+4>>2]=o[a+4>>2]|1;break Z}o[b+4>>2]=h|3;e=b+h|0;o[e+4>>2]=d|1;o[d+e>>2]=d;if(k){a=k>>>3;c=(a<<3)+13192|0;h=o[3293];a=1<>2]}o[c+8>>2]=h;o[a+12>>2]=h;o[h+12>>2]=c;o[h+8>>2]=a}o[3293]=e;o[3290]=d}a=b+8|0}R=l+16|0;return a|0}function ul(a){a=a|0;var p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;a:{if(!a){break a}s=a+ -8|0;q=o[a+ -4>>2];a=q&-8;u=s+a|0;b:{if(q&1){break b}if(!(q&3)){break a}q=o[s>>2];s=s-q|0;if(s>>>0>>0<=255){t=o[s+8>>2];q=q>>>3;p=o[s+12>>2];if((p|0)==(t|0)){x=13152,y=o[3288]&Zl(q),o[x>>2]=y;break b}o[t+12>>2]=p;o[p+8>>2]=t;break b}w=o[s+24>>2];q=o[s+12>>2];c:{if((q|0)!=(s|0)){p=o[s+8>>2];o[p+12>>2]=q;o[q+8>>2]=p;break c}d:{t=s+20|0;p=o[t>>2];if(p){break d}t=s+16|0;p=o[t>>2];if(p){break d}q=0;break c}while(1){v=t;q=p;t=q+20|0;p=o[t>>2];if(p){continue}t=q+16|0;p=o[q+16>>2];if(p){continue}break}o[v>>2]=0}if(!w){break b}t=o[s+28>>2];p=(t<<2)+13456|0;e:{if(o[p>>2]==(s|0)){o[p>>2]=q;if(q){break e}x=13156,y=o[3289]&Zl(t),o[x>>2]=y;break b}o[w+(o[w+16>>2]==(s|0)?16:20)>>2]=q;if(!q){break b}}o[q+24>>2]=w;p=o[s+16>>2];if(p){o[q+16>>2]=p;o[p+24>>2]=q}p=o[s+20>>2];if(!p){break b}o[q+20>>2]=p;o[p+24>>2]=q;break b}q=o[u+4>>2];if((q&3)!=3){break b}o[3290]=a;o[u+4>>2]=q&-2;o[s+4>>2]=a|1;o[a+s>>2]=a;return}if(u>>>0<=s>>>0){break a}q=o[u+4>>2];if(!(q&1)){break a}f:{if(!(q&2)){if((u|0)==o[3294]){o[3294]=s;a=o[3291]+a|0;o[3291]=a;o[s+4>>2]=a|1;if(o[3293]!=(s|0)){break a}o[3290]=0;o[3293]=0;return}if((u|0)==o[3293]){o[3293]=s;a=o[3290]+a|0;o[3290]=a;o[s+4>>2]=a|1;o[a+s>>2]=a;return}a=(q&-8)+a|0;g:{if(q>>>0<=255){p=o[u+8>>2];q=q>>>3;t=o[u+12>>2];if((p|0)==(t|0)){x=13152,y=o[3288]&Zl(q),o[x>>2]=y;break g}o[p+12>>2]=t;o[t+8>>2]=p;break g}w=o[u+24>>2];q=o[u+12>>2];h:{if((u|0)!=(q|0)){p=o[u+8>>2];o[p+12>>2]=q;o[q+8>>2]=p;break h}i:{t=u+20|0;p=o[t>>2];if(p){break i}t=u+16|0;p=o[t>>2];if(p){break i}q=0;break h}while(1){v=t;q=p;t=q+20|0;p=o[t>>2];if(p){continue}t=q+16|0;p=o[q+16>>2];if(p){continue}break}o[v>>2]=0}if(!w){break g}t=o[u+28>>2];p=(t<<2)+13456|0;j:{if((u|0)==o[p>>2]){o[p>>2]=q;if(q){break j}x=13156,y=o[3289]&Zl(t),o[x>>2]=y;break g}o[w+((u|0)==o[w+16>>2]?16:20)>>2]=q;if(!q){break g}}o[q+24>>2]=w;p=o[u+16>>2];if(p){o[q+16>>2]=p;o[p+24>>2]=q}p=o[u+20>>2];if(!p){break g}o[q+20>>2]=p;o[p+24>>2]=q}o[s+4>>2]=a|1;o[a+s>>2]=a;if(o[3293]!=(s|0)){break f}o[3290]=a;return}o[u+4>>2]=q&-2;o[s+4>>2]=a|1;o[a+s>>2]=a}if(a>>>0<=255){a=a>>>3;q=(a<<3)+13192|0;p=o[3288];a=1<>2]}o[q+8>>2]=s;o[a+12>>2]=s;o[s+12>>2]=q;o[s+8>>2]=a;return}o[s+16>>2]=0;o[s+20>>2]=0;q=s;t=a>>>8;p=0;l:{if(!t){break l}p=31;if(a>>>0>16777215){break l}p=t;t=t+1048320>>>16&8;p=p<>>16&4;p=p<>>16&2;p=(p<>>15)-(v|(t|w))|0;p=(p<<1|a>>>p+21&1)+28|0}o[q+28>>2]=p;v=(p<<2)+13456|0;t=o[3289];q=1<>2]=s;o[s+12>>2]=s;o[s+24>>2]=v;o[s+8>>2]=s;break m}t=a<<((p|0)==31?0:25-(p>>>1)|0);q=o[v>>2];n:{while(1){p=q;if((o[q+4>>2]&-8)==(a|0)){break n}q=t>>>29;t=t<<1;v=(p+(q&4)|0)+16|0;q=o[v>>2];if(q){continue}break}o[v>>2]=s;o[s+12>>2]=s;o[s+24>>2]=p;o[s+8>>2]=s;break m}a=o[p+8>>2];o[a+12>>2]=s;o[p+8>>2]=s;o[s+24>>2]=0;o[s+12>>2]=p;o[s+8>>2]=a}a=o[3296]+ -1|0;o[3296]=a;if(a){break a}s=13608;while(1){a=o[s>>2];s=a+8|0;if(a){continue}break}o[3296]=-1}}function vl(a){var r=0;r=o[3416];a=r+a|0;if((a|0)<=-1){o[3269]=48;return-1}a:{if(a>>>0<=U()<<16>>>0){break a}if(N(a|0)){break a}o[3269]=48;return-1}o[3416]=a;return r}function wl(a,z,A){var B=0,C=0,D=0;if(A>>>0>=8192){O(a|0,z|0,A|0)|0;return a}C=a+A|0;a:{if(!((a^z)&3)){b:{if((A|0)<1){A=a;break b}if(!(a&3)){A=a;break b}A=a;while(1){m[A|0]=p[z|0];z=z+1|0;A=A+1|0;if(A>>>0>=C>>>0){break b}if(A&3){continue}break}}B=C&-4;c:{if(B>>>0<64){break c}D=B+ -64|0;if(A>>>0>D>>>0){break c}while(1){o[A>>2]=o[z>>2];o[A+4>>2]=o[z+4>>2];o[A+8>>2]=o[z+8>>2];o[A+12>>2]=o[z+12>>2];o[A+16>>2]=o[z+16>>2];o[A+20>>2]=o[z+20>>2];o[A+24>>2]=o[z+24>>2];o[A+28>>2]=o[z+28>>2];o[A+32>>2]=o[z+32>>2];o[A+36>>2]=o[z+36>>2];o[A+40>>2]=o[z+40>>2];o[A+44>>2]=o[z+44>>2];o[A+48>>2]=o[z+48>>2];o[A+52>>2]=o[z+52>>2];o[A+56>>2]=o[z+56>>2];o[A+60>>2]=o[z+60>>2];z=z- -64|0;A=A- -64|0;if(A>>>0<=D>>>0){continue}break}}if(A>>>0>=B>>>0){break a}while(1){o[A>>2]=o[z>>2];z=z+4|0;A=A+4|0;if(A>>>0>>0){continue}break}break a}if(C>>>0<4){A=a;break a}B=C+ -4|0;if(B>>>0>>0){A=a;break a}A=a;while(1){m[A|0]=p[z|0];m[A+1|0]=p[z+1|0];m[A+2|0]=p[z+2|0];m[A+3|0]=p[z+3|0];z=z+4|0;A=A+4|0;if(A>>>0<=B>>>0){continue}break}}if(A>>>0>>0){while(1){m[A|0]=p[z|0];z=z+1|0;A=A+1|0;if((C|0)!=(A|0)){continue}break}}return a}function xl(a,z,A){var E=0,F=0,G=0,H=0;a:{if(!A){break a}E=a+A|0;m[E+ -1|0]=z;m[a|0]=z;if(A>>>0<3){break a}m[E+ -2|0]=z;m[a+1|0]=z;m[E+ -3|0]=z;m[a+2|0]=z;if(A>>>0<7){break a}m[E+ -4|0]=z;m[a+3|0]=z;if(A>>>0<9){break a}E=0-a&3;F=E+a|0;z=u(z&255,16843009);o[F>>2]=z;A=A-E&-4;E=A+F|0;o[E+ -4>>2]=z;if(A>>>0<9){break a}o[F+8>>2]=z;o[F+4>>2]=z;o[E+ -8>>2]=z;o[E+ -12>>2]=z;if(A>>>0<25){break a}o[F+24>>2]=z;o[F+20>>2]=z;o[F+16>>2]=z;o[F+12>>2]=z;o[E+ -16>>2]=z;o[E+ -20>>2]=z;o[E+ -24>>2]=z;o[E+ -28>>2]=z;H=F&4|24;A=A-H|0;if(A>>>0<32){break a}E=z;G=z;z=F+H|0;while(1){o[z+24>>2]=G;o[z+28>>2]=E;o[z+16>>2]=G;o[z+20>>2]=E;o[z+8>>2]=G;o[z+12>>2]=E;o[z>>2]=G;o[z+4>>2]=E;z=z+32|0;A=A+ -32|0;if(A>>>0>31){continue}break}}return a}function yl(a,z,A){var I=0,J=0;a:{if((a|0)==(z|0)){break a}b:{if(z+A>>>0>a>>>0){J=a+A|0;if(J>>>0>z>>>0){break b}}return wl(a,z,A)}I=(a^z)&3;c:{d:{if(a>>>0>>0){if(I){I=a;break c}if(!(a&3)){I=a;break d}I=a;while(1){if(!A){break a}m[I|0]=p[z|0];z=z+1|0;A=A+ -1|0;I=I+1|0;if(I&3){continue}break}break d}e:{if(I){break e}if(J&3){while(1){if(!A){break a}A=A+ -1|0;I=A+a|0;m[I|0]=p[z+A|0];if(I&3){continue}break}}if(A>>>0<=3){break e}while(1){A=A+ -4|0;o[A+a>>2]=o[z+A>>2];if(A>>>0>3){continue}break}}if(!A){break a}while(1){A=A+ -1|0;m[A+a|0]=p[z+A|0];if(A){continue}break}break a}if(A>>>0<=3){break c}J=A;while(1){o[I>>2]=o[z>>2];z=z+4|0;I=I+4|0;J=J+ -4|0;if(J>>>0>3){continue}break}A=A&3}if(!A){break a}while(1){m[I|0]=p[z|0];I=I+1|0;z=z+1|0;A=A+ -1|0;if(A){continue}break}}return a}function zl(a,z){a=a|0;z=z|0;if(!o[3412]){o[3413]=z;o[3412]=a}}function Al(){return R|0}function Bl(a){a=a|0;a=R-a&-16;R=a;return a|0}function Cl(a){a=a|0;R=a}function Dl(a){a=a|0;return V(a|0)|0}function El(a,o){a=a|0;o=o|0;return l[a](o)|0}function Fl(a,o){a=a|0;o=o|0;l[a](o)}function Gl(a,o,z){a=a|0;o=o|0;z=z|0;return l[a](o,z)|0}function Hl(a,o,z){a=a|0;o=o|0;z=z|0;l[a](o,z)}function Il(a,o,z,A){a=a|0;o=o|0;z=z|0;A=A|0;return l[a](o,z,A)|0}function Jl(a){a=a|0;l[a]()}function Kl(a,o,z,A){a=a|0;o=o|0;z=z|0;A=A|0;l[a](o,z,A)}function Ll(a,o,z,A,K){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;l[a](o,z,A,K)}function Ml(a,o,z,A,K,L,M){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;M=M|0;return l[a](o,z,A,K,L,M)|0}function Nl(a,o,z,A,K,L,M){a=a|0;o=o|0;z=+z;A=A|0;K=K|0;L=L|0;M=M|0;return l[a](o,z,A,K,L,M)|0}function Ol(a,o,z,A,K,L,M){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;M=M|0;l[a](o,z,A,K,L,M)}function Pl(a,o,z,A,K,L){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;L=L|0;l[a](o,z,A,K,L)}function Ql(a,o,z,A,K){a=a|0;o=o|0;z=z|0;A=A|0;K=K|0;a=l[a](o,z,A,K)|0;P(T|0);return a|0}function Rl(a,o){i(a|0,o|0)}function Sl(a,o,z,A){var K=0,L=0,M=0,N=0,O=0,P=0;K=z>>>16;L=a>>>16;P=u(K,L);M=z&65535;N=a&65535;O=u(M,N);L=(O>>>16)+u(L,M)|0;K=(L&65535)+u(K,N)|0;a=(((u(o,z)+P|0)+u(a,A)|0)+(L>>>16)|0)+(K>>>16)|0;o=O&65535|K<<16;T=a;return o}function Tl(a,o,z,A){var Q=0,R=0,S=0,U=0;Q=o;R=Q>>31;Q=Q>>31;a=a^Q;S=a-Q|0;U=(o^R)-((a>>>0>>0)+R|0)|0;Q=A;R=Q>>31;Q=Q>>31;a=z^Q;Q=Xl(S,U,a-Q|0,(A^R)-((a>>>0>>0)+R|0)|0);o=o^A;z=o>>31;a=o>>31;o=Q^a;A=o-a|0;T=(z^T)-((o>>>0>>0)+z|0)|0;return A}function Ul(a,o,z,A){var V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{X=o;if(X){V=z;if(!V){break j}W=A;if(!W){break i}W=x(W)-x(X)|0;if(W>>>0<=31){break h}break b}if((A|0)==1&z>>>0>=0|A>>>0>1){break b}o=(a>>>0)/(z>>>0)|0;Rl(a-u(o,z)|0,0);T=0;return o}V=A;if(!a){break g}if(!V){break f}W=V+ -1|0;if(W&V){break f}Rl(a,W&X);a=X>>>(_l(V)&31);T=0;return a}W=V+ -1|0;if(!(W&V)){break e}_=(x(V)+33|0)-x(X)|0;Y=0-_|0;break c}_=W+1|0;Y=63-W|0;break c}a=(X>>>0)/(V>>>0)|0;Rl(0,X-u(a,V)|0);T=0;return a}W=x(V)-x(X)|0;if(W>>>0<31){break d}break b}Rl(a&W,0);if((V|0)==1){break a}z=a;a=_l(V);A=a&31;if(32<=(a&63)>>>0){W=0;a=o>>>A}else{W=o>>>A;a=((1<>>A}T=W;return a}_=W+1|0;Y=63-W|0}V=o;X=a;W=_&63;Z=W&31;if(32<=(W&63)>>>0){W=0;aa=V>>>Z}else{W=V>>>Z;aa=((1<>>Z}a=Y&63;Y=a&31;if(32<=(a&63)>>>0){V=X<>>32-Y|o<>>0<4294967295){X=X+1|0}Y=V;while(1){V=aa;W=W<<1|V>>>31;V=V<<1;$=W;W=o>>>31|V;ba=$;V=$;$=W;Z=X-((Y>>>0>>0)+V|0)|0;V=Z>>31;Z=Z>>31;W=z&Z;aa=$-W|0;W=ba-((A&V)+($>>>0>>0)|0)|0;V=o<<1|a>>>31;a=ca|a<<1;o=V|da;V=0;ba=V;$=Z&1;ca=$;_=_+ -1|0;if(_){continue}break}}Rl(aa,W);V=o<<1|a>>>31;a=$|a<<1;T=V|ba;return a}Rl(a,o);a=0;o=0}T=o;return a}function Vl(a,o,z,A){a=Sl(a,o,z,A);return a}function Wl(a,o,z,A){a=Tl(a,o,z,A);return a}function Xl(a,o,z,A){a=Ul(a,o,z,A);return a}function Yl(a){var o=0,z=0;while(1){z=o;if(a){a=a-1&a;o=o+1|0;continue}break}return z}function Zl(a){var A=0;A=a&31;a=0-a&31;return(-1>>>A&-2)<>>a}function _l(a){if(a){return 31-x(a+ -1^a)|0}return 32} + + + + +// EMSCRIPTEN_END_FUNCS +l[1]=cl;l[2]=$c;l[3]=ad;l[4]=bd;l[5]=Zc;l[6]=_c;l[7]=gd;l[8]=hd;l[9]=id;l[10]=cd;l[11]=dd;l[12]=zd;l[13]=Ad;l[14]=vd;l[15]=wd;l[16]=Bd;l[17]=Cd;l[18]=Dd;l[19]=zb;l[20]=Ed;l[21]=al;l[22]=Fd;l[23]=id;l[24]=Od;l[25]=Pd;l[26]=Hd;l[27]=Id;l[28]=Jd;l[29]=Kd;l[30]=Fd;l[31]=Md;l[32]=Nd;l[33]=Yd;l[34]=Zd;l[35]=Rd;l[36]=Td;l[37]=_d;l[38]=Ud;l[39]=Vd;l[40]=Wd;l[41]=Xd;l[42]=ie;l[43]=je;l[44]=ae;l[45]=be;l[46]=ce;l[47]=fe;l[48]=de;l[49]=ke;l[50]=he;l[51]=qe;l[52]=re;l[53]=id;l[54]=vb;l[55]=se;l[56]=te;l[57]=ue;l[58]=Ed;l[59]=te;l[60]=id;l[61]=ve;l[62]=we;l[63]=Ad;l[64]=Ad;l[65]=xe;l[66]=ye;l[67]=ze;l[68]=se;l[69]=Ae;l[70]=De;l[71]=Ee;l[72]=Fe;l[73]=Ge;l[74]=He;l[75]=id;l[76]=Ed;l[77]=Ie;l[78]=Je;l[79]=Ke;l[80]=Ne;l[81]=Oe;l[82]=Pe;l[83]=Qe;l[84]=id;l[85]=Ed;l[86]=Re;l[87]=Se;l[88]=Te;l[89]=$c;l[90]=ad;l[91]=Ve;l[92]=zb;l[93]=Ue;l[94]=re;l[95]=id;l[96]=se;l[97]=Ye;l[98]=Ad;l[99]=Ze;l[100]=_e;l[101]=ze;l[102]=se;l[103]=Ae;l[104]=$e;l[105]=af;l[106]=bf;l[107]=Ge;l[108]=He;l[109]=id;l[110]=Ed;l[111]=Ie;l[112]=Je;l[113]=cf;l[114]=ef;l[115]=ff;l[116]=Pe;l[117]=Qe;l[118]=id;l[119]=Ed;l[120]=Re;l[121]=Se;l[122]=gf;l[123]=$c;l[124]=ad;l[125]=Ve;l[126]=zb;l[127]=hf;l[128]=re;l[129]=te;l[130]=id;l[131]=kf;l[132]=je;l[133]=lf;l[134]=nf;l[135]=mf;l[136]=qf;l[137]=bd;l[138]=of;l[139]=sf;l[140]=tf;l[141]=Pe;l[142]=vb;l[143]=uf;l[144]=id;l[145]=Ed;l[146]=vf;l[147]=id;l[148]=wf;l[149]=xf;l[150]=yf;l[151]=$c;l[152]=ad;l[153]=Ve;l[154]=zb;l[155]=Ue;l[156]=Bf;l[157]=Cf;l[158]=Pe;l[159]=uf;l[160]=id;l[161]=Ed;l[162]=vf;l[163]=xf;l[164]=Df;l[165]=$c;l[166]=ad;l[167]=Ve;l[168]=zb;l[169]=hf;l[170]=$c;l[171]=ad;l[172]=te;l[173]=id;l[174]=te;l[175]=ue;l[176]=Ed;l[177]=Af;l[178]=Ef;l[179]=Kf;l[180]=Lf;l[181]=Ff;l[182]=Gf;l[183]=mf;l[184]=Hf;l[185]=If;l[186]=Jf;l[187]=wg;l[188]=Ad;l[189]=id;l[190]=id;l[191]=vg;l[192]=gi;l[193]=hi;l[194]=id;l[195]=te;l[196]=Ed;l[197]=Ed;l[198]=Bg;l[199]=Cg;l[200]=yg;l[201]=xg;l[202]=Ag;l[203]=Dg;l[204]=Eg;l[205]=Fg;l[206]=zg;l[207]=lh;l[208]=mh;l[209]=Ig;l[210]=Jg;l[211]=Kg;l[212]=Lg;l[213]=Sg;l[214]=id;l[215]=vb;l[216]=eh;l[217]=nh;l[218]=ph;l[219]=Ig;l[220]=Jg;l[221]=Kg;l[222]=Lg;l[223]=gh;l[224]=id;l[225]=vb;l[226]=eh;l[227]=Rg;l[228]=qh;l[229]=Qg;l[230]=rh;l[231]=sh;l[232]=wh;l[233]=xh;l[234]=yh;l[235]=zh;l[236]=vh;l[237]=Bh;l[238]=th;l[239]=Ch;l[240]=Dh;l[241]=Fh;l[242]=Gh;l[243]=Hh;l[244]=Ih;l[245]=Eh;l[246]=Kh;l[247]=Lh;l[248]=Mh;l[249]=Nh;l[250]=Oh;l[251]=Zh;l[252]=Yh;l[253]=Uh;l[254]=$c;l[255]=ad;l[256]=_h;l[257]=$h;l[258]=Ad;l[259]=te;l[260]=id;l[261]=Ni;l[262]=Oi;l[263]=Pi;l[264]=Ri;l[265]=Mi;l[266]=Bj;l[267]=wj;l[268]=zj;l[269]=Pj;l[270]=Qj;l[271]=Tj;l[272]=Rj;l[273]=Sj;l[274]=qk;l[275]=$c;l[276]=ad;l[277]=bl;l[278]=el;l[279]=fl;l[280]=gl;l[281]=$c;l[282]=ad;l[283]=Cj;l[284]=Cj;l[285]=il;l[286]=sl;l[287]=ql;l[288]=ll;l[289]=ad;l[290]=rl;l[291]=pl;l[292]=ml;function U(){return buffer.byteLength/65536|0}function V(pagesToAdd){pagesToAdd=pagesToAdd|0;var W=U()|0;var X=W+pagesToAdd|0;if(W>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":293,"maximum":293+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i=endIdx))++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var STACK_BASE=5256704,DYNAMIC_BASE=5256704,DYNAMICTOP_PTR=13664;var INITIAL_TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_TOTAL_MEMORY/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_TOTAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;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){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";out(what);err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";throw new WebAssembly.RuntimeError(what)}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var wasmBinaryFile="draco_decoder.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}var binary=tryParseAsDataURI(wasmBinaryFile);if(binary){return binary}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"env":asmLibraryArg,"wasi_unstable":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function demangle(func){return func}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function ___cxa_allocate_exception(size){return _malloc(size)}var ___exception_infos={};var ___exception_last=0;function ___cxa_throw(ptr,type,destructor){___exception_infos[ptr]={ptr:ptr,adjusted:[ptr],type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};___exception_last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exceptions=1}else{__ZSt18uncaught_exceptionv.uncaught_exceptions++}throw ptr}function _abort(){abort()}function _emscripten_get_heap_size(){return HEAP8.length}function _emscripten_get_sbrk_ptr(){return 13664}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=_emscripten_get_heap_size();var PAGE_MULTIPLE=65536;var LIMIT=2147483648-PAGE_MULTIPLE;if(requestedSize>LIMIT){return false}var MIN_TOTAL_MEMORY=16777216;var newSize=Math.max(oldSize,MIN_TOTAL_MEMORY);while(newSize>2];return ret},getStr:function(){var ret=UTF8ToString(SYSCALLS.get());return ret},get64:function(){var low=SYSCALLS.get(),high=SYSCALLS.get();return low},getZero:function(){SYSCALLS.get()}};function _fd_close(fd){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}noExitRuntime=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret},copy:function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;i3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",(function(reason,p){process["exit"](1)}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}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}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(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){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}Module["print"]=typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null;Module["printErr"]=typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||Module["print"];Module.print=Module["print"];Module.printErr=Module["printErr"];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){assert(!staticSealed);var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){assert(DYNAMICTOP_PTR);var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(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 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;Module.printErr(text)}}var jsCallStartIndex=1;var functionPointers=new Array(0);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;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=[typeof _malloc==="function"?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;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 allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{if(ArrayBuffer.transfer){ret=ArrayBuffer.transfer(buffer,size)}else{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}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_round=Math.round;var Math_min=Math.min;var Math_max=Math.max;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+19728;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,HBwAAGQcAAAYAAAAAAAAAPQbAACL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2VwdGlvbiBvZiB0eXBlICVzOiAlcwB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzAHRlcm1pbmF0aW5nIHdpdGggJXMgZm9yZWlnbiBleGNlcHRpb24AdGVybWluYXRpbmcAdW5jYXVnaHQAU3Q5ZXhjZXB0aW9uAE4xMF9fY3h4YWJpdjExNl9fc2hpbV90eXBlX2luZm9FAFN0OXR5cGVfaW5mbwBOMTBfX2N4eGFiaXYxMjBfX3NpX2NsYXNzX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTE3X19jbGFzc190eXBlX2luZm9FAHB0aHJlYWRfb25jZSBmYWlsdXJlIGluIF9fY3hhX2dldF9nbG9iYWxzX2Zhc3QoKQBjYW5ub3QgY3JlYXRlIHB0aHJlYWQga2V5IGZvciBfX2N4YV9nZXRfZ2xvYmFscygpAGNhbm5vdCB6ZXJvIG91dCB0aHJlYWQgdmFsdWUgZm9yIF9fY3hhX2dldF9nbG9iYWxzKCkAdGVybWluYXRlX2hhbmRsZXIgdW5leHBlY3RlZGx5IHJldHVybmVkAFN0MTFsb2dpY19lcnJvcgBTdDEybGVuZ3RoX2Vycm9yAE4xMF9fY3h4YWJpdjExOV9fcG9pbnRlcl90eXBlX2luZm9FAE4xMF9fY3h4YWJpdjExN19fcGJhc2VfdHlwZV9pbmZvRQ==";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___cxa_allocate_exception(size){return _malloc(size)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___cxa_begin_catch(ptr){var info=EXCEPTIONS.infos[ptr];if(info&&!info.caught){info.caught=true;__ZSt18uncaught_exceptionv.uncaught_exception--}if(info)info.rethrown=false;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(setTempRet0(throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___gxx_personality_v0(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function flush_NO_FILESYSTEM(){var fflush=Module["_fflush"];if(fflush)fflush(0);var printChar=___syscall146.printChar;if(!printChar)return;var buffers=___syscall146.buffers;if(buffers[1].length)printChar(1,10);if(buffers[2].length)printChar(2,10)}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffers){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Module["dynCall_v"](func);_pthread_once.seen[ptr]=1}function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function be(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;f[a+72>>2]=e;f[a+64>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;k=a+68|0;l=f[k>>2]|0;f[k>>2]=g;if(l|0)Mq(l);l=a+8|0;Mh(l,b,d,e);d=a+56|0;g=f[d>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+16|0;q=a+32|0;r=a+12|0;s=a+28|0;t=a+20|0;v=a+24|0;if(m-n>>2>>>0>p>>>0){w=p;x=n}else{y=g;aq(y)}while(1){f[j>>2]=f[x+(w<<2)>>2];f[i>>2]=f[j>>2];Cc(a,i,b,w);g=X(w,e)|0;n=b+(g<<2)|0;p=c+(g<<2)|0;g=f[l>>2]|0;if((g|0)>0){m=0;z=f[k>>2]|0;A=g;while(1){if((A|0)>0){g=0;do{B=f[z+(g<<2)>>2]|0;C=f[o>>2]|0;if((B|0)>(C|0)){D=f[q>>2]|0;f[D+(g<<2)>>2]=C;E=D}else{D=f[r>>2]|0;C=f[q>>2]|0;f[C+(g<<2)>>2]=(B|0)<(D|0)?D:B;E=C}g=g+1|0}while((g|0)<(f[l>>2]|0));F=E}else F=f[q>>2]|0;g=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);return 0}function ce(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}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I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=4194304;if(d){d=c;c=4194304;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<20)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Mf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function fe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))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0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<19)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Nf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function ie(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;_c(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|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h>>2]|0;if(!l){k=i;break a}m=f[l+4>>2]|0;if(!((m|0)==(c|0)|(m&g|0)==(i|0))){k=i;break a}if((f[l+8>>2]|0)==(c|0)){o=l;break}else h=l}p=o+12|0;return p|0}else q=j;while(1){h=f[q>>2]|0;if(!h){k=i;break a}g=f[h+4>>2]|0;if((g|0)!=(c|0)){if(g>>>0>>0)r=g;else r=(g>>>0)%(d>>>0)|0;if((r|0)!=(i|0)){k=i;break a}}if((f[h+8>>2]|0)==(c|0)){o=h;break}else q=h}p=o+12|0;return p|0}}else k=0;while(0);q=ln(16)|0;f[q+8>>2]=c;f[q+12>>2]=0;f[q+4>>2]=c;f[q>>2]=0;i=a+12|0;s=$(((f[i>>2]|0)+1|0)>>>0);t=$(d>>>0);u=$(n[a+16>>2]);do if(e|$(u*t)>>0<3|(d+-1&d|0)!=0)&1;j=~~$(W($(s/u)))>>>0;Hi(a,r>>>0>>0?j:r);r=f[b>>2]|0;j=r+-1|0;if(!(j&r)){v=r;w=j&c;break}if(c>>>0>>0){v=r;w=c}else{v=r;w=(c>>>0)%(r>>>0)|0}}else{v=d;w=k}while(0);k=(f[a>>2]|0)+(w<<2)|0;w=f[k>>2]|0;if(!w){d=a+8|0;f[q>>2]=f[d>>2];f[d>>2]=q;f[k>>2]=d;d=f[q>>2]|0;if(d|0){k=f[d+4>>2]|0;d=v+-1|0;if(d&v)if(k>>>0>>0)x=k;else x=(k>>>0)%(v>>>0)|0;else x=k&d;y=(f[a>>2]|0)+(x<<2)|0;z=30}}else{f[q>>2]=f[w>>2];y=w;z=30}if((z|0)==30)f[y>>2]=q;f[i>>2]=(f[i>>2]|0)+1;o=q;p=o+12|0;return p|0}function ke(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h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]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<15)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Sf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function me(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;bd(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=32768;if(d){d=c;c=32768;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<13)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Uf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function ne(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;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f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function qe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=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else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function te(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;id(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function ue(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l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}if(t>>>0>=i>>>0){u=c;return 1}i=k+(t*12|0)|0;if((i|0)==(v|0)){u=c;return 1}else w=v;while(1){v=w+-12|0;f[h>>2]=v;t=f[v>>2]|0;if(!t)x=v;else{v=w+-8|0;k=f[v>>2]|0;if((k|0)!=(t|0))f[v>>2]=k+(~((k+-4-t|0)>>>2)<<2);Oq(t);x=f[h>>2]|0}if((x|0)==(i|0))break;else w=x}u=c;return 1}function we(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=f[b>>2]|0;g=f[b+4>>2]|0;h=((f[c>>2]|0)-e<<3)+(f[c+4>>2]|0)-g|0;c=e;if((h|0)<=0){i=d+4|0;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[i>>2]|0;f[k>>2]=l;return}if(!g){e=d+4|0;m=h;n=e;o=f[e>>2]|0;p=c}else{e=32-g|0;q=(h|0)<(e|0)?h:e;r=-1>>>(e-q|0)&-1<>2];e=d+4|0;s=f[e>>2]|0;t=32-s|0;u=t>>>0>>0?t:q;v=f[d>>2]|0;w=f[v>>2]&~(-1>>>(t-u|0)&-1<>2]=w;s=f[e>>2]|0;f[v>>2]=(s>>>0>g>>>0?r<>>(g-s|0))|w;w=(f[e>>2]|0)+u|0;s=v+(w>>>5<<2)|0;f[d>>2]=s;v=w&31;f[e>>2]=v;w=q-u|0;if((w|0)>0){f[s>>2]=f[s>>2]&~(-1>>>(32-w|0))|r>>>(g+u|0);f[e>>2]=w;x=w}else x=v;v=c+4|0;f[b>>2]=v;m=h-q|0;n=e;o=x;p=v}v=32-o|0;x=-1<31){o=~x;e=f[d>>2]|0;q=~m;h=m+((q|0)>-64?q:-64)+32|0;q=(h>>>5)+1|0;c=m+-32-(h&-32)|0;h=m;w=p;u=f[e>>2]|0;g=e;while(1){r=f[w>>2]|0;s=u&o;f[g>>2]=s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+(c<<2)>>2]&255;b[h>>0]=j;c=a+4|0;k=f[(f[c>>2]|0)+44>>2]|0;l=k+16|0;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0)n=j;else{f[g>>2]=f[k+4>>2];f[e>>2]=f[g>>2];Me(k,e,h,h+1|0)|0;n=b[h>>0]|0}a:do if(n<<24>>24>-1){k=a+172|0;j=f[(f[k>>2]|0)+((n<<24>>24)*136|0)>>2]|0;l=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;m=b[h>>0]|0;o=f[k>>2]|0;k=f[o+(m*136|0)+132>>2]|0;switch(f[(f[(f[l>>2]|0)+84>>2]|0)+(j<<2)>>2]|0){case 0:{p=k;q=7;break a;break}case 1:{if(b[o+(m*136|0)+28>>0]|0){p=k;q=7;break a}break}default:{}}m=f[(f[c>>2]|0)+44>>2]|0;b[i>>0]=1;o=m+16|0;j=f[o+4>>2]|0;if(!((j|0)>0|(j|0)==0&(f[o>>2]|0)>>>0>0)){f[g>>2]=f[m+4>>2];f[e>>2]=f[g>>2];Me(m,e,i,i+1|0)|0}r=k}else{p=f[a+68>>2]|0;q=7}while(0);if((q|0)==7){q=f[(f[c>>2]|0)+44>>2]|0;b[i>>0]=0;a=q+16|0;h=f[a+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[a>>2]|0)>>>0>0)){f[g>>2]=f[q+4>>2];f[e>>2]=f[g>>2];Me(q,e,i,i+1|0)|0}r=p}p=f[(f[c>>2]|0)+44>>2]|0;b[i>>0]=r;r=p+16|0;c=f[r+4>>2]|0;if((c|0)>0|(c|0)==0&(f[r>>2]|0)>>>0>0){u=d;return 1}f[g>>2]=f[p+4>>2];f[e>>2]=f[g>>2];Me(p,e,i,i+1|0)|0;u=d;return 1}function ze(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;k=a+60|0;f[a+64>>2]=g;g=a+8|0;Mh(g,b,d,e);d=a+56|0;l=f[d>>2]|0;m=f[l+4>>2]|0;n=f[l>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+68|0;q=a+16|0;r=a+32|0;s=a+12|0;t=a+28|0;v=a+20|0;w=a+24|0;if(m-n>>2>>>0>p>>>0){x=p;y=n}else{z=l;aq(z)}while(1){f[j>>2]=f[y+(x<<2)>>2];f[i>>2]=f[j>>2];ub(k,i,b,x);l=X(x,e)|0;n=b+(l<<2)|0;p=c+(l<<2)|0;l=f[g>>2]|0;if((l|0)>0){m=0;a=o;A=l;while(1){if((A|0)>0){l=0;do{B=f[a+(l<<2)>>2]|0;C=f[q>>2]|0;if((B|0)>(C|0)){D=f[r>>2]|0;f[D+(l<<2)>>2]=C;E=D}else{D=f[s>>2]|0;C=f[r>>2]|0;f[C+(l<<2)>>2]=(B|0)<(D|0)?D:B;E=C}l=l+1|0}while((l|0)<(f[g>>2]|0));F=E}else F=f[r>>2]|0;l=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=l;if((l|0)>=(f[t>>2]|0)){if((l|0)>(f[w>>2]|0)){G=l-(f[v>>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Ae(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;k=a+60|0;f[a+64>>2]=g;g=a+8|0;Mh(g,b,d,e);d=a+56|0;l=f[d>>2]|0;m=f[l+4>>2]|0;n=f[l>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+68|0;q=a+16|0;r=a+32|0;s=a+12|0;t=a+28|0;v=a+20|0;w=a+24|0;if(m-n>>2>>>0>p>>>0){x=p;y=n}else{z=l;aq(z)}while(1){f[j>>2]=f[y+(x<<2)>>2];f[i>>2]=f[j>>2];tb(k,i,b,x);l=X(x,e)|0;n=b+(l<<2)|0;p=c+(l<<2)|0;l=f[g>>2]|0;if((l|0)>0){m=0;a=o;A=l;while(1){if((A|0)>0){l=0;do{B=f[a+(l<<2)>>2]|0;C=f[q>>2]|0;if((B|0)>(C|0)){D=f[r>>2]|0;f[D+(l<<2)>>2]=C;E=D}else{D=f[s>>2]|0;C=f[r>>2]|0;f[C+(l<<2)>>2]=(B|0)<(D|0)?D:B;E=C}l=l+1|0}while((l|0)<(f[g>>2]|0));F=E}else F=f[r>>2]|0;l=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=l;if((l|0)>=(f[t>>2]|0)){if((l|0)>(f[w>>2]|0)){G=l-(f[v>>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Be(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+12|0;g=f[e>>2]|0;h=(f[g+4>>2]|0)-(f[g>>2]|0)>>2;if(!h){u=b;return 1}i=a+152|0;j=a+140|0;k=a+144|0;l=a+148|0;a=0;m=g;while(1){f[d>>2]=(a>>>0)/3|0;f[c>>2]=f[d>>2];if(!(_j(m,c)|0)?(g=f[e>>2]|0,(f[(f[g+12>>2]|0)+(a<<2)>>2]|0)==-1):0){n=a+1|0;o=((n>>>0)%3|0|0)==0?a+-2|0:n;if((o|0)==-1)p=-1;else p=f[(f[g>>2]|0)+(o<<2)>>2]|0;o=f[i>>2]|0;if((f[o+(p<<2)>>2]|0)==-1){g=f[k>>2]|0;n=f[l>>2]|0;if((g|0)==(n<<5|0)){if((g+1|0)<0){q=11;break}r=n<<6;n=g+32&-32;vi(j,g>>>0<1073741823?(r>>>0>>0?n:r):2147483647);s=f[k>>2]|0;t=f[i>>2]|0}else{s=g;t=o}f[k>>2]=s+1;o=(f[j>>2]|0)+(s>>>5<<2)|0;f[o>>2]=f[o>>2]&~(1<<(s&31));o=t+(p<<2)|0;if((f[o>>2]|0)==-1){r=a;n=o;while(1){f[n>>2]=g;o=r+1|0;a:do if((r|0)!=-1?(v=((o>>>0)%3|0|0)==0?r+-2|0:o,(v|0)!=-1):0){w=f[e>>2]|0;x=f[w+12>>2]|0;y=v;while(1){v=f[x+(y<<2)>>2]|0;if((v|0)==-1)break;z=v+1|0;A=((z>>>0)%3|0|0)==0?v+-2|0:z;if((A|0)==-1){B=-1;C=-1;break a}else y=A}x=y+1|0;A=((x>>>0)%3|0|0)==0?y+-2|0:x;if((A|0)==-1){B=y;C=-1}else{B=y;C=f[(f[w>>2]|0)+(A<<2)>>2]|0}}else{B=-1;C=-1}while(0);n=t+(C<<2)|0;if((f[n>>2]|0)!=-1)break;else r=B}}}}r=a+1|0;if(r>>>0>=h>>>0){q=3;break}a=r;m=f[e>>2]|0}if((q|0)==3){u=b;return 1}else if((q|0)==11)aq(j);return 0}function Ce(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+32|0;e=d+8|0;g=d;h=a+4|0;i=f[h>>2]|0;if(i>>>0>=b>>>0){f[h>>2]=b;u=d;return}j=a+8|0;k=f[j>>2]|0;l=k<<5;m=b-i|0;if(l>>>0>>0|i>>>0>(l-m|0)>>>0){f[e>>2]=0;n=e+4|0;f[n>>2]=0;o=e+8|0;f[o>>2]=0;if((b|0)<0)aq(a);p=k<<6;k=b+31&-32;vi(e,l>>>0<1073741823?(p>>>0>>0?k:p):2147483647);p=f[h>>2]|0;f[n>>2]=p+m;k=f[a>>2]|0;l=k;q=f[e>>2]|0;r=(l+(p>>>5<<2)-k<<3)+(p&31)|0;if((r|0)>0){p=r>>>5;im(q|0,k|0,p<<2|0)|0;k=r&31;r=q+(p<<2)|0;s=r;if(!k){t=0;v=s}else{w=-1>>>(32-k|0);f[r>>2]=f[r>>2]&~w|f[l+(p<<2)>>2]&w;t=k;v=s}}else{t=0;v=q}f[g>>2]=v;f[g+4>>2]=t;t=g;g=f[t>>2]|0;v=f[t+4>>2]|0;t=f[a>>2]|0;f[a>>2]=f[e>>2];f[e>>2]=t;e=f[h>>2]|0;f[h>>2]=f[n>>2];f[n>>2]=e;e=f[j>>2]|0;f[j>>2]=f[o>>2];f[o>>2]=e;if(t|0)Oq(t);x=g;y=v}else{v=(f[a>>2]|0)+(i>>>5<<2)|0;f[h>>2]=b;x=v;y=i&31}if(!m){u=d;return}i=(y|0)==0;v=x;if(c){if(i){z=m;A=x;B=v}else{c=32-y|0;b=c>>>0>m>>>0?m:c;f[v>>2]=f[v>>2]|-1>>>(c-b|0)&-1<>>5;sj(A|0,-1,c<<2|0)|0;A=z&31;z=B+(c<<2)|0;if(!A){u=d;return}f[z>>2]=f[z>>2]|-1>>>(32-A|0);u=d;return}else{if(i){C=m;D=x;E=v}else{x=32-y|0;i=x>>>0>m>>>0?m:x;f[v>>2]=f[v>>2]&~(-1>>>(x-i|0)&-1<>>5;sj(D|0,0,y<<2|0)|0;D=C&31;C=E+(y<<2)|0;if(!D){u=d;return}f[C>>2]=f[C>>2]&~(-1>>>(32-D|0));u=d;return}}function De(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;a=u;u=u+48|0;g=a+36|0;h=a+24|0;i=a+12|0;j=a;if(!c){k=0;u=a;return k|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(g);if(l>>>0<11){b[g+11>>0]=l;if(!l)m=g;else{n=g;o=7}}else{p=l+16&-16;q=ln(p)|0;f[g>>2]=q;f[g+8>>2]=p|-2147483648;f[g+4>>2]=l;n=q;o=7}if((o|0)==7){kh(n|0,d|0,l|0)|0;m=n}b[m+l>>0]=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(h);if(l>>>0<11){b[h+11>>0]=l;if(!l)r=h;else{s=h;o=13}}else{m=l+16&-16;n=ln(m)|0;f[h>>2]=n;f[h+8>>2]=m|-2147483648;f[h+4>>2]=l;s=n;o=13}if((o|0)==13){kh(s|0,e|0,l|0)|0;r=s}b[r+l>>0]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(i);if(l>>>0<11){b[i+11>>0]=l;if(!l)t=i;else{v=i;o=19}}else{r=l+16&-16;s=ln(r)|0;f[i>>2]=s;f[i+8>>2]=r|-2147483648;f[i+4>>2]=l;v=s;o=19}if((o|0)==19){kh(v|0,d|0,l|0)|0;t=v}b[t+l>>0]=0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(j);if(l>>>0<11){b[j+11>>0]=l;if(!l)w=j;else{x=j;o=25}}else{t=l+16&-16;v=ln(t)|0;f[j>>2]=v;f[j+8>>2]=t|-2147483648;f[j+4>>2]=l;x=v;o=25}if((o|0)==25){kh(x|0,e|0,l|0)|0;w=x}b[w+l>>0]=0;mn(c,i,j);if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);k=1;u=a;return k|0}function Ee(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;f[a>>2]=f[c>>2];d=c+4|0;f[a+4>>2]=f[d>>2];e=c+8|0;f[a+8>>2]=f[e>>2];g=c+12|0;f[a+12>>2]=f[g>>2];f[d>>2]=0;f[e>>2]=0;f[g>>2]=0;g=c+16|0;f[a+16>>2]=f[g>>2];e=c+20|0;f[a+20>>2]=f[e>>2];d=c+24|0;f[a+24>>2]=f[d>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;b[a+28>>0]=b[c+28>>0]|0;d=a+32|0;e=c+32|0;f[d>>2]=0;g=a+36|0;f[g>>2]=0;f[a+40>>2]=0;f[d>>2]=f[e>>2];d=c+36|0;f[g>>2]=f[d>>2];g=c+40|0;f[a+40>>2]=f[g>>2];f[g>>2]=0;f[d>>2]=0;f[e>>2]=0;e=a+44|0;d=c+44|0;f[e>>2]=0;g=a+48|0;f[g>>2]=0;f[a+52>>2]=0;f[e>>2]=f[d>>2];e=c+48|0;f[g>>2]=f[e>>2];g=c+52|0;f[a+52>>2]=f[g>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;d=a+56|0;e=c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ge(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/136|0)>>>0>=c>>>0){i=c;j=h;do{f[j>>2]=-1;Ok(j+4|0);b[j+100>>0]=1;k=j+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;j=(f[g>>2]|0)+136|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/136|0;h=j+c|0;if(h>>>0>31580641)aq(a);k=(e-i|0)/136|0;i=k<<1;e=k>>>0<15790320?(i>>>0>>0?h:i):31580641;do if(e)if(e>>>0>31580641){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*136|0)|0;break}else l=0;while(0);i=l+(j*136|0)|0;j=i;h=l+(e*136|0)|0;e=c;c=j;l=i;do{f[l>>2]=-1;Ok(l+4|0);b[l+100>>0]=1;k=l+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;l=c+136|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=f[g>>2]|0;if((l|0)==(e|0)){m=j;n=e;o=e}else{k=l;l=j;j=i;do{k=k+-136|0;Ee(j+-136|0,k);j=l+-136|0;l=j}while((k|0)!=(e|0));m=l;n=f[a>>2]|0;o=f[g>>2]|0}f[a>>2]=m;f[g>>2]=c;f[d>>2]=h;h=n;if((o|0)!=(h|0)){d=o;do{o=f[d+-20>>2]|0;if(o|0){c=d+-16|0;g=f[c>>2]|0;if((g|0)!=(o|0))f[c>>2]=g+(~((g+-4-o|0)>>>2)<<2);Oq(o)}o=f[d+-32>>2]|0;if(o|0){g=d+-28|0;c=f[g>>2]|0;if((c|0)!=(o|0))f[g>>2]=c+(~((c+-4-o|0)>>>2)<<2);Oq(o)}Mi(d+-132|0);d=d+-136|0}while((d|0)!=(h|0))}if(!n)return;Oq(n);return}function He(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=f[b>>2]|0;b=a+12|0;d=(c|0)==-1;e=c+1|0;do if(!d){g=((e>>>0)%3|0|0)==0?c+-2|0:e;if(!((c>>>0)%3|0)){h=g;i=c+2|0;break}else{h=g;i=c+-1|0;break}}else{h=-1;i=-1}while(0);e=d?-1:(c>>>0)/3|0;g=a+28|0;j=(f[g>>2]|0)+(e>>>5<<2)|0;f[j>>2]=1<<(e&31)|f[j>>2];j=a+172|0;e=a+176|0;k=a+280|0;if(((!d?(d=f[(f[(f[b>>2]|0)+12>>2]|0)+(c<<2)>>2]|0,(d|0)!=-1):0)?(a=(d>>>0)/3|0,(f[(f[g>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0):0)?(a=f[j>>2]|0,(f[e>>2]|0)!=(a|0)):0){d=c>>>5;l=1<<(c&31);c=0;m=a;do{a=(f[k>>2]|0)+(c<<5)|0;if(!(l&f[(f[m+(c*136|0)+4>>2]|0)+(d<<2)>>2]))fj(a,0);else fj(a,1);c=c+1|0;m=f[j>>2]|0}while(c>>>0<(((f[e>>2]|0)-m|0)/136|0)>>>0)}if((((h|0)!=-1?(m=f[(f[(f[b>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,(m|0)!=-1):0)?(c=(m>>>0)/3|0,(f[(f[g>>2]|0)+(c>>>5<<2)>>2]&1<<(c&31)|0)==0):0)?(c=f[j>>2]|0,(f[e>>2]|0)!=(c|0)):0){m=h>>>5;d=1<<(h&31);h=0;l=c;do{c=(f[k>>2]|0)+(h<<5)|0;if(!(d&f[(f[l+(h*136|0)+4>>2]|0)+(m<<2)>>2]))fj(c,0);else fj(c,1);h=h+1|0;l=f[j>>2]|0}while(h>>>0<(((f[e>>2]|0)-l|0)/136|0)>>>0)}if((i|0)==-1)return 1;l=f[(f[(f[b>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;if((l|0)==-1)return 1;b=(l>>>0)/3|0;if(f[(f[g>>2]|0)+(b>>>5<<2)>>2]&1<<(b&31)|0)return 1;b=f[j>>2]|0;if((f[e>>2]|0)==(b|0))return 1;g=i>>>5;l=1<<(i&31);i=0;h=b;do{b=(f[k>>2]|0)+(i<<5)|0;if(!(l&f[(f[h+(i*136|0)+4>>2]|0)+(g<<2)>>2]))fj(b,0);else fj(b,1);i=i+1|0;h=f[j>>2]|0}while(i>>>0<(((f[e>>2]|0)-h|0)/136|0)>>>0);return 1}function Ie(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+4|0;j=a+8|0;ci((f[j>>2]|0)-(f[i>>2]|0)>>2,c)|0;k=f[i>>2]|0;if((f[j>>2]|0)==(k|0)){u=d;return 1}l=a+32|0;a=c+16|0;m=c+4|0;n=h+1|0;o=h+1|0;p=h+1|0;q=h+1|0;r=0;s=k;do{k=f[(f[(f[l>>2]|0)+8>>2]|0)+(f[s+(r<<2)>>2]<<2)>>2]|0;b[h>>0]=f[k+56>>2];t=a;v=f[t>>2]|0;w=f[t+4>>2]|0;if((w|0)>0|(w|0)==0&v>>>0>0){x=w;y=v}else{f[g>>2]=f[m>>2];f[e>>2]=f[g>>2];Me(c,e,h,q)|0;v=a;x=f[v+4>>2]|0;y=f[v>>2]|0}b[h>>0]=f[k+28>>2];if((x|0)>0|(x|0)==0&y>>>0>0){z=x;A=y}else{f[g>>2]=f[m>>2];f[e>>2]=f[g>>2];Me(c,e,h,p)|0;v=a;z=f[v+4>>2]|0;A=f[v>>2]|0}b[h>>0]=b[k+24>>0]|0;if((z|0)>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>2]|0)+(k<<2)>>2]|0;else B=k;k=p;x=f[k>>2]|0;z=f[k+4>>2]|0;k=q;j=f[k>>2]|0;y=un(j|0,f[k+4>>2]|0,B|0,0)|0;k=Vn(y|0,I|0,x|0,z|0)|0;kh(g|0,(f[f[d>>2]>>2]|0)+k|0,j|0)|0;j=f[r>>2]|0;C=$(n[i>>2]);k=0;z=w;while(1){D=$(n[g+(k<<2)>>2]);E=$(D-$(n[j+(k<<2)>>2]));x=E<$(0.0);D=$(-E);F=$((x?D:E)/C);y=~~$(J($($(F*$(f[c>>2]|0))+$(.5))));f[a+(z<<2)>>2]=x?0-y|0:y;k=k+1|0;if((k|0)==(l|0))break;else z=z+1|0}v=v+1|0;if(v>>>0>=t>>>0)break;else w=w+l|0}Mq(g);u=h;return}function Ke(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;d=u;u=u+32|0;e=d+16|0;g=d+12|0;h=d+8|0;i=d+4|0;j=d;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;k=a+24|0;lp(k);if((a|0)!=(b|0)){f[h>>2]=f[b>>2];f[i>>2]=b+4;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(a,g,e)}l=b+24|0;if((k|0)!=(l|0)){f[h>>2]=f[l>>2];f[i>>2]=b+28;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k,g,e)}f[j>>2]=0;k=c+8|0;l=c+12|0;c=f[l>>2]|0;m=f[k>>2]|0;if((c-m|0)<=0){u=d;return}n=b+16|0;b=m;m=c;c=0;while(1){o=f[(f[b+(c<<2)>>2]|0)+56>>2]|0;p=f[n>>2]|0;if(p){q=n;r=p;a:while(1){p=r;while(1){if((f[p+16>>2]|0)>=(o|0))break;s=f[p+4>>2]|0;if(!s){t=q;break a}else p=s}r=f[p>>2]|0;if(!r){t=p;break}else q=p}if((t|0)!=(n|0)?(o|0)>=(f[t+16>>2]|0):0){q=t+20|0;r=Hd(a,j)|0;if((r|0)!=(q|0)){f[h>>2]=f[q>>2];f[i>>2]=t+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(r,g,e)}v=f[j>>2]|0;w=f[k>>2]|0;x=f[l>>2]|0}else{v=c;w=b;x=m}}else{v=c;w=b;x=m}c=v+1|0;f[j>>2]=c;if((c|0)>=(x-w>>2|0))break;else{b=w;m=x}}u=d;return}function Le(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+12|0;ci(f[i>>2]|0,c)|0;if(!(f[i>>2]|0)){j=1;u=d;return j|0}k=c+16|0;l=c+4|0;m=h+1|0;n=h+1|0;o=h+1|0;p=0;while(1){q=f[a>>2]|0;r=f[q+(p<<3)>>2]|0;if(r>>>0>63)if(r>>>0>16383)if(r>>>0>4194303){j=0;s=20;break}else{t=2;s=13}else{t=1;s=13}else if(!r){v=p+1|0;w=0;while(1){if(f[q+(v+w<<3)>>2]|0){x=w;break}y=w+1|0;if(y>>>0<63)w=y;else{x=y;break}}b[h>>0]=x<<2|3;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,o)|0}z=x+p|0}else{t=0;s=13}if((s|0)==13){s=0;b[h>>0]=t|r<<2;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}if(!t)z=p;else{w=0;do{w=w+1|0;b[h>>0]=r>>>((w<<3)+-2|0);v=k;q=f[v+4>>2]|0;if(!((q|0)>0|(q|0)==0&(f[v>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,m)|0}}while((w|0)<(t|0));z=p}}p=z+1|0;if(p>>>0>=(f[i>>2]|0)>>>0){j=1;s=20;break}}if((s|0)==20){u=d;return j|0}return 0}function Me(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;g=f[a>>2]|0;h=g;i=(f[c>>2]|0)-h|0;c=g+i|0;j=e-d|0;if((j|0)<=0){k=c;return k|0}l=a+8|0;m=f[l>>2]|0;n=a+4|0;o=f[n>>2]|0;p=o;if((j|0)<=(m-p|0)){q=p-c|0;if((j|0)>(q|0)){r=d+q|0;if((r|0)==(e|0))s=o;else{t=r;u=o;while(1){b[u>>0]=b[t>>0]|0;t=t+1|0;v=(f[n>>2]|0)+1|0;f[n>>2]=v;if((t|0)==(e|0)){s=v;break}else u=v}}if((q|0)>0){w=r;x=s}else{k=c;return k|0}}else{w=e;x=o}s=x-(c+j)|0;r=c+s|0;if(r>>>0>>0){q=r;r=x;do{b[r>>0]=b[q>>0]|0;q=q+1|0;r=(f[n>>2]|0)+1|0;f[n>>2]=r}while((q|0)!=(o|0))}if(s|0)im(x+(0-s)|0,c|0,s|0)|0;if((w|0)==(d|0)){k=c;return k|0}else{y=d;z=c}while(1){b[z>>0]=b[y>>0]|0;y=y+1|0;if((y|0)==(w|0)){k=c;break}else z=z+1|0}return k|0}z=p-h+j|0;if((z|0)<0)aq(a);j=m-h|0;h=j<<1;m=j>>>0<1073741823?(h>>>0>>0?z:h):2147483647;h=c;if(!m)A=0;else A=ln(m)|0;z=A+i|0;i=z;j=A+m|0;if((d|0)==(e|0)){B=i;C=g}else{g=d;d=i;i=z;do{b[i>>0]=b[g>>0]|0;i=d+1|0;d=i;g=g+1|0}while((g|0)!=(e|0));B=d;C=f[a>>2]|0}d=h-C|0;e=z+(0-d)|0;if((d|0)>0)kh(e|0,C|0,d|0)|0;d=(f[n>>2]|0)-h|0;if((d|0)>0){h=B;kh(h|0,c|0,d|0)|0;D=h+d|0;E=f[a>>2]|0}else{D=B;E=C}f[a>>2]=e;f[n>>2]=D;f[l>>2]=j;if(!E){k=z;return k|0}Oq(E);k=z;return k|0}function Ne(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+16|0;g=e;h=f[(f[c+4>>2]|0)+(d<<2)>>2]|0;d=f[c+28>>2]|0;c=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(h<<2)>>2]|0;switch(f[c+28>>2]|0){case 5:case 6:case 3:case 4:case 1:case 2:{i=ln(40)|0;zo(i);j=i;k=j;f[a>>2]=k;u=e;return}case 9:{l=3;break}default:{}}if((l|0)==3){i=f[d+48>>2]|0;d=ln(32)|0;f[g>>2]=d;f[g+8>>2]=-2147483616;f[g+4>>2]=17;m=d;n=14495;o=m+17|0;do{b[m>>0]=b[n>>0]|0;m=m+1|0;n=n+1|0}while((m|0)<(o|0));b[d+17>>0]=0;d=i+16|0;n=f[d>>2]|0;if(n){p=d;q=n;a:while(1){n=q;while(1){if((f[n+16>>2]|0)>=(h|0))break;r=f[n+4>>2]|0;if(!r){s=p;break a}else n=r}q=f[n>>2]|0;if(!q){s=n;break}else p=n}if(((s|0)!=(d|0)?(h|0)>=(f[s+16>>2]|0):0)?(h=s+20|0,(Jh(h,g)|0)!=0):0)t=Hk(h,g,-1)|0;else l=12}else l=12;if((l|0)==12)t=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((t|0)>0)if((f[c+56>>2]|0)==1){c=ln(48)|0;m=c;o=m+48|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(o|0));zo(c);f[c>>2]=2496;f[c+40>>2]=1168;f[c+44>>2]=-1;j=c;k=j;f[a>>2]=k;u=e;return}else{c=ln(64)|0;ym(c);j=c;k=j;f[a>>2]=k;u=e;return}}c=ln(36)|0;Hm(c);j=c;k=j;f[a>>2]=k;u=e;return}function Oe(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=(c|0)==(a|0);b[c+12>>0]=d&1;if(d)return;else e=c;while(1){g=e+8|0;h=f[g>>2]|0;c=h+12|0;if(b[c>>0]|0){i=23;break}j=h+8|0;k=f[j>>2]|0;d=f[k>>2]|0;if((d|0)==(h|0)){l=f[k+4>>2]|0;if(!l){i=7;break}m=l+12|0;if(!(b[m>>0]|0))n=m;else{i=7;break}}else{if(!d){i=16;break}m=d+12|0;if(!(b[m>>0]|0))n=m;else{i=16;break}}b[c>>0]=1;c=(k|0)==(a|0);b[k+12>>0]=c&1;b[n>>0]=1;if(c){i=23;break}else e=k}if((i|0)==7){if((f[h>>2]|0)==(e|0)){o=h;p=k}else{n=h+4|0;a=f[n>>2]|0;c=f[a>>2]|0;f[n>>2]=c;if(!c)q=k;else{f[c+8>>2]=h;q=f[j>>2]|0}f[a+8>>2]=q;q=f[j>>2]|0;f[((f[q>>2]|0)==(h|0)?q:q+4|0)>>2]=a;f[a>>2]=h;f[j>>2]=a;o=a;p=f[a+8>>2]|0}b[o+12>>0]=1;b[p+12>>0]=0;o=f[p>>2]|0;a=o+4|0;q=f[a>>2]|0;f[p>>2]=q;if(q|0)f[q+8>>2]=p;q=p+8|0;f[o+8>>2]=f[q>>2];c=f[q>>2]|0;f[((f[c>>2]|0)==(p|0)?c:c+4|0)>>2]=o;f[a>>2]=p;f[q>>2]=o;return}else if((i|0)==16){if((f[h>>2]|0)==(e|0)){o=e+4|0;q=f[o>>2]|0;f[h>>2]=q;if(!q)r=k;else{f[q+8>>2]=h;r=f[j>>2]|0}f[g>>2]=r;r=f[j>>2]|0;f[((f[r>>2]|0)==(h|0)?r:r+4|0)>>2]=e;f[o>>2]=h;f[j>>2]=e;s=e;t=f[e+8>>2]|0}else{s=h;t=k}b[s+12>>0]=1;b[t+12>>0]=0;s=t+4|0;k=f[s>>2]|0;h=f[k>>2]|0;f[s>>2]=h;if(h|0)f[h+8>>2]=t;h=t+8|0;f[k+8>>2]=f[h>>2];s=f[h>>2]|0;f[((f[s>>2]|0)==(t|0)?s:s+4|0)>>2]=k;f[k>>2]=t;f[h>>2]=k;return}else if((i|0)==23)return}function Pe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;d=f[b>>2]|0;b=a+12|0;e=(d|0)==-1;do if(e){g=1;h=-1;i=-1}else{j=d+(((d>>>0)%3|0|0)==0?2:-1)|0;if((j|0)!=-1){k=f[(f[b>>2]|0)+12>>2]|0;l=j;while(1){j=f[k+(l<<2)>>2]|0;if((j|0)==-1){m=0;n=l;break}o=j+1|0;l=((o>>>0)%3|0|0)==0?j+-2|0:o;if((l|0)==-1){m=1;n=-1;break}}if(e){g=m;h=-1;i=n;break}else{p=m;q=n}}else{p=1;q=-1}g=p;h=f[(f[f[b>>2]>>2]|0)+(d<<2)>>2]|0;i=q}while(0);if(c){c=(f[a+84>>2]|0)+(h>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(h&31);r=1}else r=0;c=f[(f[a+152>>2]|0)+(h<<2)>>2]|0;q=(f[a+140>>2]|0)+(c>>>5<<2)|0;f[q>>2]=f[q>>2]|1<<(c&31);if(!g){g=(((i>>>0)%3|0|0)==0?2:-1)+i|0;if((g|0)==-1){s=-1;t=i}else{s=f[(f[f[b>>2]>>2]|0)+(g<<2)>>2]|0;t=i}}else{s=-1;t=-1}if((s|0)==(h|0)){u=r;return u|0}i=f[a+84>>2]|0;a=r;r=s;s=t;while(1){t=i+(r>>>5<<2)|0;f[t>>2]=f[t>>2]|1<<(r&31);t=a+1|0;g=s+1|0;a:do if((s|0)!=-1?(c=((g>>>0)%3|0|0)==0?s+-2|0:g,(c|0)!=-1):0){q=f[b>>2]|0;d=f[q+12>>2]|0;p=c;while(1){c=f[d+(p<<2)>>2]|0;if((c|0)==-1)break;n=c+1|0;m=((n>>>0)%3|0|0)==0?c+-2|0:n;if((m|0)==-1){v=-1;w=-1;break a}else p=m}d=(((p>>>0)%3|0|0)==0?2:-1)+p|0;if((d|0)==-1){v=-1;w=p}else{v=f[(f[q>>2]|0)+(d<<2)>>2]|0;w=p}}else{v=-1;w=-1}while(0);if((v|0)==(h|0)){u=t;break}else{a=t;r=v;s=w}}return u|0}function Qe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa;g=u;u=u+16|0;h=g;i=b[d+24>>0]|0;j=i<<24>>24;Rh(a,c,e,j,0,d,1);k=f[a>>2]|0;a=(f[f[k>>2]>>2]|0)+(f[k+48>>2]|0)|0;k=f[c+4>>2]|0;Ap(h);Ko(h,$(n[c+20>>2]),(1<>>0>1073741823?-1:j<<2)|0;if(!e){Mq(k);u=g;return}l=d+68|0;m=d+48|0;o=d+40|0;p=c+8|0;c=h+4|0;q=(b[d+84>>0]|0)==0;if(i<<24>>24>0){r=0;s=0}else{i=0;do{if(q)t=f[(f[l>>2]|0)+(i<<2)>>2]|0;else t=i;v=m;w=f[v>>2]|0;x=f[v+4>>2]|0;v=o;y=f[v>>2]|0;z=un(y|0,f[v+4>>2]|0,t|0,0)|0;v=Vn(z|0,I|0,w|0,x|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+v|0,y|0)|0;i=i+1|0}while((i|0)!=(e|0));Mq(k);u=g;return}while(1){if(q)A=f[(f[l>>2]|0)+(s<<2)>>2]|0;else A=s;i=m;t=f[i>>2]|0;y=f[i+4>>2]|0;i=o;v=f[i>>2]|0;x=un(v|0,f[i+4>>2]|0,A|0,0)|0;i=Vn(x|0,I|0,t|0,y|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+i|0,v|0)|0;v=f[p>>2]|0;B=$(n[h>>2]);i=0;y=r;while(1){C=$(n[k+(i<<2)>>2]);D=$(C-$(n[v+(i<<2)>>2]));t=D<$(0.0);C=$(-D);E=$((t?C:D)/B);x=~~$(J($($(E*$(f[c>>2]|0))+$(.5))));f[a+(y<<2)>>2]=t?0-x|0:x;i=i+1|0;if((i|0)==(j|0))break;else y=y+1|0}s=s+1|0;if((s|0)==(e|0))break;else r=r+j|0}Mq(k);u=g;return}function Re(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;c=a+4|0;d=f[c>>2]|0;e=a+100|0;if(d>>>0<(f[e>>2]|0)>>>0){f[c>>2]=d+1;g=h[d>>0]|0}else g=Si(a)|0;switch(g|0){case 43:case 45:{d=(g|0)==45&1;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;j=h[i>>0]|0}else j=Si(a)|0;if((b|0)!=0&(j+-48|0)>>>0>9?(f[e>>2]|0)!=0:0){f[c>>2]=(f[c>>2]|0)+-1;k=d;l=j}else{k=d;l=j}break}default:{k=0;l=g}}if((l+-48|0)>>>0>9)if(!(f[e>>2]|0)){m=-2147483648;n=0}else{f[c>>2]=(f[c>>2]|0)+-1;m=-2147483648;n=0}else{g=0;j=l;while(1){g=j+-48+(g*10|0)|0;l=f[c>>2]|0;if(l>>>0<(f[e>>2]|0)>>>0){f[c>>2]=l+1;o=h[l>>0]|0}else o=Si(a)|0;if(!((o+-48|0)>>>0<10&(g|0)<214748364))break;else j=o}j=((g|0)<0)<<31>>31;if((o+-48|0)>>>0<10){l=o;d=g;b=j;while(1){i=un(d|0,b|0,10,0)|0;p=I;q=Vn(l|0,((l|0)<0)<<31>>31|0,-48,-1)|0;r=Vn(q|0,I|0,i|0,p|0)|0;p=I;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;s=h[i>>0]|0}else s=Si(a)|0;if((s+-48|0)>>>0<10&((p|0)<21474836|(p|0)==21474836&r>>>0<2061584302)){l=s;d=r;b=p}else{t=s;u=r;v=p;break}}}else{t=o;u=g;v=j}if((t+-48|0)>>>0<10)do{t=f[c>>2]|0;if(t>>>0<(f[e>>2]|0)>>>0){f[c>>2]=t+1;w=h[t>>0]|0}else w=Si(a)|0}while((w+-48|0)>>>0<10);if(f[e>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;c=(k|0)!=0;k=Xn(0,0,u|0,v|0)|0;m=c?I:v;n=c?k:u}I=m;return n|0}function Se(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;b=a+1176|0;c=f[b>>2]|0;if(c|0){d=a+1180|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+1164|0;b=f[g>>2]|0;if(b|0){j=a+1168|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+1152>>2]|0;if(l|0){g=a+1156|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1140>>2]|0;if(l|0){m=a+1144|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1128>>2]|0;if(!l){n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}g=a+1132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}function Te(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d;g=a+4|0;h=f[g>>2]|0;i=f[(f[a>>2]|0)+52>>2]|0;if(!h){if(!(Sa[i&31](a,c,0)|0)){j=0;u=d;return j|0}}else if(!(Sa[i&31](a,c,f[(f[h+4>>2]|0)+80>>2]|0)|0)){j=0;u=d;return j|0}if(!(b[a+28>>0]|0)){j=1;u=d;return j|0}h=f[a+8>>2]|0;i=f[a+32>>2]|0;a=f[h+80>>2]|0;f[e>>2]=0;k=e+4|0;f[k>>2]=0;f[e+8>>2]=0;do if(a)if(a>>>0>1073741823)aq(e);else{l=a<<2;m=ln(l)|0;f[e>>2]=m;n=m+(a<<2)|0;f[e+8>>2]=n;sj(m|0,0,l|0)|0;f[k>>2]=n;o=m;p=n;q=m;break}else{o=0;p=0;q=0}while(0);e=f[c+4>>2]|0;a=f[c>>2]|0;c=a;a:do if((e|0)!=(a|0)){m=e-a>>2;if(b[h+84>>0]|0){n=0;while(1){f[o+(f[c+(n<<2)>>2]<<2)>>2]=n;n=n+1|0;if(n>>>0>=m>>>0)break a}}n=f[h+68>>2]|0;l=0;do{f[o+(f[n+(f[c+(l<<2)>>2]<<2)>>2]<<2)>>2]=l;l=l+1|0}while(l>>>0>>0)}while(0);c=f[(f[(f[g>>2]|0)+4>>2]|0)+80>>2]|0;b:do if(c|0){g=f[i+68>>2]|0;if(b[h+84>>0]|0){a=0;while(1){f[g+(a<<2)>>2]=f[o+(a<<2)>>2];a=a+1|0;if(a>>>0>=c>>>0)break b}}a=f[h+68>>2]|0;e=0;do{f[g+(e<<2)>>2]=f[o+(f[a+(e<<2)>>2]<<2)>>2];e=e+1|0}while(e>>>0>>0)}while(0);if(o|0){if((p|0)!=(o|0))f[k>>2]=p+(~((p+-4-o|0)>>>2)<<2);Oq(q)}j=1;u=d;return j|0}function Ue(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;Oh(a+12|0);wn(a+1036|0);vo(a+1068|0);vo(a+1088|0);vo(a+1108|0);e=a+1128|0;f[e>>2]=0;g=a+1132|0;f[g>>2]=0;f[a+1136>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+1136>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+1140|0;f[g>>2]=0;e=a+1144|0;f[e>>2]=0;f[a+1148>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+1148>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+1152|0;f[g>>2]=0;e=a+1156|0;f[e>>2]=0;f[a+1160>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+1160>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8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l>>2]|0)+1,o>>>0>(f[m>>2]|0)>>>0):0){f[m>>2]=o;C=0.0}else C=0.0;else{D=+(x|0);C=+Zg(D)*D}x=(f[y>>2]|0)+1|0;f[y>>2]=x;D=+(x|0);E=+Zg(D)*D-C;p[a>>3]=+p[a>>3]+E;q=q+1|0;if((q|0)==(d|0))break;else{r=v;n=w}}}if(e){f[i>>2]=f[a>>2];f[i+4>>2]=f[a+4>>2];f[i+8>>2]=f[a+8>>2];f[i+12>>2]=f[a+12>>2];f[i+16>>2]=f[a+16>>2];u=g;return}if(!j){u=g;return}j=f[b>>2]|0;b=0;do{a=j+(f[c+(b<<2)>>2]<<2)|0;f[a>>2]=(f[a>>2]|0)+-1;b=b+1|0}while((b|0)!=(d|0));u=g;return}function We(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;f[a>>2]=e;break a;break}case 10:{e=(f[c>>2]|0)+(4-1)&~(4-1);d=f[e>>2]|0;f[c>>2]=e+4;e=a;f[e>>2]=d;f[e+4>>2]=((d|0)<0)<<31>>31;break a;break}case 11:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;d=a;f[d>>2]=e;f[d+4>>2]=0;break a;break}case 12:{d=(f[c>>2]|0)+(8-1)&~(8-1);e=d;g=f[e>>2]|0;h=f[e+4>>2]|0;f[c>>2]=d+8;d=a;f[d>>2]=g;f[d+4>>2]=h;break a;break}case 13:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&65535)<<16>>16;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 14:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&65535;f[h+4>>2]=0;break a;break}case 15:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&255)<<24>>24;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 16:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&255;f[h+4>>2]=0;break a;break}case 17:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}case 18:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}default:break a}while(0);while(0);return}function Xe(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+16|0;d=c+4|0;e=c;g=c+8|0;if(!(Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)){h=0;u=c;return h|0}i=a+44|0;j=f[i>>2]|0;k=a+8|0;l=a+12|0;m=f[l>>2]|0;n=f[k>>2]|0;b[g>>0]=(m-n|0)>>>2;o=j+16|0;p=f[o+4>>2]|0;if((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0){q=k;r=n;s=m}else{f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0;q=k;r=f[k>>2]|0;s=f[l>>2]|0}a:do if((r|0)!=(s|0)){l=a+4|0;k=r;while(1){g=f[k>>2]|0;k=k+4|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,a,f[l>>2]|0)|0)){h=0;break}if((k|0)==(s|0))break a}u=c;return h|0}while(0);if(!(xc(a)|0)){h=0;u=c;return h|0}s=a+32|0;r=f[s>>2]|0;k=a+36|0;l=f[k>>2]|0;b:do if((r|0)!=(l|0)){g=r;do{if(!(Ra[f[(f[a>>2]|0)+40>>2]&127](a,f[g>>2]|0)|0)){h=0;t=18;break}g=g+4|0}while((g|0)!=(l|0));if((t|0)==18){u=c;return h|0}g=f[s>>2]|0;d=f[k>>2]|0;if((g|0)!=(d|0)){j=g;while(1){g=f[(f[q>>2]|0)+(f[j>>2]<<2)>>2]|0;j=j+4|0;if(!(Ra[f[(f[g>>2]|0)+12>>2]&127](g,f[i>>2]|0)|0)){h=0;break}if((j|0)==(d|0))break b}u=c;return h|0}}while(0);h=Qa[f[(f[a>>2]|0)+44>>2]&127](a)|0;u=c;return h|0}function Ye(a,b){a=a|0;b=b|0;ld(a,b);ld(a+32|0,b);ld(a+64|0,b);ld(a+96|0,b);ld(a+128|0,b);ld(a+160|0,b);ld(a+192|0,b);ld(a+224|0,b);ld(a+256|0,b);ld(a+288|0,b);ld(a+320|0,b);ld(a+352|0,b);ld(a+384|0,b);ld(a+416|0,b);ld(a+448|0,b);ld(a+480|0,b);ld(a+512|0,b);ld(a+544|0,b);ld(a+576|0,b);ld(a+608|0,b);ld(a+640|0,b);ld(a+672|0,b);ld(a+704|0,b);ld(a+736|0,b);ld(a+768|0,b);ld(a+800|0,b);ld(a+832|0,b);ld(a+864|0,b);ld(a+896|0,b);ld(a+928|0,b);ld(a+960|0,b);ld(a+992|0,b);ld(a+1024|0,b);return}function Ze(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;c=u;u=u+32|0;d=c;e=a+4|0;g=f[a>>2]|0;h=(f[e>>2]|0)-g>>2;i=h+1|0;if(i>>>0>1073741823)aq(a);j=a+8|0;k=(f[j>>2]|0)-g|0;g=k>>1;l=k>>2>>>0<536870911?(g>>>0>>0?i:g):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(l)if(l>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}else{m=ln(l<<2)|0;break}else m=0;while(0);f[d>>2]=m;g=m+(h<<2)|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o+(p*12|0)>>2]=f[g>>2];f[o+(p*12|0)+4>>2]=f[c>>2];f[o+(p*12|0)+8>>2]=f[n>>2];p=p+1|0;if(p>>>0>=k>>>0)break a}}p=f[h+68>>2]|0;q=0;do{r=f[p+(f[m+(q*12|0)>>2]<<2)>>2]|0;f[g>>2]=r;s=f[p+(f[m+(q*12|0)+4>>2]<<2)>>2]|0;f[c>>2]=s;t=f[p+(f[m+(q*12|0)+8>>2]<<2)>>2]|0;f[n>>2]=t;f[o+(q*12|0)>>2]=r;f[o+(q*12|0)+4>>2]=s;f[o+(q*12|0)+8>>2]=t;q=q+1|0}while(q>>>0>>0)}while(0);Kj(a,e);a=f[e>>2]|0;if(a|0){e=f[l>>2]|0;if((e|0)!=(a|0))f[l>>2]=e+(~(((e+-12-a|0)>>>0)/12|0)*12|0);Oq(a)}u=d;return}function $e(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;wn(a+12|0);vo(a+44|0);vo(a+64|0);vo(a+84|0);e=a+104|0;f[e>>2]=0;g=a+108|0;f[g>>2]=0;f[a+112>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+112>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+116|0;f[g>>2]=0;e=a+120|0;f[e>>2]=0;f[a+124>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+124>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+128|0;f[g>>2]=0;e=a+132|0;f[e>>2]=0;f[a+136>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+136>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+140|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+152|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function af(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;vo(a+12|0);vo(a+32|0);vo(a+52|0);vo(a+72|0);e=a+92|0;f[e>>2]=0;g=a+96|0;f[g>>2]=0;f[a+100>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+100>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+104|0;f[g>>2]=0;e=a+108|0;f[e>>2]=0;f[a+112>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+112>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+116|0;f[g>>2]=0;e=a+120|0;f[e>>2]=0;f[a+124>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+124>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+128|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+140|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function bf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;d=ln(40)|0;e=d+16|0;pj(e,c);pj(d+28|0,c+12|0);c=a+4|0;g=f[c>>2]|0;do if(g){h=b[d+27>>0]|0;i=h<<24>>24<0;j=i?f[d+20>>2]|0:h&255;h=i?f[e>>2]|0:e;i=g;while(1){k=i+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[i+20>>2]|0:l&255;l=n>>>0>>0?n:j;if((l|0)!=0?(o=Vk(h,m?f[k>>2]|0:k,l)|0,(o|0)!=0):0)if((o|0)<0)p=7;else p=9;else if(j>>>0>>0)p=7;else p=9;if((p|0)==7){p=0;n=f[i>>2]|0;if(!n){p=8;break}else q=n}else if((p|0)==9){p=0;r=i+4|0;n=f[r>>2]|0;if(!n){p=11;break}else q=n}i=q}if((p|0)==8){s=i;t=i;break}else if((p|0)==11){s=i;t=r;break}}else{s=c;t=c}while(0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=s;f[t>>2]=d;s=f[f[a>>2]>>2]|0;if(!s){u=d;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}f[a>>2]=s;u=f[t>>2]|0;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}function cf(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3680;wi(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function df(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+140|0;c=f[b>>2]|0;if(c|0){d=a+144|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+128|0;b=f[g>>2]|0;if(b|0){j=a+132|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+116>>2]|0;if(l|0){g=a+120|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(l|0){m=a+108|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+92>>2]|0;if(!l){n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}g=a+96|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}function ef(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+152|0;c=f[b>>2]|0;if(c|0){d=a+156|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+140|0;b=f[g>>2]|0;if(b|0){j=a+144|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+128>>2]|0;if(l|0){g=a+132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+116>>2]|0;if(l|0){m=a+120|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(!l){n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}g=a+108|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}function ff(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3480;uj(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function gf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=u;u=u+144|0;g=e+136|0;h=e+104|0;i=e;j=ln(124)|0;k=f[c+8>>2]|0;f[j+4>>2]=0;f[j>>2]=3656;f[j+12>>2]=3636;f[j+100>>2]=0;f[j+104>>2]=0;f[j+108>>2]=0;l=j+16|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));f[j+112>>2]=k;f[j+116>>2]=d;n=j+120|0;f[n>>2]=0;o=j;f[h>>2]=3636;p=h+4|0;q=p+4|0;f[q>>2]=0;f[q+4>>2]=0;f[q+8>>2]=0;f[q+12>>2]=0;f[q+16>>2]=0;f[q+20>>2]=0;q=f[c+12>>2]|0;f[i+4>>2]=3636;f[i+92>>2]=0;f[i+96>>2]=0;f[i+100>>2]=0;l=i+8|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));l=q;f[p>>2]=l;m=((f[l+4>>2]|0)-(f[q>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;qh(h+8|0,m,g);Va[f[(f[h>>2]|0)+8>>2]&127](h);f[i>>2]=f[p>>2];fg(i+4|0,h)|0;f[i+36>>2]=q;f[i+40>>2]=d;f[i+44>>2]=k;f[i+48>>2]=j;f[n>>2]=c+72;Sg(j,i);f[a>>2]=o;Qi(i);f[h>>2]=3636;i=f[h+20>>2]|0;if(i|0)Oq(i);i=f[h+8>>2]|0;if(!i){u=e;return}Oq(i);u=e;return}function hf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+48|0;d=c+44|0;e=c+40|0;g=c+36|0;h=c+32|0;i=c;f[h>>2]=f[a+60>>2];j=b+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,h,h+4|0)|0}wn(i);tk(i);if((f[h>>2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;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function lf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=f[c>>2]|0;c=f[d>>2]|0;e=f[a+4>>2]|0;g=f[d+4>>2]|0;h=e+-1|0;i=(h&e|0)==0;if(!i)if(g>>>0>>0)j=g;else j=(g>>>0)%(e>>>0)|0;else j=h&g;g=(f[a>>2]|0)+(j<<2)|0;k=f[g>>2]|0;while(1){l=f[k>>2]|0;if((l|0)==(d|0))break;else k=l}if((k|0)!=(a+8|0)){l=f[k+4>>2]|0;if(!i)if(l>>>0>>0)m=l;else m=(l>>>0)%(e>>>0)|0;else m=l&h;if((m|0)==(j|0)){n=c;o=21}else o=13}else o=13;do if((o|0)==13){if(c|0){m=f[c+4>>2]|0;if(!i)if(m>>>0>>0)p=m;else p=(m>>>0)%(e>>>0)|0;else p=m&h;if((p|0)==(j|0)){q=c;r=c;o=22;break}}f[g>>2]=0;n=f[d>>2]|0;o=21}while(0);if((o|0)==21){g=n;if(!n)s=g;else{q=n;r=g;o=22}}if((o|0)==22){o=f[q+4>>2]|0;if(!i)if(o>>>0>>0)t=o;else t=(o>>>0)%(e>>>0)|0;else t=o&h;if((t|0)==(j|0))s=r;else{f[(f[a>>2]|0)+(t<<2)>>2]=k;s=f[d>>2]|0}}f[k>>2]=s;f[d>>2]=0;s=a+12|0;f[s>>2]=(f[s>>2]|0)+-1;if(!d)return c|0;s=d+8|0;a=f[d+20>>2]|0;if(a|0){k=d+24|0;if((f[k>>2]|0)!=(a|0))f[k>>2]=a;Oq(a)}if((b[s+11>>0]|0)<0)Oq(f[s>>2]|0);Oq(d);return c|0}function mf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=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<=-1){A=5;break}n=f[m>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function qf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>3>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>3;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){o=c;p=f[o+4>>2]|0;q=m;f[q>>2]=f[o>>2];f[q+4>>2]=p;j=j+-1|0;if(!j)break;else m=m+8|0}}if(!l){m=h+(b<<3)|0;if((m|0)==(n|0))return;else{r=i;s=n+(~((n+-8-m|0)>>>3)<<3)|0;break}}else{m=b-k|0;j=m;p=n;while(1){q=c;o=f[q+4>>2]|0;t=p;f[t>>2]=f[q>>2];f[t+4>>2]=o;j=j+-1|0;if(!j)break;else p=p+8|0}r=i;s=n+(m<<3)|0;break}}else{p=g;if(!g)u=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-8-g|0)>>>3)<<3);Oq(p);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;u=0}if(b>>>0>536870911)aq(a);j=u>>2;p=u>>3>>>0<268435455?(j>>>0>>0?b:j):536870911;if(p>>>0>536870911)aq(a);j=ln(p<<3)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(p<<3);p=b;l=j;while(1){o=c;t=f[o+4>>2]|0;q=l;f[q>>2]=f[o>>2];f[q+4>>2]=t;p=p+-1|0;if(!p)break;else l=l+8|0}r=k;s=j+(b<<3)|0}while(0);f[r>>2]=s;return}function rf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,g=0.0,h=0.0,i=0.0,j=0.0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;e=+$(n[b>>2]);g=+K(+e);h=+$(n[b+4>>2]);i=g+ +K(+h);g=+$(n[b+8>>2]);j=i+ +K(+g);b=j>1.0e-06;i=1.0/j;k=f[a+12>>2]|0;j=+(k|0);l=~~+J(+((b?i*e:1.0)*j+.5));m=~~+J(+((b?i*h:0.0)*j+.5));o=(l|0)>-1;p=k-(o?l:0-l|0)-((m|0)>-1?m:0-m|0)|0;l=(p|0)<0;q=(l?((m|0)>0?p:0-p|0):0)+m|0;m=l?0:p;p=(b?i*g:0.0)<0.0?0-m|0:m;do if(!o){if((q|0)<0)r=(p|0)>-1?p:0-p|0;else r=(f[a+8>>2]|0)-((p|0)>-1?p:0-p|0)|0;if((p|0)<0){s=(q|0)>-1?q:0-q|0;t=r;break}else{s=(f[a+8>>2]|0)-((q|0)>-1?q:0-q|0)|0;t=r;break}}else{s=k+p|0;t=k+q|0}while(0);q=(t|0)==0;p=(s|0)==0;r=f[a+8>>2]|0;if(!(s|t)){u=r;v=r;f[c>>2]=u;f[d>>2]=v;return}a=(r|0)==(s|0);if(q&a){u=s;v=s;f[c>>2]=u;f[d>>2]=v;return}o=(r|0)==(t|0);if(p&o){u=t;v=t;f[c>>2]=u;f[d>>2]=v;return}if(q&(k|0)<(s|0)){u=0;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(o&(k|0)>(s|0)){u=t;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(a&(k|0)>(t|0)){u=(k<<1)-t|0;v=s;f[c>>2]=u;f[d>>2]=v;return}if(!p){u=t;v=s;f[c>>2]=u;f[d>>2]=v;return}u=(k|0)<(t|0)?(k<<1)-t|0:t;v=0;f[c>>2]=u;f[d>>2]=v;return}function sf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12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f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];kb(a,i,h);Ye(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function uf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+32|0;d=c;e=a+8|0;g=f[e>>2]|0;h=a+4|0;i=f[h>>2]|0;j=i;if(g-i>>2>>>0>=b>>>0){sj(i|0,0,b<<2|0)|0;f[h>>2]=i+(b<<2);u=c;return}k=f[a>>2]|0;l=i-k>>2;m=l+b|0;n=k;if(m>>>0>1073741823)aq(a);o=g-k|0;p=o>>1;q=o>>2>>>0<536870911?(p>>>0>>0?m:p):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(q)if(q>>>0>1073741823){p=ra(8)|0;Oo(p,16035);f[p>>2]=7256;va(p|0,1112,110)}else{r=ln(q<<2)|0;break}else r=0;while(0);f[d>>2]=r;p=r+(l<<2)|0;l=d+8|0;m=d+4|0;f[m>>2]=p;o=r+(q<<2)|0;q=d+12|0;f[q>>2]=o;r=p+(b<<2)|0;sj(p|0,0,b<<2|0)|0;f[l>>2]=r;if((j|0)==(n|0)){s=p;t=q;v=l;w=k;x=r;y=i;z=o;A=g}else{g=j;j=p;do{g=g+-4|0;p=f[g>>2]|0;f[g>>2]=0;f[j+-4>>2]=p;j=(f[m>>2]|0)+-4|0;f[m>>2]=j}while((g|0)!=(n|0));s=j;t=q;v=l;w=f[a>>2]|0;x=f[l>>2]|0;y=f[h>>2]|0;z=f[q>>2]|0;A=f[e>>2]|0}f[a>>2]=s;f[m>>2]=w;f[h>>2]=x;f[v>>2]=y;f[e>>2]=z;f[t>>2]=A;f[d>>2]=w;ki(d);u=c;return}function vf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function wf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+112|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+116|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function xf(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=u;u=u+16|0;h=d;i=f[a+124>>2]|0;if(!i){u=d;return}j=i+-1|0;k=(j&i|0)==0;if(!k)if(i>>>0>g>>>0)l=g;else l=(g>>>0)%(i>>>0)|0;else l=j&g;m=f[(f[a+120>>2]|0)+(l<<2)>>2]|0;if(!m){u=d;return}n=f[m>>2]|0;if(!n){u=d;return}a:do if(k){m=n;while(1){o=f[m+4>>2]|0;p=(o|0)==(g|0);if(!(p|(o&j|0)==(l|0))){q=24;break}if(p?(f[m+8>>2]|0)==(g|0):0){r=m;break a}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}else{m=n;while(1){p=f[m+4>>2]|0;if((p|0)==(g|0)){if((f[m+8>>2]|0)==(g|0)){r=m;break a}}else{if(p>>>0>>0)s=p;else s=(p>>>0)%(i>>>0)|0;if((s|0)!=(l|0)){q=24;break}}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}while(0);q=f[r+12>>2]|0;if((q|0)==-1){u=d;return}f[h>>2]=q;f[h+4>>2]=c;b[h+8>>0]=e&1;e=a+112|0;c=f[e>>2]|0;if((c|0)==(f[a+116>>2]|0))yi(a+108|0,h);else{f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];f[c+8>>2]=f[h+8>>2];f[e>>2]=(f[e>>2]|0)+12}u=d;return}function yf(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=d[b>>1]|0;e=d[b+2>>1]|0;g=d[b+4>>1]|0;h=d[b+6>>1]|0;b=((((c^318)&65535)+239^e&65535)+239^g&65535)+239^h&65535;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(b>>>0>>0)m=b;else m=(b>>>0)%(i>>>0)|0;else m=b&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(b|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(d[o>>1]|0)==c<<16>>16):0)?(d[o+2>>1]|0)==e<<16>>16:0)?(d[l+12>>1]|0)==g<<16>>16:0)?(d[o+6>>1]|0)==h<<16>>16:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(b|0)){l=q+8|0;if((((d[l>>1]|0)==c<<16>>16?(d[l+2>>1]|0)==e<<16>>16:0)?(d[q+12>>1]|0)==g<<16>>16:0)?(d[l+6>>1]|0)==h<<16>>16:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function zf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|0)|0;m=i}else m=i;if(!(f[d>>2]|0)){u=g;return 1}d=a+12|0;Mm(d);m=a+32|0;Mm(m);k=a+52|0;Mm(k);l=a+72|0;Mm(l);f[i>>2]=f[b>>2];f[i+4>>2]=f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];hb(a,i,h);Bg(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function Af(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|0)|0;m=i}else m=i;if(!(f[d>>2]|0)){u=g;return 1}d=a+12|0;tk(d);m=a+44|0;Mm(m);k=a+64|0;Mm(k);l=a+84|0;Mm(l);f[i>>2]=f[b>>2];f[i+4>>2]=f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];lb(a,i,h);ld(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function Bf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;a=u;u=u+16|0;e=a+4|0;g=a;h=a+8|0;i=d+11|0;j=b[i>>0]|0;k=j<<24>>24<0;if(k){l=f[d+4>>2]|0;if(l>>>0>255){m=0;u=a;return m|0}else n=l}else n=j&255;if(!n){b[h>>0]=0;n=c+16|0;l=f[n+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}m=1;u=a;return m|0}n=d+4|0;l=f[n>>2]|0;b[h>>0]=k?l:j&255;k=c+16|0;o=k;p=f[o>>2]|0;q=f[o+4>>2]|0;if((q|0)>0|(q|0)==0&p>>>0>0){r=j;s=q;t=p;v=l}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;h=k;r=b[i>>0]|0;s=f[h+4>>2]|0;t=f[h>>2]|0;v=f[n>>2]|0}n=r<<24>>24<0;h=n?f[d>>2]|0:d;if(!((s|0)>0|(s|0)==0&t>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+(n?v:r&255)|0)|0}m=1;u=a;return m|0}function Cf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+4|0;d=f[a>>2]|0;e=((f[c>>2]|0)-d|0)/24|0;g=e+1|0;if(g>>>0>178956970)aq(a);h=a+8|0;i=((f[h>>2]|0)-d|0)/24|0;d=i<<1;j=i>>>0<89478485?(d>>>0>>0?g:d):178956970;do if(j)if(j>>>0>178956970){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j*24|0)|0;break}else k=0;while(0);d=k+(e*24|0)|0;g=d;i=k+(j*24|0)|0;f[d>>2]=1196;f[k+(e*24|0)+4>>2]=f[b+4>>2];fk(k+(e*24|0)+8|0,b+8|0);f[k+(e*24|0)+20>>2]=f[b+20>>2];b=d+24|0;e=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(e|0)){l=g;m=e;n=e}else{j=k;k=g;g=d;do{f[g+-24>>2]=1196;f[g+-20>>2]=f[j+-20>>2];d=g+-16|0;o=j+-16|0;f[d>>2]=0;p=g+-12|0;f[p>>2]=0;f[g+-8>>2]=0;f[d>>2]=f[o>>2];d=j+-12|0;f[p>>2]=f[d>>2];p=j+-8|0;f[g+-8>>2]=f[p>>2];f[p>>2]=0;f[d>>2]=0;f[o>>2]=0;f[g+-4>>2]=f[j+-4>>2];j=j+-24|0;g=k+-24|0;k=g}while((j|0)!=(e|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=b;f[h>>2]=i;i=m;if((n|0)!=(i|0)){h=n;do{h=h+-24|0;Va[f[f[h>>2]>>2]&127](h)}while((h|0)!=(i|0))}if(!m)return;Oq(m);return}function Df(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+32|0;d=c+24|0;e=c+16|0;g=c+8|0;h=c;f[a>>2]=3588;f[a+4>>2]=f[b+4>>2];i=a+8|0;j=b+8|0;f[i>>2]=0;k=a+12|0;f[k>>2]=0;l=a+16|0;f[l>>2]=0;m=b+12|0;n=f[m>>2]|0;do if(n|0)if((n|0)<0)aq(i);else{o=((n+-1|0)>>>5)+1|0;p=ln(o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;f[g>>2]=o;f[g+4>>2]=0;p=f[m>>2]|0;f[h>>2]=o+(p>>>5<<2);f[h+4>>2]=p&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);break}while(0);i=a+20|0;f[i>>2]=0;m=a+24|0;f[m>>2]=0;j=a+28|0;f[j>>2]=0;a=b+24|0;l=f[a>>2]|0;if(!l){u=c;return}if((l|0)<0)aq(i);k=((l+-1|0)>>>5)+1|0;l=ln(k<<2)|0;f[i>>2]=l;f[m>>2]=0;f[j>>2]=k;k=f[b+20>>2]|0;f[g>>2]=k;f[g+4>>2]=0;b=f[a>>2]|0;f[h>>2]=k+(b>>>5<<2);f[h+4>>2]=b&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);u=c;return}function Ef(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;h=b[c+3>>0]|0;c=(((d&255^318)+239^e&255)+239^g&255)+239^h&255;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(c>>>0>>0)m=c;else m=(c>>>0)%(i>>>0)|0;else m=c&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(c|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(b[o>>0]|0)==d<<24>>24):0)?(b[o+1>>0]|0)==e<<24>>24:0)?(b[o+2>>0]|0)==g<<24>>24:0)?(b[o+3>>0]|0)==h<<24>>24:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(c|0)){l=q+8|0;if((((b[l>>0]|0)==d<<24>>24?(b[l+1>>0]|0)==e<<24>>24:0)?(b[l+2>>0]|0)==g<<24>>24:0)?(b[l+3>>0]|0)==h<<24>>24:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function Ff(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+32|0;d=c+24|0;e=c+16|0;g=c+8|0;h=c;f[a>>2]=3636;f[a+4>>2]=f[b+4>>2];i=a+8|0;j=b+8|0;f[i>>2]=0;k=a+12|0;f[k>>2]=0;l=a+16|0;f[l>>2]=0;m=b+12|0;n=f[m>>2]|0;do if(n|0)if((n|0)<0)aq(i);else{o=((n+-1|0)>>>5)+1|0;p=ln(o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;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,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Hf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;Cd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;Ad(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function If(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;d=u;u=u+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;l=a+40|0;f[a+44>>2]=g;g=a+36|0;m=f[g>>2]|0;n=f[m+4>>2]|0;o=f[m>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=a+48|0;s=a+52|0;a=i+4|0;t=j+4|0;v=h+4|0;if(n-o>>2>>>0>q>>>0){w=q;x=o}else{y=m;aq(y)}while(1){f[k>>2]=f[x+(w<<2)>>2];f[h>>2]=f[k>>2];tb(l,h,b,w);m=X(w,e)|0;o=b+(m<<2)|0;q=c+(m<<2)|0;m=f[o+4>>2]|0;n=f[r>>2]|0;z=f[s>>2]|0;f[i>>2]=f[o>>2];f[a>>2]=m;f[j>>2]=n;f[t>>2]=z;Od(h,p,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Jf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=f[b>>2]|0;b=f[c>>2]|0;e=b-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;k=b;if(e>>>0<=h-i>>2>>>0){l=a+4|0;m=(f[l>>2]|0)-i>>2;n=e>>>0>m>>>0;o=n?d+(m<<2)|0:b;b=o-d|0;m=b>>2;if(m|0)im(i|0,d|0,b|0)|0;b=j+(m<<2)|0;if(!n){n=f[l>>2]|0;if((n|0)==(b|0))return;f[l>>2]=n+(~((n+-4-b|0)>>>2)<<2);return}b=f[c>>2]|0;c=o;if((b|0)==(c|0))return;n=f[l>>2]|0;m=b+-4-o|0;o=c;c=n;while(1){f[c>>2]=f[o>>2];o=o+4|0;if((o|0)==(b|0))break;else c=c+4|0}f[l>>2]=n+((m>>>2)+1<<2);return}m=i;if(!i)p=h;else{h=a+4|0;n=f[h>>2]|0;if((n|0)!=(j|0))f[h>>2]=n+(~((n+-4-i|0)>>>2)<<2);Oq(m);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;p=0}if(e>>>0>1073741823)aq(a);h=p>>1;m=p>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(m>>>0>1073741823)aq(a);h=ln(m<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(m<<2);m=d;if((k|0)==(m|0))return;g=k+-4-d|0;d=m;m=h;while(1){f[m>>2]=f[d>>2];d=d+4|0;if((d|0)==(k|0))break;else m=m+4|0}f[e>>2]=h+((g>>>2)+1<<2);return}function Kf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(((d-g|0)/12|0)>>>0>=b>>>0){sj(g|0,0,b*12|0)|0;f[e>>2]=h+(b*12|0);return}i=f[a>>2]|0;j=(g-i|0)/12|0;g=j+b|0;k=i;if(g>>>0>357913941)aq(a);l=(d-i|0)/12|0;d=l<<1;m=l>>>0<178956970?(d>>>0>>0?g:d):357913941;do if(m)if(m>>>0>357913941){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m*12|0)|0;break}else n=0;while(0);d=n+(j*12|0)|0;j=d;g=n+(m*12|0)|0;sj(d|0,0,b*12|0)|0;m=d+(b*12|0)|0;if((h|0)==(k|0)){o=j;p=i;q=h}else{i=h;h=j;j=d;do{d=j+-12|0;b=i;i=i+-12|0;f[d>>2]=0;n=j+-8|0;f[n>>2]=0;f[j+-4>>2]=0;f[d>>2]=f[i>>2];d=b+-8|0;f[n>>2]=f[d>>2];n=b+-4|0;f[j+-4>>2]=f[n>>2];f[n>>2]=0;f[d>>2]=0;f[i>>2]=0;j=h+-12|0;h=j}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=g;g=p;if((q|0)!=(g|0)){c=q;do{q=c;c=c+-12|0;m=f[c>>2]|0;if(m|0){e=q+-8|0;q=f[e>>2]|0;if((q|0)!=(m|0))f[e>>2]=q+(~((q+-4-m|0)>>>2)<<2);Oq(m)}}while((c|0)!=(g|0))}if(!p)return;Oq(p);return}function Lf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+100|0;h=f[e>>2]|0;i=(f[h+28>>2]|0)-(f[h+24>>2]|0)>>2;f[c>>2]=0;h=a+104|0;j=f[h>>2]|0;k=f[g>>2]|0;l=j-k>>2;m=k;k=j;if(i>>>0<=l>>>0){if(i>>>0>>0?(j=m+(i<<2)|0,(j|0)!=(k|0)):0)f[h>>2]=k+(~((k+-4-j|0)>>>2)<<2)}else Ch(g,i-l|0,c);l=a+120|0;a=f[l>>2]|0;if(!a){i=f[e>>2]|0;g=(f[i+4>>2]|0)-(f[i>>2]|0)>>2;i=(g>>>0)/3|0;if(g>>>0<=2){u=b;return 1}g=0;do{f[d>>2]=g*3;f[c>>2]=f[d>>2];wb(e,c);g=g+1|0}while((g|0)<(i|0));u=b;return 1}else{i=f[a>>2]|0;if((f[a+4>>2]|0)==(i|0)){u=b;return 1}a=0;g=i;do{f[d>>2]=f[g+(a<<2)>>2];f[c>>2]=f[d>>2];wb(e,c);a=a+1|0;i=f[l>>2]|0;g=f[i>>2]|0}while(a>>>0<(f[i+4>>2]|0)-g>>2>>>0);u=b;return 1}return 0}function Mf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-4194304|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-4177920|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+4194304|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1077936128|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Nf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-2097152|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-2080768|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+6291456|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1075838976|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Of(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-1048576|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1032192|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+7340032|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074790400|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Pf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<1,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<1)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Qf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<2,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<2)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Rf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-262144|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-245760|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8126464|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074003968|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Sf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-131072|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-114688|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8257536|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073872896|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Tf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;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l>>2]|0)|0;m=j+8355840|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073774592|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Vf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;g=f[b+12>>2]|0;b=(((c^318)+239^d)+239^e)+239^g;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=25;break}if((((n?(f[k+8>>2]|0)==(c|0):0)?(f[k+12>>2]|0)==(d|0):0)?(f[k+16>>2]|0)==(e|0):0)?(f[k+20>>2]|0)==(g|0):0){i=k;o=25;break}k=f[k>>2]|0;if(!k){i=0;o=25;break}}if((o|0)==25)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){if((((f[p+8>>2]|0)==(c|0)?(f[p+12>>2]|0)==(d|0):0)?(f[p+16>>2]|0)==(e|0):0)?(f[p+20>>2]|0)==(g|0):0){i=p;o=25;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=25;break}}p=f[p>>2]|0;if(!p){i=0;o=25;break}}if((o|0)==25)return i|0;return 0}function Wf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+(X(d,g)|0)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Xf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;qd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;pd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function Yf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=f[d>>2]|0;g=f[d+4>>2]|0;if((e|0)==(g|0)){h=0;i=a+12|0;j=a+8|0}else{d=f[c>>2]|0;c=a+8|0;k=a+12|0;a=0;l=e;while(1){e=f[l>>2]|0;m=f[d+(e<<2)>>2]|0;if(m>>>0>>0)n=a;else{o=f[c>>2]|0;p=(f[k>>2]|0)-o|0;q=o;if((p|0)>0){o=p>>>2;p=0;do{r=f[q+(p<<2)>>2]|0;s=f[r+68>>2]|0;if(!(b[r+84>>0]|0))t=f[s+(e<<2)>>2]|0;else t=e;f[s+(m<<2)>>2]=t;p=p+1|0}while((p|0)<(o|0))}n=m+1|0}l=l+4|0;if((l|0)==(g|0)){h=n;i=k;j=c;break}else a=n}}n=f[i>>2]|0;a=f[j>>2]|0;if((n-a|0)>0){u=0;v=a;w=n}else return;while(1){n=f[v+(u<<2)>>2]|0;b[n+84>>0]=0;a=n+68|0;c=n+72|0;n=f[c>>2]|0;k=f[a>>2]|0;g=n-k>>2;l=k;k=n;if(h>>>0<=g>>>0)if(h>>>0>>0?(n=l+(h<<2)|0,(n|0)!=(k|0)):0){f[c>>2]=k+(~((k+-4-n|0)>>>2)<<2);x=v;y=w}else{x=v;y=w}else{Ch(a,h-g|0,6220);x=f[j>>2]|0;y=f[i>>2]|0}u=u+1|0;if((u|0)>=(y-x>>2|0))break;else{v=x;w=y}}return}function Zf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=((c+-4-o|0)>>>2)+1|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+(p<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=((c+-4-d|0)>>>2)+1|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+(p<<2);return}function _f(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-16384|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;b[m>>0]=j;b[m+1>>0]=j>>>8;n=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;o=j+8372224|0;b[m>>0]=o;b[m+1>>0]=o>>>8;b[m+2>>0]=o>>>16;n=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;o=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+-1073758208|0;b[o>>0]=m;b[o+1>>0]=m>>>8;b[o+2>>0]=m>>>16;b[o+3>>0]=m>>>24;n=(f[l>>2]|0)+4|0;break}else{n=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;n=(f[l>>2]|0)+1|0}while(0);k=((n|0)<0)<<31>>31;Gn(e);yh(n,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,n|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,n|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function $f(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=c+-4-o|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+((p>>>2)+1<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=c+-4-d|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+((p>>>2)+1<<2);return}function ag(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0;g=u;u=u+80|0;h=g;i=g+64|0;Il(h);j=f[(f[a+8>>2]|0)+56>>2]|0;k=X(Vl(5)|0,d)|0;Jj(h,j,0,d&255,5,0,k,((k|0)<0)<<31>>31,0,0);k=ln(96)|0;tl(k,h);Bj(k,c)|0;f[i>>2]=k;gj(a,i);k=f[i>>2]|0;f[i>>2]=0;if(k|0){i=k+88|0;c=f[i>>2]|0;f[i>>2]=0;if(c|0){i=f[c+8>>2]|0;if(i|0){h=c+12|0;if((f[h>>2]|0)!=(i|0))f[h>>2]=i;Oq(i)}Oq(c)}c=f[k+68>>2]|0;if(c|0){i=k+72|0;h=f[i>>2]|0;if((h|0)!=(c|0))f[i>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=k+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){i=h+4|0;if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c)}Oq(h)}Oq(k)}if(!e){u=g;return}k=f[a+32>>2]|0;b[k+84>>0]=0;a=k+68|0;h=k+72|0;k=f[h>>2]|0;c=f[a>>2]|0;i=k-c>>2;d=k;if(i>>>0>>0){Ch(a,e-i|0,1532);u=g;return}if(i>>>0<=e>>>0){u=g;return}i=c+(e<<2)|0;if((i|0)==(d|0)){u=g;return}f[h>>2]=d+(~((d+-4-i|0)>>>2)<<2);u=g;return}function bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+16|0;d=c+4|0;e=c;g=a+4|0;h=f[g>>2]|0;i=a+8|0;j=f[i>>2]|0;if((j|0)==(h|0))k=h;else{l=j+(~((j+-4-h|0)>>>2)<<2)|0;f[i>>2]=l;k=l}l=a+16|0;h=f[l>>2]|0;j=a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(o=n+(i<<2)|0,(o|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-o|0)>>>2)<<2);p=e;q=g;r=k}else{p=e;q=g;r=k}else{Ci(a,i-m|0);m=f[b>>2]|0;p=f[h>>2]|0;q=m;r=m}if((p|0)!=(q|0)){q=f[a>>2]|0;m=(p-r|0)/12|0;p=0;do{h=p*3|0;f[q+(h<<2)>>2]=f[r+(p*12|0)>>2];f[q+(h+1<<2)>>2]=f[r+(p*12|0)+4>>2];f[q+(h+2<<2)>>2]=f[r+(p*12|0)+8>>2];p=p+1|0}while(p>>>0>>0)}f[d>>2]=-1;if(!(rc(a,d)|0)){s=0;u=c;return s|0}eb(a,f[d>>2]|0)|0;s=1;u=c;return s|0}function dg(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=d[b>>1]|0;e=d[b+2>>1]|0;g=d[b+4>>1]|0;b=(((c^318)&65535)+239^e&65535)+239^g&65535;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(d[n>>1]|0)==c<<16>>16):0)?(d[n+2>>1]|0)==e<<16>>16:0)?(d[k+12>>1]|0)==g<<16>>16:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){k=p+8|0;if(((d[k>>1]|0)==c<<16>>16?(d[k+2>>1]|0)==e<<16>>16:0)?(d[p+12>>1]|0)==g<<16>>16:0){i=p;o=23;break}}else{if(a>>>0>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=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f[a+4>>2]=f[b+4>>2];c=a+8|0;d=b+8|0;if((a|0)==(b|0))return a|0;e=b+12|0;g=f[e>>2]|0;if(!g)h=0;else{i=a+16|0;do if(g>>>0>f[i>>2]<<5>>>0){j=f[c>>2]|0;if(!j)k=g;else{Oq(j);f[c>>2]=0;f[i>>2]=0;f[a+12>>2]=0;k=f[e>>2]|0}if((k|0)<0)aq(c);else{j=((k+-1|0)>>>5)+1|0;l=ln(j<<2)|0;f[c>>2]=l;f[a+12>>2]=0;f[i>>2]=j;m=f[e>>2]|0;n=l;break}}else{m=g;n=f[c>>2]|0}while(0);im(n|0,f[d>>2]|0,((m+-1|0)>>>5<<2)+4|0)|0;h=f[e>>2]|0}f[a+12>>2]=h;h=a+20|0;e=b+20|0;m=b+24|0;b=f[m>>2]|0;if(!b)o=0;else{d=a+28|0;do if(b>>>0>f[d>>2]<<5>>>0){n=f[h>>2]|0;if(!n)p=b;else{Oq(n);f[h>>2]=0;f[d>>2]=0;f[a+24>>2]=0;p=f[m>>2]|0}if((p|0)<0)aq(h);else{n=((p+-1|0)>>>5)+1|0;c=ln(n<<2)|0;f[h>>2]=c;f[a+24>>2]=0;f[d>>2]=n;q=f[m>>2]|0;r=c;break}}else{q=b;r=f[h>>2]|0}while(0);im(r|0,f[e>>2]|0,((q+-1|0)>>>5<<2)+4|0)|0;o=f[m>>2]|0}f[a+24>>2]=o;return a|0}function gg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f[c>>2]=1;d=a+4|0;e=c+8|0;g=c+12|0;c=f[e>>2]|0;i=(f[g>>2]|0)-c|0;if(i>>>0<4294967292){Lk(e,i+4|0,0);j=f[e>>2]|0}else j=c;c=j+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[c>>0]=i;b[c+1>>0]=i>>8;b[c+2>>0]=i>>16;b[c+3>>0]=i>>24;i=a+8|0;c=a+12|0;d=f[i>>2]|0;if((f[c>>2]|0)!=(d|0)){j=0;k=d;do{d=k+(j<<2)|0;l=f[e>>2]|0;m=(f[g>>2]|0)-l|0;if(m>>>0<4294967292){Lk(e,m+4|0,0);n=f[e>>2]|0}else n=l;l=n+m|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;j=j+1|0;k=f[i>>2]|0}while(j>>>0<(f[c>>2]|0)-k>>2>>>0)}k=a+20|0;a=f[e>>2]|0;c=(f[g>>2]|0)-a|0;if(c>>>0<4294967292){Lk(e,c+4|0,0);o=f[e>>2]|0;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}else{o=a;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}}function hg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>2>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>2;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){f[m>>2]=f[c>>2];j=j+-1|0;if(!j)break;else m=m+4|0}}if(!l){m=h+(b<<2)|0;if((m|0)==(n|0))return;else{o=i;p=n+(~((n+-4-m|0)>>>2)<<2)|0;break}}else{m=b-k|0;j=m;q=n;while(1){f[q>>2]=f[c>>2];j=j+-1|0;if(!j)break;else q=q+4|0}o=i;p=n+(m<<2)|0;break}}else{q=g;if(!g)r=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(q);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;r=0}if(b>>>0>1073741823)aq(a);j=r>>1;q=r>>2>>>0<536870911?(j>>>0>>0?b:j):1073741823;if(q>>>0>1073741823)aq(a);j=ln(q<<2)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(q<<2);q=b;l=j;while(1){f[l>>2]=f[c>>2];q=q+-1|0;if(!q)break;else l=l+4|0}o=k;p=j+(b<<2)|0}while(0);f[o>>2]=p;return}function ig(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=jh(a,b,c,d,g)|0;i=f[e>>2]|0;j=f[d>>2]|0;k=f[g>>2]|0;g=f[k>>2]|0;l=(f[k+4>>2]|0)-g>>3;if(l>>>0<=i>>>0)aq(k);m=g;if(l>>>0<=j>>>0)aq(k);if((f[m+(i<<3)>>2]|0)>>>0>=(f[m+(j<<3)>>2]|0)>>>0){n=h;return n|0}f[d>>2]=i;f[e>>2]=j;j=f[d>>2]|0;e=f[c>>2]|0;if(l>>>0<=j>>>0)aq(k);if(l>>>0<=e>>>0)aq(k);if((f[m+(j<<3)>>2]|0)>>>0>=(f[m+(e<<3)>>2]|0)>>>0){n=h+1|0;return n|0}f[c>>2]=j;f[d>>2]=e;e=f[c>>2]|0;d=f[b>>2]|0;if(l>>>0<=e>>>0)aq(k);if(l>>>0<=d>>>0)aq(k);if((f[m+(e<<3)>>2]|0)>>>0>=(f[m+(d<<3)>>2]|0)>>>0){n=h+2|0;return n|0}f[b>>2]=e;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(l>>>0<=d>>>0)aq(k);if(l>>>0<=c>>>0)aq(k);if((f[m+(d<<3)>>2]|0)>>>0>=(f[m+(c<<3)>>2]|0)>>>0){n=h+3|0;return n|0}f[a>>2]=d;f[b>>2]=c;n=h+4|0;return n|0}function jg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;c=((d&255^318)+239^e&255)+239^g&255;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(c>>>0>>0)l=c;else l=(c>>>0)%(h>>>0)|0;else l=c&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(c|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(b[n>>0]|0)==d<<24>>24):0)?(b[n+1>>0]|0)==e<<24>>24:0)?(b[n+2>>0]|0)==g<<24>>24:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(c|0)){k=p+8|0;if(((b[k>>0]|0)==d<<24>>24?(b[k+1>>0]|0)==e<<24>>24:0)?(b[k+2>>0]|0)==g<<24>>24:0){i=p;o=23;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=23;break}}p=f[p>>2]|0;if(!p){i=0;o=23;break}}if((o|0)==23)return i|0;return 0}function kg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;b=u;u=u+16|0;c=b;d=a+36|0;e=a+4|0;g=a+8|0;h=(f[g>>2]|0)-(f[e>>2]|0)>>2;i=a+40|0;j=f[i>>2]|0;k=f[d>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0){if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){m=k;do{k=m+-4|0;f[i>>2]=k;n=f[k>>2]|0;f[k>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);m=f[i>>2]|0}while((m|0)!=(j|0))}}else Eg(d,h-l|0);if((f[g>>2]|0)==(f[e>>2]|0)){o=1;u=b;return o|0}l=a+52|0;h=a+48|0;j=0;while(1){Xa[f[(f[a>>2]|0)+56>>2]&15](c,a,j);m=(f[d>>2]|0)+(j<<2)|0;i=f[c>>2]|0;f[c>>2]=0;n=f[m>>2]|0;f[m>>2]=i;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[c>>2]|0;f[c>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[(f[d>>2]|0)+(j<<2)>>2]|0;if(!n){o=0;p=19;break}if(j>>>0<(f[l>>2]|0)>>>0?f[(f[h>>2]|0)+(j>>>5<<2)>>2]&1<<(j&31)|0:0)Bp(n);j=j+1|0;if(j>>>0>=(f[g>>2]|0)-(f[e>>2]|0)>>2>>>0){o=1;p=19;break}}if((p|0)==19){u=b;return o|0}return 0}function lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d+4|0;g=d;ci(f[c+12>>2]|0,b)|0;h=f[c+8>>2]|0;a:do if(h|0){i=b+16|0;j=b+4|0;k=h;while(1){l=k;if(!(Bf(0,b,l+8|0)|0)){m=0;break}n=l+20|0;o=(f[l+24>>2]|0)-(f[n>>2]|0)|0;ci(o,b)|0;l=f[n>>2]|0;n=i;p=f[n+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[j>>2];f[e>>2]=f[g>>2];Me(b,e,l,l+o|0)|0}k=f[k>>2]|0;if(!k)break a}u=d;return m|0}while(0);ci(f[c+32>>2]|0,b)|0;e=f[c+28>>2]|0;if(!e){m=1;u=d;return m|0}else q=e;while(1){e=q;if(!(Bf(0,b,e+8|0)|0)){m=0;r=10;break}lg(a,b,f[e+20>>2]|0)|0;q=f[q>>2]|0;if(!q){m=1;r=10;break}}if((r|0)==10){u=d;return m|0}return 0}function mg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+8|0;i=a+12|0;j=f[h>>2]|0;if((f[i>>2]|0)==(j|0)){k=ln(76)|0;vn(k,b);l=k;f[g>>2]=l;k=f[i>>2]|0;if(k>>>0<(f[a+16>>2]|0)>>>0){f[g>>2]=0;f[k>>2]=l;f[i>>2]=k+4;m=g}else{Qg(h,g);m=g}g=f[m>>2]|0;f[m>>2]=0;if(!g){u=c;return 1}Va[f[(f[g>>2]|0)+4>>2]&127](g);u=c;return 1}g=f[j>>2]|0;f[d>>2]=b;j=g+4|0;m=g+8|0;h=f[m>>2]|0;if((h|0)==(f[g+12>>2]|0))Ri(j,d);else{f[h>>2]=b;f[m>>2]=h+4}h=f[d>>2]|0;b=g+16|0;k=g+20|0;g=f[k>>2]|0;i=f[b>>2]|0;l=g-i>>2;a=i;if((h|0)<(l|0)){n=a;o=h}else{i=h+1|0;f[e>>2]=-1;p=g;if(i>>>0<=l>>>0)if(i>>>0>>0?(g=a+(i<<2)|0,(g|0)!=(p|0)):0){f[k>>2]=p+(~((p+-4-g|0)>>>2)<<2);q=h;r=a}else{q=h;r=a}else{Ch(b,i-l|0,e);q=f[d>>2]|0;r=f[b>>2]|0}n=r;o=q}f[n+(o<<2)>>2]=((f[m>>2]|0)-(f[j>>2]|0)>>2)+-1;u=c;return 1}function ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0>j-k>>2>>>0){m=k;if(!k)n=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(m);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;n=0}if(h>>>0>1073741823)aq(a);j=n>>1;m=n>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(m>>>0>1073741823)aq(a);j=ln(m<<2)|0;n=a+4|0;f[n>>2]=j;f[a>>2]=j;f[i>>2]=j+(m<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[n>>2]=j+(g>>>2<<2);return}g=a+4|0;a=f[g>>2]|0;j=a-k>>2;k=h>>>0>j>>>0;h=k?b+(j<<2)|0:c;c=a;j=a;if((h|0)==(b|0))p=l;else{a=h+-4-e|0;e=b;b=l;while(1){f[b>>2]=f[e>>2];e=e+4|0;if((e|0)==(h|0))break;else b=b+4|0}p=l+((a>>>2)+1<<2)|0}if(k){k=d-h|0;if((k|0)<=0)return;kh(j|0,h|0,k|0)|0;f[g>>2]=(f[g>>2]|0)+(k>>>2<<2);return}else{if((p|0)==(c|0))return;f[g>>2]=c+(~((c+-4-p|0)>>>2)<<2);return}}function og(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=c+68|0;c=f[o+96>>2]|0;o=f[d+28>>2]|0;d=f[(f[a+80>>2]|0)+12>>2]|0;a=0;while(1){h=a*3|0;i=f[d+(f[o+(h<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}g=f[m>>2]|0;f[g+(f[c+(a*12|0)>>2]<<2)>>2]=i;i=f[d+(f[o+(h+1<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+4>>2]<<2)>>2]=i;i=f[d+(f[o+(h+2<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+8>>2]<<2)>>2]=i;a=a+1|0;if(a>>>0>=e>>>0){q=1;r=10;break}}if((r|0)==10)return q|0;return 0}function pg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=u;u=u+16|0;g=e;if(!(xh(a,c,d)|0)){h=0;u=e;return h|0}if((b[(f[a+8>>2]|0)+24>>0]|0)!=3){h=0;u=e;return h|0}i=f[c+48>>2]|0;c=ln(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=17;j=c;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[c+17>>0]=0;c=i+16|0;k=f[c>>2]|0;if(k){j=c;l=k;a:while(1){k=l;while(1){if((f[k+16>>2]|0)>=(d|0))break;m=f[k+4>>2]|0;if(!m){n=j;break a}else k=m}l=f[k>>2]|0;if(!l){n=k;break}else j=k}if(((n|0)!=(c|0)?(f[n+16>>2]|0)<=(d|0):0)?(d=n+20|0,(Jh(d,g)|0)!=0):0)o=Hk(d,g,-1)|0;else p=12}else p=12;if((p|0)==12)o=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((o|0)<1){h=0;u=e;return h|0}ip(a+40|0,o);h=1;u=e;return h|0}function qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;b=((c^318)+239^d)+239^e;g=f[a+4>>2]|0;if(!g){h=0;return h|0}i=g+-1|0;j=(i&g|0)==0;if(!j)if(b>>>0>>0)k=b;else k=(b>>>0)%(g>>>0)|0;else k=b&i;l=f[(f[a>>2]|0)+(k<<2)>>2]|0;if(!l){h=0;return h|0}a=f[l>>2]|0;if(!a){h=0;return h|0}if(j){j=a;while(1){l=f[j+4>>2]|0;m=(l|0)==(b|0);if(!(m|(l&i|0)==(k|0))){h=0;n=23;break}if(((m?(f[j+8>>2]|0)==(c|0):0)?(f[j+12>>2]|0)==(d|0):0)?(f[j+16>>2]|0)==(e|0):0){h=j;n=23;break}j=f[j>>2]|0;if(!j){h=0;n=23;break}}if((n|0)==23)return h|0}else o=a;while(1){a=f[o+4>>2]|0;if((a|0)==(b|0)){if(((f[o+8>>2]|0)==(c|0)?(f[o+12>>2]|0)==(d|0):0)?(f[o+16>>2]|0)==(e|0):0){h=o;n=23;break}}else{if(a>>>0>>0)p=a;else p=(a>>>0)%(g>>>0)|0;if((p|0)!=(k|0)){h=0;n=23;break}}o=f[o>>2]|0;if(!o){h=0;n=23;break}}if((n|0)==23)return h|0;return 0}function rg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;Oq(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)aq(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)aq(a);i=ln(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;if((a|0)==(c|0))p=k;else{o=c;c=k;while(1){b[c>>0]=b[o>>0]|0;o=o+1|0;if((o|0)==(a|0))break;else c=c+1|0}p=k+(a-e)|0}if(!j){if((f[n>>2]|0)==(p|0))return;f[n>>2]=p;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}function sg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=c>>>1&1431655765|c<<1&-1431655766;c=d>>>2&858993459|d<<2&-858993460;d=c>>>4&252645135|c<<4&-252645136;c=d>>>8&16711935|d<<8&-16711936;d=32-b|0;e=(c>>>16|c<<16)>>>d;c=e-(e>>>1&1431655765)|0;g=(c>>>2&858993459)+(c&858993459)|0;c=(X((g>>>4)+g&252645135,16843009)|0)>>>24;g=b-c|0;h=f[a>>2]|0;i=h;j=Vn(f[i>>2]|0,f[i+4>>2]|0,g|0,((g|0)<0)<<31>>31|0)|0;g=h;f[g>>2]=j;f[g+4>>2]=I;g=h+8|0;h=g;j=Vn(f[h>>2]|0,f[h+4>>2]|0,c|0,0)|0;c=g;f[c>>2]=j;f[c+4>>2]=I;c=a+28|0;j=f[c>>2]|0;g=32-j|0;h=a+24|0;do if((g|0)>=(b|0)){i=-1>>>d<>2]&~i|i&e<>2]=k;i=j+b|0;f[c>>2]=i;if((i|0)!=32)return;i=a+16|0;l=f[i>>2]|0;if((l|0)==(f[a+20>>2]|0)){Ri(a+12|0,h);m=0;n=0;break}else{f[l>>2]=k;f[i>>2]=l+4;m=0;n=0;break}}else{l=-1>>>j<>2]&~l|l&e<>2]=i;l=a+16|0;k=f[l>>2]|0;if((k|0)==(f[a+20>>2]|0))Ri(a+12|0,h);else{f[k>>2]=i;f[l>>2]=k+4}k=b-g|0;m=k;n=-1>>>(32-k|0)&e>>>g}while(0);f[h>>2]=n;f[c>>2]=m;return}function tg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c&255;g=(d|0)!=0;a:do if(g&(a&3|0)!=0){h=c&255;i=a;j=d;while(1){if((b[i>>0]|0)==h<<24>>24){k=i;l=j;m=6;break a}n=i+1|0;o=j+-1|0;p=(o|0)!=0;if(p&(n&3|0)!=0){i=n;j=o}else{q=n;r=o;s=p;m=5;break}}}else{q=a;r=d;s=g;m=5}while(0);if((m|0)==5)if(s){k=q;l=r;m=6}else{t=q;u=0}b:do if((m|0)==6){q=c&255;if((b[k>>0]|0)==q<<24>>24){t=k;u=l}else{r=X(e,16843009)|0;c:do if(l>>>0>3){s=k;g=l;while(1){d=f[s>>2]^r;if((d&-2139062144^-2139062144)&d+-16843009|0)break;d=s+4|0;a=g+-4|0;if(a>>>0>3){s=d;g=a}else{v=d;w=a;m=11;break c}}x=s;y=g}else{v=k;w=l;m=11}while(0);if((m|0)==11)if(!w){t=v;u=0;break}else{x=v;y=w}while(1){if((b[x>>0]|0)==q<<24>>24){t=x;u=y;break b}r=x+1|0;y=y+-1|0;if(!y){t=r;u=0;break}else x=r}}}while(0);return (u|0?t:0)|0}function ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=e;do if((d|0)==(e|0)){h=a+8|0;i=f[h>>2]|0;j=a+12|0;k=f[j>>2]|0;l=k;if(i>>>0>>0){k=i;m=((l-k>>2)+1|0)/2|0;n=i+(m<<2)|0;o=k-d|0;k=o>>2;p=n+(0-k<<2)|0;if(!k){q=n;r=i}else{im(p|0,d|0,o|0)|0;q=p;r=f[h>>2]|0}f[c>>2]=q;f[h>>2]=r+(m<<2);s=q;break}m=l-g>>1;l=(m|0)==0?1:m;if(l>>>0>1073741823){m=ra(8)|0;Oo(m,16035);f[m>>2]=7256;va(m|0,1112,110)}m=ln(l<<2)|0;p=m;o=m+((l+3|0)>>>2<<2)|0;n=o;k=m+(l<<2)|0;if((d|0)==(i|0)){t=n;u=d}else{l=o;m=n;v=d;do{f[l>>2]=f[v>>2];l=m+4|0;m=l;v=v+4|0}while((v|0)!=(i|0));t=m;u=f[a>>2]|0}f[a>>2]=p;f[c>>2]=n;f[h>>2]=t;f[j>>2]=k;if(!u)s=o;else{Oq(u);s=f[c>>2]|0}}else s=d;while(0);f[s+-4>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+-4;return}function vg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+4|0;if((f[i>>2]|0)==-1){j=0;u=d;return j|0}k=f[a+8>>2]|0;l=c+16|0;m=l;n=f[m>>2]|0;o=f[m+4>>2]|0;if(!((o|0)>0|(o|0)==0&n>>>0>0)){m=(f[a+12>>2]|0)-k|0;p=c+4|0;f[g>>2]=f[p>>2];f[e>>2]=f[g>>2];Me(c,e,k,k+m|0)|0;m=l;k=f[m>>2]|0;q=f[m+4>>2]|0;m=a+20|0;if((q|0)>0|(q|0)==0&k>>>0>0){r=q;s=k;t=g}else{f[g>>2]=f[p>>2];f[e>>2]=f[g>>2];Me(c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12>>2]|0;if((f[h+(d<<2)>>2]|0)==-1){e=0;g=d;f[c>>2]=g;return e|0}i=f[b>>2]|0;b=f[a+152>>2]|0;if((f[b+(f[i+(d<<2)>>2]<<2)>>2]|0)==-1){a=d+1|0;j=((a>>>0)%3|0|0)==0?d+-2|0:a;if((j|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(j<<2)>>2]|0)==-1){e=0;g=j;f[c>>2]=g;return e|0}if((f[b+(f[i+(j<<2)>>2]<<2)>>2]|0)==-1){a=j+1|0;k=((a>>>0)%3|0|0)==0?j+-2|0:a;if((k|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(k<<2)>>2]|0)==-1){e=0;g=k;f[c>>2]=g;return e|0}if((f[b+(f[i+(k<<2)>>2]<<2)>>2]|0)==-1){i=k+1|0;e=1;g=((i>>>0)%3|0|0)==0?k+-2|0:i;f[c>>2]=g;return e|0}else l=k}else l=j}else l=d;while(1){d=(((l>>>0)%3|0|0)==0?2:-1)+l|0;if((d|0)==-1)break;j=f[h+(d<<2)>>2]|0;if((j|0)==-1)break;d=j+(((j>>>0)%3|0|0)==0?2:-1)|0;if((d|0)==-1)break;else l=d}e=0;g=(((l>>>0)%3|0|0)==0?2:-1)+l|0;f[c>>2]=g;return e|0}function yg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=a+4|0;g=f[e>>2]|0;if(!g){f[c>>2]=e;h=e;return h|0}e=b[d+11>>0]|0;i=e<<24>>24<0;j=i?f[d+4>>2]|0:e&255;e=i?f[d>>2]|0:d;d=a+4|0;a=g;while(1){g=a+16|0;i=b[g+11>>0]|0;k=i<<24>>24<0;l=k?f[a+20>>2]|0:i&255;i=l>>>0>>0;m=i?l:j;if((m|0)!=0?(n=Vk(e,k?f[g>>2]|0:g,m)|0,(n|0)!=0):0)if((n|0)<0)o=8;else o=10;else if(j>>>0>>0)o=8;else o=10;if((o|0)==8){o=0;n=f[a>>2]|0;if(!n){o=9;break}else{p=a;q=n}}else if((o|0)==10){o=0;n=j>>>0>>0?j:l;if((n|0)!=0?(l=Vk(k?f[g>>2]|0:g,e,n)|0,(l|0)!=0):0){if((l|0)>=0){o=16;break}}else o=12;if((o|0)==12?(o=0,!i):0){o=16;break}r=a+4|0;i=f[r>>2]|0;if(!i){o=15;break}else{p=r;q=i}}d=p;a=q}if((o|0)==9){f[c>>2]=a;h=a;return h|0}else if((o|0)==15){f[c>>2]=a;h=r;return h|0}else if((o|0)==16){f[c>>2]=a;h=d;return h|0}return 0}function zg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;d=u;u=u+32|0;e=d+24|0;g=d+16|0;h=d+8|0;i=d;j=a+4|0;k=f[j>>2]|0;l=f[b>>2]|0;m=f[b+4>>2]|0;b=f[c>>2]|0;n=f[c+4>>2]|0;c=b-l<<3;f[j>>2]=k-m+n+c;j=(f[a>>2]|0)+(k>>>5<<2)|0;a=k&31;k=j;if((m|0)!=(a|0)){f[e>>2]=l;f[e+4>>2]=m;f[g>>2]=b;f[g+4>>2]=n;f[h>>2]=k;f[h+4>>2]=a;xe(i,e,g,h);u=d;return}h=n-m+c|0;c=l;if((h|0)>0){if(!m){o=h;p=j;q=0;r=l;s=c}else{l=32-m|0;n=(h|0)<(l|0)?h:l;g=-1>>>(l-n|0)&-1<>2]=f[j>>2]&~g|f[c>>2]&g;g=n+m|0;l=c+4|0;o=h-n|0;p=j+(g>>>5<<2)|0;q=g&31;r=l;s=l}l=(o|0)/32|0;im(p|0,r|0,l<<2|0)|0;r=o-(l<<5)|0;o=p+(l<<2)|0;p=o;if((r|0)>0){g=-1>>>(32-r|0);f[o>>2]=f[o>>2]&~g|f[s+(l<<2)>>2]&g;t=r;v=p}else{t=q;v=p}}else{t=m;v=k}f[i>>2]=v;f[i+4>>2]=t;u=d;return}function Ag(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;c=a+8|0;d=f[c>>2]|0;e=a+12|0;g=f[e>>2]|0;h=g;do if((d|0)==(g|0)){i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(j>>>0>k>>>0){m=j;n=((m-l>>2)+1|0)/-2|0;o=j+(n<<2)|0;p=d-m|0;m=p>>2;if(!m)q=j;else{im(o|0,j|0,p|0)|0;q=f[i>>2]|0}p=o+(m<<2)|0;f[c>>2]=p;f[i>>2]=q+(n<<2);r=p;break}p=h-l>>1;l=(p|0)==0?1:p;if(l>>>0>1073741823){p=ra(8)|0;Oo(p,16035);f[p>>2]=7256;va(p|0,1112,110)}p=ln(l<<2)|0;n=p;m=p+(l>>>2<<2)|0;o=m;s=p+(l<<2)|0;if((j|0)==(d|0)){t=o;u=k}else{k=m;m=o;l=j;do{f[k>>2]=f[l>>2];k=m+4|0;m=k;l=l+4|0}while((l|0)!=(d|0));t=m;u=f[a>>2]|0}f[a>>2]=n;f[i>>2]=o;f[c>>2]=t;f[e>>2]=s;if(!u)r=t;else{Oq(u);r=f[c>>2]|0}}else r=d;while(0);f[r>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+4;return}function Bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+12|0;i=a+4|0;j=f[i>>2]|0;if((j|0)==(f[a+8>>2]|0)){Ri(a,h);k=f[i>>2]|0}else{f[j>>2]=f[h>>2];l=j+4|0;f[i>>2]=l;k=l}l=f[a>>2]|0;f[g>>2]=k-l;k=b+16|0;j=k;m=f[j+4>>2]|0;if(!((m|0)>0|(m|0)==0&(f[j>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=f[a>>2]|0;m=f[g>>2]|0;g=k;k=f[g+4>>2]|0;if((k|0)>0|(k|0)==0&(f[g>>2]|0)>>>0>0){n=j;o=e}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,j,j+m|0)|0;n=f[a>>2]|0;o=e}}else{n=l;o=e}e=f[i>>2]|0;if((e|0)==(n|0)){f[h>>2]=0;p=a+16|0;f[p>>2]=0;u=c;return}f[i>>2]=e+(~((e+-4-n|0)>>>2)<<2);f[h>>2]=0;p=a+16|0;f[p>>2]=0;u=c;return}function Cg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;Oq(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)aq(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)aq(a);i=ln(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}else{n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;o=a-e|0;if(o|0)im(k|0,c|0,o|0)|0;c=k+o|0;if(!j){if((f[n>>2]|0)==(c|0))return;f[n>>2]=c;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}}function Dg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+352>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Eg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}i=f[a>>2]|0;j=g-i>>2;g=j+b|0;k=i;if(g>>>0>1073741823)aq(a);l=d-i|0;d=l>>1;m=l>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(m)if(m>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m<<2)|0;break}else n=0;while(0);d=n+(j<<2)|0;sj(d|0,0,b<<2|0)|0;b=d;j=n+(m<<2)|0;m=n+(g<<2)|0;if((h|0)==(k|0)){o=b;p=i;q=h}else{i=h;h=b;b=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[b+-4>>2]=d;b=h+-4|0;h=b}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=j;j=p;if((q|0)!=(j|0)){c=q;do{c=c+-4|0;q=f[c>>2]|0;f[c>>2]=0;if(q|0)Va[f[(f[q>>2]|0)+4>>2]&127](q)}while((c|0)!=(j|0))}if(!p)return;Oq(p);return}function Fg(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=$(h);var i=0,j=0,k=0,l=0,m=0,n=0;i=u;u=u+16|0;j=i;k=i+4|0;f[j>>2]=c;c=ln(32)|0;f[k>>2]=c;f[k+8>>2]=-2147483616;f[k+4>>2]=17;l=c;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+17>>0]=0;Xj(Hd(a,j)|0,k,d);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);d=ln(32)|0;f[k>>2]=d;f[k+8>>2]=-2147483616;f[k+4>>2]=19;l=d;m=14438;n=l+19|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[d+19>>0]=0;si(Hd(a,j)|0,k,g,e);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);e=ln(32)|0;f[k>>2]=e;f[k+8>>2]=-2147483616;f[k+4>>2]=18;l=e;m=14458;n=l+18|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+18>>0]=0;Tj(Hd(a,j)|0,k,h);if((b[k+11>>0]|0)>=0){u=i;return}Oq(f[k>>2]|0);u=i;return}function Gg(a){a=a|0;tk(a);tk(a+32|0);tk(a+64|0);tk(a+96|0);tk(a+128|0);tk(a+160|0);tk(a+192|0);tk(a+224|0);tk(a+256|0);tk(a+288|0);tk(a+320|0);tk(a+352|0);tk(a+384|0);tk(a+416|0);tk(a+448|0);tk(a+480|0);tk(a+512|0);tk(a+544|0);tk(a+576|0);tk(a+608|0);tk(a+640|0);tk(a+672|0);tk(a+704|0);tk(a+736|0);tk(a+768|0);tk(a+800|0);tk(a+832|0);tk(a+864|0);tk(a+896|0);tk(a+928|0);tk(a+960|0);tk(a+992|0);tk(a+1024|0);return}function Hg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+288>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Ig(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>2>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>2;o=h>>>0>n>>>0;p=o?b+(n<<2)|0:c;c=p;n=c-e|0;e=n>>2;if(e|0)im(k|0,b|0,n|0)|0;n=l+(e<<2)|0;if(o){o=d-c|0;if((o|0)<=0)return;kh(f[m>>2]|0,p|0,o|0)|0;f[m>>2]=(f[m>>2]|0)+(o>>>2<<2);return}else{o=f[m>>2]|0;if((o|0)==(n|0))return;f[m>>2]=o+(~((o+-4-n|0)>>>2)<<2);return}}n=k;if(!k)q=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(n);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;q=0}if(h>>>0>1073741823)aq(a);j=q>>1;n=q>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(n>>>0>1073741823)aq(a);j=ln(n<<2)|0;h=a+4|0;f[h>>2]=j;f[a>>2]=j;f[i>>2]=j+(n<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[h>>2]=j+(g>>>2<<2);return}function Jg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0,v=0.0;e=u;u=u+16|0;g=e;h=c+1|0;f[g>>2]=0;i=g+4|0;f[i>>2]=0;f[g+8>>2]=0;do if(h)if(h>>>0>1073741823)aq(g);else{j=ln(h<<2)|0;f[g>>2]=j;k=j+(h<<2)|0;f[g+8>>2]=k;sj(j|0,0,(c<<2)+4|0)|0;f[i>>2]=k;l=j;m=k;n=j;break}else{l=0;m=0;n=0}while(0);if((b|0)>0){g=0;do{j=l+(f[a+(g<<2)>>2]<<2)|0;f[j>>2]=(f[j>>2]|0)+1;g=g+1|0}while((g|0)!=(b|0))}o=+(b|0);if((c|0)<0){p=0;q=0.0}else{c=0;r=0.0;b=0;while(1){g=f[l+(b<<2)>>2]|0;s=+(g|0);if((g|0)>0){t=c+1|0;v=r+ +Zg(s/o)*s}else{t=c;v=r}b=b+1|0;if((b|0)==(h|0)){p=t;q=v;break}else{c=t;r=v}}}if(d|0)f[d>>2]=p;v=-q;p=~~v>>>0;d=+K(v)>=1.0?(v>0.0?~~+Y(+J(v/4294967296.0),4294967295.0)>>>0:~~+W((v-+(~~v>>>0))/4294967296.0)>>>0):0;if(!l){I=d;u=e;return p|0}if((m|0)!=(l|0))f[i>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(n);I=d;u=e;return p|0}function Kg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e+4|0;h=e;i=ln(32)|0;f[a>>2]=i;f[a+4>>2]=c+4;c=a+8|0;b[c>>0]=0;f[i+16>>2]=f[d>>2];a=i+20|0;f[i+24>>2]=0;f[i+28>>2]=0;j=i+24|0;f[a>>2]=j;i=f[d+4>>2]|0;k=d+8|0;if((i|0)==(k|0)){b[c>>0]=1;u=e;return}d=j;j=i;while(1){i=j+16|0;f[h>>2]=d;f[g>>2]=f[h>>2];ph(a,g,i,i)|0;i=f[j+4>>2]|0;if(!i){l=j+8|0;m=f[l>>2]|0;if((f[m>>2]|0)==(j|0))n=m;else{m=l;do{l=f[m>>2]|0;m=l+8|0;o=f[m>>2]|0}while((f[o>>2]|0)!=(l|0));n=o}}else{m=i;while(1){o=f[m>>2]|0;if(!o)break;else m=o}n=m}if((n|0)==(k|0))break;else j=n}b[c>>0]=1;u=e;return}function Lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[e>>2]=b;g=a+8|0;if(((f[a+12>>2]|0)-(f[g>>2]|0)>>2|0)<=(b|0))Bh(g,b+1|0);h=f[(f[c>>2]|0)+56>>2]|0;do if((h|0)<5){i=a+20+(h*12|0)+4|0;j=f[i>>2]|0;if((j|0)==(f[a+20+(h*12|0)+8>>2]|0)){Ri(a+20+(h*12|0)|0,e);break}else{f[j>>2]=b;f[i>>2]=j+4;break}}while(0);b=f[c>>2]|0;h=f[e>>2]|0;f[b+60>>2]=h;e=(f[g>>2]|0)+(h<<2)|0;f[c>>2]=0;c=f[e>>2]|0;f[e>>2]=b;if(!c){u=d;return}b=c+88|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0){b=f[e+8>>2]|0;if(b|0){h=e+12|0;if((f[h>>2]|0)!=(b|0))f[h>>2]=b;Oq(b)}Oq(e)}e=f[c+68>>2]|0;if(e|0){b=c+72|0;h=f[b>>2]|0;if((h|0)!=(e|0))f[b>>2]=h+(~((h+-4-e|0)>>>2)<<2);Oq(e)}e=c+64|0;h=f[e>>2]|0;f[e>>2]=0;if(h|0){e=f[h>>2]|0;if(e|0){b=h+4|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(h)}Oq(c);u=d;return}function Mg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+56>>2]|0)-(f[g+52>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[(f[e>>2]|0)+64>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];Zb(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];Zb(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;d=u;u=u+48|0;e=d+16|0;g=d;h=d+32|0;i=a+28|0;j=f[i>>2]|0;f[h>>2]=j;k=a+20|0;l=(f[k>>2]|0)-j|0;f[h+4>>2]=l;f[h+8>>2]=b;f[h+12>>2]=c;b=l+c|0;l=a+60|0;f[g>>2]=f[l>>2];f[g+4>>2]=h;f[g+8>>2]=2;j=to(Aa(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=2;m=b;n=h;o=j;while(1){if((o|0)<0)break;m=m-o|0;p=f[n+4>>2]|0;q=o>>>0>p>>>0;r=q?n+8|0:n;s=g+(q<<31>>31)|0;t=o-(q?p:0)|0;f[r>>2]=(f[r>>2]|0)+t;p=r+4|0;f[p>>2]=(f[p>>2]|0)-t;f[e>>2]=f[l>>2];f[e+4>>2]=r;f[e+8>>2]=s;o=to(Aa(146,e|0)|0)|0;if((m|0)==(o|0)){v=3;break a}else{g=s;n=r}}f[a+16>>2]=0;f[i>>2]=0;f[k>>2]=0;f[a>>2]=f[a>>2]|32;if((g|0)==2)w=0;else w=c-(f[n+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=f[a+44>>2]|0;f[a+16>>2]=v+(f[a+48>>2]|0);a=v;f[i>>2]=a;f[k>>2]=a;w=c}u=d;return w|0}function Og(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=6192;b=f[a+68>>2]|0;if(b|0){c=a+72|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+56>>2]|0;if(b|0){d=a+60|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+44>>2]|0;if(b|0){c=a+48|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+32>>2]|0;if(b|0){d=a+36|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}hi(a+8|0);b=a+4|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+40|0;d=f[b>>2]|0;if(d|0){c=a+44|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){bj(i);Oq(i)}h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}bj(a);Oq(a);return}function Pg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if(((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(f[(f[d>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)==0:0)?(j=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if(((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(f[(f[d>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)==0:0)?(k=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if((((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(f[(f[d>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0:0)?(h=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n)}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Rg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+4|0;a=f[d>>2]|0;do if(a|0){e=b[c+11>>0]|0;g=e<<24>>24<0;h=g?f[c+4>>2]|0:e&255;e=g?f[c>>2]|0:c;g=d;i=a;a:while(1){j=i;while(1){k=j+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[j+20>>2]|0:l&255;l=h>>>0>>0?h:n;if((l|0)!=0?(o=Vk(m?f[k>>2]|0:k,e,l)|0,(o|0)!=0):0){if((o|0)>=0)break}else p=6;if((p|0)==6?(p=0,n>>>0>=h>>>0):0)break;n=f[j+4>>2]|0;if(!n){q=g;break a}else j=n}i=f[j>>2]|0;if(!i){q=j;break}else g=j}if((q|0)!=(d|0)){g=q+16|0;i=b[g+11>>0]|0;n=i<<24>>24<0;o=n?f[q+20>>2]|0:i&255;i=o>>>0>>0?o:h;if(i|0?(l=Vk(e,n?f[g>>2]|0:g,i)|0,l|0):0){if((l|0)<0)break;else r=q;return r|0}if(h>>>0>=o>>>0){r=q;return r|0}}}while(0);r=d;return r|0}function Sg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=a+8|0;f[c>>2]=f[b>>2];fg(a+12|0,b+4|0)|0;d=a+44|0;e=b+36|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];if((c|0)==(b|0)){f[a+96>>2]=f[b+88>>2];return}else{ng(a+60|0,f[b+52>>2]|0,f[b+56>>2]|0);ng(a+72|0,f[b+64>>2]|0,f[b+68>>2]|0);ng(a+84|0,f[b+76>>2]|0,f[b+80>>2]|0);f[a+96>>2]=f[b+88>>2];Ig(a+100|0,f[b+92>>2]|0,f[b+96>>2]|0);return}}function Tg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/12|0)>>>0>=b>>>0){i=b;j=h;do{f[j>>2]=f[c>>2];f[j+4>>2]=f[c+4>>2];f[j+8>>2]=f[c+8>>2];j=(f[g>>2]|0)+12|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/12|0;h=j+b|0;if(h>>>0>357913941)aq(a);k=(e-i|0)/12|0;i=k<<1;e=k>>>0<178956970?(i>>>0>>0?h:i):357913941;do if(e)if(e>>>0>357913941){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*12|0)|0;break}else l=0;while(0);i=l+(j*12|0)|0;j=l+(e*12|0)|0;e=b;b=i;l=i;do{f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];b=l+12|0;l=b;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;b=(f[g>>2]|0)-e|0;c=i+(((b|0)/-12|0)*12|0)|0;if((b|0)>0)kh(c|0,e|0,b|0)|0;f[a>>2]=c;f[g>>2]=l;f[d>>2]=j;if(!e)return;Oq(e);return}function Ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0){bj(n);Oq(n)}}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Vg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=f[b>>2]|0;g=f[a>>2]|0;h=f[d>>2]|0;d=f[h>>2]|0;i=(f[h+4>>2]|0)-d>>3;if(i>>>0<=e>>>0)aq(h);j=d;if(i>>>0<=g>>>0)aq(h);d=f[j+(e<<3)>>2]|0;k=f[c>>2]|0;if(i>>>0<=k>>>0)aq(h);l=j+(g<<3)|0;m=(f[j+(k<<3)>>2]|0)>>>0>>0;if(d>>>0<(f[l>>2]|0)>>>0){if(m){f[a>>2]=k;f[c>>2]=g;n=1;return n|0}f[a>>2]=e;f[b>>2]=g;d=f[c>>2]|0;if(i>>>0<=d>>>0)aq(h);if((f[j+(d<<3)>>2]|0)>>>0>=(f[l>>2]|0)>>>0){n=1;return n|0}f[b>>2]=d;f[c>>2]=g;n=2;return n|0}if(!m){n=0;return n|0}f[b>>2]=k;f[c>>2]=e;e=f[b>>2]|0;c=f[a>>2]|0;if(i>>>0<=e>>>0)aq(h);if(i>>>0<=c>>>0)aq(h);if((f[j+(e<<3)>>2]|0)>>>0>=(f[j+(c<<3)>>2]|0)>>>0){n=1;return n|0}f[a>>2]=e;f[b>>2]=c;n=2;return n|0}function Wg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[e>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];dc(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];dc(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Xg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;a=u;u=u+16|0;e=a;if(!b){g=0;u=a;return g|0}h=b+96|0;i=b+100|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;b=f[i>>2]|0;j=f[h>>2]|0;k=(b-j|0)/12|0;l=j;j=b;if(k>>>0>=c>>>0){if(k>>>0>c>>>0?(b=l+(c*12|0)|0,(b|0)!=(j|0)):0)f[i>>2]=j+(~(((j+-12-b|0)>>>0)/12|0)*12|0);if(!c){g=1;u=a;return g|0}}else Tg(h,c-k|0,e);k=0;b=f[h>>2]|0;while(1){j=k*3|0;l=f[d+(j<<2)>>2]|0;m=f[d+(j+1<<2)>>2]|0;n=f[d+(j+2<<2)>>2]|0;j=((f[i>>2]|0)-b|0)/12|0;o=k;k=k+1|0;if(o>>>0>>0){p=b;q=b}else{f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;Tg(h,k-j|0,e);j=f[h>>2]|0;p=j;q=j}f[p+(o*12|0)>>2]=l;f[p+(o*12|0)+4>>2]=m;f[p+(o*12|0)+8>>2]=n;if((k|0)==(c|0)){g=1;break}else b=q}u=a;return g|0}function Yg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;ao(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function Zg(a){a=+a;var b=0,c=0,d=0,e=0.0,g=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,q=0.0,r=0.0,t=0.0;p[s>>3]=a;b=f[s>>2]|0;c=f[s+4>>2]|0;d=(c|0)<0;do if(d|c>>>0<1048576){if((b|0)==0&(c&2147483647|0)==0){e=-1.0/(a*a);break}if(d){e=(a-a)/0.0;break}else{p[s>>3]=a*18014398509481984.0;g=f[s+4>>2]|0;h=-1077;i=g;j=f[s>>2]|0;k=g;l=9;break}}else if(c>>>0<=2146435071)if((b|0)==0&0==0&(c|0)==1072693248)e=0.0;else{h=-1023;i=c;j=b;k=c;l=9}else e=a;while(0);if((l|0)==9){l=i+614242|0;f[s>>2]=j;f[s+4>>2]=(l&1048575)+1072079006;a=+p[s>>3]+-1.0;m=a*a*.5;n=a/(a+2.0);o=n*n;q=o*o;p[s>>3]=a-m;j=f[s+4>>2]|0;f[s>>2]=0;f[s+4>>2]=j;r=+p[s>>3];t=a-r-m+n*(m+(q*(q*(q*.15313837699209373+.22222198432149784)+.3999999999940942)+o*(q*(q*(q*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)));q=r*1.4426950407214463;o=+(h+(l>>>20)|0);m=q+o;e=m+(q+(o-m)+(t*1.4426950407214463+(t+r)*1.6751713164886512e-10))}return +e}function _g(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=17;h=g;i=14390;j=h+17|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+17>>0]=0;g=c+16|0;i=f[g>>2]|0;if(i){h=g;j=i;a:while(1){i=j;while(1){if((f[i+16>>2]|0)>=(a|0))break;k=f[i+4>>2]|0;if(!k){l=h;break a}else i=k}j=f[i>>2]|0;if(!j){l=i;break}else h=i}if(((l|0)!=(g|0)?(f[l+16>>2]|0)<=(a|0):0)?(a=l+20|0,(Jh(a,e)|0)!=0):0)m=a;else n=10}else n=10;if((n|0)==10)m=c;c=Hk(m,e,-1)|0;if((b[e+11>>0]|0)>=0){o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}Oq(f[e>>2]|0);o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}function $g(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[c>>2]|0;f[c>>2]=0;f[e>>2]=g;Lg(a,b,e);g=f[e>>2]|0;f[e>>2]=0;if(g|0){e=g+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){h=c+12|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(c)}c=f[g+68>>2]|0;if(c|0){e=g+72|0;h=f[e>>2]|0;if((h|0)!=(c|0))f[e>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=g+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){e=h+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(h)}Oq(g)}g=a+84|0;h=a+88|0;a=f[h>>2]|0;c=f[g>>2]|0;e=a-c>>2;if((e|0)>(b|0)){u=d;return}i=b+1|0;b=a;if(i>>>0>e>>>0){Fh(g,i-e|0);u=d;return}if(i>>>0>=e>>>0){u=d;return}e=c+(i<<2)|0;if((e|0)==(b|0)){u=d;return}f[h>>2]=b+(~((b+-4-e|0)>>>2)<<2);u=d;return}function ah(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+352>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+352>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function bh(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0;c=a+108|0;d=(f[a+112>>2]|0)-(f[c>>2]|0)|0;e=(d|0)/12|0;g=a+4|0;ci(e,f[(f[g>>2]|0)+44>>2]|0)|0;if(!d)return 1;d=0;a=0;while(1){i=f[c>>2]|0;j=i+(d*12|0)+4|0;ci((f[j>>2]|0)-a|0,f[(f[g>>2]|0)+44>>2]|0)|0;ci((f[j>>2]|0)-(f[i+(d*12|0)>>2]|0)|0,f[(f[g>>2]|0)+44>>2]|0)|0;d=d+1|0;if(d>>>0>=e>>>0)break;else a=f[j>>2]|0}zi(f[(f[g>>2]|0)+44>>2]|0,e,0,0)|0;a=0;do{d=f[(f[g>>2]|0)+44>>2]|0;j=d+16|0;i=f[j+4>>2]|0;if((i|0)>0|(i|0)==0&(f[j>>2]|0)>>>0>0){j=f[d+12>>2]|0;d=j+4|0;i=f[d>>2]|0;k=b[(f[c>>2]|0)+(a*12|0)+8>>0]&1;l=i>>>3;m=i&7;i=(f[j>>2]|0)+l|0;b[i>>0]=(1<>0]|0);i=(f[j>>2]|0)+l|0;b[i>>0]=k<>0]|0);f[d>>2]=(f[d>>2]|0)+1}a=a+1|0}while(a>>>0>>0);eg(f[(f[g>>2]|0)+44>>2]|0);return 1}function ch(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;io(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function dh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+288>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+288>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function eh(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;g=u;u=u+32|0;h=g+16|0;i=g+8|0;j=g;k=d-e|0;d=a+8|0;if((k|0)>0){a=0-e|0;l=i+4|0;m=j+4|0;n=h+4|0;o=k;do{k=b+(o<<2)|0;p=k+(a<<2)|0;q=c+(o<<2)|0;r=f[k+4>>2]|0;s=f[p>>2]|0;t=f[p+4>>2]|0;f[i>>2]=f[k>>2];f[l>>2]=r;f[j>>2]=s;f[m>>2]=t;Od(h,d,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[n>>2];o=o-e|0}while((o|0)>0)}o=e>>>0>1073741823?-1:e<<2;e=Lq(o)|0;sj(e|0,0,o|0)|0;o=f[b+4>>2]|0;n=f[e>>2]|0;m=f[e+4>>2]|0;f[i>>2]=f[b>>2];f[i+4>>2]=o;f[j>>2]=n;f[j+4>>2]=m;Od(h,d,i,j);f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];Mq(e);u=g;return 1}function fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+32|0;d=c+12|0;e=c;g=f[b+100>>2]|0;h=f[b+96>>2]|0;b=g-h|0;i=(b|0)/12|0;f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;k=h;do if(b)if(i>>>0>357913941)aq(d);else{l=ln(b)|0;f[d>>2]=l;f[d+8>>2]=l+(i*12|0);sj(l|0,0,b|0)|0;f[j>>2]=l+b;m=l;break}else m=0;while(0);f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;if((g|0)!=(h|0)){h=e+4|0;g=e+8|0;b=0;do{l=k+(b*12|0)|0;f[e>>2]=f[l>>2];f[e+4>>2]=f[l+4>>2];f[e+8>>2]=f[l+8>>2];f[m+(b*12|0)>>2]=f[e>>2];f[m+(b*12|0)+4>>2]=f[h>>2];f[m+(b*12|0)+8>>2]=f[g>>2];b=b+1|0}while(b>>>0>>0)}Kj(a,d);a=f[d>>2]|0;if(!a){u=c;return}d=f[j>>2]|0;if((d|0)!=(a|0))f[j>>2]=d+(~(((d+-12-a|0)>>>0)/12|0)*12|0);Oq(a);u=c;return}function gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;if(c>>>0>4294967279)aq(a);d=a+11|0;e=b[d>>0]|0;g=e<<24>>24<0;if(g){h=f[a+4>>2]|0;i=(f[a+8>>2]&2147483647)+-1|0}else{h=e&255;i=10}j=h>>>0>c>>>0?h:c;c=j>>>0<11;k=c?10:(j+16&-16)+-1|0;do if((k|0)!=(i|0)){do if(c){j=f[a>>2]|0;if(g){l=0;m=j;n=a;o=13}else{Fo(a,j,(e&255)+1|0)|0;Oq(j);o=16}}else{j=k+1|0;p=ln(j)|0;if(g){l=1;m=f[a>>2]|0;n=p;o=13;break}else{Fo(p,a,(e&255)+1|0)|0;q=p;r=j;s=a+4|0;o=15;break}}while(0);if((o|0)==13){j=a+4|0;Fo(n,m,(f[j>>2]|0)+1|0)|0;Oq(m);if(l){q=n;r=k+1|0;s=j;o=15}else o=16}if((o|0)==15){f[a+8>>2]=r|-2147483648;f[s>>2]=h;f[a>>2]=q;break}else if((o|0)==16){b[d>>0]=h;break}}while(0);return}function hh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=f[b>>2]|0;if((c|0)==-1){d=-1;return d|0}b=f[(f[a+24>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1){d=0;return d|0}c=a+12|0;a=0;e=0;g=b;a:while(1){b:do if(e){h=a+1|0;i=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((i|0)==-1){d=h;j=15;break a}k=f[(f[c>>2]|0)+(i<<2)>>2]|0;if((k|0)==-1){d=h;j=15;break a}if(!((k>>>0)%3|0)){l=k+2|0;m=h;break}else{l=k+-1|0;m=h;break}}else{h=a;k=g;while(1){i=h+1|0;n=k+1|0;o=((n>>>0)%3|0|0)==0?k+-2|0:n;if((o|0)==-1){l=b;m=i;break b}n=f[(f[c>>2]|0)+(o<<2)>>2]|0;o=n+1|0;if((n|0)==-1){l=b;m=i;break b}k=((o>>>0)%3|0|0)==0?n+-2|0:o;if((k|0)==-1){l=b;m=i;break b}if((k|0)==(b|0)){d=i;j=15;break a}else h=i}}while(0);if((l|0)==-1){d=m;j=15;break}else{a=m;e=1;g=l}}if((j|0)==15)return d|0;return 0}function ih(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=a+8|0;Vg(a,a+4|0,d,c)|0;e=a+12|0;if((e|0)==(b|0))return;g=f[c>>2]|0;c=f[g>>2]|0;h=(f[g+4>>2]|0)-c>>3;i=c;c=e;e=d;a:while(1){d=f[c>>2]|0;j=f[e>>2]|0;if(h>>>0<=d>>>0){k=5;break}if(h>>>0<=j>>>0){k=7;break}l=i+(d<<3)|0;if((f[l>>2]|0)>>>0<(f[i+(j<<3)>>2]|0)>>>0){m=e;n=c;o=j;while(1){f[n>>2]=o;if((m|0)==(a|0)){p=a;break}j=m+-4|0;o=f[j>>2]|0;if(h>>>0<=o>>>0){k=11;break a}if((f[l>>2]|0)>>>0>=(f[i+(o<<3)>>2]|0)>>>0){p=m;break}else{q=m;m=j;n=q}}f[p>>2]=d}n=c+4|0;if((n|0)==(b|0)){k=3;break}else{m=c;c=n;e=m}}if((k|0)==3)return;else if((k|0)==5)aq(g);else if((k|0)==7)aq(g);else if((k|0)==11)aq(g)}function jh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=Vg(a,b,c,e)|0;h=f[d>>2]|0;i=f[c>>2]|0;j=f[e>>2]|0;e=f[j>>2]|0;k=(f[j+4>>2]|0)-e>>3;if(k>>>0<=h>>>0)aq(j);l=e;if(k>>>0<=i>>>0)aq(j);if((f[l+(h<<3)>>2]|0)>>>0>=(f[l+(i<<3)>>2]|0)>>>0){m=g;return m|0}f[c>>2]=h;f[d>>2]=i;i=f[c>>2]|0;d=f[b>>2]|0;if(k>>>0<=i>>>0)aq(j);if(k>>>0<=d>>>0)aq(j);if((f[l+(i<<3)>>2]|0)>>>0>=(f[l+(d<<3)>>2]|0)>>>0){m=g+1|0;return m|0}f[b>>2]=i;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(k>>>0<=d>>>0)aq(j);if(k>>>0<=c>>>0)aq(j);if((f[l+(d<<3)>>2]|0)>>>0>=(f[l+(c<<3)>>2]|0)>>>0){m=g+2|0;return m|0}f[a>>2]=d;f[b>>2]=c;m=g+3|0;return m|0}function kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return Da(a|0,c|0,d|0)|0;e=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return e|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}h=g&-4|0;d=h-64|0;while((a|0)<=(d|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(h|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{h=g-4|0;while((a|0)<(h|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return e|0}function lh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+16|0;d=c+4|0;e=c;f[a>>2]=1232;g=a+4|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;f[g+16>>2]=0;f[g+20>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;f[d>>2]=b;b=a+4|0;g=a+8|0;Ri(b,d);h=f[d>>2]|0;i=a+20|0;j=f[i>>2]|0;k=a+16|0;a=f[k>>2]|0;l=j-a>>2;m=a;if((h|0)<(l|0)){n=m;o=h;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}a=h+1|0;f[e>>2]=-1;w=j;if(a>>>0<=l>>>0)if(a>>>0>>0?(j=m+(a<<2)|0,(j|0)!=(w|0)):0){f[i>>2]=w+(~((w+-4-j|0)>>>2)<<2);x=h;y=m}else{x=h;y=m}else{Ch(k,a-l|0,e);x=f[d>>2]|0;y=f[k>>2]|0}n=y;o=x;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}function mh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+4|0;c=f[b>>2]|0;d=(f[c+12>>2]|0)-(f[c+8>>2]|0)|0;c=d>>2;a:do if((d|0)>0){e=0;while(1){if(!(Ra[f[(f[a>>2]|0)+36>>2]&127](a,e)|0)){g=0;break}e=e+1|0;h=f[b>>2]|0;i=(f[h+12>>2]|0)-(f[h+8>>2]|0)>>2;if((e|0)>=(i|0)){j=i;break a}}return g|0}else j=c;while(0);c=a+20|0;b=a+24|0;d=f[b>>2]|0;e=f[c>>2]|0;i=d-e>>2;h=e;e=d;if(j>>>0<=i>>>0){if(j>>>0>>0?(d=h+(j<<2)|0,(d|0)!=(e|0)):0)f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2)}else Ci(c,j-i|0);i=f[a+12>>2]|0;j=f[a+8>>2]|0;a=j;if((i|0)==(j|0)){g=1;return g|0}d=i-j>>2;j=0;do{i=f[a+(j<<2)>>2]|0;e=f[i+8>>2]|0;b=f[i+4>>2]|0;i=b;if((e|0)!=(b|0)?(h=f[c>>2]|0,k=e-b>>2,f[h+(f[i>>2]<<2)>>2]=j,k>>>0>1):0){b=1;do{f[h+(f[i+(b<<2)>>2]<<2)>>2]=j;b=b+1|0}while(b>>>0>>0)}j=j+1|0}while(j>>>0>>0);g=1;return g|0}function nh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=f[c+88>>2]|0;if(!d){e=0;return e|0}if((f[d>>2]|0)!=1){e=0;return e|0}g=d+8|0;d=f[g>>2]|0;f[a+4>>2]=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;i=a+8|0;j=c+24|0;c=b[j>>0]|0;k=c<<24>>24;l=a+12|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=k>>>0)if(o>>>0>k>>>0?(m=p+(k<<2)|0,(m|0)!=(n|0)):0){f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2);q=c;r=d}else{q=c;r=d}else{Ci(i,k-o|0);q=b[j>>0]|0;r=f[g>>2]|0}g=r+4|0;j=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;if(q<<24>>24>0){g=f[i>>2]|0;i=q<<24>>24;q=j;o=4;k=0;while(1){f[g+(k<<2)>>2]=q;o=o+4|0;k=k+1|0;d=r+o|0;c=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;if((k|0)>=(i|0)){s=c;break}else q=c}}else s=j;f[a+20>>2]=s;e=1;return e|0}function oh(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(!(fp(a,f[c>>2]|0,g)|0)){h=f[a+8>>2]|0;Za[f[(f[h>>2]|0)+24>>2]&3](h,c,d,e,g);break}if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;i=c+44|0;if((f[i>>2]|0)==4)break;j=c+52|0;b[j>>0]=0;k=c+53|0;b[k>>0]=0;l=f[a+8>>2]|0;_a[f[(f[l>>2]|0)+20>>2]&3](l,c,d,d,1,g);if(b[k>>0]|0)if(!(b[j>>0]|0)){m=3;n=11}else o=3;else{m=4;n=11}if((n|0)==11){f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0){b[c+54>>0]=1;o=m}else o=m}f[i>>2]=o;break}if((e|0)==1)f[c+32>>2]=1}else Vm(0,c,d,e);while(0);return}function ph(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e+12|0;h=e+8|0;i=e;f[i>>2]=f[b>>2];f[g>>2]=f[i>>2];i=Kd(a,g,h,e+4|0,c)|0;c=f[i>>2]|0;if(c|0){j=c;u=e;return j|0}c=ln(40)|0;pj(c+16|0,d);pj(c+28|0,d+12|0);d=f[h>>2]|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=d;f[i>>2]=c;d=f[f[a>>2]>>2]|0;if(!d)k=c;else{f[a>>2]=d;k=f[i>>2]|0}Oe(f[a+4>>2]|0,k);k=a+8|0;f[k>>2]=(f[k>>2]|0)+1;j=c;u=e;return j|0}function qh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=a+4|0;f[h>>2]=0;if(!c){u=e;return}i=a+8|0;j=f[i>>2]|0;k=j<<5;if(k>>>0>>0){f[g>>2]=0;l=g+4|0;f[l>>2]=0;m=g+8|0;f[m>>2]=0;if((c|0)<0)aq(a);n=j<<6;j=c+31&-32;vi(g,k>>>0<1073741823?(n>>>0>>0?j:n):2147483647);n=f[a>>2]|0;f[a>>2]=f[g>>2];f[g>>2]=n;g=f[h>>2]|0;f[h>>2]=c;f[l>>2]=g;g=f[i>>2]|0;f[i>>2]=f[m>>2];f[m>>2]=g;if(n|0)Oq(n);o=a}else{f[h>>2]=c;o=a}a=f[o>>2]|0;o=a;h=a;a=c>>>5;n=a<<2;if(!(b[d>>0]|0)){sj(h|0,0,n|0)|0;d=c&31;g=o+(a<<2)|0;if(!d){u=e;return}f[g>>2]=f[g>>2]&~(-1>>>(32-d|0));u=e;return}else{sj(h|0,-1,n|0)|0;n=c&31;c=o+(a<<2)|0;if(!n){u=e;return}f[c>>2]=f[c>>2]|-1>>>(32-n|0);u=e;return}}function rh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+88|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+88|0;ld(n,b);u=c;return 1}function sh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+108|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+108|0;ld(n,b);u=c;return 1}function th(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=a+32|0;d=f[a+64>>2]|0;e=(Qa[f[(f[d>>2]|0)+40>>2]&127](d)|0)+52|0;d=f[e>>2]|0;zi(c,(((f[d+100>>2]|0)-(f[d+96>>2]|0)|0)/12|0)*3|0,0,1)|0;d=a+68|0;e=f[d>>2]|0;g=(f[a+72>>2]|0)-e|0;if((g|0)<=0){eg(c);return}i=a+48|0;j=a+44|0;a=(g>>>2)+-1|0;g=e;while(1){e=f[g+(a<<2)>>2]|0;k=f[3524+(e<<2)>>2]|0;l=i;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0?(l=f[j>>2]|0,171>>>e&1|0):0){m=l+4|0;n=0;o=f[m>>2]|0;do{p=o>>>3;q=o&7;r=(f[l>>2]|0)+p|0;b[r>>0]=(1<>0]|0);r=(f[l>>2]|0)+p|0;b[r>>0]=(e>>>n&1)<>0]|0);o=(f[m>>2]|0)+1|0;f[m>>2]=o;n=n+1|0}while((n|0)!=(k|0))}k=a+-1|0;if((k|0)<=-1)break;a=k;g=f[d>>2]|0}eg(c);return}function uh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+48|0;h=g;i=g+32|0;if(!c){j=0;u=g;return j|0}Gn(h);do if((dm(c,0)|0)!=-1){if(d){if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){k=0;break}Va[f[(f[c>>2]|0)+20>>2]&127](c)}Yg(i,a,c,h);l=(f[i>>2]|0)==0;m=i+4|0;if((b[m+11>>0]|0)<0)Oq(f[m>>2]|0);if(l){l=f[h>>2]|0;m=h+4|0;rg(e,l,l+((f[m>>2]|0)-l)|0);k=(f[m>>2]|0)-(f[h>>2]|0)|0}else k=0}else k=0;while(0);e=h+12|0;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Oq(i);i=f[h>>2]|0;if(i|0){e=h+4|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}j=k;u=g;return j|0}function vh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;d=c;e=f[(f[a>>2]|0)+8>>2]|0;g=a+8|0;h=a+12|0;i=(f[h>>2]|0)-(f[g>>2]|0)>>2;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;Xa[e&15](a,i,d);i=f[d>>2]|0;f[d>>2]=0;if(!i){k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}d=i+88|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0){d=f[a+8>>2]|0;if(d|0){e=a+12|0;if((f[e>>2]|0)!=(d|0))f[e>>2]=d;Oq(d)}Oq(a)}a=f[i+68>>2]|0;if(a|0){d=i+72|0;e=f[d>>2]|0;if((e|0)!=(a|0))f[d>>2]=e+(~((e+-4-a|0)>>>2)<<2);Oq(a)}a=i+64|0;e=f[a>>2]|0;f[a>>2]=0;if(e|0){a=f[e>>2]|0;if(a|0){d=e+4|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;Oq(a)}Oq(e)}Oq(i);k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}function wh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>3>>>0>=b>>>0){h=b;i=g;do{j=i;f[j>>2]=0;f[j+4>>2]=0;i=(f[e>>2]|0)+8|0;f[e>>2]=i;h=h+-1|0}while((h|0)!=0);return}h=f[a>>2]|0;i=g-h>>3;g=i+b|0;if(g>>>0>536870911)aq(a);j=d-h|0;h=j>>2;d=j>>3>>>0<268435455?(h>>>0>>0?g:h):536870911;do if(d)if(d>>>0>536870911){h=ra(8)|0;Oo(h,16035);f[h>>2]=7256;va(h|0,1112,110)}else{k=ln(d<<3)|0;break}else k=0;while(0);h=k+(i<<3)|0;i=k+(d<<3)|0;d=b;b=h;k=h;do{g=b;f[g>>2]=0;f[g+4>>2]=0;b=k+8|0;k=b;d=d+-1|0}while((d|0)!=0);d=f[a>>2]|0;b=(f[e>>2]|0)-d|0;g=h+(0-(b>>3)<<3)|0;if((b|0)>0)kh(g|0,d|0,b|0)|0;f[a>>2]=g;f[e>>2]=k;f[c>>2]=i;if(!d)return;Oq(d);return}function xh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;if(!(bn(a,b,c)|0)){g=0;u=d;return g|0}if((Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)<<24>>24==1?((f[(f[a+8>>2]|0)+28>>2]|0)+-1|0)>>>0>=6:0){g=0;u=d;return g|0}h=_g(c,f[b+48>>2]|0)|0;Xa[f[(f[a>>2]|0)+48>>2]&15](e,a,h);h=a+36|0;b=f[e>>2]|0;f[e>>2]=0;c=f[h>>2]|0;f[h>>2]=b;if(!c){f[e>>2]=0;i=b}else{Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[e>>2]|0;f[e>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);i=f[h>>2]|0}if(!i){g=1;u=d;return g|0}if(Ra[f[(f[a>>2]|0)+36>>2]&127](a,i)|0){g=1;u=d;return g|0}i=f[h>>2]|0;f[h>>2]=0;if(!i){g=1;u=d;return g|0}Va[f[(f[i>>2]|0)+4>>2]&127](i);g=1;u=d;return g|0}function yh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e+4|0;h=e;i=e+8|0;j=a&255;b[i>>0]=j&127;do if(c>>>0>0|(c|0)==0&a>>>0>127){b[i>>0]=j|-128;k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;k=Yn(a|0,c|0,7)|0;m=yh(k,I,d)|0;break}}else{k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;n=1;u=e;return n|0}while(0);n=m;u=e;return n|0}function zh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;g=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1)h=Xi(c,d)|0;else h=b;if((h|0)==-2)i=0;else{do if((Qa[f[(f[d>>2]|0)+8>>2]&127](d)|0)==1){Xf(a,d,h,c,e,514);if(!(f[a>>2]|0)){f[a>>2]=0;break}else return}while(0);c=ln(44)|0;f[c>>2]=1544;f[c+4>>2]=g;g=c+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[g+16>>2]=f[e+16>>2];f[g+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);f[c>>2]=1600;i=c}f[a>>2]=i;return}function Ah(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+224|0;g=e+120|0;h=e+80|0;i=e;j=e+136|0;k=h;l=k+40|0;do{f[k>>2]=0;k=k+4|0}while((k|0)<(l|0));f[g>>2]=f[d>>2];if((qb(0,c,g,i,h)|0)<0)m=-1;else{if((f[a+76>>2]|0)>-1)n=Tq(a)|0;else n=0;d=f[a>>2]|0;k=d&32;if((b[a+74>>0]|0)<1)f[a>>2]=d&-33;d=a+48|0;if(!(f[d>>2]|0)){l=a+44|0;o=f[l>>2]|0;f[l>>2]=j;p=a+28|0;f[p>>2]=j;q=a+20|0;f[q>>2]=j;f[d>>2]=80;r=a+16|0;f[r>>2]=j+80;j=qb(a,c,g,i,h)|0;if(!o)s=j;else{Sa[f[a+36>>2]&31](a,0,0)|0;t=(f[q>>2]|0)==0?-1:j;f[l>>2]=o;f[d>>2]=0;f[r>>2]=0;f[p>>2]=0;f[q>>2]=0;s=t}}else s=qb(a,c,g,i,h)|0;h=f[a>>2]|0;f[a>>2]=h|k;if(n|0)Sq(a);m=(h&32|0)==0?s:-1}u=e;return m|0}function Bh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e>>2;h=d;if(g>>>0>>0){uf(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b<<2)|0;if((g|0)==(h|0))return;else i=h;do{h=i+-4|0;f[c>>2]=h;b=f[h>>2]|0;f[h>>2]=0;if(b|0){h=b+88|0;e=f[h>>2]|0;f[h>>2]=0;if(e|0){h=f[e+8>>2]|0;if(h|0){a=e+12|0;if((f[a>>2]|0)!=(h|0))f[a>>2]=h;Oq(h)}Oq(e)}e=f[b+68>>2]|0;if(e|0){h=b+72|0;a=f[h>>2]|0;if((a|0)!=(e|0))f[h>>2]=a+(~((a+-4-e|0)>>>2)<<2);Oq(e)}e=b+64|0;a=f[e>>2]|0;f[e>>2]=0;if(a|0){e=f[a>>2]|0;if(e|0){h=a+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(a)}Oq(b)}i=f[c>>2]|0}while((i|0)!=(g|0));return}function Ch(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;i=h;if(e-h>>2>>>0>=b>>>0){j=b;k=i;while(1){f[k>>2]=f[c>>2];j=j+-1|0;if(!j)break;else k=k+4|0}f[g>>2]=i+(b<<2);return}i=f[a>>2]|0;k=h-i|0;h=k>>2;j=h+b|0;if(j>>>0>1073741823)aq(a);l=e-i|0;e=l>>1;m=l>>2>>>0<536870911?(e>>>0>>0?j:e):1073741823;do if(m)if(m>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}else{e=ln(m<<2)|0;n=e;o=e;break}else{n=0;o=0}while(0);e=n+(h<<2)|0;h=n+(m<<2)|0;m=b;j=e;while(1){f[j>>2]=f[c>>2];m=m+-1|0;if(!m)break;else j=j+4|0}if((k|0)>0)kh(o|0,i|0,k|0)|0;f[a>>2]=n;f[g>>2]=e+(b<<2);f[d>>2]=h;if(!i)return;Oq(i);return}function Dh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=(f[a>>2]|0)+1794895138|0;g=gp(f[a+8>>2]|0,e)|0;h=gp(f[a+12>>2]|0,e)|0;i=gp(f[a+16>>2]|0,e)|0;a:do if((g>>>0>>2>>>0?(j=c-(g<<2)|0,h>>>0>>0&i>>>0>>0):0)?((i|h)&3|0)==0:0){j=h>>>2;k=i>>>2;l=0;m=g;while(1){n=m>>>1;o=l+n|0;p=o<<1;q=p+j|0;r=gp(f[a+(q<<2)>>2]|0,e)|0;s=gp(f[a+(q+1<<2)>>2]|0,e)|0;if(!(s>>>0>>0&r>>>0<(c-s|0)>>>0)){t=0;break a}if(b[a+(s+r)>>0]|0){t=0;break a}r=hl(d,a+s|0)|0;if(!r)break;s=(r|0)<0;if((m|0)==1){t=0;break a}else{l=s?l:o;m=s?n:m-n|0}}m=p+k|0;l=gp(f[a+(m<<2)>>2]|0,e)|0;j=gp(f[a+(m+1<<2)>>2]|0,e)|0;if(j>>>0>>0&l>>>0<(c-j|0)>>>0)t=(b[a+(j+l)>>0]|0)==0?a+j|0:0;else t=0}else t=0;while(0);return t|0}function Eh(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=u;u=u+64|0;i=h;j=f[a>>2]|0;k=a+(f[j+-8>>2]|0)|0;l=f[j+-4>>2]|0;f[i>>2]=e;f[i+4>>2]=a;f[i+8>>2]=c;f[i+12>>2]=g;g=i+16|0;c=i+20|0;a=i+24|0;j=i+28|0;m=i+32|0;n=i+40|0;o=g;p=o+36|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));d[g+36>>1]=0;b[g+38>>0]=0;a:do if(fp(l,e,0)|0){f[i+48>>2]=1;_a[f[(f[l>>2]|0)+20>>2]&3](l,i,k,k,1,0);q=(f[a>>2]|0)==1?k:0}else{Za[f[(f[l>>2]|0)+24>>2]&3](l,i,k,1,0);switch(f[i+36>>2]|0){case 0:{q=(f[n>>2]|0)==1&(f[j>>2]|0)==1&(f[m>>2]|0)==1?f[c>>2]|0:0;break a;break}case 1:break;default:{q=0;break a}}if((f[a>>2]|0)!=1?!((f[n>>2]|0)==0&(f[j>>2]|0)==1&(f[m>>2]|0)==1):0){q=0;break}q=f[g>>2]|0}while(0);u=h;return q|0}function Fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){i=b;j=h;while(1){f[j>>2]=1;i=i+-1|0;if(!i)break;else j=j+4|0}f[e>>2]=h+(b<<2);return}h=f[a>>2]|0;j=g-h|0;g=j>>2;i=g+b|0;if(i>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?i:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;g=m+(l<<2)|0;l=b;i=d;while(1){f[i>>2]=1;l=l+-1|0;if(!l)break;else i=i+4|0}if((j|0)>0)kh(n|0,h|0,j|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=g;if(!h)return;Oq(h);return}function Gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(!c){g=0;u=d;return g|0}h=a+84|0;i=f[h>>2]|0;j=a+88|0;k=f[j>>2]|0;if((k|0)!=(i|0))f[j>>2]=k+(~((k+-4-i|0)>>>2)<<2);f[h>>2]=0;f[j>>2]=0;f[a+92>>2]=0;if(i|0)Oq(i);i=a+72|0;j=f[i>>2]|0;h=a+76|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;f[i>>2]=0;f[h>>2]=0;f[a+80>>2]=0;if(j|0)Oq(j);j=c+4|0;h=(f[j>>2]|0)-(f[c>>2]|0)>>2;b[e>>0]=0;qh(a,h,e);h=c+24|0;i=c+28|0;k=(f[i>>2]|0)-(f[h>>2]|0)>>2;b[e>>0]=0;qh(a+12|0,k,e);hg(a+28|0,(f[j>>2]|0)-(f[c>>2]|0)>>2,6180);gk(a+52|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);gk(a+40|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);f[a+64>>2]=c;b[a+24>>0]=1;g=1;u=d;return g|0}function Hh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(j=f[(f[d+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(k=f[(f[d+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if(((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(h=f[(f[d+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Ih(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Td(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+20>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Td(a,e);return}function Jh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=f[a+4>>2]|0;if(!d){e=0;return e|0}a=b[c+11>>0]|0;g=a<<24>>24<0;h=g?f[c+4>>2]|0:a&255;a=g?f[c>>2]|0:c;c=d;while(1){d=c+16|0;g=b[d+11>>0]|0;i=g<<24>>24<0;j=i?f[c+20>>2]|0:g&255;g=j>>>0>>0;k=g?j:h;if((k|0)!=0?(l=Vk(a,i?f[d>>2]|0:d,k)|0,(l|0)!=0):0)if((l|0)<0)m=7;else m=8;else if(h>>>0>>0)m=7;else m=8;if((m|0)==7){m=0;n=c}else if((m|0)==8){m=0;l=h>>>0>>0?h:j;if((l|0)!=0?(j=Vk(i?f[d>>2]|0:d,a,l)|0,(j|0)!=0):0){if((j|0)>=0){e=1;m=14;break}}else m=10;if((m|0)==10?(m=0,!g):0){e=1;m=14;break}n=c+4|0}c=f[n>>2]|0;if(!c){e=0;m=14;break}}if((m|0)==14)return e|0;return 0}function Kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=u;u=u+16|0;g=e+4|0;h=e;i=f[a+8>>2]|0;j=i+24|0;k=b[j>>0]|0;l=c+4|0;ag(a,(f[l>>2]|0)-(f[c>>2]|0)>>2,k,d);d=f[a+32>>2]|0;a=(f[f[d>>2]>>2]|0)+(f[d+48>>2]|0)|0;d=f[c>>2]|0;c=f[l>>2]|0;if((d|0)==(c|0)){m=1;u=e;return m|0}l=i+84|0;n=i+68|0;o=0;p=d;while(1){d=f[p>>2]|0;if(!(b[l>>0]|0))q=f[(f[n>>2]|0)+(d<<2)>>2]|0;else q=d;f[h>>2]=q;d=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(Qb(i,g,d,a+(o<<2)|0)|0)){m=0;r=7;break}p=p+4|0;if((p|0)==(c|0)){m=1;r=7;break}else o=o+k|0}if((r|0)==7){u=e;return m|0}return 0}function Lh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=1408;b=a+72|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[a+60>>2]|0;if(c|0){b=a+64|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=f[a+48>>2]|0;if(c|0)Oq(c);c=a+36|0;d=f[c>>2]|0;if(d|0){b=a+40|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Va[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(g|0))f[c>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function Mh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f[a>>2]=d;e=a+24|0;g=a+28|0;h=f[g>>2]|0;i=f[e>>2]|0;j=h-i>>2;k=i;i=h;if(j>>>0>=d>>>0){if(j>>>0>d>>>0?(h=k+(d<<2)|0,(h|0)!=(i|0)):0)f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2)}else Ci(e,d-j|0);if(!c)return;j=f[b>>2]|0;if((c|0)>1){d=j;e=j;h=1;while(1){i=f[b+(h<<2)>>2]|0;g=(i|0)<(e|0);k=g?i:e;l=g?d:(i|0)>(d|0)?i:d;h=h+1|0;if((h|0)==(c|0)){m=l;n=k;break}else{d=l;e=k}}}else{m=j;n=j}f[a+4>>2]=n;f[a+8>>2]=m;j=Xn(m|0,((m|0)<0)<<31>>31|0,n|0,((n|0)<0)<<31>>31|0)|0;n=I;if(!(n>>>0<0|(n|0)==0&j>>>0<2147483647))return;n=j+1|0;f[a+12>>2]=n;j=(n|0)/2|0;m=a+16|0;f[m>>2]=j;f[a+20>>2]=0-j;if(n&1|0)return;f[m>>2]=j+-1;return}function Nh(a){a=a|0;Fj(a+992|0);Fj(a+960|0);Fj(a+928|0);Fj(a+896|0);Fj(a+864|0);Fj(a+832|0);Fj(a+800|0);Fj(a+768|0);Fj(a+736|0);Fj(a+704|0);Fj(a+672|0);Fj(a+640|0);Fj(a+608|0);Fj(a+576|0);Fj(a+544|0);Fj(a+512|0);Fj(a+480|0);Fj(a+448|0);Fj(a+416|0);Fj(a+384|0);Fj(a+352|0);Fj(a+320|0);Fj(a+288|0);Fj(a+256|0);Fj(a+224|0);Fj(a+192|0);Fj(a+160|0);Fj(a+128|0);Fj(a+96|0);Fj(a+64|0);Fj(a+32|0);Fj(a);return}function Oh(a){a=a|0;wn(a);wn(a+32|0);wn(a+64|0);wn(a+96|0);wn(a+128|0);wn(a+160|0);wn(a+192|0);wn(a+224|0);wn(a+256|0);wn(a+288|0);wn(a+320|0);wn(a+352|0);wn(a+384|0);wn(a+416|0);wn(a+448|0);wn(a+480|0);wn(a+512|0);wn(a+544|0);wn(a+576|0);wn(a+608|0);wn(a+640|0);wn(a+672|0);wn(a+704|0);wn(a+736|0);wn(a+768|0);wn(a+800|0);wn(a+832|0);wn(a+864|0);wn(a+896|0);wn(a+928|0);wn(a+960|0);wn(a+992|0);return}function Ph(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c+12|0;e=c+8|0;g=c+4|0;h=c;i=(a|0)==(b|0);if(!i){f[g>>2]=f[b>>2];f[h>>2]=b+4;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a,e,d)}if(!i){f[g>>2]=f[b+12>>2];f[h>>2]=b+16;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Hc(a+12|0,e,d)}if(i){u=c;return}f[g>>2]=f[b+24>>2];f[h>>2]=b+28;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a+24|0,e,d);u=c;return}function Qh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+16|0;e=a;if((c|0)<0|((b|0)==0|(d|0)==0)){g=0;u=a;return g|0}h=f[b+8>>2]|0;if(((f[b+12>>2]|0)-h>>2|0)<=(c|0)){g=0;u=a;return g|0}i=b+4|0;if(!(f[i>>2]|0)){j=ln(52)|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;n[j+16>>2]=$(1.0);k=j+20|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;n[j+36>>2]=$(1.0);f[j+40>>2]=0;f[j+44>>2]=0;f[j+48>>2]=0;f[b+4>>2]=j}j=f[(f[h+(c<<2)>>2]|0)+60>>2]|0;c=ln(44)|0;Ub(c,d);f[c+40>>2]=j;j=f[i>>2]|0;f[e>>2]=c;mk(j,e)|0;j=f[e>>2]|0;f[e>>2]=0;if(!j){g=1;u=a;return g|0}bj(j);Oq(j);g=1;u=a;return g|0}function Rh(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0;c=u;u=u+64|0;j=c;k=i?6:5;Il(j);i=f[h+56>>2]|0;h=X(Vl(k)|0,e)|0;Jj(j,i,0,e&255,k,0,h,((h|0)<0)<<31>>31,0,0);h=ln(96)|0;tl(h,j);f[a>>2]=h;Bj(h,d)|0;d=h+84|0;if(!g){b[d>>0]=1;a=f[h+68>>2]|0;j=h+72|0;k=f[j>>2]|0;if((k|0)==(a|0)){u=c;return}f[j>>2]=k+(~((k+-4-a|0)>>>2)<<2);u=c;return}b[d>>0]=0;d=h+68|0;a=h+72|0;h=f[a>>2]|0;k=f[d>>2]|0;j=h-k>>2;e=h;if(j>>>0>>0){Ch(d,g-j|0,1216);u=c;return}if(j>>>0<=g>>>0){u=c;return}j=k+(g<<2)|0;if((j|0)==(e|0)){u=c;return}f[a>>2]=e+(~((e+-4-j|0)>>>2)<<2);u=c;return}function Sh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){rd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;rd(a,e);return}function Th(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){vd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;vd(a,e);return}function Uh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Fd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Fd(a,e);return}function Vh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Pd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Pd(a,e);return}function Wh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){ud(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;ud(a,e);return}function Xh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){zd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;zd(a,e);return}function Yh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Jd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Jd(a,e);return}function Zh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;sd(a,e);return}function _h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){wd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;wd(a,e);return}function $h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Gd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Gd(a,e);return}function ai(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Qd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Qd(a,e);return}function bi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case -1:{if((mi(c)|0)==10)m=6;else m=5;break}case 1:{m=5;break}default:m=6}if((m|0)==5){i=ln(60)|0;Lo(i);n=i}else if((m|0)==6){m=ln(56)|0;tp(m);n=m}xo(n,d);Md(a,n,c,e);Va[f[(f[n>>2]|0)+4>>2]&127](n);u=g;return}function ci(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;b[h>>0]=a&127;do if(a>>>0>127){b[h>>0]=a|128;i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;k=ci(a>>>7,c)|0;break}}else{i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;l=1;u=d;return l|0}while(0);l=k;u=d;return l|0} +function vc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+8|0;j=e+4|0;k=e;switch(f[c+28>>2]|0){case 9:{l=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=l;f[g>>2]=f[h>>2];m=hc(a,c,g)|0;break}case 2:{f[i>>2]=l;f[g>>2]=f[i>>2];m=Wb(a,c,g)|0;break}case 3:{f[j>>2]=l;f[g>>2]=f[j>>2];m=uc(a,c,g)|0;break}case 4:{f[k>>2]=l;f[g>>2]=f[k>>2];m=mc(a,c,g)|0;break}default:m=0}n=m;break}case 1:{m=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=m;f[g>>2]=f[h>>2];o=gc(a,c,g)|0;break}case 2:{f[i>>2]=m;f[g>>2]=f[i>>2];o=Xb(a,c,g)|0;break}case 3:{f[j>>2]=m;f[g>>2]=f[j>>2];o=sc(a,c,g)|0;break}case 4:{f[k>>2]=m;f[g>>2]=f[k>>2];o=lc(a,c,g)|0;break}default:o=0}n=o;break}case 11:case 2:{o=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=o;f[g>>2]=f[h>>2];p=gc(a,c,g)|0;break}case 2:{f[i>>2]=o;f[g>>2]=f[i>>2];p=Xb(a,c,g)|0;break}case 3:{f[j>>2]=o;f[g>>2]=f[j>>2];p=sc(a,c,g)|0;break}case 4:{f[k>>2]=o;f[g>>2]=f[k>>2];p=lc(a,c,g)|0;break}default:p=0}n=p;break}case 4:{p=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=p;f[g>>2]=f[h>>2];q=ec(a,c,g)|0;break}case 2:{f[i>>2]=p;f[g>>2]=f[i>>2];q=Vb(a,c,g)|0;break}case 3:{f[j>>2]=p;f[g>>2]=f[j>>2];q=nc(a,c,g)|0;break}case 4:{f[k>>2]=p;f[g>>2]=f[k>>2];q=jc(a,c,g)|0;break}default:q=0}n=q;break}case 3:{q=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=q;f[g>>2]=f[h>>2];r=ec(a,c,g)|0;break}case 2:{f[i>>2]=q;f[g>>2]=f[i>>2];r=Vb(a,c,g)|0;break}case 3:{f[j>>2]=q;f[g>>2]=f[j>>2];r=nc(a,c,g)|0;break}case 4:{f[k>>2]=q;f[g>>2]=f[k>>2];r=jc(a,c,g)|0;break}default:r=0}n=r;break}case 6:{r=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=r;f[g>>2]=f[h>>2];s=hc(a,c,g)|0;break}case 2:{f[i>>2]=r;f[g>>2]=f[i>>2];s=Wb(a,c,g)|0;break}case 3:{f[j>>2]=r;f[g>>2]=f[j>>2];s=uc(a,c,g)|0;break}case 4:{f[k>>2]=r;f[g>>2]=f[k>>2];s=mc(a,c,g)|0;break}default:s=0}n=s;break}case 5:{s=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=s;f[g>>2]=f[h>>2];t=hc(a,c,g)|0;break}case 2:{f[i>>2]=s;f[g>>2]=f[i>>2];t=Wb(a,c,g)|0;break}case 3:{f[j>>2]=s;f[g>>2]=f[j>>2];t=uc(a,c,g)|0;break}case 4:{f[k>>2]=s;f[g>>2]=f[k>>2];t=mc(a,c,g)|0;break}default:t=0}n=t;break}default:{v=-1;u=e;return v|0}}v=(n|0)==0?-1:n;u=e;return v|0}function wc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+29|0;j=e;k=e+28|0;if(!(f[(f[a+8>>2]|0)+80>>2]|0)){l=1;u=e;return l|0}b[i>>0]=-2;m=a+36|0;n=f[m>>2]|0;if(n)if(Ra[f[(f[a>>2]|0)+40>>2]&127](a,n)|0){n=f[m>>2]|0;o=(Qa[f[(f[n>>2]|0)+8>>2]&127](n)|0)&255;b[i>>0]=o;p=5}else q=0;else p=5;if((p|0)==5){o=d+16|0;n=o;r=f[n+4>>2]|0;if(!((r|0)>0|(r|0)==0&(f[n>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0}i=f[m>>2]|0;if(i|0?(n=(Qa[f[(f[i>>2]|0)+36>>2]&127](i)|0)&255,b[j>>0]=n,n=o,i=f[n+4>>2]|0,!((i|0)>0|(i|0)==0&(f[n>>2]|0)>>>0>0)):0){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,j,j+1|0)|0}n=f[a+32>>2]|0;i=b[n+24>>0]|0;r=X(f[n+80>>2]|0,i)|0;s=(f[f[n>>2]>>2]|0)+(f[n+48>>2]|0)|0;f[j>>2]=0;n=j+4|0;f[n>>2]=0;f[j+8>>2]=0;t=(r|0)==0;do if(!t)if(r>>>0>1073741823)aq(j);else{v=r<<2;w=ln(v)|0;f[j>>2]=w;x=w+(r<<2)|0;f[j+8>>2]=x;sj(w|0,0,v|0)|0;f[n>>2]=x;y=w;break}else y=0;while(0);w=f[m>>2]|0;do if(w){Ta[f[(f[w>>2]|0)+44>>2]&31](w,s,y,r,i,f[c>>2]|0)|0;x=f[m>>2]|0;if(!x){z=s;A=f[j>>2]|0;p=20;break}if(!(Qa[f[(f[x>>2]|0)+32>>2]&127](x)|0)){x=f[j>>2]|0;z=f[m>>2]|0?x:s;A=x;p=20}}else{z=s;A=y;p=20}while(0);if((p|0)==20)xm(z,r,A);A=a+4|0;a=f[A>>2]|0;do if(a){z=f[a+48>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;y=ln(48)|0;f[g>>2]=y;f[g+8>>2]=-2147483600;f[g+4>>2]=34;s=y;w=10697;x=s+34|0;do{b[s>>0]=b[w>>0]|0;s=s+1|0;w=w+1|0}while((s|0)<(x|0));b[y+34>>0]=0;w=Yj(z,g,1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!w){if(!t){w=f[j>>2]|0;s=0;x=0;do{x=f[w+(s<<2)>>2]|x;s=s+1|0}while((s|0)!=(r|0));if(x)B=((_(x|0)|0)>>>3^3)+1|0;else B=1}else B=1;b[k>>0]=0;s=o;w=f[s>>2]|0;z=f[s+4>>2]|0;if((z|0)>0|(z|0)==0&w>>>0>0){C=z;D=w}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0;w=o;C=f[w+4>>2]|0;D=f[w>>2]|0}b[k>>0]=B;if(!((C|0)>0|(C|0)==0&D>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}if((B|0)==(Vl(5)|0)){w=f[j>>2]|0;z=o;s=f[z+4>>2]|0;if(!((s|0)>0|(s|0)==0&(f[z>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,w,w+(r<<2)|0)|0}p=48;break}if(t)p=48;else{w=d+4|0;z=0;do{s=(f[j>>2]|0)+(z<<2)|0;y=o;v=f[y+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[y>>2]|0)>>>0>0)){f[h>>2]=f[w>>2];f[g>>2]=f[h>>2];Me(d,g,s,s+B|0)|0}z=z+1|0}while(z>>>0>>0);p=48}}else p=27}else p=27;while(0);if((p|0)==27){b[k>>0]=1;r=o;o=f[r+4>>2]|0;if(!((o|0)>0|(o|0)==0&(f[r>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}lp(g);k=f[A>>2]|0;if(k|0)Zj(g,10-(mi(f[k+48>>2]|0)|0)|0)|0;k=Mc(f[j>>2]|0,X((f[c+4>>2]|0)-(f[c>>2]|0)>>2,i)|0,i,g,d)|0;Ej(g,f[g+4>>2]|0);if(k)p=48;else E=0}if((p|0)==48){p=f[m>>2]|0;if(!p)E=1;else{Ra[f[(f[p>>2]|0)+40>>2]&127](p,d)|0;E=1}}d=f[j>>2]|0;if(d|0){j=f[n>>2]|0;if((j|0)!=(d|0))f[n>>2]=j+(~((j+-4-d|0)>>>2)<<2);Oq(d)}q=E}l=q;u=e;return l|0}function xc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0;b=u;u=u+48|0;c=b+24|0;d=b+12|0;e=b;g=a+32|0;h=a+8|0;i=a+12|0;j=f[i>>2]|0;k=f[h>>2]|0;l=j-k>>2;m=a+36|0;n=f[m>>2]|0;o=f[g>>2]|0;p=n-o>>2;q=o;o=n;n=k;if(l>>>0<=p>>>0)if(l>>>0

    >>0:0)break;s=yg(a,d,g)|0;return s|0}while(0);if(m){f[d>>2]=c;s=i+4|0;return s|0}else{f[d>>2]=t;s=t;return s|0}}while(0);t=f[i>>2]|0;do if((f[a>>2]|0)==(i|0))v=c;else{if(!t){h=i;while(1){e=f[h+8>>2]|0;if((f[e>>2]|0)==(h|0))h=e;else{w=e;break}}}else{h=t;while(1){m=f[h+4>>2]|0;if(!m){w=h;break}else h=m}}h=w;m=w+16|0;e=b[g+11>>0]|0;o=e<<24>>24<0;n=o?f[g+4>>2]|0:e&255;e=b[m+11>>0]|0;j=e<<24>>24<0;p=j?f[w+20>>2]|0:e&255;e=n>>>0

    >>0?n:p;if((e|0)!=0?(u=Vk(j?f[m>>2]|0:m,o?f[g>>2]|0:g,e)|0,(u|0)!=0):0){if((u|0)<0){v=h;break}}else r=13;if((r|0)==13?p>>>0>>0:0){v=h;break}s=yg(a,d,g)|0;return s|0}while(0);if(!t){f[d>>2]=i;s=i;return s|0}else{f[d>>2]=v;s=v+4|0;return s|0}return 0}function Ld(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a;h=b;i=h;j=c;k=d;l=k;if(!i){m=(e|0)!=0;if(!l){if(m){f[e>>2]=(g>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(g>>>0)/(j>>>0)>>>0;return (I=n,o)|0}else{if(!m){n=0;o=0;return (I=n,o)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;n=0;o=0;return (I=n,o)|0}}m=(l|0)==0;do if(j){if(!m){p=(_(l|0)|0)-(_(i|0)|0)|0;if(p>>>0<=31){q=p+1|0;r=31-p|0;s=p-31>>31;t=q;u=g>>>(q>>>0)&s|i<>>(q>>>0)&s;w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}r=j-1|0;if(r&j|0){s=(_(j|0)|0)+33-(_(i|0)|0)|0;q=64-s|0;p=32-s|0;y=p>>31;z=s-32|0;A=z>>31;t=s;u=p-1>>31&i>>>(z>>>0)|(i<>>(s>>>0))&A;v=A&i>>>(s>>>0);w=g<>>(z>>>0))&y|g<>31;break}if(e|0){f[e>>2]=r&g;f[e+4>>2]=0}if((j|0)==1){n=h|b&0;o=a|0|0;return (I=n,o)|0}else{r=vm(j|0)|0;n=i>>>(r>>>0)|0;o=i<<32-r|g>>>(r>>>0)|0;return (I=n,o)|0}}else{if(m){if(e|0){f[e>>2]=(i>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(i>>>0)/(j>>>0)>>>0;return (I=n,o)|0}if(!g){if(e|0){f[e>>2]=0;f[e+4>>2]=(i>>>0)%(l>>>0)}n=0;o=(i>>>0)/(l>>>0)>>>0;return (I=n,o)|0}r=l-1|0;if(!(r&l)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=r&i|b&0}n=0;o=i>>>((vm(l|0)|0)>>>0);return (I=n,o)|0}r=(_(l|0)|0)-(_(i|0)|0)|0;if(r>>>0<=30){s=r+1|0;p=31-r|0;t=s;u=i<>>(s>>>0);v=i>>>(s>>>0);w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}while(0);if(!t){B=x;C=w;D=v;E=u;F=0;G=0}else{b=c|0|0;c=k|d&0;d=Vn(b|0,c|0,-1,-1)|0;k=I;h=x;x=w;w=v;v=u;u=t;t=0;do{a=h;h=x>>>31|h<<1;x=t|x<<1;g=v<<1|a>>>31|0;a=v>>>31|w<<1|0;Xn(d|0,k|0,g|0,a|0)|0;i=I;l=i>>31|((i|0)<0?-1:0)<<1;t=l&1;v=Xn(g|0,a|0,l&b|0,(((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1)&c|0)|0;w=I;u=u-1|0}while((u|0)!=0);B=h;C=x;D=w;E=v;F=0;G=t}t=C;C=0;if(e|0){f[e>>2]=E;f[e+4>>2]=D}n=(t|0)>>>31|(B|C)<<1|(C<<1|t>>>31)&0|F;o=(t<<1|0>>>31)&-2|G;return (I=n,o)|0}function Md(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=u;u=u+16|0;h=g;f[c+48>>2]=d;f[c+44>>2]=e;e=f[c+8>>2]|0;d=c+12|0;i=f[d>>2]|0;if((i|0)!=(e|0)){j=i;do{i=j+-4|0;f[d>>2]=i;k=f[i>>2]|0;f[i>>2]=0;if(k|0)Va[f[(f[k>>2]|0)+4>>2]&127](k);j=f[d>>2]|0}while((j|0)!=(e|0))}e=f[c+20>>2]|0;j=c+24|0;d=f[j>>2]|0;if((d|0)!=(e|0))f[j>>2]=d+(~((d+-4-e|0)>>>2)<<2);e=f[c+32>>2]|0;d=c+36|0;j=f[d>>2]|0;if((j|0)!=(e|0))f[d>>2]=j+(~((j+-4-e|0)>>>2)<<2);if(!(f[c+4>>2]|0)){e=ln(32)|0;f[h>>2]=e;f[h+8>>2]=-2147483616;f[h+4>>2]=23;l=e;m=15706;n=l+23|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+23>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}Ud(a,c);if(f[a>>2]|0){u=g;return}e=a+4|0;j=e+11|0;if((b[j>>0]|0)<0)Oq(f[e>>2]|0);Wi(a,c);if(f[a>>2]|0){u=g;return}if((b[j>>0]|0)<0)Oq(f[e>>2]|0);if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=29;l=j;m=15730;n=l+29|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+29>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+20>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15760;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+24>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15792;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(Qa[f[(f[c>>2]|0)+28>>2]&127](c)|0){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=g;return}c=ln(48)|0;f[h>>2]=c;f[h+8>>2]=-2147483600;f[h+4>>2]=34;l=c;m=15824;n=l+34|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+34>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}function Nd(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+32|0;d=c+4|0;e=c;g=c+16|0;h=a+48|0;i=f[h>>2]|0;j=ln(32)|0;f[d>>2]=j;f[d+8>>2]=-2147483616;f[d+4>>2]=20;k=j;l=14538;m=k+20|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[j+20>>0]=0;j=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=f[h>>2]|0;n=ln(32)|0;f[d>>2]=n;f[d+8>>2]=-2147483616;f[d+4>>2]=22;k=n;l=14559;m=k+22|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[n+22>>0]=0;n=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=a+56|0;o=f[i>>2]|0;f[i>>2]=0;if(o|0)Va[f[(f[o>>2]|0)+4>>2]&127](o);o=f[a+52>>2]|0;p=(((f[o+100>>2]|0)-(f[o+96>>2]|0)|0)/12|0)>>>0<1e3;o=f[h>>2]|0;q=ln(32)|0;f[d>>2]=q;f[d+8>>2]=-2147483616;f[d+4>>2]=18;k=q;l=14582;m=k+18|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[q+18>>0]=0;q=Hk(o,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);switch(q|0){case -1:{if(j?p|((mi(f[h>>2]|0)|0)>4|n^1):0)r=13;else r=17;break}case 0:{if(j)r=13;else r=21;break}case 2:{r=17;break}default:r=21}if((r|0)==13){j=f[a+44>>2]|0;b[g>>0]=0;n=j+16|0;h=f[n+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[n>>2]|0)>>>0>0)){f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0}j=ln(296)|0;_i(j);n=f[i>>2]|0;f[i>>2]=j;if(!n)s=j;else{Va[f[(f[n>>2]|0)+4>>2]&127](n);r=21}}else if((r|0)==17){n=f[a+44>>2]|0;b[g>>0]=2;j=n+16|0;h=f[j+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[j>>2]|0)>>>0>0)){f[e>>2]=f[n+4>>2];f[d>>2]=f[e>>2];Me(n,d,g,g+1|0)|0}g=ln(360)|0;xi(g);d=f[i>>2]|0;f[i>>2]=g;if(!d)s=g;else{Va[f[(f[d>>2]|0)+4>>2]&127](d);r=21}}if((r|0)==21){r=f[i>>2]|0;if(!r){t=0;u=c;return t|0}else s=r}t=Ra[f[(f[s>>2]|0)+8>>2]&127](s,a)|0;u=c;return t|0}function Od(a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=k}if(!y)if(!z){A=y;B=z}else p=22;else if((y|0)<0&(z|0)<1){A=y;B=z}else p=22;if((p|0)==22){if(!y)C=(z|0)==0?0:(z|0)>0?3:1;else C=(y|0)>0?(z>>31)+2|0:(z|0)<1?0:3;z=f[c>>2]|0;y=f[h>>2]|0;switch(C|0){case 1:{C=c;f[C>>2]=y;f[C+4>>2]=0-z;D=f[j>>2]|0;E=0-(f[d>>2]|0)|0;break}case 2:{C=c;f[C>>2]=0-z;f[C+4>>2]=0-y;D=0-(f[d>>2]|0)|0;E=0-(f[j>>2]|0)|0;break}case 3:{C=c;f[C>>2]=0-y;f[C+4>>2]=z;D=0-(f[j>>2]|0)|0;E=f[d>>2]|0;break}default:{C=c;f[C>>2]=z;f[C+4>>2]=y;D=f[d>>2]|0;E=f[j>>2]|0}}j=d;f[j>>2]=D;f[j+4>>2]=E;A=D;B=E}E=(f[c>>2]|0)-A|0;f[a>>2]=E;A=(f[h>>2]|0)-B|0;B=a+4|0;f[B>>2]=A;if((E|0)<0)F=(f[b+4>>2]|0)+E|0;else F=E;f[a>>2]=F;if((A|0)>=0){G=A;f[B>>2]=G;return}G=(f[b+4>>2]|0)+A|0;f[B>>2]=G;return}function Pd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){b:do if(i){g=l;c=m;j=n;while(1){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((d[p>>1]|0)==(d[v+8>>1]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}c=f[e>>2]|0;if(!c){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;c=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(b>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=c;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((d[x>>1]|0)==(d[A+8>>1]|0))z=A;else break}f[c>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;c=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Qd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){b:do if(i){g=l;d=m;j=n;while(1){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((b[p>>0]|0)==(b[v+8>>0]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}d=f[e>>2]|0;if(!d){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;d=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(c>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=d;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((b[x>>0]|0)==(b[A+8>>0]|0))z=A;else break}f[d>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;d=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Rd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;g=f[c>>2]|0;c=f[b>>2]|0;h=g-c|0;i=a+8|0;j=f[i>>2]|0;if(h>>>0<64){if(j>>>0<=1){k=0;return k|0}l=f[e>>2]|0;m=0;n=1;while(1){o=(f[l+(m<<2)>>2]|0)>>>0>(f[l+(n<<2)>>2]|0)>>>0?n:m;n=n+1|0;if(n>>>0>=j>>>0){k=o;break}else m=o}return k|0}if(j){j=f[a+1128>>2]|0;m=f[e>>2]|0;e=f[a+1140>>2]|0;n=f[d>>2]|0;d=b+4|0;l=b+8|0;if((g|0)==(c|0)){b=0;do{o=j+(b<<2)|0;f[o>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){p=f[o>>2]|0;q=h-p|0;f[o>>2]=q>>>0

    >>0?p:q}b=b+1|0;q=f[i>>2]|0}while(b>>>0>>0);r=q}else{b=0;do{q=j+(b<<2)|0;f[q>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){o=(f[n+(b<<2)>>2]|0)+(1<>2]|0;s=f[(f[d>>2]|0)+24>>2]|0;t=c;u=f[q>>2]|0;do{v=s+((X(t,p)|0)<<2)+(b<<2)|0;u=u+((f[v>>2]|0)>>>0>>0&1)|0;f[q>>2]=u;t=t+1|0}while((t|0)!=(g|0));t=h-u|0;f[q>>2]=t>>>0>>0?u:t}b=b+1|0;t=f[i>>2]|0}while(b>>>0>>0);r=t}if(r){b=f[a+1140>>2]|0;i=a+1128|0;h=0;g=0;c=0;while(1){if(!(f[b+(g<<2)>>2]|0)){w=h;x=c}else{d=f[(f[i>>2]|0)+(g<<2)>>2]|0;l=h>>>0>>0;w=l?d:h;x=l?g:c}g=g+1|0;if(g>>>0>=r>>>0){y=x;break}else{h=w;c=x}}}else y=0}else y=0;x=a+1088|0;c=a+1104|0;w=f[c>>2]|0;h=32-w|0;if((h|0)<4){r=y&15;g=4-h|0;f[c>>2]=g;h=a+1100|0;i=f[h>>2]|r>>>g;f[h>>2]=i;g=a+1092|0;b=f[g>>2]|0;if((b|0)==(f[a+1096>>2]|0))Ri(x,h);else{f[b>>2]=i;f[g>>2]=b+4}f[h>>2]=r<<32-(f[c>>2]|0);k=y;return k|0}r=a+1100|0;h=f[r>>2]|y<<28>>>w;f[r>>2]=h;b=w+4|0;f[c>>2]=b;if((b|0)!=32){k=y;return k|0}b=a+1092|0;w=f[b>>2]|0;if((w|0)==(f[a+1096>>2]|0))Ri(x,r);else{f[w>>2]=h;f[b>>2]=w+4}f[r>>2]=0;f[c>>2]=0;k=y;return k|0}function Sd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){b:do if(h){e=k;c=l;i=m;while(1){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0))break;o=(f[a>>2]|0)+(n<<2)|0;if(!(f[o>>2]|0)){p=d;q=i;r=n;s=o;break b}o=d+8|0;t=d;while(1){u=f[t>>2]|0;if(!u)break;if((f[o>>2]|0)==(f[u+8>>2]|0))t=u;else break}f[i>>2]=u;f[t>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;o=f[e>>2]|0;if(!o){v=37;break a}else d=o}c=f[d>>2]|0;if(!c){v=37;break a}else{e=d;i=d}}}else{i=k;e=l;c=m;while(1){o=e;while(1){w=f[o+4>>2]|0;if(w>>>0>>0)x=w;else x=(w>>>0)%(b>>>0)|0;if((x|0)==(j|0))break;w=(f[a>>2]|0)+(x<<2)|0;if(!(f[w>>2]|0)){p=o;q=c;r=x;s=w;break b}w=o+8|0;y=o;while(1){z=f[y>>2]|0;if(!z)break;if((f[w>>2]|0)==(f[z+8>>2]|0))y=z;else break}f[c>>2]=z;f[y>>2]=f[f[(f[a>>2]|0)+(x<<2)>>2]>>2];f[f[(f[a>>2]|0)+(x<<2)>>2]>>2]=o;w=f[i>>2]|0;if(!w){v=37;break a}else o=w}e=f[o>>2]|0;if(!e){v=37;break a}else{i=o;c=o}}}while(0);f[s>>2]=q;l=f[p>>2]|0;if(!l){v=37;break}else{j=r;k=p;m=p}}if((v|0)==37)return}function Td(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;e=a+24|0;k=j;j=g;l=d;d=g;a:while(1){g=j;m=l;n=d;b:while(1){o=m;while(1){p=f[o+4>>2]|0;if(!i)if(p>>>0>>0)q=p;else q=(p>>>0)%(c>>>0)|0;else q=p&h;if((q|0)==(k|0))break;r=(f[a>>2]|0)+(q<<2)|0;if(!(f[r>>2]|0))break b;p=f[o>>2]|0;c:do if(!p)s=o;else{t=f[o+8>>2]|0;u=f[e>>2]|0;v=f[u+8>>2]|0;w=(f[u+12>>2]|0)-v|0;u=v;v=w>>>2;if((w|0)>0){x=o;y=p}else{w=p;while(1){z=f[w>>2]|0;if(!z){s=w;break c}else w=z}}while(1){w=f[y+8>>2]|0;z=0;do{A=f[u+(z<<2)>>2]|0;if(!(b[A+84>>0]|0)){B=f[A+68>>2]|0;C=f[B+(w<<2)>>2]|0;D=f[B+(t<<2)>>2]|0}else{C=w;D=t}z=z+1|0;if((D|0)!=(C|0)){s=x;break c}}while((z|0)<(v|0));z=f[y>>2]|0;if(!z){s=y;break}else{w=y;y=z;x=w}}}while(0);f[n>>2]=f[s>>2];f[s>>2]=f[f[(f[a>>2]|0)+(q<<2)>>2]>>2];f[f[(f[a>>2]|0)+(q<<2)>>2]>>2]=o;p=f[g>>2]|0;if(!p){E=38;break a}else o=p}m=f[o>>2]|0;if(!m){E=38;break a}else{g=o;n=o}}f[r>>2]=n;l=f[o>>2]|0;if(!l){E=38;break}else{k=q;j=o;d=o}}if((E|0)==38)return}function Ud(a,c){a=a|0;c=c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s>>2]=r;r=h>>>0>1073741823?-1:h<<2;s=Lq(r)|0;q=Lq(r)|0;r=c+48|0;o=f[r>>2]|0;g=c+40|0;a=f[g>>2]|0;l=f[c>>2]|0;kh(q|0,(f[l>>2]|0)+o|0,a|0)|0;kh(p|0,(f[l>>2]|0)+o|0,a|0)|0;a=r;r=f[a>>2]|0;o=f[a+4>>2]|0;a=g;g=f[a>>2]|0;l=f[a+4>>2]|0;a=f[c>>2]|0;kh(s|0,(f[a>>2]|0)+r|0,g|0)|0;p=f[c+80>>2]|0;a:do if(p>>>0>1){if(d<<24>>24<=0){c=1;while(1){m=un(g|0,l|0,c|0,0)|0;t=Vn(m|0,I|0,r|0,o|0)|0;kh(q|0,(f[a>>2]|0)+t|0,g|0)|0;c=c+1|0;if(c>>>0>=p>>>0)break a}}c=f[k>>2]|0;t=1;do{m=un(g|0,l|0,t|0,0)|0;v=Vn(m|0,I|0,r|0,o|0)|0;kh(q|0,(f[a>>2]|0)+v|0,g|0)|0;v=0;do{m=c+(v<<2)|0;w=$(n[m>>2]);x=q+(v<<2)|0;y=$(n[x>>2]);if(w>y){n[m>>2]=y;z=$(n[x>>2])}else z=y;x=s+(v<<2)|0;if($(n[x>>2])>2]=z;v=v+1|0}while((v|0)!=(h|0));t=t+1|0}while(t>>>0

    >>0)}while(0);if(d<<24>>24>0){d=f[k>>2]|0;k=0;z=$(n[j>>2]);while(1){y=$(n[s+(k<<2)>>2]);w=$(y-$(n[d+(k<<2)>>2]));if(w>z){n[j>>2]=w;A=w}else A=z;k=k+1|0;if((k|0)==(h|0))break;else z=A}}Mq(q);Mq(s);i=1;u=e;return i|0}function Xd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a+8|0;Mh(g,b,d,e);h=d-e|0;if((h|0)>0){d=0-e|0;i=a+16|0;j=a+32|0;k=a+12|0;l=a+28|0;m=a+20|0;n=a+24|0;o=h;h=f[g>>2]|0;while(1){p=b+(o<<2)|0;q=c+(o<<2)|0;if((h|0)>0){r=0;s=p+(d<<2)|0;t=h;while(1){if((t|0)>0){u=0;do{v=f[s+(u<<2)>>2]|0;w=f[i>>2]|0;if((v|0)>(w|0)){x=f[j>>2]|0;f[x+(u<<2)>>2]=w;y=x}else{x=f[k>>2]|0;w=f[j>>2]|0;f[w+(u<<2)>>2]=(v|0)<(x|0)?x:v;y=w}u=u+1|0}while((u|0)<(f[g>>2]|0));z=y}else z=f[j>>2]|0;u=(f[p+(r<<2)>>2]|0)-(f[z+(r<<2)>>2]|0)|0;w=q+(r<<2)|0;f[w>>2]=u;if((u|0)>=(f[l>>2]|0)){if((u|0)>(f[n>>2]|0)){A=u-(f[m>>2]|0)|0;B=31}}else{A=(f[m>>2]|0)+u|0;B=31}if((B|0)==31){B=0;f[w>>2]=A}r=r+1|0;w=f[g>>2]|0;if((r|0)>=(w|0)){C=w;break}else{s=z;t=w}}}else C=h;o=o-e|0;if((o|0)<=0){D=C;break}else h=C}}else D=f[g>>2]|0;C=e>>>0>1073741823?-1:e<<2;e=Lq(C)|0;sj(e|0,0,C|0)|0;if((D|0)<=0){Mq(e);return 1}C=a+16|0;h=a+32|0;o=a+12|0;z=a+28|0;A=a+20|0;m=a+24|0;a=0;n=e;l=D;while(1){if((l|0)>0){D=0;do{j=f[n+(D<<2)>>2]|0;y=f[C>>2]|0;if((j|0)>(y|0)){k=f[h>>2]|0;f[k+(D<<2)>>2]=y;E=k}else{k=f[o>>2]|0;y=f[h>>2]|0;f[y+(D<<2)>>2]=(j|0)<(k|0)?k:j;E=y}D=D+1|0}while((D|0)<(f[g>>2]|0));F=E}else F=f[h>>2]|0;D=(f[b+(a<<2)>>2]|0)-(f[F+(a<<2)>>2]|0)|0;y=c+(a<<2)|0;f[y>>2]=D;if((D|0)>=(f[z>>2]|0)){if((D|0)>(f[m>>2]|0)){G=D-(f[A>>2]|0)|0;B=16}}else{G=(f[A>>2]|0)+D|0;B=16}if((B|0)==16){B=0;f[y>>2]=G}a=a+1|0;l=f[g>>2]|0;if((a|0)>=(l|0))break;else n=F}Mq(e);return 1}function Yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;e=f[a>>2]|0;g=e;h=(f[b>>2]|0)-g|0;b=e+(h>>2<<2)|0;i=f[c>>2]|0;c=f[d>>2]|0;d=c-i|0;j=d>>2;k=i;l=c;if((d|0)<=0){m=b;return m|0}d=a+8|0;n=f[d>>2]|0;o=a+4|0;p=f[o>>2]|0;q=p;if((j|0)<=(n-q>>2|0)){r=b;s=q-r|0;t=s>>2;if((j|0)>(t|0)){u=k+(t<<2)|0;t=u;if((u|0)==(l|0))v=p;else{w=l+-4-t|0;x=u;u=p;while(1){f[u>>2]=f[x>>2];x=x+4|0;if((x|0)==(l|0))break;else u=u+4|0}u=p+((w>>>2)+1<<2)|0;f[o>>2]=u;v=u}if((s|0)>0){y=t;z=v}else{m=b;return m|0}}else{y=c;z=p}c=z-(b+(j<<2))>>2;v=b+(c<<2)|0;if(v>>>0

    >>0){t=(p+(0-c<<2)+~r|0)>>>2;r=v;s=z;while(1){f[s>>2]=f[r>>2];r=r+4|0;if(r>>>0>=p>>>0)break;else s=s+4|0}f[o>>2]=z+(t+1<<2)}if(c|0){c=v;v=z;do{c=c+-4|0;v=v+-4|0;f[v>>2]=f[c>>2]}while((c|0)!=(b|0))}c=y;if((k|0)==(c|0)){m=b;return m|0}else{A=b;B=k}while(1){f[A>>2]=f[B>>2];B=B+4|0;if((B|0)==(c|0)){m=b;break}else A=A+4|0}return m|0}A=(q-g>>2)+j|0;if(A>>>0>1073741823)aq(a);j=n-g|0;g=j>>1;n=j>>2>>>0<536870911?(g>>>0>>0?A:g):1073741823;g=b;A=h>>2;do if(n)if(n>>>0>1073741823){j=ra(8)|0;Oo(j,16035);f[j>>2]=7256;va(j|0,1112,110)}else{j=ln(n<<2)|0;C=j;D=j;break}else{C=0;D=0}while(0);j=D+(A<<2)|0;A=D+(n<<2)|0;if((l|0)==(k|0))E=j;else{n=((l+-4-i|0)>>>2)+1|0;i=k;k=j;while(1){f[k>>2]=f[i>>2];i=i+4|0;if((i|0)==(l|0))break;else k=k+4|0}E=j+(n<<2)|0}if((h|0)>0)kh(C|0,e|0,h|0)|0;h=q-g|0;if((h|0)>0){kh(E|0,b|0,h|0)|0;F=E+(h>>>2<<2)|0}else F=E;f[a>>2]=D;f[o>>2]=F;f[d>>2]=A;if(!e){m=j;return m|0}Oq(e);m=j;return m|0}function Zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+60|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+56>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=j;y=v}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;v=m;x=f[v+4>>2]|0;y=f[v>>2]|0}f[g>>2]=f[a+20>>2];if((x|0)>0|(x|0)==0&y>>>0>0){Fj(h);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(h);u=c;return 1}function _d(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;switch(b-a>>2|0){case 2:{d=b+-4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=f[c>>2]|0;i=f[h>>2]|0;j=(f[h+4>>2]|0)-i>>3;if(j>>>0<=e>>>0)aq(h);k=i;if(j>>>0<=g>>>0)aq(h);if((f[k+(e<<3)>>2]|0)>>>0>=(f[k+(g<<3)>>2]|0)>>>0){l=1;return l|0}f[a>>2]=e;f[d>>2]=g;l=1;return l|0}case 3:{Vg(a,a+4|0,b+-4|0,c)|0;l=1;return l|0}case 4:{jh(a,a+4|0,a+8|0,b+-4|0,c)|0;l=1;return l|0}case 5:{ig(a,a+4|0,a+8|0,a+12|0,b+-4|0,c)|0;l=1;return l|0}case 1:case 0:{l=1;return l|0}default:{g=a+8|0;Vg(a,a+4|0,g,c)|0;d=a+12|0;a:do if((d|0)!=(b|0)){e=f[c>>2]|0;k=f[e>>2]|0;h=(f[e+4>>2]|0)-k>>3;j=k;k=d;i=0;m=g;b:while(1){n=f[k>>2]|0;o=f[m>>2]|0;if(h>>>0<=n>>>0){p=14;break}if(h>>>0<=o>>>0){p=16;break}q=j+(n<<3)|0;if((f[q>>2]|0)>>>0<(f[j+(o<<3)>>2]|0)>>>0){r=m;s=k;t=o;while(1){f[s>>2]=t;if((r|0)==(a|0)){u=a;break}o=r+-4|0;t=f[o>>2]|0;if(h>>>0<=t>>>0){p=20;break b}if((f[q>>2]|0)>>>0>=(f[j+(t<<3)>>2]|0)>>>0){u=r;break}else{v=r;r=o;s=v}}f[u>>2]=n;s=i+1|0;if((s|0)==8){w=0;x=(k+4|0)==(b|0);break a}else y=s}else y=i;s=k+4|0;if((s|0)==(b|0)){w=1;x=0;break a}else{r=k;k=s;i=y;m=r}}if((p|0)==14)aq(e);else if((p|0)==16)aq(e);else if((p|0)==20)aq(e)}else{w=1;x=0}while(0);l=x|w;return l|0}}return 0}function $d(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+80|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+76>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=j;y=v}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;v=m;x=f[v+4>>2]|0;y=f[v>>2]|0}f[g>>2]=f[a+16>>2];if((x|0)>0|(x|0)==0&y>>>0>0){Fj(h);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(h);u=c;return 1}function ae(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;f[a+72>>2]=e;f[a+64>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;k=a+68|0;l=f[k>>2]|0;f[k>>2]=g;if(l|0)Mq(l);l=a+8|0;Mh(l,b,d,e);d=a+56|0;g=f[d>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+16|0;q=a+32|0;r=a+12|0;s=a+28|0;t=a+20|0;v=a+24|0;if(m-n>>2>>>0>p>>>0){w=p;x=n}else{y=g;aq(y)}while(1){f[j>>2]=f[x+(w<<2)>>2];f[i>>2]=f[j>>2];Dc(a,i,b,w);g=X(w,e)|0;n=b+(g<<2)|0;p=c+(g<<2)|0;g=f[l>>2]|0;if((g|0)>0){m=0;z=f[k>>2]|0;A=g;while(1){if((A|0)>0){g=0;do{B=f[z+(g<<2)>>2]|0;C=f[o>>2]|0;if((B|0)>(C|0)){D=f[q>>2]|0;f[D+(g<<2)>>2]=C;E=D}else{D=f[r>>2]|0;C=f[q>>2]|0;f[C+(g<<2)>>2]=(B|0)<(D|0)?D:B;E=C}g=g+1|0}while((g|0)<(f[l>>2]|0));F=E}else F=f[q>>2]|0;g=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);return 0} +function $a(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da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(1){h=(f[i+4>>2]&-8)-d|0;l=h>>>0>>0;j=l?h:s;h=l?i:n;i=f[i+16+(((f[i+16>>2]|0)==0&1)<<2)>>2]|0;if(!i){t=h;v=j;break}else{n=h;s=j}}}s=t+d|0;if(s>>>0>t>>>0){n=f[t+24>>2]|0;i=f[t+12>>2]|0;do if((i|0)==(t|0)){j=t+20|0;h=f[j>>2]|0;if(!h){l=t+16|0;k=f[l>>2]|0;if(!k){w=0;break}else{x=k;y=l}}else{x=h;y=j}while(1){j=x+20|0;h=f[j>>2]|0;if(h|0){x=h;y=j;continue}j=x+16|0;h=f[j>>2]|0;if(!h)break;else{x=h;y=j}}f[y>>2]=0;w=x}else{j=f[t+8>>2]|0;f[j+12>>2]=i;f[i+8>>2]=j;w=i}while(0);do if(n|0){i=f[t+28>>2]|0;j=19440+(i<<2)|0;if((t|0)==(f[j>>2]|0)){f[j>>2]=w;if(!w){f[4785]=e&~(1<>2]|0)!=(t|0)&1)<<2)>>2]=w;if(!w)break}f[w+24>>2]=n;i=f[t+16>>2]|0;if(i|0){f[w+16>>2]=i;f[i+24>>2]=w}i=f[t+20>>2]|0;if(i|0){f[w+20>>2]=i;f[i+24>>2]=w}}while(0);if(v>>>0<16){n=v+d|0;f[t+4>>2]=n|3;e=t+n+4|0;f[e>>2]=f[e>>2]|1}else{f[t+4>>2]=d|3;f[s+4>>2]=v|1;f[s+v>>2]=v;if(m|0){e=f[4789]|0;n=m>>>3;i=19176+(n<<1<<2)|0;j=1<>2]|0;A=j}f[A>>2]=e;f[z+12>>2]=e;f[e+8>>2]=z;f[e+12>>2]=i}f[4786]=v;f[4789]=s}o=t+8|0;u=b;return o|0}else B=d}else B=d}else B=d}else if(a>>>0<=4294967231){i=a+11|0;e=i&-8;j=f[4785]|0;if(j){n=0-e|0;h=i>>>8;if(h)if(e>>>0>16777215)C=31;else{i=(h+1048320|0)>>>16&8;l=h<>>16&4;k=l<>>16&2;D=14-(h|i|l)+(k<>>15)|0;C=e>>>(D+7|0)&1|D<<1}else C=0;D=f[19440+(C<<2)>>2]|0;a:do if(!D){E=0;F=0;G=n;H=57}else{l=0;k=n;i=D;h=e<<((C|0)==31?0:25-(C>>>1)|0);I=0;while(1){J=(f[i+4>>2]&-8)-e|0;if(J>>>0>>0)if(!J){K=0;L=i;M=i;H=61;break a}else{N=i;O=J}else{N=l;O=k}J=f[i+20>>2]|0;i=f[i+16+(h>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(i|0)?I:J;J=(i|0)==0;if(J){E=P;F=N;G=O;H=57;break}else{l=N;k=O;h=h<<((J^1)&1);I=P}}}while(0);if((H|0)==57){if((E|0)==0&(F|0)==0){D=2<>>12&16;d=D>>>n;D=d>>>5&8;s=d>>>D;d=s>>>2&4;g=s>>>d;s=g>>>1&2;m=g>>>s;g=m>>>1&1;Q=0;R=f[19440+((D|n|d|s|g)+(m>>>g)<<2)>>2]|0}else{Q=F;R=E}if(!R){S=Q;T=G}else{K=G;L=R;M=Q;H=61}}if((H|0)==61)while(1){H=0;g=(f[L+4>>2]&-8)-e|0;m=g>>>0>>0;s=m?g:K;g=m?L:M;L=f[L+16+(((f[L+16>>2]|0)==0&1)<<2)>>2]|0;if(!L){S=g;T=s;break}else{K=s;M=g;H=61}}if((S|0)!=0?T>>>0<((f[4786]|0)-e|0)>>>0:0){g=S+e|0;if(g>>>0<=S>>>0){o=0;u=b;return o|0}s=f[S+24>>2]|0;m=f[S+12>>2]|0;do if((m|0)==(S|0)){d=S+20|0;n=f[d>>2]|0;if(!n){D=S+16|0;I=f[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=n;W=d}while(1){d=V+20|0;n=f[d>>2]|0;if(n|0){V=n;W=d;continue}d=V+16|0;n=f[d>>2]|0;if(!n)break;else{V=n;W=d}}f[W>>2]=0;U=V}else{d=f[S+8>>2]|0;f[d+12>>2]=m;f[m+8>>2]=d;U=m}while(0);do if(s){m=f[S+28>>2]|0;d=19440+(m<<2)|0;if((S|0)==(f[d>>2]|0)){f[d>>2]=U;if(!U){d=j&~(1<>2]|0)!=(S|0)&1)<<2)>>2]=U;if(!U){X=j;break}}f[U+24>>2]=s;d=f[S+16>>2]|0;if(d|0){f[U+16>>2]=d;f[d+24>>2]=U}d=f[S+20>>2]|0;if(d){f[U+20>>2]=d;f[d+24>>2]=U;X=j}else X=j}else X=j;while(0);do if(T>>>0>=16){f[S+4>>2]=e|3;f[g+4>>2]=T|1;f[g+T>>2]=T;j=T>>>3;if(T>>>0<256){s=19176+(j<<1<<2)|0;d=f[4784]|0;m=1<>2]|0;Z=m}f[Z>>2]=g;f[Y+12>>2]=g;f[g+8>>2]=Y;f[g+12>>2]=s;break}s=T>>>8;if(s)if(T>>>0>16777215)_=31;else{m=(s+1048320|0)>>>16&8;d=s<>>16&4;j=d<>>16&2;n=14-(s|m|d)+(j<>>15)|0;_=T>>>(n+7|0)&1|n<<1}else _=0;n=19440+(_<<2)|0;f[g+28>>2]=_;d=g+16|0;f[d+4>>2]=0;f[d>>2]=0;d=1<<_;if(!(X&d)){f[4785]=X|d;f[n>>2]=g;f[g+24>>2]=n;f[g+12>>2]=g;f[g+8>>2]=g;break}d=T<<((_|0)==31?0:25-(_>>>1)|0);j=f[n>>2]|0;while(1){if((f[j+4>>2]&-8|0)==(T|0)){H=97;break}$=j+16+(d>>>31<<2)|0;n=f[$>>2]|0;if(!n){H=96;break}else{d=d<<1;j=n}}if((H|0)==96){f[$>>2]=g;f[g+24>>2]=j;f[g+12>>2]=g;f[g+8>>2]=g;break}else if((H|0)==97){d=j+8|0;n=f[d>>2]|0;f[n+12>>2]=g;f[d>>2]=g;f[g+8>>2]=n;f[g+12>>2]=j;f[g+24>>2]=0;break}}else{n=T+e|0;f[S+4>>2]=n|3;d=S+n+4|0;f[d>>2]=f[d>>2]|1}while(0);o=S+8|0;u=b;return o|0}else B=e}else B=e}else B=-1;while(0);S=f[4786]|0;if(S>>>0>=B>>>0){T=S-B|0;$=f[4789]|0;if(T>>>0>15){_=$+B|0;f[4789]=_;f[4786]=T;f[_+4>>2]=T|1;f[$+S>>2]=T;f[$+4>>2]=B|3}else{f[4786]=0;f[4789]=0;f[$+4>>2]=S|3;T=$+S+4|0;f[T>>2]=f[T>>2]|1}o=$+8|0;u=b;return o|0}$=f[4787]|0;if($>>>0>B>>>0){T=$-B|0;f[4787]=T;S=f[4790]|0;_=S+B|0;f[4790]=_;f[_+4>>2]=T|1;f[S+4>>2]=B|3;o=S+8|0;u=b;return o|0}if(!(f[4902]|0)){f[4904]=4096;f[4903]=4096;f[4905]=-1;f[4906]=-1;f[4907]=0;f[4895]=0;f[4902]=c&-16^1431655768;aa=4096}else aa=f[4904]|0;c=B+48|0;S=B+47|0;T=aa+S|0;_=0-aa|0;aa=T&_;if(aa>>>0<=B>>>0){o=0;u=b;return o|0}X=f[4894]|0;if(X|0?(Y=f[4892]|0,Z=Y+aa|0,Z>>>0<=Y>>>0|Z>>>0>X>>>0):0){o=0;u=b;return o|0}b:do if(!(f[4895]&4)){X=f[4790]|0;c:do if(X){Z=19584;while(1){Y=f[Z>>2]|0;if(Y>>>0<=X>>>0?(ba=Z+4|0,(Y+(f[ba>>2]|0)|0)>>>0>X>>>0):0)break;Y=f[Z+8>>2]|0;if(!Y){H=118;break c}else Z=Y}j=T-$&_;if(j>>>0<2147483647){Y=Nl(j|0)|0;if((Y|0)==((f[Z>>2]|0)+(f[ba>>2]|0)|0))if((Y|0)==(-1|0))ca=j;else{da=j;ea=Y;H=135;break b}else{fa=Y;ga=j;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=Nl(0)|0;if((X|0)!=(-1|0)?(e=X,j=f[4903]|0,Y=j+-1|0,U=((Y&e|0)==0?0:(Y+e&0-j)-e|0)+aa|0,e=f[4892]|0,j=U+e|0,U>>>0>B>>>0&U>>>0<2147483647):0){Y=f[4894]|0;if(Y|0?j>>>0<=e>>>0|j>>>0>Y>>>0:0){ca=0;break}Y=Nl(U|0)|0;if((Y|0)==(X|0)){da=U;ea=X;H=135;break b}else{fa=Y;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(c>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=ga;ea=fa;H=135;break b}Y=f[4904]|0;X=S-ga+Y&0-Y;if(X>>>0>=2147483647){da=ga;ea=fa;H=135;break b}if((Nl(X|0)|0)==(-1|0)){Nl(U|0)|0;ca=0;break}else{da=X+ga|0;ea=fa;H=135;break b}}while(0);f[4895]=f[4895]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=Nl(aa|0)|0,aa=Nl(0)|0,fa=aa-ca|0,ga=fa>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|ga^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ga?fa:ha;ea=ca;H=135}if((H|0)==135){ca=(f[4892]|0)+da|0;f[4892]=ca;if(ca>>>0>(f[4893]|0)>>>0)f[4893]=ca;ca=f[4790]|0;do if(ca){ha=19584;while(1){ia=f[ha>>2]|0;ja=ha+4|0;ka=f[ja>>2]|0;if((ea|0)==(ia+ka|0)){H=143;break}fa=f[ha+8>>2]|0;if(!fa)break;else ha=fa}if(((H|0)==143?(f[ha+12>>2]&8|0)==0:0)?ea>>>0>ca>>>0&ia>>>0<=ca>>>0:0){f[ja>>2]=ka+da;fa=(f[4787]|0)+da|0;ga=ca+8|0;aa=(ga&7|0)==0?0:0-ga&7;ga=ca+aa|0;S=fa-aa|0;f[4790]=ga;f[4787]=S;f[ga+4>>2]=S|1;f[ca+fa+4>>2]=40;f[4791]=f[4906];break}if(ea>>>0<(f[4788]|0)>>>0)f[4788]=ea;fa=ea+da|0;S=19584;while(1){if((f[S>>2]|0)==(fa|0)){H=151;break}ga=f[S+8>>2]|0;if(!ga){la=19584;break}else S=ga}if((H|0)==151)if(!(f[S+12>>2]&8)){f[S>>2]=ea;ha=S+4|0;f[ha>>2]=(f[ha>>2]|0)+da;ha=ea+8|0;ga=ea+((ha&7|0)==0?0:0-ha&7)|0;ha=fa+8|0;aa=fa+((ha&7|0)==0?0:0-ha&7)|0;ha=ga+B|0;c=aa-ga-B|0;f[ga+4>>2]=B|3;do if((ca|0)!=(aa|0)){if((f[4789]|0)==(aa|0)){ba=(f[4786]|0)+c|0;f[4786]=ba;f[4789]=ha;f[ha+4>>2]=ba|1;f[ha+ba>>2]=ba;break}ba=f[aa+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){T=f[aa+8>>2]|0;X=f[aa+12>>2]|0;if((X|0)==(T|0)){f[4784]=f[4784]&~(1<<$);break}else{f[T+12>>2]=X;f[X+8>>2]=T;break}}else{T=f[aa+24>>2]|0;X=f[aa+12>>2]|0;do if((X|0)==(aa|0)){U=aa+16|0;Y=U+4|0;j=f[Y>>2]|0;if(!j){e=f[U>>2]|0;if(!e){ma=0;break}else{na=e;oa=U}}else{na=j;oa=Y}while(1){Y=na+20|0;j=f[Y>>2]|0;if(j|0){na=j;oa=Y;continue}Y=na+16|0;j=f[Y>>2]|0;if(!j)break;else{na=j;oa=Y}}f[oa>>2]=0;ma=na}else{Y=f[aa+8>>2]|0;f[Y+12>>2]=X;f[X+8>>2]=Y;ma=X}while(0);if(!T)break;X=f[aa+28>>2]|0;Y=19440+(X<<2)|0;do if((f[Y>>2]|0)!=(aa|0)){f[T+16+(((f[T+16>>2]|0)!=(aa|0)&1)<<2)>>2]=ma;if(!ma)break d}else{f[Y>>2]=ma;if(ma|0)break;f[4785]=f[4785]&~(1<>2]=T;X=aa+16|0;Y=f[X>>2]|0;if(Y|0){f[ma+16>>2]=Y;f[Y+24>>2]=ma}Y=f[X+4>>2]|0;if(!Y)break;f[ma+20>>2]=Y;f[Y+24>>2]=ma}while(0);pa=aa+_|0;qa=_+c|0}else{pa=aa;qa=c}$=pa+4|0;f[$>>2]=f[$>>2]&-2;f[ha+4>>2]=qa|1;f[ha+qa>>2]=qa;$=qa>>>3;if(qa>>>0<256){ba=19176+($<<1<<2)|0;Z=f[4784]|0;Y=1<<$;if(!(Z&Y)){f[4784]=Z|Y;ra=ba;sa=ba+8|0}else{Y=ba+8|0;ra=f[Y>>2]|0;sa=Y}f[sa>>2]=ha;f[ra+12>>2]=ha;f[ha+8>>2]=ra;f[ha+12>>2]=ba;break}ba=qa>>>8;do if(!ba)ta=0;else{if(qa>>>0>16777215){ta=31;break}Y=(ba+1048320|0)>>>16&8;Z=ba<>>16&4;X=Z<<$;Z=(X+245760|0)>>>16&2;j=14-($|Y|Z)+(X<>>15)|0;ta=qa>>>(j+7|0)&1|j<<1}while(0);ba=19440+(ta<<2)|0;f[ha+28>>2]=ta;_=ha+16|0;f[_+4>>2]=0;f[_>>2]=0;_=f[4785]|0;j=1<>2]=ha;f[ha+24>>2]=ba;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}j=qa<<((ta|0)==31?0:25-(ta>>>1)|0);_=f[ba>>2]|0;while(1){if((f[_+4>>2]&-8|0)==(qa|0)){H=192;break}ua=_+16+(j>>>31<<2)|0;ba=f[ua>>2]|0;if(!ba){H=191;break}else{j=j<<1;_=ba}}if((H|0)==191){f[ua>>2]=ha;f[ha+24>>2]=_;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}else if((H|0)==192){j=_+8|0;ba=f[j>>2]|0;f[ba+12>>2]=ha;f[j>>2]=ha;f[ha+8>>2]=ba;f[ha+12>>2]=_;f[ha+24>>2]=0;break}}else{ba=(f[4787]|0)+c|0;f[4787]=ba;f[4790]=ha;f[ha+4>>2]=ba|1}while(0);o=ga+8|0;u=b;return o|0}else la=19584;while(1){ha=f[la>>2]|0;if(ha>>>0<=ca>>>0?(va=ha+(f[la+4>>2]|0)|0,va>>>0>ca>>>0):0)break;la=f[la+8>>2]|0}ga=va+-47|0;ha=ga+8|0;c=ga+((ha&7|0)==0?0:0-ha&7)|0;ha=ca+16|0;ga=c>>>0>>0?ca:c;c=ga+8|0;aa=da+-40|0;fa=ea+8|0;S=(fa&7|0)==0?0:0-fa&7;fa=ea+S|0;ba=aa-S|0;f[4790]=fa;f[4787]=ba;f[fa+4>>2]=ba|1;f[ea+aa+4>>2]=40;f[4791]=f[4906];aa=ga+4|0;f[aa>>2]=27;f[c>>2]=f[4896];f[c+4>>2]=f[4897];f[c+8>>2]=f[4898];f[c+12>>2]=f[4899];f[4896]=ea;f[4897]=da;f[4899]=0;f[4898]=c;c=ga+24|0;do{ba=c;c=c+4|0;f[c>>2]=7}while((ba+8|0)>>>0>>0);if((ga|0)!=(ca|0)){c=ga-ca|0;f[aa>>2]=f[aa>>2]&-2;f[ca+4>>2]=c|1;f[ga>>2]=c;ba=c>>>3;if(c>>>0<256){fa=19176+(ba<<1<<2)|0;S=f[4784]|0;j=1<>2]|0;xa=j}f[xa>>2]=ca;f[wa+12>>2]=ca;f[ca+8>>2]=wa;f[ca+12>>2]=fa;break}fa=c>>>8;if(fa)if(c>>>0>16777215)ya=31;else{j=(fa+1048320|0)>>>16&8;S=fa<>>16&4;ba=S<>>16&2;Z=14-(fa|j|S)+(ba<>>15)|0;ya=c>>>(Z+7|0)&1|Z<<1}else ya=0;Z=19440+(ya<<2)|0;f[ca+28>>2]=ya;f[ca+20>>2]=0;f[ha>>2]=0;S=f[4785]|0;ba=1<>2]=ca;f[ca+24>>2]=Z;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}ba=c<<((ya|0)==31?0:25-(ya>>>1)|0);S=f[Z>>2]|0;while(1){if((f[S+4>>2]&-8|0)==(c|0)){H=213;break}za=S+16+(ba>>>31<<2)|0;Z=f[za>>2]|0;if(!Z){H=212;break}else{ba=ba<<1;S=Z}}if((H|0)==212){f[za>>2]=ca;f[ca+24>>2]=S;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}else if((H|0)==213){ba=S+8|0;c=f[ba>>2]|0;f[c+12>>2]=ca;f[ba>>2]=ca;f[ca+8>>2]=c;f[ca+12>>2]=S;f[ca+24>>2]=0;break}}}else{c=f[4788]|0;if((c|0)==0|ea>>>0>>0)f[4788]=ea;f[4896]=ea;f[4897]=da;f[4899]=0;f[4793]=f[4902];f[4792]=-1;f[4797]=19176;f[4796]=19176;f[4799]=19184;f[4798]=19184;f[4801]=19192;f[4800]=19192;f[4803]=19200;f[4802]=19200;f[4805]=19208;f[4804]=19208;f[4807]=19216;f[4806]=19216;f[4809]=19224;f[4808]=19224;f[4811]=19232;f[4810]=19232;f[4813]=19240;f[4812]=19240;f[4815]=19248;f[4814]=19248;f[4817]=19256;f[4816]=19256;f[4819]=19264;f[4818]=19264;f[4821]=19272;f[4820]=19272;f[4823]=19280;f[4822]=19280;f[4825]=19288;f[4824]=19288;f[4827]=19296;f[4826]=19296;f[4829]=19304;f[4828]=19304;f[4831]=19312;f[4830]=19312;f[4833]=19320;f[4832]=19320;f[4835]=19328;f[4834]=19328;f[4837]=19336;f[4836]=19336;f[4839]=19344;f[4838]=19344;f[4841]=19352;f[4840]=19352;f[4843]=19360;f[4842]=19360;f[4845]=19368;f[4844]=19368;f[4847]=19376;f[4846]=19376;f[4849]=19384;f[4848]=19384;f[4851]=19392;f[4850]=19392;f[4853]=19400;f[4852]=19400;f[4855]=19408;f[4854]=19408;f[4857]=19416;f[4856]=19416;f[4859]=19424;f[4858]=19424;c=da+-40|0;ba=ea+8|0;ha=(ba&7|0)==0?0:0-ba&7;ba=ea+ha|0;ga=c-ha|0;f[4790]=ba;f[4787]=ga;f[ba+4>>2]=ga|1;f[ea+c+4>>2]=40;f[4791]=f[4906]}while(0);ea=f[4787]|0;if(ea>>>0>B>>>0){da=ea-B|0;f[4787]=da;ea=f[4790]|0;ca=ea+B|0;f[4790]=ca;f[ca+4>>2]=da|1;f[ea+4>>2]=B|3;o=ea+8|0;u=b;return o|0}}ea=Vq()|0;f[ea>>2]=12;o=0;u=b;return o|0}function ab(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0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}}if(Mb|0){if((Nb|0)!=(Mb|0))f[H>>2]=Nb+(~((Nb+-4-Mb|0)>>>2)<<2);Oq(Mb)}Mb=f[m>>2]|0;if(Mb|0){m=f[E>>2]|0;if((m|0)!=(Mb|0))f[E>>2]=m+(~((m+-4-Mb|0)>>>2)<<2);Oq(Mb)}Mb=f[l+36>>2]|0;if(Mb|0){m=l+40|0;E=f[m>>2]|0;if((E|0)!=(Mb|0))f[m>>2]=E+(~((E+-4-Mb|0)>>>2)<<2);Oq(Mb)}Mb=f[l+24>>2]|0;if(Mb|0){E=l+28|0;m=f[E>>2]|0;if((m|0)!=(Mb|0))f[E>>2]=m+(~((m+-4-Mb|0)>>>2)<<2);Oq(Mb)}Mb=f[l+12>>2]|0;if(Mb|0){m=l+16|0;E=f[m>>2]|0;if((E|0)!=(Mb|0))f[m>>2]=E+(~((E+-4-Mb|0)>>>2)<<2);Oq(Mb)}Mb=f[l>>2]|0;if(!Mb){u=i;return 1}E=l+4|0;l=f[E>>2]|0;if((l|0)!=(Mb|0))f[E>>2]=l+(~((l+-4-Mb|0)>>>2)<<2);Oq(Mb);u=i;return 1}function cb(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;b=u;u=u+16|0;c=b;d=b+8|0;e=b+4|0;f[d>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;h=g*210|0;f[e>>2]=a-h;i=0;j=g;g=(Hl(6952,7144,e,c)|0)-6952>>2;k=h;a:while(1){l=(f[6952+(g<<2)>>2]|0)+k|0;h=5;while(1){if(h>>>0>=47){m=211;n=i;o=8;break}p=f[6760+(h<<2)>>2]|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0

    >>0){o=106;break a}if((l|0)==(X(q,p)|0)){r=i;break}else h=h+1|0}b:do if((o|0)==8){c:while(1){o=0;h=(l>>>0)/(m>>>0)|0;do if(h>>>0>=m>>>0)if((l|0)!=(X(h,m)|0)){p=m+10|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0>=p>>>0)if((l|0)!=(X(q,p)|0)){q=m+12|0;s=(l>>>0)/(q>>>0)|0;if(s>>>0>=q>>>0)if((l|0)!=(X(s,q)|0)){s=m+16|0;t=(l>>>0)/(s>>>0)|0;if(t>>>0>=s>>>0)if((l|0)!=(X(t,s)|0)){t=m+18|0;v=(l>>>0)/(t>>>0)|0;if(v>>>0>=t>>>0)if((l|0)!=(X(v,t)|0)){v=m+22|0;w=(l>>>0)/(v>>>0)|0;if(w>>>0>=v>>>0)if((l|0)!=(X(w,v)|0)){w=m+28|0;x=(l>>>0)/(w>>>0)|0;if(x>>>0>=w>>>0)if((l|0)==(X(x,w)|0)){y=w;z=9;A=n}else{x=m+30|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+36|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+40|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+42|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+46|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+52|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+58|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+60|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+66|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+70|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+72|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+78|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+82|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+88|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+96|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+100|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+102|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+106|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+108|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+112|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+120|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+126|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+130|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+136|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+138|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+142|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+148|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+150|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+156|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+162|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+166|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+168|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+172|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+178|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+180|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+186|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+190|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+192|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+196|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+198|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+208|0;B=(l>>>0)/(x>>>0)|0;C=B>>>0>>0;D=(l|0)==(X(B,x)|0);y=C|D?x:m+210|0;z=C?1:D?9:0;A=C?l:n}else{y=w;z=1;A=l}}else{y=v;z=9;A=n}else{y=v;z=1;A=l}}else{y=t;z=9;A=n}else{y=t;z=1;A=l}}else{y=s;z=9;A=n}else{y=s;z=1;A=l}}else{y=q;z=9;A=n}else{y=q;z=1;A=l}}else{y=p;z=9;A=n}else{y=p;z=1;A=l}}else{y=m;z=9;A=n}else{y=m;z=1;A=l}while(0);switch(z&15){case 9:{r=A;break b;break}case 0:{m=y;n=A;o=8;break}default:break c}}if(!z)r=A;else{o=107;break a}}while(0);h=g+1|0;p=(h|0)==48;q=j+(p&1)|0;i=r;j=q;g=p?0:h;k=q*210|0}if((o|0)==106){f[d>>2]=l;E=l;break}else if((o|0)==107){f[d>>2]=l;E=A;break}}else{k=Hl(6760,6952,d,c)|0;E=f[k>>2]|0}while(0);u=b;return E|0}function db(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0.0,Ua=0.0,Va=0.0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,mb=0,nb=0,ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0;i=u;u=u+256|0;e=i+104|0;j=i+240|0;k=i+224|0;l=i+160|0;m=i+140|0;n=i+248|0;o=i+72|0;p=i+40|0;q=i+128|0;r=i;s=i+232|0;t=i+220|0;v=i+216|0;w=i+212|0;x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=+W(+(Va*Ua));hb=Vn(lb|0,I|0,~~Ta>>>0|0,(+K(Ta)>=1.0?(Ta>0.0?~~+Y(+J(Ta/4294967296.0),4294967295.0)>>>0:~~+W((Ta-+(~~Ta>>>0))/4294967296.0)>>>0):0)|0)|0;lb=f[r>>2]|0;if(!((lb|0)<=(hb|0)?!((lb|0)>=(hb|0)?(rb|0)<(f[U>>2]|0):0):0)){lb=r;f[lb>>2]=hb;f[lb+4>>2]=rb;b[V>>0]=ob;f[Z>>2]=fb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[j>>2]=f[v>>2];f[e>>2]=f[w>>2];Jf(aa,j,e);f[x>>2]=Ha;f[y>>2]=Ga;f[j>>2]=f[x>>2];f[e>>2]=f[y>>2];Jf(ba,j,e)}if(Ja)break;tb=b[Fa>>0]|0;lb=-1;hb=tb;while(1){ib=lb+-1|0;ub=Ka+ib|0;kb=hb;hb=b[ub>>0]|0;if((hb&255)<(kb&255))break;if((ub|0)==(n|0)){vb=84;break d}else lb=ib}ib=Ka+lb|0;if((hb&255)<(tb&255)){wb=Fa;xb=tb}else{kb=Ka;jb=Fa;while(1){mb=jb+-1|0;if((hb&255)<(h[kb+-2>>0]|0)){wb=mb;xb=1;break}else{yb=jb;jb=mb;kb=yb}}}b[ub>>0]=xb;b[wb>>0]=hb;if((lb|0)<-1){zb=ib;Ab=Fa}else continue;while(1){kb=b[zb>>0]|0;b[zb>>0]=b[Ab>>0]|0;b[Ab>>0]=kb;kb=zb+1|0;jb=Ab+-1|0;if(kb>>>0>>0){zb=kb;Ab=jb}else continue d}}if(((vb|0)==84?(vb=0,db):0)?(gb=b[n>>0]|0,b[n>>0]=tb,b[Fa>>0]=gb,Ma):0){gb=La;ib=ka;do{lb=b[ib>>0]|0;b[ib>>0]=b[gb>>0]|0;b[gb>>0]=lb;ib=ib+1|0;gb=gb+-1|0}while(ib>>>0>>0)}if((fb|0)>=(Ia|0)){Wa=bb;Xa=na;Ya=bb;Za=na;_a=Ga;$a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f[g>>2]=N;if(!(f[F+(N>>>5<<2)>>2]&1<<(N&31))){O=0;P=J;Q=N}else{N=f[i>>2]|0;if((N|0)==(f[y>>2]|0))Ri(h,6140);else{f[N>>2]=-1;f[i>>2]=N+4}N=f[v>>2]|0;if((N|0)==(f[w>>2]|0))Ri(z,g);else{f[N>>2]=f[g>>2];f[v>>2]=N+4}N=f[l>>2]|0;R=f[j>>2]|0;if((N|0)==(R<<5|0)){if((N+1|0)<0){S=50;break a}T=R<<6;R=N+32&-32;vi(d,N>>>0<1073741823?(T>>>0>>0?R:T):2147483647);U=f[l>>2]|0}else U=N;f[l>>2]=U+1;N=(f[d>>2]|0)+(U>>>5<<2)|0;f[N>>2]=f[N>>2]&~(1<<(U&31));f[g>>2]=J;O=1;P=J+1|0;Q=J}N=f[d>>2]|0;T=N+(Q>>>5<<2)|0;f[T>>2]=f[T>>2]|1<<(Q&31);T=N;b:do if(O){R=M;while(1){if((R|0)==-1){S=64;break b}V=(f[e>>2]|0)+(R>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(R&31);V=f[g>>2]|0;f[(f[h>>2]|0)+(V<<2)>>2]=R;f[(f[a>>2]|0)+(R<<2)>>2]=V;V=R+1|0;W=((V>>>0)%3|0|0)==0?R+-2|0:V;do if((W|0)==-1)X=-1;else{V=f[(f[x>>2]|0)+(W<<2)>>2]|0;Y=V+1|0;if((V|0)==-1){X=-1;break}X=((Y>>>0)%3|0|0)==0?V+-2|0:Y}while(0);if((X|0)==(M|0))break;else R=X}}else{R=M;while(1){if((R|0)==-1){S=64;break b}W=(f[e>>2]|0)+(R>>>5<<2)|0;f[W>>2]=f[W>>2]|1<<(R&31);f[(f[h>>2]|0)+(f[g>>2]<<2)>>2]=R;W=R+1|0;Y=((W>>>0)%3|0|0)==0?R+-2|0:W;do if((Y|0)==-1)Z=-1;else{W=f[(f[x>>2]|0)+(Y<<2)>>2]|0;V=W+1|0;if((W|0)==-1){Z=-1;break}Z=((V>>>0)%3|0|0)==0?W+-2|0:V}while(0);if((Z|0)==(M|0))break;else R=Z}}while(0);c:do if((S|0)==64){S=0;if((M|0)==-1)break;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((R|0)==-1)break;Y=f[(f[x>>2]|0)+(R<<2)>>2]|0;if((Y|0)==-1)break;R=Y+(((Y>>>0)%3|0|0)==0?2:-1)|0;if((R|0)==-1)break;if(!O){Y=R;while(1){V=(f[e>>2]|0)+(Y>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(Y&31);V=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((V|0)==-1)break c;W=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((W|0)==-1)break c;Y=W+(((W>>>0)%3|0|0)==0?2:-1)|0;if((Y|0)==-1)break c}}Y=f[a>>2]|0;W=R;do{V=(f[e>>2]|0)+(W>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(W&31);f[Y+(W<<2)>>2]=f[g>>2];V=(((W>>>0)%3|0|0)==0?2:-1)+W|0;if((V|0)==-1)break c;_=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((_|0)==-1)break c;W=_+(((_>>>0)%3|0|0)==0?2:-1)|0}while((W|0)!=-1)}while(0);$=P;aa=T;ba=N}else{$=J;aa=I;ba=F}if((H|0)<2){H=H+1|0;J=$;F=ba;I=aa}else{ca=$;da=aa;ea=ba;break}}}else{ca=A;da=D;ea=E}}else{ca=A;da=D;ea=E}C=C+1|0;B=f[a>>2]|0;if(C>>>0>=(((f[m>>2]|0)-B>>2>>>0)/3|0)>>>0){S=18;break}else{A=ca;D=da;E=ea}}if((S|0)==18){fa=da;ga=f[l>>2]|0;break}else if((S|0)==50)aq(d)}else{fa=q;ga=p}}else{fa=q;ga=p}while(0);p=a+44|0;f[p>>2]=0;a=fa;fa=ga>>>5;q=a+(fa<<2)|0;S=ga&31;ga=(fa|0)!=0;d:do if(fa|S|0)if(!S){l=a;da=0;ea=ga;while(1){e:do if(ea){if(!(f[l>>2]&1)){ca=da+1|0;f[p>>2]=ca;ha=ca}else ha=da;if(!(f[l>>2]&2)){ca=ha+1|0;f[p>>2]=ca;ia=ca}else ia=ha;if(!(f[l>>2]&4)){ca=ia+1|0;f[p>>2]=ca;ja=ca}else ja=ia;if(!(f[l>>2]&8)){ca=ja+1|0;f[p>>2]=ca;ka=ca}else ka=ja;if(!(f[l>>2]&16)){ca=ka+1|0;f[p>>2]=ca;la=ca}else la=ka;if(!(f[l>>2]&32)){ca=la+1|0;f[p>>2]=ca;ma=ca}else ma=la;if(!(f[l>>2]&64)){ca=ma+1|0;f[p>>2]=ca;na=ca}else na=ma;if(!(f[l>>2]&128)){ca=na+1|0;f[p>>2]=ca;oa=ca}else oa=na;if(!(f[l>>2]&256)){ca=oa+1|0;f[p>>2]=ca;pa=ca}else pa=oa;if(!(f[l>>2]&512)){ca=pa+1|0;f[p>>2]=ca;qa=ca}else qa=pa;if(!(f[l>>2]&1024)){ca=qa+1|0;f[p>>2]=ca;ra=ca}else ra=qa;if(!(f[l>>2]&2048)){ca=ra+1|0;f[p>>2]=ca;sa=ca}else sa=ra;if(!(f[l>>2]&4096)){ca=sa+1|0;f[p>>2]=ca;ta=ca}else ta=sa;if(!(f[l>>2]&8192)){ca=ta+1|0;f[p>>2]=ca;ua=ca}else ua=ta;if(!(f[l>>2]&16384)){ca=ua+1|0;f[p>>2]=ca;va=ca}else va=ua;if(!(f[l>>2]&32768)){ca=va+1|0;f[p>>2]=ca;wa=ca}else wa=va;if(!(f[l>>2]&65536)){ca=wa+1|0;f[p>>2]=ca;xa=ca}else xa=wa;if(!(f[l>>2]&131072)){ca=xa+1|0;f[p>>2]=ca;ya=ca}else ya=xa;if(!(f[l>>2]&262144)){ca=ya+1|0;f[p>>2]=ca;za=ca}else za=ya;if(!(f[l>>2]&524288)){ca=za+1|0;f[p>>2]=ca;Aa=ca}else Aa=za;if(!(f[l>>2]&1048576)){ca=Aa+1|0;f[p>>2]=ca;Ba=ca}else Ba=Aa;if(!(f[l>>2]&2097152)){ca=Ba+1|0;f[p>>2]=ca;Ca=ca}else Ca=Ba;if(!(f[l>>2]&4194304)){ca=Ca+1|0;f[p>>2]=ca;Da=ca}else Da=Ca;if(!(f[l>>2]&8388608)){ca=Da+1|0;f[p>>2]=ca;Ea=ca}else Ea=Da;if(!(f[l>>2]&16777216)){ca=Ea+1|0;f[p>>2]=ca;Fa=ca}else Fa=Ea;if(!(f[l>>2]&33554432)){ca=Fa+1|0;f[p>>2]=ca;Ga=ca}else Ga=Fa;if(!(f[l>>2]&67108864)){ca=Ga+1|0;f[p>>2]=ca;Ha=ca}else Ha=Ga;if(!(f[l>>2]&134217728)){ca=Ha+1|0;f[p>>2]=ca;Ia=ca}else Ia=Ha;if(!(f[l>>2]&268435456)){ca=Ia+1|0;f[p>>2]=ca;Ja=ca}else Ja=Ia;if(!(f[l>>2]&536870912)){ca=Ja+1|0;f[p>>2]=ca;Ka=ca}else Ka=Ja;if(!(f[l>>2]&1073741824)){ca=Ka+1|0;f[p>>2]=ca;La=ca}else La=Ka;if((f[l>>2]|0)<=-1){Ma=La;break}ca=La+1|0;f[p>>2]=ca;Ma=ca}else{ca=0;m=da;while(1){if(!(f[l>>2]&1<>2]=ba;Na=ba}else Na=m;if((ca|0)==31){Ma=Na;break e}ca=ca+1|0;if(!ca)break d;else m=Na}}while(0);l=l+4|0;if((q|0)==(l|0))break;else{da=Ma;ea=1}}}else{if(ga){ea=0;da=a;l=0;while(1){if(!(f[da>>2]&1)){m=l+1|0;f[p>>2]=m;Oa=m;Pa=m}else{Oa=l;Pa=ea}if(!(f[da>>2]&2)){m=Oa+1|0;f[p>>2]=m;Qa=m;Ra=m}else{Qa=Oa;Ra=Pa}if(!(f[da>>2]&4)){m=Qa+1|0;f[p>>2]=m;Sa=m;Ta=m}else{Sa=Qa;Ta=Ra}if(!(f[da>>2]&8)){m=Sa+1|0;f[p>>2]=m;Ua=m;Va=m}else{Ua=Sa;Va=Ta}if(!(f[da>>2]&16)){m=Ua+1|0;f[p>>2]=m;Wa=m;Xa=m}else{Wa=Ua;Xa=Va}if(!(f[da>>2]&32)){m=Wa+1|0;f[p>>2]=m;Ya=m;Za=m}else{Ya=Wa;Za=Xa}if(!(f[da>>2]&64)){m=Ya+1|0;f[p>>2]=m;_a=m;$a=m}else{_a=Ya;$a=Za}if(!(f[da>>2]&128)){m=_a+1|0;f[p>>2]=m;ab=m;bb=m}else{ab=_a;bb=$a}if(!(f[da>>2]&256)){m=ab+1|0;f[p>>2]=m;cb=m;db=m}else{cb=ab;db=bb}if(!(f[da>>2]&512)){m=cb+1|0;f[p>>2]=m;eb=m;fb=m}else{eb=cb;fb=db}if(!(f[da>>2]&1024)){m=eb+1|0;f[p>>2]=m;gb=m;hb=m}else{gb=eb;hb=fb}if(!(f[da>>2]&2048)){m=gb+1|0;f[p>>2]=m;ib=m;jb=m}else{ib=gb;jb=hb}if(!(f[da>>2]&4096)){m=ib+1|0;f[p>>2]=m;kb=m;lb=m}else{kb=ib;lb=jb}if(!(f[da>>2]&8192)){m=kb+1|0;f[p>>2]=m;mb=m;nb=m}else{mb=kb;nb=lb}if(!(f[da>>2]&16384)){m=mb+1|0;f[p>>2]=m;ob=m;pb=m}else{ob=mb;pb=nb}if(!(f[da>>2]&32768)){m=ob+1|0;f[p>>2]=m;qb=m;rb=m}else{qb=ob;rb=pb}if(!(f[da>>2]&65536)){m=qb+1|0;f[p>>2]=m;sb=m;tb=m}else{sb=qb;tb=rb}if(!(f[da>>2]&131072)){m=sb+1|0;f[p>>2]=m;ub=m;vb=m}else{ub=sb;vb=tb}if(!(f[da>>2]&262144)){m=ub+1|0;f[p>>2]=m;wb=m;xb=m}else{wb=ub;xb=vb}if(!(f[da>>2]&524288)){m=wb+1|0;f[p>>2]=m;yb=m;zb=m}else{yb=wb;zb=xb}if(!(f[da>>2]&1048576)){m=yb+1|0;f[p>>2]=m;Ab=m;Bb=m}else{Ab=yb;Bb=zb}if(!(f[da>>2]&2097152)){m=Ab+1|0;f[p>>2]=m;Cb=m;Db=m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lb=1;do{jb=kb+(lb<<2)|0;f[jb>>2]=(f[jb>>2]|0)/(hb|0)|0;lb=lb+1|0}while((lb|0)!=(g|0));lb=f[Z>>2]|0;if(S)sb=lb;else{tb=0;ub=lb;break}}else sb=f[Z>>2]|0;lb=0;jb=0;while(1){nb=(f[kb+(lb<<2)>>2]|0)-(f[za+(lb<<2)>>2]|0)|0;mb=((nb|0)>-1?nb:0-nb|0)+jb|0;f[Da+(lb<<2)>>2]=nb;f[sb+(lb<<2)>>2]=nb<<1^nb>>31;lb=lb+1|0;if((lb|0)==(g|0)){tb=mb;ub=sb;break}else jb=mb}}else{tb=0;ub=f[Z>>2]|0}while(0);mo(e,_,ub,g);kb=Zk(e)|0;jb=I;lb=Bm(e)|0;mb=I;Va=+wm(ya,ib);nb=Vn(lb|0,mb|0,kb|0,jb|0)|0;Ta=+W(+(Va*Ua));jb=Vn(nb|0,I|0,~~Ta>>>0|0,(+K(Ta)>=1.0?(Ta>0.0?~~+Y(+J(Ta/4294967296.0),4294967295.0)>>>0:~~+W((Ta-+(~~Ta>>>0))/4294967296.0)>>>0):0)|0)|0;nb=f[r>>2]|0;if(!((nb|0)<=(jb|0)?!((nb|0)>=(jb|0)?(tb|0)<(f[T>>2]|0):0):0)){nb=r;f[nb>>2]=jb;f[nb+4>>2]=tb;b[U>>0]=qb;f[V>>2]=hb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[j>>2]=f[v>>2];f[e>>2]=f[w>>2];Jf($,j,e);f[x>>2]=Ca;f[y>>2]=Ma;f[j>>2]=f[x>>2];f[e>>2]=f[y>>2];Jf(aa,j,e)}if(Ia)break;vb=b[Ka>>0]|0;nb=-1;jb=vb;while(1){kb=nb+-1|0;wb=Na+kb|0;mb=jb;jb=b[wb>>0]|0;if((jb&255)<(mb&255))break;if((wb|0)==(n|0)){xb=84;break d}else nb=kb}kb=Na+nb|0;if((jb&255)<(vb&255)){yb=Ka;zb=vb}else{mb=Na;lb=Ka;while(1){ob=lb+-1|0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fb&31)}else{if(Ga){if((La+1|0)<0){xb=100;break b}Ga=Ja<<6;Ja=La+32&-32;vi(Eb,La>>>0<1073741823?(Ga>>>0>>0?Ja:Ga):2147483647);Gb=f[Da>>2]|0}else Gb=La;f[Da>>2]=Gb+1;La=(f[Eb>>2]|0)+(Gb>>>5<<2)|0;f[La>>2]=f[La>>2]&~(1<<(Gb&31))}hb=hb+1|0}while((hb|0)<(Fa|0))}hb=f[$>>2]|0;Da=d+(Ba<<2)|0;Ca=f[za+4>>2]|0;Aa=f[hb>>2]|0;La=f[hb+4>>2]|0;f[j>>2]=f[za>>2];f[ca>>2]=Ca;f[k>>2]=Aa;f[da>>2]=La;Od(e,ba,j,k);f[Da>>2]=f[e>>2];f[Da+4>>2]=f[ea>>2];Da=f[fa>>2]|0;if(Da|0){La=f[ia>>2]|0;if((La|0)!=(Da|0))f[ia>>2]=La+(~((La+-4-Da|0)>>>2)<<2);Oq(Da)}Da=f[ga>>2]|0;if(Da|0){La=f[ha>>2]|0;if((La|0)!=(Da|0))f[ha>>2]=La+(~((La+-4-Da|0)>>>2)<<2);Oq(Da)}if((na|0)<=2){Hb=Za;Ib=Ya;break a}Da=f[B>>2]|0;wa=f[Da>>2]|0;La=oa+-1|0;if((f[Da+4>>2]|0)-wa>>2>>>0<=La>>>0){xa=Da;xb=18;break}else{Da=oa;oa=La;pa=$a;qa=_a;ra=ab;sa=Za;ta=Ya;ua=Xa;va=Wa;na=Da}}if((xb|0)==18)aq(xa);else if((xb|0)==95)aq(Eb);else if((xb|0)==100)aq(Eb)}else{Hb=M;Ib=N}while(0);if((g|0)>0)sj(f[l>>2]|0,0,g<<2|0)|0;g=f[l>>2]|0;N=f[c+4>>2]|0;M=f[g>>2]|0;Eb=f[g+4>>2]|0;f[j>>2]=f[c>>2];f[j+4>>2]=N;f[k>>2]=M;f[k+4>>2]=Eb;Od(e,a+8|0,j,k);f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];if(Hb|0){if((Ib|0)!=(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ra=pa;sa=qa;b:while(1){qa=sa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;ta=f[qa+4>>2]|0;if(!ta){ua=ra;break b}else qa=ta}sa=f[qa>>2]|0;if(!sa){ua=qa;break}else ra=qa}if(((ua|0)!=(pa|0)?(k|0)>=(f[ua+16>>2]|0):0)?(ra=ua+20|0,(Jh(ra,d)|0)!=0):0)va=Hk(ra,d,-1)|0;else wa=17}else wa=17;if((wa|0)==17){wa=0;va=Hk(ka,d,-1)|0}if((b[w>>0]|0)<0)Oq(f[d>>2]|0);if((va|0)<1)xa=1;else{ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;sa=ln(32)|0;f[d>>2]=sa;f[z>>2]=-2147483616;f[A>>2]=19;ma=sa;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[sa+19>>0]=0;ka=ra+16|0;pa=f[ka>>2]|0;if(pa){la=ka;ta=pa;c:while(1){pa=ta;while(1){if((f[pa+16>>2]|0)>=(k|0))break;ya=f[pa+4>>2]|0;if(!ya){za=la;break c}else pa=ya}ta=f[pa>>2]|0;if(!ta){za=pa;break}else la=pa}if((za|0)!=(ka|0)?(k|0)>=(f[za+16>>2]|0):0)Aa=za+20|0;else wa=29}else wa=29;if((wa|0)==29){wa=0;Aa=ra}if(!(Jh(Aa,d)|0))Ba=0;else{la=f[(f[j>>2]|0)+48>>2]|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;ta=ln(32)|0;f[e>>2]=ta;f[X>>2]=-2147483616;f[Y>>2]=18;ma=ta;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ta+18>>0]=0;ra=la+16|0;ka=f[ra>>2]|0;if(ka){sa=ra;qa=ka;d:while(1){ka=qa;while(1){if((f[ka+16>>2]|0)>=(k|0))break;ya=f[ka+4>>2]|0;if(!ya){Ca=sa;break d}else ka=ya}qa=f[ka>>2]|0;if(!qa){Ca=ka;break}else sa=ka}if((Ca|0)!=(ra|0)?(k|0)>=(f[Ca+16>>2]|0):0)Da=Ca+20|0;else wa=39}else wa=39;if((wa|0)==39){wa=0;Da=la}sa=(Jh(Da,e)|0)!=0;if((b[Z>>0]|0)<0)Oq(f[e>>2]|0);Ba=sa}if((b[B>>0]|0)<0)Oq(f[d>>2]|0);if(Ba){sa=ja+24|0;qa=b[sa>>0]|0;ta=qa<<24>>24;f[h>>2]=0;f[C>>2]=0;f[D>>2]=0;if(!(qa<<24>>24))Ea=0;else{if(qa<<24>>24<0){wa=48;break a}qa=ta<<2;pa=ln(qa)|0;f[h>>2]=pa;ya=pa+(ta<<2)|0;f[O>>2]=ya;sj(pa|0,0,qa|0)|0;f[C>>2]=ya;Ea=pa}pa=f[(f[j>>2]|0)+48>>2]|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;ya=ln(32)|0;f[i>>2]=ya;f[E>>2]=-2147483616;f[F>>2]=19;ma=ya;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+19>>0]=0;la=b[sa>>0]|0;ra=la<<24>>24;qa=pa+16|0;ta=f[qa>>2]|0;if(ta){Fa=qa;Ga=ta;e:while(1){ta=Ga;while(1){if((f[ta+16>>2]|0)>=(k|0))break;Ha=f[ta+4>>2]|0;if(!Ha){Ia=Fa;break e}else ta=Ha}Ga=f[ta>>2]|0;if(!Ga){Ia=ta;break}else Fa=ta}if(((Ia|0)!=(qa|0)?(k|0)>=(f[Ia+16>>2]|0):0)?(Fa=Ia+20|0,(Jh(Fa,i)|0)!=0):0){Ga=Rg(Fa,i)|0;if((Ga|0)!=(Ia+24|0)){pj(d,Ga+28|0);Ga=b[M>>0]|0;Fa=Ga<<24>>24<0;if(!((Fa?f[N>>2]|0:Ga&255)|0))Ja=Ga;else{if(la<<24>>24>0){ya=Fa?f[d>>2]|0:d;Fa=0;do{Ka=$(bq(ya,e));ka=ya;ya=f[e>>2]|0;if((ka|0)==(ya|0))break;n[Ea+(Fa<<2)>>2]=Ka;Fa=Fa+1|0}while((Fa|0)<(ra|0));La=b[M>>0]|0}else La=Ga;Ja=La}if(Ja<<24>>24<0)Oq(f[d>>2]|0)}}else wa=69}else wa=69;if((wa|0)==69?(wa=0,Fa=Rg(pa,i)|0,(Fa|0)!=(pa+4|0)):0){pj(d,Fa+28|0);Fa=b[G>>0]|0;ya=Fa<<24>>24<0;if(!((ya?f[H>>2]|0:Fa&255)|0))Ma=Fa;else{if(la<<24>>24>0){qa=ya?f[d>>2]|0:d;ya=0;do{Ka=$(bq(qa,e));ka=qa;qa=f[e>>2]|0;if((ka|0)==(qa|0))break;n[Ea+(ya<<2)>>2]=Ka;ya=ya+1|0}while((ya|0)<(ra|0));Na=b[G>>0]|0}else Na=Fa;Ma=Na}if(Ma<<24>>24<0)Oq(f[d>>2]|0)}if((b[I>>0]|0)<0)Oq(f[i>>2]|0);ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;ya=ln(32)|0;f[d>>2]=ya;f[J>>2]=-2147483616;f[K>>2]=18;ma=ya;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+18>>0]=0;na=ra+16|0;ma=f[na>>2]|0;do if(ma){oa=na;Fa=ma;f:while(1){qa=Fa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;la=f[qa+4>>2]|0;if(!la){Pa=oa;break f}else qa=la}Fa=f[qa>>2]|0;if(!Fa){Pa=qa;break}else oa=qa}if((Pa|0)!=(na|0)?(k|0)>=(f[Pa+16>>2]|0):0){oa=Pa+20|0;if(!(Jh(oa,d)|0)){wa=91;break}Qa=$(sk(oa,d,$(1.0)))}else wa=91}else wa=91;while(0);if((wa|0)==91){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Oq(k)}xa=0}f[g>>2]=1196;k=f[r>>2]|0;if(k|0){na=f[y>>2]|0;if((na|0)!=(k|0))f[y>>2]=na+(~((na+-4-k|0)>>>2)<<2);Oq(k)}if(xa|0){v=0;wa=169;break a}break}case 1:case 3:case 5:{k=ja+24|0;na=b[k>>0]|0;oa=na<<24>>24;f[g>>2]=0;f[_>>2]=0;f[aa>>2]=0;if(!(na<<24>>24))Sa=0;else{if(na<<24>>24<0){wa=137;break a}na=ln(oa<<2)|0;f[_>>2]=na;f[g>>2]=na;ma=na+(oa<<2)|0;f[a>>2]=ma;ya=oa;oa=na;while(1){f[oa>>2]=2147483647;ya=ya+-1|0;if(!ya)break;else oa=oa+4|0}f[_>>2]=ma;Sa=b[k>>0]|0}oa=Sa<<24>>24;f[h>>2]=0;f[ba>>2]=0;f[ca>>2]=0;if(!(Sa<<24>>24))Ta=0;else{if(Sa<<24>>24<0){wa=144;break a}ya=oa<<2;sa=ln(ya)|0;f[h>>2]=sa;ra=sa+(oa<<2)|0;f[da>>2]=ra;sj(sa|0,0,ya|0)|0;f[ba>>2]=ra;Ta=sa}sa=ja+80|0;ra=b[k>>0]|0;g:do if(!(f[sa>>2]|0))Ua=ra;else{ya=0;oa=ra;na=Ta;while(1){f[e>>2]=ya;f[d>>2]=f[e>>2];Qb(ja,d,oa,na)|0;Fa=b[k>>0]|0;if(Fa<<24>>24>0){ta=f[g>>2]|0;la=f[h>>2]|0;pa=Fa<<24>>24;Ga=0;do{ka=ta+(Ga<<2)|0;Ha=f[la+(Ga<<2)>>2]|0;if((f[ka>>2]|0)>(Ha|0))f[ka>>2]=Ha;Ga=Ga+1|0}while((Ga|0)<(pa|0))}pa=ya+1|0;if(pa>>>0>=(f[sa>>2]|0)>>>0){Ua=Fa;break g}ya=pa;oa=Fa;na=f[h>>2]|0}}while(0);if(Ua<<24>>24>0){sa=0;ja=Ua;while(1){ra=(f[g>>2]|0)+(sa<<2)|0;ma=f[ea>>2]|0;if((ma|0)==(f[fa>>2]|0)){Ri(ga,ra);Va=b[k>>0]|0}else{f[ma>>2]=f[ra>>2];f[ea>>2]=ma+4;Va=ja}sa=sa+1|0;if((sa|0)>=(Va<<24>>24|0))break;else ja=Va}}ja=f[h>>2]|0;if(ja|0){sa=f[ba>>2]|0;if((sa|0)!=(ja|0))f[ba>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}ja=f[g>>2]|0;if(ja|0){sa=f[_>>2]|0;if((sa|0)!=(ja|0))f[_>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}break}default:{}}ja=ha+1|0;sa=f[o>>2]|0;if(ja>>>0>=(f[p>>2]|0)-sa>>2>>>0){v=1;wa=169;break}k=f[j>>2]|0;ha=ja;ia=sa;t=f[k+4>>2]|0;l=k}if((wa|0)==48)aq(h);else if((wa|0)==103)aq(Ra);else if((wa|0)==137)aq(g);else if((wa|0)==144)aq(h);else if((wa|0)==169){u=c;return v|0}return 0}function hb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0;d=u;u=u+32|0;e=d;g=a+8|0;h=f[g>>2]|0;f[e>>2]=0;i=e+4|0;f[i>>2]=0;f[e+8>>2]=0;do if(h)if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;break}else{ga=0;ha=ea}while(1){ba=(f[N>>2]|0)+((X(f[M>>2]|0,S+ga|0)|0)<<2)|0;if(!ha)ia=0;else{aa=0;do{ca=f[(f[w>>2]|0)+(aa<<2)>>2]|0;U=(f[a>>2]|0)-(f[(f[Y>>2]|0)+(ca<<2)>>2]|0)|0;do if(U|0){da=f[y>>2]|0;ja=32-da|0;ka=32-U|0;la=f[ba+(ca<<2)>>2]<(ja|0)){ma=la>>>ka;ka=U-ja|0;f[y>>2]=ka;ja=f[h>>2]|ma>>>ka;f[h>>2]=ja;ka=f[j>>2]|0;if((ka|0)==(f[m>>2]|0))Ri(n,h);else{f[ka>>2]=ja;f[j>>2]=ka+4}f[h>>2]=ma<<32-(f[y>>2]|0);break}ma=f[h>>2]|la>>>da;f[h>>2]=ma;la=da+U|0;f[y>>2]=la;if((la|0)!=32)break;la=f[j>>2]|0;if((la|0)==(f[m>>2]|0))Ri(n,h);else{f[la>>2]=ma;f[j>>2]=la+4}f[h>>2]=0;f[y>>2]=0}while(0);aa=aa+1|0;U=f[g>>2]|0}while(aa>>>0>>0);ia=U}ga=ga+1|0;if(ga>>>0>=z>>>0){fa=99;break a}else ha=ia}}$=Z+1|0;Ig(R+($*12|0)|0,f[R+(Z*12|0)>>2]|0,f[R+(Z*12|0)+4>>2]|0);aa=(f[(f[k>>2]|0)+($*12|0)>>2]|0)+(V<<2)|0;ba=(f[aa>>2]|0)+(1<>2]=ba;aa=f[A>>2]|0;U=f[B>>2]|0;b:do if((W|0)==(S|0))na=S;else{ca=f[O>>2]|0;if(!aa){if((f[ca+(V<<2)>>2]|0)>>>0>>0){na=W;break}else{oa=W;pa=S}while(1){la=oa;do{la=la+-1|0;if((pa|0)==(la|0)){na=pa;break b}ma=(f[P>>2]|0)+((X(la,U)|0)<<2)+(V<<2)|0}while((f[ma>>2]|0)>>>0>=ba>>>0);pa=pa+1|0;if((pa|0)==(la|0)){na=la;break b}else oa=la}}else{qa=W;ra=S}while(1){ma=ra;while(1){sa=ca+((X(ma,aa)|0)<<2)|0;if((f[sa+(V<<2)>>2]|0)>>>0>=ba>>>0){ta=qa;break}da=ma+1|0;if((da|0)==(qa|0)){na=qa;break b}else ma=da}while(1){ta=ta+-1|0;if((ma|0)==(ta|0)){na=ma;break b}ua=(f[P>>2]|0)+((X(ta,U)|0)<<2)|0;if((f[ua+(V<<2)>>2]|0)>>>0>>0){va=0;break}}do{la=sa+(va<<2)|0;da=ua+(va<<2)|0;ka=f[la>>2]|0;f[la>>2]=f[da>>2];f[da>>2]=ka;va=va+1|0}while((va|0)!=(aa|0));ra=ma+1|0;if((ra|0)==(ta|0)){na=ta;break}else qa=ta}}while(0);ba=(_(z|0)|0)^31;U=na-S|0;ca=W-na|0;ka=U>>>0>>0;if((U|0)!=(ca|0)){da=f[H>>2]|0;if(ka)f[I>>2]=f[I>>2]|1<<31-da;la=da+1|0;f[H>>2]=la;if((la|0)==32){la=f[J>>2]|0;if((la|0)==(f[K>>2]|0))Ri(L,I);else{f[la>>2]=f[I>>2];f[J>>2]=la+4}f[H>>2]=0;f[I>>2]=0}}la=z>>>1;do if(ka){da=f[C>>2]|0;ja=32-da|0;wa=32-ba|0;xa=la-U<(ja|0)){ya=xa>>>wa;wa=ba-ja|0;f[C>>2]=wa;ja=f[D>>2]|ya>>>wa;f[D>>2]=ja;wa=f[E>>2]|0;if((wa|0)==(f[F>>2]|0))Ri(G,D);else{f[wa>>2]=ja;f[E>>2]=wa+4}f[D>>2]=ya<<32-(f[C>>2]|0);break}ya=f[D>>2]|xa>>>da;f[D>>2]=ya;xa=da+ba|0;f[C>>2]=xa;if((xa|0)==32){xa=f[E>>2]|0;if((xa|0)==(f[F>>2]|0))Ri(G,D);else{f[xa>>2]=ya;f[E>>2]=xa+4}f[D>>2]=0;f[C>>2]=0}}else{xa=f[C>>2]|0;ya=32-xa|0;da=32-ba|0;wa=la-ca<(ya|0)){ja=wa>>>da;da=ba-ya|0;f[C>>2]=da;ya=f[D>>2]|ja>>>da;f[D>>2]=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)==(Ha|0))Ia=0;else Ia=(f[Ha+(((ba>>>0)/113|0)<<2)>>2]|0)+(((ba>>>0)%113|0)*36|0)|0;f[Ia>>2]=na;f[Ia+4>>2]=i;f[Ia+8>>2]=aa;f[Ia+12>>2]=W;ba=Ia+16|0;f[ba>>2]=p;f[ba+4>>2]=q;f[Ia+24>>2]=V;f[Ia+28>>2]=ca;f[Ia+32>>2]=$;ba=(f[l>>2]|0)+1|0;f[l>>2]=ba;Ja=ba}else fa=99}else fa=99;while(0);if((fa|0)==99){fa=0;Ja=f[l>>2]|0}if(!Ja)break;else Q=Ja}}Ja=f[t>>2]|0;Q=f[v>>2]|0;Ia=Ja+(((Q>>>0)/113|0)<<2)|0;q=f[o>>2]|0;p=q;i=Ja;if((q|0)==(Ja|0)){Ka=0;La=0}else{na=(f[Ia>>2]|0)+(((Q>>>0)%113|0)*36|0)|0;Ka=na;La=na}na=Ia;Ia=La;c:while(1){La=Ia;do{Q=La;if((Ka|0)==(Q|0))break c;La=Q+36|0}while((La-(f[na>>2]|0)|0)!=4068);La=na+4|0;na=La;Ia=f[La>>2]|0}f[l>>2]=0;l=p-i>>2;if(l>>>0>2){i=Ja;do{Oq(f[i>>2]|0);i=(f[t>>2]|0)+4|0;f[t>>2]=i;Ma=f[o>>2]|0;Na=Ma-i>>2}while(Na>>>0>2);Oa=Na;Pa=i;Qa=Ma}else{Oa=l;Pa=Ja;Qa=q}switch(Oa|0){case 1:{Ra=56;fa=113;break}case 2:{Ra=113;fa=113;break}default:{}}if((fa|0)==113)f[v>>2]=Ra;if((Pa|0)!=(Qa|0)){Ra=Pa;do{Oq(f[Ra>>2]|0);Ra=Ra+4|0}while((Ra|0)!=(Qa|0));Qa=f[t>>2]|0;t=f[o>>2]|0;if((t|0)!=(Qa|0))f[o>>2]=t+(~((t+-4-Qa|0)>>>2)<<2)}Qa=f[e>>2]|0;if(!Qa){u=d;return}Oq(Qa);u=d;return}function ib(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0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|0;if((ja|0)==(f[o>>2]|0))Ri(p,j);else{f[ja>>2]=ka;f[l>>2]=ja+4}f[j>>2]=0;f[A>>2]=0}while(0);Z=Z+1|0;W=f[i>>2]|0}while(Z>>>0>>0);ga=W}ea=ea+1|0;if(ea>>>0>=U>>>0){da=87;break a}else fa=ga}}Y=V+1|0;Z=f[m>>2]|0;$=Z+(Y*12|0)|0;if(($|0)==(S|0))la=Z;else{Ig($,f[S>>2]|0,f[O+(V*12|0)+4>>2]|0);la=f[m>>2]|0}$=(f[la+(Y*12|0)>>2]|0)+(Q<<2)|0;Z=(f[$>>2]|0)+(1<>2]=Z;$=f[C>>2]|0;W=f[D>>2]|0;b:do if((T|0)==(P|0))ma=P;else{aa=f[L>>2]|0;if(!$){if((f[aa+(Q<<2)>>2]|0)>>>0>>0){ma=T;break}else{na=T;oa=P}while(1){ja=na;do{ja=ja+-1|0;if((oa|0)==(ja|0)){ma=oa;break b}ka=(f[M>>2]|0)+((X(ja,W)|0)<<2)+(Q<<2)|0}while((f[ka>>2]|0)>>>0>=Z>>>0);oa=oa+1|0;if((oa|0)==(ja|0)){ma=ja;break b}else na=ja}}else{pa=T;qa=P}while(1){ka=qa;while(1){ra=aa+((X(ka,$)|0)<<2)|0;if((f[ra+(Q<<2)>>2]|0)>>>0>=Z>>>0){sa=pa;break}ba=ka+1|0;if((ba|0)==(pa|0)){ma=pa;break b}else ka=ba}while(1){sa=sa+-1|0;if((ka|0)==(sa|0)){ma=ka;break b}ta=(f[M>>2]|0)+((X(sa,W)|0)<<2)|0;if((f[ta+(Q<<2)>>2]|0)>>>0>>0){ua=0;break}}do{ja=ra+(ua<<2)|0;ba=ta+(ua<<2)|0;ia=f[ja>>2]|0;f[ja>>2]=f[ba>>2];f[ba>>2]=ia;ua=ua+1|0}while((ua|0)!=($|0));qa=ka+1|0;if((qa|0)==(sa|0)){ma=sa;break}else pa=sa}}while(0);Z=(_(U|0)|0)^31;W=ma-P|0;aa=T-ma|0;ia=W>>>0>>0;if((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|0;if((Ca|0)==(Da|0))Ea=0;else Ea=(f[Da+(((ia>>>0)/113|0)<<2)>>2]|0)+(((ia>>>0)%113|0)*36|0)|0;f[Ea>>2]=ma;f[Ea+4>>2]=k;f[Ea+8>>2]=$;f[Ea+12>>2]=T;ia=Ea+16|0;f[ia>>2]=r;f[ia+4>>2]=s;f[Ea+24>>2]=Q;f[Ea+28>>2]=aa;f[Ea+32>>2]=Y;ia=(f[n>>2]|0)+1|0;f[n>>2]=ia;Fa=ia}else da=87}else da=87;while(0);if((da|0)==87){da=0;Fa=f[n>>2]|0}if(!Fa)break;else N=Fa}}Fa=f[w>>2]|0;N=f[x>>2]|0;Ea=Fa+(((N>>>0)/113|0)<<2)|0;s=f[q>>2]|0;r=s;k=Fa;if((s|0)==(Fa|0)){Ga=0;Ha=0}else{ma=(f[Ea>>2]|0)+(((N>>>0)%113|0)*36|0)|0;Ga=ma;Ha=ma}ma=Ea;Ea=Ha;c:while(1){Ha=Ea;do{N=Ha;if((Ga|0)==(N|0))break c;Ha=N+36|0}while((Ha-(f[ma>>2]|0)|0)!=4068);Ha=ma+4|0;ma=Ha;Ea=f[Ha>>2]|0}f[n>>2]=0;n=r-k>>2;if(n>>>0>2){k=Fa;do{Oq(f[k>>2]|0);k=(f[w>>2]|0)+4|0;f[w>>2]=k;Ia=f[q>>2]|0;Ja=Ia-k>>2}while(Ja>>>0>2);Ka=Ja;La=k;Ma=Ia}else{Ka=n;La=Fa;Ma=s}switch(Ka|0){case 1:{Na=56;da=101;break}case 2:{Na=113;da=101;break}default:{}}if((da|0)==101)f[x>>2]=Na;if((La|0)!=(Ma|0)){Na=La;do{Oq(f[Na>>2]|0);Na=Na+4|0}while((Na|0)!=(Ma|0));Ma=f[w>>2]|0;w=f[q>>2]|0;if((w|0)!=(Ma|0))f[q>>2]=w+(~((w+-4-Ma|0)>>>2)<<2)}Ma=f[h>>2]|0;if(!Ma){u=d;return}Oq(Ma);u=d;return}function jb(a,c){a=a|0;c=c|0;var d=0,e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0,K|0)|0;f[J>>2]=M;N=L;break}else N=0;while(0);H=i+24|0;f[H>>2]=N;G=a+4|0;L=a+8|0;M=f[G>>2]|0;a:do if((f[L>>2]|0)!=(M|0)){K=j+4|0;O=j+8|0;P=j+8|0;Q=(B|0)==0;R=j+4|0;S=j+8|0;T=k+4|0;U=k+8|0;V=k+8|0;W=a+48|0;Y=j+8|0;Z=a+60|0;$=0;aa=0;ba=0;ca=0;da=M;ea=C;b:while(1){fa=f[(f[(f[ea+4>>2]|0)+8>>2]|0)+(f[da+(ca<<2)>>2]<<2)>>2]|0;switch(f[fa+28>>2]|0){case 1:case 3:case 5:case 2:case 4:case 6:{ga=fa;ha=aa;break}case 9:{ga=f[(f[Z>>2]|0)+(aa<<2)>>2]|0;ha=aa+1|0;break}default:{ia=0;break a}}if(!ga){ia=0;break a}c:do switch(f[ga+28>>2]|0){case 6:{if(Q){ja=ba;ka=ga+24|0;break c}fa=ga+84|0;la=ga+68|0;ma=ga+48|0;na=ga+40|0;oa=ga+24|0;pa=0;do{if(!(b[fa>>0]|0))qa=f[(f[la>>2]|0)+(pa<<2)>>2]|0;else qa=pa;ra=ma;sa=f[ra>>2]|0;ta=f[ra+4>>2]|0;ra=na;ua=un(f[ra>>2]|0,f[ra+4>>2]|0,qa|0,0)|0;ra=Vn(ua|0,I|0,sa|0,ta|0)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,(f[f[ga>>2]>>2]|0)+ra|0,b[oa>>0]<<2|0)|0;pa=pa+1|0}while((pa|0)!=(B|0));ja=ba;ka=oa;break}case 1:case 3:case 5:{oa=ga+24|0;pa=b[oa>>0]|0;na=pa<<24>>24;f[j>>2]=0;f[R>>2]=0;f[S>>2]=0;if(!(pa<<24>>24))va=0;else{if(pa<<24>>24<0){wa=24;break b}pa=na<<2;ma=ln(pa)|0;f[j>>2]=ma;la=ma+(na<<2)|0;f[Y>>2]=la;sj(ma|0,0,pa|0)|0;f[R>>2]=la;va=b[oa>>0]|0}la=va<<24>>24;f[k>>2]=0;f[T>>2]=0;f[U>>2]=0;if(!(va<<24>>24)){xa=0;ya=0}else{if(va<<24>>24<0){wa=30;break b}pa=la<<2;ma=ln(pa)|0;f[k>>2]=ma;na=ma+(la<<2)|0;f[V>>2]=na;sj(ma|0,0,pa|0)|0;f[T>>2]=na;xa=ma;ya=ma}if(Q){za=ya;Aa=xa}else{ma=ga+84|0;na=ga+68|0;pa=0;do{if(!(b[ma>>0]|0))Ba=f[(f[na>>2]|0)+(pa<<2)>>2]|0;else Ba=pa;la=f[j>>2]|0;f[g>>2]=Ba;fa=b[oa>>0]|0;f[e>>2]=f[g>>2];Qb(ga,e,fa,la)|0;la=b[oa>>0]|0;fa=la<<24>>24;if(la<<24>>24>0){la=f[j>>2]|0;ra=f[W>>2]|0;ta=f[k>>2]|0;sa=0;do{f[ta+(sa<<2)>>2]=(f[la+(sa<<2)>>2]|0)-(f[ra+(sa+ba<<2)>>2]|0);sa=sa+1|0}while((sa|0)<(fa|0));Ca=ta}else Ca=f[k>>2]|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,Ca|0,fa<<2|0)|0;pa=pa+1|0}while(pa>>>0>>0);pa=f[k>>2]|0;za=pa;Aa=pa}pa=ba+(b[oa>>0]|0)|0;if(za|0){na=f[T>>2]|0;if((na|0)!=(za|0))f[T>>2]=na+(~((na+-4-za|0)>>>2)<<2);Oq(Aa)}na=f[j>>2]|0;if(na|0){ma=f[R>>2]|0;if((ma|0)!=(na|0))f[R>>2]=ma+(~((ma+-4-na|0)>>>2)<<2);Oq(na)}ja=pa;ka=oa;break}default:{pa=ga+24|0;na=b[pa>>0]|0;ma=na<<24>>24;f[j>>2]=0;f[K>>2]=0;f[O>>2]=0;if(!(na<<24>>24)){Da=0;Ea=0}else{if(na<<24>>24<0){wa=53;break b}na=ma<<2;ta=ln(na)|0;f[j>>2]=ta;sa=ta+(ma<<2)|0;f[P>>2]=sa;sj(ta|0,0,na|0)|0;f[K>>2]=sa;Da=ta;Ea=ta}if(Q){Fa=Ea;Ga=Da}else{ta=ga+84|0;sa=ga+68|0;na=0;do{if(!(b[ta>>0]|0))Ha=f[(f[sa>>2]|0)+(na<<2)>>2]|0;else Ha=na;ma=f[j>>2]|0;f[g>>2]=Ha;ra=b[pa>>0]|0;f[e>>2]=f[g>>2];Pb(ga,e,ra,ma)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,na)|0)<<2)+($<<2)|0,f[j>>2]|0,b[pa>>0]<<2|0)|0;na=na+1|0}while(na>>>0>>0);na=f[j>>2]|0;Fa=na;Ga=na}if(Fa|0){na=f[K>>2]|0;if((na|0)!=(Fa|0))f[K>>2]=na+(~((na+-4-Fa|0)>>>2)<<2);Oq(Ga)}ja=ba;ka=pa}}while(0);na=ca+1|0;sa=f[G>>2]|0;if(na>>>0>=(f[L>>2]|0)-sa>>2>>>0){wa=66;break}$=$+(b[ka>>0]|0)|0;aa=ha;ba=ja;ca=na;da=sa;ea=f[A>>2]|0}if((wa|0)==24)aq(j);else if((wa|0)==30)aq(k);else if((wa|0)==53)aq(j);else if((wa|0)==66){Ia=f[D>>2]|0;Ja=f[H>>2]|0;wa=67;break}}else{Ia=E;Ja=N;wa=67}while(0);d:do if((wa|0)==67){N=X(Ia,B)|0;if((N|0)>0){E=0;H=0;while(1){D=f[Ja+(E<<2)>>2]|0;if(!D)Ka=H;else{A=(_(D|0)|0)^31;Ka=(A|0)<(H|0)?H:A+1|0}E=E+1|0;if((E|0)>=(N|0)){La=Ka;break}else H=Ka}}else La=0;switch(b[h>>0]|0){case 6:{Ue(j,Ia);f[l>>2]=0;f[l+4>>2]=i;H=f[F>>2]|0;f[l+8>>2]=H;f[m>>2]=f[i>>2];f[m+4>>2]=i;f[m+8>>2]=H;f[k>>2]=La;f[g>>2]=f[l>>2];f[g+4>>2]=f[l+4>>2];f[g+8>>2]=f[l+8>>2];f[e>>2]=f[m>>2];f[e+4>>2]=f[m+4>>2];f[e+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8>>2];H=Af(j,g,e,k,c)|0;ef(j);if(!H){ia=0;break d}break}case 1:{af(j,Ia);f[w>>2]=0;f[w+4>>2]=i;H=f[F>>2]|0;f[w+8>>2]=H;f[x>>2]=f[i>>2];f[x+4>>2]=i;f[x+8>>2]=H;f[k>>2]=La;f[g>>2]=f[w>>2];f[g+4>>2]=f[w+4>>2];f[g+8>>2]=f[w+8>>2];f[e>>2]=f[x>>2];f[e+4>>2]=f[x+4>>2];f[e+8>>2]=f[x+8>>2];H=zf(j,g,e,k,c)|0;df(j);if(!H){ia=0;break d}break}case 0:{af(j,Ia);f[y>>2]=0;f[y+4>>2]=i;H=f[F>>2]|0;f[y+8>>2]=H;f[z>>2]=f[i>>2];f[z+4>>2]=i;f[z+8>>2]=H;f[k>>2]=La;f[g>>2]=f[y>>2];f[g+4>>2]=f[y+4>>2];f[g+8>>2]=f[y+8>>2];f[e>>2]=f[z>>2];f[e+4>>2]=f[z+4>>2];f[e+8>>2]=f[z+8>>2];H=zf(j,g,e,k,c)|0;df(j);if(!H){ia=0;break d}break}default:{ia=0;break d}}ia=1}while(0);j=f[i+12>>2]|0;if(!j){u=d;return ia|0}i=f[J>>2]|0;if((i|0)!=(j|0))f[J>>2]=i+(~((i+-4-j|0)>>>2)<<2);Oq(j);u=d;return ia|0}function kb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,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+-1|0)?0:Y+1|0;f[P+(V<<2)>>2]=Y;V=V+1|0;Z=f[g>>2]|0;if(V>>>0>=Z>>>0){$=Z;break}else W=Z}}else $=U;if(!z){aa=85;break}else{ba=0;ca=$}while(1){W=(f[I>>2]|0)+((X(f[H>>2]|0,N+ba|0)|0)<<2)|0;if(!ca)da=0;else{V=0;do{Y=f[(f[w>>2]|0)+(V<<2)>>2]|0;P=(f[a>>2]|0)-(f[(f[S>>2]|0)+(Y<<2)>>2]|0)|0;do if(P|0){Z=f[y>>2]|0;ea=32-Z|0;fa=32-P|0;ga=f[W+(Y<<2)>>2]<(ea|0)){ha=ga>>>fa;fa=P-ea|0;f[y>>2]=fa;ea=f[h>>2]|ha>>>fa;f[h>>2]=ea;fa=f[j>>2]|0;if((fa|0)==(f[m>>2]|0))Ri(n,h);else{f[fa>>2]=ea;f[j>>2]=fa+4}f[h>>2]=ha<<32-(f[y>>2]|0);break}ha=f[h>>2]|ga>>>Z;f[h>>2]=ha;ga=Z+P|0;f[y>>2]=ga;if((ga|0)!=32)break;ga=f[j>>2]|0;if((ga|0)==(f[m>>2]|0))Ri(n,h);else{f[ga>>2]=ha;f[j>>2]=ga+4}f[h>>2]=0;f[y>>2]=0}while(0);V=V+1|0;P=f[g>>2]|0}while(V>>>0

    >>0);da=P}ba=ba+1|0;if(ba>>>0>=z>>>0){aa=85;break a}else ca=da}}U=T+1|0;Ig(M+(U*12|0)|0,f[M+(T*12|0)>>2]|0,f[M+(T*12|0)+4>>2]|0);V=(f[(f[k>>2]|0)+(U*12|0)>>2]|0)+(Q<<2)|0;W=(f[V>>2]|0)+(1<>2]=W;V=f[A>>2]|0;P=f[B>>2]|0;b:do if((R|0)==(N|0))ia=N;else{Y=f[J>>2]|0;if(!V){if((f[Y+(Q<<2)>>2]|0)>>>0>>0){ia=R;break}else{ja=R;ka=N}while(1){ga=ja;do{ga=ga+-1|0;if((ka|0)==(ga|0)){ia=ka;break b}ha=(f[K>>2]|0)+((X(ga,P)|0)<<2)+(Q<<2)|0}while((f[ha>>2]|0)>>>0>=W>>>0);ka=ka+1|0;if((ka|0)==(ga|0)){ia=ga;break b}else ja=ga}}else{la=R;ma=N}while(1){ha=ma;while(1){na=Y+((X(ha,V)|0)<<2)|0;if((f[na+(Q<<2)>>2]|0)>>>0>=W>>>0){oa=la;break}Z=ha+1|0;if((Z|0)==(la|0)){ia=la;break b}else ha=Z}while(1){oa=oa+-1|0;if((ha|0)==(oa|0)){ia=ha;break b}pa=(f[K>>2]|0)+((X(oa,P)|0)<<2)|0;if((f[pa+(Q<<2)>>2]|0)>>>0>>0){qa=0;break}}do{ga=na+(qa<<2)|0;Z=pa+(qa<<2)|0;fa=f[ga>>2]|0;f[ga>>2]=f[Z>>2];f[Z>>2]=fa;qa=qa+1|0}while((qa|0)!=(V|0));ma=ha+1|0;if((ma|0)==(oa|0)){ia=oa;break}else la=oa}}while(0);W=(_(z|0)|0)^31;P=ia-N|0;Y=R-ia|0;fa=P>>>0>>0;if((P|0)!=(Y|0)){Z=f[C>>2]|0;if(fa)f[D>>2]=f[D>>2]|1<<31-Z;ga=Z+1|0;f[C>>2]=ga;if((ga|0)==32){ga=f[E>>2]|0;if((ga|0)==(f[F>>2]|0))Ri(G,D);else{f[ga>>2]=f[D>>2];f[E>>2]=ga+4}f[C>>2]=0;f[D>>2]=0}}ga=z>>>1;if(fa){fa=ga-P|0;if(W|0){Z=0;ea=1<>>1}}}else{ea=ga-Y|0;if(W|0){Z=0;fa=1<>>1}}}fa=f[s>>2]|0;W=f[fa+(T*12|0)>>2]|0;Z=W+(Q<<2)|0;f[Z>>2]=(f[Z>>2]|0)+1;Ig(fa+(U*12|0)|0,W,f[fa+(T*12|0)+4>>2]|0);if((ia|0)!=(N|0)){fa=f[o>>2]|0;W=f[t>>2]|0;Z=fa-W>>2;ea=f[v>>2]|0;ga=f[l>>2]|0;if((((Z|0)==0?0:(Z*113|0)+-1|0)|0)==(ga+ea|0)){Pc(e);ra=f[v>>2]|0;sa=f[l>>2]|0;ta=f[o>>2]|0;ua=f[t>>2]|0}else{ra=ea;sa=ga;ta=fa;ua=W}W=sa+ra|0;if((ta|0)==(ua|0))va=0;else va=(f[ua+(((W>>>0)/113|0)<<2)>>2]|0)+(((W>>>0)%113|0)*36|0)|0;f[va>>2]=N;W=va+4|0;f[W>>2]=r;f[W+4>>2]=x;f[va+12>>2]=ia;f[va+16>>2]=i;f[va+20>>2]=V;f[va+24>>2]=Q;f[va+28>>2]=P;f[va+32>>2]=T;f[l>>2]=(f[l>>2]|0)+1}if((R|0)!=(ia|0)){W=f[o>>2]|0;fa=f[t>>2]|0;ga=W-fa>>2;ea=f[v>>2]|0;Z=f[l>>2]|0;if((((ga|0)==0?0:(ga*113|0)+-1|0)|0)==(Z+ea|0)){Pc(e);wa=f[v>>2]|0;xa=f[l>>2]|0;ya=f[o>>2]|0;za=f[t>>2]|0}else{wa=ea;xa=Z;ya=W;za=fa}fa=xa+wa|0;if((ya|0)==(za|0))Aa=0;else Aa=(f[za+(((fa>>>0)/113|0)<<2)>>2]|0)+(((fa>>>0)%113|0)*36|0)|0;f[Aa>>2]=ia;f[Aa+4>>2]=i;f[Aa+8>>2]=V;f[Aa+12>>2]=R;fa=Aa+16|0;f[fa>>2]=p;f[fa+4>>2]=q;f[Aa+24>>2]=Q;f[Aa+28>>2]=Y;f[Aa+32>>2]=U;fa=(f[l>>2]|0)+1|0;f[l>>2]=fa;Ba=fa}else aa=85}else aa=85;while(0);if((aa|0)==85){aa=0;Ba=f[l>>2]|0}if(!Ba)break;else L=Ba}}Ba=f[t>>2]|0;L=f[v>>2]|0;Aa=Ba+(((L>>>0)/113|0)<<2)|0;q=f[o>>2]|0;p=q;i=Ba;if((q|0)==(Ba|0)){Ca=0;Da=0}else{ia=(f[Aa>>2]|0)+(((L>>>0)%113|0)*36|0)|0;Ca=ia;Da=ia}ia=Aa;Aa=Da;c:while(1){Da=Aa;do{L=Da;if((Ca|0)==(L|0))break c;Da=L+36|0}while((Da-(f[ia>>2]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>>2]|0;Q=(f[a>>2]|0)-(f[(f[T>>2]|0)+(Z<<2)>>2]|0)|0;do if(Q|0){$=f[y>>2]|0;fa=32-$|0;ga=32-Q|0;ha=f[Y+(Z<<2)>>2]<(fa|0)){ia=ha>>>ga;ga=Q-fa|0;f[y>>2]=ga;fa=f[h>>2]|ia>>>ga;f[h>>2]=fa;ga=f[j>>2]|0;if((ga|0)==(f[m>>2]|0))Ri(n,h);else{f[ga>>2]=fa;f[j>>2]=ga+4}f[h>>2]=ia<<32-(f[y>>2]|0);break}ia=f[h>>2]|ha>>>$;f[h>>2]=ia;ha=$+Q|0;f[y>>2]=ha;if((ha|0)!=32)break;ha=f[j>>2]|0;if((ha|0)==(f[m>>2]|0))Ri(n,h);else{f[ha>>2]=ia;f[j>>2]=ha+4}f[h>>2]=0;f[y>>2]=0}while(0);W=W+1|0;Q=f[g>>2]|0}while(W>>>0>>0);ea=Q}ca=ca+1|0;if(ca>>>0>=z>>>0){ba=81;break a}else da=ea}}V=U+1|0;Ig(N+(V*12|0)|0,f[N+(U*12|0)>>2]|0,f[N+(U*12|0)+4>>2]|0);W=(f[(f[k>>2]|0)+(V*12|0)>>2]|0)+(R<<2)|0;Y=(f[W>>2]|0)+(1<>2]=Y;W=f[A>>2]|0;Q=f[B>>2]|0;b:do if((S|0)==(O|0))ja=O;else{Z=f[K>>2]|0;if(!W){if((f[Z+(R<<2)>>2]|0)>>>0>>0){ja=S;break}else{ka=S;la=O}while(1){ha=ka;do{ha=ha+-1|0;if((la|0)==(ha|0)){ja=la;break b}ia=(f[L>>2]|0)+((X(ha,Q)|0)<<2)+(R<<2)|0}while((f[ia>>2]|0)>>>0>=Y>>>0);la=la+1|0;if((la|0)==(ha|0)){ja=ha;break b}else ka=ha}}else{ma=S;na=O}while(1){ia=na;while(1){oa=Z+((X(ia,W)|0)<<2)|0;if((f[oa+(R<<2)>>2]|0)>>>0>=Y>>>0){pa=ma;break}$=ia+1|0;if(($|0)==(ma|0)){ja=ma;break b}else ia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1:{Ka=56;ba=95;break}case 2:{Ka=113;ba=95;break}default:{}}if((ba|0)==95)f[v>>2]=Ka;if((Ia|0)!=(Ja|0)){Ka=Ia;do{Oq(f[Ka>>2]|0);Ka=Ka+4|0}while((Ka|0)!=(Ja|0));Ja=f[t>>2]|0;t=f[o>>2]|0;if((t|0)!=(Ja|0))f[o>>2]=t+(~((t+-4-Ja|0)>>>2)<<2)}Ja=f[e>>2]|0;if(!Ja){u=d;return}Oq(Ja);u=d;return}function mb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=Oa,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;if(!(b[a+32>>0]|0)){r=o;m=0;while(1){s=$(b[r>>0]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}else{r=o;m=0;while(1){s=$($(b[r>>0]|0)/$(127.0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}}else t=l;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 2:{r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;u=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+u|0;if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(h[u>>0]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){v=q;break}else u=u+1|0}}else{u=o;k=0;while(1){s=$($(h[u>>0]|0)/$(255.0));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else u=u+1|0}}}else v=m;u=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 3:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$(d[u>>1]|0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else u=u+2|0}}else{u=o;l=0;while(1){s=$($(d[u>>1]|0)/$(32767.0));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else u=u+2|0}}else w=k;u=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 4:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){s=$(j[u>>1]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else u=u+2|0}}else{u=o;m=0;while(1){s=$($(j[u>>1]|0)/$(65535.0));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){x=k;break}else u=u+2|0}}else x=l;u=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 5:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(f[u>>2]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){y=q;break}else u=u+4|0}}else{u=o;k=0;while(1){s=$($(f[u>>2]|0)*$(4.65661287e-10));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){y=l;break}else u=u+4|0}}else y=m;u=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 6:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$((f[u>>2]|0)>>>0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){z=q;break}else u=u+4|0}}else{u=o;l=0;while(1){s=$($((f[u>>2]|0)>>>0)*$(2.32830644e-10));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){z=m;break}else u=u+4|0}}else z=k;u=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 7:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+(f[q+4>>2]|0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else u=u+8|0}}else{u=o;m=0;while(1){k=u;s=$($(+((f[k>>2]|0)>>>0)+4294967296.0*+(f[k+4>>2]|0))*$(1.08420217e-19));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){A=k;break}else u=u+8|0}}else A=l;u=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 8:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+((f[q+4>>2]|0)>>>0));n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){B=q;break}else u=u+8|0}}else{u=o;k=0;while(1){l=u;s=$($(+((f[l>>2]|0)>>>0)+4294967296.0*+((f[l+4>>2]|0)>>>0))*$(5.42101086e-20));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){B=l;break}else u=u+8|0}}else B=m;u=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 9:{u=a+24|0;k=b[u>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;l=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Vn(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=r+q|0;q=0;while(1){f[g+(q<<2)>>2]=f[o>>2];q=q+1|0;r=b[u>>0]|0;if((q|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){C=r;break}else o=o+4|0}}else C=k;o=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 10:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){u=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;l=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=u+l|0;l=0;while(1){s=$(+p[m>>3]);n[g+(l<<2)>>2]=s;l=l+1|0;u=b[o>>0]|0;if((l|0)>=((u<<24>>24>e<<24>>24?e:u)<<24>>24|0)){D=u;break}else m=m+8|0}}else D=q;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){o=f[f[a>>2]>>2]|0;k=a+40|0;u=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Vn(u|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=o+r|0;r=0;while(1){s=$((b[k>>0]|0)!=0&1);n[g+(r<<2)>>2]=s;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){E=o;break}else k=k+1|0}}else E=l;k=E<<24>>24;if(E<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function nb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,L=0,M=0,N=0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H=0;J=0;c:while(1){do if(D)if(!y){L=w;M=o;N=1;O=z;P=A;Q=H;R=J;S=H;T=J}else break c;else{U=Vn(H|0,J|0,1,0)|0;V=I;W=(C|0)!=48;if((o|0)>=125){if(!W){L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}f[B>>2]=f[B>>2]|1;L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}Y=j+(o<<2)|0;if(!w)Z=E;else Z=C+-48+((f[Y>>2]|0)*10|0)|0;f[Y>>2]=Z;Y=w+1|0;_=(Y|0)==9;L=_?0:Y;M=o+(_&1)|0;N=y;O=W?U:z;P=1;Q=F;R=G;S=U;T=V}while(0);V=f[m>>2]|0;if(V>>>0<(f[n>>2]|0)>>>0){f[m>>2]=V+1;$=h[V>>0]|0}else $=Si(a)|0;E=$+-48|0;D=($|0)==46;if(!(D|E>>>0<10)){aa=L;ba=M;ca=O;da=N;ea=$;fa=P;ga=S;ha=Q;ia=T;ja=R;p=29;break b}else{w=L;o=M;z=O;y=N;A=P;C=$;F=Q;G=R;H=S;J=T}}ka=w;la=o;ma=z;na=H;oa=J;pa=F;qa=G;ra=(A|0)!=0;p=37}else{aa=0;ba=0;ca=0;da=q;ea=r;fa=s;ga=0;ha=t;ia=0;ja=v;p=29}while(0);do if((p|0)==29){v=(da|0)==0;t=v?ga:ha;s=v?ia:ja;v=(fa|0)!=0;if(!(v&(ea|32|0)==101))if((ea|0)>-1){ka=aa;la=ba;ma=ca;na=ga;oa=ia;pa=t;qa=s;ra=v;p=37;break}else{sa=aa;ta=ba;ua=ca;va=ga;wa=ia;xa=v;ya=t;za=s;p=39;break}v=Re(a,g)|0;r=I;if((v|0)==0&(r|0)==-2147483648){if(!g){Ym(a,0);Aa=0.0;break}if(!(f[n>>2]|0)){Ba=0;Ca=0}else{f[m>>2]=(f[m>>2]|0)+-1;Ba=0;Ca=0}}else{Ba=v;Ca=r}r=Vn(Ba|0,Ca|0,t|0,s|0)|0;Da=aa;Ea=ba;Fa=ca;Ga=r;Ha=ga;Ia=I;Ja=ia;p=41}while(0);if((p|0)==37)if(f[n>>2]|0){f[m>>2]=(f[m>>2]|0)+-1;if(ra){Da=ka;Ea=la;Fa=ma;Ga=pa;Ha=na;Ia=qa;Ja=oa;p=41}else p=40}else{sa=ka;ta=la;ua=ma;va=na;wa=oa;xa=ra;ya=pa;za=qa;p=39}if((p|0)==39)if(xa){Da=sa;Ea=ta;Fa=ua;Ga=ya;Ha=va;Ia=za;Ja=wa;p=41}else p=40;do if((p|0)==40){wa=Vq()|0;f[wa>>2]=22;Ym(a,0);Aa=0.0}else if((p|0)==41){wa=f[j>>2]|0;if(!wa){Aa=+(e|0)*0.0;break}if(((Ja|0)<0|(Ja|0)==0&Ha>>>0<10)&((Ga|0)==(Ha|0)&(Ia|0)==(Ja|0))?(c|0)>30|(wa>>>c|0)==0:0){Aa=+(e|0)*+(wa>>>0);break}wa=(d|0)/-2|0;za=((wa|0)<0)<<31>>31;if((Ia|0)>(za|0)|(Ia|0)==(za|0)&Ga>>>0>wa>>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}wa=d+-106|0;za=((wa|0)<0)<<31>>31;if((Ia|0)<(za|0)|(Ia|0)==(za|0)&Ga>>>0>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if(!Da)Ka=Ea;else{if((Da|0)<9){wa=j+(Ea<<2)|0;za=Da;va=f[wa>>2]|0;while(1){va=va*10|0;if((za|0)>=8)break;else za=za+1|0}f[wa>>2]=va}Ka=Ea+1|0}if((Fa|0)<9?(Fa|0)<=(Ga|0)&(Ga|0)<18:0){if((Ga|0)==9){Aa=+(e|0)*+((f[j>>2]|0)>>>0);break}if((Ga|0)<9){Aa=+(e|0)*+((f[j>>2]|0)>>>0)/+(f[6720+(8-Ga<<2)>>2]|0);break}za=c+27+(X(Ga,-3)|0)|0;A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if((wa|0)==(Wa|0)){f[A>>2]=f[A>>2]|f[j+(G<<2)>>2];Za=G}else Za=Wa;f[j+(wa<<2)>>2]=Xa;La=va;Ma=Za;Na=wa;Oa=Oa+9|0}e:while(1){za=Va+1&127;H=j+((Va+127&127)<<2)|0;J=Sa;F=Ta;wa=Ua;while(1){G=(wa|0)==18;A=(wa|0)>27?9:1;_a=J;$a=F;while(1){z=0;while(1){ya=z+$a&127;if((ya|0)==(Va|0)){ab=2;p=88;break}w=f[j+(ya<<2)>>2]|0;ya=f[6752+(z<<2)>>2]|0;if(w>>>0>>0){ab=2;p=88;break}if(w>>>0>ya>>>0)break;ya=z+1|0;if((z|0)<1)z=ya;else{ab=ya;p=88;break}}if((p|0)==88?(p=0,G&(ab|0)==2):0){bb=0.0;cb=0;db=Va;break e}eb=A+_a|0;if(($a|0)==(Va|0)){_a=eb;$a=Va}else break}G=(1<>>A;fb=0;gb=$a;hb=wa;ya=$a;do{w=j+(ya<<2)|0;o=f[w>>2]|0;ua=(o>>>A)+fb|0;f[w>>2]=ua;fb=X(o&G,z)|0;o=(ya|0)==(gb|0)&(ua|0)==0;hb=o?hb+-9|0:hb;gb=o?gb+1&127:gb;ya=ya+1&127}while((ya|0)!=(Va|0));if(!fb){J=eb;F=gb;wa=hb;continue}if((za|0)!=(gb|0))break;f[H>>2]=f[H>>2]|1;J=eb;F=gb;wa=hb}f[j+(Va<<2)>>2]=fb;Sa=eb;Ta=gb;Ua=hb;Va=za}while(1){wa=cb+$a&127;F=db+1&127;if((wa|0)==(db|0)){f[j+(F+-1<<2)>>2]=0;ib=F}else ib=db;bb=bb*1.0e9+ +((f[j+(wa<<2)>>2]|0)>>>0);cb=cb+1|0;if((cb|0)==2)break;else db=ib}jb=+(e|0);kb=bb*jb;wa=_a+53|0;F=wa-d|0;J=(F|0)<(c|0);H=J?((F|0)>0?F:0):c;if((H|0)<53){lb=+rq(+bk(1.0,105-H|0),kb);mb=+Dq(kb,+bk(1.0,53-H|0));nb=lb;ob=mb;pb=lb+(kb-mb)}else{nb=0.0;ob=0.0;pb=kb}va=$a+2&127;if((va|0)!=(ib|0)){ya=f[j+(va<<2)>>2]|0;do if(ya>>>0>=5e8){if((ya|0)!=5e8){qb=jb*.75+ob;break}if(($a+3&127|0)==(ib|0)){qb=jb*.5+ob;break}else{qb=jb*.75+ob;break}}else{if((ya|0)==0?($a+3&127|0)==(ib|0):0){qb=ob;break}qb=jb*.25+ob}while(0);if((53-H|0)>1?!(+Dq(qb,1.0)!=0.0):0)rb=qb+1.0;else rb=qb}else rb=ob;jb=pb+rb-nb;do if((wa&2147483647|0)>(-2-k|0)){ya=!(+K(+jb)>=9007199254740992.0);va=_a+((ya^1)&1)|0;kb=ya?jb:jb*.5;if((va+50|0)<=(l|0)?!(rb!=0.0&(J&((H|0)!=(F|0)|ya))):0){sb=kb;tb=va;break}ya=Vq()|0;f[ya>>2]=34;sb=kb;tb=va}else{sb=jb;tb=_a}while(0);Aa=+sq(sb,tb)}while(0);u=i;return +Aa}function ob(a,c,d,e,g,i){a=a|0;c=+c;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0,D=0.0,E=0,F=0,G=0,H=0.0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0.0,ga=0.0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0;j=u;u=u+560|0;k=j+8|0;l=j;m=j+524|0;n=m;o=j+512|0;f[l>>2]=0;p=o+12|0;yo(c)|0;if((I|0)<0){q=-c;r=1;s=16605}else{q=c;r=(g&2049|0)!=0&1;s=(g&2048|0)==0?((g&1|0)==0?16606:16611):16608}yo(q)|0;do if(0==0&(I&2146435072|0)==2146435072){t=(i&32|0)!=0;v=r+3|0;Qk(a,32,d,v,g&-65537);Xo(a,s,r);Xo(a,q!=q|0.0!=0.0?(t?18555:16632):t?16624:16628,3);Qk(a,32,d,v,g^8192);w=v}else{c=+tq(q,l)*2.0;v=c!=0.0;if(v)f[l>>2]=(f[l>>2]|0)+-1;t=i|32;if((t|0)==97){x=i&32;y=(x|0)==0?s:s+9|0;z=r|2;A=12-e|0;do if(!(e>>>0>11|(A|0)==0)){B=8.0;C=A;do{C=C+-1|0;B=B*16.0}while((C|0)!=0);if((b[y>>0]|0)==45){D=-(B+(-c-B));break}else{D=c+B-B;break}}else D=c;while(0);A=f[l>>2]|0;C=(A|0)<0?0-A|0:A;E=Rj(C,((C|0)<0)<<31>>31,p)|0;if((E|0)==(p|0)){C=o+11|0;b[C>>0]=48;F=C}else F=E;b[F+-1>>0]=(A>>31&2)+43;A=F+-2|0;b[A>>0]=i+15;E=(e|0)<1;C=(g&8|0)==0;G=m;H=D;while(1){J=~~H;K=G+1|0;b[G>>0]=x|h[16636+J>>0];H=(H-+(J|0))*16.0;if((K-n|0)==1?!(C&(E&H==0.0)):0){b[K>>0]=46;L=G+2|0}else L=K;if(!(H!=0.0))break;else G=L}G=L;if((e|0)!=0?(-2-n+G|0)<(e|0):0){M=G-n|0;N=e+2|0}else{E=G-n|0;M=E;N=E}E=p-A|0;G=E+z+N|0;Qk(a,32,d,G,g);Xo(a,y,z);Qk(a,48,d,G,g^65536);Xo(a,m,M);Qk(a,48,N-M|0,0,0);Xo(a,A,E);Qk(a,32,d,G,g^8192);w=G;break}G=(e|0)<0?6:e;if(v){E=(f[l>>2]|0)+-28|0;f[l>>2]=E;O=c*268435456.0;P=E}else{O=c;P=f[l>>2]|0}E=(P|0)<0?k:k+288|0;C=E;H=O;do{x=~~H>>>0;f[C>>2]=x;C=C+4|0;H=(H-+(x>>>0))*1.0e9}while(H!=0.0);if((P|0)>0){v=E;A=C;z=P;while(1){y=(z|0)<29?z:29;x=A+-4|0;if(x>>>0>=v>>>0){K=x;x=0;do{J=Tn(f[K>>2]|0,0,y|0)|0;Q=Vn(J|0,I|0,x|0,0)|0;J=I;R=hn(Q|0,J|0,1e9,0)|0;f[K>>2]=R;x=jp(Q|0,J|0,1e9,0)|0;K=K+-4|0}while(K>>>0>=v>>>0);if(x){K=v+-4|0;f[K>>2]=x;S=K}else S=v}else S=v;K=A;while(1){if(K>>>0<=S>>>0)break;J=K+-4|0;if(!(f[J>>2]|0))K=J;else break}x=(f[l>>2]|0)-y|0;f[l>>2]=x;if((x|0)>0){v=S;A=K;z=x}else{T=S;U=K;V=x;break}}}else{T=E;U=C;V=P}if((V|0)<0){z=((G+25|0)/9|0)+1|0;A=(t|0)==102;v=T;x=U;J=V;while(1){Q=0-J|0;R=(Q|0)<9?Q:9;if(v>>>0>>0){Q=(1<>>R;Y=0;Z=v;do{_=f[Z>>2]|0;f[Z>>2]=(_>>>R)+Y;Y=X(_&Q,W)|0;Z=Z+4|0}while(Z>>>0>>0);Z=(f[v>>2]|0)==0?v+4|0:v;if(!Y){$=Z;aa=x}else{f[x>>2]=Y;$=Z;aa=x+4|0}}else{$=(f[v>>2]|0)==0?v+4|0:v;aa=x}Z=A?E:$;W=(aa-Z>>2|0)>(z|0)?Z+(z<<2)|0:aa;J=(f[l>>2]|0)+R|0;f[l>>2]=J;if((J|0)>=0){ba=$;ca=W;break}else{v=$;x=W}}}else{ba=T;ca=U}x=E;if(ba>>>0>>0){v=(x-ba>>2)*9|0;J=f[ba>>2]|0;if(J>>>0<10)da=v;else{z=v;v=10;while(1){v=v*10|0;A=z+1|0;if(J>>>0>>0){da=A;break}else z=A}}}else da=0;z=(t|0)==103;v=(G|0)!=0;J=G-((t|0)!=102?da:0)+((v&z)<<31>>31)|0;if((J|0)<(((ca-x>>2)*9|0)+-9|0)){A=J+9216|0;J=E+4+(((A|0)/9|0)+-1024<<2)|0;C=(A|0)%9|0;if((C|0)<8){A=C;C=10;while(1){W=C*10|0;if((A|0)<7){A=A+1|0;C=W}else{ea=W;break}}}else ea=10;C=f[J>>2]|0;A=(C>>>0)%(ea>>>0)|0;t=(J+4|0)==(ca|0);if(!(t&(A|0)==0)){B=(((C>>>0)/(ea>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;W=(ea|0)/2|0;H=A>>>0>>0?.5:t&(A|0)==(W|0)?1.0:1.5;if(!r){fa=H;ga=B}else{W=(b[s>>0]|0)==45;fa=W?-H:H;ga=W?-B:B}W=C-A|0;f[J>>2]=W;if(ga+fa!=ga){A=W+ea|0;f[J>>2]=A;if(A>>>0>999999999){A=ba;W=J;while(1){C=W+-4|0;f[W>>2]=0;if(C>>>0>>0){t=A+-4|0;f[t>>2]=0;ha=t}else ha=A;t=(f[C>>2]|0)+1|0;f[C>>2]=t;if(t>>>0>999999999){A=ha;W=C}else{ia=ha;ja=C;break}}}else{ia=ba;ja=J}W=(x-ia>>2)*9|0;A=f[ia>>2]|0;if(A>>>0<10){ka=ja;la=W;ma=ia}else{C=W;W=10;while(1){W=W*10|0;t=C+1|0;if(A>>>0>>0){ka=ja;la=t;ma=ia;break}else C=t}}}else{ka=J;la=da;ma=ba}}else{ka=J;la=da;ma=ba}C=ka+4|0;na=la;oa=ca>>>0>C>>>0?C:ca;pa=ma}else{na=da;oa=ca;pa=ba}C=oa;while(1){if(C>>>0<=pa>>>0){qa=0;break}W=C+-4|0;if(!(f[W>>2]|0))C=W;else{qa=1;break}}J=0-na|0;do if(z){W=G+((v^1)&1)|0;if((W|0)>(na|0)&(na|0)>-5){ra=i+-1|0;sa=W+-1-na|0}else{ra=i+-2|0;sa=W+-1|0}W=g&8;if(!W){if(qa?(A=f[C+-4>>2]|0,(A|0)!=0):0)if(!((A>>>0)%10|0)){t=0;Z=10;while(1){Z=Z*10|0;Q=t+1|0;if((A>>>0)%(Z>>>0)|0|0){ta=Q;break}else t=Q}}else ta=0;else ta=9;t=((C-x>>2)*9|0)+-9|0;if((ra|32|0)==102){Z=t-ta|0;A=(Z|0)>0?Z:0;ua=ra;va=(sa|0)<(A|0)?sa:A;wa=0;break}else{A=t+na-ta|0;t=(A|0)>0?A:0;ua=ra;va=(sa|0)<(t|0)?sa:t;wa=0;break}}else{ua=ra;va=sa;wa=W}}else{ua=i;va=G;wa=g&8}while(0);G=va|wa;x=(G|0)!=0&1;v=(ua|32|0)==102;if(v){xa=0;ya=(na|0)>0?na:0}else{z=(na|0)<0?J:na;t=Rj(z,((z|0)<0)<<31>>31,p)|0;z=p;if((z-t|0)<2){A=t;while(1){Z=A+-1|0;b[Z>>0]=48;if((z-Z|0)<2)A=Z;else{za=Z;break}}}else za=t;b[za+-1>>0]=(na>>31&2)+43;A=za+-2|0;b[A>>0]=ua;xa=A;ya=z-A|0}A=r+1+va+x+ya|0;Qk(a,32,d,A,g);Xo(a,s,r);Qk(a,48,d,A,g^65536);if(v){J=pa>>>0>E>>>0?E:pa;Z=m+9|0;R=Z;Y=m+8|0;Q=J;do{K=Rj(f[Q>>2]|0,0,Z)|0;if((Q|0)==(J|0))if((K|0)==(Z|0)){b[Y>>0]=48;Aa=Y}else Aa=K;else if(K>>>0>m>>>0){sj(m|0,48,K-n|0)|0;y=K;while(1){_=y+-1|0;if(_>>>0>m>>>0)y=_;else{Aa=_;break}}}else Aa=K;Xo(a,Aa,R-Aa|0);Q=Q+4|0}while(Q>>>0<=E>>>0);if(G|0)Xo(a,16652,1);if(Q>>>0>>0&(va|0)>0){E=va;R=Q;while(1){Y=Rj(f[R>>2]|0,0,Z)|0;if(Y>>>0>m>>>0){sj(m|0,48,Y-n|0)|0;J=Y;while(1){v=J+-1|0;if(v>>>0>m>>>0)J=v;else{Ba=v;break}}}else Ba=Y;Xo(a,Ba,(E|0)<9?E:9);R=R+4|0;J=E+-9|0;if(!(R>>>0>>0&(E|0)>9)){Ca=J;break}else E=J}}else Ca=va;Qk(a,48,Ca+9|0,9,0)}else{E=qa?C:pa+4|0;if((va|0)>-1){R=m+9|0;Z=(wa|0)==0;Q=R;G=0-n|0;J=m+8|0;K=va;v=pa;while(1){x=Rj(f[v>>2]|0,0,R)|0;if((x|0)==(R|0)){b[J>>0]=48;Da=J}else Da=x;do if((v|0)==(pa|0)){x=Da+1|0;Xo(a,Da,1);if(Z&(K|0)<1){Ea=x;break}Xo(a,16652,1);Ea=x}else{if(Da>>>0<=m>>>0){Ea=Da;break}sj(m|0,48,Da+G|0)|0;x=Da;while(1){z=x+-1|0;if(z>>>0>m>>>0)x=z;else{Ea=z;break}}}while(0);Y=Q-Ea|0;Xo(a,Ea,(K|0)>(Y|0)?Y:K);x=K-Y|0;v=v+4|0;if(!(v>>>0>>0&(x|0)>-1)){Fa=x;break}else K=x}}else Fa=va;Qk(a,48,Fa+18|0,18,0);Xo(a,xa,p-xa|0)}Qk(a,32,d,A,g^8192);w=A}while(0);u=j;return ((w|0)<(d|0)?d:w)|0}function pb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0;c=u;u=u+64|0;d=c+56|0;e=c+52|0;g=c+48|0;h=c+60|0;i=c;j=c+44|0;k=c+40|0;l=c+36|0;m=c+32|0;n=c+28|0;o=c+24|0;p=c+20|0;q=c+16|0;r=c+12|0;if(!(b[a+288>>0]|0)){_e(d,f[a+8>>2]|0);s=a+12|0;t=f[d>>2]|0;f[d>>2]=0;v=f[s>>2]|0;f[s>>2]=t;if(v){Ii(v);Oq(v);v=f[d>>2]|0;f[d>>2]=0;if(v|0){Ii(v);Oq(v)}}else f[d>>2]=0}else{fh(d,f[a+8>>2]|0);v=a+12|0;t=f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>>2]|0;if(E|0){G=E;do{E=G;G=f[G>>2]|0;Oq(E)}while((G|0)!=0)}f[F>>2]=0;F=f[a+124>>2]|0;if(F|0){G=a+120|0;E=0;do{f[(f[G>>2]|0)+(E<<2)>>2]=0;E=E+1|0}while((E|0)!=(F|0))}f[D>>2]=0}f[a+144>>2]=0;D=f[s>>2]|0;F=(f[D+28>>2]|0)-(f[D+24>>2]|0)>>2;f[d>>2]=-1;hg(a+152|0,F,d);F=a+72|0;D=f[F>>2]|0;E=a+76|0;G=f[E>>2]|0;if((G|0)!=(D|0))f[E>>2]=G+(~((G+-4-D|0)>>>2)<<2);D=f[s>>2]|0;gk(F,((f[D+4>>2]|0)-(f[D>>2]|0)>>2>>>0)/3|0);f[a+64>>2]=0;if(!(Be(a)|0)){w=0;u=c;return w|0}if(!(Hg(a)|0)){w=0;u=c;return w|0}D=a+172|0;G=a+176|0;H=(((f[G>>2]|0)-(f[D>>2]|0)|0)/136|0)&255;b[h>>0]=H;I=f[(f[x>>2]|0)+44>>2]|0;J=I+16|0;K=f[J+4>>2]|0;if((K|0)>0|(K|0)==0&(f[J>>2]|0)>>>0>0)L=H;else{f[e>>2]=f[I+4>>2];f[d>>2]=f[e>>2];Me(I,d,h,h+1|0)|0;L=b[h>>0]|0}h=a+284|0;f[h>>2]=L&255;L=f[s>>2]|0;I=(f[L+4>>2]|0)-(f[L>>2]|0)|0;L=I>>2;dj(v);f[i>>2]=0;H=i+4|0;f[H>>2]=0;f[i+8>>2]=0;a:do if((I|0)>0){J=a+104|0;K=i+8|0;M=0;b:while(1){N=(M>>>0)/3|0;O=N>>>5;P=1<<(N&31);if((f[(f[t>>2]|0)+(O<<2)>>2]&P|0)==0?(Q=f[s>>2]|0,f[j>>2]=N,f[d>>2]=f[j>>2],!(_j(Q,d)|0)):0){f[e>>2]=0;f[k>>2]=N;f[d>>2]=f[k>>2];N=xg(a,d,e)|0;fj(v,N);Q=f[e>>2]|0;R=(Q|0)==-1;do if(N){do if(R){S=-1;T=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,m=0,n=0,o=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0;i=u;u=u+64|0;j=i+16|0;k=i;l=i+24|0;m=i+8|0;n=i+20|0;f[j>>2]=c;c=(a|0)!=0;o=l+40|0;q=o;r=l+39|0;l=m+4|0;s=0;t=0;v=0;a:while(1){do if((t|0)>-1)if((s|0)>(2147483647-t|0)){w=Vq()|0;f[w>>2]=75;x=-1;break}else{x=s+t|0;break}else x=t;while(0);w=f[j>>2]|0;y=b[w>>0]|0;if(!(y<<24>>24)){z=88;break}else{A=y;B=w}b:while(1){switch(A<<24>>24){case 37:{C=B;D=B;z=9;break b;break}case 0:{E=B;break b;break}default:{}}y=B+1|0;f[j>>2]=y;A=b[y>>0]|0;B=y}c:do if((z|0)==9)while(1){z=0;if((b[D+1>>0]|0)!=37){E=C;break c}y=C+1|0;D=D+2|0;f[j>>2]=D;if((b[D>>0]|0)!=37){E=y;break}else{C=y;z=9}}while(0);y=E-w|0;if(c)Xo(a,w,y);if(y|0){s=y;t=x;continue}y=(Aq(b[(f[j>>2]|0)+1>>0]|0)|0)==0;F=f[j>>2]|0;if(!y?(b[F+2>>0]|0)==36:0){G=(b[F+1>>0]|0)+-48|0;H=1;J=3}else{G=-1;H=v;J=1}y=F+J|0;f[j>>2]=y;F=b[y>>0]|0;K=(F<<24>>24)+-32|0;if(K>>>0>31|(1<>24)+-32|K;P=F+1|0;f[j>>2]=P;Q=b[P>>0]|0;R=(Q<<24>>24)+-32|0;if(R>>>0>31|(1<>24==42){if((Aq(b[N+1>>0]|0)|0)!=0?(F=f[j>>2]|0,(b[F+2>>0]|0)==36):0){O=F+1|0;f[h+((b[O>>0]|0)+-48<<2)>>2]=10;S=f[g+((b[O>>0]|0)+-48<<3)>>2]|0;T=1;U=F+3|0}else{if(H|0){V=-1;break}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);O=f[F>>2]|0;f[e>>2]=F+4;W=O}else W=0;S=W;T=0;U=(f[j>>2]|0)+1|0}f[j>>2]=U;O=(S|0)<0;X=O?0-S|0:S;Y=O?L|8192:L;Z=T;_=U}else{O=Ll(j)|0;if((O|0)<0){V=-1;break}X=O;Y=L;Z=H;_=f[j>>2]|0}do if((b[_>>0]|0)==46){if((b[_+1>>0]|0)!=42){f[j>>2]=_+1;O=Ll(j)|0;$=O;aa=f[j>>2]|0;break}if(Aq(b[_+2>>0]|0)|0?(O=f[j>>2]|0,(b[O+3>>0]|0)==36):0){F=O+2|0;f[h+((b[F>>0]|0)+-48<<2)>>2]=10;K=f[g+((b[F>>0]|0)+-48<<3)>>2]|0;F=O+4|0;f[j>>2]=F;$=K;aa=F;break}if(Z|0){V=-1;break a}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);K=f[F>>2]|0;f[e>>2]=F+4;ba=K}else ba=0;K=(f[j>>2]|0)+2|0;f[j>>2]=K;$=ba;aa=K}else{$=-1;aa=_}while(0);K=0;F=aa;while(1){if(((b[F>>0]|0)+-65|0)>>>0>57){V=-1;break a}O=F;F=F+1|0;f[j>>2]=F;ca=b[(b[O>>0]|0)+-65+(16124+(K*58|0))>>0]|0;da=ca&255;if((da+-1|0)>>>0>=8)break;else K=da}if(!(ca<<24>>24)){V=-1;break}O=(G|0)>-1;do if(ca<<24>>24==19)if(O){V=-1;break a}else z=50;else{if(O){f[h+(G<<2)>>2]=da;P=g+(G<<3)|0;Q=f[P+4>>2]|0;y=k;f[y>>2]=f[P>>2];f[y+4>>2]=Q;z=50;break}if(!c){V=0;break a}We(k,da,e);ea=f[j>>2]|0}while(0);if((z|0)==50){z=0;if(c)ea=F;else{s=0;t=x;v=Z;continue}}O=b[ea+-1>>0]|0;Q=(K|0)!=0&(O&15|0)==3?O&-33:O;O=Y&-65537;y=(Y&8192|0)==0?Y:O;d:do switch(Q|0){case 110:{switch((K&255)<<24>>24){case 0:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 1:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 2:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}case 3:{d[f[k>>2]>>1]=x;s=0;t=x;v=Z;continue a;break}case 4:{b[f[k>>2]>>0]=x;s=0;t=x;v=Z;continue a;break}case 6:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 7:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}default:{s=0;t=x;v=Z;continue a}}break}case 112:{fa=120;ga=$>>>0>8?$:8;ha=y|8;z=62;break}case 88:case 120:{fa=Q;ga=$;ha=y;z=62;break}case 111:{P=k;R=f[P>>2]|0;ia=f[P+4>>2]|0;P=Ol(R,ia,o)|0;ja=q-P|0;ka=P;la=0;ma=16588;na=(y&8|0)==0|($|0)>(ja|0)?$:ja+1|0;oa=y;pa=R;qa=ia;z=68;break}case 105:case 100:{ia=k;R=f[ia>>2]|0;ja=f[ia+4>>2]|0;if((ja|0)<0){ia=Xn(0,0,R|0,ja|0)|0;P=I;ra=k;f[ra>>2]=ia;f[ra+4>>2]=P;sa=1;ta=16588;ua=ia;va=P;z=67;break d}else{sa=(y&2049|0)!=0&1;ta=(y&2048|0)==0?((y&1|0)==0?16588:16590):16589;ua=R;va=ja;z=67;break d}break}case 117:{ja=k;sa=0;ta=16588;ua=f[ja>>2]|0;va=f[ja+4>>2]|0;z=67;break}case 99:{b[r>>0]=f[k>>2];wa=r;xa=0;ya=16588;za=o;Aa=1;Ba=O;break}case 109:{ja=Vq()|0;Ca=$o(f[ja>>2]|0)|0;z=72;break}case 115:{ja=f[k>>2]|0;Ca=ja|0?ja:16598;z=72;break}case 67:{f[m>>2]=f[k>>2];f[l>>2]=0;f[k>>2]=m;Da=-1;Ea=m;z=76;break}case 83:{ja=f[k>>2]|0;if(!$){Qk(a,32,X,0,y);Fa=0;z=85}else{Da=$;Ea=ja;z=76}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{s=ob(a,+p[k>>3],X,$,y,Q)|0;t=x;v=Z;continue a;break}default:{wa=w;xa=0;ya=16588;za=o;Aa=$;Ba=y}}while(0);e:do if((z|0)==62){z=0;w=k;Q=f[w>>2]|0;K=f[w+4>>2]|0;w=ul(Q,K,o,fa&32)|0;F=(ha&8|0)==0|(Q|0)==0&(K|0)==0;ka=w;la=F?0:2;ma=F?16588:16588+(fa>>4)|0;na=ga;oa=ha;pa=Q;qa=K;z=68}else if((z|0)==67){z=0;ka=Rj(ua,va,o)|0;la=sa;ma=ta;na=$;oa=y;pa=ua;qa=va;z=68}else if((z|0)==72){z=0;K=tg(Ca,0,$)|0;Q=(K|0)==0;wa=Ca;xa=0;ya=16588;za=Q?Ca+$|0:K;Aa=Q?$:K-Ca|0;Ba=O}else if((z|0)==76){z=0;K=Ea;Q=0;F=0;while(1){w=f[K>>2]|0;if(!w){Ga=Q;Ha=F;break}ja=Po(n,w)|0;if((ja|0)<0|ja>>>0>(Da-Q|0)>>>0){Ga=Q;Ha=ja;break}w=ja+Q|0;if(Da>>>0>w>>>0){K=K+4|0;Q=w;F=ja}else{Ga=w;Ha=ja;break}}if((Ha|0)<0){V=-1;break a}Qk(a,32,X,Ga,y);if(!Ga){Fa=0;z=85}else{F=Ea;Q=0;while(1){K=f[F>>2]|0;if(!K){Fa=Ga;z=85;break e}ja=Po(n,K)|0;Q=ja+Q|0;if((Q|0)>(Ga|0)){Fa=Ga;z=85;break e}Xo(a,n,ja);if(Q>>>0>=Ga>>>0){Fa=Ga;z=85;break}else F=F+4|0}}}while(0);if((z|0)==68){z=0;O=(pa|0)!=0|(qa|0)!=0;F=(na|0)!=0|O;Q=q-ka+((O^1)&1)|0;wa=F?ka:o;xa=la;ya=ma;za=o;Aa=F?((na|0)>(Q|0)?na:Q):na;Ba=(na|0)>-1?oa&-65537:oa}else if((z|0)==85){z=0;Qk(a,32,X,Fa,y^8192);s=(X|0)>(Fa|0)?X:Fa;t=x;v=Z;continue}Q=za-wa|0;F=(Aa|0)<(Q|0)?Q:Aa;O=F+xa|0;ja=(X|0)<(O|0)?O:X;Qk(a,32,ja,O,Ba);Xo(a,ya,xa);Qk(a,48,ja,O,Ba^65536);Qk(a,48,F,Q,0);Xo(a,wa,Q);Qk(a,32,ja,O,Ba^8192);s=ja;t=x;v=Z}f:do if((z|0)==88)if(!a)if(v){Z=1;while(1){t=f[h+(Z<<2)>>2]|0;if(!t){Ia=Z;break}We(g+(Z<<3)|0,t,e);t=Z+1|0;if((Z|0)<9)Z=t;else{Ia=t;break}}if((Ia|0)<10){Z=Ia;while(1){if(f[h+(Z<<2)>>2]|0){V=-1;break f}if((Z|0)<9)Z=Z+1|0;else{V=1;break}}}else V=1}else V=0;else V=x;while(0);u=i;return V|0}function rb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0;c=u;u=u+64|0;d=c+56|0;e=c+52|0;g=c+48|0;h=c+60|0;i=c;j=c+44|0;k=c+40|0;l=c+36|0;m=c+32|0;n=c+28|0;o=c+24|0;p=c+20|0;q=c+16|0;r=c+12|0;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0;if((D|0)!=(z|0))f[B>>2]=D+(~((D+-4-z|0)>>>2)<<2);f[a+164>>2]=-1;z=a+168|0;f[z>>2]=0;D=f[a+108>>2]|0;E=a+112|0;F=f[E>>2]|0;if((F|0)!=(D|0))f[E>>2]=F+(~(((F+-12-D|0)>>>0)/12|0)*12|0);D=a+132|0;if(f[D>>2]|0){F=a+128|0;E=f[F>>2]|0;if(E|0){G=E;do{E=G;G=f[G>>2]|0;Oq(E)}while((G|0)!=0)}f[F>>2]=0;F=f[a+124>>2]|0;if(F|0){G=a+120|0;E=0;do{f[(f[G>>2]|0)+(E<<2)>>2]=0;E=E+1|0}while((E|0)!=(F|0))}f[D>>2]=0}f[a+144>>2]=0;D=f[s>>2]|0;F=(f[D+28>>2]|0)-(f[D+24>>2]|0)>>2;f[d>>2]=-1;hg(a+152|0,F,d);F=a+72|0;D=f[F>>2]|0;E=a+76|0;G=f[E>>2]|0;if((G|0)!=(D|0))f[E>>2]=G+(~((G+-4-D|0)>>>2)<<2);D=f[s>>2]|0;gk(F,((f[D+4>>2]|0)-(f[D>>2]|0)>>2>>>0)/3|0);f[a+64>>2]=0;if(!(Be(a)|0)){w=0;u=c;return w|0}if(!(Dg(a)|0)){w=0;u=c;return w|0}D=a+172|0;G=a+176|0;H=(((f[G>>2]|0)-(f[D>>2]|0)|0)/136|0)&255;b[h>>0]=H;I=f[(f[x>>2]|0)+44>>2]|0;J=I+16|0;K=f[J+4>>2]|0;if((K|0)>0|(K|0)==0&(f[J>>2]|0)>>>0>0)L=H;else{f[e>>2]=f[I+4>>2];f[d>>2]=f[e>>2];Me(I,d,h,h+1|0)|0;L=b[h>>0]|0}f[a+284>>2]=L&255;L=f[s>>2]|0;h=(f[L+4>>2]|0)-(f[L>>2]|0)|0;L=h>>2;dj(t);f[i>>2]=0;I=i+4|0;f[I>>2]=0;f[i+8>>2]=0;a:do if((h|0)>0){H=a+104|0;J=i+8|0;K=0;b:while(1){M=(K>>>0)/3|0;N=M>>>5;O=1<<(M&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==0?P+-2|0:X;f[m>>2]=_;f[d>>2]=f[m>>2];Pe(a,d,1)|0;f[n>>2]=f[e>>2];f[d>>2]=f[n>>2];if(!(Yb(a,d)|0))break b}while(0)}K=K+1|0;if((K|0)>=(L|0)){$=62;break a}}aa=0}else $=62;while(0);if(($|0)==62){$=f[F>>2]|0;L=f[E>>2]|0;n=L;if(($|0)!=(L|0)?(m=L+-4|0,$>>>0>>0):0){L=$;$=m;do{m=f[L>>2]|0;f[L>>2]=f[$>>2];f[$>>2]=m;L=L+4|0;$=$+-4|0}while(L>>>0<$>>>0)}f[o>>2]=n;f[p>>2]=f[i>>2];f[q>>2]=f[I>>2];f[g>>2]=f[o>>2];f[e>>2]=f[p>>2];f[d>>2]=f[q>>2];Yd(F,g,e,d)|0;if((f[G>>2]|0)!=(f[D>>2]|0)?(D=f[y>>2]|0,y=((f[D+100>>2]|0)-(f[D+96>>2]|0)|0)/12|0,b[d>>0]=0,qh(v,y,d),y=f[F>>2]|0,F=f[E>>2]|0,(y|0)!=(F|0)):0){E=y;do{f[r>>2]=f[E>>2];f[d>>2]=f[r>>2];He(a,d)|0;E=E+4|0}while((E|0)!=(F|0))}pi(t);ci(f[a+324>>2]|0,f[(f[x>>2]|0)+44>>2]|0)|0;ci(f[z>>2]|0,f[(f[x>>2]|0)+44>>2]|0)|0;if(bh(a)|0){z=f[(f[x>>2]|0)+44>>2]|0;x=f[a+232>>2]|0;t=z+16|0;F=f[t+4>>2]|0;if(!((F|0)>0|(F|0)==0&(f[t>>2]|0)>>>0>0)){t=(f[a+236>>2]|0)-x|0;f[e>>2]=f[z+4>>2];f[d>>2]=f[e>>2];Me(z,d,x,x+t|0)|0}aa=1}else aa=0}t=f[i>>2]|0;if(t|0){i=f[I>>2]|0;if((i|0)!=(t|0))f[I>>2]=i+(~((i+-4-t|0)>>>2)<<2);Oq(t)}w=aa;u=c;return w|0}function sb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p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;if((G|0)!=0?(H=f[G>>2]|0,(H|0)!=0):0){G=f[s>>2]|0;I=G+8|0;J=G+12|0;b:do if(C){G=H;while(1){K=f[G+4>>2]|0;L=(K|0)==(E|0);if(!(L|(K&A|0)==(F|0))){M=44;break a}c:do if(L){K=f[G+8>>2]|0;N=f[I>>2]|0;O=(f[J>>2]|0)-N|0;P=N;if((O|0)<=0){Q=G;break b}N=O>>>2;O=0;while(1){R=f[P+(O<<2)>>2]|0;if(!(b[R+84>>0]|0)){S=f[R+68>>2]|0;T=f[S+(v<<2)>>2]|0;U=f[S+(K<<2)>>2]|0}else{T=v;U=K}O=O+1|0;if((U|0)!=(T|0))break c;if((O|0)>=(N|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}else{G=H;while(1){L=f[G+4>>2]|0;d:do if((L|0)!=(E|0)){if(L>>>0>>0)X=L;else X=(L>>>0)%(B>>>0)|0;if((X|0)!=(F|0)){M=44;break a}}else{N=f[G+8>>2]|0;O=f[I>>2]|0;K=(f[J>>2]|0)-O|0;P=O;if((K|0)<=0){Q=G;break b}O=K>>>2;K=0;while(1){S=f[P+(K<<2)>>2]|0;if(!(b[S+84>>0]|0)){R=f[S+68>>2]|0;Y=f[R+(v<<2)>>2]|0;Z=f[R+(N<<2)>>2]|0}else{Y=v;Z=N}K=K+1|0;if((Z|0)!=(Y|0))break d;if((K|0)>=(O|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}while(0);if((M|0)==42){M=0;if(!V){M=44;break}else Q=V}f[(f[e>>2]|0)+(v<<2)>>2]=f[Q+12>>2];_=t}else M=44}else M=44;while(0);do if((M|0)==44){M=0;if(w){J=y>>>2;I=0;H=0;while(1){A=f[z+(I<<2)>>2]|0;if(!(b[A+84>>0]|0))aa=f[(f[A+68>>2]|0)+(v<<2)>>2]|0;else aa=v;A=aa+239^H;I=I+1|0;if((I|0)>=(J|0)){ba=A;break}else H=A}}else ba=0;e:do if(!x){H=B+-1|0;J=(H&B|0)==0;if(!J)if(ba>>>0>>0)ca=ba;else ca=(ba>>>0)%(B>>>0)|0;else ca=H&ba;I=f[(f[d>>2]|0)+(ca<<2)>>2]|0;if((I|0)!=0?(A=f[I>>2]|0,(A|0)!=0):0){I=f[s>>2]|0;C=I+8|0;G=I+12|0;if(J){J=A;while(1){I=f[J+4>>2]|0;if(!((I|0)==(ba|0)|(I&H|0)==(ca|0))){da=ca;M=76;break e}I=f[J+8>>2]|0;L=f[C>>2]|0;O=(f[G>>2]|0)-L|0;K=L;if((O|0)<=0){ea=v;break e}L=O>>>2;O=0;while(1){N=f[K+(O<<2)>>2]|0;if(!(b[N+84>>0]|0)){P=f[N+68>>2]|0;fa=f[P+(v<<2)>>2]|0;ga=f[P+(I<<2)>>2]|0}else{fa=v;ga=I}O=O+1|0;if((ga|0)!=(fa|0))break;if((O|0)>=(L|0)){ea=v;break e}}J=f[J>>2]|0;if(!J){da=ca;M=76;break e}}}else ha=A;while(1){J=f[ha+4>>2]|0;if((J|0)!=(ba|0)){if(J>>>0>>0)ia=J;else ia=(J>>>0)%(B>>>0)|0;if((ia|0)!=(ca|0)){da=ca;M=76;break e}}J=f[ha+8>>2]|0;H=f[C>>2]|0;L=(f[G>>2]|0)-H|0;O=H;if((L|0)<=0){ea=v;break e}H=L>>>2;L=0;while(1){I=f[O+(L<<2)>>2]|0;if(!(b[I+84>>0]|0)){K=f[I+68>>2]|0;ja=f[K+(v<<2)>>2]|0;ka=f[K+(J<<2)>>2]|0}else{ja=v;ka=J}L=L+1|0;if((ka|0)!=(ja|0))break;if((L|0)>=(H|0)){ea=v;break e}}ha=f[ha>>2]|0;if(!ha){da=ca;M=76;break}}}else{da=ca;M=76}}else{da=0;M=76}while(0);if((M|0)==76){M=0;G=ln(16)|0;f[G+8>>2]=v;f[G+12>>2]=t;f[G+4>>2]=ba;f[G>>2]=0;la=$(((f[o>>2]|0)+1|0)>>>0);ma=$(B>>>0);na=$(n[l>>2]);do if(x|$(na*ma)>>0<3|(B+-1&B|0)!=0)&1;A=~~$(W($(la/na)))>>>0;Ih(d,C>>>0>>0?A:C);C=f[q>>2]|0;A=C+-1|0;if(!(A&C)){oa=C;pa=A&ba;break}if(ba>>>0>>0){oa=C;pa=ba}else{oa=C;pa=(ba>>>0)%(C>>>0)|0}}else{oa=B;pa=da}while(0);C=(f[d>>2]|0)+(pa<<2)|0;A=f[C>>2]|0;if(!A){f[G>>2]=f[p>>2];f[p>>2]=G;f[C>>2]=p;C=f[G>>2]|0;if(C|0){H=f[C+4>>2]|0;C=oa+-1|0;if(C&oa)if(H>>>0>>0)qa=H;else qa=(H>>>0)%(oa>>>0)|0;else qa=H&C;ra=(f[d>>2]|0)+(qa<<2)|0;M=89}}else{f[G>>2]=f[A>>2];ra=A;M=89}if((M|0)==89){M=0;f[ra>>2]=G}f[o>>2]=(f[o>>2]|0)+1;ea=f[h>>2]|0}A=t+1|0;f[(f[e>>2]|0)+(ea<<2)>>2]=t;C=f[k>>2]|0;if((C|0)==(f[r>>2]|0)){Ri(g,h);_=A;break}else{f[C>>2]=f[h>>2];f[k>>2]=C+4;_=A;break}}while(0);v=(f[h>>2]|0)+1|0;f[h>>2]=v;sa=f[j>>2]|0;if(v>>>0>=sa>>>0)break;else t=_}if((_|0)!=(sa|0)){Xa[f[(f[a>>2]|0)+24>>2]&15](a,e,g);f[j>>2]=_}}_=f[g>>2]|0;if(_|0){g=f[k>>2]|0;if((g|0)!=(_|0))f[k>>2]=g+(~((g+-4-_|0)>>>2)<<2);Oq(_)}_=f[e>>2]|0;if(_|0){e=f[i>>2]|0;if((e|0)!=(_|0))f[i>>2]=e+(~((e+-4-_|0)>>>2)<<2);Oq(_)}_=f[d+8>>2]|0;if(_|0){e=_;do{_=e;e=f[e>>2]|0;Oq(_)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return}Oq(e);u=c;return}function tb(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=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,F>>>0<1073741823?(E>>>0>>0?U:E):2147483647);da=f[T>>2]|0;break}else da=F;while(0);f[T>>2]=da+1;L=(f[B>>2]|0)+(da>>>5<<2)|0;f[L>>2]=f[L>>2]|1<<(da&31);ea=x;fa=p;ga=K;ha=D}else{do if(P)if((F+1|0)<0)aq(B);else{L=O<<6;N=F+32&-32;vi(B,F>>>0<1073741823?(L>>>0>>0?N:L):2147483647);ia=f[T>>2]|0;break}else ia=F;while(0);f[T>>2]=ia+1;F=(f[B>>2]|0)+(ia>>>5<<2)|0;f[F>>2]=f[F>>2]&~(1<<(ia&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(r)ja=m<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(ja<<2)>>2];f[a+12>>2]=f[d+(ja+1<<2)>>2];u=g;return}function ub(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;g=u;u=u+80|0;h=g+76|0;i=g+72|0;j=g+48|0;k=g+24|0;l=g;m=a+32|0;n=f[c>>2]|0;c=n+1|0;do if((n|0)!=-1){o=((c>>>0)%3|0|0)==0?n+-2|0:c;if(!((n>>>0)%3|0)){p=n+2|0;q=o;break}else{p=n+-1|0;q=o;break}}else{p=-1;q=-1}while(0);n=f[(f[m>>2]|0)+28>>2]|0;m=f[n+(q<<2)>>2]|0;q=f[n+(p<<2)>>2]|0;p=f[a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0;s=I;H=Ik(E|0,C|0,N|0,L|0)|0;C=I;E=e<<1;F=f[d+(E<<2)>>2]|0;M=((F|0)<0)<<31>>31;B=f[d+((E|1)<<2)>>2]|0;E=((B|0)<0)<<31>>31;O=Xn(F|0,M|0,x|0,D|0)|0;J=I;P=Xn(B|0,E|0,c|0,K|0)|0;U=I;T=un(O|0,J|0,O|0,J|0)|0;J=I;O=un(P|0,U|0,P|0,U|0)|0;U=Vn(O|0,I|0,T|0,J|0)|0;J=I;T=Xn(F|0,M|0,G|0,s|0)|0;M=I;F=Xn(B|0,E|0,H|0,C|0)|0;E=I;B=un(T|0,M|0,T|0,M|0)|0;M=I;T=un(F|0,E|0,F|0,E|0)|0;E=Vn(T|0,I|0,B|0,M|0)|0;M=I;B=a+16|0;T=a+20|0;F=f[T>>2]|0;O=f[a+24>>2]|0;P=(F|0)==(O<<5|0);if(J>>>0>>0|(J|0)==(M|0)&U>>>0>>0){do if(P)if((F+1|0)<0)aq(B);else{E=O<<6;U=F+32&-32;vi(B,F>>>0<1073741823?(E>>>0>>0?U:E):2147483647);da=f[T>>2]|0;break}else da=F;while(0);f[T>>2]=da+1;L=(f[B>>2]|0)+(da>>>5<<2)|0;f[L>>2]=f[L>>2]|1<<(da&31);ea=x;fa=c;ga=K;ha=D}else{do if(P)if((F+1|0)<0)aq(B);else{L=O<<6;N=F+32&-32;vi(B,F>>>0<1073741823?(L>>>0>>0?N:L):2147483647);ia=f[T>>2]|0;break}else ia=F;while(0);f[T>>2]=ia+1;F=(f[B>>2]|0)+(ia>>>5<<2)|0;f[F>>2]=f[F>>2]&~(1<<(ia&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(q)ja=n<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(ja<<2)>>2];f[a+12>>2]=f[d+(ja+1<<2)>>2];u=g;return}function vb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=Oa,D=0,E=0.0,F=0,G=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){m=b[o>>0]|0;q=g+(r<<3)|0;f[q>>2]=m;f[q+4>>2]=((m|0)<0)<<31>>31;r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=g+(t<<3)|0;f[k>>2]=h[m>>0];f[k+4>>2]=0;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){o=d[l>>1]|0;k=g+(q<<3)|0;f[k>>2]=o;f[k+4>>2]=((o|0)<0)<<31>>31;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=j[r>>1];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<3)|0,0,(e<<24>>24)-r<<3|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){l=f[t>>2]|0;m=g+(o<<3)|0;f[m>>2]=l;f[m+4>>2]=((l|0)<0)<<31>>31;o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){r=g+(m<<3)|0;f[r>>2]=f[q>>2];f[r+4>>2]=0;m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){t=k;r=f[t+4>>2]|0;z=g+(l<<3)|0;f[z>>2]=f[t>>2];f[z+4>>2]=r;l=l+1|0;r=b[q>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=m;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;r=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;z=Vn(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+z|0;z=0;while(1){q=o;r=f[q+4>>2]|0;t=g+(z<<3)|0;f[t>>2]=f[q>>2];f[t+4>>2]=r;z=z+1|0;r=b[k>>0]|0;if((z|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){B=r;break}else o=o+8|0}}else B=l;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 9:{o=a+24|0;z=b[o>>0]|0;if((z<<24>>24>e<<24>>24?e:z)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){C=$(n[m>>2]);k=+K(+C)>=1.0?(+C>0.0?~~+Y(+J(+C/4294967296.0),4294967295.0)>>>0:~~+W((+C-+(~~+C>>>0))/4294967296.0)>>>0):0;r=g+(t<<3)|0;f[r>>2]=~~+C>>>0;f[r+4>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else m=m+4|0}}else D=z;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+r|0;r=0;while(1){E=+p[l>>3];o=+K(E)>=1.0?(E>0.0?~~+Y(+J(E/4294967296.0),4294967295.0)>>>0:~~+W((E-+(~~E>>>0))/4294967296.0)>>>0):0;k=g+(r<<3)|0;f[k>>2]=~~E>>>0;f[k+4>>2]=o;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){F=o;break}else l=l+8|0}}else F=t;l=F<<24>>24;if(F<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 11:{l=a+24|0;r=b[l>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){m=f[f[a>>2]>>2]|0;z=a+40|0;o=un(f[z>>2]|0,f[z+4>>2]|0,f[c>>2]|0,0)|0;z=a+48|0;k=Vn(o|0,I|0,f[z>>2]|0,f[z+4>>2]|0)|0;z=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=h[z>>0];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){G=m;break}else z=z+1|0}}else G=r;z=G<<24>>24;if(G<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(z<<3)|0,0,(e<<24>>24)-z<<3|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;c=u;u=u+16|0;d=c+8|0;e=c;if((f[a+96>>2]|0)==(f[a+92>>2]|0)){u=c;return}g=a+56|0;h=f[g>>2]|0;if((h|0)==(f[a+60>>2]|0)){Ri(a+52|0,b);i=b}else{f[h>>2]=f[b>>2];f[g>>2]=h+4;i=b}b=a+88|0;f[b>>2]=0;h=f[a>>2]|0;g=f[i>>2]|0;j=g+1|0;if((g|0)!=-1){k=((j>>>0)%3|0|0)==0?g+-2|0:j;if((k|0)==-1)l=-1;else l=f[(f[h>>2]|0)+(k<<2)>>2]|0;k=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((k|0)==-1){m=l;n=-1}else{m=l;n=f[(f[h>>2]|0)+(k<<2)>>2]|0}}else{m=-1;n=-1}k=a+24|0;h=f[k>>2]|0;l=h+(m>>>5<<2)|0;g=1<<(m&31);j=f[l>>2]|0;if(!(j&g)){f[l>>2]=j|g;g=f[i>>2]|0;j=g+1|0;if((g|0)==-1)o=-1;else o=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=o;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((o>>>0)/3|0)*12|0)+(((o>>>0)%3|0)<<2)>>2]|0;o=f[a+48>>2]|0;f[d>>2]=j;g=f[o+4>>2]|0;o=g+4|0;l=f[o>>2]|0;if((l|0)==(f[g+8>>2]|0))Ri(g,d);else{f[l>>2]=j;f[o>>2]=l+4}l=a+40|0;o=f[l>>2]|0;j=o+4|0;g=f[j>>2]|0;if((g|0)==(f[o+8>>2]|0)){Ri(o,e);p=f[l>>2]|0}else{f[g>>2]=f[e>>2];f[j>>2]=g+4;p=o}o=p+24|0;f[(f[p+12>>2]|0)+(m<<2)>>2]=f[o>>2];f[o>>2]=(f[o>>2]|0)+1;q=f[k>>2]|0}else q=h;h=q+(n>>>5<<2)|0;q=1<<(n&31);o=f[h>>2]|0;if(!(o&q)){f[h>>2]=o|q;q=f[i>>2]|0;do if((q|0)!=-1)if(!((q>>>0)%3|0)){r=q+2|0;break}else{r=q+-1|0;break}else r=-1;while(0);f[e>>2]=r;q=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=q;o=f[r+4>>2]|0;r=o+4|0;h=f[r>>2]|0;if((h|0)==(f[o+8>>2]|0))Ri(o,d);else{f[h>>2]=q;f[r>>2]=h+4}h=a+40|0;r=f[h>>2]|0;q=r+4|0;o=f[q>>2]|0;if((o|0)==(f[r+8>>2]|0)){Ri(r,e);s=f[h>>2]|0}else{f[o>>2]=f[e>>2];f[q>>2]=o+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(n<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1}r=f[i>>2]|0;if((r|0)==-1)t=-1;else t=f[(f[f[a>>2]>>2]|0)+(r<<2)>>2]|0;r=(f[k>>2]|0)+(t>>>5<<2)|0;n=1<<(t&31);s=f[r>>2]|0;if(!(n&s)){f[r>>2]=s|n;n=f[i>>2]|0;f[e>>2]=n;s=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((n>>>0)/3|0)*12|0)+(((n>>>0)%3|0)<<2)>>2]|0;n=f[a+48>>2]|0;f[d>>2]=s;r=f[n+4>>2]|0;n=r+4|0;o=f[n>>2]|0;if((o|0)==(f[r+8>>2]|0))Ri(r,d);else{f[o>>2]=s;f[n>>2]=o+4}o=a+40|0;n=f[o>>2]|0;s=n+4|0;r=f[s>>2]|0;if((r|0)==(f[n+8>>2]|0)){Ri(n,e);v=f[o>>2]|0}else{f[r>>2]=f[e>>2];f[s>>2]=r+4;v=n}n=v+24|0;f[(f[v+12>>2]|0)+(t<<2)>>2]=f[n>>2];f[n>>2]=(f[n>>2]|0)+1}n=f[b>>2]|0;a:do if((n|0)<3){t=a+12|0;v=a+44|0;r=a+48|0;s=a+40|0;o=a+92|0;q=n;while(1){h=q;while(1){w=a+52+(h*12|0)+4|0;x=f[w>>2]|0;if((f[a+52+(h*12|0)>>2]|0)!=(x|0))break;if((h|0)<2)h=h+1|0;else break a}m=x+-4|0;p=f[m>>2]|0;f[w>>2]=m;f[b>>2]=h;f[i>>2]=p;if((p|0)==-1)break;m=(p>>>0)/3|0;g=f[t>>2]|0;do if(!(f[g+(m>>>5<<2)>>2]&1<<(m&31))){j=p;l=g;b:while(1){y=(j>>>0)/3|0;z=l+(y>>>5<<2)|0;f[z>>2]=1<<(y&31)|f[z>>2];z=f[i>>2]|0;if((z|0)==-1)A=-1;else A=f[(f[f[a>>2]>>2]|0)+(z<<2)>>2]|0;y=(f[k>>2]|0)+(A>>>5<<2)|0;B=1<<(A&31);C=f[y>>2]|0;if(!(B&C)){f[y>>2]=C|B;B=f[i>>2]|0;f[e>>2]=B;C=f[(f[(f[v>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=C;y=f[B+4>>2]|0;B=y+4|0;D=f[B>>2]|0;if((D|0)==(f[y+8>>2]|0))Ri(y,d);else{f[D>>2]=C;f[B>>2]=D+4}D=f[s>>2]|0;B=D+4|0;C=f[B>>2]|0;if((C|0)==(f[D+8>>2]|0)){Ri(D,e);E=f[s>>2]|0}else{f[C>>2]=f[e>>2];f[B>>2]=C+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(A<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;F=f[i>>2]|0}else F=z;z=f[a>>2]|0;if((F|0)==-1){G=93;break}D=F+1|0;C=((D>>>0)%3|0|0)==0?F+-2|0:D;if((C|0)==-1)H=-1;else H=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((C|0)==-1)I=-1;else I=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(H|0)==-1;D=C?-1:(H>>>0)/3|0;B=(I|0)==-1;y=B?-1:(I>>>0)/3|0;if(C)J=1;else J=(f[(f[t>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)|0)!=0;do if(B)if(J){G=93;break b}else G=82;else{if(f[(f[t>>2]|0)+(y>>>5<<2)>>2]&1<<(y&31)|0)if(J){G=93;break b}else{G=82;break}D=f[(f[z>>2]|0)+(I<<2)>>2]|0;if(!(1<<(D&31)&f[(f[k>>2]|0)+(D>>>5<<2)>>2])){K=(f[o>>2]|0)+(D<<2)|0;D=f[K>>2]|0;f[K>>2]=D+1;L=(D|0)>0?1:2}else L=0;if(J?(L|0)<=(f[b>>2]|0):0){M=I;break}f[d>>2]=I;D=a+52+(L*12|0)+4|0;K=f[D>>2]|0;if((K|0)==(f[a+52+(L*12|0)+8>>2]|0))Ri(a+52+(L*12|0)|0,d);else{f[K>>2]=I;f[D>>2]=K+4}if((f[b>>2]|0)>(L|0))f[b>>2]=L;if(J){G=93;break b}else G=82}while(0);if((G|0)==82){G=0;if(C)N=-1;else N=f[(f[f[a>>2]>>2]|0)+(H<<2)>>2]|0;if(!(1<<(N&31)&f[(f[k>>2]|0)+(N>>>5<<2)>>2])){z=(f[o>>2]|0)+(N<<2)|0;y=f[z>>2]|0;f[z>>2]=y+1;O=(y|0)>0?1:2}else O=0;if((O|0)>(f[b>>2]|0))break;else M=H}f[i>>2]=M;j=M;l=f[t>>2]|0}if((G|0)==93){G=0;P=f[b>>2]|0;break}f[d>>2]=H;l=a+52+(O*12|0)+4|0;j=f[l>>2]|0;if((j|0)==(f[a+52+(O*12|0)+8>>2]|0))Ri(a+52+(O*12|0)|0,d);else{f[j>>2]=H;f[l>>2]=j+4}j=f[b>>2]|0;if((j|0)>(O|0)){f[b>>2]=O;Q=O}else Q=j;P=Q}else P=h;while(0);if((P|0)<3)q=P;else break a}u=c;return}while(0);f[i>>2]=-1;u=c;return}function xb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}xb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;xb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function yb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}yb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;yb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function zb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}zb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;zb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ab(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ab(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ab(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}} +function Bb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Bb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Bb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Cb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Cb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Cb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Db(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Db(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Db(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Eb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Eb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Eb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Fb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Fb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Gb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Gb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Gb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Hb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Hb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Hb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ib(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ib(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ib(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Jb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Jb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Jb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Kb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Kb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Kb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Lb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Lb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Lb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Mb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Mb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Mb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Nb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Nb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Nb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ob(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ob(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ob(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Pb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2])>>>0;f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3]>>>0;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Qb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2]);f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Rb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=Oa,J=0,K=0,L=0,M=0,N=Oa;e=u;u=u+48|0;g=e+36|0;h=e+24|0;i=e+12|0;j=e;if(!(xh(a,c,d)|0)){k=0;u=e;return k|0}l=f[(f[(f[c+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;if((f[l+28>>2]|0)!=9){k=0;u=e;return k|0}m=c+48|0;c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=17;p=o;q=14495;r=p+17|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+17>>0]=0;o=c+16|0;s=f[o>>2]|0;if(s){t=o;v=s;a:while(1){s=v;while(1){if((f[s+16>>2]|0)>=(d|0))break;w=f[s+4>>2]|0;if(!w){x=t;break a}else s=w}v=f[s>>2]|0;if(!v){x=s;break}else t=s}if(((x|0)!=(o|0)?(f[x+16>>2]|0)<=(d|0):0)?(o=x+20|0,(Jh(o,g)|0)!=0):0)y=Hk(o,g,-1)|0;else z=12}else z=12;if((z|0)==12)y=Hk(c,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((y|0)<1){k=0;u=e;return k|0}c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=19;p=o;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+19>>0]=0;o=c+16|0;x=f[o>>2]|0;if(x){t=o;v=x;b:while(1){x=v;while(1){if((f[x+16>>2]|0)>=(d|0))break;w=f[x+4>>2]|0;if(!w){A=t;break b}else x=w}v=f[x>>2]|0;if(!v){A=x;break}else t=x}if((A|0)!=(o|0)?(f[A+16>>2]|0)<=(d|0):0)B=A+20|0;else z=24}else z=24;if((z|0)==24)B=c;if(!(Jh(B,g)|0))C=0;else{B=f[m>>2]|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=18;p=c;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[c+18>>0]=0;c=B+16|0;A=f[c>>2]|0;if(A){o=c;t=A;c:while(1){A=t;while(1){if((f[A+16>>2]|0)>=(d|0))break;v=f[A+4>>2]|0;if(!v){D=o;break c}else A=v}t=f[A>>2]|0;if(!t){D=A;break}else o=A}if((D|0)!=(c|0)?(f[D+16>>2]|0)<=(d|0):0)E=D+20|0;else z=34}else z=34;if((z|0)==34)E=B;B=(Jh(E,h)|0)!=0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);C=B}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!C){Wd(a+40|0,l,y)|0;k=1;u=e;return k|0}C=l+24|0;l=b[C>>0]|0;B=l<<24>>24;f[i>>2]=0;E=i+4|0;f[E>>2]=0;f[i+8>>2]=0;do if(l<<24>>24)if(l<<24>>24<0)aq(i);else{D=B<<2;c=ln(D)|0;f[i>>2]=c;o=c+(B<<2)|0;f[i+8>>2]=o;sj(c|0,0,D|0)|0;f[E>>2]=o;F=c;break}else F=0;while(0);B=f[m>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=ln(32)|0;f[j>>2]=l;f[j+8>>2]=-2147483616;f[j+4>>2]=19;p=l;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[l+19>>0]=0;l=b[C>>0]|0;c=l<<24>>24;o=B+16|0;D=f[o>>2]|0;if(D){t=o;x=D;d:while(1){D=x;while(1){if((f[D+16>>2]|0)>=(d|0))break;v=f[D+4>>2]|0;if(!v){G=t;break d}else D=v}x=f[D>>2]|0;if(!x){G=D;break}else t=D}if(((G|0)!=(o|0)?(f[G+16>>2]|0)<=(d|0):0)?(o=G+20|0,(Jh(o,j)|0)!=0):0){t=Rg(o,j)|0;if((t|0)!=(G+24|0)){pj(g,t+28|0);t=g+11|0;G=b[t>>0]|0;o=G<<24>>24<0;if(!((o?f[g+4>>2]|0:G&255)|0))H=G;else{if(l<<24>>24>0){x=o?f[g>>2]|0:g;o=0;do{I=$(bq(x,h));A=x;x=f[h>>2]|0;if((A|0)==(x|0))break;n[F+(o<<2)>>2]=I;o=o+1|0}while((o|0)<(c|0));J=b[t>>0]|0}else J=G;H=J}if(H<<24>>24<0)Oq(f[g>>2]|0)}}else z=64}else z=64;if((z|0)==64?(H=Rg(B,j)|0,(H|0)!=(B+4|0)):0){pj(g,H+28|0);H=g+11|0;B=b[H>>0]|0;J=B<<24>>24<0;if(!((J?f[g+4>>2]|0:B&255)|0))K=B;else{if(l<<24>>24>0){l=J?f[g>>2]|0:g;J=0;do{I=$(bq(l,h));G=l;l=f[h>>2]|0;if((G|0)==(l|0))break;n[F+(J<<2)>>2]=I;J=J+1|0}while((J|0)<(c|0));L=b[H>>0]|0}else L=B;K=L}if(K<<24>>24<0)Oq(f[g>>2]|0)}if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);j=f[m>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;m=ln(32)|0;f[g>>2]=m;f[g+8>>2]=-2147483616;f[g+4>>2]=18;p=m;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[m+18>>0]=0;m=j+16|0;q=f[m>>2]|0;if(q){p=m;r=q;e:while(1){q=r;while(1){if((f[q+16>>2]|0)>=(d|0))break;K=f[q+4>>2]|0;if(!K){M=p;break e}else q=K}r=f[q>>2]|0;if(!r){M=q;break}else p=q}if(((M|0)!=(m|0)?(f[M+16>>2]|0)<=(d|0):0)?(d=M+20|0,(Jh(d,g)|0)!=0):0)N=$(sk(d,g,$(1.0)));else z=86}else z=86;if((z|0)==86)N=$(sk(j,g,$(1.0)));if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Dl(a+40|0,y,f[i>>2]|0,b[C>>0]|0,N);C=f[i>>2]|0;if(C|0){i=f[E>>2]|0;if((i|0)!=(C|0))f[E>>2]=i+(~((i+-4-C|0)>>>2)<<2);Oq(C)}k=1;u=e;return k|0}function Sb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,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T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>>2]|0)+U|0;else ta=U;else ta=U-(f[F>>2]|0)|0;f[G>>2]=ta;if((((ra|0)>-1?ra:0-ra|0)+((qa|0)>-1?qa:0-qa|0)|0)<(((sa|0)>-1?sa:0-sa|0)+((ta|0)>-1?ta:0-ta|0)|0)){fj(g,0);ua=k}else{fj(g,1);ua=l}U=f[ua>>2]|0;if((U|0)<0)va=(f[F>>2]|0)+U|0;else va=U;U=c+(N<<2)|0;f[U>>2]=va;O=f[ua+4>>2]|0;if((O|0)<0)wa=(f[F>>2]|0)+O|0;else wa=O;f[U+4>>2]=wa;K=K+1|0;if((K|0)>=(r|0)){la=3;break}U=f[o>>2]|0;L=f[U>>2]|0;if((f[U+4>>2]|0)-L>>2>>>0<=K>>>0){J=U;la=4;break}}if((la|0)==3){u=e;return 1}else if((la|0)==4)aq(J);return 0}function Tb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0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)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>>2]|0)+U|0;else ta=U;else ta=U-(f[F>>2]|0)|0;f[G>>2]=ta;if((((ra|0)>-1?ra:0-ra|0)+((qa|0)>-1?qa:0-qa|0)|0)<(((sa|0)>-1?sa:0-sa|0)+((ta|0)>-1?ta:0-ta|0)|0)){fj(g,0);ua=k}else{fj(g,1);ua=l}U=f[ua>>2]|0;if((U|0)<0)va=(f[F>>2]|0)+U|0;else va=U;U=c+(N<<2)|0;f[U>>2]=va;O=f[ua+4>>2]|0;if((O|0)<0)wa=(f[F>>2]|0)+O|0;else wa=O;f[U+4>>2]=wa;K=K+1|0;if((K|0)>=(r|0)){la=3;break}U=f[o>>2]|0;L=f[U>>2]|0;if((f[U+4>>2]|0)-L>>2>>>0<=K>>>0){J=U;la=4;break}}if((la|0)==3){u=e;return 1}else if((la|0)==4)aq(J);return 0}function Ub(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=Oa,V=Oa,Y=Oa,Z=0,_=0,aa=0,ba=0;d=u;u=u+16|0;e=d;g=a+16|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[g>>2]=$(1.0);i=a+20|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[a+36>>2]=$(1.0);j=f[c+8>>2]|0;a:do if(j|0){k=a+4|0;l=a+12|0;m=a+8|0;o=j;p=j;while(1){q=o+8|0;r=b[q+11>>0]|0;s=r<<24>>24<0;t=s?f[q>>2]|0:q;v=s?f[o+12>>2]|0:r&255;if(v>>>0>3){r=t;s=v;w=v;while(1){x=X(h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24,1540483477)|0;s=(X(x>>>24^x,1540483477)|0)^(X(s,1540483477)|0);w=w+-4|0;if(w>>>0<=3)break;else r=r+4|0}r=v+-4|0;w=r&-4;y=r-w|0;z=t+(w+4)|0;A=s}else{y=v;z=t;A=v}switch(y|0){case 3:{B=h[z+2>>0]<<16^A;C=8;break}case 2:{B=A;C=8;break}case 1:{D=A;C=9;break}default:E=A}if((C|0)==8){C=0;D=h[z+1>>0]<<8^B;C=9}if((C|0)==9){C=0;E=X(D^h[z>>0],1540483477)|0}w=X(E>>>13^E,1540483477)|0;r=w>>>15^w;w=f[k>>2]|0;x=(w|0)==0;b:do if(!x){F=w+-1|0;G=(F&w|0)==0;if(!G)if(r>>>0>>0)H=r;else H=(r>>>0)%(w>>>0)|0;else H=r&F;I=f[(f[a>>2]|0)+(H<<2)>>2]|0;if((I|0)!=0?(J=f[I>>2]|0,(J|0)!=0):0){I=(v|0)==0;if(G){if(I){G=J;while(1){K=f[G+4>>2]|0;if(!((K|0)==(r|0)|(K&F|0)==(H|0))){L=H;C=50;break b}K=b[G+8+11>>0]|0;if(!((K<<24>>24<0?f[G+12>>2]|0:K&255)|0))break b;G=f[G>>2]|0;if(!G){L=H;C=50;break b}}}else M=J;while(1){G=f[M+4>>2]|0;if(!((G|0)==(r|0)|(G&F|0)==(H|0))){L=H;C=50;break b}G=M+8|0;K=b[G+11>>0]|0;N=K<<24>>24<0;O=K&255;do if(((N?f[M+12>>2]|0:O)|0)==(v|0)){K=f[G>>2]|0;if(N)if(!(Vk(K,t,v)|0))break b;else break;if((b[t>>0]|0)==(K&255)<<24>>24){K=G;P=O;Q=t;do{P=P+-1|0;K=K+1|0;if(!P)break b;Q=Q+1|0}while((b[K>>0]|0)==(b[Q>>0]|0))}}while(0);M=f[M>>2]|0;if(!M){L=H;C=50;break b}}}if(I){F=J;while(1){O=f[F+4>>2]|0;if((O|0)!=(r|0)){if(O>>>0>>0)R=O;else R=(O>>>0)%(w>>>0)|0;if((R|0)!=(H|0)){L=H;C=50;break b}}O=b[F+8+11>>0]|0;if(!((O<<24>>24<0?f[F+12>>2]|0:O&255)|0))break b;F=f[F>>2]|0;if(!F){L=H;C=50;break b}}}else S=J;while(1){F=f[S+4>>2]|0;if((F|0)!=(r|0)){if(F>>>0>>0)T=F;else T=(F>>>0)%(w>>>0)|0;if((T|0)!=(H|0)){L=H;C=50;break b}}F=S+8|0;I=b[F+11>>0]|0;O=I<<24>>24<0;G=I&255;do if(((O?f[S+12>>2]|0:G)|0)==(v|0)){I=f[F>>2]|0;if(O)if(!(Vk(I,t,v)|0))break b;else break;if((b[t>>0]|0)==(I&255)<<24>>24){I=F;N=G;Q=t;do{N=N+-1|0;I=I+1|0;if(!N)break b;Q=Q+1|0}while((b[I>>0]|0)==(b[Q>>0]|0))}}while(0);S=f[S>>2]|0;if(!S){L=H;C=50;break}}}else{L=H;C=50}}else{L=0;C=50}while(0);if((C|0)==50){C=0;Di(e,a,r,q);U=$(((f[l>>2]|0)+1|0)>>>0);V=$(w>>>0);Y=$(n[g>>2]);do if(x|$(Y*V)>>0<3|(w+-1&w|0)!=0)&1;v=~~$(W($(U/Y)))>>>0;ei(a,t>>>0>>0?v:t);t=f[k>>2]|0;v=t+-1|0;if(!(v&t)){Z=t;_=v&r;break}if(r>>>0>>0){Z=t;_=r}else{Z=t;_=(r>>>0)%(t>>>0)|0}}else{Z=w;_=L}while(0);w=f[(f[a>>2]|0)+(_<<2)>>2]|0;if(!w){f[f[e>>2]>>2]=f[m>>2];f[m>>2]=f[e>>2];f[(f[a>>2]|0)+(_<<2)>>2]=m;r=f[e>>2]|0;x=f[r>>2]|0;if(x|0){q=f[x+4>>2]|0;x=Z+-1|0;if(x&Z)if(q>>>0>>0)aa=q;else aa=(q>>>0)%(Z>>>0)|0;else aa=q&x;f[(f[a>>2]|0)+(aa<<2)>>2]=r}}else{f[f[e>>2]>>2]=f[w>>2];f[w>>2]=f[e>>2]}f[l>>2]=(f[l>>2]|0)+1}w=f[p>>2]|0;if(!w)break a;else{o=w;p=w}}}while(0);e=f[c+28>>2]|0;if(!e){u=d;return}else ba=e;do{e=ba;c=ln(40)|0;Ub(c,f[e+20>>2]|0);aa=Ec(i,e+8|0)|0;e=f[aa>>2]|0;f[aa>>2]=c;if(e|0){c=f[e+28>>2]|0;if(c|0){aa=c;do{c=aa;aa=f[aa>>2]|0;ri(c+8|0);Oq(c)}while((aa|0)!=0)}aa=e+20|0;c=f[aa>>2]|0;f[aa>>2]=0;if(c|0)Oq(c);c=f[e+8>>2]|0;if(c|0){aa=c;do{c=aa;aa=f[aa>>2]|0;a=c+8|0;Z=f[c+20>>2]|0;if(Z|0){_=c+24|0;if((f[_>>2]|0)!=(Z|0))f[_>>2]=Z;Oq(Z)}if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);Oq(c)}while((aa|0)!=0)}aa=f[e>>2]|0;f[e>>2]=0;if(aa|0)Oq(aa);Oq(e)}ba=f[ba>>2]|0}while((ba|0)!=0);u=d;return}function Vb(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y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2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((d[Q>>1]|0)==G<<16>>16?(d[Q+2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(J>>>0>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((d[N>>1]|0)==G<<16>>16?(d[N+2>>1]|0)==H<<16>>16:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((d[L>>1]|0)==G<<16>>16?(d[L+2>>1]|0)==H<<16>>16:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;d[G>>1]=r;d[G+2>>1]=r>>>16;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(D>>>0);ga=$(n[l>>2]);do if(F|$(ga*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]|0;D=p;G=un(f[D>>2]|0,f[D+4>>2]|0,x+y|0,0)|0;D=Vn(G|0,I|0,E|0,F|0)|0;F=(f[f[c>>2]>>2]|0)+D|0;D=F;E=h[D>>0]|h[D+1>>0]<<8|h[D+2>>0]<<16|h[D+3>>0]<<24;D=F+4|0;F=h[D>>0]|h[D+1>>0]<<8|h[D+2>>0]<<16|h[D+3>>0]<<24;D=i;f[D>>2]=E;f[D+4>>2]=F;D=(E^318)+239^F;G=(q|0)==0;a:do if(!G){H=q+-1|0;J=(H&q|0)==0;if(!J)if(D>>>0>>0)K=D;else K=(D>>>0)%(q>>>0)|0;else K=D&H;L=f[(f[g>>2]|0)+(K<<2)>>2]|0;do if(L|0?(M=f[L>>2]|0,M|0):0){b:do if(J){N=M;while(1){O=f[N+4>>2]|0;P=(O|0)==(D|0);if(!(P|(O&H|0)==(K|0))){Q=27;break b}if((P?(f[N+8>>2]|0)==(E|0):0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}N=f[N>>2]|0;if(!N){Q=27;break}}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(D|0)){if((f[N+8>>2]|0)==(E|0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}}else{if(P>>>0>>0)S=P;else S=(P>>>0)%(q>>>0)|0;if((S|0)!=(K|0)){Q=27;break b}}N=f[N>>2]|0;if(!N){Q=27;break}}}while(0);if((Q|0)==26){Q=0;f[A+(y<<2)>>2]=f[R+16>>2];T=d;U=z;V=C;X=B;Y=A;break a}else if((Q|0)==27){Q=0;if(G){Z=0;Q=46;break a}else break}}while(0);H=q+-1|0;J=(H&q|0)==0;if(!J)if(D>>>0>>0)_=D;else _=(D>>>0)%(q>>>0)|0;else _=H&D;L=f[(f[g>>2]|0)+(_<<2)>>2]|0;if((L|0)!=0?(M=f[L>>2]|0,(M|0)!=0):0){if(J){J=M;while(1){L=f[J+4>>2]|0;if(!((L|0)==(D|0)|(L&H|0)==(_|0))){Z=_;Q=46;break a}if((f[J+8>>2]|0)==(E|0)?(f[J+12>>2]|0)==(F|0):0){Q=61;break a}J=f[J>>2]|0;if(!J){Z=_;Q=46;break a}}}else aa=M;while(1){J=f[aa+4>>2]|0;if((J|0)!=(D|0)){if(J>>>0>>0)ba=J;else ba=(J>>>0)%(q>>>0)|0;if((ba|0)!=(_|0)){Z=_;Q=46;break a}}if((f[aa+8>>2]|0)==(E|0)?(f[aa+12>>2]|0)==(F|0):0){Q=61;break a}aa=f[aa>>2]|0;if(!aa){Z=_;Q=46;break}}}else{Z=_;Q=46}}else{Z=0;Q=46}while(0);if((Q|0)==46){Q=0;M=ln(20)|0;J=M+8|0;f[J>>2]=E;f[J+4>>2]=F;f[M+16>>2]=z;f[M+4>>2]=D;f[M>>2]=0;ca=$(((f[s>>2]|0)+1|0)>>>0);da=$(q>>>0);ea=$(n[k>>2]);do if(G|$(ea*da)>>0<3|(q+-1&q|0)!=0)&1;H=~~$(W($(ca/ea)))>>>0;Yh(g,J>>>0>>0?H:J);J=f[m>>2]|0;H=J+-1|0;if(!(H&J)){fa=J;ga=H&D;break}if(D>>>0>>0){fa=J;ga=D}else{fa=J;ga=(D>>>0)%(J>>>0)|0}}else{fa=q;ga=Z}while(0);D=(f[g>>2]|0)+(ga<<2)|0;G=f[D>>2]|0;if(!G){f[M>>2]=f[t>>2];f[t>>2]=M;f[D>>2]=t;D=f[M>>2]|0;if(D|0){F=f[D+4>>2]|0;D=fa+-1|0;if(D&fa)if(F>>>0>>0)ha=F;else ha=(F>>>0)%(fa>>>0)|0;else ha=F&D;ia=(f[g>>2]|0)+(ha<<2)|0;Q=59}}else{f[M>>2]=f[G>>2];ia=G;Q=59}if((Q|0)==59){Q=0;f[ia>>2]=M}f[s>>2]=(f[s>>2]|0)+1;Q=61}if((Q|0)==61){Q=0;G=v;D=f[G>>2]|0;F=un(D|0,f[G+4>>2]|0,z|0,0)|0;kh((f[f[w>>2]>>2]|0)+F|0,i|0,D|0)|0;D=f[j>>2]|0;f[D+(y<<2)>>2]=z;T=D;U=z+1|0;V=D;X=D;Y=D}D=y+1|0;ja=f[l>>2]|0;if(D>>>0>=ja>>>0)break;d=T;y=D;z=U;A=Y;B=X;C=V;q=f[m>>2]|0}if((U|0)==(ja|0))ka=X;else{X=a+84|0;if(!(b[X>>0]|0)){m=f[a+72>>2]|0;q=f[a+68>>2]|0;C=q;if((m|0)==(q|0))la=T;else{B=m-q>>2;q=0;do{m=C+(q<<2)|0;f[m>>2]=f[V+(f[m>>2]<<2)>>2];q=q+1|0}while(q>>>0>>0);la=T}}else{b[X>>0]=0;X=a+68|0;T=a+72|0;B=f[T>>2]|0;q=f[X>>2]|0;V=B-q>>2;C=q;q=B;if(ja>>>0<=V>>>0)if(ja>>>0>>0?(B=C+(ja<<2)|0,(B|0)!=(q|0)):0){f[T>>2]=q+(~((q+-4-B|0)>>>2)<<2);ma=ja}else ma=ja;else{Ch(X,ja-V|0,1220);ma=f[l>>2]|0}V=f[j>>2]|0;if(!ma)la=V;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[V+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);la=V}}f[l>>2]=U;ka=la}if(!ka)na=U;else{la=f[o>>2]|0;if((la|0)!=(ka|0))f[o>>2]=la+(~((la+-4-ka|0)>>>2)<<2);Oq(ka);na=U}}else na=0;U=f[g+8>>2]|0;if(U|0){ka=U;do{U=ka;ka=f[ka>>2]|0;Oq(U)}while((ka|0)!=0)}ka=f[g>>2]|0;f[g>>2]=0;if(!ka){u=e;return na|0}Oq(ka);u=e;return na|0}function Xb(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=Oa,fa=Oa,ga=Oa,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0;g=u;u=u+48|0;i=g+12|0;j=g+32|0;k=g;l=i+16|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[l>>2]=$(1.0);m=a+80|0;o=f[m>>2]|0;f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;if(o){if(o>>>0>1073741823)aq(k);q=o<<2;r=ln(q)|0;f[k>>2]=r;s=r+(o<<2)|0;f[k+8>>2]=s;sj(r|0,0,q|0)|0;f[p>>2]=s;s=c+48|0;q=c+40|0;o=i+4|0;t=i+12|0;v=i+8|0;w=a+40|0;x=a+64|0;y=f[e>>2]|0;e=r;z=0;A=0;B=r;C=r;D=0;E=r;while(1){r=s;F=f[r>>2]|0;G=f[r+4>>2]|0;r=q;H=un(f[r>>2]|0,f[r+4>>2]|0,y+z|0,0)|0;r=Vn(H|0,I|0,F|0,G|0)|0;G=(f[f[c>>2]>>2]|0)+r|0;r=h[G>>0]|h[G+1>>0]<<8;d[j>>1]=r;G=r&255;F=(r&65535)>>>8;H=F&255;J=((r&255^318)+239<<16>>16^F)&65535;F=(D|0)==0;a:do if(!F){K=D+-1|0;L=(K&D|0)==0;if(!L)if(D>>>0>J>>>0)M=J;else M=(J>>>0)%(D>>>0)|0;else M=K&J;N=f[(f[i>>2]|0)+(M<<2)>>2]|0;do if(N|0?(O=f[N>>2]|0,O|0):0){b:do if(L){P=O;while(1){Q=f[P+4>>2]|0;R=(Q|0)==(J|0);if(!(R|(Q&K|0)==(M|0))){S=27;break b}if((R?(R=P+8|0,(b[R>>0]|0)==G<<24>>24):0)?(b[R+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((b[Q>>0]|0)==G<<24>>24?(b[Q+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(D>>>0>J>>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((b[N>>0]|0)==G<<24>>24?(b[N+1>>0]|0)==H<<24>>24:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((b[L>>0]|0)==G<<24>>24?(b[L+1>>0]|0)==H<<24>>24:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;b[G>>0]=r;b[G+1>>0]=r>>8;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(D>>>0);ga=$(n[l>>2]);do if(F|$(ga*fa)>>0<3|(D+-1&D|0)!=0)&1;O=~~$(W($(ea/ga)))>>>0;$h(i,G>>>0>>0?O:G);G=f[o>>2]|0;O=G+-1|0;if(!(O&G)){ha=G;ia=O&J;break}if(G>>>0>J>>>0){ha=G;ia=J}else{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f[m>>2]=X;ma=na}if(!ma)pa=X;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=X}}else pa=0;X=f[i+8>>2]|0;if(X|0){ma=X;do{X=ma;ma=f[ma>>2]|0;Oq(X)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function Yb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+200|0;v=a+320|0;w=a+152|0;x=a+84|0;y=a+324|0;z=a+292|0;A=a+304|0;B=a+316|0;C=a+328|0;D=a+336|0;E=a+332|0;F=a+168|0;G=a+140|0;H=a+120|0;I=o;do{o=f[I+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(J=(o>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((V>>>0)%3|0|0)==0?_+-2|0:V,(aa|0)!=-1):0)ba=f[(f[(f[p>>2]|0)+12>>2]|0)+(aa<<2)>>2]|0;else ba=-1;f[b>>2]=ba}else{T=M;U=38}while(0);if((U|0)==38){U=0;M=T+1|0;if((T|0)==-1){U=43;break}R=((M>>>0)%3|0|0)==0?T+-2|0:M;if((R|0)==-1)ca=-1;else ca=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;f[e>>2]=ca;R=(((T>>>0)%3|0|0)==0?2:-1)+T|0;if((R|0)==-1)da=-1;else da=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;R=(ca|0)==-1;S=R?-1:(ca>>>0)/3|0;ea=(da|0)==-1;fa=ea?-1:(da>>>0)/3|0;Q=((M>>>0)%3|0|0)==0?T+-2|0:M;if(((Q|0)!=-1?(M=f[(f[p>>2]|0)+12>>2]|0,aa=f[M+(Q<<2)>>2]|0,(aa|0)!=-1):0)?(Q=(aa>>>0)/3|0,aa=f[n>>2]|0,(f[aa+(Q>>>5<<2)>>2]&1<<(Q&31)|0)==0):0){Q=(((T>>>0)%3|0|0)==0?2:-1)+T|0;do if((Q|0)!=-1){V=f[M+(Q<<2)>>2]|0;if((V|0)==-1)break;_=(V>>>0)/3|0;if(!(f[aa+(_>>>5<<2)>>2]&1<<(_&31))){U=62;break b}}while(0);if(!ea)xf(a,f[i>>2]|0,N,0,fa);nd(t,3);ga=f[e>>2]|0}else{if(!R){xf(a,f[i>>2]|0,N,1,S);aa=f[b>>2]|0;if((aa|0)==-1){U=52;break}else ha=aa}else ha=T;aa=(((ha>>>0)%3|0|0)==0?2:-1)+ha|0;if((aa|0)==-1){U=52;break}Q=f[(f[(f[p>>2]|0)+12>>2]|0)+(aa<<2)>>2]|0;if((Q|0)==-1){U=52;break}aa=(Q>>>0)/3|0;if(f[(f[n>>2]|0)+(aa>>>5<<2)>>2]&1<<(aa&31)|0){U=52;break}nd(t,5);ga=da}f[b>>2]=ga}if((K|0)>=(k|0))break a;J=K;L=f[n>>2]|0}do if((U|0)==43){U=0;f[e>>2]=-1;U=54}else if((U|0)==52){U=0;if(ea)U=54;else{xf(a,f[i>>2]|0,N,0,fa);U=54}}else if((U|0)==62){U=0;nd(t,1);f[F>>2]=(f[F>>2]|0)+1;if(P?(L=f[(f[w>>2]|0)+(O<<2)>>2]|0,(1<<(L&31)&f[(f[G>>2]|0)+(L>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}L=f[i>>2]|0;f[d>>2]=N;J=je(H,d)|0;f[J>>2]=L;L=f[j>>2]|0;f[L+-4>>2]=da;if((L|0)==(f[m>>2]|0)){Ri(h,e);break}else{f[L>>2]=f[e>>2];f[j>>2]=L+4;break}}while(0);if((U|0)==54){U=0;nd(t,7);f[j>>2]=(f[j>>2]|0)+-4}}}else U=11;while(0);if((U|0)==11){U=0;f[j>>2]=I+-4}I=f[j>>2]|0}while((f[h>>2]|0)!=(I|0));u=c;return 1}function Zb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;do if((g|0)!=-1){l=f[m+28>>2]|0;o=f[l+((((j>>>0)%3|0|0)==0?g+-2|0:j)<<2)>>2]|0;if(!((g>>>0)%3|0)){p=o;q=g+2|0;r=l;break}else{p=o;q=g+-1|0;r=l;break}}else{l=f[m+28>>2]|0;p=f[l+-4>>2]|0;q=-1;r=l}while(0);m=f[r+(q<<2)>>2]|0;q=a+24|0;r=f[q>>2]|0;g=r+(p>>>5<<2)|0;j=1<<(p&31);l=f[g>>2]|0;if(!(l&j)){f[g>>2]=l|j;j=f[b>>2]|0;l=j+1|0;if((j|0)==-1)s=-1;else s=((l>>>0)%3|0|0)==0?j+-2|0:l;f[e>>2]=s;l=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((s>>>0)/3|0)*12|0)+(((s>>>0)%3|0)<<2)>>2]|0;s=f[a+48>>2]|0;f[d>>2]=l;j=f[s+4>>2]|0;s=j+4|0;g=f[s>>2]|0;if((g|0)==(f[j+8>>2]|0))Ri(j,d);else{f[g>>2]=l;f[s>>2]=g+4}g=a+40|0;s=f[g>>2]|0;l=s+4|0;j=f[l>>2]|0;if((j|0)==(f[s+8>>2]|0)){Ri(s,e);t=f[g>>2]|0}else{f[j>>2]=f[e>>2];f[l>>2]=j+4;t=s}s=t+24|0;f[(f[t+12>>2]|0)+(p<<2)>>2]=f[s>>2];f[s>>2]=(f[s>>2]|0)+1;v=f[q>>2]|0}else v=r;r=v+(m>>>5<<2)|0;v=1<<(m&31);s=f[r>>2]|0;if(!(s&v)){f[r>>2]=s|v;v=f[b>>2]|0;do if((v|0)!=-1)if(!((v>>>0)%3|0)){w=v+2|0;break}else{w=v+-1|0;break}else w=-1;while(0);f[e>>2]=w;v=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((w>>>0)/3|0)*12|0)+(((w>>>0)%3|0)<<2)>>2]|0;w=f[a+48>>2]|0;f[d>>2]=v;s=f[w+4>>2]|0;w=s+4|0;r=f[w>>2]|0;if((r|0)==(f[s+8>>2]|0))Ri(s,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)+(l<<2)>>2]=f[B>>2];f[B>>2]=(f[B>>2]|0)+1;B=f[a>>2]|0;l=f[b>>2]|0;if(A){D=l;E=B;F=57}else{y=l+1|0;do if((l|0)==-1)G=-1;else{o=((y>>>0)%3|0|0)==0?l+-2|0:y;if((o|0)==-1){G=-1;break}if(f[(f[B>>2]|0)+(o>>>5<<2)>>2]&1<<(o&31)|0){G=-1;break}G=f[(f[(f[B+64>>2]|0)+12>>2]|0)+(o<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0;I=B}}else{D=j;E=w;F=57}if((F|0)==57){F=0;y=D+1|0;if((D|0)==-1){F=58;break}l=((y>>>0)%3|0|0)==0?D+-2|0:y;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)J=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else J=-1;f[d>>2]=J;l=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)K=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else K=-1;l=(J|0)==-1;y=(J>>>0)/3|0;o=l?-1:y;g=(K|0)==-1;z=(K>>>0)/3|0;L=g?-1:z;do if(!l){M=f[i>>2]|0;if(f[M+(o>>>5<<2)>>2]&1<<(o&31)|0){F=67;break}if(g){N=J;O=y;break}if(!(f[M+(L>>>5<<2)>>2]&1<<(L&31))){F=72;break a}else{N=J;O=y}}else F=67;while(0);if((F|0)==67){F=0;if(g){F=69;break}if(!(f[(f[i>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31))){N=K;O=z}else{F=69;break}}f[b>>2]=N;H=O;I=E}t=H;p=f[i>>2]|0;w=I}do if((F|0)==58){F=0;f[d>>2]=-1;F=69}else if((F|0)==72){F=0;w=f[k>>2]|0;f[w+-4>>2]=K;if((w|0)==(f[n>>2]|0)){Ri(h,d);P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8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);m=m+-4|0;if(m>>>0<=3)break;else q=q+4|0}q=o+-4|0;m=q&-4;s=q-m|0;t=c+(m+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(m=f[r>>2]|0,(m|0)!=0):0){r=(o|0)==0;if(s){if(r){s=m;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=m;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=m;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=m;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=$(y>>>0);L=$(n[a+16>>2]);do if(w|$(L*K)>>0<3|(y+-1&y|0)!=0)&1;H=~~$(W($(J/L)))>>>0;ei(a,A>>>0>>0?H:A);A=f[t>>2]|0;H=A+-1|0;if(!(H&A)){M=A;N=H&z;break}if(z>>>0>>0){M=A;N=z}else{M=A;N=(z>>>0)%(A>>>0)|0}}else{M=y;N=B}while(0);B=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!B){y=a+8|0;f[f[g>>2]>>2]=f[y>>2];f[y>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>2]=y;y=f[g>>2]|0;N=f[y>>2]|0;if(!N)O=g;else{z=f[N+4>>2]|0;N=M+-1|0;if(N&M)if(z>>>0>>0)P=z;else P=(z>>>0)%(M>>>0)|0;else P=z&N;f[(f[a>>2]|0)+(P<<2)>>2]=y;O=g}}else{f[f[g>>2]>>2]=f[B>>2];f[B>>2]=f[g>>2];O=g}f[x>>2]=(f[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C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=Oa,M=Oa,N=Oa,O=0,P=0,Q=0,R=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=Id(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];lf(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;l=d+11|0;m=b[l>>0]|0;o=d+4|0;p=f[o>>2]|0;q=m<<24>>24<0?p:m&255;if(!q){r=m;s=p;t=0}else{Fi(j,q);r=b[l>>0]|0;s=f[o>>2]|0;t=f[j>>2]|0}o=r<<24>>24<0;kh(t|0,(o?f[d>>2]|0:d)|0,(o?s:r&255)|0)|0;pj(i,c);c=i+12|0;f[c>>2]=0;r=i+16|0;f[r>>2]=0;f[i+20>>2]=0;s=f[k>>2]|0;o=f[j>>2]|0;d=s-o|0;if(!d){v=o;w=s;x=0}else{Fi(c,d);v=f[j>>2]|0;w=f[k>>2]|0;x=f[c>>2]|0}kh(x|0,v|0,w-v|0)|0;v=i+11|0;w=b[v>>0]|0;x=w<<24>>24<0;c=x?f[i>>2]|0:i;d=x?f[i+4>>2]|0:w&255;if(d>>>0>3){w=c;x=d;s=d;while(1){o=X(h[w>>0]|h[w+1>>0]<<8|h[w+2>>0]<<16|h[w+3>>0]<<24,1540483477)|0;x=(X(o>>>24^o,1540483477)|0)^(X(x,1540483477)|0);s=s+-4|0;if(s>>>0<=3)break;else w=w+4|0}w=d+-4|0;s=w&-4;y=w-s|0;z=c+(s+4)|0;A=x}else{y=d;z=c;A=d}switch(y|0){case 3:{B=h[z+2>>0]<<16^A;C=12;break}case 2:{B=A;C=12;break}case 1:{D=A;C=13;break}default:E=A}if((C|0)==12){D=h[z+1>>0]<<8^B;C=13}if((C|0)==13)E=X(D^h[z>>0],1540483477)|0;z=X(E>>>13^E,1540483477)|0;E=z>>>15^z;z=a+4|0;D=f[z>>2]|0;B=(D|0)==0;a:do if(!B){A=D+-1|0;y=(A&D|0)==0;if(!y)if(E>>>0>>0)F=E;else F=(E>>>0)%(D>>>0)|0;else F=E&A;x=f[(f[a>>2]|0)+(F<<2)>>2]|0;if((x|0)!=0?(s=f[x>>2]|0,(s|0)!=0):0){x=(d|0)==0;if(y){if(x){y=s;while(1){w=f[y+4>>2]|0;if(!((w|0)==(E|0)|(w&A|0)==(F|0))){G=F;C=54;break a}w=b[y+8+11>>0]|0;if(!((w<<24>>24<0?f[y+12>>2]|0:w&255)|0))break a;y=f[y>>2]|0;if(!y){G=F;C=54;break a}}}else H=s;while(1){y=f[H+4>>2]|0;if(!((y|0)==(E|0)|(y&A|0)==(F|0))){G=F;C=54;break a}y=H+8|0;w=b[y+11>>0]|0;o=w<<24>>24<0;t=w&255;do if(((o?f[H+12>>2]|0:t)|0)==(d|0)){w=f[y>>2]|0;if(o)if(!(Vk(w,c,d)|0))break a;else break;if((b[c>>0]|0)==(w&255)<<24>>24){w=y;l=t;q=c;do{l=l+-1|0;w=w+1|0;if(!l)break a;q=q+1|0}while((b[w>>0]|0)==(b[q>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){G=F;C=54;break a}}}if(x){A=s;while(1){t=f[A+4>>2]|0;if((t|0)!=(E|0)){if(t>>>0>>0)I=t;else I=(t>>>0)%(D>>>0)|0;if((I|0)!=(F|0)){G=F;C=54;break a}}t=b[A+8+11>>0]|0;if(!((t<<24>>24<0?f[A+12>>2]|0:t&255)|0))break a;A=f[A>>2]|0;if(!A){G=F;C=54;break a}}}else J=s;while(1){A=f[J+4>>2]|0;if((A|0)!=(E|0)){if(A>>>0>>0)K=A;else K=(A>>>0)%(D>>>0)|0;if((K|0)!=(F|0)){G=F;C=54;break a}}A=J+8|0;x=b[A+11>>0]|0;t=x<<24>>24<0;y=x&255;do if(((t?f[J+12>>2]|0:y)|0)==(d|0)){x=f[A>>2]|0;if(t)if(!(Vk(x,c,d)|0))break a;else break;if((b[c>>0]|0)==(x&255)<<24>>24){x=A;o=y;q=c;do{o=o+-1|0;x=x+1|0;if(!o)break a;q=q+1|0}while((b[x>>0]|0)==(b[q>>0]|0))}}while(0);J=f[J>>2]|0;if(!J){G=F;C=54;break}}}else{G=F;C=54}}else{G=0;C=54}while(0);if((C|0)==54){oi(g,a,E,i);C=a+12|0;L=$(((f[C>>2]|0)+1|0)>>>0);M=$(D>>>0);N=$(n[a+16>>2]);do if(B|$(N*M)>>0<3|(D+-1&D|0)!=0)&1;J=~~$(W($(L/N)))>>>0;ei(a,F>>>0>>0?J:F);F=f[z>>2]|0;J=F+-1|0;if(!(J&F)){O=F;P=J&E;break}if(E>>>0>>0){O=F;P=E}else{O=F;P=(E>>>0)%(F>>>0)|0}}else{O=D;P=G}while(0);G=f[(f[a>>2]|0)+(P<<2)>>2]|0;if(!G){D=a+8|0;f[f[g>>2]>>2]=f[D>>2];f[D>>2]=f[g>>2];f[(f[a>>2]|0)+(P<<2)>>2]=D;D=f[g>>2]|0;P=f[D>>2]|0;if(!P)Q=g;else{E=f[P+4>>2]|0;P=O+-1|0;if(P&O)if(E>>>0>>0)R=E;else R=(E>>>0)%(O>>>0)|0;else R=E&P;f[(f[a>>2]|0)+(R<<2)>>2]=D;Q=g}}else{f[f[g>>2]>>2]=f[G>>2];f[G>>2]=f[g>>2];Q=g}f[C>>2]=(f[C>>2]|0)+1;f[Q>>2]=0}Q=f[i+12>>2]|0;if(Q|0){if((f[r>>2]|0)!=(Q|0))f[r>>2]=Q;Oq(Q)}if((b[v>>0]|0)<0)Oq(f[i>>2]|0);i=f[j>>2]|0;if(!i){u=e;return}if((f[k>>2]|0)!=(i|0))f[k>>2]=i;Oq(i);u=e;return}function bc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;d=u;u=u+192|0;e=d+152|0;g=d+144|0;h=d+72|0;i=d;j=d+112|0;k=d+108|0;l=d+104|0;m=a+352|0;if(b[m>>0]|0?(n=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0,((f[n+12>>2]|0)-(f[n+8>>2]|0)|0)>0):0){n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+8|0;o=f[f[n>>2]>>2]|0;f[e>>2]=c;n=o+4|0;p=o+8|0;q=f[p>>2]|0;if((q|0)==(f[o+12>>2]|0))Ri(n,e);else{f[q>>2]=c;f[p>>2]=q+4}q=f[e>>2]|0;r=o+16|0;s=o+20|0;o=f[s>>2]|0;t=f[r>>2]|0;v=o-t>>2;w=t;if((q|0)<(v|0)){x=w;y=q}else{t=q+1|0;f[g>>2]=-1;z=o;if(t>>>0<=v>>>0)if(t>>>0>>0?(o=w+(t<<2)|0,(o|0)!=(z|0)):0){f[s>>2]=z+(~((z+-4-o|0)>>>2)<<2);A=q;B=w}else{A=q;B=w}else{Ch(r,t-v|0,g);A=f[e>>2]|0;B=f[r>>2]|0}x=B;y=A}f[x+(y<<2)>>2]=((f[p>>2]|0)-(f[n>>2]|0)>>2)+-1;C=1;u=d;return C|0}n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;p=f[(f[(f[n>>2]|0)+84>>2]|0)+(c<<2)>>2]|0;n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+4|0;y=f[(f[(f[n>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;f[g>>2]=-1;n=a+172|0;x=f[a+176>>2]|0;A=f[n>>2]|0;B=A;a:do if((x|0)==(A|0))D=-1;else{r=(x-A|0)/136|0;v=0;while(1){if((f[B+(v*136|0)>>2]|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0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J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16>>2]|0)>>>0){f[l>>2]=0;f[K>>2]=c;f[a>>2]=K+4;S=l}else{Qg(k+8|0,l);S=l}l=f[S>>2]|0;f[S>>2]=0;if(!l)Q=1;else{Va[f[(f[l>>2]|0)+4>>2]&127](l);Q=1}}C=Q;u=d;return C|0}function cc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l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|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0]|0:0)break;x=ln(88)|0;r=f[a+8>>2]|0;t=B+(D*136|0)+104|0;f[x+4>>2]=0;f[x>>2]=3564;w=x+12|0;f[w>>2]=3588;q=x+64|0;f[q>>2]=0;f[x+68>>2]=0;f[x+72>>2]=0;o=x+16|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[x+76>>2]=r;f[x+80>>2]=t;s=x+84|0;f[s>>2]=0;f[h>>2]=3588;E=h+4|0;F=E+4|0;f[F>>2]=0;f[F+4>>2]=0;f[F+8>>2]=0;f[F+12>>2]=0;f[F+16>>2]=0;f[F+20>>2]=0;F=B+(D*136|0)+4|0;G=i+4|0;f[G>>2]=3588;H=i+56|0;f[H>>2]=0;I=i+60|0;f[I>>2]=0;f[i+64>>2]=0;o=i+8|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[E>>2]=F;o=f[B+(D*136|0)+68>>2]|0;z=((f[o+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;qh(h+8|0,z,e);Va[f[(f[h>>2]|0)+8>>2]&127](h);Df(j,h);Df(e,j);f[i>>2]=f[e+4>>2];z=i+4|0;fg(z,e)|0;f[e>>2]=3588;o=f[e+20>>2]|0;if(o|0)Oq(o);o=f[e+8>>2]|0;if(o|0)Oq(o);f[i+36>>2]=F;f[i+40>>2]=t;f[i+44>>2]=r;f[i+48>>2]=x;f[j>>2]=3588;o=f[j+20>>2]|0;if(o|0)Oq(o);o=f[j+8>>2]|0;if(o|0)Oq(o);f[s>>2]=a+72;f[x+8>>2]=f[i>>2];fg(w,z)|0;z=x+44|0;o=i+36|0;f[z>>2]=f[o>>2];f[z+4>>2]=f[o+4>>2];f[z+8>>2]=f[o+8>>2];f[z+12>>2]=f[o+12>>2];b[z+16>>0]=b[o+16>>0]|0;ng(q,f[H>>2]|0,f[I>>2]|0);o=x;z=f[H>>2]|0;if(z|0){J=f[I>>2]|0;if((J|0)!=(z|0))f[I>>2]=J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16>>2]|0)>>>0){f[l>>2]=0;f[K>>2]=c;f[a>>2]=K+4;S=l}else{Qg(k+8|0,l);S=l}l=f[S>>2]|0;f[S>>2]=0;if(!l)Q=1;else{Va[f[(f[l>>2]|0)+4>>2]&127](l);Q=1}}C=Q;u=d;return C|0}function dc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;if((g|0)!=-1){l=((j>>>0)%3|0|0)==0?g+-2|0:j;if((l|0)==-1)o=-1;else o=f[(f[m>>2]|0)+(l<<2)>>2]|0;l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1){p=o;q=-1}else{p=o;q=f[(f[m>>2]|0)+(l<<2)>>2]|0}}else{p=-1;q=-1}l=a+24|0;m=f[l>>2]|0;o=m+(p>>>5<<2)|0;g=1<<(p&31);j=f[o>>2]|0;if(!(j&g)){f[o>>2]=j|g;g=f[b>>2]|0;j=g+1|0;if((g|0)==-1)r=-1;else r=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=r;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=j;g=f[r+4>>2]|0;r=g+4|0;o=f[r>>2]|0;if((o|0)==(f[g+8>>2]|0))Ri(g,d);else{f[o>>2]=j;f[r>>2]=o+4}o=a+40|0;r=f[o>>2]|0;j=r+4|0;g=f[j>>2]|0;if((g|0)==(f[r+8>>2]|0)){Ri(r,e);s=f[o>>2]|0}else{f[g>>2]=f[e>>2];f[j>>2]=g+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(p<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1;t=f[l>>2]|0}else t=m;m=t+(q>>>5<<2)|0;t=1<<(q&31);r=f[m>>2]|0;if(!(r&t)){f[m>>2]=r|t;t=f[b>>2]|0;do if((t|0)!=-1)if(!((t>>>0)%3|0)){v=t+2|0;break}else{v=t+-1|0;break}else v=-1;while(0);f[e>>2]=v;t=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((v>>>0)/3|0)*12|0)+(((v>>>0)%3|0)<<2)>>2]|0;v=f[a+48>>2]|0;f[d>>2]=t;r=f[v+4>>2]|0;v=r+4|0;m=f[v>>2]|0;if((m|0)==(f[r+8>>2]|0))Ri(r,d);else{f[m>>2]=t;f[v>>2]=m+4}m=a+40|0;v=f[m>>2]|0;t=v+4|0;r=f[t>>2]|0;if((r|0)==(f[v+8>>2]|0)){Ri(v,e);w=f[m>>2]|0}else{f[r>>2]=f[e>>2];f[t>>2]=r+4;w=v}v=w+24|0;f[(f[w+12>>2]|0)+(q<<2)>>2]=f[v>>2];f[v>>2]=(f[v>>2]|0)+1}v=f[h>>2]|0;q=f[k>>2]|0;if((v|0)==(q|0)){u=c;return}w=a+44|0;r=a+48|0;t=a+40|0;m=q;q=v;while(1){v=f[m+-4>>2]|0;f[b>>2]=v;p=(v>>>0)/3|0;if((v|0)!=-1?(v=f[i>>2]|0,(f[v+(p>>>5<<2)>>2]&1<<(p&31)|0)==0):0){s=p;p=v;a:while(1){v=p+(s>>>5<<2)|0;f[v>>2]=f[v>>2]|1<<(s&31);v=f[b>>2]|0;if((v|0)==-1)x=-1;else x=f[(f[f[a>>2]>>2]|0)+(v<<2)>>2]|0;g=(f[l>>2]|0)+(x>>>5<<2)|0;j=1<<(x&31);o=f[g>>2]|0;do if(!(j&o)){y=f[a>>2]|0;z=f[(f[y+24>>2]|0)+(x<<2)>>2]|0;A=z+1|0;if(((z|0)!=-1?(B=((A>>>0)%3|0|0)==0?z+-2|0:A,(B|0)!=-1):0)?(A=f[(f[y+12>>2]|0)+(B<<2)>>2]|0,B=A+1|0,(A|0)!=-1):0)C=((((B>>>0)%3|0|0)==0?A+-2|0:B)|0)==-1;else C=1;f[g>>2]=o|j;B=f[b>>2]|0;f[e>>2]=B;A=f[(f[(f[w>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=A;y=f[B+4>>2]|0;B=y+4|0;z=f[B>>2]|0;if((z|0)==(f[y+8>>2]|0))Ri(y,d);else{f[z>>2]=A;f[B>>2]=z+4}z=f[t>>2]|0;B=z+4|0;A=f[B>>2]|0;if((A|0)==(f[z+8>>2]|0)){Ri(z,e);D=f[t>>2]|0}else{f[A>>2]=f[e>>2];f[B>>2]=A+4;D=z}z=D+24|0;f[(f[D+12>>2]|0)+(x<<2)>>2]=f[z>>2];f[z>>2]=(f[z>>2]|0)+1;if(C){E=f[b>>2]|0;F=60;break}z=f[a>>2]|0;A=f[b>>2]|0;do if((A|0)==-1)G=-1;else{B=A+1|0;y=((B>>>0)%3|0|0)==0?A+-2|0:B;if((y|0)==-1){G=-1;break}G=f[(f[z+12>>2]|0)+(y<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0}else{E=v;F=60}while(0);if((F|0)==60){F=0;v=f[a>>2]|0;if((E|0)==-1){F=61;break}j=E+1|0;o=((j>>>0)%3|0|0)==0?E+-2|0:j;if((o|0)==-1)I=-1;else I=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;f[d>>2]=I;o=(((E>>>0)%3|0|0)==0?2:-1)+E|0;if((o|0)==-1)J=-1;else J=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;o=(I|0)==-1;v=(I>>>0)/3|0;j=o?-1:v;g=(J|0)==-1;z=(J>>>0)/3|0;A=g?-1:z;do if(!o){y=f[i>>2]|0;if(f[y+(j>>>5<<2)>>2]&1<<(j&31)|0){F=68;break}if(g){K=I;L=v;break}if(!(f[y+(A>>>5<<2)>>2]&1<<(A&31))){F=73;break a}else{K=I;L=v}}else F=68;while(0);if((F|0)==68){F=0;if(g){F=70;break}if(!(f[(f[i>>2]|0)+(A>>>5<<2)>>2]&1<<(A&31))){K=J;L=z}else{F=70;break}}f[b>>2]=K;H=L}s=H;p=f[i>>2]|0}do if((F|0)==61){F=0;f[d>>2]=-1;F=70}else if((F|0)==73){F=0;p=f[k>>2]|0;f[p+-4>>2]=J;if((p|0)==(f[n>>2]|0)){Ri(h,d);M=f[k>>2]|0;break}else{f[p>>2]=f[d>>2];s=p+4|0;f[k>>2]=s;M=s;break}}while(0);if((F|0)==70){F=0;s=(f[k>>2]|0)+-4|0;f[k>>2]=s;M=s}N=f[h>>2]|0;O=M}else{s=m+-4|0;f[k>>2]=s;N=q;O=s}if((N|0)==(O|0))break;else{m=O;q=N}}u=c;return}function ec(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=Oa,fa=Oa,ga=Oa,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0;g=u;u=u+48|0;i=g+12|0;j=g+32|0;k=g;l=i+16|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[l>>2]=$(1.0);m=a+80|0;o=f[m>>2]|0;f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;if(o){if(o>>>0>1073741823)aq(k);q=o<<2;r=ln(q)|0;f[k>>2]=r;s=r+(o<<2)|0;f[k+8>>2]=s;sj(r|0,0,q|0)|0;f[p>>2]=s;s=c+48|0;q=c+40|0;o=i+4|0;t=i+12|0;v=i+8|0;w=a+40|0;x=a+64|0;y=f[e>>2]|0;e=0;z=r;A=0;B=0;C=r;D=r;E=r;while(1){r=s;F=f[r>>2]|0;G=f[r+4>>2]|0;r=q;H=un(f[r>>2]|0,f[r+4>>2]|0,y+A|0,0)|0;r=Vn(H|0,I|0,F|0,G|0)|0;G=(f[f[c>>2]>>2]|0)+r|0;r=h[G>>0]|h[G+1>>0]<<8;d[j>>1]=r;G=(r^318)&65535;a:do if(e){F=e+-1|0;H=(F&e|0)==0;if(!H)if(e>>>0>G>>>0)J=G;else J=(G>>>0)%(e>>>0)|0;else J=F&G;K=f[i>>2]|0;L=f[K+(J<<2)>>2]|0;b:do if(L|0?(M=f[L>>2]|0,M|0):0){c:do if(H){N=M;while(1){O=f[N+4>>2]|0;P=(O|0)==(G|0);if(!(P|(O&F|0)==(J|0)))break b;if(P?(d[N+8>>1]|0)==r<<16>>16:0){Q=N;break c}N=f[N>>2]|0;if(!N)break b}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(G|0)){if((d[N+8>>1]|0)==r<<16>>16){Q=N;break c}}else{if(P>>>0>>0)R=P;else R=(P>>>0)%(e>>>0)|0;if((R|0)!=(J|0))break b}N=f[N>>2]|0;if(!N)break b}}while(0);f[E+(A<<2)>>2]=f[Q+12>>2];S=z;T=B;U=D;V=C;X=E;break a}while(0);if(!H)if(e>>>0>G>>>0)Y=G;else Y=(G>>>0)%(e>>>0)|0;else Y=F&G;L=f[K+(Y<<2)>>2]|0;if(!L){Z=Y;_=e;aa=0;ba=40}else{if(H){M=L;while(1){M=f[M>>2]|0;if(!M){Z=Y;_=e;aa=0;ba=40;break a}N=f[M+4>>2]|0;if(!((N|0)==(G|0)|(N&F|0)==(Y|0))){Z=Y;_=e;aa=0;ba=40;break a}if((d[M+8>>1]|0)==r<<16>>16){ba=55;break a}}}else ca=L;while(1){ca=f[ca>>2]|0;if(!ca){Z=Y;_=e;aa=0;ba=40;break a}M=f[ca+4>>2]|0;if((M|0)!=(G|0)){if(M>>>0>>0)da=M;else da=(M>>>0)%(e>>>0)|0;if((da|0)!=(Y|0)){Z=Y;_=e;aa=0;ba=40;break a}}if((d[ca+8>>1]|0)==r<<16>>16){ba=55;break}}}}else{Z=0;_=0;aa=1;ba=40}while(0);if((ba|0)==40){ba=0;L=ln(16)|0;d[L+8>>1]=r;f[L+12>>2]=B;f[L+4>>2]=G;f[L>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(_>>>0);ga=$(n[l>>2]);do if(aa|$(ga*fa)>>0<3|(_+-1&_|0)!=0)&1;F=~~$(W($(ea/ga)))>>>0;Vh(i,M>>>0>>0?F:M);M=f[o>>2]|0;F=M+-1|0;if(!(F&M)){ha=M;ia=F&G;break}if(M>>>0>G>>>0){ha=M;ia=G}else{ha=M;ia=(G>>>0)%(M>>>0)|0}}else{ha=_;ia=Z}while(0);G=(f[i>>2]|0)+(ia<<2)|0;r=f[G>>2]|0;if(!r){f[L>>2]=f[v>>2];f[v>>2]=L;f[G>>2]=v;G=f[L>>2]|0;if(G|0){M=f[G+4>>2]|0;G=ha+-1|0;if(G&ha)if(M>>>0>>0)ja=M;else ja=(M>>>0)%(ha>>>0)|0;else ja=M&G;ka=(f[i>>2]|0)+(ja<<2)|0;ba=53}}else{f[L>>2]=f[r>>2];ka=r;ba=53}if((ba|0)==53){ba=0;f[ka>>2]=L}f[t>>2]=(f[t>>2]|0)+1;ba=55}if((ba|0)==55){ba=0;r=w;G=f[r>>2]|0;M=un(G|0,f[r+4>>2]|0,B|0,0)|0;kh((f[f[x>>2]>>2]|0)+M|0,j|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=B;S=G;T=B+1|0;U=G;V=G;X=G}G=A+1|0;la=f[m>>2]|0;if(G>>>0>=la>>>0)break;e=f[o>>2]|0;z=S;A=G;B=T;C=V;D=U;E=X}if((T|0)==(la|0))ma=V;else{V=a+84|0;if(!(b[V>>0]|0)){X=f[a+72>>2]|0;E=f[a+68>>2]|0;D=E;if((X|0)==(E|0))na=S;else{C=X-E>>2;E=0;do{X=D+(E<<2)|0;f[X>>2]=f[U+(f[X>>2]<<2)>>2];E=E+1|0}while(E>>>0>>0);na=S}}else{b[V>>0]=0;V=a+68|0;S=a+72|0;C=f[S>>2]|0;E=f[V>>2]|0;U=C-E>>2;D=E;E=C;if(la>>>0<=U>>>0)if(la>>>0>>0?(C=D+(la<<2)|0,(C|0)!=(E|0)):0){f[S>>2]=E+(~((E+-4-C|0)>>>2)<<2);oa=la}else oa=la;else{Ch(V,la-U|0,1220);oa=f[m>>2]|0}U=f[k>>2]|0;if(!oa)na=U;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[U+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);na=U}}f[m>>2]=T;ma=na}if(!ma)pa=T;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=T}}else pa=0;T=f[i+8>>2]|0;if(T|0){ma=T;do{T=ma;ma=f[ma>>2]|0;Oq(T)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function fc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=Oa,K=Oa,L=Oa,M=0,N=0,O=0,P=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=Id(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];lf(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;Fi(j,4);l=f[j>>2]|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;pj(i,c);c=i+12|0;f[c>>2]=0;m=i+16|0;f[m>>2]=0;f[i+20>>2]=0;l=f[k>>2]|0;d=f[j>>2]|0;o=l-d|0;if(!o){p=d;q=l;r=0}else{Fi(c,o);p=f[j>>2]|0;q=f[k>>2]|0;r=f[c>>2]|0}kh(r|0,p|0,q-p|0)|0;p=i+11|0;q=b[p>>0]|0;r=q<<24>>24<0;c=r?f[i>>2]|0:i;o=r?f[i+4>>2]|0:q&255;if(o>>>0>3){q=c;r=o;l=o;while(1){d=X(h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);l=l+-4|0;if(l>>>0<=3)break;else q=q+4|0}q=o+-4|0;l=q&-4;s=q-l|0;t=c+(l+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(l=f[r>>2]|0,(l|0)!=0):0){r=(o|0)==0;if(s){if(r){s=l;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=l;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=l;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=l;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=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2]=0;n[j>>2]=$(1.0);k=a+80|0;l=f[k>>2]|0;f[i>>2]=0;m=i+4|0;f[m>>2]=0;f[i+8>>2]=0;if(l){if(l>>>0>1073741823)aq(i);o=l<<2;p=ln(o)|0;f[i>>2]=p;q=p+(l<<2)|0;f[i+8>>2]=q;sj(p|0,0,o|0)|0;f[m>>2]=q;q=c+48|0;o=c+40|0;l=g+4|0;r=g+12|0;s=g+8|0;t=a+40|0;v=a+64|0;w=f[d>>2]|0;d=0;x=p;y=0;z=0;A=p;B=p;C=p;while(1){p=q;D=f[p>>2]|0;E=f[p+4>>2]|0;p=o;F=un(f[p>>2]|0,f[p+4>>2]|0,w+y|0,0)|0;p=Vn(F|0,I|0,D|0,E|0)|0;E=b[(f[f[c>>2]>>2]|0)+p>>0]|0;b[h>>0]=E;p=E&255^318;a:do if(d){D=d+-1|0;F=(D&d|0)==0;if(!F)if(p>>>0>>0)G=p;else G=(p>>>0)%(d>>>0)|0;else G=D&p;H=f[g>>2]|0;J=f[H+(G<<2)>>2]|0;b:do if(J|0?(K=f[J>>2]|0,K|0):0){c:do if(F){L=K;while(1){M=f[L+4>>2]|0;N=(M|0)==(p|0);if(!(N|(M&D|0)==(G|0)))break b;if(N?(b[L+8>>0]|0)==E<<24>>24:0){O=L;break c}L=f[L>>2]|0;if(!L)break b}}else{L=K;while(1){N=f[L+4>>2]|0;if((N|0)==(p|0)){if((b[L+8>>0]|0)==E<<24>>24){O=L;break c}}else{if(N>>>0>>0)P=N;else P=(N>>>0)%(d>>>0)|0;if((P|0)!=(G|0))break b}L=f[L>>2]|0;if(!L)break b}}while(0);f[C+(y<<2)>>2]=f[O+12>>2];Q=x;R=z;S=B;T=A;U=C;break a}while(0);if(!F)if(p>>>0>>0)V=p;else V=(p>>>0)%(d>>>0)|0;else V=D&p;J=f[H+(V<<2)>>2]|0;if(!J){X=V;Y=d;Z=0;_=40}else{if(F){K=J;while(1){K=f[K>>2]|0;if(!K){X=V;Y=d;Z=0;_=40;break a}L=f[K+4>>2]|0;if(!((L|0)==(p|0)|(L&D|0)==(V|0))){X=V;Y=d;Z=0;_=40;break a}if((b[K+8>>0]|0)==E<<24>>24){_=55;break a}}}else aa=J;while(1){aa=f[aa>>2]|0;if(!aa){X=V;Y=d;Z=0;_=40;break a}K=f[aa+4>>2]|0;if((K|0)!=(p|0)){if(K>>>0>>0)ba=K;else ba=(K>>>0)%(d>>>0)|0;if((ba|0)!=(V|0)){X=V;Y=d;Z=0;_=40;break a}}if((b[aa+8>>0]|0)==E<<24>>24){_=55;break}}}}else{X=0;Y=0;Z=1;_=40}while(0);if((_|0)==40){_=0;J=ln(16)|0;b[J+8>>0]=E;f[J+12>>2]=z;f[J+4>>2]=p;f[J>>2]=0;ca=$(((f[r>>2]|0)+1|0)>>>0);da=$(Y>>>0);ea=$(n[j>>2]);do if(Z|$(ea*da)>>0<3|(Y+-1&Y|0)!=0)&1;D=~~$(W($(ca/ea)))>>>0;ai(g,K>>>0>>0?D:K);K=f[l>>2]|0;D=K+-1|0;if(!(D&K)){fa=K;ga=D&p;break}if(p>>>0>>0){fa=K;ga=p}else{fa=K;ga=(p>>>0)%(K>>>0)|0}}else{fa=Y;ga=X}while(0);p=(f[g>>2]|0)+(ga<<2)|0;E=f[p>>2]|0;if(!E){f[J>>2]=f[s>>2];f[s>>2]=J;f[p>>2]=s;p=f[J>>2]|0;if(p|0){K=f[p+4>>2]|0;p=fa+-1|0;if(p&fa)if(K>>>0>>0)ha=K;else ha=(K>>>0)%(fa>>>0)|0;else ha=K&p;ia=(f[g>>2]|0)+(ha<<2)|0;_=53}}else{f[J>>2]=f[E>>2];ia=E;_=53}if((_|0)==53){_=0;f[ia>>2]=J}f[r>>2]=(f[r>>2]|0)+1;_=55}if((_|0)==55){_=0;E=t;p=f[E>>2]|0;K=un(p|0,f[E+4>>2]|0,z|0,0)|0;kh((f[f[v>>2]>>2]|0)+K|0,h|0,p|0)|0;p=f[i>>2]|0;f[p+(y<<2)>>2]=z;Q=p;R=z+1|0;S=p;T=p;U=p}p=y+1|0;ja=f[k>>2]|0;if(p>>>0>=ja>>>0)break;d=f[l>>2]|0;x=Q;y=p;z=R;A=T;B=S;C=U}if((R|0)==(ja|0))ka=T;else{T=a+84|0;if(!(b[T>>0]|0)){U=f[a+72>>2]|0;C=f[a+68>>2]|0;B=C;if((U|0)==(C|0))la=Q;else{A=U-C>>2;C=0;do{U=B+(C<<2)|0;f[U>>2]=f[S+(f[U>>2]<<2)>>2];C=C+1|0}while(C>>>0>>0);la=Q}}else{b[T>>0]=0;T=a+68|0;Q=a+72|0;A=f[Q>>2]|0;C=f[T>>2]|0;S=A-C>>2;B=C;C=A;if(ja>>>0<=S>>>0)if(ja>>>0>>0?(A=B+(ja<<2)|0,(A|0)!=(C|0)):0){f[Q>>2]=C+(~((C+-4-A|0)>>>2)<<2);ma=ja}else ma=ja;else{Ch(T,ja-S|0,1220);ma=f[k>>2]|0}S=f[i>>2]|0;if(!ma)la=S;else{i=f[a+68>>2]|0;a=0;do{f[i+(a<<2)>>2]=f[S+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);la=S}}f[k>>2]=R;ka=la}if(!ka)na=R;else{la=f[m>>2]|0;if((la|0)!=(ka|0))f[m>>2]=la+(~((la+-4-ka|0)>>>2)<<2);Oq(ka);na=R}}else na=0;R=f[g+8>>2]|0;if(R|0){ka=R;do{R=ka;ka=f[ka>>2]|0;Oq(R)}while((ka|0)!=0)}ka=f[g>>2]|0;f[g>>2]=0;if(!ka){u=e;return na|0}Oq(ka);u=e;return na|0}function hc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=Oa,ea=Oa,fa=Oa,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0;e=u;u=u+48|0;g=e+16|0;i=e+12|0;j=e;k=g+16|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;n[k>>2]=$(1.0);l=a+80|0;m=f[l>>2]|0;f[j>>2]=0;o=j+4|0;f[o>>2]=0;f[j+8>>2]=0;if(m){if(m>>>0>1073741823)aq(j);p=m<<2;q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=c+48|0;p=c+40|0;m=g+4|0;s=g+12|0;t=g+8|0;v=a+40|0;w=a+64|0;x=f[d>>2]|0;d=0;y=q;z=0;A=0;B=q;C=q;D=q;while(1){q=r;E=f[q>>2]|0;F=f[q+4>>2]|0;q=p;G=un(f[q>>2]|0,f[q+4>>2]|0,x+z|0,0)|0;q=Vn(G|0,I|0,E|0,F|0)|0;F=(f[f[c>>2]>>2]|0)+q|0;q=h[F>>0]|h[F+1>>0]<<8|h[F+2>>0]<<16|h[F+3>>0]<<24;f[i>>2]=q;F=q^318;a:do if(d){E=d+-1|0;G=(E&d|0)==0;if(!G)if(F>>>0>>0)H=F;else H=(F>>>0)%(d>>>0)|0;else H=E&F;J=f[g>>2]|0;K=f[J+(H<<2)>>2]|0;b:do if(K|0?(L=f[K>>2]|0,L|0):0){c:do if(G){M=L;while(1){N=f[M+4>>2]|0;O=(N|0)==(F|0);if(!(O|(N&E|0)==(H|0)))break b;if(O?(f[M+8>>2]|0)==(q|0):0){P=M;break c}M=f[M>>2]|0;if(!M)break b}}else{M=L;while(1){O=f[M+4>>2]|0;if((O|0)==(F|0)){if((f[M+8>>2]|0)==(q|0)){P=M;break c}}else{if(O>>>0>>0)Q=O;else Q=(O>>>0)%(d>>>0)|0;if((Q|0)!=(H|0))break b}M=f[M>>2]|0;if(!M)break b}}while(0);f[D+(z<<2)>>2]=f[P+12>>2];R=y;S=A;T=C;U=B;V=D;break a}while(0);if(!G)if(F>>>0>>0)X=F;else X=(F>>>0)%(d>>>0)|0;else X=E&F;K=f[J+(X<<2)>>2]|0;if(!K){Y=X;Z=d;_=0;aa=40}else{if(G){L=K;while(1){L=f[L>>2]|0;if(!L){Y=X;Z=d;_=0;aa=40;break a}M=f[L+4>>2]|0;if(!((M|0)==(F|0)|(M&E|0)==(X|0))){Y=X;Z=d;_=0;aa=40;break a}if((f[L+8>>2]|0)==(q|0)){aa=55;break a}}}else ba=K;while(1){ba=f[ba>>2]|0;if(!ba){Y=X;Z=d;_=0;aa=40;break a}L=f[ba+4>>2]|0;if((L|0)!=(F|0)){if(L>>>0>>0)ca=L;else ca=(L>>>0)%(d>>>0)|0;if((ca|0)!=(X|0)){Y=X;Z=d;_=0;aa=40;break a}}if((f[ba+8>>2]|0)==(q|0)){aa=55;break}}}}else{Y=0;Z=0;_=1;aa=40}while(0);if((aa|0)==40){aa=0;K=ln(16)|0;f[K+8>>2]=q;f[K+12>>2]=A;f[K+4>>2]=F;f[K>>2]=0;da=$(((f[s>>2]|0)+1|0)>>>0);ea=$(Z>>>0);fa=$(n[k>>2]);do if(_|$(fa*ea)>>0<3|(Z+-1&Z|0)!=0)&1;E=~~$(W($(da/fa)))>>>0;Hi(g,L>>>0>>0?E:L);L=f[m>>2]|0;E=L+-1|0;if(!(E&L)){ga=L;ha=E&F;break}if(F>>>0>>0){ga=L;ha=F}else{ga=L;ha=(F>>>0)%(L>>>0)|0}}else{ga=Z;ha=Y}while(0);F=(f[g>>2]|0)+(ha<<2)|0;q=f[F>>2]|0;if(!q){f[K>>2]=f[t>>2];f[t>>2]=K;f[F>>2]=t;F=f[K>>2]|0;if(F|0){L=f[F+4>>2]|0;F=ga+-1|0;if(F&ga)if(L>>>0>>0)ia=L;else ia=(L>>>0)%(ga>>>0)|0;else ia=L&F;ja=(f[g>>2]|0)+(ia<<2)|0;aa=53}}else{f[K>>2]=f[q>>2];ja=q;aa=53}if((aa|0)==53){aa=0;f[ja>>2]=K}f[s>>2]=(f[s>>2]|0)+1;aa=55}if((aa|0)==55){aa=0;q=v;F=f[q>>2]|0;L=un(F|0,f[q+4>>2]|0,A|0,0)|0;kh((f[f[w>>2]>>2]|0)+L|0,i|0,F|0)|0;F=f[j>>2]|0;f[F+(z<<2)>>2]=A;R=F;S=A+1|0;T=F;U=F;V=F}F=z+1|0;ka=f[l>>2]|0;if(F>>>0>=ka>>>0)break;d=f[m>>2]|0;y=R;z=F;A=S;B=U;C=T;D=V}if((S|0)==(ka|0))la=U;else{U=a+84|0;if(!(b[U>>0]|0)){V=f[a+72>>2]|0;D=f[a+68>>2]|0;C=D;if((V|0)==(D|0))ma=R;else{B=V-D>>2;D=0;do{V=C+(D<<2)|0;f[V>>2]=f[T+(f[V>>2]<<2)>>2];D=D+1|0}while(D>>>0>>0);ma=R}}else{b[U>>0]=0;U=a+68|0;R=a+72|0;B=f[R>>2]|0;D=f[U>>2]|0;T=B-D>>2;C=D;D=B;if(ka>>>0<=T>>>0)if(ka>>>0>>0?(B=C+(ka<<2)|0,(B|0)!=(D|0)):0){f[R>>2]=D+(~((D+-4-B|0)>>>2)<<2);na=ka}else na=ka;else{Ch(U,ka-T|0,1220);na=f[l>>2]|0}T=f[j>>2]|0;if(!na)ma=T;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[T+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);ma=T}}f[l>>2]=S;la=ma}if(!la)oa=S;else{ma=f[o>>2]|0;if((ma|0)!=(la|0))f[o>>2]=ma+(~((ma+-4-la|0)>>>2)<<2);Oq(la);oa=S}}else oa=0;S=f[g+8>>2]|0;if(S|0){la=S;do{S=la;la=f[la>>2]|0;Oq(S)}while((la|0)!=0)}la=f[g>>2]|0;f[g>>2]=0;if(!la){u=e;return oa|0}Oq(la);u=e;return oa|0}function ic(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0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48|0;r=c+40|0;s=i+4|0;p=i+12|0;v=i+8|0;w=a+40|0;x=a+64|0;y=0;z=0;while(1){A=e;B=f[A>>2]|0;C=f[A+4>>2]|0;A=r;D=un(f[A>>2]|0,f[A+4>>2]|0,t+y|0,0)|0;A=Vn(D|0,I|0,B|0,C|0)|0;C=(f[f[c>>2]>>2]|0)+A|0;A=C;B=h[A>>0]|h[A+1>>0]<<8|h[A+2>>0]<<16|h[A+3>>0]<<24;A=C+4|0;C=h[A>>0]|h[A+1>>0]<<8|h[A+2>>0]<<16|h[A+3>>0]<<24;A=j;f[A>>2]=B;f[A+4>>2]=C;A=k;f[A>>2]=B;f[A+4>>2]=C;C=yf(i,k)|0;if(!C){A=k;B=f[A>>2]|0;D=f[A+4>>2]|0;A=B&65535;E=Yn(B|0,D|0,16)|0;F=E&65535;G=D&65535;H=Yn(B|0,D|0,48)|0;J=H&65535;K=((((A^318)&65535)+239^E&65535)+239^D&65535)+239^H&65535;H=f[s>>2]|0;E=(H|0)==0;a:do if(!E){L=H+-1|0;M=(L&H|0)==0;if(!M)if(K>>>0>>0)N=K;else N=(K>>>0)%(H>>>0)|0;else N=K&L;O=f[(f[i>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(K|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((d[O>>1]|0)==A<<16>>16?(d[O+2>>1]|0)==F<<16>>16:0)?(d[M+12>>1]|0)==G<<16>>16:0)?(d[O+6>>1]|0)==J<<16>>16:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(K|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(H>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((d[M>>1]|0)==A<<16>>16?(d[M+2>>1]|0)==F<<16>>16:0)?(d[S+12>>1]|0)==G<<16>>16:0)?(d[M+6>>1]|0)==J<<16>>16:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;J=ln(20)|0;G=J+8|0;F=G;d[F>>1]=B;d[F+2>>1]=B>>>16;F=G+4|0;d[F>>1]=D;d[F+2>>1]=D>>>16;f[J+16>>2]=z;f[J+4>>2]=K;f[J>>2]=0;U=$(((f[p>>2]|0)+1|0)>>>0);V=$(H>>>0);X=$(n[m>>2]);do if(E|$(X*V)>>0<3|(H+-1&H|0)!=0)&1;G=~~$(W($(U/X)))>>>0;Sh(i,F>>>0>>0?G:F);F=f[s>>2]|0;G=F+-1|0;if(!(G&F)){Y=F;Z=G&K;break}if(K>>>0>>0){Y=F;Z=K}else{Y=F;Z=(K>>>0)%(F>>>0)|0}}else{Y=H;Z=Q}while(0);H=(f[i>>2]|0)+(Z<<2)|0;K=f[H>>2]|0;if(!K){f[J>>2]=f[v>>2];f[v>>2]=J;f[H>>2]=v;H=f[J>>2]|0;if(H|0){E=f[H+4>>2]|0;H=Y+-1|0;if(H&Y)if(E>>>0>>0)_=E;else _=(E>>>0)%(Y>>>0)|0;else _=E&H;aa=(f[i>>2]|0)+(_<<2)|0;R=44}}else{f[J>>2]=f[K>>2];aa=K;R=44}if((R|0)==44){R=0;f[aa>>2]=J}f[p>>2]=(f[p>>2]|0)+1}K=w;H=f[K>>2]|0;E=un(H|0,f[K+4>>2]|0,z|0,0)|0;kh((f[f[x>>2]>>2]|0)+E|0,j|0,H|0)|0;H=f[l>>2]|0;f[H+(y<<2)>>2]=z;ba=z+1|0;ca=H}else{H=f[l>>2]|0;f[H+(y<<2)>>2]=f[C+16>>2];ba=z;ca=H}y=y+1|0;da=f[o>>2]|0;if(y>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){y=f[a+72>>2]|0;j=f[a+68>>2]|0;x=j;if((y|0)==(j|0))fa=ca;else{w=y-j>>2;j=0;do{y=x+(j<<2)|0;f[y>>2]=f[ca+(f[y>>2]<<2)>>2];j=j+1|0}while(j>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;w=f[ca>>2]|0;j=f[z>>2]|0;x=w-j>>2;y=j;j=w;if(da>>>0<=x>>>0)if(da>>>0>>0?(w=y+(da<<2)|0,(w|0)!=(j|0)):0){f[ca>>2]=j+(~((j+-4-w|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-x|0,1220);ga=f[o>>2]|0}x=f[l>>2]|0;if(!ga)fa=x;else{l=f[a+68>>2]|0;a=0;do{f[l+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=x}}f[o>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[q>>2]|0;if((fa|0)!=(ea|0))f[q>>2]=fa+(~((fa+-4-ea|0)>>>2)<<2);Oq(ea);ha=ba}}else ha=0;ba=f[i+8>>2]|0;if(ba|0){ea=ba;do{ba=ea;ea=f[ea>>2]|0;Oq(ba)}while((ea|0)!=0)}ea=f[i>>2]|0;f[i>>2]=0;if(!ea){u=g;return ha|0}Oq(ea);u=g;return ha|0}function kc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+152|0;v=a+84|0;w=a+272|0;x=a+276|0;y=a+268|0;z=a+168|0;A=a+140|0;B=a+120|0;C=o;do{o=f[C+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(D=(o>>>0)/3|0,E=f[n>>2]|0,(f[E+(D>>>5<<2)>>2]&1<<(D&31)|0)==0):0){if(l){D=0;F=E;b:while(1){E=D+1|0;f[i>>2]=(f[i>>2]|0)+1;G=f[b>>2]|0;H=(G|0)==-1?-1:(G>>>0)/3|0;G=F+(H>>>5<<2)|0;f[G>>2]=1<<(H&31)|f[G>>2];G=f[q>>2]|0;if((G|0)==(f[r>>2]|0))Ri(s,b);else{f[G>>2]=f[b>>2];f[q>>2]=G+4}G=f[b>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[f[p>>2]>>2]|0)+(G<<2)>>2]|0;J=(f[(f[t>>2]|0)+(I<<2)>>2]|0)!=-1;K=(f[v>>2]|0)+(I>>>5<<2)|0;L=1<<(I&31);M=f[K>>2]|0;do if(!(M&L)){f[K>>2]=M|L;if(J){N=f[b>>2]|0;O=30;break}f[d>>2]=0;P=f[w>>2]|0;if((P|0)==(f[x>>2]|0))Ri(y,d);else{f[P>>2]=0;f[w>>2]=P+4}P=f[b>>2]|0;Q=P+1|0;if((P|0)!=-1?(R=((Q>>>0)%3|0|0)==0?P+-2|0:Q,(R|0)!=-1):0)S=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;else S=-1;f[b>>2]=S}else{N=G;O=30}while(0);if((O|0)==30){O=0;G=N+1|0;if((N|0)==-1){O=35;break}L=((G>>>0)%3|0|0)==0?N+-2|0:G;if((L|0)==-1)T=-1;else T=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;f[e>>2]=T;L=(((N>>>0)%3|0|0)==0?2:-1)+N|0;if((L|0)==-1)U=-1;else U=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;L=(T|0)==-1;M=L?-1:(T>>>0)/3|0;V=(U|0)==-1;W=V?-1:(U>>>0)/3|0;K=((G>>>0)%3|0|0)==0?N+-2|0:G;if(((K|0)!=-1?(G=f[(f[p>>2]|0)+12>>2]|0,R=f[G+(K<<2)>>2]|0,(R|0)!=-1):0)?(K=(R>>>0)/3|0,R=f[n>>2]|0,(f[R+(K>>>5<<2)>>2]&1<<(K&31)|0)==0):0){K=(((N>>>0)%3|0|0)==0?2:-1)+N|0;do if((K|0)!=-1){Q=f[G+(K<<2)>>2]|0;if((Q|0)==-1)break;P=(Q>>>0)/3|0;if(!(f[R+(P>>>5<<2)>>2]&1<<(P&31))){O=63;break b}}while(0);if(!V)xf(a,f[i>>2]|0,H,0,W);f[d>>2]=3;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=3;f[w>>2]=R+4}X=f[e>>2]|0}else{if(!L){xf(a,f[i>>2]|0,H,1,M);R=f[b>>2]|0;if((R|0)==-1){O=44;break}else Y=R}else Y=N;R=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((R|0)==-1){O=44;break}K=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;if((K|0)==-1){O=44;break}R=(K>>>0)/3|0;if(f[(f[n>>2]|0)+(R>>>5<<2)>>2]&1<<(R&31)|0){O=44;break}f[d>>2]=5;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=5;f[w>>2]=R+4}X=U}f[b>>2]=X}if((E|0)>=(k|0))break a;D=E;F=f[n>>2]|0}do if((O|0)==35){O=0;f[e>>2]=-1;O=46}else if((O|0)==44){O=0;if(V)O=46;else{xf(a,f[i>>2]|0,H,0,W);O=46}}else if((O|0)==63){O=0;f[d>>2]=1;F=f[w>>2]|0;if((F|0)==(f[x>>2]|0))Ri(y,d);else{f[F>>2]=1;f[w>>2]=F+4}f[z>>2]=(f[z>>2]|0)+1;if(J?(F=f[(f[t>>2]|0)+(I<<2)>>2]|0,(1<<(F&31)&f[(f[A>>2]|0)+(F>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}F=f[i>>2]|0;f[d>>2]=H;D=je(B,d)|0;f[D>>2]=F;F=f[j>>2]|0;f[F+-4>>2]=U;if((F|0)==(f[m>>2]|0)){Ri(h,e);break}else{f[F>>2]=f[e>>2];f[j>>2]=F+4;break}}while(0);if((O|0)==46){O=0;f[d>>2]=7;F=f[w>>2]|0;if((F|0)==(f[x>>2]|0))Ri(y,d);else{f[F>>2]=7;f[w>>2]=F+4}f[j>>2]=(f[j>>2]|0)+-4}}}else O=11;while(0);if((O|0)==11){O=0;f[j>>2]=C+-4}C=f[j>>2]|0}while((f[h>>2]|0)!=(C|0));u=c;return 1}function lc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=Oa,V=Oa,X=Oa,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;e=u;u=u+48|0;g=e+20|0;i=e+16|0;j=e+12|0;k=e;l=g+16|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;n[l>>2]=$(1.0);m=a+80|0;o=f[m>>2]|0;f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;if(o){if(o>>>0>1073741823)aq(k);q=o<<2;r=ln(q)|0;f[k>>2]=r;s=r+(o<<2)|0;f[k+8>>2]=s;sj(r|0,0,q|0)|0;f[p>>2]=s;s=f[d>>2]|0;d=c+48|0;q=c+40|0;r=g+4|0;o=g+12|0;t=g+8|0;v=a+40|0;w=a+64|0;x=0;y=0;while(1){z=d;A=f[z>>2]|0;B=f[z+4>>2]|0;z=q;C=un(f[z>>2]|0,f[z+4>>2]|0,s+x|0,0)|0;z=Vn(C|0,I|0,A|0,B|0)|0;B=(f[f[c>>2]>>2]|0)+z|0;z=h[B>>0]|h[B+1>>0]<<8|h[B+2>>0]<<16|h[B+3>>0]<<24;f[i>>2]=z;f[j>>2]=z;z=Ef(g,j)|0;if(!z){B=f[j>>2]|0;A=B&255;C=B>>>8;D=C&255;E=B>>>16;F=E&255;G=B>>>24;H=G&255;J=C&255;C=E&255;E=(((B&255^318)+239^J)+239^C)+239^G;G=f[r>>2]|0;K=(G|0)==0;a:do if(!K){L=G+-1|0;M=(L&G|0)==0;if(!M)if(E>>>0>>0)N=E;else N=(E>>>0)%(G>>>0)|0;else N=E&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(E|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((b[O>>0]|0)==A<<24>>24?(b[O+1>>0]|0)==D<<24>>24:0)?(b[O+2>>0]|0)==F<<24>>24:0)?(b[O+3>>0]|0)==H<<24>>24:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(E|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(G>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((b[M>>0]|0)==A<<24>>24?(b[M+1>>0]|0)==D<<24>>24:0)?(b[M+2>>0]|0)==F<<24>>24:0)?(b[M+3>>0]|0)==H<<24>>24:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;H=ln(16)|0;F=H+8|0;D=B&-16776961|C<<16|J<<8;b[F>>0]=D;b[F+1>>0]=D>>8;b[F+2>>0]=D>>16;b[F+3>>0]=D>>24;f[H+12>>2]=y;f[H+4>>2]=E;f[H>>2]=0;U=$(((f[o>>2]|0)+1|0)>>>0);V=$(G>>>0);X=$(n[l>>2]);do if(K|$(X*V)>>0<3|(G+-1&G|0)!=0)&1;F=~~$(W($(U/X)))>>>0;Zh(g,D>>>0>>0?F:D);D=f[r>>2]|0;F=D+-1|0;if(!(F&D)){Y=D;Z=F&E;break}if(E>>>0>>0){Y=D;Z=E}else{Y=D;Z=(E>>>0)%(D>>>0)|0}}else{Y=G;Z=Q}while(0);G=(f[g>>2]|0)+(Z<<2)|0;E=f[G>>2]|0;if(!E){f[H>>2]=f[t>>2];f[t>>2]=H;f[G>>2]=t;G=f[H>>2]|0;if(G|0){K=f[G+4>>2]|0;G=Y+-1|0;if(G&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&G;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[H>>2]=f[E>>2];aa=E;R=44}if((R|0)==44){R=0;f[aa>>2]=H}f[o>>2]=(f[o>>2]|0)+1}E=v;G=f[E>>2]|0;K=un(G|0,f[E+4>>2]|0,y|0,0)|0;kh((f[f[w>>2]>>2]|0)+K|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(x<<2)>>2]=y;ba=y+1|0;ca=G}else{G=f[k>>2]|0;f[G+(x<<2)>>2]=f[z+12>>2];ba=y;ca=G}x=x+1|0;da=f[m>>2]|0;if(x>>>0>=da>>>0)break;else y=ba}if((ba|0)==(da|0))ea=ca;else{y=a+84|0;if(!(b[y>>0]|0)){x=f[a+72>>2]|0;i=f[a+68>>2]|0;w=i;if((x|0)==(i|0))fa=ca;else{v=x-i>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[j+8>>2]=0;if(m){if(m>>>0>1073741823)aq(j);p=m<<2;q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=f[d>>2]|0;d=c+48|0;p=c+40|0;q=i+4|0;m=i+8|0;s=i+12|0;t=g+4|0;v=g+12|0;w=g+8|0;x=a+40|0;y=a+64|0;z=0;A=0;while(1){B=d;C=f[B>>2]|0;D=f[B+4>>2]|0;B=p;E=un(f[B>>2]|0,f[B+4>>2]|0,r+A|0,0)|0;B=Vn(E|0,I|0,C|0,D|0)|0;D=(f[f[c>>2]>>2]|0)+B|0;B=h;C=D;E=B+16|0;do{b[B>>0]=b[C>>0]|0;B=B+1|0;C=C+1|0}while((B|0)<(E|0));im(i|0,D|0,16)|0;C=Vf(g,i)|0;if(!C){B=f[i>>2]|0;E=f[q>>2]|0;F=f[m>>2]|0;G=f[s>>2]|0;H=(((B^318)+239^E)+239^F)+239^G;J=f[t>>2]|0;K=(J|0)==0;a:do if(!K){L=J+-1|0;M=(L&J|0)==0;if(!M)if(H>>>0>>0)N=H;else N=(H>>>0)%(J>>>0)|0;else N=H&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(H|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}if((((f[M+8>>2]|0)==(B|0)?(f[M+12>>2]|0)==(E|0):0)?(f[M+16>>2]|0)==(F|0):0)?(f[M+20>>2]|0)==(G|0):0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(H|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(J>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}if((((f[S+8>>2]|0)==(B|0)?(f[S+12>>2]|0)==(E|0):0)?(f[S+16>>2]|0)==(F|0):0)?(f[S+20>>2]|0)==(G|0):0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;D=ln(28)|0;f[D+8>>2]=B;f[D+12>>2]=E;f[D+16>>2]=F;f[D+20>>2]=G;f[D+24>>2]=z;f[D+4>>2]=H;f[D>>2]=0;U=$(((f[v>>2]|0)+1|0)>>>0);V=$(J>>>0);X=$(n[k>>2]);do if(K|$(X*V)>>0<3|(J+-1&J|0)!=0)&1;M=~~$(W($(U/X)))>>>0;Wh(g,P>>>0>>0?M:P);P=f[t>>2]|0;M=P+-1|0;if(!(M&P)){Y=P;Z=M&H;break}if(H>>>0

    >>0){Y=P;Z=H}else{Y=P;Z=(H>>>0)%(P>>>0)|0}}else{Y=J;Z=Q}while(0);J=(f[g>>2]|0)+(Z<<2)|0;H=f[J>>2]|0;if(!H){f[D>>2]=f[w>>2];f[w>>2]=D;f[J>>2]=w;J=f[D>>2]|0;if(J|0){K=f[J+4>>2]|0;J=Y+-1|0;if(J&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&J;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[D>>2]=f[H>>2];aa=H;R=44}if((R|0)==44){R=0;f[aa>>2]=D}f[v>>2]=(f[v>>2]|0)+1}H=x;J=f[H>>2]|0;K=un(J|0,f[H+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+K|0,h|0,J|0)|0;J=f[j>>2]|0;f[J+(A<<2)>>2]=z;ba=z+1|0;ca=J}else{J=f[j>>2]|0;f[J+(A<<2)>>2]=f[C+24>>2];ba=z;ca=J}A=A+1|0;da=f[l>>2]|0;if(A>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;h=f[a+68>>2]|0;y=h;if((A|0)==(h|0))fa=ca;else{x=A-h>>2;h=0;do{A=y+(h<<2)|0;f[A>>2]=f[ca+(f[A>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;x=f[ca>>2]|0;h=f[z>>2]|0;y=x-h>>2;A=h;h=x;if(da>>>0<=y>>>0)if(da>>>0>>0?(x=A+(da<<2)|0,(x|0)!=(h|0)):0){f[ca>>2]=h+(~((h+-4-x|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-y|0,1220);ga=f[l>>2]|0}y=f[j>>2]|0;if(!ga)fa=y;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=y}}f[l>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[o>>2]|0;if((fa|0)!=(ea|0))f[o>>2]=fa+(~((fa+-4-ea|0)>>>2)<<2);Oq(ea);ha=ba}}else ha=0;ba=f[g+8>>2]|0;if(ba|0){ea=ba;do{ba=ea;ea=f[ea>>2]|0;Oq(ba)}while((ea|0)!=0)}ea=f[g>>2]|0;f[g>>2]=0;if(!ea){u=e;return ha|0}Oq(ea);u=e;return ha|0}function nc(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=Oa,T=Oa,U=Oa,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0;g=u;u=u+48|0;h=g+12|0;i=g+38|0;j=g+32|0;k=g;l=h+16|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;n[l>>2]=$(1.0);m=a+80|0;o=f[m>>2]|0;f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;if(o){if(o>>>0>1073741823)aq(k);q=o<<2;r=ln(q)|0;f[k>>2]=r;s=r+(o<<2)|0;f[k+8>>2]=s;sj(r|0,0,q|0)|0;f[p>>2]=s;s=f[e>>2]|0;e=c+48|0;q=c+40|0;r=j+2|0;o=j+4|0;t=h+4|0;v=h+12|0;w=h+8|0;x=a+40|0;y=a+64|0;z=0;A=0;while(1){B=e;C=f[B>>2]|0;D=f[B+4>>2]|0;B=q;E=un(f[B>>2]|0,f[B+4>>2]|0,s+A|0,0)|0;B=Vn(E|0,I|0,C|0,D|0)|0;D=(f[f[c>>2]>>2]|0)+B|0;b[i>>0]=b[D>>0]|0;b[i+1>>0]=b[D+1>>0]|0;b[i+2>>0]=b[D+2>>0]|0;b[i+3>>0]=b[D+3>>0]|0;b[i+4>>0]=b[D+4>>0]|0;b[i+5>>0]=b[D+5>>0]|0;im(j|0,D|0,6)|0;D=dg(h,j)|0;if(!D){B=d[j>>1]|0;C=d[r>>1]|0;E=d[o>>1]|0;F=(((B^318)&65535)+239^C&65535)+239^E&65535;G=f[t>>2]|0;H=(G|0)==0;a:do if(!H){J=G+-1|0;K=(J&G|0)==0;if(!K)if(F>>>0>>0)L=F;else L=(F>>>0)%(G>>>0)|0;else L=F&J;M=f[(f[h>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}M=K+8|0;if(((d[M>>1]|0)==B<<16>>16?(d[M+2>>1]|0)==C<<16>>16:0)?(d[K+12>>1]|0)==E<<16>>16:0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}K=Q+8|0;if(((d[K>>1]|0)==B<<16>>16?(d[K+2>>1]|0)==C<<16>>16:0)?(d[Q+12>>1]|0)==E<<16>>16:0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;N=ln(20)|0;d[N+8>>1]=B;d[N+10>>1]=C;d[N+12>>1]=E;f[N+16>>2]=z;f[N+4>>2]=F;f[N>>2]=0;S=$(((f[v>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[l>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;J=~~$(W($(S/U)))>>>0;Th(h,K>>>0>>0?J:K);K=f[t>>2]|0;J=K+-1|0;if(!(J&K)){V=K;X=J&F;break}if(F>>>0>>0){V=K;X=F}else{V=K;X=(F>>>0)%(K>>>0)|0}}else{V=G;X=O}while(0);G=(f[h>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[N>>2]=f[w>>2];f[w>>2]=N;f[G>>2]=w;G=f[N>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[h>>2]|0)+(Y<<2)|0;P=42}}else{f[N>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=N}f[v>>2]=(f[v>>2]|0)+1}F=x;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+H|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=z;_=z+1|0;aa=G}else{G=f[k>>2]|0;f[G+(A<<2)>>2]=f[D+16>>2];_=z;aa=G}A=A+1|0;ba=f[m>>2]|0;if(A>>>0>=ba>>>0)break;else z=_}if((_|0)==(ba|0))ca=aa;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;i=f[a+68>>2]|0;y=i;if((A|0)==(i|0))da=aa;else{x=A-i>>2;i=0;do{A=y+(i<<2)|0;f[A>>2]=f[aa+(f[A>>2]<<2)>>2];i=i+1|0}while(i>>>0>>0);da=aa}}else{b[z>>0]=0;z=a+68|0;aa=a+72|0;x=f[aa>>2]|0;i=f[z>>2]|0;y=x-i>>2;A=i;i=x;if(ba>>>0<=y>>>0)if(ba>>>0>>0?(x=A+(ba<<2)|0,(x|0)!=(i|0)):0){f[aa>>2]=i+(~((i+-4-x|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(z,ba-y|0,1220);ea=f[m>>2]|0}y=f[k>>2]|0;if(!ea)da=y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=y}}f[m>>2]=_;ca=da}if(!ca)fa=_;else{da=f[p>>2]|0;if((da|0)!=(ca|0))f[p>>2]=da+(~((da+-4-ca|0)>>>2)<<2);Oq(ca);fa=_}}else fa=0;_=f[h+8>>2]|0;if(_|0){ca=_;do{_=ca;ca=f[ca>>2]|0;Oq(_)}while((ca|0)!=0)}ca=f[h>>2]|0;f[h>>2]=0;if(!ca){u=g;return fa|0}Oq(ca);u=g;return fa|0}function oc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0;g=a+8|0;Mh(g,b,d,e);d=f[a+48>>2]|0;h=f[a+52>>2]|0;i=e>>>0>1073741823?-1:e<<2;j=Lq(i)|0;sj(j|0,0,i|0)|0;k=Lq(i)|0;sj(k|0,0,i|0)|0;i=f[a+56>>2]|0;l=i+4|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n|0;a:do if((o|0)>4){p=o>>2;q=(e|0)>0;r=a+16|0;s=a+32|0;t=a+12|0;u=a+28|0;v=a+20|0;w=a+24|0;x=d+12|0;y=e<<2;z=p+-1|0;if(m-n>>2>>>0>z>>>0){A=p;B=z;C=n}else aq(i);while(1){z=f[C+(B<<2)>>2]|0;if(q)sj(j|0,0,y|0)|0;if((z|0)!=-1){p=f[x>>2]|0;D=0;E=z;while(1){F=f[p+(E<<2)>>2]|0;if((F|0)!=-1){G=f[d>>2]|0;H=f[h>>2]|0;I=f[H+(f[G+(F<<2)>>2]<<2)>>2]|0;J=F+1|0;K=((J>>>0)%3|0|0)==0?F+-2|0:J;if((K|0)==-1)L=-1;else L=f[G+(K<<2)>>2]|0;K=f[H+(L<<2)>>2]|0;J=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((J|0)==-1)M=-1;else M=f[G+(J<<2)>>2]|0;J=f[H+(M<<2)>>2]|0;if((I|0)<(B|0)&(K|0)<(B|0)&(J|0)<(B|0)){H=X(I,e)|0;I=X(K,e)|0;K=X(J,e)|0;if(q){J=0;do{f[k+(J<<2)>>2]=(f[b+(J+K<<2)>>2]|0)+(f[b+(J+I<<2)>>2]|0)-(f[b+(J+H<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0));if(q){J=0;do{H=j+(J<<2)|0;f[H>>2]=(f[H>>2]|0)+(f[k+(J<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0))}}N=D+1|0}else N=D}else N=D;J=(((E>>>0)%3|0|0)==0?2:-1)+E|0;do if((J|0)!=-1?(H=f[p+(J<<2)>>2]|0,(H|0)!=-1):0)if(!((H>>>0)%3|0)){O=H+2|0;break}else{O=H+-1|0;break}else O=-1;while(0);E=(O|0)==(z|0)?-1:O;if((E|0)==-1)break;else D=N}D=X(B,e)|0;if(N){if(q){E=0;do{z=j+(E<<2)|0;f[z>>2]=(f[z>>2]|0)/(N|0)|0;E=E+1|0}while((E|0)!=(e|0))}E=b+(D<<2)|0;z=c+(D<<2)|0;p=f[g>>2]|0;if((p|0)>0){J=0;H=j;I=p;while(1){if((I|0)>0){p=0;do{K=f[H+(p<<2)>>2]|0;G=f[r>>2]|0;if((K|0)>(G|0)){F=f[s>>2]|0;f[F+(p<<2)>>2]=G;P=F}else{F=f[t>>2]|0;G=f[s>>2]|0;f[G+(p<<2)>>2]=(K|0)<(F|0)?F:K;P=G}p=p+1|0}while((p|0)<(f[g>>2]|0));Q=P}else Q=f[s>>2]|0;p=(f[E+(J<<2)>>2]|0)-(f[Q+(J<<2)>>2]|0)|0;G=z+(J<<2)|0;f[G>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){R=p-(f[v>>2]|0)|0;S=57}}else{R=(f[v>>2]|0)+p|0;S=57}if((S|0)==57){S=0;f[G>>2]=R}J=J+1|0;I=f[g>>2]|0;if((J|0)>=(I|0))break;else H=Q}}}else{T=D;S=30}}else{T=X(B,e)|0;S=30}if((S|0)==30?(S=0,H=b+(T<<2)|0,I=c+(T<<2)|0,J=f[g>>2]|0,(J|0)>0):0){z=0;E=b+((X(A+-2|0,e)|0)<<2)|0;G=J;while(1){if((G|0)>0){J=0;do{p=f[E+(J<<2)>>2]|0;K=f[r>>2]|0;if((p|0)>(K|0)){F=f[s>>2]|0;f[F+(J<<2)>>2]=K;U=F}else{F=f[t>>2]|0;K=f[s>>2]|0;f[K+(J<<2)>>2]=(p|0)<(F|0)?F:p;U=K}J=J+1|0}while((J|0)<(f[g>>2]|0));V=U}else V=f[s>>2]|0;J=(f[H+(z<<2)>>2]|0)-(f[V+(z<<2)>>2]|0)|0;K=I+(z<<2)|0;f[K>>2]=J;if((J|0)>=(f[u>>2]|0)){if((J|0)>(f[w>>2]|0)){W=J-(f[v>>2]|0)|0;S=42}}else{W=(f[v>>2]|0)+J|0;S=42}if((S|0)==42){S=0;f[K>>2]=W}z=z+1|0;G=f[g>>2]|0;if((z|0)>=(G|0))break;else E=V}}if((A|0)<=2)break a;C=f[i>>2]|0;E=B+-1|0;if((f[l>>2]|0)-C>>2>>>0<=E>>>0)break;else{G=B;B=E;A=G}}aq(i)}while(0);if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;t=a+12|0;u=a+28|0;v=a+20|0;w=a+24|0;x=d+64|0;y=d+28|0;z=e<<2;A=p+-1|0;if(m-n>>2>>>0>A>>>0){B=p;C=A;D=n}else aq(i);while(1){A=f[D+(C<<2)>>2]|0;if(q)sj(j|0,0,z|0)|0;if((A|0)!=-1){p=f[d>>2]|0;E=0;F=A;while(1){if(((f[p+(F>>>5<<2)>>2]&1<<(F&31)|0)==0?(G=f[(f[(f[x>>2]|0)+12>>2]|0)+(F<<2)>>2]|0,(G|0)!=-1):0)?(H=f[y>>2]|0,I=f[h>>2]|0,J=f[I+(f[H+(G<<2)>>2]<<2)>>2]|0,K=G+1|0,L=f[I+(f[H+((((K>>>0)%3|0|0)==0?G+-2|0:K)<<2)>>2]<<2)>>2]|0,K=f[I+(f[H+((((G>>>0)%3|0|0)==0?2:-1)+G<<2)>>2]<<2)>>2]|0,(J|0)<(C|0)&(L|0)<(C|0)&(K|0)<(C|0)):0){G=X(J,e)|0;J=X(L,e)|0;L=X(K,e)|0;if(q){K=0;do{f[k+(K<<2)>>2]=(f[b+(K+L<<2)>>2]|0)+(f[b+(K+J<<2)>>2]|0)-(f[b+(K+G<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0));if(q){K=0;do{G=j+(K<<2)|0;f[G>>2]=(f[G>>2]|0)+(f[k+(K<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0))}}M=E+1|0}else M=E;K=(((F>>>0)%3|0|0)==0?2:-1)+F|0;do if(((K|0)!=-1?(f[p+(K>>>5<<2)>>2]&1<<(K&31)|0)==0:0)?(G=f[(f[(f[x>>2]|0)+12>>2]|0)+(K<<2)>>2]|0,(G|0)!=-1):0)if(!((G>>>0)%3|0)){N=G+2|0;break}else{N=G+-1|0;break}else N=-1;while(0);F=(N|0)==(A|0)?-1:N;if((F|0)==-1)break;else E=M}E=X(C,e)|0;if(M){if(q){F=0;do{A=j+(F<<2)|0;f[A>>2]=(f[A>>2]|0)/(M|0)|0;F=F+1|0}while((F|0)!=(e|0))}F=b+(E<<2)|0;A=c+(E<<2)|0;p=f[g>>2]|0;if((p|0)>0){K=0;G=j;J=p;while(1){if((J|0)>0){p=0;do{L=f[G+(p<<2)>>2]|0;H=f[r>>2]|0;if((L|0)>(H|0)){I=f[s>>2]|0;f[I+(p<<2)>>2]=H;O=I}else{I=f[t>>2]|0;H=f[s>>2]|0;f[H+(p<<2)>>2]=(L|0)<(I|0)?I:L;O=H}p=p+1|0}while((p|0)<(f[g>>2]|0));P=O}else P=f[s>>2]|0;p=(f[F+(K<<2)>>2]|0)-(f[P+(K<<2)>>2]|0)|0;H=A+(K<<2)|0;f[H>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){Q=p-(f[v>>2]|0)|0;R=55}}else{Q=(f[v>>2]|0)+p|0;R=55}if((R|0)==55){R=0;f[H>>2]=Q}K=K+1|0;J=f[g>>2]|0;if((K|0)>=(J|0))break;else G=P}}}else{S=E;R=28}}else{S=X(C,e)|0;R=28}if((R|0)==28?(R=0,G=b+(S<<2)|0,J=c+(S<<2)|0,K=f[g>>2]|0,(K|0)>0):0){A=0;F=b+((X(B+-2|0,e)|0)<<2)|0;H=K;while(1){if((H|0)>0){K=0;do{p=f[F+(K<<2)>>2]|0;L=f[r>>2]|0;if((p|0)>(L|0)){I=f[s>>2]|0;f[I+(K<<2)>>2]=L;T=I}else{I=f[t>>2]|0;L=f[s>>2]|0;f[L+(K<<2)>>2]=(p|0)<(I|0)?I:p;T=L}K=K+1|0}while((K|0)<(f[g>>2]|0));U=T}else U=f[s>>2]|0;K=(f[G+(A<<2)>>2]|0)-(f[U+(A<<2)>>2]|0)|0;L=J+(A<<2)|0;f[L>>2]=K;if((K|0)>=(f[u>>2]|0)){if((K|0)>(f[w>>2]|0)){V=K-(f[v>>2]|0)|0;R=40}}else{V=(f[v>>2]|0)+K|0;R=40}if((R|0)==40){R=0;f[L>>2]=V}A=A+1|0;H=f[g>>2]|0;if((A|0)>=(H|0))break;else F=U}}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<=-1){if((S|0)<0){M=f[t>>2]|0;W=(M|0)>-1?M:0-M|0;X=M}else{M=f[t>>2]|0;W=(f[w>>2]|0)-((M|0)>-1?M:0-M|0)|0;X=M}if((X|0)<0){Y=(S|0)>-1?S:0-S|0;Z=W;_=X;break}else{Y=(f[w>>2]|0)-((S|0)>-1?S:0-S|0)|0;Z=W;_=X;break}}else{M=f[t>>2]|0;Y=M+T|0;Z=T+S|0;_=M}while(0);M=(Z|0)==0;P=(Y|0)==0;N=f[w>>2]|0;do if(Y|Z){H=(N|0)==(Y|0);if(!(M&H)){q=(N|0)==(Z|0);if(!(P&q)){if(M&(T|0)<(Y|0)){$=0;aa=(T<<1)-Y|0;break}if(q&(T|0)>(Y|0)){$=Z;aa=(T<<1)-Y|0;break}if(H&(T|0)>(Z|0)){$=(T<<1)-Z|0;aa=Y;break}if(P){$=(T|0)<(Z|0)?(T<<1)-Z|0:Z;aa=0}else{$=Z;aa=Y}}else{$=Z;aa=Z}}else{$=Y;aa=Y}}else{$=N;aa=N}while(0);P=0-S|0;M=0-_|0;f[j>>2]=0-O;f[r>>2]=P;f[t>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(q=(N|0)==(ca|0),!(M&q)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(q&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);N=K<<1;M=b+(N<<2)|0;H=M+4|0;O=f[H>>2]|0;f[h>>2]=f[M>>2];f[x>>2]=O;f[i>>2]=$;f[y>>2]=aa;Od(d,n,h,i);O=f[d>>2]|0;f[k>>2]=O;P=f[z>>2]|0;f[A>>2]=P;q=f[H>>2]|0;f[h>>2]=f[M>>2];f[B>>2]=q;f[i>>2]=da;f[C>>2]=ea;Od(d,n,h,i);q=f[d>>2]|0;f[l>>2]=q;M=f[D>>2]|0;f[E>>2]=M;H=f[v>>2]|0;if((H|0)>=(O|0))if((O|0)<(0-H|0))fa=(f[F>>2]|0)+O|0;else fa=O;else fa=O-(f[F>>2]|0)|0;f[k>>2]=fa;if((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)-L>>2>>>0<=K>>>0){J=M;ma=6;break}}if((ma|0)==5){u=e;return 1}else if((ma|0)==6)aq(J);return 0}function rc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0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0;f[w>>2]=t;f[e>>2]=t;y=t+(v<<3)|0;f[e+8>>2]=y;z=v;v=t;k=t;while(1){s=v;f[s>>2]=-1;f[s+4>>2]=-1;s=k+8|0;A=z+-1|0;if(!A)break;else{z=A;v=s;k=s}}f[w>>2]=y;H=t;I=t}t=f[q>>2]|0;y=f[d>>2]|0;k=t-y|0;v=k>>2;f[g>>2]=0;z=g+4|0;f[z>>2]=0;f[g+8>>2]=0;s=y;do if(v)if(v>>>0>1073741823)aq(g);else{A=ln(k)|0;f[g>>2]=A;p=A+(v<<2)|0;f[g+8>>2]=p;sj(A|0,0,k|0)|0;f[z>>2]=p;J=A;K=p;L=A;break}else{J=0;K=0;L=0}while(0);if((t|0)!=(y|0)){y=0;t=0;while(1){f[J+(t<<2)>>2]=y;k=t+1|0;if(k>>>0>>0){y=(f[s+(t<<2)>>2]|0)+y|0;t=k}else break}}t=f[j>>2]|0;j=f[a>>2]|0;y=j;if((t|0)!=(j|0)){k=a+40|0;a=t-j>>2;j=H;t=H;g=H;A=H;p=H;x=H;l=0;o=J;while(1){F=f[y+(l<<2)>>2]|0;G=l+1|0;E=((G>>>0)%3|0|0)==0?l+-2|0:G;if((E|0)==-1)M=-1;else M=f[y+(E<<2)>>2]|0;E=((l>>>0)%3|0|0)==0;G=(E?2:-1)+l|0;if((G|0)==-1)N=-1;else N=f[y+(G<<2)>>2]|0;if(E?(M|0)==(N|0)|((F|0)==(M|0)|(F|0)==(N|0)):0){f[k>>2]=(f[k>>2]|0)+1;O=j;P=t;Q=g;R=A;S=p;T=x;U=l+2|0;V=o}else W=51;a:do if((W|0)==51){W=0;E=f[s+(N<<2)>>2]|0;b:do if((E|0)>0){G=0;B=f[o+(N<<2)>>2]|0;while(1){m=f[p+(B<<3)>>2]|0;if((m|0)==-1){X=j;Y=t;Z=A;_=p;break b}if((m|0)==(M|0)){m=f[p+(B<<3)+4>>2]|0;if((m|0)==-1)$=-1;else $=f[y+(m<<2)>>2]|0;if((F|0)!=($|0))break}m=G+1|0;if((m|0)<(E|0)){G=m;B=B+1|0}else{X=j;Y=t;Z=A;_=p;break b}}m=f[A+(B<<3)+4>>2]|0;r=G;n=B;D=t;while(1){r=r+1|0;if((r|0)>=(E|0))break;C=n+1|0;f[D+(n<<3)>>2]=f[D+(C<<3)>>2];f[D+(n<<3)+4>>2]=f[D+(C<<3)+4>>2];if((f[j+(n<<3)>>2]|0)==-1)break;else{n=C;D=j}}f[g+(n<<3)>>2]=-1;if((m|0)==-1){X=g;Y=g;Z=g;_=g}else{D=f[i>>2]|0;f[D+(l<<2)>>2]=m;f[D+(m<<2)>>2]=l;O=g;P=g;Q=g;R=g;S=g;T=x;U=l;V=o;break a}}else{X=j;Y=t;Z=A;_=p}while(0);E=f[s+(M<<2)>>2]|0;if((E|0)>0){D=0;r=f[J+(M<<2)>>2]|0;while(1){aa=x+(r<<3)|0;if((f[aa>>2]|0)==-1)break;D=D+1|0;if((D|0)>=(E|0)){O=x;P=x;Q=x;R=x;S=x;T=x;U=l;V=J;break a}else r=r+1|0}f[aa>>2]=N;f[H+(r<<3)+4>>2]=l;O=H;P=H;Q=H;R=H;S=H;T=H;U=l;V=J}else{O=X;P=Y;Q=g;R=Z;S=_;T=x;U=l;V=o}}while(0);l=U+1|0;if(l>>>0>=a>>>0)break;else{j=O;t=P;g=Q;A=R;p=S;x=T;o=V}}}f[b>>2]=v;if(!J){ba=H;ca=I}else{if((K|0)!=(J|0))f[z>>2]=K+(~((K+-4-J|0)>>>2)<<2);Oq(L);L=f[e>>2]|0;ba=L;ca=L}if(ba|0){L=f[w>>2]|0;if((L|0)!=(ba|0))f[w>>2]=L+(~((L+-8-ba|0)>>>3)<<3);Oq(ca)}ca=f[d>>2]|0;if(ca|0){d=f[q>>2]|0;if((d|0)!=(ca|0))f[q>>2]=d+(~((d+-4-ca|0)>>>2)<<2);Oq(ca)}h=1;u=c;return h|0}function sc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0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)==(K|0))){N=K;O=29;break a}L=J+8|0;if(((b[L>>0]|0)==A<<24>>24?(b[L+1>>0]|0)==B<<24>>24:0)?(b[L+2>>0]|0)==D<<24>>24:0)break a;J=f[J>>2]|0;if(!J){N=K;O=29;break a}}}else P=M;while(1){J=f[P+4>>2]|0;if((J|0)!=(E|0)){if(J>>>0>>0)Q=J;else Q=(J>>>0)%(F>>>0)|0;if((Q|0)!=(K|0)){N=K;O=29;break a}}J=P+8|0;if(((b[J>>0]|0)==A<<24>>24?(b[J+1>>0]|0)==B<<24>>24:0)?(b[J+2>>0]|0)==D<<24>>24:0)break a;P=f[P>>2]|0;if(!P){N=K;O=29;break}}}else{N=K;O=29}}else{N=0;O=29}while(0);if((O|0)==29){O=0;M=ln(16)|0;b[M+8>>0]=A;b[M+9>>0]=B;b[M+10>>0]=D;f[M+12>>2]=z;f[M+4>>2]=E;f[M>>2]=0;R=$(((f[t>>2]|0)+1|0)>>>0);S=$(F>>>0);T=$(n[k>>2]);do if(G|$(T*S)>>0<3|(F+-1&F|0)!=0)&1;H=~~$(W($(R/T)))>>>0;_h(g,J>>>0>>0?H:J);J=f[s>>2]|0;H=J+-1|0;if(!(H&J)){U=J;V=H&E;break}if(E>>>0>>0){U=J;V=E}else{U=J;V=(E>>>0)%(J>>>0)|0}}else{U=F;V=N}while(0);F=(f[g>>2]|0)+(V<<2)|0;E=f[F>>2]|0;if(!E){f[M>>2]=f[v>>2];f[v>>2]=M;f[F>>2]=v;F=f[M>>2]|0;if(F|0){G=f[F+4>>2]|0;F=U+-1|0;if(F&U)if(G>>>0>>0)X=G;else X=(G>>>0)%(U>>>0)|0;else X=G&F;Y=(f[g>>2]|0)+(X<<2)|0;O=42}}else{f[M>>2]=f[E>>2];Y=E;O=42}if((O|0)==42){O=0;f[Y>>2]=M}f[t>>2]=(f[t>>2]|0)+1}E=w;F=f[E>>2]|0;G=un(F|0,f[E+4>>2]|0,z|0,0)|0;kh((f[f[x>>2]>>2]|0)+G|0,h|0,F|0)|0;F=f[j>>2]|0;f[F+(y<<2)>>2]=z;Z=z+1|0;_=F}else{F=f[j>>2]|0;f[F+(y<<2)>>2]=f[C+12>>2];Z=z;_=F}y=y+1|0;aa=f[l>>2]|0;if(y>>>0>=aa>>>0)break;else z=Z}if((Z|0)==(aa|0))ba=_;else{z=a+84|0;if(!(b[z>>0]|0)){y=f[a+72>>2]|0;h=f[a+68>>2]|0;x=h;if((y|0)==(h|0))ca=_;else{w=y-h>>2;h=0;do{y=x+(h<<2)|0;f[y>>2]=f[_+(f[y>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);ca=_}}else{b[z>>0]=0;z=a+68|0;_=a+72|0;w=f[_>>2]|0;h=f[z>>2]|0;x=w-h>>2;y=h;h=w;if(aa>>>0<=x>>>0)if(aa>>>0>>0?(w=y+(aa<<2)|0,(w|0)!=(h|0)):0){f[_>>2]=h+(~((h+-4-w|0)>>>2)<<2);da=aa}else da=aa;else{Ch(z,aa-x|0,1220);da=f[l>>2]|0}x=f[j>>2]|0;if(!da)ca=x;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);ca=x}}f[l>>2]=Z;ba=ca}if(!ba)ea=Z;else{ca=f[o>>2]|0;if((ca|0)!=(ba|0))f[o>>2]=ca+(~((ca+-4-ba|0)>>>2)<<2);Oq(ba);ea=Z}}else ea=0;Z=f[g+8>>2]|0;if(Z|0){ba=Z;do{Z=ba;ba=f[ba>>2]|0;Oq(Z)}while((ba|0)!=0)}ba=f[g>>2]|0;f[g>>2]=0;if(!ba){u=e;return ea|0}Oq(ba);u=e;return ea|0}function tc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N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0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);N=K<<1;M=b+(N<<2)|0;H=M+4|0;O=f[H>>2]|0;f[h>>2]=f[M>>2];f[x>>2]=O;f[i>>2]=$;f[y>>2]=aa;Od(d,n,h,i);O=f[d>>2]|0;f[k>>2]=O;P=f[z>>2]|0;f[A>>2]=P;q=f[H>>2]|0;f[h>>2]=f[M>>2];f[B>>2]=q;f[i>>2]=da;f[C>>2]=ea;Od(d,n,h,i);q=f[d>>2]|0;f[l>>2]=q;M=f[D>>2]|0;f[E>>2]=M;H=f[v>>2]|0;if((H|0)>=(O|0))if((O|0)<(0-H|0))fa=(f[F>>2]|0)+O|0;else fa=O;else fa=O-(f[F>>2]|0)|0;f[k>>2]=fa;if((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)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%(G>>>0)|0;else L=F&J;M=f[(f[g>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}if(((f[K+8>>2]|0)==(A|0)?(f[K+12>>2]|0)==(D|0):0)?(f[K+16>>2]|0)==(E|0):0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}if(((f[Q+8>>2]|0)==(A|0)?(f[Q+12>>2]|0)==(D|0):0)?(f[Q+16>>2]|0)==(E|0):0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;C=ln(24)|0;f[C+8>>2]=A;f[C+12>>2]=D;f[C+16>>2]=E;f[C+20>>2]=y;f[C+4>>2]=F;f[C>>2]=0;S=$(((f[t>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[k>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;K=~~$(W($(S/U)))>>>0;Xh(g,N>>>0>>0?K:N);N=f[s>>2]|0;K=N+-1|0;if(!(K&N)){V=N;X=K&F;break}if(F>>>0>>0){V=N;X=F}else{V=N;X=(F>>>0)%(N>>>0)|0}}else{V=G;X=O}while(0);G=(f[g>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[C>>2]=f[v>>2];f[v>>2]=C;f[G>>2]=v;G=f[C>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[g>>2]|0)+(Y<<2)|0;P=42}}else{f[C>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=C}f[t>>2]=(f[t>>2]|0)+1}F=w;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,y|0,0)|0;kh((f[f[x>>2]>>2]|0)+H|0,h|0,G|0)|0;G=f[j>>2]|0;f[G+(z<<2)>>2]=y;_=y+1|0;aa=G}else{G=f[j>>2]|0;f[G+(z<<2)>>2]=f[B+20>>2];_=y;aa=G}z=z+1|0;ba=f[l>>2]|0;if(z>>>0>=ba>>>0)break;else y=_}if((_|0)==(ba|0))ca=aa;else{y=a+84|0;if(!(b[y>>0]|0)){z=f[a+72>>2]|0;h=f[a+68>>2]|0;x=h;if((z|0)==(h|0))da=aa;else{w=z-h>>2;h=0;do{z=x+(h<<2)|0;f[z>>2]=f[aa+(f[z>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);da=aa}}else{b[y>>0]=0;y=a+68|0;aa=a+72|0;w=f[aa>>2]|0;h=f[y>>2]|0;x=w-h>>2;z=h;h=w;if(ba>>>0<=x>>>0)if(ba>>>0>>0?(w=z+(ba<<2)|0,(w|0)!=(h|0)):0){f[aa>>2]=h+(~((h+-4-w|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(y,ba-x|0,1220);ea=f[l>>2]|0}x=f[j>>2]|0;if(!ea)da=x;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=x}}f[l>>2]=_;ca=da}if(!ca)fa=_;else{da=f[o>>2]|0;if((da|0)!=(ca|0))f[o>>2]=da+(~((da+-4-ca|0)>>>2)<<2);Oq(ca);fa=_}}else fa=0;_=f[g+8>>2]|0;if(_|0){ca=_;do{_=ca;ca=f[ca>>2]|0;Oq(_)}while((ca|0)!=0)}ca=f[g>>2]|0;f[g>>2]=0;if(!ca){u=e;return fa|0}Oq(ca);u=e;return fa|0} +function di(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Je(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function ei(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Bd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Bd(a,e);return}function fi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+48|0;g=e;h=e+32|0;if(!c){i=0;u=e;return i|0}Gn(g);if((dm(c,0)|0)!=-1?Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0:0){Va[f[(f[c>>2]|0)+20>>2]&127](c);ch(h,a,c,g);c=(f[h>>2]|0)==0;a=h+4|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);if(c){c=f[g>>2]|0;a=g+4|0;rg(d,c,c+((f[a>>2]|0)-c)|0);j=(f[a>>2]|0)-(f[g>>2]|0)|0}else j=0}else j=0;a=g+12|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0)Oq(c);c=f[g>>2]|0;if(c|0){a=g+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}i=j;u=e;return i|0}function gi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Fe(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function hi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{d=g+-4|0;f[c>>2]=d;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=h+88|0;i=f[d>>2]|0;f[d>>2]=0;if(i|0){d=f[i+8>>2]|0;if(d|0){j=i+12|0;if((f[j>>2]|0)!=(d|0))f[j>>2]=d;Oq(d)}Oq(i)}i=f[h+68>>2]|0;if(i|0){d=h+72|0;j=f[d>>2]|0;if((j|0)!=(i|0))f[d>>2]=j+(~((j+-4-i|0)>>>2)<<2);Oq(i)}i=h+64|0;j=f[i>>2]|0;f[i>>2]=0;if(j|0){i=f[j>>2]|0;if(i|0){d=j+4|0;if((f[d>>2]|0)!=(i|0))f[d>>2]=i;Oq(i)}Oq(j)}Oq(h)}g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function ii(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;if(!(Ie(a,c)|0)){i=0;u=d;return i|0}j=a+36|0;k=a+40|0;a=f[j>>2]|0;if((f[k>>2]|0)==(a|0)){i=1;u=d;return i|0}l=c+16|0;m=c+4|0;n=h+1|0;o=0;p=a;do{a=f[p+(o<<2)>>2]|0;q=Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0;b[h>>0]=q;q=l;a=f[q+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[q>>2]|0)>>>0>0)){f[g>>2]=f[m>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}o=o+1|0;p=f[j>>2]|0}while(o>>>0<(f[k>>2]|0)-p>>2>>>0);i=1;u=d;return i|0}function ji(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;e=a+24|0;lp(e);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=20;g=a;h=14538;i=g+20|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+20>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=22;g=a;h=14559;i=g+22|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+22>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)>=0){u=c;return}Oq(f[d>>2]|0);u=c;return}function ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{d=e+-4|0;f[c>>2]=d;g=f[d>>2]|0;f[d>>2]=0;if(g|0){d=g+88|0;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=f[h+8>>2]|0;if(d|0){i=h+12|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;Oq(d)}Oq(h)}h=f[g+68>>2]|0;if(h|0){d=g+72|0;i=f[d>>2]|0;if((i|0)!=(h|0))f[d>>2]=i+(~((i+-4-h|0)>>>2)<<2);Oq(h)}h=g+64|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0){h=f[i>>2]|0;if(h|0){d=i+4|0;if((f[d>>2]|0)!=(h|0))f[d>>2]=h;Oq(h)}Oq(i)}Oq(g)}e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;Oq(b);return}function li(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function mi(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c;e=ln(16)|0;f[d>>2]=e;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=e;h=14408;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[e+14>>0]=0;e=Hk(a,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);j=ln(16)|0;f[d>>2]=j;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=j;h=14423;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[j+14>>0]=0;j=Hk(a,d,-1)|0;if((b[d+11>>0]|0)>=0){k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}Oq(f[d>>2]|0);k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}function ni(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function oi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;h=g+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function pi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=a+32|0;ld(a,b);c=a+80|0;d=f[c>>2]|0;if((d|0?(e=a+84|0,(f[e>>2]|0)>0):0)?(ld(d,b),(f[e>>2]|0)>1):0){d=1;do{ld((f[c>>2]|0)+(d<<5)|0,b);d=d+1|0}while((d|0)<(f[e>>2]|0))}e=a+136|0;d=a+140|0;a=f[e>>2]|0;if((f[d>>2]|0)==(a|0))return;c=0;g=a;while(1){a=g;ci((f[a+(c*12|0)+4>>2]|0)-(f[a+(c*12|0)>>2]|0)>>2,b)|0;a=f[e>>2]|0;h=f[a+(c*12|0)>>2]|0;i=(f[a+(c*12|0)+4>>2]|0)-h>>2;if(!i)j=a;else{Mc(h,i,1,0,b)|0;j=f[e>>2]|0}c=c+1|0;if(c>>>0>=(((f[d>>2]|0)-j|0)/12|0)>>>0)break;else g=j}return}function qi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=d+16|0;g=f[e>>2]|0;if(!g)if(!(vl(d)|0)){h=f[e>>2]|0;i=5}else j=0;else{h=g;i=5}a:do if((i|0)==5){g=d+20|0;e=f[g>>2]|0;k=e;if((h-e|0)>>>0>>0){j=Sa[f[d+36>>2]&31](d,a,c)|0;break}b:do if((b[d+75>>0]|0)>-1){e=c;while(1){if(!e){l=0;m=a;n=c;o=k;break b}p=e+-1|0;if((b[a+p>>0]|0)==10)break;else e=p}p=Sa[f[d+36>>2]&31](d,a,e)|0;if(p>>>0>>0){j=p;break a}l=e;m=a+e|0;n=c-e|0;o=f[g>>2]|0}else{l=0;m=a;n=c;o=k}while(0);kh(o|0,m|0,n|0)|0;f[g>>2]=(f[g>>2]|0)+n;j=l+n|0}while(0);return j|0}function ri(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+12|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d+28>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;ri(c+8|0);Oq(c)}while((e|0)!=0)}e=d+20|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0)Oq(c);c=f[d+8>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;g=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;Oq(h)}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Oq(c)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(e|0)Oq(e);Oq(d)}if((b[a+11>>0]|0)>=0)return;Oq(f[a>>2]|0);return}function si(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0;g=u;u=u+32|0;h=g+12|0;i=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;if((e|0)>0){j=i+11|0;k=i+4|0;l=0;do{if((l|0)>0)An(h,14477)|0;il(i,$(n[d+(l<<2)>>2]));m=b[j>>0]|0;o=m<<24>>24<0;lj(h,o?f[i>>2]|0:i,o?f[k>>2]|0:m&255)|0;if((b[j>>0]|0)<0)Oq(f[i>>2]|0);l=l+1|0}while((l|0)<(e|0))}am(Ai(a,c)|0,h)|0;if((b[h+11>>0]|0)>=0){u=g;return}Oq(f[h>>2]|0);u=g;return}function ti(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){e=1;u=c;return e|0}g=a+4|0;h=a+20|0;i=a+24|0;j=a+16|0;a=0;while(1){k=f[(f[g>>2]|0)+4>>2]|0;l=dm(k,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;f[d>>2]=l;if((l|0)==-1)break;k=f[h>>2]|0;if((k|0)==(f[i>>2]|0))Ri(j,d);else{f[k>>2]=l;f[h>>2]=k+4}gl(f[g>>2]|0,f[d>>2]|0)|0;a=a+1|0;if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){e=1;m=9;break}}if((m|0)==9){u=c;return e|0}e=0;u=c;return e|0}function ui(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=1292;hi(a+60|0);b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=a+36|0;d=f[b>>2]|0;if(d|0){c=a+40|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-24|0;f[c>>2]=e;Va[f[f[e>>2]>>2]&127](e);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){b=a+20|0;d=f[b>>2]|0;if((d|0)!=(g|0))f[b>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function vi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+32|0;d=c+16|0;e=c+8|0;g=c;h=a+8|0;if(f[h>>2]<<5>>>0>=b>>>0){u=c;return}f[d>>2]=0;i=d+4|0;f[i>>2]=0;j=d+8|0;f[j>>2]=0;if((b|0)<0)aq(d);k=((b+-1|0)>>>5)+1|0;b=ln(k<<2)|0;f[d>>2]=b;f[i>>2]=0;f[j>>2]=k;k=f[a>>2]|0;f[e>>2]=k;f[e+4>>2]=0;b=a+4|0;l=f[b>>2]|0;f[g>>2]=k+(l>>>5<<2);f[g+4>>2]=l&31;zg(d,e,g);g=f[a>>2]|0;f[a>>2]=f[d>>2];f[d>>2]=g;d=f[b>>2]|0;f[b>>2]=f[i>>2];f[i>>2]=d;d=f[h>>2]|0;f[h>>2]=f[j>>2];f[j>>2]=d;if(g|0)Oq(g);u=c;return}function wi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+136|0;c=f[b>>2]|0;if(c|0){d=a+140|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=f[a+104>>2]|0;if(g|0){b=a+108|0;j=f[b>>2]|0;if((j|0)!=(g|0))f[b>>2]=j+(~((j+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+92>>2]|0;if(!g){uj(a);return}j=a+96|0;b=f[j>>2]|0;if((b|0)!=(g|0))f[j>>2]=b+(~((b+-4-g|0)>>>2)<<2);Oq(g);uj(a);return}function xi(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3680;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+316|0;e=a+264|0;g=e+52|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=-1;f[a+320>>2]=-1;f[a+324>>2]=0;f[a+328>>2]=2;f[a+332>>2]=7;f[a+336>>2]=0;f[a+340>>2]=0;f[a+344>>2]=0;b[a+352>>0]=0;return}function yi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=(e|0)/12|0;h=g+1|0;if(h>>>0>357913941)aq(a);i=a+8|0;j=((f[i>>2]|0)-d|0)/12|0;k=j<<1;l=j>>>0<178956970?(k>>>0>>0?h:k):357913941;do if(l)if(l>>>0>357913941){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{m=ln(l*12|0)|0;break}else m=0;while(0);k=m+(g*12|0)|0;f[k>>2]=f[b>>2];f[k+4>>2]=f[b+4>>2];f[k+8>>2]=f[b+8>>2];b=k+(((e|0)/-12|0)*12|0)|0;if((e|0)>0)kh(b|0,d|0,e|0)|0;f[a>>2]=b;f[c>>2]=k+12;f[i>>2]=m+(l*12|0);if(!d)return;Oq(d);return}function zi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=a+16|0;h=g;i=f[h+4>>2]|0;if((d|0)<0|(d|0)==0&c>>>0<1|((i|0)>0|(i|0)==0&(f[h>>2]|0)>>>0>0)){j=0;return j|0}b[a+24>>0]=e&1;h=Vn(c|0,d|0,7,0)|0;d=Ik(h|0,I|0,8,0)|0;h=I;c=g;f[c>>2]=d;f[c+4>>2]=h;c=a+4|0;g=f[c>>2]|0;i=f[a>>2]|0;k=g-i|0;l=Vn(k|0,0,8,0)|0;m=e?l:k;l=Vn(m|0,(e?I:0)|0,d|0,h|0)|0;h=i;i=g;if(k>>>0>=l>>>0)if(k>>>0>l>>>0?(g=h+l|0,(g|0)!=(i|0)):0){f[c>>2]=g;n=h}else n=h;else{Fi(a,l-k|0);n=f[a>>2]|0}k=ln(8)|0;f[k>>2]=n+m;f[k+4>>2]=0;m=a+12|0;a=f[m>>2]|0;f[m>>2]=k;if(!a){j=1;return j|0}Oq(a);j=1;return j|0}function Ai(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=u;u=u+16|0;d=c;e=yg(a,d,b)|0;g=f[e>>2]|0;if(g|0){h=g;i=h+28|0;u=c;return i|0}g=ln(40)|0;pj(g+16|0,b);b=g+28|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;b=f[d>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=b;f[e>>2]=g;b=f[f[a>>2]>>2]|0;if(!b)j=g;else{f[a>>2]=b;j=f[e>>2]|0}Oe(f[a+4>>2]|0,j);j=a+8|0;f[j>>2]=(f[j>>2]|0)+1;h=g;i=h+28|0;u=c;return i|0}function Bi(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=u;u=u+16|0;l=k;if((-18-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)m=f[a>>2]|0;else m=a;if(c>>>0<2147483623){n=d+c|0;d=c<<1;o=n>>>0>>0?d:n;p=o>>>0<11?11:o+16&-16}else p=-17;o=ln(p)|0;if(g|0)Fo(o,m,g)|0;if(i|0)Fo(o+g|0,j,i)|0;j=e-h|0;e=j-g|0;if(e|0)Fo(o+g+i|0,m+g+h|0,e)|0;if((c|0)!=10)Oq(m);f[a>>2]=o;f[a+8>>2]=p|-2147483648;p=j+i|0;f[a+4>>2]=p;b[l>>0]=0;up(o+p|0,l);u=k;return}function Ci(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;sj(d|0,0,b<<2|0)|0;if((i|0)>0)kh(n|0,h|0,i|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=m+(l<<2);if(!h)return;Oq(h);return}function Di(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;pj(g+8|0,e);h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function Ei(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=+d;l=j;j=i;while(1){if(j<<24>>24<0)m=f[c>>2]|0;else m=c;p[g>>3]=k;n=Bn(m,l+1|0,18562,g)|0;if((n|0)>-1)if(n>>>0>l>>>0)o=n;else break;else o=l<<1|1;Hj(c,o,0);l=o;j=b[h>>0]|0}Hj(c,n,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Fi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if((e-h|0)>>>0>=c>>>0){i=c;j=h;do{b[j>>0]=0;j=(f[g>>2]|0)+1|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=h-i|0;h=j+c|0;if((h|0)<0)aq(a);k=e-i|0;i=k<<1;e=k>>>0<1073741823?(i>>>0>>0?h:i):2147483647;if(!e)l=0;else l=ln(e)|0;i=l+j|0;j=l+e|0;e=c;c=i;l=i;do{b[l>>0]=0;l=c+1|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=(f[g>>2]|0)-e|0;h=i+(0-l)|0;if((l|0)>0)kh(h|0,e|0,l|0)|0;f[a>>2]=h;f[g>>2]=c;f[d>>2]=j;if(!e)return;Oq(e);return}function Gi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/136|0;h=d;if(g>>>0>>0){Ge(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b*136|0)|0;if((g|0)==(h|0))return;else i=h;do{f[c>>2]=i+-136;h=f[i+-20>>2]|0;if(h|0){b=i+-16|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);Oq(h)}h=f[i+-32>>2]|0;if(h|0){e=i+-28|0;b=f[e>>2]|0;if((b|0)!=(h|0))f[e>>2]=b+(~((b+-4-h|0)>>>2)<<2);Oq(h)}Mi(i+-132|0);i=f[c>>2]|0}while((i|0)!=(g|0));return}function Hi(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Sd(a,e);return}function Ii(a){a=a|0;var b=0,c=0,d=0;b=f[a+76>>2]|0;if(b|0){c=a+80|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){d=a+68|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+24>>2]|0;if(b|0){c=a+28|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0){d=a+16|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Ji(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=j;j=i;while(1){if(j<<24>>24<0)l=f[c>>2]|0;else l=c;f[g>>2]=d;m=Bn(l,k+1|0,18559,g)|0;if((m|0)>-1)if(m>>>0>k>>>0)n=m;else break;else n=k<<1|1;Hj(c,n,0);k=n;j=b[h>>0]|0}Hj(c,m,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;c=f[b>>2]|0;if((c|0)<0){d=0;return d|0}e=a+4|0;a=f[e>>2]|0;g=a+4|0;h=f[g>>2]|0;i=f[a>>2]|0;j=h-i>>2;k=i;i=h;if(c>>>0<=j>>>0)if(c>>>0>>0?(h=k+(c<<2)|0,(h|0)!=(i|0)):0){f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2);l=c}else l=c;else{Ci(a,c-j|0);l=f[b>>2]|0}if((l|0)<=0){d=1;return d|0}b=f[e>>2]|0;e=f[b>>2]|0;j=(f[b+4>>2]|0)-e>>2;c=e;e=0;while(1){if(j>>>0<=e>>>0){m=10;break}f[c+(e<<2)>>2]=e;e=e+1|0;if((e|0)>=(l|0)){d=1;m=12;break}}if((m|0)==10)aq(b);else if((m|0)==12)return d|0;return 0}function Li(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=ln(16)|0;f[g>>2]=h;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=h;j=14408;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+14>>0]=0;Xj(a,g,c);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);c=ln(16)|0;f[g>>2]=c;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=c;j=14423;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+14>>0]=0;Xj(a,g,d);if((b[g+11>>0]|0)>=0){u=e;return}Oq(f[g>>2]|0);u=e;return}function Mi(a){a=a|0;var b=0,c=0,d=0;b=f[a+84>>2]|0;if(b|0){c=a+88|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+72>>2]|0;if(b|0){d=a+76|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0){d=a+32|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0)Oq(b);b=f[a>>2]|0;if(!b)return;Oq(b);return}function Ni(a){a=a|0;var b=0,c=0,d=0,e=0;f[a>>2]=1352;b=a+32|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+88|0;d=f[b>>2]|0;f[b>>2]=0;if(d|0){b=f[d+8>>2]|0;if(b|0){e=d+12|0;if((f[e>>2]|0)!=(b|0))f[e>>2]=b;Oq(b)}Oq(d)}d=f[c+68>>2]|0;if(d|0){b=c+72|0;e=f[b>>2]|0;if((e|0)!=(d|0))f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2);Oq(d)}d=c+64|0;e=f[d>>2]|0;f[d>>2]=0;if(e|0){d=f[e>>2]|0;if(d|0){b=e+4|0;if((f[b>>2]|0)!=(d|0))f[b>>2]=d;Oq(d)}Oq(e)}Oq(c)}c=f[a+16>>2]|0;if(!c)return;e=a+20|0;a=f[e>>2]|0;if((a|0)!=(c|0))f[e>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Oi(){var a=0,b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+48|0;b=a+32|0;c=a+24|0;d=a+16|0;e=a;g=a+36|0;a=sn()|0;if(a|0?(h=f[a>>2]|0,h|0):0){a=h+48|0;i=f[a>>2]|0;j=f[a+4>>2]|0;if(!((i&-256|0)==1126902528&(j|0)==1129074247)){f[c>>2]=18701;Hn(18651,c)}if((i|0)==1126902529&(j|0)==1129074247)k=f[h+44>>2]|0;else k=h+80|0;f[g>>2]=k;k=f[h>>2]|0;h=f[k+4>>2]|0;if(Sa[f[(f[258]|0)+16>>2]&31](1032,k,g)|0){k=f[g>>2]|0;g=Qa[f[(f[k>>2]|0)+8>>2]&127](k)|0;f[e>>2]=18701;f[e+4>>2]=h;f[e+8>>2]=g;Hn(18565,e)}else{f[d>>2]=18701;f[d+4>>2]=h;Hn(18610,d)}}Hn(18689,b)}function Pi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;do if(a){if(c>>>0<128){b[a>>0]=c;e=1;break}d=(Jq()|0)+188|0;if(!(f[f[d>>2]>>2]|0))if((c&-128|0)==57216){b[a>>0]=c;e=1;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}if(c>>>0<2048){b[a>>0]=c>>>6|192;b[a+1>>0]=c&63|128;e=2;break}if(c>>>0<55296|(c&-8192|0)==57344){b[a>>0]=c>>>12|224;b[a+1>>0]=c>>>6&63|128;b[a+2>>0]=c&63|128;e=3;break}if((c+-65536|0)>>>0<1048576){b[a>>0]=c>>>18|240;b[a+1>>0]=c>>>12&63|128;b[a+2>>0]=c>>>6&63|128;b[a+3>>0]=c&63|128;e=4;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}}else e=1;while(0);return e|0}function Qi(a){a=a|0;var b=0,c=0,d=0;b=f[a+92>>2]|0;if(b|0){c=a+96|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0){d=a+80|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}f[a+4>>2]=3636;b=f[a+24>>2]|0;if(b|0)Oq(b);b=f[a+12>>2]|0;if(!b)return;Oq(b);return}function Ri(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=e>>2;h=g+1|0;if(h>>>0>1073741823)aq(a);i=a+8|0;j=(f[i>>2]|0)-d|0;k=j>>1;l=j>>2>>>0<536870911?(k>>>0>>0?h:k):1073741823;do if(l)if(l>>>0>1073741823){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{k=ln(l<<2)|0;m=k;n=k;break}else{m=0;n=0}while(0);k=m+(g<<2)|0;f[k>>2]=f[b>>2];if((e|0)>0)kh(n|0,d|0,e|0)|0;f[a>>2]=m;f[c>>2]=k+4;f[i>>2]=m+(l<<2);if(!d)return;Oq(d);return}function Si(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=a+104|0;d=f[c>>2]|0;if((d|0)!=0?(f[a+108>>2]|0)>=(d|0):0)e=4;else{d=Wm(a)|0;if((d|0)>=0){g=f[c>>2]|0;c=a+8|0;if(g){i=f[c>>2]|0;j=f[a+4>>2]|0;k=g-(f[a+108>>2]|0)|0;g=i;if((i-j|0)<(k|0)){l=g;m=g}else{l=j+(k+-1)|0;m=g}}else{g=f[c>>2]|0;l=g;m=g}f[a+100>>2]=l;l=a+4|0;if(!m)n=f[l>>2]|0;else{g=f[l>>2]|0;l=a+108|0;f[l>>2]=m+1-g+(f[l>>2]|0);n=g}g=n+-1|0;if((d|0)==(h[g>>0]|0|0))o=d;else{b[g>>0]=d;o=d}}else e=4}if((e|0)==4){f[a+100>>2]=0;o=-1}return o|0}function Ti(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=2384;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2440;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Ui(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=1964;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2020;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Vi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2440;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Wi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[(f[c+4>>2]|0)+4>>2]|0;if(!g){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=d;return}if(!(Dj(d+12|0,f[c+44>>2]|0,g)|0)){g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=26;c=g;h=15859;i=c+26|0;do{b[c>>0]=b[h>>0]|0;c=c+1|0;h=h+1|0}while((c|0)<(i|0));b[g+26>>0]=0;f[a>>2]=-1;pj(a+4|0,e);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0)}else{f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}u=d;return}function Xi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=b+48|0;if((mi(f[c>>2]|0)|0)>9){d=0;return d|0}if((Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)!=1){d=0;return d|0}e=b+4|0;b=(f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0)+56|0;a=f[b>>2]|0;do if((a|0)==3)if((mi(f[c>>2]|0)|0)<4){d=5;return d|0}else{g=f[b>>2]|0;break}else g=a;while(0);a=mi(f[c>>2]|0)|0;if((g|0)==1){d=(a|0)<4?6:0;return d|0}if((a|0)>7){d=0;return d|0}if((mi(f[c>>2]|0)|0)>1){d=1;return d|0}else return ((f[(f[e>>2]|0)+80>>2]|0)>>>0<40?1:4)|0;return 0}function Yi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2020;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Zi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=u;u=u+128|0;h=g+124|0;i=g;j=i;k=6596;l=j+124|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));if((c+-1|0)>>>0>2147483646)if(!c){m=h;n=1;o=4}else{h=Vq()|0;f[h>>2]=75;p=-1}else{m=a;n=c;o=4}if((o|0)==4){o=-2-m|0;c=n>>>0>o>>>0?o:n;f[i+48>>2]=c;n=i+20|0;f[n>>2]=m;f[i+44>>2]=m;o=m+c|0;m=i+16|0;f[m>>2]=o;f[i+28>>2]=o;o=Ah(i,d,e)|0;if(!c)p=o;else{c=f[n>>2]|0;b[c+(((c|0)==(f[m>>2]|0))<<31>>31)>>0]=0;p=o}}u=g;return p|0}function _i(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3480;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+264|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;b[d+24>>0]=0;return}function $i(a,c,d,e){a=a|0;c=c|0;d=d|0;e=+e;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;Zl(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function aj(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;$l(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function bj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+28>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;g=c+20|0;h=f[g>>2]|0;f[g>>2]=0;if(h|0){bj(h);Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=a+20|0;c=f[d>>2]|0;f[d>>2]=0;if(c|0)Oq(c);c=f[a+8>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){g=c+24|0;if((f[g>>2]|0)!=(h|0))f[g>>2]=h;Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=f[a>>2]|0;f[a>>2]=0;if(!d)return;Oq(d);return}function cj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;e=u;u=u+16|0;g=e;h=f[c+36>>2]|0;if(!h){i=ln(32)|0;f[g>>2]=i;f[g+8>>2]=-2147483616;f[g+4>>2]=23;j=i;k=15706;l=j+23|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+23>>0]=0;f[a>>2]=-1;pj(a+4|0,g);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);u=e;return}g=f[c+40>>2]|0;if(!g){Sc(a,c,h,d);u=e;return}else{bi(a,c,g,d);u=e;return}}function dj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;tk(a);b=a+84|0;c=f[b>>2]|0;if((c|0)<=0)return;d=c<<5;e=Lq(c>>>0>134217727|d>>>0>4294967291?-1:d+4|0)|0;f[e>>2]=c;d=e+4|0;e=d+(c<<5)|0;c=d;do{wn(c);c=c+32|0}while((c|0)!=(e|0));e=a+80|0;a=f[e>>2]|0;f[e>>2]=d;if(a|0){d=a+-4|0;c=f[d>>2]|0;if(c|0){g=a+(c<<5)|0;do{g=g+-32|0;Fj(g)}while((g|0)!=(a|0))}Mq(d)}if((f[b>>2]|0)>0)h=0;else return;do{tk((f[e>>2]|0)+(h<<5)|0);h=h+1|0}while((h|0)<(f[b>>2]|0));return}function ej(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!b){d=0;return d|0}if(f[b+4>>2]|0){d=0;return d|0}a=ln(52)|0;Ub(a,c);f[a+40>>2]=0;f[a+44>>2]=0;f[a+48>>2]=0;c=b+4|0;b=f[c>>2]|0;f[c>>2]=a;if(!b){d=1;return d|0}a=b+40|0;c=f[a>>2]|0;if(c|0){e=b+44|0;g=f[e>>2]|0;if((g|0)==(c|0))h=c;else{i=g;do{g=i+-4|0;f[e>>2]=g;j=f[g>>2]|0;f[g>>2]=0;if(j|0){bj(j);Oq(j)}i=f[e>>2]|0}while((i|0)!=(c|0));h=f[a>>2]|0}Oq(h)}bj(b);Oq(b);d=1;return d|0}function fj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;if(b){b=c+8|0;d=b;e=Vn(f[d>>2]|0,f[d+4>>2]|0,1,0)|0;d=b;f[d>>2]=e;f[d+4>>2]=I;d=a+28|0;e=f[d>>2]|0;b=a+24|0;f[b>>2]=f[b>>2]|1<>2]|0,f[e+4>>2]|0,1,0)|0;e=c;f[e>>2]=d;f[e+4>>2]=I;e=a+28|0;g=e;h=f[e>>2]|0}e=h+1|0;f[g>>2]=e;if((e|0)!=32)return;e=a+24|0;h=a+16|0;d=f[h>>2]|0;if((d|0)==(f[a+20>>2]|0))Ri(a+12|0,e);else{f[d>>2]=f[e>>2];f[h>>2]=d+4}f[g>>2]=0;f[e>>2]=0;return}function gj(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+32|0;a=f[b>>2]|0;f[b>>2]=0;b=f[c>>2]|0;f[c>>2]=a;if(!b)return;a=b+88|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0){a=f[c+8>>2]|0;if(a|0){d=c+12|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;Oq(a)}Oq(c)}c=f[b+68>>2]|0;if(c|0){a=b+72|0;d=f[a>>2]|0;if((d|0)!=(c|0))f[a>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=b+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){a=d+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}Oq(d)}Oq(b);return}function hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;if(c|0){h=a+11|0;i=b[h>>0]|0;if(i<<24>>24<0){j=f[a+4>>2]|0;k=(f[a+8>>2]&2147483647)+-1|0}else{j=i&255;k=10}if((k-j|0)>>>0>>0){xj(a,k,c-k+j|0,j,j,0,0);l=b[h>>0]|0}else l=i;if(l<<24>>24<0)m=f[a>>2]|0;else m=a;Qn(m+j|0,c,d)|0;d=j+c|0;if((b[h>>0]|0)<0)f[a+4>>2]=d;else b[h>>0]=d;b[g>>0]=0;up(m+d|0,g)}u=e;return a|0}function ij(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+48|0;e=d+4|0;g=d;h=f[b+12>>2]|0;i=f[b+4>>2]|0;b=e;j=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));zh(g,c,h,i,e);i=f[e+24>>2]|0;if(!i){k=f[g>>2]|0;f[a>>2]=k;u=d;return}h=e+28|0;e=f[h>>2]|0;if((e|0)!=(i|0))f[h>>2]=e+(~((e+-4-i|0)>>>2)<<2);Oq(i);k=f[g>>2]|0;f[a>>2]=k;u=d;return}function jj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=(f[a+8>>2]&2147483647)+-1|0;else k=10;do if(k>>>0>=d>>>0){if(j)l=f[a>>2]|0;else l=a;Eo(l,c,d)|0;b[g>>0]=0;up(l+d|0,g);if((b[h>>0]|0)<0){f[a+4>>2]=d;break}else{b[h>>0]=d;break}}else{if(j)m=f[a+4>>2]|0;else m=i&255;Bi(a,k,d-k|0,m,0,m,d,c)}while(0);u=e;return a|0}function kj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{f[c>>2]=g+-136;d=f[g+-20>>2]|0;if(d|0){h=g+-16|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d)}d=f[g+-32>>2]|0;if(d|0){i=g+-28|0;h=f[i>>2]|0;if((h|0)!=(d|0))f[i>>2]=h+(~((h+-4-d|0)>>>2)<<2);Oq(d)}Mi(g+-132|0);g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function lj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j){k=f[a+4>>2]|0;l=(f[a+8>>2]&2147483647)+-1|0}else{k=i&255;l=10}if((l-k|0)>>>0>=d>>>0){if(d|0){if(j)m=f[a>>2]|0;else m=a;Fo(m+k|0,c,d)|0;j=k+d|0;if((b[h>>0]|0)<0)f[a+4>>2]=j;else b[h>>0]=j;b[g>>0]=0;up(m+j|0,g)}}else Bi(a,l,d-l+k|0,k,k,0,d,c);u=e;return a|0}function mj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=3932;b=f[a+32>>2]|0;if(b|0){c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){d=a+24|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+8|0;c=f[b>>2]|0;if(!c)return;d=a+12|0;a=f[d>>2]|0;if((a|0)==(c|0))e=c;else{g=a;do{a=g+-4|0;f[d>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Va[f[(f[h>>2]|0)+4>>2]&127](h);g=f[d>>2]|0}while((g|0)!=(c|0));e=f[b>>2]|0}Oq(e);return}function nj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){d=1;return d|0}a=0;while(1){e=f[(f[c>>2]|0)+4>>2]|0;g=dm(e,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;if((g|0)==-1){d=0;h=6;break}e=f[(f[b>>2]|0)+28>>2]|0;i=fl(f[c>>2]|0,g)|0;a=a+1|0;if(!(Ra[e&127](b,i)|0)){d=0;h=6;break}if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){d=1;h=6;break}}if((h|0)==6)return d|0;return 0}function oj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!(ho(a,b,c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+52>>2]&127](a)|0)){d=0;return d|0}c=a+4|0;e=a+8|0;g=f[c>>2]|0;if((f[e>>2]|0)==(g|0)){d=1;return d|0}h=a+36|0;a=0;i=g;while(1){g=f[(f[h>>2]|0)+(a<<2)>>2]|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,b,f[i+(a<<2)>>2]|0)|0)){d=0;j=7;break}a=a+1|0;i=f[c>>2]|0;if(a>>>0>=(f[e>>2]|0)-i>>2>>>0){d=1;j=7;break}}if((j|0)==7)return d|0;return 0}function pj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;if((b[c+11>>0]|0)<0){g=f[c>>2]|0;h=f[c+4>>2]|0;if(h>>>0>4294967279)aq(a);if(h>>>0<11){b[a+11>>0]=h;i=a}else{j=h+16&-16;k=ln(j)|0;f[a>>2]=k;f[a+8>>2]=j|-2147483648;f[a+4>>2]=h;i=k}Fo(i,g,h)|0;b[e>>0]=0;up(i+h|0,e)}else{f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2]}u=d;return}function qj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;b[c+53>>0]=1;do if((f[c+4>>2]|0)==(e|0)){b[c+52>>0]=1;a=c+16|0;h=f[a>>2]|0;if(!h){f[a>>2]=d;f[c+24>>2]=g;f[c+36>>2]=1;if(!((g|0)==1?(f[c+48>>2]|0)==1:0))break;b[c+54>>0]=1;break}if((h|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;b[c+54>>0]=1;break}h=c+24|0;a=f[h>>2]|0;if((a|0)==2){f[h>>2]=g;i=g}else i=a;if((i|0)==1?(f[c+48>>2]|0)==1:0)b[c+54>>0]=1}while(0);return}function rj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)!=(e|0)){g=0;h=e;do{vg(h+(g*24|0)|0,b)|0;g=g+1|0;h=f[c>>2]|0}while(g>>>0<(((f[d>>2]|0)-h|0)/24|0)>>>0)}h=a+48|0;d=a+52|0;a=f[h>>2]|0;if((f[d>>2]|0)==(a|0))return 1;else{i=0;j=a}do{a=f[j+(i<<2)>>2]|0;ci(a<<1^a>>31,b)|0;i=i+1|0;j=f[h>>2]|0}while(i>>>0<(f[d>>2]|0)-j>>2>>>0);return 1}function sj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=e&-4|0;h=g-64|0;i=c|c<<8|c<<16|c<<24;while((a|0)<=(h|0)){f[a>>2]=i;f[a+4>>2]=i;f[a+8>>2]=i;f[a+12>>2]=i;f[a+16>>2]=i;f[a+20>>2]=i;f[a+24>>2]=i;f[a+28>>2]=i;f[a+32>>2]=i;f[a+36>>2]=i;f[a+40>>2]=i;f[a+44>>2]=i;f[a+48>>2]=i;f[a+52>>2]=i;f[a+56>>2]=i;f[a+60>>2]=i;a=a+64|0}while((a|0)<(g|0)){f[a>>2]=i;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function tj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(fp(a,f[c>>2]|0,g)|0){if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0)b[c+54>>0]=1;f[c+44>>2]=4;break}if((e|0)==1)f[c+32>>2]=1}}else Vm(0,c,d,e);while(0);return}function uj(a){a=a|0;var b=0,c=0,d=0,e=0;b=a+80|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+-4|0;d=f[b>>2]|0;if(d|0){e=c+(d<<5)|0;do{e=e+-32|0;Fj(e)}while((e|0)!=(c|0))}Mq(b)}b=f[a+68>>2]|0;if(b|0){c=a+72|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b)}b=a+44|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0)Oq(e);e=f[a+32>>2]|0;if(!e){Fj(a);return}b=a+36|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e);Fj(a);return}function vj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3092;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function wj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if((d|0)<0){e=0;return e|0}do if(!b){d=a+4|0;g=f[d>>2]|0;h=f[a>>2]|0;i=g-h|0;if(i>>>0>>0){Fi(a,c-i|0);break}if(i>>>0>c>>>0?(i=h+c|0,(i|0)!=(g|0)):0)f[d>>2]=i}else Cg(a,b,b+c|0);while(0);c=a+24|0;a=c;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=c;f[a>>2]=b;f[a+4>>2]=I;e=1;return e|0}function xj(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((-17-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)j=f[a>>2]|0;else j=a;if(c>>>0<2147483623){k=d+c|0;d=c<<1;l=k>>>0>>0?d:k;m=l>>>0<11?11:l+16&-16}else m=-17;l=ln(m)|0;if(g|0)Fo(l,j,g)|0;k=e-h-g|0;if(k|0)Fo(l+g+i|0,j+g+h|0,k)|0;if((c|0)!=10)Oq(j);f[a>>2]=l;f[a+8>>2]=m|-2147483648;return}function yj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2728;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function zj(a,b){a=a|0;b=b|0;if(!b)return;else{zj(a,f[b>>2]|0);zj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Aj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;Yf(a,b,c);c=f[a+100>>2]|0;d=f[a+96>>2]|0;a=d;if((c|0)==(d|0))return;e=f[b>>2]|0;b=(c-d|0)/12|0;d=0;do{c=a+(d*12|0)|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+4|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+8|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];d=d+1|0}while(d>>>0>>0);return}function Bj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=a+64|0;if((f[d>>2]|0)==0?(e=ln(32)|0,yn(e),g=f[d>>2]|0,f[d>>2]=e,g|0):0){e=f[g>>2]|0;if(e|0){h=g+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(g)}g=Vl(f[a+28>>2]|0)|0;e=X(g,b[a+24>>0]|0)|0;g=((e|0)<0)<<31>>31;h=f[d>>2]|0;i=un(e|0,g|0,c|0,0)|0;if(!(wj(h,0,i,I)|0)){j=0;return j|0}Kk(a,f[d>>2]|0,e,g,0,0);f[a+80>>2]=c;j=1;return j|0}function Cj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+64|0;e=d;if(!(fp(a,b,0)|0))if((b|0)!=0?(g=Eh(b,1056,1040,0)|0,(g|0)!=0):0){b=e+4|0;h=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(h|0));f[e>>2]=g;f[e+8>>2]=a;f[e+12>>2]=-1;f[e+48>>2]=1;Ya[f[(f[g>>2]|0)+28>>2]&3](g,e,f[c>>2]|0,1);if((f[e+24>>2]|0)==1){f[c>>2]=f[e+16>>2];i=1}else i=0;j=i}else j=0;else j=1;u=d;return j|0}function Dj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;if(!c){d=0;return d|0}e=c+40|0;g=c+44|0;ci((f[g>>2]|0)-(f[e>>2]|0)>>2,b)|0;h=f[e>>2]|0;e=f[g>>2]|0;if((h|0)!=(e|0)){g=h;do{h=f[g>>2]|0;if(h|0){ci(f[h+40>>2]|0,b)|0;lg(a,b,h)|0}g=g+4|0}while((g|0)!=(e|0))}lg(a,b,c)|0;d=1;return d|0}function Ej(a,c){a=a|0;c=c|0;var d=0;if(!c)return;Ej(a,f[c>>2]|0);Ej(a,f[c+4>>2]|0);a=c+16|0;d=c+28|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);Oq(c);return}function Fj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e+(~((e+-4-c|0)>>>2)<<2)|0;f[d>>2]=h;g=h}f[a+24>>2]=0;f[a+28>>2]=0;if(c|0){if((g|0)!=(c|0))f[d>>2]=g+(~((g+-4-c|0)>>>2)<<2);Oq(c)}c=f[a>>2]|0;if(!c){u=b;return}g=a+4|0;a=f[g>>2]|0;if((a|0)!=(c|0))f[g>>2]=a+(~((a+-8-c|0)>>>3)<<3);Oq(c);u=b;return}function Gj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;a:do if(!(c&3)){d=a;e=4}else{g=a;h=c;while(1){if(!(b[g>>0]|0)){i=h;break a}j=g+1|0;h=j;if(!(h&3)){d=j;e=4;break}else g=j}}while(0);if((e|0)==4){e=d;while(1){k=f[e>>2]|0;if(!((k&-2139062144^-2139062144)&k+-16843009))e=e+4|0;else break}if(!((k&255)<<24>>24))l=e;else{k=e;while(1){e=k+1|0;if(!(b[e>>0]|0)){l=e;break}else k=e}}i=l}return i-c|0}function Hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=f[a+4>>2]|0;else k=i&255;do if(k>>>0>=c>>>0)if(j){i=(f[a>>2]|0)+c|0;b[g>>0]=0;up(i,g);f[a+4>>2]=c;break}else{b[g>>0]=0;up(a+c|0,g);b[h>>0]=c;break}else hj(a,c-k|0,d)|0;while(0);u=e;return}function Ij(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}Oq(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;Oq(c)}Oq(d)}Oq(a);return}function Jj(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;f[a>>2]=d;if(d|0){m=d+16|0;n=f[m+4>>2]|0;o=a+8|0;f[o>>2]=f[m>>2];f[o+4>>2]=n;n=d+24|0;d=f[n+4>>2]|0;o=a+16|0;f[o>>2]=f[n>>2];f[o+4>>2]=d}b[a+24>>0]=e;f[a+28>>2]=g;b[a+32>>0]=h&1;h=a+40|0;f[h>>2]=i;f[h+4>>2]=j;j=a+48|0;f[j>>2]=k;f[j+4>>2]=l;f[a+56>>2]=c;return}function Kj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=ln(88)|0;d=c+60|0;e=c;g=e+60|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=c;d=c+64|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;d=cg(c,b)|0;f[a>>2]=d?c:0;a=d?0:c;if(d)return;Ii(a);Oq(a);return}function Lj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;if((f[c+76>>2]|0)>=0?(Tq(c)|0)!=0:0){d=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(g=c+20|0,h=f[g>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[g>>2]=h+1;b[h>>0]=d;i=e}else i=Nj(c,a)|0;Sq(c);j=i}else k=3;do if((k|0)==3){i=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(d=c+20|0,h=f[d>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[d>>2]=h+1;b[h>>0]=i;j=e;break}j=Nj(c,a)|0}while(0);return j|0}function Mj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=f[a+4>>2]|0;if((i|0)==-1){j=0;u=d;return j|0}b[h>>0]=i;i=c+16|0;a=f[i+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[i>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}j=1;u=d;return j|0}function Nj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+16|0;e=d;g=c&255;b[e>>0]=g;i=a+16|0;j=f[i>>2]|0;if(!j)if(!(vl(a)|0)){k=f[i>>2]|0;l=4}else m=-1;else{k=j;l=4}do if((l|0)==4){j=a+20|0;i=f[j>>2]|0;if(i>>>0>>0?(n=c&255,(n|0)!=(b[a+75>>0]|0)):0){f[j>>2]=i+1;b[i>>0]=g;m=n;break}if((Sa[f[a+36>>2]&31](a,e,1)|0)==1)m=h[e>>0]|0;else m=-1}while(0);u=d;return m|0}function Oj(a,b){a=a|0;b=b|0;if(!b)return;else{Oj(a,f[b>>2]|0);Oj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Pj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=e+4|0;f[g>>2]=c;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=17;i=c;j=14495;k=i+17|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+17>>0]=0;Xj(Hd(a,g)|0,h,d);if((b[h+11>>0]|0)>=0){u=e;return}Oq(f[h>>2]|0);u=e;return}function Qj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=a+48|0;if((f[a+52>>2]|0)>>>0<=e>>>0)Ce(b,e+1|0,0);c=(f[b>>2]|0)+(e>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(e&31);c=f[a+36>>2]|0;if((f[a+40>>2]|0)-c>>2>>>0<=e>>>0){d=1;return d|0}Bp(f[c+(e<<2)>>2]|0);d=1;return d|0}function Rj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if(c>>>0>0|(c|0)==0&a>>>0>4294967295){e=d;f=a;g=c;while(1){c=hn(f|0,g|0,10,0)|0;e=e+-1|0;b[e>>0]=c&255|48;c=f;f=jp(f|0,g|0,10,0)|0;if(!(g>>>0>9|(g|0)==9&c>>>0>4294967295))break;else g=I}h=f;i=e}else{h=a;i=d}if(!h)j=i;else{d=h;h=i;while(1){i=h+-1|0;b[i>>0]=(d>>>0)%10|0|48;if(d>>>0<10){j=i;break}else{d=(d>>>0)/10|0;h=i}}}return j|0}function Sj(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=a;while(1){d=c+1|0;if(!(eq(b[c>>0]|0)|0))break;else c=d}a=b[c>>0]|0;switch(a<<24>>24|0){case 45:{e=1;f=5;break}case 43:{e=0;f=5;break}default:{g=0;h=c;i=a}}if((f|0)==5){g=e;h=d;i=b[d>>0]|0}if(!(Aq(i<<24>>24)|0))j=0;else{i=0;d=h;while(1){h=(i*10|0)+48-(b[d>>0]|0)|0;d=d+1|0;if(!(Aq(b[d>>0]|0)|0)){j=h;break}else i=h}}return (g|0?j:0-j|0)|0}function Tj(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0;e=u;u=u+16|0;g=e;il(g,d);h=Ai(a,c)|0;c=h+11|0;if((b[c>>0]|0)<0){b[f[h>>2]>>0]=0;f[h+4>>2]=0}else{b[h>>0]=0;b[c>>0]=0}gh(h,0);f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];u=e;return}function Uj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b+8|0;d=b+4|0;e=b;f[e>>2]=f[(f[a+4>>2]|0)+80>>2];g=f[a+44>>2]|0;a=g+16|0;h=f[a+4>>2]|0;if((h|0)>0|(h|0)==0&(f[a>>2]|0)>>>0>0){u=b;return 1}f[d>>2]=f[g+4>>2];f[c>>2]=f[d>>2];Me(g,c,e,e+4|0)|0;u=b;return 1}function Vj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d&1);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Wj(a){a=a|0;if(!a)return;Ej(a+24|0,f[a+28>>2]|0);zj(a+12|0,f[a+16>>2]|0);Ej(a,f[a+4>>2]|0);Oq(a);return}function Xj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Yj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=-1;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}a=e+28|0;if((b[a+11>>0]|0)<0)k=f[a>>2]|0;else k=a;g=Sj(k)|0;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}function Zj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(c>>>0>10){g=0;u=d;return g|0}h=ln(48)|0;f[e>>2]=h;f[e+8>>2]=-2147483600;f[e+4>>2]=33;i=h;j=15987;k=i+33|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+33>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);g=1;u=d;return g|0}function _j(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[b>>2]|0;if((c|0)==-1)return 1;b=c*3|0;if((b|0)==-1)return 1;c=f[a>>2]|0;a=f[c+(b<<2)>>2]|0;d=b+1|0;e=((d>>>0)%3|0|0)==0?b+-2|0:d;if((e|0)==-1)g=-1;else g=f[c+(e<<2)>>2]|0;e=(((b>>>0)%3|0|0)==0?2:-1)+b|0;if((e|0)==-1)h=-1;else h=f[c+(e<<2)>>2]|0;if((a|0)==(g|0))return 1;else return (a|0)==(h|0)|(g|0)==(h|0)|0;return 0}function $j(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=0;while(1){if((h[16654+d>>0]|0)==(a|0)){e=2;break}g=d+1|0;if((g|0)==87){i=16742;j=87;e=5;break}else d=g}if((e|0)==2)if(!d)k=16742;else{i=16742;j=d;e=5}if((e|0)==5)while(1){e=0;d=i;do{a=d;d=d+1|0}while((b[a>>0]|0)!=0);j=j+-1|0;if(!j){k=d;break}else{i=d;e=5}}return jq(k,f[c+20>>2]|0)|0}function ak(a,b){a=+a;b=b|0;var c=0,d=0,e=0,g=0.0,h=0.0,i=0,j=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;e=Yn(c|0,d|0,52)|0;switch(e&2047){case 0:{if(a!=0.0){g=+ak(a*18446744073709551616.0,b);h=g;i=(f[b>>2]|0)+-64|0}else{h=a;i=0}f[b>>2]=i;j=h;break}case 2047:{j=a;break}default:{f[b>>2]=(e&2047)+-1022;f[s>>2]=c;f[s+4>>2]=d&-2146435073|1071644672;j=+p[s>>3]}}return +j}function bk(a,b){a=+a;b=b|0;var c=0.0,d=0,e=0,g=0.0,h=0;if((b|0)<=1023)if((b|0)<-1022){c=a*2.2250738585072014e-308;d=(b|0)<-2044;e=b+2044|0;g=d?c*2.2250738585072014e-308:c;h=d?((e|0)>-1022?e:-1022):b+1022|0}else{g=a;h=b}else{c=a*8988465674311579538646525.0e283;e=(b|0)>2046;d=b+-2046|0;g=e?c*8988465674311579538646525.0e283:c;h=e?((d|0)<1023?d:1023):b+-1023|0}b=Tn(h+1023|0,0,52)|0;h=I;f[s>>2]=b;f[s+4>>2]=h;return +(g*+p[s>>3])}function ck(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;if(!(f[a+80>>2]|0)){b=0;return b|0}c=a+8|0;d=a+12|0;a=f[c>>2]|0;if(((f[d>>2]|0)-a|0)>0){e=0;g=a}else{b=1;return b|0}while(1){a=f[g+(e<<2)>>2]|0;e=e+1|0;if(!(Gl(a,a)|0)){b=0;h=5;break}g=f[c>>2]|0;if((e|0)>=((f[d>>2]|0)-g>>2|0)){b=1;h=5;break}}if((h|0)==5)return b|0;return 0}function dk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)==(e|0)){g=1;return g|0}h=a+60|0;a=0;i=e;while(1){e=f[i+(a<<2)>>2]|0;a=a+1|0;if(!(Sa[f[(f[e>>2]|0)+20>>2]&31](e,h,b)|0)){g=0;j=5;break}i=f[c>>2]|0;if(a>>>0>=(f[d>>2]|0)-i>>2>>>0){g=1;j=5;break}}if((j|0)==5)return g|0;return 0}function ek(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+36|0;d=a+40|0;a=f[c>>2]|0;if((f[d>>2]|0)==(a|0)){e=1;return e|0}else{g=0;h=a}while(1){a=f[h+(g<<2)>>2]|0;g=g+1|0;if(!(Ra[f[(f[a>>2]|0)+24>>2]&127](a,b)|0)){e=0;i=4;break}h=f[c>>2]|0;if(g>>>0>=(f[d>>2]|0)-h>>2>>>0){e=1;i=4;break}}if((i|0)==4)return e|0;return 0}function fk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=e>>2;if(!g)return;if(g>>>0>1073741823)aq(a);h=ln(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g<<2);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;kh(h|0,g|0,b|0)|0;f[c>>2]=h+(b>>>2<<2);return}function gk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=a+8|0;d=f[a>>2]|0;if((f[c>>2]|0)-d>>2>>>0>=b>>>0)return;e=a+4|0;if(b>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=(f[e>>2]|0)-d|0;h=ln(b<<2)|0;if((g|0)>0)kh(h|0,d|0,g|0)|0;f[a>>2]=h;f[e>>2]=h+(g>>2<<2);f[c>>2]=h+(b<<2);if(!d)return;Oq(d);return}function hk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=a+36|0;c=a+40|0;d=f[b>>2]|0;if((f[c>>2]|0)==(d|0)){e=1;return e|0}g=a+60|0;a=0;h=d;while(1){d=f[h+(a<<2)>>2]|0;a=a+1|0;if(!(Ra[f[(f[d>>2]|0)+16>>2]&127](d,g)|0)){e=0;i=5;break}h=f[b>>2]|0;if(a>>>0>=(f[c>>2]|0)-h>>2>>>0){e=1;i=5;break}}if((i|0)==5)return e|0;return 0}function ik(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=f[a+176>>2]|0;e=f[a+172>>2]|0;a=e;if((d|0)==(e|0))return 0;g=(d-e|0)/136|0;e=0;while(1){if((f[a+(e*136|0)>>2]|0)==(c|0)){h=4;break}d=e+1|0;if(d>>>0>>0)e=d;else{h=6;break}}if((h|0)==4)return ((b[a+(e*136|0)+100>>0]|0)==0?0:a+(e*136|0)+4|0)|0;else if((h|0)==6)return 0;return 0}function jk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;g=ln(16)|0;f[e>>2]=g;f[e+8>>2]=-2147483632;f[e+4>>2]=15;h=g;i=14479;j=h+15|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+15>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)>=0){u=d;return}Oq(f[e>>2]|0);u=d;return}function kk(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[a+72>>2]|0;if(!c){d=0;return d|0}f[c+4>>2]=a+60;if(!(Qa[f[(f[c>>2]|0)+12>>2]&127](c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){d=0;return d|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){d=0;return d|0}d=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return d|0}function lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;f[a>>2]=0;d=a+4|0;f[d>>2]=0;f[a+8>>2]=0;if(!b)return;if(b>>>0>357913941)aq(a);e=ln(b*12|0)|0;f[d>>2]=e;f[a>>2]=e;f[a+8>>2]=e+(b*12|0);a=b;b=e;do{fk(b,c);b=(f[d>>2]|0)+12|0;f[d>>2]=b;a=a+-1|0}while((a|0)!=0);return}function mk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=f[b>>2]|0;if(!c){d=0;return d|0}e=a+44|0;g=f[e>>2]|0;if(g>>>0<(f[a+48>>2]|0)>>>0){f[b>>2]=0;f[g>>2]=c;f[e>>2]=(f[e>>2]|0)+4;d=1;return d|0}else{Ug(a+40|0,b);d=1;return d|0}return 0}function nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function ok(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);Oq(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);Oq(a);return}function pk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;f[c>>2]=2;d=a+4|0;a=c+8|0;e=f[a>>2]|0;g=(f[c+12>>2]|0)-e|0;if(g>>>0<4294967292){Lk(a,g+4|0,0);i=f[a>>2]|0}else i=e;e=i+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[e>>0]=g;b[e+1>>0]=g>>8;b[e+2>>0]=g>>16;b[e+3>>0]=g>>24;return}function qk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function sk(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=Oa,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return $(g)}a=e+28|0;if((b[a+11>>0]|0)<0)h=f[a>>2]|0;else h=a;g=$(+Iq(h));return $(g)}function tk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0)){g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}f[d>>2]=e+(~((e+-4-c|0)>>>2)<<2);g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}function uk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=f[a+176>>2]|0;d=f[a+172>>2]|0;e=d;a:do if((c|0)!=(d|0)){g=(c-d|0)/136|0;h=0;while(1){if((f[e+(h*136|0)>>2]|0)==(b|0))break;i=h+1|0;if(i>>>0>>0)h=i;else break a}j=e+(h*136|0)+104|0;return j|0}while(0);j=a+40|0;return j|0}function vk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function wk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function xk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);return}function yk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;Nc(a,b);if((b|0)<=-1)return;c=a+88|0;d=f[c>>2]|0;e=f[a+84>>2]|0;if((d-e>>2|0)<=(b|0))return;a=e+(b<<2)|0;b=a+4|0;e=d-b|0;g=e>>2;if(!g)h=d;else{im(a|0,b|0,e|0)|0;h=f[c>>2]|0}e=a+(g<<2)|0;if((h|0)==(e|0))return;f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);return}function zk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a+32>>2]|0;c=f[a+36>>2]|0;if((b|0)==(c|0)){d=1;return d|0}e=a+8|0;g=a+44|0;a=b;while(1){b=f[(f[e>>2]|0)+(f[a>>2]<<2)>>2]|0;a=a+4|0;if(!(Ra[f[(f[b>>2]|0)+20>>2]&127](b,f[g>>2]|0)|0)){d=0;h=5;break}if((a|0)==(c|0)){d=1;h=5;break}}if((h|0)==5)return d|0;return 0}function Ak(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function Bk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;d=u;u=u+128|0;e=d;g=e;h=g+124|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(h|0));g=e+4|0;f[g>>2]=a;h=e+8|0;f[h>>2]=-1;f[e+44>>2]=a;f[e+76>>2]=-1;Ym(e,0);i=+Rc(e,c,1);c=(f[g>>2]|0)-(f[h>>2]|0)+(f[e+108>>2]|0)|0;if(b|0)f[b>>2]=c|0?a+c|0:a;u=d;return +i}function Ck(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0;a=c+16|0;g=f[a>>2]|0;do if(g){if((g|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;f[c+24>>2]=2;b[c+54>>0]=1;break}h=c+24|0;if((f[h>>2]|0)==2)f[h>>2]=e}else{f[a>>2]=d;f[c+24>>2]=e;f[c+36>>2]=1}while(0);return}function Dk(a){a=a|0;var b=0,c=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Ek(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=a+20|0;c=a+28|0;if((f[d>>2]|0)>>>0>(f[c>>2]|0)>>>0)Sa[f[a+36>>2]&31](a,0,0)|0;f[a+16>>2]=0;f[c>>2]=0;f[d>>2]=0;d=f[a>>2]|0;if(!(d&4)){c=(f[a+44>>2]|0)+(f[a+48>>2]|0)|0;f[a+8>>2]=c;f[a+4>>2]=c;e=d<<27>>31}else{f[a>>2]=d|32;e=-1}return e|0}function Fk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=0;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=((Sj(g)|0)+1|0)>>>0>1;return e|0}function Gk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);Oq(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);Oq(a);return}function Hk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return g|0}d=e+28|0;if((b[d+11>>0]|0)<0)h=f[d>>2]|0;else h=d;g=Sj(h)|0;return g|0}function Ik(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;g=d>>31|((d|0)<0?-1:0)<<1;h=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;i=Xn(e^a|0,f^b|0,e|0,f|0)|0;b=I;a=g^e;e=h^f;return Xn((Ld(i,b,Xn(g^c|0,h^d|0,g|0,h|0)|0,I,0)|0)^a|0,I^e|0,a|0,e|0)|0}function Jk(a){a=a|0;var b=0,c=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Kk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;f[a>>2]=b;h=b+16|0;i=f[h+4>>2]|0;j=a+8|0;f[j>>2]=f[h>>2];f[j+4>>2]=i;i=b+24|0;b=f[i+4>>2]|0;j=a+16|0;f[j>>2]=f[i>>2];f[j+4>>2]=b;b=a+40|0;f[b>>2]=c;f[b+4>>2]=d;d=a+48|0;f[d>>2]=e;f[d+4>>2]=g;return}function Lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;h=e;e=d;if(g>>>0>=b>>>0){if(g>>>0>b>>>0?(d=h+b|0,(d|0)!=(e|0)):0)f[c>>2]=d}else Fi(a,b-g|0);g=a+24|0;a=g;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=g;f[a>>2]=b;f[a+4>>2]=I;return}function Mk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=-1;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=Sj(g)|0;return e|0}function Nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);return}function Ok(a){a=a|0;var c=0,d=0,e=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=1;c=a+68|0;d=a+28|0;e=d+40|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(e|0));f[c>>2]=a;c=a+72|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;return}function Pk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Qk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=u;u=u+256|0;g=f;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;sj(g|0,b<<24>>24|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;d=e;do{Xo(a,g,256);d=d+-256|0}while(d>>>0>255);h=b&255}else h=e;Xo(a,g,h)}u=f;return}function Rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Sk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);else{h=f[a+8>>2]|0;_a[f[(f[h>>2]|0)+20>>2]&3](h,b,c,d,e,g)}return}function Tk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Uk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Vk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;a:do if(!d)e=0;else{f=a;g=d;h=c;while(1){i=b[f>>0]|0;j=b[h>>0]|0;if(i<<24>>24!=j<<24>>24)break;g=g+-1|0;if(!g){e=0;break a}else{f=f+1|0;h=h+1|0}}e=(i&255)-(j&255)|0}while(0);return e|0}function Wk(a){a=a|0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function Xk(a){a=a|0;var b=0,c=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Yk(a){a=a|0;var c=0,d=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;c=0;while(1){if((c|0)==3)break;f[a+(c<<2)>>2]=0;c=c+1|0}if((b[a+11>>0]|0)<0)d=(f[a+8>>2]&2147483647)+-1|0;else d=10;Hj(a,d,0);return}function Zk(a){a=a|0;var b=0,c=0,d=0,e=0.0,g=0.0;b=f[a+8>>2]|0;if((b|0)<2){c=0;d=0;I=c;return d|0}e=+(b|0);g=+Zg(e)*e;e=+W(+(g-+p[a>>3]));c=+K(e)>=1.0?(e>0.0?~~+Y(+J(e/4294967296.0),4294967295.0)>>>0:~~+W((e-+(~~e>>>0))/4294967296.0)>>>0):0;d=~~e>>>0;I=c;return d|0}function _k(a){a=a|0;var b=0,c=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function $k(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;e=f[b+32>>2]|0;if(e|0){d=e;return d|0}d=f[b+8>>2]|0;return d|0}function al(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1232;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+4>>2]|0;if(!b)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(b|0))f[d>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function bl(a){a=a|0;var b=0,c=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function cl(a){a=a|0;if(!(f[a+64>>2]|0))return 0;if(!(f[a+68>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function dl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);else{e=f[a+8>>2]|0;Ya[f[(f[e>>2]|0)+28>>2]&3](e,b,c,d)}return}function el(a){a=a|0;var b=0,c=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function fl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+36>>2]&127](d,b)|0;return c|0}function gl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+32>>2]&127](d,b)|0;return c|0}function hl(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0;d=b[a>>0]|0;e=b[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24){f=e;g=d}else{d=c;c=a;do{c=c+1|0;d=d+1|0;a=b[c>>0]|0;e=b[d>>0]|0}while(!(a<<24>>24==0?1:a<<24>>24!=e<<24>>24));f=e;g=a}return (g&255)-(f&255)|0}function il(a,b){a=a|0;b=$(b);var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ei(a,d,b);Bo(d);u=c;return}function jl(a){a=a|0;var b=0,c=0,d=0,e=0,g=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d+(~((d+-4-b|0)>>>2)<<2)|0;f[c>>2]=g;e=g}f[a+12>>2]=0;f[a+16>>2]=0;if(!b)return;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b);return}function kl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=f[a+16>>2]|0;if(((f[a+20>>2]|0)-d>>2|0)<=(b|0)){e=-1;return e|0}g=f[d+(b<<2)>>2]|0;if((g|0)<0){e=-1;return e|0}e=f[(f[(f[(f[a+36>>2]|0)+(g<<2)>>2]|0)+16>>2]|0)+(c<<2)>>2]|0;return e|0}function ll(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ji(a,d,b);Bo(d);u=c;return}function ml(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;d=u;u=u+32|0;e=d;g=d+20|0;f[e>>2]=f[a+60>>2];f[e+4>>2]=0;f[e+8>>2]=b;f[e+12>>2]=g;f[e+16>>2]=c;if((to(za(140,e|0)|0)|0)<0){f[g>>2]=-1;h=-1}else h=f[g>>2]|0;u=d;return h|0}function nl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=0;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=0;return c|0}b=f[d>>2]|0;if((b|0)==-1){c=0;return c|0}c=f[(f[a+8>>2]|0)+(b<<2)>>2]|0;return c|0}function ol(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;d=(f[b+20>>2]|0)-(f[b+16>>2]|0)>>2;return d|0}function pl(a){a=a|0;if(!(f[a+40>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function ql(a){a=a|0;var b=0;if(!(f[a+24>>2]|0)){b=0;return b|0}if(!(f[a+28>>2]|0)){b=0;return b|0}if(!(f[a+32>>2]|0)){b=0;return b|0}b=(f[a+36>>2]|0)!=0;return b|0}function rl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;lh(a,c);f[a>>2]=1408;c=a+72|0;d=a+36|0;a=d+36|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(a|0));d=f[b>>2]|0;f[b>>2]=0;f[c>>2]=d;return}function sl(a){a=a|0;var b=0,c=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function tl(a,c){a=a|0;c=c|0;var d=0,e=0;d=a;e=c;c=d+64|0;do{f[d>>2]=f[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(c|0));e=a+64|0;f[a+88>>2]=0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[e+12>>2]=0;f[e+16>>2]=0;b[e+20>>0]=0;return}function ul(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if((a|0)==0&(c|0)==0)f=d;else{g=d;d=c;c=a;while(1){a=g+-1|0;b[a>>0]=h[16636+(c&15)>>0]|0|e;c=Yn(c|0,d|0,4)|0;d=I;if((c|0)==0&(d|0)==0){f=a;break}else g=a}}return f|0}function vl(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=f[a>>2]|0;if(!(d&8)){f[a+8>>2]=0;f[a+4>>2]=0;c=f[a+44>>2]|0;f[a+28>>2]=c;f[a+20>>2]=c;f[a+16>>2]=c+(f[a+48>>2]|0);e=0}else{f[a>>2]=d|32;e=-1}return e|0}function wl(a){a=a|0;if(!(f[a+60>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function xl(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[b+88>>2]|0;if(!c){d=0;return d|0}if((f[c>>2]|0)!=2){d=0;return d|0}b=f[c+8>>2]|0;f[a+4>>2]=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;d=1;return d|0}function yl(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}b=(f[a+56>>2]|0)!=0;return b|0}function zl(a){a=a|0;vj(a);Oq(a);return}function Al(a){a=a|0;var b=0,c=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function Bl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+44>>2]=c;d=1;return d|0}function Cl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;if(g>>>0>>0){Fi(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+b|0;if((g|0)==(d|0))return;f[c>>2]=g;return}function Dl(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=$(e);f[a+4>>2]=b;Zf(a+8|0,c,c+(d<<2)|0);n[a+20>>2]=e;return}function El(a,b){a=a|0;b=b|0;var c=0;if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){c=0;return c|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){c=0;return c|0}c=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return c|0}function Fl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+40>>2]=c;d=1;return d|0}function Gl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=u;u=u+16|0;d=c+4|0;e=c;f[e>>2]=0;f[d>>2]=f[e>>2];e=vc(a,b,d)|0;u=c;return e|0}function Hl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;d=f[c>>2]|0;c=a;e=b-a>>2;while(1){if(!e)break;a=(e|0)/2|0;b=c+(a<<2)|0;g=(f[b>>2]|0)>>>0>>0;c=g?b+4|0:c;e=g?e+-1-a|0:a}return c|0}function Il(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;b[a+24>>0]=1;f[a+28>>2]=9;c=a+40|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[a+56>>2]=-1;f[a+60>>2]=0;return}function Jl(a){a=a|0;yj(a);Oq(a);return}function Kl(a){a=a|0;var b=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Ll(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;if(!(Aq(b[f[a>>2]>>0]|0)|0))c=0;else{d=0;while(1){e=f[a>>2]|0;g=(d*10|0)+-48+(b[e>>0]|0)|0;h=e+1|0;f[a>>2]=h;if(!(Aq(b[h>>0]|0)|0)){c=g;break}else d=g}}return c|0}function Ml(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+64>>2]=c;d=1;return d|0}function Nl(a){a=a|0;var b=0,c=0;b=f[r>>2]|0;c=b+a|0;if((a|0)>0&(c|0)<(b|0)|(c|0)<0){ea()|0;ya(12);return -1}f[r>>2]=c;if((c|0)>(da()|0)?(ca()|0)==0:0){f[r>>2]=b;ya(12);return -1}return b|0}function Ol(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;if((a|0)==0&(c|0)==0)e=d;else{f=d;d=c;c=a;while(1){a=f+-1|0;b[a>>0]=c&7|48;c=Yn(c|0,d|0,3)|0;d=I;if((c|0)==0&(d|0)==0){e=a;break}else f=a}}return e|0}function Pl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+60>>2]=c;d=1;return d|0}function Ql(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Rl(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);return}function Sl(a){a=a|0;var b=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Tl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+56>>2]|0)-(f[e+52>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Ul(a){a=a|0;Vi(a);Oq(a);return}function Vl(a){a=a|0;var b=0;switch(a|0){case 11:case 2:case 1:{b=1;break}case 4:case 3:{b=2;break}case 6:case 5:{b=4;break}case 8:case 7:{b=8;break}case 9:{b=4;break}case 10:{b=8;break}default:b=-1}return b|0}function Wl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+28>>2]|0)-(f[e+24>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Xl(){var a=0,b=0;a=ln(40)|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[a+16>>2]=$(1.0);b=a+20|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;n[a+36>>2]=$(1.0);return a|0}function Yl(a,b){a=+a;b=+b;var c=0,d=0,e=0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s+4>>2]&-2147483648|d&2147483647;f[s>>2]=c;f[s+4>>2]=e;return +(+p[s>>3])}function Zl(a,b,c){a=a|0;b=b|0;c=+c;var d=0,e=0;d=u;u=u+16|0;e=d;p[e>>3]=c;_b(a,b,e);u=d;return}function _l(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);Oq(a);return}function $l(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;f[e>>2]=c;fc(a,b,e);u=d;return}function am(a,c){a=a|0;c=c|0;var d=0,e=0;if((a|0)!=(c|0)){d=b[c+11>>0]|0;e=d<<24>>24<0;jj(a,e?f[c>>2]|0:c,e?f[c+4>>2]|0:d&255)|0}return a|0}function bm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=X(d,c)|0;f=a>>>16;a=(e>>>16)+(X(d,f)|0)|0;d=b>>>16;b=X(d,c)|0;return (I=(a>>>16)+(X(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function cm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=Gj(b)|0;d=ln(c+13|0)|0;f[d>>2]=c;f[d+4>>2]=c;f[d+8>>2]=0;e=Fp(d)|0;kh(e|0,b|0,c+1|0)|0;f[a>>2]=e;return}function dm(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=-1;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=-1;return c|0}c=f[d>>2]|0;return c|0}function em(a){a=a|0;Yi(a);Oq(a);return}function fm(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);return}function gm(a){a=a|0;var b=0,c=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function hm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);return}function im(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else kh(a,c,d)|0;return a|0}function jm(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b){Oq(a);return}c=a+12|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function km(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function lm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=u;u=u+16|0;e=d;f[e>>2]=f[c>>2];g=Sa[f[(f[a>>2]|0)+16>>2]&31](a,b,e)|0;if(g)f[c>>2]=f[e>>2];u=d;return g&1|0}function mm(a,b){a=a|0;b=b|0;var c=0;if(b>>>0>=2){c=0;return c|0}f[a+28>>2]=b;c=1;return c|0}function nm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){mj(a);return}Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);return}function om(){var a=0,b=0;a=sn()|0;if((a|0?(b=f[a>>2]|0,b|0):0)?(a=b+48|0,(f[a>>2]&-256|0)==1126902528?(f[a+4>>2]|0)==1129074247:0):0)Ho(f[b+12>>2]|0);Ho(Qp()|0)}function pm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,6)|0}function qm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,4)|0}function rm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,2)|0}function sm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,3)|0}function tm(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function um(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,1)|0}function vm(a){a=a|0;var c=0;c=b[w+(a&255)>>0]|0;if((c|0)<8)return c|0;c=b[w+(a>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=b[w+(a>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (b[w+(a>>>24)>>0]|0)+24|0}function wm(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0;if(!a){c=0.0;return +c}if((b|0)==0|(a|0)==(b|0)){c=0.0;return +c}d=+(b>>>0)/+(a>>>0);e=1.0-d;f=d*+Zg(d);c=-(f+e*+Zg(e));return +c}function xm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b|0)>0)d=0;else return;do{e=f[a+(d<<2)>>2]|0;f[c+(d<<2)>>2]=e<<1^e>>31;d=d+1|0}while((d|0)!=(b|0));return}function ym(a){a=a|0;var b=0;zo(a);f[a>>2]=3344;f[a+40>>2]=1196;f[a+44>>2]=-1;b=a+48|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zm(a,c){a=a|0;c=c|0;var d=0;b[c+84>>0]=1;a=f[c+68>>2]|0;d=c+72|0;c=f[d>>2]|0;if((c|0)==(a|0))return 1;f[d>>2]=c+(~((c+-4-a|0)>>>2)<<2);return 1}function Am(a){a=a|0;var b=0,c=0;if(pq(a)|0?(b=Mp(f[a>>2]|0)|0,a=b+8|0,c=f[a>>2]|0,f[a>>2]=c+-1,(c+-1|0)<0):0)Oq(b);return}function Bm(a){a=a|0;var b=0,c=0;b=f[a+16>>2]|0;c=(((f[a+12>>2]|0)+1-b|0)/64|0)+b<<3;a=b<<3;b=Vn(c|0,((c|0)<0)<<31>>31|0,a|0,((a|0)<0)<<31>>31|0)|0;return b|0}function Cm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,5)|0}function Dm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,9)|0}function Em(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Fm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);Oq(a);return}function Gm(a){a=a|0;var b=0,c=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b)return;c=a+12|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Hm(a){a=a|0;var c=0;f[a>>2]=1352;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=-1;c=a+16|0;f[a+32>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;b[c+12>>0]=0;return}function Im(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Jm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);return}function Km(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Fg(a,b,c,d,e,f);return}function Lm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);Oq(a);return}function Mm(a){a=a|0;var b=0,c=0,d=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);f[a+12>>2]=0;f[a+16>>2]=0;return}function Nm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=a+20|0;e=f[d>>2]|0;g=(f[a+16>>2]|0)-e|0;a=g>>>0>c>>>0?c:g;kh(e|0,b|0,a|0)|0;f[d>>2]=(f[d>>2]|0)+a;return c|0}function Om(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Pm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-8-b|0)>>>3)<<3);Oq(b);return}function Qm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Rm(a,b){a=a|0;b=b|0;var c=0;c=f[b>>2]|0;return (1<<(c&31)&f[(f[a+28>>2]|0)+(c>>>5<<2)>>2]|0)!=0|0}function Sm(a,b,c){a=a|0;b=b|0;c=c|0;return Sa[f[(f[a>>2]|0)+44>>2]&31](a,b,c)|0}function Tm(a){a=a|0;var c=0;Il(a);c=a+64|0;f[a+88>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;b[c+20>>0]=0;return}function Um(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);Oq(a);return}function Vm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((f[b+4>>2]|0)==(c|0)?(c=b+28|0,(f[c>>2]|0)!=1):0)f[c>>2]=d;return}function Wm(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;if((Ek(a)|0)==0?(Sa[f[a+32>>2]&31](a,c,1)|0)==1:0)d=h[c>>0]|0;else d=-1;u=b;return d|0}function Xm(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Ym(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;f[a+104>>2]=b;c=f[a+8>>2]|0;d=f[a+4>>2]|0;e=c-d|0;f[a+108>>2]=e;f[a+100>>2]=(b|0)!=0&(e|0)>(b|0)?d+b|0:c;return}function Zm(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;return}function _m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Km(a,b,c,d,e,f);return}function $m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return pm(a,b,c,d,e,f)|0}function an(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return qm(a,b,c,d,e,f)|0}function bn(a,b,c){a=a|0;b=b|0;c=c|0;f[a+4>>2]=b;f[a+8>>2]=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2];f[a+12>>2]=c;return 1}function cn(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;Oq(b)}Oq(a);return}function dn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);Oq(a);return}function en(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return rm(a,b,c,d,e,f)|0}function fn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return sm(a,b,c,d,e,f)|0}function gn(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);return}function hn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e|0;Ld(a,b,c,d,g)|0;u=e;return (I=f[g+4>>2]|0,f[g>>2]|0)|0}function jn(a){a=a|0;var b=0;eo(a);f[a>>2]=6152;b=a+84|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function kn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return um(a,b,c,d,e,f)|0}function ln(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=$a(b)|0;if(a|0){c=a;break}a=Op()|0;if(!a){c=0;break}Ua[a&3]()}return c|0}function mn(a,b,c){a=a|0;b=b|0;c=c|0;ac(a,b,c);return}function nn(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function on(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Cm(a,b,c,d,e,f)|0}function pn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Dm(a,b,c,d,e,f)|0}function qn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);return}function rn(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;d=Qq(f[a+60>>2]|0)|0;f[c>>2]=d;d=to(Ba(6,c|0)|0)|0;u=b;return d|0}function sn(){var a=0,b=0;a=u;u=u+16|0;if(!(Ka(19700,3)|0)){b=Ia(f[4926]|0)|0;u=a;return b|0}else Hn(18840,a);return 0}function tn(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function un(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=bm(e,a)|0;f=I;return (I=(X(b,a)|0)+(X(d,e)|0)+f|f&0,c|0|0)|0}function vn(a,b){a=a|0;b=b|0;lh(a,b);f[a>>2]=1292;b=a+36|0;a=b+40|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function wn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;f[a+24>>2]=0;f[a+28>>2]=0;return}function xn(a){a=a|0;var b=0;b=u;u=u+16|0;yc(a);if(!(La(f[4926]|0,0)|0)){u=b;return}else Hn(18939,b)}function yn(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zn(a,b){a=a|0;b=b|0;return vg(a+40|0,b)|0}function An(a,b){a=a|0;b=b|0;return lj(a,b,lq(b)|0)|0}function Bn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;f[g>>2]=d;d=Zi(a,b,c,g)|0;u=e;return d|0}function Cn(a,b){a=a|0;b=b|0;return Mj(a+40|0,b)|0}function Dn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qh(a,b,c,d)|0}function En(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return uh(a,b,c,d)|0}function Fn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+24>>2]&127](c,b)|0}function Gn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=0;return}function Hn(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=f[1556]|0;Ah(b,a,d)|0;Lj(10,b)|0;Ca()}function In(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Ta[a&31](b|0,c|0,d|0,e|0,f|0,g|0)|0}function Jn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+16>>2]&127](c,b)|0}function Kn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+20>>2]&127](c,b)|0}function Ln(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+12>>2]&127](c,b)|0}function Mn(){var a=0;a=u;u=u+16|0;if(!(Ja(19704,113)|0)){u=a;return}else Hn(18889,a)}function Nn(a,b,c){a=a|0;b=b|0;c=c|0;Pj(a,b,c);return}function On(a){a=a|0;cf(a);Oq(a);return}function Pn(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;_a[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Qn(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)sj(a|0,(kq(c)|0)&255|0,b|0)|0;return a|0}function Rn(a){a=a|0;return 4}function Sn(a,b,c){a=a|0;b=b|0;c=c|0;return ej(0,b,c)|0}function Tn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b<>>32-c;return a<>>0;return (I=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function Wn(a,b){a=a|0;b=b|0;var c=0;if(!b)c=0;else c=Dh(f[b>>2]|0,f[b+4>>2]|0,a)|0;return (c|0?c:a)|0}function Xn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=b-d>>>0;e=b-d-(c>>>0>a>>>0|0)>>>0;return (I=e,a-c>>>0|0)|0}function Yn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b>>>c;return a>>>c|(b&(1<>>c-32|0}function Zn(a){a=a|0;var b=0;f[a>>2]=3932;b=a+4|0;a=b+44|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function _n(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return De(a,b,c,d)|0}function $n(a){a=a|0;ff(a);Oq(a);return}function ao(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=0;return}function bo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return $i(a,b,c,d)|0}function co(a){a=a|0;return 5}function eo(a){a=a|0;var b=0;f[a>>2]=6192;b=a+4|0;a=b+80|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function fo(a){a=a|0;return 6}function go(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return aj(a,b,c,d)|0}function ho(a,b,c){a=a|0;b=b|0;c=c|0;f[a+28>>2]=b;f[a+32>>2]=c;return 1}function io(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=b;return}function jo(a,b,c){a=a|0;b=b|0;c=c|0;Nn(a,b,c);return}function ko(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+28>>2]&127](b)|0}function lo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,1);return}function mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,0);return}function no(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Xg(a,b,c,d)|0}function oo(a,b,c){a=a|0;b=b|0;c=c|0;return fi(a,b,c)|0}function po(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+32>>2]&127](b)|0}function qo(a,b,c){a=a|0;b=b|0;c=c|0;return ej(a,b,c)|0}function ro(a,b,c){a=a|0;b=b|0;c=c|0;return Sn(a,b,c)|0}function so(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Za[a&3](b|0,c|0,d|0,e|0,f|0)}function to(a){a=a|0;var b=0,c=0;if(a>>>0>4294963200){b=Vq()|0;f[b>>2]=0-a;c=-1}else c=a;return c|0}function uo(a,b,c){a=a|0;b=b|0;c=c|0;Li(a,b,c);return}function vo(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;return}function wo(a,b){a=a|0;b=b|0;f[a+8>>2]=b;f[a+12>>2]=-1;return 1}function xo(a,b){a=a|0;b=b|0;f[a+52>>2]=b;ip(a,b);return}function yo(a){a=+a;var b=0;p[s>>3]=a;b=f[s>>2]|0;I=f[s+4>>2]|0;return b|0}function zo(a){a=a|0;Hm(a);f[a>>2]=1476;f[a+36>>2]=0;return}function Ao(a){a=a|0;var b=0;if(!a)b=0;else b=(Eh(a,1056,1144,0)|0)!=0&1;return b|0}function Bo(a){a=a|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);return}function Co(a){a=a|0;if(!a)return;Va[f[(f[a>>2]|0)+4>>2]&127](a);return}function Do(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Ya[a&3](b|0,c|0,d|0,e|0)}function Eo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)im(a|0,b|0,c|0)|0;return a|0}function Fo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)kh(a|0,b|0,c|0)|0;return a|0}function Go(a,b){a=a|0;b=b|0;return -1}function Ho(a){a=a|0;var b=0;b=u;u=u+16|0;Ua[a&3]();Hn(18992,b)}function Io(a){a=a|0;Lh(a);Oq(a);return}function Jo(a,b,c){a=a|0;b=b|0;c=c|0;Ro(a,b,c);return}function Ko(a,b,c){a=a|0;b=$(b);c=c|0;f[a+4>>2]=c;n[a>>2]=b;return}function Lo(a){a=a|0;To(a);f[a>>2]=3408;f[a+56>>2]=0;return}function Mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Sa[a&31](b|0,c|0,d|0)|0}function No(a,b){a=a|0;b=b|0;return (wp(a,b)|0)<<24>>24|0}function Oo(a,b){a=a|0;b=b|0;f[a>>2]=7236;cm(a+4|0,b);return}function Po(a,b){a=a|0;b=b|0;var c=0;if(!a)c=0;else c=Pi(a,b,0)|0;return c|0}function Qo(a){a=a|0;return f[a+12>>2]|0}function Ro(a,b,c){a=a|0;b=b|0;c=c|0;uo(a,b,c);return}function So(){var a=0;a=ln(64)|0;Il(a);return a|0}function To(a){a=a|0;Zn(a);f[a>>2]=3764;f[a+52>>2]=0;return}function Uo(a){a=a|0;if(!a)return;bj(a);Oq(a);return}function Vo(a){a=a|0;return Qa[f[(f[a>>2]|0)+60>>2]&127](a)|0}function Wo(a){a=a|0;return f[a+4>>2]|0}function Xo(a,b,c){a=a|0;b=b|0;c=c|0;if(!(f[a>>2]&32))qi(b,c,a)|0;return}function Yo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Xa[a&15](b|0,c|0,d|0)}function Zo(){var a=0;a=ln(96)|0;Tm(a);return a|0}function _o(a){a=a|0;var b=0;b=u;u=u+a|0;u=u+15&-16;return b|0}function $o(a){a=a|0;var b=0;b=(Jq()|0)+188|0;return $j(a,f[b>>2]|0)|0}function ap(a){a=a|0;return ((f[a+100>>2]|0)-(f[a+96>>2]|0)|0)/12|0|0}function bp(a,b){a=a|0;b=b|0;kp(a,b);return}function cp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(3);return 0}function dp(){var a=0;a=ln(12)|0;op(a);return a|0}function ep(a){a=a|0;Ni(a);Oq(a);return}function fp(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function gp(a,b){a=a|0;b=b|0;var c=0;c=sp(a|0)|0;return ((b|0)==0?a:c)|0}function hp(a){a=a|0;return (f[a+12>>2]|0)-(f[a+8>>2]|0)>>2|0}function ip(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return}function jp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ld(a,b,c,d,0)|0}function kp(a,b){a=a|0;b=b|0;jk(a,b);return}function lp(a){a=a|0;f[a+4>>2]=0;f[a+8>>2]=0;f[a>>2]=a+4;return}function mp(){var a=0;a=ln(84)|0;eo(a);return a|0}function np(a){a=a|0;ui(a);Oq(a);return}function op(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;return}function pp(a){a=a|0;f[a>>2]=7236;Am(a+4|0);return}function qp(a,b,c){a=a|0;b=b|0;c=c|0;return Ra[a&127](b|0,c|0)|0}function rp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(10)}function sp(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function tp(a){a=a|0;To(a);f[a>>2]=3836;return}function up(a,c){a=a|0;c=c|0;b[a>>0]=b[c>>0]|0;return}function vp(a,b,c){a=a|0;b=b|0;c=c|0;return -1}function wp(a,c){a=a|0;c=c|0;return b[(f[a>>2]|0)+c>>0]|0}function xp(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)|0}function yp(a){a=a|0;mj(a);Oq(a);return}function zp(a){a=a|0;if(!a)return;Oq(a);return}function Ap(a){a=a|0;n[a>>2]=$(1.0);f[a+4>>2]=1;return}function Bp(a){a=a|0;b[a+28>>0]=1;return}function Cp(a,b){a=a|0;b=b|0;if(!x){x=a;y=b}}function Dp(a){a=a|0;ji(a);return}function Ep(a,b){a=a|0;b=b|0;return 1}function Fp(a){a=a|0;return a+12|0}function Gp(a,b){a=a|0;b=b|0;f[a+80>>2]=b;return}function Hp(a,b,c){a=a|0;b=b|0;c=c|0;Wa[a&7](b|0,c|0)}function Ip(){var a=0;a=ln(36)|0;qq(a);return a|0}function Jp(a){a=a|0;return gq(a+4|0)|0}function Kp(){var a=0;a=ln(108)|0;jn(a);return a|0}function Lp(a){a=a|0;return (b[a+32>>0]|0)!=0|0}function Mp(a){a=a|0;return a+-12|0}function Np(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(9)}function Op(){var a=0;a=f[4927]|0;f[4927]=a+0;return a|0}function Pp(a){a=a|0;return f[a+56>>2]|0}function Qp(){var a=0;a=f[1786]|0;f[1786]=a+0;return a|0}function Rp(a){a=a|0;Og(a);Oq(a);return}function Sp(a){a=a|0;Sq(a);Oq(a);return}function Tp(a){a=a|0;return b[a+24>>0]|0}function Up(a,b){a=a|0;b=b|0;return 0}function Vp(a){a=a|0;return f[a+40>>2]|0}function Wp(a){a=a|0;return f[a+48>>2]|0}function Xp(a,b){a=a|0;b=b|0;return Qa[a&127](b|0)|0}function Yp(a){a=a|0;return f[a+60>>2]|0}function Zp(a){a=a|0;return f[a+28>>2]|0}function _p(a){a=a|0;sa(a|0)|0;om()}function $p(a){a=a|0;pp(a);Oq(a);return}function aq(a){a=a|0;Ca()}function bq(a,b){a=a|0;b=b|0;return $(+Bk(a,b,0))}function cq(a){a=a|0;return 3}function dq(a,b){a=a|0;b=b|0;u=a;v=b}function eq(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function fq(a){a=a|0;return f[a+80>>2]|0}function gq(a){a=a|0;return f[a>>2]|0}function hq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8)}function iq(a,b){a=a|0;b=b|0;Va[a&127](b|0)}function jq(a,b){a=a|0;b=b|0;return Wn(a,b)|0}function kq(a){a=a|0;return a&255|0}function lq(a){a=a|0;return Gj(a)|0}function mq(a,b){a=a|0;b=b|0;return +(+Bk(a,b,1))}function nq(a,b,c){a=a|0;b=b|0;c=c|0;aa(2);return 0}function oq(a){a=a|0;return 2}function pq(a){a=a|0;return 1}function qq(a){a=a|0;Dp(a);return}function rq(a,b){a=+a;b=+b;return +(+Yl(a,b))}function sq(a,b){a=+a;b=b|0;return +(+bk(a,b))}function tq(a,b){a=+a;b=b|0;return +(+ak(a,b))}function uq(){return 3}function vq(a,b,c){a=a|0;b=b|0;c=c|0;aa(7)}function wq(){return 0}function xq(){return -1}function yq(){return ln(1)|0}function zq(){return 4}function Aq(a){a=a|0;return (a+-48|0)>>>0<10|0}function Bq(){return 1}function Cq(){return 2}function Dq(a,b){a=+a;b=+b;return +(+xd(a,b))}function Eq(a,b){a=a|0;b=b|0;aa(1);return 0}function Fq(a){a=a|0;Ha()}function Gq(a){a=a|0;Ua[a&3]()}function Hq(){ua()}function Iq(a){a=a|0;return +(+mq(a,0))}function Jq(){return Yq()|0}function Kq(a,b){a=a|0;b=b|0;aa(6)}function Lq(a){a=a|0;return ln(a)|0}function Mq(a){a=a|0;Oq(a);return}function Nq(a){a=a|0;u=a}function Oq(a){a=a|0;yc(a);return}function Pq(a){a=a|0;I=a}function Qq(a){a=a|0;return a|0}function Rq(a){a=a|0;aa(0);return 0}function Sq(a){a=a|0;return}function Tq(a){a=a|0;return 0}function Uq(){return I|0}function Vq(){return 19632}function Wq(){return u|0}function Xq(a){a=a|0;aa(5)}function Yq(){return 6352}function Zq(){aa(4)} + +// EMSCRIPTEN_END_FUNCS +var Qa=[Rq,oq,pq,pq,oq,gb,Tq,Tq,Tq,hk,kg,pq,Wo,Tq,Tq,pq,Tq,pq,pq,yl,oq,yl,cq,wl,pq,co,wl,pq,fo,cl,pq,Zp,Rn,yl,pq,yl,oq,yl,cq,wl,pq,co,wl,pq,fo,cl,pq,Zp,Rn,yl,pq,cq,Tq,Wo,pq,Tq,pq,cq,pq,ql,oq,ql,Rn,ql,cq,pl,pq,co,pl,pq,fo,Wk,pq,Zp,pq,ql,oq,ql,Rn,ql,cq,pl,pq,co,pl,pq,fo,Wk,pq,Zp,pq,oq,pq,pq,Nd,pq,Vo,Xe,mh,zk,po,ko,pb,Qo,Wo,Mg,Wg,Lf,rb,Qo,Wo,pq,Tq,Tq,zc,Ki,Tq,pq,pq,Uj,Tq,Uj,ck,rn,Jp,Rq,Rq,Rq];var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,yp,yp,Nk,Gk,sb,Og,Rp,Sq,Sp,Sq,Sq,Sp,pp,$p,$p,xn,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq,Xq];var Wa=[Kq,pk,gg,yk,Nc,Kq,Kq,Kq];var Xa=[vq,Ne,ij,$b,ic,yd,$b,ic,$g,Aj,Lg,Yf,vq,vq,vq,vq];var Ya=[hq,hm,dl,hq];var Za=[Np,tj,oh,Np];var _a=[rp,Rl,Sk,rp];return{___cxa_can_catch:lm,___cxa_is_pointer_type:Ao,___divdi3:Ik,___muldi3:un,___udivdi3:jp,___uremdi3:hn,_bitshift64Lshr:Yn,_bitshift64Shl:Tn,_emscripten_bind_DracoInt8Array_DracoInt8Array_0:dp,_emscripten_bind_DracoInt8Array_GetValue_1:No,_emscripten_bind_DracoInt8Array___destroy___0:cn,_emscripten_bind_DracoInt8Array_size_0:xp,_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2:oo,_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3:En,_emscripten_bind_Encoder_Encoder_0:Ip,_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5:_m,_emscripten_bind_Encoder_SetAttributeQuantization_2:jo,_emscripten_bind_Encoder_SetEncodingMethod_1:bp,_emscripten_bind_Encoder_SetSpeedOptions_2:Jo,_emscripten_bind_Encoder___destroy___0:Wj,_emscripten_bind_GeometryAttribute_GeometryAttribute_0:So,_emscripten_bind_GeometryAttribute___destroy___0:zp,_emscripten_bind_MeshBuilder_AddFacesToMesh_3:no,_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5:pn,_emscripten_bind_MeshBuilder_AddFloatAttribute_5:pn,_emscripten_bind_MeshBuilder_AddInt16Attribute_5:fn,_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5:on,_emscripten_bind_MeshBuilder_AddInt32Attribute_5:on,_emscripten_bind_MeshBuilder_AddInt8Attribute_5:kn,_emscripten_bind_MeshBuilder_AddMetadataToMesh_2:ro,_emscripten_bind_MeshBuilder_AddMetadata_2:qo,_emscripten_bind_MeshBuilder_AddUInt16Attribute_5:an,_emscripten_bind_MeshBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_MeshBuilder_AddUInt8Attribute_5:en,_emscripten_bind_MeshBuilder_MeshBuilder_0:yq,_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_MeshBuilder___destroy___0:zp,_emscripten_bind_Mesh_Mesh_0:Kp,_emscripten_bind_Mesh___destroy___0:Co,_emscripten_bind_Mesh_num_attributes_0:hp,_emscripten_bind_Mesh_num_faces_0:ap,_emscripten_bind_Mesh_num_points_0:fq,_emscripten_bind_Mesh_set_num_points_1:Gp,_emscripten_bind_MetadataBuilder_AddDoubleEntry_3:bo,_emscripten_bind_MetadataBuilder_AddIntEntry_3:go,_emscripten_bind_MetadataBuilder_AddStringEntry_3:_n,_emscripten_bind_MetadataBuilder_MetadataBuilder_0:yq,_emscripten_bind_MetadataBuilder___destroy___0:zp,_emscripten_bind_Metadata_Metadata_0:Xl,_emscripten_bind_Metadata___destroy___0:Uo,_emscripten_bind_PointAttribute_PointAttribute_0:Zo,_emscripten_bind_PointAttribute___destroy___0:Ij,_emscripten_bind_PointAttribute_attribute_type_0:Pp,_emscripten_bind_PointAttribute_byte_offset_0:Wp,_emscripten_bind_PointAttribute_byte_stride_0:Vp,_emscripten_bind_PointAttribute_data_type_0:Zp,_emscripten_bind_PointAttribute_normalized_0:Lp,_emscripten_bind_PointAttribute_num_components_0:Tp,_emscripten_bind_PointAttribute_size_0:fq,_emscripten_bind_PointAttribute_unique_id_0:Yp,_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5:pn,_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5:fn,_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5:on,_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5:kn,_emscripten_bind_PointCloudBuilder_AddMetadata_2:qo,_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5:an,_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5:en,_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0:yq,_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_PointCloudBuilder___destroy___0:zp,_emscripten_bind_PointCloud_PointCloud_0:mp,_emscripten_bind_PointCloud___destroy___0:Co,_emscripten_bind_PointCloud_num_attributes_0:hp,_emscripten_bind_PointCloud_num_points_0:fq,_emscripten_bind_VoidPtr___destroy___0:zp,_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE:xq,_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD:wq,_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH:Bq,_emscripten_enum_draco_GeometryAttribute_Type_COLOR:Cq,_emscripten_enum_draco_GeometryAttribute_Type_GENERIC:zq,_emscripten_enum_draco_GeometryAttribute_Type_INVALID:xq,_emscripten_enum_draco_GeometryAttribute_Type_NORMAL:Bq,_emscripten_enum_draco_GeometryAttribute_Type_POSITION:wq,_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD:uq,_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING:Bq,_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING:wq,_emscripten_replace_memory:Pa,_free:yc,_i64Add:Vn,_i64Subtract:Xn,_llvm_bswap_i32:sp,_malloc:$a,_memcpy:kh,_memmove:im,_memset:sj,_sbrk:Nl,dynCall_ii:Xp,dynCall_iii:qp,dynCall_iiii:Mo,dynCall_iiiiiii:In,dynCall_v:Gq,dynCall_vi:iq,dynCall_vii:Hp,dynCall_viii:Yo,dynCall_viiii:Do,dynCall_viiiii:so,dynCall_viiiiii:Pn,establishStackSpace:dq,getTempRet0:Uq,runPostSets:Un,setTempRet0:Pq,setThrew:Cp,stackAlloc:_o,stackRestore:Nq,stackSave:Wq}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var ___divdi3=Module["___divdi3"]=asm["___divdi3"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_DracoInt8Array_DracoInt8Array_0=Module["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"]=asm["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"];var _emscripten_bind_DracoInt8Array_GetValue_1=Module["_emscripten_bind_DracoInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoInt8Array_GetValue_1"];var _emscripten_bind_DracoInt8Array___destroy___0=Module["_emscripten_bind_DracoInt8Array___destroy___0"]=asm["_emscripten_bind_DracoInt8Array___destroy___0"];var _emscripten_bind_DracoInt8Array_size_0=Module["_emscripten_bind_DracoInt8Array_size_0"]=asm["_emscripten_bind_DracoInt8Array_size_0"];var _emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2=Module["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"]=asm["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"];var _emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3=Module["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"]=asm["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"];var _emscripten_bind_Encoder_Encoder_0=Module["_emscripten_bind_Encoder_Encoder_0"]=asm["_emscripten_bind_Encoder_Encoder_0"];var _emscripten_bind_Encoder_SetAttributeExplicitQuantization_5=Module["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"]=asm["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"];var _emscripten_bind_Encoder_SetAttributeQuantization_2=Module["_emscripten_bind_Encoder_SetAttributeQuantization_2"]=asm["_emscripten_bind_Encoder_SetAttributeQuantization_2"];var _emscripten_bind_Encoder_SetEncodingMethod_1=Module["_emscripten_bind_Encoder_SetEncodingMethod_1"]=asm["_emscripten_bind_Encoder_SetEncodingMethod_1"];var _emscripten_bind_Encoder_SetSpeedOptions_2=Module["_emscripten_bind_Encoder_SetSpeedOptions_2"]=asm["_emscripten_bind_Encoder_SetSpeedOptions_2"];var _emscripten_bind_Encoder___destroy___0=Module["_emscripten_bind_Encoder___destroy___0"]=asm["_emscripten_bind_Encoder___destroy___0"];var _emscripten_bind_GeometryAttribute_GeometryAttribute_0=Module["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"]=asm["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"];var _emscripten_bind_GeometryAttribute___destroy___0=Module["_emscripten_bind_GeometryAttribute___destroy___0"]=asm["_emscripten_bind_GeometryAttribute___destroy___0"];var _emscripten_bind_MeshBuilder_AddFacesToMesh_3=Module["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"]=asm["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"];var _emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddFloatAttribute_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"];var _emscripten_bind_MeshBuilder_AddInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"];var _emscripten_bind_MeshBuilder_AddMetadataToMesh_2=Module["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"];var _emscripten_bind_MeshBuilder_AddMetadata_2=Module["_emscripten_bind_MeshBuilder_AddMetadata_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadata_2"];var _emscripten_bind_MeshBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"];var _emscripten_bind_MeshBuilder_MeshBuilder_0=Module["_emscripten_bind_MeshBuilder_MeshBuilder_0"]=asm["_emscripten_bind_MeshBuilder_MeshBuilder_0"];var _emscripten_bind_MeshBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_MeshBuilder___destroy___0=Module["_emscripten_bind_MeshBuilder___destroy___0"]=asm["_emscripten_bind_MeshBuilder___destroy___0"];var _emscripten_bind_Mesh_Mesh_0=Module["_emscripten_bind_Mesh_Mesh_0"]=asm["_emscripten_bind_Mesh_Mesh_0"];var _emscripten_bind_Mesh___destroy___0=Module["_emscripten_bind_Mesh___destroy___0"]=asm["_emscripten_bind_Mesh___destroy___0"];var _emscripten_bind_Mesh_num_attributes_0=Module["_emscripten_bind_Mesh_num_attributes_0"]=asm["_emscripten_bind_Mesh_num_attributes_0"];var _emscripten_bind_Mesh_num_faces_0=Module["_emscripten_bind_Mesh_num_faces_0"]=asm["_emscripten_bind_Mesh_num_faces_0"];var _emscripten_bind_Mesh_num_points_0=Module["_emscripten_bind_Mesh_num_points_0"]=asm["_emscripten_bind_Mesh_num_points_0"];var _emscripten_bind_Mesh_set_num_points_1=Module["_emscripten_bind_Mesh_set_num_points_1"]=asm["_emscripten_bind_Mesh_set_num_points_1"];var _emscripten_bind_MetadataBuilder_AddDoubleEntry_3=Module["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"];var _emscripten_bind_MetadataBuilder_AddIntEntry_3=Module["_emscripten_bind_MetadataBuilder_AddIntEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddIntEntry_3"];var _emscripten_bind_MetadataBuilder_AddStringEntry_3=Module["_emscripten_bind_MetadataBuilder_AddStringEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddStringEntry_3"];var _emscripten_bind_MetadataBuilder_MetadataBuilder_0=Module["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"]=asm["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"];var _emscripten_bind_MetadataBuilder___destroy___0=Module["_emscripten_bind_MetadataBuilder___destroy___0"]=asm["_emscripten_bind_MetadataBuilder___destroy___0"];var _emscripten_bind_Metadata_Metadata_0=Module["_emscripten_bind_Metadata_Metadata_0"]=asm["_emscripten_bind_Metadata_Metadata_0"];var _emscripten_bind_Metadata___destroy___0=Module["_emscripten_bind_Metadata___destroy___0"]=asm["_emscripten_bind_Metadata___destroy___0"];var _emscripten_bind_PointAttribute_PointAttribute_0=Module["_emscripten_bind_PointAttribute_PointAttribute_0"]=asm["_emscripten_bind_PointAttribute_PointAttribute_0"];var _emscripten_bind_PointAttribute___destroy___0=Module["_emscripten_bind_PointAttribute___destroy___0"]=asm["_emscripten_bind_PointAttribute___destroy___0"];var _emscripten_bind_PointAttribute_attribute_type_0=Module["_emscripten_bind_PointAttribute_attribute_type_0"]=asm["_emscripten_bind_PointAttribute_attribute_type_0"];var _emscripten_bind_PointAttribute_byte_offset_0=Module["_emscripten_bind_PointAttribute_byte_offset_0"]=asm["_emscripten_bind_PointAttribute_byte_offset_0"];var _emscripten_bind_PointAttribute_byte_stride_0=Module["_emscripten_bind_PointAttribute_byte_stride_0"]=asm["_emscripten_bind_PointAttribute_byte_stride_0"];var _emscripten_bind_PointAttribute_data_type_0=Module["_emscripten_bind_PointAttribute_data_type_0"]=asm["_emscripten_bind_PointAttribute_data_type_0"];var _emscripten_bind_PointAttribute_normalized_0=Module["_emscripten_bind_PointAttribute_normalized_0"]=asm["_emscripten_bind_PointAttribute_normalized_0"];var _emscripten_bind_PointAttribute_num_components_0=Module["_emscripten_bind_PointAttribute_num_components_0"]=asm["_emscripten_bind_PointAttribute_num_components_0"];var _emscripten_bind_PointAttribute_size_0=Module["_emscripten_bind_PointAttribute_size_0"]=asm["_emscripten_bind_PointAttribute_size_0"];var _emscripten_bind_PointAttribute_unique_id_0=Module["_emscripten_bind_PointAttribute_unique_id_0"]=asm["_emscripten_bind_PointAttribute_unique_id_0"];var _emscripten_bind_PointCloudBuilder_AddFloatAttribute_5=Module["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddMetadata_2=Module["_emscripten_bind_PointCloudBuilder_AddMetadata_2"]=asm["_emscripten_bind_PointCloudBuilder_AddMetadata_2"];var _emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_PointCloudBuilder_0=Module["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"]=asm["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"];var _emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_PointCloudBuilder___destroy___0=Module["_emscripten_bind_PointCloudBuilder___destroy___0"]=asm["_emscripten_bind_PointCloudBuilder___destroy___0"];var _emscripten_bind_PointCloud_PointCloud_0=Module["_emscripten_bind_PointCloud_PointCloud_0"]=asm["_emscripten_bind_PointCloud_PointCloud_0"];var _emscripten_bind_PointCloud___destroy___0=Module["_emscripten_bind_PointCloud___destroy___0"]=asm["_emscripten_bind_PointCloud___destroy___0"];var _emscripten_bind_PointCloud_num_attributes_0=Module["_emscripten_bind_PointCloud_num_attributes_0"]=asm["_emscripten_bind_PointCloud_num_attributes_0"];var _emscripten_bind_PointCloud_num_points_0=Module["_emscripten_bind_PointCloud_num_points_0"]=asm["_emscripten_bind_PointCloud_num_points_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Module["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"]=asm["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"];var _emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Module["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"]=asm["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"];var _emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Module["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"]=asm["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"];var _emscripten_enum_draco_GeometryAttribute_Type_COLOR=Module["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"];var _emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Module["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"];var _emscripten_enum_draco_GeometryAttribute_Type_INVALID=Module["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"];var _emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Module["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"];var _emscripten_enum_draco_GeometryAttribute_Type_POSITION=Module["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"];var _emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Module["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Module["asm"]=asm;if(memoryInitializer){if(!isDataURI(memoryInitializer)){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});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;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]&&status===0){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret}),copy:(function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;i=d);)++b;if(16k?d+=String.fromCharCode(k):(k-=65536,d+=String.fromCharCode(55296|k>>10,56320|k&1023))}}else d+=String.fromCharCode(k)}return d}function X(a,c){return a?h(ca,a,c):""}function e(a,c){0=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++b)&1023);127>=d?++c:c=2047>=d?c+2:65535>=d?c+3:c+4}c=Array(c+1);b=0;d=c.length;if(0=e){var f=a.charCodeAt(++k);e=65536+((e&1023)<<10)|f&1023}if(127>=e){if(b>=d)break;c[b++]=e}else{if(2047>=e){if(b+1>=d)break;c[b++]=192|e>>6}else{if(65535>=e){if(b+2>=d)break;c[b++]=224|e>>12}else{if(b+3>=d)break;c[b++]=240|e>>18;c[b++]=128|e>>12&63}c[b++]=128|e>>6&63}c[b++]=128| +e&63}}c[b]=0}a=n.alloc(c,T);n.copy(c,T,a)}return a}function x(){throw"cannot construct a Status, no constructor in IDL";}function A(){this.ptr=Oa();u(A)[this.ptr]=this}function B(){this.ptr=Pa();u(B)[this.ptr]=this}function C(){this.ptr=Qa();u(C)[this.ptr]=this}function D(){this.ptr=Ra();u(D)[this.ptr]=this}function E(){this.ptr=Sa();u(E)[this.ptr]=this}function q(){this.ptr=Ta();u(q)[this.ptr]=this}function J(){this.ptr=Ua();u(J)[this.ptr]=this}function w(){this.ptr=Va();u(w)[this.ptr]=this}function F(){this.ptr= +Wa();u(F)[this.ptr]=this}function r(){this.ptr=Xa();u(r)[this.ptr]=this}function G(){this.ptr=Ya();u(G)[this.ptr]=this}function H(){this.ptr=Za();u(H)[this.ptr]=this}function O(){this.ptr=$a();u(O)[this.ptr]=this}function K(){this.ptr=ab();u(K)[this.ptr]=this}function g(){this.ptr=bb();u(g)[this.ptr]=this}function y(){this.ptr=cb();u(y)[this.ptr]=this}function Q(){throw"cannot construct a VoidPtr, no constructor in IDL";}function I(){this.ptr=db();u(I)[this.ptr]=this}function L(){this.ptr=eb();u(L)[this.ptr]= +this}m=m||{};var a="undefined"!==typeof m?m:{},Ga=!1,Ha=!1;a.onRuntimeInitialized=function(){Ga=!0;if(Ha&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.onModuleParsed=function(){Ha=!0;if(Ga&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.isVersionSupported=function(a){if("string"!==typeof a)return!1;a=a.split(".");return 2>a.length||3=a[1]?!0:0!=a[0]||10>2]},getStr:function(){return X(R.get())}, +get64:function(){var a=R.get();R.get();return a},getZero:function(){R.get()}},Ka={__cxa_allocate_exception:function(a){return ib(a)},__cxa_throw:function(a,c,b){"uncaught_exception"in ta?ta.uncaught_exceptions++:ta.uncaught_exceptions=1;throw a;},abort:function(){z()},emscripten_get_sbrk_ptr:function(){return 13664},emscripten_memcpy_big:function(a,c,b){ca.set(ca.subarray(c,c+b),a)},emscripten_resize_heap:function(a){if(2147418112= +c?e(2*c,65536):Math.min(e((3*c+2147483648)/4,65536),2147418112);a:{try{ia.grow(c-ka.byteLength+65535>>16);l(ia.buffer);var b=1;break a}catch(d){}b=void 0}return b?!0:!1},environ_get:function(a,c){var b=0;ba().forEach(function(d,e){var f=c+b;e=P[a+4*e>>2]=f;for(f=0;f>0]=d.charCodeAt(f);T[e>>0]=0;b+=d.length+1});return 0},environ_sizes_get:function(a,c){var b=ba();P[a>>2]=b.length;var d=0;b.forEach(function(a){d+=a.length+1});P[c>>2]=d;return 0},fd_close:function(a){return 0},fd_seek:function(a, +c,b,d,e){return 0},fd_write:function(a,c,b,d){try{for(var e=0,f=0;f>2],k=P[c+(8*f+4)>>2],h=0;h>2]=e;return 0}catch(ua){return"undefined"!==typeof FS&&ua instanceof FS.ErrnoError||z(ua),ua.errno}},memory:ia,setTempRet0:function(a){},table:gb},La=function(){function e(c,b){a.asm=c.exports;aa--;a.monitorRunDependencies&&a.monitorRunDependencies(aa);0==aa&&(null!==sa&&(clearInterval(sa),sa=null),ja&&(c=ja,ja=null,c()))}function c(a){e(a.instance)} +function b(a){return Ma().then(function(a){return WebAssembly.instantiate(a,d)}).then(a,function(a){Y("failed to asynchronously prepare wasm: "+a);z(a)})}var d={env:Ka,wasi_unstable:Ka};aa++;a.monitorRunDependencies&&a.monitorRunDependencies(aa);if(a.instantiateWasm)try{return a.instantiateWasm(d,e)}catch(Na){return Y("Module.instantiateWasm callback failed with error: "+Na),!1}(function(){if(da||"function"!==typeof WebAssembly.instantiateStreaming||va(U)||"function"!==typeof fetch)return b(c);fetch(U, +{credentials:"same-origin"}).then(function(a){return WebAssembly.instantiateStreaming(a,d).then(c,function(a){Y("wasm streaming compile failed: "+a);Y("falling back to ArrayBuffer instantiation");b(c)})})})();return{}}();a.asm=La;var hb=a.___wasm_call_ctors=function(){return a.asm.__wasm_call_ctors.apply(null,arguments)},jb=a._emscripten_bind_Status_code_0=function(){return a.asm.emscripten_bind_Status_code_0.apply(null,arguments)},kb=a._emscripten_bind_Status_ok_0=function(){return a.asm.emscripten_bind_Status_ok_0.apply(null, +arguments)},lb=a._emscripten_bind_Status_error_msg_0=function(){return a.asm.emscripten_bind_Status_error_msg_0.apply(null,arguments)},mb=a._emscripten_bind_Status___destroy___0=function(){return a.asm.emscripten_bind_Status___destroy___0.apply(null,arguments)},Oa=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return a.asm.emscripten_bind_DracoUInt16Array_DracoUInt16Array_0.apply(null,arguments)},nb=a._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt16Array_GetValue_1.apply(null, +arguments)},ob=a._emscripten_bind_DracoUInt16Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt16Array_size_0.apply(null,arguments)},pb=a._emscripten_bind_DracoUInt16Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt16Array___destroy___0.apply(null,arguments)},Pa=a._emscripten_bind_PointCloud_PointCloud_0=function(){return a.asm.emscripten_bind_PointCloud_PointCloud_0.apply(null,arguments)},qb=a._emscripten_bind_PointCloud_num_attributes_0=function(){return a.asm.emscripten_bind_PointCloud_num_attributes_0.apply(null, +arguments)},rb=a._emscripten_bind_PointCloud_num_points_0=function(){return a.asm.emscripten_bind_PointCloud_num_points_0.apply(null,arguments)},sb=a._emscripten_bind_PointCloud___destroy___0=function(){return a.asm.emscripten_bind_PointCloud___destroy___0.apply(null,arguments)},Qa=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return a.asm.emscripten_bind_DracoUInt8Array_DracoUInt8Array_0.apply(null,arguments)},tb=a._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt8Array_GetValue_1.apply(null, +arguments)},ub=a._emscripten_bind_DracoUInt8Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt8Array_size_0.apply(null,arguments)},vb=a._emscripten_bind_DracoUInt8Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt8Array___destroy___0.apply(null,arguments)},Ra=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return a.asm.emscripten_bind_DracoUInt32Array_DracoUInt32Array_0.apply(null,arguments)},wb=a._emscripten_bind_DracoUInt32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoUInt32Array_GetValue_1.apply(null, +arguments)},xb=a._emscripten_bind_DracoUInt32Array_size_0=function(){return a.asm.emscripten_bind_DracoUInt32Array_size_0.apply(null,arguments)},yb=a._emscripten_bind_DracoUInt32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoUInt32Array___destroy___0.apply(null,arguments)},Sa=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0.apply(null,arguments)},zb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1= +function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1.apply(null,arguments)},Ab=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform_quantization_bits_0.apply(null,arguments)},Bb=a._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return a.asm.emscripten_bind_AttributeOctahedronTransform___destroy___0.apply(null,arguments)},Ta=a._emscripten_bind_PointAttribute_PointAttribute_0= +function(){return a.asm.emscripten_bind_PointAttribute_PointAttribute_0.apply(null,arguments)},Cb=a._emscripten_bind_PointAttribute_size_0=function(){return a.asm.emscripten_bind_PointAttribute_size_0.apply(null,arguments)},Db=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=function(){return a.asm.emscripten_bind_PointAttribute_GetAttributeTransformData_0.apply(null,arguments)},Eb=a._emscripten_bind_PointAttribute_attribute_type_0=function(){return a.asm.emscripten_bind_PointAttribute_attribute_type_0.apply(null, +arguments)},Fb=a._emscripten_bind_PointAttribute_data_type_0=function(){return a.asm.emscripten_bind_PointAttribute_data_type_0.apply(null,arguments)},Gb=a._emscripten_bind_PointAttribute_num_components_0=function(){return a.asm.emscripten_bind_PointAttribute_num_components_0.apply(null,arguments)},Hb=a._emscripten_bind_PointAttribute_normalized_0=function(){return a.asm.emscripten_bind_PointAttribute_normalized_0.apply(null,arguments)},Ib=a._emscripten_bind_PointAttribute_byte_stride_0=function(){return a.asm.emscripten_bind_PointAttribute_byte_stride_0.apply(null, +arguments)},Jb=a._emscripten_bind_PointAttribute_byte_offset_0=function(){return a.asm.emscripten_bind_PointAttribute_byte_offset_0.apply(null,arguments)},Kb=a._emscripten_bind_PointAttribute_unique_id_0=function(){return a.asm.emscripten_bind_PointAttribute_unique_id_0.apply(null,arguments)},Lb=a._emscripten_bind_PointAttribute___destroy___0=function(){return a.asm.emscripten_bind_PointAttribute___destroy___0.apply(null,arguments)},Ua=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0= +function(){return a.asm.emscripten_bind_AttributeTransformData_AttributeTransformData_0.apply(null,arguments)},Mb=a._emscripten_bind_AttributeTransformData_transform_type_0=function(){return a.asm.emscripten_bind_AttributeTransformData_transform_type_0.apply(null,arguments)},Nb=a._emscripten_bind_AttributeTransformData___destroy___0=function(){return a.asm.emscripten_bind_AttributeTransformData___destroy___0.apply(null,arguments)},Va=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0= +function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0.apply(null,arguments)},Ob=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1.apply(null,arguments)},Pb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_quantization_bits_0.apply(null,arguments)}, +Qb=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_min_value_1.apply(null,arguments)},Rb=a._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform_range_0.apply(null,arguments)},Sb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return a.asm.emscripten_bind_AttributeQuantizationTransform___destroy___0.apply(null,arguments)}, +Wa=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return a.asm.emscripten_bind_DracoInt8Array_DracoInt8Array_0.apply(null,arguments)},Tb=a._emscripten_bind_DracoInt8Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoInt8Array_GetValue_1.apply(null,arguments)},Ub=a._emscripten_bind_DracoInt8Array_size_0=function(){return a.asm.emscripten_bind_DracoInt8Array_size_0.apply(null,arguments)},Vb=a._emscripten_bind_DracoInt8Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt8Array___destroy___0.apply(null, +arguments)},Xa=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return a.asm.emscripten_bind_MetadataQuerier_MetadataQuerier_0.apply(null,arguments)},Wb=a._emscripten_bind_MetadataQuerier_HasEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_HasEntry_2.apply(null,arguments)},Xb=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetIntEntry_2.apply(null,arguments)},Yb=a._emscripten_bind_MetadataQuerier_GetIntEntryArray_3= +function(){return a.asm.emscripten_bind_MetadataQuerier_GetIntEntryArray_3.apply(null,arguments)},Zb=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetDoubleEntry_2.apply(null,arguments)},$b=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetStringEntry_2.apply(null,arguments)},ac=a._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return a.asm.emscripten_bind_MetadataQuerier_NumEntries_1.apply(null, +arguments)},bc=a._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return a.asm.emscripten_bind_MetadataQuerier_GetEntryName_2.apply(null,arguments)},cc=a._emscripten_bind_MetadataQuerier___destroy___0=function(){return a.asm.emscripten_bind_MetadataQuerier___destroy___0.apply(null,arguments)},Ya=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return a.asm.emscripten_bind_DracoInt16Array_DracoInt16Array_0.apply(null,arguments)},dc=a._emscripten_bind_DracoInt16Array_GetValue_1= +function(){return a.asm.emscripten_bind_DracoInt16Array_GetValue_1.apply(null,arguments)},ec=a._emscripten_bind_DracoInt16Array_size_0=function(){return a.asm.emscripten_bind_DracoInt16Array_size_0.apply(null,arguments)},fc=a._emscripten_bind_DracoInt16Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt16Array___destroy___0.apply(null,arguments)},Za=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return a.asm.emscripten_bind_DracoFloat32Array_DracoFloat32Array_0.apply(null, +arguments)},gc=a._emscripten_bind_DracoFloat32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoFloat32Array_GetValue_1.apply(null,arguments)},hc=a._emscripten_bind_DracoFloat32Array_size_0=function(){return a.asm.emscripten_bind_DracoFloat32Array_size_0.apply(null,arguments)},ic=a._emscripten_bind_DracoFloat32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoFloat32Array___destroy___0.apply(null,arguments)},$a=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return a.asm.emscripten_bind_GeometryAttribute_GeometryAttribute_0.apply(null, +arguments)},jc=a._emscripten_bind_GeometryAttribute___destroy___0=function(){return a.asm.emscripten_bind_GeometryAttribute___destroy___0.apply(null,arguments)},ab=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=function(){return a.asm.emscripten_bind_DecoderBuffer_DecoderBuffer_0.apply(null,arguments)},kc=a._emscripten_bind_DecoderBuffer_Init_2=function(){return a.asm.emscripten_bind_DecoderBuffer_Init_2.apply(null,arguments)},lc=a._emscripten_bind_DecoderBuffer___destroy___0=function(){return a.asm.emscripten_bind_DecoderBuffer___destroy___0.apply(null, +arguments)},bb=a._emscripten_bind_Decoder_Decoder_0=function(){return a.asm.emscripten_bind_Decoder_Decoder_0.apply(null,arguments)},mc=a._emscripten_bind_Decoder_GetEncodedGeometryType_1=function(){return a.asm.emscripten_bind_Decoder_GetEncodedGeometryType_1.apply(null,arguments)},nc=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return a.asm.emscripten_bind_Decoder_DecodeBufferToPointCloud_2.apply(null,arguments)},oc=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return a.asm.emscripten_bind_Decoder_DecodeBufferToMesh_2.apply(null, +arguments)},pc=a._emscripten_bind_Decoder_GetAttributeId_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeId_2.apply(null,arguments)},qc=a._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIdByName_2.apply(null,arguments)},rc=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3.apply(null,arguments)},sc=a._emscripten_bind_Decoder_GetAttribute_2= +function(){return a.asm.emscripten_bind_Decoder_GetAttribute_2.apply(null,arguments)},tc=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeByUniqueId_2.apply(null,arguments)},uc=a._emscripten_bind_Decoder_GetMetadata_1=function(){return a.asm.emscripten_bind_Decoder_GetMetadata_1.apply(null,arguments)},vc=a._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return a.asm.emscripten_bind_Decoder_GetAttributeMetadata_2.apply(null, +arguments)},wc=a._emscripten_bind_Decoder_GetFaceFromMesh_3=function(){return a.asm.emscripten_bind_Decoder_GetFaceFromMesh_3.apply(null,arguments)},xc=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return a.asm.emscripten_bind_Decoder_GetTriangleStripsFromMesh_2.apply(null,arguments)},yc=a._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=function(){return a.asm.emscripten_bind_Decoder_GetTrianglesUInt16Array_3.apply(null,arguments)},zc=a._emscripten_bind_Decoder_GetTrianglesUInt32Array_3= +function(){return a.asm.emscripten_bind_Decoder_GetTrianglesUInt32Array_3.apply(null,arguments)},Ac=a._emscripten_bind_Decoder_GetAttributeFloat_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeFloat_3.apply(null,arguments)},Bc=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3.apply(null,arguments)},Cc=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeIntForAllPoints_3.apply(null, +arguments)},Dc=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3.apply(null,arguments)},Ec=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3.apply(null,arguments)},Fc=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3.apply(null,arguments)}, +Gc=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3.apply(null,arguments)},Hc=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3.apply(null,arguments)},Ic=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=function(){return a.asm.emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3.apply(null,arguments)},Jc= +a._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=function(){return a.asm.emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5.apply(null,arguments)},Kc=a._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return a.asm.emscripten_bind_Decoder_SkipAttributeTransform_1.apply(null,arguments)},Lc=a._emscripten_bind_Decoder___destroy___0=function(){return a.asm.emscripten_bind_Decoder___destroy___0.apply(null,arguments)},cb=a._emscripten_bind_Mesh_Mesh_0=function(){return a.asm.emscripten_bind_Mesh_Mesh_0.apply(null, +arguments)},Mc=a._emscripten_bind_Mesh_num_faces_0=function(){return a.asm.emscripten_bind_Mesh_num_faces_0.apply(null,arguments)},Nc=a._emscripten_bind_Mesh_num_attributes_0=function(){return a.asm.emscripten_bind_Mesh_num_attributes_0.apply(null,arguments)},Oc=a._emscripten_bind_Mesh_num_points_0=function(){return a.asm.emscripten_bind_Mesh_num_points_0.apply(null,arguments)},Pc=a._emscripten_bind_Mesh___destroy___0=function(){return a.asm.emscripten_bind_Mesh___destroy___0.apply(null,arguments)}, +Qc=a._emscripten_bind_VoidPtr___destroy___0=function(){return a.asm.emscripten_bind_VoidPtr___destroy___0.apply(null,arguments)},db=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=function(){return a.asm.emscripten_bind_DracoInt32Array_DracoInt32Array_0.apply(null,arguments)},Rc=a._emscripten_bind_DracoInt32Array_GetValue_1=function(){return a.asm.emscripten_bind_DracoInt32Array_GetValue_1.apply(null,arguments)},Sc=a._emscripten_bind_DracoInt32Array_size_0=function(){return a.asm.emscripten_bind_DracoInt32Array_size_0.apply(null, +arguments)},Tc=a._emscripten_bind_DracoInt32Array___destroy___0=function(){return a.asm.emscripten_bind_DracoInt32Array___destroy___0.apply(null,arguments)},eb=a._emscripten_bind_Metadata_Metadata_0=function(){return a.asm.emscripten_bind_Metadata_Metadata_0.apply(null,arguments)},Uc=a._emscripten_bind_Metadata___destroy___0=function(){return a.asm.emscripten_bind_Metadata___destroy___0.apply(null,arguments)},Vc=a._emscripten_enum_draco_StatusCode_OK=function(){return a.asm.emscripten_enum_draco_StatusCode_OK.apply(null, +arguments)},Wc=a._emscripten_enum_draco_StatusCode_DRACO_ERROR=function(){return a.asm.emscripten_enum_draco_StatusCode_DRACO_ERROR.apply(null,arguments)},Xc=a._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return a.asm.emscripten_enum_draco_StatusCode_IO_ERROR.apply(null,arguments)},Yc=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=function(){return a.asm.emscripten_enum_draco_StatusCode_INVALID_PARAMETER.apply(null,arguments)},Zc=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION= +function(){return a.asm.emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION.apply(null,arguments)},$c=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return a.asm.emscripten_enum_draco_StatusCode_UNKNOWN_VERSION.apply(null,arguments)},ad=a._emscripten_enum_draco_DataType_DT_INVALID=function(){return a.asm.emscripten_enum_draco_DataType_DT_INVALID.apply(null,arguments)},bd=a._emscripten_enum_draco_DataType_DT_INT8=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT8.apply(null, +arguments)},cd=a._emscripten_enum_draco_DataType_DT_UINT8=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT8.apply(null,arguments)},dd=a._emscripten_enum_draco_DataType_DT_INT16=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT16.apply(null,arguments)},ed=a._emscripten_enum_draco_DataType_DT_UINT16=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT16.apply(null,arguments)},fd=a._emscripten_enum_draco_DataType_DT_INT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT32.apply(null, +arguments)},gd=a._emscripten_enum_draco_DataType_DT_UINT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT32.apply(null,arguments)},hd=a._emscripten_enum_draco_DataType_DT_INT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_INT64.apply(null,arguments)},id=a._emscripten_enum_draco_DataType_DT_UINT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_UINT64.apply(null,arguments)},jd=a._emscripten_enum_draco_DataType_DT_FLOAT32=function(){return a.asm.emscripten_enum_draco_DataType_DT_FLOAT32.apply(null, +arguments)},kd=a._emscripten_enum_draco_DataType_DT_FLOAT64=function(){return a.asm.emscripten_enum_draco_DataType_DT_FLOAT64.apply(null,arguments)},ld=a._emscripten_enum_draco_DataType_DT_BOOL=function(){return a.asm.emscripten_enum_draco_DataType_DT_BOOL.apply(null,arguments)},md=a._emscripten_enum_draco_DataType_DT_TYPES_COUNT=function(){return a.asm.emscripten_enum_draco_DataType_DT_TYPES_COUNT.apply(null,arguments)},nd=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE.apply(null, +arguments)},od=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD.apply(null,arguments)},pd=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return a.asm.emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH.apply(null,arguments)},qd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM.apply(null, +arguments)},rd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM.apply(null,arguments)},sd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM.apply(null,arguments)},td=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=function(){return a.asm.emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM.apply(null, +arguments)},ud=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_INVALID.apply(null,arguments)},vd=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_POSITION.apply(null,arguments)},wd=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_NORMAL.apply(null,arguments)},xd=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR= +function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_COLOR.apply(null,arguments)},yd=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD.apply(null,arguments)},zd=a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return a.asm.emscripten_enum_draco_GeometryAttribute_Type_GENERIC.apply(null,arguments)};a._setThrew=function(){return a.asm.setThrew.apply(null,arguments)};var ta=a.__ZSt18uncaught_exceptionv= +function(){return a.asm._ZSt18uncaught_exceptionv.apply(null,arguments)};a._free=function(){return a.asm.free.apply(null,arguments)};var ib=a._malloc=function(){return a.asm.malloc.apply(null,arguments)};a.stackSave=function(){return a.asm.stackSave.apply(null,arguments)};a.stackAlloc=function(){return a.asm.stackAlloc.apply(null,arguments)};a.stackRestore=function(){return a.asm.stackRestore.apply(null,arguments)};a.__growWasmMemory=function(){return a.asm.__growWasmMemory.apply(null,arguments)}; +a.dynCall_ii=function(){return a.asm.dynCall_ii.apply(null,arguments)};a.dynCall_vi=function(){return a.asm.dynCall_vi.apply(null,arguments)};a.dynCall_iii=function(){return a.asm.dynCall_iii.apply(null,arguments)};a.dynCall_vii=function(){return a.asm.dynCall_vii.apply(null,arguments)};a.dynCall_iiii=function(){return a.asm.dynCall_iiii.apply(null,arguments)};a.dynCall_v=function(){return a.asm.dynCall_v.apply(null,arguments)};a.dynCall_viii=function(){return a.asm.dynCall_viii.apply(null,arguments)}; +a.dynCall_viiii=function(){return a.asm.dynCall_viiii.apply(null,arguments)};a.dynCall_iiiiiii=function(){return a.asm.dynCall_iiiiiii.apply(null,arguments)};a.dynCall_iidiiii=function(){return a.asm.dynCall_iidiiii.apply(null,arguments)};a.dynCall_jiji=function(){return a.asm.dynCall_jiji.apply(null,arguments)};a.dynCall_viiiiii=function(){return a.asm.dynCall_viiiiii.apply(null,arguments)};a.dynCall_viiiii=function(){return a.asm.dynCall_viiiii.apply(null,arguments)};a.asm=La;var fa;a.then=function(e){if(fa)e(a); +else{var c=a.onRuntimeInitialized;a.onRuntimeInitialized=function(){c&&c();e(a)}}return a};ja=function c(){fa||ma();fa||(ja=c)};a.run=ma;if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0=n.size?(t(0>=1;break;case 4:d>>=2;break;case 8:d>>=3}for(var c=0;c2){ + this.move(1); + + } + }, + + //------------------ + + + rotate : function(name, deg){ + var div = this.hud.getElementById(name); + if(div){ + div.setAttribute("transform", "rotate(" + (deg) + ")"); + } + } + + + + +} \ No newline at end of file diff --git a/games/3dcity/src/jsm/controls/OrbitControls.js b/games/3dcity/src/jsm/controls/OrbitControls.js new file mode 100644 index 0000000..4d5ce68 --- /dev/null +++ b/games/3dcity/src/jsm/controls/OrbitControls.js @@ -0,0 +1,1252 @@ +import { + EventDispatcher, + MOUSE, + Quaternion, + Spherical, + TOUCH, + Vector2, + Vector3 +} from '../../../build/three.module.js'; + +// This set of controls performs orbiting, dollying (zooming), and panning. +// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). +// +// Orbit - left mouse / touch: one-finger move +// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish +// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move + +const _changeEvent = { type: 'change' }; +const _startEvent = { type: 'start' }; +const _endEvent = { type: 'end' }; + +class OrbitControls extends EventDispatcher { + + constructor( object, domElement ) { + + super(); + + if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' ); + if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' ); + + this.object = object; + this.domElement = domElement; + this.domElement.style.touchAction = 'none'; // disable touch scroll + + // Set to false to disable this control + this.enabled = true; + + // "target" sets the location of focus, where the object orbits around + this.target = new Vector3(); + + // How far you can dolly in and out ( PerspectiveCamera only ) + this.minDistance = 0; + this.maxDistance = Infinity; + + // How far you can zoom in and out ( OrthographicCamera only ) + this.minZoom = 0; + this.maxZoom = Infinity; + + // How far you can orbit vertically, upper and lower limits. + // Range is 0 to Math.PI radians. + this.minPolarAngle = 0; // radians + this.maxPolarAngle = Math.PI; // radians + + // How far you can orbit horizontally, upper and lower limits. + // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI ) + this.minAzimuthAngle = - Infinity; // radians + this.maxAzimuthAngle = Infinity; // radians + + // Set to true to enable damping (inertia) + // If damping is enabled, you must call controls.update() in your animation loop + this.enableDamping = false; + this.dampingFactor = 0.05; + + // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. + // Set to false to disable zooming + this.enableZoom = true; + this.zoomSpeed = 1.0; + + // Set to false to disable rotating + this.enableRotate = true; + this.rotateSpeed = 1.0; + + // Set to false to disable panning + this.enablePan = true; + this.panSpeed = 1.0; + this.screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up + this.keyPanSpeed = 7.0; // pixels moved per arrow key push + + // Set to true to automatically rotate around the target + // If auto-rotate is enabled, you must call controls.update() in your animation loop + this.autoRotate = false; + this.autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60 + + // The four arrow keys + this.keys = { LEFT: 'ArrowLeft', UP: 'ArrowUp', RIGHT: 'ArrowRight', BOTTOM: 'ArrowDown' }; + + // Mouse buttons + this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN }; + + // Touch fingers + this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN }; + + // for reset + this.target0 = this.target.clone(); + this.position0 = this.object.position.clone(); + this.zoom0 = this.object.zoom; + + // the target DOM element for key events + this._domElementKeyEvents = null; + + // + // public methods + // + + this.getPolarAngle = function () { + + return spherical.phi; + + }; + + this.getAzimuthalAngle = function () { + + return spherical.theta; + + }; + + this.getDistance = function () { + + return this.object.position.distanceTo( this.target ); + + }; + + this.listenToKeyEvents = function ( domElement ) { + + domElement.addEventListener( 'keydown', onKeyDown ); + this._domElementKeyEvents = domElement; + + }; + + this.saveState = function () { + + scope.target0.copy( scope.target ); + scope.position0.copy( scope.object.position ); + scope.zoom0 = scope.object.zoom; + + }; + + this.reset = function () { + + scope.target.copy( scope.target0 ); + scope.object.position.copy( scope.position0 ); + scope.object.zoom = scope.zoom0; + + scope.object.updateProjectionMatrix(); + scope.dispatchEvent( _changeEvent ); + + scope.update(); + + state = STATE.NONE; + + }; + + // this method is exposed, but perhaps it would be better if we can make it private... + this.update = function () { + + const offset = new Vector3(); + + // so camera.up is the orbit axis + const quat = new Quaternion().setFromUnitVectors( object.up, new Vector3( 0, 1, 0 ) ); + const quatInverse = quat.clone().invert(); + + const lastPosition = new Vector3(); + const lastQuaternion = new Quaternion(); + + const twoPI = 2 * Math.PI; + + return function update() { + + const position = scope.object.position; + + offset.copy( position ).sub( scope.target ); + + // rotate offset to "y-axis-is-up" space + offset.applyQuaternion( quat ); + + // angle from z-axis around y-axis + spherical.setFromVector3( offset ); + + if ( scope.autoRotate && state === STATE.NONE ) { + + rotateLeft( getAutoRotationAngle() ); + + } + + if ( scope.enableDamping ) { + + spherical.theta += sphericalDelta.theta * scope.dampingFactor; + spherical.phi += sphericalDelta.phi * scope.dampingFactor; + + } else { + + spherical.theta += sphericalDelta.theta; + spherical.phi += sphericalDelta.phi; + + } + + // restrict theta to be between desired limits + + let min = scope.minAzimuthAngle; + let max = scope.maxAzimuthAngle; + + if ( isFinite( min ) && isFinite( max ) ) { + + if ( min < - Math.PI ) min += twoPI; else if ( min > Math.PI ) min -= twoPI; + + if ( max < - Math.PI ) max += twoPI; else if ( max > Math.PI ) max -= twoPI; + + if ( min <= max ) { + + spherical.theta = Math.max( min, Math.min( max, spherical.theta ) ); + + } else { + + spherical.theta = ( spherical.theta > ( min + max ) / 2 ) ? + Math.max( min, spherical.theta ) : + Math.min( max, spherical.theta ); + + } + + } + + // restrict phi to be between desired limits + spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); + + spherical.makeSafe(); + + + spherical.radius *= scale; + + // restrict radius to be between desired limits + spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); + + // move target to panned location + + if ( scope.enableDamping === true ) { + + scope.target.addScaledVector( panOffset, scope.dampingFactor ); + + } else { + + scope.target.add( panOffset ); + + } + + offset.setFromSpherical( spherical ); + + // rotate offset back to "camera-up-vector-is-up" space + offset.applyQuaternion( quatInverse ); + + position.copy( scope.target ).add( offset ); + + scope.object.lookAt( scope.target ); + + if ( scope.enableDamping === true ) { + + sphericalDelta.theta *= ( 1 - scope.dampingFactor ); + sphericalDelta.phi *= ( 1 - scope.dampingFactor ); + + panOffset.multiplyScalar( 1 - scope.dampingFactor ); + + } else { + + sphericalDelta.set( 0, 0, 0 ); + + panOffset.set( 0, 0, 0 ); + + } + + scale = 1; + + // update condition is: + // min(camera displacement, camera rotation in radians)^2 > EPS + // using small-angle approximation cos(x/2) = 1 - x^2 / 8 + + if ( zoomChanged || + lastPosition.distanceToSquared( scope.object.position ) > EPS || + 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { + + scope.dispatchEvent( _changeEvent ); + + lastPosition.copy( scope.object.position ); + lastQuaternion.copy( scope.object.quaternion ); + zoomChanged = false; + + return true; + + } + + return false; + + }; + + }(); + + this.dispose = function () { + + scope.domElement.removeEventListener( 'contextmenu', onContextMenu ); + + scope.domElement.removeEventListener( 'pointerdown', onPointerDown ); + scope.domElement.removeEventListener( 'pointercancel', onPointerCancel ); + scope.domElement.removeEventListener( 'wheel', onMouseWheel ); + + scope.domElement.removeEventListener( 'pointermove', onPointerMove ); + scope.domElement.removeEventListener( 'pointerup', onPointerUp ); + + + if ( scope._domElementKeyEvents !== null ) { + + scope._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown ); + + } + + //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? + + }; + + // + // internals + // + + const scope = this; + + const STATE = { + NONE: - 1, + ROTATE: 0, + DOLLY: 1, + PAN: 2, + TOUCH_ROTATE: 3, + TOUCH_PAN: 4, + TOUCH_DOLLY_PAN: 5, + TOUCH_DOLLY_ROTATE: 6 + }; + + let state = STATE.NONE; + + const EPS = 0.000001; + + // current position in spherical coordinates + const spherical = new Spherical(); + const sphericalDelta = new Spherical(); + + let scale = 1; + const panOffset = new Vector3(); + let zoomChanged = false; + + const rotateStart = new Vector2(); + const rotateEnd = new Vector2(); + const rotateDelta = new Vector2(); + + const panStart = new Vector2(); + const panEnd = new Vector2(); + const panDelta = new Vector2(); + + const dollyStart = new Vector2(); + const dollyEnd = new Vector2(); + const dollyDelta = new Vector2(); + + const pointers = []; + const pointerPositions = {}; + + function getAutoRotationAngle() { + + return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; + + } + + function getZoomScale() { + + return Math.pow( 0.95, scope.zoomSpeed ); + + } + + function rotateLeft( angle ) { + + sphericalDelta.theta -= angle; + + } + + function rotateUp( angle ) { + + sphericalDelta.phi -= angle; + + } + + const panLeft = function () { + + const v = new Vector3(); + + return function panLeft( distance, objectMatrix ) { + + v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix + v.multiplyScalar( - distance ); + + panOffset.add( v ); + + }; + + }(); + + const panUp = function () { + + const v = new Vector3(); + + return function panUp( distance, objectMatrix ) { + + if ( scope.screenSpacePanning === true ) { + + v.setFromMatrixColumn( objectMatrix, 1 ); + + } else { + + v.setFromMatrixColumn( objectMatrix, 0 ); + v.crossVectors( scope.object.up, v ); + + } + + v.multiplyScalar( distance ); + + panOffset.add( v ); + + }; + + }(); + + // deltaX and deltaY are in pixels; right and down are positive + const pan = function () { + + const offset = new Vector3(); + + return function pan( deltaX, deltaY ) { + + const element = scope.domElement; + + if ( scope.object.isPerspectiveCamera ) { + + // perspective + const position = scope.object.position; + offset.copy( position ).sub( scope.target ); + let targetDistance = offset.length(); + + // half of the fov is center to top of screen + targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); + + // we use only clientHeight here so aspect ratio does not distort speed + panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); + panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); + + } else if ( scope.object.isOrthographicCamera ) { + + // orthographic + panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); + panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); + + } else { + + // camera neither orthographic nor perspective + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); + scope.enablePan = false; + + } + + }; + + }(); + + function dollyOut( dollyScale ) { + + if ( scope.object.isPerspectiveCamera ) { + + scale /= dollyScale; + + } else if ( scope.object.isOrthographicCamera ) { + + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; + + } else { + + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; + + } + + } + + function dollyIn( dollyScale ) { + + if ( scope.object.isPerspectiveCamera ) { + + scale *= dollyScale; + + } else if ( scope.object.isOrthographicCamera ) { + + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; + + } else { + + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; + + } + + } + + // + // event callbacks - update the object state + // + + function handleMouseDownRotate( event ) { + + rotateStart.set( event.clientX, event.clientY ); + + } + + function handleMouseDownDolly( event ) { + + dollyStart.set( event.clientX, event.clientY ); + + } + + function handleMouseDownPan( event ) { + + panStart.set( event.clientX, event.clientY ); + + } + + function handleMouseMoveRotate( event ) { + + rotateEnd.set( event.clientX, event.clientY ); + + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + + const element = scope.domElement; + + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + + rotateStart.copy( rotateEnd ); + + scope.update(); + + } + + function handleMouseMoveDolly( event ) { + + dollyEnd.set( event.clientX, event.clientY ); + + dollyDelta.subVectors( dollyEnd, dollyStart ); + + if ( dollyDelta.y > 0 ) { + + dollyOut( getZoomScale() ); + + } else if ( dollyDelta.y < 0 ) { + + dollyIn( getZoomScale() ); + + } + + dollyStart.copy( dollyEnd ); + + scope.update(); + + } + + function handleMouseMovePan( event ) { + + panEnd.set( event.clientX, event.clientY ); + + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + + pan( panDelta.x, panDelta.y ); + + panStart.copy( panEnd ); + + scope.update(); + + } + + function handleMouseWheel( event ) { + + if ( event.deltaY < 0 ) { + + dollyIn( getZoomScale() ); + + } else if ( event.deltaY > 0 ) { + + dollyOut( getZoomScale() ); + + } + + scope.update(); + + } + + function handleKeyDown( event ) { + + let needsUpdate = false; + + switch ( event.code ) { + + case scope.keys.UP: + pan( 0, scope.keyPanSpeed ); + needsUpdate = true; + break; + + case scope.keys.BOTTOM: + pan( 0, - scope.keyPanSpeed ); + needsUpdate = true; + break; + + case scope.keys.LEFT: + pan( scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; + + case scope.keys.RIGHT: + pan( - scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; + + } + + if ( needsUpdate ) { + + // prevent the browser from scrolling on cursor keys + event.preventDefault(); + + scope.update(); + + } + + + } + + function handleTouchStartRotate() { + + if ( pointers.length === 1 ) { + + rotateStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY ); + + } else { + + const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX ); + const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY ); + + rotateStart.set( x, y ); + + } + + } + + function handleTouchStartPan() { + + if ( pointers.length === 1 ) { + + panStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY ); + + } else { + + const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX ); + const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY ); + + panStart.set( x, y ); + + } + + } + + function handleTouchStartDolly() { + + const dx = pointers[ 0 ].pageX - pointers[ 1 ].pageX; + const dy = pointers[ 0 ].pageY - pointers[ 1 ].pageY; + + const distance = Math.sqrt( dx * dx + dy * dy ); + + dollyStart.set( 0, distance ); + + } + + function handleTouchStartDollyPan() { + + if ( scope.enableZoom ) handleTouchStartDolly(); + + if ( scope.enablePan ) handleTouchStartPan(); + + } + + function handleTouchStartDollyRotate() { + + if ( scope.enableZoom ) handleTouchStartDolly(); + + if ( scope.enableRotate ) handleTouchStartRotate(); + + } + + function handleTouchMoveRotate( event ) { + + if ( pointers.length == 1 ) { + + rotateEnd.set( event.pageX, event.pageY ); + + } else { + + const position = getSecondPointerPosition( event ); + + const x = 0.5 * ( event.pageX + position.x ); + const y = 0.5 * ( event.pageY + position.y ); + + rotateEnd.set( x, y ); + + } + + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + + const element = scope.domElement; + + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + + rotateStart.copy( rotateEnd ); + + } + + function handleTouchMovePan( event ) { + + if ( pointers.length === 1 ) { + + panEnd.set( event.pageX, event.pageY ); + + } else { + + const position = getSecondPointerPosition( event ); + + const x = 0.5 * ( event.pageX + position.x ); + const y = 0.5 * ( event.pageY + position.y ); + + panEnd.set( x, y ); + + } + + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + + pan( panDelta.x, panDelta.y ); + + panStart.copy( panEnd ); + + } + + function handleTouchMoveDolly( event ) { + + const position = getSecondPointerPosition( event ); + + const dx = event.pageX - position.x; + const dy = event.pageY - position.y; + + const distance = Math.sqrt( dx * dx + dy * dy ); + + dollyEnd.set( 0, distance ); + + dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) ); + + dollyOut( dollyDelta.y ); + + dollyStart.copy( dollyEnd ); + + } + + function handleTouchMoveDollyPan( event ) { + + if ( scope.enableZoom ) handleTouchMoveDolly( event ); + + if ( scope.enablePan ) handleTouchMovePan( event ); + + } + + function handleTouchMoveDollyRotate( event ) { + + if ( scope.enableZoom ) handleTouchMoveDolly( event ); + + if ( scope.enableRotate ) handleTouchMoveRotate( event ); + + } + + // + // event handlers - FSM: listen for events and reset state + // + + function onPointerDown( event ) { + + if ( scope.enabled === false ) return; + + if ( pointers.length === 0 ) { + + scope.domElement.setPointerCapture( event.pointerId ); + + scope.domElement.addEventListener( 'pointermove', onPointerMove ); + scope.domElement.addEventListener( 'pointerup', onPointerUp ); + + } + + // + + addPointer( event ); + + if ( event.pointerType === 'touch' ) { + + onTouchStart( event ); + + } else { + + onMouseDown( event ); + + } + + } + + function onPointerMove( event ) { + + if ( scope.enabled === false ) return; + + if ( event.pointerType === 'touch' ) { + + onTouchMove( event ); + + } else { + + onMouseMove( event ); + + } + + } + + function onPointerUp( event ) { + + removePointer( event ); + + if ( pointers.length === 0 ) { + + scope.domElement.releasePointerCapture( event.pointerId ); + + scope.domElement.removeEventListener( 'pointermove', onPointerMove ); + scope.domElement.removeEventListener( 'pointerup', onPointerUp ); + + } + + scope.dispatchEvent( _endEvent ); + + state = STATE.NONE; + + } + + function onPointerCancel( event ) { + + removePointer( event ); + + } + + function onMouseDown( event ) { + + let mouseAction; + + switch ( event.button ) { + + case 0: + + mouseAction = scope.mouseButtons.LEFT; + break; + + case 1: + + mouseAction = scope.mouseButtons.MIDDLE; + break; + + case 2: + + mouseAction = scope.mouseButtons.RIGHT; + break; + + default: + + mouseAction = - 1; + + } + + switch ( mouseAction ) { + + case MOUSE.DOLLY: + + if ( scope.enableZoom === false ) return; + + handleMouseDownDolly( event ); + + state = STATE.DOLLY; + + break; + + case MOUSE.ROTATE: + + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + + if ( scope.enablePan === false ) return; + + handleMouseDownPan( event ); + + state = STATE.PAN; + + } else { + + if ( scope.enableRotate === false ) return; + + handleMouseDownRotate( event ); + + state = STATE.ROTATE; + + } + + break; + + case MOUSE.PAN: + + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + + if ( scope.enableRotate === false ) return; + + handleMouseDownRotate( event ); + + state = STATE.ROTATE; + + } else { + + if ( scope.enablePan === false ) return; + + handleMouseDownPan( event ); + + state = STATE.PAN; + + } + + break; + + default: + + state = STATE.NONE; + + } + + if ( state !== STATE.NONE ) { + + scope.dispatchEvent( _startEvent ); + + } + + } + + function onMouseMove( event ) { + + if ( scope.enabled === false ) return; + + switch ( state ) { + + case STATE.ROTATE: + + if ( scope.enableRotate === false ) return; + + handleMouseMoveRotate( event ); + + break; + + case STATE.DOLLY: + + if ( scope.enableZoom === false ) return; + + handleMouseMoveDolly( event ); + + break; + + case STATE.PAN: + + if ( scope.enablePan === false ) return; + + handleMouseMovePan( event ); + + break; + + } + + } + + function onMouseWheel( event ) { + + if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return; + + event.preventDefault(); + + scope.dispatchEvent( _startEvent ); + + handleMouseWheel( event ); + + scope.dispatchEvent( _endEvent ); + + } + + function onKeyDown( event ) { + + if ( scope.enabled === false || scope.enablePan === false ) return; + + handleKeyDown( event ); + + } + + function onTouchStart( event ) { + + trackPointer( event ); + + switch ( pointers.length ) { + + case 1: + + switch ( scope.touches.ONE ) { + + case TOUCH.ROTATE: + + if ( scope.enableRotate === false ) return; + + handleTouchStartRotate(); + + state = STATE.TOUCH_ROTATE; + + break; + + case TOUCH.PAN: + + if ( scope.enablePan === false ) return; + + handleTouchStartPan(); + + state = STATE.TOUCH_PAN; + + break; + + default: + + state = STATE.NONE; + + } + + break; + + case 2: + + switch ( scope.touches.TWO ) { + + case TOUCH.DOLLY_PAN: + + if ( scope.enableZoom === false && scope.enablePan === false ) return; + + handleTouchStartDollyPan(); + + state = STATE.TOUCH_DOLLY_PAN; + + break; + + case TOUCH.DOLLY_ROTATE: + + if ( scope.enableZoom === false && scope.enableRotate === false ) return; + + handleTouchStartDollyRotate(); + + state = STATE.TOUCH_DOLLY_ROTATE; + + break; + + default: + + state = STATE.NONE; + + } + + break; + + default: + + state = STATE.NONE; + + } + + if ( state !== STATE.NONE ) { + + scope.dispatchEvent( _startEvent ); + + } + + } + + function onTouchMove( event ) { + + trackPointer( event ); + + switch ( state ) { + + case STATE.TOUCH_ROTATE: + + if ( scope.enableRotate === false ) return; + + handleTouchMoveRotate( event ); + + scope.update(); + + break; + + case STATE.TOUCH_PAN: + + if ( scope.enablePan === false ) return; + + handleTouchMovePan( event ); + + scope.update(); + + break; + + case STATE.TOUCH_DOLLY_PAN: + + if ( scope.enableZoom === false && scope.enablePan === false ) return; + + handleTouchMoveDollyPan( event ); + + scope.update(); + + break; + + case STATE.TOUCH_DOLLY_ROTATE: + + if ( scope.enableZoom === false && scope.enableRotate === false ) return; + + handleTouchMoveDollyRotate( event ); + + scope.update(); + + break; + + default: + + state = STATE.NONE; + + } + + } + + function onContextMenu( event ) { + + if ( scope.enabled === false ) return; + + event.preventDefault(); + + } + + function addPointer( event ) { + + pointers.push( event ); + + } + + function removePointer( event ) { + + delete pointerPositions[ event.pointerId ]; + + for ( let i = 0; i < pointers.length; i ++ ) { + + if ( pointers[ i ].pointerId == event.pointerId ) { + + pointers.splice( i, 1 ); + return; + + } + + } + + } + + function trackPointer( event ) { + + let position = pointerPositions[ event.pointerId ]; + + if ( position === undefined ) { + + position = new Vector2(); + pointerPositions[ event.pointerId ] = position; + + } + + position.set( event.pageX, event.pageY ); + + } + + function getSecondPointerPosition( event ) { + + const pointer = ( event.pointerId === pointers[ 0 ].pointerId ) ? pointers[ 1 ] : pointers[ 0 ]; + + return pointerPositions[ pointer.pointerId ]; + + } + + // + + scope.domElement.addEventListener( 'contextmenu', onContextMenu ); + + scope.domElement.addEventListener( 'pointerdown', onPointerDown ); + scope.domElement.addEventListener( 'pointercancel', onPointerCancel ); + scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } ); + + // force an update at start + + this.update(); + + } + +} + + +// This set of controls performs orbiting, dollying (zooming), and panning. +// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). +// This is very similar to OrbitControls, another set of touch behavior +// +// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate +// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish +// Pan - left mouse, or arrow keys / touch: one-finger move + +class MapControls extends OrbitControls { + + constructor( object, domElement ) { + + super( object, domElement ); + + this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up + + this.mouseButtons.LEFT = MOUSE.PAN; + this.mouseButtons.RIGHT = MOUSE.ROTATE; + + this.touches.ONE = TOUCH.PAN; + this.touches.TWO = TOUCH.DOLLY_ROTATE; + + } + +} + +export { OrbitControls, MapControls }; diff --git a/games/3dcity/src/jsm/loaders/DRACOLoader.js b/games/3dcity/src/jsm/loaders/DRACOLoader.js new file mode 100644 index 0000000..e9f3ca4 --- /dev/null +++ b/games/3dcity/src/jsm/loaders/DRACOLoader.js @@ -0,0 +1,587 @@ +import { + BufferAttribute, + BufferGeometry, + FileLoader, + Loader +} from '../../../build/three.module.js'; + +const _taskCache = new WeakMap(); + +class DRACOLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + this.decoderPath = ''; + this.decoderConfig = {}; + this.decoderBinary = null; + this.decoderPending = null; + + this.workerLimit = 4; + this.workerPool = []; + this.workerNextTaskID = 1; + this.workerSourceURL = ''; + + this.defaultAttributeIDs = { + position: 'POSITION', + normal: 'NORMAL', + color: 'COLOR', + uv: 'TEX_COORD' + }; + this.defaultAttributeTypes = { + position: 'Float32Array', + normal: 'Float32Array', + color: 'Float32Array', + uv: 'Float32Array' + }; + + } + + setDecoderPath( path ) { + + this.decoderPath = path; + + return this; + + } + + setDecoderConfig( config ) { + + this.decoderConfig = config; + + return this; + + } + + setWorkerLimit( workerLimit ) { + + this.workerLimit = workerLimit; + + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + const loader = new FileLoader( this.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + + loader.load( url, ( buffer ) => { + + const taskConfig = { + attributeIDs: this.defaultAttributeIDs, + attributeTypes: this.defaultAttributeTypes, + useUniqueIDs: false + }; + + this.decodeGeometry( buffer, taskConfig ) + .then( onLoad ) + .catch( onError ); + + }, onProgress, onError ); + + } + + /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */ + decodeDracoFile( buffer, callback, attributeIDs, attributeTypes ) { + + const taskConfig = { + attributeIDs: attributeIDs || this.defaultAttributeIDs, + attributeTypes: attributeTypes || this.defaultAttributeTypes, + useUniqueIDs: !! attributeIDs + }; + + this.decodeGeometry( buffer, taskConfig ).then( callback ); + + } + + decodeGeometry( buffer, taskConfig ) { + + // TODO: For backward-compatibility, support 'attributeTypes' objects containing + // references (rather than names) to typed array constructors. These must be + // serialized before sending them to the worker. + for ( const attribute in taskConfig.attributeTypes ) { + + const type = taskConfig.attributeTypes[ attribute ]; + + if ( type.BYTES_PER_ELEMENT !== undefined ) { + + taskConfig.attributeTypes[ attribute ] = type.name; + + } + + } + + // + + const taskKey = JSON.stringify( taskConfig ); + + // Check for an existing task using this buffer. A transferred buffer cannot be transferred + // again from this thread. + if ( _taskCache.has( buffer ) ) { + + const cachedTask = _taskCache.get( buffer ); + + if ( cachedTask.key === taskKey ) { + + return cachedTask.promise; + + } else if ( buffer.byteLength === 0 ) { + + // Technically, it would be possible to wait for the previous task to complete, + // transfer the buffer back, and decode again with the second configuration. That + // is complex, and I don't know of any reason to decode a Draco buffer twice in + // different ways, so this is left unimplemented. + throw new Error( + + 'THREE.DRACOLoader: Unable to re-decode a buffer with different ' + + 'settings. Buffer has already been transferred.' + + ); + + } + + } + + // + + let worker; + const taskID = this.workerNextTaskID ++; + const taskCost = buffer.byteLength; + + // Obtain a worker and assign a task, and construct a geometry instance + // when the task completes. + const geometryPending = this._getWorker( taskID, taskCost ) + .then( ( _worker ) => { + + worker = _worker; + + return new Promise( ( resolve, reject ) => { + + worker._callbacks[ taskID ] = { resolve, reject }; + + worker.postMessage( { type: 'decode', id: taskID, taskConfig, buffer }, [ buffer ] ); + + // this.debug(); + + } ); + + } ) + .then( ( message ) => this._createGeometry( message.geometry ) ); + + // Remove task from the task list. + // Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416) + geometryPending + .catch( () => true ) + .then( () => { + + if ( worker && taskID ) { + + this._releaseTask( worker, taskID ); + + // this.debug(); + + } + + } ); + + // Cache the task result. + _taskCache.set( buffer, { + + key: taskKey, + promise: geometryPending + + } ); + + return geometryPending; + + } + + _createGeometry( geometryData ) { + + const geometry = new BufferGeometry(); + + if ( geometryData.index ) { + + geometry.setIndex( new BufferAttribute( geometryData.index.array, 1 ) ); + + } + + for ( let i = 0; i < geometryData.attributes.length; i ++ ) { + + const attribute = geometryData.attributes[ i ]; + const name = attribute.name; + const array = attribute.array; + const itemSize = attribute.itemSize; + + geometry.setAttribute( name, new BufferAttribute( array, itemSize ) ); + + } + + return geometry; + + } + + _loadLibrary( url, responseType ) { + + const loader = new FileLoader( this.manager ); + loader.setPath( this.decoderPath ); + loader.setResponseType( responseType ); + loader.setWithCredentials( this.withCredentials ); + + return new Promise( ( resolve, reject ) => { + + loader.load( url, resolve, undefined, reject ); + + } ); + + } + + preload() { + + this._initDecoder(); + + return this; + + } + + _initDecoder() { + + if ( this.decoderPending ) return this.decoderPending; + + const useJS = typeof WebAssembly !== 'object' || this.decoderConfig.type === 'js'; + const librariesPending = []; + + if ( useJS ) { + + librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) ); + + } else { + + librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) ); + librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) ); + + } + + this.decoderPending = Promise.all( librariesPending ) + .then( ( libraries ) => { + + const jsContent = libraries[ 0 ]; + + if ( ! useJS ) { + + this.decoderConfig.wasmBinary = libraries[ 1 ]; + + } + + const fn = DRACOWorker.toString(); + + const body = [ + '/* draco decoder */', + jsContent, + '', + '/* worker */', + fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) + ].join( '\n' ); + + this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) ); + + } ); + + return this.decoderPending; + + } + + _getWorker( taskID, taskCost ) { + + return this._initDecoder().then( () => { + + if ( this.workerPool.length < this.workerLimit ) { + + const worker = new Worker( this.workerSourceURL ); + + worker._callbacks = {}; + worker._taskCosts = {}; + worker._taskLoad = 0; + + worker.postMessage( { type: 'init', decoderConfig: this.decoderConfig } ); + + worker.onmessage = function ( e ) { + + const message = e.data; + + switch ( message.type ) { + + case 'decode': + worker._callbacks[ message.id ].resolve( message ); + break; + + case 'error': + worker._callbacks[ message.id ].reject( message ); + break; + + default: + console.error( 'THREE.DRACOLoader: Unexpected message, "' + message.type + '"' ); + + } + + }; + + this.workerPool.push( worker ); + + } else { + + this.workerPool.sort( function ( a, b ) { + + return a._taskLoad > b._taskLoad ? - 1 : 1; + + } ); + + } + + const worker = this.workerPool[ this.workerPool.length - 1 ]; + worker._taskCosts[ taskID ] = taskCost; + worker._taskLoad += taskCost; + return worker; + + } ); + + } + + _releaseTask( worker, taskID ) { + + worker._taskLoad -= worker._taskCosts[ taskID ]; + delete worker._callbacks[ taskID ]; + delete worker._taskCosts[ taskID ]; + + } + + debug() { + + console.log( 'Task load: ', this.workerPool.map( ( worker ) => worker._taskLoad ) ); + + } + + dispose() { + + for ( let i = 0; i < this.workerPool.length; ++ i ) { + + this.workerPool[ i ].terminate(); + + } + + this.workerPool.length = 0; + + return this; + + } + +} + +/* WEB WORKER */ + +function DRACOWorker() { + + let decoderConfig; + let decoderPending; + + onmessage = function ( e ) { + + const message = e.data; + + switch ( message.type ) { + + case 'init': + decoderConfig = message.decoderConfig; + decoderPending = new Promise( function ( resolve/*, reject*/ ) { + + decoderConfig.onModuleLoaded = function ( draco ) { + + // Module is Promise-like. Wrap before resolving to avoid loop. + resolve( { draco: draco } ); + + }; + + DracoDecoderModule( decoderConfig ); // eslint-disable-line no-undef + + } ); + break; + + case 'decode': + const buffer = message.buffer; + const taskConfig = message.taskConfig; + decoderPending.then( ( module ) => { + + const draco = module.draco; + const decoder = new draco.Decoder(); + const decoderBuffer = new draco.DecoderBuffer(); + decoderBuffer.Init( new Int8Array( buffer ), buffer.byteLength ); + + try { + + const geometry = decodeGeometry( draco, decoder, decoderBuffer, taskConfig ); + + const buffers = geometry.attributes.map( ( attr ) => attr.array.buffer ); + + if ( geometry.index ) buffers.push( geometry.index.array.buffer ); + + self.postMessage( { type: 'decode', id: message.id, geometry }, buffers ); + + } catch ( error ) { + + console.error( error ); + + self.postMessage( { type: 'error', id: message.id, error: error.message } ); + + } finally { + + draco.destroy( decoderBuffer ); + draco.destroy( decoder ); + + } + + } ); + break; + + } + + }; + + function decodeGeometry( draco, decoder, decoderBuffer, taskConfig ) { + + const attributeIDs = taskConfig.attributeIDs; + const attributeTypes = taskConfig.attributeTypes; + + let dracoGeometry; + let decodingStatus; + + const geometryType = decoder.GetEncodedGeometryType( decoderBuffer ); + + if ( geometryType === draco.TRIANGULAR_MESH ) { + + dracoGeometry = new draco.Mesh(); + decodingStatus = decoder.DecodeBufferToMesh( decoderBuffer, dracoGeometry ); + + } else if ( geometryType === draco.POINT_CLOUD ) { + + dracoGeometry = new draco.PointCloud(); + decodingStatus = decoder.DecodeBufferToPointCloud( decoderBuffer, dracoGeometry ); + + } else { + + throw new Error( 'THREE.DRACOLoader: Unexpected geometry type.' ); + + } + + if ( ! decodingStatus.ok() || dracoGeometry.ptr === 0 ) { + + throw new Error( 'THREE.DRACOLoader: Decoding failed: ' + decodingStatus.error_msg() ); + + } + + const geometry = { index: null, attributes: [] }; + + // Gather all vertex attributes. + for ( const attributeName in attributeIDs ) { + + const attributeType = self[ attributeTypes[ attributeName ] ]; + + let attribute; + let attributeID; + + // A Draco file may be created with default vertex attributes, whose attribute IDs + // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively, + // a Draco file may contain a custom set of attributes, identified by known unique + // IDs. glTF files always do the latter, and `.drc` files typically do the former. + if ( taskConfig.useUniqueIDs ) { + + attributeID = attributeIDs[ attributeName ]; + attribute = decoder.GetAttributeByUniqueId( dracoGeometry, attributeID ); + + } else { + + attributeID = decoder.GetAttributeId( dracoGeometry, draco[ attributeIDs[ attributeName ] ] ); + + if ( attributeID === - 1 ) continue; + + attribute = decoder.GetAttribute( dracoGeometry, attributeID ); + + } + + geometry.attributes.push( decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) ); + + } + + // Add index. + if ( geometryType === draco.TRIANGULAR_MESH ) { + + geometry.index = decodeIndex( draco, decoder, dracoGeometry ); + + } + + draco.destroy( dracoGeometry ); + + return geometry; + + } + + function decodeIndex( draco, decoder, dracoGeometry ) { + + const numFaces = dracoGeometry.num_faces(); + const numIndices = numFaces * 3; + const byteLength = numIndices * 4; + + const ptr = draco._malloc( byteLength ); + decoder.GetTrianglesUInt32Array( dracoGeometry, byteLength, ptr ); + const index = new Uint32Array( draco.HEAPF32.buffer, ptr, numIndices ).slice(); + draco._free( ptr ); + + return { array: index, itemSize: 1 }; + + } + + function decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) { + + const numComponents = attribute.num_components(); + const numPoints = dracoGeometry.num_points(); + const numValues = numPoints * numComponents; + const byteLength = numValues * attributeType.BYTES_PER_ELEMENT; + const dataType = getDracoDataType( draco, attributeType ); + + const ptr = draco._malloc( byteLength ); + decoder.GetAttributeDataArrayForAllPoints( dracoGeometry, attribute, dataType, byteLength, ptr ); + const array = new attributeType( draco.HEAPF32.buffer, ptr, numValues ).slice(); + draco._free( ptr ); + + return { + name: attributeName, + array: array, + itemSize: numComponents + }; + + } + + function getDracoDataType( draco, attributeType ) { + + switch ( attributeType ) { + + case Float32Array: return draco.DT_FLOAT32; + case Int8Array: return draco.DT_INT8; + case Int16Array: return draco.DT_INT16; + case Int32Array: return draco.DT_INT32; + case Uint8Array: return draco.DT_UINT8; + case Uint16Array: return draco.DT_UINT16; + case Uint32Array: return draco.DT_UINT32; + + } + + } + +} + +export { DRACOLoader }; diff --git a/games/3dcity/src/jsm/loaders/GLTFLoader.js b/games/3dcity/src/jsm/loaders/GLTFLoader.js new file mode 100644 index 0000000..a04bb70 --- /dev/null +++ b/games/3dcity/src/jsm/loaders/GLTFLoader.js @@ -0,0 +1,4347 @@ +import { + AnimationClip, + Bone, + Box3, + BufferAttribute, + BufferGeometry, + ClampToEdgeWrapping, + Color, + DirectionalLight, + DoubleSide, + FileLoader, + FrontSide, + Group, + ImageBitmapLoader, + InterleavedBuffer, + InterleavedBufferAttribute, + Interpolant, + InterpolateDiscrete, + InterpolateLinear, + Line, + LineBasicMaterial, + LineLoop, + LineSegments, + LinearFilter, + LinearMipmapLinearFilter, + LinearMipmapNearestFilter, + Loader, + LoaderUtils, + Material, + MathUtils, + Matrix4, + Mesh, + MeshBasicMaterial, + MeshPhysicalMaterial, + MeshStandardMaterial, + MirroredRepeatWrapping, + NearestFilter, + NearestMipmapLinearFilter, + NearestMipmapNearestFilter, + NumberKeyframeTrack, + Object3D, + OrthographicCamera, + PerspectiveCamera, + PointLight, + Points, + PointsMaterial, + PropertyBinding, + Quaternion, + QuaternionKeyframeTrack, + RepeatWrapping, + Skeleton, + SkinnedMesh, + Sphere, + SpotLight, + TangentSpaceNormalMap, + Texture, + TextureLoader, + TriangleFanDrawMode, + TriangleStripDrawMode, + Vector2, + Vector3, + VectorKeyframeTrack, + sRGBEncoding +} from '../../../build/three.module.js'; + +class GLTFLoader extends Loader { + + constructor( manager ) { + + super( manager ); + + this.dracoLoader = null; + this.ktx2Loader = null; + this.meshoptDecoder = null; + + this.pluginCallbacks = []; + + this.register( function ( parser ) { + + return new GLTFMaterialsClearcoatExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFTextureBasisUExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFTextureWebPExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsSheenExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsTransmissionExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsVolumeExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsIorExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMaterialsSpecularExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFLightsExtension( parser ); + + } ); + + this.register( function ( parser ) { + + return new GLTFMeshoptCompression( parser ); + + } ); + + } + + load( url, onLoad, onProgress, onError ) { + + const scope = this; + + let resourcePath; + + if ( this.resourcePath !== '' ) { + + resourcePath = this.resourcePath; + + } else if ( this.path !== '' ) { + + resourcePath = this.path; + + } else { + + resourcePath = LoaderUtils.extractUrlBase( url ); + + } + + // Tells the LoadingManager to track an extra item, which resolves after + // the model is fully loaded. This means the count of items loaded will + // be incorrect, but ensures manager.onLoad() does not fire early. + this.manager.itemStart( url ); + + const _onError = function ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemError( url ); + scope.manager.itemEnd( url ); + + }; + + const loader = new FileLoader( this.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); + + loader.load( url, function ( data ) { + + try { + + scope.parse( data, resourcePath, function ( gltf ) { + + onLoad( gltf ); + + scope.manager.itemEnd( url ); + + }, _onError ); + + } catch ( e ) { + + _onError( e ); + + } + + }, onProgress, _onError ); + + } + + setDRACOLoader( dracoLoader ) { + + this.dracoLoader = dracoLoader; + return this; + + } + + setDDSLoader() { + + throw new Error( + + 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".' + + ); + + } + + setKTX2Loader( ktx2Loader ) { + + this.ktx2Loader = ktx2Loader; + return this; + + } + + setMeshoptDecoder( meshoptDecoder ) { + + this.meshoptDecoder = meshoptDecoder; + return this; + + } + + register( callback ) { + + if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) { + + this.pluginCallbacks.push( callback ); + + } + + return this; + + } + + unregister( callback ) { + + if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) { + + this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 ); + + } + + return this; + + } + + parse( data, path, onLoad, onError ) { + + let content; + const extensions = {}; + const plugins = {}; + + if ( typeof data === 'string' ) { + + content = data; + + } else { + + const magic = LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) ); + + if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) { + + try { + + extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); + + } catch ( error ) { + + if ( onError ) onError( error ); + return; + + } + + content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; + + } else { + + content = LoaderUtils.decodeText( new Uint8Array( data ) ); + + } + + } + + const json = JSON.parse( content ); + + if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) { + + if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) ); + return; + + } + + const parser = new GLTFParser( json, { + + path: path || this.resourcePath || '', + crossOrigin: this.crossOrigin, + requestHeader: this.requestHeader, + manager: this.manager, + ktx2Loader: this.ktx2Loader, + meshoptDecoder: this.meshoptDecoder + + } ); + + parser.fileLoader.setRequestHeader( this.requestHeader ); + + for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) { + + const plugin = this.pluginCallbacks[ i ]( parser ); + plugins[ plugin.name ] = plugin; + + // Workaround to avoid determining as unknown extension + // in addUnknownExtensionsToUserData(). + // Remove this workaround if we move all the existing + // extension handlers to plugin system + extensions[ plugin.name ] = true; + + } + + if ( json.extensionsUsed ) { + + for ( let i = 0; i < json.extensionsUsed.length; ++ i ) { + + const extensionName = json.extensionsUsed[ i ]; + const extensionsRequired = json.extensionsRequired || []; + + switch ( extensionName ) { + + case EXTENSIONS.KHR_MATERIALS_UNLIT: + extensions[ extensionName ] = new GLTFMaterialsUnlitExtension(); + break; + + case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: + extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension(); + break; + + case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION: + extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader ); + break; + + case EXTENSIONS.KHR_TEXTURE_TRANSFORM: + extensions[ extensionName ] = new GLTFTextureTransformExtension(); + break; + + case EXTENSIONS.KHR_MESH_QUANTIZATION: + extensions[ extensionName ] = new GLTFMeshQuantizationExtension(); + break; + + default: + + if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) { + + console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' ); + + } + + } + + } + + } + + parser.setExtensions( extensions ); + parser.setPlugins( plugins ); + parser.parse( onLoad, onError ); + + } + + parseAsync( data, path ) { + + const scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.parse( data, path, resolve, reject ); + + } ); + + } + +} + +/* GLTFREGISTRY */ + +function GLTFRegistry() { + + let objects = {}; + + return { + + get: function ( key ) { + + return objects[ key ]; + + }, + + add: function ( key, object ) { + + objects[ key ] = object; + + }, + + remove: function ( key ) { + + delete objects[ key ]; + + }, + + removeAll: function () { + + objects = {}; + + } + + }; + +} + +/*********************************/ +/********** EXTENSIONS ***********/ +/*********************************/ + +const EXTENSIONS = { + KHR_BINARY_GLTF: 'KHR_binary_glTF', + KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression', + KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual', + KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat', + KHR_MATERIALS_IOR: 'KHR_materials_ior', + KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness', + KHR_MATERIALS_SHEEN: 'KHR_materials_sheen', + KHR_MATERIALS_SPECULAR: 'KHR_materials_specular', + KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission', + KHR_MATERIALS_UNLIT: 'KHR_materials_unlit', + KHR_MATERIALS_VOLUME: 'KHR_materials_volume', + KHR_TEXTURE_BASISU: 'KHR_texture_basisu', + KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform', + KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization', + EXT_TEXTURE_WEBP: 'EXT_texture_webp', + EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression' +}; + +/** + * Punctual Lights Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual + */ +class GLTFLightsExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL; + + // Object3D instance caches + this.cache = { refs: {}, uses: {} }; + + } + + _markDefs() { + + const parser = this.parser; + const nodeDefs = this.parser.json.nodes || []; + + for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) { + + const nodeDef = nodeDefs[ nodeIndex ]; + + if ( nodeDef.extensions + && nodeDef.extensions[ this.name ] + && nodeDef.extensions[ this.name ].light !== undefined ) { + + parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light ); + + } + + } + + } + + _loadLight( lightIndex ) { + + const parser = this.parser; + const cacheKey = 'light:' + lightIndex; + let dependency = parser.cache.get( cacheKey ); + + if ( dependency ) return dependency; + + const json = parser.json; + const extensions = ( json.extensions && json.extensions[ this.name ] ) || {}; + const lightDefs = extensions.lights || []; + const lightDef = lightDefs[ lightIndex ]; + let lightNode; + + const color = new Color( 0xffffff ); + + if ( lightDef.color !== undefined ) color.fromArray( lightDef.color ); + + const range = lightDef.range !== undefined ? lightDef.range : 0; + + switch ( lightDef.type ) { + + case 'directional': + lightNode = new DirectionalLight( color ); + lightNode.target.position.set( 0, 0, - 1 ); + lightNode.add( lightNode.target ); + break; + + case 'point': + lightNode = new PointLight( color ); + lightNode.distance = range; + break; + + case 'spot': + lightNode = new SpotLight( color ); + lightNode.distance = range; + // Handle spotlight properties. + lightDef.spot = lightDef.spot || {}; + lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0; + lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0; + lightNode.angle = lightDef.spot.outerConeAngle; + lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle; + lightNode.target.position.set( 0, 0, - 1 ); + lightNode.add( lightNode.target ); + break; + + default: + throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type ); + + } + + // Some lights (e.g. spot) default to a position other than the origin. Reset the position + // here, because node-level parsing will only override position if explicitly specified. + lightNode.position.set( 0, 0, 0 ); + + lightNode.decay = 2; + + if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity; + + lightNode.name = parser.createUniqueName( lightDef.name || ( 'light_' + lightIndex ) ); + + dependency = Promise.resolve( lightNode ); + + parser.cache.add( cacheKey, dependency ); + + return dependency; + + } + + createNodeAttachment( nodeIndex ) { + + const self = this; + const parser = this.parser; + const json = parser.json; + const nodeDef = json.nodes[ nodeIndex ]; + const lightDef = ( nodeDef.extensions && nodeDef.extensions[ this.name ] ) || {}; + const lightIndex = lightDef.light; + + if ( lightIndex === undefined ) return null; + + return this._loadLight( lightIndex ).then( function ( light ) { + + return parser._getNodeRef( self.cache, lightIndex, light ); + + } ); + + } + +} + +/** + * Unlit Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit + */ +class GLTFMaterialsUnlitExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MATERIALS_UNLIT; + + } + + getMaterialType() { + + return MeshBasicMaterial; + + } + + extendParams( materialParams, materialDef, parser ) { + + const pending = []; + + materialParams.color = new Color( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + const metallicRoughness = materialDef.pbrMetallicRoughness; + + if ( metallicRoughness ) { + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + const array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) ); + + } + + } + + return Promise.all( pending ); + + } + +} + +/** + * Clearcoat Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat + */ +class GLTFMaterialsClearcoatExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.clearcoatFactor !== undefined ) { + + materialParams.clearcoat = extension.clearcoatFactor; + + } + + if ( extension.clearcoatTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) ); + + } + + if ( extension.clearcoatRoughnessFactor !== undefined ) { + + materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor; + + } + + if ( extension.clearcoatRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) ); + + } + + if ( extension.clearcoatNormalTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) ); + + if ( extension.clearcoatNormalTexture.scale !== undefined ) { + + const scale = extension.clearcoatNormalTexture.scale; + + materialParams.clearcoatNormalScale = new Vector2( scale, scale ); + + } + + } + + return Promise.all( pending ); + + } + +} + +/** + * Sheen Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen + */ +class GLTFMaterialsSheenExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_SHEEN; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + materialParams.sheenColor = new Color( 0, 0, 0 ); + materialParams.sheenRoughness = 0; + materialParams.sheen = 1; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.sheenColorFactor !== undefined ) { + + materialParams.sheenColor.fromArray( extension.sheenColorFactor ); + + } + + if ( extension.sheenRoughnessFactor !== undefined ) { + + materialParams.sheenRoughness = extension.sheenRoughnessFactor; + + } + + if ( extension.sheenColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture ) ); + + } + + if ( extension.sheenRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * Transmission Materials Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission + * Draft: https://github.com/KhronosGroup/glTF/pull/1698 + */ +class GLTFMaterialsTransmissionExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + if ( extension.transmissionFactor !== undefined ) { + + materialParams.transmission = extension.transmissionFactor; + + } + + if ( extension.transmissionTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * Materials Volume Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume + */ +class GLTFMaterialsVolumeExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_VOLUME; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0; + + if ( extension.thicknessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) ); + + } + + materialParams.attenuationDistance = extension.attenuationDistance || 0; + + const colorArray = extension.attenuationColor || [ 1, 1, 1 ]; + materialParams.attenuationColor = new Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] ); + + return Promise.all( pending ); + + } + +} + +/** + * Materials ior Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior + */ +class GLTFMaterialsIorExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_IOR; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const extension = materialDef.extensions[ this.name ]; + + materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5; + + return Promise.resolve(); + + } + +} + +/** + * Materials specular Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular + */ +class GLTFMaterialsSpecularExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR; + + } + + getMaterialType( materialIndex ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null; + + return MeshPhysicalMaterial; + + } + + extendMaterialParams( materialIndex, materialParams ) { + + const parser = this.parser; + const materialDef = parser.json.materials[ materialIndex ]; + + if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) { + + return Promise.resolve(); + + } + + const pending = []; + + const extension = materialDef.extensions[ this.name ]; + + materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0; + + if ( extension.specularTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) ); + + } + + const colorArray = extension.specularColorFactor || [ 1, 1, 1 ]; + materialParams.specularColor = new Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] ); + + if ( extension.specularColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture ).then( function ( texture ) { + + texture.encoding = sRGBEncoding; + + } ) ); + + } + + return Promise.all( pending ); + + } + +} + +/** + * BasisU Texture Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu + */ +class GLTFTextureBasisUExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.KHR_TEXTURE_BASISU; + + } + + loadTexture( textureIndex ) { + + const parser = this.parser; + const json = parser.json; + + const textureDef = json.textures[ textureIndex ]; + + if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) { + + return null; + + } + + const extension = textureDef.extensions[ this.name ]; + const source = json.images[ extension.source ]; + const loader = parser.options.ktx2Loader; + + if ( ! loader ) { + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' ); + + } else { + + // Assumes that the extension is optional and that a fallback texture is present + return null; + + } + + } + + return parser.loadTextureImage( textureIndex, source, loader ); + + } + +} + +/** + * WebP Texture Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp + */ +class GLTFTextureWebPExtension { + + constructor( parser ) { + + this.parser = parser; + this.name = EXTENSIONS.EXT_TEXTURE_WEBP; + this.isSupported = null; + + } + + loadTexture( textureIndex ) { + + const name = this.name; + const parser = this.parser; + const json = parser.json; + + const textureDef = json.textures[ textureIndex ]; + + if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) { + + return null; + + } + + const extension = textureDef.extensions[ name ]; + const source = json.images[ extension.source ]; + + let loader = parser.textureLoader; + if ( source.uri ) { + + const handler = parser.options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; + + } + + return this.detectSupport().then( function ( isSupported ) { + + if ( isSupported ) return parser.loadTextureImage( textureIndex, source, loader ); + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' ); + + } + + // Fall back to PNG or JPEG. + return parser.loadTexture( textureIndex ); + + } ); + + } + + detectSupport() { + + if ( ! this.isSupported ) { + + this.isSupported = new Promise( function ( resolve ) { + + const image = new Image(); + + // Lossy test image. Support for lossy images doesn't guarantee support for all + // WebP images, unfortunately. + image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA'; + + image.onload = image.onerror = function () { + + resolve( image.height === 1 ); + + }; + + } ); + + } + + return this.isSupported; + + } + +} + +/** + * meshopt BufferView Compression Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression + */ +class GLTFMeshoptCompression { + + constructor( parser ) { + + this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION; + this.parser = parser; + + } + + loadBufferView( index ) { + + const json = this.parser.json; + const bufferView = json.bufferViews[ index ]; + + if ( bufferView.extensions && bufferView.extensions[ this.name ] ) { + + const extensionDef = bufferView.extensions[ this.name ]; + + const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer ); + const decoder = this.parser.options.meshoptDecoder; + + if ( ! decoder || ! decoder.supported ) { + + if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) { + + throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' ); + + } else { + + // Assumes that the extension is optional and that fallback buffer data is present + return null; + + } + + } + + return Promise.all( [ buffer, decoder.ready ] ).then( function ( res ) { + + const byteOffset = extensionDef.byteOffset || 0; + const byteLength = extensionDef.byteLength || 0; + + const count = extensionDef.count; + const stride = extensionDef.byteStride; + + const result = new ArrayBuffer( count * stride ); + const source = new Uint8Array( res[ 0 ], byteOffset, byteLength ); + + decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter ); + return result; + + } ); + + } else { + + return null; + + } + + } + +} + +/* BINARY EXTENSION */ +const BINARY_EXTENSION_HEADER_MAGIC = 'glTF'; +const BINARY_EXTENSION_HEADER_LENGTH = 12; +const BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 }; + +class GLTFBinaryExtension { + + constructor( data ) { + + this.name = EXTENSIONS.KHR_BINARY_GLTF; + this.content = null; + this.body = null; + + const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH ); + + this.header = { + magic: LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ), + version: headerView.getUint32( 4, true ), + length: headerView.getUint32( 8, true ) + }; + + if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) { + + throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' ); + + } else if ( this.header.version < 2.0 ) { + + throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' ); + + } + + const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH; + const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH ); + let chunkIndex = 0; + + while ( chunkIndex < chunkContentsLength ) { + + const chunkLength = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + const chunkType = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) { + + const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength ); + this.content = LoaderUtils.decodeText( contentArray ); + + } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) { + + const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex; + this.body = data.slice( byteOffset, byteOffset + chunkLength ); + + } + + // Clients must ignore chunks with unknown types. + + chunkIndex += chunkLength; + + } + + if ( this.content === null ) { + + throw new Error( 'THREE.GLTFLoader: JSON content not found.' ); + + } + + } + +} + +/** + * DRACO Mesh Compression Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression + */ +class GLTFDracoMeshCompressionExtension { + + constructor( json, dracoLoader ) { + + if ( ! dracoLoader ) { + + throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' ); + + } + + this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION; + this.json = json; + this.dracoLoader = dracoLoader; + this.dracoLoader.preload(); + + } + + decodePrimitive( primitive, parser ) { + + const json = this.json; + const dracoLoader = this.dracoLoader; + const bufferViewIndex = primitive.extensions[ this.name ].bufferView; + const gltfAttributeMap = primitive.extensions[ this.name ].attributes; + const threeAttributeMap = {}; + const attributeNormalizedMap = {}; + const attributeTypeMap = {}; + + for ( const attributeName in gltfAttributeMap ) { + + const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase(); + + threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ]; + + } + + for ( const attributeName in primitive.attributes ) { + + const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase(); + + if ( gltfAttributeMap[ attributeName ] !== undefined ) { + + const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ]; + const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + attributeTypeMap[ threeAttributeName ] = componentType; + attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true; + + } + + } + + return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) { + + return new Promise( function ( resolve ) { + + dracoLoader.decodeDracoFile( bufferView, function ( geometry ) { + + for ( const attributeName in geometry.attributes ) { + + const attribute = geometry.attributes[ attributeName ]; + const normalized = attributeNormalizedMap[ attributeName ]; + + if ( normalized !== undefined ) attribute.normalized = normalized; + + } + + resolve( geometry ); + + }, threeAttributeMap, attributeTypeMap ); + + } ); + + } ); + + } + +} + +/** + * Texture Transform Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform + */ +class GLTFTextureTransformExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM; + + } + + extendTexture( texture, transform ) { + + if ( transform.texCoord !== undefined ) { + + console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' ); + + } + + if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) { + + // See https://github.com/mrdoob/three.js/issues/21819. + return texture; + + } + + texture = texture.clone(); + + if ( transform.offset !== undefined ) { + + texture.offset.fromArray( transform.offset ); + + } + + if ( transform.rotation !== undefined ) { + + texture.rotation = transform.rotation; + + } + + if ( transform.scale !== undefined ) { + + texture.repeat.fromArray( transform.scale ); + + } + + texture.needsUpdate = true; + + return texture; + + } + +} + +/** + * Specular-Glossiness Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness + */ + +/** + * A sub class of StandardMaterial with some of the functionality + * changed via the `onBeforeCompile` callback + * @pailhead + */ +class GLTFMeshStandardSGMaterial extends MeshStandardMaterial { + + constructor( params ) { + + super(); + + this.isGLTFSpecularGlossinessMaterial = true; + + //various chunks that need replacing + const specularMapParsFragmentChunk = [ + '#ifdef USE_SPECULARMAP', + ' uniform sampler2D specularMap;', + '#endif' + ].join( '\n' ); + + const glossinessMapParsFragmentChunk = [ + '#ifdef USE_GLOSSINESSMAP', + ' uniform sampler2D glossinessMap;', + '#endif' + ].join( '\n' ); + + const specularMapFragmentChunk = [ + 'vec3 specularFactor = specular;', + '#ifdef USE_SPECULARMAP', + ' vec4 texelSpecular = texture2D( specularMap, vUv );', + ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' specularFactor *= texelSpecular.rgb;', + '#endif' + ].join( '\n' ); + + const glossinessMapFragmentChunk = [ + 'float glossinessFactor = glossiness;', + '#ifdef USE_GLOSSINESSMAP', + ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', + ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' glossinessFactor *= texelGlossiness.a;', + '#endif' + ].join( '\n' ); + + const lightPhysicalFragmentChunk = [ + 'PhysicalMaterial material;', + 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', + 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', + 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', + 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', + 'material.roughness += geometryRoughness;', + 'material.roughness = min( material.roughness, 1.0 );', + 'material.specularColor = specularFactor;', + ].join( '\n' ); + + const uniforms = { + specular: { value: new Color().setHex( 0xffffff ) }, + glossiness: { value: 1 }, + specularMap: { value: null }, + glossinessMap: { value: null } + }; + + this._extraUniforms = uniforms; + + this.onBeforeCompile = function ( shader ) { + + for ( const uniformName in uniforms ) { + + shader.uniforms[ uniformName ] = uniforms[ uniformName ]; + + } + + shader.fragmentShader = shader.fragmentShader + .replace( 'uniform float roughness;', 'uniform vec3 specular;' ) + .replace( 'uniform float metalness;', 'uniform float glossiness;' ) + .replace( '#include ', specularMapParsFragmentChunk ) + .replace( '#include ', glossinessMapParsFragmentChunk ) + .replace( '#include ', specularMapFragmentChunk ) + .replace( '#include ', glossinessMapFragmentChunk ) + .replace( '#include ', lightPhysicalFragmentChunk ); + + }; + + Object.defineProperties( this, { + + specular: { + get: function () { + + return uniforms.specular.value; + + }, + set: function ( v ) { + + uniforms.specular.value = v; + + } + }, + + specularMap: { + get: function () { + + return uniforms.specularMap.value; + + }, + set: function ( v ) { + + uniforms.specularMap.value = v; + + if ( v ) { + + this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps + + } else { + + delete this.defines.USE_SPECULARMAP; + + } + + } + }, + + glossiness: { + get: function () { + + return uniforms.glossiness.value; + + }, + set: function ( v ) { + + uniforms.glossiness.value = v; + + } + }, + + glossinessMap: { + get: function () { + + return uniforms.glossinessMap.value; + + }, + set: function ( v ) { + + uniforms.glossinessMap.value = v; + + if ( v ) { + + this.defines.USE_GLOSSINESSMAP = ''; + this.defines.USE_UV = ''; + + } else { + + delete this.defines.USE_GLOSSINESSMAP; + delete this.defines.USE_UV; + + } + + } + } + + } ); + + delete this.metalness; + delete this.roughness; + delete this.metalnessMap; + delete this.roughnessMap; + + this.setValues( params ); + + } + + copy( source ) { + + super.copy( source ); + + this.specularMap = source.specularMap; + this.specular.copy( source.specular ); + this.glossinessMap = source.glossinessMap; + this.glossiness = source.glossiness; + delete this.metalness; + delete this.roughness; + delete this.metalnessMap; + delete this.roughnessMap; + return this; + + } + +} + + +class GLTFMaterialsPbrSpecularGlossinessExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS; + + this.specularGlossinessParams = [ + 'color', + 'map', + 'lightMap', + 'lightMapIntensity', + 'aoMap', + 'aoMapIntensity', + 'emissive', + 'emissiveIntensity', + 'emissiveMap', + 'bumpMap', + 'bumpScale', + 'normalMap', + 'normalMapType', + 'displacementMap', + 'displacementScale', + 'displacementBias', + 'specularMap', + 'specular', + 'glossinessMap', + 'glossiness', + 'alphaMap', + 'envMap', + 'envMapIntensity', + 'refractionRatio', + ]; + + } + + getMaterialType() { + + return GLTFMeshStandardSGMaterial; + + } + + extendParams( materialParams, materialDef, parser ) { + + const pbrSpecularGlossiness = materialDef.extensions[ this.name ]; + + materialParams.color = new Color( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + const pending = []; + + if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) { + + const array = pbrSpecularGlossiness.diffuseFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture ) ); + + } + + materialParams.emissive = new Color( 0.0, 0.0, 0.0 ); + materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0; + materialParams.specular = new Color( 1.0, 1.0, 1.0 ); + + if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) { + + materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor ); + + } + + if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) { + + const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture; + pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) ); + pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef ) ); + + } + + return Promise.all( pending ); + + } + + createMaterial( materialParams ) { + + const material = new GLTFMeshStandardSGMaterial( materialParams ); + material.fog = true; + + material.color = materialParams.color; + + material.map = materialParams.map === undefined ? null : materialParams.map; + + material.lightMap = null; + material.lightMapIntensity = 1.0; + + material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap; + material.aoMapIntensity = 1.0; + + material.emissive = materialParams.emissive; + material.emissiveIntensity = 1.0; + material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap; + + material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap; + material.bumpScale = 1; + + material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap; + material.normalMapType = TangentSpaceNormalMap; + + if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale; + + material.displacementMap = null; + material.displacementScale = 1; + material.displacementBias = 0; + + material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap; + material.specular = materialParams.specular; + + material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap; + material.glossiness = materialParams.glossiness; + + material.alphaMap = null; + + material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap; + material.envMapIntensity = 1.0; + + material.refractionRatio = 0.98; + + return material; + + } + +} + +/** + * Mesh Quantization Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization + */ +class GLTFMeshQuantizationExtension { + + constructor() { + + this.name = EXTENSIONS.KHR_MESH_QUANTIZATION; + + } + +} + +/*********************************/ +/********** INTERPOLATION ********/ +/*********************************/ + +// Spline Interpolation +// Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation +class GLTFCubicSplineInterpolant extends Interpolant { + + constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + super( parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + copySampleValue_( index ) { + + // Copies a sample value to the result buffer. See description of glTF + // CUBICSPLINE values layout in interpolate_() function below. + + const result = this.resultBuffer, + values = this.sampleValues, + valueSize = this.valueSize, + offset = index * valueSize * 3 + valueSize; + + for ( let i = 0; i !== valueSize; i ++ ) { + + result[ i ] = values[ offset + i ]; + + } + + return result; + + } + +} + +GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + +GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + +GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) { + + const result = this.resultBuffer; + const values = this.sampleValues; + const stride = this.valueSize; + + const stride2 = stride * 2; + const stride3 = stride * 3; + + const td = t1 - t0; + + const p = ( t - t0 ) / td; + const pp = p * p; + const ppp = pp * p; + + const offset1 = i1 * stride3; + const offset0 = offset1 - stride3; + + const s2 = - 2 * ppp + 3 * pp; + const s3 = ppp - pp; + const s0 = 1 - s2; + const s1 = s3 - pp + p; + + // Layout of keyframe output values for CUBICSPLINE animations: + // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ] + for ( let i = 0; i !== stride; i ++ ) { + + const p0 = values[ offset0 + i + stride ]; // splineVertex_k + const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k) + const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1 + const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k) + + result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1; + + } + + return result; + +}; + +const _q = new Quaternion(); + +class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant { + + interpolate_( i1, t0, t, t1 ) { + + const result = super.interpolate_( i1, t0, t, t1 ); + + _q.fromArray( result ).normalize().toArray( result ); + + return result; + + } + +} + + +/*********************************/ +/********** INTERNALS ************/ +/*********************************/ + +/* CONSTANTS */ + +const WEBGL_CONSTANTS = { + FLOAT: 5126, + //FLOAT_MAT2: 35674, + FLOAT_MAT3: 35675, + FLOAT_MAT4: 35676, + FLOAT_VEC2: 35664, + FLOAT_VEC3: 35665, + FLOAT_VEC4: 35666, + LINEAR: 9729, + REPEAT: 10497, + SAMPLER_2D: 35678, + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6, + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123 +}; + +const WEBGL_COMPONENT_TYPES = { + 5120: Int8Array, + 5121: Uint8Array, + 5122: Int16Array, + 5123: Uint16Array, + 5125: Uint32Array, + 5126: Float32Array +}; + +const WEBGL_FILTERS = { + 9728: NearestFilter, + 9729: LinearFilter, + 9984: NearestMipmapNearestFilter, + 9985: LinearMipmapNearestFilter, + 9986: NearestMipmapLinearFilter, + 9987: LinearMipmapLinearFilter +}; + +const WEBGL_WRAPPINGS = { + 33071: ClampToEdgeWrapping, + 33648: MirroredRepeatWrapping, + 10497: RepeatWrapping +}; + +const WEBGL_TYPE_SIZES = { + 'SCALAR': 1, + 'VEC2': 2, + 'VEC3': 3, + 'VEC4': 4, + 'MAT2': 4, + 'MAT3': 9, + 'MAT4': 16 +}; + +const ATTRIBUTES = { + POSITION: 'position', + NORMAL: 'normal', + TANGENT: 'tangent', + TEXCOORD_0: 'uv', + TEXCOORD_1: 'uv2', + COLOR_0: 'color', + WEIGHTS_0: 'skinWeight', + JOINTS_0: 'skinIndex', +}; + +const PATH_PROPERTIES = { + scale: 'scale', + translation: 'position', + rotation: 'quaternion', + weights: 'morphTargetInfluences' +}; + +const INTERPOLATION = { + CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each + // keyframe track will be initialized with a default interpolation type, then modified. + LINEAR: InterpolateLinear, + STEP: InterpolateDiscrete +}; + +const ALPHA_MODES = { + OPAQUE: 'OPAQUE', + MASK: 'MASK', + BLEND: 'BLEND' +}; + +/** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material + */ +function createDefaultMaterial( cache ) { + + if ( cache[ 'DefaultMaterial' ] === undefined ) { + + cache[ 'DefaultMaterial' ] = new MeshStandardMaterial( { + color: 0xFFFFFF, + emissive: 0x000000, + metalness: 1, + roughness: 1, + transparent: false, + depthTest: true, + side: FrontSide + } ); + + } + + return cache[ 'DefaultMaterial' ]; + +} + +function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) { + + // Add unknown glTF extensions to an object's userData. + + for ( const name in objectDef.extensions ) { + + if ( knownExtensions[ name ] === undefined ) { + + object.userData.gltfExtensions = object.userData.gltfExtensions || {}; + object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ]; + + } + + } + +} + +/** + * @param {Object3D|Material|BufferGeometry} object + * @param {GLTF.definition} gltfDef + */ +function assignExtrasToUserData( object, gltfDef ) { + + if ( gltfDef.extras !== undefined ) { + + if ( typeof gltfDef.extras === 'object' ) { + + Object.assign( object.userData, gltfDef.extras ); + + } else { + + console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras ); + + } + + } + +} + +/** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets + * + * @param {BufferGeometry} geometry + * @param {Array} targets + * @param {GLTFParser} parser + * @return {Promise} + */ +function addMorphTargets( geometry, targets, parser ) { + + let hasMorphPosition = false; + let hasMorphNormal = false; + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( target.POSITION !== undefined ) hasMorphPosition = true; + if ( target.NORMAL !== undefined ) hasMorphNormal = true; + + if ( hasMorphPosition && hasMorphNormal ) break; + + } + + if ( ! hasMorphPosition && ! hasMorphNormal ) return Promise.resolve( geometry ); + + const pendingPositionAccessors = []; + const pendingNormalAccessors = []; + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( hasMorphPosition ) { + + const pendingAccessor = target.POSITION !== undefined + ? parser.getDependency( 'accessor', target.POSITION ) + : geometry.attributes.position; + + pendingPositionAccessors.push( pendingAccessor ); + + } + + if ( hasMorphNormal ) { + + const pendingAccessor = target.NORMAL !== undefined + ? parser.getDependency( 'accessor', target.NORMAL ) + : geometry.attributes.normal; + + pendingNormalAccessors.push( pendingAccessor ); + + } + + } + + return Promise.all( [ + Promise.all( pendingPositionAccessors ), + Promise.all( pendingNormalAccessors ) + ] ).then( function ( accessors ) { + + const morphPositions = accessors[ 0 ]; + const morphNormals = accessors[ 1 ]; + + if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions; + if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals; + geometry.morphTargetsRelative = true; + + return geometry; + + } ); + +} + +/** + * @param {Mesh} mesh + * @param {GLTF.Mesh} meshDef + */ +function updateMorphTargets( mesh, meshDef ) { + + mesh.updateMorphTargets(); + + if ( meshDef.weights !== undefined ) { + + for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) { + + mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ]; + + } + + } + + // .extras has user-defined data, so check that .extras.targetNames is an array. + if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) { + + const targetNames = meshDef.extras.targetNames; + + if ( mesh.morphTargetInfluences.length === targetNames.length ) { + + mesh.morphTargetDictionary = {}; + + for ( let i = 0, il = targetNames.length; i < il; i ++ ) { + + mesh.morphTargetDictionary[ targetNames[ i ] ] = i; + + } + + } else { + + console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' ); + + } + + } + +} + +function createPrimitiveKey( primitiveDef ) { + + const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]; + let geometryKey; + + if ( dracoExtension ) { + + geometryKey = 'draco:' + dracoExtension.bufferView + + ':' + dracoExtension.indices + + ':' + createAttributesKey( dracoExtension.attributes ); + + } else { + + geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode; + + } + + return geometryKey; + +} + +function createAttributesKey( attributes ) { + + let attributesKey = ''; + + const keys = Object.keys( attributes ).sort(); + + for ( let i = 0, il = keys.length; i < il; i ++ ) { + + attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';'; + + } + + return attributesKey; + +} + +function getNormalizedComponentScale( constructor ) { + + // Reference: + // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data + + switch ( constructor ) { + + case Int8Array: + return 1 / 127; + + case Uint8Array: + return 1 / 255; + + case Int16Array: + return 1 / 32767; + + case Uint16Array: + return 1 / 65535; + + default: + throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' ); + + } + +} + +/* GLTF PARSER */ + +class GLTFParser { + + constructor( json = {}, options = {} ) { + + this.json = json; + this.extensions = {}; + this.plugins = {}; + this.options = options; + + // loader object cache + this.cache = new GLTFRegistry(); + + // associations between Three.js objects and glTF elements + this.associations = new Map(); + + // BufferGeometry caching + this.primitiveCache = {}; + + // Object3D instance caches + this.meshCache = { refs: {}, uses: {} }; + this.cameraCache = { refs: {}, uses: {} }; + this.lightCache = { refs: {}, uses: {} }; + + this.textureCache = {}; + + // Track node names, to ensure no duplicates + this.nodeNamesUsed = {}; + + // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the + // expensive work of uploading a texture to the GPU off the main thread. + if ( typeof createImageBitmap !== 'undefined' && /Firefox|Safari/.test( navigator.userAgent ) === false ) { + + this.textureLoader = new ImageBitmapLoader( this.options.manager ); + + } else { + + this.textureLoader = new TextureLoader( this.options.manager ); + + } + + this.textureLoader.setCrossOrigin( this.options.crossOrigin ); + this.textureLoader.setRequestHeader( this.options.requestHeader ); + + this.fileLoader = new FileLoader( this.options.manager ); + this.fileLoader.setResponseType( 'arraybuffer' ); + + if ( this.options.crossOrigin === 'use-credentials' ) { + + this.fileLoader.setWithCredentials( true ); + + } + + } + + setExtensions( extensions ) { + + this.extensions = extensions; + + } + + setPlugins( plugins ) { + + this.plugins = plugins; + + } + + parse( onLoad, onError ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + + // Clear the loader cache + this.cache.removeAll(); + + // Mark the special nodes/meshes in json for efficient parse + this._invokeAll( function ( ext ) { + + return ext._markDefs && ext._markDefs(); + + } ); + + Promise.all( this._invokeAll( function ( ext ) { + + return ext.beforeRoot && ext.beforeRoot(); + + } ) ).then( function () { + + return Promise.all( [ + + parser.getDependencies( 'scene' ), + parser.getDependencies( 'animation' ), + parser.getDependencies( 'camera' ), + + ] ); + + } ).then( function ( dependencies ) { + + const result = { + scene: dependencies[ 0 ][ json.scene || 0 ], + scenes: dependencies[ 0 ], + animations: dependencies[ 1 ], + cameras: dependencies[ 2 ], + asset: json.asset, + parser: parser, + userData: {} + }; + + addUnknownExtensionsToUserData( extensions, result, json ); + + assignExtrasToUserData( result, json ); + + Promise.all( parser._invokeAll( function ( ext ) { + + return ext.afterRoot && ext.afterRoot( result ); + + } ) ).then( function () { + + onLoad( result ); + + } ); + + } ).catch( onError ); + + } + + /** + * Marks the special nodes/meshes in json for efficient parse. + */ + _markDefs() { + + const nodeDefs = this.json.nodes || []; + const skinDefs = this.json.skins || []; + const meshDefs = this.json.meshes || []; + + // Nothing in the node definition indicates whether it is a Bone or an + // Object3D. Use the skins' joint references to mark bones. + for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) { + + const joints = skinDefs[ skinIndex ].joints; + + for ( let i = 0, il = joints.length; i < il; i ++ ) { + + nodeDefs[ joints[ i ] ].isBone = true; + + } + + } + + // Iterate over all nodes, marking references to shared resources, + // as well as skeleton joints. + for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) { + + const nodeDef = nodeDefs[ nodeIndex ]; + + if ( nodeDef.mesh !== undefined ) { + + this._addNodeRef( this.meshCache, nodeDef.mesh ); + + // Nothing in the mesh definition indicates whether it is + // a SkinnedMesh or Mesh. Use the node's mesh reference + // to mark SkinnedMesh if node has skin. + if ( nodeDef.skin !== undefined ) { + + meshDefs[ nodeDef.mesh ].isSkinnedMesh = true; + + } + + } + + if ( nodeDef.camera !== undefined ) { + + this._addNodeRef( this.cameraCache, nodeDef.camera ); + + } + + } + + } + + /** + * Counts references to shared node / Object3D resources. These resources + * can be reused, or "instantiated", at multiple nodes in the scene + * hierarchy. Mesh, Camera, and Light instances are instantiated and must + * be marked. Non-scenegraph resources (like Materials, Geometries, and + * Textures) can be reused directly and are not marked here. + * + * Example: CesiumMilkTruck sample model reuses "Wheel" meshes. + */ + _addNodeRef( cache, index ) { + + if ( index === undefined ) return; + + if ( cache.refs[ index ] === undefined ) { + + cache.refs[ index ] = cache.uses[ index ] = 0; + + } + + cache.refs[ index ] ++; + + } + + /** Returns a reference to a shared resource, cloning it if necessary. */ + _getNodeRef( cache, index, object ) { + + if ( cache.refs[ index ] <= 1 ) return object; + + const ref = object.clone(); + + // Propagates mappings to the cloned object, prevents mappings on the + // original object from being lost. + const updateMappings = ( original, clone ) => { + + const mappings = this.associations.get( original ); + if ( mappings != null ) { + + this.associations.set( clone, mappings ); + + } + + for ( const [ i, child ] of original.children.entries() ) { + + updateMappings( child, clone.children[ i ] ); + + } + + }; + + updateMappings( object, ref ); + + ref.name += '_instance_' + ( cache.uses[ index ] ++ ); + + return ref; + + } + + _invokeOne( func ) { + + const extensions = Object.values( this.plugins ); + extensions.push( this ); + + for ( let i = 0; i < extensions.length; i ++ ) { + + const result = func( extensions[ i ] ); + + if ( result ) return result; + + } + + return null; + + } + + _invokeAll( func ) { + + const extensions = Object.values( this.plugins ); + extensions.unshift( this ); + + const pending = []; + + for ( let i = 0; i < extensions.length; i ++ ) { + + const result = func( extensions[ i ] ); + + if ( result ) pending.push( result ); + + } + + return pending; + + } + + /** + * Requests the specified dependency asynchronously, with caching. + * @param {string} type + * @param {number} index + * @return {Promise} + */ + getDependency( type, index ) { + + const cacheKey = type + ':' + index; + let dependency = this.cache.get( cacheKey ); + + if ( ! dependency ) { + + switch ( type ) { + + case 'scene': + dependency = this.loadScene( index ); + break; + + case 'node': + dependency = this.loadNode( index ); + break; + + case 'mesh': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadMesh && ext.loadMesh( index ); + + } ); + break; + + case 'accessor': + dependency = this.loadAccessor( index ); + break; + + case 'bufferView': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadBufferView && ext.loadBufferView( index ); + + } ); + break; + + case 'buffer': + dependency = this.loadBuffer( index ); + break; + + case 'material': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadMaterial && ext.loadMaterial( index ); + + } ); + break; + + case 'texture': + dependency = this._invokeOne( function ( ext ) { + + return ext.loadTexture && ext.loadTexture( index ); + + } ); + break; + + case 'skin': + dependency = this.loadSkin( index ); + break; + + case 'animation': + dependency = this.loadAnimation( index ); + break; + + case 'camera': + dependency = this.loadCamera( index ); + break; + + default: + throw new Error( 'Unknown type: ' + type ); + + } + + this.cache.add( cacheKey, dependency ); + + } + + return dependency; + + } + + /** + * Requests all dependencies of the specified type asynchronously, with caching. + * @param {string} type + * @return {Promise>} + */ + getDependencies( type ) { + + let dependencies = this.cache.get( type ); + + if ( ! dependencies ) { + + const parser = this; + const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || []; + + dependencies = Promise.all( defs.map( function ( def, index ) { + + return parser.getDependency( type, index ); + + } ) ); + + this.cache.add( type, dependencies ); + + } + + return dependencies; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferIndex + * @return {Promise} + */ + loadBuffer( bufferIndex ) { + + const bufferDef = this.json.buffers[ bufferIndex ]; + const loader = this.fileLoader; + + if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) { + + throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' ); + + } + + // If present, GLB container is required to be the first buffer. + if ( bufferDef.uri === undefined && bufferIndex === 0 ) { + + return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body ); + + } + + const options = this.options; + + return new Promise( function ( resolve, reject ) { + + loader.load( LoaderUtils.resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () { + + reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) ); + + } ); + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferViewIndex + * @return {Promise} + */ + loadBufferView( bufferViewIndex ) { + + const bufferViewDef = this.json.bufferViews[ bufferViewIndex ]; + + return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) { + + const byteLength = bufferViewDef.byteLength || 0; + const byteOffset = bufferViewDef.byteOffset || 0; + return buffer.slice( byteOffset, byteOffset + byteLength ); + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors + * @param {number} accessorIndex + * @return {Promise} + */ + loadAccessor( accessorIndex ) { + + const parser = this; + const json = this.json; + + const accessorDef = this.json.accessors[ accessorIndex ]; + + if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) { + + // Ignore empty accessors, which may be used to declare runtime + // information about attributes coming from another source (e.g. Draco + // compression extension). + return Promise.resolve( null ); + + } + + const pendingBufferViews = []; + + if ( accessorDef.bufferView !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) ); + + } else { + + pendingBufferViews.push( null ); + + } + + if ( accessorDef.sparse !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) ); + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) ); + + } + + return Promise.all( pendingBufferViews ).then( function ( bufferViews ) { + + const bufferView = bufferViews[ 0 ]; + + const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ]; + const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. + const elementBytes = TypedArray.BYTES_PER_ELEMENT; + const itemBytes = elementBytes * itemSize; + const byteOffset = accessorDef.byteOffset || 0; + const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined; + const normalized = accessorDef.normalized === true; + let array, bufferAttribute; + + // The buffer is not interleaved if the stride is the item size in bytes. + if ( byteStride && byteStride !== itemBytes ) { + + // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer + // This makes sure that IBA.count reflects accessor.count properly + const ibSlice = Math.floor( byteOffset / byteStride ); + const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count; + let ib = parser.cache.get( ibCacheKey ); + + if ( ! ib ) { + + array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes ); + + // Integer parameters to IB/IBA are in array elements, not bytes. + ib = new InterleavedBuffer( array, byteStride / elementBytes ); + + parser.cache.add( ibCacheKey, ib ); + + } + + bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized ); + + } else { + + if ( bufferView === null ) { + + array = new TypedArray( accessorDef.count * itemSize ); + + } else { + + array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize ); + + } + + bufferAttribute = new BufferAttribute( array, itemSize, normalized ); + + } + + // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors + if ( accessorDef.sparse !== undefined ) { + + const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR; + const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ]; + + const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0; + const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0; + + const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices ); + const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize ); + + if ( bufferView !== null ) { + + // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes. + bufferAttribute = new BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized ); + + } + + for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) { + + const index = sparseIndices[ i ]; + + bufferAttribute.setX( index, sparseValues[ i * itemSize ] ); + if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] ); + if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] ); + if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] ); + if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.' ); + + } + + } + + return bufferAttribute; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures + * @param {number} textureIndex + * @return {Promise} + */ + loadTexture( textureIndex ) { + + const json = this.json; + const options = this.options; + const textureDef = json.textures[ textureIndex ]; + const source = json.images[ textureDef.source ]; + + let loader = this.textureLoader; + + if ( source.uri ) { + + const handler = options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; + + } + + return this.loadTextureImage( textureIndex, source, loader ); + + } + + loadTextureImage( textureIndex, source, loader ) { + + const parser = this; + const json = this.json; + const options = this.options; + + const textureDef = json.textures[ textureIndex ]; + + const cacheKey = ( source.uri || source.bufferView ) + ':' + textureDef.sampler; + + if ( this.textureCache[ cacheKey ] ) { + + // See https://github.com/mrdoob/three.js/issues/21559. + return this.textureCache[ cacheKey ]; + + } + + const URL = self.URL || self.webkitURL; + + let sourceURI = source.uri || ''; + let isObjectURL = false; + + if ( source.bufferView !== undefined ) { + + // Load binary image data from bufferView, if provided. + + sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) { + + isObjectURL = true; + const blob = new Blob( [ bufferView ], { type: source.mimeType } ); + sourceURI = URL.createObjectURL( blob ); + return sourceURI; + + } ); + + } else if ( source.uri === undefined ) { + + throw new Error( 'THREE.GLTFLoader: Image ' + textureIndex + ' is missing URI and bufferView' ); + + } + + const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) { + + return new Promise( function ( resolve, reject ) { + + let onLoad = resolve; + + if ( loader.isImageBitmapLoader === true ) { + + onLoad = function ( imageBitmap ) { + + const texture = new Texture( imageBitmap ); + texture.needsUpdate = true; + + resolve( texture ); + + }; + + } + + loader.load( LoaderUtils.resolveURL( sourceURI, options.path ), onLoad, undefined, reject ); + + } ); + + } ).then( function ( texture ) { + + // Clean up resources and configure Texture. + + if ( isObjectURL === true ) { + + URL.revokeObjectURL( sourceURI ); + + } + + texture.flipY = false; + + if ( textureDef.name ) texture.name = textureDef.name; + + const samplers = json.samplers || {}; + const sampler = samplers[ textureDef.sampler ] || {}; + + texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || LinearFilter; + texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter; + texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping; + texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping; + + parser.associations.set( texture, { textures: textureIndex } ); + + return texture; + + } ).catch( function () { + + console.error( 'THREE.GLTFLoader: Couldn\'t load texture', sourceURI ); + return null; + + } ); + + this.textureCache[ cacheKey ] = promise; + + return promise; + + } + + /** + * Asynchronously assigns a texture to the given material parameters. + * @param {Object} materialParams + * @param {string} mapName + * @param {Object} mapDef + * @return {Promise} + */ + assignTexture( materialParams, mapName, mapDef ) { + + const parser = this; + + return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) { + + // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured + // However, we will copy UV set 0 to UV set 1 on demand for aoMap + if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) { + + console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' ); + + } + + if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) { + + const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined; + + if ( transform ) { + + const gltfReference = parser.associations.get( texture ); + texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform ); + parser.associations.set( texture, gltfReference ); + + } + + } + + materialParams[ mapName ] = texture; + + return texture; + + } ); + + } + + /** + * Assigns final material to a Mesh, Line, or Points instance. The instance + * already has a material (generated from the glTF material options alone) + * but reuse of the same glTF material may require multiple threejs materials + * to accommodate different primitive types, defines, etc. New materials will + * be created if necessary, and reused from a cache. + * @param {Object3D} mesh Mesh, Line, or Points instance. + */ + assignFinalMaterial( mesh ) { + + const geometry = mesh.geometry; + let material = mesh.material; + + const useDerivativeTangents = geometry.attributes.tangent === undefined; + const useVertexColors = geometry.attributes.color !== undefined; + const useFlatShading = geometry.attributes.normal === undefined; + + if ( mesh.isPoints ) { + + const cacheKey = 'PointsMaterial:' + material.uuid; + + let pointsMaterial = this.cache.get( cacheKey ); + + if ( ! pointsMaterial ) { + + pointsMaterial = new PointsMaterial(); + Material.prototype.copy.call( pointsMaterial, material ); + pointsMaterial.color.copy( material.color ); + pointsMaterial.map = material.map; + pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px + + this.cache.add( cacheKey, pointsMaterial ); + + } + + material = pointsMaterial; + + } else if ( mesh.isLine ) { + + const cacheKey = 'LineBasicMaterial:' + material.uuid; + + let lineMaterial = this.cache.get( cacheKey ); + + if ( ! lineMaterial ) { + + lineMaterial = new LineBasicMaterial(); + Material.prototype.copy.call( lineMaterial, material ); + lineMaterial.color.copy( material.color ); + + this.cache.add( cacheKey, lineMaterial ); + + } + + material = lineMaterial; + + } + + // Clone the material if it will be modified + if ( useDerivativeTangents || useVertexColors || useFlatShading ) { + + let cacheKey = 'ClonedMaterial:' + material.uuid + ':'; + + if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:'; + if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:'; + if ( useVertexColors ) cacheKey += 'vertex-colors:'; + if ( useFlatShading ) cacheKey += 'flat-shading:'; + + let cachedMaterial = this.cache.get( cacheKey ); + + if ( ! cachedMaterial ) { + + cachedMaterial = material.clone(); + + if ( useVertexColors ) cachedMaterial.vertexColors = true; + if ( useFlatShading ) cachedMaterial.flatShading = true; + + if ( useDerivativeTangents ) { + + // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995 + if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1; + if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1; + + } + + this.cache.add( cacheKey, cachedMaterial ); + + this.associations.set( cachedMaterial, this.associations.get( material ) ); + + } + + material = cachedMaterial; + + } + + // workarounds for mesh and geometry + + if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) { + + geometry.setAttribute( 'uv2', geometry.attributes.uv ); + + } + + mesh.material = material; + + } + + getMaterialType( /* materialIndex */ ) { + + return MeshStandardMaterial; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials + * @param {number} materialIndex + * @return {Promise} + */ + loadMaterial( materialIndex ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + const materialDef = json.materials[ materialIndex ]; + + let materialType; + const materialParams = {}; + const materialExtensions = materialDef.extensions || {}; + + const pending = []; + + if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) { + + const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ]; + materialType = sgExtension.getMaterialType(); + pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) ); + + } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) { + + const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ]; + materialType = kmuExtension.getMaterialType(); + pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) ); + + } else { + + // Specification: + // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material + + const metallicRoughness = materialDef.pbrMetallicRoughness || {}; + + materialParams.color = new Color( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + const array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) ); + + } + + materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0; + materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0; + + if ( metallicRoughness.metallicRoughnessTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) ); + pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) ); + + } + + materialType = this._invokeOne( function ( ext ) { + + return ext.getMaterialType && ext.getMaterialType( materialIndex ); + + } ); + + pending.push( Promise.all( this._invokeAll( function ( ext ) { + + return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams ); + + } ) ) ); + + } + + if ( materialDef.doubleSided === true ) { + + materialParams.side = DoubleSide; + + } + + const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE; + + if ( alphaMode === ALPHA_MODES.BLEND ) { + + materialParams.transparent = true; + + // See: https://github.com/mrdoob/three.js/issues/17706 + materialParams.depthWrite = false; + + } else { + + materialParams.transparent = false; + materialParams.alphaWrite = false; + + if ( alphaMode === ALPHA_MODES.MASK ) { + + materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5; + + } + + } + + if ( materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) ); + + materialParams.normalScale = new Vector2( 1, 1 ); + + if ( materialDef.normalTexture.scale !== undefined ) { + + const scale = materialDef.normalTexture.scale; + + materialParams.normalScale.set( scale, scale ); + + } + + } + + if ( materialDef.occlusionTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) ); + + if ( materialDef.occlusionTexture.strength !== undefined ) { + + materialParams.aoMapIntensity = materialDef.occlusionTexture.strength; + + } + + } + + if ( materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial ) { + + materialParams.emissive = new Color().fromArray( materialDef.emissiveFactor ); + + } + + if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture ) ); + + } + + return Promise.all( pending ).then( function () { + + let material; + + if ( materialType === GLTFMeshStandardSGMaterial ) { + + material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams ); + + } else { + + material = new materialType( materialParams ); + + } + + if ( materialDef.name ) material.name = materialDef.name; + + // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding. + if ( material.map ) material.map.encoding = sRGBEncoding; + if ( material.emissiveMap ) material.emissiveMap.encoding = sRGBEncoding; + + assignExtrasToUserData( material, materialDef ); + + parser.associations.set( material, { materials: materialIndex } ); + + if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef ); + + return material; + + } ); + + } + + /** When Object3D instances are targeted by animation, they need unique names. */ + createUniqueName( originalName ) { + + const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' ); + + let name = sanitizedName; + + for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) { + + name = sanitizedName + '_' + i; + + } + + this.nodeNamesUsed[ name ] = true; + + return name; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry + * + * Creates BufferGeometries from primitives. + * + * @param {Array} primitives + * @return {Promise>} + */ + loadGeometries( primitives ) { + + const parser = this; + const extensions = this.extensions; + const cache = this.primitiveCache; + + function createDracoPrimitive( primitive ) { + + return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] + .decodePrimitive( primitive, parser ) + .then( function ( geometry ) { + + return addPrimitiveAttributes( geometry, primitive, parser ); + + } ); + + } + + const pending = []; + + for ( let i = 0, il = primitives.length; i < il; i ++ ) { + + const primitive = primitives[ i ]; + const cacheKey = createPrimitiveKey( primitive ); + + // See if we've already created this geometry + const cached = cache[ cacheKey ]; + + if ( cached ) { + + // Use the cached geometry if it exists + pending.push( cached.promise ); + + } else { + + let geometryPromise; + + if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) { + + // Use DRACO geometry if available + geometryPromise = createDracoPrimitive( primitive ); + + } else { + + // Otherwise create a new geometry + geometryPromise = addPrimitiveAttributes( new BufferGeometry(), primitive, parser ); + + } + + // Cache this geometry + cache[ cacheKey ] = { primitive: primitive, promise: geometryPromise }; + + pending.push( geometryPromise ); + + } + + } + + return Promise.all( pending ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes + * @param {number} meshIndex + * @return {Promise} + */ + loadMesh( meshIndex ) { + + const parser = this; + const json = this.json; + const extensions = this.extensions; + + const meshDef = json.meshes[ meshIndex ]; + const primitives = meshDef.primitives; + + const pending = []; + + for ( let i = 0, il = primitives.length; i < il; i ++ ) { + + const material = primitives[ i ].material === undefined + ? createDefaultMaterial( this.cache ) + : this.getDependency( 'material', primitives[ i ].material ); + + pending.push( material ); + + } + + pending.push( parser.loadGeometries( primitives ) ); + + return Promise.all( pending ).then( function ( results ) { + + const materials = results.slice( 0, results.length - 1 ); + const geometries = results[ results.length - 1 ]; + + const meshes = []; + + for ( let i = 0, il = geometries.length; i < il; i ++ ) { + + const geometry = geometries[ i ]; + const primitive = primitives[ i ]; + + // 1. create Mesh + + let mesh; + + const material = materials[ i ]; + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || + primitive.mode === undefined ) { + + // .isSkinnedMesh isn't in glTF spec. See ._markDefs() + mesh = meshDef.isSkinnedMesh === true + ? new SkinnedMesh( geometry, material ) + : new Mesh( geometry, material ); + + if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) { + + // we normalize floating point skin weight array to fix malformed assets (see #15319) + // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs + mesh.normalizeSkinWeights(); + + } + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) { + + mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleStripDrawMode ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { + + mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleFanDrawMode ); + + } + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) { + + mesh = new LineSegments( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) { + + mesh = new Line( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) { + + mesh = new LineLoop( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) { + + mesh = new Points( geometry, material ); + + } else { + + throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode ); + + } + + if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) { + + updateMorphTargets( mesh, meshDef ); + + } + + mesh.name = parser.createUniqueName( meshDef.name || ( 'mesh_' + meshIndex ) ); + + assignExtrasToUserData( mesh, meshDef ); + + if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive ); + + parser.assignFinalMaterial( mesh ); + + meshes.push( mesh ); + + } + + for ( let i = 0, il = meshes.length; i < il; i ++ ) { + + parser.associations.set( meshes[ i ], { + meshes: meshIndex, + primitives: i + } ); + + } + + if ( meshes.length === 1 ) { + + return meshes[ 0 ]; + + } + + const group = new Group(); + + parser.associations.set( group, { meshes: meshIndex } ); + + for ( let i = 0, il = meshes.length; i < il; i ++ ) { + + group.add( meshes[ i ] ); + + } + + return group; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras + * @param {number} cameraIndex + * @return {Promise} + */ + loadCamera( cameraIndex ) { + + let camera; + const cameraDef = this.json.cameras[ cameraIndex ]; + const params = cameraDef[ cameraDef.type ]; + + if ( ! params ) { + + console.warn( 'THREE.GLTFLoader: Missing camera parameters.' ); + return; + + } + + if ( cameraDef.type === 'perspective' ) { + + camera = new PerspectiveCamera( MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 ); + + } else if ( cameraDef.type === 'orthographic' ) { + + camera = new OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar ); + + } + + if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name ); + + assignExtrasToUserData( camera, cameraDef ); + + return Promise.resolve( camera ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins + * @param {number} skinIndex + * @return {Promise} + */ + loadSkin( skinIndex ) { + + const skinDef = this.json.skins[ skinIndex ]; + + const skinEntry = { joints: skinDef.joints }; + + if ( skinDef.inverseBindMatrices === undefined ) { + + return Promise.resolve( skinEntry ); + + } + + return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) { + + skinEntry.inverseBindMatrices = accessor; + + return skinEntry; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations + * @param {number} animationIndex + * @return {Promise} + */ + loadAnimation( animationIndex ) { + + const json = this.json; + + const animationDef = json.animations[ animationIndex ]; + + const pendingNodes = []; + const pendingInputAccessors = []; + const pendingOutputAccessors = []; + const pendingSamplers = []; + const pendingTargets = []; + + for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) { + + const channel = animationDef.channels[ i ]; + const sampler = animationDef.samplers[ channel.sampler ]; + const target = channel.target; + const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated. + const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input; + const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output; + + pendingNodes.push( this.getDependency( 'node', name ) ); + pendingInputAccessors.push( this.getDependency( 'accessor', input ) ); + pendingOutputAccessors.push( this.getDependency( 'accessor', output ) ); + pendingSamplers.push( sampler ); + pendingTargets.push( target ); + + } + + return Promise.all( [ + + Promise.all( pendingNodes ), + Promise.all( pendingInputAccessors ), + Promise.all( pendingOutputAccessors ), + Promise.all( pendingSamplers ), + Promise.all( pendingTargets ) + + ] ).then( function ( dependencies ) { + + const nodes = dependencies[ 0 ]; + const inputAccessors = dependencies[ 1 ]; + const outputAccessors = dependencies[ 2 ]; + const samplers = dependencies[ 3 ]; + const targets = dependencies[ 4 ]; + + const tracks = []; + + for ( let i = 0, il = nodes.length; i < il; i ++ ) { + + const node = nodes[ i ]; + const inputAccessor = inputAccessors[ i ]; + const outputAccessor = outputAccessors[ i ]; + const sampler = samplers[ i ]; + const target = targets[ i ]; + + if ( node === undefined ) continue; + + node.updateMatrix(); + node.matrixAutoUpdate = true; + + let TypedKeyframeTrack; + + switch ( PATH_PROPERTIES[ target.path ] ) { + + case PATH_PROPERTIES.weights: + + TypedKeyframeTrack = NumberKeyframeTrack; + break; + + case PATH_PROPERTIES.rotation: + + TypedKeyframeTrack = QuaternionKeyframeTrack; + break; + + case PATH_PROPERTIES.position: + case PATH_PROPERTIES.scale: + default: + + TypedKeyframeTrack = VectorKeyframeTrack; + break; + + } + + const targetName = node.name ? node.name : node.uuid; + + const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear; + + const targetNames = []; + + if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) { + + node.traverse( function ( object ) { + + if ( object.morphTargetInfluences ) { + + targetNames.push( object.name ? object.name : object.uuid ); + + } + + } ); + + } else { + + targetNames.push( targetName ); + + } + + let outputArray = outputAccessor.array; + + if ( outputAccessor.normalized ) { + + const scale = getNormalizedComponentScale( outputArray.constructor ); + const scaled = new Float32Array( outputArray.length ); + + for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) { + + scaled[ j ] = outputArray[ j ] * scale; + + } + + outputArray = scaled; + + } + + for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) { + + const track = new TypedKeyframeTrack( + targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], + inputAccessor.array, + outputArray, + interpolation + ); + + // Override interpolation with custom factory method. + if ( sampler.interpolation === 'CUBICSPLINE' ) { + + track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) { + + // A CUBICSPLINE keyframe in glTF has three output values for each input value, + // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize() + // must be divided by three to get the interpolant's sampleSize argument. + + const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant; + + return new interpolantType( this.times, this.values, this.getValueSize() / 3, result ); + + }; + + // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants. + track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true; + + } + + tracks.push( track ); + + } + + } + + const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex; + + return new AnimationClip( name, undefined, tracks ); + + } ); + + } + + createNodeMesh( nodeIndex ) { + + const json = this.json; + const parser = this; + const nodeDef = json.nodes[ nodeIndex ]; + + if ( nodeDef.mesh === undefined ) return null; + + return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) { + + const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh ); + + // if weights are provided on the node, override weights on the mesh. + if ( nodeDef.weights !== undefined ) { + + node.traverse( function ( o ) { + + if ( ! o.isMesh ) return; + + for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) { + + o.morphTargetInfluences[ i ] = nodeDef.weights[ i ]; + + } + + } ); + + } + + return node; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy + * @param {number} nodeIndex + * @return {Promise} + */ + loadNode( nodeIndex ) { + + const json = this.json; + const extensions = this.extensions; + const parser = this; + + const nodeDef = json.nodes[ nodeIndex ]; + + // reserve node's name before its dependencies, so the root has the intended name. + const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : ''; + + return ( function () { + + const pending = []; + + const meshPromise = parser._invokeOne( function ( ext ) { + + return ext.createNodeMesh && ext.createNodeMesh( nodeIndex ); + + } ); + + if ( meshPromise ) { + + pending.push( meshPromise ); + + } + + if ( nodeDef.camera !== undefined ) { + + pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) { + + return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera ); + + } ) ); + + } + + parser._invokeAll( function ( ext ) { + + return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex ); + + } ).forEach( function ( promise ) { + + pending.push( promise ); + + } ); + + return Promise.all( pending ); + + }() ).then( function ( objects ) { + + let node; + + // .isBone isn't in glTF spec. See ._markDefs + if ( nodeDef.isBone === true ) { + + node = new Bone(); + + } else if ( objects.length > 1 ) { + + node = new Group(); + + } else if ( objects.length === 1 ) { + + node = objects[ 0 ]; + + } else { + + node = new Object3D(); + + } + + if ( node !== objects[ 0 ] ) { + + for ( let i = 0, il = objects.length; i < il; i ++ ) { + + node.add( objects[ i ] ); + + } + + } + + if ( nodeDef.name ) { + + node.userData.name = nodeDef.name; + node.name = nodeName; + + } + + assignExtrasToUserData( node, nodeDef ); + + if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef ); + + if ( nodeDef.matrix !== undefined ) { + + const matrix = new Matrix4(); + matrix.fromArray( nodeDef.matrix ); + node.applyMatrix4( matrix ); + + } else { + + if ( nodeDef.translation !== undefined ) { + + node.position.fromArray( nodeDef.translation ); + + } + + if ( nodeDef.rotation !== undefined ) { + + node.quaternion.fromArray( nodeDef.rotation ); + + } + + if ( nodeDef.scale !== undefined ) { + + node.scale.fromArray( nodeDef.scale ); + + } + + } + + if ( ! parser.associations.has( node ) ) { + + parser.associations.set( node, {} ); + + } + + parser.associations.get( node ).nodes = nodeIndex; + + return node; + + } ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes + * @param {number} sceneIndex + * @return {Promise} + */ + loadScene( sceneIndex ) { + + const json = this.json; + const extensions = this.extensions; + const sceneDef = this.json.scenes[ sceneIndex ]; + const parser = this; + + // Loader returns Group, not Scene. + // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172 + const scene = new Group(); + if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name ); + + assignExtrasToUserData( scene, sceneDef ); + + if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef ); + + const nodeIds = sceneDef.nodes || []; + + const pending = []; + + for ( let i = 0, il = nodeIds.length; i < il; i ++ ) { + + pending.push( buildNodeHierarchy( nodeIds[ i ], scene, json, parser ) ); + + } + + return Promise.all( pending ).then( function () { + + // Removes dangling associations, associations that reference a node that + // didn't make it into the scene. + const reduceAssociations = ( node ) => { + + const reducedAssociations = new Map(); + + for ( const [ key, value ] of parser.associations ) { + + if ( key instanceof Material || key instanceof Texture ) { + + reducedAssociations.set( key, value ); + + } + + } + + node.traverse( ( node ) => { + + const mappings = parser.associations.get( node ); + + if ( mappings != null ) { + + reducedAssociations.set( node, mappings ); + + } + + } ); + + return reducedAssociations; + + }; + + parser.associations = reduceAssociations( scene ); + + return scene; + + } ); + + } + +} + +function buildNodeHierarchy( nodeId, parentObject, json, parser ) { + + const nodeDef = json.nodes[ nodeId ]; + + return parser.getDependency( 'node', nodeId ).then( function ( node ) { + + if ( nodeDef.skin === undefined ) return node; + + // build skeleton here as well + + let skinEntry; + + return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) { + + skinEntry = skin; + + const pendingJoints = []; + + for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) { + + pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) ); + + } + + return Promise.all( pendingJoints ); + + } ).then( function ( jointNodes ) { + + node.traverse( function ( mesh ) { + + if ( ! mesh.isMesh ) return; + + const bones = []; + const boneInverses = []; + + for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) { + + const jointNode = jointNodes[ j ]; + + if ( jointNode ) { + + bones.push( jointNode ); + + const mat = new Matrix4(); + + if ( skinEntry.inverseBindMatrices !== undefined ) { + + mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 ); + + } + + boneInverses.push( mat ); + + } else { + + console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] ); + + } + + } + + mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld ); + + } ); + + return node; + + } ); + + } ).then( function ( node ) { + + // build node hierachy + + parentObject.add( node ); + + const pending = []; + + if ( nodeDef.children ) { + + const children = nodeDef.children; + + for ( let i = 0, il = children.length; i < il; i ++ ) { + + const child = children[ i ]; + pending.push( buildNodeHierarchy( child, node, json, parser ) ); + + } + + } + + return Promise.all( pending ); + + } ); + +} + +/** + * @param {BufferGeometry} geometry + * @param {GLTF.Primitive} primitiveDef + * @param {GLTFParser} parser + */ +function computeBounds( geometry, primitiveDef, parser ) { + + const attributes = primitiveDef.attributes; + + const box = new Box3(); + + if ( attributes.POSITION !== undefined ) { + + const accessor = parser.json.accessors[ attributes.POSITION ]; + + const min = accessor.min; + const max = accessor.max; + + // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement. + + if ( min !== undefined && max !== undefined ) { + + box.set( + new Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ), + new Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) + ); + + if ( accessor.normalized ) { + + const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] ); + box.min.multiplyScalar( boxScale ); + box.max.multiplyScalar( boxScale ); + + } + + } else { + + console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' ); + + return; + + } + + } else { + + return; + + } + + const targets = primitiveDef.targets; + + if ( targets !== undefined ) { + + const maxDisplacement = new Vector3(); + const vector = new Vector3(); + + for ( let i = 0, il = targets.length; i < il; i ++ ) { + + const target = targets[ i ]; + + if ( target.POSITION !== undefined ) { + + const accessor = parser.json.accessors[ target.POSITION ]; + const min = accessor.min; + const max = accessor.max; + + // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement. + + if ( min !== undefined && max !== undefined ) { + + // we need to get max of absolute components because target weight is [-1,1] + vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) ); + vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) ); + vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) ); + + + if ( accessor.normalized ) { + + const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] ); + vector.multiplyScalar( boxScale ); + + } + + // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative + // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets + // are used to implement key-frame animations and as such only two are active at a time - this results in very large + // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size. + maxDisplacement.max( vector ); + + } else { + + console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' ); + + } + + } + + } + + // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets. + box.expandByVector( maxDisplacement ); + + } + + geometry.boundingBox = box; + + const sphere = new Sphere(); + + box.getCenter( sphere.center ); + sphere.radius = box.min.distanceTo( box.max ) / 2; + + geometry.boundingSphere = sphere; + +} + +/** + * @param {BufferGeometry} geometry + * @param {GLTF.Primitive} primitiveDef + * @param {GLTFParser} parser + * @return {Promise} + */ +function addPrimitiveAttributes( geometry, primitiveDef, parser ) { + + const attributes = primitiveDef.attributes; + + const pending = []; + + function assignAttributeAccessor( accessorIndex, attributeName ) { + + return parser.getDependency( 'accessor', accessorIndex ) + .then( function ( accessor ) { + + geometry.setAttribute( attributeName, accessor ); + + } ); + + } + + for ( const gltfAttributeName in attributes ) { + + const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase(); + + // Skip attributes already provided by e.g. Draco extension. + if ( threeAttributeName in geometry.attributes ) continue; + + pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) ); + + } + + if ( primitiveDef.indices !== undefined && ! geometry.index ) { + + const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) { + + geometry.setIndex( accessor ); + + } ); + + pending.push( accessor ); + + } + + assignExtrasToUserData( geometry, primitiveDef ); + + computeBounds( geometry, primitiveDef, parser ); + + return Promise.all( pending ).then( function () { + + return primitiveDef.targets !== undefined + ? addMorphTargets( geometry, primitiveDef.targets, parser ) + : geometry; + + } ); + +} + +/** + * @param {BufferGeometry} geometry + * @param {Number} drawMode + * @return {BufferGeometry} + */ +function toTrianglesDrawMode( geometry, drawMode ) { + + let index = geometry.getIndex(); + + // generate index if not present + + if ( index === null ) { + + const indices = []; + + const position = geometry.getAttribute( 'position' ); + + if ( position !== undefined ) { + + for ( let i = 0; i < position.count; i ++ ) { + + indices.push( i ); + + } + + geometry.setIndex( indices ); + index = geometry.getIndex(); + + } else { + + console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' ); + return geometry; + + } + + } + + // + + const numberOfTriangles = index.count - 2; + const newIndices = []; + + if ( drawMode === TriangleFanDrawMode ) { + + // gl.TRIANGLE_FAN + + for ( let i = 1; i <= numberOfTriangles; i ++ ) { + + newIndices.push( index.getX( 0 ) ); + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + + } + + } else { + + // gl.TRIANGLE_STRIP + + for ( let i = 0; i < numberOfTriangles; i ++ ) { + + if ( i % 2 === 0 ) { + + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i + 2 ) ); + + + } else { + + newIndices.push( index.getX( i + 2 ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i ) ); + + } + + } + + } + + if ( ( newIndices.length / 3 ) !== numberOfTriangles ) { + + console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' ); + + } + + // build final geometry + + const newGeometry = geometry.clone(); + newGeometry.setIndex( newIndices ); + + return newGeometry; + +} + +export { GLTFLoader }; diff --git a/games/3dcity/src/jsm/loaders/RGBELoader.js b/games/3dcity/src/jsm/loaders/RGBELoader.js new file mode 100644 index 0000000..ef00f82 --- /dev/null +++ b/games/3dcity/src/jsm/loaders/RGBELoader.js @@ -0,0 +1,476 @@ +import { + DataTextureLoader, + DataUtils, + FloatType, + HalfFloatType, + LinearEncoding, + LinearFilter +} from '../../../build/three.module.js'; + +// https://github.com/mrdoob/three.js/issues/5552 +// http://en.wikipedia.org/wiki/RGBE_image_format + +class RGBELoader extends DataTextureLoader { + + constructor( manager ) { + + super( manager ); + + this.type = HalfFloatType; + + } + + // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html + + parse( buffer ) { + + const + /* return codes for rgbe routines */ + //RGBE_RETURN_SUCCESS = 0, + RGBE_RETURN_FAILURE = - 1, + + /* default error routine. change this to change error handling */ + rgbe_read_error = 1, + rgbe_write_error = 2, + rgbe_format_error = 3, + rgbe_memory_error = 4, + rgbe_error = function ( rgbe_error_code, msg ) { + + switch ( rgbe_error_code ) { + + case rgbe_read_error: console.error( 'THREE.RGBELoader Read Error: ' + ( msg || '' ) ); + break; + case rgbe_write_error: console.error( 'THREE.RGBELoader Write Error: ' + ( msg || '' ) ); + break; + case rgbe_format_error: console.error( 'THREE.RGBELoader Bad File Format: ' + ( msg || '' ) ); + break; + default: + case rgbe_memory_error: console.error( 'THREE.RGBELoader: Error: ' + ( msg || '' ) ); + + } + + return RGBE_RETURN_FAILURE; + + }, + + /* offsets to red, green, and blue components in a data (float) pixel */ + //RGBE_DATA_RED = 0, + //RGBE_DATA_GREEN = 1, + //RGBE_DATA_BLUE = 2, + + /* number of floats per pixel, use 4 since stored in rgba image format */ + //RGBE_DATA_SIZE = 4, + + /* flags indicating which fields in an rgbe_header_info are valid */ + RGBE_VALID_PROGRAMTYPE = 1, + RGBE_VALID_FORMAT = 2, + RGBE_VALID_DIMENSIONS = 4, + + NEWLINE = '\n', + + fgets = function ( buffer, lineLimit, consume ) { + + const chunkSize = 128; + + lineLimit = ! lineLimit ? 1024 : lineLimit; + let p = buffer.pos, + i = - 1, len = 0, s = '', + chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ); + + while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) { + + s += chunk; len += chunk.length; + p += chunkSize; + chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ); + + } + + if ( - 1 < i ) { + + /*for (i=l-1; i>=0; i--) { + byteCode = m.charCodeAt(i); + if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++; + else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2; + if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate + }*/ + if ( false !== consume ) buffer.pos += len + i + 1; + return s + chunk.slice( 0, i ); + + } + + return false; + + }, + + /* minimal header reading. modify if you want to parse more information */ + RGBE_ReadHeader = function ( buffer ) { + + + // regexes to parse header info fields + const magic_token_re = /^#\?(\S+)/, + gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, + exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, + format_re = /^\s*FORMAT=(\S+)\s*$/, + dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, + + // RGBE format header struct + header = { + + valid: 0, /* indicate which fields are valid */ + + string: '', /* the actual header string */ + + comments: '', /* comments found in header */ + + programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */ + + format: '', /* RGBE format, default 32-bit_rle_rgbe */ + + gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */ + + exposure: 1.0, /* a value of 1.0 in an image corresponds to watts/steradian/m^2. defaults to 1.0 */ + + width: 0, height: 0 /* image dimensions, width/height */ + + }; + + let line, match; + + if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) { + + return rgbe_error( rgbe_read_error, 'no header found' ); + + } + + /* if you want to require the magic token then uncomment the next line */ + if ( ! ( match = line.match( magic_token_re ) ) ) { + + return rgbe_error( rgbe_format_error, 'bad initial token' ); + + } + + header.valid |= RGBE_VALID_PROGRAMTYPE; + header.programtype = match[ 1 ]; + header.string += line + '\n'; + + while ( true ) { + + line = fgets( buffer ); + if ( false === line ) break; + header.string += line + '\n'; + + if ( '#' === line.charAt( 0 ) ) { + + header.comments += line + '\n'; + continue; // comment line + + } + + if ( match = line.match( gamma_re ) ) { + + header.gamma = parseFloat( match[ 1 ], 10 ); + + } + + if ( match = line.match( exposure_re ) ) { + + header.exposure = parseFloat( match[ 1 ], 10 ); + + } + + if ( match = line.match( format_re ) ) { + + header.valid |= RGBE_VALID_FORMAT; + header.format = match[ 1 ];//'32-bit_rle_rgbe'; + + } + + if ( match = line.match( dimensions_re ) ) { + + header.valid |= RGBE_VALID_DIMENSIONS; + header.height = parseInt( match[ 1 ], 10 ); + header.width = parseInt( match[ 2 ], 10 ); + + } + + if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break; + + } + + if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) { + + return rgbe_error( rgbe_format_error, 'missing format specifier' ); + + } + + if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) { + + return rgbe_error( rgbe_format_error, 'missing image size specifier' ); + + } + + return header; + + }, + + RGBE_ReadPixels_RLE = function ( buffer, w, h ) { + + const scanline_width = w; + + if ( + // run length encoding is not allowed so read flat + ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) || + // this file is not run length encoded + ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) ) + ) { + + // return the flat buffer + return new Uint8Array( buffer ); + + } + + if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) { + + return rgbe_error( rgbe_format_error, 'wrong scanline width' ); + + } + + const data_rgba = new Uint8Array( 4 * w * h ); + + if ( ! data_rgba.length ) { + + return rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' ); + + } + + let offset = 0, pos = 0; + + const ptr_end = 4 * scanline_width; + const rgbeStart = new Uint8Array( 4 ); + const scanline_buffer = new Uint8Array( ptr_end ); + let num_scanlines = h; + + // read in each successive scanline + while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) { + + if ( pos + 4 > buffer.byteLength ) { + + return rgbe_error( rgbe_read_error ); + + } + + rgbeStart[ 0 ] = buffer[ pos ++ ]; + rgbeStart[ 1 ] = buffer[ pos ++ ]; + rgbeStart[ 2 ] = buffer[ pos ++ ]; + rgbeStart[ 3 ] = buffer[ pos ++ ]; + + if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) { + + return rgbe_error( rgbe_format_error, 'bad rgbe scanline format' ); + + } + + // read each of the four channels for the scanline into the buffer + // first red, then green, then blue, then exponent + let ptr = 0, count; + + while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) { + + count = buffer[ pos ++ ]; + const isEncodedRun = count > 128; + if ( isEncodedRun ) count -= 128; + + if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) { + + return rgbe_error( rgbe_format_error, 'bad scanline data' ); + + } + + if ( isEncodedRun ) { + + // a (encoded) run of the same value + const byteValue = buffer[ pos ++ ]; + for ( let i = 0; i < count; i ++ ) { + + scanline_buffer[ ptr ++ ] = byteValue; + + } + //ptr += count; + + } else { + + // a literal-run + scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr ); + ptr += count; pos += count; + + } + + } + + + // now convert data from buffer into rgba + // first red, then green, then blue, then exponent (alpha) + const l = scanline_width; //scanline_buffer.byteLength; + for ( let i = 0; i < l; i ++ ) { + + let off = 0; + data_rgba[ offset ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 1 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 2 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 3 ] = scanline_buffer[ i + off ]; + offset += 4; + + } + + num_scanlines --; + + } + + return data_rgba; + + }; + + const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) { + + const e = sourceArray[ sourceOffset + 3 ]; + const scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale; + destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale; + destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale; + destArray[ destOffset + 3 ] = 1; + + }; + + const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) { + + const e = sourceArray[ sourceOffset + 3 ]; + const scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + // clamping to 65504, the maximum representable value in float16 + destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) ); + destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) ); + destArray[ destOffset + 2 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) ); + destArray[ destOffset + 3 ] = DataUtils.toHalfFloat( 1 ); + + }; + + const byteArray = new Uint8Array( buffer ); + byteArray.pos = 0; + const rgbe_header_info = RGBE_ReadHeader( byteArray ); + + if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) { + + const w = rgbe_header_info.width, + h = rgbe_header_info.height, + image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h ); + + if ( RGBE_RETURN_FAILURE !== image_rgba_data ) { + + let data, format, type; + let numElements; + + switch ( this.type ) { + + case FloatType: + + numElements = image_rgba_data.length / 4; + const floatArray = new Float32Array( numElements * 4 ); + + for ( let j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 ); + + } + + data = floatArray; + type = FloatType; + break; + + case HalfFloatType: + + numElements = image_rgba_data.length / 4; + const halfArray = new Uint16Array( numElements * 4 ); + + for ( let j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 ); + + } + + data = halfArray; + type = HalfFloatType; + break; + + default: + + console.error( 'THREE.RGBELoader: unsupported type: ', this.type ); + break; + + } + + return { + width: w, height: h, + data: data, + header: rgbe_header_info.string, + gamma: rgbe_header_info.gamma, + exposure: rgbe_header_info.exposure, + format: format, + type: type + }; + + } + + } + + return null; + + } + + setDataType( value ) { + + this.type = value; + return this; + + } + + load( url, onLoad, onProgress, onError ) { + + function onLoadCallback( texture, texData ) { + + switch ( texture.type ) { + + case FloatType: + + texture.encoding = LinearEncoding; + texture.minFilter = LinearFilter; + texture.magFilter = LinearFilter; + texture.generateMipmaps = false; + texture.flipY = true; + break; + + case HalfFloatType: + + texture.encoding = LinearEncoding; + texture.minFilter = LinearFilter; + texture.magFilter = LinearFilter; + texture.generateMipmaps = false; + texture.flipY = true; + break; + + } + + if ( onLoad ) onLoad( texture, texData ); + + } + + return super.load( url, onLoadCallback, onProgress, onError ); + + } + +} + +export { RGBELoader }; diff --git a/games/3dcity/src/jsm/math/ImprovedNoise.js b/games/3dcity/src/jsm/math/ImprovedNoise.js new file mode 100644 index 0000000..8e197e5 --- /dev/null +++ b/games/3dcity/src/jsm/math/ImprovedNoise.js @@ -0,0 +1,71 @@ +// http://mrl.nyu.edu/~perlin/noise/ + +const _p = [ 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, + 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, + 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, + 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, + 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, + 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, + 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, + 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, + 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, + 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 ]; + +for ( let i = 0; i < 256; i ++ ) { + + _p[ 256 + i ] = _p[ i ]; + +} + +function fade( t ) { + + return t * t * t * ( t * ( t * 6 - 15 ) + 10 ); + +} + +function lerp( t, a, b ) { + + return a + t * ( b - a ); + +} + +function grad( hash, x, y, z ) { + + const h = hash & 15; + const u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z; + return ( ( h & 1 ) == 0 ? u : - u ) + ( ( h & 2 ) == 0 ? v : - v ); + +} + +class ImprovedNoise { + + noise( x, y, z ) { + + const floorX = Math.floor( x ), floorY = Math.floor( y ), floorZ = Math.floor( z ); + + const X = floorX & 255, Y = floorY & 255, Z = floorZ & 255; + + x -= floorX; + y -= floorY; + z -= floorZ; + + const xMinus1 = x - 1, yMinus1 = y - 1, zMinus1 = z - 1; + + const u = fade( x ), v = fade( y ), w = fade( z ); + + const A = _p[ X ] + Y, AA = _p[ A ] + Z, AB = _p[ A + 1 ] + Z, B = _p[ X + 1 ] + Y, BA = _p[ B ] + Z, BB = _p[ B + 1 ] + Z; + + return lerp( w, lerp( v, lerp( u, grad( _p[ AA ], x, y, z ), + grad( _p[ BA ], xMinus1, y, z ) ), + lerp( u, grad( _p[ AB ], x, yMinus1, z ), + grad( _p[ BB ], xMinus1, yMinus1, z ) ) ), + lerp( v, lerp( u, grad( _p[ AA + 1 ], x, y, zMinus1 ), + grad( _p[ BA + 1 ], xMinus1, y, zMinus1 ) ), + lerp( u, grad( _p[ AB + 1 ], x, yMinus1, zMinus1 ), + grad( _p[ BB + 1 ], xMinus1, yMinus1, zMinus1 ) ) ) ); + + } + +} + +export { ImprovedNoise }; diff --git a/games/3dcity/src/jsm/math/MeshSurfaceSampler.js b/games/3dcity/src/jsm/math/MeshSurfaceSampler.js new file mode 100644 index 0000000..bc4efc5 --- /dev/null +++ b/games/3dcity/src/jsm/math/MeshSurfaceSampler.js @@ -0,0 +1,211 @@ +import { + Triangle, + Vector3 +} from '../../../build/three.module.js'; + +/** + * Utility class for sampling weighted random points on the surface of a mesh. + * + * Building the sampler is a one-time O(n) operation. Once built, any number of + * random samples may be selected in O(logn) time. Memory usage is O(n). + * + * References: + * - http://www.joesfer.com/?p=84 + * - https://stackoverflow.com/a/4322940/1314762 + */ + +const _face = new Triangle(); +const _color = new Vector3(); + +class MeshSurfaceSampler { + + constructor( mesh ) { + + let geometry = mesh.geometry; + + if ( ! geometry.isBufferGeometry || geometry.attributes.position.itemSize !== 3 ) { + + throw new Error( 'THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.' ); + + } + + if ( geometry.index ) { + + console.warn( 'THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry.' ); + + geometry = geometry.toNonIndexed(); + + } + + this.geometry = geometry; + this.randomFunction = Math.random; + + this.positionAttribute = this.geometry.getAttribute( 'position' ); + this.colorAttribute = this.geometry.getAttribute( 'color' ); + this.weightAttribute = null; + + this.distribution = null; + + } + + setWeightAttribute( name ) { + + this.weightAttribute = name ? this.geometry.getAttribute( name ) : null; + + return this; + + } + + build() { + + const positionAttribute = this.positionAttribute; + const weightAttribute = this.weightAttribute; + + const faceWeights = new Float32Array( positionAttribute.count / 3 ); + + // Accumulate weights for each mesh face. + + for ( let i = 0; i < positionAttribute.count; i += 3 ) { + + let faceWeight = 1; + + if ( weightAttribute ) { + + faceWeight = weightAttribute.getX( i ) + + weightAttribute.getX( i + 1 ) + + weightAttribute.getX( i + 2 ); + + } + + _face.a.fromBufferAttribute( positionAttribute, i ); + _face.b.fromBufferAttribute( positionAttribute, i + 1 ); + _face.c.fromBufferAttribute( positionAttribute, i + 2 ); + faceWeight *= _face.getArea(); + + faceWeights[ i / 3 ] = faceWeight; + + } + + // Store cumulative total face weights in an array, where weight index + // corresponds to face index. + + this.distribution = new Float32Array( positionAttribute.count / 3 ); + + let cumulativeTotal = 0; + + for ( let i = 0; i < faceWeights.length; i ++ ) { + + cumulativeTotal += faceWeights[ i ]; + + this.distribution[ i ] = cumulativeTotal; + + } + + return this; + + } + + setRandomGenerator( randomFunction ) { + + this.randomFunction = randomFunction; + return this; + + } + + sample( targetPosition, targetNormal, targetColor ) { + + const cumulativeTotal = this.distribution[ this.distribution.length - 1 ]; + + const faceIndex = this.binarySearch( this.randomFunction() * cumulativeTotal ); + + return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor ); + + } + + binarySearch( x ) { + + const dist = this.distribution; + let start = 0; + let end = dist.length - 1; + + let index = - 1; + + while ( start <= end ) { + + const mid = Math.ceil( ( start + end ) / 2 ); + + if ( mid === 0 || dist[ mid - 1 ] <= x && dist[ mid ] > x ) { + + index = mid; + + break; + + } else if ( x < dist[ mid ] ) { + + end = mid - 1; + + } else { + + start = mid + 1; + + } + + } + + return index; + + } + + sampleFace( faceIndex, targetPosition, targetNormal, targetColor ) { + + let u = this.randomFunction(); + let v = this.randomFunction(); + + if ( u + v > 1 ) { + + u = 1 - u; + v = 1 - v; + + } + + _face.a.fromBufferAttribute( this.positionAttribute, faceIndex * 3 ); + _face.b.fromBufferAttribute( this.positionAttribute, faceIndex * 3 + 1 ); + _face.c.fromBufferAttribute( this.positionAttribute, faceIndex * 3 + 2 ); + + targetPosition + .set( 0, 0, 0 ) + .addScaledVector( _face.a, u ) + .addScaledVector( _face.b, v ) + .addScaledVector( _face.c, 1 - ( u + v ) ); + + if ( targetNormal !== undefined ) { + + _face.getNormal( targetNormal ); + + } + + if ( targetColor !== undefined && this.colorAttribute !== undefined ) { + + _face.a.fromBufferAttribute( this.colorAttribute, faceIndex * 3 ); + _face.b.fromBufferAttribute( this.colorAttribute, faceIndex * 3 + 1 ); + _face.c.fromBufferAttribute( this.colorAttribute, faceIndex * 3 + 2 ); + + _color + .set( 0, 0, 0 ) + .addScaledVector( _face.a, u ) + .addScaledVector( _face.b, v ) + .addScaledVector( _face.c, 1 - ( u + v ) ); + + targetColor.r = _color.x; + targetColor.g = _color.y; + targetColor.b = _color.z; + + } + + return this; + + } + +} + +export { MeshSurfaceSampler }; diff --git a/games/3dcity/src/jsm/utils/BufferGeometryUtils.js b/games/3dcity/src/jsm/utils/BufferGeometryUtils.js new file mode 100644 index 0000000..8f17210 --- /dev/null +++ b/games/3dcity/src/jsm/utils/BufferGeometryUtils.js @@ -0,0 +1,943 @@ +import { + BufferAttribute, + BufferGeometry, + Float32BufferAttribute, + InterleavedBuffer, + InterleavedBufferAttribute, + TriangleFanDrawMode, + TriangleStripDrawMode, + TrianglesDrawMode, + Vector3 +} from '../../../build/three.module.js'; + + +function computeTangents( geometry ) { + + geometry.computeTangents(); + console.warn( 'THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.' ); + +} + +/** + * @param {Array} geometries + * @param {Boolean} useGroups + * @return {BufferGeometry} + */ +function mergeBufferGeometries( geometries, useGroups = false ) { + + const isIndexed = geometries[ 0 ].index !== null; + + const attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) ); + const morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) ); + + const attributes = {}; + const morphAttributes = {}; + + const morphTargetsRelative = geometries[ 0 ].morphTargetsRelative; + + const mergedGeometry = new BufferGeometry(); + + let offset = 0; + + for ( let i = 0; i < geometries.length; ++ i ) { + + const geometry = geometries[ i ]; + let attributesCount = 0; + + // ensure that all geometries are indexed, or none + + if ( isIndexed !== ( geometry.index !== null ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' ); + return null; + + } + + // gather attributes, exit early if they're different + + for ( const name in geometry.attributes ) { + + if ( ! attributesUsed.has( name ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' ); + return null; + + } + + if ( attributes[ name ] === undefined ) attributes[ name ] = []; + + attributes[ name ].push( geometry.attributes[ name ] ); + + attributesCount ++; + + } + + // ensure geometries have the same number of attributes + + if ( attributesCount !== attributesUsed.size ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' ); + return null; + + } + + // gather morph attributes, exit early if they're different + + if ( morphTargetsRelative !== geometry.morphTargetsRelative ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' ); + return null; + + } + + for ( const name in geometry.morphAttributes ) { + + if ( ! morphAttributesUsed.has( name ) ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.' ); + return null; + + } + + if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = []; + + morphAttributes[ name ].push( geometry.morphAttributes[ name ] ); + + } + + // gather .userData + + mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || []; + mergedGeometry.userData.mergedUserData.push( geometry.userData ); + + if ( useGroups ) { + + let count; + + if ( isIndexed ) { + + count = geometry.index.count; + + } else if ( geometry.attributes.position !== undefined ) { + + count = geometry.attributes.position.count; + + } else { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' ); + return null; + + } + + mergedGeometry.addGroup( offset, count, i ); + + offset += count; + + } + + } + + // merge indices + + if ( isIndexed ) { + + let indexOffset = 0; + const mergedIndex = []; + + for ( let i = 0; i < geometries.length; ++ i ) { + + const index = geometries[ i ].index; + + for ( let j = 0; j < index.count; ++ j ) { + + mergedIndex.push( index.getX( j ) + indexOffset ); + + } + + indexOffset += geometries[ i ].attributes.position.count; + + } + + mergedGeometry.setIndex( mergedIndex ); + + } + + // merge attributes + + for ( const name in attributes ) { + + const mergedAttribute = mergeBufferAttributes( attributes[ name ] ); + + if ( ! mergedAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' ); + return null; + + } + + mergedGeometry.setAttribute( name, mergedAttribute ); + + } + + // merge morph attributes + + for ( const name in morphAttributes ) { + + const numMorphTargets = morphAttributes[ name ][ 0 ].length; + + if ( numMorphTargets === 0 ) break; + + mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {}; + mergedGeometry.morphAttributes[ name ] = []; + + for ( let i = 0; i < numMorphTargets; ++ i ) { + + const morphAttributesToMerge = []; + + for ( let j = 0; j < morphAttributes[ name ].length; ++ j ) { + + morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] ); + + } + + const mergedMorphAttribute = mergeBufferAttributes( morphAttributesToMerge ); + + if ( ! mergedMorphAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' ); + return null; + + } + + mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute ); + + } + + } + + return mergedGeometry; + +} + +/** + * @param {Array} attributes + * @return {BufferAttribute} + */ +function mergeBufferAttributes( attributes ) { + + let TypedArray; + let itemSize; + let normalized; + let arrayLength = 0; + + for ( let i = 0; i < attributes.length; ++ i ) { + + const attribute = attributes[ i ]; + + if ( attribute.isInterleavedBufferAttribute ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' ); + return null; + + } + + if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; + if ( TypedArray !== attribute.array.constructor ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' ); + return null; + + } + + if ( itemSize === undefined ) itemSize = attribute.itemSize; + if ( itemSize !== attribute.itemSize ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' ); + return null; + + } + + if ( normalized === undefined ) normalized = attribute.normalized; + if ( normalized !== attribute.normalized ) { + + console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' ); + return null; + + } + + arrayLength += attribute.array.length; + + } + + const array = new TypedArray( arrayLength ); + let offset = 0; + + for ( let i = 0; i < attributes.length; ++ i ) { + + array.set( attributes[ i ].array, offset ); + + offset += attributes[ i ].array.length; + + } + + return new BufferAttribute( array, itemSize, normalized ); + +} + +/** + * @param {Array} attributes + * @return {Array} + */ +function interleaveAttributes( attributes ) { + + // Interleaves the provided attributes into an InterleavedBuffer and returns + // a set of InterleavedBufferAttributes for each attribute + let TypedArray; + let arrayLength = 0; + let stride = 0; + + // calculate the the length and type of the interleavedBuffer + for ( let i = 0, l = attributes.length; i < l; ++ i ) { + + const attribute = attributes[ i ]; + + if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; + if ( TypedArray !== attribute.array.constructor ) { + + console.error( 'AttributeBuffers of different types cannot be interleaved' ); + return null; + + } + + arrayLength += attribute.array.length; + stride += attribute.itemSize; + + } + + // Create the set of buffer attributes + const interleavedBuffer = new InterleavedBuffer( new TypedArray( arrayLength ), stride ); + let offset = 0; + const res = []; + const getters = [ 'getX', 'getY', 'getZ', 'getW' ]; + const setters = [ 'setX', 'setY', 'setZ', 'setW' ]; + + for ( let j = 0, l = attributes.length; j < l; j ++ ) { + + const attribute = attributes[ j ]; + const itemSize = attribute.itemSize; + const count = attribute.count; + const iba = new InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, attribute.normalized ); + res.push( iba ); + + offset += itemSize; + + // Move the data for each attribute into the new interleavedBuffer + // at the appropriate offset + for ( let c = 0; c < count; c ++ ) { + + for ( let k = 0; k < itemSize; k ++ ) { + + iba[ setters[ k ] ]( c, attribute[ getters[ k ] ]( c ) ); + + } + + } + + } + + return res; + +} + +/** + * @param {Array} geometry + * @return {number} + */ +function estimateBytesUsed( geometry ) { + + // Return the estimated memory used by this geometry in bytes + // Calculate using itemSize, count, and BYTES_PER_ELEMENT to account + // for InterleavedBufferAttributes. + let mem = 0; + for ( const name in geometry.attributes ) { + + const attr = geometry.getAttribute( name ); + mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT; + + } + + const indices = geometry.getIndex(); + mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0; + return mem; + +} + +/** + * @param {BufferGeometry} geometry + * @param {number} tolerance + * @return {BufferGeometry>} + */ +function mergeVertices( geometry, tolerance = 1e-4 ) { + + tolerance = Math.max( tolerance, Number.EPSILON ); + + // Generate an index buffer if the geometry doesn't have one, or optimize it + // if it's already available. + const hashToIndex = {}; + const indices = geometry.getIndex(); + const positions = geometry.getAttribute( 'position' ); + const vertexCount = indices ? indices.count : positions.count; + + // next value for triangle indices + let nextIndex = 0; + + // attributes and new attribute arrays + const attributeNames = Object.keys( geometry.attributes ); + const attrArrays = {}; + const morphAttrsArrays = {}; + const newIndices = []; + const getters = [ 'getX', 'getY', 'getZ', 'getW' ]; + + // initialize the arrays + for ( let i = 0, l = attributeNames.length; i < l; i ++ ) { + + const name = attributeNames[ i ]; + + attrArrays[ name ] = []; + + const morphAttr = geometry.morphAttributes[ name ]; + if ( morphAttr ) { + + morphAttrsArrays[ name ] = new Array( morphAttr.length ).fill().map( () => [] ); + + } + + } + + // convert the error tolerance to an amount of decimal places to truncate to + const decimalShift = Math.log10( 1 / tolerance ); + const shiftMultiplier = Math.pow( 10, decimalShift ); + for ( let i = 0; i < vertexCount; i ++ ) { + + const index = indices ? indices.getX( i ) : i; + + // Generate a hash for the vertex attributes at the current index 'i' + let hash = ''; + for ( let j = 0, l = attributeNames.length; j < l; j ++ ) { + + const name = attributeNames[ j ]; + const attribute = geometry.getAttribute( name ); + const itemSize = attribute.itemSize; + + for ( let k = 0; k < itemSize; k ++ ) { + + // double tilde truncates the decimal value + hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier ) },`; + + } + + } + + // Add another reference to the vertex if it's already + // used by another index + if ( hash in hashToIndex ) { + + newIndices.push( hashToIndex[ hash ] ); + + } else { + + // copy data to the new index in the attribute arrays + for ( let j = 0, l = attributeNames.length; j < l; j ++ ) { + + const name = attributeNames[ j ]; + const attribute = geometry.getAttribute( name ); + const morphAttr = geometry.morphAttributes[ name ]; + const itemSize = attribute.itemSize; + const newarray = attrArrays[ name ]; + const newMorphArrays = morphAttrsArrays[ name ]; + + for ( let k = 0; k < itemSize; k ++ ) { + + const getterFunc = getters[ k ]; + newarray.push( attribute[ getterFunc ]( index ) ); + + if ( morphAttr ) { + + for ( let m = 0, ml = morphAttr.length; m < ml; m ++ ) { + + newMorphArrays[ m ].push( morphAttr[ m ][ getterFunc ]( index ) ); + + } + + } + + } + + } + + hashToIndex[ hash ] = nextIndex; + newIndices.push( nextIndex ); + nextIndex ++; + + } + + } + + // Generate typed arrays from new attribute arrays and update + // the attributeBuffers + const result = geometry.clone(); + for ( let i = 0, l = attributeNames.length; i < l; i ++ ) { + + const name = attributeNames[ i ]; + const oldAttribute = geometry.getAttribute( name ); + + const buffer = new oldAttribute.array.constructor( attrArrays[ name ] ); + const attribute = new BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized ); + + result.setAttribute( name, attribute ); + + // Update the attribute arrays + if ( name in morphAttrsArrays ) { + + for ( let j = 0; j < morphAttrsArrays[ name ].length; j ++ ) { + + const oldMorphAttribute = geometry.morphAttributes[ name ][ j ]; + + const buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ); + const morphAttribute = new BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized ); + result.morphAttributes[ name ][ j ] = morphAttribute; + + } + + } + + } + + // indices + + result.setIndex( newIndices ); + + return result; + +} + +/** + * @param {BufferGeometry} geometry + * @param {number} drawMode + * @return {BufferGeometry>} + */ +function toTrianglesDrawMode( geometry, drawMode ) { + + if ( drawMode === TrianglesDrawMode ) { + + console.warn( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.' ); + return geometry; + + } + + if ( drawMode === TriangleFanDrawMode || drawMode === TriangleStripDrawMode ) { + + let index = geometry.getIndex(); + + // generate index if not present + + if ( index === null ) { + + const indices = []; + + const position = geometry.getAttribute( 'position' ); + + if ( position !== undefined ) { + + for ( let i = 0; i < position.count; i ++ ) { + + indices.push( i ); + + } + + geometry.setIndex( indices ); + index = geometry.getIndex(); + + } else { + + console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' ); + return geometry; + + } + + } + + // + + const numberOfTriangles = index.count - 2; + const newIndices = []; + + if ( drawMode === TriangleFanDrawMode ) { + + // gl.TRIANGLE_FAN + + for ( let i = 1; i <= numberOfTriangles; i ++ ) { + + newIndices.push( index.getX( 0 ) ); + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + + } + + } else { + + // gl.TRIANGLE_STRIP + + for ( let i = 0; i < numberOfTriangles; i ++ ) { + + if ( i % 2 === 0 ) { + + newIndices.push( index.getX( i ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i + 2 ) ); + + } else { + + newIndices.push( index.getX( i + 2 ) ); + newIndices.push( index.getX( i + 1 ) ); + newIndices.push( index.getX( i ) ); + + } + + } + + } + + if ( ( newIndices.length / 3 ) !== numberOfTriangles ) { + + console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' ); + + } + + // build final geometry + + const newGeometry = geometry.clone(); + newGeometry.setIndex( newIndices ); + newGeometry.clearGroups(); + + return newGeometry; + + } else { + + console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode ); + return geometry; + + } + +} + +/** + * Calculates the morphed attributes of a morphed/skinned BufferGeometry. + * Helpful for Raytracing or Decals. + * @param {Mesh | Line | Points} object An instance of Mesh, Line or Points. + * @return {Object} An Object with original position/normal attributes and morphed ones. + */ +function computeMorphedAttributes( object ) { + + if ( object.geometry.isBufferGeometry !== true ) { + + console.error( 'THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.' ); + return null; + + } + + const _vA = new Vector3(); + const _vB = new Vector3(); + const _vC = new Vector3(); + + const _tempA = new Vector3(); + const _tempB = new Vector3(); + const _tempC = new Vector3(); + + const _morphA = new Vector3(); + const _morphB = new Vector3(); + const _morphC = new Vector3(); + + function _calculateMorphedAttributeData( + object, + material, + attribute, + morphAttribute, + morphTargetsRelative, + a, + b, + c, + modifiedAttributeArray + ) { + + _vA.fromBufferAttribute( attribute, a ); + _vB.fromBufferAttribute( attribute, b ); + _vC.fromBufferAttribute( attribute, c ); + + const morphInfluences = object.morphTargetInfluences; + + if ( material.morphTargets && morphAttribute && morphInfluences ) { + + _morphA.set( 0, 0, 0 ); + _morphB.set( 0, 0, 0 ); + _morphC.set( 0, 0, 0 ); + + for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) { + + const influence = morphInfluences[ i ]; + const morph = morphAttribute[ i ]; + + if ( influence === 0 ) continue; + + _tempA.fromBufferAttribute( morph, a ); + _tempB.fromBufferAttribute( morph, b ); + _tempC.fromBufferAttribute( morph, c ); + + if ( morphTargetsRelative ) { + + _morphA.addScaledVector( _tempA, influence ); + _morphB.addScaledVector( _tempB, influence ); + _morphC.addScaledVector( _tempC, influence ); + + } else { + + _morphA.addScaledVector( _tempA.sub( _vA ), influence ); + _morphB.addScaledVector( _tempB.sub( _vB ), influence ); + _morphC.addScaledVector( _tempC.sub( _vC ), influence ); + + } + + } + + _vA.add( _morphA ); + _vB.add( _morphB ); + _vC.add( _morphC ); + + } + + if ( object.isSkinnedMesh ) { + + object.boneTransform( a, _vA ); + object.boneTransform( b, _vB ); + object.boneTransform( c, _vC ); + + } + + modifiedAttributeArray[ a * 3 + 0 ] = _vA.x; + modifiedAttributeArray[ a * 3 + 1 ] = _vA.y; + modifiedAttributeArray[ a * 3 + 2 ] = _vA.z; + modifiedAttributeArray[ b * 3 + 0 ] = _vB.x; + modifiedAttributeArray[ b * 3 + 1 ] = _vB.y; + modifiedAttributeArray[ b * 3 + 2 ] = _vB.z; + modifiedAttributeArray[ c * 3 + 0 ] = _vC.x; + modifiedAttributeArray[ c * 3 + 1 ] = _vC.y; + modifiedAttributeArray[ c * 3 + 2 ] = _vC.z; + + } + + const geometry = object.geometry; + const material = object.material; + + let a, b, c; + const index = geometry.index; + const positionAttribute = geometry.attributes.position; + const morphPosition = geometry.morphAttributes.position; + const morphTargetsRelative = geometry.morphTargetsRelative; + const normalAttribute = geometry.attributes.normal; + const morphNormal = geometry.morphAttributes.position; + + const groups = geometry.groups; + const drawRange = geometry.drawRange; + let i, j, il, jl; + let group, groupMaterial; + let start, end; + + const modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize ); + const modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize ); + + if ( index !== null ) { + + // indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( i = 0, il = groups.length; i < il; i ++ ) { + + group = groups[ i ]; + groupMaterial = material[ group.materialIndex ]; + + start = Math.max( group.start, drawRange.start ); + end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ); + + for ( j = start, jl = end; j < jl; j += 3 ) { + + a = index.getX( j ); + b = index.getX( j + 1 ); + c = index.getX( j + 2 ); + + _calculateMorphedAttributeData( + object, + groupMaterial, + positionAttribute, + morphPosition, + morphTargetsRelative, + a, b, c, + modifiedPosition + ); + + _calculateMorphedAttributeData( + object, + groupMaterial, + normalAttribute, + morphNormal, + morphTargetsRelative, + a, b, c, + modifiedNormal + ); + + } + + } + + } else { + + start = Math.max( 0, drawRange.start ); + end = Math.min( index.count, ( drawRange.start + drawRange.count ) ); + + for ( i = start, il = end; i < il; i += 3 ) { + + a = index.getX( i ); + b = index.getX( i + 1 ); + c = index.getX( i + 2 ); + + _calculateMorphedAttributeData( + object, + material, + positionAttribute, + morphPosition, + morphTargetsRelative, + a, b, c, + modifiedPosition + ); + + _calculateMorphedAttributeData( + object, + material, + normalAttribute, + morphNormal, + morphTargetsRelative, + a, b, c, + modifiedNormal + ); + + } + + } + + } else if ( positionAttribute !== undefined ) { + + // non-indexed buffer geometry + + if ( Array.isArray( material ) ) { + + for ( i = 0, il = groups.length; i < il; i ++ ) { + + group = groups[ i ]; + groupMaterial = material[ group.materialIndex ]; + + start = Math.max( group.start, drawRange.start ); + end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ); + + for ( j = start, jl = end; j < jl; j += 3 ) { + + a = j; + b = j + 1; + c = j + 2; + + _calculateMorphedAttributeData( + object, + groupMaterial, + positionAttribute, + morphPosition, + morphTargetsRelative, + a, b, c, + modifiedPosition + ); + + _calculateMorphedAttributeData( + object, + groupMaterial, + normalAttribute, + morphNormal, + morphTargetsRelative, + a, b, c, + modifiedNormal + ); + + } + + } + + } else { + + start = Math.max( 0, drawRange.start ); + end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) ); + + for ( i = start, il = end; i < il; i += 3 ) { + + a = i; + b = i + 1; + c = i + 2; + + _calculateMorphedAttributeData( + object, + material, + positionAttribute, + morphPosition, + morphTargetsRelative, + a, b, c, + modifiedPosition + ); + + _calculateMorphedAttributeData( + object, + material, + normalAttribute, + morphNormal, + morphTargetsRelative, + a, b, c, + modifiedNormal + ); + + } + + } + + } + + const morphedPositionAttribute = new Float32BufferAttribute( modifiedPosition, 3 ); + const morphedNormalAttribute = new Float32BufferAttribute( modifiedNormal, 3 ); + + return { + + positionAttribute: positionAttribute, + normalAttribute: normalAttribute, + morphedPositionAttribute: morphedPositionAttribute, + morphedNormalAttribute: morphedNormalAttribute + + }; + +} + + + +export { + computeTangents, + mergeBufferGeometries, + mergeBufferAttributes, + interleaveAttributes, + estimateBytesUsed, + mergeVertices, + toTrianglesDrawMode, + computeMorphedAttributes, +}; diff --git a/games/3dcity/src/micro/CityGame.js b/games/3dcity/src/micro/CityGame.js new file mode 100644 index 0000000..8f573d9 --- /dev/null +++ b/games/3dcity/src/micro/CityGame.js @@ -0,0 +1,550 @@ + +import { Micro } from './Micro.js'; +import { Tile } from './Tile.js'; + +import { MessageManager } from './MessageManager.js'; +import { Messages } from './Messages.js'; +import { TXT } from './Text.js'; + +import { Simulation } from './Simulation.js'; +import { AnimationManager } from './game/AnimationManager.js'; + +import { GameMap } from './map/GameMap.js'; +import { MapGenerator} from './map/MapGenerator.js'; + +// game TOOL +import { BuildingTool } from './tool/BuildingTool.js'; +import { BulldozerTool } from './tool/BulldozerTool.js'; +import { ParkTool } from './tool/ParkTool.js'; +import { RailTool } from './tool/RailTool.js'; +import { RoadTool } from './tool/RoadTool.js'; +import { QueryTool } from './tool/QueryTool.js'; +import { WireTool } from './tool/WireTool.js'; + + +const postMessage = self.webkitPostMessage || self.postMessage; + + +var timer; +//var timestep = 1000/30; +var Game; +var pcount = 0; +var power; +var isWorker = true; +var returnMessage + +//var ab = new ArrayBuffer( 1 ); +//CityGame.post( ab, [ab] ); +var trans = false;// ( ab.byteLength === 0 ); + + +self.onmessage = function ( e ) { CityGame.message( e ) } + + +export class CityGame { + + static message ( e ) { + + var p = e.data.tell; + + if( p == "INIT" ) { + + if( e.data.returnMessage ){ + + returnMessage = e.data.returnMessage; + isWorker = false; + + } + + Game = new MainGame( e.data.timestep ) + + } + + + if( p == "NEWMAP" ) Game.newMap(); + if( p == "PLAYMAP" ) Game.playMap(); + if( p == "TOOL" ) Game.tool(e.data.name); + if( p == "MAPCLICK" ) Game.mapClick(e.data.x, e.data.y, e.data.single || false); + + //if( p == "DESTROY" ) Game.destroy(e.data.x, e.data.y); + + //if( p == "RUN" && trans) updateTrans(e.data); + + if( p == "DIFFICULTY" ) Game.changeDifficulty(e.data.n); + if( p == "SPEED" ) Game.changeSpeed(e.data.n); + + if( p == "BUDGET") Game.handleBudgetRequest(); + if( p == "NEWBUDGET") Game.setBudget(e.data.budgetData); + + if( p == "DISASTER") Game.setDisaster(e.data.disaster); + + if( p == "EVAL") Game.getEvaluation(); + + if( p == "SAVEGAME") Game.saveGame(e.data.saveCity); + if( p == "LOADGAME") Game.loadGame(e.data.isStart); + if( p == "MAKELOADGAME") Game.makeLoadGame(e.data.savegame, e.data.isStart); + + } + + static post ( e, buffer ){ + + if( isWorker ) postMessage( e, buffer ); + else returnMessage( { data : e } ); + + } + + + +} + + +var update = function(){ + + Game.tick() + +} + + +export class MainGame { + + constructor ( timestep ) { + + this.timestep = timestep; + + this.mapSize = [128,128]; + this.difficulty = 1; + this.speed = 2; + this.oldSpeed = 0; + this.mapGen = new MapGenerator(); + + this.simulation = null; + this.gameTools = null; + this.animationManager = null; + this.map = null; + + this.isPaused = false; + this.simNeededBudget = false; + this.currentTool = null; + this.timer = null; + this.infos = []; + this.sprites = []; + + this.spritesData = null; + this.animsData = null; + //this.tilesData = null; + + this.spritesData = []; + + this.power = null; + + CityGame.post({ tell:"READY" }); + + } + + next ( delay = 0 ) { + + this.timer = setTimeout( update, delay ); + + } + + stop (){ + + if( this.timer === null ) return; + clearInterval( this.timer ); + this.timer = null + + } + + tick () { + + //if ( this.isPaused ) return + + let up = this.simulation.simTick(); + + if( up ) { + + this.infos = this.simulation.infos; + + this.processMessages( Game.simulation.messageManager.getMessages() ); + + if( Micro.haveMapAnimation ) this.animatedTiles() + + this.simulation.spriteManager.moveObjects(); + this.calculateSprites(); + + CityGame.post({ tell:"RUN", infos:this.infos, tilesData:this.map.tilesData, powerData:this.map.powerData, sprites:this.spritesData, layer:this.map.layer }); + + this.map.resetLayer(); + + } + + this.next() + + } + + newMap () { + + this.map = this.mapGen.construct( this.mapSize[0], this.mapSize[1] ); + CityGame.post({ tell:"NEWMAP", tilesData:this.map.tilesData, mapSize:this.mapSize, island:this.map.isIsland, trans:trans }); + + } + + playMap ( loading ) { + + var messageMgr = new MessageManager(); + var money = 20000; + if(this.difficulty == 1) money = 10000; + if(this.difficulty == 2) money = 5000; + + this.gameTools = { + airport: new BuildingTool(10000, Tile.AIRPORT, this.map, 6, false), + bulldozer: new BulldozerTool(this.map), + coal: new BuildingTool(3000, Tile.POWERPLANT, this.map, 4, false), + commercial: new BuildingTool(100, Tile.COMCLR, this.map, 3, false), + fire: new BuildingTool(500, Tile.FIRESTATION, this.map, 3, false), + industrial: new BuildingTool(100, Tile.INDCLR, this.map, 3, false), + nuclear: new BuildingTool(5000, Tile.NUCLEAR, this.map, 4, true), + park: new ParkTool(this.map), + police: new BuildingTool(500, Tile.POLICESTATION, this.map, 3, false), + port: new BuildingTool(3000, Tile.PORT, this.map, 4, false), + rail: new RailTool(this.map), + residential: new BuildingTool(100, Tile.FREEZ, this.map, 3, false), + road: new RoadTool(this.map), + query: new QueryTool(this.map), + stadium: new BuildingTool(5000, Tile.STADIUM, this.map, 4, false), + wire: new WireTool(this.map), + }; + + if( Micro.haveMapAnimation ) this.animationManager = new AnimationManager( this.map ); + + if(loading){ + money = this.savedGame.totalFunds; + //this.infos[3] = this.savedGame.totalPop; + this.speed = this.savedGame.speed; + this.difficulty = this.savedGame.difficulty; + this.simulation = new Simulation( this.map, this.difficulty, this.speed, true, this.savedGame); + //this.processMessages(Messages.EVAL_UPDATED); + messageMgr.sendMessage(Messages.WELCOMEBACK); + + }else{ + this.simulation = new Simulation( this.map, this.difficulty, this.speed, true); + messageMgr.sendMessage(Messages.WELCOME); + + } + + this.simulation.budget.setFunds(money); + //messageMgr.sendMessage(Messages.FUNDS_CHANGED, money); + this.processMessages( messageMgr.getMessages() ); + + // update simulation time + this.isPaused = false + //if(!trans) + //this.timer = setInterval(update, 1000/this.timestep); + //this.timer = setInterval(update, 0); + //else update(); + + this.tick() + + //this.next() + } + + + + /*changeTimeStep (n){ + + clearInterval(this.timer); + this.next() + //this.timestep = n; + //this.timer = setInterval(update, 1000/this.timestep) + //this.timer = setInterval(update, 0); + + }*/ + + changeSpeed (n){ + // 0:pause 1:slow 2:medium 3:fast + this.speed = n; + this.simulation.setSpeed(this.speed); + + if(this.speed === 0) { + this.isPaused = true; + this.stop(); + } else { + if( this.isPaused ){ + this.isPaused = false; + this.stop(); + this.tick() + } + + } + + + + /*if(this.speed === 4){ + + this.simulation.setSpeed(this.speed-1); + } else { + + this.simulation.setSpeed(this.speed); + }*/ + } + + changeDifficulty(n){ + // 0: easy 1: medium 2: hard + this.difficulty = n; + if(this.simulation) this.simulation.setDifficulty ( this.difficulty ); + } + + animatedTiles () { + + var animTiles = this.animationManager.getTiles(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1, this.isPaused ); + var i = animTiles.length; + this.animsData = new Micro.M_ARRAY_TYPE(i); + while(i--){ + var tile = animTiles[i]; + this.animsData[i] = [ tile.tileValue, tile.x, tile.y ]; + } + } + + calculateSprites () { + this.sprites = this.simulation.spriteManager.getSpritesInView(0, 0, this.mapSize[0] + 1, this.mapSize[1] + 1); + var i = this.sprites.length; + //this.spritesData = new M_ARRAY_TYPE(i); + while(i--){ + var sprite = this.sprites[i]; + this.spritesData[i] = [sprite.type, sprite.frame, sprite.x || 0, sprite.y || 0]; + } + } + + processMessages ( messages ) { + + var messageOutput = false; + + for (var i = 0, l = messages.length; i < l; i++) { + var m = messages[i]; + switch (m.message) { + case Messages.BUDGET_NEEDED: this.simNeededBudget = true; this.handleBudgetRequest(); break; + case Messages.QUERY_WINDOW_NEEDED: CityGame.post({tell:"QUERY", queryTxt:this.currentTool.getInfo() }); break; + //case Messages.DATE_UPDATED: this.infos[0] = [TXT.months[ m.data.month ], m.data.year].join(' '); break; + // case Messages.EVAL_UPDATED: this.infos[1] = TXT.cityClass[m.data.classification]; this.infos[2] = m.data.score; this.infos[3] = m.data.population; break; + //case Messages.FUNDS_CHANGED: this.infos[4] = m.data; break; + //case Messages.VALVES_UPDATED: this.infos[5] = m.data.residential; this.infos[6] = m.data.commercial; this.infos[7] = m.data.industrial; break; + default: + if (!messageOutput && TXT.goodMessages[m.message] !== undefined) { + this.infos[8] = TXT.goodMessages[m.message]; + break; + } + if (!messageOutput && TXT.badMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.badMessages[m.message]; + break; + } + if (!messageOutput && TXT.neutralMessages[m.message] !== undefined) { + messageOutput = true; + this.infos[8] = TXT.neutralMessages[m.message] ; + break; + } + } + } + } + + tool (name){ + + if(this.currentTool!==null) this.currentTool.clear(); + if(name !== "none") this.currentTool = this.gameTools[name]; + else this.currentTool = null; + + } + + destroy (x,y){ + + console.log('isDestroy') + + //console.log( 'destuct ', x, y ) + + //this.mapClick(x,y); + //this.map.powerData[this.findId(x,y)] = 1; + + // this.simulation.powerManager.setTilePower(x,y); + // var messageMgr = new Micro.MessageManager(); + // this.gameTools["bulldozer"].doTool(x, y, messageMgr, this.simulation.blockMaps ); + } + + findId (x, y){ + var id = x+(y*this.mapSize[1]); + return id; + } + + mapClick (x,y, single){ + if( this.currentTool !== null ){ + //console.log(this.currentTool[0]) + var budget = this.simulation.budget; + var evaluation = this.simulation.evaluation; + var messageMgr = new MessageManager(); + this.currentTool.doTool(x, y, this.simulation.blockMaps, messageMgr ); + this.currentTool.modifyIfEnoughFunding(budget, messageMgr); + var tell = ""; + + switch (this.currentTool.result) { + case this.currentTool.TOOLRESULT_NEEDS_BULLDOZE: tell = TXT.toolMessages.needsDoze; break; + case this.currentTool.TOOLRESULT_NO_MONEY: tell = TXT.toolMessages.noMoney; break; + default: + tell = ' '; + //if( id >= 11 && id != 15 ) this.needMapUpdate = true; + if(!single) CityGame.post({tell:"BUILD", x:x, y:y }); + break; + } + + this.processMessages(messageMgr.getMessages()); + } + } + + setDisaster (disaster){ + if (disaster === Micro.DISASTER_NONE) return; + var m = new MessageManager(); + switch (disaster) { + case Micro.DISASTER_MONSTER: this.simulation.spriteManager.makeMonster(m); break; + case Micro.DISASTER_FIRE: this.simulation.disasterManager.makeFire(m); break; + case Micro.DISASTER_FLOOD: this.simulation.disasterManager.makeFlood(m); break; + case Micro.DISASTER_CRASH: this.simulation.disasterManager.makeCrash(m); break; + case Micro.DISASTER_MELTDOWN: this.simulation.disasterManager.makeMeltdown(m); break; + case Micro.DISASTER_TORNADO: this.simulation.spriteManager.makeTornado(m); break; + } + this.processMessages(m.getMessages()); + } + + setBudget (budgetData){ + this.simulation.budget.cityTax = budgetData[0]; + this.simulation.budget.roadPercent = budgetData[1]/100; + this.simulation.budget.firePercent = budgetData[2]/100; + this.simulation.budget.policePercent = budgetData[3]/100; + } + + handleBudgetRequest () { + + this.budgetShowing = true; + + let budgetData = { + roadFund: this.simulation.budget.roadFund, + roadRate: Math.floor(this.simulation.budget.roadPercent * 100), + fireFund: this.simulation.budget.fireFund, + fireRate: Math.floor(this.simulation.budget.firePercent * 100), + policeFund: this.simulation.budget.policeFund, + policeRate: Math.floor(this.simulation.budget.policePercent * 100), + taxRate: this.simulation.budget.cityTax, + totalFunds: this.simulation.budget.totalFunds, + taxesCollected: this.simulation.budget.taxFund + }; + + CityGame.post({ tell:"BUDGET", budgetData:budgetData}); + + if (this.simNeededBudget) { + this.simulation.budget.doBudgetWindow(); + this.simNeededBudget = false; + } else { + this.simulation.budget.updateFundEffects(); + } + + + + + //this.budgetWindow.open(this.handleBudgetClosed.bind(this), budgetData); + // Let the input know we handled this request + //this.inputStatus.budgetHandled(); + } + + getEvaluation (){ + let evaluation = this.simulation.evaluation; + let problemes = ""; + for (var i = 0; i < 4; i++) { + let problemNo = evaluation.getProblemNumber(i); + let text = ''; + if (problemNo !== -1) text =TXT.problems[problemNo]; + problemes += text+"
    "; + } + + let evalData = [ evaluation.cityYes, problemes]; + + CityGame.post({ tell:"EVAL", evalData:evalData}); + + } + + + //______________________________________ SAVE + + + saveGame (cityData){ + //this.oldSpeed = this.speed; + //this.changeSpeed(0); + + let gameData = {name:"Yoooooo", everClicked: true}; + gameData.speed = this.speed; + gameData.difficulty = this.difficulty; + gameData.version = Micro.CURRENT_VERSION; + gameData.city = cityData; + this.simulation.save(gameData); + + gameData = JSON.stringify(gameData); + + CityGame.post({ tell:"SAVEGAME", gameData:gameData, key:Micro.KEY }); + + //this.changeSpeed(this.oldSpeed); + } + /*makeSaveGame : function(gameData){ + gameData.version = Micro.CURRENT_VERSION; + gameData = JSON.stringify(gameData); + }*/ + + //______________________________________ LOAD + + loadGame (atStart){ + var isStart = atStart || false; + CityGame.post({ tell:"LOADGAME", key:Micro.KEY, isStart:isStart }); + } + + makeLoadGame( gameData, atStart ) { + + + + let isStart = atStart || false; + clearInterval(this.timer); + this.savedGame = JSON.parse(gameData); + + + + //this.simulation.load(this.savedGame); + //this.map = this.simulation.map; + // this.everClicked = savedGame.everClicked; + //if (savedGame.version !== Micro.CURRENT_VERSION) this.transitionOldSave(savedGame); + //savedGame.isSavedGame = true; + /*if(this.map){ + this.map.load(this.savedGame); + }else{*/ + this.map = new GameMap(Micro.MAP_WIDTH, Micro.MAP_HEIGHT); + this.map.load(this.savedGame); + //} + + // + + //this.playMap(true); + //this.simulation.map = this.map;//return + // + //this.map = this.simulation.map; + + CityGame.post({ tell:"FULLREBUILD", tilesData:this.map.tilesData, mapSize:this.mapSize, island:this.map.isIsland, cityData:this.savedGame.city, isStart:isStart }); + } + + transitionOldSave (savedGame) { + switch (savedGame.version) { + case 1: savedGame.everClicked = false; + /* falls through */ + case 2: + savedGame.pollutionMaxX = Math.floor(savedGame.width / 2); + savedGame.pollutionMaxY = Math.floor(savedGame.height / 2); + savedGame.cityCentreX = Math.floor(savedGame.width / 2); + savedGame.cityCentreY = Math.floor(savedGame.height / 2); + break; + //default: throw new Error('Unknown save version!'); + } + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/MessageManager.js b/games/3dcity/src/micro/MessageManager.js new file mode 100644 index 0000000..c1d846b --- /dev/null +++ b/games/3dcity/src/micro/MessageManager.js @@ -0,0 +1,31 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + + +export class MessageManager { + + constructor () { + this.data = []; + } + + sendMessage (message, data) { + this.data.push({message: message, data: data}); + } + + clear () { + this.data = []; + } + + getMessages () { + return this.data.slice(); + } + +} + diff --git a/games/3dcity/src/micro/Messages.js b/games/3dcity/src/micro/Messages.js new file mode 100644 index 0000000..a0035ce --- /dev/null +++ b/games/3dcity/src/micro/Messages.js @@ -0,0 +1,108 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { MiscUtils } from './Micro.js'; + +var messageData = { + AUTOBUDGET_CHANGED: MiscUtils.mcd('Autobudget changed'), + BUDGET_NEEDED: MiscUtils.mcd('User needs to budget'), + BUDGET_REQUESTED: MiscUtils.mcd('Budget window requested'), + BUDGET_WINDOW_CLOSED: MiscUtils.mcd('Budget window closed'), + BLACKOUTS_REPORTED: MiscUtils.mcd('Blackouts reported'), + CLASSIFICATION_UPDATED: MiscUtils.mcd('Classification updated'), + CONGRATS_SHOWING: MiscUtils.mcd('Congratulations showing'), + CONGRATS_WINDOW_CLOSED: MiscUtils.mcd('Congratulations window closed'), + DATE_UPDATED: MiscUtils.mcd('Date changed'), + DEBUG_WINDOW_REQUESTED: MiscUtils.mcd('Debug Window Requested'), + DEBUG_WINDOW_CLOSED: MiscUtils.mcd('Debug Window Closed'), + DISASTER_REQUESTED: MiscUtils.mcd('Disaster Requested'), + DISASTER_WINDOW_CLOSED: MiscUtils.mcd('Disaster window closed'), + EARTHQUAKE: MiscUtils.mcd('Earthquake'), + EVAL_REQUESTED: MiscUtils.mcd('Evaluation Requested'), + EVAL_UPDATED: MiscUtils.mcd('Evaluation Updated'), + EVAL_WINDOW_CLOSED: MiscUtils.mcd('Eval window closed'), + EXPLOSION_REPORTED: MiscUtils.mcd('Explosion Reported'), + FIRE_REPORTED: MiscUtils.mcd('Fire!'), + FIRE_STATION_NEEDS_FUNDING: MiscUtils.mcd('Fire station needs funding'), + FLOODING_REPORTED: MiscUtils.mcd('Flooding reported'), + FRONT_END_MESSAGE: MiscUtils.mcd('Front-end Message'), + FUNDS_CHANGED: MiscUtils.mcd('Total funds has changed'), + HEAVY_TRAFFIC: MiscUtils.mcd('Heavy traffic in city'), + HELICOPTER_CRASHED: MiscUtils.mcd('Helicopter crashed'), + HIGH_CRIME: MiscUtils.mcd('High crime'), + HIGH_POLLUTION: MiscUtils.mcd('High pollution'), + MONSTER_SIGHTED: MiscUtils.mcd('Monster sighted'), + NAG_WINDOW_CLOSED: MiscUtils.mcd('Nag window closed'), + NEED_AIRPORT: MiscUtils.mcd('Airport needed'), + NEED_ELECTRICITY: MiscUtils.mcd('More power needed'), + NEED_FIRE_STATION: MiscUtils.mcd('Fire station needed'), + NEED_MORE_COMMERCIAL: MiscUtils.mcd('More commercial zones needed'), + NEED_MORE_INDUSTRIAL: MiscUtils.mcd('More industrial zones needed'), + NEED_MORE_RAILS: MiscUtils.mcd('More railways needed'), + NEED_MORE_RESIDENTIAL: MiscUtils.mcd('More residential needed'), + NEED_MORE_ROADS: MiscUtils.mcd('More roads needed'), + NEED_POLICE_STATION: MiscUtils.mcd('Police station needed'), + NEED_SEAPORT: MiscUtils.mcd('Seaport needed'), + NEED_STADIUM: MiscUtils.mcd('Stadium needed'), + NO_MONEY: MiscUtils.mcd('No money'), + NOT_ENOUGH_POWER: MiscUtils.mcd('Not enough power'), + NUCLEAR_MELTDOWN: MiscUtils.mcd('Nuclear Meltdown'), + PLANE_CRASHED: MiscUtils.mcd('Plane crashed'), + POLICE_NEEDS_FUNDING: MiscUtils.mcd('Police need funding'), + POPULATION_UPDATED: MiscUtils.mcd('Population updated'), + QUERY_WINDOW_CLOSED: MiscUtils.mcd('Query window closed'), + QUERY_WINDOW_NEEDED: MiscUtils.mcd('Query window needed'), + REACHED_CAPITAL: MiscUtils.mcd('Now a capital'), + REACHED_CITY: MiscUtils.mcd('Now a city'), + REACHED_METROPOLIS: MiscUtils.mcd('Now a metropolis'), + REACHED_MEGALOPOLIS: MiscUtils.mcd('Now a megalopolis'), + REACHED_TOWN: MiscUtils.mcd('Now a town'), + REACHED_VILLAGE: MiscUtils.mcd('Now a village'), + ROAD_NEEDS_FUNDING: MiscUtils.mcd('Roads need funding'), + SAVE_REQUESTED: MiscUtils.mcd('Save requested'), + SAVE_WINDOW_CLOSED: MiscUtils.mcd('Save window closed'), + SCORE_UPDATED: MiscUtils.mcd('Score updated'), + SCREENSHOT_LINK_CLOSED: MiscUtils.mcd('Screenshot link closed'), + SCREENSHOT_WINDOW_CLOSED: MiscUtils.mcd('Screenshot window closed'), + SCREENSHOT_WINDOW_REQUESTED: MiscUtils.mcd('Screenshot window requested'), + SETTINGS_WINDOW_CLOSED: MiscUtils.mcd('Settings window closed'), + SETTINGS_WINDOW_REQUESTED: MiscUtils.mcd('Settings window requested'), + SHIP_CRASHED: MiscUtils.mcd('Shipwrecked'), + SOUND_EXPLOSIONHIGH: MiscUtils.mcd('Explosion! Bang!'), + SOUND_EXPLOSIONLOW: MiscUtils.mcd('Explosion! Bang!'), + SOUND_HEAVY_TRAFFIC: MiscUtils.mcd('Heavy Traffic sound'), + SOUND_HONKHONK: MiscUtils.mcd('HonkHonk sound'), + SOUND_MONSTER: MiscUtils.mcd('Monster sound'), + SPEED_CHANGE: MiscUtils.mcd('Speed change'), + SPRITE_DYING: MiscUtils.mcd('Sprite dying'), + SPRITE_MOVED: MiscUtils.mcd('Sprite move'), + TAX_TOO_HIGH: MiscUtils.mcd('Tax too high'), + TOOL_CLICKED: MiscUtils.mcd('Tool clicked'), + TORNADO_SIGHTED: MiscUtils.mcd('Tornado sighted'), + TOUCH_WINDOW_CLOSED: MiscUtils.mcd('Touch Window closed'), + TRAFFIC_JAMS: MiscUtils.mcd('Traffic jams reported'), + TRAIN_CRASHED: MiscUtils.mcd('Train crashed'), + VALVES_UPDATED: MiscUtils.mcd('Valves updated'), + WELCOME: MiscUtils.mcd('Welcome to micropolisJS'), + WELCOMEBACK: MiscUtils.mcd('Welcome back to your 3D city') +}; + +export const Messages = Object.defineProperties({}, messageData); +//var Messages = Object.defineProperties({}, messageData); + +var disasterMessages = [Messages.EARTHQUAKE, Messages.EXPLOSION_REPORTED, Messages.FIRE_REPORTED, + Messages.FLOODING_REPORTED, Messages.MONSTER_SIGHTED, Messages.NUCLEAR_MELTDOWN, + Messages.TORNADO_SIGHTED]; +Object.defineProperty(Messages, 'disasterMessages', MiscUtils.mcd(disasterMessages)); + +var crashes = [Messages.HELICOPTER_CRASHED, Messages.PLANE_CRASHED, Messages.SHIP_CRASHED, Messages.TRAIN_CRASHED]; +Object.defineProperty(Messages, 'crashes', MiscUtils.mcd(crashes)); + + +//export { Messages }; \ No newline at end of file diff --git a/games/3dcity/src/micro/Micro.js b/games/3dcity/src/micro/Micro.js new file mode 100644 index 0000000..d4a70eb --- /dev/null +++ b/games/3dcity/src/micro/Micro.js @@ -0,0 +1,228 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + + + +export const Micro = { + + haveMapAnimation: true, + + localStorage : null, + + GameMapProps : ['cityCentreX', 'cityCentreY', 'pollutionMaxX', 'pollutionMaxY', 'width', 'height'], + savePropsVar : ['cityTime'], + CensusProps : ['resPop', 'comPop', 'indPop', 'crimeRamp', 'pollutionRamp', 'landValueAverage', 'pollutionAverage', + 'crimeAverage', 'totalPop', 'resHist10', 'resHist120', 'comHist10', 'comHist120', 'indHist10', + 'indHist120', 'crimeHist10', 'crimeHist120', 'moneyHist10', 'moneyHist120', 'pollutionHist10', 'pollutionHist120' + ], + BudgetProps : ['autoBudget', 'totalFunds', 'policePercent', 'roadPercent', 'firePercent', 'roadSpend', + 'policeSpend', 'fireSpend', 'roadMaintenanceBudget', 'policeMaintenanceBudget', + 'fireMaintenanceBudget', 'cityTax', 'roadEffect', 'policeEffect', 'fireEffect' + ], + // eval + PROBLEMS : ['CVP_CRIME', 'CVP_POLLUTION', 'CVP_HOUSING', 'CVP_TAXES', 'CVP_TRAFFIC', 'CVP_UNEMPLOYMENT', 'CVP_FIRE'], + NUMPROBLEMS : 7,//this.PROBLEMS.length, + NUM_COMPLAINTS : 4, + problemData : [], + EvalProps : ['cityClass', 'cityScore'], + + speedPowerScan : [2, 4, 5, 6], + speedPollutionTerrainLandValueScan : [2, 7, 17, 30], + speedCrimeScan : [1, 8, 18, 32], + speedPopulationDensityScan : [1, 9, 19, 38], + speedFireAnalysis : [1, 10, 20, 40], + CENSUS_FREQUENCY_10 : 4, + CENSUS_FREQUENCY_120 : 4*10, + TAX_FREQUENCY : 48, + + MAP_WIDTH : 128, + MAP_HEIGHT : 128, + + MAP_DEFAULT_WIDTH : 128*3, //Micro.MAP_WIDTH*3, + MAP_DEFAULT_HEIGHT : 128*3, //Micro.MAP_HEIGHT*3, + MAP_BIG_DEFAULT_WIDTH : 128*16, //Micro.MAP_WIDTH*16, + MAP_BIG_DEFAULT_HEIGHT : 128*16, //Micro.MAP_HEIGHT*16, + MAP_BIG_DEFAULT_ID : "bigMap", + MAP_PARENT_ID : "splashContainer", + MAP_DEFAULT_ID : "SplashCanvas", + + //GameCanvas + DEFAULT_WIDTH : 400, + DEFAULT_HEIGHT : 400, + DEFAULT_ID : "MicropolisCanvas", + RCI_DEFAULT_ID : "RCICanvas", + + // Simulation + LEVEL_EASY : 0, + LEVEL_MED : 1, + LEVEL_HARD : 2, + + SPEED_PAUSED : 0, + SPEED_SLOW : 1, + SPEED_MED : 2, + SPEED_FAST : 3, + SPEED_ULTRA : 4, + + // Traffic + ROUTE_FOUND : 1, + NO_ROUTE_FOUND : 0, + NO_ROAD_FOUND : -1, + MAX_TRAFFIC_DISTANCE : 30, + perimX : [-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2], + perimY : [-2,-2,-2,-1, 0, 1, 2, 2, 2, 1, 0,-1], + + //SpriteConstants + SPRITE_TRAIN : 1, + SPRITE_HELICOPTER : 2, + SPRITE_AIRPLANE : 3, + SPRITE_SHIP : 4, + SPRITE_MONSTER : 5, + SPRITE_TORNADO : 6, + SPRITE_EXPLOSION : 7, + + // Evaluation + CC_VILLAGE : 'VILLAGE', + CC_TOWN : 'TOWN', + CC_CITY : 'CITY', + CC_CAPITAL : 'CAPITAL', + CC_METROPOLIS : 'METROPOLIS', + CC_MEGALOPOLIS : 'MEGALOPOLIS', + CRIME : 0, + POLLUTION : 1, + HOUSING : 2, + TAXES : 3, + TRAFFIC : 4, + UNEMPLOYMENT : 5, + FIRE : 6, + + // Valves + RES_VALVE_RANGE : 2000, + COM_VALVE_RANGE : 1500, + IND_VALVE_RANGE : 1500, + taxTable : [ 200, 150, 120, 100, 80, 50, 30, 0, -10, -40, -100, -150, -200, -250, -300, -350, -400, -450, -500, -550, -600], + extMarketParamTable : [1.2, 1.1, 0.98], + + // Budget + RLevels : [0.7, 0.9, 1.2], + FLevels : [1.4, 1.2, 0.8], + MAX_ROAD_EFFECT : 32, + MAX_POLICESTATION_EFFECT : 1000, + MAX_FIRESTATION_EFFECT : 1000, + + policeMaintenanceCost : 100, + fireMaintenanceCost : 100, + roadMaintenanceCost : 1, + railMaintenanceCost : 2, + + // PowerManager + COAL_POWER_STRENGTH : 700, + NUCLEAR_POWER_STRENGTH : 2000, + + //DisasterWindow + DISASTER_NONE:'None', + DISASTER_MONSTER:'Monster', + DISASTER_FIRE:'Fire', + DISASTER_FLOOD:'Flood', + DISASTER_CRASH:'Crash', + DISASTER_MELTDOWN:'Meltdown', + DISASTER_TORNADO:'Tornado', + + // storage + CURRENT_VERSION : 3, + KEY : 'micropolisJSGame', + + // disasters + DisChance: [479, 239, 59], + + // map generator + TERRAIN_CREATE_ISLAND : 0, + TERRAIN_TREE_LEVEL : -1,//level for tree creation + TERRAIN_LAKE_LEVEL : -1, //level for river curviness; -1==auto, 0==none, >0==level + TERRAIN_CURVE_LEVEL : -1,//level for lake creation; -1==auto, 0==none, >0==level + ISLAND_RADIUS : 18, + + + M_ARRAY_TYPE: ( typeof Float32Array !== 'undefined' ) ? Float32Array : Array, + + // census + arrs: ['res', 'com', 'ind', 'crime', 'money', 'pollution'], + + directionTable : [0, 3, 2, 1, 3, 4, 5, 7, 6, 5, 7, 8, 1], + + SMOOTH_NEIGHBOURS_THEN_BLOCK: 0, + SMOOTH_ALL_THEN_CLAMP : 1, + + simData:null, + messageManager:null, + +} + +export class EventEmitter { + + static emitEvent ( event, value ) { + + // ??? + Micro.messageManager.sendMessage( event, value ); + + } + +} +//var M_ARRAY_TYPE; +//if(!M_ARRAY_TYPE) { M_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; } + + +export class MiscUtils { + + /**/ + + //static makeConstantDescriptor = function(value) { + static mcd (value) { + return {configurable: false, enumerable: false, writeable: false, value: value}; + } + + static rotate10Arrays () { + for (var i = 0; i < Micro.arrs.length; i++) { + var name10 = Micro.arrs[i] + 'Hist10'; + //this[name10] = [0].concat(this[name10].slice(0, -1)); + this[name10].pop() + this[name10].unshift(0) + } + } + + static rotate120Arrays () { + for (var i = 0; i < Micro.arrs.length; i++) { + var name120 = Micro.arrs[i] + 'Hist120'; + //this[name120] = [0].concat(this[name120].slice(0, -1)); + this[name120].pop() + this[name120].unshift(0) + } + } + + static isCallable ( f ) { + return typeof(f) === 'function'; + } + + static copyFrom (data, sourceMap, sourceFn) { + var mapFn = function(elem) { return sourceFn(elem); }; + var i = sourceMap.data.length; + while(i--) data[i] = sourceMap.data[i].map(mapFn); + } + + static makeArrayOf (length, value) { + //var result = []; + //var result = new M_ARRAY_TYPE(length); + var result = new Array(length); + //for (var a = 0; a < length; a++) result[a] = value; + var i = length; while(i--) result[i] = value; + return result; + + } + + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/Simulation.js b/games/3dcity/src/micro/Simulation.js new file mode 100644 index 0000000..7c78af9 --- /dev/null +++ b/games/3dcity/src/micro/Simulation.js @@ -0,0 +1,420 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ + + +import { Micro } from './Micro.js'; +import { Messages } from './Messages.js'; +import { MessageManager } from './MessageManager.js'; + +import { TXT } from './Text.js'; +import { SpriteManager } from './sprite/SpriteManager.js'; + +import { Evaluation } from './game/Evaluation.js'; +import { Valves } from './game/Valves.js'; +import { Budget } from './game/Budget.js'; +import { Census } from './game/Census.js'; +import { BlockMap } from './game/BlockMap.js'; +import { PowerManager } from './game/PowerManager.js'; +import { MapScanner } from './game/MapScanner.js'; +import { RepairManager } from './game/RepairManager.js'; +import { Traffic } from './game/Traffic.js'; +import { DisasterManager } from './game/DisasterManager.js'; + +import { Residential } from './zone/Residential.js'; +import { Commercial } from './zone/Commercial.js'; +import { Industrial } from './zone/Industrial.js'; +import { Road } from './zone/Road.js'; +import { Transport } from './zone/Transport.js'; +import { EmergencyServices } from './zone/EmergencyServices.js'; +import { MiscTiles } from './zone/MiscTiles.js'; +import { Stadia } from './zone/Stadia.js'; + +import { MapUtils } from './map/MapUtils.js'; + +export class Simulation { + + constructor ( gameMap, gameLevel, speed, is3D, savedGame ) { + + if (gameLevel !== Micro.LEVEL_EASY && gameLevel !== Micro.LEVEL_MED && gameLevel !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); + // if (speed !== Micro.SPEED_PAUSED && speed !== Micro.SPEED_SLOW && speed !== Micro.SPEED_MED && speed !== Micro.SPEED_FAST) throw new Error('Invalid speed!'); + + this.map = gameMap; + this.gameLevel = gameLevel; + + this.div = this.map.width / 8; + + this.is3D = is3D || false; + + this.time = typeof performance === 'undefined' ? Date : performance; + + this.speed = speed; + this.speedCycle = 0; + this.phaseCycle = 0; + this.simCycle = 0; + this.doInitialEval = true; + this.cityTime = 50; + this.cityPopLast = 0; + this.messageLast = Messages.VILLAGE_REACHED; + this.startingYear = 1900; + + // Last valves updated to the user + this.resValveLast = 0; + this.comValveLast = 0; + this.indValveLast = 0; + + // Last date sent to front end + this._cityYearLast = -1; + this._cityMonthLast = -1; + + // Last time we relayed a message from PowerManager to the front-end + this._lastPowerMessage = null; + + this.infos = [] + + // And now, the main cast of characters + this.evaluation = new Evaluation( this.gameLevel ); + this.valves = new Valves(); + this.budget = new Budget(); + this.census = new Census(); + this.powerManager = new PowerManager( this.map ); + this.spriteManager = new SpriteManager( this.map ); + this.mapScanner = new MapScanner(this.map); + this.repairManager = new RepairManager(this.map); + this.traffic = new Traffic(this.map, this.spriteManager); + this.disasterManager = new DisasterManager(this.map, this.spriteManager, this.gameLevel); + + this.messageManager = new MessageManager(); + Micro.messageManager = this.messageManager; + + let w = this.map.width, h = this.map.height; + + this.blockMaps = { + + // Holds a "distance score" for the block from the city centre, range -64 to 64 + cityCentreDistScoreMap: new BlockMap( w, h, 8), + + // Holds a score representing how dangerous an area is, in range 0-250 (larger is worse) + crimeRateMap: new BlockMap( w, h, 2), + + // A map used to note positions of fire stations during the map scan, range 0-1000 + fireStationMap: new BlockMap( w, h, 8), + // Holds a value containing a score representing the effect of fire cover in this neighborhood, range 0-1000 + fireStationEffectMap: new BlockMap( w, h, 8), + + // Holds scores representing the land value in the range 0-250 + landValueMap: new BlockMap( w, h, 2), + + // A map used to note positions of police stations during the map scan, range 0-1000 + policeStationMap: new BlockMap( w, h, 8), + // Holds a value containing a score representing how much crime is dampened in this block, range 0-1000 + policeStationEffectMap: new BlockMap( w, h, 8), + + // Holds a value representing the amount of pollution in a neighbourhood, in the range 0-255 + pollutionDensityMap: new BlockMap( w, h, 2), + + // Holds a value representing population density of a block, in the range 0-510 + populationDensityMap: new BlockMap( w, h, 2), + + // Holds a value representing the rate of growth of a neighbourhood in the range -200 to +200 + rateOfGrowthMap: new BlockMap( w, h, 8), + + // Scores a block on how undeveloped/unspoilt it is, range 0-240 + terrainDensityMap: new BlockMap( w, h, 4), + // Scores the volume of traffic in this cluster, range 0-240 + trafficDensityMap: new BlockMap( w, h, 2), + + // Temporary maps + tempMap1: new BlockMap( w, h, 2), + tempMap2: new BlockMap( w, h, 2), + tempMap3: new BlockMap( w, h, 4) + + }; + + this.clearCensus(); + + if (savedGame) { + this.load(savedGame); + //this.cityPopLast = savedGame.totalPop; + } else { + this.budget.setFunds( 20000 ); + this.census.totalPop = 1; + } + + Micro.simData = this; + + this.init(); + + } + + + save ( saveData ) { + + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) + saveData[Micro.savePropsVar[i]] = this[Micro.savePropsVar[i]]; + + this.map.save(saveData); + this.evaluation.save(saveData); + this.valves.save(saveData); + this.budget.save(saveData); + this.census.save(saveData); + + } + + load (saveData) { + //console.log(saveData) + this.messageManager.clear(); + for (let i = 0, l = Micro.savePropsVar.length; i < l; i++) + this[Micro.savePropsVar[i]] = saveData[Micro.savePropsVar[i]]; + + //this.map.load(saveData); + this.evaluation.load(saveData); + this.valves.load(saveData); + this.budget.load(saveData); + this.census.load(saveData); + + } + + setSpeed (s) { + this.speed = s; + } + + setDifficulty(s) { + + if (s !== Micro.LEVEL_EASY && s !== Micro.LEVEL_MED && s !== Micro.LEVEL_HARD) throw new Error('Invalid level!'); + this.gameLevel = s; + this.disasterManager.setDifficulty( this.gameLevel ); + + } + + isPaused () { + + return this.speed === Micro.SPEED_PAUSED; + + } + + simTick () { + + let up = this.simFrame(); + + if(up){ + this.updateTime(); + this.updateInfo(); + } + + return up; + + } + + updateInfo(){ + + this.infos[0] = [TXT.months[ this._cityMonthLast ], this._cityYearLast].join(' '); + + this.infos[1] = TXT.cityClass[this.evaluation.cityScore]; + this.infos[2] = this.evaluation.cityScore; + this.infos[3] = this.evaluation.cityPop; + + this.infos[4] = this.budget.totalFunds; + this.infos[5] = this.valves.resValve; + this.infos[6] = this.valves.comValve; + this.infos[7] = this.valves.indValve; + + //this.infos[8] = '' // message + + this.infos[9] = this.map.powerChange; + this.map.powerChange = false; + + return this.infos + + } + + simFrame () { + + if ( this.budget.awaitingValues ) return false; + + if ( this.speed === Micro.SPEED_PAUSED ) return false; + + // Default to slow speed + let threshold = 100; + if (this.speed === Micro.SPEED_MED ) threshold = 50; + if (this.speed === Micro.SPEED_FAST ) threshold = 10; + if (this.speed === Micro.SPEED_ULTRA ) threshold = 5; + + let now = this.time.now();//new Date() + if ( now - this.prevTime < threshold ) return false; + + this.messageManager.clear(); + + this.simulate(); + this.prevTime = now; + return true + + } + + clearCensus () { + this.census.clearCensus(); + this.powerManager.clearPowerStack(); + this.blockMaps.fireStationMap.clear(); + this.blockMaps.policeStationMap.clear(); + } + + init () { + + this.prevTime = -1; + + + // Register actions + this.powerManager.registerHandlers(this.mapScanner, this.repairManager); + Commercial.registerHandlers(this.mapScanner, this.repairManager); + EmergencyServices.registerHandlers(this.mapScanner, this.repairManager); + Industrial.registerHandlers(this.mapScanner, this.repairManager); + MiscTiles.registerHandlers(this.mapScanner, this.repairManager); + Road.registerHandlers(this.mapScanner, this.repairManager); + Residential.registerHandlers(this.mapScanner, this.repairManager); + Stadia.registerHandlers(this.mapScanner, this.repairManager); + Transport.registerHandlers(this.mapScanner, this.repairManager); + + + this.evaluation.evalInit(); + this.valves.setValves(this.gameLevel, this.census, this.budget); + this.clearCensus(); + //this.mapScanner.mapScan(0, this.map.width, simData); + this.mapScanner.mapScan(0, this.map.width, null); + this.powerManager.doPowerScan(this.census); + + MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); + MapUtils.crimeScan(this.census, this.blockMaps); + MapUtils.populationDensityScan(this.map, this.blockMaps); + MapUtils.fireAnalysis(this.blockMaps); + //this.census.totalPop = 1; + + // if (savedGame) this.load(savedGame); + } + + simulate () { + + this.phaseCycle &= 15; + + let speedIndex = this.speed - 1; + switch (this.phaseCycle){ + case 0: + if (++this.simCycle > 1023) this.simCycle = 0; + if (this.doInitialEval) { this.doInitialEval = false; this.evaluation.cityEvaluation(); } + this.cityTime++; + if ((this.simCycle & 1) === 0) this.valves.setValves( this.gameLevel, this.census, this.budget ); + this.clearCensus(); + break; + case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: + this.mapScanner.mapScan((this.phaseCycle - 1) * this.div, this.phaseCycle * this.div, null); + break; + case 9: + if (this.cityTime % Micro.CENSUS_FREQUENCY_10 === 0) this.census.take10Census(this.budget); + if (this.cityTime % Micro.CENSUS_FREQUENCY_120 === 0) this.census.take120Census(this.budget); + if (this.cityTime % Micro.TAX_FREQUENCY === 0) { this.budget.collectTax( this.gameLevel, this.census ); this.evaluation.cityEvaluation(); }; + break; + case 10: if ((this.simCycle % 5) === 0){ MapUtils.neutraliseRateOfGrowthMap(this.blockMaps);}; MapUtils.neutraliseTrafficMap(this.blockMaps); this.sendMessages(); break; + case 11: if ((this.simCycle % Micro.speedPowerScan[speedIndex]) === 0) this.powerManager.doPowerScan(this.census); break; + case 12: if ((this.simCycle % Micro.speedPollutionTerrainLandValueScan[speedIndex]) === 0) MapUtils.pollutionTerrainLandValueScan(this.map, this.census, this.blockMaps); break; + case 13: if ((this.simCycle % Micro.speedCrimeScan[speedIndex]) === 0) MapUtils.crimeScan(this.census, this.blockMaps); break; + case 14: if ((this.simCycle % Micro.speedPopulationDensityScan[speedIndex]) === 0) MapUtils.populationDensityScan(this.map, this.blockMaps); break; + case 15: if ((this.simCycle % Micro.speedFireAnalysis[speedIndex]) === 0) MapUtils.fireAnalysis(this.blockMaps); this.disasterManager.doDisasters(this.census ); break; + } + // Go on the the next phase. + this.phaseCycle = (this.phaseCycle + 1) & 15; + } + + sendMessages () { + + this.checkGrowth(); + let totalZonePop = this.census.resZonePop + this.census.comZonePop + this.census.indZonePop; + let powerPop = this.census.nuclearPowerPop + this.census.coalPowerPop; + switch (this.cityTime & 63) { + case 1: if (Math.floor(totalZonePop / 4) >= this.census.resZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_RESIDENTIAL); break; + case 5: if (Math.floor(totalZonePop / 8) >= this.census.comZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_COMMERCIAL); break; + case 10: if (Math.floor(totalZonePop / 8) >= this.census.indZonePop) this.messageManager.sendMessage(Messages.NEED_MORE_INDUSTRIAL); break; + case 14: if (totalZonePop > 10 && totalZonePop * 2 > this.census.roadTotal) this.messageManager.sendMessage(Messages.NEED_MORE_ROADS); break; + case 18: if (totalZonePop > 50 && totalZonePop > this.census.railTotal) this.messageManager.sendMessage(Messages.NEED_MORE_RAILS); break; + case 22: if (totalZonePop > 10 && powerPop == 0) this.messageManager.sendMessage(Messages.NEED_ELECTRICITY); break; + case 26: if (this.census.resPop > 500 && this.census.stadiumPop === 0) { this.messageManager.sendMessage(Messages.NEED_STADIUM); this.valves.resCap = true; } else { this.valves.resCap = false;}; break; + case 28: if (this.census.indPop > 70 && this.census.seaportPop === 0) { this.messageManager.sendMessage(Messages.NEED_SEAPORT); this.valves.indCap = true; } else { this.valves.indCap = false; }; break; + case 30: if (this.census.comPop > 100 && this.census.airportPop === 0) { this.messageManager.sendMessage(Messages._NEED_AIRPORT); this.valves.comCap = true; } else { this.valves.comCap = false; }; break; + case 32: let zoneCount = this.census.unpoweredZoneCount + this.census.poweredZoneCount; if (zoneCount > 0) { if (this.census.poweredZoneCount / zoneCount < 0.7) this.messageManager.sendMessage(Messages.BLACKOUTS_REPORTED);}; break; + case 35: if (this.census.pollutionAverage > 60) this.messageManager.sendMessage(Messages.HIGH_POLLUTION); break; + case 42: if (this.census.crimeAverage > 100) this.messageManager.sendMessage(Messages.HIGH_CRIME); break; + case 45: if (this.census.totalPop > 60 && this.census.fireStationPop === 0) this.messageManager.sendMessage(Messages.NEED_FIRE_STATION); break; + case 48: if (this.census.totalPop > 60 && this.census.policeStationPop === 0) this.messageManager.sendMessage(Messages.NEED_POLICE_STATION); break; + case 51: if (this.budget.cityTax > 12) this.messageManager.sendMessage(Messages.TAX_TOO_HIGH); break; + case 54: if (this.budget.roadEffect < Math.floor(5 * this.budget.MAX_ROAD_EFFECT / 8) && this.census.roadTotal > 30) this.messageManager.sendMessage(Messages.ROAD_NEEDS_FUNDING); break; + case 57: if (this.budget.fireEffect < Math.floor(7 * this.budget.MAX_FIRE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.FIRE_STATION_NEEDS_FUNDING); break; + case 60: if (this.budget.policeEffect < Math.floor(7 * this.budget.MAX_POLICE_STATION_EFFECT / 10) && this.census.totalPop > 20) this.messageManager.sendMessage(Messages.POLICE_NEEDS_FUNDING); break; + case 63: if (this.census.trafficAverage > 60) this.messageManager.sendMessage(Messages.TRAFFIC_JAMS, -1, -1, true); break; + } + } + + checkGrowth () { + + if ((this.cityTime & 3) !== 0) return; + + let message = ''; + let cityPop = this.evaluation.getPopulation(this.census); + + if ( cityPop !== this.cityPopLast ) { + let lastClass = this.evaluation.getCityClass(this.cityPopLast); + let newClass = this.evaluation.getCityClass(cityPop); + if (lastClass !== newClass) { + switch (newClass) { + case Micro.CC_VILLAGE: + // Don't mention it. + break; + case Micro.CC_TOWN: message = Messages.REACHED_TOWN; break; + case Micro.CC_CITY: message = Messages.REACHED_CITY; break; + case Micro.CC_CAPITAL: message = Messages.REACHED_CAPITAL; break; + case Micro.CC_METROPOLIS: message = Messages.REACHED_METROPOLIS; break; + case Micro.CC_MEGALOPOLIS: message = Messages.REACHED_MEGALOPOLIS; break; + default: break; + } + } + } + if (message !== '' && message !== this.messageLast) { + this.messageManager.sendMessage(message); + this.messageLast = message; + } + this.cityPopLast = cityPop; + + } + + // update date + + setYear (year) { + if (year < this.startingYear) year = this.startingYear; + year = (year - this.startingYear) - (this.cityTime / 48); + this.cityTime += year * 48; + this.updateTime(); + } + + updateTime () { + + let megalinium = 1000000; + let cityYear = Math.floor(this.cityTime / 48) + this.startingYear; + let cityMonth = Math.floor(this.cityTime % 48) >> 2; + + if (cityYear >= megalinium) { + this.setYear(this.startingYear); + return; + } + + if (this._cityYearLast !== cityYear || this._cityMonthLast !== cityMonth) { + this._cityYearLast = cityYear; + this._cityMonthLast = cityMonth; + this.messageManager.sendMessage(Messages.DATE_UPDATED, {month: cityMonth, year: cityYear}); + } + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/Storage.js b/games/3dcity/src/micro/Storage.js new file mode 100644 index 0000000..14da348 --- /dev/null +++ b/games/3dcity/src/micro/Storage.js @@ -0,0 +1,61 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { Micro } from './Micro.js'; + +export class Storage { + + static getSavedGame = function() { + if(Micro.localStorage==null) return; + var savedGame = Micro.localStorage.getItem(Micro.KEY); + if (savedGame !== null) { + savedGame = JSON.parse(savedGame); + if (savedGame.version !== Micro.CURRENT_VERSION) this.transitionOldSave(savedGame); + // Flag as a saved game for Game/Simulation etc... + savedGame.isSavedGame = true; + } + + return savedGame; + } + + static saveGame = function(gameData) { + if(Micro.localStorage==null) return; + gameData.version = Micro.CURRENT_VERSION; + gameData = JSON.stringify(gameData); + Micro.localStorage.setItem(Micro.KEY, gameData); + } + + static transitionOldSave (savedGame) { + switch (savedGame.version) { + case 1: savedGame.everClicked = false; + /* falls through */ + case 2: + savedGame.pollutionMaxX = Math.floor(savedGame.width / 2); + savedGame.pollutionMaxY = Math.floor(savedGame.height / 2); + savedGame.cityCentreX = Math.floor(savedGame.width / 2); + savedGame.cityCentreY = Math.floor(savedGame.height / 2); + break; + //default: throw new Error('Unknown save version!'); + } + } + +} + + +/* + var Storage = { + getSavedGame: getSavedGame, + saveGame: saveGame, + transitionOldSave: transitionOldSave + }; + + +Micro.defineProperty(Storage, 'CURRENT_VERSION', Micro.makeConstantDescriptor(3)); +Micro.defineProperty(Storage, 'KEY', Micro.makeConstantDescriptor('micropolisJSGame')); +Micro.defineProperty(Storage, 'canStore', Micro.makeConstantDescriptor(window.localStorage !== undefined)); +*/ \ No newline at end of file diff --git a/games/3dcity/src/micro/Text.js b/games/3dcity/src/micro/Text.js new file mode 100644 index 0000000..aef8e88 --- /dev/null +++ b/games/3dcity/src/micro/Text.js @@ -0,0 +1,127 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from './Micro.js'; +import { Messages } from './Messages.js'; + +const Text = function(){ + // TODO Some kind of rudimentary L20N based on navigator.language? + + // Query tool strings + var densityStrings = ['Low', 'Medium', 'High', 'Very High']; + var landValueStrings = ['Slum', 'Lower Class', 'Middle Class', 'High']; + var crimeStrings = ['Safe', 'Light', 'Moderate', 'Dangerous']; + var pollutionStrings = ['None', 'Moderate', 'Heavy', 'Very Heavy']; + var rateStrings = ['Declining', 'Stable', 'Slow Growth', 'Fast Growth']; + var zoneTypes = ['Clear', 'Water', 'Trees', 'Rubble', 'Flood', 'Radioactive Waste', + 'Fire', 'Road', 'Power', 'Rail', 'Residential', 'Commercial', + 'Industrial', 'Seaport', 'Airport', 'Coal Power', 'Fire Department', + 'Police Department', 'Stadium', 'Nuclear Power', 'Draw Bridge', + 'Radar Dish', 'Fountain', 'Industrial', 'Steelers 38 Bears 3', + 'Draw Bridge', 'Ur 238']; + + // Evaluation window + var gameLevel = {}; + gameLevel['' + Micro.LEVEL_EASY] = 'Easy'; + gameLevel['' + Micro.LEVEL_MED] = 'Medium'; + gameLevel['' + Micro.LEVEL_HARD] = 'Hard'; + + var cityClass = {}; + cityClass[Micro.CC_VILLAGE] = 'VILLAGE'; + cityClass[Micro.CC_TOWN] = 'TOWN'; + cityClass[Micro.CC_CITY] = 'CITY'; + cityClass[Micro.CC_CAPITAL] = 'CAPITAL'; + cityClass[Micro.CC_METROPOLIS] = 'METROPOLIS'; + cityClass[Micro.CC_MEGALOPOLIS] = 'MEGALOPOLIS'; + + var problems = {}; + problems[Micro.CRIME] = 'Crime'; + problems[Micro.POLLUTION] = 'Pollution'; + problems[Micro.HOUSING] = 'Housing'; + problems[Micro.TAXES] = 'Taxes'; + problems[Micro.TRAFFIC] = 'Traffic'; + problems[Micro.UNEMPLOYMENT] = 'Unemployment'; + problems[Micro.FIRE] = 'Fire'; + + // months + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + + // Tool strings + var toolMessages = { + noMoney: 'Insufficient funds to build that', + needsDoze: 'Area must be bulldozed first' + }; + + // Message strings + var neutralMessages = {}; + neutralMessages[Messages.FIRE_STATION_NEEDS_FUNDING] = 'Fire departments need funding'; + neutralMessages[Messages.NEED_AIRPORT] = 'Commerce requires an Airport'; + neutralMessages[Messages.NEED_FIRE_STATION] = 'Citizens demand a Fire Department'; + neutralMessages[Messages.NEED_ELECTRICITY] = 'Build a Power Plant'; + neutralMessages[Messages.NEED_MORE_INDUSTRIAL] = 'More industrial zones needed'; + neutralMessages[Messages.NEED_MORE_COMMERCIAL] = 'More commercial zones needed'; + neutralMessages[Messages.NEED_MORE_RESIDENTIAL] = 'More residential zones needed'; + neutralMessages[Messages.NEED_MORE_RAILS] = 'Inadequate rail system'; + neutralMessages[Messages.NEED_MORE_ROADS] = 'More roads required'; + neutralMessages[Messages.NEED_POLICE_STATION] = 'Citizens demand a Police Department'; + neutralMessages[Messages.NEED_SEAPORT] = 'Industry requires a Sea Port'; + neutralMessages[Messages.NEED_STADIUM] = 'Residents demand a Stadium'; + neutralMessages[Messages.ROAD_NEEDS_FUNDING] = 'Roads deteriorating, due to lack of funds'; + neutralMessages[Messages.POLICE_NEEDS_FUNDING] = 'Police departments need funding'; + neutralMessages[Messages.WELCOME] = 'Welcome to 3D City'; + neutralMessages[Messages.WELCOMEBACK] = 'Welcome to 3D City'; + + var badMessages = {}; + badMessages[Messages.BLACKOUTS_REPORTED] = 'Brownouts, build another Power Plant'; + badMessages[Messages.COPTER_CRASHED] = 'A helicopter crashed '; + badMessages[Messages.EARTHQUAKE] = 'Major earthquake reported !!'; + badMessages[Messages.EXPLOSION_REPORTED] = 'Explosion detected '; + badMessages[Messages.FLOODING_REPORTED] = 'Flooding reported !'; + badMessages[Messages.FIRE_REPORTED] = 'Fire reported '; + badMessages[Messages.HEAVY_TRAFFIC] = 'Heavy Traffic reported'; + badMessages[Messages.HIGH_CRIME] = 'Crime very high'; + badMessages[Messages.HIGH_POLLUTION] = 'Pollution very high'; + badMessages[Messages.MONSTER_SIGHTED] = 'A Monster has been sighted !'; + badMessages[Messages.NO_MONEY] = 'YOUR CITY HAS GONE BROKE'; + badMessages[Messages.NOT_ENOUGH_POWER] = 'Blackouts reported. insufficient power capacity'; + badMessages[Messages.NUCLEAR_MELTDOWN] = 'A Nuclear Meltdown has occurred !!'; + badMessages[Messages.PLANE_CRASHED] = 'A plane has crashed '; + badMessages[Messages.SHIP_CRASHED] = 'Shipwreck reported '; + badMessages[Messages.TAX_TOO_HIGH] = 'Citizens upset. The tax rate is too high'; + badMessages[Messages.TORNADO_SIGHTED] = 'Tornado reported !'; + badMessages[Messages.TRAFFIC_JAMS] = 'Frequent traffic jams reported'; + badMessages[Messages.TRAIN_CRASHED] = 'A train crashed '; + + var goodMessages = {}; + goodMessages[Messages.REACHED_CAPITAL] = 'Population has reached 50,000'; + goodMessages[Messages.REACHED_CITY] = 'Population has reached 10,000'; + goodMessages[Messages.REACHED_MEGALOPOLIS] = 'Population has reached 500,000'; + goodMessages[Messages.REACHED_METROPOLIS] = 'Population has reached 100,000'; + goodMessages[Messages.REACHED_TOWN] = 'Population has reached 2,000'; + + return { + badMessages: badMessages, + cityClass: cityClass, + crimeStrings: crimeStrings, + densityStrings: densityStrings, + gameLevel: gameLevel, + goodMessages: goodMessages, + landValueStrings: landValueStrings, + months: months, + neutralMessages: neutralMessages, + problems: problems, + pollutionStrings: pollutionStrings, + rateStrings: rateStrings, + toolMessages: toolMessages, + zoneTypes: zoneTypes + } + +}; + +export const TXT = new Text(); \ No newline at end of file diff --git a/games/3dcity/src/micro/Tile.js b/games/3dcity/src/micro/Tile.js new file mode 100644 index 0000000..82ee57a --- /dev/null +++ b/games/3dcity/src/micro/Tile.js @@ -0,0 +1,705 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { math } from './math/math.js'; + + +export class ZoneUtils { + + // TileUtils + + static pixToWorld (p) { + return p >> 4; + } + + static worldToPix (w) { + return w << 4; + } + + static unwrapTile ( tile ) { + + if ( tile.isTile ) return tile = tile.getValue(); + return tile + } + + static canBulldoze (tile) { + + tile = ZoneUtils.unwrapTile( tile ) + return (tile >= Tile.FIRSTRIVEDGE && tile <= Tile.LASTRUBBLE) || + (tile >= Tile.POWERBASE + 2 && tile <= Tile.POWERBASE + 12) || + (tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP + 2); + } + + static isCommercial (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.COMBASE && tile < Tile.INDBASE; + } + + static isIndustrial (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.INDBASE && tile < Tile.PORTBASE; + } + + static isResidential (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.RESBASE && tile < Tile.HOSPITALBASE; + } + + static isDriveable (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return (tile >= Tile.ROADBASE && tile <= Tile.LASTRAIL) || tile === Tile.RAILHPOWERV || tile === Tile.RAILVPOWERH; + } + + static isFire (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.FIREBASE && tile < Tile.ROADBASE; + } + + static isFlood (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.FLOOD && tile < Tile.LASTFLOOD; + } + + static isManualExplosion (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP; + } + + static isRail (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.RAILBASE && tile < Tile.RESBASE; + } + + static isRoad (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return tile >= Tile.ROADBASE && tile < Tile.POWERBASE; + } + + static normalizeRoad (tile) { + tile = ZoneUtils.unwrapTile( tile ) + return (tile >= Tile.ROADBASE && tile <= Tile.LASTROAD + 1) ? (tile & 15) + 64 : tile; + } + + /// + + static isCommercialZone (tile) { + return tile.isZone() && ZoneUtils.isCommercial(tile) + } + + static isIndustrialZone (tile) { + return tile.isZone() && ZoneUtils.isIndustrial(tile) + } + + static isResidentialZone (tile) { + return tile.isZone() && ZoneUtils.isResidential(tile) + } + + static randomFire (tile) { + return new Tiles(Tile.FIRE + (math.getRandom16() & 3), Tile.ANIMBIT); + } + + static randomRubble ( tile ) { + return new Tiles(Tile.RUBBLE + (math.getRandom16() & 3), Tile.BULLBIT); + } + + static HOSPITAL (tile) { + } + + // ZoneUtils + + static checkBigZone = function(tile) { + + let result + switch (tile) { + case Tile.POWERPLANT: + case Tile.PORT: + case Tile.NUCLEAR: + case Tile.STADIUM: + result = {zoneSize: 4, deltaX: 0, deltaY: 0}; + break; + + case Tile.POWERPLANT + 1: + case Tile.COALSMOKE3: + case Tile.COALSMOKE3 + 1: + case Tile.COALSMOKE3 + 2: + case Tile.PORT + 1: + case Tile.NUCLEAR + 1: + case Tile.STADIUM + 1: + result = {zoneSize: 4, deltaX: -1, deltaY: 0}; + break; + + case Tile.POWERPLANT + 4: + case Tile.PORT + 4: + case Tile.NUCLEAR + 4: + case Tile.STADIUM + 4: + result = {zoneSize: 4, deltaX: 0, deltaY: -1}; + break; + + case Tile.POWERPLANT + 5: + case Tile.PORT + 5: + case Tile.NUCLEAR + 5: + case Tile.STADIUM + 5: + result = {zoneSize: 4, deltaX: -1, deltaY: -1}; + break; + case Tile.AIRPORT: result = {zoneSize: 6, deltaX: 0, deltaY: 0}; break; + case Tile.AIRPORT + 1: result = {zoneSize: 6, deltaX: -1, deltaY: 0}; break; + case Tile.AIRPORT + 2: result = {zoneSize: 6, deltaX: -2, deltaY: 0}; break; + case Tile.AIRPORT + 3: result = {zoneSize: 6, deltaX: -3, deltaY: 0}; break; + case Tile.AIRPORT + 6: result = {zoneSize: 6, deltaX: 0, deltaY: -1}; break; + case Tile.AIRPORT + 7: result = {zoneSize: 6, deltaX: -1, deltaY: -1}; break; + case Tile.AIRPORT + 8: result = {zoneSize: 6, deltaX: -2, deltaY: -1}; break; + case Tile.AIRPORT + 9: result = {zoneSize: 6, deltaX: -3, deltaY: -1}; break; + case Tile.AIRPORT + 12: result = {zoneSize: 6, deltaX: 0, deltaY: -2}; break; + case Tile.AIRPORT + 13: result = {zoneSize: 6, deltaX: -1, deltaY: -2}; break; + case Tile.AIRPORT + 14: result = {zoneSize: 6, deltaX: -2, deltaY: -2}; break; + case Tile.AIRPORT + 15: result = {zoneSize: 6, deltaX: -3, deltaY: -2}; break; + case Tile.AIRPORT + 18: result = {zoneSize: 6, deltaX: 0, deltaY: -3}; break; + case Tile.AIRPORT + 19: result = {zoneSize: 6, deltaX: -1, deltaY: -3}; break; + case Tile.AIRPORT + 20: result = {zoneSize: 6, deltaX: -2, deltaY: -3}; break; + case Tile.AIRPORT + 21: result = {zoneSize: 6, deltaX: -3, deltaY: -3}; break; + default: result = {zoneSize: 0, deltaX: 0, deltaY: 0}; break; + } + return result; + } + + + static checkZoneSize (tile) { + if ((tile >= Tile.RESBASE - 1 && tile <= Tile.PORTBASE - 1) || + (tile >= Tile.LASTPOWERPLANT + 1 && tile <= Tile.POLICESTATION + 4) || + (tile >= Tile.CHURCH1BASE && tile <= Tile.CHURCH7LAST)) { + return 3; + } + + if ((tile >= Tile.PORTBASE && tile <= Tile.LASTPORT) || + (tile >= Tile.COALBASE && tile <= Tile.LASTPOWERPLANT) || + (tile >= Tile.STADIUMBASE && tile <= Tile.LASTZONE)) { + return 4; + } + return 0; + } + + static fireZone ( map, x, y, blockMaps ) { + + let tileValue = map.getTileValue(x, y); + let zoneSize = 2; + + // A zone being on fire naturally hurts growth + let value = blockMaps.rateOfGrowthMap.worldGet(x, y); + value = math.clamp(value - 20, -200, 200); + blockMaps.rateOfGrowthMap.worldSet(x, y, value); + + if (tileValue === Tile.AIRPORT) zoneSize = 5; + else if (tileValue >= Tile.PORTBASE) zoneSize = 3; + else if (tileValue < Tile.PORTBASE) zoneSize = 2; + + // Make remaining tiles of the zone bulldozable + let xDelta, yDelta, xTem, yTem; + for ( xDelta = -1; xDelta < zoneSize; xDelta++) { + for ( yDelta = -1; yDelta < zoneSize; yDelta++) { + xTem = x + xDelta; + yTem = y + yDelta; + if (!map.testBounds(xTem, yTem)) continue; + if (map.getTileValue(xTem, yTem >= Tile.ROADBASE)) map.addTileFlags(xTem, yTem, Tile.BULLBIT); + } + } + + } + + static getLandPollutionValue ( blockMaps, x, y ) { + + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 30) return 0; + if (landValue < 80) return 1; + if (landValue < 150) return 2; + return 3; + + } + + static incRateOfGrowth ( blockMaps, x, y, growthDelta ) { + + let currentRate = blockMaps.rateOfGrowthMap.worldGet(x, y); + // TODO why the scale of 4 here + let newValue = math.clamp( currentRate + growthDelta * 4, -200, 200 ); + blockMaps.rateOfGrowthMap.worldSet(x, y, newValue); + + } + + // Calls map.putZone after first checking for flood, fire and radiation + static putZone ( map, x, y, centreTile, isPowered ) { + + let dY, dX, tileValue; + for ( dY = -1; dY < 2; dY++) { + for ( dX = -1; dX < 2; dX++) { + tileValue = map.getTileValue(x + dX, y + dY); + if (tileValue >= Tile.FLOOD && tileValue < Tile.ROADBASE) return; + } + } + map.putZone(x, y, centreTile, 3); + map.addTileFlags(x, y, Tile.BULLBIT); + if (isPowered) map.addTileFlags(x, y, Tile.POWERBIT); + + } + +} + +//export const ZoneUtils = ZoneUtils + +export class Tiles { + + constructor ( tileValue = Tile.DIRT, bitMask ) { + + this.isTile = true; + + /* + if (!(this.isTile)) return new Tiles(); + if (arguments.length > 0 && typeof(tileValue) !== 'number') throw new Error('Tile constructor called with invalid tileValue ' + tileValue); + if (arguments.length > 1 && typeof(bitMask) !== 'number') throw new Error('Tile constructor called with invalid bitMask ' + bitMask); + if (arguments.length > 1 && (tileValue < Tile.TILE_INVALID || tileValue >= Tile.TILE_COUNT)) throw new Error('Tile constructor called with out-of-range tileValue ' + tileValue); + if (arguments.length > 1 && (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1))) throw new Error('Tile constructor called with out-of-range bitmask ' + bitMask); + */ + + this._value = tileValue; + if (arguments.length > 1) this._value |= bitMask; + + } + + getValue () { + return this._value & Tile.BIT_MASK; + } + + setValue ( tileValue ) { + if ( arguments.length === 0 || typeof(tileValue) !== 'number' || tileValue < 0) throw new Error('Invalid parameter'); + + let existingFlags = 0; + if ( tileValue < Tile.BIT_START ) existingFlags = this._value & Tile.ALLBITS;//this.getFlags(); + this._value = tileValue | existingFlags; + } + + isBulldozable () { + return (this._value & Tile.BULLBIT) > 0; + } + + isAnimated () { + return (this._value & Tile.ANIMBIT) > 0; + } + + isConductive () { + return (this._value & Tile.CONDBIT) > 0; + } + + isCombustible () { + return (this._value & Tile.BURNBIT) > 0; + } + + isPowered () { + return (this._value & Tile.POWERBIT) > 0; + } + + isZone () { + return (this._value & Tile.ZONEBIT) > 0; + } + + addFlags (bitMask) { + if (!arguments.length || typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value |= bitMask; + } + + removeFlags (bitMask) { + if (!arguments.length || typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= Tile.BIT_END << 1) throw new Error('Invalid parameter'); + this._value &= ~bitMask; + } + + setFlags (bitMask) { + //if (typeof(bitMask) !== 'number' || bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Invalid parameter'); + //if (arguments.length === 0) throw new Error('Tile setFlags called with no arguments'); + //if (typeof(bitMask) !== 'number') throw new Error('Tile setFlags called with invalid bitmask ' + bitMask); + // if (bitMask < Tile.BIT_START || bitMask >= (Tile.BIT_END << 1)) throw new Error('Tile setFlags called with out-of-range bitmask ' + bitMask); + let existingValue = this._value & ~Tile.ALLBITS; + this._value = existingValue | bitMask; + } + + getFlags () { + return this._value & Tile.ALLBITS; + } + + getRawValue () { + return this._value; + } + + set ( tileValue, bitMask ) { + if (arguments.length < 2 || typeof(tileValue) !== 'number' || typeof(bitMask) !== 'number' || tileValue >= Tile.TILE_COUNT) throw new Error('Invalid parameter'); + this.setValue(tileValue); + this.setFlags(bitMask); + } + + toString () { + let value = this.getValue(); + let s = 'Tile# ' + value; + s += this.isCombustible() ? ' burning' : ''; + s += this.isPowered() ? ' powered' : ''; + s += this.isAnimated() ? ' animated' : ''; + s += this.isConductive() ? ' conductive' : ''; + s += this.isZone() ? ' zone' : ''; + s += this.isBulldozable() ? ' bulldozeable' : ''; + return s; + } + +} + + + +export const Tile = { + + // Bit-masks for statusBits + POWERBIT : 0x8000, // bit 15, tile has power. + CONDBIT : 0x4000, // bit 14. tile can conduct electricity. + BURNBIT : 0x2000, // bit 13, tile can be lit. + BULLBIT : 0x1000, // bit 12, tile is bulldozable. + ANIMBIT : 0x0800, // bit 11, tile is animated. + ZONEBIT : 0x0400, // bit 10, tile is the center tile of the zone. + BLBNBIT : 0x1000 | 0x2000, //BULLBIT | BURNBIT, + BLBNCNBIT : 0x1000 | 0x2000 | 0x4000, //BULLBIT | BURNBIT | CONDBIT, + BNCNBIT : 0x2000 | 0x4000, //BURNBIT | CONDBIT, + ASCBIT : 0x0800 | 0x4000 | 0x2000, // ANIMBIT | CONDBIT | BURNBIT, + ALLBITS : 0x8000 | 0x4000 | 0x2000 | 0x1000 | 0x0800 | 0x0400, // POWERBIT | CONDBIT | BURNBIT | BULLBIT | ANIMBIT | ZONEBIT, + BIT_START : 0x400, + BIT_END : 0x8000, + BIT_MASK : 0x400 - 1, // BIT_START - 1, + + // TODO Add comment for each tile + DIRT : 0, // Clear tile + // tile 1 ? + + /* Water */ + RIVER : 2, + REDGE : 3, + CHANNEL : 4, + FIRSTRIVEDGE : 5, + // tile 6 -- 19 ? + LASTRIVEDGE : 20, + WATER_LOW : 2, //RIVER, // First water tile + WATER_HIGH : 20, //LASTRIVEDGE, // Last water tile (inclusive) + + TREEBASE : 21, + WOODS_LOW : 21, //TREEBASE, + LASTTREE : 36, + WOODS : 37, + UNUSED_TRASH1 : 38, + UNUSED_TRASH2 : 39, + WOODS_HIGH : 39, //UNUSED_TRASH2, // Why is an 'UNUSED' tile used? + WOODS2 : 40, + WOODS3 : 41, + WOODS4 : 42, + WOODS5 : 43, + + // Rubble (4 tiles) + RUBBLE : 44, + LASTRUBBLE : 47, + // fLOOD 4 tiles + FLOOD : 48, + LASTFLOOD : 51, + // Radiation + RADTILE : 52, // Radio-active contaminated tile + + UNUSED_TRASH3 : 53, + UNUSED_TRASH4 : 54, + UNUSED_TRASH5 : 55, + + /* Fire animation (8 tiles) */ + FIRE : 56-8, + FIREBASE : 56-8, //FIRE, + LASTFIRE : 63-8, + + HBRIDGE : 64, // Horizontal bridge + ROADBASE : 64, // HBRIDGE, + VBRIDGE : 65, // Vertical bridge + ROADS : 66, + ROADS2 : 67, + ROADS3 : 68, + ROADS4 : 69, + ROADS5 : 70, + ROADS6 : 71, + ROADS7 : 72, + ROADS8 : 73, + ROADS9 : 74, + ROADS10 : 75, + INTERSECTION : 76, + HROADPOWER : 77, + VROADPOWER : 78, + BRWH : 79, + LTRFBASE : 80, // First tile with low traffic + // tile 81 -- 94 ? + BRWV : 95, + // tile 96 -- 110 ? + BRWXXX1 : 111, + // tile 96 -- 110 ? + BRWXXX2 : 127, + // tile 96 -- 110 ? + BRWXXX3 : 143, + HTRFBASE : 144, // First tile with high traffic + // tile 145 -- 158 ? + BRWXXX4 : 159, + // tile 160 -- 174 ? + BRWXXX5 : 175, + // tile 176 -- 190 ? + BRWXXX6 : 191, + // tile 192 -- 205 ? + LASTROAD : 206, + BRWXXX7 : 207, + + /* Power lines */ + HPOWER : 208, + VPOWER : 209, + LHPOWER : 210, + LVPOWER : 211, + LVPOWER2 : 212, + LVPOWER3 : 213, + LVPOWER4 : 214, + LVPOWER5 : 215, + LVPOWER6 : 216, + LVPOWER7 : 217, + LVPOWER8 : 218, + LVPOWER9 : 219, + LVPOWER10 : 220, + RAILHPOWERV : 221, // Horizontal rail, vertical power + RAILVPOWERH : 222, // Vertical rail, horizontal power + POWERBASE : 208, //HPOWER, + LASTPOWER : 222, //RAILVPOWERH, + + UNUSED_TRASH6 : 223, + + /* Rail */ + HRAIL : 224, + VRAIL : 225, + LHRAIL : 226, + LVRAIL : 227, + LVRAIL2 : 228, + LVRAIL3 : 229, + LVRAIL4 : 230, + LVRAIL5 : 231, + LVRAIL6 : 232, + LVRAIL7 : 233, + LVRAIL8 : 234, + LVRAIL9 : 235, + LVRAIL10 : 236, + HRAILROAD : 237, + VRAILROAD : 238, + RAILBASE : 224, //HRAIL, + LASTRAIL : 238, + + ROADVPOWERH : 239, /* bogus? */ + + // Residential zone tiles + + RESBASE : 240, // Empty residential, tiles 240--248 + FREEZ : 244, // center-tile of 3x3 empty residential + + HOUSE : 249, // Single tile houses until 260 + LHTHR : 249,//HOUSE, + HHTHR : 260, + + RZB : 265, // center tile first 3x3 tile residential + + HOSPITALBASE : 405, // Center of hospital (tiles 405--413) + HOSPITAL : 409, // Center of hospital (tiles 405--413) + + CHURCHBASE : 414, // Center of church (tiles 414--422) + CHURCH0BASE : 414, // numbered alias + CHURCH : 418, // Center of church (tiles 414--422) + CHURCH0 : 418, // numbered alias + + // Commercial zone tiles + + COMBASE : 423, // Empty commercial, tiles 423--431 + // tile 424 -- 426 ? + COMCLR : 427, + // tile 428 -- 435 ? + CZB : 436, + // tile 437 -- 608 ? + COMLAST : 609, + // tile 610, 611 ? + + // Industrial zone tiles. + INDBASE : 612, // Top-left tile of empty industrial zone. + INDCLR : 616, // Center tile of empty industrial zone. + LASTIND : 620, // Last tile of empty industrial zone. + + // Industrial zone population 0, value 0: 621 -- 629 + IND1 : 621, // Top-left tile of first non-empty industry zone. + IZB : 625, // Center tile of first non-empty industry zone. + + // Industrial zone population 1, value 0: 630 -- 638 + + // Industrial zone population 2, value 0: 639 -- 647 + IND2 : 641, + IND3 : 644, + + // Industrial zone population 3, value 0: 648 -- 656 + IND4 : 649, + IND5 : 650, + + // Industrial zone population 0, value 1: 657 -- 665 + + // Industrial zone population 1, value 1: 666 -- 674 + + // Industrial zone population 2, value 1: 675 -- 683 + IND6 : 676, + IND7 : 677, + + // Industrial zone population 3, value 1: 684 -- 692 + IND8 : 686, + IND9 : 689, + + // Seaport + PORTBASE : 693, // Top-left tile of the seaport. + PORT : 698, // Center tile of the seaport. + LASTPORT : 708, // Last tile of the seaport. + + AIRPORTBASE : 709, + // tile 710 ? + RADAR : 711, + // tile 712 -- 715 ? + AIRPORT : 716, + // tile 717 -- 744 ? + + // Coal power plant (4x4). + COALBASE : 745, // First tile of coal power plant. + POWERPLANT : 750, // 'Center' tile of coal power plant. + LASTPOWERPLANT : 760, // Last tile of coal power plant. + + // Fire station (3x3). + FIRESTBASE : 761, // First tile of fire station. + FIRESTATION : 765, // 'Center tile' of fire station. + // 769 last tile fire station. + + POLICESTBASE : 770, + // tile 771 -- 773 ? + POLICESTATION : 774, + // tile 775 -- 778 ? + + // Stadium (4x4). + STADIUMBASE : 779, // First tile stadium. + STADIUM : 784, // 'Center tile' stadium. + // Last tile stadium 794. + + // tile 785 -- 799 ? + FULLSTADIUM : 800, + // tile 801 -- 810 ? + + // Nuclear power plant (4x4). + NUCLEARBASE : 811, // First tile nuclear power plant. + NUCLEAR : 816, // 'Center' tile nuclear power plant. + LASTZONE : 826, // Also last tile nuclear power plant. + + LIGHTNINGBOLT : 827, + + // bridge horisontal open close + HBRDG0 : 828, + HBRDG1 : 829, + HBRDG2 : 830, + HBRDG3 : 831, + //HBRDG_END : 832, + + RADAR0 : 832, + RADAR1 : 833, + RADAR2 : 834, + RADAR3 : 835, + RADAR4 : 836, + RADAR5 : 837, + RADAR6 : 838, + RADAR7 : 839, + FOUNTAIN : 840, + // tile 841 -- 843: fountain animation. + INDBASE2 : 844, + TELEBASE : 844, + // tile 845 -- 850 ? + TELELAST : 851, + SMOKEBASE : 852, + // tile 853 -- 859 ? + TINYEXP : 860, + // tile 861 -- 863 ? + SOMETINYEXP : 864, + // tile 865 -- 866 ? + LASTTINYEXP : 867, + // tile 868 -- 882 ? + TINYEXPLAST : 883, + // tile 884 -- 915 ? + + COALSMOKE1 : 916, // Chimney animation at coal power plant (2, 0). + // 919 last animation tile for chimney at coal power plant (2, 0). + + COALSMOKE2 : 920, // Chimney animation at coal power plant (3, 0). + // 923 last animation tile for chimney at coal power plant (3, 0). + + COALSMOKE3 : 924, // Chimney animation at coal power plant (2, 1). + // 927 last animation tile for chimney at coal power plant (2, 1). + + COALSMOKE4 : 928, // Chimney animation at coal power plant (3, 1). + // 931 last animation tile for chimney at coal power plant (3, 1). + + FOOTBALLGAME1 : 932, + // tile 933 -- 939 ? + FOOTBALLGAME2 : 940, + // tile 941 -- 94 bridge open close + VBRDG0 : 948, + VBRDG1 : 949, + VBRDG2 : 950, + VBRDG3 : 951, + // nuclear animation // disable + NUKESWIRL1 : 952, + NUKESWIRL2 : 953, + NUKESWIRL3 : 954, + NUKESWIRL4 : 955, + + // Tiles 956-959 unused (originally) + // TILE_COUNT : 960, + + // Extended zones: 956-1019 + CHURCH1BASE : 956, + CHURCH1 : 960, + CHURCH2BASE : 965, + CHURCH2 : 969, + CHURCH3BASE : 974, + CHURCH3 : 978, + CHURCH4BASE : 983, + CHURCH4 : 987, + CHURCH5BASE : 992, + CHURCH5 : 996, + CHURCH6BASE : 1001, + CHURCH6 : 1005, + CHURCH7BASE : 1010, + CHURCH7 : 1014, + CHURCH7LAST : 1018, + + // Tiles 1020-1023 unused + TILE_COUNT : 1024, + TILE_INVALID : -1, // Invalid tile (not used in the world map). + MIN_SIZE : 16, // Minimum size of tile in pixels +}; + +export const RoadTable = [ + Tile.ROADS, Tile.ROADS2, Tile.ROADS, Tile.ROADS3, + Tile.ROADS2, Tile.ROADS2, Tile.ROADS4, Tile.ROADS8, + Tile.ROADS, Tile.ROADS6, Tile.ROADS, Tile.ROADS7, + Tile.ROADS5, Tile.ROADS10, Tile.ROADS9, Tile.INTERSECTION +] + +export const RailTable = [ + Tile.LHRAIL, Tile.LVRAIL, Tile.LHRAIL, Tile.LVRAIL2, + Tile.LVRAIL, Tile.LVRAIL, Tile.LVRAIL3, Tile.LVRAIL7, + Tile.LHRAIL, Tile.LVRAIL5, Tile.LHRAIL, Tile.LVRAIL6, + Tile.LVRAIL4, Tile.LVRAIL9, Tile.LVRAIL8, Tile.LVRAIL10 +] + +export const WireTable = [ + Tile.LHPOWER, Tile.LVPOWER, Tile.LHPOWER, Tile.LVPOWER2, + Tile.LVPOWER, Tile.LVPOWER, Tile.LVPOWER3, Tile.LVPOWER7, + Tile.LHPOWER, Tile.LVPOWER5, Tile.LHPOWER, Tile.LVPOWER6, + Tile.LVPOWER4, Tile.LVPOWER9, Tile.LVPOWER8, Tile.LVPOWER10 +] \ No newline at end of file diff --git a/games/3dcity/src/micro/_not_use/InputStatus.js b/games/3dcity/src/micro/_not_use/InputStatus.js new file mode 100644 index 0000000..9cc0713 --- /dev/null +++ b/games/3dcity/src/micro/_not_use/InputStatus.js @@ -0,0 +1,190 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from '../Micro.js'; + +export class InputStatus { + + constructor ( map ) { + + this.gameTools = new Micro.GameTools(map); + this.canvas = document.getElementById(Micro.DEFAULT_ID); + + // Tool clicks + this.clickX = -1; + this.clickY = -1; + + // Keyboard Movement + this.up = false; + this.down = false; + this.left = false; + this.right = false; + + // Mouse movement + this.mouseX = -1; + this.mouseY = -1; + + // Tool buttons + this.toolName = null; + this.currentTool = null; + this.toolWidth = 0; + this.toolColour = ''; + + // Other buttons + this.budgetRequested = false; + this.evalRequested = false; + this.disasterRequested = false; + + // Speed + this.speedChangeRequested = false; + this.requestedSpeed = null; + + this.bindKeys(); + + var _this = this; + this.canvas.addEventListener( 'mouseenter', function(e) { _this.mouseEnterHandler(e); }, false ); + this.canvas.addEventListener( 'mouseleave', function(e) { _this.mouseLeaveHandler(e); }, false ); + + var bb = document.getElementsByClassName('toolButton'); + for(var i=0; i= width || this.y < 0 || this.y >= height) + throw new Error('Position constructed with bad bounds ' + this + ' ' + deltaX + ' ' + deltaY); + if (!moveOK) + throw new Error('Position did not move correctly ' + this + ' ' + deltaX + ' ' + deltaY); + }; + + + Position.prototype._assignFrom = function(from) { + this.x = from.x; + this.y = from.y; + }; + + + Position.prototype.toString = function() { + return 'Position (' + this.x + ', ' + this.y + ')'; + }; + + + Position.prototype.toInt = function() { + return this.y * width + this.x; + }; + + + Position.prototype.move = function(dir) { + switch (dir) { + case Direction.INVALID: + return true; + case Direction.NORTH: + if (this.y > 0) { + this.y--; + return true; + } + break; + case Direction.NORTHEAST: + if (this.y > 0 && this.x < width - 1) { + this.y--; + this.x++; + return true; + } + break; + case Direction.EAST: + if (this.x < width - 1) { + this.x++; + return true; + } + break; + case Direction.SOUTHEAST: + if (this.y < height - 1 && this.x < width - 1) { + this.x++; + this.y++; + return true; + } + break; + case Direction.SOUTH: + if (this.y < height - 1) { + this.y++; + return true; + } + break; + case Direction.SOUTHWEST: + if (this.y < height - 1 && this.x > 0) { + this.y++; + this.x--; + return true; + } + break; + case Direction.WEST: + if (this.x > 0) { + this.x--; + return true; + } + break; + case Direction.NORTHWEST: + if (this.y > 0 && this.x > 0) { + this.y--; + this.x--; + return true; + } + break; + } + return false; + }; + + + return Position; +} + + +export { PositionMaker }; diff --git a/games/3dcity/src/micro/game/AnimationManager.js b/games/3dcity/src/micro/game/AnimationManager.js new file mode 100644 index 0000000..8f7ac5d --- /dev/null +++ b/games/3dcity/src/micro/game/AnimationManager.js @@ -0,0 +1,199 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Tile, ZoneUtils } from '../Tile.js'; +import { TileHistory } from './TileHistory.js'; +//import { TileUtils } from './tileUtils'; + +export class AnimationManager { + + constructor ( map, animationPeriod, blinkPeriod ) { + + animationPeriod = animationPeriod || 5; + blinkPeriod = blinkPeriod || 30; + + this._map = map; + this.animationPeriod = animationPeriod; + this.blinkPeriod = blinkPeriod; + this.shouldBlink = false; + this.count = 1; + + // When painting we keep track of what frames + // have been painted at which map coordinates so we can + // consistently display the correct frame even as the + // canvas moves + this._lastPainted = null; + + this._data = []; + this.initArray(); + this.registerAnimations(); + + } + + initArray () { + // Map all tiles to their own value in case we ever + // look up a tile that is not animated + for (let i = 0; i < Tile.TILE_COUNT; i++) this._data[i] = i; + } + + inSequence(tileValue, lastValue) { + // It is important that we use the base value as the starting point + // rather than the last painted value: base values often don't recur + // in their sequences + let seen = [tileValue]; + let current = this._data[tileValue]; + + while (seen.indexOf(current) === -1) { + if (current === lastValue) return true; + + seen.push(current); + current = this._data[current]; + } + return false; + } + + getTiles( startX, startY, boundX, boundY, isPaused = false ) { + + let shouldChangeAnimation = false; + + if (!isPaused) this.count += 1; + + if ((this.count % this.blinkPeriod) === 0) this.shouldBlink = !this.shouldBlink; + + if ((this.count % this.animationPeriod) === 0 && !isPaused) shouldChangeAnimation = true; + + let newPainted = new TileHistory(); + let tilesToPaint = []; + + for (let x = startX; x < boundX; x++) { + for (let y = startY; y < boundY; y++) { + if (x < 0 || x >= this._map.width || y < 0 || y >= this._map.height) continue; + + let tile = this._map.getTile(x, y); + /*if (tile.isZone() && !tile.isPowered() && this.shouldBlink) { + tilesToPaint.push({x: x, y: y, tileValue: Tile.LIGHTNINGBOLT}); + continue; + }*/ + + if (!tile.isAnimated()) continue; + + let tileValue = tile.getValue(); + let newTile = Tile.TILE_INVALID; + let last; + + if (this._lastPainted) last = this._lastPainted.getTile(x, y); + + if (shouldChangeAnimation) { + // Have we painted any of this sequence before? If so, paint the next tile + if (last && this.inSequence(tileValue, last)) { + + + newTile = this._data[last]; + + if (last === Tile.LASTTINYEXP) { + this._map.setTo( x, y, ZoneUtils.randomRubble() ); + newTile = this._map.getTileValue(x, y); + } else { + newTile = this._data[last]; + } + + + } else { + // Either we haven't painted anything here before, or the last tile painted + // there belongs to a different tile's animation sequence + newTile = this._data[tileValue]; + } + } else { + // Have we painted any of this sequence before? If so, paint the same tile + if (last && this.inSequence(tileValue, last)) newTile = last; + } + + if (newTile === Tile.TILE_INVALID) continue; + + tilesToPaint.push({x: x, y: y, tileValue: newTile}); + newPainted.setTile(x, y, newTile); + + this._map.setPaintValue(x, y, newTile); /// DIRECT SET TEXTURES + } + } + this._lastPainted = newPainted; + return tilesToPaint; + } + + registerSingleAnimation (arr) { + for (let i = 1; i < arr.length; i++) this._data[arr[i - 1]] = arr[i]; + } + + registerAnimations () { + + this.registerSingleAnimation([56, 57, 58, 59, 60, 61, 62, 63, 56]);// fire + this.registerSingleAnimation([860, 861, 862, 863, 864, 865, 866, 867]);// explosion + + + + // traffic + + this.registerSingleAnimation([80, 128, 112, 96, 80]); + this.registerSingleAnimation([81, 129, 113, 97, 81]); + this.registerSingleAnimation([82, 130, 114, 98, 82]); + this.registerSingleAnimation([83, 131, 115, 99, 83]); + this.registerSingleAnimation([84, 132, 116, 100, 84]); + this.registerSingleAnimation([85, 133, 117, 101, 85]); + this.registerSingleAnimation([86, 134, 118, 102, 86]); + this.registerSingleAnimation([87, 135, 119, 103, 87]); + this.registerSingleAnimation([88, 136, 120, 104, 88]); + this.registerSingleAnimation([89, 137, 121, 105, 89]); + this.registerSingleAnimation([90, 138, 122, 106, 90]); + this.registerSingleAnimation([91, 139, 123, 107, 91]); + this.registerSingleAnimation([92, 140, 124, 108, 92]); + this.registerSingleAnimation([93, 141, 125, 109, 93]); + this.registerSingleAnimation([94, 142, 126, 110, 94]); + this.registerSingleAnimation([95, 143, 127, 111, 95]); + + this.registerSingleAnimation([144, 192, 176, 160, 144]); + this.registerSingleAnimation([145, 193, 177, 161, 145]); + this.registerSingleAnimation([146, 194, 178, 162, 146]); + this.registerSingleAnimation([147, 195, 179, 163, 147]); + this.registerSingleAnimation([148, 196, 180, 164, 148]); + this.registerSingleAnimation([149, 197, 181, 165, 149]); + this.registerSingleAnimation([150, 198, 182, 166, 150]); + this.registerSingleAnimation([151, 199, 183, 167, 151]); + this.registerSingleAnimation([152, 200, 184, 168, 152]); + this.registerSingleAnimation([153, 201, 185, 169, 153]); + this.registerSingleAnimation([154, 202, 186, 170, 154]); + this.registerSingleAnimation([155, 203, 187, 171, 155]); + this.registerSingleAnimation([156, 204, 188, 172, 156]); + this.registerSingleAnimation([157, 205, 189, 173, 157]); + this.registerSingleAnimation([158, 206, 190, 174, 158]); + this.registerSingleAnimation([159, 207, 191, 175, 159]); +/* + // NOT NEED + this.registerSingleAnimation([621, 852, 853, 854, 855, 856, 857, 858, 859, 852]);// industrial polution + this.registerSingleAnimation([641, 884, 885, 886, 887, 884]); + this.registerSingleAnimation([644, 888, 889, 890, 891, 888]); + this.registerSingleAnimation([649, 892, 893, 894, 895, 892]); + this.registerSingleAnimation([650, 896, 897, 898, 899, 896]); + this.registerSingleAnimation([676, 900, 901, 902, 903, 900]); + this.registerSingleAnimation([677, 904, 905, 906, 907, 904]); + this.registerSingleAnimation([686, 908, 909, 910, 911, 908]); + this.registerSingleAnimation([689, 912, 913, 914, 915, 912]); + this.registerSingleAnimation([747, 916, 917, 918, 919, 916]); + this.registerSingleAnimation([748, 920, 921, 922, 923, 920]); + this.registerSingleAnimation([751, 924, 925, 926, 927, 924]); + this.registerSingleAnimation([752, 928, 929, 930, 931, 928]); + this.registerSingleAnimation([820, 952, 953, 954, 955, 952]); + this.registerSingleAnimation([832, 833, 834, 835, 836, 837, 838, 839, 832]); + this.registerSingleAnimation([840, 841, 842, 843, 840]); + this.registerSingleAnimation([844, 845, 846, 847, 848, 849, 850, 851, 844]); + this.registerSingleAnimation([932, 933, 934, 935, 936, 937, 938, 939, 932]);// football + this.registerSingleAnimation([940, 941, 942, 943, 944, 945, 946, 947, 940]);// football + */ + } + +} diff --git a/games/3dcity/src/micro/game/BlockMap.js b/games/3dcity/src/micro/game/BlockMap.js new file mode 100644 index 0000000..0df79d0 --- /dev/null +++ b/games/3dcity/src/micro/game/BlockMap.js @@ -0,0 +1,74 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { MiscUtils } from '../Micro.js'; + +export class BlockMap { + + constructor ( gameMapWidth, gameMapHeight, blockSize ) { + + if (gameMapWidth === undefined || gameMapHeight === undefined || blockSize === undefined) throw new Error('Invalid dimensions for block map') + + this.isBlockMap = true + + this.blockSize = blockSize; + this.gameMapWidth = gameMapWidth; + this.gameMapHeight = gameMapHeight; + + this.width = Math.floor((gameMapWidth + blockSize - 1) / blockSize) + this.height = Math.floor((gameMapHeight + blockSize - 1) / blockSize) + + this.data = []; + this.clear(); + + } + + clear () { + + let x, y = this.height; + while( y-- ){ + x = this.width; + while( x-- ){ + this.data[ this.width * y + x ] = 0; + } + } + + } + + copyFrom ( sourceMap, sourceFn ) { + + if (sourceMap.width !== this.width || sourceMap.height !== this.height || sourceMap.blockSize !== this.blockSize) console.warn('Copying from incompatible blockMap!'); + let x, y, height = sourceMap.height, width = sourceMap.width + for ( y = 0; y < height; y++) { + for ( x = 0; x < width; x++){ + this.data[width * y + x] = sourceFn(sourceMap.data[width * y + x]); + } + } + } + + get ( x, y ) { + return this.data[ this.width * y + x ]; + } + + set ( x, y, value ) { + this.data[ this.width * y + x ] = value; + } + + toBlock ( num ) { + return Math.floor( num / this.blockSize ); + } + + worldGet ( x, y ) { + return this.get( this.toBlock(x), this.toBlock(y) ); + } + + worldSet ( x, y, value ) { + this.set( this.toBlock(x), this.toBlock(y), value ); + } +} diff --git a/games/3dcity/src/micro/game/Budget.js b/games/3dcity/src/micro/game/Budget.js new file mode 100644 index 0000000..c3fcca8 --- /dev/null +++ b/games/3dcity/src/micro/game/Budget.js @@ -0,0 +1,230 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { EventEmitter, Micro } from '../Micro.js'; +import { Messages } from '../Messages.js'; + +export class Budget { + + constructor () { + + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + this.totalFunds = 0; + this.cityTax = 7; + this.cashFlow = 0; + this.taxFund = 0; + + // These values denote how much money is required to fully maintain the relevant services + this.roadMaintenanceBudget = 0; + this.fireMaintenanceBudget = 0; + this.policeMaintenanceBudget = 0; + + // Percentage of budget used + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; + + // Cash value of spending. Should equal Math.round(_Fund * _Percent) + this.roadSpend = 0; + this.fireSpend = 0; + this.policeSpend = 0; + + this.awaitingValues = false; + this.autoBudget = true; + + } + + save (saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) + saveData[Micro.BudgetProps[i]] = this[Micro.BudgetProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.BudgetProps.length; i < l; i++) + this[Micro.BudgetProps[i]] = saveData[Micro.BudgetProps[i]]; + + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + } + + setAutoBudget (value) { + this.autoBudget = value; + EventEmitter.emitEvent(Messages.AUTOBUDGET_CHANGED, this.autoBudget); + } + + // Calculates the best possible outcome in terms of funding the various services + // given the player's current funds and tax yield. On entry, roadPercent etc. are + // assumed to contain the desired percentage level, and taxFunds should contain the + // most recent tax collected. On exit, the *Percent members will be updated with what + // we can actually afford to spend. Returns an object containing the amount of cash + // that would be spent on each service. + _calculateBestPercentages () { + + // How much would we be spending based on current percentages? + // Note: the *Budget items are updated every January by collectTax + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); + var total = this.roadSpend + this.fireSpend + this.policeSpend; + + // If we don't have any services on the map, we can bail early + if (total === 0) { + this.roadPercent = 1; + this.firePercent = 1; + this.policePercent = 1; + return {road: 1, fire: 1, police: 1}; + } + + // How much are we actually going to spend? + var roadCost = 0; + var fireCost = 0; + var policeCost = 0; + + var cashRemaining = this.totalFunds + this.taxFund; + + // Spending priorities: road, fire, police + if (cashRemaining >= this.roadSpend) roadCost = this.roadSpend; + else roadCost = cashRemaining; + cashRemaining -= roadCost; + + if (cashRemaining >= this.fireSpend) fireCost = this.fireSpend; + else fireCost = cashRemaining; + cashRemaining -= fireCost; + + if (cashRemaining >= this.policeSpend) policeCost = this.policeSpend; + else policeCost = cashRemaining; + cashRemaining -= policeCost; + + if (this.roadMaintenanceBudget > 0) this.roadPercent = (roadCost / this.roadMaintenanceBudget).toPrecision(2) - 0; + else this.roadPercent = 1; + + if (this.fireMaintenanceBudget > 0) this.firePercent = (fireCost / this.fireMaintenanceBudget).toPrecision(2) - 0; + else this.firePercent = 1; + + if (this.policeMaintenanceBudget > 0) this.policePercent = (policeCost / this.policeMaintenanceBudget).toPrecision(2) - 0; + else this.policePercent = 1; + + return { road: roadCost, police: policeCost, fire: fireCost }; + } + + // User initiated budget + doBudgetWindow () { //doBudgetMenu + return this.doBudgetNow(true); + } + + doBudgetNow ( fromWindow ) { + + var costs = this._calculateBestPercentages(); + + if (!this.autoBudget && !fromWindow) { + this.autoBudget = false; + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + return; + } + + var roadCost = costs.road; + var policeCost = costs.police; + var fireCost = costs.fire; + var totalCost = roadCost + policeCost + fireCost; + var cashRemaining = this.totalFunds + this.taxFund - totalCost; + + // Autobudget + if ((cashRemaining > 0 && this.autoBudget) || fromWindow) { + // Either we were able to fully fund services, or we have just normalised user input. Go ahead and spend. + this.awaitingValues = false; + this.doBudgetSpend( roadCost, fireCost, policeCost ); + return; + } + + // Uh-oh. Not enough money. Make this the user's problem. + // They don't know it yet, but they're about to get a budget window. + this.setAutoBudget(false); + this.awaitingValues = true; + EventEmitter.emitEvent(Messages.BUDGET_NEEDED); + EventEmitter.emitEvent(Messages.NO_MONEY); + } + + doBudgetSpend ( roadValue, fireValue, policeValue ) { + + this.roadSpend = roadValue; + this.fireSpend = fireValue; + this.policeSpend = policeValue; + var total = this.roadSpend + this.fireSpend + this.policeSpend; + + this.spend(-(this.taxFund - total) ); + this.updateFundEffects(); + + } + + updateFundEffects () { + // The caller is assumed to have correctly set the percentage spend + this.roadSpend = Math.round(this.roadMaintenanceBudget * this.roadPercent); + this.fireSpend = Math.round(this.fireMaintenanceBudget * this.firePercent); + this.policeSpend = Math.round(this.policeMaintenanceBudget * this.policePercent); + + // Update the effect this level of spending will have on infrastructure deterioration + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + + if (this.roadMaintenanceBudget > 0) this.roadEffect = Math.floor(this.roadEffect * this.roadSpend / this.roadMaintenanceBudget); + if (this.fireMaintenanceBudget > 0) this.fireEffect = Math.floor(this.fireEffect * this.fireSpend / this.fireMaintenanceBudget); + if (this.policeMaintenanceBudget > 0) this.policeEffect = Math.floor(this.policeEffect * this.policeSpend / this.policeMaintenanceBudget); + + } + + collectTax ( gameLevel, census ) { + + this.cashFlow = 0; + // How much would it cost to fully fund every service? + this.policeMaintenanceBudget = census.policeStationPop * Micro.policeMaintenanceCost; + this.fireMaintenanceBudget = census.fireStationPop * Micro.fireMaintenanceCost; + + var roadCost = census.roadTotal * Micro.roadMaintenanceCost; + var railCost = census.railTotal * Micro.railMaintenanceCost; + this.roadMaintenanceBudget = Math.floor((roadCost + railCost) * Micro.RLevels[gameLevel]) + + this.taxFund = Math.floor( Math.floor( census.totalPop * census.landValueAverage / 120) * this.cityTax * Micro.FLevels[gameLevel]); + + if (census.totalPop > 0) { + this.cashFlow = this.taxFund - (this.policeMaintenanceBudget + this.fireMaintenanceBudget + this.roadMaintenanceBudget); + this.doBudgetNow( false ); + } else { + // We don't want roads etc deteriorating when population hasn't yet been established + // (particularly early game) + this.roadEffect = Micro.MAX_ROAD_EFFECT; + this.policeEffect = Micro.MAX_POLICESTATION_EFFECT; + this.fireEffect = Micro.MAX_FIRESTATION_EFFECT; + } + } + + setTax ( amount ) { + if (amount === this.cityTax) return; + this.cityTax = amount; + } + + setFunds ( amount ) { + if (amount === this.totalFunds) return; + this.totalFunds = Math.max(0, amount); + EventEmitter.emitEvent(Messages.FUNDS_CHANGED, this.totalFunds); + if (this.totalFunds === 0) EventEmitter.emitEvent(Messages.NO_MONEY); + } + + spend ( amount ) { + this.setFunds(this.totalFunds - amount); + } + + shouldDegradeRoad () { + return this.roadEffect < Math.floor(15 * this.MAX_ROAD_EFFECT / 16); + } + +} diff --git a/games/3dcity/src/micro/game/Census.js b/games/3dcity/src/micro/game/Census.js new file mode 100644 index 0000000..e345d54 --- /dev/null +++ b/games/3dcity/src/micro/game/Census.js @@ -0,0 +1,125 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro, MiscUtils } from '../Micro.js'; +import { math } from '../math/math.js'; + +export class Census { + + constructor () { + + this.clearCensus(); + this.changed = false; + this.crimeRamp = 0; + this.pollutionRamp = 0; + + // Set externally + this.landValueAverage = 0; + this.pollutionAverage = 0; + this.crimeAverage = 0; + this.totalPop = 0; + + var createArray = function(arrName) { + //this[arrName] = new M_ARRAY_TYPE(120); + this[arrName] = []; + //for (var a = 0; a < 120; a++) this[arrName][a] = 0; + var a = 120; + while(a--) this[arrName][a] = 0; + } + + //for (var i = 0; i < Micro.arrs.length; i++) { + + let i = Micro.arrs.length + while(i--){ + var name10 = Micro.arrs[i] + 'Hist10'; + var name120 = Micro.arrs[i] + 'Hist120'; + createArray.call(this, name10); + createArray.call(this, name120); + } + } + + save (saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) + saveData[Micro.CensusProps[i]] = this[Micro.CensusProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.CensusProps.length; i < l; i++) + this[Micro.CensusProps[i]] = saveData[Micro.CensusProps[i]]; + } + + clearCensus () { + + this.poweredZoneCount = 0; + this.unpoweredZoneCount = 0; + this.firePop = 0; + this.roadTotal = 0; + this.railTotal = 0; + this.resPop = 0; + this.comPop = 0; + this.indPop = 0; + this.resZonePop = 0; + this.comZonePop = 0; + this.indZonePop = 0; + this.hospitalPop = 0; + this.churchPop = 0; + this.policeStationPop = 0; + this.fireStationPop = 0; + this.stadiumPop = 0; + this.coalPowerPop = 0; + this.nuclearPowerPop = 0; + this.seaportPop = 0; + this.airportPop = 0; + + } + + take10Census ( budget ) { + + var resPopDenom = 8; + MiscUtils.rotate10Arrays.call(this); + + this.resHist10[0] = Math.floor(this.resPop / resPopDenom); + this.comHist10[0] = this.comPop; + this.indHist10[0] = this.indPop; + + this.crimeRamp += Math.floor((this.crimeAverage - this.crimeRamp) / 4); + this.crimeHist10[0] = Math.min(this.crimeRamp, 255); + + this.pollutionRamp += Math.floor((this.pollutionAverage - this.pollutionRamp) / 4); + this.pollutionHist10[0] = Math.min(this.pollutionRamp, 255); + + var x = Math.floor(budget.cashFlow / 20) + 128; + this.moneyHist10[0] = math.clamp(x, 0, 255); + + var resPopScaled = this.resPop >> 8; + + if (this.hospitalPop < this.resPopScaled) this.needHospital = 1; + else if (this.hospitalPop > this.resPopScaled) this.needHospital = -1; + else if (this.hospitalPop === this.resPopScaled) this.needHospital = 0; + + this.changed = true; + + } + + take120Census () { + + MiscUtils.rotate120Arrays.call(this); + var resPopDenom = 8; + + this.resHist120[0] = Math.floor(this.resPop / resPopDenom); + this.comHist120[0] = this.comPop; + this.indHist120[0] = this.indPop; + this.crimeHist120[0] = this.crimeHist10[0]; + this.pollutionHist120[0] = this.pollutionHist10[0]; + this.moneyHist120[0] = this.moneyHist10[0]; + this.changed = true; + + } + +} diff --git a/games/3dcity/src/micro/game/DisasterManager.js b/games/3dcity/src/micro/game/DisasterManager.js new file mode 100644 index 0000000..8055d70 --- /dev/null +++ b/games/3dcity/src/micro/game/DisasterManager.js @@ -0,0 +1,252 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { EventEmitter, Micro, MiscUtils } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { Messages } from '../Messages.js'; + +import { math } from '../math/math.js'; + +export const vulnerable = function( tile ) { + + let tileValue = tile.getValue(); + if (tileValue < Tile.RESBASE || tileValue > Tile.LASTZONE || tile.isZone()) return false; + return true; + +} + +export class DisasterManager { + + constructor ( map, spriteManager, gameLevel ) { + + this._map = map; + this._spriteManager = spriteManager; + this._gameLevel = gameLevel; + + this._floodCount = 0; + this.disastersEnabled = false; + + this.Dx = [ 0, 1, 0, -1]; + this.Dy = [-1, 0, 1, 0]; + + // TODO enable disasters + //Object.defineProperty(this, 'disastersEnabled', MiscUtils.mcd(false)); + } + + doDisasters ( census ) { + + if (this._floodCount) this._floodCount--; + + // TODO Scenarios + + if (!this.disastersEnabled) return; + + if (math.getRandom(Micro.DisChance[this._gameLevel])) { + switch (math.getRandom(8)) { + case 0: + case 1: this.setFire(); break; + + case 2: + case 3: this.makeFlood(); break; + + case 4: + break; + + case 5: this._spriteManager.makeTornado(); break; + + case 6: + // TODO Earthquakes + //this.makeEarthquake(); + break; + + case 7: + case 8: if (census.pollutionAverage > 60) this._spriteManager.makeMonster(); break; + } + } + } + + setDifficulty (gameLevel) { + this._gameLevel = gameLevel; + } + + scenarioDisaster () { + // TODO Scenarios + } + // User initiated meltdown: need to find the plant first + makeMeltdown () { + for (let x = 0; x < (this._map.width - 1); x++) { + for (let y = 0; y < (this._map.height - 1); y++) { + if (this._map.getTileValue(x, y) === Tile.NUCLEAR) { + this.doMeltdown( x, y ); + return; + } + } + } + } + + makeEarthquake () { + + let strength = math.getRandom(700) + 300; + this.doEarthquake(strength); + + EventEmitter.emitEvent(Messages.EARTHQUAKE, {x: this._map.cityCenterX, y: this._map.cityCenterY}); + + let i, x, y; + + for ( i = 0; i < strength; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + + if (vulnerable(this._map.getTile(x, y))) { + if ((i & 0x3) !== 0) this._map.setTo(x, y, ZoneUtils.randomRubble()); + else this._map.setTo(x, y, ZoneUtils.randomFire()); + } + } + + } + + setFire ( times = 1, zonesOnly = false ) { + + let i, x, y, tile, lowerLimit; + + for ( i = 0; i < times; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + + if (!this._map.testBounds(x, y)) continue; + + tile = this._map.getTile(x, y); + + if (!tile.isZone()) { + tile = tile.getValue(); + lowerLimit = zonesOnly ? Tile.LHTHR : Tile.TREEBASE; + if (tile > lowerLimit && tile < Tile.LASTZONE) { + this._map.setTo(x, y, ZoneUtils.randomFire()); + EventEmitter.emitEvent(Messages.FIRE_REPORTED, {showable: true, x: x, y: y}); + return; + } + } + } + } + + makeCrash () { + + let s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + if (s !== null) { s.explodeSprite(); return; } + + let x = math.getRandom(this._map.width - 1); + let y = math.getRandom(this._map.height - 1); + this._spriteManager.generatePlane(x, y); + s = this._spriteManager.getSprite(Micro.SPRITE_AIRPLANE); + s.explodeSprite(); + + } + + makeFire () { + + this.setFire( 40, false); + + } + + makeFlood () { + + let i, x, y, tileValue, j, xx, yy, tile; + + for ( i = 0; i < 300; i++) { + x = math.getRandom(this._map.width - 1); + y = math.getRandom(this._map.height - 1); + if (!this._map.testBounds(x, y)) continue; + + tileValue = this._map.getTileValue(x, y); + + if (tileValue > Tile.CHANNEL && tileValue <= Tile.WATER_HIGH) { + for ( j = 0; j < 4; j++) { + xx = x + this.Dx[j]; + yy = y + this.Dy[j]; + + if (!this._map.testBounds(xx, yy)) continue; + + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile === Tile.DIRT || (tile.isBulldozable() && tile.isCombustible)) { + this._map.setTo(xx, yy, new Tiles(Tile.FLOOD)); + this._floodCount = 30; + EventEmitter.emitEvent(Messages.FLOODING_REPORTED, {showable: true, x: xx, y: yy}); + return; + } + } + } + } + + } + + doFlood ( x, y, blockMaps ) { + + let i, xx, yy, tile, tileValue; + + if (this._floodCount > 0) { + // Flood is not over yet + for ( i = 0; i < 4; i++) { + if (math.getChance(7)) { + xx = x + this.Dx[i]; + yy = y + this.Dy[i]; + + if (this._map.testBounds(xx, yy)) { + tile = this._map.getTile(xx, yy); + tileValue = tile.getValue(); + + if (tile.isCombustible() || tileValue === Tile.DIRT || (tileValue >= Tile.WOODS5 && tileValue < Tile.FLOOD)) { + if (tile.isZone()) ZoneUtils.fireZone(this.map, xx, yy, blockMaps); + + this._map.setTile(xx, yy, Tile.FLOOD + math.getRandom(2), 0); + //this._map.setTo(xx, yy, new Tiles(Tile.FLOOD + math.getRandom(2))); + } + } + } + } + } else { + if (math.getChance(15)) this._map.setTile(x, y, Tile.DIRT, 0); + } + + } + + doMeltdown ( x, y ) { + + this._spriteManager.makeExplosion(x - 1, y - 1); + this._spriteManager.makeExplosion(x - 1, y + 2); + this._spriteManager.makeExplosion(x + 2, y - 1); + this._spriteManager.makeExplosion(x + 2, y + 2); + + let i, dY, dX, tile; + + // Whole power plant is at fire + for (dX = x - 1; dX < x + 3; dX++) { + for (dY = y - 1; dY < y + 3; dY++) { + this._map.setTo(dX, dY, ZoneUtils.randomFire()); + } + } + + // Add lots of radiation tiles around the plant + for ( i = 0; i < 200; i++) { + dX = x - 20 + math.getRandom(40); + dY = y - 15 + math.getRandom(30); + + if (!this._map.testBounds(dX, dY)) continue; + + tile = this._map.getTile(dX, dY); + + if (tile.isZone()) continue; + if (tile.isCombustible() || tile.getValue() === Tile.DIRT) this._map.setTile(dX, dY, Tile.RADTILE, 0);//this._map.setTo(dX, dY, new Tiles(Tile.RADTILE)); + } + + // Report disaster to the user + EventEmitter.emitEvent(Messages.NUCLEAR_MELTDOWN, {showable: true, x: x, y: y}); + } +} diff --git a/games/3dcity/src/micro/game/Evaluation.js b/games/3dcity/src/micro/game/Evaluation.js new file mode 100644 index 0000000..75432be --- /dev/null +++ b/games/3dcity/src/micro/game/Evaluation.js @@ -0,0 +1,348 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { EventEmitter, Micro } from '../Micro.js'; +import { Messages } from '../Messages.js'; + +import { math } from '../math/math.js'; + +export class EvaluationUtils { + + static getTrafficAverage ( blockMaps, census ) { + + var trafficDensityMap = blockMaps.trafficDensityMap; + var landValueMap = blockMaps.landValueMap; + var trafficTotal = 0; + var count = 1; + + for (var x = 0; x < landValueMap.gameMapWidth; x += landValueMap.blockSize) { + for (var y = 0; y < landValueMap.gameMapHeight; y += landValueMap.blockSize) { + if (landValueMap.worldGet(x, y) > 0) { + trafficTotal += trafficDensityMap.worldGet(x, y); + count++; + } + } + } + + var trafficAverage = Math.floor(trafficTotal / count) * 2.4; + //census.trafficAverage = trafficAverage //?? + return trafficAverage; + + } + + + static getUnemployment ( census ) { + + var b = (census.comPop + census.indPop) * 8; + if (b === 0) return 0; + // Ratio total people / working. At least 1. + var r = census.resPop / b; + b = Math.round((r - 1) * 255); + return Math.min(b, 255); + + } + + + static getFireSeverity ( census ) { + + return Math.min(census.firePop * 5, 255); + + } + +} + + +export class Evaluation { + + constructor ( gameLevel ) { + + this.problemVotes = []; + this.problemOrder = []; + this.evalInit(); + this.gameLevel = '' + gameLevel; + this.changed = false; + + } + + save (saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) + saveData[Micro.EvalProps[i]] = this[Micro.EvalProps[i]]; + } + + load (saveData) { + for (var i = 0, l = Micro.EvalProps.length; i < l; i++) + this[Micro.EvalProps[i]] = saveData[Micro.EvalProps[i]]; + } + + cityEvaluation ( simData ) { + + if(!simData) simData = Micro.simData + + var census = simData.census; + + if ( census.totalPop > 0 ) { + + Micro.problemData = [] + //var problemTable = []; + for (var i = 0; i < Micro.NUMPROBLEMS; i++) Micro.problemData.push(0) + this.getAssessedValue( census ) + this.getPopulation( census ) + this.doProblems( simData.census, simData.budget, simData.blockMaps ); + this.getScore( simData ) + this.doVotes() + this.changeEval() + } else { + this.evalInit(); + this.cityYes = 50; + this.changeEval(); + } + } + + evalInit () { + + let i; + this.cityYes = 0; + this.cityPop = 0; + this.cityPopDelta = 0; + this.cityAssessedValue = 0; + this.cityClass = Micro.CC_VILLAGE; + this.cityClassLast = Micro.CC_VILLAGE; + this.cityScore = 500; + this.cityScoreDelta = 0; + for (i = 0; i < Micro.NUMPROBLEMS; i++) this.problemVotes[i] = { index: i, voteCount: 0 }; + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) this.problemOrder[i] = Micro.NUMPROBLEMS; + + } + + getAssessedValue( census ) { + + var value; + value = census.roadTotal * 5; + value += census.railTotal * 10; + value += census.policeStationPop * 1000; + value += census.fireStationPop * 1000; + value += census.hospitalPop * 400; + value += census.stadiumPop * 3000; + value += census.seaportPop * 5000; + value += census.airportPop * 10000; + value += census.coalPowerPop * 3000; + value += census.nuclearPowerPop * 6000; + this.cityAssessedValue = value * 1000; + + } + + getPopulation ( census ) { + + let oldPopulation = this.cityPop; + this.cityPop = (census.resPop + (census.comPop + census.indPop) * 8) * 20; + this.cityPopDelta = this.cityPop - oldPopulation; + if (this.cityPopDelta !== 0) EventEmitter.emitEvent(Messages.POPULATION_UPDATED, this.cityPop); + return this.cityPop; + + } + + getCityClass ( cityPopulation ) { + + this.cityClass = Micro.CC_VILLAGE; + if (cityPopulation > 2000) this.cityClass = Micro.CC_TOWN; + if (cityPopulation > 10000) this.cityClass = Micro.CC_CITY; + if (cityPopulation > 50000) this.cityClass = Micro.CC_CAPITAL; + if (cityPopulation > 100000) this.cityClass = Micro.CC_METROPOLIS; + if (cityPopulation > 500000) this.cityClass = Micro.CC_MEGALOPOLIS; + + if ( this.cityClass !== this.cityClassLast ) { + this.cityClassLast = this.cityClass; + EventEmitter.emitEvent( Messages.CLASSIFICATION_UPDATED, this.cityClass ); + } + + return this.cityClass; + + } + + voteProblems () { + + for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + this.problemVotes[i].index = i; + this.problemVotes[i].voteCount = 0; + } + + var problem = 0; + var voteCount = 0; + var loopCount = 0; + + while (voteCount < 100 && loopCount < 600) { + var voterProblemTolerance = math.getRandom(300); + if ( Micro.problemData[problem] > voterProblemTolerance ) { + this.problemVotes[problem].voteCount += 1; + voteCount++; + } + + problem = (problem + 1) % Micro.NUMPROBLEMS; + loopCount++; + } + } + + doProblems ( census, budget, blockMaps ) { + //var problemTaken = []; + + /*for (var i = 0; i < Micro.NUMPROBLEMS; i++) { + problemTaken[i] = false; + problemTable[i] = 0; + }*/ + + Micro.problemData[Micro.CRIME] = census.crimeAverage; + Micro.problemData[Micro.POLLUTION] = census.pollutionAverage; + Micro.problemData[Micro.HOUSING] = census.landValueAverage * 7 / 10; + Micro.problemData[Micro.TAXES] = budget.cityTax * 10; + Micro.problemData[Micro.TRAFFIC] = EvaluationUtils.getTrafficAverage( blockMaps, census ); + Micro.problemData[Micro.UNEMPLOYMENT] = EvaluationUtils.getUnemployment( census ); + Micro.problemData[Micro.FIRE] = EvaluationUtils.getFireSeverity( census ); + + this.voteProblems(); + + // Rank the problems + this.problemVotes.sort(function(a, b) { + return b.voteCount - a.voteCount; + }); + + this.problemOrder = this.problemVotes.map(function(pv, i) { + if (i >= Micro.NUM_COMPLAINTS || pv.voteCount === 0) return null; + return pv.index; + }); + + /*for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + // Find biggest problem not taken yet + var maxVotes = 0; + var bestProblem = Micro.NUMPROBLEMS; + for (var j = 0; j < Micro.NUMPROBLEMS; j++) { + if ((this.problemVotes[j] > maxVotes) && (!problemTaken[j])) { + bestProblem = j; + maxVotes = this.problemVotes[j]; + } + } + // bestProblem == NUMPROBLEMS means no problem found + this.problemOrder[i] = bestProblem; + if (bestProblem < Micro.NUMPROBLEMS) { + problemTaken[bestProblem] = true; + } + }*/ + } + + getScore ( simData ) { + + var census = simData.census; + var budget = simData.budget; + var valves = simData.valves; + + var cityScoreLast; + + cityScoreLast = this.cityScore; + var score = 0; + + for ( var i = 0; i < Micro.NUMPROBLEMS; i++ ) score += Micro.problemData[i]; + + score = Math.floor(score / 3); + score = (250 - Math.min(score, 250)) * 4; + //score = Math.min(score, 256); + //score = math.clamp((256 - score) * 4, 0, 1000); + + // Penalise the player by 15% if demand for any type of zone is capped due + // to lack of suitable buildings + let demandPenalty = 0.85; + + if (valves.resCap) score = Math.round(score * demandPenalty); + + if (valves.comCap) score = Math.round(score * demandPenalty); + + if (valves.indCap) score = Math.round(score * demandPenalty); + + // Penalize if roads/rail underfunded + + if (budget.roadEffect < budget.MAX_ROAD_EFFECT) score -= budget.MAX_ROAD_EFFECT - budget.roadEffect; + + // Penalize player by up to 10% for underfunded police and fire services + + if (budget.policeEffect < budget.MAX_POLICE_STATION_EFFECT) { + score = Math.round(score * (0.9 + (budget.policeEffect / (10 * budget.MAX_POLICE_STATION_EFFECT)))); + } + + if (budget.fireEffect < budget.MAX_FIRE_STATION_EFFECT) { + score = Math.round(score * (0.9 + (budget.fireEffect / (10 * budget.MAX_FIRE_STATION_EFFECT)))); + } + + // Penalise the player by 15% if demand for any type of zone has collapsed due to overprovision + + if (valves.resValve < -1000) score = Math.round(score * 0.85); + if (valves.comValve < -1000) score = Math.round(score * 0.85); + if (valves.indValve < -1000) score = Math.round(score * 0.85); + + var scale = 1.0; + if ( this.cityPop === 0 || this.cityPopDelta === 0 || this.cityPopDelta === this.cityPop ) { + // Leave score unchanged if city is empty, if there hasn't been any migration, if the + // initial settlers have just arrived, or if the city has doubled in size + scale = 1.0; + } else if (this.cityPopDelta > 0) { + // If the city is growing, scale score by percentage growth in population + scale = (this.cityPopDelta / this.cityPop) + 1.0; + } else if (this.cityPopDelta < 0) { + // If the city is shrinking, scale down by up to 5% based on level of outward migration + scale = 0.95 + Math.floor(this.cityPopDelta / (this.cityPop - this.cityPopDelta)); + } + + score = Math.round( score * scale ); + + // Penalize player for having fires and a burdensome tax rate + score = score - EvaluationUtils.getFireSeverity(census) - budget.cityTax; // dec score for fires and tax + + // Penalize player based on ratio of unpowered zones to total zones + scale = census.unpoweredZoneCount + census.poweredZoneCount; // dec score for unpowered zones + if (scale > 0.0) score = Math.round(score * (census.poweredZoneCount / scale)); + + // Force in to range 0-1000. New score is average of last score and new computed value + score = math.clamp(score, 0, 1000); + this.cityScore = Math.round((this.cityScore + score) / 2); + + this.cityScoreDelta = this.cityScore - cityScoreLast; + + if (this.cityScoreDelta !== 0) EventEmitter.emitEvent(Messages.SCORE_UPDATED, this.cityScore) + + } + + doVotes () { + this.cityYes = 0; + + for (let i = 0; i < 100; i++) { + let voterExpectation = math.getRandom(1000); + if (this.cityScore > voterExpectation) this.cityYes++; + } + } + + changeEval () { + this.changed = true; + } + + countProblems () { + var i; + for (i = 0; i < Micro.NUM_COMPLAINTS; i++) { + if (this.problemOrder[i] === Micro.NUMPROBLEMS) break; + } + return i; + } + + getProblemNumber (i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] === Micro.NUMPROBLEMS) return -1; + else return this.problemOrder[i]; + } + + getProblemVotes (i) { + if (i < 0 || i >= Micro.NUM_COMPLAINTS || this.problemOrder[i] == Micro.NUMPROBLEMS) return -1; + else return this.problemVotes[this.problemOrder[i]].voteCount; + } + +} diff --git a/games/3dcity/src/micro/game/MapScanner.js b/games/3dcity/src/micro/game/MapScanner.js new file mode 100644 index 0000000..0261bcc --- /dev/null +++ b/games/3dcity/src/micro/game/MapScanner.js @@ -0,0 +1,72 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +import { Micro, MiscUtils } from '../Micro.js'; +import { Tiles, Tile } from '../Tile.js'; + +export class MapScanner { + + constructor ( map ) { + + this._map = map; + this._actions = []; + + } + + addAction ( criterion, action ) { + + this._actions.push({ criterion: criterion, action: action }); + + } + + mapScan ( startX, maxX, simData ) { + + if(!simData) simData = Micro.simData + + let y = this._map.height, x, i, id, tile, tileValue, current, callable; + + while( y-- ){ + + for ( x = startX; x < maxX; x++ ) { + + id = this._map.getId( x, y ); //x + y * this.mapWidth; + tile = this._map.data[id] || new Tiles(); + tileValue = tile.getValue(); + + if ( tileValue < Tile.FLOOD ) continue; + + if ( tile.isConductive() ) simData.powerManager.setTilePower(x, y); + + if ( tile.isZone() ) { + simData.repairManager.checkTile( x, y, simData.cityTime ); + if ( tile.isPowered() ){ simData.census.poweredZoneCount += 1; this._map.powered({ v:1, id:id })/*this._map.powerData[id] = 1;*/ } + else { simData.census.unpoweredZoneCount += 1; this._map.powered({ v:2, id:id })/*this._map.powerData[id] = 2;*/ } + } + + i = this._actions.length; + while(i--){ + + current = this._actions[i]; + callable = MiscUtils.isCallable(current.criterion); + + if (callable && current.criterion.call(null, tile)) { + current.action.call(null, this._map, x, y, simData); + break; + } else if (!callable && current.criterion === tileValue) { + current.action.call(null, this._map, x, y, simData); + break; + } + } + } + } + } + +} diff --git a/games/3dcity/src/micro/game/PowerManager.js b/games/3dcity/src/micro/game/PowerManager.js new file mode 100644 index 0000000..3c308b1 --- /dev/null +++ b/games/3dcity/src/micro/game/PowerManager.js @@ -0,0 +1,143 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { EventEmitter, Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js' +import { BlockMap } from './BlockMap.js'; + +import { Direction } from '../math/Direction.js' +import { Position } from '../math/Position.js' +import { math } from '../math/math.js'; + +export class PowerManager { + + constructor ( map ) { + + this._map = map; + this._powerStack = []; + this.powerGridMap = new BlockMap(this._map.width, this._map.height, 1, 0); + + } + + setTilePower (x, y) { + + var tile = this._map.getTile(x, y); + var tileValue = tile.getValue(); + + if (tileValue === Tile.NUCLEAR || tileValue === Tile.POWERPLANT || this.powerGridMap.worldGet(x, y) > 0) { + tile.addFlags(Tile.POWERBIT); + return; + } + + tile.removeFlags(Tile.POWERBIT); + + } + + clearPowerStack () { + this._powerStackPointer = 0; + this._powerStack = []; + } + + testForConductive ( pos, testDir ) { + var movedPos = new Position(pos); + if (movedPos.move(testDir)) { + if (this._map.getTile(movedPos.x, movedPos.y).isConductive()) { + if (this.powerGridMap.worldGet(movedPos.x, movedPos.y) === 0) + return true; + } + } + return false; + } + + // Note: the algorithm is buggy: if you have two adjacent power + // plants, the second will be regarded as drawing power from the first + // rather than as a power source itself + doPowerScan ( census ) { + // Clear power this._map. + this.powerGridMap.clear(); + + // Power that the combined coal and nuclear power plants can deliver. + let maxPower = census.coalPowerPop * Micro.COAL_POWER_STRENGTH + census.nuclearPowerPop * Micro.NUCLEAR_POWER_STRENGTH; + + let powerConsumption = 0; // Amount of power used. + + while (this._powerStack.length > 0) { + var pos = this._powerStack.pop(); + var anyDir = Direction.INVALID; + var conNum; + do { + powerConsumption++; + if (powerConsumption > maxPower) { + EventEmitter.emitEvent(Messages.NOT_ENOUGH_POWER); + return; + } + + if (anyDir !== Direction.INVALID) + pos.move(anyDir); + + this.powerGridMap.worldSet(pos.x, pos.y, 1); + conNum = 0; + var dir = Direction.BEGIN; + + while (dir < Direction.END && conNum < 2) { + if (this.testForConductive(pos, dir)) { + conNum++; + anyDir = dir; + } + dir = Direction.increment90(dir); + } + if (conNum > 1) this._powerStack.push( new Position(pos) ); + } while ( conNum ); + } + } + + coalPowerFound ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.coalPowerPop += 1; + this._powerStack.push(new Position(x, y)); + + // Ensure animation runs + var dX = [-1, 2, 1, 2]; + var dY = [-1, -1, 0, 0]; + + // Ensure animation bits set no animation for 3d + if(!simData.is3D) for (var i = 0; i < 4; i++) map.addTileFlags(x + dX[i], y + dY[i], Tile.ANIMBIT); + + } + + nuclearPowerFound ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + var meltdownTable = [30000, 20000, 10000]; + // TODO With the auto repair system, zone gets repaired before meltdown + // In original Micropolis code, we bail and don't repair if melting down + if (simData.disasterManager.disastersEnabled && math.getRandom(meltdownTable[simData.gameLevel]) === 0) { + // simData.disasterManager.doMeltdown(messageManager, x, y); + return; + } + simData.census.nuclearPowerPop += 1; + this._powerStack.push(new Position(x, y)); + //console.log(x, y, new map.Position(x, y)) + + // Ensure animation bits set no animation for 3d + if(!simData.is3D) + for (var i = 0; i < 4; i++) map.addTileFlags(x, y, Tile.ANIMBIT | Tile.CONDBIT | Tile.POWERBIT | Tile.BURNBIT); + } + + registerHandlers (mapScanner, repairManager) { + mapScanner.addAction(Tile.POWERPLANT, this.coalPowerFound.bind(this)); + mapScanner.addAction(Tile.NUCLEAR, this.nuclearPowerFound.bind(this)); + repairManager.addAction(Tile.POWERPLANT, 7, 4); + repairManager.addAction(Tile.NUCLEAR, 7, 4); + } +} diff --git a/games/3dcity/src/micro/game/RepairManager.js b/games/3dcity/src/micro/game/RepairManager.js new file mode 100644 index 0000000..66551c9 --- /dev/null +++ b/games/3dcity/src/micro/game/RepairManager.js @@ -0,0 +1,71 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { MiscUtils } from '../Micro.js'; +import { Tiles, Tile } from '../Tile.js'; + +export class RepairManager { + + constructor ( map ) { + + this._map = map; + this._actions = []; + + } + + addAction ( criterion, period, zoneSize ) { + + this._actions.push({ criterion: criterion, period: period, zoneSize: zoneSize }); + + } + + repairZone ( x, y, zoneSize ) { + + let xx, yy, current, currentValue; + let centre = this._map.getTileValue(x, y); + let tileValue = centre - zoneSize - 2; + + for ( yy = -1; yy < zoneSize - 1; yy++) { + for ( xx = -1; xx < zoneSize - 1; xx++) { + tileValue++; + + current = this._map.getTile(x + xx, y + yy); + if (current.isZone() || current.isAnimated()) continue; + + currentValue = current.getValue(); + if (currentValue < Tile.RUBBLE || currentValue >= Tile.ROADBASE) + this._map.setTile(x + xx, y + yy, tileValue, Tile.CONDBIT | Tile.BURNBIT); + } + } + + } + + checkTile ( x, y, cityTime ) { + + let i = this._actions.length, current, period, tile, tileValue, callable; + + while( i-- ){ + + current = this._actions[i]; + period = current.period; + + if ((cityTime & period) !== 0) continue; + + tile = this._map.getTile(x, y); + tileValue = tile.getValue(); + + callable = MiscUtils.isCallable( current.criterion ); + if (callable && current.criterion.call(null, tile)) this.repairZone( x, y, current.zoneSize ); + else if (!callable && current.criterion === tileValue) this.repairZone( x, y, current.zoneSize ); + + } + + } + +} diff --git a/games/3dcity/src/micro/game/TileHistory.js b/games/3dcity/src/micro/game/TileHistory.js new file mode 100644 index 0000000..a9b01d2 --- /dev/null +++ b/games/3dcity/src/micro/game/TileHistory.js @@ -0,0 +1,44 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +export class TileHistory { + + constructor () { + + this.clear(); + + } + + clear () { + + this.data = {}; + + } + + toKey ( x, y ) { + + return [x, y].join(','); + + } + + getTile ( x, y ) { + + let key = this.toKey( x, y ); + return this.data[key]; + + } + + setTile ( x, y, value ) { + + let key = this.toKey( x, y ); + this.data[key] = value + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/game/Traffic.js b/games/3dcity/src/micro/game/Traffic.js new file mode 100644 index 0000000..f133f34 --- /dev/null +++ b/games/3dcity/src/micro/game/Traffic.js @@ -0,0 +1,162 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro, MiscUtils } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; + +import { Direction } from '../math/Direction.js'; +import { Position } from '../math/Position.js'; +import { math } from '../math/math.js'; + +export class Traffic { + + constructor ( map, spriteManager ) { + + this._map = map; + this._stack = []; + this._spriteManager = spriteManager; + + } + + makeTraffic ( x, y, blockMaps, destFn ) { + + this._stack = []; + + let pos = new Position(x, y); + + if (this.findPerimeterRoad(pos)) { + if (this.tryDrive(pos, destFn)) { + this.addToTrafficDensityMap(blockMaps); + return Micro.ROUTE_FOUND; + } + return Micro.NO_ROUTE_FOUND; + } else { + return Micro.NO_ROAD_FOUND; + } + + } + + addToTrafficDensityMap ( blockMaps ) { + + let trafficDensityMap = blockMaps.trafficDensityMap; + + while ( this._stack.length > 0 ) { + + let pos = this._stack.pop(); + + // Could this happen?!? + if (!this._map.testBounds(pos.x, pos.y)) continue; + + let tileValue = this._map.getTileValue( pos.x, pos.y ); + + if ( tileValue >= Tile.ROADBASE && tileValue < Tile.POWERBASE ) { + // Update traffic density. + let traffic = trafficDensityMap.worldGet(pos.x, pos.y); + traffic += 50; + traffic = Math.min(traffic, 240); + trafficDensityMap.worldSet(pos.x, pos.y, traffic); + + // Attract traffic copter to the traffic + if (traffic >= 240 && math.getRandom(5) === 0) { + let sprite = this._spriteManager.getSprite(Micro.SPRITE_HELICOPTER); + if (sprite !== null) { + sprite.destX = ZoneUtils.worldToPix(pos.x); + sprite.destY = ZoneUtils.worldToPix(pos.y); + } + } + } + } + + } + + findPerimeterRoad ( pos ) { + + for ( let i = 0; i < 12; i++ ) { + + let xx = pos.x + Micro.perimX[i]; + let yy = pos.y + Micro.perimY[i]; + + if (this._map.testBounds(xx, yy)) { + if (ZoneUtils.isDriveable(this._map.getTileValue(xx, yy))) { + pos.x = xx; + pos.y = yy; + return true; + } + } + } + return false; + + } + + tryDrive ( startPos, destFn ) { + + let dirLast = Direction.INVALID; + let drivePos = new Position(startPos); + + /* Maximum distance to try */ + for (let dist = 0; dist < Micro.MAX_TRAFFIC_DISTANCE; dist++) { + let dir = this.tryGo(drivePos, dirLast); + if (dir != Direction.INVALID) { + drivePos.move(dir); + dirLast = Direction.rotate180(dir); + + if (dist & 1) this._stack.push( new Position(drivePos) ); + if (this.driveDone(drivePos, destFn)) return true; + } else { + if (this._stack.length > 0) { + this._stack.pop(); + dist += 3; + } else { + return false; + } + } + } + return false; + } + + tryGo ( pos, dirLast ) { + + let directions = []; + // Find connections from current position. + let dir = Direction.NORTH; + let i, count = 0; + + for ( i = 0; i < 4; i++ ) { + if (dir != dirLast && ZoneUtils.isDriveable(this._map.getTileFromMapOrDefault(pos, dir, Tile.DIRT))) { + // found a road in an allowed direction + directions[i] = dir; + count++; + } else { + directions[i] = Direction.INVALID; + } + dir = Direction.rotate90(dir); + } + if (count === 0) return Direction.INVALID; + if (count === 1) { + for (i = 0; i < 4; i++) { + if (directions[i] != Direction.INVALID) return directions[i]; + } + } + i = math.getRandom16() & 3; + while ( directions[i] === Direction.INVALID ) i = (i + 1) & 3; + return directions[i]; + + } + + driveDone ( pos, destFn ) { + + if (pos.y > 0) { if (destFn(this._map.getTileValue(pos.x, pos.y - 1))) return true; } + if (pos.x < (this._map.width - 1)) { if (destFn(this._map.getTileValue(pos.x + 1, pos.y))) return true; } + if (pos.y < (this._map.height - 1)) { if (destFn(this._map.getTileValue(pos.x, pos.y + 1))) return true; } + if (pos.x > 0) { if (destFn(this._map.getTileValue(pos.x - 1, pos.y))) return true; } + return false; + + } + +} diff --git a/games/3dcity/src/micro/game/Valves.js b/games/3dcity/src/micro/game/Valves.js new file mode 100644 index 0000000..2bd2710 --- /dev/null +++ b/games/3dcity/src/micro/game/Valves.js @@ -0,0 +1,121 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { EventEmitter, Micro } from '../Micro.js'; +import { Messages } from '../Messages.js'; + +import { math } from '../math/math.js'; + +export class Valves { + + constructor () { + + this.resValve = 0; + this.comValve = 0; + this.indValve = 0; + this.resCap = false; + this.comCap = false; + this.indCap = false; + } + + save ( saveData ) { + saveData.resValve = this.resValve; + saveData.comValve = this.comValve; + saveData.indValve = this.indValve; + } + + load ( saveData ) { + + this.resValve = saveData.resValve; + this.comValve = saveData.comValve; + this.indValve = saveData.indValve; + + EventEmitter.emitEvent( Messages.VALVES_UPDATED, {residential: this.resValve, commercial: this.comValve, industrial: this.indValve}) + + } + + setValves ( gameLevel, census, budget ) { + + var resPopDenom = 8; + var birthRate = 0.02; + var labourBaseMax = 1.3; + var internalMarketDenom = 3.7; + var projectedIndPopMin = 5.0; + var resRatioDefault = 1.3; + var resRatioMax = 2; + var comRatioMax = 2; + var indRatioMax = 2; + var taxMax = 20; + var taxTableScale = 600; + var employment, labourBase; + + // Residential zones scale their population index when reporting it to the census + var normalizedResPop = census.resPop / resPopDenom; + census.totalPop = Math.round(normalizedResPop + census.comPop + census.indPop); + + // A lack of developed commercial and industrial zones means there are no employment opportunities, which constrain + // growth. (This might hurt initially if, for example, the player lays out an initial grid, as the residential zones + // will likely develop first, so the residential valve will immediately crater). + if (census.resPop > 0) employment = (census.comHist10[1] + census.indHist10[1]) / normalizedResPop; + else employment = 1; + + // Given the employment rate, calculate expected migration, add in births, and project the new population. + var migration = normalizedResPop * (employment - 1); + var births = normalizedResPop * birthRate; + var projectedResPop = normalizedResPop + migration + births; + + // Examine how many zones require workers + labourBase = census.comHist10[1] + census.indHist10[1]; + if (labourBase > 0.0) labourBase = census.resHist10[1] / labourBase; + else labourBase = 1; + labourBase = math.clamp(labourBase, 0.0, labourBaseMax); + + // Project future industry and commercial needs, taking into account available labour, and competition from + // other global cities + var internalMarket = (normalizedResPop + census.comPop + census.indPop) / internalMarketDenom; + var projectedComPop = internalMarket * labourBase; + var projectedIndPop = census.indPop * labourBase * Micro.extMarketParamTable[gameLevel]; + projectedIndPop = Math.max(projectedIndPop, projectedIndPopMin); + + // Calculate the expected percentage changes in each population type + var resRatio; + if (normalizedResPop > 0) resRatio = projectedResPop / normalizedResPop; + else resRatio = resRatioDefault; + + var comRatio; + if (census.comPop > 0) comRatio = projectedComPop / census.comPop; + else comRatio = projectedComPop; + + var indRatio; + if (census.indPop > 0) indRatio = projectedIndPop / census.indPop; + else indRatio = projectedIndPop; + + resRatio = Math.min(resRatio, resRatioMax); + comRatio = Math.min(comRatio, comRatioMax); + indRatio = Math.min(indRatio, indRatioMax); + + // Global tax and game level effects. + var z = Math.min((budget.cityTax + gameLevel), taxMax); + resRatio = (resRatio - 1) * taxTableScale + Micro.taxTable[z]; + comRatio = (comRatio - 1) * taxTableScale + Micro.taxTable[z]; + indRatio = (indRatio - 1) * taxTableScale + Micro.taxTable[z]; + + // Ratios are velocity changes to valves. + this.resValve = math.clamp(this.resValve + Math.round(resRatio), -Micro.RES_VALVE_RANGE, Micro.RES_VALVE_RANGE); + this.comValve = math.clamp(this.comValve + Math.round(comRatio), -Micro.COM_VALVE_RANGE, Micro.COM_VALVE_RANGE); + this.indValve = math.clamp(this.indValve + Math.round(indRatio), -Micro.IND_VALVE_RANGE, Micro.IND_VALVE_RANGE); + + if (this.resCap && this.resValve > 0) this.resValve = 0; + if (this.comCap && this.comValve > 0) this.comValve = 0; + if (this.indCap && this.indValve > 0) this.indValve = 0; + + EventEmitter.emitEvent( Messages.VALVES_UPDATED, {residential: this.resValve, commercial: this.comValve, industrial: this.indValve}) + + } +} diff --git a/games/3dcity/src/micro/map/GameMap.js b/games/3dcity/src/micro/map/GameMap.js new file mode 100644 index 0000000..4f9993a --- /dev/null +++ b/games/3dcity/src/micro/map/GameMap.js @@ -0,0 +1,466 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 & 3D by lo-th + * + */ +import { Micro } from '../Micro.js'; +import { Tiles, Tile } from '../Tile.js'; + +import { Direction } from '../math/Direction.js'; +//import { PositionMaker } from '../math/PositionMaker.js'; + +export class GameMap { + + constructor ( width = 128, height = 128, defaultValue ) { + + this.isIsland = false; + this.pp = [] + + //this.Position = new PositionMaker( width, height ); // !! find better way + + this.width = width; + this.height = height; + + this.fsize = this.width * this.height; + + this.defaultValue = new Tiles().getValue(); + + this.data = [];//new Array(this.fsize); + this.tilesData = new Micro.M_ARRAY_TYPE(this.fsize); + this.powerData = new Micro.M_ARRAY_TYPE(this.fsize); + + let i = this.fsize; + while(i--){ + this.data[i] = new Tiles( this.defaultValue ); + this.tilesData[i] = this.defaultValue; + } + /*console.log(this.data.length)*/ + + // Generally set externally + this.cityCentreX = Math.floor(this.width * 0.5); + this.cityCentreY = Math.floor(this.height * 0.5); + this.pollutionMaxX = this.cityCentreX; + this.pollutionMaxY = this.cityCentreY; + + this.powerChange = false; + + this.layer = []; + this.resetLayer(); + + + this.makePP() + + } + + // 3D LAYER + + upLayer ( id, value, x, y ){ + + if(value>=Tile.TINYEXP && value<=Tile.TINYEXPLAST) value -= (860-35)// explosion decal + + //if(value>=Tile.HBRDG0 && value<=Tile.HBRDG3) value -= 832+32 + //if(value>=Tile.VBRDG0 && value<=Tile.VBRDG3) value -= 832+32 + + this.tilesData[ id ] = value; + + //if( this.goodValue(value) ){ + this.layer[this.findLayer(x,y)] = 1; + + } + + resetLayer () { + + let i = 64; + while( i-- ) this.layer[i] = 0; + + } + + findLayer ( x, y ){ + let cx = Math.floor(x/16) + let cy = Math.floor(y/16) + return cx+(cy*8) + } + + goodValue ( v ){ + + if( v === 0 ) return true // dirt + else if( v > 1 && v < 240 ) return true // water edge tree + //else if( v > 1 && v < 44 ) return true // water edge tree + //if( v > 43 && v < 48 ) return true // rubble + // else if( v > 43 && v < 240 ) return true // road wire rail + return false + + } + + // + + makePP () { + + let x = this.width, y, n=0; + + let pp = [] + + while( x-- ){ + y = this.height + while( y-- ){ + pp[n] = [x,y] + n++ + } + } + + this.pp = pp; + + } + + // change power statue for 3d + powered ( o ) { + + let id = o.id || this.getId( o.x, o.y ) + this.powerData[id] = o.v; + this.powerChange = true; + + } + + /*makePos (){ + + return new PositionMaker( this.width, this.height ); + + }*/ + + save ( saveData ) { + + let i=0, lng; + + // GAME PROPS + lng = Micro.GameMapProps.length; + while( i < lng ){ + saveData[Micro.GameMapProps[i]] = this[Micro.GameMapProps[i]]; + i++; + } + + // MAP DATA + //saveData.map = this.data.map(function(t) { return {value: t.getRawValue()}; }); + + + saveData.map = []; + i = 0; + lng = this.fsize; + while( i < lng ){ + saveData.map[i] = this.data[i].getRawValue(); + i++; + } + + // TILES VALUES + saveData.tileValue = []; + i = 0; + lng = this.fsize; + while( i < lng ){ + saveData.tileValue[i] = this.tilesData[i]; + i++; + } + + } + + load ( saveData ) { + + let x, y, lng, i = 0, map = saveData.map, tiles = saveData.tileValue; + + // GAME PROPS + lng = Micro.GameMapProps.length; + while( i < lng ){ + this[Micro.GameMapProps[i]] = saveData[Micro.GameMapProps[i]]; + i++; + } + + // MAP DATA + + let isOld = map[0].value !== undefined ? true : false + i = 0; + lng = this.fsize; + while( i < lng ){ + x = i % this.width; + y = Math.floor(i / this.width); + if( isOld ) this.setTileValue( x, y, map[i].value ); + else this.setTileValue( x, y, map[i] ); + i++; + } + + // TILES VALUES + i = 0; + lng = this.fsize; + while( i < lng ){ + this.tilesData[i] = tiles[i]; + i++; + } + + } + + testBounds (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + } + + getId ( x, y ){ + return x + y * this.width + } + + getTile ( x, y, newTile ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let width = this.width; + let height = this.height; + + if (x < 0 || y < 0 || x >= width || y >= height) { + console.warn('getTile called with bad bounds', x, y); + return new Tiles(Tile.TILE_INVALID); + } + let tileIndex = this.getId( x, y ); + let tile = this.data[tileIndex]; + + //var tileIndex = this._calculateIndex(x, y); + // Return the original tile if we're not given a tile to fill + if (!newTile) return tile; + + newTile.set(tile); + return tile; + + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + //return this.data[tileIndex]; + } + + getTileValue( x, y ) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let tileIndex = this.getId(x, y); + + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getValue(); + } + + getTileFlags( x, y ) { + let e = new Error('Invalid parameter'); + if (arguments.length < 1) throw e; + // Argument-shuffling + if (typeof(x) === 'object') { y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let tileIndex = this.getId(x, y); + + if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + return this.data[tileIndex].getFlags(); + } + + getTiles( x, y, w, h ) { + + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; + // Argument-shuffling + if (arguments.length === 3) { h = w; w = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let res = []; + for (let a = y, ylim = y + h; a < ylim; a++) { + res[a - y] = []; + for (let b = x, xlim = x + w; b < xlim; b++) { + let tileIndex = this.getId(b, a); + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + res[a-y].push(this.data[tileIndex]); + } + } + return res; + + } + + getTileValues( x, y, w, h, result ) { + + result = result || []; + let e = new Error('Invalid parameter'); + if (arguments.length < 3) throw e; + // Argument-shuffling + if (arguments.length === 3) { h = w; w = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + let width = this.width; + let height = this.height; + + // Result is stored in row-major order + for (let a = y, ylim = y + h; a < ylim; a++) { + for (let b = x, xlim = x + w; b < xlim; b++) { + if (a < 0 || b < 0 || a >= height || b >= width) { + result[(a - y) * w + (b - x)] = Tile.TILE_INVALID; + continue; + } + let tileIndex = b + a * width; + //result[(a - y) * w + (b - x)] = this._data[tileIndex].getRawValue(); + result[(a - y) * w + (b - x)] = this.data[tileIndex].getRawValue(); + } + } + + return result; + + } + + getTileFromMapOrDefault( pos, dir, defaultTile ) { + + switch (dir) { + case Direction.NORTH: + if (pos.y > 0) return this.getTileValue(pos.x, pos.y - 1); + return defaultTile; + case Direction.EAST: + if (pos.x < this.width - 1) return this.getTileValue(pos.x + 1, pos.y); + return defaultTile; + case Direction.SOUTH: + if (pos.y < this.height - 1) return this.getTileValue(pos.x, pos.y + 1); + return defaultTile; + case Direction.WEST: + if (pos.x > 0) return this.getTileValue(pos.x - 1, pos.y); + return defaultTile; + default: + return defaultTile; + } + + } + + //---------------------- + + testOld ( id, value ){ + + if( this.data[ id ].getValue() !== value ) return true + return false + + } + + setTile( x, y, value, flags ) { + + //var e = new Error('Invalid parameter'); + //if (arguments.length < 3) throw e; + // Argument-shuffling + if ( arguments.length === 3 ) { flags = value; value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let isNew = this.testOld( id, value ) + + this.data[ id ].set( value, flags ); + + if( isNew ) this.upLayer( id, value, x, y ) + + } + + setTo( x, y, tile ) { + + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if ( tile === undefined ) { tile = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let value = tile.getValue() + let isNew = this.testOld( id, value ) + + this.data[ id ] = tile; + // this.data[ id ].setValue(value); + + if( isNew ) this.upLayer( id, value, x, y ) + + } + + setTileValue( x, y, value ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + let isNew = this.testOld( id, value ) + //if (!(tileIndex in this.data)) this.data[tileIndex] = new Tiles(this.defaultValue); + + this.data[ id ].setValue( value ); + + if( isNew ) this.upLayer( id, value, x, y ) + + } + + setPaintValue( x, y, value ) { + //var e = new Error('Invalid parameter'); + //if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { value = y; y = x.y; x = x.x; } + //if (!this.testBounds(x, y)) throw e; + + let id = this.getId( x, y ); + this.upLayer( id, value, x, y ) + + } + + setTileFlags( x, y, flags ) { + + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let id = this.getId(x, y); + this.data[id].setFlags(flags); + + } + + addTileFlags( x, y, flags ) { + + let e = new Error('Invalid flag parameter'); + if (arguments.length < 2) throw e; + // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw e; + + let id = this.getId(x, y); + this.data[id].addFlags(flags); + + } + + removeTileFlags( x, y, flags ) { + + if (arguments.length < 2) throw new Error('GameMap removeTileFlags called with too few arguments');; + // Argument-shuffling + if (arguments.length === 2) { flags = y; y = x.y; x = x.x; } + if (!this.testBounds(x, y)) throw new Error('GameMap removeTileFlags called with invalid bounds'+ x + ', ' + y); + + let id = this.getId( x, y ); + this.data[id].removeFlags(flags); + + ///this.upLayer( id, this.data[id].getValue(), x, y ) + + } + + putZone( centreX, centreY, centreTile, size ) { + + if (!this.testBounds(centreX, centreY) || !this.testBounds(centreX - 1 + size, centreY - 1 + size)) throw new Error('GameMap putZone called with invalid bounds'); + + let tile = centreTile - 1 - size; + let startX = centreX - 1; + let startY = centreY - 1; + let x, y; + + for ( y = startY; y < startY + size; y++) { + for ( x = startX; x < startX + size; x++) { + if (x === centreX && y === centreY) this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT | Tile.ZONEBIT)); + else this.setTo(x, y, new Tiles(tile, Tile.BNCNBIT)); + tile += 1; + } + } + } +} diff --git a/games/3dcity/src/micro/map/MapGenerator.js b/games/3dcity/src/micro/map/MapGenerator.js new file mode 100644 index 0000000..a62d488 --- /dev/null +++ b/games/3dcity/src/micro/map/MapGenerator.js @@ -0,0 +1,538 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +import { Micro } from '../Micro.js'; +import { Tile, Tiles } from '../Tile.js'; + +import { Direction } from '../math/Direction.js'; +import { Position } from '../math/Position.js'; +import { math } from '../math/math.js'; + +import { GameMap } from './GameMap.js'; + +export class MapGenerator { + + constructor () { + + this.SRMatrix = [ + [ 0, 0, 3, 3, 0, 0 ], + [ 0, 3, 2, 2, 3, 0 ], + [ 3, 2, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 2, 3 ], + [ 0, 3, 2, 2, 3, 0 ], + [ 0, 0, 3, 3, 0, 0 ] + ]; + this.BRMatrix = [ + [ 0, 0, 0, 3, 3, 3, 0, 0, 0 ], + [ 0, 0, 3, 2, 2, 2, 3, 0, 0 ], + [ 0, 3, 2, 2, 2, 2, 2, 3, 0 ], + [ 3, 2, 2, 2, 2, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 4, 2, 2, 2, 3 ], + [ 3, 2, 2, 2, 2, 2, 2, 2, 3 ], + [ 0, 3, 2, 2, 2, 2, 2, 3, 0 ], + [ 0, 0, 3, 2, 2, 2, 3, 0, 0 ], + [ 0, 0, 0, 3, 3, 3, 0, 0, 0 ] + ]; + + this.riverEdge = [ + 13, 13, 17, 15, + 5 , 2 , 19, 17, + 9 , 11, 2 , 13, + 7 , 9 , 5 , 2 + ]; + + this.treeTable = [ + 0, 0, 0, 34, + 0, 0, 36, 35, + 0, 32, 0, 33, + 30, 31, 29, 37 + ]; + + } + + construct( w, h, debug = false ) { + + Micro.TERRAIN_TREE_LEVEL = -1; + Micro.TERRAIN_LAKE_LEVEL = -1; + Micro.TERRAIN_CURVE_LEVEL = -1; + Micro.ISLAND_RADIUS = 18; + + if(debug) console.time("start newmap"); + + this.map = new GameMap( w || Micro.MAP_WIDTH, h || Micro.MAP_HEIGHT ); + //this.map.makePP() + + Micro.TERRAIN_CREATE_ISLAND = math.getRandom(2) - 1; + + if ( Micro.TERRAIN_CREATE_ISLAND < 0 ) { + if (math.getRandom(100) < 10) { + this.makeIsland(); + return this.map; + } + } + + if ( Micro.TERRAIN_CREATE_ISLAND === 1 ) this.makeNakedIsland(); + else this.clearMap(); + + + // Lay a river. + if ( Micro.TERRAIN_CURVE_LEVEL !== 0 ) { + let terrainXStart = 40 + math.getRandom( this.map.width - 79 ); + let terrainYStart = 33 + math.getRandom( this.map.height - 66 ); + let terrainPos = new Position( terrainXStart, terrainYStart ); + this.doRivers( terrainPos ); + } + + // Lay a few lakes. + if ( Micro.TERRAIN_LAKE_LEVEL !== 0 ) this.makeLakes(); + + this.smoothRiver(); + this.cleanBorder(); + + // And add trees. + if ( Micro.TERRAIN_TREE_LEVEL !== 0 ) this.doTrees(); + + if( debug ) console.timeEnd("start newmap"); + + return this.map; + + } + + cleanBorder() { + + let map = this.map; + if( map.isIsland ) return + let x, y, l, r, s; + + for ( x = 0; x < map.width; x ++) { + + l = x + 1; if(l>map.width-1) l = map.width-1; + r = x - 1; if(r<0) r = 0; + s = 1 + if( map.getTileValue( x, s ) + map.getTileValue( l, s ) + map.getTileValue( r, s ) === 6 ) map.setTile( x, 0, Tile.RIVER, 0); + s = map.height-2 + if( map.getTileValue( x, s ) + map.getTileValue( l, s ) + map.getTileValue( r, s ) === 6 ) map.setTile( x, map.height-1, Tile.RIVER, 0); + + } + + for ( y = 0; y < map.height; y ++) { + + l = y + 1; if(l>map.height-1) l = map.height-1; + r = y - 1; if(r<0) r = 0; + s = 1 + if( map.getTileValue( s, y ) + map.getTileValue( s, l ) + map.getTileValue( s, r ) === 6 ) map.setTile( 0, y, Tile.RIVER, 0); + s = map.width-2 + if( map.getTileValue( s, y ) + map.getTileValue( s, l ) + map.getTileValue( s, r ) === 6 ) map.setTile( map.width-1, y, Tile.RIVER, 0); + + } + + } + + clearMap() { + + let map = this.map + + map.pp.forEach( v => {//function ( v ) { + + map.setTile( v[0], v[1], Tile.DIRT, 0); + + }) + + } + + clearUnnatural() { + + let map = this.map, value + + map.pp.forEach( v => { + + value = map.getTileValue( v[0], v[1] ); + if ( value > Tile.WOODS ) map.setTile( v[0], v[1], Tile.DIRT, 0); + + }) + + } + + makeNakedIsland() { + + let map = this.map; + let terrainIslandRadius = Micro.ISLAND_RADIUS; + let x, y, mapX, mapY; + + map.isIsland = true; + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + + if ((x < 5) || (x >= map.width - 5) || (y < 5) || (y >= map.height - 5)) map.setTile(x, y, Tile.RIVER, 0); + else map.setTile( x, y, Tile.DIRT, 0 ); + + }) + + for ( x = 0; x < map.width - 5; x += 2) { + mapY = math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:x, y:mapY }); + + mapY = (map.height - 10) - math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:x, y:mapY }) + this.plopSRiver({ x:x, y:0 }); + this.plopSRiver({ x:x, y:map.height - 6 }); + } + for ( y = 0; y < map.height - 5; y += 2 ) { + mapX = math.getERandom( terrainIslandRadius ); + this.plopBRiver({ x:mapX, y:y }); + + mapX = map.width - 10 - math.getERandom(terrainIslandRadius); + this.plopBRiver({ x:mapX, y:y }); + this.plopSRiver({ x:0, y:y }); + this.plopSRiver({ x:map.width - 6, y:y }); + } + + } + + makeIsland() { + + this.makeNakedIsland(); + this.smoothRiver(); + this.doTrees(); + + } + + makeLakes() { + + let x, y; + let numLakes = Micro.TERRAIN_LAKE_LEVEL < 0 ? math.getRandom(10) : Micro.TERRAIN_LAKE_LEVEL * 0.5; + + while (numLakes > 0) { + x = math.getRandom( this.map.width - 21) + 10; + y = math.getRandom( this.map.height - 20) + 10; + this.makeSingleLake( new Position(x, y) ); + numLakes--; + } + + } + + makeSingleLake( pos ) { + + let numPlops = math.getRandom(12) + 2, plopPos; + while ( numPlops > 0 ) { + plopPos = new Position(pos, math.getRandom(12) - 6, math.getRandom(12) - 6); + if ( math.getRandom(4) ) this.plopSRiver(plopPos); + else this.plopBRiver( plopPos ); + numPlops--; + } + + } + + treeSplash( x, y ) { + + let numTrees = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(150) + 50 : math.getRandom(100 + (Micro.TERRAIN_TREE_LEVEL * 2)) + 50; + let treePos = new Position(x, y), dir; + + while (numTrees > 0) { + + dir = Direction.NORTH + math.getRandom(7); + treePos.move( dir ); + + // XXX Should use the fact that positions return success/failure for moves + if (!this.map.testBounds(treePos.x, treePos.y)) return; + if ( this.map.getTileValue(treePos) === Tile.DIRT ) this.map.setTile(treePos, Tile.WOODS, Tile.BLBNBIT); + + numTrees--; + } + } + + doTrees() { + + let i = Micro.TERRAIN_TREE_LEVEL < 0 ? math.getRandom(100) + 50 : Micro.TERRAIN_TREE_LEVEL + 3; + + while(i--){ + this.treeSplash( math.getRandom( this.map.width - 1), math.getRandom( this.map.height - 1) ); + } + + /*for (var x = 0; x < i; x++) { + var xloc = math.getRandom(this.map.width - 1); + var yloc = math.getRandom(this.map.height - 1); + this.treeSplash( xloc, yloc ); + }*/ + + this.smoothTrees(); + this.smoothTrees(); + + } + + smoothRiver() { + + let map = this.map; + let riverEdge = this.riverEdge; + let x, y, z, xt, yt, tt, bitIndex, temp; + let dx = [-1, 0, 1, 0]; + let dy = [0, 1, 0, -1]; + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + + if ( map.getTileValue(x, y) === Tile.REDGE ) { + + bitIndex = 0; + + for ( z = 0; z < 4; z++) { + bitIndex = bitIndex << 1; + xt = x + dx[z]; + yt = y + dy[z]; + if( map.testBounds( xt, yt ) ){ + tt = map.getTileValue( xt, yt ); + if( tt !== Tile.DIRT && ( tt < Tile.WOODS_LOW || tt > Tile.WOODS_HIGH ) ) bitIndex++; + } + } + + temp = riverEdge[bitIndex & 15]; + if ( temp !== Tile.RIVER && math.getRandom(1) ) temp++; + + //map.setTileValue(x, y, temp, 0); + + map.setTile( x, y, temp, Tile.BULLBIT ) // or we can't make bridge !!! + + } + }) + } + + isTree( value ) { + + return value >= Tile.WOODS_LOW && value <= Tile.WOODS_HIGH; + + } + + smoothTrees() { + + let map = this.map; + let x, y; + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + if (this.isTree(map.getTileValue(x, y))) this.smoothTreesAt( x, y, false ); + + }) + + } + + smoothTreesAt( x, y, preserve ) { + + let map = this.map; + let dx = [-1, 0, 1, 0 ]; + let dy = [ 0, 1, 0, -1 ]; + + if (!this.isTree(this.map.getTileValue(x, y))) return; + + let i, xTemp, yTemp, temp, bitIndex = 0; + + for ( i = 0; i < 4; i++) { + bitIndex = bitIndex << 1; + xTemp = x + dx[i]; + yTemp = y + dy[i]; + if (map.testBounds(xTemp, yTemp) && this.isTree(map.getTileValue(xTemp, yTemp))) bitIndex++; + } + + temp = this.treeTable[ bitIndex & 15 ]; + if (temp) { + if (temp !== Tile.WOODS) { + if ((x + y) & 1) temp -= 8; + } + if(temp>28 && temp<38) temp-=8 + map.setTile(x, y, temp, Tile.BLBNBIT); + } else { + if (!preserve){ + if(temp>28 && temp<38) temp-=8 + map.setTileValue(x, y, temp, 0) + }; + } + + } + + doRivers( terrainPos ) { + + let riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doBRiver( terrainPos, riverDir, riverDir ); + + riverDir = Direction.rotate180(riverDir); + let terrainDir = this.doBRiver( terrainPos, riverDir, riverDir ); + + riverDir = Direction.NORTH + math.getRandom(3) * 2; + this.doSRiver( terrainPos, riverDir, terrainDir ); + + } + + doBRiver( riverPos, riverDir, terrainDir) { + + let rate1, rate2; + + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + let pos = new Position(riverPos); + while ( this.map.testBounds( pos.x + 4, pos.y + 4 ) ) { + this.plopBRiver(pos); + if (math.getRandom(rate1+1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + pos.move(terrainDir); + } + return terrainDir; + + } + + doSRiver(riverPos, riverDir, terrainDir) { + + let rate1, rate2; + if (Micro.TERRAIN_CURVE_LEVEL < 0) { + rate1 = 100; + rate2 = 200; + } else { + rate1 = Micro.TERRAIN_CURVE_LEVEL + 10; + rate2 = Micro.TERRAIN_CURVE_LEVEL + 100; + } + let pos = new Position(riverPos); + while ( this.map.testBounds(pos.x + 3, pos.y + 3) ) { + this.plopSRiver(pos); + if (math.getRandom(rate1+1) < 10) { + terrainDir = riverDir; + } else { + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir); + if (math.getRandom(rate2+1) > 90) terrainDir = Direction.rotate45(terrainDir, 7); + } + pos.move(terrainDir); + } + return terrainDir; + + } + + putOnMap( newVal, x, y ) { + + if (newVal === 0) return; + if (!this.map.testBounds(x, y)) return; + + let tmp = this.map.getTileValue(x, y); + + if (tmp !== Tile.DIRT) { + if (tmp === Tile.RIVER && newVal !== Tile.CHANNEL) return; + if (tmp === Tile.CHANNEL) return; + } + + this.map.setTile(x, y, newVal, 0); + + } + + plopBRiver( pos ) { + + let x = 9, y + + while(x--){ + y = 9; + while(y--){ + this.putOnMap( this.BRMatrix[y][x], pos.x + x, pos.y + y ); + } + } + + } + + plopSRiver( pos ) { + + let x = 6, y + + while(x--){ + y = 6; + while(y--){ + this.putOnMap( this.SRMatrix[y][x], pos.x + x, pos.y + y ); + } + } + + } + + smoothWater() { + + let map = this.map, tile, pos, dir, x, y, makeRiver; + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + + tile = map.getTileValue(x, y); + + if (tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); + + // If nearest object is not water: + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + // set river edge + map.setTileValue(x, y, Tile.REDGE, 0); + break; // Continue with next tile + } + } + } + }) + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + + tile = map.getTileValue(x, y); + if (tile !== Tile.CHANNEL && tile >= Tile.WATER_LOW && tile <= Tile.WATER_HIGH) { + makeRiver = true; + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, Tile.WATER_LOW); + if (tile < Tile.WATER_LOW || tile > Tile.WATER_HIGH) { + makeRiver = false; + break; + } + } + if (makeRiver) map.setTileValue(x, y, Tile.RIVER, 0); + } + }) + + map.pp.forEach( v => { + + x = v[0] + y = v[1] + + tile = map.getTileValue(x, y); + if (tile >= Tile.WOODS_LOW && tile <= Tile.WOODS_HIGH) { + pos = new Position(x, y); + for (dir = Direction.BEGIN; dir < Direction.END; dir = Direction.increment90(dir)) { + tile = map.getTileFromMap(pos, dir, TILE_INVALID); + if (tile === Tile.RIVER || tile === Tile.CHANNEL) { + map.setTileValue(x, y, Tile.REDGE, 0); + break; + } + } + } + }) + } + + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/map/MapUtils.js b/games/3dcity/src/micro/map/MapUtils.js new file mode 100644 index 0000000..3562ea7 --- /dev/null +++ b/games/3dcity/src/micro/map/MapUtils.js @@ -0,0 +1,454 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + * switch to ES6 by lo-th + * + */ + +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; + +import { Residential } from '../zone/Residential.js'; +import { Commercial } from '../zone/Commercial.js'; +import { Industrial } from '../zone/Industrial.js'; + +import { math } from '../math/math.js'; + +export class MapUtils { + + // Smooth the map src into dest. The way in which the map is smoothed depends on the value of smoothStyle. + // The meanings are as follows: + // + // SMOOTH_NEIGHBOURS_THEN_BLOCK + // ============================ + // For each square in src, sum the values of its immediate neighbours, and take the average, then take the average of + // that result and the square's value. This result is the new value of the square in dest. + // + // SMOOTH_ALL_THEN_CLAMP + // ===================== + // For each square in src, sum the values of that square and it's four immediate neighbours, and take an average + // rounding down. Clamp the resulting value in the range 0-255. This clamped value is the square's new value in dest. + static smoothMap ( src, dest, smoothStyle ) { + + let x = src.width, y, edges + + while( x-- ){ + y = src.height + while( y-- ){ + + edges = 0; + if (x > 0) edges += src.get(x - 1, y); + if (x < src.width - 1) edges += src.get(x + 1, y); + if (y > 0) edges += src.get(x, y - 1); + if (y < src.height - 1) edges += src.get(x, y + 1); + + if (smoothStyle === Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK) { + edges = src.get(x, y) + Math.floor(edges / 4); + dest.set(x, y, Math.floor(edges/2)); + } else { + edges = (edges + src.get(x, y)) >> 2; + if (edges > 255) edges = 255; + dest.set(x, y, edges); + } + } + } + + } + + // Over time, the rate of growth of a neighbourhood should trend towards zero (stable) + static neutraliseRateOfGrowthMap ( blockMaps ) { + + let bm = blockMaps.rateOfGrowthMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height + while( y-- ){ + + value = bm.get( x, y ); + + if (value !== 0){ + if (value > 0) value--; + else value++; + + value = math.clamp( value, -200, 200 ); + bm.set( x, y, value ); + } + } + } + } + + // Over time, traffic density should ease. + static neutraliseTrafficMap ( blockMaps ) { + + let bm = blockMaps.trafficDensityMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height + while( y-- ){ + + value = bm.get(x, y); + + if (value !== 0){ + if (value <= 24) value = 0; + else if (value > 200) value = value - 34; + else value = value - 24; + bm.set(x, y, value); + } + } + } + + } + + // Given a tileValue, score it on the pollution it generates, in the range 0-255 + static getPollutionValue ( tileValue ) { + + if (tileValue < Tile.POWERBASE) { + // Roads, fires and radiation lie below POWERBASE + + // Heavy traffic is bad + if (tileValue >= Tile.HTRFBASE) return 75; + // Low traffic not so much + if (tileValue >= Tile.LTRFBASE) return 50; + + if (tileValue < Tile.ROADBASE) { + // Fire = carbon monoxide = a bad score for you + if (tileValue > Tile.FIREBASE) return 90; + // Radiation. Top of the charts. + if (tileValue >= Tile.RADTILE) return 255; + } + + // All other types of ground are pure. + return 0; + } + + // If we've reached this point, we're classifying some form of zone tile + + // Residential and commercial zones don't pollute + if (tileValue <= Tile.LASTIND) return 0; + // Industrial zones, however... + if (tileValue < Tile.PORTBASE) return 50; + // Coal power plants are bad + if (tileValue <= Tile.LASTPOWERPLANT) return 100; + + return 0; + + } + + // Compute the Manhattan distance of the given point from the city centre, and force into the range 0-64 + static getCityCentreDistance ( map, x, y ) { + + let xDis, yDis; + if ( x > map.cityCentreX ) xDis = x - map.cityCentreX; + else xDis = map.cityCentreX - x; + if ( y > map.cityCentreY ) yDis = y - map.cityCentreY; + else yDis = map.cityCentreY - y; + return Math.min(xDis + yDis, 64); + + } + + // This monster function fills up the landValueMap, the terrainDensityMap and the pollutionDensityMap based + // on values found by iterating over the map. + // + // Factors that affect land value: + // * Distance from the city centre + // * High crime + // * High pollution + // * Proximity to undeveloped terrain (who doesn't love a good view?) + // + // Pollution is completely determined by the tile types in the block + static pollutionTerrainLandValueScan ( map, census, blockMaps ) { + + // We record raw pollution readings for each tile into tempMap1, and then use tempMap2 and tempMap1 to smooth + // out the pollution in order to construct the new values for the populationDensityMap + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; + // tempMap3 will be used to record raw terrain information, i.e. if the the land is developed. This will be + // smoothed in to terrainDensityMap later + let tempMap3 = blockMaps.tempMap3; + tempMap3.clear(); + + let landValueMap = blockMaps.landValueMap; + let terrainDensityMap = blockMaps.terrainDensityMap; + let pollutionDensityMap = blockMaps.pollutionDensityMap; + let crimeRateMap = blockMaps.crimeRateMap; + + let totalLandValue = 0; + let developedTileCount = 0; + + let x = landValueMap.width, y, pollutionLevel, developed, worldX, worldY, mapX, mapY, tileValue, terrainValue, landValue; + + while( x-- ){ + y = landValueMap.height + while( y-- ){ + + pollutionLevel = 0; + developed = false; + + // The land value map has a chunk size of 2 + worldX = x * 2; + worldY = y * 2; + + for ( mapX = worldX; mapX <= worldX + 1; mapX++) { + for ( mapY = worldY; mapY <= worldY + 1; mapY++) { + + + tileValue = map.getTileValue( mapX, mapY ); + if (tileValue === Tile.DIRT) continue; + + if (tileValue < Tile.RUBBLE) { + // Undeveloped land: record in tempMap3. Each undeveloped piece of land scores 15. + // tempMap3 has a chunk size of 4, so each square in tempMap3 will ultimately contain a + // maximum value of 240 + terrainValue = tempMap3.worldGet(mapX, mapY); + tempMap3.worldSet(mapX, mapY, terrainValue + 15); + continue; + } + + pollutionLevel += MapUtils.getPollutionValue(tileValue); + if (tileValue >= Tile.ROADBASE) { + developed = true; + } + + } + } + + pollutionLevel = Math.min(pollutionLevel, 255); + tempMap1.set(x, y, pollutionLevel); + + if (developed) { + landValue = 34 - Math.floor(MapUtils.getCityCentreDistance(map, worldX, worldY) / 2); + landValue = landValue << 2; + // Land in the same neighbourhood as unspoiled land is more valuable... + landValue += terrainDensityMap.get(x >> 1, y >> 1); + // ... and polluted land obviously is less valuable + landValue -= pollutionDensityMap.get(x, y); + // ... getting mugged won't help either + if (crimeRateMap.get(x, y) > 190) { landValue -= 20; } + // Clamp in range 1-250 (0 represents undeveloped land) + landValue = math.clamp(landValue, 1, 250); + landValueMap.set(x, y, landValue); + + totalLandValue += landValue; + developedTileCount++; + } else { + landValueMap.set(x, y, 0); + } + } + } + + if (developedTileCount > 0) census.landValueAverage = Math.floor(totalLandValue / developedTileCount); + else census.landValueAverage = 0; + + // Smooth the pollution map twice + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + + let maxPollution = 0; + let pollutedTileCount = 0; + let totalPollution = 0; + let pollution; + + // We iterate over the now-smoothed pollution map rather than using the block map's copy routines + // so that we can compute the average and total pollution en-route + for (x = 0; x < map.width; x += pollutionDensityMap.blockSize) { + for (y = 0; y < map.height; y += pollutionDensityMap.blockSize) { + // Copy the values into pollutionDensityMap + pollution = tempMap1.worldGet(x, y); + pollutionDensityMap.worldSet(x, y, pollution); + + if (pollution !== 0) { + pollutedTileCount++; + totalPollution += pollution; + + // Note the most polluted location: any monsters will be drawn there (randomly choosing one + // if we have multiple competitors for most polluted) + if (pollution > maxPollution || (pollution === maxPollution && math.getChance(3))) { + maxPollution = pollution; + map.pollutionMaxX = x; + map.pollutionMaxY = y; + } + } + } + } + + if (pollutedTileCount) census.pollutionAverage = Math.floor(totalPollution / pollutedTileCount); + else census.pollutionAverage = 0; + + MapUtils.smoothMap(tempMap3, terrainDensityMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + } + + // Computes the coverage radius of police stations, and scores each neighbourhood in the map on its crime rate. + // Factors that attract crime are: + // * The zone has a low value + // * The zone is a slum + // * The zone is far away from those pesky police + static crimeScan ( census, blockMaps ) { + + let policeStationMap = blockMaps.policeStationMap; + let policeStationEffectMap = blockMaps.policeStationEffectMap; + let crimeRateMap = blockMaps.crimeRateMap; + let landValueMap = blockMaps.landValueMap; + let populationDensityMap = blockMaps.populationDensityMap; + + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationEffectMap, policeStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(policeStationMap, policeStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + let totalCrime = 0; + let crimeZoneCount = 0; + + let x, y, width = crimeRateMap.mapWidth, height = crimeRateMap.mapHeight, value; + + // Scan the map, looking for developed land, as it can attract crime. + for ( x = 0; x < width; x += blockSize ) { + for ( y = 0; y < height; y += blockSize ) { + // Remember: landValueMap values are in the range 0-250 + value = landValueMap.worldGet(x, y); + + if (value > 0) { + + crimeZoneCount += 1; + // Force value in the range -122 to 128. Lower valued pieces of land attract more crime. + value = 128 - value; + // Add population density (a value between 0 and 510). value now lies in range -260 - 382. + // Denser areas attract more crime. + value += populationDensityMap.worldGet(x, y); + // Clamp in range -260 to 300 + value = Math.min(value, 300); + // If the police are nearby, there's no point committing the crime of the century + value -= policeStationMap.worldGet(x, y); + // Force in to range 0-250 + value = math.clamp(value, 0, 250); + + crimeRateMap.worldSet(x, y, value); + totalCrime += value; + + } else { + + crimeRateMap.worldSet(x, y, 0); + + } + } + } + + if ( crimeZoneCount > 0 ) census.crimeAverage = Math.floor(totalCrime / crimeZoneCount); + else census.crimeAverage = 0; + + } + + // Iterate over the map, and score each neighbourhood on its distance from the city centre. Scores are in the range + // -64 to 64. This affects the growth of commercial zones within that neighbourhood. + static fillCityCentreDistScoreMap ( map, blockMaps ) { + + let bm = blockMaps.cityCentreDistScoreMap; + let x = bm.width, y, value; + + while( x-- ){ + y = bm.height + while( y-- ){ + // First, we compute the Manhattan distance of the top-left hand corner of the neighbourhood to the city centre + // and half that value. This leaves us a value in the range 0 - 32 + value = Math.floor(MapUtils.getCityCentreDistance(map, x * 8, y * 8) / 2); + // Now, we scale up by a factor of 4. We're in the range 0 - 128 + value = value * 4; + // And finally, subtract from 64, leaving us a score in the range -64 to 64 + value = 64 - value; + bm.set(x, y, value); + } + } + }; + + // Dispatch to the correct zone type to get the population value for that zone + static getPopulationDensity ( map, x, y, tile ) { + + if (tile < Tile.COMBASE) return Residential.getZonePopulation(map, x, y, tile); + if (tile < Tile.INDBASE) return Commercial.getZonePopulation(map, x, y, tile) * 8; + if (tile < Tile.PORTBASE) return Industrial.getZonePopulation(map, x, y, tile) * 8; + return 0; + + } + + // Iterate over the map, examining each zone for population. We then smooth the results into a population density + // map, which is used when deciding to grow residential zones. At the same time, we also note the most populous area + // (in terms of zones) to calculate our city centre. Finally, we score each area of the map on its distance from the + // city centre. + static populationDensityScan ( map, blockMaps ) { + + // We will build the initial unsmoothed map in tempMap1, and smooth it in to tempMap2 + let tempMap1 = blockMaps.tempMap1; + let tempMap2 = blockMaps.tempMap2; + let populationDensityMap = blockMaps.populationDensityMap; + + // We will sum all the coordinates that contain zones into xTot and yTot. They are used in our city centre heuristic. + let Xtot = 0; + let Ytot = 0; + let zoneTotal = 0; + + tempMap1.clear(); + + let x = map.width, y, tile, tileValue, population + + while( x-- ){ + y = map.height + while( y-- ){ + + tile = map.getTile(x, y); + if (tile.isZone()) { + + tileValue = tile.getValue(); + + // Ask the zone to calculate its population, scale it up, then clamp in the range 0-254 + population = MapUtils.getPopulationDensity(map, x, y, tileValue) * 8; + population = Math.min(population, 254); + + // The block size of population density is 2x2, so there can only be 1 zone per block + tempMap1.worldSet(x, y, population); + Xtot += x; + Ytot += y; + zoneTotal++; + + } + } + } + + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap2, tempMap1, Micro.SMOOTH_ALL_THEN_CLAMP); + MapUtils.smoothMap(tempMap1, tempMap2, Micro.SMOOTH_ALL_THEN_CLAMP); + + blockMaps.populationDensityMap.copyFrom(tempMap2, function(x) {return x * 2;}); + + // XXX This follows the original Micropolis source, but it feels weird to me that we score the entire map + // based on city centre proximity, and then potentially move the city centre. I think these should be + // swapped. + MapUtils.fillCityCentreDistScoreMap( map, blockMaps ) + + // Compute new city center + if (zoneTotal > 0) { + map.cityCentreX = Math.floor(Xtot / zoneTotal); + map.cityCentreY = Math.floor(Ytot / zoneTotal); + } else { + map.cityCentreX = Math.floor(map.width * 0.5); + map.cityCentreY = Math.floor(map.height * 0.5); + } + } + + // Compute the radius of coverage for the firestations found during the map scan + static fireAnalysis ( blockMaps ) { + + let fireStationMap = blockMaps.fireStationMap; + let fireStationEffectMap = blockMaps.fireStationEffectMap; + + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationEffectMap, fireStationMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + MapUtils.smoothMap(fireStationMap, fireStationEffectMap, Micro.SMOOTH_NEIGHBOURS_THEN_BLOCK); + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/math/Direction.js b/games/3dcity/src/micro/math/Direction.js new file mode 100644 index 0000000..3466050 --- /dev/null +++ b/games/3dcity/src/micro/math/Direction.js @@ -0,0 +1,60 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +export const Direction = { + + INVALID: -1, + NORTH: 0, + NORTHEAST: 1, + EAST: 2, + SOUTHEAST: 3, + SOUTH: 4, + SOUTHWEST: 5, + WEST: 6, + NORTHWEST: 7, + BEGIN: 0, + END: 8, + + // Move direction clockwise by 45 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return dir + count; + }, + // Move direction clockwise by 90 degrees. No bounds checking + // i.e. result could be >= END. Has no effect on INVALID. Undefined + // when dir >= END + increment90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.increment45(dir, 2); + }, + // Move direction clockwise by 45 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate45: function (dir, count) { + if (arguments.length < 1) throw new TypeError(); + if (dir == Direction.INVALID) return dir; + if (!count && count !== 0) count = 1; + return ((dir - Direction.NORTH + count) & 7) + Direction.NORTH; + }, + // Move direction clockwise by 90 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate90: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 2); + }, + // Move direction clockwise by 180 degrees, taking the direction modulo 8 + // if necessary to force it into valid bounds. Has no effect on INVALID. + rotate180: function (dir) { + if (arguments.length < 1) throw new TypeError(); + return Direction.rotate45(dir, 4); + }, +} \ No newline at end of file diff --git a/games/3dcity/src/micro/math/Position.js b/games/3dcity/src/micro/math/Position.js new file mode 100644 index 0000000..79d3bc0 --- /dev/null +++ b/games/3dcity/src/micro/math/Position.js @@ -0,0 +1,112 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Direction } from './Direction.js'; +import { Micro } from '../Micro.js'; + +export class Position { + + constructor ( pos, deltaX, deltaY ) { + + this.isPosition = true; + this.width = Micro.MAP_WIDTH; + this.height = Micro.MAP_HEIGHT; + this.x = 0; + this.y = 0; + + + this.validDirs = [Direction.NORTH, Direction.NORTHEAST, Direction.EAST, Direction.SOUTHEAST, + Direction.SOUTH, Direction.SOUTHWEST, Direction.WEST, Direction.NORTHWEST, + Direction.INVALID]; + + + if (arguments.length === 0) return this; + + if (arguments.length === 1 && !pos.isPosition ) throw new Error('Position constructor called with invalid pos ' + pos); + + if (arguments.length === 3 && !pos.isPosition ) throw new Error('Position constructor called with invalid pos ' + pos); + + if (arguments.length === 3 && !(this.isNumber(deltaX) && this.isNumber(deltaY))) throw new Error('Position constructor called with invalid deltas ' + deltaX + ' ' + deltaY); + + if (arguments.length === 2 && this.isNumber(pos) && !this.isNumber(deltaX)) throw new Error('Position constructor called with invalid y coordinate ' + pos + ' ' + deltaX); + + if (arguments.length === 2 && (pos.isPosition) && !(this.isNumber(deltaX) && this.isDirection(deltaX))) throw new Error('Position constructor called with invalid direction ' + pos + ' ' + deltaX); + + if (arguments.length === 2 && !this.isNumber(pos) && !pos.isPosition) throw new Error('Position constructor called with bad existing position ' + pos + ' ' + deltaX); + + + // This overloaded constructor accepts the following parameters + // Position(x, y) - positive integral coordinates + // Position(Position p) - assign from existing position + // Position(Position p, Direction d) - assign from existing position and move in Direction d + // Position(Position p, deltaX, deltaY) - assign from p and then adjust x/y coordinates + // Check for the possible combinations of arguments, and error out for invalid arguments + //if ((arguments.length === 1 || arguments.length === 3) && !(pos instanceof Position)) throw new Error('Invalid parameter'); + //if (arguments.length === 3 && (!isNumber(deltaX) || !isNumber(deltaY))) throw new Error('Invalid parameter'); + //if (arguments.length === 2 && ((isNumber(pos) && !isNumber(deltaX)) || (pos instanceof Position && !isNumber(deltaX)) || (pos instanceof Position && isNumber(deltaX) && !isDirection(deltaX)) || (!isNumber(pos) && !(pos instanceof Position)))) throw new Error('Invalid parameter'); + let moveOK = true; + + if (this.isNumber(pos)) { + // Coordinates + this.x = pos; + this.y = deltaX; + } else { + this.set( pos ); + if (arguments.length === 2) moveOK = this.move( deltaX ); + else if (arguments.length === 3) { + this.x += deltaX; + this.y += deltaY; + } + } + + if ( this.x < 0 || this.x >= this.width || this.y < 0 || this.y >= this.height || !moveOK) throw new Error('Invalid parameter'); + + } + + isNumber ( v ) { + return !isNaN(v) + //return typeof(v) === 'number'; + } + + isDirection ( param ) { + return this.isNumber(param) && this.validDirs.indexOf(param) !== -1; + } + + + set ( from ) { + this.x = from.x; + this.y = from.y; + } + + toString () { + return '(' + this.x + ', ' + this.y + ')'; + } + + toInt () { + return this.y * this.width + this.x; + } + + move ( dir ) { + + let up = false; + switch (dir) { + case Direction.INVALID: return true;//up = true; break; + case Direction.NORTH: if (this.y > 0) { this.y--; up = true; } break; + case Direction.NORTHEAST: if (this.y > 0 && this.x < this.width - 1) { this.y--; this.x++; up = true; } break; + case Direction.EAST: if (this.x < this.width - 1) { this.x++; up = true; } break; + case Direction.SOUTHEAST: if (this.y < this.height - 1 && this.x < this.width - 1) { this.x++; this.y++; up = true; } break; + case Direction.SOUTH: if (this.y < this.height - 1) { this.y++; up = true; } break; + case Direction.SOUTHWEST: if (this.y < this.height - 1 && this.x > 0) { this.y++; this.x--; up = true; } break; + case Direction.WEST: if (this.x > 0) { this.x--; up = true; } break; + case Direction.NORTHWEST: if (this.y > 0 && this.x > 0) { this.y--; this.x--; up = true; } break; + } + return up; + + } +}; \ No newline at end of file diff --git a/games/3dcity/src/micro/math/math.js b/games/3dcity/src/micro/math/math.js new file mode 100644 index 0000000..5d0d45d --- /dev/null +++ b/games/3dcity/src/micro/math/math.js @@ -0,0 +1,37 @@ +export class math { + + static lerp ( x, y, t ) { return ( 1 - t ) * x + t * y; } + static rand ( low, high ) { return low + Math.random() * ( high - low ); } + static randInt ( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); } + + static clamp (value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + } + + static getChance (chance) { + return (math.getRandom16() & chance) === 0; + } + + static getERandom ( max ) { + var r1 = math.getRandom(max); + var r2 = math.getRandom(max); + return Math.min(r1, r2); + } + + static getRandom ( max ) { + return Math.floor(Math.random() * (max + 1)); + } + + static getRandom16 () { + return math.getRandom(65535); + } + + static getRandom16Signed () { + var value = math.getRandom16(); + if (value < 32768) return value; + else return -(2 ** 16) + value; + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/AirplaneSprite.js b/games/3dcity/src/micro/sprite/AirplaneSprite.js new file mode 100644 index 0000000..f68bb54 --- /dev/null +++ b/games/3dcity/src/micro/sprite/AirplaneSprite.js @@ -0,0 +1,101 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class AirplaneSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init( Micro.SPRITE_AIRPLANE, map, spriteManager, x, y ); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + if (x > SpriteUtils.worldToPix(map.width - 20)) { + this.destX = this.x - 200; + this.frame = 7; + } else { + this.destX = this.x + 200; + this.frame = 11; + } + this.destY = this.y; + + this.xDelta = [0, 0, 6, 8, 6, 0, -6, -8, -6, 8, 8, 8]; + this.yDelta = [0, -8, -6, 0, 6, 8, 6, 0, -6, 0, 0, 0]; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + let frame = this.frame; + + if ((spriteCycle % 5) === 0) { + // Frames > 8 mean the plane is taking off + if (frame > 8) { + frame--; + if (frame < 9) { // Planes always take off to the east + frame = 3; + } + this.frame = frame; + } else { + let d = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, d); + this.frame = frame; + } + } + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + if (absDist < 50) { + // We're pretty close to the destination + this.destX = math.getRandom(SpriteUtils.worldToPix(this.map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(this.map.height)) + 8; + } + + if (disasterManager.enableDisasters) { + let explode = false; + + let spriteList = this.spriteManager.getSpriteList(); + for (let i = 0; i < spriteList.length; i++) { + + let s = spriteList[i]; + + //if (s.frame === 0 || s === sprite) continue; + if (s.frame === 0 ) continue; + + if ((s.type === Micro.SPRITE_HELICOPTER || s.type === Micro.SPRITE_AIRPLANE) && SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + explode = true; + } + } + + if (explode) this.explodeSprite(messageManager); + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + + if (this.spriteNotInBounds()) this.frame = 0; + } + + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.PLANE_CRASHED); + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/BaseSprite.js b/games/3dcity/src/micro/sprite/BaseSprite.js new file mode 100644 index 0000000..6797796 --- /dev/null +++ b/games/3dcity/src/micro/sprite/BaseSprite.js @@ -0,0 +1,51 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { SpriteUtils } from './SpriteUtils.js'; + +export class BaseSprite { + + constructor ( ) { + } + + init ( type, map, spriteManager, x, y ) { + + this.type = type; + this.map = map; + this.spriteManager = spriteManager; + this.x = x; + this.y = y; + this.origX = 0; + this.origY = 0; + this.destX = 0; + this.destY = 0; + this.count = 0; + this.soundCount = 0; + this.dir = 0; + this.newDir = 0; + this.step = 0; + this.flag = 0; + this.turn = 0; + this.accel = 0; + this.speed = 100; + } + + getFileName () { + return ['obj', this.type, '-', this.frame - 1].join(''); + } + + spriteNotInBounds () { + + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + return x < 0 || y < 0 || x >= this.map.width || y >= this.map.height; + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/BoatSprite.js b/games/3dcity/src/micro/sprite/BoatSprite.js new file mode 100644 index 0000000..b8cd949 --- /dev/null +++ b/games/3dcity/src/micro/sprite/BoatSprite.js @@ -0,0 +1,160 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class BoatSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init( Micro.SPRITE_SHIP, map, spriteManager, x, y ); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x < SpriteUtils.worldToPix(4)) this.frame = 3; + else if (x >= SpriteUtils.worldToPix(map.width - 4)) this.frame = 7; + else if (y < SpriteUtils.worldToPix(4)) this.frame = 5; + else if (y >= SpriteUtils.worldToPix(map.height - 4)) this.frame = 1; + else this.frame = 3; + + this.newDir = this.frame; + this.dir = 10; + this.count = 1; + + this.tileDeltaX = [0, 0, 1, 1, 1, 0, -1, -1, -1]; + this.tileDeltaY = [0, -1, -1, 0, 1, 1, 1, 0, -1]; + this.xDelta = [0, 0, 2, 2, 2, 0, -2, -2, -2]; + this.yDelta = [0, -2, -2, 0, 2, 2, 2, 0, -2]; + this.tileWhiteList = [Tile.RIVER, Tile.CHANNEL, Tile.POWERBASE, Tile.POWERBASE + 1, Tile.RAILBASE, Tile.RAILBASE + 1, Tile.BRWH, Tile.BRWV]; + + this.CANTMOVE = 10; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + let t = Tile.RIVER; + + let startDir, frame, dir, x, y, tileValue; + + if (this.soundCount > 0) this.soundCount--; + + if (this.soundCount === 0) { + if ((math.getRandom16() & 3) === 1) { + // TODO Scenarios + // TODO Sound + messageManager.sendMessage(Messages.SOUND_HONKHONK); + } + + this.soundCount = 200; + } + + if (this.count > 0) this.count--; + + if (this.count === 0) { + + // Ships turn slowly: only 45° every 9 cycles + this.count = 9; + + // If already executing a turn, continue to do so + if (this.frame !== this.newDir) { + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + return; + } + + // Otherwise pick a new direction + // Choose a random starting direction to search from + // 0 = N, 1 = NE, ... 7 = NW + startDir = math.getRandom16() & 7; + frame = this.frame; + + for ( dir = startDir; dir < (startDir + 8); dir++) { + + frame = (dir & 7) + 1; + + if (frame === this.dir) continue; + + x = SpriteUtils.pixToWorld(this.x) + this.tileDeltaX[frame]; + y = SpriteUtils.pixToWorld(this.y) + this.tileDeltaY[frame]; + + if (this.map.testBounds(x, y)) { + tileValue = this.map.getTileValue(x, y); + + // Test for a suitable water tile + if (tileValue === Tile.CHANNEL || tileValue === Tile.BRWH || tileValue === Tile.BRWV || this.oppositeAndUnderwater(tileValue, this.dir, frame)) { + this.newDir = frame; + this.frame = SpriteUtils.turnTo(this.frame, this.newDir); + this.dir = frame + 4; + + if (this.dir > 8) this.dir -= 8; + break; + } + } + } + + if (dir === (startDir + 8)) { + this.dir = this.CANTMOVE; + this.newDir = (math.getRandom16() & 7) + 1; + } + } else { + frame = this.frame; + + if (frame === this.newDir) { + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + } + + if (this.spriteNotInBounds()) { + this.frame = 0; + return; + } + + // If we didn't find a new direction, we might explode + // depending on the last tile we looked at. + for (let i = 0; i < 8; i++) { + + if (t === this.tileWhiteList[i]) break; + if (i === 7) { + this.explodeSprite(messageManager); + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } + } + } + + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.SHIP_CRASHED); + } + + // This is an odd little function. It returns true if + // oldDir is 180° from newDir and tileValue is underwater + // rail or wire, and returns false otherwise + oppositeAndUnderwater (tileValue, oldDir, newDir) { + let opposite = oldDir + 4; + if (opposite > 8) opposite -= 8; + if (newDir != opposite) return false; + if (tileValue == Tile.POWERBASE || tileValue == Tile.POWERBASE + 1 || tileValue == Tile.RAILBASE || tileValue == Tile.RAILBASE + 1) return true; + return false; + } + +} + diff --git a/games/3dcity/src/micro/sprite/CopterSprite.js b/games/3dcity/src/micro/sprite/CopterSprite.js new file mode 100644 index 0000000..b9a5eb6 --- /dev/null +++ b/games/3dcity/src/micro/sprite/CopterSprite.js @@ -0,0 +1,106 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class CopterSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init(Micro.SPRITE_HELICOPTER, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 5; + this.count = 1500; + this.destX = math.getRandom(SpriteUtils.worldToPix(map.width)) + 8; + this.destY = math.getRandom(SpriteUtils.worldToPix(map.height)) + 8; + this.origX = x; + this.origY = y; + + this.xDelta = [0, 0, 3, 5, 3, 0, -3, -5, -3]; + this.yDelta = [0, -5, -3, 0, 3, 5, 3, 0, -3]; + + } + + move ( spriteCycle, messageManager, disasterManager, blockMaps ) { + + if (this.soundCount > 0) this.soundCount--; + + if (this.count > 0) this.count--; + + if (this.count === 0) { + // Head towards a monster, and certain doom + let s = this.spriteManager.getSprite(Micro.SPRITE_MONSTER); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + // No monsters. Hm. I bet flying near that tornado is sensible + s = this.spriteManager.getSprite(Micro.SPRITE_TORNADO); + + if (s !== null) { + this.destX = s.x; + this.destY = s.y; + } else { + this.destX = this.origX; + this.destY = this.origY; + } + } + + // If near destination, let's get her on the ground + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.origX, this.origY); + if (absDist < 30) { + this.frame = 0; + return; + } + } + + if (this.soundCount === 0) { + let x = SpriteUtils.pixToWorld(this.x); + let y = SpriteUtils.pixToWorld(this.y); + + if (x >= 0 && x < this.map.width && y >= 0 && y < this.map.height) { + if (blockMaps.trafficDensityMap.worldGet(x, y) > 170 && (math.getRandom16() & 7) === 0) { + messageManager.sendMessage(Messages.HEAVY_TRAFFIC, {x: x, y: y}); + messageManager.sendMessage(Messages.SOUND_HEAVY_TRAFFIC); + this.soundCount = 200; + } + } + } + + let frame = this.frame; + + if ((spriteCycle & 3) === 0) { + let dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + frame = SpriteUtils.turnTo(frame, dir); + this.frame = frame; + } + + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + } + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.HELICOPTER_CRASHED); + } + +} diff --git a/games/3dcity/src/micro/sprite/ExplosionSprite.js b/games/3dcity/src/micro/sprite/ExplosionSprite.js new file mode 100644 index 0000000..1776d5c --- /dev/null +++ b/games/3dcity/src/micro/sprite/ExplosionSprite.js @@ -0,0 +1,72 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile, ZoneUtils } from '../Tile.js'; +import { Messages } from '../Messages.js'; + +import { math } from '../math/math.js'; + +export class ExplosionSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init(Micro.SPRITE_EXPLOSION, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + this.frame = 1; + } + + startFire (x, y) { + x = ZoneUtils.pixToWorld(x); + y = ZoneUtils.pixToWorld(y); + + if (!this.map.testBounds(x, y)) return; + + let tile = this.map.getTile(x, y); + let tileValue = tile.getValue(); + + if (!tile.isCombustible() && tileValue !== Tile.DIRT) return; + + if (tile.isZone()) return; + + this.map.setTo(x, y, ZoneUtils.randomFire()); + + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + + if ((spriteCycle & 1) === 0) { + if (this.frame === 1) { + // Convert sprite coordinates to tile coordinates. + let explosionX = ZoneUtils.pixToWorld(this.x); + let explosionY = ZoneUtils.pixToWorld(this.y); + messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + messageManager.sendMessage(Messages.EXPLOSION_REPORTED, {x: explosionX, y: explosionY}); + } + + this.frame++; + } + + if (this.frame > 6) { + this.frame = 0; + + this.startFire(this.x, this.y); + this.startFire(this.x - 16, this.y - 16); + this.startFire(this.x + 16, this.y + 16); + this.startFire(this.x - 16, this.y + 16); + this.startFire(this.x + 16, this.y + 16); + } + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/MonsterSprite.js b/games/3dcity/src/micro/sprite/MonsterSprite.js new file mode 100644 index 0000000..d7b1109 --- /dev/null +++ b/games/3dcity/src/micro/sprite/MonsterSprite.js @@ -0,0 +1,152 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class MonsterSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init(Micro.SPRITE_MONSTER, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -24; + + if (x > SpriteUtils.worldToPix(map.width) / 2) { + if (y > SpriteUtils.worldToPix(map.height) / 2) this.frame = 10; + else this.frame = 7; + } else if (y > SpriteUtils.worldToPix(map.height) / 2) { + this.frame = 1; + } else { + this.frame = 4; + } + + this.flag = 0; + this.count = 1000; + this.destX = SpriteUtils.worldToPix(map.pollutionMaxX); + this.destY = SpriteUtils.worldToPix(map.pollutionMaxY); + this.origX = this.x; + this.origY = this.y; + this._seenLand = false; + + this.xDelta = [ 2, 2, -2, -2, 0]; + this.yDelta = [-2, 2, 2, -2, 0]; + this.cardinals1 = [ 0, 1, 2, 3]; + this.cardinals2 = [ 1, 2, 3, 0]; + this.diagonals1 = [ 2, 5, 8, 11]; + this.diagonals2 = [11, 2, 5, 8]; + } + + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + + if (this.soundCount > 0) this.soundCount--; + + // Frames 1 - 12 are diagonal sprites, 3 for each direction. + // 1-3 NE, 2-6 SE, etc. 13-16 represent the cardinal directions. + let currentDir = Math.floor((this.frame - 1) / 3); + let frame, dir; + + if (currentDir < 4) { /* turn n s e w */ + // Calculate how far in the 3 step animation we were, + // move on to the next one + frame = (this.frame - 1) % 3; + + if (frame === 2) this.step = 0; + + if (frame === 0) this.step = 1; + + if (this.step) frame++; + else frame--; + + let absDist = SpriteUtils.absoluteDistance(this.x, this.y, this.destX, this.destY); + + if (absDist < 60) { + if (this.flag === 0) { + this.flag = 1; + this.destX = this.origX; + this.destY = this.origY; + } else { + this.frame = 0; + return; + } + } + + // Perhaps switch to a cardinal direction + dir = SpriteUtils.getDir(this.x, this.y, this.destX, this.destY); + dir = Math.floor((dir - 1) / 2); + + if (dir !== currentDir && math.getChance(10)) { + + if (math.getRandom16() & 1) frame = this.cardinals1[currentDir]; + else frame = this.cardinals2[currentDir]; + + currentDir = 4; + + if (!this.soundCount) { + messageManager.sendMessage(Messages.SOUND_MONSTER); + this.soundCount = 50 + math.getRandom(100); + } + } + } else { + // Travelling in a cardinal direction. Switch to a diagonal + currentDir = 4; + dir = this.frame; + frame = (dir - 13) & 3; + + if (!(math.getRandom16() & 3)) { + if (math.getRandom16() & 1) frame = this.diagonals1[frame]; + else frame = this.diagonals2[frame]; + + // We mung currentDir and frame here to + // make the assignment below work + currentDir = Math.floor((frame - 1) / 3); + frame = (frame - 1) % 3; + } + } + + frame = currentDir * 3 + frame + 1; + if (frame > 16) frame = 16; + + this.frame = frame; + + this.x += this.xDelta[currentDir]; + this.y += this.yDelta[currentDir]; + + if (this.count > 0) this.count--; + + let tileValue = SpriteUtils.getTileValue(this.map, this.x, this.y); + + if (tileValue === -1 || (tileValue === Tile.RIVER && this.count < 500)) this.frame = 0; + + if (tileValue === Tile.DIRT || tileValue > Tile.WATER_HIGH) this._seenLand = true; + + let spriteList = this.spriteManager.getSpriteList(); + for (let i = 0; i < spriteList.length; i++) { + let s = spriteList[i]; + + if (s.frame !== 0 && + (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || + s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && + SpriteUtils.checkSpriteCollision(this, s)) + s.explodeSprite(messageManager); + } + + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/SpriteManager.js b/games/3dcity/src/micro/sprite/SpriteManager.js new file mode 100644 index 0000000..6e5e844 --- /dev/null +++ b/games/3dcity/src/micro/sprite/SpriteManager.js @@ -0,0 +1,237 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; + +import { SpriteUtils } from './SpriteUtils.js'; +import { TrainSprite } from './TrainSprite.js'; +import { BoatSprite } from './BoatSprite.js'; +import { MonsterSprite } from './MonsterSprite.js'; +import { CopterSprite } from './CopterSprite.js'; +import { AirplaneSprite } from './AirplaneSprite.js'; +import { TornadoSprite } from './TornadoSprite.js'; +import { ExplosionSprite } from './ExplosionSprite.js'; + +import { math } from '../math/math.js'; + +const constructors = {}; +constructors[Micro.SPRITE_TRAIN] = TrainSprite; +constructors[Micro.SPRITE_SHIP] = BoatSprite; +constructors[Micro.SPRITE_MONSTER] = MonsterSprite; +constructors[Micro.SPRITE_HELICOPTER] = CopterSprite; +constructors[Micro.SPRITE_AIRPLANE] = AirplaneSprite; +constructors[Micro.SPRITE_TORNADO] = TornadoSprite; +constructors[Micro.SPRITE_EXPLOSION] = ExplosionSprite; + + + + +export class SpriteManager { + + constructor ( map ) { + + this.spriteList = []; + this.map = map; + this.spriteCycle = 0; + } + + getSprite (type) { + + let filteredList = this.spriteList.filter(function (s) { + return s.frame !== 0 && s.type === type; + }); + if (filteredList.length === 0) return null; + return filteredList[0]; + } + + getSpriteList () { + return this.spriteList.slice(); + } + + getSpritesInView (startX, startY, lastX, lastY) { + let sprites = []; + startX = SpriteUtils.worldToPix(startX); + startY = SpriteUtils.worldToPix(startY); + lastX = SpriteUtils.worldToPix(lastX); + lastY = SpriteUtils.worldToPix(lastY); + return this.spriteList.filter(function(s) { + return (s.x + s.xOffset >= startX && s.y + s.yOffset >= startY) && + !(s.x + s.xOffset >= lastX && s.y + s.yOffset >= lastY); + }); + } + + moveObjects ( simData ) { + + if(!simData) simData = Micro.simData + + let messageManager = simData.messageManager; + let disasterManager = simData.disasterManager; + let blockMaps = simData.blockMaps; + + this.spriteCycle += 1; + + let list = this.spriteList.slice(); + + let i = list.length; + while(i--){ + //for (let i = 0, l = list.length; i < l; i++) { + let sprite = list[i]; + if (sprite.frame === 0) continue; + sprite.move(this.spriteCycle, messageManager, disasterManager, blockMaps); + } + + this.pruneDeadSprites(); + } + + makeSprite (type, x, y) { + + this.spriteList.push(new constructors[type](this.map, this, x, y)); + + } + + makeTornado (messageManager) { + let sprite = this.getSprite( Micro.SPRITE_TORNADO ); + if (sprite !== null) { + sprite.count = 200; + return; + } + let x = math.getRandom(SpriteUtils.worldToPix(this.map.width) - 800) + 400; + let y = math.getRandom(SpriteUtils.worldToPix(this.map.height) - 200) + 100; + + this.makeSprite( Micro.SPRITE_TORNADO, x, y ); + messageManager.sendMessage(Messages.TORNADO_SIGHTED, {x: SpriteUtils.pixToWorld(x), y: SpriteUtils.pixToWorld(y)}); + } + + makeExplosion (x, y) { + if (this.map.testBounds(x, y)) this.makeExplosionAt(SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + makeExplosionAt(x, y) { + this.makeSprite(Micro.SPRITE_EXPLOSION, x, y); + } + + generatePlane (x, y) { + if (this.getSprite(Micro.SPRITE_AIRPLANE) !== null) return; + this.makeSprite(Micro.SPRITE_AIRPLANE, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + } + + generateTrain (census, x, y) { + if (census.totalPop > 20 && this.getSprite(Micro.SPRITE_TRAIN) === null && math.getRandom(25) === 0) this.makeSprite(Micro.SPRITE_TRAIN,SpriteUtils.worldToPix(x) + 8, SpriteUtils.worldToPix(y) + 8); + } + + generateShip () { + // XXX This code is borked. The map generator will never + // place a channel tile on the edges of the map + let x,y; + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, 0) === Tile.CHANNEL) { + this.makeShipHere(x, 0); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(0, y) === Tile.CHANNEL) { + this.makeShipHere(0, y); + return; + } + } + } + + if (math.getChance(3)) { + for (x = 4; x < this.map.width - 2; x++) { + if (this.map.getTileValue(x, this.map.height - 1) === Tile.CHANNEL) { + this.makeShipHere(x, this.map.height - 1); + return; + } + } + } + + if (math.getChance(3)) { + for (y = 1; y < this.map.height - 2; y++) { + if (this.map.getTileValue(this.map.width - 1, y) === Tile.CHANNEL) { + this.makeShipHere(this.map.width - 1, y); + return; + } + } + } + } + + getBoatDistance (x, y) { + let dist = 99999; + let pixelX = SpriteUtils.worldToPix(x) + 8; + let pixelY = SpriteUtils.worldToPix(y) + 8; + let sprite; + + for (let i = 0, l = this.spriteList.length; i < l; i++) { + sprite = this.spriteList[i]; + if (sprite.type === Micro.SPRITE_SHIP && sprite.frame !== 0) { + //let sprDist = Micro.absoluteValue(sprite.x - pixelX) + Micro.absoluteValue(sprite.y - pixelY); + let sprDist = Math.abs(sprite.x - pixelX) + Math.abs(sprite.y - pixelY); + dist = Math.min(dist, sprDist); + } + } + + return dist; + } + + makeShipHere (x, y) { + this.makeSprite(Micro.SPRITE_SHIP,SpriteUtils.worldToPix(x),SpriteUtils.worldToPix(y)); + } + + generateCopter (x, y) { + if (this.getSprite(Micro.SPRITE_HELICOPTER) !== null) return; + this.makeSprite(Micro.SPRITE_HELICOPTER,SpriteUtils.worldToPix(x),SpriteUtils.worldToPix(y)); + } + + makeMonsterAt (messageManager, x, y) { + + this.makeSprite(Micro.SPRITE_MONSTER, SpriteUtils.worldToPix(x), SpriteUtils.worldToPix(y)); + messageManager.sendMessage(Messages.MONSTER_SIGHTED, {x: x, y: y}); + } + + makeMonster (messageManager) { + let sprite = this.getSprite(Micro.SPRITE_MONSTER); + if (sprite !== null) { + sprite.soundCount = 1; + sprite.count = 1000; + sprite.destX = SpriteUtils.worldToPix(this.map.pollutionMaxX); + sprite.destY = SpriteUtils.worldToPix(this.map.pollutionMaxY); + } + + let done = 0; + for (let i = 0; i < 300; i++) { + let x = math.getRandom(this.map.width - 20) + 10; + let y = math.getRandom(this.map.height - 10) + 5; + let tile = this.map.getTile(x, y); + if (tile.getValue() === Tile.RIVER) { + this.makeMonsterAt(messageManager, x, y); + done = 1; + break; + } + } + + if (done === 0) this.makeMonsterAt(messageManager, 60, 50); + } + + pruneDeadSprites (type) { + this.spriteList = this.spriteList.filter(function (s) { return s.frame !== 0; }); + } + +} + + + + diff --git a/games/3dcity/src/micro/sprite/SpriteUtils.js b/games/3dcity/src/micro/sprite/SpriteUtils.js new file mode 100644 index 0000000..a5e9b63 --- /dev/null +++ b/games/3dcity/src/micro/sprite/SpriteUtils.js @@ -0,0 +1,134 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; + + +export class SpriteUtils { + + static pixToWorld (p) { + return ZoneUtils.pixToWorld(p); + } + + static worldToPix (w) { + return ZoneUtils.worldToPix(w); + } + + // Attempt to move 45° towards the desired direction, either + // clockwise or anticlockwise, whichever gets us there quicker + static turnTo ( presentDir, desiredDir ) { + + if (presentDir === desiredDir) return presentDir; + + if (presentDir < desiredDir) { + // select clockwise or anticlockwise + if (desiredDir - presentDir < 4) presentDir++; + else presentDir--; + } else { + if (presentDir - desiredDir < 4) presentDir--; + else presentDir++; + } + if (presentDir > 8) presentDir = 1; + if (presentDir < 1) presentDir = 8; + return presentDir; + + } + + static absoluteValue ( x ) { + return Math.abs(x); + } + + static getTileValue ( map, x, y ) { + + let wX = ZoneUtils.pixToWorld(x); + let wY = ZoneUtils.pixToWorld(y); + if (wX < 0 || wX >= map.width || wY < 0 || wY >= map.height) return -1; + return map.getTileValue(wX, wY); + + } + + + // Choose the best direction to get from the origin to the destination + // If the destination is equidistant in both x and y deltas, a diagonal + // will be chosen, otherwise the most 'dominant' difference will be selected + // (so if a destination is 4 units north and 2 units east, north will be chosen). + // This code seems to always choose south if we're already there which seems like + // a bug + + static getDir ( orgX, orgY, destX, destY ) { + + let deltaX = destX - orgX; + let deltaY = destY - orgY; + let i; + + if (deltaX < 0) { + i = deltaY < 0 ? 11 : 8; + } else { + i = deltaY < 0 ? 2 : 5; + } + + deltaX = Math.abs(deltaX); + deltaY = Math.abs(deltaY); + + if (deltaX * 2 < deltaY) i++; + else if (deltaY * 2 < deltaX) i--; + if (i < 0 || i > 12) i = 0; + return Micro.directionTable[i]; + + } + + static absoluteDistance ( orgX, orgY, destX, destY ) { + + let deltaX = destX - orgX; + let deltaY = destY - orgY; + return Math.abs(deltaX) + Math.abs(deltaY); + + } + + static checkWet ( tileValue ) { + + if (tileValue === Tile.HPOWER || tileValue === Tile.VPOWER || tileValue === Tile.HRAIL || tileValue === Tile.VRAIL || tileValue === Tile.BRWH || tileValue === Tile.BRWV) return true; + else return false; + + } + + static destroyMapTile ( spriteManager, map, blockMaps, ox, oy ) { + + let x = ZoneUtils.pixToWorld(ox); + let y = ZoneUtils.pixToWorld(oy); + + if (!map.testBounds(x, y)) return; + + let tile = map.getTile(x, y); + let tileValue = tile.getValue(); + + if (tileValue < Tile.TREEBASE) return; + + if (!tile.isCombustible()) { + if (tileValue >= Tile.ROADBASE && tileValue <= Tile.LASTROAD) map.setTile(x, y, Tile.RIVER, 0); + return; + } + + if (tile.isZone()) { + ZoneUtils.fireZone( map, x, y, blockMaps ); + if (tileValue > Tile.RZB) spriteManager.makeExplosionAt(ox, oy); + } + if (SpriteUtils.checkWet(tileValue)) map.setTile(x, y, Tile.RIVER, 0); + else map.setTile(x, y, Tile.TINYEXP, Tile.BULLBIT | Tile.ANIMBIT); + + } + + static getDistance (x1, y1, x2, y2) { + return Math.abs(x1 - x2) + Math.abs(y1 - y2); + } + + static checkSpriteCollision (s1, s2) { + return s1.frame !== 0 && s2.frame !== 0 && SpriteUtils.getDistance(s1.x, s1.y, s2.x, s2.y) < 30; + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/TornadoSprite.js b/games/3dcity/src/micro/sprite/TornadoSprite.js new file mode 100644 index 0000000..16996ae --- /dev/null +++ b/games/3dcity/src/micro/sprite/TornadoSprite.js @@ -0,0 +1,95 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class TornadoSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init(Micro.SPRITE_TORNADO, map, spriteManager, x, y); + this.width = 48; + this.height = 48; + this.xOffset = -24; + this.yOffset = -40; + this.frame = 1; + this.count = 200; + + this.xDelta = [2, 3, 2, 0, -2, -3]; + this.yDelta = [-2, 0, 2, 3, 2, 0]; + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + let frame; + frame = this.frame; + + // If middle frame, move right or left + // depending on the flag value + // If frame = 1, perhaps die based on flag + // value + if (frame === 2) { + if (this.flag) frame = 3; + else frame = 1; + } else { + if (frame === 1) this.flag = 1; + else this.flag = 0; + + frame = 2; + } + + if (this.count > 0) this.count--; + + this.frame = frame; + + let spriteList = this.spriteManager.getSpriteList(); + + for (let i = 0; i < spriteList.length; i++) { + + let s = spriteList[i]; + + // Explode vulnerable sprites + if (s.frame !== 0 && + (s.type === Micro.SPRITE_AIRPLANE || s.type === Micro.SPRITE_HELICOPTER || + s.type === Micro.SPRITE_SHIP || s.type === Micro.SPRITE_TRAIN) && + SpriteUtils.checkSpriteCollision(this, s)) { + s.explodeSprite(messageManager); + } + } + + frame = Random.getRandom(5); + this.x += this.xDelta[frame]; + this.y += this.yDelta[frame]; + + if (this.spriteNotInBounds()) this.frame = 0; + + if (this.count !== 0 && Random.getRandom(500) === 0) this.frame = 0; + + SpriteUtils.destroyMapTile(this.spriteManager, this.map, blockMaps, this.x, this.y); + } +} +/* + + // Metadata for image loading + Object.defineProperties(TornadoSprite, + {ID: Micro.makeConstantDescriptor(6), + width: Micro.makeConstantDescriptor(48), + frames: Micro.makeConstantDescriptor(3)}); + + + return TornadoSprite; +}); +*/ \ No newline at end of file diff --git a/games/3dcity/src/micro/sprite/TrainSprite.js b/games/3dcity/src/micro/sprite/TrainSprite.js new file mode 100644 index 0000000..9d3db46 --- /dev/null +++ b/games/3dcity/src/micro/sprite/TrainSprite.js @@ -0,0 +1,119 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseSprite } from './BaseSprite.js'; +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { SpriteUtils } from './SpriteUtils.js'; + +import { math } from '../math/math.js'; + +export class TrainSprite extends BaseSprite { + + constructor ( map, spriteManager, x, y ) { + + super() + + this.init(Micro.SPRITE_TRAIN, map, spriteManager, x, y); + this.width = 32; + this.height = 32; + this.xOffset = -16; + this.yOffset = -16; + this.frame = 1; + this.dir = 4; + + this.tileDeltaX = [ 0, 16, 0, -16]; + this.tileDeltaY = [-16, 0, 16, 0 ]; + this.xDelta = [ 0, 4, 0, -4, 0]; + this.yDelta = [ -4, 0, 4, 0, 0]; + + this.TrainPic2 = [ 1, 2, 1, 2, 5]; + + // Frame values + this.NORTHSOUTH = 1; + this.EASTWEST = 2; + this.NWSE = 3; + this.NESW = 4; + this.UNDERWATER = 5; + + // Direction values + this.NORTH = 0; + this.EAST = 1; + this.SOUTH = 2; + this.WEST = 3; + this.CANTMOVE = 4; + + } + + move (spriteCycle, messageManager, disasterManager, blockMaps) { + // Trains can only move in the 4 cardinal directions + // Over the course of 4 frames, we move through a tile, so + // ever fourth frame, we try to find a direction to move in + // (excluding the opposite direction from the current direction + // of travel). If there is no possible direction found, our direction + // is set to CANTMOVE. (Thus, if we're in a dead end, we can start heading + // backwards next time round). If we fail to find a destination after 2 attempts, + // we die. + + if (this.frame === this.NWSE || this.frame === this.NESW) this.frame = this.TrainPic2[this.dir]; + + this.x += this.xDelta[this.dir]; + this.y += this.yDelta[this.dir]; + + // Find a new direction. + if ((spriteCycle & 3) === 0) { + // Choose a random starting point for our search + let dir = math.getRandom16() & 3; + + for (let i = dir; i < dir + 4; i++) { + let dir2 = i & 3; + + if (this.dir !== this.CANTMOVE) { + // Avoid the opposite direction + if (dir2 === ((this.dir + 2) & 3)) continue; + } + + let tileValue = SpriteUtils.getTileValue(this.map, this.x + this.tileDeltaX[dir2], this.y + this.tileDeltaY[dir2]); + + if ((tileValue >= Tile.RAILBASE && tileValue <= Tile.LASTRAIL) || tileValue === Tile.RAILVPOWERH || tileValue === Tile.RAILHPOWERV) { + if (this.dir !== dir2 && this.dir !== this.CANTMOVE) { + + if (this.dir + dir2 === this.WEST) this.frame = this.NWSE; + else this.frame = this.NESW; + + } else { + this.frame = this.TrainPic2[dir2]; + } + + if (tileValue === Tile.HRAIL || tileValue === Tile.VRAIL) this.frame = this.UNDERWATER; + + this.dir = dir2; + return; + } + } + + // Nowhere to go. Die. + if (this.dir === this.CANTMOVE) { + this.frame = 0; + return; + } + + // We didn't find a direction this time. We'll try the opposite + // next time around + this.dir = this.CANTMOVE; + } + } + + explodeSprite (messageManager) { + this.frame = 0; + this.spriteManager.makeExplosionAt(this.x, this.y); + messageManager.sendMessage(Messages.TRAIN_CRASHED); + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/BaseTool.js b/games/3dcity/src/micro/tool/BaseTool.js new file mode 100644 index 0000000..655e301 --- /dev/null +++ b/games/3dcity/src/micro/tool/BaseTool.js @@ -0,0 +1,98 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { MiscUtils } from '../Micro.js'; +import { Tile, Tiles, ZoneUtils } from '../Tile.js'; +import { WorldEffects } from './WorldEffects.js'; + + +export class BaseTool { + + constructor () { + + this.TOOLRESULT_OK = 0; + this.TOOLRESULT_FAILED = 1; + this.TOOLRESULT_NO_MONEY = 2; + this.TOOLRESULT_NEEDS_BULLDOZE = 3; + this.autoBulldoze = true; + this.bulldozerCost = 1; + + } + + init ( cost, map, shouldAutoBulldoze, IsDraggable = false ) { + + //Object.defineProperty(this, 'toolCost', MiscUtils.mcd(cost)); + this.toolCost = cost; + this.result = null; + this.isDraggable = IsDraggable; + this._shouldAutoBulldoze = shouldAutoBulldoze; + this._map = map; + this._worldEffects = new WorldEffects( map ); + this._applicationCost = 0; + + } + + clear () { + + this._applicationCost = 0; + this._worldEffects.clear(); + + } + + addCost ( cost ) { + + this._applicationCost += cost; + + } + + doAutoBulldoze ( x, y ) { + + //if ( !this._shouldAutoBulldoze ) return; + let tile = this._worldEffects.getTile(x, y); + if ( tile.isBulldozable() ) { + tile = ZoneUtils.normalizeRoad( tile ); + if ((tile >= Tile.TINYEXP && tile <= Tile.LASTTINYEXP) || (tile < Tile.HBRIDGE && tile !== Tile.DIRT)) { + this.addCost(1); + this._worldEffects.setTile(x, y, Tile.DIRT); + } + } + + } + + apply ( budget ) { + + this._worldEffects.apply(); + budget.spend(this._applicationCost); + this.clear(); + + } + + modifyIfEnoughFunding ( budget ) { + + if (this.result !== this.TOOLRESULT_OK) { this.clear(); return false; } + if (budget.totalFunds < this._applicationCost) { this.result = this.TOOLRESULT_NO_MONEY; this.clear(); return false; } + this.apply.call(this, budget); + this.clear(); + return true; + + } + + setAutoBulldoze ( value ) { + + this.autoBulldoze = value; + + } + + getAutoBulldoze () { + + return this.autoBulldoze; + + } + +} diff --git a/games/3dcity/src/micro/tool/BaseToolConnector.js b/games/3dcity/src/micro/tool/BaseToolConnector.js new file mode 100644 index 0000000..c5c7972 --- /dev/null +++ b/games/3dcity/src/micro/tool/BaseToolConnector.js @@ -0,0 +1,143 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseTool } from './BaseTool.js'; +import { Tile, ZoneUtils, RoadTable, RailTable, WireTable } from '../Tile.js'; + +export class BaseToolConnector extends BaseTool { + + constructor () { + + super() + + } + + fixSingle ( x, y ) { + + let adjTile = 0; + let tile = this._worldEffects.getTile(x, y); + + tile = ZoneUtils.normalizeRoad(tile); + + if (tile >= Tile.ROADS && tile <= Tile.INTERSECTION) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 1; + } + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 2; + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.HRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.HROADPOWER && tile !== Tile.VRAILROAD && tile !== Tile.ROADBASE) adjTile |= 4; + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if ((tile === Tile.VRAILROAD || (tile >= Tile.ROADBASE && tile <= Tile.VROADPOWER)) && tile !== Tile.VROADPOWER && tile !== Tile.HRAILROAD && tile !== Tile.VBRIDGE) adjTile |= 8; + } + + this._worldEffects.setTile(x, y, RoadTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + return; + } + + if (tile >= Tile.LHRAIL && tile <= Tile.LVRAIL10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 1; + } + + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 2; + } + + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILHPOWERV && tile !== Tile.HRAILROAD && tile !== Tile.HRAIL) adjTile |= 4; + } + + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile >= Tile.RAILHPOWERV && tile <= Tile.VRAILROAD && tile !== Tile.RAILVPOWERH && tile !== Tile.VRAILROAD && tile !== Tile.VRAIL) adjTile |= 8; + } + this._worldEffects.setTile(x, y, RailTable[adjTile] | Tile.BULLBIT | Tile.BURNBIT); + return; + } + + if (tile >= Tile.LHPOWER && tile <= Tile.LVPOWER10) { + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 1; + } + } + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 2; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.VPOWER && tile !== Tile.VROADPOWER && tile !== Tile.RAILVPOWERH) adjTile |= 4; + } + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile !== Tile.HPOWER && tile !== Tile.HROADPOWER && tile !== Tile.RAILHPOWERV) adjTile |= 8; + } + } + this._worldEffects.setTile(x, y, WireTable[adjTile] | Tile.BLBNCNBIT); + return; + } + } + + checkZoneConnections ( x, y ) { + + this.fixSingle(x, y); + if (y > 0) this.fixSingle(x, y - 1); + if (x < this._map.width - 1) this.fixSingle(x + 1, y); + if (y < this._map.height - 1) this.fixSingle(x, y + 1); + if (x > 0) this.fixSingle(x - 1, y); + + } + + checkBorder ( x, y, size ) { + + // Adjust to top left tile + x = x - 1; + y = y - 1; + let i; + for (i = 0; i < size; i++) this.fixZone(x + i, y - 1); + for (i = 0; i < size; i++) this.fixZone(x - 1, y + i); + for (i = 0; i < size; i++) this.fixZone(x + i, y + size); + for (i = 0; i < size; i++) this.fixZone(x + size, y + i); + + } + +} diff --git a/games/3dcity/src/micro/tool/BuildingTool.js b/games/3dcity/src/micro/tool/BuildingTool.js new file mode 100644 index 0000000..cb14153 --- /dev/null +++ b/games/3dcity/src/micro/tool/BuildingTool.js @@ -0,0 +1,97 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseToolConnector } from './BaseToolConnector.js'; +import { Tile, ZoneUtils } from '../Tile.js'; + +export class BuildingTool extends BaseToolConnector { + + constructor ( cost, centreTile, map, size, animated ) { + + super() + this.init( cost, map, false ); + this.centreTile = centreTile; + this.size = size; + this.animated = animated; + + } + + putBuilding ( leftX, topY ) { + let posX, posY, tileValue, tileFlags; + let baseTile = this.centreTile - this.size - 1; + + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + + for ( let dx = 0; dx < this.size; dx++ ) { + posX = leftX + dx; + tileValue = baseTile; + tileFlags = Tile.BNCNBIT; + + if (dx === 1) { + if (dy === 1) tileFlags |= Tile.ZONEBIT; + else if (dy === 2 && this.animated) tileFlags |= Tile.ANIMBIT; + } + this._worldEffects.setTile(posX, posY, tileValue, tileFlags); + baseTile++; + } + } + } + + prepareBuildingSite ( leftX, topY ) { + // Check that the entire site is on the map + if (leftX < 0 || leftX + this.size > this._map.width) return this.TOOLRESULT_FAILED; + if (topY < 0 || topY + this.size > this._map.height) return this.TOOLRESULT_FAILED; + + let posX, posY, tileValue; + + // Check whether the tiles are clear + for (let dy = 0; dy < this.size; dy++) { + posY = topY + dy; + for (let dx = 0; dx < this.size; dx++) { + posX = leftX + dx; + tileValue = this._worldEffects.getTileValue(posX, posY); + + if (tileValue === Tile.DIRT) continue; + if (!this.autoBulldoze) { + // No Tile.DIRT and no bull-dozer => not buildable + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + + if (!ZoneUtils.canBulldoze(tileValue)) { + // tilevalue cannot be auto-bulldozed + return this.TOOLRESULT_NEEDS_BULLDOZE; + } + this._worldEffects.setTile(posX, posY, Tile.DIRT); + this.addCost(this.bulldozerCost); + } + } + return this.TOOLRESULT_OK; + } + + buildBuilding ( x, y ) { + // Correct to top left + x--; + y--; + + let prepareResult = this.prepareBuildingSite(x, y); + if (prepareResult !== this.TOOLRESULT_OK) return prepareResult; + + this.addCost(this.toolCost); + this.putBuilding(x, y); + this.checkBorder(x, y); + + return this.TOOLRESULT_OK; + } + + doTool ( x, y, blockMaps ) { + this.result = this.buildBuilding(x, y); + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/BulldozerTool.js b/games/3dcity/src/micro/tool/BulldozerTool.js new file mode 100644 index 0000000..e643898 --- /dev/null +++ b/games/3dcity/src/micro/tool/BulldozerTool.js @@ -0,0 +1,147 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseToolConnector } from './BaseToolConnector.js'; +import { Micro } from '../Micro.js'; +import { Tile, ZoneUtils } from '../Tile.js'; +import { Messages } from '../Messages.js'; + +import { math } from '../math/math.js'; + +export class BulldozerTool extends BaseToolConnector { + + constructor( map ) { + + super() + this.init(10, map, true); + + } + + + putRubble( x, y, size ) { + + for (let xx = x; xx < x + size; xx++) { + for (let yy = y; yy < y + size; yy++) { + if (this._map.testBounds(xx, yy)) { + let tile = this._worldEffects.getTile(xx, yy); + if (tile !== Tile.RADTILE && tile !== Tile.DIRT) { + if( Micro.haveMapAnimation ) this._worldEffects.setTile(xx, yy, Tile.TINYEXP + math.getRandom(2), Tile.ANIMBIT | Tile.BULLBIT ); + else this._map.setTo( xx, yy, ZoneUtils.randomRubble() ); + } + } + } + } + + } + + layDoze( x, y ) { + + let tile = this._worldEffects.getTile(x, y); + + if (!tile.isBulldozable()) return this.TOOLRESULT_FAILED; + + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.HBRIDGE: + case Tile.VBRIDGE: + case Tile.BRWV: + case Tile.BRWH: + case Tile.HBRDG0: + case Tile.HBRDG1: + case Tile.HBRDG2: + case Tile.HBRDG3: + case Tile.VBRDG0: + case Tile.VBRDG1: + case Tile.VBRDG2: + case Tile.VBRDG3: + case Tile.HPOWER: + case Tile.VPOWER: + case Tile.HRAIL: + case Tile.VRAIL: + this._worldEffects.setTile(x, y, Tile.RIVER); + break; + + default: this._worldEffects.setTile(x, y, Tile.DIRT); break; + } + + this.addCost(1); + return this.TOOLRESULT_OK; + + } + + doTool( x, y, blockMaps, messageManager ) { + + if (!this._map.testBounds(x, y)) this.result = this.TOOLRESULT_FAILED; + + let tile = this._worldEffects.getTile(x, y); + let tileValue = tile.getValue(); + + let zoneSize = 0; + let deltaX; + let deltaY; + + if (tile.isZone()) { + zoneSize = ZoneUtils.checkZoneSize(tileValue); + deltaX = 0; + deltaY = 0; + } else { + let result = ZoneUtils.checkBigZone(tileValue); + zoneSize = result.zoneSize; + deltaX = result.deltaX; + deltaY = result.deltaY; + } + + //console.log( zoneSize, deltaX, deltaY ) + + if (zoneSize > 0) { + + this.addCost(this.bulldozerCost); + + //this._map.powerData[ this._map.getId( x, y ) ] = 0; + + this._map.powered({ v:1, x:x, y:y }) + + let dozeX = x; + let dozeY = y; + let centerX = x + deltaX; + let centerY = y + deltaY; + + switch (zoneSize) { + case 3: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + this.putRubble(centerX - 1, centerY - 1, 3); + break; + case 4: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 4); + break; + case 6: + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONHIGH); + //messageManager.sendMessage(Messages.SOUND_EXPLOSIONLOW); + this.putRubble(centerX - 1, centerY - 1, 6); + break; + } + + this.result = this.TOOLRESULT_OK; + } + + let toolResult; + if (tileValue === Tile.RIVER || tileValue === Tile.REDGE || tileValue === Tile.CHANNEL) { + toolResult = this.layDoze(x, y); + if (tileValue !== this._worldEffects.getTileValue(x, y)) this.addCost(5); + } else { + toolResult = this.layDoze(x, y); + this.checkZoneConnections(x, y); + } + + this.result = toolResult; + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/ParkTool.js b/games/3dcity/src/micro/tool/ParkTool.js new file mode 100644 index 0000000..317bea5 --- /dev/null +++ b/games/3dcity/src/micro/tool/ParkTool.js @@ -0,0 +1,45 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseTool } from './BaseTool.js'; +import { Tile } from '../Tile.js'; +import { math } from '../math/math.js'; + +export class ParkTool extends BaseTool { + + constructor ( map ) { + + super() + this.init( 10, map, true ); + + } + + doTool ( x, y, blockMaps ) { + + if (this._worldEffects.getTileValue(x, y) !== Tile.DIRT) { + this.result = this.TOOLRESULT_NEEDS_BULLDOZE; + return; + } + let value = math.getRandom(4); + let tileFlags = Tile.BURNBIT | Tile.BULLBIT; + let tileValue; + + if (value === 4) { + tileValue = Tile.FOUNTAIN; + tileFlags |= Tile.ANIMBIT; + } else { + tileValue = value + Tile.WOODS2; + } + + this._worldEffects.setTile(x, y, tileValue, tileFlags); + this.addCost(10); + this.result = this.TOOLRESULT_OK; + + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/QueryTool.js b/games/3dcity/src/micro/tool/QueryTool.js new file mode 100644 index 0000000..ed0965b --- /dev/null +++ b/games/3dcity/src/micro/tool/QueryTool.js @@ -0,0 +1,150 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseTool } from './BaseTool.js'; +import { Tile } from '../Tile.js'; +import { Messages } from '../Messages.js'; +import { TXT } from '../Text.js'; + +// Keep in sync with QueryWindow +var debug = true; + +export class QueryTool extends BaseTool { + + constructor ( map ) { + + super() + this.init(0, map, false, false); + this.txt = ""; + + } + + classifyPopulationDensity (x, y, blockMaps) { + var density = blockMaps.populationDensityMap.worldGet(x, y); + //if (debug) document.getElementById("queryDensityRaw").innerHTML=density; + density = density >> 6; + density = density & 3; + + this.txt+='Density: '+TXT.densityStrings[density]+'
    '; + //document.getElementById("queryDensity").innerHTML=TXT.densityStrings[density]; + } + + classifyLandValue (x, y, blockMaps) { + var landValue = blockMaps.landValueMap.worldGet(x, y); + //if (debug) document.getElementById("queryLandValueRaw").innerHTML=landValue; + + var i = 0; + if (landValue >= 150) i = 3; + else if (landValue >= 80) i = 2; + else if (landValue >= 30) i = 1; + + //var text = TXT.landValueStrings[i]; + this.txt+='Value: '+TXT.landValueStrings[i]+'
    '; + //document.getElementById("queryLandValue").innerHTML=text; + } + + classifyCrime (x, y, blockMaps) { + var crime = blockMaps.crimeRateMap.worldGet(x, y); + //if (debug) document.getElementById("queryCrimeRaw").innerHTML=crime; + + crime = crime >> 6; + crime = crime & 3; + + this.txt+='Crime: '+TXT.crimeStrings[crime]+'
    '; + //document.getElementById("queryCrime").innerHTML=TXT.crimeStrings[crime]; + } + + classifyPollution (x, y, blockMaps) { + var pollution = blockMaps.pollutionDensityMap.worldGet(x, y); + //if (debug) document.getElementById("queryPollutionRaw").innerHTML=pollution; + pollution = pollution >> 6; + pollution = pollution & 3; + + this.txt+='Pollution: '+TXT.pollutionStrings[pollution]+'
    '; + //document.getElementById("queryPollution").innerHTML=TXT.pollutionStrings[pollution]; + } + + classifyRateOfGrowth (x, y, blockMaps) { + var rate = blockMaps.rateOfGrowthMap.worldGet(x, y); + //if (debug) document.getElementById("queryRateRaw").innerHTML=rate; + rate = rate >> 6; + rate = rate & 3; + + this.txt+='Growth: '+TXT.rateStrings[rate]; + //document.getElementById("queryRate").innerHTML=TXT.rateStrings[rate]; + } + + classifyDebug (x, y, blockMaps) { + if (!debug) return; + /*document.getElementById("queryFireStationRaw").innerHTML=blockMaps.fireStationMap.worldGet(x, y); + document.getElementById("queryFireStationEffectRaw").innerHTML=blockMaps.fireStationEffectMap.worldGet(x, y); + document.getElementById("queryPoliceStationRaw").innerHTML=blockMaps.policeStationMap.worldGet(x, y); + document.getElementById("queryPoliceStationEffectRaw").innerHTML=blockMaps.policeStationEffectMap.worldGet(x, y); + document.getElementById("queryTerrainDensityRaw").innerHTML=blockMaps.terrainDensityMap.worldGet(x, y); + document.getElementById("queryTrafficDensityRaw").innerHTML=blockMaps.trafficDensityMap.worldGet(x, y); + document.getElementById("queryComRateRaw").innerHTML=blockMaps.comRateMap.worldGet(x, y);*/ + } + + classifyZone (x, y) { + var baseTiles = [ + Tile.DIRT, Tile.RIVER, Tile.TREEBASE, Tile.RUBBLE, + Tile.FLOOD, Tile.RADTILE, Tile.FIRE, Tile.ROADBASE, + Tile.POWERBASE, Tile.RAILBASE, Tile.RESBASE, Tile.COMBASE, + Tile.INDBASE, Tile.PORTBASE, Tile.AIRPORTBASE, Tile.COALBASE, + Tile.FIRESTBASE, Tile.POLICESTBASE, Tile.STADIUMBASE, Tile.NUCLEARBASE, + Tile.HBRDG0, Tile.RADAR0, Tile.FOUNTAIN, Tile.INDBASE2, + Tile.FOOTBALLGAME1, Tile.VBRDG0, 952]; + + var tileValue = this._map.getTileValue(x, y); + if (tileValue >= Tile.COALSMOKE1 && tileValue < Tile.FOOTBALLGAME1) tileValue = Tile.COALBASE; + + var index = 0, l; + for (index = 0, l = baseTiles.length - 1; index < l; index++) { + if (tileValue < baseTiles[index + 1]) + break; + } + + this.txt='Zone: '+TXT.zoneTypes[index]+'
    '; + + //document.getElementById("queryZoneType").innerHTML=TXT.zoneTypes[index]; + } + + getInfo () { + return this.txt; + } + + doTool (x, y, blockMaps, messageManager) { + + var text = 'Position (' + x + ', ' + y + ')'; + text += ' TileValue: ' + this._map.getTileValue(x, y); + + if (debug) { + var tile = this._map.getTile(x, y); + /*document.getElementById("queryTile").innerHTML=[x,y].join(', '); + document.getElementById("queryTileValue").innerHTML=tile.getValue(); + document.getElementById("queryTileBurnable").innerHTML=tile.isCombustible(); + document.getElementById("queryTileBulldozable").innerHTML=tile.isBulldozable(); + document.getElementById("queryTileCond").innerHTML=tile.isConductive(); + document.getElementById("queryTileAnim").innerHTML=tile.isAnimated(); + document.getElementById("queryTilePowered").innerHTML=tile.isPowered();*/ + } + + this.classifyZone(x, y); + this.classifyPopulationDensity(x, y, blockMaps); + this.classifyLandValue(x, y, blockMaps); + this.classifyCrime(x, y, blockMaps); + this.classifyPollution(x, y, blockMaps); + this.classifyRateOfGrowth(x, y, blockMaps); + this.classifyDebug(x, y, blockMaps); + + messageManager.sendMessage(Messages.QUERY_WINDOW_NEEDED); + + this.result = this.TOOLRESULT_OK; + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/RailTool.js b/games/3dcity/src/micro/tool/RailTool.js new file mode 100644 index 0000000..7d6583f --- /dev/null +++ b/games/3dcity/src/micro/tool/RailTool.js @@ -0,0 +1,85 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseToolConnector } from './BaseToolConnector.js'; +import { Tile, ZoneUtils } from '../Tile.js'; + +export class RailTool extends BaseToolConnector { + + constructor ( map ) { + + super() + this.init(20, map, true, true); + + } + + layRail ( x, y ) { + + this.doAutoBulldoze(x, y); + let cost = this.toolCost; + let tile = this._worldEffects.getTileValue(x, y); + tile = ZoneUtils.normalizeRoad(tile); + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.LHRAIL | Tile.BULLBIT | Tile.BURNBIT); break; + + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + cost = 100; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || (tile >= Tile.LHRAIL && tile <= Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + break; + } + } + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILHPOWERV || tile == Tile.HRAIL || (tile > Tile.VRAIL && tile < Tile.VRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.HRAIL, Tile.BULLBIT); + break; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || (tile > Tile.HRAIL && tile < Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + break; + } + } + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + if (tile == Tile.RAILVPOWERH || tile == Tile.VRAILROAD || (tile > Tile.HRAIL && tile < Tile.HRAILROAD)) { + this._worldEffects.setTile(x, y, Tile.VRAIL, Tile.BULLBIT); + break; + } + } + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVPOWER: this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS: this._worldEffects.setTile(x, y, Tile.VRAILROAD, Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS2: this._worldEffects.setTile(x, y, Tile.HRAILROAD, Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + }; + + doTool (x, y, blockMaps) { + this.result = this.layRail(x, y); + } +} diff --git a/games/3dcity/src/micro/tool/RoadTool.js b/games/3dcity/src/micro/tool/RoadTool.js new file mode 100644 index 0000000..7c020a9 --- /dev/null +++ b/games/3dcity/src/micro/tool/RoadTool.js @@ -0,0 +1,89 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { BaseToolConnector } from './BaseToolConnector.js'; +import { Tile, ZoneUtils } from '../Tile.js'; + +export class RoadTool extends BaseToolConnector { + + constructor ( map ) { + + super() + this.init(10, map, true, true); + + } + + layRoad ( x, y ) { + + this.doAutoBulldoze(x, y); + let tile = this._worldEffects.getTileValue(x, y); + let cost = this.toolCost; + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.ROADS, Tile.BULLBIT | Tile.BURNBIT); break; + case Tile.RIVER: + case Tile.REDGE: + case Tile.CHANNEL: + + //console.log('is water') + cost = 50; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTileValue(x + 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || (tile >= Tile.ROADS && tile <= Tile.HROADPOWER)) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + break; + } + } + if (x > 0) { + tile = this._worldEffects.getTileValue(x - 1, y); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.VRAILROAD || tile === Tile.HBRIDGE || (tile >= Tile.ROADS && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.HBRIDGE, Tile.BULLBIT); + break; + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTileValue(x, y + 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || (tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + break; + } + } + if (y > 0) { + tile = this._worldEffects.getTileValue(x, y - 1); + tile = ZoneUtils.normalizeRoad(tile); + + if (tile === Tile.HRAILROAD || tile === Tile.VROADPOWER || (tile >= Tile.VBRIDGE && tile <= Tile.INTERSECTION)) { + this._worldEffects.setTile(x, y, Tile.VBRIDGE, Tile.BULLBIT); + break; + } + } + return this.TOOLRESULT_FAILED; + + case Tile.LHPOWER: this._worldEffects.setTile(x, y, Tile.VROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVPOWER: this._worldEffects.setTile(x, y, Tile.HROADPOWER | Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LHRAIL: this._worldEffects.setTile(x, y, Tile.HRAILROAD | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVRAIL: this._worldEffects.setTile(x, y, Tile.VRAILROAD | Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost(cost); + this.checkZoneConnections(x, y); + return this.TOOLRESULT_OK; + } + + doTool = function(x, y, blockMaps) { + this.result = this.layRoad(x, y); + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/WireTool.js b/games/3dcity/src/micro/tool/WireTool.js new file mode 100644 index 0000000..9542a4a --- /dev/null +++ b/games/3dcity/src/micro/tool/WireTool.js @@ -0,0 +1,96 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { BaseToolConnector } from './BaseToolConnector.js'; +import { Tile, ZoneUtils } from '../Tile.js'; + +export class WireTool extends BaseToolConnector { + + constructor ( map ) { + + super() + this.init( 5, map, true, true ); + + } + + layWire ( x, y ) { + + this.doAutoBulldoze( x, y ); + let cost = 5; + let tile = this._worldEffects.getTileValue( x, y ); + tile = ZoneUtils.normalizeRoad( tile ); + + switch (tile) { + case Tile.DIRT: this._worldEffects.setTile(x, y, Tile.LHPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.RIVER: case Tile.REDGE: case Tile.CHANNEL: + cost = 25; + if (x < this._map.width - 1) { + tile = this._worldEffects.getTile(x + 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (x > 0) { + tile = this._worldEffects.getTile(x - 1, y); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.HROADPOWER && tile != Tile.RAILHPOWERV && tile != Tile.HPOWER) { + this._worldEffects.setTile(x, y, Tile.VPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (y < this._map.height - 1) { + tile = this._worldEffects.getTile(x, y + 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + if (y > 0) { + tile = this._worldEffects.getTile(x, y - 1); + if (tile.isConductive()) { + tile = tile.getValue(); + tile = ZoneUtils.normalizeRoad(tile); + if (tile != Tile.VROADPOWER && tile != Tile.RAILVPOWERH && tile != Tile.VPOWER) { + this._worldEffects.setTile(x, y, Tile.HPOWER, Tile.CONDBIT | Tile.BULLBIT); + break; + } + } + } + return this.TOOLRESULT_FAILED; + + case Tile.ROADS: this._worldEffects.setTile(x, y, Tile.HROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.ROADS2: this._worldEffects.setTile(x, y, Tile.VROADPOWER, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LHRAIL: this._worldEffects.setTile(x, y, Tile.RAILHPOWERV, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + case Tile.LVRAIL: this._worldEffects.setTile(x, y, Tile.RAILVPOWERH, Tile.CONDBIT | Tile.BURNBIT | Tile.BULLBIT); break; + default: return this.TOOLRESULT_FAILED; + } + + this.addCost( cost ); + this.checkZoneConnections( x, y ); + return this.TOOLRESULT_OK; + + } + + doTool ( x, y, blockMaps ) { + + this.result = this.layWire( x, y ); + + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/tool/WorldEffects.js b/games/3dcity/src/micro/tool/WorldEffects.js new file mode 100644 index 0000000..0188f16 --- /dev/null +++ b/games/3dcity/src/micro/tool/WorldEffects.js @@ -0,0 +1,62 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Tiles } from '../Tile.js'; + + +export class WorldEffects { + + constructor ( map ) { + + this._map = map; + this._data = {}; + } + + toKey (x, y) { + return [x, y].join(','); + } + + fromKey (k) { + k = k.split(','); + return {x: k[0] - 0, y: k[1] - 0}; + } + + clear () { + this._data = []; + } + + getTile (x, y) { + let key = this.toKey(x, y); + let tile = this._data[key]; + if ( tile === undefined ) tile = this._map.getTile(x, y); + return tile; + } + + getTileValue (x, y) { + return this.getTile(x, y).getValue(); + } + + setTile ( x, y, value, flags ) { + + if (flags !== undefined && value.isTile ) throw new Error('Flags supplied with already defined tile'); + if (flags === undefined && !value.isTile ) value = new Tiles(value); + else if (flags !== undefined) value = new Tiles(value, flags); + let key = this.toKey( x, y ); + this._data[key] = value; + } + + apply () { + let keys = Object.keys(this._data); + for ( let i = 0, l = keys.length; i < l; i++ ) { + let coords = this.fromKey(keys[i]); + this._map.setTo( coords, this._data[keys[i]] ); + } + } + +}; \ No newline at end of file diff --git a/games/3dcity/src/micro/zone/Commercial.js b/games/3dcity/src/micro/zone/Commercial.js new file mode 100644 index 0000000..9947d13 --- /dev/null +++ b/games/3dcity/src/micro/zone/Commercial.js @@ -0,0 +1,137 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + + +export const Commercial = { + + registerHandlers: function( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isCommercialZone, Commercial.commercialFound ); + }, + + // Commercial tiles have 'populations' from 1 to 5, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + getZonePopulation: function(map, x, y, tileValue) { + //if (tileValue.isTile ) tileValue = new Tiles().getValue(); //COMCLEAR) + if (tileValue === Tile.COMCLR) return 0; + return Math.floor((tileValue - Tile.CZB) / 9) % 5 + 1; + + }, + + // Takes a map and coordinates, a population category in the range 1-5, a value category in the range 0-3, and places + // the appropriate industrial zone on the map + placeCommercial: function ( map, x, y, population, lpValue, zonePower ) { + var centreTile = ((lpValue * 5) + population) * 9 + Tile.CZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + + growZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + // landValueMap contains values in the range 0-250, representing the desirability of the land. + // Thus, after shifting, landValue will be in the range 0-7. + var landValue = blockMaps.landValueMap.worldGet(x, y); + landValue = landValue >> 5; + + if (population > landValue) return; + + // This zone is desirable, and seemingly not to crowded. Switch to the next category of zone. + if (population < 5) { + Commercial.placeCommercial(map, x, y, population, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function (map, x, y, blockMaps, populationCategory, lpCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) { + Commercial.placeCommercial(map, x, y, populationCategory - 2, lpCategory, zonePower); + } else { + ZoneUtils.putZone(map, x, y, Tile.COMCLR, zonePower); + } + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + + // Called by the map scanner when it finds the centre of an commercial zone + commercialFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + // lpValue will be filled if we actually decide to trigger growth/decay. It will be an index of the land/pollution + // value in the range 0-3 + var lpValue; + + // Notify the census + simData.census.comZonePop += 1; + + // Calculate the population level for this tile, and add to census + var tileValue = map.getTileValue(x, y); + var population = Commercial.getZonePopulation(map, x, y, tileValue); + simData.census.comPop += population; + + var zonePower = map.getTile(x, y).isPowered(); + + // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if consumers cannot reach the shops. + // Note in particular, we will never take this branch if the zone is empty. + var trafficOK = Micro.ROUTE_FOUND; + if (population > math.getRandom(5)) { + // Try to find a route from here to an industrial zone + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isIndustrial); + + // Trigger outward migration if not connected to road network + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } + + // Occasionally assess and perhaps modify the tile + if (math.getChance(7)) { + + var locationScore = trafficOK === Micro.NO_ROAD_FOUND ? -3000 : simData.blockMaps.cityCentreDistScoreMap.worldGet(x, y); + var zoneScore = simData.valves.comValve + locationScore; + + // Unpowered zones should of course be penalized + if (!zonePower) zoneScore = -500; + + // The commercial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5064 - 1564. (The comRateMap, which scores + // commercial neighbourhoods based on their distance from the city centre, has range -64 to 64). + + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24816. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.8% of them are above -24816, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 3% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + if (zonePower && zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + + // Again, given the above, zoneScore + 26380 must lie in the range 21316 - 27944. + // There is a 7.3% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 82.5% chance of the number being below 21316 thus never triggering this branch, which leaves a + // 10.1% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && (zoneScore + 26380) < math.getRandom16Signed()) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Commercial.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + } +} \ No newline at end of file diff --git a/games/3dcity/src/micro/zone/EmergencyServices.js b/games/3dcity/src/micro/zone/EmergencyServices.js new file mode 100644 index 0000000..f292d81 --- /dev/null +++ b/games/3dcity/src/micro/zone/EmergencyServices.js @@ -0,0 +1,47 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { Micro } from '../Micro.js'; +import { Tile } from '../Tile.js'; +import { Position } from '../math/Position.js'; + + +const handleService = function( censusStat, budgetEffect, blockMap ) { + + return function( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census[censusStat] += 1; + var effect = simData.budget[budgetEffect]; + var isPowered = map.getTile(x, y).isPowered(); + // Unpowered buildings are half as effective + if (!isPowered) effect = Math.floor(effect / 2); + + var pos = new Position(x, y); + var connectedToRoads = simData.traffic.findPerimeterRoad( pos ); + if (!connectedToRoads) effect = Math.floor(effect / 2); + + var currentEffect = simData.blockMaps[blockMap].worldGet(x, y); + currentEffect += effect; + simData.blockMaps[blockMap].worldSet(x, y, currentEffect); + } + +} + +export const EmergencyServices = { + + registerHandlers: function(mapScanner, repairManager) { + mapScanner.addAction(Tile.POLICESTATION, EmergencyServices.policeStationFound); + mapScanner.addAction(Tile.FIRESTATION, EmergencyServices.fireStationFound); + }, + + policeStationFound: handleService('policeStationPop', 'policeEffect', 'policeStationMap'), + fireStationFound: handleService('fireStationPop', 'fireEffect', 'fireStationMap') + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/zone/Industrial.js b/games/3dcity/src/micro/zone/Industrial.js new file mode 100644 index 0000000..aaff339 --- /dev/null +++ b/games/3dcity/src/micro/zone/Industrial.js @@ -0,0 +1,141 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + +const animated = [true, false, true, true, false, false, true, true]; +const xDelta = [-1, 0, 1, 0, 0, 0, 0, 1]; +const yDelta = [-1, 0, -1, -1, 0, 0, -1, -1]; + +export const Industrial = { + + registerHandlers: function(mapScanner, repairManager) { + mapScanner.addAction( ZoneUtils.isIndustrialZone, Industrial.industrialFound ); + }, + + // Industrial tiles have 'populations' from 1 to 4, + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + + getZonePopulation: function( map, x, y, tileValue ) { + + if (tileValue === Tile.INDCLR) return 0; + return Math.floor((tileValue - Tile.IZB) / 9) % 4 + 1; + + }, + + placeIndustrial: function(map, x, y, populationCategory, valueCategory, zonePower) { + var centreTile = ((valueCategory * 4) + populationCategory) * 9 + Tile.IZB; + ZoneUtils.putZone(map, x, y, centreTile, zonePower); + }, + + growZone: function(map, x, y, blockMaps, population, valueCategory, zonePower) { + // Switch to the next category of zone + if (population < 4) { + Industrial.placeIndustrial(map, x, y, population, valueCategory, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function(map, x, y, blockMaps, populationCategory, valueCategory, zonePower) { + // Note that we special case empty zones here, rather than having to check population value on every + // call to placeIndustrial (which we anticipate will be called more often) + if (populationCategory > 1) Industrial.placeIndustrial( map, x, y, populationCategory - 2, valueCategory, zonePower ); + else ZoneUtils.putZone(map, x, y, Tile.INDCLR, zonePower); + + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + }, + + + + // Takes a map and coordinates, the tile value of the centre of the zone, and a boolean indicating whether + // the zone has power, and sets or unsets the animation bit in the appropriate part of the zone + setAnimation: function(map, x, y, tileValue, isPowered) { + + if (tileValue < Tile.IZB) return; + // There are only 7 different types of populated industrial zones. + // As tileValue - IZB will never be 8x9 or more away from IZB, we + // can shift right by 3, and get the same effect as dividing by 9 + var i = (tileValue - Tile.IZB) >> 3; + + if (animated[i] && isPowered) { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.ASCBIT); + } else { + map.addTileFlags(x + xDelta[i], y + yDelta[i], Tile.BNCNBIT); + map.removeTileFlags(x + xDelta[i], y + yDelta[i], Tile.ANIMBIT); + } + }, + + industrialFound: function(map, x, y, simData) { + + if(!simData) simData = Micro.simData + + simData.census.indZonePop += 1; + + // Calculate the population level for this tile, and add to census + var tileValue = map.getTileValue(x, y); + var population = Industrial.getZonePopulation( map, x, y, tileValue ); + simData.census.indPop += population; + + // Set animation bit if appropriate + var zonePower = map.getTile(x, y).isPowered(); + if(!simData.is3D) Industrial.setAnimation( map, x, y, tileValue, zonePower ); + + // Occasionally check to see if the zone is connected to the transport network (the chance of this happening + // increases as the population increases). Growth naturally stalls if workers cannot reach the factories. + // Note in particular, we will never take this branch if the zone is empty. + var trafficOK = Micro.ROUTE_FOUND; + if (population > math.getRandom(5)) { + // Try to find a route from here to a residential zone + trafficOK = simData.traffic.makeTraffic( x, y, simData.blockMaps, ZoneUtils.isResidential ); + + // Trigger outward migration if not connected to road network (unless the zone is already empty) + if (trafficOK === Micro.NO_ROAD_FOUND) { + var newValue = math.getRandom16() & 1; + Industrial.degradeZone(map, x, y, simData.blockMaps, population, newValue, zonePower); + return; + } + } + + // Occasionally assess and perhaps modify the tile + if (math.getChance(7)) { + var zoneScore = simData.valves.indValve + (trafficOK === Micro.NO_ROAD_FOUND ? -1000 : 0); + + // Unpowered zones should of course be penalized + if (!zonePower) zoneScore = -500; + + // The industrial demand valve has range -1500 to 1500, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -3000 - 1500 + + // First: observe that if there are no roads we will never take this branch, as zoneScore will be <= -1000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -24880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 87.9% of them are above -24880, so nearly 88% of the time, we will never take this branch. + // Thus, there's approximately a 2.9% chance that the value will be in the range, and we *might* grow. + // This has the nice effect of not preventing an individual unit from growing even if overall demand has collapsed + // (the business itself might still be growing. + if (zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + Industrial.growZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + return; + } + + // Again, given the above, zoneScore + 26380 must lie in the range 23380 - 27880. + // There is a 7.4% chance of getRandom16() always yielding a number > 27880 which would take this branch. + // There is a 85.6% chance of the number being below 23380 thus never triggering this branch, which leaves a + // 9% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && (zoneScore + 26380) < math.getRandom16Signed()) + Industrial.degradeZone(map, x, y, simData.blockMaps, population, math.getRandom16() & 1, zonePower); + } + + } + +} diff --git a/games/3dcity/src/micro/zone/MiscTiles.js b/games/3dcity/src/micro/zone/MiscTiles.js new file mode 100644 index 0000000..eb77ed8 --- /dev/null +++ b/games/3dcity/src/micro/zone/MiscTiles.js @@ -0,0 +1,85 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. +* +* This code is released under the GNU GPL v3, with some additional terms. +* Please see the files LICENSE and COPYING for details. Alternatively, +* consult http://micropolisjs.graememcc.co.uk/LICENSE and +* http://micropolisjs.graememcc.co.uk/COPYING +* +*/ + +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + +const xDelta = [-1, 0, 1, 0 ]; +const yDelta = [ 0, -1, 0, 1 ]; + + + +export const MiscTiles = { + + registerHandlers: function( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isFire, MiscTiles.fireFound, true); + mapScanner.addAction(Tile.RADTILE, MiscTiles.radiationFound, true); + mapScanner.addAction(ZoneUtils.isFlood, MiscTiles.floodFound, true); + //mapScanner.addAction(ZoneUtils.isManualExplosion, MiscTiles.explosionFound, true); + }, + + fireFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.firePop += 1; + + if ((math.getRandom16() & 3) !== 0) return; + + let i, xTem, yTem, tile + + // Try to set neighbouring tiles on fire as well + for ( i = 0; i < 4; i++) { + if (math.getChance(7)) { + xTem = x + xDelta[i]; + yTem = y + yDelta[i]; + if (map.testBounds(xTem, yTem)) { + tile = map.getTile(x, y); + if (!tile.isCombustible()) continue; + if (tile.isZone()) { + // Neighbour is a ione and burnable + ZoneUtils.fireZone(map, x, y, simData.blockMaps); + // Industrial zones etc really go boom + if (tile.getValue() > Tile.IZB) simData.spriteManager.makeExplosionAt(x, y); + } + map.setTo( ZoneUtils.randomFire() ); + } + } + } + + // Compute likelyhood of fire running out of fuel + let rate = 10; // Likelyhood of extinguishing (bigger means less chance) + i = simData.blockMaps.fireStationEffectMap.worldGet(x, y); + + if (i > 100) rate = 1; + else if (i > 20) rate = 2; + else if (i > 0) rate = 3; + + // Decide whether to put out the fire. + if ( math.getRandom(rate) === 0 ) map.setTo( x, y, ZoneUtils.randomRubble() ); + }, + + radiationFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + if (math.getChance(4095)) map.setTile( x, y, Tile.DIRT, 0 ); + }, + + floodFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + simData.disasterManager.doFlood( x, y, simData.blockMaps ); + }, + + /*explosionFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + let tileValue = map.getTileValue(x, y); + map.setTo(x, y, ZoneUtils.randomRubble()); + return; + }*/ +}; diff --git a/games/3dcity/src/micro/zone/Residential.js b/games/3dcity/src/micro/zone/Residential.js new file mode 100644 index 0000000..3460ebd --- /dev/null +++ b/games/3dcity/src/micro/zone/Residential.js @@ -0,0 +1,295 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + +const freeZone = [0, 3, 6, 1, 4, 7, 2, 5, 8]; + +export const Residential = { + + registerHandlers: function ( mapScanner, repairManager ) { + mapScanner.addAction(ZoneUtils.isResidentialZone, Residential.residentialFound); + mapScanner.addAction(ZoneUtils.HOSPITAL, Residential.hospitalFound); + repairManager.addAction(Tile.HOSPITAL, 15, 3); + }, + + // Residential tiles have 'populations' of 16, 24, 32 or 40 + // and value from 0 to 3. The tiles are laid out in + // increasing order of land value, cycling through + // each population value + placeResidential: function ( map, x, y, population, lpValue, zonePower ) { + + let centreTile = ((lpValue * 4) + population) * 9 + Tile.RZB; + ZoneUtils.putZone( map, x, y, centreTile, zonePower ); + + }, + + // Look for housing in the adjacent 8 tiles + getFreeZonePopulation: function( map, x, y, tileValue ) { + + let count = 0, xx, yy; + for ( xx = x - 1; xx <= x + 1; xx++) { + for ( yy = y - 1; yy <= y + 1; yy++) { + if (xx === x && yy === y) continue; + tileValue = map.getTileValue(xx, yy); + if (tileValue >= Tile.LHTHR && tileValue <= Tile.HHTHR) count += 1; + } + } + return count; + }, + + getZonePopulation: function ( map, x, y, tileValue ) { + //if ( tileValue.isTile ) tileValue = new Tiles().getValue(); + if ( tileValue === Tile.FREEZ) return Residential.getFreeZonePopulation(map, x, y, tileValue); + let populationIndex = Math.floor((tileValue - Tile.RZB) / 9) % 4 + 1; + return populationIndex * 8 + 16; + }, + + // Assess a tile for suitability for a house. Prefer tiles near roads + evalLot: function( map, x, y ) { + + let xDelta = [0, 1, 0, -1]; + let yDelta = [-1, 0, 1, 0]; + + if (!map.testBounds(x, y)) return -1; + + let tileValue = map.getTileValue(x, y); + if (tileValue < Tile.RESBASE || tileValue > Tile.RESBASE + 8) return -1; + + let score = 1, i, edgeX, edgeY; + for ( i = 0; i < 4; i++) { + + edgeX = x + xDelta[i]; + edgeY = y + yDelta[i]; + if (edgeX < 0 || edgeX >= map.width || edgeY < 0 || edgeY >= map.height) continue; + tileValue = map.getTileValue(edgeX, edgeY); + if (tileValue !== Tile.DIRT && tileValue <= Tile.LASTROAD) score += 1; + } + return score; + + }, + + buildHouse: function ( map, x, y, lpValue ) { + + let best = 0; + let bestScore = 0; + + // Deliberately ordered so that the centre tile is at index 0 + let xDelta = [0, -1, 0, 1, -1, 1, -1, 0, 1]; + let yDelta = [0, -1, -1, -1, 0, 0, 1, 1, 1]; + + let i, xx, yy, score; + + for ( i = 0; i < 9; i++) { + xx = x + xDelta[i]; + yy = y + yDelta[i]; + score = Residential.evalLot(map, xx, yy); + if (score > bestScore) { + bestScore = score; + best = i; + } else if (score === bestScore && math.getChance(7)) { + // Ensures we don't always select the same position when we + // have a choice + best = i; + } + } + if (best > 0 && map.testBounds(x + xDelta[best], y + yDelta[best])) + map.setTile(x + xDelta[best], y + yDelta[best], Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT); + //map.setTo(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + //map.setTile(x + xDelta[best], y + yDelta[best], new Tiles(Tile.HOUSE + math.getRandom(2) + lpValue * 3, Tile.BLBNCNBIT)); + }, + + growZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + + let pollution = blockMaps.pollutionDensityMap.worldGet(x, y); + // Cough! Too polluted noone wants to move here! + if (pollution > 128) return; + + let tileValue = map.getTileValue(x, y); + + if (tileValue === Tile.FREEZ) { + if (population < 8) { + // Zone capacity not yet reached: build another house + Residential.buildHouse(map, x, y, lpValue); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 1); + } + else if (blockMaps.populationDensityMap.worldGet(x, y) > 64) { + // There is local demand for higher density housing + Residential.placeResidential(map, x, y, 0, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + + } + + return; + } + + if (population < 40) { + // Zone population not yet maxed out + Residential.placeResidential(map, x, y, Math.floor(population / 8) - 1, lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, 8); + } + }, + + degradeZone: function ( map, x, y, blockMaps, population, lpValue, zonePower ) { + let xx, yy; + if (population === 0) return; + + if (population > 16) { + // Degrade to a lower density block + Residential.placeResidential(map, x, y, Math.floor((population - 24) / 8), lpValue, zonePower); + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } + + if (population === 16) { + // Already at lowest density: degrade to 8 individual houses + map.setTo(x, y, new Tiles(Tile.FREEZ, Tile.BLBNCNBIT | Tile.ZONEBIT)); + + for (yy = y - 1; yy <= y + 1; yy++) { + for (xx = x - 1; xx <= x + 1; xx++) { + if (xx === x && yy === y) continue; + map.setTile(x, y, Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT); + //map.setTo(x, y, new Tiles(Tile.LHTHR + lpValue + math.getRandom(2), Tile.BLBNCNBIT)); + } + } + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -8); + return; + } + + // Already down to individual houses. Remove one + let i = 0; + ZoneUtils.incRateOfGrowth(blockMaps, x, y, -1); + + for (xx = x - 1; xx <= x + 1; xx++) { + for (yy = y - 1; yy <= y + 1; yy++) { + let currentValue = map.getTileValue(xx, yy); + if (currentValue >= Tile.LHTHR && currentValue <= Tile.HHTHR) { + // We've found a house. Replace it with the normal free zone tile + map.setTile(xx, yy, freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT); + //map.setTo(xx, yy, new Tiles(freeZone[i] + Tile.RESBASE, Tile.BLBNCNBIT)); + return; + } + i += 1; + } + } + }, + + // Returns a score for the zone in the range -3000 - 3000 + evalResidential: function ( blockMaps, x, y, traffic ) { + + if (traffic === Micro.NO_ROAD_FOUND) return -3000; + let landValue = blockMaps.landValueMap.worldGet(x, y); + landValue -= blockMaps.pollutionDensityMap.worldGet(x, y); + if (landValue < 0) landValue = 0; + else landValue = Math.min(landValue * 32, 6000); + return landValue - 3000; + + }, + + residentialFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + // If we choose to grow this zone, we will fill it with an index in the range 0-3 reflecting the land value and + // pollution scores (higher is better). This is then used to select the variant to build + let lpValue; + // Notify the census + simData.census.resZonePop += 1; + + // Also, notify the census of our population + let tileValue = map.getTileValue(x, y); + let population = Residential.getZonePopulation(map, x, y, tileValue); + simData.census.resPop += population; + + let zonePower = map.getTile(x, y).isPowered(); + + let trafficOK = Micro.ROUTE_FOUND; + + // Occasionally check to see if the zone is connected to the road network. The chance of this happening increases + // as the zone's population increases. Note: we will never execute this conditional if the zone is empty, as zero + // will never be be bigger than any of the values Random will generate + if (population > math.getRandom(35)) { + // Is there a route from this zone to a commercial zone? + trafficOK = simData.traffic.makeTraffic(x, y, simData.blockMaps, ZoneUtils.isCommercial); + + // If we're not connected to the road network, then going shopping will be a pain. Move out. + if (trafficOK === Micro.NO_ROAD_FOUND) { + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + } + + // Sometimes we will randomly choose to assess this block. However, always assess it if it's empty or contains only single houses. + if (tileValue === Tile.FREEZ || math.getChance(7)) { + // First, score the individual zone. This is a value in the range -3000 to 3000 + // Then take into account global demand for housing. + let locationScore = Residential.evalResidential(simData.blockMaps, x, y, trafficOK); + let zoneScore = simData.valves.resValve + locationScore; + + // Naturally unpowered zones should be penalized + if (!zonePower) zoneScore = -500; + // The residential demand valve has range -2000 to 2000, so taking into account the "no traffic" and + // "no power" modifiers above, zoneScore must lie in the range -5500 - 5000. + + // Now, observe that if there are no roads we will never take this branch, as zoneScore will equal -3000. + // Given the comment above about ranges for zoneScore, zoneScore - 26380, will be in the range -26729 to -20880. + // getRandom16() has a range of 65536 possible numbers, in the range -32768 to 32767. + // Of those, 9.2% will always be below zoneScore and hence will always take this branch and trigger zone growth. + // 81.8% of them are above -20880, so nearly 82% of the time, we will never take this branch. + // Thus, there's approximately a 9% chance that the value will be in the range, and we *might* grow. + //if (trafficOK && (zoneScore > -350) && ((zoneScore - 26380) > math.getRandom16Signed())) { + if (zoneScore > -350 && (zoneScore - 26380) > math.getRandom16Signed()) { + // If this zone is empty, and residential demand is strong, we might make a hospital + //if (population === 0 && ((math.getRandom16() & 3) === 0)) { + if (population === 0 && math.getChance(3)) { + Residential.makeHospital(map, x, y, simData, zonePower); + return; + } + // Get an index in the range 0-3 scoring the land desirability and pollution, and grow the zone to the next + // population rank + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.growZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + return; + } + // Again, given the above, zoneScore + 26380 must lie in the range 20880 - 26030. + // There is a 10.2% chance of getRandom16() always yielding a number > 27994 which would take this branch. + // There is a 89.7% chance of the number being below 20880 thus never triggering this branch, which leaves a + // 0.1% chance of this branch being conditional on zoneScore. + if (zoneScore < 350 && ((zoneScore + 26380) < math.getRandom16Signed())) { + // Get an index in the range 0-3 scoring the land desirability and pollution, and degrade to the next + // lower ranked zone + lpValue = ZoneUtils.getLandPollutionValue(simData.blockMaps, x, y); + Residential.degradeZone(map, x, y, simData.blockMaps, population, lpValue, zonePower); + } + } + }, + + makeHospital: function ( map, x, y, simData, zonePower ) { + if(!simData) simData = Micro.simData + // We only build a hospital if the population requires it + if (simData.census.needHospital > 0) { + ZoneUtils.putZone(map, x, y, Tile.HOSPITAL, zonePower); + simData.census.needHospital = 0; + return; + } + }, + + hospitalFound: function ( map, x, y, simData ) { + if(!simData) simData = Micro.simData + + simData.census.hospitalPop += 1; + // Degrade to an empty zone if a hospital is no longer sustainable + if (simData.census.needHospital === -1) { + if (math.getRandom(20) === 0) ZoneUtils.putZone(map, x, y, Tile.FREEZ, map.getTile(x, y).isPowered()); + } + } + +} diff --git a/games/3dcity/src/micro/zone/Road.js b/games/3dcity/src/micro/zone/Road.js new file mode 100644 index 0000000..9037f57 --- /dev/null +++ b/games/3dcity/src/micro/zone/Road.js @@ -0,0 +1,187 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + +const verticalDeltaX = [0, 1, 0, 0, 0, 0, 1]; +const verticalDeltaY = [-2, -2, -1, 0, 1, 2, 2]; +const horizontalDeltaX = [-2, 2, -2, -1, 0, 1, 2]; +const horizontalDeltaY = [ -1, -1, 0, 0, 0, 0, 0]; + +const openVertical = [ Tile.VBRDG0, Tile.VBRDG1, Tile.RIVER, Tile.BRWV, Tile.RIVER, Tile.VBRDG2, Tile.VBRDG3 ]; +const closeVertical = [ Tile.VBRIDGE, Tile.RIVER, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.VBRIDGE, Tile.RIVER ]; + +const openHorizontal = [ Tile.HBRDG1, Tile.HBRDG3, Tile.HBRDG0, Tile.RIVER, Tile.BRWH, Tile.RIVER, Tile.HBRDG2 ]; +const closeHorizontal = [ Tile.RIVER, Tile.RIVER, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE, Tile.HBRIDGE ]; +/* +const openVertical = [ + Tile.VBRDG0 | Tile.BULLBIT, Tile.VBRDG1 | Tile.BULLBIT, + Tile.RIVER, Tile.BRWV | Tile.BULLBIT, + Tile.RIVER, Tile.VBRDG2 | Tile.BULLBIT, Tile.VBRDG3 | Tile.BULLBIT +]; +const closeVertical = [ + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.VBRIDGE | Tile.BULLBIT, + Tile.VBRIDGE | Tile.BULLBIT, Tile.RIVER +]; +const openHorizontal = [ + Tile.HBRDG1 | Tile.BULLBIT, Tile.HBRDG3 | Tile.BULLBIT, + Tile.HBRDG0 | Tile.BULLBIT, Tile.RIVER, Tile.BRWH | Tile.BULLBIT, + Tile.RIVER, Tile.HBRDG2 | Tile.BULLBIT +]; +const closeHorizontal = [ + Tile.RIVER, Tile.RIVER, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT, + Tile.HBRIDGE | Tile.BULLBIT, Tile.HBRIDGE | Tile.BULLBIT +];*/ + +const densityTable = [Tile.ROADBASE, Tile.LTRFBASE, Tile.HTRFBASE]; + +export const Road = { + + registerHandlers: function ( mapScanner, repairManager ) { + + mapScanner.addAction( ZoneUtils.isRoad, Road.roadFound ); + + }, + + openBridge: function ( map, origX, origY, xDelta, yDelta, oldTiles, newTiles ) { + + let i, x, y; + + for ( i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + if (map.testBounds(x, y)) { + if (map.getTileValue(x, y) === (oldTiles[i] & Tile.BIT_MASK)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + + closeBridge: function ( map, origX, origY, xDelta, yDelta, oldTiles, newTiles ) { + + let i, x, y, tileValue; + + for ( i = 0; i < 7; i++) { + x = origX + xDelta[i]; + y = origY + yDelta[i]; + if (map.testBounds(x, y)) { + tileValue = map.getTileValue(x, y); + if (tileValue === Tile.CHANNEL || (tileValue & 15) === (oldTiles[i] & 15)) map.setTileValue(x, y, newTiles[i]); + } + } + }, + + doBridge: function ( map, x, y, currentTile, simData ) { + + //console.log( 'make bridge !!' ) + + if(!simData) simData = Micro.simData + + if (currentTile === Tile.BRWV) { + // We have an open vertical bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) + Road.closeBridge(map, x, y, verticalDeltaX, verticalDeltaY, openVertical, closeVertical); + return true; + } + if (currentTile == Tile.BRWH) { + // We have an open horizontal bridge. Possibly close it. + if (math.getChance(3) && simData.spriteManager.getBoatDistance(x, y) > 340) + Road.closeBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, openHorizontal, closeHorizontal); + return true; + } + if (simData.spriteManager.getBoatDistance(x, y) < 300 || math.getChance(7)) { + if (currentTile & 1) { + if (x < map.width - 1) { + if (map.getTileValue(x + 1, y) === Tile.CHANNEL) { + // We have a closed vertical bridge. Open it. + Road.openBridge(map, x, y, verticalDeltaX, verticalDeltaY, closeVertical, openVertical); + return true; + } + } + return false; + } else { + if (y > 0) { + if (map.getTileValue(x, y - 1) === Tile.CHANNEL) { + // We have a closed horizontal bridge. Open it. + Road.openBridge(map, x, y, horizontalDeltaX, horizontalDeltaY, closeHorizontal, openHorizontal); + return true; + } + } + } + } + return false; + }, + + roadFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.roadTotal += 1; + let currentTile = map.getTile(x, y); + let tileValue = currentTile.getValue(); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + //currentTile = map.getTile(x, y); + + // Don't degrade tiles with power lines + if (!currentTile.isConductive()) { + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + //let mapValue = currentTile.getValue(); + + // Replace bridge tiles with water, otherwise rubble + if ((tileValue & 15) < 2 || (tileValue & 15) === 15) map.setTile(x, y, Tile.RIVER); + else map.setTo(x, y, ZoneUtils.randomRubble()); + return; + } + } + } + } + + // Bridges are not combustible + if (!currentTile.isCombustible()) { + // The comment in the original Micropolis code states bridges count for 4 + // However, with the increment above, it's actually 5. Bug? + simData.census.roadTotal += 4; + //if ( Road.doBridge(map, x, y, tileValue, simData)) return; + } + + // Examine traffic density, and modify tile to represent last scanned traffic + // density + let density = 0; + if (tileValue < Tile.LTRFBASE) { + density = 0; + } else if (tileValue < Tile.HTRFBASE) { + density = 1; + } else { + // Heavy traffic counts as two tiles with regards to upkeep cost + // Note, if this is heavy traffic on a bridge, and it wasn't handled above, + // it actually counts for 7 road tiles + simData.census.roadTotal += 1; + density = 2; + } + + // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + let currentDensity = simData.blockMaps.trafficDensityMap.worldGet(x, y) >> 6; + // Force currentDensity in range 0-3 (trafficDensityMap values are capped at 240) + if (currentDensity > 1) currentDensity -= 1; + if (currentDensity === density) return; + + let newValue = ((tileValue - Tile.ROADBASE) & 15) + densityTable[currentDensity]; + // Preserve all bits except animation + let newFlags = currentTile.getFlags() & ~Tile.ANIMBIT; + if (currentDensity > 0) newFlags |= Tile.ANIMBIT; + + map.setTo(x, y, new Tiles(newValue, newFlags)); + + } +} diff --git a/games/3dcity/src/micro/zone/Stadia.js b/games/3dcity/src/micro/zone/Stadia.js new file mode 100644 index 0000000..0de6ae8 --- /dev/null +++ b/games/3dcity/src/micro/zone/Stadia.js @@ -0,0 +1,53 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ +import { Micro } from '../Micro.js'; +import { Tile, Tiles } from '../Tile.js'; + +export const Stadia = { + + registerHandlers: function( mapScanner, repairManager ) { + + mapScanner.addAction( Tile.STADIUM, Stadia.emptyStadiumFound ); + mapScanner.addAction( Tile.FULLSTADIUM, Stadia.fullStadiumFound ); + repairManager.addAction( Tile.STADIUM, 15, 4 ); + + }, + + emptyStadiumFound: function( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.stadiumPop += 1; + + if (map.getTile(x, y).isPowered()) { + // Occasionally start the big game + if (((simData.cityTime + x + y) & 31) === 0) { + map.putZone(x, y, Tile.FULLSTADIUM, 4); + map.addTileFlags(x, y, Tile.POWERBIT); + map.setTo(x + 1, y, new Tiles(Tile.FOOTBALLGAME1, Tile.ANIMBIT)); + map.setTo(x + 1, y + 1, new Tiles(Tile.FOOTBALLGAME2, Tile.ANIMBIT)); + } + } + }, + + fullStadiumFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.stadiumPop += 1; + let isPowered = map.getTile(x, y).isPowered(); + + if (((simData.cityTime + x + y) & 7) === 0) { + map.putZone(x, y, Tile.STADIUM, 4); + if ( isPowered ) map.addTileFlags( x, y, Tile.POWERBIT ); + } + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/micro/zone/Transport.js b/games/3dcity/src/micro/zone/Transport.js new file mode 100644 index 0000000..1945752 --- /dev/null +++ b/games/3dcity/src/micro/zone/Transport.js @@ -0,0 +1,83 @@ +/* micropolisJS. Adapted by Graeme McCutcheon from Micropolis. + * + * This code is released under the GNU GPL v3, with some additional terms. + * Please see the files LICENSE and COPYING for details. Alternatively, + * consult http://micropolisjs.graememcc.co.uk/LICENSE and + * http://micropolisjs.graememcc.co.uk/COPYING + * + */ + +import { Micro } from '../Micro.js'; +import { Tiles, Tile, ZoneUtils } from '../Tile.js'; +import { math } from '../math/math.js'; + + + + +export const Transport = { + + registerHandlers: function ( mapScanner, repairManager ) { + + mapScanner.addAction(ZoneUtils.isRail, Transport.railFound ); + mapScanner.addAction(Tile.PORT, Transport.portFound ); + mapScanner.addAction(Tile.AIRPORT, Transport.airportFound ); + + repairManager.addAction(Tile.PORT, 15, 4); + repairManager.addAction(Tile.AIRPORT, 7, 6); + + }, + + railFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.railTotal += 1; + simData.spriteManager.generateTrain(simData.census, x, y); + + if (simData.budget.shouldDegradeRoad()) { + if (math.getChance(511)) { + let currentTile = map.getTile(x, y); + + // Don't degrade tiles with power lines + if (currentTile.isConductive()) return; + + if (simData.budget.roadEffect < (math.getRandom16() & 31)) { + let mapValue = currentTile.getValue(); + + // Replace bridge tiles with water, otherwise rubble + if ( mapValue < Tile.RAILBASE + 2 ) map.setTile( x, y, Tile.RIVER, 0 ); + else map.setTo( x, y, ZoneUtils.randomRubble() ); + } + } + } + }, + + airportFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.airportPop += 1; + + let tile = map.getTile(x, y); + if (tile.isPowered()) { + if (map.getTileValue(x + 1, y - 1) === Tile.RADAR) map.setTile(x + 1, y - 1, Tile.RADAR0, Tile.CONDBIT | Tile.ANIMBIT | Tile.BURNBIT); + if (math.getRandom(5) === 0) { + simData.spriteManager.generatePlane(x, y); + return; + } + if (math.getRandom(12) === 0) simData.spriteManager.generateCopter(x, y); + } else { + map.setTile(x + 1, y - 1, Tile.RADAR, Tile.CONDBIT | Tile.BURNBIT); + } + }, + + portFound: function ( map, x, y, simData ) { + + if(!simData) simData = Micro.simData + + simData.census.seaportPop += 1; + let tile = map.getTile(x, y); + if (tile.isPowered() && simData.spriteManager.getSprite( Micro.SPRITE_SHIP ) === null) simData.spriteManager.generateShip(); + + } +} diff --git a/games/3dcity/src/saveAs.js b/games/3dcity/src/saveAs.js new file mode 100644 index 0000000..9826ff5 --- /dev/null +++ b/games/3dcity/src/saveAs.js @@ -0,0 +1,135 @@ +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ +export var saveAs = function(e) { + + "use strict"; + + if (typeof e === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { + return + } + var t = e.document, + n = function() { + return e.URL || e.webkitURL || e + }, + r = t.createElementNS("http://www.w3.org/1999/xhtml", "a"), + o = "download" in r, + a = function(e) { + var t = new MouseEvent("click"); + e.dispatchEvent(t) + }, + i = /constructor/i.test(e.HTMLElement) || e.safari, + f = /CriOS\/[\d]+/.test(navigator.userAgent), + u = function(t) { + (e.setImmediate || e.setTimeout)(function() { + throw t + }, 0) + }, + s = "application/octet-stream", + d = 1e3 * 40, + c = function(e) { + var t = function() { + if (typeof e === "string") { + n().revokeObjectURL(e) + } else { + e.remove() + } + }; + setTimeout(t, d) + }, + l = function(e, t, n) { + t = [].concat(t); + var r = t.length; + while (r--) { + var o = e["on" + t[r]]; + if (typeof o === "function") { + try { + o.call(e, n || e) + } catch (a) { + u(a) + } + } + } + }, + p = function(e) { + if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)) { + return new Blob([String.fromCharCode(65279), e], { + type: e.type + }) + } + return e + }, + v = function(t, u, d) { + if (!d) { + t = p(t) + } + var v = this, + w = t.type, + m = w === s, + y, h = function() { + l(v, "writestart progress write writeend".split(" ")) + }, + S = function() { + if ((f || m && i) && e.FileReader) { + var r = new FileReader; + r.onloadend = function() { + var t = f ? r.result : r.result.replace(/^data:[^;]*;/, "data:attachment/file;"); + var n = e.open(t, "_blank"); + if (!n) e.location.href = t; + t = undefined; + v.readyState = v.DONE; + h() + }; + r.readAsDataURL(t); + v.readyState = v.INIT; + return + } + if (!y) { + y = n().createObjectURL(t) + } + if (m) { + e.location.href = y + } else { + var o = e.open(y, "_blank"); + if (!o) { + e.location.href = y + } + } + v.readyState = v.DONE; + h(); + c(y) + }; + v.readyState = v.INIT; + if (o) { + y = n().createObjectURL(t); + setTimeout(function() { + r.href = y; + r.download = u; + a(r); + h(); + c(y); + v.readyState = v.DONE + }); + return + } + S() + }, + w = v.prototype, + m = function(e, t, n) { + return new v(e, t || e.name || "download", n) + }; + + if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { + return function(e, t, n) { + t = t || e.name || "download"; + if (!n) { e = p(e) } + return navigator.msSaveOrOpenBlob(e, t) + } + } + + w.abort = function() {}; + w.readyState = w.INIT = 0; + w.WRITING = 1; + w.DONE = 2; + w.error = w.onwritestart = w.onprogress = w.onwrite = w.onabort = w.onerror = w.onwriteend = null; + return m + +}(typeof self !== "undefined" && self || typeof window !== "undefined" && window ); \ No newline at end of file diff --git a/games/3dcity/src/traffic/Traffic.js b/games/3dcity/src/traffic/Traffic.js new file mode 100644 index 0000000..5af1451 --- /dev/null +++ b/games/3dcity/src/traffic/Traffic.js @@ -0,0 +1,251 @@ + +export { TrafficWorld } from './core/TrafficWorld.js'; + +const ctor = function(){}; +const breaker = {}; + +// Save bytes in the minified (but not gzipped) version: +const ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + +// Create quick reference variables for speed access to core prototypes. +const + push = ArrayProto.push, + slice = ArrayProto.slice, + concat = ArrayProto.concat, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; +const + nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeReduceRight = ArrayProto.reduceRight, + nativeFilter = ArrayProto.filter, + nativeEvery = ArrayProto.every, + nativeSome = ArrayProto.some, + nativeIndexOf = ArrayProto.indexOf, + nativeLastIndexOf = ArrayProto.lastIndexOf, + nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind; + + + +export const Traffic = { + + idCounter : 0, + + TMP: new Map(), + + STATE : [ { RED: 0, GREEN: 1 } ], + + TYPE_OF_CARS : [ + + { w:1.8, l:4.8, h:1.4, m:'car001', name:'fordM' , wPos:[0.76,0,1.46], wRadius:0.36, nWheels:4, maxSpeed:40 }, + { w:1.8, l:4.5, h:1.8, m:'car002', name:'vaz' , wPos:[0.72,0,1.31], wRadius:0.36, nWheels:4 }, + { w:2.2, l:5.0, h:1.5, m:'car003', name:'coupe' , wPos:[0.96,0,1.49], wRadius:0.36, nWheels:4 }, + { w:2.2, l:5.2, h:1.9, m:'car004', name:'c4' , wPos:[0.93,0,1.65], wRadius:0.40, nWheels:4 }, + { w:2.2, l:5.2, h:1.8, m:'car005', name:'ben' , wPos:[0.88,0,1.58], wRadius:0.40, nWheels:4 }, + { w:2.1, l:5.4, h:1.7, m:'car006', name:'taxi' , wPos:[0.90,0,1.49], wRadius:0.40, nWheels:4 }, + { w:2.2, l:5.4, h:1.9, m:'car007', name:'207' , wPos:[0.94,0,1.60], wRadius:0.40, nWheels:4 }, + { w:2.3, l:5.9, h:1.7, m:'car008', name:'police' , wPos:[0.96,0,1.67], wRadius:0.40, nWheels:4 }, + { w:2.7, l:6.2, h:2.6, m:'car009', name:'van1' , wPos:[1.14,0,1.95], wRadius:0.46, nWheels:4 }, + { w:2.2, l:6.6, h:2.8, m:'car010', name:'van2' , wPos:[0.89,0,2.10], wRadius:0.40, nWheels:4 }, + { w:2.8, l:7.0, h:3.2, m:'car011', name:'van3' , wPos:[0.90,0,1.83], wRadius:0.46, nWheels:4 }, + { w:2.8, l:8.9, h:3.9, m:'car012', name:'truck1' , wPos:[1.00,0,2.58], wRadius:0.57, nWheels:6, maxSpeed:20 }, + { w:3.0, l:10.6, h:3.4, m:'car013', name:'truck1', wPos:[1.17,0,3.64], wRadius:0.57, nWheels:6, maxSpeed:20 }, + { w:3.0, l:12.7, h:3.4, m:'car014', name:'bus' , wPos:[1.25,0,2.49], wRadius:0.64, nWheels:4, maxSpeed:10 }, + + ], + + settings : { + lightsFlipInterval: 160, + gridSize: 1, + carScale: 0.05, + carSpeed: 0.05, + defaultTimeFactor: 5, + }, + + abs : Math.abs, + sqrt : Math.sqrt, + atan2 : Math.atan2, + random : Math.random, + max : Math.max, + min : Math.min, + pow : Math.pow, + + rand : function( min, max ){ + + if ( !max ) { max = min; min = 0; } + return min + Math.floor(Math.random() * (max - min + 1)); + + }, + + clamp : function( value, min, max ) { + + if (value < min) return min; + if (value > max) return max; + return value; + + }, + + // + + binding : function( fn, me ){ + + return function(){ return fn.apply(me, arguments); }; + + }, + + bind : function( func, context ) { + + let args, bound; + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + //if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + let self = new ctor; + ctor.prototype = null; + let result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; + } + + }, + + indexOf : [].indexOf || function( item ) { for (let i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + + sample : function( obj, n, guard ){ + + if( n == null || guard ) { + if( obj.length !== +obj.length ) obj = Traffic.values(obj); + //if( obj.length !== obj.length+1 ) obj = Traffic.values(obj); + return obj[Traffic.rand(obj.length - 1)]; + } + return Traffic.shuffle(obj).slice(0, Math.max(0, n)); + + }, + + shuffle: function( obj ) { + + let rand, index = 0, shuffled = []; + Traffic.each(obj, function(value) { + rand = Traffic.rand(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + + }, + + uniqueId: function( prefix ) { + + let id = ++Traffic.idCounter + ''; + return prefix ? prefix + id : id; + + }, + + extend: function( obj ) { + + Traffic.each(slice.call(arguments, 1), function(source) { + if (source) { + for (let prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + + }, + + reduce: function( obj, iterator, memo, context ) { + + let initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = Traffic.bind(iterator, context); + return initial ? obj.reduce( iterator, memo ) : obj.reduce( iterator ); + } + Traffic.each( obj, function( value, index, list ) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + //if (!initial) throw new TypeError(reduceError); + return memo; + + }, + + each : function( obj, iterator, context ) { + + let i, length, keys + + if (obj == null) return obj; + if (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } else if (obj.length === +obj.length) { + i = obj.length + while(i--){ + if (iterator.call(context, obj[i], i, obj) === breaker) return; + } + } else { + keys = Traffic.keys(obj); + i = keys.length + while(i--){ + if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; + } + } + return obj; + + }, + + keys: function( obj ) { + + if (!Traffic.isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + let keys = []; + for (let key in obj) if (Traffic.has(obj, key)) keys.push(key); + return keys; + + }, + + isObject: function( obj ) { + return obj === Object(obj); + }, + + has: function( obj, key ) { + + return hasOwnProperty.call(obj, key); + + }, + + values: function( obj ) { + + let keys = Traffic.keys(obj); + let values = []; + let i = keys.length; + while(i--){ + values[i] = obj[keys[i]]; + } + return values; + + }, + + map: function( obj, iterator, context ){ + + let results = []; + if ( obj == null ) return results; + if ( nativeMap && obj.map === nativeMap ) return obj.map( iterator, context ); + Traffic.each(obj, function(value, index, list) { + results.push(iterator.call(context, value, index, list)); + }); + return results; + + } + +} + diff --git a/games/3dcity/src/traffic/core/Car.js b/games/3dcity/src/traffic/core/Car.js new file mode 100644 index 0000000..8ac3497 --- /dev/null +++ b/games/3dcity/src/traffic/core/Car.js @@ -0,0 +1,182 @@ +import { Traffic } from '../Traffic.js'; +import { Trajectory } from './Trajectory.js'; + + +export class Car { + + constructor( lane, position ) { + + this.type = Traffic.rand(Traffic.TYPE_OF_CARS.length-1); + + this.id = Traffic.uniqueId('car'); + this.color = (300 + 240 * Traffic.random() | 0) % 360; + this._speed = 0; + + this.width = Traffic.TYPE_OF_CARS[this.type].w*Traffic.settings.carScale; + this.length = Traffic.TYPE_OF_CARS[this.type].l*Traffic.settings.carScale; + this.maxSpeed = 30*Traffic.settings.carSpeed; + if( Traffic.TYPE_OF_CARS[this.type].maxSpeed ) this.maxSpeed = Traffic.TYPE_OF_CARS[this.type].maxSpeed*Traffic.settings.carSpeed; + // minimal space between two car !! + this.s0 = 2 * Traffic.settings.carScale; + // minimal space before intersection + this.s1 = 1 * Traffic.settings.carScale; + + this.timeHeadway = 1.5*Traffic.settings.carSpeed; + this.maxAcceleration = 1*Traffic.settings.carSpeed; + this.maxDeceleration = 3*Traffic.settings.carSpeed; + + this.mid = Traffic.settings.gridSize*0.5; + + this.trajectory = new Trajectory( this, lane, position ); + this.alive = true; + this.preferedLane = null; + + this.toLongStop = 0; + + } + + get pos() { + + let p = this.coords + return { x:p.x-this.mid, y:p.y-this.mid }; + + } + + get coords() { + + return this.trajectory.coords; + + } + + get speed() { + + return this._speed; + + } + + set speed( value ) { + + this._speed = Traffic.clamp( value, 0, this.maxSpeed ); + + } + + get direction() { + + return this.trajectory.direction; + + } + + release() { + + return this.trajectory.release(); + + } + + getAcceleration() { + + let a, b, breakGap, busyRoadCoeff, coeff, deltaSpeed, distanceGap, distanceToNextCar, freeRoadCoeff, intersectionCoeff, nextCarDistance, safeDistance, safeIntersectionDistance, timeGap, _ref; + nextCarDistance = this.trajectory.nextCarDistance; + distanceToNextCar = Traffic.max(nextCarDistance.distance, 0); + a = this.maxAcceleration; + b = this.maxDeceleration; + deltaSpeed = (this.speed - ((_ref = nextCarDistance.car) != null ? _ref.speed : void 0)) || 0; + freeRoadCoeff = Traffic.pow(this.speed / this.maxSpeed, 4); + distanceGap = this.s0; + timeGap = this.speed * this.timeHeadway; + breakGap = this.speed * deltaSpeed / (2 * Traffic.sqrt(a * b)); + safeDistance = (distanceGap + timeGap + breakGap); + busyRoadCoeff = Traffic.pow(safeDistance / distanceToNextCar, 2); + safeIntersectionDistance = this.s1 + timeGap + Traffic.pow(this.speed, 2) / (2 * b); + intersectionCoeff = Traffic.pow(safeIntersectionDistance / this.trajectory.distanceToStopLine, 2); + coeff = 1 - freeRoadCoeff - busyRoadCoeff - intersectionCoeff; + return this.maxAcceleration * coeff; + + } + + move( delta ) { + + let acceleration, currentLane, preferedLane, step, turnNumber; + acceleration = this.getAcceleration(); + this.speed += acceleration * delta; + if ( !this.trajectory.isChangingLanes && this.nextLane ) { + currentLane = this.trajectory.current.lane; + turnNumber = currentLane.getTurnDirection(this.nextLane); + + switch (turnNumber) { + case 0: preferedLane = currentLane.leftmostAdjacent; break; + case 2: preferedLane = currentLane.rightmostAdjacent; break; + default: preferedLane = currentLane; + } + + if ( preferedLane !== currentLane ) { + this.trajectory.changeLane(preferedLane); + } + } + step = this.speed * delta + 0.5 * acceleration * Traffic.pow(delta, 2); + // TODO: hacks, should have changed speed + if (this.trajectory.nextCarDistance.distance < step) { /*this.alive = false;*/ console.log('bad IDM');} + if (this.trajectory.timeToMakeTurn(step)) { + if (this.nextLane == null) return this.alive = false; + } + + + // bug with two car collision + if( this.trajectory.isChangingLanes ){ + if( step <= 0 ) this.toLongStop ++ + else this.toLongStop = 0; + if ( this.toLongStop > 1000 ){ console.log('car is locked !!'); this.alive = false; } + } + + // + + this.trajectory.moveForward( step ); + + } + + pickNextRoad() { + + let currentLane, intersection, possibleRoads; + intersection = this.trajectory.nextIntersection; + currentLane = this.trajectory.current.lane; + possibleRoads = intersection.roads.filter(function(x) { + return x.target !== currentLane.road.source; + }); + /*possibleRoads = Traffic.filter(function(x) { + return x.target !== currentLane.road.source; + }, intersection.roads);*/ + if (possibleRoads.length === 0) return null; + return Traffic.sample(possibleRoads); + + } + + pickNextLane() { + + let laneNumber, nextRoad, turnNumber; + if (this.nextLane) throw Error('next lane is already chosen'); + this.nextLane = null; + nextRoad = this.pickNextRoad(); + if (!nextRoad) return null; + turnNumber = this.trajectory.current.lane.road.getTurnDirection(nextRoad); + laneNumber = (function() { + switch (turnNumber) { + case 0: return nextRoad.lanesNumber - 1; break; + case 1: return Traffic.rand(0, nextRoad.lanesNumber - 1); break; + case 2: return 0; break; + } + })(); + this.nextLane = nextRoad.lanes[laneNumber]; + if (!this.nextLane) throw Error('can not pick next lane'); + return this.nextLane; + + } + + popNextLane() { + + let nextLane = this.nextLane; + this.nextLane = null; + this.preferedLane = null; + return nextLane; + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/ControlSignals.js b/games/3dcity/src/traffic/core/ControlSignals.js new file mode 100644 index 0000000..96b7104 --- /dev/null +++ b/games/3dcity/src/traffic/core/ControlSignals.js @@ -0,0 +1,86 @@ +import { Traffic } from '../Traffic.js'; + +export class ControlSignals { + + constructor ( intersection ) { + + this.intersection = intersection; + this.onTick = Traffic.binding(this.onTick, this); + this.flipMultiplier = Traffic.random(); + this.phaseOffset = 100 * Traffic.random(); + this.time = this.phaseOffset; + this.stateNum = 0; + this.states = [['L', '', 'L', ''], ['FR', '', 'FR', ''], ['', 'L', '', 'L'], ['', 'FR', '', 'FR']]; + + } + + get flipInterval() { + + return (0.1 + 0.05 * this.flipMultiplier) * Traffic.settings.lightsFlipInterval; + + } + + get state() { + + let i, len, results; + let stringState = this.states[this.stateNum % this.states.length]; + if (this.intersection.roads.length <= 2) { stringState = ['LFR', 'LFR', 'LFR', 'LFR']; } + results = []; + for (i = 0, len = stringState.length; i < len; i++) { + results.push( this._decode( stringState[i] ) ); + } + return results; + + } + + copy( controlSignals, intersection ) { + + var result; + if (controlSignals == null) { + return new ControlSignals(intersection); + } + result = Object.create(ControlSignals.prototype); + result.flipMultiplier = controlSignals.flipMultiplier; + result.time = result.phaseOffset = controlSignals.phaseOffset; + result.stateNum = 0; + result.intersection = intersection; + return result; + + } + + toJSON() { + + return { + flipMultiplier: this.flipMultiplier, + phaseOffset: this.phaseOffset + } + + } + + _decode(str) { + + let state = [0, 0, 0]; + if (Traffic.indexOf.call(str, 'L') >= 0) state[0] = 1; + if (Traffic.indexOf.call(str, 'F') >= 0) state[1] = 1; + if (Traffic.indexOf.call(str, 'R') >= 0) state[2] = 1; + return state; + + } + + flip() { + + this.stateNum += 1; + + } + + onTick( delta ) { + + this.time += delta; + if ( this.time > this.flipInterval ) { + this.flip(); + this.time -= this.flipInterval; + } + + } + +} diff --git a/games/3dcity/src/traffic/core/Intersection.js b/games/3dcity/src/traffic/core/Intersection.js new file mode 100644 index 0000000..368735b --- /dev/null +++ b/games/3dcity/src/traffic/core/Intersection.js @@ -0,0 +1,48 @@ +import { Traffic } from '../Traffic.js'; +import { ControlSignals } from './ControlSignals.js' +import { Rect } from '../geom/Rect.js' + +export class Intersection { + + constructor( rect ) { + + this.rect = rect; + this.key = this.rect.key() + this.id = Traffic.uniqueId('intersection'); + this.roads = []; + this.inRoads = []; + this.controlSignals = new ControlSignals( this ); + + } + + copy( intersection ) { + + this.rect = intersection.rect.clone(); + return this; + + /*var result; + intersection.rect = intersection.rect.clone() + result = Object.create( Intersection.prototype ); + Traffic.extend( result, intersection ); + result.roads = []; + result.inRoads = []; + result.controlSignals = new ControlSignals( result ); + return result;*/ + + } + + toJSON() { + + return { id: this.id, rect: this.rect }; + + } + + update() { + + let i, n =0; + for( i in this.roads ){ this.roads[i].update(); n++ } + for( i in this.inRoads ){ this.inRoads[i].update(); n++ } + console.log( 'update', n ) + + } +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/Lane.js b/games/3dcity/src/traffic/core/Lane.js new file mode 100644 index 0000000..58c10c9 --- /dev/null +++ b/games/3dcity/src/traffic/core/Lane.js @@ -0,0 +1,123 @@ +import { Traffic } from '../Traffic.js'; +import { Segment } from '../geom/Segment.js' + +export class Lane { + + constructor ( sourceSegment, targetSegment, road ) { + + this.sourceSegment = sourceSegment; + this.targetSegment = targetSegment; + this.road = road; + this.leftAdjacent = null; + this.rightAdjacent = null; + this.leftmostAdjacent = null; + this.rightmostAdjacent = null; + this.carsPositions = {}; + this.update(); + + } + + get sourceSideId() { + + return this.road.sourceSideId; + + } + + get targetSideId() { + + return this.road.targetSideId; + + } + + get isRightmost() { + + return this === this.rightmostAdjacent; + + } + + get isLeftmost() { + + return this === this.leftmostAdjacent; + + } + + get leftBorder() { + + return new Segment(this.sourceSegment.source, this.targetSegment.target); + + } + + get rightBorder() { + + return new Segment(this.sourceSegment.target, this.targetSegment.source); + + } + + toJSON( lane ) { + + var obj = Traffic.extend({}, this); + delete obj.carsPositions; + return obj; + + } + + update() { + + this.middleLine = new Segment( this.sourceSegment.center, this.targetSegment.center ); + this.length = this.middleLine.length; + this.direction = this.middleLine.direction; + + } + + getTurnDirection( other ) { + + return this.road.getTurnDirection(other.road); + + } + + getDirection() { + + return this.direction; + + } + + getPoint( a ) { + + return this.middleLine.getPoint( a ); + + } + + addCarPosition( carPosition ) { + + if (carPosition.id in this.carsPositions) throw Error('car is already here'); + this.carsPositions[carPosition.id] = carPosition; + + } + + removeCar( carPosition ) { + + if (!(carPosition.id in this.carsPositions)) throw Error('removing unknown car'); + delete this.carsPositions[carPosition.id]; + + } + + getNext( carPosition ) { + + let bestDistance, distance, id, next, o; + if (carPosition.lane !== this) throw Error('car is on other lane'); + next = null; + bestDistance = Infinity; + + for ( id in this.carsPositions ) { + o = this.carsPositions[id]; + distance = o.position - carPosition.position; + if (!o.free && (0 < distance && distance < bestDistance)) { + bestDistance = distance; + next = o; + } + } + return next; + + } + +} diff --git a/games/3dcity/src/traffic/core/LanePosition.js b/games/3dcity/src/traffic/core/LanePosition.js new file mode 100644 index 0000000..59cc5ea --- /dev/null +++ b/games/3dcity/src/traffic/core/LanePosition.js @@ -0,0 +1,73 @@ +import { Traffic } from '../Traffic.js'; + +export class LanePosition { + + constructor ( car, lane, position ) { + + this.car = car; + this.position = position; + this.id = Traffic.uniqueId('laneposition'); + this.free = true; + this._lane = lane; + + } + + get lane() { + + return this._lane; + + } + + set lane( value ) { + + this.release(); + this._lane = value; + + } + + get relativePosition() { + + return this.position / this.lane.length; + + } + + get nextCarDistance() { + + let frontPosition, next, rearPosition, result; + next = this.getNext(); + if( next ) { + rearPosition = next.position - next.car.length * 0.5; + frontPosition = this.position + this.car.length * 0.5; + return result = { car: next.car, distance: (rearPosition - frontPosition) }; + } + return result = { car: null, distance: Infinity }; + + } + + acquire() { + + let _ref; + if (((_ref = this.lane) != null ? _ref.addCarPosition : void 0) != null) { + this.free = false; + return this.lane.addCarPosition(this); + } + + } + + release() { + + let _ref; + if (!this.free && ((_ref = this.lane) != null ? _ref.removeCar : void 0)) { + this.free = true; + return this.lane.removeCar(this); + } + + } + + getNext() { + + if (this.lane && !this.free) return this.lane.getNext(this); + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/Pool.js b/games/3dcity/src/traffic/core/Pool.js new file mode 100644 index 0000000..34e8402 --- /dev/null +++ b/games/3dcity/src/traffic/core/Pool.js @@ -0,0 +1,53 @@ +export class Pool { + + constructor ( factory, pool ) { + + var k, v, _ref; + this.factory = factory; + this.objects = {}; + if ((pool != null) && (pool.objects != null)) { + _ref = pool.objects; + for (k in _ref) { + v = _ref[k]; + this.objects[k] = this.factory.copy(v); + } + } + + } + + get length() { + return Object.keys(this.objects).length; + } + + toJSON() { + return this.objects; + } + + get( id ) { + return this.objects[id]; + } + + put( obj ) { + return this.objects[obj.id] = obj; + } + + pop ( obj ) { + var id, result, _ref; + id = (_ref = obj.id) != null ? _ref : obj; + result = this.objects[id]; + if (typeof result.release === "function") { + result.release(); + } + delete this.objects[id]; + return result; + } + + all() { + return this.objects; + } + + clear() { + return this.objects = {}; + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/Road.js b/games/3dcity/src/traffic/core/Road.js new file mode 100644 index 0000000..a4a190e --- /dev/null +++ b/games/3dcity/src/traffic/core/Road.js @@ -0,0 +1,98 @@ +import { Traffic } from '../Traffic.js'; +import { Lane } from './Lane.js' + +export class Road { + + constructor ( source, target ) { + + this.source = source; + this.target = target; + this.id = Traffic.uniqueId('road'); + this.lanes = []; + this.lanesNumber = null; + this.update(); + + } + + get length() { + + return this.targetSide.target.subtract(this.sourceSide.source).length; + + } + + get leftmostLane() { + + return this.lanes[this.lanesNumber - 1]; + + } + + get rightmostLane() { + + return this.lanes[0]; + + } + + copy( road ) { + + let result; + result = Object.create(Road.prototype); + Traffic.extend.extend(result, road); + if (result.lanes == null) result.lanes = []; + return result; + + } + + toJSON() { + + return { id: this.id, source: this.source.id, target: this.target.id }; + + } + + getTurnDirection( other ) { + + let side1, side2, turnNumber; + if (this.target !== other.source) throw Error('invalid roads'); + side1 = this.targetSideId; + side2 = other.sourceSideId; + return turnNumber = (side2 - side1 - 1 + 8) % 4; + + } + + update() { + + let i, sourceSplits, targetSplits, _base, _i, _j, _ref, _ref1, _results; + if (!(this.source && this.target)) throw Error('incomplete road'); + this.sourceSideId = this.source.rect.getSectorId(this.target.rect.center()); + this.sourceSide = this.source.rect.getSide(this.sourceSideId).subsegment(0.5, 1.0); + this.targetSideId = this.target.rect.getSectorId(this.source.rect.center()); + this.targetSide = this.target.rect.getSide(this.targetSideId).subsegment(0, 0.5); + this.lanesNumber = Traffic.min(this.sourceSide.length, this.targetSide.length) | 0; + this.lanesNumber = Traffic.max(2, this.lanesNumber / Traffic.settings.gridSize | 0); + sourceSplits = this.sourceSide.split(this.lanesNumber, true); + targetSplits = this.targetSide.split(this.lanesNumber); + if ((this.lanes == null) || this.lanes.length < this.lanesNumber) { + if (this.lanes == null) this.lanes = []; + for (i = _i = 0, _ref = this.lanesNumber - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { + if ((_base = this.lanes)[i] == null) _base[i] = new Lane(sourceSplits[i], targetSplits[i], this); + } + } + _results = []; + for (i = _j = 0, _ref1 = this.lanesNumber - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) { + this.lanes[i].sourceSegment = sourceSplits[i]; + this.lanes[i].targetSegment = targetSplits[i]; + this.lanes[i].leftAdjacent = this.lanes[i + 1]; + this.lanes[i].rightAdjacent = this.lanes[i - 1]; + this.lanes[i].leftmostAdjacent = this.lanes[this.lanesNumber - 1]; + this.lanes[i].rightmostAdjacent = this.lanes[0]; + _results.push(this.lanes[i].update()); + } + + //this.source.update(); + //this.target.update(); + //return _results; + + //console.log( 'update road', _results.length ) + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/TrafficWorld.js b/games/3dcity/src/traffic/core/TrafficWorld.js new file mode 100644 index 0000000..91fe6c6 --- /dev/null +++ b/games/3dcity/src/traffic/core/TrafficWorld.js @@ -0,0 +1,292 @@ +import { Traffic } from '../Traffic.js'; +import { Pool } from './Pool.js'; +import { Intersection } from './Intersection.js'; +import { Road } from './Road.js'; +import { Car } from './Car.js'; +import { Rect } from '../geom/Rect.js'; +import { Point } from '../geom/Point.js'; + +export class TrafficWorld { + + constructor () { + + this.toRemove = []; + this.onTick = Traffic.bind(this.onTick, this); + this.minDistance = Traffic.settings.gridSize/5 + this.set(); + + } + + get instantSpeed() { + + let speeds = Traffic.map( this.cars.all(), function(car) { return car.speed; }); + if (speeds.length === 0) return 0; + return (Traffic.reduce(speeds, function(a, b) { return a + b; })) / speeds.length; + + } + + set( obj = {} ) { + + if (obj == null) obj = {}; + this.intersections = new Pool( Intersection, obj.intersections); + this.roads = new Pool( Road, obj.roads ); + this.cars = new Pool( Car, obj.cars ); + return this.carsNumber = 0; + + } + + save() { + + let data; + data = Traffic.extend({}, this); + delete data.cars; + return window.localStorage.world = JSON.stringify(data); + + } + + load() { + + let data, id, intersection, road, _ref, _ref1, _results; + data = window.localStorage.world; + data = data && JSON.parse(data); + if (data == null) return; + this.clear(); + this.carsNumber = data.carsNumber || 0; + _ref = data.intersections; + for (id in _ref) { + intersection = _ref[id]; + this.addIntersection( new Intersection().copy(intersection) ); + } + _ref1 = data.roads; + _results = []; + for (id in _ref1) { + road = _ref1[id]; + road = new Road().copy(road); + road.source = this.getIntersection(road.source); + road.target = this.getIntersection(road.target); + _results.push(this.addRoad(road)); + } + return _results; + + } + + generateMap( X = 2, Y = 2, linemax = 5 , mult = 0.8, nCars = 100, decal = {x:1, y:1} ) { + + let minX = 0; + let maxX = X*2; + let minY = 0; + let maxY = Y*2; + + /*let minX = -X; + let maxX = X; + let minY = -Y; + let maxY = Y;*/ + let gridSize, intersection, intersectionsNumber, map, previous, rect, step, x, y, _i, _j, _k, _l; + + this.clear(); + intersectionsNumber = (mult * (maxX - minX + 1) * (maxY - minY + 1)) | 0; + map = {}; + gridSize = Traffic.settings.gridSize; + step = linemax * gridSize; + this.carsNumber = nCars; + while ( intersectionsNumber > 0 ) { + x = Traffic.rand( minX, maxX ); + y = Traffic.rand( minY, maxY ); + if ( map[[x, y]] == null ) { + + intersection = this.addPoint( decal.x + (step * x), decal.y + (step * y) ) + //rect = new Rect( decal.x + (step * x), decal.y + (step * y), gridSize, gridSize ); + //intersection = new Intersection( rect ); + this.addIntersection( map[[x, y]] = intersection ); + intersectionsNumber -= 1; + } + } + for (x = _i = minX; minX <= maxX ? _i <= maxX : _i >= maxX; x = minX <= maxX ? ++_i : --_i) { + previous = null; + for (y = _j = minY; minY <= maxY ? _j <= maxY : _j >= maxY; y = minY <= maxY ? ++_j : --_j) { + intersection = map[[x, y]]; + if (intersection != null) { + if (Traffic.random() < 0.9) { + if (previous != null) this.addRoad( new Road(intersection, previous) ); + if (previous != null) this.addRoad( new Road(previous, intersection) ); + } + previous = intersection; + } + } + } + for (y = _k = minY; minY <= maxY ? _k <= maxY : _k >= maxY; y = minY <= maxY ? ++_k : --_k) { + previous = null; + for (x = _l = minX; minX <= maxX ? _l <= maxX : _l >= maxX; x = minX <= maxX ? ++_l : --_l) { + intersection = map[[x, y]]; + if (intersection != null) { + if (Traffic.random() < 0.9) { + if (previous != null) this.addRoad( new Road(intersection, previous) ); + if (previous != null) this.addRoad( new Road(previous, intersection) ); + } + previous = intersection; + } + } + } + return null; + } + + clear() { + + return this.set({}); + + } + + onTick( delta ) { + + + let p = [] + + let car, id, intersection, v, _ref, _ref1, _results, k, d, n=0; + if (delta > 1) throw Error('delta > 1'); + this.refreshCars(); + v = this.intersections.all(); + for ( id in v ) { + intersection = v[id]; + intersection.controlSignals.onTick(delta); + } + v = this.cars.all(); + //_results = []; + + for ( id in v ) { + car = v[id]; + car.move( delta ); + if ( !car.alive ) this.removeCar( car ) + } + + + + } + + // ________________TEST + + + roadFromTo( p1, p2 ) { + + let from = this.addPoint( p1.x, p1.y ) + let to = this.addPoint( p2.x, p2.y ) + this.addRoad( new Road(from, to) ); + + from.update(); + to.update(); + + } + + addPoint( x,y ) { + + let tmp = Traffic.TMP; + let key = [ x, y ].join(',') + + if( tmp.has( key ) ) return tmp.get( key ); + + let gridSize = Traffic.settings.gridSize; + let rect = new Rect( x, y, gridSize, gridSize ); + let intersection = new Intersection( rect ); + + tmp.set( key, intersection ) + this.intersections.put( intersection ); + + return intersection; + + } + + removePoint( intersection ) { + + let tmp = Traffic.TMP; + if( tmp.has( intersection.key ) ) return tmp.delete( intersection.key ); + return this.intersections.pop( intersection ); + + } + + + + + + refreshCars() { + + if (this.cars.length < this.carsNumber) this.addRandomCar(); + if (this.cars.length > this.carsNumber) return this.removeRandomCar(); + + } + + addRoad( road ) { + + this.roads.put(road); + road.source.roads.push(road); + road.target.inRoads.push(road); + return road.update(); + + } + + getRoad( id ) { + + return this.roads.get(id); + + } + + addCar( car ) { + + return this.cars.put(car); + + } + + getCar( id ) { + + return this.cars.get(id); + + } + + removeCar( car ) { + + this.toRemove.push(car.id); + this.cars.pop(car); + + } + + clearTmpRemove() { + + this.toRemove = []; + + } + + addIntersection( intersection ) { + + return this.intersections.put(intersection); + + } + + + + getIntersection( id ) { + + return this.intersections.get(id); + + } + + addRandomCar() { + + let lane, road; + road = Traffic.sample(this.roads.all()); + if (road != null) { + lane = Traffic.sample(road.lanes); + if (lane != null){ + //console.log('car add'); + return this.addCar( new Car(lane) ); + } + } + + } + + removeRandomCar() { + + let car; + car = Traffic.sample( this.cars.all() ); + if (car != null) return this.removeCar(car); + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/core/Trajectory.js b/games/3dcity/src/traffic/core/Trajectory.js new file mode 100644 index 0000000..3294d7b --- /dev/null +++ b/games/3dcity/src/traffic/core/Trajectory.js @@ -0,0 +1,218 @@ +import { Traffic } from '../Traffic.js'; +import { LanePosition } from './LanePosition.js' +import { Curve } from '../geom/Curve.js' + +export class Trajectory { + + constructor ( car, lane, position ) { + + this.car = car; + if (position == null) position = 0; + this.current = new LanePosition(this.car, lane, position); + this.current.acquire(); + this.next = new LanePosition(this.car); + this.temp = new LanePosition(this.car); + this.isChangingLanes = false; + + } + + get lane() { + + return this.temp.lane || this.current.lane; + + } + + get absolutePosition() { + + if (this.temp.lane != null) return this.temp.position; + else return this.current.position; + + } + + get relativePosition() { + + return this.absolutePosition / this.lane.length; + + } + + get direction() { + + return this.lane.getDirection(this.relativePosition); + + } + + get coords() { + + return this.lane.getPoint(this.relativePosition); + + } + + get nextCarDistance() { + + let a, b; + a = this.current.nextCarDistance; + b = this.next.nextCarDistance; + if (a.distance < b.distance) return a; + else return b; + + } + + get distanceToStopLine() { + + if (!this.canEnterIntersection()) return this.getDistanceToIntersection(); + return Infinity; + + } + + get nextIntersection() { + + return this.current.lane.road.target; + + } + + get previousIntersection() { + + return this.current.lane.road.source; + + } + + isValidTurn() { + + let nextLane, sourceLane, turnNumber; + nextLane = this.car.nextLane; + sourceLane = this.current.lane; + if (!nextLane) throw Error('no road to enter'); + turnNumber = sourceLane.getTurnDirection(nextLane); + if (turnNumber === 3) throw Error('no U-turns are allowed'); + if (turnNumber === 0 && !sourceLane.isLeftmost) throw Error('no left turns from this lane'); + if (turnNumber === 2 && !sourceLane.isRightmost) throw Error('no right turns from this lane'); + return true; + + } + + canEnterIntersection() { + + let intersection, nextLane, sideId, sourceLane, turnNumber; + nextLane = this.car.nextLane; + sourceLane = this.current.lane; + if (!nextLane) return true; + intersection = this.nextIntersection; + turnNumber = sourceLane.getTurnDirection(nextLane); + sideId = sourceLane.road.targetSideId; + return intersection.controlSignals.state[sideId][turnNumber]; + + } + + getDistanceToIntersection() { + + let distance; + distance = this.current.lane.length - (this.car.length * 0.5) - this.current.position; + if (!this.isChangingLanes) return Traffic.max(distance, 0); + else return Infinity; + + } + + timeToMakeTurn( plannedStep = 0 ) { + + return this.getDistanceToIntersection() <= plannedStep; + + } + + moveForward( distance ) { + + let gap, tempRelativePosition, _ref, _ref1; + distance = Traffic.max(distance, 0); + this.current.position += distance; + this.next.position += distance; + this.temp.position += distance; + if (this.timeToMakeTurn() && this.canEnterIntersection() && this.isValidTurn()) this._startChangingLanes(this.car.popNextLane(), 0); + + tempRelativePosition = this.temp.position / ((_ref = this.temp.lane) != null ? _ref.length : void 0); + gap = 2 * this.car.length; + if (this.isChangingLanes && this.temp.position > gap && !this.current.free) this.current.release(); + + if (this.isChangingLanes && this.next.free && this.temp.position + gap > ((_ref1 = this.temp.lane) != null ? _ref1.length : void 0)) this.next.acquire(); + if (this.isChangingLanes && tempRelativePosition >= 1) this._finishChangingLanes(); + if (this.current.lane && !this.isChangingLanes && !this.car.nextLane) return this.car.pickNextLane(); + + } + + changeLane( nextLane ) { + + let nextPosition; + if (this.isChangingLanes) throw Error('already changing lane'); + if (nextLane == null) throw Error('no next lane'); + if (nextLane === this.lane) throw Error('next lane == current lane'); + if (this.lane.road !== nextLane.road) throw Error('not neighbouring lanes'); + nextPosition = this.current.position + 3 * this.car.length; + //nextPosition = this.current.position + 3 * this.car.length; + //if (!(nextPosition < this.lane.length)) throw Error('too late to change lane'); + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position + 2 * this.car.length; + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position + 1 * this.car.length; + if (!(nextPosition < this.lane.length)) nextPosition = this.current.position; + return this._startChangingLanes(nextLane, nextPosition); + + } + + _getIntersectionLaneChangeCurve() { + + } + + _getAdjacentLaneChangeCurve() { + + let control1, control2, direction1, direction2, distance, p1, p2; + p1 = this.current.lane.getPoint(this.current.relativePosition); + p2 = this.next.lane.getPoint(this.next.relativePosition); + distance = p2.subtract(p1).length; + direction1 = this.current.lane.middleLine.vector.normalized.mult(distance * 0.3); + control1 = p1.add(direction1); + direction2 = this.next.lane.middleLine.vector.normalized.mult(distance * 0.3); + control2 = p2.subtract(direction2); + return new Curve(p1, p2, control1, control2); + + } + + _getCurve() { + + return this._getAdjacentLaneChangeCurve(); + + } + + _startChangingLanes( nextLane, nextPosition ) { + + if (this.isChangingLanes) throw Error('already changing lane'); + if (nextLane == null) throw Error('no next lane'); + this.isChangingLanes = true; + this.next.lane = nextLane; + this.next.position = nextPosition; + this.temp.lane = this._getCurve(); + this.temp.position = 0; + return this.next.position -= this.temp.lane.length; + + } + + _finishChangingLanes() { + + if (!this.isChangingLanes) throw Error('no lane changing is going on'); + this.isChangingLanes = false; + this.current.lane = this.next.lane; + this.current.position = this.next.position || 0; + this.current.acquire(); + this.next.lane = null; + this.next.position = NaN; + this.temp.lane = null; + this.temp.position = NaN; + return this.current.lane; + + } + + release() { + + let _ref, _ref1, _ref2; + if ((_ref = this.current) != null) _ref.release(); + if ((_ref1 = this.next) != null) _ref1.release(); + return (_ref2 = this.temp) != null ? _ref2.release() : void 0; + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/geom/Curve.js b/games/3dcity/src/traffic/geom/Curve.js new file mode 100644 index 0000000..21d630f --- /dev/null +++ b/games/3dcity/src/traffic/geom/Curve.js @@ -0,0 +1,57 @@ + +import { Segment } from './Segment.js'; + +export class Curve { + + constructor ( _at_A, _at_B, _at_O, _at_Q ) { + + this.A = _at_A; + this.B = _at_B; + this.O = _at_O; + this.Q = _at_Q; + this.AB = new Segment(this.A, this.B); + this.AO = new Segment(this.A, this.O); + this.OQ = new Segment(this.O, this.Q); + this.QB = new Segment(this.Q, this.B); + this._length = null; + + } + + get length (){ + + let i, point, pointsNumber, prevPoint, _i; + if( this._length == null ) { + pointsNumber = 10; + prevPoint = null; + this._length = 0; + for (i = _i = 0; 0 <= pointsNumber ? _i <= pointsNumber : _i >= pointsNumber; i = 0 <= pointsNumber ? ++_i : --_i) { + point = this.getPoint(i / pointsNumber); + if( prevPoint ) this._length += point.subtract( prevPoint ).length; + prevPoint = point; + } + } + return this._length; + + } + + getPoint ( a ) { + let p0, p1, p2, r0, r1; + p0 = this.AO.getPoint(a); + p1 = this.OQ.getPoint(a); + p2 = this.QB.getPoint(a); + r0 = (new Segment(p0, p1)).getPoint(a); + r1 = (new Segment(p1, p2)).getPoint(a); + return (new Segment(r0, r1)).getPoint(a); + } + + getDirection ( a ) { + let p0, p1, p2, r0, r1; + p0 = this.AO.getPoint(a); + p1 = this.OQ.getPoint(a); + p2 = this.QB.getPoint(a); + r0 = (new Segment(p0, p1)).getPoint(a); + r1 = (new Segment(p1, p2)).getPoint(a); + return (new Segment(r0, r1)).direction; + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/geom/Point.js b/games/3dcity/src/traffic/geom/Point.js new file mode 100644 index 0000000..5d6380c --- /dev/null +++ b/games/3dcity/src/traffic/geom/Point.js @@ -0,0 +1,75 @@ +import { Traffic } from '../Traffic.js'; + + +export class Point { + + constructor( x = 0, y = 0 ) { + + this.x = x; + this.y = y; + + } + + get length() { + + return Traffic.sqrt(this.x * this.x + this.y * this.y); + + } + + get direction() { + + return Traffic.atan2(this.y, this.x); + + } + + get normalized() { + + return new this.constructor(this.x / this.length, this.y / this.length); + + } + + toKey(){ + + return [this.x, this.y].join(','); + + } + + add( o ) { + + return new this.constructor(this.x + o.x, this.y + o.y); + + } + + subtract( o ) { + + return new this.constructor(this.x - o.x, this.y - o.y); + + } + + mult( k ) { + + return new this.constructor(this.x * k, this.y * k); + + } + + divide( k ) { + + return new this.constructor(this.x / k, this.y / k); + + } + + distanceTo( v ) { + + return Traffic.sqrt( this.distanceToSquared( v ) ); + + } + + distanceToSquared( v ) { + + const dx = this.x - v.x, dy = this.y - v.y; + return dx * dx + dy * dy; + + } + + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/geom/Rect.js b/games/3dcity/src/traffic/geom/Rect.js new file mode 100644 index 0000000..828cf0e --- /dev/null +++ b/games/3dcity/src/traffic/geom/Rect.js @@ -0,0 +1,161 @@ + +import { Traffic } from '../Traffic.js'; +import { Point } from './Point.js'; +import { Segment } from './Segment.js'; + +export class Rect { + + constructor( x = 0, y = 0, width = 0, height = 0 ) { + + this.x = x; + this.y = y; + this._width = width; + this._height = height; + + } + + copy( v ) { + + this.x = v.x; + this.y = v.y; + this._width = v._width; + this._height = v._height; + return this; + + } + + clone() { + + return new this.constructor( this.x, this.y, this._width, this._height ); + + } + + toJSON() { + + return Traffic.extend({}, this); + + } + + key(){ + + return [this.x, this.y].join(','); + + } + + area() { + + return this.width() * this.height(); + + } + + left( left ) { + + if( left != null ) this.x = left; + return this.x; + + } + + right( right ) { + + if( right != null ) this.x = right - this.width(); + return this.x + this.width(); + + } + + width( width ) { + + if( width != null ) this._width = width; + return this._width; + + } + + top( top ) { + + if (top != null) this.y = top; + return this.y; + + } + + bottom( bottom ) { + + if( bottom != null ) this.y = bottom - this.height(); + return this.y + this.height(); + + } + + height( height ) { + + if (height != null) this._height = height; + return this._height; + + } + + pos() { + + return new Point( this.x, this.y ); + + } + + center( center ) { + + if (center != null) { + this.x = center.x - this.width() * 0.5; + this.y = center.y - this.height() * 0.5; + } + return new Point( this.x + this.width() * 0.5, this.y + this.height() * 0.5 ); + + } + + containsPoint( point ) { + + return (this.left() <= point.x && point.x <= this.right()) && (this.top() <= point.y && point.y <= this.bottom()) + + } + + containsRect( rect ) { + + return this.left() <= rect.left() && rect.right() <= this.right() && this.top() <= rect.top() && rect.bottom() <= this.bottom(); + + } + + getVertices() { + + return [ + new Point(this.left(), this.top()), + new Point(this.right(), this.top()), + new Point(this.right(), this.bottom()), + new Point(this.left(), this.bottom()) + ]; + + } + + getSide( i ) { + + let vertices = this.getVertices(); + return new Segment(vertices[i], vertices[(i + 1) % 4]); + + } + + getSectorId( point ) { + + let offset = point.subtract( this.center() ); + if (offset.y <= 0 && Traffic.abs(offset.x) <= Traffic.abs(offset.y)) return 0; + if (offset.x >= 0 && Traffic.abs(offset.x) >= Traffic.abs(offset.y)) return 1; + if (offset.y >= 0 && Traffic.abs(offset.x) <= Traffic.abs(offset.y)) return 2; + if (offset.x <= 0 && Traffic.abs(offset.x) >= Traffic.abs(offset.y)) return 3; + + /* if (offset.y <= 0 && (offset.x) <= (offset.y)) return 0; + if (offset.x >= 0 && (offset.x) >= (offset.y)) return 1; + if (offset.y >= 0 && (offset.x) <= (offset.y)) return 2; + if (offset.x <= 0 && (offset.x) >= (offset.y)) return 3;*/ + throw Error('algorithm error'); + + } + + getSector( point ) { + + return this.getSide(this.getSectorId(point)); + + } + +} \ No newline at end of file diff --git a/games/3dcity/src/traffic/geom/Segment.js b/games/3dcity/src/traffic/geom/Segment.js new file mode 100644 index 0000000..830c421 --- /dev/null +++ b/games/3dcity/src/traffic/geom/Segment.js @@ -0,0 +1,59 @@ +export class Segment { + + constructor( source, target ) { + + this.source = source; + this.target = target; + + } + + get vector() { + + return this.target.subtract( this.source ); + + } + + get length() { + + return this.vector.length; + + } + + get direction() { + + return this.vector.direction; + + } + + get center() { + + return this.getPoint(0.5); + + } + + split( n, reverse ) { + + let result = [], order = [], i = n; + while( i-- ) order.push(i) + if( !reverse ) order = order.reverse(); + for( let k in order ) result.push( this.subsegment(order[k] / n, (order[k] + 1) / n) ) + return result + + } + + getPoint( a ) { + + return this.source.add( this.vector.mult(a) ); + + } + + subsegment( a, b ) { + + let offset = this.vector; + let start = this.source.add( offset.mult(a) ); + let end = this.source.add( offset.mult(b) ); + return new Segment(start, end); + + } + +} \ No newline at end of file diff --git a/games/3dcity/utils/Main_rollup.config.js b/games/3dcity/utils/Main_rollup.config.js new file mode 100644 index 0000000..840ced1 --- /dev/null +++ b/games/3dcity/utils/Main_rollup.config.js @@ -0,0 +1,119 @@ +import babel from '@rollup/plugin-babel'; +import { terser } from 'rollup-plugin-terser'; + +/*export default [ + { + input: 'src/Uil.js', + plugins: [ + buble( { + transforms: { + arrow: false, + classes: true + } + } ) + ], + output: [ + { + format: 'umd', + name: 'UIL', + file: 'build/uil.js', + indent: '\t' + } + ] + }, + { + input: 'src/Uil.js', + plugins: [ + ], + output: [ + { + format: 'esm', + file: 'build/uil.module.js', + indent: '\t' + } + ] + } +];*/ + +function babelCleanup() { + + const doubleSpaces = / {2}/g; + + return { + + transform( code ) { + + code = code.replace( doubleSpaces, '\t' ); + + return { + code: code, + map: null + }; + + } + + }; + +} + + +function header() { + + return { + + renderChunk( code ) { + + return `/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +${ code }`; + + } + + }; + +} + + + +const babelrc = { + presets: [ + [ + '@babel/preset-env', + { + modules: false, + // the supported browsers of the three.js browser bundle + // https://browsersl.ist/?q=%3E0.3%25%2C+not+dead + targets: '>1%', + loose: true, + bugfixes: true, + } + ] + ], + plugins: [ + [ + "@babel/plugin-proposal-class-properties", + { + "loose": true + } + ] + ] +}; + +export default [ + { + input: 'src/Main.js', + plugins: [ + header() + ], + output: [ + { + format: 'esm', + file: 'build/MainGame.module.js' + } + ] + } + +]; \ No newline at end of file diff --git a/games/3dcity/utils/rollup.config.js b/games/3dcity/utils/rollup.config.js new file mode 100644 index 0000000..489d576 --- /dev/null +++ b/games/3dcity/utils/rollup.config.js @@ -0,0 +1,160 @@ +import babel from '@rollup/plugin-babel'; +import { terser } from 'rollup-plugin-terser'; + +/*export default [ + { + input: 'src/Uil.js', + plugins: [ + buble( { + transforms: { + arrow: false, + classes: true + } + } ) + ], + output: [ + { + format: 'umd', + name: 'UIL', + file: 'build/uil.js', + indent: '\t' + } + ] + }, + { + input: 'src/Uil.js', + plugins: [ + ], + output: [ + { + format: 'esm', + file: 'build/uil.module.js', + indent: '\t' + } + ] + } +];*/ + +function babelCleanup() { + + const doubleSpaces = / {2}/g; + + return { + + transform( code ) { + + code = code.replace( doubleSpaces, '\t' ); + + return { + code: code, + map: null + }; + + } + + }; + +} + + +function header() { + + return { + + renderChunk( code ) { + + return `/** + * @license + * Copyright 2010-2022 3d.City.js Authors + * SPDX-License-Identifier: MIT + */ +${ code }`; + + } + + }; + +} + + + +const babelrc = { + presets: [ + [ + '@babel/preset-env', + { + modules: false, + // the supported browsers of the three.js browser bundle + // https://browsersl.ist/?q=%3E0.3%25%2C+not+dead + targets: '>1%', + loose: true, + bugfixes: true, + } + ] + ], + plugins: [ + [ + "@babel/plugin-proposal-class-properties", + { + "loose": true + } + ] + ] +}; + +export default [ + { + input: 'src/micro/CityGame.js', + plugins: [ + header() + ], + output: [ + { + format: 'esm', + file: 'build/citygame.module.js' + } + ] + }, + { + input: 'src/micro/CityGame.js', + plugins: [ + babel( { + babelHelpers: 'bundled', + compact: false, + babelrc: false, + ...babelrc + } ), + babelCleanup(), + header() + ], + output: [ + { + format: 'umd', + name: 'city', + file: 'build/citygame.js', + indent: '\t' + } + ] + }, + { + input: 'src/micro/CityGame.js', + plugins: [ + babel( { + babelHelpers: 'bundled', + babelrc: false, + ...babelrc + } ), + babelCleanup(), + terser(), + header() + ], + output: [ + { + format: 'umd', + name: 'city', + file: 'build/citygame.min.js' + } + ] + } + +]; \ No newline at end of file diff --git a/games/clumsyBird/build/clumsy-min.js b/games/clumsyBird/build/clumsy-min.js new file mode 100644 index 0000000..cbc1169 --- /dev/null +++ b/games/clumsyBird/build/clumsy-min.js @@ -0,0 +1 @@ +var game={data:{score:0,steps:0,start:!1,newHiScore:!1,muted:!1},resources:[{name:"bg",type:"image",src:"data/img/bg.png"},{name:"clumsy",type:"image",src:"data/img/clumsy.png"},{name:"pipe",type:"image",src:"data/img/pipe.png"},{name:"logo",type:"image",src:"data/img/logo.png"},{name:"ground",type:"image",src:"data/img/ground.png"},{name:"gameover",type:"image",src:"data/img/gameover.png"},{name:"gameoverbg",type:"image",src:"data/img/gameoverbg.png"},{name:"hit",type:"image",src:"data/img/hit.png"},{name:"getready",type:"image",src:"data/img/getready.png"},{name:"new",type:"image",src:"data/img/new.png"},{name:"share",type:"image",src:"data/img/share.png"},{name:"tweet",type:"image",src:"data/img/tweet.png"},{name:"theme",type:"audio",src:"data/bgm/"},{name:"hit",type:"audio",src:"data/sfx/"},{name:"lose",type:"audio",src:"data/sfx/"},{name:"wing",type:"audio",src:"data/sfx/"}],onload:function(){return me.video.init(900,600,{wrapper:"screen",scale:"auto",scaleMethod:"fit"})?(me.audio.init("mp3,ogg"),void me.loader.preload(game.resources,this.loaded.bind(this))):void alert("Your browser does not support HTML5 canvas.")},loaded:function(){me.state.set(me.state.MENU,new game.TitleScreen),me.state.set(me.state.PLAY,new game.PlayScreen),me.state.set(me.state.GAME_OVER,new game.GameOverScreen),me.input.bindKey(me.input.KEY.SPACE,"fly",!0),me.input.bindKey(me.input.KEY.M,"mute",!0),me.input.bindPointer(me.input.KEY.SPACE),me.pool.register("clumsy",game.BirdEntity),me.pool.register("pipe",game.PipeEntity,!0),me.pool.register("hit",game.HitEntity,!0),me.pool.register("ground",game.Ground,!0),me.state.change(me.state.MENU)}};game.BirdEntity=me.Entity.extend({init:function(a,b){var c={};c.image="clumsy",c.width=85,c.height=60,this._super(me.Entity,"init",[a,b,c]),this.alwaysUpdate=!0,this.body.gravity=.2,this.maxAngleRotation=Number.prototype.degToRad(-30),this.maxAngleRotationDown=Number.prototype.degToRad(35),this.renderable.addAnimation("flying",[0,1,2]),this.renderable.addAnimation("idle",[0]),this.renderable.setCurrentAnimation("flying"),this.body.removeShapeAt(0),this.body.addShape(new me.Ellipse(5,5,71,51)),this.flyTween=new me.Tween(this.pos),this.flyTween.easing(me.Tween.Easing.Exponential.InOut),this.currentAngle=0,this.angleTween=new me.Tween(this),this.angleTween.easing(me.Tween.Easing.Exponential.InOut),this.endTween=null,this.collided=!1,this.gravityForce=.2},update:function(a){var b=this;if(this.pos.x=60,!game.data.start)return this._super(me.Entity,"update",[a]);if(this.renderable.currentTransform.identity(),me.input.isKeyPressed("fly")){me.audio.play("wing"),this.gravityForce=.2;var c=this.pos.y;this.angleTween.stop(),this.flyTween.stop(),this.flyTween.to({y:c-72},50),this.flyTween.start(),this.angleTween.to({currentAngle:b.maxAngleRotation},50).onComplete(function(a){b.renderable.currentTransform.rotate(b.maxAngleRotation)}),this.angleTween.start()}else this.gravityForce+=.2,this.pos.y+=me.timer.tick*this.gravityForce,this.currentAngle+=Number.prototype.degToRad(3),this.currentAngle>=this.maxAngleRotationDown&&(this.renderable.currentTransform.identity(),this.currentAngle=this.maxAngleRotationDown);this.renderable.currentTransform.rotate(this.currentAngle),me.Rect.prototype.updateBounds.apply(this);var d=-80;return this.pos.y<=d||this.collided?(game.data.start=!1,me.audio.play("lose"),this.endAnimation(),!1):(me.collision.check(this),!0)},onCollision:function(a){var b=a.b;("pipe"===b.type||"ground"===b.type)&&(me.device.vibrate(500),this.collided=!0),"hit"===b.type&&(me.game.world.removeChildNow(b),game.data.steps++,me.audio.play("hit"))},endAnimation:function(){me.game.viewport.fadeOut("#fff",100);var a=this.pos.y;this.endTween=new me.Tween(this.pos),this.endTween.easing(me.Tween.Easing.Exponential.InOut),this.flyTween.stop(),this.renderable.currentTransform.identity(),this.renderable.currentTransform.rotate(Number.prototype.degToRad(90));var b=me.game.viewport.height-this.renderable.width/2-96;this.endTween.to({y:a},1e3).to({y:b},1e3).onComplete(function(){me.state.change(me.state.GAME_OVER)}),this.endTween.start()}}),game.PipeEntity=me.Entity.extend({init:function(a,b){var c={};c.image=this.image=me.loader.getImage("pipe"),c.width=148,c.height=1664,c.framewidth=148,c.frameheight=1664,this._super(me.Entity,"init",[a,b,c]),this.alwaysUpdate=!0,this.body.gravity=0,this.body.vel.set(-5,0),this.type="pipe"},update:function(a){return game.data.start?(this.pos.add(this.body.vel),this.pos.x<-this.image.width&&me.game.world.removeChild(this),me.Rect.prototype.updateBounds.apply(this),this._super(me.Entity,"update",[a]),!0):this._super(me.Entity,"update",[a])}}),game.PipeGenerator=me.Renderable.extend({init:function(){this._super(me.Renderable,"init",[0,me.game.viewport.width,me.game.viewport.height,92]),this.alwaysUpdate=!0,this.generate=0,this.pipeFrequency=92,this.pipeHoleSize=1240,this.posX=me.game.viewport.width},update:function(a){if(this.generate++%this.pipeFrequency==0){var b=Number.prototype.random(me.video.renderer.getHeight()-100,200),c=b-me.game.viewport.height-this.pipeHoleSize,d=new me.pool.pull("pipe",this.posX,b),e=new me.pool.pull("pipe",this.posX,c),f=b-100,g=new me.pool.pull("hit",this.posX,f);d.renderable.currentTransform.scaleY(-1),me.game.world.addChild(d,10),me.game.world.addChild(e,10),me.game.world.addChild(g,11)}this._super(me.Entity,"update",[a])}}),game.HitEntity=me.Entity.extend({init:function(a,b){var c={};c.image=this.image=me.loader.getImage("hit"),c.width=148,c.height=60,c.framewidth=148,c.frameheight=60,this._super(me.Entity,"init",[a,b,c]),this.alwaysUpdate=!0,this.body.gravity=0,this.updateTime=!1,this.renderable.alpha=0,this.body.accel.set(-5,0),this.body.removeShapeAt(0),this.body.addShape(new me.Rect(0,0,c.width-30,c.height-30)),this.type="hit"},update:function(a){return this.pos.add(this.body.accel),this.pos.x<-this.image.width&&me.game.world.removeChild(this),me.Rect.prototype.updateBounds.apply(this),this._super(me.Entity,"update",[a]),!0}}),game.Ground=me.Entity.extend({init:function(a,b){var c={};c.image=me.loader.getImage("ground"),c.width=900,c.height=96,this._super(me.Entity,"init",[a,b,c]),this.alwaysUpdate=!0,this.body.gravity=0,this.body.vel.set(-4,0),this.type="ground"},update:function(a){return this.pos.add(this.body.vel),this.pos.x<-this.renderable.width&&(this.pos.x=me.video.renderer.getWidth()-10),me.Rect.prototype.updateBounds.apply(this),this._super(me.Entity,"update",[a])}}),game.HUD=game.HUD||{},game.HUD.Container=me.Container.extend({init:function(){this._super(me.Container,"init"),this.isPersistent=!0,this.collidable=!1,this.z=1/0,this.name="HUD",this.addChild(new game.HUD.ScoreItem(5,5))}}),game.HUD.ScoreItem=me.Renderable.extend({init:function(a,b){this._super(me.Renderable,"init",[a,b,10,10]),this.stepsFont=new me.Font("gamefont",80,"#000","center"),this.floating=!0},draw:function(a){game.data.start&&me.state.isCurrent(me.state.PLAY)&&this.stepsFont.draw(a,game.data.steps,me.game.viewport.width/2,10)}});var BackgroundLayer=me.ImageLayer.extend({init:function(a,b,c){var d={};d.name=a,d.width=900,d.height=600,d.image=a,d.z=b,d.ratio=1,this._super(me.ImageLayer,"init",[0,0,d])},update:function(){return me.input.isKeyPressed("mute")&&(game.data.muted=!game.data.muted,game.data.muted?me.audio.disable():me.audio.enable()),!0}});game.TitleScreen=me.ScreenObject.extend({init:function(){this._super(me.ScreenObject,"init"),this.font=null,this.ground1=null,this.ground2=null,this.logo=null},onResetEvent:function(){me.audio.stop("theme"),game.data.newHiScore=!1,me.game.world.addChild(new BackgroundLayer("bg",1)),me.input.bindKey(me.input.KEY.ENTER,"enter",!0),me.input.bindKey(me.input.KEY.SPACE,"enter",!0),me.input.bindPointer(me.input.pointer.LEFT,me.input.KEY.ENTER),this.handler=me.event.subscribe(me.event.KEYDOWN,function(a,b,c){"enter"===a&&me.state.change(me.state.PLAY)}),this.logo=new me.Sprite(me.game.viewport.width/2,me.game.viewport.height/2-20,{image:"logo"}),me.game.world.addChild(this.logo,10);me.pool.pull("me.Tween",this.logo.pos).to({y:me.game.viewport.height/2-100},1e3).easing(me.Tween.Easing.Exponential.InOut).start();this.ground1=me.pool.pull("ground",0,me.video.renderer.getHeight()-96),this.ground2=me.pool.pull("ground",me.video.renderer.getWidth(),me.video.renderer.getHeight()-96),me.game.world.addChild(this.ground1,11),me.game.world.addChild(this.ground2,11),me.game.world.addChild(new(me.Renderable.extend({init:function(){this._super(me.Renderable,"init",[0,0,100,100]),this.text=me.device.touch?"Tap to start":'PRESS SPACE OR CLICK LEFT MOUSE BUTTON TO START \n PRESS "M" TO MUTE SOUND',this.font=new me.Font("gamefont",20,"#000")},draw:function(a){var b=this.font.measureText(a,this.text),c=me.game.viewport.width/2-b.width/2,d=me.game.viewport.height/2+50;this.font.draw(a,this.text,c,d)}})),12)},onDestroyEvent:function(){me.event.unsubscribe(this.handler),me.input.unbindKey(me.input.KEY.ENTER),me.input.unbindKey(me.input.KEY.SPACE),me.input.unbindPointer(me.input.pointer.LEFT),this.ground1=null,this.ground2=null,me.game.world.removeChild(this.logo),this.logo=null}}),game.PlayScreen=me.ScreenObject.extend({init:function(){me.audio.play("theme",!0);var a=-1!==me.device.ua.indexOf("Firefox")?.3:.5;me.audio.setVolume(a),this._super(me.ScreenObject,"init")},onResetEvent:function(){me.game.reset(),me.audio.stop("theme"),game.data.muted||me.audio.play("theme",!0),me.input.bindKey(me.input.KEY.SPACE,"fly",!0),game.data.score=0,game.data.steps=0,game.data.start=!1,game.data.newHiscore=!1,me.game.world.addChild(new BackgroundLayer("bg",1)),this.ground1=me.pool.pull("ground",0,me.game.viewport.height-96),this.ground2=me.pool.pull("ground",me.game.viewport.width,me.game.viewport.height-96),me.game.world.addChild(this.ground1,11),me.game.world.addChild(this.ground2,11),this.HUD=new game.HUD.Container,me.game.world.addChild(this.HUD,11),this.bird=me.pool.pull("clumsy",60,me.game.viewport.height/2-100),me.game.world.addChild(this.bird,10),me.input.bindPointer(me.input.pointer.LEFT,me.input.KEY.SPACE),this.getReady=new me.Sprite(me.game.viewport.width/2,me.game.viewport.height/2,{image:"getready"}),me.game.world.addChild(this.getReady,11);var a=this;new me.Tween(this.getReady).to({alpha:0},2e3).easing(me.Tween.Easing.Linear.None).onComplete(function(){game.data.start=!0,me.game.world.addChild(new game.PipeGenerator,0),me.game.world.removeChild(a.getReady)}).start()},onDestroyEvent:function(){me.audio.stopTrack("theme"),this.HUD=null,this.bird=null,this.ground1=null,this.ground2=null,me.input.unbindKey(me.input.KEY.SPACE),me.input.unbindPointer(me.input.pointer.LEFT)}}),game.GameOverScreen=me.ScreenObject.extend({init:function(){this.savedData=null,this.handler=null},onResetEvent:function(){this.savedData={score:game.data.score,steps:game.data.steps},me.save.add(this.savedData),me.save.topSteps||me.save.add({topSteps:game.data.steps}),game.data.steps>me.save.topSteps&&(me.save.topSteps=game.data.steps,game.data.newHiScore=!0),me.input.bindKey(me.input.KEY.ENTER,"enter",!0),me.input.bindKey(me.input.KEY.SPACE,"enter",!1),me.input.bindPointer(me.input.pointer.LEFT,me.input.KEY.ENTER),this.handler=me.event.subscribe(me.event.KEYDOWN,function(a,b,c){"enter"===a&&me.state.change(me.state.MENU)}),me.game.world.addChild(new me.Sprite(me.game.viewport.width/2,me.game.viewport.height/2-100,{image:"gameover"}),12);var a=new me.Sprite(me.game.viewport.width/2,me.game.viewport.height/2,{image:"gameoverbg"});if(me.game.world.addChild(a,10),me.game.world.addChild(new BackgroundLayer("bg",1)),this.ground1=me.pool.pull("ground",0,me.game.viewport.height-96),this.ground2=me.pool.pull("ground",me.game.viewport.width,me.video.renderer.getHeight()-96),me.game.world.addChild(this.ground1,11),me.game.world.addChild(this.ground2,11),game.data.newHiScore){var b=new me.Sprite(a.width/2,a.height/2,{image:"new"});me.game.world.addChild(b,12)}this.dialog=new(me.Renderable.extend({init:function(){this._super(me.Renderable,"init",[0,0,me.game.viewport.width/2,me.game.viewport.height/2]),this.font=new me.Font("gamefont",40,"black","left"),this.steps="Steps: "+game.data.steps.toString(),this.topSteps="Higher Step: "+me.save.topSteps.toString()},draw:function(a){var b=this.font.measureText(a,this.steps);this.font.measureText(a,this.topSteps),this.font.measureText(a,this.score);this.font.draw(a,this.steps,me.game.viewport.width/2-b.width/2-60,me.game.viewport.height/2),this.font.draw(a,this.topSteps,me.game.viewport.width/2-b.width/2-60,me.game.viewport.height/2+50)}})),me.game.world.addChild(this.dialog,12)},onDestroyEvent:function(){me.event.unsubscribe(this.handler),me.input.unbindKey(me.input.KEY.ENTER),me.input.unbindKey(me.input.KEY.SPACE),me.input.unbindPointer(me.input.pointer.LEFT),this.ground1=null,this.ground2=null,this.font=null,me.audio.stop("theme")}}); \ No newline at end of file diff --git a/games/clumsyBird/data/bgm/.placeholder b/games/clumsyBird/data/bgm/.placeholder new file mode 100644 index 0000000..2d38605 --- /dev/null +++ b/games/clumsyBird/data/bgm/.placeholder @@ -0,0 +1 @@ +docs will be placed here when built diff --git a/games/clumsyBird/data/bgm/theme.mp3 b/games/clumsyBird/data/bgm/theme.mp3 new file mode 100644 index 0000000..f324003 Binary files /dev/null and b/games/clumsyBird/data/bgm/theme.mp3 differ diff --git a/games/clumsyBird/data/bgm/theme.ogg b/games/clumsyBird/data/bgm/theme.ogg new file mode 100644 index 0000000..c761ec0 Binary files /dev/null and b/games/clumsyBird/data/bgm/theme.ogg differ diff --git a/games/clumsyBird/data/css/gamefont.eot b/games/clumsyBird/data/css/gamefont.eot new file mode 100644 index 0000000..58bc60f Binary files /dev/null and b/games/clumsyBird/data/css/gamefont.eot differ diff --git a/games/clumsyBird/data/css/gamefont.svg b/games/clumsyBird/data/css/gamefont.svg new file mode 100644 index 0000000..2c6159e --- /dev/null +++ b/games/clumsyBird/data/css/gamefont.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/games/clumsyBird/data/css/gamefont.ttf b/games/clumsyBird/data/css/gamefont.ttf new file mode 100644 index 0000000..d209c01 Binary files /dev/null and b/games/clumsyBird/data/css/gamefont.ttf differ diff --git a/games/clumsyBird/data/css/gamefont.woff b/games/clumsyBird/data/css/gamefont.woff new file mode 100644 index 0000000..7f00dc3 Binary files /dev/null and b/games/clumsyBird/data/css/gamefont.woff differ diff --git a/games/clumsyBird/data/img/.placeholder b/games/clumsyBird/data/img/.placeholder new file mode 100644 index 0000000..2d38605 --- /dev/null +++ b/games/clumsyBird/data/img/.placeholder @@ -0,0 +1 @@ +docs will be placed here when built diff --git a/games/clumsyBird/data/img/bg.png b/games/clumsyBird/data/img/bg.png new file mode 100644 index 0000000..1f9af51 Binary files /dev/null and b/games/clumsyBird/data/img/bg.png differ diff --git a/games/clumsyBird/data/img/clumsy.png b/games/clumsyBird/data/img/clumsy.png new file mode 100644 index 0000000..5c70298 Binary files /dev/null and b/games/clumsyBird/data/img/clumsy.png differ diff --git a/games/clumsyBird/data/img/favicon.ico b/games/clumsyBird/data/img/favicon.ico new file mode 100644 index 0000000..a1aae34 Binary files /dev/null and b/games/clumsyBird/data/img/favicon.ico differ diff --git a/games/clumsyBird/data/img/gameover.png b/games/clumsyBird/data/img/gameover.png new file mode 100644 index 0000000..44d4ea9 Binary files /dev/null and b/games/clumsyBird/data/img/gameover.png differ diff --git a/games/clumsyBird/data/img/gameoverbg.png b/games/clumsyBird/data/img/gameoverbg.png new file mode 100644 index 0000000..ea30d32 Binary files /dev/null and b/games/clumsyBird/data/img/gameoverbg.png differ diff --git a/games/clumsyBird/data/img/getready.png b/games/clumsyBird/data/img/getready.png new file mode 100644 index 0000000..6916266 Binary files /dev/null and b/games/clumsyBird/data/img/getready.png differ diff --git a/games/clumsyBird/data/img/ground.png b/games/clumsyBird/data/img/ground.png new file mode 100644 index 0000000..4cce60d Binary files /dev/null and b/games/clumsyBird/data/img/ground.png differ diff --git a/games/clumsyBird/data/img/hit.png b/games/clumsyBird/data/img/hit.png new file mode 100644 index 0000000..2fe4d35 Binary files /dev/null and b/games/clumsyBird/data/img/hit.png differ diff --git a/games/clumsyBird/data/img/logo.png b/games/clumsyBird/data/img/logo.png new file mode 100644 index 0000000..bfe32bd Binary files /dev/null and b/games/clumsyBird/data/img/logo.png differ diff --git a/games/clumsyBird/data/img/new.png b/games/clumsyBird/data/img/new.png new file mode 100644 index 0000000..f75d07e Binary files /dev/null and b/games/clumsyBird/data/img/new.png differ diff --git a/games/clumsyBird/data/img/pipe.png b/games/clumsyBird/data/img/pipe.png new file mode 100644 index 0000000..3a79b27 Binary files /dev/null and b/games/clumsyBird/data/img/pipe.png differ diff --git a/games/clumsyBird/data/img/share.png b/games/clumsyBird/data/img/share.png new file mode 100644 index 0000000..e821572 Binary files /dev/null and b/games/clumsyBird/data/img/share.png differ diff --git a/games/clumsyBird/data/img/touch-icon-iphone-retina.png b/games/clumsyBird/data/img/touch-icon-iphone-retina.png new file mode 100644 index 0000000..6ed0468 Binary files /dev/null and b/games/clumsyBird/data/img/touch-icon-iphone-retina.png differ diff --git a/games/clumsyBird/data/img/touch-icon-iphone.png b/games/clumsyBird/data/img/touch-icon-iphone.png new file mode 100644 index 0000000..3fe0320 Binary files /dev/null and b/games/clumsyBird/data/img/touch-icon-iphone.png differ diff --git a/games/clumsyBird/data/img/tweet.png b/games/clumsyBird/data/img/tweet.png new file mode 100644 index 0000000..a07a080 Binary files /dev/null and b/games/clumsyBird/data/img/tweet.png differ diff --git a/games/clumsyBird/data/sfx/.placeholder b/games/clumsyBird/data/sfx/.placeholder new file mode 100644 index 0000000..2d38605 --- /dev/null +++ b/games/clumsyBird/data/sfx/.placeholder @@ -0,0 +1 @@ +docs will be placed here when built diff --git a/games/clumsyBird/data/sfx/hit.mp3 b/games/clumsyBird/data/sfx/hit.mp3 new file mode 100644 index 0000000..f51ff0c Binary files /dev/null and b/games/clumsyBird/data/sfx/hit.mp3 differ diff --git a/games/clumsyBird/data/sfx/hit.ogg b/games/clumsyBird/data/sfx/hit.ogg new file mode 100644 index 0000000..e966e67 Binary files /dev/null and b/games/clumsyBird/data/sfx/hit.ogg differ diff --git a/games/clumsyBird/data/sfx/lose.mp3 b/games/clumsyBird/data/sfx/lose.mp3 new file mode 100644 index 0000000..098ce1e Binary files /dev/null and b/games/clumsyBird/data/sfx/lose.mp3 differ diff --git a/games/clumsyBird/data/sfx/lose.ogg b/games/clumsyBird/data/sfx/lose.ogg new file mode 100644 index 0000000..7347cea Binary files /dev/null and b/games/clumsyBird/data/sfx/lose.ogg differ diff --git a/games/clumsyBird/data/sfx/wing.mp3 b/games/clumsyBird/data/sfx/wing.mp3 new file mode 100644 index 0000000..a9f94c8 Binary files /dev/null and b/games/clumsyBird/data/sfx/wing.mp3 differ diff --git a/games/clumsyBird/data/sfx/wing.ogg b/games/clumsyBird/data/sfx/wing.ogg new file mode 100644 index 0000000..5a28fb9 Binary files /dev/null and b/games/clumsyBird/data/sfx/wing.ogg differ diff --git a/games/clumsyBird/data/sfx/wing.wav b/games/clumsyBird/data/sfx/wing.wav new file mode 100644 index 0000000..a16ee51 Binary files /dev/null and b/games/clumsyBird/data/sfx/wing.wav differ diff --git a/games/clumsyBird/index.css b/games/clumsyBird/index.css new file mode 100644 index 0000000..7b05861 --- /dev/null +++ b/games/clumsyBird/index.css @@ -0,0 +1,57 @@ +body { + background-color: #0099cc; + color: #fff; + + /* Allow mouse dragging. */ + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + -webkit-user-select: none; + user-select: none; + + /* disable touch panning/zooming */ + -ms-touch-action: none; + touch-action: none; + + /* Allow canvas to hit the edges of the browser viewport. */ + margin: 0; +} + +#screen canvas { + margin: auto; + /* Hide the gap for font descenders. */ + display: block; + + /* disable scaling interpolation */ + image-rendering: optimizeSpeed; + image-rendering: -moz-crisp-edges; + image-rendering: -o-crisp-edges; + image-rendering: -webkit-optimize-contrast; + image-rendering: optimize-contrast; + -ms-interpolation-mode: nearest-neighbor; +} + +#share { + margin: 10px auto; + text-align: center; +} + +#share .fb-share-button iframe { + margin-top: -4px; +} + +@font-face { + font-family: 'gamefont'; + src: url('data/css/gamefont.eot'); + src: url('data/css/gamefont.eot?#iefix') format('embedded-opentype'), + url('data/css/gamefont.woff') format('woff'), + url('data/css/gamefont.ttf') format('truetype'), + url('data/css/gamefont.svg#gamefont') format('svg'); + font-weight: normal; + font-style: normal; +} + +.google { + position: absolute; + left:23%; +} diff --git a/games/clumsyBird/index.html b/games/clumsyBird/index.html new file mode 100644 index 0000000..529ac77 --- /dev/null +++ b/games/clumsyBird/index.html @@ -0,0 +1,49 @@ + + + + Clumsy Bird + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + diff --git a/games/clumsyBird/js/entities/HUD.js b/games/clumsyBird/js/entities/HUD.js new file mode 100644 index 0000000..e983f5f --- /dev/null +++ b/games/clumsyBird/js/entities/HUD.js @@ -0,0 +1,66 @@ +game.HUD = game.HUD || {}; + +game.HUD.Container = me.Container.extend({ + init: function() { + this._super(me.Container, 'init'); + // persistent across level change + this.isPersistent = true; + + // non collidable + this.collidable = false; + + // make sure our object is always draw first + this.z = Infinity; + + // give a name + this.name = "HUD"; + + // add our child score object at the top left corner + this.addChild(new game.HUD.ScoreItem(5, 5)); + } +}); + + +game.HUD.ScoreItem = me.Renderable.extend({ + init: function(x, y) { + this._super(me.Renderable, "init", [x, y, 10, 10]); + + // local copy of the global score + this.stepsFont = new me.Font('gamefont', 80, '#000', 'center'); + + // make sure we use screen coordinates + this.floating = true; + }, + + draw: function (renderer) { + if (game.data.start && me.state.isCurrent(me.state.PLAY)) + this.stepsFont.draw(renderer, game.data.steps, me.game.viewport.width/2, 10); + } + +}); + +var BackgroundLayer = me.ImageLayer.extend({ + init: function(image, z, speed) { + var settings = {}; + settings.name = image; + settings.width = 900; + settings.height = 600; + settings.image = image; + settings.z = z; + settings.ratio = 1; + // call parent constructor + this._super(me.ImageLayer, 'init', [0, 0, settings]); + }, + + update: function() { + if (me.input.isKeyPressed('mute')) { + game.data.muted = !game.data.muted; + if (game.data.muted){ + me.audio.disable(); + }else{ + me.audio.enable(); + } + } + return true; + } +}); diff --git a/games/clumsyBird/js/entities/entities.js b/games/clumsyBird/js/entities/entities.js new file mode 100644 index 0000000..fb719c3 --- /dev/null +++ b/games/clumsyBird/js/entities/entities.js @@ -0,0 +1,239 @@ +game.BirdEntity = me.Entity.extend({ + init: function(x, y) { + var settings = {}; + settings.image = 'clumsy'; + settings.width = 85; + settings.height = 60; + + this._super(me.Entity, 'init', [x, y, settings]); + this.alwaysUpdate = true; + this.body.gravity = 0.2; + this.maxAngleRotation = Number.prototype.degToRad(-30); + this.maxAngleRotationDown = Number.prototype.degToRad(35); + this.renderable.addAnimation("flying", [0, 1, 2]); + this.renderable.addAnimation("idle", [0]); + this.renderable.setCurrentAnimation("flying"); + //this.renderable.anchorPoint = new me.Vector2d(0.1, 0.5); + this.body.removeShapeAt(0); + this.body.addShape(new me.Ellipse(5, 5, 71, 51)); + + // a tween object for the flying physic effect + this.flyTween = new me.Tween(this.pos); + this.flyTween.easing(me.Tween.Easing.Exponential.InOut); + + this.currentAngle = 0; + this.angleTween = new me.Tween(this); + this.angleTween.easing(me.Tween.Easing.Exponential.InOut); + + // end animation tween + this.endTween = null; + + // collision shape + this.collided = false; + + this.gravityForce = 0.2; + }, + + update: function(dt) { + var that = this; + this.pos.x = 60; + if (!game.data.start) { + return this._super(me.Entity, 'update', [dt]); + } + this.renderable.currentTransform.identity(); + if (me.input.isKeyPressed('fly')) { + me.audio.play('wing'); + this.gravityForce = 0.2; + var currentPos = this.pos.y; + + this.angleTween.stop(); + this.flyTween.stop(); + + + this.flyTween.to({y: currentPos - 72}, 50); + this.flyTween.start(); + + this.angleTween.to({currentAngle: that.maxAngleRotation}, 50).onComplete(function(angle) { + that.renderable.currentTransform.rotate(that.maxAngleRotation); + }) + this.angleTween.start(); + + } else { + this.gravityForce += 0.2; + this.pos.y += me.timer.tick * this.gravityForce; + this.currentAngle += Number.prototype.degToRad(3); + if (this.currentAngle >= this.maxAngleRotationDown) { + this.renderable.currentTransform.identity(); + this.currentAngle = this.maxAngleRotationDown; + } + } + this.renderable.currentTransform.rotate(this.currentAngle); + me.Rect.prototype.updateBounds.apply(this); + + var hitSky = -80; // bird height + 20px + if (this.pos.y <= hitSky || this.collided) { + game.data.start = false; + me.audio.play("lose"); + this.endAnimation(); + return false; + } + me.collision.check(this); + return true; + }, + + onCollision: function(response) { + var obj = response.b; + if (obj.type === 'pipe' || obj.type === 'ground') { + me.device.vibrate(500); + this.collided = true; + } + // remove the hit box + if (obj.type === 'hit') { + me.game.world.removeChildNow(obj); + game.data.steps++; + me.audio.play('hit'); + } + }, + + endAnimation: function() { + me.game.viewport.fadeOut("#fff", 100); + var currentPos = this.pos.y; + this.endTween = new me.Tween(this.pos); + this.endTween.easing(me.Tween.Easing.Exponential.InOut); + + this.flyTween.stop(); + this.renderable.currentTransform.identity(); + this.renderable.currentTransform.rotate(Number.prototype.degToRad(90)); + var finalPos = me.game.viewport.height - this.renderable.width/2 - 96; + this.endTween + .to({y: currentPos}, 1000) + .to({y: finalPos}, 1000) + .onComplete(function() { + me.state.change(me.state.GAME_OVER); + }); + this.endTween.start(); + } + +}); + + +game.PipeEntity = me.Entity.extend({ + init: function(x, y) { + var settings = {}; + settings.image = this.image = me.loader.getImage('pipe'); + settings.width = 148; + settings.height= 1664; + settings.framewidth = 148; + settings.frameheight = 1664; + + this._super(me.Entity, 'init', [x, y, settings]); + this.alwaysUpdate = true; + this.body.gravity = 0; + this.body.vel.set(-5, 0); + this.type = 'pipe'; + }, + + update: function(dt) { + // mechanics + if (!game.data.start) { + return this._super(me.Entity, 'update', [dt]); + } + this.pos.add(this.body.vel); + if (this.pos.x < -this.image.width) { + me.game.world.removeChild(this); + } + me.Rect.prototype.updateBounds.apply(this); + this._super(me.Entity, 'update', [dt]); + return true; + }, + +}); + +game.PipeGenerator = me.Renderable.extend({ + init: function() { + this._super(me.Renderable, 'init', [0, me.game.viewport.width, me.game.viewport.height, 92]); + this.alwaysUpdate = true; + this.generate = 0; + this.pipeFrequency = 92; + this.pipeHoleSize = 1240; + this.posX = me.game.viewport.width; + }, + + update: function(dt) { + if (this.generate++ % this.pipeFrequency == 0) { + var posY = Number.prototype.random( + me.video.renderer.getHeight() - 100, + 200 + ); + var posY2 = posY - me.game.viewport.height - this.pipeHoleSize; + var pipe1 = new me.pool.pull('pipe', this.posX, posY); + var pipe2 = new me.pool.pull('pipe', this.posX, posY2); + var hitPos = posY - 100; + var hit = new me.pool.pull("hit", this.posX, hitPos); + pipe1.renderable.currentTransform.scaleY(-1); + me.game.world.addChild(pipe1, 10); + me.game.world.addChild(pipe2, 10); + me.game.world.addChild(hit, 11); + } + this._super(me.Entity, "update", [dt]); + }, + +}); + +game.HitEntity = me.Entity.extend({ + init: function(x, y) { + var settings = {}; + settings.image = this.image = me.loader.getImage('hit'); + settings.width = 148; + settings.height= 60; + settings.framewidth = 148; + settings.frameheight = 60; + + this._super(me.Entity, 'init', [x, y, settings]); + this.alwaysUpdate = true; + this.body.gravity = 0; + this.updateTime = false; + this.renderable.alpha = 0; + this.body.accel.set(-5, 0); + this.body.removeShapeAt(0); + this.body.addShape(new me.Rect(0, 0, settings.width - 30, settings.height - 30)); + this.type = 'hit'; + }, + + update: function(dt) { + // mechanics + this.pos.add(this.body.accel); + if (this.pos.x < -this.image.width) { + me.game.world.removeChild(this); + } + me.Rect.prototype.updateBounds.apply(this); + this._super(me.Entity, "update", [dt]); + return true; + }, + +}); + +game.Ground = me.Entity.extend({ + init: function(x, y) { + var settings = {}; + settings.image = me.loader.getImage('ground'); + settings.width = 900; + settings.height= 96; + this._super(me.Entity, 'init', [x, y, settings]); + this.alwaysUpdate = true; + this.body.gravity = 0; + this.body.vel.set(-4, 0); + this.type = 'ground'; + }, + + update: function(dt) { + // mechanics + this.pos.add(this.body.vel); + if (this.pos.x < -this.renderable.width) { + this.pos.x = me.video.renderer.getWidth() - 10; + } + me.Rect.prototype.updateBounds.apply(this); + return this._super(me.Entity, 'update', [dt]); + }, + +}); diff --git a/games/clumsyBird/js/game.js b/games/clumsyBird/js/game.js new file mode 100644 index 0000000..af6fe6a --- /dev/null +++ b/games/clumsyBird/js/game.js @@ -0,0 +1,61 @@ +var game = { + data: { + score : 0, + steps: 0, + start: false, + newHiScore: false, + muted: false + }, + + resources: [ + // images + {name: "bg", type:"image", src: "data/img/bg.png"}, + {name: "clumsy", type:"image", src: "data/img/clumsy.png"}, + {name: "pipe", type:"image", src: "data/img/pipe.png"}, + {name: "logo", type:"image", src: "data/img/logo.png"}, + {name: "ground", type:"image", src: "data/img/ground.png"}, + {name: "gameover", type:"image", src: "data/img/gameover.png"}, + {name: "gameoverbg", type:"image", src: "data/img/gameoverbg.png"}, + {name: "hit", type:"image", src: "data/img/hit.png"}, + {name: "getready", type:"image", src: "data/img/getready.png"}, + {name: "new", type:"image", src: "data/img/new.png"}, + {name: "share", type:"image", src: "data/img/share.png"}, + {name: "tweet", type:"image", src: "data/img/tweet.png"}, + // sounds + {name: "theme", type: "audio", src: "data/bgm/"}, + {name: "hit", type: "audio", src: "data/sfx/"}, + {name: "lose", type: "audio", src: "data/sfx/"}, + {name: "wing", type: "audio", src: "data/sfx/"}, + + ], + + "onload": function() { + if (!me.video.init(900, 600, { + wrapper: "screen", + scale : "auto", + scaleMethod: "fit" + })) { + alert("Your browser does not support HTML5 canvas."); + return; + } + me.audio.init("mp3,ogg"); + me.loader.preload(game.resources, this.loaded.bind(this)); + }, + + "loaded": function() { + me.state.set(me.state.MENU, new game.TitleScreen()); + me.state.set(me.state.PLAY, new game.PlayScreen()); + me.state.set(me.state.GAME_OVER, new game.GameOverScreen()); + + me.input.bindKey(me.input.KEY.SPACE, "fly", true); + me.input.bindKey(me.input.KEY.M, "mute", true); + me.input.bindPointer(me.input.KEY.SPACE); + + me.pool.register("clumsy", game.BirdEntity); + me.pool.register("pipe", game.PipeEntity, true); + me.pool.register("hit", game.HitEntity, true); + me.pool.register("ground", game.Ground, true); + + me.state.change(me.state.MENU); + } +}; diff --git a/games/clumsyBird/js/melonJS-min.js b/games/clumsyBird/js/melonJS-min.js new file mode 100644 index 0000000..e13e8f4 --- /dev/null +++ b/games/clumsyBird/js/melonJS-min.js @@ -0,0 +1,40 @@ +/** + * melonJS Game Engine v4.0.0 + * http://www.melonjs.org + * @license {@link http://www.opensource.org/licenses/mit-license.php|MIT} + * @copyright (C) 2011 - 2016, Olivier Biot, Jason Oster, Aaron McLeod + */ +if(function(){function a(){if(!c){if(!document.body)return setTimeout(a,13);for(document.removeEventListener&&document.removeEventListener("DOMContentLoaded",a,!1),window.removeEventListener("load",a,!1);d.length;)d.shift().call(window,[]);c=!0,"function"==typeof define&&define.amd&&define("me",[],function(){return me})}}window.me=window.me||{};var b=!1,c=!1,d=[];window.onReady=function(e){c?e.call(window,[]):(d.push(e),b||("complete"===document.readyState?window.setTimeout(a,0):(document.addEventListener&&document.addEventListener("DOMContentLoaded",a,!1),window.addEventListener("load",a,!1)),b=!0))},me.skipAutoInit!==!0?window.onReady(function(){me.boot()}):me.init=function(){me.boot(),a()},window.throttle||(window.throttle=function(a,b,c){var d,e=window.performance.now();return"boolean"!=typeof b&&(b=!1),function(){var f=window.performance.now(),g=f-e,h=arguments;return a>g?void(b===!1&&(clearTimeout(d),d=setTimeout(function(){return e=f,c.apply(null,h)},g))):(e=f,c.apply(null,h))}}),"undefined"==typeof console&&(console={log:function(){},info:function(){},error:function(){alert(Array.prototype.slice.call(arguments).join(", "))}})}(),!Function.prototype.bind){var Empty=function(){};Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError("Function.prototype.bind called on incompatible "+b);var c=Array.prototype.slice.call(arguments,1),d=function(){if(this instanceof d){var e=b.apply(this,c.concat(Array.prototype.slice.call(arguments)));return Object(e)===e?e:this}return b.apply(a,c.concat(Array.prototype.slice.call(arguments)))};return b.prototype&&(Empty.prototype=b.prototype,d.prototype=new Empty,Empty.prototype=null),d}}if(Function.prototype.defer=function(){return setTimeout(this.bind.apply(this,arguments),.01)},Object.defineProperty||(Object.defineProperty=function(a,b,c){if(!a.__defineGetter__)throw new TypeError("Object.defineProperty not supported");c.get&&a.__defineGetter__(b,c.get),c.set&&a.__defineSetter__(b,c.set)}),Object.create||(Object.create=function(a){var b=function(){};return b.prototype=a,new b}),Object.is||(Object.is=function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b}),Object.assign||!function(){Object.assign=function(a){"use strict";if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c0?1:-1}),Number.prototype.clamp=function(a,b){return a>this?a:this>b?b:+this},Number.prototype.random=function(a,b){return b||(b=a,a=this),~~(Math.random()*(b-a))+a},Number.prototype.randomFloat=function(a,b){return b||(b=a,a=this),Math.random()*(b-a)+a},Number.prototype.weightedRandom=function(a,b){return b||(b=a,a=this),~~(Math.pow(Math.random(),2)*(b-a))+a},Number.prototype.round=function(a,b){a=arguments.length<2?this:a;var c=Math.pow(10,b||a||0);return~~(.5+a*c)/c},Number.prototype.toHex=function(){return"0123456789ABCDEF".charAt(this-this%16>>4)+"0123456789ABCDEF".charAt(this%16)},Number.prototype.degToRad=function(a){return(a||this)/180*Math.PI},Number.prototype.radToDeg=function(a){return(a||this)*(180/Math.PI)},String.prototype.trim||String.prototype.trim||!function(){var a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(a,"")}}(),String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/,"")}),String.prototype.isNumeric=function(){return!isNaN(this)&&""!==this.trim()},String.prototype.isBoolean=function(){var a=this.trim();return"true"===a||"false"===a},String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.toHex=function(){for(var a="",b=0;bb;b++)this.push(0)}},me.TypedArray.prototype=Array.prototype,me.TypedArray.prototype.set=function(a,b){if(b=b||0,a.length+b>this.length)throw new me.Error("TypedArray pollyfill: Buffer overflow in set");for(var c=0;c-1}function e(a){return this.has(a)?this._values[s]:void 0}function f(a,b){if(this.objectOnly&&b!==Object(b))throw new TypeError("Invalid value used as weak collection key");if(b!=b||0===b)for(s=a.length;s--&&!u(a[s],b););else s=a.indexOf(b);return s>-1}function g(a){return f.call(this,this._values,a)}function h(a){return f.call(this,this._keys,a)}function i(a,b){return this.has(a)?this._values[s]=b:this._values[this._keys.push(a)-1]=b,this}function j(a){return this.has(a)||this._values.push(a),this}function k(){(this._keys||0).length=this._values.length=0}function l(){return p(this._itp,this._keys)}function m(){return p(this._itp,this._values)}function n(){return p(this._itp,this._keys,this._values)}function o(){return p(this._itp,this._values,this._values)}function p(a,b,c){var d=[0],e=!1;return a.push(d),{next:function(){var f,g=d[0];return!e&&ga;a+=2){var b=aa[a],c=aa[a+1];b(c),aa[a]=void 0,aa[a+1]=void 0}V=0}function k(){try{var a=require,b=a("vertx");return R=b.runOnLoop||b.runOnContext,f()}catch(a){return i()}}function l(a,b){var c=this,d=new this.constructor(n);void 0===d[da]&&G(d);var e=c._state;if(e){var f=arguments[e-1];W(function(){D(e,d,f,c._result)})}else z(c,d,a,b);return d}function m(a){var b=this;if(a&&"object"==typeof a&&a.constructor===b)return a;var c=new b(n);return v(c,a),c}function n(){}function o(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function q(a){try{return a.then}catch(a){return ha.error=a,ha}}function r(a,b,c,d){try{a.call(b,c,d)}catch(a){return a}}function s(a,b,c){W(function(a){var d=!1,e=r(c,b,function(c){d||(d=!0,b!==c?v(a,c):x(a,c))},function(b){d||(d=!0,y(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,y(a,e))},a)}function t(a,b){b._state===fa?x(a,b._result):b._state===ga?y(a,b._result):z(b,void 0,function(b){v(a,b)},function(b){y(a,b)})}function u(a,c,d){c.constructor===a.constructor&&d===ba&&constructor.resolve===ca?t(a,c):d===ha?y(a,ha.error):void 0===d?x(a,c):b(d)?s(a,c,d):x(a,c)}function v(b,c){b===c?y(b,o()):a(c)?u(b,c,q(c)):x(b,c)}function w(a){a._onerror&&a._onerror(a._result),A(a)}function x(a,b){a._state===ea&&(a._result=b,a._state=fa,0!==a._subscribers.length&&W(A,a))}function y(a,b){a._state===ea&&(a._state=ga,a._result=b,W(w,a))}function z(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+fa]=c,e[f+ga]=d,0===f&&a._state&&W(A,a)}function A(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;gf;f++)b.resolve(a[f]).then(c,d)}:function(a,b){b(new TypeError("You must pass an array to race."))})}function J(a){var b=this,c=new b(n);return y(c,a),c}function K(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function L(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(a){this[da]=F(),this._result=this._state=void 0,this._subscribers=[],n!==a&&("function"!=typeof a&&K(),this instanceof M?E(this,a):L())}function N(a,b){this._instanceConstructor=a,this.promise=new a(n),this.promise[da]||G(this.promise),Array.isArray(b)?(this._input=b,this.length=b.length,this._remaining=b.length,this._result=new Array(this.length),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&x(this.promise,this._result))):y(this.promise,O())}function O(){return new Error("Array Methods must be provided an Array")}function P(){var a;if("undefined"!=typeof global)a=global;else if("undefined"!=typeof self)a=self;else try{a=Function("return this")()}catch(a){throw new Error("polyfill failed because global object is unavailable in this environment")}var b=a.Promise;b&&"[object Promise]"===Object.prototype.toString.call(b.resolve())&&!b.cast||(a.Promise=na)}var Q;Q=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var R,S,T,U=Q,V=0,W=function(a,b){aa[V]=a,aa[V+1]=b,V+=2,2===V&&(S?S(j):T())},X="undefined"!=typeof window?window:void 0,Y=X||{},Z=Y.MutationObserver||Y.WebKitMutationObserver,$="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),_="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,aa=new Array(1e3);T=$?e():Z?g():_?h():void 0===X&&"function"==typeof require?k():i();var ba=l,ca=m,da=Math.random().toString(36).substring(16),ea=void 0,fa=1,ga=2,ha=new B,ia=new B,ja=0,ka=H,la=I,ma=J,na=M;M.all=ka,M.race=la,M.resolve=ca,M.reject=ma,M._setScheduler=c,M._setAsap=d,M._asap=W,M.prototype={constructor:M,then:ba,catch:function(a){return this.then(null,a)}};var oa=N;N.prototype._enumerate=function(){for(var a=this.length,b=this._input,c=0;this._state===ea&&a>c;c++)this._eachEntry(b[c],c)},N.prototype._eachEntry=function(a,b){var c=this._instanceConstructor,d=c.resolve;if(d===ca){var e=q(a);if(e===ba&&a._state!==ea)this._settledAt(a._state,b,a._result);else if("function"!=typeof e)this._remaining--,this._result[b]=a;else if(c===na){var f=new c(n);u(f,a,e),this._willSettleAt(f,b)}else this._willSettleAt(new c(function(b){b(a)}),b)}else this._willSettleAt(d(a),b)},N.prototype._settledAt=function(a,b,c){var d=this.promise;d._state===ea&&(this._remaining--,a===ga?y(d,c):this._result[b]=c),0===this._remaining&&x(d,this._result)},N.prototype._willSettleAt=function(a,b){var c=this;z(a,void 0,function(a){c._settledAt(fa,b,a)},function(a){c._settledAt(ga,b,a)})};var pa=P,qa={Promise:na,polyfill:pa};"function"==typeof define&&define.amd?define(function(){return qa}):"undefined"!=typeof module&&module.exports?module.exports=qa:"undefined"!=typeof this&&(this.ES6Promise=qa),pa()}.call(this),function(){function a(){var a={};return document.location.hash&&document.location.hash.substr(1).split("&").filter(function(a){return""!==a}).forEach(function(b){var c=b.split("="),d=c.shift(),e=c.join("=");a[d]=e||!0}),a}me.mod="melonJS",me.version="4.0.0",me.sys={fps:60,updatesPerSecond:60,interpolation:!1,scale:null,gravity:void 0,stopOnAudioError:!0,pauseOnBlur:!0,resumeOnFocus:!0,stopOnBlur:!1,preRender:!1,checkVersion:function(a,b){b=b||me.version;for(var c=a.split("."),d=b.split("."),e=Math.min(c.length,d.length),f=0,g=0;e>g&&!(f=+c[g]-+d[g]);g++);return f?f:c.length-d.length}};var b=!1;Object.defineProperty(me,"initialized",{get:function(){return b}}),me.boot=function(){b||(me.device._check(),me.save._init(),me.game.HASH=a(),me.loader.setNocache(me.game.HASH.nocache||!1),me.timer.init(),me.state.init(),me.pool.init(),me.device.isMobile===!1&&me.input._enableKeyboardEvent(),me.levelDirector.reset(),b=!0)}}(),function(){me.game=function(){var a={},b=!1,c=!0,d=!1,e=0,f=1,g=0,h=0,i=0,j=1e3/60,k=0,l=null,m=0,n=null;return a.viewport=null,a.world=null,a.mergeGroup=!0,a.sortOn="z",a.tmxRenderer=null,a.onLevelLoaded=function(){},a.HASH=null,a.init=function(d,e){b||(d=d||me.video.renderer.getWidth(),e=e||me.video.renderer.getHeight(),a.viewport=new me.Viewport(0,0,d,e),a.world=new me.Container(0,0,d,e),a.world.name="rootContainer",a.world._root=!0,me.collision.init(),n=me.video.renderer,me.event.publish(me.event.GAME_INIT),me.input._translatePointerEvents(),c=!0,b=!0)},a.reset=function(){me.collision.quadTree.clear(),a.world.destroy(),a.viewport&&a.viewport.reset(),n.reset(),me.event.publish(me.event.GAME_RESET),a.updateFrameRate()},a.updateFrameRate=function(){e=0,f=~~(.5+60/me.sys.fps),j=1e3/me.sys.updatesPerSecond,g=0,h=10*j,d=me.sys.fps>me.sys.updatesPerSecond},a.getParentContainer=function(a){return a.ancestor},a.repaint=function(){c=!0},a.update=function(b){if(++e%f===0)for(e=0,me.timer.update(b),me.input._updateGamepads(),g+=me.timer.getDelta(),g=Math.min(g,h),k=me.sys.interpolation?me.timer.getDelta():j,i=me.sys.interpolation?k:Math.max(k,m);g>=i||me.sys.interpolation;)if(l=window.performance.now(),me.collision.quadTree.clear(),me.collision.quadTree.insertContainer(a.world),c=a.world.update(k)||c,c=a.viewport.update(k)||c,me.timer.lastUpdate=window.performance.now(),m=me.timer.lastUpdate-l,g-=i,me.sys.interpolation){g=0;break}},a.draw=function(){if(c||d){var b=a.viewport.pos.x+a.viewport.offset.x,e=a.viewport.pos.y+a.viewport.offset.y;a.world.currentTransform.translate(-b,-e),me.video.renderer.clear(),a.world.draw(n,a.viewport),a.world.currentTransform.translate(b,e),a.viewport.draw(n)}c=!1,me.video.renderer.flush()},a}()}(),function(){var a=function(a){return a.substring(0,1).toUpperCase()+a.substring(1,a.length)};me.agent=function(){var b={},c=["ms","MS","moz","webkit","o"];return b.prefixed=function(b,d){if(d=d||window,b in d)return d[b];var e,f=a(b);return c.some(function(a){var b=a+f;return e=b in d?d[b]:void 0}),e},b.setPrefixed=function(b,d,e){if(e=e||window,b in e)return void(e[b]=d);var f=a(b);c.some(function(a){var b=a+f;return b in e?(e[b]=d,!0):!1})},b}()}(),function(){me.device=function(){function a(a){a.reading?(c.accelerationX=a.reading.accelerationX,c.accelerationY=a.reading.accelerationY,c.accelerationZ=a.reading.accelerationZ):(c.accelerationX=a.accelerationIncludingGravity.x,c.accelerationY=a.accelerationIncludingGravity.y,c.accelerationZ=a.accelerationIncludingGravity.z)}function b(a){c.gamma=a.gamma,c.beta=a.beta,c.alpha=a.alpha}var c={},d=!1,e=!1,f=null;return c._check=function(){me.device._detectDevice(),me.device.isMobile&&!me.device.cocoon&&window.document.addEventListener("touchmove",function(a){return a.preventDefault(),window.scroll(0,0),!1},!1),me.device.pointerEvent=me.agent.prefixed("PointerEvent",window),me.device.maxTouchPoints=me.agent.prefixed("maxTouchPoints",navigator)||0,window.gesture=me.agent.prefixed("gesture"),me.device.touch="createTouch"in document||"ontouchstart"in window||me.device.cocoon||me.device.pointerEvent&&me.device.maxTouchPoints>0,me.device.hasAccelerometer="undefined"!=typeof window.DeviceMotionEvent||"undefined"!=typeof window.Windows&&"function"==typeof Windows.Devices.Sensors.Accelerometer,this.hasPointerLockSupport=me.agent.prefixed("pointerLockElement",document),this.hasPointerLockSupport&&(document.exitPointerLock=me.agent.prefixed("exitPointerLock",document)),window.DeviceOrientationEvent&&(me.device.hasDeviceOrientation=!0),this.hasFullscreenSupport=me.agent.prefixed("fullscreenEnabled",document)||document.mozFullScreenEnabled,document.exitFullscreen=me.agent.prefixed("cancelFullScreen",document)||me.agent.prefixed("exitFullscreen",document),navigator.vibrate=me.agent.prefixed("vibrate",navigator);try{c.localStorage=!!window.localStorage}catch(a){c.localStorage=!1}window.addEventListener("blur",function(){me.sys.stopOnBlur&&me.state.stop(!0),me.sys.pauseOnBlur&&me.state.pause(!0)},!1),window.addEventListener("focus",function(){me.sys.stopOnBlur&&me.state.restart(!0),me.sys.resumeOnFocus&&me.state.resume(!0)},!1);var a,b;"undefined"!=typeof document.hidden?(a="hidden",b="visibilitychange"):"undefined"!=typeof document.mozHidden?(a="mozHidden",b="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(a="msHidden",b="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(a="webkitHidden",b="webkitvisibilitychange"),"string"==typeof b&&document.addEventListener(b,function(){document[a]?(me.sys.stopOnBlur&&me.state.stop(!0),me.sys.pauseOnBlur&&me.state.pause(!0)):(me.sys.stopOnBlur&&me.state.restart(!0),me.sys.resumeOnFocus&&me.state.resume(!0))},!1)},c._detectDevice=function(){me.device.iOS=me.device.ua.match(/iPhone|iPad|iPod/i)||!1,me.device.android=me.device.ua.match(/Android/i)||!1,me.device.android2=me.device.ua.match(/Android 2/i)||!1,me.device.wp=me.device.ua.match(/Windows Phone/i)||!1,me.device.BlackBerry=me.device.ua.match(/BlackBerry/i)||!1,me.device.Kindle=me.device.ua.match(/Kindle|Silk.*Mobile Safari/i)||!1,me.device.isMobile=me.device.ua.match(/Mobi/i)||me.device.iOS||me.device.android||me.device.wp||me.device.BlackBerry||me.device.Kindle||me.device.iOS||!1,me.device.ejecta="undefined"!=typeof window.ejecta,me.device.cocoon=navigator.isCocoonJS||"undefined"!=typeof window.Cocoon},c.ua=navigator.userAgent,c.localStorage=!1,c.hasAccelerometer=!1,c.hasDeviceOrientation=!1,c.hasFullscreenSupport=!1,c.hasPointerLockSupport=!1,c.nativeBase64="function"==typeof window.atob,c.maxTouchPoints=0,c.touch=!1,c.isMobile=!1,c.iOS=!1,c.android=!1,c.android2=!1,c.ejecta=!1,c.cocoon=!1,c.wp=!1,c.BlackBerry=!1,c.Kindle=!1,c.orientation=0,c.accelerationX=0,c.accelerationY=0,c.accelerationZ=0,c.gamma=0,c.beta=0,c.alpha=0,c.language=navigator.language||navigator.browserLanguage||navigator.userLanguage||"en",c.requestFullscreen=function(a){this.hasFullscreenSupport&&(a=a||me.video.getWrapper(),a.requestFullscreen=me.agent.prefixed("requestFullscreen",a)||a.mozRequestFullScreen,a.requestFullscreen())},c.exitFullscreen=function(){this.hasFullscreenSupport&&document.exitFullscreen()},c.getPixelRatio=function(){if(null===f){var a;a="undefined"!=typeof me.video.renderer?me.video.renderer.getScreenContext():me.Renderer.prototype.getContext2d(document.createElement("canvas"));var b=window.devicePixelRatio||1,c=me.agent.prefixed("backingStorePixelRatio",a)||1;f=b/c}return f},c.getStorage=function(a){switch(a=a||"local"){case"local":return me.save;default:throw new me.Error("storage type "+a+" not supported")}},c.turnOnPointerLock=function(){if(this.hasPointerLockSupport){var a=me.video.getWrapper();if(me.device.ua.match(/Firefox/i)){var b=function(){(me.agent.prefixed("fullscreenElement",document)||document.mozFullScreenElement)===a&&(document.removeEventListener("fullscreenchange",b),document.removeEventListener("mozfullscreenchange",b),a.requestPointerLock=me.agent.prefixed("requestPointerLock",a),a.requestPointerLock())};document.addEventListener("fullscreenchange",b,!1),document.addEventListener("mozfullscreenchange",b,!1),me.device.requestFullscreen()}else a.requestPointerLock()}},c.turnOffPointerLock=function(){this.hasPointerLockSupport&&document.exitPointerLock()},c.watchAccelerometer=function(){if(me.device.hasAccelerometer){if(!d){if("undefined"==typeof Windows)window.addEventListener("devicemotion",a,!1);else{var b=Windows.Devices.Sensors.Accelerometer.getDefault();if(b){var c=b.minimumReportInterval,e=c>=16?c:25;b.reportInterval=e,b.addEventListener("readingchanged",a,!1)}}d=!0}return!0}return!1},c.unwatchAccelerometer=function(){if(d){if("undefined"==typeof Windows)window.removeEventListener("devicemotion",a,!1);else{var b=Windows.Device.Sensors.Accelerometer.getDefault();b.removeEventListener("readingchanged",a,!1)}d=!1}},c.watchDeviceOrientation=function(){return me.device.hasDeviceOrientation&&!e&&(window.addEventListener("deviceorientation",b,!1),e=!0),!1},c.unwatchDeviceOrientation=function(){e&&(window.removeEventListener("deviceorientation",b,!1),e=!1)},c.vibrate=function(a){navigator.vibrate&&navigator.vibrate(a)},c}(),Object.defineProperty(me.device,"isFullscreen",{get:function(){if(me.device.hasFullscreenSupport){var a=me.agent.prefixed("fullscreenElement",document)||document.mozFullScreenElement;return a===me.video.getWrapper()}return!1}}),Object.defineProperty(me.device,"sound",{get:function(){return!Howler.noAudio}})}(),function(){me.timer=function(){var a={},b=0,c=0,d=0,e=0,f=0,g=Math.ceil(1e3/me.sys.fps),h=1e3/me.sys.fps*1.25,i=[],j=0,k=function(a){for(var b=0,c=i.length;c>b;b++)if(i[b].timerId===a){i.splice(b,1);break}},l=function(a){for(var b=0,c=i.length;c>b;b++){var d=i[b];d.pauseable&&me.state.isPaused()||(d.elapsed+=a),d.elapsed>=d.delay&&(d.fn.apply(this),d.repeat===!0?d.elapsed-=d.delay:me.timer.clearTimeout(d.timerId))}};return a.tick=1,a.fps=0,a.lastUpdate=window.performance.now(),a.init=function(){a.reset(),e=d=0},a.reset=function(){d=e=window.performance.now(),f=0,c=0,b=0},a.setTimeout=function(a,b,c){return i.push({fn:a,delay:b,elapsed:0,repeat:!1,timerId:++j,pauseable:c===!0||!0}),j},a.setInterval=function(a,b,c){return i.push({fn:a,delay:b,elapsed:0,repeat:!0,timerId:++j,pauseable:c===!0||!0}),j},a.clearTimeout=function(a){k.defer(this,a)},a.clearInterval=function(a){k.defer(this,a)},a.getTime=function(){return e},a.getDelta=function(){return f},a.countFPS=function(){b++,c+=f,b%10===0&&(this.fps=(~~(1e3*b/c)).clamp(0,me.sys.fps),c=0,b=0)},a.update=function(b){return d=e,e=b,f=e-d,a.tick=f>h&&me.sys.interpolation?f/g:1,l(f),f},a}()}(),function(){me.pool=function(){var a={},b={};return a.init=function(){a.register("me.Entity",me.Entity),a.register("me.CollectableEntity",me.CollectableEntity),a.register("me.LevelEntity",me.LevelEntity),a.register("me.Tween",me.Tween,!0),a.register("me.Color",me.Color,!0),a.register("me.Particle",me.Particle,!0),a.register("me.Sprite",me.Sprite),a.register("me.Vector2d",me.Vector2d,!0),a.register("me.Glyph",me.Glyph,!0),a.register("me.Matrix2d",me.Matrix2d,!0)},a.register=function(a,c,d){b[a]={class:c,pool:d?[]:void 0}},a.pull=function(a){for(var c=new Array(arguments.length),d=0;da.x?this.x:a.x,this.y>a.y?this.y:a.y)},floor:function(){return new me.Vector2d(Math.floor(this.x),Math.floor(this.y))},floorSelf:function(){return this._set(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return new me.Vector2d(Math.ceil(this.x),Math.ceil(this.y))},ceilSelf:function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},negate:function(){return new me.Vector2d(-this.x,-this.y)},negateSelf:function(){return this._set(-this.x,-this.y)},copy:function(a){return this._set(a.x,a.y)},equals:function(a){return this.x===a.x&&this.y===a.y},normalize:function(){var a=this.length();return a>0?this._set(this.x/a,this.y/a):this},perp:function(){return this._set(this.y,-this.x)},rotate:function(a){var b=this.x,c=this.y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a))},dotProduct:function(a){return this.x*a.x+this.y*a.y},length2:function(){return this.dotProduct(this)},length:function(){return Math.sqrt(this.length2())},distance:function(a){var b=this.x-a.x,c=this.y-a.y;return Math.sqrt(b*b+c*c)},angle:function(a){return Math.acos((this.dotProduct(a)/(this.length()*a.length())).clamp(-1,1))},project:function(a){return this.scale(this.dotProduct(a)/a.length2())},projectN:function(a){return this.scale(this.dotProduct(a))},clone:function(){return new me.Vector2d(this.x,this.y)},toString:function(){return"x:"+this.x+",y:"+this.y}}),me.Vector2d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Vector2d.Error"}})}(),function(){me.Vector3d=me.Object.extend({init:function(a,b,c){return this.set(a||0,b||0,c||0)},_set:function(a,b,c){return this.x=a,this.y=b,this.z=c,this},set:function(a,b,c){if(a!==+a||b!==+b||c!==+c)throw new me.Vector3d.Error("invalid x, y, z parameters (not a number)");return this._set(a,b,c)},setZero:function(){return this.set(0,0,0)},setV:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this.z)},add:function(a){return this._set(this.x+a.x,this.y+a.y,this.z+(a.z||0))},sub:function(a){return this._set(this.x-a.x,this.y-a.y,this.z-(a.z||0))},scale:function(a,b,c){return b="undefined"!=typeof b?b:a,c="undefined"!=typeof c?c:a,this._set(this.x*a,this.y*b,this.z*c)},scaleV:function(a){return this._set(this.x*a.x,this.y*a.y,this.z*(a.z||1))},div:function(a){return this._set(this.x/a,this.y/a,this.z/a)},abs:function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y,this.z<0?-this.Z:this.z)},clamp:function(a,b){return new me.Vector3d(this.x.clamp(a,b),this.y.clamp(a,b),this.z.clamp(a,b))},clampSelf:function(a,b){return this._set(this.x.clamp(a,b),this.y.clamp(a,b),this.z.clamp(a,b))},minV:function(a){var b=a.z||0;return this._set(this.xa.x?this.x:a.x,this.y>a.y?this.y:a.y,this.z>b?this.z:b)},floor:function(){return new me.Vector3d(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},floorSelf:function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},ceil:function(){return new me.Vector3d(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},ceilSelf:function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},negate:function(){return new me.Vector3d(-this.x,-this.y,-this.z)},negateSelf:function(){return this._set(-this.x,-this.y,-this.z)},copy:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this.z)},equals:function(a){return this.x===a.x&&this.y===a.y&&this.z===(a.z||this.z)},normalize:function(){var a=this.length();return a>0?this._set(this.x/a,this.y/a,this.z/a):this},perp:function(){return this._set(this.y,-this.x,this.z)},rotate:function(a){var b=this.x,c=this.y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a),this.z)},dotProduct:function(a){return this.x*a.x+this.y*a.y+this.z*(a.z||1)},length2:function(){return this.dotProduct(this)},length:function(){return Math.sqrt(this.length2())},distance:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-(a.z||0);return Math.sqrt(b*b+c*c+d*d)},angle:function(a){return Math.acos((this.dotProduct(a)/(this.length()*a.length())).clamp(-1,1))},project:function(a){return this.scale(this.dotProduct(a)/a.length2())},projectN:function(a){return this.scale(this.dotProduct(a))},clone:function(){return new me.Vector3d(this.x,this.y,this.z)},toString:function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z}}),me.Vector3d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Vector3d.Error"}})}(),function(){me.ObservableVector2d=me.Vector2d.extend({init:function(a,b,c){if(Object.defineProperty(this,"x",{get:function(){return this._x},set:function(a){this.onUpdate(a,this._y,this._x,this._y),this._x=a}}),Object.defineProperty(this,"y",{get:function(){return this._y},set:function(a){this.onUpdate(this._x,a,this._x,this._y),this._y=a}}),"undefined"==typeof c)throw new me.ObservableVector2d.Error("undefined `onUpdate` callback");this.setCallback(c.onUpdate),this._x=a||0,this._y=b||0},_set:function(a,b){return this.onUpdate(a,b,this._x,this._y),this._x=a,this._y=b,this},setMuted:function(a,b){return this._x=a,this._y=b,this},setCallback:function(a){if("function"!=typeof a)throw new me.ObservableVector2d.Error("invalid `onUpdate` callback");return this.onUpdate=a,this},add:function(a){return this._set(this._x+a.x,this._y+a.y)},sub:function(a){return this._set(this._x-a.x,this._y-a.y)},scale:function(a,b){return this._set(this._x*a,this._y*("undefined"!=typeof b?b:a))},scaleV:function(a){return this._set(this._x*a.x,this._y*a.y)},div:function(a){return this._set(this._x/a,this._y/a)},abs:function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y)},clamp:function(a,b){return new me.ObservableVector2d(this.x.clamp(a,b),this.y.clamp(a,b),{onUpdate:this.onUpdate})},clampSelf:function(a,b){return this._set(this._x.clamp(a,b),this._y.clamp(a,b))},minV:function(a){return this._set(this._xa.x?this._x:a.x,this._y>a.y?this._y:a.y)},floor:function(){return new me.ObservableVector2d(Math.floor(this._x),Math.floor(this._y),{onUpdate:this.onUpdate})},floorSelf:function(){return this._set(Math.floor(this._x),Math.floor(this._y))},ceil:function(){return new me.ObservableVector2d(Math.ceil(this._x),Math.ceil(this._y),{onUpdate:this.onUpdate})},ceilSelf:function(){return this._set(Math.ceil(this._x),Math.ceil(this._y))},negate:function(){return new me.ObservableVector2d(-this._x,-this._y,{onUpdate:this.onUpdate})},negateSelf:function(){return this._set(-this._x,-this._y)},copy:function(a){return this._set(a.x,a.y)},equals:function(a){return this._x===a.x&&this._y===a.y},normalize:function(){var a=this.length();return a>0?this._set(this._x/a,this._y/a):this},perp:function(){return this._set(this._y,-this._x)},rotate:function(a){var b=this._x,c=this._y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a))},dotProduct:function(a){return this._x*a.x+this._y*a.y},distance:function(a){return Math.sqrt((this._x-a.x)*(this._x-a.x)+(this._y-a.y)*(this._y-a.y))},clone:function(){return new me.ObservableVector2d(this._x,this._y,{onUpdate:this.onUpdate})},toVector2d:function(){return new me.Vector2d(this._x,this._y)},toString:function(){return"x:"+this._x+",y:"+this._y}}),me.ObservableVector2d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.ObservableVector2d.Error"}})}(),function(){me.ObservableVector3d=me.Vector3d.extend({init:function(a,b,c,d){if(Object.defineProperty(this,"x",{get:function(){return this._x},set:function(a){this.onUpdate(a,this._y,this._z,this._x,this._y,this._z),this._x=a}}),Object.defineProperty(this,"y",{get:function(){return this._y},set:function(a){this.onUpdate(this._x,a,this._z,this._x,this._y,this._z),this._y=a}}),Object.defineProperty(this,"z",{get:function(){return this._z},set:function(a){this.onUpdate(this._x,this._y,a,this._x,this._y,this._z),this._z=a}}),"undefined"==typeof d)throw new me.ObservableVector3d.Error("undefined `onUpdate` callback");this.setCallback(d.onUpdate),this._x=a||0,this._y=b||0,this._z=c||0},_set:function(a,b,c){return this.onUpdate(a,b,c,this._x,this._y,this._z),this._x=a,this._y=b,this._z=c,this},setMuted:function(a,b,c){return this._x=a,this._y=b,this._z=c,this},setCallback:function(a){if("function"!=typeof a)throw new me.ObservableVector2d.Error("invalid `onUpdate` callback");return this.onUpdate=a,this},add:function(a){return this._set(this._x+a.x,this._y+a.y,this._z+(a.z||0))},sub:function(a){return this._set(this._x-a.x,this._y-a.y,this._z-(a.z||0))},scale:function(a,b,c){return b="undefined"!=typeof b?b:a,c="undefined"!=typeof c?c:a,this._set(this._x*a,this._y*b,this._z*c)},scaleV:function(a){return this._set(this._x*a.x,this._y*a.y,this._z*(a.z||1))},div:function(a){return this._set(this._x/a,this._y/a,this._z/a)},abs:function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y,this._Z<0?-this._z:this._z)},clamp:function(a,b){return new me.ObservableVector3d(this._x.clamp(a,b),this._y.clamp(a,b),this._z.clamp(a,b),{onUpdate:this.onUpdate})},clampSelf:function(a,b){return this._set(this._x.clamp(a,b),this._y.clamp(a,b),this._z.clamp(a,b))},minV:function(a){var b=a.z||0;return this._set(this._xa.x?this._x:a.x,this._y>a.y?this._y:a.y,this._z>b?this._z:b)},floor:function(){return new me.ObservableVector3d(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),{onUpdate:this.onUpdate})},floorSelf:function(){return this._set(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},ceil:function(){return new me.ObservableVector3d(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z),{onUpdate:this.onUpdate})},ceilSelf:function(){return this._set(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z))},negate:function(){return new me.ObservableVector3d(-this._x,-this._y,-this._z,{onUpdate:this.onUpdate})},negateSelf:function(){return this._set(-this._x,-this._y,-this._z)},copy:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this._z)},equals:function(a){return this._x===a.x&&this._y===a.y&&this._z===(a.z||this._z)},normalize:function(){var a=this.length();return a>0?this._set(this._x/a,this._y/a,this._z/a):this},perp:function(){return this._set(this._y,-this._x,this._z)},rotate:function(a){var b=this._x,c=this._y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a),this._z)},dotProduct:function(a){return this._x*a.x+this._y*a.y+this._z*(a.z||1)},distance:function(a){var b=this._x-a.x,c=this._y-a.y,d=this._z-(a.z||0);return Math.sqrt(b*b+c*c+d*d)},clone:function(){return new me.ObservableVector3d(this._x,this._y,this._z,{onUpdate:this.onUpdate})},toVector3d:function(){return new me.Vector3d(this._x,this._y,this._z)},toString:function(){return"x:"+this._x+",y:"+this._y+",z:"+this._z}}),me.ObservableVector3d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.ObservableVector3d.Error"}})}(),function(){me.Matrix2d=me.Object.extend({init:function(){"undefined"==typeof this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof me.Matrix2d?this.copy(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.onResetEvent()},onResetEvent:function(){this.identity()},identity:function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},setTransform:function(){var a=this.val;return 9===arguments.length?(a[0]=arguments[0],a[1]=arguments[1],a[2]=arguments[2],a[3]=arguments[3],a[4]=arguments[4],a[5]=arguments[5],a[6]=arguments[6],a[7]=arguments[7],a[8]=arguments[8]):6===arguments.length&&(a[0]=arguments[0],a[1]=arguments[2],a[2]=arguments[4],a[3]=arguments[1],a[4]=arguments[3],a[5]=arguments[5],a[6]=0,a[7]=0,a[8]=1),this},copy:function(a){return this.val.set(a.val),this},multiply:function(a){a=a.val;var b=this.val,c=b[0],d=b[1],e=b[3],f=b[4],g=a[0],h=a[1],i=a[3],j=a[4],k=a[6],l=a[7];return b[0]=c*g+e*h,b[1]=d*g+f*h,b[3]=c*i+e*j,b[4]=d*i+f*j,b[6]+=c*k+e*l,b[7]+=d*k+f*l,this},transpose:function(){var a,b=this.val;return a=b[1],b[1]=b[3],b[3]=a,a=b[2],b[2]=b[6],b[6]=a,a=b[5],b[5]=b[7],b[7]=a,this},invert:function(){var a=this.val,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=j*f-g*i,l=g*h-j*e,m=i*e-f*h,n=b*k+c*l+d*m;return a[0]=k/n,a[1]=(d*i-j*c)/n,a[2]=(g*c-d*f)/n,a[3]=l/n,a[4]=(j*b-d*h)/n,a[5]=(d*e-g*b)/n,a[6]=m/n,a[7]=(c*h-i*b)/n,a[8]=(f*b-c*e)/n,this},multiplyVector:function(a){var b=this.val,c=a.x,d=a.y;return a.x=c*b[0]+d*b[3]+b[6],a.y=c*b[1]+d*b[4]+b[7],a},scale:function(a,b){var c=this.val,d=a,e="undefined"==typeof b?d:b;return c[0]*=d,c[1]*=d,c[3]*=e,c[4]*=e,this},scaleV:function(a){return this.scale(a.x,a.y)},scaleX:function(a){return this.scale(a,1)},scaleY:function(a){return this.scale(1,a)},rotate:function(a){if(0!==a){var b=this.val,c=b[0],d=b[1],e=b[3],f=b[4],g=Math.sin(a),h=Math.cos(a);b[0]=c*h+e*g,b[1]=d*h+f*g, +b[3]=c*-g+e*h,b[4]=d*-g+f*h}return this},translate:function(a,b){var c=this.val;return c[6]+=c[0]*a+c[3]*b,c[7]+=c[1]*a+c[4]*b,this},translateV:function(a){return this.translate(a.x,a.y)},isIdentity:function(){var a=this.val;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&1===a[4]&&0===a[5]&&0===a[6]&&0===a[7]&&1===a[8]},clone:function(){return me.pool.pull("me.Matrix2d").copy(this)},toString:function(){var a=this.val;return"me.Matrix2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"}})}(),function(){me.Ellipse=me.Object.extend({init:function(a,b,c,d){this.pos=new me.Vector2d,this._bounds=void 0,this.radius=NaN,this.radiusV=new me.Vector2d,this.radiusSq=new me.Vector2d,this.ratio=new me.Vector2d,this.shapeType="Ellipse",this.setShape(a,b,c,d)},setShape:function(a,b,c,d){var e=c/2,f=d/2;this.pos.set(a,b),this.radius=Math.max(e,f),this.ratio.set(e/this.radius,f/this.radius),this.radiusV.set(this.radius,this.radius).scaleV(this.ratio);var g=this.radius*this.radius;return this.radiusSq.set(g,g).scaleV(this.ratio),this.updateBounds(),this},rotate:function(){return this},scale:function(a,b){return b="undefined"!=typeof b?b:a,this.setShape(this.pos.x,this.pos.y,2*this.radiusV.x*a,2*this.radiusV.y*b)},scaleV:function(a){return this.scale(a.x,a.y)},transform:function(){return this},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this._bounds.translate(a,b),this},translateV:function(a){return this.pos.add(a),this._bounds.translateV(a),this},containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){return a-=this.pos.x,b-=this.pos.y,a*a/this.radiusSq.x+b*b/this.radiusSq.y<=1},getBounds:function(){return this._bounds},updateBounds:function(){var a=this.radiusV.x,b=this.radiusV.y,c=this.pos.x-a,d=this.pos.y-b,e=2*a,f=2*b;return this._bounds?this._bounds.setShape(c,d,e,f):this._bounds=new me.Rect(c,d,e,f),this._bounds},clone:function(){return new me.Ellipse(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)}})}(),function(){me.Polygon=me.Object.extend({init:function(a,b,c){this.pos=new me.Vector2d,this._bounds=void 0,this.points=null,this.shapeType="Polygon",this.setShape(a,b,c)},setShape:function(a,b,c){return this.pos.set(a,b),this.points=c,this.recalc(),this.updateBounds(),this},transform:function(a){for(var b=this.points,c=b.length,d=0;c>d;d++)a.multiplyVector(b[d]);return this.recalc(),this.updateBounds(),this},rotate:function(a){if(0!==a){for(var b=this.points,c=b.length,d=0;c>d;d++)b[d].rotate(a);this.recalc(),this.updateBounds()}return this},scale:function(a,b){b="undefined"!=typeof b?b:a;for(var c=this.points,d=c.length,e=0;d>e;e++)c[e].scale(a,b);return this.recalc(),this.updateBounds(),this},scaleV:function(a){return this.scale(a.x,a.y)},recalc:function(){var a,b=this.edges=[],c=this.normals=[],d=this.points,e=d.length;if(3>e)throw new me.Polygon.Error("Requires at least 3 points");for(a=0;e>a;a++){var f=(new me.Vector2d).copy(d[(a+1)%e]).sub(d[a]);b.push(f),c.push((new me.Vector2d).copy(f).perp().normalize())}return this},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this._bounds.translate(a,b),this},translateV:function(a){return this.pos.add(a),this._bounds.translateV(a),this},containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){for(var c=!1,d=this.pos.x,e=this.pos.y,f=this.points,g=f.length,h=0,i=g-1;g>h;i=h++){var j=f[h].y+e,k=f[h].x+d,l=f[i].y+e,m=f[i].x+d;j>b!=l>b&&(m-k)*(b-j)/(l-j)+k>a&&(c=!c)}return c},getBounds:function(){return this._bounds},updateBounds:function(){return this._bounds||(this._bounds=new me.Rect(0,0,0,0)),this._bounds.setPoints(this.points),this._bounds.translateV(this.pos),this._bounds},clone:function(){var a=[];return this.points.forEach(function(b){a.push(new me.Vector2d(b.x,b.y))}),new me.Polygon(this.pos.x,this.pos.y,a)}}),me.Polygon.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Polygon.Error"}})}(),function(){me.Rect=me.Polygon.extend({init:function(a,b,c,d){this.pos=new me.Vector2d,this.points=[new me.Vector2d,new me.Vector2d,new me.Vector2d,new me.Vector2d],this.shapeType="Rectangle",this.setShape(a,b,c,d)},setShape:function(a,b,c,d){return this.points[0].set(0,0),this.points[1].set(c,0),this.points[2].set(c,d),this.points[3].set(0,d),me.Polygon.prototype.setShape.apply(this,[a,b,this.points]),this._width=c,this._height=d,this},resize:function(a,b){return this.width=a,this.height=b,this},getBounds:function(){return this},setPoints:function(a){var b=1/0,c=1/0,d=-(1/0),e=-(1/0);return a.forEach(function(a){b=Math.min(b,a.x),c=Math.min(c,a.y),d=Math.max(d,a.x),e=Math.max(e,a.y)}),this.setShape(b,c,d-b,e-c),this},recalc:function(){return me.Polygon.prototype.recalc.apply(this),this._width=this.points[2].x,this._height=this.points[2].y,this},updateBounds:function(){return this},clone:function(){return new me.Rect(this.pos.x,this.pos.y,this._width,this._height)},copy:function(a){return this.setShape(a.pos.x,a.pos.y,a._width,a._height)},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this},translateV:function(a){return this.translate(a.x,a.y)},union:function(a){var b=Math.min(this.left,a.left),c=Math.min(this.top,a.top);return this.resize(Math.max(this.right,a.right)-b,Math.max(this.bottom,a.bottom)-c),this.pos.set(b,c),this},overlaps:function(a){return this.left=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom},containsPoint:function(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom},toPolygon:function(){return new me.Polygon(this.pos.x,this.pos.y,this.points)}}),Object.defineProperty(me.Rect.prototype,"left",{get:function(){return this.pos.x},configurable:!0}),Object.defineProperty(me.Rect.prototype,"right",{get:function(){var a=this._width;return this.pos.x+a||a},configurable:!0}),Object.defineProperty(me.Rect.prototype,"top",{get:function(){return this.pos.y},configurable:!0}),Object.defineProperty(me.Rect.prototype,"bottom",{get:function(){var a=this._height;return this.pos.y+a||a},configurable:!0}),Object.defineProperty(me.Rect.prototype,"width",{get:function(){return this._width},set:function(a){this.points[1].x=this.points[2].x=a,this.recalc()},configurable:!0}),Object.defineProperty(me.Rect.prototype,"height",{get:function(){return this._height},set:function(a){this.points[2].y=this.points[3].y=a,this.recalc()},configurable:!0})}(),function(){me.Line=me.Polygon.extend({containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){a-=this.pos.x,b-=this.pos.y;var c=this.points[0],d=this.points[1];return(b-c.y)*(d.x-c.x)===(d.y-c.y)*(a-c.x)},recalc:function(){var a=this.edges=[],b=this.normals=[],c=this.points;if(2!==c.length)throw new me.Line.Error("Requires exactly 2 points");var d=(new me.Vector2d).copy(c[1]).sub(c[0]);return a.push(d),b.push((new me.Vector2d).copy(d).perp().normalize()),this},clone:function(){var a=[];return this.points.forEach(function(b){a.push(new me.Vector2d(b.x,b.y))}),new me.Line(this.pos.x,this.pos.y,a)}}),me.Line.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Line.Error"}})}(),function(){me.Body=me.Rect.extend({init:function(a,b){this.entity=a,this.shapes=[],this.collisionMask=me.collision.types.ALL_OBJECT,this.collisionType=me.collision.types.ENEMY_OBJECT,"undefined"==typeof this.vel&&(this.vel=new me.Vector2d),this.vel.set(0,0),"undefined"==typeof this.accel&&(this.accel=new me.Vector2d),this.accel.set(0,0),"undefined"==typeof this.friction&&(this.friction=new me.Vector2d),this.friction.set(0,0),"undefined"==typeof this.maxVel&&(this.maxVel=new me.Vector2d),this.maxVel.set(1e3,1e3),this.gravity="undefined"!=typeof me.sys.gravity?me.sys.gravity:.98,this.falling=!1,this.jumping=!1,me.Rect.prototype.init.apply(this,[0,0,a.width,a.height]);for(var c=0;c=1,this.jumping=b.y<=-1)},updateBounds:function(){if(this.shapes.length>0){var a=this.shapes[0].getBounds();this.pos.setV(a.pos),this.resize(a.width,a.height);for(var b=1;bc?c:d>0?d:0,a.y=0>f?f:g>0?g:0},computeVelocity:function(a){this.gravity&&(a.y+=this.gravity*me.timer.tick,this.falling=a.y>0,this.jumping=this.falling?!1:this.jumping),(this.friction.x||this.friction.y)&&this.applyFriction(a),0!==a.y&&(a.y=a.y.clamp(-this.maxVel.y,this.maxVel.y)),0!==a.x&&(a.x=a.x.clamp(-this.maxVel.x,this.maxVel.x))},update:function(){return this.computeVelocity(this.vel),this.entity.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},destroy:function(){this.entity=null,this.shapes=[]}}),me.Body.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Body.Error"}})}(),function(){function a(a,b,c,d){this.max_objects=b||4,this.max_levels=c||4,this.level=d||0,this.bounds=a,this.objects=[],this.nodes=[]}var b=[],c=function(a,c,d,e){if(b.length>0){var f=b.pop();return f.bounds=a,f.max_objects=c||4,f.max_levels=d||4,f.level=e||0,f}return new me.QuadTree(a,c,d,e)},d=function(a){b.push(a)},e=new me.Vector2d;a.prototype.split=function(){var a=this.level+1,b=~~(.5+this.bounds.width/2),d=~~(.5+this.bounds.height/2),e=~~(.5+this.bounds.pos.x),f=~~(.5+this.bounds.pos.y);this.nodes[0]=c({pos:{x:e+b,y:f},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[1]=c({pos:{x:e,y:f},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[2]=c({pos:{x:e,y:f+d},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[3]=c({pos:{x:e+b,y:f+d},width:b,height:d},this.max_objects,this.max_levels,a)},a.prototype.getIndex=function(a){var b=a.getBounds(),c=b.pos;(a.floating||a.ancestor&&a.ancestor.floating)&&(c=me.game.viewport.localToWorld(c.x,c.y,e));var d=-1,f=c.x,g=c.y,h=b.width,i=b.height,j=this.bounds.pos.x+this.bounds.width/2,k=this.bounds.pos.y+this.bounds.height/2,l=k>g&&k>g+i,m=g>k;return j>f&&j>f+h?l?d=1:m&&(d=2):f>j&&(l?d=0:m&&(d=3)),d},a.prototype.insertContainer=function(a){for(var b,c=a.children.length;c--,b=a.children[c];)b instanceof me.Container?("rootContainer"!==b.name&&this.insert(b),this.insertContainer(b)):"function"==typeof b.getBounds&&this.insert(b)},a.prototype.insert=function(a){var b=-1;if(this.nodes.length>0&&(b=this.getIndex(a),-1!==b))return void this.nodes[b].insert(a);if(this.objects.push(a),this.objects.length>this.max_objects&&this.level0){var d=this.getIndex(a);if(-1!==d)c=c.concat(this.nodes[d].retrieve(a));else for(var e=0;e0){var c=this.getIndex(a);-1!==c&&(b=this.nodes[c].remove(a),b&&this.nodes[c].isPrunable()&&this.nodes.splice(c,1))}return b===!1&&-1!==this.objects.indexOf(a)&&(this.objects.remove(a),b=!0),b},a.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},a.prototype.hasChildren=function(){for(var a=0;a0||b.objects.length>0)return!0}return!1},a.prototype.clear=function(a){this.objects.length=0;for(var b=0;bg;g++){var h=a[g].dotProduct(b);d>h&&(d=h),h>e&&(e=h)}c[0]=d,c[1]=e}function b(b,c,d,e,f,h){var j=i.pop(),k=i.pop(),l=g.pop().copy(c).sub(b),m=l.dotProduct(f);if(a(d,f,j),a(e,f,k),k[0]+=m,k[1]+=m,j[0]>k[1]||k[0]>j[1])return g.push(l),i.push(j),i.push(k),!0;if(h){var n=0;if(j[0]o?o:-p}else if(h.bInA=!1,j[1]>k[1])n=j[0]-k[1],h.aInB=!1;else{var q=j[1]-k[0],r=k[1]-j[0];n=r>q?q:-r}var s=Math.abs(n);sn&&h.overlapN.negateSelf())}return g.push(l),i.push(j),i.push(k),!1}function c(a,b){var c=a.length2(),g=b.dotProduct(a);return 0>g?d:g>c?f:e}for(var d=-1,e=0,f=1,g=[],h=0;10>h;h++)g.push(new me.Vector2d);for(var i=[],j=0;5>j;j++)i.push([]);me.collision=function(){var a={};return a.quadTree=null,a.maxDepth=4,a.maxChildren=8,a.bounds=null,a.types={NO_OBJECT:0,PLAYER_OBJECT:1,NPC_OBJECT:2,ENEMY_OBJECT:4,COLLECTABLE_OBJECT:8,ACTION_OBJECT:16,PROJECTILE_OBJECT:32,WORLD_SHAPE:64,USER:128,ALL_OBJECT:4294967295},a.init=function(){a.bounds=me.game.viewport.clone(),a.quadTree=new me.QuadTree(a.bounds,a.maxChildren,a.maxDepth),me.event.subscribe(me.event.LEVEL_LOADED,function(){a.bounds=me.game.world.clone(),a.quadTree.clear(a.bounds)})},a.ResponseObject=function(){this.a=null,this.b=null,this.overlapN=new me.Vector2d,this.overlapV=new me.Vector2d,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE},a.ResponseObject.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this},a.response=new a.ResponseObject,a.shouldCollide=function(a,b){return a.body&&b.body&&0!==(a.body.collisionMask&b.body.collisionType)&&0!==(a.body.collisionType&b.body.collisionMask)},a.check=function(b,c){for(var d,e=0,f=c||a.response,g=a.quadTree.retrieve(b),h=g.length;h--,d=g[h];)if(d!==b&&a.shouldCollide(b,d)&&b.getBounds().overlaps(d.getBounds())){var i=b.body.shapes.length,j=d.body.shapes.length;if(0===i||0===j)continue;var k=0;do{var l=b.body.getShape(k),m=0;do{var n=d.body.getShape(m);a["test"+l.shapeType+n.shapeType].call(this,b,l,d,n,f.clear())===!0&&(e++,f.indexShapeA=k,f.indexShapeB=m,b.onCollision(f,d)!==!1&&b.body.respondToCollision.call(b.body,f),d.onCollision(f,b)!==!1&&d.body.respondToCollision.call(d.body,f)),m++}while(j>m);k++}while(i>k)}return e>0},a.testPolygonPolygon=function(a,c,d,e,f){var h,i=c.points,j=c.normals,k=j.length,l=e.points,m=e.normals,n=m.length,o=g.pop().copy(a.pos).add(a.ancestor._absPos).add(c.pos),p=g.pop().copy(d.pos).add(d.ancestor._absPos).add(e.pos);for(h=0;k>h;h++)if(b(o,p,i,l,j[h],f))return g.push(o),g.push(p),!1;for(h=0;n>h;h++)if(b(o,p,i,l,m[h],f))return g.push(o),g.push(p),!1;return f&&(f.a=a,f.b=d,f.overlapV.copy(f.overlapN).scale(f.overlap)),g.push(o),g.push(p),!0},a.testEllipseEllipse=function(a,b,c,d,e){var f=g.pop().copy(c.pos).add(c.ancestor._absPos).add(d.pos).sub(a.pos).add(a.ancestor._absPos).sub(b.pos),h=b.radius,i=d.radius,j=h+i,k=j*j,l=f.length2();if(l>k)return g.push(f),!1;if(e){var m=Math.sqrt(l);e.a=a,e.b=c,e.overlap=j-m,e.overlapN.copy(f.normalize()),e.overlapV.copy(f).scale(e.overlap),e.aInB=i>=h&&i-h>=m,e.bInA=h>=i&&h-i>=m}return g.push(f),!0},a.testPolygonEllipse=function(a,b,e,h,i){for(var j=g.pop().copy(e.pos).add(e.ancestor._absPos).add(h.pos).sub(a.pos).add(a.ancestor._absPos).sub(b.pos),k=h.radius,l=k*k,m=b.points,n=b.edges,o=n.length,p=g.pop(),q=g.pop(),r=g.pop(),s=0,t=0;o>t;t++){var u=t===o-1?0:t+1,v=0===t?o-1:t-1,w=0,x=null;p.copy(n[t]),r.copy(j).sub(m[t]),i&&r.length2()>l&&(i.aInB=!1);var y=c(p,r),z=!0;if(y===d){var A=null;if(o>1&&(p.copy(n[v]),A=g.pop().copy(j).sub(m[v]),y=c(p,A),y!==f&&(z=!1)),z){if(s=r.length(),s>k)return g.push(j),g.push(p),g.push(q),g.push(r),A&&g.push(A),!1;i&&(i.bInA=!1,x=r.normalize(),w=k-s)}A&&g.push(A)}else if(y===f){if(o>1&&(p.copy(n[u]),r.copy(j).sub(m[u]),y=c(p,r),y!==d&&(z=!1)),z){if(s=r.length(),s>k)return g.push(j),g.push(p),g.push(q),g.push(r),!1;i&&(i.bInA=!1,x=r.normalize(),w=k-s)}}else{q.copy(b.normals[t]),s=r.dotProduct(q);var B=Math.abs(s);if((1===o||s>0)&&B>k)return g.push(j),g.push(p),g.push(q),g.push(r),!1;i&&(x=q,w=k-s,(s>=0||2*k>w)&&(i.bInA=!1))}x&&i&&Math.abs(w)e;e++){var g,h=b[e];g="number"==typeof h||"string"==typeof h?{name:h,delay:c||this.animationspeed}:h;var i=g.name;if("number"==typeof i)"undefined"!=typeof this.textureAtlas[i]&&(this.anim[a].frames[e]=Object.assign({},this.textureAtlas[i],g),d++);else{if(null===this.atlasIndices)throw new me.Renderable.Error("string parameters for addAnimation are not allowed for standard spritesheet based Texture");this.anim[a].frames[e]=Object.assign({},this.textureAtlas[this.atlasIndices[i]],g),d++}}return this.anim[a].length=d,d},setCurrentAnimation:function(a,b,c){if(!this.anim[a])throw new me.Renderable.Error("animation id '"+a+"' not defined");this.current=this.anim[a],this.resetAnim=b||null,this.setAnimationFrame(this.current.idx),this.current.name=a,c||(this.dt=0)},isCurrentAnimation:function(a){return this.current.name===a},setAnimationFrame:function(a){this.current.idx=(a||0)%this.current.length;var b=this.getAnimationFrameObjectByIndex(this.current.idx);Object.assign(this.current,b),b.anchorPoint&&this.anchorPoint.setV(b.anchorPoint)},getCurrentAnimationFrame:function(){return this.current.idx},getAnimationFrameObjectByIndex:function(a){return this.current.frames[a]},update:function(a){var b=!1;if(!this.animationpause&&this.current&&this.current.length>1){var c=this.getAnimationFrameObjectByIndex(this.current.idx).delay;for(this.dt+=a;this.dt>=c;){if(b=!0,this.dt-=c,this.setAnimationFrame(this.current.idx+1),0===this.current.idx&&this.resetAnim)if("string"==typeof this.resetAnim)this.setCurrentAnimation(this.resetAnim,null,!0);else if(this.resetAnim()===!1){this.setAnimationFrame(this.current.length-1),this.dt%=c;break}c=this.getAnimationFrameObjectByIndex(this.current.idx).delay}}return this._flicker.isFlickering&&(this._flicker.duration-=a,this._flicker.duration<0&&("function"==typeof this._flicker.callback&&this._flicker.callback(),this.flicker(-1)),b=!0),b},draw:function(a){if(!this._flicker.isFlickering||(this._flicker.state=!this._flicker.state,this._flicker.state)){var b=this.current,c=this.pos.x,d=this.pos.y,e=b.width,f=b.height,g=b.offset;a.save(),a.setGlobalAlpha(a.globalAlpha()*this.getOpacity()),this.currentTransform.isIdentity()||a.transform(this.currentTransform),a.translate(-(e*this.anchorPoint.x),-(f*this.anchorPoint.y)),0!==b.angle&&(a.translate(-c,-d),a.rotate(b.angle),c-=f,e=b.height,f=b.width),a.drawImage(this.image,g.x,g.y,e,f,c,d,e,f),a.restore()}}}),Object.defineProperty(me.Sprite.prototype,"offset",{get:function(){return this.current.offset},set:function(a){this.current.offset.setV(a)},configurable:!0}),me.AnimationSheet=me.Sprite}(),function(){var a=Math.min,b=Math.max;me.Viewport=me.Renderable.extend({init:function(a,b,c,d){me.Renderable.prototype.init.apply(this,[a,b,c-a,d-b]),this.AXIS={NONE:0,HORIZONTAL:1,VERTICAL:2,BOTH:3},this.bounds=new me.Rect(-(1/0),-(1/0),1/0,1/0),this.offset=new me.Vector2d,this.target=null,this.follow_axis=this.AXIS.NONE,this._shake={intensity:0,duration:0,axis:this.AXIS.BOTH,onComplete:null},this._fadeOut={color:null,tween:null},this._fadeIn={color:null,tween:null},this.setDeadzone(this.width/6,this.height/6)},_followH:function(c){var d=this.pos.x;return c.x-this.pos.x>this.deadzone.right?this.pos.x=a(c.x-this.deadzone.right,this.bounds.width-this.width):c.x-this.pos.xthis.deadzone.bottom?this.pos.y=a(c.y-this.deadzone.bottom,this.bounds.height-this.height):c.y-this.pos.y0&&(this._shake.duration-=a,this._shake.duration<=0?(this._shake.duration=0,this.offset.setZero(),"function"==typeof this._shake.onComplete&&this._shake.onComplete()):(this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.HORIZONTAL||(this.offset.x=(Math.random()-.5)*this._shake.intensity),this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.VERTICAL||(this.offset.y=(Math.random()-.5)*this._shake.intensity)),b=!0),b===!0&&me.event.publish(me.event.VIEWPORT_ONCHANGE,[this.pos]),null==this._fadeIn.tween&&null==this._fadeOut.tween||(b=!0),b},shake:function(a,b,c,d,e){0!==this._shake.duration&&e!==!0||(this._shake.intensity=a,this._shake.duration=b,this._shake.axis=c||this.AXIS.BOTH,this._shake.onComplete="function"==typeof d?d:void 0)},fadeOut:function(a,b,c){this._fadeOut.color=me.pool.pull("me.Color").copy(a),this._fadeOut.tween=me.pool.pull("me.Tween",this._fadeOut.color).to({alpha:0},b||1e3).onComplete(c||null),this._fadeOut.tween.isPersistent=!0,this._fadeOut.tween.start()},fadeIn:function(a,b,c){this._fadeIn.color=me.pool.pull("me.Color").copy(a);var d=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=me.pool.pull("me.Tween",this._fadeIn.color).to({alpha:d},b||1e3).onComplete(c||null),this._fadeIn.tween.isPersistent=!0,this._fadeIn.tween.start()},getWidth:function(){return this.width},getHeight:function(){return this.height},focusOn:function(a){var b=a.getBounds();this.moveTo(a.pos.x+b.pos.x+b.width/2,a.pos.y+b.pos.y+b.height/2)},isVisible:function(a){return a.overlaps(this)},localToWorld:function(a,b,c){return c=c||new me.Vector2d,c.set(a,b).add(this.pos).sub(me.game.world.pos)},worldToLocal:function(a,b,c){return c=c||new me.Vector2d,c.set(a,b).sub(this.pos).add(me.game.world.pos)},draw:function(){this._fadeIn.tween&&(me.video.renderer.clearColor(this._fadeIn.color),1===this._fadeIn.color.alpha&&(this._fadeIn.tween=null,me.pool.push(this._fadeIn.color),this._fadeIn.color=null)),this._fadeOut.tween&&(me.video.renderer.clearColor(this._fadeOut.color),0===this._fadeOut.color.alpha&&(this._fadeOut.tween=null,me.pool.push(this._fadeOut.color),this._fadeOut.color=null))}})}(),function(){me.GUI_Object=me.Sprite.extend({init:function(a,b,c){this.isClickable=!0,this.holdThreshold=250,this.isHoldable=!1,this.hover=!1,this.holdTimeout=null,this.updated=!1,this.released=!0,me.Sprite.prototype.init.apply(this,[a,b,c]),this.floating=!0},update:function(){return this.updated?(this.released||(this.updated=!1),!0):!1},clicked:function(a){return(1===a.which||me.device.touch)&&this.isClickable?(this.updated=!0,this.released=!1,this.isHoldable&&(null!==this.holdTimeout&&me.timer.clearTimeout(this.holdTimeout),this.holdTimeout=me.timer.setTimeout(this.hold.bind(this),this.holdThreshold,!1),this.released=!1),this.onClick(a)):void 0},onClick:function(){return!1},enter:function(a){return this.hover=!0,this.onOver(a)},onOver:function(){},leave:function(a){return this.hover=!1,this.release.call(this,a),this.onOut(a)},onOut:function(){},release:function(a){return this.released===!1?(this.released=!0,me.timer.clearTimeout(this.holdTimeout),this.onRelease(a)):void 0},onRelease:function(){return!1},hold:function(){me.timer.clearTimeout(this.holdTimeout),this.released||this.onHold()},onHold:function(){},onActivateEvent:function(){me.input.registerPointerEvent("pointerdown",this,this.clicked.bind(this)),me.input.registerPointerEvent("pointerup",this,this.release.bind(this)),me.input.registerPointerEvent("pointercancel",this,this.release.bind(this)),me.input.registerPointerEvent("pointerenter",this,this.enter.bind(this)),me.input.registerPointerEvent("pointerleave",this,this.leave.bind(this)); +},onDeactivateEvent:function(){me.input.releasePointerEvent("pointerdown",this),me.input.releasePointerEvent("pointerup",this),me.input.releasePointerEvent("pointercancel",this),me.input.releasePointerEvent("pointerenter",this),me.input.releasePointerEvent("pointerleave",this),me.timer.clearTimeout(this.holdTimeout)}})}(),function(){var a=function(a,b){this.removeChildNow(a,b)},b=0;me.Container=me.Renderable.extend({init:function(a,b,c,d){this.pendingSort=null,this._root=!1,me.Renderable.prototype.init.apply(this,[a||0,b||0,c||1/0,d||1/0]),this.children=[],this.sortOn=me.game.sortOn,this.autoSort=!0,this.autoDepth=!0,this.drawCount=0,this.childBounds=this.getBounds().clone(),this.autoTransform=!1},addChild:function(a,b){return a.ancestor instanceof me.Container?a.ancestor.removeChildNow(a):a.isRenderable&&(a.GUID=me.utils.createGUID(a.id)),a.ancestor=this,this.children.push(a),"undefined"!=typeof a.pos&&("number"==typeof b?a.pos.z=b:this.autoDepth===!0&&(a.pos.z=this.children.length)),this.autoSort===!0&&this.sort(),"function"==typeof a.onActivateEvent&&this.isAttachedToRoot()&&a.onActivateEvent(),a},addChildAt:function(a,b){if(b>=0&&b1&&(c=b);e>d;)a.call(c,this.children[d],d,this.children),d++},swapChildren:function(a,b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(-1===c||-1===d)throw new me.Container.Error(a+" Both the supplied childs must be a child of the caller "+this);var e=a.pos.z;a.pos.z=b.pos.z,b.pos.z=e,this.children[c]=b,this.children[d]=a},getChildAt:function(a){if(a>=0&&a=0;e--){var f=this.children[e];c(f,a),f instanceof me.Container&&(d=d.concat(f.getChildByProp(a,b)))}return d},getChildByType:function(a){for(var b=[],c=this.children.length-1;c>=0;c--){var d=this.children[c];d instanceof a&&b.push(d),d instanceof me.Container&&(b=b.concat(d.getChildByType(a)))}return b},getChildByName:function(a){return this.getChildByProp("name",a)},getChildByGUID:function(a){var b=this.getChildByProp("GUID",a);return b.length>0?b[0]:null},updateChildBounds:function(){this.childBounds.pos.set(1/0,1/0),this.childBounds.resize(-(1/0),-(1/0));for(var a,b,c=this.children.length;c--,b=this.children[c];)b.isRenderable&&(a=b instanceof me.Container?b.childBounds:b.getBounds(),null!==a&&this.childBounds.union(a));return this.childBounds},isAttachedToRoot:function(){if(this._root)return!0;for(var a=this.ancestor;a;){if(a._root===!0)return!0;a=a.ancestor}return!1},updateBoundsPos:function(a,b){me.Renderable.prototype.updateBoundsPos.apply(this,[a,b]),this._absPos.set(a,b),this.ancestor&&this._absPos.add(this.ancestor._absPos);for(var c,d=this.children.length;d--,c=this.children[d];)c.isRenderable&&c.updateBoundsPos(c.pos.x,c.pos.y);return this.getBounds()},onActivateEvent:function(){for(var a,b=this.children.length;b--,a=this.children[b];)"function"==typeof a.onActivateEvent&&a.onActivateEvent()},removeChild:function(b,c){if(!this.hasChild(b))throw new me.Container.Error("Child is not mine.");a.defer(this,b,c)},removeChildNow:function(a,b){if(this.hasChild(a)&&this.getChildIndex(a)>=0){"function"==typeof a.onDeactivateEvent&&a.onDeactivateEvent(),b||("function"==typeof a.destroy&&a.destroy(),me.pool.push(a));var c=this.getChildIndex(a);c>=0&&(this.children.splice(c,1),a.ancestor=void 0)}},setChildsProperty:function(a,b,c){for(var d=this.children.length;d>=0;d--){var e=this.children[d];c===!0&&e instanceof me.Container&&e.setChildsProperty(a,b,c),e[a]=b}},moveUp:function(a){var b=this.getChildIndex(a);b-1>=0&&this.swapChildren(a,this.getChildAt(b-1))},moveDown:function(a){var b=this.getChildIndex(a);b>=0&&b+10&&(this.children.splice(0,0,this.children.splice(b,1)[0]),a.pos.z=this.children[1].pos.z+1)},moveToBottom:function(a){var b=this.getChildIndex(a);b>=0&&b=0;a=this.children[--b])a&&!a.isPersistent&&this.removeChildNow(a);this.currentTransform.identity()},update:function(a){me.Renderable.prototype.update.apply(this,[a]);var c=!1,d=!1,e=me.state.isPaused(),f=me.game.viewport;this._absPos.setV(this.pos),this.ancestor&&this._absPos.add(this.ancestor._absPos);for(var g,h=this.children.length;h--,g=this.children[h];)e&&!g.updateWhenPaused||(g.isRenderable?(d=b>0||g.floating,d&&b++,g.inViewport=d||f.isVisible(g.getBounds()),c=(g.inViewport||g.alwaysUpdate)&&g.update(a)||c,g._absPos.setV(this._absPos).add(g.pos),b>0&&b--):c=g.update(a)||c);return c},draw:function(a,b){var c=!1,d=!1,e=0,f=0;this.drawCount=0,a.save(),a.translate(this.pos.x,this.pos.y),this.currentTransform.isIdentity()||a.transform(this.currentTransform),a.setGlobalAlpha(a.globalAlpha()*this.getOpacity());for(var g,h=this.children.length;h--,g=this.children[h];)if(c=g.floating===!0,(g.inViewport||c)&&g.isRenderable){if(d=!g.currentTransform.isIdentity(),c)a.save(),a.resetTransform();else if(g.autoTransform===!0){var i=g.getBounds(),j=g.anchorPoint;e=i.width*j.x,f=i.height*j.y,d?(a.save(),g.currentTransform.translate(e,f),a.transform(g.currentTransform)):a.translate(e,f)}g.draw(a,b),c?a.restore():g.autoTransform===!0&&(d?(g.currentTransform.translate(-e,-f),a.restore()):a.translate(-e,-f)),this.drawCount++}a.restore()}}),me.Container.Error=me.Renderable.Error.extend({init:function(a){me.Renderable.Error.prototype.init.apply(this,[a]),this.name="me.Container.Error"}})}(),function(){me.Entity=me.Renderable.extend({init:function(a,b,c){if(this.renderable=null,"number"!=typeof c.width||"number"!=typeof c.height)throw new me.Entity.Error("height and width properties are mandatory when passing settings parameters to an object entity");me.Renderable.prototype.init.apply(this,[a,b,c.width,c.height]),c.image&&(this.renderable=new me.Sprite(0,0,{image:c.image,framewidth:~~(c.framewidth||c.width),frameheight:~~(c.frameheight||c.height),spacing:~~c.spacing,margin:~~c.margin,anchorPoint:c.anchorPoint})),c.anchorPoint&&this.anchorPoint.set(c.anchorPoint.x,c.anchorPoint.y),this.name=c.name||"",this.type=c.type||"",this.id=c.id||"",this.alive=!0;var d=Array.isArray(c.shapes)?c.shapes:[new me.Rect(0,0,this.width,this.height)];this.body?this.body.init(this,d):this.body=new me.Body(this,d);var e=this.body.updateBounds();if(0===this.width&&0===this.height&&this.resize(e.width,e.height),"undefined"!=typeof c.collisionMask&&this.body.setCollisionMask(c.collisionMask),"undefined"!=typeof c.collisionType){if("undefined"==typeof me.collision.types[c.collisionType])throw new me.Entity.Error("Invalid value for the collisionType property");this.body.collisionType=me.collision.types[c.collisionType]}this.autoTransform=!1},distanceTo:function(a){var b=this.getBounds(),c=a.getBounds(),d=b.pos.x+b.width/2-(c.pos.x+c.width/2),e=b.pos.y+b.height/2-(c.pos.y+c.height/2);return Math.sqrt(d*d+e*e)},distanceToPoint:function(a){var b=this.getBounds(),c=b.pos.x+b.width/2-a.x,d=b.pos.y+b.height/2-a.y;return Math.sqrt(c*c+d*d)},angleTo:function(a){var b=this.getBounds(),c=a.getBounds(),d=c.pos.x+c.width/2-(b.pos.x+b.width/2),e=c.pos.y+c.height/2-(b.pos.y+b.height/2);return Math.atan2(e,d)},angleToPoint:function(a){var b=this.getBounds(),c=a.x-(b.pos.x+b.width/2),d=a.y-(b.pos.y+b.height/2);return Math.atan2(d,c)},update:function(a){return this.renderable?this.renderable.update(a):me.Renderable.prototype.update.apply(this,[a])},updateBoundsPos:function(a,b){var c=this.body.pos;return me.Renderable.prototype.updateBoundsPos.apply(this,[a+c.x,b+c.y]),this.getBounds()},onBodyUpdate:function(a,b,c){var d=this.getBounds();d.pos.setV(this.pos).add(a),this.ancestor&&d.pos.add(this.ancestor._absPos),d.resize(b,c)},draw:function(a){var b=this.renderable;if(b instanceof me.Renderable){var c=this.anchorPoint.x*this.body.width,d=this.anchorPoint.y*this.body.height,e=this.pos.x+this.body.pos.x+c,f=this.pos.y+this.body.pos.y+d;if(a.translate(e,f),b.autoTransform!==!0||b.currentTransform.isIdentity())b.draw(a);else{var g=b.getBounds(),h=g.width*b.anchorPoint.x,i=g.height*b.anchorPoint.y;a.save(),a.translate(h,i),a.transform(b.currentTransform),a.translate(-h,-i),b.draw(a),a.restore()}a.translate(-e,-f)}},destroy:function(){this.renderable&&(this.renderable.destroy.apply(this.renderable,arguments),this.renderable=null),this.body.destroy.apply(this.body,arguments),this.body=null,me.Renderable.prototype.destroy.apply(this,arguments)},onDeactivateEvent:function(){this.renderable&&this.renderable.onDeactivateEvent&&this.renderable.onDeactivateEvent()},onCollision:function(){return!1}}),me.Entity.Error=me.Renderable.Error.extend({init:function(a){me.Renderable.Error.prototype.init.apply(this,[a]),this.name="me.Entity.Error"}})}(),function(){me.ScreenObject=me.Object.extend({init:function(){},reset:function(){me.game.reset(),this.onResetEvent.apply(this,arguments)},destroy:function(){this.onDestroyEvent.apply(this,arguments)},onResetEvent:function(){},onDestroyEvent:function(){}}),function(){var a=0,b=1e3/60,c=me.agent.prefixed("requestAnimationFrame"),d=me.agent.prefixed("cancelAnimationFrame")||me.agent.prefixed("cancelRequestAnimationFrame");c&&d||(c=function(c){var d=window.performance.now(),e=Math.max(0,b-(d-a)),f=window.setTimeout(function(){c(d+e)},e);return a=d+e,f},d=function(a){window.clearTimeout(a)}),window.requestAnimationFrame=c,window.cancelAnimationFrame=d}(),me.state=function(){function a(){-1===i&&-1!==h&&(me.timer.reset(),i=window.requestAnimationFrame(d))}function b(){j&&-1!==h&&(me.timer.reset(),j=!1)}function c(){j=!0}function d(a){me.game.update(a),me.game.draw(),-1!==i&&(i=window.requestAnimationFrame(d))}function e(){window.cancelAnimationFrame(i),i=-1}function f(b){e(),k[h]&&k[h].screen.destroy(),k[b]&&(h=b,k[h].screen.reset.apply(k[h].screen,n),a(),m&&m(),me.game.repaint())}var g={},h=-1,i=-1,j=!1,k={},l={color:"",duration:0},m=null,n=null,o=0;return g.LOADING=0,g.MENU=1,g.READY=2,g.PLAY=3,g.GAMEOVER=4,g.GAME_END=5,g.SCORE=6,g.CREDITS=7,g.SETTINGS=8,g.USER=100,g.onPause=null,g.onResume=null,g.onStop=null,g.onRestart=null,g.init=function(){g.set(g.LOADING,new me.DefaultLoadingScreen)},g.stop=function(a){h!==g.LOADING&&g.isRunning()&&(e(),a===!0&&me.audio.pauseTrack(),o=window.performance.now(),me.event.publish(me.event.STATE_STOP),"function"==typeof g.onStop&&g.onStop())},g.pause=function(a){h===g.LOADING||g.isPaused()||(c(),a===!0&&me.audio.pauseTrack(),o=window.performance.now(),me.event.publish(me.event.STATE_PAUSE),"function"==typeof g.onPause&&g.onPause())},g.restart=function(b){g.isRunning()||(a(),b===!0&&me.audio.resumeTrack(),o=window.performance.now()-o,me.game.repaint(),me.event.publish(me.event.STATE_RESTART,[o]),"function"==typeof g.onRestart&&g.onRestart())},g.resume=function(a){g.isPaused()&&(b(),a===!0&&me.audio.resumeTrack(),o=window.performance.now()-o,me.event.publish(me.event.STATE_RESUME,[o]),"function"==typeof g.onResume&&g.onResume())},g.isRunning=function(){return-1!==i},g.isPaused=function(){return j},g.set=function(a,b){k[a]={},k[a].screen=b,k[a].transition=!0},g.current=function(){return k[h].screen},g.transition=function(a,b,c){"fade"===a&&(l.color=b,l.duration=c)},g.setTransition=function(a,b){k[a].transition=b},g.change=function(a){if("undefined"==typeof k[a])throw new me.Error("Undefined ScreenObject for state '"+a+"'");g.isCurrent(a)||(n=null,arguments.length>1&&(n=Array.prototype.slice.call(arguments,1)),l.duration&&k[a].transition?(m=function(){me.game.viewport.fadeOut(l.color,l.duration)},me.game.viewport.fadeIn(l.color,l.duration,function(){f.defer(this,a)})):f.defer(this,a))},g.isCurrent=function(a){return h===a},g}()}(),function(){var a=me.Renderable.extend({init:function(a,b,c){me.Renderable.prototype.init.apply(this,[a.x,a.y,b,c]),this.invalidate=!1,this.barHeight=4,this.progress=0},onProgressUpdate:function(a){this.progress=~~(a*this.width),this.invalidate=!0},update:function(){return this.invalidate===!0?(this.invalidate=!1,!0):!1},draw:function(a){a.setColor("black"),a.fillRect(0,this.height/2-this.barHeight/2,this.width,this.barHeight),a.setColor("#55aa00"),a.fillRect(2,this.height/2-this.barHeight/2,this.progress,this.barHeight),a.setColor("white")}}),b=me.Renderable.extend({init:function(a,b,c){me.Renderable.prototype.init.apply(this,[b,c,100,85]),this.iconCanvas=a;var d=me.video.renderer.getContext2d(this.iconCanvas);d.translate(this.pos.x,this.pos.y),d.beginPath(),d.moveTo(.7,48.9),d.bezierCurveTo(10.8,68.9,38.4,75.8,62.2,64.5),d.bezierCurveTo(86.1,53.1,97.2,27.7,87,7.7),d.lineTo(87,7.7),d.bezierCurveTo(89.9,15.4,73.9,30.2,50.5,41.4),d.bezierCurveTo(27.1,52.5,5.2,55.8,.7,48.9),d.lineTo(.7,48.9),d.lineTo(.7,48.9),d.closePath(),d.fillStyle="rgb(255, 255, 255)",d.fill(),d.beginPath(),d.moveTo(84,7),d.bezierCurveTo(87.6,14.7,72.5,30.2,50.2,41.6),d.bezierCurveTo(27.9,53,6.9,55.9,3.2,48.2),d.bezierCurveTo(-.5,40.4,14.6,24.9,36.9,13.5),d.bezierCurveTo(59.2,2.2,80.3,-.8,84,7),d.lineTo(84,7),d.closePath(),d.lineWidth=5.3,d.strokeStyle="rgb(255, 255, 255)",d.lineJoin="miter",d.miterLimit=4,d.stroke()},draw:function(a){a.drawImage(this.iconCanvas,0,0)}}),c=me.Renderable.extend({init:function(a,b){me.Renderable.prototype.init.apply(this,[0,0,a,b]),this.logo1=new me.Font("century gothic",32,"white","middle"),this.logo2=new me.Font("century gothic",32,"#55aa00","middle"),this.logo2.bold(),this.logo1.textBaseline=this.logo2.textBaseline="alphabetic"},draw:function(a){var b=this.logo1.measureText(a,"melon").width,c=(this.width-b-this.logo2.measureText(a,"JS").width)/2,d=this.height/2+this.logo2.measureText(a,"melon").height;this.logo1.draw(a,"melon",c,d),c+=b,this.logo2.draw(a,"JS",c,d)}});me.DefaultLoadingScreen=me.ScreenObject.extend({onResetEvent:function(){me.game.world.addChild(new me.ColorLayer("background","#202020",0),0);var d=new a(new me.Vector2d,me.video.renderer.getWidth(),me.video.renderer.getHeight());this.loaderHdlr=me.event.subscribe(me.event.LOADER_PROGRESS,d.onProgressUpdate.bind(d)),this.resizeHdlr=me.event.subscribe(me.event.VIEWPORT_ONRESIZE,d.resize.bind(d)),me.game.world.addChild(d,1),this.iconCanvas=me.video.createCanvas(me.game.viewport.width,me.game.viewport.height,!1);var e=new b(this.iconCanvas,(me.video.renderer.getWidth()-100)/2,me.video.renderer.getHeight()/2-d.barHeight/2-90);me.game.world.addChild(e,1),me.game.world.addChild(new c(me.video.renderer.getWidth(),me.video.renderer.getHeight()),1)},onDestroyEvent:function(){me.event.unsubscribe(this.loaderHdlr),me.event.unsubscribe(this.resizeHdlr),this.loaderHdlr=this.resizeHdlr=null}})}(),function(){me.loader=function(){function a(){l===k?f.onload?(clearTimeout(m),setTimeout(function(){f.onload(),me.event.publish(me.event.LOADER_COMPLETE)},300)):console.error("no load callback defined"):m=setTimeout(a,100)}function b(a,b,c){g[a.name]=new Image,g[a.name].onload=b,g[a.name].onerror=c,g[a.name].src=a.src+f.nocache}function c(a,b,c){function d(b){h[a.name]=b,"tmx"===a.type&&me.levelDirector.addTMXLevel(a.name)}if(a.data)return d(a.data),void b();var e=new XMLHttpRequest,g=me.utils.getFileExtension(a.src);e.overrideMimeType&&("json"===g?e.overrideMimeType("application/json"):e.overrideMimeType("text/xml")),e.open("GET",a.src+f.nocache,!0),e.ontimeout=c,e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status||0===e.status&&e.responseText){var a=null;switch(g){case"xml":case"tmx":case"tsx":if(me.device.ua.match(/msie/i)||!e.responseXML){if(!window.DOMParser)throw new f.Error("XML file format loading not supported, use the JSON file format instead");a=(new DOMParser).parseFromString(e.responseText,"text/xml")}else a=e.responseXML;var h=me.TMXUtils.parse(a);switch(g){case"tmx":a=h.map;break;case"tsx":a=h.tilesets[0]}break;case"json":a=JSON.parse(e.responseText);break;default:throw new f.Error("TMX file format "+g+"not supported !")}d(a),b()}else c()},e.send(null)}function d(a,b,c){var d=new XMLHttpRequest;d.overrideMimeType&&d.overrideMimeType("application/json"),d.open("GET",a.src+f.nocache,!0),d.ontimeout=c,d.onreadystatechange=function(){4===d.readyState&&(200===d.status||0===d.status&&d.responseText?(j[a.name]=JSON.parse(d.responseText),b()):c())},d.send(null)}function e(a,b,c){var d=new XMLHttpRequest;d.open("GET",a.src+f.nocache,!0),d.responseType="arraybuffer",d.onerror=c,d.onload=function(){var c=d.response;if(c){for(var e=new Uint8Array(c),f=[],g=0;gn;n++){var p=k.charCodeAt(n),q=this.bitmapFontData.glyphs[p],r=m&&m.kerning?m.getKerning(p):0;0!==q.width&&0!==q.height&&b.drawImage(this.fontImage,q.src.x,q.src.y,q.width,q.height,d+q.offset.x,e+q.offset.y*this.fontScale.y,q.width*this.fontScale.x,q.height*this.fontScale.y),d+=(q.xadvance+r)*this.fontScale.x,m=q}e+=h}b.setGlobalAlpha(i)}})}(),me.BitmapFontData=me.Object.extend({init:function(a){this.padTop=0,this.padRight=0,this.padBottom=0,this.padLeft=0,this.lineHeight=0,this.capHeight=1,this.descent=0,this.scale=new me.Vector2d,this.glyphs={},this.xChars=["x","e","a","o","n","s","r","c","u","m","v","w","z"],this.capChars=["M","N","B","D","C","E","F","K","A","G","H","I","J","L","O","P","Q","R","S","T","U","V","W","X","Y","Z"],this.parse(a)},_createSpaceGlyph:function(){var a=" ".charCodeAt(0),b=this.glyphs[a];b||(b=me.pool.pull("me.Glyph"),b.id=a,b.xadvance=this._getFirstGlyph().xadvance,this.glyphs[a]=b)},_getFirstGlyph:function(){for(var a=Object.keys(this.glyphs),b=0;b32)return this.glyphs[a[b]];return null},_getValueFromPair:function(a,b){var c=a.match(b);if(!c)throw"Could not find pattern "+b+" in string: "+a;return c[0].split("=")[1]},parse:function(a){if(!a)throw"File containing font data was empty, cannot load the bitmap font.";var b=a.split(/\r\n|\n/),c=a.match(/padding\=\d+,\d+,\d+,\d+/g);if(!c)throw"Padding not found in first line";var d=c[0].split("=")[1].split(",");this.padTop=parseFloat(d[0]),this.padLeft=parseFloat(d[1]),this.padBottom=parseFloat(d[2]),this.padRight=parseFloat(d[3]),this.lineHeight=parseFloat(this._getValueFromPair(b[1],/lineHeight\=\d+/g));for(var e=parseFloat(this._getValueFromPair(b[1],/base\=\d+/g)),f=this.padTop+this.padBottom,g=null,h=4;h0&&g.height>0&&(this.descent=Math.min(e+g.yoffset,this.descent)),this.glyphs[n]=g}}this.descent+=this.padBottom,this._createSpaceGlyph();var p=null;for(h=0;h>>a];if(d)return d[c&b-1]||0}return 0},setKerning:function(c,d){this.kerning||(this.kerning={});var e=this.kerning[c>>>a];"undefined"==typeof e&&(this.kerning[c>>>a]={},e=this.kerning[c>>>a]),e[c&b-1]=d}})}(),function(){me.audio=function(){function a(a,d){if(e++>3){var f="melonJS: failed loading "+a;if(me.sys.stopOnAudioError!==!1)throw new b.Error(f);me.audio.disable(),d&&d(),console.log(f+", disabling audio")}else c[a].load()}var b={},c={},d=null,e=0;return b.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.audio.Error"}}),b.init=function(a){if(!me.initialized)throw new b.Error("me.audio.init() called before engine initialization.");return a="string"==typeof a?a:"mp3",this.audioFormats=a.split(","),!Howler.noAudio},b.enable=function(){this.unmuteAll()},b.disable=function(){this.muteAll()},b.load=function(d,f,g,h){var i=[];if("undefined"==typeof this.audioFormats||0===this.audioFormats.length)throw new b.Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");for(var j=0;j1&&(c.style.width=c.width/m+"px", +c.style.height=c.height/m+"px"),window.getComputedStyle){var n=window.getComputedStyle(c,null);me.video.setMaxSize(parseInt(n.maxWidth,10),parseInt(n.maxHeight,10))}return me.game.init(),me.video.onresize(),!0},b.getPos=function(a){return a=a||this.renderer.getScreenCanvas(),a.getBoundingClientRect?a.getBoundingClientRect():{left:0,top:0}},b.setMaxSize=function(a,b){h=a||1/0,i=b||1/0,this.onresize.defer(this)},b.createCanvas=function(a,d,e){if(0===a||0===d)throw new b.Error("width or height was zero, Canvas could not be initialized !");var f=document.createElement("canvas");return e===!0&&me.device.cocoon&&me.device.android2!==!0&&(f.screencanvas=!0),f.width=a||c.width,f.height=d||c.height,f},b.getWrapper=function(){return j.wrapper},b.onresize=function(){var a=1,b=1;if("undefined"!=typeof window.orientation?me.device.orientation=window.orientation:me.device.orientation=window.outerWidth>window.outerHeight?90:0,j.autoScale){var c,k,l=me.video.renderer.getScreenCanvas().parentNode;"undefined"!=typeof l&&(c=l.width,k=l.height);var m=Math.min(h,c||window.innerWidth),n=Math.min(i,k||window.innerHeight),o=m/n,p=1/0,q=1/0;"fill-min"===j.scaleMethod&&o>e||"fill-max"===j.scaleMethod&&e>o||"flex-width"===j.scaleMethod?(p=Math.min(h,g*o),a=b=m/p,p=~~(p+.5),this.renderer.resize(p,g),me.game.viewport.resize(p,g),me.game.world.updateChildBounds()):"fill-min"===j.scaleMethod&&e>o||"fill-max"===j.scaleMethod&&o>e||"flex-height"===j.scaleMethod?(q=Math.min(i,f*(n/m)),a=b=n/q,q=~~(q+.5),this.renderer.resize(f,q),me.game.viewport.resize(f,q),me.game.world.updateChildBounds()):"flex"===j.scaleMethod?(this.renderer.resize(m,n),me.game.viewport.resize(m,n),me.game.world.updateChildBounds()):"stretch"===j.scaleMethod?(a=m/f,b=n/g):a=b=e>o?m/f:n/g,a*=me.device.getPixelRatio(),b*=me.device.getPixelRatio(),d&&clearTimeout(d),d=me.video.updateDisplaySize.defer(this,a,b)}},b.updateDisplaySize=function(a,b){me.sys.scale.set(a,b),this.renderer.scaleCanvas(a,b),me.game.repaint(),me.input._offset=me.video.getPos(),d=0},b}()}(),function(){me.Renderer=me.Object.extend({init:function(a,b,c,d){return d=d||{},this.transparent=!!d.transparent,this.doubleBuffering=!!d.doubleBuffering,this.antiAlias=!!d.antiAlias,this.subPixel=!!d.subPixel,this.verbose=!!d.verbose,this.gameWidthZoom=d.zoomX||b,this.gameHeightZoom=d.zoomY||c,this.canvas=this.backBufferCanvas=a,this.context=null,this.currentColor=new me.Color(255,255,255,1),this.uvOffset=0,this},applyRGBFilter:function(a,b,c){var d,e,f=this.getContext2d(me.video.createCanvas(a.width,a.height,!1)),g=me.utils.getPixels(a),h=g.data;switch(b){case"b&w":for(d=0,e=h.length;e>d;d+=4){var i=3*h[d]+4*h[d+1]+h[d+2]>>>3;h[d]=i,h[d+1]=i,h[d+2]=i}break;case"brightness":var j=Math.abs(c).clamp(0,1);for(d=0,e=h.length;e>d;d+=4)h[d]*=j,h[d+1]*=j,h[d+2]*=j;break;case"transparent":var k=me.pool.pull("me.Color").parseCSS(c),l=me.pool.pull("me.Color");for(d=0,e=h.length;e>d;d+=4)l.setColor(h[d],h[d+1],h[d+2]),l.equals(k)&&(h[d+3]=0);me.pool.push(k),me.pool.push(l);break;default:return null}return f.putImageData(g,0,0),f},clear:function(){},reset:function(){this.resetTransform(),this.cache.reset()},getCanvas:function(){return this.backBufferCanvas},getScreenCanvas:function(){return this.canvas},getScreenContext:function(){return this.context},getContext2d:function(a,b){if("undefined"==typeof a||null===a)throw new me.video.Error("You must pass a canvas element in order to create a 2d context");if("undefined"==typeof a.getContext)throw new me.video.Error("Your browser does not support HTML5 canvas.");var c;return c=me.device.cocoon?a.getContext("2d",{antialias:this.antiAlias,alpha:!b}):a.getContext("2d",{alpha:!b}),c.canvas||(c.canvas=a),this.setAntiAlias(c,this.antiAlias),c},getWidth:function(){return this.backBufferCanvas.width},getHeight:function(){return this.backBufferCanvas.height},getColor:function(){return this.currentColor},globalAlpha:function(){return this.currentColor.glArray[3]},resize:function(a,b){this.backBufferCanvas.width=a,this.backBufferCanvas.height=b},setAntiAlias:function(a,b){"undefined"!=typeof a&&me.agent.setPrefixed("imageSmoothingEnabled",b===!0,a);var c=a.canvas.style["image-rendering"];b!==!1||""!==c&&"auto"!==c?b===!0&&"pixelated"===c&&(a.canvas.style["image-rendering"]="auto"):a.canvas.style["image-rendering"]="pixelated"},drawFont:function(){}})}(),function(){me.Renderer.TextureCache=me.Object.extend({init:function(a){this.max_size=a||1/0,this.reset()},reset:function(){this.cache=new Map,this.units=new Map,this.length=0},validate:function(){if(this.length>=this.max_size)throw new me.video.Error("Texture cache overflow: "+this.max_size+" texture units available.")},get:function(a,b){return this.cache.has(a)||(b||(b=me.video.renderer.Texture.prototype.createAtlas.apply(me.video.renderer.Texture.prototype,[a.width,a.height,a.src?me.utils.getBasename(a.src):void 0])),this.put(a,new me.video.renderer.Texture(b,a,!1))),this.cache.get(a)},put:function(a,b){this.validate(),this.cache.set(a,b),this.units.set(b,this.length++)},getUnit:function(a){return this.units.get(a)}})}(),function(){me.CanvasRenderer=me.Renderer.extend({init:function(a,b,c,d){return me.Renderer.prototype.init.apply(this,[a,b,c,d]),this.context=this.getContext2d(this.canvas,!this.transparent),this.doubleBuffering?(this.backBufferCanvas=me.video.createCanvas(b,c,!1),this.backBufferContext2D=this.getContext2d(this.backBufferCanvas),this.transparent&&(this.context.globalCompositeOperation="copy")):(this.backBufferCanvas=this.canvas,this.backBufferContext2D=this.context),this.fontContext2D=this.backBufferContext2D,this.setColor(this.currentColor),this.cache=new me.Renderer.TextureCache,d.textureSeamFix===!1||this.antiAlias||(this.uvOffset=1),this},clear:function(){this.transparent&&this.clearColor("rgba(0,0,0,0)",!0)},flush:function(){this.doubleBuffering&&this.context.drawImage(this.backBufferCanvas,0,0,this.backBufferCanvas.width,this.backBufferCanvas.height,0,0,this.gameWidthZoom,this.gameHeightZoom)},clearColor:function(a,b){var c=this.backBufferContext2D,d=c.canvas;c.save(),c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation=b?"copy":"source-over",c.fillStyle=a instanceof me.Color?a.toRGBA():a,c.fillRect(0,0,d.width,d.height),c.restore()},clearRect:function(a,b,c,d){this.backBufferContext2D.clearRect(a,b,c,d)},createPattern:function(a,b){return this.backBufferContext2D.createPattern(a,b)},drawImage:function(a,b,c,d,e,f,g,h,i){this.backBufferContext2D.globalAlpha<1/255||(this.subPixel===!1?("undefined"==typeof d?(d=h=a.width,e=i=a.height,f=b,g=c,b=0,c=0):"undefined"==typeof f&&(f=b,g=c,h=d,i=e,d=a.width,e=a.height,b=0,c=0),this.backBufferContext2D.drawImage(a,b,c,d,e,~~f,~~g,h,i)):this.backBufferContext2D.drawImage.apply(this.backBufferContext2D,arguments))},drawPattern:function(a,b,c,d,e){if(!(this.backBufferContext2D.globalAlpha<1/255)){var f=this.backBufferContext2D.fillStyle;this.backBufferContext2D.fillStyle=a,this.backBufferContext2D.fillRect(b,c,d,e),this.backBufferContext2D.fillStyle=f}},fillArc:function(a,b,c,d,e,f){this.backBufferContext2D.globalAlpha<1/255||(this.translate(a+c,b+c),this.backBufferContext2D.beginPath(),this.backBufferContext2D.arc(0,0,c,d,e,f||!1),this.backBufferContext2D.fill(),this.backBufferContext2D.closePath(),this.translate(-(a+c),-(b+c)))},fillRect:function(a,b,c,d){this.backBufferContext2D.globalAlpha<1/255||this.backBufferContext2D.fillRect(a,b,c,d)},getContext:function(){return this.backBufferContext2D},resetTransform:function(){this.backBufferContext2D.setTransform(1,0,0,1,0,0)},scaleCanvas:function(a,b){this.canvas.width=this.gameWidthZoom=this.backBufferCanvas.width*a,this.canvas.height=this.gameHeightZoom=this.backBufferCanvas.height*b,me.device.getPixelRatio()>1&&(this.canvas.style.width=this.canvas.width/me.device.getPixelRatio()+"px",this.canvas.style.height=this.canvas.height/me.device.getPixelRatio()+"px"),this.doubleBuffering&&this.transparent&&(this.context.globalCompositeOperation="copy"),this.setAntiAlias(this.context,this.antiAlias),this.flush()},save:function(){this.backBufferContext2D.save()},restore:function(){this.backBufferContext2D.restore(),this.currentColor.glArray[3]=this.backBufferContext2D.globalAlpha},rotate:function(a){this.backBufferContext2D.rotate(a)},scale:function(a,b){this.backBufferContext2D.scale(a,b)},setColor:function(a){this.backBufferContext2D.strokeStyle=this.backBufferContext2D.fillStyle=a instanceof me.Color?a.toRGBA():a},setGlobalAlpha:function(a){this.backBufferContext2D.globalAlpha=this.currentColor.glArray[3]=a},setLineWidth:function(a){this.backBufferContext2D.lineWidth=a},strokeArc:function(a,b,c,d,e,f){this.backBufferContext2D.globalAlpha<1/255||(this.translate(a+c,b+c),this.backBufferContext2D.beginPath(),this.backBufferContext2D.arc(0,0,c,d,e,f||!1),this.backBufferContext2D.stroke(),this.backBufferContext2D.closePath(),this.translate(-(a+c),-(b+c)))},strokeEllipse:function(a,b,c,d){if(!(this.backBufferContext2D.globalAlpha<1/255)){var e=c,f=d,g=a-e,h=a+e,i=b-f,j=b+f,k=.551784*e,l=.551784*f,m=a-k,n=a+k,o=b-l,p=b+l;this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a,i),this.backBufferContext2D.bezierCurveTo(n,i,h,o,h,b),this.backBufferContext2D.bezierCurveTo(h,p,n,j,a,j),this.backBufferContext2D.bezierCurveTo(m,j,g,p,g,b),this.backBufferContext2D.bezierCurveTo(g,o,m,i,a,i),this.backBufferContext2D.stroke()}},strokeLine:function(a,b,c,d){this.backBufferContext2D.globalAlpha<1/255||(this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a,b),this.backBufferContext2D.lineTo(c,d),this.backBufferContext2D.stroke())},strokePolygon:function(a){if(!(this.backBufferContext2D.globalAlpha<1/255)){this.translate(a.pos.x,a.pos.y),this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a.points[0].x,a.points[0].y);for(var b,c=1;ci;i++)b[""+i]={name:""+i,offset:new me.Vector2d(e+(d+a.framewidth)*(i%h.x),e+(d+a.frameheight)*~~(i/h.x)),anchorPoint:a.anchorPoint||null,width:a.framewidth,height:a.frameheight,angle:0};return b},getAtlas:function(){return this.atlas},getTexture:function(){return this.texture},getRegion:function(a){return this.atlas[a]},createSpriteFromName:function(a,b){return me.pool.pull("me.Sprite",0,0,Object.assign({image:this,region:a},b||{}))},createAnimationFromName:function(a,b){for(var c,d=[],e={},f=0,g=0,h=0;h1?(this.canvas.style.width=c/me.device.getPixelRatio()+"px",this.canvas.style.height=d/me.device.getPixelRatio()+"px"):(this.canvas.style.width=c+"px",this.canvas.style.height=d+"px"),this.compositor.setProjection(this.canvas.width,this.canvas.height)},restore:function(){var a=this.colorStack.pop();me.pool.push(a),this.currentColor.copy(a),this.currentTransform.copy(this._matrixStack.pop())},rotate:function(a){this.currentTransform.rotate(a)},save:function(){this.colorStack.push(this.currentColor.clone()),this._matrixStack.push(this.currentTransform.clone())},scale:function(a,b){this.currentTransform.scale(a,b)},setAntiAlias:function(a,b){me.Renderer.prototype.setAntiAlias.apply(this,[a,b])},setGlobalAlpha:function(a){this.currentColor.glArray[3]=a},setColor:function(a){var b=this.currentColor.glArray[3];this.currentColor.copy(a),this.currentColor.glArray[3]*=b},setLineWidth:function(a){this.compositor.lineWidth(a)},strokeArc:function(){},strokeEllipse:function(){},strokeLine:function(a,b,c,d){var e=this._linePoints.slice(0,2);e[0].x=a,e[0].y=b,e[1].x=c,e[1].y=d,this.compositor.drawLine(e,!0)},strokePolygon:function(a){var b,c,d=a.points.length;for(c=this._linePoints.length;d>c;c++)this._linePoints.push(new me.Vector2d);for(b=this._linePoints.slice(0,d),c=0;d>c;c++)b[c].x=a.pos.x+a.points[c].x,b[c].y=a.pos.y+a.points[c].y;this.compositor.drawLine(b)},strokeRect:function(a,b,c,d){var e=this._linePoints.slice(0,4);e[0].x=a,e[0].y=b,e[1].x=a+c,e[1].y=b,e[2].x=a+c,e[2].y=b+d,e[3].x=a,e[3].y=b+d,this.compositor.drawLine(e)},drawShape:function(a){"Rectangle"===a.shapeType?this.strokeRect(a.left,a.top,a.width,a.height):a instanceof me.Line||a instanceof me.Polygon?this.strokePolygon(a):a instanceof me.Ellipse&&(a.radiusV.x===a.radiusV.y?this.strokeArc(a.pos.x-a.radius,a.pos.y-a.radius,a.radius,0,2*Math.PI):this.strokeEllipse(a.pos.x,a.pos.y,a.radiusV.x,a.radiusV.y))},setTransform:function(a){this.resetTransform(),this.transform(a)},transform:function(a){if(this.currentTransform.multiply(a),this.subPixel===!1){var b=this.currentTransform.val;b[6]=~~b[6],b[7]=~~b[7]}},translate:function(a,b){this.subPixel===!1?this.currentTransform.translate(~~a,~~b):this.currentTransform.translate(a,b)}})}(),function(){me.WebGLRenderer.prototype.Texture=me.CanvasRenderer.prototype.Texture.extend({parse:function(a){var b=a.meta.size.w,c=a.meta.size.h,d=me.CanvasRenderer.prototype.Texture.prototype.parse.apply(this,[a]);return this._addStMap(d,b,c)},parseFromSpriteSheet:function(a){var b=a.image.width,c=a.image.height,d=me.CanvasRenderer.prototype.Texture.prototype.parseFromSpriteSheet.apply(this,[a]);return this._addStMap(d,b,c)},_addStMap:function(a,b,c){return Object.keys(a).forEach(function(d){var e=a[d].offset,f=a[d].width,g=a[d].height;a[d].stMap=new Float32Array([e.x/b,e.y/c,(e.x+f)/b,(e.y+g)/c]);var h=e.x+","+e.y+","+b+","+c;a[h]=a[d]}),a},_insertRegion:function(a,b,c,d,e){var f=this.texture.width,g=this.texture.height;return this.atlas[a]={name:a,offset:new me.Vector2d(b,c),width:d,height:e,angle:0,stMap:new Float32Array([b/f,c/g,(b+d)/f,(c+e)/g])},this.atlas[a]}}),me.WebGLRenderer.prototype.Texture.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.WebGLRenderer.Texture.Error"}})}(),function(){var a=2,b=4,c=1,d=2,e=a+b+c+d,f=e*Float32Array.BYTES_PER_ELEMENT,g=0,h=g+a,i=h+b,j=i+c,k=g*Float32Array.BYTES_PER_ELEMENT,l=h*Float32Array.BYTES_PER_ELEMENT,m=i*Float32Array.BYTES_PER_ELEMENT,n=j*Float32Array.BYTES_PER_ELEMENT,o=4,p=6,q=16e3;me.WebGLRenderer.Compositor=me.Object.extend({init:function(g){var h=g.gl;this.length=0,this.units=[],this.maxTextures=Math.min(24,h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS)),this.v=[new me.Vector2d,new me.Vector2d,new me.Vector2d,new me.Vector2d],this.renderer=g,this.gl=g.gl,this.matrix=g.currentTransform,this.color=g.currentColor,this.uMatrix=new me.Matrix2d;var i=h.getShaderPrecisionFormat(h.FRAGMENT_SHADER,h.HIGH_FLOAT).precision<16?"mediump":"highp";this.lineShader=me.video.shader.createShader(this.gl,function(a){var b="precision highp float;attribute vec2 aVertex;uniform mat3 uMatrix;void main(void){gl_Position=vec4((uMatrix*vec3(aVertex,1)).xy,0,1);}";return b}(),function(a){var b="precision "+a.precision+" float;uniform vec4 uColor;void main(void){gl_FragColor=uColor;}";return b}({precision:i})),this.quadShader=me.video.shader.createShader(this.gl,function(a){var b="precision highp float;attribute vec2 aVertex;attribute vec4 aColor;attribute float aTexture;attribute vec2 aRegion;uniform mat3 uMatrix;varying vec4 vColor;varying float vTexture;varying vec2 vRegion;void main(void){gl_Position=vec4((uMatrix*vec3(aVertex,1)).xy,0,1);vColor=vec4(aColor.rgb*aColor.a,aColor.a);vTexture=aTexture;vRegion=aRegion;}";return b}(),function(a){for(var b="precision "+a.precision+" float;uniform sampler2D uSampler["+a.maxTextures+"];varying vec4 vColor;varying float vTexture;varying vec2 vRegion;void main(void){int texture=int(vTexture);if(texture==0){gl_FragColor=texture2D(uSampler[0],vRegion)*vColor;}",c=1;c=q&&this.flush(),this.length>=this.sbSize&&this.resizeSB();var m=this.matrix,n=this.v[0].set(c,d),p=this.v[1].set(c+f,d),r=this.v[2].set(c,d+k),s=this.v[3].set(c+f,d+k);m.isIdentity()||(m.multiplyVector(n),m.multiplyVector(p),m.multiplyVector(r),m.multiplyVector(s));var t=this.sbIndex,u=t+e,v=u+e,w=v+e;this.stream[t+g+0]=n.x,this.stream[t+g+1]=n.y,this.stream[u+g+0]=p.x,this.stream[u+g+1]=p.y,this.stream[v+g+0]=r.x,this.stream[v+g+1]=r.y,this.stream[w+g+0]=s.x,this.stream[w+g+1]=s.y,this.stream.set(l,t+h),this.stream.set(l,u+h),this.stream.set(l,v+h),this.stream.set(l,w+h);var x=this.uploadTexture(a);this.stream[t+i]=this.stream[u+i]=this.stream[v+i]=this.stream[w+i]=x;var y=a.getRegion(b);if("undefined"==typeof y){me.video.renderer.verbose===!0&&console.warn("Adding texture region",b,"for texture",a);var z=b.split(","),A=+z[0],B=+z[1],C=+z[2],D=+z[3];y=a._insertRegion(b,A,B,C,D)}var E=y.stMap;this.stream[t+j+0]=E[0],this.stream[t+j+1]=E[1],this.stream[u+j+0]=E[2],this.stream[u+j+1]=E[1],this.stream[v+j+0]=E[0],this.stream[v+j+1]=E[3],this.stream[w+j+0]=E[2],this.stream[w+j+1]=E[3],this.sbIndex+=e*o,this.length++}},flush:function(){if(this.length){var a=this.gl,b=this.length*e*o;a.bufferData(a.ARRAY_BUFFER,this.stream.subarray(0,b),a.STREAM_DRAW),a.drawElements(a.TRIANGLES,this.length*p,a.UNSIGNED_SHORT,0),this.sbIndex=0,this.length=0}},drawLine:function(e,g){this.useShader(this.lineShader.handle);for(var h=0,i=0;i0&&b[i]--,d[i]=!1,f[g]?a._preventDefault(c):!0}return!0},a.KEY={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,NUM0:48,NUM1:49,NUM2:50,NUM3:51,NUM4:52,NUM5:53,NUM6:54,NUM7:55,NUM8:56,NUM9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,WINDOW_KEY:91,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBSTRACT:109,DECIMAL:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUM_LOCK:144,SCROLL_LOCK:145,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWAND_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,SINGLE_QUOTE:222},a.isKeyPressed=function(a){return b[a]&&!d[a]?(c[a]&&(d[a]=!0),!0):!1},a.keyStatus=function(a){return b[a]>0},a.triggerKeyEvent=function(b,c){c?a._keydown({},b):a._keyup({},b)},a.bindKey=function(g,h,i,j){a._enableKeyboardEvent(),"boolean"!=typeof j&&(j=a.preventDefault),a._KeyBinding[g]=h,f[g]=j,b[h]=0,c[h]=i?i:!1,d[h]=!1,e[h]={}},a.unlockKey=function(a){d[a]=!1},a.unbindKey=function(d){var g=a._KeyBinding[d];b[g]=0,c[g]=!1,e[g]={},a._KeyBinding[d]=null,f[d]=null}}(me.input),function(a){function b(a,b){for(var c=2;c0;){var c=C.pop();if(j.push(c),"undefined"!=typeof a.timeStamp){if(a.timeStampd;d++){var f=b.changedTouches[d];a.globalToLocal(f.clientX,f.clientY,c),c.id=f.identifier,C.push(c)}else a.globalToLocal(b.clientX,b.clientY,c),c.id=b.pointerId||1,C.push(c);b.isPrimary!==!1&&(a.pointer.pos.set(C[0].x,C[0].y),"number"==typeof b.width&&(b.width===a.pointer.width&&b.height===a.pointer.height||a.pointer.resize(b.width||1,b.height||1)))}function g(b){return b.target===me.video.renderer.getScreenCanvas()&&(f(b),b.deltaMode=1,"mousewheel"===o&&(b.deltaY=-1/40*b.wheelDelta,b.wheelDeltaX&&(b.deltaX=-1/40*b.wheelDeltaX)),e(b))?a._preventDefault(b):!0}function h(b){return f(b),e(b)?a._preventDefault(b):!0}function i(b){if(f(b),e(b))return a._preventDefault(b);var c=b.button||0,d=a.pointer.bind[c];return d?b.type===q[w]?a._keydown(b,d,c+1):a._keyup(b,d,c+1):!0}for(var j=[],k=0;10>k;k++)j.push(new me.Vector2d);var l=new Map,m=new me.Rect(0,0,1,1),n=!1,o="mousewheel",p=0,q=null,r=["mousewheel","pointermove","pointerdown","pointerup","pointercancel","pointerenter","pointerleave"],s=["mousewheel","MSPointerMove","MSPointerDown","MSPointerUp","MSPointerCancel","MSPointerEnter","MSPointerLeave"],t=["mousewheel","mousemove","mousedown","mouseup","mousecancel","mouseenter","mouseleave"],u=[void 0,"touchmove","touchstart","touchend","touchcancel","touchenter","touchleave"],v=1,w=2,x=3,y=4,z=5,A=6,B=new me.Vector2d,C=[];a._offset=null,a.pointer=new me.Rect(0,0,1,1),a.pointer.bind=[0,0,0],a.pointer.LEFT=0,a.pointer.MIDDLE=1,a.pointer.RIGHT=2,a.throttlingInterval=void 0,a.globalToLocal=function(b,c,d){d=d||new me.Vector2d;var e=a._offset,f=me.device.getPixelRatio();b-=e.left,c-=e.top;var g=me.sys.scale;return 1===g.x&&1===g.y||(b/=g.x,c/=g.y),d.set(b*f,c*f)},a.bindPointer=function(){var b=arguments.length<2?a.pointer.LEFT:arguments[0],d=arguments.length<2?arguments[0]:arguments[1];if(c(),!a._KeyBinding[d])throw new me.Error("no action defined for keycode "+d);a.pointer.bind[b]=d},a.unbindPointer=function(b){a.pointer.bind["undefined"==typeof b?a.pointer.LEFT:b]=null},a.registerPointerEvent=function(a,b,d){if(c(),-1===r.indexOf(a))throw new me.Error("invalid event type : "+a);r!==q&&(a=q[r.indexOf(a)]),l.has(b)||l.set(b,{region:b,callbacks:{},pointerId:null});var e=l.get(b);e.callbacks[a]||(e.callbacks[a]=[]),e.callbacks[a].push(d)},a.releasePointerEvent=function(a,b,c){if(-1===r.indexOf(a))throw new me.Error("invalid event type : "+a);r!==q&&(a=q[r.indexOf(a)]);var d=l.get(b);if("undefined"==typeof c)for(;d.callbacks[a].length>0;)d.callbacks[a].pop();else d.callbacks[a].remove(c);0===Object.keys(d.callbacks).length&&l.delete(b)},a._translatePointerEvents=function(){a.registerPointerEvent("pointermove",me.game.viewport,function(a){me.event.publish(me.event.POINTERMOVE,[a])})}}(me.input),function(a){function b(a){return a}function c(b,c,d){return d===a.GAMEPAD.BUTTONS.L2||d===a.GAMEPAD.BUTTONS.R2?(b+1)/2:b}function d(b,c,d){return b=b>0?d===a.GAMEPAD.BUTTONS.L2?Math.max(0,b-2e4)/111070:(b-1)/131070:(65536+b)/131070+.5}function e(a,c){var d=a.replace(g,function(a,b,c){return"000".substr(b.length-1)+b+"-"+"000".substr(c.length-1)+c+"-"}),e=a.replace(g,function(a,b,c){return b.replace(h,"")+"-"+c.replace(h,"")+"-"});c.analog=c.analog||c.buttons.map(function(){return-1}),c.normalize_fn=c.normalize_fn||b,j.set(d,c),j.set(e,c)}var f=.1,g=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,h=/^0+/,i={},j=new Map;[["45e-28e-Xbox 360 Wired Controller",{axes:[0,1,3,4],buttons:[11,12,13,14,8,9,-1,-1,5,4,6,7,0,1,2,3,10],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:c}],["54c-268-PLAYSTATION(R)3 Controller",{axes:[0,1,2,3],buttons:[14,13,15,12,10,11,8,9,0,3,1,2,4,6,7,5,16]}],["54c-5c4-Wireless Controller",{axes:[0,1,2,3],buttons:[1,0,2,3,4,5,6,7,8,9,10,11,14,15,16,17,12,13]}],["2836-1-OUYA Game Controller",{axes:[0,3,7,9],buttons:[3,6,4,5,7,8,15,16,-1,-1,9,10,11,12,13,14,-1],analog:[-1,-1,-1,-1,-1,-1,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:d}],["OUYA Game Controller (Vendor: 2836 Product: 0001)",{axes:[0,1,3,4],buttons:[0,3,1,2,4,5,12,13,-1,-1,6,7,8,9,10,11,-1],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:d}]].forEach(function(a){e(a[0],a[1])}),window.addEventListener("gamepadconnected",function(a){me.event.publish(me.event.GAMEPAD_CONNECTED,[a.gamepad])},!1),window.addEventListener("gamepaddisconnected",function(a){me.event.publish(me.event.GAMEPAD_DISCONNECTED,[a.gamepad])},!1),a._updateGamepads=navigator.getGamepads?function(){var b=navigator.getGamepads(),c={};Object.keys(i).forEach(function(d){var e=b[d];if(e){var g=null;"standard"!==e.mapping&&(g=j.get(e.id));var h=i[d];Object.keys(h.buttons).forEach(function(b){var i=h.buttons[b],j=b,k=-1;if(!(g&&(j=g.buttons[b],k=g.analog[b],0>j&&0>k))){var l=e.buttons[j]||{};if(g&&k>=0){var m=g.normalize_fn(e.axes[k],-1,+b);l={value:m,pressed:l.pressed||Math.abs(m)>=f}}me.event.publish(me.event.GAMEPAD_UPDATE,[d,"buttons",+b,l]),!i.pressed&&l.pressed?a._keydown(c,i.keyCode,j+256):i.pressed&&!l.pressed&&a._keyup(c,i.keyCode,j+256),i.value=l.value,i.pressed=l.pressed}}),Object.keys(h.axes).forEach(function(b){var i=h.axes[b],j=b;if(!(g&&(j=g.axes[b],0>j))){var k=e.axes[j];if("undefined"!=typeof k){g&&(k=g.normalize_fn(k,+b,-1));var l=Math.sign(k)||1;if(i[l]){var m=Math.abs(k)>=f+Math.abs(i[l].threshold);me.event.publish(me.event.GAMEPAD_UPDATE,[d,"axes",+b,k]),!i[l].pressed&&m?a._keydown(c,i[l].keyCode,j+256):(i[l].pressed||i[-l]&&i[-l].pressed)&&!m&&(l=i[l].pressed?l:-l,a._keyup(c,i[l].keyCode,j+256)),i[l].value=k,i[l].pressed=m}}}})}})}:function(){},a.GAMEPAD={AXES:{LX:0,LY:1,RX:2,RY:3,EXTRA_1:4,EXTRA_2:5,EXTRA_3:6,EXTRA_4:7},BUTTONS:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L1:4,R1:5,L2:6,R2:7,SELECT:8,BACK:8,START:9,FORWARD:9,L3:10,R3:11,UP:12,DOWN:13,LEFT:14,RIGHT:15,HOME:16,EXTRA_1:17,EXTRA_2:18,EXTRA_3:19,EXTRA_4:20}},a.bindGamepad=function(b,c,d){if(!a._KeyBinding[d])throw new me.Error("no action defined for keycode "+d);"object"!=typeof c&&(c={type:"buttons",code:c},console.warn("Deprecated: me.input.bindGamepad parameteres have changed")),i[b]||(i[b]={axes:{},buttons:{}});var e={keyCode:d,value:0,pressed:!1,threshold:c.threshold},f=i[b][c.type];if("buttons"===c.type)f[c.code]=e;else if("axes"===c.type){var g=Math.sign(c.threshold)||1;f[c.code]||(f[c.code]={}),f[c.code][g]=e}},a.unbindGamepad=function(a,b){if(!i[a])throw new me.Error("no bindings for gamepad "+a);i[a].buttons[b]={}},a.setGamepadDeadzone=function(a){f=a},a.setGamepadMapping=e}(me.input),function(){var a=function(){var a={},b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return a.decode=function(a){if(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,""),me.device.nativeBase64)return window.atob(a);for(var c,d,e,f,g,h,i,j=[],k=0;k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j.push(String.fromCharCode(c)),64!==h&&j.push(String.fromCharCode(d)),64!==i&&j.push(String.fromCharCode(e));return j=j.join("")},a.encode=function(a){if(a=a.replace(/\r\n/g,"\n"),me.device.nativeBase64)return window.btoa(a);for(var c,d,e,f,g,h,i,j=[],k=0;k>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?h=i=64:isNaN(e)&&(i=64),j.push(b.charAt(f)),j.push(b.charAt(g)),j.push(b.charAt(h)),j.push(b.charAt(i));return j=j.join("")},a}();me.utils=function(){var b={},c="",d=0,e=/^.*(\\|\/|\:)/,f=/\.[^\.]*$/;return b.decodeBase64=function(b){return a.decode(b)},b.encodeBase64=function(b){return a.encode(b)},b.decodeBase64AsArray=function(b,c){c=c||1;var d,e,f,g=a.decode(b),h=new Uint32Array(g.length/c);for(d=0,f=g.length/c;f>d;d++)for(h[d]=0,e=c-1;e>=0;--e)h[d]+=g.charCodeAt(d*c+e)<<(e<<3);return h},b.decompress=function(){throw new me.Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},b.decodeCSV=function(a){for(var b=a.replace("\n","").trim().split(","),c=[],d=0;d0)for(var c=0;ca;a++)c=e[a],d=e[a+1].clone(),0!==this.rotation&&(c=c.rotate(this.rotation),d=d.rotate(this.rotation)),b.push(new me.Line(0,0,[c,d]))}else b.push(new me.Polygon(0,0,[new me.Vector2d,new me.Vector2d(this.width,0),new me.Vector2d(this.width,this.height),new me.Vector2d(0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(a=0;a=this.firstgid&&a<=this.lastgid},getViewTileId:function(a){return this.animations.has(a)?a=this.animations.get(a).cur.tileid:a-=this.firstgid,a},getTileProperties:function(a){return this.TileProperties[a]},update:function(a){var b=0,c=me.timer.getTime(),d=!1;return this._lastUpdate!==c&&(this._lastUpdate=c,this.animations.forEach(function(c){for(c.dt+=a,b=c.cur.duration;c.dt>=b;)c.dt-=b,c.idx=(c.idx+1)%c.frames.length,c.cur=c.frames[c.idx],b=c.cur.duration,d=!0})),d},drawTile:function(a,b,c,d){d.flipped&&(a.save(),a.translate(b,c),a.transform(d.currentTransform),b=c=0);var e=this.atlas[this.getViewTileId(d.tileId)].offset;a.drawImage(this.image,e.x,e.y,this.tilewidth,this.tileheight,b,c,this.tilewidth+a.uvOffset,this.tileheight+a.uvOffset),d.flipped&&a.restore()}}),me.TMXTilesetGroup=me.Object.extend({init:function(){this.tilesets=[],this.length=0},add:function(a){this.tilesets.push(a),this.length++},getTilesetByIndex:function(a){return this.tilesets[a]},getTilesetByGid:function(b){var c=-1;b&=a;for(var d=0,e=this.tilesets.length;e>d;d++){if(this.tilesets[d].contains(b))return this.tilesets[d];this.tilesets[d].firstgid===this.tilesets[d].lastgid&&b>=this.tilesets[d].firstgid&&(c=d)}if(-1!==c)return this.tilesets[c];throw new me.Error("no matching tileset found for gid "+b)}}),me.TMXTileset.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.TMXTileset.Error"}})}(),function(){var a=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],b=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}];me.TMXRenderer=me.Object.extend({init:function(a,b,c,d){this.cols=a,this.rows=b,this.tilewidth=c,this.tileheight=d},canRender:function(a){return this.cols===a.cols&&this.rows===a.rows&&this.tilewidth===a.tilewidth&&this.tileheight===a.tileheight}}),me.TMXOrthogonalRenderer=me.TMXRenderer.extend({canRender:function(a){return"orthogonal"===a.orientation&&me.TMXRenderer.prototype.canRender.apply(this,[a])},pixelToTileCoords:function(a,b,c){var d=c||new me.Vector2d;return d.set(this.pixelToTileX(a),this.pixelToTileY(b))},pixelToTileX:function(a){return a/this.tilewidth},pixelToTileY:function(a){return a/this.tileheight},tileToPixelCoords:function(a,b,c){var d=c||new me.Vector2d;return d.set(a*this.tilewidth,b*this.tileheight)},adjustPosition:function(a){"number"==typeof a.gid&&(a.y-=a.height)},drawTile:function(a,b,c,d,e){e.drawTile(a,e.tileoffset.x+b*this.tilewidth,e.tileoffset.y+(c+1)*this.tileheight-e.tileheight,d)},drawTileLayer:function(a,b,c){var d=this.pixelToTileCoords(Math.max(c.pos.x-(b.maxTileSize.width-b.tilewidth),0),Math.max(c.pos.y-(b.maxTileSize.height-b.tileheight),0),me.pool.pull("me.Vector2d")).floorSelf(),e=this.pixelToTileCoords(c.pos.x+c.width+this.tilewidth,c.pos.y+c.height+this.tileheight,me.pool.pull("me.Vector2d")).ceilSelf();e.x=e.x>this.cols?this.cols:e.x,e.y=e.y>this.rows?this.rows:e.y;for(var f=d.y;f>1,-e.tilewidth+(b+c)*e.tileheight>>2,d)},drawTileLayer:function(a,b,c){var d=b.tileset,e=d.tileoffset,f=this.pixelToTileCoords(c.pos.x-d.tilewidth,c.pos.y-d.tileheight,me.pool.pull("me.Vector2d")).floorSelf(),g=this.pixelToTileCoords(c.pos.x+c.width+d.tilewidth,c.pos.y+c.height+d.tileheight,me.pool.pull("me.Vector2d")).ceilSelf(),h=this.tileToPixelCoords(g.x,g.y,me.pool.pull("me.Vector2d")),i=this.tileToPixelCoords(f.x,f.y,me.pool.pull("me.Vector2d"));i.x-=this.hTilewidth,i.y+=this.tileheight;var j=i.y-c.pos.y>this.hTileheight,k=c.pos.x-i.x=0&&m.y>=0&&m.xr;++r)o=Math.pow(this.centers[r].x-j.x,2)+Math.pow(this.centers[r].y-j.y,2),q>o&&(q=o,p=r);var s="x"===this.staggeraxis?a:b;return f=i.x+s[p].x,g=i.y+s[p].y,me.pool.push(i),me.pool.push(j),h.set(f,g)},pixelToTileX:function(a,b){var c=me.pool.pull("me.Vector2d");return this.pixelToTileCoords(a,b,c),me.pool.push(c),c.x},pixelToTileY:function(a,b){var c=me.pool.pull("me.Vector2d");return this.pixelToTileCoords(b,a,c),me.pool.push(c),c.y},tileToPixelCoords:function(a,b,c){var d,e,f=c||new me.Vector2d;return"x"===this.staggeraxis?(d=a*this.columnwidth,"odd"===this.staggerindex?(e=b*(this.tileheight+this.sidelengthy),e+=this.rowheight*(1&a)):(e=b*(this.tileheight+this.sidelengthy),e+=this.rowheight*(1-(1&a)))):(e=b*this.rowheight,"odd"===this.staggerindex?(d=a*(this.tilewidth+this.sidelengthx),d+=this.columnwidth*(1&b)):(d=a*(this.tilewidth+this.sidelengthx),d+=this.columnwidth*(1-(1&b)))),f.set(d,e)},adjustPosition:function(a){"number"==typeof a.gid&&(a.y-=a.height)},drawTile:function(a,b,c,d,e){var f=this.tileToPixelCoords(b,c,me.pool.pull("me.Vector2d"));e.drawTile(a,e.tileoffset.x+f.x,e.tileoffset.y+f.y+(this.tileheight-e.tileheight),d),me.pool.push(f)},drawTileLayer:function(a,b,c){var d=this.pixelToTileCoords(c.pos.x,c.pos.y).floorSelf(),e=this.pixelToTileCoords(c.pos.x+c.width+this.tilewidth,c.pos.y+c.height+this.tileheight).ceilSelf();d.x=d.x<0?0:d.x,d.y=d.y<0?0:d.y,e.x=e.x>this.cols?this.cols:e.x,e.y=e.y>this.rows?this.rows:e.y;for(var f=d.y;f0,this.isAnimated&&(this.preRender=!1),this.getBounds().resize(this.width,this.height)},onDeactivateEvent:function(){this.animatedTilesets=void 0},setRenderer:function(a){this.renderer=a},initArray:function(a,b){this.layerData=[];for(var c=0;a>c;c++){this.layerData[c]=[];for(var d=0;b>d;d++)this.layerData[c][d]=null}},getTileId:function(a,b){var c=this.getTile(a,b);return c?c.tileId:null},getTile:function(a,b){return this.layerData[~~this.renderer.pixelToTileX(a,b)][~~this.renderer.pixelToTileY(b,a)]},setTile:function(a,b,c){this.tileset.contains(c)||(this.tileset=this.tilesets.getTilesetByGid(c));var d=this.layerData[a][b]=new me.Tile(a,b,c,this.tileset);return this.preRender&&this.renderer.drawTile(this.canvasRenderer,a,b,d,d.tileset),d},clearTile:function(a,b){this.layerData[a][b]=null,this.preRender&&this.canvasRenderer.clearRect(a*this.tilewidth,b*this.tileheight,this.tilewidth,this.tileheight)},update:function(a){if(this.isAnimated){for(var b=!1,c=0;c0&&(b.autoSort=!0,b.autoDepth=!0,c.push(b))}return c},getLayers:function(){return this.readMapObjects(this.data),this.layers},destroy:function(){this.tilesets=void 0,this.layers=[],this.objectGroups=[],this.initialized=!1}})}(),function(){me.levelDirector=function(){function a(a,g,h){g.container.destroy(),me.video.renderer.reset(),d[c.getCurrentLevelId()]&&d[c.getCurrentLevelId()].destroy(),f=e.indexOf(a),b(a,g.container,g.flatten,g.setViewportBounds),me.event.publish(me.event.LEVEL_LOADED,[a]),g.onLoaded(a),h&&me.state.restart()}function b(a,b,c,e){function f(){b.pos.set(Math.max(0,~~((me.game.viewport.width-h.width)/2)),Math.max(0,~~((me.game.viewport.height-h.height)/2)),0)}var h=d[a],i=b.autoSort;b.autoSort=!1,e&&me.game.viewport.setBounds(0,0,Math.max(h.width,me.game.viewport.width),Math.max(h.height,me.game.viewport.height)),me.utils.resetGUID(a,h.nextobjectid),h.addTo(b,c),b.sort(!0),b.autoSort=i,b.resize(h.width,h.height),e&&(f(),g&&me.event.unsubscribe(g),g=me.event.subscribe(me.event.VIEWPORT_ONRESIZE,f))}var c={},d={},e=[],f=0,g=null;return c.reset=function(){},c.addLevel=function(){throw new me.Error("no level loader defined")},c.addTMXLevel=function(a,b){return null!=d[a]?!1:(d[a]=new me.TMXTileMap(a,me.loader.getTMX(a)),e.push(a),b&&b(),!0)},c.loadLevel=function(b,c){if(c=Object.assign({container:me.game.world,onLoaded:me.game.onLevelLoaded,flatten:me.game.mergeGroup,setViewportBounds:!0},c||{}),"undefined"==typeof d[b])throw new me.Error("level "+b+" not found");if(!(d[b]instanceof me.TMXTileMap))throw new me.Error("no level loader defined");var e=me.state.isRunning();return e?(me.state.stop(),a.defer(this,b,c,!0)):a(b,c),!0},c.getCurrentLevelId=function(){return e[f]},c.getCurrentLevel=function(){return d[c.getCurrentLevelId()]},c.reloadLevel=function(a){return c.loadLevel(c.getCurrentLevelId(),a)},c.nextLevel=function(a){return f+1=0?c.loadLevel(e[f-1],a):!1},c.levelCount=function(){return e.length},c}()}(),/** + * @preserve Tween JS + * https://github.com/sole/Tween.js + */ +function(){me.Tween=function(a){var b=null,c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null,o=null,p=null,q=null,r=null,s=null;this._resumeCallback=function(a){k&&(k+=a)},this.setProperties=function(a){b=a,c={},d={},e={},f=1e3,g=0,h=!1,i=!1,j=0,k=null,l=me.Tween.Easing.Linear.None,m=me.Tween.Interpolation.Linear,n=[],o=null,p=!1,q=null,r=null,s=me.timer.lastUpdate,this.isPersistent=!1;for(var t in a)"object"!=typeof a&&(c[t]=parseFloat(a[t],10))},this.setProperties(a),this.onResetEvent=function(a){this.setProperties(a)},this.onActivateEvent=function(){me.event.subscribe(me.event.STATE_RESUME,this._resumeCallback)},this.onDeactivateEvent=function(){me.event.unsubscribe(me.event.STATE_RESUME,this._resumeCallback)},this.to=function(a,b){return void 0!==b&&(f=b),d=a,this},this.start=function(a){p=!1,me.game.world.addChild(this),k=("undefined"==typeof a?me.timer.getTime():a)+j;for(var f in d){if(d[f]instanceof Array){if(0===d[f].length)continue;d[f]=[b[f]].concat(d[f])}c[f]=b[f],c[f]instanceof Array==!1&&(c[f]*=1),e[f]=c[f]||0}return this},this.stop=function(){return me.game.world.removeChildNow(this),this},this.delay=function(a){return j=a,this},this.repeat=function(a){return g=a,this},this.yoyo=function(a){return h=a,this},this.easing=function(a){if("function"!=typeof a)throw new me.Tween.Error("invalid easing function for me.Tween.easing()");return l=a,this},this.interpolation=function(a){return m=a,this},this.chain=function(){return n=arguments,this},this.onStart=function(a){return o=a,this},this.onUpdate=function(a){return q=a,this},this.onComplete=function(a){return r=a,this},this.update=function(a){s=me.timer.lastUpdate>s?me.timer.lastUpdate:s+a;var t,u=s;if(k>u)return!0;p===!1&&(null!==o&&o.call(b),p=!0);var v=(u-k)/f;v=v>1?1:v;var w=l(v);for(t in d){var x=c[t]||0,y=d[t];y instanceof Array?b[t]=m(y,w):("string"==typeof y&&(y=x+parseFloat(y,10)),"number"==typeof y&&(b[t]=x+(y-x)*w))}if(null!==q&&q.call(b,w),1===v){if(g>0){isFinite(g)&&g--;for(t in e){if("string"==typeof d[t]&&(e[t]=e[t]+parseFloat(d[t],10)),h){var z=e[t];e[t]=d[t],d[t]=z}c[t]=e[t]}return h&&(i=!i),k=u+j,!0}me.game.world.removeChildNow(this),null!==r&&r.call(b);for(var A=0,B=n.length;B>A;A++)n[A].start(u);return!1}return!0}},me.Tween.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*(2*Math.PI)/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)*.5+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*(a*a*((b+1)*a-b)):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-me.Tween.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*me.Tween.Easing.Bounce.In(2*a):.5*me.Tween.Easing.Bounce.Out(2*a-1)+.5}}},me.Tween.Interpolation={Linear:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=me.Tween.Interpolation.Utils.Linear;return 0>b?f(a[0],a[1],d):b>1?f(a[c],a[c-1],c-d):f(a[e],a[e+1>c?c:e+1],d-e)},Bezier:function(a,b){var c,d=0,e=a.length-1,f=Math.pow,g=me.Tween.Interpolation.Utils.Bernstein;for(c=0;e>=c;c++)d+=f(1-b,e-c)*f(b,c)*a[c]*g(e,c);return d},CatmullRom:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=me.Tween.Interpolation.Utils.CatmullRom;return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),f(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(f(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):f(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},Utils:{Linear:function(a,b,c){return(b-a)*c+a},Bernstein:function(a,b){var c=me.Tween.Interpolation.Utils.Factorial;return c(a)/c(b)/c(a-b)},Factorial:function(){var a=[1];return function(b){var c,d=1;if(a[b])return a[b];for(c=b;c>1;c--)d*=c;return a[b]=d}}(),CatmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b}}},me.Tween.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Tween.Error"}})}(),/** + * @preserve MinPubSub + * a micro publish/subscribe messaging framework + * @see https://github.com/daniellmb/MinPubSub + * @author Daniel Lamb + * + * Released under the MIT License + */ +function(){me.event=function(){var a={},b={};return a.STATE_PAUSE="me.state.onPause",a.STATE_RESUME="me.state.onResume",a.STATE_STOP="me.state.onStop",a.STATE_RESTART="me.state.onRestart",a.GAME_INIT="me.game.onInit",a.GAME_RESET="me.game.onReset",a.LEVEL_LOADED="me.game.onLevelLoaded",a.LOADER_COMPLETE="me.loader.onload",a.LOADER_PROGRESS="me.loader.onProgress",a.KEYDOWN="me.input.keydown",a.KEYUP="me.input.keyup",a.GAMEPAD_CONNECTED="gamepad.connected",a.GAMEPAD_DISCONNECTED="gamepad.disconnected",a.GAMEPAD_UPDATE="gamepad.update",a.POINTERMOVE="me.event.pointermove",a.DRAGSTART="me.game.dragstart",a.DRAGEND="me.game.dragend",a.WINDOW_ONRESIZE="window.onresize",a.VIEWPORT_ONRESIZE="viewport.onresize",a.WINDOW_ONORIENTATION_CHANGE="window.orientationchange",a.WINDOW_ONSCROLL="window.onscroll",a.VIEWPORT_ONCHANGE="viewport.onchange",a.publish=function(a,c){for(var d=b[a],e=d?d.length:0;e--;)d[e].apply(window,c||[])},a.subscribe=function(a,c){return b[a]||(b[a]=[]),b[a].push(c),[a,c]},a.unsubscribe=function(a,c){var d=b[c?a:a[0]],e=d?d.length:0;for(c=c||a[1];e--;)d[e]===c&&d.splice(e,1)},a}()}(),/*! + * howler.js v2.0.1 + * howlerjs.com + * + * (c) 2013-2016, James Simpson of GoldFire Studios + * goldfirestudios.com + * + * MIT License + */ +function(){"use strict";var a=function(){this.init()};a.prototype={init:function(){var a=this||b;return a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.mobileAutoEnable=!0,a._setup(),a},volume:function(a){var c=this||b;if(a=parseFloat(a),c.ctx||j(),"undefined"!=typeof a&&a>=0&&1>=a){if(c._volume=a,c._muted)return c;c.usingWebAudio&&(c.masterGain.gain.value=a);for(var d=0;d=0;c--)a._howls[c].unload();return a.usingWebAudio&&"undefined"!=typeof a.ctx.close&&(a.ctx.close(),a.ctx=null,j()),a},codecs:function(a){return(this||b)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||b;return a.state=a.ctx?a.ctx.state||"running":"running",a._autoSuspend(),a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||b,c="undefined"!=typeof Audio?new Audio:null;if(!c||"function"!=typeof c.canPlayType)return a;var d=c.canPlayType("audio/mpeg;").replace(/^no$/,""),e=a._navigator&&a._navigator.userAgent.match(/OPR\/([0-6].)/g),f=e&&parseInt(e[0].split("/")[1],10)<33;return a._codecs={mp3:!(f||!d&&!c.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!d,opus:!!c.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!c.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),aac:!!c.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!c.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(c.canPlayType("audio/x-m4a;")||c.canPlayType("audio/m4a;")||c.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(c.canPlayType("audio/x-mp4;")||c.canPlayType("audio/mp4;")||c.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!c.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),webm:!!c.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),dolby:!!c.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(c.canPlayType("audio/x-flac;")||c.canPlayType("audio/flac;")).replace(/^no$/,"")},a},_enableMobileAudio:function(){var a=this||b,c=/iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi/i.test(a._navigator&&a._navigator.userAgent),d=!!("ontouchend"in window||a._navigator&&a._navigator.maxTouchPoints>0||a._navigator&&a._navigator.msMaxTouchPoints>0);if(!a._mobileEnabled&&a.ctx&&(c||d)){a._mobileEnabled=!1,a._mobileUnloaded||44100===a.ctx.sampleRate||(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var e=function(){var b=a.ctx.createBufferSource();b.buffer=a._scratchBuffer,b.connect(a.ctx.destination),"undefined"==typeof b.start?b.noteOn(0):b.start(0),b.onended=function(){b.disconnect(0),a._mobileEnabled=!0,a.mobileAutoEnable=!1,document.removeEventListener("touchend",e,!0)}};return document.addEventListener("touchend",e,!0),a}},_autoSuspend:function(){var a=this;if(a.autoSuspend&&a.ctx&&"undefined"!=typeof a.ctx.suspend&&b.usingWebAudio){for(var c=0;c0?h._seek:d._sprite[a][0]/1e3,j=(d._sprite[a][0]+d._sprite[a][1])/1e3-i,k=1e3*j/Math.abs(h._rate);h._paused=!1,h._ended=!1,h._sprite=a,h._seek=i,h._start=d._sprite[a][0]/1e3,h._stop=(d._sprite[a][0]+d._sprite[a][1])/1e3,h._loop=!(!h._loop&&!d._sprite[a][2]);var l=h._node;if(d._webAudio){var m=function(){d._refreshBuffer(h);var a=h._muted||d._muted?0:h._volume;l.gain.setValueAtTime(a,b.ctx.currentTime),h._playStart=b.ctx.currentTime,"undefined"==typeof l.bufferSource.start?h._loop?l.bufferSource.noteGrainOn(0,i,86400):l.bufferSource.noteGrainOn(0,i,j):h._loop?l.bufferSource.start(0,i,86400):l.bufferSource.start(0,i,j),k!==1/0&&(d._endTimers[h._id]=setTimeout(d._ended.bind(d,h),k)),c||setTimeout(function(){d._emit("play",h._id)},0)};"loaded"===d._state?m():(d.once("load",m,h._id),d._clearTimer(h._id))}else{var n=function(){l.currentTime=i,l.muted=h._muted||d._muted||b._muted||l.muted,l.volume=h._volume*b.volume(),l.playbackRate=h._rate,setTimeout(function(){l.play(),k!==1/0&&(d._endTimers[h._id]=setTimeout(d._ended.bind(d,h),k)),c||d._emit("play",h._id)},0)},o="loaded"===d._state&&(window&&window.ejecta||!l.readyState&&b._navigator.isCocoonJS);if(4===l.readyState||o)n();else{var p=function(){n(),l.removeEventListener(b._canPlayEvent,p,!1)};l.addEventListener(b._canPlayEvent,p,!1),d._clearTimer(h._id)}}return h._id},pause:function(a){var b=this;if("loaded"!==b._state)return b._queue.push({event:"pause",action:function(){b.pause(a)}}),b;for(var c=b._getSoundIds(a),d=0;d=0?c=parseInt(e[0],10):a=parseFloat(e[0])}else e.length>=2&&(a=parseFloat(e[0]),c=parseInt(e[1],10));var h;if(!("undefined"!=typeof a&&a>=0&&1>=a))return h=c?d._soundById(c):d._sounds[0],h?h._volume:0;if("loaded"!==d._state)return d._queue.push({event:"volume",action:function(){d.volume.apply(d,e)}}),d;"undefined"==typeof c&&(d._volume=a),c=d._getSoundIds(c);for(var i=0;ic?"out":"in",i=g/.01,j=i>0?d/i:d;if(4>j&&(i=Math.ceil(i/(4/j)),j=4),"loaded"!==f._state)return f._queue.push({event:"fade",action:function(){f.fade(a,c,d,e)}}),f;f.volume(a,e);for(var k=f._getSoundIds(e),l=0;l0&&(p+="in"===h?.01:-.01),p=Math.max(0,p),p=Math.min(1,p),p=Math.round(100*p)/100,f._webAudio?("undefined"==typeof e&&(f._volume=p),b._volume=p):f.volume(p,a,!0),p===c&&(clearInterval(b._interval),b._interval=null,f.volume(p,a),f._emit("fade",a))}.bind(f,k[l],m),j)}}return f},_stopFade:function(a){var c=this,d=c._soundById(a);return d&&d._interval&&(c._webAudio&&d._node.gain.cancelScheduledValues(b.ctx.currentTime),clearInterval(d._interval),d._interval=null,c._emit("fade",a)),c},loop:function(){var a,b,c,d=this,e=arguments;if(0===e.length)return d._loop;if(1===e.length){if("boolean"!=typeof e[0])return c=d._soundById(parseInt(e[0],10)),c?c._loop:!1;a=e[0],d._loop=a}else 2===e.length&&(a=e[0],b=parseInt(e[1],10));for(var f=d._getSoundIds(b),g=0;g=0?c=parseInt(e[0],10):a=parseFloat(e[0])}else 2===e.length&&(a=parseFloat(e[0]),c=parseInt(e[1],10));var h;if("number"!=typeof a)return h=d._soundById(c),h?h._rate:d._rate;if("loaded"!==d._state)return d._queue.push({event:"rate",action:function(){d.rate.apply(d,e)}}),d;"undefined"==typeof c&&(d._rate=a),c=d._getSoundIds(c);for(var i=0;i=0?c=parseInt(e[0],10):(c=d._sounds[0]._id,a=parseFloat(e[0]))}else 2===e.length&&(a=parseFloat(e[0]),c=parseInt(e[1],10));if("undefined"==typeof c)return d;if("loaded"!==d._state)return d._queue.push({event:"seek",action:function(){d.seek.apply(d,e)}}),d;var h=d._soundById(c);if(h){if(!("number"==typeof a&&a>=0)){if(d._webAudio){var i=d.playing(c)?b.ctx.currentTime-h._playStart:0,j=h._rateSeek?h._rateSeek-h._seek:0;return h._seek+(j+i*Math.abs(h._rate))}return h._node.currentTime}var k=d.playing(c);k&&d.pause(c,!0),h._seek=a,h._ended=!1,d._clearTimer(c),k&&d.play(c,!0),!d._webAudio&&h._node&&(h._node.currentTime=a),d._emit("seek",c)}return d},playing:function(a){var b=this;if("number"==typeof a){var c=b._soundById(a);return c?!c._paused:!1}for(var d=0;d=0&&b._howls.splice(f,1)}var g=!0;for(d=0;d=0;f--)e[f].id&&e[f].id!==b&&"load"!==a||(setTimeout(function(a){a.call(this,b,c)}.bind(d,e[f].fn),0),e[f].once&&d.off(a,e[f].fn,e[f].id));return d},_loadQueue:function(){var a=this;if(a._queue.length>0){var b=a._queue[0];a.once(b.event,function(){a._queue.shift(),a._loadQueue()}),b.action()}return a},_ended:function(a){var c=this,d=a._sprite,e=!(!a._loop&&!c._sprite[d][2]);if(c._emit("end",a._id),!c._webAudio&&e&&c.stop(a._id,!0).play(a._id),c._webAudio&&e){c._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=b.ctx.currentTime;var f=1e3*(a._stop-a._start)/Math.abs(a._rate);c._endTimers[a._id]=setTimeout(c._ended.bind(c,a),f)}return c._webAudio&&!e&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,c._clearTimer(a._id),c._cleanBuffer(a._node),b._autoSuspend()),c._webAudio||e||c.stop(a._id),c},_clearTimer:function(a){var b=this;return b._endTimers[a]&&(clearTimeout(b._endTimers[a]),delete b._endTimers[a]),b},_soundById:function(a){for(var b=this,c=0;c=0;d--){if(b>=c)return;a._sounds[d]._ended&&(a._webAudio&&a._sounds[d]._node&&a._sounds[d]._node.disconnect(0),a._sounds.splice(d,1),c--)}}},_getSoundIds:function(a){var b=this;if("undefined"==typeof a){for(var c=[],d=0;d0&&(e[c._src]=a,i(c,a))},function(){c._emit("loaderror",null,"Decoding audio data failed.")})},i=function(a,b){b&&!a._duration&&(a._duration=b.duration),0===Object.keys(a._sprite).length&&(a._sprite={__default:[0,1e3*a._duration]}),"loaded"!==a._state&&(a._state="loaded",a._emit("load"),a._loadQueue()),a._autoplay&&a.play()},j=function(){b.noAudio=!1;try{"undefined"!=typeof AudioContext?b.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?b.ctx=new webkitAudioContext:b.usingWebAudio=!1}catch(a){b.usingWebAudio=!1}if(!b.usingWebAudio)if("undefined"!=typeof Audio)try{var a=new Audio;"undefined"==typeof a.oncanplaythrough&&(b._canPlayEvent="canplay")}catch(a){b.noAudio=!0}else b.noAudio=!0;try{var a=new Audio;a.muted&&(b.noAudio=!0)}catch(a){}var c=/iP(hone|od|ad)/.test(b._navigator&&b._navigator.platform),d=b._navigator&&b._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),e=d?parseInt(d[1],10):null;if(c&&e&&9>e){var f=/safari/.test(b._navigator&&b._navigator.userAgent.toLowerCase());(b._navigator&&b._navigator.standalone&&!f||b._navigator&&!b._navigator.standalone&&!f)&&(b.usingWebAudio=!1)}b.usingWebAudio&&(b.masterGain="undefined"==typeof b.ctx.createGain?b.ctx.createGainNode():b.ctx.createGain(),b.masterGain.gain.value=1,b.masterGain.connect(b.ctx.destination)),b._setup()};"function"==typeof define&&define.amd&&define([],function(){return{Howler:b,Howl:c}}),"undefined"!=typeof exports&&(exports.Howler=b,exports.Howl=c),"undefined"!=typeof window?(window.HowlerGlobal=a,window.Howler=b,window.Howl=c,window.Sound=d):"undefined"!=typeof global&&(global.HowlerGlobal=a,global.Howler=b,global.Howl=c,global.Sound=d)}(),function(){me.plugins={},me.plugin=function(){var a={};return a.Base=me.Object.extend({init:function(){this.version="4.0.0"}}),a.patch=function(a,b,c){if("undefined"!=typeof a.prototype&&(a=a.prototype),"function"==typeof a[b]){var d=a[b];Object.defineProperty(a,b,{configurable:!0,value:function(a,b){return function(){this._patched=d;var a=b.apply(this,arguments);return this._patched=null,a}}(b,c)})}else console.error(b+" is not an existing function")},a.register=function(a,b){me.plugin[b]&&console.error("plugin "+b+" already registered");var c=[];arguments.length>2&&(c=Array.prototype.slice.call(arguments,1)),c[0]=a;var d=new(a.bind.apply(a,c));if(!(d&&d instanceof me.plugin.Base))throw new me.Error("Plugin should extend the me.plugin.Base Class !");if(me.sys.checkVersion(d.version)>0)throw new me.Error("Plugin version mismatch, expected: "+d.version+", got: "+me.version);me.plugins[b]=d},a}()}(),me.DraggableEntity=function(a,b,c,d){"use strict";return a.extend({init:function(c,e,f){a.prototype.init.apply(this,[c,e,f]),this.dragging=!1,this.dragId=null,this.grabOffset=new d(0,0),this.onPointerEvent=b.registerPointerEvent,this.removePointerEvent=b.releasePointerEvent,this.initEvents()},initEvents:function(){var a=this;this.mouseDown=function(a){this.translatePointerEvent(a,c.DRAGSTART)},this.mouseUp=function(a){this.translatePointerEvent(a,c.DRAGEND)},this.onPointerEvent("pointerdown",this,this.mouseDown.bind(this)),this.onPointerEvent("pointerup",this,this.mouseUp.bind(this)),c.subscribe(c.POINTERMOVE,this.dragMove.bind(this)),c.subscribe(c.DRAGSTART,function(b,c){c===a&&a.dragStart(b)}),c.subscribe(c.DRAGEND,function(b,c){c===a&&a.dragEnd(b)})},translatePointerEvent:function(a,b){c.publish(b,[a,this])},dragStart:function(a){return this.dragging===!1?(this.dragging=!0,this.dragId=a.pointerId,this.grabOffset.set(a.gameX,a.gameY),this.grabOffset.sub(this.pos),!1):void 0},dragMove:function(a){this.dragging===!0&&this.dragId===a.pointerId&&(this.pos.set(a.gameX,a.gameY,this.pos.z),this.pos.sub(this.grabOffset))},dragEnd:function(){return this.dragging===!0?(this.pointerId=void 0,this.dragging=!1,!1):void 0},destroy:function(){c.unsubscribe(c.POINTERMOVE,this.dragMove),c.unsubscribe(c.DRAGSTART,this.dragStart),c.unsubscribe(c.DRAGEND,this.dragEnd),this.removePointerEvent("pointerdown",this),this.removePointerEvent("pointerup",this)}})}(me.Entity,me.input,me.event,me.Vector2d),me.DroptargetEntity=function(a,b){"use strict";return a.extend({init:function(c,d,e){this.CHECKMETHOD_OVERLAP="overlaps",this.CHECKMETHOD_CONTAINS="contains",this.checkMethod=null,a.prototype.init.apply(this,[c,d,e]),b.subscribe(b.DRAGEND,this.checkOnMe.bind(this)),this.checkMethod=this[this.CHECKMETHOD_OVERLAP]},setCheckMethod:function(a){"undefined"!=typeof this[a]&&(this.checkMethod=this[a])},checkOnMe:function(a,b){b&&this.checkMethod(b.getBounds())&&this.drop(b)},drop:function(){},destroy:function(){b.unsubscribe(b.DRAGEND,this.checkOnMe)}})}(me.Entity,me.event),me.CollectableEntity=me.Entity.extend({init:function(a,b,c){me.Entity.prototype.init.apply(this,[a,b,c]),this.body.collisionType=me.collision.types.COLLECTABLE_OBJECT}}),me.LevelEntity=me.Entity.extend({init:function(a,b,c){me.Entity.prototype.init.apply(this,[a,b,c]),this.nextlevel=c.to,this.fade=c.fade,this.duration=c.duration,this.fading=!1,this.name="levelEntity",this.gotolevel=c.to,this.loadLevelSettings={},["container","onLoaded","flatten","setViewportBounds"].forEach(function(a){"undefined"!=typeof c[a]&&(this.loadLevelSettings[a]=c[a])}.bind(this)),this.body.collisionType=me.collision.types.ACTION_OBJECT},getlevelSettings:function(){return"string"==typeof this.loadLevelSettings.container&&(this.loadLevelSettings.container=me.game.world.getChildByName(this.loadLevelSettings.container)[0]),this.loadLevelSettings},onFadeComplete:function(){me.levelDirector.loadLevel(this.gotolevel,this.getlevelSettings()),me.game.viewport.fadeOut(this.fade,this.duration)},goTo:function(a){this.gotolevel=a||this.nextlevel,this.fade&&this.duration?this.fading||(this.fading=!0,me.game.viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):me.levelDirector.loadLevel(this.gotolevel,this.getlevelSettings())},onCollision:function(){return"levelEntity"===this.name&&this.goTo.apply(this),!1}}),function(){var a=function(){var a=me.video.createCanvas(1,1),b=a.getContext("2d");return b.fillStyle="#fff",b.fillRect(0,0,1,1),a}();me.ParticleEmitterSettings={width:0,height:0,image:a,totalParticles:50,angle:Math.PI/2,angleVariation:0,minLife:1e3,maxLife:3e3,speed:2,speedVariation:1,minRotation:0,maxRotation:0,minStartScale:1,maxStartScale:1,minEndScale:0,maxEndScale:0,gravity:0,wind:0,followTrajectory:!1,textureAdditive:!1,onlyInViewport:!0,floating:!1,maxParticles:10,frequency:100,duration:1/0,framesToSkip:0},me.ParticleEmitter=me.Rect.extend({init:function(a,b,c){this._stream=!1,this._frequencyTimer=0,this._durationTimer=0,this._enabled=!1,this.isRenderable=!1,me.Rect.prototype.init.apply(this,[a,b,1/0,1/0]),this.autoSort=!1,this.container=new me.ParticleContainer(this),Object.defineProperty(this.pos,"z",{get:function(){return this.container.pos.z}.bind(this),set:function(a){this.container.pos.z=a}.bind(this),enumerable:!0,configurable:!0}),Object.defineProperty(this,"floating",{get:function(){return this.container.floating},set:function(a){this.container.floating=a},enumerable:!0,configurable:!0}),this.reset(c)},onActivateEvent:function(){this.ancestor.addChild(this.container),this.container.pos.z=this.pos.z,this.ancestor.autoSort||this.ancestor.sort()},onDeactivateEvent:function(){this.ancestor.hasChild(this.container)&&this.ancestor.removeChildNow(this.container)},destroy:function(){this.reset()},getRandomPointX:function(){return this.pos.x+0..randomFloat(this.width)},getRandomPointY:function(){return this.pos.y+0..randomFloat(this.height)},reset:function(a){a=a||{};var b=me.ParticleEmitterSettings,c="number"==typeof a.width?a.width:b.width,d="number"==typeof a.height?a.height:b.height;this.resize(c,d),Object.assign(this,b,a),this.container.destroy()},addParticles:function(a){for(var b=0;~~a>b;b++){var c=me.pool.pull("me.Particle",this);this.container.addChild(c)}},isRunning:function(){return this._enabled&&this._stream},streamParticles:function(a){this._enabled=!0,this._stream=!0,this.frequency=Math.max(this.frequency,1),this._durationTimer="number"==typeof a?a:this.duration},stopStream:function(){this._enabled=!1},burstParticles:function(a){this._enabled=!0,this._stream=!1,this.addParticles("number"==typeof a?a:this.totalParticles),this._enabled=!1},update:function(a){if(this._enabled&&this._stream){if(this._durationTimer!==1/0&&(this._durationTimer-=a,this._durationTimer<=0))return this.stopStream(),!1;this._frequencyTimer+=a;var b=this.container.children.length;b=this.frequency&&(b+this.maxParticles<=this.totalParticles?this.addParticles(this.maxParticles):this.addParticles(this.totalParticles-b),this._frequencyTimer=0)}return!0}})}(),function(){me.ParticleContainer=me.Container.extend({init:function(a){this._viewport=me.game.viewport,me.Container.prototype.init.apply(this),this.autoSort=!1,this._updateCount=0,this._dt=0,this._emitter=a},getBounds:function(){return this._viewport},update:function(a){if(++this._updateCount>this._emitter.framesToSkip&&(this._updateCount=0),this._updateCount>0)return this._dt+=a,!1;a+=this._dt,this._dt=0;for(var b=me.game.viewport,c=this.children.length-1;c>=0;--c){var d=this.children[c];d.isRenderable=!0,d.inViewport=this.floating||d.pos.x0){var c,d=a.getContext();this._emitter.textureAdditive&&(c=d.globalCompositeOperation,d.globalCompositeOperation="lighter"),me.Container.prototype.draw.apply(this,[a,b]),this._emitter.textureAdditive&&(d.globalCompositeOperation=c)}}})}(),function(){me.Particle=me.Renderable.extend({init:function(a){me.Renderable.prototype.init.apply(this,[a.getRandomPointX(),a.getRandomPointY(),a.image.width,a.image.height]),this.alwaysUpdate=!0,this.isRenderable=!1,this.image=a.image;var b=a.angle+(a.angleVariation>0?(0..randomFloat(2)-1)*a.angleVariation:0),c=a.speed+(a.speedVariation>0?(0..randomFloat(2)-1)*a.speedVariation:0);this.vel=new me.Vector2d(c*Math.cos(b),-c*Math.sin(b)),this.life=a.minLife.randomFloat(a.maxLife),this.startLife=this.life,this.startScale=a.minStartScale.randomFloat(a.maxStartScale).clamp(a.minStartScale,a.maxStartScale),this.endScale=a.minEndScale.randomFloat(a.maxEndScale).clamp(a.minEndScale,a.maxEndScale),this.gravity=a.gravity,this.wind=a.wind,this.followTrajectory=a.followTrajectory,this.onlyInViewport=a.onlyInViewport,this.pos.z=a.z,this._deltaInv=me.sys.fps/1e3,a.followTrajectory||(this.angle=a.minRotation.randomFloat(a.maxRotation))},update:function(a){var b=a*this._deltaInv;this.life=this.life>a?this.life-a:0;var c=this.life/this.startLife,d=this.startScale;this.startScale>this.endScale?(d*=c,d=dthis.endScale?this.endScale:d),this.alpha=c,this.vel.x+=this.wind*b,this.vel.y+=this.gravity*b;var e=this.followTrajectory?Math.atan2(this.vel.y,this.vel.x):this.angle;return this.pos.x+=this.vel.x*b,this.pos.y+=this.vel.y*b,this.currentTransform.setTransform(d,0,0,0,d,0,this.pos.x,this.pos.y,1).rotate(e),(this.inViewport||!this.onlyInViewport)&&this.life>0},draw:function(a){a.save(),a.setGlobalAlpha(a.globalAlpha()*this.alpha),a.transform(this.currentTransform);var b=this.width,c=this.height;a.drawImage(this.image,0,0,b,c,-b/2,-c/2,b,c),a.restore()}})}(window); \ No newline at end of file diff --git a/games/clumsyBird/js/screens/gameover.js b/games/clumsyBird/js/screens/gameover.js new file mode 100644 index 0000000..20a9bb8 --- /dev/null +++ b/games/clumsyBird/js/screens/gameover.js @@ -0,0 +1,110 @@ +game.GameOverScreen = me.ScreenObject.extend({ + init: function() { + this.savedData = null; + this.handler = null; + }, + + onResetEvent: function() { + //save section + this.savedData = { + score: game.data.score, + steps: game.data.steps + }; + me.save.add(this.savedData); + + if (!me.save.topSteps) me.save.add({topSteps: game.data.steps}); + if (game.data.steps > me.save.topSteps) { + me.save.topSteps = game.data.steps; + game.data.newHiScore = true; + } + me.input.bindKey(me.input.KEY.ENTER, "enter", true); + me.input.bindKey(me.input.KEY.SPACE, "enter", false) + me.input.bindPointer(me.input.pointer.LEFT, me.input.KEY.ENTER); + + this.handler = me.event.subscribe(me.event.KEYDOWN, + function (action, keyCode, edge) { + if (action === "enter") { + me.state.change(me.state.MENU); + } + }); + + me.game.world.addChild(new me.Sprite( + me.game.viewport.width/2, + me.game.viewport.height/2 - 100, + {image: 'gameover'} + ), 12); + + var gameOverBG = new me.Sprite( + me.game.viewport.width/2, + me.game.viewport.height/2, + {image: 'gameoverbg'} + ); + me.game.world.addChild(gameOverBG, 10); + + me.game.world.addChild(new BackgroundLayer('bg', 1)); + + // ground + this.ground1 = me.pool.pull('ground', 0, me.game.viewport.height - 96); + this.ground2 = me.pool.pull('ground', me.game.viewport.width, + me.video.renderer.getHeight() - 96); + me.game.world.addChild(this.ground1, 11); + me.game.world.addChild(this.ground2, 11); + + // add the dialog witht he game information + if (game.data.newHiScore) { + var newRect = new me.Sprite( + gameOverBG.width/2, + gameOverBG.height/2, + {image: 'new'} + ); + me.game.world.addChild(newRect, 12); + } + + this.dialog = new (me.Renderable.extend({ + // constructor + init: function() { + this._super(me.Renderable, 'init', + [0, 0, me.game.viewport.width/2, me.game.viewport.height/2] + ); + this.font = new me.Font('gamefont', 40, 'black', 'left'); + this.steps = 'Steps: ' + game.data.steps.toString(); + this.topSteps= 'Higher Step: ' + me.save.topSteps.toString(); + }, + + draw: function (renderer) { + var stepsText = this.font.measureText(renderer, this.steps); + var topStepsText = this.font.measureText(renderer, this.topSteps); + var scoreText = this.font.measureText(renderer, this.score); + + //steps + this.font.draw( + renderer, + this.steps, + me.game.viewport.width/2 - stepsText.width/2 - 60, + me.game.viewport.height/2 + ); + + //top score + this.font.draw( + renderer, + this.topSteps, + me.game.viewport.width/2 - stepsText.width/2 - 60, + me.game.viewport.height/2 + 50 + ); + } + })); + me.game.world.addChild(this.dialog, 12); + }, + + onDestroyEvent: function() { + // unregister the event + me.event.unsubscribe(this.handler); + me.input.unbindKey(me.input.KEY.ENTER); + me.input.unbindKey(me.input.KEY.SPACE); + me.input.unbindPointer(me.input.pointer.LEFT); + this.ground1 = null; + this.ground2 = null; + this.font = null; + me.audio.stop("theme"); + } +}); diff --git a/games/clumsyBird/js/screens/play.js b/games/clumsyBird/js/screens/play.js new file mode 100644 index 0000000..8780577 --- /dev/null +++ b/games/clumsyBird/js/screens/play.js @@ -0,0 +1,67 @@ +game.PlayScreen = me.ScreenObject.extend({ + init: function() { + me.audio.play("theme", true); + // lower audio volume on firefox browser + var vol = me.device.ua.indexOf("Firefox") !== -1 ? 0.3 : 0.5; + me.audio.setVolume(vol); + this._super(me.ScreenObject, 'init'); + }, + + onResetEvent: function() { + me.game.reset(); + me.audio.stop("theme"); + if (!game.data.muted){ + me.audio.play("theme", true); + } + + me.input.bindKey(me.input.KEY.SPACE, "fly", true); + game.data.score = 0; + game.data.steps = 0; + game.data.start = false; + game.data.newHiscore = false; + + me.game.world.addChild(new BackgroundLayer('bg', 1)); + + this.ground1 = me.pool.pull('ground', 0, me.game.viewport.height - 96); + this.ground2 = me.pool.pull('ground', me.game.viewport.width, + me.game.viewport.height - 96); + me.game.world.addChild(this.ground1, 11); + me.game.world.addChild(this.ground2, 11); + + this.HUD = new game.HUD.Container(); + me.game.world.addChild(this.HUD, 11); + + this.bird = me.pool.pull("clumsy", 60, me.game.viewport.height/2 - 100); + me.game.world.addChild(this.bird, 10); + + //inputs + me.input.bindPointer(me.input.pointer.LEFT, me.input.KEY.SPACE); + + this.getReady = new me.Sprite( + me.game.viewport.width/2, + me.game.viewport.height/2, + {image: 'getready'} + ); + me.game.world.addChild(this.getReady, 11); + + var that = this; + var fadeOut = new me.Tween(this.getReady).to({alpha: 0}, 2000) + .easing(me.Tween.Easing.Linear.None) + .onComplete(function() { + game.data.start = true; + me.game.world.addChild(new game.PipeGenerator(), 0); + me.game.world.removeChild(that.getReady); + }).start(); + }, + + onDestroyEvent: function() { + me.audio.stopTrack('theme'); + // free the stored instance + this.HUD = null; + this.bird = null; + this.ground1 = null; + this.ground2 = null; + me.input.unbindKey(me.input.KEY.SPACE); + me.input.unbindPointer(me.input.pointer.LEFT); + } +}); diff --git a/games/clumsyBird/js/screens/title.js b/games/clumsyBird/js/screens/title.js new file mode 100644 index 0000000..5e11a2f --- /dev/null +++ b/games/clumsyBird/js/screens/title.js @@ -0,0 +1,73 @@ +game.TitleScreen = me.ScreenObject.extend({ + init: function(){ + this._super(me.ScreenObject, 'init'); + this.font = null; + this.ground1 = null; + this.ground2 = null; + this.logo = null; + }, + + onResetEvent: function() { + me.audio.stop("theme"); + game.data.newHiScore = false; + + me.game.world.addChild(new BackgroundLayer('bg', 1)); + me.input.bindKey(me.input.KEY.ENTER, "enter", true); + me.input.bindKey(me.input.KEY.SPACE, "enter", true); + me.input.bindPointer(me.input.pointer.LEFT, me.input.KEY.ENTER); + + this.handler = me.event.subscribe(me.event.KEYDOWN, function (action, keyCode, edge) { + if (action === "enter") { + me.state.change(me.state.PLAY); + } + }); + + //logo + this.logo = new me.Sprite( + me.game.viewport.width/2, + me.game.viewport.height/2 - 20, + {image: 'logo'} + ); + me.game.world.addChild(this.logo, 10); + + var that = this; + var logoTween = me.pool.pull("me.Tween", this.logo.pos) + .to({y: me.game.viewport.height/2 - 100}, 1000) + .easing(me.Tween.Easing.Exponential.InOut).start(); + + this.ground1 = me.pool.pull("ground", 0, me.video.renderer.getHeight() - 96); + this.ground2 = me.pool.pull("ground", me.video.renderer.getWidth(), + me.video.renderer.getHeight() - 96); + me.game.world.addChild(this.ground1, 11); + me.game.world.addChild(this.ground2, 11); + + me.game.world.addChild(new (me.Renderable.extend ({ + // constructor + init: function() { + // size does not matter, it's just to avoid having a zero size + // renderable + this._super(me.Renderable, 'init', [0, 0, 100, 100]); + this.text = me.device.touch ? 'Tap to start' : 'PRESS SPACE OR CLICK LEFT MOUSE BUTTON TO START \n\t\t\t\t\t\t\t\t\t\t\tPRESS "M" TO MUTE SOUND'; + this.font = new me.Font('gamefont', 20, '#000'); + }, + draw: function (renderer) { + var measure = this.font.measureText(renderer, this.text); + var xpos = me.game.viewport.width/2 - measure.width/2; + var ypos = me.game.viewport.height/2 + 50; + this.font.draw(renderer, this.text, xpos, ypos); + } + })), 12); + }, + + onDestroyEvent: function() { + // unregister the event + me.event.unsubscribe(this.handler); + me.input.unbindKey(me.input.KEY.ENTER); + me.input.unbindKey(me.input.KEY.SPACE); + me.input.unbindPointer(me.input.pointer.LEFT); + this.ground1 = null; + this.ground2 = null; + me.game.world.removeChild(this.logo); + this.logo = null; + } +}); diff --git a/games/laya-snakes/images/bean1.png b/games/laya-snakes/images/bean1.png new file mode 100644 index 0000000..4bd7e97 Binary files /dev/null and b/games/laya-snakes/images/bean1.png differ diff --git a/games/laya-snakes/images/bean2.png b/games/laya-snakes/images/bean2.png new file mode 100644 index 0000000..06666d0 Binary files /dev/null and b/games/laya-snakes/images/bean2.png differ diff --git a/games/laya-snakes/images/bean3.png b/games/laya-snakes/images/bean3.png new file mode 100644 index 0000000..0f23c2c Binary files /dev/null and b/games/laya-snakes/images/bean3.png differ diff --git a/games/laya-snakes/images/bean4.png b/games/laya-snakes/images/bean4.png new file mode 100644 index 0000000..bac3929 Binary files /dev/null and b/games/laya-snakes/images/bean4.png differ diff --git a/games/laya-snakes/images/bean5.png b/games/laya-snakes/images/bean5.png new file mode 100644 index 0000000..fa8f72d Binary files /dev/null and b/games/laya-snakes/images/bean5.png differ diff --git a/games/laya-snakes/images/bean6.png b/games/laya-snakes/images/bean6.png new file mode 100644 index 0000000..8816677 Binary files /dev/null and b/games/laya-snakes/images/bean6.png differ diff --git a/games/laya-snakes/images/body1.png b/games/laya-snakes/images/body1.png new file mode 100644 index 0000000..26eed71 Binary files /dev/null and b/games/laya-snakes/images/body1.png differ diff --git a/games/laya-snakes/images/body2.png b/games/laya-snakes/images/body2.png new file mode 100644 index 0000000..4acc50a Binary files /dev/null and b/games/laya-snakes/images/body2.png differ diff --git a/games/laya-snakes/images/body3.png b/games/laya-snakes/images/body3.png new file mode 100644 index 0000000..a12d798 Binary files /dev/null and b/games/laya-snakes/images/body3.png differ diff --git a/games/laya-snakes/images/body4.png b/games/laya-snakes/images/body4.png new file mode 100644 index 0000000..06bb2ad Binary files /dev/null and b/games/laya-snakes/images/body4.png differ diff --git a/games/laya-snakes/images/body5.png b/games/laya-snakes/images/body5.png new file mode 100644 index 0000000..b22ce0f Binary files /dev/null and b/games/laya-snakes/images/body5.png differ diff --git a/games/laya-snakes/images/btn-back.png b/games/laya-snakes/images/btn-back.png new file mode 100644 index 0000000..fb69273 Binary files /dev/null and b/games/laya-snakes/images/btn-back.png differ diff --git a/games/laya-snakes/images/btn-restart.png b/games/laya-snakes/images/btn-restart.png new file mode 100644 index 0000000..1139f6b Binary files /dev/null and b/games/laya-snakes/images/btn-restart.png differ diff --git a/games/laya-snakes/images/control-back.png b/games/laya-snakes/images/control-back.png new file mode 100644 index 0000000..9373851 Binary files /dev/null and b/games/laya-snakes/images/control-back.png differ diff --git a/games/laya-snakes/images/control-flash.png b/games/laya-snakes/images/control-flash.png new file mode 100644 index 0000000..96b6fea Binary files /dev/null and b/games/laya-snakes/images/control-flash.png differ diff --git a/games/laya-snakes/images/control-rocker.png b/games/laya-snakes/images/control-rocker.png new file mode 100644 index 0000000..5b1dba1 Binary files /dev/null and b/games/laya-snakes/images/control-rocker.png differ diff --git a/games/laya-snakes/images/gameover-background.png b/games/laya-snakes/images/gameover-background.png new file mode 100644 index 0000000..775870f Binary files /dev/null and b/games/laya-snakes/images/gameover-background.png differ diff --git a/games/laya-snakes/images/head1.png b/games/laya-snakes/images/head1.png new file mode 100644 index 0000000..cec9cba Binary files /dev/null and b/games/laya-snakes/images/head1.png differ diff --git a/games/laya-snakes/images/head2.png b/games/laya-snakes/images/head2.png new file mode 100644 index 0000000..cd3ceb5 Binary files /dev/null and b/games/laya-snakes/images/head2.png differ diff --git a/games/laya-snakes/images/head3.png b/games/laya-snakes/images/head3.png new file mode 100644 index 0000000..6b381cc Binary files /dev/null and b/games/laya-snakes/images/head3.png differ diff --git a/games/laya-snakes/images/head4.png b/games/laya-snakes/images/head4.png new file mode 100644 index 0000000..34019e6 Binary files /dev/null and b/games/laya-snakes/images/head4.png differ diff --git a/games/laya-snakes/images/head5.png b/games/laya-snakes/images/head5.png new file mode 100644 index 0000000..9693524 Binary files /dev/null and b/games/laya-snakes/images/head5.png differ diff --git a/games/laya-snakes/images/map-tile.jpg b/games/laya-snakes/images/map-tile.jpg new file mode 100644 index 0000000..ac29282 Binary files /dev/null and b/games/laya-snakes/images/map-tile.jpg differ diff --git a/games/laya-snakes/images/mask.png b/games/laya-snakes/images/mask.png new file mode 100644 index 0000000..bd0a428 Binary files /dev/null and b/games/laya-snakes/images/mask.png differ diff --git a/games/laya-snakes/images/s1-background.jpg b/games/laya-snakes/images/s1-background.jpg new file mode 100644 index 0000000..9b64c3e Binary files /dev/null and b/games/laya-snakes/images/s1-background.jpg differ diff --git a/games/laya-snakes/images/s1-btn1.png b/games/laya-snakes/images/s1-btn1.png new file mode 100644 index 0000000..68dad22 Binary files /dev/null and b/games/laya-snakes/images/s1-btn1.png differ diff --git a/games/laya-snakes/images/s1-btn2.png b/games/laya-snakes/images/s1-btn2.png new file mode 100644 index 0000000..fda92bf Binary files /dev/null and b/games/laya-snakes/images/s1-btn2.png differ diff --git a/games/laya-snakes/images/s1-input.png b/games/laya-snakes/images/s1-input.png new file mode 100644 index 0000000..a35de98 Binary files /dev/null and b/games/laya-snakes/images/s1-input.png differ diff --git a/games/laya-snakes/images/s1-option-background.png b/games/laya-snakes/images/s1-option-background.png new file mode 100644 index 0000000..ac5de7c Binary files /dev/null and b/games/laya-snakes/images/s1-option-background.png differ diff --git a/games/laya-snakes/images/s1-radio.png b/games/laya-snakes/images/s1-radio.png new file mode 100644 index 0000000..652def1 Binary files /dev/null and b/games/laya-snakes/images/s1-radio.png differ diff --git a/games/laya-snakes/index.html b/games/laya-snakes/index.html new file mode 100644 index 0000000..58c20d9 --- /dev/null +++ b/games/laya-snakes/index.html @@ -0,0 +1,63 @@ + + + + + + 贪吃蛇小作战 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/games/laya-snakes/js/Bean.js b/games/laya-snakes/js/Bean.js new file mode 100644 index 0000000..07748b3 --- /dev/null +++ b/games/laya-snakes/js/Bean.js @@ -0,0 +1,40 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/** + * Bean extends laya.display.Sprite + */ +var Bean = (function (_super) { + __extends(Bean, _super); + function Bean(x, y, colorNum) { + if (x === void 0) { x = Math.random() * game.gameMainUI.map.width; } + if (y === void 0) { y = Math.random() * game.gameMainUI.map.height; } + if (colorNum === void 0) { colorNum = Math.floor(Math.random() * (6 - 1 + 1) + 1); } + _super.call(this); + this.haveEaten = false; + this.speed = 2; + this.eatenTargetPos = { x: 0, y: 0 }; + this.haveEatenDis = 4; + this.eatenPos = { x: 0, y: 0 }; + this.eatenInitPos = { x: 0, y: 0 }; + this.colorNum = colorNum; + this.zOrder = 0; + this.visible = false; + this.eatenInitPos["x"] = x; + this.eatenInitPos["y"] = y; + this.init(x, y); + } + Bean.prototype.init = function (x, y) { + this.loadImage("images/bean" + this.colorNum + ".png", 0, 0, 0, 0, new Handler(this, this.loaded, [x, y])); + }; + Bean.prototype.loaded = function (x, y) { + this.zOrder = 0; + this.pivot(this.width / 2, this.height / 2); + this.pos(x, y); + this.visible = true; + }; + return Bean; +}(laya.display.Sprite)); +//# sourceMappingURL=Bean.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/Bean.js.map b/games/laya-snakes/js/Bean.js.map new file mode 100644 index 0000000..65fdc1f --- /dev/null +++ b/games/laya-snakes/js/Bean.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Bean.js","sourceRoot":"","sources":["../../src/Bean.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH;IAAmB,wBAAmB;IAYlC,cACI,CAAqD,EACnD,CAAsD,EACtD,QAA8D;QAFhE,iBAAqD,GAArD,IAAY,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK;QACnD,iBAAsD,GAAtD,IAAY,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM;QACtD,wBAA8D,GAA9D,WAAmB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEhE,iBAAO,CAAA;QAbX,cAAS,GAAY,KAAK,CAAA;QAE1B,UAAK,GAAW,CAAC,CAAA;QACjB,mBAAc,GAAW,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QACvC,iBAAY,GAAW,CAAC,CAAA;QACxB,aAAQ,GAAW,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QACjC,iBAAY,GAAW,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAQjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACf,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC1B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC1B,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,mBAAI,GAAJ,UAAK,CAAS,EAAE,CAAS;QACrB,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9G,CAAC;IAED,qBAAM,GAAN,UAAO,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC3C,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACvB,CAAC;IACL,WAAC;AAAD,CAAC,AApCD,CAAmB,IAAI,CAAC,OAAO,CAAC,MAAM,GAoCrC"} \ No newline at end of file diff --git a/games/laya-snakes/js/Game.js b/games/laya-snakes/js/Game.js new file mode 100644 index 0000000..9d5274e --- /dev/null +++ b/games/laya-snakes/js/Game.js @@ -0,0 +1,287 @@ +var Sprite = laya.display.Sprite; +var Loader = laya.net.Loader; +var Texture = laya.resource.Texture; +var Handler = laya.utils.Handler; +var Browser = laya.utils.Browser; +var TiledMap = laya.map.TiledMap; +var Rectangle = laya.maths.Rectangle; +var Stat = laya.utils.Stat; +var TextFiled = laya.display.Text; +var LocalStorage = laya.net.LocalStorage; +/** +* Game +* 游戏入口类 +*/ +var Game = (function () { + function Game() { + this.stageW = Browser.onQQBrowser ? Browser.width / Browser.pixelRatio : Browser.clientWidth; + this.stageH = Browser.onQQBrowser ? Browser.height / Browser.pixelRatio : Browser.clientHeight; + this.beanSingleNumInit = 300; + this.beanMaxNum = 600; + this.beanNum = 0; + this.beanOrder = 0; + this.beans = {}; + this.SnakeAINum = 5; + this.snakeAIArr = []; + this._init(); + Stat.show(200, 10); + } + //屏幕适配、初始化舞台 + Game.prototype._init = function () { + this.stageW = 600; + this.stageH = Browser.height / Browser.width * this.stageW; + Laya.init(this.stageW, this.stageH, Laya.WebGL); + Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL; + Laya.stage.alignH = Laya.Stage.ALIGN_CENTER; + Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE; + Laya.stage.screenMode = Laya.Stage.SCREEN_HORIZONTAL; + Laya.stage.bgColor = "#555555"; + //加载资源 + this._load(); + //对屏幕改小改变进行监听 + Browser.window.onresize = onWindowResize; + }; + Game.prototype._onresizeAction = function () { + this.loading && this.loading.pos(this.stageW / 2, this.stageH / 2); + this.gameStartUI && this.gameStartUI.pos(this.stageW / 2, this.stageH / 2); + this.gameMainUI && (this.gameMainUI.mask_rank.x = (this.stageW - this.gameMainUI.mask_rank.width - 10)); + this.gameMainUI && this.gameMainUI.ctrl_flash.pos(this.stageW - this.gameMainUI.ctrl_flash.width, this.stageH - this.gameMainUI.ctrl_flash.height); + this.gameMainUI && this.gameMainUI.ctrl_back.pos(this.gameMainUI.ctrl_back.width, this.stageH - this.gameMainUI.ctrl_back.height); + }; + //加载资源 + Game.prototype._load = function () { + var _this = this; + this.loading = new TextFiled(); + this.loading.text = "正在加载资源,请稍后..."; + this.loading.color = "#000000"; + this.loading.font = "Microsoft YaHei"; + this.loading.pos(this.stageW / 2, this.stageH / 2); + this.loading.pivot(this.loading.width / 2, this.loading.height / 2); + Laya.stage.addChild(this.loading); + //加载资源 + Laya.loader.load("res/atlas/images.json", Laya.Handler.create(this, function () { + //资源加载完成则进入开始界面 + // this.gameStartSence() + _this.gameMain(); + }), null, Laya.Loader.ATLAS); + Laya.loader.load("map/tile_map.png"); + Laya.loader.load("images/head1.png"); + Laya.loader.load("images/head2.png"); + Laya.loader.load("images/head3.png"); + Laya.loader.load("images/head4.png"); + Laya.loader.load("images/head5.png"); + }; + //开始界面 + Game.prototype.gameStartSence = function () { + this.gameStartUI = new GameStart(); + this.gameStartUI.pos(this.stageW / 2, this.stageH / 2); + this.gameStartUI.btn_single.on("click", this, this.gameStart, [0]); + this.gameStartUI.btn_net.on("click", this, this.gameStart, [1]); + Laya.stage.addChild(this.gameStartUI); + Laya.stage.removeChild(this.loading); + this.loading.destroy(); + }; + //开始游戏,进入GameMain + Game.prototype.gameStart = function (gameMode) { + this.nickname = this.gameStartUI.nickname.label; + this.neturl = this.gameStartUI.neturl.label; + this.skin = this.gameStartUI.skinRadio.selectedIndex; + this.gameMode = gameMode; + Laya.stage.removeChild(this.gameStartUI); + this.gameMain(); + }; + //进行游戏 + Game.prototype.gameMain = function () { + this.gameMainUI = new GameMain(); + this.gameMainUI.map.pos(this.stageW / 2, this.stageH / 2); + this.gameMainUI.mask_rank.x = this.stageW - this.gameMainUI.mask_rank.width - 10; + this.gameMainUI.ctrl_flash.pos(this.stageW - this.gameMainUI.ctrl_flash.width - 30, this.stageH - this.gameMainUI.ctrl_flash.height); + this.gameMainUI.ctrl_back.pos(this.gameMainUI.ctrl_back.width + 30, this.stageH - this.gameMainUI.ctrl_back.height); + Laya.stage.addChild(this.gameMainUI); + for (var _bean_i = 0; _bean_i < this.beanSingleNumInit; _bean_i++) { + this.beanOrder++; + this.addBean(this.beanOrder); + } + this.addBeanRandom(); + this.snakeSelf = new Snake(); + this.gameMainUI.map.addChild(this.snakeSelf); + for (var index = 0; index < this.SnakeAINum; index++) { + var snakeAI = new Snake(Math.floor(Math.random() * (5 - 1 + 1) + 1), this.gameMainUI.map.width * Math.random(), this.gameMainUI.map.height * Math.random()); + snakeAI.AI = true; + this.snakeAIArr.push(snakeAI); + this.gameMainUI.map.addChild(snakeAI); + } + this.snakeAIRotation(); + Laya.timer.frameLoop(1, this, this.gameLoop); + }; + //游戏主循环 + Game.prototype.gameLoop = function () { + this.snakeSelf.move(); + this.snakeAIMove(); + this.mapMove(); + this.eateBean(); + this.gameMainUI.text_length.text = this.snakeSelf.snakeLength + ""; + // this.gameMainUI.text_kill.text = this.snakeSelf.snakeSize + "" + // this.gameMainUI.text_kill.text = Browser.width + " " + Browser.clientWidth + " " + Browser.pixelRatio + }; + Game.prototype.eateBean = function () { + for (var key in this.beans) { + var bean = this.beans[key]; + // if (bean.haveEaten) {//确定了有被吃对象 + // let x = (bean.speed) * Math.cos(Math.atan2(bean.eatenInitPos["y"] - bean.y, bean.eatenInitPos["x"] - bean.x)) + // let y = (bean.speed) * Math.sin(Math.atan2(bean.eatenInitPos["y"] - bean.y, bean.eatenInitPos["x"] - bean.x)) + // bean.x += x + // bean.y += y + // bean.eatenPos["x"] += x + // bean.eatenPos["x"] += y + // // console.log(distance(bean.eatenPos["x"], bean.eatenPos["y"], bean.eatenInitPos["x"], bean.eatenInitPos["x"])) + // if (distance(bean.x, bean.y, bean.eatenInitPos["x"], bean.eatenInitPos["y"]) < bean.haveEatenDis) { + // bean.destroy() + // this.beans[key] = undefined + // delete this.beans[key] + // this.snakeSelf.snakeLength++ + // this.snakeSelf.eatBean++ + // this.beanNum-- + // } + // } else if (distance(bean.x, bean.y, this.snakeSelf.x, this.snakeSelf.y) <= (this.snakeSelf.width / 2) + 20) { + // bean.eatenTarget = this.snakeSelf + // bean.eatenInitPos["x"] = this.snakeSelf.x + this.snakeSelf.speed * 10 * Math.cos(this.snakeSelf.rotation * Math.PI / 180) + // bean.eatenInitPos["y"] = this.snakeSelf.y + this.snakeSelf.speed * 10 * Math.sin(this.snakeSelf.rotation * Math.PI / 180) + // bean.haveEaten = true + // } + if (distance(bean.x, bean.y, this.snakeSelf.x, this.snakeSelf.y) <= this.snakeSelf.width / 2) { + bean.destroy(); + this.beans[key] = undefined; + delete this.beans[key]; + this.snakeSelf.snakeLength++; + this.snakeSelf.eatBean++; + this.beanNum--; + } + else if (distance(bean.x, bean.y, this.snakeSelf.x, this.snakeSelf.y) <= (this.snakeSelf.width / 2) + 20) { + bean.x += (this.snakeSelf.speed + 0.1) * Math.cos(Math.atan2(this.snakeSelf.y - bean.y, this.snakeSelf.x - bean.x)); + bean.y += (this.snakeSelf.speed + 0.1) * Math.sin(Math.atan2(this.snakeSelf.y - bean.y, this.snakeSelf.x - bean.x)); + } + for (var index = 0; index < this.snakeAIArr.length; index++) { + var element = this.snakeAIArr[index]; + if (distance(bean.x, bean.y, element.x, element.y) <= element.width / 2) { + bean.destroy(); + this.beans[key] = undefined; + delete this.beans[key]; + element.snakeLength++; + element.eatBean++; + this.beanNum--; + } + else if (distance(bean.x, bean.y, element.x, element.y) <= (element.width / 2) + 20) { + bean.x += (bean.speed) * Math.cos(Math.atan2(element.y - bean.y, element.x - bean.x)); + bean.y += (bean.speed) * Math.sin(Math.atan2(element.y - bean.y, element.x - bean.x)); + } + } + } + }; + //做地图相对移动,以便能让玩家的蛇始终居中 + Game.prototype.mapMove = function () { + var mapScale = this.snakeSelf.snakeInitSize / this.snakeSelf.snakeSize < 0.7 ? 0.7 : this.snakeSelf.snakeInitSize / this.snakeSelf.snakeSize; + // this.gameMainUI.map.x = -1 * (this.snakeSelf.x - this.stageW / 2 + this.snakeSelf.width / 2 - this.gameMainUI.map.width / 2) * mapScale + // this.gameMainUI.map.y = -1 * (this.snakeSelf.y - this.stageH / 2 + this.snakeSelf.height / 2 - this.gameMainUI.map.height / 2) * mapScale + this.gameMainUI.map.x = -1 * (this.snakeSelf.x + this.snakeSelf.width / 2 - this.gameMainUI.map.width / 2) * mapScale + this.stageW / 2; + this.gameMainUI.map.y = -1 * (this.snakeSelf.y + this.snakeSelf.height / 2 - this.gameMainUI.map.height / 2) * mapScale + this.stageH / 2; + this.gameMainUI.map.scale(mapScale, mapScale); + }; + Game.prototype.addBean = function (beanOrder, x, y, colorNum) { + var bean = new Bean(x, y, colorNum); + bean.orderNum = beanOrder; + this.beans[beanOrder] = bean; + this.gameMainUI.map.addChild(bean); + this.beanNum++; + }; + Game.prototype.addBeanRandom = function () { + var _this = this; + this.beanRandomTimer = setInterval(function () { + if (_this.beanNum < _this.beanMaxNum) { + for (var index = 0; index < 20; index++) { + _this.beanOrder++; + _this.addBean(_this.beanOrder); + } + } + }, 100); + }; + Game.prototype.snakeAIMove = function () { + for (var index = 0; index < this.snakeAIArr.length; index++) { + var snakeAI = this.snakeAIArr[index]; + snakeAI.move(); + var hitDis = 90 / snakeAI.speedObj["rotation"] * snakeAI.speed + snakeAI.width / 2; + var hitPos = { x: 0, y: 0 }; + hitPos["x"] = hitDis * Math.cos(snakeAI.rotation * Math.PI / 180) + snakeAI.x; + hitPos["y"] = hitDis * Math.sin(snakeAI.rotation * Math.PI / 180) + snakeAI.y; + var hiten = false; + //判断是否快碰撞到边界 + if (hitPos["x"] >= this.gameMainUI.map.width - snakeAI.width / 2 || hitPos["x"] <= snakeAI.width / 2 + || hitPos["y"] >= this.gameMainUI.map.height - snakeAI.width / 2 || hitPos["y"] <= snakeAI.width / 2) { + snakeAI.reverseRotation(); + } + //判断是否撞倒玩家蛇 + if (distance(hitPos["x"], hitPos["y"], this.snakeSelf.x, this.snakeSelf.y) <= this.snakeSelf.width) { + snakeAI.reverseRotation(); + hiten = true; + } + for (var index_1 = 0; index_1 < this.snakeSelf.bodyArr.length; index_1++) { + if (hiten) + break; + var element = this.snakeSelf.bodyArr[index_1]; + if (distance(hitPos["x"], hitPos["y"], element.x, element.y) <= element.width) { + snakeAI.reverseRotation(); + hiten = true; + } + } + //判断AI之间是否自己碰撞 + for (var i = 0; i < this.snakeAIArr.length; i++) { + if (hiten) + break; + var elementSnakeAI = this.snakeAIArr[i]; + if (index == i) + continue; + if (distance(hitPos["x"], hitPos["y"], elementSnakeAI.x, elementSnakeAI.y) <= elementSnakeAI.width) { + snakeAI.reverseRotation(); + hiten = true; + } + for (var index_2 = 0; index_2 < elementSnakeAI.bodyArr.length; index_2++) { + if (hiten) + break; + var element = elementSnakeAI.bodyArr[index_2]; + if (distance(hitPos["x"], hitPos["y"], element.x, element.y) <= element.width) { + snakeAI.reverseRotation(); + hiten = true; + } + } + } + } + }; + Game.prototype.snakeAIRotation = function () { + var _this = this; + for (var index = 0; index < this.snakeAIArr.length; index++) { + this.snakeAIArr[index].targetR = 180 - Math.random() * 360; + this.snakeAIArr[index].speedNow = Math.random() > 0.9 ? "fast" : "slow"; + } + setInterval(function () { + for (var index = 0; index < _this.snakeAIArr.length; index++) { + _this.snakeAIArr[index].targetR = 180 - Math.random() * 360; + _this.snakeAIArr[index].speedNow = Math.random() > 0.9 ? "fast" : "slow"; + } + }, 3000); + }; + return Game; +}()); +//当屏幕大小改变时回调 +function onWindowResize() { + game.stageW = Browser.onQQBrowser ? Browser.width / Browser.pixelRatio : Browser.width / Browser.pixelRatio; + game.stageH = Browser.onQQBrowser ? Browser.height / Browser.pixelRatio : Browser.height / Browser.pixelRatio; + Laya.stage.size(game.stageW, game.stageH); + //屏幕大小改变时发生的改变 + game._onresizeAction(); +} +//计算距离 +function distance(x1, y1, x2, y2) { + return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); +} +var game = new Game(); +//# sourceMappingURL=Game.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/Game.js.map b/games/laya-snakes/js/Game.js.map new file mode 100644 index 0000000..c0ddddd --- /dev/null +++ b/games/laya-snakes/js/Game.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Game.js","sourceRoot":"","sources":["../../src/Game.ts"],"names":[],"mappings":"AA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AAC,eAAe,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM;AACN,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;AACnE,CAAC;AAED,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA"} \ No newline at end of file diff --git a/games/laya-snakes/js/GameMain.js b/games/laya-snakes/js/GameMain.js new file mode 100644 index 0000000..c4de8f2 --- /dev/null +++ b/games/laya-snakes/js/GameMain.js @@ -0,0 +1,61 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/** + * GameMain extends ui.GameMainUI + */ +var GameMain = (function (_super) { + __extends(GameMain, _super); + function GameMain() { + _super.call(this); + this.keySpaceDown = false; + this.init(); + } + GameMain.prototype.init = function () { + this.ctrl_flash.on("mousedown", this.ctrl_flash, this.ctrlFlashDown); + this.ctrl_flash.on("mouseup", this.ctrl_flash, this.ctrlFlashUp); + Laya.stage.on("mouseup", this, this.ctrlRockerUp); + Laya.stage.on("mousemove", this, this.ctrlRockerDown); + Laya.stage.on("keydown", this, this.keyDown); + Laya.stage.on("keyup", this, this.keyUp); + }; + GameMain.prototype.keyUp = function (e) { + if (e.keyCode == 32) { + this.ctrlFlashUp(); + } + }; + GameMain.prototype.keyDown = function (e) { + if (e.keyCode == 32) { + this.ctrlFlashDown(); + } + }; + GameMain.prototype.ctrlFlashDown = function () { + game.snakeSelf.speedNow = "fast"; + }; + GameMain.prototype.ctrlFlashUp = function () { + game.snakeSelf.speedNow = "slow"; + }; + GameMain.prototype.ctrlRockerUp = function () { + if (Laya.stage.mouseX <= game.stageW / 1.5) { + this.ctrl_rocker.visible = true; + this.ctrl_rocker_move.visible = false; + } + }; + GameMain.prototype.ctrlRockerDown = function () { + if (Laya.stage.mouseX <= game.stageW / 1.5) { + this.ctrl_rocker.visible = false; + this.ctrl_rocker_move.visible = true; + if (distance(Laya.stage.mouseX, Laya.stage.mouseY, this.ctrl_back.x, this.ctrl_back.y) <= (this.ctrl_back.width / 2 - this.ctrl_rocker.width / 2)) { + this.ctrl_rocker_move.pos(Laya.stage.mouseX, Laya.stage.mouseY); + } + else { + this.ctrl_rocker_move.pos(this.ctrl_back.x + (this.ctrl_back.width / 2 - this.ctrl_rocker.width / 2) * Math.cos(Math.atan2(Laya.stage.mouseY - this.ctrl_back.y, Laya.stage.mouseX - this.ctrl_back.x)), this.ctrl_back.y + (this.ctrl_back.width / 2 - this.ctrl_rocker.width / 2) * Math.sin(Math.atan2(Laya.stage.mouseY - this.ctrl_back.y, Laya.stage.mouseX - this.ctrl_back.x))); + } + game.snakeSelf.targetR = Math.atan2(Laya.stage.mouseY - this.ctrl_back.y, Laya.stage.mouseX - this.ctrl_back.x) * 180 / Math.PI; + } + }; + return GameMain; +}(ui.GameMainUI)); +//# sourceMappingURL=GameMain.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/GameMain.js.map b/games/laya-snakes/js/GameMain.js.map new file mode 100644 index 0000000..66ec2a0 --- /dev/null +++ b/games/laya-snakes/js/GameMain.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GameMain.js","sourceRoot":"","sources":["../../src/GameMain.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH;IAAuB,4BAAa;IAIhC;QACI,iBAAO,CAAA;QAHX,iBAAY,GAAY,KAAK,CAAA;QAIzB,IAAI,CAAC,IAAI,EAAE,CAAA;IACf,CAAC;IAED,uBAAI,GAAJ;QACI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE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AAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAChL,CAAA;YACL,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAA;QACnI,CAAC;IACL,CAAC;IAGL,eAAC;AAAD,CAAC,AA5DD,CAAuB,EAAE,CAAC,UAAU,GA4DnC"} \ No newline at end of file diff --git a/games/laya-snakes/js/GameStart.js b/games/laya-snakes/js/GameStart.js new file mode 100644 index 0000000..7d94eee --- /dev/null +++ b/games/laya-snakes/js/GameStart.js @@ -0,0 +1,49 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/** + * GameStart extends ui.GameStartUI + */ +var GameStart = (function (_super) { + __extends(GameStart, _super); + function GameStart() { + _super.call(this); + this.init(); + } + GameStart.prototype.init = function () { + this.nickname.label = "游客" + Math.floor(Math.random() * (9999 - 1 + 1) + 1); + this.skinRadio.selectedIndex = Math.floor(Math.random() * (4 - 0 + 1) + 0); + this.neturl.label = "192.168.1.60"; + LocalStorage.getItem("nickname") && (this.nickname.label = LocalStorage.getItem("nickname")); + LocalStorage.getItem("neturl") && (this.neturl.label = LocalStorage.getItem("neturl")); + LocalStorage.getItem("skin") && (this.skinRadio.selectedIndex = parseInt(LocalStorage.getItem("skin"))); + this.nickname.on("click", this, this.changeNickName); + this.neturl.on("click", this, this.changeNetUrl); + this.skinRadio.on("click", this, this.onSelectSkin); + }; + GameStart.prototype.changeNickName = function () { + var nickname = window.prompt("请输入您的昵称!", this.nickname.label); + if (nickname != null && nickname != "") { + this.nickname.label = nickname; + } + else { + Browser.window.alert("请输入昵称!"); + } + }; + GameStart.prototype.changeNetUrl = function () { + var neturl = window.prompt("请输入服务器地址!", this.neturl.label); + if (neturl != null && neturl != "") { + this.neturl.label = neturl; + } + else { + Browser.window.alert("请输入服务器地址!"); + } + }; + GameStart.prototype.onSelectSkin = function () { + // Browser.window.alert(this.skinRadio.selectedIndex) + }; + return GameStart; +}(ui.GameStartUI)); +//# sourceMappingURL=GameStart.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/GameStart.js.map b/games/laya-snakes/js/GameStart.js.map new file mode 100644 index 0000000..8dd5a09 --- /dev/null +++ b/games/laya-snakes/js/GameStart.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GameStart.js","sourceRoot":"","sources":["../../src/GameStart.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH;IAAwB,6BAAc;IAClC;QACI,iBAAO,CAAA;QACP,IAAI,CAAC,IAAI,EAAE,CAAA;IACf,CAAC;IAED,wBAAI,GAAJ;QACI,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAC3E,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,MAAM,CA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AE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1D,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAA;QAC9B,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QACrC,CAAC;IACL,CAAC;IAED,gCAAY,GAAZ;QACI,qDAAqD;IACzD,CAAC;IACL,gBAAC;AAAD,CAAC,AAzCD,CAAwB,EAAE,CAAC,WAAW,GAyCrC"} \ No newline at end of file diff --git a/games/laya-snakes/js/Snake.js b/games/laya-snakes/js/Snake.js new file mode 100644 index 0000000..c705516 --- /dev/null +++ b/games/laya-snakes/js/Snake.js @@ -0,0 +1,187 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/** + * Snake extends laya.display.Sprite + */ +var Snake = (function (_super) { + __extends(Snake, _super); + function Snake(colorNum, x, y) { + if (colorNum === void 0) { colorNum = Math.floor(Math.random() * (5 - 1 + 1) + 1); } + if (x === void 0) { x = game.gameMainUI.map.width / 2; } + if (y === void 0) { y = game.gameMainUI.map.height / 2; } + _super.call(this); + this.speedObj = { "slow": 2, "fast": 4, "rotation": 10 }; + this.speedNow = "slow"; + this.snakeInitSize = 0.45; + this.snakeLength = 24; + this.kill = 0; + this.bodyArr = []; + this.pathArr = []; + this.eatBean = 0; + this.bodyBeanNum = 6; //吃几颗豆增加一节身体 + this.bodyMaxNum = 500; + this.initWidth = 40; + this.AI = false; + this.speed = this.speedObj[this.speedNow]; + this.targetR = this.rotation; + this.colorNum = colorNum; + this.visible = false; + this.snakeSize = this.snakeInitSize; + this.loadImage("images/head" + this.colorNum + ".png", 0, 0, 0, 0, new Handler(this, this.loaded, [x, y])); + } + Snake.prototype.loaded = function (x, y) { + this.zOrder = 11000; + this.initWidth = this.width; + this.rotationTemp = this.rotation; + this.snakeScale(this); + this.pivot(this.width / 2, this.height / 2); + this.pos(x, y); + this.visible = true; + this.bodySpace = Math.floor(this.width / 10 * 8); + for (var index = 1; index <= this.getBodyNum(); index++) { + this.addBody(this.x - index * this.bodySpace, this.y, this.rotation); + } + for (var index = 0; index < this.bodySpace * this.getBodyNum(); index++) { + this.pathArr.push({ + x: this.x - index, + y: this.y + }); + } + }; + Snake.prototype.move = function () { + this.bodySpace = Math.floor(this.width / 10 * 8); + this.headMove(); + this.bodyMove(); + this.speedChange(); + this.rotationChange(); + this.bodyCheck(); + }; + Snake.prototype.moveOut = function () { + //碰到边界了 + }; + Snake.prototype.headMove = function () { + var x = this.speed * Math.cos(this.rotation * Math.PI / 180); + var y = this.speed * Math.sin(this.rotation * Math.PI / 180); + this.rotation = this.rotationTemp; + var pos = { x: this.x, y: this.y }; + var posBefore = { x: this.x, y: this.y }; + if (!(this.x + x >= game.gameMainUI.map.width - this.width / 2 || this.x + x <= this.width / 2)) { + this.x += x; + pos.x = this.x; + } + else { + this.moveOut(); + } + if (!(this.y + y >= game.gameMainUI.map.height - this.width / 2 || this.y + y <= this.width / 2)) { + this.y += y; + pos.y = this.y; + } + else { + this.moveOut(); + } + for (var index = 1; index <= this.speed; index++) { + this.pathArr.unshift({ + x: index * Math.cos(Math.atan2(pos.y - posBefore.y, pos.x - posBefore.x)) + posBefore.x, + y: index * Math.sin(Math.atan2(pos.y - posBefore.y, pos.x - posBefore.x)) + posBefore.y + }); + } + }; + Snake.prototype.bodyMove = function () { + for (var index = 0; index < this.bodyArr.length; index++) { + var element = this.bodyArr[index]; + if (this.pathArr[(index + 1) * this.bodySpace]) { + element.rotation = Math.atan2(this.pathArr[(index + 1) * this.bodySpace]["y"] - element.y, this.pathArr[(index + 1) * this.bodySpace]["x"] - element.x) / Math.PI * 180; + element.pos(this.pathArr[(index + 1) * this.bodySpace]["x"], this.pathArr[(index + 1) * this.bodySpace]["y"]); + } + if (this.pathArr.length > this.bodyArr.length * (1 + this.bodySpace)) { + this.pathArr.pop(); + } + } + }; + Snake.prototype.snakeScale = function (ele, eleType) { + if (eleType === void 0) { eleType = "head"; } + var x = ele.x, y = ele.y, zOrder = ele.zOrder; + ele.pivot(ele.width / 2, ele.height / 2); + ele.graphics.clear(); + ele.loadImage("images/" + eleType + this.colorNum + ".png", 0, 0, this.initWidth * this.snakeSize, this.initWidth * this.snakeSize); + ele.pivot(ele.width / 2, ele.height / 2); + ele.pos(x, y); + this.speedObj["rotation"] = 4 / this.snakeSize; + }; + Snake.prototype.speedChange = function () { + this.speed = this.speedNow == 'slow' ? + (this.speed > this.speedObj[this.speedNow] ? this.speed - 1 : this.speedObj[this.speedNow]) + : (this.speed < this.speedObj[this.speedNow] ? this.speed + 1 : this.speedObj[this.speedNow]); + }; + Snake.prototype.rotationChange = function () { + var perRotation = Math.abs(this.targetR - this.rotationTemp) < this.speedObj['rotation'] ? Math.abs(this.targetR - this.rotationTemp) : this.speedObj['rotation']; + if (this.targetR < -0 && this.rotationTemp > 0 && Math.abs(this.targetR) + this.rotationTemp > 180) { + perRotation = (180 - this.rotationTemp) + (180 + this.targetR) < this.speedObj['rotation'] ? (180 - this.rotationTemp) + (180 + this.targetR) : this.speedObj['rotation']; + this.rotationTemp += perRotation; + } + else { + this.rotationTemp += this.targetR > this.rotationTemp && Math.abs(this.targetR - this.rotationTemp) <= 180 ? perRotation : -perRotation; + } + this.rotationTemp = Math.abs(this.rotationTemp) > 180 ? (this.rotationTemp > 0 ? this.rotationTemp - 360 : this.rotationTemp + 360) : this.rotationTemp; + }; + Snake.prototype.addBody = function (x, y, r) { + var _this = this; + var body = new Sprite(); + var zOrder = this.zOrder - this.bodyArr.length - 1; + body.visible = false; + body.alpha = 0; + body.zOrder = zOrder; + body.loadImage("images/body" + this.colorNum + ".png", 0, 0, 0, 0, new Handler(this, function () { + _this.snakeScale(body, "body"); + body.pos(x, y); + body.rotation = r; + game.gameMainUI.map.addChild(body); + body.visible = true; + body.alpha = 1; + })); + this.bodyArr.push(body); + }; + Snake.prototype.bodyCheck = function () { + var _this = this; + if (this.eatBean >= this.bodyBeanNum && this.bodyArr.length < this.bodyMaxNum) { + var addBodyNum = Math.floor(this.eatBean / this.bodyBeanNum); + var x = this.bodyArr[this.bodyArr.length - 1].x; + var y = this.bodyArr[this.bodyArr.length - 1].y; + var r = this.bodyArr[this.bodyArr.length - 1].rotation; + for (var index = 0; index < addBodyNum; index++) { + this.addBody(this.bodySpace * Math.cos(r * Math.PI / 180), this.bodySpace * Math.sin(r * Math.PI / 180), r); + } + for (var index = 0; index < this.bodySpace * addBodyNum; index++) { + this.pathArr.push({ + x: this.x - index * Math.cos(r * Math.PI / 180), + y: this.y - index * Math.sin(r * Math.PI / 180) + }); + } + this.eatBean = this.eatBean % this.bodyBeanNum; + if (this.snakeSize < 1) { + this.snakeSize = this.snakeInitSize + (1 - this.snakeInitSize) / this.bodyMaxNum * this.bodyArr.length; + this.bodyArr.forEach(function (element) { + _this.snakeScale(element, "body"); + }); + // for (let index = this.bodyArr.length - 1; index >= 0; index--) { + // this.snakeScale(this.bodyArr[index], "body") + // } + this.snakeScale(this); + } + else { + this.snakeSize = 1; + } + } + }; + Snake.prototype.getBodyNum = function () { + return Math.floor(this.snakeLength / this.bodyBeanNum); + }; + Snake.prototype.reverseRotation = function () { + this.targetR = this.rotation > 0 ? this.rotation - 180 : this.rotation + 180; + }; + return Snake; +}(laya.display.Sprite)); +//# sourceMappingURL=Snake.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/Snake.js.map b/games/laya-snakes/js/Snake.js.map new file mode 100644 index 0000000..8739bf0 --- /dev/null +++ b/games/laya-snakes/js/Snake.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Snake.js","sourceRoot":"","sources":["../../src/Snake.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH;I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C,EAAE,GAAG,GAAG,CAAC;iBACpD,CAAC,CAAA;YACN,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAA;YAE9C,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;gBACtG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,OAAO;oBACxB,KAAI,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;gBACpC,CAAC,CAAC,CAAA;gBACF,mEAAmE;gBACnE,mDAAmD;gBACnD,IAAI;gBACJ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,IAAI,CAAC,SAAS,GAAG,CAAC,CAAA;YACtB,CAAC;QACL,CAAC;IAEL,CAAC;IAED,0BAAU,GAAV;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;IAC1D,CAAC;IAED,+BAAe,GAAf;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAA;IAChF,CAAC;IACL,YAAC;AAAD,CAAC,AA3MD,CAAoB,IAAI,CAAC,OAAO,CAAC,MAAM,GA2MtC"} \ No newline at end of file diff --git a/games/laya-snakes/js/ui/layaUI.max.all.js b/games/laya-snakes/js/ui/layaUI.max.all.js new file mode 100644 index 0000000..45e1b03 --- /dev/null +++ b/games/laya-snakes/js/ui/layaUI.max.all.js @@ -0,0 +1,40 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var View = laya.ui.View; +var Dialog = laya.ui.Dialog; +var ui; +(function (ui) { + var GameMainUI = (function (_super) { + __extends(GameMainUI, _super); + function GameMainUI() { + _super.call(this); + } + GameMainUI.prototype.createChildren = function () { + _super.prototype.createChildren.call(this); + this.createView(ui.GameMainUI.uiView); + }; + GameMainUI.uiView = { "type": "View", "props": {}, "child": [{ "type": "Image", "props": { "var": "map", "skin": "map/tile_map.png", "pivotY": 750, "pivotX": 1500 } }, { "type": "Label", "props": { "y": 10, "x": 10, "text": "长度:" } }, { "type": "Label", "props": { "y": 10, "x": 44, "var": "text_length", "text": "0" } }, { "type": "Label", "props": { "y": 26, "x": 10, "text": "击杀:" } }, { "type": "Label", "props": { "y": 26, "x": 44, "var": "text_kill", "text": "0" } }, { "type": "Image", "props": { "y": 10, "x": 489, "width": 102, "var": "mask_rank", "skin": "images/mask.png", "height": 133 } }, { "type": "Button", "props": { "y": 321, "x": 511, "var": "ctrl_flash", "stateNum": "2", "skin": "images/control-flash.png", "pivotY": 40, "pivotX": 40 } }, { "type": "Image", "props": { "y": 329, "x": 85, "var": "ctrl_back", "skin": "images/control-back.png", "pivotY": 40, "pivotX": 40 }, "child": [{ "type": "Image", "props": { "y": 40, "x": 40, "var": "ctrl_rocker", "skin": "images/control-rocker.png", "pivotY": 17.5, "pivotX": 17.5 } }] }, { "type": "Image", "props": { "y": 357, "x": -32, "visible": false, "var": "ctrl_rocker_move", "skin": "images/control-rocker.png", "pivotY": 17.5, "pivotX": 17.5 } }] }; + return GameMainUI; + }(View)); + ui.GameMainUI = GameMainUI; +})(ui || (ui = {})); +var ui; +(function (ui) { + var GameStartUI = (function (_super) { + __extends(GameStartUI, _super); + function GameStartUI() { + _super.call(this); + } + GameStartUI.prototype.createChildren = function () { + _super.prototype.createChildren.call(this); + this.createView(ui.GameStartUI.uiView); + }; + GameStartUI.uiView = { "type": "View", "props": { "skin": "images/head2.png" }, "child": [{ "type": "Image", "props": { "var": "background", "skin": "images/s1-background.jpg", "pivotY": 297, "pivotX": 594, "name": "background" }, "child": [{ "type": "Image", "props": { "y": 204.5, "x": 394.5, "width": 399, "skin": "images/s1-option-background.png", "name": "option_background", "height": 211 }, "child": [{ "type": "RadioGroup", "props": { "y": 50, "x": 51, "var": "skinRadio", "space": -3, "skin": "images/s1-radio.png", "selectedIndex": 0, "labels": " 红色, 蓝色, 绿色, 紫色, 棕色", "labelPadding": "4", "direction": "vertical" } }, { "type": "Image", "props": { "y": 54, "x": 133, "width": 12, "skin": "images/head1.png", "rotation": 90, "height": 12 } }, { "type": "Image", "props": { "y": 75, "x": 133, "width": 12, "skin": "images/head2.png", "rotation": 90, "height": 12 } }, { "type": "Image", "props": { "y": 97, "x": 133, "width": 12, "skin": "images/head3.png", "rotation": 90, "height": 12 } }, { "type": "Image", "props": { "y": 118, "x": 133, "width": 12, "skin": "images/head4.png", "rotation": 90, "height": 12 } }, { "type": "Image", "props": { "y": 139, "x": 133, "width": 12, "skin": "images/head5.png", "rotation": 90, "height": 12 } }, { "type": "Button", "props": { "y": 14, "x": 234, "var": "btn_single", "stateNum": "1", "skin": "images/s1-btn1.png", "labelPadding": "-20", "labelBold": true, "label": "单人模式" } }, { "type": "Button", "props": { "y": 113, "x": 234, "var": "btn_net", "stateNum": "1", "skin": "images/s1-btn2.png", "labelPadding": "-20", "labelBold": true, "label": "多人模式" } }, { "type": "Button", "props": { "y": 13, "x": 46, "width": 126, "var": "nickname", "stateNum": "1", "skin": "images/s1-input.png", "label": "昵称", "height": 24 } }, { "type": "Button", "props": { "y": 166, "x": 46, "width": 126, "var": "neturl", "stateNum": "1", "skin": "images/s1-input.png", "label": "192.168.1.60", "height": 24 } }, { "type": "Label", "props": { "y": -31, "x": 139.5, "text": "贪吃蛇小作战", "fontSize": 20, "font": "Microsoft Yahei", "color": "#226eaa", "bold": true } }, { "type": "TextInput", "props": { "y": 190.5, "x": 161.5, "text": "TextInput", "skin": "comp/textinput.png" } }] }] }] }; + return GameStartUI; + }(View)); + ui.GameStartUI = GameStartUI; +})(ui || (ui = {})); +//# sourceMappingURL=layaUI.max.all.js.map \ No newline at end of file diff --git a/games/laya-snakes/js/ui/layaUI.max.all.js.map b/games/laya-snakes/js/ui/layaUI.max.all.js.map new file mode 100644 index 0000000..f131dff --- /dev/null +++ b/games/laya-snakes/js/ui/layaUI.max.all.js.map @@ -0,0 +1 @@ +{"version":3,"file":"layaUI.max.all.js","sourceRoot":"","sources":["../../../src/ui/layaUI.max.all.ts"],"names":[],"mappings":";;;;;AACA,IAAO,IAAI,GAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;AACzB,IAAO,MAAM,GAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;AAC7B,IAAO,EAAE,CAmBR;AAnBD,WAAO,EAAE,EAAC,CAAC;IACP;QAAgC,8BAAI;QAWhC;YAAe,iBAAO,CAAA;QAAA,CAAC;QACvB,mCAAc,GAAd;YAEI,gBAAK,CAAC,cAAc,WAAE,CAAC;YACvB,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;QANc,iBAAM,GAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,EAAC,CAAC,EAAC,MAAM,EAAC,OAAO,EAAC,OAAO,EAAC,EAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,kBAAkB,EAAC,QAAQ,EAAC,GAAG,EAAC,QAAQ,EAAC,IAAI,EAAC,EAAC,EAAC,EAAC,MAAM,EAAC,OAAO,EAAC,OAAO,EAAC,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,MAAM,EAAC,KAAK,EAAC,EAAC,EAAC,EAAC,MAA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,GAAG,EAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,EAAC,UAAU,EAAC,EAAE,EAAC,MAAM,EAAC,iBAAiB,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,EAAC,IAAI,EAAC,EAAC,EAAC,EAAC,MAAM,EAAC,WAAW,EAAC,OAAO,EAAC,EAAC,GAAG,EAAC,KAAK,EAAC,GAAG,EAAC,KAAK,EAAC,MAAM,EAAC,WAAW,EAAC,MAAM,EAAC,oBAAoB,EAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC;QAOj5D,kBAAC;IAAD,CAAC,AAfD,CAAiC,IAAI,GAepC;IAfY,cAAW,cAevB,CAAA;AACL,CAAC,EAjBM,EAAE,KAAF,EAAE,QAiBR"} \ No newline at end of file diff --git a/games/laya-snakes/libs/bytebuffer.js b/games/laya-snakes/libs/bytebuffer.js new file mode 100644 index 0000000..c140246 --- /dev/null +++ b/games/laya-snakes/libs/bytebuffer.js @@ -0,0 +1,3746 @@ +/* + Copyright 2013-2014 Daniel Wirtz + + 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. + */ + +/** + * @license bytebuffer.js (c) 2015 Daniel Wirtz + * Backing buffer: ArrayBuffer, Accessor: Uint8Array + * Released under the Apache License, Version 2.0 + * see: https://github.com/dcodeIO/bytebuffer.js for details + */ +(function(global, factory) { + + /* AMD */ if (typeof define === 'function' && define["amd"]) + define(["long"], factory); + /* CommonJS */ else if (typeof require === 'function' && typeof module === "object" && module && module["exports"]) + module['exports'] = (function() { + var Long; try { Long = require("long"); } catch (e) {} + return factory(Long); + })(); + /* Global */ else + (global["dcodeIO"] = global["dcodeIO"] || {})["ByteBuffer"] = factory(global["dcodeIO"]["Long"]); + +})(this, function(Long) { + "use strict"; + + /** + * Constructs a new ByteBuffer. + * @class The swiss army knife for binary data in JavaScript. + * @exports ByteBuffer + * @constructor + * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}. + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @expose + */ + var ByteBuffer = function(capacity, littleEndian, noAssert) { + if (typeof capacity === 'undefined') + capacity = ByteBuffer.DEFAULT_CAPACITY; + if (typeof littleEndian === 'undefined') + littleEndian = ByteBuffer.DEFAULT_ENDIAN; + if (typeof noAssert === 'undefined') + noAssert = ByteBuffer.DEFAULT_NOASSERT; + if (!noAssert) { + capacity = capacity | 0; + if (capacity < 0) + throw RangeError("Illegal capacity"); + littleEndian = !!littleEndian; + noAssert = !!noAssert; + } + + /** + * Backing ArrayBuffer. + * @type {!ArrayBuffer} + * @expose + */ + this.buffer = capacity === 0 ? EMPTY_BUFFER : new ArrayBuffer(capacity); + + /** + * Uint8Array utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`. + * @type {?Uint8Array} + * @expose + */ + this.view = capacity === 0 ? null : new Uint8Array(this.buffer); + + /** + * Absolute read/write offset. + * @type {number} + * @expose + * @see ByteBuffer#flip + * @see ByteBuffer#clear + */ + this.offset = 0; + + /** + * Marked offset. + * @type {number} + * @expose + * @see ByteBuffer#mark + * @see ByteBuffer#reset + */ + this.markedOffset = -1; + + /** + * Absolute limit of the contained data. Set to the backing buffer's capacity upon allocation. + * @type {number} + * @expose + * @see ByteBuffer#flip + * @see ByteBuffer#clear + */ + this.limit = capacity; + + /** + * Whether to use little endian byte order, defaults to `false` for big endian. + * @type {boolean} + * @expose + */ + this.littleEndian = littleEndian; + + /** + * Whether to skip assertions of offsets and values, defaults to `false`. + * @type {boolean} + * @expose + */ + this.noAssert = noAssert; + }; + + /** + * ByteBuffer version. + * @type {string} + * @const + * @expose + */ + ByteBuffer.VERSION = "5.0.1"; + + /** + * Little endian constant that can be used instead of its boolean value. Evaluates to `true`. + * @type {boolean} + * @const + * @expose + */ + ByteBuffer.LITTLE_ENDIAN = true; + + /** + * Big endian constant that can be used instead of its boolean value. Evaluates to `false`. + * @type {boolean} + * @const + * @expose + */ + ByteBuffer.BIG_ENDIAN = false; + + /** + * Default initial capacity of `16`. + * @type {number} + * @expose + */ + ByteBuffer.DEFAULT_CAPACITY = 16; + + /** + * Default endianess of `false` for big endian. + * @type {boolean} + * @expose + */ + ByteBuffer.DEFAULT_ENDIAN = ByteBuffer.BIG_ENDIAN; + + /** + * Default no assertions flag of `false`. + * @type {boolean} + * @expose + */ + ByteBuffer.DEFAULT_NOASSERT = false; + + /** + * A `Long` class for representing a 64-bit two's-complement integer value. May be `null` if Long.js has not been loaded + * and int64 support is not available. + * @type {?Long} + * @const + * @see https://github.com/dcodeIO/long.js + * @expose + */ + ByteBuffer.Long = Long || null; + + /** + * @alias ByteBuffer.prototype + * @inner + */ + var ByteBufferPrototype = ByteBuffer.prototype; + + /** + * An indicator used to reliably determine if an object is a ByteBuffer or not. + * @type {boolean} + * @const + * @expose + * @private + */ + ByteBufferPrototype.__isByteBuffer__; + + Object.defineProperty(ByteBufferPrototype, "__isByteBuffer__", { + value: true, + enumerable: false, + configurable: false + }); + + // helpers + + /** + * @type {!ArrayBuffer} + * @inner + */ + var EMPTY_BUFFER = new ArrayBuffer(0); + + /** + * String.fromCharCode reference for compile-time renaming. + * @type {function(...number):string} + * @inner + */ + var stringFromCharCode = String.fromCharCode; + + /** + * Creates a source function for a string. + * @param {string} s String to read from + * @returns {function():number|null} Source function returning the next char code respectively `null` if there are + * no more characters left. + * @throws {TypeError} If the argument is invalid + * @inner + */ + function stringSource(s) { + var i=0; return function() { + return i < s.length ? s.charCodeAt(i++) : null; + }; + } + + /** + * Creates a destination function for a string. + * @returns {function(number=):undefined|string} Destination function successively called with the next char code. + * Returns the final string when called without arguments. + * @inner + */ + function stringDestination() { + var cs = [], ps = []; return function() { + if (arguments.length === 0) + return ps.join('')+stringFromCharCode.apply(String, cs); + if (cs.length + arguments.length > 1024) + ps.push(stringFromCharCode.apply(String, cs)), + cs.length = 0; + Array.prototype.push.apply(cs, arguments); + }; + } + + /** + * Gets the accessor type. + * @returns {Function} `Buffer` under node.js, `Uint8Array` respectively `DataView` in the browser (classes) + * @expose + */ + ByteBuffer.accessor = function() { + return Uint8Array; + }; + /** + * Allocates a new ByteBuffer backed by a buffer of the specified capacity. + * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}. + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} + * @expose + */ + ByteBuffer.allocate = function(capacity, littleEndian, noAssert) { + return new ByteBuffer(capacity, littleEndian, noAssert); + }; + + /** + * Concatenates multiple ByteBuffers into one. + * @param {!Array.} buffers Buffers to concatenate + * @param {(string|boolean)=} encoding String encoding if `buffers` contains a string ("base64", "hex", "binary", + * defaults to "utf8") + * @param {boolean=} littleEndian Whether to use little or big endian byte order for the resulting ByteBuffer. Defaults + * to {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values for the resulting ByteBuffer. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} Concatenated ByteBuffer + * @expose + */ + ByteBuffer.concat = function(buffers, encoding, littleEndian, noAssert) { + if (typeof encoding === 'boolean' || typeof encoding !== 'string') { + noAssert = littleEndian; + littleEndian = encoding; + encoding = undefined; + } + var capacity = 0; + for (var i=0, k=buffers.length, length; i 0) capacity += length; + } + if (capacity === 0) + return new ByteBuffer(0, littleEndian, noAssert); + var bb = new ByteBuffer(capacity, littleEndian, noAssert), + bi; + i=0; while (i} buffer Anything that can be wrapped + * @param {(string|boolean)=} encoding String encoding if `buffer` is a string ("base64", "hex", "binary", defaults to + * "utf8") + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} A ByteBuffer wrapping `buffer` + * @expose + */ + ByteBuffer.wrap = function(buffer, encoding, littleEndian, noAssert) { + if (typeof encoding !== 'string') { + noAssert = littleEndian; + littleEndian = encoding; + encoding = undefined; + } + if (typeof buffer === 'string') { + if (typeof encoding === 'undefined') + encoding = "utf8"; + switch (encoding) { + case "base64": + return ByteBuffer.fromBase64(buffer, littleEndian); + case "hex": + return ByteBuffer.fromHex(buffer, littleEndian); + case "binary": + return ByteBuffer.fromBinary(buffer, littleEndian); + case "utf8": + return ByteBuffer.fromUTF8(buffer, littleEndian); + case "debug": + return ByteBuffer.fromDebug(buffer, littleEndian); + default: + throw Error("Unsupported encoding: "+encoding); + } + } + if (buffer === null || typeof buffer !== 'object') + throw TypeError("Illegal buffer"); + var bb; + if (ByteBuffer.isByteBuffer(buffer)) { + bb = ByteBufferPrototype.clone.call(buffer); + bb.markedOffset = -1; + return bb; + } + if (buffer instanceof Uint8Array) { // Extract ArrayBuffer from Uint8Array + bb = new ByteBuffer(0, littleEndian, noAssert); + if (buffer.length > 0) { // Avoid references to more than one EMPTY_BUFFER + bb.buffer = buffer.buffer; + bb.offset = buffer.byteOffset; + bb.limit = buffer.byteOffset + buffer.byteLength; + bb.view = new Uint8Array(buffer.buffer); + } + } else if (buffer instanceof ArrayBuffer) { // Reuse ArrayBuffer + bb = new ByteBuffer(0, littleEndian, noAssert); + if (buffer.byteLength > 0) { + bb.buffer = buffer; + bb.offset = 0; + bb.limit = buffer.byteLength; + bb.view = buffer.byteLength > 0 ? new Uint8Array(buffer) : null; + } + } else if (Object.prototype.toString.call(buffer) === "[object Array]") { // Create from octets + bb = new ByteBuffer(buffer.length, littleEndian, noAssert); + bb.limit = buffer.length; + for (var i=0; i} value Array of booleans to write + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted. + * @returns {!ByteBuffer} + * @expose + */ + ByteBufferPrototype.writeBitSet = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (!(value instanceof Array)) + throw TypeError("Illegal BitSet: Not an array"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + + var start = offset, + bits = value.length, + bytes = (bits >> 3), + bit = 0, + k; + + offset += this.writeVarint32(bits,offset); + + while(bytes--) { + k = (!!value[bit++] & 1) | + ((!!value[bit++] & 1) << 1) | + ((!!value[bit++] & 1) << 2) | + ((!!value[bit++] & 1) << 3) | + ((!!value[bit++] & 1) << 4) | + ((!!value[bit++] & 1) << 5) | + ((!!value[bit++] & 1) << 6) | + ((!!value[bit++] & 1) << 7); + this.writeByte(k,offset++); + } + + if(bit < bits) { + var m = 0; k = 0; + while(bit < bits) k = k | ((!!value[bit++] & 1) << (m++)); + this.writeByte(k,offset++); + } + + if (relative) { + this.offset = offset; + return this; + } + return offset - start; + } + + /** + * Reads a BitSet as an array of booleans. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted. + * @returns {Array + * @expose + */ + ByteBufferPrototype.readBitSet = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + + var ret = this.readVarint32(offset), + bits = ret.value, + bytes = (bits >> 3), + bit = 0, + value = [], + k; + + offset += ret.length; + + while(bytes--) { + k = this.readByte(offset++); + value[bit++] = !!(k & 0x01); + value[bit++] = !!(k & 0x02); + value[bit++] = !!(k & 0x04); + value[bit++] = !!(k & 0x08); + value[bit++] = !!(k & 0x10); + value[bit++] = !!(k & 0x20); + value[bit++] = !!(k & 0x40); + value[bit++] = !!(k & 0x80); + } + + if(bit < bits) { + var m = 0; + k = this.readByte(offset++); + while(bit < bits) value[bit++] = !!((k >> (m++)) & 1); + } + + if (relative) { + this.offset = offset; + } + return value; + } + /** + * Reads the specified number of bytes. + * @param {number} length Number of bytes to read + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted. + * @returns {!ByteBuffer} + * @expose + */ + ByteBufferPrototype.readBytes = function(length, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + length > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+length+") <= "+this.buffer.byteLength); + } + var slice = this.slice(offset, offset + length); + if (relative) this.offset += length; + return slice; + }; + + /** + * Writes a payload of bytes. This is an alias of {@link ByteBuffer#append}. + * @function + * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its offsets + * will be modified according to the performed read operation. + * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8") + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeBytes = ByteBufferPrototype.append; + + // types/ints/int8 + + /** + * Writes an 8bit signed integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeInt8 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value |= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 1; + var capacity0 = this.buffer.byteLength; + if (offset > capacity0) + this.resize((capacity0 *= 2) > offset ? capacity0 : offset); + offset -= 1; + this.view[offset] = value; + if (relative) this.offset += 1; + return this; + }; + + /** + * Writes an 8bit signed integer. This is an alias of {@link ByteBuffer#writeInt8}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeByte = ByteBufferPrototype.writeInt8; + + /** + * Reads an 8bit signed integer. + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readInt8 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + var value = this.view[offset]; + if ((value & 0x80) === 0x80) value = -(0xFF - value + 1); // Cast to signed + if (relative) this.offset += 1; + return value; + }; + + /** + * Reads an 8bit signed integer. This is an alias of {@link ByteBuffer#readInt8}. + * @function + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readByte = ByteBufferPrototype.readInt8; + + /** + * Writes an 8bit unsigned integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeUint8 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value >>>= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 1; + var capacity1 = this.buffer.byteLength; + if (offset > capacity1) + this.resize((capacity1 *= 2) > offset ? capacity1 : offset); + offset -= 1; + this.view[offset] = value; + if (relative) this.offset += 1; + return this; + }; + + /** + * Writes an 8bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint8}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeUInt8 = ByteBufferPrototype.writeUint8; + + /** + * Reads an 8bit unsigned integer. + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readUint8 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + var value = this.view[offset]; + if (relative) this.offset += 1; + return value; + }; + + /** + * Reads an 8bit unsigned integer. This is an alias of {@link ByteBuffer#readUint8}. + * @function + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readUInt8 = ByteBufferPrototype.readUint8; + + // types/ints/int16 + + /** + * Writes a 16bit signed integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @throws {TypeError} If `offset` or `value` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.writeInt16 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value |= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 2; + var capacity2 = this.buffer.byteLength; + if (offset > capacity2) + this.resize((capacity2 *= 2) > offset ? capacity2 : offset); + offset -= 2; + if (this.littleEndian) { + this.view[offset+1] = (value & 0xFF00) >>> 8; + this.view[offset ] = value & 0x00FF; + } else { + this.view[offset] = (value & 0xFF00) >>> 8; + this.view[offset+1] = value & 0x00FF; + } + if (relative) this.offset += 2; + return this; + }; + + /** + * Writes a 16bit signed integer. This is an alias of {@link ByteBuffer#writeInt16}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @throws {TypeError} If `offset` or `value` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.writeShort = ByteBufferPrototype.writeInt16; + + /** + * Reads a 16bit signed integer. + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @returns {number} Value read + * @throws {TypeError} If `offset` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.readInt16 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 2 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+2+") <= "+this.buffer.byteLength); + } + var value = 0; + if (this.littleEndian) { + value = this.view[offset ]; + value |= this.view[offset+1] << 8; + } else { + value = this.view[offset ] << 8; + value |= this.view[offset+1]; + } + if ((value & 0x8000) === 0x8000) value = -(0xFFFF - value + 1); // Cast to signed + if (relative) this.offset += 2; + return value; + }; + + /** + * Reads a 16bit signed integer. This is an alias of {@link ByteBuffer#readInt16}. + * @function + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @returns {number} Value read + * @throws {TypeError} If `offset` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.readShort = ByteBufferPrototype.readInt16; + + /** + * Writes a 16bit unsigned integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @throws {TypeError} If `offset` or `value` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.writeUint16 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value >>>= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 2; + var capacity3 = this.buffer.byteLength; + if (offset > capacity3) + this.resize((capacity3 *= 2) > offset ? capacity3 : offset); + offset -= 2; + if (this.littleEndian) { + this.view[offset+1] = (value & 0xFF00) >>> 8; + this.view[offset ] = value & 0x00FF; + } else { + this.view[offset] = (value & 0xFF00) >>> 8; + this.view[offset+1] = value & 0x00FF; + } + if (relative) this.offset += 2; + return this; + }; + + /** + * Writes a 16bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint16}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @throws {TypeError} If `offset` or `value` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.writeUInt16 = ByteBufferPrototype.writeUint16; + + /** + * Reads a 16bit unsigned integer. + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @returns {number} Value read + * @throws {TypeError} If `offset` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.readUint16 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 2 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+2+") <= "+this.buffer.byteLength); + } + var value = 0; + if (this.littleEndian) { + value = this.view[offset ]; + value |= this.view[offset+1] << 8; + } else { + value = this.view[offset ] << 8; + value |= this.view[offset+1]; + } + if (relative) this.offset += 2; + return value; + }; + + /** + * Reads a 16bit unsigned integer. This is an alias of {@link ByteBuffer#readUint16}. + * @function + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted. + * @returns {number} Value read + * @throws {TypeError} If `offset` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @expose + */ + ByteBufferPrototype.readUInt16 = ByteBufferPrototype.readUint16; + + // types/ints/int32 + + /** + * Writes a 32bit signed integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @expose + */ + ByteBufferPrototype.writeInt32 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value |= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 4; + var capacity4 = this.buffer.byteLength; + if (offset > capacity4) + this.resize((capacity4 *= 2) > offset ? capacity4 : offset); + offset -= 4; + if (this.littleEndian) { + this.view[offset+3] = (value >>> 24) & 0xFF; + this.view[offset+2] = (value >>> 16) & 0xFF; + this.view[offset+1] = (value >>> 8) & 0xFF; + this.view[offset ] = value & 0xFF; + } else { + this.view[offset ] = (value >>> 24) & 0xFF; + this.view[offset+1] = (value >>> 16) & 0xFF; + this.view[offset+2] = (value >>> 8) & 0xFF; + this.view[offset+3] = value & 0xFF; + } + if (relative) this.offset += 4; + return this; + }; + + /** + * Writes a 32bit signed integer. This is an alias of {@link ByteBuffer#writeInt32}. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @expose + */ + ByteBufferPrototype.writeInt = ByteBufferPrototype.writeInt32; + + /** + * Reads a 32bit signed integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readInt32 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 4 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength); + } + var value = 0; + if (this.littleEndian) { + value = this.view[offset+2] << 16; + value |= this.view[offset+1] << 8; + value |= this.view[offset ]; + value += this.view[offset+3] << 24 >>> 0; + } else { + value = this.view[offset+1] << 16; + value |= this.view[offset+2] << 8; + value |= this.view[offset+3]; + value += this.view[offset ] << 24 >>> 0; + } + value |= 0; // Cast to signed + if (relative) this.offset += 4; + return value; + }; + + /** + * Reads a 32bit signed integer. This is an alias of {@link ByteBuffer#readInt32}. + * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readInt = ByteBufferPrototype.readInt32; + + /** + * Writes a 32bit unsigned integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @expose + */ + ByteBufferPrototype.writeUint32 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value >>>= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 4; + var capacity5 = this.buffer.byteLength; + if (offset > capacity5) + this.resize((capacity5 *= 2) > offset ? capacity5 : offset); + offset -= 4; + if (this.littleEndian) { + this.view[offset+3] = (value >>> 24) & 0xFF; + this.view[offset+2] = (value >>> 16) & 0xFF; + this.view[offset+1] = (value >>> 8) & 0xFF; + this.view[offset ] = value & 0xFF; + } else { + this.view[offset ] = (value >>> 24) & 0xFF; + this.view[offset+1] = (value >>> 16) & 0xFF; + this.view[offset+2] = (value >>> 8) & 0xFF; + this.view[offset+3] = value & 0xFF; + } + if (relative) this.offset += 4; + return this; + }; + + /** + * Writes a 32bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint32}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @expose + */ + ByteBufferPrototype.writeUInt32 = ByteBufferPrototype.writeUint32; + + /** + * Reads a 32bit unsigned integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readUint32 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 4 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength); + } + var value = 0; + if (this.littleEndian) { + value = this.view[offset+2] << 16; + value |= this.view[offset+1] << 8; + value |= this.view[offset ]; + value += this.view[offset+3] << 24 >>> 0; + } else { + value = this.view[offset+1] << 16; + value |= this.view[offset+2] << 8; + value |= this.view[offset+3]; + value += this.view[offset ] << 24 >>> 0; + } + if (relative) this.offset += 4; + return value; + }; + + /** + * Reads a 32bit unsigned integer. This is an alias of {@link ByteBuffer#readUint32}. + * @function + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} Value read + * @expose + */ + ByteBufferPrototype.readUInt32 = ByteBufferPrototype.readUint32; + + // types/ints/int64 + + if (Long) { + + /** + * Writes a 64bit signed integer. + * @param {number|!Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeInt64 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + else if (!(value && value instanceof Long)) + throw TypeError("Illegal value: "+value+" (not an integer or Long)"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + offset += 8; + var capacity6 = this.buffer.byteLength; + if (offset > capacity6) + this.resize((capacity6 *= 2) > offset ? capacity6 : offset); + offset -= 8; + var lo = value.low, + hi = value.high; + if (this.littleEndian) { + this.view[offset+3] = (lo >>> 24) & 0xFF; + this.view[offset+2] = (lo >>> 16) & 0xFF; + this.view[offset+1] = (lo >>> 8) & 0xFF; + this.view[offset ] = lo & 0xFF; + offset += 4; + this.view[offset+3] = (hi >>> 24) & 0xFF; + this.view[offset+2] = (hi >>> 16) & 0xFF; + this.view[offset+1] = (hi >>> 8) & 0xFF; + this.view[offset ] = hi & 0xFF; + } else { + this.view[offset ] = (hi >>> 24) & 0xFF; + this.view[offset+1] = (hi >>> 16) & 0xFF; + this.view[offset+2] = (hi >>> 8) & 0xFF; + this.view[offset+3] = hi & 0xFF; + offset += 4; + this.view[offset ] = (lo >>> 24) & 0xFF; + this.view[offset+1] = (lo >>> 16) & 0xFF; + this.view[offset+2] = (lo >>> 8) & 0xFF; + this.view[offset+3] = lo & 0xFF; + } + if (relative) this.offset += 8; + return this; + }; + + /** + * Writes a 64bit signed integer. This is an alias of {@link ByteBuffer#writeInt64}. + * @param {number|!Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeLong = ByteBufferPrototype.writeInt64; + + /** + * Reads a 64bit signed integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!Long} + * @expose + */ + ByteBufferPrototype.readInt64 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 8 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength); + } + var lo = 0, + hi = 0; + if (this.littleEndian) { + lo = this.view[offset+2] << 16; + lo |= this.view[offset+1] << 8; + lo |= this.view[offset ]; + lo += this.view[offset+3] << 24 >>> 0; + offset += 4; + hi = this.view[offset+2] << 16; + hi |= this.view[offset+1] << 8; + hi |= this.view[offset ]; + hi += this.view[offset+3] << 24 >>> 0; + } else { + hi = this.view[offset+1] << 16; + hi |= this.view[offset+2] << 8; + hi |= this.view[offset+3]; + hi += this.view[offset ] << 24 >>> 0; + offset += 4; + lo = this.view[offset+1] << 16; + lo |= this.view[offset+2] << 8; + lo |= this.view[offset+3]; + lo += this.view[offset ] << 24 >>> 0; + } + var value = new Long(lo, hi, false); + if (relative) this.offset += 8; + return value; + }; + + /** + * Reads a 64bit signed integer. This is an alias of {@link ByteBuffer#readInt64}. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!Long} + * @expose + */ + ByteBufferPrototype.readLong = ByteBufferPrototype.readInt64; + + /** + * Writes a 64bit unsigned integer. + * @param {number|!Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeUint64 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + else if (!(value && value instanceof Long)) + throw TypeError("Illegal value: "+value+" (not an integer or Long)"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + offset += 8; + var capacity7 = this.buffer.byteLength; + if (offset > capacity7) + this.resize((capacity7 *= 2) > offset ? capacity7 : offset); + offset -= 8; + var lo = value.low, + hi = value.high; + if (this.littleEndian) { + this.view[offset+3] = (lo >>> 24) & 0xFF; + this.view[offset+2] = (lo >>> 16) & 0xFF; + this.view[offset+1] = (lo >>> 8) & 0xFF; + this.view[offset ] = lo & 0xFF; + offset += 4; + this.view[offset+3] = (hi >>> 24) & 0xFF; + this.view[offset+2] = (hi >>> 16) & 0xFF; + this.view[offset+1] = (hi >>> 8) & 0xFF; + this.view[offset ] = hi & 0xFF; + } else { + this.view[offset ] = (hi >>> 24) & 0xFF; + this.view[offset+1] = (hi >>> 16) & 0xFF; + this.view[offset+2] = (hi >>> 8) & 0xFF; + this.view[offset+3] = hi & 0xFF; + offset += 4; + this.view[offset ] = (lo >>> 24) & 0xFF; + this.view[offset+1] = (lo >>> 16) & 0xFF; + this.view[offset+2] = (lo >>> 8) & 0xFF; + this.view[offset+3] = lo & 0xFF; + } + if (relative) this.offset += 8; + return this; + }; + + /** + * Writes a 64bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint64}. + * @function + * @param {number|!Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeUInt64 = ByteBufferPrototype.writeUint64; + + /** + * Reads a 64bit unsigned integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!Long} + * @expose + */ + ByteBufferPrototype.readUint64 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 8 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength); + } + var lo = 0, + hi = 0; + if (this.littleEndian) { + lo = this.view[offset+2] << 16; + lo |= this.view[offset+1] << 8; + lo |= this.view[offset ]; + lo += this.view[offset+3] << 24 >>> 0; + offset += 4; + hi = this.view[offset+2] << 16; + hi |= this.view[offset+1] << 8; + hi |= this.view[offset ]; + hi += this.view[offset+3] << 24 >>> 0; + } else { + hi = this.view[offset+1] << 16; + hi |= this.view[offset+2] << 8; + hi |= this.view[offset+3]; + hi += this.view[offset ] << 24 >>> 0; + offset += 4; + lo = this.view[offset+1] << 16; + lo |= this.view[offset+2] << 8; + lo |= this.view[offset+3]; + lo += this.view[offset ] << 24 >>> 0; + } + var value = new Long(lo, hi, true); + if (relative) this.offset += 8; + return value; + }; + + /** + * Reads a 64bit unsigned integer. This is an alias of {@link ByteBuffer#readUint64}. + * @function + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!Long} + * @expose + */ + ByteBufferPrototype.readUInt64 = ByteBufferPrototype.readUint64; + + } // Long + + + // types/floats/float32 + + /* + ieee754 - https://github.com/feross/ieee754 + + The MIT License (MIT) + + Copyright (c) Feross Aboukhadijeh + + 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 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. + */ + + /** + * Reads an IEEE754 float from a byte array. + * @param {!Array} buffer + * @param {number} offset + * @param {boolean} isLE + * @param {number} mLen + * @param {number} nBytes + * @returns {number} + * @inner + */ + function ieee754_read(buffer, offset, isLE, mLen, nBytes) { + var e, m, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + nBits = -7, + i = isLE ? (nBytes - 1) : 0, + d = isLE ? -1 : 1, + s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity); + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); + } + + /** + * Writes an IEEE754 float to a byte array. + * @param {!Array} buffer + * @param {number} value + * @param {number} offset + * @param {boolean} isLE + * @param {number} mLen + * @param {number} nBytes + * @inner + */ + function ieee754_write(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), + i = isLE ? 0 : (nBytes - 1), + d = isLE ? 1 : -1, + s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; + } + + /** + * Writes a 32bit float. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeFloat32 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number') + throw TypeError("Illegal value: "+value+" (not a number)"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 4; + var capacity8 = this.buffer.byteLength; + if (offset > capacity8) + this.resize((capacity8 *= 2) > offset ? capacity8 : offset); + offset -= 4; + ieee754_write(this.view, value, offset, this.littleEndian, 23, 4); + if (relative) this.offset += 4; + return this; + }; + + /** + * Writes a 32bit float. This is an alias of {@link ByteBuffer#writeFloat32}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeFloat = ByteBufferPrototype.writeFloat32; + + /** + * Reads a 32bit float. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} + * @expose + */ + ByteBufferPrototype.readFloat32 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 4 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength); + } + var value = ieee754_read(this.view, offset, this.littleEndian, 23, 4); + if (relative) this.offset += 4; + return value; + }; + + /** + * Reads a 32bit float. This is an alias of {@link ByteBuffer#readFloat32}. + * @function + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted. + * @returns {number} + * @expose + */ + ByteBufferPrototype.readFloat = ByteBufferPrototype.readFloat32; + + // types/floats/float64 + + /** + * Writes a 64bit float. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeFloat64 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number') + throw TypeError("Illegal value: "+value+" (not a number)"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + offset += 8; + var capacity9 = this.buffer.byteLength; + if (offset > capacity9) + this.resize((capacity9 *= 2) > offset ? capacity9 : offset); + offset -= 8; + ieee754_write(this.view, value, offset, this.littleEndian, 52, 8); + if (relative) this.offset += 8; + return this; + }; + + /** + * Writes a 64bit float. This is an alias of {@link ByteBuffer#writeFloat64}. + * @function + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.writeDouble = ByteBufferPrototype.writeFloat64; + + /** + * Reads a 64bit float. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {number} + * @expose + */ + ByteBufferPrototype.readFloat64 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 8 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength); + } + var value = ieee754_read(this.view, offset, this.littleEndian, 52, 8); + if (relative) this.offset += 8; + return value; + }; + + /** + * Reads a 64bit float. This is an alias of {@link ByteBuffer#readFloat64}. + * @function + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted. + * @returns {number} + * @expose + */ + ByteBufferPrototype.readDouble = ByteBufferPrototype.readFloat64; + + + // types/varints/varint32 + + /** + * Maximum number of bytes required to store a 32bit base 128 variable-length integer. + * @type {number} + * @const + * @expose + */ + ByteBuffer.MAX_VARINT32_BYTES = 5; + + /** + * Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer. + * @param {number} value Value to encode + * @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT32_BYTES} + * @expose + */ + ByteBuffer.calculateVarint32 = function(value) { + // ref: src/google/protobuf/io/coded_stream.cc + value = value >>> 0; + if (value < 1 << 7 ) return 1; + else if (value < 1 << 14) return 2; + else if (value < 1 << 21) return 3; + else if (value < 1 << 28) return 4; + else return 5; + }; + + /** + * Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding. + * @param {number} n Signed 32bit integer + * @returns {number} Unsigned zigzag encoded 32bit integer + * @expose + */ + ByteBuffer.zigZagEncode32 = function(n) { + return (((n |= 0) << 1) ^ (n >> 31)) >>> 0; // ref: src/google/protobuf/wire_format_lite.h + }; + + /** + * Decodes a zigzag encoded signed 32bit integer. + * @param {number} n Unsigned zigzag encoded 32bit integer + * @returns {number} Signed 32bit integer + * @expose + */ + ByteBuffer.zigZagDecode32 = function(n) { + return ((n >>> 1) ^ -(n & 1)) | 0; // // ref: src/google/protobuf/wire_format_lite.h + }; + + /** + * Writes a 32bit base 128 variable-length integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written + * @expose + */ + ByteBufferPrototype.writeVarint32 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value |= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + var size = ByteBuffer.calculateVarint32(value), + b; + offset += size; + var capacity10 = this.buffer.byteLength; + if (offset > capacity10) + this.resize((capacity10 *= 2) > offset ? capacity10 : offset); + offset -= size; + value >>>= 0; + while (value >= 0x80) { + b = (value & 0x7f) | 0x80; + this.view[offset++] = b; + value >>>= 7; + } + this.view[offset++] = value; + if (relative) { + this.offset = offset; + return this; + } + return size; + }; + + /** + * Writes a zig-zag encoded (signed) 32bit base 128 variable-length integer. + * @param {number} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written + * @expose + */ + ByteBufferPrototype.writeVarint32ZigZag = function(value, offset) { + return this.writeVarint32(ByteBuffer.zigZagEncode32(value), offset); + }; + + /** + * Reads a 32bit base 128 variable-length integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read + * and the actual number of bytes read. + * @throws {Error} If it's not a valid varint. Has a property `truncated = true` if there is not enough data available + * to fully decode the varint. + * @expose + */ + ByteBufferPrototype.readVarint32 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + var c = 0, + value = 0 >>> 0, + b; + do { + if (!this.noAssert && offset > this.limit) { + var err = Error("Truncated"); + err['truncated'] = true; + throw err; + } + b = this.view[offset++]; + if (c < 5) + value |= (b & 0x7f) << (7*c); + ++c; + } while ((b & 0x80) !== 0); + value |= 0; + if (relative) { + this.offset = offset; + return value; + } + return { + "value": value, + "length": c + }; + }; + + /** + * Reads a zig-zag encoded (signed) 32bit base 128 variable-length integer. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read + * and the actual number of bytes read. + * @throws {Error} If it's not a valid varint + * @expose + */ + ByteBufferPrototype.readVarint32ZigZag = function(offset) { + var val = this.readVarint32(offset); + if (typeof val === 'object') + val["value"] = ByteBuffer.zigZagDecode32(val["value"]); + else + val = ByteBuffer.zigZagDecode32(val); + return val; + }; + + // types/varints/varint64 + + if (Long) { + + /** + * Maximum number of bytes required to store a 64bit base 128 variable-length integer. + * @type {number} + * @const + * @expose + */ + ByteBuffer.MAX_VARINT64_BYTES = 10; + + /** + * Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer. + * @param {number|!Long} value Value to encode + * @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT64_BYTES} + * @expose + */ + ByteBuffer.calculateVarint64 = function(value) { + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + // ref: src/google/protobuf/io/coded_stream.cc + var part0 = value.toInt() >>> 0, + part1 = value.shiftRightUnsigned(28).toInt() >>> 0, + part2 = value.shiftRightUnsigned(56).toInt() >>> 0; + if (part2 == 0) { + if (part1 == 0) { + if (part0 < 1 << 14) + return part0 < 1 << 7 ? 1 : 2; + else + return part0 < 1 << 21 ? 3 : 4; + } else { + if (part1 < 1 << 14) + return part1 < 1 << 7 ? 5 : 6; + else + return part1 < 1 << 21 ? 7 : 8; + } + } else + return part2 < 1 << 7 ? 9 : 10; + }; + + /** + * Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding. + * @param {number|!Long} value Signed long + * @returns {!Long} Unsigned zigzag encoded long + * @expose + */ + ByteBuffer.zigZagEncode64 = function(value) { + if (typeof value === 'number') + value = Long.fromNumber(value, false); + else if (typeof value === 'string') + value = Long.fromString(value, false); + else if (value.unsigned !== false) value = value.toSigned(); + // ref: src/google/protobuf/wire_format_lite.h + return value.shiftLeft(1).xor(value.shiftRight(63)).toUnsigned(); + }; + + /** + * Decodes a zigzag encoded signed 64bit integer. + * @param {!Long|number} value Unsigned zigzag encoded long or JavaScript number + * @returns {!Long} Signed long + * @expose + */ + ByteBuffer.zigZagDecode64 = function(value) { + if (typeof value === 'number') + value = Long.fromNumber(value, false); + else if (typeof value === 'string') + value = Long.fromString(value, false); + else if (value.unsigned !== false) value = value.toSigned(); + // ref: src/google/protobuf/wire_format_lite.h + return value.shiftRightUnsigned(1).xor(value.and(Long.ONE).toSigned().negate()).toSigned(); + }; + + /** + * Writes a 64bit base 128 variable-length integer. + * @param {number|Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written. + * @expose + */ + ByteBufferPrototype.writeVarint64 = function(value, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof value === 'number') + value = Long.fromNumber(value); + else if (typeof value === 'string') + value = Long.fromString(value); + else if (!(value && value instanceof Long)) + throw TypeError("Illegal value: "+value+" (not an integer or Long)"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + if (typeof value === 'number') + value = Long.fromNumber(value, false); + else if (typeof value === 'string') + value = Long.fromString(value, false); + else if (value.unsigned !== false) value = value.toSigned(); + var size = ByteBuffer.calculateVarint64(value), + part0 = value.toInt() >>> 0, + part1 = value.shiftRightUnsigned(28).toInt() >>> 0, + part2 = value.shiftRightUnsigned(56).toInt() >>> 0; + offset += size; + var capacity11 = this.buffer.byteLength; + if (offset > capacity11) + this.resize((capacity11 *= 2) > offset ? capacity11 : offset); + offset -= size; + switch (size) { + case 10: this.view[offset+9] = (part2 >>> 7) & 0x01; + case 9 : this.view[offset+8] = size !== 9 ? (part2 ) | 0x80 : (part2 ) & 0x7F; + case 8 : this.view[offset+7] = size !== 8 ? (part1 >>> 21) | 0x80 : (part1 >>> 21) & 0x7F; + case 7 : this.view[offset+6] = size !== 7 ? (part1 >>> 14) | 0x80 : (part1 >>> 14) & 0x7F; + case 6 : this.view[offset+5] = size !== 6 ? (part1 >>> 7) | 0x80 : (part1 >>> 7) & 0x7F; + case 5 : this.view[offset+4] = size !== 5 ? (part1 ) | 0x80 : (part1 ) & 0x7F; + case 4 : this.view[offset+3] = size !== 4 ? (part0 >>> 21) | 0x80 : (part0 >>> 21) & 0x7F; + case 3 : this.view[offset+2] = size !== 3 ? (part0 >>> 14) | 0x80 : (part0 >>> 14) & 0x7F; + case 2 : this.view[offset+1] = size !== 2 ? (part0 >>> 7) | 0x80 : (part0 >>> 7) & 0x7F; + case 1 : this.view[offset ] = size !== 1 ? (part0 ) | 0x80 : (part0 ) & 0x7F; + } + if (relative) { + this.offset += size; + return this; + } else { + return size; + } + }; + + /** + * Writes a zig-zag encoded 64bit base 128 variable-length integer. + * @param {number|Long} value Value to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written. + * @expose + */ + ByteBufferPrototype.writeVarint64ZigZag = function(value, offset) { + return this.writeVarint64(ByteBuffer.zigZagEncode64(value), offset); + }; + + /** + * Reads a 64bit base 128 variable-length integer. Requires Long.js. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and + * the actual number of bytes read. + * @throws {Error} If it's not a valid varint + * @expose + */ + ByteBufferPrototype.readVarint64 = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + // ref: src/google/protobuf/io/coded_stream.cc + var start = offset, + part0 = 0, + part1 = 0, + part2 = 0, + b = 0; + b = this.view[offset++]; part0 = (b & 0x7F) ; if ( b & 0x80 ) { + b = this.view[offset++]; part0 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part0 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part0 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part1 = (b & 0x7F) ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part1 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part1 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part1 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part2 = (b & 0x7F) ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + b = this.view[offset++]; part2 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) { + throw Error("Buffer overrun"); }}}}}}}}}} + var value = Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, false); + if (relative) { + this.offset = offset; + return value; + } else { + return { + 'value': value, + 'length': offset-start + }; + } + }; + + /** + * Reads a zig-zag encoded 64bit base 128 variable-length integer. Requires Long.js. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and + * the actual number of bytes read. + * @throws {Error} If it's not a valid varint + * @expose + */ + ByteBufferPrototype.readVarint64ZigZag = function(offset) { + var val = this.readVarint64(offset); + if (val && val['value'] instanceof Long) + val["value"] = ByteBuffer.zigZagDecode64(val["value"]); + else + val = ByteBuffer.zigZagDecode64(val); + return val; + }; + + } // Long + + + // types/strings/cstring + + /** + * Writes a NULL-terminated UTF8 encoded string. For this to work the specified string must not contain any NULL + * characters itself. + * @param {string} str String to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * contained in `str` + 1 if omitted. + * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written + * @expose + */ + ByteBufferPrototype.writeCString = function(str, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + var i, + k = str.length; + if (!this.noAssert) { + if (typeof str !== 'string') + throw TypeError("Illegal str: Not a string"); + for (i=0; i>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + // UTF8 strings do not contain zero bytes in between except for the zero character, so: + k = utfx.calculateUTF16asUTF8(stringSource(str))[1]; + offset += k+1; + var capacity12 = this.buffer.byteLength; + if (offset > capacity12) + this.resize((capacity12 *= 2) > offset ? capacity12 : offset); + offset -= k+1; + utfx.encodeUTF16toUTF8(stringSource(str), function(b) { + this.view[offset++] = b; + }.bind(this)); + this.view[offset++] = 0; + if (relative) { + this.offset = offset; + return this; + } + return k; + }; + + /** + * Reads a NULL-terminated UTF8 encoded string. For this to work the string read must not contain any NULL characters + * itself. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string + * read and the actual number of bytes read. + * @expose + */ + ByteBufferPrototype.readCString = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + var start = offset, + temp; + // UTF8 strings do not contain zero bytes in between except for the zero character itself, so: + var sd, b = -1; + utfx.decodeUTF8toUTF16(function() { + if (b === 0) return null; + if (offset >= this.limit) + throw RangeError("Illegal range: Truncated data, "+offset+" < "+this.limit); + b = this.view[offset++]; + return b === 0 ? null : b; + }.bind(this), sd = stringDestination(), true); + if (relative) { + this.offset = offset; + return sd(); + } else { + return { + "string": sd(), + "length": offset - start + }; + } + }; + + // types/strings/istring + + /** + * Writes a length as uint32 prefixed UTF8 encoded string. + * @param {string} str String to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written + * @expose + * @see ByteBuffer#writeVarint32 + */ + ByteBufferPrototype.writeIString = function(str, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof str !== 'string') + throw TypeError("Illegal str: Not a string"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + var start = offset, + k; + k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1]; + offset += 4+k; + var capacity13 = this.buffer.byteLength; + if (offset > capacity13) + this.resize((capacity13 *= 2) > offset ? capacity13 : offset); + offset -= 4+k; + if (this.littleEndian) { + this.view[offset+3] = (k >>> 24) & 0xFF; + this.view[offset+2] = (k >>> 16) & 0xFF; + this.view[offset+1] = (k >>> 8) & 0xFF; + this.view[offset ] = k & 0xFF; + } else { + this.view[offset ] = (k >>> 24) & 0xFF; + this.view[offset+1] = (k >>> 16) & 0xFF; + this.view[offset+2] = (k >>> 8) & 0xFF; + this.view[offset+3] = k & 0xFF; + } + offset += 4; + utfx.encodeUTF16toUTF8(stringSource(str), function(b) { + this.view[offset++] = b; + }.bind(this)); + if (offset !== start + 4 + k) + throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+4+k)); + if (relative) { + this.offset = offset; + return this; + } + return offset - start; + }; + + /** + * Reads a length as uint32 prefixed UTF8 encoded string. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string + * read and the actual number of bytes read. + * @expose + * @see ByteBuffer#readVarint32 + */ + ByteBufferPrototype.readIString = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 4 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength); + } + var start = offset; + var len = this.readUint32(offset); + var str = this.readUTF8String(len, ByteBuffer.METRICS_BYTES, offset += 4); + offset += str['length']; + if (relative) { + this.offset = offset; + return str['string']; + } else { + return { + 'string': str['string'], + 'length': offset - start + }; + } + }; + + // types/strings/utf8string + + /** + * Metrics representing number of UTF8 characters. Evaluates to `c`. + * @type {string} + * @const + * @expose + */ + ByteBuffer.METRICS_CHARS = 'c'; + + /** + * Metrics representing number of bytes. Evaluates to `b`. + * @type {string} + * @const + * @expose + */ + ByteBuffer.METRICS_BYTES = 'b'; + + /** + * Writes an UTF8 encoded string. + * @param {string} str String to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted. + * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written. + * @expose + */ + ByteBufferPrototype.writeUTF8String = function(str, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + var k; + var start = offset; + k = utfx.calculateUTF16asUTF8(stringSource(str))[1]; + offset += k; + var capacity14 = this.buffer.byteLength; + if (offset > capacity14) + this.resize((capacity14 *= 2) > offset ? capacity14 : offset); + offset -= k; + utfx.encodeUTF16toUTF8(stringSource(str), function(b) { + this.view[offset++] = b; + }.bind(this)); + if (relative) { + this.offset = offset; + return this; + } + return offset - start; + }; + + /** + * Writes an UTF8 encoded string. This is an alias of {@link ByteBuffer#writeUTF8String}. + * @function + * @param {string} str String to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted. + * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written. + * @expose + */ + ByteBufferPrototype.writeString = ByteBufferPrototype.writeUTF8String; + + /** + * Calculates the number of UTF8 characters of a string. JavaScript itself uses UTF-16, so that a string's + * `length` property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF. + * @param {string} str String to calculate + * @returns {number} Number of UTF8 characters + * @expose + */ + ByteBuffer.calculateUTF8Chars = function(str) { + return utfx.calculateUTF16asUTF8(stringSource(str))[0]; + }; + + /** + * Calculates the number of UTF8 bytes of a string. + * @param {string} str String to calculate + * @returns {number} Number of UTF8 bytes + * @expose + */ + ByteBuffer.calculateUTF8Bytes = function(str) { + return utfx.calculateUTF16asUTF8(stringSource(str))[1]; + }; + + /** + * Calculates the number of UTF8 bytes of a string. This is an alias of {@link ByteBuffer.calculateUTF8Bytes}. + * @function + * @param {string} str String to calculate + * @returns {number} Number of UTF8 bytes + * @expose + */ + ByteBuffer.calculateString = ByteBuffer.calculateUTF8Bytes; + + /** + * Reads an UTF8 encoded string. + * @param {number} length Number of characters or bytes to read. + * @param {string=} metrics Metrics specifying what `length` is meant to count. Defaults to + * {@link ByteBuffer.METRICS_CHARS}. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string + * read and the actual number of bytes read. + * @expose + */ + ByteBufferPrototype.readUTF8String = function(length, metrics, offset) { + if (typeof metrics === 'number') { + offset = metrics; + metrics = undefined; + } + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (typeof metrics === 'undefined') metrics = ByteBuffer.METRICS_CHARS; + if (!this.noAssert) { + if (typeof length !== 'number' || length % 1 !== 0) + throw TypeError("Illegal length: "+length+" (not an integer)"); + length |= 0; + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + var i = 0, + start = offset, + sd; + if (metrics === ByteBuffer.METRICS_CHARS) { // The same for node and the browser + sd = stringDestination(); + utfx.decodeUTF8(function() { + return i < length && offset < this.limit ? this.view[offset++] : null; + }.bind(this), function(cp) { + ++i; utfx.UTF8toUTF16(cp, sd); + }); + if (i !== length) + throw RangeError("Illegal range: Truncated data, "+i+" == "+length); + if (relative) { + this.offset = offset; + return sd(); + } else { + return { + "string": sd(), + "length": offset - start + }; + } + } else if (metrics === ByteBuffer.METRICS_BYTES) { + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + length > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+length+") <= "+this.buffer.byteLength); + } + var k = offset + length; + utfx.decodeUTF8toUTF16(function() { + return offset < k ? this.view[offset++] : null; + }.bind(this), sd = stringDestination(), this.noAssert); + if (offset !== k) + throw RangeError("Illegal range: Truncated data, "+offset+" == "+k); + if (relative) { + this.offset = offset; + return sd(); + } else { + return { + 'string': sd(), + 'length': offset - start + }; + } + } else + throw TypeError("Unsupported metrics: "+metrics); + }; + + /** + * Reads an UTF8 encoded string. This is an alias of {@link ByteBuffer#readUTF8String}. + * @function + * @param {number} length Number of characters or bytes to read + * @param {number=} metrics Metrics specifying what `n` is meant to count. Defaults to + * {@link ByteBuffer.METRICS_CHARS}. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string + * read and the actual number of bytes read. + * @expose + */ + ByteBufferPrototype.readString = ByteBufferPrototype.readUTF8String; + + // types/strings/vstring + + /** + * Writes a length as varint32 prefixed UTF8 encoded string. + * @param {string} str String to write + * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written + * @expose + * @see ByteBuffer#writeVarint32 + */ + ByteBufferPrototype.writeVString = function(str, offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof str !== 'string') + throw TypeError("Illegal str: Not a string"); + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + var start = offset, + k, l; + k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1]; + l = ByteBuffer.calculateVarint32(k); + offset += l+k; + var capacity15 = this.buffer.byteLength; + if (offset > capacity15) + this.resize((capacity15 *= 2) > offset ? capacity15 : offset); + offset -= l+k; + offset += this.writeVarint32(k, offset); + utfx.encodeUTF16toUTF8(stringSource(str), function(b) { + this.view[offset++] = b; + }.bind(this)); + if (offset !== start+k+l) + throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+k+l)); + if (relative) { + this.offset = offset; + return this; + } + return offset - start; + }; + + /** + * Reads a length as varint32 prefixed UTF8 encoded string. + * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string + * read and the actual number of bytes read. + * @expose + * @see ByteBuffer#readVarint32 + */ + ByteBufferPrototype.readVString = function(offset) { + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 1 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength); + } + var start = offset; + var len = this.readVarint32(offset); + var str = this.readUTF8String(len['value'], ByteBuffer.METRICS_BYTES, offset += len['length']); + offset += str['length']; + if (relative) { + this.offset = offset; + return str['string']; + } else { + return { + 'string': str['string'], + 'length': offset - start + }; + } + }; + + + /** + * Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended + * data's length. + * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to append. If `source` is a ByteBuffer, its offsets + * will be modified according to the performed read operation. + * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8") + * @param {number=} offset Offset to append at. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. + * @returns {!ByteBuffer} this + * @expose + * @example A relative `<01 02>03.append(<04 05>)` will result in `<01 02 04 05>, 04 05|` + * @example An absolute `<01 02>03.append(04 05>, 1)` will result in `<01 04>05, 04 05|` + */ + ByteBufferPrototype.append = function(source, encoding, offset) { + if (typeof encoding === 'number' || typeof encoding !== 'string') { + offset = encoding; + encoding = undefined; + } + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + if (!(source instanceof ByteBuffer)) + source = ByteBuffer.wrap(source, encoding); + var length = source.limit - source.offset; + if (length <= 0) return this; // Nothing to append + offset += length; + var capacity16 = this.buffer.byteLength; + if (offset > capacity16) + this.resize((capacity16 *= 2) > offset ? capacity16 : offset); + offset -= length; + this.view.set(source.view.subarray(source.offset, source.limit), offset); + source.offset += length; + if (relative) this.offset += length; + return this; + }; + + /** + * Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents at and after the + specified offset up to the length of this ByteBuffer's data. + * @param {!ByteBuffer} target Target ByteBuffer + * @param {number=} offset Offset to append to. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * read if omitted. + * @returns {!ByteBuffer} this + * @expose + * @see ByteBuffer#append + */ + ByteBufferPrototype.appendTo = function(target, offset) { + target.append(this, offset); + return this; + }; + + /** + * Enables or disables assertions of argument types and offsets. Assertions are enabled by default but you can opt to + * disable them if your code already makes sure that everything is valid. + * @param {boolean} assert `true` to enable assertions, otherwise `false` + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.assert = function(assert) { + this.noAssert = !assert; + return this; + }; + + /** + * Gets the capacity of this ByteBuffer's backing buffer. + * @returns {number} Capacity of the backing buffer + * @expose + */ + ByteBufferPrototype.capacity = function() { + return this.buffer.byteLength; + }; + /** + * Clears this ByteBuffer's offsets by setting {@link ByteBuffer#offset} to `0` and {@link ByteBuffer#limit} to the + * backing buffer's capacity. Discards {@link ByteBuffer#markedOffset}. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.clear = function() { + this.offset = 0; + this.limit = this.buffer.byteLength; + this.markedOffset = -1; + return this; + }; + + /** + * Creates a cloned instance of this ByteBuffer, preset with this ByteBuffer's values for {@link ByteBuffer#offset}, + * {@link ByteBuffer#markedOffset} and {@link ByteBuffer#limit}. + * @param {boolean=} copy Whether to copy the backing buffer or to return another view on the same, defaults to `false` + * @returns {!ByteBuffer} Cloned instance + * @expose + */ + ByteBufferPrototype.clone = function(copy) { + var bb = new ByteBuffer(0, this.littleEndian, this.noAssert); + if (copy) { + bb.buffer = new ArrayBuffer(this.buffer.byteLength); + bb.view = new Uint8Array(bb.buffer); + } else { + bb.buffer = this.buffer; + bb.view = this.view; + } + bb.offset = this.offset; + bb.markedOffset = this.markedOffset; + bb.limit = this.limit; + return bb; + }; + + /** + * Compacts this ByteBuffer to be backed by a {@link ByteBuffer#buffer} of its contents' length. Contents are the bytes + * between {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. Will set `offset = 0` and `limit = capacity` and + * adapt {@link ByteBuffer#markedOffset} to the same relative position if set. + * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset} + * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit} + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.compact = function(begin, end) { + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + if (begin === 0 && end === this.buffer.byteLength) + return this; // Already compacted + var len = end - begin; + if (len === 0) { + this.buffer = EMPTY_BUFFER; + this.view = null; + if (this.markedOffset >= 0) this.markedOffset -= begin; + this.offset = 0; + this.limit = 0; + return this; + } + var buffer = new ArrayBuffer(len); + var view = new Uint8Array(buffer); + view.set(this.view.subarray(begin, end)); + this.buffer = buffer; + this.view = view; + if (this.markedOffset >= 0) this.markedOffset -= begin; + this.offset = 0; + this.limit = len; + return this; + }; + + /** + * Creates a copy of this ByteBuffer's contents. Contents are the bytes between {@link ByteBuffer#offset} and + * {@link ByteBuffer#limit}. + * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}. + * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}. + * @returns {!ByteBuffer} Copy + * @expose + */ + ByteBufferPrototype.copy = function(begin, end) { + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + if (begin === end) + return new ByteBuffer(0, this.littleEndian, this.noAssert); + var capacity = end - begin, + bb = new ByteBuffer(capacity, this.littleEndian, this.noAssert); + bb.offset = 0; + bb.limit = capacity; + if (bb.markedOffset >= 0) bb.markedOffset -= begin; + this.copyTo(bb, 0, begin, end); + return bb; + }; + + /** + * Copies this ByteBuffer's contents to another ByteBuffer. Contents are the bytes between {@link ByteBuffer#offset} and + * {@link ByteBuffer#limit}. + * @param {!ByteBuffer} target Target ByteBuffer + * @param {number=} targetOffset Offset to copy to. Will use and increase the target's {@link ByteBuffer#offset} + * by the number of bytes copied if omitted. + * @param {number=} sourceOffset Offset to start copying from. Will use and increase {@link ByteBuffer#offset} by the + * number of bytes copied if omitted. + * @param {number=} sourceLimit Offset to end copying from, defaults to {@link ByteBuffer#limit} + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.copyTo = function(target, targetOffset, sourceOffset, sourceLimit) { + var relative, + targetRelative; + if (!this.noAssert) { + if (!ByteBuffer.isByteBuffer(target)) + throw TypeError("Illegal target: Not a ByteBuffer"); + } + targetOffset = (targetRelative = typeof targetOffset === 'undefined') ? target.offset : targetOffset | 0; + sourceOffset = (relative = typeof sourceOffset === 'undefined') ? this.offset : sourceOffset | 0; + sourceLimit = typeof sourceLimit === 'undefined' ? this.limit : sourceLimit | 0; + + if (targetOffset < 0 || targetOffset > target.buffer.byteLength) + throw RangeError("Illegal target range: 0 <= "+targetOffset+" <= "+target.buffer.byteLength); + if (sourceOffset < 0 || sourceLimit > this.buffer.byteLength) + throw RangeError("Illegal source range: 0 <= "+sourceOffset+" <= "+this.buffer.byteLength); + + var len = sourceLimit - sourceOffset; + if (len === 0) + return target; // Nothing to copy + + target.ensureCapacity(targetOffset + len); + + target.view.set(this.view.subarray(sourceOffset, sourceLimit), targetOffset); + + if (relative) this.offset += len; + if (targetRelative) target.offset += len; + + return this; + }; + + /** + * Makes sure that this ByteBuffer is backed by a {@link ByteBuffer#buffer} of at least the specified capacity. If the + * current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity, + * the required capacity will be used instead. + * @param {number} capacity Required capacity + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.ensureCapacity = function(capacity) { + var current = this.buffer.byteLength; + if (current < capacity) + return this.resize((current *= 2) > capacity ? current : capacity); + return this; + }; + + /** + * Overwrites this ByteBuffer's contents with the specified value. Contents are the bytes between + * {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. + * @param {number|string} value Byte value to fill with. If given as a string, the first character is used. + * @param {number=} begin Begin offset. Will use and increase {@link ByteBuffer#offset} by the number of bytes + * written if omitted. defaults to {@link ByteBuffer#offset}. + * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}. + * @returns {!ByteBuffer} this + * @expose + * @example `someByteBuffer.clear().fill(0)` fills the entire backing buffer with zeroes + */ + ByteBufferPrototype.fill = function(value, begin, end) { + var relative = typeof begin === 'undefined'; + if (relative) begin = this.offset; + if (typeof value === 'string' && value.length > 0) + value = value.charCodeAt(0); + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof value !== 'number' || value % 1 !== 0) + throw TypeError("Illegal value: "+value+" (not an integer)"); + value |= 0; + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + if (begin >= end) + return this; // Nothing to fill + while (begin < end) this.view[begin++] = value; + if (relative) this.offset = begin; + return this; + }; + + /** + * Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets `limit = offset` and + * `offset = 0`. Make sure always to flip a ByteBuffer when all relative read or write operations are complete. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.flip = function() { + this.limit = this.offset; + this.offset = 0; + return this; + }; + /** + * Marks an offset on this ByteBuffer to be used later. + * @param {number=} offset Offset to mark. Defaults to {@link ByteBuffer#offset}. + * @returns {!ByteBuffer} this + * @throws {TypeError} If `offset` is not a valid number + * @throws {RangeError} If `offset` is out of bounds + * @see ByteBuffer#reset + * @expose + */ + ByteBufferPrototype.mark = function(offset) { + offset = typeof offset === 'undefined' ? this.offset : offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + this.markedOffset = offset; + return this; + }; + /** + * Sets the byte order. + * @param {boolean} littleEndian `true` for little endian byte order, `false` for big endian + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.order = function(littleEndian) { + if (!this.noAssert) { + if (typeof littleEndian !== 'boolean') + throw TypeError("Illegal littleEndian: Not a boolean"); + } + this.littleEndian = !!littleEndian; + return this; + }; + + /** + * Switches (to) little endian byte order. + * @param {boolean=} littleEndian Defaults to `true`, otherwise uses big endian + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.LE = function(littleEndian) { + this.littleEndian = typeof littleEndian !== 'undefined' ? !!littleEndian : true; + return this; + }; + + /** + * Switches (to) big endian byte order. + * @param {boolean=} bigEndian Defaults to `true`, otherwise uses little endian + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.BE = function(bigEndian) { + this.littleEndian = typeof bigEndian !== 'undefined' ? !bigEndian : false; + return this; + }; + /** + * Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the + * prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer + * will be resized and its contents moved accordingly. + * @param {!ByteBuffer|string|!ArrayBuffer} source Data to prepend. If `source` is a ByteBuffer, its offset will be + * modified according to the performed read operation. + * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8") + * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes + * prepended if omitted. + * @returns {!ByteBuffer} this + * @expose + * @example A relative `00<01 02 03>.prepend(<04 05>)` results in `<04 05 01 02 03>, 04 05|` + * @example An absolute `00<01 02 03>.prepend(<04 05>, 2)` results in `04<05 02 03>, 04 05|` + */ + ByteBufferPrototype.prepend = function(source, encoding, offset) { + if (typeof encoding === 'number' || typeof encoding !== 'string') { + offset = encoding; + encoding = undefined; + } + var relative = typeof offset === 'undefined'; + if (relative) offset = this.offset; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: "+offset+" (not an integer)"); + offset >>>= 0; + if (offset < 0 || offset + 0 > this.buffer.byteLength) + throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength); + } + if (!(source instanceof ByteBuffer)) + source = ByteBuffer.wrap(source, encoding); + var len = source.limit - source.offset; + if (len <= 0) return this; // Nothing to prepend + var diff = len - offset; + if (diff > 0) { // Not enough space before offset, so resize + move + var buffer = new ArrayBuffer(this.buffer.byteLength + diff); + var view = new Uint8Array(buffer); + view.set(this.view.subarray(offset, this.buffer.byteLength), len); + this.buffer = buffer; + this.view = view; + this.offset += diff; + if (this.markedOffset >= 0) this.markedOffset += diff; + this.limit += diff; + offset += diff; + } else { + var arrayView = new Uint8Array(this.buffer); + } + this.view.set(source.view.subarray(source.offset, source.limit), offset - len); + + source.offset = source.limit; + if (relative) + this.offset -= len; + return this; + }; + + /** + * Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the + * prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer + * will be resized and its contents moved accordingly. + * @param {!ByteBuffer} target Target ByteBuffer + * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes + * prepended if omitted. + * @returns {!ByteBuffer} this + * @expose + * @see ByteBuffer#prepend + */ + ByteBufferPrototype.prependTo = function(target, offset) { + target.prepend(this, offset); + return this; + }; + /** + * Prints debug information about this ByteBuffer's contents. + * @param {function(string)=} out Output function to call, defaults to console.log + * @expose + */ + ByteBufferPrototype.printDebug = function(out) { + if (typeof out !== 'function') out = console.log.bind(console); + out( + this.toString()+"\n"+ + "-------------------------------------------------------------------\n"+ + this.toDebug(/* columns */ true) + ); + }; + + /** + * Gets the number of remaining readable bytes. Contents are the bytes between {@link ByteBuffer#offset} and + * {@link ByteBuffer#limit}, so this returns `limit - offset`. + * @returns {number} Remaining readable bytes. May be negative if `offset > limit`. + * @expose + */ + ByteBufferPrototype.remaining = function() { + return this.limit - this.offset; + }; + /** + * Resets this ByteBuffer's {@link ByteBuffer#offset}. If an offset has been marked through {@link ByteBuffer#mark} + * before, `offset` will be set to {@link ByteBuffer#markedOffset}, which will then be discarded. If no offset has been + * marked, sets `offset = 0`. + * @returns {!ByteBuffer} this + * @see ByteBuffer#mark + * @expose + */ + ByteBufferPrototype.reset = function() { + if (this.markedOffset >= 0) { + this.offset = this.markedOffset; + this.markedOffset = -1; + } else { + this.offset = 0; + } + return this; + }; + /** + * Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that + * large or larger. + * @param {number} capacity Capacity required + * @returns {!ByteBuffer} this + * @throws {TypeError} If `capacity` is not a number + * @throws {RangeError} If `capacity < 0` + * @expose + */ + ByteBufferPrototype.resize = function(capacity) { + if (!this.noAssert) { + if (typeof capacity !== 'number' || capacity % 1 !== 0) + throw TypeError("Illegal capacity: "+capacity+" (not an integer)"); + capacity |= 0; + if (capacity < 0) + throw RangeError("Illegal capacity: 0 <= "+capacity); + } + if (this.buffer.byteLength < capacity) { + var buffer = new ArrayBuffer(capacity); + var view = new Uint8Array(buffer); + view.set(this.view); + this.buffer = buffer; + this.view = view; + } + return this; + }; + /** + * Reverses this ByteBuffer's contents. + * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset} + * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit} + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.reverse = function(begin, end) { + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + if (begin === end) + return this; // Nothing to reverse + Array.prototype.reverse.call(this.view.subarray(begin, end)); + return this; + }; + /** + * Skips the next `length` bytes. This will just advance + * @param {number} length Number of bytes to skip. May also be negative to move the offset back. + * @returns {!ByteBuffer} this + * @expose + */ + ByteBufferPrototype.skip = function(length) { + if (!this.noAssert) { + if (typeof length !== 'number' || length % 1 !== 0) + throw TypeError("Illegal length: "+length+" (not an integer)"); + length |= 0; + } + var offset = this.offset + length; + if (!this.noAssert) { + if (offset < 0 || offset > this.buffer.byteLength) + throw RangeError("Illegal length: 0 <= "+this.offset+" + "+length+" <= "+this.buffer.byteLength); + } + this.offset = offset; + return this; + }; + + /** + * Slices this ByteBuffer by creating a cloned instance with `offset = begin` and `limit = end`. + * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}. + * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}. + * @returns {!ByteBuffer} Clone of this ByteBuffer with slicing applied, backed by the same {@link ByteBuffer#buffer} + * @expose + */ + ByteBufferPrototype.slice = function(begin, end) { + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + var bb = this.clone(); + bb.offset = begin; + bb.limit = end; + return bb; + }; + /** + * Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between + * {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. + * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory if + * possible. Defaults to `false` + * @returns {!ArrayBuffer} Contents as an ArrayBuffer + * @expose + */ + ByteBufferPrototype.toBuffer = function(forceCopy) { + var offset = this.offset, + limit = this.limit; + if (!this.noAssert) { + if (typeof offset !== 'number' || offset % 1 !== 0) + throw TypeError("Illegal offset: Not an integer"); + offset >>>= 0; + if (typeof limit !== 'number' || limit % 1 !== 0) + throw TypeError("Illegal limit: Not an integer"); + limit >>>= 0; + if (offset < 0 || offset > limit || limit > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+offset+" <= "+limit+" <= "+this.buffer.byteLength); + } + // NOTE: It's not possible to have another ArrayBuffer reference the same memory as the backing buffer. This is + // possible with Uint8Array#subarray only, but we have to return an ArrayBuffer by contract. So: + if (!forceCopy && offset === 0 && limit === this.buffer.byteLength) + return this.buffer; + if (offset === limit) + return EMPTY_BUFFER; + var buffer = new ArrayBuffer(limit - offset); + new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(offset, limit), 0); + return buffer; + }; + + /** + * Returns a raw buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between + * {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. This is an alias of {@link ByteBuffer#toBuffer}. + * @function + * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory. + * Defaults to `false` + * @returns {!ArrayBuffer} Contents as an ArrayBuffer + * @expose + */ + ByteBufferPrototype.toArrayBuffer = ByteBufferPrototype.toBuffer; + + /** + * Converts the ByteBuffer's contents to a string. + * @param {string=} encoding Output encoding. Returns an informative string representation if omitted but also allows + * direct conversion to "utf8", "hex", "base64" and "binary" encoding. "debug" returns a hex representation with + * highlighted offsets. + * @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset} + * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit} + * @returns {string} String representation + * @throws {Error} If `encoding` is invalid + * @expose + */ + ByteBufferPrototype.toString = function(encoding, begin, end) { + if (typeof encoding === 'undefined') + return "ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")"; + if (typeof encoding === 'number') + encoding = "utf8", + begin = encoding, + end = begin; + switch (encoding) { + case "utf8": + return this.toUTF8(begin, end); + case "base64": + return this.toBase64(begin, end); + case "hex": + return this.toHex(begin, end); + case "binary": + return this.toBinary(begin, end); + case "debug": + return this.toDebug(); + case "columns": + return this.toColumns(); + default: + throw Error("Unsupported encoding: "+encoding); + } + }; + + // lxiv-embeddable + + /** + * lxiv-embeddable (c) 2014 Daniel Wirtz + * Released under the Apache License, Version 2.0 + * see: https://github.com/dcodeIO/lxiv for details + */ + var lxiv = function() { + "use strict"; + + /** + * lxiv namespace. + * @type {!Object.} + * @exports lxiv + */ + var lxiv = {}; + + /** + * Character codes for output. + * @type {!Array.} + * @inner + */ + var aout = [ + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47 + ]; + + /** + * Character codes for input. + * @type {!Array.} + * @inner + */ + var ain = []; + for (var i=0, k=aout.length; i>2)&0x3f]); + t = (b&0x3)<<4; + if ((b = src()) !== null) { + t |= (b>>4)&0xf; + dst(aout[(t|((b>>4)&0xf))&0x3f]); + t = (b&0xf)<<2; + if ((b = src()) !== null) + dst(aout[(t|((b>>6)&0x3))&0x3f]), + dst(aout[b&0x3f]); + else + dst(aout[t&0x3f]), + dst(61); + } else + dst(aout[t&0x3f]), + dst(61), + dst(61); + } + }; + + /** + * Decodes base64 char codes to bytes. + * @param {!function():number|null} src Characters source as a function returning the next char code respectively + * `null` if there are no more characters left. + * @param {!function(number)} dst Bytes destination as a function successively called with the next byte. + * @throws {Error} If a character code is invalid + */ + lxiv.decode = function(src, dst) { + var c, t1, t2; + function fail(c) { + throw Error("Illegal character code: "+c); + } + while ((c = src()) !== null) { + t1 = ain[c]; + if (typeof t1 === 'undefined') fail(c); + if ((c = src()) !== null) { + t2 = ain[c]; + if (typeof t2 === 'undefined') fail(c); + dst((t1<<2)>>>0|(t2&0x30)>>4); + if ((c = src()) !== null) { + t1 = ain[c]; + if (typeof t1 === 'undefined') + if (c === 61) break; else fail(c); + dst(((t2&0xf)<<4)>>>0|(t1&0x3c)>>2); + if ((c = src()) !== null) { + t2 = ain[c]; + if (typeof t2 === 'undefined') + if (c === 61) break; else fail(c); + dst(((t1&0x3)<<6)>>>0|t2); + } + } + } + } + }; + + /** + * Tests if a string is valid base64. + * @param {string} str String to test + * @returns {boolean} `true` if valid, otherwise `false` + */ + lxiv.test = function(str) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(str); + }; + + return lxiv; + }(); + + // encodings/base64 + + /** + * Encodes this ByteBuffer's contents to a base64 encoded string. + * @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset}. + * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}. + * @returns {string} Base64 encoded string + * @throws {RangeError} If `begin` or `end` is out of bounds + * @expose + */ + ByteBufferPrototype.toBase64 = function(begin, end) { + if (typeof begin === 'undefined') + begin = this.offset; + if (typeof end === 'undefined') + end = this.limit; + begin = begin | 0; end = end | 0; + if (begin < 0 || end > this.capacity || begin > end) + throw RangeError("begin, end"); + var sd; lxiv.encode(function() { + return begin < end ? this.view[begin++] : null; + }.bind(this), sd = stringDestination()); + return sd(); + }; + + /** + * Decodes a base64 encoded string to a ByteBuffer. + * @param {string} str String to decode + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @returns {!ByteBuffer} ByteBuffer + * @expose + */ + ByteBuffer.fromBase64 = function(str, littleEndian) { + if (typeof str !== 'string') + throw TypeError("str"); + var bb = new ByteBuffer(str.length/4*3, littleEndian), + i = 0; + lxiv.decode(stringSource(str), function(b) { + bb.view[i++] = b; + }); + bb.limit = i; + return bb; + }; + + /** + * Encodes a binary string to base64 like `window.btoa` does. + * @param {string} str Binary string + * @returns {string} Base64 encoded string + * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa + * @expose + */ + ByteBuffer.btoa = function(str) { + return ByteBuffer.fromBinary(str).toBase64(); + }; + + /** + * Decodes a base64 encoded string to binary like `window.atob` does. + * @param {string} b64 Base64 encoded string + * @returns {string} Binary string + * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.atob + * @expose + */ + ByteBuffer.atob = function(b64) { + return ByteBuffer.fromBase64(b64).toBinary(); + }; + + // encodings/binary + + /** + * Encodes this ByteBuffer to a binary encoded string, that is using only characters 0x00-0xFF as bytes. + * @param {number=} begin Offset to begin at. Defaults to {@link ByteBuffer#offset}. + * @param {number=} end Offset to end at. Defaults to {@link ByteBuffer#limit}. + * @returns {string} Binary encoded string + * @throws {RangeError} If `offset > limit` + * @expose + */ + ByteBufferPrototype.toBinary = function(begin, end) { + if (typeof begin === 'undefined') + begin = this.offset; + if (typeof end === 'undefined') + end = this.limit; + begin |= 0; end |= 0; + if (begin < 0 || end > this.capacity() || begin > end) + throw RangeError("begin, end"); + if (begin === end) + return ""; + var chars = [], + parts = []; + while (begin < end) { + chars.push(this.view[begin++]); + if (chars.length >= 1024) + parts.push(String.fromCharCode.apply(String, chars)), + chars = []; + } + return parts.join('') + String.fromCharCode.apply(String, chars); + }; + + /** + * Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteBuffer. + * @param {string} str String to decode + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @returns {!ByteBuffer} ByteBuffer + * @expose + */ + ByteBuffer.fromBinary = function(str, littleEndian) { + if (typeof str !== 'string') + throw TypeError("str"); + var i = 0, + k = str.length, + charCode, + bb = new ByteBuffer(k, littleEndian); + while (i 0xff) + throw RangeError("illegal char code: "+charCode); + bb.view[i++] = charCode; + } + bb.limit = k; + return bb; + }; + + // encodings/debug + + /** + * Encodes this ByteBuffer to a hex encoded string with marked offsets. Offset symbols are: + * * `<` : offset, + * * `'` : markedOffset, + * * `>` : limit, + * * `|` : offset and limit, + * * `[` : offset and markedOffset, + * * `]` : markedOffset and limit, + * * `!` : offset, markedOffset and limit + * @param {boolean=} columns If `true` returns two columns hex + ascii, defaults to `false` + * @returns {string|!Array.} Debug string or array of lines if `asArray = true` + * @expose + * @example `>00'01 02<03` contains four bytes with `limit=0, markedOffset=1, offset=3` + * @example `00[01 02 03>` contains four bytes with `offset=markedOffset=1, limit=4` + * @example `00|01 02 03` contains four bytes with `offset=limit=1, markedOffset=-1` + * @example `|` contains zero bytes with `offset=limit=0, markedOffset=-1` + */ + ByteBufferPrototype.toDebug = function(columns) { + var i = -1, + k = this.buffer.byteLength, + b, + hex = "", + asc = "", + out = ""; + while (i 32 && b < 127 ? String.fromCharCode(b) : '.'; + } + ++i; + if (columns) { + if (i > 0 && i % 16 === 0 && i !== k) { + while (hex.length < 3*16+3) hex += " "; + out += hex+asc+"\n"; + hex = asc = ""; + } + } + if (i === this.offset && i === this.limit) + hex += i === this.markedOffset ? "!" : "|"; + else if (i === this.offset) + hex += i === this.markedOffset ? "[" : "<"; + else if (i === this.limit) + hex += i === this.markedOffset ? "]" : ">"; + else + hex += i === this.markedOffset ? "'" : (columns || (i !== 0 && i !== k) ? " " : ""); + } + if (columns && hex !== " ") { + while (hex.length < 3*16+3) + hex += " "; + out += hex + asc + "\n"; + } + return columns ? out : hex; + }; + + /** + * Decodes a hex encoded string with marked offsets to a ByteBuffer. + * @param {string} str Debug string to decode (not be generated with `columns = true`) + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} ByteBuffer + * @expose + * @see ByteBuffer#toDebug + */ + ByteBuffer.fromDebug = function(str, littleEndian, noAssert) { + var k = str.length, + bb = new ByteBuffer(((k+1)/3)|0, littleEndian, noAssert); + var i = 0, j = 0, ch, b, + rs = false, // Require symbol next + ho = false, hm = false, hl = false, // Already has offset (ho), markedOffset (hm), limit (hl)? + fail = false; + while (i': + if (!noAssert) { + if (hl) { + fail = true; + break; + } + hl = true; + } + bb.limit = j; + rs = false; + break; + case "'": + if (!noAssert) { + if (hm) { + fail = true; + break; + } + hm = true; + } + bb.markedOffset = j; + rs = false; + break; + case ' ': + rs = false; + break; + default: + if (!noAssert) { + if (rs) { + fail = true; + break; + } + } + b = parseInt(ch+str.charAt(i++), 16); + if (!noAssert) { + if (isNaN(b) || b < 0 || b > 255) + throw TypeError("Illegal str: Not a debug encoded string"); + } + bb.view[j++] = b; + rs = true; + } + if (fail) + throw TypeError("Illegal str: Invalid symbol at "+i); + } + if (!noAssert) { + if (!ho || !hl) + throw TypeError("Illegal str: Missing offset or limit"); + if (j>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + var out = new Array(end - begin), + b; + while (begin < end) { + b = this.view[begin++]; + if (b < 0x10) + out.push("0", b.toString(16)); + else out.push(b.toString(16)); + } + return out.join(''); + }; + + /** + * Decodes a hex encoded string to a ByteBuffer. + * @param {string} str String to decode + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} ByteBuffer + * @expose + */ + ByteBuffer.fromHex = function(str, littleEndian, noAssert) { + if (!noAssert) { + if (typeof str !== 'string') + throw TypeError("Illegal str: Not a string"); + if (str.length % 2 !== 0) + throw TypeError("Illegal str: Length not a multiple of 2"); + } + var k = str.length, + bb = new ByteBuffer((k / 2) | 0, littleEndian), + b; + for (var i=0, j=0; i 255) + throw TypeError("Illegal str: Contains non-hex characters"); + bb.view[j++] = b; + } + bb.limit = j; + return bb; + }; + + // utfx-embeddable + + /** + * utfx-embeddable (c) 2014 Daniel Wirtz + * Released under the Apache License, Version 2.0 + * see: https://github.com/dcodeIO/utfx for details + */ + var utfx = function() { + "use strict"; + + /** + * utfx namespace. + * @inner + * @type {!Object.} + */ + var utfx = {}; + + /** + * Maximum valid code point. + * @type {number} + * @const + */ + utfx.MAX_CODEPOINT = 0x10FFFF; + + /** + * Encodes UTF8 code points to UTF8 bytes. + * @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point + * respectively `null` if there are no more code points left or a single numeric code point. + * @param {!function(number)} dst Bytes destination as a function successively called with the next byte + */ + utfx.encodeUTF8 = function(src, dst) { + var cp = null; + if (typeof src === 'number') + cp = src, + src = function() { return null; }; + while (cp !== null || (cp = src()) !== null) { + if (cp < 0x80) + dst(cp&0x7F); + else if (cp < 0x800) + dst(((cp>>6)&0x1F)|0xC0), + dst((cp&0x3F)|0x80); + else if (cp < 0x10000) + dst(((cp>>12)&0x0F)|0xE0), + dst(((cp>>6)&0x3F)|0x80), + dst((cp&0x3F)|0x80); + else + dst(((cp>>18)&0x07)|0xF0), + dst(((cp>>12)&0x3F)|0x80), + dst(((cp>>6)&0x3F)|0x80), + dst((cp&0x3F)|0x80); + cp = null; + } + }; + + /** + * Decodes UTF8 bytes to UTF8 code points. + * @param {!function():number|null} src Bytes source as a function returning the next byte respectively `null` if there + * are no more bytes left. + * @param {!function(number)} dst Code points destination as a function successively called with each decoded code point. + * @throws {RangeError} If a starting byte is invalid in UTF8 + * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the + * remaining bytes. + */ + utfx.decodeUTF8 = function(src, dst) { + var a, b, c, d, fail = function(b) { + b = b.slice(0, b.indexOf(null)); + var err = Error(b.toString()); + err.name = "TruncatedError"; + err['bytes'] = b; + throw err; + }; + while ((a = src()) !== null) { + if ((a&0x80) === 0) + dst(a); + else if ((a&0xE0) === 0xC0) + ((b = src()) === null) && fail([a, b]), + dst(((a&0x1F)<<6) | (b&0x3F)); + else if ((a&0xF0) === 0xE0) + ((b=src()) === null || (c=src()) === null) && fail([a, b, c]), + dst(((a&0x0F)<<12) | ((b&0x3F)<<6) | (c&0x3F)); + else if ((a&0xF8) === 0xF0) + ((b=src()) === null || (c=src()) === null || (d=src()) === null) && fail([a, b, c ,d]), + dst(((a&0x07)<<18) | ((b&0x3F)<<12) | ((c&0x3F)<<6) | (d&0x3F)); + else throw RangeError("Illegal starting byte: "+a); + } + }; + + /** + * Converts UTF16 characters to UTF8 code points. + * @param {!function():number|null} src Characters source as a function returning the next char code respectively + * `null` if there are no more characters left. + * @param {!function(number)} dst Code points destination as a function successively called with each converted code + * point. + */ + utfx.UTF16toUTF8 = function(src, dst) { + var c1, c2 = null; + while (true) { + if ((c1 = c2 !== null ? c2 : src()) === null) + break; + if (c1 >= 0xD800 && c1 <= 0xDFFF) { + if ((c2 = src()) !== null) { + if (c2 >= 0xDC00 && c2 <= 0xDFFF) { + dst((c1-0xD800)*0x400+c2-0xDC00+0x10000); + c2 = null; continue; + } + } + } + dst(c1); + } + if (c2 !== null) dst(c2); + }; + + /** + * Converts UTF8 code points to UTF16 characters. + * @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point + * respectively `null` if there are no more code points left or a single numeric code point. + * @param {!function(number)} dst Characters destination as a function successively called with each converted char code. + * @throws {RangeError} If a code point is out of range + */ + utfx.UTF8toUTF16 = function(src, dst) { + var cp = null; + if (typeof src === 'number') + cp = src, src = function() { return null; }; + while (cp !== null || (cp = src()) !== null) { + if (cp <= 0xFFFF) + dst(cp); + else + cp -= 0x10000, + dst((cp>>10)+0xD800), + dst((cp%0x400)+0xDC00); + cp = null; + } + }; + + /** + * Converts and encodes UTF16 characters to UTF8 bytes. + * @param {!function():number|null} src Characters source as a function returning the next char code respectively `null` + * if there are no more characters left. + * @param {!function(number)} dst Bytes destination as a function successively called with the next byte. + */ + utfx.encodeUTF16toUTF8 = function(src, dst) { + utfx.UTF16toUTF8(src, function(cp) { + utfx.encodeUTF8(cp, dst); + }); + }; + + /** + * Decodes and converts UTF8 bytes to UTF16 characters. + * @param {!function():number|null} src Bytes source as a function returning the next byte respectively `null` if there + * are no more bytes left. + * @param {!function(number)} dst Characters destination as a function successively called with each converted char code. + * @throws {RangeError} If a starting byte is invalid in UTF8 + * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes. + */ + utfx.decodeUTF8toUTF16 = function(src, dst) { + utfx.decodeUTF8(src, function(cp) { + utfx.UTF8toUTF16(cp, dst); + }); + }; + + /** + * Calculates the byte length of an UTF8 code point. + * @param {number} cp UTF8 code point + * @returns {number} Byte length + */ + utfx.calculateCodePoint = function(cp) { + return (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4; + }; + + /** + * Calculates the number of UTF8 bytes required to store UTF8 code points. + * @param {(!function():number|null)} src Code points source as a function returning the next code point respectively + * `null` if there are no more code points left. + * @returns {number} The number of UTF8 bytes required + */ + utfx.calculateUTF8 = function(src) { + var cp, l=0; + while ((cp = src()) !== null) + l += (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4; + return l; + }; + + /** + * Calculates the number of UTF8 code points respectively UTF8 bytes required to store UTF16 char codes. + * @param {(!function():number|null)} src Characters source as a function returning the next char code respectively + * `null` if there are no more characters left. + * @returns {!Array.} The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1. + */ + utfx.calculateUTF16asUTF8 = function(src) { + var n=0, l=0; + utfx.UTF16toUTF8(src, function(cp) { + ++n; l += (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4; + }); + return [n,l]; + }; + + return utfx; + }(); + + // encodings/utf8 + + /** + * Encodes this ByteBuffer's contents between {@link ByteBuffer#offset} and {@link ByteBuffer#limit} to an UTF8 encoded + * string. + * @returns {string} Hex encoded string + * @throws {RangeError} If `offset > limit` + * @expose + */ + ByteBufferPrototype.toUTF8 = function(begin, end) { + if (typeof begin === 'undefined') begin = this.offset; + if (typeof end === 'undefined') end = this.limit; + if (!this.noAssert) { + if (typeof begin !== 'number' || begin % 1 !== 0) + throw TypeError("Illegal begin: Not an integer"); + begin >>>= 0; + if (typeof end !== 'number' || end % 1 !== 0) + throw TypeError("Illegal end: Not an integer"); + end >>>= 0; + if (begin < 0 || begin > end || end > this.buffer.byteLength) + throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength); + } + var sd; try { + utfx.decodeUTF8toUTF16(function() { + return begin < end ? this.view[begin++] : null; + }.bind(this), sd = stringDestination()); + } catch (e) { + if (begin !== end) + throw RangeError("Illegal range: Truncated data, "+begin+" != "+end); + } + return sd(); + }; + + /** + * Decodes an UTF8 encoded string to a ByteBuffer. + * @param {string} str String to decode + * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to + * {@link ByteBuffer.DEFAULT_ENDIAN}. + * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to + * {@link ByteBuffer.DEFAULT_NOASSERT}. + * @returns {!ByteBuffer} ByteBuffer + * @expose + */ + ByteBuffer.fromUTF8 = function(str, littleEndian, noAssert) { + if (!noAssert) + if (typeof str !== 'string') + throw TypeError("Illegal str: Not a string"); + var bb = new ByteBuffer(utfx.calculateUTF16asUTF8(stringSource(str), true)[1], littleEndian, noAssert), + i = 0; + utfx.encodeUTF16toUTF8(stringSource(str), function(b) { + bb.view[i++] = b; + }); + bb.limit = i; + return bb; + }; + + return ByteBuffer; +}); diff --git a/games/laya-snakes/libs/laya.ani.js b/games/laya-snakes/libs/laya.ani.js new file mode 100644 index 0000000..49786ea --- /dev/null +++ b/games/laya-snakes/libs/laya.ani.js @@ -0,0 +1,4257 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Browser=laya.utils.Browser,Byte=laya.utils.Byte,Event=laya.events.Event,EventDispatcher=laya.events.EventDispatcher; + var Graphics=laya.display.Graphics,Handler=laya.utils.Handler,Loader=laya.net.Loader,MathUtil=laya.maths.MathUtil; + var Matrix=laya.maths.Matrix,Render=laya.renders.Render,Resource=laya.resource.Resource,RunDriver=laya.utils.RunDriver; + var Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Texture=laya.resource.Texture,URL=laya.net.URL; + /** + *@private + */ + //class laya.ani.AnimationState + var AnimationState=(function(){ + function AnimationState(){} + __class(AnimationState,'laya.ani.AnimationState'); + AnimationState.stopped=0; + AnimationState.paused=1; + AnimationState.playing=2; + return AnimationState; + })() + + + /** + *@private + */ + //class laya.ani.bone.Bone + var Bone=(function(){ + function Bone(){ + this.name=null; + this.root=null; + this.parentBone=null; + this.length=10; + this.transform=null; + this.inheritScale=true; + this.inheritRotation=true; + this.rotation=NaN; + this.resultRotation=NaN; + this._tempMatrix=null; + this._sprite=null; + this.resultTransform=new Transform(); + this.resultMatrix=new Matrix(); + this._children=[]; + } + + __class(Bone,'laya.ani.bone.Bone'); + var __proto=Bone.prototype; + __proto.setTempMatrix=function(matrix){ + this._tempMatrix=matrix; + var i=0,n=0; + var tBone; + for (i=0,n=this._children.length;i < n;i++){ + tBone=this._children[i]; + tBone.setTempMatrix(this._tempMatrix); + } + } + + __proto.update=function(pMatrix){ + this.rotation=this.transform.skX; + var tResultMatrix; + if (pMatrix){ + tResultMatrix=this.resultTransform.getMatrix(); + Matrix.mul(tResultMatrix,pMatrix,this.resultMatrix); + this.resultRotation=this.rotation; + }else { + this.resultRotation=this.rotation+this.parentBone.resultRotation; + if (this.parentBone){ + if (this.inheritRotation && this.inheritScale){ + tResultMatrix=this.resultTransform.getMatrix(); + Matrix.mul(tResultMatrix,this.parentBone.resultMatrix,this.resultMatrix); + }else { + var temp=0; + var parent=this.parentBone; + var tAngle=NaN; + var cos=NaN; + var sin=NaN; + var tParentMatrix=this.parentBone.resultMatrix; + var worldX=tParentMatrix.a *this.transform.x+tParentMatrix.c *this.transform.y+tParentMatrix.tx; + var worldY=tParentMatrix.b *this.transform.x+tParentMatrix.d *this.transform.y+tParentMatrix.ty; + var tTestMatrix=new Matrix(); + if (this.inheritRotation){ + tAngle=Math.atan2(parent.resultMatrix.b,parent.resultMatrix.a); + cos=Math.cos(tAngle),sin=Math.sin(tAngle); + tTestMatrix.setTo(cos,sin,-sin,cos,0,0); + Matrix.mul(this._tempMatrix,tTestMatrix,Matrix.TEMP); + Matrix.TEMP.copyTo(tTestMatrix); + tResultMatrix=this.resultTransform.getMatrix(); + Matrix.mul(tResultMatrix,tTestMatrix,this.resultMatrix); + this.resultMatrix.tx=worldX; + this.resultMatrix.ty=worldY; + }else if (this.inheritScale){ + tResultMatrix=this.resultTransform.getMatrix(); + Matrix.TEMP.identity(); + Matrix.TEMP.d=-1; + Matrix.mul(tResultMatrix,Matrix.TEMP,this.resultMatrix); + this.resultMatrix.tx=worldX; + this.resultMatrix.ty=worldY; + }else { + tResultMatrix=this.resultTransform.getMatrix(); + Matrix.TEMP.identity(); + Matrix.TEMP.d=-1; + Matrix.mul(tResultMatrix,Matrix.TEMP,this.resultMatrix); + this.resultMatrix.tx=worldX; + this.resultMatrix.ty=worldY; + } + } + }else { + tResultMatrix=this.resultTransform.getMatrix(); + tResultMatrix.copyTo(this.resultMatrix); + } + }; + var i=0,n=0; + var tBone; + for (i=0,n=this._children.length;i < n;i++){ + tBone=this._children[i]; + tBone.update(); + } + } + + __proto.updateChild=function(){ + var i=0,n=0; + var tBone; + for (i=0,n=this._children.length;i < n;i++){ + tBone=this._children[i]; + tBone.update(); + } + } + + __proto.updateDraw=function(x,y){ + if (this._sprite){ + this._sprite.x=x+this.resultMatrix.tx; + this._sprite.y=y+this.resultMatrix.ty; + }else { + this._sprite=new Sprite(); + this._sprite.graphics.drawCircle(0,0,5,"#ff0000"); + this._sprite.graphics.fillText(this.name,0,0,"20px Arial","#00ff00","center"); + Laya.stage.addChild(this._sprite); + this._sprite.x=x+this.resultMatrix.tx; + this._sprite.y=y+this.resultMatrix.ty; + }; + var i=0,n=0; + var tBone; + for (i=0,n=this._children.length;i < n;i++){ + tBone=this._children[i]; + tBone.updateDraw(x,y); + } + } + + __proto.addChild=function(bone){ + this._children.push(bone); + bone.parentBone=this; + } + + __proto.findBone=function(boneName){ + if (this.name==boneName){ + return this; + }else { + var i=0,n=0; + var tBone; + var tResult; + for (i=0,n=this._children.length;i < n;i++){ + tBone=this._children[i]; + tResult=tBone.findBone(boneName); + if (tResult){ + return tResult; + } + } + } + return null; + } + + __proto.localToWorld=function(local){ + var localX=local[0]; + var localY=local[1]; + local[0]=localX *this.resultMatrix.a+localY *this.resultMatrix.c+this.resultMatrix.tx; + local[1]=localX *this.resultMatrix.b+localY *this.resultMatrix.d+this.resultMatrix.ty; + } + + return Bone; + })() + + + /** + *@private + */ + //class laya.ani.bone.BoneSlot + var BoneSlot=(function(){ + function BoneSlot(){ + this.name=null; + this.parent=null; + this.attachmentName=null; + this.srcDisplayIndex=-1; + this.type="src"; + this.templet=null; + this.currSlotData=null; + this.currTexture=null; + this.currDisplayData=null; + this.displayIndex=-1; + this._diyTexture=null; + this._parentMatrix=null; + this._resultMatrix=null; + this._skinSprite=null; + this.deformData=null; + } + + __class(BoneSlot,'laya.ani.bone.BoneSlot'); + var __proto=BoneSlot.prototype; + /** + *设置要显示的插槽数据 + *@param slotData + *@param disIndex + */ + __proto.showSlotData=function(slotData){ + this.currSlotData=slotData; + this.displayIndex=this.srcDisplayIndex; + this.currDisplayData=null; + this.currTexture=null; + } + + /** + *通过名字显示指定对象 + *@param name + */ + __proto.showDisplayByName=function(name){ + if (this.currSlotData){ + this.showDisplayByIndex(this.currSlotData.getDisplayByName(name)); + } + } + + /** + *指定显示对象 + *@param index + */ + __proto.showDisplayByIndex=function(index){ + if (this.currSlotData && index >-1 && index < this.currSlotData.displayArr.length){ + this.displayIndex=index; + this.currDisplayData=this.currSlotData.displayArr[index]; + if (this.currDisplayData){ + var tName=this.currDisplayData.name; + this.currTexture=this.templet.getTexture(tName); + if (this.currTexture && Render.isWebGL && this.currDisplayData.type==0 && this.currDisplayData.uvs){ + this.currTexture=this.currDisplayData.createTexture(this.currTexture); + } + } + }else { + this.displayIndex=-1; + this.currDisplayData=null; + this.currTexture=null; + } + } + + /** + *替换皮肤 + *@param _texture + */ + __proto.replaceSkin=function(_texture){ + this._diyTexture=_texture; + } + + /** + *保存父矩阵的索引 + *@param parentMatrix + */ + __proto.setParentMatrix=function(parentMatrix){ + this._parentMatrix=parentMatrix; + } + + /** + *把纹理画到Graphics上 + *@param graphics + *@param noUseSave + */ + __proto.draw=function(graphics,boneMatrixArray,noUseSave,alpha){ + (noUseSave===void 0)&& (noUseSave=false); + (alpha===void 0)&& (alpha=1); + if ((this._diyTexture==null && this.currTexture==null)|| this.currDisplayData==null){ + if (!(this.currDisplayData && this.currDisplayData.type==3)){ + return; + } + }; + var tTexture=this.currTexture; + if (this._diyTexture)tTexture=this._diyTexture; + var tSkinSprite; + switch (this.currDisplayData.type){ + case 0: + if (graphics){ + var tCurrentMatrix=this.getDisplayMatrix(); + if (this._parentMatrix){ + var tRotateKey=false; + if (tCurrentMatrix){ + Matrix.mul(tCurrentMatrix,this._parentMatrix,Matrix.TEMP); + var tResultMatrix; + if (noUseSave){ + if (this._resultMatrix==null)this._resultMatrix=new Matrix(); + tResultMatrix=this._resultMatrix; + }else { + tResultMatrix=new Matrix(); + } + if ((!Render.isWebGL && this.currDisplayData.uvs)|| (Render.isWebGL && this._diyTexture && this.currDisplayData.uvs)){ + var tTestMatrix=new Matrix(1,0,0,1); + if (this.currDisplayData.uvs[1] > this.currDisplayData.uvs[5]){ + tTestMatrix.d=-1; + } + if (this.currDisplayData.uvs[0] > this.currDisplayData.uvs[4] + && this.currDisplayData.uvs[1] > this.currDisplayData.uvs[5]){ + tRotateKey=true; + tTestMatrix.rotate(-Math.PI/2); + } + Matrix.mul(tTestMatrix,Matrix.TEMP,tResultMatrix); + }else { + Matrix.TEMP.copyTo(tResultMatrix); + } + if (tRotateKey){ + graphics.drawTexture(tTexture,-this.currDisplayData.height / 2,-this.currDisplayData.width / 2,this.currDisplayData.height,this.currDisplayData.width,tResultMatrix); + }else { + graphics.drawTexture(tTexture,-this.currDisplayData.width / 2,-this.currDisplayData.height / 2,this.currDisplayData.width,this.currDisplayData.height,tResultMatrix); + } + } + } + } + break ; + case 1: + if (noUseSave){ + if (this._skinSprite==null){ + this._skinSprite=RunDriver.skinAniSprite(); + } + tSkinSprite=this._skinSprite; + }else { + tSkinSprite=RunDriver.skinAniSprite(); + } + if (tSkinSprite==null){ + return; + }; + var tVBArray=[]; + var tIBArray=[]; + var tRed=1; + var tGreed=1; + var tBlue=1; + var tAlpha=1; + if (this.currDisplayData.bones==null){ + var tVertices=this.currDisplayData.weights; + if (this.deformData){ + tVertices=this.deformData; + } + for (var i=0,ii=0;i < tVertices.length && ii< this.currDisplayData.uvs.length;){ + var tX=tVertices[i++]; + var tY=tVertices[i++]; + tVBArray.push(tX,tY,this.currDisplayData.uvs[ii++],this.currDisplayData.uvs[ii++],tRed,tGreed,tBlue,tAlpha); + }; + var tTriangleNum=this.currDisplayData.triangles.length / 3; + for (i=0;i < tTriangleNum;i++){ + tIBArray.push(this.currDisplayData.triangles[i *3]); + tIBArray.push(this.currDisplayData.triangles[i *3+1]); + tIBArray.push(this.currDisplayData.triangles[i *3+2]); + } + tSkinSprite.init(this.currTexture,tVBArray,tIBArray); + var tCurrentMatrix2=this.getDisplayMatrix(); + if (this._parentMatrix){ + if (tCurrentMatrix2){ + Matrix.mul(tCurrentMatrix2,this._parentMatrix,Matrix.TEMP); + var tResultMatrix2; + if (noUseSave){ + if (this._resultMatrix==null)this._resultMatrix=new Matrix(); + tResultMatrix2=this._resultMatrix; + }else { + tResultMatrix2=new Matrix(); + } + Matrix.TEMP.copyTo(tResultMatrix2); + tSkinSprite.transform=tResultMatrix2; + } + } + }else { + this.skinMesh(boneMatrixArray,tSkinSprite,alpha); + } + graphics.drawSkin(tSkinSprite); + break ; + case 2: + if (noUseSave){ + if (this._skinSprite==null){ + this._skinSprite=RunDriver.skinAniSprite(); + } + tSkinSprite=this._skinSprite; + }else { + tSkinSprite=RunDriver.skinAniSprite(); + } + if (tSkinSprite==null){ + return; + } + this.skinMesh(boneMatrixArray,tSkinSprite,alpha); + graphics.drawSkin(tSkinSprite); + break ; + case 3: + break ; + } + } + + /** + *显示蒙皮动画 + *@param boneMatrixArray 当前帧的骨骼矩阵 + */ + __proto.skinMesh=function(boneMatrixArray,skinSprite,alpha){ + var tBones=this.currDisplayData.bones; + var tUvs=this.currDisplayData.uvs; + var tWeights=this.currDisplayData.weights; + var tTriangles=this.currDisplayData.triangles; + var tVBArray=[]; + var tIBArray=[]; + var tRx=0; + var tRy=0; + var nn=0; + var tMatrix; + var tX=NaN; + var tY=NaN; + var tB=0; + var tWeight=0; + var tVertices=[]; + var i=0,j=0,n=0; + var tRed=1; + var tGreed=1; + var tBlue=1; + var tAlpha=alpha; + if (this.deformData && this.deformData.length > 0){ + var f=0; + for (i=0,n=tBones.length;i < n;){ + nn=tBones[i++]+i; + tRx=0,tRy=0; + for (;i < nn;i++){ + tMatrix=boneMatrixArray[tBones[i]] + tX=tWeights[tB]+this.deformData[f++]; + tY=tWeights[tB+1]+this.deformData[f++]; + tWeight=tWeights[tB+2]; + tRx+=(tX *tMatrix.a+tY *tMatrix.c+tMatrix.tx)*tWeight; + tRy+=(tX *tMatrix.b+tY *tMatrix.d+tMatrix.ty)*tWeight; + tB+=3; + } + tVertices.push(tRx,tRy); + } + }else { + for (i=0,n=tBones.length;i < n;){ + nn=tBones[i++]+i; + tRx=0,tRy=0; + for (;i < nn;i++){ + tMatrix=boneMatrixArray[tBones[i]] + tX=tWeights[tB]; + tY=tWeights[tB+1]; + tWeight=tWeights[tB+2]; + tRx+=(tX *tMatrix.a+tY *tMatrix.c+tMatrix.tx)*tWeight; + tRy+=(tX *tMatrix.b+tY *tMatrix.d+tMatrix.ty)*tWeight; + tB+=3; + } + tVertices.push(tRx,tRy); + } + } + for (i=0,j=0;i < tVertices.length && j < tUvs.length;){ + tRx=tVertices[i++]; + tRy=tVertices[i++]; + tVBArray.push(tRx,tRy,tUvs[j++],tUvs[j++],tRed,tGreed,tBlue,tAlpha); + } + for (i=0,n=tTriangles.length;i < n;i++){ + tIBArray.push(tTriangles[i]); + } + skinSprite.init(this.currTexture,tVBArray,tIBArray); + } + + /** + *画骨骼的起始点,方便调试 + *@param graphics + */ + __proto.drawBonePoint=function(graphics){ + if (graphics && this._parentMatrix){ + graphics.drawCircle(this._parentMatrix.tx,this._parentMatrix.ty,5,"#ff0000"); + } + } + + /** + *得到显示对象的矩阵 + *@return + */ + __proto.getDisplayMatrix=function(){ + if (this.currDisplayData){ + return this.currDisplayData.transform.getMatrix(); + } + return null; + } + + /** + *得到插糟的矩阵 + *@return + */ + __proto.getMatrix=function(){ + return this._resultMatrix; + } + + /** + *用原始数据拷贝出一个 + *@return + */ + __proto.copy=function(){ + var tBoneSlot=new BoneSlot(); + tBoneSlot.type="copy"; + tBoneSlot.name=this.name; + tBoneSlot.attachmentName=this.attachmentName; + tBoneSlot.srcDisplayIndex=this.srcDisplayIndex; + tBoneSlot.parent=this.parent; + tBoneSlot.displayIndex=this.displayIndex; + tBoneSlot.templet=this.templet; + tBoneSlot.currSlotData=this.currSlotData; + tBoneSlot.currTexture=this.currTexture; + tBoneSlot.currDisplayData=this.currDisplayData; + return tBoneSlot; + } + + return BoneSlot; + })() + + + /** + *@private + */ + //class laya.ani.bone.DeformAniData + var DeformAniData=(function(){ + function DeformAniData(){ + this.skinName=null; + this.deformSlotDataList=[]; + } + + __class(DeformAniData,'laya.ani.bone.DeformAniData'); + return DeformAniData; + })() + + + /** + *... + *@author + */ + //class laya.ani.bone.DeformSlotData + var DeformSlotData=(function(){ + function DeformSlotData(){ + this.deformSlotDisplayList=[]; + } + + __class(DeformSlotData,'laya.ani.bone.DeformSlotData'); + return DeformSlotData; + })() + + + /** + *@private + */ + //class laya.ani.bone.DeformSlotDisplayData + var DeformSlotDisplayData=(function(){ + function DeformSlotDisplayData(){ + this.boneSlot=null; + this.slotIndex=-1; + this.attachment=null; + this.deformData=null; + this.frameIndex=0; + this.timeList=[]; + this.vectices=[]; + this.tweenKeyList=[]; + } + + __class(DeformSlotDisplayData,'laya.ani.bone.DeformSlotDisplayData'); + var __proto=DeformSlotDisplayData.prototype; + __proto.binarySearch1=function(values,target){ + var low=0; + var high=values.length-2; + if (high==0) + return 1; + var current=high >>> 1; + while (true){ + if (values[Math.floor(current+1)] <=target) + low=current+1; + else + high=current; + if (low==high) + return low+1; + current=(low+high)>>> 1; + } + return 0; + } + + // Can't happen. + __proto.apply=function(time,boneSlot,alpha){ + (alpha===void 0)&& (alpha=1); + if (this.timeList.length <=0){ + return; + }; + var i=0; + var n=0; + var tTime=this.timeList[0]; + if (time < tTime){ + return; + }; + var tVertexCount=this.vectices[0].length; + var tVertices=[]; + var tFrameIndex=this.binarySearch1(this.timeList,time); + this.frameIndex=tFrameIndex; + if (time >=this.timeList[this.timeList.length-1]){ + var lastVertices=this.vectices[this.vectices.length-1]; + if (alpha < 1){ + for (i=0;i < tVertexCount;i++){ + tVertices[i]+=(lastVertices[i]-tVertices[i])*alpha; + } + }else { + for (i=0;i < tVertexCount;i++){ + tVertices[i]=lastVertices[i]; + } + } + this.deformData=tVertices; + return; + }; + var tTweenKey=this.tweenKeyList[this.frameIndex]; + var tPrevVertices=this.vectices[this.frameIndex-1]; + var tNextVertices=this.vectices[this.frameIndex]; + var tPreFrameTime=this.timeList[this.frameIndex-1]; + var tFrameTime=this.timeList[this.frameIndex]; + if (this.tweenKeyList[tFrameIndex-1]){ + alpha=(time-tPreFrameTime)/ (tFrameTime-tPreFrameTime); + }; + var tPrev=NaN; + for (i=0;i < tVertexCount;i++){ + tPrev=tPrevVertices[i]; + tVertices[i]=tPrev+(tNextVertices[i]-tPrev)*alpha; + } + this.deformData=tVertices; + } + + return DeformSlotDisplayData; + })() + + + /** + *... + *@author + */ + //class laya.ani.bone.DrawOrderData + var DrawOrderData=(function(){ + function DrawOrderData(){ + this.time=NaN; + this.drawOrder=[]; + } + + __class(DrawOrderData,'laya.ani.bone.DrawOrderData'); + return DrawOrderData; + })() + + + //class laya.ani.bone.EventData + var EventData=(function(){ + function EventData(){ + this.name=null; + this.intValue=0; + this.floatValue=NaN; + this.stringValue=null; + this.time=NaN; + } + + __class(EventData,'laya.ani.bone.EventData'); + return EventData; + })() + + + /** + *@private + */ + //class laya.ani.bone.IkConstraint + var IkConstraint=(function(){ + function IkConstraint(data,bones){ + this._targetBone=null; + this._bones=null; + this._data=null; + this.name=null; + this.mix=NaN; + this.bendDirection=NaN; + this._data=data; + this._targetBone=bones[data.targetBoneIndex]; + if (this._bones==null)this._bones=[]; + this._bones.length=0; + for (var i=0,n=data.boneIndexs.length;i < n;i++){ + this._bones.push(bones[data.boneIndexs[i]]); + } + this.name=data.name; + this.mix=data.mix; + this.bendDirection=data.bendDirection; + } + + __class(IkConstraint,'laya.ani.bone.IkConstraint'); + var __proto=IkConstraint.prototype; + __proto.apply=function(){ + switch (this._bones.length){ + case 1: + this._applyIk1(this._bones[0],this._targetBone.resultMatrix.tx,this._targetBone.resultMatrix.ty,this.mix); + break ; + case 2: + this._applyIk2(this._bones[0],this._bones[1],this._targetBone.resultMatrix.tx,this._targetBone.resultMatrix.ty,this.bendDirection,this.mix); + break ; + } + } + + __proto._applyIk1=function(bone,targetX,targetY,alpha){ + var pp=bone.parentBone; + var id=1 / (pp.resultMatrix.a *pp.resultMatrix.d-pp.resultMatrix.b *pp.resultMatrix.c); + var x=targetX-pp.resultMatrix.tx; + var y=targetY-pp.resultMatrix.ty; + var tx=(x *pp.resultMatrix.d-y *pp.resultMatrix.c)*id-bone.transform.x; + var ty=(y *pp.resultMatrix.a-x *pp.resultMatrix.b)*id-bone.transform.y; + var rotationIK=Math.atan2(ty,tx)*IkConstraint.radDeg-0-bone.transform.skX; + if (bone.transform.scX < 0)rotationIK+=180; + if (rotationIK > 180) + rotationIK-=360; + else if (rotationIK <-180)rotationIK+=360; + bone.transform.skX=bone.transform.skY=bone.transform.skX+rotationIK *alpha; + bone.update(); + } + + __proto._applyIk2=function(parent,child,targetX,targetY,bendDir,alpha){ + if (alpha==0){ + return; + }; + var px=parent.resultTransform.x,py=parent.resultTransform.y; + var psx=parent.transform.scX,psy=parent.transform.scY; + var csx=child.transform.scX; + var os1=0,os2=0,s2=0; + if (psx < 0){ + psx=-psx; + os1=180; + s2=-1; + }else { + os1=0; + s2=1; + } + if (psy < 0){ + psy=-psy; + s2=-s2; + } + if (csx < 0){ + csx=-csx; + os2=180; + }else { + os2=0 + }; + var cx=child.resultTransform.x,cy=NaN,cwx=NaN,cwy=NaN; + var a=parent.resultMatrix.a,b=parent.resultMatrix.c; + var c=parent.resultMatrix.b,d=parent.resultMatrix.d; + var u=Math.abs(psx-psy)<=0.0001; + if (!u){ + cy=0; + cwx=a *cx+parent.resultMatrix.tx; + cwy=c *cx+parent.resultMatrix.ty; + }else { + cy=child.resultTransform.y; + cwx=a *cx+b *cy+parent.resultMatrix.tx; + cwy=c *cx+d *cy+parent.resultMatrix.ty; + }; + var pp=parent.parentBone; + a=pp.resultMatrix.a; + b=pp.resultMatrix.c; + c=pp.resultMatrix.b; + d=pp.resultMatrix.d; + var id=1 / (a *d-b *c); + var x=targetX-pp.resultMatrix.tx,y=targetY-pp.resultMatrix.ty; + var tx=(x *d-y *b)*id-px; + var ty=(y *a-x *c)*id-py; + x=cwx-pp.resultMatrix.tx; + y=cwy-pp.resultMatrix.ty; + var dx=(x *d-y *b)*id-px; + var dy=(y *a-x *c)*id-py; + var l1=Math.sqrt(dx *dx+dy *dy); + var l2=child.length *csx; + var a1=NaN,a2=NaN; + if (u){ + l2 *=psx; + var cos=(tx *tx+ty *ty-l1 *l1-l2 *l2)/ (2 *l1 *l2); + if (cos <-1) + cos=-1; + else if (cos > 1)cos=1; + a2=Math.acos(cos)*bendDir; + a=l1+l2 *cos; + b=l2 *Math.sin(a2); + a1=Math.atan2(ty *a-tx *b,tx *a+ty *b); + }else { + a=psx *l2; + b=psy *l2; + var aa=a *a,bb=b *b,dd=tx *tx+ty *ty,ta=Math.atan2(ty,tx); + c=bb *l1 *l1+aa *dd-aa *bb; + var c1=-2 *bb *l1,c2=bb-aa; + d=c1 *c1-4 *c2 *c; + if (d > 0){ + var q=Math.sqrt(d); + if (c1 < 0)q=-q; + q=-(c1+q)/ 2; + var r0=q / c2,r1=c / q; + var r=Math.abs(r0)< Math.abs(r1)? r0 :r1; + if (r *r <=dd){ + y=Math.sqrt(dd-r *r)*bendDir; + a1=ta-Math.atan2(y,r); + a2=Math.atan2(y / psy,(r-l1)/ psx); + } + }; + var minAngle=0,minDist=Number.MAX_VALUE,minX=0,minY=0; + var maxAngle=0,maxDist=0,maxX=0,maxY=0; + x=l1+a; + d=x *x; + if (d > maxDist){ + maxAngle=0; + maxDist=d; + maxX=x; + } + x=l1-a; + d=x *x; + if (d < minDist){ + minAngle=Math.PI; + minDist=d; + minX=x; + }; + var angle=Math.acos(-a *l1 / (aa-bb)); + x=a *Math.cos(angle)+l1; + y=b *Math.sin(angle); + d=x *x+y *y; + if (d < minDist){ + minAngle=angle; + minDist=d; + minX=x; + minY=y; + } + if (d > maxDist){ + maxAngle=angle; + maxDist=d; + maxX=x; + maxY=y; + } + if (dd <=(minDist+maxDist)/ 2){ + a1=ta-Math.atan2(minY *bendDir,minX); + a2=minAngle *bendDir; + }else { + a1=ta-Math.atan2(maxY *bendDir,maxX); + a2=maxAngle *bendDir; + } + }; + var os=Math.atan2(cy,cx)*s2; + var rotation=parent.resultTransform.skX; + a1=(a1-os)*IkConstraint.radDeg+os1-rotation; + if (a1 > 180) + a1-=360; + else if (a1 <-180)a1+=360; + parent.resultTransform.x=px; + parent.resultTransform.y=py; + parent.resultTransform.skX=parent.resultTransform.skY=rotation+a1 *alpha; + rotation=child.resultTransform.skX; + rotation=rotation % 360; + a2=((a2+os)*IkConstraint.radDeg-0)*s2+os2-rotation; + if (a2 > 180) + a2-=360; + else if (a2 <-180)a2+=360; + child.resultTransform.x=cx; + child.resultTransform.y=cy; + child.resultTransform.skX=child.resultTransform.skY=child.resultTransform.skY+a2 *alpha; + parent.update(); + } + + __static(IkConstraint, + ['radDeg',function(){return this.radDeg=180 / Math.PI;},'degRad',function(){return this.degRad=Math.PI / 180;} + ]); + return IkConstraint; + })() + + + /** + *@private + */ + //class laya.ani.bone.IkConstraintData + var IkConstraintData=(function(){ + function IkConstraintData(){ + this.name=null; + this.targetBoneName=null; + this.bendDirection=1; + this.mix=1; + this.targetBoneIndex=-1; + this.boneNames=[]; + this.boneIndexs=[]; + } + + __class(IkConstraintData,'laya.ani.bone.IkConstraintData'); + return IkConstraintData; + })() + + + /** + *@private + *路径作用器 + *1,生成根据骨骼计算控制点 + *2,根据控制点生成路径,并计算路径上的节点 + *3,根据节点,重新调整骨骼位置 + */ + //class laya.ani.bone.PathConstraint + var PathConstraint=(function(){ + function PathConstraint(data,bones){ + this.target=null; + this.data=null; + this.bones=null; + this.position=NaN; + this.spacing=NaN; + this.rotateMix=NaN; + this.translateMix=NaN; + this._debugKey=false; + this._spaces=null; + this._segments=[]; + this._curves=[]; + this.data=data; + this.position=data.position; + this.spacing=data.spacing; + this.rotateMix=data.rotateMix; + this.translateMix=data.translateMix; + this.bones=[]; + var tBoneIds=this.data.bones; + for (var i=0,n=tBoneIds.length;i < n;i++){ + this.bones.push(bones[tBoneIds[i]]); + } + } + + __class(PathConstraint,'laya.ani.bone.PathConstraint'); + var __proto=PathConstraint.prototype; + /** + *计算骨骼在路径上的节点 + *@param boneSlot + *@param boneMatrixArray + *@param graphics + */ + __proto.apply=function(boneList,graphics){ + var tTranslateMix=this.translateMix; + var tRotateMix=this.translateMix; + var tTranslate=tTranslateMix > 0; + var tRotate=tRotateMix > 0; + var tSpacingMode=this.data.spacingMode; + var tLengthSpacing=tSpacingMode=="length"; + var tRotateMode=this.data.rotateMode; + var tTangents=tRotateMode=="tangent"; + var tScale=tRotateMode=="chainScale"; + var lengths=[]; + var boneCount=this.bones.length; + var spacesCount=tTangents ? boneCount :boneCount+1; + var spaces=[]; + this._spaces=spaces; + spaces[0]=this.position; + var spacing=this.spacing; + if (tScale || tLengthSpacing){ + for (var i=0,n=spacesCount-1;i < n;){ + var bone=this.bones[i]; + var length=bone.length; + var x=length *bone.transform.getMatrix().a; + var y=length *bone.transform.getMatrix().c; + length=Math.sqrt(x *x+y *y); + if (tScale)lengths[i]=length; + spaces[++i]=tLengthSpacing ? Math.max(0,length+spacing):spacing; + } + }else { + for (i=1;i < spacesCount;i++){ + spaces[i]=spacing; + } + }; + var positions=this.computeWorldPositions(this.target,boneList,graphics,spacesCount,tTangents,this.data.positionMode=="percent",tSpacingMode=="percent"); + if (this._debugKey){ + for (i=0;i < positions.length;i++){ + graphics.drawCircle(positions[i++],positions[i++],5,"#00ff00"); + }; + var tLinePos=[]; + for (i=0;i < positions.length;i++){ + tLinePos.push(positions[i++],positions[i++]); + } + graphics.drawLines(0,0,tLinePos,"#ff0000"); + }; + var skeletonX=NaN; + var skeletonY=NaN; + var boneX=positions[0]; + var boneY=positions[1]; + var offsetRotation=this.data.offsetRotation; + var tip=tRotateMode=="chain" && offsetRotation==0; + var p=NaN; + for (i=0,p=3;i < boneCount;i++,p+=3){ + bone=this.bones[i]; + bone.resultMatrix.tx+=(boneX-bone.resultMatrix.tx)*tTranslateMix; + bone.resultMatrix.ty+=(boneY-bone.resultMatrix.ty)*tTranslateMix; + x=positions[p]; + y=positions[p+1]; + var dx=x-boneX,dy=y-boneY; + if (tScale){ + length=lengths[i]; + if (length !=0){ + var s=(Math.sqrt(dx *dx+dy *dy)/ length-1)*tRotateMix+1; + bone.resultMatrix.a *=s; + bone.resultMatrix.c *=s; + } + } + boneX=x; + boneY=y; + if (tRotate){ + var a=bone.resultMatrix.a; + var b=bone.resultMatrix.b; + var c=bone.resultMatrix.c; + var d=bone.resultMatrix.d; + var r=NaN; + var cos=NaN; + var sin=NaN; + if (tTangents){ + r=positions[p-1]; + }else if (spaces[i+1]==0){ + r=positions[p+2]; + }else { + r=Math.atan2(dy,dx); + } + r-=Math.atan2(c,a)-offsetRotation / 180 *Math.PI; + if (tip){ + cos=Math.cos(r); + sin=Math.sin(r); + length=bone.length; + boneX+=(length *(cos *a-sin *c)-dx)*tRotateMix; + boneY+=(length *(sin *a+cos *c)-dy)*tRotateMix; + } + if (r > Math.PI){ + r-=(Math.PI *2); + }else if (r <-Math.PI){ + r+=(Math.PI *2); + } + r *=tRotateMix; + cos=Math.cos(r); + sin=Math.sin(r); + bone.resultMatrix.a=cos *a-sin *c; + bone.resultMatrix.c=cos *b-sin *d; + bone.resultMatrix.b=sin *a+cos *c; + bone.resultMatrix.d=sin *b+cos *d; + } + } + } + + /** + *计算顶点的世界坐标 + *@param boneSlot + *@param boneList + *@param start + *@param count + *@param worldVertices + *@param offset + */ + __proto.computeWorldVertices2=function(boneSlot,boneList,start,count,worldVertices,offset){ + var tBones=boneSlot.currDisplayData.bones; + var tWeights=boneSlot.currDisplayData.weights; + var tTriangles=boneSlot.currDisplayData.triangles; + var tMatrix; + var i=0; + var v=0; + var skip=0; + var n=0; + var w=0; + var b=0; + var wx=0; + var wy=0; + var vx=0; + var vy=0; + for (i=0;i < start;i+=2){ + n=tBones[v]; + v+=n+1; + skip+=n; + }; + var skeletonBones=boneList; + for (w=offset,b=skip *3;w < count;w+=2){ + wx=0,wy=0; + n=tBones[v++]; + n+=v; + for (;v < n;v++,b+=3){ + tMatrix=skeletonBones[tBones[v]].resultMatrix; + vx=tWeights[b]; + vy=tWeights[b+1]; + var weight=tWeights[b+2]; + wx+=(vx *tMatrix.a+vy *tMatrix.c+tMatrix.tx)*weight; + wy+=(vx *tMatrix.b+vy *tMatrix.d+tMatrix.ty)*weight; + } + worldVertices[w]=wx; + worldVertices[w+1]=wy; + } + } + + /** + *计算路径上的节点 + *@param boneSlot + *@param boneList + *@param graphics + *@param spacesCount + *@param tangents + *@param percentPosition + *@param percentSpacing + *@return + */ + __proto.computeWorldPositions=function(boneSlot,boneList,graphics,spacesCount,tangents,percentPosition,percentSpacing){ + var tBones=boneSlot.currDisplayData.bones; + var tWeights=boneSlot.currDisplayData.weights; + var tTriangles=boneSlot.currDisplayData.triangles; + var tRx=0; + var tRy=0; + var nn=0; + var tMatrix; + var tX=NaN; + var tY=NaN; + var tB=0; + var tWeight=0; + var tVertices=[]; + var i=0,j=0,n=0; + var verticesLength=boneSlot.currDisplayData.verLen; + var target=boneSlot; + var position=this.position; + var spaces=this._spaces; + var world=[]; + var out=[]; + var closed=false; + var curveCount=verticesLength / 6; + var prevCurve=-1; + var pathLength=NaN; + var o=0,curve=0; + var p=NaN; + var space=NaN; + var prev=NaN; + var length=NaN; + if (!true){ + var lengths=boneSlot.currDisplayData.lengths; + curveCount-=closed ? 1 :2; + pathLength=lengths[curveCount]; + if (percentPosition)position *=pathLength; + if (percentSpacing){ + for (i=0;i < spacesCount;i++) + spaces[i] *=pathLength; + } + world.length=8; + for (i=0,o=0,curve=0;i < spacesCount;i++,o+=3){ + space=spaces[i]; + position+=space; + p=position; + if (closed){ + p %=pathLength; + if (p < 0)p+=pathLength; + curve=0; + }else if (p < 0){ + if (prevCurve !=PathConstraint.BEFORE){ + prevCurve=PathConstraint.BEFORE; + this.computeWorldVertices2(target,boneList,2,4,world,0); + } + this.addBeforePosition(p,world,0,out,o); + continue ; + }else if (p > pathLength){ + if (prevCurve !=PathConstraint.AFTER){ + prevCurve=PathConstraint.AFTER; + this.computeWorldVertices2(target,boneList,verticesLength-6,4,world,0); + } + this.addAfterPosition(p-pathLength,world,0,out,o); + continue ; + } + for (;;curve++){ + length=lengths[curve]; + if (p > length)continue ; + if (curve==0) + p /=length; + else { + prev=lengths[curve-1]; + p=(p-prev)/ (length-prev); + } + break ; + } + if (curve !=prevCurve){ + prevCurve=curve; + if (closed && curve==curveCount){ + this.computeWorldVertices2(target,boneList,verticesLength-4,4,world,0); + this.computeWorldVertices2(target,boneList,0,4,world,4); + }else + this.computeWorldVertices2(target,boneList,curve *6+2,8,world,0); + } + this.addCurvePosition(p,world[0],world[1],world[2],world[3],world[4],world[5],world[6],world[7],out,o,tangents || (i > 0 && space==0)); + } + return out; + } + if (closed){ + verticesLength+=2; + world[verticesLength-2]=world[0]; + world[verticesLength-1]=world[1]; + }else { + curveCount--; + verticesLength-=4; + this.computeWorldVertices2(boneSlot,boneList,2,verticesLength,tVertices,0); + if (this._debugKey){ + for (i=0;i < tVertices.length;){ + graphics.drawCircle(tVertices[i++],tVertices[i++],10,"#ff0000"); + } + } + world=tVertices; + } + this._curves.length=curveCount; + var curves=this._curves; + pathLength=0; + var x1=world[0],y1=world[1],cx1=0,cy1=0,cx2=0,cy2=0,x2=0,y2=0; + var tmpx=NaN,tmpy=NaN,dddfx=NaN,dddfy=NaN,ddfx=NaN,ddfy=NaN,dfx=NaN,dfy=NaN; + var w=0; + for (i=0,w=2;i < curveCount;i++,w+=6){ + cx1=world[w]; + cy1=world[w+1]; + cx2=world[w+2]; + cy2=world[w+3]; + x2=world[w+4]; + y2=world[w+5]; + tmpx=(x1-cx1 *2+cx2)*0.1875; + tmpy=(y1-cy1 *2+cy2)*0.1875; + dddfx=((cx1-cx2)*3-x1+x2)*0.09375; + dddfy=((cy1-cy2)*3-y1+y2)*0.09375; + ddfx=tmpx *2+dddfx; + ddfy=tmpy *2+dddfy; + dfx=(cx1-x1)*0.75+tmpx+dddfx *0.16666667; + dfy=(cy1-y1)*0.75+tmpy+dddfy *0.16666667; + pathLength+=Math.sqrt(dfx *dfx+dfy *dfy); + dfx+=ddfx; + dfy+=ddfy; + ddfx+=dddfx; + ddfy+=dddfy; + pathLength+=Math.sqrt(dfx *dfx+dfy *dfy); + dfx+=ddfx; + dfy+=ddfy; + pathLength+=Math.sqrt(dfx *dfx+dfy *dfy); + dfx+=ddfx+dddfx; + dfy+=ddfy+dddfy; + pathLength+=Math.sqrt(dfx *dfx+dfy *dfy); + curves[i]=pathLength; + x1=x2; + y1=y2; + } + if (percentPosition)position *=pathLength; + if (percentSpacing){ + for (i=0;i < spacesCount;i++) + spaces[i] *=pathLength; + }; + var segments=this._segments; + var curveLength=0; + var segment=0; + for (i=0,o=0,curve=0,segment=0;i < spacesCount;i++,o+=3){ + space=spaces[i]; + position+=space; + p=position; + if (closed){ + p %=pathLength; + if (p < 0)p+=pathLength; + curve=0; + }else if (p < 0){ + this.addBeforePosition(p,world,0,out,o); + continue ; + }else if (p > pathLength){ + this.addAfterPosition(p-pathLength,world,verticesLength-4,out,o); + continue ; + } + for (;;curve++){ + length=curves[curve]; + if (p > length)continue ; + if (curve==0) + p /=length; + else { + prev=curves[curve-1]; + p=(p-prev)/ (length-prev); + } + break ; + } + if (curve !=prevCurve){ + prevCurve=curve; + var ii=curve *6; + x1=world[ii]; + y1=world[ii+1]; + cx1=world[ii+2]; + cy1=world[ii+3]; + cx2=world[ii+4]; + cy2=world[ii+5]; + x2=world[ii+6]; + y2=world[ii+7]; + tmpx=(x1-cx1 *2+cx2)*0.03; + tmpy=(y1-cy1 *2+cy2)*0.03; + dddfx=((cx1-cx2)*3-x1+x2)*0.006; + dddfy=((cy1-cy2)*3-y1+y2)*0.006; + ddfx=tmpx *2+dddfx; + ddfy=tmpy *2+dddfy; + dfx=(cx1-x1)*0.3+tmpx+dddfx *0.16666667; + dfy=(cy1-y1)*0.3+tmpy+dddfy *0.16666667; + curveLength=Math.sqrt(dfx *dfx+dfy *dfy); + segments[0]=curveLength; + for (ii=1;ii < 8;ii++){ + dfx+=ddfx; + dfy+=ddfy; + ddfx+=dddfx; + ddfy+=dddfy; + curveLength+=Math.sqrt(dfx *dfx+dfy *dfy); + segments[ii]=curveLength; + } + dfx+=ddfx; + dfy+=ddfy; + curveLength+=Math.sqrt(dfx *dfx+dfy *dfy); + segments[8]=curveLength; + dfx+=ddfx+dddfx; + dfy+=ddfy+dddfy; + curveLength+=Math.sqrt(dfx *dfx+dfy *dfy); + segments[9]=curveLength; + segment=0; + } + p *=curveLength; + for (;;segment++){ + length=segments[segment]; + if (p > length)continue ; + if (segment==0) + p /=length; + else { + prev=segments[segment-1]; + p=segment+(p-prev)/ (length-prev); + } + break ; + } + this.addCurvePosition(p *0.1,x1,y1,cx1,cy1,cx2,cy2,x2,y2,out,o,tangents || (i > 0 && space==0)); + } + return out; + } + + __proto.addBeforePosition=function(p,temp,i,out,o){ + var x1=temp[i],y1=temp[i+1],dx=temp[i+2]-x1,dy=temp[i+3]-y1,r=Math.atan2(dy,dx); + out[o]=x1+p *Math.cos(r); + out[o+1]=y1+p *Math.sin(r); + out[o+2]=r; + } + + __proto.addAfterPosition=function(p,temp,i,out,o){ + var x1=temp[i+2],y1=temp[i+3],dx=x1-temp[i],dy=y1-temp[i+1],r=Math.atan2(dy,dx); + out[o]=x1+p *Math.cos(r); + out[o+1]=y1+p *Math.sin(r); + out[o+2]=r; + } + + __proto.addCurvePosition=function(p,x1,y1,cx1,cy1,cx2,cy2,x2,y2,out,o,tangents){ + if (p==0)p=0.0001; + var tt=p *p,ttt=tt *p,u=1-p,uu=u *u,uuu=uu *u; + var ut=u *p,ut3=ut *3,uut3=u *ut3,utt3=ut3 *p; + var x=x1 *uuu+cx1 *uut3+cx2 *utt3+x2 *ttt,y=y1 *uuu+cy1 *uut3+cy2 *utt3+y2 *ttt; + out[o]=x; + out[o+1]=y; + if (tangents){ + out[o+2]=Math.atan2(y-(y1 *uu+cy1 *ut *2+cy2 *tt),x-(x1 *uu+cx1 *ut *2+cx2 *tt)); + }else { + out[o+2]=0; + } + } + + PathConstraint.NONE=-1; + PathConstraint.BEFORE=-2; + PathConstraint.AFTER=-3; + return PathConstraint; + })() + + + /** + *@private + */ + //class laya.ani.bone.PathConstraintData + var PathConstraintData=(function(){ + function PathConstraintData(){ + this.name=null; + this.target=null; + this.positionMode=null; + this.spacingMode=null; + this.rotateMode=null; + this.offsetRotation=NaN; + this.position=NaN; + this.spacing=NaN; + this.rotateMix=NaN; + this.translateMix=NaN; + this.bones=[]; + } + + __class(PathConstraintData,'laya.ani.bone.PathConstraintData'); + return PathConstraintData; + })() + + + /** + *@private + */ + //class laya.ani.bone.SkinData + var SkinData=(function(){ + function SkinData(){ + this.name=null; + this.slotArr=[]; + } + + __class(SkinData,'laya.ani.bone.SkinData'); + return SkinData; + })() + + + /** + *@private + */ + //class laya.ani.bone.SkinSlotDisplayData + var SkinSlotDisplayData=(function(){ + function SkinSlotDisplayData(){ + this.name=null; + this.attachmentName=null; + this.type=0; + this.transform=null; + this.width=NaN; + this.height=NaN; + this.texture=null; + this.bones=null; + this.uvs=null; + this.weights=null; + this.triangles=null; + this.vertices=null; + this.lengths=null; + this.verLen=0; + } + + __class(SkinSlotDisplayData,'laya.ani.bone.SkinSlotDisplayData'); + var __proto=SkinSlotDisplayData.prototype; + __proto.createTexture=function(currTexture){ + if (this.texture)return this.texture; + this.texture=new Texture(currTexture.bitmap,this.uvs); + if (this.uvs[0] > this.uvs[4] + && this.uvs[1] > this.uvs[5]){ + this.texture.width=currTexture.height; + this.texture.height=currTexture.width; + this.texture.offsetX=-currTexture.offsetX; + this.texture.offsetY=-currTexture.offsetY; + this.texture.sourceWidth=currTexture.sourceHeight; + this.texture.sourceHeight=currTexture.sourceWidth; + }else { + this.texture.width=currTexture.width; + this.texture.height=currTexture.height; + this.texture.offsetX=-currTexture.offsetX; + this.texture.offsetY=-currTexture.offsetY; + this.texture.sourceWidth=currTexture.sourceWidth; + this.texture.sourceHeight=currTexture.sourceHeight; + } + return this.texture; + } + + __proto.destory=function(){ + if (this.texture)this.texture.destroy(); + } + + return SkinSlotDisplayData; + })() + + + /** + *@private + */ + //class laya.ani.bone.SlotData + var SlotData=(function(){ + function SlotData(){ + this.name=null; + this.displayArr=[]; + } + + __class(SlotData,'laya.ani.bone.SlotData'); + var __proto=SlotData.prototype; + __proto.getDisplayByName=function(name){ + var tDisplay; + for (var i=0,n=this.displayArr.length;i < n;i++){ + tDisplay=this.displayArr[i]; + if (tDisplay.attachmentName==name){ + return i; + } + } + return-1; + } + + return SlotData; + })() + + + /** + *@private + */ + //class laya.ani.bone.TfConstraint + var TfConstraint=(function(){ + function TfConstraint(data,bones){ + this._data=null; + this._bones=null; + this.target=null; + this.rotateMix=NaN; + this.translateMix=NaN; + this.scaleMix=NaN; + this.shearMix=NaN; + this._temp=__newvec(2,0); + this._data=data; + if (this._bones==null){ + this._bones=[]; + } + this.target=bones[data.targetIndex]; + var j=0,n=0; + for (j=0,n=data.boneIndexs.length;j < n;j++){ + this._bones.push(bones[data.boneIndexs[j]]); + } + this.rotateMix=data.rotateMix; + this.translateMix=data.translateMix; + this.scaleMix=data.scaleMix; + this.shearMix=data.shearMix; + } + + __class(TfConstraint,'laya.ani.bone.TfConstraint'); + var __proto=TfConstraint.prototype; + __proto.apply=function(){ + var tTfBone; + var ta=this.target.resultMatrix.a,tb=this.target.resultMatrix.b,tc=this.target.resultMatrix.c,td=this.target.resultMatrix.d; + for (var j=0,n=this._bones.length;j < n;j++){ + tTfBone=this._bones[j]; + if (this.rotateMix > 0){ + var a=tTfBone.resultMatrix.a,b=tTfBone.resultMatrix.b,c=tTfBone.resultMatrix.c,d=tTfBone.resultMatrix.d; + var r=Math.atan2(tc,ta)-Math.atan2(c,a)+this._data.offsetRotation *Math.PI / 180; + if (r > Math.PI) + r-=Math.PI *2; + else if (r <-Math.PI)r+=Math.PI *2; + r *=this.rotateMix; + var cos=Math.cos(r),sin=Math.sin(r); + tTfBone.resultMatrix.a=cos *a-sin *c; + tTfBone.resultMatrix.b=cos *b-sin *d; + tTfBone.resultMatrix.c=sin *a+cos *c; + tTfBone.resultMatrix.d=sin *b+cos *d; + } + if (this.translateMix){ + this._temp[0]=this._data.offsetX; + this._temp[1]=this._data.offsetY; + this.target.localToWorld(this._temp); + tTfBone.resultMatrix.tx+=(this._temp[0]-tTfBone.resultMatrix.tx)*this.translateMix; + tTfBone.resultMatrix.ty+=(this._temp[1]-tTfBone.resultMatrix.ty)*this.translateMix; + tTfBone.updateChild(); + } + if (this.scaleMix > 0){ + var bs=Math.sqrt(tTfBone.resultMatrix.a *tTfBone.resultMatrix.a+tTfBone.resultMatrix.c *tTfBone.resultMatrix.c); + var ts=Math.sqrt(ta *ta+tc *tc); + var s=bs > 0.00001 ? (bs+(ts-bs+this._data.offsetScaleX)*this.scaleMix)/ bs :0; + tTfBone.resultMatrix.a *=s; + tTfBone.resultMatrix.c *=s; + bs=Math.sqrt(tTfBone.resultMatrix.b *tTfBone.resultMatrix.b+tTfBone.resultMatrix.d *tTfBone.resultMatrix.d); + ts=Math.sqrt(tb *tb+td *td); + s=bs > 0.00001 ? (bs+(ts-bs+this._data.offsetScaleY)*this.scaleMix)/ bs :0; + tTfBone.resultMatrix.b *=s; + tTfBone.resultMatrix.d *=s; + } + if (this.shearMix > 0){ + b=tTfBone.resultMatrix.b,d=tTfBone.resultMatrix.d; + var by=Math.atan2(d,b); + r=Math.atan2(td,tb)-Math.atan2(tc,ta)-(by-Math.atan2(tTfBone.resultMatrix.c,tTfBone.resultMatrix.a)); + if (r > Math.PI) + r-=Math.PI *2; + else if (r <-Math.PI)r+=Math.PI *2; + r=by+(r+this._data.offsetShearY *Math.PI / 180)*this.shearMix; + s=Math.sqrt(b *b+d *d); + tTfBone.resultMatrix.b=Math.cos(r)*s; + tTfBone.resultMatrix.d=Math.sin(r)*s; + } + } + } + + return TfConstraint; + })() + + + /** + *@private + */ + //class laya.ani.bone.TfConstraintData + var TfConstraintData=(function(){ + function TfConstraintData(){ + this.name=null; + this.targetIndex=0; + this.rotateMix=NaN; + this.translateMix=NaN; + this.scaleMix=NaN; + this.shearMix=NaN; + this.offsetRotation=NaN; + this.offsetX=NaN; + this.offsetY=NaN; + this.offsetScaleX=NaN; + this.offsetScaleY=NaN; + this.offsetShearY=NaN; + this.boneIndexs=[]; + } + + __class(TfConstraintData,'laya.ani.bone.TfConstraintData'); + return TfConstraintData; + })() + + + /** + *@private + */ + //class laya.ani.bone.Transform + var Transform=(function(){ + function Transform(){ + this.skX=0; + this.skY=0; + this.scX=1; + this.scY=1; + this.x=0; + this.y=0; + this.mMatrix=null; + } + + __class(Transform,'laya.ani.bone.Transform'); + var __proto=Transform.prototype; + __proto.initData=function(data){ + if (data.x !=undefined){ + this.x=data.x; + } + if (data.y !=undefined){ + this.y=data.y; + } + if (data.skX !=undefined){ + this.skX=data.skX; + } + if (data.skY !=undefined){ + this.skY=data.skY; + } + if (data.scX !=undefined){ + this.scX=data.scX; + } + if (data.scY !=undefined){ + this.scY=data.scY; + } + } + + __proto.getMatrix=function(){ + var tMatrix; + if (this.mMatrix){ + tMatrix=this.mMatrix; + }else { + tMatrix=this.mMatrix=new Matrix(); + } + tMatrix.a=Math.cos(this.skY); + if (this.skX !=0 || this.skY !=0){ + var tAngle=this.skX *Math.PI / 180; + var cos=Math.cos(tAngle),sin=Math.sin(tAngle); + tMatrix.setTo(this.scX *cos,this.scX *sin,this.scY *-sin,this.scY *cos,this.x,this.y); + }else { + tMatrix.setTo(this.scX,this.skX,this.skY,this.scY,this.x,this.y); + } + return tMatrix; + } + + return Transform; + })() + + + /** + *AnimationPlayer 类用于动画播放器。 + */ + //class laya.ani.AnimationPlayer extends laya.events.EventDispatcher + var AnimationPlayer=(function(_super){ + function AnimationPlayer(){ + this._templet=null; + this._currentTime=NaN; + this._currentFrameTime=NaN; + this._playStart=NaN; + this._playEnd=NaN; + this._playDuration=NaN; + this._overallDuration=NaN; + this._stopWhenCircleFinish=false; + this._elapsedPlaybackTime=NaN; + this._startUpdateLoopCount=NaN; + this._currentAnimationClipIndex=0; + this._currentKeyframeIndex=0; + this._paused=false; + this._cacheFrameRate=0; + this._cacheFrameRateInterval=NaN; + this._cachePlayRate=NaN; + this._fullFrames=null; + this.isCache=true; + this.playbackRate=1.0; + this.returnToZeroStopped=true; + AnimationPlayer.__super.call(this); + this._currentAnimationClipIndex=-1; + this._currentKeyframeIndex=-1; + this._currentTime=0.0; + this._overallDuration=Number.MAX_VALUE; + this._stopWhenCircleFinish=false; + this._elapsedPlaybackTime=0; + this._startUpdateLoopCount=-1; + this._cachePlayRate=1.0; + this.cacheFrameRate=60; + } + + __class(AnimationPlayer,'laya.ani.AnimationPlayer',_super); + var __proto=AnimationPlayer.prototype; + /** + *@private + */ + __proto._onTempletLoadedComputeFullKeyframeIndices=function(cachePlayRate,cacheFrameRate,templet){ + if (this._templet===templet && this._cachePlayRate===cachePlayRate && this._cacheFrameRate===cacheFrameRate) + this._computeFullKeyframeIndices(); + } + + /** + *@private + */ + __proto._computeFullKeyframeIndices=function(){ + var anifullFrames=this._fullFrames=[]; + var templet=this._templet; + var cacheFrameInterval=this._cacheFrameRateInterval*this._cachePlayRate; + for (var i=0,iNum=templet.getAnimationCount();i < iNum;i++){ + var aniFullFrame=[]; + for (var j=0,jNum=templet.getAnimation(i).nodes.length;j < jNum;j++){ + var node=templet.getAnimation(i).nodes[j]; + var frameCount=Math.floor(node.playTime / cacheFrameInterval); + var nodeFullFrames=new Uint16Array(frameCount+1); + var lastFrameIndex=-1; + for (var n=0,nNum=node.keyFrame.length;n < nNum;n++){ + var keyFrame=node.keyFrame[n]; + var tm=keyFrame.startTime; + var endTm=tm+keyFrame.duration+cacheFrameInterval; + do { + var frameIndex=Math.floor(tm / cacheFrameInterval+0.5); + for (var k=lastFrameIndex+1;k < frameIndex;k++) + nodeFullFrames[k]=n; + lastFrameIndex=frameIndex; + nodeFullFrames[frameIndex]=n; + tm+=cacheFrameInterval; + }while (tm <=endTm); + } + aniFullFrame.push(nodeFullFrames); + } + anifullFrames.push(aniFullFrame); + } + this.event(Event.CACHEFRAMEINDEX_CHANGED,this); + } + + /** + *@private + */ + __proto._calculatePlayDuration=function(){ + if (this.state!==/*laya.ani.AnimationState.stopped*/0){ + var oriDuration=this._templet.getAniDuration(this._currentAnimationClipIndex); + (this._playEnd===0)&& (this._playEnd=oriDuration); + if (Math.floor(this._playEnd)> oriDuration) + this._playEnd=oriDuration; + this._playDuration=this._playEnd-this._playStart; + } + } + + /** + *播放动画。 + *@param index 动画索引。 + *@param playbackRate 播放速率。 + *@param duration 播放时长(0为1次,Number.MAX_VALUE为循环播放)。 + *@param playStart 播放的起始时间位置。 + *@param playEnd 播放的结束时间位置。(0为动画一次循环的最长结束时间位置)。 + */ + __proto.play=function(index,playbackRate,overallDuration,playStart,playEnd){ + (index===void 0)&& (index=0); + (playbackRate===void 0)&& (playbackRate=1.0); + (overallDuration===void 0)&& (overallDuration=2147483647); + (playStart===void 0)&& (playStart=0); + (playEnd===void 0)&& (playEnd=0); + if (!this._templet) + throw new Error("AnimationPlayer:templet must not be null,maybe you need to set url."); + if (overallDuration < 0 || playStart < 0 || playEnd < 0) + throw new Error("AnimationPlayer:overallDuration,playStart and playEnd must large than zero."); + if ((playEnd!==0)&& (playStart > playEnd)) + throw new Error("AnimationPlayer:start must less than end."); + this._currentTime=0; + this._currentFrameTime=0; + this._elapsedPlaybackTime=0; + this.playbackRate=playbackRate; + this._overallDuration=overallDuration; + this._playStart=playStart; + this._playEnd=playEnd; + this._paused=false; + this._currentAnimationClipIndex=index; + this._currentKeyframeIndex=0; + this._startUpdateLoopCount=Stat.loopCount; + this.event(/*laya.events.Event.PLAYED*/"played"); + if (this._templet.loaded) + this._calculatePlayDuration(); + else + this._templet.once(/*laya.events.Event.LOADED*/"loaded",this,this._calculatePlayDuration); + this.update(0); + } + + /** + *播放动画。 + *@param index 动画索引。 + *@param playbackRate 播放速率。 + *@param duration 播放时长(0为1次,Number.MAX_VALUE为循环播放)。 + *@param playStartFrame 播放的原始起始帧率位置。 + *@param playEndFrame 播放的原始结束帧率位置。(0为动画一次循环的最长结束时间位置)。 + */ + __proto.playByFrame=function(index,playbackRate,overallDuration,playStartFrame,playEndFrame,fpsIn3DBuilder){ + (index===void 0)&& (index=0); + (playbackRate===void 0)&& (playbackRate=1.0); + (overallDuration===void 0)&& (overallDuration=9007199254740991); + (playStartFrame===void 0)&& (playStartFrame=0); + (playEndFrame===void 0)&& (playEndFrame=0); + (fpsIn3DBuilder===void 0)&& (fpsIn3DBuilder=30); + var interval=1000.0 / fpsIn3DBuilder; + this.play(index,playbackRate,overallDuration,playStartFrame *interval,playEndFrame *interval); + } + + /** + *停止播放当前动画 + *@param immediate 是否立即停止 + */ + __proto.stop=function(immediate){ + (immediate===void 0)&& (immediate=true); + if (immediate){ + this._currentAnimationClipIndex=this._currentKeyframeIndex=-1; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + }else { + this._stopWhenCircleFinish=true; + } + } + + /**更新动画播放器 */ + __proto.update=function(elapsedTime){ + if (this._currentAnimationClipIndex===-1 || this._paused || !this._templet || !this._templet.loaded) + return; + var cacheFrameInterval=this._cacheFrameRateInterval *this._cachePlayRate; + var time=0; + (this._startUpdateLoopCount!==Stat.loopCount)&& (time=elapsedTime *this.playbackRate,this._elapsedPlaybackTime+=time); + var currentAniClipPlayDuration=this.playDuration; + if ((this._overallDuration!==0 && this._elapsedPlaybackTime >=this._overallDuration)|| (this._overallDuration===0 && this._elapsedPlaybackTime >=currentAniClipPlayDuration)){ + this._currentAnimationClipIndex=this._currentKeyframeIndex=-1; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + return; + } + time+=this._currentTime; + if (currentAniClipPlayDuration > 0){ + while (time >=currentAniClipPlayDuration){ + if (this._stopWhenCircleFinish){ + this._currentAnimationClipIndex=this._currentKeyframeIndex=-1; + this._stopWhenCircleFinish=false; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + return; + } + time-=currentAniClipPlayDuration; + this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + this._currentTime=time; + this._currentKeyframeIndex=Math.floor((this.currentPlayTime)/ cacheFrameInterval); + this._currentFrameTime=this._currentKeyframeIndex *cacheFrameInterval; + }else { + if (this._stopWhenCircleFinish){ + this._currentAnimationClipIndex=this._currentKeyframeIndex=-1; + this._stopWhenCircleFinish=false; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + return; + } + this._currentTime=this._currentFrameTime=this._currentKeyframeIndex=0; + this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + } + + /** + *动画播放的结束时间位置。 + *@return 结束时间位置。 + */ + __getset(0,__proto,'playEnd',function(){ + return this._playEnd; + }); + + /** + *设置动画数据模板,注意:修改此值会有计算开销。 + *@param value 动画数据模板 + */ + /** + *获取动画数据模板 + *@param value 动画数据模板 + */ + __getset(0,__proto,'templet',function(){ + return this._templet; + },function(value){ + if (!this.state===/*laya.ani.AnimationState.stopped*/0) + this.stop(true); + if (this._templet!==value){ + this._templet=value; + if (value.loaded) + this._computeFullKeyframeIndices(); + else + value.once(/*laya.events.Event.LOADED*/"loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[this._cachePlayRate,this._cacheFrameRate]); + } + }); + + /** + *动画播放的起始时间位置。 + *@return 起始时间位置。 + */ + __getset(0,__proto,'playStart',function(){ + return this._playStart; + }); + + /** + *获取动画播放一次的总时间 + *@return 动画播放一次的总时间 + */ + __getset(0,__proto,'playDuration',function(){ + return this._playDuration; + }); + + /** + *获取当前播放状态 + *@return 当前播放状态 + */ + __getset(0,__proto,'state',function(){ + if (this._currentAnimationClipIndex===-1) + return /*laya.ani.AnimationState.stopped*/0; + if (this._paused) + return /*laya.ani.AnimationState.paused*/1; + return /*laya.ani.AnimationState.playing*/2; + }); + + /** + *获取当前帧数 + *@return 当前帧数 + */ + __getset(0,__proto,'currentKeyframeIndex',function(){ + return this._currentKeyframeIndex; + }); + + /** + *获取动画播放的总总时间 + *@return 动画播放的总时间 + */ + __getset(0,__proto,'overallDuration',function(){ + return this._overallDuration; + }); + + /** + *获取当前帧时间,不包括重播时间 + *@return value 当前时间 + */ + __getset(0,__proto,'currentFrameTime',function(){ + return this._currentFrameTime; + }); + + /** + *获取当前动画索引 + *@return value 当前动画索引 + */ + __getset(0,__proto,'currentAnimationClipIndex',function(){ + return this._currentAnimationClipIndex; + }); + + /** + *获取当前精确时间,不包括重播时间 + *@return value 当前时间 + */ + __getset(0,__proto,'currentPlayTime',function(){ + return this._currentTime+this._playStart; + }); + + /** + *设置缓存播放速率,默认值为1.0,注意:修改此值会有计算开销。* + *@return value 缓存播放速率。 + */ + /** + *获取缓存播放速率。* + *@return 缓存播放速率。 + */ + __getset(0,__proto,'cachePlayRate',function(){ + return this._cachePlayRate; + },function(value){ + if (this._cachePlayRate!==value){ + this._cachePlayRate=value; + if (this._templet) + if (this._templet.loaded) + this._computeFullKeyframeIndices(); + else + this._templet.once(/*laya.events.Event.LOADED*/"loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[value,this._cacheFrameRate]); + } + }); + + /** + *设置默认帧率,每秒60帧,注意:修改此值会有计算开销。* + *@return value 缓存帧率 + */ + /** + *获取默认帧率* + *@return value 默认帧率 + */ + __getset(0,__proto,'cacheFrameRate',function(){ + return this._cacheFrameRate; + },function(value){ + if (this._cacheFrameRate!==value){ + this._cacheFrameRate=value; + this._cacheFrameRateInterval=1000.0 / this._cacheFrameRate; + if (this._templet) + if (this._templet.loaded) + this._computeFullKeyframeIndices(); + else + this._templet.once(/*laya.events.Event.LOADED*/"loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[this._cachePlayRate,value]); + } + }); + + /** + *设置当前播放位置 + *@param value 当前时间 + */ + __getset(0,__proto,'currentTime',null,function(value){ + if (this._currentAnimationClipIndex===-1 || !this._templet || !this._templet.loaded) + return; + if (value < this._playStart || value > this._playEnd) + throw new Error("AnimationPlayer:value must large than playStartTime,small than playEndTime."); + this._startUpdateLoopCount=Stat.loopCount; + var cacheFrameInterval=this._cacheFrameRateInterval *this._cachePlayRate; + this._currentTime=value; + this._currentKeyframeIndex=Math.floor(this.currentPlayTime / cacheFrameInterval); + this._currentFrameTime=this._currentKeyframeIndex *cacheFrameInterval; + }); + + /** + *设置是否暂停 + *@param value 是否暂停 + */ + /** + *获取当前是否暂停 + *@return 是否暂停 + */ + __getset(0,__proto,'paused',function(){ + return this._paused; + },function(value){ + this._paused=value; + value && this.event(/*laya.events.Event.PAUSED*/"paused"); + }); + + /** + *获取缓存帧率间隔时间 + *@return 缓存帧率间隔时间 + */ + __getset(0,__proto,'cacheFrameRateInterval',function(){ + return this._cacheFrameRateInterval; + }); + + return AnimationPlayer; + })(EventDispatcher) + + + //class laya.ani.GraphicsAni extends laya.display.Graphics + var GraphicsAni=(function(_super){ + function GraphicsAni(){ + GraphicsAni.__super.call(this); + if (Render.isConchNode){ + this["drawSkin"]=function (skin){ + skin.transform || (skin.transform=Matrix.EMPTY); + this.setSkinMesh&&this.setSkinMesh(skin._ps,skin.mVBData,skin.mEleNum,0,skin.mTexture,skin.transform); + }; + } + } + + __class(GraphicsAni,'laya.ani.GraphicsAni',_super); + var __proto=GraphicsAni.prototype; + /** + *@private + *画自定义蒙皮动画 + *@param skin + */ + __proto.drawSkin=function(skin){ + var arr=[skin]; + this._saveToCmd(Render._context._drawSkin,arr); + } + + return GraphicsAni; + })(Graphics) + + + /** + *AnimationTemplet 类用于动画模板资源。 + */ + //class laya.ani.AnimationTemplet extends laya.resource.Resource + var AnimationTemplet=(function(_super){ + function AnimationTemplet(){ + this._aniMap={}; + //this._publicExtData=null; + //this._useParent=false; + //this.unfixedCurrentFrameIndexes=null; + //this.unfixedCurrentTimes=null; + //this.unfixedKeyframes=null; + this.unfixedLastAniIndex=-1; + //this._aniVersion=null; + //this._animationDatasCache=null; + AnimationTemplet.__super.call(this); + this._anis=new Array; + } + + __class(AnimationTemplet,'laya.ani.AnimationTemplet',_super); + var __proto=AnimationTemplet.prototype; + __proto._endLoaded=function(){ + this._loaded=true; + this.event(/*laya.events.Event.LOADED*/"loaded",this); + } + + __proto.parse=function(data){ + var i=0,j=0,k=0,n=0,l=0; + var read=new Byte(data); + this._aniVersion=read.readUTFString(); + var aniClassName=read.readUTFString(); + var strList=read.readUTFString().split("\n"); + var aniCount=read.getUint8(); + var publicDataPos=read.getUint32(); + var publicExtDataPos=read.getUint32(); + var publicData; + if (publicDataPos > 0) + publicData=data.slice(publicDataPos,publicExtDataPos); + var publicRead=new Byte(publicData); + if (publicExtDataPos > 0) + this._publicExtData=data.slice(publicExtDataPos,data.byteLength); + this._useParent=!!read.getUint8(); + this._anis.length=aniCount; + for (i=0;i < aniCount;i++){ + var ani=this._anis[i]= + {}; + ani.nodes=new Array; + var name=ani.name=strList[read.getUint16()]; + this._aniMap[name]=i; + ani.bone3DMap={}; + ani.playTime=read.getFloat32(); + var boneCount=ani.nodes.length=read.getUint8(); + ani.totalKeyframesLength=0; + for (j=0;j < boneCount;j++){ + var node=ani.nodes[j]= + {}; + node.childs=[]; + var nameIndex=read.getInt16(); + if (nameIndex >=0){ + node.name=strList[nameIndex]; + ani.bone3DMap[node.name]=j; + } + node.keyFrame=new Array; + node.parentIndex=read.getInt16(); + node.parentIndex==-1 ? node.parent=null :node.parent=ani.nodes[node.parentIndex]; + var isLerp=!!read.getUint8(); + var keyframeParamsOffset=read.getUint32(); + publicRead.pos=keyframeParamsOffset; + var keyframeDataCount=node.keyframeWidth=publicRead.getUint16(); + ani.totalKeyframesLength+=keyframeDataCount; + if (isLerp){ + node.interpolationMethod=[]; + node.interpolationMethod.length=keyframeDataCount; + for (k=0;k < keyframeDataCount;k++) + node.interpolationMethod[k]=AnimationTemplet.interpolation[publicRead.getUint8()]; + } + if (node.parent !=null) + node.parent.childs.push(node); + var privateDataLen=read.getUint16(); + if (privateDataLen > 0){ + node.extenData=data.slice(read.pos,read.pos+privateDataLen); + read.pos+=privateDataLen; + }; + var keyframeCount=read.getUint16(); + node.keyFrame.length=keyframeCount; + var startTime=0; + for (k=0,n=keyframeCount;k < n;k++){ + var keyFrame=node.keyFrame[k]= + {}; + keyFrame.duration=read.getFloat32(); + keyFrame.startTime=startTime; + keyFrame.data=new Float32Array(keyframeDataCount); + keyFrame.dData=new Float32Array(keyframeDataCount); + keyFrame.nextData=new Float32Array(keyframeDataCount); + for (l=0;l < keyframeDataCount;l++){ + keyFrame.data[l]=read.getFloat32(); + if (keyFrame.data[l] >-0.00000001 && keyFrame.data[l] < 0.00000001)keyFrame.data[l]=0; + } + startTime+=keyFrame.duration; + } + node.playTime=ani.playTime; + this._calculateKeyFrame(node,keyframeCount,keyframeDataCount); + } + } + } + + __proto._calculateKeyFrame=function(node,keyframeCount,keyframeDataCount){ + var keyFrames=node.keyFrame; + keyFrames[keyframeCount]=keyFrames[0]; + for (var i=0;i < keyframeCount;i++){ + var keyFrame=keyFrames[i]; + for (var j=0;j < keyframeDataCount;j++){ + keyFrame.dData[j]=(keyFrame.duration===0)? 0 :(keyFrames[i+1].data[j]-keyFrame.data[j])/ keyFrame.duration; + keyFrame.nextData[j]=keyFrames[i+1].data[j]; + } + } + keyFrames.length--; + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + this.parse(data); + this._endLoaded(); + } + + __proto.getAnimationCount=function(){ + return this._anis.length; + } + + __proto.getAnimation=function(aniIndex){ + return this._anis[aniIndex]; + } + + __proto.getAniDuration=function(aniIndex){ + return this._anis[aniIndex].playTime; + } + + __proto.getNodes=function(aniIndex){ + return this._anis[aniIndex].nodes; + } + + __proto.getNodeIndexWithName=function(aniIndex,name){ + return this._anis[aniIndex].bone3DMap[name]; + } + + __proto.getNodeCount=function(aniIndex){ + return this._anis[aniIndex].nodes.length; + } + + __proto.getTotalkeyframesLength=function(aniIndex){ + return this._anis[aniIndex].totalKeyframesLength; + } + + __proto.getPublicExtData=function(){ + return this._publicExtData; + } + + __proto.getAnimationDataWithCache=function(key,cacheDatas,aniIndex,frameIndex){ + var aniDatas=cacheDatas[aniIndex]; + if (!aniDatas){ + return null; + }else { + var keyDatas=aniDatas[key]; + if (!keyDatas) + return null; + else { + return keyDatas[frameIndex]; + } + } + } + + __proto.setAnimationDataWithCache=function(key,cacheDatas,aniIndex,frameIndex,data){ + var aniDatas=(cacheDatas[aniIndex])|| (cacheDatas[aniIndex]={}); + var aniDatasCache=(aniDatas[key])|| (aniDatas[key]=[]); + aniDatasCache[frameIndex]=data; + } + + __proto.getOriginalData=function(aniIndex,originalData,nodesFrameIndices,frameIndex,playCurTime){ + var oneAni=this._anis[aniIndex]; + var nodes=oneAni.nodes; + var j=0; + for (var i=0,n=nodes.length,outOfs=0;i < n;i++){ + var node=nodes[i]; + var key; + key=node.keyFrame[nodesFrameIndices[i][frameIndex]]; + node.dataOffset=outOfs; + var dt=playCurTime-key.startTime; + for (j=0;j < node.keyframeWidth;){ + j+=node.interpolationMethod[j](node,j,originalData,outOfs+j,key.data,dt,key.dData,key.duration,key.nextData); + } + outOfs+=node.keyframeWidth; + } + } + + __proto.getNodesCurrentFrameIndex=function(aniIndex,playCurTime){ + var ani=this._anis[aniIndex]; + var nodes=ani.nodes; + if (aniIndex!==this.unfixedLastAniIndex){ + this.unfixedCurrentFrameIndexes=new Uint32Array(nodes.length); + this.unfixedCurrentTimes=new Float32Array(nodes.length); + this.unfixedLastAniIndex=aniIndex; + } + for (var i=0,n=nodes.length,outOfs=0;i < n;i++){ + var node=nodes[i]; + if (playCurTime < this.unfixedCurrentTimes[i]) + this.unfixedCurrentFrameIndexes[i]=0; + this.unfixedCurrentTimes[i]=playCurTime; + while ((this.unfixedCurrentFrameIndexes[i] < node.keyFrame.length)){ + if (node.keyFrame[this.unfixedCurrentFrameIndexes[i]].startTime > this.unfixedCurrentTimes[i]) + break ; + this.unfixedCurrentFrameIndexes[i]++; + } + this.unfixedCurrentFrameIndexes[i]--; + } + return this.unfixedCurrentFrameIndexes; + } + + __proto.getOriginalDataUnfixedRate=function(aniIndex,originalData,playCurTime){ + var oneAni=this._anis[aniIndex]; + var nodes=oneAni.nodes; + if (aniIndex!==this.unfixedLastAniIndex){ + this.unfixedCurrentFrameIndexes=new Uint32Array(nodes.length); + this.unfixedCurrentTimes=new Float32Array(nodes.length); + this.unfixedKeyframes=__newvec(nodes.length); + this.unfixedLastAniIndex=aniIndex; + }; + var j=0; + for (var i=0,n=nodes.length,outOfs=0;i < n;i++){ + var node=nodes[i]; + if (playCurTime < this.unfixedCurrentTimes[i]) + this.unfixedCurrentFrameIndexes[i]=0; + this.unfixedCurrentTimes[i]=playCurTime; + while (this.unfixedCurrentFrameIndexes[i] < node.keyFrame.length){ + if (node.keyFrame[this.unfixedCurrentFrameIndexes[i]].startTime > this.unfixedCurrentTimes[i]) + break ; + this.unfixedKeyframes[i]=node.keyFrame[this.unfixedCurrentFrameIndexes[i]]; + this.unfixedCurrentFrameIndexes[i]++; + }; + var key=this.unfixedKeyframes[i]; + node.dataOffset=outOfs; + var dt=playCurTime-key.startTime; + for (j=0;j < node.keyframeWidth;){ + j+=node.interpolationMethod[j](node,j,originalData,outOfs+j,key.data,dt,key.dData,key.duration,key.nextData); + } + outOfs+=node.keyframeWidth; + } + } + + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + AnimationTemplet._LinearInterpolation_0=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + out[outOfs]=data[index]+dt *dData[index]; + return 1; + } + + AnimationTemplet._QuaternionInterpolation_1=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + var amount=duration===0 ? 0 :dt / duration; + MathUtil.slerpQuaternionArray(data,index,nextData,index,amount,out,outOfs); + return 4; + } + + AnimationTemplet._AngleInterpolation_2=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + return 0; + } + + AnimationTemplet._RadiansInterpolation_3=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + return 0; + } + + AnimationTemplet._Matrix4x4Interpolation_4=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + for (var i=0;i < 16;i++,index++) + out[outOfs+i]=data[index]+dt *dData[index]; + return 16; + } + + AnimationTemplet._NoInterpolation_5=function(bone,index,out,outOfs,data,dt,dData,duration,nextData){ + out[outOfs]=data[index]; + return 1; + } + + AnimationTemplet.load=function(url){ + return Laya.loader.create(url,null,null,AnimationTemplet); + } + + AnimationTemplet.interpolation=[AnimationTemplet._LinearInterpolation_0,AnimationTemplet._QuaternionInterpolation_1,AnimationTemplet._AngleInterpolation_2,AnimationTemplet._RadiansInterpolation_3,AnimationTemplet._Matrix4x4Interpolation_4,AnimationTemplet._NoInterpolation_5]; + AnimationTemplet.LAYA_ANIMATION_VISION="LAYAANIMATION:1.0.6"; + return AnimationTemplet; + })(Resource) + + + /** + *骨骼动画由Templet,AnimationPlayer,Skeleton三部分组成 + */ + //class laya.ani.bone.Skeleton extends laya.display.Sprite + var Skeleton=(function(_super){ + function Skeleton(templet,aniMode){ + this._templet=null; + this._player=null; + this._curOriginalData=null; + this._boneMatrixArray=[]; + this._lastTime=0; + this._currAniName=null; + this._currAniIndex=-1; + this._pause=true; + this._aniClipIndex=-1; + this._clipIndex=-1; + this._skinIndex=0; + this._skinName="default"; + this._aniMode=0; + this._graphicsCache=null; + this._boneSlotDic=null; + this._bindBoneBoneSlotDic=null; + this._boneSlotArray=null; + this._index=-1; + this._total=-1; + this._indexControl=false; + this._aniPath=null; + this._texturePath=null; + this._complete=null; + this._loadAniMode=0; + this._yReverseMatrix=null; + this._ikArr=null; + this._tfArr=null; + this._pathDic=null; + this._rootBone=null; + this._boneList=null; + this._aniSectionDic=null; + this._eventIndex=0; + this._drawOrderIndex=0; + this._drawOrder=null; + this._lastAniClipIndex=-1; + Skeleton.__super.call(this); + (aniMode===void 0)&& (aniMode=0); + if (templet)this.init(templet,aniMode); + } + + __class(Skeleton,'laya.ani.bone.Skeleton',_super); + var __proto=Skeleton.prototype; + /** + *初始化动画 + *0,使用模板缓冲的数据,模板缓冲的数据,不允许修改 (内存开销小,计算开销小,不支持换装) + *1,使用动画自己的缓冲区,每个动画都会有自己的缓冲区,相当耗费内存 (内存开销大,计算开销小,支持换装) + *2,使用动态方式,去实时去画 (内存开销小,计算开销大,支持换装,不建议使用) + *@param templet 模板 + *@param aniMode 动画模式,0:不支持换装,1,2支持换装 + */ + __proto.init=function(templet,aniMode){ + (aniMode===void 0)&& (aniMode=0); + var i=0,n=0; + if (aniMode==1){ + this._graphicsCache=[]; + for (i=0,n=templet.getAnimationCount();i < n;i++){ + this._graphicsCache.push([]); + } + } + this._yReverseMatrix=templet.yReverseMatrix; + this._aniMode=aniMode; + this._templet=templet; + this._player=new AnimationPlayer(); + this._player.cacheFrameRate=templet.rate; + this._player.templet=templet; + this._player.play(); + this._parseSrcBoneMatrix(); + this._boneList=templet.mBoneArr; + this._rootBone=templet.mRootBone; + this._aniSectionDic=templet.aniSectionDic; + if (templet.ikArr.length > 0){ + this._ikArr=[]; + for (i=0,n=templet.ikArr.length;i < n;i++){ + this._ikArr.push(new IkConstraint(templet.ikArr[i],this._boneList)); + } + } + if (templet.pathArr.length > 0){ + var tPathData; + var tPathConstraint; + if (this._pathDic==null)this._pathDic={}; + var tBoneSlot; + for (i=0,n=templet.pathArr.length;i < n;i++){ + tPathData=templet.pathArr[i]; + tPathConstraint=new PathConstraint(tPathData,this._boneList); + tBoneSlot=this._boneSlotDic[tPathData.name]; + if (tBoneSlot){ + tPathConstraint=new PathConstraint(tPathData,this._boneList); + tPathConstraint.target=tBoneSlot; + } + this._pathDic[tPathData.name]=tPathConstraint; + } + } + if (templet.tfArr.length > 0){ + this._tfArr=[]; + for (i=0,n=templet.tfArr.length;i < n;i++){ + this._tfArr.push(new TfConstraint(templet.tfArr[i],this._boneList)); + } + } + if (templet.skinDataArray.length > 0){ + var tSkinData=this._templet.skinDataArray[this._skinIndex]; + this._skinName=tSkinData.name; + } + this._player.on(/*laya.events.Event.PLAYED*/"played",this,this._onPlay); + this._player.on(/*laya.events.Event.STOPPED*/"stopped",this,this._onStop); + this._player.on(/*laya.events.Event.PAUSED*/"paused",this,this._onPause); + } + + /** + *通过加载直接创建动画 + *@param path 要加载的动画文件路径 + *@param complete 加载完成的回调函数 + *@param aniMode 0,使用模板缓冲的数据,模板缓冲的数据,不允许修改(内存开销小,计算开销小,不支持换装) 1,使用动画自己的缓冲区,每个动画都会有自己的缓冲区,相当耗费内存 (内存开销大,计算开销小,支持换装)2,使用动态方式,去实时去画(内存开销小,计算开销大,支持换装,不建议使用) + */ + __proto.load=function(path,complete,aniMode){ + (aniMode===void 0)&& (aniMode=0); + this._aniPath=path; + this._complete=complete; + this._loadAniMode=aniMode; + this._texturePath=path.replace(".sk",".png").replace(".bin",".png"); + Laya.loader.load([{url:path,type:/*laya.net.Loader.BUFFER*/"arraybuffer"},{url:this._texturePath,type:/*laya.net.Loader.IMAGE*/"image"}],Handler.create(this,this._onLoaded)); + } + + /** + *加载完成 + */ + __proto._onLoaded=function(){ + var tTexture=Loader.getRes(this._texturePath); + var arraybuffer=Loader.getRes(this._aniPath); + if (tTexture==null || arraybuffer==null)return; + if (Templet.TEMPLET_DICTIONARY==null){ + Templet.TEMPLET_DICTIONARY={}; + }; + var tFactory; + tFactory=Templet.TEMPLET_DICTIONARY[this._aniPath]; + if (tFactory){ + tFactory.isParseFail ? this._parseFail():this._parseComplete(); + }else { + tFactory=new Templet(); + tFactory.url=this._aniPath; + Templet.TEMPLET_DICTIONARY[this._aniPath]=tFactory; + tFactory.on(/*laya.events.Event.COMPLETE*/"complete",this,this._parseComplete); + tFactory.on(/*laya.events.Event.ERROR*/"error",this,this._parseFail); + tFactory.parseData(tTexture,arraybuffer,60); + } + } + + /** + *解析完成 + */ + __proto._parseComplete=function(){ + var tTemple=Templet.TEMPLET_DICTIONARY[this._aniPath]; + if (tTemple){ + this.init(tTemple,this._loadAniMode); + this.play(0,true); + } + this._complete && this._complete.runWith(this); + } + + /** + *解析失败 + */ + __proto._parseFail=function(){ + console.log("[Error]:"+this._aniPath+"解析失败"); + } + + /** + *传递PLAY事件 + */ + __proto._onPlay=function(){ + this.event(/*laya.events.Event.PLAYED*/"played"); + } + + /** + *传递STOP事件 + */ + __proto._onStop=function(){ + var tEventData; + var tEventAniArr=this._templet.eventAniArr; + var tEventArr=tEventAniArr[this._aniClipIndex]; + if (tEventArr && this._eventIndex < tEventArr.length){ + for (;this._eventIndex < tEventArr.length;this._eventIndex++){ + tEventData=tEventArr[this._eventIndex]; + if (tEventData.time >=this._player.playStart && tEventData.time <=this._player.playEnd){ + this.event(/*laya.events.Event.LABEL*/"label",tEventData); + } + } + } + this._eventIndex=0; + this._drawOrder=null; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + } + + /** + *传递PAUSE事件 + */ + __proto._onPause=function(){ + this.event(/*laya.events.Event.PAUSED*/"paused"); + } + + /** + *创建骨骼的矩阵,保存每次计算的最终结果 + */ + __proto._parseSrcBoneMatrix=function(){ + var i=0,n=0; + n=this._templet.srcBoneMatrixArr.length; + for (i=0;i < n;i++){ + this._boneMatrixArray.push(new Matrix()); + } + if (this._aniMode==0){ + this._boneSlotDic=this._templet.boneSlotDic; + this._bindBoneBoneSlotDic=this._templet.bindBoneBoneSlotDic; + this._boneSlotArray=this._templet.boneSlotArray; + }else { + if (this._boneSlotDic==null)this._boneSlotDic={}; + if (this._bindBoneBoneSlotDic==null)this._bindBoneBoneSlotDic={}; + if (this._boneSlotArray==null)this._boneSlotArray=[]; + var tArr=this._templet.boneSlotArray; + var tBS; + var tBSArr; + for (i=0,n=tArr.length;i < n;i++){ + tBS=tArr[i]; + tBSArr=this._bindBoneBoneSlotDic[tBS.parent]; + if (tBSArr==null){ + this._bindBoneBoneSlotDic[tBS.parent]=tBSArr=[]; + } + this._boneSlotDic[tBS.name]=tBS=tBS.copy(); + tBSArr.push(tBS); + this._boneSlotArray.push(tBS); + } + } + } + + /** + *更新动画 + *@param autoKey true为正常更新,false为index手动更新 + */ + __proto._update=function(autoKey){ + (autoKey===void 0)&& (autoKey=true); + if (this._pause)return; + if (autoKey && this._indexControl){ + return; + }; + var tCurrTime=Laya.timer.currTimer; + if (autoKey){ + this._player.update(tCurrTime-this._lastTime) + } + this._lastTime=tCurrTime; + this._aniClipIndex=this._player.currentAnimationClipIndex; + this._clipIndex=this._player.currentKeyframeIndex; + var tEventData; + var tEventAniArr=this._templet.eventAniArr; + var tEventArr=tEventAniArr[this._aniClipIndex]; + if (tEventArr && this._eventIndex < tEventArr.length){ + tEventData=tEventArr[this._eventIndex]; + if (tEventData.time >=this._player.playStart && tEventData.time <=this._player.playEnd){ + if (this._player.currentPlayTime >=tEventData.time){ + this.event(/*laya.events.Event.LABEL*/"label",tEventData); + this._eventIndex++; + } + }else { + this._eventIndex++; + } + } + if (this._aniClipIndex==-1)return; + var tGraphics; + if (this._aniMode==0){ + tGraphics=this._templet.getGrahicsDataWithCache(this._aniClipIndex,this._clipIndex); + if (tGraphics){ + if (this.graphics !=tGraphics){ + this.graphics=tGraphics; + } + return; + } + }else if (this._aniMode==1){ + tGraphics=this._getGrahicsDataWithCache(this._aniClipIndex,this._clipIndex); + if (tGraphics){ + if (this.graphics !=tGraphics){ + this.graphics=tGraphics; + } + return; + } + } + this._createGraphics(); + } + + /** + *创建grahics图像 + */ + __proto._createGraphics=function(){ + var tDrawOrderData; + var tDrawOrderAniArr=this._templet.drawOrderAniArr; + var tDrawOrderArr=tDrawOrderAniArr[this._aniClipIndex]; + if (tDrawOrderArr && tDrawOrderArr.length > 0){ + this._drawOrderIndex=0; + tDrawOrderData=tDrawOrderArr[this._drawOrderIndex]; + while (this._player.currentPlayTime >=tDrawOrderData.time){ + this._drawOrder=tDrawOrderData.drawOrder; + this._drawOrderIndex++; + if (this._drawOrderIndex >=tDrawOrderArr.length){ + break ; + } + tDrawOrderData=tDrawOrderArr[this._drawOrderIndex]; + } + }; + var tGraphics; + if (this._aniMode==0 || this._aniMode==1){ + this.graphics=new GraphicsAni(); + }else { + if ((this.graphics instanceof laya.ani.GraphicsAni )){ + this.graphics.clear(); + }else { + this.graphics=new GraphicsAni(); + } + } + tGraphics=this.graphics; + var bones=this._templet.getNodes(this._aniClipIndex); + this._templet.getOriginalData(this._aniClipIndex,this._curOriginalData,this._player._fullFrames[this._aniClipIndex],this._clipIndex,this._player.currentFrameTime); + var tSectionArr=this._aniSectionDic[this._aniClipIndex]; + var tParentMatrix; + var tStartIndex=0; + var i=0,j=0,k=0,n=0; + var tDBBoneSlot; + var tDBBoneSlotArr; + var tParentTransform; + var tSrcBone; + var boneCount=this._templet.srcBoneMatrixArr.length; + for (i=0,n=tSectionArr[0];i < boneCount;i++){ + tSrcBone=this._boneList[i]; + tParentTransform=this._templet.srcBoneMatrixArr[i]; + tSrcBone.resultTransform.scX=tParentTransform.scX *this._curOriginalData[tStartIndex++]; + tSrcBone.resultTransform.skX=tParentTransform.skX+this._curOriginalData[tStartIndex++]; + tSrcBone.resultTransform.skY=tParentTransform.skY+this._curOriginalData[tStartIndex++]; + tSrcBone.resultTransform.scY=tParentTransform.scY *this._curOriginalData[tStartIndex++]; + tSrcBone.resultTransform.x=tParentTransform.x+this._curOriginalData[tStartIndex++]; + tSrcBone.resultTransform.y=tParentTransform.y+this._curOriginalData[tStartIndex++]; + }; + var tSlotDic={}; + var tSlotAlphaDic={}; + var tBoneData; + for (n+=tSectionArr[1];i < n;i++){ + tBoneData=bones[i]; + tSlotDic[tBoneData.name]=this._curOriginalData[tStartIndex++]; + tSlotAlphaDic[tBoneData.name]=this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + }; + var tBendDirectionDic={}; + var tMixDic={}; + for (n+=tSectionArr[2];i < n;i++){ + tBoneData=bones[i]; + tBendDirectionDic[tBoneData.name]=this._curOriginalData[tStartIndex++]; + tMixDic[tBoneData.name]=this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + this._curOriginalData[tStartIndex++]; + } + if (this._pathDic){ + var tPathConstraint; + for (n+=tSectionArr[3];i < n;i++){ + tBoneData=bones[i]; + tPathConstraint=this._pathDic[tBoneData.name]; + if (tPathConstraint){ + var tByte=new Byte(tBoneData.extenData); + switch(tByte.getByte()){ + case 1: + tPathConstraint.position=this._curOriginalData[tStartIndex++]; + break ; + case 2: + tPathConstraint.spacing=this._curOriginalData[tStartIndex++]; + break ; + case 3: + tPathConstraint.rotateMix=this._curOriginalData[tStartIndex++]; + tPathConstraint.translateMix=this._curOriginalData[tStartIndex++]; + break ; + } + } + } + } + if (this._yReverseMatrix){ + this._rootBone.update(this._yReverseMatrix); + }else { + this._rootBone.update(Matrix.TEMP.identity()); + } + if (this._ikArr){ + var tIkConstraint; + for (i=0,n=this._ikArr.length;i < n;i++){ + tIkConstraint=this._ikArr[i]; + if (tBendDirectionDic.hasOwnProperty(tIkConstraint.name)){ + tIkConstraint.bendDirection=tBendDirectionDic[tIkConstraint.name]; + } + if (tMixDic.hasOwnProperty(tIkConstraint.name)){ + tIkConstraint.mix=tMixDic[tIkConstraint.name] + } + tIkConstraint.apply(); + } + } + if (this._pathDic){ + for (var tPathStr in this._pathDic){ + tPathConstraint=this._pathDic[tPathStr]; + tPathConstraint.apply(this._boneList,tGraphics); + } + } + if (this._tfArr){ + var tTfConstraint; + for (i=0,k=this._tfArr.length;i < k;i++){ + tTfConstraint=this._tfArr[i]; + tTfConstraint.apply(); + } + } + for (i=0,k=this._boneList.length;i < k;i++){ + tSrcBone=this._boneList[i]; + tDBBoneSlotArr=this._bindBoneBoneSlotDic[tSrcBone.name]; + tSrcBone.resultMatrix.copyTo(this._boneMatrixArray[i]); + if (tDBBoneSlotArr){ + for (j=0,n=tDBBoneSlotArr.length;j < n;j++){ + tDBBoneSlot=tDBBoneSlotArr[j]; + if (tDBBoneSlot){ + tDBBoneSlot.setParentMatrix(tSrcBone.resultMatrix); + } + } + } + }; + var tDeformDic={}; + var tDeformAniArr=this._templet.deformAniArr; + var tDeformAniData; + var tDeformSlotData; + var tDeformSlotDisplayData; + if (tDeformAniArr && tDeformAniArr.length > 0){ + if (this._lastAniClipIndex !=this._aniClipIndex){ + this._lastAniClipIndex=this._aniClipIndex; + for (i=0,n=this._boneSlotArray.length;i < n;i++){ + tDBBoneSlot=this._boneSlotArray[i]; + tDBBoneSlot.deformData=null; + } + }; + var tSkinDeformAni=tDeformAniArr[this._aniClipIndex]; + tDeformAniData=tSkinDeformAni ["default"]; + if (tDeformAniData){ + for (i=0,n=tDeformAniData.deformSlotDataList.length;i < n;i++){ + tDeformSlotData=tDeformAniData.deformSlotDataList[i]; + for (j=0;j < tDeformSlotData.deformSlotDisplayList.length;j++){ + tDeformSlotDisplayData=tDeformSlotData.deformSlotDisplayList[j]; + tDBBoneSlot=this._boneSlotArray[tDeformSlotDisplayData.slotIndex]; + tDeformSlotDisplayData.apply(this._player.currentPlayTime,tDBBoneSlot); + if (!tDeformDic[tDeformSlotDisplayData.slotIndex]){ + tDeformDic[tDeformSlotDisplayData.slotIndex]={}; + } + tDeformDic[tDeformSlotDisplayData.slotIndex][tDeformSlotDisplayData.attachment]=tDeformSlotDisplayData.deformData; + } + } + } + tDeformAniData=tSkinDeformAni [this._skinName]; + if (tDeformAniData){ + for (i=0,n=tDeformAniData.deformSlotDataList.length;i < n;i++){ + tDeformSlotData=tDeformAniData.deformSlotDataList[i]; + for (j=0;j < tDeformSlotData.deformSlotDisplayList.length;j++){ + tDeformSlotDisplayData=tDeformSlotData.deformSlotDisplayList[j]; + tDBBoneSlot=this._boneSlotArray[tDeformSlotDisplayData.slotIndex]; + tDeformSlotDisplayData.apply(this._player.currentPlayTime,tDBBoneSlot); + if (!tDeformDic[tDeformSlotDisplayData.slotIndex]){ + tDeformDic[tDeformSlotDisplayData.slotIndex]={}; + } + tDeformDic[tDeformSlotDisplayData.slotIndex][tDeformSlotDisplayData.attachment]=tDeformSlotDisplayData.deformData; + } + } + } + }; + var tSlotData2; + var tSlotData3; + var tObject; + if (this._drawOrder){ + for (i=0,n=this._drawOrder.length;i < n;i++){ + tDBBoneSlot=this._boneSlotArray[this._drawOrder[i]]; + tSlotData2=tSlotDic[tDBBoneSlot.name]; + tSlotData3=tSlotAlphaDic[tDBBoneSlot.name]; + if (!isNaN(tSlotData3)){ + tGraphics.save(); + tGraphics.alpha(tSlotData3); + } + if (!isNaN(tSlotData2)){ + if (this._templet.attachmentNames){ + tDBBoneSlot.showDisplayByName(this._templet.attachmentNames[tSlotData2]); + }else { + tDBBoneSlot.showDisplayByIndex(tSlotData2); + } + } + if (tDeformDic[this._drawOrder[i]]){ + tObject=tDeformDic[this._drawOrder[i]]; + if (tDBBoneSlot.currDisplayData && tObject[tDBBoneSlot.currDisplayData.attachmentName]){ + tDBBoneSlot.deformData=tObject[tDBBoneSlot.currDisplayData.attachmentName]; + }else { + tDBBoneSlot.deformData=null; + } + }else { + tDBBoneSlot.deformData=null; + } + if (!isNaN(tSlotData3)){ + tDBBoneSlot.draw(tGraphics,this._boneMatrixArray,this._aniMode==2,tSlotData3); + }else { + tDBBoneSlot.draw(tGraphics,this._boneMatrixArray,this._aniMode==2); + } + if (!isNaN(tSlotData3)){ + tGraphics.restore(); + } + } + }else { + for (i=0,n=this._boneSlotArray.length;i < n;i++){ + tDBBoneSlot=this._boneSlotArray[i]; + tSlotData2=tSlotDic[tDBBoneSlot.name]; + tSlotData3=tSlotAlphaDic[tDBBoneSlot.name]; + if (!isNaN(tSlotData3)){ + tGraphics.save(); + tGraphics.alpha(tSlotData3); + } + if (!isNaN(tSlotData2)){ + if (this._templet.attachmentNames){ + tDBBoneSlot.showDisplayByName(this._templet.attachmentNames[tSlotData2]); + }else { + tDBBoneSlot.showDisplayByIndex(tSlotData2); + } + } + if (tDeformDic[i]){ + tObject=tDeformDic[i]; + if (tDBBoneSlot.currDisplayData && tObject[tDBBoneSlot.currDisplayData.attachmentName]){ + tDBBoneSlot.deformData=tObject[tDBBoneSlot.currDisplayData.attachmentName]; + }else { + tDBBoneSlot.deformData=null; + } + }else { + tDBBoneSlot.deformData=null; + } + if (!isNaN(tSlotData3)){ + tDBBoneSlot.draw(tGraphics,this._boneMatrixArray,this._aniMode==2,tSlotData3); + }else { + tDBBoneSlot.draw(tGraphics,this._boneMatrixArray,this._aniMode==2); + } + if (!isNaN(tSlotData3)){ + tGraphics.restore(); + } + } + } + if (this._aniMode==0){ + this._templet.setGrahicsDataWithCache(this._aniClipIndex,this._clipIndex,tGraphics); + }else if (this._aniMode==1){ + this._setGrahicsDataWithCache(this._aniClipIndex,this._clipIndex,tGraphics); + } + } + + /** + *得到当前动画的数量 + *@return + */ + __proto.getAnimNum=function(){ + return this._templet.getAnimationCount(); + } + + /** + *得到指定动画的名字 + *@param index 动画的索引 + */ + __proto.getAniNameByIndex=function(index){ + return this._templet.getAniNameByIndex(index); + } + + /** + *通过名字得到插槽的引用 + *@param name 动画的名字 + *@return + */ + __proto.getSlotByName=function(name){ + return this._boneSlotDic[name]; + } + + /** + *通过名字显示一套皮肤 + *@param name 皮肤的名字 + */ + __proto.showSkinByName=function(name){ + this.showSkinByIndex(this._templet.getSkinIndexByName(name)); + } + + /** + *通过索引显示一套皮肤 + *@param skinIndex 皮肤索引 + */ + __proto.showSkinByIndex=function(skinIndex){ + for (var i=0;i < this._boneSlotArray.length;i++){ + (this._boneSlotArray [i]).showSlotData(null); + } + if (this._templet.showSkinByIndex(this._boneSlotDic,skinIndex)){ + var tSkinData=this._templet.skinDataArray[skinIndex]; + this._skinIndex=skinIndex; + this._skinName=tSkinData.name; + } + this._clearCache(); + } + + /** + *设置某插槽的皮肤 + *@param slotName 插槽名称 + *@param index 插糟皮肤的索引 + */ + __proto.showSlotSkinByIndex=function(slotName,index){ + if (this._aniMode==0)return; + var tBoneSlot=this.getSlotByName(slotName); + if (tBoneSlot){ + tBoneSlot.showDisplayByIndex(index); + } + this._clearCache(); + } + + /** + *设置自定义皮肤 + *@param name 插糟的名字 + *@param texture 自定义的纹理 + */ + __proto.setSlotSkin=function(slotName,texture){ + if (this._aniMode==0)return; + var tBoneSlot=this.getSlotByName(slotName); + if (tBoneSlot){ + tBoneSlot.replaceSkin(texture); + } + this._clearCache(); + } + + /** + *换装的时候,需要清一下缓冲区 + */ + __proto._clearCache=function(){ + if (this._aniMode==1){ + for (var i=0,n=this._graphicsCache.length;i < n;i++){ + this._graphicsCache[i].length=0; + } + } + } + + /** + *播放动画 + *@param nameOrIndex 动画名字或者索引 + *@param loop 是否循环播放 + *@param force false,如果要播的动画跟上一个相同就不生效,true,强制生效 + *@param start 起始时间 + *@param end 结束时间 + */ + __proto.play=function(nameOrIndex,loop,force,start,end){ + (force===void 0)&& (force=true); + (start===void 0)&& (start=0); + (end===void 0)&& (end=0); + this._indexControl=false; + var index=-1; + var duration=NaN; + if (loop){ + duration=2147483647; + }else { + duration=0; + } + if ((typeof nameOrIndex=='string')){ + for (var i=0,n=this._templet.getAnimationCount();i < n;i++){ + var animation=this._templet.getAnimation(i); + if (animation && nameOrIndex==animation.name){ + index=i; + break ; + } + } + }else { + index=nameOrIndex; + } + if (index >-1 && index < this.getAnimNum()){ + if (force || this._pause || this._currAniIndex !=index){ + this._currAniIndex=index; + this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(index)); + this._drawOrder=null; + this._eventIndex=0; + this._player.play(index,this._player.playbackRate,duration,start,end); + this._templet.showSkinByIndex(this._boneSlotDic,this._skinIndex); + if (this._pause){ + this._pause=false; + this._lastTime=Browser.now(); + Laya.stage.frameLoop(1,this,this._update,null,true); + } + } + } + } + + /** + *停止动画 + */ + __proto.stop=function(){ + if (!this._pause){ + this._pause=true; + if (this._player){ + this._player.stop(true); + } + Laya.timer.clear(this,this._update); + } + } + + /** + *设置动画播放速率 + *@param value 1为标准速率 + */ + __proto.playbackRate=function(value){ + if (this._player){ + this._player.playbackRate=value; + } + } + + /** + *暂停动画的播放 + */ + __proto.paused=function(){ + if (!this._pause){ + this._pause=true; + if (this._player){ + this._player.paused=true; + } + Laya.timer.clear(this,this._update); + } + } + + /** + *恢复动画的播放 + */ + __proto.resume=function(){ + this._indexControl=false; + if (this._pause){ + this._pause=false; + if (this._player){ + this._player.paused=false; + } + this._lastTime=Browser.now(); + Laya.stage.frameLoop(1,this,this._update,null,true); + } + } + + /** + *@private + *得到缓冲数据 + *@param aniIndex + *@param frameIndex + *@return + */ + __proto._getGrahicsDataWithCache=function(aniIndex,frameIndex){ + return this._graphicsCache[aniIndex][frameIndex]; + } + + /** + *@private + *保存缓冲grahpics + *@param aniIndex + *@param frameIndex + *@param graphics + */ + __proto._setGrahicsDataWithCache=function(aniIndex,frameIndex,graphics){ + this._graphicsCache[aniIndex][frameIndex]=graphics; + } + + /** + *销毁当前动画 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._templet=null; + this._player.offAll(); + this._player=null; + this._curOriginalData=null; + this._boneMatrixArray.length=0; + this._lastTime=0; + Laya.timer.clear(this,this._update); + } + + /** + *设置动画路径 + */ + /** + *得到资源的URL + */ + __getset(0,__proto,'url',function(){ + return this._aniPath; + },function(path){ + this.load(path); + }); + + /** + *@private + *设置帧索引 + */ + /** + *@private + *得到帧索引 + */ + __getset(0,__proto,'index',function(){ + return this._index; + },function(value){ + if (this.player){ + this._index=value; + this._player.currentTime=this._index *1000 / this._player.cacheFrameRate; + this._indexControl=true; + this._update(false); + } + }); + + /** + *得到总帧数据 + */ + __getset(0,__proto,'total',function(){ + if (this._templet && this._player){ + this._total=Math.floor(this._templet.getAniDuration(this._player.currentAnimationClipIndex)/ 1000 *this._player.cacheFrameRate); + }else { + this._total=-1; + } + return this._total; + }); + + /** + *得到播放器的引用 + */ + __getset(0,__proto,'player',function(){ + return this._player; + }); + + return Skeleton; + })(Sprite) + + + /** + *

    MovieClip 用于播放经过工具处理后的 swf 动画。

    + */ + //class laya.ani.swf.MovieClip extends laya.display.Sprite + var MovieClip=(function(_super){ + function MovieClip(parentMovieClip){ + this._start=0; + this._Pos=0; + this._data=null; + this._curIndex=0; + this._preIndex=0; + this._playIndex=0; + this._playing=false; + this._ended=true; + this._count=0; + this._ids=null; + this._loadedImage={}; + this._idOfSprite=null; + this._parentMovieClip=null; + this._movieClipList=null; + this._labels=null; + this.basePath=null; + this._atlasPath=null; + this._url=null; + this._isRoot=false; + this.interval=30; + this.loop=false; + MovieClip.__super.call(this); + this._ids={}; + this._idOfSprite=[]; + this._reset(); + this._playing=false; + this._parentMovieClip=parentMovieClip; + if (!parentMovieClip){ + this._movieClipList=[this]; + this._isRoot=true; + }else { + this._isRoot=false; + this._movieClipList=parentMovieClip._movieClipList; + this._movieClipList.push(this); + } + } + + __class(MovieClip,'laya.ani.swf.MovieClip',_super); + var __proto=MovieClip.prototype; + /** + *

    销毁此对象。以及销毁引用的Texture

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + this._clear(); + _super.prototype.destroy.call(this,destroyChild); + } + + /**@private */ + __proto._setDisplay=function(value){ + _super.prototype._setDisplay.call(this,value); + if (this._isRoot){ + this._$3__onDisplay(); + } + } + + /**@private */ + __proto._$3__onDisplay=function(){ + if (this._displayedInStage)Laya.timer.loop(this.interval,this,this.updates,null,true); + else Laya.timer.clear(this,this.updates); + } + + /**@private 更新时间轴*/ + __proto.updates=function(){ + if (this._parentMovieClip)return; + var i=0,len=0; + len=this._movieClipList.length; + for (i=0;i < len;i++){ + this._movieClipList[i]&&this._movieClipList[i]._update(); + } + } + + /** + *增加一个标签到index帧上,播放到此index后会派发label事件 + *@param label 标签名称 + *@param index 索引位置 + */ + __proto.addLabel=function(label,index){ + if (!this._labels)this._labels={}; + this._labels[index]=label; + } + + /** + *删除某个标签 + *@param label 标签名字,如果label为空,则删除所有Label + */ + __proto.removeLabel=function(label){ + if (!label)this._labels=null; + else if (!this._labels){ + for (var name in this._labels){ + if (this._labels[name]===label){ + delete this._labels[name]; + break ; + } + } + } + } + + /** + *@private + *动画的帧更新处理函数。 + */ + __proto._update=function(){ + if (!this._data)return; + if (!this._playing)return; + this._playIndex++; + if (this._playIndex >=this._count){ + if (!this.loop){ + this._playIndex--; + this.stop(); + return; + } + this._playIndex=0; + } + this._parse(this._playIndex); + if (this._labels && this._labels[this._playIndex])this.event(/*laya.events.Event.LABEL*/"label",this._labels[this._playIndex]); + } + + /** + *停止播放动画。 + */ + __proto.stop=function(){ + this._playing=false; + } + + /** + *跳到某帧并停止播放动画。 + *@param frame 要跳到的帧 + */ + __proto.gotoAndStop=function(index){ + this.index=index; + this.stop(); + } + + /** + *@private + *清理。 + */ + __proto._clear=function(){ + this.stop(); + this._idOfSprite.length=0; + if (!this._parentMovieClip){ + Laya.timer.clear(this,this.updates); + var i=0,len=0; + len=this._movieClipList.length; + for (i=0;i < len;i++){ + if (this._movieClipList[i] !=this) + this._movieClipList[i]._clear(); + } + this._movieClipList.length=0; + }; + var key; + for (key in this._loadedImage){ + if (this._loadedImage[key]){ + Loader.clearRes(key); + this._loadedImage[key]=false; + } + } + this.removeChildren(); + this.graphics=null; + this._parentMovieClip=null; + } + + /** + *播放动画。 + *@param index 帧索引。 + */ + __proto.play=function(index,loop){ + (index===void 0)&& (index=0); + (loop===void 0)&& (loop=true); + this.loop=loop; + this._playing=true; + if (this._data) + this._displayFrame(index); + } + + /**@private */ + __proto._displayFrame=function(frameIndex){ + (frameIndex===void 0)&& (frameIndex=-1); + if (frameIndex !=-1){ + if (this._curIndex > frameIndex)this._reset(); + this._parse(frameIndex); + } + } + + /**@private */ + __proto._reset=function(rm){ + (rm===void 0)&& (rm=true); + if (rm && this._curIndex !=1)this.removeChildren(); + this._preIndex=this._curIndex=-1; + this._Pos=this._start; + } + + /**@private */ + __proto._parse=function(frameIndex){ + var curChild=this; + var mc,sp,key=0,type=0,tPos=0,ttype=0,ifAdd=false; + var _idOfSprite=this._idOfSprite,_data=this._data,eStr; + if (this._ended)this._reset(); + _data.pos=this._Pos; + this._ended=false; + this._playIndex=frameIndex; + if (this._curIndex > frameIndex&&frameIndex 0); + break ; + case 7: + sp=_idOfSprite[ _data.getUint16()]; + var mt=sp.transform || Matrix.create(); + mt.setTo(_data.getFloat32(),_data.getFloat32(),_data.getFloat32(),_data.getFloat32(),_data.getFloat32(),_data.getFloat32()); + sp.transform=mt; + break ; + case 8: + _idOfSprite[_data.getUint16()].setPos(_data.getFloat32(),_data.getFloat32()); + break ; + case 9: + _idOfSprite[_data.getUint16()].setSize(_data.getFloat32(),_data.getFloat32()); + break ; + case 10: + _idOfSprite[ _data.getUint16()].alpha=_data.getFloat32(); + break ; + case 11: + _idOfSprite[_data.getUint16()].setScale(_data.getFloat32(),_data.getFloat32()); + break ; + case 98: + eStr=_data.getString(); + this.event(eStr); + if (eStr=="stop")this.stop(); + break ; + case 99: + this._curIndex=_data.getUint16(); + ifAdd && this.updateZOrder(); + break ; + case 100: + this._count=this._curIndex+1; + this._ended=true; + if (this._playing){ + this.event(/*laya.events.Event.FRAME*/"enterframe"); + this.event(/*laya.events.Event.END*/"end"); + this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + this._reset(false); + break ; + } + } + if (this._playing&&!this._ended)this.event(/*laya.events.Event.FRAME*/"enterframe"); + this._Pos=_data.pos; + } + + /**@private */ + __proto._setData=function(data,start){ + this._data=data; + this._start=start+3; + } + + /** + *加载资源。 + *@param url swf 资源地址。 + *@param atlas 是否使用图集资源 + *@param atlasPath 图集路径,默认使用与swf同名的图集 + */ + __proto.load=function(url,atlas,atlasPath){ + (atlas===void 0)&& (atlas=false); + this._url=url=URL.formatURL(url); + if(atlas)this._atlasPath=atlasPath?atlasPath:url.split(".swf")[0]+".json"; + this.stop(); + this._clear(); + this._movieClipList=[this]; + var urls; + urls=[ {url:url,type:/*laya.net.Loader.BUFFER*/"arraybuffer" }]; + if (this._atlasPath){ + urls.push({url:this._atlasPath,type:/*laya.net.Loader.ATLAS*/"atlas" }); + } + Laya.loader.load(urls,Handler.create(this,this._onLoaded)); + } + + /**@private */ + __proto._onLoaded=function(){ + this.basePath=this._atlasPath?Loader.getAtlas(this._atlasPath).dir:this._url.split(".swf")[0]+"/image/"; + var data; + data=Loader.getRes(this._url); + if (!data)return; + this._initData(data); + } + + /**@private */ + __proto._initState=function(){ + this._reset(); + this._ended=false; + var preState=this._playing; + this._playing=false; + this._curIndex=0; + while (!this._ended)this._parse(++this._curIndex); + this._playing=preState; + } + + /**@private */ + __proto._initData=function(data){ + this._data=new Byte(data); + var i=0,len=this._data.getUint16(); + for (i=0;i < len;i++)this._ids[this._data.getInt16()]=this._data.getInt32(); + this.interval=1000 / this._data.getUint16(); + this._setData(this._data,this._ids[32767]); + this._initState(); + this.play(0); + this.event(/*laya.events.Event.LOADED*/"loaded"); + if (!this._parentMovieClip)Laya.timer.loop(this.interval,this,this.updates,null,true); + } + + /**当前播放索引。*/ + __getset(0,__proto,'index',function(){ + return this._playIndex; + },function(value){ + this._playIndex=value; + if (this._data) + this._displayFrame(this._playIndex); + if (this._labels && this._labels[value])this.event(/*laya.events.Event.LABEL*/"label",this._labels[value]); + }); + + /** + *帧总数。 + */ + __getset(0,__proto,'count',function(){ + return this._count; + }); + + /** + *是否在播放中 + */ + __getset(0,__proto,'playing',function(){ + return this._playing; + }); + + /** + *资源地址。 + */ + __getset(0,__proto,'url',null,function(path){ + this.load(path); + }); + + MovieClip._ValueList=["x","y","width","height","scaleX","scaleY","rotation","alpha"]; + return MovieClip; + })(Sprite) + + + /** + *动画模板类 + */ + //class laya.ani.bone.Templet extends laya.ani.AnimationTemplet + var Templet=(function(_super){ + function Templet(){ + this._mainTexture=null; + this._textureJson=null; + this._graphicsCache=[]; + this.srcBoneMatrixArr=[]; + this.ikArr=[]; + this.tfArr=[]; + this.pathArr=[]; + this.boneSlotDic={}; + this.bindBoneBoneSlotDic={}; + this.boneSlotArray=[]; + this.skinDataArray=[]; + this.skinDic={}; + this.subTextureDic={}; + this.isParseFail=false; + this.url=null; + this.yReverseMatrix=null; + this.drawOrderAniArr=[]; + this.eventAniArr=[]; + this.attachmentNames=null; + this.deformAniArr=[]; + this._rate=60; + this.aniSectionDic={}; + this._skBufferUrl=null; + this._textureDic={}; + this._loadList=null; + this._path=null; + this.mRootBone=null; + Templet.__super.call(this); + this.skinSlotDisplayDataArr=[]; + this.mBoneArr=[]; + } + + __class(Templet,'laya.ani.bone.Templet',_super); + var __proto=Templet.prototype; + __proto.loadAni=function(url){ + this._skBufferUrl=url; + Laya.loader.load(url,Handler.create(this,this.onComplete),null,/*laya.net.Loader.BUFFER*/"arraybuffer"); + } + + __proto.onComplete=function(content){ + var tSkBuffer=Loader.getRes(this._skBufferUrl); + this._path=this._skBufferUrl.slice(0,this._skBufferUrl.lastIndexOf("/"))+"/"; + this.parseData(null,tSkBuffer); + } + + /** + *解析骨骼动画数据 + *@param texture 骨骼动画用到的纹理 + *@param skeletonData 骨骼动画信息及纹理分块信息 + *@param playbackRate 缓冲的帧率数据(会根据帧率去分帧) + */ + __proto.parseData=function(texture,skeletonData,playbackRate){ + (playbackRate===void 0)&& (playbackRate=60); + this._mainTexture=texture; + if (this._mainTexture){ + if (Render.isWebGL && texture.bitmap){ + texture.bitmap.enableMerageInAtlas=false; + } + } + this._rate=playbackRate; + this.parse(skeletonData); + } + + /** + *创建动画 + *0,使用模板缓冲的数据,模板缓冲的数据,不允许修改 (内存开销小,计算开销小,不支持换装) + *1,使用动画自己的缓冲区,每个动画都会有自己的缓冲区,相当耗费内存 (内存开销大,计算开销小,支持换装) + *2,使用动态方式,去实时去画 (内存开销小,计算开销大,支持换装,不建议使用) + *@param aniMode 0 动画模式,0:不支持换装,1,2支持换装 + *@return + */ + __proto.buildArmature=function(aniMode){ + (aniMode===void 0)&& (aniMode=0); + return new Skeleton(this,aniMode); + } + + /** + *@private + *解析动画 + *@param data 解析的二进制数据 + *@param playbackRate 帧率 + */ + __proto.parse=function(data){ + _super.prototype.parse.call(this,data); + this._endLoaded(); + if (this._aniVersion !=AnimationTemplet.LAYA_ANIMATION_VISION){ + console.log("[Error] 版本不一致,请使用IDE版本(1.5.3)重新导出"); + this._loaded=false; + } + if (this._loaded){ + if (this._mainTexture){ + this._parsePublicExtData(); + }else { + this._parseTexturePath(); + } + }else { + this.event(/*laya.events.Event.ERROR*/"error",this); + this.isParseFail=true; + } + } + + __proto._parseTexturePath=function(){ + var i=0; + this._loadList=[]; + var tByte=new Byte(this.getPublicExtData()); + var tX=0,tY=0,tWidth=0,tHeight=0; + var tFrameX=0,tFrameY=0,tFrameWidth=0,tFrameHeight=0; + var tTempleData=0; + var tTextureLen=tByte.getUint8(); + var tTextureName=tByte.readUTFString(); + var tTextureNameArr=tTextureName.split("\n"); + var tTexture; + var tSrcTexturePath; + for (i=0;i < tTextureLen;i++){ + tSrcTexturePath=this._path+tTextureNameArr[i *2]; + tTextureName=tTextureNameArr[i *2+1]; + tX=tByte.getFloat32(); + tY=tByte.getFloat32(); + tWidth=tByte.getFloat32(); + tHeight=tByte.getFloat32(); + tTempleData=tByte.getFloat32(); + tFrameX=isNaN(tTempleData)? 0 :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameY=isNaN(tTempleData)? 0 :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameWidth=isNaN(tTempleData)? tWidth :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameHeight=isNaN(tTempleData)? tHeight :tTempleData; + if (this._loadList.indexOf(tSrcTexturePath)==-1){ + this._loadList.push(tSrcTexturePath); + } + } + Laya.loader.load(this._loadList,Handler.create(this,this._textureComplete)); + } + + /** + *纹理加载完成 + */ + __proto._textureComplete=function(){ + var tTexture; + var tTextureName; + for (var i=0,n=this._loadList.length;i < n;i++){ + tTextureName=this._loadList[i]; + tTexture=this._textureDic[tTextureName]=Loader.getRes(tTextureName); + if (Render.isWebGL && tTexture && tTexture.bitmap){ + tTexture.bitmap.enableMerageInAtlas=false; + } + } + this._parsePublicExtData(); + } + + /** + *解析自定义数据 + */ + __proto._parsePublicExtData=function(){ + var i=0,j=0,k=0,l=0,n=0; + for (i=0,n=this.getAnimationCount();i < n;i++){ + this._graphicsCache.push([]); + }; + var tByte=new Byte(this.getPublicExtData()); + var tX=0,tY=0,tWidth=0,tHeight=0; + var tFrameX=0,tFrameY=0,tFrameWidth=0,tFrameHeight=0; + var tTempleData=0; + var tTextureLen=tByte.getUint8(); + var tTextureName=tByte.readUTFString(); + var tTextureNameArr=tTextureName.split("\n"); + var tTexture; + var tSrcTexturePath; + for (i=0;i < tTextureLen;i++){ + tTexture=this._mainTexture; + tSrcTexturePath=this._path+tTextureNameArr[i *2]; + tTextureName=tTextureNameArr[i *2+1]; + if (this._mainTexture==null){ + tTexture=this._textureDic[tSrcTexturePath]; + } + tX=tByte.getFloat32(); + tY=tByte.getFloat32(); + tWidth=tByte.getFloat32(); + tHeight=tByte.getFloat32(); + tTempleData=tByte.getFloat32(); + tFrameX=isNaN(tTempleData)? 0 :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameY=isNaN(tTempleData)? 0 :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameWidth=isNaN(tTempleData)? tWidth :tTempleData; + tTempleData=tByte.getFloat32(); + tFrameHeight=isNaN(tTempleData)? tHeight :tTempleData; + this.subTextureDic[tTextureName]=Texture.create(tTexture,tX,tY,tWidth,tHeight,-tFrameX,-tFrameY,tFrameWidth,tFrameHeight); + } + this._mainTexture=tTexture; + var tAniCount=tByte.getUint16(); + var tSectionArr; + for (i=0;i < tAniCount;i++){ + tSectionArr=[]; + tSectionArr.push(tByte.getUint16()); + tSectionArr.push(tByte.getUint16()); + tSectionArr.push(tByte.getUint16()); + tSectionArr.push(tByte.getUint16()); + this.aniSectionDic[i]=tSectionArr; + }; + var tBone; + var tParentBone; + var tName; + var tParentName; + var tBoneLen=tByte.getInt16(); + var tBoneDic={}; + var tRootBone; + for (i=0;i < tBoneLen;i++){ + tBone=new Bone(); + if (i==0){ + tRootBone=tBone; + }else { + tBone.root=tRootBone; + } + tName=tByte.readUTFString(); + tParentName=tByte.readUTFString(); + tBone.length=tByte.getFloat32(); + if (tByte.getByte()==1){ + tBone.inheritRotation=false; + } + if (tByte.getByte()==1){ + tBone.inheritScale=false; + } + tBone.name=tName; + if (tParentName){ + tParentBone=tBoneDic[tParentName]; + if (tParentBone){ + tParentBone.addChild(tBone); + }else { + this.mRootBone=tBone; + } + } + tBoneDic[tName]=tBone; + this.mBoneArr.push(tBone); + }; + var tMatrixDataLen=tByte.getUint16(); + var tLen=tByte.getUint16(); + var parentIndex=0; + var boneLength=Math.floor(tLen / tMatrixDataLen); + var tResultTransform; + var tMatrixArray=this.srcBoneMatrixArr; + for (i=0;i < boneLength;i++){ + tResultTransform=new Transform(); + tResultTransform.scX=tByte.getFloat32(); + tResultTransform.skX=tByte.getFloat32(); + tResultTransform.skY=tByte.getFloat32(); + tResultTransform.scY=tByte.getFloat32(); + tResultTransform.x=tByte.getFloat32(); + tResultTransform.y=tByte.getFloat32(); + tMatrixArray.push(tResultTransform); + tBone=this.mBoneArr[i]; + tBone.transform=tResultTransform; + }; + var tIkConstraintData; + var tIkLen=tByte.getUint16(); + var tIkBoneLen=0; + for (i=0;i < tIkLen;i++){ + tIkConstraintData=new IkConstraintData(); + tIkBoneLen=tByte.getUint16(); + for (j=0;j < tIkBoneLen;j++){ + tIkConstraintData.boneNames.push(tByte.readUTFString()); + tIkConstraintData.boneIndexs.push(tByte.getInt16()); + } + tIkConstraintData.name=tByte.readUTFString(); + tIkConstraintData.targetBoneName=tByte.readUTFString(); + tIkConstraintData.targetBoneIndex=tByte.getInt16(); + tIkConstraintData.bendDirection=tByte.getFloat32(); + tIkConstraintData.mix=tByte.getFloat32(); + this.ikArr.push(tIkConstraintData); + }; + var tTfConstraintData; + var tTfLen=tByte.getUint16(); + var tTfBoneLen=0; + for (i=0;i < tTfLen;i++){ + tTfConstraintData=new TfConstraintData(); + tTfBoneLen=tByte.getUint16(); + for (j=0;j < tTfBoneLen;j++){ + tTfConstraintData.boneIndexs.push(tByte.getInt16()); + } + tTfConstraintData.name=tByte.getUTFString(); + tTfConstraintData.targetIndex=tByte.getInt16(); + tTfConstraintData.rotateMix=tByte.getFloat32(); + tTfConstraintData.translateMix=tByte.getFloat32(); + tTfConstraintData.scaleMix=tByte.getFloat32(); + tTfConstraintData.shearMix=tByte.getFloat32(); + tTfConstraintData.offsetRotation=tByte.getFloat32(); + tTfConstraintData.offsetX=tByte.getFloat32(); + tTfConstraintData.offsetY=tByte.getFloat32(); + tTfConstraintData.offsetScaleX=tByte.getFloat32(); + tTfConstraintData.offsetScaleY=tByte.getFloat32(); + tTfConstraintData.offsetShearY=tByte.getFloat32(); + this.tfArr.push(tTfConstraintData); + }; + var tPathConstraintData; + var tPathLen=tByte.getUint16(); + var tPathBoneLen=0; + for (i=0;i < tPathLen;i++){ + tPathConstraintData=new PathConstraintData(); + tPathConstraintData.name=tByte.readUTFString(); + tPathBoneLen=tByte.getUint16(); + for (j=0;j < tPathBoneLen;j++){ + tPathConstraintData.bones.push(tByte.getInt16()); + } + tPathConstraintData.target=tByte.readUTFString(); + tPathConstraintData.positionMode=tByte.readUTFString(); + tPathConstraintData.spacingMode=tByte.readUTFString(); + tPathConstraintData.rotateMode=tByte.readUTFString(); + tPathConstraintData.offsetRotation=tByte.getFloat32(); + tPathConstraintData.position=tByte.getFloat32(); + tPathConstraintData.spacing=tByte.getFloat32(); + tPathConstraintData.rotateMix=tByte.getFloat32(); + tPathConstraintData.translateMix=tByte.getFloat32(); + this.pathArr.push(tPathConstraintData); + }; + var tDeformSlotLen=0; + var tDeformSlotDisplayLen=0; + var tDSlotIndex=0; + var tDAttachment; + var tDeformTimeLen=0; + var tDTime=NaN; + var tDeformVecticesLen=0; + var tDeformAniData; + var tDeformSlotData; + var tDeformSlotDisplayData; + var tDeformVectices; + var tDeformAniLen=tByte.getInt16(); + for (i=0;i < tDeformAniLen;i++){ + var tDeformSkinLen=tByte.getUint8(); + var tSkinDic={}; + this.deformAniArr.push(tSkinDic); + for (var f=0;f < tDeformSkinLen;f++){ + tDeformAniData=new DeformAniData(); + tDeformAniData.skinName=tByte.getUTFString(); + tSkinDic[tDeformAniData.skinName]=tDeformAniData; + tDeformSlotLen=tByte.getInt16(); + for (j=0;j < tDeformSlotLen;j++){ + tDeformSlotData=new DeformSlotData(); + tDeformAniData.deformSlotDataList.push(tDeformSlotData); + tDeformSlotDisplayLen=tByte.getInt16(); + for (k=0;k < tDeformSlotDisplayLen;k++){ + tDeformSlotDisplayData=new DeformSlotDisplayData(); + tDeformSlotData.deformSlotDisplayList.push(tDeformSlotDisplayData); + tDeformSlotDisplayData.slotIndex=tDSlotIndex=tByte.getInt16(); + tDeformSlotDisplayData.attachment=tDAttachment=tByte.getUTFString(); + tDeformTimeLen=tByte.getInt16(); + for (l=0;l < tDeformTimeLen;l++){ + if (tByte.getByte()==1){ + tDeformSlotDisplayData.tweenKeyList.push(true); + }else { + tDeformSlotDisplayData.tweenKeyList.push(false); + } + tDTime=tByte.getFloat32(); + tDeformSlotDisplayData.timeList.push(tDTime); + tDeformVectices=[]; + tDeformSlotDisplayData.vectices.push(tDeformVectices); + tDeformVecticesLen=tByte.getInt16(); + for (n=0;n < tDeformVecticesLen;n++){ + tDeformVectices.push(tByte.getFloat32()); + } + } + } + } + } + }; + var tDrawOrderArr; + var tDrawOrderAniLen=tByte.getInt16(); + var tDrawOrderLen=0; + var tDrawOrderData; + var tDoLen=0; + for (i=0;i < tDrawOrderAniLen;i++){ + tDrawOrderLen=tByte.getInt16(); + tDrawOrderArr=[]; + for (j=0;j < tDrawOrderLen;j++){ + tDrawOrderData=new DrawOrderData(); + tDrawOrderData.time=tByte.getFloat32(); + tDoLen=tByte.getInt16(); + for (k=0;k < tDoLen;k++){ + tDrawOrderData.drawOrder.push(tByte.getInt16()); + } + tDrawOrderArr.push(tDrawOrderData); + } + this.drawOrderAniArr.push(tDrawOrderArr); + }; + var tEventArr; + var tEventAniLen=tByte.getInt16(); + var tEventLen=0; + var tEventData; + for (i=0;i < tEventAniLen;i++){ + tEventLen=tByte.getInt16(); + tEventArr=[]; + for (j=0;j < tEventLen;j++){ + tEventData=new EventData(); + tEventData.name=tByte.getUTFString(); + tEventData.intValue=tByte.getInt32(); + tEventData.floatValue=tByte.getFloat32(); + tEventData.stringValue=tByte.getUTFString(); + tEventData.time=tByte.getFloat32(); + tEventArr.push(tEventData); + } + this.eventAniArr.push(tEventArr); + }; + var tAttachmentLen=tByte.getInt16(); + if (tAttachmentLen > 0){ + this.attachmentNames=[]; + for (i=0;i < tAttachmentLen;i++){ + this.attachmentNames.push(tByte.getUTFString()); + } + }; + var tBoneSlotLen=tByte.getInt16(); + var tDBBoneSlot; + var tDBBoneSlotArr; + for (i=0;i < tBoneSlotLen;i++){ + tDBBoneSlot=new BoneSlot(); + tDBBoneSlot.name=tByte.readUTFString(); + tDBBoneSlot.parent=tByte.readUTFString(); + tDBBoneSlot.attachmentName=tByte.readUTFString(); + tDBBoneSlot.srcDisplayIndex=tDBBoneSlot.displayIndex=tByte.getInt16(); + tDBBoneSlot.templet=this; + this.boneSlotDic[tDBBoneSlot.name]=tDBBoneSlot; + tDBBoneSlotArr=this.bindBoneBoneSlotDic[tDBBoneSlot.parent]; + if (tDBBoneSlotArr==null){ + this.bindBoneBoneSlotDic[tDBBoneSlot.parent]=tDBBoneSlotArr=[]; + } + tDBBoneSlotArr.push(tDBBoneSlot); + this.boneSlotArray.push(tDBBoneSlot); + }; + var tNameString=tByte.readUTFString(); + var tNameArray=tNameString.split("\n"); + var tNameStartIndex=0; + var tSkinDataLen=tByte.getUint8(); + var tSkinData,tSlotData,tDisplayData; + var tSlotDataLen=0,tDisplayDataLen=0; + var tUvLen=0,tWeightLen=0,tTriangleLen=0,tVerticeLen=0,tLengthLen=0; + for (i=0;i < tSkinDataLen;i++){ + tSkinData=new SkinData(); + tSkinData.name=tNameArray[tNameStartIndex++]; + tSlotDataLen=tByte.getUint8(); + for (j=0;j < tSlotDataLen;j++){ + tSlotData=new SlotData(); + tSlotData.name=tNameArray[tNameStartIndex++]; + tDBBoneSlot=this.boneSlotDic[tSlotData.name]; + tDisplayDataLen=tByte.getUint8(); + for (k=0;k < tDisplayDataLen;k++){ + tDisplayData=new SkinSlotDisplayData(); + this.skinSlotDisplayDataArr.push(tDisplayData); + tDisplayData.name=tNameArray[tNameStartIndex++]; + tDisplayData.attachmentName=tNameArray[tNameStartIndex++]; + tDisplayData.transform=new Transform(); + tDisplayData.transform.scX=tByte.getFloat32(); + tDisplayData.transform.skX=tByte.getFloat32(); + tDisplayData.transform.skY=tByte.getFloat32(); + tDisplayData.transform.scY=tByte.getFloat32(); + tDisplayData.transform.x=tByte.getFloat32(); + tDisplayData.transform.y=tByte.getFloat32(); + tSlotData.displayArr.push(tDisplayData); + tDisplayData.width=tByte.getFloat32(); + tDisplayData.height=tByte.getFloat32(); + tDisplayData.type=tByte.getUint8(); + tDisplayData.verLen=tByte.getUint16(); + tBoneLen=tByte.getUint16(); + if (tBoneLen > 0){ + tDisplayData.bones=[]; + for (l=0;l < tBoneLen;l++){ + var tBoneId=tByte.getUint16(); + tDisplayData.bones.push(tBoneId); + } + } + tUvLen=tByte.getUint16(); + if (tUvLen > 0){ + tDisplayData.uvs=[]; + for (l=0;l < tUvLen;l++){ + tDisplayData.uvs.push(tByte.getFloat32()); + } + } + tWeightLen=tByte.getUint16(); + if (tWeightLen > 0){ + tDisplayData.weights=[]; + for (l=0;l < tWeightLen;l++){ + tDisplayData.weights.push(tByte.getFloat32()); + } + } + tTriangleLen=tByte.getUint16(); + if (tTriangleLen > 0){ + tDisplayData.triangles=[]; + for (l=0;l < tTriangleLen;l++){ + tDisplayData.triangles.push(tByte.getUint16()); + } + } + tVerticeLen=tByte.getUint16(); + if (tVerticeLen > 0){ + tDisplayData.vertices=[]; + for (l=0;l < tVerticeLen;l++){ + tDisplayData.vertices.push(tByte.getFloat32()); + } + } + tLengthLen=tByte.getUint16(); + if (tLengthLen > 0){ + tDisplayData.lengths=[]; + for (l=0;l < tLengthLen;l++){ + tDisplayData.lengths.push(tByte.getFloat32()); + } + } + } + tSkinData.slotArr.push(tSlotData); + } + this.skinDic[tSkinData.name]=tSkinData; + this.skinDataArray.push(tSkinData); + }; + var tReverse=tByte.getUint8(); + if (tReverse==1){ + this.yReverseMatrix=new Matrix(1,0,0,-1,0,0); + if (tRootBone){ + tRootBone.setTempMatrix(this.yReverseMatrix); + } + }else { + if (tRootBone){ + tRootBone.setTempMatrix(new Matrix()); + } + } + this.showSkinByIndex(this.boneSlotDic,0); + this.event(/*laya.events.Event.COMPLETE*/"complete",this); + } + + /** + *得到指定的纹理 + *@param name 纹理的名字 + *@return + */ + __proto.getTexture=function(name){ + var tTexture=this.subTextureDic[name]; + if (tTexture==null){ + return this._mainTexture; + } + return tTexture; + } + + /** + *@private + *显示指定的皮肤 + *@param boneSlotDic 插糟字典的引用 + *@param skinIndex 皮肤的索引 + */ + __proto.showSkinByIndex=function(boneSlotDic,skinIndex){ + if (skinIndex < 0 && skinIndex >=this.skinDataArray.length)return false; + var i=0,n=0; + var tBoneSlot; + var tSlotData; + var tSkinData=this.skinDataArray[skinIndex]; + if (tSkinData){ + for (i=0,n=tSkinData.slotArr.length;i < n;i++){ + tSlotData=tSkinData.slotArr[i]; + if (tSlotData){ + tBoneSlot=boneSlotDic[tSlotData.name]; + if (tBoneSlot){ + tBoneSlot.showSlotData(tSlotData); + if (tBoneSlot.attachmentName !="undefined" && tBoneSlot.attachmentName !="null"){ + tBoneSlot.showDisplayByName(tBoneSlot.attachmentName); + }else { + tBoneSlot.showDisplayByIndex(tBoneSlot.displayIndex); + } + } + } + } + return true; + } + return false; + } + + /** + *通过皮肤名字得到皮肤索引 + *@param skinName 皮肤名称 + *@return + */ + __proto.getSkinIndexByName=function(skinName){ + var tSkinData; + for (var i=0,n=this.skinDataArray.length;i < n;i++){ + tSkinData=this.skinDataArray[i]; + if (tSkinData.name==skinName){ + return i; + } + } + return-1; + } + + /** + *@private + *得到缓冲数据 + *@param aniIndex 动画索引 + *@param frameIndex 帧索引 + *@return + */ + __proto.getGrahicsDataWithCache=function(aniIndex,frameIndex){ + return this._graphicsCache[aniIndex][frameIndex]; + } + + /** + *@private + *保存缓冲grahpics + *@param aniIndex 动画索引 + *@param frameIndex 帧索引 + *@param graphics 要保存的数据 + */ + __proto.setGrahicsDataWithCache=function(aniIndex,frameIndex,graphics){ + this._graphicsCache[aniIndex][frameIndex]=graphics; + } + + /** + *释放纹理 + */ + __proto.destroy=function(){ + var tTexture; + /*for each*/for(var $each_tTexture in this.subTextureDic){ + tTexture=this.subTextureDic[$each_tTexture]; + tTexture.destroy(); + } + var $each_tTexture; + /*for each*/for($each_tTexture in this._textureDic){ + tTexture=this._textureDic[$each_tTexture]; + tTexture.destroy(); + }; + var tSkinSlotDisplayData; + for (var i=0,n=this.skinSlotDisplayDataArr.length;i < n;i++){ + tSkinSlotDisplayData=this.skinSlotDisplayDataArr[i]; + tSkinSlotDisplayData.destory(); + } + this.skinSlotDisplayDataArr.length=0; + if (this.url){ + delete Templet.TEMPLET_DICTIONARY[this.url]; + } + } + + /** + *通过索引得动画名称 + *@param index + *@return + */ + __proto.getAniNameByIndex=function(index){ + var tAni=this.getAnimation(index); + if (tAni)return tAni.name; + return null; + } + + __getset(0,__proto,'rate',function(){ + return this._rate; + }); + + Templet.TEMPLET_DICTIONARY=null + return Templet; + })(AnimationTemplet) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.core.js b/games/laya-snakes/libs/laya.core.js new file mode 100644 index 0000000..ec6ae9c --- /dev/null +++ b/games/laya-snakes/libs/laya.core.js @@ -0,0 +1,25238 @@ +var window = window || global; +var document = document || (window.document = {}); +/***********************************/ +/*http://www.layabox.com 2016/11/25*/ +/***********************************/ +var Laya=window.Laya=(function(window,document){ + var Laya={ + __internals:[], + __packages:{}, + __classmap:{'Object':Object,'Function':Function,'Array':Array,'String':String}, + __sysClass:{'object':'Object','array':'Array','string':'String','dictionary':'Dictionary'}, + __propun:{writable: true,enumerable: false,configurable: true}, + __presubstr:String.prototype.substr, + __substr:function(ofs,sz){return arguments.length==1?Laya.__presubstr.call(this,ofs):Laya.__presubstr.call(this,ofs,sz>0?sz:(this.length+sz));}, + __init:function(_classs){_classs.forEach(function(o){o.__init$ && o.__init$();});}, + __isClass:function(o){return o && (o.__isclass || o==Object || o==String || o==Array);}, + __newvec:function(sz,value){ + var d=[]; + d.length=sz; + for(var i=0;i1){ + for(var i=0,sz=strs.length-1;i0){ + if(fullName.indexOf('laya.')==0){ + var paths=fullName.split('.'); + miniName=miniName || paths[paths.length-1]; + if(Laya[miniName]) console.log("Warning!,this class["+miniName+"] already exist:",Laya[miniName]); + Laya[miniName]=o; + } + } + else { + if(fullName=="Main") + window.Main=o; + else{ + if(Laya[fullName]){ + console.log("Error!,this class["+fullName+"] already exist:",Laya[fullName]); + } + Laya[fullName]=o; + } + } + } + var un=Laya.un,p=o.prototype; + un(p,'hasOwnProperty',Laya.__hasOwnProperty); + un(p,'__class',o); + un(p,'__super',_super); + un(p,'__className',fullName); + un(o,'__super',_super); + un(o,'__className',fullName); + un(o,'__isclass',true); + un(o,'super',function(o){this.__super.call(o);}); + }, + imps:function(dec,src){ + if(!src) return null; + var d=dec.__imps|| Laya.un(dec,'__imps',{}); + function __(name){ + var c,exs; + if(! (c=Laya.__internals[name]) ) return; + d[name]=true; + if(!(exs=c.extend)) return; + for(var i=0;iLaya 是全局对象的引用入口集。 + */ + //class Laya + var ___Laya=(function(){ + //function Laya(){}; + /** + *表示是否捕获全局错误并弹出提示。 + */ + __getset(1,Laya,'alertGlobalError',null,function(value){ + var erralert=0; + if (value){ + Browser.window.onerror=function (msg,url,line,column,detail){ + if (erralert++< 5 && detail) + alert("出错啦,请把此信息截图给研发商\n"+msg+"\n"+detail.stack); + } + }else { + Browser.window.onerror=null; + } + }); + + Laya.init=function(width,height,__plugins){ + var plugins=[];for(var i=2,sz=arguments.length;iEventDispatcher 类是可调度事件的所有类的基类。 + */ + //class laya.events.EventDispatcher + var EventDispatcher=(function(){ + var EventHandler; + function EventDispatcher(){ + this._events=null; + } + + __class(EventDispatcher,'laya.events.EventDispatcher'); + var __proto=EventDispatcher.prototype; + /** + *检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。 + *@param type 事件的类型。 + *@return 如果指定类型的侦听器已注册,则值为 true;否则,值为 false。 + */ + __proto.hasListener=function(type){ + var listener=this._events && this._events[type]; + return !!listener; + } + + /** + *派发事件。 + *@param type 事件类型。 + *@param data 回调数据。 + *注意:如果是需要传递多个参数 p1,p2,p3,...可以使用数组结构如:[p1,p2,p3,...] ;如果需要回调单个参数 p 是一个数组,则需要使用结构如:[p],其他的单个参数 p ,可以直接传入参数 p。 + *@return 此事件类型是否有侦听者,如果有侦听者则值为 true,否则值为 false。 + */ + __proto.event=function(type,data){ + if (!this._events || !this._events[type])return false; + var listeners=this._events[type]; + if (listeners.run){ + if (listeners.once)delete this._events[type]; + data !=null ? listeners.runWith(data):listeners.run(); + }else { + for (var i=0,n=listeners.length;i < n;i++){ + var listener=listeners[i]; + if (listener){ + (data !=null)? listener.runWith(data):listener.run(); + } + if (!listener || listener.once){ + listeners.splice(i,1); + i--; + n--; + } + } + if (listeners.length===0)delete this._events[type]; + } + return true; + } + + /** + *使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知。 + *@param type 事件的类型。 + *@param caller 事件侦听函数的执行域。 + *@param listener 事件侦听函数。 + *@param args 事件侦听函数的回调参数。 + *@return 此 EventDispatcher 对象。 + */ + __proto.on=function(type,caller,listener,args){ + return this._createListener(type,caller,listener,args,false); + } + + /** + *使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知,此侦听事件响应一次后自动移除。 + *@param type 事件的类型。 + *@param caller 事件侦听函数的执行域。 + *@param listener 事件侦听函数。 + *@param args 事件侦听函数的回调参数。 + *@return 此 EventDispatcher 对象。 + */ + __proto.once=function(type,caller,listener,args){ + return this._createListener(type,caller,listener,args,true); + } + + /**@private */ + __proto._createListener=function(type,caller,listener,args,once,offBefore){ + (offBefore===void 0)&& (offBefore=true); + offBefore && this.off(type,caller,listener,once); + var handler=EventHandler.create(caller || this,listener,args,once); + this._events || (this._events={}); + var events=this._events; + if (!events[type])events[type]=handler; + else { + if (!events[type].run)events[type].push(handler); + else events[type]=[events[type],handler]; + } + return this; + } + + /** + *从 EventDispatcher 对象中删除侦听器。 + *@param type 事件的类型。 + *@param caller 事件侦听函数的执行域。 + *@param listener 事件侦听函数。 + *@param onceOnly 如果值为 true ,则只移除通过 once 方法添加的侦听器。 + *@return 此 EventDispatcher 对象。 + */ + __proto.off=function(type,caller,listener,onceOnly){ + (onceOnly===void 0)&& (onceOnly=false); + if (!this._events || !this._events[type])return this; + var listeners=this._events[type]; + if (listener !=null){ + if (listeners.run){ + if ((!caller || listeners.caller===caller)&& listeners.method===listener && (!onceOnly || listeners.once)){ + delete this._events[type]; + listeners.recover(); + } + }else { + var count=0; + for (var i=0,n=listeners.length;i < n;i++){ + var item=listeners[i]; + if (item && (!caller || item.caller===caller)&& item.method===listener && (!onceOnly || item.once)){ + count++; + listeners[i]=null; + item.recover(); + } + } + if (count===n)delete this._events[type]; + } + } + return this; + } + + /** + *从 EventDispatcher 对象中删除指定事件类型的所有侦听器。 + *@param type 事件类型,如果值为 null,则移除本对象所有类型的侦听器。 + *@return 此 EventDispatcher 对象。 + */ + __proto.offAll=function(type){ + var events=this._events; + if (!events)return this; + if (type){ + this._recoverHandlers(events[type]); + delete events[type]; + }else { + for (var name in events){ + this._recoverHandlers(events[name]); + } + this._events=null; + } + return this; + } + + __proto._recoverHandlers=function(arr){ + if (!arr)return; + if (arr.run){ + arr.recover(); + }else { + for (var i=arr.length-1;i >-1;i--){ + if (arr[i]){ + arr[i].recover(); + arr[i]=null; + } + } + } + } + + /** + *检测指定事件类型是否是鼠标事件。 + *@param type 事件的类型。 + *@return 如果是鼠标事件,则值为 true;否则,值为 false。 + */ + __proto.isMouseEvent=function(type){ + return EventDispatcher.MOUSE_EVENTS[type]; + } + + EventDispatcher.MOUSE_EVENTS={"rightmousedown":true,"rightmouseup":true,"rightclick":true,"mousedown":true,"mouseup":true,"mousemove":true,"mouseover":true,"mouseout":true,"click":true,"doubleclick":true}; + EventDispatcher.__init$=function(){ + /**@private */ + //class EventHandler extends laya.utils.Handler + EventHandler=(function(_super){ + function EventHandler(caller,method,args,once){ + EventHandler.__super.call(this,caller,method,args,once); + } + __class(EventHandler,'',_super); + var __proto=EventHandler.prototype; + __proto.recover=function(){ + if (this._id > 0){ + this._id=0; + EventHandler._pool.push(this.clear()); + } + } + EventHandler.create=function(caller,method,args,once){ + (once===void 0)&& (once=true); + if (EventHandler._pool.length)return EventHandler._pool.pop().setTo(caller,method,args,once); + return new EventHandler(caller,method,args,once); + } + EventHandler._pool=[]; + return EventHandler; + })(Handler) + } + + return EventDispatcher; + })() + + + /** + *

    Handler 是事件处理器类。

    + *

    推荐使用 Handler.create()方法从对象池创建,减少对象创建消耗。

    + *

    注意:由于鼠标事件也用本对象池,不正确的回收及调用,可能会影响鼠标事件的执行。

    + */ + //class laya.utils.Handler + var Handler=(function(){ + function Handler(caller,method,args,once){ + //this.caller=null; + //this.method=null; + //this.args=null; + this.once=false; + this._id=0; + (once===void 0)&& (once=false); + this.setTo(caller,method,args,once); + } + + __class(Handler,'laya.utils.Handler'); + var __proto=Handler.prototype; + /** + *设置此对象的指定属性值。 + *@param caller 执行域(this)。 + *@param method 回调方法。 + *@param args 携带的参数。 + *@param once 是否只执行一次,如果为true,执行后执行recover()进行回收。 + *@return 返回 handler 本身。 + */ + __proto.setTo=function(caller,method,args,once){ + this._id=Handler._gid++; + this.caller=caller; + this.method=method; + this.args=args; + this.once=once; + return this; + } + + /** + *执行处理器。 + */ + __proto.run=function(){ + if (this.method==null)return null; + var id=this._id; + var result=this.method.apply(this.caller,this.args); + this._id===id && this.once && this.recover(); + return result; + } + + /** + *执行处理器,携带额外数据。 + *@param data 附加的回调数据,可以是单数据或者Array(作为多参)。 + */ + __proto.runWith=function(data){ + if (this.method==null)return null; + var id=this._id; + if (data==null) + var result=this.method.apply(this.caller,this.args); + else if (!this.args && !data.unshift)result=this.method.call(this.caller,data); + else if (this.args)result=this.method.apply(this.caller,this.args.concat(data)); + else result=this.method.apply(this.caller,data); + this._id===id && this.once && this.recover(); + return result; + } + + /** + *清理对象引用。 + */ + __proto.clear=function(){ + this.caller=null; + this.method=null; + this.args=null; + return this; + } + + /** + *清理并回收到 Handler 对象池内。 + */ + __proto.recover=function(){ + if (this._id > 0){ + this._id=0; + Handler._pool.push(this.clear()); + } + } + + Handler.create=function(caller,method,args,once){ + (once===void 0)&& (once=true); + if (Handler._pool.length)return Handler._pool.pop().setTo(caller,method,args,once); + return new Handler(caller,method,args,once); + } + + Handler._pool=[]; + Handler._gid=1; + return Handler; + })() + + + /** + *BitmapFont 是位图字体类,用于定义位图字体信息。 + */ + //class laya.display.BitmapFont + var BitmapFont=(function(){ + function BitmapFont(){ + this.fontSize=12; + this.autoScaleSize=false; + this._texture=null; + this._fontCharDic={}; + this._complete=null; + this._path=null; + this._maxHeight=0; + this._maxWidth=0; + this._spaceWidth=10; + this._leftPadding=0; + this._rightPadding=0; + this._letterSpacing=0; + } + + __class(BitmapFont,'laya.display.BitmapFont'); + var __proto=BitmapFont.prototype; + /** + *通过指定位图字体文件路径,加载位图字体文件。 + *@param path 位图字体文件的路径。 + *@param complete 加载完成的回调,通知上层字体文件已经完成加载并解析。 + */ + __proto.loadFont=function(path,complete){ + this._path=path; + this._complete=complete; + Laya.loader.load([{url:this._path,type:/*laya.net.Loader.XML*/"xml"},{url:this._path.replace(".fnt",".png"),type:/*laya.net.Loader.IMAGE*/"image"}],Handler.create(this,this.onLoaded)); + } + + __proto.onLoaded=function(){ + this.parseFont(Loader.getRes(this._path),Loader.getRes(this._path.replace(".fnt",".png"))); + this._complete && this._complete.run(); + } + + /** + *解析字体文件。 + *@param xml 字体文件XML。 + *@param texture 字体的纹理。 + */ + __proto.parseFont=function(xml,texture){ + if (xml==null || texture==null)return; + this._texture=texture; + var tX=0; + var tScale=1; + var tInfo=xml.getElementsByTagName("info"); + this.fontSize=parseInt(tInfo[0].attributes["size"].nodeValue); + var tPadding=tInfo[0].attributes["padding"].nodeValue; + var tPaddingArray=tPadding.split(","); + var tUpPadding=parseInt(tPaddingArray[0]); + var tDownPadding=parseInt(tPaddingArray[2]); + this._leftPadding=parseInt(tPaddingArray[3]); + this._rightPadding=parseInt(tPaddingArray[1]); + var chars=xml.getElementsByTagName("char"); + var i=0; + for (i=0;i < chars.length;i++){ + var tAttribute=chars[i].attributes; + var tId=parseInt(tAttribute["id"].nodeValue); + var xOffset=parseInt(tAttribute["xoffset"].nodeValue)/ tScale; + var yOffset=parseInt(tAttribute["yoffset"].nodeValue)/ tScale; + var xAdvance=parseInt(tAttribute["xadvance"].nodeValue)/ tScale; + var region=new Rectangle(); + region.x=parseInt(tAttribute["x"].nodeValue); + region.y=parseInt(tAttribute["y"].nodeValue); + region.width=parseInt(tAttribute["width"].nodeValue); + region.height=parseInt(tAttribute["height"].nodeValue); + var tTexture=Texture.create(texture,region.x,region.y,region.width,region.height,xOffset,yOffset); + this._maxHeight=Math.max(this._maxHeight,tUpPadding+tDownPadding+tTexture.height); + this._maxWidth=Math.max(this._maxWidth,tTexture.width); + this._fontCharDic[tId]=tTexture; + } + if (this.getCharTexture(" "))this.setSpaceWidth(this.getCharWidth(" ")); + } + + /** + *获取指定字符的字体纹理对象。 + *@param char 字符。 + *@return 指定的字体纹理对象。 + */ + __proto.getCharTexture=function(char){ + return this._fontCharDic[char.charCodeAt(0)]; + } + + /** + *销毁位图字体,调用Text.unregisterBitmapFont 时,默认会销毁。 + */ + __proto.destroy=function(){ + var tTexture=null; + for (var p in this._fontCharDic){ + tTexture=this._fontCharDic[p]; + if (tTexture)tTexture.destroy(); + delete this._fontCharDic[p]; + } + this._texture.destroy(); + } + + /** + *设置空格的宽(如果字体库有空格,这里就可以不用设置了)。 + *@param spaceWidth 宽度,单位为像素。 + */ + __proto.setSpaceWidth=function(spaceWidth){ + this._spaceWidth=spaceWidth; + } + + /** + *获取指定字符的宽度。 + *@param char 字符。 + *@return 宽度。 + */ + __proto.getCharWidth=function(char){ + if (char==" ")return this._spaceWidth+this._letterSpacing; + var tTexture=this.getCharTexture(char) + if (tTexture)return tTexture.width+tTexture.offsetX *2+this._letterSpacing; + return 0; + } + + /** + *获取指定文本内容的宽度。 + *@param text 文本内容。 + *@return 宽度。 + */ + __proto.getTextWidth=function(text){ + var tWidth=0; + for (var i=0,n=text.length;i < n;i++){ + tWidth+=this.getCharWidth(text.charAt(i)); + } + return tWidth; + } + + /** + *获取最大字符宽度。 + */ + __proto.getMaxWidth=function(){ + return this._maxWidth+this._letterSpacing; + } + + /** + *获取最大字符高度。 + */ + __proto.getMaxHeight=function(){ + return this._maxHeight; + } + + /** + *@private + *将指定的文本绘制到指定的显示对象上。 + */ + __proto.drawText=function(text,sprite,drawX,drawY,align,width){ + var tWidth=0; + var tTexture; + for (var i=0,n=text.length;i < n;i++){ + tWidth+=this.getCharWidth(text.charAt(i)); + }; + var dx=this._leftPadding; + align==="center" && (dx=(width-tWidth)/ 2); + align==="right" && (dx=(width-tWidth)-this._rightPadding); + var tX=0; + for (i=0,n=text.length;i < n;i++){ + tTexture=this.getCharTexture(text.charAt(i)); + if (tTexture)sprite.graphics.drawTexture(tTexture,drawX+tX+dx,drawY,tTexture.width,tTexture.height); + tX+=this.getCharWidth(text.charAt(i)); + } + } + + /** + *设置字符之间的间距(以像素为单位)。 + */ + /** + *获取字符之间的间距(以像素为单位)。 + */ + __getset(0,__proto,'letterSpacing',function(){ + return this._letterSpacing; + },function(value){ + this._letterSpacing=value; + }); + + return BitmapFont; + })() + + + /** + *@private + *Style 类是元素样式定义类。 + */ + //class laya.display.css.Style + var Style=(function(){ + function Style(){ + this.alpha=1; + this.visible=true; + this.scrollRect=null; + this.blendMode=null; + this._type=0; + this._tf=Style._TF_EMPTY; + } + + __class(Style,'laya.display.css.Style'); + var __proto=Style.prototype; + __proto.getTransform=function(){ + return this._tf; + } + + __proto.setTransform=function(value){ + this._tf=value==='none' || !value ? Style._TF_EMPTY :value; + } + + __proto.setTranslateX=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.translateX=value; + } + + __proto.setTranslateY=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.translateY=value; + } + + __proto.setScaleX=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.scaleX=value; + } + + __proto.setScaleY=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.scaleY=value; + } + + __proto.setRotate=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.rotate=value; + } + + __proto.setSkewX=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.skewX=value; + } + + __proto.setSkewY=function(value){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.skewY=value; + } + + /**销毁此对象。*/ + __proto.destroy=function(){ + this.scrollRect=null; + } + + /**@private */ + __proto.render=function(sprite,context,x,y){} + /**@private */ + __proto.getCSSStyle=function(){ + return CSSStyle.EMPTY; + } + + /**@private */ + __proto._enableLayout=function(){ + return false; + } + + /**X 轴缩放值。*/ + __getset(0,__proto,'scaleX',function(){ + return this._tf.scaleX; + },function(value){ + this.setScaleX(value); + }); + + /**元素应用的 2D 或 3D 转换的值。该属性允许我们对元素进行旋转、缩放、移动或倾斜。*/ + __getset(0,__proto,'transform',function(){ + return this.getTransform(); + },function(value){ + this.setTransform(value); + }); + + /**定义转换,只是用 X 轴的值。*/ + __getset(0,__proto,'translateX',function(){ + return this._tf.translateX; + },function(value){ + this.setTranslateX(value); + }); + + /**定义转换,只是用 Y 轴的值。*/ + __getset(0,__proto,'translateY',function(){ + return this._tf.translateY; + },function(value){ + this.setTranslateY(value); + }); + + /**Y 轴缩放值。*/ + __getset(0,__proto,'scaleY',function(){ + return this._tf.scaleY; + },function(value){ + this.setScaleY(value); + }); + + /**表示元素是否显示为块级元素。*/ + __getset(0,__proto,'block',function(){ + return (this._type & 0x1)!=0; + }); + + /**定义沿着 Y 轴的 2D 倾斜转换。*/ + __getset(0,__proto,'skewY',function(){ + return this._tf.skewY; + },function(value){ + this.setSkewY(value); + }); + + /**定义旋转角度。*/ + __getset(0,__proto,'rotate',function(){ + return this._tf.rotate; + },function(value){ + this.setRotate(value); + }); + + /**定义沿着 X 轴的 2D 倾斜转换。*/ + __getset(0,__proto,'skewX',function(){ + return this._tf.skewX; + },function(value){ + this.setSkewX(value); + }); + + /**表示元素的左内边距。*/ + __getset(0,__proto,'paddingLeft',function(){ + return 0; + }); + + /**表示元素的上内边距。*/ + __getset(0,__proto,'paddingTop',function(){ + return 0; + }); + + /**是否为绝对定位。*/ + __getset(0,__proto,'absolute',function(){ + return true; + }); + + Style.__init__=function(){ + Style._TF_EMPTY=new TransformInfo(); + Style.EMPTY=new Style(); + } + + Style.EMPTY=null + Style._TF_EMPTY=null + return Style; + })() + + + /** + *@private + *Font 类是字体显示定义类。 + */ + //class laya.display.css.Font + var Font=(function(){ + function Font(src){ + this._type=0; + this._weight=0; + this._decoration=null; + this._text=null; + this.indent=0; + this._color=Color.create(Font.defaultColor); + this.family=Font.defaultFamily; + this.stroke=Font._STROKE; + this.size=Font.defaultSize; + src && src!==Font.EMPTY && src.copyTo(this); + } + + __class(Font,'laya.display.css.Font'); + var __proto=Font.prototype; + /** + *字体样式字符串。 + */ + __proto.set=function(value){ + this._text=null; + var strs=value.split(' '); + for (var i=0,n=strs.length;i < n;i++){ + var str=strs[i]; + switch (str){ + case 'italic': + this.italic=true; + continue ; + case 'bold': + this.bold=true; + continue ; + } + if (str.indexOf('px')> 0){ + this.size=parseInt(str); + this.family=strs[i+1]; + i++; + continue ; + } + } + } + + /** + *返回字体样式字符串。 + *@return 字体样式字符串。 + */ + __proto.toString=function(){ + this._text="" + this.italic && (this._text+="italic "); + this.bold && (this._text+="bold "); + return this._text+=this.size+"px "+this.family; + } + + /** + *将当前的属性值复制到传入的 Font 对象。 + *@param dec 一个 Font 对象。 + */ + __proto.copyTo=function(dec){ + dec._type=this._type; + dec._text=this._text; + dec._weight=this._weight; + dec._color=this._color; + dec.family=this.family; + dec.stroke=this.stroke !=Font._STROKE ? this.stroke.slice():Font._STROKE; + dec.indent=this.indent; + dec.size=this.size; + } + + /** + *表示是否为密码格式。 + */ + __getset(0,__proto,'password',function(){ + return (this._type & 0x400)!==0; + },function(value){ + value ? (this._type |=0x400):(this._type &=~0x400); + }); + + /** + *表示颜色字符串。 + */ + __getset(0,__proto,'color',function(){ + return this._color.strColor; + },function(value){ + this._color=Color.create(value); + }); + + /** + *表示是否为斜体。 + */ + __getset(0,__proto,'italic',function(){ + return (this._type & 0x200)!==0; + },function(value){ + value ? (this._type |=0x200):(this._type &=~0x200); + }); + + /** + *表示是否为粗体。 + */ + __getset(0,__proto,'bold',function(){ + return (this._type & 0x800)!==0; + },function(value){ + value ? (this._type |=0x800):(this._type &=~0x800); + }); + + /** + *文本的粗细。 + */ + __getset(0,__proto,'weight',function(){ + return ""+this._weight; + },function(value){ + var weight=0; + switch (value){ + case 'normal': + break ; + case 'bold': + this.bold=true; + weight=700; + break ; + case 'bolder': + weight=800; + break ; + case 'lighter': + weight=100; + break ; + default : + weight=parseInt(value); + } + this._weight=weight; + this._text=null; + }); + + /** + *规定添加到文本的修饰。 + */ + __getset(0,__proto,'decoration',function(){ + return this._decoration ? this._decoration.value :"none"; + },function(value){ + var strs=value.split(' '); + this._decoration || (this._decoration={}); + switch (strs[0]){ + case '_': + this._decoration.type='underline' + break ; + case '-': + this._decoration.type='line-through' + break ; + case 'overline': + this._decoration.type='overline' + break ; + default : + this._decoration.type=strs[0]; + } + strs[1] && (this._decoration.color=Color.create(strs)); + this._decoration.value=value; + }); + + Font.__init__=function(){ + Font.EMPTY=new Font(null); + } + + Font.EMPTY=null + Font.defaultColor="#000000"; + Font.defaultSize=12; + Font.defaultFamily="Arial"; + Font.defaultFont="12px Arial"; + Font._STROKE=[0,"#000000"]; + Font._ITALIC=0x200; + Font._PASSWORD=0x400; + Font._BOLD=0x800; + return Font; + })() + + + /** + *@private + */ + //class laya.display.css.TransformInfo + var TransformInfo=(function(){ + function TransformInfo(){ + this.translateX=0; + this.translateY=0; + this.scaleX=1; + this.scaleY=1; + this.rotate=0; + this.skewX=0; + this.skewY=0; + } + + __class(TransformInfo,'laya.display.css.TransformInfo'); + return TransformInfo; + })() + + + /** + *Graphics 类用于创建绘图显示对象。 + *@see laya.display.Sprite#graphics + */ + //class laya.display.Graphics + var Graphics=(function(){ + function Graphics(){ + //this._sp=null; + this._one=null; + this._cmds=null; + //this._temp=null; + //this._bounds=null; + //this._rstBoundPoints=null; + //this._vectorgraphArray=null; + this._render=this._renderEmpty; + this._render=this._renderEmpty; + if (Render.isConchNode){ + /*__JS__ */this._nativeObj=new _conchGraphics();; + /*__JS__ */this.id=this._nativeObj.conchID;; + } + } + + __class(Graphics,'laya.display.Graphics'); + var __proto=Graphics.prototype; + /** + *

    销毁此对象。

    + */ + __proto.destroy=function(){ + this.clear(); + this._temp=null; + this._bounds=null; + this._rstBoundPoints=null; + this._sp && (this._sp._renderType=0); + this._sp=null; + } + + /** + *

    清空绘制命令。

    + */ + __proto.clear=function(){ + this._one=null; + this._render=this._renderEmpty; + this._cmds=null; + this._temp && (this._temp.length=0); + this._sp && (this._sp._renderType &=~ /*laya.renders.RenderSprite.IMAGE*/0x01); + this._sp && (this._sp._renderType &=~ /*laya.renders.RenderSprite.GRAPHICS*/0x100); + this._repaint(); + if (this._vectorgraphArray){ + for (var i=0,n=this._vectorgraphArray.length;i < n;i++){ + VectorGraphManager.getInstance().deleteShape(this._vectorgraphArray[i]); + } + this._vectorgraphArray.length=0; + } + } + + /** + *@private + *重绘此对象。 + */ + __proto._repaint=function(){ + this._temp && (this._temp.length=0); + this._sp && this._sp.repaint(); + } + + /**@private */ + __proto._isOnlyOne=function(){ + return !this._cmds || this._cmds.length===0; + } + + /** + *获取位置及宽高信息矩阵(比较耗,尽量少用)。 + *@return 位置与宽高组成的 一个 Rectangle 对象。 + */ + __proto.getBounds=function(){ + if (!this._bounds || !this._temp || this._temp.length < 1){ + this._bounds=Rectangle._getWrapRec(this.getBoundPoints(),this._bounds) + } + return this._bounds; + } + + /** + *@private + *获取端点列表。 + */ + __proto.getBoundPoints=function(){ + if (!this._temp || this._temp.length < 1) + this._temp=this._getCmdPoints(); + return this._rstBoundPoints=Utils.copyArray(this._rstBoundPoints,this._temp); + } + + __proto._addCmd=function(a){ + this._cmds=this._cmds || []; + a.callee=a.shift(); + this._cmds.push(a); + } + + __proto._getCmdPoints=function(){ + var context=Render._context; + var cmds=this._cmds; + var rst; + rst=this._temp || (this._temp=[]); + rst.length=0; + if (!cmds && this._one !=null){ + Graphics._tempCmds.length=0; + Graphics._tempCmds.push(this._one); + cmds=Graphics._tempCmds; + } + if (!cmds) + return rst; + var matrixs; + matrixs=Graphics._tempMatrixArrays; + matrixs.length=0; + var tMatrix=Graphics._initMatrix; + tMatrix.identity(); + var tempMatrix=Graphics._tempMatrix; + var cmd; + for (var i=0,n=cmds.length;i < n;i++){ + cmd=cmds[i]; + switch (cmd.callee){ + case context.save: + case 7: + matrixs.push(tMatrix); + tMatrix=tMatrix.clone(); + break ; + case context.restore: + case 8: + tMatrix=matrixs.pop(); + break ; + case context._scale: + case 5: + tempMatrix.identity(); + tempMatrix.translate(-cmd[2],-cmd[3]); + tempMatrix.scale(cmd[0],cmd[1]); + tempMatrix.translate(cmd[2],cmd[3]); + this._switchMatrix(tMatrix,tempMatrix); + break ; + case context._rotate: + case 3: + tempMatrix.identity(); + tempMatrix.translate(-cmd[1],-cmd[2]); + tempMatrix.rotate(cmd[0]); + tempMatrix.translate(cmd[1],cmd[2]); + this._switchMatrix(tMatrix,tempMatrix); + break ; + case context._translate: + case 6: + tempMatrix.identity(); + tempMatrix.translate(cmd[0],cmd[1]); + this._switchMatrix(tMatrix,tempMatrix); + break ; + case context._transform: + case 4: + tempMatrix.identity(); + tempMatrix.translate(-cmd[1],-cmd[2]); + tempMatrix.concat(cmd[0]); + tempMatrix.translate(cmd[1],cmd[2]); + this._switchMatrix(tMatrix,tempMatrix); + break ; + case 16: + case 24: + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[0],cmd[1],cmd[2],cmd[3]),tMatrix); + break ; + case 17: + tMatrix.copyTo(tempMatrix); + tempMatrix.concat(cmd[4]); + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[0],cmd[1],cmd[2],cmd[3]),tempMatrix); + break ; + case context._drawTexture: + case context._fillTexture: + if (cmd[3] && cmd[4]){ + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[1],cmd[2],cmd[3],cmd[4]),tMatrix); + }else { + var tex=cmd[0]; + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[1],cmd[2],tex.width,tex.height),tMatrix); + } + break ; + case context._drawTextureWithTransform:; + var drawMatrix; + if (cmd[5]){ + tMatrix.copyTo(tempMatrix); + tempMatrix.concat(cmd[5]); + drawMatrix=tempMatrix; + }else{ + drawMatrix=tMatrix; + } + if (cmd[3] && cmd[4]){ + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[1],cmd[2],cmd[3],cmd[4]),drawMatrix); + }else { + tex=cmd[0]; + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[1],cmd[2],tex.width,tex.height),drawMatrix); + } + break ; + case context._drawRect: + case 13: + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[0],cmd[1],cmd[2],cmd[3]),tMatrix); + break ; + case context._drawCircle: + case context._fillCircle: + case 14: + Graphics._addPointArrToRst(rst,Rectangle._getBoundPointS(cmd[0]-cmd[2],cmd[1]-cmd[2],cmd[2]+cmd[2],cmd[2]+cmd[2]),tMatrix); + break ; + case context._drawLine: + case 20: + Graphics._tempPoints.length=0; + var lineWidth=NaN; + lineWidth=cmd[5] *0.5; + if (cmd[0]==cmd[2]){ + Graphics._tempPoints.push(cmd[0]+lineWidth,cmd[1],cmd[2]+lineWidth,cmd[3],cmd[0]-lineWidth,cmd[1],cmd[2]-lineWidth,cmd[3]); + }else if (cmd[1]==cmd[3]){ + Graphics._tempPoints.push(cmd[0],cmd[1]+lineWidth,cmd[2],cmd[3]+lineWidth,cmd[0],cmd[1]-lineWidth,cmd[2],cmd[3]-lineWidth); + }else { + Graphics._tempPoints.push(cmd[0],cmd[1],cmd[2],cmd[3]); + } + Graphics._addPointArrToRst(rst,Graphics._tempPoints,tMatrix); + break ; + case context._drawCurves: + case 22: + Graphics._addPointArrToRst(rst,Bezier.I.getBezierPoints(cmd[2]),tMatrix,cmd[0],cmd[1]); + break ; + case context._drawPoly: + case context._drawLines: + case 18: + Graphics._addPointArrToRst(rst,cmd[2],tMatrix,cmd[0],cmd[1]); + break ; + case context._drawPath: + case 19: + Graphics._addPointArrToRst(rst,this._getPathPoints(cmd[2]),tMatrix,cmd[0],cmd[1]); + break ; + case context._drawPie: + case 15: + Graphics._addPointArrToRst(rst,this._getPiePoints(cmd[0],cmd[1],cmd[2],cmd[3],cmd[4]),tMatrix); + break ; + } + } + if (rst.length > 200){ + rst=Utils.copyArray(rst,Rectangle._getWrapRec(rst)._getBoundPoints()); + }else if (rst.length > 8) + rst=GrahamScan.scanPList(rst); + return rst; + } + + __proto._switchMatrix=function(tMatix,tempMatrix){ + tempMatrix.concat(tMatix); + tempMatrix.copyTo(tMatix); + } + + /** + *绘制纹理。 + *@param tex 纹理。 + *@param x X 轴偏移量。 + *@param y Y 轴偏移量。 + *@param width 宽度。 + *@param height 高度。 + *@param m 矩阵信息。 + */ + __proto.drawTexture=function(tex,x,y,width,height,m,alpha){ + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + (alpha===void 0)&& (alpha=1); + if (!tex)return; + if (!width)width=tex.sourceWidth; + if (!height)height=tex.sourceHeight; + width=width-tex.sourceWidth+tex.width; + height=height-tex.sourceHeight+tex.height; + if (tex.loaded && (width <=0 || height <=0))return; + x+=tex.offsetX; + y+=tex.offsetY; + this._sp && (this._sp._renderType |=/*laya.renders.RenderSprite.GRAPHICS*/0x100); + var args=[tex,x,y,width,height,m,alpha]; + args.callee=(m || alpha !=1)? Render._context._drawTextureWithTransform :Render._context._drawTexture; + if (this._one==null && !m && alpha==1){ + this._one=args; + this._render=this._renderOneImg; + }else { + this._saveToCmd(args.callee,args); + } + if (!tex.loaded){ + tex.once(/*laya.events.Event.LOADED*/"loaded",this,this._textureLoaded,[tex,args]); + } + this._repaint(); + } + + /** + *@private 清理贴图并替换为最新的 + *@param tex + */ + __proto.cleanByTexture=function(tex,x,y,width,height){ + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + if (!tex)return this.clear(); + if (this._one && this._render===this._renderOneImg){ + if (!width)width=tex.sourceWidth; + if (!height)height=tex.sourceHeight; + width=width-tex.sourceWidth+tex.width; + height=height-tex.sourceHeight+tex.height; + x+=tex.offsetX; + y+=tex.offsetY; + this._one[0]=tex; + this._one[1]=x; + this._one[2]=y; + this._one[3]=width; + this._one[4]=height; + }else { + this.clear(); + tex && this.drawTexture(tex,x,y,width,height); + } + } + + /** + *批量绘制同样纹理。 + *@param tex 纹理。 + *@param pos 绘制次数和坐标。 + */ + __proto.drawTextures=function(tex,pos){ + if (!tex)return; + this._saveToCmd(Render._context._drawTextures,[tex,pos]); + } + + /** + *用texture填充 + *@param tex 纹理。 + *@param x X 轴偏移量。 + *@param y Y 轴偏移量。 + *@param width 宽度。 + *@param height 高度。 + *@param type 填充类型 repeat|repeat-x|repeat-y|no-repeat + *@param offset 贴图纹理偏移 + * + */ + __proto.fillTexture=function(tex,x,y,width,height,type,offset){ + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + (type===void 0)&& (type="repeat"); + if (!tex)return; + var args=[tex,x,y,width,height,type,offset||Point.EMPTY,{}]; + if (!tex.loaded){ + tex.once(/*laya.events.Event.LOADED*/"loaded",this,this._textureLoaded,[tex,args]); + } + this._saveToCmd(Render._context._fillTexture,args); + } + + __proto._textureLoaded=function(tex,param){ + param[3]=param[3] || tex.width; + param[4]=param[4] || tex.height; + this._repaint(); + } + + /** + *@private + *保存到命令流。 + */ + __proto._saveToCmd=function(fun,args){ + this._sp && (this._sp._renderType |=/*laya.renders.RenderSprite.GRAPHICS*/0x100); + if (this._one==null){ + this._one=args; + this._render=this._renderOne; + }else { + this._sp && (this._sp._renderType &=~ /*laya.renders.RenderSprite.IMAGE*/0x01); + this._render=this._renderAll; + (this._cmds || (this._cmds=[])).length===0 && this._cmds.push(this._one); + this._cmds.push(args); + } + args.callee=fun; + this._temp && (this._temp.length=0); + this._repaint(); + return args; + } + + /** + *设置剪裁区域,超出剪裁区域的坐标不显示。 + *@param x X 轴偏移量。 + *@param y Y 轴偏移量。 + *@param width 宽度。 + *@param height 高度。 + */ + __proto.clipRect=function(x,y,width,height){ + this._saveToCmd(Render._context._clipRect,[x,y,width,height]); + } + + /** + *在画布上绘制文本。 + *@param text 在画布上输出的文本。 + *@param x 开始绘制文本的 x 坐标位置(相对于画布)。 + *@param y 开始绘制文本的 y 坐标位置(相对于画布)。 + *@param font 定义字号和字体,比如"20px Arial"。 + *@param color 定义文本颜色,比如"#ff0000"。 + *@param textAlign 文本对齐方式,可选值:"left","center","right"。 + */ + __proto.fillText=function(text,x,y,font,color,textAlign){ + this._saveToCmd(Render._context._fillText,[text,x,y,font || Font.defaultFont,color,textAlign]); + } + + /** + *在画布上绘制“被填充且镶边的”文本。 + *@param text 在画布上输出的文本。 + *@param x 开始绘制文本的 x 坐标位置(相对于画布)。 + *@param y 开始绘制文本的 y 坐标位置(相对于画布)。 + *@param font 定义字体和字号,比如"20px Arial"。 + *@param fillColor 定义文本颜色,比如"#ff0000"。 + *@param borderColor 定义镶边文本颜色。 + *@param lineWidth 镶边线条宽度。 + *@param textAlign 文本对齐方式,可选值:"left","center","right"。 + */ + __proto.fillBorderText=function(text,x,y,font,fillColor,borderColor,lineWidth,textAlign){ + this._saveToCmd(Render._context._fillBorderText,[text,x,y,font || Font.defaultFont,fillColor,borderColor,lineWidth,textAlign]); + } + + /** + *在画布上绘制文本(没有填色)。文本的默认颜色是黑色。 + *@param text 在画布上输出的文本。 + *@param x 开始绘制文本的 x 坐标位置(相对于画布)。 + *@param y 开始绘制文本的 y 坐标位置(相对于画布)。 + *@param font 定义字体和字号,比如"20px Arial"。 + *@param color 定义文本颜色,比如"#ff0000"。 + *@param lineWidth 线条宽度。 + *@param textAlign 文本对齐方式,可选值:"left","center","right"。 + */ + __proto.strokeText=function(text,x,y,font,color,lineWidth,textAlign){ + this._saveToCmd(Render._context._strokeText,[text,x,y,font || Font.defaultFont,color,lineWidth,textAlign]); + } + + /** + *设置透明度。 + *@param value 透明度。 + */ + __proto.alpha=function(value){ + this._saveToCmd(Render._context._alpha,[value]); + } + + /** + *替换绘图的当前转换矩阵。 + *@param mat 矩阵。 + *@param pivotX 水平方向轴心点坐标。 + *@param pivotY 垂直方向轴心点坐标。 + */ + __proto.transform=function(matrix,pivotX,pivotY){ + (pivotX===void 0)&& (pivotX=0); + (pivotY===void 0)&& (pivotY=0); + this._saveToCmd(Render._context._transform,[matrix,pivotX,pivotY]); + } + + /** + *旋转当前绘图。(推荐使用transform,性能更高) + *@param angle 旋转角度,以弧度计。 + *@param pivotX 水平方向轴心点坐标。 + *@param pivotY 垂直方向轴心点坐标。 + */ + __proto.rotate=function(angle,pivotX,pivotY){ + (pivotX===void 0)&& (pivotX=0); + (pivotY===void 0)&& (pivotY=0); + this._saveToCmd(Render._context._rotate,[angle,pivotX,pivotY]); + } + + /** + *缩放当前绘图至更大或更小。(推荐使用transform,性能更高) + *@param scaleX 水平方向缩放值。 + *@param scaleY 垂直方向缩放值。 + *@param pivotX 水平方向轴心点坐标。 + *@param pivotY 垂直方向轴心点坐标。 + */ + __proto.scale=function(scaleX,scaleY,pivotX,pivotY){ + (pivotX===void 0)&& (pivotX=0); + (pivotY===void 0)&& (pivotY=0); + this._saveToCmd(Render._context._scale,[scaleX,scaleY,pivotX,pivotY]); + } + + /** + *重新映射画布上的 (0,0)位置。 + *@param x 添加到水平坐标(x)上的值。 + *@param y 添加到垂直坐标(y)上的值。 + */ + __proto.translate=function(x,y){ + this._saveToCmd(Render._context._translate,[x,y]); + } + + /** + *保存当前环境的状态。 + */ + __proto.save=function(){ + this._saveToCmd(Render._context._save,[]); + } + + /** + *返回之前保存过的路径状态和属性。 + */ + __proto.restore=function(){ + this._saveToCmd(Render._context._restore,[]); + } + + /** + *@private + *替换文本内容。 + *@param text 文本内容。 + *@return 替换成功则值为true,否则值为flase。 + */ + __proto.replaceText=function(text){ + this._repaint(); + var cmds=this._cmds; + if (!cmds){ + if (this._one && this._isTextCmd(this._one.callee)){ + if (this._one[0].toUpperCase)this._one[0]=text; + else this._one[0].setText(text); + return true; + } + }else { + for (var i=cmds.length-1;i >-1;i--){ + if (this._isTextCmd(cmds[i].callee)){ + if (cmds[i][0].toUpperCase)cmds[i][0]=text; + else cmds[i][0].setText(text); + return true; + } + } + } + return false; + } + + /**@private */ + __proto._isTextCmd=function(fun){ + return fun===Render._context._fillText || fun===Render._context._fillBorderText || fun===Render._context._strokeText; + } + + /** + *@private + *替换文本颜色。 + *@param color 颜色。 + */ + __proto.replaceTextColor=function(color){ + this._repaint(); + var cmds=this._cmds; + if (!cmds){ + if (this._one && this._isTextCmd(this._one.callee)){ + this._one[4]=color; + if (!this._one[0].toUpperCase)this._one[0].changed=true; + } + }else { + for (var i=cmds.length-1;i >-1;i--){ + if (this._isTextCmd(cmds[i].callee)){ + cmds[i][4]=color; + if (!cmds[i][0].toUpperCase)cmds[i][0].changed=true; + } + } + } + } + + /** + *加载并显示一个图片。 + *@param url 图片地址。 + *@param x 显示图片的x位置。 + *@param y 显示图片的y位置。 + *@param width 显示图片的宽度,设置为0表示使用图片默认宽度。 + *@param height 显示图片的高度,设置为0表示使用图片默认高度。 + *@param complete 加载完成回调。 + */ + __proto.loadImage=function(url,x,y,width,height,complete){ + var _$this=this; + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + var tex=Loader.getRes(url); + if (tex)onloaded(tex); + else Laya.loader.load(url,Handler.create(null,onloaded),null,/*laya.net.Loader.IMAGE*/"image"); + function onloaded (tex){ + if (tex){ + _$this.drawTexture(tex,x,y,width,height); + if (complete !=null)complete.call(_$this._sp,tex); + } + } + } + + /** + *@private + */ + __proto._renderEmpty=function(sprite,context,x,y){} + /** + *@private + */ + __proto._renderAll=function(sprite,context,x,y){ + var cmds=this._cmds,cmd; + for (var i=0,n=cmds.length;i < n;i++){ + (cmd=cmds[i]).callee.call(context,x,y,cmd); + } + } + + /** + *@private + */ + __proto._renderOne=function(sprite,context,x,y){ + this._one.callee.call(context,x,y,this._one); + } + + /** + *@private + */ + __proto._renderOneImg=function(sprite,context,x,y){ + this._one.callee.call(context,x,y,this._one); + if (sprite._renderType!==2305){ + sprite._renderType |=/*laya.renders.RenderSprite.IMAGE*/0x01; + } + } + + /** + *绘制一条线。 + *@param fromX X 轴开始位置。 + *@param fromY Y 轴开始位置。 + *@param toX X 轴结束位置。 + *@param toY Y 轴结束位置。 + *@param lineColor 颜色。 + *@param lineWidth 线条宽度。 + */ + __proto.drawLine=function(fromX,fromY,toX,toY,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var tId=0; + if (Render.isWebGL){ + tId=VectorGraphManager.getInstance().getId(); + if (this._vectorgraphArray==null)this._vectorgraphArray=[]; + this._vectorgraphArray.push(tId); + }; + var arr=[fromX+0.5,fromY+0.5,toX+0.5,toY+0.5,lineColor,lineWidth,tId]; + this._saveToCmd(Render._context._drawLine,arr); + } + + /** + *绘制一系列线段。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param points 线段的点集合。格式:[x1,y1,x2,y2,x3,y3...]。 + *@param lineColor 线段颜色,或者填充绘图的渐变对象。 + *@param lineWidth 线段宽度。 + */ + __proto.drawLines=function(x,y,points,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var tId=0; + if (Render.isWebGL){ + tId=VectorGraphManager.getInstance().getId(); + if (this._vectorgraphArray==null)this._vectorgraphArray=[]; + this._vectorgraphArray.push(tId); + }; + var arr=[x+0.5,y+0.5,points,lineColor,lineWidth,tId]; + this._saveToCmd(Render._context._drawLines,arr); + } + + /** + *绘制一系列曲线。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param points 线段的点集合,格式[startx,starty,ctrx,ctry,startx,starty...]。 + *@param lineColor 线段颜色,或者填充绘图的渐变对象。 + *@param lineWidth 线段宽度。 + */ + __proto.drawCurves=function(x,y,points,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var arr=[x+0.5,y+0.5,points,lineColor,lineWidth]; + this._saveToCmd(Render._context._drawCurves,arr); + } + + /** + *绘制矩形。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param width 矩形宽度。 + *@param height 矩形高度。 + *@param fillColor 填充颜色,或者填充绘图的渐变对象。 + *@param lineColor 边框颜色,或者填充绘图的渐变对象。 + *@param lineWidth 边框宽度。 + */ + __proto.drawRect=function(x,y,width,height,fillColor,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var offset=lineColor ? 0.5 :0; + var arr=[x+offset,y+offset,width,height,fillColor,lineColor,lineWidth]; + this._saveToCmd(Render._context._drawRect,arr); + } + + /** + *绘制圆形。 + *@param x 圆点X 轴位置。 + *@param y 圆点Y 轴位置。 + *@param radius 半径。 + *@param fillColor 填充颜色,或者填充绘图的渐变对象。 + *@param lineColor 边框颜色,或者填充绘图的渐变对象。 + *@param lineWidth 边框宽度。 + */ + __proto.drawCircle=function(x,y,radius,fillColor,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var offset=lineColor ? 0.5 :0; + var tId=0; + if (Render.isWebGL){ + tId=VectorGraphManager.getInstance().getId(); + if (this._vectorgraphArray==null)this._vectorgraphArray=[]; + this._vectorgraphArray.push(tId); + }; + var arr=[x+offset,y+offset,radius,fillColor,lineColor,lineWidth,tId]; + this._saveToCmd(Render._context._drawCircle,arr); + } + + /** + *绘制扇形。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param radius 扇形半径。 + *@param startAngle 开始角度。 + *@param endAngle 结束角度。 + *@param fillColor 填充颜色,或者填充绘图的渐变对象。 + *@param lineColor 边框颜色,或者填充绘图的渐变对象。 + *@param lineWidth 边框宽度。 + */ + __proto.drawPie=function(x,y,radius,startAngle,endAngle,fillColor,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var offset=lineColor ? 0.5 :0; + var tId=0; + if (Render.isWebGL){ + tId=VectorGraphManager.getInstance().getId(); + if (this._vectorgraphArray==null)this._vectorgraphArray=[]; + this._vectorgraphArray.push(tId); + }; + var arr=[x+offset,y+offset,radius,startAngle,endAngle,fillColor,lineColor,lineWidth,tId]; + arr[3]=Utils.toRadian(startAngle); + arr[4]=Utils.toRadian(endAngle); + this._saveToCmd(Render._context._drawPie,arr); + } + + __proto._getPiePoints=function(x,y,radius,startAngle,endAngle){ + var rst=Graphics._tempPoints; + Graphics._tempPoints.length=0; + rst.push(x,y); + var dP=Math.PI / 10; + var i=NaN; + for (i=startAngle;i < endAngle;i+=dP){ + rst.push(x+radius *Math.cos(i),y+radius *Math.sin(i)); + } + if (endAngle !=i){ + rst.push(x+radius *Math.cos(endAngle),y+radius *Math.sin(endAngle)); + } + return rst; + } + + /** + *绘制多边形。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param points 多边形的点集合。 + *@param fillColor 填充颜色,或者填充绘图的渐变对象。 + *@param lineColor 边框颜色,或者填充绘图的渐变对象。 + *@param lineWidth 边框宽度。 + */ + __proto.drawPoly=function(x,y,points,fillColor,lineColor,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var offset=lineColor ? 0.5 :0; + var tId=0; + if (Render.isWebGL){ + tId=VectorGraphManager.getInstance().getId(); + if (this._vectorgraphArray==null)this._vectorgraphArray=[]; + this._vectorgraphArray.push(tId); + var tIsConvexPolygon=false; + if (points.length > 6){ + tIsConvexPolygon=false; + }else { + tIsConvexPolygon=true; + } + }; + var arr=[x+offset,y+offset,points,fillColor,lineColor,lineWidth,tId,tIsConvexPolygon]; + this._saveToCmd(Render._context._drawPoly,arr); + } + + __proto._getPathPoints=function(paths){ + var i=0,len=0; + var rst=Graphics._tempPoints; + rst.length=0; + len=paths.length; + var tCMD; + for (i=0;i < len;i++){ + tCMD=paths[i]; + if (tCMD.length > 1){ + rst.push(tCMD[1],tCMD[2]); + if (tCMD.length > 3){ + rst.push(tCMD[3],tCMD[4]); + } + } + } + return rst; + } + + /** + *绘制路径。 + *@param x 开始绘制的 X 轴位置。 + *@param y 开始绘制的 Y 轴位置。 + *@param paths 路径集合,路径支持以下格式:[["moveTo",x,y],["lineTo",x,y,x,y,x,y],["arcTo",x1,y1,x2,y2,r],["closePath"]]。 + *@param brush 刷子定义,支持以下设置{fillStyle}。 + *@param pen 画笔定义,支持以下设置{strokeStyle,lineWidth,lineJoin,lineCap,miterLimit}。 + */ + __proto.drawPath=function(x,y,paths,brush,pen){ + var arr=[x+0.5,y+0.5,paths,brush,pen]; + this._saveToCmd(Render._context._drawPath,arr); + } + + /**@private */ + /** + *@private + *命令流。 + */ + __getset(0,__proto,'cmds',function(){ + return this._cmds; + },function(value){ + this._sp && (this._sp._renderType |=/*laya.renders.RenderSprite.GRAPHICS*/0x100); + this._cmds=value; + this._render=this._renderAll; + this._repaint(); + }); + + Graphics.__init__=function(){ + if (Render.isConchNode){ + var from=laya.display.Graphics.prototype; + var to=/*__JS__ */ConchGraphics.prototype; + var list=["clear","destroy","alpha","rotate","transform","scale","translate","save","restore","clipRect","blendMode","fillText","fillBorderText","_fands","drawRect","drawCircle","drawPie","drawPoly","drawPath","drawImageM","drawLine","drawLines","_drawPs","drawCurves","replaceText","replaceTextColor","_fillImage","fillTexture","setSkinMesh","drawParticle","drawImageS"]; + for (var i=0,len=list.length;i <=len;i++){ + var temp=list[i]; + from[temp]=to[temp]; + } + from._saveToCmd=null; + if (to.drawImageS){ + from.drawTextures=function (tex,pos){ + if (!tex)return; + if (!(tex.loaded && tex.bitmap && tex.source)){ + return; + }; + var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height; + this.drawImageS(tex.bitmap.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,tex.offsetX,tex.offsetY,tex.width,tex.height,pos); + } + } + from.drawTexture=function (tex,x,y,width,height,m){ + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + if (!tex)return; + if (!(tex.loaded && tex.bitmap && tex.source)){ + return; + } + if (!width)width=tex.sourceWidth; + if (!height)height=tex.sourceHeight; + width=width-tex.sourceWidth+tex.width; + height=height-tex.sourceHeight+tex.height; + if (width <=0 || height <=0)return; + x+=tex.offsetX; + y+=tex.offsetY; + var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height; + this.drawImageM(tex.bitmap.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,x,y,width,height,m); + } + from.fillTexture=function (tex,x,y,width,height,type,offset){ + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + (type===void 0)&& (type="repeat"); + if (!tex)return; + if (tex.loaded){ + var ctxi=Render._context.ctx; + var w=tex.bitmap.width,h=tex.bitmap.height,uv=tex.uv; + var pat; + if (tex.uv !=Texture.DEF_UV){ + pat=ctxi.createPattern(tex.bitmap.source,type,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h); + }else { + pat=ctxi.createPattern(tex.bitmap.source,type); + }; + var sX=0,sY=0; + if (offset){ + x+=offset.x % tex.width; + y+=offset.y % tex.height; + sX-=offset.x % tex.width; + sY-=offset.y % tex.height; + } + this._fillImage(pat,x,y,sX,sY,width,height); + } + } + } + } + + Graphics._addPointArrToRst=function(rst,points,matrix,dx,dy){ + (dx===void 0)&& (dx=0); + (dy===void 0)&& (dy=0); + var i=0,len=0; + len=points.length; + for (i=0;i < len;i+=2){ + Graphics._addPointToRst(rst,points[i]+dx,points[i+1]+dy,matrix); + } + } + + Graphics._addPointToRst=function(rst,x,y,matrix){ + var _tempPoint=Point.TEMP; + _tempPoint.setTo(x ? x :0,y ? y :0); + matrix.transformPoint(_tempPoint); + rst.push(_tempPoint.x,_tempPoint.y); + } + + Graphics._tempPoints=[]; + Graphics._tempMatrixArrays=[]; + Graphics._tempCmds=[]; + __static(Graphics, + ['_tempMatrix',function(){return this._tempMatrix=new Matrix();},'_initMatrix',function(){return this._initMatrix=new Matrix();} + ]); + return Graphics; + })() + + + /** + *Event 是事件类型的集合。 + */ + //class laya.events.Event + var Event=(function(){ + function Event(){ + //this.type=null; + //this.nativeEvent=null; + //this.target=null; + //this.currentTarget=null; + //this._stoped=false; + //this.touchId=0; + //this.keyCode=0; + } + + __class(Event,'laya.events.Event'); + var __proto=Event.prototype; + /** + *设置事件数据。 + *@param type 事件类型。 + *@param currentTarget 事件目标触发对象。 + *@param target 事件当前冒泡对象。 + *@return 返回当前 Event 对象。 + */ + __proto.setTo=function(type,currentTarget,target){ + this.type=type; + this.currentTarget=currentTarget; + this.target=target; + return this; + } + + /** + *防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。 + */ + __proto.stopPropagation=function(){ + this._stoped=true; + } + + /**鼠标在 Stage 上的 Y 轴坐标*/ + __getset(0,__proto,'stageY',function(){ + return Laya.stage.mouseY; + }); + + /** + *包含按下或释放的键的字符代码值。字符代码值为英文键盘值。 + */ + __getset(0,__proto,'charCode',function(){ + return this.nativeEvent.charCode; + }); + + /** + *触摸点列表。 + */ + __getset(0,__proto,'touches',function(){ + var arr=this.nativeEvent.touches; + if (arr){ + var stage=Laya.stage; + for (var i=0,n=arr.length;i < n;i++){ + var e=arr[i]; + var point=Point.TEMP; + point.setTo(e.clientX,e.clientY); + stage._canvasTransform.invertTransformPoint(point); + stage.transform.invertTransformPoint(point); + e.stageX=point.x; + e.stageY=point.y; + } + } + return arr; + }); + + /** + *表示键在键盘上的位置。这对于区分在键盘上多次出现的键非常有用。
    + *例如,您可以根据此属性的值来区分左 Shift 键和右 Shift 键:左 Shift 键的值为 KeyLocation.LEFT,右 Shift 键的值为 KeyLocation.RIGHT。另一个示例是区分标准键盘 (KeyLocation.STANDARD)与数字键盘 (KeyLocation.NUM_PAD)上按下的数字键。 + */ + __getset(0,__proto,'keyLocation',function(){ + return this.nativeEvent.keyLocation; + }); + + /** + *表示 Ctrl 键是处于活动状态 (true)还是非活动状态 (false)。 + */ + __getset(0,__proto,'ctrlKey',function(){ + return this.nativeEvent.ctrlKey; + }); + + /** + *表示 Alt 键是处于活动状态 (true)还是非活动状态 (false)。 + */ + __getset(0,__proto,'altKey',function(){ + return this.nativeEvent.altKey; + }); + + /** + *表示 Shift 键是处于活动状态 (true)还是非活动状态 (false)。 + */ + __getset(0,__proto,'shiftKey',function(){ + return this.nativeEvent.shiftKey; + }); + + /**鼠标在 Stage 上的 X 轴坐标*/ + __getset(0,__proto,'stageX',function(){ + return Laya.stage.mouseX; + }); + + Event.EMPTY=new Event(); + Event.MOUSE_DOWN="mousedown"; + Event.MOUSE_UP="mouseup"; + Event.CLICK="click"; + Event.RIGHT_MOUSE_DOWN="rightmousedown"; + Event.RIGHT_MOUSE_UP="rightmouseup"; + Event.RIGHT_CLICK="rightclick"; + Event.MOUSE_MOVE="mousemove"; + Event.MOUSE_OVER="mouseover"; + Event.MOUSE_OUT="mouseout"; + Event.MOUSE_WHEEL="mousewheel"; + Event.ROLL_OVER="mouseover"; + Event.ROLL_OUT="mouseout"; + Event.DOUBLE_CLICK="doubleclick"; + Event.CHANGE="change"; + Event.CHANGED="changed"; + Event.RESIZE="resize"; + Event.ADDED="added"; + Event.REMOVED="removed"; + Event.DISPLAY="display"; + Event.UNDISPLAY="undisplay"; + Event.ERROR="error"; + Event.COMPLETE="complete"; + Event.LOADED="loaded"; + Event.PROGRESS="progress"; + Event.INPUT="input"; + Event.RENDER="render"; + Event.OPEN="open"; + Event.MESSAGE="message"; + Event.CLOSE="close"; + Event.KEY_DOWN="keydown"; + Event.KEY_PRESS="keypress"; + Event.KEY_UP="keyup"; + Event.FRAME="enterframe"; + Event.DRAG_START="dragstart"; + Event.DRAG_MOVE="dragmove"; + Event.DRAG_END="dragend"; + Event.ENTER="enter"; + Event.SELECT="select"; + Event.BLUR="blur"; + Event.FOCUS="focus"; + Event.PLAYED="played"; + Event.PAUSED="paused"; + Event.STOPPED="stopped"; + Event.START="start"; + Event.END="end"; + Event.ENABLED_CHANGED="enabledchanged"; + Event.COMPONENT_ADDED="componentadded"; + Event.COMPONENT_REMOVED="componentremoved"; + Event.ACTIVE_CHANGED="activechanged"; + Event.LAYER_CHANGED="layerchanged"; + Event.HIERARCHY_LOADED="hierarchyloaded"; + Event.RECOVERING="recovering"; + Event.RECOVERED="recovered"; + Event.RELEASED="released"; + Event.LINK="link"; + Event.LABEL="label"; + Event.FULL_SCREEN_CHANGE="fullscreenchange"; + Event.DEVICE_LOST="devicelost"; + Event.MESH_CHANGED="meshchanged"; + Event.MATERIAL_CHANGED="materialchanged"; + Event.RENDERQUEUE_CHANGED="renderqueuechanged"; + Event.WORLDMATRIX_NEEDCHANGE="worldmatrixneedchanged"; + Event.ANIMATION_CHANGED="animationchanged"; + return Event; + })() + + + /** + *Keyboard 类的属性是一些常数,这些常数表示控制游戏时最常用的键。 + */ + //class laya.events.Keyboard + var Keyboard=(function(){ + function Keyboard(){}; + __class(Keyboard,'laya.events.Keyboard'); + Keyboard.NUMBER_0=48; + Keyboard.NUMBER_1=49; + Keyboard.NUMBER_2=50; + Keyboard.NUMBER_3=51; + Keyboard.NUMBER_4=52; + Keyboard.NUMBER_5=53; + Keyboard.NUMBER_6=54; + Keyboard.NUMBER_7=55; + Keyboard.NUMBER_8=56; + Keyboard.NUMBER_9=57; + Keyboard.A=65; + Keyboard.B=66; + Keyboard.C=67; + Keyboard.D=68; + Keyboard.E=69; + Keyboard.F=70; + Keyboard.G=71; + Keyboard.H=72; + Keyboard.I=73; + Keyboard.J=74; + Keyboard.K=75; + Keyboard.L=76; + Keyboard.M=77; + Keyboard.N=78; + Keyboard.O=79; + Keyboard.P=80; + Keyboard.Q=81; + Keyboard.R=82; + Keyboard.S=83; + Keyboard.T=84; + Keyboard.U=85; + Keyboard.V=86; + Keyboard.W=87; + Keyboard.X=88; + Keyboard.Y=89; + Keyboard.Z=90; + Keyboard.F1=112; + Keyboard.F2=113; + Keyboard.F3=114; + Keyboard.F4=115; + Keyboard.F5=116; + Keyboard.F6=117; + Keyboard.F7=118; + Keyboard.F8=119; + Keyboard.F9=120; + Keyboard.F10=121; + Keyboard.F11=122; + Keyboard.F12=123; + Keyboard.F13=124; + Keyboard.F14=125; + Keyboard.F15=126; + Keyboard.NUMPAD=21; + Keyboard.NUMPAD_0=96; + Keyboard.NUMPAD_1=97; + Keyboard.NUMPAD_2=98; + Keyboard.NUMPAD_3=99; + Keyboard.NUMPAD_4=100; + Keyboard.NUMPAD_5=101; + Keyboard.NUMPAD_6=102; + Keyboard.NUMPAD_7=103; + Keyboard.NUMPAD_8=104; + Keyboard.NUMPAD_9=105; + Keyboard.NUMPAD_ADD=107; + Keyboard.NUMPAD_DECIMAL=110; + Keyboard.NUMPAD_DIVIDE=111; + Keyboard.NUMPAD_ENTER=108; + Keyboard.NUMPAD_MULTIPLY=106; + Keyboard.NUMPAD_SUBTRACT=109; + Keyboard.SEMICOLON=186; + Keyboard.EQUAL=187; + Keyboard.COMMA=188; + Keyboard.MINUS=189; + Keyboard.PERIOD=190; + Keyboard.SLASH=191; + Keyboard.BACKQUOTE=192; + Keyboard.LEFTBRACKET=219; + Keyboard.BACKSLASH=220; + Keyboard.RIGHTBRACKET=221; + Keyboard.QUOTE=222; + Keyboard.ALTERNATE=18; + Keyboard.BACKSPACE=8; + Keyboard.CAPS_LOCK=20; + Keyboard.COMMAND=15; + Keyboard.CONTROL=17; + Keyboard.DELETE=46; + Keyboard.ENTER=13; + Keyboard.ESCAPE=27; + Keyboard.PAGE_UP=33; + Keyboard.PAGE_DOWN=34; + Keyboard.END=35; + Keyboard.HOME=36; + Keyboard.LEFT=37; + Keyboard.UP=38; + Keyboard.RIGHT=39; + Keyboard.DOWN=40; + Keyboard.SHIFT=16; + Keyboard.SPACE=32; + Keyboard.TAB=9; + Keyboard.INSERT=45; + return Keyboard; + })() + + + /** + *

    KeyBoardManager 是键盘事件管理类。

    + *

    该类从浏览器中接收键盘事件,并派发该事件。 + *派发事件时若 Stage.focus 为空则只从 Stage 上派发该事件,否则将从 Stage.focus 对象开始一直冒泡派发该事件。 + *所以在 Laya.stage 上监听键盘事件一定能够收到,如果在其他地方监听,则必须处在Stage.focus的冒泡链上才能收到该事件。

    + *

    用户可以通过代码 Laya.stage.focus=someNode 的方式来设置focus对象。

    + *

    用户可统一的根据事件对象中 e.keyCode 来判断按键类型,该属性兼容了不同浏览器的实现。

    + */ + //class laya.events.KeyBoardManager + var KeyBoardManager=(function(){ + function KeyBoardManager(){}; + __class(KeyBoardManager,'laya.events.KeyBoardManager'); + KeyBoardManager.__init__=function(){ + KeyBoardManager._addEvent("keydown"); + KeyBoardManager._addEvent("keypress"); + KeyBoardManager._addEvent("keyup"); + } + + KeyBoardManager._addEvent=function(type){ + Browser.document.addEventListener(type,function(e){ + laya.events.KeyBoardManager._dispatch(e,type); + },true); + } + + KeyBoardManager._dispatch=function(e,type){ + if (!KeyBoardManager.enabled)return; + KeyBoardManager._event._stoped=false; + KeyBoardManager._event.nativeEvent=e; + KeyBoardManager._event.keyCode=e.keyCode || e.which || e.charCode; + if (type==="keydown")KeyBoardManager._pressKeys[KeyBoardManager._event.keyCode]=true; + else if (type==="keyup")KeyBoardManager._pressKeys[KeyBoardManager._event.keyCode]=null; + var target=(Laya.stage.focus && (Laya.stage.focus.event !=null))? Laya.stage.focus :Laya.stage; + var ct=target; + while (ct){ + ct.event(type,KeyBoardManager._event.setTo(type,ct,target)); + ct=ct.parent; + } + } + + KeyBoardManager.hasKeyDown=function(key){ + return KeyBoardManager._pressKeys[key]; + } + + KeyBoardManager._pressKeys={}; + KeyBoardManager.enabled=true; + __static(KeyBoardManager, + ['_event',function(){return this._event=new Event();} + ]); + return KeyBoardManager; + })() + + + /** + *

    KeyLocation 类包含表示在键盘或类似键盘的输入设备上按键位置的常量。

    + *

    KeyLocation 常数用在键盘事件对象的 keyLocation 属性中。

    + */ + //class laya.events.KeyLocation + var KeyLocation=(function(){ + function KeyLocation(){}; + __class(KeyLocation,'laya.events.KeyLocation'); + KeyLocation.STANDARD=0; + KeyLocation.LEFT=1; + KeyLocation.RIGHT=2; + KeyLocation.NUM_PAD=3; + return KeyLocation; + })() + + + /** + *MouseManager 是鼠标、触摸交互管理器。 + */ + //class laya.events.MouseManager + var MouseManager=(function(){ + function MouseManager(){ + this.mouseX=0; + this.mouseY=0; + this.disableMouseEvent=false; + this.mouseDownTime=0; + this.mouseMoveAccuracy=2; + this._stage=null; + this._target=null; + this._lastOvers=[]; + this._currOvers=[]; + this._lastClickTimer=0; + this._lastMoveTimer=0; + this._isDoubleClick=false; + this._isLeftMouse=false; + this._eventList=[]; + this._touchIDs={}; + this._id=1; + this._event=new Event(); + this._matrix=new Matrix(); + this._point=new Point(); + this._rect=new Rectangle(); + this._prePoint=new Point(); + } + + __class(MouseManager,'laya.events.MouseManager'); + var __proto=MouseManager.prototype; + /** + *@private + *初始化。 + */ + __proto.__init__=function(stage,canvas){ + var _$this=this; + this._stage=stage; + var _this=this; + var list=this._eventList; + canvas.oncontextmenu=function (e){ + if (MouseManager.enabled)return false; + } + canvas.addEventListener('mousedown',function(e){ + if (MouseManager.enabled){ + e.preventDefault(); + list.push(e); + _this.mouseDownTime=Browser.now(); + } + }); + canvas.addEventListener('mouseup',function(e){ + if (MouseManager.enabled){ + e.preventDefault(); + list.push(e); + _this.mouseDownTime=-Browser.now(); + } + },true); + canvas.addEventListener('mousemove',function(e){ + if (MouseManager.enabled){ + e.preventDefault(); + var now=Browser.now(); + if (now-_this._lastMoveTimer < 10)return; + _this._lastMoveTimer=now; + list.push(e); + } + },true); + canvas.addEventListener("mouseout",function(e){ + if (MouseManager.enabled)list.push(e); + }) + canvas.addEventListener("mouseover",function(e){ + if (MouseManager.enabled)list.push(e); + }) + canvas.addEventListener("touchstart",function(e){ + if (MouseManager.enabled){ + list.push(e); + _$this.runEvent(); + if (!Input.isInputting)e.preventDefault(); + _this.mouseDownTime=Browser.now(); + } + }); + canvas.addEventListener("touchend",function(e){ + if (MouseManager.enabled){ + if (!Input.isInputting)e.preventDefault(); + list.push(e); + _this.mouseDownTime=-Browser.now(); + } + },true); + canvas.addEventListener("touchmove",function(e){ + if (MouseManager.enabled){ + e.preventDefault(); + list.push(e); + } + },true); + canvas.addEventListener('mousewheel',function(e){ + if (MouseManager.enabled)list.push(e); + }); + canvas.addEventListener('DOMMouseScroll',function(e){ + if (MouseManager.enabled)list.push(e); + }); + } + + __proto.initEvent=function(e,nativeEvent){ + var _this=this; + _this._event._stoped=false; + _this._event.nativeEvent=nativeEvent || e; + _this._target=null; + this._point.setTo(e.clientX,e.clientY); + this._stage._canvasTransform.invertTransformPoint(this._point); + _this.mouseX=this._point.x; + _this.mouseY=this._point.y; + _this._event.touchId=e.identifier || 0; + } + + __proto.checkMouseWheel=function(e){ + this._event.delta=e.wheelDelta ? e.wheelDelta *0.025 :-e.detail; + for (var i=0,n=this._lastOvers.length;i < n;i++){ + var ele=this._lastOvers[i]; + ele.event(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this._event.setTo(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",ele,this._target)); + } + this._stage.event(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this._event.setTo(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this._stage,this._target)); + } + + __proto.checkMouseOut=function(){ + if (this.disableMouseEvent)return; + for (var i=0,n=this._lastOvers.length;i < n;i++){ + var ele=this._lastOvers[i]; + if (!ele.destroyed && this._currOvers.indexOf(ele)< 0){ + ele._set$P("$_MOUSEOVER",false); + ele.event(/*laya.events.Event.MOUSE_OUT*/"mouseout",this._event.setTo(/*laya.events.Event.MOUSE_OUT*/"mouseout",ele,this._target)); + } + }; + var temp=this._lastOvers; + this._lastOvers=this._currOvers; + this._currOvers=temp; + this._currOvers.length=0; + } + + __proto.onMouseMove=function(ele){ + this.sendMouseMove(ele); + this._event._stoped=false; + this.sendMouseOver(this._target); + } + + __proto.sendMouseMove=function(ele){ + ele.event(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this._event.setTo(/*laya.events.Event.MOUSE_MOVE*/"mousemove",ele,this._target)); + !this._event._stoped && ele.parent && this.sendMouseMove(ele.parent); + } + + __proto.sendMouseOver=function(ele){ + if (ele.parent || ele===this._stage){ + if (!ele._get$P("$_MOUSEOVER")){ + ele._set$P("$_MOUSEOVER",true); + ele.event(/*laya.events.Event.MOUSE_OVER*/"mouseover",this._event.setTo(/*laya.events.Event.MOUSE_OVER*/"mouseover",ele,this._target)); + } + this._currOvers.push(ele); + } + !this._event._stoped && ele.parent && this.sendMouseOver(ele.parent); + } + + __proto.onMouseDown=function(ele){ + if (Input.isInputting && Laya.stage.focus && Laya.stage.focus["focus"] && !Laya.stage.focus.contains(this._target)){ + Laya.stage.focus["focus"]=false; + } + this._onMouseDown(ele); + } + + __proto._onMouseDown=function(ele){ + if (this._isLeftMouse){ + ele._set$P("$_MOUSEDOWN",this._touchIDs[this._event.touchId]); + ele.event(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this._event.setTo(/*laya.events.Event.MOUSE_DOWN*/"mousedown",ele,this._target)); + }else { + ele._set$P("$_RIGHTMOUSEDOWN",this._touchIDs[this._event.touchId]); + ele.event(/*laya.events.Event.RIGHT_MOUSE_DOWN*/"rightmousedown",this._event.setTo(/*laya.events.Event.RIGHT_MOUSE_DOWN*/"rightmousedown",ele,this._target)); + } + !this._event._stoped && ele.parent && this.onMouseDown(ele.parent); + } + + __proto.onMouseUp=function(ele){ + var type=this._isLeftMouse ? /*laya.events.Event.MOUSE_UP*/"mouseup" :/*laya.events.Event.RIGHT_MOUSE_UP*/"rightmouseup"; + this.sendMouseUp(ele,type); + this._event._stoped=false; + this.sendClick(this._target,type); + } + + __proto.sendMouseUp=function(ele,type){ + ele.event(type,this._event.setTo(type,ele,this._target)); + !this._event._stoped && ele.parent && this.sendMouseUp(ele.parent,type); + } + + __proto.sendClick=function(ele,type){ + if (ele.destroyed)return; + if (type===/*laya.events.Event.MOUSE_UP*/"mouseup" && ele._get$P("$_MOUSEDOWN")===this._touchIDs[this._event.touchId]){ + ele._set$P("$_MOUSEDOWN",-1); + ele.event(/*laya.events.Event.CLICK*/"click",this._event.setTo(/*laya.events.Event.CLICK*/"click",ele,this._target)); + this._isDoubleClick && ele.event(/*laya.events.Event.DOUBLE_CLICK*/"doubleclick",this._event.setTo(/*laya.events.Event.DOUBLE_CLICK*/"doubleclick",ele,this._target)); + }else if (type===/*laya.events.Event.RIGHT_MOUSE_UP*/"rightmouseup" && ele._get$P("$_RIGHTMOUSEDOWN")===this._touchIDs[this._event.touchId]){ + ele._set$P("$_RIGHTMOUSEDOWN",-1); + ele.event(/*laya.events.Event.RIGHT_CLICK*/"rightclick",this._event.setTo(/*laya.events.Event.RIGHT_CLICK*/"rightclick",ele,this._target)); + } + !this._event._stoped && ele.parent && this.sendClick(ele.parent,type); + } + + __proto.check=function(sp,mouseX,mouseY,callBack){ + var transform=sp.transform || this._matrix; + var pivotX=sp.pivotX; + var pivotY=sp.pivotY; + if (pivotX===0 && pivotY===0){ + transform.setTranslate(sp.x,sp.y); + }else { + if (transform===this._matrix){ + transform.setTranslate(sp.x-pivotX,sp.y-pivotY); + }else { + var cos=transform.cos; + var sin=transform.sin; + transform.setTranslate(sp.x-(pivotX *cos-pivotY *sin)*sp.scaleX,sp.y-(pivotX *sin+pivotY *cos)*sp.scaleY); + } + } + transform.invertTransformPoint(this._point.setTo(mouseX,mouseY)); + transform.setTranslate(0,0); + mouseX=this._point.x; + mouseY=this._point.y; + var scrollRect=sp.scrollRect; + if (scrollRect){ + this._rect.setTo(0,0,scrollRect.width,scrollRect.height); + var isHit=this._rect.contains(mouseX,mouseY); + if (!isHit)return false; + } + if (!this.disableMouseEvent){ + var flag=false; + if (sp.hitTestPrior && !sp.mouseThrough && !this.hitTest(sp,mouseX,mouseY)){ + return false; + } + for (var i=sp._childs.length-1;i >-1;i--){ + var child=sp._childs[i]; + if (!child.destroyed && child.mouseEnabled && child.visible){ + flag=this.check(child,mouseX+(scrollRect ? scrollRect.x :0),mouseY+(scrollRect ? scrollRect.y :0),callBack); + if (flag)return true; + } + } + } + isHit=this.hitTest(sp,mouseX,mouseY); + if (isHit){ + this._target=sp; + callBack.call(this,sp); + }else if (callBack===this.onMouseUp && sp===this._stage){ + this._target=this._stage; + callBack.call(this,this._target); + } + return isHit; + } + + __proto.hitTest=function(sp,mouseX,mouseY){ + var isHit=false; + if ((sp.hitArea instanceof laya.utils.HitArea )){ + return sp.hitArea.isHit(mouseX,mouseY); + } + if (sp.width > 0 && sp.height > 0 || sp.mouseThrough || sp.hitArea){ + var hitRect=this._rect; + if (!sp.mouseThrough){ + if (sp.hitArea)hitRect=sp.hitArea; + else hitRect.setTo(0,0,sp.width,sp.height); + isHit=hitRect.contains(mouseX,mouseY); + }else { + isHit=sp.getGraphicBounds().contains(mouseX,mouseY); + } + } + return isHit; + } + + /** + *执行事件处理。 + */ + __proto.runEvent=function(){ + var len=this._eventList.length; + if (!len)return; + var _this=this; + var i=0; + while (i < len){ + var evt=this._eventList[i]; + if (evt.type!=='mousemove')this._prePoint.x=this._prePoint.y=-1000000; + switch (evt.type){ + case 'mousedown': + this._touchIDs[0]=this._id++; + if (!MouseManager._isTouchRespond){ + _this._isLeftMouse=evt.button===0; + _this.initEvent(evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseDown); + }else + MouseManager._isTouchRespond=false; + break ; + case 'mouseup': + _this._isLeftMouse=evt.button===0; + var now=Browser.now(); + _this._isDoubleClick=(now-_this._lastClickTimer)< 300; + _this._lastClickTimer=now; + _this.initEvent(evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseUp); + break ; + case 'mousemove': + if ((Math.abs(this._prePoint.x-evt.clientX)+Math.abs(this._prePoint.y-evt.clientY))>=this.mouseMoveAccuracy){ + this._prePoint.x=evt.clientX; + this._prePoint.y=evt.clientY; + _this.initEvent(evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseMove); + _this.checkMouseOut(); + } + break ; + case "touchstart": + MouseManager._isTouchRespond=true; + _this._isLeftMouse=true; + var touches=evt.changedTouches; + for (var j=0,n=touches.length;j < n;j++){ + var touch=touches[j]; + if (this._id % 200===0)this._touchIDs={}; + this._touchIDs[touch.identifier]=this._id++; + _this.initEvent(touch,evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseDown); + } + break ; + case "touchend": + MouseManager._isTouchRespond=true; + _this._isLeftMouse=true; + now=Browser.now(); + _this._isDoubleClick=(now-_this._lastClickTimer)< 300; + _this._lastClickTimer=now; + var touchends=evt.changedTouches; + for (j=0,n=touchends.length;j < n;j++){ + _this.initEvent(touchends[j],evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseUp); + } + break ; + case "touchmove":; + var touchemoves=evt.changedTouches; + for (j=0,n=touchemoves.length;j < n;j++){ + _this.initEvent(touchemoves[j],evt); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseMove); + } + _this.checkMouseOut(); + break ; + case "wheel": + case "mousewheel": + case "DOMMouseScroll": + _this.checkMouseWheel(evt); + break ; + case "mouseout": + _this._stage.event(/*laya.events.Event.MOUSE_OUT*/"mouseout",_this._event.setTo(/*laya.events.Event.MOUSE_OUT*/"mouseout",_this._stage,_this._stage)); + break ; + case "mouseover": + _this._stage.event(/*laya.events.Event.MOUSE_OVER*/"mouseover",_this._event.setTo(/*laya.events.Event.MOUSE_OVER*/"mouseover",_this._stage,_this._stage)); + break ; + } + i++; + } + this._eventList.length=0; + } + + MouseManager.enabled=true; + MouseManager._isTouchRespond=false; + __static(MouseManager, + ['instance',function(){return this.instance=new MouseManager();} + ]); + return MouseManager; + })() + + + /** + *Filter 是滤镜基类。 + */ + //class laya.filters.Filter + var Filter=(function(){ + function Filter(){ + this._action=null; + } + + __class(Filter,'laya.filters.Filter'); + var __proto=Filter.prototype; + Laya.imps(__proto,{"laya.filters.IFilter":true}) + /**@private */ + __proto.callNative=function(sp){} + /**@private 滤镜类型。*/ + __getset(0,__proto,'type',function(){return-1}); + /**@private 滤镜动作。*/ + __getset(0,__proto,'action',function(){return this._action }); + Filter.BLUR=0x10; + Filter.COLOR=0x20; + Filter.GLOW=0x08; + Filter._filterStart=null + Filter._filterEnd=null + Filter._EndTarget=null + Filter._recycleScope=null + Filter._filter=null + Filter._useSrc=null + Filter._endSrc=null + Filter._useOut=null + Filter._endOut=null + return Filter; + })() + + + /** + *ColorFilterAction 是一个颜色滤镜应用类。 + */ + //class laya.filters.ColorFilterAction + var ColorFilterAction=(function(){ + function ColorFilterAction(){ + this.data=null; + } + + __class(ColorFilterAction,'laya.filters.ColorFilterAction'); + var __proto=ColorFilterAction.prototype; + Laya.imps(__proto,{"laya.filters.IFilterAction":true}) + /** + *给指定的对象应用颜色滤镜。 + *@param srcCanvas 需要应用画布对象。 + *@return 应用了滤镜后的画布对象。 + */ + __proto.apply=function(srcCanvas){ + var ctx=srcCanvas.ctx.ctx; + var canvas=srcCanvas.ctx.ctx.canvas; + if (canvas.width==0 || canvas.height==0)return canvas; + var imgdata=ctx.getImageData(0,0,canvas.width,canvas.height); + var data=imgdata.data; + var nData; + for (var i=0,n=data.length;i < n;i+=4){ + nData=this.getColor(data[i],data[i+1],data[i+2],data[i+3]); + if (data[i+3]==0)continue ; + data[i]=nData[0]; + data[i+1]=nData[1]; + data[i+2]=nData[2]; + data[i+3]=nData[3]; + } + ctx.putImageData(imgdata,0,0); + return srcCanvas; + } + + __proto.getColor=function(red,green,blue,alpha){ + var rst=[]; + if (this.data._mat && this.data._alpha){ + var mat=this.data._mat; + var tempAlpha=this.data._alpha; + rst[0]=mat[0] *red+mat[1] *green+mat[2] *blue+mat[3] *alpha+tempAlpha[0]; + rst[1]=mat[4] *red+mat[5] *green+mat[6] *blue+mat[7] *alpha+tempAlpha[1]; + rst[2]=mat[8] *red+mat[9] *green+mat[10] *blue+mat[11] *alpha+tempAlpha[2]; + rst[3]=mat[12] *red+mat[13] *green+mat[14] *blue+mat[15] *alpha+tempAlpha[3]; + } + return rst; + } + + return ColorFilterAction; + })() + + + /** + *@private + */ + //class laya.maths.Arith + var Arith=(function(){ + function Arith(){}; + __class(Arith,'laya.maths.Arith'); + Arith.formatR=function(r){ + if (r > Math.PI)r-=Math.PI *2; + if (r <-Math.PI)r+=Math.PI *2; + return r; + } + + Arith.isPOT=function(w,h){ + return (w > 0 && (w & (w-1))===0 && h > 0 && (h & (h-1))===0); + } + + Arith.setMatToArray=function(mat,array){ + mat.a,mat.b,0,0,mat.c,mat.d,0,0,0,0,1,0,mat.tx+20,mat.ty+20,0,1 + array[0]=mat.a; + array[1]=mat.b; + array[4]=mat.c; + array[5]=mat.d; + array[12]=mat.tx; + array[13]=mat.ty; + } + + return Arith; + })() + + + /** + *@private + *计算贝塞尔曲线的工具类。 + */ + //class laya.maths.Bezier + var Bezier=(function(){ + function Bezier(){ + this._controlPoints=[new Point(),new Point(),new Point()]; + this._calFun=this.getPoint2; + } + + __class(Bezier,'laya.maths.Bezier'); + var __proto=Bezier.prototype; + /**@private */ + __proto._switchPoint=function(x,y){ + var tPoint=this._controlPoints.shift(); + tPoint.setTo(x,y); + this._controlPoints.push(tPoint); + } + + /** + *计算二次贝塞尔点。 + *@param t + *@param rst + * + */ + __proto.getPoint2=function(t,rst){ + var p1=this._controlPoints[0]; + var p2=this._controlPoints[1]; + var p3=this._controlPoints[2]; + var lineX=Math.pow((1-t),2)*p1.x+2 *t *(1-t)*p2.x+Math.pow(t,2)*p3.x; + var lineY=Math.pow((1-t),2)*p1.y+2 *t *(1-t)*p2.y+Math.pow(t,2)*p3.y; + rst.push(lineX,lineY); + } + + /** + *计算三次贝塞尔点 + *@param t + *@param rst + * + */ + __proto.getPoint3=function(t,rst){ + var p1=this._controlPoints[0]; + var p2=this._controlPoints[1]; + var p3=this._controlPoints[2]; + var p4=this._controlPoints[3]; + var lineX=Math.pow((1-t),3)*p1.x+3 *p2.x *t *(1-t)*(1-t)+3 *p3.x *t *t *(1-t)+p4.x *Math.pow(t,3); + var lineY=Math.pow((1-t),3)*p1.y+3 *p2.y *t *(1-t)*(1-t)+3 *p3.y *t *t *(1-t)+p4.y *Math.pow(t,3); + rst.push(lineX,lineY); + } + + /** + *计算贝塞尔点序列 + *@param count + *@param rst + * + */ + __proto.insertPoints=function(count,rst){ + var i=NaN; + count=count > 0 ? count :5; + var dLen=NaN; + dLen=1 / count; + for (i=0;i <=1;i+=dLen){ + this._calFun(i,rst); + } + } + + /** + *获取贝塞尔曲线上的点。 + *@param pList 控制点[x0,y0,x1,y1...] + *@param inSertCount 每次曲线的插值数量 + *@return + * + */ + __proto.getBezierPoints=function(pList,inSertCount,count){ + (inSertCount===void 0)&& (inSertCount=5); + (count===void 0)&& (count=2); + var i=0,len=0; + len=pList.length; + if (len < (count+1)*2)return []; + var rst; + rst=[]; + switch (count){ + case 2: + this._calFun=this.getPoint2; + break ; + case 3: + this._calFun=this.getPoint3; + break ; + default : + return []; + } + while(this._controlPoints.length<=count){ + this._controlPoints.push(new Point()); + } + for (i=0;i < count *2;i+=2){ + this._switchPoint(pList[i],pList[i+1]); + } + for (i=count *2;i < len;i+=2){ + this._switchPoint(pList[i],pList[i+1]); + if ((i / 2)% count==0) + this.insertPoints(inSertCount,rst); + } + return rst; + } + + __static(Bezier, + ['I',function(){return this.I=new Bezier();} + ]); + return Bezier; + })() + + + /** + *@private + *凸包算法。 + */ + //class laya.maths.GrahamScan + var GrahamScan=(function(){ + function GrahamScan(){}; + __class(GrahamScan,'laya.maths.GrahamScan'); + GrahamScan.multiply=function(p1,p2,p0){ + return ((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y)); + } + + GrahamScan.dis=function(p1,p2){ + return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y); + } + + GrahamScan._getPoints=function(count,tempUse,rst){ + (tempUse===void 0)&& (tempUse=false); + if (!GrahamScan._mPointList)GrahamScan._mPointList=[]; + while (GrahamScan._mPointList.length < count)GrahamScan._mPointList.push(new Point()); + if (!rst)rst=[]; + rst.length=0; + if (tempUse){ + GrahamScan.getFrom(rst,GrahamScan._mPointList,count); + }else { + GrahamScan.getFromR(rst,GrahamScan._mPointList,count); + } + return rst; + } + + GrahamScan.getFrom=function(rst,src,count){ + var i=0; + for (i=0;i < count;i++){ + rst.push(src[i]); + } + return rst; + } + + GrahamScan.getFromR=function(rst,src,count){ + var i=0; + for (i=0;i < count;i++){ + rst.push(src.pop()); + } + return rst; + } + + GrahamScan.pListToPointList=function(pList,tempUse){ + (tempUse===void 0)&& (tempUse=false); + var i=0,len=pList.length / 2,rst=GrahamScan._getPoints(len,tempUse,GrahamScan._tempPointList); + for (i=0;i < len;i++){ + rst[i].setTo(pList[i+i],pList[i+i+1]); + } + return rst; + } + + GrahamScan.pointListToPlist=function(pointList){ + var i=0,len=pointList.length,rst=GrahamScan._temPList,tPoint; + rst.length=0; + for (i=0;i < len;i++){ + tPoint=pointList[i]; + rst.push(tPoint.x,tPoint.y); + } + return rst; + } + + GrahamScan.scanPList=function(pList){ + return Utils.copyArray(pList,GrahamScan.pointListToPlist(GrahamScan.scan(GrahamScan.pListToPointList(pList,true)))); + } + + GrahamScan.scan=function(PointSet){ + var i=0,j=0,k=0,top=2,tmp,n=PointSet.length,ch; + var _tmpDic={}; + var key; + ch=GrahamScan._temArr; + ch.length=0; + n=PointSet.length; + for (i=n-1;i >=0;i--){ + tmp=PointSet[i]; + key=tmp.x+"_"+tmp.y; + if (!_tmpDic.hasOwnProperty(key)){ + _tmpDic[key]=true; + ch.push(tmp); + } + } + n=ch.length; + Utils.copyArray(PointSet,ch); + for (i=1;i < n;i++) + if ((PointSet[i].y < PointSet[k].y)|| ((PointSet[i].y==PointSet[k].y)&& (PointSet[i].x < PointSet[k].x))) + k=i; + tmp=PointSet[0]; + PointSet[0]=PointSet[k]; + PointSet[k]=tmp; + for (i=1;i < n-1;i++){ + k=i; + for (j=i+1;j < n;j++) + if ((GrahamScan.multiply(PointSet[j],PointSet[k],PointSet[0])> 0)|| ((GrahamScan.multiply(PointSet[j],PointSet[k],PointSet[0])==0)&& (GrahamScan.dis(PointSet[0],PointSet[j])< GrahamScan.dis(PointSet[0],PointSet[k])))) + k=j; + tmp=PointSet[i]; + PointSet[i]=PointSet[k]; + PointSet[k]=tmp; + } + ch=GrahamScan._temArr; + ch.length=0; + if (PointSet.length < 3){ + return Utils.copyArray(ch,PointSet); + } + ch.push(PointSet[0],PointSet[1],PointSet[2]); + for (i=3;i < n;i++){ + while (ch.length >=2 && GrahamScan.multiply(PointSet[i],ch[ch.length-1],ch[ch.length-2])>=0)ch.pop(); + PointSet[i] && ch.push(PointSet[i]); + } + return ch; + } + + GrahamScan._mPointList=null + GrahamScan._tempPointList=[]; + GrahamScan._temPList=[]; + GrahamScan._temArr=[]; + return GrahamScan; + })() + + + /** + *@private + *MathUtil 是一个数据处理工具类。 + */ + //class laya.maths.MathUtil + var MathUtil=(function(){ + function MathUtil(){}; + __class(MathUtil,'laya.maths.MathUtil'); + MathUtil.subtractVector3=function(l,r,o){ + o[0]=l[0]-r[0]; + o[1]=l[1]-r[1]; + o[2]=l[2]-r[2]; + } + + MathUtil.lerp=function(left,right,amount){ + return left *(1-amount)+right *amount; + } + + MathUtil.scaleVector3=function(f,b,e){ + e[0]=f[0] *b; + e[1]=f[1] *b; + e[2]=f[2] *b; + } + + MathUtil.lerpVector3=function(l,r,t,o){ + var ax=l[0],ay=l[1],az=l[2]; + o[0]=ax+t *(r[0]-ax); + o[1]=ay+t *(r[1]-ay); + o[2]=az+t *(r[2]-az); + } + + MathUtil.lerpVector4=function(l,r,t,o){ + var ax=l[0],ay=l[1],az=l[2],aw=l[3]; + o[0]=ax+t *(r[0]-ax); + o[1]=ay+t *(r[1]-ay); + o[2]=az+t *(r[2]-az); + o[3]=aw+t *(r[3]-aw); + } + + MathUtil.slerpQuaternionArray=function(a,Offset1,b,Offset2,t,out,Offset3){ + var ax=a[Offset1+0],ay=a[Offset1+1],az=a[Offset1+2],aw=a[Offset1+3],bx=b[Offset2+0],by=b[Offset2+1],bz=b[Offset2+2],bw=b[Offset2+3]; + var omega,cosom,sinom,scale0,scale1; + cosom=ax *bx+ay *by+az *bz+aw *bw; + if (cosom < 0.0){ + cosom=-cosom; + bx=-bx; + by=-by; + bz=-bz; + bw=-bw; + } + if ((1.0-cosom)> 0.000001){ + omega=Math.acos(cosom); + sinom=Math.sin(omega); + scale0=Math.sin((1.0-t)*omega)/ sinom; + scale1=Math.sin(t *omega)/ sinom; + }else { + scale0=1.0-t; + scale1=t; + } + out[Offset3+0]=scale0 *ax+scale1 *bx; + out[Offset3+1]=scale0 *ay+scale1 *by; + out[Offset3+2]=scale0 *az+scale1 *bz; + out[Offset3+3]=scale0 *aw+scale1 *bw; + return out; + } + + MathUtil.getRotation=function(x0,y0,x1,y1){ + return Math.atan2(y1-y0,x1-x0)/ Math.PI *180; + } + + MathUtil.sortBigFirst=function(a,b){ + if (a==b) + return 0; + return b > a ? 1 :-1; + } + + MathUtil.sortSmallFirst=function(a,b){ + if (a==b) + return 0; + return b > a ?-1 :1; + } + + MathUtil.sortNumBigFirst=function(a,b){ + return parseFloat(b)-parseFloat(a); + } + + MathUtil.sortNumSmallFirst=function(a,b){ + return parseFloat(a)-parseFloat(b); + } + + MathUtil.sortByKey=function(key,bigFirst,forceNum){ + (bigFirst===void 0)&& (bigFirst=false); + (forceNum===void 0)&& (forceNum=true); + var _sortFun; + if (bigFirst){ + _sortFun=forceNum ? MathUtil.sortNumBigFirst :MathUtil.sortBigFirst; + }else { + _sortFun=forceNum ? MathUtil.sortNumSmallFirst :MathUtil.sortSmallFirst; + } + return function (a,b){ + return _sortFun(a[key],b[key]); + } + } + + return MathUtil; + })() + + + /** + *Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 + */ + //class laya.maths.Matrix + var Matrix=(function(){ + function Matrix(a,b,c,d,tx,ty){ + this.cos=1; + this.sin=0; + //this.a=NaN; + //this.b=NaN; + //this.c=NaN; + //this.d=NaN; + //this.tx=NaN; + //this.ty=NaN; + this.inPool=false; + this.bTransform=false; + (a===void 0)&& (a=1); + (b===void 0)&& (b=0); + (c===void 0)&& (c=0); + (d===void 0)&& (d=1); + (tx===void 0)&& (tx=0); + (ty===void 0)&& (ty=0); + this.a=a; + this.b=b; + this.c=c; + this.d=d; + this.tx=tx; + this.ty=ty; + this._checkTransform(); + } + + __class(Matrix,'laya.maths.Matrix'); + var __proto=Matrix.prototype; + /** + *为每个矩阵属性设置一个值。 + *@return 返回当前矩形。 + */ + __proto.identity=function(){ + this.a=this.d=1; + this.b=this.tx=this.ty=this.c=0; + this.bTransform=false; + return this; + } + + /**@private*/ + __proto._checkTransform=function(){ + return this.bTransform=(this.a!==1 || this.b!==0 || this.c!==0 || this.d!==1); + } + + /** + *设置沿 x 、y 轴平移每个点的距离。 + *@param x 沿 x 轴平移每个点的距离。 + *@param y 沿 y 轴平移每个点的距离。 + *@return 返回对象本身 + */ + __proto.setTranslate=function(x,y){ + this.tx=x; + this.ty=y; + return this; + } + + /** + *沿 x 和 y 轴平移矩阵,由 x 和 y 参数指定。 + *@param x 沿 x 轴向右移动的量(以像素为单位)。 + *@param y 沿 y 轴向下移动的量(以像素为单位)。 + *@return 返回此矩形。 + */ + __proto.translate=function(x,y){ + this.tx+=x; + this.ty+=y; + return this; + } + + /** + *对矩阵应用缩放转换。 + *@param x 用于沿 x 轴缩放对象的乘数。 + *@param y 用于沿 y 轴缩放对象的乘数。 + */ + __proto.scale=function(x,y){ + this.a *=x; + this.d *=y; + this.c *=x; + this.b *=y; + this.tx *=x; + this.ty *=y; + this.bTransform=true; + } + + /** + *对 Matrix 对象应用旋转转换。 + *@param angle 以弧度为单位的旋转角度。 + */ + __proto.rotate=function(angle){ + var cos=this.cos=Math.cos(angle); + var sin=this.sin=Math.sin(angle); + var a1=this.a; + var c1=this.c; + var tx1=this.tx; + this.a=a1 *cos-this.b *sin; + this.b=a1 *sin+this.b *cos; + this.c=c1 *cos-this.d *sin; + this.d=c1 *sin+this.d *cos; + this.tx=tx1 *cos-this.ty *sin; + this.ty=tx1 *sin+this.ty *cos; + this.bTransform=true; + } + + /** + *对 Matrix 对象应用倾斜转换。 + *@param x 沿着 X 轴的 2D 倾斜弧度。 + *@param y 沿着 Y 轴的 2D 倾斜弧度。 + *@return 当前 Matrix 对象。 + */ + __proto.skew=function(x,y){ + var tanX=Math.tan(x); + var tanY=Math.tan(y); + var a1=this.a; + var b1=this.b; + this.a+=tanY *this.c; + this.b+=tanY *this.d; + this.c+=tanX *a1; + this.d+=tanX *b1; + return this; + } + + /** + *对指定的点应用当前矩阵的逆转化并返回此点。 + *@param out 待转化的点 Point 对象。 + *@return 返回out + */ + __proto.invertTransformPoint=function(out){ + var a1=this.a; + var b1=this.b; + var c1=this.c; + var d1=this.d; + var tx1=this.tx; + var n=a1 *d1-b1 *c1; + var a2=d1 / n; + var b2=-b1 / n; + var c2=-c1 / n; + var d2=a1 / n; + var tx2=(c1 *this.ty-d1 *tx1)/ n; + var ty2=-(a1 *this.ty-b1 *tx1)/ n; + return out.setTo(a2 *out.x+c2 *out.y+tx2,b2 *out.x+d2 *out.y+ty2); + } + + /** + *将 Matrix 对象表示的几何转换应用于指定点。 + *@param out 用来设定输出结果的点。 + *@return 返回out + */ + __proto.transformPoint=function(out){ + return out.setTo(this.a *out.x+this.c *out.y+this.tx,this.b *out.x+this.d *out.y+this.ty); + } + + /** + *@private + *将 Matrix 对象表示的几何转换应用于指定点。 + *@param data 点集合。 + *@param out 存储应用转化的点的列表。 + *@return 返回out数组 + */ + __proto.transformPointArray=function(data,out){ + var len=data.length; + for (var i=0;i < len;i+=2){ + var x=data[i],y=data[i+1]; + out[i]=this.a *x+this.c *y+this.tx; + out[i+1]=this.b *x+this.d *y+this.ty; + } + return out; + } + + /** + *@private + *将 Matrix 对象表示的几何缩放转换应用于指定点。 + *@param data 点集合。 + *@param out 存储应用转化的点的列表。 + *@return 返回out数组 + */ + __proto.transformPointArrayScale=function(data,out){ + var len=data.length; + for (var i=0;i < len;i+=2){ + var x=data[i],y=data[i+1]; + out[i]=this.a *x+this.c *y; + out[i+1]=this.b *x+this.d *y; + } + return out; + } + + /** + *获取 X 轴缩放值。 + *@return X 轴缩放值。 + */ + __proto.getScaleX=function(){ + return this.b===0 ? this.a :Math.sqrt(this.a *this.a+this.b *this.b); + } + + /** + *获取 Y 轴缩放值。 + *@return Y 轴缩放值。 + */ + __proto.getScaleY=function(){ + return this.c===0 ? this.d :Math.sqrt(this.c *this.c+this.d *this.d); + } + + /** + *执行原始矩阵的逆转换。 + *@return 当前矩阵对象。 + */ + __proto.invert=function(){ + var a1=this.a; + var b1=this.b; + var c1=this.c; + var d1=this.d; + var tx1=this.tx; + var n=a1 *d1-b1 *c1; + this.a=d1 / n; + this.b=-b1 / n; + this.c=-c1 / n; + this.d=a1 / n; + this.tx=(c1 *this.ty-d1 *tx1)/ n; + this.ty=-(a1 *this.ty-b1 *tx1)/ n; + return this; + } + + /** + *将 Matrix 的成员设置为指定值。 + *@param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 + *@param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + *@param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + *@param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 + *@param tx 沿 x 轴平移每个点的距离。 + *@param ty 沿 y 轴平移每个点的距离。 + *@return 当前矩阵对象。 + */ + __proto.setTo=function(a,b,c,d,tx,ty){ + this.a=a,this.b=b,this.c=c,this.d=d,this.tx=tx,this.ty=ty; + return this; + } + + /** + *将指定矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。 + *@param matrix 要连接到源矩阵的矩阵。 + *@return 当前矩阵。 + */ + __proto.concat=function(matrix){ + var a=this.a; + var c=this.c; + var tx=this.tx; + this.a=a *matrix.a+this.b *matrix.c; + this.b=a *matrix.b+this.b *matrix.d; + this.c=c *matrix.a+this.d *matrix.c; + this.d=c *matrix.b+this.d *matrix.d; + this.tx=tx *matrix.a+this.ty *matrix.c+matrix.tx; + this.ty=tx *matrix.b+this.ty *matrix.d+matrix.ty; + return this; + } + + /** + *对矩阵应用缩放转换。反向相乘 + *@param x 用于沿 x 轴缩放对象的乘数。 + *@param y 用于沿 y 轴缩放对象的乘数。 + */ + __proto.scaleEx=function(x,y){ + var ba=this.a,bb=this.b,bc=this.c,bd=this.d; + if (bb!==0 || bc!==0){ + this.a=x *ba; + this.b=x *bb; + this.c=y *bc; + this.d=y *bd; + } + else{ + this.a=x *ba; + this.b=0 *bd; + this.c=0 *ba; + this.d=y *bd; + } + this.bTransform=true; + } + + /** + *对 Matrix 对象应用旋转转换。反向相乘 + *@param angle 以弧度为单位的旋转角度。 + */ + __proto.rotateEx=function(angle){ + var cos=Math.cos(angle); + var sin=Math.sin(angle); + var ba=this.a,bb=this.b,bc=this.c,bd=this.d; + if (bb!==0 || bc!==0){ + this.a=cos *ba+sin *bc; + this.b=cos *bb+sin *bd; + this.c=-sin *ba+cos *bc; + this.d=-sin *bb+cos *bd; + } + else{ + this.a=cos *ba; + this.b=sin *bd; + this.c=-sin *ba; + this.d=cos *bd; + } + this.bTransform=true; + } + + /** + *返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 + *@return 一个 Matrix 对象。 + */ + __proto.clone=function(){ + var no=Matrix._cache; + var dec=!no._length ? (new Matrix()):no[--no._length]; + dec.a=this.a; + dec.b=this.b; + dec.c=this.c; + dec.d=this.d; + dec.tx=this.tx; + dec.ty=this.ty; + dec.bTransform=this.bTransform; + return dec; + } + + /** + *将当前 Matrix 对象中的所有矩阵数据复制到指定的 Matrix 对象中。 + *@param dec 要复制当前矩阵数据的 Matrix 对象。 + *@return 已复制当前矩阵数据的 Matrix 对象。 + */ + __proto.copyTo=function(dec){ + dec.a=this.a; + dec.b=this.b; + dec.c=this.c; + dec.d=this.d; + dec.tx=this.tx; + dec.ty=this.ty; + dec.bTransform=this.bTransform; + return dec; + } + + /** + *返回列出该 Matrix 对象属性的文本值。 + *@return 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 + */ + __proto.toString=function(){ + return this.a+","+this.b+","+this.c+","+this.d+","+this.tx+","+this.ty; + } + + /** + *销毁此对象。 + */ + __proto.destroy=function(){ + if (this.inPool)return; + var cache=Matrix._cache; + this.inPool=true; + cache._length || (cache._length=0); + cache[cache._length++]=this; + this.a=this.d=1; + this.b=this.c=this.tx=this.ty=0; + this.bTransform=false; + } + + Matrix.mul=function(m1,m2,out){ + var aa=m1.a,ab=m1.b,ac=m1.c,ad=m1.d,atx=m1.tx,aty=m1.ty; + var ba=m2.a,bb=m2.b,bc=m2.c,bd=m2.d,btx=m2.tx,bty=m2.ty; + if (bb!==0 || bc!==0){ + out.a=aa *ba+ab *bc; + out.b=aa *bb+ab *bd; + out.c=ac *ba+ad *bc; + out.d=ac *bb+ad *bd; + out.tx=ba *atx+bc *aty+btx; + out.ty=bb *atx+bd *aty+bty; + }else { + out.a=aa *ba; + out.b=ab *bd; + out.c=ac *ba; + out.d=ad *bd; + out.tx=ba *atx+btx; + out.ty=bd *aty+bty; + } + return out; + } + + Matrix.mulPre=function(m1,ba,bb,bc,bd,btx,bty,out){ + var aa=m1.a,ab=m1.b,ac=m1.c,ad=m1.d,atx=m1.tx,aty=m1.ty; + if (bb!==0 || bc!==0){ + out.a=aa *ba+ab *bc; + out.b=aa *bb+ab *bd; + out.c=ac *ba+ad *bc; + out.d=ac *bb+ad *bd; + out.tx=ba *atx+bc *aty+btx; + out.ty=bb *atx+bd *aty+bty; + }else { + out.a=aa *ba; + out.b=ab *bd; + out.c=ac *ba; + out.d=ad *bd; + out.tx=ba *atx+btx; + out.ty=bd *aty+bty; + } + return out; + } + + Matrix.mulPos=function(m1,aa,ab,ac,ad,atx,aty,out){ + var ba=m1.a,bb=m1.b,bc=m1.c,bd=m1.d,btx=m1.tx,bty=m1.ty; + if (bb!==0 || bc!==0){ + out.a=aa *ba+ab *bc; + out.b=aa *bb+ab *bd; + out.c=ac *ba+ad *bc; + out.d=ac *bb+ad *bd; + out.tx=ba *atx+bc *aty+btx; + out.ty=bb *atx+bd *aty+bty; + }else { + out.a=aa *ba; + out.b=ab *bd; + out.c=ac *ba; + out.d=ad *bd; + out.tx=ba *atx+btx; + out.ty=bd *aty+bty; + } + return out; + } + + Matrix.preMul=function(parent,self,out){ + var pa=parent.a,pb=parent.b,pc=parent.c,pd=parent.d; + var na=self.a,nb=self.b,nc=self.c,nd=self.d,ntx=self.tx,nty=self.ty; + out.a=na *pa; + out.b=out.c=0; + out.d=nd *pd; + out.tx=ntx *pa+parent.tx; + out.ty=nty *pd+parent.ty; + if (nb!==0 || nc!==0 || pb!==0 || pc!==0){ + out.a+=nb *pc; + out.d+=nc *pb; + out.b+=na *pb+nb *pd; + out.c+=nc *pa+nd *pc; + out.tx+=nty *pc; + out.ty+=ntx *pb; + } + return out; + } + + Matrix.preMulXY=function(parent,x,y,out){ + var pa=parent.a,pb=parent.b,pc=parent.c,pd=parent.d; + out.a=pa; + out.b=pb; + out.c=pc; + out.d=pd; + out.tx=x *pa+parent.tx+y *pc; + out.ty=y *pd+parent.ty+x *pb; + return out; + } + + Matrix.create=function(){ + var cache=Matrix._cache; + var mat=!cache._length ? (new Matrix()):cache[--cache._length]; + mat.inPool=false; + return mat; + } + + Matrix.EMPTY=new Matrix(); + Matrix.TEMP=new Matrix(); + Matrix._cache=[]; + return Matrix; + })() + + + /** + *Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 + */ + //class laya.maths.Point + var Point=(function(){ + function Point(x,y){ + //this.x=NaN; + //this.y=NaN; + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + this.x=x; + this.y=y; + } + + __class(Point,'laya.maths.Point'); + var __proto=Point.prototype; + /** + *将 Point 的成员设置为指定值。 + *@param x 水平坐标。 + *@param y 垂直坐标。 + *@return 当前 Point 对象。 + */ + __proto.setTo=function(x,y){ + this.x=x; + this.y=y; + return this; + } + + /** + *计算当前点和目标x,y点的距离 + *@param x 水平坐标。 + *@param y 垂直坐标。 + *@return 返回之间的距离 + */ + __proto.distance=function(x,y){ + return Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y)); + } + + /**返回包含 x 和 y 坐标的值的字符串。*/ + __proto.toString=function(){ + return this.x+","+this.y; + } + + /** + *标准化向量 + */ + __proto.normalize=function(){ + var d=Math.sqrt(this.x *this.x+this.y *this.y); + if (d > 0){ + var id=1.0 / d; + this.x *=id; + this.y *=id; + } + } + + Point.TEMP=new Point(); + Point.EMPTY=new Point(); + return Point; + })() + + + /** + *Rectangle 对象是按其位置(由它左上角的点 (x,y)确定)以及宽度和高度定义的区域。 + */ + //class laya.maths.Rectangle + var Rectangle=(function(){ + function Rectangle(x,y,width,height){ + //this.x=NaN; + //this.y=NaN; + //this.width=NaN; + //this.height=NaN; + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + this.x=x; + this.y=y; + this.width=width; + this.height=height; + } + + __class(Rectangle,'laya.maths.Rectangle'); + var __proto=Rectangle.prototype; + /** + *将 Rectangle 的属性设置为指定值。 + *@param x x 矩形左上角的 X 轴坐标。 + *@param y x 矩形左上角的 Y 轴坐标。 + *@param width 矩形的宽度。 + *@param height 矩形的高。 + *@return 返回属性值修改后的矩形对象本身。 + */ + __proto.setTo=function(x,y,width,height){ + this.x=x; + this.y=y; + this.width=width; + this.height=height; + return this; + } + + /** + *复制 source 对象的属性值到此矩形对象中。 + *@param sourceRect 源 Rectangle 对象。 + *@return 返回属性值修改后的矩形对象本身。 + */ + __proto.copyFrom=function(source){ + this.x=source.x; + this.y=source.y; + this.width=source.width; + this.height=source.height; + return this; + } + + /** + *检测此矩形对象是否包含指定的点。 + *@param x 点的 X 轴坐标值(水平位置)。 + *@param y 点的 Y 轴坐标值(垂直位置)。 + *@return 如果 Rectangle 对象包含指定的点,则值为 true;否则为 false。 + */ + __proto.contains=function(x,y){ + if (this.width <=0 || this.height <=0)return false; + if (x >=this.x && x < this.right){ + if (y >=this.y && y < this.bottom){ + return true; + } + } + return false; + } + + /** + *检测传入的矩形对象是否与此对象相交。 + *@param rect Rectangle 对象。 + *@return 如果传入的矩形对象与此对象相交,则返回 true 值,否则返回 false。 + */ + __proto.intersects=function(rect){ + return !(rect.x > (this.x+this.width)|| (rect.x+rect.width)< this.x || rect.y > (this.y+this.height)|| (rect.y+rect.height)< this.y); + } + + /** + *获取此对象与传入的矩形对象的相交区域。并将相交区域赋值给传入的输出矩形对象。 + *@param rect 待比较的矩形区域。 + *@param out 待输出的矩形区域。建议:尽量用此对象复用对象,减少对象创建消耗。 + *@return 返回相交的矩形区域对象。 + */ + __proto.intersection=function(rect,out){ + if (!this.intersects(rect))return null; + out || (out=new Rectangle()); + out.x=Math.max(this.x,rect.x); + out.y=Math.max(this.y,rect.y); + out.width=Math.min(this.right,rect.right)-out.x; + out.height=Math.min(this.bottom,rect.bottom)-out.y; + return out; + } + + /** + *矩形联合,通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 + *@param 目标矩形对象。 + *@param out 待输出结果的矩形对象。建议:尽量用此对象复用对象,减少对象创建消耗。 + *@return 两个矩形后联合的 Rectangle 对象 out 。 + */ + __proto.union=function(source,out){ + out || (out=new Rectangle()); + this.clone(out); + if (source.width <=0 || source.height <=0)return out; + out.addPoint(source.x,source.y); + out.addPoint(source.right,source.bottom); + return this; + } + + /** + *返回一个 Rectangle 对象,其 x、y、width 和 height 属性的值与当前 Rectangle 对象的对应值相同。 + *@param out 待输出的矩形对象。建议:尽量用此对象复用对象,减少对象创建消耗。 + *@return Rectangle 对象 out ,其 x、y、width 和 height 属性的值与当前 Rectangle 对象的对应值相同。 + */ + __proto.clone=function(out){ + out || (out=new Rectangle()); + out.x=this.x; + out.y=this.y; + out.width=this.width; + out.height=this.height; + return out; + } + + /** + *当前 Rectangle 对象的水平位置 x 和垂直位置 y 以及高度 width 和宽度 height 以逗号连接成的字符串。 + */ + __proto.toString=function(){ + return this.x+","+this.y+","+this.width+","+this.height; + } + + /** + *检测传入的 Rectangle 对象的属性是否与当前 Rectangle 对象的属性 x、y、width、height 属性值都相等。 + *@param rect 待比较的 Rectangle 对象。 + *@return 如果判断的属性都相等,则返回 true ,否则返回 false。 + */ + __proto.equals=function(rect){ + if (!rect || rect.x!==this.x || rect.y!==this.y || rect.width!==this.width || rect.height!==this.height)return false; + return true; + } + + /** + *在当前矩形区域中加一个点。 + *@param x 点的 X 坐标。 + *@param y 点的 Y 坐标。 + *@return 返回此 Rectangle 对象。 + */ + __proto.addPoint=function(x,y){ + this.x > x && (this.width+=this.x-x,this.x=x); + this.y > y && (this.height+=this.y-y,this.y=y); + if (this.width < x-this.x)this.width=x-this.x; + if (this.height < y-this.y)this.height=y-this.y; + return this; + } + + /** + *@private + *返回代表当前矩形的顶点数据。 + *@return 顶点数据。 + */ + __proto._getBoundPoints=function(){ + var rst=Rectangle._temB; + rst.length=0; + if (this.width==0 || this.height==0)return rst; + rst.push(this.x,this.y,this.x+this.width,this.y,this.x,this.y+this.height,this.x+this.width,this.y+this.height); + return rst; + } + + /**确定此 Rectangle 对象是否为空。*/ + __proto.isEmpty=function(){ + if (this.width <=0 || this.height <=0)return true; + return false; + } + + /**此矩形的右边距。 x 和 width 属性的和。*/ + __getset(0,__proto,'right',function(){ + return this.x+this.width; + }); + + /**此矩形的底边距。y 和 height 属性的和。*/ + __getset(0,__proto,'bottom',function(){ + return this.y+this.height; + }); + + Rectangle._getBoundPointS=function(x,y,width,height){ + var rst=Rectangle._temA; + rst.length=0; + if (width==0 || height==0)return rst; + rst.push(x,y,x+width,y,x,y+height,x+width,y+height); + return rst; + } + + Rectangle._getWrapRec=function(pointList,rst){ + if (!pointList || pointList.length < 1)return rst ? rst.setTo(0,0,0,0):Rectangle.TEMP.setTo(0,0,0,0); + rst=rst ? rst :new Rectangle(); + var i,len=pointList.length,minX,maxX,minY,maxY,tPoint=Point.TEMP; + minX=minY=99999; + maxX=maxY=-minX; + for (i=0;i < len;i+=2){ + tPoint.x=pointList[i]; + tPoint.y=pointList[i+1]; + minX=minX < tPoint.x ? minX :tPoint.x; + minY=minY < tPoint.y ? minY :tPoint.y; + maxX=maxX > tPoint.x ? maxX :tPoint.x; + maxY=maxY > tPoint.y ? maxY :tPoint.y; + } + return rst.setTo(minX,minY,maxX-minX,maxY-minY); + } + + Rectangle.EMPTY=new Rectangle(); + Rectangle.TEMP=new Rectangle(); + Rectangle._temB=[]; + Rectangle._temA=[]; + return Rectangle; + })() + + + /** + *SoundManager 是一个声音管理类。 + */ + //class laya.media.SoundManager + var SoundManager=(function(){ + function SoundManager(){}; + __class(SoundManager,'laya.media.SoundManager'); + /** + *设置是否失去焦点后自动停止背景音乐。 + *@param v Boolean 值。 + * + */ + /** + *表示是否失去焦点后自动停止背景音乐。 + *@return + */ + __getset(1,SoundManager,'autoStopMusic',function(){ + return SoundManager._autoStopMusic; + },function(v){ + Laya.stage.off(/*laya.events.Event.BLUR*/"blur",null,SoundManager._stageOnBlur); + Laya.stage.off(/*laya.events.Event.FOCUS*/"focus",null,SoundManager._stageOnFocus); + SoundManager._autoStopMusic=v; + if (v){ + Laya.stage.on(/*laya.events.Event.BLUR*/"blur",null,SoundManager._stageOnBlur); + Laya.stage.on(/*laya.events.Event.FOCUS*/"focus",null,SoundManager._stageOnFocus); + } + }); + + /** + *表示是否静音。 + */ + __getset(1,SoundManager,'muted',function(){ + return SoundManager._muted; + },function(value){ + if (value){ + SoundManager.stopAll(); + } + SoundManager._muted=value; + }); + + /**表示是否使背景音乐静音。*/ + __getset(1,SoundManager,'musicMuted',function(){ + return SoundManager._musicMuted; + },function(value){ + if (value){ + if (SoundManager._tMusic) + SoundManager.stopSound(SoundManager._tMusic); + SoundManager._musicMuted=value; + }else { + SoundManager._musicMuted=value; + if (SoundManager._tMusic){ + SoundManager.playMusic(SoundManager._tMusic); + } + } + }); + + /**表示是否使音效静音。*/ + __getset(1,SoundManager,'soundMuted',function(){ + return SoundManager._soundMuted; + },function(value){ + SoundManager._soundMuted=value; + }); + + SoundManager.addChannel=function(channel){ + if (SoundManager._channels.indexOf(channel)>=0)return; + SoundManager._channels.push(channel); + } + + SoundManager.removeChannel=function(channel){ + var i=0; + for (i=SoundManager._channels.length-1;i >=0;i--){ + if (SoundManager._channels[i]==channel){ + SoundManager._channels.splice(i,1); + } + } + } + + SoundManager._stageOnBlur=function(){ + if (SoundManager._musicChannel){ + if (!SoundManager._musicChannel.isStopped){ + SoundManager._blurPaused=true; + SoundManager._musicLoops=SoundManager._musicChannel.loops; + SoundManager._musicCompleteHandler=SoundManager._musicChannel.completeHandler; + SoundManager._musicPosition=SoundManager._musicChannel.position; + SoundManager._musicChannel.stop(); + Laya.stage.once(/*laya.events.Event.MOUSE_DOWN*/"mousedown",null,SoundManager._stageOnFocus); + } + } + } + + SoundManager._stageOnFocus=function(){ + Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",null,SoundManager._stageOnFocus); + if (SoundManager._blurPaused){ + SoundManager.playMusic(SoundManager._tMusic,SoundManager._musicLoops,SoundManager._musicCompleteHandler,SoundManager._musicPosition); + SoundManager._blurPaused=false; + } + } + + SoundManager.playSound=function(url,loops,complete,soundClass,startTime){ + (loops===void 0)&& (loops=1); + (startTime===void 0)&& (startTime=0); + if (SoundManager._muted) + return null; + if (url==SoundManager._tMusic){ + if (SoundManager._musicMuted)return null; + }else { + if (SoundManager._soundMuted)return null; + }; + var tSound=Laya.loader.getRes(url); + if (!soundClass)soundClass=SoundManager._soundClass; + if (!tSound){ + tSound=new soundClass(); + tSound.load(url); + Loader.cacheRes(url,tSound); + }; + var channel; + channel=tSound.play(startTime,loops); + channel.url=url; + channel.volume=(url==SoundManager._tMusic)? SoundManager.musicVolume :SoundManager.soundVolume; + channel.completeHandler=complete; + return channel; + } + + SoundManager.destroySound=function(url){ + var tSound=Laya.loader.getRes(url); + if (tSound){ + Loader.clearRes(url); + tSound.dispose(); + } + } + + SoundManager.playMusic=function(url,loops,complete,startTime){ + (loops===void 0)&& (loops=0); + (startTime===void 0)&& (startTime=0); + SoundManager._tMusic=url; + if (SoundManager._musicChannel) + SoundManager._musicChannel.stop(); + return SoundManager._musicChannel=SoundManager.playSound(url,loops,complete,null,startTime); + } + + SoundManager.stopSound=function(url){ + var i=0; + var channel; + for (i=SoundManager._channels.length-1;i >=0;i--){ + channel=SoundManager._channels[i]; + if (channel.url==url){ + channel.stop(); + } + } + } + + SoundManager.stopAll=function(){ + var i=0; + var channel; + for (i=SoundManager._channels.length-1;i >=0;i--){ + channel=SoundManager._channels[i]; + channel.stop(); + } + } + + SoundManager.stopMusic=function(){ + if (SoundManager._musicChannel) + SoundManager._musicChannel.stop(); + } + + SoundManager.setSoundVolume=function(volume,url){ + if (url){ + SoundManager._setVolume(url,volume); + }else { + SoundManager.soundVolume=volume; + } + } + + SoundManager.setMusicVolume=function(volume){ + SoundManager.musicVolume=volume; + SoundManager._setVolume(SoundManager._tMusic,volume); + } + + SoundManager._setVolume=function(url,volume){ + var i=0; + var channel; + for (i=SoundManager._channels.length-1;i >=0;i--){ + channel=SoundManager._channels[i]; + if (channel.url==url){ + channel.volume=volume; + } + } + } + + SoundManager.musicVolume=1; + SoundManager.soundVolume=1; + SoundManager._muted=false; + SoundManager._soundMuted=false; + SoundManager._musicMuted=false; + SoundManager._tMusic=null; + SoundManager._musicChannel=null; + SoundManager._channels=[]; + SoundManager._autoStopMusic=false; + SoundManager._blurPaused=false; + SoundManager._musicLoops=0; + SoundManager._musicPosition=0; + SoundManager._musicCompleteHandler=null; + SoundManager._soundClass=null + return SoundManager; + })() + + + /** + *

    LocalStorage 类用于没有时间限制的数据存储。

    + */ + //class laya.net.LocalStorage + var LocalStorage=(function(){ + var Storage; + function LocalStorage(){}; + __class(LocalStorage,'laya.net.LocalStorage'); + LocalStorage.__init__=function(){ + if (!LocalStorage._baseClass){ + LocalStorage._baseClass=Storage; + Storage.init(); + } + LocalStorage.items=LocalStorage._baseClass.items; + LocalStorage.support=LocalStorage._baseClass.support; + } + + LocalStorage.setItem=function(key,value){ + LocalStorage._baseClass.setItem(key,value); + } + + LocalStorage.getItem=function(key){ + return LocalStorage._baseClass.getItem(key); + } + + LocalStorage.setJSON=function(key,value){ + LocalStorage._baseClass.setJSON(key,value); + } + + LocalStorage.getJSON=function(key){ + return LocalStorage._baseClass.getJSON(key); + } + + LocalStorage.removeItem=function(key){ + LocalStorage._baseClass.removeItem(key); + } + + LocalStorage.clear=function(){ + LocalStorage._baseClass.clear(); + } + + LocalStorage._baseClass=null + LocalStorage.items=null + LocalStorage.support=false; + LocalStorage.__init$=function(){ + //class Storage + Storage=(function(){ + function Storage(){}; + __class(Storage,''); + Storage.init=function(){ + /*__JS__ */try{Storage.items=window.localStorage;Storage.setItem('laya','1');Storage.removeItem('laya');Storage.support=true;}catch(e){}if(!Storage.support)console.log('LocalStorage is not supprot or browser is private mode.'); + } + Storage.setItem=function(key,value){ + try { + Storage.support && Storage.items.setItem(key,value); + }catch (e){ + console.log("set localStorage failed",e); + } + } + Storage.getItem=function(key){ + return Storage.support ? Storage.items.getItem(key):null; + } + Storage.setJSON=function(key,value){ + try { + Storage.support && Storage.items.setItem(key,JSON.stringify(value)); + }catch (e){ + console.log("set localStorage failed",e); + } + } + Storage.getJSON=function(key){ + return JSON.parse(Storage.support ? Storage.items.getItem(key):null); + } + Storage.removeItem=function(key){ + Storage.support && Storage.items.removeItem(key); + } + Storage.clear=function(){ + Storage.support && Storage.items.clear(); + } + Storage.items=null + Storage.support=true; + return Storage; + })() + } + + return LocalStorage; + })() + + + /** + *

    URL 类用于定义地址信息。

    + */ + //class laya.net.URL + var URL=(function(){ + function URL(url){ + this._url=null; + this._path=null; + this._url=URL.formatURL(url); + this._path=URL.getPath(url); + } + + __class(URL,'laya.net.URL'); + var __proto=URL.prototype; + /**地址的路径。*/ + __getset(0,__proto,'path',function(){ + return this._path; + }); + + /**格式化后的地址。*/ + __getset(0,__proto,'url',function(){ + return this._url; + }); + + URL.formatURL=function(url,base){ + if (URL.customFormat !=null)url=URL.customFormat(url,base); + if (!url)return "null path"; + if (url.indexOf("data:image")===0)return url; + if (Render.isConchApp==false){ + URL.version[url] && (url+="?v="+URL.version[url]); + } + if (url.charAt(0)=='~')return URL.rootPath+url.substring(1); + if (URL.isAbsolute(url))return url; + var retVal=(base || URL.basePath)+url; + return URL.formatRelativePath(retVal); + } + + URL.formatRelativePath=function(value){ + if (value.indexOf("../")>-1){ + var parts=value.split("/"); + for (var i=0,len=parts.length;i < len;i++){ + if (parts[i]=='..'){ + parts.splice(i-1,2); + i-=2; + } + } + return parts.join('/'); + } + return value; + } + + URL.isAbsolute=function(url){ + return url.indexOf(":")> 0 || url.charAt(0)=='/'; + } + + URL.getPath=function(url){ + var ofs=url.lastIndexOf('/'); + return ofs > 0 ? url.substr(0,ofs+1):""; + } + + URL.getFileName=function(url){ + var ofs=url.lastIndexOf('/'); + return ofs > 0 ? url.substr(ofs+1):url; + } + + URL.version={}; + URL.basePath=""; + URL.rootPath=""; + URL.customFormat=null + return URL; + })() + + + /** + *@private + *Render 是渲染管理类。它是一个单例,可以使用 Laya.render 访问。 + */ + //class laya.renders.Render + var Render=(function(){ + function Render(width,height){ + this._timeId=0; + var style=Render._mainCanvas.source.style; + style.position='absolute'; + style.top=style.left="0px"; + style.background="#000000"; + Render._mainCanvas.source.id=Render._mainCanvas.source.id || "layaCanvas"; + var isWebGl=laya.renders.Render.isWebGL; + isWebGl && Render.WebGL.init(Render._mainCanvas,width,height); + if (Render._mainCanvas.source.nodeName || laya.renders.Render.isConchApp){ + Browser.container.appendChild(Render._mainCanvas.source); + } + Render._context=new RenderContext(width,height,isWebGl ? null :Render._mainCanvas); + Render._context.ctx.setIsMainContext(); + Browser.window.requestAnimationFrame(loop); + function loop (){ + Laya.stage._loop(); + Browser.window.requestAnimationFrame(loop); + } + Laya.stage.on(/*laya.events.Event.BLUR*/"blur",this,this._onBlur); + Laya.stage.on(/*laya.events.Event.FOCUS*/"focus",this,this._onFocus); + } + + __class(Render,'laya.renders.Render'); + var __proto=Render.prototype; + /**@private */ + __proto._onFocus=function(){ + Browser.window.clearInterval(this._timeId); + } + + /**@private */ + __proto._onBlur=function(){ + this._timeId=Browser.window.setInterval(this._enterFrame,1000); + } + + /**@private */ + __proto._enterFrame=function(e){ + Laya.stage._loop(); + } + + /**是否是加速器 只读*/ + __getset(1,Render,'isConchApp',function(){ + return /*__JS__ */(window.ConchRenderType & 0x04)==0x04; + }); + + /**目前使用的渲染器。*/ + __getset(1,Render,'context',function(){ + return Render._context; + }); + + /**加速器模式下设置是否是节点模式 如果是否就是非节点模式 默认为canvas模式 如果设置了isConchWebGL则是webGL模式*/ + __getset(1,Render,'isConchNode',function(){ + return /*__JS__ */(window.ConchRenderType & 5)==5; + },function(b){ + if (b){ + /*__JS__ */window.ConchRenderType |=0x01; + }else { + /*__JS__ */window.ConchRenderType &=~ 0x01; + } + }); + + /**加速器模式下设置是否是WebGL模式*/ + __getset(1,Render,'isConchWebGL',function(){ + return /*__JS__ */window.ConchRenderType==6; + },function(b){ + if (b){ + Render.isConchNode=false; + /*__JS__ */window.ConchRenderType |=0x02; + }else { + /*__JS__ */window.ConchRenderType &=~ 0x02; + } + }); + + /**渲染使用的原生画布引用。 */ + __getset(1,Render,'canvas',function(){ + return Render._mainCanvas.source; + }); + + Render._context=null + Render._mainCanvas=null + Render.WebGL=null + Render.NODE=0x01; + Render.WEBGL=0x02; + Render.CONCH=0x04; + Render.isWebGL=false; + Render.is3DMode=false; + Render.optimizeTextureMemory=function(url,texture){ + return true; + } + + Render.__init$=function(){ + /*__JS__ */window.ConchRenderType=window.ConchRenderType||1;; + /*__JS__ */window.ConchRenderType|=(!window.conch?0:0x04);;; + } + + return Render; + })() + + + /** + *@private + *渲染环境 + */ + //class laya.renders.RenderContext + var RenderContext=(function(){ + function RenderContext(width,height,canvas){ + this.x=0; + this.y=0; + //this.canvas=null; + //this.ctx=null; + this._drawTexture=function(x,y,args){ + if (args[0].loaded)this.ctx.drawTexture(args[0],args[1],args[2],args[3],args[4],x,y); + } + this._fillTexture=function(x,y,args){ + if (args[0].loaded)this.ctx.fillTexture(args[0],args[1]+x,args[2]+y,args[3],args[4],args[5],args[6],args[7]); + } + this._drawTextureWithTransform=function(x,y,args){ + if (args[0].loaded)this.ctx.drawTextureWithTransform(args[0],args[1],args[2],args[3],args[4],args[5],x,y,args[6]); + } + this._fillQuadrangle=function(x,y,args){ + this.ctx.fillQuadrangle(args[0],args[1],args[2],args[3],args[4]); + } + this._drawRect=function(x,y,args){ + var ctx=this.ctx; + if (args[4] !=null){ + ctx.fillStyle=args[4]; + ctx.fillRect(x+args[0],y+args[1],args[2],args[3],null); + } + if (args[5] !=null){ + ctx.strokeStyle=args[5]; + ctx.lineWidth=args[6]; + ctx.strokeRect(x+args[0],y+args[1],args[2],args[3],args[6]); + } + } + this._drawPie=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(args[8]); + ctx.beginPath(); + if (Render.isWebGL){ + ctx.movePath(args[0]+x,args[1]+y); + ctx.moveTo(0,0); + }else { + ctx.moveTo(x+args[0],y+args[1]); + } + ctx.arc(x+args[0],y+args[1],args[2],args[3],args[4]); + ctx.closePath(); + this._fillAndStroke(args[5],args[6],args[7],true); + } + this._clipRect=function(x,y,args){ + this.ctx.clipRect(x+args[0],y+args[1],args[2],args[3]); + } + this._fillRect=function(x,y,args){ + this.ctx.fillRect(x+args[0],y+args[1],args[2],args[3],args[4]); + } + this._drawCircle=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(args[6]); + Stat.drawCall++; + ctx.beginPath(); + Render.isWebGL && ctx.movePath(args[0]+x,args[1]+y); + ctx.arc(args[0]+x,args[1]+y,args[2],0,RenderContext.PI2); + ctx.closePath(); + this._fillAndStroke(args[3],args[4],args[5],true); + } + this._fillCircle=function(x,y,args){ + Stat.drawCall++; + var ctx=this.ctx; + ctx.beginPath(); + ctx.fillStyle=args[3]; + ctx.arc(args[0]+x,args[1]+y,args[2],0,RenderContext.PI2); + ctx.fill(); + } + this._setShader=function(x,y,args){ + this.ctx.setShader(args[0]); + } + this._drawLine=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(args[6]); + ctx.beginPath(); + ctx.strokeStyle=args[4]; + ctx.lineWidth=args[5]; + if (Render.isWebGL){ + ctx.movePath(x,y); + ctx.moveTo(args[0],args[1]); + ctx.lineTo(args[2],args[3]); + }else { + ctx.moveTo(x+args[0],y+args[1]); + ctx.lineTo(x+args[2],y+args[3]); + } + ctx.stroke(); + } + this._drawLines=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(args[5]); + ctx.beginPath(); + x+=args[0],y+=args[1]; + Render.isWebGL && ctx.movePath(x,y); + ctx.strokeStyle=args[3]; + ctx.lineWidth=args[4]; + var points=args[2]; + var i=2,n=points.length; + if (Render.isWebGL){ + ctx.moveTo(points[0],points[1]); + while (i < n){ + ctx.lineTo(points[i++],points[i++]); + } + }else { + ctx.moveTo(x+points[0],y+points[1]); + while (i < n){ + ctx.lineTo(x+points[i++],y+points[i++]); + } + } + ctx.stroke(); + } + this._drawLinesWebGL=function(x,y,args){ + this.ctx.drawLines(x+this.x+args[0],y+this.y+args[1],args[2],args[3],args[4]); + } + this._drawCurves=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(-1); + ctx.beginPath(); + ctx.strokeStyle=args[3]; + ctx.lineWidth=args[4]; + var points=args[2]; + x+=args[0],y+=args[1]; + ctx.moveTo(x+points[0],y+points[1]); + var i=2,n=points.length; + while (i < n){ + ctx.quadraticCurveTo(x+points[i++],y+points[i++],x+points[i++],y+points[i++]); + } + ctx.stroke(); + } + this._draw=function(x,y,args){ + args[0].call(null,this,x,y); + } + this._transformByMatrix=function(x,y,args){ + this.ctx.transformByMatrix(args[0]); + } + this._setTransform=function(x,y,args){ + this.ctx.setTransform(args[0],args[1],args[2],args[3],args[4],args[5]); + } + this._setTransformByMatrix=function(x,y,args){ + this.ctx.setTransformByMatrix(args[0]); + } + this._save=function(x,y,args){ + this.ctx.save(); + } + this._restore=function(x,y,args){ + this.ctx.restore(); + } + this._translate=function(x,y,args){ + this.ctx.translate(args[0],args[1]); + } + this._transform=function(x,y,args){ + this.ctx.translate(args[1]+x,args[2]+y); + var mat=args[0]; + this.ctx.transform(mat.a,mat.b,mat.c,mat.d,mat.tx,mat.ty); + this.ctx.translate(-x-args[1],-y-args[2]); + } + this._rotate=function(x,y,args){ + this.ctx.translate(args[1]+x,args[2]+y); + this.ctx.rotate(args[0]); + this.ctx.translate(-x-args[1],-y-args[2]); + } + this._scale=function(x,y,args){ + this.ctx.translate(args[2]+x,args[3]+y); + this.ctx.scale(args[0],args[1]); + this.ctx.translate(-x-args[2],-y-args[3]); + } + this._alpha=function(x,y,args){ + this.ctx.globalAlpha *=args[0]; + } + this._setAlpha=function(x,y,args){ + this.ctx.globalAlpha=args[0]; + } + this._fillText=function(x,y,args){ + this.ctx.fillText(args[0],args[1]+x,args[2]+y,args[3],args[4],args[5]); + } + this._strokeText=function(x,y,args){ + this.ctx.strokeText(args[0],args[1]+x,args[2]+y,args[3],args[4],args[5],args[6]); + } + this._fillBorderText=function(x,y,args){ + this.ctx.fillBorderText(args[0],args[1]+x,args[2]+y,args[3],args[4],args[5],args[6],args[7]); + } + this._blendMode=function(x,y,args){ + this.ctx.globalCompositeOperation=args[0]; + } + this._beginClip=function(x,y,args){ + this.ctx.beginClip && this.ctx.beginClip(x+args[0],y+args[1],args[2],args[3]); + } + this._setIBVB=function(x,y,args){ + this.ctx.setIBVB(args[0]+x,args[1]+y,args[2],args[3],args[4],args[5],args[6],args[7]); + } + this._fillTrangles=function(x,y,args){ + this.ctx.fillTrangles(args[0],args[1]+x,args[2]+y,args[3],args[4]); + } + this._drawPath=function(x,y,args){ + var ctx=this.ctx; + Render.isWebGL && ctx.setPathId(-1); + ctx.beginPath(); + x+=args[0],y+=args[1]; + var paths=args[2]; + for (var i=0,n=paths.length;i < n;i++){ + var path=paths[i]; + switch (path[0]){ + case "moveTo": + ctx.moveTo(x+path[1],y+path[2]); + break ; + case "lineTo": + ctx.lineTo(x+path[1],y+path[2]); + break ; + case "arcTo": + ctx.arcTo(x+path[1],y+path[2],x+path[3],y+path[4],path[5]); + break ; + case "closePath": + ctx.closePath(); + break ; + } + }; + var brush=args[3]; + if (brush !=null){ + ctx.fillStyle=brush.fillStyle; + ctx.fill(); + }; + var pen=args[4]; + if (pen !=null){ + ctx.strokeStyle=pen.strokeStyle; + ctx.lineWidth=pen.lineWidth || 1; + ctx.lineJoin=pen.lineJoin; + ctx.lineCap=pen.lineCap; + ctx.miterLimit=pen.miterLimit; + ctx.stroke(); + } + } + this.drawPoly=function(x,y,args){ + this.ctx.drawPoly(x+this.x+args[0],y+this.y+args[1],args[2],args[3],args[4],args[5],args[6]); + } + this._drawPoly=function(x,y,args){ + var ctx=this.ctx; + var points=args[2]; + var i=2,n=points.length; + if (Render.isWebGL){ + ctx.setPathId(args[6]); + ctx.beginPath(); + x+=args[0],y+=args[1]; + ctx.movePath(x,y); + ctx.moveTo(points[0],points[1]); + while (i < n){ + ctx.lineTo(points[i++],points[i++]); + } + }else { + ctx.beginPath(); + x+=args[0],y+=args[1]; + ctx.moveTo(x+points[0],y+points[1]); + while (i < n){ + ctx.lineTo(x+points[i++],y+points[i++]); + } + } + ctx.closePath(); + this._fillAndStroke(args[3],args[4],args[5],args[7]); + } + this._drawSkin=function(x,y,args){ + var tSprite=args[0]; + if (tSprite){ + var ctx=this.ctx; + tSprite.render(ctx,x,y); + } + } + this._drawParticle=function(x,y,args){ + this.ctx.drawParticle(x+this.x,y+this.y,args[0]); + } + if (canvas){ + this.ctx=canvas.getContext('2d'); + }else { + canvas=HTMLCanvas.create("3D"); + this.ctx=RunDriver.createWebGLContext2D(canvas); + canvas._setContext(this.ctx); + } + canvas.size(width,height); + this.canvas=canvas; + } + + __class(RenderContext,'laya.renders.RenderContext'); + var __proto=RenderContext.prototype; + /**销毁当前渲染环境*/ + __proto.destroy=function(){ + if (this.canvas){ + this.canvas.destroy(); + this.canvas=null; + } + if (this.ctx){ + this.ctx.destroy(); + this.ctx=null; + } + } + + __proto.drawTexture=function(tex,x,y,width,height){ + if (tex.loaded)this.ctx.drawTexture(tex,x,y,width,height,this.x,this.y); + } + + __proto._drawTextures=function(x,y,args){ + if (args[0].loaded)this.ctx.drawTextures(args[0],args[1],x+this.x,y+this.y); + } + + __proto.drawTextureWithTransform=function(tex,x,y,width,height,m,alpha){ + if (tex.loaded)this.ctx.drawTextureWithTransform(tex,x,y,width,height,m,this.x,this.y,alpha); + } + + __proto.fillQuadrangle=function(tex,x,y,point4,m){ + this.ctx.fillQuadrangle(tex,x,y,point4,m); + } + + __proto.drawCanvas=function(canvas,x,y,width,height){ + this.ctx.drawCanvas(canvas,x+this.x,y+this.y,width,height); + } + + __proto.drawRect=function(x,y,width,height,color,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var ctx=this.ctx; + ctx.strokeStyle=color; + ctx.lineWidth=lineWidth; + ctx.strokeRect(x+this.x,y+this.y,width,height,lineWidth); + } + + __proto._fillAndStroke=function(fillColor,strokeColor,lineWidth,isConvexPolygon){ + (isConvexPolygon===void 0)&& (isConvexPolygon=false); + var ctx=this.ctx; + if (fillColor !=null){ + ctx.fillStyle=fillColor; + if (Render.isWebGL){ + ctx.fill(isConvexPolygon); + }else { + ctx.fill(); + } + } + if (strokeColor !=null && lineWidth > 0){ + ctx.strokeStyle=strokeColor; + ctx.lineWidth=lineWidth; + ctx.stroke(); + } + } + + //ctx.translate(-x-args[0],-y-args[1]); + __proto.clipRect=function(x,y,width,height){ + this.ctx.clipRect(x+this.x,y+this.y,width,height); + } + + __proto.fillRect=function(x,y,width,height,fillStyle){ + this.ctx.fillRect(x+this.x,y+this.y,width,height,fillStyle); + } + + __proto.drawCircle=function(x,y,radius,color,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + Stat.drawCall++; + var ctx=this.ctx; + ctx.beginPath(); + ctx.strokeStyle=color; + ctx.lineWidth=lineWidth; + ctx.arc(x+this.x,y+this.y,radius,0,RenderContext.PI2); + ctx.stroke(); + } + + __proto.fillCircle=function(x,y,radius,color){ + Stat.drawCall++; + var ctx=this.ctx; + ctx.beginPath(); + ctx.fillStyle=color; + ctx.arc(x+this.x,y+this.y,radius,0,RenderContext.PI2); + ctx.fill(); + } + + __proto.setShader=function(shader){ + this.ctx.setShader(shader); + } + + __proto.drawLine=function(fromX,fromY,toX,toY,color,lineWidth){ + (lineWidth===void 0)&& (lineWidth=1); + var ctx=this.ctx; + ctx.beginPath(); + ctx.strokeStyle=color; + ctx.lineWidth=lineWidth; + ctx.moveTo(this.x+fromX,this.y+fromY); + ctx.lineTo(this.x+toX,this.y+toY); + ctx.stroke(); + } + + __proto.clear=function(){ + this.ctx.clear(); + } + + __proto.transformByMatrix=function(value){ + this.ctx.transformByMatrix(value); + } + + __proto.setTransform=function(a,b,c,d,tx,ty){ + this.ctx.setTransform(a,b,c,d,tx,ty); + } + + __proto.setTransformByMatrix=function(value){ + this.ctx.setTransformByMatrix(value); + } + + __proto.save=function(){ + this.ctx.save(); + } + + __proto.restore=function(){ + this.ctx.restore(); + } + + __proto.translate=function(x,y){ + this.ctx.translate(x,y); + } + + __proto.transform=function(a,b,c,d,tx,ty){ + this.ctx.transform(a,b,c,d,tx,ty); + } + + __proto.rotate=function(angle){ + this.ctx.rotate(angle); + } + + __proto.scale=function(scaleX,scaleY){ + this.ctx.scale(scaleX,scaleY); + } + + __proto.alpha=function(value){ + this.ctx.globalAlpha *=value; + } + + __proto.setAlpha=function(value){ + this.ctx.globalAlpha=value; + } + + __proto.fillWords=function(words,x,y,font,color){ + this.ctx.fillWords(words,x,y,font,color); + } + + __proto.fillText=function(text,x,y,font,color,textAlign){ + this.ctx.fillText(text,x+this.x,y+this.y,font,color,textAlign); + } + + __proto.strokeText=function(text,x,y,font,color,lineWidth,textAlign){ + this.ctx.strokeText(text,x+this.x,y+this.y,font,color,lineWidth,textAlign); + } + + __proto.blendMode=function(type){ + this.ctx.globalCompositeOperation=type; + } + + __proto.flush=function(){ + this.ctx.flush && this.ctx.flush(); + } + + __proto.addRenderObject=function(o){ + this.ctx.addRenderObject(o); + } + + __proto.beginClip=function(x,y,w,h){ + this.ctx.beginClip && this.ctx.beginClip(x,y,w,h); + } + + __proto.endClip=function(){ + this.ctx.endClip && this.ctx.endClip(); + } + + __proto.fillTrangles=function(x,y,args){ + this.ctx.fillTrangles(args[0],args[1],args[2],args[3],args.length > 4 ? args[4] :null); + } + + RenderContext.PI2=2 *Math.PI; + return RenderContext; + })() + + + /** + *@private + *精灵渲染器 + */ + //class laya.renders.RenderSprite + var RenderSprite=(function(){ + function RenderSprite(type,next){ + //this._next=null; + //this._fun=null; + this._next=next || RenderSprite.NORENDER; + switch (type){ + case 0: + this._fun=this._no; + return; + case 0x01: + this._fun=this._image; + return; + case 0x02: + this._fun=this._alpha; + return; + case 0x04: + this._fun=this._transform; + return; + case 0x20: + this._fun=this._blend; + return; + case 0x08: + this._fun=this._canvas; + return; + case 0x40: + this._fun=this._clip; + return; + case 0x80: + this._fun=this._style; + return; + case 0x100: + this._fun=this._graphics; + return; + case 0x800: + this._fun=this._childs; + return; + case 0x200: + this._fun=this._custom; + return; + case 0x01 | 0x100: + this._fun=this._image2; + return; + case 0x01 | 0x04 | 0x100: + this._fun=this._image2; + return; + case 0x10: + this._fun=Filter._filter; + return; + case 0x11111: + this._fun=RenderSprite._initRenderFun; + return; + } + this.onCreate(type); + } + + __class(RenderSprite,'laya.renders.RenderSprite'); + var __proto=RenderSprite.prototype; + __proto.onCreate=function(type){} + __proto._style=function(sprite,context,x,y){ + sprite._style.render(sprite,context,x,y); + var next=this._next; + next._fun.call(next,sprite,context,x,y); + } + + __proto._no=function(sprite,context,x,y){} + __proto._custom=function(sprite,context,x,y){ + sprite.customRender(context,x,y); + var tf=sprite._style._tf; + this._next._fun.call(this._next,sprite,context,x-tf.translateX,y-tf.translateY); + } + + __proto._clip=function(sprite,context,x,y){ + var next=this._next; + if (next==RenderSprite.NORENDER)return; + var r=sprite._style.scrollRect; + context.ctx.save(); + context.ctx.clipRect(x,y,r.width,r.height); + next._fun.call(next,sprite,context,x-r.x,y-r.y); + context.ctx.restore(); + } + + __proto._blend=function(sprite,context,x,y){ + var style=sprite._style; + if (style.blendMode){ + context.ctx.globalCompositeOperation=style.blendMode; + }; + var next=this._next; + next._fun.call(next,sprite,context,x,y); + var mask=sprite.mask; + if (mask){ + context.ctx.globalCompositeOperation="destination-in"; + if (mask.numChildren > 0 || !mask.graphics._isOnlyOne()){ + mask.cacheAsBitmap=true; + } + mask.render(context,x,y); + } + context.ctx.globalCompositeOperation="source-over"; + } + + __proto._graphics=function(sprite,context,x,y){ + var tf=sprite._style._tf; + sprite._graphics && sprite._graphics._render(sprite,context,x-tf.translateX,y-tf.translateY); + var next=this._next; + next._fun.call(next,sprite,context,x,y); + } + + __proto._image=function(sprite,context,x,y){ + var style=sprite._style; + context.ctx.drawTexture2(x,y,style._tf.translateX,style._tf.translateY,sprite.transform,style.alpha,style.blendMode,sprite._graphics._one); + } + + __proto._image2=function(sprite,context,x,y){ + var tf=sprite._style._tf; + context.ctx.drawTexture2(x,y,tf.translateX,tf.translateY,sprite.transform,1,null,sprite._graphics._one); + } + + __proto._alpha=function(sprite,context,x,y){ + var style=sprite._style; + var alpha; + if ((alpha=style.alpha)> 0.01){ + var temp=context.ctx.globalAlpha; + context.ctx.globalAlpha *=alpha; + var next=this._next; + next._fun.call(next,sprite,context,x,y); + context.ctx.globalAlpha=temp; + } + } + + __proto._transform=function(sprite,context,x,y){ + var transform=sprite.transform,_next=this._next; + if (transform && _next !=RenderSprite.NORENDER){ + context.save(); + context.transform(transform.a,transform.b,transform.c,transform.d,transform.tx+x,transform.ty+y); + _next._fun.call(_next,sprite,context,0,0); + context.restore(); + }else + _next._fun.call(_next,sprite,context,x,y); + } + + __proto._childs=function(sprite,context,x,y){ + var style=sprite._style; + x+=-style._tf.translateX+style.paddingLeft; + y+=-style._tf.translateY+style.paddingTop; + if (style._calculation){ + var words=sprite._getWords(); + words && context.fillWords(words,x,y,(style).font,(style).color); + }; + var childs=sprite._childs,n=childs.length,ele; + if (!sprite.viewport || !sprite.optimizeScrollRect){ + for (var i=0;i < n;++i) + (ele=(childs [i]))._style.visible && ele.render(context,x,y); + }else { + var rect=sprite.viewport; + var left=rect.x; + var top=rect.y; + var right=rect.right; + var bottom=rect.bottom; + var _x=NaN,_y=NaN; + for (i=0;i < n;++i){ + if ((ele=childs [i]).visible && ((_x=ele._x)< right && (_x+ele.width)> left && (_y=ele._y)< bottom && (_y+ele.height)> top)){ + ele.render(context,x,y); + } + } + } + } + + __proto._canvas=function(sprite,context,x,y){ + var _cacheCanvas=sprite._$P.cacheCanvas; + var _next=this._next; + if (!_cacheCanvas){ + _next._fun.call(_next,sprite,tx,x,y); + return; + }; + var tx=_cacheCanvas.ctx; + var _repaint=sprite._needRepaint()|| (!tx); + var canvas; + var left; + var top; + var tRec; + _cacheCanvas.type==='bitmap' ? (Stat.canvasBitmap++):(Stat.canvasNormal++); + if (_repaint){ + if (!_cacheCanvas._cacheRec) + _cacheCanvas._cacheRec=new Rectangle(); + var w,h; + tRec=sprite.getSelfBounds(); + tRec.x-=sprite.pivotX; + tRec.y-=sprite.pivotY; + tRec.x-=10; + tRec.y-=10; + tRec.width+=20; + tRec.height+=20; + tRec.x=Math.floor(tRec.x+x)-x; + tRec.y=Math.floor(tRec.y+y)-y; + tRec.width=Math.floor(tRec.width); + tRec.height=Math.floor(tRec.height); + _cacheCanvas._cacheRec.copyFrom(tRec); + tRec=_cacheCanvas._cacheRec; + var scaleX=Render.isWebGL ? 1 :Browser.pixelRatio *Laya.stage.clientScaleX; + var scaleY=Render.isWebGL ? 1 :Browser.pixelRatio *Laya.stage.clientScaleY; + if (!Render.isWebGL){ + var chainScaleX=1; + var chainScaleY=1; + var tar; + tar=sprite; + while (tar && tar !=Laya.stage){ + chainScaleX *=tar.scaleX; + chainScaleY *=tar.scaleY; + tar=tar.parent; + } + if(Render.isWebGL){ + if (chainScaleX < 1)scaleX *=chainScaleX; + if (chainScaleY < 1)scaleY *=chainScaleY; + }else{ + if (chainScaleX > 1)scaleX *=chainScaleX; + if (chainScaleY > 1)scaleY *=chainScaleY; + } + } + w=tRec.width *scaleX; + h=tRec.height *scaleY; + left=tRec.x; + top=tRec.y; + if (Render.isWebGL && _cacheCanvas.type==='bitmap' && (w > 2048 || h > 2048)){ + console.log("cache bitmap size larger than 2048,cache ignored"); + if(_cacheCanvas.ctx){ + Pool.recover("RenderContext",_cacheCanvas.ctx); + _cacheCanvas.ctx=null; + } + _next._fun.call(_next,sprite,context,x,y); + return; + } + if (!tx){ + tx=_cacheCanvas.ctx=Pool.getItem("RenderContext")|| new RenderContext(w,h,HTMLCanvas.create(/*laya.resource.HTMLCanvas.TYPEAUTO*/"AUTO")); + tx.ctx.sprite=sprite; + } + canvas=tx.canvas; + if (_cacheCanvas.type==='bitmap')canvas.context.asBitmap=true; + canvas.clear(); + (canvas.width !=w || canvas.height !=h)&& canvas.size(w,h); + var t; + if (scaleX !=1 || scaleY !=1){ + var ctx=(tx).ctx; + ctx.save(); + ctx.scale(scaleX,scaleY); + if (!Render.isConchWebGL && Render.isConchApp){ + t=sprite._$P.cf; + t && ctx.setFilterMatrix && ctx.setFilterMatrix(t._mat,t._alpha); + } + _next._fun.call(_next,sprite,tx,-left,-top); + ctx.restore(); + if (!Render.isConchApp || Render.isConchWebGL)sprite._applyFilters(); + }else { + ctx=(tx).ctx; + if (!Render.isConchWebGL && Render.isConchApp){ + t=sprite._$P.cf; + t && ctx.setFilterMatrix && ctx.setFilterMatrix(t._mat,t._alpha); + } + _next._fun.call(_next,sprite,tx,-left,-top); + if (!Render.isConchApp || Render.isConchWebGL)sprite._applyFilters(); + } + if (sprite._$P.staticCache)_cacheCanvas.reCache=false; + Stat.canvasReCache++; + }else { + tRec=_cacheCanvas._cacheRec; + left=tRec.x; + top=tRec.y; + canvas=tx.canvas; + } + context.drawCanvas(canvas,x+left,y+top,tRec.width,tRec.height); + } + + RenderSprite.__init__=function(){ + var i=0,len=0; + var initRender; + initRender=RunDriver.createRenderSprite(0x11111,null); + len=RenderSprite.renders.length=0x800 *2; + for (i=0;i < len;i++) + RenderSprite.renders[i]=initRender; + RenderSprite.renders[0]=RunDriver.createRenderSprite(0,null); + function _initSame (value,o){ + var n=0; + for (var i=0;i < value.length;i++){ + n |=value[i]; + RenderSprite.renders[n]=o; + } + } + _initSame([0x01,0x100,0x04,0x02],new RenderSprite(0x01,null)); + RenderSprite.renders[0x01 | 0x100]=RunDriver.createRenderSprite(0x01 | 0x100,null); + RenderSprite.renders[0x01 | 0x04 | 0x100]=new RenderSprite(0x01 | 0x04 | 0x100,null); + } + + RenderSprite._initRenderFun=function(sprite,context,x,y){ + var type=sprite._renderType; + var r=RenderSprite.renders[type]=RenderSprite._getTypeRender(type); + r._fun(sprite,context,x,y); + } + + RenderSprite._getTypeRender=function(type){ + var rst=null; + var tType=0x800; + while (tType > 1){ + if (tType & type) + rst=RunDriver.createRenderSprite(tType,rst); + tType=tType >> 1; + } + return rst; + } + + RenderSprite.IMAGE=0x01; + RenderSprite.ALPHA=0x02; + RenderSprite.TRANSFORM=0x04; + RenderSprite.CANVAS=0x08; + RenderSprite.FILTERS=0x10; + RenderSprite.BLEND=0x20; + RenderSprite.CLIP=0x40; + RenderSprite.STYLE=0x80; + RenderSprite.GRAPHICS=0x100; + RenderSprite.CUSTOM=0x200; + RenderSprite.CHILDS=0x800; + RenderSprite.INIT=0x11111; + RenderSprite.renders=[]; + RenderSprite.NORENDER=new RenderSprite(0,null); + return RenderSprite; + })() + + + /** + *@private + *Context扩展类 + */ + //class laya.resource.Context + var Context=(function(){ + function Context(){ + //this._canvas=null; + this._repaint=false; + } + + __class(Context,'laya.resource.Context'); + var __proto=Context.prototype; + __proto.setIsMainContext=function(){} + __proto.drawTextures=function(tex,pos,tx,ty){ + Stat.drawCall+=pos.length / 2; + var w=tex.bitmap.width; + var h=tex.bitmap.height; + for (var i=0,sz=pos.length;i < sz;i+=2){ + this.drawTexture(tex,pos[i],pos[i+1],w,h,tx,ty); + } + } + + /***@private */ + __proto.drawCanvas=function(canvas,x,y,width,height){ + Stat.drawCall++; + this.drawImage(canvas.source,x,y,width,height); + } + + /***@private */ + __proto.fillRect=function(x,y,width,height,style){ + Stat.drawCall++; + style && (this.fillStyle=style); + /*__JS__ */this.__fillRect(x,y,width,height); + } + + /***@private */ + __proto.fillText=function(text,x,y,font,color,textAlign){ + Stat.drawCall++; + if (arguments.length > 3 && font !=null){ + this.font=font; + this.fillStyle=color; + /*__JS__ */this.textAlign=textAlign; + this.textBaseline="top"; + } + /*__JS__ */this.__fillText(text,x,y); + } + + /***@private */ + __proto.fillBorderText=function(text,x,y,font,fillColor,borderColor,lineWidth,textAlign){ + Stat.drawCall++; + this.font=font; + this.fillStyle=fillColor; + this.textBaseline="top"; + /*__JS__ */this.strokeStyle=borderColor; + /*__JS__ */this.lineWidth=lineWidth; + /*__JS__ */this.textAlign=textAlign; + /*__JS__ */this.__strokeText(text,x,y); + /*__JS__ */this.__fillText(text,x,y); + } + + /***@private */ + __proto.strokeText=function(text,x,y,font,color,lineWidth,textAlign){ + Stat.drawCall++; + if (arguments.length > 3 && font !=null){ + this.font=font; + /*__JS__ */this.strokeStyle=color; + /*__JS__ */this.lineWidth=lineWidth; + /*__JS__ */this.textAlign=textAlign; + this.textBaseline="top"; + } + /*__JS__ */this.__strokeText(text,x,y); + } + + /***@private */ + __proto.transformByMatrix=function(value){ + this.transform(value.a,value.b,value.c,value.d,value.tx,value.ty); + } + + /***@private */ + __proto.setTransformByMatrix=function(value){ + this.setTransform(value.a,value.b,value.c,value.d,value.tx,value.ty); + } + + /***@private */ + __proto.clipRect=function(x,y,width,height){ + Stat.drawCall++; + this.beginPath(); + this.rect(x,y,width,height); + this.clip(); + } + + /***@private */ + __proto.drawTexture=function(tex,x,y,width,height,tx,ty){ + Stat.drawCall++; + var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height; + this.drawImage(tex.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,x+tx,y+ty,width,height); + } + + /***@private */ + __proto.drawTextureWithTransform=function(tex,x,y,width,height,m,tx,ty,alpha){ + Stat.drawCall++; + var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height; + this.save(); + alpha !=1 && (this.globalAlpha *=alpha); + if (m){ + this.transform(m.a,m.b,m.c,m.d,m.tx+tx,m.ty+ty); + this.drawImage(tex.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,x ,y,width,height); + }else { + this.drawImage(tex.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,x+tx ,y+ty,width,height); + } + this.restore(); + } + + /***@private */ + __proto.drawTexture2=function(x,y,pivotX,pivotY,m,alpha,blendMode,args2){ + 'use strict'; + var tex=args2[0]; + if (!(tex.loaded && tex.bitmap && tex.source)){ + return; + } + Stat.drawCall++; + var alphaChanged=alpha!==1; + if (alphaChanged){ + var temp=this.globalAlpha; + this.globalAlpha *=alpha; + }; + var uv=tex.uv,w=tex.bitmap.width,h=tex.bitmap.height; + if (m){ + this.save(); + this.transform(m.a,m.b,m.c,m.d,m.tx+x,m.ty+y); + this.drawImage(tex.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,args2[1]-pivotX ,args2[2]-pivotY,args2[3],args2[4]); + this.restore(); + }else { + this.drawImage(tex.source,uv[0] *w,uv[1] *h,(uv[2]-uv[0])*w,(uv[5]-uv[3])*h,args2[1]-pivotX+x ,args2[2]-pivotY+y,args2[3],args2[4]); + } + if (alphaChanged)this.globalAlpha=temp; + } + + __proto.fillTexture=function(texture,x,y,width,height,type,offset,other){ + if (!other.pat){ + if (texture.uv !=Texture.DEF_UV){ + var canvas=new HTMLCanvas("2D"); + canvas.getContext('2d'); + canvas.size(texture.width,texture.height); + canvas.context.drawTexture(texture,0,0,texture.width,texture.height,0,0); + texture=new Texture(canvas); + } + other.pat=this.createPattern(texture.bitmap.source,type); + }; + var oX=x,oY=y; + var sX=0,sY=0; + if (offset){ + oX+=offset.x % texture.width; + oY+=offset.y % texture.height; + sX-=offset.x % texture.width; + sY-=offset.y % texture.height; + } + this.translate(oX,oY); + this.fillRect(sX,sY,width,height,other.pat); + this.translate(-oX,-oY); + } + + /***@private */ + __proto.flush=function(){ + return 0; + } + + /***@private */ + __proto.fillWords=function(words,x,y,font,color){ + font && (this.font=font); + color && (this.fillStyle=color); + var _this=this; + this.textBaseline="top"; + /*__JS__ */this.textAlign='left'; + for (var i=0,n=words.length;i < n;i++){ + var a=words[i]; + /*__JS__ */this.__fillText(a.char,a.x+x,a.y+y); + } + } + + /***@private */ + __proto.destroy=function(){ + /*__JS__ */this.canvas.width=this.canvas.height=0; + } + + /***@private */ + __proto.clear=function(){ + this.clearRect(0,0,this._canvas.width,this._canvas.height); + this._repaint=false; + } + + Context.__init__=function(to){ + var from=laya.resource.Context.prototype; + to=to || /*__JS__ */CanvasRenderingContext2D.prototype; + to.__fillText=to.fillText; + to.__fillRect=to.fillRect; + to.__strokeText=to.strokeText; + var funs=['drawTextures','fillWords','setIsMainContext','fillRect','strokeText','fillTexture','fillText','transformByMatrix','setTransformByMatrix','clipRect','drawTexture','drawTexture2','drawTextureWithTransform','flush','clear','destroy','drawCanvas','fillBorderText']; + funs.forEach(function(i){ + to[i]=from[i] || to[i]; + }); + } + + Context._default=new Context(); + return Context; + })() + + + /** + *ResourceManager 是资源管理类。它用于资源的载入、获取、销毁。 + */ + //class laya.resource.ResourceManager + var ResourceManager=(function(){ + function ResourceManager(){ + this._id=0; + this._name=null; + this._resources=null; + this._memorySize=0; + this._garbageCollectionRate=NaN; + this._isOverflow=false; + this.autoRelease=false; + this.autoReleaseMaxSize=0; + this._id=++ResourceManager._uniqueIDCounter; + this._name="Content Manager"; + ResourceManager._isResourceManagersSorted=false; + this._memorySize=0; + this._isOverflow=false; + this.autoRelease=false; + this.autoReleaseMaxSize=1024 *1024 *512; + this._garbageCollectionRate=0.2; + ResourceManager._resourceManagers.push(this); + this._resources=[]; + } + + __class(ResourceManager,'laya.resource.ResourceManager'); + var __proto=ResourceManager.prototype; + Laya.imps(__proto,{"laya.resource.IDispose":true}) + /** + *获取指定索引的资源 Resource 对象。 + *@param 索引。 + *@return 资源 Resource 对象。 + */ + __proto.getResourceByIndex=function(index){ + return this._resources[index]; + } + + /** + *获取此管理器所管理的资源个数。 + *@return 资源个数。 + */ + __proto.getResourcesLength=function(){ + return this._resources.length; + } + + /** + *添加指定资源。 + *@param resource 需要添加的资源 Resource 对象。 + *@return 是否添加成功。 + */ + __proto.addResource=function(resource){ + if (resource.resourceManager) + resource.resourceManager.removeResource(resource); + var index=this._resources.indexOf(resource); + if (index===-1){ + resource._resourceManager=this; + this._resources.push(resource); + this.addSize(resource.memorySize); + return true; + } + return false; + } + + /** + *移除指定资源。 + *@param resource 需要移除的资源 Resource 对象 + *@return 是否移除成功。 + */ + __proto.removeResource=function(resource){ + var index=this._resources.indexOf(resource); + if (index!==-1){ + this._resources.splice(index,1); + resource._resourceManager=null; + this._memorySize-=resource.memorySize; + return true; + } + return false; + } + + /** + *卸载此资源管理器载入的资源。 + */ + __proto.unload=function(){ + var tempResources=this._resources.slice(0,this._resources.length); + for (var i=0;i < tempResources.length;i++){ + var resource=tempResources[i]; + resource.dispose(); + } + tempResources.length=0; + } + + /** + *设置唯一名字。 + *@param newName 名字,如果名字重复则自动加上“-copy”。 + */ + __proto.setUniqueName=function(newName){ + var isUnique=true; + for (var i=0;i < ResourceManager._resourceManagers.length;i++){ + if (ResourceManager._resourceManagers[i]._name!==newName || ResourceManager._resourceManagers[i]===this) + continue ; + isUnique=false; + return; + } + if (isUnique){ + if (this.name !=newName){ + this.name=newName; + ResourceManager._isResourceManagersSorted=false; + } + }else{ + this.setUniqueName(newName.concat("-copy")); + } + } + + /**释放资源。*/ + __proto.dispose=function(){ + if (this===ResourceManager._systemResourceManager) + throw new Error("systemResourceManager不能被释放!"); + ResourceManager._resourceManagers.splice(ResourceManager._resourceManagers.indexOf(this),1); + ResourceManager._isResourceManagersSorted=false; + var tempResources=this._resources.slice(0,this._resources.length); + for (var i=0;i < tempResources.length;i++){ + var resource=tempResources[i]; + resource.resourceManager.removeResource(resource); + resource.dispose(); + } + tempResources.length=0; + } + + /** + *增加内存。 + *@param add 需要增加的内存大小。 + */ + __proto.addSize=function(add){ + if (add){ + if (this.autoRelease && add > 0) + ((this._memorySize+add)> this.autoReleaseMaxSize)&& (this.garbageCollection((1-this._garbageCollectionRate)*this.autoReleaseMaxSize)); + this._memorySize+=add; + } + } + + /** + *垃圾回收。 + *@param reserveSize 保留尺寸。 + */ + __proto.garbageCollection=function(reserveSize){ + var all=this._resources; + all=all.slice(); + all.sort(function(a,b){ + if (!a || !b) + throw new Error("a或b不能为空!"); + if (a.released && b.released) + return 0; + else if (a.released) + return 1; + else if (b.released) + return-1; + return a.lastUseFrameCount-b.lastUseFrameCount; + }); + var currentFrameCount=Stat.loopCount; + for (var i=0,n=all.length;i < n;i++){ + var resou=all[i]; + if (currentFrameCount-resou.lastUseFrameCount > 1){ + resou.releaseResource(); + }else { + if (this._memorySize >=reserveSize) + this._isOverflow=true; + return; + } + if (this._memorySize < reserveSize){ + this._isOverflow=false; + return; + } + } + } + + /** + *唯一标识 ID 。 + */ + __getset(0,__proto,'id',function(){ + return this._id; + }); + + /** + *名字。 + */ + __getset(0,__proto,'name',function(){ + return this._name; + },function(value){ + if ((value || value!=="")&& this._name!==value){ + this._name=value; + ResourceManager._isResourceManagersSorted=false; + } + }); + + /** + *此管理器所管理资源的累计内存,以字节为单位。 + */ + __getset(0,__proto,'memorySize',function(){ + return this._memorySize; + }); + + /** + *系统资源管理器。 + */ + __getset(1,ResourceManager,'systemResourceManager',function(){ + (ResourceManager._systemResourceManager===null)&& (ResourceManager._systemResourceManager=new ResourceManager(),ResourceManager._systemResourceManager._name="System Resource Manager"); + return ResourceManager._systemResourceManager; + }); + + /** + *排序后的资源管理器列表。 + */ + __getset(1,ResourceManager,'sortedResourceManagersByName',function(){ + if (!ResourceManager._isResourceManagersSorted){ + ResourceManager._isResourceManagersSorted=true; + ResourceManager._resourceManagers.sort(ResourceManager.compareResourceManagersByName); + } + return ResourceManager._resourceManagers; + }); + + ResourceManager.__init__=function(){ + ResourceManager.currentResourceManager=ResourceManager.systemResourceManager; + } + + ResourceManager.getLoadedResourceManagerByIndex=function(index){ + return ResourceManager._resourceManagers[index]; + } + + ResourceManager.getLoadedResourceManagersCount=function(){ + return ResourceManager._resourceManagers.length; + } + + ResourceManager.recreateContentManagers=function(force){ + (force===void 0)&& (force=false); + var temp=ResourceManager.currentResourceManager; + for (var i=0;i < ResourceManager._resourceManagers.length;i++){ + ResourceManager.currentResourceManager=ResourceManager._resourceManagers[i]; + for (var j=0;j < ResourceManager.currentResourceManager._resources.length;j++){ + ResourceManager.currentResourceManager._resources[j].releaseResource(force); + ResourceManager.currentResourceManager._resources[j].activeResource(force); + } + } + ResourceManager.currentResourceManager=temp; + } + + ResourceManager.releaseContentManagers=function(force){ + (force===void 0)&& (force=false); + var temp=ResourceManager.currentResourceManager; + for (var i=0;i < ResourceManager._resourceManagers.length;i++){ + ResourceManager.currentResourceManager=ResourceManager._resourceManagers[i]; + for (var j=0;j < ResourceManager.currentResourceManager._resources.length;j++){ + var resource=ResourceManager.currentResourceManager._resources[j]; + (!resource.released)&& (resource.releaseResource(force)); + } + } + ResourceManager.currentResourceManager=temp; + } + + ResourceManager.compareResourceManagersByName=function(left,right){ + if (left==right) + return 0; + var x=left._name; + var y=right._name; + if (x==null){ + if (y==null) + return 0; + else + return-1; + }else { + if (y==null) + return 1; + else { + var retval=x.localeCompare(y); + if (retval !=0) + return retval; + else { + right.setUniqueName(y); + y=right._name; + return x.localeCompare(y); + } + } + } + } + + ResourceManager._uniqueIDCounter=0; + ResourceManager._systemResourceManager=null + ResourceManager._isResourceManagersSorted=false; + ResourceManager._resourceManagers=[]; + ResourceManager.currentResourceManager=null + return ResourceManager; + })() + + + /** + *@private + */ + //class laya.resource.WXCanvas + var WXCanvas=(function(){ + function WXCanvas(id){ + this._ctx=null; + this._id=null; + this.style={}; + this._id=id; + } + + __class(WXCanvas,'laya.resource.WXCanvas'); + var __proto=WXCanvas.prototype; + __proto.getContext=function(){ + var wx=laya.resource.WXCanvas.wx; + var ctx=wx.createContext(); + ctx.id=this._id; + ctx.fillRect=function (x,y,w,h){ + this.rect(x,y,w,h); + this.fill(); + } + ctx.strokeRect=function (x,y,w,h){ + this.rect(x,y,w,h); + this.stroke(); + } + ctx.___drawImage=ctx.drawImage; + ctx.drawImage=function (){ + var img=arguments[0].tempFilePath; + if (img==null)return; + switch(arguments.length){ + case 3: + this.___drawImage(img,arguments[1],arguments[2],arguments[0].width,arguments[0].height); + return; + case 5: + this.___drawImage(img,arguments[1],arguments[2],arguments[3],arguments[4]); + return; + case 9: + this.___drawImage(img,arguments[5],arguments[6],arguments[7],arguments[8]); + return; + } + } + Object.defineProperty(ctx,"strokeStyle",{set:function (value){this.setStrokeStyle(value)},enumerable:false }); + Object.defineProperty(ctx,"fillStyle",{set:function (value){this.setFillStyle(value)},enumerable:false }); + Object.defineProperty(ctx,"fontSize",{set:function (value){this.setFontSize(value)},enumerable:false }); + Object.defineProperty(ctx,"lineWidth",{set:function (value){this.setLineWidth(value)},enumerable:false }); + Context.__init__(ctx); + ctx.flush=function (){ + wx.drawCanvas({canvasId:this.id,actions:this.getActions()}); + } + return ctx; + } + + __proto.oncontextmenu=function(e){} + __proto.addEventListener=function(){} + __getset(0,__proto,'id',function(){ + return this._id; + },function(value){ + this._id=value; + }); + + WXCanvas.wx=null; + return WXCanvas; + })() + + + /** + *@private + */ + //class laya.system.System + var System=(function(){ + function System(){}; + __class(System,'laya.system.System'); + System.changeDefinition=function(name,classObj){ + Laya[name]=classObj; + var str=name+"=classObj"; + /*__JS__ */eval(str); + } + + System.__init__=function(){ + if (Render.isConchApp){ + /*__JS__ */conch.disableConchResManager(); + /*__JS__ */conch.disableConchAutoRestoreLostedDevice(); + } + } + + return System; + })() + + + SoundManager; + /** + *Browser 是浏览器代理类。封装浏览器及原生 js 提供的一些功能。 + */ + //class laya.utils.Browser + var Browser=(function(){ + function Browser(){}; + __class(Browser,'laya.utils.Browser'); + /**设备像素比。*/ + __getset(1,Browser,'pixelRatio',function(){ + Browser.__init__(); + return RunDriver.getPixelRatio(); + }); + + /**浏览器物理高度。*/ + __getset(1,Browser,'height',function(){ + Browser.__init__(); + return ((Laya.stage && Laya.stage.canvasRotation)? Browser.clientWidth :Browser.clientHeight)*Browser.pixelRatio; + }); + + /**浏览器可视宽度。*/ + __getset(1,Browser,'clientWidth',function(){ + Browser.__init__(); + return Browser.window.innerWidth || Browser.document.body.clientWidth; + }); + + /**浏览器原生 window 对象的引用。*/ + __getset(1,Browser,'window',function(){ + Browser.__init__(); + return Browser._window; + }); + + /**浏览器可视高度。*/ + __getset(1,Browser,'clientHeight',function(){ + Browser.__init__(); + return Browser.window.innerHeight || Browser.document.body.clientHeight || Browser.document.documentElement.clientHeight; + }); + + /**浏览器物理宽度,。*/ + __getset(1,Browser,'width',function(){ + Browser.__init__(); + return ((Laya.stage && Laya.stage.canvasRotation)? Browser.clientHeight :Browser.clientWidth)*Browser.pixelRatio; + }); + + /**画布容器,用来盛放画布的容器。方便对画布进行控制*/ + __getset(1,Browser,'container',function(){ + Browser.__init__(); + if (!Browser._container){ + Browser._container=Browser.createElement("div"); + Browser._container.id="layaContainer"; + Browser.document.body.appendChild(Browser._container); + } + return Browser._container; + },function(value){ + Browser._container=value; + }); + + /**浏览器原生 document 对象的引用。*/ + __getset(1,Browser,'document',function(){ + Browser.__init__(); + return Browser._document; + }); + + Browser.__init__=function(){ + SoundManager; + if (Browser._window)return; + Browser._window=RunDriver.getWindow(); + Browser._document=Browser.window.document; + Browser._window.addEventListener('message',function(e){ + laya.utils.Browser._onMessage(e); + },false); + /*__JS__ */Browser.document.__createElement=Browser.document.createElement; + /*__JS__ */window.requestAnimationFrame=(function(){return window.requestAnimationFrame || window.webkitRequestAnimationFrame ||window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||function (c){return window.setTimeout(c,1000 / 60);};})(); + /*__JS__ */var $BS=window.document.body.style;$BS.margin=0;$BS.overflow='hidden';; + /*__JS__ */var metas=window.document.getElementsByTagName('meta');; + /*__JS__ */var i=0,flag=false,content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no';; + /*__JS__ */while(i-1; + Browser.onIPhone=/*[SAFE]*/ Browser.u.indexOf("iPhone")>-1; + Browser.onIPad=/*[SAFE]*/ Browser.u.indexOf("iPad")>-1; + Browser.onAndriod=/*[SAFE]*/ Browser.u.indexOf('Android')>-1 || Browser.u.indexOf('Adr')>-1; + Browser.onWP=/*[SAFE]*/ Browser.u.indexOf("Windows Phone")>-1; + Browser.onQQBrowser=/*[SAFE]*/ Browser.u.indexOf("QQBrowser")>-1; + Browser.onMQQBrowser=/*[SAFE]*/ Browser.u.indexOf("MQQBrowser")>-1; + Browser.onWeiXin=/*[SAFE]*/ Browser.u.indexOf('MicroMessenger')>-1; + Browser.onPC=/*[SAFE]*/ !Browser.onMobile; + Browser.onSafari=/*[SAFE]*/ !!Browser.u.match(/Version\/\d+\.\d\x20Mobile\/\S+\x20Safari/); + Browser.httpProtocol=/*[SAFE]*/ Browser.window.location.protocol=="http:"; + Browser.webAudioEnabled=/*[SAFE]*/ Browser.window["AudioContext"] || Browser.window["webkitAudioContext"] || Browser.window["mozAudioContext"] ? true :false; + Browser.soundType=/*[SAFE]*/ Browser.webAudioEnabled ? "WEBAUDIOSOUND" :"AUDIOSOUND"; + /*__JS__ */Sound=Browser.webAudioEnabled?WebAudioSound:AudioSound;; + /*__JS__ */if (Browser.webAudioEnabled)WebAudioSound.initWebAudio();; + /*__JS__ */Browser.enableTouch=(('ontouchstart' in window)|| window.DocumentTouch && document instanceof DocumentTouch); + /*__JS__ */window.focus(); + /*__JS__ */SoundManager._soundClass=Sound;; + var MainCanvas=null; + if (Browser.window.MainCanvasID){ + var _wx=/*__JS__ */wx; + if (_wx && !_wx.createContext)_wx=null; + if ((WXCanvas.wx=_wx)!=null){ + MainCanvas=new WXCanvas(Browser.window.MainCanvasID); + var from=Context.prototype; + from.flush=null; + Browser.window.Image=function (){ + this.setSrc=function (url){ + this.__src=url; + var _this=this; + this.success(); + } + this.success=function (res){ + this.width=200; + this.height=200; + this.tempFilePath=res ? res.tempFilePath :this.__src; + this.onload && this.onload(); + } + this.getSrc=function (){ + return this.__src; + } + Object.defineProperty(this,"src",{get:this.getSrc,set:this.setSrc,enumerable:false }); + } + }else { + MainCanvas=Browser.document.getElementById(Browser.window.MainCanvasID); + } + } + Render._mainCanvas=Render._mainCanvas || HTMLCanvas.create('2D',MainCanvas); + if (Browser.canvas)return; + Browser.canvas=HTMLCanvas.create('2D'); + Browser.context=Browser.canvas.getContext('2d'); + } + + Browser._onMessage=function(e){ + if (!e.data)return; + if (e.data.name=="size"){ + Browser.window.innerWidth=e.data.width; + Browser.window.innerHeight=e.data.height; + Browser.window.__innerHeight=e.data.clientHeight; + if (!Browser.document.createEvent){ + console.log("no document.createEvent"); + return; + }; + var evt=Browser.document.createEvent("HTMLEvents"); + evt.initEvent("resize",false,false); + Browser.window.dispatchEvent(evt); + return; + } + } + + Browser.createElement=function(type){ + Browser.__init__(); + return Browser.document.__createElement(type); + } + + Browser.getElementById=function(type){ + Browser.__init__(); + return Browser.document.getElementById(type); + } + + Browser.removeElement=function(ele){ + if (ele && ele.parentNode)ele.parentNode.removeChild(ele); + } + + Browser.now=function(){ + return RunDriver.now(); + } + + Browser._window=null + Browser._document=null + Browser._container=null + Browser.userAgent=null + Browser.u=null + Browser.onIOS=false; + Browser.onMobile=false; + Browser.onIPhone=false; + Browser.onIPad=false; + Browser.onAndriod=false; + Browser.onWP=false; + Browser.onQQBrowser=false; + Browser.onMQQBrowser=false; + Browser.onSafari=false; + Browser.onWeiXin=false; + Browser.onPC=false; + Browser.httpProtocol=false; + Browser.webAudioEnabled=false; + Browser.soundType=null + Browser.enableTouch=false; + Browser.canvas=null + Browser.context=null + Browser.__init$=function(){ + AudioSound; + WebAudioSound; + } + + return Browser; + })() + + + /** + * + *Byte 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 + */ + //class laya.utils.Byte + var Byte=(function(){ + function Byte(data){ + this._xd_=true; + this._allocated_=8; + //this._d_=null; + //this._u8d_=null; + this._pos_=0; + this._length=0; + if (data){ + this._u8d_=new Uint8Array(data); + this._d_=new DataView(this._u8d_.buffer); + this._length=this._d_.byteLength; + }else { + this.___resizeBuffer(this._allocated_); + } + } + + __class(Byte,'laya.utils.Byte'); + var __proto=Byte.prototype; + /**@private */ + __proto.___resizeBuffer=function(len){ + try { + var newByteView=new Uint8Array(len); + if (this._u8d_ !=null){ + if (this._u8d_.length <=len)newByteView.set(this._u8d_); + else newByteView.set(this._u8d_.subarray(0,len)); + } + this._u8d_=newByteView; + this._d_=new DataView(newByteView.buffer); + }catch (err){ + throw "___resizeBuffer err:"+len; + } + } + + /** + *读取字符型值。 + *@return + */ + __proto.getString=function(){ + return this.rUTF(this.getUint16()); + } + + /** + *从指定的位置读取指定长度的数据用于创建一个 Float32Array 对象并返回此对象。 + *@param start 开始位置。 + *@param len 需要读取的字节长度。 + *@return 读出的 Float32Array 对象。 + */ + __proto.getFloat32Array=function(start,len){ + var v=new Float32Array(this._d_.buffer.slice(start,start+len)); + this._pos_+=len; + return v; + } + + /** + *从指定的位置读取指定长度的数据用于创建一个 Uint8Array 对象并返回此对象。 + *@param start 开始位置。 + *@param len 需要读取的字节长度。 + *@return 读出的 Uint8Array 对象。 + */ + __proto.getUint8Array=function(start,len){ + var v=new Uint8Array(this._d_.buffer.slice(start,start+len)); + this._pos_+=len; + return v; + } + + /** + *从指定的位置读取指定长度的数据用于创建一个 Int16Array 对象并返回此对象。 + *@param start 开始位置。 + *@param len 需要读取的字节长度。 + *@return 读出的 Uint8Array 对象。 + */ + __proto.getInt16Array=function(start,len){ + var v=new Int16Array(this._d_.buffer.slice(start,start+len)); + this._pos_+=len; + return v; + } + + /** + *在指定字节偏移量位置处读取 Float32 值。 + *@return Float32 值。 + */ + __proto.getFloat32=function(){ + var v=this._d_.getFloat32(this._pos_,this._xd_); + this._pos_+=4; + return v; + } + + __proto.getFloat64=function(){ + var v=this._d_.getFloat64(this._pos_,this._xd_); + this._pos_+=8; + return v; + } + + /** + *在当前字节偏移量位置处写入 Float32 值。 + *@param value 需要写入的 Float32 值。 + */ + __proto.writeFloat32=function(value){ + this.ensureWrite(this._pos_+4); + this._d_.setFloat32(this._pos_,value,this._xd_); + this._pos_+=4; + } + + __proto.writeFloat64=function(value){ + this.ensureWrite(this._pos_+8); + this._d_.setFloat64(this._pos_,value,this._xd_); + this._pos_+=8; + } + + /** + *在当前字节偏移量位置处读取 Int32 值。 + *@return Int32 值。 + */ + __proto.getInt32=function(){ + var float=this._d_.getInt32(this._pos_,this._xd_); + this._pos_+=4; + return float; + } + + /** + *在当前字节偏移量位置处读取 Uint32 值。 + *@return Uint32 值。 + */ + __proto.getUint32=function(){ + var v=this._d_.getUint32(this._pos_,this._xd_); + this._pos_+=4; + return v; + } + + /** + *在当前字节偏移量位置处写入 Int32 值。 + *@param value 需要写入的 Int32 值。 + */ + __proto.writeInt32=function(value){ + this.ensureWrite(this._pos_+4); + this._d_.setInt32(this._pos_,value,this._xd_); + this._pos_+=4; + } + + /** + *在当前字节偏移量位置处写入 Uint32 值。 + *@param value 需要写入的 Uint32 值。 + */ + __proto.writeUint32=function(value){ + this.ensureWrite(this._pos_+4); + this._d_.setUint32(this._pos_,value,this._xd_); + this._pos_+=4; + } + + /** + *在当前字节偏移量位置处读取 Int16 值。 + *@return Int16 值。 + */ + __proto.getInt16=function(){ + var us=this._d_.getInt16(this._pos_,this._xd_); + this._pos_+=2; + return us; + } + + /** + *在当前字节偏移量位置处读取 Uint16 值。 + *@return Uint16 值。 + */ + __proto.getUint16=function(){ + var us=this._d_.getUint16(this._pos_,this._xd_); + this._pos_+=2; + return us; + } + + /** + *在当前字节偏移量位置处写入 Uint16 值。 + *@param value 需要写入的Uint16 值。 + */ + __proto.writeUint16=function(value){ + this.ensureWrite(this._pos_+2); + this._d_.setUint16(this._pos_,value,this._xd_); + this._pos_+=2; + } + + /** + *在当前字节偏移量位置处写入 Int16 值。 + *@param value 需要写入的 Int16 值。 + */ + __proto.writeInt16=function(value){ + this.ensureWrite(this._pos_+2); + this._d_.setInt16(this._pos_,value,this._xd_); + this._pos_+=2; + } + + /** + *在当前字节偏移量位置处读取 Uint8 值。 + *@return Uint8 值。 + */ + __proto.getUint8=function(){ + return this._d_.getUint8(this._pos_++); + } + + /** + *在当前字节偏移量位置处写入 Uint8 值。 + *@param value 需要写入的 Uint8 值。 + */ + __proto.writeUint8=function(value){ + this.ensureWrite(this._pos_+1); + this._d_.setUint8(this._pos_,value,this._xd_); + this._pos_++; + } + + /** + *@private + *在指定位置处读取 Uint8 值。 + *@param pos 字节读取位置。 + *@return Uint8 值。 + */ + __proto._getUInt8=function(pos){ + return this._d_.getUint8(pos); + } + + /** + *@private + *在指定位置处读取 Uint16 值。 + *@param pos 字节读取位置。 + *@return Uint16 值。 + */ + __proto._getUint16=function(pos){ + return this._d_.getUint16(pos,this._xd_); + } + + /** + *@private + *使用 getFloat32()读取6个值,用于创建并返回一个 Matrix 对象。 + *@return Matrix 对象。 + */ + __proto._getMatrix=function(){ + var rst=new Matrix(this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32()); + return rst; + } + + /** + *@private + *读取指定长度的 UTF 型字符串。 + *@param len 需要读取的长度。 + *@return 读出的字符串。 + */ + __proto.rUTF=function(len){ + var v="",max=this._pos_+len,c=0,c2=0,c3=0,f=String.fromCharCode; + var u=this._u8d_,i=0; + while (this._pos_ < max){ + c=u[this._pos_++]; + if (c < 0x80){ + if (c !=0){ + v+=f(c); + } + }else if (c < 0xE0){ + v+=f(((c & 0x3F)<< 6)| (u[this._pos_++] & 0x7F)); + }else if (c < 0xF0){ + c2=u[this._pos_++]; + v+=f(((c & 0x1F)<< 12)| ((c2 & 0x7F)<< 6)| (u[this._pos_++] & 0x7F)); + }else { + c2=u[this._pos_++]; + c3=u[this._pos_++]; + v+=f(((c & 0x0F)<< 18)| ((c2 & 0x7F)<< 12)| ((c3 << 6)& 0x7F)| (u[this._pos_++] & 0x7F)); + } + i++; + } + return v; + } + + /** + *字符串读取。 + *@param len + *@return + */ + __proto.getCustomString=function(len){ + var v="",ulen=0,c=0,c2=0,f=String.fromCharCode; + var u=this._u8d_,i=0; + while (len > 0){ + c=u[this._pos_]; + if (c < 0x80){ + v+=f(c); + this._pos_++; + len--; + }else { + ulen=c-0x80; + this._pos_++; + len-=ulen; + while (ulen > 0){ + c=u[this._pos_++]; + c2=u[this._pos_++]; + v+=f((c2 << 8)| c); + ulen--; + } + } + } + return v; + } + + /** + *清除数据。 + */ + __proto.clear=function(){ + this._pos_=0; + this.length=0; + } + + /** + *@private + *获取此对象的 ArrayBuffer 引用。 + *@return + */ + __proto.__getBuffer=function(){ + return this._d_.buffer; + } + + /** + *写入字符串,该方法写的字符串要使用 readUTFBytes 方法读取。 + *@param value 要写入的字符串。 + */ + __proto.writeUTFBytes=function(value){ + value=value+""; + for (var i=0,sz=value.length;i < sz;i++){ + var c=value.charCodeAt(i); + if (c <=0x7F){ + this.writeByte(c); + }else if (c <=0x7FF){ + this.writeByte(0xC0 | (c >> 6)); + this.writeByte(0x80 | (c & 63)); + }else if (c <=0xFFFF){ + this.writeByte(0xE0 | (c >> 12)); + this.writeByte(0x80 | ((c >> 6)& 63)); + this.writeByte(0x80 | (c & 63)); + }else { + this.writeByte(0xF0 | (c >> 18)); + this.writeByte(0x80 | ((c >> 12)& 63)); + this.writeByte(0x80 | ((c >> 6)& 63)); + this.writeByte(0x80 | (c & 63)); + } + } + } + + /** + *将 UTF-8 字符串写入字节流。 + *@param value 要写入的字符串值。 + */ + __proto.writeUTFString=function(value){ + var tPos=0; + tPos=this.pos; + this.writeUint16(1); + this.writeUTFBytes(value); + var dPos=0; + dPos=this.pos-tPos-2; + this._d_.setUint16(tPos,dPos,this._xd_); + } + + /** + *@private + *读取 UTF-8 字符串。 + *@return 读出的字符串。 + */ + __proto.readUTFString=function(){ + var tPos=0; + tPos=this.pos; + var len=0; + len=this.getUint16(); + return this.readUTFBytes(len); + } + + /** + *读取 UTF-8 字符串。 + *@return 读出的字符串。 + */ + __proto.getUTFString=function(){ + return this.readUTFString(); + } + + /** + *@private + *读字符串,必须是 writeUTFBytes 方法写入的字符串。 + *@param len 要读的buffer长度,默认将读取缓冲区全部数据。 + *@return 读取的字符串。 + */ + __proto.readUTFBytes=function(len){ + (len===void 0)&& (len=-1); + if(len==0)return ""; + len=len > 0 ? len :this.bytesAvailable; + return this.rUTF(len); + } + + /** + *读字符串,必须是 writeUTFBytes 方法写入的字符串。 + *@param len 要读的buffer长度,默认将读取缓冲区全部数据。 + *@return 读取的字符串。 + */ + __proto.getUTFBytes=function(len){ + (len===void 0)&& (len=-1); + return this.readUTFBytes(len); + } + + /** + *在字节流中写入一个字节。 + *@param value + */ + __proto.writeByte=function(value){ + this.ensureWrite(this._pos_+1); + this._d_.setInt8(this._pos_,value); + this._pos_+=1; + } + + /** + *@private + *在字节流中读一个字节。 + */ + __proto.readByte=function(){ + return this._d_.getInt8(this._pos_++); + } + + /** + *在字节流中读一个字节。 + */ + __proto.getByte=function(){ + return this.readByte(); + } + + /** + *指定该字节流的长度。 + *@param lengthToEnsure 指定的长度。 + */ + __proto.ensureWrite=function(lengthToEnsure){ + if (this._length < lengthToEnsure)this._length=lengthToEnsure; + if (this._allocated_ < lengthToEnsure)this.length=lengthToEnsure; + } + + /** + *写入指定的 Arraybuffer 对象。 + *@param arraybuffer 需要写入的 Arraybuffer 对象。 + *@param offset 偏移量(以字节为单位) + *@param length 长度(以字节为单位) + */ + __proto.writeArrayBuffer=function(arraybuffer,offset,length){ + (offset===void 0)&& (offset=0); + (length===void 0)&& (length=0); + if (offset < 0 || length < 0)throw "writeArrayBuffer error - Out of bounds"; + if (length==0)length=arraybuffer.byteLength-offset; + this.ensureWrite(this._pos_+length); + var uint8array=new Uint8Array(arraybuffer); + this._u8d_.set(uint8array.subarray(offset,offset+length),this._pos_); + this._pos_+=length; + } + + /** + *获取此对象的 ArrayBuffer数据,数据只包含有效数据部分 。 + */ + __getset(0,__proto,'buffer',function(){ + var rstBuffer=this._d_.buffer; + if (rstBuffer.byteLength==this.length)return rstBuffer; + return rstBuffer.slice(0,this.length); + }); + + /** + *字节顺序。 + */ + __getset(0,__proto,'endian',function(){ + return this._xd_ ? "littleEndian" :"bigEndian"; + },function(endianStr){ + this._xd_=(endianStr=="littleEndian"); + }); + + /** + *字节长度。 + */ + __getset(0,__proto,'length',function(){ + return this._length; + },function(value){ + if (this._allocated_ < value) + this.___resizeBuffer(this._allocated_=Math.floor(Math.max(value,this._allocated_ *2))); + else if (this._allocated_ > value) + this.___resizeBuffer(this._allocated_=value); + this._length=value; + }); + + /** + *当前读取到的位置。 + */ + __getset(0,__proto,'pos',function(){ + return this._pos_; + },function(value){ + this._pos_=value; + this._d_.byteOffset=value; + }); + + /** + *可从字节流的当前位置到末尾读取的数据的字节数。 + */ + __getset(0,__proto,'bytesAvailable',function(){ + return this.length-this._pos_; + }); + + Byte.getSystemEndian=function(){ + if (!Byte._sysEndian){ + var buffer=new ArrayBuffer(2); + new DataView(buffer).setInt16(0,256,true); + Byte._sysEndian=(new Int16Array(buffer))[0]===256 ? /*CLASS CONST:laya.utils.Byte.LITTLE_ENDIAN*/"littleEndian" :/*CLASS CONST:laya.utils.Byte.BIG_ENDIAN*/"bigEndian"; + } + return Byte._sysEndian; + } + + Byte.BIG_ENDIAN="bigEndian"; + Byte.LITTLE_ENDIAN="littleEndian"; + Byte._sysEndian=null; + return Byte; + })() + + + /** + *对象缓存统一管理类 + */ + //class laya.utils.CacheManger + var CacheManger=(function(){ + function CacheManger(){} + __class(CacheManger,'laya.utils.CacheManger'); + CacheManger.regCacheByFunction=function(disposeFunction,getCacheListFunction){ + CacheManger.unRegCacheByFunction(disposeFunction,getCacheListFunction); + var cache; + cache={ + tryDispose:disposeFunction, + getCacheList:getCacheListFunction + }; + CacheManger._cacheList.push(cache); + } + + CacheManger.unRegCacheByFunction=function(disposeFunction,getCacheListFunction){ + var i=0,len=0; + len=CacheManger._cacheList.length; + for (i=0;i < len;i++){ + if (CacheManger._cacheList[i].tryDispose==disposeFunction && CacheManger._cacheList[i].getCacheList==getCacheListFunction){ + CacheManger._cacheList.splice(i,1); + return; + } + } + } + + CacheManger.forceDispose=function(){ + var i=0,len=CacheManger._cacheList.length; + for(i=0;i 0){ + CacheManger._index++; + CacheManger._index=CacheManger._index % len; + cacheList[CacheManger._index].tryDispose(false); + if (Browser.now()-tTime > CacheManger.loopTimeLimit)break ; + count--; + } + } + + CacheManger.loopTimeLimit=2; + CacheManger._cacheList=[]; + CacheManger._index=0; + return CacheManger; + })() + + + /** + *ClassUtils 是一个类工具类。 + */ + //class laya.utils.ClassUtils + var ClassUtils=(function(){ + function ClassUtils(){}; + __class(ClassUtils,'laya.utils.ClassUtils'); + ClassUtils.regClass=function(className,classDef){ + ClassUtils._classMap[className]=classDef; + } + + ClassUtils.getRegClass=function(className){ + return ClassUtils._classMap[className]; + } + + ClassUtils.getInstance=function(className){ + var compClass=ClassUtils.getClass(className); + if (compClass) + return new compClass(); + else + console.log("[error] Undefined class:",className); + return null; + } + + ClassUtils.createByJson=function(json,node,root,customHandler,instanceHandler){ + if ((typeof json=='string')) + json=JSON.parse(json); + var props=json.props; + if (!node){ + node=instanceHandler ? instanceHandler.runWith(json):ClassUtils.getInstance(props.runtime || json.type); + if (!node) + return null; + }; + var child=json.child; + if (child){ + for (var i=0,n=child.length;i < n;i++){ + var data=child[i]; + if ((data.props.name==="render" || data.props.renderType==="render")&& node["_$set_itemRender"]) + node.itemRender=data; + else { + if (data.type=="Graphic"){ + ClassUtils.addGraphicsToSprite(data,node); + }else if (ClassUtils.isDrawType(data.type)){ + ClassUtils.addGraphicToSprite(data,node,true); + }else { + var tChild=ClassUtils.createByJson(data,null,root,customHandler,instanceHandler) + if (data.type=="Script"){ + tChild["owner"]=node; + }else if (data.props.renderType=="mask"){ + node.mask=tChild; + }else { + node.addChild(tChild); + } + } + } + } + } + if (props){ + for (var prop in props){ + var value=props[prop]; + if (prop==="var" && root){ + root[value]=node; + }else if ((value instanceof Array)&& (typeof (node[prop])=='function')){ + node[prop].apply(node,value); + }else { + node[prop]=value; + } + } + } + if (customHandler && json.customProps){ + customHandler.runWith([node,json]); + } + if (node["created"]) + node.created(); + return node; + } + + ClassUtils.addGraphicsToSprite=function(graphicO,sprite){ + var graphics; + graphics=graphicO.child; + if (!graphics || graphics.length < 1) + return; + var g; + g=ClassUtils._getGraphicsFromSprite(graphicO,sprite); + var ox=0; + var oy=0; + if (graphicO.props){ + ox=ClassUtils._getObjVar(graphicO.props,"x",0); + oy=ClassUtils._getObjVar(graphicO.props,"y",0); + } + if (ox !=0 && oy !=0){ + g.translate(ox,oy); + }; + var i=0,len=0; + len=graphics.length; + for (i=0;i < len;i++){ + ClassUtils._addGraphicToGraphics(graphics[i],g); + } + if (ox !=0 && oy !=0){ + g.translate(-ox,-oy); + } + } + + ClassUtils.addGraphicToSprite=function(graphicO,sprite,isChild){ + (isChild===void 0)&& (isChild=false); + var g; + g=isChild ? ClassUtils._getGraphicsFromSprite(graphicO,sprite):sprite.graphics; + ClassUtils._addGraphicToGraphics(graphicO,g); + } + + ClassUtils._getGraphicsFromSprite=function(dataO,sprite){ + var g; + if (!dataO || !dataO.props) + return sprite.graphics; + var propsName; + propsName=dataO.props.renderType; + switch (propsName){ + case "hit": + case "unHit":; + var hitArea; + if (!sprite.hitArea){ + sprite.hitArea=new HitArea(); + } + hitArea=sprite.hitArea; + if (!hitArea[propsName]){ + hitArea[propsName]=new Graphics(); + } + g=hitArea[propsName]; + break ; + default : + } + if (!g) + g=sprite.graphics; + return g; + } + + ClassUtils._getTransformData=function(propsO){ + var m; + if (propsO.hasOwnProperty("pivotX")|| propsO.hasOwnProperty("pivotY")){ + m=m || new Matrix(); + m.translate(-ClassUtils._getObjVar(propsO,"pivotX",0),-ClassUtils._getObjVar(propsO,"pivotY",0)); + }; + var sx=ClassUtils._getObjVar(propsO,"scaleX",1),sy=ClassUtils._getObjVar(propsO,"scaleY",1); + var rotate=ClassUtils._getObjVar(propsO,"rotation",0); + var skewX=ClassUtils._getObjVar(propsO,"skewX",0); + var skewY=ClassUtils._getObjVar(propsO,"skewY",0); + if (sx !=1 || sy !=1 || rotate !=0){ + m=m || new Matrix(); + m.scale(sx,sy); + m.rotate(rotate *0.0174532922222222); + } + return m; + } + + ClassUtils._addGraphicToGraphics=function(graphicO,graphic){ + var propsO; + propsO=graphicO.props; + if (!propsO) + return; + var drawConfig; + drawConfig=ClassUtils.DrawTypeDic[graphicO.type]; + if (!drawConfig) + return; + var g; + g=graphic; + var m; + var params=ClassUtils._getParams(propsO,drawConfig[1],drawConfig[2],drawConfig[3]); + m=ClassUtils._tM; + if (m || ClassUtils._alpha !=1){ + g.save(); + if (m) + g.transform(m); + if (ClassUtils._alpha !=1) + g.alpha(ClassUtils._alpha); + } + g[drawConfig[0]].apply(g,params); + if (m || ClassUtils._alpha !=1){ + g.restore(); + } + } + + ClassUtils._adptLineData=function(params){ + params[2]=parseFloat(params[0])+parseFloat(params[2]); + params[3]=parseFloat(params[1])+parseFloat(params[3]); + return params; + } + + ClassUtils._adptTextureData=function(params){ + params[0]=Loader.getRes(params[0]); + return params; + } + + ClassUtils._adptLinesData=function(params){ + params[2]=ClassUtils._getPointListByStr(params[2]); + return params; + } + + ClassUtils.isDrawType=function(type){ + if (type=="Image") + return false; + return ClassUtils.DrawTypeDic.hasOwnProperty(type); + } + + ClassUtils._getParams=function(obj,params,xPos,adptFun){ + (xPos===void 0)&& (xPos=0); + var rst; + rst=ClassUtils._temParam; + rst.length=params.length; + var i=0,len=0; + len=params.length; + for (i=0;i < len;i++){ + rst[i]=ClassUtils._getObjVar(obj,params[i][0],params[i][1]); + } + ClassUtils._alpha=ClassUtils._getObjVar(obj,"alpha",1); + var m; + m=ClassUtils._getTransformData(obj); + if (m){ + if (!xPos)xPos=0; + m.translate(rst[xPos],rst[xPos+1]); + rst[xPos]=rst[xPos+1]=0; + ClassUtils._tM=m; + }else { + ClassUtils._tM=null; + } + if (adptFun && ClassUtils[adptFun]){ + rst=ClassUtils[adptFun](rst); + } + return rst; + } + + ClassUtils._getPointListByStr=function(str){ + var pointArr; + pointArr=str.split(","); + var i=0,len=0; + len=pointArr.length; + for (i=0;i < len;i++){ + pointArr[i]=parseFloat(pointArr[i]); + } + return pointArr; + } + + ClassUtils._getObjVar=function(obj,key,noValue){ + if (obj.hasOwnProperty(key)){ + return obj[key]; + } + return noValue; + } + + ClassUtils._temParam=[]; + ClassUtils._classMap={'Sprite':'laya.display.Sprite','Text':'laya.display.Text','Animation':'laya.display.Animation','Skeleton':'laya.ani.bone.Skeleton','Particle2D':'laya.particle.Particle2D','div':'laya.html.dom.HTMLDivElement','p':'laya.html.dom.HTMLElement','img':'laya.html.dom.HTMLImageElement','span':'laya.html.dom.HTMLElement','br':'laya.html.dom.HTMLBrElement','style':'laya.html.dom.HTMLStyleElement','font':'laya.html.dom.HTMLElement','a':'laya.html.dom.HTMLElement','#text':'laya.html.dom.HTMLElement'}; + ClassUtils.getClass=function(className){ + var classObject=ClassUtils._classMap[className] || className; + if ((typeof classObject=='string')) + return Laya["__classmap"][classObject]; + return classObject; + } + + ClassUtils._tM=null + ClassUtils._alpha=NaN + __static(ClassUtils, + ['DrawTypeDic',function(){return this.DrawTypeDic={"Rect":["drawRect",[["x",0],["y",0],["width",0],["height",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],"Circle":["drawCircle",[["x",0],["y",0],["radius",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],"Pie":["drawPie",[["x",0],["y",0],["radius",0],["startAngle",0],["endAngle",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],"Image":["drawTexture",[["x",0],["y",0],["width",0],["height",0]]],"Texture":["drawTexture",[["skin",null],["x",0],["y",0],["width",0],["height",0]],1,"_adptTextureData"],"FillTexture":["fillTexture",[["skin",null],["x",0],["y",0],["width",0],["height",0],["repeat",null]],1,"_adptTextureData"],"FillText":["fillText",[["text",""],["x",0],["y",0],["font",null],["color",null],["textAlign",null]],1],"Line":["drawLine",[["x",0],["y",0],["toX",0],["toY",0],["lineColor",null],["lineWidth",0]],0,"_adptLineData"],"Lines":["drawLines",[["x",0],["y",0],["points",""],["lineColor",null],["lineWidth",0]],0,"_adptLinesData"],"Curves":["drawCurves",[["x",0],["y",0],["points",""],["lineColor",null],["lineWidth",0]],0,"_adptLinesData"],"Poly":["drawPoly",[["x",0],["y",0],["points",""],["fillColor",null],["lineColor",null],["lineWidth",1]],0,"_adptLinesData"]};} + ]); + return ClassUtils; + })() + + + /** + *Color 是一个颜色值处理类。 + */ + //class laya.utils.Color + var Color=(function(){ + function Color(str){ + this._color=[]; + //this.strColor=null; + //this.numColor=0; + //this._drawStyle=null; + if ((typeof str=='string')){ + this.strColor=str; + if (str===null)str="#000000"; + str.charAt(0)=='#' && (str=str.substr(1)); + var color=this.numColor=parseInt(str,16); + var flag=(str.length==8); + if (flag){ + this._color=[parseInt(str.substr(0,2),16)/ 255,((0x00FF0000 & color)>> 16)/ 255,((0x0000FF00 & color)>> 8)/ 255,(0x000000FF & color)/ 255]; + return; + } + }else { + color=this.numColor=str; + this.strColor=Utils.toHexColor(color); + } + this._color=[((0xFF0000 & color)>> 16)/ 255,((0xFF00 & color)>> 8)/ 255,(0xFF & color)/ 255,1]; + (this._color).__id=++Color._COLODID; + } + + __class(Color,'laya.utils.Color'); + Color._initDefault=function(){ + Color._DEFAULT={}; + for (var i in Color._COLOR_MAP)Color._SAVE[i]=Color._DEFAULT[i]=new Color(Color._COLOR_MAP[i]); + return Color._DEFAULT; + } + + Color._initSaveMap=function(){ + Color._SAVE_SIZE=0; + Color._SAVE={}; + for (var i in Color._DEFAULT)Color._SAVE[i]=Color._DEFAULT[i]; + } + + Color.create=function(str){ + var color=Color._SAVE[str+""]; + if (color !=null)return color; + (Color._SAVE_SIZE < 1000)|| Color._initSaveMap(); + return Color._SAVE[str+""]=new Color(str); + } + + Color._SAVE={}; + Color._SAVE_SIZE=0; + Color._COLOR_MAP={"white":'#FFFFFF',"red":'#FF0000',"green":'#00FF00',"blue":'#0000FF',"black":'#000000',"yellow":'#FFFF00','gray':'#AAAAAA'}; + Color._DEFAULT=Color._initDefault(); + Color._COLODID=1; + return Color; + })() + + + /** + *Dictionary 是一个字典型的数据存取类。 + */ + //class laya.utils.Dictionary + var Dictionary=(function(){ + function Dictionary(){ + this._values=[]; + this._keys=[]; + } + + __class(Dictionary,'laya.utils.Dictionary'); + var __proto=Dictionary.prototype; + /** + *给指定的键名设置值。 + *@param key 键名。 + *@param value 值。 + */ + __proto.set=function(key,value){ + var index=this.indexOf(key); + if (index >=0){ + this._values[index]=value; + return; + } + this._keys.push(key); + this._values.push(value); + } + + /** + *获取指定对象的键名索引。 + *@param key 键名对象。 + *@return 键名索引。 + */ + __proto.indexOf=function(key){ + var index=this._keys.indexOf(key); + if (index >=0)return index; + key=((typeof key=='string'))? Number(key):(((typeof key=='number'))? key.toString():key); + return this._keys.indexOf(key); + } + + /** + *返回指定键名的值。 + *@param key 键名对象。 + *@return 指定键名的值。 + */ + __proto.get=function(key){ + var index=this.indexOf(key); + return index < 0 ? null :this._values[index]; + } + + /** + *移除指定键名的值。 + *@param key 键名对象。 + *@return 是否成功移除。 + */ + __proto.remove=function(key){ + var index=this.indexOf(key); + if (index >=0){ + this._keys.splice(index,1); + this._values.splice(index,1); + return true; + } + return false; + } + + /** + *清除此对象的键名列表和键值列表。 + */ + __proto.clear=function(){ + this._values.length=0; + this._keys.length=0; + } + + /** + *获取所有的子元素列表。 + */ + __getset(0,__proto,'values',function(){ + return this._values; + }); + + /** + *获取所有的子元素键名列表。 + */ + __getset(0,__proto,'keys',function(){ + return this._keys; + }); + + return Dictionary; + })() + + + /** + *Dragging 类是触摸滑动控件。 + */ + //class laya.utils.Dragging + var Dragging=(function(){ + function Dragging(){ + //this.target=null; + this.ratio=0.92; + this.maxOffset=60; + //this.area=null; + //this.hasInertia=false; + //this.elasticDistance=NaN; + //this.elasticBackTime=NaN; + //this.data=null; + this._dragging=false; + this._clickOnly=true; + //this._elasticRateX=NaN; + //this._elasticRateY=NaN; + //this._lastX=NaN; + //this._lastY=NaN; + //this._offsetX=NaN; + //this._offsetY=NaN; + //this._offsets=null; + //this._disableMouseEvent=false; + //this._tween=null; + //this._parent=null; + } + + __class(Dragging,'laya.utils.Dragging'); + var __proto=Dragging.prototype; + /** + *开始拖拽。 + *@param target 待拖拽的 Sprite 对象。 + *@param area 滑动范围。 + *@param hasInertia 拖动是否有惯性。 + *@param elasticDistance 橡皮筋最大值。 + *@param elasticBackTime 橡皮筋回弹时间,单位为毫秒。 + *@param data 事件携带数据。 + *@param disableMouseEvent 鼠标事件是否有效。 + *@param ratio 惯性阻尼系数 + */ + __proto.start=function(target,area,hasInertia,elasticDistance,elasticBackTime,data,disableMouseEvent,ratio){ + (ratio===void 0)&& (ratio=0.92); + this.clearTimer(); + this.target=target; + this.area=area; + this.hasInertia=hasInertia; + this.elasticDistance=area ? elasticDistance :0; + this.elasticBackTime=elasticBackTime; + this.data=data; + this._disableMouseEvent=disableMouseEvent; + this.ratio=ratio; + if (target.globalScaleX !=1 || target.globalScaleY !=1){ + this._parent=target.parent; + }else { + this._parent=Laya.stage; + } + this._clickOnly=true; + this._dragging=true; + this._elasticRateX=this._elasticRateY=1; + this._lastX=this._parent.mouseX; + this._lastY=this._parent.mouseY; + Laya.stage.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp); + Laya.stage.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp); + Laya.timer.frameLoop(1,this,this.loop); + } + + /** + *清除计时器。 + */ + __proto.clearTimer=function(){ + Laya.timer.clear(this,this.loop); + Laya.timer.clear(this,this.tweenMove); + if (this._tween){ + this._tween.recover(); + this._tween=null; + } + } + + /** + *停止拖拽。 + */ + __proto.stop=function(){ + if (this._dragging){ + MouseManager.instance.disableMouseEvent=false; + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp); + Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp); + this._dragging=false; + this.target && this.area && this.backToArea(); + this.clear(); + } + } + + /** + *拖拽的循环处理函数。 + */ + __proto.loop=function(){ + var point=this._parent.getMousePoint(); + var mouseX=point.x; + var mouseY=point.y; + var offsetX=mouseX-this._lastX; + var offsetY=mouseY-this._lastY; + if (this._clickOnly){ + if (Math.abs(offsetX *Laya.stage._canvasTransform.getScaleX())> 1 || Math.abs(offsetY *Laya.stage._canvasTransform.getScaleY())> 1){ + this._clickOnly=false; + this._offsets || (this._offsets=[]); + this._offsets.length=0; + this.target.event(/*laya.events.Event.DRAG_START*/"dragstart",this.data); + MouseManager.instance.disableMouseEvent=this._disableMouseEvent; + this.target._set$P("$_MOUSEDOWN",false); + }else return; + }else { + this._offsets.push(offsetX,offsetY); + } + if (offsetX===0 && offsetY===0)return; + this._lastX=mouseX; + this._lastY=mouseY; + this.target.x+=offsetX *this._elasticRateX; + this.target.y+=offsetY *this._elasticRateY; + this.area && this.checkArea(); + this.target.event(/*laya.events.Event.DRAG_MOVE*/"dragmove",this.data); + } + + /** + *拖拽区域检测。 + */ + __proto.checkArea=function(){ + if (this.elasticDistance <=0){ + this.backToArea(); + }else { + if (this.target.x < this.area.x){ + var offsetX=this.area.x-this.target.x; + }else if (this.target.x > this.area.x+this.area.width){ + offsetX=this.target.x-this.area.x-this.area.width; + }else { + offsetX=0; + } + this._elasticRateX=Math.max(0,1-(offsetX / this.elasticDistance)); + if (this.target.y < this.area.y){ + var offsetY=this.area.y-this.target.y; + }else if (this.target.y > this.area.y+this.area.height){ + offsetY=this.target.y-this.area.y-this.area.height; + }else { + offsetY=0; + } + this._elasticRateY=Math.max(0,1-(offsetY / this.elasticDistance)); + } + } + + /** + *移动至设定的拖拽区域。 + */ + __proto.backToArea=function(){ + this.target.x=Math.min(Math.max(this.target.x,this.area.x),this.area.x+this.area.width); + this.target.y=Math.min(Math.max(this.target.y,this.area.y),this.area.y+this.area.height); + } + + /** + *舞台的抬起事件侦听函数。 + *@param e Event 对象。 + */ + __proto.onStageMouseUp=function(e){ + MouseManager.instance.disableMouseEvent=false; + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp); + Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp); + Laya.timer.clear(this,this.loop); + if (this._clickOnly || !this.target)return; + if (this.hasInertia){ + if (this._offsets.length < 1){ + this._offsets.push(this._parent.mouseX-this._lastX,this._parent.mouseY-this._lastY); + } + this._offsetX=this._offsetY=0; + var len=this._offsets.length; + var n=Math.min(len,6); + var m=this._offsets.length-n; + for (var i=len-1;i > m;i--){ + this._offsetY+=this._offsets[i--]; + this._offsetX+=this._offsets[i]; + } + this._offsetX=this._offsetX / n *2; + this._offsetY=this._offsetY / n *2; + if (Math.abs(this._offsetX)> this.maxOffset)this._offsetX=this._offsetX > 0 ? this.maxOffset :-this.maxOffset; + if (Math.abs(this._offsetY)> this.maxOffset)this._offsetY=this._offsetY > 0 ? this.maxOffset :-this.maxOffset; + Laya.timer.frameLoop(1,this,this.tweenMove); + }else if (this.elasticDistance > 0){ + this.checkElastic(); + }else { + this.clear(); + } + } + + /** + *橡皮筋效果检测。 + */ + __proto.checkElastic=function(){ + var tx=NaN; + var ty=NaN; + if (this.target.x < this.area.x)tx=this.area.x; + else if (this.target.x > this.area.x+this.area.width)tx=this.area.x+this.area.width; + if (this.target.y < this.area.y)ty=this.area.y; + else if (this.target.y > this.area.y+this.area.height)ty=this.area.y+this.area.height; + if (!isNaN(tx)|| !isNaN(ty)){ + var obj={}; + if (!isNaN(tx))obj.x=tx; + if (!isNaN(ty))obj.y=ty; + this._tween=Tween.to(this.target,obj,this.elasticBackTime,Ease.sineOut,Handler.create(this,this.clear),0,false,false); + }else { + this.clear(); + } + } + + /** + *移动。 + */ + __proto.tweenMove=function(){ + this._offsetX *=this.ratio *this._elasticRateX; + this._offsetY *=this.ratio *this._elasticRateY; + this.target.x+=this._offsetX; + this.target.y+=this._offsetY; + this.area && this.checkArea(); + this.target.event(/*laya.events.Event.DRAG_MOVE*/"dragmove",this.data); + if ((Math.abs(this._offsetX)< 1 && Math.abs(this._offsetY)< 1)|| this._elasticRateX < 0.5 || this._elasticRateY < 0.5){ + Laya.timer.clear(this,this.tweenMove); + if (this.elasticDistance > 0)this.checkElastic(); + else this.clear(); + } + } + + /** + *结束拖拽。 + */ + __proto.clear=function(){ + if (this.target){ + this.clearTimer(); + var sp=this.target; + this.target=null; + this._parent=null; + sp.event(/*laya.events.Event.DRAG_END*/"dragend",this.data); + } + } + + return Dragging; + })() + + + /** + *Ease 类定义了缓动函数,以便实现 Tween 动画的缓动效果。 + */ + //class laya.utils.Ease + var Ease=(function(){ + function Ease(){}; + __class(Ease,'laya.utils.Ease'); + Ease.linearNone=function(t,b,c,d){ + return c *t / d+b; + } + + Ease.linearIn=function(t,b,c,d){ + return c *t / d+b; + } + + Ease.linearInOut=function(t,b,c,d){ + return c *t / d+b; + } + + Ease.linearOut=function(t,b,c,d){ + return c *t / d+b; + } + + Ease.bounceIn=function(t,b,c,d){ + return c-Ease.bounceOut(d-t,0,c,d)+b; + } + + Ease.bounceInOut=function(t,b,c,d){ + if (t < d *0.5)return Ease.bounceIn(t *2,0,c,d)*.5+b; + else return Ease.bounceOut(t *2-d,0,c,d)*.5+c *.5+b; + } + + Ease.bounceOut=function(t,b,c,d){ + if ((t /=d)< (1 / 2.75))return c *(7.5625 *t *t)+b; + else if (t < (2 / 2.75))return c *(7.5625 *(t-=(1.5 / 2.75))*t+.75)+b; + else if (t < (2.5 / 2.75))return c *(7.5625 *(t-=(2.25 / 2.75))*t+.9375)+b; + else return c *(7.5625 *(t-=(2.625 / 2.75))*t+.984375)+b; + } + + Ease.backIn=function(t,b,c,d,s){ + (s===void 0)&& (s=1.70158); + return c *(t /=d)*t *((s+1)*t-s)+b; + } + + Ease.backInOut=function(t,b,c,d,s){ + (s===void 0)&& (s=1.70158); + if ((t /=d *0.5)< 1)return c *0.5 *(t *t *(((s *=(1.525))+1)*t-s))+b; + return c / 2 *((t-=2)*t *(((s *=(1.525))+1)*t+s)+2)+b; + } + + Ease.backOut=function(t,b,c,d,s){ + (s===void 0)&& (s=1.70158); + return c *((t=t / d-1)*t *((s+1)*t+s)+1)+b; + } + + Ease.elasticIn=function(t,b,c,d,a,p){ + (a===void 0)&& (a=0); + (p===void 0)&& (p=0); + var s; + if (t==0)return b; + if ((t /=d)==1)return b+c; + if (!p)p=d *.3; + if (!a || (c > 0 && a < c)|| (c < 0 && a <-c)){ + a=c; + s=p / 4; + }else s=p / Ease.PI2 *Math.asin(c / a); + return-(a *Math.pow(2,10 *(t-=1))*Math.sin((t *d-s)*Ease.PI2 / p))+b; + } + + Ease.elasticInOut=function(t,b,c,d,a,p){ + (a===void 0)&& (a=0); + (p===void 0)&& (p=0); + var s; + if (t==0)return b; + if ((t /=d *0.5)==2)return b+c; + if (!p)p=d *(.3 *1.5); + if (!a || (c > 0 && a < c)|| (c < 0 && a <-c)){ + a=c; + s=p / 4; + }else s=p / Ease.PI2 *Math.asin(c / a); + if (t < 1)return-.5 *(a *Math.pow(2,10 *(t-=1))*Math.sin((t *d-s)*Ease.PI2 / p))+b; + return a *Math.pow(2,-10 *(t-=1))*Math.sin((t *d-s)*Ease.PI2 / p)*.5+c+b; + } + + Ease.elasticOut=function(t,b,c,d,a,p){ + (a===void 0)&& (a=0); + (p===void 0)&& (p=0); + var s; + if (t==0)return b; + if ((t /=d)==1)return b+c; + if (!p)p=d *.3; + if (!a || (c > 0 && a < c)|| (c < 0 && a <-c)){ + a=c; + s=p / 4; + }else s=p / Ease.PI2 *Math.asin(c / a); + return (a *Math.pow(2,-10 *t)*Math.sin((t *d-s)*Ease.PI2 / p)+c+b); + } + + Ease.strongIn=function(t,b,c,d){ + return c *(t /=d)*t *t *t *t+b; + } + + Ease.strongInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return c *0.5 *t *t *t *t *t+b; + return c *0.5 *((t-=2)*t *t *t *t+2)+b; + } + + Ease.strongOut=function(t,b,c,d){ + return c *((t=t / d-1)*t *t *t *t+1)+b; + } + + Ease.sineInOut=function(t,b,c,d){ + return-c *0.5 *(Math.cos(Math.PI *t / d)-1)+b; + } + + Ease.sineIn=function(t,b,c,d){ + return-c *Math.cos(t / d *Ease.HALF_PI)+c+b; + } + + Ease.sineOut=function(t,b,c,d){ + return c *Math.sin(t / d *Ease.HALF_PI)+b; + } + + Ease.quintIn=function(t,b,c,d){ + return c *(t /=d)*t *t *t *t+b; + } + + Ease.quintInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return c *0.5 *t *t *t *t *t+b; + return c *0.5 *((t-=2)*t *t *t *t+2)+b; + } + + Ease.quintOut=function(t,b,c,d){ + return c *((t=t / d-1)*t *t *t *t+1)+b; + } + + Ease.quartIn=function(t,b,c,d){ + return c *(t /=d)*t *t *t+b; + } + + Ease.quartInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return c *0.5 *t *t *t *t+b; + return-c *0.5 *((t-=2)*t *t *t-2)+b; + } + + Ease.quartOut=function(t,b,c,d){ + return-c *((t=t / d-1)*t *t *t-1)+b; + } + + Ease.cubicIn=function(t,b,c,d){ + return c *(t /=d)*t *t+b; + } + + Ease.cubicInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return c *0.5 *t *t *t+b; + return c *0.5 *((t-=2)*t *t+2)+b; + } + + Ease.cubicOut=function(t,b,c,d){ + return c *((t=t / d-1)*t *t+1)+b; + } + + Ease.quadIn=function(t,b,c,d){ + return c *(t /=d)*t+b; + } + + Ease.quadInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return c *0.5 *t *t+b; + return-c *0.5 *((--t)*(t-2)-1)+b; + } + + Ease.quadOut=function(t,b,c,d){ + return-c *(t /=d)*(t-2)+b; + } + + Ease.expoIn=function(t,b,c,d){ + return (t==0)? b :c *Math.pow(2,10 *(t / d-1))+b-c *0.001; + } + + Ease.expoInOut=function(t,b,c,d){ + if (t==0)return b; + if (t==d)return b+c; + if ((t /=d *0.5)< 1)return c *0.5 *Math.pow(2,10 *(t-1))+b; + return c *0.5 *(-Math.pow(2,-10 *--t)+2)+b; + } + + Ease.expoOut=function(t,b,c,d){ + return (t==d)? b+c :c *(-Math.pow(2,-10 *t / d)+1)+b; + } + + Ease.circIn=function(t,b,c,d){ + return-c *(Math.sqrt(1-(t /=d)*t)-1)+b; + } + + Ease.circInOut=function(t,b,c,d){ + if ((t /=d *0.5)< 1)return-c *0.5 *(Math.sqrt(1-t *t)-1)+b; + return c *0.5 *(Math.sqrt(1-(t-=2)*t)+1)+b; + } + + Ease.circOut=function(t,b,c,d){ + return c *Math.sqrt(1-(t=t / d-1)*t)+b; + } + + Ease.HALF_PI=Math.PI *0.5; + Ease.PI2=Math.PI *2; + return Ease; + })() + + + /** + *鼠标点击区域,可以设置绘制一系列矢量图作为点击区域和非点击区域(目前只支持圆形,矩形,多边形) + */ + //class laya.utils.HitArea + var HitArea=(function(){ + function HitArea(){ + this._hit=null; + this._unHit=null; + } + + __class(HitArea,'laya.utils.HitArea'); + var __proto=HitArea.prototype; + /** + *是否包含某个点 + *@param x x坐标 + *@param y y坐标 + *@return 是否点击到 + */ + __proto.isHit=function(x,y){ + if (!HitArea.isHitGraphic(x,y,this.hit))return false; + return !HitArea.isHitGraphic(x,y,this.unHit); + } + + /** + *可点击区域,可以设置绘制一系列矢量图作为点击区域(目前只支持圆形,矩形,多边形) + */ + __getset(0,__proto,'hit',function(){ + if (!this._hit)this._hit=new Graphics(); + return this._hit; + },function(value){ + this._hit=value; + }); + + /** + *不可点击区域,可以设置绘制一系列矢量图作为非点击区域(目前只支持圆形,矩形,多边形) + */ + __getset(0,__proto,'unHit',function(){ + if (!this._unHit)this._unHit=new Graphics(); + return this._unHit; + },function(value){ + this._unHit=value; + }); + + HitArea.isHitGraphic=function(x,y,graphic){ + if (!graphic)return false; + var cmds; + cmds=graphic.cmds; + if (!cmds && graphic._one){ + cmds=HitArea._cmds; + cmds.length=1; + cmds[0]=graphic._one; + } + if (!cmds)return false; + var i=0,len=0; + len=cmds.length; + var cmd; + for (i=0;i < len;i++){ + cmd=cmds[i]; + if (!cmd)continue ; + var context=Render._context; + switch (cmd.callee){ + case context._translate: + case 6: + x-=cmd[0]; + y-=cmd[1]; + default : + } + if (HitArea.isHitCmd(x,y,cmd))return true; + } + return false; + } + + HitArea.isHitCmd=function(x,y,cmd){ + if (!cmd)return false; + var context=Render._context; + var rst=false; + switch (cmd["callee"]){ + case context._drawRect: + case 13: + HitArea._rec.setTo(cmd[0],cmd[1],cmd[2],cmd[3]); + rst=HitArea._rec.contains(x,y); + break ; + case context._drawCircle: + case context._fillCircle: + case 14:; + var d=NaN; + x-=cmd[0]; + y-=cmd[1]; + d=x *x+y *y; + rst=d < cmd[2] *cmd[2]; + break ; + case context._drawPoly: + case 18: + x-=cmd[0]; + y-=cmd[1]; + rst=HitArea.ptInPolygon(x,y,cmd[2]); + break ; + default : + break ; + } + return rst; + } + + HitArea.ptInPolygon=function(x,y,areaPoints){ + var p; + p=HitArea._ptPoint; + p.setTo(x,y); + var nCross=0; + var p1x=NaN,p1y=NaN,p2x=NaN,p2y=NaN; + var len=0; + len=areaPoints.length; + for (var i=0;i < len;i+=2){ + p1x=areaPoints[i]; + p1y=areaPoints[i+1]; + p2x=areaPoints[(i+2)% len]; + p2y=areaPoints[(i+3)% len]; + if (p1y==p2y) + continue ; + if (p.y < Math.min(p1y,p2y)) + continue ; + if (p.y >=Math.max(p1y,p2y)) + continue ; + var tx=(p.y-p1y)*(p2x-p1x)/ (p2y-p1y)+p1x; + if (tx > p.x){ + nCross++; + } + } + return (nCross % 2==1); + } + + HitArea._cmds=[]; + __static(HitArea, + ['_rec',function(){return this._rec=new Rectangle();},'_ptPoint',function(){return this._ptPoint=new Point();} + ]); + return HitArea; + })() + + + /** + *HTMLChar 是一个 HTML 字符类。 + */ + //class laya.utils.HTMLChar + var HTMLChar=(function(){ + function HTMLChar(char,w,h,style){ + //this._sprite=null; + //this._x=NaN; + //this._y=NaN; + //this._w=NaN; + //this._h=NaN; + //this.isWord=false; + //this.char=null; + //this.charNum=NaN; + //this.style=null; + this.char=char; + this.charNum=char.charCodeAt(0); + this._x=this._y=0; + this.width=w; + this.height=h; + this.style=style; + this.isWord=!HTMLChar._isWordRegExp.test(char); + } + + __class(HTMLChar,'laya.utils.HTMLChar'); + var __proto=HTMLChar.prototype; + Laya.imps(__proto,{"laya.display.ILayout":true}) + /** + *设置与此对象绑定的显示对象 Sprite 。 + *@param sprite 显示对象 Sprite 。 + */ + __proto.setSprite=function(sprite){ + this._sprite=sprite; + } + + /** + *获取与此对象绑定的显示对象 Sprite。 + *@return + */ + __proto.getSprite=function(){ + return this._sprite; + } + + /**@private */ + __proto._isChar=function(){ + return true; + } + + /**@private */ + __proto._getCSSStyle=function(){ + return this.style; + } + + /** + *宽度。 + */ + __getset(0,__proto,'width',function(){ + return this._w; + },function(value){ + this._w=value; + }); + + /** + *此对象存储的 X 轴坐标值。 + *当设置此值时,如果此对象有绑定的 Sprite 对象,则改变 Sprite 对象的属性 x 的值。 + */ + __getset(0,__proto,'x',function(){ + return this._x; + },function(value){ + if (this._sprite){ + this._sprite.x=value; + } + this._x=value; + }); + + /** + *此对象存储的 Y 轴坐标值。 + *当设置此值时,如果此对象有绑定的 Sprite 对象,则改变 Sprite 对象的属性 y 的值。 + */ + __getset(0,__proto,'y',function(){ + return this._y; + },function(value){ + if (this._sprite){ + this._sprite.y=value; + } + this._y=value; + }); + + /** + *高度。 + */ + __getset(0,__proto,'height',function(){ + return this._h; + },function(value){ + this._h=value; + }); + + HTMLChar._isWordRegExp=new RegExp("[\\w\.]",""); + return HTMLChar; + })() + + + /** + *Log 类用于在界面内显示日志记录信息。 + */ + //class laya.utils.Log + var Log=(function(){ + function Log(){}; + __class(Log,'laya.utils.Log'); + Log.enable=function(){ + if (!Log._logdiv){ + Log._logdiv=Browser.window.document.createElement('div'); + Browser.window.document.body.appendChild(Log._logdiv); + Log._logdiv.style.cssText="pointer-events:none;border:white;overflow:hidden;z-index:1000000;background:rgba(100,100,100,0.6);color:white;position: absolute;left:0px;top:0px;width:50%;height:50%;"; + } + } + + Log.toggle=function(){ + var style=Log._logdiv.style; + if (style.width=="1px"){ + style.width=style.height="50%"; + }else { + style.width=style.height="1px"; + } + } + + Log.print=function(value){ + if (Log._logdiv){ + if (Log._count >=Log.maxCount)Log.clear(); + Log._count++; + Log._logdiv.innerText+=value+"\n"; + Log._logdiv.scrollTop=Log._logdiv.scrollHeight; + } + } + + Log.clear=function(){ + Log._logdiv.innerText=""; + Log._count=0; + } + + Log._logdiv=null + Log._count=0; + Log.maxCount=20; + return Log; + })() + + + /** + *Mouse 类用于控制鼠标光标。 + */ + //class laya.utils.Mouse + var Mouse=(function(){ + function Mouse(){} + __class(Mouse,'laya.utils.Mouse'); + /** + *设置鼠标样式 + *@param cursorStr + *例如auto move no-drop col-resize + *all-scroll pointer not-allowed row-resize + *crosshair progress e-resize ne-resize + *default text n-resize nw-resize + *help vertical-text s-resize se-resize + *inherit wait w-resize sw-resize + * + */ + __getset(1,Mouse,'cursor',function(){ + return Mouse._style.cursor; + },function(cursorStr){ + Mouse._style.cursor=cursorStr; + }); + + Mouse.hide=function(){ + if (Mouse.cursor !="none"){ + Mouse._preCursor=Mouse.cursor; + Mouse.cursor="none"; + } + } + + Mouse.show=function(){ + if (Mouse.cursor=="none"){ + if (Mouse._preCursor){ + Mouse.cursor=Mouse._preCursor; + }else{ + Mouse.cursor="auto"; + } + } + } + + Mouse._preCursor=null + __static(Mouse, + ['_style',function(){return this._style=Browser.document.body.style;} + ]); + return Mouse; + })() + + + /** + *Pool 是对象池类,用于对象的存贮、重复使用。 + */ + //class laya.utils.Pool + var Pool=(function(){ + function Pool(){}; + __class(Pool,'laya.utils.Pool'); + Pool.getPoolBySign=function(sign){ + return Pool._poolDic[sign] || (Pool._poolDic[sign]=[]); + } + + Pool.clearBySign=function(sign){ + if (Pool._poolDic[sign])Pool._poolDic[sign].length=0; + } + + Pool.recover=function(sign,item){ + if (item["__InPool"])return; + item["__InPool"]=true; + Pool.getPoolBySign(sign).push(item); + } + + Pool.getItemByClass=function(sign,cls){ + var pool=Pool.getPoolBySign(sign); + var rst=pool.length ? pool.pop():new cls(); + rst["__InPool"]=false; + return rst; + } + + Pool.getItemByCreateFun=function(sign,createFun){ + var pool=Pool.getPoolBySign(sign); + var rst=pool.length ? pool.pop():createFun(); + rst["__InPool"]=false; + return rst; + } + + Pool.getItem=function(sign){ + var pool=Pool.getPoolBySign(sign); + var rst=pool.length ? pool.pop():null; + if (rst){ + rst["__InPool"]=false; + } + return rst; + } + + Pool._poolDic={}; + Pool.InPoolSign="__InPool"; + return Pool; + })() + + + /** + *基于个数的对象缓存管理器 + */ + //class laya.utils.PoolCache + var PoolCache=(function(){ + function PoolCache(){ + this.sign=null; + this.maxCount=1000; + } + + __class(PoolCache,'laya.utils.PoolCache'); + var __proto=PoolCache.prototype; + /** + *获取缓存的对象列表 + *@return + * + */ + __proto.getCacheList=function(){ + return Pool.getPoolBySign(this.sign); + } + + /** + *尝试清理缓存 + *@param force 是否强制清理 + * + */ + __proto.tryDispose=function(force){ + var list; + list=Pool.getPoolBySign(this.sign); + if (list.length > this.maxCount){ + list.splice(this.maxCount,list.length-this.maxCount); + } + } + + PoolCache.addPoolCacheManager=function(sign,maxCount){ + (maxCount===void 0)&& (maxCount=100); + var cache; + cache=new PoolCache(); + cache.sign=sign; + cache.maxCount=maxCount; + CacheManger.regCacheByFunction(Utils.bind(cache.tryDispose,cache),Utils.bind(cache.getCacheList,cache)); + } + + return PoolCache; + })() + + + /** + *Stat 用于显示帧率统计信息。 + */ + //class laya.utils.Stat + var Stat=(function(){ + function Stat(){}; + __class(Stat,'laya.utils.Stat'); + /** + *点击帧频显示区域的处理函数。 + */ + __getset(1,Stat,'onclick',null,function(fn){ + Stat._canvas.source.onclick=fn; + Stat._canvas.source.style.pointerEvents=''; + }); + + Stat.show=function(x,y){ + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + if (Render.isConchApp){ + /*__JS__ */conch.showFPS&&conch.showFPS(x,y); + return; + }; + var pixel=Browser.pixelRatio; + Stat._width=pixel *120; + Stat._vx=pixel *70; + Stat._view[0]={title:"FPS(Canvas)",value:"_fpsStr",color:"yellow",units:"int"}; + Stat._view[1]={title:"Sprite",value:"spriteCount",color:"white",units:"int"}; + Stat._view[2]={title:"DrawCall",value:"drawCall",color:"white",units:"int"}; + Stat._view[3]={title:"CurMem",value:"currentMemorySize",color:"yellow",units:"M"}; + if (Render.isWebGL){ + Stat._view[4]={title:"Shader",value:"shaderCall",color:"white",units:"int"}; + if (!Render.is3DMode){ + Stat._view[0].title="FPS(WebGL)"; + Stat._view[5]={title:"Canvas",value:"_canvasStr",color:"white",units:"int"}; + }else { + Stat._view[0].title="FPS(3D)"; + Stat._view[5]={title:"TriFaces",value:"trianglesFaces",color:"white",units:"int"}; + } + }else { + Stat._view[4]={title:"Canvas",value:"_canvasStr",color:"white",units:"int"}; + } + Stat._fontSize=12 *pixel; + for (var i=0;i < Stat._view.length;i++){ + Stat._view[i].x=4; + Stat._view[i].y=i *Stat._fontSize+2 *pixel; + } + Stat._height=pixel *(Stat._view.length *12+3 *pixel); + if (!Stat._canvas){ + Stat._canvas=new HTMLCanvas('2D'); + Stat._canvas.size(Stat._width,Stat._height); + Stat._ctx=Stat._canvas.getContext('2d'); + Stat._ctx.textBaseline="top"; + Stat._ctx.font=Stat._fontSize+"px Sans-serif"; + Stat._canvas.source.style.cssText="pointer-events:none;background:rgba(150,150,150,0.8);z-index:100000;position: absolute;left:"+x+"px;top:"+y+"px;width:"+(Stat._width / pixel)+"px;height:"+(Stat._height / pixel)+"px;"; + } + Stat._first=true; + Stat.loop(); + Stat._first=false; + Browser.container.appendChild(Stat._canvas.source); + Stat.enable(); + } + + Stat.enable=function(){ + Laya.timer.frameLoop(1,Stat,Stat.loop); + } + + Stat.hide=function(){ + Browser.removeElement(Stat._canvas.source); + Laya.timer.clear(Stat,Stat.loop); + } + + Stat.clear=function(){ + Stat.trianglesFaces=Stat.drawCall=Stat.shaderCall=Stat.spriteCount=Stat.canvasNormal=Stat.canvasBitmap=Stat.canvasReCache=0; + } + + Stat.loop=function(){ + Stat._count++; + var timer=Browser.now(); + if (timer-Stat._timer < 1000)return; + var count=Stat._count; + Stat.FPS=Math.round((count *1000)/ (timer-Stat._timer)); + if (Stat._canvas){ + Stat.trianglesFaces=Math.round(Stat.trianglesFaces / count); + Stat.drawCall=Math.round(Stat.drawCall / count)-2; + Stat.shaderCall=Math.round(Stat.shaderCall / count); + Stat.spriteCount=Math.round(Stat.spriteCount / count)-1; + Stat.canvasNormal=Math.round(Stat.canvasNormal / count); + Stat.canvasBitmap=Math.round(Stat.canvasBitmap / count); + Stat.canvasReCache=Math.ceil(Stat.canvasReCache / count); + Stat._fpsStr=Stat.FPS+(Stat.renderSlow ? " slow" :""); + Stat._canvasStr=Stat.canvasReCache+"/"+Stat.canvasNormal+"/"+Stat.canvasBitmap; + Stat.currentMemorySize=ResourceManager.systemResourceManager.memorySize; + var ctx=Stat._ctx; + ctx.clearRect(Stat._first ? 0 :Stat._vx,0,Stat._width,Stat._height); + for (var i=0;i < Stat._view.length;i++){ + var one=Stat._view[i]; + if (Stat._first){ + ctx.fillStyle="white"; + ctx.fillText(one.title,one.x,one.y,null,null,null); + } + ctx.fillStyle=one.color; + var value=Stat[one.value]; + (one.units=="M")&& (value=Math.floor(value / (1024 *1024)*100)/ 100+" M"); + ctx.fillText(value+"",one.x+Stat._vx,one.y,null,null,null); + } + Stat.clear(); + } + Stat._count=0; + Stat._timer=timer; + } + + Stat.loopCount=0; + Stat.shaderCall=0; + Stat.drawCall=0; + Stat.trianglesFaces=0; + Stat.spriteCount=0; + Stat.FPS=0; + Stat.canvasNormal=0; + Stat.canvasBitmap=0; + Stat.canvasReCache=0; + Stat.renderSlow=false; + Stat.currentMemorySize=0; + Stat._fpsStr=null + Stat._canvasStr=null + Stat._canvas=null + Stat._ctx=null + Stat._timer=0; + Stat._count=0; + Stat._width=120; + Stat._height=100; + Stat._view=[]; + Stat._fontSize=12; + Stat._first=false; + Stat._vx=NaN + return Stat; + })() + + + /** + *StringKey 类用于存取字符串对应的数字。 + */ + //class laya.utils.StringKey + var StringKey=(function(){ + function StringKey(){ + this._strs={}; + this._length=0; + } + + __class(StringKey,'laya.utils.StringKey'); + var __proto=StringKey.prototype; + /** + *添加一个字符。 + *@param str 字符,将作为key 存储相应生成的数字。 + *@return 此字符对应的数字。 + */ + __proto.add=function(str){ + var index=this._strs[str]; + if (index !=null)return index; + return this._strs[str]=this._length++; + } + + /** + *获取指定字符对应的数字。 + *@param str key 字符。 + *@return 此字符对应的数字。 + */ + __proto.get=function(str){ + var index=this._strs[str]; + return index==null ?-1 :index; + } + + return StringKey; + })() + + + /** + *Timer 是时钟管理类。它是一个单例,可以通过 Laya.timer 访问。 + */ + //class laya.utils.Timer + var Timer=(function(){ + var TimerHandler; + function Timer(){ + this._delta=0; + this.scale=1; + this.currFrame=0; + this._mid=1; + this._map=[]; + this._laters=[]; + this._handlers=[]; + this._temp=[]; + this._count=0; + this.currTimer=Browser.now(); + this._lastTimer=Browser.now(); + Laya.timer && Laya.timer.frameLoop(1,this,this._update); + } + + __class(Timer,'laya.utils.Timer'); + var __proto=Timer.prototype; + /** + *@private + *帧循环处理函数。 + */ + __proto._update=function(){ + if (this.scale <=0){ + this._lastTimer=Browser.now(); + return; + }; + var frame=this.currFrame=this.currFrame+this.scale; + var now=Browser.now(); + this._delta=(now-this._lastTimer)*this.scale; + var timer=this.currTimer=this.currTimer+this._delta; + this._lastTimer=now; + var handlers=this._handlers; + this._count=0; + for (i=0,n=handlers.length;i < n;i++){ + handler=handlers[i]; + if (handler.method!==null){ + var t=handler.userFrame ? frame :timer; + if (t >=handler.exeTime){ + if (handler.repeat){ + if (t > handler.exeTime){ + handler.exeTime+=handler.delay; + handler.run(false); + if (t > handler.exeTime){ + handler.exeTime+=Math.ceil((t-handler.exeTime)/ handler.delay)*handler.delay; + } + } + }else { + handler.run(true); + } + } + }else { + this._count++; + } + } + if (this._count > 30 || frame % 200===0)this._clearHandlers(); + var laters=this._laters; + for (var i=0,n=laters.length-1;i <=n;i++){ + var handler=laters[i]; + handler.method!==null && handler.run(false); + this._recoverHandler(handler); + i===n && (n=laters.length-1); + } + laters.length=0; + } + + /**@private */ + __proto._clearHandlers=function(){ + var handlers=this._handlers; + for (var i=0,n=handlers.length;i < n;i++){ + var handler=handlers[i]; + if (handler.method!==null)this._temp.push(handler); + else this._recoverHandler(handler); + } + this._handlers=this._temp; + this._temp=handlers; + this._temp.length=0; + } + + /**@private */ + __proto._recoverHandler=function(handler){ + this._map[handler.key]=null; + handler.clear(); + Timer._pool.push(handler); + } + + /**@private */ + __proto._create=function(useFrame,repeat,delay,caller,method,args,coverBefore){ + if (!delay){ + method.apply(caller,args); + return; + } + if (coverBefore){ + var handler=this._getHandler(caller,method); + if (handler){ + handler.repeat=repeat; + handler.userFrame=useFrame; + handler.delay=delay; + handler.caller=caller; + handler.method=method; + handler.args=args; + handler.exeTime=delay+(useFrame ? this.currFrame :this.currTimer); + return; + } + } + handler=Timer._pool.length > 0 ? Timer._pool.pop():new TimerHandler(); + handler.repeat=repeat; + handler.userFrame=useFrame; + handler.delay=delay; + handler.caller=caller; + handler.method=method; + handler.args=args; + handler.exeTime=delay+(useFrame ? this.currFrame :this.currTimer); + this._indexHandler(handler); + this._handlers.push(handler); + } + + /**@private */ + __proto._indexHandler=function(handler){ + var caller=handler.caller; + var method=handler.method; + var cid=caller ? caller.$_GID || (caller.$_GID=Utils.getGID()):0; + var mid=method.$_TID || (method.$_TID=(this._mid++)*100000); + handler.key=cid+mid; + this._map[handler.key]=handler; + } + + /** + *定时执行一次。 + *@param delay 延迟时间(单位为毫秒)。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为 true 。 + */ + __proto.once=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this._create(false,false,delay,caller,method,args,coverBefore); + } + + /** + *定时重复执行。 + *@param delay 间隔时间(单位毫秒)。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为 true 。 + */ + __proto.loop=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this._create(false,true,delay,caller,method,args,coverBefore); + } + + /** + *定时执行一次(基于帧率)。 + *@param delay 延迟几帧(单位为帧)。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为 true 。 + */ + __proto.frameOnce=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this._create(true,false,delay,caller,method,args,coverBefore); + } + + /** + *定时重复执行(基于帧率)。 + *@param delay 间隔几帧(单位为帧)。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为 true 。 + */ + __proto.frameLoop=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this._create(true,true,delay,caller,method,args,coverBefore); + } + + /**返回统计信息。*/ + __proto.toString=function(){ + return "callLater:"+this._laters.length+" handlers:"+this._handlers.length+" pool:"+Timer._pool.length; + } + + /** + *清理定时器。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + */ + __proto.clear=function(caller,method){ + var handler=this._getHandler(caller,method); + if (handler){ + this._map[handler.key]=null;handler.key=0; + handler.clear(); + } + } + + /** + *清理对象身上的所有定时器。 + *@param caller 执行域(this)。 + */ + __proto.clearAll=function(caller){ + for (var i=0,n=this._handlers.length;i < n;i++){ + var handler=this._handlers[i]; + if (handler.caller===caller){ + this._map[handler.key]=null;handler.key=0; + handler.clear(); + } + } + } + + /**@private */ + __proto._getHandler=function(caller,method){ + var cid=caller ? caller.$_GID || (caller.$_GID=Utils.getGID()):0; + var mid=method.$_TID || (method.$_TID=(this._mid++)*100000); + return this._map[cid+mid]; + } + + /** + *延迟执行。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + *@param args 回调参数。 + */ + __proto.callLater=function(caller,method,args){ + if (this._getHandler(caller,method)==null){ + if (Timer._pool.length) + var handler=Timer._pool.pop(); + else handler=new TimerHandler(); + handler.caller=caller; + handler.method=method; + handler.args=args; + this._indexHandler(handler); + this._laters.push(handler); + } + } + + /** + *立即执行 callLater 。 + *@param caller 执行域(this)。 + *@param method 定时器回调函数。 + */ + __proto.runCallLater=function(caller,method){ + var handler=this._getHandler(caller,method); + if (handler && handler.method !=null){ + this._map[handler.key]=null; + handler.run(true); + } + } + + /** + *两帧之间的时间间隔,单位毫秒。 + */ + __getset(0,__proto,'delta',function(){ + return this._delta; + }); + + Timer._pool=[]; + Timer.__init$=function(){ + /**@private */ + //class TimerHandler + TimerHandler=(function(){ + function TimerHandler(){ + this.key=0; + this.repeat=false; + this.delay=0; + this.userFrame=false; + this.exeTime=0; + this.caller=null; + this.method=null; + this.args=null; + } + __class(TimerHandler,''); + var __proto=TimerHandler.prototype; + __proto.clear=function(){ + this.caller=null; + this.method=null; + this.args=null; + } + __proto.run=function(widthClear){ + var caller=this.caller; + if (caller && caller.destroyed)return this.clear(); + var method=this.method; + var args=this.args; + widthClear && this.clear(); + if (method==null)return; + args ? method.apply(caller,args):method.call(caller); + } + return TimerHandler; + })() + } + + return Timer; + })() + + + /** + *Tween 是一个缓动类。使用实现目标对象属性的渐变。 + */ + //class laya.utils.Tween + var Tween=(function(){ + function Tween(){ + //this._complete=null; + //this._target=null; + //this._ease=null; + //this._props=null; + //this._duration=0; + //this._delay=0; + //this._startTimer=0; + //this._usedTimer=0; + //this._usedPool=false; + this.gid=0; + //this.update=null; + } + + __class(Tween,'laya.utils.Tween'); + var __proto=Tween.prototype; + /** + *缓动对象的props属性到目标值。 + *@param target 目标对象(即将更改属性值的对象)。 + *@param props 变化的属性列表,比如{x:100,y:20,ease:Ease.backOut,complete:Handler.create(this,onComplete),update:new Handler(this,onComplete)}。 + *@param duration 花费的时间,单位毫秒。 + *@param ease 缓动类型,默认为匀速运动。 + *@param complete 结束回调函数。 + *@param delay 延迟执行时间。 + *@param coverBefore 是否覆盖之前的缓动。 + *@return 返回Tween对象。 + */ + __proto.to=function(target,props,duration,ease,complete,delay,coverBefore){ + (delay===void 0)&& (delay=0); + (coverBefore===void 0)&& (coverBefore=false); + return this._create(target,props,duration,ease,complete,delay,coverBefore,true,false,true); + } + + /** + *从props属性,缓动到当前状态。 + *@param target 目标对象(即将更改属性值的对象)。 + *@param props 变化的属性列表,比如{x:100,y:20,ease:Ease.backOut,complete:Handler.create(this,onComplete),update:new Handler(this,onComplete)}。 + *@param duration 花费的时间,单位毫秒。 + *@param ease 缓动类型,默认为匀速运动。 + *@param complete 结束回调函数。 + *@param delay 延迟执行时间。 + *@param coverBefore 是否覆盖之前的缓动。 + *@return 返回Tween对象。 + */ + __proto.from=function(target,props,duration,ease,complete,delay,coverBefore){ + (delay===void 0)&& (delay=0); + (coverBefore===void 0)&& (coverBefore=false); + return this._create(target,props,duration,ease,complete,delay,coverBefore,false,false,true); + } + + /**@private */ + __proto._create=function(target,props,duration,ease,complete,delay,coverBefore,isTo,usePool,runNow){ + if (!target)throw new Error("Tween:target is null"); + this._target=target; + this._duration=duration; + this._ease=ease || props.ease || Tween.easeNone; + this._complete=complete || props.complete; + this._delay=delay; + this._props=[]; + this._usedTimer=0; + this._startTimer=Browser.now(); + this._usedPool=usePool; + this.update=props.update; + var gid=(target.$_GID || (target.$_GID=Utils.getGID())); + if (!Tween.tweenMap[gid]){ + Tween.tweenMap[gid]=[this]; + }else { + if (coverBefore)Tween.clearTween(target); + Tween.tweenMap[gid].push(this); + } + if (runNow){ + if (delay <=0)this.firstStart(target,props,isTo); + else Laya.timer.once(delay,this,this.firstStart,[target,props,isTo]); + }else { + this._initProps(target,props,isTo); + } + return this; + } + + __proto.firstStart=function(target,props,isTo){ + this._initProps(target,props,isTo); + this._beginLoop(); + } + + __proto._initProps=function(target,props,isTo){ + for (var p in props){ + if ((typeof (target[p])=='number')){ + var start=isTo ? target[p] :props[p]; + var end=isTo ? props[p] :target[p]; + this._props.push([p,start,end-start]); + } + } + } + + __proto._beginLoop=function(){ + Laya.timer.frameLoop(1,this,this._doEase); + } + + /**执行缓动**/ + __proto._doEase=function(){ + this._updateEase(Browser.now()); + } + + /**@private */ + __proto._updateEase=function(time){ + var target=this._target; + if (target.destroyed)return Tween.clearTween(target); + var usedTimer=this._usedTimer=time-this._startTimer-this._delay; + if (usedTimer < 0)return; + if (usedTimer >=this._duration)return this.complete(); + var ratio=usedTimer > 0 ? this._ease(usedTimer,0,1,this._duration):0; + var props=this._props; + for (var i=0,n=props.length;i < n;i++){ + var prop=props[i]; + target[prop[0]]=prop[1]+(ratio *prop[2]); + } + if (this.update)this.update.run(); + } + + /** + *立即结束缓动并到终点。 + */ + __proto.complete=function(){ + if (!this._target)return; + var target=this._target; + var props=this._props; + var handler=this._complete; + for (var i=0,n=props.length;i < n;i++){ + var prop=props[i]; + target[prop[0]]=prop[1]+prop[2]; + } + if (this.update)this.update.run(); + this.clear(); + handler && handler.run(); + } + + /** + *暂停缓动,可以通过resume或restart重新开始。 + */ + __proto.pause=function(){ + Laya.timer.clear(this,this._beginLoop); + Laya.timer.clear(this,this._doEase); + } + + /** + *设置开始时间。 + *@param startTime 开始时间。 + */ + __proto.setStartTime=function(startTime){ + this._startTimer=startTime; + } + + /** + *停止并清理当前缓动。 + */ + __proto.clear=function(){ + if (this._target){ + this._remove(); + this._clear(); + } + } + + /** + *@private + */ + __proto._clear=function(){ + this.pause(); + Laya.timer.clear(this,this.firstStart); + this._complete=null; + this._target=null; + this._ease=null; + this._props=null; + if (this._usedPool){ + this.update=null; + Pool.recover("tween",this); + } + } + + /**回收到对象池。*/ + __proto.recover=function(){ + this._usedPool=true; + this._clear(); + } + + __proto._remove=function(){ + var tweens=Tween.tweenMap[this._target.$_GID]; + if (tweens){ + for (var i=0,n=tweens.length;i < n;i++){ + if (tweens[i]===this){ + tweens.splice(i,1); + break ; + } + } + } + } + + /** + *重新开始暂停的缓动。 + */ + __proto.restart=function(){ + this.pause(); + this._usedTimer=0; + this._startTimer=Browser.now(); + var props=this._props; + for (var i=0,n=props.length;i < n;i++){ + var prop=props[i]; + this._target[prop[0]]=prop[1]; + } + Laya.timer.once(this._delay,this,this._beginLoop); + } + + /** + *恢复暂停的缓动。 + */ + __proto.resume=function(){ + if (this._usedTimer >=this._duration)return; + this._startTimer=Browser.now()-this._usedTimer-this._delay; + this._beginLoop(); + } + + /**设置当前执行比例**/ + __getset(0,__proto,'progress',null,function(v){ + var uTime=v *this._duration; + this._startTimer=Browser.now()-this._delay-uTime; + }); + + Tween.to=function(target,props,duration,ease,complete,delay,coverBefore,autoRecover){ + (delay===void 0)&& (delay=0); + (coverBefore===void 0)&& (coverBefore=false); + (autoRecover===void 0)&& (autoRecover=true); + return Pool.getItemByClass("tween",Tween)._create(target,props,duration,ease,complete,delay,coverBefore,true,autoRecover,true); + } + + Tween.from=function(target,props,duration,ease,complete,delay,coverBefore,autoRecover){ + (delay===void 0)&& (delay=0); + (coverBefore===void 0)&& (coverBefore=false); + (autoRecover===void 0)&& (autoRecover=true); + return Pool.getItemByClass("tween",Tween)._create(target,props,duration,ease,complete,delay,coverBefore,false,autoRecover,true); + } + + Tween.clearAll=function(target){ + if (!target || !target.$_GID)return; + var tweens=Tween.tweenMap[target.$_GID]; + if (tweens){ + for (var i=0,n=tweens.length;i < n;i++){ + tweens[i]._clear(); + } + tweens.length=0; + } + } + + Tween.clear=function(tween){ + tween.clear(); + } + + Tween.clearTween=function(target){ + Tween.clearAll(target); + } + + Tween.easeNone=function(t,b,c,d){ + return c *t / d+b; + } + + Tween.tweenMap={}; + return Tween; + })() + + + /** + *Utils 是工具类。 + */ + //class laya.utils.Utils + var Utils=(function(){ + function Utils(){}; + __class(Utils,'laya.utils.Utils'); + Utils.toRadian=function(angle){ + return angle *Utils._pi2; + } + + Utils.toAngle=function(radian){ + return radian *Utils._pi; + } + + Utils.toHexColor=function(color){ + if (color < 0 || isNaN(color))return null; + var str=color.toString(16); + while (str.length < 6)str="0"+str; + return "#"+str; + } + + Utils.getGID=function(){ + return Utils._gid++; + } + + Utils.concatArray=function(source,array){ + if (!array)return source; + if (!source)return array; + var i=0,len=array.length; + for (i=0;i < len;i++){ + source.push(array[i]); + } + return source; + } + + Utils.clearArray=function(array){ + if (!array)return array; + array.length=0; + return array; + } + + Utils.copyArray=function(source,array){ + source || (source=[]); + if (!array)return source; + source.length=array.length; + var i=0,len=array.length; + for (i=0;i < len;i++){ + source[i]=array[i]; + } + return source; + } + + Utils.getGlobalRecByPoints=function(sprite,x0,y0,x1,y1){ + var newLTPoint; + newLTPoint=new Point(x0,y0); + newLTPoint=sprite.localToGlobal(newLTPoint); + var newRBPoint; + newRBPoint=new Point(x1,y1); + newRBPoint=sprite.localToGlobal(newRBPoint); + return Rectangle._getWrapRec([newLTPoint.x,newLTPoint.y,newRBPoint.x,newRBPoint.y]); + } + + Utils.getGlobalPosAndScale=function(sprite){ + return Utils.getGlobalRecByPoints(sprite,0,0,1,1); + } + + Utils.bind=function(fun,scope){ + var rst=fun; + /*__JS__ */rst=fun.bind(scope);; + return rst; + } + + Utils.measureText=function(txt,font){ + return RunDriver.measureText(txt,font); + } + + Utils.updateOrder=function(array){ + if (!array || array.length < 2)return false; + var i=1,j=0,len=array.length,key=NaN,c; + while (i < len){ + j=i; + c=array[j]; + key=array[j]._zOrder; + while (--j >-1){ + if (array[j]._zOrder > key)array[j+1]=array[j]; + else break ; + } + array[j+1]=c; + i++; + }; + var model=c.parent.model; + if (model){ + if (model.updateZOrder){ + model.updateZOrder(); + } + else{ + for (i=0;i < len;i++){ + model.removeChild(array[i].model); + } + for (i=0;i < len;i++){ + model.addChildAt(array[i].model,i); + } + } + } + return true; + } + + Utils.transPointList=function(points,x,y){ + var i=0,len=points.length; + for (i=0;i < len;i+=2){ + points[i]+=x; + points[i+1]+=y; + } + } + + Utils.parseInt=function(str,radix){ + (radix===void 0)&& (radix=0); + var result=Browser.window.parseInt(str,radix); + if (isNaN(result))return 0; + return result; + } + + Utils.getFileExtension=function(path){ + Utils._extReg.lastIndex=path.lastIndexOf("."); + var result=Utils._extReg.exec(path); + if (result && result.length > 1){ + return result[1].toLowerCase(); + } + return null; + } + + Utils._gid=1; + Utils._pi=180 / Math.PI; + Utils._pi2=Math.PI / 180; + Utils._extReg=/\.(\w+)\??/g; + Utils.parseXMLFromString=function(value){ + var rst; + value=value.replace(/>\s+<'); + /*__JS__ */rst=(new DOMParser()).parseFromString(value,'text/xml'); + if (rst.firstChild.textContent.indexOf("This page contains the following errors")>-1){ + throw new Error(rst.firstChild.firstChild.textContent); + } + return rst; + } + + return Utils; + })() + + + /** + *@private + */ + //class laya.utils.VectorGraphManager + var VectorGraphManager=(function(){ + function VectorGraphManager(){ + this.useDic={}; + this.shapeDic={}; + this.shapeLineDic={}; + this._id=0; + this._checkKey=false; + this._freeIdArray=[]; + if (Render.isWebGL){ + CacheManger.regCacheByFunction(Utils.bind(this.startDispose,this),Utils.bind(this.getCacheList,this)); + } + } + + __class(VectorGraphManager,'laya.utils.VectorGraphManager'); + var __proto=VectorGraphManager.prototype; + /** + *得到个空闲的ID + *@return + */ + __proto.getId=function(){ + return this._id++; + } + + /** + *添加一个图形到列表中 + *@param id + *@param shape + */ + __proto.addShape=function(id,shape){ + this.shapeDic[id]=shape; + if (!this.useDic[id]){ + this.useDic[id]=true; + } + } + + /** + *添加一个线图形到列表中 + *@param id + *@param Line + */ + __proto.addLine=function(id,Line){ + this.shapeLineDic[id]=Line; + if (!this.shapeLineDic[id]){ + this.shapeLineDic[id]=true; + } + } + + /** + *检测一个对象是否在使用中 + *@param id + */ + __proto.getShape=function(id){ + if (this._checkKey){ + if (this.useDic[id] !=null){ + this.useDic[id]=true; + } + } + } + + /** + *删除一个图形对象 + *@param id + */ + __proto.deleteShape=function(id){ + if (this.shapeDic[id]){ + this.shapeDic[id]=null; + delete this.shapeDic[id]; + } + if (this.shapeLineDic[id]){ + this.shapeLineDic[id]=null; + delete this.shapeLineDic[id]; + } + if (this.useDic[id] !=null){ + delete this.useDic[id]; + } + } + + /** + *得到缓存列表 + *@return + */ + __proto.getCacheList=function(){ + var str; + var list=[]; + for (str in this.shapeDic){ + list.push(this.shapeDic[str]); + } + for (str in this.shapeLineDic){ + list.push(this.shapeLineDic[str]); + } + return list; + } + + /** + *开始清理状态,准备销毁 + */ + __proto.startDispose=function(key){ + var str; + for (str in this.useDic){ + this.useDic[str]=false; + } + this._checkKey=true; + } + + /** + *确认销毁 + */ + __proto.endDispose=function(){ + if (this._checkKey){ + var str; + for (str in this.useDic){ + if (!this.useDic[str]){ + this.deleteShape(str); + } + } + this._checkKey=false; + } + } + + VectorGraphManager.getInstance=function(){ + return VectorGraphManager.instance=VectorGraphManager.instance|| new VectorGraphManager(); + } + + VectorGraphManager.instance=null + return VectorGraphManager; + })() + + + /** + *@private + */ + //class laya.utils.WordText + var WordText=(function(){ + function WordText(){ + this.id=NaN; + this.save=[]; + this.toUpperCase=null; + this.changed=false; + this._text=null; + } + + __class(WordText,'laya.utils.WordText'); + var __proto=WordText.prototype; + __proto.setText=function(txt){ + this.changed=true; + this._text=txt; + } + + __proto.toString=function(){ + return this._text; + } + + __proto.charCodeAt=function(i){ + return this._text ? this._text.charCodeAt(i):NaN; + } + + __proto.charAt=function(i){ + return this._text ? this._text.charAt(i):null; + } + + __getset(0,__proto,'length',function(){ + return this._text ? this._text.length :0; + }); + + return WordText; + })() + + + /** + *Node 类用于创建节点对象,节点是最基本的元素。 + */ + //class laya.display.Node extends laya.events.EventDispatcher + var Node=(function(_super){ + function Node(){ + this.name=""; + this.destroyed=false; + this._displayedInStage=false; + this._parent=null; + this.model=null; + Node.__super.call(this); + this._childs=Node.ARRAY_EMPTY; + this.timer=Laya.timer; + this._$P=Node.PROP_EMPTY; + this.model=Render.isConchNode ? /*__JS__ */new ConchNode():null; + } + + __class(Node,'laya.display.Node',_super); + var __proto=Node.prototype; + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + this.destroyed=true; + this._parent && this._parent.removeChild(this); + if (this._childs){ + if (destroyChild)this.destroyChildren(); + else this.removeChildren(); + } + this._childs=null; + this._$P=null; + this.offAll(); + } + + /** + *销毁所有子对象,不销毁自己本身。 + */ + __proto.destroyChildren=function(){ + if (this._childs){ + for (var i=this._childs.length-1;i >-1;i--){ + this._childs[i].destroy(true); + } + } + } + + /** + *添加子节点。 + *@param node 节点对象 + *@return 返回添加的节点 + */ + __proto.addChild=function(node){ + if (this.destroyed || node===this)return node; + if (node._parent===this){ + this._childs.splice(this.getChildIndex(node),1); + this._childs.push(node); + if (this.model){ + this.model.removeChild(node.model); + this.model.addChildAt(node.model,this._childs.length-1); + } + this._childChanged(); + }else { + node.parent && node.parent.removeChild(node); + this._childs===Node.ARRAY_EMPTY && (this._childs=[]); + this._childs.push(node); + this.model && this.model.addChildAt(node.model,this._childs.length-1); + node.parent=this; + this._childChanged(); + } + return node; + } + + /** + *批量增加子节点 + *@param ...args 无数子节点。 + */ + __proto.addChildren=function(__args){ + var args=arguments; + var i=0,n=args.length; + while (i < n){ + this.addChild(args[i++]); + } + } + + /** + *添加子节点到指定的索引位置。 + *@param node 节点对象。 + *@param index 索引位置。 + *@return 返回添加的节点。 + */ + __proto.addChildAt=function(node,index){ + if (this.destroyed || node===this)return node; + if (index >=0 && index <=this._childs.length){ + if (node._parent===this){ + var oldIndex=this.getChildIndex(node); + this._childs.splice(oldIndex,1); + this._childs.splice(index,0,node); + if (this.model){ + this.model.removeChild(node.model); + this.model.addChildAt(node.model,index); + } + this._childChanged(); + }else { + node.parent && node.parent.removeChild(node); + this._childs===Node.ARRAY_EMPTY && (this._childs=[]); + this._childs.splice(index,0,node); + this.model && this.model.addChildAt(node.model,index); + node.parent=this; + } + return node; + }else { + throw new Error("appendChildAt:The index is out of bounds"); + } + } + + /** + *根据子节点对象,获取子节点的索引位置。 + *@param node 子节点。 + *@return 子节点所在的索引位置。 + */ + __proto.getChildIndex=function(node){ + return this._childs.indexOf(node); + } + + /** + *根据子节点的名字,获取子节点对象。 + *@param name 子节点的名字。 + *@return 节点对象。 + */ + __proto.getChildByName=function(name){ + var nodes=this._childs; + for (var i=0,n=nodes.length;i < n;i++){ + var node=nodes[i]; + if (node.name===name)return node; + } + return null; + } + + /**@private */ + __proto._get$P=function(key){ + return this._$P[key]; + } + + /**@private */ + __proto._set$P=function(key,value){ + if (!this.destroyed){ + this._$P===Node.PROP_EMPTY && (this._$P={}); + this._$P[key]=value; + } + return value; + } + + /** + *根据子节点的索引位置,获取子节点对象。 + *@param index 索引位置 + *@return 子节点 + */ + __proto.getChildAt=function(index){ + return this._childs[index]; + } + + /** + *设置子节点的索引位置。 + *@param node 子节点。 + *@param index 新的索引。 + *@return 返回子节点本身。 + */ + __proto.setChildIndex=function(node,index){ + var childs=this._childs; + if (index < 0 || index >=childs.length){ + throw new Error("setChildIndex:The index is out of bounds."); + }; + var oldIndex=this.getChildIndex(node); + if (oldIndex < 0)throw new Error("setChildIndex:node is must child of this object."); + childs.splice(oldIndex,1); + childs.splice(index,0,node); + if (this.model){ + this.model.removeChild(node.model); + this.model.addChildAt(node.model,index); + } + this._childChanged(); + return node; + } + + /** + *@private + *子节点发生改变。 + *@param child 子节点。 + */ + __proto._childChanged=function(child){} + /** + *删除子节点。 + *@param node 子节点 + *@return 被删除的节点 + */ + __proto.removeChild=function(node){ + if (!this._childs)return node; + var index=this._childs.indexOf(node); + return this.removeChildAt(index); + } + + /** + *从父容器删除自己,如已经被删除不会抛出异常。 + *@return 当前节点( Node )对象。 + */ + __proto.removeSelf=function(){ + this._parent && this._parent.removeChild(this); + return this; + } + + /** + *根据子节点名字删除对应的子节点对象,如果找不到不会抛出异常。 + *@param name 对象名字。 + *@return 查找到的节点( Node )对象。 + */ + __proto.removeChildByName=function(name){ + var node=this.getChildByName(name); + node && this.removeChild(node); + return node; + } + + /** + *根据子节点索引位置,删除对应的子节点对象。 + *@param index 节点索引位置。 + *@return 被删除的节点。 + */ + __proto.removeChildAt=function(index){ + var node=this.getChildAt(index); + if (node){ + this._childs.splice(index,1); + this.model && this.model.removeChild(node.model); + node.parent=null; + } + return node; + } + + /** + *删除指定索引区间的所有子对象。 + *@param beginIndex 开始索引。 + *@param endIndex 结束索引。 + *@return 当前节点对象。 + */ + __proto.removeChildren=function(beginIndex,endIndex){ + (beginIndex===void 0)&& (beginIndex=0); + (endIndex===void 0)&& (endIndex=0x7fffffff); + if (this._childs && this._childs.length > 0){ + var childs=this._childs; + if (beginIndex===0 && endIndex >=n){ + var arr=childs; + this._childs=Node.ARRAY_EMPTY; + }else { + arr=childs.splice(beginIndex,endIndex-beginIndex); + } + for (var i=0,n=arr.length;i < n;i++){ + arr[i].parent=null; + this.model && this.model.removeChild(arr[i].model); + } + } + return this; + } + + /** + *替换子节点。 + *@internal 将传入的新节点对象替换到已有子节点索引位置处。 + *@param newNode 新节点。 + *@param oldNode 老节点。 + *@return 返回新节点。 + */ + __proto.replaceChild=function(newNode,oldNode){ + var index=this._childs.indexOf(oldNode); + if (index >-1){ + this._childs.splice(index,1,newNode); + if (this.model){ + this.model.removeChild(oldNode.model); + this.model.addChildAt(newNode.model,index); + } + oldNode.parent=null; + newNode.parent=this; + return newNode; + } + return null; + } + + /**@private */ + __proto._setDisplay=function(value){ + if (this._displayedInStage!==value){ + this._displayedInStage=value; + if (value)this.event(/*laya.events.Event.DISPLAY*/"display"); + else this.event(/*laya.events.Event.UNDISPLAY*/"undisplay"); + } + } + + /** + *@private + *设置指定节点对象是否可见(是否在渲染列表中)。 + *@param node 节点。 + *@param display 是否可见。 + */ + __proto._displayChild=function(node,display){ + var childs=node._childs; + if (childs){ + for (var i=childs.length-1;i >-1;i--){ + var child=childs[i]; + child._setDisplay(display); + child._childs.length && this._displayChild(child,display); + } + } + node._setDisplay(display); + } + + /** + *当前容器是否包含 node 节点。 + *@param node 某一个节点 Node。 + *@return 一个布尔值表示是否包含node节点。 + */ + __proto.contains=function(node){ + if (node===this)return true; + while (node){ + if (node.parent===this)return true; + node=node.parent; + } + return false; + } + + /** + *定时重复执行某函数。 + *@param delay 间隔时间(单位毫秒)。 + *@param caller 执行域(this)。 + *@param method 结束时的回调方法。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为true。 + */ + __proto.timerLoop=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this.timer._create(false,true,delay,caller,method,args,coverBefore); + } + + /** + *定时执行某函数一次。 + *@param delay 延迟时间(单位毫秒)。 + *@param caller 执行域(this)。 + *@param method 结束时的回调方法。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为true。 + */ + __proto.timerOnce=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this.timer._create(false,false,delay,caller,method,args,coverBefore); + } + + /** + *定时重复执行某函数(基于帧率)。 + *@param delay 间隔几帧(单位为帧)。 + *@param caller 执行域(this)。 + *@param method 结束时的回调方法。 + *@param args 回调参数。 + *@param coverBefore 是否覆盖之前的延迟执行,默认为true。 + */ + __proto.frameLoop=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this.timer._create(true,true,delay,caller,method,args,coverBefore); + } + + /** + *定时执行一次某函数(基于帧率)。 + *@param delay 延迟几帧(单位为帧)。 + *@param caller 执行域(this) + *@param method 结束时的回调方法 + *@param args 回调参数 + *@param coverBefore 是否覆盖之前的延迟执行,默认为true + */ + __proto.frameOnce=function(delay,caller,method,args,coverBefore){ + (coverBefore===void 0)&& (coverBefore=true); + this.timer._create(true,false,delay,caller,method,args,coverBefore); + } + + /** + *清理定时器。 + *@param caller 执行域(this)。 + *@param method 结束时的回调方法。 + */ + __proto.clearTimer=function(caller,method){ + this.timer.clear(caller,method); + } + + /** + *子对象数量。 + */ + __getset(0,__proto,'numChildren',function(){ + return this._childs.length; + }); + + /**父节点。*/ + __getset(0,__proto,'parent',function(){ + return this._parent; + },function(value){ + if (this._parent!==value){ + if (value){ + this._parent=value; + this.event(/*laya.events.Event.ADDED*/"added"); + value.displayedInStage && this._displayChild(this,true); + value._childChanged(this); + }else { + this.event(/*laya.events.Event.REMOVED*/"removed"); + this._parent._childChanged(); + this._displayChild(this,false); + this._parent=value; + } + } + }); + + /**表示是否在显示列表中显示。是否在显示渲染列表中。*/ + __getset(0,__proto,'displayedInStage',function(){ + return this._displayedInStage; + }); + + Node.ARRAY_EMPTY=[]; + Node.PROP_EMPTY={}; + return Node; + })(EventDispatcher) + + + /** + *@private + *CSSStyle 类是元素CSS样式定义类。 + */ + //class laya.display.css.CSSStyle extends laya.display.css.Style + var CSSStyle=(function(_super){ + function CSSStyle(ower){ + this._bgground=null; + this._border=null; + //this._ower=null; + this._rect=null; + this.lineHeight=0; + CSSStyle.__super.call(this); + this._padding=CSSStyle._PADDING; + this._spacing=CSSStyle._SPACING; + this._aligns=CSSStyle._ALIGNS; + this._font=Font.EMPTY; + this._ower=ower; + } + + __class(CSSStyle,'laya.display.css.CSSStyle',_super); + var __proto=CSSStyle.prototype; + /**@inheritDoc */ + __proto.destroy=function(){ + this._ower=null; + this._font=null; + this._rect=null; + } + + /** + *复制传入的 CSSStyle 属性值。 + *@param src 待复制的 CSSStyle 对象。 + */ + __proto.inherit=function(src){ + this._font=src._font; + this._spacing=src._spacing===CSSStyle._SPACING ? CSSStyle._SPACING :src._spacing.slice(); + this.lineHeight=src.lineHeight; + } + + /**@private */ + __proto._widthAuto=function(){ + return (this._type & 0x40000)!==0; + } + + /**@inheritDoc */ + __proto.widthed=function(sprite){ + return (this._type & 0x8)!=0; + } + + /** + *@private + */ + __proto._calculation=function(type,value){ + if (value.indexOf('%')< 0)return false; + var ower=this._ower; + var parent=ower.parent; + var rect=this._rect; + function getValue (pw,w,nums){ + return (pw *nums[0]+w *nums[1]+nums[2]); + } + function onParentResize (type){ + var pw=parent.width,w=ower.width; + rect.width && (ower.width=getValue(pw,w,rect.width)); + rect.height && (ower.height=getValue(pw,w,rect.height)); + rect.left && (ower.x=getValue(pw,w,rect.left)); + rect.top && (ower.y=getValue(pw,w,rect.top)); + } + if (rect===null){ + parent._getCSSStyle()._type |=0x80000; + parent.on(/*laya.events.Event.RESIZE*/"resize",this,onParentResize); + this._rect=rect={input:{}}; + }; + var nums=value.split(' '); + nums[0]=parseFloat(nums[0])/ 100; + if (nums.length==1) + nums[1]=nums[2]=0; + else { + nums[1]=parseFloat(nums[1])/ 100; + nums[2]=parseFloat(nums[2]); + } + rect[type]=nums; + rect.input[type]=value; + onParentResize(type); + return true; + } + + /** + *是否已设置高度。 + *@param sprite 显示对象 Sprite。 + *@return 一个Boolean 表示是否已设置高度。 + */ + __proto.heighted=function(sprite){ + return (this._type & 0x2000)!=0; + } + + /** + *设置宽高。 + *@param w 宽度。 + *@param h 高度。 + */ + __proto.size=function(w,h){ + var ower=this._ower; + var resize=false; + if (w!==-1 && w !=this._ower.width){ + this._type |=0x8; + this._ower.width=w; + resize=true; + } + if (h!==-1 && h !=this._ower.height){ + this._type |=0x2000; + this._ower.height=h; + resize=true; + } + if (resize){ + ower._layoutLater(); + (this._type & 0x80000)&& ower.event(/*laya.events.Event.RESIZE*/"resize",this); + } + } + + /**@private */ + __proto._getAlign=function(){ + return this._aligns[0]; + } + + /**@private */ + __proto._getValign=function(){ + return this._aligns[1]; + } + + /**@private */ + __proto._getCssFloat=function(){ + return (this._type & 0x8000)!=0 ? 0x8000 :0; + } + + __proto._createFont=function(){ + return (this._type & 0x1000)? this._font :(this._type |=0x1000,this._font=new Font(this._font)); + } + + /**@inheritDoc */ + __proto.render=function(sprite,context,x,y){ + var w=sprite.width; + var h=sprite.height; + x-=sprite.pivotX; + y-=sprite.pivotY; + this._bgground && this._bgground.color !=null && context.ctx.fillRect(x,y,w,h,this._bgground.color); + this._border && this._border.color && context.drawRect(x,y,w,h,this._border.color.strColor,this._border.size); + } + + /**@inheritDoc */ + __proto.getCSSStyle=function(){ + return this; + } + + /** + *设置 CSS 样式字符串。 + *@param text CSS样式字符串。 + */ + __proto.cssText=function(text){ + this.attrs(CSSStyle.parseOneCSS(text,';')); + } + + /** + *根据传入的属性名、属性值列表,设置此对象的属性值。 + *@param attrs 属性名与属性值列表。 + */ + __proto.attrs=function(attrs){ + if (attrs){ + for (var i=0,n=attrs.length;i < n;i++){ + var attr=attrs[i]; + this[attr[0]]=attr[1]; + } + } + } + + /**@inheritDoc */ + __proto.setTransform=function(value){ + (value==='none')? (this._tf=Style._TF_EMPTY):this.attrs(CSSStyle.parseOneCSS(value,',')); + } + + /** + *定义 X 轴、Y 轴移动转换。 + *@param x X 轴平移量。 + *@param y Y 轴平移量。 + */ + __proto.translate=function(x,y){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.translateX=x; + this._tf.translateY=y; + } + + /** + *定义 缩放转换。 + *@param x X 轴缩放值。 + *@param y Y 轴缩放值。 + */ + __proto.scale=function(x,y){ + this._tf===Style._TF_EMPTY && (this._tf=new TransformInfo()); + this._tf.scaleX=x; + this._tf.scaleY=y; + } + + /**@private */ + __proto._enableLayout=function(){ + return (this._type & 0x2)===0 && (this._type & 0x4)===0; + } + + /** + *是否显示为块级元素。 + */ + __getset(0,__proto,'block',_super.prototype._$get_block,function(value){ + value ? (this._type |=0x1):(this._type &=(~0x1)); + }); + + /** + *垂直对齐方式。 + */ + __getset(0,__proto,'valign',function(){ + return CSSStyle._valigndef[this._aligns[1]]; + },function(value){ + this._aligns===CSSStyle._ALIGNS && (this._aligns=[0,0,0]); + this._aligns[1]=CSSStyle._valigndef[value]; + }); + + /** + *高度。 + */ + __getset(0,__proto,'height',null,function(h){ + this._type |=0x2000; + if ((typeof h=='string')){ + if (this._calculation("height",h))return; + h=parseInt(h); + } + this.size(-1,h); + }); + + /** + *宽度。 + */ + __getset(0,__proto,'width',null,function(w){ + this._type |=0x8; + if ((typeof w=='string')){ + var offset=w.indexOf('auto'); + if (offset >=0){ + this._type |=0x40000; + w=w.substr(0,offset); + } + if (this._calculation("width",w))return; + w=parseInt(w); + } + this.size(w,-1); + }); + + /** + *字体粗细。 + */ + __getset(0,__proto,'fontWeight',function(){ + return this._font.weight; + },function(value){ + this._createFont().weight=value; + }); + + /** + *表示左边距。 + */ + __getset(0,__proto,'left',null,function(value){ + var ower=this._ower; + if (((typeof value=='string'))){ + if (value==="center") + value="50% -50% 0"; + else if (value==="right") + value="100% -100% 0"; + if (this._calculation("left",value))return; + value=parseInt(value); + } + ower.x=value; + }); + + __getset(0,__proto,'_translate',null,function(value){ + this.translate(value[0],value[1]); + }); + + /**@inheritDoc */ + __getset(0,__proto,'absolute',function(){ + return (this._type & 0x4)!==0; + }); + + /** + *表示上边距。 + */ + __getset(0,__proto,'top',null,function(value){ + var ower=this._ower; + if (((typeof value=='string'))){ + if (value==="middle") + value="50% -50% 0"; + else if (value==="bottom") + value="100% -100% 0"; + if (this._calculation("top",value))return; + value=parseInt(value); + } + ower.y=value; + }); + + /** + *水平对齐方式。 + */ + __getset(0,__proto,'align',function(){ + return CSSStyle._aligndef[this._aligns[0]]; + },function(value){ + this._aligns===CSSStyle._ALIGNS && (this._aligns=[0,0,0]); + this._aligns[0]=CSSStyle._aligndef[value]; + }); + + /** + *表示是否加粗。 + */ + __getset(0,__proto,'bold',function(){ + return this._font.bold; + },function(value){ + this._createFont().bold=value; + }); + + /** + *边距信息。 + */ + __getset(0,__proto,'padding',function(){ + return this._padding; + },function(value){ + this._padding=value; + }); + + /** + *行间距。 + */ + __getset(0,__proto,'leading',function(){ + return this._spacing[1]; + },function(d){ + ((typeof d=='string'))&& (d=parseInt(d+"")); + this._spacing===CSSStyle._SPACING && (this._spacing=[0,0]); + this._spacing[1]=d; + }); + + /** + *是否是行元素。 + */ + __getset(0,__proto,'lineElement',function(){ + return (this._type & 0x10000)!=0; + },function(value){ + value ? (this._type |=0x10000):(this._type &=(~0x10000)); + }); + + /** + *浮动方向。 + */ + __getset(0,__proto,'cssFloat',function(){ + return (this._type & 0x8000)!=0 ? "right" :"left"; + },function(value){ + this.lineElement=false; + value==="right" ? (this._type |=0x8000):(this._type &=(~0x8000)); + }); + + /** + *添加到文本的修饰。 + */ + __getset(0,__proto,'textDecoration',function(){ + return this._font.decoration; + },function(value){ + this._createFont().decoration=value; + }); + + /** + *设置如何处理元素内的空白。 + */ + __getset(0,__proto,'whiteSpace',function(){ + return (this._type & 0x20000)? "nowrap" :""; + },function(type){ + type==="nowrap" && (this._type |=0x20000); + type==="none" && (this._type &=~0x20000); + }); + + __getset(0,__proto,'background',null,function(value){ + if (!value){ + this._bgground=null; + return; + } + this._bgground || (this._bgground={}); + this._bgground.color=value; + this._ower.model && this._ower.model.bgColor(value); + this._type |=0x4000; + this._ower._renderType |=/*laya.renders.RenderSprite.STYLE*/0x80; + }); + + /** + *表示是否换行。 + */ + __getset(0,__proto,'wordWrap',function(){ + return (this._type & 0x20000)===0; + },function(value){ + value ? (this._type &=~0x20000):(this._type |=0x20000); + }); + + /** + *字体颜色。 + */ + __getset(0,__proto,'color',function(){ + return this._font.color; + },function(value){ + this._createFont().color=value; + }); + + /** + *

    指定文本字段是否是密码文本字段。

    + *如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 + */ + __getset(0,__proto,'password',function(){ + return this._font.password; + },function(value){ + this._createFont().password=value; + }); + + /** + *背景颜色。 + */ + __getset(0,__proto,'backgroundColor',function(){ + return this._bgground ? this._bgground.color :null; + },function(value){ + if (value==='none')this._bgground=null; + else (this._bgground || (this._bgground={}),this._bgground.color=value); + this._ower.model && this._ower.model.bgColor(value); + this._ower._renderType |=/*laya.renders.RenderSprite.STYLE*/0x80; + }); + + /** + *字体信息。 + */ + __getset(0,__proto,'font',function(){ + return this._font.toString(); + },function(value){ + this._createFont().set(value); + }); + + /** + *文本的粗细。 + */ + __getset(0,__proto,'weight',null,function(value){ + this._createFont().weight=value; + }); + + /** + *间距。 + */ + __getset(0,__proto,'letterSpacing',function(){ + return this._spacing[0]; + },function(d){ + ((typeof d=='string'))&& (d=parseInt(d+"")); + this._spacing===CSSStyle._SPACING && (this._spacing=[0,0]); + this._spacing[0]=d; + }); + + /** + *字体大小。 + */ + __getset(0,__proto,'fontSize',function(){ + return this._font.size; + },function(value){ + this._createFont().size=value; + }); + + /** + *表示是否为斜体。 + */ + __getset(0,__proto,'italic',function(){ + return this._font.italic; + },function(value){ + this._createFont().italic=value; + }); + + /** + *字体系列。 + */ + __getset(0,__proto,'fontFamily',function(){ + return this._font.family; + },function(value){ + this._createFont().family=value; + }); + + /** + *

    描边宽度(以像素为单位)。

    + *默认值0,表示不描边。 + *@default 0 + */ + __getset(0,__proto,'stroke',function(){ + return this._font.stroke[0]; + },function(value){ + if (this._createFont().stroke===Font._STROKE)this._font.stroke=[0,"#000000"]; + this._font.stroke[0]=value; + }); + + /** + *

    描边颜色,以字符串表示。

    + *@default "#000000"; + */ + __getset(0,__proto,'strokeColor',function(){ + return this._font.stroke[1]; + },function(value){ + if (this._createFont().stroke===Font._STROKE)this._font.stroke=[0,"#000000"]; + this._font.stroke[1]=value; + }); + + /** + *边框属性,比如border="5px solid red" + */ + __getset(0,__proto,'border',function(){ + return this._border ? this._border.value :""; + },function(value){ + if (value=='none'){ + this._border=null; + return; + } + this._border || (this._border={}); + this._border.value=value; + var values=value.split(' '); + this._border.color=Color.create(values[values.length-1]); + if (values.length==1){ + this._border.size=1; + this._border.type='solid'; + return; + }; + var i=0; + if (values[0].indexOf('px')> 0){ + this._border.size=parseInt(values[0]); + i++; + }else this._border.size=1; + this._border.type=values[i]; + this._ower._renderType |=/*laya.renders.RenderSprite.STYLE*/0x80; + }); + + /** + *边框的颜色。 + */ + __getset(0,__proto,'borderColor',function(){ + return (this._border && this._border.color)? this._border.color.strColor :null; + },function(value){ + if (!value){ + this._border=null; + return; + } + this._border || (this._border={size:1,type:'solid'}); + this._border.color=(value==null)? null :Color.create(value); + this._ower.model && this._ower.model.border(this._border.color.strColor); + this._ower._renderType |=/*laya.renders.RenderSprite.STYLE*/0x80; + }); + + /** + *元素的定位类型。 + */ + __getset(0,__proto,'position',function(){ + return (this._type & 0x4)? "absolute" :""; + },function(value){ + value=="absolute" ? (this._type |=0x4):(this._type &=~0x4); + }); + + /** + *规定元素应该生成的框的类型。 + */ + __getset(0,__proto,'display',null,function(value){ + switch (value){ + case '': + this._type &=~0x2; + this.visible=true; + break ; + case 'none': + this._type |=0x2; + this.visible=false; + this._ower._layoutLater(); + break ; + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'paddingLeft',function(){ + return this.padding[3]; + }); + + /**@inheritDoc */ + __getset(0,__proto,'paddingTop',function(){ + return this.padding[0]; + }); + + __getset(0,__proto,'_scale',null,function(value){ + this._ower.scale(value[0],value[1]); + }); + + __getset(0,__proto,'_rotate',null,function(value){ + this._ower.rotation=value; + }); + + CSSStyle.parseOneCSS=function(text,clipWord){ + var out=[]; + var attrs=text.split(clipWord); + var valueArray; + for (var i=0,n=attrs.length;i < n;i++){ + var attr=attrs[i]; + var ofs=attr.indexOf(':'); + var name=attr.substr(0,ofs).replace(/^\s+|\s+$/g,''); + if (name.length==0) + continue ; + var value=attr.substr(ofs+1).replace(/^\s+|\s+$/g,''); + var one=[name,value]; + switch (name){ + case 'italic': + case 'bold': + one[1]=value=="true"; + break ; + case 'line-height': + one[0]='lineHeight'; + one[1]=parseInt(value); + break ; + case 'font-size': + one[0]='fontSize'; + one[1]=parseInt(value); + break ; + case 'padding': + valueArray=value.split(' '); + valueArray.length > 1 || (valueArray[1]=valueArray[2]=valueArray[3]=valueArray[0]); + one[1]=[parseInt(valueArray[0]),parseInt(valueArray[1]),parseInt(valueArray[2]),parseInt(valueArray[3])]; + break ; + case 'rotate': + one[0]="_rotate"; + one[1]=parseFloat(value); + break ; + case 'scale': + valueArray=value.split(' '); + one[0]="_scale"; + one[1]=[parseFloat(valueArray[0]),parseFloat(valueArray[1])]; + break ; + case 'translate': + valueArray=value.split(' '); + one[0]="_translate"; + one[1]=[parseInt(valueArray[0]),parseInt(valueArray[1])]; + break ; + default : + (one[0]=CSSStyle._CSSTOVALUE[name])|| (one[0]=name); + } + out.push(one); + } + return out; + } + + CSSStyle.parseCSS=function(text,uri){ + var one; + while ((one=CSSStyle._parseCSSRegExp.exec(text))!=null){ + CSSStyle.styleSheets[one[1]]=CSSStyle.parseOneCSS(one[2],';'); + } + } + + CSSStyle.EMPTY=new CSSStyle(null); + CSSStyle._CSSTOVALUE={'letter-spacing':'letterSpacing','line-spacing':'lineSpacing','white-space':'whiteSpace','line-height':'lineHeight','scale-x':'scaleX','scale-y':'scaleY','translate-x':'translateX','translate-y':'translateY','font-family':'fontFamily','font-weight':'fontWeight','vertical-align':'valign','text-decoration':'textDecoration','background-color':'backgroundColor','border-color':'borderColor','float':'cssFloat'}; + CSSStyle._parseCSSRegExp=new RegExp("([\.\#]\\w+)\\s*{([\\s\\S]*?)}","g"); + CSSStyle._aligndef={'left':0,'center':1,'right':2,0:'left',1:'center',2:'right'}; + CSSStyle._valigndef={'top':0,'middle':1,'bottom':2,0:'top',1:'middle',2:'bottom'}; + CSSStyle.styleSheets={}; + CSSStyle.ALIGN_CENTER=1; + CSSStyle.ALIGN_RIGHT=2; + CSSStyle.VALIGN_MIDDLE=1; + CSSStyle.VALIGN_BOTTOM=2; + CSSStyle._CSS_BLOCK=0x1; + CSSStyle._DISPLAY_NONE=0x2; + CSSStyle._ABSOLUTE=0x4; + CSSStyle._WIDTH_SET=0x8; + CSSStyle._PADDING=[0,0,0,0]; + CSSStyle._RECT=[-1,-1,-1,-1]; + CSSStyle._SPACING=[0,0]; + CSSStyle._ALIGNS=[0,0,0]; + CSSStyle.ADDLAYOUTED=0x200; + CSSStyle._NEWFONT=0x1000; + CSSStyle._HEIGHT_SET=0x2000; + CSSStyle._BACKGROUND_SET=0x4000; + CSSStyle._FLOAT_RIGHT=0x8000; + CSSStyle._LINE_ELEMENT=0x10000; + CSSStyle._NOWARP=0x20000; + CSSStyle._WIDTHAUTO=0x40000; + CSSStyle._LISTERRESZIE=0x80000; + return CSSStyle; + })(Style) + + + /** + *@private + *使用Audio标签播放声音 + */ + //class laya.media.h5audio.AudioSound extends laya.events.EventDispatcher + var AudioSound=(function(_super){ + function AudioSound(){ + this.url=null; + this.audio=null; + this.loaded=false; + AudioSound.__super.call(this); + } + + __class(AudioSound,'laya.media.h5audio.AudioSound',_super); + var __proto=AudioSound.prototype; + /** + *释放声音 + * + */ + __proto.dispose=function(){ + var ad=AudioSound._audioCache[this.url]; + if (ad){ + ad.src=""; + delete AudioSound._audioCache[this.url]; + } + } + + /** + *加载声音 + *@param url + * + */ + __proto.load=function(url){ + this.url=url; + var ad=AudioSound._audioCache[url]; + if (ad && ad.readyState >=2){ + this.event(/*laya.events.Event.COMPLETE*/"complete"); + return; + } + if (!ad){ + ad=Browser.createElement("audio"); + ad.src=url; + AudioSound._audioCache[url]=ad; + } + ad.addEventListener("canplaythrough",onLoaded); + ad.addEventListener("error",onErr); + var me=this; + function onLoaded (){ + offs(); + me.loaded=true; + me.event(/*laya.events.Event.COMPLETE*/"complete"); + } + function onErr (){ + offs(); + me.event(/*laya.events.Event.ERROR*/"error"); + } + function offs (){ + ad.removeEventListener("canplaythrough",onLoaded); + ad.removeEventListener("error",onErr); + } + this.audio=ad; + if (ad.load){ + ad.load(); + }else { + onErr(); + } + } + + /** + *播放声音 + *@param startTime 起始时间 + *@param loops 循环次数 + *@return + * + */ + __proto.play=function(startTime,loops){ + (startTime===void 0)&& (startTime=0); + (loops===void 0)&& (loops=0); + if (!this.url)return null; + var ad; + ad=AudioSound._audioCache[this.url]; + if (!ad)return null; + var tAd; + tAd=Pool.getItem("audio:"+this.url); + tAd=tAd?tAd:ad.cloneNode(true); + var channel=new AudioSoundChannel(tAd); + channel.url=this.url; + channel.loops=loops; + channel.startTime=startTime; + channel.play(); + SoundManager.addChannel(channel); + return channel; + } + + /** + *获取总时间。 + */ + __getset(0,__proto,'duration',function(){ + var ad; + ad=AudioSound._audioCache[this.url]; + if (!ad) + return 0; + return ad.duration; + }); + + AudioSound._audioCache={}; + return AudioSound; + })(EventDispatcher) + + + /** + *SoundChannel 用来控制程序中的声音。 + */ + //class laya.media.SoundChannel extends laya.events.EventDispatcher + var SoundChannel=(function(_super){ + function SoundChannel(){ + this.url=null; + this.loops=0; + this.startTime=NaN; + this.isStopped=false; + this.completeHandler=null; + SoundChannel.__super.call(this); + } + + __class(SoundChannel,'laya.media.SoundChannel',_super); + var __proto=SoundChannel.prototype; + /** + *播放。 + */ + __proto.play=function(){} + /** + *停止。 + */ + __proto.stop=function(){} + /** + *private + */ + __proto.__runComplete=function(handler){ + if (handler){ + handler.run(); + } + } + + /** + *音量。 + */ + __getset(0,__proto,'volume',function(){ + return 1; + },function(v){ + }); + + /** + *获取当前播放时间。 + */ + __getset(0,__proto,'position',function(){ + return 0; + }); + + /** + *获取总时间。 + */ + __getset(0,__proto,'duration',function(){ + return 0; + }); + + return SoundChannel; + })(EventDispatcher) + + + /** + *Sound 类是用来播放控制声音的类。 + */ + //class laya.media.Sound extends laya.events.EventDispatcher + var Sound=(function(_super){ + function Sound(){Sound.__super.call(this);; + }; + + __class(Sound,'laya.media.Sound',_super); + var __proto=Sound.prototype; + /** + *加载声音。 + *@param url 地址。 + * + */ + __proto.load=function(url){} + /** + *播放声音。 + *@param startTime 开始时间,单位秒 + *@param loops 循环次数,0表示一直循环 + *@return 声道 SoundChannel 对象。 + * + */ + __proto.play=function(startTime,loops){ + (startTime===void 0)&& (startTime=0); + (loops===void 0)&& (loops=0); + return null; + } + + /** + *释放声音资源。 + * + */ + __proto.dispose=function(){} + /** + *获取总时间。 + */ + __getset(0,__proto,'duration',function(){ + return 0; + }); + + return Sound; + })(EventDispatcher) + + + /** + *@private + *web audio api方式播放声音 + */ + //class laya.media.webaudio.WebAudioSound extends laya.events.EventDispatcher + var WebAudioSound=(function(_super){ + function WebAudioSound(){ + this.url=null; + this.loaded=false; + this.data=null; + this.audioBuffer=null; + this.__toPlays=null; + WebAudioSound.__super.call(this); + } + + __class(WebAudioSound,'laya.media.webaudio.WebAudioSound',_super); + var __proto=WebAudioSound.prototype; + /** + *加载声音 + *@param url + * + */ + __proto.load=function(url){ + var me=this; + this.url=url; + this.audioBuffer=WebAudioSound._dataCache[url]; + if (this.audioBuffer){ + this._loaded(this.audioBuffer); + return; + } + WebAudioSound.e.on("loaded:"+url,this,this._loaded); + WebAudioSound.e.on("err:"+url,this,this._err); + if (WebAudioSound.__loadingSound[url]){ + return; + } + WebAudioSound.__loadingSound[url]=true; + var request=new Browser.window.XMLHttpRequest(); + request.open("GET",url,true); + request.responseType="arraybuffer"; + request.onload=function (){ + me.data=request.response; + WebAudioSound.buffs.push({"buffer":me.data,"url":me.url}); + WebAudioSound.decode(); + }; + request.onerror=function (e){ + me._err(); + } + request.send(); + } + + __proto._err=function(){ + this._removeLoadEvents(); + WebAudioSound.__loadingSound[this.url]=false; + this.event(/*laya.events.Event.ERROR*/"error"); + } + + __proto._loaded=function(audioBuffer){ + this._removeLoadEvents(); + this.audioBuffer=audioBuffer; + WebAudioSound._dataCache[this.url]=this.audioBuffer; + this.loaded=true; + this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + + __proto._removeLoadEvents=function(){ + WebAudioSound.e.off("loaded:"+this.url,this,this._loaded); + WebAudioSound.e.off("err:"+this.url,this,this._err); + } + + __proto.__playAfterLoaded=function(){ + if (!this.__toPlays)return; + var i=0,len=0; + var toPlays; + toPlays=this.__toPlays; + len=toPlays.length; + var tParams; + for (i=0;i < len;i++){ + tParams=toPlays[i]; + if(tParams[2]&&!(tParams [2]).isStopped){ + this.play(tParams[0],tParams[1],tParams[2]); + } + } + this.__toPlays.length=0; + } + + /** + *播放声音 + *@param startTime 起始时间 + *@param loops 循环次数 + *@return + * + */ + __proto.play=function(startTime,loops,channel){ + (startTime===void 0)&& (startTime=0); + (loops===void 0)&& (loops=0); + channel=channel ? channel :new WebAudioSoundChannel(); + if (!this.audioBuffer){ + if (this.url){ + if (!this.__toPlays)this.__toPlays=[]; + this.__toPlays.push([startTime,loops,channel]); + this.once(/*laya.events.Event.COMPLETE*/"complete",this,this.__playAfterLoaded); + this.load(this.url); + } + } + channel.url=this.url; + channel.loops=loops; + channel["audioBuffer"]=this.audioBuffer; + channel.startTime=startTime; + channel.play(); + SoundManager.addChannel(channel); + return channel; + } + + __proto.dispose=function(){ + delete WebAudioSound._dataCache[this.url]; + delete WebAudioSound.__loadingSound[this.url]; + } + + __getset(0,__proto,'duration',function(){ + if (this.audioBuffer){ + return this.audioBuffer.duration; + } + return 0; + }); + + WebAudioSound.decode=function(){ + if (WebAudioSound.buffs.length <=0 || WebAudioSound.isDecoding){ + return; + } + WebAudioSound.isDecoding=true; + WebAudioSound.tInfo=WebAudioSound.buffs.shift(); + WebAudioSound.ctx.decodeAudioData(WebAudioSound.tInfo["buffer"],WebAudioSound._done,WebAudioSound._fail); + } + + WebAudioSound._done=function(audioBuffer){ + WebAudioSound.e.event("loaded:"+WebAudioSound.tInfo.url,audioBuffer); + WebAudioSound.isDecoding=false; + WebAudioSound.decode(); + } + + WebAudioSound._fail=function(){ + WebAudioSound.e.event("err:"+WebAudioSound.tInfo.url,null); + WebAudioSound.isDecoding=false; + WebAudioSound.decode(); + } + + WebAudioSound._playEmptySound=function(){ + if (WebAudioSound.ctx==null){return;}; + var source=WebAudioSound.ctx.createBufferSource(); + source.buffer=WebAudioSound._miniBuffer; + source.connect(WebAudioSound.ctx.destination); + source.start(0,0,0); + } + + WebAudioSound._unlock=function(){ + if (WebAudioSound._unlocked){return;} + WebAudioSound._playEmptySound(); + if (WebAudioSound.ctx.state=="running"){ + Browser.document.removeEventListener("mousedown",WebAudioSound._unlock,true); + Browser.document.removeEventListener("touchend",WebAudioSound._unlock,true); + WebAudioSound._unlocked=true; + } + } + + WebAudioSound.initWebAudio=function(){ + if (WebAudioSound.ctx.state !="running"){ + WebAudioSound._unlock(); + Browser.document.addEventListener("mousedown",WebAudioSound._unlock,true); + Browser.document.addEventListener("touchend",WebAudioSound._unlock,true); + } + } + + WebAudioSound._dataCache={}; + WebAudioSound.buffs=[]; + WebAudioSound.isDecoding=false; + WebAudioSound._unlocked=false; + WebAudioSound.tInfo=null + WebAudioSound.__loadingSound={}; + __static(WebAudioSound, + ['window',function(){return this.window=Browser.window;},'webAudioEnabled',function(){return this.webAudioEnabled=WebAudioSound.window["AudioContext"] || WebAudioSound.window["webkitAudioContext"] || WebAudioSound.window["mozAudioContext"];},'ctx',function(){return this.ctx=WebAudioSound.webAudioEnabled ? new (WebAudioSound.window["AudioContext"] || WebAudioSound.window["webkitAudioContext"] || WebAudioSound.window["mozAudioContext"])():undefined;},'_miniBuffer',function(){return this._miniBuffer=WebAudioSound.ctx.createBuffer(1,1,22050);},'e',function(){return this.e=new EventDispatcher();} + ]); + return WebAudioSound; + })(EventDispatcher) + + + /** + *HttpRequest 通过 HTTP 协议传送或接收 XML 及其他数据。 + */ + //class laya.net.HttpRequest extends laya.events.EventDispatcher + var HttpRequest=(function(_super){ + function HttpRequest(){ + this._responseType=null; + this._data=null; + HttpRequest.__super.call(this); + this._http=new Browser.window.XMLHttpRequest(); + } + + __class(HttpRequest,'laya.net.HttpRequest',_super); + var __proto=HttpRequest.prototype; + /** + *发送请求。 + *@param url 请求的地址。 + *@param data 发送的数据,可选。 + *@param method 发送数据方式,值为“get”或“post”,默认为 “get”方式。 + *@param responseType 返回消息类型,可设置为"text","json","xml","arraybuffer"。 + *@param headers 头信息,key value数组,比如["Content-Type","application/json"]。 + */ + __proto.send=function(url,data,method,responseType,headers){ + (method===void 0)&& (method="get"); + (responseType===void 0)&& (responseType="text"); + this._responseType=responseType; + this._data=null; + var _this=this; + var http=this._http; + http.open(method,url,true); + if (headers){ + for (var i=0;i < headers.length;i++){ + http.setRequestHeader(headers[i++],headers[i]); + } + }else { + if (!data || (typeof data=='string'))http.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); + else http.setRequestHeader("Content-Type","application/json"); + } + http.responseType=responseType!=="arraybuffer" ? "text" :"arraybuffer"; + http.onerror=function (e){ + _this._onError(e); + } + http.onabort=function (e){ + _this._onAbort(e); + } + http.onprogress=function (e){ + _this._onProgress(e); + } + http.onload=function (e){ + _this._onLoad(e); + } + http.send(data); + } + + /** + *@private + *请求进度的侦听处理函数。 + *@param e 事件对象。 + */ + __proto._onProgress=function(e){ + if (e && e.lengthComputable)this.event(/*laya.events.Event.PROGRESS*/"progress",e.loaded / e.total); + } + + /** + *@private + *请求中断的侦听处理函数。 + *@param e 事件对象。 + */ + __proto._onAbort=function(e){ + this.error("Request was aborted by user"); + } + + /** + *@private + *请求出错侦的听处理函数。 + *@param e 事件对象。 + */ + __proto._onError=function(e){ + this.error("Request failed Status:"+this._http.status+" text:"+this._http.statusText); + } + + /** + *@private + *请求消息返回的侦听处理函数。 + *@param e 事件对象。 + */ + __proto._onLoad=function(e){ + var http=this._http; + var status=http.status!==undefined ? http.status :200; + if (status===200 || status===204 || status===0){ + this.complete(); + }else { + this.error("["+http.status+"]"+http.statusText+":"+http.responseURL); + } + } + + /** + *@private + *请求错误的处理函数。 + *@param message 错误信息。 + */ + __proto.error=function(message){ + this.clear(); + this.event(/*laya.events.Event.ERROR*/"error",message); + } + + /** + *@private + *请求成功完成的处理函数。 + */ + __proto.complete=function(){ + this.clear(); + var flag=true; + try { + if (this._responseType==="json"){ + this._data=JSON.parse(this._http.responseText); + }else if (this._responseType==="xml"){ + this._data=Utils.parseXMLFromString(this._http.responseText); + }else { + this._data=this._http.response || this._http.responseText; + } + }catch (e){ + flag=false; + this.error(e.message); + } + flag && this.event(/*laya.events.Event.COMPLETE*/"complete",(this._data instanceof Array)? [this._data] :this._data); + } + + /** + *@private + *清除当前请求。 + */ + __proto.clear=function(){ + var http=this._http; + http.onerror=http.onabort=http.onprogress=http.onload=null; + } + + /**请求的地址。*/ + __getset(0,__proto,'url',function(){ + return this._http.responseURL; + }); + + /**原生XMLHttpRequest引用*/ + __getset(0,__proto,'http',function(){ + return this._http; + }); + + /**返回的数据。*/ + __getset(0,__proto,'data',function(){ + return this._data; + }); + + return HttpRequest; + })(EventDispatcher) + + + /** + *Loader 类可用来加载文本、JSON、XML、二进制、图像等资源。 + */ + //class laya.net.Loader extends laya.events.EventDispatcher + var Loader=(function(_super){ + function Loader(){ + this._data=null; + this._url=null; + this._type=null; + this._cache=false; + this._http=null; + Loader.__super.call(this); + } + + __class(Loader,'laya.net.Loader',_super); + var __proto=Loader.prototype; + /** + *加载资源。 + *@param url 地址 + *@param type 类型,如果为null,则根据文件后缀,自动分析类型。 + *@param cache 是否缓存数据。 + *@param group 分组。 + *@param ignoreCache 是否忽略缓存,强制重新加载 + */ + __proto.load=function(url,type,cache,group,ignoreCache){ + (cache===void 0)&& (cache=true); + (ignoreCache===void 0)&& (ignoreCache=false); + if (url.indexOf("data:image")===0)this._type="image"; + url=URL.formatURL(url); + this._url=url; + this._type=type || (type=this.getTypeFromUrl(url)); + this._cache=cache; + this._data=null; + if (!ignoreCache && Loader.loadedMap[url]){ + this._data=Loader.loadedMap[url]; + this.event(/*laya.events.Event.PROGRESS*/"progress",1); + this.event(/*laya.events.Event.COMPLETE*/"complete",this._data); + return; + } + if (group)Loader.setGroup(url,group); + if (Loader.parserMap[type] !=null){ + if (((Loader.parserMap[type])instanceof laya.utils.Handler ))Loader.parserMap[type].runWith(this); + else Loader.parserMap[type].call(null,this); + return; + } + if (type==="image" || type==="htmlimage" || type==="nativeimage")return this._loadImage(url); + if (type==="sound")return this._loadSound(url); + if (!this._http){ + this._http=new HttpRequest(); + this._http.on(/*laya.events.Event.PROGRESS*/"progress",this,this.onProgress); + this._http.on(/*laya.events.Event.ERROR*/"error",this,this.onError); + this._http.on(/*laya.events.Event.COMPLETE*/"complete",this,this.onLoaded); + }; + var contentType; + switch (type){ + case "atlas": + contentType="json"; + break ; + case "font": + contentType="xml"; + break ; + default : + contentType=type; + } + this._http.send(url,null,"get",contentType); + } + + /** + *获取指定资源地址的数据类型。 + *@param url 资源地址。 + *@return 数据类型。 + */ + __proto.getTypeFromUrl=function(url){ + var type=Utils.getFileExtension(url); + if (type)return Loader.typeMap[type]; + console.log("Not recognize the resources suffix",url); + return "text"; + } + + /** + *@private + *加载图片资源。 + *@param url 资源地址。 + */ + __proto._loadImage=function(url){ + var _this=this; + var image; + function clear (){ + image.onload=null; + image.onerror=null; + }; + var onload=function (){ + clear(); + _this.onLoaded(image); + }; + var onerror=function (){ + clear(); + _this.event(/*laya.events.Event.ERROR*/"error","Load image filed"); + } + if (this._type==="nativeimage"){ + image=new Browser.window.Image(); + image.crossOrigin=""; + image.onload=onload; + image.onerror=onerror; + image.src=url; + }else { + new HTMLImage.create(url,{onload:onload,onerror:onerror,onCreate:function (img){ + image=img; + }}); + } + } + + /** + *@private + *加载声音资源。 + *@param url 资源地址。 + */ + __proto._loadSound=function(url){ + var sound=(new SoundManager._soundClass()); + var _this=this; + sound.on(/*laya.events.Event.COMPLETE*/"complete",this,soundOnload); + sound.on(/*laya.events.Event.ERROR*/"error",this,soundOnErr); + sound.load(url); + function soundOnload (){ + clear(); + _this.onLoaded(sound); + } + function soundOnErr (){ + clear(); + _this.event(/*laya.events.Event.ERROR*/"error","Load sound filed"); + } + function clear (){ + sound.offAll(); + } + } + + /**@private */ + __proto.onProgress=function(value){ + if (this._type==="atlas")this.event(/*laya.events.Event.PROGRESS*/"progress",value *0.3); + else this.event(/*laya.events.Event.PROGRESS*/"progress",value); + } + + /**@private */ + __proto.onError=function(message){ + this.event(/*laya.events.Event.ERROR*/"error",message); + } + + /** + *资源加载完成的处理函数。 + *@param data 数据。 + */ + __proto.onLoaded=function(data){ + var type=this._type; + if (type==="image"){ + var tex=new Texture(data); + tex.url=this._url; + this.complete(tex); + }else if (type==="sound" || type==="htmlimage" || type==="nativeimage"){ + this.complete(data); + }else if (type==="atlas"){ + if (!data.src){ + if (!this._data){ + this._data=data; + if (data.meta && data.meta.image){ + var toloadPics=data.meta.image.split(","); + var split=this._url.indexOf("/")>=0 ? "/" :"\\"; + var idx=this._url.lastIndexOf(split); + var folderPath=idx >=0 ? this._url.substr(0,idx+1):""; + idx=this._url.indexOf("?"); + var ver; + ver=idx >=0 ? this._url.substr(idx):""; + for (var i=0,len=toloadPics.length;i < len;i++){ + toloadPics[i]=folderPath+toloadPics[i]+ver; + } + }else { + toloadPics=[this._url.replace(".json",".png")]; + } + toloadPics.reverse(); + data.toLoads=toloadPics; + data.pics=[]; + } + this.event(/*laya.events.Event.PROGRESS*/"progress",0.3+1 / toloadPics.length *0.6); + return this._loadImage(URL.formatURL(toloadPics.pop())); + }else { + this._data.pics.push(data); + if (this._data.toLoads.length > 0){ + this.event(/*laya.events.Event.PROGRESS*/"progress",0.3+1 / this._data.toLoads.length *0.6); + return this._loadImage(URL.formatURL(this._data.toLoads.pop())); + }; + var frames=this._data.frames; + var cleanUrl=this._url.split("?")[0]; + var directory=(this._data.meta && this._data.meta.prefix)? URL.basePath+this._data.meta.prefix :cleanUrl.substring(0,cleanUrl.lastIndexOf("."))+"/"; + var pics=this._data.pics; + var map=Loader.atlasMap[this._url] || (Loader.atlasMap[this._url]=[]); + map.dir=directory; + for (var name in frames){ + var obj=frames[name]; + var tPic=pics[obj.frame.idx ? obj.frame.idx :0]; + var url=directory+name; + Loader.cacheRes(url,Texture.create(tPic,obj.frame.x,obj.frame.y,obj.frame.w,obj.frame.h,obj.spriteSourceSize.x,obj.spriteSourceSize.y,obj.sourceSize.w,obj.sourceSize.h)); + Loader.loadedMap[url].url=url; + map.push(url); + } + this.complete(this._data); + } + }else if (type=="font"){ + if (!data.src){ + this._data=data; + this.event(/*laya.events.Event.PROGRESS*/"progress",0.5); + return this._loadImage(URL.formatURL(this._url.replace(".fnt",".png"))); + }else { + var bFont; + bFont=new BitmapFont(); + bFont.parseFont(this._data,data); + var tArr=this._url.split(".fnt")[0].split("/"); + var fontName=tArr[tArr.length-1]; + Text.registerBitmapFont(fontName,bFont); + this._data=bFont; + this.complete(this._data); + } + }else { + this.complete(data); + } + } + + /** + *加载完成。 + *@param data 加载的数据。 + */ + __proto.complete=function(data){ + this._data=data; + Loader._loaders.push(this); + if (!Loader._isWorking)Loader.checkNext(); + } + + /** + *结束加载,处理是否缓存及派发完成事件 Event.COMPLETE 。 + *@param content 加载后的数据 + */ + __proto.endLoad=function(content){ + content && (this._data=content); + if (this._cache)Loader.cacheRes(this._url,this._data); + this.event(/*laya.events.Event.PROGRESS*/"progress",1); + this.event(/*laya.events.Event.COMPLETE*/"complete",(this.data instanceof Array)? [this.data] :this.data); + } + + /**加载地址。*/ + __getset(0,__proto,'url',function(){ + return this._url; + }); + + /**返回的数据。*/ + __getset(0,__proto,'data',function(){ + return this._data; + }); + + /**是否缓存。*/ + __getset(0,__proto,'cache',function(){ + return this._cache; + }); + + /**加载类型。*/ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + Loader.checkNext=function(){ + Loader._isWorking=true; + var startTimer=Browser.now(); + var thisTimer=startTimer; + while (Loader._startIndex < Loader._loaders.length){ + thisTimer=Browser.now(); + Loader._loaders[Loader._startIndex].endLoad(); + Loader._startIndex++; + if (Browser.now()-startTimer > Loader.maxTimeOut){ + console.log("loader callback cost a long time:"+(Browser.now()-startTimer)+" url="+Loader._loaders[Loader._startIndex-1].url); + Laya.timer.frameOnce(1,null,Loader.checkNext); + return; + } + } + Loader._loaders.length=0; + Loader._startIndex=0; + Loader._isWorking=false; + } + + Loader.clearRes=function(url,forceDispose){ + (forceDispose===void 0)&& (forceDispose=false); + url=URL.formatURL(url); + var arr=Loader.atlasMap[url]; + if (arr){ + for (var i=0,n=arr.length;i < n;i++){ + var resUrl=arr[i]; + var tex=Loader.getRes(resUrl); + if (tex)tex.destroy(forceDispose); + delete Loader.loadedMap[resUrl]; + } + arr.length=0; + delete Loader.atlasMap[url]; + delete Loader.loadedMap[url]; + }else { + var res=Loader.loadedMap[url]; + if (res){ + if ((res instanceof laya.resource.Texture )&& res.bitmap)(res).destroy(forceDispose); + delete Loader.loadedMap[url]; + } + } + } + + Loader.getRes=function(url){ + return Loader.loadedMap[URL.formatURL(url)]; + } + + Loader.getAtlas=function(url){ + return Loader.atlasMap[URL.formatURL(url)]; + } + + Loader.cacheRes=function(url,data){ + url=URL.formatURL(url); + if (Loader.loadedMap[url] !=null){ + console.log("Resources already exist,is repeated loading:",url); + }else { + Loader.loadedMap[url]=data; + } + } + + Loader.setGroup=function(url,group){ + if (!Loader.groupMap[group])Loader.groupMap[group]=[]; + Loader.groupMap[group].push(url); + } + + Loader.clearResByGroup=function(group){ + if (!Loader.groupMap[group])return; + var arr=Loader.groupMap[group],i=0,len=arr.length; + for (i=0;i < len;i++){ + Loader.clearRes(arr[i]); + } + arr.length=0; + } + + Loader.TEXT="text"; + Loader.JSON="json"; + Loader.XML="xml"; + Loader.BUFFER="arraybuffer"; + Loader.IMAGE="image"; + Loader.SOUND="sound"; + Loader.ATLAS="atlas"; + Loader.FONT="font"; + Loader.typeMap={"png":"image","jpg":"image","jpeg":"image","txt":"text","json":"json","xml":"xml","als":"atlas","mp3":"sound","ogg":"sound","wav":"sound","part":"json","fnt":"font"}; + Loader.parserMap={}; + Loader.loadedMap={}; + Loader.groupMap={}; + Loader.maxTimeOut=100; + Loader.atlasMap={}; + Loader._loaders=[]; + Loader._isWorking=false; + Loader._startIndex=0; + return Loader; + })(EventDispatcher) + + + /** + *

    ColorFilter 是颜色滤镜。

    + */ + //class laya.filters.ColorFilter extends laya.filters.Filter + var ColorFilter=(function(_super){ + function ColorFilter(mat){ + //this._mat=null; + //this._alpha=null; + ColorFilter.__super.call(this); + if (!mat){ + mat=[0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0,0,0,1,0]; + } + this._mat=new Float32Array(16); + this._alpha=new Float32Array(4); + var j=0; + var z=0; + for (var i=0;i < 20;i++){ + if (i % 5 !=4){ + this._mat[j++]=mat[i]; + }else { + this._alpha[z++]=mat[i]; + } + } + this._action=RunDriver.createFilterAction(0x20); + this._action.data=this; + } + + __class(ColorFilter,'laya.filters.ColorFilter',_super); + var __proto=ColorFilter.prototype; + Laya.imps(__proto,{"laya.filters.IFilter":true}) + /** + *@private 通知微端 + */ + __proto.callNative=function(sp){ + var t=sp._$P.cf=this; + sp.model && sp.model.setFilterMatrix&&sp.model.setFilterMatrix(this._mat,this._alpha); + } + + /**@private */ + __getset(0,__proto,'type',function(){ + return 0x20; + }); + + /**@private */ + __getset(0,__proto,'action',function(){ + return this._action; + }); + + __getset(1,ColorFilter,'DEFAULT',function(){ + if (!ColorFilter._DEFAULT){ + ColorFilter._DEFAULT=new ColorFilter([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]); + } + return ColorFilter._DEFAULT; + },laya.filters.Filter._$SET_DEFAULT); + + __getset(1,ColorFilter,'GRAY',function(){ + if (!ColorFilter._GRAY){ + ColorFilter._GRAY=new ColorFilter([0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0,0,0,1,0]); + } + return ColorFilter._GRAY; + },laya.filters.Filter._$SET_GRAY); + + ColorFilter._DEFAULT=null + ColorFilter._GRAY=null + return ColorFilter; + })(Filter) + + + /** + *

    LoaderManager 类用于用于批量加载资源、数据。

    + *

    批量加载器,单例,可以通过Laya.loader访问。

    + *多线程(默认5个线程),5个优先级(0最快,4最慢,默认为1) + *某个资源加载失败后,会按照最低优先级重试加载(属性retryNum决定重试几次),如果重试后失败,则调用complete函数,并返回null + */ + //class laya.net.LoaderManager extends laya.events.EventDispatcher + var LoaderManager=(function(_super){ + var ResInfo; + function LoaderManager(){ + this.retryNum=1; + this.maxLoader=5; + this._loaders=[]; + this._loaderCount=0; + this._resInfos=[]; + this._infoPool=[]; + this._maxPriority=5; + this._failRes={}; + LoaderManager.__super.call(this); + for (var i=0;i < this._maxPriority;i++)this._resInfos[i]=[]; + } + + __class(LoaderManager,'laya.net.LoaderManager',_super); + var __proto=LoaderManager.prototype; + /** + *根据clas定义创建一个资源空壳,随后进行异步加载,资源加载完成后,会调用资源类的onAsynLoaded方法回调真正的数据,套嵌资源的子资源会保留资源路径"?"后的部分 + *@param url 资源地址或者数组,比如[{url:xx,clas:xx,priority:xx},{url:xx,clas:xx,priority:xx}] + *@param progress 进度回调,回调参数为当前文件加载的进度信息(0-1)。 + *@param clas 资源类名,比如Texture + *@param type 资源类型 + *@param priority 优先级 + *@param cache 是否缓存 + *@return 返回资源对象 + */ + __proto.create=function(url,complete,progress,clas,priority,cache){ + (priority===void 0)&& (priority=1); + (cache===void 0)&& (cache=true); + if ((url instanceof Array)){ + var items=url; + var itemCount=items.length; + var loadedCount=0; + if (progress){ + var progress2=Handler.create(progress.caller,progress.method,progress.args,false); + } + for (var i=0;i < itemCount;i++){ + var item=items[i]; + if ((typeof item=='string'))item=items[i]={url:item}; + item.progress=0; + var progressHandler=progress ? Handler.create(null,onProgress,[item],false):null; + var completeHandler=(progress || complete)? Handler.create(null,onComplete,[item]):null; + this._create(item.url,completeHandler,progressHandler,item.clas || clas,item.priority || priority,cache); + } + function onComplete (item,content){ + loadedCount++; + item.progress=1; + if (loadedCount===itemCount && complete){ + complete.run(); + } + } + function onProgress (item,value){ + item.progress=value; + var num=0; + for (var j=0;j < itemCount;j++){ + var item1=items[j]; + num+=item1.progress; + }; + var v=num / itemCount; + progress2.runWith(v); + } + return true; + }else return this._create(url,complete,progress,clas,priority,cache); + } + + __proto._create=function(url,complete,progress,clas,priority,cache){ + (priority===void 0)&& (priority=1); + (cache===void 0)&& (cache=true); + var item=this.getRes(url); + if (!item){ + var extension=Utils.getFileExtension(url); + var creatItem=LoaderManager.createMap[extension]; + if (!clas)clas=creatItem[0]; + var type=creatItem[1]; + if (clas===Texture)type="htmlimage"; + item=clas ? new clas():null; + this.load(url,Handler.create(null,onLoaded),progress,type,priority,false,null,true); + function onLoaded (data){ + item && item.onAsynLoaded.call(item,url,data); + if (complete)complete.run(); + } + if (cache)LoaderManager.cacheRes(url,item); + }else { + progress && progress.runWith(1); + complete && complete.run(); + } + return item; + } + + /** + *加载资源。 + *@param url 地址,或者资源对象数组(简单数组:["a.png","b.png"],复杂数组[{url:"a.png",type:Loader.IMAGE,size:100,priority:1},{url:"b.json",type:Loader.JSON,size:50,priority:1}])。 + *@param complete 结束回调,如果加载失败,则返回 null 。 + *@param progress 进度回调,回调参数为当前文件加载的进度信息(0-1)。 + *@param type 资源类型。 + *@param priority 优先级,0-4,五个优先级,0优先级最高,默认为1。 + *@param cache 是否缓存加载结果。 + *@param group 分组。 + *@param ignoreCache 是否忽略缓存,强制重新加载 + *@return 此 LoaderManager 对象。 + */ + __proto.load=function(url,complete,progress,type,priority,cache,group,ignoreCache){ + (priority===void 0)&& (priority=1); + (cache===void 0)&& (cache=true); + (ignoreCache===void 0)&& (ignoreCache=false); + if ((url instanceof Array))return this._loadAssets(url,complete,progress,type,priority,cache,group); + url=URL.formatURL(url); + var content=Loader.getRes(url); + if (content !=null){ + progress && progress.runWith(1); + complete && complete.runWith(content); + this._loaderCount || this.event(/*laya.events.Event.COMPLETE*/"complete"); + }else { + var info=LoaderManager._resMap[url]; + if (!info){ + info=this._infoPool.length ? this._infoPool.pop():new ResInfo(); + info.url=url; + info.type=type; + info.cache=cache; + info.group=group; + info.ignoreCache=ignoreCache; + complete && info.on(/*laya.events.Event.COMPLETE*/"complete",complete.caller,complete.method,complete.args); + progress && info.on(/*laya.events.Event.PROGRESS*/"progress",progress.caller,progress.method,progress.args); + LoaderManager._resMap[url]=info; + priority=priority < this._maxPriority ? priority :this._maxPriority-1; + this._resInfos[priority].push(info); + this._next(); + }else { + complete && info._createListener(/*laya.events.Event.COMPLETE*/"complete",complete.caller,complete.method,complete.args,false,false); + progress && info._createListener(/*laya.events.Event.PROGRESS*/"progress",progress.caller,progress.method,progress.args,false,false); + } + } + return this; + } + + __proto._next=function(){ + if (this._loaderCount >=this.maxLoader)return; + for (var i=0;i < this._maxPriority;i++){ + var infos=this._resInfos[i]; + if (infos.length > 0){ + var info=infos.shift(); + if (info)return this._doLoad(info); + } + } + this._loaderCount || this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + + __proto._doLoad=function(resInfo){ + this._loaderCount++; + var loader=this._loaders.length ? this._loaders.pop():new Loader(); + loader.on(/*laya.events.Event.COMPLETE*/"complete",null,onLoaded); + loader.on(/*laya.events.Event.PROGRESS*/"progress",null,function(num){ + resInfo.event(/*laya.events.Event.PROGRESS*/"progress",num); + }); + loader.on(/*laya.events.Event.ERROR*/"error",null,function(msg){ + onLoaded(null); + }); + var _this=this; + function onLoaded (data){ + loader.offAll(); + loader._data=null; + _this._loaders.push(loader); + _this._endLoad(resInfo,(data instanceof Array)? [data] :data); + _this._loaderCount--; + _this._next(); + } + loader.load(resInfo.url,resInfo.type,resInfo.cache,resInfo.group,resInfo.ignoreCache); + } + + __proto._endLoad=function(resInfo,content){ + if (content===null){ + var errorCount=this._failRes[resInfo.url] || 0; + if (errorCount < this.retryNum){ + console.log("[warn]Retry to load:",resInfo.url); + this._failRes[resInfo.url]=errorCount+1; + this._resInfos[this._maxPriority-1].push(resInfo); + return; + }else { + console.log("[error]Failed to load:",resInfo.url); + this.event(/*laya.events.Event.ERROR*/"error",resInfo.url); + } + } + delete LoaderManager._resMap[resInfo.url]; + resInfo.event(/*laya.events.Event.COMPLETE*/"complete",content); + resInfo.offAll(); + this._infoPool.push(resInfo); + } + + /** + *清理指定资源地址缓存。 + *@param url 资源地址。 + *@param forceDispose 是否强制销毁,有些资源是采用引用计数方式销毁,如果forceDispose=true,则忽略引用计数,直接销毁,比如Texture,默认为false + */ + __proto.clearRes=function(url,forceDispose){ + (forceDispose===void 0)&& (forceDispose=false); + Loader.clearRes(url,forceDispose); + } + + /** + *获取指定资源地址的资源。 + *@param url 资源地址。 + *@return 返回资源。 + */ + __proto.getRes=function(url){ + return Loader.getRes(url); + } + + /**清理当前未完成的加载,所有未加载的内容全部停止加载。*/ + __proto.clearUnLoaded=function(){ + for (var i=0;i < this._maxPriority;i++){ + var infos=this._resInfos[i]; + for (var j=infos.length-1;j >-1;j--){ + var info=infos[j]; + if (info){ + info.offAll(); + this._infoPool.push(info); + } + } + infos.length=0; + } + this._loaderCount=0; + LoaderManager._resMap={}; + } + + /** + *根据地址集合清理掉未加载的内容 + *@param urls 资源地址集合 + */ + __proto.cancelLoadByUrls=function(urls){ + if (!urls)return; + for (var i=0,n=urls.length;i < n;i++){ + this.cancelLoadByUrl(urls[i]); + } + } + + /** + *根据地址清理掉未加载的内容 + *@param url 资源地址 + */ + __proto.cancelLoadByUrl=function(url){ + url=URL.formatURL(url); + for (var i=0;i < this._maxPriority;i++){ + var infos=this._resInfos[i]; + for (var j=infos.length-1;j >-1;j--){ + var info=infos[j]; + if (info && info.url===url){ + infos[j]=null; + info.offAll(); + this._infoPool.push(info); + } + } + } + if (LoaderManager._resMap[url])delete LoaderManager._resMap[url]; + } + + /** + *@private + *加载数组里面的资源。 + *@param arr 简单:["a.png","b.png"],复杂[{url:"a.png",type:Loader.IMAGE,size:100,priority:1},{url:"b.json",type:Loader.JSON,size:50,priority:1}]*/ + __proto._loadAssets=function(arr,complete,progress,type,priority,cache,group){ + (priority===void 0)&& (priority=1); + (cache===void 0)&& (cache=true); + var itemCount=arr.length; + var loadedCount=0; + var totalSize=0; + var items=[]; + var defaultType=type || /*laya.net.Loader.IMAGE*/"image"; + for (var i=0;i < itemCount;i++){ + var item=arr[i]; + if ((typeof item=='string'))item={url:item,type:defaultType,size:1,priority:priority}; + if (!item.size)item.size=1; + item.progress=0; + totalSize+=item.size; + items.push(item); + var progressHandler=progress ? Handler.create(null,loadProgress,[item],false):null; + var completeHandler=(complete || progress)? Handler.create(null,loadComplete,[item]):null; + this.load(item.url,completeHandler,progressHandler,item.type,item.priority || 1,cache,item.group || group); + } + function loadComplete (item,content){ + loadedCount++; + item.progress=1; + if (loadedCount===itemCount && complete){ + complete.run(); + } + } + function loadProgress (item,value){ + if (progress !=null){ + item.progress=value; + var num=0; + for (var j=0;j < items.length;j++){ + var item1=items[j]; + num+=item1.size *item1.progress; + }; + var v=num / totalSize; + progress.runWith(v); + } + } + return this; + } + + LoaderManager.cacheRes=function(url,data){ + Loader.cacheRes(url,data); + } + + LoaderManager._resMap={}; + __static(LoaderManager, + ['createMap',function(){return this.createMap={atlas:[null,/*laya.net.Loader.ATLAS*/"atlas"]};} + ]); + LoaderManager.__init$=function(){ + //class ResInfo extends laya.events.EventDispatcher + ResInfo=(function(_super){ + function ResInfo(){ + this.url=null; + this.type=null; + this.cache=false; + this.group=null; + this.ignoreCache=false; + ResInfo.__super.call(this); + } + __class(ResInfo,'',_super); + return ResInfo; + })(EventDispatcher) + } + + return LoaderManager; + })(EventDispatcher) + + + /** + *Socket 是一种双向通信协议,在建立连接后,服务器和 Browser/Client Agent 都能主动的向对方发送或接收数据。 + */ + //class laya.net.Socket extends laya.events.EventDispatcher + var Socket=(function(_super){ + function Socket(host,port,byteClass){ + this._endian=null; + this._stamp=NaN; + this._socket=null; + this._connected=false; + this._addInputPosition=0; + this._input=null; + this._output=null; + this.timeout=0; + this.objectEncoding=0; + this.disableInput=false; + this._byteClass=null; + (port===void 0)&& (port=0); + Socket.__super.call(this); + this._byteClass=byteClass; + this._byteClass=this._byteClass ? this._byteClass :Byte; + this.endian="bigEndian"; + this.timeout=20000; + this._addInputPosition=0; + if (host&&port > 0 && port < 65535) + this.connect(host,port); + } + + __class(Socket,'laya.net.Socket',_super); + var __proto=Socket.prototype; + /** + *连接到指定的主机和端口。 + *@param host 服务器地址。 + *@param port 服务器端口。 + */ + __proto.connect=function(host,port){ + var url="ws://"+host+":"+port; + this.connectByUrl(url); + } + + /** + *连接到指定的url + *@param url 连接目标 + */ + __proto.connectByUrl=function(url){ + var _$this=this; + if (this._socket !=null) + this.close(); + this._socket && this._cleanSocket(); + this._socket=new Browser.window.WebSocket(url); + this._socket.binaryType="arraybuffer"; + this._output=new this._byteClass(); + this._output.endian=this.endian; + this._input=new this._byteClass(); + this._input.endian=this.endian; + this._addInputPosition=0; + this._socket.onopen=function (e){ + _$this._onOpen(e); + }; + this._socket.onmessage=function (msg){ + _$this._onMessage(msg); + }; + this._socket.onclose=function (e){ + _$this._onClose(e); + }; + this._socket.onerror=function (e){ + _$this._onError(e); + }; + } + + __proto._cleanSocket=function(){ + try { + this._socket.close(); + }catch (e){} + this._connected=false; + this._socket.onopen=null; + this._socket.onmessage=null; + this._socket.onclose=null; + this._socket.onerror=null; + this._socket=null; + } + + /** + *关闭连接。 + */ + __proto.close=function(){ + if (this._socket !=null){ + this._cleanSocket(); + } + } + + /** + *@private + *连接建立成功 。 + */ + __proto._onOpen=function(e){ + this._connected=true; + this.event(/*laya.events.Event.OPEN*/"open",e); + } + + /** + *@private + *接收到数据处理方法。 + *@param msg 数据。 + */ + __proto._onMessage=function(msg){ + if (!msg || !msg.data)return; + var data=msg.data; + if(this.disableInput&&data){ + this.event(/*laya.events.Event.MESSAGE*/"message",data); + return; + } + if (this._input.length > 0 && this._input.bytesAvailable < 1){ + this._input.clear(); + this._addInputPosition=0; + }; + var pre=this._input.pos; + !this._addInputPosition && (this._addInputPosition=0); + this._input.pos=this._addInputPosition; + if (data){ + if ((typeof data=='string')){ + this._input.writeUTFBytes(data); + }else { + this._input.writeArrayBuffer(data); + } + this._addInputPosition=this._input.pos; + this._input.pos=pre; + } + this.event(/*laya.events.Event.MESSAGE*/"message",data); + } + + /** + *@private + *连接被关闭处理方法。 + */ + __proto._onClose=function(e){ + this._connected=false; + this.event(/*laya.events.Event.CLOSE*/"close",e) + } + + /** + *@private + *出现异常处理方法。 + */ + __proto._onError=function(e){ + this.event(/*laya.events.Event.ERROR*/"error",e) + } + + /** + *发送数据到服务器。 + *@param data 需要发送的数据,可以是String或者ArrayBuffer。 + */ + __proto.send=function(data){ + this._socket.send(data); + } + + /** + *发送缓冲区中的数据到服务器。 + */ + __proto.flush=function(){ + if (this._output && this._output.length > 0){ + var evt; + try { + this._socket && this._socket.send(this._output.__getBuffer().slice(0,this._output.length)); + }catch (e){ + evt=e; + } + this._output.endian=this.endian; + this._output.clear(); + if(evt)this.event(/*laya.events.Event.ERROR*/"error",evt); + } + } + + /** + *表示服务端发来的数据。 + */ + __getset(0,__proto,'input',function(){ + return this._input; + }); + + /** + *表示需要发送至服务端的缓冲区中的数据。 + */ + __getset(0,__proto,'output',function(){ + return this._output; + }); + + /** + *表示此 Socket 对象目前是否已连接。 + */ + __getset(0,__proto,'connected',function(){ + return this._connected; + }); + + /** + *表示数据的字节顺序。 + */ + __getset(0,__proto,'endian',function(){ + return this._endian; + },function(value){ + this._endian=value; + if (this._input !=null)this._input.endian=value; + if (this._output !=null)this._output.endian=value; + }); + + Socket.LITTLE_ENDIAN="littleEndian"; + Socket.BIG_ENDIAN="bigEndian"; + return Socket; + })(EventDispatcher) + + + /** + *Resource 资源存取类。 + */ + //class laya.resource.Resource extends laya.events.EventDispatcher + var Resource=(function(_super){ + function Resource(){ + this._id=0; + this._lastUseFrameCount=0; + this._memorySize=0; + this._name=null; + this._loaded=false; + this._released=false; + this._resourceManager=null; + this.lock=false; + Resource.__super.call(this); + this._$1__id=++Resource._uniqueIDCounter; + Resource._loadedResources.push(this); + Resource._isLoadedResourcesSorted=false; + this._released=true; + this.lock=false; + this._memorySize=0; + this._lastUseFrameCount=-1; + (ResourceManager.currentResourceManager)&& (ResourceManager.currentResourceManager.addResource(this)); + } + + __class(Resource,'laya.resource.Resource',_super); + var __proto=Resource.prototype; + Laya.imps(__proto,{"laya.resource.ICreateResource":true,"laya.resource.IDispose":true}) + /**重新创建资源。override it,同时修改memorySize属性、处理startCreate()和compoleteCreate()方法。*/ + __proto.recreateResource=function(){ + this.startCreate(); + this.completeCreate(); + } + + /**销毁资源,override it,同时修改memorySize属性。*/ + __proto.detoryResource=function(){} + /** + *激活资源,使用资源前应先调用此函数激活。 + *@param force 是否强制创建。 + */ + __proto.activeResource=function(force){ + (force===void 0)&& (force=false); + this._lastUseFrameCount=Stat.loopCount; + if (this._released || force){ + this.recreateResource(); + } + } + + /** + *释放资源。 + *@param force 是否强制释放。 + *@return 是否成功释放。 + */ + __proto.releaseResource=function(force){ + (force===void 0)&& (force=false); + if (!force && this.lock) + return false; + if (!this._released || force){ + this.detoryResource(); + this._released=true; + this._lastUseFrameCount=-1; + this.event(/*laya.events.Event.RELEASED*/"released",this); + return true; + }else { + return false; + } + } + + /** + *设置唯一名字,如果名字重复则自动加上“-copy”。 + *@param newName 名字。 + */ + __proto.setUniqueName=function(newName){ + var isUnique=true; + for (var i=0;i < Resource._loadedResources.length;i++){ + if (Resource._loadedResources[i]._name!==newName || Resource._loadedResources[i]===this) + continue ; + isUnique=false; + return; + } + if (isUnique){ + if (this.name !=newName){ + this.name=newName; + Resource._isLoadedResourcesSorted=false; + } + }else{ + this.setUniqueName(newName.concat("-copy")); + } + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + throw new Error("Resource: must override this function!"); + } + + /** + *

    彻底清理资源。

    + *

    注意:会强制解锁清理。

    + */ + __proto.dispose=function(){ + if (this._resourceManager!==null) + throw new Error("附属于resourceManager的资源不能独立释放!"); + this.lock=false; + this.releaseResource(); + var index=Resource._loadedResources.indexOf(this); + if (index!==-1){ + Resource._loadedResources.splice(index,1); + Resource._isLoadedResourcesSorted=false; + } + } + + /**开始资源激活。*/ + __proto.startCreate=function(){ + this.event(/*laya.events.Event.RECOVERING*/"recovering",this); + } + + /**完成资源激活。*/ + __proto.completeCreate=function(){ + this._released=false; + this.event(/*laya.events.Event.RECOVERED*/"recovered",this); + } + + __getset(0,__proto,'loaded',function(){ + return this._loaded; + }); + + /** + *获取唯一标识ID(通常用于优化或识别)。 + */ + __getset(0,__proto,'id',function(){ + return this._$1__id; + }); + + /** + *是否已释放。 + */ + __getset(0,__proto,'released',function(){ + return this._released; + }); + + /** + *设置名字 + */ + /** + *获取名字。 + */ + __getset(0,__proto,'name',function(){ + return this._name; + },function(value){ + if ((value || value!=="")&& this.name!==value){ + this._name=value; + Resource._isLoadedResourcesSorted=false; + } + }); + + /** + *距离上次使用帧率。 + */ + __getset(0,__proto,'lastUseFrameCount',function(){ + return this._lastUseFrameCount; + }); + + /** + *资源管理员。 + */ + __getset(0,__proto,'resourceManager',function(){ + return this._resourceManager; + }); + + /** + *占用内存尺寸。 + */ + __getset(0,__proto,'memorySize',function(){ + return this._memorySize; + },function(value){ + var offsetValue=value-this._memorySize; + this._memorySize=value; + this.resourceManager && this.resourceManager.addSize(offsetValue); + }); + + /** + *本类型排序后的已载入资源。 + */ + __getset(1,Resource,'sortedLoadedResourcesByName',function(){ + if (!Resource._isLoadedResourcesSorted){ + Resource._isLoadedResourcesSorted=true; + Resource._loadedResources.sort(Resource.compareResourcesByName); + } + return Resource._loadedResources; + },laya.events.EventDispatcher._$SET_sortedLoadedResourcesByName); + + Resource.getLoadedResourceByIndex=function(index){ + return Resource._loadedResources[index]; + } + + Resource.getLoadedResourcesCount=function(){ + return Resource._loadedResources.length; + } + + Resource.compareResourcesByName=function(left,right){ + if (left===right) + return 0; + var x=left.name; + var y=right.name; + if (x===null){ + if (y===null) + return 0; + else + return-1; + }else { + if (y==null) + return 1; + else { + var retval=x.localeCompare(y); + if (retval !=0) + return retval; + else { + right.setUniqueName(y); + y=right.name; + return x.localeCompare(y); + } + } + } + } + + Resource._uniqueIDCounter=0; + Resource._loadedResources=[]; + Resource._isLoadedResourcesSorted=false; + return Resource; + })(EventDispatcher) + + + /** + *Texture 是一个纹理处理类。 + */ + //class laya.resource.Texture extends laya.events.EventDispatcher + var Texture=(function(_super){ + function Texture(bitmap,uv){ + //this.bitmap=null; + //this.uv=null; + this.offsetX=0; + this.offsetY=0; + this.sourceWidth=0; + this.sourceHeight=0; + //this._loaded=false; + this._w=0; + this._h=0; + //this.$_GID=NaN; + //this.url=null; + this._uvID=0; + Texture.__super.call(this); + if (bitmap){ + bitmap.useNum++; + } + this.setTo(bitmap,uv); + } + + __class(Texture,'laya.resource.Texture',_super); + var __proto=Texture.prototype; + /** + *设置此对象的位图资源、UV数据信息。 + *@param bitmap 位图资源 + *@param uv UV数据信息 + */ + __proto.setTo=function(bitmap,uv){ + this.bitmap=bitmap; + this.uv=uv || Texture.DEF_UV; + if (bitmap){ + this._w=bitmap.width; + this._h=bitmap.height; + this.sourceWidth=this.sourceWidth || this._w; + this.sourceHeight=this.sourceHeight || this._h + this._loaded=this._w > 0; + var _this=this; + if (this._loaded){ + RunDriver.addToAtlas && RunDriver.addToAtlas(_this); + }else { + var bm=bitmap; + if ((bm instanceof laya.resource.HTMLImage )&& bm.image) + bm.image.addEventListener('load',function(e){ + RunDriver.addToAtlas && RunDriver.addToAtlas(_this); + },false); + } + } + } + + /**@private 激活资源。*/ + __proto.active=function(){ + this.bitmap.activeResource(); + } + + /** + *销毁纹理(分直接销毁,跟计数销毁两种) + *@param forceDispose true为强制销毁主纹理,false是通过计数销毁纹理 + */ + __proto.destroy=function(forceDispose){ + (forceDispose===void 0)&& (forceDispose=false); + if (this.bitmap && (this.bitmap).useNum > 0){ + if (forceDispose){ + this.bitmap.dispose(); + (this.bitmap).useNum=0; + }else { + (this.bitmap).useNum--; + if ((this.bitmap).useNum==0){ + this.bitmap.dispose(); + } + } + this.bitmap=null; + if (this.url && this===Laya.loader.getRes(this.url))Laya.loader.clearRes(this.url); + this._loaded=false; + } + } + + /** + *加载指定地址的图片。 + *@param url 图片地址。 + */ + __proto.load=function(url){ + var _$this=this; + this._loaded=false; + var fileBitmap=(this.bitmap || (this.bitmap=HTMLImage.create(URL.formatURL(url)))); + if (fileBitmap)fileBitmap.useNum++; + var _this=this; + fileBitmap.onload=function (){ + fileBitmap.onload=null; + _this._loaded=true; + _$this.sourceWidth=_$this._w=fileBitmap.width; + _$this.sourceHeight=_$this._h=fileBitmap.height; + _this.event(/*laya.events.Event.LOADED*/"loaded",this); + (RunDriver.addToAtlas)&& (RunDriver.addToAtlas(_this)); + }; + } + + /**@private */ + __proto.addTextureToAtlas=function(e){ + RunDriver.addTextureToAtlas(this); + } + + /** + *获取Texture上的某个区域的像素点 + *@param x + *@param y + *@param width + *@param height + *@return 返回像素点集合 + */ + __proto.getPixels=function(x,y,width,height){ + if (Render.isWebGL){ + return RunDriver.getTexturePixels(this,x,y,width,height); + }else { + Browser.canvas.size(width,height); + Browser.canvas.clear(); + Browser.context.drawTexture(this,-x,-y,this.width,this.height,0,0); + var info=Browser.context.getImageData(0,0,width,height); + } + return info.data; + } + + /**@private */ + __proto.onAsynLoaded=function(url,bitmap){ + if (bitmap)bitmap.useNum++; + this.setTo(bitmap,this.uv); + } + + /**激活并获取资源。*/ + __getset(0,__proto,'source',function(){ + this.bitmap.activeResource(); + return this.bitmap.source; + }); + + /** + *表示是否加载成功,只能表示初次载入成功(通常包含下载和载入),并不能完全表示资源是否可立即使用(资源管理机制释放影响等)。 + */ + __getset(0,__proto,'loaded',function(){ + return this._loaded; + }); + + /** + *表示资源是否已释放。 + */ + __getset(0,__proto,'released',function(){ + return this.bitmap.released; + }); + + /**实际宽度。*/ + __getset(0,__proto,'width',function(){ + if (this._w)return this._w; + return (this.uv && this.uv!==Texture.DEF_UV)? (this.uv[2]-this.uv[0])*this.bitmap.width :this.bitmap.width; + },function(value){ + this._w=value; + this.sourceWidth || (this.sourceWidth=value); + }); + + /** + *通过外部设置是否启用纹理平铺(后面要改成在着色器里计算) + */ + /** + *获取当前纹理是否启用了纹理平铺 + */ + __getset(0,__proto,'repeat',function(){ + if (Render.isWebGL && this.bitmap){ + return this.bitmap.repeat; + } + return true; + },function(value){ + if (value){ + if (Render.isWebGL && this.bitmap){ + this.bitmap.repeat=value; + if (value){ + this.bitmap.enableMerageInAtlas=false; + } + } + } + }); + + /**实际高度。*/ + __getset(0,__proto,'height',function(){ + if (this._h)return this._h; + return (this.uv && this.uv!==Texture.DEF_UV)? (this.uv[5]-this.uv[1])*this.bitmap.height :this.bitmap.height; + },function(value){ + this._h=value; + this.sourceHeight || (this.sourceHeight=value); + }); + + /** + *设置线性采样的状态(目前只能第一次绘制前设置false生效,来关闭线性采样) + */ + /** + *获取当前纹理是否启用了线性采样 + */ + __getset(0,__proto,'isLinearSampling',function(){ + return Render.isWebGL ? (this.bitmap.minFifter !=0x2600):true; + },function(value){ + if (!value && Render.isWebGL){ + if (!value && (this.bitmap.minFifter==-1)&& (this.bitmap.magFifter==-1)){ + this.bitmap.minFifter=0x2600; + this.bitmap.magFifter=0x2600; + this.bitmap.enableMerageInAtlas=false; + } + } + }); + + Texture.moveUV=function(offsetX,offsetY,uv){ + for (var i=0;i < 8;i+=2){ + uv[i]+=offsetX; + uv[i+1]+=offsetY; + } + return uv; + } + + Texture.create=function(source,x,y,width,height,offsetX,offsetY,sourceWidth,sourceHeight){ + (offsetX===void 0)&& (offsetX=0); + (offsetY===void 0)&& (offsetY=0); + (sourceWidth===void 0)&& (sourceWidth=0); + (sourceHeight===void 0)&& (sourceHeight=0); + var btex=(source instanceof laya.resource.Texture ); + var uv=btex ? source.uv :Texture.DEF_UV; + var bitmap=btex ? source.bitmap :source; + var tex=new Texture(bitmap,null); + tex.width=width; + tex.height=height; + tex.offsetX=offsetX; + tex.offsetY=offsetY; + tex.sourceWidth=sourceWidth || width; + tex.sourceHeight=sourceHeight || height; + var dwidth=1 / bitmap.width; + var dheight=1 / bitmap.height; + x *=dwidth; + y *=dheight; + width *=dwidth; + height *=dheight; + var u1=tex.uv[0],v1=tex.uv[1],u2=tex.uv[4],v2=tex.uv[5]; + var inAltasUVWidth=(u2-u1),inAltasUVHeight=(v2-v1); + var oriUV=Texture.moveUV(uv[0],uv[1],[x,y,x+width,y,x+width,y+height,x,y+height]); + tex.uv=[u1+oriUV[0] *inAltasUVWidth,v1+oriUV[1] *inAltasUVHeight,u2-(1-oriUV[2])*inAltasUVWidth,v1+oriUV[3] *inAltasUVHeight,u2-(1-oriUV[4])*inAltasUVWidth,v2-(1-oriUV[5])*inAltasUVHeight,u1+oriUV[6] *inAltasUVWidth,v2-(1-oriUV[7])*inAltasUVHeight]; + return tex; + } + + Texture.createFromTexture=function(texture,x,y,width,height){ + var rect=Rectangle.TEMP.setTo(x-texture.offsetX,y-texture.offsetY,width,height); + var result=rect.intersection(Texture._rect1.setTo(0,0,texture.width,texture.height),Texture._rect2); + if (result) + var tex=Texture.create(texture,result.x,result.y,result.width,result.height,result.x-rect.x,result.y-rect.y,width,height); + else return null; + tex.bitmap.useNum--; + return tex; + } + + Texture.DEF_UV=[0,0,1.0,0,1.0,1.0,0,1.0]; + Texture.INV_UV=[0,1,1.0,1,1.0,0.0,0,0.0]; + Texture._rect1=new Rectangle(); + Texture._rect2=new Rectangle(); + return Texture; + })(EventDispatcher) + + + /** + *TimeLine 是一个用来创建时间轴动画的类。 + */ + //class laya.utils.TimeLine extends laya.events.EventDispatcher + var TimeLine=(function(_super){ + var tweenData; + function TimeLine(){ + this._labelDic=null; + this._tweenDic={}; + this._tweenDataList=[]; + this._endTweenDataList=null; + this._currTime=0; + this._lastTime=0; + this._startTime=0; + this._index=0; + this._gidIndex=0; + this._firstTweenDic={}; + this._startTimeSort=false; + this._endTimeSort=false; + this._loopKey=false; + this.scale=1; + this._frameRate=60; + this._frameIndex=0; + this._total=0; + TimeLine.__super.call(this); + } + + __class(TimeLine,'laya.utils.TimeLine',_super); + var __proto=TimeLine.prototype; + /** + *控制一个对象,从当前点移动到目标点。 + *@param target 要控制的对象。 + *@param props 要控制对象的属性。 + *@param duration 对象TWEEN的时间。 + *@param ease 缓动类型 + *@param offset 相对于上一个对象,偏移多长时间(单位:毫秒)。 + */ + __proto.to=function(target,props,duration,ease,offset){ + (offset===void 0)&& (offset=0); + return this._create(target,props,duration,ease,offset,true); + } + + /** + *从 props 属性,缓动到当前状态。 + *@param target target 目标对象(即将更改属性值的对象) + *@param props 要控制对象的属性 + *@param duration 对象TWEEN的时间 + *@param ease 缓动类型 + *@param offset 相对于上一个对象,偏移多长时间(单位:毫秒) + */ + __proto.from=function(target,props,duration,ease,offset){ + (offset===void 0)&& (offset=0); + return this._create(target,props,duration,ease,offset,false); + } + + /**@private */ + __proto._create=function(target,props,duration,ease,offset,isTo){ + var tTweenData=new tweenData(); + tTweenData.isTo=isTo; + tTweenData.type=0; + tTweenData.target=target; + tTweenData.duration=duration; + tTweenData.data=props; + tTweenData.startTime=this._startTime+offset; + tTweenData.endTime=tTweenData.startTime+tTweenData.duration; + tTweenData.ease=ease; + this._startTime=Math.max(tTweenData.endTime,this._startTime); + this._tweenDataList.push(tTweenData); + this._startTimeSort=true; + this._endTimeSort=true; + return this; + } + + /** + *在时间队列中加入一个标签。 + *@param label 标签名称。 + *@param offset 标签相对于上个动画的偏移时间(单位:毫秒)。 + */ + __proto.addLabel=function(label,offset){ + var tTweenData=new tweenData(); + tTweenData.type=1; + tTweenData.data=label; + tTweenData.endTime=tTweenData.startTime=this._startTime+offset; + this._labelDic || (this._labelDic={}); + this._labelDic[label]=tTweenData; + this._tweenDataList.push(tTweenData); + return this; + } + + /** + *移除指定的标签 + *@param label + */ + __proto.removeLabel=function(label){ + if (this._labelDic && this._labelDic[label]){ + var tTweenData=this._labelDic[label]; + if (tTweenData){ + var tIndex=this._tweenDataList.indexOf(tTweenData); + if (tIndex >-1){ + this._tweenDataList.splice(tIndex,1); + } + } + delete this._labelDic[label]; + } + } + + /** + *动画从整个动画的某一时间开始。 + *@param time(单位:毫秒)。 + */ + __proto.gotoTime=function(time){ + if (this._tweenDataList==null || this._tweenDataList.length==0)return; + var tTween; + var tObject; + for (var p in this._firstTweenDic){ + tObject=this._firstTweenDic[p]; + if (tObject){ + for (var tDataP in tObject){ + if (tObject.diyTarget.hasOwnProperty(tDataP)){ + tObject.diyTarget[tDataP]=tObject[tDataP]; + } + } + } + } + for (p in this._tweenDic){ + tTween=this._tweenDic[p]; + tTween.clear(); + delete this._tweenDic[p]; + } + this._index=0; + this._gidIndex=0; + this._currTime=time; + this._lastTime=Browser.now(); + var tTweenDataCopyList; + if (this._endTweenDataList==null || this._endTimeSort){ + this._endTimeSort=false; + this._endTweenDataList=tTweenDataCopyList=this._tweenDataList.concat(); + function Compare (paraA,paraB){ + if (paraA.endTime > paraB.endTime){ + return 1; + }else if (paraA.endTime < paraB.endTime){ + return-1; + }else { + return 0; + } + } + tTweenDataCopyList.sort(Compare); + }else { + tTweenDataCopyList=this._endTweenDataList + }; + var tTweenData; + for (var i=0,n=tTweenDataCopyList.length;i < n;i++){ + tTweenData=tTweenDataCopyList[i]; + if (tTweenData.type==0){ + if (time >=tTweenData.endTime){ + this._index=Math.max(this._index,i+1); + var props=tTweenData.data; + for (var tP in props){ + if (tTweenData.isTo){ + tTweenData.target[tP]=props[tP]; + } + } + }else { + break ; + } + } + } + for (i=0,n=this._tweenDataList.length;i < n;i++){ + tTweenData=this._tweenDataList[i]; + if (tTweenData.type==0){ + if (time >=tTweenData.startTime && time < tTweenData.endTime){ + this._index=Math.max(this._index,i+1); + this._gidIndex++; + tTween=Pool.getItemByClass("tween",Tween); + tTween._create(tTweenData.target,tTweenData.data,tTweenData.duration,tTweenData.ease,Handler.create(this,this._animComplete,[this._gidIndex]),0,false,tTweenData.isTo,true,false); + tTween.setStartTime(this._currTime-(time-tTweenData.startTime)); + tTween._updateEase(this._currTime); + tTween.gid=this._gidIndex; + this._tweenDic[this._gidIndex]=tTween; + } + } + } + } + + /** + *从指定的标签开始播。 + *@param Label 标签名。 + */ + __proto.gotoLabel=function(Label){ + if (this._labelDic==null)return; + var tLabelData=this._labelDic[Label]; + if (tLabelData)this.gotoTime(tLabelData.startTime); + } + + /** + *暂停整个动画。 + */ + __proto.pause=function(){ + Laya.timer.clear(this,this._update); + } + + /** + *恢复暂停动画的播放。 + */ + __proto.resume=function(){ + this.play(this._currTime,this._loopKey); + } + + /** + *播放动画。 + *@param timeOrLabel 开启播放的时间点或标签名。 + *@param loop 是否循环播放。 + */ + __proto.play=function(timeOrLabel,loop){ + (timeOrLabel===void 0)&& (timeOrLabel=0); + (loop===void 0)&& (loop=false); + if (this._startTimeSort){ + this._startTimeSort=false; + function Compare (paraA,paraB){ + if (paraA.startTime > paraB.startTime){ + return 1; + }else if (paraA.startTime < paraB.startTime){ + return-1; + }else { + return 0; + } + } + this._tweenDataList.sort(Compare); + for (var i=0,n=this._tweenDataList.length;i < n;i++){ + var tTweenData=this._tweenDataList[i]; + if (tTweenData !=null && tTweenData.type==0){ + var tTarget=tTweenData.target; + var gid=(tTarget.$_GID || (tTarget.$_GID=Utils.getGID())); + var tSrcData=null; + if (this._firstTweenDic[gid]==null){ + tSrcData={}; + tSrcData.diyTarget=tTarget; + this._firstTweenDic[gid]=tSrcData; + }else { + tSrcData=this._firstTweenDic[gid]; + } + for (var p in tTweenData.data){ + if (tSrcData[p]==null){ + tSrcData[p]=tTarget[p]; + } + } + } + } + } + if ((typeof timeOrLabel=='string')){ + this.gotoLabel(timeOrLabel); + }else { + this.gotoTime(timeOrLabel); + } + this._loopKey=loop; + this._lastTime=Browser.now(); + Laya.timer.frameLoop(1,this,this._update); + } + + /** + *更新当前动画。 + */ + __proto._update=function(){ + if (this._currTime >=this._startTime){ + if (this._loopKey){ + this._complete(); + this.gotoTime(0); + }else { + this._complete(); + this.pause(); + return; + } + }; + var tNow=Browser.now(); + var tFrameTime=tNow-this._lastTime; + var tCurrTime=this._currTime+=tFrameTime *this.scale; + this._lastTime=tNow; + var tTween; + if (this._tweenDataList.length !=0 && this._index < this._tweenDataList.length){ + var tTweenData=this._tweenDataList[this._index]; + if (tCurrTime >=tTweenData.startTime){ + this._index++; + if (tTweenData.type==0){ + this._gidIndex++; + tTween=Pool.getItemByClass("tween",Tween); + tTween._create(tTweenData.target,tTweenData.data,tTweenData.duration,tTweenData.ease,new Handler(this,this._animComplete,[this._gidIndex]),0,false,tTweenData.isTo,true,false); + tTween.setStartTime(tCurrTime); + tTween.gid=this._gidIndex; + this._tweenDic[this._gidIndex]=tTween; + }else { + this.event(/*laya.events.Event.LABEL*/"label",tTweenData.data); + } + } + } + for (var p in this._tweenDic){ + tTween=this._tweenDic[p]; + tTween._updateEase(tCurrTime); + } + } + + /** + *指定的动画索引处的动画播放完成后,把此动画从列表中删除。 + *@param index + */ + __proto._animComplete=function(index){ + var tTween=this._tweenDic[index]; + if (tTween)delete this._tweenDic[index]; + } + + /**@private */ + __proto._complete=function(){ + this.event(/*laya.events.Event.COMPLETE*/"complete"); + } + + /** + *重置所有对象,复用对象的时候使用。 + */ + __proto.reset=function(){ + var p; + if (this._labelDic){ + for (p in this._labelDic){ + delete this._labelDic[p]; + } + }; + var tTween; + for (p in this._tweenDic){ + tTween=this._tweenDic[p]; + tTween.clear(); + delete this._tweenDic[p]; + } + for (p in this._firstTweenDic){ + delete this._firstTweenDic[p]; + } + this._endTweenDataList=null; + this._tweenDataList.length=0; + this._currTime=0; + this._lastTime=0; + this._startTime=0; + this._index=0; + this._gidIndex=0; + this.scale=1; + Laya.timer.clear(this,this._update); + } + + /** + *彻底销毁此对象。 + */ + __proto.destroy=function(){ + this.reset(); + this._labelDic=null; + this._tweenDic=null; + this._tweenDataList=null; + this._firstTweenDic=null; + } + + /** + *@private + *设置帧索引 + */ + /** + *@private + *得到帧索引 + */ + __getset(0,__proto,'index',function(){ + return this._frameIndex; + },function(value){ + this._frameIndex=value; + this.gotoTime(this._frameIndex / this._frameRate *1000); + }); + + /** + *得到总帧数据 + */ + __getset(0,__proto,'total',function(){ + this._total=Math.floor(this._startTime / 1000 *this._frameRate); + return this._total; + }); + + TimeLine.to=function(target,props,duration,ease,offset){ + (offset===void 0)&& (offset=0); + return (new TimeLine()).to(target,props,duration,ease,offset); + } + + TimeLine.from=function(target,props,duration,ease,offset){ + (offset===void 0)&& (offset=0); + return (new TimeLine()).from(target,props,duration,ease,offset); + } + + TimeLine.__init$=function(){ + //class tweenData + tweenData=(function(){ + function tweenData(){ + this.type=0; + this.isTo=true; + this.startTime=NaN; + this.endTime=NaN; + this.target=null; + this.duration=NaN; + this.ease=null; + this.data=null; + } + __class(tweenData,''); + return tweenData; + })() + } + + return TimeLine; + })(EventDispatcher) + + + /** + *

    Sprite 类是基本显示列表构造块:一个可显示图形并且也可包含子项的显示列表节点。

    + * + *@example 以下示例代码,创建了一个 Text 实例。 + *+ *package + *{ + *import laya.display.Sprite; + *import laya.events.Event; + * + *public class Sprite_Example + *{ + *private var sprite:Sprite; + *private var shape:Sprite + *public function Sprite_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *private function onInit():void + *{ + *sprite=new Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *sprite.loadImage("resource/ui/bg.png");//加载并显示图片。 + *sprite.x=200;//设置 sprite 对象相对于父容器的水平方向坐标值。 + *sprite.y=200;//设置 sprite 对象相对于父容器的垂直方向坐标值。 + *sprite.pivotX=0;//设置 sprite 对象的水平方法轴心点坐标。 + *sprite.pivotY=0;//设置 sprite 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(sprite);//将此 sprite 对象添加到显示列表。 + *sprite.on(Event.CLICK,this,onClickSprite);//给 sprite 对象添加点击事件侦听。 + *shape=new Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *shape.graphics.drawRect(0,0,100,100,"#ccff00","#ff0000",2);//绘制一个有边框的填充矩形。 + *shape.x=400;//设置 shape 对象相对于父容器的水平方向坐标值。 + *shape.y=200;//设置 shape 对象相对于父容器的垂直方向坐标值。 + *shape.width=100;//设置 shape 对象的宽度。 + *shape.height=100;//设置 shape 对象的高度。 + *shape.pivotX=50;//设置 shape 对象的水平方法轴心点坐标。 + *shape.pivotY=50;//设置 shape 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(shape);//将此 shape 对象添加到显示列表。 + *shape.on(Event.CLICK,this,onClickShape);//给 shape 对象添加点击事件侦听。 + *} + *private function onClickSprite():void + *{ + *trace("点击 sprite 对象。"); + *sprite.rotation+=5;//旋转 sprite 对象。 + *} + *private function onClickShape():void + *{ + *trace("点击 shape 对象。"); + *shape.rotation+=5;//旋转 shape 对象。 + *} + *} + *} + * + *+ *var sprite; + *var shape; + *Sprite_Example(); + *function Sprite_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *function onInit() + *{ + *sprite=new laya.display.Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *sprite.loadImage("resource/ui/bg.png");//加载并显示图片。 + *sprite.x=200;//设置 sprite 对象相对于父容器的水平方向坐标值。 + *sprite.y=200;//设置 sprite 对象相对于父容器的垂直方向坐标值。 + *sprite.pivotX=0;//设置 sprite 对象的水平方法轴心点坐标。 + *sprite.pivotY=0;//设置 sprite 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(sprite);//将此 sprite 对象添加到显示列表。 + *sprite.on(Event.CLICK,this,onClickSprite);//给 sprite 对象添加点击事件侦听。 + *shape=new laya.display.Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *shape.graphics.drawRect(0,0,100,100,"#ccff00","#ff0000",2);//绘制一个有边框的填充矩形。 + *shape.x=400;//设置 shape 对象相对于父容器的水平方向坐标值。 + *shape.y=200;//设置 shape 对象相对于父容器的垂直方向坐标值。 + *shape.width=100;//设置 shape 对象的宽度。 + *shape.height=100;//设置 shape 对象的高度。 + *shape.pivotX=50;//设置 shape 对象的水平方法轴心点坐标。 + *shape.pivotY=50;//设置 shape 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(shape);//将此 shape 对象添加到显示列表。 + *shape.on(laya.events.Event.CLICK,this,onClickShape);//给 shape 对象添加点击事件侦听。 + *} + *function onClickSprite() + *{ + *console.log("点击 sprite 对象。"); + *sprite.rotation+=5;//旋转 sprite 对象。 + *} + *function onClickShape() + *{ + *console.log("点击 shape 对象。"); + *shape.rotation+=5;//旋转 shape 对象。 + *} + * + *+ *import Sprite=laya.display.Sprite; + *class Sprite_Example { + *private sprite:Sprite; + *private shape:Sprite + *public Sprite_Example(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.onInit(); + *} + *private onInit():void { + *this.sprite=new Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *this.sprite.loadImage("resource/ui/bg.png");//加载并显示图片。 + *this.sprite.x=200;//设置 sprite 对象相对于父容器的水平方向坐标值。 + *this.sprite.y=200;//设置 sprite 对象相对于父容器的垂直方向坐标值。 + *this.sprite.pivotX=0;//设置 sprite 对象的水平方法轴心点坐标。 + *this.sprite.pivotY=0;//设置 sprite 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(this.sprite);//将此 sprite 对象添加到显示列表。 + *this.sprite.on(laya.events.Event.CLICK,this,this.onClickSprite);//给 sprite 对象添加点击事件侦听。 + *this.shape=new Sprite();//创建一个 Sprite 类的实例对象 sprite 。 + *this.shape.graphics.drawRect(0,0,100,100,"#ccff00","#ff0000",2);//绘制一个有边框的填充矩形。 + *this.shape.x=400;//设置 shape 对象相对于父容器的水平方向坐标值。 + *this.shape.y=200;//设置 shape 对象相对于父容器的垂直方向坐标值。 + *this.shape.width=100;//设置 shape 对象的宽度。 + *this.shape.height=100;//设置 shape 对象的高度。 + *this.shape.pivotX=50;//设置 shape 对象的水平方法轴心点坐标。 + *this.shape.pivotY=50;//设置 shape 对象的垂直方法轴心点坐标。 + *Laya.stage.addChild(this.shape);//将此 shape 对象添加到显示列表。 + *this.shape.on(laya.events.Event.CLICK,this,this.onClickShape);//给 shape 对象添加点击事件侦听。 + *} + *private onClickSprite():void { + *console.log("点击 sprite 对象。"); + *this.sprite.rotation+=5;//旋转 sprite 对象。 + *} + *private onClickShape():void { + *console.log("点击 shape 对象。"); + *this.shape.rotation+=5;//旋转 shape 对象。 + *} + *} + * + */ + //class laya.display.Sprite extends laya.display.Node + var Sprite=(function(_super){ + function Sprite(){ + this.mouseThrough=false; + this._transform=null; + this._tfChanged=false; + this._x=0; + this._y=0; + this._width=0; + this._height=0; + this._repaint=1; + this._changeType=0; + this._mouseEnableState=0; + this._zOrder=0; + this._graphics=null; + this._renderType=0; + this.autoSize=false; + this.hitTestPrior=false; + this.viewport=null; + this._optimizeScrollRect=false; + this._texture=null; + Sprite.__super.call(this); + this._style=Style.EMPTY; + } + + __class(Sprite,'laya.display.Sprite',_super); + var __proto=Sprite.prototype; + Laya.imps(__proto,{"laya.display.ILayout":true}) + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._style && this._style.destroy(); + this._transform=null; + this._style=null; + this._graphics=null; + } + + /**根据zOrder进行重新排序。*/ + __proto.updateZOrder=function(){ + Utils.updateOrder(this._childs)&& this.repaint(); + } + + /**在设置cacheAs或staticCache=true的情况下,调用此方法会重新刷新缓存。*/ + __proto.reCache=function(){ + if (this._$P.cacheCanvas)this._$P.cacheCanvas.reCache=true; + } + + /** + *设置bounds大小,如果有设置,则不再通过getBounds计算 + *@param bound bounds矩形区域 + */ + __proto.setBounds=function(bound){ + this._set$P("uBounds",bound); + } + + /** + *获取本对象在父容器坐标系的矩形显示区域。 + *

    注意:计算量较大,尽量少用。

    + *@return 矩形区域。 + */ + __proto.getBounds=function(){ + if (!this._$P.mBounds)this._set$P("mBounds",new Rectangle()); + return Rectangle._getWrapRec(this._boundPointsToParent(),this._$P.mBounds); + } + + /** + *获取本对象在自己坐标系的矩形显示区域。 + *

    注意:计算量较大,尽量少用。

    + *@return 矩形区域。 + */ + __proto.getSelfBounds=function(){ + if (!this._$P.mBounds)this._set$P("mBounds",new Rectangle()); + return Rectangle._getWrapRec(this._getBoundPointsM(false),this._$P.mBounds); + } + + /** + *@private + *获取本对象在父容器坐标系的显示区域多边形顶点列表。 + *当显示对象链中有旋转时,返回多边形顶点列表,无旋转时返回矩形的四个顶点。 + *@param ifRotate 之前的对象链中是否有旋转。 + *@return 顶点列表。结构:[x1,y1,x2,y2,x3,y3,...]。 + */ + __proto._boundPointsToParent=function(ifRotate){ + (ifRotate===void 0)&& (ifRotate=false); + var pX=0,pY=0; + if (this._style){ + pX=this._style._tf.translateX; + pY=this._style._tf.translateY; + ifRotate=ifRotate || (this._style._tf.rotate!==0); + if (this._style.scrollRect){ + pX+=this._style.scrollRect.x; + pY+=this._style.scrollRect.y; + } + }; + var pList=this._getBoundPointsM(ifRotate); + if (!pList || pList.length < 1)return pList; + if (pList.length !=8){ + pList=ifRotate ? GrahamScan.scanPList(pList):Rectangle._getWrapRec(pList,Rectangle.TEMP)._getBoundPoints(); + } + if (!this.transform){ + Utils.transPointList(pList,this.x-pX,this.y-pY); + return pList; + }; + var tPoint=Point.TEMP; + var i=0,len=pList.length; + for (i=0;i < len;i+=2){ + tPoint.x=pList[i]; + tPoint.y=pList[i+1]; + this.toParentPoint(tPoint); + pList[i]=tPoint.x; + pList[i+1]=tPoint.y; + } + return pList; + } + + /** + *返回此实例中的绘图对象( Graphics )的显示区域。 + *@return 一个 Rectangle 对象,表示获取到的显示区域。 + */ + __proto.getGraphicBounds=function(){ + if (!this._graphics)return Rectangle.TEMP.setTo(0,0,0,0); + return this._graphics.getBounds(); + } + + /** + *@private + *获取自己坐标系的显示区域多边形顶点列表 + *@param ifRotate 当前的显示对象链是否由旋转 + *@return 顶点列表。结构:[x1,y1,x2,y2,x3,y3,...]。 + */ + __proto._getBoundPointsM=function(ifRotate){ + (ifRotate===void 0)&& (ifRotate=false); + if (this._$P.uBounds)return this._$P.uBounds._getBoundPoints(); + if (!this._$P.temBM)this._set$P("temBM",[]); + if (this.scrollRect){ + var rst=Utils.clearArray(this._$P.temBM); + var rec=Rectangle.TEMP; + rec.copyFrom(this.scrollRect); + Utils.concatArray(rst,rec._getBoundPoints()); + return rst; + }; + var pList=this._graphics ? this._graphics.getBoundPoints():Utils.clearArray(this._$P.temBM); + var child; + var cList; + var __childs; + __childs=this._childs; + for (var i=0,n=__childs.length;i < n;i++){ + child=__childs [i]; + if ((child instanceof laya.display.Sprite )&& child.visible==true){ + cList=child._boundPointsToParent(ifRotate); + if (cList) + pList=pList ? Utils.concatArray(pList,cList):cList; + } + } + return pList; + } + + /** + *@private + *获取样式。 + *@return 样式 Style 。 + */ + __proto.getStyle=function(){ + this._style===Style.EMPTY && (this._style=new Style()); + return this._style; + } + + /** + *@private + *设置样式。 + *@param value 样式。 + */ + __proto.setStyle=function(value){ + this._style=value; + } + + /**@private */ + __proto._adjustTransform=function(){ + 'use strict'; + this._tfChanged=false; + var style=this._style; + var tf=style._tf; + var sx=tf.scaleX,sy=tf.scaleY; + var m; + if (tf.rotate || sx!==1 || sy!==1 || tf.skewX || tf.skewY){ + m=this._transform || (this._transform=Matrix.create()); + m.bTransform=true; + if (tf.rotate){ + var angle=tf.rotate *0.0174532922222222; + var cos=m.cos=Math.cos(angle); + var sin=m.sin=Math.sin(angle); + m.a=sx *cos; + m.b=sx *sin; + m.c=-sy *sin; + m.d=sy *cos; + m.tx=m.ty=0; + return m; + }else { + m.a=sx; + m.d=sy; + m.c=m.b=m.tx=m.ty=0; + if (tf.skewX || tf.skewY){ + return m.skew(tf.skewX *0.0174532922222222,tf.skewY *0.0174532922222222); + } + return m; + } + }else { + this._transform && this._transform.destroy(); + this._transform=null; + this._renderType &=~ /*laya.renders.RenderSprite.TRANSFORM*/0x04; + } + return m; + } + + /** + *设置坐标位置。 + *@param x X 轴坐标。 + *@param y Y 轴坐标。 + *@return 返回对象本身。 + */ + __proto.pos=function(x,y){ + if (this._x!==x || this._y!==y){ + this.x=x; + this.y=y; + } + return this; + } + + /** + *设置轴心点。 + *@param x X轴心点。 + *@param y Y轴心点。 + *@return 返回对象本身。 + */ + __proto.pivot=function(x,y){ + this.pivotX=x; + this.pivotY=y; + return this; + } + + /** + *设置宽高。 + *@param width 宽度。 + *@param hegiht 高度。 + *@return 返回对象本身。 + */ + __proto.size=function(width,height){ + this.width=width; + this.height=height; + return this; + } + + /** + *设置缩放。 + *@param scaleX X轴缩放比例。 + *@param scaleY Y轴缩放比例。 + *@return 返回对象本身。 + */ + __proto.scale=function(scaleX,scaleY){ + this.scaleX=scaleX; + this.scaleY=scaleY; + return this; + } + + /** + *设置倾斜角度。 + *@param skewX 水平倾斜角度。 + *@param skewY 垂直倾斜角度。 + *@return 返回对象本身 + */ + __proto.skew=function(skewX,skewY){ + this.skewX=skewX; + this.skewY=skewY; + return this; + } + + /** + *更新、呈现显示对象。 + *@param context 渲染的上下文引用。 + *@param x X轴坐标。 + *@param y Y轴坐标。 + */ + __proto.render=function(context,x,y){ + Stat.spriteCount++; + RenderSprite.renders[this._renderType]._fun(this,context,x+this._x,y+this._y); + this._repaint=0; + } + + /** + *绘制 Spritecanvas 上。 + *@param canvasWidth 画布宽度。 + *@param canvasHeight 画布高度。 + *@param x 绘制的 X 轴偏移量。 + *@param y 绘制的 Y 轴偏移量。 + *@return HTMLCanvas 对象。 + */ + __proto.drawToCanvas=function(canvasWidth,canvasHeight,offsetX,offsetY){ + return RunDriver.drawToCanvas(this,this._renderType,canvasWidth,canvasHeight,offsetX,offsetY); + } + + /** + *自定义更新、呈现显示对象。 + *

    注意不要在此函数内增加或删除树节点,否则会树节点遍历照成影响。

    + *@param context 渲染的上下文引用。 + *@param x X轴坐标。 + *@param y Y轴坐标。 + */ + __proto.customRender=function(context,x,y){ + this._renderType |=/*laya.renders.RenderSprite.CUSTOM*/0x200; + } + + /** + *@private + *应用滤镜。 + */ + __proto._applyFilters=function(){ + if (Render.isWebGL)return; + var _filters; + _filters=this._$P.filters; + if (!_filters || _filters.length < 1)return; + for (var i=0,n=_filters.length;i < n;i++){ + _filters[i].action.apply(this._$P.cacheCanvas); + } + } + + /** + *@private + *查看当前原件中是否包含发光滤镜。 + *@return 一个 Boolean 值,表示当前原件中是否包含发光滤镜。 + */ + __proto._isHaveGlowFilter=function(){ + var i=0,len=0; + if (this.filters){ + for (i=0;i < this.filters.length;i++){ + if (this.filters[i].type==/*laya.filters.Filter.GLOW*/0x08){ + return true; + } + } + } + for (i=0,len=this._childs.length;i < len;i++){ + if (this._childs[i]._isHaveGlowFilter()){ + return true; + } + } + return false; + } + + /** + *本地坐标转全局坐标。 + *@param point 本地坐标点。 + *@param createNewPoint 用于存储转换后的坐标的点。 + *@return 转换后的坐标的点。 + */ + __proto.localToGlobal=function(point,createNewPoint){ + (createNewPoint===void 0)&& (createNewPoint=false); + if (!this._displayedInStage || !point)return point; + if (createNewPoint===true){ + point=new Point(point.x,point.y); + }; + var ele=this; + while (ele){ + if (ele==Laya.stage)break ; + point=ele.toParentPoint(point); + ele=ele.parent; + } + return point; + } + + /** + *全局坐标转本地坐标。 + *@param point 全局坐标点。 + *@param createNewPoint 用于存储转换后的坐标的点。 + *@return 转换后的坐标的点。 + */ + __proto.globalToLocal=function(point,createNewPoint){ + (createNewPoint===void 0)&& (createNewPoint=false); + if (!this._displayedInStage || !point)return point; + if (createNewPoint===true){ + point=new Point(point.x,point.y); + }; + var ele=this; + var list=[]; + while (ele){ + if (ele==Laya.stage)break ; + list.push(ele); + ele=ele.parent; + }; + var i=list.length-1; + while (i >=0){ + ele=list[i]; + point=ele.fromParentPoint(point); + i--; + } + return point; + } + + /** + *将本地坐标系坐标转换到父容器坐标系。 + *@param point 本地坐标点。 + *@return 转换后的点。 + */ + __proto.toParentPoint=function(point){ + if (!point)return point; + point.x-=this.pivotX; + point.y-=this.pivotY; + if (this.transform){ + this._transform.transformPoint(point); + } + point.x+=this._x; + point.y+=this._y; + var scroll=this._style.scrollRect; + if (scroll){ + point.x-=scroll.x; + point.y-=scroll.y; + } + return point; + } + + /** + *将父容器坐标系坐标转换到本地坐标系。 + *@param point 父容器坐标点。 + *@return 转换后的点。 + */ + __proto.fromParentPoint=function(point){ + if (!point)return point; + point.x-=this._x; + point.y-=this._y; + var scroll=this._style.scrollRect; + if (scroll){ + point.x+=scroll.x; + point.y+=scroll.y; + } + if (this.transform){ + this._transform.invertTransformPoint(point); + } + point.x+=this.pivotX; + point.y+=this.pivotY; + return point; + } + + /** + *使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知。 + *如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnable 的值为 true。 + *@param type 事件的类型。 + *@param caller 事件侦听函数的执行域。 + *@param listener 事件侦听函数。 + *@param args 事件侦听函数的回调参数。 + *@return 此 EventDispatcher 对象。 + */ + __proto.on=function(type,caller,listener,args){ + if (this._mouseEnableState!==1 && this.isMouseEvent(type)){ + if (this._displayedInStage)this._$2__onDisplay(); + else laya.events.EventDispatcher.prototype.once.call(this,/*laya.events.Event.DISPLAY*/"display",this,this._$2__onDisplay); + } + return laya.events.EventDispatcher.prototype.on.call(this,type,caller,listener,args); + } + + /** + *使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知,此侦听事件响应一次后自动移除。 + *如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnabled 的值为 true(如果父节点mouseEnabled=false,则停止设置父节点mouseEnabled属性)。 + *@param type 事件的类型。 + *@param caller 事件侦听函数的执行域。 + *@param listener 事件侦听函数。 + *@param args 事件侦听函数的回调参数。 + *@return 此 EventDispatcher 对象。 + */ + __proto.once=function(type,caller,listener,args){ + if (this._mouseEnableState!==1 && this.isMouseEvent(type)){ + if (this._displayedInStage)this._$2__onDisplay(); + else laya.events.EventDispatcher.prototype.once.call(this,/*laya.events.Event.DISPLAY*/"display",this,this._$2__onDisplay); + } + return laya.events.EventDispatcher.prototype.once.call(this,type,caller,listener,args); + } + + /**@private */ + __proto._$2__onDisplay=function(){ + if (this._mouseEnableState!==1){ + var ele=this; + while (ele && ele._mouseEnableState!==1){ + ele.mouseEnabled=true; + ele=ele.parent; + } + } + } + + /** + *加载并显示一个图片。功能等同于Graphics.loadImage + *@param url 图片地址。 + *@param x 显示图片的x位置 + *@param y 显示图片的y位置 + *@param width 显示图片的宽度,设置为0表示使用图片默认宽度 + *@param height 显示图片的高度,设置为0表示使用图片默认高度 + *@param complete 加载完成回调 + *@return 返回精灵对象本身 + */ + __proto.loadImage=function(url,x,y,width,height,complete){ + var _$this=this; + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + function loaded (tex){ + if (!_$this.destroyed){ + _$this.size(x+(width || tex.width),y+(height || tex.height)); + _$this.repaint(); + complete && complete.runWith(tex); + } + } + this.graphics.loadImage(url,x,y,width,height,loaded); + return this; + } + + /**cacheAs后,设置自己和父对象缓存失效。*/ + __proto.repaint=function(){ + this.model && this.model.repaint && this.model.repaint(); + (this._repaint===0)&& (this._repaint=1,this.parentRepaint()); + if (this._$P && this._$P.maskParent){ + this._$P.maskParent.repaint(); + } + } + + /** + *@private + *获取是否重新缓存。 + *@return 如果重新缓存值为 true,否则值为 false。 + */ + __proto._needRepaint=function(){ + return (this._repaint!==0)&& this._$P.cacheCanvas && this._$P.cacheCanvas.reCache; + } + + /**@inheritDoc */ + __proto._childChanged=function(child){ + if (this._childs.length)this._renderType |=/*laya.renders.RenderSprite.CHILDS*/0x800; + else this._renderType &=~ /*laya.renders.RenderSprite.CHILDS*/0x800; + if (child && (child).zOrder)Laya.timer.callLater(this,this.updateZOrder); + this.repaint(); + } + + /**cacheAs时,设置所有父对象缓存失效。 */ + __proto.parentRepaint=function(){ + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + + /** + *开始拖动此对象。 + *@param area 拖动区域,此区域为当前对象注册点活动区域(不包括对象宽高),可选。 + *@param hasInertia 鼠标松开后,是否还惯性滑动,默认为false,可选。 + *@param elasticDistance 橡皮筋效果的距离值,0为无橡皮筋效果,默认为0,可选。 + *@param elasticBackTime 橡皮筋回弹时间,单位为毫秒,默认为300毫秒,可选。 + *@param data 拖动事件携带的数据,可选。 + *@param disableMouseEvent 禁用其他对象的鼠标检测,默认为false,设置为true能提高性能 + *@param ratio 惯性阻尼系数 + */ + __proto.startDrag=function(area,hasInertia,elasticDistance,elasticBackTime,data,disableMouseEvent,ratio){ + (hasInertia===void 0)&& (hasInertia=false); + (elasticDistance===void 0)&& (elasticDistance=0); + (elasticBackTime===void 0)&& (elasticBackTime=300); + (disableMouseEvent===void 0)&& (disableMouseEvent=false); + (ratio===void 0)&& (ratio=0.92); + this._$P.dragging || (this._set$P("dragging",new Dragging())); + this._$P.dragging.start(this,area,hasInertia,elasticDistance,elasticBackTime,data,disableMouseEvent,ratio); + } + + /**停止拖动此对象。*/ + __proto.stopDrag=function(){ + this._$P.dragging && this._$P.dragging.stop(); + } + + /**@private */ + __proto._setDisplay=function(value){ + if (!value && this._$P.cacheCanvas && this._$P.cacheCanvas.ctx){ + Pool.recover("RenderContext",this._$P.cacheCanvas.ctx); + this._$P.cacheCanvas.ctx=null; + } + if (!value){ + var fc=this._$P._filterCache; + if (fc){ + fc.destroy(); + fc.recycle(); + this._set$P('_filterCache',null); + } + this._$P._isHaveGlowFilter && this._set$P('_isHaveGlowFilter',false); + } + _super.prototype._setDisplay.call(this,value); + } + + /** + *检测某个点是否在此对象内。 + *@param x 全局x坐标。 + *@param y 全局y坐标。 + *@return 表示是否在对象内。 + */ + __proto.hitTestPoint=function(x,y){ + var point=this.globalToLocal(Point.TEMP.setTo(x,y)); + var rect=this._$P.hitArea ? this._$P.hitArea :Rectangle.EMPTY.setTo(0,0,this._width,this._height); + return rect.contains(point.x,point.y); + } + + /**获得相对于本对象上的鼠标坐标信息。*/ + __proto.getMousePoint=function(){ + return this.globalToLocal(Point.TEMP.setTo(Laya.stage.mouseX,Laya.stage.mouseY)); + } + + /**@private */ + __proto._getWords=function(){ + return null; + } + + /**@private */ + __proto._addChildsToLayout=function(out){ + var words=this._getWords(); + if (words==null && this._childs.length==0)return false; + if (words){ + for (var i=0,n=words.length;i < n;i++){ + out.push(words[i]); + } + } + this._childs.forEach(function(o,index,array){ + o._style._enableLayout()&& o._addToLayout(out); + }); + return true; + } + + /**@private */ + __proto._addToLayout=function(out){ + if (this._style.absolute)return; + this._style.block ? out.push(this):(this._addChildsToLayout(out)&& (this.x=this.y=0)); + } + + /**@private */ + __proto._isChar=function(){ + return false; + } + + /**@private */ + __proto._getCSSStyle=function(){ + return this._style.getCSSStyle(); + } + + /** + *@private + *设置指定属性名的属性值。 + *@param name 属性名。 + *@param value 属性值。 + */ + __proto._setAttributes=function(name,value){ + switch (name){ + case 'x': + this.x=parseFloat(value); + break ; + case 'y': + this.y=parseFloat(value); + break ; + case 'width': + this.width=parseFloat(value); + break ; + case 'height': + this.height=parseFloat(value); + break ; + default : + this[name]=value; + } + } + + /** + *@private + */ + __proto._layoutLater=function(){ + this.parent && (this.parent)._layoutLater(); + } + + /** + *

    指定是否对使用了 scrollRect 的显示对象进行优化处理。

    + *

    默认为false(不优化)。

    + *

    当值为ture时:将对此对象使用了scrollRect 设定的显示区域以外的显示内容不进行渲染,以提高性能。

    + */ + __getset(0,__proto,'optimizeScrollRect',function(){ + return this._optimizeScrollRect; + },function(b){ + if (this._optimizeScrollRect !=b){ + this._optimizeScrollRect=b; + this.model && this.model.optimizeScrollRect(b); + } + }); + + /** + *开启自定义渲染,只有开启自定义渲染,才能使用customRender函数渲染 + */ + __getset(0,__proto,'customRenderEnable',null,function(b){ + if (b){ + this._renderType |=/*laya.renders.RenderSprite.CUSTOM*/0x200; + if (Render.isConchNode){ + laya.display.Sprite.CustomList.push(this); + var canvas=new HTMLCanvas("2d"); + canvas._setContext(/*__JS__ */new CanvasRenderingContext2D()); + /*__JS__ */this.customContext=new RenderContext(0,0,canvas); + canvas.context.setCanvasType && canvas.context.setCanvasType(2); + this.model.custom(canvas.context); + } + } + }); + + /** + *指定显示对象是否缓存为静态图像。功能同cacheAs的normal模式。 + */ + __getset(0,__proto,'cacheAsBitmap',function(){ + return this.cacheAs!=="none"; + },function(value){ + this.cacheAs=value ? (this._$P["hasFilter"] ? "none" :"normal"):"none"; + }); + + /** + *

    指定显示对象是否缓存为静态图像,cacheAs时,子对象发生变化,会自动重新缓存,同时也可以手动调用reCache方法更新缓存。

    + *建议把不经常变化的复杂内容缓存为静态图像,能极大提高渲染性能,有"none","normal"和"bitmap"三个值可选。 + *
  • 默认为"none",不做任何缓存。
  • + *
  • 当值为"normal"时,canvas下进行画布缓存,webgl模式下进行命令缓存。
  • + *
  • 当值为"bitmap"时,canvas下进行依然是画布缓存,webgl模式下使用renderTarget缓存。
  • + *webgl下renderTarget缓存模式有最大2048大小限制,会额外增加内存开销,不断重绘时开销比较大,但是会减少drawcall,渲染性能最高。 + *webgl下命令缓存模式只会减少节点遍历及命令组织,不会减少drawcall,性能中等。 + */ + __getset(0,__proto,'cacheAs',function(){ + return this._$P.cacheCanvas==null ? "none" :this._$P.cacheCanvas.type; + },function(value){ + var cacheCanvas=this._$P.cacheCanvas; + if (value===(cacheCanvas ? cacheCanvas.type :"none"))return; + if (value!=="none"){ + cacheCanvas || (cacheCanvas=this._set$P("cacheCanvas",Pool.getItemByClass("cacheCanvas",Object))); + cacheCanvas.type=value; + cacheCanvas.reCache=true; + this._renderType |=/*laya.renders.RenderSprite.CANVAS*/0x08; + if (value=="bitmap")this.model && this.model.cacheAs(1); + this._set$P("cacheForFilters",false); + }else { + if (this._$P["hasFilter"]){ + this._set$P("cacheForFilters",true); + }else { + if (cacheCanvas)Pool.recover("cacheCanvas",cacheCanvas); + this._$P.cacheCanvas=null; + this._renderType &=~ /*laya.renders.RenderSprite.CANVAS*/0x08; + this.model && this.model.cacheAs(0); + } + } + this.repaint(); + }); + + /**z排序,更改此值,按照值的大小进行显示层级排序。*/ + __getset(0,__proto,'zOrder',function(){ + return this._zOrder; + },function(value){ + if (this._zOrder !=value){ + this._zOrder=value; + this.model && this.model.setZOrder && this.model.setZOrder(value); + this._parent && Laya.timer.callLater(this._parent,this.updateZOrder); + } + }); + + /**旋转角度,默认值为0。*/ + __getset(0,__proto,'rotation',function(){ + return this._style._tf.rotate; + },function(value){ + var style=this.getStyle(); + if (style._tf.rotate!==value){ + this._changeType |=0x10; + style.setRotate(value); + this._tfChanged=true; + this.model && this.model.rotate(value); + this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + }); + + /** + *表示显示对象的宽度,以像素为单位。 + */ + __getset(0,__proto,'width',function(){ + if (!this.autoSize)return this._width; + return this.getSelfBounds().width; + },function(value){ + this._width!==value && (this._width=value,this.model && this.model.size(value,this._height),this.repaint()); + }); + + /**表示显示对象相对于父容器的水平方向坐标值。*/ + __getset(0,__proto,'x',function(){ + return this._x; + },function(value){ + if (this._x!==value){ + if (this.destroyed)return; + this._x=value; + this.model && this.model.pos(value,this._y); + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + this._$P.maskParent && this._$P.maskParent._repaint===0 && (this._$P.maskParent._repaint=1,this._$P.maskParent.parentRepaint()); + } + }); + + /** + *获得全局Y轴缩放值 + */ + __getset(0,__proto,'globalScaleY',function(){ + var scale=1; + var ele=this; + while (ele){ + if (ele===Laya.stage)break ; + scale *=ele.scaleX; + ele=ele.parent; + } + return scale; + }); + + /**手动设置的可点击区域,或者一个HitArea区域。*/ + __getset(0,__proto,'hitArea',function(){ + return this._$P.hitArea; + },function(value){ + this._set$P("hitArea",value); + }); + + /**设置cacheAs为非空时此值才有效,staticCache=true时,子对象变化时不会自动更新缓存,只能通过调用reCache方法手动刷新。*/ + __getset(0,__proto,'staticCache',function(){ + return this._$P.staticCache; + },function(value){ + this._set$P("staticCache",value); + if (!value && this._$P.cacheCanvas){ + this._$P.cacheCanvas.reCache=true; + } + }); + + /**@private 清理graphics,只显示此texture图片,等同于graphics.clear();graphics.drawTexture()*/ + __getset(0,__proto,'texture',function(){ + return this._texture; + },function(value){ + if (this._texture !=value){ + this._texture=value; + this.graphics.cleanByTexture(value,0,0); + } + }); + + /**表示显示对象相对于父容器的垂直方向坐标值。*/ + __getset(0,__proto,'y',function(){ + return this._y; + },function(value){ + if (this._y!==value){ + if (this.destroyed)return; + this._y=value; + this.model && this.model.pos(this._x,value); + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + this._$P.maskParent && this._$P.maskParent._repaint===0 && (this._$P.maskParent._repaint=1,this._$P.maskParent.parentRepaint()); + } + }); + + /** + *表示显示对象的高度,以像素为单位。 + */ + __getset(0,__proto,'height',function(){ + if (!this.autoSize)return this._height; + return this.getSelfBounds().height; + },function(value){ + this._height!==value && (this._height=value,this.model && this.model.size(this._width,value),this.repaint()); + }); + + /**指定要使用的混合模式。*/ + __getset(0,__proto,'blendMode',function(){ + return this._style.blendMode; + },function(value){ + this.getStyle().blendMode=value; + this.model && this.model.blendMode(value); + if (value && value !="source-over")this._renderType |=/*laya.renders.RenderSprite.BLEND*/0x20; + else this._renderType &=~ /*laya.renders.RenderSprite.BLEND*/0x20; + this.parentRepaint(); + }); + + /**X轴缩放值,默认值为1。*/ + __getset(0,__proto,'scaleX',function(){ + return this._style._tf.scaleX; + },function(value){ + var style=this.getStyle(); + if (style._tf.scaleX!==value){ + style.setScaleX(value); + this._changeType |=0x10; + this._tfChanged=true; + this.model && this.model.scale(value,style._tf.scaleY); + this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + }); + + /**Y轴缩放值,默认值为1。*/ + __getset(0,__proto,'scaleY',function(){ + return this._style._tf.scaleY; + },function(value){ + var style=this.getStyle(); + if (style._tf.scaleY!==value){ + style.setScaleY(value); + this._changeType |=0x10; + this._tfChanged=true; + this.model && this.model.scale(style._tf.scaleX,value); + this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + }); + + /**对舞台 stage 的引用。*/ + __getset(0,__proto,'stage',function(){ + return Laya.stage; + }); + + /**水平倾斜角度,默认值为0。*/ + __getset(0,__proto,'skewX',function(){ + return this._style._tf.skewX; + },function(value){ + var style=this.getStyle(); + if (style._tf.skewX!==value){ + style.setSkewX(value); + this._tfChanged=true; + this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + }); + + /**显示对象的滚动矩形范围。*/ + __getset(0,__proto,'scrollRect',function(){ + return this._style.scrollRect; + },function(value){ + this.getStyle().scrollRect=value; + this.viewport=value; + this.repaint(); + if (value){ + this._renderType |=/*laya.renders.RenderSprite.CLIP*/0x40; + this.model && this.model.scrollRect(value.x,value.y,value.width,value.height); + }else { + this._renderType &=~ /*laya.renders.RenderSprite.CLIP*/0x40; + this.model && this.model.removeType(/*laya.renders.RenderSprite.CLIP*/0x40); + } + }); + + /**垂直倾斜角度,默认值为0。*/ + __getset(0,__proto,'skewY',function(){ + return this._style._tf.skewY; + },function(value){ + var style=this.getStyle(); + if (style._tf.skewY!==value){ + style.setSkewY(value); + this._tfChanged=true; + this.model && this.model.skew(style._tf.skewX,value); + this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + var p=this._parent; + p && p._repaint===0 && (p._repaint=1,p.parentRepaint()); + } + }); + + /** + *对象的矩阵信息。 + */ + __getset(0,__proto,'transform',function(){ + return this._tfChanged ? this._adjustTransform():this._transform; + },function(value){ + this._tfChanged=false; + this._transform=value; + if (value){ + this._x=value.tx; + this._y=value.ty; + value.tx=value.ty=0; + this.model && this.model.transform(value.a,value.b,value.c,value.d,this._x,this._y); + } + if (value)this._renderType |=/*laya.renders.RenderSprite.TRANSFORM*/0x04; + else { + this._renderType &=~ /*laya.renders.RenderSprite.TRANSFORM*/0x04; + this.model && this.model.removeType(/*laya.renders.RenderSprite.TRANSFORM*/0x04); + } + this.parentRepaint(); + }); + + /**X轴 轴心点的位置,单位为像素,默认为0,轴心点会影响对象位置,缩放,旋转。*/ + __getset(0,__proto,'pivotX',function(){ + return this._style._tf.translateX; + },function(value){ + this.getStyle().setTranslateX(value); + this._changeType |=0x10; + this.model && this.model.pivot(value,this._style._tf.translateY); + this.repaint(); + }); + + /**Y轴 轴心点的位置,单位为像素,默认为0,轴心点会影响对象位置,缩放,旋转。*/ + __getset(0,__proto,'pivotY',function(){ + return this._style._tf.translateY; + },function(value){ + this.getStyle().setTranslateY(value); + this._changeType |=0x10; + this.model && this.model.pivot(this._style._tf.translateX,value); + this.repaint(); + }); + + /**透明度,值为0-1,默认值为1,表示不透明。*/ + __getset(0,__proto,'alpha',function(){ + return this._style.alpha; + },function(value){ + if (this._style && this._style.alpha!==value){ + value=value < 0 ? 0 :(value > 1 ? 1 :value); + this.getStyle().alpha=value; + this.model && this.model.alpha(value); + if (value!==1)this._renderType |=/*laya.renders.RenderSprite.ALPHA*/0x02; + else this._renderType &=~ /*laya.renders.RenderSprite.ALPHA*/0x02; + this.parentRepaint(); + } + }); + + /**表示是否可见,默认为true。*/ + __getset(0,__proto,'visible',function(){ + return this._style.visible; + },function(value){ + if (this._style && this._style.visible!==value){ + this.getStyle().visible=value; + this.model && this.model.visible(value); + this.parentRepaint(); + } + }); + + /**绘图对象。*/ + __getset(0,__proto,'graphics',function(){ + return this._graphics || (this.graphics=RunDriver.createGraphics()); + },function(value){ + if (this._graphics)this._graphics._sp=null; + this._graphics=value; + if (value){ + this._renderType &=~ /*laya.renders.RenderSprite.IMAGE*/0x01; + this._renderType |=/*laya.renders.RenderSprite.GRAPHICS*/0x100; + value._sp=this; + this.model && this.model.graphics(this._graphics); + }else { + this._renderType &=~ /*laya.renders.RenderSprite.GRAPHICS*/0x100; + this._renderType &=~ /*laya.renders.RenderSprite.IMAGE*/0x01; + this.model && this.model.removeType(/*laya.renders.RenderSprite.GRAPHICS*/0x100); + } + this.repaint(); + }); + + /**滤镜集合。*/ + __getset(0,__proto,'filters',function(){ + return this._$P.filters; + },function(value){ + value && value.length===0 && (value=null); + if (this._$P.filters==value)return; + this._set$P("filters",value ? value.slice():null); + if (Render.isConchApp){ + this.model && this.model.removeType(0x10); + if (this._$P.filters && this._$P.filters.length==1){ + this._$P.filters[0].callNative(this); + } + } + if (Render.isWebGL){ + if (value && value.length){ + this._renderType |=/*laya.renders.RenderSprite.FILTERS*/0x10; + }else { + this._renderType &=~ /*laya.renders.RenderSprite.FILTERS*/0x10; + } + } + if (value && value.length > 0){ + if (!(Render.isWebGL && value.length==1 && (((value[0])instanceof laya.filters.ColorFilter )))){ + if (this.cacheAs !="bitmap"){ + if (!Render.isConchNode)this.cacheAs="bitmap"; + this._set$P("cacheForFilters",true); + } + this._set$P("hasFilter",true); + } + }else { + this._set$P("hasFilter",false); + if (this._$P["cacheForFilters"] && this.cacheAs=="bitmap"){ + this.cacheAs="none"; + } + } + this.repaint(); + }); + + /**遮罩,可以设置一个对象或者图片,根据对象形状进行遮罩显示。 + *【注意】遮罩对象坐标系是相对遮罩对象本身的,这个和flash机制不同*/ + __getset(0,__proto,'mask',function(){ + return this._$P._mask; + },function(value){ + if (value && this.mask && this.mask._$P.maskParent)return; + if (value){ + this.cacheAs="bitmap"; + this._set$P("_mask",value); + value._set$P("maskParent",this); + }else { + this.cacheAs="none"; + this.mask && this.mask._set$P("maskParent",null); + this._set$P("_mask",value); + } + this.model && this.model.mask(value ? value.model :null); + this._renderType |=/*laya.renders.RenderSprite.BLEND*/0x20; + this.parentRepaint(); + }); + + /** + *是否接受鼠标事件。 + *默认为false,如果监听鼠标事件,则会自动设置本对象及父节点的属性 mouseEnable 的值都为 true(如果父节点手动设置为false,则不会更改)。 + **/ + __getset(0,__proto,'mouseEnabled',function(){ + return this._mouseEnableState > 1; + },function(value){ + this._mouseEnableState=value ? 2 :1; + }); + + /** + *获得全局X轴缩放值 + */ + __getset(0,__proto,'globalScaleX',function(){ + var scale=1; + var ele=this; + while (ele){ + if (ele===Laya.stage)break ; + scale *=ele.scaleX; + ele=ele.parent; + } + return scale; + }); + + /** + *表示鼠标在此对象上的 X 轴坐标信息。 + */ + __getset(0,__proto,'mouseX',function(){ + return this.getMousePoint().x; + }); + + /** + *表示鼠标在此对象上的 Y 轴坐标信息。 + */ + __getset(0,__proto,'mouseY',function(){ + return this.getMousePoint().y; + }); + + Sprite.fromImage=function(url){ + return new Sprite().loadImage(url); + } + + Sprite.CHG_VIEW=0x10; + Sprite.CHG_SCALE=0x100; + Sprite.CHG_TEXTURE=0x1000; + Sprite.CustomList=[]; + return Sprite; + })(Node) + + + /** + *@private + *audio标签播放声音的音轨控制 + */ + //class laya.media.h5audio.AudioSoundChannel extends laya.media.SoundChannel + var AudioSoundChannel=(function(_super){ + function AudioSoundChannel(audio){ + this._audio=null; + this._onEnd=null; + this._resumePlay=null; + AudioSoundChannel.__super.call(this); + this._onEnd=Utils.bind(this.__onEnd,this); + this._resumePlay=Utils.bind(this.__resumePlay,this); + audio.addEventListener("ended",this._onEnd); + this._audio=audio; + } + + __class(AudioSoundChannel,'laya.media.h5audio.AudioSoundChannel',_super); + var __proto=AudioSoundChannel.prototype; + __proto.__onEnd=function(){ + if (this.loops==1){ + if (this.completeHandler){ + Laya.timer.once(10,this,this.__runComplete,[this.completeHandler],false); + this.completeHandler=null; + } + this.stop(); + this.event(/*laya.events.Event.COMPLETE*/"complete"); + return; + } + if (this.loops > 0){ + this.loops--; + } + this.play(); + } + + __proto.__resumePlay=function(){ + if(this._audio)this._audio.removeEventListener("canplay",this._resumePlay); + try { + this._audio.currentTime=this.startTime; + Browser.container.appendChild(this._audio); + this._audio.play(); + }catch (e){ + this.event(/*laya.events.Event.ERROR*/"error"); + } + } + + /** + *播放 + */ + __proto.play=function(){ + try { + this._audio.currentTime=this.startTime; + }catch (e){ + this._audio.addEventListener("canplay",this._resumePlay); + return; + } + Browser.container.appendChild(this._audio); + if("play" in this._audio) + this._audio.play(); + } + + /** + *停止播放 + * + */ + __proto.stop=function(){ + this.isStopped=true; + SoundManager.removeChannel(this); + this.completeHandler=null; + if (!this._audio) + return; + if("pause" in this._audio) + this._audio.pause(); + this._audio.removeEventListener("ended",this._onEnd); + this._audio.removeEventListener("canplay",this._resumePlay); + Pool.recover("audio:"+this.url,this._audio); + Browser.removeElement(this._audio); + this._audio=null; + } + + /** + *当前播放到的位置 + *@return + * + */ + __getset(0,__proto,'position',function(){ + if (!this._audio) + return 0; + return this._audio.currentTime; + }); + + /** + *获取总时间。 + */ + __getset(0,__proto,'duration',function(){ + if (!this._audio) + return 0; + return this._audio.duration; + }); + + /** + *设置音量 + *@param v + * + */ + /** + *获取音量 + *@return + * + */ + __getset(0,__proto,'volume',function(){ + if (!this._audio)return 1; + return this._audio.volume; + },function(v){ + if (!this._audio)return; + this._audio.volume=v; + }); + + return AudioSoundChannel; + })(SoundChannel) + + + /** + *@private + *web audio api方式播放声音的音轨控制 + */ + //class laya.media.webaudio.WebAudioSoundChannel extends laya.media.SoundChannel + var WebAudioSoundChannel=(function(_super){ + function WebAudioSoundChannel(){ + this.audioBuffer=null; + this.gain=null; + this.bufferSource=null; + this._currentTime=0; + this._volume=1; + this._startTime=0; + this._onPlayEnd=null; + this.context=WebAudioSound.ctx; + WebAudioSoundChannel.__super.call(this); + this._onPlayEnd=Utils.bind(this.__onPlayEnd,this); + if (this.context["createGain"]){ + this.gain=this.context["createGain"](); + }else { + this.gain=this.context["createGainNode"](); + } + } + + __class(WebAudioSoundChannel,'laya.media.webaudio.WebAudioSoundChannel',_super); + var __proto=WebAudioSoundChannel.prototype; + /** + *播放声音 + */ + __proto.play=function(){ + this._clearBufferSource(); + if (!this.audioBuffer)return; + var context=this.context; + var gain=this.gain; + var bufferSource=context.createBufferSource(); + this.bufferSource=bufferSource; + bufferSource.buffer=this.audioBuffer; + bufferSource.connect(gain); + if (gain) + gain.disconnect(); + gain.connect(context.destination); + bufferSource.onended=this._onPlayEnd; + this._startTime=Browser.now(); + this.gain.gain.value=this._volume; + if (this.loops==0){ + bufferSource.loop=true; + } + bufferSource.start(0,this.startTime); + this._currentTime=0; + } + + __proto.__onPlayEnd=function(){ + if (this.loops==1){ + if (this.completeHandler){ + Laya.timer.once(10,this,this.__runComplete,[this.completeHandler],false); + this.completeHandler=null; + } + this.stop(); + this.event(/*laya.events.Event.COMPLETE*/"complete"); + return; + } + if (this.loops > 0){ + this.loops--; + } + this.play(); + } + + __proto._clearBufferSource=function(){ + if (this.bufferSource){ + var sourceNode=this.bufferSource; + if (sourceNode.stop){ + sourceNode.stop(0); + }else { + sourceNode.noteOff(0); + } + sourceNode.disconnect(0); + sourceNode.onended=null; + if (!WebAudioSoundChannel._tryCleanFailed)this._tryClearBuffer(sourceNode); + this.bufferSource=null; + } + } + + __proto._tryClearBuffer=function(sourceNode){ + try {sourceNode.buffer=WebAudioSound._miniBuffer;}catch (e){WebAudioSoundChannel._tryCleanFailed=true;} + } + + /** + *停止播放 + */ + __proto.stop=function(){ + this._clearBufferSource(); + this.audioBuffer=null; + if (this.gain) + this.gain.disconnect(); + this.isStopped=true; + SoundManager.removeChannel(this); + this.completeHandler=null; + } + + /** + *获取当前播放位置 + */ + __getset(0,__proto,'position',function(){ + if (this.bufferSource){ + return (Browser.now()-this._startTime)/ 1000+this.startTime; + } + return 0; + }); + + __getset(0,__proto,'duration',function(){ + if (this.audioBuffer){ + return this.audioBuffer.duration; + } + return 0; + }); + + /** + *设置音量 + */ + /** + *获取音量 + */ + __getset(0,__proto,'volume',function(){ + return this._volume; + },function(v){ + if (this.isStopped){ + return; + } + this._volume=v; + this.gain.gain.value=v; + }); + + WebAudioSoundChannel._tryCleanFailed=false; + return WebAudioSoundChannel; + })(SoundChannel) + + + /** + *@private + *Bitmap 是图片资源类。 + */ + //class laya.resource.Bitmap extends laya.resource.Resource + var Bitmap=(function(_super){ + function Bitmap(){ + //this._source=null; + //this._w=NaN; + //this._h=NaN; + this.useNum=0; + Bitmap.__super.call(this); + this._w=0; + this._h=0; + } + + __class(Bitmap,'laya.resource.Bitmap',_super); + var __proto=Bitmap.prototype; + /** + *彻底清理资源。 + */ + __proto.dispose=function(){ + this._resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + /*** + *宽度。 + */ + __getset(0,__proto,'width',function(){ + return this._w; + }); + + /*** + *高度。 + */ + __getset(0,__proto,'height',function(){ + return this._h; + }); + + /*** + *HTML Image 或 HTML Canvas 或 WebGL Texture 。 + */ + __getset(0,__proto,'source',function(){ + return this._source; + }); + + return Bitmap; + })(Resource) + + + /** + *动画播放控制器 + */ + //class laya.display.AnimationPlayerBase extends laya.display.Sprite + var AnimationPlayerBase=(function(_super){ + function AnimationPlayerBase(){ + this.loop=false; + this.wrapMode=0; + this._index=0; + this._count=0; + this._isPlaying=false; + this._labels=null; + this._isReverse=false; + this._frameRateChanged=false; + this._controlNode=null; + this._actionName=null; + AnimationPlayerBase.__super.call(this); + this._interval=Config.animationInterval; + } + + __class(AnimationPlayerBase,'laya.display.AnimationPlayerBase',_super); + var __proto=AnimationPlayerBase.prototype; + /** + *播放动画。 + *@param start 开始播放的动画索引或label。 + *@param loop 是否循环。 + *@param name 如果name为空(可选),则播放当前动画,如果不为空,则播放全局缓存动画(如果有) + */ + __proto.play=function(start,loop,name){ + (start===void 0)&& (start=0); + (loop===void 0)&& (loop=true); + (name===void 0)&& (name=""); + this._isPlaying=true; + this.index=((typeof start=='string'))? this._getFrameByLabel(start):start; + this.loop=loop; + this._actionName=name; + this._isReverse=this.wrapMode==1; + if (this.interval > 0){ + this.timerLoop(this.interval,this,this._frameLoop,null,true); + } + } + + /**@private */ + __proto._getFrameByLabel=function(label){ + var i=0; + for (i=0;i < this._count;i++){ + if (this._labels[i]==label)return i; + } + return 0; + } + + /**@private */ + __proto._frameLoop=function(){ + if (this._isReverse){ + this._index--; + if (this._index < 0){ + if (this.loop){ + if (this.wrapMode==2){ + this._index=this._count > 0 ? 1 :0; + this._isReverse=false; + }else { + this._index=this._count-1; + } + this.event(/*laya.events.Event.COMPLETE*/"complete"); + }else { + this._index=0; + this.stop(); + this.event(/*laya.events.Event.COMPLETE*/"complete"); + return; + } + } + }else { + this._index++; + if (this._index >=this._count){ + if (this.loop){ + if (this.wrapMode==2){ + this._index=this._count-2 >=0 ? this._count-2 :0; + this._isReverse=true; + }else { + this._index=0; + } + this.event(/*laya.events.Event.COMPLETE*/"complete"); + }else { + this._index--; + this.stop(); + this.event(/*laya.events.Event.COMPLETE*/"complete"); + return; + } + } + } + this.index=this._index; + } + + /**@private */ + __proto._setControlNode=function(node){ + if (this._controlNode){ + this._controlNode.off(/*laya.events.Event.DISPLAY*/"display",this,this._$3__onDisplay); + this._controlNode.off(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._$3__onDisplay); + } + this._controlNode=node; + if (node && node !=this){ + node.on(/*laya.events.Event.DISPLAY*/"display",this,this._$3__onDisplay); + node.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._$3__onDisplay); + } + } + + /**@private */ + __proto._setDisplay=function(value){ + _super.prototype._setDisplay.call(this,value); + this._$3__onDisplay(); + } + + /**@private */ + __proto._$3__onDisplay=function(){ + if (this._isPlaying){ + if (this._controlNode.displayedInStage)this.play(this._index,this.loop,this._actionName); + else this.clearTimer(this,this._frameLoop); + } + } + + /** + *停止播放。 + */ + __proto.stop=function(){ + this._isPlaying=false; + this.clearTimer(this,this._frameLoop); + } + + /** + *增加一个标签到index帧上,播放到此index后会派发label事件 + *@param label 标签名称 + *@param index 索引位置 + */ + __proto.addLabel=function(label,index){ + if (!this._labels)this._labels={}; + this._labels[index]=label; + } + + /** + *删除某个标签 + *@param label 标签名字,如果label为空,则删除所有Label + */ + __proto.removeLabel=function(label){ + if (!label)this._labels=null; + else if (this._labels){ + for (var name in this._labels){ + if (this._labels[name]===label){ + delete this._labels[name]; + break ; + } + } + } + } + + /** + *切换到某帧并停止 + *@param position 帧索引或label + */ + __proto.gotoAndStop=function(position){ + this.index=((typeof position=='string'))? this._getFrameByLabel(position):position; + this.stop(); + } + + /** + *@private + *显示到某帧 + *@param value 帧索引 + * + */ + __proto._displayToIndex=function(value){} + /**清理。方便对象复用。*/ + __proto.clear=function(){ + this.stop(); + this._labels=null; + } + + /**播放间隔(单位:毫秒)。*/ + /**播放间隔(单位:毫秒)。*/ + __getset(0,__proto,'interval',function(){ + return this._interval; + },function(value){ + if (this._interval !=value){ + this._frameRateChanged=true; + this._interval=value; + if (this._isPlaying && value > 0){ + this.timerLoop(value,this,this._frameLoop,null,true); + } + } + }); + + /** + *是否在播放中 + */ + __getset(0,__proto,'isPlaying',function(){ + return this._isPlaying; + }); + + /**当前播放索引。*/ + __getset(0,__proto,'index',function(){ + return this._index; + },function(value){ + this._index=value; + this._displayToIndex(value); + if (this._labels && this._labels[value])this.event(/*laya.events.Event.LABEL*/"label",this._labels[value]); + }); + + /**动画长度。*/ + __getset(0,__proto,'count',function(){ + return this._count; + }); + + return AnimationPlayerBase; + })(Sprite) + + + /** + *

    Text 类用于创建显示对象以显示文本。

    + *@example 以下示例代码,创建了一个 Text 实例。 + *+ *package + *{ + *import laya.display.Text; + *public class Text_Example + *{ + *public function Text_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *private function onInit():void + *{ + *var text:Text=new Text();//创建一个 Text 类的实例对象 text 。 + *text.text="这个是一个 Text 文本示例。"; + *text.color="#008fff";//设置 text 的文本颜色。 + *text.font="Arial";//设置 text 的文本字体。 + *text.bold=true;//设置 text 的文本显示为粗体。 + *text.fontSize=30;//设置 text 的字体大小。 + *text.wordWrap=true;//设置 text 的文本自动换行。 + *text.x=100;//设置 text 对象的属性 x 的值,用于控制 text 对象的显示位置。 + *text.y=100;//设置 text 对象的属性 y 的值,用于控制 text 对象的显示位置。 + *text.width=300;//设置 text 的宽度。 + *text.height=200;//设置 text 的高度。 + *text.italic=true;//设置 text 的文本显示为斜体。 + *text.borderColor="#fff000";//设置 text 的文本边框颜色。 + *Laya.stage.addChild(text);//将 text 添加到显示列表。 + *} + *} + *} + * + *+ *Text_Example(); + *function Text_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *function onInit() + *{ + *var text=new laya.display.Text();//创建一个 Text 类的实例对象 text 。 + *text.text="这个是一个 Text 文本示例。"; + *text.color="#008fff";//设置 text 的文本颜色。 + *text.font="Arial";//设置 text 的文本字体。 + *text.bold=true;//设置 text 的文本显示为粗体。 + *text.fontSize=30;//设置 text 的字体大小。 + *text.wordWrap=true;//设置 text 的文本自动换行。 + *text.x=100;//设置 text 对象的属性 x 的值,用于控制 text 对象的显示位置。 + *text.y=100;//设置 text 对象的属性 y 的值,用于控制 text 对象的显示位置。 + *text.width=300;//设置 text 的宽度。 + *text.height=200;//设置 text 的高度。 + *text.italic=true;//设置 text 的文本显示为斜体。 + *text.borderColor="#fff000";//设置 text 的文本边框颜色。 + *Laya.stage.addChild(text);//将 text 添加到显示列表。 + *} + * + *+ *class Text_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.onInit(); + *} + *private onInit():void { + *var text:laya.display.Text=new laya.display.Text();//创建一个 Text 类的实例对象 text 。 + *text.text="这个是一个 Text 文本示例。"; + *text.color="#008fff";//设置 text 的文本颜色。 + *text.font="Arial";//设置 text 的文本字体。 + *text.bold=true;//设置 text 的文本显示为粗体。 + *text.fontSize=30;//设置 text 的字体大小。 + *text.wordWrap=true;//设置 text 的文本自动换行。 + *text.x=100;//设置 text 对象的属性 x 的值,用于控制 text 对象的显示位置。 + *text.y=100;//设置 text 对象的属性 y 的值,用于控制 text 对象的显示位置。 + *text.width=300;//设置 text 的宽度。 + *text.height=200;//设置 text 的高度。 + *text.italic=true;//设置 text 的文本显示为斜体。 + *text.borderColor="#fff000";//设置 text 的文本边框颜色。 + *Laya.stage.addChild(text);//将 text 添加到显示列表。 + *} + *} + * + */ + //class laya.display.Text extends laya.display.Sprite + var Text=(function(_super){ + function Text(){ + this._clipPoint=null; + this._currBitmapFont=null; + this._text=null; + this._isChanged=false; + this._textWidth=0; + this._textHeight=0; + this._lines=[]; + this._lineWidths=[]; + this._startX=NaN; + this._startY=NaN; + this._lastVisibleLineIndex=-1; + this._words=null; + this._charSize={}; + this.underline=false; + this._underlineColor=null; + Text.__super.call(this); + this.overflow=Text.VISIBLE; + this._style=new CSSStyle(this); + (this._style).wordWrap=false; + } + + __class(Text,'laya.display.Text',_super); + var __proto=Text.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._lines=null; + if (this._words){ + this._words.length=0; + this._words=null; + } + } + + /** + *@private + *@inheritDoc + */ + __proto._getBoundPointsM=function(ifRotate){ + (ifRotate===void 0)&& (ifRotate=false); + var rec=Rectangle.TEMP; + rec.setTo(0,0,this.width,this.height); + return rec._getBoundPoints(); + } + + /** + *@inheritDoc + */ + __proto.getGraphicBounds=function(){ + var rec=Rectangle.TEMP; + rec.setTo(0,0,this.width,this.height); + return rec; + } + + /** + *@private + *@inheritDoc + */ + __proto._getCSSStyle=function(){ + return this._style; + } + + /** + *

    根据指定的文本,从语言包中取当前语言的文本内容。并对此文本中的{i}文本进行替换。

    + *

    例如: + *

  • (1)text 的值为“我的名字”,先取到这个文本对应的当前语言版本里的值“My name”,将“My name”设置为当前文本的内容。
  • + *
  • (2)text 的值为“恭喜你赢得{0}个钻石,{1}经验。”,arg1 的值为100,arg2 的值为200。 + *则先取到这个文本对应的当前语言版本里的值“Congratulations on your winning {0}diamonds,{1}experience.”, + *然后将文本里的{0}、{1},依据括号里的数字从0开始替换为 arg1、arg2 的值。 + *将替换处理后的文本“Congratulations on your winning 100 diamonds,200 experience.”设置为当前文本的内容。 + *
  • + *

    + *@param text 文本内容。 + *@param ...args 文本替换参数。 + */ + __proto.lang=function(text,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10){ + text=Text.langPacks && Text.langPacks[text] ? Text.langPacks[text] :text; + if (arguments.length < 2){ + this._text=text; + }else { + for (var i=0,n=arguments.length;i < n;i++){ + text=text.replace("{"+i+"}",arguments[i+1]); + } + this._text=text; + } + } + + /** + *渲染文字。 + *@param begin 开始渲染的行索引。 + *@param visibleLineCount 渲染的行数。 + */ + __proto.renderText=function(begin,visibleLineCount){ + var graphics=this.graphics; + graphics.clear(); + var ctxFont=(this.italic ? "italic " :"")+(this.bold ? "bold " :"")+this.fontSize+"px "+this.font; + Browser.context.font=ctxFont; + var padding=this.padding; + var startX=padding[3]; + var textAlgin="left"; + var lines=this._lines; + var lineHeight=this.leading+this._charSize.height; + var tCurrBitmapFont=this._currBitmapFont; + if (tCurrBitmapFont){ + lineHeight=this.leading+tCurrBitmapFont.getMaxHeight(); + }; + var startY=padding[0]; + if ((!tCurrBitmapFont)&& this._width > 0 && this._textWidth <=this._width){ + if (this.align=="right"){ + textAlgin="right"; + startX=this._width-padding[1]; + }else if (this.align=="center"){ + textAlgin="center"; + startX=this._width *0.5+padding[3]-padding[1]; + } + } + if (this._height > 0){ + var tempVAlign=(this._textHeight > this._height)? "top" :this.valign; + if (tempVAlign==="middle") + startY=(this._height-visibleLineCount *lineHeight)*0.5+padding[0]-padding[2]; + else if (tempVAlign==="bottom") + startY=this._height-visibleLineCount *lineHeight-padding[2]; + }; + var style=this._style; + if (tCurrBitmapFont && tCurrBitmapFont.autoScaleSize){ + var bitmapScale=tCurrBitmapFont.fontSize / this.fontSize; + } + if (this._clipPoint){ + graphics.save(); + if (tCurrBitmapFont && tCurrBitmapFont.autoScaleSize){ + var tClipWidth=0; + var tClipHeight=0; + this._width ? tClipWidth=(this._width-padding[3]-padding[1]):tClipWidth=this._textWidth; + this._height ? tClipHeight=(this._height-padding[0]-padding[2]):tClipHeight=this._textHeight; + tClipWidth *=bitmapScale; + tClipHeight *=bitmapScale; + graphics.clipRect(padding[3],padding[0],tClipWidth,tClipHeight); + }else { + graphics.clipRect(padding[3],padding[0],this._width ? (this._width-padding[3]-padding[1]):this._textWidth,this._height ? (this._height-padding[0]-padding[2]):this._textHeight); + } + }; + var password=style.password; + if (("prompt" in this)&& this['prompt']==this._text) + password=false; + var x=0,y=0; + var end=Math.min(this._lines.length,visibleLineCount+begin)|| 1; + for (var i=begin;i < end;i++){ + var word=lines[i]; + var _word; + if (password){ + var len=word.length; + word=""; + for (var j=len;j > 0;j--){ + word+="●"; + } + } + x=startX-(this._clipPoint ? this._clipPoint.x :0); + y=startY+lineHeight *i-(this._clipPoint ? this._clipPoint.y :0); + this.underline && this.drawUnderline(textAlgin,x,y,i); + if (tCurrBitmapFont){ + var tWidth=this.width; + if (tCurrBitmapFont.autoScaleSize){ + tWidth=this.width *bitmapScale; + } + tCurrBitmapFont.drawText(word,this,x,y,this.align,tWidth); + }else { + if (Render.isWebGL){ + this._words || (this._words=[]); + _word=this._words.length > (i-begin)? this._words[i-begin] :new WordText(); + _word.setText(word); + }else { + _word=word; + } + style.stroke ? graphics.fillBorderText(_word,x,y,ctxFont,this.color,style.strokeColor,style.stroke,textAlgin):graphics.fillText(_word,x,y,ctxFont,this.color,textAlgin); + } + } + if (tCurrBitmapFont && tCurrBitmapFont.autoScaleSize){ + var tScale=1 / bitmapScale; + this.scale(tScale,tScale); + } + if (this._clipPoint) + graphics.restore(); + this._startX=startX; + this._startY=startY; + } + + /** + *绘制下划线 + *@param x 本行坐标 + *@param y 本行坐标 + *@param lineIndex 本行索引 + */ + __proto.drawUnderline=function(align,x,y,lineIndex){ + var lineWidth=this._lineWidths[lineIndex]; + switch (align){ + case 'center': + x-=lineWidth / 2; + break ; + case 'right': + x-=lineWidth; + break ; + case 'left': + default : + break ; + } + y+=this._charSize.height; + this._graphics.drawLine(x,y,x+lineWidth,y,this.underlineColor || this.color,1); + } + + /** + *

    排版文本。

    + *

    进行宽高计算,渲染、重绘文本。

    + */ + __proto.typeset=function(){ + this._isChanged=false; + if (!this._text){ + this._clipPoint=null; + this._textWidth=this._textHeight=0; + this.graphics.clear(); + return; + } + Browser.context.font=this._getCSSStyle().font; + this._lines.length=0; + this._lineWidths.length=0; + this.parseLines(this._text); + this.evalTextSize(); + if (this.checkEnabledViewportOrNot()) + this._clipPoint || (this._clipPoint=new Point(0,0)); + else + this._clipPoint=null; + var lineCount=this._lines.length; + if (this.overflow !=Text.VISIBLE){ + var func=this.overflow==Text.HIDDEN ? Math.floor :Math.ceil; + lineCount=Math.min(lineCount,func((this.height-this.padding[0]-this.padding[2])/ (this.leading+this._charSize.height))); + }; + var startLine=this.scrollY / (this._charSize.height+this.leading)| 0; + this.renderText(startLine,lineCount); + this.repaint(); + } + + __proto.evalTextSize=function(){ + var nw=NaN,nh=NaN; + nw=Math.max.apply(this,this._lineWidths); + if (this._currBitmapFont) + nh=this._lines.length *(this._currBitmapFont.getMaxHeight()+this.leading)+this.padding[0]+this.padding[2]; + else + nh=this._lines.length *(this._charSize.height+this.leading)+this.padding[0]+this.padding[2]; + if (nw !=this._textWidth || nh !=this._textHeight){ + this._textWidth=nw; + this._textHeight=nh; + if(!this._width||!this._height) + this.model&&this.model.size(this._width||this._textWidth,this._height||this._textHeight); + } + } + + __proto.checkEnabledViewportOrNot=function(){ + return this.overflow==Text.SCROLL && ((this._width > 0 && this._textWidth > this._width)|| (this._height > 0 && this._textHeight > this._height)); + } + + /** + *快速更改显示文本。不进行排版计算,效率较高。 + *

    如果只更改文字内容,不更改文字样式,建议使用此接口,能提高效率。

    + *@param text 文本内容。 + */ + __proto.changeText=function(text){ + if (this._text!==text){ + this.lang(text+""); + if (this._graphics && this._graphics.replaceText(this._text)){ + }else { + this.typeset(); + } + } + } + + /** + *@private + *分析文本换行。 + */ + __proto.parseLines=function(text){ + var needWordWrapOrTruncate=this.wordWrap || this.overflow==Text.HIDDEN; + if (needWordWrapOrTruncate){ + var wordWrapWidth=this.getWordWrapWidth(); + }; + var measureResult=Browser.context.measureText("阳"); + this._charSize.width=measureResult.width; + this._charSize.height=(measureResult.height || this.fontSize); + var lines=text.replace(/\r\n/g,"\n").split("\n"); + for (var i=0,n=lines.length;i < n;i++){ + if (i < n-1) + lines[i]+="\n"; + var line=lines[i]; + if (needWordWrapOrTruncate) + this.parseLine(line,wordWrapWidth); + else { + this._lineWidths.push(this.getTextWidth(line)); + this._lines.push(line); + } + } + } + + /** + *@private + *解析行文本。 + *@param line 某行的文本。 + *@param wordWrapWidth 文本的显示宽度。 + */ + __proto.parseLine=function(line,wordWrapWidth){ + var ctx=Browser.context; + var lines=this._lines; + var maybeIndex=0; + var execResult; + var charsWidth=NaN; + var wordWidth=NaN; + var startIndex=0; + charsWidth=this.getTextWidth(line); + if (charsWidth <=wordWrapWidth){ + lines.push(line); + this._lineWidths.push(charsWidth); + return; + } + charsWidth=this._currBitmapFont ? this._currBitmapFont.getMaxWidth():this._charSize.width; + maybeIndex=Math.floor(wordWrapWidth / charsWidth); + (maybeIndex==0)&& (maybeIndex=1); + charsWidth=this.getTextWidth(line.substring(0,maybeIndex)); + wordWidth=charsWidth; + for (var j=maybeIndex,m=line.length;j < m;j++){ + charsWidth=this.getTextWidth(line.charAt(j)); + wordWidth+=charsWidth; + if (wordWidth > wordWrapWidth){ + if (this.wordWrap){ + var newLine=line.substring(startIndex,j); + if (newLine.charCodeAt(newLine.length-1)< 255){ + execResult=/[^\x20-]+$/.exec(newLine); + if (execResult){ + j=execResult.index+startIndex; + if (execResult.index==0) + j+=newLine.length; + else + newLine=line.substring(startIndex,j); + } + } + lines.push(newLine); + this._lineWidths.push(wordWidth-charsWidth); + startIndex=j; + if (j+maybeIndex < m){ + j+=maybeIndex; + charsWidth=this.getTextWidth(line.substring(startIndex,j)); + wordWidth=charsWidth; + j--; + }else { + lines.push(line.substring(startIndex,m)); + this._lineWidths.push(this.getTextWidth(lines[lines.length-1])); + startIndex=-1; + break ; + } + }else if (this.overflow==Text.HIDDEN){ + lines.push(line.substring(0,j)); + this._lineWidths.push(this.getTextWidth(lines[lines.length-1])); + return; + } + } + } + if (this.wordWrap && startIndex !=-1){ + lines.push(line.substring(startIndex,m)); + this._lineWidths.push(this.getTextWidth(lines[lines.length-1])); + } + } + + __proto.getTextWidth=function(text){ + if (this._currBitmapFont) + return this._currBitmapFont.getTextWidth(text); + else + return Browser.context.measureText(text).width; + } + + /** + *获取换行所需的宽度。 + */ + __proto.getWordWrapWidth=function(){ + var p=this.padding; + var w=NaN; + if (this._currBitmapFont && this._currBitmapFont.autoScaleSize) + w=this._width *(this._currBitmapFont.fontSize / this.fontSize); + else + w=this._width; + if (w <=0){ + w=this.wordWrap ? 100 :Browser.width; + } + w <=0 && (w=100); + return w-p[3]-p[1]; + } + + /** + *返回字符的位置信息。 + *@param charIndex 索引位置。 + *@param out 输出的Point引用。 + *@return 返回Point位置信息。 + */ + __proto.getCharPoint=function(charIndex,out){ + this._isChanged && Laya.timer.runCallLater(this,this.typeset); + var len=0,lines=this._lines,startIndex=0; + for (var i=0,n=lines.length;i < n;i++){ + len+=lines[i].length; + if (charIndex < len){ + var line=i; + break ; + } + startIndex=len; + }; + var ctxFont=(this.italic ? "italic " :"")+(this.bold ? "bold " :"")+this.fontSize+"px "+this.font; + Browser.context.font=ctxFont; + var width=this.getTextWidth(this._text.substring(startIndex,charIndex)); + var point=out || new Point(); + return point.setTo(this._startX+width-(this._clipPoint ? this._clipPoint.x :0),this._startY+line *(this._charSize.height+this.leading)-(this._clipPoint ? this._clipPoint.y :0)); + } + + /** + *@inheritDoc + */ + __getset(0,__proto,'width',function(){ + if (this._width) + return this._width; + return this.textWidth+this.padding[1]+this.padding[3]; + },function(value){ + if (value !=this._width){ + _super.prototype._$set_width.call(this,value); + this.isChanged=true; + } + }); + + /** + *表示文本的宽度,以像素为单位。 + */ + __getset(0,__proto,'textWidth',function(){ + this._isChanged && Laya.timer.runCallLater(this,this.typeset); + return this._textWidth; + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'height',function(){ + if (this._height)return this._height; + return this.textHeight+this.padding[0]+this.padding[2]; + },function(value){ + if (value !=this._height){ + _super.prototype._$set_height.call(this,value); + this.isChanged=true; + } + }); + + /** + *表示文本的高度,以像素为单位。 + */ + __getset(0,__proto,'textHeight',function(){ + this._isChanged && Laya.timer.runCallLater(this,this.typeset); + return this._textHeight; + }); + + /** + *边距信息。 + *

    数据格式:[上边距,右边距,下边距,左边距](边距以像素为单位)。

    + */ + __getset(0,__proto,'padding',function(){ + return this._getCSSStyle().padding; + },function(value){ + this._getCSSStyle().padding=value; + this.isChanged=true; + }); + + /** + *指定文本是否为粗体字。 + *

    默认值为 false,这意味着不使用粗体字。如果值为 true,则文本为粗体字。

    + */ + __getset(0,__proto,'bold',function(){ + return this._getCSSStyle().bold; + },function(value){ + this._getCSSStyle().bold=value; + this.isChanged=true; + }); + + /**当前文本的内容字符串。*/ + __getset(0,__proto,'text',function(){ + return this._text || ""; + },function(value){ + if (this._text!==value){ + this.lang(value+""); + this.isChanged=true; + this.event(/*laya.events.Event.CHANGE*/"change"); + } + }); + + /** + *表示文本的颜色值。可以通过 Text.defaultColor 设置默认颜色。 + *

    默认值为黑色。

    + */ + __getset(0,__proto,'color',function(){ + return this._getCSSStyle().color; + },function(value){ + if (this._getCSSStyle().color !=value){ + this._getCSSStyle().color=value; + if (!this._isChanged && this._graphics){ + this._graphics.replaceTextColor(this.color) + }else { + this.isChanged=true; + } + } + }); + + /** + *文本的字体名称,以字符串形式表示。 + *

    默认值为:"Arial",可以通过Text.defaultFont设置默认字体。

    * + *@see laya.display.css.Font#defaultFamily + */ + __getset(0,__proto,'font',function(){ + return this._getCSSStyle().fontFamily; + },function(value){ + if (this._currBitmapFont){ + this._currBitmapFont=null; + this.scale(1,1); + } + if (Text._bitmapFonts && Text._bitmapFonts[value]){ + this._currBitmapFont=Text._bitmapFonts[value]; + } + this._getCSSStyle().fontFamily=value; + this.isChanged=true; + }); + + /** + *指定文本的字体大小(以像素为单位)。 + *

    默认为20像素,可以通过 Text.defaultSize 设置默认大小。

    + */ + __getset(0,__proto,'fontSize',function(){ + return this._getCSSStyle().fontSize; + },function(value){ + this._getCSSStyle().fontSize=value; + this.isChanged=true; + }); + + /** + *表示使用此文本格式的文本是否为斜体。 + *

    默认值为 false,这意味着不使用斜体。如果值为 true,则文本为斜体。

    + */ + __getset(0,__proto,'italic',function(){ + return this._getCSSStyle().italic; + },function(value){ + this._getCSSStyle().italic=value; + this.isChanged=true; + }); + + /** + *表示文本的水平显示方式。 + *

    取值: + *

  • "left": 居左对齐显示。
  • + *
  • "center": 居中对齐显示。
  • + *
  • "right": 居右对齐显示。
  • + *

    + */ + __getset(0,__proto,'align',function(){ + return this._getCSSStyle().align; + },function(value){ + this._getCSSStyle().align=value; + this.isChanged=true; + }); + + /** + *表示文本的垂直显示方式。 + *

    取值: + *

  • "top": 居顶部对齐显示。
  • + *
  • "middle": 居中对齐显示。
  • + *
  • "bottom": 居底部对齐显示。
  • + *

    + */ + __getset(0,__proto,'valign',function(){ + return this._getCSSStyle().valign; + },function(value){ + this._getCSSStyle().valign=value; + this.isChanged=true; + }); + + /** + *表示文本是否自动换行,默认为false。 + *

    若值为true,则自动换行;否则不自动换行。

    + */ + __getset(0,__proto,'wordWrap',function(){ + return this._getCSSStyle().wordWrap; + },function(value){ + this._getCSSStyle().wordWrap=value; + this.isChanged=true; + }); + + /** + *垂直行间距(以像素为单位)。 + */ + __getset(0,__proto,'leading',function(){ + return this._getCSSStyle().leading; + },function(value){ + this._getCSSStyle().leading=value; + this.isChanged=true; + }); + + /** + *文本背景颜色,以字符串表示。 + */ + __getset(0,__proto,'bgColor',function(){ + return this._getCSSStyle().backgroundColor; + },function(value){ + this._getCSSStyle().backgroundColor=value; + this.isChanged=true; + }); + + /** + *文本边框背景颜色,以字符串表示。 + */ + __getset(0,__proto,'borderColor',function(){ + return this._getCSSStyle().borderColor; + },function(value){ + this._getCSSStyle().borderColor=value; + this.isChanged=true; + }); + + /** + *

    描边宽度(以像素为单位)。

    + *默认值0,表示不描边。 + */ + __getset(0,__proto,'stroke',function(){ + return this._getCSSStyle().stroke; + },function(value){ + this._getCSSStyle().stroke=value; + this.isChanged=true; + }); + + /** + *

    描边颜色,以字符串表示。

    + *默认值为 "#000000"(黑色); + */ + __getset(0,__proto,'strokeColor',function(){ + return this._getCSSStyle().strokeColor; + },function(value){ + this._getCSSStyle().strokeColor=value; + this.isChanged=true; + }); + + /** + *一个布尔值,表示文本的属性是否有改变。若为true表示有改变。 + */ + __getset(0,__proto,'isChanged',null,function(value){ + if (this._isChanged!==value){ + this._isChanged=value; + value && Laya.timer.callLater(this,this.typeset); + } + }); + + /** + *设置横向滚动量。 + *

    即使设置超出滚动范围的值,也会被自动限制在可能的最大值处。

    + */ + /** + *获取横向滚动量。 + */ + __getset(0,__proto,'scrollX',function(){ + if (!this._clipPoint) + return 0; + return this._clipPoint.x; + },function(value){ + if (this.overflow !=Text.SCROLL || (this.textWidth < this._width || !this._clipPoint)) + return; + value=value < this.padding[3] ? this.padding[3] :value; + var maxScrollX=this._textWidth-this._width; + value=value > maxScrollX ? maxScrollX :value; + var visibleLineCount=this._height / (this._charSize.height+this.leading)| 0+1; + this._clipPoint.x=value; + this.renderText(this._lastVisibleLineIndex,visibleLineCount); + }); + + /** + *设置纵向滚动量(px)。即使设置超出滚动范围的值,也会被自动限制在可能的最大值处。 + */ + /** + *获取纵向滚动量。 + */ + __getset(0,__proto,'scrollY',function(){ + if (!this._clipPoint) + return 0; + return this._clipPoint.y; + },function(value){ + if (this.overflow !=Text.SCROLL || (this.textHeight < this._height || !this._clipPoint)) + return; + value=value < this.padding[0] ? this.padding[0] :value; + var maxScrollY=this._textHeight-this._height; + value=value > maxScrollY ? maxScrollY :value; + var startLine=value / (this._charSize.height+this.leading)| 0; + this._lastVisibleLineIndex=startLine; + var visibleLineCount=(this._height / (this._charSize.height+this.leading)| 0)+1; + this._clipPoint.y=value; + this.renderText(startLine,visibleLineCount); + }); + + /** + *获取横向可滚动最大值。 + */ + __getset(0,__proto,'maxScrollX',function(){ + return (this.textWidth < this._width)? 0 :this._textWidth-this._width; + }); + + /** + *获取纵向可滚动最大值。 + */ + __getset(0,__proto,'maxScrollY',function(){ + return (this.textHeight < this._height)? 0 :this._textHeight-this._height; + }); + + __getset(0,__proto,'lines',function(){ + return this._lines; + }); + + __getset(0,__proto,'underlineColor',function(){ + return this._underlineColor; + },function(value){ + this._underlineColor=value; + this._isChanged=true; + this.typeset(); + }); + + Text.registerBitmapFont=function(name,bitmapFont){ + Text._bitmapFonts || (Text._bitmapFonts={}); + Text._bitmapFonts[name]=bitmapFont; + } + + Text.unregisterBitmapFont=function(name,destroy){ + (destroy===void 0)&& (destroy=true); + if (Text._bitmapFonts && Text._bitmapFonts[name]){ + var tBitmapFont=Text._bitmapFonts[name]; + if (destroy){ + tBitmapFont.destroy(); + } + delete Text._bitmapFonts[name]; + } + } + + Text.langPacks=null + Text.VISIBLE="visible"; + Text.SCROLL="scroll"; + Text.HIDDEN="hidden"; + Text._bitmapFonts=null + return Text; + })(Sprite) + + + /** + *

    Stage 类是显示对象的根节点。

    + *可以通过 Laya.stage 访问。 + */ + //class laya.display.Stage extends laya.display.Sprite + var Stage=(function(_super){ + function Stage(){ + this.focus=null; + this.frameRate="fast"; + this.desginWidth=0; + this.desginHeight=0; + this.canvasRotation=false; + this.canvasDegree=0; + this.renderingEnabled=true; + this._screenMode="none"; + this._scaleMode="noscale"; + this._alignV="top"; + this._alignH="left"; + this._bgColor="black"; + this._mouseMoveTime=0; + this._renderCount=0; + this._safariOffsetY=0; + this._frameStartTime=NaN; + this._previousOrientation=0; + this._scenes=null; + Stage.__super.call(this); + this.offset=new Point(); + this._canvasTransform=new Matrix(); + var _$this=this; + this.transform=Matrix.create(); + this._scenes=[]; + this.mouseEnabled=true; + this.hitTestPrior=true; + this.autoSize=false; + this._displayedInStage=true; + var _this=this; + var window=Browser.window; + window.addEventListener("focus",function(){ + _this.event(/*laya.events.Event.FOCUS*/"focus"); + }); + window.addEventListener("blur",function(){ + _this.event(/*laya.events.Event.BLUR*/"blur"); + if (_this._isInputting())Input["inputElement"].target.focus=false; + }); + var hidden="hidden",state="visibilityState",visibilityChange="visibilitychange"; + var document=window.document; + if (typeof document.hidden!=="undefined"){ + visibilityChange="visibilitychange"; + state="visibilityState"; + }else if (typeof document.mozHidden!=="undefined"){ + visibilityChange="mozvisibilitychange"; + state="mozVisibilityState"; + }else if (typeof document.msHidden!=="undefined"){ + visibilityChange="msvisibilitychange"; + state="msVisibilityState"; + }else if (typeof document.webkitHidden!=="undefined"){ + visibilityChange="webkitvisibilitychange"; + state="webkitVisibilityState"; + } + window.document.addEventListener(visibilityChange,visibleChangeFun); + function visibleChangeFun (){ + if (Browser.document[state]=="hidden"){ + _this.event(/*laya.events.Event.BLUR*/"blur"); + if (_this._isInputting())Input["inputElement"].target.focus=false; + }else { + _this.event(/*laya.events.Event.FOCUS*/"focus"); + } + } + window.addEventListener("resize",function(){ + var orientation=Browser.window.orientation; + if (orientation !=null && orientation !=_$this._previousOrientation && _this._isInputting()){ + Input["inputElement"].target.focus=false; + } + _$this._previousOrientation=orientation; + if (_this._isInputting())return; + if (Browser.onSafari) + _this._safariOffsetY=(Browser.window.__innerHeight || Browser.document.body.clientHeight || Browser.document.documentElement.clientHeight)-Browser.window.innerHeight; + _this._resetCanvas(); + }); + window.addEventListener("orientationchange",function(e){ + _this._resetCanvas(); + }); + this.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this._onmouseMove); + if (Browser.onMobile)this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onmouseMove); + } + + __class(Stage,'laya.display.Stage',_super); + var __proto=Stage.prototype; + /** + *在移动端输入时,输入法弹出期间不进行画布尺寸重置。 + */ + __proto._isInputting=function(){ + return (Browser.onMobile && Input.isInputting); + } + + /**@private */ + __proto._changeCanvasSize=function(){ + this.setScreenSize(Browser.clientWidth *Browser.pixelRatio,Browser.clientHeight *Browser.pixelRatio); + } + + /**@private */ + __proto._resetCanvas=function(){ + var canvas=Render._mainCanvas; + var canvasStyle=canvas.source.style; + canvas.size(1,1); + canvasStyle.transform=canvasStyle.webkitTransform=canvasStyle.msTransform=canvasStyle.mozTransform=canvasStyle.oTransform=""; + this.visible=false; + Laya.timer.once(100,this,this._changeCanvasSize); + } + + /** + *设置屏幕大小,场景会根据屏幕大小进行适配。 + *@param screenWidth 屏幕宽度。 + *@param screenHeight 屏幕高度。 + */ + __proto.setScreenSize=function(screenWidth,screenHeight){ + var rotation=false; + if (this._screenMode!=="none"){ + var screenType=screenWidth / screenHeight < 1 ? "vertical" :"horizontal"; + rotation=screenType!==this._screenMode; + if (rotation){ + var temp=screenHeight; + screenHeight=screenWidth; + screenWidth=temp; + } + } + this.canvasRotation=rotation; + var canvas=Render._mainCanvas; + var canvasStyle=canvas.source.style; + var mat=this._canvasTransform.identity(); + var scaleMode=this._scaleMode; + var scaleX=screenWidth / this.desginWidth; + var scaleY=screenHeight / this.desginHeight; + var canvasWidth=this.desginWidth; + var canvasHeight=this.desginHeight; + var realWidth=screenWidth; + var realHeight=screenHeight; + var pixelRatio=Browser.pixelRatio; + this._width=this.desginWidth; + this._height=this.desginHeight; + switch (scaleMode){ + case "noscale": + scaleX=scaleY=1; + realWidth=this.desginWidth; + realHeight=this.desginHeight; + break ; + case "showall": + scaleX=scaleY=Math.min(scaleX,scaleY); + canvasWidth=realWidth=Math.round(this.desginWidth *scaleX); + canvasHeight=realHeight=Math.round(this.desginHeight *scaleY); + break ; + case "noborder": + scaleX=scaleY=Math.max(scaleX,scaleY); + realWidth=Math.round(this.desginWidth *scaleX); + realHeight=Math.round(this.desginHeight *scaleY); + break ; + case "full": + scaleX=scaleY=1; + this._width=canvasWidth=screenWidth; + this._height=canvasHeight=screenHeight; + break ; + case "fixedwidth": + scaleY=scaleX; + this._height=screenHeight / scaleX; + canvasHeight=Math.round(screenHeight / scaleX); + break ; + case "fixedheight": + scaleX=scaleY; + this._width=screenWidth / scaleY; + canvasWidth=Math.round(screenWidth / scaleY); + break ; + } + scaleX *=this.scaleX; + scaleY *=this.scaleY; + if (scaleX===1 && scaleY===1){ + this.transform.identity(); + }else { + this.transform.a=this._formatData(scaleX / (realWidth / canvasWidth)); + this.transform.d=this._formatData(scaleY / (realHeight / canvasHeight)); + this.model && this.model.scale(this.transform.a,this.transform.d); + } + canvas.size(canvasWidth,canvasHeight); + RunDriver.changeWebGLSize(canvasWidth,canvasHeight); + mat.scale(realWidth / canvasWidth / pixelRatio,realHeight / canvasHeight / pixelRatio); + if (this._alignH==="left")this.offset.x=0; + else if (this._alignH==="right")this.offset.x=screenWidth-realWidth; + else this.offset.x=(screenWidth-realWidth)*0.5 / pixelRatio; + if (this._alignV==="top")this.offset.y=0; + else if (this._alignV==="bottom")this.offset.y=screenHeight-realHeight; + else this.offset.y=(screenHeight-realHeight)*0.5 / pixelRatio; + this.offset.x=Math.round(this.offset.x); + this.offset.y=Math.round(this.offset.y); + mat.translate(this.offset.x,this.offset.y); + if (this._safariOffsetY && parseInt(canvasStyle.top)===0)canvasStyle.top=this._safariOffsetY+"px"; + this.canvasDegree=0; + if (rotation){ + if (this._screenMode==="horizontal"){ + mat.rotate(Math.PI / 2); + mat.translate(screenHeight / pixelRatio,0); + this.canvasDegree=90; + }else { + mat.rotate(-Math.PI / 2); + mat.translate(0,screenWidth / pixelRatio); + this.canvasDegree=-90; + } + } + mat.a=this._formatData(mat.a); + mat.d=this._formatData(mat.d); + mat.tx=this._formatData(mat.tx); + mat.ty=this._formatData(mat.ty); + canvasStyle.transformOrigin=canvasStyle.webkitTransformOrigin=canvasStyle.msTransformOrigin=canvasStyle.mozTransformOrigin=canvasStyle.oTransformOrigin="0px 0px 0px"; + canvasStyle.transform=canvasStyle.webkitTransform=canvasStyle.msTransform=canvasStyle.mozTransform=canvasStyle.oTransform="matrix("+mat.toString()+")"; + mat.translate(parseInt(canvasStyle.left)|| 0,parseInt(canvasStyle.top)|| 0); + this.visible=true; + this._repaint=1; + this.event(/*laya.events.Event.RESIZE*/"resize"); + } + + __proto._formatData=function(value){ + if (Math.abs(value)< 0.000001)return 0; + if (Math.abs(1-value)< 0.001)return value > 0 ? 1 :-1; + return value; + } + + /**@inheritDoc */ + __proto.getMousePoint=function(){ + return Point.TEMP.setTo(this.mouseX,this.mouseY); + } + + /**@inheritDoc */ + __proto.repaint=function(){ + this._repaint=1; + } + + /**@inheritDoc */ + __proto.parentRepaint=function(){} + /**@private */ + __proto._loop=function(){ + this.render(Render.context,0,0); + return true; + } + + /**@private */ + __proto._onmouseMove=function(e){ + this._mouseMoveTime=Browser.now(); + } + + /**获得距当前帧开始后,过了多少时间,单位为毫秒 + *可以用来判断函数内时间消耗,控制每帧函数处理消耗的时间过长,导致帧率下降*/ + __proto.getTimeFromFrameStart=function(){ + return Browser.now()-this._frameStartTime; + } + + /**@inheritDoc */ + __proto.render=function(context,x,y){ + if (this.frameRate==="sleep"){ + var now=Browser.now(); + if (now-this._frameStartTime >=1000)this._frameStartTime=now; + else return; + } + this._renderCount++; + Render.isFlash && this.repaint(); + if (!this.visible){ + if (this._renderCount % 5===0){ + Stat.loopCount++; + MouseManager.instance.runEvent(); + Laya.timer._update(); + } + return; + } + this._frameStartTime=Browser.now(); + var frameMode=this.frameRate==="mouse" ? (((this._frameStartTime-this._mouseMoveTime)< 2000)? "fast" :"slow"):this.frameRate; + var isFastMode=(frameMode!=="slow"); + var isDoubleLoop=(this._renderCount % 2===0); + Stat.renderSlow=!isFastMode; + if (isFastMode || isDoubleLoop){ + Stat.loopCount++; + MouseManager.instance.runEvent(); + Laya.timer._update(); + var i=0,n=0; + for (i=0,n=this._scenes.length;i < n;i++){ + var scene=this._scenes[i]; + (scene)&& (scene._updateScene()); + } + if (Render.isConchNode){ + var customList=Sprite.CustomList; + for (i=0,n=customList.length;i < n;i++){ + var customItem=customList[i]; + customItem.customRender(customItem.customContext,0,0); + } + return; + } + if (Render.isWebGL && this.renderingEnabled){ + context.clear(); + _super.prototype.render.call(this,context,x,y); + } + } + if (Render.isConchNode)return; + if (this.renderingEnabled && (isFastMode || !isDoubleLoop)){ + if (Render.isWebGL){ + RunDriver.clear(this._bgColor); + RunDriver.beginFlush(); + context.flush(); + RunDriver.endFinish(); + VectorGraphManager.instance && VectorGraphManager.getInstance().endDispose(); + }else { + RunDriver.clear(this._bgColor); + _super.prototype.render.call(this,context,x,y); + } + } + } + + /**@private */ + __proto._requestFullscreen=function(){ + var element=Browser.document.documentElement; + if (element.requestFullscreen){ + element.requestFullscreen(); + }else if (element.mozRequestFullScreen){ + element.mozRequestFullScreen(); + }else if (element.webkitRequestFullscreen){ + element.webkitRequestFullscreen(); + }else if (element.msRequestFullscreen){ + element.msRequestFullscreen(); + } + } + + /**@private */ + __proto._fullScreenChanged=function(){ + Laya.stage.event(/*laya.events.Event.FULL_SCREEN_CHANGE*/"fullscreenchange"); + } + + /**退出全屏*/ + __proto.exitFullscreen=function(){ + var document=Browser.document; + if (document.exitFullscreen){ + document.exitFullscreen(); + }else if (document.mozCancelFullScreen){ + document.mozCancelFullScreen(); + }else if (document.webkitExitFullscreen){ + document.webkitExitFullscreen(); + } + } + + /**鼠标在 Stage 上的 Y 轴坐标。*/ + __getset(0,__proto,'mouseY',function(){ + return Math.round(MouseManager.instance.mouseY / this.clientScaleY); + }); + + /**当前视窗由缩放模式导致的 Y 轴缩放系数。*/ + __getset(0,__proto,'clientScaleY',function(){ + return this._transform ? this._transform.getScaleY():1; + }); + + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + this.desginWidth=value; + _super.prototype._$set_width.call(this,value); + Laya.timer.callLater(this,this._changeCanvasSize); + }); + + /** + *水平对齐方式。 + *

      取值范围: + *
    • "left" :居左对齐;
    • + *
    • "center" :居中对齐;
    • + *
    • "right" :居右对齐;
    • + *

    + *默认值为"left"。 + */ + __getset(0,__proto,'alignH',function(){ + return this._alignH; + },function(value){ + this._alignH=value; + Laya.timer.callLater(this,this._changeCanvasSize); + }); + + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + this.desginHeight=value; + _super.prototype._$set_height.call(this,value); + Laya.timer.callLater(this,this._changeCanvasSize); + }); + + /** + *

    缩放模式。

    + *

      取值范围: + *
    • "noscale" :不缩放;
    • + *
    • "exactfit" :全屏不等比缩放;
    • + *
    • "showall" :最小比例缩放;
    • + *
    • "noborder" :最大比例缩放;
    • + *
    • "full" :不缩放,stage的宽高等于屏幕宽高;
    • + *
    • "fixedwidth" :宽度不变,高度根据屏幕比缩放;
    • + *
    • "fixedheight" :高度不变,宽度根据屏幕比缩放;
    • + *

    + *默认值为 "noscale"。 + */ + __getset(0,__proto,'scaleMode',function(){ + return this._scaleMode; + },function(value){ + this._scaleMode=value; + Laya.timer.callLater(this,this._changeCanvasSize); + }); + + /** + *垂直对齐方式。 + *

      取值范围: + *
    • "top" :居顶部对齐;
    • + *
    • "middle" :居中对齐;
    • + *
    • "bottom" :居底部对齐;
    • + *

    + */ + __getset(0,__proto,'alignV',function(){ + return this._alignV; + },function(value){ + this._alignV=value; + Laya.timer.callLater(this,this._changeCanvasSize); + }); + + /**舞台的背景颜色,默认为黑色,null为透明。*/ + __getset(0,__proto,'bgColor',function(){ + return this._bgColor; + },function(value){ + this._bgColor=value; + this.model && this.model.bgColor(value); + if (value){ + Render.canvas.style.background=value; + }else { + Render.canvas.style.background="none"; + } + }); + + /**当前视窗由缩放模式导致的 X 轴缩放系数。*/ + __getset(0,__proto,'clientScaleX',function(){ + return this._transform ? this._transform.getScaleX():1; + }); + + /**鼠标在 Stage 上的 X 轴坐标。*/ + __getset(0,__proto,'mouseX',function(){ + return Math.round(MouseManager.instance.mouseX / this.clientScaleX); + }); + + /** + *场景布局类型。 + *

      取值范围: + *
    • "none" :不更改屏幕
    • + *
    • "horizontal" :自动横屏
    • + *
    • "vertical" :自动竖屏
    • + *

    + */ + __getset(0,__proto,'screenMode',function(){ + return this._screenMode; + },function(value){ + this._screenMode=value; + }); + + __getset(0,__proto,'visible',_super.prototype._$get_visible,function(value){ + if (this.visible!==value){ + _super.prototype._$set_visible.call(this,value); + var style=Render._mainCanvas.source.style; + style.visibility=value ? "visible" :"hidden"; + } + }); + + /**是否开启全屏,用户点击后进入全屏*/ + __getset(0,__proto,'fullScreenEnabled',null,function(value){ + var document=Browser.document; + var canvas=Render.canvas; + if (value){ + canvas.addEventListener('mousedown',this._requestFullscreen); + canvas.addEventListener('touchstart',this._requestFullscreen); + document.addEventListener("fullscreenchange",this._fullScreenChanged); + document.addEventListener("mozfullscreenchange",this._fullScreenChanged); + document.addEventListener("webkitfullscreenchange",this._fullScreenChanged); + document.addEventListener("msfullscreenchange",this._fullScreenChanged); + }else { + canvas.removeEventListener('mousedown',this._requestFullscreen); + canvas.removeEventListener('touchstart',this._requestFullscreen); + document.removeEventListener("fullscreenchange",this._fullScreenChanged); + document.removeEventListener("mozfullscreenchange",this._fullScreenChanged); + document.removeEventListener("webkitfullscreenchange",this._fullScreenChanged); + document.removeEventListener("msfullscreenchange",this._fullScreenChanged); + } + }); + + Stage.SCALE_NOSCALE="noscale"; + Stage.SCALE_EXACTFIT="exactfit"; + Stage.SCALE_SHOWALL="showall"; + Stage.SCALE_NOBORDER="noborder"; + Stage.SCALE_FULL="full"; + Stage.SCALE_FIXED_WIDTH="fixedwidth"; + Stage.SCALE_FIXED_HEIGHT="fixedheight"; + Stage.ALIGN_LEFT="left"; + Stage.ALIGN_RIGHT="right"; + Stage.ALIGN_CENTER="center"; + Stage.ALIGN_TOP="top"; + Stage.ALIGN_MIDDLE="middle"; + Stage.ALIGN_BOTTOM="bottom"; + Stage.SCREEN_NONE="none"; + Stage.SCREEN_HORIZONTAL="horizontal"; + Stage.SCREEN_VERTICAL="vertical"; + Stage.FRAME_FAST="fast"; + Stage.FRAME_SLOW="slow"; + Stage.FRAME_MOUSE="mouse"; + Stage.FRAME_SLEEP="sleep"; + return Stage; + })(Sprite) + + + //class laya.media.SoundNode extends laya.display.Sprite + var SoundNode=(function(_super){ + function SoundNode(){ + this.url=null; + this._channel=null; + this._tar=null; + this._playEvents=null; + this._stopEvents=null; + SoundNode.__super.call(this); + this.visible=false; + this.on(/*laya.events.Event.ADDED*/"added",this,this._onParentChange); + this.on(/*laya.events.Event.REMOVED*/"removed",this,this._onParentChange); + } + + __class(SoundNode,'laya.media.SoundNode',_super); + var __proto=SoundNode.prototype; + /**@private */ + __proto._onParentChange=function(){ + this.target=this.parent; + } + + /** + *播放 + *@param loops 循环次数 + *@param complete 完成回调 + * + */ + __proto.play=function(loops,complete){ + (loops===void 0)&& (loops=1); + if (isNaN(loops)){ + loops=1; + } + if (!this.url)return; + this.stop(); + this._channel=SoundManager.playSound(this.url,loops,complete); + } + + /** + *停止播放 + * + */ + __proto.stop=function(){ + if (this._channel && !this._channel.isStopped){ + this._channel.stop(); + } + this._channel=null; + } + + /**@private */ + __proto._setPlayAction=function(tar,event,action,add){ + (add===void 0)&& (add=true); + if (!this[action])return; + if (!tar)return; + if (add){ + tar.on(event,this,this[action]); + }else { + tar.off(event,this,this[action]); + } + } + + /**@private */ + __proto._setPlayActions=function(tar,events,action,add){ + (add===void 0)&& (add=true); + if (!tar)return; + if (!events)return; + var eventArr=events.split(","); + var i=0,len=0; + len=eventArr.length; + for (i=0;i < len;i++){ + this._setPlayAction(tar,eventArr[i],action,add); + } + } + + /** + *设置触发播放的事件 + *@param events + * + */ + __getset(0,__proto,'playEvent',null,function(events){ + this._playEvents=events; + if (!events)return; + if (this._tar){ + this._setPlayActions(this._tar,events,"play"); + } + }); + + /** + *设置控制播放的对象 + *@param tar + * + */ + __getset(0,__proto,'target',null,function(tar){ + if (this._tar){ + this._setPlayActions(this._tar,this._playEvents,"play",false); + this._setPlayActions(this._tar,this._stopEvents,"stop",false); + } + this._tar=tar; + if (this._tar){ + this._setPlayActions(this._tar,this._playEvents,"play",true); + this._setPlayActions(this._tar,this._stopEvents,"stop",true); + } + }); + + /** + *设置触发停止的事件 + *@param events + * + */ + __getset(0,__proto,'stopEvent',null,function(events){ + this._stopEvents=events; + if (!events)return; + if (this._tar){ + this._setPlayActions(this._tar,events,"stop"); + } + }); + + return SoundNode; + })(Sprite) + + + //class laya.scene.Scene2D extends laya.display.Sprite + var Scene2D=(function(_super){ + function Scene2D(){ + Scene2D.__super.call(this); + this.createChildren(); + } + + __class(Scene2D,'laya.scene.Scene2D',_super); + var __proto=Scene2D.prototype; + /** + *

    创建并添加控件子节点。

    + *@internal 子类可在此函数内创建并添加子节点。 + */ + __proto.createChildren=function(){} + __proto.createView=function(sceneData){ + ClassUtils.createByJson(sceneData,this,this); + } + + return Scene2D; + })(Sprite) + + + /** + *@private + *FileBitmap 是图片文件资源类。 + */ + //class laya.resource.FileBitmap extends laya.resource.Bitmap + var FileBitmap=(function(_super){ + function FileBitmap(){ + this._src=null; + this._onload=null; + this._onerror=null; + FileBitmap.__super.call(this); + } + + __class(FileBitmap,'laya.resource.FileBitmap',_super); + var __proto=FileBitmap.prototype; + /** + *文件路径全名。 + */ + __getset(0,__proto,'src',function(){ + return this._src; + },function(value){ + this._src=value; + }); + + /** + *载入完成处理函数。 + */ + __getset(0,__proto,'onload',null,function(value){ + }); + + /** + *错误处理函数。 + */ + __getset(0,__proto,'onerror',null,function(value){ + }); + + return FileBitmap; + })(Bitmap) + + + /** + *HTMLCanvas 是 Html Canvas 的代理类,封装了 Canvas 的属性和方法。。请不要直接使用 new HTMLCanvas! + */ + //class laya.resource.HTMLCanvas extends laya.resource.Bitmap + var HTMLCanvas=(function(_super){ + function HTMLCanvas(type,canvas){ + //this._ctx=null; + this._is2D=false; + HTMLCanvas.__super.call(this); + var _$this=this; + this._source=this; + if (type==="2D" || (type==="AUTO" && !Render.isWebGL)){ + this._is2D=true; + this._source=canvas || Browser.createElement("canvas"); + var o=this; + o.getContext=function (contextID,other){ + if (_$this._ctx)return _$this._ctx; + var ctx=_$this._ctx=_$this._source.getContext(contextID,other); + if (ctx){ + ctx._canvas=o; + if(!Render.isFlash)ctx.size=function (w,h){ + }; + } + return ctx; + } + } + else this._source={}; + } + + __class(HTMLCanvas,'laya.resource.HTMLCanvas',_super); + var __proto=HTMLCanvas.prototype; + /** + *清空画布内容。 + */ + __proto.clear=function(){ + this._ctx && this._ctx.clear(); + } + + /** + *销毁。 + */ + __proto.destroy=function(){ + this._ctx && this._ctx.destroy(); + this._ctx=null; + } + + /** + *释放。 + */ + __proto.release=function(){} + /** + *@private + *设置 Canvas 渲染上下文。 + *@param context Canvas 渲染上下文。 + */ + __proto._setContext=function(context){ + this._ctx=context; + } + + /** + *获取 Canvas 渲染上下文。 + *@param contextID 上下文ID. + *@param other + *@return Canvas 渲染上下文 Context 对象。 + */ + __proto.getContext=function(contextID,other){ + return this._ctx ? this._ctx :(this._ctx=HTMLCanvas._createContext(this)); + } + + /** + *获取内存大小。 + *@return 内存大小。 + */ + __proto.getMemSize=function(){ + return 0; + } + + /** + *设置宽高。 + *@param w 宽度。 + *@param h 高度。 + */ + __proto.size=function(w,h){ + if (this._w !=w || this._h !=h){ + this._w=w; + this._h=h; + this._ctx && this._ctx.size(w,h); + this._source && (this._source.height=h,this._source.width=w); + } + } + + /** + *Canvas 渲染上下文。 + */ + __getset(0,__proto,'context',function(){ + return this._ctx; + }); + + /** + *是否当作 Bitmap 对象。 + */ + __getset(0,__proto,'asBitmap',null,function(value){ + }); + + HTMLCanvas.create=function(type,canvas){ + return new HTMLCanvas(type,canvas); + } + + HTMLCanvas.TYPE2D="2D"; + HTMLCanvas.TYPE3D="3D"; + HTMLCanvas.TYPEAUTO="AUTO"; + HTMLCanvas._createContext=null + return HTMLCanvas; + })(Bitmap) + + + /** + *@private + */ + //class laya.resource.HTMLSubImage extends laya.resource.Bitmap + var HTMLSubImage=(function(_super){ + //请不要直接使用new HTMLSubImage + function HTMLSubImage(canvas,offsetX,offsetY,width,height,atlasImage,src,allowMerageInAtlas){ + HTMLSubImage.__super.call(this); + throw new Error("不允许new!"); + } + + __class(HTMLSubImage,'laya.resource.HTMLSubImage',_super); + HTMLSubImage.create=function(canvas,offsetX,offsetY,width,height,atlasImage,src,allowMerageInAtlas){ + (allowMerageInAtlas===void 0)&& (allowMerageInAtlas=false); + return new HTMLSubImage(canvas,offsetX,offsetY,width,height,atlasImage,src,allowMerageInAtlas); + } + + return HTMLSubImage; + })(Bitmap) + + + /** + *

    Animation 类是位图动画,用于创建位图动画。

    + *

    Animation 类可以加载并显示一组位图图片,并组成动画进行播放。

    + *@example 以下示例代码,创建了一个 Text 实例。 + *+ *package + *{ + *import laya.display.Animation; + *import laya.net.Loader; + *import laya.utils.Handler; + *public class Animation_Example + *{ + *public function Animation_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *init();//初始化 + *} + *private function init():void + *{ + *var animation:Animation=new Animation();//创建一个 Animation 类的实例对象 animation 。 + *animation.loadAtlas("resource/ani/fighter.json");//加载图集并播放 + *animation.x=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.y=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.interval=50;//设置 animation 对象的动画播放间隔时间,单位:毫秒。 + *animation.play();//播放动画。 + *Laya.stage.addChild(animation);//将 animation 对象添加到显示列表。 + *} + *} + *} + * + *+ *Animation_Example(); + *function Animation_Example(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *init();//初始化 + *} + *function init() + *{ + *var animation=new Laya.Animation();//创建一个 Animation 类的实例对象 animation 。 + *animation.loadAtlas("resource/ani/fighter.json");//加载图集并播放 + *animation.x=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.y=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.interval=50;//设置 animation 对象的动画播放间隔时间,单位:毫秒。 + *animation.play();//播放动画。 + *Laya.stage.addChild(animation);//将 animation 对象添加到显示列表。 + *} + * + *+ *import Animation=laya.display.Animation; + *class Animation_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.init(); + *} + *private init():void { + *var animation:Animation=new Laya.Animation();//创建一个 Animation 类的实例对象 animation 。 + *animation.loadAtlas("resource/ani/fighter.json");//加载图集并播放 + *animation.x=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.y=200;//设置 animation 对象的属性 x 的值,用于控制 animation 对象的显示位置。 + *animation.interval=50;//设置 animation 对象的动画播放间隔时间,单位:毫秒。 + *animation.play();//播放动画。 + *Laya.stage.addChild(animation);//将 animation 对象添加到显示列表。 + *} + *} + *new Animation_Example(); + * + */ + //class laya.display.Animation extends laya.display.AnimationPlayerBase + var Animation=(function(_super){ + function Animation(){ + this._frames=null; + this._url=null; + Animation.__super.call(this); + this._setControlNode(this); + } + + __class(Animation,'laya.display.Animation',_super); + var __proto=Animation.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + this.stop(); + laya.display.Sprite.prototype.destroy.call(this,destroyChild); + this._frames=null; + this._labels=null; + } + + /** + *播放动画。 + *@param start 开始播放的动画索引或label。 + *@param loop 是否循环。 + *@param name 如果name为空(可选),则播放当前动画,如果不为空,则播放全局缓存动画(如果有) + */ + __proto.play=function(start,loop,name){ + (start===void 0)&& (start=0); + (loop===void 0)&& (loop=true); + (name===void 0)&& (name=""); + if (name)this._setFramesFromCache(name); + this._isPlaying=true; + this.index=((typeof start=='string'))? this._getFrameByLabel(start):start; + this.loop=loop; + this._actionName=name; + this._isReverse=this.wrapMode==1; + if (this._frames && this.interval > 0){ + this.timerLoop(this.interval,this,this._frameLoop,null,true); + } + } + + __proto._setFramesFromCache=function(name){ + if (this._url)name=this._url+"#"+name; + if (name && Animation.framesMap[name]){ + this._frames=Animation.framesMap[name]; + this._count=this._frames.length; + if (!this._frameRateChanged && Animation.framesMap[name+"$len"])this._interval=Animation.framesMap[name+"$len"]; + return true; + } + return false; + } + + __proto._frameLoop=function(){ + if (this._style.visible && this._style.alpha > 0.01){ + _super.prototype._frameLoop.call(this); + } + } + + __proto._displayToIndex=function(value){ + if (this._frames)this.graphics=this._frames[value]; + } + + /**清理。方便对象复用。*/ + __proto.clear=function(){ + this.stop(); + this.graphics=null; + this._frames=null; + this._labels=null; + } + + /** + *加载图片集合,组成动画。 + *@param urls 图片地址集合。如:[url1,url2,url3,...]。 + *@param cacheName 缓存为模板的名称,下次可以直接使用play调用,无需重新创建动画模板,设置为空则不缓存 + *@return 返回动画本身。 + */ + __proto.loadImages=function(urls,cacheName){ + (cacheName===void 0)&& (cacheName=""); + this._url=""; + if (!this._setFramesFromCache(cacheName)){ + this.frames=Animation.framesMap[cacheName] ? Animation.framesMap[cacheName] :Animation.createFrames(urls,cacheName); + } + return this; + } + + /** + *加载并播放一个图集。 + *@param url 图集地址。 + *@param loaded 加载完毕回调 + *@param cacheName 缓存为模板的名称,下次可以直接使用play调用,无需重新创建动画模板,设置为空则不缓存 + *@return 返回动画本身。 + */ + __proto.loadAtlas=function(url,loaded,cacheName){ + (cacheName===void 0)&& (cacheName=""); + this._url=""; + var _this=this; + if (!_this._setFramesFromCache(cacheName)){ + function onLoaded (loadUrl){ + if (url===loadUrl){ + _this.frames=Animation.framesMap[cacheName] ? Animation.framesMap[cacheName] :Animation.createFrames(url,cacheName); + if (loaded)loaded.run(); + } + } + if (Loader.getAtlas(url))onLoaded(url); + else Laya.loader.load(url,Handler.create(null,onLoaded,[url]),null,/*laya.net.Loader.ATLAS*/"atlas"); + } + return this; + } + + /** + *加载并播放一个由IDE制作的动画,播放的帧率按照IDE设计的帧率 + *@param url 动画地址。 + *@param loaded 加载完毕回调 + *@return 返回动画本身。 + */ + __proto.loadAnimation=function(url,loaded){ + this._url=url; + var _this=this; + if (!_this._setFramesFromCache("")){ + function onLoaded (loadUrl){ + if (url===loadUrl){ + if (!Animation.framesMap[url+"#"]){ + var aniData=_this._parseGraphicAnimation(Loader.getRes(url)); + if (!aniData)return; + var obj=aniData.animationDic; + var flag=true; + for (var name in obj){ + var info=obj[name]; + if (info.frames.length){ + Animation.framesMap[url+"#"+name]=info.frames; + Animation.framesMap[url+"#"+name+"$len"]=info.interval; + }else { + flag=false; + } + } + if(!_this._frameRateChanged)_this._interval=aniData.animationList[0].interval; + _this.frames=aniData.animationList[0].frames; + if (flag){ + Animation.framesMap[url+"#$len"]=aniData.animationList[0].interval; + Animation.framesMap[url+"#"]=_this.frames; + } + }else { + if(!_this._frameRateChanged)_this._interval=Animation.framesMap[url+"#$len"]; + _this.frames=Animation.framesMap[url+"#"]; + } + if (loaded)loaded.run(); + } + } + if (Loader.getRes(url))onLoaded(url); + else Laya.loader.load(url,Handler.create(null,onLoaded,[url]),null,/*laya.net.Loader.JSON*/"json"); + Loader.clearRes(url); + } + return this; + } + + /**@private */ + __proto._parseGraphicAnimation=function(animationData){ + return GraphicAnimation.parseAnimationData(animationData) + } + + /**Graphics集合*/ + __getset(0,__proto,'frames',function(){ + return this._frames; + },function(value){ + this._frames=value; + if (value){ + this._count=value.length; + if (this._isPlaying)this.play(this._index,this.loop,this._actionName); + else this.index=this._index; + } + }); + + /**是否自动播放*/ + __getset(0,__proto,'autoPlay',null,function(value){ + if (value)this.play(); + else this.stop(); + }); + + /**图集地址或者图片集合*/ + __getset(0,__proto,'source',null,function(value){ + if (value.indexOf(".ani")>-1)this.loadAnimation(value); + else if (value.indexOf(".json")>-1 || value.indexOf("als")>-1)this.loadAtlas(value); + else this.loadImages(value.split(",")); + }); + + Animation.createFrames=function(url,name){ + var arr; + if ((typeof url=='string')){ + var atlas=Loader.getAtlas(url); + if (atlas && atlas.length){ + arr=[]; + for (var i=0,n=atlas.length;i < n;i++){ + var g=new Graphics(); + g.drawTexture(Loader.getRes(atlas[i]),0,0); + arr.push(g); + } + } + }else if ((url instanceof Array)){ + arr=[]; + for (i=0,n=url.length;i < n;i++){ + g=new Graphics(); + g.loadImage(url[i],0,0); + arr.push(g); + } + } + if (name)Animation.framesMap[name]=arr; + return arr; + } + + Animation.clearCache=function(key){ + var cache=Animation.framesMap; + var val; + var key2=key+"#"; + for (val in cache){ + if (val===key || val.indexOf(key2)==0){ + delete Animation.framesMap[val]; + } + } + } + + Animation.framesMap={}; + return Animation; + })(AnimationPlayerBase) + + + /** + *关键帧动画播放类 + * + */ + //class laya.display.FrameAnimation extends laya.display.AnimationPlayerBase + var FrameAnimation=(function(_super){ + function FrameAnimation(){ + this._targetDic=null; + this._animationData=null; + FrameAnimation.__super.call(this); + if(FrameAnimation._sortIndexFun==null){ + FrameAnimation._sortIndexFun=MathUtil.sortByKey("index",false,true); + } + } + + __class(FrameAnimation,'laya.display.FrameAnimation',_super); + var __proto=FrameAnimation.prototype; + /** + *@private + *初始化动画数据 + *@param targetDic 对象表 + *@param animationData 动画数据 + * + */ + __proto._setUp=function(targetDic,animationData){ + this._labels=null; + this._targetDic=targetDic; + this._animationData=animationData; + this.interval=1000 / animationData.frameRate; + if (animationData.parsed){ + this._count=animationData.count; + }else{ + this._calculateDatas(); + } + animationData.parsed=true; + animationData.count=this._count; + } + + /**@inheritDoc */ + __proto.clear=function(){ + _super.prototype.clear.call(this); + this._targetDic=null; + this._animationData=null; + } + + /**@inheritDoc */ + __proto._displayToIndex=function(value){ + if(!this._animationData)return; + if(value<0)value=0; + if(value>this._count)value=this._count; + var nodes=this._animationData.nodes,i=0,len=nodes.length; + for(i=0;iframe){ + value=propFrames[frame]; + }else{ + value=propFrames[propFrames.length-1]; + } + target[key]=value; + } + } + + /** + *@private + *计算帧数据 + * + */ + __proto._calculateDatas=function(){ + if(!this._animationData)return; + var nodes=this._animationData.nodes,i=0,len=nodes.length,tNode; + this._count=0; + for(i=0;ithis._count)this._count=end; + if(startFrame.tween){ + easeFun=Ease[startFrame.tweenMethod]; + if(easeFun==null){ + easeFun=Ease.linearNone; + } + for(i=start;iInput 类用于创建显示对象以显示和输入文本。

    + */ + //class laya.display.Input extends laya.display.Text + var Input=(function(_super){ + function Input(){ + this._focus=false; + this._multiline=false; + this._editable=true; + this._restrictPattern=null; + this._type="text"; + this._prompt=''; + this._promptColor="#A9A9A9"; + this._originColor="#000000"; + this._content=''; + Input.__super.call(this); + this._maxChars=1E5; + this._width=100; + this._height=20; + this.multiline=false; + this.overflow=Text.SCROLL; + this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onMouseDown); + this.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onUnDisplay); + } + + __class(Input,'laya.display.Input',_super); + var __proto=Input.prototype; + /** + *设置光标位置和选取字符。 + *@param startIndex 光标起始位置。 + *@param endIndex 光标结束位置。 + */ + __proto.setSelection=function(startIndex,endIndex){ + laya.display.Input.inputElement.selectionStart=startIndex; + laya.display.Input.inputElement.selectionEnd=endIndex; + } + + /**@private */ + __proto._onUnDisplay=function(e){ + this.focus=false; + } + + /**@private */ + __proto._onMouseDown=function(e){ + this.focus=true; + Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._checkBlur); + } + + /**@private */ + __proto._checkBlur=function(e){ + if (e.nativeEvent.target !=laya.display.Input.input && e.nativeEvent.target !=laya.display.Input.area && e.target !=this) + this.focus=false; + } + + /**@inheritDoc*/ + __proto.render=function(context,x,y){ + laya.display.Sprite.prototype.render.call(this,context,x,y); + } + + /** + *在输入期间,如果 Input 实例的位置改变,调用该方法同步输入框的位置。 + */ + __proto._syncInputTransform=function(){ + var style=this.nativeInput.style; + var stage=Laya.stage; + var rec; + rec=Utils.getGlobalPosAndScale(this); + var m=stage._canvasTransform.clone(); + var tm=m.clone(); + tm.rotate(-Math.PI / 180 *Laya.stage.canvasDegree); + tm.scale(Laya.stage.clientScaleX,Laya.stage.clientScaleY); + var perpendicular=(Laya.stage.canvasDegree % 180 !=0); + var sx=perpendicular ? tm.d :tm.a; + var sy=perpendicular ? tm.a :tm.d; + tm.destroy(); + var tx=this.padding[3]; + var ty=this.padding[0]; + if (Laya.stage.canvasDegree==0){ + tx+=rec.x; + ty+=rec.y; + tx *=sx; + ty *=sy; + tx+=m.tx; + ty+=m.ty; + }else if (Laya.stage.canvasDegree==90){ + tx+=rec.y; + ty+=rec.x; + tx *=sx; + ty *=sy; + tx=m.tx-tx; + ty+=m.ty; + }else{ + tx+=rec.y; + ty+=rec.x; + tx *=sx; + ty *=sy; + tx+=m.tx; + ty=m.ty-ty; + }; + var quarter=0.785; + var r=Math.atan2(rec.height,rec.width)-quarter; + var sin=Math.sin(r),cos=Math.cos(r); + var tsx=cos *rec.width+sin *rec.height; + var tsy=cos *rec.height-sin *rec.width; + sx *=(perpendicular ? tsy :tsx); + sy *=(perpendicular ? tsx :tsy); + m.tx=0; + m.ty=0; + r *=180 / 3.1415; + Input.inputContainer.style.transform="scale("+sx+","+sy+") rotate("+(Laya.stage.canvasDegree+r)+"deg)"; + Input.inputContainer.style.webkitTransform="scale("+sx+","+sy+") rotate("+(Laya.stage.canvasDegree+r)+"deg)"; + Input.inputContainer.setPos(tx,ty); + m.destroy(); + var inputWid=this._width-this.padding[1]-this.padding[3]; + var inputHei=this._height-this.padding[0]-this.padding[2]; + this.nativeInput.setSize(inputWid,inputHei); + if (Render.isConchApp){ + this.nativeInput.setPos(tx,ty); + this.nativeInput.setScale(sx,sy); + } + } + + /**选中所有文本。*/ + __proto.select=function(){ + this.nativeInput.select(); + } + + /**@private 设置输入法(textarea或input)*/ + __proto._setInputMethod=function(){ + Input.input.parentElement && (Input.inputContainer.removeChild(Input.input)); + Input.area.parentElement && (Input.inputContainer.removeChild(Input.area)); + Input.inputElement=(this._multiline ? Input.area :Input.input); + Input.inputContainer.appendChild(Input.inputElement); + } + + /**@private */ + __proto._focusIn=function(){ + laya.display.Input.isInputting=true; + var input=this.nativeInput; + this._focus=true; + var cssStyle=input.style; + cssStyle.whiteSpace=(this.wordWrap ? "pre-wrap" :"nowrap"); + this._setPromptColor(); + input.readOnly=!this._editable; + input.maxLength=this._maxChars; + var padding=this.padding; + input.type=this._type; + input.value=this._content; + input.placeholder=this._prompt; + Laya.stage.off(/*laya.events.Event.KEY_DOWN*/"keydown",this,this._onKeyDown); + Laya.stage.on(/*laya.events.Event.KEY_DOWN*/"keydown",this,this._onKeyDown); + Laya.stage.focus=this; + this.event(/*laya.events.Event.FOCUS*/"focus"); + if (Browser.onPC)input.focus(); + var temp=this._text; + this._text=null; + this.typeset(); + input.setColor(this._originColor); + input.setFontSize(this.fontSize); + input.setFontFace(this.font); + if (Render.isConchApp){ + input.setMultiAble && input.setMultiAble(this._multiline); + } + cssStyle.lineHeight=(this.leading+this.fontSize)+"px"; + cssStyle.fontStyle=(this.italic ? "italic" :"normal"); + cssStyle.fontWeight=(this.bold ? "bold" :"normal"); + cssStyle.textAlign=this.align; + cssStyle.padding="0 0"; + this._syncInputTransform(); + if (!Render.isConchApp && Browser.onPC) + Laya.timer.frameLoop(1,this,this._syncInputTransform); + } + + // 设置DOM输入框提示符颜色。 + __proto._setPromptColor=function(){ + Input.promptStyleDOM=Browser.getElementById("promptStyle"); + if (!Input.promptStyleDOM){ + Input.promptStyleDOM=Browser.createElement("style"); + Browser.document.head.appendChild(Input.promptStyleDOM); + } + Input.promptStyleDOM.innerText="input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {"+"color:"+this._promptColor+"}"+"input:-moz-placeholder, textarea:-moz-placeholder {"+"color:"+this._promptColor+"}"+"input::-moz-placeholder, textarea::-moz-placeholder {"+"color:"+this._promptColor+"}"+"input:-ms-input-placeholder, textarea:-ms-input-placeholder {"+"color:"+this._promptColor+"}"; + } + + /**@private */ + __proto._focusOut=function(){ + laya.display.Input.isInputting=false; + this._focus=false; + this._text=null; + this._content=this.nativeInput.value; + if (!this._content){ + _super.prototype._$set_text.call(this,this._prompt); + _super.prototype._$set_color.call(this,this._promptColor); + }else { + _super.prototype._$set_text.call(this,this._content); + _super.prototype._$set_color.call(this,this._originColor); + } + Laya.stage.off(/*laya.events.Event.KEY_DOWN*/"keydown",this,this._onKeyDown); + Laya.stage.focus=null; + this.event(/*laya.events.Event.BLUR*/"blur"); + if (Render.isConchApp)this.nativeInput.blur(); + Browser.onPC && Laya.timer.clear(this,this._syncInputTransform); + Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._checkBlur); + } + + /**@private */ + __proto._onKeyDown=function(e){ + if (e.keyCode===13){ + if (Browser.onMobile && !this._multiline) + this.focus=false; + this.event(/*laya.events.Event.ENTER*/"enter"); + } + } + + __proto.changeText=function(text){ + this._content=text; + if (this._focus){ + this.nativeInput.value=text || ''; + this.event(/*laya.events.Event.CHANGE*/"change"); + }else + _super.prototype.changeText.call(this,text); + } + + /**@inheritDoc */ + __getset(0,__proto,'color',_super.prototype._$get_color,function(value){ + if (this._focus) + this.nativeInput.setColor(value); + _super.prototype._$set_color.call(this,this._content?value:this._promptColor); + this._originColor=value; + }); + + //[Deprecated] + __getset(0,__proto,'inputElementYAdjuster',function(){ + console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementYAdjuster已弃用。"); + return 0; + },function(value){ + console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementYAdjuster已弃用。"); + }); + + /**表示是否是多行输入框。*/ + __getset(0,__proto,'multiline',function(){ + return this._multiline; + },function(value){ + this._multiline=value; + this.valign=value ? "top" :"middle"; + }); + + /** + *字符数量限制,默认为10000。 + *设置字符数量限制时,小于等于0的值将会限制字符数量为10000。 + */ + __getset(0,__proto,'maxChars',function(){ + return this._maxChars; + },function(value){ + if (value <=0) + value=1E5; + this._maxChars=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'text',function(){ + if (this._focus) + return this.nativeInput.value; + else + return this._content || ""; + },function(value){ + _super.prototype._$set_color.call(this,this._originColor); + value+=''; + if (this._focus){ + this.nativeInput.value=value || ''; + this.event(/*laya.events.Event.CHANGE*/"change"); + }else { + if (!this._multiline) + value=value.replace(/\r?\n/g,''); + this._content=value; + if (value) + _super.prototype._$set_text.call(this,value); + else { + _super.prototype._$set_text.call(this,this._prompt); + _super.prototype._$set_color.call(this,this.promptColor); + } + } + }); + + /** + *获取对输入框的引用实例。 + */ + __getset(0,__proto,'nativeInput',function(){ + return this._multiline ? Input.area :Input.input; + }); + + /** + *设置输入提示符。 + */ + __getset(0,__proto,'prompt',function(){ + return this._prompt; + },function(value){ + if (!this._text && value) + _super.prototype._$set_color.call(this,this._promptColor); + this.promptColor=this._promptColor; + if (this._text) + _super.prototype._$set_text.call(this,(this._text==this._prompt)?value:this._text); + else + _super.prototype._$set_text.call(this,value); + this._prompt=value; + }); + + // 因此 调用focus接口是无法都在移动平台立刻弹出键盘的 + /** + *表示焦点是否在显示对象上。 + */ + __getset(0,__proto,'focus',function(){ + return this._focus; + },function(value){ + var input=this.nativeInput; + if (this._focus!==value){ + if (value){ + input.target && (input.target.focus=false); + input.target=this; + this._setInputMethod(); + this._focusIn(); + }else { + input.target=null; + this._focusOut(); + input.blur(); + if (Render.isConchApp){ + input.setPos(-10000,-10000); + }else if (Input.inputContainer.contains(input)) + Input.inputContainer.removeChild(input); + } + } + }); + + /**限制输入的字符。*/ + __getset(0,__proto,'restrict',function(){ + if (this._restrictPattern){ + return this._restrictPattern.source; + } + return ""; + },function(pattern){ + if (pattern){ + pattern="[^"+pattern+"]"; + if (pattern.indexOf("^^")>-1) + pattern=pattern.replace("^^",""); + this._restrictPattern=new RegExp(pattern,"g"); + }else + this._restrictPattern=null; + }); + + /** + *是否可编辑。 + */ + __getset(0,__proto,'editable',function(){ + return this._editable; + },function(value){ + this._editable=value; + }); + + /** + *设置输入提示符颜色。 + */ + __getset(0,__proto,'promptColor',function(){ + return this._promptColor; + },function(value){ + this._promptColor=value; + if (!this._content)_super.prototype._$set_color.call(this,value); + }); + + /** + *输入框类型为Input静态常量之一。 + *平台兼容性参见http://www.w3school.com.cn/html5/html_5_form_input_types.asp。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + },function(value){ + if (value=="password") + this._getCSSStyle().password=true; + else + this._getCSSStyle().password=false; + this._type=value; + }); + + //[Deprecated] + __getset(0,__proto,'inputElementXAdjuster',function(){ + console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementXAdjuster已弃用。"); + return 0; + },function(value){ + console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementXAdjuster已弃用。"); + }); + + //[Deprecated(replacement="Input.type")] + __getset(0,__proto,'asPassword',function(){ + return this._getCSSStyle().password; + },function(value){ + this._getCSSStyle().password=value; + this._type=/*CLASS CONST:laya.display.Input.TYPE_PASSWORD*/"password"; + console.warn("deprecated: 使用type=\"password\"替代设置asPassword, asPassword将在下次重大更新时删去"); + this.isChanged=true; + }); + + Input.__init__=function(){ + Input._createInputElement(); + if (Browser.onMobile) + Render.canvas.addEventListener(Input.IOS_IFRAME ? "click" :"touchend",Input._popupInputMethod); + } + + Input._popupInputMethod=function(e){ + if (!laya.display.Input.isInputting)return; + var input=laya.display.Input.inputElement; + input.focus(); + } + + Input._createInputElement=function(){ + Input._initInput(Input.area=Browser.createElement("textarea")); + Input._initInput(Input.input=Browser.createElement("input")); + Input.inputContainer=Browser.createElement("div"); + Input.inputContainer.style.position="absolute"; + Input.inputContainer.style.zIndex=1E5; + Browser.container.appendChild(Input.inputContainer); + Input.inputContainer.setPos=function (x,y){Input.inputContainer.style.left=x+'px';Input.inputContainer.style.top=y+'px';}; + } + + Input._initInput=function(input){ + var style=input.style; + style.cssText="position:absolute;overflow:hidden;resize:none;transform-origin:0 0;-webkit-transform-origin:0 0;-moz-transform-origin:0 0;-o-transform-origin:0 0;"; + style.resize='none'; + style.backgroundColor='transparent'; + style.border='none'; + style.outline='none'; + style.zIndex=1; + input.addEventListener('input',Input._processInputting); + input.addEventListener('mousemove',Input._stopEvent); + input.addEventListener('mousedown',Input._stopEvent); + input.addEventListener('touchmove',Input._stopEvent); + if(!Render.isConchApp){ + input.setColor=function (color){input.style.color=color;}; + input.setFontSize=function (fontSize){input.style.fontSize=fontSize+'px';}; + input.setSize=function (w,h){input.style.width=w+'px';input.style.height=h+'px';}; + } + input.setFontFace=function (fontFace){input.style.fontFamily=fontFace;}; + } + + Input._processInputting=function(e){ + var input=laya.display.Input.inputElement.target; + if (!input)return; + var value=laya.display.Input.inputElement.value; + if (input._restrictPattern){ + value=value.replace(/\u2006|\x27/g,""); + if (input._restrictPattern.test(value)){ + value=value.replace(input._restrictPattern,""); + laya.display.Input.inputElement.value=value; + } + } + input._text=value; + input.event(/*laya.events.Event.INPUT*/"input"); + } + + Input._stopEvent=function(e){ + if (e.type=='touchmove') + e.preventDefault(); + e.stopPropagation && e.stopPropagation(); + } + + Input.TYPE_TEXT="text"; + Input.TYPE_PASSWORD="password"; + Input.TYPE_EMAIL="email"; + Input.TYPE_URL="url"; + Input.TYPE_NUMBER="number"; + Input.TYPE_RANGE="range"; + Input.TYPE_DATE="date"; + Input.TYPE_MONTH="month"; + Input.TYPE_WEEK="week"; + Input.TYPE_TIME="time"; + Input.TYPE_DATE_TIME="datetime"; + Input.TYPE_DATE_TIME_LOCAL="datetime-local"; + Input.TYPE_SEARCH="search"; + Input.input=null + Input.area=null + Input.inputElement=null + Input.inputContainer=null + Input.confirmButton=null + Input.promptStyleDOM=null + Input.inputHeight=45; + Input.isInputting=false; + __static(Input, + ['IOS_IFRAME',function(){return this.IOS_IFRAME=(Browser.onIOS && Browser.window.top !=Browser.window.self);} + ]); + return Input; + })(Text) + + + /** + *HTMLImage 用于创建 HTML Image 元素。 + *@private + */ + //class laya.resource.HTMLImage extends laya.resource.FileBitmap + var HTMLImage=(function(_super){ + function HTMLImage(src,def){ + this._recreateLock=false; + this._needReleaseAgain=false; + HTMLImage.__super.call(this); + this._init_(src,def); + } + + __class(HTMLImage,'laya.resource.HTMLImage',_super); + var __proto=HTMLImage.prototype; + __proto._init_=function(src,def){ + this._src=src; + this._source=new Browser.window.Image(); + if (def){ + def.onload && (this.onload=def.onload); + def.onerror && (this.onerror=def.onerror); + def.onCreate && def.onCreate(this); + } + if (src.indexOf("data:image")!=0)this._source.crossOrigin=""; + (src)&& (this._source.src=src); + } + + /** + *@inheritDoc + */ + __proto.recreateResource=function(){ + var _$this=this; + if (this._src==="") + throw new Error("src no null!"); + this._needReleaseAgain=false; + if (!this._source){ + this._recreateLock=true; + this.startCreate(); + var _this=this; + this._source=new Browser.window.Image(); + this._source.crossOrigin=""; + this._source.onload=function (){ + if (_this._needReleaseAgain){ + _this._needReleaseAgain=false; + _this._source.onload=null; + _this._source=null; + return; + } + _this._source.onload=null; + _this.memorySize=_$this._w *_$this._h *4; + _this._recreateLock=false; + _this.completeCreate(); + }; + this._source.src=this._src; + }else { + if (this._recreateLock) + return; + this.startCreate(); + this.memorySize=this._w *this._h *4; + this._recreateLock=false; + this.completeCreate(); + } + } + + /** + *@inheritDoc + */ + __proto.detoryResource=function(){ + if (this._recreateLock) + this._needReleaseAgain=true; + (this._source)&& (this._source=null,this.memorySize=0); + } + + /***调整尺寸。*/ + __proto.onresize=function(){ + this._w=this._source.width; + this._h=this._source.height; + } + + /** + *@inheritDoc + */ + __getset(0,__proto,'onload',null,function(value){ + var _$this=this; + this._onload=value; + this._source && (this._source.onload=this._onload !=null ? (function(){ + _$this.onresize(); + _$this._onload(); + }):null); + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'onerror',null,function(value){ + var _$this=this; + this._onerror=value; + this._source && (this._source.onerror=this._onerror !=null ? (function(){ + _$this._onerror() + }):null); + }); + + HTMLImage.create=function(src,def){ + return new HTMLImage(src,def); + } + + return HTMLImage; + })(FileBitmap) + + + /** + *@private + */ + //class laya.display.GraphicAnimation extends laya.display.FrameAnimation + var GraphicAnimation=(function(_super){ + function GraphicAnimation(){ + this.animationList=null; + this.animationDic=null; + this._nodeList=null; + this._nodeDefaultProps=null; + this._gList=null; + this._nodeIDAniDic={}; + GraphicAnimation.__super.call(this); + } + + __class(GraphicAnimation,'laya.display.GraphicAnimation',_super); + var __proto=GraphicAnimation.prototype; + /** + *@private + */ + __proto._parseNodeList=function(uiView){ + if (!this._nodeList){ + this._nodeList=[]; + } + this._nodeDefaultProps[uiView.compId]=uiView.props; + if (uiView.compId) + this._nodeList.push(uiView.compId); + var childs=uiView.child; + if (childs){ + var i=0,len=childs.length; + for (i=0;i < len;i++){ + this._parseNodeList(childs[i]); + } + } + } + + /** + *@private + */ + __proto._calGraphicData=function(aniData){ + this._setUp(null,aniData); + this._createGraphicData(); + } + + /** + *@private + */ + __proto._createGraphicData=function(){ + var gList=[]; + var i=0,len=this.count; + for (i=0;i < len;i++){ + gList.push(this._createFrameGraphic(i)); + } + this._gList=gList; + } + + /** + *@private + */ + __proto._createFrameGraphic=function(frame){ + var g=new Graphics(); + var i=0,len=this._nodeList.length; + var tNode=0; + for (i=0;i < len;i++){ + tNode=this._nodeList[i]; + this._addNodeGraphic(tNode,g,frame); + } + return g; + } + + /** + *@private + */ + __proto._calculateNodeKeyFrames=function(node){ + _super.prototype._calculateNodeKeyFrames.call(this,node); + this._nodeIDAniDic[node.target]=node; + } + + /** + *@private + */ + __proto.getNodeDataByID=function(nodeID){ + return this._nodeIDAniDic[nodeID]; + } + + /** + *@private + */ + __proto._getParams=function(obj,params,frame,obj2){ + var rst=GraphicAnimation._temParam; + rst.length=params.length; + var i=0,len=params.length; + for (i=0;i < len;i++){ + rst[i]=this._getObjVar(obj,params[i][0],frame,params[i][1],obj2); + } + return rst; + } + + /** + *@private + */ + __proto._getObjVar=function(obj,key,frame,noValue,obj2){ + if (obj.hasOwnProperty(key)){ + var vArr=obj[key]; + if (frame >=vArr.length) + frame=vArr.length-1; + return obj[key][frame]; + } + if (obj2.hasOwnProperty(key)){ + return obj2[key]; + } + return noValue; + } + + /** + *@private + */ + __proto._addNodeGraphic=function(nodeID,g,frame){ + var node=this.getNodeDataByID(nodeID); + if (!node) + return; + var frameData=node.frames; + var params=this._getParams(frameData,GraphicAnimation._drawTextureCmd,frame,this._nodeDefaultProps[nodeID]); + var url=params[0]; + if (!url)return; + params[0]=this._getTextureByUrl(url); + if (!params[0]){ + console.log("lost:",url); + throw new Error("texture not loaded:"+url); + return; + }; + var m; + var px=params[5],py=params[6]; + if (px !=0 || py !=0){ + m=m || new Matrix(); + m.translate(-px,-py); + }; + var sx=params[7],sy=params[8]; + var rotate=params[9]; + if (sx !=1 || sy !=1 || rotate !=0){ + m=m || new Matrix(); + m.scale(sx,sy); + m.rotate(rotate *0.0174532922222222); + } + if (m){ + m.translate(params[1],params[2]); + params[1]=params[2]=0; + } + g.drawTexture(params[0],params[1],params[2],params[3],params[4],m,params[10]); + } + + /** + *@private + */ + __proto._getTextureByUrl=function(url){ + return Loader.getRes(url); + } + + /** + *@private + */ + __proto.setAniData=function(uiView){ + if (uiView.animations){ + this._nodeDefaultProps={}; + if (this._nodeList)this._nodeList.length=0; + this._parseNodeList(uiView); + var aniDic={}; + var anilist=[]; + var animations=uiView.animations; + var i=0,len=animations.length; + var tAniO; + for (i=0;i < len;i++){ + tAniO=animations[i]; + if (!tAniO)continue ; + try{ + this._calGraphicData(tAniO); + }catch (e){ + console.log("parse animation fail:"+tAniO.name+",empty animation created"); + this._gList=[]; + }; + var frameO={}; + frameO.interval=1000 / tAniO["frameRate"]; + frameO.frames=this._gList; + anilist.push(frameO); + aniDic[tAniO.name]=frameO; + } + this.animationList=anilist; + this.animationDic=aniDic; + } + GraphicAnimation._temParam.length=0; + } + + /** + *@private + */ + __proto._clear=function(){ + this.animationList=null; + this.animationDic=null; + this._gList=null; + } + + GraphicAnimation.parseAnimationData=function(aniData){ + if (!GraphicAnimation._I) + GraphicAnimation._I=new GraphicAnimation(); + GraphicAnimation._I.setAniData(aniData); + var rst; + rst={}; + rst.animationList=GraphicAnimation._I.animationList; + rst.animationDic=GraphicAnimation._I.animationDic; + GraphicAnimation._I._clear(); + return rst; + } + + GraphicAnimation._temParam=[]; + GraphicAnimation._I=null + __static(GraphicAnimation, + ['_drawTextureCmd',function(){return this._drawTextureCmd=[["skin",null],["x",0],["y",0],["width",0],["height",0],["pivotX",0],["pivotY",0],["scaleX",1],["scaleY",1],["rotation",0],["alpha",1]];} + ]); + return GraphicAnimation; + })(FrameAnimation) + + + Laya.__init([EventDispatcher,LoaderManager,Render,Browser,Timer,LocalStorage,TimeLine]); +})(window,document,Laya); + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Arith=laya.maths.Arith,Bezier=laya.maths.Bezier,Bitmap=laya.resource.Bitmap,Browser=laya.utils.Browser; + var Color=laya.utils.Color,ColorFilter=laya.filters.ColorFilter,Config=Laya.Config,Context=laya.resource.Context; + var Event=laya.events.Event,Filter=laya.filters.Filter,Graphics=laya.display.Graphics,HTMLCanvas=laya.resource.HTMLCanvas; + var HTMLChar=laya.utils.HTMLChar,HTMLImage=laya.resource.HTMLImage,Handler=laya.utils.Handler,Matrix=laya.maths.Matrix; + var Point=laya.maths.Point,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext; + var RenderSprite=laya.renders.RenderSprite,Resource=laya.resource.Resource,ResourceManager=laya.resource.ResourceManager; + var RunDriver=laya.utils.RunDriver,Sprite=laya.display.Sprite,Stat=laya.utils.Stat,StringKey=laya.utils.StringKey; + var Style=laya.display.css.Style,System=laya.system.System,Texture=laya.resource.Texture,Utils=laya.utils.Utils; + var VectorGraphManager=laya.utils.VectorGraphManager,WordText=laya.utils.WordText; + Laya.interface('laya.webgl.shapes.IShape'); + Laya.interface('laya.webgl.submit.ISubmit'); + Laya.interface('laya.webgl.text.ICharSegment'); + Laya.interface('laya.webgl.canvas.save.ISaveData'); + Laya.interface('laya.webgl.resource.IMergeAtlasBitmap'); + Laya.interface('laya.filters.IFilterActionGL','laya.filters.IFilterAction'); + //class LayaMain + var LayaMain=(function(){ + /*[COMPILER OPTIONS:normal]*/ + function LayaMain(){} + __class(LayaMain,'LayaMain'); + return LayaMain; + })() + + + //class laya.filters.webgl.FilterActionGL + var FilterActionGL=(function(){ + function FilterActionGL(){} + __class(FilterActionGL,'laya.filters.webgl.FilterActionGL'); + var __proto=FilterActionGL.prototype; + Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) + __proto.setValue=function(shader){} + __proto.setValueMix=function(shader){} + __proto.apply3d=function(scope,sprite,context,x,y){return null;} + __proto.apply=function(srcCanvas){return null;} + __getset(0,__proto,'typeMix',function(){ + return 0; + }); + + return FilterActionGL; + })() + + + //class laya.webgl.shader.ShaderValue + var ShaderValue=(function(){ + function ShaderValue(){} + __class(ShaderValue,'laya.webgl.shader.ShaderValue'); + return ShaderValue; + })() + + + //class laya.webgl.atlas.AtlasGrid + var AtlasGrid=(function(){ + var TexRowInfo,TexMergeTexSize; + function AtlasGrid(width,height,atlasID){ + this._atlasID=0; + this._width=0; + this._height=0; + this._texCount=0; + this._rowInfo=null; + this._cells=null; + this._failSize=new TexMergeTexSize(); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + (atlasID===void 0)&& (atlasID=0); + this._cells=null; + this._rowInfo=null; + this._init(width,height); + this._atlasID=atlasID; + } + + __class(AtlasGrid,'laya.webgl.atlas.AtlasGrid'); + var __proto=AtlasGrid.prototype; + //------------------------------------------------------------------------------ + __proto.getAltasID=function(){ + return this._atlasID; + } + + //------------------------------------------------------------------------------ + __proto.setAltasID=function(atlasID){ + if (atlasID >=0){ + this._atlasID=atlasID; + } + } + + //------------------------------------------------------------------ + __proto.addTex=function(type,width,height){ + var result=this._get(width,height); + if (result.ret==false){ + return result; + } + this._fill(result.x,result.y,width,height,type); + this._texCount++; + return result; + } + + //------------------------------------------------------------------------------ + __proto._release=function(){ + if (this._cells !=null){ + this._cells.length=0; + this._cells=null; + } + if (this._rowInfo){ + this._rowInfo.length=0; + this._rowInfo=null; + } + } + + //------------------------------------------------------------------------------ + __proto._init=function(width,height){ + this._width=width; + this._height=height; + this._release(); + if (this._width==0)return false; + this._cells=new Uint8Array(this._width *this._height*3); + this._rowInfo=__newvec(this._height); + for (var i=0;i < this._height;i++){ + this._rowInfo[i]=new TexRowInfo(); + } + this._clear(); + return true; + } + + //------------------------------------------------------------------ + __proto._get=function(width,height){ + var pFillInfo=new MergeFillInfo(); + if (width >=this._failSize.width && height >=this._failSize.height){ + return pFillInfo; + }; + var rx=-1; + var ry=-1; + var nWidth=this._width; + var nHeight=this._height; + var pCellBox=this._cells; + for (var y=0;y < nHeight;y++){ + if (this._rowInfo[y].spaceCount < width)continue ; + for (var x=0;x < nWidth;){ + var tm=(y *nWidth+x)*3; + if (pCellBox[tm] !=0 || pCellBox[tm+1] < width || pCellBox[tm+2] < height){ + x+=pCellBox[tm+1]; + continue ; + } + rx=x; + ry=y; + for (var xx=0;xx < width;xx++){ + if (pCellBox[3*xx+tm+2] < height){ + rx=-1; + break ; + } + } + if (rx < 0){ + x+=pCellBox[tm+1]; + continue ; + } + pFillInfo.ret=true; + pFillInfo.x=rx; + pFillInfo.y=ry; + return pFillInfo; + } + } + return pFillInfo; + } + + //------------------------------------------------------------------ + __proto._fill=function(x,y,w,h,type){ + var nWidth=this._width; + var nHeghit=this._height; + this._check((x+w)<=nWidth && (y+h)<=nHeghit); + for (var yy=y;yy < (h+y);++yy){ + this._check(this._rowInfo[yy].spaceCount >=w); + this._rowInfo[yy].spaceCount-=w; + for (var xx=0;xx < w;xx++){ + var tm=(x+yy *nWidth+xx)*3; + this._check(this._cells[tm]==0); + this._cells[tm]=type; + this._cells[tm+1]=w; + this._cells[tm+2]=h; + } + } + if (x > 0){ + for (yy=0;yy < h;++yy){ + var s=0; + for (xx=x-1;xx >=0;--xx,++s){ + if (this._cells[((y+yy)*nWidth+xx)*3] !=0)break ; + } + for (xx=s;xx > 0;--xx){ + this._cells[((y+yy)*nWidth+x-xx)*3+1]=xx; + this._check(xx > 0); + } + } + } + if (y > 0){ + for (xx=x;xx < (x+w);++xx){ + s=0; + for (yy=y-1;yy >=0;--yy,s++){ + if (this._cells[(xx+yy *nWidth)*3] !=0)break ; + } + for (yy=s;yy > 0;--yy){ + this._cells[(xx+(y-yy)*nWidth)*3+2]=yy; + this._check(yy > 0); + } + } + } + } + + __proto._check=function(ret){ + if (ret==false){ + console.log("xtexMerger 错误啦"); + } + } + + //------------------------------------------------------------------ + __proto._clear=function(){ + this._texCount=0; + for (var y=0;y < this._height;y++){ + this._rowInfo[y].spaceCount=this._width; + } + for (var i=0;i < this._height;i++){ + for (var j=0;j < this._width;j++){ + var tm=(i *this._width+j)*3; + this._cells[tm]=0; + this._cells[tm+1]=this._width-j; + this._cells[tm+2]=this._width-i; + } + } + this._failSize.width=this._width+1; + this._failSize.height=this._height+1; + } + + AtlasGrid.__init$=function(){ + //------------------------------------------------------------------------------ + //class TexRowInfo + TexRowInfo=(function(){ + function TexRowInfo(){ + this.spaceCount=0; + } + __class(TexRowInfo,''); + return TexRowInfo; + })() + //------------------------------------------------------------------------------ + //class TexMergeTexSize + TexMergeTexSize=(function(){ + function TexMergeTexSize(){ + this.width=0; + this.height=0; + } + __class(TexMergeTexSize,''); + return TexMergeTexSize; + })() + } + + return AtlasGrid; + })() + + + //class laya.webgl.atlas.AtlasResourceManager + var AtlasResourceManager=(function(){ + function AtlasResourceManager(width,height,gridSize,maxTexNum){ + this._currentAtlasCount=0; + this._maxAtlaserCount=0; + this._width=0; + this._height=0; + this._gridSize=0; + this._gridNumX=0; + this._gridNumY=0; + this._init=false; + this._curAtlasIndex=0; + this._setAtlasParam=false; + this._atlaserArray=null; + this._needGC=false; + this._setAtlasParam=true; + this._width=width; + this._height=height; + this._gridSize=gridSize; + this._maxAtlaserCount=maxTexNum; + this._gridNumX=width / gridSize; + this._gridNumY=height / gridSize; + this._curAtlasIndex=0; + this._atlaserArray=[]; + } + + __class(AtlasResourceManager,'laya.webgl.atlas.AtlasResourceManager'); + var __proto=AtlasResourceManager.prototype; + __proto.setAtlasParam=function(width,height,gridSize,maxTexNum){ + if (this._setAtlasParam==true){ + AtlasResourceManager._sid_=0; + this._width=width; + this._height=height; + this._gridSize=gridSize; + this._maxAtlaserCount=maxTexNum; + this._gridNumX=width / gridSize; + this._gridNumY=height / gridSize; + this._curAtlasIndex=0; + this.freeAll(); + return true; + }else { + console.log("设置大图合集参数错误,只能在开始页面设置各种参数"); + throw-1; + return false; + } + return false; + } + + //添加 图片到大图集 + __proto.pushData=function(texture){ + var tex=texture; + this._setAtlasParam=false; + var bFound=false; + var nImageGridX=(Math.ceil((texture.bitmap.width+2)/ this._gridSize)); + var nImageGridY=(Math.ceil((texture.bitmap.height+2)/ this._gridSize)); + var bSuccess=false; + for (var k=0;k < 2;k++){ + var maxAtlaserCount=this._maxAtlaserCount; + for (var i=0;i < maxAtlaserCount;i++){ + var altasIndex=(this._curAtlasIndex+i)% maxAtlaserCount; + (this._atlaserArray.length-1>=altasIndex)|| (this._atlaserArray.push(new Atlaser(this._gridNumX,this._gridNumY,this._width,this._height,AtlasResourceManager._sid_++))); + var atlas=this._atlaserArray[altasIndex]; + var bitmap=texture.bitmap; + var webGLImageIndex=atlas.inAtlasWebGLImagesKey.indexOf(bitmap); + var offsetX=0,offsetY=0; + if (webGLImageIndex==-1){ + var fillInfo=atlas.addTex(1,nImageGridX,nImageGridY); + if (fillInfo.ret){ + offsetX=fillInfo.x *this._gridSize+1; + offsetY=fillInfo.y *this._gridSize+1; + bitmap.lock=true; + atlas.addToAtlasTexture((bitmap),offsetX,offsetY); + atlas.addToAtlas(texture,offsetX,offsetY); + bSuccess=true; + this._curAtlasIndex=altasIndex; + break ; + } + }else { + var offset=atlas.InAtlasWebGLImagesOffsetValue[webGLImageIndex]; + offsetX=offset[0]; + offsetY=offset[1]; + atlas.addToAtlas(texture,offsetX,offsetY); + bSuccess=true; + this._curAtlasIndex=altasIndex; + break ; + } + } + if (bSuccess) + break ; + this._atlaserArray.push(new Atlaser(this._gridNumX,this._gridNumY,this._width,this._height,AtlasResourceManager._sid_++)); + this._needGC=true; + this.garbageCollection(); + this._curAtlasIndex=this._atlaserArray.length-1; + } + if (!bSuccess){ + console.log(">>>AtlasManager pushData error"); + } + return bSuccess; + } + + __proto.addToAtlas=function(tex){ + laya.webgl.atlas.AtlasResourceManager.instance.pushData(tex); + } + + /** + *回收大图合集,不建议手动调用 + *@return + */ + __proto.garbageCollection=function(){ + if (this._needGC===true){ + var n=this._atlaserArray.length-this._maxAtlaserCount; + for (var i=0;i < n;i++) + this._atlaserArray[i].dispose(); + this._atlaserArray.splice(0,n); + this._needGC=false; + } + return true; + } + + __proto.freeAll=function(){ + for (var i=0,n=this._atlaserArray.length;i < n;i++){ + this._atlaserArray[i].dispose(); + } + this._atlaserArray.length=0; + this._curAtlasIndex=0; + } + + __proto.getAtlaserCount=function(){ + return this._atlaserArray.length; + } + + __proto.getAtlaserByIndex=function(index){ + return this._atlaserArray[index]; + } + + __getset(1,AtlasResourceManager,'instance',function(){ + if (!AtlasResourceManager._Instance){ + AtlasResourceManager._Instance=new AtlasResourceManager(laya.webgl.atlas.AtlasResourceManager.atlasTextureWidth,laya.webgl.atlas.AtlasResourceManager.atlasTextureHeight,/*CLASS CONST:laya.webgl.atlas.AtlasResourceManager.gridSize*/16,laya.webgl.atlas.AtlasResourceManager.maxTextureCount); + } + return AtlasResourceManager._Instance; + }); + + __getset(1,AtlasResourceManager,'enabled',function(){ + return AtlasResourceManager._enabled; + }); + + __getset(1,AtlasResourceManager,'atlasLimitWidth',function(){ + return AtlasResourceManager._atlasLimitWidth; + },function(value){ + AtlasResourceManager._atlasLimitWidth=value; + }); + + __getset(1,AtlasResourceManager,'atlasLimitHeight',function(){ + return AtlasResourceManager._atlasLimitHeight; + },function(value){ + AtlasResourceManager._atlasLimitHeight=value; + }); + + AtlasResourceManager._enable=function(){ + AtlasResourceManager._enabled=true; + Config.atlasEnable=true; + } + + AtlasResourceManager._disable=function(){ + AtlasResourceManager._enabled=false; + Config.atlasEnable=false; + } + + AtlasResourceManager.__init__=function(){ + AtlasResourceManager.atlasTextureWidth=2048; + AtlasResourceManager.atlasTextureHeight=2048; + AtlasResourceManager.maxTextureCount=6; + AtlasResourceManager.atlasLimitWidth=512; + AtlasResourceManager.atlasLimitHeight=512; + } + + AtlasResourceManager._enabled=false; + AtlasResourceManager._atlasLimitWidth=0; + AtlasResourceManager._atlasLimitHeight=0; + AtlasResourceManager.gridSize=16; + AtlasResourceManager.atlasTextureWidth=0; + AtlasResourceManager.atlasTextureHeight=0; + AtlasResourceManager.maxTextureCount=0; + AtlasResourceManager._atlasRestore=0; + AtlasResourceManager.BOARDER_TYPE_NO=0; + AtlasResourceManager.BOARDER_TYPE_RIGHT=1; + AtlasResourceManager.BOARDER_TYPE_LEFT=2; + AtlasResourceManager.BOARDER_TYPE_BOTTOM=4; + AtlasResourceManager.BOARDER_TYPE_TOP=8; + AtlasResourceManager.BOARDER_TYPE_ALL=15; + AtlasResourceManager._sid_=0; + AtlasResourceManager._Instance=null; + return AtlasResourceManager; + })() + + + //class laya.webgl.atlas.MergeFillInfo + var MergeFillInfo=(function(){ + function MergeFillInfo(){ + this.x=0; + this.y=0; + this.ret=false; + this.ret=false; + this.x=0; + this.y=0; + } + + __class(MergeFillInfo,'laya.webgl.atlas.MergeFillInfo'); + return MergeFillInfo; + })() + + + ; + //class laya.webgl.canvas.BlendMode + var BlendMode=(function(){ + function BlendMode(){}; + __class(BlendMode,'laya.webgl.canvas.BlendMode'); + BlendMode._init_=function(gl){ + BlendMode.fns=[BlendMode.BlendNormal,BlendMode.BlendAdd,BlendMode.BlendMultiply,BlendMode.BlendScreen,BlendMode.BlendOverlay,BlendMode.BlendLight,BlendMode.BlendMask,BlendMode.BlendDestinationOut]; + BlendMode.targetFns=[BlendMode.BlendNormalTarget,BlendMode.BlendAddTarget,BlendMode.BlendMultiplyTarget,BlendMode.BlendScreenTarget,BlendMode.BlendOverlayTarget,BlendMode.BlendLightTarget,BlendMode.BlendMask,BlendMode.BlendDestinationOut]; + } + + BlendMode.BlendNormal=function(gl){ + gl.blendFuncSeparate(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303,/*laya.webgl.WebGLContext.ONE*/1,/*laya.webgl.WebGLContext.ONE*/1); + } + + BlendMode.BlendAdd=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.DST_ALPHA*/0x0304); + } + + BlendMode.BlendMultiply=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.DST_COLOR*/0x0306,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303); + } + + BlendMode.BlendScreen=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE*/1); + } + + BlendMode.BlendOverlay=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.ONE*/1,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_COLOR*/0x0301); + } + + BlendMode.BlendLight=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE*/1); + } + + BlendMode.BlendNormalTarget=function(gl){ + gl.blendFuncSeparate(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303,/*laya.webgl.WebGLContext.ONE*/1,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303); + } + + BlendMode.BlendAddTarget=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.DST_ALPHA*/0x0304); + } + + BlendMode.BlendMultiplyTarget=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.DST_COLOR*/0x0306,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303); + } + + BlendMode.BlendScreenTarget=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE*/1); + } + + BlendMode.BlendOverlayTarget=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.ONE*/1,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_COLOR*/0x0301); + } + + BlendMode.BlendLightTarget=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE*/1); + } + + BlendMode.BlendMask=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.ZERO*/0,/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302); + } + + BlendMode.BlendDestinationOut=function(gl){ + gl.blendFunc(/*laya.webgl.WebGLContext.ZERO*/0,/*laya.webgl.WebGLContext.ZERO*/0); + } + + BlendMode.activeBlendFunction=null; + BlendMode.NAMES=["normal","add","multiply","screen","overlay","light","mask","destination-out"]; + BlendMode.TOINT={"normal":0,"add":1,"multiply":2,"screen":3 ,"lighter":1,"overlay":4,"light":5,"mask":6,"destination-out":7}; + BlendMode.NORMAL="normal"; + BlendMode.ADD="add"; + BlendMode.MULTIPLY="multiply"; + BlendMode.SCREEN="screen"; + BlendMode.LIGHT="light"; + BlendMode.OVERLAY="overlay"; + BlendMode.DESTINATIONOUT="destination-out"; + BlendMode.fns=[]; + BlendMode.targetFns=[]; + return BlendMode; + })() + + + //class laya.webgl.canvas.DrawStyle + var DrawStyle=(function(){ + function DrawStyle(value){ + this._color=Color.create("black"); + this.setValue(value); + } + + __class(DrawStyle,'laya.webgl.canvas.DrawStyle'); + var __proto=DrawStyle.prototype; + __proto.setValue=function(value){ + if (value){ + if ((typeof value=='string')){ + this._color=Color.create(value); + return; + } + if ((value instanceof laya.utils.Color )){ + this._color=value; + return; + } + } + } + + __proto.reset=function(){ + this._color=Color.create("black"); + } + + __proto.equal=function(value){ + if ((typeof value=='string'))return this._color.strColor===value; + if ((value instanceof laya.utils.Color ))return this._color.numColor===(value).numColor; + return false; + } + + __proto.toColorStr=function(){ + return this._color.strColor; + } + + DrawStyle.create=function(value){ + if (value){ + var color; + if ((typeof value=='string'))color=Color.create(value); + else if ((value instanceof laya.utils.Color ))color=value; + if (color){ + return color._drawStyle || (color._drawStyle=new DrawStyle(value)); + } + } + return null; + } + + DrawStyle.DEFAULT=new DrawStyle("#000000"); + return DrawStyle; + })() + + + //class laya.webgl.canvas.Path + var Path=(function(){ + function Path(){ + this._x=0; + this._y=0; + //this._rect=null; + //this.ib=null; + //this.vb=null; + this.dirty=false; + //this.geomatrys=null; + //this._curGeomatry=null; + this.offset=0; + this.count=0; + this.geoStart=0; + this.tempArray=[]; + this.closePath=false; + this.geomatrys=[]; + var gl=WebGL.mainContext; + this.ib=IndexBuffer2D.create(/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this.vb=VertexBuffer2D.create(5); + } + + __class(Path,'laya.webgl.canvas.Path'); + var __proto=Path.prototype; + __proto.addPoint=function(pointX,pointY){ + this.tempArray.push(pointX,pointY); + } + + __proto.getEndPointX=function(){ + return this.tempArray[this.tempArray.length-2]; + } + + __proto.getEndPointY=function(){ + return this.tempArray[this.tempArray.length-1]; + } + + __proto.polygon=function(x,y,points,color,borderWidth,borderColor){ + var geo; + this.geomatrys.push(this._curGeomatry=geo=new Polygon(x,y,points,color,borderWidth,borderColor)); + if (!color)geo.fill=false; + if (borderColor==undefined)geo.borderWidth=0; + return geo; + } + + __proto.setGeomtry=function(shape){ + this.geomatrys.push(this._curGeomatry=shape); + } + + __proto.drawLine=function(x,y,points,width,color){ + var geo; + if (this.closePath){ + this.geomatrys.push(this._curGeomatry=geo=new LoopLine(x,y,points,width,color)); + }else { + this.geomatrys.push(this._curGeomatry=geo=new Line(x,y,points,width,color)); + } + geo.fill=false; + return geo; + } + + __proto.update=function(){ + var si=this.ib.byteLength; + var len=this.geomatrys.length; + this.offset=si; + for (var i=this.geoStart;i < len;i++){ + this.geomatrys[i].getData(this.ib,this.vb,this.vb.byteLength / 20); + } + this.geoStart=len; + this.count=(this.ib.byteLength-si)/ CONST3D2D.BYTES_PIDX; + } + + __proto.reset=function(){ + this.vb.clear(); + this.ib.clear(); + this.offset=this.count=this.geoStart=0; + this.geomatrys.length=0; + } + + return Path; + })() + + + //class laya.webgl.canvas.save.SaveBase + var SaveBase=(function(){ + function SaveBase(){ + //this._valueName=null; + //this._value=null; + //this._dataObj=null; + //this._newSubmit=false; + } + + __class(SaveBase,'laya.webgl.canvas.save.SaveBase'); + var __proto=SaveBase.prototype; + Laya.imps(__proto,{"laya.webgl.canvas.save.ISaveData":true}) + __proto.isSaveMark=function(){return false;} + __proto.restore=function(context){ + this._dataObj[this._valueName]=this._value; + SaveBase._cache[SaveBase._cache._length++]=this; + this._newSubmit && (context._curSubmit=Submit.RENDERBASE,context._renderKey=0); + } + + SaveBase._createArray=function(){ + var value=[]; + value._length=0; + return value; + } + + SaveBase._init=function(){ + var namemap=SaveBase._namemap={}; + namemap[0x1]="ALPHA"; + namemap[0x2]="fillStyle"; + namemap[0x8]="font"; + namemap[0x100]="lineWidth"; + namemap[0x200]="strokeStyle"; + namemap[0x2000]="_mergeID"; + namemap[0x400]=namemap[0x800]=namemap[0x1000]=[]; + namemap[0x4000]="textBaseline"; + namemap[0x8000]="textAlign"; + namemap[0x10000]="_nBlendType"; + namemap[0x80000]="shader"; + namemap[0x100000]="filters"; + return namemap; + } + + SaveBase.save=function(context,type,dataObj,newSubmit){ + if ((context._saveMark._saveuse & type)!==type){ + context._saveMark._saveuse |=type; + var cache=SaveBase._cache; + var o=cache._length > 0 ? cache[--cache._length] :(new SaveBase()); + o._value=dataObj[o._valueName=SaveBase._namemap[type]]; + o._dataObj=dataObj; + o._newSubmit=newSubmit; + var _save=context._save; + _save[_save._length++]=o; + } + } + + SaveBase._cache=laya.webgl.canvas.save.SaveBase._createArray(); + SaveBase._namemap=SaveBase._init(); + return SaveBase; + })() + + + //class laya.webgl.canvas.save.SaveClipRect + var SaveClipRect=(function(){ + function SaveClipRect(){ + //this._clipSaveRect=null; + //this._submitScissor=null; + this._clipRect=new Rectangle(); + } + + __class(SaveClipRect,'laya.webgl.canvas.save.SaveClipRect'); + var __proto=SaveClipRect.prototype; + Laya.imps(__proto,{"laya.webgl.canvas.save.ISaveData":true}) + __proto.isSaveMark=function(){return false;} + __proto.restore=function(context){ + context._clipRect=this._clipSaveRect; + SaveClipRect._cache[SaveClipRect._cache._length++]=this; + this._submitScissor.submitLength=context._submits._length-this._submitScissor.submitIndex; + context._curSubmit=Submit.RENDERBASE; + context._renderKey=0; + } + + SaveClipRect.save=function(context,submitScissor){ + if ((context._saveMark._saveuse & /*laya.webgl.canvas.save.SaveBase.TYPE_CLIPRECT*/0x20000)==/*laya.webgl.canvas.save.SaveBase.TYPE_CLIPRECT*/0x20000)return; + context._saveMark._saveuse |=/*laya.webgl.canvas.save.SaveBase.TYPE_CLIPRECT*/0x20000; + var cache=SaveClipRect._cache; + var o=cache._length > 0 ? cache[--cache._length] :(new SaveClipRect()); + o._clipSaveRect=context._clipRect; + context._clipRect=o._clipRect.copyFrom(context._clipRect); + o._submitScissor=submitScissor; + var _save=context._save; + _save[_save._length++]=o; + } + + SaveClipRect._cache=SaveBase._createArray(); + return SaveClipRect; + })() + + + //class laya.webgl.canvas.save.SaveMark + var SaveMark=(function(){ + function SaveMark(){ + this._saveuse=0; + //this._preSaveMark=null; + ; + } + + __class(SaveMark,'laya.webgl.canvas.save.SaveMark'); + var __proto=SaveMark.prototype; + Laya.imps(__proto,{"laya.webgl.canvas.save.ISaveData":true}) + __proto.isSaveMark=function(){ + return true; + } + + __proto.restore=function(context){ + context._saveMark=this._preSaveMark; + SaveMark._no[SaveMark._no._length++]=this; + } + + SaveMark.Create=function(context){ + var no=SaveMark._no; + var o=no._length > 0 ? no[--no._length] :(new SaveMark()); + o._saveuse=0; + o._preSaveMark=context._saveMark; + context._saveMark=o; + return o; + } + + SaveMark._no=SaveBase._createArray(); + return SaveMark; + })() + + + //class laya.webgl.canvas.save.SaveTransform + var SaveTransform=(function(){ + function SaveTransform(){ + //this._savematrix=null; + this._matrix=new Matrix(); + } + + __class(SaveTransform,'laya.webgl.canvas.save.SaveTransform'); + var __proto=SaveTransform.prototype; + Laya.imps(__proto,{"laya.webgl.canvas.save.ISaveData":true}) + __proto.isSaveMark=function(){return false;} + __proto.restore=function(context){ + context._curMat=this._savematrix; + SaveTransform._no[SaveTransform._no._length++]=this; + } + + SaveTransform.save=function(context){ + var _saveMark=context._saveMark; + if ((_saveMark._saveuse & /*laya.webgl.canvas.save.SaveBase.TYPE_TRANSFORM*/0x800)===/*laya.webgl.canvas.save.SaveBase.TYPE_TRANSFORM*/0x800)return; + _saveMark._saveuse |=/*laya.webgl.canvas.save.SaveBase.TYPE_TRANSFORM*/0x800; + var no=SaveTransform._no; + var o=no._length > 0 ? no[--no._length] :(new SaveTransform()); + o._savematrix=context._curMat; + context._curMat=context._curMat.copyTo(o._matrix); + var _save=context._save; + _save[_save._length++]=o; + } + + SaveTransform._no=SaveBase._createArray(); + return SaveTransform; + })() + + + //class laya.webgl.canvas.save.SaveTranslate + var SaveTranslate=(function(){ + function SaveTranslate(){ + //this._x=NaN; + //this._y=NaN; + } + + __class(SaveTranslate,'laya.webgl.canvas.save.SaveTranslate'); + var __proto=SaveTranslate.prototype; + Laya.imps(__proto,{"laya.webgl.canvas.save.ISaveData":true}) + __proto.isSaveMark=function(){return false;} + __proto.restore=function(context){ + var mat=context._curMat; + context._x=this._x; + context._y=this._y; + SaveTranslate._no[SaveTranslate._no._length++]=this; + } + + SaveTranslate.save=function(context){ + var no=SaveTranslate._no; + var o=no._length > 0 ? no[--no._length] :(new SaveTranslate()); + o._x=context._x; + o._y=context._y; + var _save=context._save; + _save[_save._length++]=o; + } + + SaveTranslate._no=SaveBase._createArray(); + return SaveTranslate; + })() + + + //class laya.webgl.resource.RenderTargetMAX + var RenderTargetMAX=(function(){ + var OneTarget; + function RenderTargetMAX(){ + this.targets=null; + this.oneTargets=null; + this.repaint=false; + this._width=NaN; + this._height=NaN; + this._clipRect=new Rectangle(); + } + + __class(RenderTargetMAX,'laya.webgl.resource.RenderTargetMAX'); + var __proto=RenderTargetMAX.prototype; + __proto.size=function(w,h){ + if (this._width===w && this._height===h)return; + this.repaint=true; + this._width=w; + this._height=h; + if (!this.oneTargets) + this.oneTargets=new OneTarget(w,h); + else + this.oneTargets.target.size(w,h); + } + + __proto._flushToTarget=function(context,target){ + var worldScissorTest=RenderState2D.worldScissorTest; + var preworldClipRect=RenderState2D.worldClipRect; + RenderState2D.worldClipRect=this._clipRect; + this._clipRect.x=this._clipRect.y=0; + this._clipRect.width=this._width; + this._clipRect.height=this._height; + RenderState2D.worldScissorTest=false; + WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + var preAlpha=RenderState2D.worldAlpha; + var preMatrix4=RenderState2D.worldMatrix4; + var preMatrix=RenderState2D.worldMatrix; + var preFilters=RenderState2D.worldFilters; + var preShaderDefines=RenderState2D.worldShaderDefines; + RenderState2D.worldMatrix=RenderTargetMAX._matrixDefault; + RenderState2D.restoreTempArray(); + RenderState2D.worldMatrix4=RenderState2D.TEMPMAT4_ARRAY; + RenderState2D.worldAlpha=1; + RenderState2D.worldFilters=null; + RenderState2D.worldShaderDefines=null; + Shader.activeShader=null; + target.start(); + Config.showCanvasMark ? target.clear(0,1,0,0.3):target.clear(0,0,0,0); + context.flush(); + target.end(); + Shader.activeShader=null; + RenderState2D.worldAlpha=preAlpha; + RenderState2D.worldMatrix4=preMatrix4; + RenderState2D.worldMatrix=preMatrix; + RenderState2D.worldFilters=preFilters; + RenderState2D.worldShaderDefines=preShaderDefines; + RenderState2D.worldScissorTest=worldScissorTest + if (worldScissorTest){ + var y=RenderState2D.height-preworldClipRect.y-preworldClipRect.height; + WebGL.mainContext.scissor(preworldClipRect.x,y,preworldClipRect.width,preworldClipRect.height); + WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + } + RenderState2D.worldClipRect=preworldClipRect; + } + + __proto.flush=function(context){ + if (this.repaint){ + this._flushToTarget(context,this.oneTargets.target); + this.repaint=false; + } + } + + __proto.drawTo=function(context,x,y,width,height){ + context.drawTexture(this.oneTargets.target.getTexture(),x,y,width,height,0,0); + } + + __proto.destroy=function(){ + if (this.oneTargets){ + this.oneTargets.target.destroy(); + this.oneTargets.target=null; + this.oneTargets=null; + } + } + + __static(RenderTargetMAX, + ['_matrixDefault',function(){return this._matrixDefault=new Matrix();} + ]); + RenderTargetMAX.__init$=function(){ + //class OneTarget + OneTarget=(function(){ + function OneTarget(w,h){ + //this.x=NaN; + //this.width=NaN; + //this.height=NaN; + //this.target=null; + this.width=w; + this.height=h; + this.target=RenderTarget2D.create(w,h); + } + __class(OneTarget,''); + return OneTarget; + })() + } + + return RenderTargetMAX; + })() + + + //class laya.webgl.shader.d2.Shader2D + var Shader2D=(function(){ + function Shader2D(){ + this.ALPHA=1; + //this.glTexture=null; + //this.shader=null; + //this.filters=null; + this.shaderType=0; + //this.colorAdd=null; + //this.strokeStyle=null; + //this.fillStyle=null; + this.defines=new ShaderDefines2D(); + } + + __class(Shader2D,'laya.webgl.shader.d2.Shader2D'); + Shader2D.__init__=function(){ + Shader.addInclude("parts/ColorFilter_ps_uniform.glsl","uniform vec4 colorAlpha;\nuniform mat4 colorMat;"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/ColorFilter_ps_uniform.glsl*/); + Shader.addInclude("parts/ColorFilter_ps_logic.glsl","gl_FragColor = gl_FragColor * colorMat + colorAlpha/255.0;"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/ColorFilter_ps_logic.glsl*/); + Shader.addInclude("parts/GlowFilter_ps_uniform.glsl","uniform vec4 u_color;\nuniform float u_strength;\nuniform float u_blurX;\nuniform float u_blurY;\nuniform float u_offsetX;\nuniform float u_offsetY;\nuniform float u_textW;\nuniform float u_textH;"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/GlowFilter_ps_uniform.glsl*/); + Shader.addInclude("parts/GlowFilter_ps_logic.glsl","const float c_IterationTime = 10.0;\nfloat floatIterationTotalTime = c_IterationTime * c_IterationTime;\nvec4 vec4Color = vec4(0.0,0.0,0.0,0.0);\nvec2 vec2FilterDir = vec2(-(u_offsetX)/u_textW,-(u_offsetY)/u_textH);\nvec2 vec2FilterOff = vec2(u_blurX/u_textW/c_IterationTime * 2.0,u_blurY/u_textH/c_IterationTime * 2.0);\nfloat maxNum = u_blurX * u_blurY;\nvec2 vec2Off = vec2(0.0,0.0);\nfloat floatOff = c_IterationTime/2.0;\nfor(float i = 0.0;i<=c_IterationTime; ++i){\n for(float j = 0.0;j<=c_IterationTime; ++j){\n vec2Off = vec2(vec2FilterOff.x * (i - floatOff),vec2FilterOff.y * (j - floatOff));\n vec4Color += texture2D(texture, v_texcoord + vec2FilterDir + vec2Off)/floatIterationTotalTime;\n }\n}\ngl_FragColor = vec4(u_color.rgb,vec4Color.a * u_strength);"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/GlowFilter_ps_logic.glsl*/); + Shader.addInclude("parts/BlurFilter_ps_logic.glsl","gl_FragColor=vec4(0.0);\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 0])*0.004431848411938341;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 1])*0.05399096651318985;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 2])*0.2419707245191454;\ngl_FragColor += texture2D(texture, v_texcoord )*0.3989422804014327;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 3])*0.2419707245191454;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 4])*0.05399096651318985;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 5])*0.004431848411938341;"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/BlurFilter_ps_logic.glsl*/); + Shader.addInclude("parts/BlurFilter_ps_uniform.glsl","varying vec2 vBlurTexCoords[6];"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/BlurFilter_ps_uniform.glsl*/); + Shader.addInclude("parts/BlurFilter_vs_uniform.glsl","uniform float strength;\nvarying vec2 vBlurTexCoords[6];"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/BlurFilter_vs_uniform.glsl*/); + Shader.addInclude("parts/BlurFilter_vs_logic.glsl","\nvBlurTexCoords[ 0] = v_texcoord + vec2(-0.012 * strength, 0.0);\nvBlurTexCoords[ 1] = v_texcoord + vec2(-0.008 * strength, 0.0);\nvBlurTexCoords[ 2] = v_texcoord + vec2(-0.004 * strength, 0.0);\nvBlurTexCoords[ 3] = v_texcoord + vec2( 0.004 * strength, 0.0);\nvBlurTexCoords[ 4] = v_texcoord + vec2( 0.008 * strength, 0.0);\nvBlurTexCoords[ 5] = v_texcoord + vec2( 0.012 * strength, 0.0);"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/BlurFilter_vs_logic.glsl*/); + Shader.addInclude("parts/ColorAdd_ps_uniform.glsl","uniform vec4 colorAdd;\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/ColorAdd_ps_uniform.glsl*/); + Shader.addInclude("parts/ColorAdd_ps_logic.glsl","gl_FragColor = vec4(colorAdd.rgb,colorAdd.a*gl_FragColor.a);"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/parts/ColorAdd_ps_logic.glsl*/); + var vs,ps; + vs="attribute vec4 position;\nattribute vec2 texcoord;\nuniform vec2 size;\n\n#ifdef WORLDMAT\nuniform mat4 mmat;\n#endif\nvarying vec2 v_texcoord;\n\n#include?BLUR_FILTER \"parts/BlurFilter_vs_uniform.glsl\";\nvoid main() {\n #ifdef WORLDMAT\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n #else\n gl_Position =vec4((position.x/size.x-0.5)*2.0,(0.5-position.y/size.y)*2.0,position.z,1.0);\n #endif\n \n v_texcoord = texcoord;\n #include?BLUR_FILTER \"parts/BlurFilter_vs_logic.glsl\";\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/texture.vs*/; + ps="precision mediump float;\n//precision highp float;\nvarying vec2 v_texcoord;\nuniform sampler2D texture;\nuniform float alpha;\n#include?BLUR_FILTER \"parts/BlurFilter_ps_uniform.glsl\";\n#include?COLOR_FILTER \"parts/ColorFilter_ps_uniform.glsl\";\n#include?GLOW_FILTER \"parts/GlowFilter_ps_uniform.glsl\";\n#include?COLOR_ADD \"parts/ColorAdd_ps_uniform.glsl\";\n\nvoid main() {\n vec4 color= texture2D(texture, v_texcoord);\n color.a*=alpha;\n gl_FragColor=color;\n #include?COLOR_ADD \"parts/ColorAdd_ps_logic.glsl\"; \n #include?BLUR_FILTER \"parts/BlurFilter_ps_logic.glsl\";\n #include?COLOR_FILTER \"parts/ColorFilter_ps_logic.glsl\";\n #include?GLOW_FILTER \"parts/GlowFilter_ps_logic.glsl\";\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/texture.ps*/; + Shader.preCompile2D(0,/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,vs,ps,null); + vs="attribute vec4 position;\nuniform vec2 size;\nuniform mat4 mmat;\nvoid main() {\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/line.vs*/; + ps="precision mediump float;\nuniform vec4 color;\nuniform float alpha;\n#include?COLOR_FILTER \"parts/ColorFilter_ps_uniform.glsl\";\nvoid main() {\n vec4 a = vec4(color.r, color.g, color.b, color.a);\n a.w = alpha;\n gl_FragColor = a;\n #include?COLOR_FILTER \"parts/ColorFilter_ps_logic.glsl\";\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/line.ps*/; + Shader.preCompile2D(0,/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,vs,ps,null); + vs="attribute vec4 position;\nattribute vec3 a_color;\nuniform mat4 mmat;\nuniform mat4 u_mmat2;\nuniform vec2 u_pos;\nuniform vec2 size;\nvarying vec3 color;\nvoid main(){\n vec4 tPos = vec4(position.x + u_pos.x,position.y + u_pos.y,position.z,position.w);\n vec4 pos=mmat*u_mmat2*tPos;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n color=a_color;\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/primitive.vs*/; + ps="precision mediump float;\n//precision mediump float;\nvarying vec3 color;\nuniform float alpha;\nvoid main(){\n //vec4 a=vec4(color.r, color.g, color.b, 1);\n //a.a*=alpha;\n gl_FragColor=vec4(color.r, color.g, color.b, alpha);\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/primitive.ps*/; + Shader.preCompile2D(0,/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,vs,ps,null); + vs="attribute vec4 position;\nattribute vec2 texcoord;\nuniform vec2 size;\n\n#ifdef WORLDMAT\nuniform mat4 mmat;\n#endif\nvarying vec2 v_texcoord;\n\n#include?BLUR_FILTER \"parts/BlurFilter_vs_uniform.glsl\";\nvoid main() {\n #ifdef WORLDMAT\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n #else\n gl_Position =vec4((position.x/size.x-0.5)*2.0,(0.5-position.y/size.y)*2.0,position.z,1.0);\n #endif\n \n v_texcoord = texcoord;\n #include?BLUR_FILTER \"parts/BlurFilter_vs_logic.glsl\";\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/texture.vs*/; + ps="precision mediump float;\n//precision highp float;\nvarying vec2 v_texcoord;\nuniform sampler2D texture;\nuniform float alpha;\nuniform vec4 u_TexRange;\nuniform vec2 u_offset;\n#include?BLUR_FILTER \"parts/BlurFilter_ps_uniform.glsl\";\n#include?COLOR_FILTER \"parts/ColorFilter_ps_uniform.glsl\";\n#include?GLOW_FILTER \"parts/GlowFilter_ps_uniform.glsl\";\n#include?COLOR_ADD \"parts/ColorAdd_ps_uniform.glsl\";\n\nvoid main() {\n vec2 newTexCoord;\n newTexCoord.x = mod(u_offset.x + v_texcoord.x,u_TexRange.y) + u_TexRange.x;\n newTexCoord.y = mod(u_offset.y + v_texcoord.y,u_TexRange.w) + u_TexRange.z;\n vec4 color= texture2D(texture, newTexCoord);\n color.a*=alpha;\n gl_FragColor=color;\n #include?COLOR_ADD \"parts/ColorAdd_ps_logic.glsl\"; \n #include?BLUR_FILTER \"parts/BlurFilter_ps_logic.glsl\";\n #include?COLOR_FILTER \"parts/ColorFilter_ps_logic.glsl\";\n #include?GLOW_FILTER \"parts/GlowFilter_ps_logic.glsl\";\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/files/fillTextureShader.ps*/; + Shader.preCompile2D(0,/*laya.webgl.shader.d2.ShaderDefines2D.FILLTEXTURE*/0x100,vs,ps,null); + vs="attribute vec2 position;\nattribute vec2 texcoord;\nattribute vec4 color;\nuniform vec2 size;\nuniform float offsetX;\nuniform float offsetY;\nuniform mat4 mmat;\nuniform mat4 u_mmat2;\nvarying vec2 v_texcoord;\nvarying vec4 v_color;\nvoid main() {\n vec4 pos=mmat*u_mmat2*vec4(offsetX+position.x,offsetY+position.y,0,1 );\n gl_Position = vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n v_color = color;\n v_texcoord = texcoord; \n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/skinAnishader/skinShader.vs*/; + ps="precision mediump float;\nvarying vec2 v_texcoord;\nvarying vec4 v_color;\nuniform sampler2D texture;\nuniform float alpha;\nvoid main() {\n vec4 t_color = texture2D(texture, v_texcoord);\n gl_FragColor = t_color.rgba * v_color;\n gl_FragColor.a = gl_FragColor.a * alpha;\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/webGL/src/laya/webgl/shader/d2/skinAnishader/skinShader.ps*/; + Shader.preCompile2D(0,/*laya.webgl.shader.d2.ShaderDefines2D.SKINMESH*/0x200,vs,ps,null); + } + + return Shader2D; + })() + + + //class laya.webgl.shader.ShaderDefines + var ShaderDefines=(function(){ + function ShaderDefines(name2int,int2name,int2nameMap){ + this._value=0; + //this._name2int=null; + //this._int2name=null; + //this._int2nameMap=null; + this._name2int=name2int; + this._int2name=int2name; + this._int2nameMap=int2nameMap; + } + + __class(ShaderDefines,'laya.webgl.shader.ShaderDefines'); + var __proto=ShaderDefines.prototype; + __proto.add=function(value){ + if ((typeof value=='string'))value=this._name2int[value]; + this._value |=value; + return this._value; + } + + __proto.addInt=function(value){ + this._value |=value; + return this._value; + } + + __proto.remove=function(value){ + if ((typeof value=='string'))value=this._name2int[value]; + this._value &=(~value); + return this._value; + } + + __proto.isDefine=function(def){ + return (this._value & def)===def; + } + + __proto.getValue=function(){ + return this._value; + } + + __proto.setValue=function(value){ + this._value=value; + } + + __proto.toNameDic=function(){ + var r=this._int2nameMap[this._value]; + return r ? r :ShaderDefines._toText(this._value,this._int2name,this._int2nameMap); + } + + ShaderDefines._reg=function(name,value,_name2int,_int2name){ + _name2int[name]=value; + _int2name[value]=name; + } + + ShaderDefines._toText=function(value,_int2name,_int2nameMap){ + var r=_int2nameMap[value]; + if (r)return r; + var o={}; + var d=1; + for (var i=0;i < 32;i++){ + d=1 << i; + if (d > value)break ; + if (value & d){ + var name=_int2name[d]; + name && (o[name]=""); + } + } + _int2nameMap[value]=o; + return o; + } + + ShaderDefines._toInt=function(names,_name2int){ + var words=names.split('.'); + var num=0; + for (var i=0,n=words.length;i < n;i++){ + var value=_name2int[words[i]]; + if (!value)throw new Error("Defines to int err:"+names+"/"+words[i]); + num |=value; + } + return num; + } + + return ShaderDefines; + })() + + + /** + *这里销毁的问题,后面待确认 + */ + //class laya.webgl.shader.d2.skinAnishader.SkinMesh + var SkinMesh=(function(){ + function SkinMesh(){ + this.mVBBuffer=null; + this.mIBBuffer=null; + this.mVBData=null; + this.mIBData=null; + this.mEleNum=0; + this.mTexture=null; + this.transform=null; + this._vs=null; + this._ps=null; + this._resultPs=null; + this._start=-1; + this._indexStart=-1; + this._tempMatrix=new Matrix(); + } + + __class(SkinMesh,'laya.webgl.shader.d2.skinAnishader.SkinMesh'); + var __proto=SkinMesh.prototype; + __proto.init=function(texture,vs,ps){ + if (vs){ + this._vs=vs; + }else { + this._vs=[]; + var tWidth=texture.width; + var tHeight=texture.height; + var tRed=1; + var tGreed=1; + var tBlue=1; + var tAlpha=1; + this._vs.push(0,0,0,0,tRed,tGreed,tBlue,tAlpha); + this._vs.push(tWidth,0,1,0,tRed,tGreed,tBlue,tAlpha); + this._vs.push(tWidth,tHeight,1,1,tRed,tGreed,tBlue,tAlpha); + this._vs.push(0,tHeight,0,1,tRed,tGreed,tBlue,tAlpha); + } + if (ps){ + this._ps=ps; + }else { + this._ps=[]; + this._ps.push(0,1,3,3,1,2); + } + this.mVBData=new Float32Array(this._vs); + this.mEleNum=this._ps.length; + this.mTexture=texture; + } + + __proto.getData=function(vb,ib,start){ + this.mVBBuffer=vb; + this.mIBBuffer=ib; + vb.append(this.mVBData); + this._start=start; + this._indexStart=ib.byteLength; + if (this._resultPs==null)this._resultPs=[]; + this._resultPs.length=0; + for (var i=0,n=this._ps.length;i < n;i++){ + this._resultPs.push(this._ps[i]+start); + } + this.mIBData=new Uint16Array(this._resultPs); + ib.append(this.mIBData); + } + + __proto.render=function(context,x,y){ + if (Render.isWebGL && this.mTexture){ + context._renderKey=0; + context._shader2D.glTexture=null; + SkinMeshBuffer.getInstance().addSkinMesh(this); + var tempSubmit=Submit.createShape(context,this.mIBBuffer,this.mVBBuffer,this.mEleNum,this._indexStart,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.SKINMESH*/0x200,0)); + this.transform || (this.transform=Matrix.EMPTY); + this.transform.translate(x,y); + Matrix.mul(this.transform,context._curMat,this._tempMatrix); + this.transform.translate(-x,-y); + var tArray=RenderState2D.getMatrArray(); + RenderState2D.mat2MatArray(this._tempMatrix,tArray); + var tShaderValue=tempSubmit.shaderValue; + tShaderValue.textureHost=this.mTexture; + tShaderValue.offsetX=0; + tShaderValue.offsetY=0; + tShaderValue.u_mmat2=tArray; + tShaderValue.ALPHA=context._shader2D.ALPHA; + context._submits[context._submits._length++]=tempSubmit; + } + else if (Render.isConchApp&&this.mTexture){ + this.transform || (this.transform=Matrix.EMPTY); + context.setSkinMesh&&context.setSkinMesh(x,y,this._ps,this.mVBData,this.mEleNum,0,this.mTexture,this.transform); + } + } + + return SkinMesh; + })() + + + //class laya.webgl.shader.d2.skinAnishader.SkinMeshBuffer + var SkinMeshBuffer=(function(){ + function SkinMeshBuffer(){ + this.ib=null; + this.vb=null; + var gl=WebGL.mainContext; + this.ib=IndexBuffer2D.create(/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this.vb=VertexBuffer2D.create(8); + } + + __class(SkinMeshBuffer,'laya.webgl.shader.d2.skinAnishader.SkinMeshBuffer'); + var __proto=SkinMeshBuffer.prototype; + __proto.addSkinMesh=function(skinMesh){ + skinMesh.getData(this.vb,this.ib,this.vb.byteLength / 32); + } + + __proto.reset=function(){ + this.vb.clear(); + this.ib.clear(); + } + + SkinMeshBuffer.getInstance=function(){ + return SkinMeshBuffer.instance=SkinMeshBuffer.instance|| new SkinMeshBuffer(); + } + + SkinMeshBuffer.instance=null + return SkinMeshBuffer; + })() + + + //此类可以减少代码 + //class laya.webgl.shapes.BasePoly + var BasePoly=(function(){ + function BasePoly(x,y,width,height,edges,color,borderWidth,borderColor,round){ + //this.x=NaN; + //this.y=NaN; + //this.r=NaN; + //this.width=NaN; + //this.height=NaN; + //this.edges=NaN; + this.r0=0 + //this.color=0; + //this.borderColor=NaN; + //this.borderWidth=NaN; + //this.round=0; + this.fill=true; + this.r1=Math.PI / 2; + (round===void 0)&& (round=0); + this.x=x; + this.y=y; + this.width=width; + this.height=height; + this.edges=edges; + this.color=color; + this.borderWidth=borderWidth; + this.borderColor=borderColor; + } + + __class(BasePoly,'laya.webgl.shapes.BasePoly'); + var __proto=BasePoly.prototype; + Laya.imps(__proto,{"laya.webgl.shapes.IShape":true}) + __proto.getData=function(ib,vb,start){} + __proto.sector=function(outVert,outIndex,start){ + var x=this.x,y=this.y,edges=this.edges,seg=(this.r1-this.r0)/ edges; + var w=this.width,h=this.height,color=this.color; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + outVert.push(x,y,r,g,b); + for (var i=0;i < edges+1;i++){ + outVert.push(x+Math.sin(seg *i+this.r0)*w,y+Math.cos(seg *i+this.r0)*h); + outVert.push(r,g,b); + } + for (i=0;i < edges;i++){ + outIndex.push(start,start+i+1,start+i+2); + } + } + + //用于画线 + __proto.createLine2=function(p,indices,lineWidth,len,outVertex,indexCount){ + var points=p.concat(); + var result=outVertex; + var color=this.borderColor; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + var length=points.length / 2; + var iStart=len,w=lineWidth / 2; + var px,py,p1x,p1y,p2x,p2y,p3x,p3y; + var perpx,perpy,perp2x,perp2y,perp3x,perp3y; + var a1,b1,c1,a2,b2,c2; + var denom,pdist,dist; + p1x=points[0]; + p1y=points[1]; + p2x=points[2]; + p2y=points[3]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p1x-perpx+this.x,p1y-perpy+this.y,r,g,b,p1x+perpx+this.x,p1y+perpy+this.y,r,g,b); + for (var i=1;i < length-1;i++){ + p1x=points[(i-1)*2]; + p1y=points[(i-1)*2+1]; + p2x=points[(i)*2]; + p2y=points[(i)*2+1]; + p3x=points[(i+1)*2]; + p3y=points[(i+1)*2+1]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + perp2x=-(p2y-p3y); + perp2y=p2x-p3x; + dist=Math.sqrt(perp2x *perp2x+perp2y *perp2y); + perp2x=perp2x / dist *w; + perp2y=perp2y / dist *w; + a1=(-perpy+p1y)-(-perpy+p2y); + b1=(-perpx+p2x)-(-perpx+p1x); + c1=(-perpx+p1x)*(-perpy+p2y)-(-perpx+p2x)*(-perpy+p1y); + a2=(-perp2y+p3y)-(-perp2y+p2y); + b2=(-perp2x+p2x)-(-perp2x+p3x); + c2=(-perp2x+p3x)*(-perp2y+p2y)-(-perp2x+p2x)*(-perp2y+p3y); + denom=a1 *b2-a2 *b1; + if (Math.abs(denom)< 0.1){ + denom+=10.1; + result.push(p2x-perpx+this.x,p2y-perpy+this.y,r,g,b,p2x+perpx+this.x,p2y+perpy+this.y,r,g,b); + continue ; + } + px=(b1 *c2-b2 *c1)/ denom; + py=(a2 *c1-a1 *c2)/ denom; + pdist=(px-p2x)*(px-p2x)+(py-p2y)+(py-p2y); + result.push(px+this.x,py+this.y,r,g,b,p2x-(px-p2x)+this.x,p2y-(py-p2y)+this.y,r,g,b); + } + p1x=points[points.length-4]; + p1y=points[points.length-3]; + p2x=points[points.length-2]; + p2y=points[points.length-1]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p2x-perpx+this.x,p2y-perpy+this.y,r,g,b,p2x+perpx+this.x,p2y+perpy+this.y,r,g,b); + var groupLen=indexCount; + for (i=1;i < groupLen;i++){ + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+i *2+1,iStart+i *2+1,iStart+i *2,iStart+(i-1)*2); + } + return result; + } + + //用于比如 扇形 不带两直线 + __proto.createLine=function(p,indices,lineWidth,len){ + var points=p.concat(); + var result=p; + var color=this.borderColor; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + points.splice(0,5); + var length=points.length / 5; + var iStart=len,w=lineWidth / 2; + var px,py,p1x,p1y,p2x,p2y,p3x,p3y; + var perpx,perpy,perp2x,perp2y,perp3x,perp3y; + var a1,b1,c1,a2,b2,c2; + var denom,pdist,dist; + p1x=points[0]; + p1y=points[1]; + p2x=points[5]; + p2y=points[6]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p1x-perpx,p1y-perpy,r,g,b,p1x+perpx,p1y+perpy,r,g,b); + for (var i=1;i < length-1;i++){ + p1x=points[(i-1)*5]; + p1y=points[(i-1)*5+1]; + p2x=points[(i)*5]; + p2y=points[(i)*5+1]; + p3x=points[(i+1)*5]; + p3y=points[(i+1)*5+1]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + perp2x=-(p2y-p3y); + perp2y=p2x-p3x; + dist=Math.sqrt(perp2x *perp2x+perp2y *perp2y); + perp2x=perp2x / dist *w; + perp2y=perp2y / dist *w; + a1=(-perpy+p1y)-(-perpy+p2y); + b1=(-perpx+p2x)-(-perpx+p1x); + c1=(-perpx+p1x)*(-perpy+p2y)-(-perpx+p2x)*(-perpy+p1y); + a2=(-perp2y+p3y)-(-perp2y+p2y); + b2=(-perp2x+p2x)-(-perp2x+p3x); + c2=(-perp2x+p3x)*(-perp2y+p2y)-(-perp2x+p2x)*(-perp2y+p3y); + denom=a1 *b2-a2 *b1; + if (Math.abs(denom)< 0.1){ + denom+=10.1; + result.push(p2x-perpx,p2y-perpy,r,g,b,p2x+perpx,p2y+perpy,r,g,b); + continue ; + } + px=(b1 *c2-b2 *c1)/ denom; + py=(a2 *c1-a1 *c2)/ denom; + pdist=(px-p2x)*(px-p2x)+(py-p2y)+(py-p2y); + result.push(px,py,r,g,b,p2x-(px-p2x),p2y-(py-p2y),r,g,b); + } + p1x=points[points.length-10]; + p1y=points[points.length-9]; + p2x=points[points.length-5]; + p2y=points[points.length-4]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p2x-perpx,p2y-perpy,r,g,b,p2x+perpx,p2y+perpy,r,g,b); + var groupLen=this.edges+1; + for (i=1;i < groupLen;i++){ + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+i *2+1,iStart+i *2+1,iStart+i *2,iStart+(i-1)*2); + } + return result; + } + + //闭合路径 + __proto.createLoopLine=function(p,indices,lineWidth,len,outVertex,outIndex){ + var points=p.concat(); + var result=outVertex ? outVertex :p; + var color=this.borderColor; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + points.splice(0,5); + var firstPoint=[points[0],points[1]]; + var lastPoint=[points[points.length-5],points[points.length-4]]; + var midPointX=lastPoint[0]+(firstPoint[0]-lastPoint[0])*0.5; + var midPointY=lastPoint[1]+(firstPoint[1]-lastPoint[1])*0.5; + points.unshift(midPointX,midPointY,0,0,0); + points.push(midPointX,midPointY,0,0,0); + var length=points.length / 5; + var iStart=len,w=lineWidth / 2; + var px,py,p1x,p1y,p2x,p2y,p3x,p3y; + var perpx,perpy,perp2x,perp2y,perp3x,perp3y; + var a1,b1,c1,a2,b2,c2; + var denom,pdist,dist; + p1x=points[0]; + p1y=points[1]; + p2x=points[5]; + p2y=points[6]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p1x-perpx,p1y-perpy,r,g,b,p1x+perpx,p1y+perpy,r,g,b); + for (var i=1;i < length-1;i++){ + p1x=points[(i-1)*5]; + p1y=points[(i-1)*5+1]; + p2x=points[(i)*5]; + p2y=points[(i)*5+1]; + p3x=points[(i+1)*5]; + p3y=points[(i+1)*5+1]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + perp2x=-(p2y-p3y); + perp2y=p2x-p3x; + dist=Math.sqrt(perp2x *perp2x+perp2y *perp2y); + perp2x=perp2x / dist *w; + perp2y=perp2y / dist *w; + a1=(-perpy+p1y)-(-perpy+p2y); + b1=(-perpx+p2x)-(-perpx+p1x); + c1=(-perpx+p1x)*(-perpy+p2y)-(-perpx+p2x)*(-perpy+p1y); + a2=(-perp2y+p3y)-(-perp2y+p2y); + b2=(-perp2x+p2x)-(-perp2x+p3x); + c2=(-perp2x+p3x)*(-perp2y+p2y)-(-perp2x+p2x)*(-perp2y+p3y); + denom=a1 *b2-a2 *b1; + if (Math.abs(denom)< 0.1){ + denom+=10.1; + result.push(p2x-perpx,p2y-perpy,r,g,b,p2x+perpx,p2y+perpy,r,g,b); + continue ; + } + px=(b1 *c2-b2 *c1)/ denom; + py=(a2 *c1-a1 *c2)/ denom; + pdist=(px-p2x)*(px-p2x)+(py-p2y)+(py-p2y); + result.push(px,py,r,g,b,p2x-(px-p2x),p2y-(py-p2y),r,g,b); + } + if (outIndex){ + indices=outIndex; + }; + var groupLen=this.edges+1; + for (i=1;i < groupLen;i++){ + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+i *2+1,iStart+i *2+1,iStart+i *2,iStart+(i-1)*2); + } + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+1,iStart+1,iStart,iStart+(i-1)*2); + return result; + } + + return BasePoly; + })() + + + //class laya.webgl.shapes.GeometryData + var GeometryData=(function(){ + function GeometryData(lineWidth,lineColor,lineAlpha,fillColor,fillAlpha,fill,shape){ + //this.lineWidth=NaN; + //this.lineColor=NaN; + //this.lineAlpha=NaN; + //this.fillColor=NaN; + //this.fillAlpha=NaN; + //this.shape=null; + //this.fill=false; + this.lineWidth=lineWidth; + this.lineColor=lineColor; + this.lineAlpha=lineAlpha; + this.fillColor=fillColor; + this.fillAlpha=fillAlpha; + this.shape=shape; + this.fill=fill; + } + + __class(GeometryData,'laya.webgl.shapes.GeometryData'); + var __proto=GeometryData.prototype; + __proto.clone=function(){ + return new GeometryData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape); + } + + __proto.getIndexData=function(){ + return null; + } + + __proto.getVertexData=function(){ + return null; + } + + __proto.destroy=function(){ + this.shape=null; + } + + return GeometryData; + })() + + + //class laya.webgl.shapes.Vertex + var Vertex=(function(){ + function Vertex(p){ + //this.points=null; + if((p instanceof Float32Array)) + this.points=p; + else if((p instanceof Array)){ + var len=p.length; + this.points=new Float32Array(p); + } + } + + __class(Vertex,'laya.webgl.shapes.Vertex'); + var __proto=Vertex.prototype; + Laya.imps(__proto,{"laya.webgl.shapes.IShape":true}) + __proto.getData=function(ib,vb,start){} + return Vertex; + })() + + + //class laya.webgl.submit.Submit + var Submit=(function(){ + function Submit(renderType){ + //this._selfVb=null; + //this._ib=null; + //this._blendFn=null; + //this._renderType=0; + //this._vb=null; + //this._startIdx=0; + //this._numEle=0; + //this.shaderValue=null; + (renderType===void 0)&& (renderType=10000); + this._renderType=renderType; + } + + __class(Submit,'laya.webgl.submit.Submit'); + var __proto=Submit.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.releaseRender=function(){ + var cache=Submit._cache; + cache[cache._length++]=this; + this.shaderValue.release(); + this._vb=null; + } + + __proto.getRenderType=function(){ + return this._renderType; + } + + __proto.renderSubmit=function(){ + if (this._numEle===0)return 1; + var _tex=this.shaderValue.textureHost; + if (_tex){ + var source=_tex.source; + if (!_tex.bitmap || !source) + return 1; + this.shaderValue.texture=source; + } + this._vb.bind_upload(this._ib); + var gl=WebGL.mainContext; + this.shaderValue.upload(); + if (BlendMode.activeBlendFunction!==this._blendFn){ + gl.enable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + this._blendFn(gl); + BlendMode.activeBlendFunction=this._blendFn; + } + Stat.drawCall++; + Stat.trianglesFaces+=this._numEle / 3; + gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._numEle,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._startIdx); + return 1; + } + + Submit.__init__=function(){ + var s=Submit.RENDERBASE=new Submit(-1); + s.shaderValue=new Value2D(0,0); + s.shaderValue.ALPHA=-1234; + } + + Submit.create=function(context,ib,vb,pos,sv){ + var o=Submit._cache._length ? Submit._cache[--Submit._cache._length] :new Submit(); + if (vb==null){ + vb=o._selfVb || (o._selfVb=VertexBuffer2D.create(-1)); + vb.clear(); + pos=0; + } + o._ib=ib; + o._vb=vb; + o._startIdx=pos *CONST3D2D.BYTES_PIDX; + o._numEle=0; + var blendType=context._nBlendType; + o._blendFn=context._targets ? BlendMode.targetFns[blendType] :BlendMode.fns[blendType]; + o.shaderValue=sv; + o.shaderValue.setValue(context._shader2D); + var filters=context._shader2D.filters; + filters && o.shaderValue.setFilters(filters); + return o; + } + + Submit.createShape=function(ctx,ib,vb,numEle,offset,sv){ + var o=(!Submit._cache._length)? (new Submit()):Submit._cache[--Submit._cache._length]; + o._ib=ib; + o._vb=vb; + o._numEle=numEle; + o._startIdx=offset; + o.shaderValue=sv; + o.shaderValue.setValue(ctx._shader2D); + var blendType=ctx._nBlendType; + o._blendFn=ctx._targets ? BlendMode.targetFns[blendType] :BlendMode.fns[blendType]; + return o; + } + + Submit.TYPE_2D=10000; + Submit.TYPE_CANVAS=10003; + Submit.TYPE_CMDSETRT=10004; + Submit.TYPE_CUSTOM=10005; + Submit.TYPE_BLURRT=10006; + Submit.TYPE_CMDDESTORYPRERT=10007; + Submit.TYPE_DISABLESTENCIL=10008; + Submit.TYPE_OTHERIBVB=10009; + Submit.TYPE_PRIMITIVE=10010; + Submit.TYPE_RT=10011; + Submit.TYPE_BLUR_RT=10012; + Submit.TYPE_TARGET=10013; + Submit.TYPE_CHANGE_VALUE=10014; + Submit.TYPE_SHAPE=10015; + Submit.TYPE_TEXTURE=10016; + Submit.RENDERBASE=null + Submit._cache=(Submit._cache=[],Submit._cache._length=0,Submit._cache); + return Submit; + })() + + + //class laya.webgl.submit.SubmitCMD + var SubmitCMD=(function(){ + function SubmitCMD(){ + this.fun=null; + this.args=null; + } + + __class(SubmitCMD,'laya.webgl.submit.SubmitCMD'); + var __proto=SubmitCMD.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.renderSubmit=function(){ + this.fun.apply(null,this.args); + return 1; + } + + __proto.getRenderType=function(){ + return 0; + } + + __proto.releaseRender=function(){ + var cache=SubmitCMD._cache; + cache[cache._length++]=this; + } + + SubmitCMD.create=function(args,fun){ + var o=SubmitCMD._cache._length?SubmitCMD._cache[--SubmitCMD._cache._length]:new SubmitCMD(); + o.fun=fun; + o.args=args; + return o; + } + + SubmitCMD._cache=(SubmitCMD._cache=[],SubmitCMD._cache._length=0,SubmitCMD._cache); + return SubmitCMD; + })() + + + //class laya.webgl.submit.SubmitCMDScope + var SubmitCMDScope=(function(){ + function SubmitCMDScope(){ + this.variables={}; + } + + __class(SubmitCMDScope,'laya.webgl.submit.SubmitCMDScope'); + var __proto=SubmitCMDScope.prototype; + __proto.getValue=function(name){ + return this.variables[name]; + } + + __proto.addValue=function(name,value){ + return this.variables[name]=value; + } + + __proto.setValue=function(name,value){ + if(this.variables.hasOwnProperty(name)){ + return this.variables[name]=value; + } + return null; + } + + __proto.clear=function(){ + for(var key in this.variables){ + delete this.variables[key]; + } + } + + __proto.recycle=function(){ + this.clear(); + SubmitCMDScope.POOL.push(this); + } + + SubmitCMDScope.create=function(){ + var scope=SubmitCMDScope.POOL.pop(); + scope||(scope=new SubmitCMDScope()); + return scope; + } + + SubmitCMDScope.POOL=[]; + return SubmitCMDScope; + })() + + + //class laya.webgl.submit.SubmitOtherIBVB + var SubmitOtherIBVB=(function(){ + function SubmitOtherIBVB(){ + this.offset=0; + //this._vb=null; + //this._ib=null; + //this._blendFn=null; + //this._mat=null; + //this._shader=null; + //this._shaderValue=null; + //this._numEle=0; + this.startIndex=0; + ; + this._mat=Matrix.create(); + } + + __class(SubmitOtherIBVB,'laya.webgl.submit.SubmitOtherIBVB'); + var __proto=SubmitOtherIBVB.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.releaseRender=function(){ + var cache=SubmitOtherIBVB._cache; + cache[cache._length++]=this; + } + + __proto.getRenderType=function(){ + return /*laya.webgl.submit.Submit.TYPE_OTHERIBVB*/10009; + } + + __proto.renderSubmit=function(){ + var _tex=this._shaderValue.textureHost; + if (_tex){ + var source=_tex.source; + if (!_tex.bitmap || !source) + return 1; + this._shaderValue.texture=source; + } + this._vb.bind_upload(this._ib); + var w=RenderState2D.worldMatrix4; + var wmat=Matrix.TEMP; + Matrix.mulPre(this._mat,w[0],w[1],w[4],w[5],w[12],w[13],wmat); + var tmp=RenderState2D.worldMatrix4=SubmitOtherIBVB.tempMatrix4; + tmp[0]=wmat.a; + tmp[1]=wmat.b; + tmp[4]=wmat.c; + tmp[5]=wmat.d; + tmp[12]=wmat.tx; + tmp[13]=wmat.ty; + this._shader._offset=this.offset; + this._shaderValue.refresh(); + this._shader.upload(this._shaderValue); + this._shader._offset=0; + var gl=WebGL.mainContext; + if (BlendMode.activeBlendFunction!==this._blendFn){ + gl.enable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + this._blendFn(gl); + BlendMode.activeBlendFunction=this._blendFn; + } + Stat.drawCall++; + Stat.trianglesFaces+=this._numEle / 3; + gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._numEle,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this.startIndex); + RenderState2D.worldMatrix4=w; + Shader.activeShader=null; + return 1; + } + + SubmitOtherIBVB.create=function(context,vb,ib,numElement,shader,shaderValue,startIndex,offset,type){ + (type===void 0)&& (type=0); + var o=(!SubmitOtherIBVB._cache._length)? (new SubmitOtherIBVB()):SubmitOtherIBVB._cache[--SubmitOtherIBVB._cache._length]; + o._ib=ib; + o._vb=vb; + o._numEle=numElement; + o._shader=shader; + o._shaderValue=shaderValue; + var blendType=context._nBlendType; + o._blendFn=context._targets ? BlendMode.targetFns[blendType] :BlendMode.fns[blendType]; + switch(type){ + case 0: + o.offset=0; + o.startIndex=offset / (CONST3D2D.BYTES_PE *vb.vertexStride)*1.5; + o.startIndex *=CONST3D2D.BYTES_PIDX; + break ; + case 1: + o.startIndex=startIndex; + o.offset=offset; + break ; + } + return o; + } + + SubmitOtherIBVB._cache=(SubmitOtherIBVB._cache=[],SubmitOtherIBVB._cache._length=0,SubmitOtherIBVB._cache); + SubmitOtherIBVB.tempMatrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,]; + return SubmitOtherIBVB; + })() + + + //class laya.webgl.submit.SubmitScissor + var SubmitScissor=(function(){ + function SubmitScissor(){ + this.submitIndex=0; + this.submitLength=0; + this.context=null; + this.clipRect=new Rectangle(); + this.screenRect=new Rectangle(); + } + + __class(SubmitScissor,'laya.webgl.submit.SubmitScissor'); + var __proto=SubmitScissor.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto._scissor=function(x,y,w,h){ + var m=RenderState2D.worldMatrix4; + var a=m[0],d=m[5],tx=m[12],ty=m[13]; + x=x *a+tx; + y=y *d+ty; + w *=a; + h *=d; + if (w < 1 || h < 1){ + return false; + }; + var r=x+w; + var b=y+h; + x < 0 && (x=0,w=r-x); + y < 0 && (y=0,h=b-y); + var screen=RenderState2D.worldClipRect; + x=Math.max(x,screen.x); + y=Math.max(y,screen.y); + w=Math.min(r,screen.right)-x; + h=Math.min(b,screen.bottom)-y; + if (w < 1 || h < 1){ + return false; + }; + var worldScissorTest=RenderState2D.worldScissorTest; + this.screenRect.copyFrom(screen); + screen.x=x; + screen.y=y; + screen.width=w; + screen.height=h; + RenderState2D.worldScissorTest=true; + y=RenderState2D.height-y-h; + WebGL.mainContext.scissor(x,y,w,h); + WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + this.context.submitElement(this.submitIndex,this.submitIndex+this.submitLength); + if (worldScissorTest){ + y=RenderState2D.height-this.screenRect.y-this.screenRect.height; + WebGL.mainContext.scissor(this.screenRect.x,y,this.screenRect.width,this.screenRect.height); + WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + } + else{ + WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + RenderState2D.worldScissorTest=false; + } + screen.copyFrom(this.screenRect); + return true; + } + + __proto._scissorWithTagart=function(x,y,w,h){ + if (w < 1 || h < 1){ + return false; + }; + var r=x+w; + var b=y+h; + x < 0 && (x=0,w=r-x); + y < 0 && (y=0,h=b-y); + var screen=RenderState2D.worldClipRect; + x=Math.max(x,screen.x); + y=Math.max(y,screen.y); + w=Math.min(r,screen.right)-x; + h=Math.min(b,screen.bottom)-y; + if (w < 1 || h < 1){ + return false; + }; + var worldScissorTest=RenderState2D.worldScissorTest; + this.screenRect.copyFrom(screen); + RenderState2D.worldScissorTest=true; + screen.x=x; + screen.y=y; + screen.width=w; + screen.height=h; + y=RenderState2D.height-y-h; + WebGL.mainContext.scissor(x,y,w,h); + WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + this.context.submitElement(this.submitIndex,this.submitIndex+this.submitLength); + if (worldScissorTest){ + y=RenderState2D.height-this.screenRect.y-this.screenRect.height; + WebGL.mainContext.scissor(this.screenRect.x,y,this.screenRect.width,this.screenRect.height); + WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + } + else{ + WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + RenderState2D.worldScissorTest=false; + } + screen.copyFrom(this.screenRect); + return true; + } + + __proto.renderSubmit=function(){ + this.submitLength=Math.min(this.context._submits._length-1,this.submitLength); + if (this.submitLength < 1 || this.clipRect.width < 1 || this.clipRect.height < 1) + return this.submitLength+1; + if (this.context._targets) + this._scissorWithTagart(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height); + else this._scissor(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height); + return this.submitLength+1; + } + + __proto.getRenderType=function(){ + return 0; + } + + __proto.releaseRender=function(){ + var cache=SubmitScissor._cache; + cache[cache._length++]=this; + this.context=null; + } + + SubmitScissor.create=function(context){ + var o=SubmitScissor._cache._length?SubmitScissor._cache[--SubmitScissor._cache._length]:new SubmitScissor(); + o.context=context; + return o; + } + + SubmitScissor._cache=(SubmitScissor._cache=[],SubmitScissor._cache._length=0,SubmitScissor._cache); + return SubmitScissor; + })() + + + //class laya.webgl.submit.SubmitStencil + var SubmitStencil=(function(){ + function SubmitStencil(){ + this.step=0; + this.blendMode=null; + this.level=0; + } + + __class(SubmitStencil,'laya.webgl.submit.SubmitStencil'); + var __proto=SubmitStencil.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.renderSubmit=function(){ + switch(this.step){ + case 1: + this.do1(); + break ; + case 2: + this.do2(); + break ; + case 3: + this.do3(); + break ; + case 4: + this.do4(); + break ; + case 5: + this.do5(); + break ; + case 6: + this.do6(); + break ; + } + return 1; + } + + __proto.getRenderType=function(){ + return 0; + } + + __proto.releaseRender=function(){ + var cache=SubmitStencil._cache; + cache[cache._length++]=this; + } + + __proto.do1=function(){ + var gl=WebGL.mainContext; + gl.enable(/*laya.webgl.WebGLContext.STENCIL_TEST*/0x0B90); + gl.clear(/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400); + gl.colorMask(false,false,false,false); + gl.stencilFunc(/*laya.webgl.WebGLContext.EQUAL*/0x0202,this.level,0xFF); + gl.stencilOp(/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.INCR*/0x1E02); + } + + //gl.stencilOp(WebGLContext.KEEP,WebGLContext.KEEP,WebGLContext.INVERT);//测试通过给模版缓冲 写入值 一开始是0 现在是 0xFF (模版缓冲中不知道是多少位的数据) + __proto.do2=function(){ + var gl=WebGL.mainContext; + gl.stencilFunc(/*laya.webgl.WebGLContext.EQUAL*/0x0202,this.level+1,0xFF); + gl.colorMask(true,true,true,true); + gl.stencilOp(/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00); + } + + __proto.do3=function(){ + var gl=WebGL.mainContext; + gl.colorMask(true,true,true,true); + gl.stencilOp(/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00); + gl.clear(/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400); + gl.disable(/*laya.webgl.WebGLContext.STENCIL_TEST*/0x0B90); + } + + __proto.do4=function(){ + var gl=WebGL.mainContext; + gl.enable(/*laya.webgl.WebGLContext.STENCIL_TEST*/0x0B90); + gl.clear(/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400); + gl.colorMask(false,false,false,false); + gl.stencilFunc(/*laya.webgl.WebGLContext.ALWAYS*/0x0207,this.level,0xFF); + gl.stencilOp(/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.INVERT*/0x150A); + } + + __proto.do5=function(){ + var gl=WebGL.mainContext; + gl.stencilFunc(/*laya.webgl.WebGLContext.EQUAL*/0x0202,0xff,0xFF); + gl.colorMask(true,true,true,true); + gl.stencilOp(/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00,/*laya.webgl.WebGLContext.KEEP*/0x1E00); + } + + __proto.do6=function(){ + var gl=WebGL.mainContext; + BlendMode.targetFns[BlendMode.TOINT[this.blendMode]](gl); + } + + SubmitStencil.create=function(step){ + var o=SubmitStencil._cache._length?SubmitStencil._cache[--SubmitStencil._cache._length]:new SubmitStencil(); + o.step=step; + return o; + } + + SubmitStencil._cache=(SubmitStencil._cache=[],SubmitStencil._cache._length=0,SubmitStencil._cache); + return SubmitStencil; + })() + + + //class laya.webgl.submit.SubmitTarget + var SubmitTarget=(function(){ + function SubmitTarget(){ + this._renderType=0; + this._vb=null; + this._ib=null; + this._startIdx=0; + this._numEle=0; + this.shaderValue=null; + this.blendType=0; + this.proName=null; + this.scope=null; + } + + __class(SubmitTarget,'laya.webgl.submit.SubmitTarget'); + var __proto=SubmitTarget.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.renderSubmit=function(){ + this._vb.bind_upload(this._ib); + var target=this.scope.getValue(this.proName); + if (target){ + this.shaderValue.texture=target.source; + this.shaderValue.upload(); + this.blend(); + Stat.drawCall++; + Stat.trianglesFaces+=this._numEle/3; + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._numEle,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._startIdx); + } + return 1; + } + + __proto.blend=function(){ + if (BlendMode.activeBlendFunction!==BlendMode.fns[this.blendType]){ + var gl=WebGL.mainContext; + gl.enable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + BlendMode.fns[this.blendType](gl); + BlendMode.activeBlendFunction=BlendMode.fns[this.blendType]; + } + } + + __proto.getRenderType=function(){ + return 0; + } + + __proto.releaseRender=function(){ + var cache=SubmitTarget._cache; + cache[cache._length++]=this; + } + + SubmitTarget.create=function(context,ib,vb,pos,sv,proName){ + var o=SubmitTarget._cache._length?SubmitTarget._cache[--SubmitTarget._cache._length]:new SubmitTarget(); + o._ib=ib; + o._vb=vb; + o.proName=proName; + o._startIdx=pos *CONST3D2D.BYTES_PIDX; + o._numEle=0; + o.blendType=context._nBlendType; + o.shaderValue=sv; + o.shaderValue.setValue(context._shader2D); + return o; + } + + SubmitTarget._cache=(SubmitTarget._cache=[],SubmitTarget._cache._length=0,SubmitTarget._cache); + return SubmitTarget; + })() + + + /** + *...特殊的字符,如泰文,必须重新实现这个类 + */ + //class laya.webgl.text.CharSegment + var CharSegment=(function(){ + function CharSegment(){ + this._sourceStr=null; + } + + __class(CharSegment,'laya.webgl.text.CharSegment'); + var __proto=CharSegment.prototype; + Laya.imps(__proto,{"laya.webgl.text.ICharSegment":true}) + __proto.textToSpit=function(str){ + this._sourceStr=str; + } + + __proto.getChar=function(i){ + return this._sourceStr.charAt(i); + } + + __proto.getCharCode=function(i){ + return this._sourceStr.charCodeAt(i); + } + + __proto.length=function(){ + return this._sourceStr.length; + } + + return CharSegment; + })() + + + //class laya.webgl.text.DrawText + var DrawText=(function(){ + var CharValue; + function DrawText(){}; + __class(DrawText,'laya.webgl.text.DrawText'); + DrawText.__init__=function(){ + DrawText._charsTemp=new Array; + DrawText._drawValue=new CharValue(); + DrawText._charSeg=new CharSegment(); + } + + DrawText.customCharSeg=function(charseg){ + DrawText._charSeg=charseg; + } + + DrawText.getChar=function(char,id,drawValue){ + return DrawText._charsCache[id]=DrawTextChar.createOneChar(char,drawValue); + } + + DrawText._drawSlow=function(save,ctx,txt,words,curMat,font,textAlign,fillColor,borderColor,lineWidth,x,y,sx,sy){ + var drawValue=DrawText._drawValue.value(font,fillColor,borderColor,lineWidth,sx,sy); + var i=0,n=0; + var chars=DrawText._charsTemp; + var width=0,oneChar,htmlWord,id=NaN; + if (words){ + chars.length=words.length; + for (i=0,n=words.length;i < n;i++){ + htmlWord=words[i]; + id=htmlWord.charNum+drawValue.txtID; + chars[i]=oneChar=DrawText._charsCache[id] || DrawText.getChar(htmlWord.char,id,drawValue); + oneChar.active(); + } + }else { + if ((txt instanceof laya.utils.WordText )) + DrawText._charSeg.textToSpit((txt).toString()); + else + DrawText._charSeg.textToSpit(txt); + var len=/*if err,please use iflash.method.xmlLength()*/DrawText._charSeg.length(); + chars.length=len; + for (i=0,n=len;i < n;i++){ + id=DrawText._charSeg.getCharCode(i)+drawValue.txtID; + chars[i]=oneChar=DrawText._charsCache[id] || DrawText.getChar(DrawText._charSeg.getChar(i),id,drawValue); + oneChar.active(); + width+=oneChar.width; + } + }; + var dx=0; + if (textAlign!==null && textAlign!=="left") + dx=-(textAlign=="center" ? (width / 2):width); + var uv,bdSz=NaN,texture,value,saveLength=0; + if (words){ + for (i=0,n=chars.length;i < n;i++){ + oneChar=chars[i]; + if (!oneChar.isSpace){ + htmlWord=words[i]; + bdSz=oneChar.borderSize; + texture=oneChar.texture; + ctx._drawText(texture,x+dx+htmlWord.x *sx-bdSz,y+htmlWord.y *sy-bdSz,texture.width,texture.height,curMat,0,0,0,0); + } + } + }else { + for (i=0,n=chars.length;i < n;i++){ + oneChar=chars[i]; + if (!oneChar.isSpace){ + bdSz=oneChar.borderSize; + texture=oneChar.texture; + ctx._drawText(texture,x+dx-bdSz,y-bdSz,texture.width,texture.height,curMat,0,0,0,0); + save && (value=save[saveLength++],value || (value=save[saveLength-1]=[]),value[0]=texture,value[1]=dx-bdSz,value[2]=-bdSz); + } + dx+=oneChar.width; + } + save && (save.length=saveLength); + } + } + + DrawText._drawFast=function(save,ctx,curMat,x,y){ + var texture,value; + for (var i=0,n=save.length;i < n;i++){ + value=save[i]; + texture=value[0]; + texture.active(); + ctx._drawText(texture,x+value[1],y+value[2],texture.width,texture.height,curMat,0,0,0,0); + } + } + + DrawText.drawText=function(ctx,txt,words,curMat,font,textAlign,fillColor,borderColor,lineWidth,x,y){ + if ((txt && txt.length===0)|| (words && words.length===0)) + return; + var sx=curMat.a,sy=curMat.d; + (curMat.b!==0 || curMat.c!==0)&& (sx=sy=1); + var scale=sx!==1 || sy!==1; + if (scale && Laya.stage.transform){ + var t=Laya.stage.transform; + scale=t.a===sx && t.d===sy; + }else scale=false; + if (scale){ + curMat=curMat.copyTo(WebGLContext2D._tmpMatrix); + curMat.scale(1 / sx,1 / sy); + curMat._checkTransform(); + x *=sx; + y *=sy; + }else sx=sy=1; + if (words){ + DrawText._drawSlow(null,ctx,txt,words,curMat,font,textAlign,fillColor,borderColor,lineWidth,x,y,sx,sy); + }else { + if (txt.toUpperCase===null){ + var idNum=sx+sy *100000; + var myCache=txt; + if (!myCache.changed && myCache.id===idNum){ + DrawText._drawFast(myCache.save,ctx,curMat,x,y); + }else { + myCache.id=idNum; + myCache.changed=false; + DrawText._drawSlow(myCache.save,ctx,txt,words,curMat,font,textAlign,fillColor,borderColor,lineWidth,x,y,sx,sy); + } + return; + }; + var id=txt+font.toString()+fillColor+borderColor+lineWidth+sx+sy+textAlign; + var cache=DrawText._textsCache[id]; + if (cache){ + DrawText._drawFast(cache,ctx,curMat,x,y); + }else { + DrawText._textsCache.__length || (DrawText._textsCache.__length=0); + if (DrawText._textsCache.__length > Config.WebGLTextCacheCount){ + DrawText._textsCache={}; + DrawText._textsCache.__length=0; + DrawText._curPoolIndex=0; + } + DrawText._textCachesPool[DrawText._curPoolIndex] ? (cache=DrawText._textsCache[id]=DrawText._textCachesPool[DrawText._curPoolIndex],cache.length=0):(DrawText._textCachesPool[DrawText._curPoolIndex]=cache=DrawText._textsCache[id]=[]); + DrawText._textsCache.__length++ + DrawText._curPoolIndex++; + DrawText._drawSlow(cache,ctx,txt,words,curMat,font,textAlign,fillColor,borderColor,lineWidth,x,y,sx,sy); + } + } + } + + DrawText._charsTemp=null + DrawText._textCachesPool=[]; + DrawText._curPoolIndex=0; + DrawText._charsCache={}; + DrawText._textsCache={}; + DrawText._drawValue=null + DrawText.d=[]; + DrawText._charSeg=null; + DrawText.__init$=function(){ + //class CharValue + CharValue=(function(){ + function CharValue(){ + //this.txtID=NaN; + //this.font=null; + //this.fillColor=null; + //this.borderColor=null; + //this.lineWidth=0; + //this.scaleX=NaN; + //this.scaleY=NaN; + } + __class(CharValue,''); + var __proto=CharValue.prototype; + __proto.value=function(font,fillColor,borderColor,lineWidth,scaleX,scaleY){ + this.font=font; + this.fillColor=fillColor; + this.borderColor=borderColor; + this.lineWidth=lineWidth; + this.scaleX=scaleX; + this.scaleY=scaleY; + var key=font.toString()+scaleX+scaleY+lineWidth+fillColor+borderColor; + this.txtID=CharValue._keymap[key]; + if (!this.txtID){ + this.txtID=(++CharValue._keymapCount)*0.0000001; + CharValue._keymap[key]=this.txtID; + } + return this; + } + CharValue.clear=function(){ + CharValue._keymap={}; + CharValue._keymapCount=1; + } + CharValue._keymap={}; + CharValue._keymapCount=1; + return CharValue; + })() + } + + return DrawText; + })() + + + //class laya.webgl.text.DrawTextChar + var DrawTextChar=(function(){ + function DrawTextChar(content,drawValue){ + //this.xs=NaN; + //this.ys=NaN; + //this.width=0; + //this.height=0; + //this.char=null; + //this.fillColor=null; + //this.borderColor=null; + //this.borderSize=0; + //this.font=null; + //this.fontSize=0; + //this.texture=null; + //this.lineWidth=0; + //this.UV=null; + //this.isSpace=false; + this.char=content; + this.isSpace=content===' '; + this.xs=drawValue.scaleX; + this.ys=drawValue.scaleY; + this.font=drawValue.font.toString(); + this.fontSize=drawValue.font.size; + this.fillColor=drawValue.fillColor; + this.borderColor=drawValue.borderColor; + this.lineWidth=drawValue.lineWidth; + var bIsConchApp=Render.isConchApp; + if (bIsConchApp){ + /*__JS__ */var pCanvas=ConchTextCanvas; + /*__JS__ */pCanvas._source=ConchTextCanvas; + /*__JS__ */pCanvas._source.canvas=ConchTextCanvas; + /*__JS__ */this.texture=new Texture(new WebGLCharImage(pCanvas,this)); + }else { + this.texture=new Texture(new WebGLCharImage(Browser.canvas.source,this)); + } + } + + __class(DrawTextChar,'laya.webgl.text.DrawTextChar'); + var __proto=DrawTextChar.prototype; + __proto.active=function(){ + this.texture.active(); + } + + DrawTextChar.createOneChar=function(content,drawValue){ + var char=new DrawTextChar(content,drawValue); + return char; + } + + return DrawTextChar; + })() + + + //class laya.webgl.text.FontInContext + var FontInContext=(function(){ + function FontInContext(font){ + //this._text=null; + //this._words=null; + this._index=0; + this._size=14; + this._italic=-2; + this.setFont(font || "14px Arial"); + } + + __class(FontInContext,'laya.webgl.text.FontInContext'); + var __proto=FontInContext.prototype; + __proto.setFont=function(value){ + this._words=value.split(' '); + for (var i=0,n=this._words.length;i < n;i++){ + if (this._words[i].indexOf('px')> 0){ + this._index=i; + break ; + } + } + this._size=parseInt(this._words[this._index]); + this._text=null; + this._italic=-2; + } + + __proto.getItalic=function(){ + this._italic===-2 && (this._italic=this.hasType("italic")); + return this._italic; + } + + __proto.hasType=function(name){ + for (var i=0,n=this._words.length;i < n;i++) + if (this._words[i]===name)return i; + return-1; + } + + __proto.removeType=function(name){ + for (var i=0,n=this._words.length;i < n;i++) + if (this._words[i]===name){ + this._words.splice(i,1); + if (this._index > i)this._index--; + break ; + } + this._text=null; + this._italic=-2; + } + + __proto.copyTo=function(dec){ + dec._text=this._text; + dec._size=this._size; + dec._index=this._index; + dec._words=this._words.slice(); + dec._italic=-2; + return dec; + } + + __proto.toString=function(){ + return this._text ? this._text :(this._text=this._words.join(' ')); + } + + __getset(0,__proto,'size',function(){ + return this._size; + },function(value){ + this._size=value; + this._words[this._index]=value+"px"; + this._text=null; + }); + + FontInContext.create=function(font){ + var r=FontInContext._cache[font]; + if (r)return r; + r=FontInContext._cache[font]=new FontInContext(font); + return r; + } + + FontInContext.EMPTY=new FontInContext(); + FontInContext._cache={}; + return FontInContext; + })() + + + //class laya.webgl.utils.CONST3D2D + var CONST3D2D=(function(){ + function CONST3D2D(){}; + __class(CONST3D2D,'laya.webgl.utils.CONST3D2D'); + CONST3D2D.defaultMatrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]; + CONST3D2D.defaultMinusYMatrix4=[1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1]; + CONST3D2D.uniformMatrix3=[1,0,0,0,0,1,0,0,0,0,1,0]; + CONST3D2D._TMPARRAY=[]; + CONST3D2D._OFFSETX=0; + CONST3D2D._OFFSETY=0; + __static(CONST3D2D, + ['BYTES_PE',function(){return this.BYTES_PE=/*__JS__ */Float32Array.BYTES_PER_ELEMENT;},'BYTES_PIDX',function(){return this.BYTES_PIDX=/*__JS__ */Uint16Array.BYTES_PER_ELEMENT;} + ]); + return CONST3D2D; + })() + + + //class laya.webgl.utils.GlUtils + var GlUtils=(function(){ + function GlUtils(){}; + __class(GlUtils,'laya.webgl.utils.GlUtils'); + GlUtils.make2DProjection=function(width,height,depth){ + return [2.0 / width,0,0,0,0,-2.0 / height,0,0,0,0,2.0 / depth,0,-1,1,0,1,]; + } + + GlUtils.fillIBQuadrangle=function(buffer,count){ + if (count > 65535 / 4){ + throw Error("IBQuadrangle count:"+count+" must<:"+Math.floor(65535 / 4)); + return false; + } + count=Math.floor(count); + buffer._resizeBuffer((count+1)*6 */*laya.webgl.utils.Buffer2D.SHORT*/2,false); + buffer.byteLength=buffer.bufferLength; + var bufferData=buffer.getUint16Array(); + var idx=0; + for (var i=0;i < count;i++){ + bufferData[idx++]=i *4; + bufferData[idx++]=i *4+2; + bufferData[idx++]=i *4+1; + bufferData[idx++]=i *4; + bufferData[idx++]=i *4+3; + bufferData[idx++]=i *4+2; + } + buffer.setNeedUpload(); + return true; + } + + GlUtils.expandIBQuadrangle=function(buffer,count){ + buffer.bufferLength >=(count *6 */*laya.webgl.utils.Buffer2D.SHORT*/2)|| GlUtils.fillIBQuadrangle(buffer,count); + } + + GlUtils.mathCeilPowerOfTwo=function(value){ + value--; + value |=value >> 1; + value |=value >> 2; + value |=value >> 4; + value |=value >> 8; + value |=value >> 16; + value++; + return value; + } + + GlUtils.fillQuadrangleImgVb=function(vb,x,y,point4,uv,m,_x,_y){ + 'use strict'; + var vpos=(vb._byteLength >> 2)+/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16; + vb.byteLength=(vpos << 2); + var vbdata=vb.getFloat32Array(); + vpos-=/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16; + vbdata[vpos+2]=uv[0]; + vbdata[vpos+3]=uv[1]; + vbdata[vpos+6]=uv[2]; + vbdata[vpos+7]=uv[3]; + vbdata[vpos+10]=uv[4]; + vbdata[vpos+11]=uv[5]; + vbdata[vpos+14]=uv[6]; + vbdata[vpos+15]=uv[7]; + var a=m.a,b=m.b,c=m.c,d=m.d; + if (a!==1 || b!==0 || c!==0 || d!==1){ + m.bTransform=true; + var tx=m.tx+_x,ty=m.ty+_y; + vbdata[vpos]=(point4[0]+x)*a+(point4[1]+y)*c+tx; + vbdata[vpos+1]=(point4[0]+x)*b+(point4[1]+y)*d+ty; + vbdata[vpos+4]=(point4[2]+x)*a+(point4[3]+y)*c+tx; + vbdata[vpos+5]=(point4[2]+x)*b+(point4[3]+y)*d+ty; + vbdata[vpos+8]=(point4[4]+x)*a+(point4[5]+y)*c+tx; + vbdata[vpos+9]=(point4[4]+x)*b+(point4[5]+y)*d+ty; + vbdata[vpos+12]=(point4[6]+x)*a+(point4[7]+y)*c+tx; + vbdata[vpos+13]=(point4[6]+x)*b+(point4[7]+y)*d+ty; + }else { + m.bTransform=false; + x+=m.tx+_x; + y+=m.ty+_y; + vbdata[vpos]=x+point4[0]; + vbdata[vpos+1]=y+point4[1]; + vbdata[vpos+4]=x+point4[2]; + vbdata[vpos+5]=y+point4[3]; + vbdata[vpos+8]=x+point4[4]; + vbdata[vpos+9]=y+point4[5]; + vbdata[vpos+12]=x+point4[6]; + vbdata[vpos+13]=y+point4[7]; + } + vb._upload=true; + return true; + } + + GlUtils.fillTranglesVB=function(vb,x,y,points,m,_x,_y){ + 'use strict'; + var vpos=(vb._byteLength >> 2)+points.length; + vb.byteLength=(vpos << 2); + var vbdata=vb.getFloat32Array(); + vpos-=points.length; + var len=points.length; + var a=m.a,b=m.b,c=m.c,d=m.d; + for (var i=0;i < len;i+=4){ + vbdata[vpos+i+2]=points[i+2]; + vbdata[vpos+i+3]=points[i+3]; + if (a!==1 || b!==0 || c!==0 || d!==1){ + m.bTransform=true; + var tx=m.tx+_x,ty=m.ty+_y; + vbdata[vpos+i]=(points[i]+x)*a+(points[i+1]+y)*c+tx; + vbdata[vpos+i+1]=(points[i]+x)*b+(points[i+1]+y)*d+ty; + }else { + m.bTransform=false; + x+=m.tx+_x; + y+=m.ty+_y; + vbdata[vpos+i]=x+points[i]; + vbdata[vpos+i+1]=y+points[i+1]; + } + } + vb._upload=true; + return true; + } + + GlUtils.copyPreImgVb=function(vb,dx,dy){ + var vpos=(vb._byteLength >> 2); + vb.byteLength=((vpos+/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16)<< 2); + var vbdata=vb.getFloat32Array(); + for (var i=0,ci=vpos-16;i < 4;i++){ + vbdata[vpos]=vbdata[ci]+dx;++vpos;++ci; + vbdata[vpos]=vbdata[ci]+dy;++vpos;++ci; + vbdata[vpos]=vbdata[ci];++vpos;++ci; + vbdata[vpos]=vbdata[ci];++vpos;++ci; + } + vb._upload=true; + } + + GlUtils.fillRectImgVb=function(vb,clip,x,y,width,height,uv,m,_x,_y,dx,dy,round){ + (round===void 0)&& (round=false); + 'use strict'; + var mType=1; + var toBx,toBy,toEx,toEy; + var cBx,cBy,cEx,cEy; + var w0,h0,tx,ty; + var finalX,finalY,offsetX,offsetY; + var a=m.a,b=m.b,c=m.c,d=m.d; + var useClip=clip.width < /*laya.webgl.canvas.WebGLContext2D._MAXSIZE*/99999999; + if (a!==1 || b!==0 || c!==0 || d!==1){ + m.bTransform=true; + if (b===0 && c===0){ + mType=23; + w0=width+x,h0=height+y; + tx=m.tx+_x,ty=m.ty+_y; + toBx=a *x+tx; + toEx=a *w0+tx; + toBy=d *y+ty; + toEy=d *h0+ty; + } + }else { + mType=23; + m.bTransform=false; + toBx=x+m.tx+_x; + toEx=toBx+width; + toBy=y+m.ty+_y; + toEy=toBy+height; + } + if (useClip){ + cBx=clip.x,cBy=clip.y,cEx=clip.width+cBx,cEy=clip.height+cBy; + } + if (mType!==1 && (toBx >=cEx || toBy >=cEy || toEx <=cBx || toEy <=cBy)) + return false; + var vpos=(vb._byteLength >> 2); + vb.byteLength=((vpos+/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16)<< 2); + var vbdata=vb.getFloat32Array(); + vbdata[vpos+2]=uv[0]; + vbdata[vpos+3]=uv[1]; + vbdata[vpos+6]=uv[2]; + vbdata[vpos+7]=uv[3]; + vbdata[vpos+10]=uv[4]; + vbdata[vpos+11]=uv[5]; + vbdata[vpos+14]=uv[6]; + vbdata[vpos+15]=uv[7]; + switch (mType){ + case 1: + tx=m.tx+_x,ty=m.ty+_y; + w0=width+x,h0=height+y; + var w1=x,h1=y; + var aw1=a *w1,ch1=c *h1,dh1=d *h1,bw1=b *w1; + var aw0=a *w0,ch0=c *h0,dh0=d *h0,bw0=b *w0; + if (round){ + finalX=aw1+ch1+tx; + offsetX=Math.round(finalX)-finalX; + finalY=dh1+bw1+ty; + offsetY=Math.round(finalY)-finalY; + vbdata[vpos]=finalX+offsetX; + vbdata[vpos+1]=finalY+offsetY; + vbdata[vpos+4]=aw0+ch1+tx+offsetX; + vbdata[vpos+5]=dh1+bw0+ty+offsetY; + vbdata[vpos+8]=aw0+ch0+tx+offsetX; + vbdata[vpos+9]=dh0+bw0+ty+offsetY; + vbdata[vpos+12]=aw1+ch0+tx+offsetX; + vbdata[vpos+13]=dh0+bw1+ty+offsetY; + }else { + vbdata[vpos]=aw1+ch1+tx; + vbdata[vpos+1]=dh1+bw1+ty; + vbdata[vpos+4]=aw0+ch1+tx; + vbdata[vpos+5]=dh1+bw0+ty; + vbdata[vpos+8]=aw0+ch0+tx; + vbdata[vpos+9]=dh0+bw0+ty; + vbdata[vpos+12]=aw1+ch0+tx; + vbdata[vpos+13]=dh0+bw1+ty; + } + break ; + case 23: + if (round){ + finalX=toBx+dx; + offsetX=Math.round(finalX)-finalX; + finalY=toBy; + offsetY=Math.round(finalY)-finalY; + vbdata[vpos]=finalX+offsetX; + vbdata[vpos+1]=finalY+offsetY; + vbdata[vpos+4]=toEx+dx+offsetX; + vbdata[vpos+5]=toBy+offsetY; + vbdata[vpos+8]=toEx+offsetX; + vbdata[vpos+9]=toEy+offsetY; + vbdata[vpos+12]=toBx+offsetX; + vbdata[vpos+13]=toEy+offsetY; + }else { + vbdata[vpos]=toBx+dx; + vbdata[vpos+1]=toBy; + vbdata[vpos+4]=toEx+dx; + vbdata[vpos+5]=toBy; + vbdata[vpos+8]=toEx; + vbdata[vpos+9]=toEy; + vbdata[vpos+12]=toBx; + vbdata[vpos+13]=toEy; + } + break ; + } + vb._upload=true; + return true; + } + + GlUtils.fillLineVb=function(vb,clip,fx,fy,tx,ty,width,mat){ + 'use strict'; + var linew=width *.5; + var data=GlUtils._fillLineArray; + var perpx=-(fy-ty),perpy=fx-tx; + var dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx /=dist,perpy /=dist,perpx *=linew,perpy *=linew; + data[0]=fx-perpx,data[1]=fy-perpy,data[4]=fx+perpx,data[5]=fy+perpy,data[8]=tx+perpx,data[9]=ty+perpy,data[12]=tx-perpx,data[13]=ty-perpy; + mat && mat.transformPointArray(data,data); + var vpos=(vb._byteLength >> 2)+/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16; + vb.byteLength=(vpos << 2); + vb.insertData(data,vpos-/*laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16); + return true; + } + + GlUtils._fillLineArray=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]; + return GlUtils; + })() + + + //class laya.webgl.utils.MatirxArray + var MatirxArray=(function(){ + function MatirxArray(){}; + __class(MatirxArray,'laya.webgl.utils.MatirxArray'); + MatirxArray.ArrayMul=function(a,b,o){ + if (!a){ + MatirxArray.copyArray(b,o); + return; + } + if (!b){ + MatirxArray.copyArray(a,o); + return; + }; + var ai0=NaN,ai1=NaN,ai2=NaN,ai3=NaN; + for (var i=0;i < 4;i++){ + ai0=a[i]; + ai1=a[i+4]; + ai2=a[i+8]; + ai3=a[i+12]; + o[i]=ai0 *b[0]+ai1 *b[1]+ai2 *b[2]+ai3 *b[3]; + o[i+4]=ai0 *b[4]+ai1 *b[5]+ai2 *b[6]+ai3 *b[7]; + o[i+8]=ai0 *b[8]+ai1 *b[9]+ai2 *b[10]+ai3 *b[11]; + o[i+12]=ai0 *b[12]+ai1 *b[13]+ai2 *b[14]+ai3 *b[15]; + } + } + + MatirxArray.copyArray=function(f,t){ + if (!f)return; + if (!t)return; + for (var i=0;i < f.length;i++){ + t[i]=f[i]; + } + } + + return MatirxArray; + })() + + + //class laya.webgl.utils.RenderState2D + var RenderState2D=(function(){ + function RenderState2D(){}; + __class(RenderState2D,'laya.webgl.utils.RenderState2D'); + RenderState2D.getMatrArray=function(){ + return [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]; + } + + RenderState2D.mat2MatArray=function(mat,matArray){ + var m=mat; + var m4=matArray; + m4[0]=m.a; + m4[1]=m.b; + m4[4]=m.c; + m4[5]=m.d; + m4[12]=m.tx; + m4[13]=m.ty; + return matArray; + } + + RenderState2D.restoreTempArray=function(){ + RenderState2D.TEMPMAT4_ARRAY[0]=1; + RenderState2D.TEMPMAT4_ARRAY[1]=0; + RenderState2D.TEMPMAT4_ARRAY[4]=0; + RenderState2D.TEMPMAT4_ARRAY[5]=1; + RenderState2D.TEMPMAT4_ARRAY[12]=0; + RenderState2D.TEMPMAT4_ARRAY[13]=0; + } + + RenderState2D.clear=function(){ + RenderState2D.worldScissorTest=false; + RenderState2D.worldShaderDefines=null; + RenderState2D.worldFilters=null; + RenderState2D.worldAlpha=1; + RenderState2D.worldClipRect.x=RenderState2D.worldClipRect.y=0; + RenderState2D.worldClipRect.width=RenderState2D.width; + RenderState2D.worldClipRect.height=RenderState2D.height; + RenderState2D.curRenderTarget=null; + } + + RenderState2D._MAXSIZE=99999999; + RenderState2D.TEMPMAT4_ARRAY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]; + RenderState2D.worldMatrix4=RenderState2D.TEMPMAT4_ARRAY; + RenderState2D.worldAlpha=1.0; + RenderState2D.worldScissorTest=false; + RenderState2D.worldFilters=null + RenderState2D.worldShaderDefines=null + RenderState2D.worldClipRect=new Rectangle(0,0,99999999,99999999); + RenderState2D.curRenderTarget=null + RenderState2D.width=0; + RenderState2D.height=0; + __static(RenderState2D, + ['worldMatrix',function(){return this.worldMatrix=new Matrix();} + ]); + return RenderState2D; + })() + + + //class laya.webgl.utils.ShaderCompile + var ShaderCompile=(function(){ + var ShaderScriptBlock; + function ShaderCompile(name,vs,ps,nameMap,includeFiles){ + //this._VS=null; + //this._PS=null; + //this._VSTXT=null; + //this._PSTXT=null; + //this._nameMap=null; + this._VSTXT=vs; + this._PSTXT=ps; + function split (str){ + var words=str.split(' '); + var out=[]; + for (var i=0;i < words.length;i++) + words[i].length > 0 && out.push(words[i]); + return out; + } + function c (script){ + var i=0,n=0,ofs=0,words,condition; + var top=new ShaderScriptBlock(0,null,null,null); + var parent=top; + var lines=script.split('\n'); + for (i=0,n=lines.length;i < n;i++){ + var line=lines[i]; + if (line.indexOf("#ifdef")>=0){ + words=split(line); + parent=new ShaderScriptBlock(1,words[1],"",parent); + continue ; + } + if (line.indexOf("#else")>=0){ + condition=parent.condition; + parent=new ShaderScriptBlock(2,null,"",parent.parent); + parent.condition=condition; + continue ; + } + if (line.indexOf("#endif")>=0){ + parent=parent.parent; + continue ; + } + if (line.indexOf("#include")>=0){ + words=split(line); + var fname=words[1]; + var chr=fname.charAt(0); + if (chr==='"' || chr==="'"){ + fname=fname.substr(1,fname.length-2); + ofs=fname.lastIndexOf(chr); + if (ofs > 0)fname=fname.substr(0,ofs); + } + ofs=words[0].indexOf('?'); + var str=ofs > 0 ? words[0].substr(ofs+1):words[0]; + new ShaderScriptBlock(1,str,includeFiles[fname],parent); + continue ; + } + if (parent.childs.length > 0 && parent.childs[parent.childs.length-1].type===0){ + parent.childs[parent.childs.length-1].text+="\n"+line; + }else new ShaderScriptBlock(0,null,line,parent); + } + return top; + } + this._VS=c(vs); + this._PS=c(ps); + this._nameMap=nameMap; + } + + __class(ShaderCompile,'laya.webgl.utils.ShaderCompile'); + var __proto=ShaderCompile.prototype; + __proto.createShader=function(define,shaderName,createShader){ + var defMap={}; + var defineStr=""; + if (define){ + for (var i in define){ + defineStr+="#define "+i+"\n"; + defMap[i]=true; + } + }; + var vs=this._VS.toscript(defMap,[]); + var ps=this._PS.toscript(defMap,[]); + return (createShader || Shader.create)(defineStr+vs.join('\n'),defineStr+ps.join('\n'),shaderName,this._nameMap); + } + + ShaderCompile.IFDEF_NO=0; + ShaderCompile.IFDEF_YES=1; + ShaderCompile.IFDEF_ELSE=2; + ShaderCompile.__init$=function(){ + //class ShaderScriptBlock + ShaderScriptBlock=(function(){ + function ShaderScriptBlock(type,condition,text,parent){ + //this.type=0; + //this.condition=null; + //this.text=null; + //this.parent=null; + this.childs=new Array; + this.type=type; + this.text=text; + this.parent=parent; + parent && parent.childs.push(this); + if (!condition)return; + var newcondition=""; + var preIsParam=false,isParam=false; + for (var i=0,n=condition.length;i < n;i++){ + var c=condition.charAt(i); + isParam="!&|() \t".indexOf(c)< 0; + if (preIsParam !=isParam){ + isParam && (newcondition+="this."); + preIsParam=isParam; + } + newcondition+=c; + } + this.condition=RunDriver.createShaderCondition(newcondition); + } + __class(ShaderScriptBlock,''); + var __proto=ShaderScriptBlock.prototype; + __proto.toscript=function(def,out){ + if (this.type===/*laya.webgl.utils.ShaderCompile.IFDEF_NO*/0){ + this.text && out.push(this.text); + } + if (this.childs.length < 1 && !this.text)return out; + if (this.type!==/*laya.webgl.utils.ShaderCompile.IFDEF_NO*/0){ + var ifdef=!!this.condition.call(def); + this.type===/*laya.webgl.utils.ShaderCompile.IFDEF_ELSE*/2 && (ifdef=!ifdef); + if (!ifdef)return out; + this.text && out.push(this.text); + } + this.childs.length > 0 && this.childs.forEach(function(o,index,arr){ + o.toscript(def,out) + }); + return out; + } + return ShaderScriptBlock; + })() + } + + return ShaderCompile; + })() + + + /** + *@private + *Shader3D 主要用数组的方式保存shader变量定义,后期合并ShaderValue不使用for in,性能较高。 + */ + //class laya.webgl.utils.ValusArray + var ValusArray=(function(){ + function ValusArray(){ + this._data=[]; + this._length=0; + this._data._length=0; + } + + __class(ValusArray,'laya.webgl.utils.ValusArray'); + var __proto=ValusArray.prototype; + __proto.pushValue=function(name,value){ + this.setValue(this._length,name,value); + this._length+=2; + } + + __proto.setValue=function(index,name,value){ + this._data[index++]=name; + this._data[index]=value; + } + + __proto.pushArray=function(value){ + var data=this._data; + var len=this._length; + var inData=value._data; + var dec; + for (var i=0,n=value.length;i < n;i++,len++){ + data[len++]=inData[i++]; + data[len]=inData[i]; + } + this._length=len; + } + + __getset(0,__proto,'data',function(){ + return this._data; + }); + + __getset(0,__proto,'length',function(){ + return this._length; + },function(value){ + this._length=value; + }); + + return ValusArray; + })() + + + /** + *@private + */ + //class laya.webgl.WebGL + var WebGL=(function(){ + function WebGL(){}; + __class(WebGL,'laya.webgl.WebGL'); + WebGL._float32ArraySlice=function(){ + var _this=/*__JS__ */this; + var sz=_this.length; + var dec=new Float32Array(_this.length); + for (var i=0;i < sz;i++)dec[i]=_this[i]; + return dec; + } + + WebGL._uint16ArraySlice=function(__arg){ + var arg=arguments; + var _this=/*__JS__ */this; + var sz=0; + var dec; + var i=0; + if (arg.length===0){ + sz=_this.length; + dec=new Uint16Array(sz); + for (i=0;i < sz;i++) + dec[i]=_this[i]; + }else if (arg.length===2){ + var start=arg[0]; + var end=arg[1]; + if (end > start){ + sz=end-start; + dec=new Uint16Array(sz); + for (i=start;i < end;i++) + dec[i-start]=_this[i]; + }else { + dec=new Uint16Array(0); + } + } + return dec; + } + + WebGL.expandContext=function(){ + var from=Context.prototype; + var to=/*__JS__ */CanvasRenderingContext2D.prototype; + to.fillTrangles=from.fillTrangles; + Buffer2D.__int__(null); + to.setIBVB=function (x,y,ib,vb,numElement,mat,shader,shaderValues,startIndex,offset){ + (startIndex===void 0)&& (startIndex=0); + (offset===void 0)&& (offset=0); + if (ib===null){ + this._ib=this._ib || IndexBuffer2D.QuadrangleIB; + ib=this._ib; + GlUtils.expandIBQuadrangle(ib,(vb.byteLength / (4 *16)+8)); + } + this._setIBVB(x,y,ib,vb,numElement,mat,shader,shaderValues,startIndex,offset); + }; + to.fillTrangles=function (tex,x,y,points,m){ + this._curMat=this._curMat || Matrix.create(); + this._vb=this._vb || VertexBuffer2D.create(); + if (!this._ib){ + this._ib=IndexBuffer2D.create(); + GlUtils.fillIBQuadrangle(this._ib,length / 4); + }; + var vb=this._vb; + var length=points.length >> 4; + GlUtils.fillTranglesVB(vb,x,y,points,m || this._curMat,0,0); + GlUtils.expandIBQuadrangle(this._ib,(vb.byteLength / (4 *16)+8)); + var shaderValues=new Value2D(0x01,0); + shaderValues.textureHost=tex; + var sd=new Shader2X("attribute vec2 position; attribute vec2 texcoord; uniform vec2 size; uniform mat4 mmat; varying vec2 v_texcoord; void main() { vec4 p=vec4(position.xy,0.0,1.0);vec4 pos=mmat*p; gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0); v_texcoord = texcoord; }","precision mediump float; varying vec2 v_texcoord; uniform sampler2D texture; void main() {vec4 color= texture2D(texture, v_texcoord); color.a*=1.0; gl_FragColor= color;}"); + /*__JS__ */vb._vertType=3; + this._setIBVB(x,y,this._ib,vb,length *6,m,sd,shaderValues,0,0); + } + } + + WebGL.enable=function(){ + if (Render.isConchApp){ + if (!Render.isConchWebGL){ + RunDriver.skinAniSprite=function (){ + var tSkinSprite=new SkinMesh() + return tSkinSprite; + } + WebGL.expandContext(); + return false; + } + } + if (!WebGL.isWebGLSupported())return false; + if (Render.isWebGL)return true; + HTMLImage.create=function (src,def){ + return new WebGLImage(src,def); + } + Render.WebGL=WebGL; + Render.isWebGL=true; + DrawText.__init__(); + RunDriver.createRenderSprite=function (type,next){ + return new RenderSprite3D(type,next); + } + RunDriver.createWebGLContext2D=function (c){ + return new WebGLContext2D(c); + } + RunDriver.changeWebGLSize=function (width,height){ + laya.webgl.WebGL.onStageResize(width,height); + } + RunDriver.createGraphics=function (){ + return new GraphicsGL(); + }; + var action=RunDriver.createFilterAction; + RunDriver.createFilterAction=action ? action :function (type){ + return new ColorFilterActionGL() + } + RunDriver.clear=function (color){ + RenderState2D.worldScissorTest && laya.webgl.WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + if (color==null){ + Render.context.ctx.clearBG(0,0,0,0); + }else { + var c=Color.create(color)._color; + Render.context.ctx.clearBG(c[0],c[1],c[2],c[3]); + } + RenderState2D.clear(); + } + RunDriver.addToAtlas=function (texture,force){ + (force===void 0)&& (force=false); + var bitmap=texture.bitmap; + if (!Render.optimizeTextureMemory(texture.url,texture)){ + (bitmap).enableMerageInAtlas=false; + return; + } + if ((Laya.__typeof(bitmap,'laya.webgl.resource.IMergeAtlasBitmap'))&& ((bitmap).allowMerageInAtlas)){ + bitmap.on(/*laya.events.Event.RECOVERED*/"recovered",texture,texture.addTextureToAtlas); + } + } + AtlasResourceManager._enable(); + RunDriver.beginFlush=function (){ + var atlasResourceManager=AtlasResourceManager.instance; + var count=atlasResourceManager.getAtlaserCount(); + for (var i=0;i < count;i++){ + var atlerCanvas=atlasResourceManager.getAtlaserByIndex(i).texture; + (atlerCanvas._flashCacheImageNeedFlush)&& (RunDriver.flashFlushImage(atlerCanvas)); + } + } + RunDriver.drawToCanvas=function (sprite,_renderType,canvasWidth,canvasHeight,offsetX,offsetY){ + var renderTarget=new RenderTarget2D(canvasWidth,canvasHeight,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0,false); + renderTarget.start(); + renderTarget.clear(1.0,0.0,0.0,1.0); + sprite.render(Render.context,-offsetX,RenderState2D.height-canvasHeight-offsetY); + Render.context.flush(); + renderTarget.end(); + var pixels=renderTarget.getData(0,0,renderTarget.width,renderTarget.height); + renderTarget.dispose(); + return pixels; + } + RunDriver.createFilterAction=function (type){ + var action; + switch (type){ + case /*laya.filters.Filter.COLOR*/0x20: + action=new ColorFilterActionGL(); + break ; + } + return action; + } + RunDriver.addTextureToAtlas=function (texture){ + texture._uvID++; + AtlasResourceManager._atlasRestore++; + ((texture.bitmap).enableMerageInAtlas)&& (AtlasResourceManager.instance.addToAtlas(texture)); + } + RunDriver.getTexturePixels=function (value,x,y,width,height){ + (Render.context.ctx).clear(); + var tSprite=new Sprite(); + tSprite.graphics.drawTexture(value,-x,-y); + var tRenderTarget=RenderTarget2D.create(width,height); + tRenderTarget.start(); + tRenderTarget.clear(0,0,0,0); + tSprite.render(Render.context,0,0); + (Render.context.ctx).flush(); + tRenderTarget.end(); + var tUint8Array=tRenderTarget.getData(0,0,width,height); + var tArray=[]; + var tIndex=0; + for (var i=height-1;i >=0;i--){ + for (var j=0;j < width;j++){ + tIndex=(i *width+j)*4; + tArray.push(tUint8Array[tIndex]); + tArray.push(tUint8Array[tIndex+1]); + tArray.push(tUint8Array[tIndex+2]); + tArray.push(tUint8Array[tIndex+3]); + } + } + return tArray; + } + RunDriver.skinAniSprite=function (){ + var tSkinSprite=new SkinMesh() + return tSkinSprite; + } + Filter._filterStart=function (scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + var source=RenderTarget2D.create(b.width,b.height); + source.start(); + source.clear(0,0,0,0); + scope.addValue("src",source); + scope.addValue("ScissorTest",RenderState2D.worldScissorTest); + if (RenderState2D.worldScissorTest){ + var tClilpRect=new Rectangle(); + tClilpRect.copyFrom((context.ctx)._clipRect) + scope.addValue("clipRect",tClilpRect); + RenderState2D.worldScissorTest=false; + laya.webgl.WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + } + } + Filter._filterEnd=function (scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + var source=scope.getValue("src"); + source.end(); + var out=RenderTarget2D.create(b.width,b.height); + out.start(); + out.clear(0,0,0,0); + scope.addValue("out",out); + sprite._set$P('_filterCache',out); + sprite._set$P('_isHaveGlowFilter',scope.getValue("_isHaveGlowFilter")); + } + Filter._EndTarget=function (scope,context){ + var source=scope.getValue("src"); + source.recycle(); + var out=scope.getValue("out"); + out.end(); + var b=scope.getValue("ScissorTest"); + if (b){ + RenderState2D.worldScissorTest=true; + laya.webgl.WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + context.ctx.save(); + var tClipRect=scope.getValue("clipRect"); + (context.ctx).clipRect(tClipRect.x,tClipRect.y,tClipRect.width,tClipRect.height); + } + } + Filter._useSrc=function (scope){ + var source=scope.getValue("out"); + source.end(); + source=scope.getValue("src"); + source.start(); + source.clear(0,0,0,0); + } + Filter._endSrc=function (scope){ + var source=scope.getValue("src"); + source.end(); + } + Filter._useOut=function (scope){ + var source=scope.getValue("src"); + source.end(); + source=scope.getValue("out"); + source.start(); + source.clear(0,0,0,0); + } + Filter._endOut=function (scope){ + var source=scope.getValue("out"); + source.end(); + } + Filter._recycleScope=function (scope){ + scope.recycle(); + } + Filter._filter=function (sprite,context,x,y){ + var next=this._next; + if (next){ + var filters=sprite.filters,len=filters.length; + if (len==1 && (filters[0].type==/*laya.filters.Filter.COLOR*/0x20)){ + context.ctx.save(); + context.ctx.setFilters([filters[0]]); + next._fun.call(next,sprite,context,x,y); + context.ctx.restore(); + return; + }; + var shaderValue; + var b; + var scope=SubmitCMDScope.create(); + var p=Point.TEMP; + var tMatrix=context.ctx._getTransformMatrix(); + var mat=Matrix.create(); + tMatrix.copyTo(mat); + var tPadding=0; + var tHalfPadding=0; + var tIsHaveGlowFilter=false; + var out=sprite._$P._filterCache ? sprite._$P._filterCache :null; + if (!out || sprite._repaint){ + tIsHaveGlowFilter=sprite._isHaveGlowFilter(); + scope.addValue("_isHaveGlowFilter",tIsHaveGlowFilter); + if (tIsHaveGlowFilter){ + tPadding=50; + tHalfPadding=25; + } + b=new Rectangle(); + b.copyFrom((sprite).getBounds()); + var tSX=b.x; + var tSY=b.y; + b.width+=tPadding; + b.height+=tPadding; + p.x=b.x *mat.a+b.y *mat.c; + p.y=b.y *mat.d+b.x *mat.b; + b.x=p.x; + b.y=p.y; + p.x=b.width *mat.a+b.height *mat.c; + p.y=b.height *mat.d+b.width *mat.b; + b.width=p.x; + b.height=p.y; + if (b.width <=0 || b.height <=0){ + return; + } + out && out.recycle(); + scope.addValue("bounds",b); + var submit=SubmitCMD.create([scope,sprite,context,0,0],Filter._filterStart); + context.addRenderObject(submit); + (context.ctx)._renderKey=0; + (context.ctx)._shader2D.glTexture=null; + var tX=sprite.x-tSX+tHalfPadding; + var tY=sprite.y-tSY+tHalfPadding; + next._fun.call(next,sprite,context,tX,tY); + submit=SubmitCMD.create([scope,sprite,context,0,0],Filter._filterEnd); + context.addRenderObject(submit); + for (var i=0;i < len;i++){ + if (i !=0){ + submit=SubmitCMD.create([scope],Filter._useSrc); + context.addRenderObject(submit); + shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + Matrix.TEMP.identity(); + context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.TEMP,"out",shaderValue,null,BlendMode.TOINT.overlay); + submit=SubmitCMD.create([scope],Filter._useOut); + context.addRenderObject(submit); + }; + var fil=filters[i]; + fil.action.apply3d(scope,sprite,context,0,0); + } + submit=SubmitCMD.create([scope,context],Filter._EndTarget); + context.addRenderObject(submit); + }else { + tIsHaveGlowFilter=sprite._$P._isHaveGlowFilter ? sprite._$P._isHaveGlowFilter :false; + if (tIsHaveGlowFilter){ + tPadding=50; + tHalfPadding=25; + } + b=sprite.getBounds(); + if (b.width <=0 || b.height <=0){ + return; + } + b.width+=tPadding; + b.height+=tPadding; + p.x=b.x *mat.a+b.y *mat.c; + p.y=b.y *mat.d+b.x *mat.b; + b.x=p.x; + b.y=p.y; + p.x=b.width *mat.a+b.height *mat.c; + p.y=b.height *mat.d+b.width *mat.b; + b.width=p.x; + b.height=p.y; + scope.addValue("out",out); + } + x=x-tHalfPadding-sprite.x; + y=y-tHalfPadding-sprite.y; + p.setTo(x,y); + mat.transformPoint(p); + x=p.x+b.x; + y=p.y+b.y; + shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + Matrix.TEMP.identity(); + (context.ctx).drawTarget(scope,x,y,b.width,b.height,Matrix.TEMP,"out",shaderValue,null,BlendMode.TOINT.overlay); + submit=SubmitCMD.create([scope],Filter._recycleScope); + context.addRenderObject(submit); + mat.destroy(); + } + } + Float32Array.prototype.slice || (Float32Array.prototype.slice=WebGL._float32ArraySlice); + Uint16Array.prototype.slice || (Uint16Array.prototype.slice=WebGL._uint16ArraySlice); + return true; + } + + WebGL.isWebGLSupported=function(){ + var canvas=Browser.createElement('canvas'); + var gl; + var names=["webgl","experimental-webgl","webkit-3d","moz-webgl"]; + for (var i=0;i < names.length;i++){ + try { + gl=canvas.getContext(names[i]); + }catch (e){} + if (gl)return names[i]; + } + return null; + } + + WebGL.onStageResize=function(width,height){ + WebGL.mainContext.viewport(0,0,width,height); + RenderState2D.width=width; + RenderState2D.height=height; + } + + WebGL.isExperimentalWebgl=function(){ + return WebGL._isExperimentalWebgl; + } + + WebGL.addRenderFinish=function(){ + if (WebGL._isExperimentalWebgl || Render.isFlash){ + RunDriver.endFinish=function (){ + Render.context.ctx.finish(); + } + } + } + + WebGL.removeRenderFinish=function(){ + if (WebGL._isExperimentalWebgl){ + RunDriver.endFinish=function (){} + } + } + + WebGL.onInvalidGLRes=function(){ + AtlasResourceManager.instance.freeAll(); + ResourceManager.releaseContentManagers(true); + WebGL.doNodeRepaint(Laya.stage); + WebGL.mainContext.viewport(0,0,RenderState2D.width,RenderState2D.height); + Laya.stage.event(/*laya.events.Event.DEVICE_LOST*/"devicelost"); + } + + WebGL.doNodeRepaint=function(sprite){ + (sprite.numChildren==0)&& (sprite.repaint()); + for (var i=0;i < sprite.numChildren;i++) + WebGL.doNodeRepaint(sprite.getChildAt(i)); + } + + WebGL.init=function(canvas,width,height){ + WebGL.mainCanvas=canvas; + HTMLCanvas._createContext=function (canvas){ + return new WebGLContext2D(canvas); + }; + var webGLName=WebGL.isWebGLSupported(); + var gl=WebGL.mainContext=RunDriver.newWebGLContext(canvas,webGLName); + WebGL._isExperimentalWebgl=(webGLName !="webgl" && (Browser.onWeiXin || Browser.onMQQBrowser)); + WebGL.frameShaderHighPrecision=false; + try { + var precisionFormat=laya.webgl.WebGL.mainContext.getShaderPrecisionFormat(/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30,/*laya.webgl.WebGLContext.HIGH_FLOAT*/0x8DF2); + precisionFormat.precision ? WebGL.frameShaderHighPrecision=true :WebGL.frameShaderHighPrecision=false; + }catch (e){} + Browser.window.SetupWebglContext && Browser.window.SetupWebglContext(gl); + WebGL.onStageResize(width,height); + if (WebGL.mainContext==null) + throw new Error("webGL getContext err!"); + System.__init__(); + AtlasResourceManager.__init__(); + ShaderDefines2D.__init__(); + Submit.__init__(); + WebGLContext2D.__init__(); + Value2D.__init__(); + Shader2D.__init__(); + Buffer2D.__int__(gl); + BlendMode._init_(gl); + if (Render.isConchApp){ + /*__JS__ */conch.setOnInvalidGLRes(WebGL.onInvalidGLRes); + } + } + + WebGL.mainCanvas=null + WebGL.mainContext=null + WebGL.antialias=true; + WebGL.frameShaderHighPrecision=false; + WebGL._bg_null=[0,0,0,0]; + WebGL._isExperimentalWebgl=false; + return WebGL; + })() + + + //class laya.webgl.WebGLContext + var WebGLContext=(function(){ + function WebGLContext(){}; + __class(WebGLContext,'laya.webgl.WebGLContext'); + WebGLContext.UseProgram=function(program){ + if (WebGLContext._useProgram===program)return false; + WebGL.mainContext.useProgram(program); + WebGLContext._useProgram=program; + return true; + } + + WebGLContext.setDepthTest=function(gl,value){ + value!==WebGLContext._depthTest && (WebGLContext._depthTest=value,value?gl.enable(/*CLASS CONST:laya.webgl.WebGLContext.DEPTH_TEST*/0x0B71):gl.disable(/*CLASS CONST:laya.webgl.WebGLContext.DEPTH_TEST*/0x0B71)); + } + + WebGLContext.setDepthMask=function(gl,value){ + value!==WebGLContext._depthMask && (WebGLContext._depthMask=value,gl.depthMask(value)); + } + + WebGLContext.setDepthFunc=function(gl,value){ + value!==WebGLContext._depthFunc && (WebGLContext._depthFunc=value,gl.depthFunc(value)); + } + + WebGLContext.setBlend=function(gl,value){ + value!==WebGLContext._blend && (WebGLContext._blend=value,value?gl.enable(/*CLASS CONST:laya.webgl.WebGLContext.BLEND*/0x0BE2):gl.disable(/*CLASS CONST:laya.webgl.WebGLContext.BLEND*/0x0BE2)); + } + + WebGLContext.setBlendFunc=function(gl,sFactor,dFactor){ + (sFactor!==WebGLContext._sFactor||dFactor!==WebGLContext._dFactor)&& (WebGLContext._sFactor=sFactor,WebGLContext._dFactor=dFactor,gl.blendFunc(sFactor,dFactor)); + } + + WebGLContext.setCullFace=function(gl,value){ + value!==WebGLContext._cullFace && (WebGLContext._cullFace=value,value?gl.enable(/*CLASS CONST:laya.webgl.WebGLContext.CULL_FACE*/0x0B44):gl.disable(/*CLASS CONST:laya.webgl.WebGLContext.CULL_FACE*/0x0B44)); + } + + WebGLContext.setFrontFaceCCW=function(gl,value){ + value!==WebGLContext._frontFace && (WebGLContext._frontFace=value,gl.frontFace(value)); + } + + WebGLContext.bindTexture=function(gl,target,texture){ + gl.bindTexture(target,texture); + WebGLContext.curBindTexTarget=target; + WebGLContext.curBindTexValue=texture; + } + + WebGLContext._useProgram=null; + WebGLContext._depthTest=true; + WebGLContext._depthMask=1; + WebGLContext._blend=false; + WebGLContext._cullFace=false; + WebGLContext.curBindTexTarget=null + WebGLContext.curBindTexValue=null + __static(WebGLContext, + ['_depthFunc',function(){return this._depthFunc=/*CLASS CONST:laya.webgl.WebGLContext.LESS*/0x0201;},'_sFactor',function(){return this._sFactor=/*CLASS CONST:laya.webgl.WebGLContext.ONE*/1;},'_dFactor',function(){return this._dFactor=/*CLASS CONST:laya.webgl.WebGLContext.ZERO*/0;},'_frontFace',function(){return this._frontFace=/*CLASS CONST:laya.webgl.WebGLContext.CCW*/0x0901;} + ]); + WebGLContext.__init$=function(){ + ; + } + + return WebGLContext; + })() + + + //class laya.webgl.display.GraphicsGL extends laya.display.Graphics + var GraphicsGL=(function(_super){ + function GraphicsGL(){ + GraphicsGL.__super.call(this); + } + + __class(GraphicsGL,'laya.webgl.display.GraphicsGL',_super); + var __proto=GraphicsGL.prototype; + __proto.setShader=function(shader){ + this._saveToCmd(Render.context._setShader,[shader]); + } + + __proto.setIBVB=function(x,y,ib,vb,numElement,shader){ + this._saveToCmd(Render.context._setIBVB,[x,y,ib,vb,numElement,shader]); + } + + __proto.drawParticle=function(x,y,ps){ + var pt=RunDriver.createParticleTemplate2D(ps); + pt.x=x; + pt.y=y; + this._saveToCmd(Render.context._drawParticle,[pt]); + } + + return GraphicsGL; + })(Graphics) + + + //class laya.webgl.canvas.WebGLContext2D extends laya.resource.Context + var WebGLContext2D=(function(_super){ + var ContextParams; + function WebGLContext2D(c){ + this._x=0; + this._y=0; + this._id=++WebGLContext2D._COUNT; + //this._other=null; + this._path=null; + //this._primitiveValue2D=null; + this._drawCount=1; + this._maxNumEle=0; + this._clear=false; + this._isMain=false; + this._atlasResourceChange=0; + this._submits=[]; + this._curSubmit=null; + this._ib=null; + this._vb=null; + //this._curMat=null; + this._nBlendType=0; + //this._save=null; + //this._targets=null; + //this._renderKey=NaN; + this._saveMark=null; + //this.sprite=null; + this.mId=-1; + this.mHaveKey=false; + this.mHaveLineKey=false; + this.mX=0; + this.mY=0; + WebGLContext2D.__super.call(this); + this._width=99999999; + this._height=99999999; + this._clipRect=WebGLContext2D.MAXCLIPRECT; + this._shader2D=new Shader2D(); + this.mOutPoint + this._canvas=c; + this._curMat=Matrix.create(); + if (Render.isFlash){ + this._ib=IndexBuffer2D.create(/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + GlUtils.fillIBQuadrangle(this._ib,16); + } + else + this._ib=IndexBuffer2D.QuadrangleIB; + this._vb=VertexBuffer2D.create(-1); + this._other=ContextParams.DEFAULT; + this._save=[SaveMark.Create(this)]; + this._save.length=10; + this.clear(); + } + + __class(WebGLContext2D,'laya.webgl.canvas.WebGLContext2D',_super); + var __proto=WebGLContext2D.prototype; + __proto.setIsMainContext=function(){ + this._isMain=true; + } + + __proto.clearBG=function(r,g,b,a){ + var gl=WebGL.mainContext; + gl.clearColor(r,g,b,a); + gl.clear(/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000 | /*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100); + } + + __proto._getSubmits=function(){ + return this._submits; + } + + __proto.destroy=function(){ + this._curMat && this._curMat.destroy(); + this._targets && this._targets.destroy(); + this._vb && this._vb.releaseResource(); + this._ib && (this._ib !=IndexBuffer2D.QuadrangleIB)&& this._ib.releaseResource(); + } + + __proto.clear=function(){ + this._vb.clear(); + this._targets && (this._targets.repaint=true); + this._other=ContextParams.DEFAULT; + this._clear=true; + this._repaint=false; + this._drawCount=1; + this._renderKey=0; + this._other.lineWidth=this._shader2D.ALPHA=1.0; + this._nBlendType=0; + this._clipRect=WebGLContext2D.MAXCLIPRECT; + this._curSubmit=Submit.RENDERBASE; + this._shader2D.glTexture=null; + this._shader2D.fillStyle=this._shader2D.strokeStyle=DrawStyle.DEFAULT; + for (var i=0,n=this._submits._length;i < n;i++) + this._submits[i].releaseRender(); + this._submits._length=0; + this._curMat.identity(); + this._other.clear(); + this._saveMark=this._save[0]; + this._save._length=1; + } + + __proto.size=function(w,h){ + this._width=w; + this._height=h; + this._targets && (this._targets.size(w,h)); + } + + __proto._getTransformMatrix=function(){ + return this._curMat; + } + + __proto.translate=function(x,y){ + if (x!==0 || y!==0){ + SaveTranslate.save(this); + if (this._curMat.bTransform){ + SaveTransform.save(this); + this._curMat.transformPoint(Point.TEMP.setTo(x,y)); + x=Point.TEMP.x; + y=Point.TEMP.y; + } + this._x+=x; + this._y+=y; + } + } + + __proto.save=function(){ + this._save[this._save._length++]=SaveMark.Create(this); + } + + __proto.restore=function(){ + var sz=this._save._length; + if (sz < 1) + return; + for (var i=sz-1;i >=0;i--){ + var o=this._save[i]; + o.restore(this); + if (o.isSaveMark()){ + this._save._length=i; + return; + } + } + } + + __proto.measureText=function(text){ + return RunDriver.measureText(text,this._other.font.toString()); + } + + __proto._fillText=function(txt,words,x,y,fontStr,color,textAlign){ + var shader=this._shader2D; + var curShader=this._curSubmit.shaderValue; + var font=fontStr ? FontInContext.create(fontStr):this._other.font; + if (AtlasResourceManager.enabled){ + if (shader.ALPHA!==curShader.ALPHA) + shader.glTexture=null; + DrawText.drawText(this,txt,words,this._curMat,font,textAlign || this._other.textAlign,color,null,-1,x,y); + } + else{ + var preDef=this._shader2D.defines.getValue(); + var colorAdd=color ? Color.create(color)._color :shader.colorAdd; + if (shader.ALPHA!==curShader.ALPHA || colorAdd!==shader.colorAdd || curShader.colorAdd!==shader.colorAdd){ + shader.glTexture=null; + shader.colorAdd=colorAdd; + } + DrawText.drawText(this,txt,words,this._curMat,font,textAlign || this._other.textAlign,color,null,-1,x,y); + } + } + + //shader.defines.setValue(preDef); + __proto.fillWords=function(words,x,y,fontStr,color){ + words.length > 0 && this._fillText(null,words,x,y,fontStr,color,null); + } + + __proto.fillText=function(txt,x,y,fontStr,color,textAlign){ + txt.length > 0 && this._fillText(txt,null,x,y,fontStr,color,textAlign); + } + + __proto.strokeText=function(txt,x,y,fontStr,color,lineWidth,textAlign){ + if (txt.length===0) + return; + var shader=this._shader2D; + var curShader=this._curSubmit.shaderValue; + var font=fontStr ? (WebGLContext2D._fontTemp.setFont(fontStr),WebGLContext2D._fontTemp):this._other.font; + if (AtlasResourceManager.enabled){ + if (shader.ALPHA!==curShader.ALPHA){ + shader.glTexture=null; + } + DrawText.drawText(this,txt,null,this._curMat,font,textAlign || this._other.textAlign,null,color,lineWidth || 1,x,y); + } + else{ + var preDef=this._shader2D.defines.getValue(); + var colorAdd=color ? Color.create(color)._color :shader.colorAdd; + if (shader.ALPHA!==curShader.ALPHA || colorAdd!==shader.colorAdd || curShader.colorAdd!==shader.colorAdd){ + shader.glTexture=null; + shader.colorAdd=colorAdd; + } + DrawText.drawText(this,txt,null,this._curMat,font,textAlign || this._other.textAlign,null,color,lineWidth || 1,x,y); + } + } + + //shader.defines.setValue(preDef); + __proto.fillBorderText=function(txt,x,y,fontStr,fillColor,borderColor,lineWidth,textAlign){ + if (txt.length===0) + return; + if (!AtlasResourceManager.enabled){ + this.strokeText(txt,x,y,fontStr,borderColor,lineWidth,textAlign); + this.fillText(txt,x,y,fontStr,fillColor,textAlign); + return; + }; + var shader=this._shader2D; + var curShader=this._curSubmit.shaderValue; + if (shader.ALPHA!==curShader.ALPHA) + shader.glTexture=null; + var font=fontStr ? (WebGLContext2D._fontTemp.setFont(fontStr),WebGLContext2D._fontTemp):this._other.font; + DrawText.drawText(this,txt,null,this._curMat,font,textAlign || this._other.textAlign,fillColor,borderColor,lineWidth || 1,x,y); + } + + __proto.fillRect=function(x,y,width,height,fillStyle){ + var vb=this._vb; + if (GlUtils.fillRectImgVb(vb,this._clipRect,x,y,width,height,Texture.DEF_UV,this._curMat,this._x,this._y,0,0)){ + this._renderKey=0; + var pre=this._shader2D.fillStyle; + fillStyle && (this._shader2D.fillStyle=DrawStyle.create(fillStyle)); + var shader=this._shader2D; + var curShader=this._curSubmit.shaderValue; + if (shader.fillStyle!==curShader.fillStyle || shader.ALPHA!==curShader.ALPHA){ + shader.glTexture=null; + var submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength-16 */*laya.webgl.utils.Buffer2D.FLOAT32*/4)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,0)); + submit.shaderValue.color=shader.fillStyle._color._color; + submit.shaderValue.ALPHA=shader.ALPHA; + this._submits[this._submits._length++]=submit; + } + this._curSubmit._numEle+=6; + this._shader2D.fillStyle=pre; + } + } + + __proto.fillTexture=function(texture,x,y,width,height,type,offset,other){ + var vb=this._vb; + var w=texture.bitmap.width,h=texture.bitmap.height,uv=texture.uv; + if (w!=other.w||h!=other.h){ + switch(type){ + case "repeat": + other.width=width; + other.height=height; + break ; + case "repeat-x": + other.width=width; + other.height=texture.height > height?height:texture.height; + break ; + case "repeat-y": + other.width=texture.width > width?width:texture.width; + other.height=height; + break ; + default : + other.width=width; + other.height=height; + break ; + } + other.w=w; + other.h=h; + other.uv=[0,0,other.width / w,0,other.width / w,other.height / h,0,other.height / h]; + } + if (GlUtils.fillRectImgVb(vb,this._clipRect,x,y,other.width,other.height,other.uv,this._curMat,this._x,this._y,0,0)){ + this._renderKey=0; + var submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength-16 */*laya.webgl.utils.Buffer2D.FLOAT32*/4)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.FILLTEXTURE*/0x100,0)); + this._submits[this._submits._length++]=submit; + var shaderValue=submit.shaderValue; + shaderValue.textureHost=texture; + var tTextureX=uv[0] *w; + var tTextureY=uv[1] *h; + var tTextureW=(uv[2]-uv[0])*w; + var tTextureH=(uv[5]-uv[3])*h; + var tx=-offset.x / w; + var ty=-offset.y / h; + shaderValue.u_TexRange[0]=tTextureX / w; + shaderValue.u_TexRange[1]=tTextureW / w; + shaderValue.u_TexRange[2]=tTextureY / h; + shaderValue.u_TexRange[3]=tTextureH / h; + shaderValue.u_offset[0]=tx; + shaderValue.u_offset[1]=ty; + submit._renderType=/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + this._curSubmit._numEle+=6; + } + } + + __proto.setShader=function(shader){ + SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_SHADER*/0x80000,this._shader2D,true); + this._shader2D.shader=shader; + } + + __proto.setFilters=function(value){ + SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_FILTERS*/0x100000,this._shader2D,true); + this._shader2D.filters=value; + this._curSubmit=Submit.RENDERBASE; + this._renderKey=0; + this._drawCount++; + } + + __proto.drawTexture=function(tex,x,y,width,height,tx,ty){ + this._drawTextureM(tex,x,y,width,height,tx,ty,null,1); + } + + __proto.addTextureVb=function(invb,x,y){ + var finalVB=this._curSubmit._vb || this._vb; + var vpos=(finalVB._byteLength >> 2); + finalVB.byteLength=((vpos+/*CLASS CONST:laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16)<< 2); + var vbdata=finalVB.getFloat32Array(); + for (var i=0,ci=0;i < 16;i+=4){ + vbdata[vpos++]=invb[i]+x; + vbdata[vpos++]=invb[i+1]+y; + vbdata[vpos++]=invb[i+2]; + vbdata[vpos++]=invb[i+3]; + } + this._curSubmit._numEle+=6; + this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle); + finalVB._upload=true; + } + + __proto.willDrawTexture=function(tex,alpha){ + if (!(tex.loaded && tex.bitmap && tex.source)){ + if (this.sprite){ + Laya.timer.callLater(this,this._repaintSprite); + } + return 0; + }; + var webGLImg=tex.bitmap; + var rid=webGLImg.id+this._shader2D.ALPHA*alpha+/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + if (rid==this._renderKey)return rid; + var shader=this._shader2D; + var preAlpha=shader.ALPHA; + var curShader=this._curSubmit.shaderValue; + shader.ALPHA *=alpha; + this._renderKey=rid; + this._drawCount++; + shader.glTexture=webGLImg; + var vb=this._vb; + var submit=null; + var vbSize=(vb._byteLength / 32)*3; + submit=SubmitTexture.create(this,this._ib,vb,vbSize,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0)); + this._submits[this._submits._length++]=submit; + submit.shaderValue.textureHost=tex; + submit._renderType=/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + submit._preIsSameTextureShader=this._curSubmit._renderType===/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016 && shader.ALPHA===curShader.ALPHA; + this._curSubmit=submit; + shader.ALPHA=preAlpha; + return rid; + } + + __proto.drawTextures=function(tex,pos,tx,ty){ + if (!(tex.loaded && tex.bitmap && tex.source)){ + this.sprite && Laya.timer.callLater(this,this._repaintSprite); + return; + }; + var pre=this._clipRect; + this._clipRect=WebGLContext2D.MAXCLIPRECT; + if (!this._drawTextureM(tex,pos[0],pos[1],tex.width,tex.height,tx,ty,null,1)){ + alert("drawTextures err"); + return; + } + this._clipRect=pre; + Stat.drawCall+=pos.length / 2; + if (pos.length < 4) + return; + var finalVB=this._curSubmit._vb || this._vb; + var sx=this._curMat.a,sy=this._curMat.d; + for (var i=2,sz=pos.length;i < sz;i+=2){ + GlUtils.copyPreImgVb(finalVB,(pos[i]-pos[i-2])*sx,(pos[i+1]-pos[i-1])*sy); + this._curSubmit._numEle+=6; + } + this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle); + } + + __proto._drawTextureM=function(tex,x,y,width,height,tx,ty,m,alpha){ + if (!(tex.loaded && tex.bitmap && tex.source)){ + if (this.sprite){ + Laya.timer.callLater(this,this._repaintSprite); + } + return false; + }; + var finalVB=this._curSubmit._vb || this._vb; + var webGLImg=tex.bitmap; + x+=tx; + y+=ty; + this._drawCount++; + var rid=webGLImg.id+this._shader2D.ALPHA *alpha+/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + if (rid!=this._renderKey){ + this._renderKey=rid; + var curShader=this._curSubmit.shaderValue; + var shader=this._shader2D; + var alphaBack=shader.ALPHA; + shader.ALPHA *=alpha; + shader.glTexture=webGLImg; + var vb=this._vb; + var submit=null; + var vbSize=(vb._byteLength / 32)*3; + submit=SubmitTexture.create(this,this._ib,vb,vbSize,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0)); + this._submits[this._submits._length++]=submit; + submit.shaderValue.textureHost=tex; + submit._renderType=/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + submit._preIsSameTextureShader=this._curSubmit._renderType===/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016 && shader.ALPHA===curShader.ALPHA; + this._curSubmit=submit; + finalVB=this._curSubmit._vb || this._vb; + shader.ALPHA=alphaBack; + } + if (GlUtils.fillRectImgVb(finalVB,this._clipRect,x,y,width || tex.width,height || tex.height,tex.uv,m || this._curMat,this._x,this._y,0,0)){ + if (AtlasResourceManager.enabled && !this._isMain) + (this._curSubmit).addTexture(tex,(finalVB._byteLength >> 2)-/*CLASS CONST:laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16); + this._curSubmit._numEle+=6; + this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle); + return true; + } + return false; + } + + __proto._repaintSprite=function(){ + this.sprite.repaint(); + } + + //} + __proto._drawText=function(tex,x,y,width,height,m,tx,ty,dx,dy){ + var webGLImg=tex.bitmap; + this._drawCount++; + var rid=webGLImg.id+this._shader2D.ALPHA+/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + if (rid!=this._renderKey){ + this._renderKey=rid; + var curShader=this._curSubmit.shaderValue; + var shader=this._shader2D; + shader.glTexture=webGLImg; + var vb=this._vb; + var submit=null; + var submitID=NaN; + var vbSize=(vb._byteLength / 32)*3; + if (AtlasResourceManager.enabled){ + submit=SubmitTexture.create(this,this._ib,vb,vbSize,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0)); + } + else{ + submit=SubmitTexture.create(this,this._ib,vb,vbSize,TextSV.create()); + } + submit._preIsSameTextureShader=this._curSubmit._renderType===/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016 && shader.ALPHA===curShader.ALPHA; + this._submits[this._submits._length++]=submit; + submit.shaderValue.textureHost=tex; + submit._renderType=/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016; + this._curSubmit=submit; + } + tex.active(); + var finalVB=this._curSubmit._vb || this._vb; + if (GlUtils.fillRectImgVb(finalVB,this._clipRect,x+tx,y+ty,width || tex.width,height || tex.height,tex.uv,m || this._curMat,this._x,this._y,dx,dy,true)){ + if (AtlasResourceManager.enabled && !this._isMain){ + (this._curSubmit).addTexture(tex,(finalVB._byteLength >> 2)-/*CLASS CONST:laya.webgl.canvas.WebGLContext2D._RECTVBSIZE*/16); + } + this._curSubmit._numEle+=6; + this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle); + } + } + + __proto.drawTextureWithTransform=function(tex,x,y,width,height,transform,tx,ty,alpha){ + var curMat=this._curMat; + (tx!==0 || ty!==0)&& (this._x=tx *curMat.a+ty *curMat.c,this._y=ty *curMat.d+tx *curMat.b); + if (transform && curMat.bTransform){ + Matrix.mul(transform,curMat,WebGLContext2D._tmpMatrix); + transform=WebGLContext2D._tmpMatrix; + transform._checkTransform(); + } + else{ + this._x+=curMat.tx; + this._y+=curMat.ty; + } + this._drawTextureM(tex,x,y,width,height,0,0,transform,alpha); + this._x=this._y=0; + } + + __proto.fillQuadrangle=function(tex,x,y,point4,m){ + var submit=this._curSubmit; + var vb=this._vb; + var shader=this._shader2D; + var curShader=submit.shaderValue; + this._renderKey=0; + if (tex.bitmap){ + var t_tex=tex.bitmap; + if (shader.glTexture !=t_tex || shader.ALPHA!==curShader.ALPHA){ + shader.glTexture=t_tex; + submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0)); + submit.shaderValue.glTexture=t_tex; + this._submits[this._submits._length++]=submit; + } + GlUtils.fillQuadrangleImgVb(vb,x,y,point4,tex.uv,m || this._curMat,this._x,this._y); + } + else{ + if (!submit.shaderValue.fillStyle || !submit.shaderValue.fillStyle.equal(tex)|| shader.ALPHA!==curShader.ALPHA){ + shader.glTexture=null; + submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,0)); + submit.shaderValue.defines.add(/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02); + submit.shaderValue.fillStyle=DrawStyle.create(tex); + this._submits[this._submits._length++]=submit; + } + GlUtils.fillQuadrangleImgVb(vb,x,y,point4,Texture.DEF_UV,m || this._curMat,this._x,this._y); + } + submit._numEle+=6; + } + + __proto.drawTexture2=function(x,y,pivotX,pivotY,transform,alpha,blendMode,args){ + var curMat=this._curMat; + this._x=x *curMat.a+y *curMat.c; + this._y=y *curMat.d+x *curMat.b; + if (transform){ + if (curMat.bTransform || transform.bTransform){ + Matrix.mul(transform,curMat,WebGLContext2D._tmpMatrix); + transform=WebGLContext2D._tmpMatrix; + } + else{ + this._x+=transform.tx+curMat.tx; + this._y+=transform.ty+curMat.ty; + transform=Matrix.EMPTY; + } + } + if (alpha===1 && !blendMode) + this._drawTextureM(args[0],args[1]-pivotX,args[2]-pivotY,args[3],args[4],0,0,transform,1); + else{ + var preAlpha=this._shader2D.ALPHA; + var preblendType=this._nBlendType; + this._shader2D.ALPHA=alpha; + blendMode && (this._nBlendType=BlendMode.TOINT(blendMode)); + this._drawTextureM(args[0],args[1]-pivotX,args[2]-pivotY,args[3],args[4],0,0,transform,1); + this._shader2D.ALPHA=preAlpha; + this._nBlendType=preblendType; + } + this._x=this._y=0; + } + + __proto.drawCanvas=function(canvas,x,y,width,height){ + var src=canvas.context; + this._renderKey=0; + if (src._targets){ + this._submits[this._submits._length++]=SubmitCanvas.create(src,0,null); + this._curSubmit=Submit.RENDERBASE; + src._targets.drawTo(this,x,y,width,height); + } + else{ + var submit=this._submits[this._submits._length++]=SubmitCanvas.create(src,this._shader2D.ALPHA,this._shader2D.filters); + var sx=width / canvas.width; + var sy=height / canvas.height; + var mat=submit._matrix; + this._curMat.copyTo(mat); + sx !=1 && sy !=1 && mat.scale(sx,sy); + var tx=mat.tx,ty=mat.ty; + mat.tx=mat.ty=0; + mat.transformPoint(Point.TEMP.setTo(x,y)); + mat.translate(Point.TEMP.x+tx,Point.TEMP.y+ty); + this._curSubmit=Submit.RENDERBASE; + } + if (Config.showCanvasMark){ + this.save(); + this.lineWidth=4; + this.strokeStyle=src._targets ? "yellow" :"green"; + this.strokeRect(x-1,y-1,width+2,height+2,1); + this.strokeRect(x,y,width,height,1); + this.restore(); + } + } + + __proto.drawTarget=function(scope,x,y,width,height,m,proName,shaderValue,uv,blend){ + (blend===void 0)&& (blend=-1); + var vb=this._vb; + if (GlUtils.fillRectImgVb(vb,this._clipRect,x,y,width,height,uv || Texture.DEF_UV,m || this._curMat,this._x,this._y,0,0)){ + this._renderKey=0; + var shader=this._shader2D; + shader.glTexture=null; + var curShader=this._curSubmit.shaderValue; + var submit=this._curSubmit=SubmitTarget.create(this,this._ib,vb,((vb._byteLength-16 */*laya.webgl.utils.Buffer2D.FLOAT32*/4)/ 32)*3,shaderValue,proName); + if (blend==-1){ + submit.blendType=this._nBlendType; + } + else{ + submit.blendType=blend; + } + submit.scope=scope; + this._submits[this._submits._length++]=submit; + this._curSubmit._numEle+=6; + } + } + + __proto.transform=function(a,b,c,d,tx,ty){ + SaveTransform.save(this); + Matrix.mul(Matrix.TEMP.setTo(a,b,c,d,tx,ty),this._curMat,this._curMat); + this._curMat._checkTransform(); + } + + __proto.setTransformByMatrix=function(value){ + value.copyTo(this._curMat); + } + + __proto.transformByMatrix=function(value){ + SaveTransform.save(this); + Matrix.mul(value,this._curMat,this._curMat); + this._curMat._checkTransform(); + } + + __proto.rotate=function(angle){ + SaveTransform.save(this); + this._curMat.rotateEx(angle); + } + + __proto.scale=function(scaleX,scaleY){ + SaveTransform.save(this); + this._curMat.scaleEx(scaleX,scaleY); + } + + __proto.clipRect=function(x,y,width,height){ + width *=this._curMat.a; + height *=this._curMat.d; + var p=Point.TEMP; + this._curMat.transformPoint(p.setTo(x,y)); + this._renderKey=0; + var submit=this._curSubmit=SubmitScissor.create(this); + this._submits[this._submits._length++]=submit; + submit.submitIndex=this._submits._length; + submit.submitLength=9999999; + SaveClipRect.save(this,submit); + var clip=this._clipRect; + var x1=clip.x,y1=clip.y; + var r=p.x+width,b=p.y+height; + x1 < p.x && (clip.x=p.x); + y1 < p.y && (clip.y=p.y); + clip.width=Math.min(r,x1+clip.width)-clip.x; + clip.height=Math.min(b,y1+clip.height)-clip.y; + this._shader2D.glTexture=null; + submit.clipRect.copyFrom(clip); + this._curSubmit=Submit.RENDERBASE; + } + + __proto.setIBVB=function(x,y,ib,vb,numElement,mat,shader,shaderValues,startIndex,offset,type){ + (startIndex===void 0)&& (startIndex=0); + (offset===void 0)&& (offset=0); + (type===void 0)&& (type=0); + if (ib===null){ + if (!Render.isFlash){ + ib=this._ib; + } + else{ + var falshVB=vb; + (falshVB._selfIB)|| (falshVB._selfIB=IndexBuffer2D.create(/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4)); + falshVB._selfIB.clear(); + ib=falshVB._selfIB; + } + GlUtils.expandIBQuadrangle(ib,(vb.byteLength / (/*laya.webgl.utils.Buffer2D.FLOAT32*/4 *vb.vertexStride *4))); + } + if (!shaderValues || !shader) + throw Error("setIBVB must input:shader shaderValues"); + var submit=SubmitOtherIBVB.create(this,vb,ib,numElement,shader,shaderValues,startIndex,offset,type); + mat || (mat=Matrix.EMPTY); + mat.translate(x,y); + Matrix.mul(mat,this._curMat,submit._mat); + mat.translate(-x,-y); + this._submits[this._submits._length++]=submit; + this._curSubmit=Submit.RENDERBASE; + this._renderKey=0; + } + + __proto.addRenderObject=function(o){ + this._submits[this._submits._length++]=o; + } + + __proto.fillTrangles=function(tex,x,y,points,m){ + var submit=this._curSubmit; + var vb=this._vb; + var shader=this._shader2D; + var curShader=submit.shaderValue; + var length=points.length >> 4; + var t_tex=tex.bitmap; + this._renderKey=0; + if (shader.glTexture !=t_tex || shader.ALPHA!==curShader.ALPHA){ + submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0)); + submit.shaderValue.textureHost=tex; + this._submits[this._submits._length++]=submit; + } + GlUtils.fillTranglesVB(vb,x,y,points,m || this._curMat,this._x,this._y); + submit._numEle+=length *6; + } + + __proto.submitElement=function(start,end){ + var renderList=this._submits; + end < 0 && (end=renderList._length); + while (start < end){ + start+=renderList[start].renderSubmit(); + } + } + + __proto.finish=function(){ + WebGL.mainContext.finish(); + } + + __proto.flush=function(){ + var maxNum=Math.max(this._vb.byteLength / (/*laya.webgl.utils.Buffer2D.FLOAT32*/4 *16),this._maxNumEle / 6)+8; + if (maxNum > (this._ib.bufferLength / (6 */*laya.webgl.utils.Buffer2D.SHORT*/2))){ + GlUtils.expandIBQuadrangle(this._ib,maxNum); + } + if (!this._isMain && AtlasResourceManager.enabled && AtlasResourceManager._atlasRestore > this._atlasResourceChange){ + this._atlasResourceChange=AtlasResourceManager._atlasRestore; + var renderList=this._submits; + for (var i=0,s=renderList._length;i < s;i++){ + var submit=renderList [i]; + if (submit.getRenderType()===/*laya.webgl.submit.Submit.TYPE_TEXTURE*/10016) + (submit).checkTexture(); + } + } + this.submitElement(0,this._submits._length); + this._path && this._path.reset(); + SkinMeshBuffer.instance && SkinMeshBuffer.getInstance().reset(); + this._curSubmit=Submit.RENDERBASE; + this._renderKey=0; + return this._submits._length; + } + + __proto.setPathId=function(id){ + this.mId=id; + if (this.mId !=-1){ + this.mHaveKey=false; + var tVGM=VectorGraphManager.getInstance(); + if (tVGM.shapeDic[this.mId]){ + this.mHaveKey=true; + } + this.mHaveLineKey=false; + if (tVGM.shapeLineDic[this.mId]){ + this.mHaveLineKey=true; + } + } + } + + __proto.movePath=function(x,y){ + this.mX+=x; + this.mY+=y; + } + + __proto.beginPath=function(){ + var tPath=this._getPath(); + tPath.tempArray.length=0; + tPath.closePath=false; + this.mX=0; + this.mY=0; + } + + __proto.closePath=function(){ + this._path.closePath=true; + } + + __proto.fill=function(isConvexPolygon){ + (isConvexPolygon===void 0)&& (isConvexPolygon=false); + var tPath=this._getPath(); + this.drawPoly(0,0,tPath.tempArray,this.fillStyle._color.numColor,0,0,isConvexPolygon); + } + + __proto.stroke=function(){ + var tPath=this._getPath(); + if (this.lineWidth > 0){ + if (this.mId==-1){ + tPath.drawLine(0,0,tPath.tempArray,this.lineWidth,this.strokeStyle._color.numColor); + } + else{ + if (this.mHaveLineKey){ + var tShapeLine=VectorGraphManager.getInstance().shapeLineDic[this.mId]; + tPath.setGeomtry(tShapeLine); + } + else{ + VectorGraphManager.getInstance().addLine(this.mId,tPath.drawLine(0,0,tPath.tempArray,this.lineWidth,this.strokeStyle._color.numColor)); + } + } + tPath.update(); + var tArray=RenderState2D.getMatrArray(); + RenderState2D.mat2MatArray(this._curMat,tArray); + var tPosArray=[this.mX,this.mY]; + var tempSubmit=Submit.createShape(this,tPath.ib,tPath.vb,tPath.count,tPath.offset,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,0)); + tempSubmit.shaderValue.ALPHA=this._shader2D.ALPHA; + (tempSubmit.shaderValue).u_pos=tPosArray; + tempSubmit.shaderValue.u_mmat2=tArray; + this._submits[this._submits._length++]=tempSubmit; + } + } + + __proto.line=function(fromX,fromY,toX,toY,lineWidth,mat){ + var submit=this._curSubmit; + var vb=this._vb; + if (GlUtils.fillLineVb(vb,this._clipRect,fromX,fromY,toX,toY,lineWidth,mat)){ + this._renderKey=0; + var shader=this._shader2D; + var curShader=submit.shaderValue; + if (shader.strokeStyle!==curShader.strokeStyle || shader.ALPHA!==curShader.ALPHA){ + shader.glTexture=null; + submit=this._curSubmit=Submit.create(this,this._ib,vb,((vb._byteLength-16 */*laya.webgl.utils.Buffer2D.FLOAT32*/4)/ 32)*3,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,0)); + submit.shaderValue.strokeStyle=shader.strokeStyle; + submit.shaderValue.mainID=/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02; + submit.shaderValue.ALPHA=shader.ALPHA; + this._submits[this._submits._length++]=submit; + } + submit._numEle+=6; + } + } + + __proto.moveTo=function(x,y){ + var tPath=this._getPath(); + tPath.addPoint(x,y); + } + + __proto.lineTo=function(x,y){ + var tPath=this._getPath(); + tPath.addPoint(x,y); + } + + __proto.arcTo=function(x1,y1,x2,y2,r){ + if (this.mId !=-1){ + if (this.mHaveKey){ + return; + } + }; + var tPath=this._getPath(); + var x0=tPath.getEndPointX(); + var y0=tPath.getEndPointY(); + var dx0=NaN,dy0=NaN,dx1=NaN,dy1=NaN,a=NaN,d=NaN,cx=NaN,cy=NaN,a0=NaN,a1=NaN; + var dir=false; + dx0=x0-x1; + dy0=y0-y1; + dx1=x2-x1; + dy1=y2-y1; + Point.TEMP.setTo(dx0,dy0); + Point.TEMP.normalize(); + dx0=Point.TEMP.x; + dy0=Point.TEMP.y; + Point.TEMP.setTo(dx1,dy1); + Point.TEMP.normalize(); + dx1=Point.TEMP.x; + dy1=Point.TEMP.y; + a=Math.acos(dx0 *dx1+dy0 *dy1); + var tTemp=Math.tan(a / 2.0); + d=r / tTemp; + if (d > 10000){ + this.lineTo(x1,y1); + return; + } + if (dx0 *dy1-dx1 *dy0 <=0.0){ + cx=x1+dx0 *d+dy0 *r; + cy=y1+dy0 *d-dx0 *r; + a0=Math.atan2(dx0,-dy0); + a1=Math.atan2(-dx1,dy1); + dir=false; + } + else{ + cx=x1+dx0 *d-dy0 *r; + cy=y1+dy0 *d+dx0 *r; + a0=Math.atan2(-dx0,dy0); + a1=Math.atan2(dx1,-dy1); + dir=true; + } + this.arc(cx,cy,r,a0,a1,dir); + } + + __proto.arc=function(cx,cy,r,startAngle,endAngle,counterclockwise){ + (counterclockwise===void 0)&& (counterclockwise=false); + if (this.mId !=-1){ + if (this.mHaveKey){ + return; + } + cx=0; + cy=0; + }; + var a=0,da=0,hda=0,kappa=0; + var dx=0,dy=0,x=0,y=0,tanx=0,tany=0; + var px=0,py=0,ptanx=0,ptany=0; + var i=0,ndivs=0,nvals=0; + da=endAngle-startAngle; + if (!counterclockwise){ + if (Math.abs(da)>=Math.PI *2){ + da=Math.PI *2; + } + else{ + while (da < 0.0){ + da+=Math.PI *2; + } + } + } + else{ + if (Math.abs(da)>=Math.PI *2){ + da=-Math.PI *2; + } + else{ + while (da > 0.0){ + da-=Math.PI *2; + } + } + } + if (r < 101){ + ndivs=Math.max(10,da *r / 5); + } + else if (r < 201){ + ndivs=Math.max(10,da *r / 20); + } + else{ + ndivs=Math.max(10,da *r / 40); + } + hda=(da / ndivs)/ 2.0; + kappa=Math.abs(4 / 3 *(1-Math.cos(hda))/ Math.sin(hda)); + if (counterclockwise) + kappa=-kappa; + nvals=0; + var tPath=this._getPath(); + for (i=0;i <=ndivs;i++){ + a=startAngle+da *(i / ndivs); + dx=Math.cos(a); + dy=Math.sin(a); + x=cx+dx *r; + y=cy+dy *r; + if (x !=this._path.getEndPointX()|| y !=this._path.getEndPointY()){ + tPath.addPoint(x,y); + } + } + dx=Math.cos(endAngle); + dy=Math.sin(endAngle); + x=cx+dx *r; + y=cy+dy *r; + if (x !=this._path.getEndPointX()|| y !=this._path.getEndPointY()){ + tPath.addPoint(x,y); + } + } + + __proto.quadraticCurveTo=function(cpx,cpy,x,y){ + var tBezier=Bezier.I; + var tResultArray=[]; + var tArray=tBezier.getBezierPoints([this._path.getEndPointX(),this._path.getEndPointY(),cpx,cpy,x,y],30,2); + for (var i=0,n=tArray.length / 2;i < n;i++){ + this.lineTo(tArray[i *2],tArray[i *2+1]); + } + this.lineTo(x,y); + } + + __proto.rect=function(x,y,width,height){ + this._other=this._other.make(); + this._other.path || (this._other.path=new Path()); + this._other.path.rect(x,y,width,height); + } + + __proto.strokeRect=function(x,y,width,height,parameterLineWidth){ + var tW=parameterLineWidth *0.5; + this.line(x-tW,y,x+width+tW,y,parameterLineWidth,this._curMat); + this.line(x+width,y,x+width,y+height,parameterLineWidth,this._curMat); + this.line(x,y,x,y+height,parameterLineWidth,this._curMat); + this.line(x-tW,y+height,x+width+tW,y+height,parameterLineWidth,this._curMat); + } + + __proto.clip=function(){} + /** + *画多边形(用) + *@param x + *@param y + *@param points + */ + __proto.drawPoly=function(x,y,points,color,lineWidth,boderColor,isConvexPolygon){ + (isConvexPolygon===void 0)&& (isConvexPolygon=false); + this._renderKey=0; + this._shader2D.glTexture=null; + var tPath=this._getPath(); + if (this.mId==-1){ + tPath.polygon(x,y,points,color,lineWidth ? lineWidth :1,boderColor) + } + else{ + if (this.mHaveKey){ + var tShape=VectorGraphManager.getInstance().shapeDic[this.mId]; + tPath.setGeomtry(tShape); + } + else{ + VectorGraphManager.getInstance().addShape(this.mId,tPath.polygon(x,y,points,color,lineWidth ? lineWidth :1,boderColor)); + } + } + tPath.update(); + var tPosArray=[this.mX,this.mY]; + var tArray=RenderState2D.getMatrArray(); + RenderState2D.mat2MatArray(this._curMat,tArray); + var tempSubmit; + if (!isConvexPolygon){ + var submit=SubmitStencil.create(4); + this.addRenderObject(submit); + tempSubmit=Submit.createShape(this,tPath.ib,tPath.vb,tPath.count,tPath.offset,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,0)); + tempSubmit.shaderValue.ALPHA=this._shader2D.ALPHA; + (tempSubmit.shaderValue).u_pos=tPosArray; + tempSubmit.shaderValue.u_mmat2=tArray; + this._submits[this._submits._length++]=tempSubmit; + submit=SubmitStencil.create(5); + this.addRenderObject(submit); + } + tempSubmit=Submit.createShape(this,tPath.ib,tPath.vb,tPath.count,tPath.offset,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,0)); + tempSubmit.shaderValue.ALPHA=this._shader2D.ALPHA; + (tempSubmit.shaderValue).u_pos=tPosArray; + tempSubmit.shaderValue.u_mmat2=tArray; + this._submits[this._submits._length++]=tempSubmit; + if (!isConvexPolygon){ + submit=SubmitStencil.create(3); + this.addRenderObject(submit); + } + if (lineWidth > 0){ + if (this.mHaveLineKey){ + var tShapeLine=VectorGraphManager.getInstance().shapeLineDic[this.mId]; + tPath.setGeomtry(tShapeLine); + } + else{ + VectorGraphManager.getInstance().addShape(this.mId,tPath.drawLine(x,y,points,lineWidth,boderColor)); + } + tPath.update(); + tempSubmit=Submit.createShape(this,tPath.ib,tPath.vb,tPath.count,tPath.offset,Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,0)); + tempSubmit.shaderValue.ALPHA=this._shader2D.ALPHA; + tempSubmit.shaderValue.u_mmat2=tArray; + this._submits[this._submits._length++]=tempSubmit; + } + } + + /*******************************************end矢量绘制***************************************************/ + __proto.drawParticle=function(x,y,pt){ + pt.x=x; + pt.y=y; + this._submits[this._submits._length++]=pt; + } + + __proto._getPath=function(){ + return this._path || (this._path=new Path()); + } + + /*,_shader2D.ALPHA=1*/ + __getset(0,__proto,'globalCompositeOperation',function(){ + return BlendMode.NAMES[this._nBlendType]; + },function(value){ + var n=BlendMode.TOINT[value]; + n==null || (this._nBlendType===n)|| (SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_GLOBALCOMPOSITEOPERATION*/0x10000,this,true),this._curSubmit=Submit.RENDERBASE,this._renderKey=0,this._nBlendType=n); + }); + + __getset(0,__proto,'strokeStyle',function(){ + return this._shader2D.strokeStyle; + },function(value){ + this._shader2D.strokeStyle.equal(value)|| (SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_STROKESTYLE*/0x200,this._shader2D,false),this._shader2D.strokeStyle=DrawStyle.create(value)); + }); + + __getset(0,__proto,'globalAlpha',function(){ + return this._shader2D.ALPHA; + },function(value){ + value=Math.floor(value *1000)/ 1000; + if (value !=this._shader2D.ALPHA){ + SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_ALPHA*/0x1,this._shader2D,true); + this._shader2D.ALPHA=value; + } + }); + + __getset(0,__proto,'asBitmap',null,function(value){ + if (value){ + this._targets || (this._targets=new RenderTargetMAX()); + this._targets.repaint=true; + if (!this._width || !this._height) + throw Error("asBitmap no size!"); + this._targets.size(this._width,this._height); + } + else + this._targets=null; + }); + + __getset(0,__proto,'fillStyle',function(){ + return this._shader2D.fillStyle; + },function(value){ + this._shader2D.fillStyle.equal(value)|| (SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_FILESTYLE*/0x2,this._shader2D,false),this._shader2D.fillStyle=DrawStyle.create(value)); + }); + + __getset(0,__proto,'textAlign',function(){ + return this._other.textAlign; + },function(value){ + (this._other.textAlign===value)|| (this._other=this._other.make(),SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_TEXTALIGN*/0x8000,this._other,false),this._other.textAlign=value); + }); + + __getset(0,__proto,'lineWidth',function(){ + return this._other.lineWidth; + },function(value){ + (this._other.lineWidth===value)|| (this._other=this._other.make(),SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_LINEWIDTH*/0x100,this._other,false),this._other.lineWidth=value); + }); + + __getset(0,__proto,'textBaseline',function(){ + return this._other.textBaseline; + },function(value){ + (this._other.textBaseline===value)|| (this._other=this._other.make(),SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_TEXTBASELINE*/0x4000,this._other,false),this._other.textBaseline=value); + }); + + __getset(0,__proto,'font',null,function(str){ + if (str==this._other.font.toString()) + return; + this._other=this._other.make(); + SaveBase.save(this,/*laya.webgl.canvas.save.SaveBase.TYPE_FONT*/0x8,this._other,false); + this._other.font===FontInContext.EMPTY ? (this._other.font=new FontInContext(str)):(this._other.font.setFont(str)); + }); + + WebGLContext2D.__init__=function(){ + ContextParams.DEFAULT=new ContextParams(); + } + + WebGLContext2D._SUBMITVBSIZE=32000; + WebGLContext2D._MAXSIZE=99999999; + WebGLContext2D._RECTVBSIZE=16; + WebGLContext2D.MAXCLIPRECT=new Rectangle(0,0,99999999,99999999); + WebGLContext2D._COUNT=0; + WebGLContext2D._tmpMatrix=new Matrix(); + __static(WebGLContext2D, + ['_fontTemp',function(){return this._fontTemp=new FontInContext();},'_drawStyleTemp',function(){return this._drawStyleTemp=new DrawStyle(null);} + ]); + WebGLContext2D.__init$=function(){ + //class ContextParams + ContextParams=(function(){ + function ContextParams(){ + this.lineWidth=1; + this.path=null; + this.textAlign=null; + this.textBaseline=null; + this.font=FontInContext.EMPTY; + } + __class(ContextParams,''); + var __proto=ContextParams.prototype; + __proto.clear=function(){ + this.lineWidth=1; + this.path && this.path.clear(); + this.textAlign=this.textBaseline=null; + this.font=FontInContext.EMPTY; + } + __proto.make=function(){ + return this===ContextParams.DEFAULT ? new ContextParams():this; + } + ContextParams.DEFAULT=null + return ContextParams; + })() + } + + return WebGLContext2D; + })(Context) + + + //class laya.webgl.shader.d2.value.Value2D extends laya.webgl.shader.ShaderValue + var Value2D=(function(_super){ + function Value2D(mainID,subID){ + this.size=[0,0]; + this.alpha=1.0; + //this.mmat=null; + this.ALPHA=1.0; + //this.shader=null; + //this.mainID=0; + this.subID=0; + //this.filters=null; + //this.textureHost=null; + //this.texture=null; + //this.fillStyle=null; + //this.color=null; + //this.strokeStyle=null; + //this.colorAdd=null; + //this.glTexture=null; + //this.u_mmat2=null; + //this._inClassCache=null; + this._cacheID=0; + Value2D.__super.call(this); + this.defines=new ShaderDefines2D(); + this.position=Value2D._POSITION; + this.mainID=mainID; + this.subID=subID; + this.textureHost=null; + this.texture=null; + this.fillStyle=null; + this.color=null; + this.strokeStyle=null; + this.colorAdd=null; + this.glTexture=null; + this.u_mmat2=null; + this._cacheID=mainID|subID; + this._inClassCache=Value2D._cache[this._cacheID]; + if (mainID>0 && !this._inClassCache){ + this._inClassCache=Value2D._cache[this._cacheID]=[]; + this._inClassCache._length=0; + } + this.clear(); + } + + __class(Value2D,'laya.webgl.shader.d2.value.Value2D',_super); + var __proto=Value2D.prototype; + __proto.setValue=function(value){} + //throw new Error("todo in subclass"); + __proto.refresh=function(){ + var size=this.size; + size[0]=RenderState2D.width; + size[1]=RenderState2D.height; + this.alpha=this.ALPHA *RenderState2D.worldAlpha; + this.mmat=RenderState2D.worldMatrix4; + return this; + } + + __proto._ShaderWithCompile=function(){ + return Shader.withCompile2D(0,this.mainID,this.defines.toNameDic(),this.mainID | this.defines._value,Shader2X.create); + } + + __proto._withWorldShaderDefines=function(){ + var defs=RenderState2D.worldShaderDefines; + var sd=Shader.sharders [this.mainID | this.defines._value | defs.getValue()]; + if (!sd){ + var def={}; + var dic; + var name; + dic=this.defines.toNameDic();for (name in dic)def[name]=""; + dic=defs.toNameDic();for (name in dic)def[name]=""; + sd=Shader.withCompile2D(0,this.mainID,def,this.mainID | this.defines._value| defs.getValue(),Shader2X.create); + }; + var worldFilters=RenderState2D.worldFilters; + if (!worldFilters)return sd; + var n=worldFilters.length,f; + for (var i=0;i < n;i++){ + ((f=worldFilters[i]))&& f.action.setValue(this); + } + return sd; + } + + __proto.upload=function(){ + var renderstate2d=RenderState2D; + this.alpha=this.ALPHA *renderstate2d.worldAlpha; + if (RenderState2D.worldMatrix4!==RenderState2D.TEMPMAT4_ARRAY)this.defines.add(/*laya.webgl.shader.d2.ShaderDefines2D.WORLDMAT*/0x80); + var sd=renderstate2d.worldShaderDefines?this._withWorldShaderDefines():(Shader.sharders [this.mainID | this.defines._value] || this._ShaderWithCompile()); + var params; + this.size[0]=renderstate2d.width,this.size[1]=renderstate2d.height; + this.mmat=renderstate2d.worldMatrix4; + if (Shader.activeShader!==sd){ + if (sd._shaderValueWidth!==renderstate2d.width || sd._shaderValueHeight!==renderstate2d.height){ + sd._shaderValueWidth=renderstate2d.width; + sd._shaderValueHeight=renderstate2d.height; + } + else{ + params=sd._params2dQuick2 || sd._make2dQuick2(); + } + sd.upload(this,params); + } + else{ + if (sd._shaderValueWidth!==renderstate2d.width || sd._shaderValueHeight!==renderstate2d.height){ + sd._shaderValueWidth=renderstate2d.width; + sd._shaderValueHeight=renderstate2d.height; + } + else{ + params=(sd._params2dQuick1)|| sd._make2dQuick1(); + } + sd.upload(this,params); + } + } + + __proto.setFilters=function(value){ + this.filters=value; + if (!value) + return; + var n=value.length,f; + for (var i=0;i < n;i++){ + f=value[i]; + if (f){ + this.defines.add(f.type); + f.action.setValue(this); + } + } + } + + __proto.clear=function(){ + this.defines.setValue(this.subID); + } + + __proto.release=function(){ + this._inClassCache[this._inClassCache._length++]=this; + this.fillStyle=null; + this.strokeStyle=null; + this.clear(); + } + + Value2D._initone=function(type,classT){ + Value2D._typeClass[type]=classT; + Value2D._cache[type]=[]; + Value2D._cache[type]._length=0; + } + + Value2D.__init__=function(){ + Value2D._POSITION=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,4 *CONST3D2D.BYTES_PE,0]; + Value2D._TEXCOORD=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,4 *CONST3D2D.BYTES_PE,2 *CONST3D2D.BYTES_PE]; + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,Color2dSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,PrimitiveSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.FILLTEXTURE*/0x100,FillTextureSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.SKINMESH*/0x200,SkinSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,TextureSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01 | /*laya.webgl.shader.d2.ShaderDefines2D.COLORADD*/0x40,TextSV); + Value2D._initone(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01 | /*laya.webgl.shader.d2.ShaderDefines2D.FILTERGLOW*/0x08,TextureSV); + } + + Value2D.create=function(mainType,subType){ + var types=Value2D._cache[mainType|subType]; + if (types._length) + return types[--types._length]; + else + return new Value2D._typeClass[mainType|subType](subType); + } + + Value2D._POSITION=null + Value2D._TEXCOORD=null + Value2D._cache=[]; + Value2D._typeClass=[]; + Value2D.TEMPMAT4_ARRAY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]; + return Value2D; + })(ShaderValue) + + + //class laya.webgl.utils.RenderSprite3D extends laya.renders.RenderSprite + var RenderSprite3D=(function(_super){ + function RenderSprite3D(type,next){ + RenderSprite3D.__super.call(this,type,next); + } + + __class(RenderSprite3D,'laya.webgl.utils.RenderSprite3D',_super); + var __proto=RenderSprite3D.prototype; + __proto.onCreate=function(type){ + switch (type){ + case 0x20: + this._fun=this._blend; + return; + case 0x04: + this._fun=this._transform; + return; + } + } + + __proto._blend=function(sprite,context,x,y){ + var style=sprite._style; + var next=this._next; + var mask=sprite.mask; + var submitCMD; + var submitStencil; + context.ctx.save(); + if (mask){ + var preBlendMode=(context.ctx).globalCompositeOperation; + var tRect=new Rectangle(); + tRect.copyFrom(mask.getBounds()); + if (tRect.width > 0 && tRect.height > 0){ + var scope=SubmitCMDScope.create(); + scope.addValue("bounds",tRect); + submitCMD=SubmitCMD.create([scope,context],laya.webgl.utils.RenderSprite3D.tmpTarget); + context.addRenderObject(submitCMD); + mask.render(context,-tRect.x,-tRect.y); + submitCMD=SubmitCMD.create([scope],laya.webgl.utils.RenderSprite3D.endTmpTarget); + context.addRenderObject(submitCMD); + context.ctx.save(); + context.clipRect(x+tRect.x,y+tRect.y,tRect.width,tRect.height); + next._fun.call(next,sprite,context,x,y); + context.ctx.restore(); + submitStencil=SubmitStencil.create(6); + preBlendMode=(context.ctx).globalCompositeOperation; + submitStencil.blendMode="mask"; + context.addRenderObject(submitStencil); + Matrix.TEMP.identity(); + var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + (context.ctx).drawTarget(scope,x+tRect.x,y+tRect.y,tRect.width,tRect.height,Matrix.TEMP,"tmpTarget",shaderValue,Texture.INV_UV,6); + submitCMD=SubmitCMD.create([scope],laya.webgl.utils.RenderSprite3D.recycleTarget); + context.addRenderObject(submitCMD); + submitStencil=SubmitStencil.create(6); + submitStencil.blendMode=preBlendMode; + context.addRenderObject(submitStencil); + } + }else { + context.ctx.globalCompositeOperation=style.blendMode; + next=this._next; + next._fun.call(next,sprite,context,x,y); + } + context.ctx.restore(); + } + + __proto._transform=function(sprite,context,x,y){ + 'use strict'; + var transform=sprite.transform,_next=this._next; + if (transform && _next !=RenderSprite.NORENDER){ + var ctx=context.ctx; + var style=sprite._style; + transform.tx=x; + transform.ty=y; + var m2=ctx._getTransformMatrix(); + var m1=m2.clone(); + Matrix.mul(transform,m2,m2); + m2._checkTransform(); + _next._fun.call(_next,sprite,context,0,0); + m1.copyTo(m2); + m1.destroy(); + transform.tx=transform.ty=0; + }else { + _next._fun.call(_next,sprite,context,x,y); + } + } + + RenderSprite3D.tmpTarget=function(scope,context){ + var b=scope.getValue("bounds"); + var tmpTarget=RenderTarget2D.create(b.width,b.height); + tmpTarget.start(); + tmpTarget.clear(0,0,0,0); + scope.addValue("tmpTarget",tmpTarget); + } + + RenderSprite3D.endTmpTarget=function(scope){ + var tmpTarget=scope.getValue("tmpTarget"); + tmpTarget.end(); + } + + RenderSprite3D.recycleTarget=function(scope){ + var tmpTarget=scope.getValue("tmpTarget"); + tmpTarget.recycle(); + scope.recycle(); + } + + return RenderSprite3D; + })(RenderSprite) + + + //class laya.filters.webgl.ColorFilterActionGL extends laya.filters.webgl.FilterActionGL + var ColorFilterActionGL=(function(_super){ + function ColorFilterActionGL(){ + this.data=null; + ColorFilterActionGL.__super.call(this); + } + + __class(ColorFilterActionGL,'laya.filters.webgl.ColorFilterActionGL',_super); + var __proto=ColorFilterActionGL.prototype; + Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) + __proto.setValue=function(shader){ + shader.colorMat=this.data._mat; + shader.colorAlpha=this.data._alpha; + } + + __proto.apply3d=function(scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + shaderValue.setFilters([this.data]); + var tMatrix=Matrix.EMPTY; + tMatrix.identity(); + context.ctx.drawTarget(scope,0,0,b.width,b.height,tMatrix,"src",shaderValue); + } + + return ColorFilterActionGL; + })(FilterActionGL) + + + //class laya.webgl.atlas.Atlaser extends laya.webgl.atlas.AtlasGrid + var Atlaser=(function(_super){ + function Atlaser(gridNumX,gridNumY,width,height,atlasID){ + this._atlasCanvas=null; + this._inAtlasTextureKey=null; + this._inAtlasTextureBitmapValue=null; + this._inAtlasTextureOriUVValue=null; + this._InAtlasWebGLImagesKey=null; + this._InAtlasWebGLImagesOffsetValue=null; + Atlaser.__super.call(this,gridNumX,gridNumY,atlasID); + this._inAtlasTextureKey=[]; + this._inAtlasTextureBitmapValue=[]; + this._inAtlasTextureOriUVValue=[]; + this._InAtlasWebGLImagesKey=[]; + this._InAtlasWebGLImagesOffsetValue=[]; + this._atlasCanvas=new AtlasWebGLCanvas(); + this._atlasCanvas.width=width; + this._atlasCanvas.height=height; + this._atlasCanvas.activeResource(); + this._atlasCanvas.lock=true; + } + + __class(Atlaser,'laya.webgl.atlas.Atlaser',_super); + var __proto=Atlaser.prototype; + __proto.computeUVinAtlasTexture=function(texture,oriUV,offsetX,offsetY){ + var tex=texture; + var _width=AtlasResourceManager.atlasTextureWidth; + var _height=AtlasResourceManager.atlasTextureHeight; + var u1=offsetX / _width,v1=offsetY / _height,u2=(offsetX+texture.bitmap.width)/ _width,v2=(offsetY+texture.bitmap.height)/ _height; + var inAltasUVWidth=texture.bitmap.width / _width,inAltasUVHeight=texture.bitmap.height / _height; + texture.uv=[u1+oriUV[0] *inAltasUVWidth,v1+oriUV[1] *inAltasUVHeight,u2-(1-oriUV[2])*inAltasUVWidth,v1+oriUV[3] *inAltasUVHeight,u2-(1-oriUV[4])*inAltasUVWidth,v2-(1-oriUV[5])*inAltasUVHeight,u1+oriUV[6] *inAltasUVWidth,v2-(1-oriUV[7])*inAltasUVHeight]; + } + + /** + * + *@param inAtlasRes + *@return 是否已经存在队列中 + */ + __proto.addToAtlasTexture=function(mergeAtlasBitmap,offsetX,offsetY){ + ((mergeAtlasBitmap instanceof laya.webgl.resource.WebGLImage ))&& (this._InAtlasWebGLImagesKey.push(mergeAtlasBitmap),this._InAtlasWebGLImagesOffsetValue.push([offsetX,offsetY])); + this._atlasCanvas.texSubImage2D(offsetX,offsetY,mergeAtlasBitmap.atlasSource); + mergeAtlasBitmap.clearAtlasSource(); + } + + __proto.addToAtlas=function(texture,offsetX,offsetY){ + var oriUV=texture.uv.slice(); + var oriBitmap=texture.bitmap; + this._inAtlasTextureKey.push(texture); + this._inAtlasTextureOriUVValue.push(oriUV); + this._inAtlasTextureBitmapValue.push(oriBitmap); + this.computeUVinAtlasTexture(texture,oriUV,offsetX,offsetY); + texture.bitmap=this._atlasCanvas; + } + + __proto.clear=function(){ + for (var i=0,n=this._inAtlasTextureKey.length;i < n;i++){ + this._inAtlasTextureKey[i].bitmap=this._inAtlasTextureBitmapValue[i]; + this._inAtlasTextureKey[i].uv=this._inAtlasTextureOriUVValue[i]; + this._inAtlasTextureKey[i].bitmap.lock=false; + this._inAtlasTextureKey[i].bitmap.releaseResource(); + } + this._inAtlasTextureKey.length=0; + this._inAtlasTextureBitmapValue.length=0; + this._inAtlasTextureOriUVValue.length=0; + this._InAtlasWebGLImagesKey.length=0; + this._InAtlasWebGLImagesOffsetValue.length=0; + } + + __proto.dispose=function(){ + this.clear(); + this._atlasCanvas.dispose(); + } + + __getset(0,__proto,'InAtlasWebGLImagesOffsetValue',function(){ + return this._InAtlasWebGLImagesOffsetValue; + }); + + __getset(0,__proto,'texture',function(){ + return this._atlasCanvas; + }); + + __getset(0,__proto,'inAtlasWebGLImagesKey',function(){ + return this._InAtlasWebGLImagesKey; + }); + + return Atlaser; + })(AtlasGrid) + + + //class laya.webgl.shader.d2.ShaderDefines2D extends laya.webgl.shader.ShaderDefines + var ShaderDefines2D=(function(_super){ + function ShaderDefines2D(){ + ShaderDefines2D.__super.call(this,ShaderDefines2D.__name2int,ShaderDefines2D.__int2name,ShaderDefines2D.__int2nameMap); + } + + __class(ShaderDefines2D,'laya.webgl.shader.d2.ShaderDefines2D',_super); + ShaderDefines2D.__init__=function(){ + ShaderDefines2D.reg("TEXTURE2D",0x01); + ShaderDefines2D.reg("COLOR2D",0x02); + ShaderDefines2D.reg("PRIMITIVE",0x04); + ShaderDefines2D.reg("GLOW_FILTER",0x08); + ShaderDefines2D.reg("BLUR_FILTER",0x10); + ShaderDefines2D.reg("COLOR_FILTER",0x20); + ShaderDefines2D.reg("COLOR_ADD",0x40); + ShaderDefines2D.reg("WORLDMAT",0x80); + ShaderDefines2D.reg("FILLTEXTURE",0x100); + } + + ShaderDefines2D.reg=function(name,value){ + ShaderDefines._reg(name,value,ShaderDefines2D.__name2int,ShaderDefines2D.__int2name); + } + + ShaderDefines2D.toText=function(value,int2name,int2nameMap){ + return ShaderDefines._toText(value,int2name,int2nameMap); + } + + ShaderDefines2D.toInt=function(names){ + return ShaderDefines._toInt(names,ShaderDefines2D.__name2int); + } + + ShaderDefines2D.TEXTURE2D=0x01; + ShaderDefines2D.COLOR2D=0x02; + ShaderDefines2D.PRIMITIVE=0x04; + ShaderDefines2D.FILTERGLOW=0x08; + ShaderDefines2D.FILTERBLUR=0x10; + ShaderDefines2D.FILTERCOLOR=0x20; + ShaderDefines2D.COLORADD=0x40; + ShaderDefines2D.WORLDMAT=0x80; + ShaderDefines2D.FILLTEXTURE=0x100; + ShaderDefines2D.SKINMESH=0x200; + ShaderDefines2D.__name2int={}; + ShaderDefines2D.__int2name=[]; + ShaderDefines2D.__int2nameMap=[]; + return ShaderDefines2D; + })(ShaderDefines) + + + //class laya.webgl.shapes.Ellipse extends laya.webgl.shapes.BasePoly + var Ellipse=(function(_super){ + function Ellipse(x,y,width,height,color,borderWidth,borderColor){ + Ellipse.__super.call(this,x,y,width,height,40,color,borderWidth,borderColor); + } + + __class(Ellipse,'laya.webgl.shapes.Ellipse',_super); + return Ellipse; + })(BasePoly) + + + //class laya.webgl.shapes.Line extends laya.webgl.shapes.BasePoly + var Line=(function(_super){ + function Line(x,y,points,borderWidth,color){ + this._points=[]; + var tCurrX=NaN; + var tCurrY=NaN; + var tLastX=-1; + var tLastY=-1; + var tLen=points.length / 2; + for (var i=0;i < tLen;i++){ + tCurrX=points[i *2]; + tCurrY=points[i *2+1]; + if (Math.abs(tLastX-tCurrX)> 0.01 || Math.abs(tLastY-tCurrY)>0.01){ + this._points.push(tCurrX,tCurrY); + } + tLastX=tCurrX; + tLastY=tCurrY; + } + Line.__super.call(this,x,y,0,0,0,color,borderWidth,color,0); + } + + __class(Line,'laya.webgl.shapes.Line',_super); + var __proto=Line.prototype; + __proto.getData=function(ib,vb,start){ + var indices=[]; + var verts=[]; + (this.borderWidth > 0)&& this.createLine2(this._points,indices,this.borderWidth,start,verts,this._points.length / 2); + ib.append(new Uint16Array(indices)); + vb.append(new Float32Array(verts)); + } + + return Line; + })(BasePoly) + + + //class laya.webgl.shapes.LoopLine extends laya.webgl.shapes.BasePoly + var LoopLine=(function(_super){ + function LoopLine(x,y,points,width,color){ + this._points=[]; + var tCurrX=NaN; + var tCurrY=NaN; + var tLastX=-1; + var tLastY=-1; + var tLen=points.length / 2-1; + for (var i=0;i < tLen;i++){ + tCurrX=points[i *2]; + tCurrY=points[i *2+1]; + if (Math.abs(tLastX-tCurrX)> 0.01 || Math.abs(tLastY-tCurrY)> 0.01){ + this._points.push(tCurrX,tCurrY); + } + tLastX=tCurrX; + tLastY=tCurrY; + } + tCurrX=points[tLen *2]; + tCurrY=points[tLen *2+1]; + tLastX=this._points[0]; + tLastY=this._points[1]; + if (Math.abs(tLastX-tCurrX)> 0.01 || Math.abs(tLastY-tCurrY)> 0.01){ + this._points.push(tCurrX,tCurrY); + } + LoopLine.__super.call(this,x,y,0,0,this._points.length / 2,0,width,color); + } + + __class(LoopLine,'laya.webgl.shapes.LoopLine',_super); + var __proto=LoopLine.prototype; + __proto.getData=function(ib,vb,start){ + if (this.borderWidth > 0){ + var color=this.color; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + var verts=[]; + var tLastX=-1,tLastY=-1; + var tCurrX=0,tCurrY=0; + var indices=[]; + var tLen=Math.floor(this._points.length / 2); + for (var i=0;i < tLen;i++){ + tCurrX=this._points[i *2]; + tCurrY=this._points[i *2+1]; + verts.push(this.x+tCurrX,this.y+tCurrY,r,g,b); + } + this.createLoopLine(verts,indices,this.borderWidth,start+verts.length / 5); + ib.append(new Uint16Array(indices)); + vb.append(new Float32Array(verts)); + } + } + + __proto.createLoopLine=function(p,indices,lineWidth,len,outVertex,outIndex){ + var tLen=p.length / 5; + var points=p.concat(); + var result=outVertex ? outVertex :p; + var color=this.borderColor; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + var firstPoint=[points[0],points[1]]; + var lastPoint=[points[points.length-5],points[points.length-4]]; + var midPointX=lastPoint[0]+(firstPoint[0]-lastPoint[0])*0.5; + var midPointY=lastPoint[1]+(firstPoint[1]-lastPoint[1])*0.5; + points.unshift(midPointX,midPointY,0,0,0); + points.push(midPointX,midPointY,0,0,0); + var length=points.length / 5; + var iStart=len,w=lineWidth / 2; + var px,py,p1x,p1y,p2x,p2y,p3x,p3y; + var perpx,perpy,perp2x,perp2y,perp3x,perp3y; + var a1,b1,c1,a2,b2,c2; + var denom,pdist,dist; + p1x=points[0]; + p1y=points[1]; + p2x=points[5]; + p2y=points[6]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + result.push(p1x-perpx,p1y-perpy,r,g,b,p1x+perpx,p1y+perpy,r,g,b); + for (var i=1;i < length-1;i++){ + p1x=points[(i-1)*5]; + p1y=points[(i-1)*5+1]; + p2x=points[(i)*5]; + p2y=points[(i)*5+1]; + p3x=points[(i+1)*5]; + p3y=points[(i+1)*5+1]; + perpx=-(p1y-p2y); + perpy=p1x-p2x; + dist=Math.sqrt(perpx *perpx+perpy *perpy); + perpx=perpx / dist *w; + perpy=perpy / dist *w; + perp2x=-(p2y-p3y); + perp2y=p2x-p3x; + dist=Math.sqrt(perp2x *perp2x+perp2y *perp2y); + perp2x=perp2x / dist *w; + perp2y=perp2y / dist *w; + a1=(-perpy+p1y)-(-perpy+p2y); + b1=(-perpx+p2x)-(-perpx+p1x); + c1=(-perpx+p1x)*(-perpy+p2y)-(-perpx+p2x)*(-perpy+p1y); + a2=(-perp2y+p3y)-(-perp2y+p2y); + b2=(-perp2x+p2x)-(-perp2x+p3x); + c2=(-perp2x+p3x)*(-perp2y+p2y)-(-perp2x+p2x)*(-perp2y+p3y); + denom=a1 *b2-a2 *b1; + if (Math.abs(denom)< 0.1){ + denom+=10.1; + result.push(p2x-perpx,p2y-perpy,r,g,b,p2x+perpx,p2y+perpy,r,g,b); + continue ; + } + px=(b1 *c2-b2 *c1)/ denom; + py=(a2 *c1-a1 *c2)/ denom; + pdist=(px-p2x)*(px-p2x)+(py-p2y)+(py-p2y); + result.push(px,py,r,g,b,p2x-(px-p2x),p2y-(py-p2y),r,g,b); + } + if (outIndex){ + indices=outIndex; + }; + var groupLen=this.edges+1; + for (i=1;i < groupLen;i++){ + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+i *2+1,iStart+i *2+1,iStart+i *2,iStart+(i-1)*2); + } + indices.push(iStart+(i-1)*2,iStart+(i-1)*2+1,iStart+1,iStart+1,iStart,iStart+(i-1)*2); + return result; + } + + return LoopLine; + })(BasePoly) + + + //class laya.webgl.shapes.Polygon extends laya.webgl.shapes.BasePoly + var Polygon=(function(_super){ + function Polygon(x,y,points,color,borderWidth,borderColor){ + this._points=null; + this._start=-1; + this.mUint16Array=null; + this.mFloat32Array=null; + this._points=points.slice(0,points.length); + Polygon.__super.call(this,x,y,0,0,this._points.length / 2,color,borderWidth,borderColor); + } + + __class(Polygon,'laya.webgl.shapes.Polygon',_super); + var __proto=Polygon.prototype; + __proto.getData=function(ib,vb,start){ + var indices,i=0; + var tArray=this._points; + var tLen=0; + if (this.mUint16Array && this.mFloat32Array){ + if (this._start !=start){ + this._start=start; + indices=[]; + tLen=Math.floor(tArray.length / 2); + for (i=2;i < tLen;i++){ + indices.push(start,start+i-1,start+i); + } + this.mUint16Array=new Uint16Array(indices); + } + }else { + this._start=start; + indices=[]; + var verts=[]; + var color=this.color; + var r=((color >> 16)& 0x0000ff)/ 255,g=((color >> 8)& 0xff)/ 255,b=(color & 0x0000ff)/ 255; + tLen=Math.floor(tArray.length / 2); + for (i=0;i < tLen;i++){ + verts.push(this.x+tArray[i *2],this.y+tArray[i *2+1],r,g,b); + } + for (i=2;i < tLen;i++){ + indices.push(start,start+i-1,start+i); + } + this.mUint16Array=new Uint16Array(indices); + this.mFloat32Array=new Float32Array(verts); + } + ib.append(this.mUint16Array); + vb.append(this.mFloat32Array); + } + + return Polygon; + })(BasePoly) + + + //class laya.webgl.submit.SubmitCanvas extends laya.webgl.submit.Submit + var SubmitCanvas=(function(_super){ + function SubmitCanvas(){ + //this._ctx_src=null; + this._matrix=new Matrix(); + this._matrix4=CONST3D2D.defaultMatrix4.concat(); + SubmitCanvas.__super.call(this,/*laya.webgl.submit.Submit.TYPE_2D*/10000); + this.shaderValue=new Value2D(0,0); + } + + __class(SubmitCanvas,'laya.webgl.submit.SubmitCanvas',_super); + var __proto=SubmitCanvas.prototype; + __proto.renderSubmit=function(){ + if (this._ctx_src._targets){ + this._ctx_src._targets.flush(this._ctx_src); + return 1; + }; + var preAlpha=RenderState2D.worldAlpha; + var preMatrix4=RenderState2D.worldMatrix4; + var preMatrix=RenderState2D.worldMatrix; + var preFilters=RenderState2D.worldFilters; + var preWorldShaderDefines=RenderState2D.worldShaderDefines; + var v=this.shaderValue; + var m=this._matrix; + var m4=this._matrix4; + var mout=Matrix.TEMP; + Matrix.mul(m,preMatrix,mout); + m4[0]=mout.a; + m4[1]=mout.b; + m4[4]=mout.c; + m4[5]=mout.d; + m4[12]=mout.tx; + m4[13]=mout.ty; + RenderState2D.worldMatrix=mout.clone(); + RenderState2D.worldMatrix4=m4; + RenderState2D.worldAlpha=RenderState2D.worldAlpha *v.alpha; + if (v.filters && v.filters.length){ + RenderState2D.worldFilters=v.filters; + RenderState2D.worldShaderDefines=v.defines; + } + this._ctx_src.flush(); + RenderState2D.worldAlpha=preAlpha; + RenderState2D.worldMatrix4=preMatrix4; + RenderState2D.worldMatrix.destroy(); + RenderState2D.worldMatrix=preMatrix; + RenderState2D.worldFilters=preFilters; + RenderState2D.worldShaderDefines=preWorldShaderDefines; + return 1; + } + + __proto.releaseRender=function(){ + var cache=SubmitCanvas._cache; + cache[cache._length++]=this; + } + + __proto.getRenderType=function(){ + return /*laya.webgl.submit.Submit.TYPE_CANVAS*/10003; + } + + SubmitCanvas.create=function(ctx_src,alpha,filters){ + var o=(!SubmitCanvas._cache._length)? (new SubmitCanvas()):SubmitCanvas._cache[--SubmitCanvas._cache._length]; + o._ctx_src=ctx_src; + var v=o.shaderValue; + v.alpha=alpha; + v.defines.setValue(0); + filters && filters.length && v.setFilters(filters); + return o; + } + + SubmitCanvas._cache=(SubmitCanvas._cache=[],SubmitCanvas._cache._length=0,SubmitCanvas._cache); + return SubmitCanvas; + })(Submit) + + + //class laya.webgl.submit.SubmitTexture extends laya.webgl.submit.Submit + var SubmitTexture=(function(_super){ + function SubmitTexture(renderType){ + this._preIsSameTextureShader=false; + this._isSameTexture=true; + this._texs=new Array; + this._texsID=new Array; + this._vbPos=new Array; + (renderType===void 0)&& (renderType=10000); + SubmitTexture.__super.call(this,renderType); + } + + __class(SubmitTexture,'laya.webgl.submit.SubmitTexture',_super); + var __proto=SubmitTexture.prototype; + __proto.releaseRender=function(){ + var cache=SubmitTexture._cache; + cache[cache._length++]=this; + this.shaderValue.release(); + this._preIsSameTextureShader=false; + this._vb=null; + this._texs.length=0; + this._isSameTexture=true; + } + + __proto.addTexture=function(tex,vbpos){ + this._texsID[this._texs.length]=tex._uvID; + this._texs.push(tex); + this._vbPos.push(vbpos); + } + + //检查材质是否修改,修改UV,设置是否是同一材质 + __proto.checkTexture=function(){ + if (this._texs.length < 1){ + this._isSameTexture=true; + return; + }; + var _tex=this.shaderValue.textureHost; + var webGLImg=_tex.bitmap; + if (webGLImg===null)return; + var vbdata=this._vb.getFloat32Array(); + for (var i=0,s=this._texs.length;i < s;i++){ + var tex=this._texs[i]; + tex.active(); + var newUV=tex.uv; + if (this._texsID[i]!==tex._uvID){ + this._texsID[i]=tex._uvID; + var vbPos=this._vbPos[i]; + vbdata[vbPos+2]=newUV[0]; + vbdata[vbPos+3]=newUV[1]; + vbdata[vbPos+6]=newUV[2]; + vbdata[vbPos+7]=newUV[3]; + vbdata[vbPos+10]=newUV[4]; + vbdata[vbPos+11]=newUV[5]; + vbdata[vbPos+14]=newUV[6]; + vbdata[vbPos+15]=newUV[7]; + this._vb.setNeedUpload(); + } + if (tex.bitmap!==webGLImg){ + this._isSameTexture=false; + } + } + } + + __proto.renderSubmit=function(){ + if (this._numEle===0)return 1; + var _tex=this.shaderValue.textureHost; + if (_tex){ + var source=_tex.source; + if (!_tex.bitmap || !source){ + SubmitTexture._shaderSet=false; + return 1; + } + this.shaderValue.texture=source; + } + this._vb.bind_upload(this._ib); + var gl=WebGL.mainContext; + if (BlendMode.activeBlendFunction!==this._blendFn){ + gl.enable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + this._blendFn(gl); + BlendMode.activeBlendFunction=this._blendFn; + } + Stat.drawCall++; + Stat.trianglesFaces+=this._numEle / 3; + if (this._preIsSameTextureShader && Shader.activeShader && SubmitTexture._shaderSet) + Shader.activeShader.uploadTexture2D(this.shaderValue.texture); + else this.shaderValue.upload(); + SubmitTexture._shaderSet=true; + if (this._texs.length > 1 && !this._isSameTexture){ + var webGLImg=_tex.bitmap; + var index=0; + var shader=Shader.activeShader; + for (var i=0,s=this._texs.length;i < s;i++){ + var tex2=this._texs[i]; + if (tex2.bitmap!==webGLImg || (i+1)===s){ + shader.uploadTexture2D(tex2.source); + gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,(i-index+1)*6,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._startIdx+index *6 *CONST3D2D.BYTES_PIDX); + webGLImg=tex2.bitmap; + index=i; + } + } + }else { + gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._numEle,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._startIdx); + } + return 1; + } + + SubmitTexture.create=function(context,ib,vb,pos,sv){ + var o=SubmitTexture._cache._length ? SubmitTexture._cache[--SubmitTexture._cache._length] :new SubmitTexture(); + if (vb==null){ + vb=o._selfVb || (o._selfVb=VertexBuffer2D.create(-1)); + vb.clear(); + pos=0; + } + o._ib=ib; + o._vb=vb; + o._startIdx=pos *CONST3D2D.BYTES_PIDX; + o._numEle=0; + var blendType=context._nBlendType; + o._blendFn=context._targets ? BlendMode.targetFns[blendType] :BlendMode.fns[blendType]; + o.shaderValue=sv; + o.shaderValue.setValue(context._shader2D); + var filters=context._shader2D.filters; + filters && o.shaderValue.setFilters(filters); + return o; + } + + SubmitTexture._cache=(SubmitTexture._cache=[],SubmitTexture._cache._length=0,SubmitTexture._cache); + SubmitTexture._shaderSet=true; + return SubmitTexture; + })(Submit) + + + //class laya.webgl.shader.Shader extends laya.resource.Resource + var Shader=(function(_super){ + function Shader(vs,ps,saveName,nameMap){ + this.customCompile=false; + //this._nameMap=null; + //this._vs=null; + //this._ps=null; + this._curActTexIndex=0; + //this._reCompile=false; + this.tag={}; + //this._vshader=null; + //this._pshader=null; + this._program=null; + this._params=null; + this._paramsMap={}; + this._offset=0; + //this._id=0; + Shader.__super.call(this); + if ((!vs)|| (!ps))throw "Shader Error"; + if (Render.isConchApp || Render.isFlash){ + this.customCompile=true; + } + this._id=++Shader._count; + this._vs=vs; + this._ps=ps; + this._nameMap=nameMap ? nameMap :{}; + saveName !=null && (Shader.sharders[saveName]=this); + } + + __class(Shader,'laya.webgl.shader.Shader',_super); + var __proto=Shader.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + this._compile(); + this.completeCreate(); + this.memorySize=0; + } + + //忽略尺寸尺寸 + __proto.detoryResource=function(){ + WebGL.mainContext.deleteShader(this._vshader); + WebGL.mainContext.deleteShader(this._pshader); + WebGL.mainContext.deleteProgram(this._program); + this._vshader=this._pshader=this._program=null; + this._params=null; + this._paramsMap={}; + this.memorySize=0; + this._curActTexIndex=0; + } + + __proto._compile=function(){ + if (!this._vs || !this._ps || this._params) + return; + this._reCompile=true; + this._params=[]; + var text=[this._vs,this._ps]; + var result; + if (this.customCompile) + result=this._preGetParams(this._vs,this._ps); + var gl=WebGL.mainContext; + this._program=gl.createProgram(); + this._vshader=Shader._createShader(gl,text[0],/*laya.webgl.WebGLContext.VERTEX_SHADER*/0x8B31); + this._pshader=Shader._createShader(gl,text[1],/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30); + gl.attachShader(this._program,this._vshader); + gl.attachShader(this._program,this._pshader); + gl.linkProgram(this._program); + if (!this.customCompile && !gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.LINK_STATUS*/0x8B82)){ + throw gl.getProgramInfoLog(this._program); + }; + var one,i=0,j=0,n=0,location; + var attribNum=this.customCompile ? result.attributes.length :gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.ACTIVE_ATTRIBUTES*/0x8B89); + for (i=0;i < attribNum;i++){ + var attrib=this.customCompile ? result.attributes[i] :gl.getActiveAttrib(this._program,i); + location=gl.getAttribLocation(this._program,attrib.name); + one={vartype:"attribute",ivartype:0,attrib:attrib,location:location,name:attrib.name,type:attrib.type,isArray:false,isSame:false,preValue:null,indexOfParams:0}; + this._params.push(one); + }; + var nUniformNum=this.customCompile ? result.uniforms.length :gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.ACTIVE_UNIFORMS*/0x8B86); + for (i=0;i < nUniformNum;i++){ + var uniform=this.customCompile ? result.uniforms[i] :gl.getActiveUniform(this._program,i); + location=gl.getUniformLocation(this._program,uniform.name); + one={vartype:"uniform",ivartype:1,attrib:attrib,location:location,name:uniform.name,type:uniform.type,isArray:false,isSame:false,preValue:null,indexOfParams:0}; + if (one.name.indexOf('[0]')> 0){ + one.name=one.name.substr(0,one.name.length-3); + one.isArray=true; + one.location=gl.getUniformLocation(this._program,one.name); + } + this._params.push(one); + } + for (i=0,n=this._params.length;i < n;i++){ + one=this._params[i]; + one.indexOfParams=i; + one.index=1; + one.value=[one.location,null]; + one.codename=one.name; + one.name=this._nameMap[one.codename] ? this._nameMap[one.codename] :one.codename; + this._paramsMap[one.name]=one; + one._this=this; + one.uploadedValue=[]; + if (one.vartype==="attribute"){ + one.fun=this._attribute; + continue ; + } + switch (one.type){ + case /*laya.webgl.WebGLContext.INT*/0x1404: + one.fun=one.isArray ? this._uniform1iv :this._uniform1i; + break ; + case /*laya.webgl.WebGLContext.FLOAT*/0x1406: + one.fun=one.isArray ? this._uniform1fv :this._uniform1f; + break ; + case /*laya.webgl.WebGLContext.FLOAT_VEC2*/0x8B50: + one.fun=one.isArray ? this._uniform_vec2v:this._uniform_vec2; + break ; + case /*laya.webgl.WebGLContext.FLOAT_VEC3*/0x8B51: + one.fun=one.isArray ? this._uniform_vec3v:this._uniform_vec3; + break ; + case /*laya.webgl.WebGLContext.FLOAT_VEC4*/0x8B52: + one.fun=one.isArray ? this._uniform_vec4v:this._uniform_vec4; + break ; + case /*laya.webgl.WebGLContext.SAMPLER_2D*/0x8B5E: + one.fun=this._uniform_sampler2D; + break ; + case /*laya.webgl.WebGLContext.SAMPLER_CUBE*/0x8B60: + one.fun=this._uniform_samplerCube; + break ; + case /*laya.webgl.WebGLContext.FLOAT_MAT4*/0x8B5C: + one.fun=this._uniformMatrix4fv; + break ; + case /*laya.webgl.WebGLContext.BOOL*/0x8B56: + one.fun=this._uniform1i; + break ; + case /*laya.webgl.WebGLContext.FLOAT_MAT2*/0x8B5A: + case /*laya.webgl.WebGLContext.FLOAT_MAT3*/0x8B5B: + throw new Error("compile shader err!"); + break ; + default : + throw new Error("compile shader err!"); + break ; + } + } + } + + /** + *根据变量名字获得 + *@param name + *@return + */ + __proto.getUniform=function(name){ + return this._paramsMap[name]; + } + + __proto._attribute=function(one,value){ + var gl=WebGL.mainContext; + gl.enableVertexAttribArray(one.location); + gl.vertexAttribPointer(one.location,value[0],value[1],value[2],value[3],value[4]+this._offset); + return 2; + } + + __proto._uniform1f=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value){ + WebGL.mainContext.uniform1f(one.location,uploadedValue[0]=value); + return 1; + } + return 0; + } + + __proto._uniform1fv=function(one,value){ + if (value.length < 4){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){ + WebGL.mainContext.uniform1fv(one.location,value); + uploadedValue[0]=value[0]; + uploadedValue[1]=value[1]; + uploadedValue[2]=value[2]; + uploadedValue[3]=value[3]; + return 1; + } + return 0; + }else { + WebGL.mainContext.uniform1fv(one.location,value); + return 1; + } + } + + __proto._uniform_vec2=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1]){ + WebGL.mainContext.uniform2f(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1]); + return 1; + } + return 0; + } + + __proto._uniform_vec2v=function(one,value){ + if (value.length < 2){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){ + WebGL.mainContext.uniform2fv(one.location,value); + uploadedValue[0]=value[0]; + uploadedValue[1]=value[1]; + uploadedValue[2]=value[2]; + uploadedValue[3]=value[3]; + return 1; + } + return 0; + }else { + WebGL.mainContext.uniform2fv(one.location,value); + return 1; + } + } + + __proto._uniform_vec3=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2]){ + WebGL.mainContext.uniform3f(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2]); + return 1; + } + return 0; + } + + __proto._uniform_vec3v=function(one,value){ + WebGL.mainContext.uniform3fv(one.location,value); + return 1; + } + + __proto._uniform_vec4=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){ + WebGL.mainContext.uniform4f(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2],uploadedValue[3]=value[3]); + return 1; + } + return 0; + } + + __proto._uniform_vec4v=function(one,value){ + WebGL.mainContext.uniform4fv(one.location,value); + return 1; + } + + __proto._uniformMatrix2fv=function(one,value){ + WebGL.mainContext.uniformMatrix2fv(one.location,false,value); + return 1; + } + + __proto._uniformMatrix3fv=function(one,value){ + WebGL.mainContext.uniformMatrix3fv(one.location,false,value); + return 1; + } + + __proto._uniformMatrix4fv=function(one,value){ + WebGL.mainContext.uniformMatrix4fv(one.location,false,value); + return 1; + } + + __proto._uniform1i=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value){ + WebGL.mainContext.uniform1i(one.location,uploadedValue[0]=value); + return 1; + } + return 0; + } + + __proto._uniform1iv=function(one,value){ + WebGL.mainContext.uniform1iv(one.location,value); + return 1; + } + + __proto._uniform_ivec2=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1]){ + WebGL.mainContext.uniform2i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1]); + return 1; + } + return 0; + } + + __proto._uniform_ivec2v=function(one,value){ + WebGL.mainContext.uniform2iv(one.location,value); + return 1; + } + + __proto._uniform_vec3i=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2]){ + WebGL.mainContext.uniform3i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2]); + return 1; + } + return 0; + } + + __proto._uniform_vec3vi=function(one,value){ + WebGL.mainContext.uniform3iv(one.location,value); + return 1; + } + + __proto._uniform_vec4i=function(one,value){ + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){ + WebGL.mainContext.uniform4i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2],uploadedValue[3]=value[3]); + return 1; + } + return 0; + } + + __proto._uniform_vec4vi=function(one,value){ + WebGL.mainContext.uniform4iv(one.location,value); + return 1; + } + + __proto._uniform_sampler2D=function(one,value){ + var gl=WebGL.mainContext; + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]==null){ + uploadedValue[0]=this._curActTexIndex; + gl.uniform1i(one.location,this._curActTexIndex); + gl.activeTexture(Shader._TEXTURES[this._curActTexIndex]); + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,value); + this._curActTexIndex++; + return 1; + }else { + gl.activeTexture(Shader._TEXTURES[uploadedValue[0]]); + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,value); + return 0; + } + } + + __proto._uniform_samplerCube=function(one,value){ + var gl=WebGL.mainContext; + var uploadedValue=one.uploadedValue; + if (uploadedValue[0]==null){ + uploadedValue[0]=this._curActTexIndex; + gl.uniform1i(one.location,this._curActTexIndex); + gl.activeTexture(Shader._TEXTURES[this._curActTexIndex]); + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,value); + this._curActTexIndex++; + return 1; + }else { + gl.activeTexture(Shader._TEXTURES[uploadedValue[0]]); + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,value); + return 0; + } + } + + __proto._noSetValue=function(one){ + console.log("no....:"+one.name); + } + + //throw new Error("upload shader err,must set value:"+one.name); + __proto.uploadOne=function(name,value){ + this.activeResource(); + WebGLContext.UseProgram(this._program); + var one=this._paramsMap[name]; + one.fun.call(this,one,value); + } + + __proto.uploadTexture2D=function(value){ + Stat.shaderCall++; + var gl=WebGL.mainContext; + gl.activeTexture(/*laya.webgl.WebGLContext.TEXTURE0*/0x84C0); + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,value); + } + + /** + *提交shader到GPU + *@param shaderValue + */ + __proto.upload=function(shaderValue,params){ + Shader.activeShader=this; + this.activeResource(); + WebGLContext.UseProgram(this._program); + if (this._reCompile){ + params=this._params; + this._reCompile=false; + }else { + params=params || this._params; + }; + var one,value,n=params.length,shaderCall=0; + for (var i=0;i < n;i++){ + one=params[i]; + ((value=shaderValue[one.name])!==null)&& (shaderCall+=one.fun.call(this,one,value)); + } + Stat.shaderCall+=shaderCall; + } + + /** + *按数组的定义提交 + *@param shaderValue 数组格式[name,value,...] + */ + __proto.uploadArray=function(shaderValue,length,_bufferUsage){ + Shader.activeShader=this; + this.activeResource(); + WebGLContext.UseProgram(this._program); + var params=this._params,value; + var one,shaderCall=0; + for (var i=length-2;i >=0;i-=2){ + one=this._paramsMap[shaderValue[i]]; + if (!one) + continue ; + value=shaderValue[i+1]; + if (value !=null){ + _bufferUsage && _bufferUsage[one.name] && _bufferUsage[one.name].bind(); + shaderCall+=one.fun.call(this,one,value); + } + } + Stat.shaderCall+=shaderCall; + } + + /** + *得到编译后的变量及相关预定义 + *@return + */ + __proto.getParams=function(){ + return this._params; + } + + __proto._preGetParams=function(vs,ps){ + var text=[vs,ps]; + var result={}; + var attributes=[]; + var uniforms=[]; + var definesInfo={}; + var definesName=[]; + result.attributes=attributes; + result.uniforms=uniforms; + result.defines=definesInfo; + var removeAnnotation=new RegExp("(/\\*([^*]|[\\r\\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)","g"); + var reg=new RegExp("(\".*\")|('.*')|([#\\w\\*-\\.+/()=<>{}\\\\]+)|([,;:\\\\])","g"); + var i=0,n=0,one; + for (var s=0;s < 2;s++){ + text[s]=text[s].replace(removeAnnotation,""); + var words=text[s].match(reg); + var tempelse; + for (i=0,n=words.length;i < n;i++){ + var word=words[i]; + if (word !="attribute" && word !="uniform"){ + if (word=="#define"){ + word=words[++i]; + definesName[word]=1; + continue ; + }else if (word=="#ifdef"){ + tempelse=words[++i]; + var def=definesInfo[tempelse]=definesInfo[tempelse] || []; + for (i++;i < n;i++){ + word=words[i]; + if (word !="attribute" && word !="uniform"){ + if (word=="#else"){ + for (i++;i < n;i++){ + word=words[i]; + if (word !="attribute" && word !="uniform"){ + if (word=="#endif"){ + break ; + } + continue ; + } + i=this.parseOne(attributes,uniforms,words,i,word,!definesName[tempelse]); + } + } + continue ; + } + i=this.parseOne(attributes,uniforms,words,i,word,definesName[tempelse]); + } + } + continue ; + } + i=this.parseOne(attributes,uniforms,words,i,word,true); + } + } + return result; + } + + __proto.parseOne=function(attributes,uniforms,words,i,word,b){ + var one={type:Shader.shaderParamsMap[words[i+1]],name:words[i+2],size:isNaN(parseInt(words[i+3]))? 1 :parseInt(words[i+3])}; + if (b){ + if (word=="attribute"){ + attributes.push(one); + }else { + uniforms.push(one); + } + } + if (words[i+3]==':'){ + one.type=words[i+4]; + i+=2; + } + i+=2; + return i; + } + + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + Shader.getShader=function(name){ + return Shader.sharders[name]; + } + + Shader.create=function(vs,ps,saveName,nameMap){ + return new Shader(vs,ps,saveName,nameMap); + } + + Shader.withCompile=function(nameID,define,shaderName,createShader){ + if (shaderName && Shader.sharders[shaderName]) + return Shader.sharders[shaderName]; + var pre=Shader._preCompileShader[0.0002 *nameID]; + if (!pre) + throw new Error("withCompile shader err!"+nameID); + return pre.createShader(define,shaderName,createShader); + } + + Shader.withCompile2D=function(nameID,mainID,define,shaderName,createShader){ + if (shaderName && Shader.sharders[shaderName]) + return Shader.sharders[shaderName]; + var pre=Shader._preCompileShader[0.0002 *nameID+mainID]; + if (!pre) + throw new Error("withCompile shader err!"+nameID+" "+mainID); + return pre.createShader(define,shaderName,createShader); + } + + Shader.addInclude=function(fileName,txt){ + if (!txt || txt.length===0) + throw new Error("add shader include file err:"+fileName); + if (Shader._includeFiles[fileName]) + throw new Error("add shader include file err, has add:"+fileName); + Shader._includeFiles[fileName]=txt; + } + + Shader.preCompile=function(nameID,vs,ps,nameMap){ + var id=0.0002 *nameID; + Shader._preCompileShader[id]=new ShaderCompile(id,vs,ps,nameMap,Shader._includeFiles); + } + + Shader.preCompile2D=function(nameID,mainID,vs,ps,nameMap){ + var id=0.0002 *nameID+mainID; + Shader._preCompileShader[id]=new ShaderCompile(id,vs,ps,nameMap,Shader._includeFiles); + } + + Shader._createShader=function(gl,str,type){ + var shader=gl.createShader(type); + gl.shaderSource(shader,str); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader,/*laya.webgl.WebGLContext.COMPILE_STATUS*/0x8B81)){ + throw gl.getShaderInfoLog(shader); + } + return shader; + } + + Shader._TEXTURES=[ /*laya.webgl.WebGLContext.TEXTURE0*/0x84C0,/*laya.webgl.WebGLContext.TEXTURE1*/0x84C1,/*laya.webgl.WebGLContext.TEXTURE2*/0x84C2,/*laya.webgl.WebGLContext.TEXTURE3*/0x84C3,/*laya.webgl.WebGLContext.TEXTURE4*/0x84C4,/*laya.webgl.WebGLContext.TEXTURE5*/0x84C5,/*laya.webgl.WebGLContext.TEXTURE6*/0x84C6,,/*laya.webgl.WebGLContext.TEXTURE7*/0x84C7,/*laya.webgl.WebGLContext.TEXTURE8*/0x84C8]; + Shader._includeFiles={}; + Shader._count=0; + Shader._preCompileShader={}; + Shader.SHADERNAME2ID=0.0002; + Shader.activeShader=null + Shader.sharders=(Shader.sharders=[],Shader.sharders.length=0x20,Shader.sharders); + __static(Shader, + ['shaderParamsMap',function(){return this.shaderParamsMap={"float":/*laya.webgl.WebGLContext.FLOAT*/0x1406,"int":/*laya.webgl.WebGLContext.INT*/0x1404,"bool":/*laya.webgl.WebGLContext.BOOL*/0x8B56,"vec2":/*laya.webgl.WebGLContext.FLOAT_VEC2*/0x8B50,"vec3":/*laya.webgl.WebGLContext.FLOAT_VEC3*/0x8B51,"vec4":/*laya.webgl.WebGLContext.FLOAT_VEC4*/0x8B52,"ivec2":/*laya.webgl.WebGLContext.INT_VEC2*/0x8B53,"ivec3":/*laya.webgl.WebGLContext.INT_VEC3*/0x8B54,"ivec4":/*laya.webgl.WebGLContext.INT_VEC4*/0x8B55,"bvec2":/*laya.webgl.WebGLContext.BOOL_VEC2*/0x8B57,"bvec3":/*laya.webgl.WebGLContext.BOOL_VEC3*/0x8B58,"bvec4":/*laya.webgl.WebGLContext.BOOL_VEC4*/0x8B59,"mat2":/*laya.webgl.WebGLContext.FLOAT_MAT2*/0x8B5A,"mat3":/*laya.webgl.WebGLContext.FLOAT_MAT3*/0x8B5B,"mat4":/*laya.webgl.WebGLContext.FLOAT_MAT4*/0x8B5C,"sampler2D":/*laya.webgl.WebGLContext.SAMPLER_2D*/0x8B5E,"samplerCube":/*laya.webgl.WebGLContext.SAMPLER_CUBE*/0x8B60};},'nameKey',function(){return this.nameKey=new StringKey();} + ]); + return Shader; + })(Resource) + + + //class laya.webgl.resource.RenderTarget2D extends laya.resource.Texture + var RenderTarget2D=(function(_super){ + function RenderTarget2D(width,height,surfaceFormat,surfaceType,depthStencilFormat,mipMap,repeat,minFifter,magFifter){ + this._type=0; + this._svWidth=NaN; + this._svHeight=NaN; + this._preRenderTarget=null; + this._alreadyResolved=false; + this._looked=false; + this._surfaceFormat=0; + this._surfaceType=0; + this._depthStencilFormat=0; + this._mipMap=false; + this._repeat=false; + this._minFifter=0; + this._magFifter=0; + this._destroy=false; + (surfaceFormat===void 0)&& (surfaceFormat=/*laya.webgl.WebGLContext.RGBA*/0x1908); + (surfaceType===void 0)&& (surfaceType=/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401); + (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5); + (mipMap===void 0)&& (mipMap=false); + (repeat===void 0)&& (repeat=false); + (minFifter===void 0)&& (minFifter=-1); + (magFifter===void 0)&& (magFifter=-1); + this._type=1; + this._w=width; + this._h=height; + this._surfaceFormat=surfaceFormat; + this._surfaceType=surfaceType; + this._depthStencilFormat=depthStencilFormat; + this._mipMap=mipMap; + this._repeat=repeat; + this._minFifter=minFifter; + this._magFifter=magFifter; + this._createWebGLRenderTarget(); + this.bitmap.lock=true; + RenderTarget2D.__super.call(this,this.bitmap,Texture.INV_UV); + } + + __class(RenderTarget2D,'laya.webgl.resource.RenderTarget2D',_super); + var __proto=RenderTarget2D.prototype; + Laya.imps(__proto,{"laya.resource.IDispose":true}) + //TODO:临时...................................................... + __proto.getType=function(){ + return this._type; + } + + //*/ + __proto.getTexture=function(){ + return this; + } + + __proto.size=function(w,h){ + if (this.bitmap && this._w==w && this._h==h) + return; + this._w=w; + this._h=h; + this.release(); + this._createWebGLRenderTarget(); + } + + __proto.release=function(){ + this.destroy(); + } + + __proto.recycle=function(){ + RenderTarget2D.POOL.push(this); + } + + __proto.start=function(){ + var gl=WebGL.mainContext; + this._preRenderTarget=RenderState2D.curRenderTarget; + RenderState2D.curRenderTarget=this; + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this.bitmap.frameBuffer); + this._alreadyResolved=false; + if (this._type==1){ + gl.viewport(0,0,this._w,this._h); + this._svWidth=RenderState2D.width; + this._svHeight=RenderState2D.height; + RenderState2D.width=this._w; + RenderState2D.height=this._h; + Shader.activeShader=null; + } + return this; + } + + __proto.clear=function(r,g,b,a){ + (r===void 0)&& (r=0.0); + (g===void 0)&& (g=0.0); + (b===void 0)&& (b=0.0); + (a===void 0)&& (a=1.0); + var gl=WebGL.mainContext; + gl.clearColor(r,g,b,a); + var clearFlag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000; + switch (this._depthStencilFormat){ + case /*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + break ; + case /*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48: + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400; + break ; + case /*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400 + break ; + } + gl.clear(clearFlag); + } + + __proto.end=function(){ + var gl=WebGL.mainContext; + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._preRenderTarget ? this._preRenderTarget.bitmap.frameBuffer :null); + this._alreadyResolved=true; + RenderState2D.curRenderTarget=this._preRenderTarget; + if (this._type==1){ + gl.viewport(0,0,this._svWidth,this._svHeight); + RenderState2D.width=this._svWidth; + RenderState2D.height=this._svHeight; + Shader.activeShader=null; + }else gl.viewport(0,0,Laya.stage.width,Laya.stage.height); + } + + __proto.getData=function(x,y,width,height){ + var gl=WebGL.mainContext; + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,(this.bitmap).frameBuffer); + var canRead=(gl.checkFramebufferStatus(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40)===/*laya.webgl.WebGLContext.FRAMEBUFFER_COMPLETE*/0x8CD5); + if (!canRead){ + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + return null; + }; + var pixels=new Uint8Array(this._w *this._h *4); + gl.readPixels(x,y,width,height,this._surfaceFormat,this._surfaceType,pixels); + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + return pixels; + } + + /**彻底清理资源,注意会强制解锁清理*/ + __proto.destroy=function(foreDiposeTexture){ + (foreDiposeTexture===void 0)&& (foreDiposeTexture=false); + if (!this._destroy){ + this._loaded=false; + this.bitmap.dispose(); + this.bitmap=null; + this._destroy=true; + _super.prototype.destroy.call(this); + } + } + + //待测试 + __proto.dispose=function(){} + __proto._createWebGLRenderTarget=function(){ + this.bitmap=new WebGLRenderTarget(this.width,this.height,this._surfaceFormat,this._surfaceType,this._depthStencilFormat,this._mipMap,this._repeat,this._minFifter,this._magFifter); + this.bitmap.activeResource(); + this._alreadyResolved=true; + this._destroy=false; + this._loaded=true; + } + + __getset(0,__proto,'surfaceFormat',function(){ + return this._surfaceFormat; + }); + + __getset(0,__proto,'magFifter',function(){ + return this._magFifter; + }); + + __getset(0,__proto,'surfaceType',function(){ + return this._surfaceType; + }); + + __getset(0,__proto,'mipMap',function(){ + return this._mipMap; + }); + + __getset(0,__proto,'depthStencilFormat',function(){ + return this._depthStencilFormat; + }); + + //} + __getset(0,__proto,'minFifter',function(){ + return this._minFifter; + }); + + /**返回RenderTarget的Texture*/ + __getset(0,__proto,'source',function(){ + if (this._alreadyResolved) + return _super.prototype._$get_source.call(this); + throw new Error("RenderTarget 还未准备好!"); + }); + + RenderTarget2D.create=function(w,h,surfaceFormat,surfaceType,depthStencilFormat,mipMap,repeat,minFifter,magFifter){ + (surfaceFormat===void 0)&& (surfaceFormat=/*laya.webgl.WebGLContext.RGBA*/0x1908); + (surfaceType===void 0)&& (surfaceType=/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401); + (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5); + (mipMap===void 0)&& (mipMap=false); + (repeat===void 0)&& (repeat=false); + (minFifter===void 0)&& (minFifter=-1); + (magFifter===void 0)&& (magFifter=-1); + var t=RenderTarget2D.POOL.pop(); + t || (t=new RenderTarget2D(w,h)); + if (!t.bitmap || t._w !=w || t._h !=h || t._surfaceFormat !=surfaceFormat || t._surfaceType !=surfaceType || t._depthStencilFormat !=depthStencilFormat || t._mipMap !=mipMap || t._repeat !=repeat || t._minFifter !=minFifter || t._magFifter !=magFifter){ + t._w=w; + t._h=h; + t._surfaceFormat=surfaceFormat; + t._surfaceType=surfaceType; + t._depthStencilFormat=depthStencilFormat; + t._mipMap=mipMap; + t._repeat=repeat; + t._minFifter=minFifter; + t._magFifter=magFifter; + t.release(); + t._createWebGLRenderTarget(); + } + return t; + } + + RenderTarget2D.TYPE2D=1; + RenderTarget2D.TYPE3D=2; + RenderTarget2D.POOL=[]; + return RenderTarget2D; + })(Texture) + + + //class laya.webgl.utils.Buffer extends laya.resource.Resource + var Buffer=(function(_super){ + function Buffer(){ + this._glBuffer=null; + this._buffer=null; + this._bufferType=0; + this._bufferUsage=0; + this._byteLength=0; + Buffer.__super.call(this); + Buffer._gl=WebGL.mainContext; + } + + __class(Buffer,'laya.webgl.utils.Buffer',_super); + var __proto=Buffer.prototype; + __proto._bind=function(){ + this.activeResource(); + (Buffer._bindActive[this._bufferType]===this._glBuffer)|| (Buffer._gl.bindBuffer(this._bufferType,Buffer._bindActive[this._bufferType]=this._glBuffer),Shader.activeShader=null); + } + + __proto.recreateResource=function(){ + this.startCreate(); + this._glBuffer || (this._glBuffer=Buffer._gl.createBuffer()); + this.completeCreate(); + } + + __proto.detoryResource=function(){ + if (this._glBuffer){ + WebGL.mainContext.deleteBuffer(this._glBuffer); + this._glBuffer=null; + } + this.memorySize=0; + } + + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + //TODO:私有 + __getset(0,__proto,'byteLength',function(){ + return this._byteLength; + }); + + __getset(0,__proto,'bufferType',function(){ + return this._bufferType; + }); + + __getset(0,__proto,'bufferUsage',function(){ + return this._bufferUsage; + }); + + Buffer._gl=null + Buffer._bindActive={}; + return Buffer; + })(Resource) + + + //class laya.webgl.shader.d2.skinAnishader.SkinSV extends laya.webgl.shader.d2.value.Value2D + var SkinSV=(function(_super){ + function SkinSV(type){ + this.texcoord=null; + this.offsetX=300; + this.offsetY=0; + SkinSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.SKINMESH*/0x200,0); + var _vlen=8 *CONST3D2D.BYTES_PE; + this.position=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,_vlen,0]; + this.texcoord=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,_vlen,2 *CONST3D2D.BYTES_PE]; + this.color=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,_vlen,4 *CONST3D2D.BYTES_PE]; + } + + __class(SkinSV,'laya.webgl.shader.d2.skinAnishader.SkinSV',_super); + return SkinSV; + })(Value2D) + + + //class laya.webgl.shader.d2.value.Color2dSV extends laya.webgl.shader.d2.value.Value2D + var Color2dSV=(function(_super){ + function Color2dSV(args){ + Color2dSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.COLOR2D*/0x02,0); + this.color=[]; + } + + __class(Color2dSV,'laya.webgl.shader.d2.value.Color2dSV',_super); + var __proto=Color2dSV.prototype; + __proto.setValue=function(value){ + value.fillStyle&&(this.color=value.fillStyle._color._color); + value.strokeStyle&&(this.color=value.strokeStyle._color._color); + } + + return Color2dSV; + })(Value2D) + + + //class laya.webgl.shader.d2.value.FillTextureSV extends laya.webgl.shader.d2.value.Value2D + var FillTextureSV=(function(_super){ + function FillTextureSV(type){ + this.u_colorMatrix=null; + this.strength=0; + this.colorMat=null; + this.colorAlpha=null; + this.u_TexRange=[0,1,0,1]; + this.u_offset=[0,0]; + this.texcoord=Value2D._TEXCOORD; + FillTextureSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.FILLTEXTURE*/0x100,0); + } + + __class(FillTextureSV,'laya.webgl.shader.d2.value.FillTextureSV',_super); + var __proto=FillTextureSV.prototype; + //this.color=[4,WebGLContext.FLOAT,false,_vlen,4 *CONST3D2D.BYTES_PE]; + __proto.setValue=function(vo){ + this.ALPHA=vo.ALPHA; + vo.filters && this.setFilters(vo.filters); + } + + __proto.clear=function(){ + this.texture=null; + this.shader=null; + this.defines.setValue(0); + } + + return FillTextureSV; + })(Value2D) + + + //class laya.webgl.shader.d2.value.TextureSV extends laya.webgl.shader.d2.value.Value2D + var TextureSV=(function(_super){ + function TextureSV(subID){ + this.u_colorMatrix=null; + this.strength=0; + this.colorMat=null; + this.colorAlpha=null; + this.texcoord=Value2D._TEXCOORD; + (subID===void 0)&& (subID=0); + TextureSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,subID); + } + + __class(TextureSV,'laya.webgl.shader.d2.value.TextureSV',_super); + var __proto=TextureSV.prototype; + __proto.setValue=function(vo){ + this.ALPHA=vo.ALPHA; + vo.filters && this.setFilters(vo.filters); + } + + __proto.clear=function(){ + this.texture=null; + this.shader=null; + this.defines.setValue(0); + } + + return TextureSV; + })(Value2D) + + + //class laya.webgl.shader.d2.value.PrimitiveSV extends laya.webgl.shader.d2.value.Value2D + var PrimitiveSV=(function(_super){ + function PrimitiveSV(args){ + this.a_color=null; + this.u_pos=[0,0]; + PrimitiveSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.PRIMITIVE*/0x04,0); + this.position=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,5 *CONST3D2D.BYTES_PE,0]; + this.a_color=[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,5 *CONST3D2D.BYTES_PE,2 *CONST3D2D.BYTES_PE]; + } + + __class(PrimitiveSV,'laya.webgl.shader.d2.value.PrimitiveSV',_super); + return PrimitiveSV; + })(Value2D) + + + //class laya.webgl.atlas.AtlasWebGLCanvas extends laya.resource.Bitmap + var AtlasWebGLCanvas=(function(_super){ + function AtlasWebGLCanvas(){ + this._flashCacheImage=null; + this._flashCacheImageNeedFlush=false; + AtlasWebGLCanvas.__super.call(this); + } + + __class(AtlasWebGLCanvas,'laya.webgl.atlas.AtlasWebGLCanvas',_super); + var __proto=AtlasWebGLCanvas.prototype; + /***重新创建资源*/ + __proto.recreateResource=function(){ + this.startCreate(); + var gl=WebGL.mainContext; + var glTex=this._source=gl.createTexture(); + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,this._w,this._h,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,null); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + this.memorySize=this._w *this._h *4; + this.completeCreate(); + } + + /***销毁资源*/ + __proto.detoryResource=function(){ + if (this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this.memorySize=0; + } + } + + /**采样image到WebGLTexture的一部分*/ + __proto.texSubImage2D=function(xoffset,yoffset,bitmap){ + if (!Render.isFlash){ + var gl=WebGL.mainContext; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + (xoffset-1 >=0)&& (gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset-1,yoffset,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,bitmap)); + (xoffset+1 <=this._w)&& (gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset+1,yoffset,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,bitmap)); + (yoffset-1 >=0)&& (gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset,yoffset-1,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,bitmap)); + (yoffset+1 <=this._h)&& (gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset,yoffset+1,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,bitmap)); + gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset,yoffset,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,bitmap); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + }else { + if (!this._flashCacheImage){ + this._flashCacheImage=HTMLImage.create(null); + this._flashCacheImage.image.createCanvas(this._w,this._h); + }; + var bmData=bitmap.bitmapdata; + (xoffset-1 >=0)&& (this._flashCacheImage.image.copyPixels(bmData,0,0,bmData.width-1,bmData.height,xoffset,yoffset)); + (xoffset+1 <=this._w)&& (this._flashCacheImage.image.copyPixels(bmData,0,0,bmData.width+1,bmData.height,xoffset,yoffset)); + (yoffset-1 >=0)&& (this._flashCacheImage.image.copyPixels(bmData,0,0,bmData.width,bmData.height-1,xoffset,yoffset)); + (yoffset+1 <=this._h)&& (this._flashCacheImage.image.copyPixels(bmData,0,0,bmData.width+1,bmData.height,xoffset,yoffset)); + this._flashCacheImage.image.copyPixels(bmData,0,0,bmData.width,bmData.height,xoffset,yoffset); + (this._flashCacheImageNeedFlush)|| (this._flashCacheImageNeedFlush=true); + } + } + + /**采样image到WebGLTexture的一部分*/ + __proto.texSubImage2DPixel=function(xoffset,yoffset,width,height,pixel){ + var gl=WebGL.mainContext; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + var pixels=new Uint8Array(pixel.data); + gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset,yoffset,width,height,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + } + + /*** + *设置图片宽度 + *@param value 图片宽度 + */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + this._w=value; + }); + + /*** + *设置图片高度 + *@param value 图片高度 + */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + this._h=value; + }); + + return AtlasWebGLCanvas; + })(Bitmap) + + + //class laya.webgl.resource.WebGLCanvas extends laya.resource.Bitmap + var WebGLCanvas=(function(_super){ + function WebGLCanvas(type){ + //this._ctx=null; + this._is2D=false; + //this._canvas=null; + //this.iscpuSource=false; + var _$this=this; + WebGLCanvas.__super.call(this); + this._canvas=this; + if (type==="2D" || (type==="AUTO" && !Render.isWebGL)){ + this._is2D=true; + this._canvas=this._source=Browser.createElement("canvas"); + this.iscpuSource=true; + var o=this; + o.getContext=function (contextID,other){ + if (_$this._ctx)return _$this._ctx; + var ctx=_$this._ctx=_$this._canvas.getContext(contextID,other); + if (ctx){ + ctx._canvas=o; + ctx.size=function (){ + }; + } + return ctx; + } + }else this._canvas={}; + } + + __class(WebGLCanvas,'laya.webgl.resource.WebGLCanvas',_super); + var __proto=WebGLCanvas.prototype; + __proto.clear=function(){ + this._ctx && this._ctx.clear(); + } + + __proto.destroy=function(){ + this._ctx && this._ctx.destroy(); + this._ctx=null; + } + + __proto._setContext=function(context){ + this._ctx=context; + } + + __proto.getContext=function(contextID,other){ + return this._ctx ? this._ctx :(this._ctx=WebGLCanvas._createContext(this)); + } + + /*override public function copyTo(dec:Bitmap):void { + super.copyTo(dec); + (dec as WebGLCanvas)._ctx=_ctx; + }*/ + + + __proto.size=function(w,h){ + if (this._w !=w || this._h !=h){ + this._w=w; + this._h=h; + this._ctx && this._ctx.size(w,h); + this._canvas && (this._canvas.height=h,this._canvas.width=w); + } + + } + + + __proto.recreateResource=function(){ + this.startCreate(); + this.createWebGlTexture(); + this.completeCreate(); + } + + + __proto.detoryResource=function(){ + if (this._source && !this.iscpuSource){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this.memorySize=0; + } + + } + + + __proto.createWebGlTexture=function(){ + var gl=WebGL.mainContext; + if (!this._canvas){ + throw "create GLTextur err:no data:"+this._canvas; + }; + + var glTex=this._source=gl.createTexture(); + this.iscpuSource=false; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,this._w,this._h,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,null); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + this.memorySize=this._w *this._h *4; + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + this._canvas=null; + } + + + __proto.texSubImage2D=function(webglCanvas,xoffset,yoffset){ + var gl=WebGL.mainContext; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + gl.texSubImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,xoffset,yoffset,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,webglCanvas._source); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + } + + + /** + *返回HTML Image,as3无internal货friend,通常禁止开发者修改image内的任何属性 + *@param HTML Image + */ + __getset(0,__proto,'canvas',function(){ + return this._canvas; + }); + + + __getset(0,__proto,'context',function(){ + return this._ctx; + }); + + + __getset(0,__proto,'asBitmap',null,function(value){ + this._ctx && (this._ctx.asBitmap=value); + }); + + + WebGLCanvas.create=function(type){ + return new WebGLCanvas(type); + } + + + WebGLCanvas._createContext=null + return WebGLCanvas; + })(Bitmap) + + + //class laya.webgl.resource.WebGLCharImage extends laya.resource.Bitmap + var WebGLCharImage=(function(_super){ + function WebGLCharImage(canvas,char){ + this.borderSize=12; + //this._ctx=null; + //this._allowMerageInAtlas=false; + //this._enableMerageInAtlas=false; + //this.canvas=null; + //this.char=null; + WebGLCharImage.__super.call(this); + this.canvas=canvas; + this.char=char; + this._enableMerageInAtlas=true; + var bIsConchApp=Render.isConchApp; + if (bIsConchApp){ + /*__JS__ */this._ctx=canvas; + }else { + this._ctx=canvas.getContext('2d',undefined); + }; + var xs=char.xs,ys=char.ys; + var t=null; + if (bIsConchApp){ + this._ctx.font=char.font; + t=this._ctx.measureText(char.char); + char.width=t.width *xs; + char.height=t.height *ys; + }else { + t=Utils.measureText(char.char,char.font); + char.width=t.width *xs; + char.height=t.height *ys; + } + this.onresize(char.width+this.borderSize *2,char.height+this.borderSize *2); + } + + __class(WebGLCharImage,'laya.webgl.resource.WebGLCharImage',_super); + var __proto=WebGLCharImage.prototype; + Laya.imps(__proto,{"laya.webgl.resource.IMergeAtlasBitmap":true}) + __proto.recreateResource=function(){ + this.startCreate(); + var char=this.char; + var bIsConchApp=Render.isConchApp; + var xs=char.xs,ys=char.ys; + this.onresize(char.width+this.borderSize *2,char.height+this.borderSize *2); + this.canvas && (this.canvas.height=this._h,this.canvas.width=this._w); + if (bIsConchApp){ + var nFontSize=char.fontSize; + if (xs !=1 || ys !=1){ + nFontSize=parseInt(nFontSize *((xs > ys)? xs :ys)+""); + }; + var sFont="normal 100 "+nFontSize+"px Arial"; + if (char.borderColor){ + sFont+=" 1 "+char.borderColor; + } + this._ctx.font=sFont; + this._ctx.textBaseline="top"; + this._ctx.fillStyle=char.fillColor; + this._ctx.fillText(char.char,this.borderSize,this.borderSize,null,null,null); + }else { + this._ctx.save(); + (this._ctx).clearRect(0,0,char.width+this.borderSize *2,char.height+this.borderSize *2); + this._ctx.font=char.font; + this._ctx.textBaseline="top"; + this._ctx.translate(this.borderSize,this.borderSize); + if (xs !=1 || ys !=1){ + this._ctx.scale(xs,ys); + } + if (char.fillColor && char.borderColor){ + /*__JS__ */this._ctx.strokeStyle=char.borderColor; + /*__JS__ */this._ctx.lineWidth=char.lineWidth; + this._ctx.strokeText(char.char,0,0,null,null,0,null); + this._ctx.fillStyle=char.fillColor; + this._ctx.fillText(char.char,0,0,null,null,null); + }else { + if (char.lineWidth===-1){ + this._ctx.fillStyle=char.fillColor ? char.fillColor :"white"; + this._ctx.fillText(char.char,0,0,null,null,null); + }else { + /*__JS__ */this._ctx.strokeStyle=char.borderColor?char.borderColor:'white'; + /*__JS__ */this._ctx.lineWidth=char.lineWidth; + this._ctx.strokeText(char.char,0,0,null,null,0,null); + } + } + this._ctx.restore(); + } + char.borderSize=this.borderSize; + this.completeCreate(); + } + + __proto.onresize=function(w,h){ + this._w=w; + this._h=h; + if ((this._w < AtlasResourceManager.atlasLimitWidth && this._h < AtlasResourceManager.atlasLimitHeight)){ + this._allowMerageInAtlas=true + }else { + this._allowMerageInAtlas=false; + throw new Error("文字尺寸超出大图合集限制!"); + } + } + + __proto.clearAtlasSource=function(){} + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'allowMerageInAtlas',function(){ + return this._allowMerageInAtlas; + }); + + __getset(0,__proto,'atlasSource',function(){ + return this.canvas; + }); + + /** + *是否创建私有Source,通常禁止修改 + *@param value 是否创建 + */ + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'enableMerageInAtlas',function(){ + return this._enableMerageInAtlas; + },function(value){ + this._enableMerageInAtlas=value; + }); + + return WebGLCharImage; + })(Bitmap) + + + //class laya.webgl.resource.WebGLRenderTarget extends laya.resource.Bitmap + var WebGLRenderTarget=(function(_super){ + function WebGLRenderTarget(width,height,surfaceFormat,surfaceType,depthStencilFormat,mipMap,repeat,minFifter,magFifter){ + //this._frameBuffer=null; + //this._depthStencilBuffer=null; + //this._surfaceFormat=0; + //this._surfaceType=0; + //this._depthStencilFormat=0; + //this._mipMap=false; + //this._repeat=false; + //this._minFifter=0; + //this._magFifter=0; + (surfaceFormat===void 0)&& (surfaceFormat=/*laya.webgl.WebGLContext.RGBA*/0x1908); + (surfaceType===void 0)&& (surfaceType=/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401); + (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5); + (mipMap===void 0)&& (mipMap=false); + (repeat===void 0)&& (repeat=false); + (minFifter===void 0)&& (minFifter=-1); + (magFifter===void 0)&& (magFifter=1); + WebGLRenderTarget.__super.call(this); + this._w=width; + this._h=height; + this._surfaceFormat=surfaceFormat; + this._surfaceType=surfaceType; + this._depthStencilFormat=depthStencilFormat; + this._mipMap=mipMap; + this._repeat=repeat; + this._minFifter=minFifter; + this._magFifter=magFifter; + } + + __class(WebGLRenderTarget,'laya.webgl.resource.WebGLRenderTarget',_super); + var __proto=WebGLRenderTarget.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + var gl=WebGL.mainContext; + this._frameBuffer || (this._frameBuffer=gl.createFramebuffer()); + this._source || (this._source=gl.createTexture()); + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,this._w,this._h,0,this._surfaceFormat,this._surfaceType,null); + var minFifter=this._minFifter; + var magFifter=this._magFifter; + var repeat=this._repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPot=Arith.isPOT(this._w,this._h); + if (isPot){ + if (this._mipMap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this._mipMap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer); + gl.framebufferTexture2D(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.COLOR_ATTACHMENT0*/0x8CE0,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source,0); + if (this._depthStencilFormat){ + this._depthStencilBuffer || (this._depthStencilBuffer=gl.createRenderbuffer()); + gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilFormat,this._w,this._h); + switch (this._depthStencilFormat){ + case /*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_ATTACHMENT*/0x8D00,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + case /*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.STENCIL_ATTACHMENT*/0x8D20,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + case /*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_STENCIL_ATTACHMENT*/0x821A,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + } + } + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,null); + this.memorySize=this._w *this._h *4; + this.completeCreate(); + } + + __proto.detoryResource=function(){ + if (this._frameBuffer){ + WebGL.mainContext.deleteTexture(this._source); + WebGL.mainContext.deleteFramebuffer(this._frameBuffer); + WebGL.mainContext.deleteRenderbuffer(this._depthStencilBuffer); + this._source=null; + this._frameBuffer=null; + this._depthStencilBuffer=null; + this.memorySize=0; + } + } + + __getset(0,__proto,'depthStencilBuffer',function(){ + return this._depthStencilBuffer; + }); + + __getset(0,__proto,'frameBuffer',function(){ + return this._frameBuffer; + }); + + return WebGLRenderTarget; + })(Bitmap) + + + //class laya.webgl.resource.WebGLSubImage extends laya.resource.Bitmap + var WebGLSubImage=(function(_super){ + function WebGLSubImage(canvas,offsetX,offsetY,width,height,atlasImage,src,enableMerageInAtlas){ + //this._ctx=null; + //this._allowMerageInAtlas=false; + //this._enableMerageInAtlas=false; + //this.canvas=null; + //this.repeat=false; + //this.mipmap=false; + //this.minFifter=0; + //this.magFifter=0; + //this.atlasImage=null; + this.offsetX=0; + this.offsetY=0; + //this.src=null; + (enableMerageInAtlas===void 0)&& (enableMerageInAtlas=true); + WebGLSubImage.__super.call(this); + this.repeat=true; + this.mipmap=false; + this.minFifter=-1; + this.magFifter=-1; + this.atlasImage=atlasImage; + this.canvas=canvas; + this._ctx=canvas.getContext('2d',undefined); + this._w=width; + this._h=height; + this.offsetX=offsetX; + this.offsetY=offsetY; + this.src=src; + this._enableMerageInAtlas=enableMerageInAtlas; + } + + __class(WebGLSubImage,'laya.webgl.resource.WebGLSubImage',_super); + var __proto=WebGLSubImage.prototype; + Laya.imps(__proto,{"laya.webgl.resource.IMergeAtlasBitmap":true}) + /*override public function copyTo(dec:Bitmap):void { + var d:WebGLSubImage=dec as WebGLSubImage; + super.copyTo(dec); + d._ctx=_ctx; + }*/ + + + __proto.size=function(w,h){ + this._w=w; + this._h=h; + this._ctx && this._ctx.size(w,h); + this.canvas && (this.canvas.height=h,this.canvas.width=w); + } + + + __proto.recreateResource=function(){ + this.startCreate(); + this.size(this._w,this._h); + this._ctx.drawImage(this.atlasImage,this.offsetX,this.offsetY,this._w,this._h,0,0,this._w,this._h); + (!(AtlasResourceManager.enabled && this._allowMerageInAtlas))&& (this.createWebGlTexture()); + this.completeCreate(); + } + + + __proto.createWebGlTexture=function(){ + var gl=WebGL.mainContext; + if (!this.canvas){ + throw "create GLTextur err:no data:"+this.canvas; + }; + + var glTex=this._source=gl.createTexture(); + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this.canvas); + var minFifter=this.minFifter; + var magFifter=this.magFifter; + var repeat=this.repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPOT=Arith.isPOT(this.width,this.height); + if (isPOT){ + if (this.mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this.mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + this.canvas=null; + this.memorySize=this._w *this._h *4; + } + + + __proto.detoryResource=function(){ + if (!(AtlasResourceManager.enabled && this._allowMerageInAtlas)&& this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this.memorySize=0; + } + + } + + + __proto.clearAtlasSource=function(){ + this.canvas=null; + } + + + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'allowMerageInAtlas',function(){ + return this._allowMerageInAtlas; + }); + + + //public var createFromPixel:Boolean=true; + __getset(0,__proto,'atlasSource',function(){ + return this.canvas; + }); + + + /** + *是否创建私有Source,通常禁止修改 + *@param value 是否创建 + */ + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'enableMerageInAtlas',function(){ + return this._allowMerageInAtlas; + },function(value){ + + this._allowMerageInAtlas=value; + }); + + + return WebGLSubImage; + })(Bitmap) + + + //class laya.webgl.shader.d2.Shader2X extends laya.webgl.shader.Shader + var Shader2X=(function(_super){ + function Shader2X(vs,ps,saveName,nameMap){ + this._params2dQuick1=null; + this._params2dQuick2=null; + this._shaderValueWidth=NaN; + this._shaderValueHeight=NaN; + Shader2X.__super.call(this,vs,ps,saveName,nameMap); + } + + __class(Shader2X,'laya.webgl.shader.d2.Shader2X',_super); + var __proto=Shader2X.prototype; + __proto.upload2dQuick1=function(shaderValue){ + this.upload(shaderValue,this._params2dQuick1 || this._make2dQuick1()); + } + + __proto._make2dQuick1=function(){ + if (!this._params2dQuick1){ + this.activeResource(); + this._params2dQuick1=[]; + var params=this._params,one; + for (var i=0,n=params.length;i < n;i++){ + one=params[i]; + if (!Render.isFlash && (one.name==="size" || one.name==="mmat" || one.name==="position" || one.name==="texcoord"))continue ; + this._params2dQuick1.push(one); + } + } + return this._params2dQuick1; + } + + __proto.detoryResource=function(){ + _super.prototype.detoryResource.call(this); + this._params2dQuick1=null; + this._params2dQuick2=null; + } + + __proto.upload2dQuick2=function(shaderValue){ + this.upload(shaderValue,this._params2dQuick2 || this._make2dQuick2()); + } + + __proto._make2dQuick2=function(){ + if (!this._params2dQuick2){ + this.activeResource(); + this._params2dQuick2=[]; + var params=this._params,one; + for (var i=0,n=params.length;i < n;i++){ + one=params[i]; + if (!Render.isFlash && (one.name==="size"))continue ; + this._params2dQuick2.push(one); + } + } + return this._params2dQuick2; + } + + Shader2X.create=function(vs,ps,saveName,nameMap){ + return new Shader2X(vs,ps,saveName,nameMap); + } + + return Shader2X; + })(Shader) + + + //class laya.webgl.utils.Buffer2D extends laya.webgl.utils.Buffer + var Buffer2D=(function(_super){ + function Buffer2D(){ + this._maxsize=0; + this._upload=true; + this._uploadSize=0; + Buffer2D.__super.call(this); + this.lock=true; + } + + __class(Buffer2D,'laya.webgl.utils.Buffer2D',_super); + var __proto=Buffer2D.prototype; + __proto._bufferData=function(){ + this._maxsize=Math.max(this._maxsize,this._byteLength); + if (Stat.loopCount % 30==0){ + if (this._buffer.byteLength > (this._maxsize+64)){ + this.memorySize=this._buffer.byteLength; + this._buffer=this._buffer.slice(0,this._maxsize+64); + this._checkArrayUse(); + } + this._maxsize=this._byteLength; + } + if (this._uploadSize < this._buffer.byteLength){ + this._uploadSize=this._buffer.byteLength; + Buffer._gl.bufferData(this._bufferType,this._uploadSize,this._bufferUsage); + this.memorySize=this._uploadSize; + } + Buffer._gl.bufferSubData(this._bufferType,0,this._buffer); + } + + __proto._bufferSubData=function(offset,dataStart,dataLength){ + (offset===void 0)&& (offset=0); + (dataStart===void 0)&& (dataStart=0); + (dataLength===void 0)&& (dataLength=0); + this._maxsize=Math.max(this._maxsize,this._byteLength); + if (Stat.loopCount % 30==0){ + if (this._buffer.byteLength > (this._maxsize+64)){ + this.memorySize=this._buffer.byteLength; + this._buffer=this._buffer.slice(0,this._maxsize+64); + this._checkArrayUse(); + } + this._maxsize=this._byteLength; + } + if (this._uploadSize < this._buffer.byteLength){ + this._uploadSize=this._buffer.byteLength; + Buffer._gl.bufferData(this._bufferType,this._uploadSize,this._bufferUsage); + this.memorySize=this._uploadSize; + } + if (dataStart || dataLength){ + var subBuffer=this._buffer.slice(dataStart,dataLength); + Buffer._gl.bufferSubData(this._bufferType,offset,subBuffer); + }else { + Buffer._gl.bufferSubData(this._bufferType,offset,this._buffer); + } + } + + __proto._checkArrayUse=function(){} + __proto._bind_upload=function(){ + if (!this._upload) + return false; + this._upload=false; + this._bind(); + this._bufferData(); + return true; + } + + __proto._bind_subUpload=function(offset,dataStart,dataLength){ + (offset===void 0)&& (offset=0); + (dataStart===void 0)&& (dataStart=0); + (dataLength===void 0)&& (dataLength=0); + if (!this._upload) + return false; + this._upload=false; + this._bind(); + this._bufferSubData(offset,dataStart,dataLength); + return true; + } + + __proto._resizeBuffer=function(nsz,copy){ + if (nsz < this._buffer.byteLength) + return this; + this.memorySize=nsz; + if (copy && this._buffer && this._buffer.byteLength > 0){ + var newbuffer=new ArrayBuffer(nsz); + var n=new Uint8Array(newbuffer); + n.set(new Uint8Array(this._buffer),0); + this._buffer=newbuffer; + }else + this._buffer=new ArrayBuffer(nsz); + this._checkArrayUse(); + this._upload=true; + return this; + } + + __proto.append=function(data){ + this._upload=true; + var byteLen=0,n; + byteLen=data.byteLength; + if ((data instanceof Uint8Array)){ + this._resizeBuffer(this._byteLength+byteLen,true); + n=new Uint8Array(this._buffer,this._byteLength); + }else if ((data instanceof Uint16Array)){ + this._resizeBuffer(this._byteLength+byteLen,true); + n=new Uint16Array(this._buffer,this._byteLength); + }else if ((data instanceof Float32Array)){ + this._resizeBuffer(this._byteLength+byteLen,true); + n=new Float32Array(this._buffer,this._byteLength); + } + n.set(data,0); + this._byteLength+=byteLen; + this._checkArrayUse(); + } + + __proto.getBuffer=function(){ + return this._buffer; + } + + __proto.setNeedUpload=function(){ + this._upload=true; + } + + __proto.getNeedUpload=function(){ + return this._upload; + } + + __proto.upload=function(){ + var scuess=this._bind_upload(); + Buffer._gl.bindBuffer(this._bufferType,null); + Buffer._bindActive[this._bufferType]=null; + Shader.activeShader=null + return scuess; + } + + __proto.subUpload=function(offset,dataStart,dataLength){ + (offset===void 0)&& (offset=0); + (dataStart===void 0)&& (dataStart=0); + (dataLength===void 0)&& (dataLength=0); + var scuess=this._bind_subUpload(); + Buffer._gl.bindBuffer(this._bufferType,null); + Buffer._bindActive[this._bufferType]=null; + Shader.activeShader=null + return scuess; + } + + __proto.detoryResource=function(){ + _super.prototype.detoryResource.call(this); + this._upload=true; + this._uploadSize=0; + } + + __proto.clear=function(){ + this._byteLength=0; + this._upload=true; + } + + __getset(0,__proto,'bufferLength',function(){ + return this._buffer.byteLength; + }); + + __getset(0,__proto,'byteLength',_super.prototype._$get_byteLength,function(value){ + if (this._byteLength===value) + return; + value <=this._buffer.byteLength || (this._resizeBuffer(value *2+256,true)); + this._byteLength=value; + }); + + Buffer2D.__int__=function(gl){ + IndexBuffer2D.QuadrangleIB=IndexBuffer2D.create(/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + GlUtils.fillIBQuadrangle(IndexBuffer2D.QuadrangleIB,16); + } + + Buffer2D.FLOAT32=4; + Buffer2D.SHORT=2; + return Buffer2D; + })(Buffer) + + + //class laya.webgl.shader.d2.value.GlowSV extends laya.webgl.shader.d2.value.TextureSV + var GlowSV=(function(_super){ + function GlowSV(args){ + this.u_blurX=false; + this.u_color=null; + this.u_offset=null; + this.u_strength=NaN; + this.u_texW=0; + this.u_texH=0; + GlowSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.FILTERGLOW*/0x08| /*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01); + } + + __class(GlowSV,'laya.webgl.shader.d2.value.GlowSV',_super); + var __proto=GlowSV.prototype; + __proto.setValue=function(vo){ + _super.prototype.setValue.call(this,vo); + } + + __proto.clear=function(){ + _super.prototype.clear.call(this); + } + + return GlowSV; + })(TextureSV) + + + //class laya.webgl.shader.d2.value.TextSV extends laya.webgl.shader.d2.value.TextureSV + var TextSV=(function(_super){ + function TextSV(args){ + TextSV.__super.call(this,/*laya.webgl.shader.d2.ShaderDefines2D.COLORADD*/0x40); + this.defines.add(/*laya.webgl.shader.d2.ShaderDefines2D.COLORADD*/0x40); + } + + __class(TextSV,'laya.webgl.shader.d2.value.TextSV',_super); + var __proto=TextSV.prototype; + __proto.release=function(){ + TextSV.pool[TextSV._length++]=this; + this.clear(); + } + + __proto.clear=function(){ + _super.prototype.clear.call(this); + } + + TextSV.create=function(){ + if (TextSV._length)return TextSV.pool[--TextSV._length]; + else return new TextSV(null); + } + + TextSV.pool=[]; + TextSV._length=0; + return TextSV; + })(TextureSV) + + + //class laya.webgl.utils.IndexBuffer2D extends laya.webgl.utils.Buffer2D + var IndexBuffer2D=(function(_super){ + function IndexBuffer2D(bufferUsage){ + this._uint8Array=null; + this._uint16Array=null; + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + IndexBuffer2D.__super.call(this); + this._bufferUsage=bufferUsage; + this._bufferType=/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893; + Render.isFlash || (this._buffer=new ArrayBuffer(8)); + } + + __class(IndexBuffer2D,'laya.webgl.utils.IndexBuffer2D',_super); + var __proto=IndexBuffer2D.prototype; + __proto._checkArrayUse=function(){ + this._uint8Array && (this._uint8Array=new Uint8Array(this._buffer)); + this._uint16Array && (this._uint16Array=new Uint16Array(this._buffer)); + } + + __proto.getUint8Array=function(){ + return this._uint8Array || (this._uint8Array=new Uint8Array(this._buffer)); + } + + __proto.getUint16Array=function(){ + return this._uint16Array || (this._uint16Array=new Uint16Array(this._buffer)); + } + + IndexBuffer2D.QuadrangleIB=null + IndexBuffer2D.create=function(bufferUsage){ + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + return new IndexBuffer2D(bufferUsage); + } + + return IndexBuffer2D; + })(Buffer2D) + + + //class laya.webgl.utils.VertexBuffer2D extends laya.webgl.utils.Buffer2D + var VertexBuffer2D=(function(_super){ + function VertexBuffer2D(vertexStride,bufferUsage){ + this._floatArray32=null; + this._vertexStride=0; + VertexBuffer2D.__super.call(this); + this._vertexStride=vertexStride; + this._bufferUsage=bufferUsage; + this._bufferType=/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892; + Render.isFlash || (this._buffer=new ArrayBuffer(8)); + this.getFloat32Array(); + } + + __class(VertexBuffer2D,'laya.webgl.utils.VertexBuffer2D',_super); + var __proto=VertexBuffer2D.prototype; + __proto.getFloat32Array=function(){ + return this._floatArray32 || (this._floatArray32=new Float32Array(this._buffer)); + } + + __proto.bind=function(ibBuffer){ + (ibBuffer)&& (ibBuffer._bind()); + this._bind(); + } + + __proto.insertData=function(data,pos){ + var vbdata=this.getFloat32Array(); + vbdata.set(data,pos); + this._upload=true; + } + + __proto.bind_upload=function(ibBuffer){ + (ibBuffer._bind_upload())|| (ibBuffer._bind()); + (this._bind_upload())|| (this._bind()); + } + + __proto._checkArrayUse=function(){ + this._floatArray32 && (this._floatArray32=new Float32Array(this._buffer)); + } + + __proto.detoryResource=function(){ + _super.prototype.detoryResource.call(this); + for (var i=0;i < 10;i++) + WebGL.mainContext.disableVertexAttribArray(i); + } + + __getset(0,__proto,'vertexStride',function(){ + return this._vertexStride; + }); + + VertexBuffer2D.create=function(vertexStride,bufferUsage){ + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + return new VertexBuffer2D(vertexStride,bufferUsage); + } + + return VertexBuffer2D; + })(Buffer2D) + + + //class laya.webgl.resource.WebGLImage extends laya.resource.HTMLImage + var WebGLImage=(function(_super){ + function WebGLImage(src,def){ + this._image=null; + this._allowMerageInAtlas=false; + this._enableMerageInAtlas=false; + this.repeat=false; + this.mipmap=false; + this.minFifter=0; + this.magFifter=0; + WebGLImage.__super.call(this,src,def); + this.repeat=false; + this.mipmap=false; + this.minFifter=-1; + this.magFifter=-1; + this._src=src; + this._image=new Browser.window.Image(); + if (def){ + def.onload && (this.onload=def.onload); + def.onerror && (this.onerror=def.onerror); + def.onCreate && def.onCreate(this); + } + this._image.crossOrigin=(src && (src.indexOf("data:")==0))? null :""; + (src)&& (this._image.src=src); + this._enableMerageInAtlas=true; + } + + __class(WebGLImage,'laya.webgl.resource.WebGLImage',_super); + var __proto=WebGLImage.prototype; + Laya.imps(__proto,{"laya.webgl.resource.IMergeAtlasBitmap":true}) + __proto._init_=function(src,def){} + __proto._createWebGlTexture=function(){ + if (!this._image){ + throw "create GLTextur err:no data:"+this._image; + }; + var gl=WebGL.mainContext; + var glTex=this._source=gl.createTexture(); + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._image); + var minFifter=this.minFifter; + var magFifter=this.magFifter; + var repeat=this.repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPot=Arith.isPOT(this._w,this._h); + if (isPot){ + if (this.mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this.mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + this._image.onload=null; + this._image=null; + if (isPot) + this.memorySize=this._w *this._h *4 *(1+1 / 3); + else + this.memorySize=this._w *this._h *4; + this._recreateLock=false; + } + + /***重新创建资源,如果异步创建中被强制释放再创建,则需等待释放完成后再重新加载创建。*/ + __proto.recreateResource=function(){ + var _$this=this; + if (this._src==null || this._src==="") + return; + this._needReleaseAgain=false; + if (!this._image){ + this._recreateLock=true; + this.startCreate(); + var _this=this; + this._image=new Browser.window.Image(); + this._image.crossOrigin=this._src.indexOf("data:")==0 ? null :""; + this._image.onload=function (){ + if (_this._needReleaseAgain){ + _this._needReleaseAgain=false; + _this._image.onload=null; + _this._image=null; + return; + } + (!(_this._allowMerageInAtlas && _this._enableMerageInAtlas))? (_this._createWebGlTexture()):(_$this.memorySize=0,_$this._recreateLock=false); + _this.completeCreate(); + }; + this._image.src=this._src; + }else { + if (this._recreateLock){ + return; + } + this.startCreate(); + (!(this._allowMerageInAtlas && this._enableMerageInAtlas))? (this._createWebGlTexture()):(this.memorySize=0,this._recreateLock=false); + this.completeCreate(); + } + } + + /***销毁资源*/ + __proto.detoryResource=function(){ + if (this._recreateLock){ + this._needReleaseAgain=true; + } + if (this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this._image=null; + this.memorySize=0; + } + } + + /***调整尺寸*/ + __proto.onresize=function(){ + this._w=this._image.width; + this._h=this._image.height; + (AtlasResourceManager.enabled)&& (this._w < AtlasResourceManager.atlasLimitWidth && this._h < AtlasResourceManager.atlasLimitHeight)? this._allowMerageInAtlas=true :this._allowMerageInAtlas=false; + } + + __proto.clearAtlasSource=function(){ + this._image=null; + } + + /** + *返回HTML Image,as3无internal货friend,通常禁止开发者修改image内的任何属性 + *@param HTML Image + */ + __getset(0,__proto,'image',function(){ + return this._image; + }); + + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'allowMerageInAtlas',function(){ + return this._allowMerageInAtlas; + }); + + __getset(0,__proto,'atlasSource',function(){ + return this._image; + }); + + /** + *是否创建私有Source,通常禁止修改 + *@param value 是否创建 + */ + /** + *是否创建私有Source + *@return 是否创建 + */ + __getset(0,__proto,'enableMerageInAtlas',function(){ + return this._enableMerageInAtlas; + },function(value){ + this._enableMerageInAtlas=value; + }); + + /*** + *设置onload函数 + *@param value onload函数 + */ + __getset(0,__proto,'onload',null,function(value){ + var _$this=this; + this._onload=value; + this._image && (this._image.onload=this._onload !=null ? (function(){ + _$this.onresize(); + _$this._onload(); + }):null); + }); + + /*** + *设置onerror函数 + *@param value onerror函数 + */ + __getset(0,__proto,'onerror',null,function(value){ + var _$this=this; + this._onerror=value; + this._image && (this._image.onerror=this._onerror !=null ? (function(){ + _$this._onerror() + }):null); + }); + + return WebGLImage; + })(HTMLImage) + + + Laya.__init([DrawText,WebGLContext,AtlasGrid,WebGLContext2D,RenderTargetMAX,ShaderCompile]); + new LayaMain(); + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.d3.js b/games/laya-snakes/libs/laya.d3.js new file mode 100644 index 0000000..1149889 --- /dev/null +++ b/games/laya-snakes/libs/laya.d3.js @@ -0,0 +1,21452 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var AnimationPlayer=laya.ani.AnimationPlayer,AnimationState=laya.ani.AnimationState,AnimationTemplet=laya.ani.AnimationTemplet; + var Arith=laya.maths.Arith,Bitmap=laya.resource.Bitmap,Browser=laya.utils.Browser,Buffer=laya.webgl.utils.Buffer; + var Buffer2D=laya.webgl.utils.Buffer2D,Byte=laya.utils.Byte,ClassUtils=laya.utils.ClassUtils,Config=Laya.Config; + var EmitterBase=laya.particle.emitter.EmitterBase,Event=laya.events.Event,EventDispatcher=laya.events.EventDispatcher; + var Handler=laya.utils.Handler,IndexBuffer2D=laya.webgl.utils.IndexBuffer2D,Loader=laya.net.Loader,LoaderManager=laya.net.LoaderManager; + var MathUtil=laya.maths.MathUtil,Node=laya.display.Node,ParticleSetting=laya.particle.ParticleSetting,ParticleShader=laya.particle.shader.ParticleShader; + var ParticleTemplateWebGL=laya.particle.ParticleTemplateWebGL,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render; + var RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite,RenderState2D=laya.webgl.utils.RenderState2D; + var Resource=laya.resource.Resource,RunDriver=laya.utils.RunDriver,Shader=laya.webgl.shader.Shader,ShaderDefines=laya.webgl.shader.ShaderDefines; + var Sprite=laya.display.Sprite,Stat=laya.utils.Stat,URL=laya.net.URL,ValusArray=laya.webgl.utils.ValusArray; + var VertexBuffer2D=laya.webgl.utils.VertexBuffer2D,WebGL=laya.webgl.WebGL,WebGLContext=laya.webgl.WebGLContext; + var WebGLContext2D=laya.webgl.canvas.WebGLContext2D,WebGLImage=laya.webgl.resource.WebGLImage; + Laya.interface('laya.d3.core.IClone'); + Laya.interface('laya.d3.graphics.IVertex'); + Laya.interface('laya.d3.core.render.IUpdate'); + Laya.interface('laya.d3.core.render.IRenderable'); + /** + *SplineCurvePositionVelocity 类用于通过顶点和速度创建闪光插值。 + */ + //class laya.d3.core.glitter.SplineCurvePositionVelocity + var SplineCurvePositionVelocity=(function(){ + function SplineCurvePositionVelocity(){ + this._tempVector30=new Vector3(); + this._tempVector31=new Vector3(); + this._tempVector32=new Vector3(); + this._a=new Vector3(); + this._b=new Vector3(); + this._c=new Vector3(); + this._d=new Vector3(); + } + + __class(SplineCurvePositionVelocity,'laya.d3.core.glitter.SplineCurvePositionVelocity'); + var __proto=SplineCurvePositionVelocity.prototype; + /** + *初始化插值所需信息。 + *@param position0 顶点0的位置。 + *@param velocity0 顶点0的速度。 + *@param position1 顶点1的位置。 + *@param velocity1 顶点1的速度。 + */ + __proto.Init=function(position0,velocity0,position1,velocity1){ + position0.cloneTo(this._d); + velocity0.cloneTo(this._c); + Vector3.scale(position0,2.0,this._a); + Vector3.scale(position1,2.0,this._tempVector30); + Vector3.subtract(this._a,this._tempVector30,this._a); + Vector3.add(this._a,velocity0,this._a); + Vector3.add(this._a,velocity1,this._a); + Vector3.scale(position1,3.0,this._b); + Vector3.scale(position0,3.0,this._tempVector30); + Vector3.subtract(this._b,this._tempVector30,this._b); + Vector3.subtract(this._b,velocity1,this._b); + Vector3.scale(velocity0,2.0,this._tempVector30); + Vector3.subtract(this._b,this._tempVector30,this._b); + } + + /** + *初始化插值所需信息。 + *@param t 插值比例 + *@param out 输出结果 + */ + __proto.Slerp=function(t,out){ + Vector3.scale(this._a,t *t *t,this._tempVector30); + Vector3.scale(this._b,t *t,this._tempVector31); + Vector3.scale(this._c,t,this._tempVector32); + Vector3.add(this._tempVector30,this._tempVector31,out); + Vector3.add(out,this._tempVector32,out); + Vector3.add(out,this._d,out); + } + + return SplineCurvePositionVelocity; + })() + + + /** + *HeightMap 类用于实现高度图数据。 + */ + //class laya.d3.core.HeightMap + var HeightMap=(function(){ + function HeightMap(width,height,minHeight,maxHeight){ + this._datas=null; + this._w=0; + this._h=0; + this._minHeight=NaN; + this._maxHeight=NaN; + this._datas=[]; + this._w=width; + this._h=height; + this._minHeight=minHeight; + this._maxHeight=maxHeight; + } + + __class(HeightMap,'laya.d3.core.HeightMap'); + var __proto=HeightMap.prototype; + /**@private */ + __proto._inBounds=function(row,col){ + return row >=0 && row < this._h && col >=0 && col < this._w; + } + + /** + *获取高度。 + *@param row 列数。 + *@param col 行数。 + *@return 高度。 + */ + __proto.getHeight=function(row,col){ + if (this._inBounds(row,col)) + return this._datas[row][col]; + else + return NaN; + } + + /** + *获取宽度。 + *@return value 宽度。 + */ + __getset(0,__proto,'width',function(){ + return this._w; + }); + + /** + *获取高度。 + *@return value 高度。 + */ + __getset(0,__proto,'height',function(){ + return this._h; + }); + + /** + *最大高度。 + *@return value 最大高度。 + */ + __getset(0,__proto,'maxHeight',function(){ + return this._maxHeight; + }); + + /** + *最大高度。 + *@return value 最大高度。 + */ + __getset(0,__proto,'minHeight',function(){ + return this._minHeight; + }); + + HeightMap.creatFromMesh=function(mesh,width,height,outCellSize){ + var vertices=[]; + var indexs=[]; + var submesheCount=mesh.getSubMeshCount(); + for (var i=0;i < submesheCount;i++){ + var subMesh=mesh.getSubMesh(i); + var vertexBuffer=subMesh._getVertexBuffer(); + var verts=vertexBuffer.getData(); + var subMeshVertices=[]; + for (var j=0;j < verts.length;j+=vertexBuffer.vertexDeclaration.vertexStride / 4){ + var position=new Vector3(verts[j+0],verts[j+1],verts[j+2]); + subMeshVertices.push(position); + } + vertices.push(subMeshVertices); + var ib=subMesh._getIndexBuffer(); + indexs.push(ib.getData()); + }; + var boundingBox=mesh.boundingBox; + var minX=boundingBox.min.x; + var minZ=boundingBox.min.z; + var maxX=boundingBox.max.x; + var maxZ=boundingBox.max.z; + var minY=boundingBox.min.y; + var maxY=boundingBox.max.y; + var widthSize=maxX-minX; + var heightSize=maxZ-minZ; + var cellWidth=outCellSize.elements[0]=widthSize / (width-1); + var cellHeight=outCellSize.elements[1]=heightSize / (height-1); + var heightMap=new HeightMap(width,height,minY,maxY); + var ray=HeightMap._tempRay; + var rayDirE=ray.direction.elements; + rayDirE[0]=0; + rayDirE[1]=-1; + rayDirE[2]=0; + var heightOffset=0.1; + var rayY=maxY+heightOffset; + ray.origin.elements[1]=rayY; + for (var w=0;w < width;w++){ + var posZ=minZ+w *cellHeight; + heightMap._datas[w]=[]; + for (var h=0;h < height;h++){ + var posX=minX+h *cellWidth; + var rayOriE=ray.origin.elements; + rayOriE[0]=posX; + rayOriE[2]=posZ; + var closestIntersection=HeightMap._getPosition(ray,vertices,indexs); + heightMap._datas[w][h]=(closestIntersection===Number.MAX_VALUE)? NaN :rayY-closestIntersection; + } + } + return heightMap; + } + + HeightMap.createFromImage=function(texture,minHeight,maxHeight){ + var textureWidth=texture.width; + var textureHeight=texture.height; + var heightMap=new HeightMap(textureWidth,textureHeight,minHeight,maxHeight); + var compressionRatio=(maxHeight-minHeight)/ 254; + Browser.canvas.size(textureWidth,textureHeight); + Browser.context.drawImage(texture._image,0,0,textureWidth,textureHeight); + var pixelsInfo=Browser.context.getImageData(0,0,textureWidth,textureHeight).data; + var index=0; + for (var w=0;w < textureWidth;w++){ + var colDatas=heightMap._datas[w]=[]; + for (var h=0;h < textureHeight;h++){ + var r=pixelsInfo[index++]; + var g=pixelsInfo[index++]; + var b=pixelsInfo[index++]; + var a=pixelsInfo[index++]; + if (r==255 && g==255 && b==255 && a==255) + colDatas[h]=NaN; + else { + colDatas[h]=(r+g+b)/ 3 *compressionRatio+minHeight; + } + } + } + return heightMap; + } + + HeightMap._getPosition=function(ray,vertices,indexs){ + var closestIntersection=Number.MAX_VALUE; + for (var i=0;i < vertices.length;i++){ + var subMeshVertices=vertices[i]; + var subMeshIndexes=indexs[i]; + for (var j=0;j < subMeshIndexes.length;j+=3){ + var vertex1=subMeshVertices[subMeshIndexes[j+0]]; + var vertex2=subMeshVertices[subMeshIndexes[j+1]]; + var vertex3=subMeshVertices[subMeshIndexes[j+2]]; + var intersection=Picker.rayIntersectsTriangle(ray,vertex1,vertex2,vertex3); + if (!isNaN(intersection)&& intersection < closestIntersection){ + closestIntersection=intersection; + } + } + } + return closestIntersection; + } + + __static(HeightMap, + ['_tempRay',function(){return this._tempRay=new Ray(new Vector3(),new Vector3());} + ]); + return HeightMap; + })() + + + /** + *Layer 类用于实现遮罩层。 + */ + //class laya.d3.core.Layer + var Layer=(function(){ + function Layer(){ + this._id=0; + this._number=0; + this._mask=0; + this._active=true; + this._visible=true; + this.name=null; + this._id=Layer._uniqueIDCounter; + Layer._uniqueIDCounter++; + if (this._id > 1+31) + throw new Error("不允许创建Layer,请参考函数getLayerByNumber、getLayerByMask、getLayerByName!"); + } + + __class(Layer,'laya.d3.core.Layer'); + var __proto=Layer.prototype; + /** + *获取编号。 + *@return 编号。 + */ + __getset(0,__proto,'number',function(){ + return this._number; + }); + + /** + *设置是否显示。 + *@param value 是否显示。 + */ + /** + *获取是否显示。 + *@return 是否显示。 + */ + __getset(0,__proto,'visible',function(){ + return this._visible; + },function(value){ + if (this._number===29 || this._number==30) + return; + this._visible=value; + if (value) + Layer._visibleLayers=Layer._visibleLayers | this.mask; + else + Layer._visibleLayers=Layer._visibleLayers & ~this.mask; + }); + + /** + *获取蒙版值。 + *@return 蒙版值。 + */ + __getset(0,__proto,'mask',function(){ + return this._mask; + }); + + /** + *设置是否激活。 + *@param value 是否激活。 + */ + /** + *获取是否激活。 + *@return 是否激活。 + */ + __getset(0,__proto,'active',function(){ + return this._active; + },function(value){ + if (this._number===29 || this._number==30) + return; + this._active=value; + if (value) + Layer._activeLayers=Layer._activeLayers | this.mask; + else + Layer._activeLayers=Layer._activeLayers & ~this.mask; + }); + + /** + *设置Layer激活层。 + *@param value 激活层。 + */ + /** + *获取Layer激活层。 + *@return 激活层。 + */ + __getset(1,Layer,'activeLayers',function(){ + return Layer._activeLayers; + },function(value){ + Layer._activeLayers=value | Layer.getLayerByNumber(29).mask | Layer.getLayerByNumber(30).mask; + for (var i=0;i < Layer._layerList.length;i++){ + var layer=Layer._layerList[i]; + layer._active=(layer._mask & Layer._activeLayers)!==0; + } + }); + + /** + *设置Layer显示层。 + *@param value 显示层。 + */ + /** + *获取Layer显示层。 + *@return 显示层。 + */ + __getset(1,Layer,'visibleLayers',function(){ + return Layer._visibleLayers; + },function(value){ + Layer._visibleLayers=value | Layer.getLayerByNumber(29).mask | Layer.getLayerByNumber(30).mask; + for (var i=0;i < Layer._layerList.length;i++){ + var layer=Layer._layerList[i]; + layer._visible=(layer._mask & Layer._visibleLayers)!==0; + } + }); + + Layer.__init__=function(){ + Layer._layerList.length=31; + for (var i=0;i < 31;i++){ + var layer=new Layer(); + Layer._layerList[i]=layer; + if (i===0) + layer.name="Default Layer"; + else if (i===29) + layer.name="Reserved Layer0"; + else if (i===30) + layer.name="Reserved Layer1"; + else + layer.name="Layer-"+i; + layer._number=i; + layer._mask=Math.pow(2,i); + } + Layer._activeLayers=2147483647; + Layer._visibleLayers=2147483647; + Layer._currentCameraCullingMask=2147483647; + Layer.currentCreationLayer=Layer._layerList[0]; + } + + Layer.getLayerByNumber=function(number){ + if (number < 0 || number > 30) + throw new Error("无法返回指定Layer,该number超出范围!"); + return Layer._layerList[number]; + } + + Layer.getLayerByMask=function(mask){ + for (var i=0;i < 31;i++){ + if (Layer._layerList[i].mask===mask) + return Layer._layerList[i]; + } + throw new Error("无法返回指定Layer,该mask不存在"); + } + + Layer.getLayerByName=function(name){ + for (var i=0;i < 31;i++){ + if (Layer._layerList[i].name===name) + return Layer._layerList[i]; + } + throw new Error("无法返回指定Layer,该name不存在"); + } + + Layer.isActive=function(mask){ + return (mask & Layer._activeLayers)!=0; + } + + Layer.isVisible=function(mask){ + return (mask & Layer._currentCameraCullingMask & Layer._visibleLayers)!=0; + } + + Layer._uniqueIDCounter=1; + Layer._layerCount=31; + Layer._layerList=[]; + Layer._activeLayers=0; + Layer._visibleLayers=0; + Layer._currentCameraCullingMask=0; + Layer.currentCreationLayer=null + return Layer; + })() + + + /** + *Burst 类用于粒子的爆裂描述。 + */ + //class laya.d3.core.particleShuriKen.module.Burst + var Burst=(function(){ + function Burst(time,minCount,maxCount){ + this._time=NaN; + this._minCount=0; + this._maxCount=0; + this._time=time; + this._minCount=minCount; + this._maxCount=maxCount; + } + + __class(Burst,'laya.d3.core.particleShuriKen.module.Burst'); + var __proto=Burst.prototype; + /** + *获取爆裂时间,单位为秒。 + *@return 爆裂时间,单位为秒。 + */ + __getset(0,__proto,'time',function(){ + return this._time; + }); + + /** + *获取爆裂的最小数量。 + *@return 爆裂的最小数量。 + */ + __getset(0,__proto,'minCount',function(){ + return this._minCount; + }); + + /** + *获取爆裂的最大数量。 + *@return 爆裂的最大数量。 + */ + __getset(0,__proto,'maxCount',function(){ + return this._maxCount; + }); + + return Burst; + })() + + + /** + *ColorOverLifetime 类用于粒子的生命周期颜色。 + */ + //class laya.d3.core.particleShuriKen.module.ColorOverLifetime + var ColorOverLifetime=(function(){ + function ColorOverLifetime(color){ + this._color=null; + this.enbale=false; + this._color=color; + } + + __class(ColorOverLifetime,'laya.d3.core.particleShuriKen.module.ColorOverLifetime'); + var __proto=ColorOverLifetime.prototype; + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destColorOverLifetime=destObject; + this._color.cloneTo(destColorOverLifetime._color); + destColorOverLifetime.enbale=this.enbale; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destColorOverLifetime=/*__JS__ */new this.constructor(); + this.cloneTo(destColorOverLifetime); + return destColorOverLifetime; + } + + /** + *获取颜色。 + */ + __getset(0,__proto,'color',function(){ + return this._color; + }); + + return ColorOverLifetime; + })() + + + /** + *FrameOverTime 类用于创建时间帧。 + */ + //class laya.d3.core.particleShuriKen.module.FrameOverTime + var FrameOverTime=(function(){ + function FrameOverTime(){ + this._type=0; + this._constant=0; + this._overTime=null; + this._constantMin=0; + this._constantMax=0; + this._overTimeMin=null; + this._overTimeMax=null; + } + + __class(FrameOverTime,'laya.d3.core.particleShuriKen.module.FrameOverTime'); + var __proto=FrameOverTime.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destFrameOverTime=destObject; + destFrameOverTime._type=this._type; + destFrameOverTime._constant=this._constant; + this._overTime.cloneTo(destFrameOverTime._overTime); + destFrameOverTime._constantMin=this._constantMin; + destFrameOverTime._constantMax=this._constantMax; + this._overTimeMin.cloneTo(destFrameOverTime._overTimeMin); + this._overTimeMax.cloneTo(destFrameOverTime._overTimeMax); + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destFrameOverTime=/*__JS__ */new this.constructor(); + this.cloneTo(destFrameOverTime); + return destFrameOverTime; + } + + /** + *时间帧。 + */ + __getset(0,__proto,'frameOverTimeData',function(){ + return this._overTime; + }); + + /** + *固定帧。 + */ + __getset(0,__proto,'constant',function(){ + return this._constant; + }); + + /** + *生命周期旋转类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *最小时间帧。 + */ + __getset(0,__proto,'frameOverTimeDataMin',function(){ + return this._overTimeMin; + }); + + /** + *最小固定帧。 + */ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *最大时间帧。 + */ + __getset(0,__proto,'frameOverTimeDataMax',function(){ + return this._overTimeMax; + }); + + /** + *最大固定帧。 + */ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + FrameOverTime.createByConstant=function(constant){ + var rotationOverLifetime=new FrameOverTime(); + rotationOverLifetime._type=0; + rotationOverLifetime._constant=constant; + return rotationOverLifetime; + } + + FrameOverTime.createByOverTime=function(overTime){ + var rotationOverLifetime=new FrameOverTime(); + rotationOverLifetime._type=1; + rotationOverLifetime._overTime=overTime; + return rotationOverLifetime; + } + + FrameOverTime.createByRandomTwoConstant=function(constantMin,constantMax){ + var rotationOverLifetime=new FrameOverTime(); + rotationOverLifetime._type=2; + rotationOverLifetime._constantMin=constantMin; + rotationOverLifetime._constantMax=constantMax; + return rotationOverLifetime; + } + + FrameOverTime.createByRandomTwoOverTime=function(gradientFrameMin,gradientFrameMax){ + var rotationOverLifetime=new FrameOverTime(); + rotationOverLifetime._type=3; + rotationOverLifetime._overTimeMin=gradientFrameMin; + rotationOverLifetime._overTimeMax=gradientFrameMax; + return rotationOverLifetime; + } + + return FrameOverTime; + })() + + + /** + *GradientRotation 类用于创建渐变角速度。 + */ + //class laya.d3.core.particleShuriKen.module.GradientAngularVelocity + var GradientAngularVelocity=(function(){ + function GradientAngularVelocity(){ + this._type=0; + this._separateAxes=false; + this._constant=NaN; + this._constantSeparate=null; + this._gradient=null; + this._gradientX=null; + this._gradientY=null; + this._gradientZ=null; + this._constantMin=NaN; + this._constantMax=NaN; + this._constantMinSeparate=null; + this._constantMaxSeparate=null; + this._gradientMin=null; + this._gradientMax=null; + this._gradientXMin=null; + this._gradientXMax=null; + this._gradientYMin=null; + this._gradientYMax=null; + this._gradientZMin=null; + this._gradientZMax=null; + } + + __class(GradientAngularVelocity,'laya.d3.core.particleShuriKen.module.GradientAngularVelocity'); + var __proto=GradientAngularVelocity.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientAngularVelocity=destObject; + destGradientAngularVelocity._type=this._type; + destGradientAngularVelocity._separateAxes=this._separateAxes; + destGradientAngularVelocity._constant=this._constant; + this._constantSeparate.cloneTo(destGradientAngularVelocity._constantSeparate); + this._gradient.cloneTo(destGradientAngularVelocity._gradient); + this._gradientX.cloneTo(destGradientAngularVelocity._gradientX); + this._gradientY.cloneTo(destGradientAngularVelocity._gradientY); + this._gradientZ.cloneTo(destGradientAngularVelocity._gradientZ); + destGradientAngularVelocity._constantMin=this._constantMin; + destGradientAngularVelocity._constantMax=this._constantMax; + this._constantMinSeparate.cloneTo(destGradientAngularVelocity._constantMinSeparate); + this._constantMaxSeparate.cloneTo(destGradientAngularVelocity._constantMaxSeparate); + this._gradientMin.cloneTo(destGradientAngularVelocity._gradientMin); + this._gradientMax.cloneTo(destGradientAngularVelocity._gradientMax); + this._gradientXMin.cloneTo(destGradientAngularVelocity._gradientXMin); + this._gradientXMax.cloneTo(destGradientAngularVelocity._gradientXMax); + this._gradientYMin.cloneTo(destGradientAngularVelocity._gradientYMin); + this._gradientYMax.cloneTo(destGradientAngularVelocity._gradientYMax); + this._gradientZMin.cloneTo(destGradientAngularVelocity._gradientZMin); + this._gradientZMax.cloneTo(destGradientAngularVelocity._gradientZMax); + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientAngularVelocity=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientAngularVelocity); + return destGradientAngularVelocity; + } + + /** + *渐变角速度Z。 + */ + __getset(0,__proto,'gradientZ',function(){ + return this._gradientZ; + }); + + /** + *固定角速度。 + */ + __getset(0,__proto,'constant',function(){ + return this._constant; + }); + + /** + *渐变角速度。 + */ + __getset(0,__proto,'gradient',function(){ + return this._gradient; + }); + + /** + *是否分轴。 + */ + __getset(0,__proto,'separateAxes',function(){ + return this._separateAxes; + }); + + /** + *生命周期角速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *分轴固定角速度。 + */ + __getset(0,__proto,'constantSeparate',function(){ + return this._constantSeparate; + }); + + /** + *最小渐变角速度。 + */ + __getset(0,__proto,'gradientMin',function(){ + return this._gradientMin; + }); + + /** + *最小随机双固定角速度。 + */ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *渐变角角速度X。 + */ + __getset(0,__proto,'gradientX',function(){ + return this._gradientX; + }); + + /** + *渐变角速度Y。 + */ + __getset(0,__proto,'gradientY',function(){ + return this._gradientY; + }); + + /** + *最大渐变角速度。 + */ + __getset(0,__proto,'gradientMax',function(){ + return this._gradientMax; + }); + + /** + *最大随机双固定角速度。 + */ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + /** + *最小分轴随机双固定角速度。 + */ + __getset(0,__proto,'constantMinSeparate',function(){ + return this._constantMinSeparate; + }); + + /** + *最大分轴随机双固定角速度。 + */ + __getset(0,__proto,'constantMaxSeparate',function(){ + return this._constantMaxSeparate; + }); + + /** + *最小渐变角速度X。 + */ + __getset(0,__proto,'gradientXMin',function(){ + return this._gradientXMin; + }); + + /** + *最大渐变角速度X。 + */ + __getset(0,__proto,'gradientXMax',function(){ + return this._gradientXMax; + }); + + /** + *最小渐变角速度Y。 + */ + __getset(0,__proto,'gradientYMin',function(){ + return this._gradientYMin; + }); + + /** + *最大渐变角速度Y。 + */ + __getset(0,__proto,'gradientYMax',function(){ + return this._gradientYMax; + }); + + /** + *最小渐变角速度Z。 + */ + __getset(0,__proto,'gradientZMin',function(){ + return this._gradientZMin; + }); + + /** + *最大渐变角速度Z。 + */ + __getset(0,__proto,'gradientZMax',function(){ + return this._gradientZMax; + }); + + GradientAngularVelocity.createByConstant=function(constant){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=0; + gradientAngularVelocity._separateAxes=false; + gradientAngularVelocity._constant=constant; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByConstantSeparate=function(separateConstant){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=0; + gradientAngularVelocity._separateAxes=true; + gradientAngularVelocity._constantSeparate=separateConstant; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByGradient=function(gradient){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=1; + gradientAngularVelocity._separateAxes=false; + gradientAngularVelocity._gradient=gradient; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByGradientSeparate=function(gradientX,gradientY,gradientZ){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=1; + gradientAngularVelocity._separateAxes=true; + gradientAngularVelocity._gradientX=gradientX; + gradientAngularVelocity._gradientY=gradientY; + gradientAngularVelocity._gradientZ=gradientZ; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByRandomTwoConstant=function(constantMin,constantMax){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=2; + gradientAngularVelocity._separateAxes=false; + gradientAngularVelocity._constantMin=constantMin; + gradientAngularVelocity._constantMax=constantMax; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByRandomTwoConstantSeparate=function(separateConstantMin,separateConstantMax){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=2; + gradientAngularVelocity._separateAxes=true; + gradientAngularVelocity._constantMinSeparate=separateConstantMin; + gradientAngularVelocity._constantMaxSeparate=separateConstantMax; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByRandomTwoGradient=function(gradientMin,gradientMax){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=3; + gradientAngularVelocity._separateAxes=false; + gradientAngularVelocity._gradientMin=gradientMin; + gradientAngularVelocity._gradientMax=gradientMax; + return gradientAngularVelocity; + } + + GradientAngularVelocity.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){ + var gradientAngularVelocity=new GradientAngularVelocity(); + gradientAngularVelocity._type=3; + gradientAngularVelocity._separateAxes=true; + gradientAngularVelocity._gradientXMin=gradientXMin; + gradientAngularVelocity._gradientXMax=gradientXMax; + gradientAngularVelocity._gradientYMin=gradientYMin; + gradientAngularVelocity._gradientYMax=gradientYMax; + gradientAngularVelocity._gradientZMin=gradientZMin; + gradientAngularVelocity._gradientZMax=gradientZMax; + return gradientAngularVelocity; + } + + return GradientAngularVelocity; + })() + + + /** + *GradientColor 类用于创建渐变颜色。 + */ + //class laya.d3.core.particleShuriKen.module.GradientColor + var GradientColor=(function(){ + function GradientColor(){ + this._type=0; + this._constant=null; + this._constantMin=null; + this._constantMax=null; + this._gradient=null; + this._gradientMin=null; + this._gradientMax=null; + } + + __class(GradientColor,'laya.d3.core.particleShuriKen.module.GradientColor'); + var __proto=GradientColor.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientColor=destObject; + destGradientColor._type=this._type; + this._constant.cloneTo(destGradientColor._constant); + this._constantMin.cloneTo(destGradientColor._constantMin); + this._constantMax.cloneTo(destGradientColor._constantMax); + this._gradient.cloneTo(destGradientColor._gradient); + this._gradientMin.cloneTo(destGradientColor._gradientMin); + this._gradientMax.cloneTo(destGradientColor._gradientMax); + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientColor=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientColor); + return destGradientColor; + } + + /** + *渐变颜色。 + */ + __getset(0,__proto,'gradient',function(){ + return this._gradient; + }); + + /** + *固定颜色。 + */ + __getset(0,__proto,'constant',function(){ + return this._constant; + }); + + /** + *生命周期颜色类型,0为固定颜色模式,1渐变模式,2为随机双固定颜色模式,3随机双渐变模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *最小渐变颜色。 + */ + __getset(0,__proto,'gradientMin',function(){ + return this._gradientMin; + }); + + /** + *最小固定颜色。 + */ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *最大渐变颜色。 + */ + __getset(0,__proto,'gradientMax',function(){ + return this._gradientMax; + }); + + /** + *最大固定颜色。 + */ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + GradientColor.createByConstant=function(constant){ + var gradientColor=new GradientColor(); + gradientColor._type=0; + gradientColor._constant=constant; + return gradientColor; + } + + GradientColor.createByGradient=function(gradient){ + var gradientColor=new GradientColor(); + gradientColor._type=1; + gradientColor._gradient=gradient; + return gradientColor; + } + + GradientColor.createByRandomTwoConstant=function(minConstant,maxConstant){ + var gradientColor=new GradientColor(); + gradientColor._type=2; + gradientColor._constantMin=minConstant; + gradientColor._constantMax=maxConstant; + return gradientColor; + } + + GradientColor.createByRandomTwoGradient=function(minGradient,maxGradient){ + var gradientColor=new GradientColor(); + gradientColor._type=3; + gradientColor._gradientMin=minGradient; + gradientColor._gradientMax=maxGradient; + return gradientColor; + } + + return GradientColor; + })() + + + /** + *GradientDataColor 类用于创建颜色渐变。 + */ + //class laya.d3.core.particleShuriKen.module.GradientDataColor + var GradientDataColor=(function(){ + function GradientDataColor(){ + this._alphaCurrentLength=0; + this._rgbCurrentLength=0; + this._alphaElements=null; + this._rgbElements=null; + this._alphaElements=new Float32Array(8); + this._rgbElements=new Float32Array(16); + } + + __class(GradientDataColor,'laya.d3.core.particleShuriKen.module.GradientDataColor'); + var __proto=GradientDataColor.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *增加Alpha渐变。 + *@param key 生命周期,范围为0到1。 + *@param value rgb值。 + */ + __proto.addAlpha=function(key,value){ + if (this._alphaCurrentLength < 8){ + this._alphaElements[this._alphaCurrentLength++]=key; + this._alphaElements[this._alphaCurrentLength++]=value; + }else { + throw new Error("GradientDataColor:Alpha count must less than 4."); + } + } + + /** + *增加RGB渐变。 + *@param key 生命周期,范围为0到1。 + *@param value RGB值。 + */ + __proto.addRGB=function(key,value){ + if (this._rgbCurrentLength < 16){ + this._rgbElements[this._rgbCurrentLength++]=key; + this._rgbElements[this._rgbCurrentLength++]=value.x; + this._rgbElements[this._rgbCurrentLength++]=value.y; + this._rgbElements[this._rgbCurrentLength++]=value.z; + }else { + throw new Error("GradientDataColor:RGB count must less than 4."); + } + } + + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientDataColor=destObject; + var i=0,n=0; + destGradientDataColor._alphaCurrentLength=this._alphaCurrentLength; + var destAlphaElements=destGradientDataColor._alphaElements; + destAlphaElements.length=this._alphaElements.length; + for (i=0,n=this._alphaElements.length;i < n;i++) + destAlphaElements[i]=this._alphaElements[i]; + destGradientDataColor._rgbCurrentLength=this._rgbCurrentLength; + var destRGBElements=destGradientDataColor._rgbElements; + destRGBElements.length=this._rgbElements.length; + for (i=0,n=this._rgbElements.length;i < n;i++) + destRGBElements[i]=this._rgbElements[i]; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientDataColor=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientDataColor); + return destGradientDataColor; + } + + /**渐变Alpha数量。*/ + __getset(0,__proto,'alphaGradientCount',function(){ + return this._alphaCurrentLength / 2; + }); + + /**渐变RGB数量。*/ + __getset(0,__proto,'rgbGradientCount',function(){ + return this._rgbCurrentLength / 4; + }); + + return GradientDataColor; + })() + + + /** + *GradientDataInt 类用于创建整形渐变。 + */ + //class laya.d3.core.particleShuriKen.module.GradientDataInt + var GradientDataInt=(function(){ + function GradientDataInt(){ + this._currentLength=0; + this._elements=null; + this._elements=new Float32Array(8); + } + + __class(GradientDataInt,'laya.d3.core.particleShuriKen.module.GradientDataInt'); + var __proto=GradientDataInt.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *增加整形渐变。 + *@param key 生命周期,范围为0到1。 + *@param value 整形值。 + */ + __proto.add=function(key,value){ + if (this._currentLength < 8){ + this._elements[this._currentLength++]=key; + this._elements[this._currentLength++]=value; + }else { + throw new Error("GradientDataInt: Count must less than 4."); + } + } + + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientDataInt=destObject; + destGradientDataInt._currentLength=this._currentLength; + var destElements=destGradientDataInt._elements; + destElements.length=this._elements.length; + for (var i=0,n=this._elements.length;i < n;i++){ + destElements[i]=this._elements[i]; + } + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientDataInt=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientDataInt); + return destGradientDataInt; + } + + /**整形渐变数量。*/ + __getset(0,__proto,'gradientCount',function(){ + return this._currentLength / 2; + }); + + return GradientDataInt; + })() + + + /** + *GradientDataNumber 类用于创建浮点渐变。 + */ + //class laya.d3.core.particleShuriKen.module.GradientDataNumber + var GradientDataNumber=(function(){ + function GradientDataNumber(){ + this._currentLength=0; + this._elements=null; + this._elements=new Float32Array(8); + } + + __class(GradientDataNumber,'laya.d3.core.particleShuriKen.module.GradientDataNumber'); + var __proto=GradientDataNumber.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *增加浮点渐变。 + *@param key 生命周期,范围为0到1。 + *@param value 浮点值。 + */ + __proto.add=function(key,value){ + if (this._currentLength < 8){ + this._elements[this._currentLength++]=key; + this._elements[this._currentLength++]=value; + }else { + throw new Error("GradientDataNumber: Count must less than 4."); + } + } + + /** + *通过索引获取键。 + *@param index 索引。 + *@return value 键。 + */ + __proto.getKeyByIndex=function(index){ + return this._elements[index *2]; + } + + /** + *通过索引获取值。 + *@param index 索引。 + *@return value 值。 + */ + __proto.getValueByIndex=function(index){ + return this._elements[index *2+1]; + } + + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientDataNumber=destObject; + destGradientDataNumber._currentLength=this._currentLength; + var destElements=destGradientDataNumber._elements; + destElements.length=this._elements.length; + for (var i=0,n=this._elements.length;i < n;i++) + destElements[i]=this._elements[i]; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientDataNumber=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientDataNumber); + return destGradientDataNumber; + } + + /**渐变浮点数量。*/ + __getset(0,__proto,'gradientCount',function(){ + return this._currentLength / 2; + }); + + return GradientDataNumber; + })() + + + /** + *GradientDataVector2 类用于创建二维向量渐变。 + */ + //class laya.d3.core.particleShuriKen.module.GradientDataVector2 + var GradientDataVector2=(function(){ + function GradientDataVector2(){ + this._currentLength=0; + this._elements=null; + this._elements=new Float32Array(12); + } + + __class(GradientDataVector2,'laya.d3.core.particleShuriKen.module.GradientDataVector2'); + var __proto=GradientDataVector2.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *增加二维向量渐变。 + *@param key 生命周期,范围为0到1。 + *@param value 二维向量值。 + */ + __proto.add=function(key,value){ + if (this._currentLength < 8){ + this._elements[this._currentLength++]=key; + this._elements[this._currentLength++]=value.x; + this._elements[this._currentLength++]=value.y; + }else { + throw new Error("GradientDataVector2: Count must less than 4."); + } + } + + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientDataVector2=destObject; + destGradientDataVector2._currentLength=this._currentLength; + var destElements=destGradientDataVector2._elements; + destElements.length=this._elements.length; + for (var i=0,n=this._elements.length;i < n;i++){ + destElements[i]=this._elements[i]; + } + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientDataVector2=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientDataVector2); + return destGradientDataVector2; + } + + /**二维向量渐变数量。*/ + __getset(0,__proto,'gradientCount',function(){ + return this._currentLength / 3; + }); + + return GradientDataVector2; + })() + + + /** + *GradientSize 类用于创建渐变尺寸。 + */ + //class laya.d3.core.particleShuriKen.module.GradientSize + var GradientSize=(function(){ + function GradientSize(){ + this._type=0; + this._separateAxes=false; + this._gradient=null; + this._gradientX=null; + this._gradientY=null; + this._gradientZ=null; + this._constantMin=NaN; + this._constantMax=NaN; + this._constantMinSeparate=null; + this._constantMaxSeparate=null; + this._gradientMin=null; + this._gradientMax=null; + this._gradientXMin=null; + this._gradientXMax=null; + this._gradientYMin=null; + this._gradientYMax=null; + this._gradientZMin=null; + this._gradientZMax=null; + } + + __class(GradientSize,'laya.d3.core.particleShuriKen.module.GradientSize'); + var __proto=GradientSize.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientSize=destObject; + destGradientSize._type=this._type; + destGradientSize._separateAxes=this._separateAxes; + this._gradient.cloneTo(destGradientSize._gradient); + this._gradientX.cloneTo(destGradientSize._gradientX); + this._gradientY.cloneTo(destGradientSize._gradientY); + this._gradientZ.cloneTo(destGradientSize._gradientZ); + destGradientSize._constantMin=this._constantMin; + destGradientSize._constantMax=this._constantMax; + this._constantMinSeparate.cloneTo(destGradientSize._constantMinSeparate); + this._constantMaxSeparate.cloneTo(destGradientSize._constantMaxSeparate); + this._gradientMin.cloneTo(destGradientSize._gradientMin); + this._gradientMax.cloneTo(destGradientSize._gradientMax); + this._gradientXMin.cloneTo(destGradientSize._gradientXMin); + this._gradientXMax.cloneTo(destGradientSize._gradientXMax); + this._gradientYMin.cloneTo(destGradientSize._gradientYMin); + this._gradientYMax.cloneTo(destGradientSize._gradientYMax); + this._gradientZMin.cloneTo(destGradientSize._gradientZMin); + this._gradientZMax.cloneTo(destGradientSize._gradientZMax); + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientSize=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientSize); + return destGradientSize; + } + + /** + *是否分轴。 + */ + __getset(0,__proto,'separateAxes',function(){ + return this._separateAxes; + }); + + /** + *生命周期尺寸类型,0曲线模式,1随机双常量模式,2随机双曲线模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *渐变尺寸X。 + */ + __getset(0,__proto,'gradientSizeX',function(){ + return this._gradientX; + }); + + /** + *渐变尺寸。 + */ + __getset(0,__proto,'gradientSize',function(){ + return this._gradient; + }); + + /** + *渐变最小尺寸。 + */ + __getset(0,__proto,'gradientMin',function(){ + return this._gradientMin; + }); + + /** + *最小随机双固定尺寸。 + */ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *渐变最小尺寸Z。 + */ + __getset(0,__proto,'gradientZMin',function(){ + return this._gradientZMin; + }); + + /** + *渐变尺寸Y。 + */ + __getset(0,__proto,'gradientSizeY',function(){ + return this._gradientY; + }); + + /** + *最小分轴随机双固定尺寸。 + */ + __getset(0,__proto,'constantMinSeparate',function(){ + return this._constantMinSeparate; + }); + + /** + *渐变尺寸Z。 + */ + __getset(0,__proto,'gradientSizeZ',function(){ + return this._gradientZ; + }); + + /** + *渐变最大尺寸。 + */ + __getset(0,__proto,'gradientMax',function(){ + return this._gradientMax; + }); + + /** + *最大随机双固定尺寸。 + */ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + /** + *最小分轴随机双固定尺寸。 + */ + __getset(0,__proto,'constantMaxSeparate',function(){ + return this._constantMaxSeparate; + }); + + /** + *渐变最小尺寸X。 + */ + __getset(0,__proto,'gradientXMin',function(){ + return this._gradientXMin; + }); + + /** + *渐变最大尺寸X。 + */ + __getset(0,__proto,'gradientXMax',function(){ + return this._gradientXMax; + }); + + /** + *渐变最小尺寸Y。 + */ + __getset(0,__proto,'gradientYMin',function(){ + return this._gradientYMin; + }); + + /** + *渐变最大尺寸Y。 + */ + __getset(0,__proto,'gradientYMax',function(){ + return this._gradientYMax; + }); + + /** + *渐变最大尺寸Z。 + */ + __getset(0,__proto,'gradientZMax',function(){ + return this._gradientZMax; + }); + + GradientSize.createByGradient=function(gradient){ + var gradientSize=new GradientSize(); + gradientSize._type=0; + gradientSize._separateAxes=false; + gradientSize._gradient=gradient; + return gradientSize; + } + + GradientSize.createByGradientSeparate=function(gradientX,gradientY,gradientZ){ + var gradientSize=new GradientSize(); + gradientSize._type=0; + gradientSize._separateAxes=true; + gradientSize._gradientX=gradientX; + gradientSize._gradientY=gradientY; + gradientSize._gradientZ=gradientZ; + return gradientSize; + } + + GradientSize.createByRandomTwoConstant=function(constantMin,constantMax){ + var gradientSize=new GradientSize(); + gradientSize._type=1; + gradientSize._separateAxes=false; + gradientSize._constantMin=constantMin; + gradientSize._constantMax=constantMax; + return gradientSize; + } + + GradientSize.createByRandomTwoConstantSeparate=function(constantMinSeparate,constantMaxSeparate){ + var gradientSize=new GradientSize(); + gradientSize._type=1; + gradientSize._separateAxes=true; + gradientSize._constantMinSeparate=constantMinSeparate; + gradientSize._constantMaxSeparate=constantMaxSeparate; + return gradientSize; + } + + GradientSize.createByRandomTwoGradient=function(gradientMin,gradientMax){ + var gradientSize=new GradientSize(); + gradientSize._type=2; + gradientSize._separateAxes=false; + gradientSize._gradientMin=gradientMin; + gradientSize._gradientMax=gradientMax; + return gradientSize; + } + + GradientSize.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){ + var gradientSize=new GradientSize(); + gradientSize._type=2; + gradientSize._separateAxes=true; + gradientSize._gradientXMin=gradientXMin; + gradientSize._gradientXMax=gradientXMax; + gradientSize._gradientYMin=gradientYMin; + gradientSize._gradientYMax=gradientYMax; + gradientSize._gradientZMin=gradientZMin; + gradientSize._gradientZMax=gradientZMax; + return gradientSize; + } + + return GradientSize; + })() + + + /** + *GradientVelocity 类用于创建渐变速度。 + */ + //class laya.d3.core.particleShuriKen.module.GradientVelocity + var GradientVelocity=(function(){ + function GradientVelocity(){ + this._type=0; + this._constant=null; + this._gradientX=null; + this._gradientY=null; + this._gradientZ=null; + this._constantMin=null; + this._constantMax=null; + this._gradientXMin=null; + this._gradientXMax=null; + this._gradientYMin=null; + this._gradientYMax=null; + this._gradientZMin=null; + this._gradientZMax=null; + } + + __class(GradientVelocity,'laya.d3.core.particleShuriKen.module.GradientVelocity'); + var __proto=GradientVelocity.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destGradientVelocity=destObject; + destGradientVelocity._type=this._type; + this._constant.cloneTo(destGradientVelocity._constant); + this._gradientX.cloneTo(destGradientVelocity._gradientX); + this._gradientY.cloneTo(destGradientVelocity._gradientY); + this._gradientZ.cloneTo(destGradientVelocity._gradientZ); + this._constantMin.cloneTo(destGradientVelocity._constantMin); + this._constantMax.cloneTo(destGradientVelocity._constantMax); + this._gradientXMin.cloneTo(destGradientVelocity._gradientXMin); + this._gradientXMax.cloneTo(destGradientVelocity._gradientXMax); + this._gradientYMin.cloneTo(destGradientVelocity._gradientYMin); + this._gradientYMax.cloneTo(destGradientVelocity._gradientYMax); + this._gradientZMin.cloneTo(destGradientVelocity._gradientZMin); + this._gradientZMax.cloneTo(destGradientVelocity._gradientZMax); + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destGradientVelocity=/*__JS__ */new this.constructor(); + this.cloneTo(destGradientVelocity); + return destGradientVelocity; + } + + /** + *渐变速度Z。 + */ + __getset(0,__proto,'gradientZ',function(){ + return this._gradientZ; + }); + + /**固定速度。*/ + __getset(0,__proto,'constant',function(){ + return this._constant; + }); + + /** + *生命周期速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *渐变最大速度X。 + */ + __getset(0,__proto,'gradientXMax',function(){ + return this._gradientXMax; + }); + + /**最小固定速度。*/ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *渐变速度X。 + */ + __getset(0,__proto,'gradientX',function(){ + return this._gradientX; + }); + + /** + *渐变速度Y。 + */ + __getset(0,__proto,'gradientY',function(){ + return this._gradientY; + }); + + /** + *渐变最小速度X。 + */ + __getset(0,__proto,'gradientXMin',function(){ + return this._gradientXMin; + }); + + /**最大固定速度。*/ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + /** + *渐变最小速度Y。 + */ + __getset(0,__proto,'gradientYMin',function(){ + return this._gradientYMin; + }); + + /** + *渐变最大速度Y。 + */ + __getset(0,__proto,'gradientYMax',function(){ + return this._gradientYMax; + }); + + /** + *渐变最小速度Z。 + */ + __getset(0,__proto,'gradientZMin',function(){ + return this._gradientZMin; + }); + + /** + *渐变最大速度Z。 + */ + __getset(0,__proto,'gradientZMax',function(){ + return this._gradientZMax; + }); + + GradientVelocity.createByConstant=function(constant){ + var gradientVelocity=new GradientVelocity(); + gradientVelocity._type=0; + gradientVelocity._constant=constant; + return gradientVelocity; + } + + GradientVelocity.createByGradient=function(gradientX,gradientY,gradientZ){ + var gradientVelocity=new GradientVelocity(); + gradientVelocity._type=1; + gradientVelocity._gradientX=gradientX; + gradientVelocity._gradientY=gradientY; + gradientVelocity._gradientZ=gradientZ; + return gradientVelocity; + } + + GradientVelocity.createByRandomTwoConstant=function(constantMin,constantMax){ + var gradientVelocity=new GradientVelocity(); + gradientVelocity._type=2; + gradientVelocity._constantMin=constantMin; + gradientVelocity._constantMax=constantMax; + return gradientVelocity; + } + + GradientVelocity.createByRandomTwoGradient=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){ + var gradientVelocity=new GradientVelocity(); + gradientVelocity._type=3; + gradientVelocity._gradientXMin=gradientXMin; + gradientVelocity._gradientXMax=gradientXMax; + gradientVelocity._gradientYMin=gradientYMin; + gradientVelocity._gradientYMax=gradientYMax; + gradientVelocity._gradientZMin=gradientZMin; + gradientVelocity._gradientZMax=gradientZMax; + return gradientVelocity; + } + + return GradientVelocity; + })() + + + /** + *RotationOverLifetime 类用于粒子的生命周期旋转。 + */ + //class laya.d3.core.particleShuriKen.module.RotationOverLifetime + var RotationOverLifetime=(function(){ + function RotationOverLifetime(angularVelocity){ + this._angularVelocity=null; + this.enbale=false; + this._angularVelocity=angularVelocity; + } + + __class(RotationOverLifetime,'laya.d3.core.particleShuriKen.module.RotationOverLifetime'); + var __proto=RotationOverLifetime.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destRotationOverLifetime=destObject; + this._angularVelocity.cloneTo(destRotationOverLifetime._angularVelocity); + destRotationOverLifetime.enbale=this.enbale; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destRotationOverLifetime=/*__JS__ */new this.constructor(); + this.cloneTo(destRotationOverLifetime); + return destRotationOverLifetime; + } + + /** + *获取角速度。 + */ + __getset(0,__proto,'angularVelocity',function(){ + return this._angularVelocity; + }); + + return RotationOverLifetime; + })() + + + /** + *BaseShape 类用于粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.BaseShape + var BaseShape=(function(){ + function BaseShape(){ + this.enbale=false; + } + + __class(BaseShape,'laya.d3.core.particleShuriKen.module.shape.BaseShape'); + var __proto=BaseShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + throw new Error("BaseShape: must override it."); + } + + return BaseShape; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.core.particleShuriKen.module.shape.ShapeUtils + var ShapeUtils=(function(){ + function ShapeUtils(){} + __class(ShapeUtils,'laya.d3.core.particleShuriKen.module.shape.ShapeUtils'); + ShapeUtils._randomPointUnitArcCircle=function(arc,out){ + var outE=out.elements; + var angle=Math.random()*arc; + outE[0]=Math.cos(angle); + outE[1]=Math.sin(angle); + } + + ShapeUtils._randomPointInsideUnitArcCircle=function(arc,out){ + var outE=out.elements; + ShapeUtils._randomPointUnitArcCircle(arc,out); + var range=Math.pow(Math.random(),1.0 / 2.0); + outE[0]=outE[0] *range; + outE[1]=outE[1] *range; + } + + ShapeUtils._randomPointUnitCircle=function(out){ + var outE=out.elements; + var angle=Math.random()*Math.PI *2; + outE[0]=Math.cos(angle); + outE[1]=Math.sin(angle); + } + + ShapeUtils._randomPointInsideUnitCircle=function(out){ + var outE=out.elements; + ShapeUtils._randomPointUnitCircle(out); + var range=Math.pow(Math.random(),1.0 / 2.0); + outE[0]=outE[0] *range; + outE[1]=outE[1] *range; + } + + ShapeUtils._randomPointUnitSphere=function(out){ + var outE=out.elements; + var z=outE[2]=Math.random()*2-1.0; + var a=Math.random()*Math.PI *2; + var r=Math.sqrt(1.0-z *z); + outE[0]=r *Math.cos(a); + outE[1]=r *Math.sin(a); + } + + ShapeUtils._randomPointInsideUnitSphere=function(out){ + var outE=out.elements; + ShapeUtils._randomPointUnitSphere(out); + var range=Math.pow(Math.random(),1.0 / 3.0); + outE[0]=outE[0] *range; + outE[1]=outE[1] *range; + outE[2]=outE[2] *range; + } + + ShapeUtils._randomPointInsideHalfUnitBox=function(out){ + var outE=out.elements; + outE[0]=(Math.random()-0.5); + outE[1]=(Math.random()-0.5); + outE[2]=(Math.random()-0.5); + } + + return ShapeUtils; + })() + + + /** + *SizeOverLifetime 类用于粒子的生命周期尺寸。 + */ + //class laya.d3.core.particleShuriKen.module.SizeOverLifetime + var SizeOverLifetime=(function(){ + function SizeOverLifetime(size){ + this._size=null; + this.enbale=false; + this._size=size; + } + + __class(SizeOverLifetime,'laya.d3.core.particleShuriKen.module.SizeOverLifetime'); + var __proto=SizeOverLifetime.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destSizeOverLifetime=destObject; + this._size.cloneTo(destSizeOverLifetime._size); + destSizeOverLifetime.enbale=this.enbale; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destSizeOverLifetime=/*__JS__ */new this.constructor(); + this.cloneTo(destSizeOverLifetime); + return destSizeOverLifetime; + } + + /** + *获取尺寸。 + */ + __getset(0,__proto,'size',function(){ + return this._size; + }); + + return SizeOverLifetime; + })() + + + /** + *StartFrame 类用于创建开始帧。 + */ + //class laya.d3.core.particleShuriKen.module.StartFrame + var StartFrame=(function(){ + function StartFrame(){ + this._type=0; + this._constant=NaN; + this._constantMin=NaN; + this._constantMax=NaN; + } + + __class(StartFrame,'laya.d3.core.particleShuriKen.module.StartFrame'); + var __proto=StartFrame.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destStartFrame=destObject; + destStartFrame._type=this._type; + destStartFrame._constant=this._constant; + destStartFrame._constantMin=this._constantMin; + destStartFrame._constantMax=this._constantMax; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destStartFrame=/*__JS__ */new this.constructor(); + this.cloneTo(destStartFrame); + return destStartFrame; + } + + /** + *固定帧。 + */ + __getset(0,__proto,'constant',function(){ + return this._constant; + }); + + /** + *开始帧类型,0常量模式,1随机双常量模式。 + */ + __getset(0,__proto,'type',function(){ + return this._type; + }); + + /** + *最小固定帧。 + */ + __getset(0,__proto,'constantMin',function(){ + return this._constantMin; + }); + + /** + *最大固定帧。 + */ + __getset(0,__proto,'constantMax',function(){ + return this._constantMax; + }); + + StartFrame.createByConstant=function(constant){ + var rotationOverLifetime=new StartFrame(); + rotationOverLifetime._type=0; + rotationOverLifetime._constant=constant; + return rotationOverLifetime; + } + + StartFrame.createByRandomTwoConstant=function(constantMin,constantMax){ + var rotationOverLifetime=new StartFrame(); + rotationOverLifetime._type=1; + rotationOverLifetime._constantMin=constantMin; + rotationOverLifetime._constantMax=constantMax; + return rotationOverLifetime; + } + + return StartFrame; + })() + + + /** + *TextureSheetAnimation 类用于创建粒子帧动画。 + */ + //class laya.d3.core.particleShuriKen.module.TextureSheetAnimation + var TextureSheetAnimation=(function(){ + function TextureSheetAnimation(frame,startFrame){ + this.tiles=null; + this.type=0; + this.randomRow=false; + this.frame=null; + this.startFrame=null; + this.cycles=0; + this.enableUVChannels=0; + this.enbale=false; + this.tiles=new Vector2(1,1); + this.type=0; + this.randomRow=true; + this.cycles=1; + this.enableUVChannels=1; + this.frame=frame; + this.startFrame=startFrame; + } + + __class(TextureSheetAnimation,'laya.d3.core.particleShuriKen.module.TextureSheetAnimation'); + var __proto=TextureSheetAnimation.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destTextureSheetAnimation=destObject; + this.tiles.clone(destTextureSheetAnimation.tiles); + destTextureSheetAnimation.type=this.type; + destTextureSheetAnimation.randomRow=this.randomRow; + this.frame.cloneTo(destTextureSheetAnimation.frame); + this.startFrame.cloneTo(destTextureSheetAnimation.startFrame); + destTextureSheetAnimation.cycles=this.cycles; + destTextureSheetAnimation.enableUVChannels=this.enableUVChannels; + destTextureSheetAnimation.enbale=this.enbale; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destTextureSheetAnimation=/*__JS__ */new this.constructor(); + this.cloneTo(destTextureSheetAnimation); + return destTextureSheetAnimation; + } + + return TextureSheetAnimation; + })() + + + /** + *VelocityOverLifetime 类用于粒子的生命周期速度。 + */ + //class laya.d3.core.particleShuriKen.module.VelocityOverLifetime + var VelocityOverLifetime=(function(){ + function VelocityOverLifetime(velocity){ + this._velocity=null; + this.enbale=false; + this.space=0; + this._velocity=velocity; + } + + __class(VelocityOverLifetime,'laya.d3.core.particleShuriKen.module.VelocityOverLifetime'); + var __proto=VelocityOverLifetime.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destVelocityOverLifetime=destObject; + this._velocity.cloneTo(destVelocityOverLifetime._velocity); + destVelocityOverLifetime.enbale=this.enbale; + destVelocityOverLifetime.space=this.space; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destVelocityOverLifetime=/*__JS__ */new this.constructor(); + this.cloneTo(destVelocityOverLifetime); + return destVelocityOverLifetime; + } + + /** + *获取尺寸。 + */ + __getset(0,__proto,'velocity',function(){ + return this._velocity; + }); + + return VelocityOverLifetime; + })() + + + /** + *@private + */ + //class laya.d3.core.particleShuriKen.ShurikenParticleData + var ShurikenParticleData=(function(){ + function ShurikenParticleData(){ + this.startLifeTime=NaN; + this.position=null; + this.direction=null; + this.startColor=null; + this.startSize=null; + this.startRotation0=null; + this.startRotation1=null; + this.startRotation2=null; + this.time=NaN; + this.startSpeed=NaN; + this.startUVInfo=null; + this.simulationWorldPostion=null; + } + + __class(ShurikenParticleData,'laya.d3.core.particleShuriKen.ShurikenParticleData'); + ShurikenParticleData._getStartLifetimeFromGradient=function(startLifeTimeGradient,emissionTime){ + for (var i=1,n=startLifeTimeGradient.gradientCount;i < n;i++){ + var key=startLifeTimeGradient.getKeyByIndex(i); + if (key >=emissionTime){ + var lastKey=startLifeTimeGradient.getKeyByIndex(i-1); + var age=(emissionTime-lastKey)/ (key-lastKey); + return MathUtil.lerp(startLifeTimeGradient.getValueByIndex(i-1),startLifeTimeGradient.getValueByIndex(i),age) + } + } + throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient."); + } + + ShurikenParticleData.create=function(particleSystem,particleRender,position,direction,time,transform){ + var particleData=new ShurikenParticleData(); + particleData.position=position; + MathUtil.scaleVector3(direction,1.0,ShurikenParticleData._tempDirection); + particleData.direction=ShurikenParticleData._tempDirection; + particleData.startColor=ShurikenParticleData._tempStartColor; + switch (particleSystem.startColorType){ + case 0:; + var startColorE=particleData.startColor; + var constantStartColorE=particleSystem.startColorConstant.elements; + startColorE[0]=constantStartColorE[0]; + startColorE[1]=constantStartColorE[1]; + startColorE[2]=constantStartColorE[2]; + startColorE[3]=constantStartColorE[3]; + break ; + case 2: + MathUtil.lerpVector4(particleSystem.startColorConstantMin.elements,particleSystem.startColorConstantMax.elements,Math.random(),particleData.startColor); + break ; + }; + var colorOverLifetime=particleSystem.colorOverLifetime; + if (colorOverLifetime && colorOverLifetime.enbale){ + var startColor=particleData.startColor; + var color=colorOverLifetime.color; + switch (color.type){ + case 0: + startColor[0]=startColor[0] *color.constant.x; + startColor[1]=startColor[1] *color.constant.y; + startColor[2]=startColor[2] *color.constant.z; + startColor[3]=startColor[3] *color.constant.w; + break ; + case 2:; + var colorRandom=Math.random(); + var minConstantColor=color.constantMin; + var maxConstantColor=color.constantMax; + startColor[0]=startColor[0] *MathUtil.lerp(minConstantColor.x,maxConstantColor.x,colorRandom); + startColor[1]=startColor[1] *MathUtil.lerp(minConstantColor.y,maxConstantColor.y,colorRandom); + startColor[2]=startColor[2] *MathUtil.lerp(minConstantColor.z,maxConstantColor.z,colorRandom); + startColor[3]=startColor[3] *MathUtil.lerp(minConstantColor.w,maxConstantColor.w,colorRandom); + break ; + } + } + particleData.startSize=ShurikenParticleData._tempStartSize; + var particleSize=particleData.startSize; + switch (particleSystem.startSizeType){ + case 0: + if (particleSystem.threeDStartSize){ + var startSizeConstantSeparate=particleSystem.startSizeConstantSeparate; + particleSize[0]=startSizeConstantSeparate.x; + particleSize[1]=startSizeConstantSeparate.y; + particleSize[2]=startSizeConstantSeparate.z; + }else { + particleSize[0]=particleSize[1]=particleSize[2]=particleSystem.startSizeConstant; + } + break ; + case 2: + if (particleSystem.threeDStartSize){ + var startSizeConstantMinSeparate=particleSystem.startSizeConstantMinSeparate; + var startSizeConstantMaxSeparate=particleSystem.startSizeConstantMaxSeparate; + particleSize[0]=MathUtil.lerp(startSizeConstantMinSeparate.x,startSizeConstantMaxSeparate.x,Math.random()); + particleSize[1]=MathUtil.lerp(startSizeConstantMinSeparate.y,startSizeConstantMaxSeparate.y,Math.random()); + particleSize[2]=MathUtil.lerp(startSizeConstantMinSeparate.z,startSizeConstantMaxSeparate.z,Math.random()); + }else { + particleSize[0]=particleSize[1]=particleSize[2]=MathUtil.lerp(particleSystem.startSizeConstantMin,particleSystem.startSizeConstantMax,Math.random()); + } + break ; + }; + var sizeOverLifetime=particleSystem.sizeOverLifetime; + if (sizeOverLifetime && sizeOverLifetime.enbale && sizeOverLifetime.size.type===1){ + var size=sizeOverLifetime.size; + if (size.separateAxes){ + particleSize[0]=particleSize[0] *MathUtil.lerp(size.constantMinSeparate.x,size.constantMaxSeparate.x,Math.random()); + particleSize[1]=particleSize[1] *MathUtil.lerp(size.constantMinSeparate.y,size.constantMaxSeparate.y,Math.random()); + particleSize[2]=particleSize[2] *MathUtil.lerp(size.constantMinSeparate.z,size.constantMaxSeparate.z,Math.random()); + }else { + var randomSize=MathUtil.lerp(size.constantMin,size.constantMax,Math.random()); + particleSize[0]=particleSize[0] *randomSize; + particleSize[1]=particleSize[1] *randomSize; + particleSize[2]=particleSize[2] *randomSize; + } + }; + var particleRotation0; + var particleRotation1; + var particleRotation2; + var rotationMatrixE; + switch (particleSystem.startRotationType){ + case 0: + if (particleSystem.threeDStartRotation && (particleRender.renderMode!==1)&& (particleRender.renderMode!==1)){ + var startRotationConstantSeparate=particleSystem.startRotationConstantSeparate; + Matrix4x4.createRotationYawPitchRoll(startRotationConstantSeparate.y,startRotationConstantSeparate.x,startRotationConstantSeparate.z,ShurikenParticleData._tempRotationMatrix); + rotationMatrixE=ShurikenParticleData._tempRotationMatrix.elements; + particleData.startRotation0=ShurikenParticleData._tempStartRotation0; + particleRotation0=particleData.startRotation0; + particleRotation0[0]=rotationMatrixE[0]; + particleRotation0[1]=rotationMatrixE[1]; + particleRotation0[2]=rotationMatrixE[2]; + particleData.startRotation1=ShurikenParticleData._tempStartRotation1; + particleRotation1=particleData.startRotation1; + particleRotation1[0]=rotationMatrixE[4]; + particleRotation1[1]=rotationMatrixE[5]; + particleRotation1[2]=rotationMatrixE[6]; + particleData.startRotation2=ShurikenParticleData._tempStartRotation2; + particleRotation2=particleData.startRotation2; + particleRotation2[0]=rotationMatrixE[8]; + particleRotation2[1]=rotationMatrixE[9]; + particleRotation2[2]=rotationMatrixE[10]; + }else { + particleData.startRotation0=ShurikenParticleData._tempStartRotation0; + particleRotation0=particleData.startRotation0; + particleRotation0[0]=particleRotation0[1]=particleRotation0[2]=particleSystem.startRotationConstant; + } + break ; + case 2: + if (particleSystem.threeDStartRotation && (particleRender.renderMode!==1)&& (particleRender.renderMode!==2)){ + particleData.startRotation0=ShurikenParticleData._tempStartRotation0; + particleRotation0=particleData.startRotation0; + var startRotationConstantMinSeparate=particleSystem.startRotationConstantMinSeparate; + var startRotationConstantMaxSeparate=particleSystem.startRotationConstantMaxSeparate; + Matrix4x4.createRotationYawPitchRoll(MathUtil.lerp(startRotationConstantMinSeparate.y,startRotationConstantMaxSeparate.y,Math.random()),MathUtil.lerp(startRotationConstantMinSeparate.x,startRotationConstantMaxSeparate.x,Math.random()),MathUtil.lerp(startRotationConstantMinSeparate.z,startRotationConstantMaxSeparate.z,Math.random()),ShurikenParticleData._tempRotationMatrix); + rotationMatrixE=ShurikenParticleData._tempRotationMatrix.elements; + particleData.startRotation0=ShurikenParticleData._tempStartRotation0; + particleRotation0=particleData.startRotation0; + particleRotation0[0]=rotationMatrixE[0]; + particleRotation0[1]=rotationMatrixE[1]; + particleRotation0[2]=rotationMatrixE[2]; + particleData.startRotation1=ShurikenParticleData._tempStartRotation1; + particleRotation1=particleData.startRotation1; + particleRotation1[0]=rotationMatrixE[4]; + particleRotation1[1]=rotationMatrixE[5]; + particleRotation1[2]=rotationMatrixE[6]; + particleData.startRotation2=ShurikenParticleData._tempStartRotation2; + particleRotation2=particleData.startRotation2; + particleRotation2[0]=rotationMatrixE[8]; + particleRotation2[1]=rotationMatrixE[9]; + particleRotation2[2]=rotationMatrixE[10]; + }else { + particleData.startRotation0=ShurikenParticleData._tempStartRotation0; + particleRotation0=particleData.startRotation0; + particleRotation0[0]=particleRotation0[1]=particleRotation0[2]=MathUtil.lerp(particleSystem.startRotationConstantMin,particleSystem.startRotationConstantMax,Math.random()); + } + break ; + } + if (Math.random()< particleSystem.randomizeRotationDirection){ + particleRotation0[0]=-particleRotation0[0]; + particleRotation0[1]=-particleRotation0[1]; + particleRotation0[2]=-particleRotation0[2]; + } + particleData.startRotation1=ShurikenParticleData._tempStartRotation1; + particleData.startRotation2=ShurikenParticleData._tempStartRotation2; + switch (particleSystem.startLifetimeType){ + case 0: + particleData.startLifeTime=particleSystem.startLifetimeConstant; + break ; + case 1: + particleData.startLifeTime=ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradient,particleSystem.emission.emissionTime); + break ; + case 2: + particleData.startLifeTime=MathUtil.lerp(particleSystem.startLifetimeConstantMin,particleSystem.startLifetimeConstantMax,Math.random()); + break ; + case 3:; + var emissionTime=particleSystem.emission.emissionTime; + particleData.startLifeTime=MathUtil.lerp(ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMin,emissionTime),ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMax,emissionTime),Math.random()); + break ; + } + switch (particleSystem.startSpeedType){ + case 0: + particleData.startSpeed=particleSystem.startSpeedConstant; + break ; + case 2: + particleData.startSpeed=MathUtil.lerp(particleSystem.startSpeedConstantMin,particleSystem.startSpeedConstantMax,Math.random()); + break ; + } + particleData.startUVInfo=ShurikenParticleData._tempStartUVInfo; + var textureSheetAnimation=particleSystem.textureSheetAnimation; + var enableSheetAnimation=textureSheetAnimation && textureSheetAnimation.enbale; + var startUVInfo; + if (enableSheetAnimation){ + var title=textureSheetAnimation.tiles; + var titleX=title.x,titleY=title.y; + var subU=1.0 / titleX,subV=1.0 / titleY; + var totalFrameCount=0; + var startRow=0; + var randomRow=textureSheetAnimation.randomRow; + switch (textureSheetAnimation.type){ + case 0: + totalFrameCount=titleX *titleY; + break ; + case 1: + totalFrameCount=titleX; + if (randomRow) + startRow=Math.round(Math.random()*titleY); + else + startRow=0; + break ; + }; + var startFrameCount=0; + var startFrame=textureSheetAnimation.startFrame; + switch (startFrame.type){ + case 0: + startFrameCount=startFrame.constant; + break ; + case 1: + startFrameCount=Math.round(MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,Math.random())); + break ; + }; + var frame=textureSheetAnimation.frame; + switch (frame.type){ + case 0: + startFrameCount+=frame.constant; + break ; + case 2: + startFrameCount+=Math.round(MathUtil.lerp(frame.constantMin,frame.constantMax,Math.random())); + break ; + } + if (!randomRow) + startRow=Math.floor(startFrameCount / titleX); + var startCol=startFrameCount % titleX; + startUVInfo=particleData.startUVInfo; + startUVInfo[0]=subU; + startUVInfo[1]=subV; + startUVInfo[2]=startCol *subU; + startUVInfo[3]=startRow *subV; + }else { + startUVInfo=particleData.startUVInfo; + startUVInfo[0]=1.0; + startUVInfo[1]=1.0; + startUVInfo[2]=0.0; + startUVInfo[3]=0.0; + } + particleData.time=time; + particleData.simulationWorldPostion=ShurikenParticleData._tempSimulationWorldPostion; + var particleSimulationWorldPostion=particleData.simulationWorldPostion; + if (particleSystem.simulationSpace===0){ + var positionE=transform.position.elements; + particleSimulationWorldPostion[0]=positionE[0]; + particleSimulationWorldPostion[1]=positionE[1]; + particleSimulationWorldPostion[2]=positionE[2]; + }else { + particleSimulationWorldPostion[0]=0; + particleSimulationWorldPostion[1]=0; + particleSimulationWorldPostion[2]=0; + } + return particleData; + } + + __static(ShurikenParticleData, + ['_tempRotationMatrix',function(){return this._tempRotationMatrix=new Matrix4x4();},'_tempDirection',function(){return this._tempDirection=new Float32Array(3);},'_tempStartColor',function(){return this._tempStartColor=new Float32Array(4);},'_tempStartSize',function(){return this._tempStartSize=new Float32Array(3);},'_tempStartRotation0',function(){return this._tempStartRotation0=new Float32Array(3);},'_tempStartRotation1',function(){return this._tempStartRotation1=new Float32Array(3);},'_tempStartRotation2',function(){return this._tempStartRotation2=new Float32Array(3);},'_tempStartUVInfo',function(){return this._tempStartUVInfo=new Float32Array(4);},'_tempSimulationWorldPostion',function(){return this._tempSimulationWorldPostion=new Float32Array(3);} + ]); + return ShurikenParticleData; + })() + + + /** + *ShurikenParticleSystem 类用于创建3D粒子数据模板。 + */ + //class laya.d3.core.particleShuriKen.ShurikenParticleSystem + var ShurikenParticleSystem=(function(){ + function ShurikenParticleSystem(owner){ + this._owner=null; + this._vertices=null; + this._floatCountPerVertex=0; + this._firstActiveElement=0; + this._firstNewElement=0; + this._firstFreeElement=0; + this._firstRetiredElement=0; + this._drawCounter=0; + this._currentTime=NaN; + this._vertexBuffer=null; + this._indexBuffer=null; + this._maxParticles=0; + this._emission=null; + this._aliveParticleCount=0; + this._shape=null; + this._startUpdateLoopCount=0; + this.duration=NaN; + this.looping=false; + this.prewarm=false; + this.startDelayType=0; + this.startDelay=NaN; + this.startDelayMin=NaN; + this.startDelayMax=NaN; + this.startLifetimeType=0; + this.startLifetimeConstant=NaN; + this.startLifeTimeGradient=null; + this.startLifetimeConstantMin=NaN; + this.startLifetimeConstantMax=NaN; + this.startLifeTimeGradientMin=null; + this.startLifeTimeGradientMax=null; + this.startSpeedType=0; + this.startSpeedConstant=NaN; + this.startSpeedConstantMin=NaN; + this.startSpeedConstantMax=NaN; + this.threeDStartSize=false; + this.startSizeType=0; + this.startSizeConstant=NaN; + this.startSizeConstantSeparate=null; + this.startSizeConstantMin=NaN; + this.startSizeConstantMax=NaN; + this.startSizeConstantMinSeparate=null; + this.startSizeConstantMaxSeparate=null; + this.threeDStartRotation=false; + this.startRotationType=0; + this.startRotationConstant=NaN; + this.startRotationConstantSeparate=null; + this.startRotationConstantMin=NaN; + this.startRotationConstantMax=NaN; + this.startRotationConstantMinSeparate=null; + this.startRotationConstantMaxSeparate=null; + this.randomizeRotationDirection=NaN; + this.startColorType=0; + this.startColorConstant=null; + this.startColorConstantMin=null; + this.startColorConstantMax=null; + this.gravity=null; + this.gravityModifier=NaN; + this.simulationSpace=0; + this.scaleMode=0; + this.playOnAwake=false; + this.velocityOverLifetime=null; + this.colorOverLifetime=null; + this.sizeOverLifetime=null; + this.rotationOverLifetime=null; + this.textureSheetAnimation=null; + this.isPerformanceMode=false; + this._owner=owner; + this._currentTime=0; + this._floatCountPerVertex=40; + this._maxParticles=1000; + this.duration=5.0; + this.looping=true; + this.prewarm=false; + this.startDelayType=0; + this.startDelay=0.0; + this.startDelayMin=0.0; + this.startDelayMax=0.0; + this.startLifetimeType=0; + this.startLifetimeConstant=5.0; + this.startRotationConstantSeparate=new Vector3(0,0,0); + this.startLifetimeConstantMin=0.0; + this.startLifetimeConstantMax=5.0; + this.startRotationConstantMinSeparate=new Vector3(0,0,0); + this.startRotationConstantMaxSeparate=new Vector3(0,0,0); + this.startSpeedType=0; + this.startSpeedConstant=5.0; + this.startSpeedConstantMin=0.0; + this.startSpeedConstantMax=5.0; + this.threeDStartSize=false; + this.startSizeType=0; + this.startSizeConstant=1; + this.startSizeConstantSeparate=new Vector3(1,1,1); + this.startSizeConstantMin=0; + this.startSizeConstantMax=1; + this.startSizeConstantMinSeparate=new Vector3(0,0,0); + this.startSizeConstantMaxSeparate=new Vector3(1,1,1); + this.threeDStartRotation=false; + this.startRotationType=0; + this.startRotationConstant=0; + this.startRotationConstantMin=0.0; + this.startRotationConstantMax=0.0; + this.randomizeRotationDirection=0.0; + this.startColorType=0; + this.startColorConstant=new Vector4(1,1,1,1); + this.startColorConstantMin=new Vector4(1,1,1,1); + this.startColorConstantMax=new Vector4(1,1,1,1); + this.gravity=new Vector3(0,-9.81,0); + this.gravityModifier=0.0; + this.simulationSpace=1; + this.scaleMode=0; + this.playOnAwake=true; + this.isPerformanceMode=true; + } + + __class(ShurikenParticleSystem,'laya.d3.core.particleShuriKen.ShurikenParticleSystem'); + var __proto=ShurikenParticleSystem.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return this._indexBuffer; + } + + __proto._retireActiveParticles=function(){ + var epsilon=0.0001; + while (this._firstActiveElement !=this._firstNewElement){ + var index=this._firstActiveElement *this._floatCountPerVertex *4; + var timeIndex=index+27; + var particleAge=this._currentTime-this._vertices[timeIndex]; + if (particleAge+epsilon < this._vertices[index+26]) + break ; + this._vertices[timeIndex]=this._drawCounter; + this._firstActiveElement++; + if (this._firstActiveElement >=this._maxParticles) + this._firstActiveElement=0; + } + } + + __proto._freeRetiredParticles=function(){ + while (this._firstRetiredElement !=this._firstActiveElement){ + var age=this._drawCounter-this._vertices[this._firstRetiredElement *this._floatCountPerVertex *4+27]; + if (this.isPerformanceMode) + if (age < 3) + break ; + this._firstRetiredElement++; + if (this._firstRetiredElement >=this._maxParticles) + this._firstRetiredElement=0; + } + } + + __proto._setPartVertexDatas=function(subU,subV,startU,startV){ + for (var i=0;i < this._maxParticles;i++){ + var particleOffset=i *this._floatCountPerVertex *4; + this._vertices[particleOffset+this._floatCountPerVertex *0+0]=-0.5; + this._vertices[particleOffset+this._floatCountPerVertex *0+1]=-0.5; + this._vertices[particleOffset+this._floatCountPerVertex *1+0]=0.5; + this._vertices[particleOffset+this._floatCountPerVertex *1+1]=-0.5; + this._vertices[particleOffset+this._floatCountPerVertex *2+0]=0.5; + this._vertices[particleOffset+this._floatCountPerVertex *2+1]=0.5; + this._vertices[particleOffset+this._floatCountPerVertex *3+0]=-0.5; + this._vertices[particleOffset+this._floatCountPerVertex *3+1]=0.5; + } + } + + __proto._initPartVertexDatas=function(){ + this._vertexBuffer=VertexBuffer3D.create(VertexParticleShuriken.vertexDeclaration,this._maxParticles *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._vertices=new Float32Array(this._maxParticles *this._floatCountPerVertex *4); + var enableSheetAnimation=this.textureSheetAnimation && this.textureSheetAnimation.enbale; + if (enableSheetAnimation){ + var title=this.textureSheetAnimation.tiles; + var titleX=title.x,titleY=title.y; + var subU=1.0 / titleX,subV=1.0 / titleY; + var totalFrameCount=0; + var startRow=0; + var randomRow=this.textureSheetAnimation.randomRow; + switch (this.textureSheetAnimation.type){ + case 0: + totalFrameCount=titleX *titleY; + break ; + case 1: + totalFrameCount=titleX; + if (randomRow) + startRow=Math.round(Math.random()*titleY); + else + startRow=0; + break ; + }; + var startFrameCount=0; + var startFrame=this.textureSheetAnimation.startFrame; + switch (startFrame.type){ + case 0: + startFrameCount=startFrame.constant; + break ; + case 1: + startFrameCount=Math.round(MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,Math.random())); + break ; + }; + var frame=this.textureSheetAnimation.frame; + switch (frame.type){ + case 0: + startFrameCount+=frame.constant; + break ; + case 2: + startFrameCount+=Math.round(MathUtil.lerp(frame.constantMin,frame.constantMax,Math.random())); + break ; + } + if (!randomRow) + startRow=Math.floor(startFrameCount / titleX); + var startCol=startFrameCount % titleX; + this._setPartVertexDatas(subU,subV,startCol *subU,startRow *subV); + }else { + this._setPartVertexDatas(1.0,1.0,0.0,0.0); + } + } + + __proto._initIndexDatas=function(){ + this._indexBuffer=IndexBuffer3D.create(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._maxParticles *6,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + var indexes=new Uint16Array(this._maxParticles *6); + for (var i=0;i < this._maxParticles;i++){ + var indexOffset=i *6; + var vertexOffset=i *4; + indexes[indexOffset+0]=(vertexOffset+0); + indexes[indexOffset+1]=(vertexOffset+2); + indexes[indexOffset+2]=(vertexOffset+1); + indexes[indexOffset+3]=(vertexOffset+0); + indexes[indexOffset+4]=(vertexOffset+3); + indexes[indexOffset+5]=(vertexOffset+2); + } + this._indexBuffer.setData(indexes); + } + + /** + *@private + */ + __proto._destroy=function(){ + this._vertexBuffer.dispose(); + this._indexBuffer.dispose(); + this._emission._destroy(); + this._owner=null; + this._vertices=null; + this._vertexBuffer=null; + this._indexBuffer=null; + this._emission=null; + this._shape=null; + this.startLifeTimeGradient=null; + this.startLifeTimeGradientMin=null; + this.startLifeTimeGradientMax=null; + this.startSizeConstantSeparate=null; + this.startSizeConstantMinSeparate=null; + this.startSizeConstantMaxSeparate=null; + this.startRotationConstantSeparate=null; + this.startRotationConstantMinSeparate=null; + this.startRotationConstantMaxSeparate=null; + this.startColorConstant=null; + this.startColorConstantMin=null; + this.startColorConstantMax=null; + this.gravity=null; + this.velocityOverLifetime=null; + this.colorOverLifetime=null; + this.sizeOverLifetime=null; + this.rotationOverLifetime=null; + this.textureSheetAnimation=null; + } + + __proto.update=function(state){ + var elapsedTime=0; + (this._startUpdateLoopCount!==Stat.loopCount)&& (elapsedTime=state.elapsedTime / 1000.0,this._currentTime+=elapsedTime); + this._retireActiveParticles(); + this._freeRetiredParticles(); + this._emission.update(elapsedTime,this._owner.transform); + if (this._firstActiveElement===this._firstFreeElement) + this._currentTime=0; + if (this._firstRetiredElement===this._firstActiveElement) + this._drawCounter=0; + if (this._firstNewElement >=this._firstRetiredElement) + this._aliveParticleCount=this._firstNewElement-this._firstRetiredElement; + else + this._aliveParticleCount=this._maxParticles-this._firstRetiredElement+this._firstNewElement; + } + + __proto.addParticle=function(position,direction,transform){ + Vector3.normalize(direction,direction); + var positionE=position.elements; + var directionE=direction.elements; + var nextFreeParticle=this._firstFreeElement+1; + if (nextFreeParticle >=this._maxParticles) + nextFreeParticle=0; + if (nextFreeParticle===this._firstRetiredElement) + return false; + var particleData=ShurikenParticleData.create(this,this._owner.particleRender,positionE,directionE,this._currentTime,transform); + var startIndex=this._firstFreeElement *this._floatCountPerVertex *4; + var randomX0=Math.random(),randomY0=Math.random(),randomZ0=Math.random(),randomW0=Math.random(); + var randomX1=Math.random(),randomY1=Math.random(),randomZ1=Math.random(),randomW1=Math.random(); + var subU=particleData.startUVInfo[0]; + var subV=particleData.startUVInfo[1]; + var startU=particleData.startUVInfo[2]; + var startV=particleData.startUVInfo[3]; + this._vertices[startIndex+2]=startU; + this._vertices[startIndex+3]=startV+subV; + this._vertices[startIndex+this._floatCountPerVertex+2]=startU+subU; + this._vertices[startIndex+this._floatCountPerVertex+3]=startV+subV; + this._vertices[startIndex+this._floatCountPerVertex *2+2]=startU+subU; + this._vertices[startIndex+this._floatCountPerVertex *2+3]=startV; + this._vertices[startIndex+this._floatCountPerVertex *3+2]=startU; + this._vertices[startIndex+this._floatCountPerVertex *3+3]=startV; + for (var i=0;i < 4;i++){ + var vertexStart=startIndex+i *this._floatCountPerVertex; + var j=0,offset=0; + for (j=0,offset=4;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.position[j]; + for (j=0,offset=7;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.direction[j]; + for (j=0,offset=10;j < 4;j++) + this._vertices[vertexStart+offset+j]=particleData.startColor[j]; + for (j=0,offset=14;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.startSize[j]; + for (j=0,offset=17;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.startRotation0[j]; + for (j=0,offset=20;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.startRotation1[j]; + for (j=0,offset=23;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.startRotation2[j]; + this._vertices[vertexStart+26]=particleData.startLifeTime; + this._vertices[vertexStart+27]=particleData.time; + this._vertices[vertexStart+28]=particleData.startSpeed; + this._vertices[vertexStart+29]=randomX0; + this._vertices[vertexStart+30]=randomY0; + this._vertices[vertexStart+31]=randomZ0; + this._vertices[vertexStart+32]=randomW0; + this._vertices[vertexStart+33]=randomX1; + this._vertices[vertexStart+34]=randomY1; + this._vertices[vertexStart+35]=randomZ1; + this._vertices[vertexStart+36]=randomW1; + for (j=0,offset=37;j < 3;j++) + this._vertices[vertexStart+offset+j]=particleData.simulationWorldPostion[j]; + } + this._firstFreeElement=nextFreeParticle; + return true; + } + + __proto.addNewParticlesToVertexBuffer=function(){ + var start=0; + if (this._firstNewElement < this._firstFreeElement){ + start=this._firstNewElement *4 *this._floatCountPerVertex; + this._vertexBuffer.setData(this._vertices,start,start,(this._firstFreeElement-this._firstNewElement)*4 *this._floatCountPerVertex); + }else { + start=this._firstNewElement *4 *this._floatCountPerVertex; + this._vertexBuffer.setData(this._vertices,start,start,(this._maxParticles-this._firstNewElement)*4 *this._floatCountPerVertex); + if (this._firstFreeElement > 0){ + this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement *4 *this._floatCountPerVertex); + } + } + this._firstNewElement=this._firstFreeElement; + } + + __proto._beforeRender=function(state){ + if (this._firstNewElement !=this._firstFreeElement){ + this.addNewParticlesToVertexBuffer(); + } + this._drawCounter++; + if (this._firstActiveElement !=this._firstFreeElement){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + return true; + } + return false; + } + + __proto._render=function(state){ + var drawVertexCount=0; + var glContext=WebGL.mainContext; + if (this._firstActiveElement < this._firstFreeElement){ + drawVertexCount=(this._firstFreeElement-this._firstActiveElement)*6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + }else { + drawVertexCount=(this._maxParticles-this._firstActiveElement)*6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + if (this._firstFreeElement > 0){ + drawVertexCount=this._firstFreeElement *6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + } + } + } + + /**当前粒子时间。*/ + __getset(0,__proto,'currentTime',function(){ + return this._currentTime; + }); + + __getset(0,__proto,'indexOfHost',function(){ + return 0; + }); + + /**设置最大粒子数,注意:谨慎修改此属性,有性能损耗。*/ + /**获取最大粒子数。*/ + __getset(0,__proto,'maxParticles',function(){ + return this._maxParticles-1; + },function(value){ + var newMaxParticles=value+1; + if (newMaxParticles!==this._maxParticles){ + this._maxParticles=newMaxParticles; + if (this._vertexBuffer){ + this._vertexBuffer.dispose(); + this._indexBuffer.dispose(); + } + this._initPartVertexDatas(); + this._initIndexDatas(); + } + }); + + /** + *是否存活。 + */ + __getset(0,__proto,'isAlive',function(){ + if (this._emission.isPlaying || this._aliveParticleCount > 0) + return true; + return false; + }); + + /** + *设置形状。 + */ + /** + *获取形状。 + */ + __getset(0,__proto,'shape',function(){ + return this._shape; + },function(value){ + this._shape=value; + this._emission._shape=value; + }); + + /** + *设置发射器。 + */ + /** + *获取发射器。 + */ + __getset(0,__proto,'emission',function(){ + return this._emission; + },function(value){ + this._emission=value; + value._particleSystem=this; + value._shape=this._shape; + }); + + /** + *粒子存活个数。 + */ + __getset(0,__proto,'aliveParticleCount',function(){ + return this._aliveParticleCount; + }); + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer.indexCount / 3; + }); + + return ShurikenParticleSystem; + })() + + + /** + *@private + *PhasorSpriter3D 类用于创建矢量笔刷。 + */ + //class laya.d3.core.PhasorSpriter3D + var PhasorSpriter3D=(function(){ + function PhasorSpriter3D(){ + this._tempInt0=0; + this._tempInt1=0; + this._tempUint0=0; + this._tempUint1=0; + this._tempUint2=0; + this._tempUint3=0; + this._tempUint4=0; + this._tempUint5=0; + this._tempUint6=0; + this._tempUint7=0; + this._tempNumver0=NaN; + this._tempNumver1=NaN; + this._tempNumver2=NaN; + this._tempNumver3=NaN; + this._floatSizePerVer=7; + this._defaultBufferSize=600 *this._floatSizePerVer; + this._vb=null; + this._posInVBData=0; + this._ib=null; + this._posInIBData=0; + this._primitiveType=NaN; + this._hasBegun=false; + this._numVertsPerPrimitive=0; + this._renderState=null; + this._sharderNameID=0; + this._shader=null; + this._posShaderValue=[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,28,0]; + this._colorShaderValue=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,28,12]; + this._albedo=new Vector4(1.0,1.0,1.0,1.0); + this._vbData=new Float32Array(this._defaultBufferSize); + this._ibData=new Uint16Array(this._defaultBufferSize); + this._wvpMatrix=new Matrix4x4(); + ; + this._vb=new VertexBuffer2D(-1,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._ib=new IndexBuffer2D(); + this._sharderNameID=Shader.nameKey.get("SIMPLE"); + } + + __class(PhasorSpriter3D,'laya.d3.core.PhasorSpriter3D'); + var __proto=PhasorSpriter3D.prototype; + __proto.line=function(startX,startY,startZ,startR,startG,startB,startA,endX,endY,endZ,endR,endG,endB,endA){ + if (!this._hasBegun || this._primitiveType!==/*laya.webgl.WebGLContext.LINES*/0x0001) + this.drawLinesException(); + if (this._posInVBData+2 *this._floatSizePerVer > this._vbData.length || this._posInIBData+2 > this._ibData.length) + this.flush(); + this._tempUint0=this._posInVBData / this._floatSizePerVer; + this.addVertex(startX,startY,startZ,startR,startG,startB,startA); + this.addVertex(endX,endY,endZ,endR,endG,endB,endA); + this.addIndexes(this._tempUint0,this._tempUint0+1); + return this; + } + + __proto.circle=function(radius,numberOfPoints,r,g,b,a){ + if (!this._hasBegun || (this._primitiveType!==/*laya.webgl.WebGLContext.LINES*/0x0001)) + this.drawLinesException(); + this._tempUint0=numberOfPoints *2; + if (this._posInVBData+this._tempUint0 *this._floatSizePerVer > this._vbData.length || this._posInIBData+2 *this._tempUint0 > this._ibData.length) + this.flush(); + this._tempUint1=this._posInVBData / this._floatSizePerVer; + for (this._tempNumver0=0,this._tempInt0=0;this._tempNumver0 < 3.1416 *2;this._tempNumver0=this._tempNumver0+(3.1416 / numberOfPoints),this._tempInt0++){ + this.addVertex(Math.sin(this._tempNumver0)*radius,Math.cos(this._tempNumver0)*radius,0,r,g,b,a); + if (this._tempInt0===0){ + this.addIndexes(this._tempUint1); + }else if (this._tempInt0===this._tempUint0-1){ + this._tempUint2=this._tempUint1+this._tempInt0; + this.addIndexes(this._tempUint2,this._tempUint2,this._tempUint1); + }else { + this._tempUint2=this._tempUint1+this._tempInt0; + this.addIndexes(this._tempUint2,this._tempUint2); + } + } + return this; + } + + __proto.plane=function(positionX,positionY,positionZ,width,height,r,g,b,a){ + if (!this._hasBegun || this._primitiveType!==/*laya.webgl.WebGLContext.TRIANGLES*/0x0004) + this.drawTrianglesException(); + if (this._posInVBData+4 *this._floatSizePerVer > this._vbData.length || this._posInIBData+6 > this._ibData.length) + this.flush(); + this._tempNumver0=width / 2; + this._tempNumver1=height / 2; + this._tempUint0=this._posInVBData / this._floatSizePerVer; + this.addVertex(positionX-this._tempNumver0,positionY+this._tempNumver1,positionZ,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY+this._tempNumver1,positionZ,r,g,b,a); + this.addVertex(positionX-this._tempNumver0,positionY-this._tempNumver1,positionZ,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY-this._tempNumver1,positionZ,r,g,b,a); + this._tempUint1=this._tempUint0+1; + this._tempUint2=this._tempUint0+2; + this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint0+3); + return this; + } + + __proto.box=function(positionX,positionY,positionZ,width,height,depth,r,g,b,a){ + if (!this._hasBegun || this._primitiveType!==/*laya.webgl.WebGLContext.TRIANGLES*/0x0004) + this.drawTrianglesException(); + if (this._posInVBData+8 *this._floatSizePerVer > this._vbData.length || this._posInIBData+36 > this._ibData.length) + this.flush(); + this._tempNumver0=width / 2; + this._tempNumver1=height / 2; + this._tempNumver2=depth / 2; + this._tempUint0=this._posInVBData / this._floatSizePerVer; + this.addVertex(positionX-this._tempNumver0,positionY+this._tempNumver1,positionZ+this._tempNumver2,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY+this._tempNumver1,positionZ+this._tempNumver2,r,g,b,a); + this.addVertex(positionX-this._tempNumver0,positionY-this._tempNumver1,positionZ+this._tempNumver2,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY-this._tempNumver1,positionZ+this._tempNumver2,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY+this._tempNumver1,positionZ-this._tempNumver2,r,g,b,a); + this.addVertex(positionX-this._tempNumver0,positionY+this._tempNumver1,positionZ-this._tempNumver2,r,g,b,a); + this.addVertex(positionX+this._tempNumver0,positionY-this._tempNumver1,positionZ-this._tempNumver2,r,g,b,a); + this.addVertex(positionX-this._tempNumver0,positionY-this._tempNumver1,positionZ-this._tempNumver2,r,g,b,a); + this._tempUint1=this._tempUint0+1; + this._tempUint2=this._tempUint0+2; + this._tempUint3=this._tempUint0+3; + this._tempUint4=this._tempUint0+4; + this._tempUint5=this._tempUint0+5; + this._tempUint6=this._tempUint0+6; + this._tempUint7=this._tempUint0+7; + this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint3, + this._tempUint4,this._tempUint5,this._tempUint6,this._tempUint6,this._tempUint5,this._tempUint7, + this._tempUint5,this._tempUint0,this._tempUint7,this._tempUint7,this._tempUint0,this._tempUint2, + this._tempUint1,this._tempUint4,this._tempUint3,this._tempUint3,this._tempUint4,this._tempUint6, + this._tempUint5,this._tempUint4,this._tempUint0,this._tempUint0,this._tempUint4,this._tempUint1, + this._tempUint2,this._tempUint3,this._tempUint7,this._tempUint7,this._tempUint3,this._tempUint6); + return this; + } + + __proto.cone=function(radius,length,Slices,r,g,b,a){ + if (!this._hasBegun || this._primitiveType!==/*laya.webgl.WebGLContext.TRIANGLES*/0x0004) + this.drawTrianglesException(); + if (this._posInVBData+(2 *Slices+2)*this._floatSizePerVer > this._vbData.length || this._posInIBData+6 *Slices > this._ibData.length) + this.flush(); + this._tempUint0=this._posInVBData; + this._tempUint1=this._posInVBData / this._floatSizePerVer; + this._tempNumver0=Math.PI *2 / Slices; + this.addVertexIndex(0,length,0,r,g,b,a,this._tempUint0); + this.addVertexIndex(0,0,0,r,g,b,a,this._tempUint0+this._floatSizePerVer); + this._tempInt0=2; + this._tempNumver1=0; + for (this._tempInt1=0;this._tempInt1 < Slices;this._tempInt1++){ + this._tempNumver2=Math.cos(this._tempNumver1); + this._tempNumver3=Math.sin(this._tempNumver1); + this.addVertexIndex(radius *this._tempNumver2,0,radius *this._tempNumver3,r,g,b,a,this._tempUint0+this._tempInt0 *this._floatSizePerVer); + this.addIndexes(this._tempUint1,this._tempUint1+this._tempInt0); + if (this._tempInt1==Slices-1) + this.addIndexes(this._tempUint1+2); + else + this.addIndexes(this._tempUint1+this._tempInt0+1); + this.addVertexIndex(radius *this._tempNumver2,0,radius *this._tempNumver3,r,g,b,a,this._tempUint0+(this._tempInt0+Slices)*this._floatSizePerVer); + this.addIndexes(this._tempUint1+1); + if (this._tempInt1==Slices-1) + this.addIndexes(this._tempUint1+Slices+2); + else + this.addIndexes(this._tempUint1+this._tempInt0+Slices+1); + this.addIndexes(this._tempUint1+this._tempInt0+Slices); + this._tempInt0++; + this._tempNumver1+=this._tempNumver0; + } + return this; + } + + __proto.boundingBoxLine=function(minX,minY,minZ,maxX,maxY,maxZ,r,g,b,a){ + if (!this._hasBegun || this._primitiveType!==/*laya.webgl.WebGLContext.LINES*/0x0001) + this.drawLinesException(); + if (this._posInVBData+8 *this._floatSizePerVer > this._vbData.length || this._posInIBData+48 > this._ibData.length) + this.flush(); + this._tempUint0=this._posInVBData / this._floatSizePerVer; + this.addVertex(minX,maxY,maxZ,r,g,b,a); + this.addVertex(maxX,maxY,maxZ,r,g,b,a); + this.addVertex(minX,minY,maxZ,r,g,b,a); + this.addVertex(maxX,minY,maxZ,r,g,b,a); + this.addVertex(maxX,maxY,minZ,r,g,b,a); + this.addVertex(minX,maxY,minZ,r,g,b,a); + this.addVertex(maxX,minY,minZ,r,g,b,a); + this.addVertex(minX,minY,minZ,r,g,b,a); + this._tempUint1=this._tempUint0+1; + this._tempUint2=this._tempUint0+2; + this._tempUint3=this._tempUint0+3; + this._tempUint4=this._tempUint0+4; + this._tempUint5=this._tempUint0+5; + this._tempUint6=this._tempUint0+6; + this._tempUint7=this._tempUint0+7; + this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint1,this._tempUint3,this._tempUint3,this._tempUint2,this._tempUint2,this._tempUint0, + this._tempUint4,this._tempUint5,this._tempUint5,this._tempUint7,this._tempUint7,this._tempUint6,this._tempUint6,this._tempUint4, + this._tempUint5,this._tempUint0,this._tempUint0,this._tempUint2,this._tempUint2,this._tempUint7,this._tempUint7,this._tempUint5, + this._tempUint1,this._tempUint4,this._tempUint4,this._tempUint6,this._tempUint6,this._tempUint3,this._tempUint3,this._tempUint1, + this._tempUint5,this._tempUint4,this._tempUint4,this._tempUint1,this._tempUint1,this._tempUint0,this._tempUint0,this._tempUint5, + this._tempUint2,this._tempUint3,this._tempUint3,this._tempUint6,this._tempUint6,this._tempUint7,this._tempUint7,this._tempUint2); + return this; + } + + __proto.addVertex=function(x,y,z,r,g,b,a){ + if (!this._hasBegun) + this.addVertexIndexException(); + this._vbData[this._posInVBData]=x,this._vbData[this._posInVBData+1]=y,this._vbData[this._posInVBData+2]=z; + this._vbData[this._posInVBData+3]=r,this._vbData[this._posInVBData+4]=g,this._vbData[this._posInVBData+5]=b,this._vbData[this._posInVBData+6]=a; + this._posInVBData+=this._floatSizePerVer; + return this; + } + + __proto.addVertexIndex=function(x,y,z,r,g,b,a,index){ + if (!this._hasBegun) + this.addVertexIndexException(); + this._vbData[index]=x,this._vbData[index+1]=y,this._vbData[index+2]=z; + this._vbData[index+3]=r,this._vbData[index+4]=g,this._vbData[index+5]=b,this._vbData[index+6]=a; + index+=this._floatSizePerVer; + if (index > this._posInVBData) + this._posInVBData=index; + return this; + } + + __proto.addIndexes=function(__indexes){ + var indexes=arguments; + if (!this._hasBegun) + this.addVertexIndexException(); + for (var i=0;i < indexes.length;i++){ + this._ibData[this._posInIBData]=indexes[i]; + this._posInIBData++; + } + return this; + } + + __proto.begin=function(primitive,wvpMatrix,renState){ + if (this._hasBegun) + this.beginException0(); + if (primitive!==/*laya.webgl.WebGLContext.LINES*/0x0001 && primitive!==/*laya.webgl.WebGLContext.TRIANGLES*/0x0004) + this.beginException1(); + this._primitiveType=primitive; + this._wvpMatrix=wvpMatrix; + this._renderState=renState; + this._hasBegun=true; + return this; + } + + __proto.end=function(){ + if (!this._hasBegun) + this.endException(); + this.flush(); + this._hasBegun=false; + return this; + } + + __proto.flush=function(){ + if (this._posInVBData===0) + return; + this._ib.clear(); + this._ib.append(this._ibData); + this._vb.clear(); + this._vb.append(this._vbData); + this._vb.bind_upload(this._ib); + var presz=this._renderState.shaderValue.length; + var predef=this._renderState.shaderDefines.getValue(); + this._shader=this.getShader(this._renderState); + this._renderState.shaderValue.pushValue(/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION",this._posShaderValue); + this._renderState.shaderValue.pushValue(/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR",this._colorShaderValue); + this._renderState.shaderValue.pushValue(/*laya.d3.core.material.StandardMaterial.MVPMATRIX*/"MVPMATRIX",this._wvpMatrix.elements); + this._renderState.shaderValue.pushValue(/*laya.d3.core.material.StandardMaterial.ALBEDO*/"ALBEDO",this._albedo.elements); + this._shader.uploadArray(this._renderState.shaderValue.data,this._renderState.shaderValue.length,null); + this._renderState.shaderDefines.setValue(predef); + this._renderState.shaderValue.length=presz; + Stat.drawCall++; + WebGL.mainContext.drawElements(this._primitiveType,this._posInIBData,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + this._posInIBData=0; + this._posInVBData=0; + } + + __proto.getShader=function(state){ + var preDef=state.shaderDefines._value; + state.shaderDefines._value=preDef & (~(/*laya.d3.shader.ShaderDefines3D.POINTLIGHT*/0x2000 | /*laya.d3.shader.ShaderDefines3D.SPOTLIGHT*/0x4000 | /*laya.d3.shader.ShaderDefines3D.DIRECTIONLIGHT*/0x1000)); + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.COLOR*/0x800); + var nameID=state.shaderDefines.getValue()+this._sharderNameID */*laya.webgl.shader.Shader.SHADERNAME2ID*/0.0002; + var shader=this._shader ? this._shader :Shader.getShader(nameID); + return shader || (shader=Shader.withCompile(this._sharderNameID,state.shaderDefines.toNameDic(),nameID,null)); + } + + __proto.addVertexIndexException=function(){ + throw new Error("请先调用begin()函数"); + } + + __proto.beginException0=function(){ + throw new Error("调用begin()前请确保已成功调用end()!"); + } + + __proto.beginException1=function(){ + throw new Error("只支持“LINES”和“TRIANGLES”两种基元!"); + } + + __proto.endException=function(){ + throw new Error("调用end()前请确保已成功调用begin()!"); + } + + __proto.drawLinesException=function(){ + throw new Error("您必须确保在此之前已调用begin()且使用“LINES”基元!"); + } + + __proto.drawTrianglesException=function(){ + throw new Error("您必须确保在此之前已调用begin()且使用“TRIANGLES”基元!"); + } + + return PhasorSpriter3D; + })() + + + /** + *RenderConfig 类用于实现渲染配置。 + */ + //class laya.d3.core.render.RenderConfig + var RenderConfig=(function(){ + function RenderConfig(){ + this.depthTest=true; + this.depthMask=1; + this.blend=false; + this.cullFace=true; + this.sFactor=/*laya.webgl.WebGLContext.ONE*/1; + this.dFactor=/*laya.webgl.WebGLContext.ZERO*/0; + this.frontFace=/*laya.webgl.WebGLContext.CW*/0x0900; + } + + __class(RenderConfig,'laya.d3.core.render.RenderConfig'); + return RenderConfig; + })() + + + /** + *@private + *RenderElement 类用于实现渲染物体。 + */ + //class laya.d3.core.render.RenderElement + var RenderElement=(function(){ + function RenderElement(){ + this._type=0; + this._mainSortID=0; + this._renderObject=null; + this._sprite3D=null; + this._material=null; + this._renderObj=null; + this._staticBatch=null; + this._batchIndexStart=0; + this._batchIndexEnd=0; + this._canDynamicBatch=false; + this._canDynamicBatch=true; + } + + __class(RenderElement,'laya.d3.core.render.RenderElement'); + var __proto=RenderElement.prototype; + /** + *@private + */ + __proto.getStaticBatchBakedVertexs=function(index){ + var byteSizeInFloat=4; + var vb=this._renderObj._getVertexBuffer(index); + var bakedVertexes=vb.getData().slice(); + var vertexDeclaration=vb.vertexDeclaration; + var positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION").offset / byteSizeInFloat; + var normalOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL").offset / byteSizeInFloat; + var rootTransform=this._staticBatch._rootSprite.transform.worldMatrix; + var transform=this._sprite3D.transform.worldMatrix; + var rootInvertMat=RenderElement._tempMatrix4x40; + var result=RenderElement._tempMatrix4x41; + rootTransform.invert(rootInvertMat); + Matrix4x4.multiply(rootInvertMat,transform,result); + var rotation=RenderElement._tempQuaternion0; + result.decompose(RenderElement._tempVector30,rotation,RenderElement._tempVector31); + var vertexFloatCount=vertexDeclaration.vertexStride / byteSizeInFloat; + for (var i=0,n=bakedVertexes.length;i < n;i+=vertexFloatCount){ + var posOffset=i+positionOffset; + var norOffset=i+normalOffset; + Utils3D.transformVector3ArrayToVector3ArrayCoordinate(bakedVertexes,posOffset,result,bakedVertexes,posOffset); + Utils3D.transformVector3ArrayByQuat(bakedVertexes,normalOffset,rotation,bakedVertexes,normalOffset); + } + return bakedVertexes; + } + + /** + *@private + */ + __proto.getDynamicBatchBakedVertexs=function(index){ + var byteSizeInFloat=4; + var vb=this._renderObj._getVertexBuffer(index); + var bakedVertexes=vb.getData().slice(); + var vertexDeclaration=vb.vertexDeclaration; + var positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION").offset / byteSizeInFloat; + var normalOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL").offset / byteSizeInFloat; + var transform=this._sprite3D.transform; + var worldMatrix=transform.worldMatrix; + var rotation=transform.rotation; + var vertexFloatCount=vertexDeclaration.vertexStride / byteSizeInFloat; + for (var i=0,n=bakedVertexes.length;i < n;i+=vertexFloatCount){ + var posOffset=i+positionOffset; + var norOffset=i+normalOffset; + Utils3D.transformVector3ArrayToVector3ArrayCoordinate(bakedVertexes,posOffset,worldMatrix,bakedVertexes,posOffset); + Utils3D.transformVector3ArrayByQuat(bakedVertexes,normalOffset,rotation,bakedVertexes,normalOffset); + } + return bakedVertexes; + } + + /** + *@private + */ + __proto.getBakedIndices=function(){ + return this._renderObj._getIndexBuffer().getData(); + } + + __getset(0,__proto,'renderObj',function(){ + return this._renderObj; + },function(value){ + if (this._renderObj!==value){ + this._renderObj=value; + } + }); + + __static(RenderElement, + ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();},'_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_tempMatrix4x41',function(){return this._tempMatrix4x41=new Matrix4x4();} + ]); + return RenderElement; + })() + + + /** + *@private + *RenderQuene 类用于实现渲染队列。 + */ + //class laya.d3.core.render.RenderQueue + var RenderQueue=(function(){ + function RenderQueue(renderConfig,scene){ + this._id=0; + this._needSort=false; + this._renderElements=null; + this._staticBatches=null; + this._renderableRenderObjects=null; + this._renderConfig=null; + this._staticBatchCombineRenderElements=null; + this._dynamicBatchCombineRenderElements=null; + this._finalElements=null; + this._scene=null; + this._id=++RenderQueue._uniqueIDCounter; + this._needSort=false; + this._renderConfig=renderConfig; + this._scene=scene; + this._renderElements=[]; + this._renderableRenderObjects=[]; + this._staticBatchCombineRenderElements=[]; + this._dynamicBatchCombineRenderElements=[]; + this._staticBatches=[]; + } + + __class(RenderQueue,'laya.d3.core.render.RenderQueue'); + var __proto=RenderQueue.prototype; + __proto._sortAlphaFunc=function(a,b){ + if (a._renderObject && b._renderObject) + return Vector3.distance(b._renderObject._boundingSphere.center,RenderQueue._cameraPosition)-Vector3.distance(a._renderObject._boundingSphere.center,RenderQueue._cameraPosition); + else + return 0; + } + + /** + *@private + */ + __proto._begainRenderElement=function(state,renderObj,material){ + if (renderObj._beforeRender(state)){ + state.shaderValue.pushArray(renderObj._getVertexBuffer(0).vertexDeclaration.shaderValues); + return true; + } + return false; + } + + /** + *@private + */ + __proto._endRenderElement=function(state,renderObj,material){ + material._upload(state,renderObj._getVertexBuffer(0).vertexDeclaration,null); + renderObj._render(state); + } + + /** + *@private + *更新组件preRenderUpdate函数 + *@param state 渲染相关状态 + */ + __proto._preRenderUpdateComponents=function(sprite3D,state){ + for (var i=0;i < sprite3D.componentsCount;i++){ + var component=sprite3D.getComponentByIndex(i); + (!component.started)&& (component._start(state),component.started=true); + (component.isActive)&& (component._preRenderUpdate(state)); + } + } + + /** + *@private + *更新组件postRenderUpdate函数 + *@param state 渲染相关状态 + */ + __proto._postRenderUpdateComponents=function(sprite3D,state){ + for (var i=0;i < sprite3D.componentsCount;i++){ + var component=sprite3D.getComponentByIndex(i); + (!component.started)&& (component._start(state),component.started=true); + (component.isActive)&& (component._postRenderUpdate(state)); + } + } + + /** + *@private + */ + __proto._sortAlpha=function(cameraPos){ + RenderQueue._cameraPosition=cameraPos; + this._finalElements.sort(this._sortAlphaFunc); + } + + /** + *@private + *应用渲染状态到显卡。 + *@param gl WebGL上下文。 + */ + __proto._setState=function(gl,state){ + WebGLContext.setDepthTest(gl,this._renderConfig.depthTest); + WebGLContext.setDepthMask(gl,this._renderConfig.depthMask); + WebGLContext.setBlend(gl,this._renderConfig.blend); + WebGLContext.setBlendFunc(gl,this._renderConfig.sFactor,this._renderConfig.dFactor); + WebGLContext.setCullFace(gl,this._renderConfig.cullFace); + if (state.camera.renderTarget) + WebGLContext.setFrontFaceCCW(gl,this._renderConfig.frontFace===/*laya.webgl.WebGLContext.CW*/0x0900 ? /*laya.webgl.WebGLContext.CCW*/0x0901 :/*laya.webgl.WebGLContext.CW*/0x0900); + else + WebGLContext.setFrontFaceCCW(gl,this._renderConfig.frontFace); + } + + /** + *@private + *准备渲染队列。 + *@param state 渲染状态。 + */ + __proto._preRender=function(state){ + this._staticBatchCombineRenderElements.length=0; + for (var i=0,n=this._staticBatches.length;i < n;i++) + this._staticBatches[i]._getRenderElement(this._staticBatchCombineRenderElements); + this._finalElements=this._renderElements.concat(this._staticBatchCombineRenderElements,this._dynamicBatchCombineRenderElements); + } + + /** + *@private + *渲染队列。 + *@param state 渲染状态。 + */ + __proto._render=function(state){ + var preShaderValue=state.shaderValue.length; + var preShadeDef=state.shaderDefines.getValue(); + for (var i=0,n=this._finalElements.length;i < n;i++){ + var renderElement=this._finalElements[i]; + var renderObj,material; + if (renderElement._type===0){ + var owner=renderElement._sprite3D; + state.owner=owner; + state.renderElement=renderElement; + this._preRenderUpdateComponents(owner,state); + renderObj=renderElement.renderObj,material=renderElement._material; + if (this._begainRenderElement(state,renderObj,material)){ + material._setLoopShaderParams(state,state.projectionViewMatrix,owner.transform.worldMatrix,renderElement.renderObj,material); + this._endRenderElement(state,renderObj,material); + } + this._postRenderUpdateComponents(owner,state); + }else if (renderElement._type===1){ + var staticBatch=renderElement.renderObj; + state.owner=null; + state.renderElement=renderElement; + state._batchIndexStart=renderElement._batchIndexStart; + state._batchIndexEnd=renderElement._batchIndexEnd; + renderObj=renderElement.renderObj,material=renderElement._material; + if (this._begainRenderElement(state,renderObj,material)){ + renderElement._material._setLoopShaderParams(state,state.projectionViewMatrix,staticBatch._rootSprite.transform.worldMatrix,renderElement.renderObj,renderElement._material); + this._endRenderElement(state,renderObj,material); + } + }else if (renderElement._type===2){ + var dynamicBatch=renderElement.renderObj; + state.owner=null; + state.renderElement=renderElement; + state._batchIndexStart=renderElement._batchIndexStart; + state._batchIndexEnd=renderElement._batchIndexEnd; + renderObj=renderElement.renderObj,material=renderElement._material; + if (this._begainRenderElement(state,renderObj,material)){ + renderElement._material._setLoopShaderParams(state,state.projectionViewMatrix,Matrix4x4.DEFAULT,renderElement.renderObj,renderElement._material); + this._endRenderElement(state,renderObj,material); + } + } + state.shaderDefines.setValue(preShadeDef); + state.shaderValue.length=preShaderValue; + } + } + + /** + *清空队列中的渲染物体。 + */ + __proto._clearRenderElements=function(){ + this._staticBatches.length=0; + this._dynamicBatchCombineRenderElements.length=0; + this._renderElements.length=0; + this._needSort=true; + } + + /** + *添加渲染物体。 + *@param renderObj 渲染物体。 + */ + __proto._addRenderElement=function(renderElement){ + this._renderElements.push(renderElement); + this._needSort=true; + } + + /** + *添加静态批处理。 + *@param renderObj 静态批处理。 + */ + __proto._addStaticBatch=function(staticBatch){ + this._staticBatches.push(staticBatch) + } + + /** + *添加动态批处理。 + *@param renderObj 动态批处理。 + */ + __proto._addDynamicBatchElement=function(dynamicBatchElement){ + this._dynamicBatchCombineRenderElements.push(dynamicBatchElement); + } + + /** + *获取唯一标识ID(通常用于优化或识别)。 + */ + __getset(0,__proto,'id',function(){ + return this._id; + }); + + RenderQueue._uniqueIDCounter=0; + RenderQueue.OPAQUE=1; + RenderQueue.OPAQUE_DOUBLEFACE=2; + RenderQueue.ALPHA_BLEND=3; + RenderQueue.ALPHA_BLEND_DOUBLEFACE=4; + RenderQueue.ALPHA_ADDTIVE_BLEND=5; + RenderQueue.ALPHA_ADDTIVE_BLEND_DOUBLEFACE=6; + RenderQueue.DEPTHREAD_ALPHA_BLEND=7; + RenderQueue.DEPTHREAD_ALPHA_BLEND_DOUBLEFACE=8; + RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND=9; + RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=10; + RenderQueue.NONDEPTH_ALPHA_BLEND=11; + RenderQueue.NONDEPTH_ALPHA_BLEND_DOUBLEFACE=12; + RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND=13; + RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=14; + RenderQueue._cameraPosition=null + return RenderQueue; + })() + + + /** + *RenderState 类用于实现渲染状态。 + */ + //class laya.d3.core.render.RenderState + var RenderState=(function(){ + function RenderState(){ + this.elapsedTime=NaN; + this.loopCount=0; + this.context=null; + this.scene=null; + this.owner=null; + this.renderElement=null; + this._staticBatch=null; + this._batchIndexStart=0; + this._batchIndexEnd=0; + this.camera=null; + this.viewMatrix=null; + this.projectionMatrix=null; + this.projectionViewMatrix=null; + this.cameraBoundingFrustum=null; + this.viewport=null; + this.shaderValue=new ValusArray; + this.shaderDefines=new ShaderDefines3D(); + this.reset(); + } + + __class(RenderState,'laya.d3.core.render.RenderState'); + var __proto=RenderState.prototype; + /** + *重置。 + */ + __proto.reset=function(){ + this.shaderValue.length=0; + this.shaderDefines.setValue(0); + } + + RenderState.VERTEXSHADERING=0x04; + RenderState.PIXELSHADERING=0x08; + RenderState.clientWidth=0; + RenderState.clientHeight=0; + return RenderState; + })() + + + /** + *@private + *DynamicBatch 类用于动态批处理。 + */ + //class laya.d3.graphics.DynamicBatch + var DynamicBatch=(function(){ + function DynamicBatch(vertexDeclaration){ + this._vertexDeclaration=null; + this._vertexDatas=null; + this._indexDatas=null; + this._vertexBuffer=null; + this._indexBuffer=null; + this._currentCombineVertexCount=0; + this._currentCombineIndexCount=0; + this._combineRenderElements=null; + this._materials=null; + this._materialToRenderElementsOffsets=null; + this._merageElements=null; + this._combineRenderElementPool=null; + this._combineRenderElementPoolIndex=0; + this._currentCombineVertexCount=0; + this._currentCombineIndexCount=0; + this._combineRenderElements=[]; + this._materialToRenderElementsOffsets=[]; + this._materials=[]; + this._merageElements=[]; + this._combineRenderElementPool=[]; + this._combineRenderElementPoolIndex=0; + this._vertexDeclaration=vertexDeclaration; + } + + __class(DynamicBatch,'laya.d3.graphics.DynamicBatch'); + var __proto=DynamicBatch.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return this._indexBuffer; + } + + __proto._getCombineRenderElementFromPool=function(){ + var renderElement=this._combineRenderElementPool[this._combineRenderElementPoolIndex++]; + return renderElement || (this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new RenderElement()); + } + + __proto._getRenderElement=function(){ + if (!this._vertexDatas){ + this._vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride / 4 *DynamicBatch.maxVertexCount); + this._indexDatas=new Uint16Array(DynamicBatch.maxIndexCount); + this._vertexBuffer=VertexBuffer3D.create(this._vertexDeclaration,DynamicBatch.maxVertexCount,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._indexBuffer=IndexBuffer3D.create(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",DynamicBatch.maxIndexCount,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + } + this._merageElements.length=0; + var curMerVerCount=0; + var curIndexCount=0; + for (var i=0,n=this._combineRenderElements.length;i < n;i++){ + var renderElement=this._combineRenderElements[i]; + var subVertexDatas=renderElement.getDynamicBatchBakedVertexs(0); + var subIndexDatas=renderElement.getBakedIndices(); + var indexOffset=curMerVerCount / (this._vertexDeclaration.vertexStride / 4); + var indexStart=curIndexCount; + var indexEnd=indexStart+subIndexDatas.length; + renderElement._batchIndexStart=indexStart; + renderElement._batchIndexEnd=indexEnd; + this._indexDatas.set(subIndexDatas,curIndexCount); + for (var k=indexStart;k < indexEnd;k++) + this._indexDatas[k]=indexOffset+this._indexDatas[k]; + curIndexCount+=subIndexDatas.length; + this._vertexDatas.set(subVertexDatas,curMerVerCount); + curMerVerCount+=subVertexDatas.length; + } + this._vertexBuffer.setData(this._vertexDatas); + this._indexBuffer.setData(this._indexDatas); + this._combineRenderElementPoolIndex=0; + for (i=0,n=this._materials.length;i < n;i++){ + var merageElement=this._getCombineRenderElementFromPool(); + merageElement._type=2; + merageElement._staticBatch=null; + merageElement.renderObj=this; + var renderElementStartIndex=this._combineRenderElements[this._materialToRenderElementsOffsets[i]]._batchIndexStart; + var renderElementEndIndex=(i+1===this._materialToRenderElementsOffsets.length)? curIndexCount :this._combineRenderElements[this._materialToRenderElementsOffsets[i+1]]._batchIndexStart; + merageElement._batchIndexStart=renderElementStartIndex; + merageElement._batchIndexEnd=renderElementEndIndex; + merageElement._material=this._materials[i]; + this._merageElements.push(merageElement); + } + } + + __proto._addCombineRenderObjTest=function(renderElement){ + var renderObj=renderElement.renderObj; + var indexCount=this._currentCombineIndexCount+renderObj._getIndexBuffer().indexCount; + var vertexCount=this._currentCombineVertexCount+renderObj._getVertexBuffer().vertexCount; + if (vertexCount > DynamicBatch.maxVertexCount || indexCount > DynamicBatch.maxIndexCount){ + return false; + } + return true; + } + + __proto._addCombineRenderObj=function(renderElement){ + var renderObj=renderElement.renderObj; + this._combineRenderElements.push(renderElement); + this._currentCombineIndexCount=this._currentCombineIndexCount+renderObj._getIndexBuffer().indexCount; + this._currentCombineVertexCount=this._currentCombineVertexCount+renderObj._getVertexBuffer().vertexCount; + } + + __proto._addCombineMaterial=function(material){ + this._materials.push(material); + } + + __proto._addMaterialToRenderElementOffset=function(offset){ + this._materialToRenderElementsOffsets.push(offset); + } + + __proto._clearRenderElements=function(){ + this._combineRenderElements.length=0; + this._materials.length=0; + this._materialToRenderElementsOffsets.length=0; + this._currentCombineVertexCount=0; + this._currentCombineIndexCount=0; + } + + __proto._addToRenderQueue=function(scene){ + this._getRenderElement(); + for (var i=0,n=this._materials.length;i < n;i++) + scene.getRenderQueue(this._materials[i].renderQueue)._addDynamicBatchElement(this._merageElements[i]); + } + + __proto._beforeRender=function(state){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + return true; + } + + __proto._render=function(state){ + var indexCount=state._batchIndexEnd-state._batchIndexStart; + state.context.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,state._batchIndexStart *2); + Stat.drawCall++; + Stat.trianglesFaces+=indexCount / 3; + } + + __getset(0,__proto,'indexOfHost',function(){ + return 0; + }); + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer.indexCount / 3; + }); + + __getset(0,__proto,'combineRenderElementsCount',function(){ + return this._combineRenderElements.length; + }); + + DynamicBatch.maxVertexCount=20000; + DynamicBatch.maxIndexCount=40000; + DynamicBatch.maxCombineTriangleCount=50; + return DynamicBatch; + })() + + + /** + *@private + *DynamicBatchManager 类用于管理动态批处理。 + */ + //class laya.d3.graphics.DynamicBatchManager + var DynamicBatchManager=(function(){ + function DynamicBatchManager(){ + this._dynamicBatches=null; + this._prepareDynamicBatchCombineElements=null; + this._dynamicBatches={}; + this._prepareDynamicBatchCombineElements=[]; + } + + __class(DynamicBatchManager,'laya.d3.graphics.DynamicBatchManager'); + var __proto=DynamicBatchManager.prototype; + __proto.getDynamicBatch=function(_vertexDeclaration,number){ + var dynamicBatch; + var key=_vertexDeclaration.id.toString()+number; + if (!this._dynamicBatches[key]){ + this._dynamicBatches[key]=dynamicBatch=new DynamicBatch(_vertexDeclaration); + }else { + dynamicBatch=this._dynamicBatches[key]; + } + return dynamicBatch; + } + + /**需手动调用*/ + __proto._garbageCollection=function(){ + for (var key in this._dynamicBatches) + if (this._dynamicBatches[key].combineRenderElementsCount===0) + delete this._dynamicBatches[key]; + } + + __proto._addPrepareRenderElement=function(renderElement){ + this._prepareDynamicBatchCombineElements.push(renderElement); + } + + /**@private */ + __proto._finishCombineDynamicBatch=function(scene){ + this._prepareDynamicBatchCombineElements.sort(DynamicBatchManager._sortPrepareDynamicBatch); + var lastMaterial; + var lastVertexDeclaration; + var lastRenderElement; + var lastBatchNumber=-1; + var lastCanMerage=true; + var curMaterial; + var curRenderElement; + var curDynamicBatch; + var curbatchNumber=0; + var laterAddMaterial; + var laterAddRenderElement; + var laterAddMatToElementOffset=-1; + for (var i=0,n=this._prepareDynamicBatchCombineElements.length;i < n;i++){ + curRenderElement=this._prepareDynamicBatchCombineElements[i]; + var curDeclaration=curRenderElement.renderObj._getVertexBuffer(0).vertexDeclaration; + var declarationChanged=(lastVertexDeclaration!==curDeclaration); + declarationChanged && (curbatchNumber=0,lastVertexDeclaration=curDeclaration); + var batchNumbrChanged=(curbatchNumber!==lastBatchNumber); + batchNumbrChanged && (lastBatchNumber=curbatchNumber); + if ((declarationChanged)|| batchNumbrChanged){ + curDynamicBatch=this.getDynamicBatch(curDeclaration,curbatchNumber); + lastMaterial=null; + } + if (lastCanMerage){ + if (curDynamicBatch._addCombineRenderObjTest(curRenderElement)){ + curMaterial=curRenderElement._material; + if (lastMaterial!==curMaterial){ + if (laterAddMaterial){ + scene.getRenderQueue(laterAddRenderElement._material.renderQueue)._addRenderElement(laterAddRenderElement); + laterAddMaterial=null; + laterAddRenderElement=null; + laterAddMatToElementOffset=-1; + } + laterAddMaterial=curMaterial; + laterAddMatToElementOffset=curDynamicBatch.combineRenderElementsCount; + laterAddRenderElement=curRenderElement; + lastMaterial=curMaterial; + }else { + if (laterAddMaterial){ + var lastRenderObj=laterAddRenderElement.renderObj; + var curRenderObj=curRenderElement.renderObj; + if (((lastRenderObj._getVertexBuffer().vertexCount+curRenderObj._getVertexBuffer().vertexCount)> DynamicBatch.maxVertexCount)|| ((lastRenderObj._getIndexBuffer().indexCount+curRenderObj._getIndexBuffer().indexCount)> DynamicBatch.maxIndexCount)){ + scene.getRenderQueue(laterAddRenderElement._material.renderQueue)._addRenderElement(laterAddRenderElement); + laterAddMaterial=curMaterial; + laterAddMatToElementOffset=curDynamicBatch.combineRenderElementsCount; + laterAddRenderElement=curRenderElement; + }else { + curDynamicBatch._addCombineMaterial(laterAddMaterial); + curDynamicBatch._addMaterialToRenderElementOffset(laterAddMatToElementOffset); + curDynamicBatch._addCombineRenderObj(laterAddRenderElement); + laterAddMaterial=null; + laterAddRenderElement=null; + laterAddMatToElementOffset=-1; + curDynamicBatch._addCombineRenderObj(curRenderElement); + } + }else { + curDynamicBatch._addCombineRenderObj(curRenderElement); + } + } + lastCanMerage=true; + }else { + if (laterAddMaterial){ + scene.getRenderQueue(laterAddRenderElement._material.renderQueue)._addRenderElement(laterAddRenderElement); + laterAddMaterial=null; + laterAddRenderElement=null; + laterAddMatToElementOffset=-1; + } + curbatchNumber++; + lastCanMerage=false; + } + }else { + lastRenderElement=this._prepareDynamicBatchCombineElements[i-1]; + curDynamicBatch._addMaterialToRenderElementOffset(curDynamicBatch.combineRenderElementsCount); + lastMaterial=lastRenderElement._material; + curDynamicBatch._addCombineMaterial(lastMaterial); + curDynamicBatch._addCombineRenderObj(lastRenderElement); + lastCanMerage=true; + curMaterial=curRenderElement._material; + if (lastMaterial!==curMaterial){ + laterAddMaterial=curMaterial; + laterAddMatToElementOffset=curDynamicBatch.combineRenderElementsCount; + laterAddRenderElement=curRenderElement; + }else { + curDynamicBatch._addCombineRenderObj(curRenderElement); + } + lastMaterial=curMaterial; + } + } + if (laterAddMaterial){ + scene.getRenderQueue(laterAddRenderElement._material.renderQueue)._addRenderElement(laterAddRenderElement); + laterAddMaterial=null; + laterAddRenderElement=null; + laterAddMatToElementOffset=-1; + } + this._prepareDynamicBatchCombineElements.length=0; + } + + __proto._clearRenderElements=function(){ + for (var key in this._dynamicBatches) + this._dynamicBatches[key]._clearRenderElements(); + } + + __proto._addToRenderQueue=function(scene){ + for (var key in this._dynamicBatches){ + var dynamicBatch=this._dynamicBatches[key]; + (dynamicBatch.combineRenderElementsCount > 0)&& (dynamicBatch._addToRenderQueue(scene)); + } + } + + __proto.dispose=function(){ + this._dynamicBatches=null; + } + + DynamicBatchManager._sortPrepareDynamicBatch=function(a,b){ + return a._mainSortID-b._mainSortID; + } + + return DynamicBatchManager; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.graphics.FrustumCulling + var FrustumCulling=(function(){ + function FrustumCulling(){} + __class(FrustumCulling,'laya.d3.graphics.FrustumCulling'); + FrustumCulling.RenderObjectCulling=function(boundFrustum,scene){ + var i=0,iNum=0,j=0,jNum=0; + var frustumCullingObject; + var renderElement; + var curRenderQueue; + var queues=scene._quenes; + var staticBatchMananger=scene._staticBatchManager; + var dynamicBatchManager=scene._dynamicBatchManager; + var frustumCullingObjects=scene._frustumCullingObjects; + for (i=0,iNum=queues.length;i < iNum;i++) + (queues[i])&& (queues[i]._clearRenderElements()); + staticBatchMananger._clearRenderElements(); + dynamicBatchManager._clearRenderElements(); + for (i=0,iNum=frustumCullingObjects.length;i < iNum;i++){ + frustumCullingObject=frustumCullingObjects[i]; + if (Layer.isVisible(frustumCullingObject._layerMask)&& frustumCullingObject._ownerEnable && frustumCullingObject._enable && (boundFrustum.ContainsBoundSphere(frustumCullingObject._boundingSphere)!==/*laya.d3.math.ContainmentType.Disjoint*/0)){ + for (j=0,jNum=frustumCullingObject._renderElements.length;j < jNum;j++){ + renderElement=frustumCullingObject._renderElements[j]; + var staticBatch=renderElement._staticBatch; + if (staticBatch && (staticBatch._material===renderElement._material)){ + staticBatch._addRenderElement(renderElement); + }else { + var renderObj=renderElement.renderObj; + if ((renderObj.triangleCount < /*laya.d3.graphics.DynamicBatch.maxCombineTriangleCount*/50)&& (renderObj._vertexBufferCount===1)&& (renderObj._getIndexBuffer())&&(renderElement._material.renderQueue<3)&&renderElement._canDynamicBatch) + dynamicBatchManager._addPrepareRenderElement(renderElement); + else + scene.getRenderQueue(renderElement._material.renderQueue)._addRenderElement(renderElement); + } + } + } + } + staticBatchMananger._addToRenderQueue(scene); + dynamicBatchManager._finishCombineDynamicBatch(scene); + dynamicBatchManager._addToRenderQueue(scene); + } + + return FrustumCulling; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.graphics.RenderObject + var RenderObject=(function(){ + function RenderObject(){ + this._render=null; + this._renderElements=null; + this._layerMask=0; + this._ownerEnable=false; + this._enable=false; + this._renderElements=[]; + } + + __class(RenderObject,'laya.d3.graphics.RenderObject'); + var __proto=RenderObject.prototype; + __getset(0,__proto,'_boundingSphere',function(){ + return this._render.boundingSphere; + }); + + return RenderObject; + })() + + + /** + *@private + *StaticBatch 类用于静态批处理。 + */ + //class laya.d3.graphics.StaticBatch + var StaticBatch=(function(){ + function StaticBatch(rootSprite,vertexDeclaration,material){ + this._vertexBuffer=null; + this._indexBuffer=null; + this._renderElements=null; + this._combineRenderElementPool=null; + this._combineRenderElementPoolIndex=0; + this._combineRenderElements=null; + this._currentCombineVertexCount=0; + this._currentCombineIndexCount=0; + this._needFinishCombine=false; + this._rootSprite=null; + this._vertexDeclaration=null; + this._material=null; + this._currentCombineVertexCount=0; + this._currentCombineIndexCount=0; + this._needFinishCombine=false; + this._renderElements=[]; + this._combineRenderElements=[]; + this._combineRenderElementPool=[]; + this._combineRenderElementPoolIndex=0; + this._rootSprite=rootSprite; + this._vertexDeclaration=vertexDeclaration; + this._material=material; + } + + __class(StaticBatch,'laya.d3.graphics.StaticBatch'); + var __proto=StaticBatch.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return this._indexBuffer; + } + + __proto._getCombineRenderElementFromPool=function(){ + var renderElement=this._combineRenderElementPool[this._combineRenderElementPoolIndex++]; + return renderElement || (this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new RenderElement()); + } + + __proto._addCombineRenderObjTest=function(renderElement){ + var renderObj=renderElement.renderObj; + var vertexCount=this._currentCombineVertexCount+renderObj._getVertexBuffer().vertexCount; + if (vertexCount > StaticBatch.maxVertexCount){ + return false; + } + return true; + } + + __proto._addCombineRenderObj=function(renderElement){ + var renderObj=renderElement.renderObj; + this._combineRenderElements.push(renderElement); + renderElement._staticBatch=this; + this._currentCombineIndexCount=this._currentCombineIndexCount+renderObj._getIndexBuffer().indexCount; + this._currentCombineVertexCount=this._currentCombineVertexCount+renderObj._getVertexBuffer().vertexCount; + this._needFinishCombine=true; + } + + __proto._deleteCombineRenderObj=function(renderElement){ + var renderObj=renderElement.renderObj; + var index=this._combineRenderElements.indexOf(renderElement); + if (index!==-1){ + this._combineRenderElements.splice(index,1); + renderElement._staticBatch=null; + this._currentCombineIndexCount=this._currentCombineIndexCount-renderObj._getIndexBuffer().indexCount; + this._currentCombineVertexCount=this._currentCombineVertexCount-renderObj._getVertexBuffer().vertexCount; + this._needFinishCombine=true; + } + } + + __proto._finshCombine=function(){ + if (this._needFinishCombine){ + var curMerVerCount=0; + var curIndexCount=0; + var vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride / 4 *this._currentCombineVertexCount); + var indexDatas=new Uint16Array(this._currentCombineIndexCount); + if (this._vertexBuffer){ + this._vertexBuffer.dispose(); + this._indexBuffer.dispose(); + } + this._vertexBuffer=VertexBuffer3D.create(this._vertexDeclaration,this._currentCombineVertexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + this._indexBuffer=IndexBuffer3D.create(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._currentCombineIndexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + for (var i=0,n=this._combineRenderElements.length;i < n;i++){ + var renderElement=this._combineRenderElements[i]; + var subVertexDatas=renderElement.getStaticBatchBakedVertexs(0); + var subIndexDatas=renderElement.getBakedIndices(); + var indexOffset=curMerVerCount / (this._vertexDeclaration.vertexStride / 4); + var indexStart=curIndexCount; + var indexEnd=indexStart+subIndexDatas.length; + renderElement._batchIndexStart=indexStart; + renderElement._batchIndexEnd=indexEnd; + indexDatas.set(subIndexDatas,curIndexCount); + for (var k=indexStart;k < indexEnd;k++) + indexDatas[k]=indexOffset+indexDatas[k]; + curIndexCount+=subIndexDatas.length; + vertexDatas.set(subVertexDatas,curMerVerCount); + curMerVerCount+=subVertexDatas.length; + } + this._vertexBuffer.setData(vertexDatas); + this._indexBuffer.setData(indexDatas); + this._needFinishCombine=false; + } + } + + __proto._clearRenderElements=function(){ + this._renderElements.length=0; + } + + __proto._addRenderElement=function(renderElement){ + for (var i=0,n=this._renderElements.length;i < n;i++){ + if (this._renderElements[i]._batchIndexStart > renderElement._batchIndexStart){ + this._renderElements.splice(i,0,renderElement); + return; + } + } + this._renderElements.push(renderElement); + } + + __proto._getRenderElement=function(mergeElements){ + this._combineRenderElementPoolIndex=0; + var length=this._renderElements.length; + var merageElement=this._getCombineRenderElementFromPool(); + merageElement._type=1; + merageElement._staticBatch=null; + merageElement.renderObj=this; + merageElement._batchIndexStart=this._renderElements[0]._batchIndexStart; + merageElement._batchIndexEnd=this._renderElements[0]._batchIndexEnd; + merageElement._material=this._material; + merageElement._material=this._material; + mergeElements.push(merageElement); + if (length > 1){ + for (var i=1;i < length;i++){ + var renderElement=this._renderElements[i]; + if (this._renderElements[i-1]._batchIndexEnd!==renderElement._batchIndexStart){ + merageElement=this._getCombineRenderElementFromPool(); + merageElement._type=1; + merageElement._staticBatch=null; + merageElement.renderObj=this; + merageElement._batchIndexStart=renderElement._batchIndexStart; + merageElement._batchIndexEnd=renderElement._batchIndexEnd; + merageElement._material=this._material; + mergeElements.push(merageElement); + }else { + merageElement._batchIndexEnd=renderElement._batchIndexEnd; + } + } + } + } + + __proto._addToRenderQueue=function(scene){ + (this._renderElements.length > 0)&& (scene.getRenderQueue(this._material.renderQueue)._addStaticBatch(this)); + } + + //TODO:>0移到外层 + __proto._beforeRender=function(state){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + return true; + } + + __proto._render=function(state){ + var indexCount=state._batchIndexEnd-state._batchIndexStart; + state.context.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,state._batchIndexStart *2); + Stat.drawCall++; + Stat.trianglesFaces+=indexCount / 3; + } + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'indexOfHost',function(){ + return 0; + }); + + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer.indexCount / 3; + }); + + StaticBatch._addToRenderQueueStaticBatch=function(scene,sprite3D){ + var i=0,n=0; + if (((sprite3D instanceof laya.d3.core.MeshSprite3D ))&& (sprite3D.isStatic)){ + var renderElements=(sprite3D).meshRender.renderObject._renderElements; + for (i=0,n=renderElements.length;i < n;i++){ + var renderElement=renderElements[i]; + if (renderElement.renderObj._vertexBufferCount===1) + scene._staticBatchManager._addPrepareRenderElement(renderElement); + } + } + for (i=0,n=sprite3D.numChildren;i < n;i++) + StaticBatch._addToRenderQueueStaticBatch(scene,sprite3D._childs [i]); + } + + StaticBatch.combine=function(staticBatchRoot){ + var scene=staticBatchRoot.scene; + if (!scene) + throw new Error("BaseScene: staticBatchRoot is not a part of scene."); + StaticBatch._addToRenderQueueStaticBatch(scene,staticBatchRoot); + scene._staticBatchManager._finishCombineStaticBatch(staticBatchRoot); + } + + StaticBatch.maxVertexCount=65535; + return StaticBatch; + })() + + + /** + *@private + *StaticBatchManager 类用于管理静态批处理。 + */ + //class laya.d3.graphics.StaticBatchManager + var StaticBatchManager=(function(){ + function StaticBatchManager(){ + this._staticBatches=null; + this._prepareStaticBatchCombineElements=null; + this._staticBatches={}; + this._prepareStaticBatchCombineElements=[]; + } + + __class(StaticBatchManager,'laya.d3.graphics.StaticBatchManager'); + var __proto=StaticBatchManager.prototype; + /**完成合并*/ + __proto._finshCombine=function(){ + for (var key in this._staticBatches) + this._staticBatches[key]._finshCombine(); + } + + __proto.getStaticBatch=function(rootSprite,_vertexDeclaration,material,number){ + var staticBatch; + var key=rootSprite.id.toString()+material.id.toString()+_vertexDeclaration.id.toString()+number; + if (!this._staticBatches[key]){ + this._staticBatches[key]=staticBatch=new StaticBatch(rootSprite,_vertexDeclaration,material); + }else { + staticBatch=this._staticBatches[key]; + } + return staticBatch; + } + + /**@private 通常应在所有getStaticBatchQneue函数相关操作结束后执行*/ + __proto._garbageCollection=function(){ + for (var key in this._staticBatches) + if (this._staticBatches[key].combineRenderElementsCount===0) + delete this._staticBatches[key]; + } + + /**@private */ + __proto._addPrepareRenderElement=function(renderElement){ + this._prepareStaticBatchCombineElements.push(renderElement); + } + + /**@private */ + __proto._finishCombineStaticBatch=function(rootSprite){ + this._prepareStaticBatchCombineElements.sort(StaticBatchManager._sortPrepareStaticBatch); + var lastMaterial; + var lastVertexDeclaration; + var lastCanMerage=false; + var curStaticBatch; + var renderElement; + var lastRenderObj; + var vb; + var oldStaticBatch; + var batchNumber=0; + for (var i=0,n=this._prepareStaticBatchCombineElements.length;i < n;i++){ + renderElement=this._prepareStaticBatchCombineElements[i]; + vb=renderElement.renderObj._getVertexBuffer(0); + if ((lastVertexDeclaration===vb.vertexDeclaration)&& (lastMaterial===renderElement._material)){ + if (!lastCanMerage){ + lastRenderObj=this._prepareStaticBatchCombineElements[i-1]; + var lastRenderElement=lastRenderObj.renderObj; + var curRenderElement=renderElement.renderObj; + if (((lastRenderElement._getVertexBuffer().vertexCount+curRenderElement._getVertexBuffer().vertexCount)> StaticBatch.maxVertexCount)){ + lastCanMerage=false; + }else { + curStaticBatch=this.getStaticBatch(rootSprite,lastVertexDeclaration,lastMaterial,batchNumber); + oldStaticBatch=lastRenderObj._staticBatch; + (oldStaticBatch)&& (oldStaticBatch!==curStaticBatch)&& (oldStaticBatch._deleteCombineRenderObj(lastRenderObj)); + curStaticBatch._addCombineRenderObj(lastRenderObj); + oldStaticBatch=renderElement._staticBatch; + (oldStaticBatch)&& (oldStaticBatch!==curStaticBatch)&& (oldStaticBatch._deleteCombineRenderObj(renderElement)); + curStaticBatch._addCombineRenderObj(renderElement); + lastCanMerage=true; + } + }else { + if (!curStaticBatch._addCombineRenderObjTest(renderElement)){ + lastCanMerage=false; + batchNumber++; + }else { + oldStaticBatch=renderElement._staticBatch; + (oldStaticBatch)&& (oldStaticBatch!==curStaticBatch)&& (oldStaticBatch._deleteCombineRenderObj(renderElement)); + curStaticBatch._addCombineRenderObj(renderElement) + } + } + }else { + lastCanMerage=false; + batchNumber=0; + } + lastMaterial=renderElement._material; + lastVertexDeclaration=vb.vertexDeclaration; + } + this._garbageCollection(); + this._finshCombine(); + this._prepareStaticBatchCombineElements.length=0; + } + + __proto._clearRenderElements=function(){ + for (var key in this._staticBatches) + this._staticBatches[key]._clearRenderElements(); + } + + __proto._addToRenderQueue=function(scene){ + for (var key in this._staticBatches) + this._staticBatches[key]._addToRenderQueue(scene); + } + + __proto.dispose=function(){ + this._staticBatches=null; + } + + StaticBatchManager._sortPrepareStaticBatch=function(a,b){ + var id=a._mainSortID-b._mainSortID; + return (id===0)? (a.renderObj.triangleCount-b.renderObj.triangleCount):id; + } + + return StaticBatchManager; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.graphics.VertexDeclaration + var VertexDeclaration=(function(){ + function VertexDeclaration(vertexStride,vertexElements){ + this._id=0; + this._shaderValues=null; + this._shaderDefineValue=0; + this._vertexStride=0; + this._vertexElements=null; + this._vertexElementsDic=null; + this._id=++VertexDeclaration._uniqueIDCounter; + if (this._id > VertexDeclaration.maxVertexDeclaration) + throw new Error("VertexDeclaration: VertexDeclaration count should not large than ",VertexDeclaration.maxVertexDeclaration); + this._shaderValues=new ValusArray(); + this._vertexElementsDic={}; + this._vertexStride=vertexStride; + this._vertexElements=vertexElements; + for (var i=0;i < vertexElements.length;i++){ + var vertexElement=vertexElements[i]; + var attributeName=vertexElement.elementUsage; + this._vertexElementsDic[attributeName]=vertexElement; + var value=[VertexDeclaration._getTypeSize(vertexElement.elementFormat)/ 4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,this._vertexStride,vertexElement.offset]; + this._shaderValues.pushValue(attributeName,value); + switch (attributeName){ + case /*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV": + this._shaderDefineValue |=/*laya.d3.shader.ShaderDefines3D.UV*/0x400; + break ; + case /*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR": + this._shaderDefineValue |=/*laya.d3.shader.ShaderDefines3D.COLOR*/0x800; + break ; + } + } + } + + __class(VertexDeclaration,'laya.d3.graphics.VertexDeclaration'); + var __proto=VertexDeclaration.prototype; + __proto.getVertexElements=function(){ + return this._vertexElements.slice(); + } + + __proto.getVertexElementByUsage=function(usage){ + return this._vertexElementsDic[usage]; + } + + __proto.unBinding=function(){} + __getset(0,__proto,'shaderDefineValue',function(){ + return this._shaderDefineValue; + }); + + /** + *获取唯一标识ID(通常用于优化或识别)。 + *@return 唯一标识ID + */ + __getset(0,__proto,'id',function(){ + return this._id; + }); + + __getset(0,__proto,'vertexStride',function(){ + return this._vertexStride; + }); + + __getset(0,__proto,'shaderValues',function(){ + return this._shaderValues; + }); + + VertexDeclaration._getTypeSize=function(format){ + switch (format){ + case /*laya.d3.graphics.VertexElementFormat.Single*/"single": + return 4; + case /*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2": + return 8; + case /*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3": + return 12; + case /*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4": + return 16; + case /*laya.d3.graphics.VertexElementFormat.Color*/"color": + return 4; + case /*laya.d3.graphics.VertexElementFormat.Byte4*/"byte4": + return 4; + case /*laya.d3.graphics.VertexElementFormat.Short2*/"short2": + return 4; + case /*laya.d3.graphics.VertexElementFormat.Short4*/"short4": + return 8; + case /*laya.d3.graphics.VertexElementFormat.NormalizedShort2*/"normalizedshort2": + return 4; + case /*laya.d3.graphics.VertexElementFormat.NormalizedShort4*/"normalizedshort4": + return 8; + case /*laya.d3.graphics.VertexElementFormat.HalfVector2*/"halfvector2": + return 4; + case /*laya.d3.graphics.VertexElementFormat.HalfVector4*/"halfvector4": + return 8; + } + return 0; + } + + VertexDeclaration.getVertexStride=function(vertexElements){ + var curStride=0; + for (var i=0;i < vertexElements.Length;i++){ + var element=vertexElements[i]; + var stride=element.offset+VertexDeclaration._getTypeSize(element.elementFormat); + if (curStride < stride){ + curStride=stride; + } + } + return curStride; + } + + VertexDeclaration._maxVertexDeclarationBit=1000; + VertexDeclaration._uniqueIDCounter=1; + __static(VertexDeclaration, + ['maxVertexDeclaration',function(){return this.maxVertexDeclaration=2147483647-Math.floor(2147483647 / 1000)*1000;} + ]); + return VertexDeclaration; + })() + + + /** + *VertexElement 类用于创建顶点结构分配。 + */ + //class laya.d3.graphics.VertexElement + var VertexElement=(function(){ + function VertexElement(offset,elementFormat,elementUsage){ + this.offset=0; + this.elementFormat=null; + this.elementUsage=null; + this.offset=offset; + this.elementFormat=elementFormat; + this.elementUsage=elementUsage; + } + + __class(VertexElement,'laya.d3.graphics.VertexElement'); + return VertexElement; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.graphics.VertexElementFormat + var VertexElementFormat=(function(){ + function VertexElementFormat(){}; + __class(VertexElementFormat,'laya.d3.graphics.VertexElementFormat'); + VertexElementFormat.Single="single"; + VertexElementFormat.Vector2="vector2"; + VertexElementFormat.Vector3="vector3"; + VertexElementFormat.Vector4="vector4"; + VertexElementFormat.Color="color"; + VertexElementFormat.Byte4="byte4"; + VertexElementFormat.Short2="short2"; + VertexElementFormat.Short4="short4"; + VertexElementFormat.NormalizedShort2="normalizedshort2"; + VertexElementFormat.NormalizedShort4="normalizedshort4"; + VertexElementFormat.HalfVector2="halfvector2"; + VertexElementFormat.HalfVector4="halfvector4"; + return VertexElementFormat; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.graphics.VertexElementUsage + var VertexElementUsage=(function(){ + function VertexElementUsage(){}; + __class(VertexElementUsage,'laya.d3.graphics.VertexElementUsage'); + VertexElementUsage.POSITION0="POSITION"; + VertexElementUsage.COLOR0="COLOR"; + VertexElementUsage.TEXTURECOORDINATE0="UV"; + VertexElementUsage.NORMAL0="NORMAL"; + VertexElementUsage.BINORMAL0="BINORMAL"; + VertexElementUsage.TANGENT0="TANGENT0"; + VertexElementUsage.BLENDINDICES0="BLENDINDICES"; + VertexElementUsage.BLENDWEIGHT0="BLENDWEIGHT"; + VertexElementUsage.DEPTH0="DEPTH"; + VertexElementUsage.FOG0="FOG"; + VertexElementUsage.POINTSIZE0="POINTSIZE"; + VertexElementUsage.SAMPLE0="SAMPLE"; + VertexElementUsage.TESSELLATEFACTOR0="TESSELLATEFACTOR"; + VertexElementUsage.COLOR1="COLOR1"; + VertexElementUsage.NEXTTEXTURECOORDINATE0="NEXTUV"; + VertexElementUsage.TEXTURECOORDINATE1="UV1"; + VertexElementUsage.NEXTTEXTURECOORDINATE1="NEXTUV1"; + VertexElementUsage.CORNERTEXTURECOORDINATE0="CORNERTEXTURECOORDINATE"; + VertexElementUsage.VELOCITY0="VELOCITY"; + VertexElementUsage.STARTCOLOR0="STARTCOLOR"; + VertexElementUsage.STARTSIZE="STARTSIZE"; + VertexElementUsage.AGEADDSCALE0="AGEADDSCALE0"; + VertexElementUsage.STARTROTATION0="STARTROTATION0"; + VertexElementUsage.STARTROTATION1="STARTROTATION1"; + VertexElementUsage.STARTROTATION2="STARTROTATION2"; + VertexElementUsage.ENDCOLOR0="ENDCOLOR"; + VertexElementUsage.SIZEROTATION0="SIZEROTATION"; + VertexElementUsage.RADIUS0="RADIUS"; + VertexElementUsage.RADIAN0="RADIAN"; + VertexElementUsage.STARTLIFETIME="STARTLIFETIME"; + VertexElementUsage.STARTSPEED="STARTSPEED"; + VertexElementUsage.DIRECTION="DIRECTION"; + VertexElementUsage.TIME0="TIME"; + VertexElementUsage.RANDOM0="RANDOM0"; + VertexElementUsage.RANDOM1="RANDOM1"; + VertexElementUsage.SIMULATIONWORLDPOSTION="SIMULATIONWORLDPOSTION"; + return VertexElementUsage; + })() + + + /** + *VertexPositionNormalColorTangent 类用于创建粒子顶点结构。 + */ + //class laya.d3.graphics.VertexGlitter + var VertexGlitter=(function(){ + function VertexGlitter(position,textureCoordinate,time){ + this._position=null; + this._textureCoordinate0=null; + this._time=NaN; + this._position=position; + this._textureCoordinate0=textureCoordinate; + this._time=time; + } + + __class(VertexGlitter,'laya.d3.graphics.VertexGlitter'); + var __proto=VertexGlitter.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'time',function(){ + return this._time; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexGlitter._vertexDeclaration; + }); + + __getset(1,VertexGlitter,'vertexDeclaration',function(){ + return VertexGlitter._vertexDeclaration; + }); + + __static(VertexGlitter, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(24, + [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(20,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.TIME0*/"TIME")]);} + ]); + return VertexGlitter; + })() + + + /** + *VertexPositionNormalColorTangent 类用于创建粒子顶点结构。 + */ + //class laya.d3.graphics.VertexParticle + var VertexParticle=(function(){ + function VertexParticle(cornerTextureCoordinate,position,velocity,startColor,endColor,sizeRotation,radius,radian,ageAddScale,time){ + this._cornerTextureCoordinate=null; + this._position=null; + this._velocity=null; + this._startColor=null; + this._endColor=null; + this._sizeRotation=null; + this._radius=null; + this._radian=null; + this._ageAddScale=NaN; + this._time=NaN; + this._cornerTextureCoordinate=cornerTextureCoordinate; + this._position=position; + this._velocity=velocity; + this._startColor=startColor; + this._endColor=endColor; + this._sizeRotation=sizeRotation; + this._radius=radius; + this._radian=radian; + this._ageAddScale=ageAddScale; + this._time=time; + } + + __class(VertexParticle,'laya.d3.graphics.VertexParticle'); + var __proto=VertexParticle.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'endColor',function(){ + return this._endColor; + }); + + __getset(0,__proto,'cornerTextureCoordinate',function(){ + return this._cornerTextureCoordinate; + }); + + __getset(0,__proto,'sizeRotation',function(){ + return this._sizeRotation; + }); + + __getset(0,__proto,'velocity',function(){ + return this._velocity; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'startColor',function(){ + return this._startColor; + }); + + __getset(0,__proto,'radius',function(){ + return this._radius; + }); + + __getset(0,__proto,'radian',function(){ + return this._radian; + }); + + __getset(0,__proto,'ageAddScale',function(){ + return this._ageAddScale; + }); + + __getset(0,__proto,'time',function(){ + return this._time; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexParticle._vertexDeclaration; + }); + + __getset(1,VertexParticle,'vertexDeclaration',function(){ + return VertexParticle._vertexDeclaration; + }); + + __static(VertexParticle, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(116, + [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.CORNERTEXTURECOORDINATE0*/"CORNERTEXTURECOORDINATE"), + new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(28,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.VELOCITY0*/"VELOCITY"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.STARTCOLOR0*/"STARTCOLOR"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.ENDCOLOR0*/"ENDCOLOR"), + new VertexElement(72,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.SIZEROTATION0*/"SIZEROTATION"), + new VertexElement(84,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.RADIUS0*/"RADIUS"), + new VertexElement(92,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.RADIAN0*/"RADIAN"), + new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.STARTLIFETIME*/"STARTLIFETIME"), + new VertexElement(112,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.TIME0*/"TIME")]);} + ]); + return VertexParticle; + })() + + + /** + *VertexPositionNormalColorTangent 类用于创建粒子顶点结构。 + */ + //class laya.d3.graphics.VertexParticleShuriken + var VertexParticleShuriken=(function(){ + function VertexParticleShuriken(cornerTextureCoordinate,position,velocity,startColor,startSize,startRotation0,startRotation1,startRotation2,ageAddScale,time,startSpeed,randoms0,randoms1,simulationWorldPostion){ + this._cornerTextureCoordinate=null; + this._position=null; + this._velocity=null; + this._startColor=null; + this._startSize=null; + this._startRotation0=null; + this._startRotation1=null; + this._startRotation2=null; + this._startLifeTime=NaN; + this._time=NaN; + this._startSpeed=NaN; + this._randoms0=null; + this._randoms1=null; + this._simulationWorldPostion=null; + this._cornerTextureCoordinate=cornerTextureCoordinate; + this._position=position; + this._velocity=velocity; + this._startColor=startColor; + this._startSize=startSize; + this._startRotation0=startRotation0; + this._startRotation1=startRotation1; + this._startRotation2=startRotation2; + this._startLifeTime=ageAddScale; + this._time=time; + this._startSpeed=startSpeed; + this._randoms0=this.random0; + this._randoms1=this.random1; + this._simulationWorldPostion=simulationWorldPostion; + } + + __class(VertexParticleShuriken,'laya.d3.graphics.VertexParticleShuriken'); + var __proto=VertexParticleShuriken.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'cornerTextureCoordinate',function(){ + return this._cornerTextureCoordinate; + }); + + __getset(0,__proto,'velocity',function(){ + return this._velocity; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'random0',function(){ + return this._randoms0; + }); + + __getset(0,__proto,'startSize',function(){ + return this._startSize; + }); + + __getset(0,__proto,'startColor',function(){ + return this._startColor; + }); + + __getset(0,__proto,'startRotation0',function(){ + return this._startRotation0; + }); + + __getset(0,__proto,'startRotation1',function(){ + return this._startRotation1; + }); + + __getset(0,__proto,'random1',function(){ + return this._randoms1; + }); + + __getset(0,__proto,'startRotation2',function(){ + return this._startRotation2; + }); + + __getset(0,__proto,'startLifeTime',function(){ + return this._startLifeTime; + }); + + __getset(0,__proto,'time',function(){ + return this._time; + }); + + __getset(0,__proto,'startSpeed',function(){ + return this._startSpeed; + }); + + __getset(0,__proto,'simulationWorldPostion',function(){ + return this._simulationWorldPostion; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexParticleShuriken._vertexDeclaration; + }); + + __getset(1,VertexParticleShuriken,'vertexDeclaration',function(){ + return VertexParticleShuriken._vertexDeclaration; + }); + + __static(VertexParticleShuriken, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(160,[new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.CORNERTEXTURECOORDINATE0*/"CORNERTEXTURECOORDINATE"),new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"),new VertexElement(28,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.DIRECTION*/"DIRECTION"),new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.STARTCOLOR0*/"STARTCOLOR"),new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.STARTSIZE*/"STARTSIZE"),new VertexElement(68,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.STARTROTATION0*/"STARTROTATION0"),new VertexElement(80,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.STARTROTATION1*/"STARTROTATION1"),new VertexElement(92,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.STARTROTATION2*/"STARTROTATION2"),new VertexElement(104,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.STARTLIFETIME*/"STARTLIFETIME"),new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.TIME0*/"TIME"),new VertexElement(112,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.VertexElementUsage.STARTSPEED*/"STARTSPEED"),new VertexElement(116,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.RANDOM0*/"RANDOM0"),new VertexElement(132,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.RANDOM1*/"RANDOM1"),new VertexElement(148,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.SIMULATIONWORLDPOSTION*/"SIMULATIONWORLDPOSTION")]);} + ]); + return VertexParticleShuriken; + })() + + + /** + *VertexPositionNormalColor 类用于创建位置、法线、颜色顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColor + var VertexPositionNormalColor=(function(){ + function VertexPositionNormalColor(position,normal,color){ + this._position=null; + this._normal=null; + this._color=null; + this._position=position; + this._normal=normal; + this._color=color; + } + + __class(VertexPositionNormalColor,'laya.d3.graphics.VertexPositionNormalColor'); + var __proto=VertexPositionNormalColor.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColor._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColor,'vertexDeclaration',function(){ + return VertexPositionNormalColor._vertexDeclaration; + }); + + __static(VertexPositionNormalColor, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(40,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR")]);} + ]); + return VertexPositionNormalColor; + })() + + + /** + *VertexPositionNormalColorSkin 类用于创建位置、法线、颜色、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorSkin + var VertexPositionNormalColorSkin=(function(){ + function VertexPositionNormalColorSkin(position,normal,color,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._color=null; + this._blendIndex=null; + this._blendWeight=null; + this._position=position; + this._normal=normal; + this._color=color; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalColorSkin,'laya.d3.graphics.VertexPositionNormalColorSkin'); + var __proto=VertexPositionNormalColorSkin.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorSkin._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorSkin,'vertexDeclaration',function(){ + return VertexPositionNormalColorSkin._vertexDeclaration; + }); + + __static(VertexPositionNormalColorSkin, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(72,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES")]);} + ]); + return VertexPositionNormalColorSkin; + })() + + + /** + *VertexPositionNormalColorSkin 类用于创建位置、法线、颜色、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorSkinTangent + var VertexPositionNormalColorSkinTangent=(function(){ + function VertexPositionNormalColorSkinTangent(position,normal,color,tangent,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._color=null; + this._blendIndex=null; + this._blendWeight=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._color=color; + this._tangent=tangent; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalColorSkinTangent,'laya.d3.graphics.VertexPositionNormalColorSkinTangent'); + var __proto=VertexPositionNormalColorSkinTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorSkinTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorSkinTangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorSkinTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorSkinTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(84,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES"), + new VertexElement(72,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorSkinTangent; + })() + + + /** + *VertexPositionNormalColorTangent 类用于创建位置、法线、颜色、切线顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTangent + var VertexPositionNormalColorTangent=(function(){ + function VertexPositionNormalColorTangent(position,normal,color,tangent){ + this._position=null; + this._normal=null; + this._color=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._color=color; + this._tangent=tangent; + } + + __class(VertexPositionNormalColorTangent,'laya.d3.graphics.VertexPositionNormalColorTangent'); + var __proto=VertexPositionNormalColorTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorTangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(52,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorTangent; + })() + + + /** + *VertexPositionNormalColorTexture 类用于创建位置、法线、颜色、纹理顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTexture + var VertexPositionNormalColorTexture=(function(){ + function VertexPositionNormalColorTexture(position,normal,color,textureCoordinate){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate=textureCoordinate; + } + + __class(VertexPositionNormalColorTexture,'laya.d3.graphics.VertexPositionNormalColorTexture'); + var __proto=VertexPositionNormalColorTexture.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorTexture,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTexture, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(48,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV")]);} + ]); + return VertexPositionNormalColorTexture; + })() + + + /** + *VertexPositionNormalColorTexture 类用于创建位置、法线、颜色、纹理顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTexture0Texture1 + var VertexPositionNormalColorTexture0Texture1=(function(){ + function VertexPositionNormalColorTexture0Texture1(position,normal,color,textureCoordinate0,textureCoordinate1){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + } + + __class(VertexPositionNormalColorTexture0Texture1,'laya.d3.graphics.VertexPositionNormalColorTexture0Texture1'); + var __proto=VertexPositionNormalColorTexture0Texture1.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(1,VertexPositionNormalColorTexture0Texture1,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTexture0Texture1, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(56,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1")]);} + ]); + return VertexPositionNormalColorTexture0Texture1; + })() + + + /** + *VertexPositionNormalColorTextureSkin 类用于创建位置、法线、颜色、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin + var VertexPositionNormalColorTexture0Texture1Skin=(function(){ + function VertexPositionNormalColorTexture0Texture1Skin(position,normal,color,textureCoordinate0,textureCoordinate1,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._blendIndex=null; + this._blendWeight=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalColorTexture0Texture1Skin,'laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin'); + var __proto=VertexPositionNormalColorTexture0Texture1Skin.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1Skin._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(1,VertexPositionNormalColorTexture0Texture1Skin,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1Skin._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTexture0Texture1Skin, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(88,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(72,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES")]);} + ]); + return VertexPositionNormalColorTexture0Texture1Skin; + })() + + + /** + *VertexPositionNormalTextureSkin 类用于创建位置、法线、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent + var VertexPositionNormalColorTexture0Texture1SkinTangent=(function(){ + function VertexPositionNormalColorTexture0Texture1SkinTangent(){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._blendIndex=null; + this._blendWeight=null; + this._tangent=null; + } + + __class(VertexPositionNormalColorTexture0Texture1SkinTangent,'laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent'); + var __proto=VertexPositionNormalColorTexture0Texture1SkinTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __proto.VertexPositionNormalColorTexture0SkinTangent=function(position,normal,color,textureCoordinate0,textureCoordinate1,tangent,blendIndex,blendWeight){ + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._tangent=tangent; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1SkinTangent._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(1,VertexPositionNormalColorTexture0Texture1SkinTangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1SkinTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTexture0Texture1SkinTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(100,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(72,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES"), + new VertexElement(88,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorTexture0Texture1SkinTangent; + })() + + + /** + *VertexPositionNormalColorTextureTangent 类用于创建位置、法线、颜色、纹理、切线顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent + var VertexPositionNormalColorTexture0Texture1Tangent=(function(){ + function VertexPositionNormalColorTexture0Texture1Tangent(){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._tangent=null; + } + + __class(VertexPositionNormalColorTexture0Texture1Tangent,'laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent'); + var __proto=VertexPositionNormalColorTexture0Texture1Tangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __proto.VertexPositionNormalColorTexture0Tangent=function(position,normal,color,textureCoordinate0,textureCoordinate1,tangent){ + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._tangent=tangent; + } + + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1Tangent._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(1,VertexPositionNormalColorTexture0Texture1Tangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorTexture0Texture1Tangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTexture0Texture1Tangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(68,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorTexture0Texture1Tangent; + })() + + + /** + *VertexPositionNormalColorTextureSkin 类用于创建位置、法线、颜色、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTextureSkin + var VertexPositionNormalColorTextureSkin=(function(){ + function VertexPositionNormalColorTextureSkin(position,normal,color,textureCoordinate,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate=null; + this._blendIndex=null; + this._blendWeight=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate=textureCoordinate; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalColorTextureSkin,'laya.d3.graphics.VertexPositionNormalColorTextureSkin'); + var __proto=VertexPositionNormalColorTextureSkin.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureSkin._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorTextureSkin,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureSkin._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTextureSkin, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(80,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(64,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES")]);} + ]); + return VertexPositionNormalColorTextureSkin; + })() + + + /** + *VertexPositionNormalTextureSkin 类用于创建位置、法线、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent + var VertexPositionNormalColorTextureSkinTangent=(function(){ + function VertexPositionNormalColorTextureSkinTangent(position,normal,color,textureCoordinate,tangent,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate=null; + this._blendIndex=null; + this._blendWeight=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate=textureCoordinate; + this._tangent=tangent; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalColorTextureSkinTangent,'laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent'); + var __proto=VertexPositionNormalColorTextureSkinTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureSkinTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorTextureSkinTangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureSkinTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTextureSkinTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(92,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(64,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES"), + new VertexElement(80,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorTextureSkinTangent; + })() + + + /** + *VertexPositionNormalColorTextureTangent 类用于创建位置、法线、颜色、纹理、切线顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalColorTextureTangent + var VertexPositionNormalColorTextureTangent=(function(){ + function VertexPositionNormalColorTextureTangent(position,normal,color,textureCoordinate,tangent){ + this._position=null; + this._normal=null; + this._color=null; + this._textureCoordinate=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._color=color; + this._textureCoordinate=textureCoordinate; + this._tangent=tangent; + } + + __class(VertexPositionNormalColorTextureTangent,'laya.d3.graphics.VertexPositionNormalColorTextureTangent'); + var __proto=VertexPositionNormalColorTextureTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'color',function(){ + return this._color; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalColorTextureTangent,'vertexDeclaration',function(){ + return VertexPositionNormalColorTextureTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalColorTextureTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(60,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalColorTextureTangent; + })() + + + /** + *VertexPositionNormalTexture 类用于创建位置、法线、纹理顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTexture + var VertexPositionNormalTexture=(function(){ + function VertexPositionNormalTexture(position,normal,textureCoordinate){ + this._position=null; + this._normal=null; + this._textureCoordinate=null; + this._position=position; + this._normal=normal; + this._textureCoordinate=textureCoordinate; + } + + __class(VertexPositionNormalTexture,'laya.d3.graphics.VertexPositionNormalTexture'); + var __proto=VertexPositionNormalTexture.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTexture._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalTexture,'vertexDeclaration',function(){ + return VertexPositionNormalTexture._vertexDeclaration; + }); + + __static(VertexPositionNormalTexture, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(32,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV")]);} + ]); + return VertexPositionNormalTexture; + })() + + + /** + *VertexPositionNormalTexture 类用于创建位置、法线、纹理顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTexture0Texture1 + var VertexPositionNormalTexture0Texture1=(function(){ + function VertexPositionNormalTexture0Texture1(position,normal,textureCoordinate0,textureCoordinate1){ + this._position=null; + this._normal=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._position=position; + this._normal=normal; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + } + + __class(VertexPositionNormalTexture0Texture1,'laya.d3.graphics.VertexPositionNormalTexture0Texture1'); + var __proto=VertexPositionNormalTexture0Texture1.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(1,VertexPositionNormalTexture0Texture1,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1._vertexDeclaration; + }); + + __static(VertexPositionNormalTexture0Texture1, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(40,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1")]);} + ]); + return VertexPositionNormalTexture0Texture1; + })() + + + /** + *VertexPositionNormalColorTextureSkin 类用于创建位置、法线、颜色、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin + var VertexPositionNormalTexture0Texture1Skin=(function(){ + function VertexPositionNormalTexture0Texture1Skin(position,normal,textureCoordinate0,textureCoordinate1,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._blendIndex=null; + this._blendWeight=null; + this._position=position; + this._normal=normal; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalTexture0Texture1Skin,'laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin'); + var __proto=VertexPositionNormalTexture0Texture1Skin.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1Skin._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(1,VertexPositionNormalTexture0Texture1Skin,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1Skin._vertexDeclaration; + }); + + __static(VertexPositionNormalTexture0Texture1Skin, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(72,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES")]);} + ]); + return VertexPositionNormalTexture0Texture1Skin; + })() + + + /** + *VertexPositionNormalTextureSkin 类用于创建位置、法线、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent + var VertexPositionNormalTexture0Texture1SkinTangent=(function(){ + function VertexPositionNormalTexture0Texture1SkinTangent(){ + this._position=null; + this._normal=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._blendIndex=null; + this._blendWeight=null; + this._tangent=null; + } + + __class(VertexPositionNormalTexture0Texture1SkinTangent,'laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent'); + var __proto=VertexPositionNormalTexture0Texture1SkinTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __proto.VertexPositionNormalTexture0SkinTangent=function(position,normal,textureCoordinate0,textureCoordinate1,tangent,blendIndex,blendWeight){ + this._position=position; + this._normal=normal; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._tangent=tangent; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1SkinTangent._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(1,VertexPositionNormalTexture0Texture1SkinTangent,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1SkinTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalTexture0Texture1SkinTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(84,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(56,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES"), + new VertexElement(72,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalTexture0Texture1SkinTangent; + })() + + + /** + *VertexPositionNormalTextureTangent 类用于创建位置、法线、纹理、切线顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent + var VertexPositionNormalTexture0Texture1Tangent=(function(){ + function VertexPositionNormalTexture0Texture1Tangent(){ + this._position=null; + this._normal=null; + this._textureCoordinate0=null; + this._textureCoordinate1=null; + this._tangent=null; + } + + __class(VertexPositionNormalTexture0Texture1Tangent,'laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent'); + var __proto=VertexPositionNormalTexture0Texture1Tangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __proto.VertexPositionNormalTexture0Tangent=function(position,normal,textureCoordinate0,textureCoordinate1,tangent){ + this._position=position; + this._normal=normal; + this._textureCoordinate0=textureCoordinate0; + this._textureCoordinate1=textureCoordinate1; + this._tangent=tangent; + } + + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'textureCoordinate0',function(){ + return this._textureCoordinate0; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1Tangent._vertexDeclaration; + }); + + __getset(0,__proto,'textureCoordinate1',function(){ + return this._textureCoordinate1; + }); + + __getset(1,VertexPositionNormalTexture0Texture1Tangent,'vertexDeclaration',function(){ + return VertexPositionNormalTexture0Texture1Tangent._vertexDeclaration; + }); + + __static(VertexPositionNormalTexture0Texture1Tangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(52,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1"), + new VertexElement(40,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalTexture0Texture1Tangent; + })() + + + /** + *VertexPositionNormalColorTextureSkin 类用于创建位置、法线、颜色、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTextureSkin + var VertexPositionNormalTextureSkin=(function(){ + function VertexPositionNormalTextureSkin(position,normal,textureCoordinate,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._textureCoordinate=null; + this._blendIndex=null; + this._blendWeight=null; + this._position=position; + this._normal=normal; + this._textureCoordinate=textureCoordinate; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalTextureSkin,'laya.d3.graphics.VertexPositionNormalTextureSkin'); + var __proto=VertexPositionNormalTextureSkin.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTextureSkin._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalTextureSkin,'vertexDeclaration',function(){ + return VertexPositionNormalTextureSkin._vertexDeclaration; + }); + + __static(VertexPositionNormalTextureSkin, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(64,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES")]);} + ]); + return VertexPositionNormalTextureSkin; + })() + + + /** + *VertexPositionNormalTextureSkin 类用于创建位置、法线、纹理、骨骼索引、骨骼权重顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTextureSkinTangent + var VertexPositionNormalTextureSkinTangent=(function(){ + function VertexPositionNormalTextureSkinTangent(position,normal,textureCoordinate,tangent,blendIndex,blendWeight){ + this._position=null; + this._normal=null; + this._textureCoordinate=null; + this._blendIndex=null; + this._blendWeight=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._textureCoordinate=textureCoordinate; + this._tangent=tangent; + this._blendIndex=blendIndex; + this._blendWeight=blendWeight; + } + + __class(VertexPositionNormalTextureSkinTangent,'laya.d3.graphics.VertexPositionNormalTextureSkinTangent'); + var __proto=VertexPositionNormalTextureSkinTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'blendIndex',function(){ + return this._blendIndex; + }); + + __getset(0,__proto,'blendWeight',function(){ + return this._blendWeight; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTextureSkinTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalTextureSkinTangent,'vertexDeclaration',function(){ + return VertexPositionNormalTextureSkinTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalTextureSkinTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(76,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT"), + new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES"), + new VertexElement(64,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalTextureSkinTangent; + })() + + + /** + *VertexPositionNormalTextureTangent 类用于创建位置、法线、纹理、切线顶点结构。 + */ + //class laya.d3.graphics.VertexPositionNormalTextureTangent + var VertexPositionNormalTextureTangent=(function(){ + function VertexPositionNormalTextureTangent(position,normal,textureCoordinate,tangent){ + this._position=null; + this._normal=null; + this._textureCoordinate=null; + this._tangent=null; + this._position=position; + this._normal=normal; + this._textureCoordinate=textureCoordinate; + this._tangent=tangent; + } + + __class(VertexPositionNormalTextureTangent,'laya.d3.graphics.VertexPositionNormalTextureTangent'); + var __proto=VertexPositionNormalTextureTangent.prototype; + Laya.imps(__proto,{"laya.d3.graphics.IVertex":true}) + __getset(0,__proto,'tangent',function(){ + return this._tangent; + }); + + __getset(0,__proto,'textureCoordinate',function(){ + return this._textureCoordinate; + }); + + __getset(0,__proto,'normal',function(){ + return this._normal; + }); + + __getset(0,__proto,'position',function(){ + return this._position; + }); + + __getset(0,__proto,'vertexDeclaration',function(){ + return VertexPositionNormalTextureTangent._vertexDeclaration; + }); + + __getset(1,VertexPositionNormalTextureTangent,'vertexDeclaration',function(){ + return VertexPositionNormalTextureTangent._vertexDeclaration; + }); + + __static(VertexPositionNormalTextureTangent, + ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(44,[ + new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"), + new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"), + new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV"), + new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")]);} + ]); + return VertexPositionNormalTextureTangent; + })() + + + /** + *@private + *LoadModel 类用于模型加载。 + */ + //class laya.d3.loaders.LoadModel + var LoadModel=(function(){ + function LoadModel(data,mesh,materials,materialMap){ + this._version=null; + this._strings=['BLOCK','DATA',"STRINGS"]; + this._materials=null; + this._materialMap=null; + this._fileData=null; + this._readData=null; + this._mesh=null; + this._BLOCK={count:0}; + this._DATA={offset:0,size:0}; + this._STRINGS={offset:0,size:0}; + this._shaderAttributes=null; + this._mesh=mesh; + this._materials=materials; + this._materialMap=materialMap; + this._onLoaded(data); + } + + __class(LoadModel,'laya.d3.loaders.LoadModel'); + var __proto=LoadModel.prototype; + /** + *@private + */ + __proto._onLoaded=function(data){ + this._fileData=data; + this._readData=new Byte(this._fileData); + this._readData.pos=0; + this._version=this._readData.readUTFString(); + this.READ_BLOCK(); + for (var i=0;i < this._BLOCK.count;i++){ + var index=this._readData.getUint16(); + var blockName=this._strings[index]; + var fn=this["READ_"+blockName]; + if (fn==null)throw new Error("model file err,no this function:"+index+" "+blockName); + if (!fn.call(this))break ; + } + return this._mesh; + } + + __proto.onError=function(){} + /** + *@private + */ + __proto._readString=function(){ + return this._strings[this._readData.getUint16()]; + } + + __proto.READ_BLOCK=function(){ + var n=this._readData.getUint16(); + this._BLOCK.count=this._readData.getUint16(); + return true; + } + + __proto.READ_DATA=function(){ + this._DATA.offset=this._readData.getUint32(); + this._DATA.size=this._readData.getUint32(); + return true; + } + + __proto.READ_STRINGS=function(){ + this._STRINGS.offset=this._readData.getUint16(); + this._STRINGS.size=this._readData.getUint16(); + var ofs=this._readData.pos; + this._readData.pos=this._STRINGS.offset+this._DATA.offset; + for (var i=0;i < this._STRINGS.size;i++){ + this._strings[i]=this._readData.readUTFString(); + } + this._readData.pos=ofs; + return true; + } + + __proto.READ_MATERIAL=function(){ + var i=0,n=0; + var index=this._readData.getUint16(); + var shaderName=this._readString(); + var url=this._readString(); + if (url!=="null") + this._materials[index]=Loader.getRes(this._materialMap[url]); + else + this._materials[index]=new BaseMaterial(); + return true; + } + + __proto.READ_MESH=function(){ + var name=this._readString(); + switch (this._version){ + case "LAYAMODEL:01": + console.log("Warning: The (.lm) file is converted by old fbxTools,please reConverted it use lastest fbxTools version,later we will remove the support of old version (.lm) support."); + break ; + case "LAYASKINANI:01":; + var arrayBuffer=this._readData.__getBuffer(); + var i=0,n=0; + var bindPoseStart=this._readData.getUint32(); + var binPoseLength=this._readData.getUint32(); + var bindPoseDatas=new Float32Array(arrayBuffer.slice(bindPoseStart+this._DATA.offset,bindPoseStart+this._DATA.offset+binPoseLength)); + this.mesh._bindPoses=[]; + for (i=0,n=bindPoseDatas.length;i < n;i+=16){ + var bindPose=new Matrix4x4(bindPoseDatas[i+0],bindPoseDatas[i+1],bindPoseDatas[i+2],bindPoseDatas[i+3],bindPoseDatas[i+4],bindPoseDatas[i+5],bindPoseDatas[i+6],bindPoseDatas[i+7],bindPoseDatas[i+8],bindPoseDatas[i+9],bindPoseDatas[i+10],bindPoseDatas[i+11],bindPoseDatas[i+12],bindPoseDatas[i+13],bindPoseDatas[i+14],bindPoseDatas[i+15]); + this.mesh._bindPoses.push(bindPose); + }; + var inverseGlobalBindPoseStart=this._readData.getUint32(); + var inverseGlobalBinPoseLength=this._readData.getUint32(); + var invGloBindPoseDatas=new Float32Array(arrayBuffer.slice(inverseGlobalBindPoseStart+this._DATA.offset,inverseGlobalBindPoseStart+this._DATA.offset+inverseGlobalBinPoseLength)); + this.mesh._inverseBindPoses=[]; + for (i=0,n=invGloBindPoseDatas.length;i < n;i+=16){ + var inverseGlobalBindPose=new Matrix4x4(invGloBindPoseDatas[i+0],invGloBindPoseDatas[i+1],invGloBindPoseDatas[i+2],invGloBindPoseDatas[i+3],invGloBindPoseDatas[i+4],invGloBindPoseDatas[i+5],invGloBindPoseDatas[i+6],invGloBindPoseDatas[i+7],invGloBindPoseDatas[i+8],invGloBindPoseDatas[i+9],invGloBindPoseDatas[i+10],invGloBindPoseDatas[i+11],invGloBindPoseDatas[i+12],invGloBindPoseDatas[i+13],invGloBindPoseDatas[i+14],invGloBindPoseDatas[i+15]); + this.mesh._inverseBindPoses.push(inverseGlobalBindPose); + } + break ; + default : + throw new Error("LoadModel:unknown version."); + } + return true; + } + + __proto.READ_SUBMESH=function(){ + var className=this._readString(); + var material=this._readData.getUint8(); + var bufferAttribute=this._readString(); + this._shaderAttributes=bufferAttribute.match(LoadModel._attrReg); + var ibofs=this._readData.getUint32(); + var ibsize=this._readData.getUint32(); + var vbIndicesofs=this._readData.getUint32(); + var vbIndicessize=this._readData.getUint32(); + var vbofs=this._readData.getUint32(); + var vbsize=this._readData.getUint32(); + var boneDicofs=this._readData.getUint32(); + var boneDicsize=this._readData.getUint32(); + var arrayBuffer=this._readData.__getBuffer(); + var submesh=new SubMesh(); + var vertexDeclaration=this._getVertexDeclaration(); + var vb=VertexBuffer3D.create(vertexDeclaration,vbsize / vertexDeclaration.vertexStride,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + var vbStart=vbofs+this._DATA.offset; + var vbArrayBuffer=arrayBuffer.slice(vbStart,vbStart+vbsize); + vb.setData(new Float32Array(vbArrayBuffer)); + submesh._vertexBuffer=vb; + var vertexElements=vb.vertexDeclaration.getVertexElements(); + for (var i=0;i < vertexElements.length;i++) + submesh._bufferUsage[(vertexElements [i]).elementUsage]=vb; + var ib=IndexBuffer3D.create(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ibsize / 2,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + var ibStart=ibofs+this._DATA.offset; + var ibArrayBuffer=arrayBuffer.slice(ibStart,ibStart+ibsize); + ib.setData(new Uint16Array(ibArrayBuffer)); + submesh._indexBuffer=ib; + var boneDicArrayBuffer=arrayBuffer.slice(boneDicofs+this._DATA.offset,boneDicofs+this._DATA.offset+boneDicsize); + submesh._boneIndices=new Uint8Array(boneDicArrayBuffer); + this._mesh._add(submesh); + return true; + } + + __proto.READ_DATAAREA=function(){ + return false; + } + + __proto._getVertexDeclaration=function(){ + var position=false,normal=false,color=false,texcoord0=false,texcoord1=false,tangent=false,blendWeight=false,blendIndex=false; + for (var i=0;i < this._shaderAttributes.length;i+=8){ + switch (this._shaderAttributes[i]){ + case "POSITION": + position=true; + break ; + case "NORMAL": + normal=true; + break ; + case "COLOR": + color=true; + break ; + case "UV": + texcoord0=true; + break ; + case "UV1": + texcoord1=true; + break ; + case "BLENDWEIGHT": + blendWeight=true; + break ; + case "BLENDINDICES": + blendIndex=true; + break ; + case "TANGENT": + tangent=true; + break ; + } + }; + var vertexDeclaration; + if (position && normal && color && texcoord0 && texcoord1 && blendWeight && blendIndex && tangent) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1SkinTangent.vertexDeclaration; + else if (position && normal && color && texcoord0 && texcoord1 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1Skin.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1 && blendWeight && blendIndex && tangent) + vertexDeclaration=VertexPositionNormalTexture0Texture1SkinTangent.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalTexture0Texture1Skin.vertexDeclaration; + else if (position && normal && color && texcoord0 && blendWeight && blendIndex && tangent) + vertexDeclaration=VertexPositionNormalColorTextureSkinTangent.vertexDeclaration; + else if (position && normal && color && texcoord0 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorTextureSkin.vertexDeclaration; + else if (position && normal && texcoord0 && blendWeight && blendIndex && tangent) + vertexDeclaration=VertexPositionNormalTextureSkinTangent.vertexDeclaration; + else if (position && normal && texcoord0 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalTextureSkin.vertexDeclaration; + else if (position && normal && color && blendWeight && blendIndex && tangent) + vertexDeclaration=VertexPositionNormalColorSkinTangent.vertexDeclaration; + else if (position && normal && color && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorSkin.vertexDeclaration; + else if (position && normal && color && texcoord0 && texcoord1 && tangent) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1Tangent.vertexDeclaration; + else if (position && normal && color && texcoord0 && texcoord1) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1 && tangent) + vertexDeclaration=VertexPositionNormalTexture0Texture1Tangent.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1) + vertexDeclaration=VertexPositionNormalTexture0Texture1.vertexDeclaration; + else if (position && normal && color && texcoord0 && tangent) + vertexDeclaration=VertexPositionNormalColorTextureTangent.vertexDeclaration; + else if (position && normal && color && texcoord0) + vertexDeclaration=VertexPositionNormalColorTexture.vertexDeclaration; + else if (position && normal && texcoord0 && tangent) + vertexDeclaration=VertexPositionNormalTextureTangent.vertexDeclaration; + else if (position && normal && texcoord0) + vertexDeclaration=VertexPositionNormalTexture.vertexDeclaration; + else if (position && normal && color && tangent) + vertexDeclaration=VertexPositionNormalColorTangent.vertexDeclaration; + else if (position && normal && color) + vertexDeclaration=VertexPositionNormalColor.vertexDeclaration; + return vertexDeclaration; + } + + __getset(0,__proto,'mesh',function(){ + return this._mesh; + }); + + LoadModel._attrReg=new RegExp("(\\w+)|([:,;])","g"); + return LoadModel; + })() + + + /** + *BoundBox 类用于创建包围盒。 + */ + //class laya.d3.math.BoundBox + var BoundBox=(function(){ + function BoundBox(min,max){ + this.min=null; + this.max=null; + this.min=min; + this.max=max; + } + + __class(BoundBox,'laya.d3.math.BoundBox'); + var __proto=BoundBox.prototype; + /** + *获取包围盒的8个角顶点。 + *@param corners 返回顶点的输出队列。 + */ + __proto.getCorners=function(corners){ + corners.length=8; + var mine=this.min.elements; + var maxe=this.max.elements; + var minX=mine[0]; + var minY=mine[1]; + var minZ=mine[2]; + var maxX=maxe[0]; + var maxY=maxe[1]; + var maxZ=maxe[2]; + corners[0]=new Vector3(minX,maxY,maxZ); + corners[1]=new Vector3(maxX,maxY,maxZ); + corners[2]=new Vector3(maxX,minY,maxZ); + corners[3]=new Vector3(minX,minY,maxZ); + corners[4]=new Vector3(minX,maxY,minZ); + corners[5]=new Vector3(maxX,maxY,minZ); + corners[6]=new Vector3(maxX,minY,minZ); + corners[7]=new Vector3(minX,minY,minZ); + } + + __proto.toDefault=function(){ + this.min.toDefault(); + this.max.toDefault(); + } + + BoundBox.createfromPoints=function(points,out){ + if (points==null) + throw new Error("points"); + var min=new Vector3(Number.MAX_VALUE); + var max=new Vector3(-Number.MAX_VALUE); + for (var i=0;i < points.length;++i){ + Vector3.min(min,points[i],min); + Vector3.max(max,points[i],max); + } + out.min=min; + out.max=max; + } + + return BoundBox; + })() + + + /** + *BoundFrustum 类用于创建锥截体。 + */ + //class laya.d3.math.BoundFrustum + var BoundFrustum=(function(){ + function BoundFrustum(matrix){ + this._matrix=null; + this._near=null; + this._far=null; + this._left=null; + this._right=null; + this._top=null; + this._bottom=null; + this._matrix=matrix; + this._near=new Plane(new Vector3()); + this._far=new Plane(new Vector3()); + this._left=new Plane(new Vector3()); + this._right=new Plane(new Vector3()); + this._top=new Plane(new Vector3()); + this._bottom=new Plane(new Vector3()); + BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom); + } + + __class(BoundFrustum,'laya.d3.math.BoundFrustum'); + var __proto=BoundFrustum.prototype; + /** + *判断是否与其他锥截体相等。 + *@param other 锥截体。 + */ + __proto.equalsBoundFrustum=function(other){ + return this._matrix.equalsOtherMatrix(other.matrix) + } + + /** + *判断是否与其他对象相等。 + *@param obj 对象。 + */ + __proto.equalsObj=function(obj){ + if ((obj instanceof laya.d3.math.BoundFrustum )){ + var bf=obj; + return this.equalsBoundFrustum(bf); + } + return false; + } + + /** + *获取锥截体的任意一平面。 + *0:近平面 + *1:远平面 + *2:左平面 + *3:右平面 + *4:顶平面 + *5:底平面 + *@param index 索引。 + */ + __proto.getPlane=function(index){ + switch(index){ + case 0: + return this._near; + case 1: + return this._far; + case 2: + return this._left; + case 3: + return this._right; + case 4: + return this._top; + case 5: + return this._bottom; + default : + return null; + } + } + + /** + *锥截体的8个顶点。 + *@param corners 返回顶点的输出队列。 + */ + __proto.getCorners=function(corners){ + corners[0]=BoundFrustum.get3PlaneInterPoint(this._near,this._bottom,this._right); + corners[1]=BoundFrustum.get3PlaneInterPoint(this._near,this._top,this._right); + corners[2]=BoundFrustum.get3PlaneInterPoint(this._near,this._top,this._left); + corners[3]=BoundFrustum.get3PlaneInterPoint(this._near,this._bottom,this._left); + corners[4]=BoundFrustum.get3PlaneInterPoint(this._far,this._bottom,this._right); + corners[5]=BoundFrustum.get3PlaneInterPoint(this._far,this._top,this._right); + corners[6]=BoundFrustum.get3PlaneInterPoint(this._far,this._top,this._left); + corners[7]=BoundFrustum.get3PlaneInterPoint(this._far,this._bottom,this._left); + } + + /** + *与点的位置关系。返回-1,包涵;0,相交;1,不相交 + *@param point 点。 + */ + __proto.ContainsPoint=function(point){ + var result=Plane.PlaneIntersectionType_Front; + var planeResult=Plane.PlaneIntersectionType_Front; + for (var i=0;i < 6;i++){ + switch(i){ + case 0: + planeResult=Collision.intersectsPlaneAndPoint(this._near,point); + break ; + case 1: + planeResult=Collision.intersectsPlaneAndPoint(this._far,point); + break ; + case 2: + planeResult=Collision.intersectsPlaneAndPoint(this._left,point); + break ; + case 3: + planeResult=Collision.intersectsPlaneAndPoint(this._right,point); + break ; + case 4: + planeResult=Collision.intersectsPlaneAndPoint(this._top,point); + break ; + case 5: + planeResult=Collision.intersectsPlaneAndPoint(this._bottom,point); + break ; + } + switch(planeResult){ + case Plane.PlaneIntersectionType_Back: + return /*laya.d3.math.ContainmentType.Disjoint*/0; + case Plane.PlaneIntersectionType_Intersecting: + result=Plane.PlaneIntersectionType_Intersecting; + break ; + } + } + switch(result){ + case Plane.PlaneIntersectionType_Intersecting: + return /*laya.d3.math.ContainmentType.Intersects*/2; + default : + return /*laya.d3.math.ContainmentType.Contains*/1; + } + } + + /** + *与包围盒的位置关系。返回-1,包涵;0,相交;1,不相交 + *@param box 包围盒。 + */ + __proto.ContainsBoundBox=function(box){ + var plane; + var result=/*laya.d3.math.ContainmentType.Contains*/1; + for (var i=0;i < 6;i++){ + plane=this.getPlane(i); + this._getBoxToPlanePVertexNVertex(box,plane.normal,BoundFrustum._tempV30,BoundFrustum._tempV31); + if (Collision.intersectsPlaneAndPoint(plane,BoundFrustum._tempV30)==Plane.PlaneIntersectionType_Back) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if (Collision.intersectsPlaneAndPoint(plane,BoundFrustum._tempV31)==Plane.PlaneIntersectionType_Back) + result=/*laya.d3.math.ContainmentType.Intersects*/2; + } + return result; + } + + /** + *与包围球的位置关系。返回-1,包涵;0,相交;1,不相交 + *@param sphere 包围球。 + */ + __proto.ContainsBoundSphere=function(sphere){ + var result=Plane.PlaneIntersectionType_Front; + var planeResult=Plane.PlaneIntersectionType_Front; + for (var i=0;i < 6;i++){ + switch(i){ + case 0: + planeResult=Collision.intersectsPlaneAndSphere(this._near,sphere); + break ; + case 1: + planeResult=Collision.intersectsPlaneAndSphere(this._far,sphere); + break ; + case 2: + planeResult=Collision.intersectsPlaneAndSphere(this._left,sphere); + break ; + case 3: + planeResult=Collision.intersectsPlaneAndSphere(this._right,sphere); + break ; + case 4: + planeResult=Collision.intersectsPlaneAndSphere(this._top,sphere); + break ; + case 5: + planeResult=Collision.intersectsPlaneAndSphere(this._bottom,sphere); + break ; + } + switch(planeResult){ + case Plane.PlaneIntersectionType_Back: + return /*laya.d3.math.ContainmentType.Disjoint*/0; + case Plane.PlaneIntersectionType_Intersecting: + result=Plane.PlaneIntersectionType_Intersecting; + break ; + } + } + switch(result){ + case Plane.PlaneIntersectionType_Intersecting: + return /*laya.d3.math.ContainmentType.Intersects*/2; + default : + return /*laya.d3.math.ContainmentType.Contains*/1; + } + } + + /** + *@private + */ + __proto._getBoxToPlanePVertexNVertex=function(box,planeNormal,outP,outN){ + var boxMin=box.min; + var boxMinE=boxMin.elements; + var boxMax=box.max; + var boxMaxE=boxMax.elements; + var planeNorE=planeNormal.elements; + var planeNorEX=planeNorE[0]; + var planeNorEY=planeNorE[1]; + var planeNorEZ=planeNorE[2]; + outP=boxMin; + var outPE=outP.elements; + if (planeNorEX >=0) + outPE[0]=boxMaxE[0]; + if (planeNorEY >=0) + outPE[1]=boxMaxE[1]; + if (planeNorEZ >=0) + outPE[2]=boxMaxE[2]; + outN=boxMax; + var outNE=outN.elements; + if (planeNorEX >=0) + outNE[0]=boxMinE[0]; + if (planeNorEY >=0) + outNE[1]=boxMinE[1]; + if (planeNorEZ >=0) + outNE[2]=boxMinE[2]; + } + + /** + *获取顶平面。 + *@return 顶平面。 + */ + __getset(0,__proto,'top',function(){ + return this._top; + }); + + /** + *设置描述矩阵。 + *@param matrix 描述矩阵。 + */ + /** + *获取描述矩阵。 + *@return 描述矩阵。 + */ + __getset(0,__proto,'matrix',function(){ + return this._matrix; + },function(matrix){ + this._matrix=matrix; + BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom); + }); + + /** + *获取近平面。 + *@return 近平面。 + */ + __getset(0,__proto,'near',function(){ + return this._near; + }); + + /** + *获取远平面。 + *@return 远平面。 + */ + __getset(0,__proto,'far',function(){ + return this._far; + }); + + /** + *获取左平面。 + *@return 左平面。 + */ + __getset(0,__proto,'left',function(){ + return this._left; + }); + + /** + *获取右平面。 + *@return 右平面。 + */ + __getset(0,__proto,'right',function(){ + return this._right; + }); + + /** + *获取底平面。 + *@return 底平面。 + */ + __getset(0,__proto,'bottom',function(){ + return this._bottom; + }); + + BoundFrustum._getPlanesFromMatrix=function(m,np,fp,lp,rp,tp,bp){ + var matrixE=m.elements; + var m11=matrixE[0]; + var m12=matrixE[1]; + var m13=matrixE[2]; + var m14=matrixE[3]; + var m21=matrixE[4]; + var m22=matrixE[5]; + var m23=matrixE[6]; + var m24=matrixE[7]; + var m31=matrixE[8]; + var m32=matrixE[9]; + var m33=matrixE[10]; + var m34=matrixE[11]; + var m41=matrixE[12]; + var m42=matrixE[13]; + var m43=matrixE[14]; + var m44=matrixE[15]; + var nearNorE=np.normal.elements; + nearNorE[0]=m13; + nearNorE[1]=m23; + nearNorE[2]=m33; + np.distance=m43; + np.normalize(); + var farNorE=fp.normal.elements; + farNorE[0]=m14-m13; + farNorE[1]=m24-m23; + farNorE[2]=m34-m33; + fp.distance=m44-m43; + fp.normalize(); + var leftNorE=lp.normal.elements; + leftNorE[0]=m14+m11; + leftNorE[1]=m24+m21; + leftNorE[2]=m34+m31; + lp.distance=m44+m41; + lp.normalize(); + var rightNorE=rp.normal.elements; + rightNorE[0]=m14-m11; + rightNorE[1]=m24-m21; + rightNorE[2]=m34-m31; + rp.distance=m44-m41; + rp.normalize(); + var topNorE=tp.normal.elements; + topNorE[0]=m14-m12; + topNorE[1]=m24-m22; + topNorE[2]=m34-m32; + tp.distance=m44-m42; + tp.normalize(); + var bottomNorE=bp.normal.elements; + bottomNorE[0]=m14+m12; + bottomNorE[1]=m24+m22; + bottomNorE[2]=m34+m32; + bp.distance=m44+m42; + bp.normalize(); + } + + BoundFrustum.get3PlaneInterPoint=function(p1,p2,p3){ + var p1Nor=p1.normal; + var p2Nor=p2.normal; + var p3Nor=p3.normal; + Vector3.cross(p2Nor,p3Nor,BoundFrustum._tempV30); + Vector3.cross(p3Nor,p1Nor,BoundFrustum._tempV31); + Vector3.cross(p1Nor,p2Nor,BoundFrustum._tempV32); + var a=Vector3.dot(p1Nor,BoundFrustum._tempV30); + var b=Vector3.dot(p2Nor,BoundFrustum._tempV31); + var c=Vector3.dot(p3Nor,BoundFrustum._tempV32); + Vector3.scale(BoundFrustum._tempV30,-p1.distance / a,BoundFrustum._tempV33); + Vector3.scale(BoundFrustum._tempV31,-p2.distance / b,BoundFrustum._tempV34); + Vector3.scale(BoundFrustum._tempV32,-p3.distance / c,BoundFrustum._tempV35); + Vector3.add(BoundFrustum._tempV33,BoundFrustum._tempV34,BoundFrustum._tempV36); + Vector3.add(BoundFrustum._tempV35,BoundFrustum._tempV36,BoundFrustum._tempV37); + var v=BoundFrustum._tempV37; + return v; + } + + __static(BoundFrustum, + ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempV35',function(){return this._tempV35=new Vector3();},'_tempV36',function(){return this._tempV36=new Vector3();},'_tempV37',function(){return this._tempV37=new Vector3();} + ]); + return BoundFrustum; + })() + + + /** + *BoundSphere 类用于创建包围球。 + */ + //class laya.d3.math.BoundSphere + var BoundSphere=(function(){ + function BoundSphere(center,radius){ + this.center=null; + this.radius=NaN; + this.center=center; + this.radius=radius; + } + + __class(BoundSphere,'laya.d3.math.BoundSphere'); + var __proto=BoundSphere.prototype; + __proto.toDefault=function(){ + this.center.toDefault(); + this.radius=0; + } + + BoundSphere.createFromSubPoints=function(points,start,count,out){ + if (points==null){ + throw new Error("points"); + } + if (start < 0 || start >=points.length){ + throw new Error("start"+start+"Must be in the range [0, "+(points.length-1)+"]"); + } + if (count < 0 || (start+count)> points.length){ + throw new Error("count"+count+"Must be in the range <= "+points.length+"}"); + }; + var upperEnd=start+count; + var center=BoundSphere._tempVector3; + center.elements[0]=0; + center.elements[1]=0; + center.elements[2]=0; + for (var i=start;i < upperEnd;++i){ + Vector3.add(points[i],center,center); + }; + var outCenter=out.center; + Vector3.scale(center,1 / count,outCenter); + var radius=0.0; + for (i=start;i < upperEnd;++i){ + var distance=Vector3.distanceSquared(outCenter,points[i]); + if (distance > radius) + radius=distance; + } + out.radius=Math.sqrt(radius); + } + + BoundSphere.createfromPoints=function(points,out){ + if (points==null){ + throw new Error("points"); + } + BoundSphere.createFromSubPoints(points,0,points.length,out); + } + + __static(BoundSphere, + ['_tempVector3',function(){return this._tempVector3=new Vector3();} + ]); + return BoundSphere; + })() + + + /** + *Collision 类用于检测碰撞。 + */ + //class laya.d3.math.Collision + var Collision=(function(){ + /** + *创建一个 Collision 实例。 + */ + function Collision(){} + __class(Collision,'laya.d3.math.Collision'); + Collision.distancePlaneToPoint=function(plane,point){ + var dot=Vector3.dot(plane.normal,point); + return dot-plane.distance; + } + + Collision.distanceBoxToPoint=function(box,point){ + var boxMine=box.min.elements; + var boxMineX=boxMine[0]; + var boxMineY=boxMine[1]; + var boxMineZ=boxMine[2]; + var boxMaxe=box.max.elements; + var boxMaxeX=boxMaxe[0]; + var boxMaxeY=boxMaxe[1]; + var boxMaxeZ=boxMaxe[2]; + var pointe=point.elements; + var pointeX=pointe[0]; + var pointeY=pointe[1]; + var pointeZ=pointe[2]; + var distance=0; + if (pointeX < boxMineX) + distance+=(boxMineX-pointeX)*(boxMineX-pointeX); + if (pointeX > boxMaxeX) + distance+=(boxMaxeX-pointeX)*(boxMaxeX-pointeX); + if (pointeY < boxMineY) + distance+=(boxMineY-pointeY)*(boxMineY-pointeY); + if (pointeY > boxMaxeY) + distance+=(boxMaxeY-pointeY)*(boxMaxeY-pointeY); + if (pointeZ < boxMineZ) + distance+=(boxMineZ-pointeZ)*(boxMineZ-pointeZ); + if (pointeZ > boxMaxeZ) + distance+=(boxMaxeZ-pointeZ)*(boxMaxeZ-pointeZ); + return Math.sqrt(distance); + } + + Collision.distanceBoxToBox=function(box1,box2){ + var box1Mine=box1.min.elements; + var box1MineX=box1Mine[0]; + var box1MineY=box1Mine[1]; + var box1MineZ=box1Mine[2]; + var box1Maxe=box1.max.elements; + var box1MaxeX=box1Maxe[0]; + var box1MaxeY=box1Maxe[1]; + var box1MaxeZ=box1Maxe[2]; + var box2Mine=box2.min.elements; + var box2MineX=box2Mine[0]; + var box2MineY=box2Mine[1]; + var box2MineZ=box2Mine[2]; + var box2Maxe=box2.max.elements; + var box2MaxeX=box2Maxe[0]; + var box2MaxeY=box2Maxe[1]; + var box2MaxeZ=box2Maxe[2]; + var distance=0; + var delta=NaN; + if (box1MineX > box2MaxeX){ + delta=box1MineX-box2MaxeX; + distance+=delta *delta; + }else if (box2MineX > box1MaxeX){ + delta=box2MineX-box1MaxeX; + distance+=delta *delta; + } + if (box1MineY > box2MaxeY){ + delta=box1MineY-box2MaxeY; + distance+=delta *delta; + }else if (box2MineY > box1MaxeY){ + delta=box2MineY-box1MaxeY; + distance+=delta *delta; + } + if (box1MineZ > box2MaxeZ){ + delta=box1MineZ-box2MaxeZ; + distance+=delta *delta; + }else if (box2MineZ > box1MaxeZ){ + delta=box2MineZ-box1MaxeZ; + distance+=delta *delta; + } + return Math.sqrt(distance); + } + + Collision.distanceSphereToPoint=function(sphere,point){ + var distance=Math.sqrt(Vector3.distanceSquared(sphere.center,point)); + distance-=sphere.radius; + return Math.max(distance,0); + } + + Collision.distanceSphereToSphere=function(sphere1,sphere2){ + var distance=Math.sqrt(Vector3.distanceSquared(sphere1.center,sphere2.center)); + distance-=sphere1.radius+sphere2.radius; + return Math.max(distance,0); + } + + Collision.intersectsRayAndTriangleRD=function(ray,vertex1,vertex2,vertex3,out){ + var rayO=ray.origin; + var rayOe=rayO.elements; + var rayOeX=rayOe[0]; + var rayOeY=rayOe[1]; + var rayOeZ=rayOe[2]; + var rayD=ray.direction; + var rayDe=rayD.elements; + var rayDeX=rayDe[0]; + var rayDeY=rayDe[1]; + var rayDeZ=rayDe[2]; + var v1e=vertex1.elements; + var v1eX=v1e[0]; + var v1eY=v1e[1]; + var v1eZ=v1e[2]; + var v2e=vertex2.elements; + var v2eX=v2e[0]; + var v2eY=v2e[1]; + var v2eZ=v2e[2]; + var v3e=vertex3.elements; + var v3eX=v3e[0]; + var v3eY=v3e[1]; + var v3eZ=v3e[2]; + var _tempV30e=Collision._tempV30.elements; + var _tempV30eX=_tempV30e[0]; + var _tempV30eY=_tempV30e[1]; + var _tempV30eZ=_tempV30e[2]; + _tempV30eX=v2eX-v1eX; + _tempV30eY=v2eY-v1eY; + _tempV30eZ=v2eZ-v1eZ; + var _tempV31e=Collision._tempV31.elements; + var _tempV31eX=_tempV31e[0]; + var _tempV31eY=_tempV31e[1]; + var _tempV31eZ=_tempV31e[2]; + _tempV31eX=v3eX-v1eX; + _tempV31eY=v3eY-v1eY; + _tempV31eZ=v3eZ-v1eZ; + var _tempV32e=Collision._tempV32.elements; + var _tempV32eX=_tempV32e[0]; + var _tempV32eY=_tempV32e[1]; + var _tempV32eZ=_tempV32e[2]; + _tempV32eX=(rayDeY *_tempV31eZ)-(rayDeZ *_tempV31eY); + _tempV32eY=(rayDeZ *_tempV31eX)-(rayDeX *_tempV31eZ); + _tempV32eZ=(rayDeX *_tempV31eY)-(rayDeY *_tempV31eX); + var determinant=(_tempV30eX *_tempV32eX)+(_tempV30eY *_tempV32eY)+(_tempV30eZ *_tempV32eZ); + if (MathUtils3D.isZero(determinant)){ + out=0; + return false; + }; + var inversedeterminant=1 / determinant; + var _tempV33e=Collision._tempV33.elements; + var _tempV33eX=_tempV33e[0]; + var _tempV33eY=_tempV33e[1]; + var _tempV33eZ=_tempV33e[2]; + _tempV33eX=rayOeX-v1eX; + _tempV33eY=rayOeY-v1eY; + _tempV33eZ=rayOeZ-v1eZ; + var triangleU=(_tempV33eX *_tempV32eX)+(_tempV33eY *_tempV32eY)+(_tempV33eZ *_tempV32eZ); + triangleU *=inversedeterminant; + if (triangleU < 0 || triangleU > 1){ + out=0; + return false; + }; + var _tempV34e=Collision._tempV34.elements; + var _tempV34eX=_tempV34e[0]; + var _tempV34eY=_tempV34e[1]; + var _tempV34eZ=_tempV34e[2]; + _tempV34eX=(_tempV33eY *_tempV30eZ)-(_tempV33eZ *_tempV30eY); + _tempV34eY=(_tempV33eZ *_tempV30eX)-(_tempV33eX *_tempV30eZ); + _tempV34eZ=(_tempV33eX *_tempV30eY)-(_tempV33eY *_tempV30eX); + var triangleV=((rayDeX *_tempV34eX)+(rayDeY *_tempV34eY))+(rayDeZ *_tempV34eZ); + triangleV *=inversedeterminant; + if (triangleV < 0 || triangleU+triangleV > 1){ + out=0; + return false; + }; + var raydistance=(_tempV31eX *_tempV34eX)+(_tempV31eY *_tempV34eY)+(_tempV31eZ *_tempV34eZ); + raydistance *=inversedeterminant; + if (raydistance < 0){ + out=0; + return false; + } + out=raydistance; + return true; + } + + Collision.intersectsRayAndTriangleRP=function(ray,vertex1,vertex2,vertex3,out){ + var distance=NaN; + if (!Collision.intersectsRayAndTriangleRD(ray,vertex1,vertex2,vertex3,distance)){ + out=Vector3.ZERO; + return false; + } + Vector3.scale(ray.direction,distance,Collision._tempV30); + Vector3.add(ray.origin,Collision._tempV30,out); + return true; + } + + Collision.intersectsRayAndPoint=function(ray,point){ + Vector3.subtract(ray.origin,point,Collision._tempV30); + var b=Vector3.dot(Collision._tempV30,ray.direction); + var c=Vector3.dot(Collision._tempV30,Collision._tempV30)-MathUtils3D.zeroTolerance; + if (c > 0 && b > 0) + return false; + var discriminant=b *b-c; + if (discriminant < 0) + return false; + return true; + } + + Collision.intersectsRayAndRay=function(ray1,ray2,out){ + var ray1o=ray1.origin; + var ray1oe=ray1o.elements; + var ray1oeX=ray1oe[0]; + var ray1oeY=ray1oe[1]; + var ray1oeZ=ray1oe[2]; + var ray1d=ray1.direction; + var ray1de=ray1d.elements; + var ray1deX=ray1de[0]; + var ray1deY=ray1de[1]; + var ray1deZ=ray1de[2]; + var ray2o=ray2.origin; + var ray2oe=ray2o.elements; + var ray2oeX=ray2oe[0]; + var ray2oeY=ray2oe[1]; + var ray2oeZ=ray2oe[2]; + var ray2d=ray2.direction; + var ray2de=ray2d.elements; + var ray2deX=ray2de[0]; + var ray2deY=ray2de[1]; + var ray2deZ=ray2de[2]; + Vector3.cross(ray1d,ray2d,Collision._tempV30); + var tempV3e=Collision._tempV30.elements; + var denominator=Vector3.scalarLength(Collision._tempV30); + if (MathUtils3D.isZero(denominator)){ + if (MathUtils3D.nearEqual(ray2oeX,ray1oeX)&& MathUtils3D.nearEqual(ray2oeY,ray1oeY)&& MathUtils3D.nearEqual(ray2oeZ,ray1oeZ)){ + out=Vector3.ZERO; + return true; + } + } + denominator=denominator *denominator; + var m11=ray2oeX-ray1oeX; + var m12=ray2oeY-ray1oeY; + var m13=ray2oeZ-ray1oeZ; + var m21=ray2deX; + var m22=ray2deY; + var m23=ray2deZ; + var m31=tempV3e[0]; + var m32=tempV3e[1]; + var m33=tempV3e[2]; + var dets=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31; + m21=ray1deX; + m22=ray1deY; + m23=ray1deZ; + var dett=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31; + var s=dets / denominator; + var t=dett / denominator; + Vector3.scale(ray1d,s,Collision._tempV30); + Vector3.scale(ray2d,s,Collision._tempV31); + Vector3.add(ray1o,Collision._tempV30,Collision._tempV32); + Vector3.add(ray2o,Collision._tempV31,Collision._tempV33); + var point1e=Collision._tempV32.elements; + var point2e=Collision._tempV33.elements; + if (!MathUtils3D.nearEqual(point2e[0],point1e[0])|| !MathUtils3D.nearEqual(point2e[1],point1e[1])|| !MathUtils3D.nearEqual(point2e[2],point1e[2])){ + out=Vector3.ZERO; + return false; + } + out=Collision._tempV32; + return true; + } + + Collision.intersectsPlaneAndTriangle=function(plane,vertex1,vertex2,vertex3){ + var test1=Collision.intersectsPlaneAndPoint(plane,vertex1); + var test2=Collision.intersectsPlaneAndPoint(plane,vertex2); + var test3=Collision.intersectsPlaneAndPoint(plane,vertex3); + if (test1==Plane.PlaneIntersectionType_Front && test2==Plane.PlaneIntersectionType_Front && test3==Plane.PlaneIntersectionType_Front) + return Plane.PlaneIntersectionType_Front; + if (test1==Plane.PlaneIntersectionType_Back && test2==Plane.PlaneIntersectionType_Back && test3==Plane.PlaneIntersectionType_Back) + return Plane.PlaneIntersectionType_Back; + return Plane.PlaneIntersectionType_Intersecting; + } + + Collision.intersectsRayAndPlaneRD=function(ray,plane,out){ + var planeNor=plane.normal; + var direction=Vector3.dot(planeNor,ray.direction); + if (MathUtils3D.isZero(direction)){ + out=0; + return false; + }; + var position=Vector3.dot(planeNor,ray.origin); + out=(-plane.distance-position)/ direction; + if (out < 0){ + out=0; + return false; + } + return true; + } + + Collision.intersectsRayAndPlaneRP=function(ray,plane,out){ + var distance=NaN; + if (!Collision.intersectsRayAndPlaneRD(ray,plane,distance)){ + out=Vector3.ZERO; + return false; + } + Vector3.scale(ray.direction,distance,Collision._tempV30); + Vector3.add(ray.origin,Collision._tempV30,Collision._tempV31); + out=Collision._tempV31; + return true; + } + + Collision.intersectsRayAndBoxRD=function(ray,box,out){ + var rayoe=ray.origin.elements; + var rayoeX=rayoe[0]; + var rayoeY=rayoe[1]; + var rayoeZ=rayoe[2]; + var rayde=ray.direction.elements; + var raydeX=rayde[0]; + var raydeY=rayde[1]; + var raydeZ=rayde[2]; + var boxMine=box.min.elements; + var boxMineX=boxMine[0]; + var boxMineY=boxMine[1]; + var boxMineZ=boxMine[2]; + var boxMaxe=box.max.elements; + var boxMaxeX=boxMaxe[0]; + var boxMaxeY=boxMaxe[1]; + var boxMaxeZ=boxMaxe[2]; + out=0; + var tmax=MathUtils3D.MaxValue; + if (MathUtils3D.isZero(raydeX)){ + if (rayoeX < boxMineX || rayoeX > boxMaxeX){ + out=0; + return false; + } + }else { + var inverse=1 / raydeX; + var t1=(boxMineX-rayoeX)*inverse; + var t2=(boxMaxeX-rayoeX)*inverse; + if (t1 > t2){ + var temp=t1; + t1=t2; + t2=temp; + } + out=Math.max(t1,out); + tmax=Math.min(t2,tmax); + if (out > tmax){ + out=0; + return false; + } + } + if (MathUtils3D.isZero(raydeY)){ + if (rayoeY < boxMineY || rayoeY > boxMaxeY){ + out=0; + return false; + } + }else { + var inverse1=1 / raydeY; + var t3=(boxMineY-rayoeY)*inverse1; + var t4=(boxMaxeY-rayoeY)*inverse1; + if (t3 > t4){ + var temp1=t3; + t3=t4; + t4=temp1; + } + out=Math.max(t3,out); + tmax=Math.min(t4,tmax); + if (out > tmax){ + out=0; + return false; + } + } + if (MathUtils3D.isZero(raydeZ)){ + if (rayoeZ < boxMineZ || rayoeZ > boxMaxeZ){ + out=0; + return false; + } + }else { + var inverse2=1 / raydeZ; + var t5=(boxMineZ-rayoeZ)*inverse2; + var t6=(boxMaxeZ-rayoeZ)*inverse2; + if (t5 > t6){ + var temp2=t5; + t5=t6; + t6=temp2; + } + out=Math.max(t5,out); + tmax=Math.min(t6,tmax); + if (out > tmax){ + out=0; + return false; + } + } + return true; + } + + Collision.intersectsRayAndBoxRP=function(ray,box,out){ + var distance=NaN; + if (!Collision.intersectsRayAndBoxRD(ray,box,distance)){ + out=Vector3.ZERO; + return false; + } + Vector3.scale(ray.direction,distance,Collision._tempV30); + Vector3.add(ray.origin,Collision._tempV30,Collision._tempV31); + out=Collision._tempV31; + return true; + } + + Collision.intersectsRayAndSphereRD=function(ray,sphere,out){ + var sphereR=sphere.radius; + Vector3.subtract(ray.origin,sphere.center,Collision._tempV30); + var b=Vector3.dot(Collision._tempV30,ray.direction); + var c=Vector3.dot(Collision._tempV30,Collision._tempV30)-(sphereR *sphereR); + if (c > 0 && b > 0){ + out=0; + return false; + }; + var discriminant=b *b-c; + if (discriminant < 0){ + out=0; + return false; + } + out=-b-Math.sqrt(discriminant); + if (out < 0) + out=0; + return true; + } + + Collision.intersectsRayAndSphereRP=function(ray,sphere,out){ + var distance=NaN; + if (!Collision.intersectsRayAndSphereRD(ray,sphere,distance)){ + out=Vector3.ZERO; + return false; + } + Vector3.scale(ray.direction,distance,Collision._tempV30); + Vector3.add(ray.origin,Collision._tempV30,Collision._tempV31); + out=Collision._tempV31; + return true; + } + + Collision.intersectsSphereAndTriangle=function(sphere,vertex1,vertex2,vertex3){ + var sphereC=sphere.center; + var sphereR=sphere.radius; + Collision.closestPointPointTriangle(sphereC,vertex1,vertex2,vertex3,Collision._tempV30); + Vector3.subtract(Collision._tempV30,sphereC,Collision._tempV31); + var dot=Vector3.dot(Collision._tempV31,Collision._tempV31); + return dot <=sphereR *sphereR; + } + + Collision.intersectsPlaneAndPoint=function(plane,point){ + var distance=Vector3.dot(plane.normal,point)+plane.distance; + if (distance > 0) + return Plane.PlaneIntersectionType_Front; + else if (distance < 0) + return Plane.PlaneIntersectionType_Back; + else + return Plane.PlaneIntersectionType_Intersecting; + } + + Collision.intersectsPlaneAndPlane=function(plane1,plane2){ + Vector3.cross(plane1.normal,plane2.normal,Collision._tempV30); + var denominator=Vector3.dot(Collision._tempV30,Collision._tempV30); + if (MathUtils3D.isZero(denominator)) + return false; + return true; + } + + Collision.intersectsPlaneAndPlaneRL=function(plane1,plane2,line){ + var plane1nor=plane1.normal; + var plane2nor=plane2.normal; + Vector3.cross(plane1nor,plane2nor,Collision._tempV34); + var denominator=Vector3.dot(Collision._tempV34,Collision._tempV34); + if (MathUtils3D.isZero(denominator)) + return false; + Vector3.scale(plane2nor,plane1.distance,Collision._tempV30); + Vector3.scale(plane1nor,plane2.distance,Collision._tempV31); + Vector3.subtract(Collision._tempV30,Collision._tempV31,Collision._tempV32); + Vector3.cross(Collision._tempV32,Collision._tempV34,Collision._tempV33); + Vector3.normalize(Collision._tempV34,Collision._tempV34); + line=new Ray(Collision._tempV33,Collision._tempV34); + return true; + } + + Collision.intersectsPlaneAndBox=function(plane,box){ + var planeD=plane.distance; + var planeNor=plane.normal; + var planeNore=planeNor.elements; + var planeNoreX=planeNore[0]; + var planeNoreY=planeNore[1]; + var planeNoreZ=planeNore[2]; + var boxMine=box.min.elements; + var boxMineX=boxMine[0]; + var boxMineY=boxMine[1]; + var boxMineZ=boxMine[2]; + var boxMaxe=box.max.elements; + var boxMaxeX=boxMaxe[0]; + var boxMaxeY=boxMaxe[1]; + var boxMaxeZ=boxMaxe[2]; + Collision._tempV30.elements[0]=(planeNoreX > 0)? boxMineX :boxMaxeX; + Collision._tempV30.elements[1]=(planeNoreY > 0)? boxMineY :boxMaxeY; + Collision._tempV30.elements[2]=(planeNoreZ > 0)? boxMineZ :boxMaxeZ; + Collision._tempV31.elements[0]=(planeNoreX > 0)? boxMaxeX :boxMineX; + Collision._tempV31.elements[1]=(planeNoreY > 0)? boxMaxeY :boxMineY; + Collision._tempV31.elements[2]=(planeNoreZ > 0)? boxMaxeZ :boxMineZ; + var distance=Vector3.dot(planeNor,Collision._tempV30); + if (distance+planeD > 0) + return Plane.PlaneIntersectionType_Front; + distance=Vector3.dot(planeNor,Collision._tempV31); + if (distance+planeD < 0) + return Plane.PlaneIntersectionType_Back; + return Plane.PlaneIntersectionType_Intersecting; + } + + Collision.intersectsPlaneAndSphere=function(plane,sphere){ + var sphereR=sphere.radius; + var distance=Vector3.dot(plane.normal,sphere.center)+plane.distance; + if (distance > sphereR) + return Plane.PlaneIntersectionType_Front; + if (distance <-sphereR) + return Plane.PlaneIntersectionType_Back; + return Plane.PlaneIntersectionType_Intersecting; + } + + Collision.intersectsBoxAndBox=function(box1,box2){ + var box1Mine=box1.min.elements; + var box1Maxe=box1.max.elements; + var box2Mine=box2.min.elements; + var box2Maxe=box2.max.elements; + if (box1Mine[0] > box2Maxe[0] || box2Mine[0] > box1Maxe[0]) + return false; + if (box1Mine[1] > box2Maxe[1] || box2Mine[1] > box1Maxe[1]) + return false; + if (box1Mine[2] > box2Maxe[2] || box2Mine[2] > box1Maxe[2]) + return false; + return true; + } + + Collision.intersectsBoxAndSphere=function(box,sphere){ + var sphereC=sphere.center; + var sphereR=sphere.radius; + Vector3.Clamp(sphereC,box.min,box.max,Collision._tempV30); + var distance=Vector3.distanceSquared(sphereC,Collision._tempV30); + return distance <=sphereR *sphereR; + } + + Collision.intersectsSphereAndSphere=function(sphere1,sphere2){ + var radiisum=sphere1.radius+sphere2.radius; + return Vector3.distanceSquared(sphere1.center,sphere2.center)<=radiisum *radiisum; + } + + Collision.boxContainsPoint=function(box,point){ + var boxMine=box.min.elements; + var boxMaxe=box.max.elements; + var pointe=point.elements; + if (boxMine[0] <=pointe[0] && boxMaxe[0] >=pointe[0] && boxMine[1] <=pointe[1] && boxMaxe[1] >=pointe[1] && boxMine[2] <=pointe[2] && boxMaxe[2] >=pointe[2]) + return /*laya.d3.math.ContainmentType.Contains*/1; + return /*laya.d3.math.ContainmentType.Disjoint*/0; + } + + Collision.boxContainsBox=function(box1,box2){ + var box1Mine=box1.min.elements; + var box1MineX=box1Mine[0]; + var box1MineY=box1Mine[1]; + var box1MineZ=box1Mine[2]; + var box1Maxe=box1.max.elements; + var box1MaxeX=box1Maxe[0]; + var box1MaxeY=box1Maxe[1]; + var box1MaxeZ=box1Maxe[2]; + var box2Mine=box2.min.elements; + var box2MineX=box2Mine[0]; + var box2MineY=box2Mine[1]; + var box2MineZ=box2Mine[2]; + var box2Maxe=box2.max.elements; + var box2MaxeX=box2Maxe[0]; + var box2MaxeY=box2Maxe[1]; + var box2MaxeZ=box2Maxe[2]; + if (box1MaxeX < box2MineX || box1MineX > box2MaxeX) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if (box1MaxeY < box2MineY || box1MineY > box2MaxeY) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if (box1MaxeZ < box2MineZ || box1MineZ > box2MaxeZ) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if (box1MineX <=box2MineX && box2MaxeX <=box2MineX && box1MineY <=box2MineY && box2MaxeY <=box1MaxeY && box1MineZ <=box2MineZ && box2MaxeZ <=box1MaxeZ){ + return /*laya.d3.math.ContainmentType.Contains*/1; + } + return /*laya.d3.math.ContainmentType.Intersects*/2; + } + + Collision.boxContainsSphere=function(box,sphere){ + var boxMin=box.min; + var boxMine=boxMin.elements; + var boxMineX=boxMine[0]; + var boxMineY=boxMine[1]; + var boxMineZ=boxMine[2]; + var boxMax=box.max; + var boxMaxe=boxMax.elements; + var boxMaxeX=boxMaxe[0]; + var boxMaxeY=boxMaxe[1]; + var boxMaxeZ=boxMaxe[2]; + var sphereC=sphere.center; + var sphereCe=sphereC.elements; + var sphereCeX=sphereCe[0]; + var sphereCeY=sphereCe[1]; + var sphereCeZ=sphereCe[2]; + var sphereR=sphere.radius; + Vector3.Clamp(sphereC,boxMin,boxMax,Collision._tempV30); + var distance=Vector3.distanceSquared(sphereC,Collision._tempV30); + if (distance > sphereR *sphereR) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if ((((boxMineX+sphereR <=sphereCeX)&& (sphereCeX <=boxMaxeX-sphereR))&& ((boxMaxeX-boxMineX > sphereR)&& + (boxMineY+sphereR <=sphereCeY)))&& (((sphereCeY <=boxMaxeY-sphereR)&& (boxMaxeY-boxMineY > sphereR))&& + (((boxMineZ+sphereR <=sphereCeZ)&& (sphereCeZ <=boxMaxeZ-sphereR))&& (boxMaxeZ-boxMineZ > sphereR)))) + return /*laya.d3.math.ContainmentType.Contains*/1; + return /*laya.d3.math.ContainmentType.Intersects*/2; + } + + Collision.sphereContainsPoint=function(sphere,point){ + if (Vector3.distanceSquared(point,sphere.center)<=sphere.radius *sphere.radius) + return /*laya.d3.math.ContainmentType.Contains*/1; + return /*laya.d3.math.ContainmentType.Disjoint*/0; + } + + Collision.sphereContainsTriangle=function(sphere,vertex1,vertex2,vertex3){ + var test1=Collision.sphereContainsPoint(sphere,vertex1); + var test2=Collision.sphereContainsPoint(sphere,vertex2); + var test3=Collision.sphereContainsPoint(sphere,vertex3); + if (test1==/*laya.d3.math.ContainmentType.Contains*/1 && test2==/*laya.d3.math.ContainmentType.Contains*/1 && test3==/*laya.d3.math.ContainmentType.Contains*/1) + return /*laya.d3.math.ContainmentType.Contains*/1; + if (Collision.intersectsSphereAndTriangle(sphere,vertex1,vertex2,vertex3)) + return /*laya.d3.math.ContainmentType.Intersects*/2; + return /*laya.d3.math.ContainmentType.Disjoint*/0; + } + + Collision.sphereContainsBox=function(sphere,box){ + var sphereC=sphere.center; + var sphereCe=sphereC.elements; + var sphereCeX=sphereCe[0]; + var sphereCeY=sphereCe[1]; + var sphereCeZ=sphereCe[2]; + var sphereR=sphere.radius; + var boxMin=box.min; + var boxMine=boxMin.elements; + var boxMineX=boxMine[0]; + var boxMineY=boxMine[1]; + var boxMineZ=boxMine[2]; + var boxMax=box.max; + var boxMaxe=boxMax.elements; + var boxMaxeX=boxMaxe[0]; + var boxMaxeY=boxMaxe[1]; + var boxMaxeZ=boxMaxe[2]; + var _tempV30e=Collision._tempV30.elements; + var _tempV30eX=_tempV30e[0]; + var _tempV30eY=_tempV30e[1]; + var _tempV30eZ=_tempV30e[2]; + if (!Collision.intersectsBoxAndSphere(box,sphere)) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + var radiusSquared=sphereR *sphereR; + _tempV30eX=sphereCeX-boxMineX; + _tempV30eY=sphereCeY-boxMaxeY; + _tempV30eZ=sphereCeZ-boxMaxeZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMaxeX; + _tempV30eY=sphereCeY-boxMaxeY; + _tempV30eZ=sphereCeZ-boxMaxeZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMaxeX; + _tempV30eY=sphereCeY-boxMineY; + _tempV30eZ=sphereCeZ-boxMaxeZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMineX; + _tempV30eY=sphereCeY-boxMineY; + _tempV30eZ=sphereCeZ-boxMaxeZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMineX; + _tempV30eY=sphereCeY-boxMaxeY; + _tempV30eZ=sphereCeZ-boxMineZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMaxeX; + _tempV30eY=sphereCeY-boxMaxeY; + _tempV30eZ=sphereCeZ-boxMineZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMaxeX; + _tempV30eY=sphereCeY-boxMineY; + _tempV30eZ=sphereCeZ-boxMineZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + _tempV30eX=sphereCeX-boxMineX; + _tempV30eY=sphereCeY-boxMineY; + _tempV30eZ=sphereCeZ-boxMineZ; + if (Vector3.scalarLengthSquared(Collision._tempV30)> radiusSquared) + return /*laya.d3.math.ContainmentType.Intersects*/2; + return /*laya.d3.math.ContainmentType.Contains*/1; + } + + Collision.sphereContainsSphere=function(sphere1,sphere2){ + var sphere1R=sphere1.radius; + var sphere2R=sphere2.radius; + var distance=Vector3.distance(sphere1.center,sphere2.center); + if (sphere1R+sphere2R < distance) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + if (sphere1R-sphere2R < distance) + return /*laya.d3.math.ContainmentType.Intersects*/2; + return /*laya.d3.math.ContainmentType.Contains*/1; + } + + Collision.closestPointPointTriangle=function(point,vertex1,vertex2,vertex3,out){ + Vector3.subtract(vertex2,vertex1,Collision._tempV30); + Vector3.subtract(vertex3,vertex1,Collision._tempV31); + Vector3.subtract(point,vertex1,Collision._tempV32); + Vector3.subtract(point,vertex2,Collision._tempV33); + Vector3.subtract(point,vertex3,Collision._tempV34); + var d1=Vector3.dot(Collision._tempV30,Collision._tempV32); + var d2=Vector3.dot(Collision._tempV31,Collision._tempV32); + var d3=Vector3.dot(Collision._tempV30,Collision._tempV33); + var d4=Vector3.dot(Collision._tempV31,Collision._tempV33); + var d5=Vector3.dot(Collision._tempV30,Collision._tempV34); + var d6=Vector3.dot(Collision._tempV31,Collision._tempV34); + if (d1 <=0 && d2 <=0){ + vertex1.cloneTo(out); + return; + } + if (d3 >=0 && d4 <=d3){ + vertex2.cloneTo(out); + return; + }; + var vc=d1 *d4-d3 *d2; + if (vc <=0 && d1 >=0 && d3 <=0){ + var v=d1 / (d1-d3); + Vector3.scale(Collision._tempV30,v,out); + Vector3.add(vertex1,out,out); + return; + } + if (d6 >=0 && d5 <=d6){ + vertex3.cloneTo(out); + return; + }; + var vb=d5 *d2-d1 *d6; + if (vb <=0 && d2 >=0 && d6 <=0){ + var w=d2 / (d2-d6); + Vector3.scale(Collision._tempV31,w,out); + Vector3.add(vertex1,out,out); + return; + }; + var va=d3 *d6-d5 *d4; + if (va <=0 && (d4-d3)>=0 && (d5-d6)>=0){ + var w3=(d4-d3)/ ((d4-d3)+(d5-d6)); + Vector3.subtract(vertex3,vertex2,out); + Vector3.scale(out,w3,out); + Vector3.add(vertex2,out,out); + return; + }; + var denom=1 / (va+vb+vc); + var v2=vb *denom; + var w2=vc *denom; + Vector3.scale(Collision._tempV30,v2,Collision._tempV35); + Vector3.scale(Collision._tempV31,w2,Collision._tempV36); + Vector3.add(Collision._tempV35,Collision._tempV36,out); + Vector3.add(vertex1,out,out); + } + + Collision.closestPointPlanePoint=function(plane,point,out){ + var planeN=plane.normal; + var t=Vector3.dot(planeN,point)-plane.distance; + Vector3.scale(planeN,t,Collision._tempV30); + Vector3.subtract(point,Collision._tempV30,out); + } + + Collision.closestPointBoxPoint=function(box,point,out){ + Vector3.max(point,box.min,Collision._tempV30); + Vector3.min(Collision._tempV30,box.max,out); + } + + Collision.closestPointSpherePoint=function(sphere,point,out){ + var sphereC=sphere.center; + Vector3.subtract(point,sphereC,out); + Vector3.normalize(out,out); + Vector3.scale(out,sphere.radius,out); + Vector3.add(out,sphereC,out); + } + + Collision.closestPointSphereSphere=function(sphere1,sphere2,out){ + var sphere1C=sphere1.center; + Vector3.subtract(sphere2.center,sphere1C,out); + Vector3.normalize(out,out); + Vector3.scale(out,sphere1.radius,out); + Vector3.add(out,sphere1C,out); + } + + __static(Collision, + ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempV35',function(){return this._tempV35=new Vector3();},'_tempV36',function(){return this._tempV36=new Vector3();} + ]); + return Collision; + })() + + + /** + *ContainmentType 类用于定义空间物体位置关系。 + */ + //class laya.d3.math.ContainmentType + var ContainmentType=(function(){ + function ContainmentType(){}; + __class(ContainmentType,'laya.d3.math.ContainmentType'); + ContainmentType.Disjoint=0; + ContainmentType.Contains=1; + ContainmentType.Intersects=2; + return ContainmentType; + })() + + + /** + *MathUtils 类用于创建数学工具。 + */ + //class laya.d3.math.MathUtils3D + var MathUtils3D=(function(){ + /** + *创建一个 MathUtils 实例。 + */ + function MathUtils3D(){} + __class(MathUtils3D,'laya.d3.math.MathUtils3D'); + MathUtils3D.isZero=function(v){ + return Math.abs(v)< MathUtils3D.zeroTolerance; + } + + MathUtils3D.nearEqual=function(n1,n2){ + if (MathUtils3D.isZero(n1-n2)) + return true; + return false; + } + + MathUtils3D.fastInvSqrt=function(value){ + if (MathUtils3D.isZero(value)) + return value; + return 1.0 / Math.sqrt(value); + } + + __static(MathUtils3D, + ['zeroTolerance',function(){return this.zeroTolerance=1e-6;},'MaxValue',function(){return this.MaxValue=3.40282347e+38;},'MinValue',function(){return this.MinValue=-3.40282347e+38;} + ]); + return MathUtils3D; + })() + + + /** + *Matrix3x3 类用于创建3x3矩阵。 + */ + //class laya.d3.math.Matrix3x3 + var Matrix3x3=(function(){ + function Matrix3x3(){ + //this.elements=null; + var e=this.elements=new Float32Array(9); + e[0]=1; + e[1]=0; + e[2]=0; + e[3]=0; + e[4]=1; + e[5]=0; + e[6]=0; + e[7]=0; + e[8]=1; + } + + __class(Matrix3x3,'laya.d3.math.Matrix3x3'); + var __proto=Matrix3x3.prototype; + /** + *计算3x3矩阵的行列式 + *@return 矩阵的行列式 + */ + __proto.determinant=function(){ + var f=this.elements; + var a00=f[0],a01=f[1],a02=f[2]; + var a10=f[3],a11=f[4],a12=f[5]; + var a20=f[6],a21=f[7],a22=f[8]; + return a00 *(a22 *a11-a12 *a21)+a01 *(-a22 *a10+a12 *a20)+a02 *(a21 *a10-a11 *a20); + } + + /** + *通过一个二维向量转换3x3矩阵 + *@param tra 转换向量 + *@param out 输出矩阵 + */ + __proto.translate=function(trans,out){ + var e=out.elements; + var f=this.elements; + var g=trans.elements; + var a00=f[0],a01=f[1],a02=f[2]; + var a10=f[3],a11=f[4],a12=f[5]; + var a20=f[6],a21=f[7],a22=f[8]; + var x=g[0],y=g[1]; + e[0]=a00; + e[1]=a01; + e[2]=a02; + e[3]=a10; + e[4]=a11; + e[5]=a12; + e[6]=x *a00+y *a10+a20; + e[7]=x *a01+y *a11+a21; + e[8]=x *a02+y *a12+a22; + } + + /** + *根据指定角度旋转3x3矩阵 + *@param rad 旋转角度 + *@param out 输出矩阵 + */ + __proto.rotate=function(rad,out){ + var e=out.elements; + var f=this.elements; + var a00=f[0],a01=f[1],a02=f[2]; + var a10=f[3],a11=f[4],a12=f[5]; + var a20=f[6],a21=f[7],a22=f[8]; + var s=Math.sin(rad); + var c=Math.cos(rad); + e[0]=c *a00+s *a10; + e[1]=c *a01+s *a11; + e[2]=c *a02+s *a12; + e[3]=c *a10-s *a00; + e[4]=c *a11-s *a01; + e[5]=c *a12-s *a02; + e[6]=a20; + e[7]=a21; + e[8]=a22; + } + + /** + *根据制定缩放3x3矩阵 + *@param scale 缩放值 + *@param out 输出矩阵 + */ + __proto.scale=function(scale,out){ + var e=out.elements; + var f=this.elements; + var g=scale.elements; + var x=g[0],y=g[1]; + e[0]=x *f[0]; + e[1]=x *f[1]; + e[2]=x *f[2]; + e[3]=y *f[3]; + e[4]=y *f[4]; + e[5]=y *f[5]; + e[6]=f[6]; + e[7]=f[7]; + e[8]=f[8]; + } + + /** + *计算3x3矩阵的逆矩阵 + *@param out 输出的逆矩阵 + */ + __proto.invert=function(out){ + var e=out.elements; + var f=this.elements; + var a00=f[0],a01=f[1],a02=f[2]; + var a10=f[3],a11=f[4],a12=f[5]; + var a20=f[6],a21=f[7],a22=f[8]; + var b01=a22 *a11-a12 *a21; + var b11=-a22 *a10+a12 *a20; + var b21=a21 *a10-a11 *a20; + var det=a00 *b01+a01 *b11+a02 *b21; + if (!det){ + out=null; + } + det=1.0 / det; + e[0]=b01 *det; + e[1]=(-a22 *a01+a02 *a21)*det; + e[2]=(a12 *a01-a02 *a11)*det; + e[3]=b11 *det; + e[4]=(a22 *a00-a02 *a20)*det; + e[5]=(-a12 *a00+a02 *a10)*det; + e[6]=b21 *det; + e[7]=(-a21 *a00+a01 *a20)*det; + e[8]=(a11 *a00-a01 *a10)*det; + } + + /** + *计算3x3矩阵的转置矩阵 + *@param out 输出矩阵 + */ + __proto.transpose=function(out){ + var e=out.elements; + var f=this.elements; + if (out===this){ + var a01=f[1],a02=f[2],a12=f[5]; + e[1]=f[3]; + e[2]=f[6]; + e[3]=a01; + e[5]=f[7]; + e[6]=a02; + e[7]=a12; + }else { + e[0]=f[0]; + e[1]=f[3]; + e[2]=f[6]; + e[3]=f[1]; + e[4]=f[4]; + e[5]=f[7]; + e[6]=f[2]; + e[7]=f[5]; + e[8]=f[8]; + } + } + + /**设置已有的矩阵为单位矩阵*/ + __proto.identity=function(){ + var e=this.elements; + e[0]=1; + e[1]=0; + e[2]=0; + e[3]=0; + e[4]=1; + e[5]=0; + e[6]=0; + e[7]=0; + e[8]=1; + } + + /** + *克隆一个3x3矩阵 + *@param out 输出的3x3矩阵 + */ + __proto.cloneTo=function(out){ + var i,s,d; + s=this.elements; + d=out.elements; + if (s===d){ + return; + } + for (i=0;i < 9;++i){ + d[i]=s[i]; + } + } + + /** + *从一个3x3矩阵复制 + *@param sou 源3x3矩阵 + */ + __proto.copyFrom=function(sou){ + var i,s,d; + s=sou.elements; + d=this.elements; + if (s===d){ + return; + } + for (i=0;i < 9;++i){ + d[i]=s[i]; + } + } + + /** + *从一个数组复制 + *@param sou 源Float32Array数组 + */ + __proto.copyFromArray=function(sou){ + var i,d; + d=this.elements; + if (sou===d){ + return; + } + for (i=0;i < 9;++i){ + d[i]=sou[i]; + } + } + + Matrix3x3.createFromTranslation=function(trans,out){ + var e=out.elements; + var g=trans.elements; + out[0]=1; + out[1]=0; + out[2]=0; + out[3]=0; + out[4]=1; + out[5]=0; + out[6]=g[0]; + out[7]=g[1]; + out[8]=1; + } + + Matrix3x3.createFromRotation=function(rad,out){ + var e=out.elements; + var s=Math.sin(rad),c=Math.cos(rad); + e[0]=c; + e[1]=s; + e[2]=0; + e[3]=-s; + e[4]=c; + e[5]=0; + e[6]=0; + e[7]=0; + e[8]=1; + } + + Matrix3x3.createFromScaling=function(scale,out){ + var e=out.elements; + var g=scale.elements; + e[0]=g[0]; + e[1]=0; + e[2]=0; + e[3]=0; + e[4]=g[1]; + e[5]=0; + e[6]=0; + e[7]=0; + e[8]=1; + } + + Matrix3x3.createFromMatrix4x4=function(sou,out){ + out[0]=sou[0]; + out[1]=sou[1]; + out[2]=sou[2]; + out[3]=sou[4]; + out[4]=sou[5]; + out[5]=sou[6]; + out[6]=sou[8]; + out[7]=sou[9]; + out[8]=sou[10]; + } + + Matrix3x3.multiply=function(left,right,out){ + var e=out.elements; + var f=left.elements; + var g=right.elements; + var a00=f[0],a01=f[1],a02=f[2]; + var a10=f[3],a11=f[4],a12=f[5]; + var a20=f[6],a21=f[7],a22=f[8]; + var b00=g[0],b01=g[1],b02=g[2]; + var b10=g[3],b11=g[4],b12=g[5]; + var b20=g[6],b21=g[7],b22=g[8]; + e[0]=b00 *a00+b01 *a10+b02 *a20; + e[1]=b00 *a01+b01 *a11+b02 *a21; + e[2]=b00 *a02+b01 *a12+b02 *a22; + e[3]=b10 *a00+b11 *a10+b12 *a20; + e[4]=b10 *a01+b11 *a11+b12 *a21; + e[5]=b10 *a02+b11 *a12+b12 *a22; + e[6]=b20 *a00+b21 *a10+b22 *a20; + e[7]=b20 *a01+b21 *a11+b22 *a21; + e[8]=b20 *a02+b21 *a12+b22 *a22; + } + + Matrix3x3.DEFAULT=new Matrix3x3(); + return Matrix3x3; + })() + + + /** + *Matrix4x4 类用于创建4x4矩阵。 + */ + //class laya.d3.math.Matrix4x4 + var Matrix4x4=(function(){ + function Matrix4x4(m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44){ + //this.elements=null; + (m11===void 0)&& (m11=1); + (m12===void 0)&& (m12=0); + (m13===void 0)&& (m13=0); + (m14===void 0)&& (m14=0); + (m21===void 0)&& (m21=0); + (m22===void 0)&& (m22=1); + (m23===void 0)&& (m23=0); + (m24===void 0)&& (m24=0); + (m31===void 0)&& (m31=0); + (m32===void 0)&& (m32=0); + (m33===void 0)&& (m33=1); + (m34===void 0)&& (m34=0); + (m41===void 0)&& (m41=0); + (m42===void 0)&& (m42=0); + (m43===void 0)&& (m43=0); + (m44===void 0)&& (m44=1); + var e=this.elements=new Float32Array(16); + e[0]=m11; + e[1]=m12; + e[2]=m13; + e[3]=m14; + e[4]=m21; + e[5]=m22; + e[6]=m23; + e[7]=m24; + e[8]=m31; + e[9]=m32; + e[10]=m33; + e[11]=m34; + e[12]=m41; + e[13]=m42; + e[14]=m43; + e[15]=m44; + } + + __class(Matrix4x4,'laya.d3.math.Matrix4x4'); + var __proto=Matrix4x4.prototype; + /** + *判断两个4x4矩阵的值是否相等。 + *@param other 4x4矩阵 + */ + __proto.equalsOtherMatrix=function(other){ + var e=this.elements; + var oe=other.elements; + return (MathUtils3D.nearEqual(e[0],oe[0])&& MathUtils3D.nearEqual(e[1],oe[1])&& MathUtils3D.nearEqual(e[2],oe[2])&& MathUtils3D.nearEqual(e[3],oe[3])&& MathUtils3D.nearEqual(e[4],oe[4])&& MathUtils3D.nearEqual(e[5],oe[5])&& MathUtils3D.nearEqual(e[6],oe[6])&& MathUtils3D.nearEqual(e[7],oe[7])&& MathUtils3D.nearEqual(e[8],oe[8])&& MathUtils3D.nearEqual(e[9],oe[9])&& MathUtils3D.nearEqual(e[10],oe[10])&& MathUtils3D.nearEqual(e[11],oe[11])&& MathUtils3D.nearEqual(e[12],oe[12])&& MathUtils3D.nearEqual(e[13],oe[13])&& MathUtils3D.nearEqual(e[14],oe[14])&& MathUtils3D.nearEqual(e[15],oe[15])); + } + + /** + *分解矩阵 + *@param translation 平移 + *@param rotation 旋转 + *@param scale 缩放 + *@return 是否成功 + */ + __proto.decompose=function(translation,rotation,scale){ + var me=this.elements; + var te=translation.elements; + var re=rotation.elements; + var se=scale.elements; + te[0]=me[12]; + te[1]=me[13]; + te[2]=me[14]; + se[0]=Math.sqrt((me[0] *me[0])+(me[1] *me[1])+(me[2] *me[2])); + se[1]=Math.sqrt((me[4] *me[4])+(me[5] *me[5])+(me[6] *me[6])); + se[2]=Math.sqrt((me[8] *me[8])+(me[9] *me[9])+(me[10] *me[10])); + if (MathUtils3D.isZero(se[0])|| MathUtils3D.isZero(se[1])|| MathUtils3D.isZero(se[2])){ + re[0]=re[1]=re[2]=0; + re[3]=1; + return false; + }; + var rotationmatrix=new Matrix4x4(); + var rme=rotationmatrix.elements; + rme[0]=me[0] / se[0]; + rme[1]=me[1] / se[0]; + rme[2]=me[2] / se[0]; + rme[4]=me[4] / se[1]; + rme[5]=me[5] / se[1]; + rme[6]=me[6] / se[1]; + rme[8]=me[8] / se[2]; + rme[9]=me[9] / se[2]; + rme[10]=me[10] / se[2]; + rotationmatrix[15]=1; + Quaternion.createFromMatrix4x4(rotationmatrix,rotation); + return true; + } + + /**归一化矩阵 */ + __proto.normalize=function(){ + var v=this.elements; + var c=v[0],d=v[1],e=v[2],g=Math.sqrt(c *c+d *d+e *e); + if (g){ + if (g==1) + return; + }else { + v[0]=0; + v[1]=0; + v[2]=0; + return; + } + g=1 / g; + v[0]=c *g; + v[1]=d *g; + v[2]=e *g; + } + + /**计算矩阵的转置矩阵*/ + __proto.transpose=function(){ + var e,t; + e=this.elements; + t=e[1]; + e[1]=e[4]; + e[4]=t; + t=e[2]; + e[2]=e[8]; + e[8]=t; + t=e[3]; + e[3]=e[12]; + e[12]=t; + t=e[6]; + e[6]=e[9]; + e[9]=t; + t=e[7]; + e[7]=e[13]; + e[13]=t; + t=e[11]; + e[11]=e[14]; + e[14]=t; + return this; + } + + /** + *计算一个矩阵的逆矩阵 + *@param out 输出矩阵 + */ + __proto.invert=function(out){ + var ae=this.elements; + var oe=out.elements; + var a00=ae[0],a01=ae[1],a02=ae[2],a03=ae[3],a10=ae[4],a11=ae[5],a12=ae[6],a13=ae[7],a20=ae[8],a21=ae[9],a22=ae[10],a23=ae[11],a30=ae[12],a31=ae[13],a32=ae[14],a33=ae[15], + b00=a00 *a11-a01 *a10,b01=a00 *a12-a02 *a10,b02=a00 *a13-a03 *a10,b03=a01 *a12-a02 *a11,b04=a01 *a13-a03 *a11,b05=a02 *a13-a03 *a12,b06=a20 *a31-a21 *a30,b07=a20 *a32-a22 *a30,b08=a20 *a33-a23 *a30,b09=a21 *a32-a22 *a31,b10=a21 *a33-a23 *a31,b11=a22 *a33-a23 *a32, + det=b00 *b11-b01 *b10+b02 *b09+b03 *b08-b04 *b07+b05 *b06; + if (Math.abs(det)===0.0){ + return; + } + det=1.0 / det; + oe[0]=(a11 *b11-a12 *b10+a13 *b09)*det; + oe[1]=(a02 *b10-a01 *b11-a03 *b09)*det; + oe[2]=(a31 *b05-a32 *b04+a33 *b03)*det; + oe[3]=(a22 *b04-a21 *b05-a23 *b03)*det; + oe[4]=(a12 *b08-a10 *b11-a13 *b07)*det; + oe[5]=(a00 *b11-a02 *b08+a03 *b07)*det; + oe[6]=(a32 *b02-a30 *b05-a33 *b01)*det; + oe[7]=(a20 *b05-a22 *b02+a23 *b01)*det; + oe[8]=(a10 *b10-a11 *b08+a13 *b06)*det; + oe[9]=(a01 *b08-a00 *b10-a03 *b06)*det; + oe[10]=(a30 *b04-a31 *b02+a33 *b00)*det; + oe[11]=(a21 *b02-a20 *b04-a23 *b00)*det; + oe[12]=(a11 *b07-a10 *b09-a12 *b06)*det; + oe[13]=(a00 *b09-a01 *b07+a02 *b06)*det; + oe[14]=(a31 *b01-a30 *b03-a32 *b00)*det; + oe[15]=(a20 *b03-a21 *b01+a22 *b00)*det; + } + + /**设置矩阵为单位矩阵*/ + __proto.identity=function(){ + var e=this.elements; + e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0; + e[0]=e[5]=e[10]=e[15]=1; + } + + /** + *克隆一个4x4矩阵 + *@param out 输出的4x4矩阵 + */ + __proto.cloneTo=function(out){ + var i,s,d; + s=this.elements; + d=out.elements; + if (s===d){ + return; + } + for (i=0;i < 16;++i){ + d[i]=s[i]; + } + } + + /** + *从一个4x4矩阵复制 + *@param sou 源4x4矩阵 + */ + __proto.copyFrom=function(sou){ + var i,s,d; + s=sou.elements; + d=this.elements; + if (s===d){ + return; + } + for (i=0;i < 16;++i){ + d[i]=s[i]; + } + } + + /** + *从一个数组复制 + *@param sou 源Float32Array数组 + */ + __proto.copyFromArray=function(sou){ + var i,d; + d=this.elements; + if (sou===d){ + return; + } + for (i=0;i < 16;++i){ + d[i]=sou[i]; + } + } + + __getset(0,__proto,'translationVector',function(){ + var me=this.elements; + var oe=Matrix4x4._translationVector.elements; + oe[0]=me[12]; + oe[1]=me[13]; + oe[2]=me[14]; + return Matrix4x4._translationVector; + },function(v3){ + var me=this.elements; + var ve=v3.elements; + me[12]=ve[0]; + me[13]=ve[1]; + me[14]=ve[2]; + }); + + Matrix4x4.createRotationX=function(rad,out){ + var oe=out.elements; + var s=Math.sin(rad),c=Math.cos(rad); + oe[1]=oe[2]=oe[3]=oe[4]=oe[7]=oe[8]=oe[11]=oe[12]=oe[13]=oe[14]=0; + oe[0]=oe[15]=1; + oe[5]=oe[10]=c; + oe[6]=s; + oe[9]=-s; + } + + Matrix4x4.createRotationY=function(rad,out){ + var oe=out.elements; + var s=Math.sin(rad),c=Math.cos(rad); + oe[1]=oe[3]=oe[4]=oe[6]=oe[7]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0; + oe[5]=oe[15]=1; + oe[0]=oe[10]=c; + oe[2]=-s; + oe[8]=s; + } + + Matrix4x4.createRotationZ=function(rad,out){ + var oe=out.elements; + var s=Math.sin(rad),c=Math.cos(rad); + oe[2]=oe[3]=oe[6]=oe[7]=oe[8]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0; + oe[10]=oe[15]=1; + oe[0]=oe[5]=c; + oe[1]=s; + oe[4]=-s; + } + + Matrix4x4.createRotationYawPitchRoll=function(yaw,pitch,roll,result){ + Quaternion.createFromYawPitchRoll(yaw,pitch,roll,Matrix4x4._tempQuaternion); + Matrix4x4.createRotationQuaternion(Matrix4x4._tempQuaternion,result); + } + + Matrix4x4.createRotationQuaternion=function(rotation,result){ + var rotationE=rotation.elements; + var resultE=result.elements; + var rotationX=rotationE[0]; + var rotationY=rotationE[1]; + var rotationZ=rotationE[2]; + var rotationW=rotationE[3]; + var xx=rotationX *rotationX; + var yy=rotationY *rotationY; + var zz=rotationZ *rotationZ; + var xy=rotationX *rotationY; + var zw=rotationZ *rotationW; + var zx=rotationZ *rotationX; + var yw=rotationY *rotationW; + var yz=rotationY *rotationZ; + var xw=rotationX *rotationW; + resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0; + resultE[15]=1.0; + resultE[0]=1.0-(2.0 *(yy+zz)); + resultE[1]=2.0 *(xy+zw); + resultE[2]=2.0 *(zx-yw); + resultE[4]=2.0 *(xy-zw); + resultE[5]=1.0-(2.0 *(zz+xx)); + resultE[6]=2.0 *(yz+xw); + resultE[8]=2.0 *(zx+yw); + resultE[9]=2.0 *(yz-xw); + resultE[10]=1.0-(2.0 *(yy+xx)); + } + + Matrix4x4.createTranslate=function(trans,out){ + var te=trans.elements; + var oe=out.elements; + oe[4]=oe[8]=oe[1]=oe[9]=oe[2]=oe[6]=oe[3]=oe[7]=oe[11]=0; + oe[0]=oe[5]=oe[10]=oe[15]=1; + oe[12]=te[0]; + oe[13]=te[1]; + oe[14]=te[2]; + } + + Matrix4x4.createScaling=function(scale,out){ + var se=scale.elements; + var oe=out.elements; + oe[0]=se[0]; + oe[5]=se[1]; + oe[10]=se[2]; + oe[1]=oe[4]=oe[8]=oe[12]=oe[9]=oe[13]=oe[2]=oe[6]=oe[14]=oe[3]=oe[7]=oe[11]=0; + oe[15]=1; + } + + Matrix4x4.multiply=function(left,right,out){ + var i,e,a,b,ai0,ai1,ai2,ai3; + e=out.elements; + a=left.elements; + b=right.elements; + if (e===b){ + b=new Float32Array(16); + for (i=0;i < 16;++i){ + b[i]=e[i]; + } + } + for (i=0;i < 4;i++){ + ai0=a[i]; + ai1=a[i+4]; + ai2=a[i+8]; + ai3=a[i+12]; + e[i]=ai0 *b[0]+ai1 *b[1]+ai2 *b[2]+ai3 *b[3]; + e[i+4]=ai0 *b[4]+ai1 *b[5]+ai2 *b[6]+ai3 *b[7]; + e[i+8]=ai0 *b[8]+ai1 *b[9]+ai2 *b[10]+ai3 *b[11]; + e[i+12]=ai0 *b[12]+ai1 *b[13]+ai2 *b[14]+ai3 *b[15]; + } + } + + Matrix4x4.createFromQuaternion=function(rotation,out){ + var e=out.elements; + var q=rotation.elements; + var x=q[0],y=q[1],z=q[2],w=q[3]; + var x2=x+x; + var y2=y+y; + var z2=z+z; + var xx=x *x2; + var yx=y *x2; + var yy=y *y2; + var zx=z *x2; + var zy=z *y2; + var zz=z *z2; + var wx=w *x2; + var wy=w *y2; + var wz=w *z2; + e[0]=1-yy-zz; + e[1]=yx+wz; + e[2]=zx-wy; + e[3]=0; + e[4]=yx-wz; + e[5]=1-xx-zz; + e[6]=zy+wx; + e[7]=0; + e[8]=zx+wy; + e[9]=zy-wx; + e[10]=1-xx-yy; + e[11]=0; + e[12]=0; + e[13]=0; + e[14]=0; + out[15]=1; + } + + Matrix4x4.createAffineTransformation=function(trans,rot,scale,out){ + var te=trans.elements; + var re=rot.elements; + var se=scale.elements; + var oe=out.elements; + var x=re[0],y=re[1],z=re[2],w=re[3],x2=x+x,y2=y+y,z2=z+z; + var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2; + var wx=w *x2,wy=w *y2,wz=w *z2,sx=se[0],sy=se[1],sz=se[2]; + oe[0]=(1-(yy+zz))*sx; + oe[1]=(xy+wz)*sx; + oe[2]=(xz-wy)*sx; + oe[3]=0; + oe[4]=(xy-wz)*sy; + oe[5]=(1-(xx+zz))*sy; + oe[6]=(yz+wx)*sy; + oe[7]=0; + oe[8]=(xz+wy)*sz; + oe[9]=(yz-wx)*sz; + oe[10]=(1-(xx+yy))*sz; + oe[11]=0; + oe[12]=te[0]; + oe[13]=te[1]; + oe[14]=te[2]; + oe[15]=1; + } + + Matrix4x4.createLookAt=function(eye,center,up,out){ + var ee=eye.elements; + var ce=center.elements; + var ue=up.elements; + var oe=out.elements; + var x0,x1,x2,y0,y1,y2,z0,z1,z2,len,eyex=ee[0],eyey=ee[1],eyez=ee[2],upx=ue[0],upy=ue[1],upz=ue[2],centerx=ce[0],centery=ce[1],centerz=ce[2]; + if (Math.abs(eyex-centerx)< MathUtils3D.zeroTolerance && Math.abs(eyey-centery)< MathUtils3D.zeroTolerance && Math.abs(eyez-centerz)< MathUtils3D.zeroTolerance){ + out.identity(); + return; + } + z0=eyex-centerx; + z1=eyey-centery; + z2=eyez-centerz; + len=1 / Math.sqrt(z0 *z0+z1 *z1+z2 *z2); + z0 *=len; + z1 *=len; + z2 *=len; + x0=upy *z2-upz *z1; + x1=upz *z0-upx *z2; + x2=upx *z1-upy *z0; + len=Math.sqrt(x0 *x0+x1 *x1+x2 *x2); + if (!len){ + x0=x1=x2=0; + }else { + len=1 / len; + x0 *=len; + x1 *=len; + x2 *=len; + } + y0=z1 *x2-z2 *x1; + y1=z2 *x0-z0 *x2; + y2=z0 *x1-z1 *x0; + len=Math.sqrt(y0 *y0+y1 *y1+y2 *y2); + if (!len){ + y0=y1=y2=0; + }else { + len=1 / len; + y0 *=len; + y1 *=len; + y2 *=len; + } + oe[0]=x0; + oe[1]=y0; + oe[2]=z0; + oe[3]=0; + oe[4]=x1; + oe[5]=y1; + oe[6]=z1; + oe[7]=0; + oe[8]=x2; + oe[9]=y2; + oe[10]=z2; + oe[11]=0; + oe[12]=-(x0 *eyex+x1 *eyey+x2 *eyez); + oe[13]=-(y0 *eyex+y1 *eyey+y2 *eyez); + oe[14]=-(z0 *eyex+z1 *eyey+z2 *eyez); + oe[15]=1; + } + + Matrix4x4.createPerspective=function(fov,aspect,near,far,out){ + var oe=out.elements; + var yScale=1.0 / Math.tan(fov *0.5); + var q=far / (near-far); + oe[0]=yScale / aspect; + oe[5]=yScale; + oe[10]=q; + oe[11]=-1.0; + oe[14]=q *near; + oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[7]=oe[8]=oe[9]=oe[12]=oe[13]=oe[15]=0; + } + + Matrix4x4.createOrthogonal=function(left,right,bottom,top,near,far,out){ + var oe=out.elements; + var lr=1 / (left-right); + var bt=1 / (bottom-top); + var nf=1 / (near-far); + oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[7]=oe[8]=oe[9]=oe[11]=0; + oe[15]=1; + oe[0]=-2 *lr; + oe[5]=-2 *bt; + oe[10]=2 *nf; + oe[12]=(left+right)*lr; + oe[13]=(top+bottom)*bt; + oe[14]=(far+near)*nf; + } + + Matrix4x4.translation=function(v3,out){ + var ve=v3.elements; + var oe=out.elements; + oe[0]=oe[5]=oe[10]=oe[15]=1; + oe[12]=ve[0]; + oe[13]=ve[1]; + oe[14]=ve[2]; + } + + Matrix4x4._tempMatrix4x4=new Matrix4x4(); + Matrix4x4.DEFAULT=new Matrix4x4(); + __static(Matrix4x4, + ['_tempQuaternion',function(){return this._tempQuaternion=new Quaternion();},'_translationVector',function(){return this._translationVector=new Vector3();} + ]); + return Matrix4x4; + })() + + + /** + *OrientedBoundBox 类用于创建OBB包围盒。 + */ + //class laya.d3.math.OrientedBoundBox + var OrientedBoundBox=(function(){ + function OrientedBoundBox(box){ + this.extents=null; + this.transformation=null; + var min=box.min; + var max=box.max; + Vector3.subtract(max,min,OrientedBoundBox._tempV30); + Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30); + Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31); + Vector3.subtract(max,OrientedBoundBox._tempV31,this.extents); + Matrix4x4.translation(OrientedBoundBox._tempV31,this.transformation); + } + + __class(OrientedBoundBox,'laya.d3.math.OrientedBoundBox'); + var __proto=OrientedBoundBox.prototype; + /** + *获取OBB包围盒的8个角顶点。 + *@param corners 返回顶点的输出队列。 + */ + __proto.getCorners=function(corners){ + var extentsE=this.extents.elements; + corners.length=8; + OrientedBoundBox._tempV30.x=extentsE[0]; + OrientedBoundBox._tempV31.y=extentsE[1]; + OrientedBoundBox._tempV32.z=extentsE[2]; + Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30); + Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31); + Vector3.TransformNormal(OrientedBoundBox._tempV32,this.transformation,OrientedBoundBox._tempV32); + OrientedBoundBox._tempV33=this.transformation.translationVector; + Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[0]); + Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[1]); + Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[2]); + Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[3]); + Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[4]); + Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[5]); + Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[6]); + Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34); + Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34); + Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[7]); + } + + /** + *变换该包围盒的矩阵信息。 + *@param mat 矩阵 + */ + __proto.transform=function(mat){ + Matrix4x4.multiply(this.transformation,mat,this.transformation); + } + + /** + *缩放该包围盒 + *@param scaling 各轴的缩放比。 + */ + __proto.scale=function(scaling){ + Vector3.multiply(this.extents,scaling,this.extents); + } + + /** + *平移该包围盒。 + *@param translation 平移参数 + */ + __proto.translate=function(translation){ + var v3=this.transformation.translationVector; + Vector3.add(v3,translation,OrientedBoundBox._tempV30); + this.transformation.translationVector=OrientedBoundBox._tempV30; + } + + /** + *该包围盒的尺寸。 + *@param out 输出 + */ + __proto.Size=function(out){ + Vector3.scale(this.extents,2,out); + } + + /** + *该包围盒需要考虑的尺寸 + *@param out 输出 + */ + __proto.getSize=function(out){ + var extentsE=this.extents.elements; + OrientedBoundBox._tempV30.x=extentsE[0]; + OrientedBoundBox._tempV31.y=extentsE[1]; + OrientedBoundBox._tempV32.z=extentsE[2]; + Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30); + Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31); + Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32); + var oe=out.elements; + oe[0]=Vector3.scalarLength(OrientedBoundBox._tempV30); + oe[1]=Vector3.scalarLength(OrientedBoundBox._tempV31); + oe[2]=Vector3.scalarLength(OrientedBoundBox._tempV32); + } + + /** + *该包围盒需要考虑尺寸的平方 + *@param out 输出 + */ + __proto.getSizeSquared=function(out){ + var extentsE=this.extents.elements; + OrientedBoundBox._tempV30.x=extentsE[0]; + OrientedBoundBox._tempV31.y=extentsE[1]; + OrientedBoundBox._tempV32.z=extentsE[2]; + Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30); + Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31); + Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32); + var oe=out.elements; + oe[0]=Vector3.scalarLengthSquared(OrientedBoundBox._tempV30); + oe[1]=Vector3.scalarLengthSquared(OrientedBoundBox._tempV31); + oe[2]=Vector3.scalarLengthSquared(OrientedBoundBox._tempV32); + } + + /** + *该包围盒的几何中心 + */ + __proto.getCenter=function(){ + return this.transformation.translationVector; + } + + /** + *该包围盒是否包含空间中一点 + *@param point 点 + *@return 返回位置关系 + */ + __proto.containsPoint=function(point){ + var extentsE=this.extents.elements; + var extentsEX=extentsE[0]; + var extentsEY=extentsE[1]; + var extentsEZ=extentsE[2]; + this.transformation.invert(OrientedBoundBox._tempM0); + Vector3.transformCoordinate(point,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30); + var _tempV30e=OrientedBoundBox._tempV30.elements; + var _tempV30ex=Math.abs(_tempV30e[0]); + var _tempV30ey=Math.abs(_tempV30e[1]); + var _tempV30ez=Math.abs(_tempV30e[2]); + if (MathUtils3D.nearEqual(_tempV30ex,extentsEX)&& MathUtils3D.nearEqual(_tempV30ey,extentsEY)&& MathUtils3D.nearEqual(_tempV30ez,extentsEZ)) + return /*laya.d3.math.ContainmentType.Intersects*/2; + if (_tempV30ex < extentsEX && _tempV30ey < extentsEY && _tempV30ez < extentsEZ) + return /*laya.d3.math.ContainmentType.Contains*/1; + else + return /*laya.d3.math.ContainmentType.Disjoint*/0; + } + + /** + *该包围盒是否包含空间中一包围球 + *@param sphere 包围球 + *@param ignoreScale 是否考虑该包围盒的缩放 + *@return 返回位置关系 + */ + __proto.containsSphere=function(sphere,ignoreScale){ + (ignoreScale===void 0)&& (ignoreScale=false); + var extentsE=this.extents.elements; + var extentsEX=extentsE[0]; + var extentsEY=extentsE[1]; + var extentsEZ=extentsE[2]; + var sphereR=sphere.radius; + this.transformation.invert(OrientedBoundBox._tempM0); + Vector3.transformCoordinate(sphere.center,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30); + var locRadius=NaN; + if (ignoreScale){ + locRadius=sphereR; + }else { + Vector3.scale(Vector3.UnitX,sphereR,OrientedBoundBox._tempV31); + Vector3.TransformNormal(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31); + locRadius=Vector3.scalarLength(OrientedBoundBox._tempV31); + } + Vector3.scale(this.extents,-1,OrientedBoundBox._tempV32); + Vector3.Clamp(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,this.extents,OrientedBoundBox._tempV33); + var distance=Vector3.distanceSquared(OrientedBoundBox._tempV30,OrientedBoundBox._tempV33); + if (distance > locRadius *locRadius) + return /*laya.d3.math.ContainmentType.Disjoint*/0; + var tempV30e=OrientedBoundBox._tempV30.elements; + var tempV30ex=tempV30e[0]; + var tempV30ey=tempV30e[1]; + var tempV30ez=tempV30e[2]; + var tempV32e=OrientedBoundBox._tempV32.elements; + var tempV32ex=tempV32e[0]; + var tempV32ey=tempV32e[1]; + var tempV32ez=tempV32e[2]; + if ((((tempV32ex+locRadius <=tempV30ex)&& (tempV30ex <=extentsEX-locRadius))&& ((extentsEX-tempV32ex > locRadius)&& (tempV32ey+locRadius <=tempV30ey)))&& (((tempV30ey <=extentsEY-locRadius)&& (extentsEY-tempV32ey > locRadius))&& (((tempV32ez+locRadius <=tempV30ez)&& (tempV30ez <=extentsEZ-locRadius))&& (extentsEZ-tempV32ez > locRadius)))){ + return /*laya.d3.math.ContainmentType.Contains*/1; + } + return /*laya.d3.math.ContainmentType.Intersects*/2; + } + + OrientedBoundBox._getRows=function(mat,out){ + out.length=3; + var mate=mat.elements; + var row0e=out[0].elements; + row0e[0]=mate[0]; + row0e[1]=mate[1]; + row0e[2]=mate[2]; + var row1e=out[1].elements; + row1e[0]=mate[4]; + row1e[1]=mate[5]; + row1e[2]=mate[6]; + var row2e=out[2].elements; + row2e[0]=mate[8]; + row2e[1]=mate[9]; + row2e[2]=mate[10]; + } + + __static(OrientedBoundBox, + ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempM0',function(){return this._tempM0=new Matrix4x4();},'_tempM1',function(){return this._tempM1=new Matrix4x4();} + ]); + return OrientedBoundBox; + })() + + + /** + *Plane 类用于创建平面。 + */ + //class laya.d3.math.Plane + var Plane=(function(){ + function Plane(normal,d){ + this.normal=null; + this.distance=NaN; + (d===void 0)&& (d=0); + this.normal=normal; + this.distance=d; + } + + __class(Plane,'laya.d3.math.Plane'); + var __proto=Plane.prototype; + /** + *更改平面法线向量的系数,使之成单位长度。 + */ + __proto.normalize=function(){ + var normalE=this.normal.elements; + var normalEX=normalE[0]; + var normalEY=normalE[1]; + var normalEZ=normalE[2]; + var magnitude=1 / Math.sqrt(normalEX *normalEX+normalEY *normalEY+normalEZ *normalEZ); + normalE[0]=normalEX *magnitude; + normalE[1]=normalEY *magnitude; + normalE[2]=normalEZ *magnitude; + this.distance *=magnitude; + } + + Plane.createPlaneBy3P=function(point1,point2,point3){ + var point1e=point1.elements; + var point2e=point2.elements; + var point3e=point3.elements; + var x1=point2e[0]-point1e[0]; + var y1=point2e[1]-point1e[1]; + var z1=point2e[2]-point1e[2]; + var x2=point3e[0]-point1e[0]; + var y2=point3e[1]-point1e[1]; + var z2=point3e[2]-point1e[2]; + var yz=(y1 *z2)-(z1 *y2); + var xz=(z1 *x2)-(x1 *z2); + var xy=(x1 *y2)-(y1 *x2); + var invPyth=1 / (Math.sqrt((yz *yz)+(xz *xz)+(xy *xy))); + var x=yz *invPyth; + var y=xz *invPyth; + var z=xy *invPyth; + var TEMPVec3e=Plane._TEMPVec3.elements; + TEMPVec3e[0]=x; + TEMPVec3e[1]=y; + TEMPVec3e[2]=z; + var d=-((x *point1e[0])+(y *point1e[1])+(z *point1e[2])); + var plane=new Plane(Plane._TEMPVec3,d); + return plane; + } + + Plane.PlaneIntersectionType_Back=0; + Plane.PlaneIntersectionType_Front=1; + Plane.PlaneIntersectionType_Intersecting=2; + __static(Plane, + ['_TEMPVec3',function(){return this._TEMPVec3=new Vector3();} + ]); + return Plane; + })() + + + /** + *Quaternion 类用于创建四元数。 + */ + //class laya.d3.math.Quaternion + var Quaternion=(function(){ + function Quaternion(x,y,z,w){ + this.elements=new Float32Array(4); + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (z===void 0)&& (z=0); + (w===void 0)&& (w=1); + this.elements[0]=x; + this.elements[1]=y; + this.elements[2]=z; + this.elements[3]=w; + } + + __class(Quaternion,'laya.d3.math.Quaternion'); + var __proto=Quaternion.prototype; + /** + *根据缩放值缩放四元数 + *@param scale 缩放值 + *@param out 输出四元数 + */ + __proto.scaling=function(scaling,out){ + var e=out.elements; + var f=this.elements; + e[0]=f[0] *scaling; + e[1]=f[1] *scaling; + e[2]=f[2] *scaling; + e[3]=f[3] *scaling; + } + + /** + *归一化四元数 + *@param out 输出四元数 + */ + __proto.normalize=function(out){ + var e=out.elements; + var f=this.elements; + var x=f[0],y=f[1],z=f[2],w=f[3]; + var len=x *x+y *y+z *z+w *w; + if (len > 0){ + len=1 / Math.sqrt(len); + e[0]=x *len; + e[1]=y *len; + e[2]=z *len; + e[3]=w *len; + } + } + + /** + *计算四元数的长度 + *@return 长度 + */ + __proto.length=function(){ + var f=this.elements; + var x=f[0],y=f[1],z=f[2],w=f[3]; + return Math.sqrt(x *x+y *y+z *z+w *w); + } + + /** + *根据绕X轴的角度旋转四元数 + *@param rad 角度 + *@param out 输出四元数 + */ + __proto.rotateX=function(rad,out){ + var e=out.elements; + var f=this.elements; + rad *=0.5; + var ax=f[0],ay=f[1],az=f[2],aw=f[3]; + var bx=Math.sin(rad),bw=Math.cos(rad); + e[0]=ax *bw+aw *bx; + e[1]=ay *bw+az *bx; + e[2]=az *bw-ay *bx; + e[3]=aw *bw-ax *bx; + } + + /** + *根据绕Y轴的制定角度旋转四元数 + *@param rad 角度 + *@param out 输出四元数 + */ + __proto.rotateY=function(rad,out){ + var e=out.elements; + var f=this.elements; + rad *=0.5; + var ax=f[0],ay=f[1],az=f[2],aw=f[3],by=Math.sin(rad),bw=Math.cos(rad); + e[0]=ax *bw-az *by; + e[1]=ay *bw+aw *by; + e[2]=az *bw+ax *by; + e[3]=aw *bw-ay *by; + } + + /** + *根据绕Z轴的制定角度旋转四元数 + *@param rad 角度 + *@param out 输出四元数 + */ + __proto.rotateZ=function(rad,out){ + var e=out.elements; + var f=this.elements; + rad *=0.5; + var ax=f[0],ay=f[1],az=f[2],aw=f[3],bz=Math.sin(rad),bw=Math.cos(rad); + e[0]=ax *bw+ay *bz; + e[1]=ay *bw-ax *bz; + e[2]=az *bw+aw *bz; + e[3]=aw *bw-az *bz; + } + + /** + *分解四元数到欧拉角(顺序为Yaw、Pitch、Roll),参考自http://xboxforums.create.msdn.com/forums/p/4574/23988.aspx#23988,问题绕X轴翻转超过±90度时有,会产生瞬间反转 + *@param quaternion 源四元数 + *@param out 欧拉角值 + */ + __proto.getYawPitchRoll=function(out){ + Vector3.transformQuat(Vector3.ForwardRH,this,Quaternion.TEMPVector31); + Vector3.transformQuat(Vector3.Up,this,Quaternion.TEMPVector32); + var upe=Quaternion.TEMPVector32.elements; + Quaternion.angleTo(Vector3.ZERO,Quaternion.TEMPVector31,Quaternion.TEMPVector33); + var anglee=Quaternion.TEMPVector33.elements; + if (anglee[0]==Math.PI / 2){ + anglee[1]=Quaternion.arcTanAngle(upe[2],upe[0]); + anglee[2]=0; + }else if (anglee[0]==-Math.PI / 2){ + anglee[1]=Quaternion.arcTanAngle(-upe[2],-upe[0]); + anglee[2]=0; + }else { + Matrix4x4.createRotationY(-anglee[1],Quaternion.TEMPMatrix0); + Matrix4x4.createRotationX(-anglee[0],Quaternion.TEMPMatrix1); + Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix0,Quaternion.TEMPVector32); + Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix1,Quaternion.TEMPVector32); + anglee[2]=Quaternion.arcTanAngle(upe[1],-upe[0]); + } + if (anglee[1] <=-Math.PI) + anglee[1]=Math.PI; + if (anglee[2] <=-Math.PI) + anglee[2]=Math.PI; + if (anglee[1] >=Math.PI && anglee[2] >=Math.PI){ + anglee[1]=0; + anglee[2]=0; + anglee[0]=Math.PI-anglee[0]; + }; + var oe=out.elements; + oe[0]=anglee[1]; + oe[1]=anglee[0]; + oe[2]=anglee[2]; + } + + /** + *求四元数的逆 + *@param out 输出四元数 + */ + __proto.invert=function(out){ + var e=out.elements; + var f=this.elements; + var a0=f[0],a1=f[1],a2=f[2],a3=f[3]; + var dot=a0 *a0+a1 *a1+a2 *a2+a3 *a3; + var invDot=dot ? 1.0 / dot :0; + e[0]=-a0 *invDot; + e[1]=-a1 *invDot; + e[2]=-a2 *invDot; + e[3]=a3 *invDot; + } + + /** + *设置四元数为单位算数 + *@param out 输出四元数 + */ + __proto.identity=function(){ + var e=this.elements; + e[0]=0; + e[1]=0; + e[2]=0; + e[3]=1; + } + + /** + *克隆一个四元数 + *@param out 输出的四元数 + */ + __proto.cloneTo=function(out){ + var i,s,d; + s=this.elements; + d=out.elements; + if (s===d){ + return; + } + for (i=0;i < 4;++i){ + d[i]=s[i]; + } + } + + /** + *从一个四元数复制 + *@param sou 源四元数 + */ + __proto.copyFrom=function(sou){ + var i,s,d; + s=sou.elements; + d=this.elements; + if (s===d){ + return; + } + for (i=0;i < 4;++i){ + d[i]=s[i]; + } + } + + /** + *从一个数组复制 + *@param sou 源Float32Array数组 + */ + __proto.copyFromArray=function(sou){ + var i,d; + d=this.elements; + if (sou===d){ + return; + } + for (i=0;i < 4;++i){ + d[i]=sou[i]; + } + } + + /** + *获取四元数的x值 + */ + __getset(0,__proto,'x',function(){ + return this.elements[0]; + }); + + /** + *获取四元数的y值 + */ + __getset(0,__proto,'y',function(){ + return this.elements[1]; + }); + + /** + *获取四元数的z值 + */ + __getset(0,__proto,'z',function(){ + return this.elements[2]; + }); + + /** + *获取四元数的w值 + */ + __getset(0,__proto,'w',function(){ + return this.elements[3]; + }); + + Quaternion.createFromYawPitchRoll=function(yaw,pitch,roll,out){ + var halfRoll=roll *0.5; + var halfPitch=pitch *0.5; + var halfYaw=yaw *0.5; + var sinRoll=Math.sin(halfRoll); + var cosRoll=Math.cos(halfRoll); + var sinPitch=Math.sin(halfPitch); + var cosPitch=Math.cos(halfPitch); + var sinYaw=Math.sin(halfYaw); + var cosYaw=Math.cos(halfYaw); + var oe=out.elements; + oe[0]=(cosYaw *sinPitch *cosRoll)+(sinYaw *cosPitch *sinRoll); + oe[1]=(sinYaw *cosPitch *cosRoll)-(cosYaw *sinPitch *sinRoll); + oe[2]=(cosYaw *cosPitch *sinRoll)-(sinYaw *sinPitch *cosRoll); + oe[3]=(cosYaw *cosPitch *cosRoll)+(sinYaw *sinPitch *sinRoll); + } + + Quaternion.multiply=function(left,right,out){ + var le=left.elements; + var re=right.elements; + var oe=out.elements; + var lx=le[0]; + var ly=le[1]; + var lz=le[2]; + var lw=le[3]; + var rx=re[0]; + var ry=re[1]; + var rz=re[2]; + var rw=re[3]; + var a=(ly *rz-lz *ry); + var b=(lz *rx-lx *rz); + var c=(lx *ry-ly *rx); + var d=(lx *rx+ly *ry+lz *rz); + oe[0]=(lx *rw+rx *lw)+a; + oe[1]=(ly *rw+ry *lw)+b; + oe[2]=(lz *rw+rz *lw)+c; + oe[3]=lw *rw-d; + } + + Quaternion.arcTanAngle=function(x,y){ + if (x==0){ + if (y==1) + return Math.PI / 2; + return-Math.PI / 2; + } + if (x > 0) + return Math.atan(y / x); + if (x < 0){ + if (y > 0) + return Math.atan(y / x)+Math.PI; + return Math.atan(y / x)-Math.PI; + } + return 0; + } + + Quaternion.angleTo=function(from,location,angle){ + Vector3.subtract(location,from,Quaternion.TEMPVector30); + Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30); + angle.elements[0]=Math.asin(Quaternion.TEMPVector30.y); + angle.elements[1]=Quaternion.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x); + } + + Quaternion.createFromAxisAngle=function(axis,rad,out){ + var e=out.elements; + var f=axis.elements; + rad=rad *0.5; + var s=Math.sin(rad); + e[0]=s *f[0]; + e[1]=s *f[1]; + e[2]=s *f[2]; + e[3]=Math.cos(rad); + } + + Quaternion.createFromMatrix3x3=function(sou,out){ + var e=out.elements; + var f=sou.elements; + var fTrace=f[0]+f[4]+f[8]; + var fRoot; + if (fTrace > 0.0){ + fRoot=Math.sqrt(fTrace+1.0); + e[3]=0.5 *fRoot; + fRoot=0.5 / fRoot; + e[0]=(f[5]-f[7])*fRoot; + e[1]=(f[6]-f[2])*fRoot; + e[2]=(f[1]-f[3])*fRoot; + }else { + var i=0; + if (f[4] > f[0]) + i=1; + if (f[8] > f[i *3+i]) + i=2; + var j=(i+1)% 3; + var k=(i+2)% 3; + fRoot=Math.sqrt(f[i *3+i]-f[j *3+j]-f[k *3+k]+1.0); + e[i]=0.5 *fRoot; + fRoot=0.5 / fRoot; + e[3]=(f[j *3+k]-f[k *3+j])*fRoot; + e[j]=(f[j *3+i]+f[i *3+j])*fRoot; + e[k]=(f[k *3+i]+f[i *3+k])*fRoot; + } + return; + } + + Quaternion.createFromMatrix4x4=function(mat,out){ + var me=mat.elements; + var oe=out.elements; + var sqrt; + var half; + var scale=me[0]+me[5]+me[10]; + if (scale > 0.0){ + sqrt=Math.sqrt(scale+1.0); + oe[3]=sqrt *0.5; + sqrt=0.5 / sqrt; + oe[0]=(me[6]-me[9])*sqrt; + oe[1]=(me[8]-me[2])*sqrt; + oe[2]=(me[1]-me[4])*sqrt; + }else if ((me[0] >=me[5])&& (me[0] >=me[10])){ + sqrt=Math.sqrt(1.0+me[0]-me[5]-me[10]); + half=0.5 / sqrt; + oe[0]=0.5 *sqrt; + oe[1]=(me[1]+me[4])*half; + oe[2]=(me[2]+me[8])*half; + oe[3]=(me[6]-me[9])*half; + }else if (me[5] > me[10]){ + sqrt=Math.sqrt(1.0+me[5]-me[0]-me[10]); + half=0.5 / sqrt; + oe[0]=(me[4]+me[1])*half; + oe[1]=0.5 *sqrt; + oe[2]=(me[9]+me[6])*half; + oe[3]=(me[8]-me[2])*half; + }else { + sqrt=Math.sqrt(1.0+me[10]-me[0]-me[5]); + half=0.5 / sqrt; + oe[0]=(me[8]+me[2])*half; + oe[1]=(me[9]+me[6])*half; + oe[2]=0.5 *sqrt; + oe[3]=(me[1]-me[4])*half; + } + } + + Quaternion.slerp=function(left,right,t,out){ + var a=left.elements; + var b=right.elements; + var oe=out.elements; + var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3]; + var omega,cosom,sinom,scale0,scale1; + cosom=ax *bx+ay *by+az *bz+aw *bw; + if (cosom < 0.0){ + cosom=-cosom; + bx=-bx; + by=-by; + bz=-bz; + bw=-bw; + } + if ((1.0-cosom)> 0.000001){ + omega=Math.acos(cosom); + sinom=Math.sin(omega); + scale0=Math.sin((1.0-t)*omega)/ sinom; + scale1=Math.sin(t *omega)/ sinom; + }else { + scale0=1.0-t; + scale1=t; + } + oe[0]=scale0 *ax+scale1 *bx; + oe[1]=scale0 *ay+scale1 *by; + oe[2]=scale0 *az+scale1 *bz; + oe[3]=scale0 *aw+scale1 *bw; + return oe; + } + + Quaternion.lerp=function(left,right,t,out){ + var e=out.elements; + var f=left.elements; + var g=right.elements; + var ax=f[0],ay=f[1],az=f[2],aw=f[3]; + e[0]=ax+t *(g[0]-ax); + e[1]=ay+t *(g[1]-ay); + e[2]=az+t *(g[2]-az); + e[3]=aw+t *(g[3]-aw); + } + + Quaternion.add=function(left,right,out){ + var e=out.elements; + var f=left.elements; + var g=right.elements; + e[0]=f[0]+g[0]; + e[1]=f[1]+g[1]; + e[2]=f[2]+g[2]; + e[3]=f[3]+g[3]; + } + + Quaternion.dot=function(left,right){ + var f=left.elements; + var g=right.elements; + return f[0] *g[0]+f[1] *g[1]+f[2] *g[2]+f[3] *g[3]; + } + + Quaternion.DEFAULT=new Quaternion(); + __static(Quaternion, + ['TEMPVector30',function(){return this.TEMPVector30=new Vector3();},'TEMPVector31',function(){return this.TEMPVector31=new Vector3();},'TEMPVector32',function(){return this.TEMPVector32=new Vector3();},'TEMPVector33',function(){return this.TEMPVector33=new Vector3();},'TEMPMatrix0',function(){return this.TEMPMatrix0=new Matrix4x4();},'TEMPMatrix1',function(){return this.TEMPMatrix1=new Matrix4x4();} + ]); + return Quaternion; + })() + + + /** + *Ray 类用于创建射线。 + */ + //class laya.d3.math.Ray + var Ray=(function(){ + function Ray(origin,direction){ + this.origin=null; + this.direction=null; + this.origin=origin; + this.direction=direction; + } + + __class(Ray,'laya.d3.math.Ray'); + return Ray; + })() + + + /** + *Vector2 类用于创建二维向量。 + */ + //class laya.d3.math.Vector2 + var Vector2=(function(){ + function Vector2(x,y){ + this.elements=new Float32Array(2); + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + var v=this.elements; + v[0]=x; + v[1]=y; + } + + __class(Vector2,'laya.d3.math.Vector2'); + var __proto=Vector2.prototype; + /** + *从一个克隆二维向量克隆。 + *@param v 源二维向量。 + */ + __proto.clone=function(v){ + var out=this.elements,s=v.elements; + out[0]=s[0]; + out[1]=s[1]; + } + + /** + *获取X轴坐标。 + *@return x X轴坐标。 + */ + __getset(0,__proto,'x',function(){ + return this.elements[0]; + }); + + /** + *获取Y轴坐标。 + *@return y Y轴坐标。 + */ + __getset(0,__proto,'y',function(){ + return this.elements[1]; + }); + + Vector2.scale=function(a,b,out){ + var e=out.elements; + var f=a.elements; + e[0]=f[0] *b; + e[1]=f[1] *b; + } + + __static(Vector2, + ['ZERO',function(){return this.ZERO=new Vector2(0.0,0.0);},'ONE',function(){return this.ONE=new Vector2(1.0,1.0);} + ]); + return Vector2; + })() + + + /** + *Vector3 类用于创建三维向量。 + */ + //class laya.d3.math.Vector3 + var Vector3=(function(){ + function Vector3(x,y,z){ + this.elements=new Float32Array(3); + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (z===void 0)&& (z=0); + var v=this.elements; + v[0]=x; + v[1]=y; + v[2]=z; + } + + __class(Vector3,'laya.d3.math.Vector3'); + var __proto=Vector3.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destVector3=destObject; + var destE=destVector3.elements; + var s=this.elements; + destE[0]=s[0]; + destE[1]=s[1]; + destE[2]=s[2]; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destVector3=/*__JS__ */new this.constructor(); + this.cloneTo(destVector3); + return destVector3; + } + + __proto.toDefault=function(){ + this.elements[0]=0; + this.elements[1]=0; + this.elements[2]=0; + } + + /** + *设置X轴坐标。 + *@param x X轴坐标。 + */ + /** + *获取X轴坐标。 + *@return x X轴坐标。 + */ + __getset(0,__proto,'x',function(){ + return this.elements[0]; + },function(value){ + this.elements[0]=value; + }); + + /** + *设置Y轴坐标。 + *@param y Y轴坐标。 + */ + /** + *获取Y轴坐标。 + *@return y Y轴坐标。 + */ + __getset(0,__proto,'y',function(){ + return this.elements[1]; + },function(value){ + this.elements[1]=value; + }); + + /** + *设置Z轴坐标。 + *@param z Z轴坐标。 + */ + /** + *获取Z轴坐标。 + *@return z Z轴坐标。 + */ + __getset(0,__proto,'z',function(){ + return this.elements[2]; + },function(value){ + this.elements[2]=value; + }); + + Vector3.distanceSquared=function(value1,value2){ + var value1e=value1.elements; + var value2e=value2.elements; + var x=value1e[0]-value2e[0]; + var y=value1e[1]-value2e[1]; + var z=value1e[2]-value2e[2]; + return (x *x)+(y *y)+(z *z); + } + + Vector3.distance=function(value1,value2){ + var value1e=value1.elements; + var value2e=value2.elements; + var x=value1e[0]-value2e[0]; + var y=value1e[1]-value2e[1]; + var z=value1e[2]-value2e[2]; + return Math.sqrt((x *x)+(y *y)+(z *z)); + } + + Vector3.min=function(a,b,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements + e[0]=Math.min(f[0],g[0]); + e[1]=Math.min(f[1],g[1]); + e[2]=Math.min(f[2],g[2]); + } + + Vector3.max=function(a,b,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements + e[0]=Math.max(f[0],g[0]); + e[1]=Math.max(f[1],g[1]); + e[2]=Math.max(f[2],g[2]); + } + + Vector3.transformQuat=function(source,rotation,out){ + var destination=out.elements; + var se=source.elements; + var re=rotation.elements; + var x=se[0],y=se[1],z=se[2],qx=re[0],qy=re[1],qz=re[2],qw=re[3], + ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z; + destination[0]=ix *qw+iw *-qx+iy *-qz-iz *-qy; + destination[1]=iy *qw+iw *-qy+iz *-qx-ix *-qz; + destination[2]=iz *qw+iw *-qz+ix *-qy-iy *-qx; + } + + Vector3.scalarLength=function(a){ + var f=a.elements; + var x=f[0],y=f[1],z=f[2]; + return Math.sqrt(x *x+y *y+z *z); + } + + Vector3.scalarLengthSquared=function(a){ + var f=a.elements; + var x=f[0],y=f[1],z=f[2]; + return x *x+y *y+z *z; + } + + Vector3.normalize=function(s,out){ + var se=s.elements; + var oe=out.elements; + var x=se[0],y=se[1],z=se[2]; + var len=x *x+y *y+z *z; + if (len > 0){ + len=1 / Math.sqrt(len); + oe[0]=se[0] *len; + oe[1]=se[1] *len; + oe[2]=se[2] *len; + } + } + + Vector3.multiply=function(a,b,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements + e[0]=f[0] *g[0]; + e[1]=f[1] *g[1]; + e[2]=f[2] *g[2]; + } + + Vector3.scale=function(a,b,out){ + var e=out.elements; + var f=a.elements; + e[0]=f[0] *b; + e[1]=f[1] *b; + e[2]=f[2] *b; + } + + Vector3.lerp=function(a,b,t,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements; + var ax=f[0],ay=f[1],az=f[2]; + e[0]=ax+t *(g[0]-ax); + e[1]=ay+t *(g[1]-ay); + e[2]=az+t *(g[2]-az); + } + + Vector3.transformV3ToV3=function(vector,transform,result){ + var intermediate=new Vector4(); + Vector3.transformV3ToV4(vector,transform,intermediate); + var intermediateElem=intermediate.elements; + var resultElem=result.elements; + resultElem[0]=intermediateElem[0]; + resultElem[1]=intermediateElem[1]; + resultElem[2]=intermediateElem[2]; + } + + Vector3.transformV3ToV4=function(vector,transform,result){ + var vectorElem=vector.elements; + var vectorX=vectorElem[0]; + var vectorY=vectorElem[1]; + var vectorZ=vectorElem[2]; + var transformElem=transform.elements; + var resultElem=result.elements; + resultElem[0]=(vectorX *transformElem[0])+(vectorY *transformElem[4])+(vectorZ *transformElem[8])+transformElem[12]; + resultElem[1]=(vectorX *transformElem[1])+(vectorY *transformElem[5])+(vectorZ *transformElem[9])+transformElem[13]; + resultElem[2]=(vectorX *transformElem[2])+(vectorY *transformElem[6])+(vectorZ *transformElem[10])+transformElem[14]; + resultElem[3]=(vectorX *transformElem[3])+(vectorY *transformElem[7])+(vectorZ *transformElem[11])+transformElem[15]; + } + + Vector3.TransformNormal=function(normal,transform,result){ + var normalElem=normal.elements; + var normalX=normalElem[0]; + var normalY=normalElem[1]; + var normalZ=normalElem[2]; + var transformElem=transform.elements; + var resultElem=result.elements; + resultElem[0]=(normalX *transformElem[0])+(normalY *transformElem[4])+(normalZ *transformElem[8]); + resultElem[1]=(normalX *transformElem[1])+(normalY *transformElem[5])+(normalZ *transformElem[9]); + resultElem[2]=(normalX *transformElem[2])+(normalY *transformElem[6])+(normalZ *transformElem[10]); + } + + Vector3.transformCoordinate=function(coordinate,transform,result){ + var vectorElem=Vector3.TEMPVec4.elements; + var coordinateElem=coordinate.elements; + var coordinateX=coordinateElem[0]; + var coordinateY=coordinateElem[1]; + var coordinateZ=coordinateElem[2]; + var transformElem=transform.elements; + vectorElem[0]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12]; + vectorElem[1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13]; + vectorElem[2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14]; + vectorElem[3]=1.0 / ((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]); + var resultElem=result.elements; + resultElem[0]=vectorElem[0] *vectorElem[3]; + resultElem[1]=vectorElem[1] *vectorElem[3]; + resultElem[2]=vectorElem[2] *vectorElem[3]; + } + + Vector3.Clamp=function(value,min,max,out){ + var valuee=value.elements; + var x=valuee[0]; + var y=valuee[1]; + var z=valuee[2]; + var mine=min.elements; + var mineX=mine[0]; + var mineY=mine[1]; + var mineZ=mine[2]; + var maxe=max.elements; + var maxeX=maxe[0]; + var maxeY=maxe[1]; + var maxeZ=maxe[2]; + var oute=out.elements; + x=(x > maxeX)? maxeX :x; + x=(x < mineX)? mineX :x; + y=(y > maxeY)? maxeY :y; + y=(y < mineY)? mineY :y; + z=(z > maxeZ)? maxeZ :z; + z=(z < mineZ)? mineZ :z; + oute[0]=x; + oute[1]=y; + oute[2]=z; + } + + Vector3.add=function(a,b,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements + e[0]=f[0]+g[0]; + e[1]=f[1]+g[1]; + e[2]=f[2]+g[2]; + } + + Vector3.subtract=function(a,b,o){ + var oe=o.elements; + var ae=a.elements; + var be=b.elements; + oe[0]=ae[0]-be[0]; + oe[1]=ae[1]-be[1]; + oe[2]=ae[2]-be[2]; + } + + Vector3.cross=function(a,b,o){ + var ae=a.elements; + var be=b.elements; + var oe=o.elements; + var ax=ae[0],ay=ae[1],az=ae[2],bx=be[0],by=be[1],bz=be[2]; + oe[0]=ay *bz-az *by; + oe[1]=az *bx-ax *bz; + oe[2]=ax *by-ay *bx; + } + + Vector3.dot=function(a,b){ + var ae=a.elements; + var be=b.elements; + var r=(ae[0] *be[0])+(ae[1] *be[1])+(ae[2] *be[2]); + return r; + } + + Vector3.equals=function(a,b){ + var ae=a.elements; + var be=b.elements; + return MathUtils3D.nearEqual(Math.abs(ae[0]),Math.abs(be[0])) + && MathUtils3D.nearEqual(Math.abs(ae[1]),Math.abs(be[1])) + && MathUtils3D.nearEqual(Math.abs(ae[2]),Math.abs(be[2])); + } + + __static(Vector3, + ['TEMPVec4',function(){return this.TEMPVec4=new Vector4();},'ZERO',function(){return this.ZERO=new Vector3(0.0,0.0,0.0);},'ONE',function(){return this.ONE=new Vector3(1.0,1.0,1.0);},'NegativeUnitX',function(){return this.NegativeUnitX=new Vector3(-1,0,0);},'UnitX',function(){return this.UnitX=new Vector3(1,0,0);},'UnitY',function(){return this.UnitY=new Vector3(0,1,0);},'UnitZ',function(){return this.UnitZ=new Vector3(0,0,1);},'ForwardRH',function(){return this.ForwardRH=new Vector3(0,0,-1);},'ForwardLH',function(){return this.ForwardLH=new Vector3(0,0,1);},'Up',function(){return this.Up=new Vector3(0,1,0);} + ]); + return Vector3; + })() + + + /** + *Vector4 类用于创建四维向量。 + */ + //class laya.d3.math.Vector4 + var Vector4=(function(){ + function Vector4(x,y,z,w){ + this.elements=new Float32Array(4); + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (z===void 0)&& (z=0); + (w===void 0)&& (w=0); + var v=this.elements; + v[0]=x; + v[1]=y; + v[2]=z; + v[3]=w; + } + + __class(Vector4,'laya.d3.math.Vector4'); + var __proto=Vector4.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destVector4=destObject; + var destE=destVector4.elements; + var s=this.elements; + destE[0]=s[0]; + destE[1]=s[1]; + destE[2]=s[2]; + destE[3]=s[3]; + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destVector4=/*__JS__ */new this.constructor(); + this.cloneTo(destVector4); + return destVector4; + } + + /** + *获取X轴坐标。 + *@return x X轴坐标。 + */ + __getset(0,__proto,'x',function(){ + return this.elements[0]; + }); + + /** + *获取Y轴坐标。 + *@return y Y轴坐标。 + */ + __getset(0,__proto,'y',function(){ + return this.elements[1]; + }); + + /** + *获取Z轴坐标。 + *@return z Z轴坐标。 + */ + __getset(0,__proto,'z',function(){ + return this.elements[2]; + }); + + /** + *获取W轴坐标。 + *@return w W轴坐标。 + */ + __getset(0,__proto,'w',function(){ + return this.elements[3]; + }); + + Vector4.lerp=function(a,b,t,out){ + var e=out.elements; + var f=a.elements; + var g=b.elements; + var ax=f[0],ay=f[1],az=f[2],aw=f[3]; + e[0]=ax+t *(g[0]-ax); + e[1]=ay+t *(g[1]-ay); + e[2]=az+t *(g[2]-az); + e[3]=aw+t *(g[3]-aw); + } + + __static(Vector4, + ['ZERO',function(){return this.ZERO=new Vector4();} + ]); + return Vector4; + })() + + + /** + *Viewport 类用于创建视口。 + */ + //class laya.d3.math.Viewport + var Viewport=(function(){ + function Viewport(x,y,width,height){ + //this.x=NaN; + //this.y=NaN; + //this.width=NaN; + //this.height=NaN; + //this.minDepth=NaN; + //this.maxDepth=NaN; + this.minDepth=0.0; + this.maxDepth=1.0; + this.x=x; + this.y=y; + this.width=width; + this.height=height; + } + + __class(Viewport,'laya.d3.math.Viewport'); + var __proto=Viewport.prototype; + /** + *变换一个三维向量。 + *@param source 源三维向量。 + *@param matrix 变换矩阵。 + *@param vector 输出三维向量。 + */ + __proto.project=function(source,matrix,out){ + Vector3.transformV3ToV3(source,matrix,out); + var sourceEleme=source.elements; + var matrixEleme=matrix.elements; + var outEleme=out.elements; + var a=(((sourceEleme[0] *matrixEleme[3])+(sourceEleme[1] *matrixEleme[7]))+(sourceEleme[2] *matrixEleme[11]))+matrixEleme[15]; + if (a!==1.0){ + outEleme[0]=outEleme[0] / a; + outEleme[1]=outEleme[1] / a; + outEleme[2]=outEleme[2] / a; + } + outEleme[0]=(((outEleme[0]+1.0)*0.5)*this.width)+this.x; + outEleme[1]=(((-outEleme[1]+1.0)*0.5)*this.height)+this.y; + outEleme[2]=(outEleme[2] *(this.maxDepth-this.minDepth))+this.minDepth; + } + + /** + *反变换一个三维向量。 + *@param source 源三维向量。 + *@param matrix 变换矩阵。 + *@param vector 输出三维向量。 + */ + __proto.unprojectFromMat=function(source,matrix,out){ + var sourceEleme=source.elements; + var matrixEleme=matrix.elements; + var outEleme=out.elements; + outEleme[0]=(((sourceEleme[0]-this.x)/ (this.width))*2.0)-1.0; + outEleme[1]=-((((sourceEleme[1]-this.y)/ (this.height))*2.0)-1.0); + var halfDepth=(this.maxDepth-this.minDepth)/ 2; + outEleme[2]=(sourceEleme[2]-this.minDepth-halfDepth)/ halfDepth; + var a=(((outEleme[0] *matrixEleme[3])+(outEleme[1] *matrixEleme[7]))+(outEleme[2] *matrixEleme[11]))+matrixEleme[15]; + Vector3.transformV3ToV3(out,matrix,out); + if (a!==1.0){ + outEleme[0]=outEleme[0] / a; + outEleme[1]=outEleme[1] / a; + outEleme[2]=outEleme[2] / a; + } + } + + /** + *反变换一个三维向量。 + *@param source 源三维向量。 + *@param projection 透视投影矩阵。 + *@param view 视图矩阵。 + *@param world 世界矩阵,可设置为null。 + *@param out 输出向量。 + */ + __proto.unprojectFromWVP=function(source,projection,view,world,out){ + Matrix4x4.multiply(projection,view,Viewport._tempMatrix4x4); + (world)&& (Matrix4x4.multiply(Viewport._tempMatrix4x4,world,Viewport._tempMatrix4x4)); + Viewport._tempMatrix4x4.invert(Viewport._tempMatrix4x4); + this.unprojectFromMat(source,Viewport._tempMatrix4x4,out); + } + + __static(Viewport, + ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();} + ]); + return Viewport; + })() + + + /** + *SubMesh 类用于创建子网格数据模板。 + */ + //class laya.d3.resource.models.SubMesh + var SubMesh=(function(){ + function SubMesh(){ + this._indexBuffer=null; + this._vertexBuffer=null; + this._boneIndices=null; + this._bufferUsage=null; + this._indexInMesh=0; + this._bufferUsage={}; + } + + __class(SubMesh,'laya.d3.resource.models.SubMesh'); + var __proto=SubMesh.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true,"laya.resource.IDispose":true}) + /** + *@private + */ + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + /** + *@private + */ + __proto._getIndexBuffer=function(){ + return this._indexBuffer; + } + + /** + *@private + */ + __proto._beforeRender=function(state){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + return true; + } + + /** + *@private + *渲染。 + *@param state 渲染状态。 + */ + __proto._render=function(state){ + var indexCount=this._indexBuffer.indexCount; + state.context.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.drawCall++; + Stat.trianglesFaces+=indexCount / 3; + } + + /** + *

    彻底清理资源。

    + *

    注意:会强制解锁清理。

    + */ + __proto.dispose=function(){ + this._boneIndices=null; + this._indexBuffer.dispose(); + this._vertexBuffer.dispose(); + } + + /** + *@private + */ + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + /** + *@private + */ + __getset(0,__proto,'indexOfHost',function(){ + return this._indexInMesh; + }); + + /** + *@private + */ + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer.indexCount / 3; + }); + + return SubMesh; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.utils.Physics + var Physics=(function(){ + function Physics(){} + __class(Physics,'laya.d3.utils.Physics'); + Physics.rayCastNode=function(ray,sprite3D,outHitInfo){ + if ((sprite3D instanceof laya.d3.core.MeshSprite3D )){ + var meshSprite3D=sprite3D; + var worldMatrix=sprite3D.transform.worldMatrix; + var invertWorldMatrix=Physics._tempMatrix4x40; + worldMatrix.invert(invertWorldMatrix); + var preRayOrigin=Physics._tempVector30; + var preRayDirection=Physics._tempVector31; + var rayOrigin=ray.origin; + var rayDirection=ray.direction; + rayOrigin.cloneTo(preRayOrigin); + rayDirection.cloneTo(preRayDirection); + Vector3.transformCoordinate(rayOrigin,invertWorldMatrix,rayOrigin); + Vector3.TransformNormal(rayDirection,invertWorldMatrix,rayDirection); + Vector3.normalize(rayDirection,rayDirection); + var renderElements=meshSprite3D.meshRender.renderObject._renderElements; + for (var i=0,iNum=renderElements.length;i < iNum;i++){ + var renderObj=renderElements[i].renderObj; + var vertexBuffer=renderObj._getVertexBuffer(0); + var vertexDatas=vertexBuffer.getData(); + var indexDatas=renderObj._getIndexBuffer().getData(); + var elementRaycastHit=Physics._tempRaycastHit0; + var isHit=Picker.rayIntersectsPositionsAndIndices(ray,vertexDatas,vertexBuffer.vertexDeclaration,indexDatas,elementRaycastHit); + if (isHit){ + Vector3.transformCoordinate(elementRaycastHit.position,worldMatrix,elementRaycastHit.position); + var trianglePositions=elementRaycastHit.trianglePositions; + Vector3.transformCoordinate(trianglePositions[0],worldMatrix,trianglePositions[0]); + Vector3.transformCoordinate(trianglePositions[1],worldMatrix,trianglePositions[1]); + Vector3.transformCoordinate(trianglePositions[2],worldMatrix,trianglePositions[2]); + var triangleNormals=elementRaycastHit.triangleNormals; + Vector3.transformCoordinate(triangleNormals[0],worldMatrix,triangleNormals[0]); + Vector3.transformCoordinate(triangleNormals[1],worldMatrix,triangleNormals[1]); + Vector3.transformCoordinate(triangleNormals[2],worldMatrix,triangleNormals[2]); + var rayOriToPos=Physics._tempVector33; + Vector3.subtract(preRayOrigin,elementRaycastHit.position,rayOriToPos); + outHitInfo.distance=Vector3.scalarLength(rayOriToPos); + } + if (isHit && elementRaycastHit.distance < outHitInfo.distance){ + elementRaycastHit.copy(outHitInfo); + } + } + preRayOrigin.cloneTo(rayOrigin); + preRayDirection.cloneTo(rayDirection); + } + for (var j=0,jNum=sprite3D._childs.length;j < jNum;j++) + Physics.rayCast(ray,sprite3D._childs[j],outHitInfo); + } + + Physics.rayCast=function(ray,sprite3D,outHitInfo){ + outHitInfo.position.toDefault(); + outHitInfo.distance=Number.MAX_VALUE; + outHitInfo.trianglePositions[0].toDefault(); + outHitInfo.trianglePositions[1].toDefault(); + outHitInfo.trianglePositions[2].toDefault(); + outHitInfo.triangleNormals[0].toDefault(); + outHitInfo.triangleNormals[1].toDefault(); + outHitInfo.triangleNormals[2].toDefault(); + Physics.rayCastNode(ray,sprite3D,outHitInfo); + } + + __static(Physics, + ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector33',function(){return this._tempVector33=new Vector3();},'_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_tempRaycastHit0',function(){return this._tempRaycastHit0=new RaycastHit();} + ]); + return Physics; + })() + + + /** + *Picker 类用于创建拾取。 + */ + //class laya.d3.utils.Picker + var Picker=(function(){ + /** + *创建一个 Picker 实例。 + */ + function Picker(){} + __class(Picker,'laya.d3.utils.Picker'); + Picker.calculateCursorRay=function(point,viewPort,projectionMatrix,viewMatrix,world,out){ + var x=point.elements[0]; + var y=point.elements[1]; + var nearSource=Picker._tempVector30; + var nerSourceE=nearSource.elements; + nerSourceE[0]=x; + nerSourceE[1]=y; + nerSourceE[2]=viewPort.minDepth; + var farSource=Picker._tempVector31; + var farSourceE=farSource.elements; + farSourceE[0]=x; + farSourceE[1]=y; + farSourceE[2]=viewPort.maxDepth; + var nearPoint=out.origin; + var farPoint=Picker._tempVector32; + viewPort.unprojectFromWVP(nearSource,projectionMatrix,viewMatrix,world,nearPoint); + viewPort.unprojectFromWVP(farSource,projectionMatrix,viewMatrix,world,farPoint); + var outDire=out.direction.elements; + outDire[0]=farPoint.x-nearPoint.x; + outDire[1]=farPoint.y-nearPoint.y; + outDire[2]=farPoint.z-nearPoint.z; + Vector3.normalize(out.direction,out.direction); + } + + Picker.rayIntersectsPositionsAndIndices=function(ray,vertexDatas,vertexDeclaration,indices,outHitInfo){ + var vertexStrideFloatCount=vertexDeclaration.vertexStride / 4; + var positionVertexElementOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION").offset / 4; + var closestIntersection=Number.MAX_VALUE; + var closestTriangleVertexIndex1=-1; + var closestTriangleVertexIndex2=-1; + var closestTriangleVertexIndex3=-1; + for (var j=0;j < indices.length;j+=3){ + var vertex1=Picker._tempVector35; + var vertex1E=vertex1.elements; + var vertex1Index=indices[j] *vertexStrideFloatCount; + var vertex1PositionIndex=vertex1Index+positionVertexElementOffset; + vertex1E[0]=vertexDatas[vertex1PositionIndex]; + vertex1E[1]=vertexDatas[vertex1PositionIndex+1]; + vertex1E[2]=vertexDatas[vertex1PositionIndex+2]; + var vertex2=Picker._tempVector36; + var vertex2E=vertex2.elements; + var vertex2Index=indices[j+1] *vertexStrideFloatCount; + var vertex2PositionIndex=vertex2Index+positionVertexElementOffset; + vertex2E[0]=vertexDatas[vertex2PositionIndex]; + vertex2E[1]=vertexDatas[vertex2PositionIndex+1]; + vertex2E[2]=vertexDatas[vertex2PositionIndex+2]; + var vertex3=Picker._tempVector37; + var vertex3E=vertex3.elements; + var vertex3Index=indices[j+2] *vertexStrideFloatCount; + var vertex3PositionIndex=vertex3Index+positionVertexElementOffset; + vertex3E[0]=vertexDatas[vertex3PositionIndex]; + vertex3E[1]=vertexDatas[vertex3PositionIndex+1]; + vertex3E[2]=vertexDatas[vertex3PositionIndex+2]; + var intersection=laya.d3.utils.Picker.rayIntersectsTriangle(ray,vertex1,vertex2,vertex3); + if (!isNaN(intersection)&& intersection < closestIntersection){ + closestIntersection=intersection; + closestTriangleVertexIndex1=vertex1Index; + closestTriangleVertexIndex2=vertex2Index; + closestTriangleVertexIndex3=vertex3Index; + } + } + if (closestIntersection!==Number.MAX_VALUE){ + outHitInfo.distance=closestIntersection; + Vector3.normalize(ray.direction,ray.direction); + Vector3.scale(ray.direction,closestIntersection,outHitInfo.position); + Vector3.add(ray.origin,outHitInfo.position,outHitInfo.position); + var trianglePositions=outHitInfo.trianglePositions; + var position0=trianglePositions[0]; + var position1=trianglePositions[1]; + var position2=trianglePositions[2]; + var position0E=position0.elements; + var position1E=position1.elements; + var position2E=position2.elements; + var closestVertex1PositionIndex=closestTriangleVertexIndex1+positionVertexElementOffset; + position0E[0]=vertexDatas[closestVertex1PositionIndex]; + position0E[1]=vertexDatas[closestVertex1PositionIndex+1]; + position0E[2]=vertexDatas[closestVertex1PositionIndex+2]; + var closestVertex2PositionIndex=closestTriangleVertexIndex2+positionVertexElementOffset; + position1E[0]=vertexDatas[closestVertex2PositionIndex]; + position1E[1]=vertexDatas[closestVertex2PositionIndex+1]; + position1E[2]=vertexDatas[closestVertex2PositionIndex+2]; + var closestVertex3PositionIndex=closestTriangleVertexIndex3+positionVertexElementOffset; + position2E[0]=vertexDatas[closestVertex3PositionIndex]; + position2E[1]=vertexDatas[closestVertex3PositionIndex+1]; + position2E[2]=vertexDatas[closestVertex3PositionIndex+2]; + var normalVertexElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL"); + if (normalVertexElement){ + var normalVertexElementOffset=normalVertexElement.offset / 4; + var triangleNormals=outHitInfo.triangleNormals; + var normal0=triangleNormals[0]; + var normal1=triangleNormals[1]; + var normal2=triangleNormals[2]; + var normal0E=normal0.elements; + var normal1E=normal1.elements; + var normal2E=normal2.elements; + var closestVertex1NormalIndex=closestTriangleVertexIndex1+normalVertexElementOffset; + normal0E[0]=vertexDatas[closestVertex1NormalIndex]; + normal0E[1]=vertexDatas[closestVertex1NormalIndex+1]; + normal0E[2]=vertexDatas[closestVertex1NormalIndex+2]; + var closestVertex2NormalIndex=closestTriangleVertexIndex2+normalVertexElementOffset; + normal1E[0]=vertexDatas[closestVertex2NormalIndex]; + normal1E[1]=vertexDatas[closestVertex2NormalIndex+1]; + normal1E[2]=vertexDatas[closestVertex2NormalIndex+2]; + var closestVertex3NormalIndex=closestTriangleVertexIndex3+normalVertexElementOffset; + normal2E[0]=vertexDatas[closestVertex3NormalIndex]; + normal2E[1]=vertexDatas[closestVertex3NormalIndex+1]; + normal2E[2]=vertexDatas[closestVertex3NormalIndex+2]; + } + return true; + }else { + outHitInfo.position.toDefault(); + outHitInfo.distance=Number.MAX_VALUE; + outHitInfo.trianglePositions[0].toDefault(); + outHitInfo.trianglePositions[1].toDefault(); + outHitInfo.trianglePositions[2].toDefault(); + outHitInfo.triangleNormals[0].toDefault(); + outHitInfo.triangleNormals[1].toDefault(); + outHitInfo.triangleNormals[2].toDefault(); + return false; + } + } + + Picker.rayIntersectsTriangle=function(ray,vertex1,vertex2,vertex3){ + var result; + var edge1=Picker._tempVector30,edge2=Picker._tempVector31; + Vector3.subtract(vertex2,vertex1,edge1); + Vector3.subtract(vertex3,vertex1,edge2); + var directionCrossEdge2=Picker._tempVector32; + Vector3.cross(ray.direction,edge2,directionCrossEdge2); + var determinant; + determinant=Vector3.dot(edge1,directionCrossEdge2); + if (determinant >-Number.MIN_VALUE && determinant < Number.MIN_VALUE){ + result=Number.NaN; + return result; + }; + var inverseDeterminant=1.0 / determinant; + var distanceVector=Picker._tempVector33; + Vector3.subtract(ray.origin,vertex1,distanceVector); + var triangleU; + triangleU=Vector3.dot(distanceVector,directionCrossEdge2); + triangleU *=inverseDeterminant; + if (triangleU < 0 || triangleU > 1){ + result=Number.NaN; + return result; + }; + var distanceCrossEdge1=Picker._tempVector34; + Vector3.cross(distanceVector,edge1,distanceCrossEdge1); + var triangleV; + triangleV=Vector3.dot(ray.direction,distanceCrossEdge1); + triangleV *=inverseDeterminant; + if (triangleV < 0 || triangleU+triangleV > 1){ + result=Number.NaN; + return result; + }; + var rayDistance; + rayDistance=Vector3.dot(edge2,distanceCrossEdge1); + rayDistance *=inverseDeterminant; + if (rayDistance < 0){ + result=Number.NaN; + return result; + } + result=rayDistance; + return result; + } + + __static(Picker, + ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector32',function(){return this._tempVector32=new Vector3();},'_tempVector33',function(){return this._tempVector33=new Vector3();},'_tempVector34',function(){return this._tempVector34=new Vector3();},'_tempVector35',function(){return this._tempVector35=new Vector3();},'_tempVector36',function(){return this._tempVector36=new Vector3();},'_tempVector37',function(){return this._tempVector37=new Vector3();} + ]); + return Picker; + })() + + + /** + *... + *@author ... + */ + //class laya.d3.utils.RaycastHit + var RaycastHit=(function(){ + function RaycastHit(){ + this.distance=NaN; + this.trianglePositions=null; + this.triangleNormals=null; + this.position=null; + this.distance=Number.MAX_VALUE; + this.trianglePositions=[new Vector3(),new Vector3(),new Vector3()]; + this.trianglePositions.length=3; + this.triangleNormals=[new Vector3(),new Vector3(),new Vector3()]; + this.triangleNormals.length=3; + this.position=new Vector3(); + } + + __class(RaycastHit,'laya.d3.utils.RaycastHit'); + var __proto=RaycastHit.prototype; + __proto.copy=function(dec){ + dec.distance=this.distance; + this.trianglePositions[0].cloneTo(dec.trianglePositions[0]); + this.trianglePositions[1].cloneTo(dec.trianglePositions[1]); + this.trianglePositions[2].cloneTo(dec.trianglePositions[2]); + this.triangleNormals[0].cloneTo(dec.triangleNormals[0]); + this.triangleNormals[1].cloneTo(dec.triangleNormals[1]); + this.triangleNormals[2].cloneTo(dec.triangleNormals[2]); + this.position.cloneTo(dec.position); + } + + return RaycastHit; + })() + + + //class laya.d3.utils.Size + var Size=(function(){ + function Size(width,height){ + this._width=0; + this._height=0; + this._width=width; + this._height=height; + } + + __class(Size,'laya.d3.utils.Size'); + var __proto=Size.prototype; + __getset(0,__proto,'width',function(){ + if (this._width===-1) + return RenderState.clientWidth; + return this._width; + }); + + __getset(0,__proto,'height',function(){ + if (this._height===-1) + return RenderState.clientHeight; + return this._height; + }); + + __getset(1,Size,'fullScreen',function(){ + return new Size(-1,-1); + }); + + return Size; + })() + + + /** + *Utils3D 类用于创建3D工具。 + */ + //class laya.d3.utils.Utils3D + var Utils3D=(function(){ + function Utils3D(){}; + __class(Utils3D,'laya.d3.utils.Utils3D'); + var __proto=Utils3D.prototype; + /** + *@private + */ + __proto.testTangent=function(renderElement,vertexBuffer,indeBuffer,bufferUsage){ + var vertexDeclaration=vertexBuffer.vertexDeclaration; + var material=renderElement._material; + if (material.normalTexture && !vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0")){ + var vertexDatas=vertexBuffer.getData(); + var newVertexDatas=laya.d3.utils.Utils3D.generateTangent(vertexDatas,vertexDeclaration.vertexStride / 4,vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION").offset / 4,vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV").offset / 4,indeBuffer.getData()); + vertexDeclaration=laya.d3.utils.Utils3D.getVertexTangentDeclaration(vertexDeclaration.getVertexElements()); + var newVB=VertexBuffer3D.create(vertexDeclaration,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + newVB.setData(newVertexDatas); + vertexBuffer.dispose(); + bufferUsage[ /*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0"]=newVB; + return newVB; + } + return vertexBuffer; + } + + Utils3D._getTexturePath=function(path){ + var extenIndex=path.length-4; + if (path.indexOf(".dds")==extenIndex || path.indexOf(".tga")==extenIndex || path.indexOf(".exr")==extenIndex || path.indexOf(".DDS")==extenIndex || path.indexOf(".TGA")==extenIndex || path.indexOf(".EXR")==extenIndex) + path=path.substr(0,extenIndex)+".png"; + return path=URL.formatURL(path); + } + + Utils3D._rotationTransformScaleSkinAnimation=function(tx,ty,tz,qx,qy,qz,qw,sx,sy,sz,outArray,outOffset){ + var re=Utils3D._tempArray16_0; + var se=Utils3D._tempArray16_1; + var tse=Utils3D._tempArray16_2; + var x2=qx+qx; + var y2=qy+qy; + var z2=qz+qz; + var xx=qx *x2; + var yx=qy *x2; + var yy=qy *y2; + var zx=qz *x2; + var zy=qz *y2; + var zz=qz *z2; + var wx=qw *x2; + var wy=qw *y2; + var wz=qw *z2; + re[15]=1; + re[0]=1-yy-zz; + re[1]=yx+wz; + re[2]=zx-wy; + re[4]=yx-wz; + re[5]=1-xx-zz; + re[6]=zy+wx; + re[8]=zx+wy; + re[9]=zy-wx; + re[10]=1-xx-yy; + se[15]=1; + se[0]=sx; + se[5]=sy; + se[10]=sz; + var i,a,b,e,ai0,ai1,ai2,ai3; + for (i=0;i < 4;i++){ + ai0=re[i]; + ai1=re[i+4]; + ai2=re[i+8]; + ai3=re[i+12]; + tse[i]=ai0; + tse[i+4]=ai1; + tse[i+8]=ai2; + tse[i+12]=ai0 *tx+ai1 *ty+ai2 *tz+ai3; + } + for (i=0;i < 4;i++){ + ai0=tse[i]; + ai1=tse[i+4]; + ai2=tse[i+8]; + ai3=tse[i+12]; + outArray[i+outOffset]=ai0 *se[0]+ai1 *se[1]+ai2 *se[2]+ai3 *se[3]; + outArray[i+outOffset+4]=ai0 *se[4]+ai1 *se[5]+ai2 *se[6]+ai3 *se[7]; + outArray[i+outOffset+8]=ai0 *se[8]+ai1 *se[9]+ai2 *se[10]+ai3 *se[11]; + outArray[i+outOffset+12]=ai0 *se[12]+ai1 *se[13]+ai2 *se[14]+ai3 *se[15]; + } + } + + Utils3D._applyMeshMaterials=function(meshSprite3D,mesh){ + var meshRender=meshSprite3D.meshRender; + var shaderMaterials=meshRender.sharedMaterials; + var meshMaterials=mesh.materials; + for (var i=0,n=meshMaterials.length;i < n;i++) + (shaderMaterials[i])|| (shaderMaterials[i]=meshMaterials[i]); + meshRender.sharedMaterials=shaderMaterials; + } + + Utils3D._loadParticle=function(settting,particle,innerResouMap){ + var anglelToRad=Math.PI / 180.0; + var i=0,n=0; + var material=new ShurikenParticleMaterial(); + material.diffuseTexture=innerResouMap ? Loader.getRes(innerResouMap[settting.texturePath]):Texture2D.load(settting.texturePath); + material.renderMode=/*laya.d3.core.material.BaseMaterial.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE*/8; + particle.particleRender.sharedMaterial=material; + var particleSystem=particle.particleSystem; + particleSystem.isPerformanceMode=settting.isPerformanceMode; + particleSystem.duration=settting.duration; + particleSystem.looping=settting.looping; + particleSystem.prewarm=settting.prewarm; + particleSystem.startDelayType=settting.startDelayType; + particleSystem.startDelay=settting.startDelay; + particleSystem.startDelayMin=settting.startDelayMin; + particleSystem.startDelayMax=settting.startDelayMax; + particleSystem.startLifetimeType=settting.startLifetimeType; + particleSystem.startLifetimeConstant=settting.startLifetimeConstant; + particleSystem.startLifeTimeGradient=Utils3D._initStartLife(settting.startLifetimeGradient); + particleSystem.startLifetimeConstantMin=settting.startLifetimeConstantMin; + particleSystem.startLifetimeConstantMax=settting.startLifetimeConstantMax; + particleSystem.startLifeTimeGradientMin=Utils3D._initStartLife(settting.startLifetimeGradientMin); + particleSystem.startLifeTimeGradientMax=Utils3D._initStartLife(settting.startLifetimeGradientMax); + particleSystem.startSpeedType=settting.startSpeedType; + particleSystem.startSpeedConstant=settting.startSpeedConstant; + particleSystem.startSpeedConstantMin=settting.startSpeedConstantMin; + particleSystem.startSpeedConstantMax=settting.startSpeedConstantMax; + particleSystem.threeDStartSize=settting.threeDStartSize; + particleSystem.startSizeType=settting.startSizeType; + particleSystem.startSizeConstant=settting.startSizeConstant; + var startSizeConstantSeparateArray=settting.startSizeConstantSeparate; + var startSizeConstantSeparateElement=particleSystem.startSizeConstantSeparate.elements; + startSizeConstantSeparateElement[0]=startSizeConstantSeparateArray[0]; + startSizeConstantSeparateElement[1]=startSizeConstantSeparateArray[1]; + startSizeConstantSeparateElement[2]=startSizeConstantSeparateArray[2]; + particleSystem.startSizeConstantMin=settting.startSizeConstantMin; + particleSystem.startSizeConstantMax=settting.startSizeConstantMax; + var startSizeConstantMinSeparateArray=settting.startSizeConstantMinSeparate; + var startSizeConstantMinSeparateElement=particleSystem.startSizeConstantMinSeparate.elements; + startSizeConstantMinSeparateElement[0]=startSizeConstantMinSeparateArray[0]; + startSizeConstantMinSeparateElement[1]=startSizeConstantMinSeparateArray[1]; + startSizeConstantMinSeparateElement[2]=startSizeConstantMinSeparateArray[2]; + var startSizeConstantMaxSeparateArray=settting.startSizeConstantMaxSeparate; + var startSizeConstantMaxSeparateElement=particleSystem.startSizeConstantMaxSeparate.elements; + startSizeConstantMaxSeparateElement[0]=startSizeConstantMaxSeparateArray[0]; + startSizeConstantMaxSeparateElement[1]=startSizeConstantMaxSeparateArray[1]; + startSizeConstantMaxSeparateElement[2]=startSizeConstantMaxSeparateArray[2]; + particleSystem.threeDStartRotation=settting.threeDStartRotation; + particleSystem.startRotationType=settting.startRotationType; + particleSystem.startRotationConstant=settting.startRotationConstant *anglelToRad; + var startRotationConstantSeparateArray=settting.startRotationConstantSeparate; + var startRotationConstantSeparateElement=particleSystem.startRotationConstantSeparate.elements; + startRotationConstantSeparateElement[0]=startRotationConstantSeparateArray[0] *anglelToRad; + startRotationConstantSeparateElement[1]=startRotationConstantSeparateArray[1] *anglelToRad; + startRotationConstantSeparateElement[2]=startRotationConstantSeparateArray[2] *anglelToRad; + particleSystem.startRotationConstantMin=settting.startRotationConstantMin *anglelToRad; + particleSystem.startRotationConstantMax=settting.startRotationConstantMax *anglelToRad; + var startRotationConstantMinSeparateArray=settting.startRotationConstantMinSeparate; + var startRotationConstantMinSeparateElement=particleSystem.startRotationConstantMinSeparate.elements; + startRotationConstantMinSeparateElement[0]=startRotationConstantMinSeparateArray[0] *anglelToRad; + startRotationConstantMinSeparateElement[1]=startRotationConstantMinSeparateArray[1] *anglelToRad; + startRotationConstantMinSeparateElement[2]=startRotationConstantMinSeparateArray[2] *anglelToRad; + var startRotationConstantMaxSeparateArray=settting.startRotationConstantMaxSeparate; + var startRotationConstantMaxSeparateElement=particleSystem.startRotationConstantMaxSeparate.elements; + startRotationConstantMaxSeparateElement[0]=startRotationConstantMaxSeparateArray[0] *anglelToRad; + startRotationConstantMaxSeparateElement[1]=startRotationConstantMaxSeparateArray[1] *anglelToRad; + startRotationConstantMaxSeparateElement[2]=startRotationConstantMaxSeparateArray[2] *anglelToRad; + particleSystem.randomizeRotationDirection=settting.randomizeRotationDirection; + particleSystem.startColorType=settting.startColorType; + var startColorConstantArray=settting.startColorConstant; + var startColorConstantElement=particleSystem.startColorConstant.elements; + startColorConstantElement[0]=startColorConstantArray[0]; + startColorConstantElement[1]=startColorConstantArray[1]; + startColorConstantElement[2]=startColorConstantArray[2]; + startColorConstantElement[3]=startColorConstantArray[3]; + var startColorConstantMinArray=settting.startColorConstantMin; + var startColorConstantMinElement=particleSystem.startColorConstantMin.elements; + startColorConstantMinElement[0]=startColorConstantMinArray[0]; + startColorConstantMinElement[1]=startColorConstantMinArray[1]; + startColorConstantMinElement[2]=startColorConstantMinArray[2]; + startColorConstantMinElement[3]=startColorConstantMinArray[3]; + var startColorConstantMaxArray=settting.startColorConstantMax; + var startColorConstantMaxElement=particleSystem.startColorConstantMax.elements; + startColorConstantMaxElement[0]=startColorConstantMaxArray[0]; + startColorConstantMaxElement[1]=startColorConstantMaxArray[1]; + startColorConstantMaxElement[2]=startColorConstantMaxArray[2]; + startColorConstantMaxElement[3]=startColorConstantMaxArray[3]; + var gravityArray=settting.gravity; + var gravityE=particleSystem.gravity.elements; + gravityE[0]=gravityArray[0]; + gravityE[1]=gravityArray[1]; + gravityE[2]=gravityArray[2]; + particleSystem.gravityModifier=settting.gravityModifier; + particleSystem.simulationSpace=settting.simulationSpace; + particleSystem.scaleMode=settting.scaleMode; + particleSystem.playOnAwake=settting.playOnAwake; + particleSystem.maxParticles=settting.maxParticles; + var emissionData=settting.emission; + var emission=new Emission(); + emission.emissionRate=emissionData.emissionRate; + var burstsData=emissionData.bursts; + if (burstsData) + for (i=0,n=burstsData.length;i < n;i++){ + var brust=burstsData[i]; + emission.addBurst(new Burst(brust.time,brust.min,brust.max)); + } + emission.enbale=emissionData.enable; + particleSystem.emission=emission; + var shapeData=settting.shape; + var shape; + switch (shapeData.shapeType){ + case 0:; + var sphereShape; + shape=sphereShape=new SphereShape(); + sphereShape.radius=shapeData.sphereRadius; + sphereShape.emitFromShell=shapeData.sphereEmitFromShell; + sphereShape.randomDirection=shapeData.sphereRandomDirection; + break ; + case 1:; + var hemiSphereShape; + shape=hemiSphereShape=new HemisphereShape(); + hemiSphereShape.radius=shapeData.hemiSphereRadius; + hemiSphereShape.emitFromShell=shapeData.hemiSphereEmitFromShell; + hemiSphereShape.randomDirection=shapeData.hemiSphereRandomDirection; + break ; + case 2:; + var coneShape; + shape=coneShape=new ConeShape(); + coneShape.angle=shapeData.coneAngle *anglelToRad; + coneShape.radius=shapeData.coneRadius; + coneShape.length=shapeData.coneLength; + coneShape.emitType=shapeData.coneEmitType; + coneShape.randomDirection=shapeData.coneRandomDirection; + break ; + case 3:; + var boxShape; + shape=boxShape=new BoxShape(); + boxShape.x=shapeData.boxX; + boxShape.y=shapeData.boxY; + boxShape.z=shapeData.boxZ; + boxShape.randomDirection=shapeData.boxRandomDirection; + break ; + case 7:; + var circleShape; + shape=circleShape=new CircleShape(); + circleShape.radius=shapeData.circleRadius; + circleShape.arc=shapeData.circleArc *anglelToRad; + circleShape.emitFromEdge=shapeData.circleEmitFromEdge; + circleShape.randomDirection=shapeData.circleRandomDirection; + break ; + } + shape.enbale=shapeData.enable; + particleSystem.shape=shape; + var velocityOverLifetimeData=settting.velocityOverLifetime; + if (velocityOverLifetimeData){ + var velocityData=velocityOverLifetimeData.velocity; + var velocity; + switch (velocityData.type){ + case 0:; + var constantData=velocityData.constant; + velocity=GradientVelocity.createByConstant(new Vector3(constantData[0],constantData[1],constantData[2])); + break ; + case 1: + velocity=GradientVelocity.createByGradient(Utils3D._initParticleVelocity(velocityData.gradientX),Utils3D._initParticleVelocity(velocityData.gradientY),Utils3D._initParticleVelocity(velocityData.gradientZ)); + break ; + case 2:; + var constantMinData=velocityData.constantMin; + var constantMaxData=velocityData.constantMax; + velocity=GradientVelocity.createByRandomTwoConstant(new Vector3(constantMinData[0],constantMinData[1],constantMinData[2]),new Vector3(constantMaxData[0],constantMaxData[1],constantMaxData[2])); + break ; + case 3: + velocity=GradientVelocity.createByRandomTwoGradient(Utils3D._initParticleVelocity(velocityData.gradientXMin),Utils3D._initParticleVelocity(velocityData.gradientXMax),Utils3D._initParticleVelocity(velocityData.gradientYMin),Utils3D._initParticleVelocity(velocityData.gradientYMax),Utils3D._initParticleVelocity(velocityData.gradientZMin),Utils3D._initParticleVelocity(velocityData.gradientZMax)); + break ; + }; + var velocityOverLifetime=new VelocityOverLifetime(velocity); + velocityOverLifetime.space=velocityOverLifetimeData.space; + velocityOverLifetime.enbale=velocityOverLifetimeData.enable; + particleSystem.velocityOverLifetime=velocityOverLifetime; + }; + var colorOverLifetimeData=settting.colorOverLifetime; + if (colorOverLifetimeData){ + var colorData=colorOverLifetimeData.color; + var color; + switch (colorData.type){ + case 0:; + var constColorData=colorData.constant; + color=GradientColor.createByConstant(new Vector4(constColorData[0],constColorData[1],constColorData[2],constColorData[3])); + break ; + case 1: + color=GradientColor.createByGradient(Utils3D._initParticleColor(colorData.gradient)); + break ; + case 2:; + var minConstColorData=colorData.constantMin; + var maxConstColorData=colorData.constantMax; + color=GradientColor.createByRandomTwoConstant(new Vector4(minConstColorData[0],minConstColorData[1],minConstColorData[2],minConstColorData[3]),new Vector4(maxConstColorData[0],maxConstColorData[1],maxConstColorData[2],maxConstColorData[3])); + break ; + case 3: + color=GradientColor.createByRandomTwoGradient(Utils3D._initParticleColor(colorData.gradientMin),Utils3D._initParticleColor(colorData.gradientMax)); + break ; + }; + var colorOverLifetime=new ColorOverLifetime(color); + colorOverLifetime.enbale=colorOverLifetimeData.enable; + particleSystem.colorOverLifetime=colorOverLifetime; + }; + var sizeOverLifetimeData=settting.sizeOverLifetime; + if (sizeOverLifetimeData){ + var sizeData=sizeOverLifetimeData.size; + var size; + switch (sizeData.type){ + case 0: + if (sizeData.separateAxes){ + size=GradientSize.createByGradientSeparate(Utils3D._initParticleSize(sizeData.gradientX),Utils3D._initParticleSize(sizeData.gradientY),Utils3D._initParticleSize(sizeData.gradientZ)); + }else { + size=GradientSize.createByGradient(Utils3D._initParticleSize(sizeData.gradient)); + } + break ; + case 1: + if (sizeData.separateAxes){ + var constantMinSeparateData=sizeData.constantMinSeparate; + var constantMaxSeparateData=sizeData.constantMaxSeparate; + size=GradientSize.createByRandomTwoConstantSeparate(new Vector3(constantMinSeparateData[0],constantMinSeparateData[1],constantMinSeparateData[2]),new Vector3(constantMaxSeparateData[0],constantMaxSeparateData[1],constantMaxSeparateData[2])); + }else { + size=GradientSize.createByRandomTwoConstant(sizeData.constantMin,sizeData.constantMax); + } + break ; + case 2: + if (sizeData.separateAxes){ + size=GradientSize.createByRandomTwoGradientSeparate(Utils3D._initParticleSize(sizeData.gradientXMin),Utils3D._initParticleSize(sizeData.gradientYMin),Utils3D._initParticleSize(sizeData.gradientZMin),Utils3D._initParticleSize(sizeData.gradientXMax),Utils3D._initParticleSize(sizeData.gradientYMax),Utils3D._initParticleSize(sizeData.gradientZMax)); + }else { + size=GradientSize.createByRandomTwoGradient(Utils3D._initParticleSize(sizeData.gradientMin),Utils3D._initParticleSize(sizeData.gradientMax)); + } + break ; + }; + var sizeOverLifetime=new SizeOverLifetime(size); + sizeOverLifetime.enbale=sizeOverLifetimeData.enable; + particleSystem.sizeOverLifetime=sizeOverLifetime; + }; + var rotationOverLifetimeData=settting.rotationOverLifetime; + if (rotationOverLifetimeData){ + var angularVelocityData=rotationOverLifetimeData.angularVelocity; + var angularVelocity; + switch (angularVelocityData.type){ + case 0: + if (angularVelocityData.separateAxes){ + }else { + angularVelocity=GradientAngularVelocity.createByConstant(angularVelocityData.constant *anglelToRad); + } + break ; + case 1: + if (angularVelocityData.separateAxes){ + }else { + angularVelocity=GradientAngularVelocity.createByGradient(Utils3D._initParticleRotation(angularVelocityData.gradient)); + } + break ; + case 2: + if (angularVelocityData.separateAxes){ + }else { + angularVelocity=GradientAngularVelocity.createByRandomTwoConstant(angularVelocityData.constantMin *anglelToRad,angularVelocityData.constantMax *anglelToRad); + } + break ; + case 3: + if (angularVelocityData.separateAxes){ + }else { + angularVelocity=GradientAngularVelocity.createByRandomTwoGradient(Utils3D._initParticleRotation(angularVelocityData.gradientMin),Utils3D._initParticleRotation(angularVelocityData.gradientMax)); + } + break ; + }; + var rotationOverLifetime=new RotationOverLifetime(angularVelocity); + rotationOverLifetime.enbale=rotationOverLifetimeData.enable; + particleSystem.rotationOverLifetime=rotationOverLifetime; + }; + var textureSheetAnimationData=settting.textureSheetAnimation; + if (textureSheetAnimationData){ + var frameData=textureSheetAnimationData.frame; + var frameOverTime; + switch (frameData.type){ + case 0: + frameOverTime=FrameOverTime.createByConstant(frameData.constant); + break ; + case 1: + frameOverTime=FrameOverTime.createByOverTime(Utils3D._initParticleFrame(frameData.overTime)); + break ; + case 2: + frameOverTime=FrameOverTime.createByRandomTwoConstant(frameData.constantMin,frameData.constantMax); + break ; + case 3: + frameOverTime=FrameOverTime.createByRandomTwoOverTime(Utils3D._initParticleFrame(frameData.overTimeMin),Utils3D._initParticleFrame(frameData.overTimeMax)); + break ; + }; + var startFrameData=textureSheetAnimationData.startFrame; + var startFrame; + switch (startFrameData.type){ + case 0: + startFrame=StartFrame.createByConstant(startFrameData.constant); + break ; + case 1: + startFrame=StartFrame.createByRandomTwoConstant(startFrameData.constantMin,startFrameData.constantMax); + break ; + }; + var textureSheetAnimation=new TextureSheetAnimation(frameOverTime,startFrame); + textureSheetAnimation.enbale=textureSheetAnimationData.enable; + var tilesData=textureSheetAnimationData.tiles; + textureSheetAnimation.tiles=new Vector2(tilesData[0],tilesData[1]); + textureSheetAnimation.type=textureSheetAnimationData.type; + textureSheetAnimation.randomRow=textureSheetAnimationData.randomRow; + textureSheetAnimation.cycles=textureSheetAnimationData.cycles; + particleSystem.textureSheetAnimation=textureSheetAnimation; + }; + var particleRender=particle.particleRender; + particleRender.renderMode=settting.renderMode; + particleRender.stretchedBillboardCameraSpeedScale=settting.stretchedBillboardCameraSpeedScale; + particleRender.stretchedBillboardSpeedScale=settting.stretchedBillboardSpeedScale; + particleRender.stretchedBillboardLengthScale=settting.stretchedBillboardLengthScale; + (particleSystem.playOnAwake)&& (emission.play()); + } + + Utils3D._parseHierarchyProp=function(innerResouMap,node,json){ + var customProps=json.customProps; + var transValue=customProps.translate; + var loccalPosition=node.transform.localPosition; + var loccalPositionElments=loccalPosition.elements; + loccalPositionElments[0]=transValue[0]; + loccalPositionElments[1]=transValue[1]; + loccalPositionElments[2]=transValue[2]; + node.transform.localPosition=loccalPosition; + var rotValue=customProps.rotation; + var localRotation=node.transform.localRotation; + var localRotationElement=localRotation.elements; + localRotationElement[0]=rotValue[0]; + localRotationElement[1]=rotValue[1]; + localRotationElement[2]=rotValue[2]; + localRotationElement[3]=rotValue[3]; + node.transform.localRotation=localRotation; + var scaleValue=customProps.scale; + var localScale=node.transform.localScale; + var localSceleElement=localScale.elements; + localSceleElement[0]=scaleValue[0]; + localSceleElement[1]=scaleValue[1]; + localSceleElement[2]=scaleValue[2]; + node.transform.localScale=localScale; + switch (json.type){ + case "Sprite3D": + break ; + case "MeshSprite3D":; + var mesh=Loader.getRes(innerResouMap[json.instanceParams.loadPath]); + var meshSprite3D=(node); + meshSprite3D.meshFilter.sharedMesh=mesh; + if (mesh.loaded) + meshSprite3D.meshRender.sharedMaterials=mesh.materials; + else + mesh.once(/*laya.events.Event.LOADED*/"loaded",meshSprite3D,meshSprite3D._applyMeshMaterials); + break ; + case "ShuriKenParticle3D":; + var shuriKenParticle3D=(node); + Utils3D._loadParticle(customProps,shuriKenParticle3D,innerResouMap); + break ; + } + } + + Utils3D._parseHierarchyNode=function(json){ + switch (json.type){ + case "Sprite3D": + return new Sprite3D(); + break ; + case "MeshSprite3D": + return new MeshSprite3D(); + break ; + case "ShuriKenParticle3D": + return new ShuriKenParticle3D(); + break ; + default : + throw new Error("Utils3D:unidentified class type in (.lh) file."); + } + } + + Utils3D._initStartLife=function(gradientData){ + var gradient=new GradientDataNumber(); + var startLifetimesData=gradientData.startLifetimes; + for (var i=0,n=startLifetimesData.length;i < n;i++){ + var valueData=startLifetimesData[i]; + gradient.add(valueData.key,valueData.value); + } + return gradient + } + + Utils3D._initParticleVelocity=function(gradientData){ + var gradient=new GradientDataNumber(); + var velocitysData=gradientData.velocitys; + for (var i=0,n=velocitysData.length;i < n;i++){ + var valueData=velocitysData[i]; + gradient.add(valueData.key,valueData.value); + } + return gradient; + } + + Utils3D._initParticleColor=function(gradientColorData){ + var gradientColor=new GradientDataColor(); + var alphasData=gradientColorData.alphas; + var i=0,n=0; + for (i=0,n=alphasData.length;i < n;i++){ + var alphaData=alphasData[i]; + gradientColor.addAlpha(alphaData.key,alphaData.value); + }; + var rgbsData=gradientColorData.rgbs; + for (i=0,n=rgbsData.length;i < n;i++){ + var rgbData=rgbsData[i]; + var rgbValue=rgbData.value; + gradientColor.addRGB(rgbData.key,new Vector3(rgbValue[0],rgbValue[1],rgbValue[2])); + } + return gradientColor; + } + + Utils3D._initParticleSize=function(gradientSizeData){ + var gradientSize=new GradientDataNumber(); + var sizesData=gradientSizeData.sizes; + for (var i=0,n=sizesData.length;i < n;i++){ + var valueData=sizesData[i]; + gradientSize.add(valueData.key,valueData.value); + } + return gradientSize; + } + + Utils3D._initParticleRotation=function(gradientData){ + var gradient=new GradientDataNumber(); + var angularVelocitysData=gradientData.angularVelocitys; + for (var i=0,n=angularVelocitysData.length;i < n;i++){ + var valueData=angularVelocitysData[i]; + gradient.add(valueData.key,valueData.value / 180.0 *Math.PI); + } + return gradient; + } + + Utils3D._initParticleFrame=function(overTimeFramesData){ + var overTimeFrame=new GradientDataInt(); + var framesData=overTimeFramesData.frames; + for (var i=0,n=framesData.length;i < n;i++){ + var frameData=framesData[i]; + overTimeFrame.add(frameData.key,frameData.value); + } + return overTimeFrame; + } + + Utils3D._parseMaterial=function(textureMap,material,json){ + var customProps=json.customProps; + var ambientColorValue=customProps.ambientColor; + material.ambientColor=new Vector3(ambientColorValue[0],ambientColorValue[1],ambientColorValue[2]); + var diffuseColorValue=customProps.diffuseColor; + material.diffuseColor=new Vector3(diffuseColorValue[0],diffuseColorValue[1],diffuseColorValue[2]); + var specularColorValue=customProps.specularColor; + material.specularColor=new Vector4(specularColorValue[0],specularColorValue[1],specularColorValue[2],specularColorValue[3]); + var reflectColorValue=customProps.reflectColor; + material.reflectColor=new Vector3(reflectColorValue[0],reflectColorValue[1],reflectColorValue[2]); + var diffuseTexture=customProps.diffuseTexture.texture2D; + (diffuseTexture)&& (material.diffuseTexture=Loader.getRes(textureMap[diffuseTexture])); + var normalTexture=customProps.normalTexture.texture2D; + (normalTexture)&& (material.normalTexture=Loader.getRes(textureMap[normalTexture])); + var specularTexture=customProps.specularTexture.texture2D; + (specularTexture)&& (material.specularTexture=Loader.getRes(textureMap[specularTexture])); + var emissiveTexture=customProps.emissiveTexture.texture2D; + (emissiveTexture)&& (material.emissiveTexture=Loader.getRes(textureMap[emissiveTexture])); + var ambientTexture=customProps.ambientTexture.texture2D; + (ambientTexture)&& (material.ambientTexture=Loader.getRes(textureMap[ambientTexture])); + var reflectTexture=customProps.reflectTexture.texture2D; + (reflectTexture)&& (material.reflectTexture=Loader.getRes(textureMap[reflectTexture])); + } + + Utils3D._computeBoneAndAnimationDatas=function(bones,curData,exData,outBonesDatas,outAnimationDatas){ + var offset=0; + var matOffset=0; + var len=exData.length / 2; + var i; + var parentOffset; + var boneLength=bones.length; + for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){ + laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(curData[offset+7],curData[offset+8],curData[offset+9],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+0],curData[offset+1],curData[offset+2],outBonesDatas,matOffset); + if (i !=0){ + parentOffset=bones[i].parentIndex *16; + laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset); + } + } + for (i=0;i < len;i+=16){ + laya.d3.utils.Utils3D.mulMatrixByArrayFast(outBonesDatas,i,exData,len+i,outAnimationDatas,i); + } + } + + Utils3D._computeAnimationDatas=function(exData,bonesDatas,outAnimationDatas){ + var len=exData.length / 2; + for (var i=0;i < len;i+=16){ + laya.d3.utils.Utils3D.mulMatrixByArrayFast(bonesDatas,i,exData,len+i,outAnimationDatas,i); + } + } + + Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxix=function(bones,curData,inverGlobalBindPose,outBonesDatas,outAnimationDatas){ + var offset=0; + var matOffset=0; + var i; + var parentOffset; + var boneLength=bones.length; + for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){ + laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(curData[offset+7],curData[offset+8],curData[offset+9],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+0],curData[offset+1],curData[offset+2],outBonesDatas,matOffset); + if (i !=0){ + parentOffset=bones[i].parentIndex *16; + laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset); + } + }; + var n=inverGlobalBindPose.length; + for (i=0;i < n;i++){ + var arrayOffset=i *16; + laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(outBonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset); + } + } + + Utils3D._computeAnimationDatasByArrayAndMatrixFast=function(inverGlobalBindPose,bonesDatas,outAnimationDatas){ + var n=inverGlobalBindPose.length; + for (var i=0;i < n;i++){ + var arrayOffset=i *16; + laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(bonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset); + } + } + + Utils3D._computeRootAnimationData=function(bones,curData,animationDatas){ + for (var i=0,offset=0,matOffset=0,boneLength=bones.length;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++) + laya.d3.utils.Utils3D.createAffineTransformationArray(curData[offset+0],curData[offset+1],curData[offset+2],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+7],curData[offset+8],curData[offset+9],animationDatas,matOffset); + } + + Utils3D.generateTangent=function(vertexDatas,vertexStride,positionOffset,uvOffset,indices){ + var tangentElementCount=3; + var newVertexStride=vertexStride+tangentElementCount; + var tangentVertexDatas=new Float32Array(newVertexStride *(vertexDatas.length / vertexStride)); + for (var i=0;i < indices.length;i+=3){ + var index1=indices[i+0]; + var index2=indices[i+1]; + var index3=indices[i+2]; + var position1Offset=vertexStride *index1+positionOffset; + var position1=Utils3D._tempVector3_0; + position1.x=vertexDatas[position1Offset+0]; + position1.y=vertexDatas[position1Offset+1]; + position1.z=vertexDatas[position1Offset+2]; + var position2Offset=vertexStride *index2+positionOffset; + var position2=Utils3D._tempVector3_1; + position2.x=vertexDatas[position2Offset+0]; + position2.y=vertexDatas[position2Offset+1]; + position2.z=vertexDatas[position2Offset+2]; + var position3Offset=vertexStride *index3+positionOffset; + var position3=Utils3D._tempVector3_2; + position3.x=vertexDatas[position3Offset+0]; + position3.y=vertexDatas[position3Offset+1]; + position3.z=vertexDatas[position3Offset+2]; + var uv1Offset=vertexStride *index1+uvOffset; + var UV1X=vertexDatas[uv1Offset+0]; + var UV1Y=vertexDatas[uv1Offset+1]; + var uv2Offset=vertexStride *index2+uvOffset; + var UV2X=vertexDatas[uv2Offset+0]; + var UV2Y=vertexDatas[uv2Offset+1]; + var uv3Offset=vertexStride *index3+uvOffset; + var UV3X=vertexDatas[uv3Offset+0]; + var UV3Y=vertexDatas[uv3Offset+1]; + var lengthP2ToP1=Utils3D._tempVector3_3; + Vector3.subtract(position2,position1,lengthP2ToP1); + var lengthP3ToP1=Utils3D._tempVector3_4; + Vector3.subtract(position3,position1,lengthP3ToP1); + Vector3.scale(lengthP2ToP1,UV3Y-UV1Y,lengthP2ToP1); + Vector3.scale(lengthP3ToP1,UV2Y-UV1Y,lengthP3ToP1); + var tangent=Utils3D._tempVector3_5; + Vector3.subtract(lengthP2ToP1,lengthP3ToP1,tangent); + Vector3.scale(tangent,1.0 / ((UV2X-UV1X)*(UV3Y-UV1Y)-(UV2Y-UV1Y)*(UV3X-UV1X)),tangent); + var j=0; + for (j=0;j < vertexStride;j++) + tangentVertexDatas[newVertexStride *index1+j]=vertexDatas[vertexStride *index1+j]; + for (j=0;j < tangentElementCount;j++) + tangentVertexDatas[newVertexStride *index1+vertexStride+j]=+tangent.elements[j]; + for (j=0;j < vertexStride;j++) + tangentVertexDatas[newVertexStride *index2+j]=vertexDatas[vertexStride *index2+j]; + for (j=0;j < tangentElementCount;j++) + tangentVertexDatas[newVertexStride *index2+vertexStride+j]=+tangent.elements[j]; + for (j=0;j < vertexStride;j++) + tangentVertexDatas[newVertexStride *index3+j]=vertexDatas[vertexStride *index3+j]; + for (j=0;j < tangentElementCount;j++) + tangentVertexDatas[newVertexStride *index3+vertexStride+j]=+tangent.elements[j]; + } + for (i=0;i < tangentVertexDatas.length;i+=newVertexStride){ + var tangentStartIndex=newVertexStride *i+vertexStride; + var t=Utils3D._tempVector3_6; + t.x=tangentVertexDatas[tangentStartIndex+0]; + t.y=tangentVertexDatas[tangentStartIndex+1]; + t.z=tangentVertexDatas[tangentStartIndex+2]; + Vector3.normalize(t,t); + tangentVertexDatas[tangentStartIndex+0]=t.x; + tangentVertexDatas[tangentStartIndex+1]=t.y; + tangentVertexDatas[tangentStartIndex+2]=t.z; + } + return tangentVertexDatas; + } + + Utils3D.getVertexTangentDeclaration=function(vertexElements){ + var position=false,normal=false,color=false,texcoord0=false,texcoord1=false,blendWeight=false,blendIndex=false; + for (var i=0;i < vertexElements.length;i++){ + switch ((vertexElements [i]).elementUsage){ + case "POSITION": + position=true; + break ; + case "NORMAL": + normal=true; + break ; + case "COLOR": + color=true; + break ; + case "UV": + texcoord0=true; + break ; + case "UV1": + texcoord1=true; + break ; + case "BLENDWEIGHT": + blendWeight=true; + break ; + case "BLENDINDICES": + blendIndex=true; + break ; + } + }; + var vertexDeclaration; + if (position && normal && color && texcoord0 && texcoord1 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1SkinTangent.vertexDeclaration; + if (position && normal && color && texcoord0 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorTextureSkinTangent.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalTexture0Texture1SkinTangent.vertexDeclaration; + else if (position && normal && texcoord0 && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalTextureSkinTangent.vertexDeclaration; + else if (position && normal && color && blendWeight && blendIndex) + vertexDeclaration=VertexPositionNormalColorSkinTangent.vertexDeclaration; + else if (position && normal && color && texcoord0 && texcoord1) + vertexDeclaration=VertexPositionNormalColorTexture0Texture1Tangent.vertexDeclaration; + else if (position && normal && color && texcoord0) + vertexDeclaration=VertexPositionNormalColorTextureTangent.vertexDeclaration; + else if (position && normal && texcoord0 && texcoord1) + vertexDeclaration=VertexPositionNormalTexture0Texture1Tangent.vertexDeclaration; + else if (position && normal && texcoord0) + vertexDeclaration=VertexPositionNormalTextureTangent.vertexDeclaration; + else if (position && normal && color) + vertexDeclaration=VertexPositionNormalColorTangent.vertexDeclaration; + return vertexDeclaration; + } + + Utils3D.transformVector3ArrayByQuat=function(sourceArray,sourceOffset,rotation,outArray,outOffset){ + var re=rotation.elements; + var x=sourceArray[sourceOffset],y=sourceArray[sourceOffset+1],z=sourceArray[sourceOffset+2],qx=re[0],qy=re[1],qz=re[2],qw=re[3], + ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z; + outArray[outOffset]=ix *qw+iw *-qx+iy *-qz-iz *-qy; + outArray[outOffset+1]=iy *qw+iw *-qy+iz *-qx-ix *-qz; + outArray[outOffset+2]=iz *qw+iw *-qz+ix *-qy-iy *-qx; + } + + Utils3D.mulMatrixByArray=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){ + var i,ai0,ai1,ai2,ai3; + if (outArray===rightArray){ + rightArray=Utils3D._tempArray16_3; + for (i=0;i < 16;++i){ + rightArray[i]=outArray[outOffset+i]; + } + rightOffset=0; + } + for (i=0;i < 4;i++){ + ai0=leftArray[leftOffset+i]; + ai1=leftArray[leftOffset+i+4]; + ai2=leftArray[leftOffset+i+8]; + ai3=leftArray[leftOffset+i+12]; + outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3]; + outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7]; + outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11]; + outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15]; + } + } + + Utils3D.mulMatrixByArrayFast=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){ + var i,ai0,ai1,ai2,ai3; + for (i=0;i < 4;i++){ + ai0=leftArray[leftOffset+i]; + ai1=leftArray[leftOffset+i+4]; + ai2=leftArray[leftOffset+i+8]; + ai3=leftArray[leftOffset+i+12]; + outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3]; + outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7]; + outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11]; + outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15]; + } + } + + Utils3D.mulMatrixByArrayAndMatrixFast=function(leftArray,leftOffset,rightMatrix,outArray,outOffset){ + var i,ai0,ai1,ai2,ai3; + var rightMatrixE=rightMatrix.elements; + var m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3]; + var m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7]; + var m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11]; + var m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15]; + var ai0LeftOffset=leftOffset; + var ai1LeftOffset=leftOffset+4; + var ai2LeftOffset=leftOffset+8; + var ai3LeftOffset=leftOffset+12; + var ai0OutOffset=outOffset; + var ai1OutOffset=outOffset+4; + var ai2OutOffset=outOffset+8; + var ai3OutOffset=outOffset+12; + for (i=0;i < 4;i++){ + ai0=leftArray[ai0LeftOffset+i]; + ai1=leftArray[ai1LeftOffset+i]; + ai2=leftArray[ai2LeftOffset+i]; + ai3=leftArray[ai3LeftOffset+i]; + outArray[ai0OutOffset+i]=ai0 *m11+ai1 *m12+ai2 *m13+ai3 *m14; + outArray[ai1OutOffset+i]=ai0 *m21+ai1 *m22+ai2 *m23+ai3 *m24; + outArray[ai2OutOffset+i]=ai0 *m31+ai1 *m32+ai2 *m33+ai3 *m34; + outArray[ai3OutOffset+i]=ai0 *m41+ai1 *m42+ai2 *m43+ai3 *m44; + } + } + + Utils3D.createAffineTransformationArray=function(tX,tY,tZ,rX,rY,rZ,rW,sX,sY,sZ,outArray,outOffset){ + var x2=rX+rX,y2=rY+rY,z2=rZ+rZ; + var xx=rX *x2,xy=rX *y2,xz=rX *z2,yy=rY *y2,yz=rY *z2,zz=rZ *z2; + var wx=rW *x2,wy=rW *y2,wz=rW *z2; + outArray[outOffset+0]=(1-(yy+zz))*sX; + outArray[outOffset+1]=(xy+wz)*sX; + outArray[outOffset+2]=(xz-wy)*sX; + outArray[outOffset+3]=0; + outArray[outOffset+4]=(xy-wz)*sY; + outArray[outOffset+5]=(1-(xx+zz))*sY; + outArray[outOffset+6]=(yz+wx)*sY; + outArray[outOffset+7]=0; + outArray[outOffset+8]=(xz+wy)*sZ; + outArray[outOffset+9]=(yz-wx)*sZ; + outArray[outOffset+10]=(1-(xx+yy))*sZ; + outArray[outOffset+11]=0; + outArray[outOffset+12]=tX; + outArray[outOffset+13]=tY; + outArray[outOffset+14]=tZ; + outArray[outOffset+15]=1; + } + + Utils3D.transformVector3ArrayToVector3ArrayCoordinate=function(source,sourceOffset,transform,result,resultOffset){ + var vectorElem=Utils3D._tempArray4_0; + var coordinateX=source[sourceOffset+0]; + var coordinateY=source[sourceOffset+1]; + var coordinateZ=source[sourceOffset+2]; + var transformElem=transform.elements; + vectorElem[0]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12]; + vectorElem[1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13]; + vectorElem[2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14]; + vectorElem[3]=1.0 / ((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]); + result[resultOffset+0]=vectorElem[0] *vectorElem[3]; + result[resultOffset+1]=vectorElem[1] *vectorElem[3]; + result[resultOffset+2]=vectorElem[2] *vectorElem[3]; + } + + Utils3D.convert3DCoordTo2DScreenCoord=function(source,out){ + var se=source.elements; + var oe=out.elements; + oe[0]=-RenderState.clientWidth / 2+se[0]; + oe[1]=RenderState.clientHeight / 2-se[1]; + oe[2]=se[2]; + } + + Utils3D.getURLVerion=function(url){ + var index=url.indexOf("?"); + return index >=0 ? url.substr(index):null; + } + + Utils3D._tempVector3_0=new Vector3(); + Utils3D._tempVector3_1=new Vector3(); + Utils3D._tempVector3_2=new Vector3(); + Utils3D._tempVector3_3=new Vector3(); + Utils3D._tempVector3_4=new Vector3(); + Utils3D._tempVector3_5=new Vector3(); + Utils3D._tempVector3_6=new Vector3(); + Utils3D._tempArray4_0=new Float32Array(4); + Utils3D._tempArray16_0=new Float32Array(16); + Utils3D._tempArray16_1=new Float32Array(16); + Utils3D._tempArray16_2=new Float32Array(16); + Utils3D._tempArray16_3=new Float32Array(16); + __static(Utils3D, + ['_typeToFunO',function(){return this._typeToFunO={"INT16":"writeInt16","SHORT":"writeInt16","UINT16":"writeUint16","UINT32":"writeUint32","FLOAT32":"writeFloat32","INT":"writeInt32","UINT":"writeUint32","BYTE":"writeByte","STRING":"writeUTFString"};} + ]); + return Utils3D; + })() + + + /** + *Laya3D 类用于初始化3D设置。 + */ + //class Laya3D + var Laya3D=(function(){ + /** + *创建一个 Laya3D 实例。 + */ + function Laya3D(){} + __class(Laya3D,'Laya3D'); + Laya3D._changeWebGLSize=function(width,height){ + WebGL.onStageResize(width,height); + RenderState.clientWidth=width; + RenderState.clientHeight=height; + } + + Laya3D._initShader=function(){ + Shader.addInclude("LightHelper.glsl","\nstruct DirectionLight\n{\n vec3 Direction;\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n};\n\nstruct PointLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n vec3 Direction;\n float Spot;\n float Range;\n};\n\n\nvoid computeDirectionLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in DirectionLight dirLight,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);//不初始化在IOS中闪烁,PC中不会闪烁\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec=-normalize(dirLight.Direction);\n \n amb=matAmb*dirLight.Ambient;\n \n float diffuseFactor=dot(lightVec, normal);\n \n if(diffuseFactor>0.0)\n {\n vec3 v = reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * dirLight.Diffuse;\n spec = specFactor * matSpe.rgb * dirLight.Specular;\n }\n \n}\n\nvoid computePointLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in PointLight poiLight, in vec3 pos,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec = poiLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > poiLight.Range )\n return;\n \n lightVec /= d; \n \n amb = matAmb * poiLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if( diffuseFactor > 0.0 )\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * poiLight.Diffuse;\n spec = specFactor * matSpe.rgb * poiLight.Specular;\n }\n\n float attenuate = 1.0 / dot(poiLight.Attenuation, vec3(1.0, d, d*d));\n\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvoid ComputeSpotLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in SpotLight spoLight,in vec3 pos, in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n amb = vec3(0.0);\n dif =vec3(0.0);\n spec= vec3(0.0);\n vec3 lightVec = spoLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > spoLight.Range)\n return;\n \n lightVec /= d; \n \n amb = matAmb * spoLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if(diffuseFactor > 0.0)\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * spoLight.Diffuse;\n spec = specFactor * matSpe.rgb * spoLight.Specular;\n }\n \n float spot = pow(max(dot(-lightVec, normalize(spoLight.Direction)), 0.0), spoLight.Spot);\n\n float attenuate = spot/dot(spoLight.Attenuation, vec3(1.0, d, d*d));\n\n amb *= spot;\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent)\n{\n vec3 normalT = 2.0*normalMapSample - 1.0;\n\n // Build orthonormal basis.\n vec3 N = normalize(unitNormal);\n vec3 T = normalize(tangent- dot(tangent, N)*N);\n vec3 B = cross(T, N);\n\n mat3 TBN = mat3(T, B, N);\n\n // Transform from tangent space to world space.\n vec3 bumpedNormal = TBN*normalT;\n\n return bumpedNormal;\n}\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/LightHelper.glsl*/); + Shader.addInclude("VRHelper.glsl","\nvec4 DistortFishEye(vec4 p)\n{\n vec2 v = p.xy / p.w;\n float radius = length(v);// Convert to polar coords\n if (radius > 0.0)\n {\n float theta = atan(v.y,v.x);\n \n radius = pow(radius, 0.93);// Distort:\n\n v.x = radius * cos(theta);// Convert back to Cartesian\n v.y = radius * sin(theta);\n p.xy = v.xy * p.w;\n }\n return p;\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/VRHelper.glsl*/); + var vs,ps; + var shaderNameMap={ + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Color':/*laya.d3.graphics.VertexElementUsage.COLOR0*/"COLOR", + 'a_Normal':/*laya.d3.graphics.VertexElementUsage.NORMAL0*/"NORMAL", + 'a_Texcoord0':/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV", + 'a_Texcoord1':/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE1*/"UV1", + 'a_TexcoordNext0':/*laya.d3.graphics.VertexElementUsage.NEXTTEXTURECOORDINATE0*/"NEXTUV", + 'a_BoneWeights':/*laya.d3.graphics.VertexElementUsage.BLENDWEIGHT0*/"BLENDWEIGHT", + 'a_BoneIndices':/*laya.d3.graphics.VertexElementUsage.BLENDINDICES0*/"BLENDINDICES", + 'a_Tangent0':/*laya.d3.graphics.VertexElementUsage.TANGENT0*/"TANGENT0", + 'u_CameraPos':/*laya.d3.core.scene.BaseScene.CAMERAPOS*/"CAMERAPOS", + 'u_FogStart':/*laya.d3.core.scene.BaseScene.FOGSTART*/"FOGSTART", + 'u_FogRange':/*laya.d3.core.scene.BaseScene.FOGRANGE*/"FOGRANGE", + 'u_FogColor':/*laya.d3.core.scene.BaseScene.FOGCOLOR*/"FOGCOLOR", + 'u_DirectionLight.Direction':/*laya.d3.core.scene.BaseScene.LIGHTDIRECTION*/"LIGHTDIRECTION", + 'u_DirectionLight.Diffuse':/*laya.d3.core.scene.BaseScene.LIGHTDIRDIFFUSE*/"LIGHTDIRDIFFUSE", + 'u_DirectionLight.Ambient':/*laya.d3.core.scene.BaseScene.LIGHTDIRAMBIENT*/"LIGHTDIRAMBIENT", + 'u_DirectionLight.Specular':/*laya.d3.core.scene.BaseScene.LIGHTDIRSPECULAR*/"LIGHTDIRSPECULAR", + 'u_PointLight.Position':/*laya.d3.core.scene.BaseScene.POINTLIGHTPOS*/"POINTLIGHTPOS", + 'u_PointLight.Range':/*laya.d3.core.scene.BaseScene.POINTLIGHTRANGE*/"POINTLIGHTRANGE", + 'u_PointLight.Attenuation':/*laya.d3.core.scene.BaseScene.POINTLIGHTATTENUATION*/"POINTLIGHTATTENUATION", + 'u_PointLight.Diffuse':/*laya.d3.core.scene.BaseScene.POINTLIGHTDIFFUSE*/"POINTLIGHTDIFFUSE", + 'u_PointLight.Ambient':/*laya.d3.core.scene.BaseScene.POINTLIGHTAMBIENT*/"POINTLIGHTAMBIENT", + 'u_PointLight.Specular':/*laya.d3.core.scene.BaseScene.POINTLIGHTSPECULAR*/"POINTLIGHTSPECULAR", + 'u_SpotLight.Position':/*laya.d3.core.scene.BaseScene.SPOTLIGHTPOS*/"SPOTLIGHTPOS", + 'u_SpotLight.Direction':/*laya.d3.core.scene.BaseScene.SPOTLIGHTDIRECTION*/"SPOTLIGHTDIRECTION", + 'u_SpotLight.Range':/*laya.d3.core.scene.BaseScene.SPOTLIGHTRANGE*/"SPOTLIGHTRANGE", + 'u_SpotLight.Spot':/*laya.d3.core.scene.BaseScene.SPOTLIGHTSPOT*/"SPOTLIGHTSPOT", + 'u_SpotLight.Attenuation':/*laya.d3.core.scene.BaseScene.SPOTLIGHTATTENUATION*/"SPOTLIGHTATTENUATION", + 'u_SpotLight.Diffuse':/*laya.d3.core.scene.BaseScene.SPOTLIGHTDIFFUSE*/"SPOTLIGHTDIFFUSE", + 'u_SpotLight.Ambient':/*laya.d3.core.scene.BaseScene.SPOTLIGHTAMBIENT*/"SPOTLIGHTAMBIENT", + 'u_SpotLight.Specular':/*laya.d3.core.scene.BaseScene.SPOTLIGHTSPECULAR*/"SPOTLIGHTSPECULAR", + 'u_WorldMat':/*laya.d3.core.material.StandardMaterial.WORLDMATRIX*/"MATRIX1", + 'u_DiffuseTexture':/*laya.d3.core.material.StandardMaterial.DIFFUSETEXTURE*/"DIFFUSETEXTURE", + 'u_SpecularTexture':/*laya.d3.core.material.StandardMaterial.SPECULARTEXTURE*/"SPECULARTEXTURE", + 'u_NormalTexture':/*laya.d3.core.material.StandardMaterial.NORMALTEXTURE*/"NORMALTEXTURE", + 'u_AmbientTexture':/*laya.d3.core.material.StandardMaterial.AMBIENTTEXTURE*/"AMBIENTTEXTURE", + 'u_ReflectTexture':/*laya.d3.core.material.StandardMaterial.REFLECTTEXTURE*/"REFLECTTEXTURE", + 'u_MvpMatrix':/*laya.d3.core.material.StandardMaterial.MVPMATRIX*/"MVPMATRIX", + 'u_Bones':/*laya.d3.core.material.StandardMaterial.Bones*/"MATRIXARRAY0", + 'u_Albedo':/*laya.d3.core.material.StandardMaterial.ALBEDO*/"ALBEDO", + 'u_AlphaTestValue':/*laya.d3.core.material.StandardMaterial.ALPHATESTVALUE*/"ALPHATESTVALUE", + 'u_UVMatrix':/*laya.d3.core.material.StandardMaterial.UVMATRIX*/"MATRIX2", + 'u_UVAge':/*laya.d3.core.material.StandardMaterial.UVAGE*/"FLOAT0", + 'u_UVAniAge':/*laya.d3.core.material.StandardMaterial.UVANIAGE*/"UVAGEX", + 'u_MaterialDiffuse':/*laya.d3.core.material.StandardMaterial.MATERIALDIFFUSE*/"MATERIALDIFFUSE", + 'u_MaterialAmbient':/*laya.d3.core.material.StandardMaterial.MATERIALAMBIENT*/"MATERIALAMBIENT", + 'u_MaterialSpecular':/*laya.d3.core.material.StandardMaterial.MATERIALSPECULAR*/"MATERIALSPECULAR", + 'u_MaterialReflect':/*laya.d3.core.material.StandardMaterial.MATERIALREFLECT*/"MATERIALREFLECT"}; + var SIMPLE=Shader.nameKey.add("SIMPLE"); + vs="#include?VR \"VRHelper.glsl\";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM \n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP)&&NORMALMAP\nattribute vec3 a_Tangent0;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n\n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n mat3 worldMat;\n #ifdef BONE\n worldMat=mat3(u_WorldMat*skinTransform);\n #else\n worldMat=mat3(u_WorldMat);\n #endif \n v_Normal=worldMat*a_Normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n v_Tangent0=worldMat*a_Tangent0;\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG\n #ifdef BONE\n v_PositionWorld=(u_WorldMat*position).xyz;\n #else\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n #endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/PixelSimpleTextureSkinnedMesh.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT \"LightHelper.glsl\";\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP \n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\nuniform sampler2D u_NormalTexture;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n vec3 normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n vec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n normal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent0));\n #else\n normal = normalize(v_Normal);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n vec3 diffuse = vec3(0.0);\n vec3 ambient = vec3(0.0);\n vec3 specular= vec3(0.0);\n vec3 dif, amb, spe;\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n vec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n #else\n toEye=normalize(u_CameraPos-v_PositionWorld);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT\n computeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n #ifdef POINTLIGHT\n computePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n\n #ifdef SPOTLIGHT\n ComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n\n \n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n specular =specular*texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n #endif\n gl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular,gl_FragColor.a);\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -toEye;\n vec3 reflectionVector = reflect(incident,normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/PixelSimpleTextureSkinnedMesh.ps*/; + Shader.preCompile(SIMPLE,vs,ps,shaderNameMap); + var SIMPLEVEXTEX=Shader.nameKey.add("SIMPLEVEXTEX"); + vs="#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT \"LightHelper.glsl\";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n#include?VR \"VRHelper.glsl\";\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM\n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_ToEye;\nvarying vec3 v_Normal;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n \n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n #ifdef BONE\n vec3 normal=normalize( mat3(u_WorldMat*skinTransform)*a_Normal);\n #else\n vec3 normal=normalize( mat3(u_WorldMat)*a_Normal);\n #endif\n \n #ifdef REFLECTMAP\n v_Normal=normal;\n #endif\n#endif\n \n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n v_Diffuse=vec3(0.0);\n v_Ambient=vec3(0.0);\n v_Specular=vec3(0.0);\n vec3 dif, amb, spe;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n #ifdef BONE\n vec3 positionWorld=(u_WorldMat*position).xyz;\n #else\n vec3 positionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nvec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-positionWorld;\n v_ToEyeLength=length(toEye);\n toEye/=v_ToEyeLength;\n #else\n toEye=normalize(u_CameraPos-positionWorld);\n #endif\n \n #ifdef REFLECTMAP\n v_ToEye=toEye;\n #endif\n#endif\n \n#ifdef DIRECTIONLIGHT\ncomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef POINTLIGHT\ncomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\nComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/VertexSimpleTextureSkinnedMesh.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_Normal;\nvarying vec3 v_ToEye;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef REFLECTMAP\n vec3 normal=normalize(v_Normal);\n #endif \n\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n vec3 specular =v_Specular*texture2D(u_SpecularTexture,v_Texcoord0).rgb;\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+specular,gl_FragColor.a);\n #else\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+v_Specular,gl_FragColor.a);\n #endif\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -v_ToEye;\n vec3 reflectionVector = reflect(incident,v_Normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((v_ToEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/VertexSimpleTextureSkinnedMesh.ps*/; + Shader.preCompile(SIMPLEVEXTEX,vs,ps,shaderNameMap); + shaderNameMap={ + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Texcoord':/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV", + 'u_FogStart':/*laya.d3.core.scene.BaseScene.FOGSTART*/"FOGSTART", + 'u_FogRange':/*laya.d3.core.scene.BaseScene.FOGRANGE*/"FOGRANGE", + 'u_FogColor':/*laya.d3.core.scene.BaseScene.FOGCOLOR*/"FOGCOLOR", + 'u_CameraPos':/*laya.d3.core.scene.BaseScene.CAMERAPOS*/"CAMERAPOS", + 'u_WorldMat':/*laya.d3.core.material.StandardMaterial.WORLDMATRIX*/"MATRIX1", + 'u_BlendTexture':/*laya.d3.core.material.StandardMaterial.DIFFUSETEXTURE*/"DIFFUSETEXTURE", + 'u_LayerTexture0':/*laya.d3.core.material.StandardMaterial.NORMALTEXTURE*/"NORMALTEXTURE", + 'u_LayerTexture1':/*laya.d3.core.material.StandardMaterial.SPECULARTEXTURE*/"SPECULARTEXTURE", + 'u_LayerTexture2':/*laya.d3.core.material.StandardMaterial.EMISSIVETEXTURE*/"EMISSIVETEXTURE", + 'u_LayerTexture3':/*laya.d3.core.material.StandardMaterial.AMBIENTTEXTURE*/"AMBIENTTEXTURE", + 'u_MvpMatrix':/*laya.d3.core.material.StandardMaterial.MVPMATRIX*/"MVPMATRIX", + 'u_Albedo':/*laya.d3.core.material.StandardMaterial.ALBEDO*/"ALBEDO", + 'u_Ambient':/*laya.d3.core.material.StandardMaterial.MATERIALAMBIENT*/"MATERIALAMBIENT", + 'u_UVMatrix':/*laya.d3.core.material.StandardMaterial.UVMATRIX*/"MATRIX2"}; + var TERRAIN=Shader.nameKey.add("TERRAIN"); + vs="#include?VR \"VRHelper.glsl\";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_UVMatrix;\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\nattribute vec2 a_Texcoord;\nvarying vec2 v_Texcoord;\nvarying vec2 v_TiledTexcoord;\n#endif\n\n#ifdef FOG\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n \n #ifdef FOG\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n v_Texcoord=a_Texcoord;\n v_TiledTexcoord=(u_UVMatrix*vec4(a_Texcoord,0.0,1.0)).xy;\n #endif\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/modelTerrain.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform vec3 u_Ambient;\n\n#ifdef FOG\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n varying vec2 v_Texcoord;\n varying vec2 v_TiledTexcoord;\n uniform sampler2D u_BlendTexture;\n uniform sampler2D u_LayerTexture0;\n uniform sampler2D u_LayerTexture1;\n uniform sampler2D u_LayerTexture2;\n uniform sampler2D u_LayerTexture3;\n#endif\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n vec4 blend=texture2D(u_BlendTexture, v_Texcoord);\n vec4 c0=texture2D(u_LayerTexture0, v_TiledTexcoord);\n vec4 c1=texture2D(u_LayerTexture1, v_TiledTexcoord);\n vec4 c2=texture2D(u_LayerTexture2, v_TiledTexcoord);\n vec4 c3=texture2D(u_LayerTexture3, v_TiledTexcoord);\n vec4 texColor = c0;\n texColor = mix(texColor, c1, blend.r);\n texColor = mix(texColor, c2, blend.g);\n texColor = mix(texColor, c3, blend.b);\n gl_FragColor=vec4(texColor.rgb*u_Ambient.rgb*blend.a,1.0);\n gl_FragColor=gl_FragColor*u_Albedo;\n #endif \n \n #ifdef FOG\n vec3 toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n \n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/modelTerrain.ps*/; + Shader.preCompile(TERRAIN,vs,ps,shaderNameMap); + shaderNameMap={ + 'a_CornerTextureCoordinate':/*laya.d3.graphics.VertexElementUsage.CORNERTEXTURECOORDINATE0*/"CORNERTEXTURECOORDINATE", + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Velocity':/*laya.d3.graphics.VertexElementUsage.VELOCITY0*/"VELOCITY", + 'a_StartColor':/*laya.d3.graphics.VertexElementUsage.STARTCOLOR0*/"STARTCOLOR", + 'a_EndColor':/*laya.d3.graphics.VertexElementUsage.ENDCOLOR0*/"ENDCOLOR", + 'a_SizeRotation':/*laya.d3.graphics.VertexElementUsage.SIZEROTATION0*/"SIZEROTATION", + 'a_Radius':/*laya.d3.graphics.VertexElementUsage.RADIUS0*/"RADIUS", + 'a_Radian':/*laya.d3.graphics.VertexElementUsage.RADIAN0*/"RADIAN", + 'a_AgeAddScale':/*laya.d3.graphics.VertexElementUsage.STARTLIFETIME*/"STARTLIFETIME", + 'a_Time':/*laya.d3.graphics.VertexElementUsage.TIME0*/"TIME", + 'u_WorldMat':/*laya.d3.core.material.ParticleMaterial.WORLDMATRIX*/"MVPMATRIX", + 'u_View':/*laya.d3.core.material.ParticleMaterial.VIEWMATRIX*/"MATRIX1", + 'u_Projection':/*laya.d3.core.material.ParticleMaterial.PROJECTIONMATRIX*/"MATRIX2", + 'u_ViewportScale':/*laya.d3.core.material.ParticleMaterial.VIEWPORTSCALE*/"VIEWPORTSCALE", + 'u_CurrentTime':/*laya.d3.core.material.ParticleMaterial.CURRENTTIME*/"CURRENTTIME", + 'u_Duration':/*laya.d3.core.material.ParticleMaterial.DURATION*/"DURATION", + 'u_Gravity':/*laya.d3.core.material.ParticleMaterial.GRAVITY*/"GRAVITY", + 'u_EndVelocity':/*laya.d3.core.material.ParticleMaterial.ENDVELOCITY*/"ENDVELOCITY", + 'u_texture':/*laya.d3.core.material.ParticleMaterial.DIFFUSETEXTURE*/"DIFFUSETEXTURE"}; + var PARTICLE=Shader.nameKey.add("PARTICLE"); + Shader.preCompile(PARTICLE,ParticleShader.vs,ParticleShader.ps,shaderNameMap); + shaderNameMap={ + 'a_CornerTextureCoordinate':/*laya.d3.graphics.VertexElementUsage.CORNERTEXTURECOORDINATE0*/"CORNERTEXTURECOORDINATE", + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Direction':/*laya.d3.graphics.VertexElementUsage.DIRECTION*/"DIRECTION", + 'a_StartColor':/*laya.d3.graphics.VertexElementUsage.STARTCOLOR0*/"STARTCOLOR", + 'a_EndColor':/*laya.d3.graphics.VertexElementUsage.ENDCOLOR0*/"ENDCOLOR", + 'a_StartSize':/*laya.d3.graphics.VertexElementUsage.STARTSIZE*/"STARTSIZE", + 'a_StartRotation0':/*laya.d3.graphics.VertexElementUsage.STARTROTATION0*/"STARTROTATION0", + 'a_StartRotation1':/*laya.d3.graphics.VertexElementUsage.STARTROTATION1*/"STARTROTATION1", + 'a_StartRotation2':/*laya.d3.graphics.VertexElementUsage.STARTROTATION2*/"STARTROTATION2", + 'a_StartLifeTime':/*laya.d3.graphics.VertexElementUsage.STARTLIFETIME*/"STARTLIFETIME", + 'a_StartSpeed':/*laya.d3.graphics.VertexElementUsage.STARTSPEED*/"STARTSPEED", + 'a_Time':/*laya.d3.graphics.VertexElementUsage.TIME0*/"TIME", + 'a_Random0':/*laya.d3.graphics.VertexElementUsage.RANDOM0*/"RANDOM0", + 'a_Random1':/*laya.d3.graphics.VertexElementUsage.RANDOM1*/"RANDOM1", + 'a_SimulationWorldPostion':/*laya.d3.graphics.VertexElementUsage.SIMULATIONWORLDPOSTION*/"SIMULATIONWORLDPOSTION", + 'u_WorldPosition':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.WORLDPOSITION*/"WORLDPOSITION", + 'u_WorldRotationMat':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.WORLDROTATIONMATRIX*/"WORLDROTATIONMATRIX", + 'u_ThreeDStartRotation':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.THREEDSTARTROTATION*/"THREEDSTARTROTATION", + 'u_ScalingMode':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SCALINGMODE*/"SCALINGMODE", + 'u_PositionScale':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.POSITIONSCALE*/"POSITIONSCALE", + 'u_SizeScale':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SIZESCALE*/"SIZESCALE", + 'u_View':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VIEWMATRIX*/"MATRIX1", + 'u_Projection':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.PROJECTIONMATRIX*/"MATRIX2", + 'u_CurrentTime':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.CURRENTTIME*/"CURRENTTIME", + 'u_Gravity':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.GRAVITY*/"GRAVITY", + 'u_texture':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.DIFFUSETEXTURE*/"DIFFUSETEXTURE", + 'u_CameraDirection':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.CAMERADIRECTION*/"CAMERADIRECTION", + 'u_CameraUp':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.CAMERAUP*/"CAMERAUP", + 'u_StretchedBillboardLengthScale':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.STRETCHEDBILLBOARDLENGTHSCALE*/"STRETCHEDBILLBOARDLENGTHSCALE", + 'u_StretchedBillboardSpeedScale':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.STRETCHEDBILLBOARDSPEEDSCALE*/"STRETCHEDBILLBOARDSPEEDSCALE", + 'u_ColorOverLifeGradientAlphas':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.COLOROVERLIFEGRADIENTALPHAS*/"COLOROVERLIFEGRADIENTALPHAS", + 'u_ColorOverLifeGradientColors':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.COLOROVERLIFEGRADIENTCOLORS*/"COLOROVERLIFEGRADIENTCOLORS", + 'u_MaxColorOverLifeGradientAlphas':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.MAXCOLOROVERLIFEGRADIENTALPHAS*/"MAXCOLOROVERLIFEGRADIENTALPHAS", + 'u_MaxColorOverLifeGradientColors':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.MAXCOLOROVERLIFEGRADIENTCOLORS*/"MAXCOLOROVERLIFEGRADIENTCOLORS", + 'u_SimulationSpace':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SIMULATIONSPACE*/"SIMULATIONSPACE", + 'u_VOLType':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLTYPE*/"VOLTYPE", + 'u_VOLVelocityConst':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYCONST*/"VOLVELOCITYCONST", + 'u_VOLVelocityGradientX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTX*/"VOLVELOCITYGRADIENTX", + 'u_VOLVelocityGradientY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTY*/"VOLVELOCITYGRADIENTY", + 'u_VOLVelocityGradientZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTZ*/"VOLVELOCITYGRADIENTZ", + 'u_VOLVelocityConstMax':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYCONSTMAX*/"VOLVELOCITYCONSTMAX", + 'u_VOLVelocityGradientMaxX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTXMAX*/"VOLVELOCITYGRADIENTXMAX", + 'u_VOLVelocityGradientMaxY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTYMAX*/"VOLVELOCITYGRADIENTYMAX", + 'u_VOLVelocityGradientMaxZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLVELOCITYGRADIENTZMAX*/"VOLVELOCITYGRADIENTZMAX", + 'u_VOLSpaceType':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.VOLSPACETYPE*/"VOLSPACETYPE", + 'u_SOLType':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLTYPE*/"SOLTYPE", + 'u_SOLSeprarate':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSEPRARATE*/"SOLSEPRARATE", + 'u_SOLSizeGradient':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSIZEGRADIENT*/"SOLSIZEGRADIENT", + 'u_SOLSizeGradientX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSIZEGRADIENTX*/"SOLSIZEGRADIENTX", + 'u_SOLSizeGradientY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSIZEGRADIENTY*/"SOLSIZEGRADIENTY", + 'u_SOLSizeGradientZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSizeGradientZ*/"SOLSizeGradientZ", + 'u_SOLSizeGradientMax':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSizeGradientMax*/"SOLSizeGradientMax", + 'u_SOLSizeGradientMaxX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSIZEGRADIENTXMAX*/"SOLSIZEGRADIENTXMAX", + 'u_SOLSizeGradientMaxY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSIZEGRADIENTYMAX*/"SOLSIZEGRADIENTYMAX", + 'u_SOLSizeGradientMaxZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SOLSizeGradientZMAX*/"SOLSizeGradientZMAX", + 'u_ROLType':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLTYPE*/"ROLTYPE", + 'u_ROLSeprarate':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLSEPRARATE*/"ROLSEPRARATE", + 'u_ROLAngularVelocityConst':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYCONST*/"ROLANGULARVELOCITYCONST", + 'u_ROLAngularVelocityConstSeprarate':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTSEPRARATE*/"ROLANGULARVELOCITYCONSTSEPRARATE", + 'u_ROLAngularVelocityGradient':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENT*/"ROLANGULARVELOCITYGRADIENT", + 'u_ROLAngularVelocityGradientX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTX*/"ROLANGULARVELOCITYGRADIENTX", + 'u_ROLAngularVelocityGradientY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTY*/"ROLANGULARVELOCITYGRADIENTY", + 'u_ROLAngularVelocityGradientZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTZ*/"ROLANGULARVELOCITYGRADIENTZ", + 'u_ROLAngularVelocityConstMax':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTMAX*/"ROLANGULARVELOCITYCONSTMAX", + 'u_ROLAngularVelocityConstMaxSeprarate':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTMAXSEPRARATE*/"ROLANGULARVELOCITYCONSTMAXSEPRARATE", + 'u_ROLAngularVelocityGradientMax':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTMAX*/"ROLANGULARVELOCITYGRADIENTMAX", + 'u_ROLAngularVelocityGradientMaxX':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTXMAX*/"ROLANGULARVELOCITYGRADIENTXMAX", + 'u_ROLAngularVelocityGradientMaxY':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTYMAX*/"ROLANGULARVELOCITYGRADIENTYMAX", + 'u_ROLAngularVelocityGradientMaxZ':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTZMAX*/"ROLANGULARVELOCITYGRADIENTZMAX", + 'u_TSAType':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.TEXTURESHEETANIMATIONTYPE*/"TEXTURESHEETANIMATIONTYPE", + 'u_TSACycles':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.TEXTURESHEETANIMATIONCYCLES*/"TEXTURESHEETANIMATIONCYCLES", + 'u_TSASubUVLength':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.TEXTURESHEETANIMATIONSUBUVLENGTH*/"TEXTURESHEETANIMATIONSUBUVLENGTH", + 'u_TSAGradientUVs':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.TEXTURESHEETANIMATIONGRADIENTUVS*/"TEXTURESHEETANIMATIONGRADIENTUVS", + 'u_TSAMaxGradientUVs':/*laya.d3.core.particleShuriKen.ShurikenParticleMaterial.TEXTURESHEETANIMATIONGRADIENTMAXUVS*/"TEXTURESHEETANIMATIONGRADIENTMAXUVS"}; + var PARTICLESHURIKEN=Shader.nameKey.add("PARTICLESHURIKEN"); + vs="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Direction;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute vec3 a_StartRotation1;\nattribute vec3 a_StartRotation2;\nattribute float a_StartLifeTime;\nattribute float a_Time;\nattribute float a_StartSpeed;\n#ifdef VELOCITYOVERLIFETIME||COLOROVERLIFETIME||RANDOMCOLOROVERLIFETIME||SIZEOVERLIFETIME||ROTATIONOVERLIFETIME\n attribute vec4 a_Random0;\n#endif\n#ifdef TEXTURESHEETANIMATION\n attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform mat4 u_WorldRotationMat;\nuniform bool u_ThreeDStartRotation;\nuniform int u_ScalingMode;\nuniform vec3 u_PositionScale;\nuniform vec3 u_SizeScale;\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform float u_StretchedBillboardLengthScale;\nuniform float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#ifdef VELOCITYOVERLIFETIME\n uniform int u_VOLType;\n uniform vec3 u_VOLVelocityConst;\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\n uniform vec3 u_VOLVelocityConstMax;\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\n uniform int u_VOLSpaceType;\n#endif\n\n#ifdef COLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef RANDOMCOLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef SIZEOVERLIFETIME\n uniform int u_SOLType;\n uniform bool u_SOLSeprarate;\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\n#endif\n\n\n#ifdef ROTATIONOVERLIFETIME\n uniform int u_ROLType;\n uniform bool u_ROLSeprarate;\n uniform float u_ROLAngularVelocityConst;\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientZ[4];//x为key,y为旋转\n uniform float u_ROLAngularVelocityConstMax;\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];//x为key,y为旋转\n#endif\n\n#ifdef TEXTURESHEETANIMATION\n uniform int u_TSAType;\n uniform float u_TSACycles;\n uniform vec2 u_TSASubUVLength;\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float curValue;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n curValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n break;\n }\n }\n return curValue;\n}\n\n#ifdef VELOCITYOVERLIFETIME\n//float getTotalPositionFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n//{\n// float totalPosition=0.0;\n// for(int i=1;i<4;i++)\n// {\n// vec2 gradientNumber=gradientNumbers[i];\n// float key=gradientNumber.x;\n// vec2 lastGradientNumber=gradientNumbers[i-1];\n// float lastValue=lastGradientNumber.y;\n// \n// if(key>=normalizedAge){\n// float lastKey=lastGradientNumber.x;\n// float age=(normalizedAge-lastKey)/(key-lastKey);\n// \n// float velocity=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(normalizedAge-lastKey);//TODO:计算POSITION时可用优化,用已计算好速度\n// break;\n// }\n// else{\n// float velocity=(lastValue+gradientNumber.y)/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(key-lastGradientNumber.x);\n// }\n// }\n// return totalPosition;\n//}\n#endif\n\n\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float totalValue=0.0;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastValue=lastGradientNumber.y;\n \n if(key>=normalizedAge){\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n totalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_StartLifeTime*(normalizedAge-lastKey);\n break;\n }\n else{\n totalValue+=(lastValue+gradientNumber.y)/2.0*a_StartLifeTime*(key-lastGradientNumber.x);\n }\n }\n return totalValue;\n}\n\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n vec4 overTimeColor;\n for(int i=1;i<4;i++)\n {\n vec2 gradientAlpha=gradientAlphas[i];\n float alphaKey=gradientAlpha.x;\n if(alphaKey>=normalizedAge)\n {\n vec2 lastGradientAlpha=gradientAlphas[i-1];\n float lastAlphaKey=lastGradientAlpha.x;\n float age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n overTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n break;\n }\n }\n \n for(int i=1;i<4;i++)\n {\n vec4 gradientColor=gradientColors[i];\n float colorKey=gradientColor.x;\n if(colorKey>=normalizedAge)\n {\n vec4 lastGradientColor=gradientColors[i-1];\n float lastColorKey=lastGradientColor.x;\n float age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n overTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n break;\n }\n }\n return overTimeColor;\n}\n\n\n\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n float overTimeFrame;\n for(int i=1;i<4;i++)\n {\n vec2 gradientFrame=gradientFrames[i];\n float key=gradientFrame.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientFrame=gradientFrames[i-1];\n float lastKey=lastGradientFrame.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n overTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n break;\n }\n }\n return floor(overTimeFrame);\n}\n\n#ifdef VELOCITYOVERLIFETIME\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n if(u_VOLType==0)\n outLifeVelocity=u_VOLVelocityConst; \n else if(u_VOLType==1)\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n else if(u_VOLType==2)\n outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,a_Random0.x); \n else if(u_VOLType==3)\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n \n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLType==0){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==1){\n startPosition=startVelocity*age;\n lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n }\n else if(u_VOLType==2){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==3){\n startPosition=startVelocity*age;\n lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n }\n \n vec3 finalPosition;\n if(u_VOLSpaceType==0){\n if(u_ScalingMode!=2)\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition+lifePosition));\n else\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition+lifePosition);\n }\n else{\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition))+lifePosition;\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition)+lifePosition;\n }\n #else\n startPosition=startVelocity*age;\n vec3 finalPosition;\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition));\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=u_Gravity*age*normalizedAge;//计算受重力影响的位置//TODO:移除\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n #ifdef COLOROVERLIFETIME\n color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n #endif\n \n #ifdef RANDOMCOLOROVERLIFETIME\n color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n #endif\n\n return color;\n}\n\nvec2 computeParticleSize(in vec2 size,in float normalizedAge)\n{\n #ifdef SIZEOVERLIFETIME\n if(u_SOLType==0){\n if(u_SOLSeprarate){\n size*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n }\n else{\n size*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n }\n }\n else if(u_SOLType==2){\n if(u_SOLSeprarate){\n size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n }\n else{\n size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n }\n }\n #endif\n return size;\n}\n\nvec3 computeParticleRotation(in vec3 rotation,in float age,in float normalizedAge)//TODO:不分轴是否无需计算XY,Billboard模式下好像是,待确认。\n{ \n #ifdef ROTATIONOVERLIFETIME\n if(u_ROLType==0){\n if(u_ROLSeprarate){\n vec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=u_ROLAngularVelocityConst*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==1){\n if(u_ROLSeprarate){\n rotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n }\n else{\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n }\n }\n else if(u_ROLType==2){\n if(u_ROLSeprarate){\n vec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==3){\n if(u_ROLSeprarate){\n rotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n }\n else{\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n }\n }\n #endif\n return rotation;\n}\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n #ifdef TEXTURESHEETANIMATION\n if(u_TSAType==1){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n else if(u_TSAType==3){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n #endif\n return uv;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n float normalizedAge = age/a_StartLifeTime;\n vec3 lifeVelocity;\n if(normalizedAge<1.0){ \n vec3 startVelocity=a_Direction*a_StartSpeed;\n #ifdef VELOCITYOVERLIFETIME\n lifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n #endif \n \n vec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge);//计算粒子位置\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n \n #ifdef SPHERHBILLBOARD\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n if(u_ThreeDStartRotation){\n center += u_SizeScale.xzy*(mat3(a_StartRotation0,a_StartRotation1,a_StartRotation2)*(corner.x*sideVector+corner.y*upVector));\n }\n else{\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner;\n center += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n }\n \n #endif\n \n #ifdef STRETCHEDBILLBOARD\n vec3 velocity;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLSpaceType==0)\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*(startVelocity+lifeVelocity));\n else\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity)+lifeVelocity;\n #else\n velocity= mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity);\n #endif \n vec3 cameraUpVector =normalize(velocity);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec2 size=computeParticleSize(a_StartSize.xy,normalizedAge);\n const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n corner=rotaionZHalfPI*corner;\n corner.y=corner.y-abs(corner.y);\n float speed=length(velocity);//TODO:\n center +=u_SizeScale.xzy*size.x*corner.x*sideVector+((cameraUpVector*speed)*u_StretchedBillboardSpeedScale+cameraUpVector*size.y*u_StretchedBillboardLengthScale)*corner.y;\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,0.0,-1.0);\n const vec3 sideVector = vec3(1.0,0.0,0.0);\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n v_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n v_Discard=0.0;\n }\n else\n {\n v_Discard=1.0;\n }\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/ParticleShuriKen.vs*/; + ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP\n if(v_Discard!=0.0)\n discard;\n gl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n #else\n gl_FragColor=vec4(0.0);\n #endif\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/ParticleShuriKen.ps*/; + Shader.preCompile(PARTICLESHURIKEN,vs,ps,shaderNameMap); + shaderNameMap={ + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Texcoord0':/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV", + 'a_Time':/*laya.d3.core.material.GlitterMaterial.TIME*/"TIME", + 'u_Texture':/*laya.d3.core.material.GlitterMaterial.DIFFUSETEXTURE*/"DIFFUSETEXTURE", + 'u_MvpMatrix':/*laya.d3.core.material.GlitterMaterial.MVPMATRIX*/"MVPMATRIX", + 'u_Albedo':/*laya.d3.core.material.GlitterMaterial.ALBEDO*/"ALBEDO", + 'u_CurrentTime':/*laya.d3.core.material.GlitterMaterial.CURRENTTIME*/"CURRENTTIME", + 'u_Color':/*laya.d3.core.material.GlitterMaterial.UNICOLOR*/"UNICOLOR", + 'u_Duration':/*laya.d3.core.material.GlitterMaterial.DURATION*/"DURATION"}; + var GLITTER=Shader.nameKey.add("GLITTER"); + vs="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nattribute float a_Time;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_CurrentTime;\nuniform vec4 u_Color;\nuniform float u_Duration;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n \n float age = u_CurrentTime-a_Time;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n \n v_Texcoord=a_Texcoord0;\n \n v_Color=u_Color;\n v_Color.a*=1.0-normalizedAge;\n}\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/Glitter.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform sampler2D u_Texture;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{ \n gl_FragColor=texture2D(u_Texture, v_Texcoord)*v_Color;\n gl_FragColor=gl_FragColor*u_Albedo;\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/Glitter.ps*/; + Shader.preCompile(GLITTER,vs,ps,shaderNameMap); + shaderNameMap={ + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'u_MvpMatrix':/*laya.d3.resource.models.Sky.MVPMATRIX*/"MVPMATRIX", + 'u_Intensity':/*laya.d3.resource.models.Sky.INTENSITY*/"INTENSITY", + 'u_AlphaBlending':/*laya.d3.resource.models.Sky.ALPHABLENDING*/"ALPHABLENDING", + 'u_CubeTexture':/*laya.d3.resource.models.Sky.DIFFUSETEXTURE*/"DIFFUSETEXTURE"}; + var skyBox=Shader.nameKey.add("SkyBox"); + vs="attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord=a_Position.xyz;\n}\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/SkyBox.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform samplerCube u_CubeTexture;\n\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(textureCube(u_CubeTexture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/SkyBox.ps*/; + Shader.preCompile(skyBox,vs,ps,shaderNameMap); + shaderNameMap={ + 'a_Position':/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION", + 'a_Texcoord0':/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV", + 'u_MvpMatrix':/*laya.d3.resource.models.Sky.MVPMATRIX*/"MVPMATRIX", + 'u_Intensity':/*laya.d3.resource.models.Sky.INTENSITY*/"INTENSITY", + 'u_AlphaBlending':/*laya.d3.resource.models.Sky.ALPHABLENDING*/"ALPHABLENDING", + 'u_texture':/*laya.d3.resource.models.Sky.DIFFUSETEXTURE*/"DIFFUSETEXTURE"}; + var skyDome=Shader.nameKey.add("SkyDome"); + vs="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nuniform mat4 u_MvpMatrix;\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord = a_Texcoord0;\n}\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/SkyDome.vs*/; + ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform sampler2D u_texture;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(texture2D(u_texture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/d3/src/laya/d3/shader/files/SkyDome.ps*/; + Shader.preCompile(skyDome,vs,ps,shaderNameMap); + } + + Laya3D._initResourceLoad=function(){ + var createMap=LoaderManager.createMap; + createMap["lh"]=[Sprite3D,/*CLASS CONST:Laya3D.SPRITE3DHIERARCHY*/"SPRITE3DHIERARCHY"]; + createMap["lm"]=[Mesh,/*CLASS CONST:Laya3D.MESH*/"MESH"]; + createMap["lmat"]=[StandardMaterial,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"]; + createMap["ltc"]=[TextureCube,/*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"]; + createMap["jpg"]=[Texture2D,"nativeimage"]; + createMap["jpeg"]=[Texture2D,"nativeimage"]; + createMap["png"]=[Texture2D,"nativeimage"]; + createMap["lsani"]=[AnimationTemplet,/*laya.net.Loader.BUFFER*/"arraybuffer"]; + createMap["lrani"]=[AnimationTemplet,/*laya.net.Loader.BUFFER*/"arraybuffer"]; + createMap["ani"]=[AnimationTemplet,/*laya.net.Loader.BUFFER*/"arraybuffer"]; + createMap["lani"]=[AnimationTemplet,/*laya.net.Loader.BUFFER*/"arraybuffer"]; + Loader.parserMap[ /*CLASS CONST:Laya3D.SPRITE3DHIERARCHY*/"SPRITE3DHIERARCHY"]=Laya3D._loadSprite3DHierarchy; + Loader.parserMap[ /*CLASS CONST:Laya3D.MESH*/"MESH"]=Laya3D._loadMesh; + Loader.parserMap[ /*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"]=Laya3D._loadMaterial; + Loader.parserMap[ /*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"]=Laya3D._loadTextureCube; + } + + Laya3D.READ_BLOCK=function(){ + Laya3D._readData.pos+=4; + return true; + } + + Laya3D.READ_DATA=function(){ + Laya3D._DATA.offset=Laya3D._readData.getUint32(); + Laya3D._DATA.size=Laya3D._readData.getUint32(); + return true; + } + + Laya3D.READ_STRINGS=function(){ + var materialUrls=[]; + var _STRINGS={offset:0,size:0}; + _STRINGS.offset=Laya3D._readData.getUint16(); + _STRINGS.size=Laya3D._readData.getUint16(); + var ofs=Laya3D._readData.pos; + Laya3D._readData.pos=_STRINGS.offset+Laya3D._DATA.offset; + for (var i=0;i < _STRINGS.size;i++){ + var string=Laya3D._readData.readUTFString(); + if (string.lastIndexOf(".lmat")!==-1) + materialUrls.push(string); + } + return materialUrls; + } + + Laya3D._getSprite3DHierarchyInnerUrls=function(hierarchyNode,urls,urlMap,urlVersion){ + var path; + var clas; + switch (hierarchyNode.type){ + case "MeshSprite3D": + path=hierarchyNode.instanceParams.loadPath; + clas=Mesh; + break ; + case "ShuriKenParticle3D": + path=hierarchyNode.customProps.texturePath; + clas=Texture2D; + break ; + } + if (path){ + var formatSubUrl=URL.formatURL(path); + (urlVersion)&& (formatSubUrl=formatSubUrl+urlVersion); + urls.push({url:formatSubUrl,clas:clas}); + urlMap[path]=formatSubUrl; + }; + var children=hierarchyNode.child; + for (var i=0,n=children.length;i < n;i++) + Laya3D._getSprite3DHierarchyInnerUrls(children[i],urls,urlMap,urlVersion); + } + + Laya3D._loadSprite3DHierarchy=function(loader){ + var lmLoader=new Loader(); + lmLoader.on(/*laya.events.Event.COMPLETE*/"complete",null,Laya3D._onSprite3DHierarchylhLoaded,[loader]); + lmLoader.load(loader.url,/*laya.net.Loader.TEXT*/"text",false,null,true); + } + + Laya3D._onSprite3DHierarchylhLoaded=function(loader,lhData){ + var url=loader.url; + var urlVersion=Utils3D.getURLVerion(url); + var preBasePath=URL.basePath; + URL.basePath=URL.getPath(URL.formatURL(url)); + var urls=[]; + var urlMap={}; + var hierarchyData=JSON.parse(lhData); + Laya3D._getSprite3DHierarchyInnerUrls(hierarchyData,urls,urlMap,urlVersion); + var urlCount=urls.length; + var totalProcessCount=urlCount+1; + var lhWeight=1 / totalProcessCount; + Laya3D._onProcessChange(loader,0,lhWeight,1.0); + if (urlCount > 0){ + var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,lhWeight,urlCount / totalProcessCount],false); + Laya3D._innerSprite3DHierarchyLoaderManager.create(urls,Handler.create(null,Laya3D._onSprite3DMeshsLoaded,[loader,processHandler,lhData,urlMap]),processHandler); + }else { + Laya3D._onSprite3DMeshsLoaded(loader,null,lhData,null); + } + URL.basePath=preBasePath; + } + + Laya3D._onSprite3DMeshsLoaded=function(loader,processHandler,lhData,urlMap){ + loader.endLoad([lhData,urlMap]); + (processHandler)&& (processHandler.recover()); + } + + Laya3D._loadMesh=function(loader){ + var lmLoader=new Loader(); + lmLoader.on(/*laya.events.Event.COMPLETE*/"complete",null,Laya3D._onMeshLmLoaded,[loader]); + lmLoader.load(loader.url,/*laya.net.Loader.BUFFER*/"arraybuffer",false,null,true); + } + + Laya3D._onMeshLmLoaded=function(loader,lmData){ + var url=loader.url; + var urlVersion=Utils3D.getURLVerion(url); + var preBasePath=URL.basePath; + URL.basePath=URL.getPath(URL.formatURL(url)); + var urls; + var urlMap={}; + var formatSubUrl; + Laya3D._readData=new Byte(lmData); + Laya3D._readData.pos=0; + Laya3D._readData.readUTFString(); + Laya3D.READ_BLOCK(); + var i=0,n=0; + for (i=0;i < 2;i++){ + var index=Laya3D._readData.getUint16(); + var blockName=Laya3D._strings[index]; + var fn=Laya3D["READ_"+blockName]; + if (fn==null)throw new Error("model file err,no this function:"+index+" "+blockName); + if (i===1) + urls=fn.call(); + else + fn.call() + } + for (i=0,n=urls.length;i < n;i++){ + var subUrl=urls[i]; + formatSubUrl=URL.formatURL(subUrl); + (urlVersion)&& (formatSubUrl=formatSubUrl+urlVersion); + urls[i]=formatSubUrl; + urlMap[subUrl]=formatSubUrl; + }; + var urlCount=1; + var totalProcessCount=urlCount+1; + var lmatWeight=1 / totalProcessCount; + Laya3D._onProcessChange(loader,0,lmatWeight,1.0); + var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,lmatWeight,urlCount / totalProcessCount],false); + Laya3D._innerMeshLoaderManager.create(urls,Handler.create(null,Laya3D._onMeshMateialLoaded,[loader,processHandler,lmData,urlMap]),processHandler,StandardMaterial); + URL.basePath=preBasePath; + } + + Laya3D._onMeshMateialLoaded=function(loader,processHandler,lmData,urlMap){ + loader.endLoad([lmData,urlMap]); + processHandler.recover(); + } + + Laya3D._getMaterialTexturePath=function(path,urlVersion){ + var extenIndex=path.length-4; + if (path.indexOf(".dds")==extenIndex || path.indexOf(".tga")==extenIndex || path.indexOf(".exr")==extenIndex || path.indexOf(".DDS")==extenIndex || path.indexOf(".TGA")==extenIndex || path.indexOf(".EXR")==extenIndex) + path=path.substr(0,extenIndex)+".png"; + path=URL.formatURL(path); + (urlVersion)&& (path=path+urlVersion); + return path; + } + + Laya3D._loadMaterial=function(loader){ + var lmatLoader=new Loader(); + lmatLoader.on(/*laya.events.Event.COMPLETE*/"complete",null,Laya3D._onMaterilLmatLoaded,[loader]); + lmatLoader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true); + } + + Laya3D._onMaterilLmatLoaded=function(loader,lmatData){ + var url=loader.url; + var urlVersion=Utils3D.getURLVerion(url); + var preBasePath=URL.basePath; + URL.basePath=URL.getPath(URL.formatURL(url)); + var urls=[]; + var urlMap={}; + var customProps=lmatData.customProps; + var formatSubUrl; + var diffuseTexture=customProps.diffuseTexture.texture2D; + if (diffuseTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(diffuseTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[diffuseTexture]=formatSubUrl; + }; + var normalTexture=customProps.normalTexture.texture2D; + if (normalTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(normalTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[normalTexture]=formatSubUrl; + }; + var specularTexture=customProps.specularTexture.texture2D; + if (specularTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(specularTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[specularTexture]=formatSubUrl; + }; + var emissiveTexture=customProps.emissiveTexture.texture2D; + if (emissiveTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(emissiveTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[emissiveTexture]=formatSubUrl; + }; + var ambientTexture=customProps.ambientTexture.texture2D; + if (ambientTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(ambientTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[ambientTexture]=formatSubUrl; + }; + var reflectTexture=customProps.reflectTexture.texture2D; + if (reflectTexture){ + formatSubUrl=Laya3D._getMaterialTexturePath(reflectTexture,urlVersion); + urls.push(formatSubUrl); + urlMap[reflectTexture]=formatSubUrl; + }; + var urlCount=urls.length; + var totalProcessCount=urlCount+1; + var lmatWeight=1 / totalProcessCount; + Laya3D._onProcessChange(loader,0,lmatWeight,1.0); + if (urlCount > 0){ + var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,lmatWeight,urlCount / totalProcessCount],false); + Laya3D._innerMaterialLoaderManager.create(urls,Handler.create(null,Laya3D._onMateialTexturesLoaded,[loader,processHandler,lmatData,urlMap]),processHandler,Texture2D); + }else { + Laya3D._onMateialTexturesLoaded(loader,null,lmatData,null); + } + URL.basePath=preBasePath; + } + + Laya3D._onMateialTexturesLoaded=function(loader,processHandler,lmatData,urlMap){ + loader.endLoad([lmatData,urlMap]); + (processHandler)&& (processHandler.recover()); + } + + Laya3D._loadTextureCube=function(loader){ + var ltcLoader=new Loader(); + ltcLoader.on(/*laya.events.Event.COMPLETE*/"complete",null,Laya3D._onTextureCubeLtcLoaded,[loader]); + ltcLoader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true); + } + + Laya3D._onTextureCubeLtcLoaded=function(loader,ltcData){ + var preBasePath=URL.basePath; + URL.basePath=URL.getPath(URL.formatURL(loader.url)); + var urls=[URL.formatURL(ltcData.px),URL.formatURL(ltcData.nx),URL.formatURL(ltcData.py),URL.formatURL(ltcData.ny),URL.formatURL(ltcData.pz),URL.formatURL(ltcData.nz)]; + var ltcWeight=1 / 7; + Laya3D._onProcessChange(loader,0,ltcWeight,1.0); + var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,ltcWeight,6 / 7],false); + Laya3D._innerTextureCubeLoaderManager.load(urls,Handler.create(null,Laya3D._onTextureCubeImagesLoaded,[loader,urls,processHandler]),processHandler,"nativeimage"); + URL.basePath=preBasePath; + } + + Laya3D._onTextureCubeImagesLoaded=function(loader,urls,processHandler){ + var images=[]; + images.length=6; + for (var i=0;i < 6;i++){ + var url=urls[i]; + images[i]=Loader.getRes(url); + Loader.clearRes(url); + } + loader.endLoad(images); + processHandler.recover(); + } + + Laya3D._onProcessChange=function(loader,offset,weight,process){ + var process=offset+process *weight; + (process < 1.0)&& (loader.event(/*laya.events.Event.PROGRESS*/"progress",process)); + } + + Laya3D.init=function(width,height,antialias,alpha,premultipliedAlpha){ + (antialias===void 0)&& (antialias=false); + (alpha===void 0)&& (alpha=false); + (premultipliedAlpha===void 0)&& (premultipliedAlpha=false); + if (!WebGL.enable()){ + alert("Laya3D init err,must support webGL!"); + return; + } + Laya3D._innerTextureCubeLoaderManager.maxLoader=1; + Laya3D._innerMaterialLoaderManager.maxLoader=1; + Laya3D._innerMeshLoaderManager.maxLoader=1; + Laya3D._innerSprite3DHierarchyLoaderManager.maxLoader=1; + RunDriver.changeWebGLSize=Laya3D._changeWebGLSize; + Config.isAntialias=antialias; + Config.isAlpha=alpha; + Config.premultipliedAlpha=premultipliedAlpha; + Render.is3DMode=true; + Laya.init(width,height); + Layer.__init__(); + ShaderDefines3D.__init__(); + Laya3D._initShader(); + Laya3D._initResourceLoad(); + } + + Laya3D._readData=null + Laya3D.SPRITE3DHIERARCHY="SPRITE3DHIERARCHY"; + Laya3D.MESH="MESH"; + Laya3D.MATERIAL="MATERIAL"; + Laya3D.TEXTURECUBE="TEXTURECUBE"; + __static(Laya3D, + ['_DATA',function(){return this._DATA={offset:0,size:0};},'_strings',function(){return this._strings=['BLOCK','DATA',"STRINGS"];},'_innerTextureCubeLoaderManager',function(){return this._innerTextureCubeLoaderManager=new LoaderManager();},'_innerMaterialLoaderManager',function(){return this._innerMaterialLoaderManager=new LoaderManager();},'_innerMeshLoaderManager',function(){return this._innerMeshLoaderManager=new LoaderManager();},'_innerSprite3DHierarchyLoaderManager',function(){return this._innerSprite3DHierarchyLoaderManager=new LoaderManager();} + ]); + return Laya3D; + })() + + + /** + *Component3D 类用于创建组件的父类。 + */ + //class laya.d3.component.Component3D extends laya.events.EventDispatcher + var Component3D=(function(_super){ + function Component3D(){ + this._id=0; + this._cachedOwnerLayerMask=0; + this._cachedOwnerEnable=false; + this._enable=false; + this._owner=null; + this.started=false; + Component3D.__super.call(this); + this._id=Component3D._uniqueIDCounter; + Component3D._uniqueIDCounter++; + } + + __class(Component3D,'laya.d3.component.Component3D',_super); + var __proto=Component3D.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IUpdate":true}) + /** + *@private + *owner蒙版变化事件处理。 + *@param mask 蒙版值。 + */ + __proto._onLayerChanged=function(layer){ + this._cachedOwnerLayerMask=layer.mask; + } + + /** + *@private + *owner启用变化事件处理。 + *@param enable 是否启用。 + */ + __proto._onEnableChanged=function(enable){ + this._cachedOwnerEnable=enable; + } + + /** + *@private + *初始化组件。 + *@param owner 所属Sprite3D节点。 + */ + __proto._initialize=function(owner){ + this._owner=owner; + this.enable=true; + this.started=false; + this._cachedOwnerLayerMask=owner.layer.mask; + this._owner.on(/*laya.events.Event.LAYER_CHANGED*/"layerchanged",this,this._onLayerChanged); + this._cachedOwnerEnable=owner.enable; + this._owner.on(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onEnableChanged); + this._load(owner); + } + + /** + *@private + *卸载组件。 + */ + __proto._uninitialize=function(){ + this._unload(this.owner); + this._owner=null; + } + + /** + *@private + *载入组件时执行,可重写此函数。 + */ + __proto._load=function(owner){} + /** + *@private + *在任意第一次更新时执行,可重写此函数。 + */ + __proto._start=function(state){} + /** + *@private + *更新组件,可重写此函数。 + *@param state 渲染状态参数。 + */ + __proto._update=function(state){} + /** + *@private + *更新的最后阶段执行,可重写此函数。 + *@param state 渲染状态参数。 + */ + __proto._lateUpdate=function(state){} + /** + *@private + *渲染前设置组件相关参数,可重写此函数。 + *@param state 渲染状态参数。 + */ + __proto._preRenderUpdate=function(state){} + /** + *@private + *渲染的最后阶段执行,可重写此函数。 + *@param state 渲染状态参数。 + */ + __proto._postRenderUpdate=function(state){} + /** + *@private + *卸载组件时执行,可重写此函数。 + */ + __proto._unload=function(owner){ + this.offAll(); + } + + /** + *获取唯一标识ID。 + *@return 唯一标识ID。 + */ + __getset(0,__proto,'id',function(){ + return this._id; + }); + + /** + *获取所属Sprite3D节点。 + *@return 所属Sprite3D节点。 + */ + __getset(0,__proto,'owner',function(){ + return this._owner; + }); + + /** + *设置是否启用。 + *@param value 是否启动 + */ + /** + *获取是否启用。 + *@return 是否启动。 + */ + __getset(0,__proto,'enable',function(){ + return this._enable; + },function(value){ + if (this._enable!==value){ + this._enable=value; + this.event(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this._enable); + } + }); + + /** + *获取是否激活。 + *@return 是否激活。 + */ + __getset(0,__proto,'isActive',function(){ + return Layer.isActive(this._cachedOwnerLayerMask)&& this._cachedOwnerEnable && this._enable; + }); + + /** + *获取是否可见。 + *@return 是否可见。 + */ + __getset(0,__proto,'isVisible',function(){ + return Layer.isVisible(this._cachedOwnerLayerMask)&& this._cachedOwnerEnable && this._enable; + }); + + Component3D._uniqueIDCounter=1; + return Component3D; + })(EventDispatcher) + + + /** + *Render 类用于渲染器的父类,抽象类不允许示例。 + */ + //class laya.d3.core.render.BaseRender extends laya.events.EventDispatcher + var BaseRender=(function(_super){ + function BaseRender(owner){ + this._owner=null; + this._enable=false; + this._renderObject=null; + this._materials=null; + this._boundingSphereNeedChange=false; + this._boundingBoxNeedChange=false; + this._boundingSphere=null; + this._boundingBox=null; + BaseRender.__super.call(this); + this._owner=owner; + this._enable=true; + this._boundingBox=new BoundBox(new Vector3(),new Vector3()); + this._boundingSphere=new BoundSphere(new Vector3(),0); + this._boundingSphereNeedChange=true; + this._boundingBoxNeedChange=true; + this._renderObject=new RenderObject(); + this._renderObject._render=this; + this._renderObject._layerMask=this._owner.layer.mask; + this._renderObject._ownerEnable=this._owner.enable; + this._renderObject._enable=this._enable; + this._materials=[]; + this._owner.transform.on(/*laya.events.Event.WORLDMATRIX_NEEDCHANGE*/"worldmatrixneedchanged",this,this._onWorldMatNeedChange); + this._owner.on(/*laya.events.Event.LAYER_CHANGED*/"layerchanged",this,this._onOwnerLayerChanged); + this._owner.on(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onOwnerEnableChanged); + this.on(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onEnableChanged); + } + + __class(BaseRender,'laya.d3.core.render.BaseRender',_super); + var __proto=BaseRender.prototype; + Laya.imps(__proto,{"laya.resource.IDestroy":true}) + /** + *@private + */ + __proto._onWorldMatNeedChange=function(){ + this._boundingSphereNeedChange=true; + this._boundingBoxNeedChange=true; + } + + /** + *@private + */ + __proto._onOwnerLayerChanged=function(layer){ + this._renderObject._layerMask=layer.mask; + } + + /** + *@private + */ + __proto._onOwnerEnableChanged=function(enable){ + this._renderObject._ownerEnable=enable; + } + + /** + *@private + */ + __proto._onEnableChanged=function(sender,enable){ + this._renderObject._enable=enable; + } + + /** + *@private + */ + __proto._calculateBoundingSphere=function(){ + throw("BaseRender: must override it."); + } + + /** + *@private + */ + __proto._calculateBoundingBox=function(){ + throw("BaseRender: must override it."); + } + + /** + *@private + */ + __proto._destroy=function(){ + this.offAll(); + this._owner=null; + this._renderObject=null; + this._materials=null; + this._boundingBox=null; + this._boundingSphere=null; + } + + /** + *设置是否可用。 + *@param value 是否可用。 + */ + /** + *获取是否可用。 + *@return 是否可用。 + */ + __getset(0,__proto,'enable',function(){ + return this._enable; + },function(value){ + this._enable=value; + this.event(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",[this,value]); + }); + + /** + *获取包围盒。 + *@return 包围盒。 + */ + __getset(0,__proto,'boundingBox',function(){ + if (this._boundingBoxNeedChange){ + this._calculateBoundingBox(); + this._boundingBoxNeedChange=false; + } + return this._boundingBox; + }); + + /** + *设置材质列表。 + *@param value 材质列表。 + */ + /** + *获取浅拷贝材质列表。 + *@return 浅拷贝材质列表。 + */ + __getset(0,__proto,'sharedMaterials',function(){ + var materials=this._materials.slice(); + return materials; + },function(value){ + if (!value) + throw new Error("MeshRender: shadredMaterials value can't be null."); + this._materials=value; + for (var i=0,n=value.length;iMeshFilter 类用于创建网格过滤器。 + */ + //class laya.d3.core.MeshFilter extends laya.events.EventDispatcher + var MeshFilter=(function(_super){ + function MeshFilter(owner){ + this._owner=null; + this._sharedMesh=null; + MeshFilter.__super.call(this); + this._owner=owner; + } + + __class(MeshFilter,'laya.d3.core.MeshFilter',_super); + var __proto=MeshFilter.prototype; + Laya.imps(__proto,{"laya.resource.IDestroy":true}) + /** + *@private + */ + __proto._destroy=function(){ + this.offAll(); + this._owner=null; + this._sharedMesh=null; + } + + /** + *设置共享网格。 + *@return value 共享网格。 + */ + /** + *获取共享网格。 + *@return 共享网格。 + */ + __getset(0,__proto,'sharedMesh',function(){ + return this._sharedMesh; + },function(value){ + var oldMesh=this._sharedMesh; + this._sharedMesh=value; + this.event(/*laya.events.Event.MESH_CHANGED*/"meshchanged",[this,oldMesh,value]); + }); + + return MeshFilter; + })(EventDispatcher) + + + /** + *Emission 类用于粒子发射器。 + */ + //class laya.d3.core.particleShuriKen.module.Emission extends laya.events.EventDispatcher + var Emission=(function(_super){ + function Emission(){ + this._burstsIndex=0; + this._bursts=null; + this._startDelay=NaN; + this._isPlaying=false; + this._isPaused=false; + this._frameTime=NaN; + this._emissionTime=NaN; + this._playbackTime=NaN; + this._minEmissionTime=NaN; + this._emissionRate=0; + this._particleSystem=null; + this._shape=null; + this.enbale=false; + Emission.__super.call(this); + this._burstsIndex=0; + this._isPlaying=false; + this._isPaused=false; + this._frameTime=0; + this._emissionTime=0; + this._playbackTime=0; + this.emissionRate=10; + this._bursts=[]; + } + + __class(Emission,'laya.d3.core.particleShuriKen.module.Emission',_super); + var __proto=Emission.prototype; + Laya.imps(__proto,{"laya.resource.IDestroy":true}) + /** + *@private + */ + __proto._burst=function(fromTime,toTime){ + var totalEmitCount=0; + for (var n=this._bursts.length;this._burstsIndex < n;this._burstsIndex++){ + var burst=this._bursts[this._burstsIndex]; + var burstTime=burst.time; + if (burstTime >=fromTime && burstTime <=toTime){ + var emitCount=MathUtil.lerp(burst.minCount,burst.maxCount,Math.random()); + totalEmitCount+=emitCount; + }else { + break ; + } + } + return totalEmitCount; + } + + /** + *@private + */ + __proto._advanceTime=function(elapsedTime,transform){ + if (!this._isPlaying || this._isPaused) + return; + this._playbackTime+=elapsedTime; + if (this._playbackTime < this._startDelay) + return; + var i=0; + var lastEmissionTime=this._emissionTime; + this._emissionTime+=elapsedTime; + var duration=this._particleSystem.duration; + var totalBurstCount=0; + if (this._emissionTime > duration){ + totalBurstCount+=this._burst(lastEmissionTime,duration); + if (this._particleSystem.looping){ + this._emissionTime-=duration; + this.event(/*laya.events.Event.COMPLETE*/"complete"); + this._burstsIndex=0; + totalBurstCount+=this._burst(0,this._emissionTime); + }else { + this._isPlaying=false; + totalBurstCount=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,totalBurstCount); + for (i=0;i < totalBurstCount;i++) + this.emit(transform); + this.event(/*laya.events.Event.STOPPED*/"stopped"); + return; + } + }else { + totalBurstCount+=this._burst(lastEmissionTime,this._emissionTime); + } + totalBurstCount=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,totalBurstCount); + for (i=0;i < totalBurstCount;i++) + this.emit(transform); + this._frameTime+=elapsedTime; + if (this._frameTime < this._minEmissionTime) + return; + while (this._frameTime > this._minEmissionTime){ + if (this.emit(transform)) + this._frameTime-=this._minEmissionTime; + else + break ; + } + } + + /** + *@private + */ + __proto._destroy=function(){ + this.offAll(); + this._bursts=null; + this._particleSystem=null; + } + + /** + *开始发射粒子。 + */ + __proto.play=function(){ + this._burstsIndex=0; + this._isPlaying=true; + this._isPaused=false; + this._frameTime=0; + this._emissionTime=0; + this._playbackTime=0; + switch (this._particleSystem.startDelayType){ + case 0: + this._startDelay=this._particleSystem.startDelay; + break ; + case 1: + this._startDelay=MathUtil.lerp(this._particleSystem.startDelayMin,this._particleSystem.startDelayMax,Math.random()); + break ; + default : + throw new Error("Utils3D: startDelayType is invalid."); + } + this._particleSystem._startUpdateLoopCount=Stat.loopCount; + this.event(/*laya.events.Event.PLAYED*/"played"); + } + + /** + *暂停发射粒子。 + */ + __proto.pause=function(){ + this._isPaused=true; + this.event(/*laya.events.Event.PAUSED*/"paused"); + } + + /** + *停止发射粒子。 + */ + __proto.stop=function(){ + this._burstsIndex=0; + this._frameTime=0; + this._isPlaying=false; + this._isPaused=false; + this._emissionTime=0; + this._playbackTime=0; + this.event(/*laya.events.Event.STOPPED*/"stopped"); + } + + /** + *获取粒子爆裂个数。 + *@return 粒子爆裂个数。 + */ + __proto.getBurstsCount=function(){ + return this._bursts.length; + } + + /** + *通过索引获取粒子爆裂。 + *@param index 爆裂索引。 + *@return 粒子爆裂。 + */ + __proto.getBurstByIndex=function(index){ + return this._bursts[index]; + } + + /** + *增加粒子爆裂。 + *@param burst 爆裂。 + */ + __proto.addBurst=function(burst){ + var burstsCount=this._bursts.length; + if (burstsCount > 0) + for (var i=0;i < burstsCount;i++){ + if (this._bursts[i].time > burst.time) + this._bursts.splice(i,0,burst); + } + else + this._bursts.push(burst); + } + + /** + *移除粒子爆裂。 + *@param burst 爆裂。 + */ + __proto.removeBurst=function(burst){ + var index=this._bursts.indexOf(burst); + if (index!==-1){ + this._bursts.splice(index,1); + var maxBurstsIndex=this._bursts.length; + if (this._burstsIndex > maxBurstsIndex) + this._burstsIndex=maxBurstsIndex; + } + } + + /** + *通过索引移除粒子爆裂。 + *@param index 爆裂索引。 + */ + __proto.removeBurstByIndex=function(index){ + this._bursts.splice(index,1); + var maxBurstsIndex=this._bursts.length; + if (this._burstsIndex > maxBurstsIndex) + this._burstsIndex=maxBurstsIndex; + } + + /** + *清空粒子爆裂。 + */ + __proto.clearBurst=function(){ + this._burstsIndex=0; + this._bursts.length=0; + } + + /** + *更新球粒子发射器。 + *@param state 渲染相关状态参数。 + */ + __proto.update=function(elapsedTime,transform){ + (this.enbale)&& (this._advanceTime(elapsedTime,transform)); + } + + /** + *发射一个粒子。 + */ + __proto.emit=function(transform){ + var position=Emission._tempPosition; + var direction=Emission._tempDirection; + if (this._shape.enbale){ + this._shape.generatePositionAndDirection(position,direction); + }else { + var positionE=position.elements; + var directionE=direction.elements; + positionE[0]=positionE[1]=positionE[2]=0; + directionE[0]=directionE[1]=0; + directionE[2]=1; + } + return this._particleSystem.addParticle(position,direction,transform); + } + + /** + *获取播放的累计时间。 + *@return 播放的累计时间。 + */ + __getset(0,__proto,'playbackTime',function(){ + return this._playbackTime; + }); + + /**是否正在播放。*/ + __getset(0,__proto,'isPlaying',function(){ + return this._isPlaying; + }); + + /**是否已暂停。*/ + __getset(0,__proto,'isPaused',function(){ + return this._isPaused; + }); + + /** + *获取一次循环内的累计时间。 + *@return 一次循环内的累计时间。 + */ + __getset(0,__proto,'emissionTime',function(){ + var duration=this._particleSystem.duration; + return this._emissionTime > duration ? duration :this._emissionTime; + }); + + /** + *设置粒子发射速率。 + *@param emissionRate 粒子发射速率 (个/秒)。 + */ + /** + *获取粒子发射速率。 + *@return 粒子发射速率 (个/秒)。 + */ + __getset(0,__proto,'emissionRate',function(){ + return this._emissionRate; + },function(value){ + if (value < 0) + throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0."); + this._emissionRate=value; + if (value===0) + this._minEmissionTime=2147483647; + else + this._minEmissionTime=1 / value; + }); + + __static(Emission, + ['_tempPosition',function(){return this._tempPosition=new Vector3();},'_tempDirection',function(){return this._tempDirection=new Vector3();} + ]); + return Emission; + })(EventDispatcher) + + + /** + *Transform3D 类用于实现3D变换。 + */ + //class laya.d3.core.Transform3D extends laya.events.EventDispatcher + var Transform3D=(function(_super){ + function Transform3D(owner){ + this._owner=null; + this._preWorldTransformModifyID=-1; + this._localUpdate=false; + this._worldUpdate=true; + this._parent=null; + Transform3D.__super.call(this); + this._tempMatrix0=new Matrix4x4(); + this._tempQuaternion0=new Quaternion(); + this._tempVector30=new Vector3(); + this._localPosition=new Vector3(); + this._localRotation=new Quaternion(0,0,0,1); + this._localScale=new Vector3(1,1,1); + this._localMatrix=new Matrix4x4(); + this._position=new Vector3(); + this._rotation=new Quaternion(0,0,0,1); + this._scale=new Vector3(1,1,1); + this._worldMatrix=new Matrix4x4(); + this._forward=new Vector3(); + this._up=new Vector3(); + this._right=new Vector3(); + this._owner=owner; + } + + __class(Transform3D,'laya.d3.core.Transform3D',_super); + var __proto=Transform3D.prototype; + /** + *@private + */ + __proto._updateLocalMatrix=function(){ + Matrix4x4.createAffineTransformation(this._localPosition,this._localRotation,this._localScale,this._localMatrix); + } + + /** + *@private + */ + __proto._onLocalTransform=function(){ + this._localUpdate=true; + } + + /** + *@private + */ + __proto._onWorldTransform=function(){ + if (!this._worldUpdate){ + this._worldUpdate=true; + this.event(/*laya.events.Event.WORLDMATRIX_NEEDCHANGE*/"worldmatrixneedchanged"); + for (var i=0,n=this._owner._childs.length;i < n;i++) + (this._owner._childs [i]).transform._onWorldTransform(); + } + } + + /** + *平移变换。 + *@param translation 移动距离。 + *@param isLocal 是否局部空间。 + */ + __proto.translate=function(translation,isLocal){ + (isLocal===void 0)&& (isLocal=true); + if (isLocal){ + Matrix4x4.createFromQuaternion(this.localRotation,this._tempMatrix0); + Vector3.transformCoordinate(translation,this._tempMatrix0,this._tempVector30); + Vector3.add(this.localPosition,this._tempVector30,this._localPosition); + this.localPosition=this._localPosition; + }else { + Vector3.add(this.position,translation,this._position); + this.position=this._position; + } + } + + /** + *旋转变换。 + *@param rotations 旋转幅度。 + *@param isLocal 是否局部空间。 + *@param isRadian 是否弧度制。 + */ + __proto.rotate=function(rotation,isLocal,isRadian){ + (isLocal===void 0)&& (isLocal=true); + (isRadian===void 0)&& (isRadian=true); + var rot; + if (!isRadian){ + Vector3.scale(rotation,Math.PI / 180,this._tempVector30); + rot=this._tempVector30; + }else { + rot=rotation; + } + Quaternion.createFromYawPitchRoll(rot.y,rot.x,rot.z,this._tempQuaternion0); + if (isLocal){ + Quaternion.multiply(this._localRotation,this._tempQuaternion0,this._localRotation); + this.localRotation=this._localRotation; + }else { + Quaternion.multiply(this._tempQuaternion0,this.rotation,this._rotation); + this.rotation=this._rotation; + } + } + + /** + *设置局部旋转。 + *@param value 局部旋转。 + */ + /** + *获取局部旋转。 + *@return 局部旋转。 + */ + __getset(0,__proto,'localRotation',function(){ + return this._localRotation; + },function(value){ + this._localRotation=value; + this._localRotation.normalize(this._localRotation); + this._onLocalTransform(); + this._onWorldTransform(); + }); + + /** + *设置世界矩阵。 + *@param value 世界矩阵。 + */ + /** + *获取世界矩阵。 + *@return 世界矩阵。 + */ + __getset(0,__proto,'worldMatrix',function(){ + if (!this._worldUpdate) + return this._worldMatrix; + if (this._parent !=null) + Matrix4x4.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix); + else + this.localMatrix.cloneTo(this._worldMatrix); + this._worldUpdate=false; + return this._worldMatrix; + },function(value){ + if (this._parent===null) + this.localMatrix=value; + else { + this._parent.worldMatrix.invert(this._localMatrix); + Matrix4x4.multiply(this._localMatrix,value,this._localMatrix); + this.localMatrix=this._localMatrix; + } + }); + + /** + *获取世界矩阵是否需要更新。 + *@return 世界矩阵是否需要更新。 + */ + __getset(0,__proto,'worldNeedUpdate',function(){ + return this._worldUpdate; + }); + + /** + *设置局部矩阵。 + *@param value 局部矩阵。 + */ + /** + *获取局部矩阵。 + *@return 局部矩阵。 + */ + __getset(0,__proto,'localMatrix',function(){ + if (this._localUpdate){ + this._updateLocalMatrix(); + this._localUpdate=false; + } + return this._localMatrix; + },function(value){ + this._localMatrix=value; + this._localMatrix.decompose(this._localPosition,this._localRotation,this._localScale); + this._onWorldTransform(); + }); + + /** + *设置局部位置。 + *@param value 局部位置。 + */ + /** + *获取局部位置。 + *@return 局部位置。 + */ + __getset(0,__proto,'localPosition',function(){ + return this._localPosition; + },function(value){ + this._localPosition=value; + this._onLocalTransform(); + this._onWorldTransform(); + }); + + /** + *设置局部缩放。 + *@param value 局部缩放。 + */ + /** + *获取局部缩放。 + *@return 局部缩放。 + */ + __getset(0,__proto,'localScale',function(){ + return this._localScale; + },function(value){ + this._localScale=value; + this._onLocalTransform(); + this._onWorldTransform(); + }); + + /** + *设置世界位置。 + *@param value 世界位置。 + */ + /** + *获取世界位置。 + *@return 世界位置。 + */ + __getset(0,__proto,'position',function(){ + if (this._parent!==null){ + var worldMatElem=this.worldMatrix.elements; + this._position.elements[0]=worldMatElem[12]; + this._position.elements[1]=worldMatElem[13]; + this._position.elements[2]=worldMatElem[14]; + }else { + this._localPosition.cloneTo(this._position); + } + return this._position; + },function(value){ + if (this._parent!==null){ + this._parent.worldMatrix.invert(this._tempMatrix0); + Vector3.transformCoordinate(value,this._tempMatrix0,this._localPosition); + this.localPosition=this._localPosition; + }else { + value.cloneTo(this._localPosition); + this.localPosition=this._localPosition; + } + }); + + /** + *设置世界旋转。 + *@param value 世界旋转。 + */ + /** + *获取世界旋转。 + *@return 世界旋转。 + */ + __getset(0,__proto,'rotation',function(){ + if (this._parent!==null){ + this.worldMatrix.decompose(this._position,this._rotation,this._scale); + }else { + this._localRotation.cloneTo(this._rotation); + } + return this._rotation; + },function(value){ + if (this._parent!==null){ + this._parent.rotation.invert(this._tempQuaternion0); + Quaternion.multiply(value,this._tempQuaternion0,this._localRotation); + this.localRotation=this._localRotation; + }else { + value.cloneTo(this._localRotation); + this.localRotation=this._localRotation; + } + }); + + /** + *设置局部空间的旋转角度。 + *@param value 欧拉角的旋转值,顺序为x、y、z。 + */ + __getset(0,__proto,'localRotationEuler',null,function(value){ + Quaternion.createFromYawPitchRoll(value.y,value.x,value.z,this._localRotation); + this._onLocalTransform(); + this._onWorldTransform(); + }); + + /** + *获取世界缩放。 + *@return 世界缩放。 + */ + __getset(0,__proto,'scale',function(){ + if (this._parent!==null){ + Vector3.multiply(this._parent.scale,this._localScale,this._scale); + }else { + this._localScale.cloneTo(this._scale); + } + return this._scale; + }); + + /** + *设置局部空间的旋转角度。 + *@param 欧拉角的旋转值,顺序为x、y、z。 + */ + __getset(0,__proto,'rotationEuler',null,function(value){ + Quaternion.createFromYawPitchRoll(value.y,value.x,value.z,this._rotation); + this.rotation=this._rotation; + }); + + /** + *获取向前方向。 + *@return 向前方向。 + */ + __getset(0,__proto,'forward',function(){ + var worldMatElem=this.worldMatrix.elements; + this._forward.elements[0]=-worldMatElem[8]; + this._forward.elements[1]=-worldMatElem[9]; + this._forward.elements[2]=-worldMatElem[10]; + return this._forward; + }); + + /** + *获取向上方向。 + *@return 向上方向。 + */ + __getset(0,__proto,'up',function(){ + var worldMatElem=this.worldMatrix.elements; + this._up.elements[0]=worldMatElem[4]; + this._up.elements[1]=worldMatElem[5]; + this._up.elements[2]=worldMatElem[6]; + return this._up; + }); + + /** + *获取向右方向。 + *@return 向右方向。 + */ + __getset(0,__proto,'right',function(){ + var worldMatElem=this.worldMatrix.elements; + this._right.elements[0]=worldMatElem[0]; + this._right.elements[1]=worldMatElem[1]; + this._right.elements[2]=worldMatElem[2]; + return this._right; + }); + + /** + *设置父3D变换。 + *@param value 父3D变换。 + */ + __getset(0,__proto,'parent',null,function(value){ + this._parent=value; + this._onWorldTransform(); + }); + + return Transform3D; + })(EventDispatcher) + + + /** + *TransformUV 类用于实现UV变换。 + */ + //class laya.d3.core.TransformUV extends laya.events.EventDispatcher + var TransformUV=(function(_super){ + function TransformUV(){ + this._rotation=0; + this._matNeedUpdte=false; + TransformUV.__super.call(this); + this._tempTitlingV3=new Vector3(); + this._tempRotationMatrix=new Matrix4x4(); + this._tempTitlingMatrix=new Matrix4x4(); + this._matrix=new Matrix4x4(); + this._offset=new Vector2(); + this._tiling=new Vector2(); + } + + __class(TransformUV,'laya.d3.core.TransformUV',_super); + var __proto=TransformUV.prototype; + /** + *@private + */ + __proto._updateMatrix=function(){ + this._tempTitlingV3.elements[0]=this._tiling.x; + this._tempTitlingV3.elements[1]=this._tiling.y; + this._tempTitlingV3.elements[2]=1; + Matrix4x4.createScaling(this._tempTitlingV3,this._tempTitlingMatrix); + Matrix4x4.createRotationZ(this._rotation,this._tempRotationMatrix); + Matrix4x4.multiply(this._tempRotationMatrix,this._tempTitlingMatrix,this._matrix); + var mate=this._matrix.elements; + mate[12]=this._offset.x; + mate[13]=this._offset.y; + mate[14]=0; + } + + /** + *获取变换矩阵。 + *@return 变换矩阵。 + */ + __getset(0,__proto,'matrix',function(){ + if (this._matNeedUpdte){ + this._updateMatrix(); + this._matNeedUpdte=false; + } + return this._matrix; + }); + + /** + *设置平铺次数。 + *@param value 平铺次数。 + */ + /** + *获取平铺次数。 + *@return 平铺次数。 + */ + __getset(0,__proto,'tiling',function(){ + return this._tiling; + },function(value){ + this._tiling=value; + this._matNeedUpdte=true; + }); + + /** + *设置偏移。 + *@param value 偏移。 + */ + /** + *获取偏移。 + *@return 偏移。 + */ + __getset(0,__proto,'offset',function(){ + return this._offset; + },function(value){ + this._offset=value; + this._matNeedUpdte=true; + }); + + /** + *设置旋转。 + *@param value 旋转。 + */ + /** + *获取旋转。 + *@return 旋转。 + */ + __getset(0,__proto,'rotation',function(){ + return this._rotation; + },function(value){ + this._rotation=value; + this._matNeedUpdte=true; + }); + + return TransformUV; + })(EventDispatcher) + + + /** + *@private + *GlitterTemplet 类用于创建闪光数据模板。 + */ + //class laya.d3.resource.tempelet.GlitterTemplet extends laya.events.EventDispatcher + var GlitterTemplet=(function(_super){ + function GlitterTemplet(owner){ + this._floatCountPerVertex=6; + this._owner=null; + this._vertices=null; + this._vertexBuffer=null; + this._firstActiveElement=0; + this._firstNewElement=0; + this._firstFreeElement=0; + this._firstRetiredElement=0; + this._currentTime=NaN; + this._drawCounter=0; + this.scLeft=null; + this.scRight=null; + this._numPositionMode=0; + this._numPositionVelocityMode=0; + this._lastTime=NaN; + this._needPatch=false; + this._lastPatchAddPos0=null; + this._lastPatchAddPos1=null; + this._lastPatchAddTime=NaN; + this.lifeTime=NaN; + this.minSegmentDistance=NaN; + this.minInterpDistance=NaN; + this.maxSlerpCount=0; + this.color=null; + this._maxSegments=0; + GlitterTemplet.__super.call(this); + this._tempVector0=new Vector3(); + this._tempVector1=new Vector3(); + this._tempVector2=new Vector3(); + this._tempVector3=new Vector3(); + this._albedo=new Vector4(1.0,1.0,1.0,1.0); + this._posModeLastPosition0=new Vector3(); + this._posModeLastPosition1=new Vector3(); + this._posModePosition0=new Vector3(); + this._posModePosition1=new Vector3(); + this._posVelModePosition0=new Vector3(); + this._posVelModeVelocity0=new Vector3(); + this._posVelModePosition1=new Vector3(); + this._posVelModeVelocity1=new Vector3(); + this._owner=owner; + this._lastTime=0 + this._firstActiveElement=0; + this._firstNewElement=0; + this._firstFreeElement=0; + this._firstRetiredElement=0; + this._currentTime=0; + this._drawCounter=0; + this._needPatch=false; + this._lastPatchAddPos0=new Vector3(); + this._lastPatchAddPos1=new Vector3(); + this.scLeft=new SplineCurvePositionVelocity(); + this.scRight=new SplineCurvePositionVelocity(); + this.lifeTime=0.5; + this.minSegmentDistance=0.1; + this.minInterpDistance=0.6; + this.maxSlerpCount=128; + this.color=new Vector4(1.0,1.0,1.0,1.0); + this._maxSegments=200; + this._owner.on(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onEnableChanged); + } + + __class(GlitterTemplet,'laya.d3.resource.tempelet.GlitterTemplet',_super); + var __proto=GlitterTemplet.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return null; + } + + /** + *@private + */ + __proto._initialize=function(){ + this._vertexBuffer=VertexBuffer3D.create(VertexGlitter.vertexDeclaration,this.maxSegments *2,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._vertices=new Float32Array(this.maxSegments *this._floatCountPerVertex *2); + } + + __proto._onEnableChanged=function(enable){ + if (!enable){ + this._numPositionMode=0; + this._numPositionVelocityMode=0; + this._firstActiveElement=0; + this._firstNewElement=0; + this._firstFreeElement=0; + this._firstRetiredElement=0; + this._currentTime=0; + this._drawCounter=0; + } + } + + /** + *@private + */ + __proto._updateTextureCoordinates=function(){ + if (this._firstActiveElement < this._firstFreeElement){ + this._updateSubTextureCoordinates(this._firstActiveElement,(this._firstFreeElement-this._firstActiveElement)*2); + }else { + this._updateSubTextureCoordinates(this._firstActiveElement,(this.maxSegments-this._firstActiveElement)*2); + if (this._firstFreeElement > 0) + this._updateSubTextureCoordinates(0,this._firstFreeElement *2); + } + } + + /** + *@private + */ + __proto._updateSubTextureCoordinates=function(start,count){ + var startOffset=start *2; + for (var i=0;i < count;i+=2){ + var vertexOffset=startOffset+i; + var upVertexOffset=vertexOffset *this._floatCountPerVertex; + var downVertexOffset=(vertexOffset+1)*this._floatCountPerVertex; + this._vertices[upVertexOffset+3]=this._vertices[downVertexOffset+3]=(this._vertices[upVertexOffset+5]-this._currentTime)/ this.lifeTime; + } + } + + /** + *@private + */ + __proto._retireActiveGlitter=function(){ + var particleDuration=this.lifeTime; + var _floatCountOneSegement=this._floatCountPerVertex *2; + while (this._firstActiveElement !=this._firstNewElement){ + var index=this._firstActiveElement *_floatCountOneSegement+5; + var particleAge=this._currentTime-this._vertices[index]; + if (particleAge < particleDuration) + break ; + this._vertices[index]=this._drawCounter; + this._firstActiveElement++; + if (this._firstActiveElement >=this.maxSegments) + this._firstActiveElement=0; + } + } + + /** + *@private + */ + __proto._freeRetiredGlitter=function(){ + var _floatCountOneSegement=this._floatCountPerVertex *2; + while (this._firstRetiredElement !=this._firstActiveElement){ + var age=this._drawCounter-this._vertices[this._firstRetiredElement *_floatCountOneSegement+5]; + if (age < 3) + break ; + this._firstRetiredElement++; + if (this._firstRetiredElement >=this.maxSegments) + this._firstRetiredElement=0; + } + } + + /** + *@private + */ + __proto._calcVelocity=function(left,right,out){ + Vector3.subtract(left,right,out); + Vector3.scale(out,0.5,out); + } + + /** + *@private + */ + __proto._addNewGlitterSegementToVertexBuffer=function(){ + var start=0; + if (this._firstActiveElement < this._firstFreeElement){ + start=this._firstActiveElement *2 *this._floatCountPerVertex; + this._vertexBuffer.setData(this._vertices,start,start,(this._firstFreeElement-this._firstActiveElement)*2 *this._floatCountPerVertex); + }else { + start=this._firstActiveElement *2 *this._floatCountPerVertex; + this._vertexBuffer.setData(this._vertices,start,start,(this.maxSegments-this._firstActiveElement)*2 *this._floatCountPerVertex); + if (this._firstFreeElement > 0){ + this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement *2 *this._floatCountPerVertex); + } + } + this._firstNewElement=this._firstFreeElement; + } + + /** + *@private + */ + __proto._addGlitter=function(position0,position1,time){ + if (this._needPatch){ + this._needPatch=false; + this._addGlitter(this._lastPatchAddPos0,this._lastPatchAddPos1,this._lastPatchAddTime); + }; + var nextFreeParticle=this._firstFreeElement+1; + if (nextFreeParticle >=this.maxSegments){ + nextFreeParticle=0; + position0.cloneTo(this._lastPatchAddPos0); + position1.cloneTo(this._lastPatchAddPos1); + this._lastPatchAddTime=time; + this._needPatch=true; + } + if (nextFreeParticle===this._firstRetiredElement) + throw new Error("GlitterTemplet:current segement count have large than maxSegments,please adjust the value of maxSegments or add Glitter Vertex Frequency."); + var position0e=position0.elements; + var position1e=position1.elements; + var j=0; + var positionIndex=this._firstFreeElement *this._floatCountPerVertex *2; + for (j=0;j < 3;j++) + this._vertices[positionIndex+j]=position0e[j]; + this._vertices[positionIndex+3]=0.0; + this._vertices[positionIndex+4]=0.0; + this._vertices[positionIndex+5]=time; + var nextPositionIndex=positionIndex+this._floatCountPerVertex; + for (j=0;j < 3;j++) + this._vertices[nextPositionIndex+j]=position1e[j]; + this._vertices[nextPositionIndex+3]=0.0; + this._vertices[nextPositionIndex+4]=1.0; + this._vertices[nextPositionIndex+5]=time; + this._firstFreeElement=nextFreeParticle; + } + + /** + *@private + *更新闪光。 + *@param elapsedTime 间隔时间 + */ + __proto._update=function(elapsedTime){ + this._currentTime+=elapsedTime / 1000; + this._retireActiveGlitter(); + this._freeRetiredGlitter(); + if (this._firstActiveElement==this._firstFreeElement) + this._currentTime=0; + if (this._firstRetiredElement==this._firstActiveElement) + this._drawCounter=0; + this._updateTextureCoordinates(); + } + + //实时更新纹理坐标 + __proto._beforeRender=function(state){ + if (this._firstNewElement !=this._firstFreeElement){ + this._addNewGlitterSegementToVertexBuffer(); + } + this._drawCounter++; + if (this._firstActiveElement !=this._firstFreeElement){ + this._vertexBuffer.bindWithIndexBuffer(null); + return true; + } + return false; + } + + /** + *@private + *渲染闪光。 + *@param state 相关渲染状态 + */ + __proto._render=function(state){ + var drawVertexCount=0; + var glContext=WebGL.mainContext; + if (this._firstActiveElement < this._firstFreeElement){ + drawVertexCount=(this._firstFreeElement-this._firstActiveElement)*2; + glContext.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,this._firstActiveElement *2,drawVertexCount); + Stat.trianglesFaces+=drawVertexCount-2; + Stat.drawCall++; + }else { + drawVertexCount=(this.maxSegments-this._firstActiveElement)*2; + glContext.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,this._firstActiveElement *2,drawVertexCount); + Stat.trianglesFaces+=drawVertexCount-2; + Stat.drawCall++; + if (this._firstFreeElement > 0){ + drawVertexCount=this._firstFreeElement *2; + glContext.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,0,drawVertexCount); + Stat.trianglesFaces+=drawVertexCount-2; + Stat.drawCall++; + } + } + } + + /** + *通过位置添加刀光。 + *@param position0 位置0。 + *@param position1 位置1。 + */ + __proto.addVertexPosition=function(position0,position1){ + if (this._owner.enable){ + if (this._numPositionMode < 2){ + if (this._numPositionMode===0){ + position0.cloneTo(this._posModeLastPosition0); + position1.cloneTo(this._posModeLastPosition1); + }else { + position0.cloneTo(this._posModePosition0); + position1.cloneTo(this._posModePosition1); + } + this._numPositionMode++; + }else { + var v0=this._tempVector2; + this._calcVelocity(position0,this._posModeLastPosition0,v0); + var v1=this._tempVector3; + this._calcVelocity(position1,this._posModeLastPosition1,v1); + this.addVertexPositionVelocity(this._posModePosition0,v0,this._posModePosition1,v1); + this._posModePosition0.cloneTo(this._posModeLastPosition0); + this._posModePosition1.cloneTo(this._posModeLastPosition1); + position0.cloneTo(this._posModePosition0); + position1.cloneTo(this._posModePosition1); + } + } + } + + /** + *通过位置和速度添加刀光。 + *@param position0 位置0。 + *@param velocity0 速度0。 + *@param position1 位置1。 + *@param velocity1 速度1。 + */ + __proto.addVertexPositionVelocity=function(position0,velocity0,position1,velocity1){ + if (this._owner.enable){ + if (this._numPositionVelocityMode===0){ + this._numPositionVelocityMode++; + }else { + var d=this._tempVector0; + Vector3.subtract(position0,this._posVelModePosition0,d); + var distance0=Vector3.scalarLength(d); + Vector3.subtract(position1,this._posVelModePosition1,d); + var distance1=Vector3.scalarLength(d); + var slerpCount=0; + var minSegmentDistance=minSegmentDistance; + if (distance0 < minSegmentDistance && distance1 < minSegmentDistance) + return; + slerpCount=1+Math.floor(Math.max(distance0,distance1)/ this.minInterpDistance); + if (slerpCount===1){ + this._addGlitter(position0,position1,this._currentTime); + }else { + slerpCount=Math.min(slerpCount,this.maxSlerpCount); + this.scLeft.Init(this._posVelModePosition0,this._posVelModeVelocity0,position0,velocity0); + this.scRight.Init(this._posVelModePosition1,this._posVelModeVelocity1,position1,velocity1); + var segment=1.0 / slerpCount; + var addSegment=segment; + var timeOffset=this._currentTime-this._lastTime; + for (var i=1;i <=slerpCount;i++){ + var pos0=this._tempVector0; + this.scLeft.Slerp(addSegment,pos0); + var pos1=this._tempVector1; + this.scRight.Slerp(addSegment,pos1); + var time=this._lastTime+timeOffset *i / slerpCount; + this._addGlitter(pos0,pos1,time); + addSegment+=segment; + } + } + } + this._lastTime=this._currentTime; + position0.cloneTo(this._posVelModePosition0); + velocity0.cloneTo(this._posVelModeVelocity0); + position1.cloneTo(this._posVelModePosition1); + velocity1.cloneTo(this._posVelModeVelocity1); + } + } + + __proto.dispose=function(){ + this._owner.off(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onEnableChanged); + } + + /**设置最大分段数,注意:谨慎修改此属性,有性能损耗。*/ + /**获取最大分段数。*/ + __getset(0,__proto,'maxSegments',function(){ + return this._maxSegments-1; + },function(value){ + var newMaxSegments=value+1; + if (newMaxSegments!==this._maxSegments){ + this._maxSegments=newMaxSegments; + if (this._vertexBuffer){ + this._vertexBuffer.dispose(); + } + this._initialize(); + } + }); + + __getset(0,__proto,'indexOfHost',function(){ + return 0; + }); + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'triangleCount',function(){ + var drawVertexCount=0; + if (this._firstActiveElement < this._firstFreeElement){ + drawVertexCount=(this._firstFreeElement-this._firstActiveElement)*2-2; + }else { + drawVertexCount=(this.maxSegments-this._firstActiveElement)*2-2; + drawVertexCount+=this._firstFreeElement *2-2; + } + return drawVertexCount; + }); + + return GlitterTemplet; + })(EventDispatcher) + + + /** + *EmitterBox 类用于盒发射器。 + */ + //class laya.d3.core.particle.EmitterBox extends laya.particle.emitter.EmitterBase + var EmitterBox=(function(_super){ + function EmitterBox(particle3D){ + this._settings=null; + this._particle3D=null; + EmitterBox.__super.call(this); + this._resultPosition=new Vector3(); + this._resultVelocity=new Vector3(); + this.centerPosition=new Vector3(); + this.size=new Vector3(); + this.velocity=new Vector3(); + this.velocityAddVariance=new Vector3(); + this._particle3D=particle3D; + var setting=particle3D.templet.settings; + for (var i=0;i < 3;i++){ + this.centerPosition.elements[i]=setting.boxEmitterCenterPosition[i]; + this.size.elements[i]=setting.boxEmitterSize[i]; + this.velocity.elements[i]=setting.boxEmitterVelocity[i]; + this.velocityAddVariance.elements[i]=setting.boxEmitterVelocityAddVariance[i]; + } + this.emissionRate=setting.emissionRate; + } + + __class(EmitterBox,'laya.d3.core.particle.EmitterBox',_super); + var __proto=EmitterBox.prototype; + /** + *@private + */ + __proto._randomPositionOnBox=function(){ + var rpe=this._resultPosition.elements; + var cpe=this.centerPosition.elements; + var se=this.size.elements; + rpe[0]=cpe[0]+se[0] *(Math.random()-0.5); + rpe[1]=cpe[1]+se[1] *(Math.random()-0.5); + rpe[2]=cpe[2]+se[2] *(Math.random()-0.5); + return this._resultPosition; + } + + /** + *@private + */ + __proto._randomVelocityOnBox=function(){ + var rve=this._resultVelocity.elements; + var ve=this.velocity.elements; + var vve=this.velocityAddVariance.elements; + rve[0]=ve[0]+vve[0] *Math.random(); + rve[1]=ve[1]+vve[1] *Math.random(); + rve[2]=ve[2]+vve[2] *Math.random(); + return this._resultVelocity; + } + + /** + *盒发射器发射函数。 + */ + __proto.emit=function(){ + _super.prototype.emit.call(this); + this._particle3D.templet.addParticle(this._randomPositionOnBox(),this._randomVelocityOnBox()); + } + + /** + *更新盒粒子发射器。 + *@param state 渲染相关状态参数。 + */ + __proto.update=function(state){ + this.advanceTime(state.elapsedTime / 1000); + } + + return EmitterBox; + })(EmitterBase) + + + /** + *EmitterPoint 类用于点发射器。 + */ + //class laya.d3.core.particle.EmitterPoint extends laya.particle.emitter.EmitterBase + var EmitterPoint=(function(_super){ + function EmitterPoint(particle3D){ + this._settings=null; + this._particle3D=null; + EmitterPoint.__super.call(this); + this._resultPosition=new Vector3(); + this._resultVelocity=new Vector3(); + this.position=new Vector3(); + this.positionVariance=new Vector3(); + this.velocity=new Vector3(); + this.velocityAddVariance=new Vector3(); + this._particle3D=particle3D; + var setting=particle3D.templet.settings; + for (var i=0;i < 3;i++){ + this.position.elements[i]=setting.pointEmitterPosition[i]; + this.positionVariance.elements[i]=setting.pointEmitterPositionVariance[i]; + this.velocity.elements[i]=setting.pointEmitterVelocity[i]; + this.velocityAddVariance.elements[i]=setting.pointEmitterVelocityAddVariance[i]; + } + this.emissionRate=setting.emissionRate; + } + + __class(EmitterPoint,'laya.d3.core.particle.EmitterPoint',_super); + var __proto=EmitterPoint.prototype; + /** + *@private + */ + __proto._randomPositionOnPoint=function(){ + var rpe=this._resultPosition.elements; + var pe=this.position.elements; + var pve=this.positionVariance.elements; + rpe[0]=pe[0]+pve[0] *(Math.random()-0.5)*2; + rpe[1]=pe[1]+pve[1] *(Math.random()-0.5)*2; + rpe[2]=pe[2]+pve[2] *(Math.random()-0.5)*2; + return this._resultPosition; + } + + /** + *@private + */ + __proto._randomVelocityOnPoint=function(){ + var rve=this._resultVelocity.elements; + var ve=this.velocity.elements; + var vve=this.velocityAddVariance.elements; + rve[0]=ve[0]+vve[0] *Math.random(); + rve[1]=ve[1]+vve[1] *Math.random(); + rve[2]=ve[2]+vve[2] *Math.random(); + return this._resultVelocity; + } + + /** + *点发射器发射函数。 + */ + __proto.emit=function(){ + _super.prototype.emit.call(this); + this._particle3D.templet.addParticle(this._randomPositionOnPoint(),this._randomVelocityOnPoint()); + } + + /** + *更新点粒子发射器。 + *@param state 渲染相关状态参数。 + */ + __proto.update=function(state){ + this.advanceTime(state.elapsedTime / 1000); + } + + return EmitterPoint; + })(EmitterBase) + + + /** + *EmitterRing 类用于环发射器。 + */ + //class laya.d3.core.particle.EmitterRing extends laya.particle.emitter.EmitterBase + var EmitterRing=(function(_super){ + function EmitterRing(particle3D){ + this._settings=null; + this._particle3D=null; + this.radius=30; + this.velocity=0; + this.velocityAddVariance=0; + this.up=2; + EmitterRing.__super.call(this); + this._resultPosition=new Vector3(); + this._resultVelocity=new Vector3(); + this._direction=new Vector3(); + this.centerPosition=new Vector3(); + this._particle3D=particle3D; + var setting=particle3D.templet.settings; + for (var i=0;i < 3;i++){ + this.centerPosition.elements[i]=setting.ringEmitterCenterPosition[i]; + } + this.radius=setting.ringEmitterRadius + this.velocity=setting.ringEmitterVelocity + this.velocityAddVariance=setting.ringEmitterVelocityAddVariance + this.emissionRate=setting.emissionRate; + } + + __class(EmitterRing,'laya.d3.core.particle.EmitterRing',_super); + var __proto=EmitterRing.prototype; + /** + *@private + */ + __proto._randomPointOnRing=function(){ + var angle=Math.random()*Math.PI *2; + var x=Math.cos(angle); + var y=Math.sin(angle); + var rpe=this._resultPosition.elements; + var cpe=this.centerPosition.elements; + switch (this.up){ + case 0: + rpe[0]=cpe[0]+0; + rpe[1]=cpe[1]+x *this.radius; + rpe[2]=cpe[2]+y *this.radius; + break ; + case 1: + rpe[0]=cpe[0]+x *this.radius; + rpe[1]=cpe[1]+0; + rpe[2]=cpe[2]+y *this.radius; + break ; + case 2: + rpe[0]=cpe[0]+x *this.radius; + rpe[1]=cpe[1]+y *this.radius; + rpe[2]=cpe[2]+0; + break ; + } + return this._resultPosition; + } + + /** + *@private + */ + __proto._randomVelocityOnRing=function(){ + var rve=this._resultVelocity.elements; + this._resultPosition.cloneTo(this._direction); + Vector3.normalize(this._direction,this._direction); + var de=this._direction.elements; + rve[0]=de[0] *(this.velocity+this.velocityAddVariance *Math.random()); + rve[1]=de[1] *(this.velocity+this.velocityAddVariance *Math.random()); + rve[2]=de[2] *(this.velocity+this.velocityAddVariance *Math.random()); + return this._resultVelocity; + } + + /** + *环发射器发射函数。 + */ + __proto.emit=function(){ + _super.prototype.emit.call(this); + this._particle3D.templet.addParticle(this._randomPointOnRing(),this._randomVelocityOnRing()); + } + + /** + *更新环粒子发射器。 + *@param state 渲染相关状态参数。 + */ + __proto.update=function(elapsedTime){ + this.advanceTime(elapsedTime / 1000); + } + + return EmitterRing; + })(EmitterBase) + + + /** + *EmitterSphere 类用于球发射器。 + */ + //class laya.d3.core.particle.EmitterSphere extends laya.particle.emitter.EmitterBase + var EmitterSphere=(function(_super){ + function EmitterSphere(particle3D){ + this._settings=null; + this._particle3D=null; + this.radius=1; + this.velocity=0; + this.velocityAddVariance=0; + EmitterSphere.__super.call(this); + this._reultPosition=new Vector3(); + this._resultVelocity=new Vector3(); + this._direction=new Vector3(); + this.centerPosition=new Vector3(); + this._particle3D=particle3D; + var setting=particle3D.templet.settings; + for (var i=0;i < 3;i++){ + this.centerPosition.elements[i]=setting.sphereEmitterCenterPosition[i]; + } + this.radius=setting.sphereEmitterRadius + this.velocity=setting.sphereEmitterVelocity + this.velocityAddVariance=setting.sphereEmitterVelocityAddVariance + this.emissionRate=setting.emissionRate; + } + + __class(EmitterSphere,'laya.d3.core.particle.EmitterSphere',_super); + var __proto=EmitterSphere.prototype; + /** + *@private + */ + __proto._randomPositionOnSphere=function(){ + var angleVer=Math.random()*Math.PI *2; + var angleHor=Math.random()*Math.PI *2; + var r=Math.cos(angleVer)*this.radius; + var y=Math.sin(angleVer)*this.radius; + var x=Math.cos(angleHor)*r; + var z=Math.sin(angleHor)*r; + var rpe=this._reultPosition.elements; + var cpe=this.centerPosition.elements; + rpe[0]=cpe[0]+x; + rpe[1]=cpe[1]+y; + rpe[2]=cpe[2]+z; + return this._reultPosition; + } + + /** + *@private + */ + __proto._randomVelocityOnSphere=function(){ + var rve=this._resultVelocity.elements; + this._reultPosition.cloneTo(this._direction); + Vector3.normalize(this._direction,this._direction); + var de=this._direction.elements; + rve[0]=de[0] *(this.velocity+this.velocityAddVariance *Math.random()); + rve[1]=de[1] *(this.velocity+this.velocityAddVariance *Math.random()); + rve[2]=de[2] *(this.velocity+this.velocityAddVariance *Math.random()); + return this._resultVelocity; + } + + /** + *球发射器发射函数。 + */ + __proto.emit=function(){ + _super.prototype.emit.call(this); + this._particle3D.templet.addParticle(this._randomPositionOnSphere(),this._randomVelocityOnSphere()); + } + + /** + *更新球粒子发射器。 + *@param state 渲染相关状态参数。 + */ + __proto.update=function(state){ + this.advanceTime(state.elapsedTime / 1000); + } + + return EmitterSphere; + })(EmitterBase) + + + /** + *SplineCurvePosition 类用于通过顶点创建闪光插值。 + */ + //class laya.d3.core.glitter.SplineCurvePosition extends laya.d3.core.glitter.SplineCurvePositionVelocity + var SplineCurvePosition=(function(_super){ + /** + *创建一个 SplineCurvePosition 实例。 + */ + function SplineCurvePosition(){ + SplineCurvePosition.__super.call(this); + } + + __class(SplineCurvePosition,'laya.d3.core.glitter.SplineCurvePosition',_super); + var __proto=SplineCurvePosition.prototype; + /** + *@private + *计算速度。 + */ + __proto._CalcVelocity=function(left,right,out){ + Vector3.subtract(left,right,out); + Vector3.scale(out,0.5,out); + } + + /** + *初始化插值所需信息。 + *@param lastPosition0 顶点0的上次位置。 + *@param position0 顶点0的位置。 + *@param lastPosition1 顶点1的上次位置。 + *@param position1 顶点1的位置。 + */ + __proto.Init=function(lastPosition0,position0,lastPosition1,position1){ + this._CalcVelocity(position0,lastPosition0,this._tempVector30); + this._CalcVelocity(position1,lastPosition1,this._tempVector31); + _super.prototype.Init.call(this,position0,this._tempVector30,position1,this._tempVector31); + } + + return SplineCurvePosition; + })(SplineCurvePositionVelocity) + + + /** + *@private + *ShaderDefines3D 类用于创建3DshaderDefine相关。 + */ + //class laya.d3.shader.ShaderDefines3D extends laya.webgl.shader.ShaderDefines + var ShaderDefines3D=(function(_super){ + function ShaderDefines3D(){ + ShaderDefines3D.__super.call(this,ShaderDefines3D._name2int,ShaderDefines3D._int2name,ShaderDefines3D._int2nameMap); + } + + __class(ShaderDefines3D,'laya.d3.shader.ShaderDefines3D',_super); + ShaderDefines3D.__init__=function(){ + ShaderDefines3D.reg("FSHIGHPRECISION",0x80); + ShaderDefines3D.reg("DIFFUSEMAP",0x1); + ShaderDefines3D.reg("NORMALMAP",0x2); + ShaderDefines3D.reg("SPECULARMAP",0x4); + ShaderDefines3D.reg("EMISSIVEMAP",0x8); + ShaderDefines3D.reg("AMBIENTMAP",0x10); + ShaderDefines3D.reg("REFLECTMAP",0x20); + ShaderDefines3D.reg("PARTICLE3D",0x40000); + ShaderDefines3D.reg("COLOR",0x800); + ShaderDefines3D.reg("UV",0x400); + ShaderDefines3D.reg("SKINNED",0x10000); + ShaderDefines3D.reg("DIRECTIONLIGHT",0x1000); + ShaderDefines3D.reg("POINTLIGHT",0x2000); + ShaderDefines3D.reg("SPOTLIGHT",0x4000); + ShaderDefines3D.reg("BONE",0x8000); + ShaderDefines3D.reg("ALPHATEST",0x20000); + ShaderDefines3D.reg("UVTRANSFORM",0x100); + ShaderDefines3D.reg("FOG",0x200); + ShaderDefines3D.reg("VR",0x40); + ShaderDefines3D.reg("SPHERHBILLBOARD",0x80000); + ShaderDefines3D.reg("STRETCHEDBILLBOARD",0x100000); + ShaderDefines3D.reg("HORIZONTALBILLBOARD",0x200000); + ShaderDefines3D.reg("VERTICALBILLBOARD",0x400000); + ShaderDefines3D.reg("COLOROVERLIFETIME",0x800000); + ShaderDefines3D.reg("RANDOMCOLOROVERLIFETIME",0x1000000); + ShaderDefines3D.reg("SIZEOVERLIFETIME",0x2000000); + ShaderDefines3D.reg("ROTATIONOVERLIFETIME",0x4000000); + ShaderDefines3D.reg("TEXTURESHEETANIMATION",0x8000000); + ShaderDefines3D.reg("VELOCITYOVERLIFETIME",0x10000000); + } + + ShaderDefines3D.reg=function(name,value){ + ShaderDefines._reg(name,value,ShaderDefines3D._name2int,ShaderDefines3D._int2name); + } + + ShaderDefines3D.toText=function(value,_int2name,_int2nameMap){ + return ShaderDefines._toText(value,_int2name,_int2nameMap); + } + + ShaderDefines3D.toInt=function(names){ + return ShaderDefines._toInt(names,ShaderDefines3D._name2int); + } + + ShaderDefines3D.FSHIGHPRECISION=0x80; + ShaderDefines3D.VR=0x40; + ShaderDefines3D.FOG=0x200; + ShaderDefines3D.DIRECTIONLIGHT=0x1000; + ShaderDefines3D.POINTLIGHT=0x2000; + ShaderDefines3D.SPOTLIGHT=0x4000; + ShaderDefines3D.DIFFUSEMAP=0x1; + ShaderDefines3D.NORMALMAP=0x2; + ShaderDefines3D.SPECULARMAP=0x4; + ShaderDefines3D.EMISSIVEMAP=0x8; + ShaderDefines3D.AMBIENTMAP=0x10; + ShaderDefines3D.REFLECTMAP=0x20; + ShaderDefines3D.UVTRANSFORM=0x100; + ShaderDefines3D.UV=0x400; + ShaderDefines3D.COLOR=0x800; + ShaderDefines3D.BONE=0x8000; + ShaderDefines3D.SKINNED=0x10000; + ShaderDefines3D.ALPHATEST=0x20000; + ShaderDefines3D.PARTICLE3D=0x40000; + ShaderDefines3D.SPHERHBILLBOARD=0x80000; + ShaderDefines3D.STRETCHEDBILLBOARD=0x100000; + ShaderDefines3D.HORIZONTALBILLBOARD=0x200000; + ShaderDefines3D.VERTICALBILLBOARD=0x400000; + ShaderDefines3D.COLOROVERLIFETIME=0x800000; + ShaderDefines3D.RANDOMCOLOROVERLIFETIME=0x1000000; + ShaderDefines3D.SIZEOVERLIFETIME=0x2000000; + ShaderDefines3D.ROTATIONOVERLIFETIME=0x4000000; + ShaderDefines3D.TEXTURESHEETANIMATION=0x8000000; + ShaderDefines3D.VELOCITYOVERLIFETIME=0x10000000; + ShaderDefines3D._name2int={}; + ShaderDefines3D._int2name=[]; + ShaderDefines3D._int2nameMap=[]; + return ShaderDefines3D; + })(ShaderDefines) + + + /** + *BoxShape 类用于创建球形粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.BoxShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape + var BoxShape=(function(_super){ + function BoxShape(){ + this.x=NaN; + this.y=NaN; + this.z=NaN; + this.randomDirection=false; + BoxShape.__super.call(this); + this.x=1.0; + this.y=1.0; + this.z=1.0; + this.randomDirection=false; + } + + __class(BoxShape,'laya.d3.core.particleShuriKen.module.shape.BoxShape',_super); + var __proto=BoxShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + var rpE=position.elements; + var rdE=direction.elements; + ShapeUtils._randomPointInsideHalfUnitBox(position); + rpE[0]=this.x *rpE[0]; + rpE[1]=this.y *rpE[1]; + rpE[2]=this.z *rpE[2]; + if (this.randomDirection){ + ShapeUtils._randomPointUnitSphere(direction); + }else { + rdE[0]=0.0; + rdE[1]=0.0; + rdE[2]=-1.0; + } + } + + return BoxShape; + })(BaseShape) + + + /** + *CircleShape 类用于创建环形粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.CircleShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape + var CircleShape=(function(_super){ + function CircleShape(){ + this.radius=NaN; + this.arc=NaN; + this.emitFromEdge=false; + this.randomDirection=false; + CircleShape.__super.call(this); + this.radius=1.0; + this.arc=360.0 / 180.0 *Math.PI; + this.emitFromEdge=false; + this.randomDirection=false; + } + + __class(CircleShape,'laya.d3.core.particleShuriKen.module.shape.CircleShape',_super); + var __proto=CircleShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + var rpE=position.elements; + var positionPointE=CircleShape._tempPositionPoint.elements; + if (this.emitFromEdge) + ShapeUtils._randomPointUnitArcCircle(this.arc,CircleShape._tempPositionPoint); + else + ShapeUtils._randomPointInsideUnitArcCircle(this.arc,CircleShape._tempPositionPoint); + rpE[0]=positionPointE[0]; + rpE[1]=positionPointE[1]; + rpE[2]=0; + Vector3.scale(position,this.radius,position); + if (this.randomDirection){ + ShapeUtils._randomPointUnitSphere(direction); + }else { + position.cloneTo(direction); + } + } + + __static(CircleShape, + ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();} + ]); + return CircleShape; + })(BaseShape) + + + /** + *ConeShape 类用于创建锥形粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.ConeShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape + var ConeShape=(function(_super){ + function ConeShape(){ + this.angle=NaN; + this.radius=NaN; + this.length=NaN; + this.emitType=0; + this.randomDirection=false; + ConeShape.__super.call(this); + this.angle=25.0 / 180.0 *Math.PI; + this.radius=1.0; + this.length=5.0; + this.emitType=0; + this.randomDirection=false; + } + + __class(ConeShape,'laya.d3.core.particleShuriKen.module.shape.ConeShape',_super); + var __proto=ConeShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + var rpE=position.elements; + var rdE=direction.elements; + var positionPointE=ConeShape._tempPositionPoint.elements; + var positionX=NaN; + var positionY=NaN; + var directionPointE; + var dirCosA=Math.cos(this.angle); + var dirSinA=Math.sin(this.angle); + switch (this.emitType){ + case 0: + ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint); + positionX=positionPointE[0]; + positionY=positionPointE[1]; + rpE[0]=positionX *this.radius; + rpE[1]=positionY *this.radius; + rpE[2]=0; + if (this.randomDirection){ + ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint); + directionPointE=ConeShape._tempDirectionPoint.elements; + rdE[0]=directionPointE[0] *dirSinA; + rdE[1]=directionPointE[1] *dirSinA; + }else { + rdE[0]=positionX *dirSinA; + rdE[1]=positionY *dirSinA; + } + rdE[2]=-dirCosA; + break ; + case 1: + ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint); + positionX=positionPointE[0]; + positionY=positionPointE[1]; + rpE[0]=positionX *this.radius; + rpE[1]=positionY *this.radius; + rpE[2]=0; + if (this.randomDirection){ + ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint); + directionPointE=ConeShape._tempDirectionPoint.elements; + rdE[0]=directionPointE[0] *dirSinA; + rdE[1]=directionPointE[1] *dirSinA; + }else { + rdE[0]=positionX *dirSinA; + rdE[1]=positionY *dirSinA; + } + rdE[2]=-dirCosA; + break ; + case 2: + ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint); + positionX=positionPointE[0]; + positionY=positionPointE[1]; + rpE[0]=positionX *this.radius; + rpE[1]=positionY *this.radius; + rpE[2]=0; + rdE[0]=positionX *dirSinA; + rdE[1]=positionY *dirSinA; + rdE[2]=-dirCosA; + Vector3.normalize(direction,direction); + Vector3.scale(direction,this.length *Math.random(),direction); + Vector3.add(position,direction,position); + if (this.randomDirection) + ShapeUtils._randomPointUnitSphere(direction); + break ; + case 3: + ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint); + positionX=positionPointE[0]; + positionY=positionPointE[1]; + rpE[0]=positionX *this.radius; + rpE[1]=positionY *this.radius; + rpE[2]=0; + rdE[0]=positionX *dirSinA; + rdE[1]=positionY *dirSinA; + rdE[2]=-dirCosA; + Vector3.normalize(direction,direction); + Vector3.scale(direction,this.length *Math.random(),direction); + Vector3.add(position,direction,position); + if (this.randomDirection) + ShapeUtils._randomPointUnitSphere(direction); + break ; + default : + throw new Error("ConeShape:emitType is invalid."); + } + } + + __static(ConeShape, + ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();},'_tempDirectionPoint',function(){return this._tempDirectionPoint=new Vector2();} + ]); + return ConeShape; + })(BaseShape) + + + /** + *HemisphereShape 类用于创建半球形粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.HemisphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape + var HemisphereShape=(function(_super){ + function HemisphereShape(){ + this.radius=NaN; + this.emitFromShell=false; + this.randomDirection=false; + HemisphereShape.__super.call(this); + this.radius=1.0; + this.emitFromShell=false; + this.randomDirection=false; + } + + __class(HemisphereShape,'laya.d3.core.particleShuriKen.module.shape.HemisphereShape',_super); + var __proto=HemisphereShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + var rpE=position.elements; + if (this.emitFromShell) + ShapeUtils._randomPointUnitSphere(position); + else + ShapeUtils._randomPointInsideUnitSphere(position); + Vector3.scale(position,this.radius,position); + var z=rpE[2]; + (z > 0.0)&& (rpE[2]=z *-1.0); + if (this.randomDirection){ + ShapeUtils._randomPointUnitSphere(direction); + }else { + position.cloneTo(direction); + } + } + + return HemisphereShape; + })(BaseShape) + + + /** + *SphereShape 类用于创建球形粒子形状。 + */ + //class laya.d3.core.particleShuriKen.module.shape.SphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape + var SphereShape=(function(_super){ + function SphereShape(){ + this.radius=NaN; + this.emitFromShell=false; + this.randomDirection=false; + SphereShape.__super.call(this); + this.radius=1.0; + this.emitFromShell=false; + this.randomDirection=false; + } + + __class(SphereShape,'laya.d3.core.particleShuriKen.module.shape.SphereShape',_super); + var __proto=SphereShape.prototype; + /** + *用于生成粒子初始位置和方向。 + *@param position 粒子位置。 + *@param direction 粒子方向。 + */ + __proto.generatePositionAndDirection=function(position,direction){ + if (this.emitFromShell) + ShapeUtils._randomPointUnitSphere(position); + else + ShapeUtils._randomPointInsideUnitSphere(position); + Vector3.scale(position,this.radius,position); + if (this.randomDirection){ + ShapeUtils._randomPointUnitSphere(direction); + }else { + position.cloneTo(direction); + } + } + + return SphereShape; + })(BaseShape) + + + /** + *Sprite3D 类用于实现3D精灵。 + */ + //class laya.d3.core.Sprite3D extends laya.display.Node + var Sprite3D=(function(_super){ + function Sprite3D(name){ + this._id=0; + this._enable=false; + this._layerMask=0; + this._componentsMap=[]; + this.transform=null; + this.isStatic=false; + Sprite3D.__super.call(this); + this._components=[]; + (name)? (this.name=name):(this.name="Sprite3D-"+Sprite3D._nameNumberCounter++); + this._enable=true; + this._id=++Sprite3D._uniqueIDCounter; + this.layer=Layer.currentCreationLayer; + this.transform=new Transform3D(this); + this.on(/*laya.events.Event.DISPLAY*/"display",this,this._onDisplay); + this.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onUnDisplay); + } + + __class(Sprite3D,'laya.d3.core.Sprite3D',_super); + var __proto=Sprite3D.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IUpdate":true,"laya.resource.ICreateResource":true,"laya.d3.core.IClone":true}) + /** + *@private + */ + __proto._onDisplay=function(){ + this.transform.parent=(this._parent).transform; + this._addSelfRenderObjects(); + } + + /** + *@private + */ + __proto._onUnDisplay=function(){ + this.transform.parent=null; + this._clearSelfRenderObjects(); + } + + /** + *清理自身渲染物体,请重载此函数。 + */ + __proto._clearSelfRenderObjects=function(){} + /** + *添加自身渲染物体,请重载此函数。 + */ + __proto._addSelfRenderObjects=function(){} + /** + *更新组件update函数。 + *@param state 渲染相关状态。 + */ + __proto._updateComponents=function(state){ + for (var i=0,n=this._components.length;i < n;i++){ + var component=this._components[i]; + (!component.started)&& (component._start(state),component.started=true); + (component.isActive)&& (component._update(state)); + } + } + + /** + *更新组件lateUpdate函数。 + *@param state 渲染相关状态。 + */ + __proto._lateUpdateComponents=function(state){ + for (var i=0;i < this._components.length;i++){ + var component=this._components[i]; + (!component.started)&& (component._start(state),component.started=true); + (component.isActive)&& (component._lateUpdate(state)); + } + } + + /** + *更新子节点。 + *@param state 渲染相关状态。 + */ + __proto._updateChilds=function(state){ + var n=this._childs.length; + if (n===0)return; + for (var i=0;i < n;++i) + this._childs[i]._update((state)); + } + + /** + *排序函数。 + *@param state 渲染相关状态。 + */ + __proto._getSortID=function(renderElement,material){ + return renderElement._getVertexBuffer().vertexDeclaration.id+material.id */*laya.d3.graphics.VertexDeclaration._maxVertexDeclarationBit*/1000; + } + + /** + *更新 + *@param state 渲染相关状态 + */ + __proto._update=function(state){ + state.owner=this; + if (this._enable){ + this._updateComponents(state); + this._lateUpdateComponents(state); + } + Stat.spriteCount++; + this._childs.length && this._updateChilds(state); + } + + /** + *加载层级文件,并作为该节点的子节点。 + *@param url + */ + __proto.loadHierarchy=function(url){ + this.addChild(laya.d3.core.Sprite3D.load(url)); + } + + __proto.addChildAt=function(node,index){ + if (!((node instanceof laya.d3.core.Sprite3D ))) + throw new Error("Sprite3D:Node type must Sprite3D."); + return _super.prototype.addChildAt.call(this,node,index); + } + + __proto.addChild=function(node){ + if (!((node instanceof laya.d3.core.Sprite3D ))) + throw new Error("Sprite3D:Node type must Sprite3D."); + return _super.prototype.addChild.call(this,node); + } + + /** + *添加指定类型组件。 + *@param type 组件类型。 + *@return 组件。 + */ + __proto.addComponent=function(type){ + if (this._componentsMap.indexOf(type)!==-1) + throw new Error("无法创建"+type+"组件"+","+type+"组件已存在!"); + var component=ClassUtils.getInstance(type); + component._initialize(this); + this._componentsMap.push(type); + this._components.push(component); + this.event(/*laya.events.Event.COMPONENT_ADDED*/"componentadded",component); + return component; + } + + /** + *获得指定类型组件。 + *@param type 组件类型。 + *@return 组件。 + */ + __proto.getComponentByType=function(type){ + var index=this._componentsMap.indexOf(type); + if (index===-1) + return null; + return this._components[index]; + } + + /** + *获得指定类型组件。 + *@param type 组件类型。 + *@return 组件。 + */ + __proto.getComponentByIndex=function(index){ + return this._components[index]; + } + + /** + *移除指定类型组件。 + *@param type 组件类型。 + */ + __proto.removeComponent=function(type){ + var index=this._componentsMap.indexOf(type); + if (index===-1) + return; + var component=this._components[index]; + this._components.splice(index,1); + this._componentsMap.splice(index,1); + component._uninitialize(); + this.event(/*laya.events.Event.COMPONENT_REMOVED*/"componentremoved",component); + } + + /** + *移除全部组件。 + */ + __proto.removeAllComponent=function(){ + for (var component in this._componentsMap) + this.removeComponent(component); + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + var oriData=data[0]; + var innerResouMap=data[1]; + ClassUtils.createByJson(oriData,this,this,Handler.create(null,Utils3D._parseHierarchyProp,[innerResouMap],false),Handler.create(null,Utils3D._parseHierarchyNode,null,false)); + this.event(/*laya.events.Event.HIERARCHY_LOADED*/"hierarchyloaded",[this]); + } + + __proto.cloneTo=function(destObject){ + var destSprite3D=destObject; + destSprite3D.name=this.name; + destSprite3D.destroyed=this.destroyed; + destSprite3D.timer=this.timer; + destSprite3D._displayedInStage=this._displayedInStage; + destSprite3D._$P=this._$P; + destSprite3D._enable=this._enable; + destSprite3D._layerMask=this._layerMask; + var destLocalMatrix=destSprite3D.transform.localMatrix; + this.transform.localMatrix.cloneTo(destLocalMatrix); + destSprite3D.transform.localMatrix=destLocalMatrix; + destSprite3D.isStatic=this.isStatic; + var i=0,n=0; + for (i=0,n=this._componentsMap.length;i < n;i++) + destSprite3D.addComponent(this._componentsMap[i]); + for (i=0,n=this._childs.length;i < n;i++) + destSprite3D.addChild(this._childs[i].clone()); + } + + __proto.clone=function(){ + var destSprite3D=/*__JS__ */new this.constructor(); + this.cloneTo(destSprite3D); + return destSprite3D; + } + + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + for (var i=0,n=this._components.length;i < n;i++) + this._components[i]._uninitialize(); + this._components=null; + this._componentsMap=null; + this.transform=null; + } + + /** + *获得组件的数量。 + *@return 组件数量。 + */ + __getset(0,__proto,'componentsCount',function(){ + return this._components.length; + }); + + /** + *获取唯一标识ID。 + *@return 唯一标识ID。 + */ + __getset(0,__proto,'id',function(){ + return this._id; + }); + + /** + *设置蒙版。 + *@param value 蒙版。 + */ + /** + *获取蒙版。 + *@return 蒙版。 + */ + __getset(0,__proto,'layer',function(){ + return Layer.getLayerByMask(this._layerMask); + },function(value){ + this._layerMask=value.mask; + this.event(/*laya.events.Event.LAYER_CHANGED*/"layerchanged",value); + }); + + /** + *设置是否启用。 + *@param value 是否启动。 + */ + /** + *获取是否启用。 + *@return 是否激活。 + */ + __getset(0,__proto,'enable',function(){ + return this._enable; + },function(value){ + if (this._enable!==value){ + this._enable=value; + this.event(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this._enable); + } + }); + + /** + *获取是否激活。 + *@return 是否激活。 + */ + __getset(0,__proto,'active',function(){ + return Layer.isActive(this._layerMask)&& this._enable; + }); + + /** + *获取是否显示。 + *@return 是否显示。 + */ + __getset(0,__proto,'visible',function(){ + return Layer.isVisible(this._layerMask)&& this._enable; + }); + + /** + *获得所属场景。 + *@return 场景。 + */ + __getset(0,__proto,'scene',function(){ + return this.parent ? (this.parent).scene :null; + }); + + Sprite3D.instantiate=function(original,position,rotation,parent,worldPositionStays){ + (worldPositionStays===void 0)&& (worldPositionStays=true); + var destSprite3D=original.clone(); + var transform; + if (position || rotation){ + (parent)&& (parent.addChild(destSprite3D)); + transform=destSprite3D.transform; + (position)&& (transform.position=position); + (rotation)&& (transform.rotation=rotation); + }else { + if (worldPositionStays){ + transform=destSprite3D.transform; + if (parent){ + var oriPosition=transform.position; + var oriRotation=transform.rotation; + parent.addChild(destSprite3D); + transform.position=oriPosition; + transform.rotation=oriRotation; + } + }else { + if (parent){ + parent.addChild(destSprite3D); + } + } + } + return destSprite3D; + } + + Sprite3D.load=function(url){ + return Laya.loader.create(url,null,null,Sprite3D,1,false); + } + + Sprite3D._uniqueIDCounter=0; + Sprite3D._nameNumberCounter=0; + return Sprite3D; + })(Node) + + + /** + *BaseMaterial 类用于创建材质,抽象类,不允许实例。 + */ + //class laya.d3.core.material.BaseMaterial extends laya.resource.Resource + var BaseMaterial=(function(_super){ + function BaseMaterial(){ + this._renderQueue=0; + this._renderMode=0; + this._sharderNameID=0; + this._shaderDefineValue=0; + this._disableShaderDefineValue=0; + this._shaderValues=null; + this._textureSharderIndices=null; + this._colorSharderIndices=null; + this._numberSharderIndices=null; + this._matrix4x4SharderIndices=null; + this._textures=null; + this._colors=null; + this._numbers=null; + this._matrix4x4s=null; + this._isInstance=false; + this.shader=null; + BaseMaterial.__super.call(this); + this._loaded=true; + this._isInstance=false; + this._shaderDefineValue=0; + this._disableShaderDefineValue=0; + this._shaderValues=new ValusArray(); + this._textures=[]; + this._colors=[]; + this._numbers=[]; + this._matrix4x4s=[]; + this._textureSharderIndices=[]; + this._colorSharderIndices=[]; + this._numberSharderIndices=[]; + this._matrix4x4SharderIndices=[]; + this.renderMode=1; + } + + __class(BaseMaterial,'laya.d3.core.material.BaseMaterial',_super); + var __proto=BaseMaterial.prototype; + Laya.imps(__proto,{"laya.d3.core.IClone":true}) + /** + *@private + */ + __proto._uploadTextures=function(){ + for (var i=0,n=this._textures.length;i < n;i++){ + var texture=this._textures[i]; + if (texture){ + var source=texture.source; + (source)? this._uploadTexture(i,source):this._uploadTexture(i,SolidColorTexture2D.grayTexture.source); + } + } + } + + /** + *获取Shader。 + *@param state 相关渲染状态。 + *@return Shader。 + */ + __proto._getShader=function(stateShaderDefines,vertexShaderDefineValue){ + var defineValue=stateShaderDefines._value | vertexShaderDefineValue | this._shaderDefineValue; + this._disableShaderDefineValue && (defineValue=defineValue & (~this._disableShaderDefineValue)); + stateShaderDefines._value=defineValue; + var nameID=defineValue+this._sharderNameID */*laya.webgl.shader.Shader.SHADERNAME2ID*/0.0002; + this.shader=Shader.withCompile(this._sharderNameID,stateShaderDefines.toNameDic(),nameID,null); + } + + /** + *@private + */ + __proto._uploadTexture=function(shaderIndex,textureSource){ + this._shaderValues.data[this._textureSharderIndices[shaderIndex]]=textureSource; + } + + /** + *增加Shader宏定义。 + *@param value 宏定义。 + */ + __proto._addShaderDefine=function(value){ + this._shaderDefineValue |=value; + } + + /** + *移除Shader宏定义。 + *@param value 宏定义。 + */ + __proto._removeShaderDefine=function(value){ + this._shaderDefineValue &=~value; + } + + /** + *增加禁用宏定义。 + *@param value 宏定义。 + */ + __proto._addDisableShaderDefine=function(value){ + this._disableShaderDefineValue |=value; + } + + /** + *移除禁用宏定义。 + *@param value 宏定义。 + */ + __proto._removeDisableShaderDefine=function(value){ + this._disableShaderDefineValue &=~value; + } + + __proto._setMatrix4x4=function(matrix4x4Index,shaderName,matrix4x4){ + var shaderValue=this._shaderValues; + var index=this._matrix4x4SharderIndices[matrix4x4Index]; + if (!index && matrix4x4){ + this._matrix4x4SharderIndices[matrix4x4Index]=index=shaderValue.length+1; + shaderValue.pushValue(shaderName,null); + } + shaderValue.data[index]=matrix4x4.elements; + this._matrix4x4s[matrix4x4Index]=matrix4x4; + } + + __proto._getMatrix4x4=function(matrix4x4Index){ + return this._matrix4x4s[matrix4x4Index]; + } + + __proto._setNumber=function(numberIndex,shaderName,number){ + var shaderValue=this._shaderValues; + var index=this._numberSharderIndices[numberIndex]; + if (!index && number){ + this._numberSharderIndices[numberIndex]=index=shaderValue.length+1; + shaderValue.pushValue(shaderName,null); + } + shaderValue.data[index]=number; + this._numbers[numberIndex]=number; + } + + __proto._getNumber=function(numberIndex){ + return this._numbers[numberIndex]; + } + + __proto._setColor=function(colorIndex,shaderName,color){ + var shaderValue=this._shaderValues; + var index=this._colorSharderIndices[colorIndex]; + if (!index && color){ + this._colorSharderIndices[colorIndex]=index=shaderValue.length+1; + shaderValue.pushValue(shaderName,null); + } + shaderValue.data[index]=color.elements; + this._colors[colorIndex]=color; + } + + __proto._getColor=function(colorIndex){ + return this._colors[colorIndex]; + } + + /** + *设置纹理。 + */ + __proto._setTexture=function(texture,textureIndex,shaderName){ + var shaderValue=this._shaderValues; + var index=this._textureSharderIndices[textureIndex]; + if (!index && texture){ + this._textureSharderIndices[textureIndex]=index=shaderValue.length+1; + shaderValue.pushValue(shaderName,null); + } + this._textures[textureIndex]=texture; + } + + /** + *获取纹理。 + */ + __proto._getTexture=function(textureIndex){ + return this._textures[textureIndex]; + } + + /** + *上传材质。 + *@param state 相关渲染状态。 + *@param bufferUsageShader Buffer相关绑定。 + *@param shader 着色器。 + *@return 是否成功。 + */ + __proto._upload=function(state,vertexDeclaration,bufferUsageShader){ + this._uploadTextures(); + this._getShader(state.shaderDefines,vertexDeclaration.shaderDefineValue); + var shaderValue=state.shaderValue; + shaderValue.pushArray(this._shaderValues); + this.shader.uploadArray(shaderValue.data,shaderValue.length,bufferUsageShader); + } + + __proto._setLoopShaderParams=function(state,projectionView,worldMatrix,mesh,material){ + throw new Error("Marterial:must override it."); + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + var jsonData=data[0]; + var textureMap=data[1]; + var customHandler=Handler.create(null,Utils3D._parseMaterial,[textureMap],false); + ClassUtils.createByJson(jsonData,this,null,customHandler,null); + customHandler.recover(); + this.event(/*laya.events.Event.LOADED*/"loaded",this); + } + + /** + *设置使用Shader名字。 + *@param name 名称。 + */ + __proto.setShaderName=function(name){ + this._sharderNameID=Shader.nameKey.get(name); + } + + /** + *克隆。 + *@param destObject 克隆源。 + */ + __proto.cloneTo=function(destObject){ + var destBaseMaterial=destObject; + destBaseMaterial.name=this.name; + destBaseMaterial._loaded=this._loaded; + destBaseMaterial._renderQueue=this._renderQueue; + destBaseMaterial._renderMode=this._renderMode; + destBaseMaterial.shader=this.shader; + destBaseMaterial._sharderNameID=this._sharderNameID; + destBaseMaterial._disableShaderDefineValue=this._disableShaderDefineValue; + destBaseMaterial._shaderDefineValue=this._shaderDefineValue; + var i=0,n=0; + var shaderDataIndex=0; + var destShaderValues=destBaseMaterial._shaderValues; + destBaseMaterial._shaderValues.length=this._shaderValues.length + destBaseMaterial._colorSharderIndices=this._colorSharderIndices.slice(); + var colorCount=this._colors.length; + var destColors=destBaseMaterial._colors; + destColors.length=colorCount; + for (i=0,n=colorCount;i < n;i++){ + var destColor=destColors[i]; + (this._colors [i]).cloneTo(destColor); + shaderDataIndex=this._colorSharderIndices[i]-1; + destShaderValues.data[shaderDataIndex]=this._shaderValues.data[shaderDataIndex]; + destShaderValues.data[shaderDataIndex+1]=destColor.elements; + } + destBaseMaterial._numberSharderIndices=this._numberSharderIndices.slice(); + var numberCount=this._numbers.length; + var destNumbers=destBaseMaterial._numbers; + destNumbers.length=numberCount; + for (i=0,n=numberCount;i < n;i++){ + var number=this._numbers[i]; + destNumbers[i]=number; + shaderDataIndex=this._numberSharderIndices[i]-1; + destShaderValues.data[shaderDataIndex]=this._shaderValues.data[shaderDataIndex]; + destShaderValues.data[shaderDataIndex+1]=number; + } + destBaseMaterial._matrix4x4SharderIndices=this._matrix4x4SharderIndices.slice(); + var matrixCount=this._matrix4x4s.length; + var destMatrixs=destBaseMaterial._matrix4x4s; + destMatrixs.length=matrixCount; + for (i=0,n=matrixCount;i < n;i++){ + var destMatrix=destMatrixs[i]; + (this._matrix4x4s [i]).cloneTo(destMatrix); + shaderDataIndex=this._matrix4x4SharderIndices[i]-1; + destShaderValues.data[shaderDataIndex]=this._shaderValues.data[shaderDataIndex]; + destShaderValues.data[shaderDataIndex+1]=destMatrix.elements; + } + destBaseMaterial._textureSharderIndices=this._textureSharderIndices.slice(); + var textureCount=this._textures.length; + var destTextures=destBaseMaterial._textures; + destTextures.length=textureCount; + for (i=0,n=textureCount;i < n;i++){ + destTextures[i]=this._textures[i]; + shaderDataIndex=this._textureSharderIndices[i]-1; + destShaderValues.data[shaderDataIndex]=this._shaderValues.data[shaderDataIndex]; + } + } + + /** + *克隆。 + *@return 克隆副本。 + */ + __proto.clone=function(){ + var destBaseMaterial=/*__JS__ */new this.constructor(); + this.cloneTo(destBaseMaterial); + return destBaseMaterial; + } + + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + /** + *获取所属渲染队列。 + *@return 渲染队列。 + */ + __getset(0,__proto,'renderQueue',function(){ + return this._renderQueue; + }); + + /** + *设置渲染模式。 + *@return 渲染模式。 + */ + /** + *获取渲染状态。 + *@return 渲染状态。 + */ + __getset(0,__proto,'renderMode',function(){ + return this._renderMode; + },function(value){ + this._renderMode=value; + switch (value){ + case 1: + this._renderQueue=/*laya.d3.core.render.RenderQueue.OPAQUE*/1; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 2: + this._renderQueue=/*laya.d3.core.render.RenderQueue.OPAQUE_DOUBLEFACE*/2; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 3: + this._renderQueue=/*laya.d3.core.render.RenderQueue.OPAQUE*/1; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 4: + this._renderQueue=/*laya.d3.core.render.RenderQueue.OPAQUE_DOUBLEFACE*/2; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 13: + this._renderQueue=/*laya.d3.core.render.RenderQueue.ALPHA_BLEND*/3; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 14: + this._renderQueue=/*laya.d3.core.render.RenderQueue.ALPHA_BLEND_DOUBLEFACE*/4; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 15: + this._renderQueue=/*laya.d3.core.render.RenderQueue.ALPHA_ADDTIVE_BLEND*/5; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 16: + this._renderQueue=/*laya.d3.core.render.RenderQueue.ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/6; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 5: + this._renderQueue=/*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_BLEND*/7; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 6: + this._renderQueue=/*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_BLEND_DOUBLEFACE*/8; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 7: + this._renderQueue=/*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND*/9; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 8: + this._renderQueue=/*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/10; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 9: + this._renderQueue=/*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_BLEND*/11; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 10: + this._renderQueue=/*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_BLEND_DOUBLEFACE*/12; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 11: + this._renderQueue=/*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND*/13; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + case 12: + this._renderQueue=/*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/14; + this.event(/*laya.events.Event.RENDERQUEUE_CHANGED*/"renderqueuechanged",this); + break ; + default : + throw new Error("Material:renderMode value error."); + } + if (this._renderMode===3 || this._renderMode===4) + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.ALPHATEST*/0x20000); + else + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.ALPHATEST*/0x20000); + }); + + BaseMaterial.RENDERMODE_OPAQUE=1; + BaseMaterial.RENDERMODE_OPAQUEDOUBLEFACE=2; + BaseMaterial.RENDERMODE_CUTOUT=3; + BaseMaterial.RENDERMODE_CUTOUTDOUBLEFACE=4; + BaseMaterial.RENDERMODE_TRANSPARENT=13; + BaseMaterial.RENDERMODE_TRANSPARENTDOUBLEFACE=14; + BaseMaterial.RENDERMODE_ADDTIVE=15; + BaseMaterial.RENDERMODE_ADDTIVEDOUBLEFACE=16; + BaseMaterial.RENDERMODE_DEPTHREAD_TRANSPARENT=5; + BaseMaterial.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6; + BaseMaterial.RENDERMODE_DEPTHREAD_ADDTIVE=7; + BaseMaterial.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8; + BaseMaterial.RENDERMODE_NONDEPTH_TRANSPARENT=9; + BaseMaterial.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10; + BaseMaterial.RENDERMODE_NONDEPTH_ADDTIVE=11; + BaseMaterial.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12; + return BaseMaterial; + })(Resource) + + + /** + *BaseTexture 纹理的父类,抽象类,不允许实例。 + */ + //class laya.d3.resource.BaseTexture extends laya.resource.Resource + var BaseTexture=(function(_super){ + function BaseTexture(){ + this._width=0; + this._height=0; + this._size=null; + this._repeat=false; + this._mipmap=false; + this._minFifter=0; + this._magFifter=0; + this._source=null; + BaseTexture.__super.call(this); + this._repeat=true; + this._mipmap=true; + this._minFifter=-1; + this._magFifter=-1; + } + + __class(BaseTexture,'laya.d3.resource.BaseTexture',_super); + var __proto=BaseTexture.prototype; + __proto.dispose=function(){ + this.resourceManager.removeResource(this); + _super.prototype.dispose.call(this); + } + + /** + *获取宽度。 + */ + __getset(0,__proto,'width',function(){ + return this._width; + }); + + /** + *是否使用重复模式纹理寻址 + */ + __getset(0,__proto,'repeat',function(){ + return this._repeat; + }); + + /** + *获取高度。 + */ + __getset(0,__proto,'height',function(){ + return this._height; + }); + + /** + *放大过滤器 + */ + __getset(0,__proto,'magFifter',function(){ + return this._magFifter; + }); + + /** + *获取尺寸。 + */ + __getset(0,__proto,'size',function(){ + return this._size; + }); + + /** + *是否使用mipLevel + */ + __getset(0,__proto,'mipmap',function(){ + return this._mipmap; + }); + + /**\ + *缩小过滤器 + */ + __getset(0,__proto,'minFifter',function(){ + return this._minFifter; + }); + + /** + *获取纹理资源。 + */ + __getset(0,__proto,'source',function(){ + this.activeResource(); + return this._source; + }); + + return BaseTexture; + })(Resource) + + + /** + *BaseMesh 类用于创建网格,抽象类,不允许实例。 + */ + //class laya.d3.resource.models.BaseMesh extends laya.resource.Resource + var BaseMesh=(function(_super){ + function BaseMesh(){ + this._subMeshCount=0; + this._boundingBox=null; + this._boundingSphere=null; + BaseMesh.__super.call(this); + this._loaded=false; + } + + __class(BaseMesh,'laya.d3.resource.models.BaseMesh',_super); + var __proto=BaseMesh.prototype; + /** + *获取渲染单元数量,请重载此方法。 + *@return 渲染单元数量。 + */ + __proto.getRenderElementsCount=function(){ + throw new Error("未Override,请重载该属性!"); + } + + /** + *获取渲染单元,请重载此方法。 + *@param index 索引。 + *@return 渲染单元。 + */ + __proto.getRenderElement=function(index){ + throw new Error("未Override,请重载该属性!"); + } + + /** + *获取网格顶点,请重载此方法。 + *@return 网格顶点。 + */ + __getset(0,__proto,'positions',function(){ + throw new Error("未Override,请重载该属性!"); + }); + + /** + *获取SubMesh的个数。 + *@return SubMesh的个数。 + */ + __getset(0,__proto,'subMeshCount',function(){ + return this._subMeshCount; + }); + + /** + *获取AABB包围盒。 + *@return AABB包围盒。 + */ + __getset(0,__proto,'boundingBox',function(){ + return this._boundingBox; + }); + + /** + *获取包围球。 + *@return 包围球。 + */ + __getset(0,__proto,'boundingSphere',function(){ + return this._boundingSphere; + }); + + return BaseMesh; + })(Resource) + + + /** + *Sky 类用于创建天空的父类,抽象类不允许实例。 + */ + //class laya.d3.resource.models.Sky extends laya.resource.Resource + var Sky=(function(_super){ + function Sky(){ + Sky.__super.call(this); + } + + __class(Sky,'laya.d3.resource.models.Sky',_super); + var __proto=Sky.prototype; + __proto._render=function(state){} + Sky.MVPMATRIX="MVPMATRIX"; + Sky.INTENSITY="INTENSITY"; + Sky.ALPHABLENDING="ALPHABLENDING"; + Sky.DIFFUSETEXTURE="DIFFUSETEXTURE"; + return Sky; + })(Resource) + + + /** + *KeyframeAnimation 类用于帧动画组件的父类。 + */ + //class laya.d3.component.animation.KeyframeAnimations extends laya.d3.component.Component3D + var KeyframeAnimations=(function(_super){ + function KeyframeAnimations(){ + this._player=null; + this._templet=null; + KeyframeAnimations.__super.call(this); + this._player=new AnimationPlayer(); + } + + __class(KeyframeAnimations,'laya.d3.component.animation.KeyframeAnimations',_super); + var __proto=KeyframeAnimations.prototype; + /** + *@private + */ + __proto._updateAnimtionPlayer=function(){ + this._player.update(Laya.timer.delta); + } + + /** + *@private + */ + __proto._addUpdatePlayerToTimer=function(){ + Laya.timer.frameLoop(1,this,this._updateAnimtionPlayer); + } + + /** + *@private + */ + __proto._removeUpdatePlayerToTimer=function(){ + Laya.timer.clear(this,this._updateAnimtionPlayer); + } + + /** + *@private + */ + __proto._onOwnerEnableChanged=function(enable){ + if (this._owner.displayedInStage){ + if (enable) + this._addUpdatePlayerToTimer(); + else + this._removeUpdatePlayerToTimer(); + } + } + + /** + *@private + */ + __proto._onDisplayInStage=function(){ + (this._owner.enable)&& (this._addUpdatePlayerToTimer()); + } + + /** + *@private + */ + __proto._onUnDisplayInStage=function(){ + (this._owner.enable)&& (this._removeUpdatePlayerToTimer()); + } + + /** + *@private + *载入组件时执行 + */ + __proto._load=function(owner){ + (this._owner.displayedInStage && this._owner.enable)&& (this._addUpdatePlayerToTimer()); + this._owner.on(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onOwnerEnableChanged); + this._owner.on(/*laya.events.Event.DISPLAY*/"display",this,this._onDisplayInStage); + this._owner.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onUnDisplayInStage); + } + + /** + *@private + *卸载组件时执行 + */ + __proto._unload=function(owner){ + _super.prototype._unload.call(this,owner); + (this._owner.displayedInStage && this._owner.enable)&& (this._removeUpdatePlayerToTimer()); + this._owner.off(/*laya.events.Event.ENABLED_CHANGED*/"enabledchanged",this,this._onOwnerEnableChanged); + this._owner.off(/*laya.events.Event.DISPLAY*/"display",this,this._onDisplayInStage); + this._owner.off(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onUnDisplayInStage); + this._player._destroy(); + this._player=null; + this._templet=null; + } + + /** + *设置url地址。 + *@param value 地址。 + */ + __getset(0,__proto,'url',null,function(value){ + console.log("Warning: discard property,please use templet property instead."); + var templet=Laya.loader.create(value,null,null,AnimationTemplet); + if (this._templet!==templet){ + if (this._player.state!==/*laya.ani.AnimationState.stopped*/0) + this._player.stop(true); + this._templet=templet; + this._player.templet=templet; + this.event(/*laya.events.Event.ANIMATION_CHANGED*/"animationchanged",this); + } + }); + + /** + *获取动画播放器。 + *@return 动画播放器。 + */ + __getset(0,__proto,'player',function(){ + return this._player; + }); + + /** + *设置动画模板。 + *@param value 设置动画模板。 + */ + /** + *获取动画模板。 + *@return value 动画模板。 + */ + __getset(0,__proto,'templet',function(){ + return this._templet; + },function(value){ + if (this._templet!==value){ + if (this._player.state!==/*laya.ani.AnimationState.stopped*/0) + this._player.stop(true); + this._templet=value; + this._player.templet=value; + this.event(/*laya.events.Event.ANIMATION_CHANGED*/"animationchanged",this); + } + }); + + /** + *获取播放器帧数。 + *@return 播放器帧数。 + */ + __getset(0,__proto,'currentFrameIndex',function(){ + return this._player.currentKeyframeIndex; + }); + + /** + *获取播放器的动画索引。 + *@return 动画索引。 + */ + __getset(0,__proto,'currentAnimationClipIndex',function(){ + return this._player.currentAnimationClipIndex; + }); + + /** + *获取播放器当前动画的节点数量。 + *@return 节点数量。 + */ + __getset(0,__proto,'nodeCount',function(){ + return this._templet.getNodeCount(this._player.currentAnimationClipIndex); + }); + + return KeyframeAnimations; + })(Component3D) + + + /** + *AttachPoint 类用于创建挂点组件。 + */ + //class laya.d3.component.AttachPoint extends laya.d3.component.Component3D + var AttachPoint=(function(_super){ + function AttachPoint(){ + this._attachSkeleton=null; + this._data=null; + this._extenData=null; + this.attachBones=null; + this.matrixs=null; + AttachPoint.__super.call(this); + this.attachBones=[]; + this.matrixs=[]; + } + + __class(AttachPoint,'laya.d3.component.AttachPoint',_super); + var __proto=AttachPoint.prototype; + /** + *@private + *初始化载入挂点组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + _super.prototype._load.call(this,owner); + this._attachSkeleton=owner.getComponentByType(SkinAnimations); + } + + /** + *@private + *更新挂点组件。 + *@param state 渲染状态。 + */ + __proto._update=function(state){ + if (!this._attachSkeleton || this._attachSkeleton.player.state!==/*laya.ani.AnimationState.playing*/2 || !this._attachSkeleton.curBonesDatas) + return; + var player=this._attachSkeleton.player; + this.matrixs.length=this.attachBones.length; + for (var i=0;i < this.attachBones.length;i++){ + var index=this._attachSkeleton.templet.getNodeIndexWithName(player.currentAnimationClipIndex,this.attachBones[i]); + this._data=this._attachSkeleton.curBonesDatas.subarray(index *16,(index+1)*16); + var matrix=this.matrixs[i]; + matrix || (matrix=this.matrixs[i]=new Matrix4x4()); + matrix.copyFromArray(this._data); + Matrix4x4.multiply(this.owner.transform.worldMatrix,matrix,matrix); + } + } + + return AttachPoint; + })(Component3D) + + + /** + *Script 类用于创建脚本的父类。 + */ + //class laya.d3.component.Script extends laya.d3.component.Component3D + var Script=(function(_super){ + /** + *创建一个新的 Script 实例。 + */ + function Script(){ + Script.__super.call(this); + } + + __class(Script,'laya.d3.component.Script',_super); + return Script; + })(Component3D) + + + /** + *... + *@author ... + */ + //class laya.d3.core.GlitterRender extends laya.d3.core.render.BaseRender + var GlitterRender=(function(_super){ + function GlitterRender(owner){ + GlitterRender.__super.call(this,owner); + } + + __class(GlitterRender,'laya.d3.core.GlitterRender',_super); + var __proto=GlitterRender.prototype; + __proto._calculateBoundingBox=function(){ + var minE=this._boundingBox.min.elements; + minE[0]=-Number.MAX_VALUE; + minE[1]=-Number.MAX_VALUE; + minE[2]=-Number.MAX_VALUE; + var maxE=this._boundingBox.min.elements; + maxE[0]=Number.MAX_VALUE; + maxE[1]=Number.MAX_VALUE; + maxE[2]=Number.MAX_VALUE; + } + + __proto._calculateBoundingSphere=function(){ + var centerE=this._boundingSphere.center.elements; + centerE[0]=0; + centerE[1]=0; + centerE[2]=0; + this._boundingSphere.radius=Number.MAX_VALUE; + } + + return GlitterRender; + })(BaseRender) + + + /** + *MeshRender 类用于网格渲染器。 + */ + //class laya.d3.core.MeshRender extends laya.d3.core.render.BaseRender + var MeshRender=(function(_super){ + function MeshRender(owner){ + this._meshSprite3DOwner=null; + this.castShadow=false; + this.receiveShadow=false; + MeshRender.__super.call(this,owner); + this._meshSprite3DOwner=owner; + this.castShadow=true; + this.receiveShadow=true; + this._meshSprite3DOwner.meshFilter.on(/*laya.events.Event.MESH_CHANGED*/"meshchanged",this,this._onMeshChanged); + } + + __class(MeshRender,'laya.d3.core.MeshRender',_super); + var __proto=MeshRender.prototype; + /** + *@private + */ + __proto._onMeshChanged=function(sender,oldMesh,mesh){ + if (mesh.loaded){ + this._boundingSphereNeedChange=true; + this._boundingBoxNeedChange=true; + }else { + mesh.once(/*laya.events.Event.LOADED*/"loaded",this,this._onMeshLoaed); + } + } + + /** + *@private + */ + __proto._onMeshLoaed=function(sender,enable){ + this._boundingSphereNeedChange=true; + this._boundingBoxNeedChange=true; + } + + __proto._calculateBoundingSphere=function(){ + if (this._meshSprite3DOwner.meshFilter.sharedMesh===null || this._meshSprite3DOwner.meshFilter.sharedMesh.boundingSphere===null){ + this._boundingSphere.toDefault(); + }else { + var meshBoundingSphere=this._meshSprite3DOwner.meshFilter.sharedMesh.boundingSphere; + var maxScale=NaN; + var transform=this._meshSprite3DOwner.transform; + var scale=transform.scale; + if (scale.x >=scale.y && scale.x >=scale.z) + maxScale=scale.x; + else + maxScale=scale.y >=scale.z ? scale.y :scale.z; + Vector3.transformCoordinate(meshBoundingSphere.center,transform.worldMatrix,this._boundingSphere.center); + this._boundingSphere.radius=meshBoundingSphere.radius *maxScale; + } + } + + __proto._calculateBoundingBox=function(){ + if (this._meshSprite3DOwner.meshFilter.sharedMesh===null || this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox===null){ + this._boundingBox.toDefault(); + }else { + var meshBoudingBox=this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox; + var worldMat=this._meshSprite3DOwner.transform.worldMatrix; + Vector3.transformCoordinate(meshBoudingBox.min,worldMat,this._boundingBox.min); + Vector3.transformCoordinate(meshBoudingBox.max,worldMat,this._boundingBox.max); + } + } + + /** + *@private + */ + __proto._destroy=function(){ + _super.prototype._destroy.call(this); + this._meshSprite3DOwner=null; + } + + return MeshRender; + })(BaseRender) + + + /** + *... + *@author ... + */ + //class laya.d3.core.ParticleRender extends laya.d3.core.render.BaseRender + var ParticleRender=(function(_super){ + function ParticleRender(owner){ + ParticleRender.__super.call(this,owner); + } + + __class(ParticleRender,'laya.d3.core.ParticleRender',_super); + var __proto=ParticleRender.prototype; + __proto._calculateBoundingBox=function(){ + var minE=this._boundingBox.min.elements; + minE[0]=-Number.MAX_VALUE; + minE[1]=-Number.MAX_VALUE; + minE[2]=-Number.MAX_VALUE; + var maxE=this._boundingBox.min.elements; + maxE[0]=Number.MAX_VALUE; + maxE[1]=Number.MAX_VALUE; + maxE[2]=Number.MAX_VALUE; + } + + __proto._calculateBoundingSphere=function(){ + var centerE=this._boundingSphere.center.elements; + centerE[0]=0; + centerE[1]=0; + centerE[2]=0; + this._boundingSphere.radius=Number.MAX_VALUE; + } + + return ParticleRender; + })(BaseRender) + + + /** + *... + *@author ... + */ + //class laya.d3.core.particleShuriKen.ShurikenParticleRender extends laya.d3.core.render.BaseRender + var ShurikenParticleRender=(function(_super){ + function ShurikenParticleRender(owner){ + this.renderMode=0; + this.stretchedBillboardCameraSpeedScale=0; + this.stretchedBillboardSpeedScale=0; + this.stretchedBillboardLengthScale=1; + ShurikenParticleRender.__super.call(this,owner); + this.renderMode=0; + } + + __class(ShurikenParticleRender,'laya.d3.core.particleShuriKen.ShurikenParticleRender',_super); + var __proto=ShurikenParticleRender.prototype; + __proto._calculateBoundingBox=function(){ + var minE=this._boundingBox.min.elements; + minE[0]=-Number.MAX_VALUE; + minE[1]=-Number.MAX_VALUE; + minE[2]=-Number.MAX_VALUE; + var maxE=this._boundingBox.min.elements; + maxE[0]=Number.MAX_VALUE; + maxE[1]=Number.MAX_VALUE; + maxE[2]=Number.MAX_VALUE; + } + + __proto._calculateBoundingSphere=function(){ + var centerE=this._boundingSphere.center.elements; + centerE[0]=0; + centerE[1]=0; + centerE[2]=0; + this._boundingSphere.radius=Number.MAX_VALUE; + } + + return ShurikenParticleRender; + })(BaseRender) + + + /** + *@private + *ParticleTemplet3D 类用于创建3D粒子数据模板。 + */ + //class laya.d3.resource.tempelet.ParticleTemplet3D extends laya.particle.ParticleTemplateWebGL + var ParticleTemplet3D=(function(_super){ + function ParticleTemplet3D(owner,setting){ + this._owner=null; + this._vertexBuffer3D=null; + this._indexBuffer3D=null; + ParticleTemplet3D.__super.call(this,setting); + this._owner=owner; + this.initialize(); + this._vertexBuffer=this._vertexBuffer3D=VertexBuffer3D.create(VertexParticle.vertexDeclaration,setting.maxPartices *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._indexBuffer=this._indexBuffer3D=IndexBuffer3D.create(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",setting.maxPartices *6,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this.loadContent(); + } + + __class(ParticleTemplet3D,'laya.d3.resource.tempelet.ParticleTemplet3D',_super); + var __proto=ParticleTemplet3D.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer3D; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return this._indexBuffer3D; + } + + __proto.addParticle=function(position,velocity){ + this.addParticleArray(position.elements,velocity.elements); + } + + __proto.loadContent=function(){ + var indexes=new Uint16Array(this.settings.maxPartices *6); + for (var i=0;i < this.settings.maxPartices;i++){ + indexes[i *6+0]=(i *4+0); + indexes[i *6+1]=(i *4+1); + indexes[i *6+2]=(i *4+2); + indexes[i *6+3]=(i *4+0); + indexes[i *6+4]=(i *4+2); + indexes[i *6+5]=(i *4+3); + } + this._indexBuffer3D.setData(indexes); + } + + __proto.addNewParticlesToVertexBuffer=function(){ + var start=0; + if (this._firstNewElement < this._firstFreeElement){ + start=this._firstNewElement *4 *this._floatCountPerVertex; + this._vertexBuffer3D.setData(this._vertices,start,start,(this._firstFreeElement-this._firstNewElement)*4 *this._floatCountPerVertex); + }else { + start=this._firstNewElement *4 *this._floatCountPerVertex; + this._vertexBuffer3D.setData(this._vertices,start,start,(this.settings.maxPartices-this._firstNewElement)*4 *this._floatCountPerVertex); + if (this._firstFreeElement > 0){ + this._vertexBuffer3D.setData(this._vertices,0,0,this._firstFreeElement *4 *this._floatCountPerVertex); + } + } + this._firstNewElement=this._firstFreeElement; + } + + __proto._beforeRender=function(state){ + if (this._firstNewElement !=this._firstFreeElement){ + this.addNewParticlesToVertexBuffer(); + } + this._drawCounter++; + if (this._firstActiveElement !=this._firstFreeElement){ + this._vertexBuffer3D._bind(); + this._indexBuffer._bind(); + return true; + } + return false; + } + + __proto._render=function(state){ + var drawVertexCount=0; + var glContext=WebGL.mainContext; + if (this._firstActiveElement < this._firstFreeElement){ + drawVertexCount=(this._firstFreeElement-this._firstActiveElement)*6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + }else { + drawVertexCount=(this.settings.maxPartices-this._firstActiveElement)*6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + if (this._firstFreeElement > 0){ + drawVertexCount=this._firstFreeElement *6; + glContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,drawVertexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.trianglesFaces+=drawVertexCount / 3; + Stat.drawCall++; + } + } + } + + __getset(0,__proto,'indexOfHost',function(){ + return 0; + }); + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer3D.indexCount / 3; + }); + + return ParticleTemplet3D; + })(ParticleTemplateWebGL) + + + /** + *BaseScene 类用于实现场景的父类。 + */ + //class laya.d3.core.scene.BaseScene extends laya.display.Sprite + var BaseScene=(function(_super){ + function BaseScene(){ + this._invertYProjectionMatrix=null; + this._invertYProjectionViewMatrix=null; + this._invertYScaleMatrix=null; + this._boundFrustum=null; + this._enableLightCount=3; + this._renderTargetTexture=null; + this._customRenderQueneIndex=11; + this._lastCurrentTime=NaN; + this._staticBatchManager=null; + this._dynamicBatchManager=null; + this.enableFog=false; + this.fogStart=NaN; + this.fogRange=NaN; + this.fogColor=null; + this.enableLight=true; + BaseScene.__super.call(this); + this._renderState=new RenderState(); + this._lights=new Array; + this._renderConfigs=[]; + this._frustumCullingObjects=[]; + this._quenes=[]; + this._cameraPool=[]; + this._invertYProjectionMatrix=new Matrix4x4(); + this._invertYProjectionViewMatrix=new Matrix4x4(); + this._invertYScaleMatrix=new Matrix4x4(); + Matrix4x4.createScaling(new Vector3(1,-1,1),this._invertYScaleMatrix); + this._staticBatchManager=new StaticBatchManager(); + this._dynamicBatchManager=new DynamicBatchManager(); + this._boundFrustum=new BoundFrustum(Matrix4x4.DEFAULT); + this.enableFog=false; + this.fogStart=300; + this.fogRange=1000; + this.fogColor=new Vector3(0.7,0.7,0.7); + var renderConfig; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.OPAQUE*/1]=new RenderConfig(); + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.OPAQUE_DOUBLEFACE*/2]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.ALPHA_BLEND*/3]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.ALPHA_BLEND_DOUBLEFACE*/4]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.ALPHA_ADDTIVE_BLEND*/5]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/6]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_BLEND*/7]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.depthMask=0; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND*/9]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.depthMask=0; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_BLEND_DOUBLEFACE*/8]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.depthMask=0; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.DEPTHREAD_ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/10]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.depthMask=0; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_BLEND*/11]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.depthTest=false; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND*/13]=new RenderConfig(); + renderConfig.blend=true; + renderConfig.depthTest=false; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_BLEND_DOUBLEFACE*/12]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.depthTest=false; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + renderConfig=this._renderConfigs[ /*laya.d3.core.render.RenderQueue.NONDEPTH_ALPHA_ADDTIVE_BLEND_DOUBLEFACE*/14]=new RenderConfig(); + renderConfig.cullFace=false; + renderConfig.blend=true; + renderConfig.depthTest=false; + renderConfig.sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + renderConfig.dFactor=/*laya.webgl.WebGLContext.ONE*/1; + this.on(/*laya.events.Event.DISPLAY*/"display",this,this._$3__onDisplay); + this.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onUnDisplay); + } + + __class(BaseScene,'laya.d3.core.scene.BaseScene',_super); + var __proto=BaseScene.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + /** + *@private + */ + __proto._$3__onDisplay=function(){ + Laya.stage._scenes.push(this); + Laya.stage._scenes.sort(BaseScene._sortScenes); + } + + /** + *@private + */ + __proto._onUnDisplay=function(){ + var scenes=Laya.stage._scenes; + scenes.splice(scenes.indexOf(this),1); + } + + /** + *@private + *场景相关渲染准备设置。 + *@param gl WebGL上下文。 + *@return state 渲染状态。 + */ + __proto._prepareUpdateToRenderState=function(gl,state){ + state.context=WebGL.mainContext; + state.elapsedTime=this._lastCurrentTime ? this.timer.currTimer-this._lastCurrentTime :0; + this._lastCurrentTime=this.timer.currTimer; + state.loopCount=Stat.loopCount; + state.scene=this; + } + + /** + *@private + *场景相关渲染准备设置。 + *@param gl WebGL上下文。 + *@return state 渲染状态。 + */ + __proto._prepareRenderToRenderState=function(camera,state){ + var shaderDefines=state.shaderDefines; + (WebGL.frameShaderHighPrecision)&& (shaderDefines.addInt(/*laya.d3.shader.ShaderDefines3D.FSHIGHPRECISION*/0x80)); + Layer._currentCameraCullingMask=camera.cullingMask; + state.camera=camera; + var shaderValue=state.shaderValue; + camera && shaderValue.pushValue(/*CLASS CONST:laya.d3.core.scene.BaseScene.CAMERAPOS*/"CAMERAPOS",camera.transform.position.elements); + if (this._lights.length > 0){ + var lightCount=0; + for (var i=0;i < this._lights.length;i++){ + var light=this._lights[i]; + if (!light.active)continue ; + lightCount++; + if (lightCount > this._enableLightCount) + break ; + light.updateToWorldState(state); + } + } + if (this.enableFog){ + shaderDefines.addInt(/*laya.d3.shader.ShaderDefines3D.FOG*/0x200); + shaderValue.pushValue(/*CLASS CONST:laya.d3.core.scene.BaseScene.FOGSTART*/"FOGSTART",this.fogStart); + shaderValue.pushValue(/*CLASS CONST:laya.d3.core.scene.BaseScene.FOGRANGE*/"FOGRANGE",this.fogRange); + shaderValue.pushValue(/*CLASS CONST:laya.d3.core.scene.BaseScene.FOGCOLOR*/"FOGCOLOR",this.fogColor.elements); + } + } + + __proto._endRenderToRenderState=function(state){ + state.reset(); + } + + /** + *@private + */ + __proto._updateScene=function(){ + var renderState=this._renderState; + this._prepareUpdateToRenderState(WebGL.mainContext,renderState); + this.beforeUpate(renderState); + this._updateChilds(renderState); + this.lateUpate(renderState); + } + + /** + *@private + */ + __proto._updateChilds=function(state){ + for (var i=0,n=this._childs.length;i < n;++i) + this._childs[i]._update(state); + } + + /** + *@private + */ + __proto._preRenderScene=function(gl,state){ + this._boundFrustum.matrix=state.projectionViewMatrix; + FrustumCulling.RenderObjectCulling(this._boundFrustum,this); + for (var i=0,iNum=this._quenes.length;i < iNum;i++) + (this._quenes[i])&& (this._quenes[i]._preRender(state)); + } + + __proto._clear=function(gl,state){ + var viewport=state.viewport; + var camera=state.camera; + var renderTargetHeight=camera.renderTargetSize.height; + gl.viewport(viewport.x,renderTargetHeight-viewport.y-viewport.height,viewport.width,viewport.height); + var clearFlag=0; + switch (camera.clearFlag){ + case /*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0: + if (camera.clearColor){ + gl.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + gl.scissor(viewport.x,renderTargetHeight-viewport.y-viewport.height,viewport.width,viewport.height); + var clearColorE=camera.clearColor.elements; + gl.clearColor(clearColorE[0],clearColorE[1],clearColorE[2],clearColorE[3]); + clearFlag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000; + if (camera.renderTarget){ + switch (camera.renderTarget.depthStencilFormat){ + case /*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + break ; + case /*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48: + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400; + break ; + case /*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400 + break ; + } + }else { + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + } + gl.clear(clearFlag); + gl.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11); + }else { + gl.clear(/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100); + } + break ; + case /*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1: + case /*laya.d3.core.BaseCamera.CLEARFLAG_DEPTHONLY*/2: + if (camera.renderTarget){ + switch (camera.renderTarget.depthStencilFormat){ + case /*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + break ; + case /*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48: + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400; + break ; + case /*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9: + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + clearFlag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400 + break ; + } + }else { + clearFlag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100; + } + break ; + case /*laya.d3.core.BaseCamera.CLEARFLAG_NONE*/3: + break ; + default : + throw new Error("BaseScene:camera clearFlag invalid."); + } + } + + /** + *@private + */ + __proto._renderScene=function(gl,state){ + var camera=state.camera; + var i=0,n=0; + var queue; + for (i=0;i < 3;i++){ + queue=this._quenes[i]; + if (queue){ + queue._setState(gl,state); + queue._render(state); + } + } + if (camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1){ + var sky=camera.sky; + if (sky){ + WebGLContext.setCullFace(gl,false); + WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LEQUAL*/0x0203); + WebGLContext.setDepthMask(gl,0); + sky._render(state); + WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LESS*/0x0201); + WebGLContext.setDepthMask(gl,1); + } + } + for (i=3,n=this._quenes.length;i < n;i++){ + queue=this._quenes[i]; + if (queue){ + queue._sortAlpha(state.camera.transform.position); + queue._setState(gl,state); + queue._render(state); + } + } + } + + /** + *@private + */ + __proto._set3DRenderConfig=function(gl){ + gl.disable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + WebGLContext._blend=false; + gl.blendFunc(/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303); + WebGLContext._sFactor=/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302; + WebGLContext._dFactor=/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303; + gl.disable(/*laya.webgl.WebGLContext.DEPTH_TEST*/0x0B71); + WebGLContext._depthTest=false; + gl.enable(/*laya.webgl.WebGLContext.CULL_FACE*/0x0B44); + WebGLContext._cullFace=true; + gl.depthMask(1); + WebGLContext._depthMask=1; + gl.frontFace(/*laya.webgl.WebGLContext.CW*/0x0900); + WebGLContext._frontFace=/*laya.webgl.WebGLContext.CW*/0x0900; + } + + /** + *@private + */ + __proto._set2DRenderConfig=function(gl){ + WebGLContext.setBlend(gl,true); + WebGLContext.setBlendFunc(gl,/*laya.webgl.WebGLContext.SRC_ALPHA*/0x0302,/*laya.webgl.WebGLContext.ONE_MINUS_SRC_ALPHA*/0x0303); + WebGLContext.setDepthTest(gl,false); + WebGLContext.setCullFace(gl,false); + WebGLContext.setDepthMask(gl,1); + WebGLContext.setFrontFaceCCW(gl,/*laya.webgl.WebGLContext.CCW*/0x0901); + gl.viewport(0,0,RenderState2D.width,RenderState2D.height); + } + + /** + *@private + */ + __proto._addLight=function(light){ + if (this._lights.indexOf(light)< 0)this._lights.push(light); + } + + /** + *@private + */ + __proto._removeLight=function(light){ + var index=this._lights.indexOf(light); + index >=0 && (this._lights.splice(index,1)); + } + + __proto.addChildAt=function(node,index){ + if (!((node instanceof laya.d3.core.Sprite3D ))) + throw new Error("Sprite3D:Node type must Sprite3D."); + return laya.display.Node.prototype.addChildAt.call(this,node,index); + } + + __proto.addChild=function(node){ + if (!((node instanceof laya.d3.core.Sprite3D ))) + throw new Error("Sprite3D:Node type must Sprite3D."); + return laya.display.Node.prototype.addChild.call(this,node); + } + + __proto.addFrustumCullingObject=function(frustumCullingObject){ + this._frustumCullingObjects.push(frustumCullingObject); + } + + __proto.removeFrustumCullingObject=function(frustumCullingObject){ + var index=this._frustumCullingObjects.indexOf(frustumCullingObject); + (index!==-1)&& (this._frustumCullingObjects.splice(index,1)); + } + + /** + *获得某个渲染队列。 + *@param index 渲染队列索引。 + *@return 渲染队列。 + */ + __proto.getRenderQueue=function(index){ + return (this._quenes[index] || (this._quenes[index]=new RenderQueue(this._renderConfigs[index],this))); + } + + /** + *添加渲染队列。 + *@param renderConfig 渲染队列配置文件。 + */ + __proto.addRenderQuene=function(renderConfig){ + this._quenes[this._customRenderQueneIndex++]=new RenderQueue(renderConfig,this); + } + + /** + *更新前处理,可重写此函数。 + *@param state 渲染相关状态。 + */ + __proto.beforeUpate=function(state){} + /** + *更新后处理,可重写此函数。 + *@param state 渲染相关状态。 + */ + __proto.lateUpate=function(state){} + /** + *渲染前处理,可重写此函数。 + *@param state 渲染相关状态。 + */ + __proto.beforeRender=function(state){} + /** + *渲染后处理,可重写此函数。 + *@param state 渲染相关状态。 + */ + __proto.lateRender=function(state){} + /** + *@private + */ + __proto.render=function(context,x,y){ + (Render._context.ctx)._shader2D.glTexture=null; + this._childs.length > 0 && context.addRenderObject(this); + this._renderType &=~ /*laya.renders.RenderSprite.CHILDS*/0x800; + _super.prototype.render.call(this,context,x,y); + } + + /** + *@private + */ + __proto.renderSubmit=function(){ + return 1; + } + + /** + *@private + */ + __proto.getRenderType=function(){ + return 0; + } + + /** + *@private + */ + __proto.releaseRender=function(){} + /** + *获取当前场景。 + *@return 当前场景。 + */ + __getset(0,__proto,'scene',function(){ + return this; + }); + + BaseScene._sortScenes=function(a,b){ + if (a.parent===Laya.stage && b.parent===Laya.stage){ + var stageChildren=Laya.stage._childs; + return stageChildren.indexOf(a)-stageChildren.indexOf(b); + }else if (a.parent!==Laya.stage && b.parent!==Laya.stage){ + return BaseScene._sortScenes(a.parent,b.parent); + }else { + return (a.parent===Laya.stage)?-1 :1; + } + } + + BaseScene.FOGCOLOR="FOGCOLOR"; + BaseScene.FOGSTART="FOGSTART"; + BaseScene.FOGRANGE="FOGRANGE"; + BaseScene.CAMERAPOS="CAMERAPOS"; + BaseScene.LIGHTDIRECTION="LIGHTDIRECTION"; + BaseScene.LIGHTDIRDIFFUSE="LIGHTDIRDIFFUSE"; + BaseScene.LIGHTDIRAMBIENT="LIGHTDIRAMBIENT"; + BaseScene.LIGHTDIRSPECULAR="LIGHTDIRSPECULAR"; + BaseScene.POINTLIGHTPOS="POINTLIGHTPOS"; + BaseScene.POINTLIGHTRANGE="POINTLIGHTRANGE"; + BaseScene.POINTLIGHTATTENUATION="POINTLIGHTATTENUATION"; + BaseScene.POINTLIGHTDIFFUSE="POINTLIGHTDIFFUSE"; + BaseScene.POINTLIGHTAMBIENT="POINTLIGHTAMBIENT"; + BaseScene.POINTLIGHTSPECULAR="POINTLIGHTSPECULAR"; + BaseScene.SPOTLIGHTPOS="SPOTLIGHTPOS"; + BaseScene.SPOTLIGHTDIRECTION="SPOTLIGHTDIRECTION"; + BaseScene.SPOTLIGHTSPOT="SPOTLIGHTSPOT"; + BaseScene.SPOTLIGHTRANGE="SPOTLIGHTRANGE"; + BaseScene.SPOTLIGHTATTENUATION="SPOTLIGHTATTENUATION"; + BaseScene.SPOTLIGHTDIFFUSE="SPOTLIGHTDIFFUSE"; + BaseScene.SPOTLIGHTAMBIENT="SPOTLIGHTAMBIENT"; + BaseScene.SPOTLIGHTSPECULAR="SPOTLIGHTSPECULAR"; + return BaseScene; + })(Sprite) + + + /** + *BaseCamera 类用于创建摄像机的父类。 + */ + //class laya.d3.core.BaseCamera extends laya.d3.core.Sprite3D + var BaseCamera=(function(_super){ + function BaseCamera(nearPlane,farPlane){ + //this._tempVector3=null; + //this._position=null; + //this._up=null; + //this._forward=null; + //this._right=null; + //this._renderTarget=null; + //this._renderingOrder=0; + //this._renderTargetSize=null; + //this._nearPlane=NaN; + //this._farPlane=NaN; + //this._fieldOfView=NaN; + //this._orthographic=false; + //this._orthographicVerticalSize=NaN; + //this._useUserProjectionMatrix=false; + //this._viewportExpressedInClipSpace=false; + this._projectionMatrixModifyID=0; + //this.clearFlag=0; + //this.clearColor=null; + //this.cullingMask=0; + //this.sky=null; + BaseCamera.__super.call(this); + (nearPlane===void 0)&& (nearPlane=0.1); + (farPlane===void 0)&& (farPlane=1000); + this._tempVector3=new Vector3(); + this._position=new Vector3(); + this._up=new Vector3(); + this._forward=new Vector3(); + this._right=new Vector3(); + this._fieldOfView=60; + this._useUserProjectionMatrix=false; + this._orthographic=false; + this._viewportExpressedInClipSpace=true; + this._renderTargetSize=Size.fullScreen; + this._orthographicVerticalSize=10; + this.renderingOrder=0; + this._nearPlane=nearPlane; + this._farPlane=farPlane; + this.cullingMask=2147483647; + this.clearColor=new Vector4(0.26,0.26,0.26,1.0); + this.clearFlag=/*CLASS CONST:laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0; + this._calculateProjectionMatrix(); + Laya.stage.on(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged); + } + + __class(BaseCamera,'laya.d3.core.BaseCamera',_super); + var __proto=BaseCamera.prototype; + /** + *通过RenderingOrder属性对摄像机机型排序。 + */ + __proto._sortCamerasByRenderingOrder=function(){ + if (this._displayedInStage){ + var cameraPool=this.scene._cameraPool; + var n=cameraPool.length-1; + for (var i=0;i < n;i++){ + if (cameraPool[i].renderingOrder > cameraPool[n].renderingOrder){ + var tempCamera=cameraPool[i]; + cameraPool[i]=cameraPool[n]; + cameraPool[n]=tempCamera; + } + } + } + } + + __proto._calculateProjectionMatrix=function(){} + __proto._onScreenSizeChanged=function(){ + this._calculateProjectionMatrix(); + } + + /** + *增加可视图层。 + *@param layer 图层。 + */ + __proto.addLayer=function(layer){ + if (layer.number===29 || layer.number==30) + return; + this.cullingMask=this.cullingMask | layer.mask; + } + + /** + *移除可视图层。 + *@param layer 图层。 + */ + __proto.removeLayer=function(layer){ + if (layer.number===29 || layer.number==30) + return; + this.cullingMask=this.cullingMask & ~layer.mask; + } + + /** + *增加所有图层。 + */ + __proto.addAllLayers=function(){ + this.cullingMask=2147483647; + } + + /** + *移除所有图层。 + */ + __proto.removeAllLayers=function(){ + this.cullingMask=0 | Layer.getLayerByNumber(29).mask | Layer.getLayerByNumber(30).mask; + } + + __proto.ResetProjectionMatrix=function(){ + this._useUserProjectionMatrix=false; + this._calculateProjectionMatrix(); + } + + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + this.sky=null; + this.renderTarget=null; + Laya.stage.off(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged); + _super.prototype.destroy.call(this,destroyChild); + } + + /** + *向前移动。 + *@param distance 移动距离。 + */ + __proto.moveForward=function(distance){ + this._tempVector3.elements[0]=this._tempVector3.elements[1]=0; + this._tempVector3.elements[2]=distance; + this.transform.translate(this._tempVector3); + } + + /** + *向右移动。 + *@param distance 移动距离。 + */ + __proto.moveRight=function(distance){ + this._tempVector3.elements[1]=this._tempVector3.elements[2]=0; + this._tempVector3.elements[0]=distance; + this.transform.translate(this._tempVector3); + } + + /** + *向上移动。 + *@param distance 移动距离。 + */ + __proto.moveVertical=function(distance){ + this._tempVector3.elements[0]=this._tempVector3.elements[2]=0; + this._tempVector3.elements[1]=distance; + this.transform.translate(this._tempVector3,false); + } + + //}// BoundingFrustumWorldSpace + __proto._addSelfRenderObjects=function(){ + var cameraPool=this.scene._cameraPool; + var cmaeraCount=cameraPool.length; + if (cmaeraCount > 0){ + for (var i=cmaeraCount-1;i >=0;i--){ + if (this.renderingOrder <=cameraPool[i].renderingOrder){ + cameraPool.splice(i+1,0,this); + break ; + } + } + }else { + cameraPool.push(this); + } + } + + __proto._clearSelfRenderObjects=function(){ + var cameraPool=this.scene._cameraPool; + cameraPool.splice(cameraPool.indexOf(this),1); + } + + /** + *获取前向量。 + *@return 前向量。 + */ + __getset(0,__proto,'forward',function(){ + var worldMatrixe=this.transform.worldMatrix.elements; + var forwarde=this._forward.elements; + forwarde[0]=-worldMatrixe[8]; + forwarde[1]=-worldMatrixe[9]; + forwarde[2]=-worldMatrixe[10]; + return this._forward; + }); + + /**获取位置。*/ + __getset(0,__proto,'position',function(){ + var worldMatrixe=this.transform.worldMatrix.elements; + var positione=this._position.elements; + positione[0]=worldMatrixe[12]; + positione[1]=worldMatrixe[13]; + positione[2]=worldMatrixe[14]; + return this._position; + }); + + /** + *设置远裁面。 + *@param value 远裁面。 + */ + /** + *获取远裁面。 + *@return 远裁面。 + */ + __getset(0,__proto,'farPlane',function(){ + return this._farPlane; + },function(vaule){ + this._farPlane=vaule; + this._calculateProjectionMatrix(); + }); + + /** + *设置渲染场景的渲染目标。 + *@param value 渲染场景的渲染目标。 + */ + /** + *获取渲染场景的渲染目标。 + *@return 渲染场景的渲染目标。 + */ + __getset(0,__proto,'renderTarget',function(){ + return this._renderTarget; + },function(value){ + this._renderTarget=value; + if (value !=null) + this._renderTargetSize=value.size; + }); + + /** + *获取上向量。 + *@return 上向量。 + */ + __getset(0,__proto,'up',function(){ + var worldMatrixe=this.transform.worldMatrix.elements; + var upe=this._up.elements; + upe[0]=worldMatrixe[4]; + upe[1]=worldMatrixe[5]; + upe[2]=worldMatrixe[6]; + return this._up; + }); + + /** + *获取右向量。 + *@return 右向量。 + */ + __getset(0,__proto,'right',function(){ + var worldMatrixe=this.transform.worldMatrix.elements; + var righte=this._right.elements; + righte[0]=worldMatrixe[0]; + righte[1]=worldMatrixe[1]; + righte[2]=worldMatrixe[2]; + return this._right; + }); + + /** + *设置渲染目标的尺寸 + *@param value 渲染目标的尺寸。 + */ + /** + *获取渲染目标的尺寸 + *@return 渲染目标的尺寸。 + */ + __getset(0,__proto,'renderTargetSize',function(){ + return this._renderTargetSize; + },function(value){ + if (this.renderTarget !=null && this._renderTargetSize !=value){} + this._renderTargetSize=value; + this._calculateProjectionMatrix(); + }); + + /** + *设置视野。 + *@param value 视野。 + */ + /** + *获取视野。 + *@return 视野。 + */ + __getset(0,__proto,'fieldOfView',function(){ + return this._fieldOfView; + },function(value){ + this._fieldOfView=value; + this._calculateProjectionMatrix(); + }); + + /** + *设置近裁面。 + *@param value 近裁面。 + */ + /** + *获取近裁面。 + *@return 近裁面。 + */ + __getset(0,__proto,'nearPlane',function(){ + return this._nearPlane; + },function(value){ + this._nearPlane=value; + this._calculateProjectionMatrix(); + }); + + /** + *设置是否正交投影矩阵。 + *@param 是否正交投影矩阵。 + */ + /** + *获取是否正交投影矩阵。 + *@return 是否正交投影矩阵。 + */ + __getset(0,__proto,'orthographicProjection',function(){ + return this._orthographic; + },function(vaule){ + this._orthographic=vaule; + this._calculateProjectionMatrix(); + }); + + /** + *设置正交投影垂直矩阵尺寸。 + *@param 正交投影垂直矩阵尺寸。 + */ + /** + *获取正交投影垂直矩阵尺寸。 + *@return 正交投影垂直矩阵尺寸。 + */ + __getset(0,__proto,'orthographicVerticalSize',function(){ + return this._orthographicVerticalSize; + },function(vaule){ + this._orthographicVerticalSize=vaule; + this._calculateProjectionMatrix(); + }); + + __getset(0,__proto,'renderingOrder',function(){ + return this._renderingOrder; + },function(value){ + this._renderingOrder=value; + this._sortCamerasByRenderingOrder(); + }); + + BaseCamera.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING"; + BaseCamera.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING"; + BaseCamera.CLEARFLAG_SOLIDCOLOR=0; + BaseCamera.CLEARFLAG_SKY=1; + BaseCamera.CLEARFLAG_DEPTHONLY=2; + BaseCamera.CLEARFLAG_NONE=3; + return BaseCamera; + })(Sprite3D) + + + /** + *Glitter 类用于创建闪光。 + */ + //class laya.d3.core.glitter.Glitter extends laya.d3.core.Sprite3D + var Glitter=(function(_super){ + function Glitter(){ + this._templet=null; + this._glitterRender=null; + Glitter.__super.call(this); + this._glitterRender=new GlitterRender(this); + this._glitterRender.on(/*laya.events.Event.MATERIAL_CHANGED*/"materialchanged",this,this._onMaterialChanged); + var material=new GlitterMaterial(); + this._glitterRender.sharedMaterial=material; + this._templet=new GlitterTemplet(this); + material.renderMode=/*laya.d3.core.material.BaseMaterial.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE*/8; + this._changeRenderObject(0); + } + + __class(Glitter,'laya.d3.core.glitter.Glitter',_super); + var __proto=Glitter.prototype; + /**@private */ + __proto._changeRenderObject=function(index){ + var renderObjects=this._glitterRender.renderObject._renderElements; + var renderElement=renderObjects[index]; + (renderElement)|| (renderElement=renderObjects[index]=new RenderElement()); + renderElement._renderObject=this._glitterRender.renderObject; + var material=this._glitterRender.sharedMaterials[index]; + (material)|| (material=GlitterMaterial.defaultMaterial); + var element=this._templet; + renderElement._mainSortID=0; + renderElement._sprite3D=this; + renderElement.renderObj=element; + renderElement._material=material; + return renderElement; + } + + /**@private */ + __proto._onMaterialChanged=function(_glitterRender,index,material){ + var renderElementCount=_glitterRender.renderObject._renderElements.length; + (index < renderElementCount)&& this._changeRenderObject(index); + } + + /**@private */ + __proto._clearSelfRenderObjects=function(){ + this.scene.removeFrustumCullingObject(this._glitterRender.renderObject); + } + + /**@private */ + __proto._addSelfRenderObjects=function(){ + this.scene.addFrustumCullingObject(this._glitterRender.renderObject); + } + + /** + *@private + *更新闪光。 + *@param state 渲染状态参数。 + */ + __proto._update=function(state){ + this._templet._update(state.elapsedTime); + state.owner=this; + Stat.spriteCount++; + this._childs.length && this._updateChilds(state); + } + + /** + *通过位置添加刀光。 + *@param position0 位置0。 + *@param position1 位置1。 + */ + __proto.addGlitterByPositions=function(position0,position1){ + this._templet.addVertexPosition(position0,position1); + } + + /** + *通过位置和速度添加刀光。 + *@param position0 位置0。 + *@param velocity0 速度0。 + *@param position1 位置1。 + *@param velocity1 速度1。 + */ + __proto.addGlitterByPositionsVelocitys=function(position0,velocity0,position1,velocity1){ + this._templet.addVertexPositionVelocity(position0,velocity0,position1,velocity1); + } + + __proto.cloneTo=function(destObject){ + _super.prototype.cloneTo.call(this,destObject); + var destGlitter=destObject; + var destTemplet=destGlitter.templet; + destTemplet.lifeTime=this._templet.lifeTime; + destTemplet.minSegmentDistance=this._templet.minSegmentDistance; + destTemplet.minInterpDistance=this._templet.minInterpDistance; + destTemplet.maxSlerpCount=this._templet.maxSlerpCount; + this._templet.color.cloneTo(destTemplet.color); + destTemplet._maxSegments=this._templet._maxSegments; + var destGlitterRender=destGlitter._glitterRender; + destGlitterRender.sharedMaterials=this._glitterRender.sharedMaterials; + destGlitterRender.enable=this._glitterRender.enable; + } + + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._glitterRender._destroy(); + this._templet=null; + } + + /** + *获取闪光模板。 + *@return 闪光模板。 + */ + __getset(0,__proto,'templet',function(){ + return this._templet; + }); + + /** + *获取刀光渲染器。 + *@return 刀光渲染器。 + */ + __getset(0,__proto,'glitterRender',function(){ + return this._glitterRender; + }); + + return Glitter; + })(Sprite3D) + + + /** + *LightSprite 类用于创建灯光的父类。 + */ + //class laya.d3.core.light.LightSprite extends laya.d3.core.Sprite3D + var LightSprite=(function(_super){ + function LightSprite(){ + this._diffuseColor=null; + this._ambientColor=null; + this._specularColor=null; + this._reflectColor=null; + LightSprite.__super.call(this); + this.on(/*laya.events.Event.ADDED*/"added",this,this._onAdded); + this.on(/*laya.events.Event.REMOVED*/"removed",this,this._onRemoved); + this._diffuseColor=new Vector3(0.8,0.8,0.8); + this._ambientColor=new Vector3(0.6,0.6,0.6); + this._specularColor=new Vector3(1.0,1.0,1.0); + this._reflectColor=new Vector3(1.0,1.0,1.0); + } + + __class(LightSprite,'laya.d3.core.light.LightSprite',_super); + var __proto=LightSprite.prototype; + /** + *@private + *灯光节点移除事件处理函数。 + */ + __proto._onRemoved=function(){ + this.scene._removeLight(this); + } + + /** + *@private + *灯光节点添加事件处理函数。 + */ + __proto._onAdded=function(){ + this.scene._addLight(this); + } + + /** + *更新灯光相关渲染状态参数。 + *@param state 渲染状态参数。 + */ + __proto.updateToWorldState=function(state){} + /** + *设置灯光的漫反射颜色。 + *@param value 灯光的漫反射颜色。 + */ + /** + *获取灯光的漫反射颜色。 + *@return 灯光的漫反射颜色。 + */ + __getset(0,__proto,'diffuseColor',function(){ + return this._diffuseColor; + },function(value){ + this._diffuseColor=value; + }); + + /** + *设置灯光的环境光颜色。 + *@param value 灯光的环境光颜色。 + */ + /** + *获取灯光的环境光颜色。 + *@return 灯光的环境光颜色。 + */ + __getset(0,__proto,'ambientColor',function(){ + return this._ambientColor; + },function(value){ + this._ambientColor=value; + }); + + /** + *获取灯光的类型。 + *@return 灯光的类型。 + */ + __getset(0,__proto,'lightType',function(){ + return-1; + }); + + /** + *设置灯光的高光颜色。 + *@param value 灯光的高光颜色。 + */ + /** + *获取灯光的高光颜色。 + *@return 灯光的高光颜色。 + */ + __getset(0,__proto,'specularColor',function(){ + return this._specularColor; + },function(value){ + this._specularColor=value; + }); + + /** + *设置灯光的反射颜色。 + *@param value 灯光的反射颜色。 + */ + /** + *获取灯光的反射颜色。 + *@return 灯光的反射颜色。 + */ + __getset(0,__proto,'reflectColor',function(){ + return this._reflectColor; + },function(value){ + this._reflectColor=value; + }); + + LightSprite.TYPE_DIRECTIONLIGHT=1; + LightSprite.TYPE_POINTLIGHT=2; + LightSprite.TYPE_SPOTLIGHT=3; + return LightSprite; + })(Sprite3D) + + + /** + *MeshSprite3D 类用于创建网格。 + */ + //class laya.d3.core.MeshSprite3D extends laya.d3.core.Sprite3D + var MeshSprite3D=(function(_super){ + function MeshSprite3D(mesh,name){ + this._meshFilter=null; + this._meshRender=null; + MeshSprite3D.__super.call(this,name); + this._meshFilter=new MeshFilter(this); + this._meshRender=new MeshRender(this); + this._meshFilter.on(/*laya.events.Event.MESH_CHANGED*/"meshchanged",this,this._onMeshChanged); + this._meshRender.on(/*laya.events.Event.MATERIAL_CHANGED*/"materialchanged",this,this._onMaterialChanged); + if (mesh){ + this._meshFilter.sharedMesh=mesh; + if ((mesh instanceof laya.d3.resource.models.Mesh )) + if (mesh.loaded) + this._meshRender.sharedMaterials=(mesh).materials; + else + mesh.once(/*laya.events.Event.LOADED*/"loaded",this,this._applyMeshMaterials); + } + } + + __class(MeshSprite3D,'laya.d3.core.MeshSprite3D',_super); + var __proto=MeshSprite3D.prototype; + /**@private */ + __proto._changeRenderObjectByMesh=function(index){ + var renderObjects=this._meshRender.renderObject._renderElements; + var renderElement=renderObjects[index]; + (renderElement)|| (renderElement=renderObjects[index]=new RenderElement()); + renderElement._renderObject=this._meshRender.renderObject; + var material=this._meshRender.sharedMaterials[index]; + (material)|| (material=StandardMaterial.defaultMaterial); + var element=this._meshFilter.sharedMesh.getRenderElement(index); + renderElement._mainSortID=this._getSortID(element,material); + renderElement._sprite3D=this; + renderElement.renderObj=element; + renderElement._material=material; + return renderElement; + } + + /**@private */ + __proto._changeRenderObjectByMaterial=function(index,material){ + var renderElement=this._meshRender.renderObject._renderElements[index]; + var element=this._meshFilter.sharedMesh.getRenderElement(index); + renderElement._mainSortID=this._getSortID(element,material); + renderElement._sprite3D=this; + renderElement.renderObj=element; + renderElement._material=material; + return renderElement; + } + + /**@private */ + __proto._changeRenderObjectsByMesh=function(){ + var renderElementsCount=this._meshFilter.sharedMesh.getRenderElementsCount(); + this._meshRender.renderObject._renderElements.length=renderElementsCount; + for (var i=0;i < renderElementsCount;i++) + this._changeRenderObjectByMesh(i); + } + + /**@private */ + __proto._onMeshChanged=function(meshFilter){ + var mesh=meshFilter.sharedMesh; + if (mesh.loaded) + this._changeRenderObjectsByMesh(); + else + mesh.once(/*laya.events.Event.LOADED*/"loaded",this,this._onMeshLoaded); + } + + /**@private */ + __proto._onMeshLoaded=function(sender){ + (sender===this.meshFilter.sharedMesh)&& (this._changeRenderObjectsByMesh()); + } + + /**@private */ + __proto._onMaterialChanged=function(meshRender,index,material){ + var renderElementCount=this._meshRender.renderObject._renderElements.length; + (index < renderElementCount)&& this._changeRenderObjectByMaterial(index,material); + } + + /**@private */ + __proto._clearSelfRenderObjects=function(){ + this.scene.removeFrustumCullingObject(this._meshRender.renderObject); + } + + /**@private */ + __proto._addSelfRenderObjects=function(){ + this.scene.addFrustumCullingObject(this._meshRender.renderObject); + } + + /**@private */ + __proto._applyMeshMaterials=function(mesh){ + var shaderMaterials=this._meshRender.sharedMaterials; + var meshMaterials=mesh.materials; + for (var i=0,n=meshMaterials.length;i < n;i++) + (shaderMaterials[i])|| (shaderMaterials[i]=meshMaterials[i]); + this._meshRender.sharedMaterials=shaderMaterials; + } + + /** + *@private + */ + __proto._update=function(state){ + state.owner=this; + if (this._enable){ + this._updateComponents(state); + this._lateUpdateComponents(state); + } + Stat.spriteCount++; + this._childs.length && this._updateChilds(state); + } + + __proto.cloneTo=function(destObject){ + _super.prototype.cloneTo.call(this,destObject); + var meshSprite3D=destObject; + meshSprite3D._meshFilter.sharedMesh=this._meshFilter.sharedMesh; + var destMeshRender=meshSprite3D._meshRender; + destMeshRender.enable=this._meshRender.enable; + destMeshRender.sharedMaterials=this._meshRender.sharedMaterials; + destMeshRender.castShadow=this._meshRender.castShadow; + destMeshRender.receiveShadow=this._meshRender.receiveShadow; + } + + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._meshFilter._destroy(); + this._meshRender._destroy(); + } + + /** + *获取网格过滤器。 + *@return 网格过滤器。 + */ + __getset(0,__proto,'meshFilter',function(){ + return this._meshFilter; + }); + + /** + *获取网格渲染器。 + *@return 网格渲染器。 + */ + __getset(0,__proto,'meshRender',function(){ + return this._meshRender; + }); + + return MeshSprite3D; + })(Sprite3D) + + + /** + *Particle3D 3D粒子。 + */ + //class laya.d3.core.particle.Particle3D extends laya.d3.core.Sprite3D + var Particle3D=(function(_super){ + function Particle3D(setting){ + this._setting=null; + this._templet=null; + this._particleRender=null; + Particle3D.__super.call(this); + this._setting=setting; + this._particleRender=new ParticleRender(this); + this._particleRender.on(/*laya.events.Event.MATERIAL_CHANGED*/"materialchanged",this,this._onMaterialChanged); + var material=new ParticleMaterial(); + if (setting.textureName){ + material.diffuseTexture=Texture2D.load(setting.textureName); + } + this._particleRender.sharedMaterial=material; + this._templet=new ParticleTemplet3D(this,setting); + if (setting.blendState===0) + material.renderMode=/*laya.d3.core.material.BaseMaterial.RENDERMODE_DEPTHREAD_TRANSPARENT*/5; + else if (setting.blendState===1) + material.renderMode=/*laya.d3.core.material.BaseMaterial.RENDERMODE_DEPTHREAD_ADDTIVE*/7; + this._changeRenderObject(0); + } + + __class(Particle3D,'laya.d3.core.particle.Particle3D',_super); + var __proto=Particle3D.prototype; + /**@private */ + __proto._changeRenderObject=function(index){ + var renderObjects=this._particleRender.renderObject._renderElements; + var renderElement=renderObjects[index]; + (renderElement)|| (renderElement=renderObjects[index]=new RenderElement()); + renderElement._renderObject=this._particleRender.renderObject; + var material=this._particleRender.sharedMaterials[index]; + (material)|| (material=ParticleMaterial.defaultMaterial); + var element=this._templet; + renderElement._mainSortID=0; + renderElement._sprite3D=this; + renderElement.renderObj=element; + renderElement._material=material; + return renderElement; + } + + /**@private */ + __proto._onMaterialChanged=function(_particleRender,index,material){ + var renderElementCount=_particleRender.renderObject._renderElements.length; + (index < renderElementCount)&& this._changeRenderObject(index); + } + + /**@private */ + __proto._clearSelfRenderObjects=function(){ + this.scene.removeFrustumCullingObject(this._particleRender.renderObject); + } + + /**@private */ + __proto._addSelfRenderObjects=function(){ + this.scene.addFrustumCullingObject(this._particleRender.renderObject); + } + + /** + *更新粒子。 + *@param state 渲染相关状态参数。 + */ + __proto._update=function(state){ + this._templet.update(state.elapsedTime); + state.owner=this; + Stat.spriteCount++; + this._childs.length && this._updateChilds(state); + } + + /** + *添加粒子。 + *@param position 粒子位置。 + *@param velocity 粒子速度。 + */ + __proto.addParticle=function(position,velocity){ + Vector3.add(this.transform.localPosition,position,position); + this._templet.addParticle(position,velocity); + } + + __proto.cloneTo=function(destObject){ + _super.prototype.cloneTo.call(this,destObject); + var destParticle3D=destObject; + destParticle3D._templet=this._templet; + var destParticleRender=destParticle3D._particleRender; + destParticleRender.sharedMaterials=this._particleRender.sharedMaterials; + destParticleRender.enable=this._particleRender.enable; + } + + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._particleRender._destroy(); + this._templet=null; + } + + /** + *获取粒子模板。 + *@return 粒子模板。 + */ + __getset(0,__proto,'templet',function(){ + return this._templet; + }); + + /** + *获取粒子渲染器。 + *@return 粒子渲染器。 + */ + __getset(0,__proto,'particleRender',function(){ + return this._particleRender; + }); + + return Particle3D; + })(Sprite3D) + + + /** + *ShuriKenParticle3D 3D粒子。 + */ + //class laya.d3.core.particleShuriKen.ShuriKenParticle3D extends laya.d3.core.Sprite3D + var ShuriKenParticle3D=(function(_super){ + function ShuriKenParticle3D(material){ + this._particleSystem=null; + this._particleRender=null; + ShuriKenParticle3D.__super.call(this); + this._particleRender=new ShurikenParticleRender(this); + this._particleRender.on(/*laya.events.Event.MATERIAL_CHANGED*/"materialchanged",this,this._onMaterialChanged); + this._particleSystem=new ShurikenParticleSystem(this); + this._changeRenderObject(0); + (material)&& (this._particleRender.sharedMaterial=material); + } + + __class(ShuriKenParticle3D,'laya.d3.core.particleShuriKen.ShuriKenParticle3D',_super); + var __proto=ShuriKenParticle3D.prototype; + /**@private */ + __proto._changeRenderObject=function(index){ + var renderObjects=this._particleRender.renderObject._renderElements; + var renderElement=renderObjects[index]; + (renderElement)|| (renderElement=renderObjects[index]=new RenderElement()); + renderElement._renderObject=this._particleRender.renderObject; + var material=this._particleRender.sharedMaterials[index]; + (material)|| (material=ShurikenParticleMaterial.defaultMaterial); + var element=this._particleSystem; + renderElement._mainSortID=0; + renderElement._sprite3D=this; + renderElement.renderObj=element; + renderElement._material=material; + return renderElement; + } + + /**@private */ + __proto._onMaterialChanged=function(_particleRender,index,material){ + var renderElementCount=_particleRender.renderObject._renderElements.length; + (index < renderElementCount)&& this._changeRenderObject(index); + } + + /**@private */ + __proto._clearSelfRenderObjects=function(){ + this.scene.removeFrustumCullingObject(this._particleRender.renderObject); + } + + /**@private */ + __proto._addSelfRenderObjects=function(){ + this.scene.addFrustumCullingObject(this._particleRender.renderObject); + } + + /** + *更新粒子。 + *@param state 渲染相关状态参数。 + */ + __proto._update=function(state){ + state.owner=this; + this._particleSystem.update(state); + Stat.spriteCount++; + this._childs.length && this._updateChilds(state); + } + + __proto.cloneTo=function(destObject){ + _super.prototype.cloneTo.call(this,destObject); + var destShuriKenParticle3D=destObject; + var destParticleSystem=destShuriKenParticle3D._particleSystem; + destParticleSystem.duration=this._particleSystem.duration; + destParticleSystem.looping=this._particleSystem.looping; + destParticleSystem.prewarm=this._particleSystem.prewarm; + destParticleSystem.startDelayType=this._particleSystem.startDelayType; + destParticleSystem.startDelay=this._particleSystem.startDelay; + destParticleSystem.startDelayMin=this._particleSystem.startDelayMin; + destParticleSystem.startDelayMax=this._particleSystem.startDelayMax; + destParticleSystem.startLifetimeType=this._particleSystem.startLifetimeType; + destParticleSystem.startLifetimeConstant=this._particleSystem.startLifetimeConstant; + this._particleSystem.startLifeTimeGradient.cloneTo(destParticleSystem.startLifeTimeGradient); + destParticleSystem.startLifetimeConstantMin=this._particleSystem.startLifetimeConstantMin; + destParticleSystem.startLifetimeConstantMax=this._particleSystem.startLifetimeConstantMax; + this._particleSystem.startLifeTimeGradientMin.cloneTo(destParticleSystem.startLifeTimeGradientMin); + this._particleSystem.startLifeTimeGradientMax.cloneTo(destParticleSystem.startLifeTimeGradientMax); + destParticleSystem.startSpeedType=this._particleSystem.startSpeedType; + destParticleSystem.startSpeedConstant=this._particleSystem.startSpeedConstant; + destParticleSystem.startSpeedConstantMin=this._particleSystem.startSpeedConstantMin; + destParticleSystem.startSpeedConstantMax=this._particleSystem.startSpeedConstantMax; + destParticleSystem.threeDStartSize=this._particleSystem.threeDStartSize; + destParticleSystem.startSizeType=this._particleSystem.startSizeType; + destParticleSystem.startSizeConstant=this._particleSystem.startSizeConstant; + this._particleSystem.startSizeConstantSeparate.cloneTo(destParticleSystem.startSizeConstantSeparate); + destParticleSystem.startSizeConstantMin=this._particleSystem.startSizeConstantMin; + destParticleSystem.startSizeConstantMax=this._particleSystem.startSizeConstantMax; + this._particleSystem.startSizeConstantMinSeparate.cloneTo(destParticleSystem.startSizeConstantMinSeparate); + this._particleSystem.startSizeConstantMaxSeparate.cloneTo(destParticleSystem.startSizeConstantMaxSeparate); + destParticleSystem.threeDStartRotation=this._particleSystem.threeDStartRotation; + destParticleSystem.startRotationType=this._particleSystem.startRotationType; + destParticleSystem.startRotationConstant=this._particleSystem.startRotationConstant; + this._particleSystem.startRotationConstantSeparate.cloneTo(destParticleSystem.startRotationConstantSeparate); + destParticleSystem.startRotationConstantMin=this._particleSystem.startRotationConstantMin; + destParticleSystem.startRotationConstantMax=this._particleSystem.startRotationConstantMax; + this._particleSystem.startRotationConstantMinSeparate.cloneTo(destParticleSystem.startRotationConstantMinSeparate); + this._particleSystem.startRotationConstantMaxSeparate.cloneTo(destParticleSystem.startRotationConstantMaxSeparate); + destParticleSystem.randomizeRotationDirection=this._particleSystem.randomizeRotationDirection; + destParticleSystem.startColorType=this._particleSystem.startColorType; + this._particleSystem.startColorConstant.cloneTo(destParticleSystem.startColorConstant); + this._particleSystem.startColorConstantMin.cloneTo(destParticleSystem.startColorConstantMin); + this._particleSystem.startColorConstantMax.cloneTo(destParticleSystem.startColorConstantMax); + this._particleSystem.gravity.cloneTo(destParticleSystem.gravity); + destParticleSystem.gravityModifier=this._particleSystem.gravityModifier; + destParticleSystem.simulationSpace=this._particleSystem.simulationSpace; + destParticleSystem.scaleMode=this._particleSystem.scaleMode; + destParticleSystem.playOnAwake=this._particleSystem.playOnAwake; + this._particleSystem.velocityOverLifetime.cloneTo(destParticleSystem.velocityOverLifetime); + this._particleSystem.colorOverLifetime.cloneTo(destParticleSystem.colorOverLifetime); + this._particleSystem.sizeOverLifetime.cloneTo(destParticleSystem.sizeOverLifetime); + this._particleSystem.rotationOverLifetime.cloneTo(destParticleSystem.rotationOverLifetime); + this._particleSystem.textureSheetAnimation.cloneTo(destParticleSystem.textureSheetAnimation); + destParticleSystem.isPerformanceMode=this._particleSystem.isPerformanceMode; + var destParticleRender=destShuriKenParticle3D._particleRender; + destParticleRender.sharedMaterials=this._particleRender.sharedMaterials; + destParticleRender.enable=this._particleRender.enable; + destParticleRender.renderMode=this._particleRender.renderMode; + destParticleRender.stretchedBillboardCameraSpeedScale=this._particleRender.stretchedBillboardCameraSpeedScale; + destParticleRender.stretchedBillboardSpeedScale=this._particleRender.stretchedBillboardSpeedScale; + destParticleRender.stretchedBillboardLengthScale=this._particleRender.stretchedBillboardLengthScale; + } + + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._particleRender._destroy(); + this._particleSystem._destroy(); + this._particleRender=null; + this._particleSystem=null; + } + + /** + *获取粒子系统。 + *@return 粒子系统。 + */ + __getset(0,__proto,'particleSystem',function(){ + return this._particleSystem; + }); + + /** + *获取粒子渲染器。 + *@return 粒子渲染器。 + */ + __getset(0,__proto,'particleRender',function(){ + return this._particleRender; + }); + + return ShuriKenParticle3D; + })(Sprite3D) + + + /** + *... + *@author ... + */ + //class laya.d3.core.material.GlitterMaterial extends laya.d3.core.material.BaseMaterial + var GlitterMaterial=(function(_super){ + function GlitterMaterial(){ + GlitterMaterial.__super.call(this); + this.setShaderName("GLITTER"); + } + + __class(GlitterMaterial,'laya.d3.core.material.GlitterMaterial',_super); + var __proto=GlitterMaterial.prototype; + __proto._setLoopShaderParams=function(state,projectionView,worldMatrix,mesh,material){ + var glitter=state.owner; + var templet=glitter.templet; + state.shaderValue.pushValue("UNICOLOR",templet.color.elements); + state.shaderValue.pushValue("MVPMATRIX",state.projectionViewMatrix.elements); + state.shaderValue.pushValue("DURATION",templet.lifeTime); + state.shaderValue.pushValue("ALBEDO",templet._albedo.elements); + state.shaderValue.pushValue("CURRENTTIME",templet._currentTime); + } + + /** + *设置漫反射贴图。 + *@param value 漫反射贴图。 + */ + /** + *获取漫反射贴图。 + *@return 漫反射贴图。 + */ + __getset(0,__proto,'diffuseTexture',function(){ + return this._getTexture(0); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + } + this._setTexture(value,0,"DIFFUSETEXTURE"); + }); + + GlitterMaterial.load=function(url){ + return Laya.loader.create(url,null,null,GlitterMaterial); + } + + GlitterMaterial.TIME="TIME"; + GlitterMaterial.DIFFUSETEXTURE="DIFFUSETEXTURE"; + GlitterMaterial.MVPMATRIX="MVPMATRIX"; + GlitterMaterial.ALBEDO="ALBEDO"; + GlitterMaterial.CURRENTTIME="CURRENTTIME"; + GlitterMaterial.UNICOLOR="UNICOLOR"; + GlitterMaterial.DURATION="DURATION"; + GlitterMaterial._diffuseTextureIndex=0; + __static(GlitterMaterial, + ['defaultMaterial',function(){return this.defaultMaterial=new GlitterMaterial();} + ]); + return GlitterMaterial; + })(BaseMaterial) + + + /** + *... + *@author ... + */ + //class laya.d3.core.material.ParticleMaterial extends laya.d3.core.material.BaseMaterial + var ParticleMaterial=(function(_super){ + function ParticleMaterial(){ + ParticleMaterial.__super.call(this); + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.PARTICLE3D*/0x40000); + this.setShaderName("PARTICLE"); + } + + __class(ParticleMaterial,'laya.d3.core.material.ParticleMaterial',_super); + var __proto=ParticleMaterial.prototype; + __proto._setLoopShaderParams=function(state,projectionView,worldMatrix,mesh,material){ + var particle=state.owner; + var templet=particle.templet; + var setting=templet.settings; + state.shaderValue.pushValue("DURATION",setting.duration); + state.shaderValue.pushValue("GRAVITY",setting.gravity); + state.shaderValue.pushValue("ENDVELOCITY",setting.endVelocity); + state.shaderValue.pushValue("MVPMATRIX",worldMatrix.elements); + state.shaderValue.pushValue("MATRIX1",state.viewMatrix.elements); + state.shaderValue.pushValue("MATRIX2",state.projectionMatrix.elements); + var aspectRadio=state.viewport.width / state.viewport.height; + var viewportScale=new Vector2(0.5 / aspectRadio,-0.5); + state.shaderValue.pushValue("VIEWPORTSCALE",viewportScale.elements); + state.shaderValue.pushValue("CURRENTTIME",templet._currentTime); + } + + /** + *设置漫反射贴图。 + *@param value 漫反射贴图。 + */ + /** + *获取漫反射贴图。 + *@return 漫反射贴图。 + */ + __getset(0,__proto,'diffuseTexture',function(){ + return this._getTexture(0); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + } + this._setTexture(value,0,"DIFFUSETEXTURE"); + }); + + ParticleMaterial.load=function(url){ + return Laya.loader.create(url,null,null,ParticleMaterial); + } + + ParticleMaterial.WORLDMATRIX="MVPMATRIX"; + ParticleMaterial.VIEWMATRIX="MATRIX1"; + ParticleMaterial.PROJECTIONMATRIX="MATRIX2"; + ParticleMaterial.VIEWPORTSCALE="VIEWPORTSCALE"; + ParticleMaterial.CURRENTTIME="CURRENTTIME"; + ParticleMaterial.DURATION="DURATION"; + ParticleMaterial.GRAVITY="GRAVITY"; + ParticleMaterial.ENDVELOCITY="ENDVELOCITY"; + ParticleMaterial.DIFFUSETEXTURE="DIFFUSETEXTURE"; + ParticleMaterial._diffuseTextureIndex=0; + __static(ParticleMaterial, + ['defaultMaterial',function(){return this.defaultMaterial=new ParticleMaterial();} + ]); + return ParticleMaterial; + })(BaseMaterial) + + + /** + *... + *@author ... + */ + //class laya.d3.core.material.StandardMaterial extends laya.d3.core.material.BaseMaterial + var StandardMaterial=(function(_super){ + function StandardMaterial(){ + this._transformUV=null; + StandardMaterial.__super.call(this); + this._setColor(0,"MATERIALAMBIENT",new Vector3(0.6,0.6,0.6)); + this._setColor(1,"MATERIALDIFFUSE",new Vector3(1.0,1.0,1.0)); + this._setColor(2,"MATERIALSPECULAR",new Vector4(1.0,1.0,1.0,8.0)); + this._setColor(3,"MATERIALREFLECT",new Vector3(1.0,1.0,1.0)); + this._setColor(4,"ALBEDO",new Vector4(1.0,1.0,1.0,1.0)); + this._setNumber(0,"ALPHATESTVALUE",0.5); + this.setShaderName("SIMPLE"); + } + + __class(StandardMaterial,'laya.d3.core.material.StandardMaterial',_super); + var __proto=StandardMaterial.prototype; + /** + *禁用灯光。 + */ + __proto.disableLight=function(){ + this._addDisableShaderDefine(/*laya.d3.shader.ShaderDefines3D.POINTLIGHT*/0x2000 | /*laya.d3.shader.ShaderDefines3D.SPOTLIGHT*/0x4000 | /*laya.d3.shader.ShaderDefines3D.DIRECTIONLIGHT*/0x1000); + } + + /** + *禁用雾化。 + */ + __proto.disableFog=function(){ + this._addDisableShaderDefine(/*laya.d3.shader.ShaderDefines3D.FOG*/0x200); + } + + __proto._setLoopShaderParams=function(state,projectionView,worldMatrix,mesh,material){ + (this._transformUV)&& (this._transformUV.matrix); + var pvw; + if (worldMatrix===Matrix4x4.DEFAULT){ + pvw=projectionView; + }else { + pvw=StandardMaterial._tempMatrix4x40; + Matrix4x4.multiply(projectionView,worldMatrix,pvw); + } + state.shaderValue.pushValue("MATRIX1",worldMatrix.elements); + state.shaderValue.pushValue("MVPMATRIX",pvw.elements); + } + + /** + *设置环境光颜色。 + *@param value 环境光颜色。 + */ + __getset(0,__proto,'ambientColor',function(){ + return this._getColor(0); + },function(value){ + this._setColor(0,"MATERIALAMBIENT",value); + }); + + /** + *设置反射率。 + *@param value 反射率。 + */ + __getset(0,__proto,'albedo',function(){ + return this._getColor(4); + },function(value){ + this._setColor(4,"ALBEDO",value); + }); + + /** + *设置漫反射光颜色。 + *@param value 漫反射光颜色。 + */ + __getset(0,__proto,'diffuseColor',function(){ + return this._getColor(1); + },function(value){ + this._setColor(1,"MATERIALDIFFUSE",value); + }); + + /** + *设置高光颜色。 + *@param value 高光颜色。 + */ + __getset(0,__proto,'specularColor',function(){ + return this._getColor(2); + },function(value){ + this._setColor(2,"MATERIALSPECULAR",value); + }); + + /** + *设置法线贴图。 + *@param value 法线贴图。 + */ + /** + *获取法线贴图。 + *@return 法线贴图。 + */ + __getset(0,__proto,'normalTexture',function(){ + return this._getTexture(1); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.NORMALMAP*/0x2); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.NORMALMAP*/0x2); + } + this._setTexture(value,1,"NORMALTEXTURE"); + }); + + /** + *设置反射颜色。 + *@param value 反射颜色。 + */ + __getset(0,__proto,'reflectColor',function(){ + return this._getColor(3); + },function(value){ + this._setColor(3,"MATERIALREFLECT",value); + }); + + /** + *设置漫反射贴图。 + *@param value 漫反射贴图。 + */ + /** + *获取漫反射贴图。 + *@return 漫反射贴图。 + */ + __getset(0,__proto,'diffuseTexture',function(){ + return this._getTexture(0); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + } + this._setTexture(value,0,"DIFFUSETEXTURE"); + }); + + /** + *设置透明测试模式裁剪值。 + *@param value 透明测试模式裁剪值。 + */ + /** + *获取透明测试模式裁剪值。 + *@return 透明测试模式裁剪值。 + */ + __getset(0,__proto,'alphaTestValue',function(){ + return this._getNumber(0); + },function(value){ + this._setNumber(0,"ALPHATESTVALUE",value); + }); + + /** + *设置高光贴图。 + *@param value 高光贴图。 + */ + /** + *获取高光贴图。 + *@return 高光贴图。 + */ + __getset(0,__proto,'specularTexture',function(){ + return this._getTexture(2); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.SPECULARMAP*/0x4); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.SPECULARMAP*/0x4); + } + this._setTexture(value,2,"SPECULARTEXTURE"); + }); + + /** + *设置放射贴图。 + *@param value 放射贴图。 + */ + /** + *获取放射贴图。 + *@return 放射贴图。 + */ + __getset(0,__proto,'emissiveTexture',function(){ + return this._getTexture(3); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.EMISSIVEMAP*/0x8); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.EMISSIVEMAP*/0x8); + } + this._setTexture(value,3,"EMISSIVETEXTURE"); + }); + + /** + *设置环境贴图。 + *@param value 环境贴图。 + */ + /** + *获取环境贴图。 + *@return 环境贴图。 + */ + __getset(0,__proto,'ambientTexture',function(){ + return this._getTexture(4); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.AMBIENTMAP*/0x10); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.AMBIENTMAP*/0x10); + } + this._setTexture(value,4,"AMBIENTTEXTURE"); + }); + + /** + *设置反射贴图。 + *@param value 反射贴图。 + */ + /** + *获取反射贴图。 + *@return 反射贴图。 + */ + __getset(0,__proto,'reflectTexture',function(){ + return this._getTexture(5); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.REFLECTMAP*/0x20); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.REFLECTMAP*/0x20); + } + this._setTexture(value,5,"REFLECTTEXTURE"); + }); + + /** + *设置UV变换。 + *@param value UV变换。 + */ + /** + *获取UV变换。 + *@return UV变换。 + */ + __getset(0,__proto,'transformUV',function(){ + return this._transformUV; + },function(value){ + this._transformUV=value; + this._setMatrix4x4(0,"MATRIX2",value.matrix); + if (value) + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.UVTRANSFORM*/0x100); + else + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.UVTRANSFORM*/0x100); + }); + + StandardMaterial.load=function(url){ + return Laya.loader.create(url,null,null,StandardMaterial); + } + + StandardMaterial.WORLDMATRIX="MATRIX1"; + StandardMaterial.MVPMATRIX="MVPMATRIX"; + StandardMaterial.DIFFUSETEXTURE="DIFFUSETEXTURE"; + StandardMaterial.NORMALTEXTURE="NORMALTEXTURE"; + StandardMaterial.SPECULARTEXTURE="SPECULARTEXTURE"; + StandardMaterial.EMISSIVETEXTURE="EMISSIVETEXTURE"; + StandardMaterial.AMBIENTTEXTURE="AMBIENTTEXTURE"; + StandardMaterial.REFLECTTEXTURE="REFLECTTEXTURE"; + StandardMaterial.Bones="MATRIXARRAY0"; + StandardMaterial.ALBEDO="ALBEDO"; + StandardMaterial.ALPHATESTVALUE="ALPHATESTVALUE"; + StandardMaterial.UVANIAGE="UVAGEX"; + StandardMaterial.MATERIALAMBIENT="MATERIALAMBIENT"; + StandardMaterial.MATERIALDIFFUSE="MATERIALDIFFUSE"; + StandardMaterial.MATERIALSPECULAR="MATERIALSPECULAR"; + StandardMaterial.MATERIALREFLECT="MATERIALREFLECT"; + StandardMaterial.UVMATRIX="MATRIX2"; + StandardMaterial.UVAGE="FLOAT0"; + StandardMaterial._ambientColorIndex=0; + StandardMaterial._diffuseColorIndex=1; + StandardMaterial._speclarColorIndex=2; + StandardMaterial._reflectColorIndex=3; + StandardMaterial._albedoColorIndex=4; + StandardMaterial._alphaTestValueIndex=0; + StandardMaterial._diffuseTextureIndex=0; + StandardMaterial._normalTextureIndex=1; + StandardMaterial._specularTextureIndex=2; + StandardMaterial._emissiveTextureIndex=3; + StandardMaterial._ambientTextureIndex=4; + StandardMaterial._reflectTextureIndex=5; + StandardMaterial.TRANSFORMUV=0; + __static(StandardMaterial, + ['_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'defaultMaterial',function(){return this.defaultMaterial=new StandardMaterial();} + ]); + return StandardMaterial; + })(BaseMaterial) + + + /** + *IndexBuffer3D 类用于创建索引缓冲。 + */ + //class laya.d3.graphics.IndexBuffer3D extends laya.webgl.utils.Buffer + var IndexBuffer3D=(function(_super){ + function IndexBuffer3D(indexType,indexCount,bufferUsage,canRead){ + this._indexType=null; + this._indexTypeByteCount=0; + this._indexCount=0; + this._canRead=false; + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + (canRead===void 0)&& (canRead=false); + IndexBuffer3D.__super.call(this); + this._indexType=indexType; + this._indexCount=indexCount; + this._bufferUsage=bufferUsage; + this._bufferType=/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893; + this._canRead=canRead; + this._bind(); + var byteLength=0; + if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort") + this._indexTypeByteCount=2; + else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte") + this._indexTypeByteCount=1; + else + throw new Error("unidentification index type."); + byteLength=this._indexTypeByteCount *indexCount; + this._byteLength=byteLength; + Buffer._gl.bufferData(this._bufferType,byteLength,this._bufferUsage); + if (canRead){ + if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort") + this._buffer=new Uint16Array(indexCount); + else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte") + this._buffer=new Uint8Array(indexCount); + this.memorySize=byteLength *2; + }else { + this.memorySize=byteLength; + } + } + + __class(IndexBuffer3D,'laya.d3.graphics.IndexBuffer3D',_super); + var __proto=IndexBuffer3D.prototype; + /** + *设置数据。 + *@param data 索引数据。 + *@param bufferOffset 索引缓冲中的偏移。 + *@param dataStartIndex 索引数据的偏移。 + *@param dataCount 索引数据的数量。 + */ + __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){ + (bufferOffset===void 0)&& (bufferOffset=0); + (dataStartIndex===void 0)&& (dataStartIndex=0); + (dataCount===void 0)&& (dataCount=4294967295); + var byteCount=0; + if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort"){ + byteCount=2; + if (dataStartIndex!==0 || dataCount!==4294967295) + data=new Uint16Array(data.buffer,dataStartIndex *byteCount,dataCount); + }else if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte"){ + byteCount=1; + if (dataStartIndex!==0 || dataCount!==4294967295) + data=new Uint8Array(data.buffer,dataStartIndex *byteCount,dataCount); + } + this._bind(); + Buffer._gl.bufferSubData(this._bufferType,bufferOffset *byteCount,data); + if (this._canRead){ + if (bufferOffset!==0 || dataStartIndex!==0 || dataCount!==4294967295){ + var maxLength=this._buffer.length-bufferOffset; + if (dataCount > maxLength) + dataCount=maxLength; + for (var i=0;i < dataCount;i++) + this._buffer[bufferOffset+i]=data[i]; + }else { + this._buffer=data; + } + } + } + + /** + *获取索引数据。 + *@return 索引数据。 + */ + __proto.getData=function(){ + if (this._canRead) + return this._buffer; + else + throw new Error("Can't read data from VertexBuffer with only write flag!"); + } + + /**彻底销毁索引缓冲。*/ + __proto.dispose=function(){ + this._buffer=null; + _super.prototype.dispose.call(this); + this.memorySize=0; + } + + /** + *获取索引类型。 + *@return 索引类型。 + */ + __getset(0,__proto,'indexType',function(){ + return this._indexType; + }); + + /** + *获取索引类型字节数量。 + *@return 索引类型字节数量。 + */ + __getset(0,__proto,'indexTypeByteCount',function(){ + return this._indexTypeByteCount; + }); + + /** + *获取索引个数。 + *@return 索引个数。 + */ + __getset(0,__proto,'indexCount',function(){ + return this._indexCount; + }); + + /** + *获取是否可读。 + *@return 是否可读。 + */ + __getset(0,__proto,'canRead',function(){ + return this._canRead; + }); + + IndexBuffer3D.INDEXTYPE_UBYTE="ubyte"; + IndexBuffer3D.INDEXTYPE_USHORT="ushort"; + IndexBuffer3D.create=function(indexType,indexCount,bufferUsage,canRead){ + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + (canRead===void 0)&& (canRead=false); + return new IndexBuffer3D(indexType,indexCount,bufferUsage,canRead); + } + + return IndexBuffer3D; + })(Buffer) + + + /** + *VertexBuffer3D 类用于创建顶点缓冲。 + */ + //class laya.d3.graphics.VertexBuffer3D extends laya.webgl.utils.Buffer + var VertexBuffer3D=(function(_super){ + function VertexBuffer3D(vertexDeclaration,vertexCount,bufferUsage,canRead){ + this._vertexDeclaration=null; + this._vertexCount=0; + this._canRead=false; + (canRead===void 0)&& (canRead=false); + VertexBuffer3D.__super.call(this); + this._vertexDeclaration=vertexDeclaration; + this._vertexCount=vertexCount; + this._bufferUsage=bufferUsage; + this._bufferType=/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892; + this._canRead=canRead; + this._bind(); + var byteLength=this._vertexDeclaration.vertexStride *vertexCount; + this.memorySize=byteLength; + this._byteLength=byteLength; + Buffer._gl.bufferData(this._bufferType,byteLength,this._bufferUsage); + canRead && (this._buffer=new Float32Array(byteLength / 4)); + } + + __class(VertexBuffer3D,'laya.d3.graphics.VertexBuffer3D',_super); + var __proto=VertexBuffer3D.prototype; + /** + *和索引缓冲一起绑定。 + *@param ib 索引缓冲。 + */ + __proto.bindWithIndexBuffer=function(ib){ + (ib)&& (ib._bind()); + this._bind(); + } + + /** + *设置数据。 + *@param data 顶点数据。 + *@param bufferOffset 顶点缓冲中的偏移。 + *@param dataStartIndex 顶点数据的偏移。 + *@param dataCount 顶点数据的数量。 + */ + __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){ + (bufferOffset===void 0)&& (bufferOffset=0); + (dataStartIndex===void 0)&& (dataStartIndex=0); + (dataCount===void 0)&& (dataCount=4294967295); + if (dataStartIndex!==0 || dataCount!==4294967295) + data=new Float32Array(data.buffer,dataStartIndex *4,dataCount); + this._bind(); + Buffer._gl.bufferSubData(this._bufferType,bufferOffset *4,data); + if (this._canRead){ + if (bufferOffset!==0 || dataStartIndex!==0 || dataCount!==4294967295){ + var maxLength=this._buffer.length-bufferOffset; + if (dataCount > maxLength) + dataCount=maxLength; + for (var i=0;i < dataCount;i++) + this._buffer[bufferOffset+i]=data[i]; + }else { + this._buffer=data; + } + } + } + + /** + *获取顶点数据。 + *@return 顶点数据。 + */ + __proto.getData=function(){ + if (this._canRead) + return this._buffer; + else + throw new Error("Can't read data from VertexBuffer with only write flag!"); + } + + /**销毁顶点缓冲。*/ + __proto.detoryResource=function(){ + var elements=this._vertexDeclaration.getVertexElements(); + for (var i=0;i < elements.length;i++) + WebGL.mainContext.disableVertexAttribArray(i); + _super.prototype.detoryResource.call(this); + } + + /**彻底销毁顶点缓冲。*/ + __proto.dispose=function(){ + _super.prototype.dispose.call(this); + this._buffer=null; + this._vertexDeclaration=null; + this.memorySize=0; + } + + /** + *获取顶点结构声明。 + *@return 顶点结构声明。 + */ + __getset(0,__proto,'vertexDeclaration',function(){ + return this._vertexDeclaration; + }); + + /** + *获取顶点个数。 + *@return 顶点个数。 + */ + __getset(0,__proto,'vertexCount',function(){ + return this._vertexCount; + }); + + /** + *获取是否可读。 + *@return 是否可读。 + */ + __getset(0,__proto,'canRead',function(){ + return this._canRead; + }); + + VertexBuffer3D.create=function(vertexDeclaration,vertexCount,bufferUsage,canRead){ + (bufferUsage===void 0)&& (bufferUsage=/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + (canRead===void 0)&& (canRead=false); + return new VertexBuffer3D(vertexDeclaration,vertexCount,bufferUsage,canRead); + } + + return VertexBuffer3D; + })(Buffer) + + + /** + *... + *@author ... + */ + //class laya.d3.core.particleShuriKen.ShurikenParticleMaterial extends laya.d3.core.material.BaseMaterial + var ShurikenParticleMaterial=(function(_super){ + function ShurikenParticleMaterial(){ + this._tempRotationMatrix=new Matrix4x4(); + this._uvLength=new Vector2(); + ShurikenParticleMaterial.__super.call(this); + this.setShaderName("PARTICLESHURIKEN"); + } + + __class(ShurikenParticleMaterial,'laya.d3.core.particleShuriKen.ShurikenParticleMaterial',_super); + var __proto=ShurikenParticleMaterial.prototype; + __proto._setLoopShaderParams=function(state,projectionView,worldMatrix,mesh,material){ + var particle=state.owner; + var particleSystem=particle.particleSystem; + var particleRender=particle.particleRender; + var transform=particle.transform; + var finalGravityE=ShurikenParticleMaterial._tempGravity.elements; + var gravityE=particleSystem.gravity.elements; + var gravityModifier=particleSystem.gravityModifier; + finalGravityE[0]=gravityE[0] *gravityModifier; + finalGravityE[1]=gravityE[1] *gravityModifier; + finalGravityE[2]=gravityE[2] *gravityModifier; + var shaderValues=state.shaderValue; + shaderValues.pushValue("GRAVITY",finalGravityE); + shaderValues.pushValue("SIMULATIONSPACE",particleSystem.simulationSpace); + switch (particleSystem.simulationSpace){ + case 0: + shaderValues.pushValue("WORLDPOSITION",Vector3.ZERO.elements); + break ; + case 1: + shaderValues.pushValue("WORLDPOSITION",transform.position.elements); + break ; + default : + throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid."); + } + Matrix4x4.createFromQuaternion(transform.rotation,this._tempRotationMatrix); + shaderValues.pushValue("WORLDROTATIONMATRIX",this._tempRotationMatrix.elements); + shaderValues.pushValue("THREEDSTARTROTATION",particleSystem.threeDStartRotation); + shaderValues.pushValue("SCALINGMODE",particleSystem.scaleMode); + switch (particleSystem.scaleMode){ + case 0: + shaderValues.pushValue("POSITIONSCALE",transform.scale.elements); + shaderValues.pushValue("SIZESCALE",transform.scale.elements); + break ; + case 1: + shaderValues.pushValue("POSITIONSCALE",transform.localScale.elements); + shaderValues.pushValue("SIZESCALE",transform.localScale.elements); + break ; + case 2: + shaderValues.pushValue("POSITIONSCALE",transform.scale.elements); + shaderValues.pushValue("SIZESCALE",Vector3.ONE.elements); + break ; + } + shaderValues.pushValue("CAMERADIRECTION",state.camera.forward.elements); + shaderValues.pushValue("CAMERAUP",state.camera.up.elements); + shaderValues.pushValue("MATRIX1",state.viewMatrix.elements); + shaderValues.pushValue("MATRIX2",state.projectionMatrix.elements); + shaderValues.pushValue("STRETCHEDBILLBOARDLENGTHSCALE",particleRender.stretchedBillboardLengthScale); + shaderValues.pushValue("STRETCHEDBILLBOARDSPEEDSCALE",particleRender.stretchedBillboardSpeedScale); + shaderValues.pushValue("CURRENTTIME",particleSystem.currentTime); + switch (particleRender.renderMode){ + case 0: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.SPHERHBILLBOARD*/0x80000); + break ; + case 1: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.STRETCHEDBILLBOARD*/0x100000); + break ; + case 2: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.HORIZONTALBILLBOARD*/0x200000); + break ; + case 3: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.VERTICALBILLBOARD*/0x400000); + break ; + }; + var velocityOverLifetime=particleSystem.velocityOverLifetime; + if (velocityOverLifetime && velocityOverLifetime.enbale){ + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.VELOCITYOVERLIFETIME*/0x10000000); + var velocity=velocityOverLifetime.velocity; + var velocityType=velocity.type; + shaderValues.pushValue("VOLTYPE",velocityType); + switch (velocityType){ + case 0: + shaderValues.pushValue("VOLVELOCITYCONST",velocity.constant.elements); + break ; + case 1: + shaderValues.pushValue("VOLVELOCITYGRADIENTX",velocity.gradientX._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTY",velocity.gradientY._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTZ",velocity.gradientZ._elements); + break ; + case 2: + shaderValues.pushValue("VOLVELOCITYCONST",velocity.constantMin.elements); + shaderValues.pushValue("VOLVELOCITYCONSTMAX",velocity.constantMax.elements); + break ; + case 3: + shaderValues.pushValue("VOLVELOCITYGRADIENTX",velocity.gradientXMin._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTXMAX",velocity.gradientXMax._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTY",velocity.gradientYMin._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTYMAX",velocity.gradientYMax._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTZ",velocity.gradientZMin._elements); + shaderValues.pushValue("VOLVELOCITYGRADIENTZMAX",velocity.gradientZMax._elements); + break ; + }; + var spaceType=velocityOverLifetime.space; + shaderValues.pushValue("VOLSPACETYPE",spaceType); + }; + var colorOverLifetime=particleSystem.colorOverLifetime; + if (colorOverLifetime && colorOverLifetime.enbale){ + var color=colorOverLifetime.color; + switch (color.type){ + case 1: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.COLOROVERLIFETIME*/0x800000); + var gradientColor=color.gradient; + shaderValues.pushValue("COLOROVERLIFEGRADIENTALPHAS",gradientColor._alphaElements); + shaderValues.pushValue("COLOROVERLIFEGRADIENTCOLORS",gradientColor._rgbElements); + break ; + case 3: + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.RANDOMCOLOROVERLIFETIME*/0x1000000); + var minGradientColor=color.gradientMin; + var maxGradientColor=color.gradientMax; + shaderValues.pushValue("COLOROVERLIFEGRADIENTALPHAS",minGradientColor._alphaElements); + shaderValues.pushValue("COLOROVERLIFEGRADIENTCOLORS",minGradientColor._rgbElements); + shaderValues.pushValue("MAXCOLOROVERLIFEGRADIENTALPHAS",maxGradientColor._alphaElements); + shaderValues.pushValue("MAXCOLOROVERLIFEGRADIENTCOLORS",maxGradientColor._rgbElements); + break ; + } + }; + var sizeOverLifetime=particleSystem.sizeOverLifetime; + if (sizeOverLifetime && sizeOverLifetime.enbale){ + var size=sizeOverLifetime.size; + var sizeType=size.type; + var sizeSeparate=false; + switch (sizeType){ + case 0: + sizeSeparate=size.separateAxes; + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.SIZEOVERLIFETIME*/0x2000000); + shaderValues.pushValue("SOLTYPE",sizeType); + shaderValues.pushValue("SOLSEPRARATE",sizeSeparate); + if (sizeSeparate){ + shaderValues.pushValue("SOLSIZEGRADIENTX",size.gradientSizeX._elements); + shaderValues.pushValue("SOLSIZEGRADIENTY",size.gradientSizeY._elements); + shaderValues.pushValue("SOLSizeGradientZ",size.gradientSizeZ._elements); + }else { + shaderValues.pushValue("SOLSIZEGRADIENT",size.gradientSize._elements); + } + break ; + case 2: + sizeSeparate=size.separateAxes; + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.SIZEOVERLIFETIME*/0x2000000); + shaderValues.pushValue("SOLTYPE",sizeType); + shaderValues.pushValue("SOLSEPRARATE",sizeSeparate); + if (sizeSeparate){ + shaderValues.pushValue("SOLSIZEGRADIENTX",size.gradientXMin._elements); + shaderValues.pushValue("SOLSIZEGRADIENTXMAX",size.gradientXMax._elements); + shaderValues.pushValue("SOLSIZEGRADIENTY",size.gradientYMin._elements); + shaderValues.pushValue("SOLSIZEGRADIENTYMAX",size.gradientYMax._elements); + shaderValues.pushValue("SOLSizeGradientZ",size.gradientZMin._elements); + shaderValues.pushValue("SOLSizeGradientZMAX",size.gradientZMax._elements); + }else { + shaderValues.pushValue("SOLSIZEGRADIENT",size.gradientMin._elements); + shaderValues.pushValue("SOLSizeGradientMax",size.gradientMax._elements); + } + break ; + } + }; + var rotationOverLifetime=particleSystem.rotationOverLifetime; + if (rotationOverLifetime && rotationOverLifetime.enbale){ + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.ROTATIONOVERLIFETIME*/0x4000000); + var rotation=rotationOverLifetime.angularVelocity; + var rotationType=rotation.type; + var rotationSeparate=rotation.separateAxes; + shaderValues.pushValue("ROLTYPE",rotationType); + shaderValues.pushValue("ROLSEPRARATE",rotationSeparate); + switch (rotationType){ + case 0: + if (rotationSeparate){ + shaderValues.pushValue("ROLANGULARVELOCITYCONSTSEPRARATE",rotation.constantSeparate.elements); + }else { + shaderValues.pushValue("ROLANGULARVELOCITYCONST",rotation.constant); + } + break ; + case 1: + if (rotationSeparate){ + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTX",rotation.gradientX._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTY",rotation.gradientY._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTZ",rotation.gradientZ._elements); + }else { + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENT",rotation.gradient._elements); + } + break ; + case 2: + if (rotationSeparate){ + shaderValues.pushValue("ROLANGULARVELOCITYCONSTSEPRARATE",rotation.constantMinSeparate.elements); + shaderValues.pushValue("ROLANGULARVELOCITYCONSTMAXSEPRARATE",rotation.constantMaxSeparate.elements); + }else { + shaderValues.pushValue("ROLANGULARVELOCITYCONST",rotation.constantMin); + shaderValues.pushValue("ROLANGULARVELOCITYCONSTMAX",rotation.constantMax); + } + break ; + case 3: + if (rotationSeparate){ + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTX",rotation.gradientXMin._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTXMAX",rotation.gradientXMax._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTY",rotation.gradientYMin._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTYMAX",rotation.gradientYMax._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTZ",rotation.gradientZMin._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTZMAX",rotation.gradientZMax._elements); + }else { + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENT",rotation.gradientMin._elements); + shaderValues.pushValue("ROLANGULARVELOCITYGRADIENTMAX",rotation.gradientMax._elements); + } + break ; + } + }; + var textureSheetAnimation=particleSystem.textureSheetAnimation; + if (textureSheetAnimation && textureSheetAnimation.enbale){ + var frameOverTime=textureSheetAnimation.frame; + var textureAniType=frameOverTime.type; + if (textureAniType===1 || textureAniType===3){ + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.TEXTURESHEETANIMATION*/0x8000000); + shaderValues.pushValue("TEXTURESHEETANIMATIONTYPE",textureAniType); + shaderValues.pushValue("TEXTURESHEETANIMATIONCYCLES",textureSheetAnimation.cycles); + var title=textureSheetAnimation.tiles; + var _uvLengthE=this._uvLength.elements; + _uvLengthE[0]=1.0 / title.x; + _uvLengthE[1]=1.0 / title.y; + shaderValues.pushValue("TEXTURESHEETANIMATIONSUBUVLENGTH",this._uvLength.elements); + } + switch (textureAniType){ + case 1: + shaderValues.pushValue("TEXTURESHEETANIMATIONGRADIENTUVS",frameOverTime.frameOverTimeData._elements); + break ; + case 3: + shaderValues.pushValue("TEXTURESHEETANIMATIONGRADIENTUVS",frameOverTime.frameOverTimeDataMin._elements); + shaderValues.pushValue("TEXTURESHEETANIMATIONGRADIENTMAXUVS",frameOverTime.frameOverTimeDataMax._elements); + break ; + } + } + } + + /** + *设置漫反射贴图。 + *@param value 漫反射贴图。 + */ + /** + *获取漫反射贴图。 + *@return 漫反射贴图。 + */ + __getset(0,__proto,'diffuseTexture',function(){ + return this._getTexture(0); + },function(value){ + if (value){ + this._addShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + }else { + this._removeShaderDefine(/*laya.d3.shader.ShaderDefines3D.DIFFUSEMAP*/0x1); + } + this._setTexture(value,0,"DIFFUSETEXTURE"); + }); + + ShurikenParticleMaterial.load=function(url){ + return Laya.loader.create(url,null,null,ShurikenParticleMaterial); + } + + ShurikenParticleMaterial.WORLDPOSITION="WORLDPOSITION"; + ShurikenParticleMaterial.WORLDROTATIONMATRIX="WORLDROTATIONMATRIX"; + ShurikenParticleMaterial.THREEDSTARTROTATION="THREEDSTARTROTATION"; + ShurikenParticleMaterial.SCALINGMODE="SCALINGMODE"; + ShurikenParticleMaterial.POSITIONSCALE="POSITIONSCALE"; + ShurikenParticleMaterial.SIZESCALE="SIZESCALE"; + ShurikenParticleMaterial.VIEWMATRIX="MATRIX1"; + ShurikenParticleMaterial.PROJECTIONMATRIX="MATRIX2"; + ShurikenParticleMaterial.CURRENTTIME="CURRENTTIME"; + ShurikenParticleMaterial.GRAVITY="GRAVITY"; + ShurikenParticleMaterial.DIFFUSETEXTURE="DIFFUSETEXTURE"; + ShurikenParticleMaterial.CAMERADIRECTION="CAMERADIRECTION"; + ShurikenParticleMaterial.CAMERAUP="CAMERAUP"; + ShurikenParticleMaterial.STRETCHEDBILLBOARDLENGTHSCALE="STRETCHEDBILLBOARDLENGTHSCALE"; + ShurikenParticleMaterial.STRETCHEDBILLBOARDSPEEDSCALE="STRETCHEDBILLBOARDSPEEDSCALE"; + ShurikenParticleMaterial.SIMULATIONSPACE="SIMULATIONSPACE"; + ShurikenParticleMaterial.VOLTYPE="VOLTYPE"; + ShurikenParticleMaterial.VOLVELOCITYCONST="VOLVELOCITYCONST"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTX="VOLVELOCITYGRADIENTX"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTY="VOLVELOCITYGRADIENTY"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTZ="VOLVELOCITYGRADIENTZ"; + ShurikenParticleMaterial.VOLVELOCITYCONSTMAX="VOLVELOCITYCONSTMAX"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTXMAX="VOLVELOCITYGRADIENTXMAX"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTYMAX="VOLVELOCITYGRADIENTYMAX"; + ShurikenParticleMaterial.VOLVELOCITYGRADIENTZMAX="VOLVELOCITYGRADIENTZMAX"; + ShurikenParticleMaterial.VOLSPACETYPE="VOLSPACETYPE"; + ShurikenParticleMaterial.COLOROVERLIFEGRADIENTALPHAS="COLOROVERLIFEGRADIENTALPHAS"; + ShurikenParticleMaterial.COLOROVERLIFEGRADIENTCOLORS="COLOROVERLIFEGRADIENTCOLORS"; + ShurikenParticleMaterial.MAXCOLOROVERLIFEGRADIENTALPHAS="MAXCOLOROVERLIFEGRADIENTALPHAS"; + ShurikenParticleMaterial.MAXCOLOROVERLIFEGRADIENTCOLORS="MAXCOLOROVERLIFEGRADIENTCOLORS"; + ShurikenParticleMaterial.SOLTYPE="SOLTYPE"; + ShurikenParticleMaterial.SOLSEPRARATE="SOLSEPRARATE"; + ShurikenParticleMaterial.SOLSIZEGRADIENT="SOLSIZEGRADIENT"; + ShurikenParticleMaterial.SOLSIZEGRADIENTX="SOLSIZEGRADIENTX"; + ShurikenParticleMaterial.SOLSIZEGRADIENTY="SOLSIZEGRADIENTY"; + ShurikenParticleMaterial.SOLSizeGradientZ="SOLSizeGradientZ"; + ShurikenParticleMaterial.SOLSizeGradientMax="SOLSizeGradientMax"; + ShurikenParticleMaterial.SOLSIZEGRADIENTXMAX="SOLSIZEGRADIENTXMAX"; + ShurikenParticleMaterial.SOLSIZEGRADIENTYMAX="SOLSIZEGRADIENTYMAX"; + ShurikenParticleMaterial.SOLSizeGradientZMAX="SOLSizeGradientZMAX"; + ShurikenParticleMaterial.ROLTYPE="ROLTYPE"; + ShurikenParticleMaterial.ROLSEPRARATE="ROLSEPRARATE"; + ShurikenParticleMaterial.ROLANGULARVELOCITYCONST="ROLANGULARVELOCITYCONST"; + ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTSEPRARATE="ROLANGULARVELOCITYCONSTSEPRARATE"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENT="ROLANGULARVELOCITYGRADIENT"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTX="ROLANGULARVELOCITYGRADIENTX"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTY="ROLANGULARVELOCITYGRADIENTY"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTZ="ROLANGULARVELOCITYGRADIENTZ"; + ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTMAX="ROLANGULARVELOCITYCONSTMAX"; + ShurikenParticleMaterial.ROLANGULARVELOCITYCONSTMAXSEPRARATE="ROLANGULARVELOCITYCONSTMAXSEPRARATE"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTMAX="ROLANGULARVELOCITYGRADIENTMAX"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTXMAX="ROLANGULARVELOCITYGRADIENTXMAX"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTYMAX="ROLANGULARVELOCITYGRADIENTYMAX"; + ShurikenParticleMaterial.ROLANGULARVELOCITYGRADIENTZMAX="ROLANGULARVELOCITYGRADIENTZMAX"; + ShurikenParticleMaterial.TEXTURESHEETANIMATIONTYPE="TEXTURESHEETANIMATIONTYPE"; + ShurikenParticleMaterial.TEXTURESHEETANIMATIONCYCLES="TEXTURESHEETANIMATIONCYCLES"; + ShurikenParticleMaterial.TEXTURESHEETANIMATIONSUBUVLENGTH="TEXTURESHEETANIMATIONSUBUVLENGTH"; + ShurikenParticleMaterial.TEXTURESHEETANIMATIONGRADIENTUVS="TEXTURESHEETANIMATIONGRADIENTUVS"; + ShurikenParticleMaterial.TEXTURESHEETANIMATIONGRADIENTMAXUVS="TEXTURESHEETANIMATIONGRADIENTMAXUVS"; + ShurikenParticleMaterial._diffuseTextureIndex=0; + __static(ShurikenParticleMaterial, + ['_tempGravity',function(){return this._tempGravity=new Vector3();},'defaultMaterial',function(){return this.defaultMaterial=new ShurikenParticleMaterial();} + ]); + return ShurikenParticleMaterial; + })(BaseMaterial) + + + /** + *CameraAnimations 类用于创建摄像机动画组件。 + */ + //class laya.d3.component.animation.CameraAnimations extends laya.d3.component.animation.KeyframeAnimations + var CameraAnimations=(function(_super){ + function CameraAnimations(){ + this._tempCurAnimationData=null; + this._lastFrameIndex=-1; + this._currentTransform=null; + this._originalAnimationTransform=null; + this._originalFov=0; + this._camera=null; + this._cacheAnimationDatas=[]; + this._currentAnimationData=null; + this.localMode=true; + this.addMode=true; + this._tempVector30=new Vector3(); + this._tempVector31=new Vector3(); + this._tempVector32=new Vector3(); + CameraAnimations.__super.call(this); + } + + __class(CameraAnimations,'laya.d3.component.animation.CameraAnimations',_super); + var __proto=CameraAnimations.prototype; + /** + *@private + *摄像机动画作用函数。 + */ + __proto._effect=function(){ + var i=0; + for (i=0;i < 3;i++){ + this._tempVector30.elements[i]=this._currentAnimationData[i]; + this._tempVector31.elements[i]=this._currentAnimationData[i+3]; + this._tempVector32.elements[i]=this._currentAnimationData[i+6]; + } + this._currentTransform || (this._currentTransform=new Matrix4x4()); + Matrix4x4.createLookAt(this._tempVector30,this._tempVector31,this._tempVector32,this._currentTransform); + this._currentTransform.invert(this._currentTransform); + if (this.addMode){ + Matrix4x4.multiply(this._originalAnimationTransform,this._currentTransform,this._currentTransform); + } + if (this.localMode) + this.owner.transform.localMatrix=this._currentTransform; + else + this.owner.transform.worldMatrix=this._currentTransform; + this._camera.fieldOfView=this._currentAnimationData[9]; + } + + /** + *@private + *初始化载入摄像机动画组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + var _$this=this; + if ((owner instanceof laya.d3.core.Camera )) + this._camera=owner; + else + throw new Error("该Sprite3D并非Camera"); + this._player.on(/*laya.events.Event.STOPPED*/"stopped",this,function(){ + if (_$this._player.returnToZeroStopped){ + if (_$this.localMode) + _$this._originalAnimationTransform && (owner.transform.localMatrix=_$this._originalAnimationTransform); + else + _$this._originalAnimationTransform && (owner.transform.worldMatrix=_$this._originalAnimationTransform); + _$this._camera.fieldOfView=_$this._originalFov; + } + }); + } + + /** + *@private + *更新摄像机动画组件。 + *@param state 渲染状态。 + */ + __proto._update=function(state){ + if (!this._templet || !this._templet.loaded || this._player.state!==/*laya.ani.AnimationState.playing*/2) + return; + var rate=this._player.playbackRate *Laya.timer.scale; + var frameIndex=(this._player.isCache && rate >=1.0)? this.currentFrameIndex :-1; + var animationClipIndex=this.currentAnimationClipIndex; + if (frameIndex!==-1 && this._lastFrameIndex===frameIndex){ + laya.d3.component.Component3D.prototype._update.call(this,state); + return; + } + if (this._player.isCache && rate >=1.0){ + var cache=this._templet.getAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,animationClipIndex,frameIndex); + if (cache){ + this._currentAnimationData=cache; + this._lastFrameIndex=frameIndex; + laya.d3.component.Component3D.prototype._update.call(this,state); + this._effect(); + return; + } + }; + var nodes=this._templet.getNodes(animationClipIndex); + var nodeCount=nodes.length; + if (this._player.isCache && rate >=1.0){ + this._currentAnimationData=new Float32Array(nodeCount *10); + }else{ + (this._tempCurAnimationData)|| (this._tempCurAnimationData=new Float32Array(nodeCount *10)); + this._currentAnimationData=this._tempCurAnimationData; + } + if (this._player.isCache && rate >=1.0) + this._templet.getOriginalData(animationClipIndex,this._currentAnimationData,this._player._fullFrames[animationClipIndex],frameIndex,this._player.currentPlayTime); + else + this._templet.getOriginalDataUnfixedRate(animationClipIndex,this._currentAnimationData,this._player.currentPlayTime); + if (this._player.isCache && rate >=1.0){ + this._templet.setAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,animationClipIndex,frameIndex,this._currentAnimationData); + } + this._lastFrameIndex=frameIndex; + laya.d3.component.Component3D.prototype._update.call(this,state); + this._effect(); + } + + return CameraAnimations; + })(KeyframeAnimations) + + + /** + *RigidAnimations 类用于创建变换动画组件。 + */ + //class laya.d3.component.animation.RigidAnimations extends laya.d3.component.animation.KeyframeAnimations + var RigidAnimations=(function(_super){ + function RigidAnimations(){ + this._animationSprites=null; + this._animationSpritesInitLocalMatrix=null; + this._tempCurAnimationData=null; + this._curOriginalData=null; + this._lastFrameIndex=-1; + this._curAnimationDatas=null; + RigidAnimations.__super.call(this); + this._animationSprites=[]; + this._animationSpritesInitLocalMatrix=[]; + } + + __class(RigidAnimations,'laya.d3.component.animation.RigidAnimations',_super); + var __proto=RigidAnimations.prototype; + /** + *@private + */ + __proto._init=function(){ + var nodes=this._templet.getNodes(this.currentAnimationClipIndex); + var curParentSprite=this._owner; + var nodeLength=nodes.length; + var pathStart=0; + var extentDatas=new Uint16Array(this._templet.getPublicExtData()); + for (var i=0;i < nodeLength;i++){ + var hierarchys=extentDatas.slice(pathStart+1,pathStart+1+extentDatas[pathStart]); + pathStart+=(extentDatas[pathStart]+1); + for (var j=1;j < hierarchys.length;j++){ + var childIndex=hierarchys[j]; + curParentSprite=curParentSprite._childs[hierarchys[j]]; + }; + var curSprite=curParentSprite.getChildByName(nodes[i].name); + if (!curSprite) + break ; + this._animationSprites[i]=curSprite; + var localMatrix=this._animationSpritesInitLocalMatrix[i]; + (localMatrix)|| (localMatrix=this._animationSpritesInitLocalMatrix[i]=new Matrix4x4()); + curSprite.transform.localMatrix.cloneTo(localMatrix); + curParentSprite=this._owner; + } + } + + /** + *@private + */ + __proto._animtionPlay=function(){ + if (this._templet.loaded) + this._init(); + else + this._templet.once(/*laya.events.Event.LOADED*/"loaded",this,this._init); + } + + /** + *@private + */ + __proto._animtionStop=function(){ + this._lastFrameIndex=-1; + if (this._player.returnToZeroStopped){ + this._curAnimationDatas=null; + for (var i=0;i < this._animationSprites.length;i++) + this._animationSprites[i].transform.localMatrix=this._animationSpritesInitLocalMatrix[i]; + } + } + + /** + *@private + *摄像机动画作用函数。 + */ + __proto._effectAnimation=function(nodes){ + for (var nodeIndex=0,nodeLength=this._animationSprites.length;nodeIndex < nodeLength;nodeIndex++){ + var sprite=this._animationSprites[nodeIndex]; + var matrix=sprite.transform.localMatrix; + var matrixE=matrix.elements; + for (var i=0;i < 16;i++) + matrixE[i]=this._curAnimationDatas[nodeIndex *16+i]; + sprite.transform.localMatrix=matrix; + } + } + + /** + *@private + *初始化载入摄像机动画组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + _super.prototype._load.call(this,owner); + this._player.on(/*laya.events.Event.STOPPED*/"stopped",this,this._animtionStop); + this._player.on(/*laya.events.Event.PLAYED*/"played",this,this._animtionPlay); + } + + /** + *@private + *更新摄像机动画组件。 + *@param state 渲染状态。 + */ + __proto._update=function(state){ + if (this._player.state!==/*laya.ani.AnimationState.playing*/2 || !this._templet || !this._templet.loaded) + return; + var rate=this._player.playbackRate *Laya.timer.scale; + var cachePlayRate=this._player.cachePlayRate; + var isCache=this._player.isCache && rate >=cachePlayRate; + var frameIndex=isCache ? this.currentFrameIndex :-1; + if (frameIndex!==-1 && this._lastFrameIndex===frameIndex) + return; + var animationClipIndex=this.currentAnimationClipIndex; + var nodes=this._templet.getNodes(animationClipIndex); + var animationDatasCache=this._templet._animationDatasCache; + if (isCache){ + var cacheData=this._templet.getAnimationDataWithCache(cachePlayRate,animationDatasCache,animationClipIndex,frameIndex); + if (cacheData){ + this._curAnimationDatas=cacheData; + this._lastFrameIndex=frameIndex; + this._effectAnimation(nodes); + return; + } + }; + var nodeFloatCount=nodes.length *16; + if (isCache){ + this._curAnimationDatas=new Float32Array(nodeFloatCount); + }else{ + (this._tempCurAnimationData)|| (this._tempCurAnimationData=new Float32Array(nodeFloatCount)); + this._curAnimationDatas=this._tempCurAnimationData; + } + this._curOriginalData || (this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(animationClipIndex))); + if (isCache) + this._templet.getOriginalData(animationClipIndex,this._curOriginalData,this._player._fullFrames[animationClipIndex],frameIndex,this._player.currentFrameTime); + else + this._templet.getOriginalDataUnfixedRate(animationClipIndex,this._curOriginalData,this._player.currentPlayTime); + Utils3D._computeRootAnimationData(nodes,this._curOriginalData,this._curAnimationDatas); + if (isCache){ + this._templet.setAnimationDataWithCache(cachePlayRate,animationDatasCache,animationClipIndex,frameIndex,this._curAnimationDatas); + } + this._lastFrameIndex=frameIndex; + this._effectAnimation(nodes); + } + + /** + *@private + *卸载组件时执行。 + */ + __proto._unload=function(owner){ + _super.prototype._unload.call(this,owner); + this._animationSprites=null; + this._animationSpritesInitLocalMatrix=null; + this._tempCurAnimationData=null; + this._curOriginalData=null; + this._curAnimationDatas=null; + } + + /** + *设置url地址。 + *@param value 地址。 + */ + __getset(0,__proto,'url',null,function(value){ + _super.prototype._$set_url.call(this,value); + this._curOriginalData=null; + this._curAnimationDatas=null; + this._tempCurAnimationData=null; + (this._templet._animationDatasCache)|| (this._templet._animationDatasCache=[]); + }); + + __getset(0,__proto,'templet',_super.prototype._$get_templet,function(value){ + _super.prototype._$set_templet.call(this,value); + this._curOriginalData=null; + this._curAnimationDatas=null; + this._tempCurAnimationData=null; + (this._templet._animationDatasCache)|| (this._templet._animationDatasCache=[]); + }); + + return RigidAnimations; + })(KeyframeAnimations) + + + /** + *SkinAnimations 类用于创建蒙皮动画组件。 + */ + //class laya.d3.component.animation.SkinAnimations extends laya.d3.component.animation.KeyframeAnimations + var SkinAnimations=(function(_super){ + function SkinAnimations(){ + this._tempCurAnimationData=null; + this._tempCurBonesData=null; + this._curOriginalData=null; + this._extenData=null; + this._lastFrameIndex=-1; + this._curMeshAnimationData=null; + this._curBonesDatas=null; + this._curAnimationDatas=null; + this._ownerMesh=null; + SkinAnimations.__super.call(this); + } + + __class(SkinAnimations,'laya.d3.component.animation.SkinAnimations',_super); + var __proto=SkinAnimations.prototype; + /**@private */ + __proto._getAnimationDatasWithCache=function(rate,mesh,cacheDatas,aniIndex,frameIndex){ + var aniDatas=cacheDatas[aniIndex]; + if (!aniDatas){ + return null; + }else { + var rateDatas=aniDatas[rate]; + if (!rateDatas) + return null; + else { + var meshDatas=rateDatas[mesh.id]; + if (!meshDatas) + return null; + else + return meshDatas[frameIndex]; + } + } + } + + /**@private */ + __proto._setAnimationDatasWithCache=function(rate,mesh,cacheDatas,aniIndex,frameIndex,animationDatas){ + var aniDatas=(cacheDatas[aniIndex])|| (cacheDatas[aniIndex]={}); + var rateDatas=(aniDatas[rate])|| (aniDatas[rate]={}); + var meshDatas=(rateDatas[mesh.id])|| (rateDatas[mesh.id]=[]); + meshDatas[frameIndex]=animationDatas; + } + + /**@private */ + __proto._onAnimationPlayMeshLoaded=function(){ + var renderElements=this._ownerMesh.meshRender.renderObject._renderElements; + for (var i=0,n=renderElements.length;i < n;i++) + renderElements[i]._canDynamicBatch=false; + } + + /**@private */ + __proto._onAnimationPlay=function(){ + var mesh=this._ownerMesh.meshFilter.sharedMesh; + if (mesh.loaded) + this._onAnimationPlayMeshLoaded(); + else + mesh.on(/*laya.events.Event.LOADED*/"loaded",this,this._onAnimationPlayMeshLoaded); + } + + /**@private */ + __proto._onAnimationStop=function(){ + this._lastFrameIndex=-1; + if (this._player.returnToZeroStopped){ + this._curBonesDatas=null; + this._curAnimationDatas=null; + }; + var renderElements=this._ownerMesh.meshRender.renderObject._renderElements; + for (var i=0,n=renderElements.length;i < n;i++) + renderElements[i]._canDynamicBatch=true; + } + + /** + *@private + *初始化载入蒙皮动画组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + _super.prototype._load.call(this,owner); + this._ownerMesh=(owner); + this._player.on(/*laya.events.Event.PLAYED*/"played",this,this._onAnimationPlay); + this._player.on(/*laya.events.Event.STOPPED*/"stopped",this,this._onAnimationStop); + } + + /** + *预缓存帧动画数据(需确保动画模板、模型模板都已加载完成)。 + *@param animationClipIndex 动画索引 + *@param meshTemplet 动画模板 + */ + __proto.preComputeKeyFrames=function(animationClipIndex){ + if (!this._templet.loaded || !this._ownerMesh.meshFilter.sharedMesh.loaded) + throw new Error("SkinAnimations: must to be sure animation templet and mesh templet has loaded."); + var cachePlayRate=this._player.cachePlayRate; + var cacheFrameRateInterval=this._player.cacheFrameRateInterval *cachePlayRate; + var maxKeyFrame=Math.floor(this._templet.getAniDuration(animationClipIndex)/ cacheFrameRateInterval); + for (var frameIndex=0;frameIndex <=maxKeyFrame;frameIndex++){ + var boneDatasCache=this._templet._animationDatasCache[0]; + var animationDatasCache=this._templet._animationDatasCache[1]; + var mesh=this._ownerMesh.meshFilter.sharedMesh; + var cacheAnimationDatas=this._getAnimationDatasWithCache(cachePlayRate,mesh,animationDatasCache,animationClipIndex,frameIndex); + if (cacheAnimationDatas){ + continue ; + }; + var bones=this._templet.getNodes(animationClipIndex); + var boneFloatCount=bones.length *16; + (this._curMeshAnimationData)|| (this._curMeshAnimationData=new Float32Array(boneFloatCount)); + var i=0,n=0; + this._curAnimationDatas=[]; + for (i=0,n=mesh.getSubMeshCount();i < n;i++) + this._curAnimationDatas[i]=new Float32Array(mesh.getSubMesh(i)._boneIndices.length *16); + this._curBonesDatas=new Float32Array(boneFloatCount); + this._curOriginalData || (this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(animationClipIndex))); + this._templet.getOriginalData(animationClipIndex,this._curOriginalData,this._player._fullFrames[animationClipIndex],frameIndex,cacheFrameRateInterval *frameIndex); + var inverseAbsoluteBindPoses=mesh.InverseAbsoluteBindPoses; + if (inverseAbsoluteBindPoses){ + Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxix(bones,this._curOriginalData,inverseAbsoluteBindPoses,this._curBonesDatas,this._curMeshAnimationData); + }else { + this._extenData || (this._extenData=new Float32Array(this._templet.getPublicExtData())); + Utils3D._computeBoneAndAnimationDatas(bones,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData); + } + for (i=0,n=mesh.getSubMeshCount();i < n;i++){ + var subMesh=mesh.getSubMesh(i); + SkinAnimations._computeSubMeshAniDatas(i,subMesh._boneIndices,this._curMeshAnimationData,this._curAnimationDatas); + } + this._setAnimationDatasWithCache(cachePlayRate,mesh,animationDatasCache,animationClipIndex,frameIndex,this._curAnimationDatas); + this._templet.setAnimationDataWithCache(cachePlayRate,boneDatasCache,animationClipIndex,frameIndex,this._curBonesDatas); + } + } + + /** + *@private + *更新蒙皮动画组件。 + *@param state 渲染状态参数。 + */ + __proto._update=function(state){ + var mesh=this._ownerMesh.meshFilter.sharedMesh; + if (this._player.state!==/*laya.ani.AnimationState.playing*/2 || !this._templet || !this._templet.loaded || !mesh.loaded) + return; + var rate=this._player.playbackRate *Laya.timer.scale; + var cachePlayRate=this._player.cachePlayRate; + var isCache=this._player.isCache && rate >=cachePlayRate; + var frameIndex=isCache ? this.currentFrameIndex :-1; + if (frameIndex!==-1 && this._lastFrameIndex===frameIndex) + return; + var animationClipIndex=this.currentAnimationClipIndex; + var boneDatasCache=this._templet._animationDatasCache[0]; + var animationDatasCache=this._templet._animationDatasCache[1]; + if (isCache){ + var cacheAnimationDatas=this._getAnimationDatasWithCache(cachePlayRate,mesh,animationDatasCache,animationClipIndex,frameIndex); + if (cacheAnimationDatas){ + this._curAnimationDatas=cacheAnimationDatas; + this._curBonesDatas=this._templet.getAnimationDataWithCache(cachePlayRate,boneDatasCache,animationClipIndex,frameIndex); + this._lastFrameIndex=frameIndex; + return; + } + }; + var isCacheBonesDatas=false; + if (isCache){ + this._curBonesDatas=this._templet.getAnimationDataWithCache(cachePlayRate,boneDatasCache,animationClipIndex,frameIndex); + isCacheBonesDatas=this._curBonesDatas ? true :false; + }; + var bones=this._templet.getNodes(animationClipIndex); + var boneFloatCount=bones.length *16; + (this._curMeshAnimationData)|| (this._curMeshAnimationData=new Float32Array(boneFloatCount)); + var i=0,n=0; + if (isCache){ + this._curAnimationDatas=[]; + for (i=0,n=mesh.getSubMeshCount();i < n;i++) + this._curAnimationDatas[i]=new Float32Array(mesh.getSubMesh(i)._boneIndices.length *16); + (isCacheBonesDatas)|| (this._curBonesDatas=new Float32Array(boneFloatCount)); + }else { + if (!this._tempCurAnimationData){ + this._tempCurAnimationData=[]; + for (i=0,n=mesh.getSubMeshCount();i < n;i++) + this._tempCurAnimationData[i]=new Float32Array(mesh.getSubMesh(i)._boneIndices.length *16); + } + (this._tempCurBonesData)|| (this._tempCurBonesData=new Float32Array(boneFloatCount)); + this._curAnimationDatas=this._tempCurAnimationData; + this._curBonesDatas=this._tempCurBonesData; + } + this._curOriginalData || (this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(animationClipIndex))); + if (isCache) + this._templet.getOriginalData(animationClipIndex,this._curOriginalData,this._player._fullFrames[animationClipIndex],frameIndex,this._player.currentFrameTime); + else + this._templet.getOriginalDataUnfixedRate(animationClipIndex,this._curOriginalData,this._player.currentPlayTime); + var inverseAbsoluteBindPoses=mesh.InverseAbsoluteBindPoses; + if (inverseAbsoluteBindPoses){ + if (isCache && isCacheBonesDatas) + Utils3D._computeAnimationDatasByArrayAndMatrixFast(inverseAbsoluteBindPoses,this._curBonesDatas,this._curMeshAnimationData); + else + Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxix(bones,this._curOriginalData,inverseAbsoluteBindPoses,this._curBonesDatas,this._curMeshAnimationData); + }else { + this._extenData || (this._extenData=new Float32Array(this._templet.getPublicExtData())); + if (isCache && isCacheBonesDatas) + Utils3D._computeAnimationDatas(this._extenData,this._curBonesDatas,this._curMeshAnimationData); + else + Utils3D._computeBoneAndAnimationDatas(bones,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData); + } + for (i=0,n=mesh.getSubMeshCount();i < n;i++){ + var subMesh=mesh.getSubMesh(i); + SkinAnimations._computeSubMeshAniDatas(i,subMesh._boneIndices,this._curMeshAnimationData,this._curAnimationDatas); + } + if (isCache){ + this._setAnimationDatasWithCache(cachePlayRate,mesh,animationDatasCache,animationClipIndex,frameIndex,this._curAnimationDatas); + (isCacheBonesDatas)|| (this._templet.setAnimationDataWithCache(cachePlayRate,boneDatasCache,animationClipIndex,frameIndex,this._curBonesDatas)); + } + this._lastFrameIndex=frameIndex; + } + + /** + *@private + *在渲染前更新蒙皮动画组件渲染参数。 + *@param state 渲染状态参数。 + */ + __proto._preRenderUpdate=function(state){ + if (this._curAnimationDatas){ + state.shaderDefines.addInt(/*laya.d3.shader.ShaderDefines3D.BONE*/0x8000); + var subMeshIndex=state.renderElement.renderObj.indexOfHost; + state.shaderValue.pushValue(/*laya.d3.core.material.StandardMaterial.Bones*/"MATRIXARRAY0",this._curAnimationDatas[subMeshIndex]); + } + } + + /** + *@private + *卸载组件时执行 + */ + __proto._unload=function(owner){ + _super.prototype._unload.call(this,owner); + this._tempCurAnimationData=null; + this._tempCurBonesData=null; + this._curOriginalData=null; + this._extenData=null; + this._curMeshAnimationData=null; + this._curBonesDatas=null; + this._curAnimationDatas=null; + this._ownerMesh=null; + } + + /** + *获取骨骼数据。 + *@return 骨骼数据。 + */ + __getset(0,__proto,'curBonesDatas',function(){ + return this._curBonesDatas; + }); + + /** + *获取动画数据。 + *@return 动画数据。 + */ + __getset(0,__proto,'curAnimationDatas',function(){ + return this._curAnimationDatas; + }); + + /** + *设置url地址。 + *@param value 地址。 + */ + __getset(0,__proto,'url',null,function(value){ + _super.prototype._$set_url.call(this,value); + this._curOriginalData=this._extenData=null; + this._curMeshAnimationData=null; + this._tempCurBonesData=null; + this._tempCurAnimationData=null; + (this._templet._animationDatasCache)|| (this._templet._animationDatasCache=[[],[]]); + }); + + __getset(0,__proto,'templet',_super.prototype._$get_templet,function(value){ + _super.prototype._$set_templet.call(this,value); + this._curOriginalData=this._extenData=null; + this._curMeshAnimationData=null; + this._tempCurBonesData=null; + this._tempCurAnimationData=null; + (this._templet._animationDatasCache)|| (this._templet._animationDatasCache=[[],[]]); + }); + + SkinAnimations._computeSubMeshAniDatas=function(subMeshIndex,index,bonesData,animationDatas){ + var data=animationDatas[subMeshIndex]; + for (var i=0,n=index.length,ii=0;i < n;i++){ + for (var j=0;j < 16;j++,ii++){ + data[ii]=bonesData[(index[i] << 4)+j]; + } + } + } + + SkinAnimations._copyBone=function(index,bonesData,out){ + for (var i=0,n=index.length,ii=0;i < n;i++){ + for (var j=0;j < 16;j++,ii++){ + out[ii]=bonesData[(index[i] << 4)+j]; + } + } + } + + return SkinAnimations; + })(KeyframeAnimations) + + + /** + *UVAnimations 类用于创建UV动画组件。 + */ + //class laya.d3.component.animation.UVAnimations extends laya.d3.component.animation.KeyframeAnimations + var UVAnimations=(function(_super){ + function UVAnimations(){ + this._nodes=null; + this._lasstInitIndex=-1; + this._materials=null; + this._mesh=null; + this._meshDataInited=false; + this._uvDatasCount=0; + this._subMeshIndexToNodeIndex=[]; + this._keyframeAges=[]; + this._ages=[]; + this._bufferUsages=[]; + this._originalShaderAttributes=[]; + this._uvShaderValues=[]; + this._uvNextShaderValues=[]; + this._uvAnimationBuffers=[]; + UVAnimations.__super.call(this); + this._meshDataInited=false; + } + + __class(UVAnimations,'laya.d3.component.animation.UVAnimations',_super); + var __proto=UVAnimations.prototype; + /** + *@private + *初始化Mesh相关数据函数。 + */ + __proto._initMeshData=function(){ + this._materials=this._mesh.meshRender.sharedMaterials; + this._meshDataInited=true; + } + + /** + *@private + *初始化UV动画相关数据函数。 + */ + __proto._initAnimationData=function(animationIndex){} + /** + *@private + *初始化载入UV动画组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + if ((owner instanceof laya.d3.core.MeshSprite3D )) + this._mesh=owner; + else + throw new Error("该Sprite3D并非Mesh"); + owner.on(/*laya.events.Event.LOADED*/"loaded",this,function(mesh){ + }); + this.on(/*laya.events.Event.LOADED*/"loaded",this,function(){ + }); + this.player.on(/*laya.events.Event.PLAYED*/"played",this,function(){ + }); + this.player.on(/*laya.events.Event.STOPPED*/"stopped",this,function(){ + }); + } + + /** + *@private + *更新UV动画组件。 + *@param state 渲染状态参数。 + */ + __proto._update=function(state){ + this.player.update(state.elapsedTime); + if (!this._templet || !this._templet.loaded || this.player.state!==/*laya.ani.AnimationState.playing*/2) + return; + var animationClipIndex=this.currentAnimationClipIndex; + var unfixedIndexes=this._templet.getNodesCurrentFrameIndex(animationClipIndex,this.player.currentPlayTime); + for (var i=0;i < this._nodes.length;i++){ + var index=unfixedIndexes[i]; + this._keyframeAges[i]=(this.player.currentPlayTime-this._nodes[i].keyFrame[index].startTime)/ this._nodes[i].keyFrame[index].duration; + this._ages[i]=this.player.currentPlayTime / this._nodes[i].playTime; + var subkeyframeWidth=this._nodes[i].keyframeWidth / this._uvDatasCount; + (this._uvShaderValues[i])|| (this._uvShaderValues[i]=[]); + (this._uvNextShaderValues[i])|| (this._uvNextShaderValues[i]=[]); + for (var c=0;c < this._uvDatasCount;c++){ + var uvShaderValue=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,0,(index)*subkeyframeWidth *4]; + var uvNextShaderValue=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,0,(index+1)*subkeyframeWidth *4]; + this._uvShaderValues[i][c]=uvShaderValue; + this._uvNextShaderValues[i][c]=uvNextShaderValue; + } + } + laya.d3.component.Component3D.prototype._update.call(this,state); + } + + /** + *@private + *在渲染前更新UV动画组件渲染参数。 + *@param state 渲染状态参数。 + */ + __proto._preRenderUpdate=function(state){} + return UVAnimations; + })(KeyframeAnimations) + + + /** + *@private + *PrimitiveMesh 类用于创建基本网格的父类。 + */ + //class laya.d3.resource.models.PrimitiveMesh extends laya.d3.resource.models.BaseMesh + var PrimitiveMesh=(function(_super){ + function PrimitiveMesh(){ + this._numberVertices=0; + this._numberIndices=0; + this._vertexBuffer=null; + this._indexBuffer=null; + this._indexOfHost=0; + PrimitiveMesh.__super.call(this); + this._indexOfHost=0; + } + + __class(PrimitiveMesh,'laya.d3.resource.models.PrimitiveMesh',_super); + var __proto=PrimitiveMesh.prototype; + Laya.imps(__proto,{"laya.d3.core.render.IRenderable":true}) + __proto._getVertexBuffer=function(index){ + (index===void 0)&& (index=0); + if (index===0) + return this._vertexBuffer; + else + return null; + } + + __proto._getIndexBuffer=function(){ + return this._indexBuffer; + } + + __proto.getRenderElement=function(index){ + return this; + } + + __proto.getRenderElementsCount=function(){ + return 1; + } + + __proto.detoryResource=function(){ + (this._vertexBuffer)&& (this._vertexBuffer.dispose(),this._vertexBuffer=null); + (this._indexBuffer)&& (this._indexBuffer.dispose(),this._indexBuffer=null); + this.memorySize=0; + } + + __proto._beforeRender=function(state){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + return true; + } + + __proto._render=function(state){ + state.context.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._numberIndices,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.drawCall++; + Stat.trianglesFaces+=this._numberIndices / 3; + } + + __getset(0,__proto,'indexOfHost',function(){ + return this._indexOfHost; + }); + + __getset(0,__proto,'_vertexBufferCount',function(){ + return 1; + }); + + __getset(0,__proto,'triangleCount',function(){ + return this._indexBuffer.indexCount / 3; + }); + + /** + *获取网格顶点 + *@return 网格顶点。 + */ + __getset(0,__proto,'positions',function(){ + var vertices=[]; + var positionElement; + var vertexElements=this._vertexBuffer.vertexDeclaration.getVertexElements(); + var j=0; + for (j=0;j < vertexElements.length;j++){ + var vertexElement=vertexElements[j]; + if (vertexElement.elementFormat===/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3" && vertexElement.elementUsage===/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"){ + positionElement=vertexElement; + break ; + } + }; + var verticesData=this._vertexBuffer.getData(); + for (j=0;j < verticesData.length;j+=this._vertexBuffer.vertexDeclaration.vertexStride / 4){ + var ofset=j+positionElement.offset / 4; + var position=new Vector3(verticesData[ofset+0],verticesData[ofset+1],verticesData[ofset+2]); + vertices.push(position); + } + return vertices; + }); + + return PrimitiveMesh; + })(BaseMesh) + + + /** + *Mesh 类用于创建文件网格数据模板。 + */ + //class laya.d3.resource.models.Mesh extends laya.d3.resource.models.BaseMesh + var Mesh=(function(_super){ + function Mesh(){ + this._materials=null; + this._subMeshes=null; + this._bindPoses=null; + this._inverseBindPoses=null; + Mesh.__super.call(this); + this._subMeshes=[]; + this._materials=[]; + if (this._loaded) + this._generateBoundingObject(); + else + this.once(/*laya.events.Event.LOADED*/"loaded",this,this._generateBoundingObject); + } + + __class(Mesh,'laya.d3.resource.models.Mesh',_super); + var __proto=Mesh.prototype; + __proto._generateBoundingObject=function(){ + var pos=this.positions; + this._boundingBox=new BoundBox(new Vector3(),new Vector3()); + BoundBox.createfromPoints(pos,this._boundingBox); + this._boundingSphere=new BoundSphere(new Vector3(),0); + BoundSphere.createfromPoints(pos,this._boundingSphere); + } + + /** + *添加子网格(开发者禁止修改)。 + *@param subMesh 子网格。 + */ + __proto._add=function(subMesh){ + subMesh._indexInMesh=this._subMeshes.length; + this._subMeshes.push(subMesh); + this._subMeshCount++; + } + + /** + *移除子网格(开发者禁止修改)。 + *@param subMesh 子网格。 + *@return 是否成功。 + */ + __proto._remove=function(subMesh){ + var index=this._subMeshes.indexOf(subMesh); + if (index < 0)return false; + this._subMeshes.splice(index,1); + this._subMeshCount--; + return true; + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + var bufferData=data[0]; + var textureMap=data[1]; + new LoadModel(bufferData,this,this._materials,textureMap); + this._loaded=true; + this.event(/*laya.events.Event.LOADED*/"loaded",this); + } + + /** + *获得子网格。 + *@param index 子网格索引。 + *@return 子网格。 + */ + __proto.getSubMesh=function(index){ + return this._subMeshes[index]; + } + + /** + *获得子网格数量。 + *@return 子网格数量。 + */ + __proto.getSubMeshCount=function(){ + return this._subMeshes.length; + } + + __proto.getRenderElementsCount=function(){ + return this._subMeshes.length; + } + + __proto.getRenderElement=function(index){ + return this._subMeshes[index]; + } + + /** + *

    彻底清理资源。

    + *

    注意:会强制解锁清理。

    + */ + __proto.dispose=function(){ + this._resourceManager.removeResource(this); + laya.resource.Resource.prototype.dispose.call(this); + for (var i=0;i < this._subMeshes.length;i++) + this._subMeshes[i].dispose(); + this._subMeshes=null; + this._subMeshCount=0; + } + + /** + *获取网格顶点 + *@return 网格顶点。 + */ + __getset(0,__proto,'positions',function(){ + var vertices=[]; + var submesheCount=this._subMeshes.length; + for (var i=0;i < submesheCount;i++){ + var subMesh=this._subMeshes[i]; + var vertexBuffer=subMesh._getVertexBuffer(); + var positionElement; + var vertexElements=vertexBuffer.vertexDeclaration.getVertexElements(); + var j=0; + for (j=0;j < vertexElements.length;j++){ + var vertexElement=vertexElements[j]; + if (vertexElement.elementFormat===/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3" && vertexElement.elementUsage===/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"){ + positionElement=vertexElement; + break ; + } + }; + var verticesData=vertexBuffer.getData(); + for (j=0;j < verticesData.length;j+=vertexBuffer.vertexDeclaration.vertexStride / 4){ + var ofset=j+positionElement.offset / 4; + var position=new Vector3(verticesData[ofset+0],verticesData[ofset+1],verticesData[ofset+2]); + vertices.push(position); + } + } + return vertices; + }); + + /** + *获取材质队列的浅拷贝。 + *@return 材质队列的浅拷贝。 + */ + __getset(0,__proto,'materials',function(){ + return this._materials.slice(); + }); + + /** + *获取网格的默认绑定动作矩阵。 + *@return 网格的默认绑定动作矩阵。 + */ + __getset(0,__proto,'bindPoses',function(){ + return this._bindPoses; + }); + + /** + *获取网格的全局默认绑定动作逆矩阵。 + *@return 网格的全局默认绑定动作逆矩阵。 + */ + __getset(0,__proto,'InverseAbsoluteBindPoses',function(){ + return this._inverseBindPoses; + }); + + Mesh.load=function(url){ + return Laya.loader.create(url,null,null,Mesh); + } + + return Mesh; + })(BaseMesh) + + + /** + *RenderTarget 类用于创建渲染目标。 + */ + //class laya.d3.resource.RenderTexture extends laya.d3.resource.BaseTexture + var RenderTexture=(function(_super){ + function RenderTexture(width,height,surfaceFormat,surfaceType,depthStencilFormat,mipMap,repeat,minFifter,magFifter){ + this._alreadyResolved=false; + this._surfaceFormat=0; + this._surfaceType=0; + this._depthStencilFormat=0; + this._frameBuffer=null; + this._depthStencilBuffer=null; + (surfaceFormat===void 0)&& (surfaceFormat=/*laya.webgl.WebGLContext.RGBA*/0x1908); + (surfaceType===void 0)&& (surfaceType=/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401); + (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5); + (mipMap===void 0)&& (mipMap=false); + (repeat===void 0)&& (repeat=false); + (minFifter===void 0)&& (minFifter=-1); + (magFifter===void 0)&& (magFifter=-1); + RenderTexture.__super.call(this); + this._width=width; + this._height=height; + this._size=new Size(width,height); + this._surfaceFormat=surfaceFormat; + this._surfaceType=surfaceType; + this._depthStencilFormat=depthStencilFormat; + this._mipmap=mipMap; + this._repeat=repeat; + this._minFifter=minFifter; + this._magFifter=magFifter; + this.activeResource(); + this._loaded=true; + this._alreadyResolved=true; + } + + __class(RenderTexture,'laya.d3.resource.RenderTexture',_super); + var __proto=RenderTexture.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + var gl=WebGL.mainContext; + this._frameBuffer=gl.createFramebuffer(); + this._source=gl.createTexture(); + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,this._width,this._height,0,this._surfaceFormat,this._surfaceType,null); + var minFifter=this._minFifter; + var magFifter=this._magFifter; + var repeat=this._repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPot=Arith.isPOT(this._width,this._height); + if (isPot){ + if (this._mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this._mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer); + gl.framebufferTexture2D(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.COLOR_ATTACHMENT0*/0x8CE0,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source,0); + if (this._depthStencilFormat){ + this._depthStencilBuffer=gl.createRenderbuffer(); + gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilFormat,this._width,this._height); + switch (this._depthStencilFormat){ + case /*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_ATTACHMENT*/0x8D00,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + case /*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.STENCIL_ATTACHMENT*/0x8D20,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + case /*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9: + gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_STENCIL_ATTACHMENT*/0x821A,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer); + break ; + } + } + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,null); + this.memorySize=this._width *this._height *4; + this.completeCreate(); + } + + /** + *开始绑定。 + */ + __proto.start=function(){ + WebGL.mainContext.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this.frameBuffer); + RenderTexture._currentRenderTarget=this; + this._alreadyResolved=false; + } + + /** + *结束绑定。 + */ + __proto.end=function(){ + WebGL.mainContext.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + RenderTexture._currentRenderTarget=null; + this._alreadyResolved=true; + } + + /** + *获得像素数据。 + *@param x X像素坐标。 + *@param y Y像素坐标。 + *@param width 宽度。 + *@param height 高度。 + *@return 像素数据。 + */ + __proto.getData=function(x,y,width,height){ + var gl=WebGL.mainContext; + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer); + var canRead=(gl.checkFramebufferStatus(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40)===/*laya.webgl.WebGLContext.FRAMEBUFFER_COMPLETE*/0x8CD5); + if (!canRead){ + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + return null; + }; + var pixels=new Uint8Array(this._width *this._height *4); + gl.readPixels(x,y,width,height,this._surfaceFormat,this._surfaceType,pixels); + gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null); + return pixels; + } + + /** + *销毁资源。 + */ + __proto.detoryResource=function(){ + if (this._frameBuffer){ + var gl=WebGL.mainContext; + gl.deleteTexture(this._source); + gl.deleteFramebuffer(this._frameBuffer); + gl.deleteRenderbuffer(this._depthStencilBuffer); + this._source=null; + this._frameBuffer=null; + this._depthStencilBuffer=null; + this.memorySize=0; + } + } + + /** + *获取表面格式。 + *@return 表面格式。 + */ + __getset(0,__proto,'surfaceFormat',function(){ + return this._surfaceFormat; + }); + + /** + *获取表面类型。 + *@return 表面类型。 + */ + __getset(0,__proto,'surfaceType',function(){ + return this._surfaceType; + }); + + /** + *获取深度格式。 + *@return 深度格式。 + */ + __getset(0,__proto,'depthStencilFormat',function(){ + return this._depthStencilFormat; + }); + + /** + *获取RenderTarget数据源,如果alreadyResolved等于false,则返回null。 + *@return RenderTarget数据源。 + */ + __getset(0,__proto,'source',function(){ + if (this._alreadyResolved) + return _super.prototype._$get_source.call(this); + else + return null; + }); + + __getset(0,__proto,'depthStencilBuffer',function(){ + return this._depthStencilBuffer; + }); + + __getset(0,__proto,'frameBuffer',function(){ + return this._frameBuffer; + }); + + RenderTexture._currentRenderTarget=null + return RenderTexture; + })(BaseTexture) + + + /** + *SolidColorTexture2D 二维纯色纹理。 + */ + //class laya.d3.resource.SolidColorTexture2D extends laya.d3.resource.BaseTexture + var SolidColorTexture2D=(function(_super){ + function SolidColorTexture2D(color){ + this._color=null; + this._pixels=null; + SolidColorTexture2D.__super.call(this); + this._width=1; + this._height=1; + this._size=new Size(this.width,this.height); + this._color=color; + this._pixels=new Uint8Array([color.x *255,color.y *255,color.z *255,color.w *255]); + } + + __class(SolidColorTexture2D,'laya.d3.resource.SolidColorTexture2D',_super); + var __proto=SolidColorTexture2D.prototype; + /** + *@private + */ + __proto._createWebGlTexture=function(){ + var gl=WebGL.mainContext; + var glTex=this._source=gl.createTexture(); + var w=this._width; + var h=this._height; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,w,h,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._pixels); + var minFifter=this._minFifter; + var magFifter=this._magFifter; + var repeat=this._repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPot=Arith.isPOT(w,h); + if (isPot){ + if (this._mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this._mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + if (isPot) + this.memorySize=w *h *4 *(1+1 / 3); + else + this.memorySize=w *h *4; + } + + /** + *重新创建资源,如果异步创建中被强制释放再创建,则需等待释放完成后再重新加载创建。 + */ + __proto.recreateResource=function(){ + this.startCreate(); + this._createWebGlTexture(); + this.completeCreate(); + } + + /** + *销毁资源。 + */ + __proto.detoryResource=function(){ + if (this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this.memorySize=0; + } + } + + __getset(0,__proto,'source',function(){ + return _super.prototype._$get_source.call(this); + }); + + __static(SolidColorTexture2D, + ['magentaTexture',function(){return this.magentaTexture=new SolidColorTexture2D(new Vector4(1.0,0.0,1.0,1.0));},'grayTexture',function(){return this.grayTexture=new SolidColorTexture2D(new Vector4(0.5,0.5,0.5,1.0));} + ]); + return SolidColorTexture2D; + })(BaseTexture) + + + /** + *Sky 类用于创建天空盒。 + */ + //class laya.d3.resource.models.SkyBox extends laya.d3.resource.models.Sky + var SkyBox=(function(_super){ + function SkyBox(){ + this._sharderNameID=0; + this._shader=null; + this._numberVertices=0; + this._numberIndices=0; + this._vertexBuffer=null; + this._indexBuffer=null; + this._alphaBlending=1.0; + this._colorIntensity=1.0; + this._textureCube=null; + this._shaderValue=new ValusArray(); + SkyBox.__super.call(this); + this.name="Skybox-"+SkyBox._nameNumber; + SkyBox._nameNumber++; + this.loadShaderParams(); + this.recreateResource(); + } + + __class(SkyBox,'laya.d3.resource.models.SkyBox',_super); + var __proto=SkyBox.prototype; + /** + *@private + */ + __proto._getShader=function(state){ + var shaderDefs=state.shaderDefines; + var preDef=shaderDefs._value; + var nameID=shaderDefs._value+this._sharderNameID */*laya.webgl.shader.Shader.SHADERNAME2ID*/0.0002; + this._shader=Shader.withCompile(this._sharderNameID,state.shaderDefines.toNameDic(),nameID,null); + shaderDefs._value=preDef; + return this._shader; + } + + /** + *@private + */ + __proto.recreateResource=function(){ + this.startCreate(); + this._numberVertices=36; + this._numberIndices=36; + var indices=new Uint16Array(this._numberIndices); + var vertexFloatStride=SkyBox._vertexDeclaration.vertexStride / 4; + var vertices=new Float32Array(this._numberVertices *vertexFloatStride); + var width=1.0; + var height=1.0; + var depth=1.0; + var halfWidth=width / 2.0; + var halfHeight=height / 2.0; + var halfDepth=depth / 2.0; + var topLeftFront=new Vector3(-halfWidth,halfHeight,halfDepth); + var bottomLeftFront=new Vector3(-halfWidth,-halfHeight,halfDepth); + var topRightFront=new Vector3(halfWidth,halfHeight,halfDepth); + var bottomRightFront=new Vector3(halfWidth,-halfHeight,halfDepth); + var topLeftBack=new Vector3(-halfWidth,halfHeight,-halfDepth); + var topRightBack=new Vector3(halfWidth,halfHeight,-halfDepth); + var bottomLeftBack=new Vector3(-halfWidth,-halfHeight,-halfDepth); + var bottomRightBack=new Vector3(halfWidth,-halfHeight,-halfDepth); + var vertexCount=0; + vertexCount=this._addVertex(vertices,vertexCount,topLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightFront); + vertexCount=this._addVertex(vertices,vertexCount,topLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,topRightBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,topRightBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightBack); + vertexCount=this._addVertex(vertices,vertexCount,topLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightBack); + vertexCount=this._addVertex(vertices,vertexCount,topLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,topLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightFront); + vertexCount=this._addVertex(vertices,vertexCount,topLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,topLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,bottomLeftBack); + vertexCount=this._addVertex(vertices,vertexCount,topLeftFront); + vertexCount=this._addVertex(vertices,vertexCount,topRightFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightBack); + vertexCount=this._addVertex(vertices,vertexCount,topRightBack); + vertexCount=this._addVertex(vertices,vertexCount,topRightFront); + vertexCount=this._addVertex(vertices,vertexCount,bottomRightBack); + for (var i=0;i < 36;i++) + indices[i]=i; + this._vertexBuffer=new VertexBuffer3D(SkyBox._vertexDeclaration,this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._numberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._vertexBuffer.setData(vertices); + this._indexBuffer.setData(indices); + this.memorySize=(this._vertexBuffer.byteLength+this._indexBuffer.byteLength)*2; + this.completeCreate(); + } + + /** + *@private + */ + __proto._addVertex=function(vertices,index,position){ + var posE=position.elements; + vertices[index+0]=posE[0]; + vertices[index+1]=posE[1]; + vertices[index+2]=posE[2]; + return index+3; + } + + /** + *@private + */ + __proto.loadShaderParams=function(){ + this._sharderNameID=Shader.nameKey.get("SkyBox"); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.DIFFUSETEXTURE*/"DIFFUSETEXTURE",null); + } + + __proto._render=function(state){ + if (this._textureCube && this._textureCube.loaded){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + this._shader=this._getShader(state); + var presz=this._shaderValue.length; + this._shaderValue.pushArray(state.shaderValue); + this._shaderValue.pushArray(this._vertexBuffer.vertexDeclaration.shaderValues); + state.camera.transform.worldMatrix.cloneTo(SkyBox._tempMatrix4x40); + SkyBox._tempMatrix4x40.transpose(); + Matrix4x4.multiply(state.projectionMatrix,SkyBox._tempMatrix4x40,SkyBox._tempMatrix4x41); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.MVPMATRIX*/"MVPMATRIX",SkyBox._tempMatrix4x41.elements); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.INTENSITY*/"INTENSITY",this._colorIntensity); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.ALPHABLENDING*/"ALPHABLENDING",this.alphaBlending); + this._shaderValue.data[1]=this.textureCube.source; + this._shader.uploadArray(this._shaderValue.data,this._shaderValue.length,null); + this._shaderValue.length=presz; + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,36,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.trianglesFaces+=12; + Stat.drawCall++; + } + } + + /** + *设置透明混合度。 + *@param value 透明混合度。 + */ + /** + *获取透明混合度。 + *@return 透明混合度。 + */ + __getset(0,__proto,'alphaBlending',function(){ + return this._alphaBlending; + },function(value){ + this._alphaBlending=value; + if (this._alphaBlending < 0) + this._alphaBlending=0; + if (this._alphaBlending > 1) + this._alphaBlending=1; + }); + + /** + *设置天空立方体纹理。 + *@param value 天空立方体纹理。 + */ + /** + *获取天空立方体纹理。 + *@return 天空立方体纹理。 + */ + __getset(0,__proto,'textureCube',function(){ + return this._textureCube; + },function(value){ + this._textureCube=value; + }); + + /** + *设置颜色强度。 + *@param value 颜色强度。 + */ + /** + *获取颜色强度。 + *@return 颜色强度。 + */ + __getset(0,__proto,'colorIntensity',function(){ + return this._colorIntensity; + },function(value){ + this._colorIntensity=value; + if (this._colorIntensity < 0) + this._colorIntensity=0; + }); + + SkyBox._nameNumber=1; + __static(SkyBox, + ['_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_tempMatrix4x41',function(){return this._tempMatrix4x41=new Matrix4x4();},'_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(12,[new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION")]);} + ]); + return SkyBox; + })(Sky) + + + /** + *Sky 类用于创建天空盒。 + */ + //class laya.d3.resource.models.SkyDome extends laya.d3.resource.models.Sky + var SkyDome=(function(_super){ + function SkyDome(){ + this._sharderNameID=0; + this._shader=null; + this._numberVertices=0; + this._numberIndices=0; + this._vertexBuffer=null; + this._indexBuffer=null; + this._alphaBlending=1.0; + this._colorIntensity=1.0; + this._texture=null; + this._stacks=16; + this._slices=16; + this._radius=1; + this._shaderValue=new ValusArray(); + SkyDome.__super.call(this); + this.name="SkyDome-"+SkyDome._nameNumber; + SkyDome._nameNumber++; + this.loadShaderParams(); + this.recreateResource(); + } + + __class(SkyDome,'laya.d3.resource.models.SkyDome',_super); + var __proto=SkyDome.prototype; + /** + *@private + */ + __proto._getShader=function(state){ + var shaderDefs=state.shaderDefines; + var preDef=shaderDefs._value; + var nameID=shaderDefs._value+this._sharderNameID */*laya.webgl.shader.Shader.SHADERNAME2ID*/0.0002; + this._shader=Shader.withCompile(this._sharderNameID,state.shaderDefines.toNameDic(),nameID,null); + shaderDefs._value=preDef; + return this._shader; + } + + /** + *@private + */ + __proto.recreateResource=function(){ + this.startCreate(); + this._numberVertices=(this._stacks+1)*(this._slices+1); + this._numberIndices=(3 *this._stacks *(this._slices+1))*2; + var indices=new Uint16Array(this._numberIndices); + var vertexFloatStride=SkyDome._vertexDeclaration.vertexStride / 4; + var vertices=new Float32Array(this._numberVertices *vertexFloatStride); + var stackAngle=Math.PI / this._stacks; + var sliceAngle=(Math.PI *2.0)/ this._slices; + var vertexIndex=0; + var vertexCount=0; + var indexCount=0; + for (var stack=0;stack < (this._stacks+1);stack++){ + var r=Math.sin(stack *stackAngle); + var y=Math.cos(stack *stackAngle); + for (var slice=0;slice < (this._slices+1);slice++){ + var x=r *Math.sin(slice *sliceAngle); + var z=r *Math.cos(slice *sliceAngle); + vertices[vertexCount+0]=x *this._radius; + vertices[vertexCount+1]=y *this._radius; + vertices[vertexCount+2]=z *this._radius; + vertices[vertexCount+3]=slice / this._slices; + vertices[vertexCount+4]=stack / this._stacks; + vertexCount+=vertexFloatStride; + if (stack !=(this._stacks-1)){ + indices[indexCount++]=vertexIndex+1; + indices[indexCount++]=vertexIndex; + indices[indexCount++]=vertexIndex+(this._slices+1); + indices[indexCount++]=vertexIndex+(this._slices+1); + indices[indexCount++]=vertexIndex; + indices[indexCount++]=vertexIndex+(this._slices); + vertexIndex++; + } + } + } + this._vertexBuffer=new VertexBuffer3D(SkyDome._vertexDeclaration,this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._numberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + this._vertexBuffer.setData(vertices); + this._indexBuffer.setData(indices); + this.memorySize=(this._vertexBuffer.byteLength+this._indexBuffer.byteLength)*2; + this.completeCreate(); + } + + /** + *@private + */ + __proto.loadShaderParams=function(){ + this._sharderNameID=Shader.nameKey.get("SkyDome"); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.DIFFUSETEXTURE*/"DIFFUSETEXTURE",null); + } + + __proto._render=function(state){ + if (this._texture && this._texture.loaded){ + this._vertexBuffer._bind(); + this._indexBuffer._bind(); + this._shader=this._getShader(state); + var presz=this._shaderValue.length; + this._shaderValue.pushArray(state.shaderValue); + this._shaderValue.pushArray(this._vertexBuffer.vertexDeclaration.shaderValues); + state.camera.transform.worldMatrix.cloneTo(SkyDome._tempMatrix4x40); + SkyDome._tempMatrix4x40.transpose(); + Matrix4x4.multiply(state.projectionMatrix,SkyDome._tempMatrix4x40,SkyDome._tempMatrix4x41); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.MVPMATRIX*/"MVPMATRIX",SkyDome._tempMatrix4x41.elements); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.INTENSITY*/"INTENSITY",this._colorIntensity); + this._shaderValue.pushValue(/*laya.d3.resource.models.Sky.ALPHABLENDING*/"ALPHABLENDING",this.alphaBlending); + this._shaderValue.data[1]=this.texture.source; + this._shader.uploadArray(this._shaderValue.data,this._shaderValue.length,null); + this._shaderValue.length=presz; + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._indexBuffer.indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + Stat.trianglesFaces+=this._numberIndices / 3; + Stat.drawCall++; + } + } + + /** + *设置透明混合度。 + *@param value 透明混合度。 + */ + /** + *获取透明混合度。 + *@return 透明混合度。 + */ + __getset(0,__proto,'alphaBlending',function(){ + return this._alphaBlending; + },function(value){ + this._alphaBlending=value; + if (this._alphaBlending < 0) + this._alphaBlending=0; + if (this._alphaBlending > 1) + this._alphaBlending=1; + }); + + /** + *设置颜色强度。 + *@param value 颜色强度。 + */ + /** + *获取颜色强度。 + *@return 颜色强度。 + */ + __getset(0,__proto,'colorIntensity',function(){ + return this._colorIntensity; + },function(value){ + this._colorIntensity=value; + if (this._colorIntensity < 0) + this._colorIntensity=0; + }); + + /** + *设置天空立方体纹理。 + *@param value 天空立方体纹理。 + */ + /** + *获取天空立方体纹理。 + *@return 天空立方体纹理。 + */ + __getset(0,__proto,'texture',function(){ + return this._texture; + },function(value){ + this._texture=value; + }); + + SkyDome._nameNumber=1; + __static(SkyDome, + ['_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_tempMatrix4x41',function(){return this._tempMatrix4x41=new Matrix4x4();},'_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(20,[new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.VertexElementUsage.POSITION0*/"POSITION"),new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.VertexElementUsage.TEXTURECOORDINATE0*/"UV")]);} + ]); + return SkyDome; + })(Sky) + + + /** + *Texture2D 二维纹理。 + */ + //class laya.d3.resource.Texture2D extends laya.d3.resource.BaseTexture + var Texture2D=(function(_super){ + function Texture2D(){ + this._src=null; + this._image=null; + this._recreateLock=false; + this._needReleaseAgain=false; + Texture2D.__super.call(this); + } + + __class(Texture2D,'laya.d3.resource.Texture2D',_super); + var __proto=Texture2D.prototype; + /** + *@private + */ + __proto._onTextureLoaded=function(img){ + this._image=img; + var w=img.width; + var h=img.height; + this._width=w; + this._height=h; + this._size=new Size(w,h); + } + + /** + *@private + */ + __proto._createWebGlTexture=function(){ + if (!this._image){ + throw "create GLTextur err:no data:"+this._image; + }; + var gl=WebGL.mainContext; + var glTex=this._source=gl.createTexture(); + var w=this._width; + var h=this._height; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._image); + var minFifter=this._minFifter; + var magFifter=this._magFifter; + var repeat=this._repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPot=Arith.isPOT(w,h); + if (isPot){ + if (this._mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this._mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + this._image.onload=null; + this._image=null; + if (isPot) + this.memorySize=w *h *4 *(1+1 / 3); + else + this.memorySize=w *h *4; + this._recreateLock=false; + } + + /** + *重新创建资源,如果异步创建中被强制释放再创建,则需等待释放完成后再重新加载创建。 + */ + __proto.recreateResource=function(){ + if (this._src==null || this._src==="") + return; + this._needReleaseAgain=false; + if (!this._image){ + this._recreateLock=true; + this.startCreate(); + var _this=this; + this._image=new Browser.window.Image(); + this._image.crossOrigin=""; + this._image.onload=function (){ + if (_this._needReleaseAgain){ + _this._needReleaseAgain=false; + _this._image.onload=null; + _this._image=null; + return; + } + _this._createWebGlTexture(); + _this.completeCreate(); + }; + this._image.src=this._src; + }else { + if (this._recreateLock){ + return; + } + this.startCreate(); + this._createWebGlTexture(); + this.completeCreate(); + } + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + this._src=url; + this._onTextureLoaded(data); + this.activeResource(); + this._loaded=true; + this.event(/*laya.events.Event.LOADED*/"loaded",this); + } + + /** + *销毁资源。 + */ + __proto.detoryResource=function(){ + if (this._recreateLock){ + this._needReleaseAgain=true; + } + if (this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this._image=null; + this.memorySize=0; + } + } + + /** + *获取文件路径全名。 + */ + __getset(0,__proto,'src',function(){ + return this._src; + }); + + Texture2D.load=function(url){ + return Laya.loader.create(url,null,null,Texture2D); + } + + return Texture2D; + })(BaseTexture) + + + //class laya.d3.resource.TextureCube extends laya.d3.resource.BaseTexture + var TextureCube=(function(_super){ + function TextureCube(){ + this._texCount=6; + //this._images=null; + //this._srcs=null; + this._recreateLock=false; + this._needReleaseAgain=false; + TextureCube.__super.call(this); + } + + __class(TextureCube,'laya.d3.resource.TextureCube',_super); + var __proto=TextureCube.prototype; + /** + *@private + */ + __proto._onTextureLoaded=function(images){ + this._images=images; + var minWidth=2147483647; + var minHeight=2147483647; + for (var i=0;i < 6;i++){ + var image=images[i]; + minWidth=Math.min(minWidth,image.width); + minHeight=Math.min(minHeight,image.height); + } + this._width=minWidth; + this._height=minHeight; + this._size=new Size(minWidth,minHeight); + } + + __proto._createWebGlTexture=function(){ + var i=0; + for (i=0;i < this._texCount;i++){ + if (!this._images[i]){ + throw "create GLTextur err:no data:"+this._images[i]; + } + }; + var gl=WebGL.mainContext; + var glTex=this._source=gl.createTexture(); + var w=this._width; + var h=this._height; + var preTarget=WebGLContext.curBindTexTarget; + var preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,glTex); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_X*/0x8515,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[0]); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_X*/0x8516,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[1]); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Y*/0x8517,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[2]); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Y*/0x8518,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[3]); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Z*/0x8519,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[4]); + gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Z*/0x851A,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this._images[5]); + var minFifter=this.minFifter; + var magFifter=this.magFifter; + var repeat=this.repeat ? /*laya.webgl.WebGLContext.REPEAT*/0x2901 :/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F; + var isPOT=Arith.isPOT(w,h); + if (isPOT){ + if (this.mipmap) + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR_MIPMAP_LINEAR*/0x2703); + else + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,repeat); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,repeat); + this.mipmap && gl.generateMipmap(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513); + }else { + (minFifter!==-1)|| (minFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (magFifter!==-1)|| (magFifter=/*laya.webgl.WebGLContext.LINEAR*/0x2601); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,minFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,magFifter); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + } + (preTarget && preTexture)&& (WebGLContext.bindTexture(gl,preTarget,preTexture)); + for (i=0;i < 6;i++){ + this._images[i].onload=null; + this._images[i]=null; + } + if (isPOT) + this.memorySize=w *h *4 *(1+1 / 3)*this._texCount; + else + this.memorySize=w *h *4 *this._texCount; + this._recreateLock=false; + } + + __proto.recreateResource=function(){ + var _$this=this; + if (this._srcs==null) + return; + this._needReleaseAgain=false; + if (!this._images[0]){ + this._recreateLock=true; + this.startCreate(); + var _this=this; + for (var i=0;i < this._texCount;i++){ + this._images[i]=new Browser.window.Image(); + this._images[i].crossOrigin=""; + var index=i; + this._images[index].onload=function (){ + var j=0; + if (_this._needReleaseAgain){ + for (j=0;j < _$this._texCount;j++) + if (!_this._images[j].complete) + return; + _this._needReleaseAgain=false; + for (j=0;j < _$this._texCount;j++){ + _this._images[j].onload=null; + _this._images[j]=null; + } + return; + } + for (j=0;j < _$this._texCount;j++) + if (!_this._images[j].complete) + return; + _this._createWebGlTexture(); + _this.completeCreate(); + }; + this._images[i].src=this._srcs[i]; + } + }else { + if (this._recreateLock){ + return; + } + this.startCreate(); + this._createWebGlTexture(); + this.completeCreate(); + } + } + + /** + *@private + */ + __proto.onAsynLoaded=function(url,data){ + this._srcs=url; + this._onTextureLoaded(data); + this.activeResource(); + this._loaded=true; + this.event(/*laya.events.Event.LOADED*/"loaded",this); + } + + __proto.detoryResource=function(){ + if (this._recreateLock){ + this._needReleaseAgain=true; + } + if (this._source){ + WebGL.mainContext.deleteTexture(this._source); + this._source=null; + this.memorySize=0; + } + } + + /** + *文件路径全名。 + */ + __getset(0,__proto,'srcs',function(){ + return this._srcs; + }); + + TextureCube.load=function(url){ + return Laya.loader.create(url,null,null,TextureCube); + } + + return TextureCube; + })(BaseTexture) + + + /** + *Scene 类用于实现普通场景。 + */ + //class laya.d3.core.scene.Scene extends laya.d3.core.scene.BaseScene + var Scene=(function(_super){ + /** + *创建一个 Scene 实例。 + */ + function Scene(){ + Scene.__super.call(this); + } + + __class(Scene,'laya.d3.core.scene.Scene',_super); + var __proto=Scene.prototype; + __proto._renderCamera=function(gl,state,camera){ + this._prepareRenderToRenderState(camera,state); + this.beforeRender(state); + var renderTarget=camera.renderTarget; + if (renderTarget){ + renderTarget.start(); + Matrix4x4.multiply(this._invertYScaleMatrix,camera.projectionMatrix,this._invertYProjectionMatrix); + Matrix4x4.multiply(this._invertYScaleMatrix,camera.projectionViewMatrix,this._invertYProjectionViewMatrix); + state.projectionMatrix=this._invertYProjectionMatrix; + state.projectionViewMatrix=this._invertYProjectionViewMatrix; + }else { + state.projectionMatrix=camera.projectionMatrix; + state.projectionViewMatrix=camera.projectionViewMatrix; + } + state.viewMatrix=camera.viewMatrix; + state.viewport=camera.viewport; + this._preRenderScene(gl,state); + this._clear(gl,state); + this._renderScene(gl,state); + this.lateRender(state); + this._endRenderToRenderState(state); + (renderTarget)&& (renderTarget.end()); + } + + /** + *@private + */ + __proto.renderSubmit=function(){ + var gl=WebGL.mainContext; + this._set3DRenderConfig(gl); + for (var i=0,n=this._cameraPool.length;i < n;i++){ + var camera=this._cameraPool [i]; + (camera.enable)&& (this._renderCamera(gl,this._renderState,camera)); + } + this._set2DRenderConfig(gl); + return 1; + } + + return Scene; + })(BaseScene) + + + /** + *VRScene 类用于实现VR场景。 + */ + //class laya.d3.core.scene.VRScene extends laya.d3.core.scene.BaseScene + var VRScene=(function(_super){ + /** + *创建一个 VRScene 实例。 + */ + function VRScene(){ + VRScene.__super.call(this); + } + + __class(VRScene,'laya.d3.core.scene.VRScene',_super); + var __proto=VRScene.prototype; + __proto.renderCamera=function(gl,state,cameraVR){ + this._prepareRenderToRenderState(cameraVR,state); + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.VR*/0x40); + this.beforeRender(state); + var renderTarget=cameraVR.renderTarget; + if (renderTarget){ + renderTarget.start(); + Matrix4x4.multiply(this._invertYScaleMatrix,cameraVR.leftProjectionMatrix,this._invertYProjectionMatrix); + Matrix4x4.multiply(this._invertYScaleMatrix,cameraVR.leftProjectionViewMatrix,this._invertYProjectionViewMatrix); + state.projectionMatrix=this._invertYProjectionMatrix; + state.projectionViewMatrix=this._invertYProjectionViewMatrix; + }else { + state.projectionMatrix=cameraVR.leftProjectionMatrix; + state.projectionViewMatrix=cameraVR.leftProjectionViewMatrix; + } + state.viewMatrix=cameraVR.leftViewMatrix; + state.viewport=cameraVR.leftViewport; + this._preRenderScene(gl,state); + this._clear(gl,state); + this._renderScene(gl,state); + if (renderTarget){ + renderTarget.start(); + Matrix4x4.multiply(this._invertYScaleMatrix,cameraVR.rightProjectionMatrix,this._invertYProjectionMatrix); + Matrix4x4.multiply(this._invertYScaleMatrix,cameraVR.rightProjectionViewMatrix,this._invertYProjectionViewMatrix); + state.projectionMatrix=this._invertYProjectionMatrix; + state.projectionViewMatrix=this._invertYProjectionViewMatrix; + }else { + state.projectionMatrix=cameraVR.rightProjectionMatrix; + state.projectionViewMatrix=cameraVR.rightProjectionViewMatrix; + } + state.viewMatrix=cameraVR.rightViewMatrix; + state.viewport=cameraVR.rightViewport; + this._preRenderScene(gl,state); + this._clear(gl,state); + this._renderScene(gl,state); + this.lateRender(state); + (renderTarget)&& (renderTarget.end()); + } + + /** + *@private + */ + __proto.renderSubmit=function(){ + var gl=WebGL.mainContext; + var state=this._renderState; + this._set3DRenderConfig(gl); + for (var i=0,n=this._cameraPool.length;i < n;i++){ + var cameraVR=this._cameraPool [i]; + if (cameraVR.enable) + this.renderCamera(gl,state,cameraVR); + } + this._set2DRenderConfig(gl); + return 1; + } + + return VRScene; + })(BaseScene) + + + /** + *Camera 类用于创建摄像机。 + */ + //class laya.d3.core.Camera extends laya.d3.core.BaseCamera + var Camera=(function(_super){ + function Camera(aspectRatio,nearPlane,farPlane){ + //this._aspectRatio=NaN; + //this._viewport=null; + //this._normalizedViewport=null; + //this._viewMatrix=null; + //this._projectionMatrix=null; + //this._projectionViewMatrix=null; + (aspectRatio===void 0)&& (aspectRatio=0); + (nearPlane===void 0)&& (nearPlane=0.1); + (farPlane===void 0)&& (farPlane=1000); + this._viewMatrix=new Matrix4x4(); + this._projectionMatrix=new Matrix4x4(); + this._projectionViewMatrix=new Matrix4x4(); + this._viewport=new Viewport(0,0,0,0); + this._normalizedViewport=new Viewport(0,0,1,1); + this._aspectRatio=aspectRatio; + Camera.__super.call(this,nearPlane,farPlane); + } + + __class(Camera,'laya.d3.core.Camera',_super); + var __proto=Camera.prototype; + /** + *@private + *计算投影矩阵。 + */ + __proto._calculateProjectionMatrix=function(){ + if (!this._useUserProjectionMatrix){ + if (this.orthographicProjection){ + var halfWidth=this.orthographicVerticalSize *this.aspectRatio *0.5; + var halfHeight=this.orthographicVerticalSize *0.5; + Matrix4x4.createOrthogonal(-halfWidth,halfWidth,-halfHeight,halfHeight,this.nearPlane,this.farPlane,this._projectionMatrix); + }else { + Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix); + } + } + this._projectionMatrixModifyID+=0.01 / this.id; + } + + /** + *计算从屏幕空间生成的射线。 + *@param point 屏幕空间的位置位置。 + *@return out 输出射线。 + */ + __proto.viewportPointToRay=function(point,out){ + Picker.calculateCursorRay(point,this.viewport,this._projectionMatrix,this.viewMatrix,null,out); + } + + /** + *计算从裁切空间生成的射线。 + *@param point 裁切空间的位置。。 + *@return out 输出射线。 + */ + __proto.normalizedViewportPointToRay=function(point,out){ + var finalPoint=Camera._tempVector2; + var vp=this.viewport; + var nVpPosE=point.elements; + var vpPosE=finalPoint.elements; + vpPosE[0]=nVpPosE[0] *vp.width; + vpPosE[1]=nVpPosE[1] *vp.height; + Picker.calculateCursorRay(finalPoint,this.viewport,this._projectionMatrix,this.viewMatrix,null,out); + } + + /** + *计算从世界空间准换三维坐标到屏幕空间。 + *@param position 世界空间的位置。 + *@return out 输出位置。 + */ + __proto.worldToViewportPoint=function(position,out){ + Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix); + this.viewport.project(position,this._projectionViewMatrix,out); + if (out.z < 0.0 || out.z > 1.0){ + var outE=out.elements; + outE[0]=outE[1]=outE[2]=NaN; + } + } + + /** + *计算从世界空间准换三维坐标到裁切空间。 + *@param position 世界空间的位置。 + *@return out 输出位置。 + */ + __proto.worldToNormalizedViewportPoint=function(position,out){ + Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix); + this.normalizedViewport.project(position,this._projectionViewMatrix,out); + if (out.z < 0.0 || out.z > 1.0){ + var outE=out.elements; + outE[0]=outE[1]=outE[2]=NaN; + } + } + + /** + *获取视图投影矩阵。 + *@return 视图投影矩阵。 + */ + __getset(0,__proto,'projectionViewMatrix',function(){ + Matrix4x4.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix); + return this._projectionViewMatrix; + }); + + /** + *设置横纵比。 + *@param value 横纵比。 + */ + /** + *获取横纵比。 + *@return 横纵比。 + */ + __getset(0,__proto,'aspectRatio',function(){ + if (this._aspectRatio===0){ + var vp=this.viewport; + return vp.width / vp.height; + } + return this._aspectRatio; + },function(value){ + if (value < 0) + throw new Error("Camera: the aspect ratio has to be a positive real number."); + this._aspectRatio=value; + this._calculateProjectionMatrix(); + }); + + __getset(0,__proto,'needViewport',function(){ + var nVp=this.normalizedViewport; + return nVp.x===0 && nVp.y===0 && nVp.width===1 && nVp.height===1; + }); + + /** + *设置屏幕空间的视口。 + *@param 屏幕空间的视口。 + */ + /** + *获取屏幕空间的视口。 + *@return 屏幕空间的视口。 + */ + __getset(0,__proto,'viewport',function(){ + if (this._viewportExpressedInClipSpace){ + var nVp=this._normalizedViewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._viewport.x=nVp.x *sizeW; + this._viewport.y=nVp.y *sizeH; + this._viewport.width=nVp.width *sizeW; + this._viewport.height=nVp.height *sizeH; + } + return this._viewport; + },function(value){ + if (this.renderTarget !=null && (value.x < 0 || value.y < 0 || value.width==0 || value.height==0)) + throw new Error("Camera: viewport size invalid.","value"); + this._viewportExpressedInClipSpace=false; + this._viewport=value; + this._calculateProjectionMatrix(); + }); + + /** + *设置裁剪空间的视口。 + *@return 裁剪空间的视口。 + */ + /** + *获取裁剪空间的视口。 + *@return 裁剪空间的视口。 + */ + __getset(0,__proto,'normalizedViewport',function(){ + if (!this._viewportExpressedInClipSpace){ + var vp=this._viewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._normalizedViewport.x=vp.x / sizeW; + this._normalizedViewport.y=vp.y / sizeH; + this._normalizedViewport.width=vp.width / sizeW; + this._normalizedViewport.height=vp.height / sizeH; + } + return this._normalizedViewport; + },function(value){ + if (value.x < 0 || value.y < 0 || (value.x+value.width)> 1 || (value.x+value.height)> 1) + throw new Error("Camera: viewport size invalid.","value"); + this._viewportExpressedInClipSpace=true; + this._normalizedViewport=value; + this._calculateProjectionMatrix(); + }); + + /**设置投影矩阵。*/ + /**获取投影矩阵。*/ + __getset(0,__proto,'projectionMatrix',function(){ + return this._projectionMatrix; + },function(value){ + this._projectionMatrix=value; + this._useUserProjectionMatrix=true; + }); + + /** + *获取视图矩阵。 + *@return 视图矩阵。 + */ + __getset(0,__proto,'viewMatrix',function(){ + this.transform.worldMatrix.invert(this._viewMatrix); + return this._viewMatrix; + }); + + __static(Camera, + ['_tempVector2',function(){return this._tempVector2=new Vector2();} + ]); + return Camera; + })(BaseCamera) + + + /** + *DirectionLight 类用于创建平行光。 + */ + //class laya.d3.core.light.DirectionLight extends laya.d3.core.light.LightSprite + var DirectionLight=(function(_super){ + function DirectionLight(){ + this._direction=null; + DirectionLight.__super.call(this); + this._diffuseColor=new Vector3(1.0,1.0,1.0); + this._ambientColor=new Vector3(0.6,0.6,0.6); + this._specularColor=new Vector3(1.0,1.0,1.0); + this._reflectColor=new Vector3(1.0,1.0,1.0); + this._direction=new Vector3(0.0,-0.5,-1.0); + } + + __class(DirectionLight,'laya.d3.core.light.DirectionLight',_super); + var __proto=DirectionLight.prototype; + /** + *更新平行光相关渲染状态参数。 + *@param state 渲染状态参数。 + */ + __proto.updateToWorldState=function(state){ + if (state.scene.enableLight){ + var shaderValue=state.shaderValue; + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.DIRECTIONLIGHT*/0x1000); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.LIGHTDIRDIFFUSE*/"LIGHTDIRDIFFUSE",this.diffuseColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.LIGHTDIRAMBIENT*/"LIGHTDIRAMBIENT",this.ambientColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.LIGHTDIRSPECULAR*/"LIGHTDIRSPECULAR",this.specularColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.LIGHTDIRECTION*/"LIGHTDIRECTION",this.direction.elements); + } + } + + /** + *设置平行光的方向。 + *@param value 平行光的方向。 + */ + /** + *获取平行光的方向。 + *@return 平行光的方向。 + */ + __getset(0,__proto,'direction',function(){ + return this._direction; + },function(value){ + this._direction=value; + }); + + /** + *获取平行光的类型。 + *@return 平行光的类型。 + */ + __getset(0,__proto,'lightType',function(){ + return 1; + }); + + return DirectionLight; + })(LightSprite) + + + /** + *PointLight 类用于创建点光。 + */ + //class laya.d3.core.light.PointLight extends laya.d3.core.light.LightSprite + var PointLight=(function(_super){ + function PointLight(){ + this._attenuation=null; + this._range=NaN; + PointLight.__super.call(this); + this._diffuseColor=new Vector3(1.0,1.0,1.0); + this._ambientColor=new Vector3(0.2,0.2,0.2); + this._specularColor=new Vector3(1.0,0.0,0.0); + this._reflectColor=new Vector3(1.0,1.0,1.0); + this.transform.position=new Vector3(0.0,0.0,0.0); + this._range=6.0; + this._attenuation=new Vector3(0.6,0.6,0.6); + } + + __class(PointLight,'laya.d3.core.light.PointLight',_super); + var __proto=PointLight.prototype; + /** + *更新点光相关渲染状态参数。 + *@param state 渲染状态参数。 + */ + __proto.updateToWorldState=function(state){ + if (state.scene.enableLight){ + var shaderValue=state.shaderValue; + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.POINTLIGHT*/0x2000); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTDIFFUSE*/"POINTLIGHTDIFFUSE",this.diffuseColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTAMBIENT*/"POINTLIGHTAMBIENT",this.ambientColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTSPECULAR*/"POINTLIGHTSPECULAR",this.specularColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTPOS*/"POINTLIGHTPOS",this.transform.position.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTRANGE*/"POINTLIGHTRANGE",this.range); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.POINTLIGHTATTENUATION*/"POINTLIGHTATTENUATION",this.attenuation.elements); + } + } + + /** + *设置点光的范围。 + *@param value 点光的范围。 + */ + /** + *获取点光的范围。 + *@return 点光的范围。 + */ + __getset(0,__proto,'range',function(){ + return this._range; + },function(value){ + this._range=value; + }); + + /** + *获取点光的类型。 + *@return 点光的类型。 + */ + __getset(0,__proto,'lightType',function(){ + return 2; + }); + + /** + *设置点光的衰减。 + *@param value 点光的衰减。 + */ + /** + *获取点光的衰减。 + *@return 点光的衰减。 + */ + __getset(0,__proto,'attenuation',function(){ + return this._attenuation; + },function(value){ + this._attenuation=value; + }); + + return PointLight; + })(LightSprite) + + + /** + *SpotLight 类用于创建聚光。 + */ + //class laya.d3.core.light.SpotLight extends laya.d3.core.light.LightSprite + var SpotLight=(function(_super){ + function SpotLight(){ + this._direction=null; + this._attenuation=null; + this._spot=NaN; + this._range=NaN; + SpotLight.__super.call(this); + this._diffuseColor=new Vector3(1.0,1.0,1.0); + this._ambientColor=new Vector3(0.2,0.2,0.2); + this._specularColor=new Vector3(1.0,1.0,1.0); + this._reflectColor=new Vector3(1.0,1.0,1.0); + this.transform.position=new Vector3(0.0,1.0,1.0); + this._direction=new Vector3(0.0,-1.0,-1.0); + this._attenuation=new Vector3(0.6,0.6,0.6); + this._spot=96.0; + this._range=6.0; + } + + __class(SpotLight,'laya.d3.core.light.SpotLight',_super); + var __proto=SpotLight.prototype; + /** + *更新聚光相关渲染状态参数。 + *@param state 渲染状态参数。 + */ + __proto.updateToWorldState=function(state){ + if (state.scene.enableLight){ + var shaderValue=state.shaderValue; + state.shaderDefines.add(/*laya.d3.shader.ShaderDefines3D.SPOTLIGHT*/0x4000); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTDIFFUSE*/"SPOTLIGHTDIFFUSE",this.diffuseColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTAMBIENT*/"SPOTLIGHTAMBIENT",this.ambientColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTSPECULAR*/"SPOTLIGHTSPECULAR",this.specularColor.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTPOS*/"SPOTLIGHTPOS",this.transform.position.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTDIRECTION*/"SPOTLIGHTDIRECTION",this.direction.elements); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTRANGE*/"SPOTLIGHTRANGE",this.range); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTSPOT*/"SPOTLIGHTSPOT",this.spot); + shaderValue.pushValue(/*laya.d3.core.scene.BaseScene.SPOTLIGHTATTENUATION*/"SPOTLIGHTATTENUATION",this.attenuation.elements); + } + } + + /** + *设置聚光的范围。 + *@param value 聚光的范围值。 + */ + /** + *获取聚光的范围。 + *@return 聚光的范围值。 + */ + __getset(0,__proto,'range',function(){ + return this._range; + },function(value){ + this._range=value; + }); + + /** + *设置聚光的方向。 + *@param value 聚光的方向。 + */ + /** + *获取聚光的方向。 + *@return 聚光的方向。 + */ + __getset(0,__proto,'direction',function(){ + return this._direction; + },function(value){ + this._direction=value; + }); + + /** + *获取聚光的类型。 + *@return 聚光的类型。 + */ + __getset(0,__proto,'lightType',function(){ + return 3; + }); + + /** + *设置聚光的衰减。 + *@param value 聚光的衰减。 + */ + /** + *获取聚光的衰减。 + *@return 聚光的衰减。 + */ + __getset(0,__proto,'attenuation',function(){ + return this._attenuation; + },function(value){ + this._attenuation=value; + }); + + /** + *设置聚光的聚光值。 + *@param value 聚光的聚光值。 + */ + /** + *获取聚光的聚光值。 + *@return 聚光的聚光值。 + */ + __getset(0,__proto,'spot',function(){ + return this._spot; + },function(value){ + this._spot=value; + }); + + return SpotLight; + })(LightSprite) + + + /** + *TerrainMeshSprite3D 类用于创建网格。 + */ + //class laya.d3.core.MeshTerrainSprite3D extends laya.d3.core.MeshSprite3D + var MeshTerrainSprite3D=(function(_super){ + function MeshTerrainSprite3D(mesh,heightMap,name){ + this._minX=NaN; + this._minZ=NaN; + this._cellSize=null; + this._heightMap=null; + MeshTerrainSprite3D.__super.call(this,mesh,name); + this._heightMap=heightMap; + this._cellSize=new Vector2(); + } + + __class(MeshTerrainSprite3D,'laya.d3.core.MeshTerrainSprite3D',_super); + var __proto=MeshTerrainSprite3D.prototype; + /** + *@private + */ + __proto._disableRotation=function(){ + var rotation=this.transform.rotation; + rotation.elements[0]=0; + rotation.elements[1]=0; + rotation.elements[2]=0; + rotation.elements[3]=1; + this.transform.rotation=rotation; + } + + /** + *@private + */ + __proto._getScaleX=function(){ + var worldMat=this.transform.worldMatrix; + var worldMatE=worldMat.elements; + var m11=worldMatE[0]; + var m12=worldMatE[1]; + var m13=worldMatE[2]; + return Math.sqrt((m11 *m11)+(m12 *m12)+(m13 *m13)); + } + + /** + *@private + */ + __proto._getScaleZ=function(){ + var worldMat=this.transform.worldMatrix; + var worldMatE=worldMat.elements; + var m31=worldMatE[8]; + var m32=worldMatE[9]; + var m33=worldMatE[10]; + return Math.sqrt((m31 *m31)+(m32 *m32)+(m33 *m33)); + } + + /** + *@private + */ + __proto._initCreateFromMesh=function(heightMapWidth,heightMapHeight){ + this._heightMap=HeightMap.creatFromMesh(this.meshFilter.sharedMesh,heightMapWidth,heightMapHeight,this._cellSize); + var boundingBox=this.meshFilter.sharedMesh.boundingBox; + var min=boundingBox.min; + var max=boundingBox.max; + this._minX=min.x; + this._minZ=min.z; + } + + /** + *@private + */ + __proto._createFromMeshAndHeightMapMeshLoaded=function(sender,texture,minHeight,maxHeight){ + this._initCreateFromMeshHeightMap(texture,minHeight,maxHeight); + } + + /** + *@private + */ + __proto._initCreateFromMeshHeightMap=function(texture,minHeight,maxHeight){ + var _$this=this; + var boundingBox=this.meshFilter.sharedMesh.boundingBox; + if (texture.loaded){ + this._heightMap=HeightMap.createFromImage(texture,minHeight,maxHeight); + this._computeCellSize(boundingBox); + }else { + texture.once(/*laya.events.Event.LOADED*/"loaded",null,function(){ + _$this._heightMap=HeightMap.createFromImage(texture,minHeight,maxHeight); + _$this._computeCellSize(boundingBox); + }); + }; + var min=boundingBox.min; + var max=boundingBox.max; + this._minX=min.x; + this._minZ=min.z; + } + + /** + *@private + */ + __proto._computeCellSize=function(boundingBox){ + var min=boundingBox.min; + var max=boundingBox.max; + var minX=min.x; + var minZ=min.z; + var maxX=max.x; + var maxZ=max.z; + var widthSize=maxX-minX; + var heightSize=maxZ-minZ; + this._cellSize.elements[0]=widthSize / (this._heightMap.width-1); + this._cellSize.elements[1]=heightSize / (this._heightMap.height-1); + } + + /** + *@private + */ + __proto._update=function(state){ + this._disableRotation(); + _super.prototype._update.call(this,state); + } + + /** + *获取地形高度。 + *@param x X轴坐标。 + *@param z Z轴坐标。 + */ + __proto.getHeight=function(x,z){ + MeshTerrainSprite3D._tempVector3.elements[0]=x; + MeshTerrainSprite3D._tempVector3.elements[1]=0; + MeshTerrainSprite3D._tempVector3.elements[2]=z; + this._disableRotation(); + var worldMat=this.transform.worldMatrix; + worldMat.invert(MeshTerrainSprite3D._tempMatrix4x4); + Vector3.transformCoordinate(MeshTerrainSprite3D._tempVector3,MeshTerrainSprite3D._tempMatrix4x4,MeshTerrainSprite3D._tempVector3); + x=MeshTerrainSprite3D._tempVector3.elements[0]; + z=MeshTerrainSprite3D._tempVector3.elements[2]; + var c=(x-this._minX)/ this._cellSize.x; + var d=(z-this._minZ)/ this._cellSize.y; + var row=Math.floor(d); + var col=Math.floor(c); + var s=c-col; + var t=d-row; + var uy=NaN; + var vy=NaN; + var worldMatE=worldMat.elements; + var m21=worldMatE[4]; + var m22=worldMatE[5]; + var m23=worldMatE[6]; + var scaleY=Math.sqrt((m21 *m21)+(m22 *m22)+(m23 *m23)); + var translateY=worldMatE[13]; + var h01=this._heightMap.getHeight(row,col+1); + var h10=this._heightMap.getHeight((row+1),col); + if (isNaN(h01)|| isNaN(h10)) + return NaN; + if (s+t <=1.0){ + var h00=this._heightMap.getHeight(row,col); + if (isNaN(h00)) + return NaN; + uy=h01-h00; + vy=h10-h00; + return (h00+s *uy+t *vy)*scaleY+translateY; + }else { + var h11=this._heightMap.getHeight((row+1),col+1); + if (isNaN(h11)) + return NaN; + uy=h10-h11; + vy=h01-h11; + return (h11+(1.0-s)*uy+(1.0-t)*vy)*scaleY+translateY; + } + } + + /** + *获取地形X轴最小位置。 + *@return 地形X轴最小位置。 + */ + __getset(0,__proto,'minX',function(){ + var worldMat=this.transform.worldMatrix; + var worldMatE=worldMat.elements; + return this._minX *this._getScaleX()+worldMatE[12]; + }); + + /** + *获取地形X轴长度。 + *@return 地形X轴长度。 + */ + __getset(0,__proto,'width',function(){ + return (this._heightMap.width-1)*this._cellSize.x *this._getScaleX(); + }); + + /** + *获取地形Z轴最小位置。 + *@return 地形X轴最小位置。 + */ + __getset(0,__proto,'minZ',function(){ + var worldMat=this.transform.worldMatrix; + var worldMatE=worldMat.elements; + return this._minZ *this._getScaleZ()+worldMatE[14]; + }); + + /** + *获取地形Z轴长度。 + *@return 地形Z轴长度。 + */ + __getset(0,__proto,'depth',function(){ + return (this._heightMap.height-1)*this._cellSize.y *this._getScaleZ(); + }); + + MeshTerrainSprite3D.createFromMesh=function(mesh,heightMapWidth,heightMapHeight,name){ + var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name); + if (mesh.loaded) + meshTerrainSprite3D._initCreateFromMesh(heightMapWidth,heightMapHeight); + else + mesh.once(/*laya.events.Event.LOADED*/"loaded",meshTerrainSprite3D,meshTerrainSprite3D._initCreateFromMesh,[heightMapWidth,heightMapHeight]); + return meshTerrainSprite3D; + } + + MeshTerrainSprite3D.createFromMeshAndHeightMap=function(mesh,texture,minHeight,maxHeight,name){ + var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name); + if (mesh.loaded) + meshTerrainSprite3D._initCreateFromMeshHeightMap(texture,minHeight,maxHeight); + else + mesh.once(/*laya.events.Event.LOADED*/"loaded",meshTerrainSprite3D,meshTerrainSprite3D._createFromMeshAndHeightMapMeshLoaded,[texture,maxHeight]); + return meshTerrainSprite3D; + } + + __static(MeshTerrainSprite3D, + ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();} + ]); + return MeshTerrainSprite3D; + })(MeshSprite3D) + + + /** + *Camera 类用于创建VR摄像机。 + */ + //class laya.d3.core.VRCamera extends laya.d3.core.BaseCamera + var VRCamera=(function(_super){ + function VRCamera(pupilDistande,leftAspectRatio,rightAspectRatio,nearPlane,farPlane){ + //this._tempMatrix=null; + //this._leftAspectRatio=NaN; + //this._leftViewport=null; + //this._leftNormalizedViewport=null; + //this._leftViewMatrix=null; + //this._leftProjectionMatrix=null; + //this._leftProjectionViewMatrix=null; + //this._rightAspectRatio=NaN; + //this._rightViewport=null; + //this._rightNormalizedViewport=null; + //this._rightViewMatrix=null; + //this._rightProjectionMatrix=null; + //this._rightProjectionViewMatrix=null; + //this._pupilDistande=0; + (pupilDistande===void 0)&& (pupilDistande=0.1); + (leftAspectRatio===void 0)&& (leftAspectRatio=0); + (rightAspectRatio===void 0)&& (rightAspectRatio=0); + (nearPlane===void 0)&& (nearPlane=0.1); + (farPlane===void 0)&& (farPlane=1000); + this._tempMatrix=new Matrix4x4(); + this._leftViewMatrix=new Matrix4x4(); + this._leftProjectionMatrix=new Matrix4x4(); + this._leftProjectionViewMatrix=new Matrix4x4(); + this._leftViewport=new Viewport(0,0,0,0); + this._leftNormalizedViewport=new Viewport(0,0,0.5,1); + this._leftAspectRatio=leftAspectRatio; + this._rightViewMatrix=new Matrix4x4(); + this._rightProjectionMatrix=new Matrix4x4(); + this._rightProjectionViewMatrix=new Matrix4x4(); + this._rightViewport=new Viewport(0,0,0,0); + this._rightNormalizedViewport=new Viewport(0.5,0,0.5,1); + this._rightAspectRatio=rightAspectRatio; + this._pupilDistande=pupilDistande; + VRCamera.__super.call(this,nearPlane,farPlane); + } + + __class(VRCamera,'laya.d3.core.VRCamera',_super); + var __proto=VRCamera.prototype; + /** + *@private + *计算瞳距。 + */ + __proto._calculatePupilOffset=function(){ + var offset=this._tempVector3; + Vector3.scale(this.right,this._pupilDistande / 2,offset); + return offset.elements; + } + + /** + *@private + *计算左投影矩阵。 + */ + __proto._calculateLeftProjectionMatrix=function(){ + if (!this._useUserProjectionMatrix){ + if (this.orthographicProjection){ + var leftHalfWidth=this.orthographicVerticalSize *this.leftAspectRatio *0.5; + var leftHalfHeight=this.orthographicVerticalSize *0.5; + Matrix4x4.createOrthogonal(-leftHalfWidth,leftHalfWidth,-leftHalfHeight,leftHalfHeight,this.nearPlane,this.farPlane,this._leftProjectionMatrix); + }else { + Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.leftAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix); + } + } + this._projectionMatrixModifyID+=0.01 / this.id; + } + + /** + *@private + *计算右投影矩阵。 + */ + __proto._calculateRightProjectionMatrix=function(){ + if (!this._useUserProjectionMatrix){ + if (this.orthographicProjection){ + var rightHalfWidth=this.orthographicVerticalSize *this.rightAspectRatio *0.5; + var rightHalfHeight=this.orthographicVerticalSize *0.5; + Matrix4x4.createOrthogonal(-rightHalfWidth,rightHalfWidth,rightHalfHeight,rightHalfHeight,this.nearPlane,this.farPlane,this._rightProjectionMatrix); + }else { + Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix); + } + } + this._projectionMatrixModifyID+=0.01 / this.id; + } + + /** + *@private + *计算投影矩阵。 + */ + __proto._calculateProjectionMatrix=function(){ + if (!this._useUserProjectionMatrix){ + if (this.orthographicProjection){ + var leftHalfWidth=this.orthographicVerticalSize *this.leftAspectRatio *0.5; + var leftHalfHeight=this.orthographicVerticalSize *0.5; + var rightHalfWidth=this.orthographicVerticalSize *this.rightAspectRatio *0.5; + var rightHalfHeight=this.orthographicVerticalSize *0.5; + Matrix4x4.createOrthogonal(-leftHalfWidth,leftHalfWidth,-leftHalfHeight,leftHalfHeight,this.nearPlane,this.farPlane,this._leftProjectionMatrix); + Matrix4x4.createOrthogonal(-rightHalfWidth,rightHalfWidth,rightHalfHeight,rightHalfHeight,this.nearPlane,this.farPlane,this._rightProjectionMatrix); + }else { + Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.leftAspectRatio,this.nearPlane,this.farPlane,this._leftProjectionMatrix); + Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix); + } + } + this._projectionMatrixModifyID+=0.01 / this.id; + } + + /** + *获取裁剪空间的左视口。 + *@return 裁剪空间的左视口。 + */ + __getset(0,__proto,'leftNormalizedViewport',function(){ + if (!this._viewportExpressedInClipSpace){ + var vp=this._leftViewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._leftNormalizedViewport.x=vp.x / sizeW; + this._leftNormalizedViewport.y=vp.y / sizeH; + this._leftNormalizedViewport.width=vp.width / sizeW; + this._leftNormalizedViewport.height=vp.height / sizeH; + } + return this._leftNormalizedViewport; + }); + + /** + *获取屏幕空间的右视口。 + *@return 屏幕空间的右视口。 + */ + __getset(0,__proto,'rightViewport',function(){ + if (this._viewportExpressedInClipSpace){ + var nVp=this._rightNormalizedViewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._rightViewport.x=nVp.x *sizeW; + this._rightViewport.y=nVp.y *sizeH; + this._rightViewport.width=nVp.width *sizeW; + this._rightViewport.height=nVp.height *sizeH; + } + return this._rightViewport; + }); + + /** + *设置屏幕空间的视口。 + *@param 屏幕空间的视口。 + */ + __getset(0,__proto,'viewport',null,function(value){ + if (this.renderTarget !=null && (value.x < 0 || value.y < 0 || value.width==0 || value.height==0)) + throw new Error("VRCamera: viewport size invalid.","value"); + this._viewportExpressedInClipSpace=false; + this._leftViewport=new Viewport(0,0,value.width / 2,value.height); + this._rightViewport=new Viewport(value.width / 2,0,value.width / 2,value.height); + this._calculateProjectionMatrix(); + }); + + /** + *获取左横纵比。 + *@return 左横纵比。 + */ + __getset(0,__proto,'leftAspectRatio',function(){ + if (this._leftAspectRatio===0){ + var lVp=this.leftViewport; + return lVp.width / lVp.height; + } + return this._leftAspectRatio; + }); + + /** + *获取右横纵比。 + *@return 右横纵比。 + */ + __getset(0,__proto,'rightAspectRatio',function(){ + if (this._rightAspectRatio===0){ + var rVp=this.rightViewport; + return rVp.width / rVp.height; + } + return this._rightAspectRatio; + }); + + /** + *设置横纵比。 + *@param value 横纵比。 + */ + __getset(0,__proto,'aspectRatio',null,function(value){ + if (value < 0) + throw new Error("VRCamera: the aspect ratio has to be a positive real number."); + this._leftAspectRatio=value; + this._rightAspectRatio=value; + this._calculateRightProjectionMatrix(); + }); + + /** + *获取裁剪空间的右视口。 + *@return 裁剪空间的右视口。 + */ + __getset(0,__proto,'rightNormalizedViewport',function(){ + if (!this._viewportExpressedInClipSpace){ + var vp=this._rightViewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._rightNormalizedViewport.x=vp.x / sizeW; + this._rightNormalizedViewport.y=vp.y / sizeH; + this._rightNormalizedViewport.width=vp.width / sizeW; + this._rightNormalizedViewport.height=vp.height / sizeH; + } + return this._rightNormalizedViewport; + }); + + /** + *设置裁剪空间的视口。 + *@return 裁剪空间的视口。 + */ + __getset(0,__proto,'normalizedViewport',null,function(value){ + if (value.x < 0 || value.y < 0 || (value.x+value.width)> 1 || (value.x+value.height)> 1) + throw new Error("VRCamera: viewport size invalid.","value"); + this._viewportExpressedInClipSpace=true; + this._leftNormalizedViewport=new Viewport(0,0,value.width / 2,value.height); + this._rightNormalizedViewport=new Viewport(value.width / 2,0,value.width / 2,value.height); + this._calculateProjectionMatrix(); + }); + + /** + *获取屏幕空间的左视口。 + *@return 屏幕空间的左视口。 + */ + __getset(0,__proto,'leftViewport',function(){ + if (this._viewportExpressedInClipSpace){ + var nVp=this._leftNormalizedViewport; + var size=this.renderTargetSize; + var sizeW=size.width; + var sizeH=size.height; + this._leftViewport.x=nVp.x *sizeW; + this._leftViewport.y=nVp.y *sizeH; + this._leftViewport.width=nVp.width *sizeW; + this._leftViewport.height=nVp.height *sizeH; + } + return this._leftViewport; + }); + + __getset(0,__proto,'needLeftViewport',function(){ + var nVp=this.leftNormalizedViewport; + return nVp.x===0 && nVp.y===0 && nVp.width===1 && nVp.height===1; + }); + + __getset(0,__proto,'needRightViewport',function(){ + var nVp=this.rightNormalizedViewport; + return nVp.x===0 && nVp.y===0 && nVp.width===1 && nVp.height===1; + }); + + /** + *获取左视图矩阵。 + *@return 左视图矩阵。 + */ + __getset(0,__proto,'leftViewMatrix',function(){ + var offsetE=this._calculatePupilOffset(); + var tempWorldMat=this._tempMatrix; + this.transform.worldMatrix.cloneTo(tempWorldMat); + var worldMatE=tempWorldMat.elements; + worldMatE[12]-=offsetE[0]; + worldMatE[13]-=offsetE[1]; + worldMatE[14]-=offsetE[2]; + tempWorldMat.invert(this._leftViewMatrix); + return this._leftViewMatrix; + }); + + /** + *获取右视图矩阵。 + *@return 右视图矩阵。 + */ + __getset(0,__proto,'rightViewMatrix',function(){ + var offsetE=this._calculatePupilOffset(); + var tempWorldMat=this._tempMatrix; + this.transform.worldMatrix.cloneTo(tempWorldMat); + var worldMatE=tempWorldMat.elements; + worldMatE[12]+=offsetE[0]; + worldMatE[13]+=offsetE[1]; + worldMatE[14]+=offsetE[2]; + tempWorldMat.invert(this._rightViewMatrix); + return this._rightViewMatrix; + }); + + /** + *获取左投影矩阵。 + *@return 左投影矩阵。 + */ + __getset(0,__proto,'leftProjectionMatrix',function(){ + return this._leftProjectionMatrix; + }); + + /** + *获取左投影视图矩阵。 + *@return 左投影视图矩阵。 + */ + __getset(0,__proto,'leftProjectionViewMatrix',function(){ + Matrix4x4.multiply(this.leftProjectionMatrix,this.leftViewMatrix,this._leftProjectionViewMatrix); + return this._leftProjectionViewMatrix; + }); + + /** + *获取右投影矩阵。 + *@return 右投影矩阵。 + */ + __getset(0,__proto,'rightProjectionMatrix',function(){ + return this._rightProjectionMatrix; + }); + + /** + *获取右投影视图矩阵。 + *@return 右投影视图矩阵。 + */ + __getset(0,__proto,'rightProjectionViewMatrix',function(){ + Matrix4x4.multiply(this.rightProjectionMatrix,this.rightViewMatrix,this._rightProjectionViewMatrix); + return this._rightProjectionViewMatrix; + }); + + return VRCamera; + })(BaseCamera) + + + /** + *Sphere 类用于创建球体。 + */ + //class laya.d3.resource.models.BoxMesh extends laya.d3.resource.models.PrimitiveMesh + var BoxMesh=(function(_super){ + function BoxMesh(long,width,height){ + this._long=NaN; + this._width=NaN; + this._height=NaN; + (long===void 0)&& (long=1); + (width===void 0)&& (width=1); + (height===void 0)&& (height=1); + BoxMesh.__super.call(this); + this._long=long; + this._width=width; + this._height=height; + this.recreateResource(); + this._loaded=true; + var pos=this.positions; + this._boundingBox=new BoundBox(new Vector3(),new Vector3()); + BoundBox.createfromPoints(pos,this._boundingBox); + this._boundingSphere=new BoundSphere(new Vector3(),0); + BoundSphere.createfromPoints(pos,this._boundingSphere); + } + + __class(BoxMesh,'laya.d3.resource.models.BoxMesh',_super); + var __proto=BoxMesh.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + this._numberVertices=24; + this._numberIndices=36; + var indices=new Uint16Array(this._numberIndices); + var vertexDeclaration=VertexPositionNormalTexture.vertexDeclaration; + var vertexFloatStride=vertexDeclaration.vertexStride / 4; + var vertices=new Float32Array(this._numberVertices*vertexFloatStride); + var halfLong=this._long / 2; + var halfWidth=this._width / 2; + var nPointNum=0; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=-1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=-1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=-1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=-1;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=-1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=-1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=-1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=-1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=1;vertices[nPointNum+4]=0;vertices[nPointNum+5]=0; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=1; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=1; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=1; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=1; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=-1; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=this._height;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=-1; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=0;nPointNum+=8; + vertices[nPointNum+0]=halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=-1; + vertices[nPointNum+6]=0;vertices[nPointNum+7]=1;nPointNum+=8; + vertices[nPointNum+0]=-halfLong;vertices[nPointNum+1]=0;vertices[nPointNum+2]=-halfWidth; + vertices[nPointNum+3]=0;vertices[nPointNum+4]=0;vertices[nPointNum+5]=-1; + vertices[nPointNum+6]=1;vertices[nPointNum+7]=1; + var nFaceNum=0; + indices[nFaceNum+0]=0;indices[nFaceNum+1]=1;indices[nFaceNum+2]=2;nFaceNum+=3; + indices[nFaceNum+0]=2;indices[nFaceNum+1]=3;indices[nFaceNum+2]=0;nFaceNum+=3; + indices[nFaceNum+0]=4;indices[nFaceNum+1]=7;indices[nFaceNum+2]=6;nFaceNum+=3; + indices[nFaceNum+0]=6;indices[nFaceNum+1]=5;indices[nFaceNum+2]=4;nFaceNum+=3; + indices[nFaceNum+0]=8;indices[nFaceNum+1]=9;indices[nFaceNum+2]=10;nFaceNum+=3; + indices[nFaceNum+0]=10;indices[nFaceNum+1]=11;indices[nFaceNum+2]=8;nFaceNum+=3; + indices[nFaceNum+0]=12;indices[nFaceNum+1]=15;indices[nFaceNum+2]=14;nFaceNum+=3; + indices[nFaceNum+0]=14;indices[nFaceNum+1]=13;indices[nFaceNum+2]=12;nFaceNum+=3; + indices[nFaceNum+0]=16;indices[nFaceNum+1]=17;indices[nFaceNum+2]=18;nFaceNum+=3; + indices[nFaceNum+0]=18;indices[nFaceNum+1]=19;indices[nFaceNum+2]=16;nFaceNum+=3; + indices[nFaceNum+0]=20;indices[nFaceNum+1]=23;indices[nFaceNum+2]=22;nFaceNum+=3; + indices[nFaceNum+0]=22;indices[nFaceNum+1]=21;indices[nFaceNum+2]=20; + this._vertexBuffer=new VertexBuffer3D(vertexDeclaration,this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._numberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._vertexBuffer.setData(vertices); + this._indexBuffer.setData(indices); + this.memorySize=(this._vertexBuffer.byteLength+this._indexBuffer.byteLength)*2; + this.completeCreate(); + } + + /** + *设置长度(改变此属性会重新生成顶点和索引) + *@param value 长度 + */ + /** + *返回长度 + *@return 长 + */ + __getset(0,__proto,'long',function(){ + return this._long; + },function(value){ + this._long=value; + this.recreateResource(); + }); + + /** + *设置宽度(改变此属性会重新生成顶点和索引) + *@param value 宽度 + */ + /** + *返回宽度 + *@return 宽 + */ + __getset(0,__proto,'width',function(){ + return this._width; + },function(value){ + this._width=value; + this.recreateResource(); + }); + + /** + *设置高度(改变此属性会重新生成顶点和索引) + *@param value 高度 + */ + /** + *返回高度 + *@return 高 + */ + __getset(0,__proto,'height',function(){ + return this._height; + },function(value){ + this._height=value; + this.recreateResource(); + }); + + return BoxMesh; + })(PrimitiveMesh) + + + /** + *MeshCylinder 类用于创建圆柱。 + */ + //class laya.d3.resource.models.CylinderMesh extends laya.d3.resource.models.PrimitiveMesh + var CylinderMesh=(function(_super){ + function CylinderMesh(radius,height,stacks,slices){ + this._radius=NaN; + this._height=NaN; + this._slices=0; + this._stacks=0; + (radius===void 0)&& (radius=10); + (height===void 0)&& (height=10); + (stacks===void 0)&& (stacks=8); + (slices===void 0)&& (slices=8); + CylinderMesh.__super.call(this); + this._radius=radius; + this._height=height; + this._stacks=stacks; + this._slices=slices; + this.recreateResource(); + this._loaded=true; + var pos=this.positions; + this._boundingBox=new BoundBox(new Vector3(),new Vector3()); + BoundBox.createfromPoints(pos,this._boundingBox); + this._boundingSphere=new BoundSphere(new Vector3(),0); + BoundSphere.createfromPoints(pos,this._boundingSphere); + } + + __class(CylinderMesh,'laya.d3.resource.models.CylinderMesh',_super); + var __proto=CylinderMesh.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + this._numberVertices=(this._stacks+1+2)*(this._slices+1); + this._numberIndices=(this._slices-1+this._stacks*this._slices)*2*3; + var indices=new Uint16Array(this._numberIndices); + var vertexDeclaration=VertexPositionNormalTexture.vertexDeclaration; + var vertexFloatStride=vertexDeclaration.vertexStride / 4; + var vertices=new Float32Array(this._numberVertices *vertexFloatStride); + var sliceAngle=(Math.PI *2.0)/ this._slices; + var cAng=0; + var buttomUVCenterX=0.5; + var buttomUVCenterY=0.5; + var buttomUVR=0.5; + var capUVCenterX=0.5; + var capUVCenterY=0.5; + var wallUVLeft=0; + var wallUVTop=0; + var wallUVRight=1; + var wallUVBottom=1; + var indexCount=0; + var vertexIndex=0; + var vertexCount=0; + var cv=0; + for (var slice=0;slice < (this._slices+1);slice++){ + var x=Math.cos(cAng); + var y=Math.sin(cAng); + cAng+=sliceAngle; + vertices[cv++]=this._radius *x;vertices[cv++]=this._radius *y;vertices[cv++]=0; + vertices[cv++]=0;vertices[cv++]=0;vertices[cv++]=-1; + vertices[cv++]=buttomUVR *x+buttomUVCenterX;vertices[cv++]=buttomUVR *y+buttomUVCenterY; + } + for (slice=2;slice < (this._slices+1);slice++){ + indices[indexCount++]=0; + indices[indexCount++]=slice-1; + indices[indexCount++]=slice; + } + vertexCount+=(this._slices+1); + var hdist=this._height / this._stacks; + var cz=0; + for (var h=0;h < this._stacks+1;h++){ + for (slice=0;slice < (this._slices+1);slice++){ + var tx=vertices[ slice*vertexFloatStride]; + var ty=vertices[ slice*vertexFloatStride+1]; + vertices[cv++]=tx;vertices[cv++]=ty;vertices[cv++]=cz; + vertices[cv++]=tx;vertices[cv++]=ty;vertices[cv++]=0; + vertices[cv++]=wallUVLeft+slice *(wallUVRight-wallUVLeft)/ this._slices; + vertices[cv++]=wallUVBottom+h *(wallUVTop-wallUVBottom)/ this._stacks; + if (h > 0 && slice > 0){ + var v1=vertexCount-1; + var v2=vertexCount; + var v3=vertexCount-(this._slices+1); + var v4=vertexCount-(this._slices+1)-1; + indices[indexCount++]=v4;indices[indexCount++]=v1;indices[indexCount++]=v2; + indices[indexCount++]=v4;indices[indexCount++]=v2;indices[indexCount++]=v3; + } + vertexCount++; + } + cz+=hdist; + } + for (slice=0;slice < (this._slices+1);slice++){ + tx=vertices[ slice*vertexFloatStride]; + ty=vertices[ slice*vertexFloatStride+1]; + vertices[cv++]=tx;vertices[cv++]=ty;vertices[cv++]=this._height; + vertices[cv++]=0;vertices[cv++]=0;vertices[cv++]=1; + vertices[cv++]=buttomUVR*tx/this._radius+capUVCenterX;vertices[cv++]=buttomUVR*ty/this._radius+capUVCenterY; + } + for (slice=2;slice < (this._slices+1);slice++){ + indices[indexCount++]=vertexCount; + indices[indexCount++]=vertexCount+slice; + indices[indexCount++]=vertexCount+slice-1; + } + vertexCount+=(this._slices+1); + this._vertexBuffer=new VertexBuffer3D(vertexDeclaration,this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._numberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._vertexBuffer.setData(vertices); + this._indexBuffer.setData(indices); + this.memorySize=(this._vertexBuffer.byteLength+this._indexBuffer.byteLength)*2; + this.completeCreate(); + } + + /** + *设置半径(改变此属性会重新生成顶点和索引) + *@param value 半径 + */ + /** + *返回半径 + *@return 半径 + */ + __getset(0,__proto,'radius',function(){ + return this._radius; + },function(value){ + this._radius=value; + this.recreateResource(); + }); + + /** + *设置宽度分段(改变此属性会重新生成顶点和索引) + *@param value 宽度分段 + */ + /** + *获取宽度分段 + *@return 宽度分段 + */ + __getset(0,__proto,'slices',function(){ + return this._slices; + },function(value){ + this._slices=value; + this.recreateResource(); + }); + + /** + *设置高度分段(改变此属性会重新生成顶点和索引) + *@param value高度分段 + */ + /** + *获取高度分段 + *@return 高度分段 + */ + __getset(0,__proto,'stacks',function(){ + return this._stacks; + },function(value){ + this._stacks=value; + this.recreateResource(); + }); + + return CylinderMesh; + })(PrimitiveMesh) + + + /** + *Sphere 类用于创建球体。 + */ + //class laya.d3.resource.models.SphereMesh extends laya.d3.resource.models.PrimitiveMesh + var SphereMesh=(function(_super){ + function SphereMesh(radius,stacks,slices){ + this._radius=NaN; + this._slices=0; + this._stacks=0; + (radius===void 0)&& (radius=10); + (stacks===void 0)&& (stacks=8); + (slices===void 0)&& (slices=8); + SphereMesh.__super.call(this); + this._radius=radius; + this._stacks=stacks; + this._slices=slices; + this.recreateResource(); + this._loaded=true; + var pos=this.positions; + this._boundingBox=new BoundBox(new Vector3(),new Vector3()); + BoundBox.createfromPoints(pos,this._boundingBox); + this._boundingSphere=new BoundSphere(new Vector3(),0); + BoundSphere.createfromPoints(pos,this._boundingSphere); + } + + __class(SphereMesh,'laya.d3.resource.models.SphereMesh',_super); + var __proto=SphereMesh.prototype; + __proto.recreateResource=function(){ + this.startCreate(); + this._numberVertices=(this._stacks+1)*(this._slices+1); + this._numberIndices=(3 *this._stacks *(this._slices+1))*2; + var indices=new Uint16Array(this._numberIndices); + var vertexDeclaration=VertexPositionNormalTexture.vertexDeclaration; + var vertexFloatStride=vertexDeclaration.vertexStride / 4; + var vertices=new Float32Array(this._numberVertices *vertexFloatStride); + var stackAngle=Math.PI / this._stacks; + var sliceAngle=(Math.PI *2.0)/ this._slices; + var vertexIndex=0; + var vertexCount=0; + var indexCount=0; + for (var stack=0;stack < (this._stacks+1);stack++){ + var r=Math.sin(stack *stackAngle); + var y=Math.cos(stack *stackAngle); + for (var slice=0;slice < (this._slices+1);slice++){ + var x=r *Math.sin(slice *sliceAngle); + var z=r *Math.cos(slice *sliceAngle); + vertices[vertexCount+0]=x *this._radius; + vertices[vertexCount+1]=y *this._radius; + vertices[vertexCount+2]=z *this._radius; + vertices[vertexCount+3]=x; + vertices[vertexCount+4]=y; + vertices[vertexCount+5]=z; + vertices[vertexCount+6]=slice / this._slices; + vertices[vertexCount+7]=stack / this._stacks; + vertexCount+=vertexFloatStride; + if (stack !=(this._stacks-1)){ + indices[indexCount++]=vertexIndex+(this._slices+1); + indices[indexCount++]=vertexIndex; + indices[indexCount++]=vertexIndex+1; + indices[indexCount++]=vertexIndex+(this._slices); + indices[indexCount++]=vertexIndex; + indices[indexCount++]=vertexIndex+(this._slices+1); + vertexIndex++; + } + } + } + this._vertexBuffer=new VertexBuffer3D(vertexDeclaration,this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._numberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true); + this._vertexBuffer.setData(vertices); + this._indexBuffer.setData(indices); + this.memorySize=(this._vertexBuffer.byteLength+this._indexBuffer.byteLength)*2; + this.completeCreate(); + } + + /** + *设置半径(改变此属性会重新生成顶点和索引) + *@param value 半径 + */ + /** + *返回半径 + *@return 半径 + */ + __getset(0,__proto,'radius',function(){ + return this._radius; + },function(value){ + this._radius=value; + this.recreateResource(); + }); + + /** + *设置宽度分段(改变此属性会重新生成顶点和索引) + *@param value 宽度分段 + */ + /** + *获取宽度分段 + *@return 宽度分段 + */ + __getset(0,__proto,'slices',function(){ + return this._slices; + },function(value){ + this._slices=value; + this.recreateResource(); + }); + + /** + *设置高度分段(改变此属性会重新生成顶点和索引) + *@param value高度分段 + */ + /** + *获取高度分段 + *@return 高度分段 + */ + __getset(0,__proto,'stacks',function(){ + return this._stacks; + },function(value){ + this._stacks=value; + this.recreateResource(); + }); + + return SphereMesh; + })(PrimitiveMesh) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.d3Plugin.js b/games/laya-snakes/libs/laya.d3Plugin.js new file mode 100644 index 0000000..8ca1370 --- /dev/null +++ b/games/laya-snakes/libs/laya.d3Plugin.js @@ -0,0 +1,102 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Component3D=laya.d3.component.Component3D,MeshTerrainSprite3D=laya.d3.core.MeshTerrainSprite3D; + var Sprite3D=laya.d3.core.Sprite3D; + /** + *PathFinding 类用于创建寻路。 + */ + //class laya.d3.component.PathFind extends laya.d3.component.Component3D + var PathFind=(function(_super){ + function PathFind(){ + this._meshTerrainSprite3D=null; + this._finder=null; + this._setting=null; + this.grid=null; + PathFind.__super.call(this); + } + + __class(PathFind,'laya.d3.component.PathFind',_super); + var __proto=PathFind.prototype; + /** + *@private + *初始化载入蒙皮动画组件。 + *@param owner 所属精灵对象。 + */ + __proto._load=function(owner){ + if (! (owner instanceof laya.d3.core.MeshTerrainSprite3D )) + throw new Error("PathFinding: The owner must MeshTerrainSprite3D!"); + _super.prototype._load.call(this,owner); + this._meshTerrainSprite3D=owner; + } + + /** + *寻找路径。 + *@param startX 开始X。 + *@param startZ 开始Z。 + *@param endX 结束X。 + *@param endZ 结束Z。 + *@return 路径。 + */ + __proto.findPath=function(startX,startZ,endX,endZ){ + var minX=this._meshTerrainSprite3D.minX; + var minZ=this._meshTerrainSprite3D.minZ; + var cellX=this._meshTerrainSprite3D.width / this.grid.width; + var cellZ=this._meshTerrainSprite3D.depth / this.grid.height; + var halfCellX=cellX / 2; + var halfCellZ=cellZ / 2; + var gridStartX=Math.floor((startX-minX)/ cellX); + var gridStartZ=Math.floor((startZ-minZ)/ cellZ); + var gridEndX=Math.floor((endX-minX)/ cellX); + var gridEndZ=Math.floor((endZ-minZ)/ cellZ); + var boundWidth=this.grid.width-1; + var boundHeight=this.grid.height-1; + (gridStartX > boundWidth)&& (gridStartX=boundWidth); + (gridStartZ > boundHeight)&& (gridStartZ=boundHeight); + (gridStartX < 0)&& (gridStartX=0); + (gridStartZ < 0)&& (gridStartZ=0); + (gridEndX > boundWidth)&& (gridEndX=boundWidth); + (gridEndZ > boundHeight)&& (gridEndZ=boundHeight); + (gridEndX < 0)&& (gridEndX=0); + (gridEndZ < 0)&& (gridEndZ=0); + var path=this._finder.findPath(gridStartX,gridStartZ,gridEndX,gridEndZ,this.grid); + this.grid.reset(); + for (var i=1;i < path.length-1;i++){ + var gridPos=path[i]; + gridPos[0]=gridPos[0] *cellX+halfCellX+minX; + gridPos[1]=gridPos[1] *cellZ+halfCellZ+minZ; + } + if (path.length==1){ + path[0][0]=endX; + path[0][1]=endX; + }else if (path.length > 1){ + path[0][0]=startX; + path[0][1]=startZ; + path[path.length-1][0]=endX; + path[path.length-1][1]=endZ; + } + return path; + } + + /** + *设置寻路设置。 + *@param value 寻路设置。 + */ + /** + *获取寻路设置。 + *@return 寻路设置。 + */ + __getset(0,__proto,'setting',function(){ + return this._setting; + },function(value){ + (value)&& (this._finder=new PathFinding.finders.AStarFinder(value)); + this._setting=value; + }); + + return PathFind; + })(Component3D) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.debugtool.js b/games/laya-snakes/libs/laya.debugtool.js new file mode 100644 index 0000000..10f182b --- /dev/null +++ b/games/laya-snakes/libs/laya.debugtool.js @@ -0,0 +1,11280 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Box=laya.ui.Box,Browser=laya.utils.Browser,Button=laya.ui.Button,Byte=laya.utils.Byte,CSSStyle=laya.display.css.CSSStyle; + var Component=laya.ui.Component,Config=Laya.Config,Event=laya.events.Event,EventDispatcher=laya.events.EventDispatcher; + var Filter=laya.filters.Filter,GrahamScan=laya.maths.GrahamScan,Graphics=laya.display.Graphics,HTMLCanvas=laya.resource.HTMLCanvas; + var Handler=laya.utils.Handler,Image=laya.ui.Image,Input=laya.display.Input,Label=laya.ui.Label,List=laya.ui.List; + var Loader=laya.net.Loader,LoaderManager=laya.net.LoaderManager,LocalStorage=laya.net.LocalStorage,MathUtil=laya.maths.MathUtil; + var Matrix=laya.maths.Matrix,Node=laya.display.Node,Point=laya.maths.Point,Pool=laya.utils.Pool,Rectangle=laya.maths.Rectangle; + var Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite; + var Resource=laya.resource.Resource,ResourceManager=laya.resource.ResourceManager,RunDriver=laya.utils.RunDriver; + var Sprite=laya.display.Sprite,Stage=laya.display.Stage,Stat=laya.utils.Stat,Style=laya.display.css.Style; + var Text=laya.display.Text,TextInput=laya.ui.TextInput,Texture=laya.resource.Texture,Tree=laya.ui.Tree,UIEvent=laya.ui.UIEvent; + var URL=laya.net.URL,Utils=laya.utils.Utils,View=laya.ui.View; + //class laya.debug.data.Base64AtlasManager + var Base64AtlasManager=(function(){ + function Base64AtlasManager(){} + __class(Base64AtlasManager,'laya.debug.data.Base64AtlasManager'); + Base64AtlasManager.replaceRes=function(uiO){ + Base64AtlasManager.base64.replaceRes(uiO); + } + + __static(Base64AtlasManager, + ['dataO',function(){return this.dataO={"comp/button1.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAABRCAYAAAApS3MNAAABSUlEQVR4Xu3a0QmFMADFUJ1JXM0h3moPZ6qg4AoNeLqAIenFn65jjLE40w2sQkxvcAMI0eggRKSDEEJUDEQ4/COEiBiIYFiEEBEDEQyLECJiIIJhEUJEDEQwLEKIiIEIhkUIETEQwbAIISIGIhgWIUTEQATDIoSIGIhgWIQQEQMRDIsQImIggnEvYvv9IzjfxDiP/XlgJsTcCyDEXP/v14UQImIggmERQkQMRDAsQoiIgQiGRQgRMRDBsAghIgYiGBYhRMRABMMihIgYiGBYhBARAxEMixAiYiCCYRFCRAxEMCxCiIiBCMa7iAjPpzG8fY3kF0KIiIEIhkUIETEQwbAIISIGIhgWIUTEQATDIoSIGIhgWIQQEQMRDIsQImIggmERQkQMRDAsQoiIgQiGRQgRMRDBsAghIgYiGBYhRMRABMMihIgYiGBcGJiOHTRZjZAAAAAASUVORK5CYII=","comp/line2.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAAG0lEQVQYV2NkoDJgpLJ5DIxtra3/qWko1V0IAJvgApS1libIAAAAAElFTkSuQmCC","view/create.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAkCAYAAAC9itu8AAAAdElEQVQ4T2NkwAIWLFjwH5t4QkICIyM2CXQxmAHka/j///9mXDYxMjL6YtgwBDUg+w8crIT8MBQ0oEca55JvWNPS9xgu4tISzADyNfz///8MnrRkgmHDENSALWng9fRQ0DA40xLecglbWhpqGoZCMUNKUQkANAHAJVkE5XwAAAAASUVORK5CYII=","view/rendertime.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAkCAYAAAC9itu8AAABeUlEQVQ4T+2Uv0tCURSAvyNdcwiXBlsaaomWFgeHlqAtCPsDJHwIiUtDSxERtErtmQ6CjkHo4FpDBQ0tbVFR0BYE0eQvOnFF7T17QlOTd3m88873OD8+rtA9uVzOBIPBlIisAwvd8B1QajQahXQ63bIx6QHFYrEEJHrv7qeqZhzHOfYA+Xw+Yow5B+YHoGwymdxW1QAQEFWNAk8i8uEDuZM3gUcLZIEJYNcNqWrVcZyd7p9t8jLwYIFTYBx47UHlcjmcSCQ+B5JtpU0LnAFj3br7kE+yTalb4BCYczVqoT3AjteW4T73FlgFNgY+1IGQz4hPLGCAI2DGbweu2Auw1Vmcqk4C+8DsEOgZOBCR9/6mVdU2vgIsAdOuIVwANRFpezatuahpTYVSop1m+y6pasm8NQqSvvW61KwslkSHuCRkgvErr0taiUXaal1Sr0siWRO/9HfpF+RN9nfpB/qqmrXrv7mktVhYVm5GLo1cct9LI5e8d84/3UvfAgdlKH0EO7MAAAAASUVORK5CYII=","view/cache.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAkCAYAAABSSLCCAAAAcElEQVQ4T2NcsGDB/4SEBEYGBgYGYtmMxCpENhhsA6mA8f///5tHNTEwkBcQpIYcSD15kUtWigi51vR/jVYdOGUQy2YkViGywWSnvTOkhiAonkY1gZIRqSEHTntkRe4g10RWQIyWe5Bgo2O5R7dkBADztyP+yFzirAAAAABJRU5ErkJggg==","comp/clip_selectBox.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAoCAYAAAAIeF9DAAAAsElEQVRoQ+3ZQQ0AMQzEwAuqEgh/Sj2pKObhIrBsrfLonHPu12MMTEGYFg+kIFaPgmA9ClIQzQDG0w0pCGYAw2khBcEMYDgtpCCYAQynhRQEM4DhtJCCYAYwnBZSEMwAhtNCCoIZwHBmd/tTh6IUBIrx/tRbiFWkIFaPFoL1KEhBNAMYTzekIJgBDKeFFAQzgOG0kIJgBjCcFlIQzACG00IKghnAcFpIQTADGE4LwYL8U/BE1dCJ3PsAAAAASUVORK5CYII=","comp/label.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAASCAYAAACQCxruAAAAmElEQVRoQ+3aMQqAQBBDUef+hx4Zq1mrbPnhWylECHmghVZ397OOqqp97TlugdNzgEXFIaaFuwROt0LmBEay5aXb920+FjIpMJItLy1wvhUyKTCSLS8tcL4VMikwki0vLXC+FTIpMJItLy1wvhUyKTCSLS89wPP1Qeh8M0zy+84gMMbruqjA15OxbtjAu7mPa5bj0fb/A8cLgD4n/wQKNiIAAAAASUVORK5CYII=","comp/clip_tree_arrow.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAQCAYAAAArij59AAAAwUlEQVQoU5WRPRKCMBCFWUt6vYQeB06RUDpoBbFDa7yDwm30FGi9dHnOMiQDBgvT5c3b7+0PRVEUlVV9A3NmzL6T//SRfMz5CgCdtVafjlmzaHAigAbM2tE8YVo1pf0yvABoc9D3wACgBbMKIgD4qqDJsqqlMV8VGL5n/88geCJKlijSMBXFZUNx/CSi9WwX1r7R99thzKKqkxXRbMUWSE2u2sEwHsxHCbrMVSq6N4xRD9HAvJstylEkarhurlqnfQC58YP5+CvQNwAAAABJRU5ErkJggg==","view/bg_panel.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMUlEQVRYR+3QQREAAAjDMGZk/l2CDD6pgl7SduexGCBAgAABAgQIECBAgAABAgS+BQ4oyStBhXcy5AAAAABJRU5ErkJggg==","view/bg_top.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMUlEQVRYR+3QQREAAAjDMKZp/rWBDD6pgl7SduexGCBAgAABAgQIECBAgAABAgS+BQ6WyDMhXMLeQgAAAABJRU5ErkJggg==","view/clickselect.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAqCAYAAACDdWrxAAACfElEQVRIS8WVO2iTYRSGn5OWqpMOurg0VRBdVVCsg7GgDjpZECyirl4GEYfSgBlaB5VSpApdxCJIoeKgg7dKC21ALahIiyiKKUjxAiI4qCH1lRP/hPhfAnHpGZPv+c4573nP95ukO/xHmINmtq8RtswsPiipB/gAPAFem5nCbcSWKukIsD84/A2YBh4DL8ysWLkk0qOkDcD5GLF+Ac+Ap35ZHGjAdWB5gtJvgZFYVSWdBHaFwBlg1Mw8K0ngFiAbAm+a2XBij/6HpBbgBrAEmAVeAZ1AFU40QDCWrcBZL0/S4Vq4HtgB7DWzU5XyauDBMhhWz70ryVVdb2ZuhGpI2g1MODjfiMFrxZk3s9WNwJ6snHFxQUlXgXfAPeC5mf2O2Y5oqZLcMceCw1+AseCSSTP7mSiOpM3A7RixfvgYgAd+WUQcSSnfPWBlgtIvgf5YVSVdBA6GQF/mS2bmWcvbERmHJF+payFw0MzO1TWApKXBViwL3h5/Pk4AVTjRAMFY9njJXl6wLccrcD3wAHDUzBwuRw18JtbkbkFJruomM7sf2o4u4Jals/mFRgxeFcfBQm97UyOwM+WMiwums/k3QnMps+HWpuLIRC5TCrcRW2pbT35MRiY4XDRsVmiU5uJQIZfxb0k5Ij229eQPySJ287MLGO8Rd1M0XY6AO3LjzYVSy3fAH+VICL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AABJRU5ErkJggg==","view/tab_panel.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAABICAYAAADyMAW8AAAAcUlEQVRYR+3WsQ3AMAhE0TCMeyTvP1tShRQo7lxYegxA8fUPLuac97VhwuKXKhTlFxRQ9GPDClawYvGEDwxIZu7pFRZXr4ACinY1ghWsYMX/NxWQr22edyvGGHt6hcV1NqGAon8QVrCCFYteISDnBuQB3xJuQcDkEngAAAAASUVORK5CYII=","view/btn_close.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAqCAYAAACz+XvQAAACmUlEQVRIS7WWS0/bUBCFz7mJmyZxENm06mNVoVZC7LqGn9FNqy55/BSWSEhs2/4uuqFVoA150JLKJvGdaiIH2TfXNoKQpeP5PHPO3GMTK/5xxTwsAUWkBeBZ+qAByb/Zh4pIA8CL9NqY5Dj7vw9YA/ABwDsAfwB8ITnUIhF5CuATgNcAfgH4RnJSCkwLl6AA/lXBtLZQQxFxoTr6q6LOFl2WmuJAtcY7ZuXIixsczfRyTlPfhpSN7BpwBeBtFdQLFJE2gI8AXi7GBBBl3Fdnv5L87XbpWxuFfQbw3NXM0dQLLdrDIH3ylGTiLLYB8CS9lpCc3tmU+xzL1Z9lEXl/n06KavjowCiK1uM4fqMd1Ov1s3a7fZntZjabtSeTiQYHgiC4aLVavZwpbofT6TQYDAaH1tod3bMwDHc7nc5PLZrNZmG/3z8WkS1jzGm32z1oNBqjUqD+6YM2m81xFWyeNkUaulAAlyKyWdTZbdqUmZKFakEVrLRDV7P5zY6m3rQp6tA1AMC5tXY7he51Op0fdwbGcdwdDodHWc2MMdcL9wGM1tbW9sMw/L6UNm6HChuNRifW2g1XM0dTL3TJZS1KkkTDFbVaLQqCIJcm6k0URRpxuvg39Xo9rtzDh5zt1Z/lXq+32rR5dKC1dt0YM08bAGd65BxN1ZB52ojIBcl82rgdWmsDkocAdgDoW22X5DxtSIZJkhyT3AJwCuCAZD5tfCP7oMaYcRVs/tAiDT1QH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AAAAElFTkSuQmCC","comp/textinput.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAAAWCAYAAACv8OArAAAAZElEQVRYR+3UQQkAMAwEwcZI/LtsoSL2NTGwMByZ3b3HJQIDO3H+EdidNezQGjbsUiBs+dmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4Ew9QBe0R29X9x+dwAAAABJRU5ErkJggg==","comp/vscroll.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAhCAYAAAA/F0BXAAAAOklEQVRIS2N8+OzVf2YWFgYmJiYGcgHjqCEYQTcaJpipaTRMRsOEmDJmNJ2MppPRdEJMCIymE2JCCQAYonwDuu2VMAAAAABJRU5ErkJggg==","comp/vscroll$down.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAzCAYAAABxCePHAAAC/klEQVRIS+2WS0wTURSG/zszBcrLFVvjio0LiAqRRDAmGpRodFE1MQQQkOKGqBujRo3ExLjB4MaKgDzUaGQhvoJGYwAjYoioERcuDGxYEIwPkBY6nWvObXuLnXZaSklYOIu5M/fxzZn/nvPPsInJKa5qGhRFQaIH+w8xSbcymtTd+gBFYXAdyjM9sf7ORxgGR0t5/j9jpkhq2t5B0xQwBrgqNsnJ9V0j4BzQdQNtNYXWkKz0NDiaXkBTFTCFoaWmCHVtQ+AGh+4z0HNiO2bmPNYQGiXQvkuPoaqqiIgi8Pl8eHBqtwlA86MKS6Cy8z1gjIFzjqcXHBEBlpBgRNuOd+HVlYqogJiQIChcg/BtW5k8SaSSkxPJ5PRPTttHfkI7kcghIpn8NYfp33NLXp+TnYG1OWvA3ox9499nPSjdkCsgHJxOIjc43VMrugL9dEUD4Oj/PA4CsUfDX/jOjbmisHTDCCzi4t4QgLDrQF+qTYOmqhgYGw9BvLpv0ZNjQwieaU9b7ZCDriFhSt3VBSZNartHA6aUJ7SK+jqO5n5pSp1HiqSw1e3Di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ycsSos9xUsmSr8BfgGeWI6+BgEAAAAASUVORK5CYII=","comp/button.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE0AAABFCAYAAAAPWmvdAAABA0lEQVR4Xu3ZMRGDUBRFwXwfKSgxFhfRgAbUxEakkCEO3qmX+p9m5w7NW9v7cz18I4EFbeT1fwxtbgYtmEGDVgRC458GLQiExNKgBYGQWBq0IBASS4MWBEJiadCCQEgsDVoQCImlQQsCIbE0aEEgJJZW0Pbj64Q3hFvQhmL3CQ8atLlAKCwNWhAIiaVBCwIhsTRoQSAklgYtCITE0qAFgZBYGrQgEBJLgxYEQmJp0IJASCwNWhAIiaUVtOfrdMIbwi1oQ7H7hAcN2lwgFJYGLQiExNKgBYGQWBq0IBASS4MWBEJiadCCQEgsDVoQCImlQQsCIbE0aEEgJJYGLQiExNIC2g/MxaMp6CSauwAAAABJRU5ErkJggg==","view/bg_tool.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMklEQVRYR+3QQREAAAjDMCYG/DsEGXxSBb2ke7YeiwECBAgQIECAAAECBAgQIEDgW+AAAeIuAVS/mngAAAAASUVORK5CYII=","comp/minBtn.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA8CAYAAAB1odqiAAAArUlEQVRYR+3X0QmAMAwE0GQN19B9nM193CmiIH7ZXOAoRc/fpjl8jVDdOj/eOc8USBcXqUjLAtDQRMSOdHb3JatTYCZUXodIy10bGxTI1Lx6/YA0Ima6W2tKFcjmdpGKtCow7NBAdxozy+804Gfx/cDqbLzWDzs0ekNY4B9nOMEehMKTVIEEyKeFSKmc18+MppRtipJuYPCa1SkwEyqvo6Tlxm8bFEijvBt9n/QA/fOPydLHcUIAAAAASUVORK5CYII=","view/zoom_out.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAACy0lEQVRIS92WQU8TQRTH/28oQkj0CL0QOMAJQkz4DkS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itm/IakzItz5QcXhKSZsBCyrpdjlwuZwfSO8mLOkdYAHqFXSrRKWvErtXFdOcJcnp0AX96ZwuldQ5uxtTrD+VUmWWXqfujwk8eQ4f68rsuRG+d/gZVb9eIk9kPS6miXvIv91rNc12TXPc5MkTyO/AFhJCujHqZlCAAAAAElFTkSuQmCC","comp/checkbox.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAqCAYAAACDdWrxAAABbUlEQVRIS+2TP0gCURzHv88GRYsrExyOo5cEQVEtWdQQpE4N0R+HxmirXXCrKYigqMF2IRqCQByaLJqNIFpyUIzu4rIwpExODy88ITD/cJ603Rsf7/OGz+/zI5TSEAE20cZRgBMySKni8XrbwICrWAwG2ESZIadFS53J0R25brCyHZNud1vbcRuPV7fDAOu9GXJatNSZHN2R6wb/PfJCrxOZCR8Gbk6hWc6Xg8PrcgBETMIVPdIGSjYG/NoOSHcfkLqDK3qsBSRIrgRAuBF1quUPEUPhYGMwb2dhywrqQ3F0Dt++jSokJMBdhmDO52pB2WwFP7OK8rgH9os99IgppNf3QWwMFP4RNHKALrmoflIj53l6CaWpRcBkgiIkYHl6gDTrh5JJg57v/kJ1YOUixw7jfWELxMpAKUmAXAR7tg3LZ7am3IbjKDBOvPiDqkUmcoj+9H1d7k3nmHdweBubB70ON9wRzQH8pVVQb+Q/zZAEfpwDCU4AAAAASUVORK5CYII=","comp/btn_close.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA8CAYAAAB1odqiAAAE6UlEQVRYR+3Y30+bVRgH8G/T0t/0Jy0USrIsC0E2GMKAVYcRpmSbEzIGZhqyxCxeceGVF3pjvJl/wYyJWZYY4hZBFnBuBBUW2ewYAxlsSMiyLKH8aEt/0vZtSxvM+562We15C6jlxr53zfO8z+ec5z2nOTmCk598tY19fAQs+Hlvz76QX1zpAwd+1NMNXzieU1QtFeKbvn4CXvqgC95wLKegRirC1e8GCPjh+53wMnRwedkG54aLG4yhSI/ycnPawHaKJ5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idrVoZHIZClWF1DqisjLMzPxBwNraasRsdHDD6c7ApDIJVzTMRDJiRQb6EUNkLsPs7DwBa6qrELPZqCNzu/1pG1siEUOhkHK5wWAYkUg0La7T0U9tIrMZc/MLBKw+XImtZTrIMBFEouQkIBEXQJaYXXJ0O8WTeQXlZsw/XSRg1SsVvGDWpbuHIAsu/LlEwMrKCsQDAcQ93j2U2H2qUKuBUKnE4uISBF9f/Hj7wJwVhyordl/hH2Q+W1zCixoLOdNUj98Ei+byYbH5lnPkmJhL6O+18/c0/1m38/c0qVbm72nYVuTvadgu5O9pUtsif0+Tv6dhF8P/657mLz4NfQVdLmZiAAAAAElFTkSuQmCC","comp/textarea.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAAAXCAYAAABkrDOOAAAA4klEQVRoQ+3ZvQrCMBiF4e9rU+sPOErRqxDRe/KG9Fp0EAc3VzuIg1ML4uDmlkaaquDenMUTyJoDD+8W3ZyKlaoshSeogHOy1m1euOmoI1EU+auqQUf/8XHnnBzLp3jsWdaVJEnEGEPsADXU2Ifro8Gej/uSpqnHruvmaVegqirZX+4N9mIy8Nh13XEct7vE18RaK7vzjdiIFoiNUH5vEJvYQAHgFMsmNlAAOMWyiQ0UAE6xbGIDBYBTLJvYQAHgFMsmNlAAOMWyiQ0UAE79lM2fmrDy358a/q6Hhf68ng175QueKdEXxUGVVwAAAABJRU5ErkJggg==","view/re.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAACpklEQVRIS+WWPUgcQRiG3+8O70QEUwTB1EJgsTGdRRrhOMjOtEtSRbBIBMFKuCtkZleES2uRQoWQJggKKW7Of7GyTRvBLkVShhS73OXMfWGOU85Es7uXs0m2XeZh+OZ95xnCHX10R1ykBvu+P5fP59+VSqVvf9pUarBS6jWAR0Q0rbWOboP3BCaiOQAHAKTW+vtN8L8BW96W4zjPPM/78Ss8FlypVEYajYbHzALAJIAHALJdoDWl1Esi4m74rWBmpiA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3/axXC1dh9XPgbZqmW8aYd9t3ohCVUt4BWARwkyTJZhzHH7Zgdq4MvQbw7ThOw/f9zypgKVoVsS7UX+C+v+kgeI0Oklrvb0Yw03rwlZW8Hnz14OvqjXrw1e/pPyfwCww91CttlMG7AAAAAElFTkSuQmCC","view/save.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAAA1klEQVRIS+2VzQ3DIAyFwxwdoMMAA/VQ8ZByyEBhmA7QOVxxKLIaOcIoSZUfrlifHw/wM91Ky6zE7SZgANTaDEDhzYJ5odSMC7nA5U7+b4X2dVQr3ic4hHCTlMcY33xPZUUGcwBvdEJwjcfGGIQQ4rd2qenWA3hyAUuABwCP31NtN+i1v02qP4DicRybM885J2ceB/NCyUupfuLxBS4WbmKF9rNUv4p9gq21d0l5SunF91RWZDAH8EYnBNd4nDPPWitnXst0I6Leez+feVowEQ3e+wNk3ge7C/Qp3GfwkgAAAABJRU5ErkJggg=="};},'base64',function(){return this.base64=new Base64Atlas(Base64AtlasManager.dataO);} + ]); + return Base64AtlasManager; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-24 下午3:00:38 + */ + //class laya.debug.DebugTool + var DebugTool=(function(){ + function DebugTool(){} + __class(DebugTool,'laya.debug.DebugTool'); + __getset(1,DebugTool,'target',function(){ + return DebugTool._target; + },function(v){ + DebugTool._target=v; + }); + + __getset(1,DebugTool,'isThisShow',function(){ + return false; + }); + + /** + *设置是否显示帧率信息 + *@param value 是否显示true|false + */ + __getset(1,DebugTool,'showStatu',null,function(value){ + if (value){ + Stat.show(); + } + else{ + Stat.hide(); + DebugTool.clearDebugLayer(); + } + }); + + /** + *是否自动显示点击对象的边框 + *@param value + */ + __getset(1,DebugTool,'showBound',function(){ + return DebugTool._showBound; + },function(value){ + DebugTool._showBound=value; + if (!DebugTool._showBound){ + DebugTool.clearDebugLayer(); + } + }); + + DebugTool.getMenuShowEvent=function(){ + if (Browser.onMobile){ + return /*laya.events.Event.DOUBLE_CLICK*/"doubleclick"; + }else{ + return /*laya.events.Event.RIGHT_CLICK*/"rightclick"; + } + } + + DebugTool.init=function(cacheAnalyseEnable,loaderAnalyseEnable,createAnalyseEnable,renderAnalyseEnable,showCacheRec){ + (cacheAnalyseEnable===void 0)&& (cacheAnalyseEnable=true); + (loaderAnalyseEnable===void 0)&& (loaderAnalyseEnable=true); + (createAnalyseEnable===void 0)&& (createAnalyseEnable=true); + (renderAnalyseEnable===void 0)&& (renderAnalyseEnable=true); + (showCacheRec===void 0)&& (showCacheRec=false); + DebugTool.enableCacheAnalyse=cacheAnalyseEnable; + if (DebugTool.enableCacheAnalyse){ + RenderSpriteHook.init(); + } + if (renderAnalyseEnable){ + SpriteRenderHook.init(); + } + DebugTool.enableNodeCreateAnalyse=createAnalyseEnable; + if (DebugTool.enableNodeCreateAnalyse){ + ClassCreateHook.I.hookClass(Node); + } + if (loaderAnalyseEnable){ + LoaderHook.init(); + } + CacheAnalyser.showCacheSprite=showCacheRec; + DisplayHook.initMe(); + NodeInfoPanel.init(); + if (!DebugTool.debugLayer){ + DebugTool.debugLayer=DebugInfoLayer.I.graphicLayer; + DebugTool.debugLayer.mouseEnabled=false; + DebugTool.debugLayer.mouseThrough=true; + DebugTool.showStatu=true; + Laya.stage.on(/*laya.events.Event.KEY_DOWN*/"keydown",null,DebugTool.keyHandler); + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.IMAGE*/0x01]="IMAGE"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.ALPHA*/0x02]="ALPHA"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.TRANSFORM*/0x04]="TRANSFORM"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.CANVAS*/0x08]="CANVAS"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.GRAPHICS*/0x100]="GRAPHICS"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.CUSTOM*/0x200]="CUSTOM"; + DebugTool.cmdToTypeO[ /*laya.renders.RenderSprite.CHILDS*/0x800]="CHILDS"; + DebugExport.export(); + } + } + + DebugTool.dTrace=function(str){ + if (DebugTool._traceFun !=null){ + DebugTool._traceFun(str); + } + console.log(str); + } + + DebugTool.keyHandler=function(e){ + var key; + key=String.fromCharCode(e.keyCode); + if (!e.altKey) + return; + switch (e.keyCode){ + case 38: + DebugTool.showParent(); + break ; + case 40: + DebugTool.showChild(); + break ; + case 37: + DebugTool.showBrother(DebugTool.target,1); + break ; + case 39: + DebugTool.showBrother(DebugTool.target,-1); + break ; + } + DebugTool.dealCMDKey(key); + } + + DebugTool.dealCMDKey=function(key){ + switch (key){ + case "上": + DebugTool.showParent(); + break ; + case "下": + DebugTool.showChild(); + break ; + case "左": + DebugTool.showBrother(DebugTool.target,1); + break ; + case "右": + DebugTool.showBrother(DebugTool.target,-1); + break ; + case "B": + DebugTool.showAllBrother(); + break ; + case "C": + DebugTool.showAllChild(); + break ; + case "E": + DebugTool.traceDisMouseEnable(); + break ; + case "S": + DebugTool.traceDisSizeChain(); + break ; + case "D": + DisControlTool.downDis(DebugTool.target); + break ; + case "U": + DisControlTool.upDis(DebugTool.target); + break ; + case "N": + DebugTool.getNodeInfo(); + break ; + case "M": + DebugTool.showAllUnderMosue(); + break ; + case "I": + break ; + case "O": + ObjectCreateView.I.show(); + break ; + case "L": + DisController.I.switchType(); + break ; + case "Q": + DebugTool.showNodeInfo(); + break ; + case "F": + DebugTool.showToolPanel(); + break ; + case "P": + DebugTool.showToolFilter(); + break ; + case "V": + DebugTool.selectNodeUnderMouse(); + break ; + case "A": + if (NodeToolView.I.target){ + MouseEventAnalyser.analyseNode(NodeToolView.I.target); + } + break ; + case "K": + NodeUtils.traceStage(); + break ; + case "T": + DebugTool.switchNodeTree(); + break ; + case "R": + RenderCostRankView.I.show(); + break ; + case "X": + NodeTree.I.fresh(); + break ; + case "mCMD": + DebugTool.traceCMD(); + break ; + case "allCMD": + DebugTool.traceCMDR(); + break ; + } + } + + DebugTool.switchNodeTree=function(){ + ToolPanel.I.switchShow(/*laya.debug.view.nodeInfo.ToolPanel.Tree*/"Tree"); + } + + DebugTool.analyseMouseHit=function(){ + if (DebugTool.target) + MouseEventAnalyser.analyseNode(DebugTool.target); + } + + DebugTool.selectNodeUnderMouse=function(){ + DisplayHook.instance.selectDisUnderMouse(); + DebugTool.showDisBound(); + return; + } + + DebugTool.showToolPanel=function(){ + ToolPanel.I.switchShow(/*laya.debug.view.nodeInfo.ToolPanel.Find*/"Find"); + } + + DebugTool.showToolFilter=function(){ + ToolPanel.I.switchShow(/*laya.debug.view.nodeInfo.ToolPanel.Filter*/"Filter"); + } + + DebugTool.showNodeInfo=function(){ + if (NodeInfoPanel.I.isWorkState){ + NodeInfoPanel.I.recoverNodes(); + } + else{ + NodeInfoPanel.I.showDisInfo(DebugTool.target); + } + } + + DebugTool.switchDisController=function(){ + if (DisController.I.target){ + DisController.I.target=null; + } + else{ + if (DebugTool.target){ + DisController.I.target=DebugTool.target; + } + } + } + + DebugTool.showParent=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + DebugTool.target=sprite.parent; + DebugTool.autoWork(); + } + + DebugTool.showChild=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + if (sprite.numChildren > 0){ + DebugTool.target=sprite.getChildAt(0); + DebugTool.autoWork(); + } + } + + DebugTool.showAllChild=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + DebugTool.selectedNodes=DisControlTool.getAllChild(sprite); + DebugTool.showSelected(); + } + + DebugTool.showAllUnderMosue=function(){ + DebugTool.selectedNodes=DisControlTool.getObjectsUnderGlobalPoint(Laya.stage); + DebugTool.showSelected(); + } + + DebugTool.showParentChain=function(sprite){ + if (!sprite) + return; + DebugTool.selectedNodes=[]; + var tar; + tar=sprite.parent; + while (tar){ + DebugTool.selectedNodes.push(tar); + tar=tar.parent; + } + DebugTool.showSelected(); + } + + DebugTool.showAllBrother=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + if (!sprite.parent) + return; + DebugTool.selectedNodes=DisControlTool.getAllChild(sprite.parent); + DebugTool.showSelected(); + } + + DebugTool.showBrother=function(sprite,dID){ + (dID===void 0)&& (dID=1); + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + }; + var p; + p=sprite.parent; + if (!p) + return; + var n=0; + n=p.getChildIndex(sprite); + n+=dID; + if (n < 0) + n+=p.numChildren; + if (n >=p.numChildren) + n-=p.numChildren; + DebugTool.target=p.getChildAt(n); + DebugTool.autoWork(); + } + + DebugTool.clearDebugLayer=function(){ + if (DebugTool.debugLayer.graphics) + DebugTool.debugLayer.graphics.clear(); + } + + DebugTool.showSelected=function(){ + if (!DebugTool.autoShowSelected) + return; + if (!DebugTool.selectedNodes || DebugTool.selectedNodes.length < 1) + return; + console.log("selected:"); + console.log(DebugTool.selectedNodes); + var i=0; + var len=0; + len=DebugTool.selectedNodes.length; + DebugTool.clearDebugLayer(); + for (i=0;i < len;i++){ + DebugTool.showDisBound(DebugTool.selectedNodes[i],false); + } + } + + DebugTool.getClassCreateInfo=function(className){ + return RunProfile.getRunInfo(className); + } + + DebugTool.autoWork=function(){ + if (!DebugTool.isThisShow) + return; + if (DebugTool.showBound) + DebugTool.showDisBound(); + if (DebugTool.autoTraceSpriteInfo && DebugTool.target){ + TraceTool.traceSpriteInfo(DebugTool.target,DebugTool.autoTraceBounds,DebugTool.autoTraceSize,DebugTool.autoTraceTree); + } + if (!DebugTool.target) + return; + if (DebugTool.autoTraceCMD){ + DebugTool.traceCMD(); + } + if (DebugTool.autoTraceCMDR){ + DebugTool.traceCMDR(); + } + if (DebugTool.autoTraceEnable){ + DebugTool.traceDisMouseEnable(DebugTool.target); + } + } + + DebugTool.traceDisMouseEnable=function(tar){ + console.log("traceDisMouseEnable:"); + if (!tar) + tar=DebugTool.target; + if (!tar){ + console.log("no targetAvalible"); + return null; + }; + var strArr; + strArr=["TraceDisMouseEnable"]; + DebugTool.selectedNodes=[]; + while (tar){ + strArr.push(ClassTool.getNodeClassAndName(tar)+":"+tar.mouseEnabled+" hitFirst:"+tar.hitTestPrior); + DebugTool.selectedNodes.push(tar); + tar=tar.parent; + } + DebugTool.showSelected(); + return strArr.join("\n"); + } + + DebugTool.traceDisSizeChain=function(tar){ + console.log("traceDisSizeChain:"); + if (!tar) + tar=DebugTool.target; + if (!tar){ + console.log("no targetAvalible"); + return null; + } + DebugTool.selectedNodes=[]; + var strArr; + strArr=["traceDisSizeChain"]; + while (tar){ + DebugTool.dTrace(TraceTool.getClassName(tar)+":"); + strArr.push(ClassTool.getNodeClassAndName(tar)+":"); + strArr.push("Size: x:"+tar.x+" y:"+tar.y+" w:"+tar.width+" h:"+tar.height+" scaleX:"+tar.scaleX+" scaleY:"+tar.scaleY); + TraceTool.traceSize(tar); + DebugTool.selectedNodes.push(tar); + tar=tar.parent; + } + DebugTool.showSelected(); + return strArr.join("\n"); + } + + DebugTool.showDisBound=function(sprite,clearPre,color){ + (clearPre===void 0)&& (clearPre=true); + (color===void 0)&& (color="#ff0000"); + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + if (clearPre) + DebugTool.clearDebugLayer(); + var pointList; + pointList=sprite._getBoundPointsM(true); + if (!pointList || pointList.length < 1) + return; + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,sprite.localToGlobal,sprite); + pointList=GrahamScan.pointListToPlist(pointList); + DebugTool._disBoundRec=Rectangle._getWrapRec(pointList,DebugTool._disBoundRec); + DebugTool.debugLayer.graphics.drawRect(DebugTool._disBoundRec.x,DebugTool._disBoundRec.y,DebugTool._disBoundRec.width,DebugTool._disBoundRec.height,null,color); + DebugInfoLayer.I.setTop(); + } + + DebugTool.showDisBoundToSprite=function(sprite,graphicSprite,color,lineWidth){ + (color===void 0)&& (color="#ff0000"); + (lineWidth===void 0)&& (lineWidth=1); + var pointList; + pointList=sprite._getBoundPointsM(true); + if (!pointList || pointList.length < 1) + return; + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,sprite.localToGlobal,sprite); + pointList=GrahamScan.pointListToPlist(pointList); + DebugTool._disBoundRec=Rectangle._getWrapRec(pointList,DebugTool._disBoundRec); + graphicSprite.graphics.drawRect(DebugTool._disBoundRec.x,DebugTool._disBoundRec.y,DebugTool._disBoundRec.width,DebugTool._disBoundRec.height,null,color,lineWidth); + } + + DebugTool.getNodeInfo=function(){ + DebugTool.counter.reset(); + WalkTools.walkTarget(Laya.stage,DebugTool.addNodeInfo); + console.log("node info:"); + DebugTool.counter.traceSelf(); + return DebugTool.counter.data; + } + + DebugTool.findByClass=function(className){ + DebugTool._classList=[]; + DebugTool._tFindClass=className; + WalkTools.walkTarget(Laya.stage,DebugTool.addClassNode); + DebugTool.selectedNodes=DebugTool._classList; + DebugTool.showSelected(); + return DebugTool._classList; + } + + DebugTool.addClassNode=function(node){ + var type; + type=node["constructor"].name; + if (type==DebugTool._tFindClass){ + DebugTool._classList.push(node); + } + } + + DebugTool.traceCMD=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return null; + } + console.log("self CMDs:"); + console.log(sprite.graphics.cmds); + var renderSprite; + renderSprite=RenderSprite.renders[sprite._renderType]; + console.log("renderSprite:",renderSprite); + DebugTool._rSpList.length=0; + while (renderSprite && renderSprite["_sign"] > 0){ + DebugTool._rSpList.push(DebugTool.cmdToTypeO[renderSprite["_sign"]]); + renderSprite=renderSprite._next; + } + console.log("fun:",DebugTool._rSpList.join(",")); + DebugTool.counter.reset(); + DebugTool.addCMDs(sprite.graphics.cmds); + DebugTool.counter.traceSelf(); + return DebugTool.counter.data; + } + + DebugTool.addCMDs=function(cmds){ + WalkTools.walkArr(cmds,DebugTool.addCMD); + } + + DebugTool.addCMD=function(cmd){ + DebugTool.counter.add(cmd.callee); + } + + DebugTool.traceCMDR=function(sprite){ + if (!sprite) + sprite=DebugTool.target; + if (!sprite){ + console.log("no targetAvalible"); + return 0; + } + DebugTool.counter.reset(); + WalkTools.walkTarget(sprite,DebugTool.getCMdCount); + console.log("cmds include children"); + DebugTool.counter.traceSelf(); + return DebugTool.counter.data; + } + + DebugTool.getCMdCount=function(target){ + if (!target) + return 0; + if (! (target instanceof laya.display.Sprite )) + return 0; + if (!target.graphics.cmds) + return 0; + DebugTool.addCMDs(target.graphics.cmds); + var rst=target.graphics.cmds.length; + return rst; + } + + DebugTool.addNodeInfo=function(node){ + var type; + type=node["constructor"].name; + DebugTool.counter.add(type); + } + + DebugTool.find=function(filter,ifShowSelected){ + (ifShowSelected===void 0)&& (ifShowSelected=true); + var rst; + rst=DebugTool.findTarget(Laya.stage,filter); + DebugTool.selectedNodes=rst; + if (DebugTool.selectedNodes){ + DebugTool.target=DebugTool.selectedNodes[0]; + } + if (ifShowSelected) + DebugTool.showSelected(); + return rst; + } + + DebugTool.findByName=function(name){ + DebugTool.nameFilter.name=name; + return DebugTool.find(DebugTool.nameFilter); + } + + DebugTool.findNameStartWith=function(startStr){ + DebugTool.nameFilter.name=DebugTool.getStartWithFun(startStr); + return DebugTool.find(DebugTool.nameFilter); + } + + DebugTool.findNameHas=function(hasStr,showSelected){ + (showSelected===void 0)&& (showSelected=true); + DebugTool.nameFilter.name=DebugTool.getHasFun(hasStr); + return DebugTool.find(DebugTool.nameFilter,showSelected); + } + + DebugTool.getStartWithFun=function(startStr){ + var rst=function (str){ + if (!str) + return false; + if (str.indexOf(startStr)==0) + return true; + return false; + }; + return rst; + } + + DebugTool.getHasFun=function(hasStr){ + var rst=function (str){ + if (!str) + return false; + if (str.indexOf(hasStr)>=0) + return true; + return false; + }; + return rst; + } + + DebugTool.findTarget=function(target,filter){ + var rst=[]; + if (DebugTool.isFit(target,filter)) + rst.push(target); + var i=0; + var len=0; + var tChild; + len=target.numChildren; + for (i=0;i < len;i++){ + tChild=target.getChildAt(i); + if ((tChild instanceof laya.display.Sprite )){ + rst=rst.concat(DebugTool.findTarget(tChild,filter)); + } + } + return rst; + } + + DebugTool.findClassHas=function(target,str){ + var rst=[]; + if (ClassTool.getClassName(target).indexOf(str)>=0) + rst.push(target); + var i=0; + var len=0; + var tChild; + len=target.numChildren; + for (i=0;i < len;i++){ + tChild=target.getChildAt(i); + if ((tChild instanceof laya.display.Sprite )){ + rst=rst.concat(DebugTool.findClassHas(tChild,str)); + } + } + return rst; + } + + DebugTool.isFit=function(tar,filter){ + if (!tar) + return false; + if (!filter) + return true; + if ((typeof filter=='function')){ + return (filter)(tar); + }; + var key; + for (key in filter){ + if ((typeof (filter[key])=='function')){ + if (!filter[key](tar[key])) + return false; + } + else{ + if (tar[key] !=filter[key]) + return false; + } + } + return true; + } + + DebugTool.log=function(__args){ + var args=arguments; + var arr; + arr=DTrace.getArgArr(args); + if (DebugTool._logFun!=null){ + DebugTool._logFun(arr.join(" ")); + } + } + + DebugTool.enableCacheAnalyse=false; + DebugTool.enableNodeCreateAnalyse=true; + DebugTool._traceFun=null + DebugTool.debugLayer=null + DebugTool._target=null + DebugTool.selectedNodes=[]; + DebugTool.autoShowSelected=true; + DebugTool._showBound=true; + DebugTool._disBoundRec=null + DebugTool.autoTraceEnable=false; + DebugTool.autoTraceBounds=false; + DebugTool.autoTraceSize=false; + DebugTool.autoTraceTree=true; + DebugTool.autoTraceCMD=true; + DebugTool.autoTraceCMDR=false; + DebugTool.autoTraceSpriteInfo=true; + DebugTool._classList=null + DebugTool._tFindClass=null + DebugTool._rSpList=[]; + DebugTool._logFun=null + __static(DebugTool, + ['text',function(){return this.text=new Stat();},'cmdToTypeO',function(){return this.cmdToTypeO={ + };},'counter',function(){return this.counter=new CountTool();},'nameFilter',function(){return this.nameFilter={"name":"name"};} + + ]); + return DebugTool; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.Base64Atlas + var Base64Atlas=(function(){ + function Base64Atlas(data,idKey){ + this.data=null; + this.replaceO=null; + this.idKey=null; + this._loadedHandler=null; + this.data=data; + if (!idKey)idKey=Math.random()+"key"; + this.idKey=idKey; + this.init(); + } + + __class(Base64Atlas,'laya.debug.tools.Base64Atlas'); + var __proto=Base64Atlas.prototype; + //preLoad(); + __proto.init=function(){ + this.replaceO={}; + var key; + for (key in this.data){ + this.replaceO[key]=this.idKey+"/"+key; + } + } + + __proto.getAdptUrl=function(url){ + return this.replaceO[url]; + } + + __proto.preLoad=function(completeHandler){ + this._loadedHandler=completeHandler; + Laya.loader.load(Base64ImageTool.getPreloads(this.data),new Handler(this,this.preloadEnd)); + } + + __proto.preloadEnd=function(){ + var key; + for (key in this.data){ + var tx; + tx=Laya.loader.getRes(this.data[key]); + Loader.cacheRes(this.replaceO[key],tx); + } + if (this._loadedHandler){ + this._loadedHandler.run(); + } + } + + __proto.replaceRes=function(uiObj){ + ObjectTools.replaceValue(uiObj,this.replaceO); + } + + return Base64Atlas; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.Base64ImageTool + var Base64ImageTool=(function(){ + function Base64ImageTool(){} + __class(Base64ImageTool,'laya.debug.tools.Base64ImageTool'); + Base64ImageTool.getCanvasPic=function(img){ + img=img.bitmap; + var canvas=Browser.createElement("canvas"); + var ctx=canvas.getContext('2d'); + canvas.height=img.height; + canvas.width=img.width; + ctx.drawImage(img.source,0,0); + return canvas; + } + + Base64ImageTool.getBase64Pic=function(img){ + return Base64ImageTool.getCanvasPic(img).toDataURL("image/png"); + } + + Base64ImageTool.getPreloads=function(base64Data){ + var rst; + rst=[]; + var key; + for (key in base64Data){ + rst.push({url:base64Data[key],type:/*laya.net.Loader.IMAGE*/"image" }); + } + return rst; + } + + return Base64ImageTool; + })() + + + /** + *base64编码解码类 + *@author ww + */ + //class laya.debug.tools.Base64Tool + var Base64Tool=(function(){ + function Base64Tool(){} + __class(Base64Tool,'laya.debug.tools.Base64Tool'); + Base64Tool.init=function(){ + if (Base64Tool.lookup) + return; + Base64Tool.lookup=new Uint8Array(256) + for (var i=0;i < Base64Tool.chars.length;i++){ + Base64Tool.lookup[Base64Tool.chars.charCodeAt(i)]=i; + } + } + + Base64Tool.encode=function(arraybuffer){ + var bytes=new Uint8Array(arraybuffer),i=0,len=bytes.length,base64=""; + for (i=0;i < len;i+=3){ + base64+=Base64Tool.chars[bytes[i] >> 2]; + base64+=Base64Tool.chars[((bytes[i] & 3)<< 4)| (bytes[i+1] >> 4)]; + base64+=Base64Tool.chars[((bytes[i+1] & 15)<< 2)| (bytes[i+2] >> 6)]; + base64+=Base64Tool.chars[bytes[i+2] & 63]; + } + if ((len % 3)===2){ + base64=base64.substring(0,base64.length-1)+"="; + } + else if (len % 3===1){ + base64=base64.substring(0,base64.length-2)+"=="; + } + return base64; + } + + Base64Tool.encodeStr=function(str){ + var byte; + byte=new Byte(); + byte.writeUTFString(str); + return Base64Tool.encodeByte(byte); + } + + Base64Tool.encodeByte=function(byte,start,end){ + (start===void 0)&& (start=0); + (end===void 0)&& (end=-1); + if (end < 0){ + end=byte.length; + } + return Base64Tool.encode(byte.buffer.slice(start,end)); + } + + Base64Tool.decodeToByte=function(base64){ + return new Byte(Base64Tool.decode(base64)); + } + + Base64Tool.decode=function(base64){ + Base64Tool.init(); + var bufferLength=base64.length *0.75,len=base64.length,i=0,p=0,encoded1=0,encoded2=0,encoded3=0,encoded4=0; + if (base64[base64.length-1]==="="){ + bufferLength--; + if (base64[base64.length-2]==="="){ + bufferLength--; + } + }; + var arraybuffer=new ArrayBuffer(bufferLength),bytes=new Uint8Array(arraybuffer); + for (i=0;i < len;i+=4){ + encoded1=Base64Tool.lookup[base64.charCodeAt(i)]; + encoded2=Base64Tool.lookup[base64.charCodeAt(i+1)]; + encoded3=Base64Tool.lookup[base64.charCodeAt(i+2)]; + encoded4=Base64Tool.lookup[base64.charCodeAt(i+3)]; + bytes[p++]=(encoded1 << 2)| (encoded2 >> 4); + bytes[p++]=((encoded2 & 15)<< 4)| (encoded3 >> 2); + bytes[p++]=((encoded3 & 3)<< 6)| (encoded4 & 63); + } + return arraybuffer; + } + + Base64Tool.chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + Base64Tool.lookup=null; + return Base64Tool; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.CacheAnalyser + var CacheAnalyser=(function(){ + function CacheAnalyser(){} + __class(CacheAnalyser,'laya.debug.tools.CacheAnalyser'); + var __proto=CacheAnalyser.prototype; + __proto.renderCanvas=function(sprite,time){ + (time===void 0)&& (time=0); + if (!CacheAnalyser.showCacheSprite)return; + if (DebugInfoLayer.I.isDebugItem(sprite))return; + DebugTool.showDisBoundToSprite(sprite,DebugInfoLayer.I.cacheViewLayer,"#ff0000",2); + } + + __proto.reCacheCanvas=function(sprite,time){ + (time===void 0)&& (time=0); + if (DebugInfoLayer.I.isDebugItem(sprite))return; + var info; + info=CacheAnalyser.getNodeInfoByNode(sprite); + info.addCount(time); + CacheAnalyser.counter.addTime(sprite,time); + if (!info.parent){ + DebugInfoLayer.I.nodeRecInfoLayer.addChild(info); + } + } + + CacheAnalyser.renderLoopBegin=function(){ + DebugInfoLayer.I.cacheViewLayer.graphics.clear(); + } + + CacheAnalyser.getNodeInfoByNode=function(node){ + IDTools.idObj(node); + var key=0; + key=IDTools.getObjID(node); + if (!CacheAnalyser._nodeInfoDic[key]){ + CacheAnalyser._nodeInfoDic[key]=new ReCacheRecInfo(); + } + (CacheAnalyser._nodeInfoDic [key]).setTarget(node); + return CacheAnalyser._nodeInfoDic[key]; + } + + CacheAnalyser._nodeInfoDic={}; + CacheAnalyser.showCacheSprite=false; + __static(CacheAnalyser, + ['counter',function(){return this.counter=new ObjTimeCountTool();},'I',function(){return this.I=new CacheAnalyser();} + ]); + return CacheAnalyser; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.CanvasTools + var CanvasTools=(function(){ + function CanvasTools(){} + __class(CanvasTools,'laya.debug.tools.CanvasTools'); + CanvasTools.createCanvas=function(width,height){ + var rst=new HTMLCanvas("2D"); + rst.getContext('2d'); + rst.size(width,height); + return rst; + } + + CanvasTools.renderSpriteToCanvas=function(sprite,canvas,offsetX,offsetY){ + RenderSprite.renders[sprite._renderType]._fun(sprite,canvas.context,offsetX,offsetY); + } + + CanvasTools.getImageDataFromCanvas=function(canvas,x,y,width,height){ + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + if (width <=0) + width=canvas.width; + if (height <=0) + height=canvas.height; + var imgdata=canvas.context.getImageData(x,y,width,height); + return imgdata; + } + + CanvasTools.getImageDataFromCanvasByRec=function(canvas,rec){ + var imgdata=canvas.context.getImageData(rec.x,rec.y,rec.width,rec.height); + return imgdata; + } + + CanvasTools.getDifferCount=function(imageData1,imageData2){ + var data1=imageData1.data; + var data2=imageData2.data; + var differCount=0; + differCount=0; + CanvasTools.walkImageData(imageData1,myWalkFun); + return differCount; + function myWalkFun (i,j,tarPos,data){ + if (!CanvasTools.isPoinSame(tarPos,data1,data2))differCount++; + } + } + + CanvasTools.getDifferRate=function(imageData1,imageData2){ + return CanvasTools.getDifferCount(imageData1,imageData2)/(imageData1.width *imageData1.height); + } + + CanvasTools.getCanvasDisRec=function(canvas){ + var rst; + rst=new Rectangle; + var imgdata; + imgdata=CanvasTools.getImageDataFromCanvas(canvas,0,0); + var maxX=0; + var minX=0; + var maxY=0; + var minY=0; + maxX=maxY=0; + minX=imgdata.width; + minY=imgdata.height; + var i=0,iLen=0; + var j=0,jLen=0; + iLen=imgdata.width; + jLen=imgdata.height; + var data; + data=imgdata.data; + var tarPos=0; + for (j=0;j < jLen;j++){ + for (i=0;i < iLen;i++){ + if (!CanvasTools.isEmptyPoint(data,tarPos)){ + if (minX > i) + minX=i; + if (maxX < i) + maxX=i; + if (minY > j) + minY=j; + if (maxY < j) + maxY=j; + } + tarPos+=4; + } + } + rst.setTo(minX,minY,maxX-minX+1,maxY-minY+1); + return rst; + } + + CanvasTools.fillCanvasRec=function(canvas,rec,color){ + var ctx=canvas.context; + ctx.fillStyle=color; + ctx.fillRect(rec.x,rec.y,rec.width,rec.height); + } + + CanvasTools.isEmptyPoint=function(data,pos){ + if (data[pos]==0 && data[pos+1]==0 && data[pos+2]==0 && data[pos+3]==0){ + return true; + } + else{ + return false; + } + } + + CanvasTools.isPoinSame=function(pos,data1,data2){ + if (data1[pos]==data2[pos] && data1[pos+1]==data2[pos+1] && data1[pos+2]==data2[pos+2] && data1[pos+3]==data2[pos+3]){ + return true; + } + else{ + return false; + } + } + + CanvasTools.walkImageData=function(imgdata,walkFun){ + var i=0,iLen=0; + var j=0,jLen=0; + iLen=imgdata.width; + jLen=imgdata.height; + var tarPos=0; + var data=imgdata.data; + for (i=0;i < iLen;i++){ + for (j=0;j < jLen;j++){ + walkFun(i,j,tarPos,data); + tarPos+=4; + } + } + } + + CanvasTools.getSpriteByCanvas=function(canvas){ + var rst; + rst=new Sprite(); + rst.graphics.drawTexture(new Texture(canvas),0,0,canvas.width,canvas.height); + return rst; + } + + CanvasTools.renderSpritesToCanvas=function(canvas,sprites,offx,offy,startIndex){ + (offx===void 0)&& (offx=0); + (offy===void 0)&& (offy=0); + (startIndex===void 0)&& (startIndex=0); + var i=0,len=0; + len=sprites.length; + for (i=startIndex;i < len;i++){ + CanvasTools.renderSpriteToCanvas(sprites[i],canvas,offx,offy); + } + } + + CanvasTools.clearCanvas=function(canvas){ + var preWidth=NaN; + var preHeight=NaN; + preWidth=canvas.width; + preHeight=canvas.height; + canvas.size(preWidth+1,preHeight); + canvas.size(preWidth,preHeight); + } + + return CanvasTools; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-10-23 下午2:24:04 + */ + //class laya.debug.tools.ClassTool + var ClassTool=(function(){ + function ClassTool(){} + __class(ClassTool,'laya.debug.tools.ClassTool'); + ClassTool.defineProperty=function(obj,name,des){ + /*__JS__ */Object.defineProperty(obj,name,des);; + } + + ClassTool.getOwnPropertyDescriptor=function(obj,name){ + var rst; + /*__JS__ */rst=Object.getOwnPropertyDescriptor(obj,name);; + return rst; + } + + ClassTool.getOwnPropertyNames=function(obj){ + var rst; + /*__JS__ */rst=Object.getOwnPropertyNames(obj);; + return rst; + } + + ClassTool.getClassName=function(tar){ + if ((typeof tar=='function'))return tar.name; + return tar["constructor"].name; + } + + ClassTool.getNodeClassAndName=function(tar){ + if (!tar)return "null"; + var rst; + if (tar.name){ + rst=ClassTool.getClassName(tar)+"("+tar.name+")"; + }else{ + rst=ClassTool.getClassName(tar); + } + return rst; + } + + ClassTool.getClassNameByClz=function(clz){ + return clz["name"]; + } + + ClassTool.getClassByName=function(className){ + var rst; + rst=/*__JS__ */eval(className); + return rst; + } + + ClassTool.createObjByName=function(className){ + var clz; + clz=ClassTool.getClassByName(className); + return new clz(); + } + + return ClassTool; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.ColorTool + var ColorTool=(function(){ + function ColorTool(){ + this.red=NaN; + this.green=NaN; + this.blue=NaN; + } + + __class(ColorTool,'laya.debug.tools.ColorTool'); + ColorTool.toHexColor=function(color){ + if (color < 0 || isNaN(color)) + return null; + var str=color.toString(16); + while (str.length < 6) + str="0"+str; + return "#"+str; + } + + ColorTool.getRGBByRGBStr=function(str){ + str.charAt(0)=='#' && (str=str.substr(1)); + var color=/*__JS__ */parseInt(str,16); + var flag=(str.length==8); + var _color; + _color=[((0x00FF0000 & color)>> 16),((0x0000FF00 & color)>> 8),(0x000000FF & color)]; + return _color; + } + + ColorTool.getColorBit=function(value){ + var rst; + rst=Math.floor(value).toString(16); + rst=rst.length > 1 ? rst :"0"+rst; + return rst; + } + + ColorTool.getRGBStr=function(rgb){ + return "#"+ColorTool.getColorBit(rgb[0])+ColorTool.getColorBit(rgb[1])+ColorTool.getColorBit(rgb[2]); + } + + ColorTool.traseHSB=function(hsb){ + console.log("hsb:",hsb[0],hsb[1],hsb[2]); + } + + ColorTool.rgb2hsb=function(rgbR,rgbG,rgbB){ + var rgb=[rgbR,rgbG,rgbB]; + rgb.sort(MathTools.sortNumSmallFirst); + var max=rgb[2]; + var min=rgb[0]; + var hsbB=max / 255.0; + var hsbS=max==0 ? 0 :(max-min)/ max; + var hsbH=0; + if(max==min){ + hsbH=1; + } + else + if (rgbR==0 && rgbG==0&&rgbB==0){ + }else + if (max==rgbR && rgbG >=rgbB){ + hsbH=(rgbG-rgbB)*60 / (max-min)+0; + } + else if (max==rgbR && rgbG < rgbB){ + hsbH=(rgbG-rgbB)*60 / (max-min)+360; + } + else if (max==rgbG){ + hsbH=(rgbB-rgbR)*60 / (max-min)+120; + } + else if (max==rgbB){ + hsbH=(rgbR-rgbG)*60 / (max-min)+240; + } + return [hsbH,hsbS,hsbB]; + } + + ColorTool.hsb2rgb=function(h,s,v){ + var r=0,g=0,b=0; + var i=Math.floor((h / 60)% 6); + var f=(h / 60)-i; + var p=v *(1-s); + var q=v *(1-f *s); + var t=v *(1-(1-f)*s); + switch (i){ + case 0: + r=v; + g=t; + b=p; + break ; + case 1: + r=q; + g=v; + b=p; + break ; + case 2: + r=p; + g=v; + b=t; + break ; + case 3: + r=p; + g=q; + b=v; + break ; + case 4: + r=t; + g=p; + b=v; + break ; + case 5: + r=v; + g=p; + b=q; + break ; + default : + break ; + } + return [Math.floor(r *255.0),Math.floor(g *255.0),Math.floor(b *255.0)]; + } + + return ColorTool; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-29 下午12:53:31 + */ + //class laya.debug.tools.CommonTools + var CommonTools=(function(){ + function CommonTools(){} + __class(CommonTools,'laya.debug.tools.CommonTools'); + CommonTools.bind=function(fun,scope){ + var rst; + /*__JS__ */rst=fun.bind(scope); + return rst; + } + + CommonTools.insertP=function(tar,x,y,scaleX,scaleY,rotation){ + var nSp; + nSp=new Sprite(); + tar.parent.addChild(nSp); + nSp.x=x; + nSp.y=y; + nSp.scaleX=scaleX; + nSp.scaleY=scaleY; + nSp.rotation=rotation; + nSp.addChild(tar); + CommonTools.count++; + nSp.name="insertP:"+CommonTools.count; + } + + CommonTools.insertChild=function(tar,x,y,scaleX,scaleY,rotation,color){ + (color===void 0)&& (color="#ff00ff"); + var nSp; + nSp=new Sprite(); + tar.addChild(nSp); + nSp.x=x; + nSp.y=y; + nSp.scaleX=scaleX; + nSp.scaleY=scaleY; + nSp.rotation=rotation; + nSp.graphics.drawRect(0,0,20,20,color); + nSp.name="child:"+tar.numChildren; + return nSp; + } + + CommonTools.count=0; + return CommonTools; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-24 下午6:37:56 + */ + //class laya.debug.tools.CountTool + var CountTool=(function(){ + function CountTool(){ + this.data={}; + this.preO={}; + this.changeO={}; + this.count=0; + } + + __class(CountTool,'laya.debug.tools.CountTool'); + var __proto=CountTool.prototype; + __proto.reset=function(){ + this.data={}; + this.count=0; + } + + __proto.add=function(name,num){ + (num===void 0)&& (num=1); + this.count++; + if(!this.data.hasOwnProperty(name)){ + this.data[name]=0; + } + this.data[name]=this.data[name]+num; + } + + __proto.getKeyCount=function(key){ + if(!this.data.hasOwnProperty(key)){ + this.data[key]=0; + } + return this.data[key]; + } + + __proto.getKeyChange=function(key){ + if (!this.changeO[key])return 0; + return this.changeO[key]; + } + + __proto.record=function(){ + var key; + for (key in this.changeO){ + this.changeO[key]=0; + } + for (key in this.data){ + if (!this.preO[key])this.preO[key]=0; + this.changeO[key]=this.data[key]-this.preO[key]; + this.preO[key]=this.data[key] + } + } + + __proto.getCount=function(dataO){ + var rst=0; + var key; + for (key in dataO){ + rst+=dataO[key]; + } + return rst; + } + + __proto.traceSelf=function(dataO){ + if (!dataO)dataO=this.data; + var tCount=0; + tCount=this.getCount(dataO); + console.log("total:"+tCount); + return "total:"+tCount+"\n"+TraceTool.traceObj(dataO); + } + + __proto.traceSelfR=function(dataO){ + if (!dataO)dataO=this.data; + var tCount=0; + tCount=this.getCount(dataO); + console.log("total:"+tCount); + return "total:"+tCount+"\n"+TraceTool.traceObjR(dataO); + } + + return CountTool; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-10-31 下午3:35:16 + */ + //class laya.debug.tools.DebugExport + var DebugExport=(function(){ + function DebugExport(){} + __class(DebugExport,'laya.debug.tools.DebugExport'); + DebugExport.export=function(){ + var _window; + /*__JS__ */_window=window;; + var key; + for(key in DebugExport._exportsDic){ + _window[key]=DebugExport._exportsDic[key]; + } + } + + __static(DebugExport, + ['_exportsDic',function(){return this._exportsDic={ + "DebugTool":DebugTool, + "Watcher":Watcher + };} + + ]); + return DebugExport; + })() + + + /** + *本类用于显示对象值变化过程 + *@author ww + *@version 1.0 + * + *@created 2015-10-23 上午10:41:50 + */ + //class laya.debug.tools.DifferTool + var DifferTool=(function(){ + function DifferTool(sign,autoTrace){ + this.autoTrace=true; + this.sign=""; + this.obj=null; + (sign===void 0)&& (sign=""); + (autoTrace===void 0)&& (autoTrace=true); + this.sign=sign; + this.autoTrace=autoTrace; + } + + __class(DifferTool,'laya.debug.tools.DifferTool'); + var __proto=DifferTool.prototype; + __proto.update=function(data,msg){ + if(msg){ + console.log(msg); + }; + var tObj=ObjectTools.copyObj(data); + if(!this.obj)this.obj={}; + var rst; + rst=ObjectTools.differ(this.obj,tObj); + this.obj=tObj; + if(this.autoTrace){ + console.log(this.sign+" differ:"); + ObjectTools.traceDifferObj(rst); + } + return rst; + } + + DifferTool.differ=function(sign,data,msg){ + if(!DifferTool._differO[sign])DifferTool._differO[sign]=new DifferTool(sign,true); + var tDiffer; + tDiffer=DifferTool._differO[sign]; + return tDiffer.update(data,msg); + } + + DifferTool._differO={}; + return DifferTool; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2016-1-14 下午4:32:47 + */ + //class laya.debug.tools.DisController + var DisController=(function(){ + function DisController(){ + this.arrowAxis=null; + this._target=null; + this.recInfo=null; + DisController.init(); + this.arrowAxis=new Axis(); + this.arrowAxis.mouseEnabled=true; + } + + __class(DisController,'laya.debug.tools.DisController'); + var __proto=DisController.prototype; + __proto.switchType=function(){ + this.arrowAxis.switchType(); + } + + __proto.updateMe=function(){ + if(!this._target)return; + this.recInfo=RecInfo.getGlobalRecInfo(this._target,0,0,1,0,0,1); + console.log("rotation:",this.recInfo.rotation); + console.log("pos:",this.recInfo.x,this.recInfo.y); + console.log("scale:",this.recInfo.width,this.recInfo.height); + this.arrowAxis.x=this.recInfo.x; + this.arrowAxis.y=this.recInfo.y; + this.arrowAxis.rotation=this.recInfo.rotation; + this.arrowAxis.yAxis.rotation=this.recInfo.rotationV-this.recInfo.rotation; + } + + __getset(0,__proto,'target',function(){ + return this._target; + },function(target){ + this._target=target; + if(target){ + DisController._container.addChild(this.arrowAxis); + Laya.timer.loop(100,this,this.updateMe); + }else{ + this.arrowAxis.removeSelf(); + Laya.timer.clear(this,this.updateMe); + } + this.arrowAxis.target=target; + this.updateMe(); + }); + + __getset(0,__proto,'type',function(){ + return this.arrowAxis.type; + },function(lenType){ + this.arrowAxis.type=lenType; + }); + + DisController.init=function(){ + if (DisController._container){ + DisControlTool.setTop(DisController._container); + return; + }; + DisController._container=new Sprite(); + DisController._container.mouseEnabled=true; + Laya.stage.addChild(DisController._container); + } + + DisController._container=null + __static(DisController, + ['I',function(){return this.I=new DisController();} + ]); + return DisController; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-25 下午7:19:44 + */ + //class laya.debug.tools.DisControlTool + var DisControlTool=(function(){ + function DisControlTool(){} + __class(DisControlTool,'laya.debug.tools.DisControlTool'); + DisControlTool.getObjectsUnderPoint=function(sprite,x,y,rst,filterFun){ + rst=rst?rst:[]; + if(filterFun!=null&&!filterFun(sprite))return rst; + if (sprite.getBounds().contains(x,y)){ + rst.push(sprite); + var tS; + var tempP=new Point(); + tempP.setTo(x,y); + tempP=sprite.fromParentPoint(tempP); + x=tempP.x; + y=tempP.y; + for (var i=sprite._childs.length-1;i >-1;i--){ + var child=sprite._childs[i]; + if((child instanceof laya.display.Sprite )) + DisControlTool.getObjectsUnderPoint(child,x,y,rst,filterFun); + } + } + return rst; + } + + DisControlTool.getObjectsUnderGlobalPoint=function(sprite,filterFun){ + var point=new Point(); + point.setTo(Laya.stage.mouseX,Laya.stage.mouseY); + if(sprite.parent) + point=(sprite.parent).globalToLocal(point); + return DisControlTool.getObjectsUnderPoint(sprite,point.x,point.y,null,filterFun); + } + + DisControlTool.findFirstObjectsUnderGlobalPoint=function(){ + var disList; + disList=DisControlTool.getObjectsUnderGlobalPoint(Laya.stage); + if (!disList)return null; + var i=0,len=0; + var tDis; + len=disList.length; + for (i=len-1;i>=0;i--){ + tDis=disList[i]; + if (tDis && tDis.numChildren < 1){ + return tDis; + } + } + return tDis; + } + + DisControlTool.visibleAndEnableObjFun=function(tar){ + return tar.visible&&tar.mouseEnabled; + } + + DisControlTool.visibleObjFun=function(tar){ + return tar.visible; + } + + DisControlTool.getMousePoint=function(sprite){ + var point=new Point(); + point.setTo(Laya.stage.mouseX,Laya.stage.mouseY); + point=sprite.globalToLocal(point); + return point; + } + + DisControlTool.isChildE=function(parent,child){ + if (!parent)return false; + while (child){ + if (child.parent==parent)return true; + child=child.parent; + } + return false; + } + + DisControlTool.isInTree=function(pNode,child){ + return pNode==child || DisControlTool.isChildE(pNode,child); + } + + DisControlTool.setTop=function(tar){ + if(tar&&tar.parent){ + var tParent; + tParent=tar.parent; + tParent.setChildIndex(tar,tParent.numChildren-1); + } + } + + DisControlTool.clearItemRelativeInfo=function(item){ + var Nan="NaN"; + item.getLayout().left=Nan; + item.getLayout().right=Nan; + item.getLayout().top=Nan; + item.getLayout().bottom=Nan; + } + + DisControlTool.swap=function(tarA,tarB){ + if (tarA==tarB)return; + var iA=0; + iA=tarA.parent.getChildIndex(tarA); + var iB=0; + iB=tarB.parent.getChildIndex(tarB); + var bP; + bP=tarB.parent; + tarA.parent.addChildAt(tarB,iA); + bP.addChildAt(tarA,iB); + } + + DisControlTool.insertToTarParent=function(tarA,tars,after){ + (after===void 0)&& (after=false); + var tIndex=0; + var parent; + if(!tarA)return; + parent=tarA.parent; + if(!parent)return; + tIndex=parent.getChildIndex(tarA); + if(after)tIndex++; + DisControlTool.insertToParent(parent,tars,tIndex); + } + + DisControlTool.insertToParent=function(parent,tars,index){ + (index===void 0)&& (index=-1); + if(!parent)return; + if(index<0)index=parent.numChildren; + var i=0,len=0; + len=tars.length; + for(i=0;i=tParent.numChildren){ + newIndex=tParent.numChildren-1; + } + console.log("setChildIndex:"+newIndex); + tParent.setChildIndex(child,newIndex); + } + } + + DisControlTool.downDis=function(child){ + if(child&&child.parent){ + var tParent; + tParent=child.parent; + var newIndex=0; + newIndex=tParent.getChildIndex(child)-1; + if(newIndex<0)newIndex=0; + console.log("setChildIndex:"+newIndex); + tParent.setChildIndex(child,newIndex); + } + } + + DisControlTool.setResizeAbleEx=function(node){ + var clickItem; + clickItem=node.getChildByName("resizeBtn"); + if (clickItem){ + SimpleResizer.setResizeAble(clickItem,node); + } + } + + DisControlTool.setResizeAble=function(node){ + node.on(/*laya.events.Event.CLICK*/"click",null,DisControlTool.resizeHandler,[node]); + } + + DisControlTool.resizeHandler=function(tar){ + DisResizer.setUp(tar); + } + + DisControlTool.setDragingItem=function(dragBar,tar){ + dragBar.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",null,DisControlTool.dragingHandler,[tar]); + tar.on(/*laya.events.Event.DRAG_END*/"dragend",null,DisControlTool.dragingEnd,[tar]); + } + + DisControlTool.dragingHandler=function(tar){ + if (tar){ + tar.startDrag(); + } + } + + DisControlTool.dragingEnd=function(tar){ + DisControlTool.intFyDisPos(tar); + console.log(tar.x,tar.y); + } + + DisControlTool.showToStage=function(dis,offX,offY){ + (offX===void 0)&& (offX=0); + (offY===void 0)&& (offY=0); + var rec=dis.getBounds(); + dis.x=Laya.stage.mouseX+offX; + dis.y=Laya.stage.mouseY+offY; + if (dis.x+rec.width > Laya.stage.width){ + dis.x-=rec.width+offX; + } + if (dis.y+rec.height > Laya.stage.height){ + dis.y-=rec.height+offY; + } + DisControlTool.intFyDisPos(dis); + } + + DisControlTool.intFyDisPos=function(dis){ + if (!dis)return; + dis.x=Math.round(dis.x); + dis.y=Math.round(dis.y); + } + + DisControlTool.showOnly=function(disList,showItem){ + var i=0,len=0; + len=disList.length; + for (i=0;i < len;i++){ + disList[i].visible=disList[i]==showItem; + } + } + + DisControlTool.showOnlyByIndex=function(disList,index){ + DisControlTool.showOnly(disList,disList[index]); + } + + DisControlTool.addOnly=function(disList,showItem,parent){ + var i=0,len=0; + len=disList.length; + for (i=0;i < len;i++){ + if (disList[i] !=showItem){ + disList[i].removeSelf(); + }else{ + parent.addChild(disList[i]); + } + } + } + + DisControlTool.addOnlyByIndex=function(disList,index,parent){ + DisControlTool.addOnly(disList,disList[index],parent); + } + + __static(DisControlTool, + ['tempP',function(){return this.tempP=new Point();} + ]); + return DisControlTool; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-12-24 下午4:20:25 + */ + //class laya.debug.tools.DisEditor + var DisEditor=(function(){ + function DisEditor(){ + this.tar=null; + this.rec=new Sprite(); + this.rootContainer=new Sprite(); + } + + __class(DisEditor,'laya.debug.tools.DisEditor'); + var __proto=DisEditor.prototype; + __proto.setTarget=function(target){ + this.tar=target; + var g; + g=this.rec.graphics; + g.clear(); + var bounds; + bounds=this.tar.getSelfBounds(); + g.drawRect(bounds.x,bounds.y,bounds.width,bounds.height,null,"#00ff00"); + this.createSameDisChain(); + Laya.stage.addChild(this.rootContainer); + } + + __proto.createSameDisChain=function(){ + var tParent; + var cpParent; + var preTar; + preTar=this.rec; + tParent=this.tar; + while(tParent&&tParent!=Laya.stage){ + cpParent=new Sprite(); + cpParent.addChild(preTar); + cpParent.x=tParent.x; + cpParent.y=tParent.y; + cpParent.scaleX=tParent.scaleX; + cpParent.scaleY=tParent.scaleY; + cpParent.rotation=tParent.rotation; + cpParent.scrollRect=tParent.scrollRect; + preTar=cpParent; + tParent=tParent.parent; + } + this.rootContainer.removeChildren(); + this.rootContainer.addChild(preTar); + } + + return DisEditor; + })() + + + /** + *调试拾取显示对象类 + *@author ww + */ + //class laya.debug.tools.DisplayHook + var DisplayHook=(function(){ + function DisplayHook(){ + this.mouseX=NaN; + this.mouseY=NaN; + this._stage=null; + this._target=null; + this.isGetting=false; + this._matrix=new Matrix(); + this._point=new Point(); + this._rect=new Rectangle(); + this._event=Event.EMPTY; + this._stage=Laya.stage; + this.init(Render.context.canvas); + } + + __class(DisplayHook,'laya.debug.tools.DisplayHook'); + var __proto=DisplayHook.prototype; + __proto.init=function(canvas){ + var _$this=this; + if (Browser.window.navigator.msPointerEnabled){ + canvas.style['-ms-content-zooming']='none'; + canvas.style['-ms-touch-action']='none'; + }; + var _this=this; + Browser.document.addEventListener('mousedown',function(e){ + _$this._event._stoped=false; + DisplayHook.isFirst=true; + _this.check(_this._stage,e.offsetX,e.offsetY,_this.onMouseDown,true,false); + },true); + Browser.document.addEventListener('touchstart',function(e){ + _$this._event._stoped=false; + DisplayHook.isFirst=true; + var touches=e.changedTouches; + for (var i=0,n=touches.length;i < n;i++){ + var touch=touches[i]; + initEvent(touch,e); + _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseDown,true,false); + } + },true); + function initEvent (e,event){ + _this._event._stoped=false; + _this._event.nativeEvent=event || e; + _this._target=null; + if (e.offsetX){ + _this.mouseX=e.offsetX; + _this.mouseY=e.offsetY; + }else { + _this.mouseX=e.clientX-Laya.stage.offset.x; + _this.mouseY=e.clientY-Laya.stage.offset.y; + } + } + } + + __proto.onMouseMove=function(ele,hit){ + this.sendEvent(ele,/*laya.events.Event.MOUSE_MOVE*/"mousemove"); + return; + if (hit && ele !=this._stage && ele!==this._target){ + if (this._target){ + if (this._target.$_MOUSEOVER){ + this._target.$_MOUSEOVER=false; + this._target.event(/*laya.events.Event.MOUSE_OUT*/"mouseout"); + } + } + this._target=ele; + if (!ele.$_MOUSEOVER){ + ele.$_MOUSEOVER=true; + this.sendEvent(ele,/*laya.events.Event.MOUSE_OVER*/"mouseover"); + } + }else if (!hit && this._target && ele===this._target){ + this._target=null; + if (ele.$_MOUSEOVER){ + ele.$_MOUSEOVER=false; + this.sendEvent(ele,/*laya.events.Event.MOUSE_OUT*/"mouseout"); + } + } + } + + __proto.onMouseUp=function(ele,hit){ + hit && this.sendEvent(ele,/*laya.events.Event.MOUSE_UP*/"mouseup"); + } + + __proto.onMouseDown=function(ele,hit){ + if (hit){ + ele.$_MOUSEDOWN=true; + this.sendEvent(ele,/*laya.events.Event.MOUSE_DOWN*/"mousedown"); + } + } + + __proto.sendEvent=function(ele,type){ + if (!this._event._stoped){ + ele.event(type,this._event.setTo(type,ele,ele)); + if (type===/*laya.events.Event.MOUSE_UP*/"mouseup" && ele.$_MOUSEDOWN){ + ele.$_MOUSEDOWN=false; + ele.event(/*laya.events.Event.CLICK*/"click",this._event.setTo(/*laya.events.Event.CLICK*/"click",ele,ele)); + } + } + } + + __proto.selectDisUnderMouse=function(){ + DisplayHook.isFirst=true; + this.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null,true,false); + SelectInfosView.I.setSelectTarget(DebugTool.target); + } + + __proto.getDisUnderMouse=function(){ + this.isGetting=true; + DisplayHook.isFirst=true; + DebugTool.target=null; + this.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null,true,false); + this.isGetting=false; + return DebugTool.target; + } + + __proto.check=function(sp,mouseX,mouseY,callBack,hitTest,mouseEnable){ + if (sp==DebugTool.debugLayer)return false; + if (sp==DebugInfoLayer.I)return false; + if (this.isGetting && sp==DebugInfoLayer.I)return false; + if (!sp.visible || sp.getSelfBounds().width<=0)return false; + var isHit=false; + mouseEnable=true + if (mouseEnable){ + var graphicHit=false; + if (hitTest){ + this._rect=sp.getBounds(); + isHit=this._rect.contains(mouseX,mouseY); + this._point.setTo(mouseX,mouseY); + sp.fromParentPoint(this._point); + mouseX=this._point.x; + mouseY=this._point.y; + } + if (isHit){ + var flag=false; + for (var i=sp._childs.length-1;i >-1;i--){ + var child=sp._childs[i]; + (flag=this.check(child,mouseX,mouseY,callBack,hitTest,true)); + if (flag)break ; + } + graphicHit=sp.getGraphicBounds().contains(mouseX,mouseY); + isHit=flag||graphicHit; + if(isHit&&!flag&&DisplayHook.isFirst){ + DisplayHook.isFirst=false; + if(! ((sp instanceof laya.debug.tools.debugUI.DButton ))){ + DebugTool.target=sp; + if (!this.isGetting){ + DebugTool.autoWork(); + Notice.notify("ItemClicked",sp); + } + } + } + } + } + return isHit; + } + + DisplayHook.initMe=function(){ + if(!DisplayHook.instance){ + DisplayHook.instance=new DisplayHook(); + } + } + + DisplayHook.ITEM_CLICKED="ItemClicked"; + DisplayHook.instance=null + DisplayHook.isFirst=false; + return DisplayHook; + })() + + + /** + *简单的显示对象对象池 + *从父容器上移除时即被视为可被重用 + *@author ww + *@version 1.0 + * + *@created 2015-11-13 下午8:05:13 + */ + //class laya.debug.tools.DisPool + var DisPool=(function(){ + function DisPool(){} + __class(DisPool,'laya.debug.tools.DisPool'); + DisPool.getDis=function(clz){ + var clzName; + clzName=ClassTool.getClassNameByClz(clz); + if(!DisPool._objDic[clzName]){ + DisPool._objDic[clzName]=[]; + }; + var disList; + disList=DisPool._objDic[clzName]; + var i=0,len=0; + len=disList.length; + for(i=0;i0&& SpriteRenderForVisibleAnalyse.tarRec.height > 0){ + SpriteRenderForVisibleAnalyse.isTarRecOK=true; + SpriteRenderForVisibleAnalyse.preImageData=CanvasTools.getImageDataFromCanvasByRec(SpriteRenderForVisibleAnalyse.mainCanvas,SpriteRenderForVisibleAnalyse.tarRec); + SpriteRenderForVisibleAnalyse.tarImageData=CanvasTools.getImageDataFromCanvasByRec(SpriteRenderForVisibleAnalyse.mainCanvas,SpriteRenderForVisibleAnalyse.tarRec); + }else{ + console.log("tarRec Not OK:",SpriteRenderForVisibleAnalyse.tarRec); + } + }else{ + if (SpriteRenderForVisibleAnalyse.isTarRecOK){ + SpriteRenderForVisibleAnalyse.tImageData=CanvasTools.getImageDataFromCanvasByRec(SpriteRenderForVisibleAnalyse.mainCanvas,SpriteRenderForVisibleAnalyse.tarRec); + var dRate=NaN; + dRate=CanvasTools.getDifferRate(SpriteRenderForVisibleAnalyse.preImageData,SpriteRenderForVisibleAnalyse.tImageData); + SpriteRenderForVisibleAnalyse.preImageData=SpriteRenderForVisibleAnalyse.tImageData; + if (dRate > 0){ + VisibleAnalyser.addCoverNode(me,dRate); + } + } + } + } + + __proto.analyseNode=function(node){ + VisibleAnalyser.resetCoverList(); + if (Sprite["prototype"]["render"] !=SpriteRenderForVisibleAnalyse.I.render){ + this.preFun=Sprite["prototype"]["render"]; + } + this.target=node; + Sprite["prototype"]["render"]=this.render; + if (!SpriteRenderForVisibleAnalyse.tarCanvas) + SpriteRenderForVisibleAnalyse.tarCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height); + if (!SpriteRenderForVisibleAnalyse.mainCanvas) + SpriteRenderForVisibleAnalyse.mainCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height); + this.isTargetRenderd=false; + SpriteRenderForVisibleAnalyse.isVisibleTesting=true; + SpriteRenderForVisibleAnalyse.allowRendering=false; + CanvasTools.clearCanvas(SpriteRenderForVisibleAnalyse.mainCanvas); + CanvasTools.clearCanvas(SpriteRenderForVisibleAnalyse.tarCanvas); + SpriteRenderForVisibleAnalyse.isTarRecOK=false; + var ctx=new RenderContext(SpriteRenderForVisibleAnalyse.mainCanvas.width,SpriteRenderForVisibleAnalyse.mainCanvas.height,SpriteRenderForVisibleAnalyse.mainCanvas); + SpriteRenderForVisibleAnalyse.mainCanvas=ctx.canvas; + this.render.call(Laya.stage,ctx,0,0); + if (!SpriteRenderForVisibleAnalyse.isTarRecOK){ + SpriteRenderForVisibleAnalyse.coverRate=0; + }else{ + SpriteRenderForVisibleAnalyse.coverRate=CanvasTools.getDifferRate(SpriteRenderForVisibleAnalyse.preImageData,SpriteRenderForVisibleAnalyse.tarImageData); + } + VisibleAnalyser.coverRate=SpriteRenderForVisibleAnalyse.coverRate; + VisibleAnalyser.isTarRecOK=SpriteRenderForVisibleAnalyse.isTarRecOK; + console.log("coverRate:",SpriteRenderForVisibleAnalyse.coverRate); + this.isTargetRenderd=false; + SpriteRenderForVisibleAnalyse.isVisibleTesting=false; + SpriteRenderForVisibleAnalyse.allowRendering=true; + Sprite["prototype"]["render"]=this.preFun; + } + + __proto.noRenderMode=function(){ + return; + RenderSprite["prototype"]["_graphics"]=this.m_graphics; + RenderSprite["prototype"]["_image"]=this.m_image; + RenderSprite["prototype"]["_image2"]=this.m_image2; + } + + __proto.normalMode=function(){ + RenderSprite["prototype"]["_graphics"]=this.pgraphic; + RenderSprite["prototype"]["_image"]=this.pimage; + RenderSprite["prototype"]["_image2"]=this.pimage2; + } + + __proto.inits=function(){ + this.noRenderMode(); + } + + __proto.m_graphics=function(sprite,context,x,y){ + if (laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){ + var tf=sprite._style._tf; + sprite._graphics && sprite._graphics._render(sprite,context,x-tf.translateX,y-tf.translateY); + }; + var next=this._next; + next._fun.call(next,sprite,context,x,y); + } + + __proto.m_image=function(sprite,context,x,y){ + if (laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){ + var style=sprite._style; + context.ctx.drawTexture2(x,y,style._tf.translateX,style._tf.translateY,sprite.transform,style.alpha,style.blendMode,sprite._graphics._one); + } + } + + __proto.m_image2=function(sprite,context,x,y){ + if (laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){ + var tf=sprite._style._tf; + context.ctx.drawTexture2(x,y,tf.translateX,tf.translateY,sprite.transform,1,null,sprite._graphics._one); + } + } + + SpriteRenderForVisibleAnalyse.tarCanvas=null + SpriteRenderForVisibleAnalyse.mainCanvas=null + SpriteRenderForVisibleAnalyse.preImageData=null + SpriteRenderForVisibleAnalyse.tImageData=null + SpriteRenderForVisibleAnalyse.tarImageData=null + SpriteRenderForVisibleAnalyse.tarRec=null + SpriteRenderForVisibleAnalyse.isTarRecOK=false; + SpriteRenderForVisibleAnalyse.isVisibleTesting=false; + SpriteRenderForVisibleAnalyse.allowRendering=true; + SpriteRenderForVisibleAnalyse.coverRate=NaN + __static(SpriteRenderForVisibleAnalyse, + ['I',function(){return this.I=new SpriteRenderForVisibleAnalyse();} + ]); + return SpriteRenderForVisibleAnalyse; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.enginehook.SpriteRenderHook + var SpriteRenderHook=(function(){ + function SpriteRenderHook(){ + this._repaint=1; + this._renderType=1; + this._x=0; + this._y=0; + } + + __class(SpriteRenderHook,'laya.debug.tools.enginehook.SpriteRenderHook'); + var __proto=SpriteRenderHook.prototype; + /** + *更新、呈现显示对象。 + *@param context 渲染的上下文引用。 + *@param x X轴坐标。 + *@param y Y轴坐标。 + */ + __proto.render=function(context,x,y){ + if ((this)==Laya.stage){ + CacheAnalyser.renderLoopBegin(); + }; + var preTime=0; + preTime=Browser.now(); + Stat.spriteCount++; + RenderSprite.renders[this._renderType]._fun(this,context,x+this._x,y+this._y); + this._repaint=0; + RenderAnalyser.I.render(this,Browser.now()-preTime); + } + + SpriteRenderHook.init=function(){ + SpriteRenderHook.I=new SpriteRenderHook(); + SpriteRenderHook.setRenderHook(); + } + + SpriteRenderHook.setRenderHook=function(){ + Sprite["prototype"]["render"]=SpriteRenderHook.I.render; + } + + SpriteRenderHook.I=null + return SpriteRenderHook; + })() + + + /** + *本类调用原生observe接口,仅支持部分浏览器,chrome有效 + *变化输出为异步方式,所以无法跟踪到是什么函数导致变化 + *@author ww + *@version 1.0 + * + *@created 2015-10-26 上午9:35:45 + */ + //class laya.debug.tools.exp.Observer + var Observer=(function(){ + function Observer(){} + __class(Observer,'laya.debug.tools.exp.Observer'); + Observer.observe=function(obj,callBack){ + /*__JS__ */Object.observe(obj,callBack); + } + + Observer.unobserve=function(obj,callBack){ + /*__JS__ */Object.unobserve(obj,callBack); + } + + Observer.observeDiffer=function(obj,sign,msg){ + (msg===void 0)&& (msg="obDiffer"); + var differFun=function (){ + DifferTool.differ(sign,obj,msg); + } + Observer.observe(obj,differFun); + } + + return Observer; + })() + + + /** + *本类调用原生watch接口,仅火狐有效 + *@author ww + *@version 1.0 + * + *@created 2015-10-26 上午9:48:18 + */ + //class laya.debug.tools.exp.Watch + var Watch=(function(){ + function Watch(){} + __class(Watch,'laya.debug.tools.exp.Watch'); + Watch.watch=function(obj,name,callBack){ + /*__JS__ */obj.watch(name,callBack); + } + + Watch.unwatch=function(obj,name,callBack){ + /*__JS__ */obj.unwatch(name,callBack); + } + + return Watch; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-10-30 下午1:06:56 + */ + //class laya.debug.tools.FilterTool + var FilterTool=(function(){ + function FilterTool(){} + __class(FilterTool,'laya.debug.tools.FilterTool'); + FilterTool.getArrByFilter=function(arr,filterFun){ + var i=0,len=arr.length; + var rst=[]; + for(i=0;i 0)return JSTools._pixelRatio; + var canvas=Browser.createElement("canvas"); + var context=canvas.getContext('2d'); + var devicePixelRatio=Browser.window.devicePixelRatio || 1; + var backingStoreRatio=context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; + var ratio=devicePixelRatio / backingStoreRatio; + console.log("pixelRatioc:",ratio); + JSTools._pixelRatio=ratio; + return ratio; + } + + JSTools._pixelRatio=-1; + return JSTools; + })() + + + /** + *布局工具类,目前只支持水平方向布局 + *@author ww + */ + //class laya.debug.tools.layout.Layouter + var Layouter=(function(){ + function Layouter(){ + this.data=null; + this._items=null; + this.layoutFun=null; + this._sX=0; + this._width=0; + } + + __class(Layouter,'laya.debug.tools.layout.Layouter'); + var __proto=Layouter.prototype; + __proto.layout=function(){ + this.layoutFun(this._width,this._items,this.data,this._sX); + } + + /** + *重新布局 + * + */ + __proto.changed=function(){ + Laya.timer.callLater(this,this.layout); + } + + /** + *根据当前的对象状态计算位置大小 + * + */ + __proto.calSize=function(){ + var i=0,len=0; + var tItem; + tItem=this.items[0]; + this._sX=tItem.x; + var maxX=NaN; + maxX=this._sX+tItem.width; + len=this.items.length; + for (i=1;i < len;i++){ + tItem=this.items[i]; + if (this._sX > tItem.x){ + this._sX=tItem.x; + } + if (maxX < tItem.x+tItem.width){ + maxX=tItem.x+tItem.width; + } + } + this._width=maxX-this._sX; + } + + __getset(0,__proto,'width',function(){ + return this._width; + },function(v){ + this._width=v; + this.changed(); + }); + + __getset(0,__proto,'x',function(){ + return this._sX; + },function(v){ + this._sX=v; + this.changed(); + }); + + __getset(0,__proto,'items',function(){ + return this._items; + },function(arr){ + this._items=arr; + this.calSize(); + }); + + return Layouter; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.layout.LayoutFuns + var LayoutFuns=(function(){ + function LayoutFuns(){} + __class(LayoutFuns,'laya.debug.tools.layout.LayoutFuns'); + LayoutFuns.sameWidth=function(totalWidth,items,data,sX){ + (sX===void 0)&& (sX=0); + var dWidth=0; + if (data && data.dWidth) + dWidth=data.dWidth; + var perWidth=NaN; + perWidth=(totalWidth-(items.length-1)*dWidth)/ items.length; + var tItem; + var i=0,len=0; + var tX=NaN; + tX=sX; + len=items.length; + for (i=0;i < len;i++){ + tItem=items[i]; + tItem.x=tX; + tItem.width=perWidth; + tX+=dWidth+perWidth; + } + } + + LayoutFuns.getSameWidthLayout=function(items,dWidth){ + var data; + data={}; + data.dWidth=dWidth; + return LayoutFuns.getLayouter(items,data,laya.debug.tools.layout.LayoutFuns.sameWidth); + } + + LayoutFuns.getLayouter=function(items,data,fun){ + var layouter; + layouter=new Layouter(); + layouter.items=items; + layouter.data=data; + layouter.layoutFun=fun; + return layouter; + } + + LayoutFuns.sameDis=function(totalWidth,items,data,sX){ + (sX===void 0)&& (sX=0); + var dWidth=NaN; + dWidth=totalWidth; + var tItem; + var i=0,len=0; + len=items.length; + LayoutFuns.prepareForLayoutWidth(totalWidth,items); + for (i=0;i < len;i++){ + tItem=items[i]; + dWidth-=tItem.width; + } + if (items.length > 1) + dWidth=dWidth / (items.length-1); + var tX=NaN; + tX=sX; + len=items.length; + for (i=0;i < len;i++){ + tItem=items[i]; + tItem.x=tX; + tX+=dWidth+tItem.width; + } + } + + LayoutFuns.getSameDisLayout=function(items,rateSame){ + (rateSame===void 0)&& (rateSame=false); + var data; + data={}; + if (rateSame){ + var i=0,len=0; + len=items.length; + var tItem; + var totalWidth=NaN; + totalWidth=0; + for (i=0;i < len;i++){ + tItem=items[i]; + totalWidth+=tItem.width; + } + totalWidth=tItem.x+tItem.width; + for (i=0;i < len;i++){ + tItem=items[i]; + LayoutFuns.setItemRate(tItem,tItem.width / totalWidth); + } + } + return LayoutFuns.getLayouter(items,data,laya.debug.tools.layout.LayoutFuns.sameDis); + } + + LayoutFuns.fullFill=function(totalWidth,items,data,sX){ + (sX===void 0)&& (sX=0); + var dL=0,dR=0; + if (data){ + if (data.dL) + dL=data.dL; + if (data.dR) + dR=data.dR; + }; + var item; + var i=0,len=0; + len=items.length; + for (i=0;i < len;i++){ + item=items[i]; + item.x=sX+dL; + item.width=totalWidth-dL-dR; + } + } + + LayoutFuns.getFullFillLayout=function(items,dL,dR){ + (dL===void 0)&& (dL=0); + (dR===void 0)&& (dR=0); + var data; + data={}; + data.dL=dL; + data.dR=dR; + return LayoutFuns.getLayouter(items,data,laya.debug.tools.layout.LayoutFuns.fullFill); + } + + LayoutFuns.fixPos=function(totalWidth,items,data,sX){ + (sX===void 0)&& (sX=0); + var dLen=0; + var poss=[]; + var isRate=false; + if (data){ + if (data.dLen) + dLen=data.dLen; + if (data.poss) + poss=data.poss; + if (data.isRate) + isRate=data.isRate; + }; + var item; + var i=0,len=0; + len=poss.length; + var tX=NaN; + tX=sX; + var tValue=NaN; + var preItem; + preItem=null; + for (i=0;i < len;i++){ + item=items[i]; + tValue=sX+poss[i]; + if (isRate){ + tValue=sX+poss[i] *totalWidth; + } + item.x=tValue; + if (preItem){ + preItem.width=item.x-dLen-preItem.x; + } + preItem=item; + }; + var lastItem; + lastItem=items[items.length-1]; + lastItem.width=sX+totalWidth-dLen-lastItem.x; + } + + LayoutFuns.getFixPos=function(items,dLen,isRate,poss){ + (dLen===void 0)&& (dLen=0); + (isRate===void 0)&& (isRate=false); + var data; + data={}; + var layout; + layout=LayoutFuns.getLayouter(items,data,LayoutFuns.fixPos); + var i=0,len=0; + var sX=NaN; + var totalWidth=NaN; + sX=layout.x; + totalWidth=layout.width; + if (!poss){ + poss=[]; + len=items.length; + var tValue=NaN; + for (i=0;i < len;i++){ + tValue=items[i].x-sX; + if (isRate){ + tValue=tValue / totalWidth; + } + else{ + } + poss.push(tValue); + } + } + data.dLen=dLen; + data.poss=poss; + data.isRate=isRate; + return layout; + } + + LayoutFuns.clearItemsRelativeInfo=function(items){ + var i=0,len=0; + len=items.length; + for (i=0;i < len;i++){ + LayoutFuns.clearItemRelativeInfo(items[i]); + } + } + + LayoutFuns.clearItemRelativeInfo=function(item){ + var Nan="NaN"; + item.getLayout().left=Nan; + item.getLayout().right=Nan; + } + + LayoutFuns.prepareForLayoutWidth=function(totalWidth,items){ + var i=0,len=0; + len=items.length; + for (i=0;i < len;i++){ + LayoutFuns.prepareItemForLayoutWidth(totalWidth,items[i]); + } + } + + LayoutFuns.getSumWidth=function(items){ + var sum=NaN; + sum=0; + var i=0,len=0; + len=items.length; + for (i=0;i < len;i++){ + sum+=items[i].width; + } + return sum; + } + + LayoutFuns.prepareItemForLayoutWidth=function(totalWidth,item){ + if (LayoutFuns.getItemRate(item)> 0){ + item.width=totalWidth *LayoutFuns.getItemRate(item); + } + } + + LayoutFuns.setItemRate=function(item,rate){ + item["layoutRate"]=rate; + } + + LayoutFuns.getItemRate=function(item){ + return item["layoutRate"] ? item["layoutRate"] :-1; + } + + LayoutFuns.setItemFreeSize=function(item,free){ + (free===void 0)&& (free=true); + item["layoutFreeSize"]=free; + } + + LayoutFuns.isItemFreeSize=function(item){ + return item["layoutFreeSize"]; + } + + LayoutFuns.lockedDis=function(totalWidth,items,data,sX){ + (sX===void 0)&& (sX=0); + var dists; + dists=data.dists; + var sumDis=NaN; + sumDis=data.sumDis; + var sumWidth=NaN; + var i=0,len=0; + var tItem; + var preItem; + LayoutFuns.prepareForLayoutWidth(totalWidth,items); + sumWidth=LayoutFuns.getSumWidth(items); + var dWidth=NaN; + dWidth=totalWidth-sumDis-sumWidth; + var freeItem; + freeItem=LayoutFuns.getFreeItem(items); + if(freeItem){ + freeItem.width+=dWidth; + } + preItem=items[0]; + preItem.x=sX; + len=items.length; + for(i=1;i maxHeight){ + maxHeight=tItem.height; + } + tCount++; + if (tCount >=xCount){ + tCount=tCount % xCount; + tItem.y+=maxHeight+dY; + maxHeight=0; + }else{ + tX+=tItem.width+dx; + } + } + } + + LayoutTools.layoutToWidth=function(items,width,dX,dY,sx,sy){ + var tX=NaN,tY=NaN; + var tItem; + var i=0,len=0; + tX=sx; + tY=sy; + len=items.length; + for(i=0;iwidth){ + tX=sx; + tY+=dY+tItem.height; + }else{ + } + tItem.x=tX; + tItem.y=tY; + tX+=dX+tItem.width; + } + } + + return LayoutTools; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.MathTools + var MathTools=(function(){ + function MathTools(){} + __class(MathTools,'laya.debug.tools.MathTools'); + MathTools.sortBigFirst=function(a,b){ + if (a==b) + return 0; + return b > a ? 1 :-1; + } + + MathTools.sortSmallFirst=function(a,b){ + if (a==b) + return 0; + return b > a ?-1 :1; + } + + MathTools.sortNumBigFirst=function(a,b){ + return parseFloat(b)-parseFloat(a); + } + + MathTools.sortNumSmallFirst=function(a,b){ + return parseFloat(a)-parseFloat(b); + } + + MathTools.sortByKey=function(key,bigFirst,forceNum){ + (bigFirst===void 0)&& (bigFirst=false); + (forceNum===void 0)&& (forceNum=true); + var _sortFun; + if (bigFirst){ + _sortFun=forceNum ? MathTools.sortNumBigFirst :MathTools.sortBigFirst; + }else { + _sortFun=forceNum ? MathTools.sortNumSmallFirst :MathTools.sortSmallFirst; + } + return function (a,b){ + return _sortFun(a[key],b[key]); + }; + } + + return MathTools; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.MouseEventAnalyser + var MouseEventAnalyser=(function(){ + function MouseEventAnalyser(){} + __class(MouseEventAnalyser,'laya.debug.tools.MouseEventAnalyser'); + MouseEventAnalyser.analyseNode=function(node){ + DebugTool.showDisBound(node,true); + var _node; + _node=node; + ObjectTools.clearObj(MouseEventAnalyser.infoO); + ObjectTools.clearObj(MouseEventAnalyser.nodeO); + ObjectTools.clearObj(MouseEventAnalyser.hitO); + var nodeList; + nodeList=[]; + while (node){ + IDTools.idObj(node); + MouseEventAnalyser.nodeO[IDTools.getObjID(node)]=node; + nodeList.push(node); + node=node.parent; + } + MouseEventAnalyser.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null); + var canStr; + if (MouseEventAnalyser.hitO[IDTools.getObjID(_node)]){ + console.log("can hit"); + canStr="can hit"; + } + else{ + console.log("can't hit"); + canStr="can't hit"; + }; + var i=0,len=0; + nodeList=nodeList.reverse(); + len=nodeList.length; + var rstTxts; + rstTxts=["[分析对象]:"+ClassTool.getNodeClassAndName(_node)+":"+canStr]; + for (i=0;i < len;i++){ + node=nodeList[i]; + if (MouseEventAnalyser.hitO[IDTools.getObjID(node)]){ + console.log("can hit:",ClassTool.getNodeClassAndName(node)); + console.log("原因:",MouseEventAnalyser.infoO[IDTools.getObjID(node)]); + rstTxts.push("can hit:"+" "+ClassTool.getNodeClassAndName(node)); + rstTxts.push("原因:"+" "+MouseEventAnalyser.infoO[IDTools.getObjID(node)]); + } + else{ + console.log("can't hit:"+ClassTool.getNodeClassAndName(node)); + console.log("原因:",MouseEventAnalyser.infoO[IDTools.getObjID(node)] ? MouseEventAnalyser.infoO[IDTools.getObjID(node)] :"鼠标事件在父级已停止派发"); + rstTxts.push("can't hit:"+" "+ClassTool.getNodeClassAndName(node)); + rstTxts.push("原因:"+" "+(MouseEventAnalyser.infoO[IDTools.getObjID(node)] ? MouseEventAnalyser.infoO[IDTools.getObjID(node)] :"鼠标事件在父级已停止派发")); + } + }; + var rstStr; + rstStr=rstTxts.join("\n"); + ToolPanel.I.showTxtInfo(rstStr); + } + + MouseEventAnalyser.check=function(sp,mouseX,mouseY,callBack){ + IDTools.idObj(sp); + var isInAnlyseChain=false; + isInAnlyseChain=MouseEventAnalyser.nodeO[IDTools.getObjID(sp)]; + var transform=sp.transform || MouseEventAnalyser._matrix; + var pivotX=sp.pivotX; + var pivotY=sp.pivotY; + if (pivotX===0 && pivotY===0){ + transform.setTranslate(sp.x,sp.y); + } + else{ + if (transform===MouseEventAnalyser._matrix){ + transform.setTranslate(sp.x-pivotX,sp.y-pivotY); + } + else{ + var cos=transform.cos; + var sin=transform.sin; + transform.setTranslate(sp.x-(pivotX *cos-pivotY *sin)*sp.scaleX,sp.y-(pivotX *sin+pivotY *cos)*sp.scaleY); + } + } + transform.invertTransformPoint(MouseEventAnalyser._point.setTo(mouseX,mouseY)); + transform.setTranslate(0,0); + mouseX=MouseEventAnalyser._point.x; + mouseY=MouseEventAnalyser._point.y; + var scrollRect=sp.scrollRect; + if (scrollRect){ + MouseEventAnalyser._rect.setTo(0,0,scrollRect.width,scrollRect.height); + var isHit=MouseEventAnalyser._rect.contains(mouseX,mouseY); + if (!isHit){ + if (isInAnlyseChain){ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="scrollRect没有包含鼠标"+MouseEventAnalyser._rect.toString()+":"+mouseX+","+mouseY; + } + return false; + } + }; + var i=0,len=0; + var cList; + cList=sp._childs; + len=cList.length; + var child; + var childInChain; + childInChain=null; + for (i=0;i < len;i++){ + child=cList[i]; + IDTools.idObj(child); + if (MouseEventAnalyser.nodeO[IDTools.getObjID(child)]){ + childInChain=child; + break ; + } + }; + var coverByOthers=false; + coverByOthers=childInChain ? true :false; + var flag=false; + if (sp.hitTestPrior && !sp.mouseThrough && !MouseEventAnalyser.hitTest(sp,mouseX,mouseY)){ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="hitTestPrior=true,宽高区域不包含鼠标:"+":"+mouseX+","+mouseY+" size:"+sp.width+","+sp.height; + return false; + } + for (i=sp._childs.length-1;i >-1;i--){ + child=sp._childs[i]; + if (child==childInChain){ + if (!childInChain.mouseEnabled){ + MouseEventAnalyser.infoO[IDTools.getObjID(childInChain)]="mouseEnabled=false"; + } + if (!childInChain.visible){ + MouseEventAnalyser.infoO[IDTools.getObjID(childInChain)]="visible=false"; + } + coverByOthers=false; + } + if (child.mouseEnabled && child.visible){ + flag=MouseEventAnalyser.check(child,mouseX+(scrollRect ? scrollRect.x :0),mouseY+(scrollRect ? scrollRect.y :0),callBack); + if (flag){ + MouseEventAnalyser.hitO[IDTools.getObjID(sp)]=true; + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="子对象被击中"; + if (child==childInChain){ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="子对象被击中,"+"击中对象在分析链中"; + } + else{ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="子对象被击中,"+"击中对象不在分析链中"; + if (coverByOthers){ + MouseEventAnalyser.infoO[IDTools.getObjID(childInChain)]="被兄弟节点挡住,兄弟节点信息:"+ClassTool.getNodeClassAndName(child)+","+child.getBounds().toString(); + DebugTool.showDisBound(child,false,"#ffff00"); + } + } + return true; + } + else{ + if (child==childInChain){ + coverByOthers=false; + } + } + } + }; + var mHitRect=new Rectangle(); + var graphicHit=false; + graphicHit=sp.getGraphicBounds().contains(mouseX,mouseY); + if (sp.width > 0 && sp.height > 0){ + var hitRect=MouseEventAnalyser._rect; + if (!sp.mouseThrough){ + if (sp.hitArea) + hitRect=sp.hitArea; + else + hitRect.setTo(0,0,sp.width,sp.height); + mHitRect.copyFrom(hitRect); + isHit=hitRect.contains(mouseX,mouseY); + } + else{ + isHit=graphicHit; + mHitRect.copyFrom(sp.getGraphicBounds()); + } + if (isHit){ + MouseEventAnalyser.hitO[IDTools.getObjID(sp)]=true; + } + }else{ + } + if (!isHit){ + if (graphicHit){ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="子对象未包含鼠标,实际绘图区域包含鼠标,设置的宽高区域不包含鼠标:"+":"+mouseX+","+mouseY+" hitRec:"+mHitRect.toString()+" graphicBounds:"+sp.getGraphicBounds().toString()+",设置mouseThrough=true或将宽高设置到实际绘图区域可解决问题"; + }else{ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="子对象未包含鼠标,实际绘图区域不包含鼠标,设置的宽高区域不包含鼠标:"+":"+mouseX+","+mouseY+" hitRec:"+mHitRect.toString()+" graphicBounds:"+sp.getGraphicBounds().toString(); + } + } + else{ + MouseEventAnalyser.infoO[IDTools.getObjID(sp)]="自身区域被击中"; + } + return isHit; + } + + MouseEventAnalyser.hitTest=function(sp,mouseX,mouseY){ + var isHit=false; + if (sp.width > 0 && sp.height > 0 || sp.mouseThrough || sp.hitArea){ + var hitRect=MouseEventAnalyser._rect; + if (!sp.mouseThrough){ + if (sp.hitArea)hitRect=sp.hitArea; + else hitRect.setTo(0,0,sp.width,sp.height); + isHit=hitRect.contains(mouseX,mouseY); + }else { + isHit=sp.getGraphicBounds().contains(mouseX,mouseY); + } + } + return isHit; + } + + MouseEventAnalyser.infoO={}; + MouseEventAnalyser.nodeO={}; + MouseEventAnalyser.hitO={}; + __static(MouseEventAnalyser, + ['_matrix',function(){return this._matrix=new Matrix();},'_point',function(){return this._point=new Point();},'_rect',function(){return this._rect=new Rectangle();} + ]); + return MouseEventAnalyser; + })() + + + /** + *本类提供obj相关的一些操作 + *@author ww + *@version 1.0 + * + *@created 2015-10-21 下午2:03:36 + */ + //class laya.debug.tools.ObjectTools + var ObjectTools=(function(){ + function ObjectTools(){} + __class(ObjectTools,'laya.debug.tools.ObjectTools'); + ObjectTools.getFlatKey=function(tKey,aKey){ + if(tKey=="")return aKey; + return tKey+ObjectTools.sign+aKey; + } + + ObjectTools.flatObj=function(obj,rst,tKey){ + (tKey===void 0)&& (tKey=""); + rst=rst?rst:{}; + var key; + var tValue; + for(key in obj){ + if((typeof (obj[key])=='object')){ + ObjectTools.flatObj(obj[key],rst,ObjectTools.getFlatKey(tKey,key)); + }else{ + tValue=obj[key]; + rst[ObjectTools.getFlatKey(tKey,key)]=obj[key]; + } + } + return rst; + } + + ObjectTools.recoverObj=function(obj){ + var rst={}; + var tKey; + for(tKey in obj){ + ObjectTools.setKeyValue(rst,tKey,obj[tKey]); + } + return rst; + } + + ObjectTools.differ=function(objA,objB){ + var tKey; + var valueA; + var valueB; + objA=ObjectTools.flatObj(objA); + objB=ObjectTools.flatObj(objB); + var rst={}; + for(tKey in objA){ + if(!objB.hasOwnProperty(tKey)){ + rst[tKey]="被删除"; + } + } + for(tKey in objB){ + if(objB[tKey]!=objA[tKey]){ + rst[tKey]={"pre":objA[tKey],"now":objB[tKey]}; + } + } + return rst; + } + + ObjectTools.traceDifferObj=function(obj){ + var key; + var tO; + for(key in obj){ + if((typeof (obj[key])=='string')){ + console.log(key+":",obj[key]); + }else{ + tO=obj[key]; + console.log(key+":","now:",tO["now"],"pre:",tO["pre"]); + } + } + } + + ObjectTools.setKeyValue=function(obj,flatKey,value){ + if(flatKey.indexOf(ObjectTools.sign)>=0){ + var keys=flatKey.split(ObjectTools.sign); + var tKey; + while(keys.length>1){ + tKey=keys.shift(); + if(!obj[tKey]){ + obj[tKey]={}; + console.log("addKeyObj:",tKey); + } + obj=obj[tKey]; + if(!obj){ + console.log("wrong flatKey:",flatKey); + return; + } + } + obj[keys.shift()]=value; + }else{ + obj[flatKey]=value; + } + } + + ObjectTools.clearObj=function(obj){ + var key; + for (key in obj){ + delete obj[key]; + } + } + + ObjectTools.copyObjFast=function(obj){ + var jsStr; + jsStr=laya.debug.tools.ObjectTools.getJsonString(obj); + return laya.debug.tools.ObjectTools.getObj(jsStr); + } + + ObjectTools.copyObj=function(obj){ + if((obj instanceof Array))return ObjectTools.copyArr(obj); + var rst={}; + var key; + for(key in obj){ + if(((obj[key])instanceof Array)){ + rst[key]=ObjectTools.copyArr(obj[key]); + } + else + if((typeof (obj[key])=='object')){ + rst[key]=ObjectTools.copyObj(obj[key]); + }else{ + rst[key]=obj[key]; + } + } + return rst; + } + + ObjectTools.copyArr=function(arr){ + var rst; + rst=[]; + var i=0,len=0; + len=arr.length; + for(i=0;i minWidth?tWidth:minWidth; + tar.height=tHeight>minHeight?tHeight:minHeight; + } + + SimpleResizer.onMouseMoveEnd=function(e){ + SimpleResizer.clearEvents(); + } + + SimpleResizer.clearEvents=function(){ + Laya.timer.clear(null,SimpleResizer.onMouseMoving); + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",null,SimpleResizer.onMouseMoveEnd); + } + + __static(SimpleResizer, + ['preMousePoint',function(){return this.preMousePoint=new Point();},'preTarSize',function(){return this.preTarSize=new Point();},'preScale',function(){return this.preScale=new Point();} + ]); + return SimpleResizer; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.tools.ResTools + var ResTools=(function(){ + function ResTools(){} + __class(ResTools,'laya.debug.tools.ResTools'); + ResTools.getCachedResList=function(){ + if (Render.isWebGL){ + return ResTools.getWebGlResList(); + }else{ + return ResTools.getCanvasResList(); + } + } + + ResTools.getWebGlResList=function(){ + var rst; + rst=[]; + var tResource; + var _resources; + _resources=ResourceManager.currentResourceManager["_resources"]; + for(var i=0;i <_resources.length;i++){ + tResource=_resources[i]; + if(ClassTool.getClassName(tResource)=="WebGLImage"){ + var url=tResource["src"]; + if(url&&url.indexOf("data:image/png;base64")<0) + rst.push(url); + } + } + return rst; + } + + ResTools.getCanvasResList=function(){ + var picDic; + picDic={}; + var dataO; + dataO=Loader.loadedMap; + ResTools.collectPics(dataO,picDic); + return ResTools.getArrFromDic(picDic); + } + + ResTools.getArrFromDic=function(dic){ + var key; + var rst; + rst=[]; + for (key in dic){ + rst.push(key); + } + return rst; + } + + ResTools.collectPics=function(dataO,picDic){ + if (!dataO)return; + var key; + var tTexture; + for (key in dataO){ + tTexture=dataO[key]; + if (tTexture){ + if (tTexture.bitmap&&tTexture.bitmap.src){ + var url=tTexture.bitmap.src; + if(url.indexOf("data:image/png;base64")<0) + picDic[tTexture.bitmap.src]=true; + } + } + } + } + + return ResTools; + })() + + + /** + *类实例创建分析工具 + *@author ww + *@version 1.0 + * + *@created 2015-9-25 下午3:31:46 + */ + //class laya.debug.tools.RunProfile + var RunProfile=(function(){ + function RunProfile(){} + __class(RunProfile,'laya.debug.tools.RunProfile'); + RunProfile.run=function(funName,callLen){ + (callLen===void 0)&& (callLen=3); + var tCount; + if(!RunProfile.infoDic.hasOwnProperty(funName)){ + RunProfile.infoDic[funName]=new CountTool(); + } + tCount=RunProfile.infoDic[funName]; + var msg; + msg=TraceTool.getCallLoc(callLen)+"\n"+TraceTool.getCallStack(1,callLen-3); + tCount.add(msg); + if(RunProfile._runShowDic[funName]){ + console.log("Create:"+funName); + console.log(msg); + } + } + + RunProfile.showClassCreate=function(funName){ + RunProfile._runShowDic[funName]=true; + } + + RunProfile.hideClassCreate=function(funName){ + RunProfile._runShowDic[funName]=false; + } + + RunProfile.getRunInfo=function(funName){ + var rst; + rst=RunProfile.infoDic[funName]; + if(rst){ + } + return RunProfile.infoDic[funName]; + } + + RunProfile.runTest=function(fun,count,sign){ + (sign===void 0)&& (sign="runTest"); + DTrace.timeStart(sign); + var i=0; + for(i=0;i=0){ + return StringTool.insert(str,iStr,i+tarStr.length); + } + return str; + } + + StringTool.insertBefore=function(str,iStr,tarStr,isLast){ + (isLast===void 0)&& (isLast=false); + var i=0; + if(isLast){ + i=str.lastIndexOf(tarStr); + }else{ + i=str.indexOf(tarStr); + } + if(i>=0){ + return StringTool.insert(str,iStr,i); + } + return str; + } + + StringTool.insertParamToFun=function(funStr,params){ + var oldParam; + oldParam=StringTool.getParamArr(funStr); + var inserStr; + inserStr=params.join(","); + if(oldParam.length>0){ + inserStr=","+inserStr; + } + return StringTool.insertBefore(funStr,inserStr,")",true); + } + + StringTool.trim=function(str,vList){ + if(!vList){ + vList=[" ","\r","\n","\t",String.fromCharCode(65279)]; + }; + var rst; + var i=0; + var len=0; + rst=str; + len=vList.length; + for(i=0;i=0){ + i--; + }; + var rst; + rst=str.substring(0,i) + if(i>=0){ + return str.substring(0,i+1); + } + return ""; + } + + StringTool.trimSide=function(str){ + var rst; + rst=StringTool.trimLeft(str); + rst=StringTool.trimRight(rst); + return rst; + } + + StringTool.isOkFileName=function(fileName){ + if(laya.debug.tools.StringTool.trimSide(fileName)=="")return false; + var i=0,len=0; + len=fileName.length; + for(i=0;i=0;i--){ + str=strArr[i]; + str=laya.debug.tools.StringTool.trimSide(str); + if(StringTool.isEmpty(str)){ + strArr.splice(i,1); + }else{ + strArr[i]=str; + } + } + return strArr; + } + + StringTool.ifNoAddToTail=function(str,sign){ + if(str.indexOf(sign)>=0){ + return str; + } + return str+sign; + } + + StringTool.trimEmptyLine=function(str){ + var i=0; + var len=0; + var tLines; + var tLine; + tLines=str.split("\n"); + for(i=tLines.length-1;i>=0;i--){ + tLine=tLines[i]; + if(StringTool.isEmptyLine(tLine)){ + tLines.splice(i,1); + } + } + return tLines.join("\n"); + } + + StringTool.isEmptyLine=function(str){ + str=laya.debug.tools.StringTool.trim(str); + if(str=="")return true; + return false; + } + + StringTool.removeCommentLine=function(lines){ + var rst; + rst=[]; + var i=0; + var tLine; + var adptLine; + i=0; + var len=0; + var index=0; + len=lines.length; + while(i=0){ + adptLine=tLine.substring(0,index-1); + StringTool.addIfNotEmpty(rst,adptLine); + while(i=0){ + adptLine=tLine.substring(index+2); + StringTool.addIfNotEmpty(rst,adptLine); + break ; + } + i++; + } + }else if(tLine.indexOf("//")>=0){ + if(laya.debug.tools.StringTool.trim(tLine).indexOf("//")==0){ + }else{ + StringTool.addIfNotEmpty(rst,adptLine); + } + }else{ + StringTool.addIfNotEmpty(rst,adptLine); + } + i++; + } + return rst; + } + + StringTool.addIfNotEmpty=function(arr,str){ + if(!str)return; + var tStr; + tStr=StringTool.trim(str); + if(tStr!=""){ + arr.push(str); + } + } + + StringTool.trimExt=function(str,vars){ + var rst; + rst=StringTool.trim(str); + var i=0; + var len=0; + len=vars.length; + for(i=0;i0){ + if(arr[0]==""){ + arr.shift(); + }else{ + break ; + } + } + } + + StringTool.getWords=function(line){ + var rst=StringTool.getSplitLine(line); + StringTool.delelteItem(rst); + return rst; + } + + StringTool.getLinesI=function(startLine,endLine,lines){ + var i=0; + var rst=[]; + for(i=startLine;i<=endLine;i++){ + rst.push(lines[i]); + } + return rst; + } + + StringTool.structfy=function(str,inWidth,removeEmpty){ + (inWidth===void 0)&& (inWidth=4); + (removeEmpty===void 0)&& (removeEmpty=true); + if(removeEmpty){ + str=laya.debug.tools.StringTool.trimEmptyLine(str); + }; + var lines; + var tIn=0; + tIn=0; + var tInStr; + tInStr=StringTool.getEmptyStr(0); + lines=str.split("\n"); + var i=0; + var len=0; + var tLineStr; + len=lines.length; + for(i=0;i=0){ + tInStr=StringTool.getEmptyStr(tIn*inWidth); + } + tLineStr=tInStr+tLineStr; + lines[i]=tLineStr; + tInStr=StringTool.getEmptyStr(tIn*inWidth); + } + return lines.join("\n"); + } + + StringTool.getEmptyStr=function(width){ + if(!StringTool.emptyDic.hasOwnProperty(width)){ + var i=0; + var len=0; + len=width; + var rst; + rst=""; + for(i=0;i0||tC=="0"){ + rst=10*rst+Number(tC); + if(rst>0)isBegin=true; + }else{ + if(isBegin)return rst; + } + } + return rst; + } + + StringTool.getReplace=function(str,oStr,nStr){ + if(!str)return ""; + var rst; + rst=str.replace(new RegExp(oStr,"g"),nStr); + return rst; + } + + StringTool.getWordCount=function(str,findWord){ + var rg=new RegExp(findWord,"g") + return str.match(rg).length; + } + + StringTool.getResolvePath=function(path,basePath){ + if(StringTool.isAbsPath(path)){ + return path; + }; + var tSign; + tSign="\\"; + if(basePath.indexOf("/")>=0){ + tSign="/"; + } + if(basePath.charAt(basePath.length-1)==tSign){ + basePath=basePath.substr(0,basePath.length-1); + }; + var parentSign; + parentSign=".."+tSign; + var tISign; + tISign="."+tSign; + var pCount=0; + pCount=StringTool.getWordCount(path,parentSign); + path=laya.debug.tools.StringTool.getReplace(path,parentSign,""); + path=laya.debug.tools.StringTool.getReplace(path,tISign,""); + var i=0; + var len=0; + len=pCount; + var iPos=0; + for(i=0;i=0)return true; + return false; + } + + StringTool.removeLastSign=function(str,sign){ + var iPos=0; + iPos=str.lastIndexOf(sign); + str=str.substring(0,iPos); + return str; + } + + StringTool.getParamArr=function(str){ + var paramStr; + paramStr=laya.debug.tools.StringTool.getBetween(str,"(",")",true); + if(StringTool.trim(paramStr).length<1)return []; + return paramStr.split(","); + } + + StringTool.copyStr=function(str){ + return str.substring(); + } + + StringTool.ArrayToString=function(arr){ + var rst; + rst="[{items}]".replace(new RegExp("\\{items\\}","g"),StringTool.getArrayItems(arr)); + return rst; + } + + StringTool.getArrayItems=function(arr){ + var rst; + if(arr.length<1)return ""; + rst=StringTool.parseItem(arr[0]); + var i=0; + var len=0; + len=arr.length; + for(i=1;i0){ + if(s<=0){ + msg+=caller+"<-"; + life--; + }else{ + } + caller=caller.caller; + s--; + } + return msg; + } + + TraceTool.getCallLoc=function(index){ + (index===void 0)&& (index=2); + var loc; + try { + TraceTool.Erroer.i++; + }catch (e){ + var arr; + arr=e.stack.replace(/Error\n/).split(/\n/); + if (arr[index]){ + loc=arr[index].replace(/^\s+|\s+$/,""); + }else{ + loc="unknow"; + } + } + return loc; + } + + TraceTool.traceCallStack=function(){ + var loc; + try { + TraceTool.Erroer.i++; + }catch (e){ + loc=e.stack; + } + console.log(loc); + return loc; + } + + TraceTool.getPlaceHolder=function(len){ + if(!TraceTool.holderDic.hasOwnProperty(len)){ + var rst; + rst=""; + var i=0; + for(i=0;i 0 && visibleRec.height > 0){ + isInVisibleRec=true; + } + else{ + isInVisibleRec=false; + }; + var gAlpha=NaN; + gAlpha=NodeUtils.getGAlpha(node); + var gVisible=false; + gVisible=NodeUtils.getGVisible(node); + var msg; + msg=""; + msg+="isInstage:"+isInstage+"\n"; + msg+="isInVisibleRec:"+isInVisibleRec+"\n"; + msg+="gVisible:"+gVisible+"\n"; + msg+="gAlpha:"+gAlpha+"\n"; + if (isInstage && isInVisibleRec && gVisible && gAlpha > 0){ + if (Render.isWebGL){ + VisibleAnalyser.anlyseRecVisible(node); + }else{ + SpriteRenderForVisibleAnalyse.I.analyseNode(node); + } + msg+="coverRate:"+VisibleAnalyser.coverRate+"\n"; + if (VisibleAnalyser._coverList.length > 0){ + Laya.timer.once(1000,null,VisibleAnalyser.showListLater); + } + } + console.log(msg); + OutPutView.I.showTxt(msg); + } + + VisibleAnalyser.showListLater=function(){ + NodeListPanelView.I.showList(VisibleAnalyser._coverList); + } + + VisibleAnalyser.isCoverByBrother=function(node){ + var parent=node.parent; + if (!parent) + return; + var _childs; + _childs=parent._childs; + var index=0; + index=_childs.indexOf(node); + if (index < 0) + return; + var i=0,len=0; + var canvas; + var rec; + rec=parent.getSelfBounds(); + if (rec.width <=0 || rec.height <=0) + return; + } + + VisibleAnalyser.anlyseRecVisible=function(node){ + VisibleAnalyser.isNodeWalked=false; + VisibleAnalyser._analyseTarget=node; + if (!VisibleAnalyser.mainCanvas) + VisibleAnalyser.mainCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height); + CanvasTools.clearCanvas(VisibleAnalyser.mainCanvas); + VisibleAnalyser.tColor=1; + VisibleAnalyser.resetCoverList(); + WalkTools.walkTargetEX(Laya.stage,VisibleAnalyser.recVisibleWalker,null,VisibleAnalyser.filterFun); + if (!VisibleAnalyser.isTarRecOK){ + VisibleAnalyser.coverRate=0; + } + else{ + VisibleAnalyser.coverRate=CanvasTools.getDifferRate(VisibleAnalyser.preImageData,VisibleAnalyser.tarImageData); + } + console.log("coverRate:",VisibleAnalyser.coverRate); + } + + VisibleAnalyser.getRecArea=function(rec){ + return rec.width *rec.height; + } + + VisibleAnalyser.addCoverNode=function(node,coverRate){ + var data; + data={}; + data.path=node; + data.label=ClassTool.getNodeClassAndName(node)+":"+coverRate; + data.coverRate=coverRate; + VisibleAnalyser._coverList.push(data); + console.log("coverByNode:",node,coverRate); + } + + VisibleAnalyser.resetCoverList=function(){ + VisibleAnalyser._coverList.length=0; + } + + VisibleAnalyser.recVisibleWalker=function(node){ + if (node==VisibleAnalyser._analyseTarget){ + VisibleAnalyser.isNodeWalked=true; + VisibleAnalyser.tarRec.copyFrom(NodeUtils.getGRec(node)); + console.log("tarRec:",VisibleAnalyser.tarRec.toString()); + if (VisibleAnalyser.tarRec.width > 0 && VisibleAnalyser.tarRec.height > 0){ + VisibleAnalyser.isTarRecOK=true; + VisibleAnalyser.tColor++; + CanvasTools.fillCanvasRec(VisibleAnalyser.mainCanvas,VisibleAnalyser.tarRec,ColorTool.toHexColor(VisibleAnalyser.tColor)); + VisibleAnalyser.preImageData=CanvasTools.getImageDataFromCanvasByRec(VisibleAnalyser.mainCanvas,VisibleAnalyser.tarRec); + VisibleAnalyser.tarImageData=CanvasTools.getImageDataFromCanvasByRec(VisibleAnalyser.mainCanvas,VisibleAnalyser.tarRec); + } + else{ + console.log("tarRec Not OK:",VisibleAnalyser.tarRec); + } + } + else{ + if (VisibleAnalyser.isTarRecOK){ + var tRec; + tRec=NodeUtils.getGRec(node); + VisibleAnalyser.interRec=VisibleAnalyser.tarRec.intersection(tRec,VisibleAnalyser.interRec); + if (VisibleAnalyser.interRec && VisibleAnalyser.interRec.width > 0 && VisibleAnalyser.interRec.height > 0){ + VisibleAnalyser.tColor++; + CanvasTools.fillCanvasRec(VisibleAnalyser.mainCanvas,tRec,ColorTool.toHexColor(VisibleAnalyser.tColor)); + VisibleAnalyser.tImageData=CanvasTools.getImageDataFromCanvasByRec(VisibleAnalyser.mainCanvas,VisibleAnalyser.tarRec); + var dRate=NaN; + dRate=CanvasTools.getDifferRate(VisibleAnalyser.preImageData,VisibleAnalyser.tImageData); + VisibleAnalyser.preImageData=VisibleAnalyser.tImageData; + VisibleAnalyser.addCoverNode(node,dRate); + } + } + } + } + + VisibleAnalyser.filterFun=function(node){ + if (node.visible==false) + return false; + if (node.alpha < 0) + return false; + if (DebugInfoLayer.I.isDebugItem(node))return false; + return true; + } + + VisibleAnalyser.isNodeWalked=false; + VisibleAnalyser._analyseTarget=null + VisibleAnalyser.isTarRecOK=false; + VisibleAnalyser.mainCanvas=null + VisibleAnalyser.preImageData=null + VisibleAnalyser.tImageData=null + VisibleAnalyser.tarImageData=null + VisibleAnalyser.coverRate=NaN + VisibleAnalyser.tColor=0; + VisibleAnalyser._coverList=[]; + __static(VisibleAnalyser, + ['tarRec',function(){return this.tarRec=new Rectangle();},'interRec',function(){return this.interRec=new Rectangle();} + ]); + return VisibleAnalyser; + })() + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-24 下午6:15:01 + */ + //class laya.debug.tools.WalkTools + var WalkTools=(function(){ + function WalkTools(){} + __class(WalkTools,'laya.debug.tools.WalkTools'); + WalkTools.walkTarget=function(target,fun,_this){ + fun.apply(_this,[target]); + var i=0; + var len=0; + var tChild; + len=target.numChildren; + for(i=0;i 0; + return rst; + } + + NodeUtils.adptShowKeys=function(keys){ + var i=0,len=0; + len=keys.length; + for (i=len-1;i >=0;i--){ + keys[i]=StringTool.trimSide(keys[i]); + if (keys[i].length < 1){ + keys.splice(i,1); + } + } + return keys; + } + + NodeUtils.getNodeTreeData=function(sprite,keys){ + NodeUtils.adptShowKeys(keys); + var treeO; + treeO=NodeUtils.getPropertyDesO(sprite,keys); + var treeArr; + treeArr=[]; + NodeUtils.getTreeArr(treeO,treeArr); + return treeArr; + } + + NodeUtils.getTreeArr=function(treeO,arr,add){ + (add===void 0)&& (add=true); + if (add) + arr.push(treeO); + var tArr=treeO.childs; + var i=0,len=tArr.length; + for (i=0;i < len;i++){ + if (!add){ + tArr[i].nodeParent=null; + } + else{ + tArr[i].nodeParent=treeO; + } + if (tArr[i].isDirectory){ + NodeUtils.getTreeArr(tArr[i],arr); + } + else{ + arr.push(tArr[i]); + } + } + } + + NodeUtils.traceStage=function(){ + console.log(NodeUtils.getFilterdTree(Laya.stage,null)); + console.log("treeArr:",NodeUtils.getNodeTreeData(Laya.stage,null)); + } + + NodeUtils.getNodeCount=function(node,visibleRequire){ + (visibleRequire===void 0)&& (visibleRequire=false); + if (visibleRequire){ + if (!node.visible)return 0; + }; + var rst=0; + rst=1; + var i=0,len=0; + var cList; + cList=node._childs; + len=cList.length; + for (i=0;i < len;i++){ + rst+=NodeUtils.getNodeCount(cList[i],visibleRequire); + } + return rst; + } + + NodeUtils.getGVisible=function(node){ + while (node){ + if (!node.visible)return false; + node=node.parent; + } + return true; + } + + NodeUtils.getGAlpha=function(node){ + var rst=NaN; + rst=1; + while (node){ + rst *=node.alpha; + node=node.parent; + } + return rst; + } + + NodeUtils.getGPos=function(node){ + var point; + point=new Point(); + node.localToGlobal(point); + return point; + } + + NodeUtils.getGRec=function(node){ + var pointList; + pointList=node._getBoundPointsM(true); + if (!pointList || pointList.length < 1) + return Rectangle.TEMP.setTo(0,0,0,0); + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,node.localToGlobal,node); + pointList=GrahamScan.pointListToPlist(pointList); + var _disBoundRec; + _disBoundRec=Rectangle._getWrapRec(pointList,_disBoundRec); + return _disBoundRec; + } + + NodeUtils.getGGraphicRec=function(node){ + var pointList; + pointList=node.getGraphicBounds()._getBoundPoints(); + if (!pointList || pointList.length < 1) + return Rectangle.TEMP.setTo(0,0,0,0); + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,node.localToGlobal,node); + pointList=GrahamScan.pointListToPlist(pointList); + var _disBoundRec; + _disBoundRec=Rectangle._getWrapRec(pointList,_disBoundRec); + return _disBoundRec; + } + + NodeUtils.getNodeCmdCount=function(node){ + var rst=0; + if (node.graphics){ + if (node.graphics.cmds){ + rst=node.graphics.cmds.length; + } + else{ + if (node.graphics._one){ + rst=1; + } + else{ + rst=0; + } + } + } + else{ + rst=0; + } + return rst; + } + + NodeUtils.getNodeCmdTotalCount=function(node){ + var rst=0; + var i=0,len=0; + var cList; + cList=node._childs; + len=cList.length; + rst=NodeUtils.getNodeCmdCount(node); + for (i=0;i < len;i++){ + rst+=NodeUtils.getNodeCmdTotalCount(cList[i]); + } + return rst; + } + + NodeUtils.getRenderNodeCount=function(node){ + if (node.cacheAs !="none")return 1; + var rst=0; + var i=0,len=0; + var cList; + cList=node._childs; + len=cList.length; + rst=1; + for (i=0;i < len;i++){ + rst+=NodeUtils.getRenderNodeCount(cList[i]); + } + return rst; + } + + NodeUtils.getReFreshRenderNodeCount=function(node){ + var rst=0; + var i=0,len=0; + var cList; + cList=node._childs; + len=cList.length; + rst=1; + for (i=0;i < len;i++){ + rst+=NodeUtils.getRenderNodeCount(cList[i]); + } + return rst; + } + + NodeUtils.showCachedSpriteRecs=function(){ + NodeUtils.g=DebugInfoLayer.I.graphicLayer.graphics; + NodeUtils.g.clear(); + WalkTools.walkTarget(Laya.stage,NodeUtils.drawCachedBounds,null); + } + + NodeUtils.drawCachedBounds=function(sprite){ + if (sprite.cacheAs=="none")return; + if (DebugInfoLayer.I.isDebugItem(sprite))return; + var rec; + rec=NodeUtils.getGRec(sprite); + NodeUtils.g.drawRect(rec.x,rec.y,rec.width,rec.height,null,"#0000ff",2); + } + + NodeUtils.g=null + __static(NodeUtils, + ['defaultKeys',function(){return this.defaultKeys=["x","y","width","height"];} + ]); + return NodeUtils; + })() + + + /** + *... + *@author ww + */ + //class laya.debug.view.StyleConsts + var StyleConsts=(function(){ + function StyleConsts(){} + __class(StyleConsts,'laya.debug.view.StyleConsts'); + StyleConsts.setViewScale=function(view){ + view.scaleX=view.scaleY=StyleConsts.PanelScale; + } + + __static(StyleConsts, + ['PanelScale',function(){return this.PanelScale=Browser.onPC?1:Browser.pixelRatio;} + ]); + return StyleConsts; + })() + + + /** + *本类用于模块间消息传递 + *@author ww + */ + //class laya.debug.tools.Notice extends laya.events.EventDispatcher + var Notice=(function(_super){ + function Notice(){ + Notice.__super.call(this); + } + + __class(Notice,'laya.debug.tools.Notice',_super); + Notice.notify=function(type,data){ + Notice.I.event(type,data); + } + + Notice.listen=function(type,_scope,fun,args,cancelBefore){ + (cancelBefore===void 0)&& (cancelBefore=false); + if(cancelBefore)Notice.cancel(type,_scope,fun); + Notice.I.on(type,_scope,fun,args); + } + + Notice.cancel=function(type,_scope,fun){ + Notice.I.off(type,_scope,fun); + } + + __static(Notice, + ['I',function(){return this.I=new Notice();} + ]); + return Notice; + })(EventDispatcher) + + + /** + *... + *@author ww + */ + //class laya.debug.tools.enginehook.LoaderHook extends laya.net.LoaderManager + var LoaderHook=(function(_super){ + function LoaderHook(){ + LoaderHook.__super.call(this); + } + + __class(LoaderHook,'laya.debug.tools.enginehook.LoaderHook',_super); + var __proto=LoaderHook.prototype; + __proto.checkUrls=function(url){ + var tarUrl; + if ((typeof url=='string')){ + tarUrl=url; + }else{ + tarUrl=url.url; + } + if (LoaderHook.preFails[tarUrl]){ + if (LoaderHook.enableFailDebugger){ + debugger; + } + } + } + + __proto.chekUrlList=function(urls){ + var i=0,len=0; + len=urls.length; + for (i=0;i < len;i++){ + this.checkUrls(urls[i]); + } + } + + __proto.load=function(url,complete,progress,type,priority,cache,group,ignoreCache){ + (priority===void 0)&& (priority=1); + (cache===void 0)&& (cache=true); + (ignoreCache===void 0)&& (ignoreCache=false); + if ((url instanceof Array)){ + this.chekUrlList(url); + }else{ + this.checkUrls(url); + } + return _super.prototype.load.call(this,url,complete,progress,type,priority,cache,group,ignoreCache); + } + + LoaderHook.init=function(){ + Laya.loader=new LoaderHook(); + Laya.loader.on(/*laya.events.Event.ERROR*/"error",null,LoaderHook.onFail); + LoaderHook.preFails=LocalStorage.getJSON("LoadFailItems"); + if (!LoaderHook.preFails)LoaderHook.preFails={}; + } + + LoaderHook.onFail=function(failFile){ + OutPutView.I.dTrace("LoadFail:"+failFile); + LoaderHook.nowFails[failFile]=true; + LocalStorage.setJSON("LoadFailItems",LoaderHook.nowFails); + } + + LoaderHook.resetFails=function(){ + LoaderHook.nowFails={}; + LocalStorage.setJSON("LoadFailItems",LoaderHook.nowFails); + } + + LoaderHook.preFails={}; + LoaderHook.nowFails={}; + LoaderHook.enableFailDebugger=true; + LoaderHook.FailSign="LoadFailItems"; + return LoaderHook; + })(LoaderManager) + + + /** + *颜色选取类 + *@author ww + */ + //class laya.debug.tools.ColorSelector extends laya.display.Sprite + var ColorSelector=(function(_super){ + function ColorSelector(){ + this.sideColor=null; + this.mainColor=null; + this.demoColor=null; + this.posSp=null; + this.hPos=null; + this.container=null; + this.isChanging=false; + this.tColor=null; + this.tH=NaN; + ColorSelector.__super.call(this); + this.container=this; + this.createUI(); + } + + __class(ColorSelector,'laya.debug.tools.ColorSelector',_super); + var __proto=ColorSelector.prototype; + __proto.createUI=function(){ + this.sideColor=new Sprite(); + this.container.addChild(this.sideColor); + this.posSp=new Sprite(); + this.posSp.pos(100,100); + this.posSp.graphics.drawCircle(0,0,5,null,"#ff0000"); + this.posSp.graphics.drawCircle(0,0,6,null,"#ffff00"); + this.posSp.autoSize=true; + this.posSp.cacheAsBitmap=true; + this.sideColor.addChild(this.posSp); + this.sideColor.pos(0,0); + this.sideColor.size(150,150); + this.sideColor.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.sideColorClick); + var i=0; + this.mainColor=new Sprite(); + var g; + g=this.mainColor.graphics; + var h=NaN; + var s=NaN; + var b=NaN; + var rgb; + for (i=0;i < 150;i++){ + rgb=ColorTool.hsb2rgb(i/150*360,1,1); + g.drawLine(0,i,20,i,ColorTool.getRGBStr(rgb)); + } + this.mainColor.pos(150+10,0); + this.mainColor.size(20,i); + this.mainColor.cacheAsBitmap=true; + this.hPos=new Sprite(); + this.hPos.graphics.drawPie(0,0,10,-10,10,"#ff0000"); + this.hPos.x=this.mainColor.x+22; + this.container.addChild(this.hPos); + this.container.addChild(this.mainColor); + this.mainColor.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.mainColorClick); + this.demoColor=new Sprite(); + this.demoColor.pos(this.sideColor.x,this.sideColor.y+this.sideColor.height+10); + this.demoColor.size(150,20); + this.container.addChild(this.demoColor); + this.setColorByRGBStr("#099599"); + this.posSp.on(/*laya.events.Event.DRAG_MOVE*/"dragmove",this,this.posDraging); + } + + // posSp.on(Event.MOUSE_DOWN,this,posMouseDown); + __proto.posMouseDown=function(e){} + __proto.posDraging=function(){ + this.updatePosSpAndShowColor(); + } + + __proto.posDragEnd=function(){ + this.isChanging=false; + this.updatePosSpAndShowColor(); + } + + __proto.setColorByRGBStr=function(rgbStr){ + var rgb; + rgb=ColorTool.getRGBByRGBStr(rgbStr); + this.setColor(rgb[0],rgb[1],rgb[2]); + } + + __proto.setColor=function(red,green,blue,notice){ + (notice===void 0)&& (notice=true); + var hsb; + hsb=ColorTool.rgb2hsb(red,green,blue); + var tRGB; + tRGB=ColorTool.hsb2rgb(hsb[0],hsb[1],hsb[2]); + this.setColorByHSB(hsb[0],hsb[1],hsb[2],notice); + } + + __proto.setColorByHSB=function(h,s,b,notice){ + (notice===void 0)&& (notice=true); + this.hPos.y=this.mainColor.y+h/360*150; + this.posSp.x=s *150; + this.posSp.y=(1-b)*150; + this.updateSideColor(h,notice); + } + + __proto.sideColorClick=function(e){ + this.isChanging=true; + this.posSp.startDrag(); + this.updatePosSpAndShowColor(); + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.sideColorMouseUp); + Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.sideColorMouseUp); + } + + __proto.sideColorMouseUp=function(e){ + this.isChanging=false; + this.updatePosSpAndShowColor(); + } + + __proto.updatePosSpAndShowColor=function(){ + this.posSp.x=this.sideColor.mouseX; + this.posSp.y=this.sideColor.mouseY; + if(this.posSp.x<0)this.posSp.x=0; + if(this.posSp.y<0)this.posSp.y=0; + if(this.posSp.x>150)this.posSp.x=150; + if(this.posSp.y>150)this.posSp.y=150; + this.updateDemoColor(); + } + + __proto.updateDemoColor=function(notice){ + (notice===void 0)&& (notice=true); + var h=NaN; + var s=NaN; + var b=NaN; + h=this.tH; + s=this.posSp.x / 150; + b=1-this.posSp.y / 150; + this.tColor=ColorTool.hsb2rgb(h,s,b); + var g; + g=this.demoColor.graphics; + g.clear(); + g.drawRect(0,0,this.demoColor.width,this.demoColor.height,ColorTool.getRGBStr(this.tColor)); + if(this.isChanging)return; + if(notice) + this.event("ColorChanged",this); + } + + __proto.mainColorClick=function(e){ + var yPos=NaN; + yPos=this.mainColor.mouseY; + this.hPos.y=yPos+this.mainColor.y; + var h=NaN; + h=yPos / 150 *360; + this.updateSideColor(h); + } + + __proto.updateSideColor=function(h,notice){ + (notice===void 0)&& (notice=true); + this.tH=h; + var s=NaN; + var b=NaN; + var g; + g=this.sideColor.graphics; + g.clear(); + this.sideColor.cacheAsBitmap=false; + var rgb; + rgb=ColorTool.hsb2rgb(h,1,1); + var gradient=Browser.context.createLinearGradient(0,0,80,0); + gradient.addColorStop(0,"white"); + gradient.addColorStop(1,ColorTool.getRGBStr(rgb)); + this.sideColor.graphics.drawRect(0,0,150,150,gradient); + this.sideColor.graphics.loadImage("comp/colorpicker_overlay.png",0,0); + this.sideColor.size(150,150); + this.sideColor.cacheAsBitmap=true; + this.updateDemoColor(notice); + } + + ColorSelector.COLOR_CHANGED="ColorChanged"; + ColorSelector.COLOR_CLEARED="COLOR_CLEARED"; + ColorSelector.RecWidth=150; + return ColorSelector; + })(Sprite) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-12-30 下午1:59:34 + */ + //class laya.debug.tools.comps.Arrow extends laya.display.Sprite + var Arrow=(function(_super){ + function Arrow(){ + Arrow.__super.call(this); + this.drawMe(); + } + + __class(Arrow,'laya.debug.tools.comps.Arrow',_super); + var __proto=Arrow.prototype; + __proto.drawMe=function(){ + var g; + g=this.graphics; + g.clear(); + g.drawLine(0,0,-1,-1,"#ff0000"); + g.drawLine(0,0,1,-1,"#ff0000"); + } + + return Arrow; + })(Sprite) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-12-30 下午2:03:32 + */ + //class laya.debug.tools.comps.ArrowLine extends laya.display.Sprite + var ArrowLine=(function(_super){ + function ArrowLine(sign){ + this.lineLen=160; + this.arrowLen=10; + this.sign="Y"; + this._targetChanger=null; + this._isMoving=false; + this.lenControl=new Rect(); + this.rotationControl=new Rect(); + this.lenChanger=ValueChanger.create(this,"lineLen"); + this.lenControlXChanger=ValueChanger.create(this.lenControl,"x"); + (sign===void 0)&& (sign="X"); + ArrowLine.__super.call(this); + this.sign=sign; + this.addChild(this.lenControl); + this.addChild(this.rotationControl); + this.lenControl.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.controlMouseDown); + this.drawMe(); + } + + __class(ArrowLine,'laya.debug.tools.comps.ArrowLine',_super); + var __proto=ArrowLine.prototype; + __proto.drawMe=function(){ + var g; + g=this.graphics; + g.clear(); + g.drawLine(0,0,this.lineLen,0,"#ffff00"); + g.drawLine(this.lineLen,0,this.lineLen-this.arrowLen,-this.arrowLen,"#ff0000"); + g.drawLine(this.lineLen,0,this.lineLen-this.arrowLen,this.arrowLen,"#ff0000"); + g.fillText(this.sign,50,-5,"","#ff0000","left"); + if(this._isMoving&&this._targetChanger){ + g.fillText(this._targetChanger.key+":"+this._targetChanger.value.toFixed(2),this.lineLen-15,-25,"","#ffff00","center"); + } + this.lenControl.posTo(this.lineLen-15,0); + this.rotationControl.posTo(this.lineLen+10,0); + this.size(this.arrowLen,this.lineLen); + } + + __proto.clearMoveEvents=function(){ + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.stageMouseMove); + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.stageMouseUp); + } + + __proto.controlMouseDown=function(e){ + this.clearMoveEvents(); + this.lenControlXChanger.record(); + this.lenChanger.record(); + if(this.targetChanger){ + this.targetChanger.record(); + } + this._isMoving=true; + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.stageMouseMove); + Laya.stage.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.stageMouseUp); + } + + __proto.stageMouseMove=function(e){ + this.lenControlXChanger.value=this.mouseX; + this.lenChanger.showValueByScale(this.lenControlXChanger.scaleValue); + if(this.targetChanger){ + this.targetChanger.showValueByScale(this.lenControlXChanger.scaleValue); + } + this.drawMe(); + } + + __proto.stageMouseUp=function(e){ + this._isMoving=false; + this.noticeChange(); + this.clearMoveEvents(); + this.lenControlXChanger.recover(); + this.lenChanger.recover(); + this.drawMe(); + } + + __proto.noticeChange=function(){ + var dLen=NaN; + dLen=this.lenChanger.dValue; + console.log("lenChange:",dLen); + } + + __getset(0,__proto,'targetChanger',function(){ + return this._targetChanger; + },function(changer){ + if(this._targetChanger){ + this._targetChanger.dispose(); + } + this._targetChanger=changer; + }); + + return ArrowLine; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.tools.comps.AutoSizeRec extends laya.display.Sprite + var AutoSizeRec=(function(_super){ + function AutoSizeRec(type){ + this.type=0; + this._color="#ffffff"; + this.preX=NaN; + this.preY=NaN; + AutoSizeRec.__super.call(this); + } + + __class(AutoSizeRec,'laya.debug.tools.comps.AutoSizeRec',_super); + var __proto=AutoSizeRec.prototype; + __proto.setColor=function(color){ + this._color=color; + this.reRender(); + } + + __proto.changeSize=function(){ + this.reRender(); + } + + __proto.reRender=function(){ + var g=this.graphics; + g.clear(); + g.drawRect(0,0,this.width,this.height,this._color); + } + + __proto.record=function(){ + this.preX=this.x; + this.preY=this.y; + } + + __proto.getDx=function(){ + return this.x-this.preX; + } + + __proto.getDy=function(){ + return this.y-this.preY; + } + + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this.changeSize(); + }); + + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this.changeSize(); + }); + + return AutoSizeRec; + })(Sprite) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-12-30 下午2:37:05 + */ + //class laya.debug.tools.comps.Axis extends laya.display.Sprite + var Axis=(function(_super){ + function Axis(){ + this._target=null; + this._lenType= + [ + ["width","height"], + ["scaleX","scaleY"]]; + this._type=1; + this.xAxis=new ArrowLine("X"); + this.yAxis=new ArrowLine("Y"); + this.controlBox=new Rect(); + this._point=new Point(); + this.oPoint=new Point(); + this.myRotationChanger=ValueChanger.create(this,"rotation"); + this.targetRotationChanger=ValueChanger.create(null,"rotation"); + this.stageMouseRotationChanger=new ValueChanger(); + Axis.__super.call(this); + this.mouseEnabled=true; + this.size(1,1); + this.initMe(); + this.xAxis.rotationControl.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.controlMouseDown); + this.yAxis.rotationControl.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.controlMouseDown); + this.controlBox.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.controlBoxMouseDown); + this.on(/*laya.events.Event.DRAG_MOVE*/"dragmove",this,this.dragging); + } + + __class(Axis,'laya.debug.tools.comps.Axis',_super); + var __proto=Axis.prototype; + __proto.updateChanges=function(){ + if(this._target){ + var params; + params=this._lenType[this._type]; + this.xAxis.targetChanger=ValueChanger.create(this._target,params[0]); + this.yAxis.targetChanger=ValueChanger.create(this._target,params[1]); + } + } + + __proto.switchType=function(){ + this._type++; + this._type=this._type%this._lenType.length; + this.type=this._type; + } + + __proto.controlBoxMouseDown=function(e){ + this.startDrag(); + } + + __proto.dragging=function(){ + if (this._target){ + this._point.setTo(this.x,this.y); + DisControlTool.transPoint(this.parent,this._target.parent,this._point); + this._target.pos(this._point.x,this._point.y); + } + } + + __proto.initMe=function(){ + this.addChild(this.xAxis); + this.addChild(this.yAxis); + this.yAxis.rotation=90; + this.addChild(this.controlBox); + this.controlBox.posTo(0,0); + } + + __proto.clearMoveEvents=function(){ + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.stageMouseMove); + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.stageMouseUp); + } + + __proto.controlMouseDown=function(e){ + this.targetRotationChanger.target=this.target; + this.clearMoveEvents(); + this.oPoint.setTo(0,0); + this.myRotationChanger.record(); + this.oPoint=this.localToGlobal(this.oPoint); + this.stageMouseRotationChanger.value=this.getStageMouseRatation(); + this.stageMouseRotationChanger.record(); + this.targetRotationChanger.record(); + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.stageMouseMove); + Laya.stage.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.stageMouseUp); + } + + __proto.getStageMouseRatation=function(){ + return MathUtil.getRotation(this.oPoint.x,this.oPoint.y,Laya.stage.mouseX,Laya.stage.mouseY); + } + + __proto.stageMouseMove=function(e){ + this.stageMouseRotationChanger.value=this.getStageMouseRatation(); + var dRotation=NaN; + dRotation=-this.stageMouseRotationChanger.dValue; + if(this.target){ + this.targetRotationChanger.showValueByAdd(dRotation); + }else{ + this.myRotationChanger.showValueByAdd(dRotation); + } + } + + __proto.stageMouseUp=function(e){ + this.noticeChange(); + this.clearMoveEvents(); + } + + __proto.noticeChange=function(){ + console.log("rotate:",-this.stageMouseRotationChanger.dValue); + } + + __getset(0,__proto,'target',function(){ + return this._target; + },function(tar){ + this._target=tar; + this.updateChanges(); + }); + + __getset(0,__proto,'type',function(){ + return this._type; + },function(lenType){ + this._type=lenType; + this.updateChanges(); + }); + + return Axis; + })(Sprite) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-12-30 下午3:23:06 + */ + //class laya.debug.tools.comps.Rect extends laya.display.Sprite + var Rect=(function(_super){ + function Rect(){ + this.recWidth=10; + Rect.__super.call(this); + this.drawMe(); + } + + __class(Rect,'laya.debug.tools.comps.Rect',_super); + var __proto=Rect.prototype; + __proto.drawMe=function(){ + var g; + g=this.graphics; + g.clear(); + g.drawRect(0,0,this.recWidth,this.recWidth,"#22ff22"); + this.size(this.recWidth,this.recWidth); + } + + __proto.posTo=function(x,y){ + this.x=x-this.recWidth*0.5; + this.y=y-this.recWidth*0.5; + } + + return Rect; + })(Sprite) + + + //class laya.debug.tools.DragBox extends laya.display.Sprite + var DragBox=(function(_super){ + function DragBox(type){ + this._box=null; + this._target=null; + this._currDir=null; + this._type=0; + this.fixScale=NaN; + DragBox.__super.call(this); + this._left=this.drawBlock(); + this._right=this.drawBlock(); + this._top=this.drawBlock(); + this._bottom=this.drawBlock(); + this._topLeft=this.drawBlock(); + this._topRight=this.drawBlock(); + this._bottomLeft=this.drawBlock(); + this._bottomRight=this.drawBlock(); + this._lastPoint=new Point(); + this._type=type=3; + this.addChild(this._box=this.drawBorder(0,0,0xff0000)); + if (type==1 || type==3){ + this.addChild(this._left); + this.addChild(this._right); + } + if (type==2 || type==3){ + this.addChild(this._top); + this.addChild(this._bottom); + } + if (type==3){ + this.addChild(this._topLeft); + this.addChild(this._topRight); + this.addChild(this._bottomLeft); + this.addChild(this._bottomRight); + } + this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onMouseDown); + this.mouseThrough=true; + } + + __class(DragBox,'laya.debug.tools.DragBox',_super); + var __proto=DragBox.prototype; + __proto.onMouseDown=function(e){ + this._currDir=e.target; + if(e.nativeEvent.shiftKey){ + this.initFixScale(); + } + if (this._currDir !=this){ + this._lastPoint.x=Laya.stage.mouseX; + this._lastPoint.y=Laya.stage.mouseY; + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onMouseMove); + Laya.stage.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onMouseUp); + e.stopPropagation(); + } + } + + __proto.onMouseUp=function(e){ + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onMouseMove); + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onMouseUp); + } + + __proto.initFixScale=function(){ + this.fixScale=this._target.height / this._target.width; + } + + __proto.onMouseMove=function(e){ + var scale=1; + var tx=(Laya.stage.mouseX-this._lastPoint.x)/ scale; + var ty=(Laya.stage.mouseY-this._lastPoint.y)/ scale; + var sameScale=false; + var adptX=NaN; + var adptY=NaN; + if(e.nativeEvent.shiftKey){ + if(this.fixScale<0)this.initFixScale(); + adptY=tx *this.fixScale; + adptX=ty/this.fixScale; + sameScale=true; + switch(this._currDir){ + case this._topLeft: + case this._bottomLeft: + this._currDir=this._left; + break ; + case this._topRight: + case this._bottomRight: + this._currDir=this._right; + break ; + } + } + if (tx !=0 || ty !=0){ + this._lastPoint.x+=tx *scale; + this._lastPoint.y+=ty *scale; + var tw=tx / this._target.scaleX; + var th=ty / this._target.scaleY; + if (this._currDir==this._left){ + this._target.x+=tx; + this._target.width-=tw; + if (sameScale){ + this._target.height=this._target.width*this.fixScale; + } + }else if (this._currDir==this._right){ + this._target.width+=tw; + if (sameScale){ + this._target.height=this._target.width*this.fixScale; + } + }else if (this._currDir==this._top){ + this._target.y+=ty; + this._target.height-=th; + if (sameScale){ + this._target.width=this._target.height/this.fixScale; + } + }else if (this._currDir==this._bottom){ + this._target.height+=th; + if (sameScale){ + this._target.width=this._target.height/this.fixScale; + } + }else if (this._currDir==this._topLeft){ + this._target.x+=tx; + this._target.y+=ty; + this._target.width-=tw; + this._target.height-=th; + }else if (this._currDir==this._topRight){ + this._target.y+=ty; + this._target.width+=tw; + this._target.height-=th; + }else if (this._currDir==this._bottomLeft){ + this._target.x+=tx; + this._target.width-=tw; + this._target.height+=th; + }else if (this._currDir==this._bottomRight){ + this._target.width+=tw; + this._target.height+=th; + } + if (this._target.width < 1){ + this._target.width=1; + } + if (this._target.height < 1){ + this._target.height=1; + } + this._target.width=Math.round(this._target.width); + this._target.x=Math.round(this._target.x); + this._target.y=Math.round(this._target.y); + this._target.height=Math.round(this._target.height); + this.refresh(); + } + } + + /**画矩形*/ + __proto.drawBorder=function(width,height,color,alpha){ + (alpha===void 0)&& (alpha=1); + var box=new Sprite(); + var g=box.graphics; + g.clear(); + g.drawRect(0,0,width,height,null,"#"+color); + return box; + } + + /**画矩形*/ + __proto.drawBlock=function(){ + var box=new Sprite(); + var g=box.graphics; + g.clear(); + box.width=DragBox.BLOCK_WIDTH; + box.height=DragBox.BLOCK_WIDTH; + g.drawRect(-DragBox.BLOCK_WIDTH *0.5,-DragBox.BLOCK_WIDTH *0.5,DragBox.BLOCK_WIDTH,DragBox.BLOCK_WIDTH,"#ffffff","#ff0000",1); + box.mouseEnabled=true; + box.mouseThrough=true; + return box; + } + + /**设置对象*/ + __proto.setTarget=function(target){ + this._target=target; + this.refresh(); + } + + __proto.refresh=function(){ + this.changePoint(); + this.changeSize(); + } + + __proto.changePoint=function(){ + var p=this._target.localToGlobal(new Point()); + var np=(this.parent).globalToLocal(p); + this.x=np.x; + this.y=np.y; + } + + /**设置大小*/ + __proto.changeSize=function(){ + var width=this._target.width *this._target.scaleX; + var height=this._target.height *this._target.scaleY; + console.log("change size"); + this.rotation=this._target.rotation; + if (this._box.width !=width || this._box.height !=height){ + this._box.graphics.clear(); + this._box.graphics.drawRect(0,0,Math.abs(width),Math.abs(height),null,"#ff0000"); + this._box.size(width,height); + this.size(width,height); + this._box.scaleX=Math.abs(this._box.scaleX)*(this._target.scaleX > 0 ? 1 :-1); + this._box.scaleY=Math.abs(this._box.scaleY)*(this._target.scaleY > 0 ? 1 :-1); + this._left.x=0; + this._left.y=height *0.5; + this._right.x=width; + this._right.y=height *0.5; + this._top.x=width *0.5; + this._top.y=0; + this._bottom.x=width *0.5; + this._bottom.y=height; + this._topLeft.x=this._topLeft.y=0; + this._topRight.x=width; + this._topRight.y=0; + this._bottomLeft.x=0; + this._bottomLeft.y=height; + this._bottomRight.x=width; + this._bottomRight.y=height; + } + } + + DragBox.BLOCK_WIDTH=6; + return DragBox; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.DebugInfoLayer extends laya.display.Sprite + var DebugInfoLayer=(function(_super){ + function DebugInfoLayer(){ + this.nodeRecInfoLayer=null; + this.lineLayer=null; + this.txtLayer=null; + this.popLayer=null; + this.graphicLayer=null; + this.cacheViewLayer=null; + DebugInfoLayer.__super.call(this); + this.nodeRecInfoLayer=new Sprite(); + this.lineLayer=new Sprite(); + this.txtLayer=new Sprite(); + this.popLayer=new Sprite(); + this.graphicLayer=new Sprite(); + this.cacheViewLayer=new Sprite(); + this.nodeRecInfoLayer.name="nodeRecInfoLayer"; + this.lineLayer.name="lineLayer"; + this.txtLayer.name="txtLayer"; + this.popLayer.name="popLayer"; + this.graphicLayer.name="graphicLayer"; + this.cacheViewLayer.name="cacheViewLayer"; + this.addChild(this.lineLayer); + this.addChild(this.cacheViewLayer); + this.addChild(this.nodeRecInfoLayer); + this.addChild(this.txtLayer); + this.addChild(this.popLayer); + this.addChild(this.graphicLayer); + DebugInfoLayer.I=this; + Laya.stage.on(/*laya.events.Event.DOUBLE_CLICK*/"doubleclick",this,this.setTop); + } + + __class(DebugInfoLayer,'laya.debug.view.nodeInfo.DebugInfoLayer',_super); + var __proto=DebugInfoLayer.prototype; + __proto.setTop=function(){ + DisControlTool.setTop(this); + } + + __proto.isDebugItem=function(sprite){ + return DisControlTool.isInTree(this,sprite); + } + + DebugInfoLayer.I=null + return DebugInfoLayer; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.NodeInfoPanel extends laya.display.Sprite + var NodeInfoPanel=(function(_super){ + function NodeInfoPanel(){ + this._stateDic={}; + this.isWorkState=false; + NodeInfoPanel.__super.call(this); + } + + __class(NodeInfoPanel,'laya.debug.view.nodeInfo.NodeInfoPanel',_super); + var __proto=NodeInfoPanel.prototype; + __proto.showDisInfo=function(node){ + this.recoverNodes(); + NodeInfosItem.showDisInfos(node); + this.showOnly(node); + this.isWorkState=true; + } + + __proto.showOnly=function(node){ + if (!node) + return; + this.hideBrothers(node); + this.showOnly(node.parent); + } + + __proto.recoverNodes=function(){ + NodeInfosItem.hideAllInfos(); + var key; + var data; + var tTar; + for (key in this._stateDic){ + data=this._stateDic[key]; + tTar=data["target"]; + if (tTar){ + try{ + tTar.visible=data.visible; + }catch (e){ + } + } + } + this.isWorkState=false; + } + + __proto.hideOtherChain=function(node){ + if (!node) + return; + while (node){ + this.hideBrothers(node); + node=node.parent; + } + } + + __proto.hideChilds=function(node){ + if (!node) + return; + var i=0,len=0; + var cList; + cList=node._childs; + len=cList.length; + var tChild; + for (i=0;i < len;i++){ + tChild=cList[i]; + if (tChild==NodeInfosItem.NodeInfoContainer)continue ; + this.saveNodeInfo(tChild); + tChild.visible=false; + } + } + + __proto.hideBrothers=function(node){ + if (!node) + return; + var p; + p=node.parent; + if (!p) + return; + var i=0,len=0; + var cList; + cList=p._childs; + len=cList.length; + var tChild; + for (i=0;i < len;i++){ + tChild=cList[i]; + if (tChild==NodeInfosItem.NodeInfoContainer)continue ; + if (tChild !=node){ + this.saveNodeInfo(tChild); + tChild.visible=false; + } + } + } + + __proto.saveNodeInfo=function(node){ + IDTools.idObj(node); + if(this._stateDic.hasOwnProperty(IDTools.getObjID(node)))return; + var data; + data={}; + data.target=node; + data.visible=node.visible; + this._stateDic[IDTools.getObjID(node)]=data; + } + + __proto.recoverNodeInfo=function(node){ + IDTools.idObj(node); + if (this._stateDic.hasOwnProperty(IDTools.getObjID(node))){ + var data; + data=this._stateDic[IDTools.getObjID(node)]; + node["visible"]=data.visible; + } + } + + NodeInfoPanel.init=function(){ + if (!NodeInfoPanel.I){ + NodeInfoPanel.I=new NodeInfoPanel(); + NodeInfosItem.init(); + ToolPanel.init(); + } + } + + NodeInfoPanel.I=null + return NodeInfoPanel; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.NodeInfosItem extends laya.display.Sprite + var NodeInfosItem=(function(_super){ + function NodeInfosItem(){ + this._infoTxt=null; + this._tar=null; + NodeInfosItem.__super.call(this); + this._infoTxt=new Text(); + this._infoTxt.color="#ff0000"; + this._infoTxt.bgColor="#00ff00"; + this._infoTxt.fontSize=12; + } + + __class(NodeInfosItem,'laya.debug.view.nodeInfo.NodeInfosItem',_super); + var __proto=NodeInfosItem.prototype; + __proto.removeSelf=function(){ + this._infoTxt.removeSelf(); + return laya.display.Node.prototype.removeSelf.call(this); + } + + __proto.showToUI=function(){ + NodeInfosItem.NodeInfoContainer.nodeRecInfoLayer.addChild(this); + this._infoTxt.removeSelf(); + NodeInfosItem.NodeInfoContainer.txtLayer.addChild(this._infoTxt); + this.findOkPos(); + } + + __proto.randomAPos=function(r){ + this._infoTxt.x=this.x+Laya.stage.width*Math.random(); + this._infoTxt.y=this.y+r *Math.random(); + } + + __proto.findOkPos=function(){ + var len=0; + len=20; + this.randomAPos(len); + return; + var count=0; + count=1; + while (!this.isPosOk()){ + count++; + if (count >=500){ + len+=10; + count=0; + } + this.randomAPos(len); + } + } + + __proto.isPosOk=function(){ + var tParent; + tParent=NodeInfosItem.NodeInfoContainer.nodeRecInfoLayer; + var i=0,len=0; + var cList; + cList=tParent._childs; + len=cList.length; + var tChild; + var mRec; + mRec=this._infoTxt.getBounds(); + if (mRec.x < 0)return false; + if (mRec.y < 0)return false; + if (mRec.right > Laya.stage.width)return false; + for (i=0;i < len;i++){ + tChild=cList[i]; + if (tChild==this._infoTxt)continue ; + if (mRec.intersects(tChild.getBounds()))return false; + } + return true; + } + + __proto.showInfo=function(node){ + this._tar=node; + if (!node)return; + NodeInfosItem._txts.length=0; + var i=0,len=0; + var tKey; + len=NodeInfosItem.showValues.length; + if (node.name){ + NodeInfosItem._txts.push(ClassTool.getClassName(node)+"("+node.name+")"); + }else{ + NodeInfosItem._txts.push(ClassTool.getClassName(node)); + } + for (i=0;i < len;i++){ + tKey=NodeInfosItem.showValues[i]; + NodeInfosItem._txts.push(tKey+":"+NodeInfosItem.getNodeValue(node,tKey)); + } + this._infoTxt.text=NodeInfosItem._txts.join("\n"); + this.graphics.clear(); + var pointList; + pointList=node._getBoundPointsM(true); + if(!pointList||pointList.length<1)return; + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,node.localToGlobal,node); + pointList=GrahamScan.pointListToPlist(pointList); + NodeInfosItem._disBoundRec=Rectangle._getWrapRec(pointList,NodeInfosItem._disBoundRec); + this.graphics.drawRect(0,0,NodeInfosItem._disBoundRec.width,NodeInfosItem._disBoundRec.height,null,"#00ffff"); + this.pos(NodeInfosItem._disBoundRec.x,NodeInfosItem._disBoundRec.y); + } + + __proto.fresh=function(){ + this.showInfo(this._tar); + } + + __proto.clearMe=function(){ + this._tar=null; + } + + __proto.recover=function(){ + Pool.recover("NodeInfosItem",this); + } + + NodeInfosItem.init=function(){ + if (!NodeInfosItem.NodeInfoContainer){ + NodeInfosItem.NodeInfoContainer=new DebugInfoLayer(); + Laya.stage.addChild(NodeInfosItem.NodeInfoContainer); + } + } + + NodeInfosItem.getNodeInfoByNode=function(node){ + IDTools.idObj(node); + var key=0; + key=IDTools.getObjID(node); + if (!NodeInfosItem._nodeInfoDic[key]){ + NodeInfosItem._nodeInfoDic[key]=new NodeInfosItem(); + } + return NodeInfosItem._nodeInfoDic[key]; + } + + NodeInfosItem.hideAllInfos=function(){ + var key; + var tInfo; + for (key in NodeInfosItem._nodeInfoDic){ + tInfo=NodeInfosItem._nodeInfoDic[key]; + tInfo.removeSelf(); + } + NodeInfosItem.clearRelations(); + } + + NodeInfosItem.showNodeInfo=function(node){ + var nodeInfo; + nodeInfo=NodeInfosItem.getNodeInfoByNode(node); + nodeInfo.showInfo(node); + nodeInfo.showToUI(); + } + + NodeInfosItem.showDisInfos=function(node){ + var _node; + _node=node; + if (!node) + return; + while (node){ + NodeInfosItem.showNodeInfo(node); + node=node.parent; + } + DisControlTool.setTop(NodeInfosItem.NodeInfoContainer); + NodeInfosItem.apdtTxtInfoPoss(_node); + NodeInfosItem.updateRelations(); + } + + NodeInfosItem.apdtTxtInfoPoss=function(node){ + var disList; + disList=[]; + while (node){ + disList.push(node); + node=node.parent; + }; + var i=0,len=0; + var tInfo; + var tTxt; + len=disList.length; + var xPos=NaN; + xPos=Laya.stage.width-150; + var heightLen=0; + heightLen=100; + node=disList[0]; + if (node){ + tInfo=NodeInfosItem.getNodeInfoByNode(node); + if (tInfo){ + tTxt=tInfo._infoTxt; + xPos=Laya.stage.width-tTxt.width-10; + heightLen=tTxt.height+10; + } + } + disList=disList.reverse(); + for (i=0;i < len;i++){ + node=disList[i]; + tInfo=NodeInfosItem.getNodeInfoByNode(node); + if (tInfo){ + tTxt=tInfo._infoTxt; + tTxt.pos(xPos,heightLen *i); + } + } + } + + NodeInfosItem.clearRelations=function(){ + var g; + g=NodeInfosItem.NodeInfoContainer.lineLayer.graphics; + g.clear(); + } + + NodeInfosItem.updateRelations=function(){ + var g; + g=NodeInfosItem.NodeInfoContainer.lineLayer.graphics; + g.clear(); + var key; + var tInfo; + for (key in NodeInfosItem._nodeInfoDic){ + tInfo=NodeInfosItem._nodeInfoDic[key]; + if (tInfo.parent){ + g.drawLine(tInfo.x,tInfo.y,tInfo._infoTxt.x,tInfo._infoTxt.y,"#0000ff"); + } + } + } + + NodeInfosItem.getNodeValue=function(node,key){ + var rst; + NodeInfosItem._nodePoint.setTo(0,0); + switch(key){ + case "x": + rst=node["x"]+" (g:"+node.localToGlobal(NodeInfosItem._nodePoint).x+")" + break ; + case "y": + rst=node["y"]+" (g:"+node.localToGlobal(NodeInfosItem._nodePoint).y+")" + break ; + default : + rst=node[key]; + } + return rst; + } + + NodeInfosItem.NodeInfoContainer=null + NodeInfosItem._nodeInfoDic={}; + NodeInfosItem._txts=[]; + __static(NodeInfosItem, + ['showValues',function(){return this.showValues=["x","y","scaleX","scaleY","width","height","visible","mouseEnabled"];},'_disBoundRec',function(){return this._disBoundRec=new Rectangle();},'_nodePoint',function(){return this._nodePoint=new Point();} + ]); + return NodeInfosItem; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.recinfos.NodeRecInfo extends laya.display.Sprite + var NodeRecInfo=(function(_super){ + function NodeRecInfo(){ + this.txt=null; + this._tar=null; + this.recColor="#00ff00"; + NodeRecInfo.__super.call(this); + this.txt=new Text(); + this.txt.color="#ff0000"; + this.txt.bgColor="#00ff00"; + this.txt.fontSize=12; + this.addChild(this.txt); + } + + __class(NodeRecInfo,'laya.debug.view.nodeInfo.recinfos.NodeRecInfo',_super); + var __proto=NodeRecInfo.prototype; + __proto.setInfo=function(str){ + this.txt.text=str; + } + + __proto.setTarget=function(tar){ + this._tar=tar; + } + + __proto.showInfo=function(node){ + this._tar=node; + if (!node)return; + if(!node._$P)return; + this.graphics.clear(); + var pointList; + pointList=node._getBoundPointsM(true); + if(!pointList||pointList.length<1)return; + pointList=GrahamScan.pListToPointList(pointList,true); + WalkTools.walkArr(pointList,node.localToGlobal,node); + pointList=GrahamScan.pointListToPlist(pointList); + NodeRecInfo._disBoundRec=Rectangle._getWrapRec(pointList,NodeRecInfo._disBoundRec); + this.graphics.drawRect(0,0,NodeRecInfo._disBoundRec.width,NodeRecInfo._disBoundRec.height,null,this.recColor,2); + this.pos(NodeRecInfo._disBoundRec.x,NodeRecInfo._disBoundRec.y); + } + + __proto.fresh=function(){ + this.showInfo(this._tar); + } + + __proto.clearMe=function(){ + this._tar=null; + } + + __static(NodeRecInfo, + ['_disBoundRec',function(){return this._disBoundRec=new Rectangle();} + ]); + return NodeRecInfo; + })(Sprite) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.ToolPanel extends laya.display.Sprite + var ToolPanel=(function(_super){ + function ToolPanel(){ + ToolPanel.__super.call(this); + Base64AtlasManager.base64.preLoad(Handler.create(this,this.showToolBar)); + ContextMenu.init(); + DisResizer.init(); + var tipManager; + tipManager=new TipManagerForDebug(); + } + + __class(ToolPanel,'laya.debug.view.nodeInfo.ToolPanel',_super); + var __proto=ToolPanel.prototype; + //Laya.timer.once(1000,this,showToolBar); + __proto.showToolBar=function(){ + DebugPanelView.I.show(); + } + + __proto.createViews=function(){ + ToolPanel.typeClassDic["Find"]=FindView; + ToolPanel.typeClassDic["Filter"]=FilterView; + ToolPanel.typeClassDic["TxtInfo"]=TxtInfoView; + ToolPanel.typeClassDic["Tree"]=NodeTreeView; + } + + __proto.switchShow=function(type){ + var view; + view=this.getView(type); + if (view){ + view.switchShow(); + } + } + + __proto.getView=function(type){ + var view; + view=ToolPanel.viewDic[type]; + if (!view && ToolPanel.typeClassDic[type]){ + view=ToolPanel.viewDic[type]=new ToolPanel.typeClassDic[type](); + } + return view; + } + + __proto.showTxtInfo=function(txt){ + OutPutView.I.showTxt(txt); + } + + __proto.showNodeTree=function(node){ + NodeTree.I.setDis(node); + DebugPanelView.I.switchToTree(); + } + + __proto.showSelectInStage=function(node){ + NodeTree.I.showSelectInStage(node); + DebugPanelView.I.switchToTree(); + } + + __proto.showSelectItems=function(selectList){ + DebugPanelView.I.swichToSelect(); + SelectInfosView.I.setSelectList(selectList); + } + + ToolPanel.init=function(){ + if (!ToolPanel.I)ToolPanel.I=new ToolPanel(); + } + + ToolPanel.I=null + ToolPanel.viewDic={}; + ToolPanel.Find="Find"; + ToolPanel.Filter="Filter"; + ToolPanel.TxtInfo="TxtInfo"; + ToolPanel.Tree="Tree"; + __static(ToolPanel, + ['typeClassDic',function(){return this.typeClassDic={ + };} + + ]); + return ToolPanel; + })(Sprite) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-9-29 上午11:17:35 + */ + //class laya.debug.tools.debugUI.DButton extends laya.display.Text + var DButton=(function(_super){ + function DButton(){ + DButton.__super.call(this); + this.bgColor="#ffff00"; + this.wordWrap=false; + this.mouseEnabled=true; + } + + __class(DButton,'laya.debug.tools.debugUI.DButton',_super); + return DButton; + })(Text) + + + /** + *自动根据大小填充自己全部区域的显示对象 + *@author ww + */ + //class laya.debug.tools.resizer.AutoFillRec extends laya.ui.Component + var AutoFillRec=(function(_super){ + function AutoFillRec(type){ + this.type=0; + this.preX=NaN; + this.preY=NaN; + AutoFillRec.__super.call(this); + } + + __class(AutoFillRec,'laya.debug.tools.resizer.AutoFillRec',_super); + var __proto=AutoFillRec.prototype; + //super(type); + __proto.changeSize=function(){ + _super.prototype.changeSize.call(this); + var g=this.graphics; + g.clear(); + g.drawRect(0,0,this.width,this.height,"#33c5f5"); + } + + __proto.record=function(){ + this.preX=this.x; + this.preY=this.y; + } + + __proto.getDx=function(){ + return this.x-this.preX; + } + + __proto.getDy=function(){ + return this.y-this.preY; + } + + return AutoFillRec; + })(Component) + + + /**鼠标提示管理类*/ + //class laya.debug.tools.TipManagerForDebug extends laya.ui.Component + var TipManagerForDebug=(function(_super){ + function TipManagerForDebug(){ + this._tipBox=null; + this._tipText=null; + this._defaultTipHandler=null; + TipManagerForDebug.__super.call(this); + this._tipBox=new Component(); + this._tipBox.addChild(this._tipText=new Text()); + this._tipText.x=this._tipText.y=5; + this._tipText.color=TipManagerForDebug.tipTextColor; + this._defaultTipHandler=this.showDefaultTip; + Laya.stage.on(/*laya.ui.UIEvent.SHOW_TIP*/"showtip",this,this.onStageShowTip); + Laya.stage.on(/*laya.ui.UIEvent.HIDE_TIP*/"hidetip",this,this.onStageHideTip); + } + + __class(TipManagerForDebug,'laya.debug.tools.TipManagerForDebug',_super); + var __proto=TipManagerForDebug.prototype; + __proto.onStageHideTip=function(e){ + Laya.timer.clear(this,this.showTip); + this.closeAll(); + this.removeSelf(); + } + + __proto.onStageShowTip=function(data){ + Laya.timer.once(TipManagerForDebug.tipDelay,this,this.showTip,[data],true); + } + + __proto.showTip=function(tip){ + if ((typeof tip=='string')){ + var text=String(tip); + if (Boolean(text)){ + this._defaultTipHandler(text); + } + }else if ((tip instanceof laya.utils.Handler )){ + (tip).run(); + }else if ((typeof tip=='function')){ + (tip).apply(); + } + if (true){ + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onStageMouseMove); + Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onStageMouseDown); + } + this.onStageMouseMove(null); + } + + __proto.onStageMouseDown=function(e){ + this.closeAll(); + } + + __proto.onStageMouseMove=function(e){ + this.showToStage(this,TipManagerForDebug.offsetX,TipManagerForDebug.offsetY); + } + + __proto.showToStage=function(dis,offX,offY){ + (offX===void 0)&& (offX=0); + (offY===void 0)&& (offY=0); + var rec=dis.getBounds(); + dis.x=Laya.stage.mouseX+offX; + dis.y=Laya.stage.mouseY+offY; + if (dis.x+rec.width > Laya.stage.width){ + dis.x-=rec.width+offX; + } + if (dis.y+rec.height > Laya.stage.height){ + dis.y-=rec.height+offY; + } + } + + /**关闭所有鼠标提示*/ + __proto.closeAll=function(){ + Laya.timer.clear(this,this.showTip); + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onStageMouseMove); + Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onStageMouseDown); + this.removeChildren(); + } + + __proto.showDisTip=function(tip){ + this.addChild(tip); + this.showToStage(this); + Laya.stage.addChild(this); + } + + __proto.showDefaultTip=function(text){ + this._tipText.text=text; + var g=this._tipBox.graphics; + g.clear(); + g.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,TipManagerForDebug.tipBackColor); + this.addChild(this._tipBox); + this.showToStage(this); + Laya.stage.addChild(this); + } + + /**默认鼠标提示函数*/ + __getset(0,__proto,'defaultTipHandler',function(){ + return this._defaultTipHandler; + },function(value){ + this._defaultTipHandler=value; + }); + + TipManagerForDebug.offsetX=10; + TipManagerForDebug.offsetY=15; + TipManagerForDebug.tipTextColor="#ffffff"; + TipManagerForDebug.tipBackColor="#111111"; + TipManagerForDebug.tipDelay=200; + return TipManagerForDebug; + })(Component) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.UIViewBase extends laya.ui.Component + var UIViewBase=(function(_super){ + function UIViewBase(){ + this.minHandler=null; + this.maxHandler=null; + this.isFirstShow=true; + this.dis=null; + UIViewBase.__super.call(this); + this.dis=this; + this.minHandler=new Handler(this,this.close); + this.maxHandler=new Handler(this,this.show); + this.createPanel(); + if (this.dis){ + this.dis.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.bringToTop); + this.dis.cacheAsBitmap=true; + } + } + + __class(UIViewBase,'laya.debug.view.nodeInfo.views.UIViewBase',_super); + var __proto=UIViewBase.prototype; + __proto.show=function(){ + DebugInfoLayer.I.setTop(); + DebugInfoLayer.I.popLayer.addChild(this.dis); + if (this.isFirstShow){ + this.firstShowFun(); + this.isFirstShow=false; + } + } + + __proto.firstShowFun=function(){ + this.dis.x=(Laya.stage.width-this.dis.width)*0.5; + this.dis.y=(Laya.stage.height-this.dis.height)*0.5; + DisControlTool.intFyDisPos(this.dis); + } + + __proto.bringToTop=function(){ + DisControlTool.setTop(this.dis); + } + + __proto.switchShow=function(){ + if (this.dis.parent){ + this.close(); + }else{ + this.show(); + } + } + + __proto.close=function(){ + this.dis.removeSelf(); + } + + __proto.createPanel=function(){} + __proto.getInput=function(){ + var input; + input=new DInput(); + input.size(200,30); + input.fontSize=30; + return input; + } + + __proto.getButton=function(){ + var btn; + btn=new DButton(); + btn.size(40,30); + btn.fontSize=30; + return btn; + } + + return UIViewBase; + })(Component) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.recinfos.ReCacheRecInfo extends laya.debug.view.nodeInfo.recinfos.NodeRecInfo + var ReCacheRecInfo=(function(_super){ + function ReCacheRecInfo(){ + this.isWorking=false; + this.count=0; + this.mTime=0; + ReCacheRecInfo.__super.call(this); + this.txt.fontSize=12; + } + + __class(ReCacheRecInfo,'laya.debug.view.nodeInfo.recinfos.ReCacheRecInfo',_super); + var __proto=ReCacheRecInfo.prototype; + __proto.addCount=function(time){ + (time===void 0)&& (time=0); + this.count++; + this.mTime+=time; + if (!this.isWorking){ + this.working=true; + } + } + + __proto.updates=function(){ + if (!this._tar["displayedInStage"]){ + this.working=false; + this.removeSelf(); + } + this.txt.text=ClassTool.getNodeClassAndName(this._tar)+"\n"+"reCache:"+this.count+"\ntime:"+this.mTime; + if (this.count > 0){ + this.fresh(); + Laya.timer.clear(this,this.removeSelfLater); + }else{ + this.working=false; + Laya.timer.once(3000,this,this.removeSelfLater); + } + this.count=0; + this.mTime=0; + } + + __proto.removeSelfLater=function(){ + this.working=false; + this.removeSelf(); + } + + __getset(0,__proto,'working',null,function(v){ + this.isWorking=v; + if (v){ + Laya.timer.loop(1000,this,this.updates); + }else{ + Laya.timer.clear(this,this.updates); + } + }); + + ReCacheRecInfo.showTime=3000; + return ReCacheRecInfo; + })(NodeRecInfo) + + + /** + *... + *@author ww + */ + //class laya.debug.tools.debugUI.DInput extends laya.display.Input + var DInput=(function(_super){ + function DInput(){ + DInput.__super.call(this); + this.bgColor="#11ff00"; + } + + __class(DInput,'laya.debug.tools.debugUI.DInput',_super); + return DInput; + })(Input) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2015-10-24 下午2:58:37 + */ + //class laya.debug.uicomps.ContextMenu extends laya.ui.Box + var ContextMenu=(function(_super){ + function ContextMenu(){ + this._tY=0; + ContextMenu.__super.call(this); + StyleConsts.setViewScale(this); + } + + __class(ContextMenu,'laya.debug.uicomps.ContextMenu',_super); + var __proto=ContextMenu.prototype; + __proto.addItem=function(item){ + this.addChild(item); + item.y=this._tY; + this._tY+=item.height; + item.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onClick); + } + + __proto.onClick=function(e){ + this.event(/*laya.events.Event.SELECT*/"select",e); + this.removeSelf(); + } + + __proto.show=function(posX,posY){ + (posX===void 0)&& (posX=-999); + (posY===void 0)&& (posY=-999); + Laya.timer.once(100,this,ContextMenu.showMenu,[this,posX,posY]); + } + + ContextMenu.init=function(){ + Laya.stage.on(/*laya.events.Event.CLICK*/"click",null,ContextMenu.cleanMenu); + } + + ContextMenu.cleanMenu=function(e){ + var i=0; + var len=0; + len=ContextMenu._menuList.length; + for(i=0;i 0){ + tData.label=key+":"+dataO[key]+" +"+tData.add; + } + else{ + tData.label=key+":"+dataO[key]; + } + count=RunProfile.getRunInfo(key); + if (count){ + count.record(); + } + tData.rank=tData.add *1000+tData.count; + this.preInfo[key]=dataO[key]; + dataList.push(tData); + } + dataList.sort(MathTools.sortByKey("rank",true,true)); + this.view.itemList.array=dataList; + } + + __getset(1,ObjectCreateView,'I',function(){ + if (!ObjectCreateView._I) + ObjectCreateView._I=new ObjectCreateView(); + return ObjectCreateView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + ObjectCreateView._I=null + return ObjectCreateView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.ObjectInfoView extends laya.debug.view.nodeInfo.views.UIViewBase + var ObjectInfoView=(function(_super){ + function ObjectInfoView(){ + this.view=null; + this.showKeys=["x","y","width","height","renderCost"]; + this._closeSettingHandler=null; + this._tar=null; + ObjectInfoView.__super.call(this); + } + + __class(ObjectInfoView,'laya.debug.view.nodeInfo.views.ObjectInfoView',_super); + var __proto=ObjectInfoView.prototype; + __proto.createPanel=function(){ + _super.prototype.createPanel.call(this); + this.view=new ObjectInfo(); + StyleConsts.setViewScale(this.view); + this.addChild(this.view); + this.inits(); + } + + __proto.inits=function(){ + this.view.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.close); + this.view.settingBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onSettingBtn); + this.view.autoUpdate.on(/*laya.events.Event.CHANGE*/"change",this,this.onAutoUpdateChange); + DisControlTool.setDragingItem(this.view.bg,this.view); + DisControlTool.setResizeAbleEx(this.view); + this._closeSettingHandler=new Handler(this,this.closeSetting); + this.dis=this.view; + } + + __proto.onAutoUpdateChange=function(){ + this.autoUpdate=this.view.autoUpdate.selected; + } + + __proto.onSettingBtn=function(){ + NodeTreeSettingView.I.showSetting(this.showKeys,this._closeSettingHandler,this._tar); + } + + __proto.reset=function(){ + this.showKeys=["x","y","width","height","renderCost"]; + } + + __proto.closeSetting=function(newKeys){ + this.showKeys=newKeys; + this.fresh(); + } + + __proto.showObjectInfo=function(obj){ + this._tar=obj; + this.fresh(); + this.show(); + this.onAutoUpdateChange(); + } + + __proto.fresh=function(){ + if (!this._tar){ + this.view.showTxt.text=""; + this.view.title.text="未选中对象"; + } + else{ + this.view.title.text=ClassTool.getNodeClassAndName(this._tar); + this.view.showTxt.text=ObjectInfoView.getObjValueStr(this._tar,this.showKeys,false); + } + } + + __proto.freshKeyInfos=function(){ + this.fresh(); + } + + __proto.close=function(){ + _super.prototype.close.call(this); + this.autoUpdate=false; + Pool.recover("ObjectInfoView",this); + } + + __proto.show=function(){ + _super.prototype.show.call(this); + } + + __getset(0,__proto,'autoUpdate',null,function(v){ + Laya.timer.clear(this,this.freshKeyInfos); + if (v){ + Laya.timer.loop(2000,this,this.freshKeyInfos); + } + }); + + ObjectInfoView.getObjValueStr=function(obj,keys,withTitle){ + (withTitle===void 0)&& (withTitle=true); + var i=0,len=0; + var tKey; + ObjectInfoView._txts.length=0; + len=keys.length; + if (withTitle){ + if (obj.name){ + ObjectInfoView._txts.push(ClassTool.getClassName(obj)+"("+obj.name+")"); + } + else{ + ObjectInfoView._txts.push(ClassTool.getClassName(obj)); + } + } + for (i=0;i < len;i++){ + tKey=keys[i]; + ObjectInfoView._txts.push(tKey+":"+ObjectInfoView.getNodeValue(obj,tKey)); + } + return ObjectInfoView._txts.join("\n"); + } + + ObjectInfoView.getNodeValue=function(node,key){ + var rst; + if ((node instanceof laya.display.Sprite )){ + var tNode; + tNode=node; + switch (key){ + case "gRec": + rst=NodeUtils.getGRec(tNode).toString(); + break ; + case "gAlpha": + rst=NodeUtils.getGAlpha(tNode)+""; + break ; + case "cmdCount": + rst=NodeUtils.getNodeCmdCount(tNode)+""; + break ; + case "cmdAll": + rst=NodeUtils.getNodeCmdTotalCount(tNode)+""; + break ; + case "nodeAll": + rst=""+NodeUtils.getNodeCount(tNode); + break ; + case "nodeVisible": + rst=""+NodeUtils.getNodeCount(tNode,true); + break ; + case "nodeRender": + rst=""+NodeUtils.getRenderNodeCount(tNode); + break ; + case "nodeReCache": + rst=""+NodeUtils.getReFreshRenderNodeCount(tNode); + break ; + case "renderCost": + rst=""+RenderAnalyser.I.getTime(tNode); + break ; + case "renderCount": + rst=""+RenderAnalyser.I.getCount(tNode); + break ; + default : + rst=node[key]+""; + } + } + else{ + rst=node[key]+""; + } + return rst; + } + + ObjectInfoView.showObject=function(obj){ + var infoView; + infoView=Pool.getItemByClass("ObjectInfoView",ObjectInfoView); + infoView.reset(); + infoView.showObjectInfo(obj); + } + + ObjectInfoView._txts=[]; + return ObjectInfoView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.OutPutView extends laya.debug.view.nodeInfo.views.UIViewBase + var OutPutView=(function(_super){ + function OutPutView(){ + this.view=null; + OutPutView.__super.call(this); + DebugTool._logFun=OutPutView.log; + } + + __class(OutPutView,'laya.debug.view.nodeInfo.views.OutPutView',_super); + var __proto=OutPutView.prototype; + __proto.createPanel=function(){ + this.view=new OutPut(); + DisControlTool.setDragingItem(this.view.txt,this.view); + DisControlTool.setDragingItem(this.view.bg,this.view); + StyleConsts.setViewScale(this.view); + this.view.txt.textField.overflow=Text.SCROLL; + this.view.txt.textField.wordWrap=true; + this.view.on(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this.mouseWheel); + this.view.txt.text=""; + DisControlTool.setResizeAbleEx(this.view); + this.view.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.close); + this.view.clearBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onClearBtn); + this.dis=this.view; + } + + __proto.onClearBtn=function(){ + this.clearText(); + } + + __proto.mouseWheel=function(e){ + this.view.txt.textField.scrollY-=e.delta*10; + } + + __proto.showTxt=function(str){ + this.view.txt.text=str; + this.show(); + this.view.txt.textField.scrollY=this.view.txt.textField.maxScrollY; + } + + __proto.clearText=function(){ + this.view.txt.text=""; + } + + __proto.dTrace=function(__arg){ + var arg=arguments; + if (this.view.txt.textField.scrollY > 1000){ + this.view.txt.text=""; + }; + var str; + var i=0,len=0; + len=arg.length; + str=arg[0]; + for (i=1;i < len;i++){ + str+=" "+arg[i]; + } + this.addStr(str); + } + + __proto.addStr=function(str){ + this.view.txt.text+="\n"+str; + this.show(); + this.view.txt.textField.scrollY=this.view.txt.textField.maxScrollY; + } + + __getset(1,OutPutView,'I',function(){ + if (!OutPutView._I)OutPutView._I=new OutPutView(); + return OutPutView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + OutPutView.log=function(str){ + OutPutView.I.addStr(str); + } + + OutPutView._I=null + return OutPutView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.RenderCostRankView extends laya.debug.view.nodeInfo.views.UIViewBase + var RenderCostRankView=(function(_super){ + function RenderCostRankView(){ + this.view=null; + RenderCostRankView.__super.call(this); + } + + __class(RenderCostRankView,'laya.debug.view.nodeInfo.views.RenderCostRankView',_super); + var __proto=RenderCostRankView.prototype; + __proto.createPanel=function(){ + this.view=new Rank(); + this.view.top=this.view.bottom=this.view.left=this.view.right=0; + this.addChild(this.view); + NodeMenu.I.setNodeListAction(this.view.itemList); + this.view.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.close); + this.view.freshBtn.on(/*laya.events.Event.CLICK*/"click",this,this.fresh); + this.view.itemList.scrollBar.hide=true; + this.view.autoUpdate.on(/*laya.events.Event.CHANGE*/"change",this,this.onAutoUpdateChange); + this.dis=this; + this.view.itemList.array=[]; + this.onAutoUpdateChange(); + this.fresh(); + Laya.timer.once(5000,this,this.fresh); + } + + __proto.onRightClick=function(){ + var list; + list=this.view.itemList; + if (list.selectedItem){ + var tarNode; + tarNode=list.selectedItem.path; + NodeMenu.I.objRightClick(tarNode); + } + } + + __proto.onAutoUpdateChange=function(){ + this.autoUpdate=this.view.autoUpdate.selected; + } + + __proto.fresh=function(){ + this.view.title.text="渲染用时排行("+NodeConsts.RenderCostMaxTime+"ms)"; + var nodeDic; + nodeDic=RenderAnalyser.I.nodeDic; + var key; + var tNode; + var tData; + var dataList; + dataList=[]; + for (key in nodeDic){ + tNode=nodeDic[key]; + if (RenderCostRankView.filterDebugNodes && DisControlTool.isInTree(DebugInfoLayer.I,tNode))continue ; + if (RenderAnalyser.I.getTime(tNode)<=0)continue ; + tData={}; + tData.time=RenderAnalyser.I.getTime(tNode); + if (RenderCostRankView.filterDebugNodes && tNode==Laya.stage){ + tData.time-=RenderAnalyser.I.getTime(DebugInfoLayer.I); + } + tData.path=tNode; + tData.label=ClassTool.getNodeClassAndName(tNode)+":"+tData.time; + dataList.push(tData); + } + dataList.sort(MathTools.sortByKey("time",true,true)); + this.view.itemList.array=dataList; + } + + __getset(0,__proto,'autoUpdate',null,function(v){ + Laya.timer.clear(this,this.fresh); + if (v){ + this.fresh(); + Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.fresh); + } + }); + + __getset(1,RenderCostRankView,'I',function(){ + if (!RenderCostRankView._I) + RenderCostRankView._I=new RenderCostRankView(); + return RenderCostRankView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + RenderCostRankView._I=null + RenderCostRankView.filterDebugNodes=true; + return RenderCostRankView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.ResRankView extends laya.debug.view.nodeInfo.views.UIViewBase + var ResRankView=(function(_super){ + function ResRankView(){ + this.view=null; + ResRankView.__super.call(this); + } + + __class(ResRankView,'laya.debug.view.nodeInfo.views.ResRankView',_super); + var __proto=ResRankView.prototype; + __proto.createPanel=function(){ + this.view=new Rank(); + this.view.top=this.view.bottom=this.view.left=this.view.right=0; + this.addChild(this.view); + this.view.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.close); + this.view.freshBtn.on(/*laya.events.Event.CLICK*/"click",this,this.fresh); + this.view.itemList.scrollBar.hide=true; + this.view.autoUpdate.on(/*laya.events.Event.CHANGE*/"change",this,this.onAutoUpdateChange); + this.dis=this; + this.view.itemList.array=[]; + this.view.itemList.on(/*laya.events.Event.RIGHT_CLICK*/"rightclick",this,this.onRightClick); + this.onAutoUpdateChange(); + this.fresh(); + } + + __proto.onRightClick=function(){ + var list; + list=this.view.itemList; + if (list.selectedItem){ + console.log(list.selectedItem["url"]); + } + } + + __proto.onAutoUpdateChange=function(){ + this.autoUpdate=this.view.autoUpdate.selected; + } + + __proto.fresh=function(){ + this.view.title.text="图片缓存列表"; + var resList; + resList=ResTools.getCachedResList(); + var key; + var tNode; + var tData; + var dataList; + dataList=[]; + var i=0,len=0; + len=resList.length; + for (i=0;i < len;i++){ + tData={}; + var tUrl; + tUrl=resList[i]; + tUrl=tUrl.replace(URL.rootPath,"") + tData.label=tUrl; + tData.url=tUrl; + dataList.push(tData); + } + this.view.itemList.array=dataList; + } + + __getset(0,__proto,'autoUpdate',null,function(v){ + Laya.timer.clear(this,this.fresh); + if (v){ + this.fresh(); + Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.fresh); + } + }); + + __getset(1,ResRankView,'I',function(){ + if (!ResRankView._I) + ResRankView._I=new ResRankView(); + return ResRankView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + ResRankView._I=null + ResRankView.filterDebugNodes=true; + return ResRankView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.SelectInfosView extends laya.debug.view.nodeInfo.views.UIViewBase + var SelectInfosView=(function(_super){ + function SelectInfosView(){ + this.showKeys=[]; + this.view=null; + this.fliterTxt=null; + this.itemList=null; + SelectInfosView.__super.call(this); + SelectInfosView._I=this; + this.setSelectList(null); + } + + __class(SelectInfosView,'laya.debug.view.nodeInfo.views.SelectInfosView',_super); + var __proto=SelectInfosView.prototype; + __proto.createPanel=function(){ + this.view=new SelectInfos(); + this.addChild(this.view); + this.view.top=this.view.bottom=this.view.left=this.view.right=0; + NodeMenu.I.setNodeListAction(this.view.selectList); + this.view.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.close); + this.view.selectList.scrollBar.hide=true; + this.dis=null; + this.view.findBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onFindBtn); + this.fliterTxt=this.view.fliterTxt; + this.view.fliterTxt.on(/*laya.events.Event.ENTER*/"enter",this,this.onFliterTxtChange); + this.view.fliterTxt.on(/*laya.events.Event.BLUR*/"blur",this,this.onFliterTxtChange); + } + + __proto.onFliterTxtChange=function(e){ + var key; + key=this.fliterTxt.text; + if (key==""){ + if (this.showKeys.length !=0){ + this.showKeys.length=0; + this.fresh(); + } + }else + if (key !=this.showKeys.join(",")){ + this.showKeys=key.split(","); + this.fresh(); + } + } + + __proto.onFindBtn=function(){ + FindSmallView.I.show(); + } + + __proto.onRightClick=function(){ + var list; + list=this.view.selectList; + if (list.selectedItem){ + var tarNode; + tarNode=list.selectedItem.path; + NodeMenu.I.objRightClick(tarNode); + } + } + + //} + __proto.setSelectTarget=function(node){ + if (!node)return; + this.setSelectList([node]); + } + + __proto.setSelectList=function(list){ + this.itemList=list; + this.fresh(); + } + + //show(); + __proto.fresh=function(){ + var list; + list=this.itemList; + if (!list || list.length < 1){ + this.view.selectList.array=[]; + return; + }; + var i=0,len=0; + var tDis; + var tData; + len=list.length; + var disList; + disList=[]; + for (i=0;i < len;i++){ + tDis=list[i]; + tData={}; + tData.label=this.getLabelTxt(tDis); + tData.path=tDis; + disList.push(tData); + } + this.view.selectList.array=disList; + } + + __proto.getLabelTxt=function(item){ + var rst; + rst=ClassTool.getNodeClassAndName(item); + var i=0,len=0; + len=this.showKeys.length; + for (i=0;i < len;i++){ + rst+=","+ObjectInfoView.getNodeValue(item,this.showKeys[i]); + } + return rst; + } + + __getset(1,SelectInfosView,'I',function(){ + if (!SelectInfosView._I)SelectInfosView._I=new SelectInfosView(); + return SelectInfosView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + SelectInfosView._I=null + return SelectInfosView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.ToolBarView extends laya.debug.view.nodeInfo.views.UIViewBase + var ToolBarView=(function(_super){ + function ToolBarView(){ + this.view=null; + ToolBarView.__super.call(this); + } + + __class(ToolBarView,'laya.debug.view.nodeInfo.views.ToolBarView',_super); + var __proto=ToolBarView.prototype; + __proto.createPanel=function(){ + this.view=new ToolBar(); + this.addChild(this.view); + DisControlTool.setDragingItem(this.view.bg,this.view); + this.view.on(/*laya.events.Event.CLICK*/"click",this,this.onBtnClick); + this.view.minBtn.minHandler=this.minHandler; + this.view.minBtn.maxHandler=this.maxHandler; + this.view.minBtn.tar=this.view; + this.clickSelectChange(); + this.view.selectWhenClick.on(/*laya.events.Event.CHANGE*/"change",this,this.clickSelectChange); + Notice.listen(/*laya.debug.tools.DisplayHook.ITEM_CLICKED*/"ItemClicked",this,this.itemClicked); + this.dis=this.view; + } + + __proto.itemClicked=function(tar){ + if (!ToolBarView.isClickSelectState)return; + if (DisControlTool.isInTree(this.view.selectWhenClick,tar))return; + if (ToolBarView.ignoreDebugTool){ + if (DebugInfoLayer.I.isDebugItem(tar))return; + } + } + + __proto.clickSelectChange=function(){ + ToolBarView.isClickSelectState=this.view.selectWhenClick.selected; + } + + __proto.firstShowFun=function(){ + this.dis.x=Laya.stage.width-this.dis.width-20; + this.dis.y=5; + } + + __proto.onBtnClick=function(e){ + switch(e.target){ + case this.view.treeBtn: + ToolPanel.I.switchShow(/*laya.debug.view.nodeInfo.ToolPanel.Tree*/"Tree"); + break ; + case this.view.findBtn: + ToolPanel.I.switchShow(/*laya.debug.view.nodeInfo.ToolPanel.Find*/"Find"); + break ; + case this.view.clearBtn: + DebugTool.clearDebugLayer(); + break ; + case this.view.rankBtn: + RenderCostRankView.I.show(); + break ; + case this.view.nodeRankBtn: + ObjectCreateView.I.show(); + break ; + case this.view.cacheBtn: + NodeUtils.showCachedSpriteRecs(); + break ; + } + } + + __getset(1,ToolBarView,'I',function(){ + if (!ToolBarView._I)ToolBarView._I=new ToolBarView(); + return ToolBarView._I; + },laya.debug.view.nodeInfo.views.UIViewBase._$SET_I); + + ToolBarView._I=null + ToolBarView.ignoreDebugTool=true; + ToolBarView.isClickSelectState=false; + return ToolBarView; + })(UIViewBase) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.views.TxtInfoView extends laya.debug.view.nodeInfo.views.UIViewBase + var TxtInfoView=(function(_super){ + function TxtInfoView(){ + this.input=null; + this.btn=null; + TxtInfoView.__super.call(this); + } + + __class(TxtInfoView,'laya.debug.view.nodeInfo.views.TxtInfoView',_super); + var __proto=TxtInfoView.prototype; + __proto.createPanel=function(){ + this.input=new Input(); + this.input.size(200,400); + this.input.multiline=true; + this.input.bgColor="#ff00ff"; + this.input.fontSize=12; + this.input.wordWrap=true; + this.addChild(this.input); + this.btn=this.getButton(); + this.btn.text="关闭"; + this.btn.size(50,20); + this.btn.align="center"; + this.btn.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onCloseBtn); + this.btn.pos(5,this.input.height+5); + this.addChild(this.btn); + } + + __proto.showInfo=function(txt){ + this.input.text=txt; + this.show(); + } + + __proto.show=function(){ + DebugInfoLayer.I.setTop(); + DebugInfoLayer.I.popLayer.addChild(this); + this.x=(Laya.stage.width-this.width); + this.y=0; + } + + __proto.onCloseBtn=function(){ + this.close(); + } + + return TxtInfoView; + })(UIViewBase) + + + //class laya.debug.ui.debugui.CodeUsedResUI extends laya.ui.View + var CodeUsedResUI=(function(_super){ + function CodeUsedResUI(){ + this.tab=null; + CodeUsedResUI.__super.call(this); + } + + __class(CodeUsedResUI,'laya.debug.ui.debugui.CodeUsedResUI',_super); + var __proto=CodeUsedResUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(CodeUsedResUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(CodeUsedResUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":359,"y":91,"skin":"comp/button1.png"},"type":"Image"},{"props":{"x":309,"y":283,"skin":"comp/line2.png"},"type":"Image"},{"type":"Tab","child":[{"props":{"skin":"view/create.png","label":" 对象创建","width":70,"height":17,"name":"item0"},"type":"CheckBox"},{"props":{"x":70,"skin":"view/rendertime.png","label":"渲染用时","width":70,"height":19,"name":"item1"},"type":"CheckBox"},{"props":{"x":140,"skin":"view/cache.png","label":"Cache","width":70,"height":16,"name":"item2"},"type":"CheckBox"}],"props":{"x":76,"y":210,"selectedIndex":0,"var":"tab"}}],"props":{"width":600,"height":400,"base64pic":true}};} + ]); + return CodeUsedResUI; + })(View) + + + //class laya.debug.ui.debugui.comps.ListItemUI extends laya.ui.View + var ListItemUI=(function(_super){ + function ListItemUI(){ + ListItemUI.__super.call(this); + } + + __class(ListItemUI,'laya.debug.ui.debugui.comps.ListItemUI',_super); + var __proto=ListItemUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(ListItemUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(ListItemUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"base64pic":true,"width":244,"height":19},"child":[{"type":"Clip","props":{"y":-1,"skin":"comp/clip_selectBox.png","clipY":2,"height":19,"name":"selectBox","left":2,"right":2,"x":0}},{"type":"Label","props":{"x":25,"text":"render","color":"#dcea36","width":77,"height":17,"name":"label","y":2,"fontSize":12}},{"type":"Clip","props":{"skin":"comp/clip_tree_arrow.png","clipY":2,"name":"arrow","x":8,"y":4,"mouseEnabled":false}}]};} + ]); + return ListItemUI; + })(View) + + + //class laya.debug.ui.debugui.comps.RankListItemUI extends laya.ui.View + var RankListItemUI=(function(_super){ + function RankListItemUI(){ + RankListItemUI.__super.call(this); + } + + __class(RankListItemUI,'laya.debug.ui.debugui.comps.RankListItemUI',_super); + var __proto=RankListItemUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(RankListItemUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(RankListItemUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"y":-1,"skin":"comp/clip_selectBox.png","clipY":2,"height":19,"name":"selectBox","left":0,"right":0,"x":0},"type":"Clip"},{"props":{"text":"render","color":"#a0a0a0","height":15,"name":"label","y":2,"left":11,"right":5,"fontSize":12,"x":11,"width":163},"type":"Label"}],"props":{"width":179,"height":19}};} + ]); + return RankListItemUI; + })(View) + + + //class laya.debug.ui.debugui.DebugPanelUI extends laya.ui.View + var DebugPanelUI=(function(_super){ + function DebugPanelUI(){ + this.bg=null; + this.minBtn=null; + this.treePanel=null; + this.selectWhenClick=null; + this.profilePanel=null; + this.resizeBtn=null; + this.mouseAnalyseBtn=null; + this.dragIcon=null; + this.clearBtn=null; + this.selectPanel=null; + this.tab=null; + DebugPanelUI.__super.call(this); + } + + __class(DebugPanelUI,'laya.debug.ui.debugui.DebugPanelUI',_super); + var __proto=DebugPanelUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(DebugPanelUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.view.nodeInfo.nodetree.MinBtnComp",MinBtnComp); + View.regComponent("laya.debug.view.nodeInfo.views.NodeTreeView",NodeTreeView); + View.regComponent("laya.debug.view.nodeInfo.nodetree.Profile",Profile); + View.regComponent("laya.debug.view.nodeInfo.views.SelectInfosView",SelectInfosView); + } + + __static(DebugPanelUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"base64pic":true,"width":260,"height":400},"child":[{"type":"Image","props":{"x":205,"y":254,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"}},{"type":"Image","props":{"y":0,"skin":"view/bg_top.png","left":0,"right":0}},{"type":"MinBtnComp","props":{"y":-3,"var":"minBtn","runtime":"laya.debug.view.nodeInfo.nodetree.MinBtnComp","right":-3,"x":207}},{"type":"NodeTree","props":{"left":0,"right":0,"top":32,"bottom":0,"name":"节点树","var":"treePanel","runtime":"laya.debug.view.nodeInfo.views.NodeTreeView"}},{"type":"CheckBox","props":{"x":8,"y":9,"skin":"view/clickselect.png","toolTip":"点击选取","var":"selectWhenClick","mouseEnabled":true,"width":14,"height":14}},{"type":"Profile","props":{"name":"性能","top":32,"right":0,"left":0,"bottom":0,"var":"profilePanel","runtime":"laya.debug.view.nodeInfo.nodetree.Profile"}},{"type":"Button","props":{"x":169,"y":247,"skin":"view/resize.png","right":2,"bottom":2,"name":"resizeBtn","var":"resizeBtn","stateNum":3}},{"type":"Clip","props":{"y":9,"skin":"view/clickanalyse.png","var":"mouseAnalyseBtn","toolTip":"拖动选取","left":33,"x":33,"clipY":3}},{"type":"Clip","props":{"y":0,"skin":"view/clickanalyse.png","var":"dragIcon","x":33,"clipY":3}},{"type":"Button","props":{"y":7,"skin":"view/res.png","stateNum":2,"toolTip":"清除边框","var":"clearBtn","right":34,"x":184}},{"type":"SelectInfos","props":{"top":32,"left":0,"right":0,"bottom":0,"name":"选中","var":"selectPanel","runtime":"laya.debug.view.nodeInfo.views.SelectInfosView"}},{"type":"Tab","props":{"x":59,"y":0,"name":"tab","var":"tab","selectedIndex":0},"child":[{"type":"Button","props":{"skin":"view/tab_panel.png","label":"节点","width":42,"height":32,"name":"item0","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":42,"skin":"view/tab_panel.png","label":"查询","width":42,"height":32,"name":"item1","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":84,"skin":"view/tab_panel.png","label":"性能","width":42,"height":32,"name":"item2","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}}]}]};} + ]); + return DebugPanelUI; + })(View) + + + //class laya.debug.ui.debugui.FindNodeSmallUI extends laya.ui.View + var FindNodeSmallUI=(function(_super){ + function FindNodeSmallUI(){ + this.bg=null; + this.closeBtn=null; + this.title=null; + this.typeSelect=null; + this.findTxt=null; + this.findBtn=null; + FindNodeSmallUI.__super.call(this); + } + + __class(FindNodeSmallUI,'laya.debug.ui.debugui.FindNodeSmallUI',_super); + var __proto=FindNodeSmallUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(FindNodeSmallUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(FindNodeSmallUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":185,"y":234,"skin":"view/bg_tool.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg"},"type":"Image"},{"props":{"x":185,"y":15,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2},"type":"Button"},{"props":{"x":6,"y":4,"text":"查找对象","width":67,"height":20,"color":"#288edf","var":"title"},"type":"Label"},{"props":{"x":60,"y":81,"skin":"comp/combobox.png","labels":"name,class","width":63,"height":21,"var":"typeSelect","sizeGrid":"5,35,5,5","labelColors":"#a0a0a0,#fffff,#ffffff#fffff"},"type":"ComboBox"},{"props":{"x":27,"y":83,"text":"类型","width":27,"height":20,"color":"#288edf","align":"right"},"type":"Label"},{"props":{"x":7,"y":40,"text":"包含内容","width":47,"height":20,"color":"#288edf","align":"right"},"type":"Label"},{"props":{"x":60,"y":37,"skin":"comp/textinput.png","text":"Sprite","width":164,"height":22,"var":"findTxt","sizeGrid":"5,5,5,5","color":"#a0a0a0"},"type":"TextInput"},{"props":{"x":158,"y":79,"skin":"comp/button.png","label":"查找","width":65,"height":23,"var":"findBtn","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"},"type":"Button"}],"props":{"base64pic":true,"width":233,"height":120}};} + ]); + return FindNodeSmallUI; + })(View) + + + //class laya.debug.ui.debugui.FindNodeUI extends laya.ui.View + var FindNodeUI=(function(_super){ + function FindNodeUI(){ + this.bg=null; + this.closeBtn=null; + this.title=null; + this.typeSelect=null; + this.findTxt=null; + this.result=null; + this.findBtn=null; + FindNodeUI.__super.call(this); + } + + __class(FindNodeUI,'laya.debug.ui.debugui.FindNodeUI',_super); + var __proto=FindNodeUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(FindNodeUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.RankListItem",RankListItem); + } + + __static(FindNodeUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":185,"y":234,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":185,"y":15,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2},"type":"Button"},{"props":{"x":6,"y":4,"text":"查找对象","width":67,"height":20,"color":"#88ef19","var":"title"},"type":"Label"},{"props":{"x":52,"y":75,"skin":"comp/combobox.png","labels":"name,class","width":63,"height":21,"var":"typeSelect","sizeGrid":"5,35,5,5","labelColors":"#a0a0a0,#fffff,#ffffff#fffff"},"type":"ComboBox"},{"props":{"x":10,"y":77,"text":"类型","width":27,"height":20,"color":"#88ef19","align":"right"},"type":"Label"},{"props":{"x":7,"y":34,"text":"包含内容","width":47,"height":20,"color":"#88ef19","align":"right"},"type":"Label"},{"props":{"x":59,"y":31,"skin":"comp/textinput.png","text":"Sprite","width":131,"height":22,"var":"findTxt","sizeGrid":"5,5,5,5","color":"#a0a0a0"},"type":"TextInput"},{"type":"List","child":[{"type":"RankListItem","props":{"y":30,"left":5,"right":5,"name":"render","x":30,"runtime":"laya.debug.uicomps.RankListItem"}}],"props":{"x":6,"y":106,"width":188,"height":180,"vScrollBarSkin":"comp/vscroll.png","var":"result"}},{"props":{"x":125,"y":73,"skin":"comp/button.png","label":"查找","width":65,"height":23,"var":"findBtn","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"},"type":"Button"}],"props":{"width":200,"height":300,"base64pic":true}};} + ]); + return FindNodeUI; + })(View) + + + //class laya.debug.ui.debugui.MinBtnCompUI extends laya.ui.View + var MinBtnCompUI=(function(_super){ + function MinBtnCompUI(){ + this.minBtn=null; + this.maxUI=null; + this.bg=null; + this.maxBtn=null; + MinBtnCompUI.__super.call(this); + } + + __class(MinBtnCompUI,'laya.debug.ui.debugui.MinBtnCompUI',_super); + var __proto=MinBtnCompUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(MinBtnCompUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(MinBtnCompUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":7,"y":8,"skin":"comp/minBtn.png","stateNum":"3","var":"minBtn","width":22,"height":20,"toolTip":"最小化"},"type":"Button"},{"type":"Box","child":[{"props":{"x":0,"y":0,"skin":"view/bg_panel.png","var":"bg","width":36,"height":36,"sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":6,"y":8,"skin":"view/zoom_out.png","stateNum":"2","var":"maxBtn"},"type":"Button"}],"props":{"var":"maxUI"}}],"props":{"width":36,"height":36,"base64pic":true}};} + ]); + return MinBtnCompUI; + })(View) + + + //class laya.debug.ui.debugui.NodeListPanelUI extends laya.ui.View + var NodeListPanelUI=(function(_super){ + function NodeListPanelUI(){ + this.bg=null; + this.closeBtn=null; + this.title=null; + this.itemList=null; + NodeListPanelUI.__super.call(this); + } + + __class(NodeListPanelUI,'laya.debug.ui.debugui.NodeListPanelUI',_super); + var __proto=NodeListPanelUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(NodeListPanelUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.RankListItem",RankListItem); + } + + __static(NodeListPanelUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":235,"y":284,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":204,"y":32,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2,"visible":true},"type":"Button"},{"props":{"x":10,"y":6,"text":"节点信息","width":147,"height":16,"color":"#288edf","var":"title"},"type":"Label"},{"type":"List","child":[{"type":"RankListItem","props":{"left":5,"right":5,"name":"render","runtime":"laya.debug.uicomps.RankListItem"}}],"props":{"vScrollBarSkin":"comp/vscroll.png","var":"itemList","left":2,"right":2,"top":26,"bottom":0,"repeatX":1,"x":20}}],"props":{"width":200,"height":300}};} + ]); + return NodeListPanelUI; + })(View) + + + //class laya.debug.ui.debugui.NodeToolUI extends laya.ui.View + var NodeToolUI=(function(_super){ + function NodeToolUI(){ + this.bg=null; + this.closeBtn=null; + this.tarTxt=null; + this.freshBtn=null; + this.mouseAnalyseBtn=null; + this.dragIcon=null; + NodeToolUI.__super.call(this); + } + + __class(NodeToolUI,'laya.debug.ui.debugui.NodeToolUI',_super); + var __proto=NodeToolUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(NodeToolUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(NodeToolUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"base64pic":true,"width":200,"height":341},"child":[{"type":"Image","props":{"x":195,"y":244,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"}},{"type":"Label","props":{"x":9,"y":5,"text":"当前选中对象","width":67,"height":16,"color":"#a0a0a0"}},{"type":"Button","props":{"x":195,"y":25,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2}},{"type":"Label","props":{"x":10,"y":25,"text":"当前对象","width":67,"height":16,"color":"#a0a0a0","var":"tarTxt"}},{"type":"Button","props":{"x":15,"y":65,"skin":"comp/button.png","label":"父链","width":39,"height":23,"mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":66,"y":65,"skin":"comp/button.png","label":"子","width":35,"height":23,"mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":112,"y":65,"skin":"comp/button.png","label":"兄弟","width":49,"height":23,"mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":13,"y":117,"skin":"comp/button.png","label":"Enable链","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":100,"y":117,"skin":"comp/button.png","label":"Size链","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Label","props":{"x":14,"y":97,"text":"节点链信息","width":67,"height":16,"color":"#a0a0a0"}},{"type":"Label","props":{"x":15,"y":45,"text":"对象选取","width":67,"height":16,"color":"#a0a0a0"}},{"type":"Label","props":{"x":16,"y":145,"text":"节点显示","width":67,"height":16,"color":"#a0a0a0"}},{"type":"Button","props":{"x":13,"y":164,"skin":"comp/button.png","label":"隐藏旁支","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":100,"y":164,"skin":"comp/button.png","label":"隐藏兄弟","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":13,"y":197,"skin":"comp/button.png","label":"隐藏子","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":99,"y":197,"skin":"comp/button.png","label":"恢复","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Label","props":{"x":15,"y":228,"text":"其他","width":67,"height":16,"color":"#a0a0a0"}},{"type":"Button","props":{"x":12,"y":247,"skin":"comp/button.png","label":"节点树定位","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":99,"y":247,"skin":"comp/button.png","label":"显示边框","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Label","props":{"x":12,"y":315,"text":"Alt+A分析鼠标能否够点中对象","width":173,"height":16,"color":"#a0a0a0"}},{"type":"Button","props":{"x":156,"y":1,"skin":"view/refresh2.png","var":"freshBtn","left":156,"toolTip":"recache节点"}},{"type":"Button","props":{"x":12,"y":279,"skin":"comp/button.png","label":"输出到控制台","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Button","props":{"x":99,"y":279,"skin":"comp/button.png","label":"显示切换","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"}},{"type":"Clip","props":{"y":44,"skin":"view/clickanalyse.png","var":"mouseAnalyseBtn","toolTip":"拖动到对象上方判断是否能够点中","left":84,"x":84,"clipY":3}},{"type":"Clip","props":{"y":35,"skin":"view/clickanalyse.png","var":"dragIcon","x":94,"clipY":3}}]};} + ]); + return NodeToolUI; + })(View) + + + //class laya.debug.ui.debugui.NodeTreeSettingUI extends laya.ui.View + var NodeTreeSettingUI=(function(_super){ + function NodeTreeSettingUI(){ + this.bg=null; + this.showTxt=null; + this.okBtn=null; + this.closeBtn=null; + NodeTreeSettingUI.__super.call(this); + } + + __class(NodeTreeSettingUI,'laya.debug.ui.debugui.NodeTreeSettingUI',_super); + var __proto=NodeTreeSettingUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(NodeTreeSettingUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(NodeTreeSettingUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":0,"y":0,"skin":"view/bg_panel.png","left":0,"top":0,"bottom":0,"right":0,"var":"bg","width":200,"height":300,"sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":9,"y":7,"text":"要显示的属性","width":76,"height":16,"color":"#ffffff","align":"left"},"type":"Label"},{"props":{"x":6,"y":29,"skin":"comp/textinput.png","text":"x\\ny\\nwidth\\nheight","width":188,"height":230,"multiline":true,"var":"showTxt","color":"#a0a0a0","sizeGrid":"5,5,5,5"},"type":"TextInput"},{"props":{"x":57,"y":269,"skin":"comp/button.png","label":"确定","var":"okBtn","mouseEnabled":"true","labelColors":"#ffffff,#ffffff,#ffffff,#ffffff"},"type":"Button"},{"props":{"x":175,"y":5,"skin":"view/btn_close.png","var":"closeBtn"},"type":"Button"}],"props":{"base64pic":true,"width":200,"height":300}};} + ]); + return NodeTreeSettingUI; + })(View) + + + //class laya.debug.ui.debugui.NodeTreeUI extends laya.ui.View + var NodeTreeUI=(function(_super){ + function NodeTreeUI(){ + this.nodeTree=null; + this.controlBar=null; + this.settingBtn=null; + this.freshBtn=null; + this.fliterTxt=null; + this.closeBtn=null; + this.ifShowProps=null; + NodeTreeUI.__super.call(this); + } + + __class(NodeTreeUI,'laya.debug.ui.debugui.NodeTreeUI',_super); + var __proto=NodeTreeUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(NodeTreeUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.TreeListItem",TreeListItem); + } + + __static(NodeTreeUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"width":200,"height":260,"base64pic":true},"child":[{"type":"Image","props":{"x":-22,"y":-47,"skin":"view/bg_panel.png","width":211,"height":206,"left":0,"right":0,"top":0,"bottom":0,"sizeGrid":"5,5,5,5"}},{"props":{"y":0,"skin":"view/bg_tool.png","left":0,"right":0},"type":"Image"},{"type":"Tree","props":{"x":0,"scrollBarSkin":"comp/vscroll.png","width":195,"height":229,"var":"nodeTree","left":0,"right":0,"top":38,"bottom":20},"child":[{"type":"ListItem","props":{"y":0,"name":"render","left":0,"right":0,"runtime":"laya.debug.uicomps.TreeListItem"}}]},{"type":"Box","props":{"x":3,"y":5,"var":"controlBar","left":3,"right":3,"top":5,"height":23},"child":[{"type":"Button","props":{"x":6,"skin":"view/setting.png","stateNum":3,"var":"settingBtn","toolTip":"设置显示的属性","y":6}},{"type":"Button","props":{"y":6,"skin":"view/refresh.png","var":"freshBtn","left":30,"toolTip":"刷新数据"}},{"type":"TextInput","props":{"y":0,"skin":"view/bg_top.png","height":22,"var":"fliterTxt","left":53,"right":0,"color":"#a0a0a0"}},{"type":"Button","props":{"x":172,"y":2,"skin":"view/btn_close.png","var":"closeBtn","right":1,"visible":false}}]},{"props":{"y":243,"skin":"comp/checkbox.png","label":"显示属性","var":"ifShowProps","bottom":3,"selected":true,"visible":true,"x":2,"width":70,"height":14,"labelColors":"#a0a0a0,#fffff,#ffffff,#fffff"},"type":"CheckBox"}]};} + ]); + return NodeTreeUI; + })(View) + + + //class laya.debug.ui.debugui.ObjectCreateUI extends laya.ui.View + var ObjectCreateUI=(function(_super){ + function ObjectCreateUI(){ + this.bg=null; + this.closeBtn=null; + this.itemList=null; + this.freshBtn=null; + ObjectCreateUI.__super.call(this); + } + + __class(ObjectCreateUI,'laya.debug.ui.debugui.ObjectCreateUI',_super); + var __proto=ObjectCreateUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(ObjectCreateUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.RankListItem",RankListItem); + } + + __static(ObjectCreateUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":215,"y":264,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":184,"y":12,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2,"visible":false},"type":"Button"},{"props":{"x":11,"y":5,"text":"对象创建统计","width":83,"height":16,"color":"#288edf"},"type":"Label"},{"type":"List","child":[{"type":"RankListItem","props":{"y":0,"left":5,"right":5,"name":"render","runtime":"laya.debug.uicomps.RankListItem"}}],"props":{"vScrollBarSkin":"comp/vscroll.png","var":"itemList","top":26,"bottom":5,"left":5,"right":5,"repeatX":1}},{"props":{"y":1,"skin":"view/refresh2.png","var":"freshBtn","toolTip":"刷新数据","right":1,"x":178},"type":"Button"}],"props":{"width":200,"height":300,"base64pic":true}};} + ]); + return ObjectCreateUI; + })(View) + + + //class laya.debug.ui.debugui.ObjectInfoUI extends laya.ui.View + var ObjectInfoUI=(function(_super){ + function ObjectInfoUI(){ + this.bg=null; + this.title=null; + this.showTxt=null; + this.closeBtn=null; + this.autoUpdate=null; + this.settingBtn=null; + ObjectInfoUI.__super.call(this); + } + + __class(ObjectInfoUI,'laya.debug.ui.debugui.ObjectInfoUI',_super); + var __proto=ObjectInfoUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(ObjectInfoUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(ObjectInfoUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":-1,"y":0,"skin":"view/bg_panel.png","left":-1,"right":1,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":7,"y":5,"text":"对象类型","width":67,"height":20,"color":"#ffffff","var":"title","left":7,"right":6},"type":"Label"},{"props":{"x":2,"skin":"comp/textinput.png","text":"属性内容","width":196,"height":228,"left":2,"right":2,"var":"showTxt","top":25,"bottom":20,"editable":false,"multiline":true,"sizeGrid":"5,5,5,5","color":"#a0a0a0"},"type":"TextArea"},{"props":{"x":178,"y":4,"skin":"view/btn_close.png","var":"closeBtn","top":4,"right":2},"type":"Button"},{"props":{"skin":"comp/checkbox.png","label":"自动刷新属性","var":"autoUpdate","bottom":2,"x":3,"labelColors":"#a0a0a0,#fffff,#ffffff,#fffff"},"type":"CheckBox"},{"props":{"x":164,"skin":"view/setting.png","stateNum":"3","var":"settingBtn","y":6,"top":6,"right":24,"toolTip":"设置显示属性"},"type":"Button"},{"props":{"x":179,"y":257,"skin":"view/resize.png","right":2,"bottom":2,"name":"resizeBtn","stateNum":3},"type":"Button"}],"props":{"base64pic":true,"width":200,"height":200}};} + ]); + return ObjectInfoUI; + })(View) + + + //class laya.debug.ui.debugui.OutPutUI extends laya.ui.View + var OutPutUI=(function(_super){ + function OutPutUI(){ + this.bg=null; + this.txt=null; + this.closeBtn=null; + this.clearBtn=null; + OutPutUI.__super.call(this); + } + + __class(OutPutUI,'laya.debug.ui.debugui.OutPutUI',_super); + var __proto=OutPutUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(OutPutUI.uiView); + } + + __proto.viewMapRegists=function(){} + __static(OutPutUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"width":300,"height":200,"base64pic":true},"child":[{"type":"Image","props":{"x":205,"y":254,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"}},{"type":"Label","props":{"skin":"comp/textarea.png","text":"TextArea","color":"#a0a0a0","var":"txt","left":5,"right":5,"top":22,"bottom":5,"mouseEnabled":true,"sizeGrid":"3,3,3,3"}},{"type":"Button","props":{"x":185,"y":15,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2}},{"props":{"x":253,"y":1,"skin":"view/re.png","stateNum":"2","var":"clearBtn","right":25},"type":"Button"},{"props":{"x":169,"y":247,"skin":"view/resize.png","right":2,"bottom":2,"name":"resizeBtn","stateNum":3},"type":"Button"}]};} + ]); + return OutPutUI; + })(View) + + + //class laya.debug.ui.debugui.ProfileUI extends laya.ui.View + var ProfileUI=(function(_super){ + function ProfileUI(){ + this.renderPanel=null; + this.createPanel=null; + this.cachePanel=null; + this.tab=null; + this.resPanel=null; + ProfileUI.__super.call(this); + } + + __class(ProfileUI,'laya.debug.ui.debugui.ProfileUI',_super); + var __proto=ProfileUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(ProfileUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.view.nodeInfo.views.RenderCostRankView",RenderCostRankView); + View.regComponent("laya.debug.view.nodeInfo.views.ObjectCreateView",ObjectCreateView); + View.regComponent("laya.debug.view.nodeInfo.views.CacheRankView",CacheRankView); + View.regComponent("laya.debug.view.nodeInfo.views.ResRankView",ResRankView); + } + + __static(ProfileUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"width":260,"height":329,"base64pic":true},"child":[{"type":"Image","props":{"y":0,"skin":"view/bg_tool.png","right":0,"left":0}},{"type":"Rank","props":{"var":"renderPanel","top":29,"runtime":"laya.debug.view.nodeInfo.views.RenderCostRankView","right":0,"name":"渲染用时","left":0,"bottom":0}},{"type":"ObjectCreate","props":{"var":"createPanel","top":29,"runtime":"laya.debug.view.nodeInfo.views.ObjectCreateView","right":0,"name":"对象创建统计","left":0,"bottom":0}},{"type":"Rank","props":{"x":10,"var":"cachePanel","top":29,"runtime":"laya.debug.view.nodeInfo.views.CacheRankView","right":0,"name":"cache用时","left":0,"bottom":0}},{"type":"Tab","props":{"y":9,"x":7,"width":191,"var":"tab","selectedIndex":0,"height":19},"child":[{"type":"CheckBox","props":{"y":0,"x":0,"width":50,"skin":"view/create.png","name":"item0","labelColors":"#a0a0a0,#ffffff,#ffffff,#ffffff","label":" 对象","height":17}},{"type":"CheckBox","props":{"y":0,"x":55,"width":50,"skin":"view/rendertime.png","name":"item1","labelColors":"#a0a0a0,#ffffff,#ffffff,#ffffff","label":" 渲染","height":19}},{"type":"CheckBox","props":{"y":0,"x":110,"width":50,"skin":"view/cache.png","name":"item2","labelColors":"#a0a0a0,#ffffff,#ffffff,#ffffff","label":" 重绘","height":16}},{"type":"CheckBox","props":{"y":0,"x":165,"width":50,"skin":"view/cache.png","name":"item3","labelColors":"#a0a0a0,#ffffff,#ffffff,#ffffff","label":" 资源","height":16}}]},{"type":"Rank","props":{"y":40,"x":50,"var":"resPanel","top":29,"runtime":"laya.debug.view.nodeInfo.views.ResRankView","right":0,"name":"资源缓存","left":0,"bottom":0}}]};} + ]); + return ProfileUI; + })(View) + + + //class laya.debug.ui.debugui.RankUI extends laya.ui.View + var RankUI=(function(_super){ + function RankUI(){ + this.bg=null; + this.closeBtn=null; + this.title=null; + this.itemList=null; + this.autoUpdate=null; + this.freshBtn=null; + RankUI.__super.call(this); + } + + __class(RankUI,'laya.debug.ui.debugui.RankUI',_super); + var __proto=RankUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(RankUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.RankListItem",RankListItem); + } + + __static(RankUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":225,"y":274,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"x":194,"y":22,"skin":"view/btn_close.png","var":"closeBtn","top":2,"right":2,"visible":false},"type":"Button"},{"props":{"x":8,"y":5,"text":"渲染用时表(3000ms)","width":109,"height":16,"color":"#288edf","var":"title"},"type":"Label"},{"type":"List","child":[{"type":"RankListItem","props":{"left":5,"right":5,"name":"render","runtime":"laya.debug.uicomps.RankListItem"}}],"props":{"vScrollBarSkin":"comp/vscroll.png","var":"itemList","left":2,"right":2,"top":26,"bottom":25,"repeatX":1,"x":10,"y":10}},{"props":{"skin":"comp/checkbox.png","label":"自动刷新属性","var":"autoUpdate","bottom":3,"selected":false,"visible":true,"left":2,"labelColors":"#a0a0a0,#fffff,#ffffff,#fffff"},"type":"CheckBox"},{"props":{"y":1,"skin":"view/refresh2.png","var":"freshBtn","toolTip":"刷新数据","right":1},"type":"Button"}],"props":{"width":200,"height":300}};} + ]); + return RankUI; + })(View) + + + //class laya.debug.ui.debugui.SelectInfosUI extends laya.ui.View + var SelectInfosUI=(function(_super){ + function SelectInfosUI(){ + this.bg=null; + this.closeBtn=null; + this.selectList=null; + this.findBtn=null; + this.fliterTxt=null; + SelectInfosUI.__super.call(this); + } + + __class(SelectInfosUI,'laya.debug.ui.debugui.SelectInfosUI',_super); + var __proto=SelectInfosUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(SelectInfosUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.uicomps.RankListItem",RankListItem); + } + + __static(SelectInfosUI, + ['uiView',function(){return this.uiView={"type":"View","child":[{"props":{"x":205,"y":254,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"},"type":"Image"},{"props":{"skin":"view/btn_close.png","var":"closeBtn","top":32,"visible":false,"right":2},"type":"Button"},{"props":{"x":7,"y":36,"text":"当前选中列表","width":83,"height":16,"color":"#288edf"},"type":"Label"},{"type":"List","child":[{"type":"RankListItem","props":{"left":5,"right":5,"name":"render","runtime":"laya.debug.uicomps.RankListItem"}}],"props":{"vScrollBarSkin":"comp/vscroll.png","var":"selectList","left":5,"right":5,"top":56,"bottom":25,"repeatX":1,"x":20}},{"props":{"x":6,"text":"Alt+V选取鼠标下的对象","width":189,"height":16,"color":"#a0a0a0","bottom":3},"type":"Label"},{"type":"Image","props":{"y":0,"skin":"view/bg_tool.png","left":0,"right":0}},{"type":"Clip","props":{"y":6,"skin":"view/search.png","clipY":2,"var":"findBtn","right":5,"toolTip":"查找","x":174}},{"type":"TextInput","props":{"y":6,"skin":"view/bg_top.png","height":22,"var":"fliterTxt","left":8,"right":45,"color":"#a0a0a0","x":8,"width":147}}],"props":{"width":200,"height":300,"base64pic":true}};} + ]); + return SelectInfosUI; + })(View) + + + //class laya.debug.ui.debugui.ToolBarUI extends laya.ui.View + var ToolBarUI=(function(_super){ + function ToolBarUI(){ + this.bg=null; + this.treeBtn=null; + this.findBtn=null; + this.minBtn=null; + this.selectWhenClick=null; + this.clearBtn=null; + this.rankBtn=null; + this.nodeRankBtn=null; + this.cacheBtn=null; + ToolBarUI.__super.call(this); + } + + __class(ToolBarUI,'laya.debug.ui.debugui.ToolBarUI',_super); + var __proto=ToolBarUI.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + laya.ui.Component.prototype.createChildren.call(this); + this.createView(ToolBarUI.uiView); + } + + __proto.viewMapRegists=function(){ + View.regComponent("laya.debug.view.nodeInfo.nodetree.MinBtnComp",MinBtnComp); + } + + __static(ToolBarUI, + ['uiView',function(){return this.uiView={"type":"View","props":{"base64pic":true,"width":250,"height":30},"child":[{"type":"Image","props":{"x":195,"y":244,"skin":"view/bg_panel.png","left":0,"right":0,"top":0,"bottom":0,"var":"bg","sizeGrid":"5,5,5,5"}},{"type":"Button","props":{"x":2,"y":6,"skin":"view/save.png","stateNum":2,"var":"treeBtn","toolTip":"节点树"}},{"type":"Button","props":{"x":25,"y":6,"skin":"view/save.png","stateNum":2,"var":"findBtn","toolTip":"查找面板"}},{"type":"MinBtnComp","props":{"x":218,"y":-3,"var":"minBtn","runtime":"laya.debug.view.nodeInfo.nodetree.MinBtnComp"}},{"type":"CheckBox","props":{"x":124,"y":8,"skin":"comp/checkbox.png","label":"点击选取","var":"selectWhenClick","labelColors":"#a0a0a0,#fffff,#ffffff,#fffff"}},{"type":"Button","props":{"x":193,"y":5,"skin":"view/res.png","stateNum":2,"toolTip":"清除边框","var":"clearBtn"}},{"type":"Button","props":{"x":49,"y":6,"skin":"view/save.png","stateNum":2,"var":"rankBtn","toolTip":"渲染用时排行"}},{"type":"Button","props":{"x":72,"y":6,"skin":"view/save.png","stateNum":2,"var":"nodeRankBtn","toolTip":"创建对象排行"}},{"type":"Button","props":{"x":94,"y":6,"skin":"view/save.png","stateNum":2,"var":"cacheBtn","toolTip":"cache对象"}}]};} + ]); + return ToolBarUI; + })(View) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2016-7-6 上午9:42:46 + */ + //class laya.debug.uicomps.ListBase extends laya.ui.List + var ListBase=(function(_super){ + function ListBase(){ + ListBase.__super.call(this); + } + + __class(ListBase,'laya.debug.uicomps.ListBase',_super); + var __proto=ListBase.prototype; + __getset(0,__proto,'selectedIndex',_super.prototype._$get_selectedIndex,function(value){ + if (this._selectedIndex !=value){ + this._selectedIndex=value; + this.changeSelectStatus(); + this.event(/*laya.events.Event.CHANGE*/"change"); + this.selectHandler && this.selectHandler.runWith(value); + } + if (this.selectEnable && this._scrollBar){ + var numX=this._isVertical ? this.repeatX :this.repeatY; + if (value < this._startIndex || (value+numX > this._startIndex+this.repeatX *this.repeatY)){ + this.scrollTo(value); + } + } + }); + + return ListBase; + })(List) + + + /** + * + *@author ww + *@version 1.0 + * + *@created 2016-7-6 上午9:49:47 + */ + //class laya.debug.uicomps.TreeBase extends laya.ui.Tree + var TreeBase=(function(_super){ + function TreeBase(){ + TreeBase.__super.call(this); + } + + __class(TreeBase,'laya.debug.uicomps.TreeBase',_super); + var __proto=TreeBase.prototype; + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._list=new ListBase()); + this._list.renderHandler=Handler.create(this,this.renderItem,null,false); + this._list.repeatX=1; + this._list.on(/*laya.events.Event.CHANGE*/"change",this,this.onListChange); + } + + return TreeBase; + })(Tree) + + + /** + *... + *@author ww + */ + //class laya.debug.uicomps.RankListItem extends laya.debug.ui.debugui.comps.RankListItemUI + var RankListItem=(function(_super){ + function RankListItem(){ + RankListItem.__super.call(this); + Base64AtlasManager.replaceRes(RankListItemUI.uiView); + this.createView(RankListItemUI.uiView); + } + + __class(RankListItem,'laya.debug.uicomps.RankListItem',_super); + var __proto=RankListItem.prototype; + __proto.createChildren=function(){} + return RankListItem; + })(RankListItemUI) + + + /** + *... + *@author ww + */ + //class laya.debug.uicomps.TreeListItem extends laya.debug.ui.debugui.comps.ListItemUI + var TreeListItem=(function(_super){ + function TreeListItem(){ + TreeListItem.__super.call(this); + Base64AtlasManager.replaceRes(ListItemUI.uiView); + this.createView(ListItemUI.uiView); + } + + __class(TreeListItem,'laya.debug.uicomps.TreeListItem',_super); + var __proto=TreeListItem.prototype; + __proto.createChildren=function(){} + return TreeListItem; + })(ListItemUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.DebugPanel extends laya.debug.ui.debugui.DebugPanelUI + var DebugPanel=(function(_super){ + function DebugPanel(){ + this.views=null; + DebugPanel.__super.call(this); + this.msRec=new Rectangle(); + Base64AtlasManager.replaceRes(DebugPanelUI.uiView); + this.createView(DebugPanelUI.uiView); + DisControlTool.setResizeAbleEx(this); + this.views=[this.treePanel,this.selectPanel,this.profilePanel]; + this.tab.selectedIndex=0; + this.tabChange(); + this.tab.on(/*laya.events.Event.CHANGE*/"change",this,this.tabChange); + this.changeSize(); + } + + __class(DebugPanel,'laya.debug.view.nodeInfo.nodetree.DebugPanel',_super); + var __proto=DebugPanel.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + __proto.tabChange=function(){ + DisControlTool.addOnlyByIndex(this.views,this.tab.selectedIndex,this); + DisControlTool.setTop(this.resizeBtn); + } + + __proto.changeSize=function(){ + if (this.width < 245){ + this.width=245; + } + if (this.height < 100){ + this.height=200; + } + laya.ui.Component.prototype.changeSize.call(this); + this.msRec.setTo(0,0,this.width,this.height); + this.scrollRect=this.msRec; + } + + return DebugPanel; + })(DebugPanelUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.FindNode extends laya.debug.ui.debugui.FindNodeUI + var FindNode=(function(_super){ + function FindNode(){ + FindNode.__super.call(this); + Base64AtlasManager.replaceRes(FindNodeUI.uiView); + this.createView(FindNodeUI.uiView); + } + + __class(FindNode,'laya.debug.view.nodeInfo.nodetree.FindNode',_super); + var __proto=FindNode.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + return FindNode; + })(FindNodeUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.FindNodeSmall extends laya.debug.ui.debugui.FindNodeSmallUI + var FindNodeSmall=(function(_super){ + function FindNodeSmall(){ + FindNodeSmall.__super.call(this); + Base64AtlasManager.replaceRes(FindNodeSmallUI.uiView); + this.createView(FindNodeSmallUI.uiView); + } + + __class(FindNodeSmall,'laya.debug.view.nodeInfo.nodetree.FindNodeSmall',_super); + var __proto=FindNodeSmall.prototype; + __proto.createChildren=function(){} + return FindNodeSmall; + })(FindNodeSmallUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.MinBtnComp extends laya.debug.ui.debugui.MinBtnCompUI + var MinBtnComp=(function(_super){ + function MinBtnComp(){ + this.tar=null; + this.minHandler=null; + this.maxHandler=null; + this.prePos=new Point(); + MinBtnComp.__super.call(this); + Base64AtlasManager.replaceRes(MinBtnCompUI.uiView); + this.createView(MinBtnCompUI.uiView); + this.init(); + } + + __class(MinBtnComp,'laya.debug.view.nodeInfo.nodetree.MinBtnComp',_super); + var __proto=MinBtnComp.prototype; + __proto.createChildren=function(){} + __proto.init=function(){ + this.minBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onMinBtn); + this.maxBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onMaxBtn); + this.minState=false; + this.maxUI.removeSelf(); + DisControlTool.setDragingItem(this.bg,this.maxUI); + } + + __proto.onMaxBtn=function(){ + this.maxUI.removeSelf(); + if (this.maxHandler){ + this.maxHandler.run(); + } + if (this.tar){ + this.tar.x+=this.maxUI.x-this.prePos.x; + this.tar.y+=this.maxUI.y-this.prePos.y; + } + } + + __proto.onMinBtn=function(){ + if (!this.displayedInStage)return; + var tPos; + tPos=Point.TEMP; + tPos.setTo(0,0); + tPos=this.localToGlobal(tPos); + tPos=DebugInfoLayer.I.popLayer.globalToLocal(tPos); + this.maxUI.pos(tPos.x,tPos.y); + DebugInfoLayer.I.popLayer.addChild(this.maxUI); + if (this.tar){ + this.prePos.setTo(tPos.x,tPos.y); + } + if (this.minHandler){ + this.minHandler.run(); + } + } + + __getset(0,__proto,'minState',null,function(v){ + }); + + return MinBtnComp; + })(MinBtnCompUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.NodeListPanel extends laya.debug.ui.debugui.NodeListPanelUI + var NodeListPanel=(function(_super){ + function NodeListPanel(){ + NodeListPanel.__super.call(this); + Base64AtlasManager.replaceRes(NodeListPanelUI.uiView); + this.createView(NodeListPanelUI.uiView); + } + + __class(NodeListPanel,'laya.debug.view.nodeInfo.nodetree.NodeListPanel',_super); + var __proto=NodeListPanel.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + return NodeListPanel; + })(NodeListPanelUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.NodeTool extends laya.debug.ui.debugui.NodeToolUI + var NodeTool=(function(_super){ + function NodeTool(){ + NodeTool.__super.call(this); + Base64AtlasManager.replaceRes(NodeToolUI.uiView); + this.createView(NodeToolUI.uiView); + } + + __class(NodeTool,'laya.debug.view.nodeInfo.nodetree.NodeTool',_super); + var __proto=NodeTool.prototype; + __proto.createChildren=function(){} + return NodeTool; + })(NodeToolUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.NodeTreeSetting extends laya.debug.ui.debugui.NodeTreeSettingUI + var NodeTreeSetting=(function(_super){ + function NodeTreeSetting(){ + NodeTreeSetting.__super.call(this); + Base64AtlasManager.replaceRes(NodeTreeSettingUI.uiView); + this.createView(NodeTreeSettingUI.uiView); + } + + __class(NodeTreeSetting,'laya.debug.view.nodeInfo.nodetree.NodeTreeSetting',_super); + var __proto=NodeTreeSetting.prototype; + //inits(); + __proto.createChildren=function(){} + return NodeTreeSetting; + })(NodeTreeSettingUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.NodeTree extends laya.debug.ui.debugui.NodeTreeUI + var NodeTree=(function(_super){ + function NodeTree(){ + this.showProps=false; + this._closeSettingHandler=null; + this._tar=null; + NodeTree.__super.call(this); + Base64AtlasManager.replaceRes(NodeTreeUI.uiView); + View.regComponent("Tree",TreeBase); + this.createView(NodeTreeUI.uiView); + View.regComponent("Tree",Tree); + this.inits(); + NodeTree.I=this; + } + + __class(NodeTree,'laya.debug.view.nodeInfo.nodetree.NodeTree',_super); + var __proto=NodeTree.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + __proto.inits=function(){ + this.nodeTree.list.scrollBar.hide=true; + this.nodeTree.list.selectEnable=true; + this.settingBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onSettingBtn); + this.freshBtn.on(/*laya.events.Event.CLICK*/"click",this,this.fresh); + this.closeBtn.on(/*laya.events.Event.CLICK*/"click",this,this.onCloseBtn); + this.fliterTxt.on(/*laya.events.Event.ENTER*/"enter",this,this.onFliterTxtChange); + this.fliterTxt.on(/*laya.events.Event.BLUR*/"blur",this,this.onFliterTxtChange); + NodeMenu.I.setNodeListAction(this.nodeTree.list); + this.nodeTree.list.on(/*laya.events.Event.CLICK*/"click",this,this.onListClick,[this.nodeTree.list]); + this.nodeTree.renderHandler=new Handler(this,this.treeRender); + this._closeSettingHandler=new Handler(this,this.closeSetting); + this.onIfShowPropsChange(); + this.ifShowProps.on(/*laya.events.Event.CHANGE*/"change",this,this.onIfShowPropsChange); + } + + __proto.onIfShowPropsChange=function(){ + this.showProps=this.ifShowProps.selected; + this.fresh(); + } + + __proto.onListClick=function(list){ + if (list.selectedItem){ + if (list.selectedItem.isDirectory){ + list.selectedItem.isOpen=!list.selectedItem.isOpen; + this.nodeTree.fresh(); + } + } + } + + //} + __proto.onFindBtn=function(){ + FindSmallView.I.show(); + } + + __proto.onCloseBtn=function(){ + this.removeSelf(); + } + + __proto.onTreeDoubleClick=function(e){ + if (this.nodeTree.selectedItem){ + var tarNode; + tarNode=this.nodeTree.selectedItem.path; + NodeMenu.I.objRightClick(tarNode); + } + } + + //} + __proto.onTreeRightMouseDown=function(e){ + if (this.nodeTree.selectedItem){ + var tarNode; + tarNode=this.nodeTree.selectedItem.path; + NodeMenu.I.objRightClick(tarNode); + } + } + + //} + __proto.onSettingBtn=function(){ + NodeTreeSettingView.I.showSetting(NodeTree.showKeys,this._closeSettingHandler,this._tar); + } + + __proto.closeSetting=function(newKeys){ + NodeTree.showKeys=newKeys; + this.fresh(); + } + + __proto.onFliterTxtChange=function(e){ + var key; + key=this.fliterTxt.text; + if (key=="")return; + if (key !=NodeTree.showKeys.join(",")){ + NodeTree.showKeys=key.split(","); + this.fresh(); + } + return; + this.selecteByFile(key); + } + + __proto.selecteByFile=function(key){ + var arr; + arr=this.nodeTree.source; + var rsts; + rsts=DebugTool.findNameHas(key,false); + if (rsts && rsts.length > 0){ + var tar; + tar=rsts[0]; + this.parseOpen(arr,tar); + } + } + + __proto.showSelectInStage=function(node){ + this.setDis(Laya.stage); + this.selectByNode(node); + } + + __proto.selectByNode=function(node){ + if (!node)return; + var arr; + arr=this.nodeTree.source; + this.parseOpen(arr,node); + } + + __proto.showNodeList=function(nodeList){ + if (!nodeList)return; + var i=0,len=0; + len=nodeList.length; + var showList; + showList=[]; + var tData; + var tSprite; + for (i=0;i < len;i++){ + tSprite=nodeList[i]; + tData={}; + tData.label=ClassTool.getNodeClassAndName(tSprite); + tData.path=tSprite; + showList.push(tData); + } + this.nodeTree.array=showList; + } + + __proto.parseOpen=function(tree,node){ + if (tree.length < 1)return; + if (!node)return; + var i=0,len=0; + len=tree.length; + var tItem; + for(i=0;i-1){ + item.x=0; + result.push(item); + } + if (item.child && item.child.length > 0){ + this.getFilterSource(item.child,result,key); + } + } + } + + __proto.onControlDown=function(){ + this.startDrag(); + } + + __proto.setDis=function(sprite){ + this._tar=sprite; + this.fresh(); + } + + __proto.fresh=function(){ + var preTar; + if (this.nodeTree.selectedItem){ + var tItem; + tItem=this.nodeTree.selectedItem; + while (tItem && (! (tItem.path instanceof laya.display.Sprite ))){ + tItem=tItem.nodeParent; + } + if (tItem && tItem.path){ + preTar=tItem.path; + } + } + if (!this._tar){ + this.nodeTree.array=[]; + }else{ + this.nodeTree.array=NodeUtils.getNodeTreeData(this._tar,this.showProps?NodeTree.showKeys:NodeTree.emptyShowKey); + } + if (preTar){ + this.selectByNode(preTar); + } + } + + __proto.treeRender=function(cell,index){ + var item=cell.dataSource; + if (item){ + var isDirectory=item.child || item.isDirectory; + var label=cell.getChildByName("label"); + if ((item.path instanceof laya.display.Node )){ + label.color="#09a4f6"; + }else{ + if (item.isChilds){ + label.color="#00ff11"; + }else{ + label.color="#838bc5"; + } + } + } + } + + NodeTree.I=null + NodeTree.emptyShowKey=[]; + __static(NodeTree, + ['showKeys',function(){return this.showKeys=["x","y","width","height","renderCost"];} + ]); + return NodeTree; + })(NodeTreeUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.ObjectCreate extends laya.debug.ui.debugui.ObjectCreateUI + var ObjectCreate=(function(_super){ + function ObjectCreate(){ + ObjectCreate.__super.call(this); + Base64AtlasManager.replaceRes(ObjectCreateUI.uiView); + this.createView(ObjectCreateUI.uiView); + } + + __class(ObjectCreate,'laya.debug.view.nodeInfo.nodetree.ObjectCreate',_super); + var __proto=ObjectCreate.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + return ObjectCreate; + })(ObjectCreateUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.ObjectInfo extends laya.debug.ui.debugui.ObjectInfoUI + var ObjectInfo=(function(_super){ + function ObjectInfo(){ + ObjectInfo.__super.call(this); + Base64AtlasManager.replaceRes(ObjectInfoUI.uiView); + this.createView(ObjectInfoUI.uiView); + } + + __class(ObjectInfo,'laya.debug.view.nodeInfo.nodetree.ObjectInfo',_super); + var __proto=ObjectInfo.prototype; + __proto.createChildren=function(){} + return ObjectInfo; + })(ObjectInfoUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.OutPut extends laya.debug.ui.debugui.OutPutUI + var OutPut=(function(_super){ + function OutPut(){ + OutPut.__super.call(this); + Base64AtlasManager.replaceRes(OutPutUI.uiView); + this.createView(OutPutUI.uiView); + } + + __class(OutPut,'laya.debug.view.nodeInfo.nodetree.OutPut',_super); + var __proto=OutPut.prototype; + __proto.createChildren=function(){} + return OutPut; + })(OutPutUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.Profile extends laya.debug.ui.debugui.ProfileUI + var Profile=(function(_super){ + function Profile(){ + this.views=null; + Profile.__super.call(this); + Base64AtlasManager.replaceRes(ProfileUI.uiView); + this.createView(ProfileUI.uiView); + this.views=[this.createPanel,this.renderPanel,this.cachePanel,this.resPanel]; + this.tab.selectedIndex=0; + this.tabChange(); + this.tab.on(/*laya.events.Event.CHANGE*/"change",this,this.tabChange); + } + + __class(Profile,'laya.debug.view.nodeInfo.nodetree.Profile',_super); + var __proto=Profile.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + __proto.tabChange=function(){ + DisControlTool.addOnlyByIndex(this.views,this.tab.selectedIndex,this); + } + + return Profile; + })(ProfileUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.Rank extends laya.debug.ui.debugui.RankUI + var Rank=(function(_super){ + function Rank(){ + Rank.__super.call(this); + Base64AtlasManager.replaceRes(RankUI.uiView); + this.createView(RankUI.uiView); + } + + __class(Rank,'laya.debug.view.nodeInfo.nodetree.Rank',_super); + var __proto=Rank.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + return Rank; + })(RankUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.SelectInfos extends laya.debug.ui.debugui.SelectInfosUI + var SelectInfos=(function(_super){ + function SelectInfos(){ + SelectInfos.__super.call(this); + Base64AtlasManager.replaceRes(SelectInfosUI.uiView); + this.createView(SelectInfosUI.uiView); + } + + __class(SelectInfos,'laya.debug.view.nodeInfo.nodetree.SelectInfos',_super); + var __proto=SelectInfos.prototype; + __proto.createChildren=function(){ + this.viewMapRegists(); + } + + return SelectInfos; + })(SelectInfosUI) + + + /** + *... + *@author ww + */ + //class laya.debug.view.nodeInfo.nodetree.ToolBar extends laya.debug.ui.debugui.ToolBarUI + var ToolBar=(function(_super){ + function ToolBar(){ + ToolBar.__super.call(this); + Base64AtlasManager.replaceRes(ToolBarUI.uiView); + this.createView(ToolBarUI.uiView); + } + + __class(ToolBar,'laya.debug.view.nodeInfo.nodetree.ToolBar',_super); + var __proto=ToolBar.prototype; + __proto.createChildren=function(){} + return ToolBar; + })(ToolBarUI) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.device.js b/games/laya-snakes/libs/laya.device.js new file mode 100644 index 0000000..1c99772 --- /dev/null +++ b/games/laya-snakes/libs/laya.device.js @@ -0,0 +1,927 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Bitmap=laya.resource.Bitmap,Browser=laya.utils.Browser,Event=laya.events.Event,EventDispatcher=laya.events.EventDispatcher; + var Handler=laya.utils.Handler,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,Sprite=laya.display.Sprite; + var Stage=laya.display.Stage,Texture=laya.resource.Texture,Utils=laya.utils.Utils,WebGL=laya.webgl.WebGL; + var WebGLContext=laya.webgl.WebGLContext; + /** + *使用前可用supported查看浏览器支持。 + */ + //class laya.device.geolocation.Geolocation + var Geolocation=(function(){ + function Geolocation(){} + __class(Geolocation,'laya.device.geolocation.Geolocation'); + Geolocation.getCurrentPosition=function(onSuccess,onError){ + Geolocation.navigator.geolocation.getCurrentPosition(function(pos){ + Geolocation.position.setPosition(pos); + onSuccess.runWith(Geolocation.position); + }, + function(error){ + onError.runWith(error); + },{ + enableHighAccuracy :laya.device.geolocation.Geolocation.enableHighAccuracy, + timeout :laya.device.geolocation.Geolocation.timeout, + maximumAge :laya.device.geolocation.Geolocation.maximumAge + }); + } + + Geolocation.watchPosition=function(onSuccess,onError){ + return Geolocation.navigator.geolocation.watchPosition(function(pos){ + Geolocation.position.setPosition(pos); + onSuccess.runWith(Geolocation.position); + }, + function(error){ + onError.runWith(error); + },{ + enableHighAccuracy :Geolocation.enableHighAccuracy, + timeout :Geolocation.timeout, + maximumAge :Geolocation.maximumAge + }); + } + + Geolocation.clearWatch=function(id){ + Geolocation.navigator.geolocation.clearWatch(id); + } + + Geolocation.PERMISSION_DENIED=1; + Geolocation.POSITION_UNAVAILABLE=2; + Geolocation.TIMEOUT=3; + Geolocation.enableHighAccuracy=false; + Geolocation.maximumAge=0; + __static(Geolocation, + ['navigator',function(){return this.navigator=Browser.window.navigator;},'position',function(){return this.position=new GeolocationInfo();},'supported',function(){return this.supported=!!Geolocation.navigator.geolocation;},'timeout',function(){return this.timeout=1E10;} + ]); + return Geolocation; + })() + + + //class laya.device.geolocation.GeolocationInfo + var GeolocationInfo=(function(){ + function GeolocationInfo(){ + this.pos=null; + this.coords=null; + } + + __class(GeolocationInfo,'laya.device.geolocation.GeolocationInfo'); + var __proto=GeolocationInfo.prototype; + __proto.setPosition=function(pos){ + this.pos=pos; + this.coords=pos.coords; + } + + __getset(0,__proto,'heading',function(){ + return this.coords.heading; + }); + + __getset(0,__proto,'latitude',function(){ + return this.coords.latitude; + }); + + __getset(0,__proto,'altitudeAccuracy',function(){ + return this.coords.altitudeAccuracy; + }); + + __getset(0,__proto,'longitude',function(){ + return this.coords.longitude; + }); + + __getset(0,__proto,'altitude',function(){ + return this.coords.altitude; + }); + + __getset(0,__proto,'accuracy',function(){ + return this.coords.accuracy; + }); + + __getset(0,__proto,'speed',function(){ + return this.coords.speed; + }); + + __getset(0,__proto,'timestamp',function(){ + return this.pos.timestamp; + }); + + return GeolocationInfo; + })() + + + /** + *Media用于捕捉摄像头和麦克风。可以捕捉任意之一,或者同时捕捉两者。getCamera前可以使用supported()检查当前浏览器是否支持。 + *NOTE: + *

    目前Media在移动平台只支持Android,不支持IOS。只可在FireFox完整地使用,Chrome测试时无法捕捉视频。

    + */ + //class laya.device.media.Media + var Media=(function(){ + function Media(){} + __class(Media,'laya.device.media.Media'); + Media.supported=function(){ + return !!Browser.window.navigator.getUserMedia; + } + + Media.getMedia=function(options,onSuccess,onError){ + if (Browser.window.navigator.getUserMedia){ + Browser.window.navigator.getUserMedia(options,function(stream){ + onSuccess.runWith(Browser.window.URL.createObjectURL(stream)); + },function(err){ + onError.runWith(err); + }); + } + } + + Media.__init$=function(){ + /*__JS__ */navigator.getUserMedia=navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;; + } + + return Media; + })() + + + /** + *加速度x/y/z的单位均为m/s²。 + *在硬件(陀螺仪)不支持的情况下,alpha、beta和gamma值为null。 + * + *@author Survivor + */ + //class laya.device.motion.AccelerationInfo + var AccelerationInfo=(function(){ + function AccelerationInfo(){ + this.x=NaN; + this.y=NaN; + this.z=NaN; + } + + __class(AccelerationInfo,'laya.device.motion.AccelerationInfo'); + return AccelerationInfo; + })() + + + /** + *保存旋转信息的类。请勿修改本类的属性。 + *@author Survivor + */ + //class laya.device.motion.RotationInfo + var RotationInfo=(function(){ + function RotationInfo(){ + this.absolute=false; + this.alpha=NaN; + this.beta=NaN; + this.gamma=NaN; + this.compassAccuracy=NaN; + } + + __class(RotationInfo,'laya.device.motion.RotationInfo'); + return RotationInfo; + })() + + + /** + *Accelerator.instance获取唯一的Accelerator引用,请勿调用构造函数。 + * + *

    + *listen()的回调处理器接受四个参数: + *

      + *
    1. acceleration:表示用户给予设备的加速度。
    2. + *
    3. accelerationIncludingGravity:设备受到的总加速度(包含重力)。
    4. + *
    5. rotationRate:设备的自转速率。
    6. + *
    7. interval:加速度获取的时间间隔(毫秒)。
    8. + *
    + *

    + *

    + *NOTE
    + *如,rotationRate的alpha在apple和moz文档中都是z轴旋转角度,但是实测是x轴旋转角度。为了使各属性表示的值与文档所述相同,实际值与其他属性进行了对调。 + *其中: + *

      + *
    • alpha使用gamma值。
    • + *
    • beta使用alpha值。
    • + *
    • gamma使用beta。
    • + *
    + *目前孰是孰非尚未可知,以此为注。 + *

    + */ + //class laya.device.motion.Accelerator extends laya.events.EventDispatcher + var Accelerator=(function(_super){ + function Accelerator(singleton){ + Accelerator.__super.call(this); + /*__JS__ */this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this); + } + + __class(Accelerator,'laya.device.motion.Accelerator',_super); + var __proto=Accelerator.prototype; + /** + *侦听加速器运动。 + *@param observer 回调函数接受4个参数,见类说明。 + */ + __proto.on=function(type,caller,listener,args){ + _super.prototype.on.call(this,type,caller,listener,args); + Browser.window.addEventListener('devicemotion',this.onDeviceOrientationChange); + return this; + } + + /** + *取消侦听加速器。 + *@param handle 侦听加速器所用处理器。 + */ + __proto.off=function(type,caller,listener,onceOnly){ + (onceOnly===void 0)&& (onceOnly=false); + if (!this.hasListener(type)) + Browser.window.removeEventListener('devicemotion',this.onDeviceOrientationChange) + return _super.prototype.off.call(this,type,caller,listener,onceOnly); + } + + __proto.onDeviceOrientationChange=function(e){ + var interval=e.interval; + Accelerator.acceleration.x=e.acceleration.x; + Accelerator.acceleration.y=e.acceleration.y; + Accelerator.acceleration.z=e.acceleration.z; + Accelerator.accelerationIncludingGravity.x=e.accelerationIncludingGravity.x; + Accelerator.accelerationIncludingGravity.y=e.accelerationIncludingGravity.y; + Accelerator.accelerationIncludingGravity.z=e.accelerationIncludingGravity.z; + Accelerator.rotationRate.alpha=e.rotationRate.gamma *-1; + Accelerator.rotationRate.beta=e.rotationRate.alpha *-1; + Accelerator.rotationRate.gamma=e.rotationRate.beta; + if (Browser.onAndriod){ + if (Accelerator.onChrome){ + Accelerator.rotationRate.alpha *=180 / Math.PI; + Accelerator.rotationRate.beta *=180 / Math.PI; + Accelerator.rotationRate.gamma *=180 / Math.PI; + } + Accelerator.acceleration.x *=-1; + Accelerator.accelerationIncludingGravity.x *=-1; + } + else if (Browser.onIOS){ + Accelerator.acceleration.y *=-1; + Accelerator.acceleration.z *=-1; + Accelerator.accelerationIncludingGravity.y *=-1; + Accelerator.accelerationIncludingGravity.z *=-1; + interval *=1000; + } + this.event(/*laya.events.Event.CHANGE*/"change",[Accelerator.acceleration,Accelerator.accelerationIncludingGravity,Accelerator.rotationRate,interval]); + } + + __getset(1,Accelerator,'instance',function(){Accelerator._instance=Accelerator._instance|| new Accelerator(0) + return Accelerator._instance; + },laya.events.EventDispatcher._$SET_instance); + + Accelerator.getTransformedAcceleration=function(acceleration){Accelerator.transformedAcceleration=Accelerator.transformedAcceleration|| new AccelerationInfo(); + Accelerator.transformedAcceleration.z=acceleration.z; + if (Browser.window.orientation==90){ + Accelerator.transformedAcceleration.x=acceleration.y; + Accelerator.transformedAcceleration.y=-acceleration.x; + } + else if (Browser.window.orientation==-90){ + Accelerator.transformedAcceleration.x=-acceleration.y; + Accelerator.transformedAcceleration.y=acceleration.x; + } + else if (!Browser.window.orientation){ + Accelerator.transformedAcceleration.x=acceleration.x; + Accelerator.transformedAcceleration.y=acceleration.y; + } + else if (Browser.window.orientation==180){ + Accelerator.transformedAcceleration.x=-acceleration.x; + Accelerator.transformedAcceleration.y=-acceleration.y; + }; + var tx=NaN; + if (Laya.stage.canvasDegree==-90){ + tx=Accelerator.transformedAcceleration.x; + Accelerator.transformedAcceleration.x=-Accelerator.transformedAcceleration.y; + Accelerator.transformedAcceleration.y=tx; + } + else if (Laya.stage.canvasDegree==90){ + tx=Accelerator.transformedAcceleration.x; + Accelerator.transformedAcceleration.x=Accelerator.transformedAcceleration.y; + Accelerator.transformedAcceleration.y=-tx; + } + return Accelerator.transformedAcceleration; + } + + Accelerator._instance=null + Accelerator.transformedAcceleration=null + __static(Accelerator, + ['acceleration',function(){return this.acceleration=new AccelerationInfo();},'accelerationIncludingGravity',function(){return this.accelerationIncludingGravity=new AccelerationInfo();},'rotationRate',function(){return this.rotationRate=new RotationInfo();},'onChrome',function(){return this.onChrome=(Browser.userAgent.indexOf("Chrome")>-1);} + ]); + return Accelerator; + })(EventDispatcher) + + + /** + *使用Gyroscope.instance获取唯一的Gyroscope引用,请勿调用构造函数。 + * + *

    + *listen()的回调处理器接受两个参数: + *function onOrientationChange(absolute:Boolean,info:RotationInfo):void + *

      + *
    1. absolute:指示设备是否可以提供绝对方位数据(指向地球坐标系),或者设备决定的任意坐标系。关于坐标系参见https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Orientation_and_motion_data_explained
    2. + *
    3. info:RotationInfo类型参数,保存设备的旋转值。
    4. + *
    + *

    + * + *

    + *浏览器兼容性参见:http://caniuse.com/#search=deviceorientation + *

    + */ + //class laya.device.motion.Gyroscope extends laya.events.EventDispatcher + var Gyroscope=(function(_super){ + function Gyroscope(singleton){ + Gyroscope.__super.call(this); + /*__JS__ */this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this); + } + + __class(Gyroscope,'laya.device.motion.Gyroscope',_super); + var __proto=Gyroscope.prototype; + /** + *监视陀螺仪运动。 + *@param observer 回调函数接受一个Boolean类型的absoluteGyroscopeInfo类型参数。 + */ + __proto.on=function(type,caller,listener,args){ + _super.prototype.on.call(this,type,caller,listener,args); + Browser.window.addEventListener('deviceorientation',this.onDeviceOrientationChange); + return this; + } + + /** + *取消指定处理器对陀螺仪的监视。 + *@param observer + */ + __proto.off=function(type,caller,listener,onceOnly){ + (onceOnly===void 0)&& (onceOnly=false); + if (!this.hasListener(type)) + Browser.window.removeEventListener('deviceorientation',this.onDeviceOrientationChange); + return _super.prototype.off.call(this,type,caller,listener,onceOnly); + } + + __proto.onDeviceOrientationChange=function(e){ + Gyroscope.info.alpha=e.alpha; + Gyroscope.info.beta=e.beta; + Gyroscope.info.gamma=e.gamma; + if (e.webkitCompassHeading){ + Gyroscope.info.alpha=e.webkitCompassHeading *-1; + Gyroscope.info.compassAccuracy=e.webkitCompassAccuracy; + } + this.event(/*laya.events.Event.CHANGE*/"change",[e.absolute,Gyroscope.info]); + } + + __getset(1,Gyroscope,'instance',function(){Gyroscope._instance=Gyroscope._instance|| new Gyroscope(0); + return Gyroscope._instance; + },laya.events.EventDispatcher._$SET_instance); + + Gyroscope._instance=null + __static(Gyroscope, + ['info',function(){return this.info=new RotationInfo();} + ]); + return Gyroscope; + })(EventDispatcher) + + + /** + *Shake只能在支持此操作的设备上有效。 + * + *@author Survivor + */ + //class laya.device.Shake extends laya.events.EventDispatcher + var Shake=(function(_super){ + function Shake(){ + this.throushold=0; + this.shakeInterval=0; + this.callback=null; + this.lastX=NaN; + this.lastY=NaN; + this.lastZ=NaN; + this.lastMillSecond=NaN; + Shake.__super.call(this); + } + + __class(Shake,'laya.device.Shake',_super); + var __proto=Shake.prototype; + /** + *开始响应设备摇晃。 + *@param throushold 响应的瞬时速度阈值,轻度摇晃的值约在5~10间。 + *@param timeout 设备摇晃的响应间隔时间。 + *@param callback 在设备摇晃触发时调用的处理器。 + */ + __proto.start=function(throushold,interval){ + this.throushold=throushold; + this.shakeInterval=interval; + this.lastX=this.lastY=this.lastZ=NaN; + Accelerator.instance.on(/*laya.events.Event.CHANGE*/"change",this,this.onShake); + } + + /** + *停止响应设备摇晃。 + */ + __proto.stop=function(){ + Accelerator.instance.off(/*laya.events.Event.CHANGE*/"change",this,this.onShake); + } + + __proto.onShake=function(acceleration,accelerationIncludingGravity,rotationRate,interval){ + if(isNaN(this.lastX)){ + this.lastX=accelerationIncludingGravity.x; + this.lastY=accelerationIncludingGravity.y; + this.lastZ=accelerationIncludingGravity.z; + this.lastMillSecond=Browser.now(); + return; + }; + var deltaX=Math.abs(this.lastX-accelerationIncludingGravity.x); + var deltaY=Math.abs(this.lastY-accelerationIncludingGravity.y); + var deltaZ=Math.abs(this.lastZ-accelerationIncludingGravity.z); + if(this.isShaked(deltaX,deltaY,deltaZ)){ + var deltaMillSecond=Browser.now()-this.lastMillSecond; + if (deltaMillSecond > this.shakeInterval){ + this.event(/*laya.events.Event.CHANGE*/"change"); + this.lastMillSecond=Browser.now(); + } + } + this.lastX=accelerationIncludingGravity.x; + this.lastY=accelerationIncludingGravity.y; + this.lastZ=accelerationIncludingGravity.z; + } + + // 通过任意两个分量判断是否满足摇晃设定。 + __proto.isShaked=function(deltaX,deltaY,deltaZ){ + return (deltaX > this.throushold && deltaY > this.throushold)|| + (deltaX > this.throushold && deltaZ > this.throushold)|| + (deltaY > this.throushold && deltaZ > this.throushold) + } + + __getset(1,Shake,'instance',function(){Shake._instance=Shake._instance|| new Shake(); + return Shake._instance; + },laya.events.EventDispatcher._$SET_instance); + + Shake._instance=null + return Shake; + })(EventDispatcher) + + + /** + *Video将视频显示到Canvas上。Video可能不会在所有浏览器有效。 + *

    关于Video支持的所有事件参见:http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp

    + *

    + *注意:
    + *在PC端可以在任何时机调用play()因此,可以在程序开始运行时就使Video开始播放。但是在移动端,只有在用户第一次触碰屏幕后才可以调用play(),所以移动端不可能在程序开始运行时就自动开始播放Video。 + *

    + * + *

    MDN Video链接: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video

    + */ + //class laya.device.media.Video extends laya.display.Sprite + var Video=(function(_super){ + function Video(width,height){ + this.htmlVideo=null; + this.videoElement=null; + this.internalTexture=null; + (width===void 0)&& (width=320); + (height===void 0)&& (height=240); + Video.__super.call(this); + if (Render.isWebGL) + this.htmlVideo=new WebGLVideo(); + else + this.htmlVideo=new HtmlVideo(); + this.videoElement=this.htmlVideo.getVideo(); + this.videoElement.layaTarget=this; + this.internalTexture=new Texture(this.htmlVideo); + this.videoElement.addEventListener("abort",Video.onAbort); + this.videoElement.addEventListener("canplay",Video.onCanplay); + this.videoElement.addEventListener("canplaythrough",Video.onCanplaythrough); + this.videoElement.addEventListener("durationchange",Video.onDurationchange); + this.videoElement.addEventListener("emptied",Video.onEmptied); + this.videoElement.addEventListener("error",Video.onError); + this.videoElement.addEventListener("loadeddata",Video.onLoadeddata); + this.videoElement.addEventListener("loadedmetadata",Video.onLoadedmetadata); + this.videoElement.addEventListener("loadstart",Video.onLoadstart); + this.videoElement.addEventListener("pause",Video.onPause); + this.videoElement.addEventListener("play",Video.onPlay); + this.videoElement.addEventListener("playing",Video.onPlaying); + this.videoElement.addEventListener("progress",Video.onProgress); + this.videoElement.addEventListener("ratechange",Video.onRatechange); + this.videoElement.addEventListener("seeked",Video.onSeeked); + this.videoElement.addEventListener("seeking",Video.onSeeking); + this.videoElement.addEventListener("stalled",Video.onStalled); + this.videoElement.addEventListener("suspend",Video.onSuspend); + this.videoElement.addEventListener("timeupdate",Video.onTimeupdate); + this.videoElement.addEventListener("volumechange",Video.onVolumechange); + this.videoElement.addEventListener("waiting",Video.onWaiting); + this.videoElement.addEventListener("ended",this.onPlayComplete['bind'](this)); + this.size(width,height); + if (Browser.onMobile){ + /*__JS__ */this.onDocumentClick=this.onDocumentClick.bind(this); + Browser.document.addEventListener("touchend",this.onDocumentClick); + } + } + + __class(Video,'laya.device.media.Video',_super); + var __proto=Video.prototype; + __proto.onPlayComplete=function(e){ + Laya.timer.clear(this,this.renderCanvas); + this.event("ended"); + } + + /** + *设置播放源。 + *@param url 播放源路径。 + */ + __proto.load=function(url){ + if (url.indexOf("blob:")==0) + this.videoElement.src=url; + else + this.htmlVideo.setSource(url,laya.device.media.Video.MP4); + } + + /** + *开始播放视频。 + */ + __proto.play=function(){ + this.videoElement.play(); + Laya.timer.frameLoop(1,this,this.renderCanvas); + } + + /** + *暂停视频播放。 + */ + __proto.pause=function(){ + this.videoElement.pause(); + Laya.timer.clear(this,this.renderCanvas); + } + + /** + *重新加载视频。 + */ + __proto.reload=function(){ + this.videoElement.load(); + } + + /** + *检测是否支持播放指定格式视频。 + *@param type 参数为Video.MP4 / Video.OGG / Video.WEBM之一。 + *@return + */ + __proto.canPlayType=function(type){ + var typeString; + switch (type){ + case laya.device.media.Video.MP4: + typeString="video/mp4"; + break ; + case laya.device.media.Video.OGG: + typeString="video/ogg"; + break ; + case laya.device.media.Video.WEBM: + typeString="video/webm"; + break ; + } + return this.videoElement.canPlayType(typeString); + } + + __proto.renderCanvas=function(){ + if (this.readyState===0) + return; + if (Render.isWebGL) + this.htmlVideo['updateTexture'](); + this.graphics.clear(); + this.graphics.drawTexture(this.internalTexture,0,0,this.width,this.height); + } + + __proto.onDocumentClick=function(){ + this.videoElement.play(); + this.videoElement.pause(); + Browser.document.removeEventListener("touchend",this.onDocumentClick); + } + + __proto.size=function(width,height){ + _super.prototype.size.call(this,width,height) + this.videoElement.width=width / Browser.pixelRatio; + if (this.paused)this.renderCanvas(); + return this; + } + + /** + *销毁内部事件绑定。 + */ + __proto.destroy=function(detroyChildren){ + (detroyChildren===void 0)&& (detroyChildren=true); + _super.prototype.destroy.call(this,detroyChildren); + this.videoElement.removeEventListener("abort",Video.onAbort); + this.videoElement.removeEventListener("canplay",Video.onCanplay); + this.videoElement.removeEventListener("canplaythrough",Video.onCanplaythrough); + this.videoElement.removeEventListener("durationchange",Video.onDurationchange); + this.videoElement.removeEventListener("emptied",Video.onEmptied); + this.videoElement.removeEventListener("error",Video.onError); + this.videoElement.removeEventListener("loadeddata",Video.onLoadeddata); + this.videoElement.removeEventListener("loadedmetadata",Video.onLoadedmetadata); + this.videoElement.removeEventListener("loadstart",Video.onLoadstart); + this.videoElement.removeEventListener("pause",Video.onPause); + this.videoElement.removeEventListener("play",Video.onPlay); + this.videoElement.removeEventListener("playing",Video.onPlaying); + this.videoElement.removeEventListener("progress",Video.onProgress); + this.videoElement.removeEventListener("ratechange",Video.onRatechange); + this.videoElement.removeEventListener("seeked",Video.onSeeked); + this.videoElement.removeEventListener("seeking",Video.onSeeking); + this.videoElement.removeEventListener("stalled",Video.onStalled); + this.videoElement.removeEventListener("suspend",Video.onSuspend); + this.videoElement.removeEventListener("timeupdate",Video.onTimeupdate); + this.videoElement.removeEventListener("volumechange",Video.onVolumechange); + this.videoElement.removeEventListener("waiting",Video.onWaiting); + this.videoElement.removeEventListener("ended",this.onPlayComplete); + } + + __proto.syncVideoPosition=function(){ + var stage=Laya.stage; + var rec; + rec=Utils.getGlobalPosAndScale(this); + var a=stage._canvasTransform.a,d=stage._canvasTransform.d; + var x=rec.x *stage.clientScaleX *a+stage.offset.x; + var y=rec.y *stage.clientScaleY *d+stage.offset.y; + this.videoElement.style.left=x+'px';; + this.videoElement.style.top=y+'px'; + this.videoElement.width=this.width / Browser.pixelRatio; + this.videoElement.height=this.height / Browser.pixelRatio; + } + + /** + *buffered 属性返回 TimeRanges(JS)对象。TimeRanges 对象表示用户的音视频缓冲范围。缓冲范围指的是已缓冲音视频的时间范围。如果用户在音视频中跳跃播放,会得到多个缓冲范围。 + *

    buffered.length返回缓冲范围个数。如获取第一个缓冲范围则是buffered.start(0)和buffered.end(0)。以秒计。

    + *@return + */ + __getset(0,__proto,'buffered',function(){ + return this.videoElement.buffered; + }); + + /** + *获取视频源尺寸。ready事件触发后可用。 + */ + __getset(0,__proto,'videoWidth',function(){ + return this.videoElement.videoWidth; + }); + + /** + *获取当前播放源路径。 + */ + __getset(0,__proto,'currentSrc',function(){ + return this.videoElement.currentSrc; + }); + + /** + *设置和获取当前播放头位置。 + */ + __getset(0,__proto,'currentTime',function(){ + return this.videoElement.currentTime; + },function(value){ + this.videoElement.currentTime=value; + this.renderCanvas(); + }); + + /** + *返回音频/视频的播放是否已结束 + */ + __getset(0,__proto,'ended',function(){ + return this.videoElement.ended; + }); + + /** + *设置和获取当前音量。 + */ + __getset(0,__proto,'volume',function(){ + return this.videoElement.volume; + },function(value){ + this.videoElement.volume=value; + }); + + __getset(0,__proto,'videoHeight',function(){ + return this.videoElement.videoHeight; + }); + + /** + *表示视频元素的就绪状态: + *
      + *
    • 0=HAVE_NOTHING-没有关于音频/视频是否就绪的信息
    • + *
    • 1=HAVE_METADATA-关于音频/视频就绪的元数据
    • + *
    • 2=HAVE_CURRENT_DATA-关于当前播放位置的数据是可用的,但没有足够的数据来播放下一帧/毫秒
    • + *
    • 3=HAVE_FUTURE_DATA-当前及至少下一帧的数据是可用的
    • + *
    • 4=HAVE_ENOUGH_DATA-可用数据足以开始播放
    • + *
    + */ + __getset(0,__proto,'readyState',function(){ + return this.videoElement.readyState; + }); + + /** + *获取视频长度(秒)。ready事件触发后可用。 + */ + __getset(0,__proto,'duration',function(){ + return this.videoElement.duration; + }); + + /** + *返回表示音频/视频错误状态的 MediaError(JS)对象。 + */ + __getset(0,__proto,'error',function(){ + return this.videoElement.error; + }); + + /** + *设置或返回音频/视频是否应在结束时重新播放。 + */ + __getset(0,__proto,'loop',function(){ + return this.videoElement.loop; + },function(value){ + this.videoElement.loop=value; + }); + + /** + *playbackRate 属性设置或返回音频/视频的当前播放速度。如: + *
      + *
    • 1.0 正常速度
    • + *
    • 0.5 半速(更慢)
    • + *
    • 2.0 倍速(更快)
    • + *
    • -1.0 向后,正常速度
    • + *
    • -0.5 向后,半速
    • + *
    + *

    只有 Google Chrome 和 Safari 支持 playbackRate 属性。

    + */ + __getset(0,__proto,'playbackRate',function(){ + return this.videoElement.playbackRate; + },function(value){ + this.videoElement.playbackRate=value; + }); + + /** + *获取和设置静音状态。 + */ + __getset(0,__proto,'muted',function(){ + return this.videoElement.muted; + },function(value){ + this.videoElement.muted=value; + }); + + /** + *返回视频是否暂停 + */ + __getset(0,__proto,'paused',function(){ + return this.videoElement.paused; + }); + + /** + *preload 属性设置或返回是否在页面加载后立即加载视频。可赋值如下: + *
      + *
    • auto 指示一旦页面加载,则开始加载视频。
    • + *
    • metadata 指示当页面加载后仅加载音频/视频的元数据。
    • + *
    • none 指示页面加载后不应加载音频/视频。
    • + *
    + *@return + * + */ + __getset(0,__proto,'preload',function(){ + return this.videoElement.preload; + },function(value){ + this.videoElement.preload=value; + }); + + /** + *参见 http://www.w3school.com.cn/tags/av_prop_seekable.asp。 + *@return + * + */ + __getset(0,__proto,'seekable',function(){ + return this.videoElement.seekable; + }); + + /** + *seeking 属性返回用户目前是否在音频/视频中寻址。 + *寻址中(Seeking)指的是用户在音频/视频中移动/跳跃到新的位置。 + */ + __getset(0,__proto,'seeking',function(){ + return this.videoElement.seeking; + }); + + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + if (this.paused)this.renderCanvas(); + }); + + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + this.videoElement.width=this.width / Browser.pixelRatio; + _super.prototype._$set_width.call(this,value); + if (this.paused)this.renderCanvas(); + }); + + Video.onAbort=function(e){e.target.layaTarget.event("abort")} + Video.onCanplay=function(e){e.target.layaTarget.event("canplay")} + Video.onCanplaythrough=function(e){e.target.layaTarget.event("canplaythrough")} + Video.onDurationchange=function(e){e.target.layaTarget.event("durationchange")} + Video.onEmptied=function(e){e.target.layaTarget.event("emptied")} + Video.onError=function(e){e.target.layaTarget.event("error")} + Video.onLoadeddata=function(e){e.target.layaTarget.event("loadeddata")} + Video.onLoadedmetadata=function(e){e.target.layaTarget.event("loadedmetadata")} + Video.onLoadstart=function(e){e.target.layaTarget.event("loadstart")} + Video.onPause=function(e){e.target.layaTarget.event("pause")} + Video.onPlay=function(e){e.target.layaTarget.event("play")} + Video.onPlaying=function(e){e.target.layaTarget.event("playing")} + Video.onProgress=function(e){e.target.layaTarget.event("progress")} + Video.onRatechange=function(e){e.target.layaTarget.event("ratechange")} + Video.onSeeked=function(e){e.target.layaTarget.event("seeked")} + Video.onSeeking=function(e){e.target.layaTarget.event("seeking")} + Video.onStalled=function(e){e.target.layaTarget.event("stalled")} + Video.onSuspend=function(e){e.target.layaTarget.event("suspend")} + Video.onTimeupdate=function(e){e.target.layaTarget.event("timeupdate")} + Video.onVolumechange=function(e){e.target.layaTarget.event("volumechange")} + Video.onWaiting=function(e){e.target.layaTarget.event("waiting")} + Video.MP4=1; + Video.OGG=2; + Video.CAMERA=4; + Video.WEBM=8; + Video.SUPPORT_PROBABLY="probably"; + Video.SUPPORT_MAYBY="maybe"; + Video.SUPPORT_NO=""; + return Video; + })(Sprite) + + + /** + *@private + */ + //class laya.device.media.HtmlVideo extends laya.resource.Bitmap + var HtmlVideo=(function(_super){ + function HtmlVideo(){ + this.video=null; + HtmlVideo.__super.call(this); + this._w=1; + this._h=1; + this.createDomElement(); + } + + __class(HtmlVideo,'laya.device.media.HtmlVideo',_super); + var __proto=HtmlVideo.prototype; + __proto.createDomElement=function(){ + var _$this=this; + this._source=this.video=Browser.createElement("video"); + var style=this.video.style; + style.position='absolute'; + style.top='0px'; + style.left='0px'; + this.video.addEventListener("loadedmetadata",(function(){ + this._w=_$this.video.videoWidth; + this._h=_$this.video.videoHeight; + })['bind'](this)); + } + + __proto.setSource=function(url,extension){ + while(this.video.childElementCount) + this.video.firstChild.remove(); + if (extension & Video.MP4) + this.appendSource(url,"video/mp4"); + if (extension & Video.OGG) + this.appendSource(url+".ogg","video/ogg"); + } + + __proto.appendSource=function(source,type){ + var sourceElement=Browser.createElement("source"); + sourceElement.src=source; + sourceElement.type=type; + this.video.appendChild(sourceElement); + } + + __proto.getVideo=function(){ + return this.video; + } + + HtmlVideo.create=function(){ + return new HtmlVideo(); + } + + return HtmlVideo; + })(Bitmap) + + + /** + *@private + */ + //class laya.device.media.WebGLVideo extends laya.device.media.HtmlVideo + var WebGLVideo=(function(_super){ + function WebGLVideo(){ + this.gl=null; + this.preTarget=null; + this.preTexture=null; + WebGLVideo.__super.call(this); + this.gl=WebGL.mainContext; + this._source=this.gl.createTexture(); + this.preTarget=WebGLContext.curBindTexTarget; + this.preTexture=WebGLContext.curBindTexValue; + WebGLContext.bindTexture(this.gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + this.gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + this.gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,/*laya.webgl.WebGLContext.CLAMP_TO_EDGE*/0x812F); + this.gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MAG_FILTER*/0x2800,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + this.gl.texParameteri(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,/*laya.webgl.WebGLContext.TEXTURE_MIN_FILTER*/0x2801,/*laya.webgl.WebGLContext.LINEAR*/0x2601); + (this.preTarget && this.preTexture)&& (WebGLContext.bindTexture(this.gl,this.preTarget,this.preTexture)); + } + + __class(WebGLVideo,'laya.device.media.WebGLVideo',_super); + var __proto=WebGLVideo.prototype; + __proto.updateTexture=function(){ + WebGLContext.bindTexture(this.gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._source); + this.gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,0,/*laya.webgl.WebGLContext.RGB*/0x1907,/*laya.webgl.WebGLContext.RGB*/0x1907,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,this.video); + } + + return WebGLVideo; + })(HtmlVideo) + + + Laya.__init([Media]); +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.filter.js b/games/laya-snakes/libs/laya.filter.js new file mode 100644 index 0000000..722dd57 --- /dev/null +++ b/games/laya-snakes/libs/laya.filter.js @@ -0,0 +1,340 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var BlendMode=laya.webgl.canvas.BlendMode,Browser=laya.utils.Browser,Color=laya.utils.Color,ColorFilterAction=laya.filters.ColorFilterAction; + var ColorFilterActionGL=laya.filters.webgl.ColorFilterActionGL,Filter=laya.filters.Filter,FilterActionGL=laya.filters.webgl.FilterActionGL; + var Matrix=laya.maths.Matrix,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext; + var RenderTarget2D=laya.webgl.resource.RenderTarget2D,RunDriver=laya.utils.RunDriver,ShaderDefines2D=laya.webgl.shader.d2.ShaderDefines2D; + var Sprite=laya.display.Sprite,SubmitCMD=laya.webgl.submit.SubmitCMD,Texture=laya.resource.Texture,Value2D=laya.webgl.shader.d2.value.Value2D; + /** + *默认的FILTER,什么都不做 + *@private + */ + //class laya.filters.FilterAction + var FilterAction=(function(){ + function FilterAction(){ + this.data=null; + } + + __class(FilterAction,'laya.filters.FilterAction'); + var __proto=FilterAction.prototype; + Laya.imps(__proto,{"laya.filters.IFilterAction":true}) + __proto.apply=function(data){ + return null; + } + + return FilterAction; + })() + + + /** + *@private + */ + //class laya.filters.WebGLFilter + var WebGLFilter=(function(){ + function WebGLFilter(){}; + __class(WebGLFilter,'laya.filters.WebGLFilter'); + WebGLFilter.enable=function(){ + if (WebGLFilter.isInit)return; + WebGLFilter.isInit=true; + if (!Render.isWebGL)return; + RunDriver.createFilterAction=function (type){ + var action; + switch (type){ + case /*laya.filters.Filter.COLOR*/0x20: + action=new ColorFilterActionGL(); + break ; + case /*laya.filters.Filter.BLUR*/0x10: + action=new BlurFilterActionGL(); + break ; + case /*laya.filters.Filter.GLOW*/0x08: + action=new GlowFilterActionGL(); + break ; + } + return action; + } + } + + WebGLFilter.isInit=false; + WebGLFilter.__init$=function(){ + BlurFilterActionGL; + ColorFilterActionGL; + GlowFilterActionGL; + Render; + RunDriver;{ + RunDriver.createFilterAction=function (type){ + var action; + switch (type){ + case /*laya.filters.Filter.BLUR*/0x10: + action=new FilterAction(); + break ; + case /*laya.filters.Filter.GLOW*/0x08: + action=new FilterAction(); + break ; + case /*laya.filters.Filter.COLOR*/0x20: + action=new ColorFilterAction(); + break ; + } + return action; + } + } + } + + return WebGLFilter; + })() + + + /** + *模糊滤镜 + */ + //class laya.filters.BlurFilter extends laya.filters.Filter + var BlurFilter=(function(_super){ + function BlurFilter(strength){ + this.strength=NaN; + BlurFilter.__super.call(this); + (strength===void 0)&& (strength=4); + if (Render.isWebGL)WebGLFilter.enable(); + this.strength=strength; + this._action=RunDriver.createFilterAction(0x10); + this._action.data=this; + } + + __class(BlurFilter,'laya.filters.BlurFilter',_super); + var __proto=BlurFilter.prototype; + /** + *@private 通知微端 + */ + __proto.callNative=function(sp){ + sp.model &&sp.model.blurFilter&&sp.model.blurFilter(this.strength); + } + + /** + *@private + *当前滤镜对应的操作器 + */ + __getset(0,__proto,'action',function(){ + return this._action; + }); + + /** + *@private + *当前滤镜的类型 + */ + __getset(0,__proto,'type',function(){ + return 0x10; + }); + + return BlurFilter; + })(Filter) + + + /** + *发光滤镜(也可以当成阴影滤使用) + */ + //class laya.filters.GlowFilter extends laya.filters.Filter + var GlowFilter=(function(_super){ + function GlowFilter(color,blur,offX,offY){ + this._color=null; + GlowFilter.__super.call(this); + this._elements=new Float32Array(9); + (blur===void 0)&& (blur=4); + (offX===void 0)&& (offX=6); + (offY===void 0)&& (offY=6); + if (Render.isWebGL){ + WebGLFilter.enable(); + } + this._color=new Color(color); + this.blur=blur; + this.offX=offX; + this.offY=offY; + this._action=RunDriver.createFilterAction(0x08); + this._action.data=this; + } + + __class(GlowFilter,'laya.filters.GlowFilter',_super); + var __proto=GlowFilter.prototype; + /**@private */ + __proto.getColor=function(){ + return this._color._color; + } + + /** + *@private 通知微端 + */ + __proto.callNative=function(sp){ + sp.model &&sp.model.glowFilter&&sp.model.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6]); + } + + /** + *@private + *滤镜类型 + */ + __getset(0,__proto,'type',function(){ + return 0x08; + }); + + /**@private */ + __getset(0,__proto,'action',function(){ + return this._action; + }); + + /**@private */ + /**@private */ + __getset(0,__proto,'offY',function(){ + return this._elements[6]; + },function(value){ + this._elements[6]=value; + }); + + /**@private */ + /**@private */ + __getset(0,__proto,'offX',function(){ + return this._elements[5]; + },function(value){ + this._elements[5]=value; + }); + + /**@private */ + /**@private */ + __getset(0,__proto,'blur',function(){ + return this._elements[4]; + },function(value){ + this._elements[4]=value; + }); + + return GlowFilter; + })(Filter) + + + /** + *@private + */ + //class laya.filters.webgl.BlurFilterActionGL extends laya.filters.webgl.FilterActionGL + var BlurFilterActionGL=(function(_super){ + function BlurFilterActionGL(){ + this.data=null; + BlurFilterActionGL.__super.call(this); + } + + __class(BlurFilterActionGL,'laya.filters.webgl.BlurFilterActionGL',_super); + var __proto=BlurFilterActionGL.prototype; + __proto.setValueMix=function(shader){ + shader.defines.add(this.data.type); + var o=shader; + } + + __proto.apply3d=function(scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + shaderValue.setFilters([this.data]); + var tMatrix=Matrix.EMPTY; + tMatrix.identity(); + context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.EMPTY,"src",shaderValue); + shaderValue.setFilters(null); + } + + __proto.setValue=function(shader){ + shader.strength=this.data.strength; + } + + __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.BLUR*/0x10;}); + return BlurFilterActionGL; + })(FilterActionGL) + + + /** + *@private + */ + //class laya.filters.webgl.GlowFilterActionGL extends laya.filters.webgl.FilterActionGL + var GlowFilterActionGL=(function(_super){ + function GlowFilterActionGL(){ + this.data=null; + this._initKey=false; + this._textureWidth=0; + this._textureHeight=0; + GlowFilterActionGL.__super.call(this); + } + + __class(GlowFilterActionGL,'laya.filters.webgl.GlowFilterActionGL',_super); + var __proto=GlowFilterActionGL.prototype; + Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) + __proto.setValueMix=function(shader){} + __proto.apply3d=function(scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + scope.addValue("color",this.data.getColor()); + var w=b.width,h=b.height; + this._textureWidth=w; + this._textureHeight=h; + var submit=SubmitCMD.create([scope,sprite,context,0,0],GlowFilterActionGL.tmpTarget); + context.ctx.addRenderObject(submit); + var shaderValue; + var mat=Matrix.TEMP; + mat.identity(); + shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + shaderValue.setFilters([this.data]); + context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue,null,BlendMode.TOINT.overlay); + submit=SubmitCMD.create([scope,sprite,context,0,0],GlowFilterActionGL.startOut); + context.ctx.addRenderObject(submit); + shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"tmpTarget",shaderValue,Texture.INV_UV,BlendMode.TOINT.overlay); + shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); + context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue); + submit=SubmitCMD.create([scope,sprite,context,0,0],GlowFilterActionGL.recycleTarget); + context.ctx.addRenderObject(submit); + return null; + } + + __proto.setSpriteWH=function(sprite){ + this._textureWidth=sprite.width; + this._textureHeight=sprite.height; + } + + __proto.setValue=function(shader){ + shader.u_offsetX=this.data.offX; + shader.u_offsetY=-this.data.offY; + shader.u_strength=1.0; + shader.u_blurX=this.data.blur; + shader.u_blurY=this.data.blur; + shader.u_textW=this._textureWidth; + shader.u_textH=this._textureHeight; + shader.u_color=this.data.getColor(); + } + + __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.GLOW*/0x08;}); + GlowFilterActionGL.tmpTarget=function(scope,sprite,context,x,y){ + var b=scope.getValue("bounds"); + var out=scope.getValue("out"); + out.end(); + var tmpTarget=RenderTarget2D.create(b.width,b.height); + tmpTarget.start(); + var color=scope.getValue("color"); + if (color){ + tmpTarget.clear(color[0],color[1],color[2],0); + } + scope.addValue("tmpTarget",tmpTarget); + } + + GlowFilterActionGL.startOut=function(scope,sprite,context,x,y){ + var tmpTarget=scope.getValue("tmpTarget"); + tmpTarget.end(); + var out=scope.getValue("out"); + out.start(); + var color=scope.getValue("color"); + if (color){ + out.clear(color[0],color[1],color[2],0); + } + } + + GlowFilterActionGL.recycleTarget=function(scope,sprite,context,x,y){ + var src=scope.getValue("src"); + var tmpTarget=scope.getValue("tmpTarget"); + tmpTarget.recycle(); + } + + return GlowFilterActionGL; + })(FilterActionGL) + + + Laya.__init([WebGLFilter]); +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.html.js b/games/laya-snakes/libs/laya.html.js new file mode 100644 index 0000000..6d1481d --- /dev/null +++ b/games/laya-snakes/libs/laya.html.js @@ -0,0 +1,851 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Browser=laya.utils.Browser,CSSStyle=laya.display.css.CSSStyle,ClassUtils=laya.utils.ClassUtils; + var Event=laya.events.Event,HTMLChar=laya.utils.HTMLChar,Loader=laya.net.Loader,Node=laya.display.Node,Rectangle=laya.maths.Rectangle; + var Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite; + var Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Texture=laya.resource.Texture,URL=laya.net.URL,Utils=laya.utils.Utils; + /** + *@private + */ + //class laya.html.utils.HTMLParse + var HTMLParse=(function(){ + function HTMLParse(){}; + __class(HTMLParse,'laya.html.utils.HTMLParse'); + HTMLParse.parse=function(ower,xmlString,url){ + xmlString=xmlString.replace(/
    /g,"
    "); + xmlString=""+xmlString+""; + xmlString=xmlString.replace(HTMLParse.spacePattern,HTMLParse.char255); + var xml=Utils.parseXMLFromString(xmlString); + HTMLParse._parseXML(ower,xml.childNodes[0].childNodes,url); + } + + HTMLParse._parseXML=function(parent,xml,url,href){ + var i=0,n=0; + if (xml.join || xml.item){ + for (i=0,n=xml.length;i < n;++i){ + HTMLParse._parseXML(parent,xml[i],url,href); + } + }else { + var node; + var nodeName; + if (xml.nodeType==3){ + var txt; + if ((parent instanceof laya.html.dom.HTMLDivElement )){ + if (xml.nodeName==null){ + xml.nodeName="#text"; + } + nodeName=xml.nodeName.toLowerCase(); + txt=xml.textContent.replace(/^\s+|\s+$/g,''); + if (txt.length > 0){ + node=ClassUtils.getInstance(nodeName); + if (node){ + parent.addChild(node); + ((node).innerTEXT=txt.replace(HTMLParse.char255AndOneSpacePattern," ")); + } + } + }else { + txt=xml.textContent.replace(/^\s+|\s+$/g,''); + if (txt.length > 0){ + ((parent).innerTEXT=txt.replace(HTMLParse.char255AndOneSpacePattern," ")); + } + } + return; + }else { + nodeName=xml.nodeName.toLowerCase(); + if (nodeName=="#comment")return; + node=ClassUtils.getInstance(nodeName); + if (node){ + node=parent.addChild(node); + (node).URI=url; + (node).href=href; + var attributes=xml.attributes; + if (attributes && attributes.length > 0){ + for (i=0,n=attributes.length;i < n;++i){ + var attribute=attributes[i]; + var attrName=attribute.nodeName; + var value=attribute.value; + node._setAttributes(attrName,value); + } + } + HTMLParse._parseXML(node,xml.childNodes,url,(node).href); + }else { + HTMLParse._parseXML(parent,xml.childNodes,url,href); + } + } + } + } + + HTMLParse.char255=String.fromCharCode(255); + HTMLParse.spacePattern=/ | /g; + HTMLParse.char255AndOneSpacePattern=new RegExp(String.fromCharCode(255)+"|(\\s+)","g"); + return HTMLParse; + })() + + + /** + *@private + *HTML的布局类 + *对HTML的显示对象进行排版 + */ + //class laya.html.utils.Layout + var Layout=(function(){ + function Layout(){}; + __class(Layout,'laya.html.utils.Layout'); + Layout.later=function(element){ + if (Layout._will==null){ + Layout._will=[]; + Laya.stage.frameLoop(1,null,function(){ + if (Layout._will.length < 1) + return; + for (var i=0;i < Layout._will.length;i++){ + laya.html.utils.Layout.layout(Layout._will[i]); + } + Layout._will.length=0; + }); + } + Layout._will.push(element); + } + + Layout.layout=function(element){ + if ((element._style._type & /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200)===0) + return null; + element._style._type &=~ /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; + var arr=Layout._multiLineLayout(element); + if (Render.isConchApp&&element["layaoutCallNative"]){ + (element).layaoutCallNative(); + } + return arr; + } + + Layout._multiLineLayout=function(element){ + var elements=new Array; + element._addChildsToLayout(elements); + var i=0,n=elements.length,j=0; + var style=element._getCSSStyle(); + var letterSpacing=style.letterSpacing; + var leading=style.leading; + var lineHeight=style.lineHeight; + var widthAuto=style._widthAuto()|| !style.wordWrap; + var width=widthAuto ? 999999 :element.width; + var height=element.height; + var maxWidth=0; + var exWidth=style.italic ? style.fontSize / 3 :0; + var align=style._getAlign(); + var valign=style._getValign(); + var endAdjust=valign!==0 || align!==0 || lineHeight !=0; + var oneLayout; + var x=0; + var y=0; + var w=0; + var h=0; + var tBottom=0; + var lines=new Array; + var curStyle; + var curPadding; + var curLine=lines[0]=new LayoutLine(); + var newLine=false,nextNewline=false; + var htmlWord; + var sprite; + curLine.h=0; + if (style.italic) + width-=style.fontSize / 3; + var tWordWidth=0; + var tLineFirstKey=true; + function addLine (){ + curLine.y=y; + y+=curLine.h+leading; + curLine.mWidth=tWordWidth; + tWordWidth=0; + curLine=new LayoutLine(); + lines.push(curLine); + curLine.h=0; + x=0; + tLineFirstKey=true; + newLine=false; + } + for (i=0;i < n;i++){ + oneLayout=elements[i]; + if (oneLayout==null){ + if (!tLineFirstKey){ + x+=Layout.DIV_ELEMENT_PADDING; + } + curLine.wordStartIndex=curLine.elements.length; + continue ; + } + tLineFirstKey=false; + if ((oneLayout instanceof laya.html.dom.HTMLBrElement )){ + addLine(); + curLine.y=y; + curLine.h=lineHeight; + continue ; + }else if (oneLayout._isChar()){ + htmlWord=oneLayout; + if (!htmlWord.isWord){ + if (lines.length > 0 && (x+w)> width && curLine.wordStartIndex > 0){ + var tLineWord=0; + tLineWord=curLine.elements.length-curLine.wordStartIndex+1; + curLine.elements.length=curLine.wordStartIndex; + i-=tLineWord; + addLine(); + continue ; + } + newLine=false; + tWordWidth+=htmlWord.width; + }else { + newLine=nextNewline || (htmlWord.char==='\n'); + curLine.wordStartIndex=curLine.elements.length; + } + w=htmlWord.width+letterSpacing; + h=htmlWord.height; + nextNewline=false; + newLine=newLine || ((x+w)> width); + newLine && addLine(); + curLine.minTextHeight=Math.min(curLine.minTextHeight,oneLayout.height); + }else { + curStyle=oneLayout._getCSSStyle(); + sprite=oneLayout; + curPadding=curStyle.padding; + curStyle._getCssFloat()===0 || (endAdjust=true); + newLine=nextNewline || curStyle.lineElement; + w=sprite.width *sprite._style._tf.scaleX+curPadding[1]+curPadding[3]+letterSpacing; + h=sprite.height *sprite._style._tf.scaleY+curPadding[0]+curPadding[2]; + nextNewline=curStyle.lineElement; + newLine=newLine || ((x+w)> width && curStyle.wordWrap); + newLine && addLine(); + } + curLine.elements.push(oneLayout); + curLine.h=Math.max(curLine.h,h); + oneLayout.x=x; + oneLayout.y=y; + x+=w; + curLine.w=x-letterSpacing; + curLine.y=y; + maxWidth=Math.max(x+exWidth,maxWidth); + } + y=curLine.y+curLine.h; + if (endAdjust){ + var tY=0; + var tWidth=width; + if (widthAuto && element.width > 0){ + tWidth=element.width; + } + for (i=0,n=lines.length;i < n;i++){ + lines[i].updatePos(0,tWidth,i,tY,align,valign,lineHeight); + tY+=Math.max(lineHeight,lines[i].h); + } + y=tY; + } + widthAuto && (element.width=maxWidth); + (y > element.height)&& (element.height=y); + return [maxWidth,y]; + } + + Layout._will=null + Layout.DIV_ELEMENT_PADDING=0; + return Layout; + })() + + + /** + *@private + */ + //class laya.html.utils.LayoutLine + var LayoutLine=(function(){ + function LayoutLine(){ + this.x=0; + this.y=0; + this.w=0; + this.h=0; + this.wordStartIndex=0; + this.minTextHeight=99999; + this.mWidth=0; + this.elements=new Array; + } + + __class(LayoutLine,'laya.html.utils.LayoutLine'); + var __proto=LayoutLine.prototype; + /** + *底对齐(默认) + *@param left + *@param width + *@param dy + *@param align 水平 + *@param valign 垂直 + *@param lineHeight 行高 + */ + __proto.updatePos=function(left,width,lineNum,dy,align,valign,lineHeight){ + var w=0; + var one + if (this.elements.length > 0){ + one=this.elements[this.elements.length-1]; + w=one.x+one.width-this.elements[0].x; + }; + var dx=0,ddy=NaN; + align===/*laya.display.css.CSSStyle.ALIGN_CENTER*/1 && (dx=(width-w)/ 2); + align===/*laya.display.css.CSSStyle.ALIGN_RIGHT*/2 && (dx=(width-w)); + lineHeight===0 || valign !=0 || (valign=1); + for (var i=0,n=this.elements.length;i < n;i++){ + one=this.elements[i]; + var tCSSStyle=one._getCSSStyle(); + dx!==0 && (one.x+=dx); + switch (tCSSStyle._getValign()){ + case 0: + one.y=dy; + break ; + case /*laya.display.css.CSSStyle.VALIGN_MIDDLE*/1:; + var tMinTextHeight=0; + if (this.minTextHeight !=99999){ + tMinTextHeight=this.minTextHeight; + }; + var tBottomLineY=(tMinTextHeight+lineHeight)/ 2; + tBottomLineY=Math.max(tBottomLineY,this.h); + if ((one instanceof laya.html.dom.HTMLImageElement )){ + ddy=dy+tBottomLineY-one.height; + }else { + ddy=dy+tBottomLineY-one.height; + } + one.y=ddy; + break ; + case /*laya.display.css.CSSStyle.VALIGN_BOTTOM*/2: + one.y=dy+(lineHeight-one.height); + break ; + } + } + } + + return LayoutLine; + })() + + + /** + *@private + */ + //class laya.html.dom.HTMLElement extends laya.display.Sprite + var HTMLElement=(function(_super){ + function HTMLElement(){ + this.URI=null; + this._href=null; + HTMLElement.__super.call(this); + this._text=HTMLElement._EMPTYTEXT; + this.setStyle(new CSSStyle(this)); + this._getCSSStyle().valign="middle"; + this.mouseEnabled=true; + } + + __class(HTMLElement,'laya.html.dom.HTMLElement',_super); + var __proto=HTMLElement.prototype; + /** + *@private + */ + __proto.layaoutCallNative=function(){ + var n=0; + if (this._childs &&(n=this._childs.length)> 0){ + for (var i=0;i < n;i++){ + this._childs[i].layaoutCallNative && this._childs[i].layaoutCallNative(); + } + }; + var word=this._getWords(); + word&&HTMLElement.fillWords(this,word,0,0,this.style.font,this.style.color); + } + + __proto.appendChild=function(c){ + return this.addChild(c); + } + + __proto._getWords=function(){ + var txt=this._text.text; + if (!txt || txt.length===0) + return null; + var words=this._text.words; + if (words && words.length===txt.length) + return words; + words===null && (this._text.words=words=[]); + words.length=txt.length; + var size; + var style=this.style; + var fontStr=style.font; + var startX=0; + for (var i=0,n=txt.length;i < n;i++){ + size=Utils.measureText(txt.charAt(i),fontStr); + var tHTMLChar=words[i]=new HTMLChar(txt.charAt(i),size.width,size.height,style); + if (this.href){ + var tSprite=new Sprite(); + this.addChild(tSprite); + tHTMLChar.setSprite(tSprite); + } + } + return words; + } + + __proto.showLinkSprite=function(){ + var words=this._text.words; + if (words){ + var tLinkSpriteList=[]; + var tSprite; + var tHtmlChar; + for (var i=0;i < words.length;i++){ + tHtmlChar=words[i]; + tSprite=new Sprite(); + tSprite.graphics.drawRect(0,0,tHtmlChar.width,tHtmlChar.height,"#ff0000"); + tSprite.width=tHtmlChar.width; + tSprite.height=tHtmlChar.height; + this.addChild(tSprite); + tLinkSpriteList.push(tSprite); + } + } + } + + __proto._layoutLater=function(){ + var style=this.style; + if ((style._type & /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200))return; + if (style.widthed(this)&& (this._childs.length>0 || this._getWords()!=null)&& style.block){ + Layout.later(this); + style._type |=/*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; + } + else{ + this.parent && (this.parent)._layoutLater(); + } + } + + __proto._setAttributes=function(name,value){ + switch (name){ + case 'style': + this.style.cssText(value); + return; + case 'class': + this.className=value; + return; + } + _super.prototype._setAttributes.call(this,name,value); + } + + __proto.updateHref=function(){ + if (this._href !=null){ + var words=this._getWords(); + if (words){ + var tHTMLChar; + var tSprite; + for (var i=0;i < words.length;i++){ + tHTMLChar=words[i]; + tSprite=tHTMLChar.getSprite(); + if (tSprite){ + var tHeight=tHTMLChar.height-1; + tSprite.graphics.drawLine(0,tHeight,tHTMLChar.width,tHeight,tHTMLChar._getCSSStyle().color); + tSprite.size(tHTMLChar.width,tHTMLChar.height); + tSprite.on(/*laya.events.Event.CLICK*/"click",this,this.onLinkHandler); + } + } + } + } + } + + __proto.onLinkHandler=function(e){ + switch(e.type){ + case /*laya.events.Event.CLICK*/"click":; + var target=this; + while (target){ + target.event(/*laya.events.Event.LINK*/"link",[this.href]); + target=target.parent; + } + break ; + } + } + + __proto.formatURL=function(url){ + return URL.formatURL(url,this.URI ? this.URI.path :null); + } + + __getset(0,__proto,'href',function(){ + return this._href; + },function(url){ + this._href=url; + if (url !=null){ + this.updateHref(); + } + }); + + __getset(0,__proto,'color',null,function(value){ + this.style.color=value; + }); + + __getset(0,__proto,'onClick',null,function(value){ + var fn; + /*__JS__ */eval("fn=function(event){"+value+";}"); + this.on(/*laya.events.Event.CLICK*/"click",this,fn); + }); + + __getset(0,__proto,'id',null,function(value){ + HTMLDocument.document.setElementById(value,this); + }); + + __getset(0,__proto,'innerTEXT',function(){ + return this._text.text; + },function(value){ + this.text=value; + }); + + __getset(0,__proto,'style',function(){ + return this._style; + }); + + __getset(0,__proto,'text',function(){ + return this._text.text; + },function(value){ + if (this._text==HTMLElement._EMPTYTEXT){ + this._text={text:value,words:null}; + } + else{ + this._text.text=value; + this._text.words && (this._text.words.length=0); + } + this._renderType |=/*laya.renders.RenderSprite.CHILDS*/0x800; + this.repaint(); + this.updateHref(); + }); + + __getset(0,__proto,'parent',_super.prototype._$get_parent,function(value){ + if ((value instanceof laya.html.dom.HTMLElement )){ + var p=value; + this.URI || (this.URI=p.URI); + this.style.inherit(p.style); + } + _super.prototype._$set_parent.call(this,value); + }); + + __getset(0,__proto,'className',null,function(value){ + this.style.attrs(HTMLDocument.document.styleSheets['.'+value]); + }); + + HTMLElement.fillWords=function(ele,words,x,y,font,color){ + ele.graphics.clear(); + for (var i=0,n=words.length;i < n;i++){ + var a=words[i]; + ele.graphics.fillText(a.char,a.x+x,a.y+y,font,color,'left'); + } + } + + HTMLElement._EMPTYTEXT={text:null,words:null}; + return HTMLElement; + })(Sprite) + + + /** + *@private + */ + //class laya.html.dom.HTMLBrElement extends laya.html.dom.HTMLElement + var HTMLBrElement=(function(_super){ + function HTMLBrElement(){ + HTMLBrElement.__super.call(this); + this.style.lineElement=true; + this.style.block=true; + } + + __class(HTMLBrElement,'laya.html.dom.HTMLBrElement',_super); + return HTMLBrElement; + })(HTMLElement) + + + /** + *DIV标签 + */ + //class laya.html.dom.HTMLDivElement extends laya.html.dom.HTMLElement + var HTMLDivElement=(function(_super){ + function HTMLDivElement(){ + this.contextHeight=NaN; + this.contextWidth=NaN; + HTMLDivElement.__super.call(this); + this.style.block=true; + this.style.lineElement=true; + this.style.width=200; + this.style.height=200; + HTMLStyleElement; + } + + __class(HTMLDivElement,'laya.html.dom.HTMLDivElement',_super); + var __proto=HTMLDivElement.prototype; + /** + *追加内容,解析并对显示对象排版 + *@param text + */ + __proto.appendHTML=function(text){ + HTMLParse.parse(this,text,this.URI); + this.layout(); + } + + /** + *@private + *@param out + *@return + */ + __proto._addChildsToLayout=function(out){ + var words=this._getWords(); + if (words==null && this._childs.length==0)return false; + words && words.forEach(function(o){ + out.push(o); + }); + var tFirstKey=true; + for (var i=0,len=this._childs.length;i < len;i++){ + var o=this._childs[i]; + if (tFirstKey){ + tFirstKey=false; + }else { + out.push(null); + } + o._addToLayout(out) + } + return true; + } + + /** + *@private + *@param out + */ + __proto._addToLayout=function(out){ + this.layout(); + } + + /** + *@private + *对显示内容进行排版 + */ + __proto.layout=function(){ + this.style._type |=/*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; + var tArray=Layout.layout(this); + if (tArray){ + if (!this._$P.mHtmlBounds)this._set$P("mHtmlBounds",new Rectangle()); + var tRectangle=this._$P.mHtmlBounds; + tRectangle.x=tRectangle.y=0; + tRectangle.width=this.contextWidth=tArray[0]; + tRectangle.height=this.contextHeight=tArray[1]; + this.setBounds(tRectangle); + } + } + + /** + *获取对象的高 + */ + __getset(0,__proto,'height',function(){ + if (this._height)return this._height; + return this.contextHeight; + },_super.prototype._$set_height); + + /** + *设置标签内容 + */ + __getset(0,__proto,'innerHTML',null,function(text){ + this.destroyChildren(); + this.appendHTML(text); + }); + + /** + *获取对象的宽 + */ + __getset(0,__proto,'width',function(){ + if (this._width)return this._width; + return this.contextWidth; + },_super.prototype._$set_width); + + return HTMLDivElement; + })(HTMLElement) + + + /** + *@private + */ + //class laya.html.dom.HTMLDocument extends laya.html.dom.HTMLElement + var HTMLDocument=(function(_super){ + function HTMLDocument(){ + this.all=new Array; + this.styleSheets=CSSStyle.styleSheets; + HTMLDocument.__super.call(this); + } + + __class(HTMLDocument,'laya.html.dom.HTMLDocument',_super); + var __proto=HTMLDocument.prototype; + __proto.getElementById=function(id){ + return this.all[id]; + } + + __proto.setElementById=function(id,e){ + this.all[id]=e; + } + + __static(HTMLDocument, + ['document',function(){return this.document=new HTMLDocument();} + ]); + return HTMLDocument; + })(HTMLElement) + + + /** + *@private + */ + //class laya.html.dom.HTMLImageElement extends laya.html.dom.HTMLElement + var HTMLImageElement=(function(_super){ + function HTMLImageElement(){ + this._tex=null; + this._url=null; + this._renderArgs=[]; + HTMLImageElement.__super.call(this); + this.style.block=true; + } + + __class(HTMLImageElement,'laya.html.dom.HTMLImageElement',_super); + var __proto=HTMLImageElement.prototype; + __proto._addToLayout=function(out){ + !this._style.absolute && out.push(this); + } + + __proto.render=function(context,x,y){ + if (!this._tex || !this._tex.loaded || !this._tex.loaded || this._width < 1 || this._height < 1)return; + Stat.spriteCount++; + this._renderArgs[0]=this._tex; + this._renderArgs[1]=this.x; + this._renderArgs[2]=this.y; + this._renderArgs[3]=this.width || this._tex.width; + this._renderArgs[4]=this.height || this._tex.height; + context.ctx.drawTexture2(x,y,this.style.translateX,this.style.translateY,this.transform,this.style.alpha,this.style.blendMode,this._renderArgs); + } + + __getset(0,__proto,'src',null,function(url){ + var _$this=this; + url=this.formatURL(url); + if (this._url==url)return; + this._url=url; + this._tex=Loader.getRes(url) + if (!this._tex){ + this._tex=new Texture(); + this._tex.load(url); + Loader.cacheRes(url,this._tex); + }; + var tex=this._tex=Loader.getRes(url); + if (!tex){ + this._tex=tex=new Texture(); + tex.load(url); + Loader.cacheRes(url,tex); + } + function onloaded (){ + var style=_$this._style; + var w=style.widthed(_$this)?-1:_$this._tex.width; + var h=style.heighted(_$this)?-1:_$this._tex.height; + if (!style.widthed(_$this)&& _$this._width !=_$this._tex.width){ + _$this.width=_$this._tex.width; + _$this.parent && (_$this.parent)._layoutLater(); + } + if (!style.heighted(_$this)&& _$this._height !=_$this._tex.height){ + _$this.height=_$this._tex.height; + _$this.parent && (_$this.parent)._layoutLater(); + } + if (Render.isConchApp){ + _$this._renderArgs[0]=_$this._tex; + _$this._renderArgs[1]=_$this.x; + _$this._renderArgs[2]=_$this.y; + _$this._renderArgs[3]=_$this.width || _$this._tex.width; + _$this._renderArgs[4]=_$this.height || _$this._tex.height; + _$this.graphics.drawTexture(_$this._tex,0,0,_$this._renderArgs[3],_$this._renderArgs[4]); + } + } + tex.loaded?onloaded():tex.on(/*laya.events.Event.LOADED*/"loaded",null,onloaded); + }); + + return HTMLImageElement; + })(HTMLElement) + + + /** + *@private + */ + //class laya.html.dom.HTMLLinkElement extends laya.html.dom.HTMLElement + var HTMLLinkElement=(function(_super){ + function HTMLLinkElement(){ + this.type=null; + HTMLLinkElement.__super.call(this); + this.visible=false; + } + + __class(HTMLLinkElement,'laya.html.dom.HTMLLinkElement',_super); + var __proto=HTMLLinkElement.prototype; + __proto._onload=function(data){ + switch(this.type){ + case 'text/css': + CSSStyle.parseCSS(data,this.URI); + break ; + } + } + + __getset(0,__proto,'href',_super.prototype._$get_href,function(url){ + var _$this=this; + url=this.formatURL(url); + this.URI=new URL(url); + var l=new Loader(); + l.once(/*laya.events.Event.COMPLETE*/"complete",null,function(data){ + _$this._onload(data); + }); + l.load(url,/*laya.net.Loader.TEXT*/"text"); + }); + + HTMLLinkElement._cuttingStyle=new RegExp("((@keyframes[\\s\\t]+|)(.+))[\\t\\n\\r\\\s]*{","g"); + return HTMLLinkElement; + })(HTMLElement) + + + /** + *@private + */ + //class laya.html.dom.HTMLStyleElement extends laya.html.dom.HTMLElement + var HTMLStyleElement=(function(_super){ + function HTMLStyleElement(){ + HTMLStyleElement.__super.call(this); + this.visible=false; + } + + __class(HTMLStyleElement,'laya.html.dom.HTMLStyleElement',_super); + var __proto=HTMLStyleElement.prototype; + /** + *解析样式 + */ + __getset(0,__proto,'text',_super.prototype._$get_text,function(value){ + CSSStyle.parseCSS(value,null); + }); + + return HTMLStyleElement; + })(HTMLElement) + + + /** + *iframe标签类,目前用于加载外并解析数据 + */ + //class laya.html.dom.HTMLIframeElement extends laya.html.dom.HTMLDivElement + var HTMLIframeElement=(function(_super){ + function HTMLIframeElement(){ + HTMLIframeElement.__super.call(this); + this._getCSSStyle().valign="middle"; + } + + __class(HTMLIframeElement,'laya.html.dom.HTMLIframeElement',_super); + var __proto=HTMLIframeElement.prototype; + /** + *加载html文件,并解析数据 + *@param url + */ + __getset(0,__proto,'href',_super.prototype._$get_href,function(url){ + var _$this=this; + url=this.formatURL(url); + var l=new Loader(); + l.once(/*laya.events.Event.COMPLETE*/"complete",null,function(data){ + var pre=_$this.URI; + _$this.URI=new URL(url); + _$this.innerHTML=data; + !pre || (_$this.URI=pre); + }); + l.load(url,/*laya.net.Loader.TEXT*/"text"); + }); + + return HTMLIframeElement; + })(HTMLDivElement) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.particle.js b/games/laya-snakes/libs/laya.particle.js new file mode 100644 index 0000000..a1ab7db --- /dev/null +++ b/games/laya-snakes/libs/laya.particle.js @@ -0,0 +1,1234 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var BlendMode=laya.webgl.canvas.BlendMode,Event=laya.events.Event,HTMLCanvas=laya.resource.HTMLCanvas; + var Handler=laya.utils.Handler,IndexBuffer2D=laya.webgl.utils.IndexBuffer2D,Loader=laya.net.Loader,MathUtil=laya.maths.MathUtil; + var Matrix=laya.maths.Matrix,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite; + var Shader=laya.webgl.shader.Shader,Sprite=laya.display.Sprite,Stage=laya.display.Stage,Stat=laya.utils.Stat; + var Texture=laya.resource.Texture,Timer=laya.utils.Timer,Utils=laya.utils.Utils,Value2D=laya.webgl.shader.d2.value.Value2D; + var VertexBuffer2D=laya.webgl.utils.VertexBuffer2D,WebGL=laya.webgl.WebGL,WebGLContext=laya.webgl.WebGLContext; + /** + *EmitterBase 类是粒子发射器类 + */ + //class laya.particle.emitter.EmitterBase + var EmitterBase=(function(){ + function EmitterBase(){ + this._frameTime=0; + this._emissionRate=60; + this._emissionTime=0; + this.minEmissionTime=1 / 60; + this._particleTemplate=null; + } + + __class(EmitterBase,'laya.particle.emitter.EmitterBase'); + var __proto=EmitterBase.prototype; + /** + *开始发射粒子 + *@param duration 发射持续的时间 + */ + __proto.start=function(duration){ + (duration===void 0)&& (duration=1.7976931348623157e+308); + if (this._emissionRate !=0) + this._emissionTime=duration; + } + + /** + *停止发射粒子 + *@param clearParticles 是否清理当前的粒子 + */ + __proto.stop=function(){ + this._emissionTime=0; + } + + /** + *清理当前的活跃粒子 + *@param clearTexture 是否清理贴图数据,若清除贴图数据将无法再播放 + */ + __proto.clear=function(){ + this._emissionTime=0; + } + + /** + *发射一个粒子 + * + */ + __proto.emit=function(){} + /** + *时钟前进 + *@param passedTime 前进时间 + * + */ + __proto.advanceTime=function(passedTime){ + (passedTime===void 0)&& (passedTime=1); + this._emissionTime-=passedTime; + if (this._emissionTime < 0)return; + this._frameTime+=passedTime; + if (this._frameTime < this.minEmissionTime)return; + while (this._frameTime > this.minEmissionTime){ + this._frameTime-=this.minEmissionTime; + this.emit(); + } + } + + /** + *设置粒子粒子模板 + *@param particleTemplate 粒子模板 + * + */ + __getset(0,__proto,'particleTemplate',null,function(particleTemplate){ + this._particleTemplate=particleTemplate; + }); + + /** + *设置粒子发射速率 + *@param emissionRate 粒子发射速率 (个/秒) + */ + /** + *获取粒子发射速率 + *@return 发射速率 粒子发射速率 (个/秒) + */ + __getset(0,__proto,'emissionRate',function(){ + return this._emissionRate; + },function(_emissionRate){ + if (_emissionRate <=0)return; + this._emissionRate=_emissionRate; + (_emissionRate > 0)&& (this.minEmissionTime=1 / _emissionRate); + }); + + return EmitterBase; + })() + + + /** + *@private + */ + //class laya.particle.ParticleData + var ParticleData=(function(){ + function ParticleData(){ + this.position=null; + this.velocity=null; + this.startColor=null; + this.endColor=null; + this.sizeRotation=null; + this.radius=null; + this.radian=null; + this.durationAddScale=NaN; + this.time=NaN; + } + + __class(ParticleData,'laya.particle.ParticleData'); + ParticleData.Create=function(settings,position,velocity,time){ + var particleData=new ParticleData(); + particleData.position=position; + MathUtil.scaleVector3(velocity,settings.emitterVelocitySensitivity,ParticleData._tempVelocity); + var horizontalVelocity=MathUtil.lerp(settings.minHorizontalVelocity,settings.maxHorizontalVelocity,Math.random()); + var horizontalAngle=Math.random()*Math.PI *2; + ParticleData._tempVelocity[0]+=horizontalVelocity *Math.cos(horizontalAngle); + ParticleData._tempVelocity[2]+=horizontalVelocity *Math.sin(horizontalAngle); + ParticleData._tempVelocity[1]+=MathUtil.lerp(settings.minVerticalVelocity,settings.maxVerticalVelocity,Math.random()); + particleData.velocity=ParticleData._tempVelocity; + particleData.startColor=ParticleData._tempStartColor; + particleData.endColor=ParticleData._tempEndColor; + var i=0; + if (settings.colorComponentInter){ + for (i=0;i < 4;i++){ + particleData.startColor[i]=MathUtil.lerp(settings.minStartColor[i],settings.maxStartColor[i],Math.random()); + particleData.endColor[i]=MathUtil.lerp(settings.minEndColor[i],settings.maxEndColor[i],Math.random()); + } + }else { + MathUtil.lerpVector4(settings.minStartColor,settings.maxStartColor,Math.random(),particleData.startColor); + MathUtil.lerpVector4(settings.minEndColor,settings.maxEndColor,Math.random(),particleData.endColor); + } + particleData.sizeRotation=ParticleData._tempSizeRotation; + var sizeRandom=Math.random(); + particleData.sizeRotation[0]=MathUtil.lerp(settings.minStartSize,settings.maxStartSize,sizeRandom); + particleData.sizeRotation[1]=MathUtil.lerp(settings.minEndSize,settings.maxEndSize,sizeRandom); + particleData.sizeRotation[2]=MathUtil.lerp(settings.minRotateSpeed,settings.maxRotateSpeed,Math.random()); + particleData.radius=ParticleData._tempRadius; + var radiusRandom=Math.random(); + particleData.radius[0]=MathUtil.lerp(settings.minStartRadius,settings.maxStartRadius,radiusRandom); + particleData.radius[1]=MathUtil.lerp(settings.minEndRadius,settings.maxEndRadius,radiusRandom); + particleData.radian=ParticleData._tempRadian; + particleData.radian[0]=MathUtil.lerp(settings.minHorizontalStartRadian,settings.maxHorizontalStartRadian,Math.random()); + particleData.radian[1]=MathUtil.lerp(settings.minVerticalStartRadian,settings.maxVerticalStartRadian,Math.random()); + var useEndRadian=settings.useEndRadian; + particleData.radian[2]=useEndRadian?MathUtil.lerp(settings.minHorizontalEndRadian,settings.maxHorizontalEndRadian,Math.random()):particleData.radian[0]; + particleData.radian[3]=useEndRadian?MathUtil.lerp(settings.minVerticalEndRadian,settings.maxVerticalEndRadian,Math.random()):particleData.radian[1]; + particleData.durationAddScale=settings.ageAddScale *Math.random(); + particleData.time=time; + return particleData; + } + + __static(ParticleData, + ['_tempVelocity',function(){return this._tempVelocity=new Float32Array(3);},'_tempStartColor',function(){return this._tempStartColor=new Float32Array(4);},'_tempEndColor',function(){return this._tempEndColor=new Float32Array(4);},'_tempSizeRotation',function(){return this._tempSizeRotation=new Float32Array(3);},'_tempRadius',function(){return this._tempRadius=new Float32Array(2);},'_tempRadian',function(){return this._tempRadian=new Float32Array(4);} + ]); + return ParticleData; + })() + + + /** + *@private + */ + //class laya.particle.ParticleEmitter + var ParticleEmitter=(function(){ + function ParticleEmitter(templet,particlesPerSecond,initialPosition){ + this._templet=null; + this._timeBetweenParticles=NaN; + this._previousPosition=null; + this._timeLeftOver=0; + this._tempVelocity=new Float32Array([0,0,0]); + this._tempPosition=new Float32Array([0,0,0]); + this._templet=templet; + this._timeBetweenParticles=1.0 / particlesPerSecond; + this._previousPosition=initialPosition; + } + + __class(ParticleEmitter,'laya.particle.ParticleEmitter'); + var __proto=ParticleEmitter.prototype; + __proto.update=function(elapsedTime,newPosition){ + elapsedTime=elapsedTime / 1000; + if (elapsedTime > 0){ + MathUtil.subtractVector3(newPosition,this._previousPosition,this._tempVelocity); + MathUtil.scaleVector3(this._tempVelocity,1 / elapsedTime,this._tempVelocity); + var timeToSpend=this._timeLeftOver+elapsedTime; + var currentTime=-this._timeLeftOver; + while (timeToSpend > this._timeBetweenParticles){ + currentTime+=this._timeBetweenParticles; + timeToSpend-=this._timeBetweenParticles; + MathUtil.lerpVector3(this._previousPosition,newPosition,currentTime / elapsedTime,this._tempPosition); + this._templet.addParticleArray(this._tempPosition,this._tempVelocity); + } + this._timeLeftOver=timeToSpend; + } + this._previousPosition[0]=newPosition[0]; + this._previousPosition[1]=newPosition[1]; + this._previousPosition[2]=newPosition[2]; + } + + return ParticleEmitter; + })() + + + /** + *ParticleSettings 类是粒子配置数据类 + */ + //class laya.particle.ParticleSetting + var ParticleSetting=(function(){ + function ParticleSetting(){ + this.textureName=null; + this.textureCount=1; + this.maxPartices=100; + this.duration=1; + this.ageAddScale=0; + this.emitterVelocitySensitivity=1; + this.minStartSize=100; + this.maxStartSize=100; + this.minEndSize=100; + this.maxEndSize=100; + this.minHorizontalVelocity=0; + this.maxHorizontalVelocity=0; + this.minVerticalVelocity=0; + this.maxVerticalVelocity=0; + this.endVelocity=1; + this.minRotateSpeed=0; + this.maxRotateSpeed=0; + this.minStartRadius=0; + this.maxStartRadius=0; + this.minEndRadius=0; + this.maxEndRadius=0; + this.minHorizontalStartRadian=0; + this.maxHorizontalStartRadian=0; + this.minVerticalStartRadian=0; + this.maxVerticalStartRadian=0; + this.useEndRadian=true; + this.minHorizontalEndRadian=0; + this.maxHorizontalEndRadian=0; + this.minVerticalEndRadian=0; + this.maxVerticalEndRadian=0; + this.colorComponentInter=false; + this.blendState=0; + this.emitterType="null"; + this.emissionRate=0; + this.sphereEmitterRadius=1; + this.sphereEmitterVelocity=0; + this.sphereEmitterVelocityAddVariance=0; + this.ringEmitterRadius=30; + this.ringEmitterVelocity=0; + this.ringEmitterVelocityAddVariance=0; + this.ringEmitterUp=2; + this.gravity=new Float32Array([0,0,0]); + this.minStartColor=new Float32Array([1,1,1,1]); + this.maxStartColor=new Float32Array([1,1,1,1]); + this.minEndColor=new Float32Array([1,1,1,1]); + this.maxEndColor=new Float32Array([1,1,1,1]); + this.pointEmitterPosition=new Float32Array([0,0,0]); + this.pointEmitterPositionVariance=new Float32Array([0,0,0]); + this.pointEmitterVelocity=new Float32Array([0,0,0]); + this.pointEmitterVelocityAddVariance=new Float32Array([0,0,0]); + this.boxEmitterCenterPosition=new Float32Array([0,0,0]); + this.boxEmitterSize=new Float32Array([0,0,0]); + this.boxEmitterVelocity=new Float32Array([0,0,0]); + this.boxEmitterVelocityAddVariance=new Float32Array([0,0,0]); + this.sphereEmitterCenterPosition=new Float32Array([0,0,0]); + this.ringEmitterCenterPosition=new Float32Array([0,0,0]); + this.positionVariance=new Float32Array([0,0,0]); + } + + __class(ParticleSetting,'laya.particle.ParticleSetting'); + ParticleSetting.checkSetting=function(setting){ + var key; + for (key in ParticleSetting._defaultSetting){ + if (!setting.hasOwnProperty(key)){ + setting[key]=ParticleSetting._defaultSetting[key]; + } + } + } + + __static(ParticleSetting, + ['_defaultSetting',function(){return this._defaultSetting=new ParticleSetting();} + ]); + return ParticleSetting; + })() + + + /** + * + *ParticleTemplateBase 类是粒子模板基类 + * + */ + //class laya.particle.ParticleTemplateBase + var ParticleTemplateBase=(function(){ + function ParticleTemplateBase(){ + this.settings=null; + this.texture=null; + } + + __class(ParticleTemplateBase,'laya.particle.ParticleTemplateBase'); + var __proto=ParticleTemplateBase.prototype; + /** + *添加一个粒子 + *@param position 粒子位置 + *@param velocity 粒子速度 + * + */ + __proto.addParticleArray=function(position,velocity){} + return ParticleTemplateBase; + })() + + + /** + *@private + */ + //class laya.particle.particleUtils.CanvasShader + var CanvasShader=(function(){ + function CanvasShader(){ + this.u_Duration=NaN; + this.u_EndVelocity=NaN; + this.u_Gravity=null; + this.a_Position=null; + this.a_Velocity=null; + this.a_StartColor=null; + this.a_EndColor=null; + this.a_SizeRotation=null; + this.a_Radius=null; + this.a_Radian=null; + this.a_AgeAddScale=NaN; + this.gl_Position=null; + this.v_Color=null; + this.oSize=NaN; + this._color=new Float32Array(4); + this._position=new Float32Array(3); + } + + __class(CanvasShader,'laya.particle.particleUtils.CanvasShader'); + var __proto=CanvasShader.prototype; + __proto.getLen=function(position){ + return Math.sqrt(position[0] *position[0]+position[1] *position[1]+position[2] *position[2]); + } + + __proto.ComputeParticlePosition=function(position,velocity,age,normalizedAge){ + this._position[0]=position[0]; + this._position[1]=position[1]; + this._position[2]=position[2]; + var startVelocity=this.getLen(velocity); + var endVelocity=startVelocity *this.u_EndVelocity; + var velocityIntegral=startVelocity *normalizedAge+(endVelocity-startVelocity)*normalizedAge *normalizedAge / 2.0; + var lenVelocity=NaN; + lenVelocity=this.getLen(velocity); + var i=0,len=0; + len=3; + for (i=0;i < len;i++){ + this._position[i]+=this._position[i]+(velocity[i] / lenVelocity)*velocityIntegral *this.u_Duration; + this._position[i]+=this.u_Gravity[i] *age *normalizedAge; + }; + var radius=MathUtil.lerp(this.a_Radius[0],this.a_Radius[1],normalizedAge); + var radianHorizontal=MathUtil.lerp(this.a_Radian[0],this.a_Radian[2],normalizedAge); + var radianVertical=MathUtil.lerp(this.a_Radian[1],this.a_Radian[3],normalizedAge); + var r=Math.cos(radianVertical)*radius; + this._position[1]+=Math.sin(radianVertical)*radius; + this._position[0]+=Math.cos(radianHorizontal)*r; + this._position[2]+=Math.sin(radianHorizontal)*r; + return new Float32Array([this._position[0],this._position[1],0.0,1.0]); + } + + __proto.ComputeParticleSize=function(startSize,endSize,normalizedAge){ + var size=MathUtil.lerp(startSize,endSize,normalizedAge); + return size; + } + + __proto.ComputeParticleRotation=function(rot,age){ + return rot *age; + } + + __proto.ComputeParticleColor=function(startColor,endColor,normalizedAge){ + var rst=this._color; + MathUtil.lerpVector4(startColor,endColor,normalizedAge,rst); + rst[3]=rst[3]*normalizedAge *(1.0-normalizedAge)*(1.0-normalizedAge)*6.7; + return rst; + } + + __proto.clamp=function(value,min,max){ + if(valuemax)return max; + return value; + } + + __proto.getData=function(age){ + age *=1.0+this.a_AgeAddScale; + var normalizedAge=this.clamp(age / this.u_Duration,0.0,1.0); + this.gl_Position=this.ComputeParticlePosition(this.a_Position,this.a_Velocity,age,normalizedAge); + var pSize=this.ComputeParticleSize(this.a_SizeRotation[0],this.a_SizeRotation[1],normalizedAge); + var rotation=this.ComputeParticleRotation(this.a_SizeRotation[2],age); + this.v_Color=this.ComputeParticleColor(this.a_StartColor,this.a_EndColor,normalizedAge); + var matric=new Matrix(); + var scale=NaN; + scale=pSize/this.oSize*2; + matric.scale(scale,scale); + matric.rotate(rotation); + matric.setTranslate(this.gl_Position[0],-this.gl_Position[1]); + var alpha=NaN; + alpha=this.v_Color[3]; + return [this.v_Color,alpha,matric,this.v_Color[0]*alpha,this.v_Color[1]*alpha,this.v_Color[2]*alpha]; + } + + return CanvasShader; + })() + + + /** + * + *@private + * + *@created 2015-8-25 下午3:41:07 + */ + //class laya.particle.particleUtils.CMDParticle + var CMDParticle=(function(){ + function CMDParticle(){ + this.maxIndex=0; + this.cmds=null; + this.id=0; + } + + __class(CMDParticle,'laya.particle.particleUtils.CMDParticle'); + var __proto=CMDParticle.prototype; + __proto.setCmds=function(cmds){ + this.cmds=cmds; + this.maxIndex=cmds.length-1; + } + + return CMDParticle; + })() + + + //class laya.particle.particleUtils.PicTool + var PicTool=(function(){ + function PicTool(){}; + __class(PicTool,'laya.particle.particleUtils.PicTool'); + PicTool.getCanvasPic=function(img,color){ + img=img.bitmap; + var canvas=new HTMLCanvas("2D"); + var ctx=canvas.getContext('2d'); + canvas.size(img.width,img.height); + var red=(color >> 16 & 0xFF); + var green=(color >> 8 & 0xFF); + var blue=(color & 0xFF); + if(Render.isConchApp){ + ctx.setFilter(red/255,green/255,blue/255,0); + } + ctx.drawImage(img.source,0,0); + if (!Render.isConchApp){ + var imgdata=ctx.getImageData(0,0,canvas.width,canvas.height); + var data=imgdata.data; + for (var i=0,n=data.length;i < n;i+=4){ + if (data[i+3]==0)continue ; + data[i]=red; + data[i+1]=green; + data[i+2]=blue; + } + ctx.putImageData(imgdata,0,0); + } + return canvas; + } + + PicTool.getRGBPic=function(img){ + var rst; + rst=[new Texture(PicTool.getCanvasPic(img,0xFF0000)),new Texture(PicTool.getCanvasPic(img,0x00FF00)),new Texture(PicTool.getCanvasPic(img,0x0000FF))]; + return rst; + } + + return PicTool; + })() + + + /** + * + *@private + */ + //class laya.particle.emitter.Emitter2D extends laya.particle.emitter.EmitterBase + var Emitter2D=(function(_super){ + function Emitter2D(_template){ + this.setting=null; + this._posRange=null; + this._canvasTemplate=null; + this._emitFun=null; + Emitter2D.__super.call(this); + this.template=_template; + } + + __class(Emitter2D,'laya.particle.emitter.Emitter2D',_super); + var __proto=Emitter2D.prototype; + __proto.emit=function(){ + _super.prototype.emit.call(this); + if(this._emitFun!=null) + this._emitFun(); + } + + __proto.getRandom=function(value){ + return (Math.random()*2-1)*value; + } + + __proto.webGLEmit=function(){ + var pos=new Float32Array(3); + pos[0]=this.getRandom(this._posRange[0]); + pos[1]=this.getRandom(this._posRange[1]); + pos[2]=this.getRandom(this._posRange[2]); + var v=new Float32Array(3); + v[0]=0; + v[1]=0; + v[2]=0; + this._particleTemplate.addParticleArray(pos,v); + } + + __proto.canvasEmit=function(){ + var pos=new Float32Array(3); + pos[0]=this.getRandom(this._posRange[0]); + pos[1]=this.getRandom(this._posRange[1]); + pos[2]=this.getRandom(this._posRange[2]); + var v=new Float32Array(3); + v[0]=0; + v[1]=0; + v[2]=0; + this._particleTemplate.addParticleArray(pos,v); + } + + __getset(0,__proto,'template',function(){ + return this._particleTemplate; + },function(template){ + this._particleTemplate=template; + if (!template){ + this._emitFun=null; + this.setting=null; + this._posRange=null; + }; + this.setting=template.settings; + this._posRange=this.setting.positionVariance; + if((this._particleTemplate instanceof laya.particle.ParticleTemplate2D )){ + this._emitFun=this.webGLEmit; + }else + if((this._particleTemplate instanceof laya.particle.ParticleTemplateCanvas )){ + this._canvasTemplate=template; + this._emitFun=this.canvasEmit; + } + }); + + return Emitter2D; + })(EmitterBase) + + + /** + *@private + */ + //class laya.particle.ParticleTemplateWebGL extends laya.particle.ParticleTemplateBase + var ParticleTemplateWebGL=(function(_super){ + function ParticleTemplateWebGL(parSetting){ + this._vertices=null; + this._vertexBuffer=null; + this._indexBuffer=null; + this._floatCountPerVertex=29; + this._firstActiveElement=0; + this._firstNewElement=0; + this._firstFreeElement=0; + this._firstRetiredElement=0; + this._currentTime=0; + this._drawCounter=0; + ParticleTemplateWebGL.__super.call(this); + this.settings=parSetting; + } + + __class(ParticleTemplateWebGL,'laya.particle.ParticleTemplateWebGL',_super); + var __proto=ParticleTemplateWebGL.prototype; + __proto.initialize=function(){ + this._vertices=new Float32Array(this.settings.maxPartices *this._floatCountPerVertex *4); + var particleOffset=0; + for (var i=0;i < this.settings.maxPartices;i++){ + var random=Math.random(); + var cornerYSegement=this.settings.textureCount ? 1.0 / this.settings.textureCount :1.0; + var cornerY=NaN; + for (cornerY=0;cornerY < this.settings.textureCount;cornerY+=cornerYSegement){ + if (random < cornerY+cornerYSegement) + break ; + } + particleOffset=i *this._floatCountPerVertex *4; + this._vertices[particleOffset+this._floatCountPerVertex *0+0]=-1; + this._vertices[particleOffset+this._floatCountPerVertex *0+1]=-1; + this._vertices[particleOffset+this._floatCountPerVertex *0+2]=0; + this._vertices[particleOffset+this._floatCountPerVertex *0+3]=cornerY; + this._vertices[particleOffset+this._floatCountPerVertex *1+0]=1; + this._vertices[particleOffset+this._floatCountPerVertex *1+1]=-1; + this._vertices[particleOffset+this._floatCountPerVertex *1+2]=1; + this._vertices[particleOffset+this._floatCountPerVertex *1+3]=cornerY; + this._vertices[particleOffset+this._floatCountPerVertex *2+0]=1; + this._vertices[particleOffset+this._floatCountPerVertex *2+1]=1; + this._vertices[particleOffset+this._floatCountPerVertex *2+2]=1; + this._vertices[particleOffset+this._floatCountPerVertex *2+3]=cornerY+cornerYSegement; + this._vertices[particleOffset+this._floatCountPerVertex *3+0]=-1; + this._vertices[particleOffset+this._floatCountPerVertex *3+1]=1; + this._vertices[particleOffset+this._floatCountPerVertex *3+2]=0; + this._vertices[particleOffset+this._floatCountPerVertex *3+3]=cornerY+cornerYSegement; + } + } + + __proto.loadContent=function(){} + __proto.update=function(elapsedTime){ + this._currentTime+=elapsedTime / 1000; + this.retireActiveParticles(); + this.freeRetiredParticles(); + if (this._firstActiveElement==this._firstFreeElement) + this._currentTime=0; + if (this._firstRetiredElement==this._firstActiveElement) + this._drawCounter=0; + } + + __proto.retireActiveParticles=function(){ + var particleDuration=this.settings.duration; + while (this._firstActiveElement !=this._firstNewElement){ + var index=this._firstActiveElement *this._floatCountPerVertex *4+28; + var particleAge=this._currentTime-this._vertices[index]; + if (particleAge < particleDuration) + break ; + this._vertices[index]=this._drawCounter; + this._firstActiveElement++; + if (this._firstActiveElement >=this.settings.maxPartices) + this._firstActiveElement=0; + } + } + + __proto.freeRetiredParticles=function(){ + while (this._firstRetiredElement !=this._firstActiveElement){ + var age=this._drawCounter-this._vertices[this._firstRetiredElement *this._floatCountPerVertex *4+28]; + if (age < 3) + break ; + this._firstRetiredElement++; + if (this._firstRetiredElement >=this.settings.maxPartices) + this._firstRetiredElement=0; + } + } + + __proto.addNewParticlesToVertexBuffer=function(){} + __proto.addParticleArray=function(position,velocity){ + var nextFreeParticle=this._firstFreeElement+1; + if (nextFreeParticle >=this.settings.maxPartices) + nextFreeParticle=0; + if (nextFreeParticle===this._firstRetiredElement) + return; + var particleData=ParticleData.Create(this.settings,position,velocity,this._currentTime); + var startIndex=this._firstFreeElement *this._floatCountPerVertex *4; + for (var i=0;i < 4;i++){ + var j=0,offset=0; + for (j=0,offset=4;j < 3;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.position[j]; + for (j=0,offset=7;j < 3;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.velocity[j]; + for (j=0,offset=10;j < 4;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.startColor[j]; + for (j=0,offset=14;j < 4;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.endColor[j]; + for (j=0,offset=18;j < 3;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.sizeRotation[j]; + for (j=0,offset=21;j < 2;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.radius[j]; + for (j=0,offset=23;j < 4;j++) + this._vertices[startIndex+i *this._floatCountPerVertex+offset+j]=particleData.radian[j]; + this._vertices[startIndex+i *this._floatCountPerVertex+27]=particleData.durationAddScale; + this._vertices[startIndex+i *this._floatCountPerVertex+28]=particleData.time; + } + this._firstFreeElement=nextFreeParticle; + } + + return ParticleTemplateWebGL; + })(ParticleTemplateBase) + + + /** + *@private + */ + //class laya.particle.ParticleTemplateCanvas extends laya.particle.ParticleTemplateBase + var ParticleTemplateCanvas=(function(_super){ + function ParticleTemplateCanvas(particleSetting){ + this._ready=false; + this.textureList=[]; + this.particleList=[]; + this.pX=0; + this.pY=0; + this.activeParticles=[]; + this.deadParticles=[]; + this.iList=[]; + this._maxNumParticles=0; + this.textureWidth=NaN; + this.dTextureWidth=NaN; + this.colorChange=true; + this.step=1/60; + this.canvasShader=new CanvasShader(); + ParticleTemplateCanvas.__super.call(this); + this.settings=particleSetting; + this._maxNumParticles=particleSetting.maxPartices; + this.texture=new Texture(); + this.texture.on(/*laya.events.Event.LOADED*/"loaded",this,this._textureLoaded); + this.texture.load(particleSetting.textureName); + } + + __class(ParticleTemplateCanvas,'laya.particle.ParticleTemplateCanvas',_super); + var __proto=ParticleTemplateCanvas.prototype; + __proto._textureLoaded=function(e){ + this.setTexture(this.texture); + this._ready=true; + } + + __proto.clear=function(clearTexture){ + (clearTexture===void 0)&& (clearTexture=true); + this.deadParticles.length=0; + this.activeParticles.length=0; + this.textureList.length=0; + } + + /** + *设置纹理 + *@param texture + * + */ + __proto.setTexture=function(texture){ + this.texture=texture; + this.textureWidth=texture.width; + this.dTextureWidth=1/this.textureWidth; + this.pX=-texture.width*0.5; + this.pY=-texture.height*0.5; + this.textureList=ParticleTemplateCanvas.changeTexture(texture,this.textureList); + this.particleList.length=0; + this.deadParticles.length=0; + this.activeParticles.length=0; + } + + /** + *创建一个粒子数据 + *@return + * + */ + __proto._createAParticleData=function(position,velocity){ + this.canvasShader.u_EndVelocity=this.settings.endVelocity; + this.canvasShader.u_Gravity=this.settings.gravity; + this.canvasShader.u_Duration=this.settings.duration; + var particle; + particle=ParticleData.Create(this.settings,position,velocity,0); + this.canvasShader.a_Position=particle.position; + this.canvasShader.a_Velocity=particle.velocity; + this.canvasShader.a_StartColor=particle.startColor; + this.canvasShader.a_EndColor=particle.endColor; + this.canvasShader.a_SizeRotation=particle.sizeRotation; + this.canvasShader.a_Radius=particle.radius; + this.canvasShader.a_Radian=particle.radian; + this.canvasShader.a_AgeAddScale=particle.durationAddScale; + this.canvasShader.oSize=this.textureWidth; + var rst=new CMDParticle(); + var i=0,len=this.settings.duration/(1+particle.durationAddScale); + var params=[]; + var mStep=NaN; + for(i=0;i0){ + tParticle=this.deadParticles.pop(); + this.iList[tParticle.id]=0; + this.activeParticles.push(tParticle); + } + } + } + + __proto.advanceTime=function(passedTime){ + (passedTime===void 0)&& (passedTime=1); + if(!this._ready)return; + var particleList=this.activeParticles; + var pool=this.deadParticles; + var i=0,len=particleList.length; + var tcmd; + var tI=0; + var iList=this.iList; + for(i=len-1;i>-1;i--){ + tcmd=particleList[i]; + tI=iList[tcmd.id]; + if(tI>=tcmd.maxIndex){ + tI=0; + particleList.splice(i,1); + pool.push(tcmd); + }else{ + tI+=1; + } + iList[tcmd.id]=tI; + } + } + + __proto.render=function(context,x,y){ + if(!this._ready)return; + if(this.activeParticles.length<1)return; + if (this.textureList.length < 2)return; + if (this.settings.colorComponentInter){ + this.noColorRender(context,x,y); + }else{ + this.canvasRender(context,x,y); + } + } + + __proto.noColorRender=function(context,x,y){ + var particleList=this.activeParticles; + var i=0,len=particleList.length; + var tcmd; + var tParam; + var tAlpha=NaN; + var px=this.pX,py=this.pY; + var pw=-px*2,ph=-py*2; + var tI=0; + var textureList=this.textureList; + var iList=this.iList; + var preAlpha=NaN; + context.translate(x,y); + preAlpha=context.ctx.globalAlpha; + for(i=0;i0.01){ + context.setAlpha(preAlpha*tParam[3]); + context.drawTexture(textureList[0],px,py,pw,ph); + } + if(tParam[4]>0.01){ + context.setAlpha(preAlpha*tParam[4]); + context.drawTexture(textureList[1],px,py,pw,ph); + } + if(tParam[5]>0.01){ + context.setAlpha(preAlpha*tParam[5]); + context.drawTexture(textureList[2],px,py,pw,ph); + } + context.restore(); + } + context.setAlpha(preAlpha); + context.translate(-x,-y); + context.blendMode(preB); + } + + ParticleTemplateCanvas.changeTexture=function(texture,rst,settings){ + if(!rst)rst=[]; + rst.length=0; + if (settings&&settings.colorComponentInter){ + rst.push(texture,texture,texture); + }else{ + Utils.copyArray(rst,PicTool.getRGBPic(texture)); + } + return rst; + } + + return ParticleTemplateCanvas; + })(ParticleTemplateBase) + + + /** + *@private + */ + //class laya.particle.ParticleTemplate2D extends laya.particle.ParticleTemplateWebGL + var ParticleTemplate2D=(function(_super){ + function ParticleTemplate2D(parSetting){ + this._vertexBuffer2D=null; + this._indexBuffer2D=null; + this.x=0; + this.y=0; + this._blendFn=null; + this._startTime=0; + this.sv=new ParticleShaderValue(); + ParticleTemplate2D.__super.call(this,parSetting); + var _this=this; + Laya.loader.load(this.settings.textureName,Handler.create(null,function(texture){ + (texture.bitmap).enableMerageInAtlas=false; + _this.texture=texture; + })); + this.sv.u_Duration=this.settings.duration; + this.sv.u_Gravity=this.settings.gravity; + this.sv.u_EndVelocity=this.settings.endVelocity; + this._blendFn=BlendMode.fns[parSetting.blendState]; + this.initialize(); + this._vertexBuffer=this._vertexBuffer2D=VertexBuffer2D.create(-1,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8); + this._indexBuffer=this._indexBuffer2D=IndexBuffer2D.create(/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4); + this.loadContent(); + } + + __class(ParticleTemplate2D,'laya.particle.ParticleTemplate2D',_super); + var __proto=ParticleTemplate2D.prototype; + Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true}) + __proto.getRenderType=function(){return-111} + __proto.releaseRender=function(){} + __proto.addParticleArray=function(position,velocity){ + position[0]+=this.x; + position[1]+=this.y; + _super.prototype.addParticleArray.call(this,position,velocity); + } + + __proto.loadContent=function(){ + var indexes=new Uint16Array(this.settings.maxPartices *6); + for (var i=0;i < this.settings.maxPartices;i++){ + indexes[i *6+0]=(i *4+0); + indexes[i *6+1]=(i *4+1); + indexes[i *6+2]=(i *4+2); + indexes[i *6+3]=(i *4+0); + indexes[i *6+4]=(i *4+2); + indexes[i *6+5]=(i *4+3); + } + this._indexBuffer2D.clear(); + this._indexBuffer2D.append(indexes); + this._indexBuffer2D.upload(); + } + + __proto.addNewParticlesToVertexBuffer=function(){ + this._vertexBuffer2D.clear(); + this._vertexBuffer2D.append(this._vertices); + var start=0; + if (this._firstNewElement < this._firstFreeElement){ + start=this._firstNewElement *4 *this._floatCountPerVertex *4; + this._vertexBuffer2D.subUpload(start,start,start+(this._firstFreeElement-this._firstNewElement)*4 *this._floatCountPerVertex *4); + }else { + start=this._firstNewElement *4 *this._floatCountPerVertex *4; + this._vertexBuffer2D.subUpload(start,start,start+(this.settings.maxPartices-this._firstNewElement)*4 *this._floatCountPerVertex *4); + if (this._firstFreeElement > 0){ + this._vertexBuffer2D.setNeedUpload(); + this._vertexBuffer2D.subUpload(0,0,this._firstFreeElement *4 *this._floatCountPerVertex *4); + } + } + this._firstNewElement=this._firstFreeElement; + } + + __proto.renderSubmit=function(){ + if (this.texture&&this.texture.loaded){ + this.update(Laya.timer.delta); + this.sv.u_CurrentTime=this._currentTime; + if (this._firstNewElement !=this._firstFreeElement){ + this.addNewParticlesToVertexBuffer(); + } + this.blend(); + if (this._firstActiveElement !=this._firstFreeElement){ + var gl=WebGL.mainContext; + this._vertexBuffer2D.bind(this._indexBuffer2D); + this.sv.u_texture=this.texture.source; + this.sv.upload(); + if (this._firstActiveElement < this._firstFreeElement){ + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,(this._firstFreeElement-this._firstActiveElement)*6,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + } + else{ + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,(this.settings.maxPartices-this._firstActiveElement)*6,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._firstActiveElement *6 *2); + if (this._firstFreeElement > 0) + WebGL.mainContext.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._firstFreeElement *6,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0); + } + Stat.drawCall++; + } + this._drawCounter++; + } + return 1; + } + + __proto.blend=function(){ + if (BlendMode.activeBlendFunction!==this._blendFn){ + var gl=WebGL.mainContext; + gl.enable(/*laya.webgl.WebGLContext.BLEND*/0x0BE2); + this._blendFn(gl); + BlendMode.activeBlendFunction=this._blendFn; + } + } + + __proto.dispose=function(){ + this._vertexBuffer2D.dispose(); + this._indexBuffer2D.dispose(); + } + + ParticleTemplate2D.activeBlendType=-1; + return ParticleTemplate2D; + })(ParticleTemplateWebGL) + + + /** + *@private + */ + //class laya.particle.shader.value.ParticleShaderValue extends laya.webgl.shader.d2.value.Value2D + var ParticleShaderValue=(function(_super){ + function ParticleShaderValue(){ + this.a_CornerTextureCoordinate=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,0]; + this.a_Position=[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,16]; + this.a_Velocity=[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,28]; + this.a_StartColor=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,40]; + this.a_EndColor=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,56]; + this.a_SizeRotation=[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,72]; + this.a_Radius=[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,84]; + this.a_Radian=[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,92]; + this.a_AgeAddScale=[1,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,108]; + this.a_Time=[1,/*laya.webgl.WebGLContext.FLOAT*/0x1406,false,116,112]; + this.u_CurrentTime=NaN; + this.u_Duration=NaN; + this.u_Gravity=null; + this.u_EndVelocity=NaN; + this.u_texture=null; + ParticleShaderValue.__super.call(this,0,0); + } + + __class(ParticleShaderValue,'laya.particle.shader.value.ParticleShaderValue',_super); + var __proto=ParticleShaderValue.prototype; + __proto.upload=function(){ + this.refresh(); + ParticleShaderValue.pShader.upload(this); + } + + __static(ParticleShaderValue, + ['pShader',function(){return this.pShader=new ParticleShader();} + ]); + return ParticleShaderValue; + })(Value2D) + + + /** + *Particle2D 类是2D粒子播放类 + * + */ + //class laya.particle.Particle2D extends laya.display.Sprite + var Particle2D=(function(_super){ + function Particle2D(setting){ + this._matrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]; + this._particleTemplate=null; + this._canvasTemplate=null; + this._emitter=null; + this.autoPlay=true; + Particle2D.__super.call(this); + if (setting)this.setParticleSetting(setting); + } + + __class(Particle2D,'laya.particle.Particle2D',_super); + var __proto=Particle2D.prototype; + /** + *加载粒子文件 + *@param url 粒子文件地址 + */ + __proto.load=function(url){ + Laya.loader.load(url,Handler.create(this,this.setParticleSetting),null,/*laya.net.Loader.JSON*/"json"); + } + + /** + *设置粒子配置数据 + *@param settings 粒子配置数据 + */ + __proto.setParticleSetting=function(setting){ + var _$this=this; + if (!setting)return this.stop(); + ParticleSetting.checkSetting(setting); + if(/*__JS__ */!window.ConchParticleTemplate2D||Render.isWebGL)this.customRenderEnable=true; + if (Render.isWebGL){ + this._particleTemplate=new ParticleTemplate2D(setting); + this.graphics._saveToCmd(Render.context._drawParticle,[this._particleTemplate]); + } + else if (Render.isConchApp&&/*__JS__ */window.ConchParticleTemplate2D){ + this._particleTemplate=/*__JS__ */new ConchParticleTemplate2D(); + var _this=this; + Laya.loader.load(setting.textureName,Handler.create(null,function(texture){ + /*__JS__ */_this._particleTemplate.texture=texture; + _this._particleTemplate.settings=setting; + if (Render.isConchNode){ + /*__JS__ */_this.graphics.drawParticle(_this._particleTemplate); + } + else{ + _this.graphics._saveToCmd(Render.context._drawParticle,[_$this._particleTemplate]); + } + })); + this._emitter={start:function (){}}; + /*__JS__ */this.play=this._particleTemplate.play.bind(this._particleTemplate); + /*__JS__ */this.stop=this._particleTemplate.stop.bind(this._particleTemplate); + if (this.autoPlay)this.play(); + return; + } + else { + this._particleTemplate=this._canvasTemplate=new ParticleTemplateCanvas(setting); + } + if (!this._emitter){ + this._emitter=new Emitter2D(this._particleTemplate); + }else { + (this._emitter).template=this._particleTemplate; + } + if (this.autoPlay){ + this.emitter.start(); + this.play(); + } + } + + /** + *播放 + */ + __proto.play=function(){ + Laya.timer.frameLoop(1,this,this._loop); + } + + /** + *停止 + */ + __proto.stop=function(){ + Laya.timer.clear(this,this._loop); + } + + /**@private */ + __proto._loop=function(){ + this.advanceTime(1 / 60); + } + + /** + *时钟前进 + *@param passedTime 时钟前进时间 + */ + __proto.advanceTime=function(passedTime){ + (passedTime===void 0)&& (passedTime=1); + if (this._canvasTemplate){ + this._canvasTemplate.advanceTime(passedTime); + } + if (this._emitter){ + this._emitter.advanceTime(passedTime); + } + } + + __proto.customRender=function(context,x,y){ + if (Render.isWebGL){ + this._matrix4[0]=context.ctx._curMat.a; + this._matrix4[1]=context.ctx._curMat.b; + this._matrix4[4]=context.ctx._curMat.c; + this._matrix4[5]=context.ctx._curMat.d; + this._matrix4[12]=context.ctx._curMat.tx; + this._matrix4[13]=context.ctx._curMat.ty; + var sv=(this._particleTemplate).sv; + sv.u_mmat=this._matrix4; + } + if (this._canvasTemplate){ + this._canvasTemplate.render(context,x,y); + } + } + + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + if ((this._particleTemplate instanceof laya.particle.ParticleTemplate2D )) + (this._particleTemplate).dispose(); + _super.prototype.destroy.call(this,destroyChild); + } + + /** + *设置 粒子文件地址 + *@param path 粒子文件地址 + */ + __getset(0,__proto,'url',null,function(url){ + this.load(url); + }); + + /** + *获取粒子发射器 + */ + __getset(0,__proto,'emitter',function(){ + return this._emitter; + }); + + return Particle2D; + })(Sprite) + + + /** + *@private + */ + //class laya.particle.shader.ParticleShader extends laya.webgl.shader.Shader + var ParticleShader=(function(_super){ + function ParticleShader(){ + ParticleShader.__super.call(this,ParticleShader.vs,ParticleShader.ps,"ParticleShader"); + } + + __class(ParticleShader,'laya.particle.shader.ParticleShader',_super); + __static(ParticleShader, + ['vs',function(){return this.vs="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Velocity;\nattribute vec4 a_StartColor;\nattribute vec4 a_EndColor;\nattribute vec3 a_SizeRotation;\nattribute vec2 a_Radius;\nattribute vec4 a_Radian;\nattribute float a_AgeAddScale;\nattribute float a_Time;\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform float u_Duration;\nuniform float u_EndVelocity;\nuniform vec3 u_Gravity;\n\n#ifdef PARTICLE3D\n uniform mat4 u_WorldMat;\n uniform mat4 u_View;\n uniform mat4 u_Projection;\n uniform vec2 u_ViewportScale;\n#else\n uniform vec2 size;\n uniform mat4 mmat;\n uniform mat4 u_mmat;\n#endif\n\nvec4 ComputeParticlePosition(in vec3 position, in vec3 velocity,in float age,in float normalizedAge)\n{\n\n float startVelocity = length(velocity);//起始标量速度\n float endVelocity = startVelocity * u_EndVelocity;//结束标量速度\n\n float velocityIntegral = startVelocity * normalizedAge +(endVelocity - startVelocity) * normalizedAge *normalizedAge/2.0;//计算当前速度的标量(单位空间),vt=v0*t+(1/2)*a*(t^2)\n \n vec3 addPosition = normalize(velocity) * velocityIntegral * u_Duration;//计算受自身速度影响的位置,转换标量到矢量 \n addPosition += u_Gravity * age * normalizedAge;//计算受重力影响的位置\n \n float radius=mix(a_Radius.x, a_Radius.y, normalizedAge); //计算粒子受半径和角度影响(无需计算角度和半径时,可用宏定义优化屏蔽此计算)\n float radianHorizontal =mix(a_Radian.x,a_Radian.z,normalizedAge);\n float radianVertical =mix(a_Radian.y,a_Radian.w,normalizedAge);\n \n float r =cos(radianVertical)* radius;\n addPosition.y += sin(radianVertical) * radius;\n \n addPosition.x += cos(radianHorizontal) *r;\n addPosition.z += sin(radianHorizontal) *r;\n \n #ifdef PARTICLE3D\n position+=addPosition;\n return u_Projection*u_View*u_WorldMat*(vec4(position, 1.0));\n #else\n addPosition.y=-addPosition.y;//2D粒子位置更新需要取负,2D粒子坐标系Y轴正向朝上\n position+=addPosition;\n return vec4(position,1.0);\n #endif\n}\n\nfloat ComputeParticleSize(in float startSize,in float endSize, in float normalizedAge)\n{ \n float size = mix(startSize, endSize, normalizedAge);\n \n #ifdef PARTICLE3D\n //Project the size into screen coordinates.\n return size * u_Projection[1][1];\n #else\n return size;\n #endif\n}\n\nmat2 ComputeParticleRotation(in float rot,in float age)\n{ \n float rotation =rot * age;\n //计算2x2旋转矩阵.\n float c = cos(rotation);\n float s = sin(rotation);\n return mat2(c, -s, s, c);\n}\n\nvec4 ComputeParticleColor(in vec4 startColor,in vec4 endColor,in float normalizedAge)\n{\n vec4 color=mix(startColor,endColor,normalizedAge);\n //硬编码设置,使粒子淡入很快,淡出很慢,6.7的缩放因子把置归一在0到1之间,可以谷歌x*(1-x)*(1-x)*6.7的制图表\n color.a *= normalizedAge * (1.0-normalizedAge) * (1.0-normalizedAge) * 6.7;\n \n return color;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n age *= 1.0 + a_AgeAddScale;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n gl_Position = ComputeParticlePosition(a_Position, a_Velocity, age, normalizedAge);//计算粒子位置\n float pSize = ComputeParticleSize(a_SizeRotation.x,a_SizeRotation.y, normalizedAge);\n mat2 rotation = ComputeParticleRotation(a_SizeRotation.z, age);\n \n #ifdef PARTICLE3D\n gl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize * u_ViewportScale;\n #else\n mat4 mat=u_mmat*mmat;\n gl_Position=vec4((mat*gl_Position).xy,0.0,1.0);\n gl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize*vec2(mat[0][0],mat[1][1]);\n gl_Position=vec4((gl_Position.x/size.x-0.5)*2.0,(0.5-gl_Position.y/size.y)*2.0,0.0,1.0);\n #endif\n \n v_Color = ComputeParticleColor(a_StartColor,a_EndColor, normalizedAge);\n v_TextureCoordinate =a_CornerTextureCoordinate.zw;\n}\n\n"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/particle/src/laya/particle/shader/files/Particle.vs*/;},'ps',function(){return this.ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\nvoid main()\n{ \n gl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n}"/*__INCLUDESTR__E:/trank/libs/LayaAir/publish/LayaAirPublish/branch/src/particle/src/laya/particle/shader/files/Particle.ps*/;} + ]); + return ParticleShader; + })(Shader) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.pathfinding.js b/games/laya-snakes/libs/laya.pathfinding.js new file mode 100644 index 0000000..5166f1d --- /dev/null +++ b/games/laya-snakes/libs/laya.pathfinding.js @@ -0,0 +1,2026 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + /** + *... + *@author dongketao + */ + //class PathFinding.core.DiagonalMovement + var DiagonalMovement=(function(){ + function DiagonalMovement(){} + __class(DiagonalMovement,'PathFinding.core.DiagonalMovement'); + DiagonalMovement.Always=1; + DiagonalMovement.Never=2; + DiagonalMovement.IfAtMostOneObstacle=3; + DiagonalMovement.OnlyWhenNoObstacles=4; + return DiagonalMovement; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.core.Grid + var Grid=(function(){ + function Grid(width_or_matrix,height,matrix){ + this.width=0; + this.height=0; + this.nodes=null; + var width=0; + if ((typeof width_or_matrix=='number')){ + width=width_or_matrix; + } + else{ + height=width_or_matrix.length; + width=width_or_matrix[0].length; + matrix=width_or_matrix; + } + this.width=width; + this.height=height; + this.nodes=this._buildNodes(width,height,matrix); + } + + __class(Grid,'PathFinding.core.Grid'); + var __proto=Grid.prototype; + /** + *Build and return the nodes. + *@private + *@param {number}width + *@param {number}height + *@param {Array>}[matrix]-A 0-1 matrix representing + *the walkable status of the nodes. + *@see Grid + */ + __proto._buildNodes=function(width,height,matrix){ + var i=0,j=0,nodes=[]; + for (i=0;i < height;++i){ + nodes[i]=[]; + for (j=0;j < width;++j){ + nodes[i][j]=new Node1(j,i); + } + } + if (matrix==null){ + return nodes; + } + if (matrix.length !=height || matrix[0].length !=width){ + throw new Error('Matrix size does not fit'); + } + for (i=0;i < height;++i){ + for (j=0;j < width;++j){ + if (matrix[i][j]){ + nodes[i][j].walkable=false; + } + } + } + return nodes; + } + + __proto.getNodeAt=function(x,y){ + return this.nodes[y][x]; + } + + /** + *Determine whether the node at the given position is walkable. + *(Also returns false if the position is outside the grid.) + *@param {number}x-The x coordinate of the node. + *@param {number}y-The y coordinate of the node. + *@return {boolean}-The walkability of the node. + */ + __proto.isWalkableAt=function(x,y){ + return this.isInside(x,y)&& this.nodes[y][x].walkable; + } + + /** + *Determine whether the position is inside the grid. + *XXX:`grid.isInside(x,y)` is wierd to read. + *It should be `(x,y)is inside grid`,but I failed to find a better + *name for this method. + *@param {number}x + *@param {number}y + *@return {boolean} + */ + __proto.isInside=function(x,y){ + return (x >=0 && x < this.width)&& (y >=0 && y < this.height); + } + + /** + *Set whether the node on the given position is walkable. + *NOTE:throws exception if the coordinate is not inside the grid. + *@param {number}x-The x coordinate of the node. + *@param {number}y-The y coordinate of the node. + *@param {boolean}walkable-Whether the position is walkable. + */ + __proto.setWalkableAt=function(x,y,walkable){ + this.nodes[y][x].walkable=walkable; + } + + /** + *Get the neighbors of the given node. + * + *offsets diagonalOffsets: + *+---+---+---++---+---+---+ + *| | 0 | | | 0 | | 1 | + *+---+---+---++---+---+---+ + *| 3 | | 1 | | | | | + *+---+---+---++---+---+---+ + *| | 2 | | | 3 | | 2 | + *+---+---+---++---+---+---+ + * + *When allowDiagonal is true,if offsets[i] is valid,then + *diagonalOffsets[i] and + *diagonalOffsets[(i+1)% 4] is valid. + *@param {Node}node + *@param {diagonalMovement}diagonalMovement + */ + __proto.getNeighbors=function(node,diagonalMovement){ + var x=node.x,y=node.y,neighbors=[],s0=false,d0=false,s1=false,d1=false,s2=false,d2=false,s3=false,d3=false,nodes=this.nodes; + if (this.isWalkableAt(x,y-1)){ + neighbors.push(nodes[y-1][x]); + s0=true; + } + if (this.isWalkableAt(x+1,y)){ + neighbors.push(nodes[y][x+1]); + s1=true; + } + if (this.isWalkableAt(x,y+1)){ + neighbors.push(nodes[y+1][x]); + s2=true; + } + if (this.isWalkableAt(x-1,y)){ + neighbors.push(nodes[y][x-1]); + s3=true; + } + if (diagonalMovement==DiagonalMovement.Never){ + return neighbors; + } + if (diagonalMovement==DiagonalMovement.OnlyWhenNoObstacles){ + d0=s3 && s0; + d1=s0 && s1; + d2=s1 && s2; + d3=s2 && s3; + } + else if (diagonalMovement==DiagonalMovement.IfAtMostOneObstacle){ + d0=s3 || s0; + d1=s0 || s1; + d2=s1 || s2; + d3=s2 || s3; + } + else if (diagonalMovement==DiagonalMovement.Always){ + d0=true; + d1=true; + d2=true; + d3=true; + } + else{ + throw new Error('Incorrect value of diagonalMovement'); + } + if (d0 && this.isWalkableAt(x-1,y-1)){ + neighbors.push(nodes[y-1][x-1]); + } + if (d1 && this.isWalkableAt(x+1,y-1)){ + neighbors.push(nodes[y-1][x+1]); + } + if (d2 && this.isWalkableAt(x+1,y+1)){ + neighbors.push(nodes[y+1][x+1]); + } + if (d3 && this.isWalkableAt(x-1,y+1)){ + neighbors.push(nodes[y+1][x-1]); + } + return neighbors; + } + + /** + *Get a clone of this grid. + *@return {Grid}Cloned grid. + */ + __proto.clone=function(){ + var i=0,j=0, + width=this.width,height=this.height,thisNodes=this.nodes, + newGrid=new Grid(width,height),newNodes=[]; + for (i=0;i < height;++i){ + newNodes[i]=[]; + for (j=0;j < width;++j){ + newNodes[i][j]=new Node1(j,i,thisNodes[i][j].walkable); + } + } + newGrid.nodes=newNodes; + return newGrid; + } + + __proto.reset=function(){ + var _node; + for (var i=0;i < this.height;++i){ + for (var j=0;j < this.width;++j){ + _node=this.nodes[i][j]; + _node.g=0; + _node.f=0; + _node.h=0; + _node.by=0; + _node.parent=null; + _node.opened=null; + _node.closed=null; + _node.tested=null; + } + } + } + + return Grid; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.core.Heuristic + var Heuristic=(function(){ + function Heuristic(){} + __class(Heuristic,'PathFinding.core.Heuristic'); + Heuristic.manhattan=function(dx,dy){ + return dx+dy; + } + + Heuristic.euclidean=function(dx,dy){ + return Math.sqrt(dx *dx+dy *dy); + } + + Heuristic.octile=function(dx,dy){ + var F=Math.SQRT2-1; + return (dx < dy)? F *dx+dy :F *dy+dx; + } + + Heuristic.chebyshev=function(dx,dy){ + return Math.max(dx,dy); + } + + return Heuristic; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.core.Node + var Node1=(function(){ + function Node(x,y,walkable){ + this.x=0; + this.y=0; + this.g=0; + this.f=0; + this.h=0; + this.by=0; + this.parent=null; + this.opened=null; + this.closed=null; + this.tested=null; + this.walkable=false; + (walkable===void 0)&& (walkable=true); + this.x=x; + this.y=y; + this.walkable=walkable; + } + + __class(Node,'PathFinding.core.Node',null,'Node1'); + return Node; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.core.Util + var Util=(function(){ + function Util(){} + __class(Util,'PathFinding.core.Util'); + Util.backtrace=function(node){ + var path=[[node.x,node.y]]; + while (node.parent){ + node=node.parent; + path.push([node.x,node.y]); + } + return path.reverse(); + } + + Util.biBacktrace=function(nodeA,nodeB){ + var pathA=Util.backtrace(nodeA),pathB=Util.backtrace(nodeB); + return pathA.concat(pathB.reverse()); + } + + Util.pathLength=function(path){ + var i=0,sum=0,a=0,b=0,dx=0,dy=0; + for (i=1;i < path.length;++i){ + a=path[i-1]; + b=path[i]; + dx=a[0]-b[0]; + dy=a[1]-b[1]; + sum+=Math.sqrt(dx *dx+dy *dy); + } + return sum; + } + + Util.interpolate=function(x0,y0,x1,y1){ + var abs=Math.abs,line=[],sx=0,sy=0,dx=0,dy=0,err=0,e2=0; + dx=abs(x1-x0); + dy=abs(y1-y0); + sx=(x0 < x1)? 1 :-1; + sy=(y0 < y1)? 1 :-1; + err=dx-dy; + while (true){ + line.push([x0,y0]); + if (x0==x1 && y0==y1){ + break ; + } + e2=2 *err; + if (e2 >-dy){ + err=err-dy; + x0=x0+sx; + } + if (e2 < dx){ + err=err+dx; + y0=y0+sy; + } + } + return line; + } + + Util.expandPath=function(path){ + var expanded=[],len=path.length,coord0,coord1,interpolated,interpolatedLen=0,i=0,j=0; + if (len < 2){ + return expanded; + } + for (i=0;i < len-1;++i){ + coord0=path[i]; + coord1=path[i+1]; + interpolated=Util.interpolate(coord0[0],coord0[1],coord1[0],coord1[1]); + interpolatedLen=interpolated.length; + for (j=0;j < interpolatedLen-1;++j){ + expanded.push(interpolated[j]); + } + } + expanded.push(path[len-1]); + return expanded; + } + + Util.smoothenPath=function(grid,path){ + var len=path.length,x0=path[0][0], + y0=path[0][1], + x1=path[len-1][0], + y1=path[len-1][1], + sx=0,sy=0, + ex=0,ey=0, + newPath,i=0,j=0,coord,line,testCoord,blocked=false,lastValidCoord; + sx=x0; + sy=y0; + newPath=[[sx,sy]]; + for (i=2;i < len;++i){ + coord=path[i]; + ex=coord[0]; + ey=coord[1]; + line=Util.interpolate(sx,sy,ex,ey); + blocked=false; + for (j=1;j < line.length;++j){ + testCoord=line[j]; + if (!grid.isWalkableAt(testCoord[0],testCoord[1])){ + blocked=true; + break ; + } + } + if (blocked){ + lastValidCoord=path[i-1]; + newPath.push(lastValidCoord); + sx=lastValidCoord[0]; + sy=lastValidCoord[1]; + } + } + newPath.push([x1,y1]); + return newPath; + } + + Util.compressPath=function(path){ + if (path.length < 3){ + return path; + }; + var compressed=[],sx=path[0][0], + sy=path[0][1], + px=path[1][0], + py=path[1][1], + dx=px-sx, + dy=py-sy, + lx=0,ly=0,ldx=0,ldy=0,sq=NaN,i=0; + sq=Math.sqrt(dx *dx+dy *dy); + dx /=sq; + dy /=sq; + compressed.push([sx,sy]); + for (i=2;i < path.length;i++){ + lx=px; + ly=py; + ldx=dx; + ldy=dy; + px=path[i][0]; + py=path[i][1]; + dx=px-lx; + dy=py-ly; + sq=Math.sqrt(dx *dx+dy *dy); + dx /=sq; + dy /=sq; + if (dx!==ldx || dy!==ldy){ + compressed.push([lx,ly]); + } + } + compressed.push([px,py]); + return compressed; + } + + return Util; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.finders.AStarFinder + var AStarFinder=(function(){ + function AStarFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.heuristic=null; + this.weight=0; + this.diagonalMovement=0; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.heuristic=opt.heuristic || Heuristic.manhattan; + this.weight=opt.weight || 1; + this.diagonalMovement=opt.diagonalMovement; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + if (this.diagonalMovement===DiagonalMovement.Never){ + this.heuristic=opt.heuristic || Heuristic.manhattan; + } + else{ + this.heuristic=opt.heuristic || Heuristic.octile; + } + } + + __class(AStarFinder,'PathFinding.finders.AStarFinder'); + var __proto=AStarFinder.prototype; + /** + *Find and return the the path. + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var openList=new Heap(function(nodeA,nodeB){ + return nodeA.f-nodeB.f; + }),startNode=grid.getNodeAt(startX,startY),endNode=grid.getNodeAt(endX,endY),heuristic=this.heuristic,diagonalMovement=this.diagonalMovement,weight=this.weight,abs=Math.abs,SQRT2=Math.SQRT2,node,neighbors,neighbor,i=0,l=0,x=0,y=0,ng=0; + startNode.g=0; + startNode.f=0; + openList.push(startNode); + startNode.opened=true; + while (!openList.empty()){ + node=openList.pop(); + node.closed=true; + if (node===endNode){ + return Util.backtrace(endNode); + } + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + x=neighbor.x; + y=neighbor.y; + ng=node.g+((x-node.x===0 || y-node.y===0)? 1 :SQRT2); + if (!neighbor.opened || ng < neighbor.g){ + neighbor.g=ng; + neighbor.h=neighbor.h || weight *heuristic(abs(x-endX),abs(y-endY)); + neighbor.f=neighbor.g+neighbor.h; + neighbor.parent=node; + if (!neighbor.opened){ + openList.push(neighbor); + neighbor.opened=true; + } + else{ + openList.updateItem(neighbor); + } + } + } + } + return []; + } + + return AStarFinder; + })() + + + /** + *... + *@author ... + */ + //class PathFinding.finders.BiAStarFinder + var BiAStarFinder=(function(){ + function BiAStarFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.diagonalMovement=0; + this.heuristic=null; + this.weight=0; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.diagonalMovement=opt.diagonalMovement; + this.heuristic=opt.heuristic || Heuristic.manhattan; + this.weight=opt.weight || 1; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + if (this.diagonalMovement==DiagonalMovement.Never){ + this.heuristic=opt.heuristic || Heuristic.manhattan; + } + else{ + this.heuristic=opt.heuristic || Heuristic.octile; + } + } + + __class(BiAStarFinder,'PathFinding.finders.BiAStarFinder'); + var __proto=BiAStarFinder.prototype; + /** + *Find and return the the path. + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var cmp=function (nodeA,nodeB){ + return nodeA.f-nodeB.f; + }; + var startOpenList=new Heap(cmp),endOpenList=new Heap(cmp),startNode=grid.getNodeAt(startX,startY),endNode=grid.getNodeAt(endX,endY),heuristic=this.heuristic,diagonalMovement=this.diagonalMovement,weight=this.weight,abs=Math.abs,SQRT2=Math.SQRT2,node,neighbors,neighbor,i=0,l=0,x=0,y=0,ng=0,BY_START=1,BY_END=2; + startNode.g=0; + startNode.f=0; + startOpenList.push(startNode); + startNode.opened=BY_START; + endNode.g=0; + endNode.f=0; + endOpenList.push(endNode); + endNode.opened=BY_END; + while (!startOpenList.empty()&& !endOpenList.empty()){ + node=startOpenList.pop(); + node.closed=true; + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + if (neighbor.opened===BY_END){ + return Util.biBacktrace(node,neighbor); + } + x=neighbor.x; + y=neighbor.y; + ng=node.g+((x-node.x===0 || y-node.y===0)? 1 :SQRT2); + if (!neighbor.opened || ng < neighbor.g){ + neighbor.g=ng; + neighbor.h=neighbor.h || weight *heuristic(abs(x-endX),abs(y-endY)); + neighbor.f=neighbor.g+neighbor.h; + neighbor.parent=node; + if (!neighbor.opened){ + startOpenList.push(neighbor); + neighbor.opened=BY_START; + } + else{ + startOpenList.updateItem(neighbor); + } + } + } + node=endOpenList.pop(); + node.closed=true; + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + if (neighbor.opened===BY_START){ + return Util.biBacktrace(neighbor,node); + } + x=neighbor.x; + y=neighbor.y; + ng=node.g+((x-node.x===0 || y-node.y===0)? 1 :SQRT2); + if (!neighbor.opened || ng < neighbor.g){ + neighbor.g=ng; + neighbor.h=neighbor.h || weight *heuristic(abs(x-startX),abs(y-startY)); + neighbor.f=neighbor.g+neighbor.h; + neighbor.parent=node; + if (!neighbor.opened){ + endOpenList.push(neighbor); + neighbor.opened=BY_END; + } + else{ + endOpenList.updateItem(neighbor); + } + } + } + } + return []; + } + + return BiAStarFinder; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.finders.BiBreadthFirstFinder + var BiBreadthFirstFinder=(function(){ + function BiBreadthFirstFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.heuristic=null; + this.weight=0; + this.diagonalMovement=0; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.diagonalMovement=opt.diagonalMovement; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + } + + __class(BiBreadthFirstFinder,'PathFinding.finders.BiBreadthFirstFinder'); + var __proto=BiBreadthFirstFinder.prototype; + /** + *Find and return the the path. + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var startNode=grid.getNodeAt(startX,startY),endNode=grid.getNodeAt(endX,endY),startOpenList=[],endOpenList=[],neighbors,neighbor,node,diagonalMovement=this.diagonalMovement,BY_START=0,BY_END=1,i=0,l=0; + startOpenList.push(startNode); + startNode.opened=true; + startNode.by=BY_START; + endOpenList.push(endNode); + endNode.opened=true; + endNode.by=BY_END; + while (startOpenList.length && endOpenList.length){ + node=startOpenList.shift(); + node.closed=true; + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + if (neighbor.opened){ + if (neighbor.by===BY_END){ + return Util.biBacktrace(node,neighbor); + } + continue ; + } + startOpenList.push(neighbor); + neighbor.parent=node; + neighbor.opened=true; + neighbor.by=BY_START; + } + node=endOpenList.shift(); + node.closed=true; + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + if (neighbor.opened){ + if (neighbor.by===BY_START){ + return Util.biBacktrace(neighbor,node); + } + continue ; + } + endOpenList.push(neighbor); + neighbor.parent=node; + neighbor.opened=true; + neighbor.by=BY_END; + } + } + return []; + } + + return BiBreadthFirstFinder; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.finders.BreadthFirstFinder + var BreadthFirstFinder=(function(){ + function BreadthFirstFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.heuristic=null; + this.weight=0; + this.diagonalMovement=0; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.diagonalMovement=opt.diagonalMovement; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + } + + __class(BreadthFirstFinder,'PathFinding.finders.BreadthFirstFinder'); + var __proto=BreadthFirstFinder.prototype; + /** + *Find and return the the path. + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var openList=[],diagonalMovement=this.diagonalMovement,startNode=grid.getNodeAt(startX,startY),endNode=grid.getNodeAt(endX,endY),neighbors,neighbor,node,i=0,l=0; + openList.push(startNode); + startNode.opened=true; + while (openList.length){ + node=openList.shift(); + node.closed=true; + if (node===endNode){ + return Util.backtrace(endNode); + } + neighbors=grid.getNeighbors(node,diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed || neighbor.opened){ + continue ; + } + openList.push(neighbor); + neighbor.opened=true; + neighbor.parent=node; + } + } + return []; + } + + return BreadthFirstFinder; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.finders.IDAStarFinder + var IDAStarFinder=(function(){ + function IDAStarFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.heuristic=null; + this.weight=0; + this.diagonalMovement=0; + this.trackRecursion=false; + this.timeLimit=NaN; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.diagonalMovement=opt.diagonalMovement; + this.heuristic=opt.heuristic || Heuristic.manhattan; + this.weight=opt.weight || 1; + this.trackRecursion=opt.trackRecursion || false; + this.timeLimit=opt.timeLimit || Infinity; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + if (this.diagonalMovement===DiagonalMovement.Never){ + this.heuristic=opt.heuristic || Heuristic.manhattan; + } + else{ + this.heuristic=opt.heuristic || Heuristic.octile; + } + } + + __class(IDAStarFinder,'PathFinding.finders.IDAStarFinder'); + var __proto=IDAStarFinder.prototype; + /** + *Find and return the the path. When an empty array is returned,either + *no path is possible,or the maximum execution time is reached. + * + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var _$this=this; + var nodesVisited=0; + var startTime=new Date().getTime(); + var h=function (a,b){ + return _$this.heuristic(Math.abs(b.x-a.x),Math.abs(b.y-a.y)); + }.bind(this); + var cost=function (a,b){ + return (a.x===b.x || a.y===b.y)? 1 :Math.SQRT2; + }; + var search=function (node,g,cutoff,route,depth){ + nodesVisited++; + if (_$this.timeLimit > 0 && new Date().getTime()-startTime > _$this.timeLimit *1000){ + return Infinity; + }; + var f=g+h(node,end)*_$this.weight; + if (f > cutoff){ + return f; + } + if (node==end){ + route[depth]=[node.x,node.y]; + return node; + }; + var min=0,t=0,k=0,neighbour; + var neighbours=grid.getNeighbors(node,_$this.diagonalMovement); + for (k=0,min=Infinity;neighbour=neighbours[k];++k){ + if (_$this.trackRecursion){ + neighbour.retainCount=neighbour.retainCount+1 || 1; + if (neighbour.tested !=true){ + neighbour.tested=true; + } + } + t=search(neighbour,g+cost(node,neighbour),cutoff,route,depth+1); + if ((t instanceof PathFinding.core.Node )){ + route[depth]=[node.x,node.y]; + return t; + } + if (_$this.trackRecursion && (--neighbour.retainCount)===0){ + neighbour.tested=false; + } + if (t < min){ + min=t; + } + } + return min; + }.bind(this); + var start=grid.getNodeAt(startX,startY); + var end=grid.getNodeAt(endX,endY); + var cutOff=h(start,end); + var j=0,route,t=0; + for (j=0;true;++j){ + route=[]; + t=search(start,0,cutOff,route,0); + if (t==Infinity){ + return []; + } + if ((t instanceof PathFinding.core.Node )){ + return route; + } + cutOff=t; + } + } + + return IDAStarFinder; + })() + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JumpPointFinderBase + var JumpPointFinderBase=(function(){ + function JumpPointFinderBase(opt){ + this.grid=null; + this.openList=null; + this.startNode=null; + this.endNode=null; + this.heuristic=null; + this.trackJumpRecursion=false; + opt=opt || {}; + this.heuristic=opt.heuristic || Heuristic.manhattan; + this.trackJumpRecursion=opt.trackJumpRecursion || false; + } + + __class(JumpPointFinderBase,'PathFinding.finders.JumpPointFinderBase'); + var __proto=JumpPointFinderBase.prototype; + /** + *Find and return the path. + *@return {Array>}The path,including both start and + *end positions. + */ + __proto.findPath=function(startX,startY,endX,endY,grid){ + var openList=this.openList=new Heap(function(nodeA,nodeB){ + return nodeA.f-nodeB.f; + }),startNode=this.startNode=grid.getNodeAt(startX,startY),endNode=this.endNode=grid.getNodeAt(endX,endY),node; + this.grid=grid; + startNode.g=0; + startNode.f=0; + openList.push(startNode); + startNode.opened=true; + while (!openList.empty()){ + node=openList.pop(); + node.closed=true; + if (node==endNode){ + return Util.expandPath(Util.backtrace(endNode)); + } + this._identifySuccessors(node); + } + return []; + } + + /** + *Identify successors for the given node. Runs a jump point search in the + *direction of each available neighbor,adding any points found to the open + *list. + *@protected + */ + __proto._identifySuccessors=function(node){ + var grid=this.grid,heuristic=this.heuristic,openList=this.openList,endX=this.endNode.x,endY=this.endNode.y,neighbors,neighbor,jumpPoint,i=0,l=0,x=node.x,y=node.y,jx=0,jy=0,dx=0,dy=0,d=0,ng=0,jumpNode,abs=Math.abs,max=Math.max; + neighbors=this._findNeighbors(node); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + jumpPoint=this._jump(neighbor[0],neighbor[1],x,y); + if (jumpPoint){ + jx=jumpPoint[0]; + jy=jumpPoint[1]; + jumpNode=grid.getNodeAt(jx,jy); + if (jumpNode.closed){ + continue ; + } + d=Heuristic.octile(abs(jx-x),abs(jy-y)); + ng=node.g+d; + if (!jumpNode.opened || ng < jumpNode.g){ + jumpNode.g=ng; + jumpNode.h=jumpNode.h || heuristic(abs(jx-endX),abs(jy-endY)); + jumpNode.f=jumpNode.g+jumpNode.h; + jumpNode.parent=node; + if (!jumpNode.opened){ + openList.push(jumpNode); + jumpNode.opened=true; + } + else{ + openList.updateItem(jumpNode); + } + } + } + } + } + + __proto._jump=function(x,y,px,py){} + __proto._findNeighbors=function(node){} + return JumpPointFinderBase; + })() + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JumpPointFinder + var JumpPointFinder=(function(){ + /** + *Path finder using the Jump Point Search algorithm + *@param {Object}opt + *@param {function}opt.heuristic Heuristic function to estimate the distance + *(defaults to manhattan). + *@param {DiagonalMovement}opt.diagonalMovement Condition under which diagonal + *movement will be allowed. + */ + function JumpPointFinder(opt){ + opt=opt || {}; + if (opt.diagonalMovement===DiagonalMovement.Never){ + return new JPFNeverMoveDiagonally(opt); + } + else if (opt.diagonalMovement===DiagonalMovement.Always){ + return new JPFAlwaysMoveDiagonally(opt); + } + else if (opt.diagonalMovement===DiagonalMovement.OnlyWhenNoObstacles){ + return new JPFMoveDiagonallyIfNoObstacles(opt); + } + else{ + return new JPFMoveDiagonallyIfAtMostOneObstacle(opt); + } + } + + __class(JumpPointFinder,'PathFinding.finders.JumpPointFinder'); + return JumpPointFinder; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.finders.TraceFinder + var TraceFinder=(function(){ + function TraceFinder(opt){ + this.allowDiagonal=false; + this.dontCrossCorners=false; + this.diagonalMovement=0; + this.heuristic=null; + opt=opt || {}; + this.allowDiagonal=opt.allowDiagonal; + this.dontCrossCorners=opt.dontCrossCorners; + this.heuristic=opt.heuristic || Heuristic.manhattan; + this.diagonalMovement=opt.diagonalMovement; + if (!this.diagonalMovement){ + if (!this.allowDiagonal){ + this.diagonalMovement=DiagonalMovement.Never; + } + else{ + if (this.dontCrossCorners){ + this.diagonalMovement=DiagonalMovement.OnlyWhenNoObstacles; + } + else{ + this.diagonalMovement=DiagonalMovement.IfAtMostOneObstacle; + } + } + } + if (this.diagonalMovement==DiagonalMovement.Never){ + this.heuristic=opt.heuristic || Heuristic.manhattan; + } + else{ + this.heuristic=opt.heuristic || Heuristic.octile; + } + } + + __class(TraceFinder,'PathFinding.finders.TraceFinder'); + var __proto=TraceFinder.prototype; + __proto.findPath=function(startX,startY,endX,endY,grid){ + var openList=new Heap(function(nodeA,nodeB){ + return nodeA.f-nodeB.f; + }),startNode=grid.getNodeAt(startX,startY),endNode=grid.getNodeAt(endX,endY),heuristic=this.heuristic,allowDiagonal=this.allowDiagonal,dontCrossCorners=this.dontCrossCorners,abs=Math.abs,SQRT2=Math.SQRT2,node,neighbors,neighbor,i=0,l=0,x=0,y=0,ng=0; + startNode.g=0; + startNode.f=0; + openList.push(startNode); + startNode.opened=true; + while (!openList.empty()){ + node=openList.pop(); + node.closed=true; + if (node===endNode){ + return Util.backtrace(endNode); + } + neighbors=grid.getNeighbors(node,this.diagonalMovement); + for (i=0,l=neighbors.length;i < l;++i){ + neighbor=neighbors[i]; + if (neighbor.closed){ + continue ; + } + x=neighbor.x; + y=neighbor.y; + ng=node.g+((x-node.x===0 || y-node.y===0)? 1 :SQRT2); + if (!neighbor.opened || ng < neighbor.g){ + neighbor.g=ng *l / 9; + neighbor.h=neighbor.h || heuristic(abs(x-endX),abs(y-endY)); + neighbor.f=neighbor.g+neighbor.h; + neighbor.parent=node; + if (!neighbor.opened){ + openList.push(neighbor); + neighbor.opened=true; + } + else{ + openList.updateItem(neighbor); + } + } + } + } + return []; + } + + return TraceFinder; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.libs.Heap + var Heap=(function(){ + function Heap(cmp){ + this.cmp=null; + this.nodes=null; + this.heapFunction=new HeapFunction(); + this.cmp=cmp !=null ? cmp :this.heapFunction.defaultCmp; + this.nodes=[]; + } + + __class(Heap,'PathFinding.libs.Heap'); + var __proto=Heap.prototype; + __proto.push=function(x){ + return this.heapFunction.heappush(this.nodes,x,this.cmp); + } + + __proto.pop=function(){ + return this.heapFunction.heappop(this.nodes,this.cmp); + } + + __proto.peek=function(){ + return this.nodes[0]; + } + + __proto.contains=function(x){ + return this.nodes.indexOf(x)!==-1; + } + + __proto.replace=function(x){ + return this.heapFunction.heapreplace(this.nodes,x,this.cmp); + } + + __proto.pushpop=function(x){ + return this.heapFunction.heappushpop(this.nodes,x,this.cmp); + } + + __proto.heapify=function(){ + return this.heapFunction.heapify(this.nodes,this.cmp); + } + + __proto.updateItem=function(x){ + return this.heapFunction.updateItem(this.nodes,x,this.cmp); + } + + __proto.clear=function(){ + return this.nodes=[]; + } + + __proto.empty=function(){ + return this.nodes.length===0; + } + + __proto.size=function(){ + return this.nodes.length; + } + + __proto.clone=function(){ + var heap=new Heap(); + heap.nodes=this.nodes.slice(0); + return heap; + } + + __proto.toArray=function(){ + return this.nodes.slice(0); + } + + return Heap; + })() + + + /** + *... + *@author dongketao + */ + //class PathFinding.libs.HeapFunction + var HeapFunction=(function(){ + function HeapFunction(){ + this.defaultCmp=function(x,y){ + if (x < y){ + return-1; + } + if (x > y){ + return 1; + } + return 0; + } + } + + __class(HeapFunction,'PathFinding.libs.HeapFunction'); + var __proto=HeapFunction.prototype; + //}; + __proto.insort=function(a,x,lo,hi,cmp){ + var mid=NaN; + if (lo==null){ + lo=0; + } + if (cmp==null){ + cmp=this.defaultCmp; + } + if (lo < 0){ + throw new Error('lo must be non-negative'); + } + if (hi==null){ + hi=a.length; + } + while (lo < hi){ + mid=Math.floor((lo+hi)/ 2); + if (cmp(x,a[mid])< 0){ + hi=mid; + } + else{ + lo=mid+1; + } + } + return ([].splice.apply(a,[lo,lo-lo].concat(x)),x); + } + + //}; + __proto.heappush=function(array,item,cmp){ + if (cmp==null){ + cmp=this.defaultCmp; + } + array.push(item); + return this._siftdown(array,0,array.length-1,cmp); + } + + //}; + __proto.heappop=function(array,cmp){ + var lastelt,returnitem; + if (cmp==null){ + cmp=this.defaultCmp; + } + lastelt=array.pop(); + if (array.length){ + returnitem=array[0]; + array[0]=lastelt; + this._siftup(array,0,cmp); + } + else{ + returnitem=lastelt; + } + return returnitem; + } + + //}; + __proto.heapreplace=function(array,item,cmp){ + var returnitem; + if (cmp==null){ + cmp=this.defaultCmp; + } + returnitem=array[0]; + array[0]=item; + this._siftup(array,0,cmp); + return returnitem; + } + + //}; + __proto.heappushpop=function(array,item,cmp){ + var _ref; + if (cmp==null){ + cmp=this.defaultCmp; + } + if (array.length && cmp(array[0],item)< 0){ + _ref=[array[0],item],item=_ref[0],array[0]=_ref[1]; + this._siftup(array,0,cmp); + } + return item; + } + + //}; + __proto.heapify=function(array,cmp){ + var i=0,_i=0,_j=0,_len=0,_ref,_ref1,_results,_results1; + if (cmp==null){ + cmp=this.defaultCmp; + } + _ref1=(function(){ + _results1=[]; + for (_j=0,_ref=Math.floor(array.length / 2);0 <=_ref ? _j < _ref :_j > _ref;0 <=_ref ? _j++:_j--){ + _results1.push(_j); + } + return _results1; + }).apply(this).reverse(); + _results=[]; + for (_i=0,_len=_ref1.length;_i < _len;_i++){ + i=_ref1[_i]; + _results.push(this._siftup(array,i,cmp)); + } + return _results; + } + + //}; + __proto.updateItem=function(array,item,cmp){ + var pos=0; + if (cmp==null){ + cmp=this.defaultCmp; + } + pos=array.indexOf(item); + if (pos===-1){ + return null; + } + this._siftdown(array,0,pos,cmp); + return this._siftup(array,pos,cmp); + } + + //}; + __proto.nlargest=function(array,n,cmp){ + var elem,result,_i=0,_len=0,_ref; + if (cmp==null){ + cmp=this.defaultCmp; + } + result=array.slice(0,n); + if (!result.length){ + return result; + } + this.heapify(result,cmp); + _ref=array.slice(n); + for (_i=0,_len=_ref.length;_i < _len;_i++){ + elem=_ref[_i]; + this.heappushpop(result,elem,cmp); + } + return result.sort(cmp).reverse(); + } + + //}; + __proto.nsmallest=function(array,n,cmp){ + var elem,i,los,result,_i=0,_j=0,_len,_ref,_ref1,_results; + if (cmp==null){ + cmp=this.defaultCmp; + } + if (n *10 <=array.length){ + result=array.slice(0,n).sort(cmp); + if (!result.length){ + return result; + } + los=result[result.length-1]; + _ref=array.slice(n); + for (_i=0,_len=_ref.length;_i < _len;_i++){ + elem=_ref[_i]; + if (cmp(elem,los)< 0){ + this.insort(result,elem,0,null,cmp); + result.pop(); + los=result[result.length-1]; + } + } + return result; + } + this.heapify(array,cmp); + _results=[]; + for (i=_j=0,_ref1=Math.min(n,array.length);0 <=_ref1 ? _j < _ref1 :_j > _ref1;i=0 <=_ref1 ?++_j :--_j){ + _results.push(this.heappop(array,cmp)); + } + return _results; + } + + //}; + __proto._siftdown=function(array,startpos,pos,cmp){ + var newitem,parent,parentpos=0; + if (cmp==null){ + cmp=this.defaultCmp; + } + newitem=array[pos]; + while (pos > startpos){ + parentpos=(pos-1)>> 1; + parent=array[parentpos]; + if (cmp(newitem,parent)< 0){ + array[pos]=parent; + pos=parentpos; + continue ; + } + break ; + } + return array[pos]=newitem; + } + + //}; + __proto._siftup=function(array,pos,cmp){ + var childpos=0,endpos=0,newitem,rightpos=0,startpos=0; + if (cmp==null){ + cmp=this.defaultCmp; + } + endpos=array.length; + startpos=pos; + newitem=array[pos]; + childpos=2 *pos+1; + while (childpos < endpos){ + rightpos=childpos+1; + if (rightpos < endpos && !(cmp(array[childpos],array[rightpos])< 0)){ + childpos=rightpos; + } + array[pos]=array[childpos]; + pos=childpos; + childpos=2 *pos+1; + } + array[pos]=newitem; + return this._siftdown(array,startpos,pos,cmp); + } + + return HeapFunction; + })() + + + /** + *... + *@author dongketao + */ + //class TestPathFinding + var TestPathFinding=(function(){ + function TestPathFinding(){ + var opt={allowDiagonal:true,dontCrossCorners:false,heuristic:Heuristic["manhattan"],weight:1}; + var astart=new AStarFinder(opt); + var grid=new Grid(64,36); + var path=astart.findPath(23,16,33,16,grid); + console.log(path.toString()); + } + + __class(TestPathFinding,'TestPathFinding'); + return TestPathFinding; + })() + + + /** + *... + *@author ... + */ + //class PathFinding.finders.BestFirstFinder extends PathFinding.finders.AStarFinder + var BestFirstFinder=(function(_super){ + function BestFirstFinder(opt){ + BestFirstFinder.__super.call(this,opt); + var orig=this.heuristic; + this.heuristic=function (dx,dy){ + return orig(dx,dy)*1000000; + }; + } + + __class(BestFirstFinder,'PathFinding.finders.BestFirstFinder',_super); + return BestFirstFinder; + })(AStarFinder) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.BiBestFirstFinder extends PathFinding.finders.BiAStarFinder + var BiBestFirstFinder=(function(_super){ + function BiBestFirstFinder(opt){ + BiBestFirstFinder.__super.call(this,opt); + var orig=this.heuristic; + this.heuristic=function (dx,dy){ + return orig(dx,dy)*1000000; + }; + } + + __class(BiBestFirstFinder,'PathFinding.finders.BiBestFirstFinder',_super); + return BiBestFirstFinder; + })(BiAStarFinder) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.BiDijkstraFinder extends PathFinding.finders.BiAStarFinder + var BiDijkstraFinder=(function(_super){ + function BiDijkstraFinder(opt){ + BiDijkstraFinder.__super.call(this,opt); + this.heuristic=function (dx,dy){ + return 0; + }; + } + + __class(BiDijkstraFinder,'PathFinding.finders.BiDijkstraFinder',_super); + return BiDijkstraFinder; + })(BiAStarFinder) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.DijkstraFinder extends PathFinding.finders.AStarFinder + var DijkstraFinder=(function(_super){ + function DijkstraFinder(opt){ + DijkstraFinder.__super.call(this,opt); + this.heuristic=function (dx,dy){ + return 0; + }; + } + + __class(DijkstraFinder,'PathFinding.finders.DijkstraFinder',_super); + return DijkstraFinder; + })(AStarFinder) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JPFAlwaysMoveDiagonally extends PathFinding.finders.JumpPointFinderBase + var JPFAlwaysMoveDiagonally=(function(_super){ + function JPFAlwaysMoveDiagonally(opt){ + JPFAlwaysMoveDiagonally.__super.call(this,opt); + } + + __class(JPFAlwaysMoveDiagonally,'PathFinding.finders.JPFAlwaysMoveDiagonally',_super); + var __proto=JPFAlwaysMoveDiagonally.prototype; + /** + *Search recursively in the direction (parent-> child),stopping only when a + *jump point is found. + *@protected + *@return {Array>}The x,y coordinate of the jump point + *found,or null if not found + */ + __proto._jump=function(x,y,px,py){ + var grid=this.grid,dx=x-px,dy=y-py; + if (!grid.isWalkableAt(x,y)){ + return null; + } + if (this.trackJumpRecursion==true){ + grid.getNodeAt(x,y).tested=true; + } + if (grid.getNodeAt(x,y)==this.endNode){ + return [x,y]; + } + if (dx!==0 && dy!==0){ + if ((grid.isWalkableAt(x-dx,y+dy)&& !grid.isWalkableAt(x-dx,y))|| (grid.isWalkableAt(x+dx,y-dy)&& !grid.isWalkableAt(x,y-dy))){ + return [x,y]; + } + if (this._jump(x+dx,y,x,y)|| this._jump(x,y+dy,x,y)){ + return [x,y]; + } + } + else{ + if (dx!==0){ + if ((grid.isWalkableAt(x+dx,y+1)&& !grid.isWalkableAt(x,y+1))|| (grid.isWalkableAt(x+dx,y-1)&& !grid.isWalkableAt(x,y-1))){ + return [x,y]; + } + } + else{ + if ((grid.isWalkableAt(x+1,y+dy)&& !grid.isWalkableAt(x+1,y))|| (grid.isWalkableAt(x-1,y+dy)&& !grid.isWalkableAt(x-1,y))){ + return [x,y]; + } + } + } + return this._jump(x+dx,y+dy,x,y); + } + + /** + *Find the neighbors for the given node. If the node has a parent, + *prune the neighbors based on the jump point search algorithm,otherwise + *return all available neighbors. + *@return {Array>}The neighbors found. + */ + __proto._findNeighbors=function(node){ + var parent=node.parent,x=node.x,y=node.y,grid=this.grid,px=0,py=0,nx=0,ny=0,dx=0,dy=0,neighbors=[],neighborNodes,neighborNode,i=0,l=0; + if (parent){ + px=parent.x; + py=parent.y; + dx=(x-px)/ Math.max(Math.abs(x-px),1); + dy=(y-py)/ Math.max(Math.abs(y-py),1); + if (dx!==0 && dy!==0){ + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + } + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + } + if (grid.isWalkableAt(x+dx,y+dy)){ + neighbors.push([x+dx,y+dy]); + } + if (!grid.isWalkableAt(x-dx,y)){ + neighbors.push([x-dx,y+dy]); + } + if (!grid.isWalkableAt(x,y-dy)){ + neighbors.push([x+dx,y-dy]); + } + } + else{ + if (dx===0){ + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + } + if (!grid.isWalkableAt(x+1,y)){ + neighbors.push([x+1,y+dy]); + } + if (!grid.isWalkableAt(x-1,y)){ + neighbors.push([x-1,y+dy]); + } + } + else{ + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + } + if (!grid.isWalkableAt(x,y+1)){ + neighbors.push([x+dx,y+1]); + } + if (!grid.isWalkableAt(x,y-1)){ + neighbors.push([x+dx,y-1]); + } + } + } + } + else{ + neighborNodes=grid.getNeighbors(node,DiagonalMovement.Always); + for (i=0,l=neighborNodes.length;i < l;++i){ + neighborNode=neighborNodes[i]; + neighbors.push([neighborNode.x,neighborNode.y]); + } + } + return neighbors; + } + + return JPFAlwaysMoveDiagonally; + })(JumpPointFinderBase) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JPFMoveDiagonallyIfAtMostOneObstacle extends PathFinding.finders.JumpPointFinderBase + var JPFMoveDiagonallyIfAtMostOneObstacle=(function(_super){ + function JPFMoveDiagonallyIfAtMostOneObstacle(opt){ + JPFMoveDiagonallyIfAtMostOneObstacle.__super.call(this,opt); + } + + __class(JPFMoveDiagonallyIfAtMostOneObstacle,'PathFinding.finders.JPFMoveDiagonallyIfAtMostOneObstacle',_super); + var __proto=JPFMoveDiagonallyIfAtMostOneObstacle.prototype; + /** + *Search recursively in the direction (parent-> child),stopping only when a + *jump point is found. + *@protected + *@return {Array>}The x,y coordinate of the jump point + *found,or null if not found + */ + __proto._jump=function(x,y,px,py){ + var grid=this.grid,dx=x-px,dy=y-py; + if (!grid.isWalkableAt(x,y)){ + return null; + } + if (this.trackJumpRecursion===true){ + grid.getNodeAt(x,y).tested=true; + } + if (grid.getNodeAt(x,y)==this.endNode){ + return [x,y]; + } + if (dx!==0 && dy!==0){ + if ((grid.isWalkableAt(x-dx,y+dy)&& !grid.isWalkableAt(x-dx,y))|| (grid.isWalkableAt(x+dx,y-dy)&& !grid.isWalkableAt(x,y-dy))){ + return [x,y]; + } + if (this._jump(x+dx,y,x,y)|| this._jump(x,y+dy,x,y)){ + return [x,y]; + } + } + else{ + if (dx!==0){ + if ((grid.isWalkableAt(x+dx,y+1)&& !grid.isWalkableAt(x,y+1))|| (grid.isWalkableAt(x+dx,y-1)&& !grid.isWalkableAt(x,y-1))){ + return [x,y]; + } + } + else{ + if ((grid.isWalkableAt(x+1,y+dy)&& !grid.isWalkableAt(x+1,y))|| (grid.isWalkableAt(x-1,y+dy)&& !grid.isWalkableAt(x-1,y))){ + return [x,y]; + } + } + } + if (grid.isWalkableAt(x+dx,y)|| grid.isWalkableAt(x,y+dy)){ + return this._jump(x+dx,y+dy,x,y); + } + else{ + return null; + } + } + + /** + *Find the neighbors for the given node. If the node has a parent, + *prune the neighbors based on the jump point search algorithm,otherwise + *return all available neighbors. + *@return {Array>}The neighbors found. + */ + __proto._findNeighbors=function(node){ + var parent=node.parent,x=node.x,y=node.y,grid=this.grid,px=0,py=0,nx=0,ny=0,dx=0,dy=0,neighbors=[],neighborNodes,neighborNode,i=0,l=0; + if (parent){ + px=parent.x; + py=parent.y; + dx=(x-px)/ Math.max(Math.abs(x-px),1); + dy=(y-py)/ Math.max(Math.abs(y-py),1); + if (dx!==0 && dy!==0){ + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + } + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + } + if (grid.isWalkableAt(x,y+dy)|| grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y+dy]); + } + if (!grid.isWalkableAt(x-dx,y)&& grid.isWalkableAt(x,y+dy)){ + neighbors.push([x-dx,y+dy]); + } + if (!grid.isWalkableAt(x,y-dy)&& grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y-dy]); + } + } + else{ + if (dx===0){ + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + if (!grid.isWalkableAt(x+1,y)){ + neighbors.push([x+1,y+dy]); + } + if (!grid.isWalkableAt(x-1,y)){ + neighbors.push([x-1,y+dy]); + } + } + } + else{ + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + if (!grid.isWalkableAt(x,y+1)){ + neighbors.push([x+dx,y+1]); + } + if (!grid.isWalkableAt(x,y-1)){ + neighbors.push([x+dx,y-1]); + } + } + } + } + } + else{ + neighborNodes=grid.getNeighbors(node,DiagonalMovement.IfAtMostOneObstacle); + for (i=0,l=neighborNodes.length;i < l;++i){ + neighborNode=neighborNodes[i]; + neighbors.push([neighborNode.x,neighborNode.y]); + } + } + return neighbors; + } + + return JPFMoveDiagonallyIfAtMostOneObstacle; + })(JumpPointFinderBase) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JPFMoveDiagonallyIfNoObstacles extends PathFinding.finders.JumpPointFinderBase + var JPFMoveDiagonallyIfNoObstacles=(function(_super){ + function JPFMoveDiagonallyIfNoObstacles(opt){ + JPFMoveDiagonallyIfNoObstacles.__super.call(this,opt); + } + + __class(JPFMoveDiagonallyIfNoObstacles,'PathFinding.finders.JPFMoveDiagonallyIfNoObstacles',_super); + var __proto=JPFMoveDiagonallyIfNoObstacles.prototype; + /** + *Search recursively in the direction (parent-> child),stopping only when a + *jump point is found. + *@protected + *@return {Array>}The x,y coordinate of the jump point + *found,or null if not found + */ + __proto._jump=function(x,y,px,py){ + var grid=this.grid,dx=x-px,dy=y-py; + if (!grid.isWalkableAt(x,y)){ + return null; + } + if (this.trackJumpRecursion===true){ + grid.getNodeAt(x,y).tested=true; + } + if (grid.getNodeAt(x,y)===this.endNode){ + return [x,y]; + } + if (dx!==0 && dy!==0){ + if (this._jump(x+dx,y,x,y)|| this._jump(x,y+dy,x,y)){ + return [x,y]; + } + } + else{ + if (dx!==0){ + if ((grid.isWalkableAt(x,y-1)&& !grid.isWalkableAt(x-dx,y-1))|| (grid.isWalkableAt(x,y+1)&& !grid.isWalkableAt(x-dx,y+1))){ + return [x,y]; + } + } + else if (dy!==0){ + if ((grid.isWalkableAt(x-1,y)&& !grid.isWalkableAt(x-1,y-dy))|| (grid.isWalkableAt(x+1,y)&& !grid.isWalkableAt(x+1,y-dy))){ + return [x,y]; + } + } + } + if (grid.isWalkableAt(x+dx,y)&& grid.isWalkableAt(x,y+dy)){ + return this._jump(x+dx,y+dy,x,y); + } + else{ + return null; + } + } + + /** + *Find the neighbors for the given node. If the node has a parent, + *prune the neighbors based on the jump point search algorithm,otherwise + *return all available neighbors. + *@return {Array>}The neighbors found. + */ + __proto._findNeighbors=function(node){ + var parent=node.parent,x=node.x,y=node.y,grid=this.grid,px=0,py=0,nx=0,ny=0,dx=0,dy=0,neighbors=[],neighborNodes,neighborNode,i=0,l=0; + if (parent){ + px=parent.x; + py=parent.y; + dx=(x-px)/ Math.max(Math.abs(x-px),1); + dy=(y-py)/ Math.max(Math.abs(y-py),1); + if (dx!==0 && dy!==0){ + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + } + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + } + if (grid.isWalkableAt(x,y+dy)&& grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y+dy]); + } + } + else{ + var isNextWalkable; + if (dx!==0){ + isNextWalkable=grid.isWalkableAt(x+dx,y); + var isTopWalkable=grid.isWalkableAt(x,y+1); + var isBottomWalkable=grid.isWalkableAt(x,y-1); + if (isNextWalkable){ + neighbors.push([x+dx,y]); + if (isTopWalkable){ + neighbors.push([x+dx,y+1]); + } + if (isBottomWalkable){ + neighbors.push([x+dx,y-1]); + } + } + if (isTopWalkable){ + neighbors.push([x,y+1]); + } + if (isBottomWalkable){ + neighbors.push([x,y-1]); + } + } + else if (dy!==0){ + isNextWalkable=grid.isWalkableAt(x,y+dy); + var isRightWalkable=grid.isWalkableAt(x+1,y); + var isLeftWalkable=grid.isWalkableAt(x-1,y); + if (isNextWalkable){ + neighbors.push([x,y+dy]); + if (isRightWalkable){ + neighbors.push([x+1,y+dy]); + } + if (isLeftWalkable){ + neighbors.push([x-1,y+dy]); + } + } + if (isRightWalkable){ + neighbors.push([x+1,y]); + } + if (isLeftWalkable){ + neighbors.push([x-1,y]); + } + } + } + } + else{ + neighborNodes=grid.getNeighbors(node,DiagonalMovement.OnlyWhenNoObstacles); + for (i=0,l=neighborNodes.length;i < l;++i){ + neighborNode=neighborNodes[i]; + neighbors.push([neighborNode.x,neighborNode.y]); + } + } + return neighbors; + } + + return JPFMoveDiagonallyIfNoObstacles; + })(JumpPointFinderBase) + + + /** + *... + *@author ... + */ + //class PathFinding.finders.JPFNeverMoveDiagonally extends PathFinding.finders.JumpPointFinderBase + var JPFNeverMoveDiagonally=(function(_super){ + function JPFNeverMoveDiagonally(opt){ + JPFNeverMoveDiagonally.__super.call(this,opt); + } + + __class(JPFNeverMoveDiagonally,'PathFinding.finders.JPFNeverMoveDiagonally',_super); + var __proto=JPFNeverMoveDiagonally.prototype; + /** + *Search recursively in the direction (parent-> child),stopping only when a + *jump point is found. + *@protected + *@return {Array>}The x,y coordinate of the jump point + *found,or null if not found + */ + __proto._jump=function(x,y,px,py){ + var grid=this.grid,dx=x-px,dy=y-py; + if (!grid.isWalkableAt(x,y)){ + return null; + } + if (this.trackJumpRecursion===true){ + grid.getNodeAt(x,y).tested=true; + } + if (grid.getNodeAt(x,y)==this.endNode){ + return [x,y]; + } + if (dx!==0){ + if ((grid.isWalkableAt(x,y-1)&& !grid.isWalkableAt(x-dx,y-1))|| (grid.isWalkableAt(x,y+1)&& !grid.isWalkableAt(x-dx,y+1))){ + return [x,y]; + } + } + else if (dy!==0){ + if ((grid.isWalkableAt(x-1,y)&& !grid.isWalkableAt(x-1,y-dy))|| (grid.isWalkableAt(x+1,y)&& !grid.isWalkableAt(x+1,y-dy))){ + return [x,y]; + } + if (this._jump(x+1,y,x,y)|| this._jump(x-1,y,x,y)){ + return [x,y]; + } + } + else{ + throw new Error("Only horizontal and vertical movements are allowed"); + } + return this._jump(x+dx,y+dy,x,y); + } + + /** + *Find the neighbors for the given node. If the node has a parent, + *prune the neighbors based on the jump point search algorithm,otherwise + *return all available neighbors. + *@return {Array>}The neighbors found. + */ + __proto._findNeighbors=function(node){ + var parent=node.parent,x=node.x,y=node.y,grid=this.grid,px=0,py=0,nx=0,ny=0,dx=0,dy=0,neighbors=[],neighborNodes,neighborNode,i=0,l=0; + if (parent){ + px=parent.x; + py=parent.y; + dx=(x-px)/ Math.max(Math.abs(x-px),1); + dy=(y-py)/ Math.max(Math.abs(y-py),1); + if (dx!==0){ + if (grid.isWalkableAt(x,y-1)){ + neighbors.push([x,y-1]); + } + if (grid.isWalkableAt(x,y+1)){ + neighbors.push([x,y+1]); + } + if (grid.isWalkableAt(x+dx,y)){ + neighbors.push([x+dx,y]); + } + } + else if (dy!==0){ + if (grid.isWalkableAt(x-1,y)){ + neighbors.push([x-1,y]); + } + if (grid.isWalkableAt(x+1,y)){ + neighbors.push([x+1,y]); + } + if (grid.isWalkableAt(x,y+dy)){ + neighbors.push([x,y+dy]); + } + } + } + else{ + neighborNodes=grid.getNeighbors(node,DiagonalMovement.Never); + for (i=0,l=neighborNodes.length;i < l;++i){ + neighborNode=neighborNodes[i]; + neighbors.push([neighborNode.x,neighborNode.y]); + } + } + return neighbors; + } + + return JPFNeverMoveDiagonally; + })(JumpPointFinderBase) + + + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.tiledmap.js b/games/laya-snakes/libs/laya.tiledmap.js new file mode 100644 index 0000000..f8d3462 --- /dev/null +++ b/games/laya-snakes/libs/laya.tiledmap.js @@ -0,0 +1,1817 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Browser=laya.utils.Browser,Handler=laya.utils.Handler,Loader=laya.net.Loader,Point=laya.maths.Point; + var Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,Sprite=laya.display.Sprite,Texture=laya.resource.Texture; + /** + *tiledMap是整个地图的核心 + *地图以层级来划分地图(例如:地表层,植被层,建筑层) + *每层又以分块(GridSprite)来处理显示对象,只显示在视口区域的区 + *每块又包括N*N个格子(tile) + *格子类型又分为动画格子跟图片格子两种 + *@author ... + */ + //class laya.map.TiledMap + var TiledMap=(function(){ + var GRect,TileMapAniData,TileSet; + function TiledMap(){ + this._jsonData=null; + this._tileTexSetArr=[]; + this._texArray=[]; + this._x=0; + this._y=0; + this._width=0; + this._height=0; + this._mapW=0; + this._mapH=0; + this._mapTileW=0; + this._mapTileH=0; + this._mapSprite=null; + this._layerArray=[]; + this._gridArray=[]; + this._showGridKey=false; + this._totalGridNum=0; + this._gridW=0; + this._gridH=0; + this._gridWidth=450; + this._gridHeight=450; + this._jsonLoader=null; + this._loader=null; + this._tileSetArray=[]; + this._currTileSet=null; + this._completeHandler=null; + this._index=0; + this._animationDic={}; + this._properties=null; + this._tileProperties={}; + this._orientation="orthogonal"; + this._renderOrder="right-down"; + this._colorArray=["FF","00","33","66"]; + this._scale=1; + this._pivotScaleX=0.5; + this._pivotScaleY=0.5; + this._centerX=0; + this._centerY=0; + this._viewPortX=0; + this._viewPortY=0; + this._viewPortWidth=0; + this._viewPortHeight=0; + this._enableLinear=true; + this._resPath=null; + this._pathArray=null; + this._limitRange=false; + this._rect=new Rectangle(); + this._paddingRect=new Rectangle(); + this._mapRect=new GRect(); + this._mapLastRect=new GRect(); + } + + __class(TiledMap,'laya.map.TiledMap'); + var __proto=TiledMap.prototype; + /** + *创建地图 + *@param mapName JSON文件名字 + *@param viewRect 视口区域 + *@param completeHandler 地图创建完成的回调函数 + *@param viewRectPadding 视口扩充区域,把视口区域上、下、左、右扩充一下,防止视口移动时的穿帮 + *@param gridSize grid大小 + *@param enableLinear 是否开启线性取样(为false时,可以解决地图黑线的问题,但画质会锐化) + *@param limitRange 把地图限制在显示区域 + */ + __proto.createMap=function(mapName,viewRect,completeHandler,viewRectPadding,gridSize,enableLinear,limitRange){ + (enableLinear===void 0)&& (enableLinear=true); + (limitRange===void 0)&& (limitRange=false); + this._enableLinear=enableLinear; + this._limitRange=limitRange; + this._rect.x=viewRect.x; + this._rect.y=viewRect.y; + this._rect.width=viewRect.width; + this._rect.height=viewRect.height; + this._viewPortWidth=viewRect.width / this._scale; + this._viewPortHeight=viewRect.height / this._scale; + this._completeHandler=completeHandler; + if (viewRectPadding){ + this._paddingRect.copyFrom(viewRectPadding); + }else { + this._paddingRect.setTo(0,0,0,0); + } + if (gridSize){ + this._gridWidth=gridSize.x; + this._gridHeight=gridSize.y; + }; + var tIndex=mapName.lastIndexOf("/"); + if (tIndex >-1){ + this._resPath=mapName.substr(0,tIndex); + this._pathArray=this._resPath.split("/"); + }else { + this._resPath=""; + this._pathArray=[]; + } + this._jsonLoader=new Loader(); + this._jsonLoader.once("complete",this,this.onJsonComplete); + this._jsonLoader.load(mapName,/*laya.net.Loader.JSON*/"json",false); + } + + /** + *json文件读取成功后,解析里面的纹理数据,进行加载 + *@param e JSON数据 + */ + __proto.onJsonComplete=function(e){ + this._mapSprite=new Sprite(); + Laya.stage.addChild(this._mapSprite); + var tJsonData=this._jsonData=e; + this._properties=tJsonData.properties; + this._orientation=tJsonData.orientation; + this._renderOrder=tJsonData.renderorder; + this._mapW=tJsonData.width; + this._mapH=tJsonData.height; + this._mapTileW=tJsonData.tilewidth; + this._mapTileH=tJsonData.tileheight; + this._width=this._mapTileW *this._mapW; + this._height=this._mapTileH *this._mapH; + this._mapLastRect.top=this._mapLastRect.bottom=this._mapLastRect.left=this._mapLastRect.right=-1; + var tArray=tJsonData.tilesets; + var tileset; + var tTileSet; + var i=0; + for (i=0;i < tArray.length;i++){ + tileset=tArray[i]; + tTileSet=new TileSet(); + tTileSet.init(tileset); + this._tileProperties[i]=tTileSet.tileproperties; + this._tileSetArray.push(tTileSet); + var tTiles=tileset.tiles; + if (tTiles){ + for (var p in tTiles){ + var tAnimation=tTiles[p].animation; + if (tAnimation){ + var tAniData=new TileMapAniData(); + this._animationDic[p]=tAniData; + for (var j=0;j < tAnimation.length;j++){ + var tAnimationItem=tAnimation[j]; + tAniData.mAniIdArray.push(tAnimationItem.tileid); + tAniData.mDurationTimeArray.push(tAnimationItem.duration); + } + } + } + } + } + this._tileTexSetArr.push(null); + if (this._tileSetArray.length > 0){ + tTileSet=this._currTileSet=this._tileSetArray.shift(); + this._loader=new Loader(); + this._loader.once("complete",this,this.onTextureComplete); + var tPath=this.mergePath(this._resPath,tTileSet.image); + this._loader.load(tPath,/*laya.net.Loader.IMAGE*/"image",false); + } + } + + /** + *合并路径 + *@param resPath + *@param relativePath + *@return + */ + __proto.mergePath=function(resPath,relativePath){ + var tResultPath=""; + var tImageArray=relativePath.split("/"); + var tParentPathNum=0; + var i=0; + for (i=tImageArray.length-1;i >=0;i--){ + if (tImageArray[i]==".."){ + tParentPathNum++; + } + } + if (tParentPathNum==0){ + if (this._pathArray.length > 0){ + tResultPath=resPath+"/"+relativePath; + }else { + tResultPath=relativePath; + } + return tResultPath; + }; + var tSrcNum=this._pathArray.length-tParentPathNum; + if (tSrcNum < 0){ + console.log("[error]path does not exist"); + } + for (i=0;i < tSrcNum;i++){ + if (i==0){ + tResultPath+=this._pathArray[i]; + }else { + tResultPath=tResultPath+"/"+this._pathArray[i]; + } + } + for (i=tParentPathNum;i < tImageArray.length;i++){ + tResultPath=tResultPath+"/"+tImageArray[i]; + } + return tResultPath; + } + + /** + *纹理加载完成,如果所有的纹理加载,开始初始化地图 + *@param e 纹理数据 + */ + __proto.onTextureComplete=function(e){ + var json=this._jsonData; + var tTexture=e; + if (Render.isWebGL && (!this._enableLinear)){ + tTexture.bitmap.minFifter=0x2600; + tTexture.bitmap.magFifter=0x2600; + tTexture.bitmap.enableMerageInAtlas=false; + } + this._texArray.push(tTexture); + var tSubTexture=null; + var tTileSet=this._currTileSet; + var tTileTextureW=tTileSet.tilewidth; + var tTileTextureH=tTileSet.tileheight; + var tImageWidth=tTileSet.imagewidth; + var tImageHeight=tTileSet.imageheight; + var tFirstgid=tTileSet.firstgid; + var tTileWNum=Math.floor((tImageWidth-tTileSet.margin-tTileTextureW)/ (tTileTextureW+tTileSet.spacing))+1; + var tTileHNum=Math.floor((tImageHeight-tTileSet.margin-tTileTextureH)/ (tTileTextureH+tTileSet.spacing))+1; + var tTileTexSet=null; + for (var i=0;i < tTileHNum;i++){ + for (var j=0;j < tTileWNum;j++){ + tTileTexSet=new TileTexSet(); + tTileTexSet.offX=tTileSet.titleoffsetX; + tTileTexSet.offY=tTileSet.titleoffsetY-(tTileTextureH-this._mapTileH); + tTileTexSet.texture=Texture.create(tTexture,tTileSet.margin+(tTileTextureW+tTileSet.spacing)*j,tTileSet.margin+(tTileTextureH+tTileSet.spacing)*i,tTileTextureW,tTileTextureH); + this._tileTexSetArr.push(tTileTexSet); + tTileTexSet.gid=this._tileTexSetArr.length; + } + } + if (this._tileSetArray.length > 0){ + tTileSet=this._currTileSet=this._tileSetArray.shift(); + this._loader.once("complete",this,this.onTextureComplete); + var tPath=this.mergePath(this._resPath,tTileSet.image); + this._loader.load(tPath,/*laya.net.Loader.IMAGE*/"image",false); + }else { + this._currTileSet=null; + this.initMap(); + } + } + + /** + *初始化地图 + */ + __proto.initMap=function(){ + var i=0,n=0; + for (var p in this._animationDic){ + var tTileTexSet=this.getTexture(parseInt(p)+1); + var tAniData=this._animationDic[p]; + if (tAniData.mAniIdArray.length > 0){ + tTileTexSet.textureArray=[]; + tTileTexSet.durationTimeArray=tAniData.mDurationTimeArray; + tTileTexSet.isAnimation=true; + tTileTexSet.animationTotalTime=0; + for (i=0,n=tTileTexSet.durationTimeArray.length;i < n;i++){ + tTileTexSet.animationTotalTime+=tTileTexSet.durationTimeArray[i]; + } + for (i=0,n=tAniData.mAniIdArray.length;i < n;i++){ + var tTexture=this.getTexture(tAniData.mAniIdArray[i]+1); + tTileTexSet.textureArray.push(tTexture); + } + } + } + this._gridWidth=Math.floor(this._gridWidth / this._mapTileW)*this._mapTileW; + this._gridHeight=Math.floor(this._gridHeight / this._mapTileH)*this._mapTileH; + if (this._gridWidth < this._mapTileW){ + this._gridWidth=this._mapTileW; + } + if (this._gridWidth < this._mapTileH){ + this._gridWidth=this._mapTileH; + } + this._gridW=Math.ceil(this._width / this._gridWidth); + this._gridH=Math.ceil(this._height / this._gridHeight); + this._totalGridNum=this._gridW *this._gridH; + for (i=0;i < this._gridH;i++){ + var tGridArray=[]; + this._gridArray.push(tGridArray); + for (var j=0;j < this._gridW;j++){ + tGridArray.push(null); + } + }; + var tLayerArray=this._jsonData.layers; + for (var tLayerLoop=0;tLayerLoop < tLayerArray.length;tLayerLoop++){ + var tLayerData=tLayerArray[tLayerLoop]; + if (tLayerData.visible==true){ + var tMapLayer=new MapLayer(); + tMapLayer.init(tLayerData,this); + this._mapSprite.addChild(tMapLayer); + this._layerArray.push(tMapLayer); + } + } + this.moveViewPort(this._rect.x,this._rect.y); + if (this._completeHandler !=null){ + this._completeHandler.run(); + } + } + + /** + *得到一块指定的地图纹理 + *@param index 纹理的索引值,默认从1开始 + *@return + */ + __proto.getTexture=function(index){ + if (index < this._tileTexSetArr.length){ + return this._tileTexSetArr[index]; + } + return null; + } + + /** + *得到地图的自定义属性 + *@param name 属性名称 + *@return + */ + __proto.getMapProperties=function(name){ + if (this._properties){ + return this._properties[name]; + } + return null; + } + + /** + *得到tile自定义属性 + *@param index 地图块索引 + *@param id 具体的TileSetID + *@param name 属性名称 + *@return + */ + __proto.getTileProperties=function(index,id,name){ + if (this._tileProperties[index] && this._tileProperties[index][id]){ + return this._tileProperties[index][id][name]; + } + return null; + } + + /** + *通过纹理索引,生成一个可控制物件 + *@param index 纹理的索引值,默认从1开始 + *@return + */ + __proto.getSprite=function(index,width,height){ + if (0 < this._tileTexSetArr.length){ + var tGridSprite=new GridSprite(); + tGridSprite.initData(this,true); + var tTileTexSet=this._tileTexSetArr[index]; + if (tTileTexSet !=null && tTileTexSet.texture !=null){ + if (tTileTexSet.isAnimation){ + var tAnimationSprite=new TileAniSprite(); + this._index++; + tAnimationSprite.setTileTextureSet(this._index.toString(),tTileTexSet); + tGridSprite.addAniSprite(tAnimationSprite); + tGridSprite.addChild(tAnimationSprite); + }else { + tGridSprite.graphics.drawTexture(tTileTexSet.texture,0,0,width,height); + } + tGridSprite.drawImageNum++; + } + return tGridSprite; + } + return null; + } + + /** + *设置视口的缩放中心点(例如:scaleX=scaleY=0.5,就是以视口中心缩放) + *@param scaleX + *@param scaleY + */ + __proto.setViewPortPivotByScale=function(scaleX,scaleY){ + this._pivotScaleX=scaleX; + this._pivotScaleY=scaleY; + } + + /** + *移动视口 + *@param moveX 视口的坐标x + *@param moveY 视口的坐标y + */ + __proto.moveViewPort=function(moveX,moveY){ + this._x=-moveX; + this._y=-moveY; + this._rect.x=moveX; + this._rect.y=moveY; + this.updateViewPort(); + } + + /** + *改变视口大小 + *@param moveX 视口的坐标x + *@param moveY 视口的坐标y + *@param width 视口的宽 + *@param height 视口的高 + */ + __proto.changeViewPort=function(moveX,moveY,width,height){ + this._x=-moveX; + this._y=-moveY; + this._rect.x=moveX; + this._rect.y=moveY; + this._rect.width=width; + this._rect.height=height; + this._viewPortWidth=width / this._scale; + this._viewPortHeight=height / this._scale; + this.updateViewPort(); + } + + /** + *在锚点的基础上计算,通过宽和高,重新计算视口 + *@param width 新视口宽 + *@param height 新视口高 + *@param rect 返回的结果 + *@return + */ + __proto.changeViewPortBySize=function(width,height,rect){ + if (rect==null){ + rect=new Rectangle(); + } + this._centerX=this._rect.x+this._rect.width *this._pivotScaleX; + this._centerY=this._rect.y+this._rect.height *this._pivotScaleY; + rect.x=this._centerX-width *this._pivotScaleX; + rect.y=this._centerY-height *this._pivotScaleY; + rect.width=width; + rect.height=height; + this.changeViewPort(rect.x,rect.y,rect.width,rect.height); + return rect; + } + + /** + *刷新视口 + */ + __proto.updateViewPort=function(){ + this._centerX=this._rect.x+this._rect.width *this._pivotScaleX; + this._centerY=this._rect.y+this._rect.height *this._pivotScaleY; + this._viewPortX=this._centerX-this._rect.width *this._pivotScaleX/ this._scale; + this._viewPortY=this._centerY-this._rect.height *this._pivotScaleY / this._scale; + if (this._limitRange){ + var tRight=this._viewPortX+this._viewPortWidth; + if (tRight > this._width){ + this._viewPortX=this._width-this._viewPortWidth; + }; + var tBottom=this._viewPortY+this._viewPortHeight; + if (tBottom > this._height){ + this._viewPortY=this._height-this._viewPortHeight; + } + if (this._viewPortX < 0){ + this._viewPortX=0; + } + if (this._viewPortY < 0){ + this._viewPortY=0; + } + }; + var tPaddingRect=this._paddingRect; + this._mapRect.top=Math.floor((this._viewPortY-tPaddingRect.y)/ this._gridHeight); + this._mapRect.bottom=Math.floor((this._viewPortY+this._viewPortHeight+tPaddingRect.height+tPaddingRect.y)/ this._gridHeight); + this._mapRect.left=Math.floor((this._viewPortX-tPaddingRect.x)/ this._gridWidth); + this._mapRect.right=Math.floor((this._viewPortX+this._viewPortWidth+tPaddingRect.width+tPaddingRect.x)/ this._gridWidth); + this.clipViewPort(); + this._mapLastRect.top=this._mapRect.top; + this._mapLastRect.bottom=this._mapRect.bottom; + this._mapLastRect.left=this._mapRect.left; + this._mapLastRect.right=this._mapRect.right; + var tMapLayer; + for (var i=0;i < this._layerArray.length;i++){ + tMapLayer=this._layerArray[i]; + tMapLayer.updateGridPos(); + } + } + + /** + *GRID裁剪 + */ + __proto.clipViewPort=function(){ + var tSpriteNum=0; + var tSprite; + var tIndex=0; + var tSub=0; + var tAdd=0; + var i=0,j=0; + if (this._mapRect.left > this._mapLastRect.left){ + tSub=this._mapRect.left-this._mapLastRect.left; + if (tSub > 0){ + for (j=this._mapLastRect.left;j < this._mapLastRect.left+tSub;j++){ + for (i=this._mapLastRect.top;i <=this._mapLastRect.bottom;i++){ + this.hideGrid(j,i); + } + } + } + }else { + tAdd=this._mapLastRect.left-this._mapRect.left; + if (tAdd > 0){ + for (j=this._mapRect.left;j < this._mapRect.left+tAdd;j++){ + for (i=this._mapRect.top;i <=this._mapRect.bottom;i++){ + this.showGrid(j,i); + } + } + } + } + if (this._mapRect.right > this._mapLastRect.right){ + tAdd=this._mapRect.right-this._mapLastRect.right; + if (tAdd > 0){ + for (j=this._mapLastRect.right+1;j <=this._mapLastRect.right+tAdd;j++){ + for (i=this._mapRect.top;i <=this._mapRect.bottom;i++){ + this.showGrid(j,i); + } + } + } + }else { + tSub=this._mapLastRect.right-this._mapRect.right + if (tSub > 0){ + for (j=this._mapRect.right+1;j <=this._mapRect.right+tSub;j++){ + for (i=this._mapLastRect.top;i <=this._mapLastRect.bottom;i++){ + this.hideGrid(j,i); + } + } + } + } + if (this._mapRect.top > this._mapLastRect.top){ + tSub=this._mapRect.top-this._mapLastRect.top; + if (tSub > 0){ + for (i=this._mapLastRect.top;i < this._mapLastRect.top+tSub;i++){ + for (j=this._mapLastRect.left;j <=this._mapLastRect.right;j++){ + this.hideGrid(j,i); + } + } + } + }else { + tAdd=this._mapLastRect.top-this._mapRect.top; + if (tAdd > 0){ + for (i=this._mapRect.top;i < this._mapRect.top+tAdd;i++){ + for (j=this._mapRect.left;j <=this._mapRect.right;j++){ + this.showGrid(j,i); + } + } + } + } + if (this._mapRect.bottom > this._mapLastRect.bottom){ + tAdd=this._mapRect.bottom-this._mapLastRect.bottom; + if (tAdd > 0){ + for (i=this._mapLastRect.bottom+1;i <=this._mapLastRect.bottom+tAdd;i++){ + for (j=this._mapRect.left;j <=this._mapRect.right;j++){ + this.showGrid(j,i); + } + } + } + }else { + tSub=this._mapLastRect.bottom-this._mapRect.bottom + if (tSub > 0){ + for (i=this._mapRect.bottom+1;i <=this._mapRect.bottom+tSub;i++){ + for (j=this._mapLastRect.left;j <=this._mapLastRect.right;j++){ + this.hideGrid(j,i); + } + } + } + } + } + + /** + *显示指定的GRID + *@param gridX + *@param gridY + */ + __proto.showGrid=function(gridX,gridY){ + if (gridX < 0 || gridX >=this._gridW || gridY < 0 || gridY >=this._gridH){ + return; + }; + var i=0,j=0; + var tGridSprite; + var tTempArray=this._gridArray[gridY][gridX]; + if (tTempArray==null){ + tTempArray=this._gridArray[gridY][gridX]=[]; + var tLeft=0; + var tRight=0; + var tTop=0; + var tBottom=0; + var tGridWidth=this._gridWidth; + var tGridHeight=this._gridHeight; + switch (this.orientation){ + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric": + tLeft=Math.floor(gridX *tGridWidth); + tRight=Math.floor(gridX *tGridWidth+tGridWidth); + tTop=Math.floor(gridY *tGridHeight); + tBottom=Math.floor(gridY *tGridHeight+tGridHeight); + var tLeft1=0,tRight1=0,tTop1=0,tBottom1=0; + break ; + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + tLeft=Math.floor(gridX *tGridWidth / this._mapTileW); + tRight=Math.floor((gridX *tGridWidth+tGridWidth)/ this._mapTileW); + tTop=Math.floor(gridY *tGridHeight / (this._mapTileH/2)); + tBottom=Math.floor((gridY *tGridHeight+tGridHeight)/ (this._mapTileH/2)); + break ; + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + tLeft=Math.floor(gridX *tGridWidth / this._mapTileW); + tRight=Math.floor((gridX *tGridWidth+tGridWidth)/ this._mapTileW); + tTop=Math.floor(gridY *tGridHeight / this._mapTileH); + tBottom=Math.floor((gridY *tGridHeight+tGridHeight)/ this._mapTileH); + break ; + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal":; + var tHeight=this._mapTileH *2 / 3; + tLeft=Math.floor(gridX *tGridWidth / this._mapTileW); + tRight=Math.ceil((gridX *tGridWidth+tGridWidth)/ this._mapTileW); + tTop=Math.floor(gridY *tGridHeight / tHeight); + tBottom=Math.ceil((gridY *tGridHeight+tGridHeight)/ tHeight); + break ; + }; + var tLayer=null; + for (var z=0;z < this._layerArray.length;z++){ + tLayer=this._layerArray[z]; + tGridSprite=tLayer.getDrawSprite(gridX,gridY); + tTempArray.push(tGridSprite); + var tColorStr; + if (this._showGridKey){ + tColorStr="#"; + tColorStr+=this._colorArray[Math.floor(Math.random()*this._colorArray.length)]; + tColorStr+=this._colorArray[Math.floor(Math.random()*this._colorArray.length)]; + tColorStr+=this._colorArray[Math.floor(Math.random()*this._colorArray.length)]; + } + switch (this.orientation){ + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric":; + var tHalfTileHeight=this.tileHeight / 2; + var tHalfTileWidth=this.tileWidth / 2; + var tHalfMapWidth=this._width / 2; + tTop1=Math.floor(tTop / tHalfTileHeight); + tBottom1=Math.floor(tBottom / tHalfTileHeight); + tLeft1=this._mapW+Math.floor((tLeft-tHalfMapWidth)/ tHalfTileWidth); + tRight1=this._mapW+Math.floor((tRight-tHalfMapWidth)/ tHalfTileWidth); + var tMapW=this._mapW *2; + var tMapH=this._mapH *2; + if (tTop1 < 0){ + tTop1=0; + } + if (tTop1 >=tMapH){ + tTop1=tMapH-1; + } + if (tBottom1 < 0){ + tBottom=0; + } + if (tBottom1 >=tMapH){ + tBottom1=tMapH-1; + } + tGridSprite.zOrder=this._totalGridNum *z+gridY *this._gridW+gridX; + for (i=tTop1;i < tBottom1;i++){ + for (j=0;j <=i;j++){ + var tIndexX=i-j; + var tIndexY=j; + var tIndexValue=(tIndexX-tIndexY)+this._mapW; + if (tIndexValue > tLeft1 && tIndexValue <=tRight1){ + if (tLayer.drawTileTexture(tGridSprite,tIndexX,tIndexY)){ + tGridSprite.drawImageNum++; + } + } + } + } + break ; + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + tGridSprite.zOrder=z *this._totalGridNum+gridY *this._gridW+gridX; + for (i=tTop;i < tBottom;i++){ + for (j=tLeft;j < tRight;j++){ + if (tLayer.drawTileTexture(tGridSprite,j,i)){ + tGridSprite.drawImageNum++; + } + } + } + break ; + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + case /*CLASS CONST:laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal": + switch (this._renderOrder){ + case "right-down": + tGridSprite.zOrder=z *this._totalGridNum+gridY *this._gridW+gridX; + for (i=tTop;i < tBottom;i++){ + for (j=tLeft;j < tRight;j++){ + if (tLayer.drawTileTexture(tGridSprite,j,i)){ + tGridSprite.drawImageNum++; + } + } + } + break ; + case "right-up": + tGridSprite.zOrder=z *this._totalGridNum+(this._gridH-1-gridY)*this._gridW+gridX; + for (i=tBottom-1;i >=tTop;i--){ + for (j=tLeft;j < tRight;j++){ + if (tLayer.drawTileTexture(tGridSprite,j,i)){ + tGridSprite.drawImageNum++; + } + } + } + break ; + case "left-down": + tGridSprite.zOrder=z *this._totalGridNum+gridY *this._gridW+(this._gridW-1-gridX); + for (i=tTop;i < tBottom;i++){ + for (j=tRight-1;j >=tLeft;j--){ + if (tLayer.drawTileTexture(tGridSprite,j,i)){ + tGridSprite.drawImageNum++; + } + } + } + break ; + case "left-up": + tGridSprite.zOrder=z *this._totalGridNum+(this._gridH-1-gridY)*this._gridW+(this._gridW-1-gridX); + for (i=tBottom-1;i >=tTop;i--){ + for (j=tRight-1;j >=tLeft;j--){ + if (tLayer.drawTileTexture(tGridSprite,j,i)){ + tGridSprite.drawImageNum++; + } + } + } + break ; + } + break ; + } + if (!tGridSprite.isHaveAnimation){ + tGridSprite.autoSize=true; + tGridSprite.cacheAs="bitmap"; + tGridSprite.autoSize=false; + } + if (tGridSprite.drawImageNum > 0){ + tLayer.addChild(tGridSprite); + } + if (this._showGridKey){ + tGridSprite.graphics.drawRect(0,0,tGridWidth,tGridHeight,null,tColorStr); + } + } + }else { + for (i=0;i < tTempArray.length && i < this._layerArray.length;i++){ + var tLayerSprite=this._layerArray[i]; + if (tLayerSprite && tTempArray[i]){ + tGridSprite=tTempArray[i]; + if (tGridSprite.visible==false && tGridSprite.drawImageNum > 0){ + tGridSprite.show(); + } + } + } + } + } + + /** + *隐藏指定的GRID + *@param gridX + *@param gridY + */ + __proto.hideGrid=function(gridX,gridY){ + if (gridX < 0 || gridX >=this._gridW || gridY < 0 || gridY >=this._gridH){ + return; + }; + var tTempArray=this._gridArray[gridY][gridX]; + if (tTempArray){ + var tGridSprite; + for (var i=0;i < tTempArray.length;i++){ + tGridSprite=tTempArray[i]; + if (tGridSprite.drawImageNum > 0){ + if (tGridSprite !=null){ + tGridSprite.hide(); + } + } + } + } + } + + /** + *得到对象层上的某一个物品 + *@param layerName 层的名称 + *@param objectName 所找物品的名称 + *@return + */ + __proto.getLayerObject=function(layerName,objectName){ + var tLayer=null; + for (var i=0;i < this._layerArray.length;i++){ + tLayer=this._layerArray[i]; + if (tLayer.layerName==layerName){ + break ; + } + } + if (tLayer){ + return tLayer.getObjectByName(objectName); + } + return null; + } + + /** + *销毁地图 + */ + __proto.destroy=function(){ + this._orientation="orthogonal"; + this._jsonData=null; + var i=0; + var j=0; + var z=0; + this._gridArray=[]; + var tTileTexSet; + for (i=0;i < this._tileTexSetArr.length;i++){ + tTileTexSet=this._tileTexSetArr[i]; + if (tTileTexSet){ + tTileTexSet.clearAll(); + } + } + this._tileTexSetArr=[]; + var tTexture; + for (i=0;i < this._texArray.length;i++){ + tTexture=this._texArray[i]; + tTexture.destroy(); + } + this._texArray=[]; + this._width=0; + this._height=0; + this._mapW=0; + this._mapH=0; + this._mapTileW=0; + this._mapTileH=0; + this._rect.setTo(0,0,0,0); + var tLayer; + for (i=0;i < this._layerArray.length;i++){ + tLayer=this._layerArray[i]; + tLayer.clearAll(); + } + this._layerArray=[]; + if (this._mapSprite){ + this._mapSprite.destroy(); + this._mapSprite=null; + } + this._jsonLoader=null; + this._loader=null; + var tDic=this._animationDic; + for (var p in tDic){ + delete tDic[p]; + } + this._properties=null; + tDic=this._tileProperties; + for (p in tDic){ + delete tDic[p]; + } + this._currTileSet=null; + this._completeHandler=null; + this._mapRect.clearAll(); + this._mapLastRect.clearAll(); + this._tileSetArray=[]; + this._gridWidth=450; + this._gridHeight=450; + this._gridW=0; + this._gridH=0; + this._x=0; + this._y=0; + this._index=0; + this._enableLinear=true; + this._resPath=null; + this._pathArray=null; + } + + /** + *整个地图的显示容器 + *@return 地图的显示容器 + */ + __proto.mapSprite=function(){ + return this._mapSprite; + } + + /** + *得到指定的MapLayer + *@param layerName 要找的层名称 + *@return + */ + __proto.getLayerByName=function(layerName){ + var tMapLayer; + for (var i=0;i < this._layerArray.length;i++){ + tMapLayer=this._layerArray[i]; + if (layerName==tMapLayer.layerName){ + return tMapLayer; + } + } + return null; + } + + /** + *通过索引得MapLayer + *@param index 要找的层索引 + *@return + */ + __proto.getLayerByIndex=function(index){ + if (index < this._layerArray.length){ + return this._layerArray[index]; + } + return null; + } + + /** + *当前地图类型 + */ + __getset(0,__proto,'orientation',function(){ + return this._orientation; + }); + + /** + *@private + *视口x坐标 + */ + __getset(0,__proto,'viewPortX',function(){ + return-this._viewPortX; + }); + + /** + *设置地图缩放 + *@param scale + */ + /** + *得到当前地图的缩放 + */ + __getset(0,__proto,'scale',function(){ + return this._scale; + },function(scale){ + if (scale <=0)return; + this._scale=scale; + this._viewPortWidth=this._rect.width / scale; + this._viewPortHeight=this._rect.height / scale; + this._mapSprite.scale(this._scale,this._scale); + this.updateViewPort(); + }); + + /** + *格子的宽度 + */ + __getset(0,__proto,'tileWidth',function(){ + return this._mapTileW; + }); + + /** + *@private + *视口的y坐标 + */ + __getset(0,__proto,'viewPortY',function(){ + return-this._viewPortY; + }); + + /** + *格子的高度 + */ + __getset(0,__proto,'tileHeight',function(){ + return this._mapTileH; + }); + + /** + *地图的宽度 + */ + __getset(0,__proto,'width',function(){ + return this._width; + }); + + /** + *地图竖向的格子数 + */ + __getset(0,__proto,'numRowsTile',function(){ + return this._mapH; + }); + + /** + *地图横向的格子数 + */ + __getset(0,__proto,'numColumnsTile',function(){ + return this._mapW; + }); + + /** + *地图的高度 + */ + __getset(0,__proto,'height',function(){ + return this._height; + }); + + /** + *@private + *视口的宽度 + */ + __getset(0,__proto,'viewPortWidth',function(){ + return this._viewPortWidth; + }); + + /** + *@private + *视口的高度 + */ + __getset(0,__proto,'viewPortHeight',function(){ + return this._viewPortHeight; + }); + + /** + *地图的x坐标 + */ + __getset(0,__proto,'x',function(){ + return this._x; + }); + + /** + *地图的y坐标 + */ + __getset(0,__proto,'y',function(){ + return this._y; + }); + + /** + *块的宽度 + */ + __getset(0,__proto,'gridWidth',function(){ + return this._gridWidth; + }); + + /** + *块的高度 + */ + __getset(0,__proto,'gridHeight',function(){ + return this._gridHeight; + }); + + /** + *地图的横向块数 + */ + __getset(0,__proto,'numColumnsGrid',function(){ + return this._gridW; + }); + + /** + *地图的坚向块数 + */ + __getset(0,__proto,'numRowsGrid',function(){ + return this._gridH; + }); + + /** + *tile渲染顺序 + */ + __getset(0,__proto,'renderOrder',function(){ + return this._renderOrder; + }); + + TiledMap.ORIENTATION_ORTHOGONAL="orthogonal"; + TiledMap.ORIENTATION_ISOMETRIC="isometric"; + TiledMap.ORIENTATION_STAGGERED="staggered"; + TiledMap.ORIENTATION_HEXAGONAL="hexagonal"; + TiledMap.RENDERORDER_RIGHTDOWN="right-down"; + TiledMap.RENDERORDER_RIGHTUP="right-up"; + TiledMap.RENDERORDER_LEFTDOWN="left-down"; + TiledMap.RENDERORDER_LEFTUP="left-up"; + TiledMap.__init$=function(){ + //class GRect + GRect=(function(){ + function GRect(){ + this.left=0; + this.top=0; + this.right=0; + this.bottom=0; + } + __class(GRect,''); + var __proto=GRect.prototype; + __proto.clearAll=function(){ + this.left=this.top=this.right=this.bottom=0; + } + return GRect; + })() + //class TileMapAniData + TileMapAniData=(function(){ + function TileMapAniData(){ + this.mAniIdArray=[]; + this.mDurationTimeArray=[]; + this.mTileTexSetArr=[]; + } + __class(TileMapAniData,''); + return TileMapAniData; + })() + //class TileSet + TileSet=(function(){ + function TileSet(){ + this.firstgid=0; + this.image=""; + this.imageheight=0; + this.imagewidth=0; + this.margin=0; + this.name=0; + this.properties=null; + this.spacing=0; + this.tileheight=0; + this.tilewidth=0; + this.titleoffsetX=0; + this.titleoffsetY=0; + this.tileproperties=null; + } + __class(TileSet,''); + var __proto=TileSet.prototype; + __proto.init=function(data){ + this.firstgid=data.firstgid; + this.image=data.image; + this.imageheight=data.imageheight; + this.imagewidth=data.imagewidth; + this.margin=data.margin; + this.name=data.name; + this.properties=data.properties; + this.spacing=data.spacing; + this.tileheight=data.tileheight; + this.tilewidth=data.tilewidth; + this.tileproperties=data.tileproperties; + var tTileoffset=data.tileoffset; + if (tTileoffset){ + this.titleoffsetX=tTileoffset.x; + this.titleoffsetY=tTileoffset.y; + } + } + return TileSet; + })() + } + + return TiledMap; + })() + + + /** + *此类是子纹理类,也包括同类动画的管理 + *TiledMap会把纹理分割成无数子纹理,也可以把其中的某块子纹理替换成一个动画序列 + *本类的实现就是如果发现子纹理被替换成一个动画序列,animationKey会被设为true + *即animationKey为true,就使用TileAniSprite来做显示,把动画序列根据时间画到TileAniSprite上 + *@author ... + */ + //class laya.map.TileTexSet + var TileTexSet=(function(){ + function TileTexSet(){ + this.gid=-1; + this.texture=null; + this.offX=0; + this.offY=0; + this.textureArray=null; + this.durationTimeArray=null; + this.animationTotalTime=0; + this.isAnimation=false; + this._spriteNum=0; + this._aniDic=null; + this._frameIndex=0; + this._time=0; + this._interval=0; + this._preFrameTime=0; + } + + __class(TileTexSet,'laya.map.TileTexSet'); + var __proto=TileTexSet.prototype; + /** + *加入一个动画显示对象到此动画中 + *@param aniName //显示对象的名字 + *@param sprite //显示对象 + */ + __proto.addAniSprite=function(aniName,sprite){ + if (this.animationTotalTime==0){ + return; + } + if (this._aniDic==null){ + this._aniDic={}; + } + if (this._spriteNum==0){ + Laya.timer.frameLoop(3,this,this.animate); + this._preFrameTime=Browser.now(); + this._frameIndex=0; + this._time=0; + this._interval=0; + } + this._spriteNum++; + this._aniDic[aniName]=sprite; + if (this.textureArray && this._frameIndex < this.textureArray.length){ + var tTileTextureSet=this.textureArray[this._frameIndex]; + this.drawTexture(sprite,tTileTextureSet); + } + } + + /** + *把动画画到所有注册的SPRITE上 + */ + __proto.animate=function(){ + if (this.textureArray && this.textureArray.length > 0 && this.durationTimeArray && this.durationTimeArray.length > 0){ + var tNow=Browser.now(); + this._interval=tNow-this._preFrameTime; + this._preFrameTime=tNow; + if (this._interval > this.animationTotalTime){ + this._interval=this._interval % this.animationTotalTime; + } + this._time+=this._interval; + var tTime=this.durationTimeArray[this._frameIndex]; + while (this._time > tTime){ + this._time-=tTime; + this._frameIndex++; + if (this._frameIndex >=this.durationTimeArray.length || this._frameIndex >=this.textureArray.length){ + this._frameIndex=0; + }; + var tTileTextureSet=this.textureArray[this._frameIndex]; + var tSprite; + for (var p in this._aniDic){ + tSprite=this._aniDic[p]; + this.drawTexture(tSprite,tTileTextureSet); + } + tTime=this.durationTimeArray[this._frameIndex]; + } + } + } + + __proto.drawTexture=function(sprite,tileTextSet){ + sprite.graphics.clear(); + sprite.graphics.drawTexture(tileTextSet.texture,tileTextSet.offX,tileTextSet.offY,tileTextSet.texture.width,tileTextSet.texture.height); + } + + /** + *移除不需要更新的SPRITE + *@param _name + */ + __proto.removeAniSprite=function(_name){ + if (this._aniDic && this._aniDic[_name]){ + delete this._aniDic[_name]; + this._spriteNum-- + if (this._spriteNum==0){ + Laya.timer.clear(this,this.animate); + } + } + } + + /** + *显示当前动画的使用情况 + */ + __proto.showDebugInfo=function(){ + var tInfo=null; + if (this._spriteNum > 0){ + tInfo="TileTextureSet::gid:"+this.gid.toString()+" 动画数:"+this._spriteNum.toString(); + } + return tInfo; + } + + /** + *清理 + */ + __proto.clearAll=function(){ + this.gid=-1; + if (this.texture){ + this.texture.destroy(); + this.texture=null; + } + this.offX=0; + this.offY=0; + this.textureArray=null; + this.durationTimeArray=null; + this.isAnimation=false; + this._spriteNum=0; + this._aniDic=null; + this._frameIndex=0; + this._preFrameTime=0; + this._time=0; + this._interval=0; + } + + return TileTexSet; + })() + + + /** + *地图的每层都会分块渲染处理 + *本类就是地图的块数据 + *@author ... + */ + //class laya.map.GridSprite extends laya.display.Sprite + var GridSprite=(function(_super){ + function GridSprite(){ + this.relativeX=0; + this.relativeY=0; + this.isAloneObject=false; + this.isHaveAnimation=false; + this.aniSpriteArray=null; + this.drawImageNum=0; + this._map=null; + GridSprite.__super.call(this); + } + + __class(GridSprite,'laya.map.GridSprite',_super); + var __proto=GridSprite.prototype; + /** + *传入必要的参数,用于裁剪,跟确认此对象类型 + *@param map 把地图的引用传进来,参与一些裁剪计算 + *@param objectKey true:表示当前GridSprite是个活动对象,可以控制,false:地图层的组成块 + */ + __proto.initData=function(map,objectKey){ + (objectKey===void 0)&& (objectKey=false); + this._map=map; + this.isAloneObject=objectKey; + } + + /** + *把一个动画对象绑定到当前GridSprite + *@param sprite 动画的显示对象 + */ + __proto.addAniSprite=function(sprite){ + if (this.aniSpriteArray==null){ + this.aniSpriteArray=[]; + } + this.aniSpriteArray.push(sprite); + } + + /** + *显示当前GridSprite,并把上面的动画全部显示 + */ + __proto.show=function(){ + if (!this.visible){ + this.visible=true; + if (this.aniSpriteArray==null){ + return; + }; + var tAniSprite; + for (var i=0;i < this.aniSpriteArray.length;i++){ + tAniSprite=this.aniSpriteArray[i]; + tAniSprite.show(); + } + } + } + + /** + *隐藏当前GridSprite,并把上面绑定的动画全部移除 + */ + __proto.hide=function(){ + if (this.visible){ + this.visible=false; + if (this.aniSpriteArray==null){ + return; + }; + var tAniSprite; + for (var i=0;i < this.aniSpriteArray.length;i++){ + tAniSprite=this.aniSpriteArray[i]; + tAniSprite.hide(); + } + } + } + + /** + *刷新坐标,当我们自己控制一个GridSprite移动时,需要调用此函数,手动刷新 + */ + __proto.updatePos=function(){ + if (this.isAloneObject){ + if (this._map){ + this.x=this.relativeX+this._map.viewPortX; + this.y=this.relativeY+this._map.viewPortY; + } + if (this.x < 0 || this.x > this._map.viewPortWidth || this.y < 0 || this.y > this._map.viewPortHeight){ + this.hide(); + }else { + this.show(); + } + }else { + if (this._map){ + this.x=this.relativeX+this._map.viewPortX; + this.y=this.relativeY+this._map.viewPortY; + } + } + } + + /** + *重置当前对象的所有属性 + */ + __proto.clearAll=function(){ + if (this._map){ + this._map=null; + } + this.visible=false; + if (this.aniSpriteArray==null){ + return; + }; + var tAniSprite; + for (var i=0;i < this.aniSpriteArray.length;i++){ + tAniSprite=this.aniSpriteArray[i]; + tAniSprite.clearAll(); + } + this.destroy(); + this.relativeX=0; + this.relativeY=0; + this.isHaveAnimation=false; + this.aniSpriteArray=null; + this.drawImageNum=0; + } + + return GridSprite; + })(Sprite) + + + /** + *地图支持多层渲染(例如,地表层,植被层,建筑层等) + *本类就是层级类 + *@author ... + */ + //class laya.map.MapLayer extends laya.display.Sprite + var MapLayer=(function(_super){ + function MapLayer(){ + this._map=null; + this._mapData=null; + this._tileWidthHalf=0; + this._tileHeightHalf=0; + this._mapWidthHalf=0; + this._mapHeightHalf=0; + this._gridSpriteArray=[]; + this._objDic=null; + this._properties=null; + this.layerName=null; + MapLayer.__super.call(this); + this._tempMapPos=new Point(); + } + + __class(MapLayer,'laya.map.MapLayer',_super); + var __proto=MapLayer.prototype; + /** + *解析LAYER数据,以及初始化一些数据 + *@param layerData 地图数据中,layer数据的引用 + *@param map 地图的引用 + */ + __proto.init=function(layerData,map){ + this._map=map; + this._mapData=layerData.data; + var tHeight=layerData.height; + var tWidth=layerData.width; + var tTileW=map.tileWidth; + var tTileH=map.tileHeight; + this.layerName=layerData.name; + this._properties=layerData.properties; + this.alpha=layerData.opacity; + this._tileWidthHalf=tTileW / 2; + this._tileHeightHalf=tTileH / 2; + this._mapWidthHalf=this._map.width / 2-this._tileWidthHalf; + this._mapHeightHalf=this._map.height / 2; + switch (layerData.type){ + case "tilelayer": + break ; + case "objectgroup":; + var tObjectGid=0; + var tArray=layerData.objects; + if (tArray.length > 0){ + this._objDic={}; + }; + var tObjectData; + var tObjWidth=NaN; + var tObjHeight=NaN; + for (var i=0;i < tArray.length;i++){ + tObjectData=tArray[i]; + if (tObjectData.visible==true){ + tObjWidth=tObjectData.width; + tObjHeight=tObjectData.height; + var tSprite=map.getSprite(tObjectData.gid,tObjWidth,tObjHeight); + if (tSprite !=null){ + switch (this._map.orientation){ + case /*laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric": + this.getScreenPositionByTilePos(tObjectData.x / tTileH,tObjectData.y / tTileH,Point.TEMP); + tSprite.pivot(tObjWidth / 2,tObjHeight / 2); + tSprite.rotation=tObjectData.rotation; + tSprite.x=tSprite.relativeX=Point.TEMP.x+this._map.viewPortX; + tSprite.y=tSprite.relativeY=Point.TEMP.y+this._map.viewPortY-tObjHeight / 2; + break ; + case /*laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + tSprite.pivot(tObjWidth / 2,tObjHeight / 2); + tSprite.rotation=tObjectData.rotation; + tSprite.x=tSprite.relativeX=tObjectData.x+tObjWidth / 2; + tSprite.y=tSprite.relativeY=tObjectData.y-tObjHeight / 2; + break ; + case /*laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + tSprite.pivot(tObjWidth / 2,tObjHeight / 2); + tSprite.rotation=tObjectData.rotation; + tSprite.x=tSprite.relativeX=tObjectData.x+tObjWidth / 2; + tSprite.y=tSprite.relativeY=tObjectData.y-tObjHeight / 2; + break ; + case /*laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal": + tSprite.x=tSprite.relativeX=tObjectData.x; + tSprite.y=tSprite.relativeY=tObjectData.y; + break ; + } + this.addChild(tSprite); + this._gridSpriteArray.push(tSprite); + this._objDic[tObjectData.name]=tSprite; + } + } + } + break ; + } + } + + /** + *通过名字获取控制对象,如果找不到返回为null + *@param objName 所要获取对象的名字 + *@return + */ + __proto.getObjectByName=function(objName){ + if (this._objDic){ + return this._objDic[objName]; + } + return null; + } + + /** + *得到地图层的自定义属性 + *@param name + *@return + */ + __proto.getLayerProperties=function(name){ + if (this._properties){ + return this._properties[name]; + } + return null; + } + + /** + *得到指定格子的数据 + *@param tileX 格子坐标X + *@param tileY 格子坐标Y + *@return + */ + __proto.getTileData=function(tileX,tileY){ + if (tileY >=0 && tileY < this._map.numRowsTile && tileX >=0 && tileX < this._map.numColumnsTile){ + var tIndex=tileY *this._map.numColumnsTile+tileX; + var tMapData=this._mapData; + if (tMapData !=null && tIndex < tMapData.length){ + return tMapData[tIndex]; + } + } + return 0; + } + + /** + *通过地图坐标得到屏幕坐标 + *@param tileX 格子坐标X + *@param tileY 格子坐标Y + *@param screenPos 把计算好的屏幕坐标数据,放到此对象中 + */ + __proto.getScreenPositionByTilePos=function(tileX,tileY,screenPos){ + if (screenPos){ + switch (this._map.orientation){ + case /*laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric": + screenPos.x=this._map.width / 2-(tileY-tileX)*this._tileWidthHalf; + screenPos.y=(tileY+tileX)*this._tileHeightHalf; + break ; + case /*laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + tileX=Math.floor(tileX); + tileY=Math.floor(tileY); + screenPos.x=tileX *this._map.tileWidth+(tileY & 1)*this._tileWidthHalf; + screenPos.y=tileY *this._tileHeightHalf; + break ; + case /*laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + screenPos.x=tileX *this._map.tileWidth; + screenPos.y=tileY *this._map.tileHeight; + break ; + case /*laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal": + tileX=Math.floor(tileX); + tileY=Math.floor(tileY); + var tTileHeight=this._map.tileHeight *2 / 3; + screenPos.x=(tileX *this._map.tileWidth+tileY % 2 *this._tileWidthHalf)% this._map.gridWidth; + screenPos.y=(tileY *tTileHeight)% this._map.gridHeight; + break ; + } + screenPos.x=(screenPos.x+this._map.viewPortX)*this._map.scale; + screenPos.y=(screenPos.y+this._map.viewPortY)*this._map.scale; + } + } + + /** + *通过屏幕坐标来获取选中格子的数据 + *@param screenX 屏幕坐标x + *@param screenY 屏幕坐标y + *@return + */ + __proto.getTileDataByScreenPos=function(screenX,screenY){ + var tData=0; + if (this.getTilePositionByScreenPos(screenX,screenY,this._tempMapPos)){ + tData=this.getTileData(Math.floor(this._tempMapPos.x),Math.floor(this._tempMapPos.y)); + } + return tData; + } + + /** + *通过屏幕坐标来获取选中格子的索引 + *@param screenX 屏幕坐标x + *@param screenY 屏幕坐标y + *@param result 把计算好的格子坐标,放到此对象中 + *@return + */ + __proto.getTilePositionByScreenPos=function(screenX,screenY,result){ + screenX=screenX/this._map.scale-this._map.viewPortX; + screenY=screenY/this._map.scale-this._map.viewPortY; + var tTileW=this._map.tileWidth; + var tTileH=this._map.tileHeight; + var tV=0; + var tU=0; + switch (this._map.orientation){ + case /*laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric":; + var tDirX=screenX-this._map.width / 2; + var tDirY=screenY; + tV=-(tDirX / tTileW-tDirY / tTileH); + tU=tDirX / tTileW+tDirY / tTileH; + if (result){ + result.x=tU; + result.y=tV; + } + return true; + break ; + case /*laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + if (result){ + var cx=0,cy=0,rx=0,ry=0; + cx=Math.floor(screenX / tTileW)*tTileW+tTileW / 2; + cy=Math.floor(screenY / tTileH)*tTileH+tTileH / 2; + rx=(screenX-cx)*tTileH / 2; + ry=(screenY-cy)*tTileW / 2; + if (Math.abs(rx)+Math.abs(ry)<=tTileW *tTileH / 4){ + tU=Math.floor(screenX / tTileW); + tV=Math.floor(screenY / tTileH)*2; + }else { + screenX=screenX-tTileW / 2; + tU=Math.floor(screenX / tTileW)+1; + screenY=screenY-tTileH / 2; + tV=Math.floor(screenY / tTileH)*2+1; + } + result.x=tU-(tV & 1); + result.y=tV; + } + return true; + break ; + case /*laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + tU=screenX / tTileW; + tV=screenY / tTileH; + if (result){ + result.x=tU; + result.y=tV; + } + return true; + break ; + case /*laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal":; + var tTileHeight=tTileH *2 / 3; + tV=screenY / tTileHeight; + tU=(screenX-tV % 2 *this._tileWidthHalf)/ tTileW; + if (result){ + result.x=tU; + result.y=tV; + } + break ; + } + return false; + } + + /** + *得到一个GridSprite + *@param gridX 当前Grid的X轴索引 + *@param gridY 当前Grid的Y轴索引 + *@return 一个GridSprite对象 + */ + __proto.getDrawSprite=function(gridX,gridY){ + var tSprite=new GridSprite(); + tSprite.relativeX=gridX *this._map.gridWidth; + tSprite.relativeY=gridY *this._map.gridHeight; + tSprite.initData(this._map); + this._gridSpriteArray.push(tSprite); + return tSprite; + } + + /** + *更新此层中块的坐标 + *手动刷新的目的是,保持层级的宽和高保持最小,加快渲染 + */ + __proto.updateGridPos=function(){ + var tSprite; + for (var i=0;i < this._gridSpriteArray.length;i++){ + tSprite=this._gridSpriteArray[i]; + if ((tSprite.visible || tSprite.isAloneObject)&& tSprite.drawImageNum > 0){ + tSprite.updatePos(); + } + } + } + + /** + *@private + *把tile画到指定的显示对象上 + *@param gridSprite 被指定显示的目标 + *@param tileX 格子的X轴坐标 + *@param tileY 格子的Y轴坐标 + *@return + */ + __proto.drawTileTexture=function(gridSprite,tileX,tileY){ + if (tileY >=0 && tileY < this._map.numRowsTile && tileX >=0 && tileX < this._map.numColumnsTile){ + var tIndex=tileY *this._map.numColumnsTile+tileX; + var tMapData=this._mapData; + if (tMapData !=null && tIndex < tMapData.length){ + if (tMapData[tIndex] !=0){ + var tTileTexSet=this._map.getTexture(tMapData[tIndex]); + if (tTileTexSet){ + var tX=0; + var tY=0; + var tTexture=tTileTexSet.texture; + switch (this._map.orientation){ + case /*laya.map.TiledMap.ORIENTATION_STAGGERED*/"staggered": + tX=tileX *this._map.tileWidth % this._map.gridWidth+(tileY & 1)*this._tileWidthHalf; + tY=tileY *this._tileHeightHalf % this._map.gridHeight; + break ; + case /*laya.map.TiledMap.ORIENTATION_ORTHOGONAL*/"orthogonal": + tX=tileX *this._map.tileWidth % this._map.gridWidth; + tY=tileY *this._map.tileHeight % this._map.gridHeight; + break ; + case /*laya.map.TiledMap.ORIENTATION_ISOMETRIC*/"isometric": + tX=(this._mapWidthHalf+(tileX-tileY)*this._tileWidthHalf)% this._map.gridWidth; + tY=((tileX+tileY)*this._tileHeightHalf)% this._map.gridHeight; + break ; + case /*laya.map.TiledMap.ORIENTATION_HEXAGONAL*/"hexagonal":; + var tTileHeight=this._map.tileHeight *2 / 3; + tX=(tileX *this._map.tileWidth+tileY % 2 *this._tileWidthHalf)% this._map.gridWidth; + tY=(tileY *tTileHeight)% this._map.gridHeight; + break ; + } + if (tTileTexSet.isAnimation){ + var tAnimationSprite=new TileAniSprite(); + tAnimationSprite.x=tX; + tAnimationSprite.y=tY; + tAnimationSprite.setTileTextureSet(tIndex.toString(),tTileTexSet); + gridSprite.addAniSprite(tAnimationSprite); + gridSprite.addChild(tAnimationSprite); + gridSprite.isHaveAnimation=true; + }else { + gridSprite.graphics.drawTexture(tTileTexSet.texture,tX+tTileTexSet.offX,tY+tTileTexSet.offY,tTexture.width,tTexture.height); + } + return true; + } + } + } + } + return false; + } + + /** + *@private + *清理当前对象 + */ + __proto.clearAll=function(){ + this._map=null; + this._mapData=null; + this._tileWidthHalf=0; + this._tileHeightHalf=0; + this._mapWidthHalf=0; + this._mapHeightHalf=0; + this.layerName=null; + var i=0; + if (this._objDic){ + for (var p in this._objDic){ + delete this._objDic[p]; + } + this._objDic=null; + }; + var tGridSprite; + for (i=0;i < this._gridSpriteArray.length;i++){ + tGridSprite=this._gridSpriteArray[i]; + tGridSprite.clearAll(); + } + this._properties=null; + this._tempMapPos=null; + } + + return MapLayer; + })(Sprite) + + + /** + *TildMap的动画显示对象(一个动画(TileTexSet),可以绑定多个动画显示对象(TileAniSprite)) + *@author ... + */ + //class laya.map.TileAniSprite extends laya.display.Sprite + var TileAniSprite=(function(_super){ + function TileAniSprite(){ + this._tileTextureSet=null; + this._aniName=null; + TileAniSprite.__super.call(this); + } + + __class(TileAniSprite,'laya.map.TileAniSprite',_super); + var __proto=TileAniSprite.prototype; + /** + *确定当前显示对象的名称以及属于哪个动画 + *@param aniName 当前动画显示对象的名字,名字唯一 + *@param tileTextureSet 当前显示对象属于哪个动画(一个动画,可以绑定多个同类显示对象) + */ + __proto.setTileTextureSet=function(aniName,tileTextureSet){ + this._aniName=aniName; + this._tileTextureSet=tileTextureSet; + tileTextureSet.addAniSprite(this._aniName,this); + } + + /** + *把当前动画加入到对应的动画刷新列表中 + */ + __proto.show=function(){ + this._tileTextureSet.addAniSprite(this._aniName,this); + } + + /** + *把当前动画从对应的动画刷新列表中移除 + */ + __proto.hide=function(){ + this._tileTextureSet.removeAniSprite(this._aniName); + } + + /** + *清理 + */ + __proto.clearAll=function(){ + this._tileTextureSet.removeAniSprite(this._aniName); + this.destroy(); + this._tileTextureSet=null; + this._aniName=null; + } + + return TileAniSprite; + })(Sprite) + + + Laya.__init([TiledMap]); +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.ui.js b/games/laya-snakes/libs/laya.ui.js new file mode 100644 index 0000000..df43ab1 --- /dev/null +++ b/games/laya-snakes/libs/laya.ui.js @@ -0,0 +1,8705 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + + var Animation=laya.display.Animation,ClassUtils=laya.utils.ClassUtils,ColorFilter=laya.filters.ColorFilter; + var Ease=laya.utils.Ease,Event=laya.events.Event,Font=laya.display.css.Font,FrameAnimation=laya.display.FrameAnimation; + var Graphics=laya.display.Graphics,Handler=laya.utils.Handler,Input=laya.display.Input,Loader=laya.net.Loader; + var Node=laya.display.Node,Point=laya.maths.Point,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render; + var Sprite=laya.display.Sprite,Stage=laya.display.Stage,Text=laya.display.Text,Texture=laya.resource.Texture; + var Tween=laya.utils.Tween,Utils=laya.utils.Utils; + Laya.interface('laya.ui.IItem'); + Laya.interface('laya.ui.IRender'); + Laya.interface('laya.ui.ISelect'); + Laya.interface('laya.ui.IComponent'); + Laya.interface('laya.ui.IBox','IComponent'); + /** + *LayoutStyle 是一个布局样式类。 + */ + //class laya.ui.LayoutStyle + var LayoutStyle=(function(){ + function LayoutStyle(){ + this.enable=false; + this.top=NaN; + this.bottom=NaN; + this.left=NaN; + this.right=NaN; + this.centerX=NaN; + this.centerY=NaN; + this.anchorX=NaN; + this.anchorY=NaN; + } + + __class(LayoutStyle,'laya.ui.LayoutStyle'); + __static(LayoutStyle, + ['EMPTY',function(){return this.EMPTY=new LayoutStyle();} + ]); + return LayoutStyle; + })() + + + /** + *Styles 定义了组件常用的样式属性。 + */ + //class laya.ui.Styles + var Styles=(function(){ + function Styles(){}; + __class(Styles,'laya.ui.Styles'); + Styles.labelColor="#000000"; + Styles.buttonStateNum=3; + Styles.scrollBarMinNum=15; + Styles.scrollBarDelayTime=500; + __static(Styles, + ['defaultSizeGrid',function(){return this.defaultSizeGrid=[4,4,4,4,0];},'labelPadding',function(){return this.labelPadding=[2,2,2,2];},'inputLabelPadding',function(){return this.inputLabelPadding=[1,1,1,3];},'buttonLabelColors',function(){return this.buttonLabelColors=["#32556b","#32cc6b","#ff0000","#C0C0C0"];},'comboBoxItemColors',function(){return this.comboBoxItemColors=["#5e95b6","#ffffff","#000000","#8fa4b1","#ffffff"];} + ]); + return Styles; + })() + + + /** + *UIUtils 是文本工具集。 + */ + //class laya.ui.UIUtils + var UIUtils=(function(){ + function UIUtils(){}; + __class(UIUtils,'laya.ui.UIUtils'); + UIUtils.fillArray=function(arr,str,type){ + var temp=arr.concat(); + if (str){ + var a=str.split(","); + for (var i=0,n=Math.min(temp.length,a.length);i < n;i++){ + var value=a[i]; + temp[i]=(value=="true" ? true :(value=="false" ? false :value)); + if (type !=null)temp[i]=type(value); + } + } + return temp; + } + + UIUtils.toColor=function(color){ + var str=color.toString("16"); + while (str.length < 6)str="0"+str; + return "#"+str; + } + + UIUtils.gray=function(traget,isGray){ + (isGray===void 0)&& (isGray=true); + if (isGray){ + UIUtils.addFilter(traget,UIUtils.grayFilter); + }else { + UIUtils.clearFilter(traget,ColorFilter); + } + } + + UIUtils.addFilter=function(target,filter){ + var filters=target.filters || []; + filters.push(filter); + target.filters=filters; + } + + UIUtils.clearFilter=function(target,filterType){ + var filters=target.filters; + if (filters !=null && filters.length > 0){ + for (var i=filters.length-1;i >-1;i--){ + var filter=filters[i]; + if (Laya.__typeof(filter,filterType))filters.splice(i,1); + } + target.filters=filters; + } + } + + __static(UIUtils, + ['grayFilter',function(){return this.grayFilter=new ColorFilter([0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0,0,0,1,0]);} + ]); + return UIUtils; + })() + + + /**全局配置*/ + //class UIConfig + var UIConfig=(function(){ + function UIConfig(){}; + __class(UIConfig,'UIConfig'); + UIConfig.touchScrollEnable=true; + UIConfig.mouseWheelEnable=true; + UIConfig.showButtons=true; + UIConfig.popupBgColor="#000000"; + UIConfig.popupBgAlpha=0.5; + return UIConfig; + })() + + + /** + *AutoBitmap 类是用于表示位图图像或绘制图形的显示对象。 + *

    封装了位置,宽高及九宫格的处理,供UI组件使用。

    + */ + //class laya.ui.AutoBitmap extends laya.display.Graphics + var AutoBitmap=(function(_super){ + function AutoBitmap(){ + this.autoCacheCmd=true; + this._width=0; + this._height=0; + this._source=null; + this._sizeGrid=null; + this._isChanged=false; + this._offset=null; + AutoBitmap.__super.call(this); + } + + __class(AutoBitmap,'laya.ui.AutoBitmap',_super); + var __proto=AutoBitmap.prototype; + /**@inheritDoc */ + __proto.destroy=function(){ + _super.prototype.destroy.call(this); + this._source=null; + this._sizeGrid=null; + this._offset=null; + } + + /**@private */ + __proto._setChanged=function(){ + if (!this._isChanged){ + this._isChanged=true; + Laya.timer.callLater(this,this.changeSource); + } + } + + /** + *@private + *修改纹理资源。 + */ + __proto.changeSource=function(){ + if (AutoBitmap.cacheCount++> 50)AutoBitmap.clearCache(); + this._isChanged=false; + var source=this._source; + if (!source || !source.bitmap)return; + var width=this.width; + var height=this.height; + var sizeGrid=this._sizeGrid; + var sw=source.sourceWidth; + var sh=source.sourceHeight; + if (!sizeGrid || (sw===width && sh===height)){ + this.cleanByTexture(source,this._offset ? this._offset[0] :0,this._offset ? this._offset[1] :0,width,height); + }else { + source.$_GID || (source.$_GID=Utils.getGID()); + var key=source.$_GID+"."+width+"."+height+"."+sizeGrid.join("."); + if (AutoBitmap.cmdCaches[key]){ + this.cmds=AutoBitmap.cmdCaches[key]; + return; + } + this.clear(); + var top=sizeGrid[0]; + var right=sizeGrid[1]; + var bottom=sizeGrid[2]; + var left=sizeGrid[3]; + var repeat=sizeGrid[4]; + if (left+right > width){ + right=0; + } + left && top && this.drawTexture(AutoBitmap.getTexture(source,0,0,left,top),0,0,left,top); + right && top && this.drawTexture(AutoBitmap.getTexture(source,sw-right,0,right,top),width-right,0,right,top); + left && bottom && this.drawTexture(AutoBitmap.getTexture(source,0,sh-bottom,left,bottom),0,height-bottom,left,bottom); + right && bottom && this.drawTexture(AutoBitmap.getTexture(source,sw-right,sh-bottom,right,bottom),width-right,height-bottom,right,bottom); + top && this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,0,sw-left-right,top),left,0,width-left-right,top); + bottom && this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,sh-bottom,sw-left-right,bottom),left,height-bottom,width-left-right,bottom); + left && this.drawBitmap(repeat,AutoBitmap.getTexture(source,0,top,left,sh-top-bottom),0,top,left,height-top-bottom); + right && this.drawBitmap(repeat,AutoBitmap.getTexture(source,sw-right,top,right,sh-top-bottom),width-right,top,right,height-top-bottom); + this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,top,sw-left-right,sh-top-bottom),left,top,width-left-right,height-top-bottom); + if (this.autoCacheCmd && !Render.isConchApp)AutoBitmap.cmdCaches[key]=this.cmds; + } + this._repaint(); + } + + __proto.drawBitmap=function(repeat,tex,x,y,width,height){ + (width===void 0)&& (width=0); + (height===void 0)&& (height=0); + if (repeat)this.fillTexture(tex,x,y,width,height); + else this.drawTexture(tex,x,y,width,height); + } + + /** + *当前实例的有效缩放网格数据。 + *

    如果设置为null,则在应用任何缩放转换时,将正常缩放整个显示对象。

    + *

    数据格式:[上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)]。 + *

    • 例如:[4,4,4,4,1]

    + *

    sizeGrid 的值如下所示: + *

      + *
    1. 上边距
    2. + *
    3. 右边距
    4. + *
    5. 下边距
    6. + *
    7. 左边距
    8. + *
    9. 是否重复填充(值为0:不重复填充,1:重复填充)
    10. + *

    + *

    当定义 sizeGrid 属性时,该显示对象被分割到以 sizeGrid 数据中的"上边距,右边距,下边距,左边距" 组成的矩形为基础的具有九个区域的网格中,该矩形定义网格的中心区域。网格的其它八个区域如下所示: + *

      + *
    • 矩形上方的区域
    • + *
    • 矩形外的右上角
    • + *
    • 矩形左侧的区域
    • + *
    • 矩形右侧的区域
    • + *
    • 矩形外的左下角
    • + *
    • 矩形下方的区域
    • + *
    • 矩形外的右下角
    • + *
    • 矩形外的左上角
    • + *
    + *同时也支持3宫格,比如0,4,0,4,1为水平3宫格,4,0,4,0,1为垂直3宫格,3宫格性能比9宫格高。 + *

    + */ + __getset(0,__proto,'sizeGrid',function(){ + return this._sizeGrid; + },function(value){ + this._sizeGrid=value; + this._setChanged(); + }); + + /** + *表示显示对象的宽度,以像素为单位。 + */ + __getset(0,__proto,'width',function(){ + if (this._width)return this._width; + if (this._source)return this._source.sourceWidth; + return 0; + },function(value){ + if (this._width !=value){ + this._width=value; + this._setChanged(); + } + }); + + /** + *表示显示对象的高度,以像素为单位。 + */ + __getset(0,__proto,'height',function(){ + if (this._height)return this._height; + if (this._source)return this._source.sourceHeight; + return 0; + },function(value){ + if (this._height !=value){ + this._height=value; + this._setChanged(); + } + }); + + /** + *对象的纹理资源。 + *@see laya.resource.Texture + */ + __getset(0,__proto,'source',function(){ + return this._source; + },function(value){ + if (value){ + this._source=value + this._setChanged(); + }else { + this._source=null; + this.clear(); + } + }); + + AutoBitmap.getTexture=function(tex,x,y,width,height){ + if (width <=0)width=1; + if (height <=0)height=1; + tex.$_GID || (tex.$_GID=Utils.getGID()) + var key=tex.$_GID+"."+x+"."+y+"."+width+"."+height; + var texture=AutoBitmap.textureCache[key]; + if (!texture){ + texture=AutoBitmap.textureCache[key]=Texture.createFromTexture(tex,x,y,width,height); + } + return texture; + } + + AutoBitmap.clearCache=function(){ + AutoBitmap.cacheCount=0; + AutoBitmap.cmdCaches={}; + AutoBitmap.textureCache={}; + } + + AutoBitmap.setCache=function(key,value){ + AutoBitmap.cacheCount++; + AutoBitmap.textureCache[key]=value; + } + + AutoBitmap.getCache=function(key){ + return AutoBitmap.textureCache[key]; + } + + AutoBitmap.cmdCaches={}; + AutoBitmap.cacheCount=0; + AutoBitmap.textureCache={}; + return AutoBitmap; + })(Graphics) + + + /** + *UIEvent 类用来定义UI组件类的事件类型。 + */ + //class laya.ui.UIEvent extends laya.events.Event + var UIEvent=(function(_super){ + function UIEvent(){UIEvent.__super.call(this);; + }; + + __class(UIEvent,'laya.ui.UIEvent',_super); + UIEvent.SHOW_TIP="showtip"; + UIEvent.HIDE_TIP="hidetip"; + return UIEvent; + })(Event) + + + /** + *Component 是ui控件类的基类。 + *

    生命周期:preinitialize > createChildren > initialize > 组件构造函数

    + */ + //class laya.ui.Component extends laya.display.Sprite + var Component=(function(_super){ + function Component(){ + this._comXml=null; + this._dataSource=null; + this._toolTip=null; + this._tag=null; + this._disabled=false; + this._gray=false; + Component.__super.call(this); + this._layout=LayoutStyle.EMPTY; + this.preinitialize(); + this.createChildren(); + this.initialize(); + } + + __class(Component,'laya.ui.Component',_super); + var __proto=Component.prototype; + Laya.imps(__proto,{"laya.ui.IComponent":true}) + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._dataSource=this._layout=null; + this._tag=null; + this._toolTip=null; + } + + /** + *

    预初始化。

    + *@internal 子类可在此函数内设置、修改属性默认值 + */ + __proto.preinitialize=function(){} + /** + *

    创建并添加控件子节点。

    + *@internal 子类可在此函数内创建并添加子节点。 + */ + __proto.createChildren=function(){} + /** + *

    控件初始化。

    + *@internal 在此子对象已被创建,可以对子对象进行修改。 + */ + __proto.initialize=function(){} + /** + *

    延迟运行指定的函数。

    + *

    在控件被显示在屏幕之前调用,一般用于延迟计算数据。

    + *@param method 要执行的函数的名称。例如,functionName。 + *@param args 传递给 method 函数的可选参数列表。 + * + *@see #runCallLater() + */ + __proto.callLater=function(method,args){ + Laya.timer.callLater(this,method,args); + } + + /** + *

    如果有需要延迟调用的函数(通过 callLater 函数设置),则立即执行延迟调用函数。

    + *@param method 要执行的函数名称。例如,functionName。 + *@see #callLater() + */ + __proto.runCallLater=function(method){ + Laya.timer.runCallLater(this,method); + } + + /** + *

    立即执行影响宽高度量的延迟调用函数。

    + *@internal

    使用 runCallLater 函数,立即执行影响宽高度量的延迟运行函数(使用 callLater 设置延迟执行函数)。

    + *@see #callLater() + *@see #runCallLater() + */ + __proto.commitMeasure=function(){} + /** + *

    重新调整对象的大小。

    + */ + __proto.changeSize=function(){ + this.event(/*laya.events.Event.RESIZE*/"resize"); + } + + /** + *@private + *

    获取对象的布局样式。

    + */ + __proto.getLayout=function(){ + this._layout===LayoutStyle.EMPTY && (this._layout=new LayoutStyle()); + return this._layout; + } + + /** + *对象从显示列表移除的事件侦听处理函数。 + */ + __proto.onRemoved=function(){ + this.parent.off(/*laya.events.Event.RESIZE*/"resize",this,this.onCompResize); + } + + /** + *对象被添加到显示列表的事件侦听处理函数。 + */ + __proto.onAdded=function(){ + this.parent.on(/*laya.events.Event.RESIZE*/"resize",this,this.onCompResize); + this.resetLayoutX(); + this.resetLayoutY(); + } + + /** + *父容器的 Event.RESIZE 事件侦听处理函数。 + */ + __proto.onCompResize=function(){ + if (this._layout && this._layout.enable){ + this.resetLayoutX(); + this.resetLayoutY(); + } + } + + /** + *

    重置对象的 X 轴(水平方向)布局。

    + */ + __proto.resetLayoutX=function(){ + var layout=this._layout; + if (!isNaN(layout.anchorX))this.pivotX=layout.anchorX *this.width; + var parent=this.parent; + if (parent){ + if (!isNaN(layout.centerX)){ + this.x=(parent.width-this.displayWidth)*0.5+layout.centerX+this.pivotX *this.scaleX; + }else if (!isNaN(layout.left)){ + this.x=layout.left+this.pivotX *this.scaleX; + if (!isNaN(layout.right)){ + this.width=(parent._width-layout.left-layout.right)/ this.scaleX; + } + }else if (!isNaN(layout.right)){ + this.x=parent.width-this.displayWidth-layout.right+this.pivotX *this.scaleX; + } + } + } + + /** + *

    重置对象的 Y 轴(垂直方向)布局。

    + */ + __proto.resetLayoutY=function(){ + var layout=this._layout; + if (!isNaN(layout.anchorY))this.pivotY=layout.anchorY *this.height; + var parent=this.parent; + if (parent){ + if (!isNaN(layout.centerY)){ + this.y=(parent.height-this.displayHeight)*0.5+layout.centerY+this.pivotY *this.scaleY; + }else if (!isNaN(layout.top)){ + this.y=layout.top+this.pivotY *this.scaleY; + if (!isNaN(layout.bottom)){ + this.height=(parent._height-layout.top-layout.bottom)/ this.scaleY; + } + }else if (!isNaN(layout.bottom)){ + this.y=parent.height-this.displayHeight-layout.bottom+this.pivotY *this.scaleY; + } + } + } + + /** + *对象的 Event.MOUSE_OVER 事件侦听处理函数。 + */ + __proto.onMouseOver=function(e){ + Laya.stage.event(/*laya.ui.UIEvent.SHOW_TIP*/"showtip",this._toolTip); + } + + /** + *对象的 Event.MOUSE_OUT 事件侦听处理函数。 + */ + __proto.onMouseOut=function(e){ + Laya.stage.event(/*laya.ui.UIEvent.HIDE_TIP*/"hidetip",this._toolTip); + } + + /** + *

    对象的显示宽度(以像素为单位)。

    + */ + __getset(0,__proto,'displayWidth',function(){ + return this.width *this.scaleX; + }); + + /** + *

    表示显示对象的宽度,以像素为单位。

    + *

    注:当值为0时,宽度为自适应大小。

    + */ + __getset(0,__proto,'width',function(){ + if (this._width)return this._width; + return this.measureWidth; + },function(value){ + if (this._width !=value){ + this._width=value; + this.model && this.model.size(this._width,this._height); + this.callLater(this.changeSize); + if (this._layout.enable && (!isNaN(this._layout.centerX)|| !isNaN(this._layout.right)|| !isNaN(this._layout.anchorX)))this.resetLayoutX(); + } + }); + + /** + *

    显示对象的实际显示区域宽度(以像素为单位)。

    + */ + __getset(0,__proto,'measureWidth',function(){ + var max=0; + this.commitMeasure(); + for (var i=this.numChildren-1;i >-1;i--){ + var comp=this.getChildAt(i); + if (comp.visible){ + max=Math.max(comp.x+comp.width *comp.scaleX,max); + } + } + return max; + }); + + /** + *@private + *

    指定对象是否可使用布局。

    + *

    如果值为true,则此对象可以使用布局样式,否则不使用布局样式。

    + *@param value 一个 Boolean 值,指定对象是否可使用布局。 + */ + __getset(0,__proto,'layOutEabled',null,function(value){ + if (this._layout && this._layout.enable !=value){ + this._layout.enable=value; + if (this.parent){ + this.onAdded(); + }else { + this.on(/*laya.events.Event.ADDED*/"added",this,this.onAdded); + this.on(/*laya.events.Event.REMOVED*/"removed",this,this.onRemoved); + } + } + }); + + /** + *

    对象的显示高度(以像素为单位)。

    + */ + __getset(0,__proto,'displayHeight',function(){ + return this.height *this.scaleY; + }); + + /** + *

    表示显示对象的高度,以像素为单位。

    + *

    注:当值为0时,高度为自适应大小。

    + *@return + */ + __getset(0,__proto,'height',function(){ + if (this._height)return this._height; + return this.measureHeight; + },function(value){ + if (this._height !=value){ + this._height=value; + this.model && this.model.size(this._width,this._height); + this.callLater(this.changeSize); + if (this._layout.enable && (!isNaN(this._layout.centerY)|| !isNaN(this._layout.bottom)|| !isNaN(this._layout.anchorY)))this.resetLayoutY(); + } + }); + + /** + *

    数据赋值,通过对UI赋值来控制UI显示逻辑。

    + *

    简单赋值会更改组件的默认属性,使用大括号可以指定组件的任意属性进行赋值。

    + *@example 以下示例中, label1、checkbox1 分别为示例的name属性值。 + + //默认属性赋值 + dataSource={label1:"改变了label",checkbox1:true};//(更改了label1的text属性值,更改checkbox1的selected属性)。 + //任意属性赋值 + dataSource={label2:{text:"改变了label",size:14},checkbox2:{selected:true,x:10}}; + + *@return + */ + __getset(0,__proto,'dataSource',function(){ + return this._dataSource; + },function(value){ + this._dataSource=value; + for (var prop in this._dataSource){ + if (this.hasOwnProperty(prop)){ + this[prop]=this._dataSource[prop]; + } + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'scaleY',_super.prototype._$get_scaleY,function(value){ + if (_super.prototype._$get_scaleY.call(this)!=value){ + _super.prototype._$set_scaleY.call(this,value); + this.callLater(this.changeSize); + this._layout.enable && this.resetLayoutY(); + } + }); + + /** + *

    显示对象的实际显示区域高度(以像素为单位)。

    + */ + __getset(0,__proto,'measureHeight',function(){ + var max=0; + this.commitMeasure(); + for (var i=this.numChildren-1;i >-1;i--){ + var comp=this.getChildAt(i); + if (comp.visible){ + max=Math.max(comp.y+comp.height *comp.scaleY,max); + } + } + return max; + }); + + /**@inheritDoc */ + __getset(0,__proto,'scaleX',_super.prototype._$get_scaleX,function(value){ + if (_super.prototype._$get_scaleX.call(this)!=value){ + _super.prototype._$set_scaleX.call(this,value); + this.callLater(this.changeSize); + this._layout.enable && this.resetLayoutX(); + } + }); + + /** + *

    从组件顶边到其内容区域顶边之间的垂直距离(以像素为单位)。

    + */ + __getset(0,__proto,'top',function(){ + return this._layout.top; + },function(value){ + this.getLayout().top=value; + this.layOutEabled=true; + this.resetLayoutY(); + }); + + /** + *

    从组件底边到其内容区域底边之间的垂直距离(以像素为单位)。

    + */ + __getset(0,__proto,'bottom',function(){ + return this._layout.bottom; + },function(value){ + this.getLayout().bottom=value; + this.layOutEabled=true; + this.resetLayoutY(); + }); + + /** + *

    从组件左边到其内容区域左边之间的水平距离(以像素为单位)。

    + */ + __getset(0,__proto,'left',function(){ + return this._layout.left; + },function(value){ + this.getLayout().left=value; + this.layOutEabled=true; + this.resetLayoutX(); + }); + + /** + *

    从组件右边到其内容区域右边之间的水平距离(以像素为单位)。

    + */ + __getset(0,__proto,'right',function(){ + return this._layout.right; + },function(value){ + this.getLayout().right=value; + this.layOutEabled=true; + this.resetLayoutX(); + }); + + /** + *

    在父容器中,此对象的水平方向中轴线与父容器的水平方向中心线的距离(以像素为单位)。

    + */ + __getset(0,__proto,'centerX',function(){ + return this._layout.centerX; + },function(value){ + this.getLayout().centerX=value; + this.layOutEabled=true; + this.resetLayoutX(); + }); + + /** + *

    在父容器中,此对象的垂直方向中轴线与父容器的垂直方向中心线的距离(以像素为单位)。

    + */ + __getset(0,__proto,'centerY',function(){ + return this._layout.centerY; + },function(value){ + this.getLayout().centerY=value; + this.layOutEabled=true; + this.resetLayoutY(); + }); + + /**X轴锚点,值为0-1*/ + __getset(0,__proto,'anchorX',function(){ + return this._layout.anchorX; + },function(value){ + this.getLayout().anchorX=value; + this.layOutEabled=true; + this.resetLayoutX(); + }); + + /**Y轴锚点,值为0-1*/ + __getset(0,__proto,'anchorY',function(){ + return this._layout.anchorY; + },function(value){ + this.getLayout().anchorY=value; + this.layOutEabled=true; + this.resetLayoutY(); + }); + + /** + *

    对象的标签。

    + *@internal 冗余字段,可以用来储存数据。 + */ + __getset(0,__proto,'tag',function(){ + return this._tag; + },function(value){ + this._tag=value; + }); + + /** + *

    鼠标悬停提示。

    + *

    可以赋值为文本 String 或函数 Handler ,用来实现自定义样式的鼠标提示和参数携带等。

    + *@example 以下例子展示了三种鼠标提示: + + private var _testTips:TestTipsUI=new TestTipsUI(); + private function testTips():void { + //简单鼠标提示 + btn2.toolTip="这里是鼠标提示<b>粗体</b><br>换行"; + //自定义的鼠标提示 + btn1.toolTip=showTips1; + //带参数的自定义鼠标提示 + clip.toolTip=new Handler(this,showTips2,["clip"]); + } + + private function showTips1():void { + _testTips.label.text="这里是按钮["+btn1.label+"]"; + tip.addChild(_testTips); + } + + private function showTips2(name:String):void { + _testTips.label.text="这里是"+name; + tip.addChild(_testTips); + } + + + */ + __getset(0,__proto,'toolTip',function(){ + return this._toolTip; + },function(value){ + if (this._toolTip !=value){ + this._toolTip=value; + if (value !=null){ + this.on(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouseOver); + this.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouseOut); + }else { + this.off(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouseOver); + this.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouseOut); + } + } + }); + + /** + *XML 数据。 + */ + __getset(0,__proto,'comXml',function(){ + return this._comXml; + },function(value){ + this._comXml=value; + }); + + /**是否变灰。*/ + __getset(0,__proto,'gray',function(){ + return this._gray; + },function(value){ + if (value!==this._gray){ + this._gray=value; + UIUtils.gray(this,value); + } + }); + + /**是否禁用页面,设置为true后,会变灰并且禁用鼠标。*/ + __getset(0,__proto,'disabled',function(){ + return this._disabled; + },function(value){ + if (value!==this._disabled){ + this.gray=this._disabled=value; + this.mouseEnabled=!value; + } + }); + + return Component; + })(Sprite) + + + /** + *Box 类是一个控件容器类。 + */ + //class laya.ui.Box extends laya.ui.Component + var Box=(function(_super){ + function Box(){Box.__super.call(this);; + }; + + __class(Box,'laya.ui.Box',_super); + var __proto=Box.prototype; + Laya.imps(__proto,{"laya.ui.IBox":true}) + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + for (var name in value){ + var comp=this.getChildByName(name); + if (comp)comp.dataSource=value[name]; + else if (this.hasOwnProperty(name))this[name]=value[name]; + } + }); + + return Box; + })(Component) + + + /** + *Button 组件用来表示常用的多态按钮。 Button 组件可显示文本标签、图标或同时显示两者。 * + *

    可以是单态,两态和三态,默认三态(up,over,down)。

    + * + *@example 以下示例代码,创建了一个 Button 实例。 + *+ *package + *{ + *import laya.ui.Button; + *import laya.utils.Handler; + *public class Button_Example + *{ + *public function Button_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *trace("资源加载完成!"); + *var button:Button=new Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,并传入它的皮肤。 + *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。 + *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。 + *button.clickHandler=new Handler(this,onClickButton,[button]);//设置 button 的点击事件处理器。 + *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。 + *} + *private function onClickButton(button:Button):void + *{ + *trace("按钮button被点击了!"); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *function loadComplete() + *{ + *console.log("资源加载完成!"); + *var button=new laya.ui.Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,传入它的皮肤skin和标签label。 + *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。 + *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。 + *button.clickHandler=laya.utils.Handler.create(this,onClickButton,[button],false);//设置 button 的点击事件处理函数。 + *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。 + *} + *function onClickButton(button) + *{ + *console.log("按钮被点击了。",button); + *} + * + *+ *import Button=laya.ui.Button; + *import Handler=laya.utils.Handler; + *class Button_Example{ + *constructor() + *{ + *Laya.init(640,800); + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete() + *{ + *var button:Button=new Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,并传入它的皮肤。 + *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。 + *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。 + *button.clickHandler=new Handler(this,this.onClickButton,[button]);//设置 button 的点击事件处理器。 + *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。 + *} + *private onClickButton(button:Button):void + *{ + *console.log("按钮button被点击了!") + *} + *} + * + */ + //class laya.ui.Button extends laya.ui.Component + var Button=(function(_super){ + function Button(skin,label){ + this.toggle=false; + this._bitmap=null; + this._text=null; + this._strokeColors=null; + this._state=0; + this._selected=false; + this._skin=null; + this._autoSize=true; + this._sources=null; + this._clickHandler=null; + this._stateChanged=false; + Button.__super.call(this); + this._labelColors=Styles.buttonLabelColors; + this._stateNum=Styles.buttonStateNum; + (label===void 0)&& (label=""); + this.skin=skin; + this.label=label; + } + + __class(Button,'laya.ui.Button',_super); + var __proto=Button.prototype; + Laya.imps(__proto,{"laya.ui.ISelect":true}) + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._bitmap && this._bitmap.destroy(); + this._text && this._text.destroy(destroyChild); + this._bitmap=null; + this._text=null; + this._clickHandler=null; + this._labelColors=this._sources=this._strokeColors=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.graphics=this._bitmap=new AutoBitmap(); + } + + /**@private */ + __proto.createText=function(){ + if (!this._text){ + this._text=new Text(); + this._text.overflow=Text.HIDDEN; + this._text.align="center"; + this._text.valign="middle"; + } + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this.on(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouse); + this.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouse); + this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onMouse); + this.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onMouse); + this.on(/*laya.events.Event.CLICK*/"click",this,this.onMouse); + } + + /** + *对象的 Event.MOUSE_OVER、Event.MOUSE_OUT、Event.MOUSE_DOWN、Event.MOUSE_UP、Event.CLICK 事件侦听处理函数。 + *@param e Event 对象。 + */ + __proto.onMouse=function(e){ + if (this.toggle===false && this._selected)return; + if (e.type===/*laya.events.Event.CLICK*/"click"){ + this.toggle && (this.selected=!this._selected); + this._clickHandler && this._clickHandler.run(); + return; + } + !this._selected && (this.state=Button.stateMap[e.type]); + } + + /** + *@private + *对象的资源切片发生改变。 + */ + __proto.changeClips=function(){ + var img=Loader.getRes(this._skin); + if (!img){ + console.log("lose skin",this._skin); + return; + }; + var width=img.sourceWidth; + var height=img.sourceHeight / this._stateNum; + var key=this._skin+this._stateNum; + var clips=AutoBitmap.getCache(key); + if (clips)this._sources=clips; + else { + this._sources=[]; + if (this._stateNum===1){ + this._sources.push(img); + }else { + for (var i=0;i < this._stateNum;i++){ + this._sources.push(Texture.createFromTexture(img,0,height *i,width,height)); + } + } + AutoBitmap.setCache(key,this._sources); + } + if (this._autoSize){ + this._bitmap.width=this._width || width; + this._bitmap.height=this._height || height; + if (this._text){ + this._text.width=this._bitmap.width; + this._text.height=this._bitmap.height; + } + }else { + this._text && (this._text.x=width); + } + } + + /** + *@private + *改变对象的状态。 + */ + __proto.changeState=function(){ + this._stateChanged=false; + this.runCallLater(this.changeClips); + var index=this._state < this._stateNum ? this._state :this._stateNum-1; + this._sources && (this._bitmap.source=this._sources[index]); + if (this.label){ + this._text.color=this._labelColors[index]; + if (this._strokeColors)this._text.strokeColor=this._strokeColors[index]; + } + } + + /**@private */ + __proto._setStateChanged=function(){ + if (!this._stateChanged){ + this._stateChanged=true; + this.callLater(this.changeState); + } + } + + /** + *

    描边颜色,以字符串表示。

    + *默认值为 "#000000"(黑色); + *@see laya.display.Text.strokeColor() + */ + __getset(0,__proto,'labelStrokeColor',function(){ + this.createText(); + return this._text.strokeColor; + },function(value){ + this.createText(); + this._text.strokeColor=value + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'measureHeight',function(){ + this.runCallLater(this.changeClips); + return this._text ? Math.max(this._bitmap.height,this._text.height):this._bitmap.height; + }); + + /** + *

    对象的皮肤资源地址。

    + *支持单态,两态和三态,用 stateNum 属性设置 + *

    对象的皮肤地址,以字符串表示。

    + *@see #stateNum + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this.callLater(this.changeClips); + this._setStateChanged(); + } + }); + + /** + *对象的状态值。 + *@see #stateMap + */ + __getset(0,__proto,'state',function(){ + return this._state; + },function(value){ + if (this._state !=value){ + this._state=value; + this._setStateChanged(); + } + }); + + /** + *按钮文本标签 Text 控件。 + */ + __getset(0,__proto,'text',function(){ + this.createText(); + return this._text; + }); + + /** + *

    指定对象的状态值,以数字表示。

    + *

    默认值为3。此值决定皮肤资源图片的切割方式。

    + *

    取值: + *

  • 1:单态。图片不做切割,按钮的皮肤状态只有一种。
  • + *
  • 2:两态。图片将以竖直方向被等比切割为2部分,从上向下,依次为 + *弹起状态皮肤、 + *按下和经过及选中状态皮肤。
  • + *
  • 3:三态。图片将以竖直方向被等比切割为2部分,从上向下,依次为 + *弹起状态皮肤、 + *经过状态皮肤、 + *按下和选中状态皮肤
  • + *

    + */ + __getset(0,__proto,'stateNum',function(){ + return this._stateNum; + },function(value){ + if (this._stateNum !=value){ + this._stateNum=value < 1 ? 1 :value > 3 ? 3 :value; + this.callLater(this.changeClips); + } + }); + + /** + *表示按钮各个状态下的描边颜色。 + *

    格式: "upColor,overColor,downColor,disableColor"。

    + */ + __getset(0,__proto,'strokeColors',function(){ + return this._strokeColors ? this._strokeColors.join(","):""; + },function(value){ + this._strokeColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String); + this._setStateChanged(); + }); + + /** + *表示按钮各个状态下的文本颜色。 + *

    格式: "upColor,overColor,downColor,disableColor"。

    + */ + __getset(0,__proto,'labelColors',function(){ + return this._labelColors.join(","); + },function(value){ + this._labelColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String); + this._setStateChanged(); + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'measureWidth',function(){ + this.runCallLater(this.changeClips); + if (this._autoSize)return this._bitmap.width; + this.runCallLater(this.changeState); + return this._bitmap.width+(this._text ? this._text.width :0); + }); + + /** + *按钮的文本内容。 + */ + __getset(0,__proto,'label',function(){ + return this._text ? this._text.text :null; + },function(value){ + if (!this._text && !value)return; + this.createText(); + if (this._text.text !=value){ + value && !this._text.displayedInStage && this.addChild(this._text); + this._text.text=(value+"").replace(/\\n/g,"\n"); + this._setStateChanged(); + } + }); + + /** + *表示按钮的选中状态。 + *

    如果值为true,表示该对象处于选中状态。否则该对象处于未选中状态。

    + */ + __getset(0,__proto,'selected',function(){ + return this._selected; + },function(value){ + if (this._selected !=value){ + this._selected=value; + this.state=this._selected ? 2 :0; + this.event(/*laya.events.Event.CHANGE*/"change"); + } + }); + + /** + *表示按钮文本标签的边距。 + *

    格式:"上边距,右边距,下边距,左边距"。

    + */ + __getset(0,__proto,'labelPadding',function(){ + this.createText(); + return this._text.padding.join(","); + },function(value){ + this.createText(); + this._text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number); + }); + + /** + *表示按钮文本标签的字体大小。 + *@see laya.display.Text.fontSize() + */ + __getset(0,__proto,'labelSize',function(){ + this.createText(); + return this._text.fontSize; + },function(value){ + this.createText(); + this._text.fontSize=value + }); + + /** + *

    描边宽度(以像素为单位)。

    + *默认值0,表示不描边。 + *@see laya.display.Text.stroke() + */ + __getset(0,__proto,'labelStroke',function(){ + this.createText(); + return this._text.stroke; + },function(value){ + this.createText(); + this._text.stroke=value + }); + + /** + *表示按钮文本标签是否为粗体字。 + *@see laya.display.Text.bold() + */ + __getset(0,__proto,'labelBold',function(){ + this.createText(); + return this._text.bold; + },function(value){ + this.createText(); + this._text.bold=value; + }); + + /** + *表示按钮文本标签的字体名称,以字符串形式表示。 + *@see laya.display.Text.font() + */ + __getset(0,__proto,'labelFont',function(){ + this.createText(); + return this._text.font; + },function(value){ + this.createText(); + this._text.font=value; + }); + + /**标签对齐模式,默认为居中对齐。*/ + __getset(0,__proto,'labelAlign',function(){ + this.createText() + return this._text.align; + },function(value){ + this.createText() + this._text.align=value; + }); + + /** + *对象的点击事件处理器函数(无默认参数)。 + */ + __getset(0,__proto,'clickHandler',function(){ + return this._clickHandler; + },function(value){ + this._clickHandler=value; + }); + + /** + *

    当前实例的位图 AutoImage 实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(","); + return null; + },function(value){ + this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number); + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + if (this._autoSize){ + this._bitmap.width=value; + this._text && (this._text.width=value); + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + if (this._autoSize){ + this._bitmap.height=value; + this._text && (this._text.height=value); + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='number')|| (typeof value=='string'))this.label=value+""; + else _super.prototype._$set_dataSource.call(this,value); + }); + + /**图标x,y偏移,格式:100,100*/ + __getset(0,__proto,'iconOffset',function(){ + return this._bitmap._offset ? null :this._bitmap._offset.join(","); + },function(value){ + if (value)this._bitmap._offset=UIUtils.fillArray([1,1],value,Number); + else this._bitmap._offset=[]; + }); + + __static(Button, + ['stateMap',function(){return this.stateMap={"mouseup":0,"mouseover":1,"mousedown":2,"mouseout":0};} + ]); + return Button; + })(Component) + + + /** + *

    Clip 类是位图切片动画。

    + *

    Clip 可将一张图片,按横向分割数量 clipX 、竖向分割数量 clipY , + *或横向分割每个切片的宽度 clipWidth 、竖向分割每个切片的高度 clipHeight , + *从左向右,从上到下,分割组合为一个切片动画。

    + * + *@example 以下示例代码,创建了一个 Clip 实例。 + *+ *package + *{ + *import laya.ui.Clip; + *public class Clip_Example + *{ + *private var clip:Clip; + *public function Clip_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *private function onInit():void + *{ + *clip=new Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。 + *clip.autoPlay=true;//设置 clip 动画自动播放。 + *clip.interval=100;//设置 clip 动画的播放时间间隔。 + *clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。 + *clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。 + *clip.on(Event.CLICK,this,onClick);//给 clip 添加点击事件函数侦听。 + *Laya.stage.addChild(clip);//将此 clip 对象添加到显示列表。 + *} + *private function onClick():void + *{ + *trace("clip 的点击事件侦听处理函数。clip.total="+clip.total); + *if (clip.isPlaying==true) + *{ + *clip.stop();//停止动画。 + *}else { + *clip.play();//播放动画。 + *} + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var clip; + *Laya.loader.load("resource/ui/clip_num.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *function loadComplete(){ + *console.log("资源加载完成!"); + *clip=new laya.ui.Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。 + *clip.autoPlay=true;//设置 clip 动画自动播放。 + *clip.interval=100;//设置 clip 动画的播放时间间隔。 + *clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。 + *clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。 + *clip.on(Event.CLICK,this,onClick);//给 clip 添加点击事件函数侦听。 + *Laya.stage.addChild(clip);//将此 clip 对象添加到显示列表。 + *} + *function onClick() + *{ + *console.log("clip 的点击事件侦听处理函数。"); + *if(clip.isPlaying==true) + *{ + *clip.stop(); + *}else { + *clip.play(); + *} + *} + * + *+ *import Clip=laya.ui.Clip; + *import Handler=laya.utils.Handler; + *class Clip_Example { + *private clip:Clip; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.onInit(); + *} + *private onInit():void { + *this.clip=new Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。 + *this.clip.autoPlay=true;//设置 clip 动画自动播放。 + *this.clip.interval=100;//设置 clip 动画的播放时间间隔。 + *this.clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。 + *this.clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。 + *this.clip.on(laya.events.Event.CLICK,this,this.onClick);//给 clip 添加点击事件函数侦听。 + *Laya.stage.addChild(this.clip);//将此 clip 对象添加到显示列表。 + *} + *private onClick():void { + *console.log("clip 的点击事件侦听处理函数。clip.total="+this.clip.total); + *if (this.clip.isPlaying==true){ + *this.clip.stop();//停止动画。 + *}else { + *this.clip.play();//播放动画。 + *} + *} + *} + * + * + */ + //class laya.ui.Clip extends laya.ui.Component + var Clip=(function(_super){ + function Clip(url,clipX,clipY){ + this._sources=null; + this._bitmap=null; + this._skin=null; + this._clipX=1; + this._clipY=1; + this._clipWidth=0; + this._clipHeight=0; + this._autoPlay=false; + this._interval=50; + this._complete=null; + this._isPlaying=false; + this._index=0; + this._clipChanged=false; + this._group=null; + Clip.__super.call(this); + (clipX===void 0)&& (clipX=1); + (clipY===void 0)&& (clipY=1); + this._clipX=clipX; + this._clipY=clipY; + this.skin=url; + } + + __class(Clip,'laya.ui.Clip',_super); + var __proto=Clip.prototype; + /**@inheritDoc */ + __proto.destroy=function(clearFromCache){ + (clearFromCache===void 0)&& (clearFromCache=false); + _super.prototype.destroy.call(this,true); + this._bitmap && this._bitmap.destroy(); + this._bitmap=null; + this._sources=null; + } + + /** + *销毁对象并释放加载的皮肤资源。 + */ + __proto.dispose=function(){ + this.destroy(true); + Laya.loader.clearRes(this._skin); + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.graphics=this._bitmap=new AutoBitmap(); + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this.on(/*laya.events.Event.DISPLAY*/"display",this,this._onDisplay); + this.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onDisplay); + } + + /**@private */ + __proto._onDisplay=function(e){ + if (this._isPlaying){ + if (this._displayedInStage)this.play(); + else this.stop(); + }else if (this._autoPlay && this._displayedInStage){ + this.play(); + } + } + + /** + *@private + *改变切片的资源、切片的大小。 + */ + __proto.changeClip=function(){ + this._clipChanged=false; + if (!this._skin)return; + var img=Loader.getRes(this._skin); + if (img){ + this.loadComplete(this._skin,img); + }else { + Laya.loader.load(this._skin,Handler.create(this,this.loadComplete,[this._skin])); + } + } + + /** + *@private + *加载切片图片资源完成函数。 + *@param url 资源地址。 + *@param img 纹理。 + */ + __proto.loadComplete=function(url,img){ + if (url===this._skin && img){ + this._clipWidth || (this._clipWidth=Math.ceil(img.sourceWidth / this._clipX)); + this._clipHeight || (this._clipHeight=Math.ceil(img.sourceHeight / this._clipY)); + var key=this._skin+this._clipWidth+this._clipHeight; + var clips=AutoBitmap.getCache(key); + if (clips)this._sources=clips; + else { + this._sources=[]; + for (var i=0;i < this._clipY;i++){ + for (var j=0;j < this._clipX;j++){ + this._sources.push(Texture.createFromTexture(img,this._clipWidth *j,this._clipHeight *i,this._clipWidth,this._clipHeight)); + } + } + AutoBitmap.setCache(key,this._sources); + } + this.index=this._index; + this.event(/*laya.events.Event.LOADED*/"loaded"); + this.onCompResize(); + } + } + + /** + *播放动画。 + */ + __proto.play=function(){ + this._isPlaying=true; + this.index=0; + this._index++; + Laya.timer.loop(this.interval,this,this._loop); + } + + /** + *@private + */ + __proto._loop=function(){ + if (this._style.visible && this._sources){ + this.index=this._index,this._index++; + this._index >=this._sources.length && (this._index=0); + } + } + + /** + *停止动画。 + */ + __proto.stop=function(){ + this._isPlaying=false; + Laya.timer.clear(this,this._loop); + } + + /**@private */ + __proto._setClipChanged=function(){ + if (!this._clipChanged){ + this._clipChanged=true; + this.callLater(this.changeClip); + } + } + + /** + *表示动画播放间隔时间(以毫秒为单位)。 + */ + __getset(0,__proto,'interval',function(){ + return this._interval; + },function(value){ + if (this._interval !=value){ + this._interval=value; + if (this._isPlaying)this.play(); + } + }); + + /** + *@copy laya.ui.Image#skin + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + if (value){ + this._setClipChanged() + }else { + this._bitmap.source=null; + } + } + }); + + /** + *源数据。 + */ + __getset(0,__proto,'sources',function(){ + return this._sources; + },function(value){ + this._sources=value; + this.index=this._index; + this.event(/*laya.events.Event.LOADED*/"loaded"); + }); + + /**X轴(横向)切片数量。*/ + __getset(0,__proto,'clipX',function(){ + return this._clipX; + },function(value){ + this._clipX=value; + this._setClipChanged() + }); + + /**Y轴(竖向)切片数量。*/ + __getset(0,__proto,'clipY',function(){ + return this._clipY; + },function(value){ + this._clipY=value; + this._setClipChanged() + }); + + /** + *切片动画的总帧数。 + */ + __getset(0,__proto,'total',function(){ + this.runCallLater(this.changeClip); + return this._sources ? this._sources.length :0; + }); + + /** + *横向分割时每个切片的宽度,与 clipX 同时设置时优先级高于 clipX 。 + */ + __getset(0,__proto,'clipWidth',function(){ + return this._clipWidth; + },function(value){ + this._clipWidth=value; + this._setClipChanged() + }); + + /** + *

    当前实例的位图 AutoImage 实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(","); + return null; + },function(value){ + this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number); + }); + + /** + *资源分组。 + */ + __getset(0,__proto,'group',function(){ + return this._group; + },function(value){ + if (value && this._skin)Loader.setGroup(this._skin,value); + this._group=value; + }); + + /** + *竖向分割时每个切片的高度,与 clipY 同时设置时优先级高于 clipY 。 + */ + __getset(0,__proto,'clipHeight',function(){ + return this._clipHeight; + },function(value){ + this._clipHeight=value; + this._setClipChanged() + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._bitmap.width=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._bitmap.height=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + this.runCallLater(this.changeClip); + return this._bitmap.width; + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + this.runCallLater(this.changeClip); + return this._bitmap.height; + }); + + /** + *当前帧索引。 + */ + __getset(0,__proto,'index',function(){ + return this._index; + },function(value){ + this._index=value; + this._bitmap && this._sources && (this._bitmap.source=this._sources[value]); + this.event(/*laya.events.Event.CHANGE*/"change"); + }); + + /** + *表示是否自动播放动画,若自动播放值为true,否则值为false; + *

    可控制切片动画的播放、停止。

    + */ + __getset(0,__proto,'autoPlay',function(){ + return this._autoPlay; + },function(value){ + if (this._autoPlay !=value){ + this._autoPlay=value; + value ? this.play():this.stop(); + } + }); + + /** + *表示动画的当前播放状态。 + *如果动画正在播放中,则为true,否则为flash。 + */ + __getset(0,__proto,'isPlaying',function(){ + return this._isPlaying; + },function(value){ + this._isPlaying=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.index=parseInt(value); + else _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *AutoBitmap 位图实例。 + */ + __getset(0,__proto,'bitmap',function(){ + return this._bitmap; + }); + + return Clip; + })(Component) + + + /** + *ColorPicker 组件将显示包含多个颜色样本的列表,用户可以从中选择颜色。 + * + *@example 以下示例代码,创建了一个 ColorPicker 实例。 + *+ *package + *{ + *import laya.ui.ColorPicker; + *import laya.utils.Handler; + *public class ColorPicker_Example + *{ + *public function ColorPicker_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/color.png",Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *trace("资源加载完成!"); + *var colorPicket:ColorPicker=new ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。 + *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。 + *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.changeHandler=new Handler(this,onChangeColor,[colorPicket]);//设置 colorPicket 的颜色改变回调函数。 + *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。 + *} + *private function onChangeColor(colorPicket:ColorPicker):void + *{ + *trace("当前选择的颜色: "+colorPicket.selectedColor); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load("resource/ui/color.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *function loadComplete() + *{ + *console.log("资源加载完成!"); + *var colorPicket=new laya.ui.ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。 + *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。 + *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.changeHandler=laya.utils.Handler.create(this,onChangeColor,[colorPicket],false);//设置 colorPicket 的颜色改变回调函数。 + *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。 + *} + *function onChangeColor(colorPicket) + *{ + *console.log("当前选择的颜色: "+colorPicket.selectedColor); + *} + * + *+ *import ColorPicker=laya.ui.ColorPicker; + *import Handler=laya.utils.Handler; + *class ColorPicker_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/color.png",Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *console.log("资源加载完成!"); + *var colorPicket:ColorPicker=new ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。 + *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。 + *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。 + *colorPicket.changeHandler=new Handler(this,this.onChangeColor,[colorPicket]);//设置 colorPicket 的颜色改变回调函数。 + *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。 + *} + *private onChangeColor(colorPicket:ColorPicker):void { + *console.log("当前选择的颜色: "+colorPicket.selectedColor); + *} + *} + * + */ + //class laya.ui.ColorPicker extends laya.ui.Component + var ColorPicker=(function(_super){ + function ColorPicker(){ + this.changeHandler=null; + this._gridSize=11; + this._bgColor="#ffffff"; + this._borderColor="#000000"; + this._inputColor="#000000"; + this._inputBgColor="#efefef"; + this._colorPanel=null; + this._colorTiles=null; + this._colorBlock=null; + this._colorInput=null; + this._colorButton=null; + this._colors=[]; + this._selectedColor="#000000"; + this._panelChanged=false; + ColorPicker.__super.call(this); + } + + __class(ColorPicker,'laya.ui.ColorPicker',_super); + var __proto=ColorPicker.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._colorPanel && this._colorPanel.destroy(destroyChild); + this._colorButton && this._colorButton.destroy(destroyChild); + this._colorPanel=null; + this._colorTiles=null; + this._colorBlock=null; + this._colorInput=null; + this._colorButton=null; + this._colors=null; + this.changeHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._colorButton=new Button()); + this._colorPanel=new Box(); + this._colorPanel.size(230,166); + this._colorPanel.addChild(this._colorTiles=new Sprite()); + this._colorPanel.addChild(this._colorBlock=new Sprite()); + this._colorPanel.addChild(this._colorInput=new Input()); + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this._colorButton.on(/*laya.events.Event.CLICK*/"click",this,this.onColorButtonClick); + this._colorBlock.pos(5,5); + this._colorInput.pos(60,5); + this._colorInput.size(60,20); + this._colorInput.on(/*laya.events.Event.CHANGE*/"change",this,this.onColorInputChange); + this._colorInput.on(/*laya.events.Event.KEY_DOWN*/"keydown",this,this.onColorFieldKeyDown); + this._colorTiles.pos(5,30); + this._colorTiles.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onColorTilesMouseMove); + this._colorTiles.on(/*laya.events.Event.CLICK*/"click",this,this.onColorTilesClick); + this._colorTiles.size(20 *this._gridSize,12 *this._gridSize); + this._colorPanel.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onPanelMouseDown); + this.bgColor=this._bgColor; + } + + __proto.onPanelMouseDown=function(e){ + e.stopPropagation(); + } + + /** + *改变颜色样本列表面板。 + */ + __proto.changePanel=function(){ + this._panelChanged=false; + var g=this._colorPanel.graphics; + g.clear(); + g.drawRect(0,0,230,166,this._bgColor,this._borderColor); + this.drawBlock(this._selectedColor); + this._colorInput.borderColor=this._borderColor; + this._colorInput.bgColor=this._inputBgColor; + this._colorInput.color=this._inputColor; + g=this._colorTiles.graphics; + g.clear(); + var mainColors=[0x000000,0x333333,0x666666,0x999999,0xCCCCCC,0xFFFFFF,0xFF0000,0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF]; + for (var i=0;i < 12;i++){ + for (var j=0;j < 20;j++){ + var color=0; + if (j===0)color=mainColors[i]; + else if (j===1)color=0x000000; + else color=(((i *3+j / 6)% 3 << 0)+((i / 6)<< 0)*3)*0x33 << 16 | j % 6 *0x33 << 8 | (i << 0)% 6 *0x33; + var strColor=UIUtils.toColor(color); + this._colors.push(strColor); + var x=j *this._gridSize; + var y=i *this._gridSize; + g.drawRect(x,y,this._gridSize,this._gridSize,strColor,"#000000"); + } + } + } + + /** + *颜色样本列表面板的显示按钮的 Event.MOUSE_DOWN 事件侦听处理函数。 + */ + __proto.onColorButtonClick=function(e){ + if (this._colorPanel.parent)this.close(); + else this.open(); + } + + /** + *打开颜色样本列表面板。 + */ + __proto.open=function(){ + var p=this.localToGlobal(new Point()); + var px=p.x+this._colorPanel.width <=Laya.stage.width ? p.x :Laya.stage.width-this._colorPanel.width; + var py=p.y+this._colorButton.height; + py=py+this._colorPanel.height <=Laya.stage.height ? py :p.y-this._colorPanel.height; + this._colorPanel.pos(px,py); + Laya.stageBox.addChild(this._colorPanel); + Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeColorBox); + } + + /** + *关闭颜色样本列表面板。 + */ + __proto.close=function(){ + Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeColorBox); + this._colorPanel.removeSelf(); + } + + /** + *舞台的 Event.MOUSE_DOWN 事件侦听处理函数。 + */ + __proto.removeColorBox=function(e){ + this.close(); + } + + /** + *小格子色块的 Event.KEY_DOWN 事件侦听处理函数。 + */ + __proto.onColorFieldKeyDown=function(e){ + if (e.keyCode==13){ + if (this._colorInput.text)this.selectedColor=this._colorInput.text; + else this.selectedColor=null; + this.close(); + e.stopPropagation(); + } + } + + /** + *颜色值输入框 Event.CHANGE 事件侦听处理函数。 + */ + __proto.onColorInputChange=function(e){ + if (this._colorInput.text)this.drawBlock(this._colorInput.text); + else this.drawBlock("#FFFFFF"); + } + + /** + *小格子色块的 Event.CLICK 事件侦听处理函数。 + */ + __proto.onColorTilesClick=function(e){ + this.selectedColor=this.getColorByMouse(); + this.close(); + } + + /** + *@private + *小格子色块的 Event.MOUSE_MOVE 事件侦听处理函数。 + */ + __proto.onColorTilesMouseMove=function(e){ + this._colorInput.focus=false; + var color=this.getColorByMouse(); + this._colorInput.text=color; + this.drawBlock(color); + } + + /** + *通过鼠标位置取对应的颜色块的颜色值。 + */ + __proto.getColorByMouse=function(){ + var point=this._colorTiles.getMousePoint(); + var x=Math.floor(point.x / this._gridSize); + var y=Math.floor(point.y / this._gridSize); + return this._colors[y *20+x]; + } + + /** + *绘制颜色块。 + *@param color 需要绘制的颜色块的颜色值。 + */ + __proto.drawBlock=function(color){ + var g=this._colorBlock.graphics; + g.clear(); + var showColor=color ? color :"#ffffff"; + g.drawRect(0,0,50,20,showColor,this._borderColor); + color || g.drawLine(0,0,50,20,"#ff0000"); + } + + /** + *改变颜色。 + */ + __proto.changeColor=function(){ + var g=this.graphics; + g.clear(); + var showColor=this._selectedColor || "#000000"; + g.drawRect(0,0,this._colorButton.width,this._colorButton.height,showColor); + } + + /**@private */ + __proto._setPanelChanged=function(){ + if (!this._panelChanged){ + this._panelChanged=true; + this.callLater(this.changePanel); + } + } + + /** + *表示颜色输入框的背景颜色值。 + */ + __getset(0,__proto,'inputBgColor',function(){ + return this._inputBgColor; + },function(value){ + this._inputBgColor=value; + this._setPanelChanged(); + }); + + /** + *表示选择的颜色值。 + */ + __getset(0,__proto,'selectedColor',function(){ + return this._selectedColor; + },function(value){ + if (this._selectedColor !=value){ + this._selectedColor=this._colorInput.text=value; + this.drawBlock(value); + this.changeColor(); + this.changeHandler && this.changeHandler.runWith(this._selectedColor); + this.event(/*laya.events.Event.CHANGE*/"change",Event.EMPTY.setTo(/*laya.events.Event.CHANGE*/"change",this,this)); + } + }); + + /** + *@copy laya.ui.Button#skin + */ + __getset(0,__proto,'skin',function(){ + return this._colorButton.skin; + },function(value){ + this._colorButton.skin=value; + this.changeColor(); + }); + + /** + *表示颜色样本列表面板的背景颜色值。 + */ + __getset(0,__proto,'bgColor',function(){ + return this._bgColor; + },function(value){ + this._bgColor=value; + this._setPanelChanged(); + }); + + /** + *表示颜色样本列表面板的边框颜色值。 + */ + __getset(0,__proto,'borderColor',function(){ + return this._borderColor; + },function(value){ + this._borderColor=value; + this._setPanelChanged(); + }); + + /** + *表示颜色样本列表面板选择或输入的颜色值。 + */ + __getset(0,__proto,'inputColor',function(){ + return this._inputColor; + },function(value){ + this._inputColor=value; + this._setPanelChanged(); + }); + + return ColorPicker; + })(Component) + + + /** + *ComboBox 组件包含一个下拉列表,用户可以从该列表中选择单个值。 + * + *@example 以下示例代码,创建了一个 ComboBox 实例。 + *+ *package + *{ + *import laya.ui.ComboBox; + *import laya.utils.Handler; + *public class ComboBox_Example + *{ + *public function ComboBox_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *trace("资源加载完成!"); + *var comboBox:ComboBox=new ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。 + *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.selectHandler=new Handler(this,onSelect);//设置 comboBox 选择项改变时执行的处理器。 + *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。 + *} + *private function onSelect(index:int):void + *{ + *trace("当前选中的项对象索引: ",index); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *function loadComplete(){ + *console.log("资源加载完成!"); + *var comboBox=new laya.ui.ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。 + *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.selectHandler=new laya.utils.Handler(this,onSelect);//设置 comboBox 选择项改变时执行的处理器。 + *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。 + *} + *function onSelect(index) + *{ + *console.log("当前选中的项对象索引: ",index); + *} + * + *+ *import ComboBox=laya.ui.ComboBox; + *import Handler=laya.utils.Handler; + *class ComboBox_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/button.png",Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *console.log("资源加载完成!"); + *var comboBox:ComboBox=new ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。 + *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。 + *comboBox.selectHandler=new Handler(this,this.onSelect);//设置 comboBox 选择项改变时执行的处理器。 + *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。 + *} + *private onSelect(index:number):void { + *console.log("当前选中的项对象索引: ",index); + *} + *} + * + * + */ + //class laya.ui.ComboBox extends laya.ui.Component + var ComboBox=(function(_super){ + function ComboBox(skin,labels){ + this._visibleNum=6; + this._button=null; + this._list=null; + this._isOpen=false; + this._scrollBar=null; + this._itemSize=12; + this._labels=[]; + this._selectedIndex=-1; + this._selectHandler=null; + this._itemHeight=NaN; + this._listHeight=NaN; + this._listChanged=false; + this._itemChanged=false; + this._scrollBarSkin=null; + this.itemRender=null; + ComboBox.__super.call(this); + this._itemColors=Styles.comboBoxItemColors; + this.skin=skin; + this.labels=labels; + } + + __class(ComboBox,'laya.ui.ComboBox',_super); + var __proto=ComboBox.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._button && this._button.destroy(destroyChild); + this._list && this._list.destroy(destroyChild); + this._scrollBar && this._scrollBar.destroy(destroyChild); + this._button=null; + this._list=null; + this._scrollBar=null; + this._itemColors=null; + this._labels=null; + this._selectHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._button=new Button()); + this._button.text.align="left"; + this._button.labelPadding="0,0,0,5"; + this._button.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown); + } + + __proto._createList=function(){ + this._list=new List(); + this._list.selectEnable=true; + this._list.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onListDown); + this._list.mouseHandler=Handler.create(this,this.onlistItemMouse,null,false); + if (this._scrollBarSkin){ + this._list.addChild(this._scrollBar=new VScrollBar()); + this._scrollBar.skin=this._scrollBarSkin; + this._scrollBar.name="scrollBar"; + this._scrollBar.y=1; + this._scrollBar.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onScrollBarDown); + } + } + + /** + *@private + */ + __proto.onListDown=function(e){ + e.stopPropagation(); + } + + __proto.onScrollBarDown=function(e){ + e.stopPropagation(); + } + + __proto.onButtonMouseDown=function(e){ + this.callLater(this.switchTo,[!this._isOpen]); + } + + /** + *@private + */ + __proto.changeList=function(){ + this._listChanged=false; + var labelWidth=this.width-2; + var labelColor=this._itemColors[2]; + this._itemHeight=this._itemSize+6; + this._list.itemRender=this.itemRender || {type:"Box",child:[{type:"Label",props:{name:"label",x:1,padding:"3,3,3,3",width:labelWidth,height:this._itemHeight,fontSize:this._itemSize,color:labelColor}}]}; + this._list.repeatY=this._visibleNum; + if (this._scrollBar)this._scrollBar.x=this.width-this._scrollBar.width-1; + this._list.refresh(); + } + + /** + *@private + *下拉列表的鼠标事件响应函数。 + */ + __proto.onlistItemMouse=function(e,index){ + var type=e.type; + if (type===/*laya.events.Event.MOUSE_OVER*/"mouseover" || type===/*laya.events.Event.MOUSE_OUT*/"mouseout"){ + var box=this._list.getCell(index); + if (!box)return; + var label=box.getChildByName("label"); + if (label){ + if (type===/*laya.events.Event.ROLL_OVER*/"mouseover"){ + label.bgColor=this._itemColors[0]; + label.color=this._itemColors[1]; + }else { + label.bgColor=null; + label.color=this._itemColors[2]; + } + } + }else if (type===/*laya.events.Event.CLICK*/"click"){ + this.selectedIndex=index; + this.isOpen=false; + } + } + + /** + *@private + */ + __proto.switchTo=function(value){ + this.isOpen=value; + } + + /** + *更改下拉列表的打开状态。 + */ + __proto.changeOpen=function(){ + this.isOpen=!this._isOpen; + } + + /** + *更改下拉列表。 + */ + __proto.changeItem=function(){ + this._itemChanged=false; + this.runCallLater(this.changeList); + this._listHeight=this._labels.length > 0 ? Math.min(this._visibleNum,this._labels.length)*this._itemHeight :this._itemHeight; + if (this._scrollBar)this._scrollBar.height=this._listHeight-2; + var g=this._list.graphics; + g.clear(); + g.drawRect(0,0,this.width-1,this._listHeight,this._itemColors[4],this._itemColors[3]); + var a=this._list.array || []; + a.length=0; + for (var i=0,n=this._labels.length;i < n;i++){ + a.push({label:this._labels[i]}); + } + this._list.array=a; + if (this._visibleNum > a.length){ + this._list.height=this._listHeight; + }else { + this._list.height=0; + } + } + + __proto.changeSelected=function(){ + this._button.label=this.selectedLabel; + } + + /** + *关闭下拉列表。 + */ + __proto.removeList=function(e){ + this.isOpen=false; + } + + /** + *表示选择的下拉列表项的索引。 + */ + __getset(0,__proto,'selectedIndex',function(){ + return this._selectedIndex; + },function(value){ + if (this._selectedIndex !=value){ + this._selectedIndex=value; + if (this._labels.length > 0)this.changeSelected(); + else this.callLater(this.changeSelected); + this.event(/*laya.events.Event.CHANGE*/"change",[Event.EMPTY.setTo(/*laya.events.Event.CHANGE*/"change",this,this)]); + this._selectHandler && this._selectHandler.runWith(this._selectedIndex); + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + return this._button.height; + }); + + /** + *@copy laya.ui.Button#skin + */ + __getset(0,__proto,'skin',function(){ + return this._button.skin; + },function(value){ + if (this._button.skin !=value){ + this._button.skin=value; + this._listChanged=true; + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + return this._button.width; + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._button.width=this._width; + this._itemChanged=true; + this._listChanged=true; + }); + + /** + *表示选择的下拉列表项的的标签。 + */ + __getset(0,__proto,'selectedLabel',function(){ + return this._selectedIndex >-1 && this._selectedIndex < this._labels.length ? this._labels[this._selectedIndex] :null; + },function(value){ + this.selectedIndex=this._labels.indexOf(value); + }); + + /** + *标签集合字符串。 + */ + __getset(0,__proto,'labels',function(){ + return this._labels.join(","); + },function(value){ + if (this._labels.length > 0)this.selectedIndex=-1; + if (value)this._labels=value.split(","); + else this._labels.length=0; + this._itemChanged=true; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._button.height=this._height; + }); + + /** + *改变下拉列表的选择项时执行的处理器(默认返回参数index:int)。 + */ + __getset(0,__proto,'selectHandler',function(){ + return this._selectHandler; + },function(value){ + this._selectHandler=value; + }); + + /** + *获取或设置没有滚动条的下拉列表中可显示的最大行数。 + */ + __getset(0,__proto,'visibleNum',function(){ + return this._visibleNum; + },function(value){ + this._visibleNum=value; + this._listChanged=true; + }); + + /** + *表示按钮文本标签是否为粗体字。 + *@see laya.display.Text#bold + */ + __getset(0,__proto,'labelBold',function(){ + return this._button.text.bold; + },function(value){ + this._button.text.bold=value + }); + + /** + *下拉列表项颜色。 + *

    格式:"悬停或被选中时背景颜色,悬停或被选中时标签颜色,标签颜色,边框颜色,背景颜色"

    + */ + __getset(0,__proto,'itemColors',function(){ + return String(this._itemColors) + },function(value){ + this._itemColors=UIUtils.fillArray(this._itemColors,value,String); + this._listChanged=true; + }); + + /** + *下拉列表项标签的字体大小。 + */ + __getset(0,__proto,'itemSize',function(){ + return this._itemSize; + },function(value){ + this._itemSize=value; + this._listChanged=true; + }); + + /** + *获取对 ComboBox 组件所包含的 VScrollBar 滚动条组件的引用。 + */ + __getset(0,__proto,'scrollBar',function(){ + return this._scrollBar; + }); + + /** + *表示下拉列表的打开状态。 + */ + __getset(0,__proto,'isOpen',function(){ + return this._isOpen; + },function(value){ + if (this._isOpen !=value){ + this._isOpen=value; + this._button.selected=this._isOpen; + if (this._isOpen){ + this._list || this._createList(); + this._listChanged && this.changeList(); + this._itemChanged && this.changeItem(); + var p=this.localToGlobal(Point.TEMP.setTo(0,0)); + var py=p.y+this._button.height; + py=py+this._listHeight <=Laya.stage.height ? py :p.y-this._listHeight; + this._list.pos(p.x,py); + Laya.stageBox.addChild(this._list); + Laya.stage.once(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeList); + this._list.selectedIndex=this._selectedIndex; + }else { + this._list && this._list.removeSelf(); + } + } + }); + + /** + *滚动条皮肤。 + */ + __getset(0,__proto,'scrollBarSkin',function(){ + return this._scrollBarSkin; + },function(value){ + this._scrollBarSkin=value; + }); + + /** + *

    当前实例的位图 AutoImage 实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + return this._button.sizeGrid; + },function(value){ + this._button.sizeGrid=value; + }); + + /** + *获取对 ComboBox 组件所包含的 Button 组件的引用。 + */ + __getset(0,__proto,'button',function(){ + return this._button; + }); + + /** + *获取对 ComboBox 组件所包含的 List 列表组件的引用。 + */ + __getset(0,__proto,'list',function(){ + this._list || this._createList(); + return this._list; + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value); + else if ((value instanceof Array))this.labels=(value).join(","); + else _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *获取或设置对 ComboBox 组件所包含的 Button 组件的文本标签颜色。 + *

    格式:upColor,overColor,downColor,disableColor

    + */ + __getset(0,__proto,'labelColors',function(){ + return this._button.labelColors; + },function(value){ + if (this._button.labelColors !=value){ + this._button.labelColors=value; + } + }); + + /** + *获取或设置对 ComboBox 组件所包含的 Button 组件的文本边距。 + *

    格式:上边距,右边距,下边距,左边距

    + */ + __getset(0,__proto,'labelPadding',function(){ + return this._button.text.padding.join(","); + },function(value){ + this._button.text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number); + }); + + /** + *获取或设置对 ComboBox 组件所包含的 Button 组件的标签字体大小。 + */ + __getset(0,__proto,'labelSize',function(){ + return this._button.text.fontSize; + },function(value){ + this._button.text.fontSize=value + }); + + /** + *表示按钮文本标签的字体名称,以字符串形式表示。 + *@see laya.display.Text#font + */ + __getset(0,__proto,'labelFont',function(){ + return this._button.text.font; + },function(value){ + this._button.text.font=value + }); + + /** + *表示按钮的状态值。 + *@see laya.ui.Button#stateNum + */ + __getset(0,__proto,'stateNum',function(){ + return this._button.stateNum; + },function(value){ + this._button.stateNum=value + }); + + return ComboBox; + })(Component) + + + /** + *ScrollBar 组件是一个滚动条组件。 + *

    当数据太多以至于显示区域无法容纳时,最终用户可以使用 ScrollBar 组件控制所显示的数据部分。

    + *

    滚动条由四部分组成:两个箭头按钮、一个轨道和一个滑块。

    * + * + *@see laya.ui.VScrollBar + *@see laya.ui.HScrollBar + */ + //class laya.ui.ScrollBar extends laya.ui.Component + var ScrollBar=(function(_super){ + function ScrollBar(skin){ + this.rollRatio=0.95; + this.changeHandler=null; + this.scaleBar=true; + this.autoHide=false; + this.elasticDistance=0; + this.elasticBackTime=500; + this.upButton=null; + this.downButton=null; + this.slider=null; + this._scrollSize=1; + this._skin=null; + this._thumbPercent=1; + this._target=null; + this._lastPoint=null; + this._lastOffset=0; + this._checkElastic=false; + this._isElastic=false; + this._value=NaN; + this._hide=false; + this._clickOnly=true; + this._offsets=null; + ScrollBar.__super.call(this); + this._showButtons=UIConfig.showButtons; + this._touchScrollEnable=UIConfig.touchScrollEnable; + this._mouseWheelEnable=UIConfig.mouseWheelEnable; + this.skin=skin; + this.max=1; + } + + __class(ScrollBar,'laya.ui.ScrollBar',_super); + var __proto=ScrollBar.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this.upButton && this.upButton.destroy(destroyChild); + this.downButton && this.downButton.destroy(destroyChild); + this.slider && this.slider.destroy(destroyChild); + this.upButton=this.downButton=null; + this.slider=null; + this.changeHandler=null; + this._offsets=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this.slider=new Slider()); + this.addChild(this.upButton=new Button()); + this.addChild(this.downButton=new Button()); + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this.slider.showLabel=false; + this.slider.on(/*laya.events.Event.CHANGE*/"change",this,this.onSliderChange); + this.slider.setSlider(0,0,0); + this.upButton.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown); + this.downButton.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown); + } + + /** + *@private + *滑块位置发生改变的处理函数。 + */ + __proto.onSliderChange=function(){ + this.value=this.slider.value; + } + + /** + *@private + *向上和向下按钮的 Event.MOUSE_DOWN 事件侦听处理函数。 + */ + __proto.onButtonMouseDown=function(e){ + var isUp=e.currentTarget===this.upButton; + this.slide(isUp); + Laya.timer.once(Styles.scrollBarDelayTime,this,this.startLoop,[isUp]); + Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp); + } + + /**@private */ + __proto.startLoop=function(isUp){ + Laya.timer.frameLoop(1,this,this.slide,[isUp]); + } + + /**@private */ + __proto.slide=function(isUp){ + if (isUp)this.value-=this._scrollSize; + else this.value+=this._scrollSize; + } + + /** + *@private + *舞台的 Event.MOUSE_DOWN 事件侦听处理函数。 + */ + __proto.onStageMouseUp=function(e){ + Laya.timer.clear(this,this.startLoop); + Laya.timer.clear(this,this.slide); + } + + /** + *@private + *更改对象的皮肤及位置。 + */ + __proto.changeScrollBar=function(){ + this.upButton.visible=this._showButtons; + this.downButton.visible=this._showButtons; + if (this._showButtons){ + this.upButton.skin=this._skin.replace(".png","$up.png"); + this.downButton.skin=this._skin.replace(".png","$down.png"); + } + if (this.slider.isVertical)this.slider.y=this._showButtons ? this.upButton.height :0; + else this.slider.x=this._showButtons ? this.upButton.width :0; + this.resetPositions(); + } + + /**@inheritDoc */ + __proto.changeSize=function(){ + _super.prototype.changeSize.call(this); + this.resetPositions(); + this.event(/*laya.events.Event.CHANGE*/"change"); + this.changeHandler && this.changeHandler.runWith(this.value); + } + + /**@private */ + __proto.resetPositions=function(){ + if (this.slider.isVertical)this.slider.height=this.height-(this._showButtons ? (this.upButton.height+this.downButton.height):0); + else this.slider.width=this.width-(this._showButtons ? (this.upButton.width+this.downButton.width):0); + this.resetButtonPosition(); + } + + /**@private */ + __proto.resetButtonPosition=function(){ + if (this.slider.isVertical)this.downButton.y=this.slider.y+this.slider.height; + else this.downButton.x=this.slider.x+this.slider.width; + } + + /** + *设置滚动条信息。 + *@param min 滚动条最小位置值。 + *@param max 滚动条最大位置值。 + *@param value 滚动条当前位置值。 + */ + __proto.setScroll=function(min,max,value){ + this.runCallLater(this.changeSize); + this.slider.setSlider(min,max,value); + this.slider.bar.visible=max > 0; + if (!this._hide && this.autoHide)this.visible=false; + } + + /**@private */ + __proto.onTargetMouseWheel=function(e){ + this.value-=e.delta *this._scrollSize; + this.target=this._target; + } + + /**@private */ + __proto.onTargetMouseDown=function(e){ + this._clickOnly=true; + this._lastOffset=0; + this._checkElastic=false; + this._lastPoint || (this._lastPoint=new Point()); + this._lastPoint.setTo(Laya.stage.mouseX,Laya.stage.mouseY); + Laya.timer.clear(this,this.tweenMove); + Tween.clearTween(this); + Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2); + Laya.stage.once(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2); + Laya.timer.frameLoop(1,this,this.loop); + } + + /**@private */ + __proto.loop=function(){ + var mouseY=Laya.stage.mouseY; + var mouseX=Laya.stage.mouseX; + this._lastOffset=this.isVertical ? (mouseY-this._lastPoint.y):(mouseX-this._lastPoint.x); + if (this._clickOnly){ + if (Math.abs(this._lastOffset *(this.isVertical ? Laya.stage._canvasTransform.getScaleY():Laya.stage._canvasTransform.getScaleX()))> 1){ + this._clickOnly=false; + this._offsets || (this._offsets=[]); + this._offsets.length=0; + this._target.mouseEnabled=false; + if (!this.hide && this.autoHide){ + this.alpha=1; + this.visible=true; + } + this.event(/*laya.events.Event.START*/"start"); + }else return; + } + this._offsets.push(this._lastOffset); + this._lastPoint.x=mouseX; + this._lastPoint.y=mouseY; + if (this._lastOffset===0)return; + if (!this._checkElastic){ + if (this.elasticDistance > 0){ + if (!this._checkElastic && this._lastOffset !=0){ + this._checkElastic=true; + if ((this._lastOffset > 0 && this._value <=this.min)|| (this._lastOffset < 0 && this._value >=this.max)){ + this._isElastic=true; + }else { + this._isElastic=false; + } + } + }else { + this._checkElastic=true; + } + } + if (this._checkElastic){ + if (this._isElastic){ + if (this._value <=this.min){ + this.value-=this._lastOffset *Math.max(0,(1-((this.min-this._value)/ this.elasticDistance))); + }else if (this._value >=this.max){ + this.value-=this._lastOffset *Math.max(0,(1-((this._value-this.max)/ this.elasticDistance))); + } + }else { + this.value-=this._lastOffset; + } + } + } + + /**@private */ + __proto.onStageMouseUp2=function(e){ + Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2); + Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2); + Laya.timer.clear(this,this.loop); + if (this._clickOnly)return; + this._target.mouseEnabled=true; + if (this._isElastic){ + if (this._value < this.min){ + Tween.to(this,{value:this.min},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver)); + }else if (this._value > this.max){ + Tween.to(this,{value:this.max},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver)); + } + }else { + if (this._offsets.length < 1){ + this._offsets[0]=this.isVertical ? Laya.stage.mouseY-this._lastPoint.y :Laya.stage.mouseX-this._lastPoint.x; + }; + var offset=0; + var n=Math.min(this._offsets.length,3); + for (var i=0;i < n;i++){ + offset+=this._offsets[this._offsets.length-1-i]; + } + this._lastOffset=offset / n; + offset=Math.abs(this._lastOffset); + if (offset < 2){ + this.event(/*laya.events.Event.END*/"end"); + return; + } + if (offset > 60)this._lastOffset=this._lastOffset > 0 ? 60 :-60; + Laya.timer.frameLoop(1,this,this.tweenMove); + } + } + + /**@private */ + __proto.elasticOver=function(){ + this._isElastic=false; + if (!this.hide && this.autoHide){ + Tween.to(this,{alpha:0},500); + } + this.event(/*laya.events.Event.END*/"end"); + } + + /**@private */ + __proto.tweenMove=function(){ + this._lastOffset *=this.rollRatio; + this.value-=this._lastOffset; + if (Math.abs(this._lastOffset)< 1 || this.value==this.max || this.value==this.min){ + Laya.timer.clear(this,this.tweenMove); + this.event(/*laya.events.Event.END*/"end"); + if (!this.hide && this.autoHide){ + Tween.to(this,{alpha:0},500); + } + } + } + + /** + *停止滑动。 + */ + __proto.stopScroll=function(){ + this.onStageMouseUp2(null); + Laya.timer.clear(this,this.tweenMove); + Tween.clearTween(this); + } + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + if (this.slider.isVertical)return 100; + return this.slider.height; + }); + + /** + *@copy laya.ui.Image#skin + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this.slider.skin=this._skin; + this.callLater(this.changeScrollBar); + } + }); + + /** + *获取或设置表示最高滚动位置的数字。 + */ + __getset(0,__proto,'max',function(){ + return this.slider.max; + },function(value){ + this.slider.max=value; + }); + + /**一个布尔值,指定是否显示向上、向下按钮,默认值为true。*/ + __getset(0,__proto,'showButtons',function(){ + return this._showButtons; + },function(value){ + this._showButtons=value; + this.callLater(this.changeScrollBar); + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + if (this.slider.isVertical)return this.slider.width; + return 100; + }); + + /** + *获取或设置表示最低滚动位置的数字。 + */ + __getset(0,__proto,'min',function(){ + return this.slider.min; + },function(value){ + this.slider.min=value; + }); + + /** + *获取或设置表示当前滚动位置的数字。 + */ + __getset(0,__proto,'value',function(){ + return this._value; + },function(v){ + if (v!==this._value){ + if (this._isElastic)this._value=v; + else { + this.slider.value=v; + this._value=this.slider.value; + } + this.event(/*laya.events.Event.CHANGE*/"change"); + this.changeHandler && this.changeHandler.runWith(this.value); + } + }); + + /** + *一个布尔值,指示滚动条是否为垂直滚动。如果值为true,则为垂直滚动,否则为水平滚动。 + *

    默认值为:true。

    + */ + __getset(0,__proto,'isVertical',function(){ + return this.slider.isVertical; + },function(value){ + this.slider.isVertical=value; + }); + + /** + *

    当前实例的 Slider 实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + return this.slider.sizeGrid; + },function(value){ + this.slider.sizeGrid=value; + }); + + /**获取或设置一个值,该值表示按下滚动条轨道时页面滚动的增量。 */ + __getset(0,__proto,'scrollSize',function(){ + return this._scrollSize; + },function(value){ + this._scrollSize=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value); + else _super.prototype._$set_dataSource.call(this,value); + }); + + /**获取或设置一个值,该值表示滑条长度比例,值为:(0-1)。 */ + __getset(0,__proto,'thumbPercent',function(){ + return this._thumbPercent; + },function(value){ + this.runCallLater(this.changeScrollBar); + this.runCallLater(this.changeSize); + value=value >=1 ? 0.99 :value; + this._thumbPercent=value; + if (this.scaleBar){ + if (this.slider.isVertical)this.slider.bar.height=Math.max(this.slider.height *value,Styles.scrollBarMinNum); + else this.slider.bar.width=Math.max(this.slider.width *value,Styles.scrollBarMinNum); + } + }); + + /** + *设置滚动对象。 + *@see laya.ui.TouchScroll#target + */ + __getset(0,__proto,'target',function(){ + return this._target; + },function(value){ + if (this._target){ + this._target.off(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this.onTargetMouseWheel); + this._target.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onTargetMouseDown); + } + this._target=value; + if (value){ + this._mouseWheelEnable && this._target.on(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this.onTargetMouseWheel); + this._touchScrollEnable && this._target.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onTargetMouseDown); + } + }); + + /**是否隐藏滚动条,不显示滚动条,但是可以正常滚动,默认为false。*/ + __getset(0,__proto,'hide',function(){ + return this._hide; + },function(value){ + this._hide=value; + this.visible=!value; + }); + + /**一个布尔值,指定是否开启触摸,默认值为true。*/ + __getset(0,__proto,'touchScrollEnable',function(){ + return this._touchScrollEnable; + },function(value){ + this._touchScrollEnable=value; + this.target=this._target; + }); + + /**一个布尔值,指定是否滑轮滚动,默认值为true。*/ + __getset(0,__proto,'mouseWheelEnable',function(){ + return this._mouseWheelEnable; + },function(value){ + this._mouseWheelEnable=value; + }); + + return ScrollBar; + })(Component) + + + /** + *使用 Slider 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。 + *

    滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。

    + *

    滑块允许最小值和最大值之间特定间隔内的值。滑块还可以使用数据提示显示其当前值。

    + * + *@see laya.ui.HSlider + *@see laya.ui.VSlider + */ + //class laya.ui.Slider extends laya.ui.Component + var Slider=(function(_super){ + function Slider(skin){ + this.changeHandler=null; + this.isVertical=true; + this.showLabel=true; + this._allowClickBack=false; + this._max=100; + this._min=0; + this._tick=1; + this._value=0; + this._skin=null; + this._bg=null; + this._bar=null; + this._tx=NaN; + this._ty=NaN; + this._maxMove=NaN; + this._globalSacle=null; + Slider.__super.call(this); + this.skin=skin; + } + + __class(Slider,'laya.ui.Slider',_super); + var __proto=Slider.prototype; + /** + *@inheritDoc + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._bg && this._bg.destroy(destroyChild); + this._bar && this._bar.destroy(destroyChild); + this._bg=null; + this._bar=null; + this.changeHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._bg=new Image()); + this.addChild(this._bar=new Button()); + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this._bar.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBarMouseDown); + this._bg.sizeGrid=this._bar.sizeGrid="4,4,4,4,0"; + this.allowClickBack=true; + } + + /** + *@private + *滑块的的 Event.MOUSE_DOWN 事件侦听处理函数。 + *@param e + */ + __proto.onBarMouseDown=function(e){ + this._globalSacle || (this._globalSacle=new Point()); + this._globalSacle.setTo(this.globalScaleX,this.globalScaleY); + this._maxMove=this.isVertical ? (this.height-this._bar.height):(this.width-this._bar.width); + this._tx=Laya.stage.mouseX; + this._ty=Laya.stage.mouseY; + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.mouseMove); + Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.mouseUp); + this.showValueText(); + } + + /** + *@private + *显示标签。 + */ + __proto.showValueText=function(){ + if (this.showLabel){ + var label=laya.ui.Slider.label; + this.addChild(label); + label.textField.changeText(this._value+""); + if (this.isVertical){ + label.x=this._bar.x+20; + label.y=(this._bar.height-label.height)*0.5+this._bar.y; + }else { + label.y=this._bar.y-20; + label.x=(this._bar.width-label.width)*0.5+this._bar.x; + } + } + } + + /** + *@private + *隐藏标签。 + */ + __proto.hideValueText=function(){ + laya.ui.Slider.label && laya.ui.Slider.label.removeSelf(); + } + + /** + *@private + *@param e + */ + __proto.mouseUp=function(e){ + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.mouseMove); + this.sendChangeEvent(/*laya.events.Event.CHANGED*/"changed"); + this.hideValueText(); + } + + /** + *@private + *@param e + */ + __proto.mouseMove=function(e){ + var oldValue=this._value; + if (this.isVertical){ + this._bar.y+=(Laya.stage.mouseY-this._ty)/ this._globalSacle.y; + if (this._bar.y > this._maxMove)this._bar.y=this._maxMove; + else if (this._bar.y < 0)this._bar.y=0; + this._value=this._bar.y / this._maxMove *(this._max-this._min)+this._min; + }else { + this._bar.x+=(Laya.stage.mouseX-this._tx)/ this._globalSacle.x; + if (this._bar.x > this._maxMove)this._bar.x=this._maxMove; + else if (this._bar.x < 0)this._bar.x=0; + this._value=this._bar.x / this._maxMove *(this._max-this._min)+this._min; + } + this._tx=Laya.stage.mouseX; + this._ty=Laya.stage.mouseY; + var pow=Math.pow(10,(this._tick+"").length-1); + this._value=Math.round(Math.round(this._value / this._tick)*this._tick *pow)/ pow; + if (this._value !=oldValue){ + this.sendChangeEvent(); + } + this.showValueText(); + } + + /** + *@private + *@param type + */ + __proto.sendChangeEvent=function(type){ + (type===void 0)&& (type=/*laya.events.Event.CHANGE*/"change"); + this.event(type); + this.changeHandler && this.changeHandler.runWith(this._value); + } + + /** + *@private + *设置滑块的位置信息。 + */ + __proto.setBarPoint=function(){ + if (this.isVertical)this._bar.x=Math.round((this._bg.width-this._bar.width)*0.5); + else this._bar.y=Math.round((this._bg.height-this._bar.height)*0.5); + } + + /**@inheritDoc */ + __proto.changeSize=function(){ + _super.prototype.changeSize.call(this); + if (this.isVertical)this._bg.height=this.height; + else this._bg.width=this.width; + this.setBarPoint(); + this.changeValue(); + } + + /** + *设置滑动条的信息。 + *@param min 滑块的最小值。 + *@param max 滑块的最小值。 + *@param value 滑块的当前值。 + */ + __proto.setSlider=function(min,max,value){ + this._value=-1; + this._min=min; + this._max=max > min ? max :min; + this.value=value < min ? min :value > max ? max :value; + } + + /** + *@private + *改变滑块的位置值。 + */ + __proto.changeValue=function(){ + var pow=Math.pow(10,(this._tick+"").length-1); + this._value=Math.round(Math.round(this._value / this._tick)*this._tick *pow)/ pow; + this._value=this._value > this._max ? this._max :this._value < this._min ? this._min :this._value; + if (this.isVertical)this._bar.y=(this._value-this._min)/ (this._max-this._min)*(this.height-this._bar.height); + else this._bar.x=(this._value-this._min)/ (this._max-this._min)*(this.width-this._bar.width); + } + + /** + *@private + *滑动条的 Event.MOUSE_DOWN 事件侦听处理函数。 + */ + __proto.onBgMouseDown=function(e){ + var point=this._bg.getMousePoint(); + if (this.isVertical)this.value=point.y / (this.height-this._bar.height)*(this._max-this._min)+this._min; + else this.value=point.x / (this.width-this._bar.width)*(this._max-this._min)+this._min; + } + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + return Math.max(this._bg.height,this._bar.height); + }); + + /** + *@copy laya.ui.Image#skin + *@return + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this._bg.skin=this._skin; + this._bar.skin=this._skin.replace(".png","$bar.png"); + this.setBarPoint(); + } + }); + + /** + *一个布尔值,指定是否允许通过点击滑动条改变 Slidervalue 属性值。 + */ + __getset(0,__proto,'allowClickBack',function(){ + return this._allowClickBack; + },function(value){ + if (this._allowClickBack !=value){ + this._allowClickBack=value; + if (value)this._bg.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBgMouseDown); + else this._bg.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBgMouseDown); + } + }); + + /** + *获取或设置表示最高位置的数字。 默认值为100。 + */ + __getset(0,__proto,'max',function(){ + return this._max; + },function(value){ + if (this._max !=value){ + this._max=value; + this.callLater(this.changeValue); + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + return Math.max(this._bg.width,this._bar.width); + }); + + /** + *表示当前的刻度值。默认值为1。 + *@return + */ + __getset(0,__proto,'tick',function(){ + return this._tick; + },function(value){ + if (this._tick !=value){ + this._tick=value; + this.callLater(this.changeValue); + } + }); + + /** + *

    当前实例的背景图( Image )和滑块按钮( Button )实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + *@return + */ + __getset(0,__proto,'sizeGrid',function(){ + return this._bg.sizeGrid; + },function(value){ + this._bg.sizeGrid=value; + this._bar.sizeGrid=value; + }); + + /** + *获取或设置表示最低位置的数字。 默认值为0。 + */ + __getset(0,__proto,'min',function(){ + return this._min; + },function(value){ + if (this._min !=value){ + this._min=value; + this.callLater(this.changeValue); + } + }); + + /** + *获取或设置表示当前滑块位置的数字。 + */ + __getset(0,__proto,'value',function(){ + return this._value; + },function(num){ + if (this._value !=num){ + var oldValue=this._value; + this._value=num; + this.changeValue(); + if (this._value !=oldValue){ + this.sendChangeEvent(); + } + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value); + else _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *表示滑块按钮的引用。 + */ + __getset(0,__proto,'bar',function(){ + return this._bar; + }); + + __static(Slider, + ['label',function(){return this.label=new Label();} + ]); + return Slider; + })(Component) + + + /** + *Image 类是用于表示位图图像或绘制图形的显示对象。 + *@example 以下示例代码,创建了一个新的 Image 实例,设置了它的皮肤、位置信息,并添加到舞台上。 + *+ *package + *{ + *import laya.ui.Image; + *public class Image_Example + *{ + *public function Image_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *private function onInit():void + *{ + *var bg:Image=new Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。 + *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。 + *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。 + *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。 + *bg.width=150;//设置 bg 对象的宽度。 + *bg.height=250;//设置 bg 对象的高度。 + *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。 + *var image:Image=new Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。 + *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。 + *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。 + *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。 + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *onInit(); + *function onInit(){ + *var bg=new laya.ui.Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。 + *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。 + *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。 + *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。 + *bg.width=150;//设置 bg 对象的宽度。 + *bg.height=250;//设置 bg 对象的高度。 + *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。 + *var image=new laya.ui.Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。 + *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。 + *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。 + *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。 + *} + * + *+ *class Image_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.onInit(); + *} + *private onInit():void { + *var bg:laya.ui.Image=new laya.ui.Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。 + *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。 + *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。 + *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。 + *bg.width=150;//设置 bg 对象的宽度。 + *bg.height=250;//设置 bg 对象的高度。 + *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。 + *var image:laya.ui.Image=new laya.ui.Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。 + *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。 + *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。 + *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。 + *} + *} + * + *@see laya.ui.AutoBitmap + */ + //class laya.ui.Image extends laya.ui.Component + var Image=(function(_super){ + function Image(skin){ + this._bitmap=null; + this._skin=null; + this._group=null; + Image.__super.call(this); + this.skin=skin; + } + + __class(Image,'laya.ui.Image',_super); + var __proto=Image.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,true); + this._bitmap && this._bitmap.destroy(); + this._bitmap=null; + } + + /** + *销毁对象并释放加载的皮肤资源。 + */ + __proto.dispose=function(){ + this.destroy(true); + Laya.loader.clearRes(this._skin); + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.graphics=this._bitmap=new AutoBitmap(); + this._bitmap.autoCacheCmd=false; + } + + /** + *@private + *设置皮肤资源。 + */ + __proto.setSource=function(url,img){ + if (url===this._skin && img){ + this.source=img + this.onCompResize(); + } + } + + /** + *@copy laya.ui.AutoBitmap#source + */ + __getset(0,__proto,'source',function(){ + return this._bitmap.source; + },function(value){ + if (!this._bitmap)return; + this._bitmap.source=value; + this.event(/*laya.events.Event.LOADED*/"loaded"); + this.repaint(); + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='string'))this.skin=value; + else _super.prototype._$set_dataSource.call(this,value); + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + return this._bitmap.height; + }); + + /** + *

    对象的皮肤地址,以字符串表示。

    + *

    如果资源未加载,则先加载资源,加载完成后应用于此对象。

    + *注意:资源加载完成后,会自动缓存至资源库中。 + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + if (value){ + var source=Loader.getRes(value); + if (source){ + this.source=source; + this.onCompResize(); + }else Laya.loader.load(this._skin,Handler.create(this,this.setSource,[this._skin]),null,/*laya.net.Loader.IMAGE*/"image",1,true,this._group); + }else { + this.source=null; + } + } + }); + + /** + *资源分组。 + */ + __getset(0,__proto,'group',function(){ + return this._group; + },function(value){ + if (value && this._skin)Loader.setGroup(this._skin,value); + this._group=value; + }); + + /** + *

    当前实例的位图 AutoImage 实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"。

    + *@see laya.ui.AutoBitmap#sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(","); + return null; + },function(value){ + this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number); + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + return this._bitmap.width; + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._bitmap.width=value==0 ? 0.0000001 :value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._bitmap.height=value==0 ? 0.0000001 :value; + }); + + return Image; + })(Component) + + + /** + *

    Label 类用于创建显示对象以显示文本。

    + * + *@example 以下示例代码,创建了一个 Label 实例。 + *+ *package + *{ + *import laya.ui.Label; + *public class Label_Example + *{ + *public function Label_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *onInit(); + *} + *private function onInit():void + *{ + *var label:Label=new Label();//创建一个 Label 类的实例对象 label 。 + *label.font="Arial";//设置 label 的字体。 + *label.bold=true;//设置 label 显示为粗体。 + *label.leading=4;//设置 label 的行间距。 + *label.wordWrap=true;//设置 label 自动换行。 + *label.padding="10,10,10,10";//设置 label 的边距。 + *label.color="#ff00ff";//设置 label 的颜色。 + *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。 + *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。 + *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。 + *label.width=300;//设置 label 的宽度。 + *label.height=200;//设置 label 的高度。 + *Laya.stage.addChild(label);//将 label 添加到显示列表。 + *var passwordLabel:Label=new Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。 + *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。 + *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.width=300;//设置 passwordLabel 的宽度。 + *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。 + *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。 + *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。 + *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。 + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *onInit(); + *function onInit(){ + *var label=new laya.ui.Label();//创建一个 Label 类的实例对象 label 。 + *label.font="Arial";//设置 label 的字体。 + *label.bold=true;//设置 label 显示为粗体。 + *label.leading=4;//设置 label 的行间距。 + *label.wordWrap=true;//设置 label 自动换行。 + *label.padding="10,10,10,10";//设置 label 的边距。 + *label.color="#ff00ff";//设置 label 的颜色。 + *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。 + *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。 + *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。 + *label.width=300;//设置 label 的宽度。 + *label.height=200;//设置 label 的高度。 + *Laya.stage.addChild(label);//将 label 添加到显示列表。 + *var passwordLabel=new laya.ui.Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。 + *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。 + *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.width=300;//设置 passwordLabel 的宽度。 + *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。 + *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。 + *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。 + *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。 + *} + * + *+ *import Label=laya.ui.Label; + *class Label_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *this.onInit(); + *} + *private onInit():void { + *var label:Label=new Label();//创建一个 Label 类的实例对象 label 。 + *label.font="Arial";//设置 label 的字体。 + *label.bold=true;//设置 label 显示为粗体。 + *label.leading=4;//设置 label 的行间距。 + *label.wordWrap=true;//设置 label 自动换行。 + *label.padding="10,10,10,10";//设置 label 的边距。 + *label.color="#ff00ff";//设置 label 的颜色。 + *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。 + *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。 + *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。 + *label.width=300;//设置 label 的宽度。 + *label.height=200;//设置 label 的高度。 + *Laya.stage.addChild(label);//将 label 添加到显示列表。 + *var passwordLabel:Label=new Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。 + *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。 + *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。 + *passwordLabel.width=300;//设置 passwordLabel 的宽度。 + *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。 + *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。 + *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。 + *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。 + *} + *} + * + *@see laya.display.Text + */ + //class laya.ui.Label extends laya.ui.Component + var Label=(function(_super){ + function Label(text){ + this._tf=null; + Label.__super.call(this); + (text===void 0)&& (text=""); + Font.defaultColor=Styles.labelColor; + this.text=text; + } + + __class(Label,'laya.ui.Label',_super); + var __proto=Label.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._tf=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._tf=new Text()); + } + + /**@copy laya.display.Text#changeText() + **/ + __proto.changeText=function(text){ + this._tf.changeText(text); + } + + /** + *

    边距信息

    + *

    "上边距,右边距,下边距 , 左边距(边距以像素为单位)"

    + *@see laya.display.Text.padding + */ + __getset(0,__proto,'padding',function(){ + return this._tf.padding.join(","); + },function(value){ + this._tf.padding=UIUtils.fillArray(Styles.labelPadding,value,Number); + }); + + /** + *@copy laya.display.Text#bold + */ + __getset(0,__proto,'bold',function(){ + return this._tf.bold; + },function(value){ + this._tf.bold=value; + }); + + /** + *@copy laya.display.Text#align + */ + __getset(0,__proto,'align',function(){ + return this._tf.align; + },function(value){ + this._tf.align=value; + }); + + /** + *当前文本内容字符串。 + *@see laya.display.Text.text + */ + __getset(0,__proto,'text',function(){ + return this._tf.text; + },function(value){ + if (this._tf.text !=value){ + if(value) + value=(value+"").replace(Label._textReg,"\n"); + this._tf.text=value; + this.event(/*laya.events.Event.CHANGE*/"change"); + } + }); + + /** + *@copy laya.display.Text#italic + */ + __getset(0,__proto,'italic',function(){ + return this._tf.italic; + },function(value){ + this._tf.italic=value; + }); + + /** + *@copy laya.display.Text#wordWrap + */ + /** + *@copy laya.display.Text#wordWrap + */ + __getset(0,__proto,'wordWrap',function(){ + return this._tf.wordWrap; + },function(value){ + this._tf.wordWrap=value; + }); + + /** + *@copy laya.display.Text#font + */ + __getset(0,__proto,'font',function(){ + return this._tf.font; + },function(value){ + this._tf.font=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='number')|| (typeof value=='string'))this.text=value+""; + else _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *@copy laya.display.Text#color + */ + __getset(0,__proto,'color',function(){ + return this._tf.color; + },function(value){ + this._tf.color=value; + }); + + /** + *@copy laya.display.Text#valign + */ + __getset(0,__proto,'valign',function(){ + return this._tf.valign; + },function(value){ + this._tf.valign=value; + }); + + /** + *@copy laya.display.Text#leading + */ + __getset(0,__proto,'leading',function(){ + return this._tf.leading; + },function(value){ + this._tf.leading=value; + }); + + /** + *@copy laya.display.Text#fontSize + */ + __getset(0,__proto,'fontSize',function(){ + return this._tf.fontSize; + },function(value){ + this._tf.fontSize=value; + }); + + /** + *@copy laya.display.Text#bgColor + */ + __getset(0,__proto,'bgColor',function(){ + return this._tf.bgColor + },function(value){ + this._tf.bgColor=value; + }); + + /** + *@copy laya.display.Text#borderColor + */ + __getset(0,__proto,'borderColor',function(){ + return this._tf.borderColor + },function(value){ + this._tf.borderColor=value; + }); + + /** + *@copy laya.display.Text#stroke + */ + __getset(0,__proto,'stroke',function(){ + return this._tf.stroke; + },function(value){ + this._tf.stroke=value; + }); + + /** + *@copy laya.display.Text#strokeColor + */ + __getset(0,__proto,'strokeColor',function(){ + return this._tf.strokeColor; + },function(value){ + this._tf.strokeColor=value; + }); + + /** + *文本控件实体 Text 实例。 + */ + __getset(0,__proto,'textField',function(){ + return this._tf; + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'measureWidth',function(){ + return this._tf.width; + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'measureHeight',function(){ + return this._tf.height; + }); + + /** + *@inheritDoc + */ + /** + *@inheritDoc + */ + __getset(0,__proto,'width',function(){ + if (this._width || this._tf.text)return _super.prototype._$get_width.call(this); + return 0; + },function(value){ + _super.prototype._$set_width.call(this,value); + this._tf.width=value; + }); + + /** + *@inheritDoc + */ + /** + *@inheritDoc + */ + __getset(0,__proto,'height',function(){ + if (this._height || this._tf.text)return _super.prototype._$get_height.call(this); + return 0; + },function(value){ + _super.prototype._$set_height.call(this,value); + this._tf.height=value; + }); + + /** + *@copy laya.display.Text#overflow + */ + /** + *@copy laya.display.Text#overflow + */ + __getset(0,__proto,'overflow',function(){ + return this._tf.overflow; + },function(value){ + this._tf.overflow=value; + }); + + /** + *@copy laya.display.Text#underline + */ + /** + *@copy laya.display.Text#underline + */ + __getset(0,__proto,'underline',function(){ + return this._tf.underline; + },function(value){ + this._tf.underline=value; + }); + + /** + *@copy laya.display.Text#underlineColor + */ + /** + *@copy laya.display.Text#underlineColor + */ + __getset(0,__proto,'underlineColor',function(){ + return this._tf.underlineColor; + },function(value){ + this._tf.underlineColor=value; + }); + + __static(Label, + ['_textReg',function(){return this._textReg=new RegExp("\\\\n","g");} + ]); + return Label; + })(Component) + + + /** + *ProgressBar 组件显示内容的加载进度。 + *@example 以下示例代码,创建了一个新的 ProgressBar 实例,设置了它的皮肤、位置、宽高、网格等信息,并添加到舞台上。 + *+ *package + *{ + *import laya.ui.ProgressBar; + *import laya.utils.Handler; + *public class ProgressBar_Example + *{ + *private var progressBar:ProgressBar; + *public function ProgressBar_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/progress.png","resource/ui/progress$bar.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *progressBar=new ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。 + *progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。 + *progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。 + *progressBar.value=0.3;//设置 progressBar 的进度值。 + *progressBar.width=200;//设置 progressBar 的宽度。 + *progressBar.height=50;//设置 progressBar 的高度。 + *progressBar.sizeGrid="5,10,5,10";//设置 progressBar 的网格信息。 + *progressBar.changeHandler=new Handler(this,onChange);//设置 progressBar 的value值改变时执行的处理器。 + *Laya.stage.addChild(progressBar);//将 progressBar 添加到显示列表。 + *Laya.timer.once(3000,this,changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。 + *} + *private function changeValue():void + *{ + *trace("改变进度条的进度值。"); + *progressBar.value=0.6; + *} + *private function onChange(value:Number):void + *{ + *trace("进度发生改变: value=" ,value); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var res=["resource/ui/progress.png","resource/ui/progress$bar.png"]; + *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete() + *{ + *progressBar=new laya.ui.ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。 + *progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。 + *progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。 + *progressBar.value=0.3;//设置 progressBar 的进度值。 + *progressBar.width=200;//设置 progressBar 的宽度。 + *progressBar.height=50;//设置 progressBar 的高度。 + *progressBar.sizeGrid="10,5,10,5";//设置 progressBar 的网格信息。 + *progressBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 progressBar 的value值改变时执行的处理器。 + *Laya.stage.addChild(progressBar);//将 progressBar 添加到显示列表。 + *Laya.timer.once(3000,this,changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。 + *} + *function changeValue() + *{ + *console.log("改变进度条的进度值。"); + *progressBar.value=0.6; + *} + *function onChange(value) + *{ + *console.log("进度发生改变: value=" ,value); + *} + * + *+ *import ProgressBar=laya.ui.ProgressBar; + *import Handler=laya.utils.Handler; + *class ProgressBar_Example { + *private progressBar:ProgressBar; + *public ProgressBar_Example(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/progress.png","resource/ui/progress$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *this.progressBar=new ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。 + *this.progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。 + *this.progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。 + *this.progressBar.value=0.3;//设置 progressBar 的进度值。 + *this.progressBar.width=200;//设置 progressBar 的宽度。 + *this.progressBar.height=50;//设置 progressBar 的高度。 + *this.progressBar.sizeGrid="5,10,5,10";//设置 progressBar 的网格信息。 + *this.progressBar.changeHandler=new Handler(this,this.onChange);//设置 progressBar 的value值改变时执行的处理器。 + *Laya.stage.addChild(this.progressBar);//将 progressBar 添加到显示列表。 + *Laya.timer.once(3000,this,this.changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。 + *} + *private changeValue():void { + *console.log("改变进度条的进度值。"); + *this.progressBar.value=0.6; + *} + *private onChange(value:number):void { + *console.log("进度发生改变: value=",value); + *} + *} + * + */ + //class laya.ui.ProgressBar extends laya.ui.Component + var ProgressBar=(function(_super){ + function ProgressBar(skin){ + this.changeHandler=null; + this._bg=null; + this._bar=null; + this._skin=null; + this._value=0.5; + ProgressBar.__super.call(this); + this.skin=skin; + } + + __class(ProgressBar,'laya.ui.ProgressBar',_super); + var __proto=ProgressBar.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._bg && this._bg.destroy(destroyChild); + this._bar && this._bar.destroy(destroyChild); + this._bg=this._bar=null; + this.changeHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._bg=new Image()); + this.addChild(this._bar=new Image()); + this._bar._bitmap.autoCacheCmd=false; + } + + /** + *@private + *更改进度值的显示。 + */ + __proto.changeValue=function(){ + if (this.sizeGrid){ + var grid=this.sizeGrid.split(","); + var left=Number(grid[3]); + var right=Number(grid[1]); + var max=this.width-left-right; + var sw=max *this._value; + this._bar.width=left+right+sw; + this._bar.visible=this._bar.width > left+right; + }else { + this._bar.width=this.width *this._value; + } + } + + /**@inheritDoc */ + __getset(0,__proto,'measureHeight',function(){ + return this._bg.height; + }); + + /** + *@copy laya.ui.Image#skin + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this._bg.skin=this._skin; + this._bar.skin=this._skin.replace(".png","$bar.png"); + this.callLater(this.changeValue); + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'measureWidth',function(){ + return this._bg.width; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._bg.height=this._height; + this._bar.height=this._height; + }); + + /** + *获取进度条对象。 + */ + __getset(0,__proto,'bar',function(){ + return this._bar; + }); + + /** + *当前的进度量。 + *

    取值:介于0和1之间。

    + */ + __getset(0,__proto,'value',function(){ + return this._value; + },function(num){ + if (this._value !=num){ + num=num > 1 ? 1 :num < 0 ? 0 :num; + this._value=num; + this.callLater(this.changeValue); + this.event(/*laya.events.Event.CHANGE*/"change"); + this.changeHandler && this.changeHandler.runWith(num); + } + }); + + /** + *获取背景条对象。 + */ + __getset(0,__proto,'bg',function(){ + return this._bg; + }); + + /** + *

    当前 ProgressBar 实例的进度条背景位图( Image 实例)的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + return this._bg.sizeGrid; + },function(value){ + this._bg.sizeGrid=this._bar.sizeGrid=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._bg.width=this._width; + this.callLater(this.changeValue); + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value); + else _super.prototype._$set_dataSource.call(this,value); + }); + + return ProgressBar; + })(Component) + + + /**鼠标提示管理类*/ + //class laya.ui.TipManager extends laya.ui.Component + var TipManager=(function(_super){ + function TipManager(){ + this._tipBox=null; + this._tipText=null; + this._defaultTipHandler=null; + TipManager.__super.call(this); + this._tipBox=new Component(); + this._tipBox.addChild(this._tipText=new Text()); + this._tipText.x=this._tipText.y=5; + this._tipText.color=TipManager.tipTextColor; + this._defaultTipHandler=this._showDefaultTip; + Laya.stage.on(/*laya.ui.UIEvent.SHOW_TIP*/"showtip",this,this._onStageShowTip); + Laya.stage.on(/*laya.ui.UIEvent.HIDE_TIP*/"hidetip",this,this._onStageHideTip); + } + + __class(TipManager,'laya.ui.TipManager',_super); + var __proto=TipManager.prototype; + /** + *@private + */ + __proto._onStageHideTip=function(e){ + Laya.timer.clear(this,this._showTip); + this.closeAll(); + this.removeSelf(); + } + + /** + *@private + */ + __proto._onStageShowTip=function(data){ + Laya.timer.once(TipManager.tipDelay,this,this._showTip,[data],true); + } + + /** + *@private + */ + __proto._showTip=function(tip){ + if ((typeof tip=='string')){ + var text=String(tip); + if (Boolean(text)){ + this._defaultTipHandler(text); + } + }else if ((tip instanceof laya.utils.Handler )){ + (tip).run(); + }else if ((typeof tip=='function')){ + (tip).apply(); + } + if (true){ + Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this._onStageMouseMove); + Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onStageMouseDown); + } + this._onStageMouseMove(null); + } + + /** + *@private + */ + __proto._onStageMouseDown=function(e){ + this.closeAll(); + } + + /** + *@private + */ + __proto._onStageMouseMove=function(e){ + this._showToStage(this,TipManager.offsetX,TipManager.offsetY); + } + + /** + *@private + */ + __proto._showToStage=function(dis,offX,offY){ + (offX===void 0)&& (offX=0); + (offY===void 0)&& (offY=0); + var rec=dis.getBounds(); + dis.x=Laya.stage.mouseX+offX; + dis.y=Laya.stage.mouseY+offY; + if (dis.x+rec.width > Laya.stage.width){ + dis.x-=rec.width+offX; + } + if (dis.y+rec.height > Laya.stage.height){ + dis.y-=rec.height+offY; + } + } + + /**关闭所有鼠标提示*/ + __proto.closeAll=function(){ + Laya.timer.clear(this,this._showTip); + Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this._onStageMouseMove); + Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onStageMouseDown); + this.removeChildren(); + } + + /** + *显示显示对象类型的tip + */ + __proto.showDislayTip=function(tip){ + this.addChild(tip); + this._showToStage(this); + Laya.stageBox.addChild(this); + } + + /** + *@private + */ + __proto._showDefaultTip=function(text){ + this._tipText.text=text; + var g=this._tipBox.graphics; + g.clear(); + g.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,TipManager.tipBackColor); + this.addChild(this._tipBox); + this._showToStage(this); + Laya.stageBox.addChild(this); + } + + /**默认鼠标提示函数*/ + __getset(0,__proto,'defaultTipHandler',function(){ + return this._defaultTipHandler; + },function(value){ + this._defaultTipHandler=value; + }); + + TipManager.offsetX=10; + TipManager.offsetY=15; + TipManager.tipTextColor="#ffffff"; + TipManager.tipBackColor="#111111"; + TipManager.tipDelay=200; + return TipManager; + })(Component) + + + /** + *关键帧动画播放类 + * + */ + //class laya.ui.FrameClip extends laya.display.FrameAnimation + var FrameClip=(function(_super){ + /** + *创建一个 FrameClip 实例。 + */ + function FrameClip(){ + FrameClip.__super.call(this); + } + + __class(FrameClip,'laya.ui.FrameClip',_super); + return FrameClip; + })(FrameAnimation) + + + /** + *CheckBox 组件显示一个小方框,该方框内可以有选中标记。 + *CheckBox 组件还可以显示可选的文本标签,默认该标签位于 CheckBox 右侧。 + *

    CheckBox 使用 dataSource赋值时的的默认属性是:selected

    + * + *@example 以下示例代码,创建了一个 CheckBox 实例。 + *+ *package + *{ + *import laya.ui.CheckBox; + *import laya.utils.Handler; + *public class CheckBox_Example + *{ + *public function CheckBox_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/check.png",Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *trace("资源加载完成!"); + *var checkBox:CheckBox=new CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的实例对象 checkBox ,传入它的皮肤skin和标签label。 + *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.clickHandler=new Handler(this,onClick,[checkBox]);//设置 checkBox 的点击事件处理器。 + *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。 + *} + *private function onClick(checkBox:CheckBox):void + *{ + *trace("输出选中状态: checkBox.selected = "+checkBox.selected); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load("resource/ui/check.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *function loadComplete() + *{ + *console.log("资源加载完成!"); + *var checkBox:laya.ui.CheckBox=new laya.ui.CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的类的实例对象 checkBox ,传入它的皮肤skin和标签label。 + *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.clickHandler=new laya.utils.Handler(this,this.onClick,[checkBox],false);//设置 checkBox 的点击事件处理器。 + *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。 + *} + *function onClick(checkBox) + *{ + *console.log("checkBox.selected = ",checkBox.selected); + *} + * + *+ *import CheckBox=laya.ui.CheckBox; + *import Handler=laya.utils.Handler; + *class CheckBox_Example{ + *constructor() + *{ + *Laya.init(640,800); + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/check.png",Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete() + *{ + *var checkBox:CheckBox=new CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的实例对象 checkBox ,传入它的皮肤skin和标签label。 + *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。 + *checkBox.clickHandler=new Handler(this,this.onClick,[checkBox]);//设置 checkBox 的点击事件处理器。 + *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。 + *} + *private onClick(checkBox:CheckBox):void + *{ + *console.log("输出选中状态: checkBox.selected = "+checkBox.selected); + *} + *} + * + */ + //class laya.ui.CheckBox extends laya.ui.Button + var CheckBox=(function(_super){ + /** + *创建一个新的 CheckBox 组件实例。 + *@param skin 皮肤资源地址。 + *@param label 文本标签的内容。 + */ + function CheckBox(skin,label){ + (label===void 0)&& (label=""); + CheckBox.__super.call(this,skin,label); + } + + __class(CheckBox,'laya.ui.CheckBox',_super); + var __proto=CheckBox.prototype; + /**@inheritDoc */ + __proto.preinitialize=function(){ + laya.ui.Component.prototype.preinitialize.call(this); + this.toggle=true; + this._autoSize=false; + } + + /**@inheritDoc */ + __proto.initialize=function(){ + _super.prototype.initialize.call(this); + this.createText(); + this._text.align="left"; + this._text.valign="top"; + this._text.width=0; + } + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if ((typeof value=='boolean'))this.selected=value; + else if ((typeof value=='string'))this.selected=value==="true"; + else _super.prototype._$set_dataSource.call(this,value); + }); + + return CheckBox; + })(Button) + + + /** + *View 是一个视图类。 + *@internal

    View

    + */ + //class laya.ui.View extends laya.ui.Box + var View=(function(_super){ + function View(){ + this._idMap=null; + this._aniList=null; + View.__super.call(this); + } + + __class(View,'laya.ui.View',_super); + var __proto=View.prototype; + /** + *@private + *通过视图数据创建视图。 + *@param uiView 视图数据信息。 + */ + __proto.createView=function(uiView){ + if (uiView.animations && !this._idMap)this._idMap={}; + View.createComp(uiView,this,this); + if (uiView.animations){ + var anilist=[]; + var animations=uiView.animations; + var i=0,len=animations.length; + var tAni; + var tAniO; + for (i=0;i < len;i++){ + tAni=new FrameClip(); + tAniO=animations[i]; + tAni._setUp(this._idMap,tAniO); + this[tAniO.name]=tAni; + tAni._setControlNode(this); + switch (tAniO.action){ + case 1: + tAni.play(0,false); + break ; + case 2: + tAni.play(0,true); + break ; + } + anilist.push(tAni); + } + this._aniList=anilist; + } + if (this._width > 0 && uiView.props.hitTestPrior==null && !this.mouseThrough)this.hitTestPrior=true; + } + + /** + *@private + *装载UI视图。用于加载模式。 + *@param path UI资源地址。 + */ + __proto.loadUI=function(path){ + var uiView=View.uiMap[path]; + uiView && this.createView(uiView); + } + + /** + *

    销毁此对象。

    + *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。 + */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + if (this._aniList)this._aniList.length=0; + this._idMap=null; + this._aniList=null; + laya.ui.Component.prototype.destroy.call(this,destroyChild); + } + + View._regs=function(){ + var key; + for (key in View.uiClassMap){ + ClassUtils.regClass(key,View.uiClassMap[key]); + } + } + + View.createComp=function(uiView,comp,view){ + comp=comp || View.getCompInstance(uiView); + if (!comp){ + console.log("can not create:"+uiView.type); + return null; + }; + var child=uiView.child; + if (child){ + for (var i=0,n=child.length;i < n;i++){ + var node=child[i]; + if (comp.hasOwnProperty("itemRender")&& (node.props.name=="render" || node.props.renderType==="render")){ + (comp).itemRender=node; + }else if (node.type=="Graphic"){ + ClassUtils.addGraphicsToSprite(node,comp); + }else if (ClassUtils.isDrawType(node.type)){ + ClassUtils.addGraphicToSprite(node,comp,true); + }else { + var tChild=View.createComp(node,null,view); + if (node.type=="Script"){ + tChild["owner"]=comp; + }else if (node.props.renderType=="mask" || node.props.name=="mask"){ + comp.mask=tChild; + }else {( + tChild instanceof laya.display.Sprite )&& comp.addChild(tChild); + } + } + } + }; + var props=uiView.props; + for (var prop in props){ + var value=props[prop]; + View.setCompValue(comp,prop,value,view); + } + if (Laya.__typeof(comp,'laya.ui.IItem'))(comp).initItems(); + if (uiView.compId && view && view._idMap){ + view._idMap[uiView.compId]=comp; + } + return comp; + } + + View.setCompValue=function(comp,prop,value,view){ + if (prop==="var" && view){ + view[value]=comp; + } + else if (prop==="x" || prop==="y" || prop==="width" || prop==="height" || (typeof (comp[prop])=='number')){ + comp[prop]=parseFloat(value); + } + else { + comp[prop]=(value==="true" ? true :(value==="false" ? false :value)) + } + } + + View.getCompInstance=function(json){ + var runtime=json.props ? json.props.runtime :""; + var compClass; + compClass=runtime ? (View.viewClassMap[runtime] || View.uiClassMap[runtime]|| Laya["__classmap"][runtime]):View.uiClassMap[json.type]; + return compClass ? new compClass():null; + } + + View.regComponent=function(key,compClass){ + View.uiClassMap[key]=compClass; + ClassUtils.regClass(key,compClass); + } + + View.regViewRuntime=function(key,compClass){ + View.viewClassMap[key]=compClass; + } + + View.uiMap={}; + View.viewClassMap={}; + __static(View, + ['uiClassMap',function(){return this.uiClassMap={"ViewStack":ViewStack,"LinkButton":Button,"TextArea":TextArea,"ColorPicker":ColorPicker,"Box":Box,"Button":Button,"CheckBox":CheckBox,"Clip":Clip,"ComboBox":ComboBox,"Component":Component,"HScrollBar":HScrollBar,"HSlider":HSlider,"Image":Image,"Label":Label,"List":List,"Panel":Panel,"ProgressBar":ProgressBar,"Radio":Radio,"RadioGroup":RadioGroup,"ScrollBar":ScrollBar,"Slider":Slider,"Tab":Tab,"TextInput":TextInput,"View":View,"VScrollBar":VScrollBar,"VSlider":VSlider,"Tree":Tree,"HBox":HBox,"VBox":VBox,"Sprite":Sprite,"Animation":Animation,"Text":Text};} + ]); + View.__init$=function(){ + View._regs() + } + + return View; + })(Box) + + + /** + *LayoutBox 是一个布局容器类。 + */ + //class laya.ui.LayoutBox extends laya.ui.Box + var LayoutBox=(function(_super){ + function LayoutBox(){ + this._space=0; + this._align="none"; + this._itemChanged=false; + LayoutBox.__super.call(this); + } + + __class(LayoutBox,'laya.ui.LayoutBox',_super); + var __proto=LayoutBox.prototype; + /**@inheritDoc */ + __proto.addChild=function(child){ + child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setItemChanged(); + return laya.display.Node.prototype.addChild.call(this,child); + } + + __proto.onResize=function(e){ + this._setItemChanged(); + } + + /**@inheritDoc */ + __proto.addChildAt=function(child,index){ + child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setItemChanged(); + return laya.display.Node.prototype.addChildAt.call(this,child,index); + } + + /**@inheritDoc */ + __proto.removeChild=function(child){ + child.off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setItemChanged(); + return laya.display.Node.prototype.removeChild.call(this,child); + } + + /**@inheritDoc */ + __proto.removeChildAt=function(index){ + this.getChildAt(index).off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setItemChanged(); + return laya.display.Node.prototype.removeChildAt.call(this,index); + } + + /**刷新。*/ + __proto.refresh=function(){ + this._setItemChanged(); + } + + /** + *改变子对象的布局。 + */ + __proto.changeItems=function(){ + this._itemChanged=false; + } + + /** + *排序项目列表。可通过重写改变默认排序规则。 + *@param items 项目列表。 + */ + __proto.sortItem=function(items){ + if (items)items.sort(function(a,b){return a.y > b.y ? 1 :-1 + }); + } + + __proto._setItemChanged=function(){ + if (!this._itemChanged){ + this._itemChanged=true; + this.callLater(this.changeItems); + } + } + + /**子对象的间隔。*/ + __getset(0,__proto,'space',function(){ + return this._space; + },function(value){ + this._space=value; + this._setItemChanged(); + }); + + /**子对象对齐方式。*/ + __getset(0,__proto,'align',function(){ + return this._align; + },function(value){ + this._align=value; + this._setItemChanged(); + }); + + return LayoutBox; + })(Box) + + + /** + *List 控件可显示项目列表。默认为垂直方向列表。可通过UI编辑器自定义列表。 + * + *@example 以下示例代码,创建了一个 List 实例。 + *+ *package + *{ + *import laya.ui.List; + *import laya.utils.Handler; + *public class List_Example + *{ + *public function List_Example() + *{ + *Laya.init(640,800,"false");//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,onLoadComplete)); + *} + *private function onLoadComplete():void + *{ + *var arr:Array=[];//创建一个数组,用于存贮列表的数据信息。 + *for (var i:int=0;i <20;i++) + *{ + *arr.push({label:"item"+i}); + *} + *var list:List=new List();//创建一个 List 类的实例对象 list 。 + *list.itemRender=Item;//设置 list 的单元格渲染器。 + *list.repeatX=1;//设置 list 的水平方向单元格数量。 + *list.repeatY=10;//设置 list 的垂直方向单元格数量。 + *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。 + *list.array=arr;//设置 list 的列表数据源。 + *list.pos(100,100);//设置 list 的位置。 + *list.selectEnable=true;//设置 list 可选。 + *list.selectHandler=new Handler(this,onSelect);//设置 list 改变选择项执行的处理器。 + *Laya.stage.addChild(list);//将 list 添加到显示列表。 + *} + *private function onSelect(index:int):void + *{ + *trace("当前选择的项目索引: index= ",index); + *} + *} + *} + *import laya.ui.Box; + *import laya.ui.Label; + *class Item extends Box + *{ + *public function Item() + *{ + *graphics.drawRect(0,0,100,20,null,"#ff0000"); + *var label:Label=new Label(); + *label.text="100000"; + *label.name="label";//设置 label 的name属性值。 + *label.size(100,20); + *addChild(label); + *} + *} + * + *+ *(function (_super){ + *function Item(){ + *Item.__super.call(this);//初始化父类 + *this.graphics.drawRect(0,0,100,20,"#ff0000"); + *var label=new laya.ui.Label();//创建一个 Label 类的实例对象 label 。 + *label.text="100000";//设置 label 的文本内容。 + *label.name="label";//设置 label 的name属性值。 + *label.size(100,20);//设置 label 的宽度、高度。 + *this.addChild(label);//将 label 添加到显示列表。 + *}; + *Laya.class(Item,"mypackage.listExample.Item",_super);//注册类 Item 。 + *})(laya.ui.Box); + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"]; + *Laya.loader.load(res,new laya.utils.Handler(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *var arr=[];//创建一个数组,用于存贮列表的数据信息。 + *for (var i=0;i <20;i++){ + *arr.push({label:"item"+i}); + *} + *var list=new laya.ui.List();//创建一个 List 类的实例对象 list 。 + *list.itemRender=mypackage.listExample.Item;//设置 list 的单元格渲染器。 + *list.repeatX=1;//设置 list 的水平方向单元格数量。 + *list.repeatY=10;//设置 list 的垂直方向单元格数量。 + *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。 + *list.array=arr;//设置 list 的列表数据源。 + *list.pos(100,100);//设置 list 的位置。 + *list.selectEnable=true;//设置 list 可选。 + *list.selectHandler=new laya.utils.Handler(this,onSelect);//设置 list 改变选择项执行的处理器。 + *Laya.stage.addChild(list);//将 list 添加到显示列表。 + *} + *function onSelect(index) + *{ + *console.log("当前选择的项目索引: index= ",index); + *} + * + * + *+ *import List=laya.ui.List; + *import Handler=laya.utils.Handler; + *public class List_Example { + *public List_Example(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,this.onLoadComplete)); + *} + *private onLoadComplete():void { + *var arr=[];//创建一个数组,用于存贮列表的数据信息。 + *for (var i:number=0;i <20;i++) + *{ + *arr.push({label:"item"+i }); + *} + *var list:List=new List();//创建一个 List 类的实例对象 list 。 + *list.itemRender=Item;//设置 list 的单元格渲染器。 + *list.repeatX=1;//设置 list 的水平方向单元格数量。 + *list.repeatY=10;//设置 list 的垂直方向单元格数量。 + *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。 + *list.array=arr;//设置 list 的列表数据源。 + *list.pos(100,100);//设置 list 的位置。 + *list.selectEnable=true;//设置 list 可选。 + *list.selectHandler=new Handler(this,this.onSelect);//设置 list 改变选择项执行的处理器。 + *Laya.stage.addChild(list);//将 list 添加到显示列表。 + *} + *private onSelect(index:number):void { + *console.log("当前选择的项目索引: index= ",index); + *} + *} + *import Box=laya.ui.Box; + *import Label=laya.ui.Label; + *class Item extends Box { + *constructor(){ + *this.graphics.drawRect(0,0,100,20,null,"#ff0000"); + *var label:Label=new Label(); + *label.text="100000"; + *label.name="label";//设置 label 的name属性值。 + *label.size(100,20); + *this.addChild(label); + *} + *} + * + */ + //class laya.ui.List extends laya.ui.Box + var List=(function(_super){ + function List(){ + this.selectHandler=null; + this.renderHandler=null; + this.mouseHandler=null; + this.selectEnable=false; + this.totalPage=0; + this._content=null; + this._scrollBar=null; + this._itemRender=null; + this._repeatX=0; + this._repeatY=0; + this._repeatX2=0; + this._repeatY2=0; + this._spaceX=0; + this._spaceY=0; + this._array=null; + this._startIndex=0; + this._selectedIndex=-1; + this._page=0; + this._isVertical=true; + this._cellSize=20; + this._cellOffset=0; + this._isMoved=false; + this.cacheContent=false; + this._createdLine=0; + this._cellChanged=false; + List.__super.call(this); + this._cells=[]; + } + + __class(List,'laya.ui.List',_super); + var __proto=List.prototype; + Laya.imps(__proto,{"laya.ui.IRender":true,"laya.ui.IItem":true}) + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + laya.ui.Component.prototype.destroy.call(this,destroyChild); + this._content && this._content.destroy(destroyChild); + this._scrollBar && this._scrollBar.destroy(destroyChild); + this._content=null; + this._scrollBar=null; + this._itemRender=null; + this._cells=null; + this._array=null; + this.selectHandler=this.renderHandler=this.mouseHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._content=new Box()); + } + + __proto.onScrollStart=function(){ + this._$P.cacheAs || (this._$P.cacheAs=_super.prototype._$get_cacheAs.call(this)); + _super.prototype._$set_cacheAs.call(this,"none"); + this._scrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd); + } + + __proto.onScrollEnd=function(){ + _super.prototype._$set_cacheAs.call(this,this._$P.cacheAs); + } + + /** + *@private + *更改单元格的信息。 + *@internal 在此销毁、创建单元格,并设置单元格的位置等属性。相当于此列表内容发送改变时调用此函数。 + */ + __proto.changeCells=function(){ + this._cellChanged=false; + if (this._itemRender){ + for (var i=this._cells.length-1;i >-1;i--){ + this._cells[i].destroy(); + } + this._cells.length=0; + this.scrollBar=this.getChildByName("scrollBar"); + var cell=this.createItem(); + var cellWidth=(cell.width+this._spaceX)|| 1; + var cellHeight=(cell.height+this._spaceY)|| 1; + if (this._width > 0)this._repeatX2=this._isVertical ? Math.round(this._width / cellWidth):Math.ceil(this._width / cellWidth); + if (this._height > 0)this._repeatY2=this._isVertical ? Math.ceil(this._height / cellHeight):Math.round(this._height / cellHeight); + var listWidth=this._width ? this._width :(cellWidth *this.repeatX-this._spaceX); + var listHeight=this._height ? this._height :(cellHeight *this.repeatY-this._spaceY); + this._cellSize=this._isVertical ? cellHeight :cellWidth; + this._cellOffset=this._isVertical ? (cellHeight *Math.max(this._repeatY2,this._repeatY)-listHeight-this._spaceY):(cellWidth *Math.max(this._repeatX2,this._repeatX)-listWidth-this._spaceX); + if (this._isVertical && this._scrollBar)this._scrollBar.height=listHeight; + else if (!this._isVertical && this._scrollBar)this._scrollBar.width=listWidth; + this.setContentSize(listWidth,listHeight); + var numX=this._isVertical ? this.repeatX :this.repeatY; + var numY=(this._isVertical ? this.repeatY :this.repeatX)+(this._scrollBar ? 1 :0); + this._createItems(0,numX,numY); + this._createdLine=numY; + if (this._array){ + this.array=this._array; + this.runCallLater(this.renderItems); + } + } + } + + __proto._createItems=function(startY,numX,numY){ + var box=this._content; + var cell=this.createItem(); + var cellWidth=cell.width+this._spaceX; + var cellHeight=cell.height+this._spaceY; + if (this.cacheContent){ + var cacheBox=new Box(); + cacheBox.cacheAsBitmap=true; + cacheBox.pos((this._isVertical ? 0 :startY)*cellWidth,(this._isVertical ? startY :0)*cellHeight); + this._content.addChild(cacheBox); + this._content.optimizeScrollRect=true; + box=cacheBox; + } + for (var k=startY;k < numY;k++){ + for (var l=0;l < numX;l++){ + cell=this.createItem(); + cell.x=(this._isVertical ? l :k)*cellWidth-box.x; + cell.y=(this._isVertical ? k :l)*cellHeight-box.y; + cell.name="item"+(k *numX+l); + box.addChild(cell); + this.addCell(cell); + } + } + } + + __proto.createItem=function(){ + return (typeof this._itemRender=='function')? new this._itemRender():View.createComp(this._itemRender); + } + + /** + *@private + *添加单元格。 + *@param cell 需要添加的单元格对象。 + */ + __proto.addCell=function(cell){ + cell.on(/*laya.events.Event.CLICK*/"click",this,this.onCellMouse); + cell.on(/*laya.events.Event.RIGHT_CLICK*/"rightclick",this,this.onCellMouse); + cell.on(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onCellMouse); + cell.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onCellMouse); + cell.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onCellMouse); + cell.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onCellMouse); + this._cells.push(cell); + } + + /** + *初始化单元格信息。 + */ + __proto.initItems=function(){ + if (!this._itemRender && this.getChildByName("item0")!=null){ + this.repeatX=1; + var count=0; + count=0; + for (var i=0;i < 10000;i++){ + var cell=this.getChildByName("item"+i); + if (cell){ + this.addCell(cell); + count++; + continue ; + } + break ; + } + this.repeatY=count; + } + } + + /** + *设置可视区域大小。 + *

    以(0,0,width参数,height参数)组成的矩形区域为可视区域。

    + *@param width 可视区域宽度。 + *@param height 可视区域高度。 + */ + __proto.setContentSize=function(width,height){ + this._content.width=width; + this._content.height=height; + if (this._scrollBar){ + this._content.scrollRect || (this._content.scrollRect=new Rectangle()); + this._content.scrollRect.setTo(0,0,width,height); + this._content.model && this._content.model.scrollRect(0,0,width,height); + this.event(/*laya.events.Event.RESIZE*/"resize"); + } + } + + /** + *@private + *单元格的鼠标事件侦听处理函数。 + */ + __proto.onCellMouse=function(e){ + if (e.type===/*laya.events.Event.MOUSE_DOWN*/"mousedown")this._isMoved=false; + var cell=e.currentTarget; + var index=this._startIndex+this._cells.indexOf(cell); + if (index < 0)return; + if (e.type===/*laya.events.Event.CLICK*/"click" || e.type===/*laya.events.Event.RIGHT_CLICK*/"rightclick"){ + if (this.selectEnable && !this._isMoved)this.selectedIndex=index; + else this.changeCellState(cell,true,0); + }else if ((e.type===/*laya.events.Event.MOUSE_OVER*/"mouseover" || e.type===/*laya.events.Event.MOUSE_OUT*/"mouseout")&& this._selectedIndex!==index){ + this.changeCellState(cell,e.type===/*laya.events.Event.MOUSE_OVER*/"mouseover",0); + } + this.mouseHandler && this.mouseHandler.runWith([e,index]); + } + + /** + *@private + *改变单元格的可视状态。 + *@param cell 单元格对象。 + *@param visable 是否显示。 + *@param index 单元格的属性 index 值。 + */ + __proto.changeCellState=function(cell,visable,index){ + var selectBox=cell.getChildByName("selectBox"); + if (selectBox){ + this.selectEnable=true; + selectBox.visible=visable; + selectBox.index=index; + } + } + + /**@inheritDoc */ + __proto.changeSize=function(){ + laya.ui.Component.prototype.changeSize.call(this); + this.setContentSize(this.width,this.height); + if (this._scrollBar) + Laya.timer.once(10,this,this.onScrollBarChange); + } + + /** + *@private + *滚动条的 Event.CHANGE 事件侦听处理函数。 + */ + __proto.onScrollBarChange=function(e){ + this.runCallLater(this.changeCells); + var scrollValue=this._scrollBar.value; + var lineX=(this._isVertical ? this.repeatX :this.repeatY); + var lineY=(this._isVertical ? this.repeatY :this.repeatX); + var scrollLine=Math.floor(scrollValue / this._cellSize); + if (!this.cacheContent){ + var index=scrollLine *lineX; + if (index > this._startIndex){ + var num=index-this._startIndex; + var down=true; + var toIndex=this._startIndex+lineX *(lineY+1); + this._isMoved=true; + }else if (index < this._startIndex){ + num=this._startIndex-index; + down=false; + toIndex=this._startIndex-1; + this._isMoved=true; + } + for (var i=0;i < num;i++){ + if (down){ + var cell=this._cells.shift(); + this._cells[this._cells.length]=cell; + var cellIndex=toIndex+i; + }else { + cell=this._cells.pop(); + this._cells.unshift(cell); + cellIndex=toIndex-i; + }; + var pos=Math.floor(cellIndex / lineX)*this._cellSize; + this._isVertical ? cell.y=pos :cell.x=pos; + this.renderItem(cell,cellIndex); + } + this._startIndex=index; + this.changeSelectStatus(); + }else { + num=(lineY+1); + if (this._createdLine-scrollLine < num){ + this._createItems(this._createdLine,lineX,this._createdLine+num); + this._createdLine+=num; + this.renderItems(this._createdLine *lineX,0); + } + }; + var r=this._content.scrollRect; + if (this._isVertical){ + r.y=scrollValue; + }else { + r.x=scrollValue; + } + this._content.model && this._content.model.scrollRect(r.x,r.y,r.width,r.height); + this.repaint(); + } + + __proto.posCell=function(cell,cellIndex){ + if (!this._scrollBar)return; + var lineX=(this._isVertical ? this.repeatX :this.repeatY); + var lineY=(this._isVertical ? this.repeatY :this.repeatX); + var pos=Math.floor(cellIndex / lineX)*this._cellSize; + this._isVertical ? cell.y=pos :cell.x=pos; + } + + /** + *@private + *改变单元格的选择状态。 + */ + __proto.changeSelectStatus=function(){ + for (var i=0,n=this._cells.length;i < n;i++){ + this.changeCellState(this._cells[i],this._selectedIndex===this._startIndex+i,1); + } + } + + /** + *@private + *渲染单元格列表。 + */ + __proto.renderItems=function(from,to){ + (from===void 0)&& (from=0); + (to===void 0)&& (to=0); + for (var i=0,n=to || this._cells.length;i < n;i++){ + this.renderItem(this._cells[i],this._startIndex+i); + } + this.changeSelectStatus(); + } + + /** + *渲染一个单元格。 + *@param cell 需要渲染的单元格对象。 + *@param index 单元格索引。 + */ + __proto.renderItem=function(cell,index){ + if (index >=0 && index < this._array.length){ + cell.visible=true; + cell.dataSource=this._array[index]; + if (!this.cacheContent){ + this.posCell(cell,index); + } + if (this.hasListener(/*laya.events.Event.RENDER*/"render"))this.event(/*laya.events.Event.RENDER*/"render",[cell,index]); + if (this.renderHandler)this.renderHandler.runWith([cell,index]); + }else { + cell.visible=false; + cell.dataSource=null; + } + } + + /** + *刷新列表数据源。 + */ + __proto.refresh=function(){ + this.array=this._array; + } + + /** + *获取单元格数据源。 + *@param index 单元格索引。 + */ + __proto.getItem=function(index){ + if (index >-1 && index < this._array.length){ + return this._array[index]; + } + return null; + } + + /** + *修改单元格数据源。 + *@param index 单元格索引。 + *@param source 单元格数据源。 + */ + __proto.changeItem=function(index,source){ + if (index >-1 && index < this._array.length){ + this._array[index]=source; + if (index >=this._startIndex && index < this._startIndex+this._cells.length){ + this.renderItem(this.getCell(index),index); + } + } + } + + /** + *设置单元格数据源。 + *@param index 单元格索引。 + *@param source 单元格数据源。 + */ + __proto.setItem=function(index,source){ + this.changeItem(index,source); + } + + /** + *添加单元格数据源。 + *@param souce 数据源。 + */ + __proto.addItem=function(souce){ + this._array.push(souce); + this.array=this._array; + } + + /** + *添加单元格数据源到对应的数据索引处。 + *@param souce 单元格数据源。 + *@param index 索引。 + */ + __proto.addItemAt=function(souce,index){ + this._array.splice(index,0,souce); + this.array=this._array; + } + + /** + *通过数据源索引删除单元格数据源。 + *@param index 需要删除的数据源索引值。 + */ + __proto.deleteItem=function(index){ + this._array.splice(index,1); + this.array=this._array; + } + + /** + *通过可视单元格索引,获取单元格。 + *@param index 可视单元格索引。 + *@return 单元格对象。 + */ + __proto.getCell=function(index){ + this.runCallLater(this.changeCells); + if (index >-1 && this._cells){ + return this._cells[(index-this._startIndex)% this._cells.length]; + } + return null; + } + + /** + *

    滚动列表,以设定的数据索引对应的单元格为当前可视列表的第一项。

    + *@param index 单元格在数据列表中的索引。 + */ + __proto.scrollTo=function(index){ + if (this._scrollBar){ + var numX=this._isVertical ? this.repeatX :this.repeatY; + this._scrollBar.value=Math.floor(index / numX)*this._cellSize; + }else { + this.startIndex=index; + } + } + + /** + *

    缓动滚动列表,以设定的数据索引对应的单元格为当前可视列表的第一项。

    + *@param index 单元格在数据列表中的索引。 + *@param time 缓动时间。 + *@param complete 缓动结束回掉 + */ + __proto.tweenTo=function(index,time,complete){ + (time===void 0)&& (time=200); + if (this._scrollBar){ + var numX=this._isVertical ? this.repeatX :this.repeatY; + Tween.to(this._scrollBar,{value:Math.floor(index / numX)*this._cellSize},time,null,complete,0,true); + }else { + this.startIndex=index; + if (complete)complete.run(); + } + } + + /**@private */ + __proto._setCellChanged=function(){ + if (!this._cellChanged){ + this._cellChanged=true; + this.callLater(this.changeCells); + } + } + + /**@inheritDoc */ + __getset(0,__proto,'cacheAs',_super.prototype._$get_cacheAs,function(value){ + _super.prototype._$set_cacheAs.call(this,value); + if (this._scrollBar){ + this._$P.cacheAs=null; + if (value!=="none")this._scrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart); + else this._scrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart); + } + }); + + /** + *获取对 List 组件所包含的内容容器 Box 组件的引用。 + */ + __getset(0,__proto,'content',function(){ + return this._content; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._setCellChanged(); + }); + + /** + *单元格渲染器。 + *

    取值: + *

      + *
    1. 单元格类对象。
    2. + *
    3. UI 的 JSON 描述。
    4. + *

    + */ + __getset(0,__proto,'itemRender',function(){ + return this._itemRender; + },function(value){ + this._itemRender=value; + this._setCellChanged(); + }); + + /** + *垂直方向滚动条皮肤。 + */ + __getset(0,__proto,'vScrollBarSkin',function(){ + return this._scrollBar ? this._scrollBar.skin :null; + },function(value){ + this.removeChildByName("scrollBar"); + var scrollBar=new VScrollBar(); + scrollBar.name="scrollBar"; + scrollBar.right=0; + scrollBar.skin=value; + this.scrollBar=scrollBar; + this.addChild(scrollBar); + this._setCellChanged(); + }); + + /** + *列表的当前页码。 + */ + __getset(0,__proto,'page',function(){ + return this._page; + },function(value){ + this._page=value + if (this._array){ + this._page=value > 0 ? value :0; + this._page=this._page < this.totalPage ? this._page :this.totalPage-1; + this.startIndex=this._page *this.repeatX *this.repeatY; + } + }); + + /** + *水平方向滚动条皮肤。 + */ + __getset(0,__proto,'hScrollBarSkin',function(){ + return this._scrollBar ? this._scrollBar.skin :null; + },function(value){ + this.removeChildByName("scrollBar"); + var scrollBar=new HScrollBar(); + scrollBar.name="scrollBar"; + scrollBar.bottom=0; + scrollBar.skin=value; + this.scrollBar=scrollBar; + this.addChild(scrollBar); + this._setCellChanged(); + }); + + /** + *水平方向显示的单元格数量。 + */ + __getset(0,__proto,'repeatX',function(){ + return this._repeatX > 0 ? this._repeatX :this._repeatX2 > 0 ? this._repeatX2 :1; + },function(value){ + this._repeatX=value; + this._setCellChanged(); + }); + + /** + *获取对 List 组件所包含的滚动条 ScrollBar 组件的引用。 + */ + __getset(0,__proto,'scrollBar',function(){ + return this._scrollBar; + },function(value){ + if (this._scrollBar !=value){ + this._scrollBar=value; + if (value){ + this.addChild(this._scrollBar); + this._scrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange); + this._isVertical=this._scrollBar.isVertical; + } + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._setCellChanged(); + }); + + /** + *垂直方向显示的单元格数量。 + */ + __getset(0,__proto,'repeatY',function(){ + return this._repeatY > 0 ? this._repeatY :this._repeatY2 > 0 ? this._repeatY2 :1; + },function(value){ + this._repeatY=value; + this._setCellChanged(); + }); + + /** + *水平方向显示的单元格之间的间距(以像素为单位)。 + */ + __getset(0,__proto,'spaceX',function(){ + return this._spaceX; + },function(value){ + this._spaceX=value; + this._setCellChanged(); + }); + + /** + *垂直方向显示的单元格之间的间距(以像素为单位)。 + */ + __getset(0,__proto,'spaceY',function(){ + return this._spaceY; + },function(value){ + this._spaceY=value; + this._setCellChanged(); + }); + + /** + *表示当前选择的项索引。 + */ + __getset(0,__proto,'selectedIndex',function(){ + return this._selectedIndex; + },function(value){ + if (this._selectedIndex !=value){ + this._selectedIndex=value; + this.changeSelectStatus(); + this.event(/*laya.events.Event.CHANGE*/"change"); + this.selectHandler && this.selectHandler.runWith(value); + } + }); + + /** + *当前选中的单元格数据源。 + */ + __getset(0,__proto,'selectedItem',function(){ + return this._selectedIndex !=-1 ? this._array[this._selectedIndex] :null; + },function(value){ + this.selectedIndex=this._array.indexOf(value); + }); + + /** + *列表的数据总个数。 + */ + __getset(0,__proto,'length',function(){ + return this._array.length; + }); + + /** + *获取或设置当前选择的单元格对象。 + */ + __getset(0,__proto,'selection',function(){ + return this.getCell(this._selectedIndex); + },function(value){ + this.selectedIndex=this._startIndex+this._cells.indexOf(value); + }); + + /** + *当前显示的单元格列表的开始索引。 + */ + __getset(0,__proto,'startIndex',function(){ + return this._startIndex; + },function(value){ + this._startIndex=value > 0 ? value :0; + this.callLater(this.renderItems); + }); + + /** + *列表数据源。 + */ + __getset(0,__proto,'array',function(){ + return this._array; + },function(value){ + this.runCallLater(this.changeCells); + this._array=value || []; + var length=this._array.length; + this.totalPage=Math.ceil(length / (this.repeatX *this.repeatY)); + this._selectedIndex=this._selectedIndex < length ? this._selectedIndex :length-1; + this.startIndex=this._startIndex; + if (this._scrollBar){ + var numX=this._isVertical ? this.repeatX :this.repeatY; + var numY=this._isVertical ? this.repeatY :this.repeatX; + var lineCount=Math.ceil(length / numX); + var total=this._cellOffset > 0 ? this.totalPage+1 :this.totalPage; + if (total > 1){ + this._scrollBar.scrollSize=this._cellSize; + this._scrollBar.thumbPercent=numY / lineCount; + this._scrollBar.setScroll(0,(lineCount-numY)*this._cellSize+this._cellOffset,this._isVertical ? this._content.scrollRect.y :this._content.scrollRect.x); + this._scrollBar.target=this._content; + }else { + this._scrollBar.setScroll(0,0,0); + this._scrollBar.target=this._content; + } + } + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value); + else if ((value instanceof Array))this.array=value + else _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *单元格集合。 + */ + __getset(0,__proto,'cells',function(){ + this.runCallLater(this.changeCells); + return this._cells; + }); + + return List; + })(Box) + + + /** + *Panel 是一个面板容器类。 + */ + //class laya.ui.Panel extends laya.ui.Box + var Panel=(function(_super){ + function Panel(){ + this._content=null; + this._vScrollBar=null; + this._hScrollBar=null; + this._scrollChanged=false; + Panel.__super.call(this); + this.width=this.height=100; + this._content.optimizeScrollRect=true; + } + + __class(Panel,'laya.ui.Panel',_super); + var __proto=Panel.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + laya.ui.Component.prototype.destroy.call(this,destroyChild); + this._content && this._content.destroy(destroyChild); + this._vScrollBar && this._vScrollBar.destroy(destroyChild); + this._hScrollBar && this._hScrollBar.destroy(destroyChild); + this._vScrollBar=null; + this._hScrollBar=null; + this._content=null; + } + + /**@inheritDoc */ + __proto.destroyChildren=function(){ + this._content.destroyChildren(); + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + laya.display.Node.prototype.addChild.call(this,this._content=new Box()); + } + + /**@inheritDoc */ + __proto.addChild=function(child){ + child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setScrollChanged(); + return this._content.addChild(child); + } + + /** + *@private + *子对象的 Event.RESIZE 事件侦听处理函数。 + */ + __proto.onResize=function(){ + this._setScrollChanged(); + } + + /**@inheritDoc */ + __proto.addChildAt=function(child,index){ + child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setScrollChanged(); + return this._content.addChildAt(child,index); + } + + /**@inheritDoc */ + __proto.removeChild=function(child){ + child.off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setScrollChanged(); + return this._content.removeChild(child); + } + + /**@inheritDoc */ + __proto.removeChildAt=function(index){ + this.getChildAt(index).off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this._setScrollChanged(); + return this._content.removeChildAt(index); + } + + /**@inheritDoc */ + __proto.removeChildren=function(beginIndex,endIndex){ + (beginIndex===void 0)&& (beginIndex=0); + (endIndex===void 0)&& (endIndex=0x7fffffff); + for (var i=this._content.numChildren-1;i >-1;i--){ + this._content.removeChildAt(i); + } + this._setScrollChanged(); + return this; + } + + /**@inheritDoc */ + __proto.getChildAt=function(index){ + return this._content.getChildAt(index); + } + + /**@inheritDoc */ + __proto.getChildByName=function(name){ + return this._content.getChildByName(name); + } + + /**@inheritDoc */ + __proto.getChildIndex=function(child){ + return this._content.getChildIndex(child); + } + + /**@private */ + __proto.changeScroll=function(){ + this._scrollChanged=false; + var contentW=this.contentWidth; + var contentH=this.contentHeight; + var vscroll=this._vScrollBar; + var hscroll=this._hScrollBar; + var vShow=vscroll && contentH > this._height; + var hShow=hscroll && contentW > this._width; + var showWidth=vShow ? this._width-vscroll.width :this._width; + var showHeight=hShow ? this._height-hscroll.height :this._height; + if (vscroll){ + vscroll.x=this._width-vscroll.width; + vscroll.y=0; + vscroll.height=this._height-(hShow ? hscroll.height :0); + vscroll.scrollSize=Math.max(this._height *0.033,1); + vscroll.thumbPercent=showHeight / contentH; + vscroll.setScroll(0,contentH-showHeight,vscroll.value); + } + if (hscroll){ + hscroll.x=0; + hscroll.y=this._height-hscroll.height; + hscroll.width=this._width-(vShow ? vscroll.width :0); + hscroll.scrollSize=Math.max(this._width *0.033,1); + hscroll.thumbPercent=showWidth / contentW; + hscroll.setScroll(0,contentW-showWidth,hscroll.value); + } + } + + /**@inheritDoc */ + __proto.changeSize=function(){ + laya.ui.Component.prototype.changeSize.call(this); + this.setContentSize(this._width,this._height); + } + + /** + *@private + *设置内容的宽度、高度(以像素为单位)。 + *@param width 宽度。 + *@param height 高度。 + */ + __proto.setContentSize=function(width,height){ + var content=this._content; + content.width=width; + content.height=height; + content.scrollRect || (content.scrollRect=new Rectangle()); + content.scrollRect.setTo(0,0,width,height); + content.model&&content.model.scrollRect(0,0,width,height); + } + + /** + *@private + *滚动条的Event.MOUSE_DOWN事件侦听处理函数。事件侦听处理函数。 + *@param scrollBar 滚动条对象。 + *@param e Event 对象。 + */ + __proto.onScrollBarChange=function(scrollBar){ + var rect=this._content.scrollRect; + if (rect){ + var start=Math.round(scrollBar.value); + scrollBar.isVertical ? rect.y=start :rect.x=start; + this._content.model&&this._content.model.scrollRect(rect.x,rect.y,rect.width,rect.height); + } + } + + /** + *

    滚动内容容器至设定的垂直、水平方向滚动条位置。

    + *@param x 水平方向滚动条属性value值。滚动条位置数字。 + *@param y 垂直方向滚动条属性value值。滚动条位置数字。 + */ + __proto.scrollTo=function(x,y){ + (x===void 0)&& (x=0); + (y===void 0)&& (y=0); + if (this.vScrollBar)this.vScrollBar.value=y; + if (this.hScrollBar)this.hScrollBar.value=x; + } + + /** + *刷新滚动内容。 + */ + __proto.refresh=function(){ + this.changeScroll(); + } + + __proto.onScrollStart=function(){ + this._$P.cacheAs || (this._$P.cacheAs=_super.prototype._$get_cacheAs.call(this)); + _super.prototype._$set_cacheAs.call(this,"none"); + this._hScrollBar && this._hScrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd); + this._vScrollBar && this._vScrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd); + } + + __proto.onScrollEnd=function(){ + _super.prototype._$set_cacheAs.call(this,this._$P.cacheAs); + } + + /**@private */ + __proto._setScrollChanged=function(){ + if (!this._scrollChanged){ + this._scrollChanged=true; + this.callLater(this.changeScroll); + } + } + + /**@inheritDoc */ + __getset(0,__proto,'numChildren',function(){ + return this._content.numChildren; + }); + + /** + *水平方向滚动条皮肤。 + */ + __getset(0,__proto,'hScrollBarSkin',function(){ + return this._hScrollBar ? this._hScrollBar.skin :null; + },function(value){ + if (this._hScrollBar==null){ + laya.display.Node.prototype.addChild.call(this,this._hScrollBar=new HScrollBar()); + this._hScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange,[this._hScrollBar]); + this._hScrollBar.target=this._content; + this._setScrollChanged(); + } + this._hScrollBar.skin=value; + }); + + /** + *@private + *获取内容宽度(以像素为单位)。 + */ + __getset(0,__proto,'contentWidth',function(){ + var max=0; + for (var i=this._content.numChildren-1;i >-1;i--){ + var comp=this._content.getChildAt(i); + max=Math.max(comp.x+comp.width *comp.scaleX,max); + } + return max; + }); + + /** + *@private + *获取内容高度(以像素为单位)。 + */ + __getset(0,__proto,'contentHeight',function(){ + var max=0; + for (var i=this._content.numChildren-1;i >-1;i--){ + var comp=this._content.getChildAt(i); + max=Math.max(comp.y+comp.height *comp.scaleY,max); + } + return max; + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._setScrollChanged(); + }); + + /** + *水平方向滚动条对象。 + */ + __getset(0,__proto,'hScrollBar',function(){ + return this._hScrollBar; + }); + + /** + *获取内容容器对象。 + */ + __getset(0,__proto,'content',function(){ + return this._content; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._setScrollChanged(); + }); + + /** + *垂直方向滚动条皮肤。 + */ + __getset(0,__proto,'vScrollBarSkin',function(){ + return this._vScrollBar ? this._vScrollBar.skin :null; + },function(value){ + if (this._vScrollBar==null){ + laya.display.Node.prototype.addChild.call(this,this._vScrollBar=new VScrollBar()); + this._vScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange,[this._vScrollBar]); + this._vScrollBar.target=this._content; + this._setScrollChanged(); + } + this._vScrollBar.skin=value; + }); + + /** + *垂直方向滚动条对象。 + */ + __getset(0,__proto,'vScrollBar',function(){ + return this._vScrollBar; + }); + + /**@inheritDoc */ + __getset(0,__proto,'cacheAs',_super.prototype._$get_cacheAs,function(value){ + _super.prototype._$set_cacheAs.call(this,value); + this._$P.cacheAs=null; + if (value!=="none"){ + this._hScrollBar && this._hScrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart); + this._vScrollBar && this._vScrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart); + }else { + this._hScrollBar && this._hScrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart); + this._vScrollBar && this._vScrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart); + } + }); + + return Panel; + })(Box) + + + /** + *使用 HScrollBar (水平 ScrollBar )控件,可以在因数据太多而不能在显示区域完全显示时控制显示的数据部分。 + *@example 以下示例代码,创建了一个 HScrollBar 实例。 + *+ *package + *{ + *import laya.ui.HScrollBar; + *import laya.utils.Handler; + *public class HScrollBar_Example + *{ + *private var hScrollBar:HScrollBar; + *public function HScrollBar_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *hScrollBar=new HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。 + *hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。 + *hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。 + *hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。 + *hScrollBar.changeHandler=new Handler(this,onChange);//设置 hScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(hScrollBar);//将此 hScrollBar 对象添加到显示列表。 + *} + *private function onChange(value:Number):void + *{ + *trace("滚动条的位置: value="+value); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var hScrollBar; + *var res=["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"]; + *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *console.log("资源加载完成!"); + *hScrollBar=new laya.ui.HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。 + *hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。 + *hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。 + *hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。 + *hScrollBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 hScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(hScrollBar);//将此 hScrollBar 对象添加到显示列表。 + *} + *function onChange(value) + *{ + *console.log("滚动条的位置: value="+value); + *} + * + *+ *import HScrollBar=laya.ui.HScrollBar; + *import Handler=laya.utils.Handler; + *class HScrollBar_Example { + *private hScrollBar:HScrollBar; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *this.hScrollBar=new HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。 + *this.hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。 + *this.hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。 + *this.hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。 + *this.hScrollBar.changeHandler=new Handler(this,this.onChange);//设置 hScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(this.hScrollBar);//将此 hScrollBar 对象添加到显示列表。 + *} + *private onChange(value:number):void { + *console.log("滚动条的位置: value="+value); + *} + *} + * + */ + //class laya.ui.HScrollBar extends laya.ui.ScrollBar + var HScrollBar=(function(_super){ + function HScrollBar(){HScrollBar.__super.call(this);; + }; + + __class(HScrollBar,'laya.ui.HScrollBar',_super); + var __proto=HScrollBar.prototype; + /**@inheritDoc */ + __proto.initialize=function(){ + _super.prototype.initialize.call(this); + this.slider.isVertical=false; + } + + return HScrollBar; + })(ScrollBar) + + + /** + *Radio 控件使用户可在一组互相排斥的选择中做出一种选择。 + *用户一次只能选择 Radio 组中的一个成员。选择未选中的组成员将取消选择该组中当前所选的 Radio 控件。 + *@see laya.ui.RadioGroup + */ + //class laya.ui.Radio extends laya.ui.Button + var Radio=(function(_super){ + function Radio(skin,label){ + this._value=null; + (label===void 0)&& (label=""); + Radio.__super.call(this,skin,label); + } + + __class(Radio,'laya.ui.Radio',_super); + var __proto=Radio.prototype; + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._value=null; + } + + /**@inheritDoc */ + __proto.preinitialize=function(){ + laya.ui.Component.prototype.preinitialize.call(this); + this.toggle=false; + this._autoSize=false; + } + + /**@inheritDoc */ + __proto.initialize=function(){ + _super.prototype.initialize.call(this); + this.createText(); + this._text.align="left"; + this._text.valign="top"; + this._text.width=0; + this.on(/*laya.events.Event.CLICK*/"click",this,this.onClick); + } + + /** + *@private + *对象的Event.CLICK事件侦听处理函数。 + */ + __proto.onClick=function(e){ + this.selected=true; + } + + /** + *获取或设置 Radio 关联的可选用户定义值。 + */ + __getset(0,__proto,'value',function(){ + return this._value !=null ? this._value :this.label; + },function(obj){ + this._value=obj; + }); + + return Radio; + })(Button) + + + /** + *Group 是一个可以自动布局的项集合控件。 + *

    Group 的默认项对象为 Button 类实例。 + *GroupTabRadioGroup 的基类。

    + */ + //class laya.ui.UIGroup extends laya.ui.Box + var UIGroup=(function(_super){ + function UIGroup(labels,skin){ + this.selectHandler=null; + this._items=null; + this._selectedIndex=-1; + this._skin=null; + this._direction="horizontal"; + this._space=0; + this._labels=null; + this._labelColors=null; + this._labelStrokeColor=null; + this._strokeColors=null; + this._labelStroke=NaN; + this._labelSize=0; + this._labelBold=false; + this._labelPadding=null; + this._labelAlign=null; + this._stateNum=0; + this._labelChanged=false; + UIGroup.__super.call(this); + this.skin=skin; + this.labels=labels; + } + + __class(UIGroup,'laya.ui.UIGroup',_super); + var __proto=UIGroup.prototype; + Laya.imps(__proto,{"laya.ui.IItem":true}) + /**@inheritDoc */ + __proto.preinitialize=function(){ + this.mouseEnabled=true; + } + + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + laya.ui.Component.prototype.destroy.call(this,destroyChild); + this._items && (this._items.length=0); + this._items=null; + this.selectHandler=null; + } + + /** + *添加一个项对象,返回此项对象的索引id。 + * + *@param item 需要添加的项对象。 + *@param autoLayOut 是否自动布局,如果为true,会根据 directionspace 属性计算item的位置。 + *@return + */ + __proto.addItem=function(item,autoLayOut){ + (autoLayOut===void 0)&& (autoLayOut=true); + var display=item; + var index=this._items.length; + display.name="item"+index; + this.addChild(display); + this.initItems(); + if (autoLayOut && index > 0){ + var preItem=this._items [index-1]; + if (this._direction=="horizontal"){ + display.x=preItem.x+preItem.width+this._space; + }else { + display.y=preItem.y+preItem.height+this._space; + } + }else { + if (autoLayOut){ + display.x=0; + display.y=0; + } + } + return index; + } + + /** + *删除一个项对象。 + *@param item 需要删除的项对象。 + *@param autoLayOut 是否自动布局,如果为true,会根据 directionspace 属性计算item的位置。 + */ + __proto.delItem=function(item,autoLayOut){ + (autoLayOut===void 0)&& (autoLayOut=true); + var index=this._items.indexOf(item); + if (index !=-1){ + var display=item; + this.removeChild(display); + for (var i=index+1,n=this._items.length;i < n;i++){ + var child=this._items [i]; + child.name="item"+(i-1); + if (autoLayOut){ + if (this._direction=="horizontal"){ + child.x-=display.width+this._space; + }else { + child.y-=display.height+this._space; + } + } + } + this.initItems(); + if (this._selectedIndex >-1){ + var newIndex=0; + newIndex=this._selectedIndex < this._items.length ? this._selectedIndex :(this._selectedIndex-1); + this._selectedIndex=-1; + this.selectedIndex=newIndex; + } + } + } + + /** + *初始化项对象们。 + */ + __proto.initItems=function(){ + this._items || (this._items=[]); + this._items.length=0; + for (var i=0;i < 10000;i++){ + var item=this.getChildByName("item"+i); + if (item==null)break ; + this._items.push(item); + item.selected=(i===this._selectedIndex); + item.clickHandler=Handler.create(this,this.itemClick,[i],false); + } + } + + /** + *@private + *项对象的点击事件侦听处理函数。 + *@param index 项索引。 + */ + __proto.itemClick=function(index){ + this.selectedIndex=index; + } + + /** + *@private + *通过对象的索引设置项对象的 selected 属性值。 + *@param index 需要设置的项对象的索引。 + *@param selected 表示项对象的选中状态。 + */ + __proto.setSelect=function(index,selected){ + if (this._items && index >-1 && index < this._items.length)this._items[index].selected=selected; + } + + /** + *@private + *创建一个项显示对象。 + *@param skin 项对象的皮肤。 + *@param label 项对象标签。 + */ + __proto.createItem=function(skin,label){ + return null; + } + + /** + *@private + *更改项对象的属性值。 + */ + __proto.changeLabels=function(){ + this._labelChanged=false; + if (this._items){ + var left=0 + for (var i=0,n=this._items.length;i < n;i++){ + var btn=this._items [i]; + this._skin && (btn.skin=this._skin); + this._labelColors && (btn.labelColors=this._labelColors); + this._labelSize && (btn.labelSize=this._labelSize); + this._labelStroke && (btn.labelStroke=this._labelStroke); + this._labelStrokeColor && (btn.labelStrokeColor=this._labelStrokeColor); + this._strokeColors && (btn.strokeColors=this._strokeColors); + this._labelBold && (btn.labelBold=this._labelBold); + this._labelPadding && (btn.labelPadding=this._labelPadding); + this._labelAlign && (btn.labelAlign=this._labelAlign); + this._stateNum && (btn.stateNum=this._stateNum); + if (this._direction==="horizontal"){ + btn.y=0; + btn.x=left; + left+=btn.width+this._space; + }else { + btn.x=0; + btn.y=left; + left+=btn.height+this._space; + } + } + } + this.changeSize(); + } + + /**@inheritDoc */ + __proto.commitMeasure=function(){ + this.runCallLater(this.changeLabels); + } + + /**@private */ + __proto._setLabelChanged=function(){ + if (!this._labelChanged){ + this._labelChanged=true; + this.callLater(this.changeLabels); + } + } + + /** + *

    描边颜色,以字符串表示。

    + *默认值为 "#000000"(黑色); + *@see laya.display.Text.strokeColor() + */ + __getset(0,__proto,'labelStrokeColor',function(){ + return this._labelStrokeColor; + },function(value){ + if (this._labelStrokeColor !=value){ + this._labelStrokeColor=value; + this._setLabelChanged(); + } + }); + + /** + *@copy laya.ui.Image#skin + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this._setLabelChanged(); + } + }); + + /** + *表示当前选择的项索引。默认值为-1。 + */ + __getset(0,__proto,'selectedIndex',function(){ + return this._selectedIndex; + },function(value){ + if (this._selectedIndex !=value){ + this.setSelect(this._selectedIndex,false); + this._selectedIndex=value; + this.setSelect(value,true); + this.event(/*laya.events.Event.CHANGE*/"change"); + this.selectHandler && this.selectHandler.runWith(this._selectedIndex); + } + }); + + /** + *标签集合字符串。以逗号做分割,如"item0,item1,item2,item3,item4,item5"。 + */ + __getset(0,__proto,'labels',function(){ + return this._labels; + },function(value){ + if (this._labels !=value){ + this._labels=value; + this.removeChildren(); + this._setLabelChanged(); + if (this._labels){ + var a=this._labels.split(","); + for (var i=0,n=a.length;i < n;i++){ + var item=this.createItem(this._skin,a[i]); + item.name="item"+i; + this.addChild(item); + } + } + this.initItems(); + } + }); + + /** + *

    表示各个状态下的描边颜色。

    + *@see laya.display.Text.strokeColor() + */ + __getset(0,__proto,'strokeColors',function(){ + return this._strokeColors; + },function(value){ + if (this._strokeColors !=value){ + this._strokeColors=value; + this._setLabelChanged(); + } + }); + + /** + *@copy laya.ui.Button#labelColors() + */ + __getset(0,__proto,'labelColors',function(){ + return this._labelColors; + },function(value){ + if (this._labelColors !=value){ + this._labelColors=value; + this._setLabelChanged(); + } + }); + + /** + *

    描边宽度(以像素为单位)。

    + *默认值0,表示不描边。 + *@see laya.display.Text.stroke() + */ + __getset(0,__proto,'labelStroke',function(){ + return this._labelStroke; + },function(value){ + if (this._labelStroke !=value){ + this._labelStroke=value; + this._setLabelChanged(); + } + }); + + /** + *表示按钮文本标签的字体大小。 + */ + __getset(0,__proto,'labelSize',function(){ + return this._labelSize; + },function(value){ + if (this._labelSize !=value){ + this._labelSize=value; + this._setLabelChanged(); + } + }); + + /** + *表示按钮文本标签的字体大小。 + */ + __getset(0,__proto,'stateNum',function(){ + return this._stateNum; + },function(value){ + if (this._stateNum !=value){ + this._stateNum=value; + this._setLabelChanged(); + } + }); + + /** + *表示按钮文本标签是否为粗体字。 + */ + __getset(0,__proto,'labelBold',function(){ + return this._labelBold; + },function(value){ + if (this._labelBold !=value){ + this._labelBold=value; + this._setLabelChanged(); + } + }); + + /** + *表示按钮文本标签的边距。 + *

    格式:"上边距,右边距,下边距,左边距"。

    + */ + __getset(0,__proto,'labelPadding',function(){ + return this._labelPadding; + },function(value){ + if (this._labelPadding !=value){ + this._labelPadding=value; + this._setLabelChanged(); + } + }); + + /** + *布局方向。 + *

    默认值为"horizontal"。

    + *

    取值: + *

  • "horizontal":表示水平布局。
  • + *
  • "vertical":表示垂直布局。
  • + *

    + */ + __getset(0,__proto,'direction',function(){ + return this._direction; + },function(value){ + this._direction=value; + this._setLabelChanged(); + }); + + /** + *项对象们之间的间隔(以像素为单位)。 + */ + __getset(0,__proto,'space',function(){ + return this._space; + },function(value){ + this._space=value; + this._setLabelChanged(); + }); + + /** + *项对象们的存放数组。 + */ + __getset(0,__proto,'items',function(){ + return this._items; + }); + + /** + *获取或设置当前选择的项对象。 + */ + __getset(0,__proto,'selection',function(){ + return this._selectedIndex >-1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] :null; + },function(value){ + this.selectedIndex=this._items.indexOf(value); + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value); + else if ((value instanceof Array))this.labels=(value).join(","); + else _super.prototype._$set_dataSource.call(this,value); + }); + + return UIGroup; + })(Box) + + + /** + *使用 HSlider 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。 + *

    HSlider 控件采用水平方向。滑块轨道从左向右扩展,而标签位于轨道的顶部或底部。

    + * + *@example 以下示例代码,创建了一个 HSlider 实例。 + *+ *package + *{ + *import laya.ui.HSlider; + *import laya.utils.Handler; + *public class HSlider_Example + *{ + *private var hSlider:HSlider; + *public function HSlider_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/hslider.png","resource/ui/hslider$bar.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *hSlider=new HSlider();//创建一个 HSlider 类的实例对象 hSlider 。 + *hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。 + *hSlider.min=0;//设置 hSlider 最低位置值。 + *hSlider.max=10;//设置 hSlider 最高位置值。 + *hSlider.value=2;//设置 hSlider 当前位置值。 + *hSlider.tick=1;//设置 hSlider 刻度值。 + *hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。 + *hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。 + *hSlider.changeHandler=new Handler(this,onChange);//设置 hSlider 位置变化处理器。 + *Laya.stage.addChild(hSlider);//把 hSlider 添加到显示列表。 + *} + *private function onChange(value:Number):void + *{ + *trace("滑块的位置: value="+value); + *} + *} + *} + * + *+ *Laya.init(640,800,"canvas");//设置游戏画布宽高、渲染模式 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var hSlider; + *var res=["resource/ui/hslider.png","resource/ui/hslider$bar.png"]; + *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete)); + *function onLoadComplete(){ + *console.log("资源加载完成!"); + *hSlider=new laya.ui.HSlider();//创建一个 HSlider 类的实例对象 hSlider 。 + *hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。 + *hSlider.min=0;//设置 hSlider 最低位置值。 + *hSlider.max=10;//设置 hSlider 最高位置值。 + *hSlider.value=2;//设置 hSlider 当前位置值。 + *hSlider.tick=1;//设置 hSlider 刻度值。 + *hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。 + *hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。 + *hSlider.changeHandler=new laya.utils.Handler(this,onChange);//设置 hSlider 位置变化处理器。 + *Laya.stage.addChild(hSlider);//把 hSlider 添加到显示列表。 + *} + *function onChange(value) + *{ + *console.log("滑块的位置: value="+value); + *} + * + *+ *import Handler=laya.utils.Handler; + *import HSlider=laya.ui.HSlider; + *class HSlider_Example { + *private hSlider:HSlider; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/hslider.png","resource/ui/hslider$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *this.hSlider=new HSlider();//创建一个 HSlider 类的实例对象 hSlider 。 + *this.hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。 + *this.hSlider.min=0;//设置 hSlider 最低位置值。 + *this.hSlider.max=10;//设置 hSlider 最高位置值。 + *this.hSlider.value=2;//设置 hSlider 当前位置值。 + *this.hSlider.tick=1;//设置 hSlider 刻度值。 + *this.hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。 + *this.hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。 + *this.hSlider.changeHandler=new Handler(this,this.onChange);//设置 hSlider 位置变化处理器。 + *Laya.stage.addChild(this.hSlider);//把 hSlider 添加到显示列表。 + *} + *private onChange(value:number):void { + *console.log("滑块的位置: value="+value); + *} + *} + * + * + *@see laya.ui.Slider + */ + //class laya.ui.HSlider extends laya.ui.Slider + var HSlider=(function(_super){ + /** + *创建一个 HSlider 类实例。 + *@param skin 皮肤。 + */ + function HSlider(skin){ + HSlider.__super.call(this,skin); + this.isVertical=false; + } + + __class(HSlider,'laya.ui.HSlider',_super); + return HSlider; + })(Slider) + + + /** + *Tree 控件使用户可以查看排列为可扩展树的层次结构数据。 + * + *@example 以下示例代码,创建了一个 Tree 实例。 + *+ *package + *{ + *import laya.ui.Tree; + *import laya.utils.Browser; + *import laya.utils.Handler; + *public class Tree_Example + *{ + *public function Tree_Example() + *{ + *Laya.init(640,800); + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder.png","resource/ui/clip_tree_arrow.png"],Handler.create(this,onLoadComplete)); + *} + *private function onLoadComplete():void + *{ + *var xmlString:String;//创建一个xml字符串,用于存储树结构数据。 + *xmlString="<root><item label='box1'><abc label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/><abc label='child5'/></item><item label='box2'><abc label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/></item></root>"; + *var domParser:*=new Browser.window.DOMParser();//创建一个DOMParser实例domParser。 + *var xml:*=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。 + *var tree:Tree=new Tree();//创建一个 Tree 类的实例对象 tree 。 + *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。 + *tree.itemRender=Item;//设置 tree 的项渲染器。 + *tree.xml=xml;//设置 tree 的树结构数据。 + *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。 + *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。 + *tree.width=200;//设置 tree 的宽度。 + *tree.height=100;//设置 tree 的高度。 + *Laya.stage.addChild(tree);//将 tree 添加到显示列表。 + *} + *} + *} + *import laya.ui.Box; + *import laya.ui.Clip; + *import laya.ui.Label; + *class Item extends Box + *{ + *public function Item() + *{ + *this.name="render"; + *this.right=0; + *this.left=0; + *var selectBox:Clip=new Clip("resource/ui/clip_selectBox.png",1,2); + *selectBox.name="selectBox"; + *selectBox.height=24; + *selectBox.x=13; + *selectBox.y=0; + *selectBox.left=12; + *addChild(selectBox); + *var folder:Clip=new Clip("resource/ui/clip_tree_folder.png",1,3); + *folder.name="folder"; + *folder.x=14; + *folder.y=4; + *addChild(folder); + *var label:Label=new Label("treeItem"); + *label.name="label"; + *label.color="#ffff00"; + *label.width=150; + *label.height=22; + *label.x=33; + *label.y=1; + *label.left=33; + *label.right=0; + *addChild(label); + *var arrow:Clip=new Clip("resource/ui/clip_tree_arrow.png",1,2); + *arrow.name="arrow"; + *arrow.x=0; + *arrow.y=5; + *addChild(arrow); + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高、渲染模式 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder.png","resource/ui/clip_tree_arrow.png"]; + *Laya.loader.load(res,new laya.utils.Handler(this,onLoadComplete)); + *function onLoadComplete(){ + *var xmlString;//创建一个xml字符串,用于存储树结构数据。 + *xmlString="<root><item label='box1'><abc label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/><abc label='child5'/></item><item label='box2'><abc label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/></item></root>"; + *var domParser=new laya.utils.Browser.window.DOMParser();//创建一个DOMParser实例domParser。 + *var xml=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。 + *var tree=new laya.ui.Tree();//创建一个 Tree 类的实例对象 tree 。 + *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。 + *tree.itemRender=mypackage.treeExample.Item;//设置 tree 的项渲染器。 + *tree.xml=xml;//设置 tree 的树结构数据。 + *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。 + *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。 + *tree.width=200;//设置 tree 的宽度。 + *tree.height=100;//设置 tree 的高度。 + *Laya.stage.addChild(tree);//将 tree 添加到显示列表。 + *} + *(function (_super){ + *function Item(){ + *Item.__super.call(this);//初始化父类。 + *this.right=0; + *this.left=0; + *var selectBox=new laya.ui.Clip("resource/ui/clip_selectBox.png",1,2); + *selectBox.name="selectBox";//设置 selectBox 的name 为“selectBox”时,将被识别为树结构的项的背景。2帧:悬停时背景、选中时背景。 + *selectBox.height=24; + *selectBox.x=13; + *selectBox.y=0; + *selectBox.left=12; + *this.addChild(selectBox);//需要使用this.访问父类的属性或方法。 + *var folder=new laya.ui.Clip("resource/ui/clip_tree_folder.png",1,3); + *folder.name="folder";//设置 folder 的name 为“folder”时,将被识别为树结构的文件夹开启状态图表。2帧:折叠状态、打开状态。 + *folder.x=14; + *folder.y=4; + *this.addChild(folder); + *var label=new laya.ui.Label("treeItem"); + *label.name="label";//设置 label 的name 为“label”时,此值将用于树结构数据赋值。 + *label.color="#ffff00"; + *label.width=150; + *label.height=22; + *label.x=33; + *label.y=1; + *label.left=33; + *label.right=0; + *this.addChild(label); + *var arrow=new laya.ui.Clip("resource/ui/clip_tree_arrow.png",1,2); + *arrow.name="arrow";//设置 arrow 的name 为“arrow”时,将被识别为树结构的文件夹开启状态图表。2帧:折叠状态、打开状态。 + *arrow.x=0; + *arrow.y=5; + *this.addChild(arrow); + *}; + *Laya.class(Item,"mypackage.treeExample.Item",_super);//注册类 Item 。 + *})(laya.ui.Box); + * + *+ *import Tree=laya.ui.Tree; + *import Browser=laya.utils.Browser; + *import Handler=laya.utils.Handler; + *class Tree_Example { + *constructor(){ + *Laya.init(640,800); + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder * . * png","resource/ui/clip_tree_arrow.png"],Handler.create(this,this.onLoadComplete)); + *} + *private onLoadComplete():void { + *var xmlString:String;//创建一个xml字符串,用于存储树结构数据。 + *xmlString="<root><item label='box1'><abc label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/><abc label='child5'/></item><item label='box2'><abc * label='child1'/><abc label='child2'/><abc label='child3'/><abc label='child4'/></item></root>"; + *var domParser:any=new Browser.window.DOMParser();//创建一个DOMParser实例domParser。 + *var xml:any=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。 + *var tree:Tree=new Tree();//创建一个 Tree 类的实例对象 tree 。 + *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。 + *tree.itemRender=Item;//设置 tree 的项渲染器。 + *tree.xml=xml;//设置 tree 的树结构数据。 + *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。 + *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。 + *tree.width=200;//设置 tree 的宽度。 + *tree.height=100;//设置 tree 的高度。 + *Laya.stage.addChild(tree);//将 tree 添加到显示列表。 + *} + *} + *import Box=laya.ui.Box; + *import Clip=laya.ui.Clip; + *import Label=laya.ui.Label; + *class Item extends Box { + *constructor(){ + *super(); + *this.name="render"; + *this.right=0; + *this.left=0; + *var selectBox:Clip=new Clip("resource/ui/clip_selectBox.png",1,2); + *selectBox.name="selectBox"; + *selectBox.height=24; + *selectBox.x=13; + *selectBox.y=0; + *selectBox.left=12; + *this.addChild(selectBox); + *var folder:Clip=new Clip("resource/ui/clip_tree_folder.png",1,3); + *folder.name="folder"; + *folder.x=14; + *folder.y=4; + *this.addChild(folder); + *var label:Label=new Label("treeItem"); + *label.name="label"; + *label.color="#ffff00"; + *label.width=150; + *label.height=22; + *label.x=33; + *label.y=1; + *label.left=33; + *label.right=0; + *this.addChild(label); + *var arrow:Clip=new Clip("resource/ui/clip_tree_arrow.png",1,2); + *arrow.name="arrow"; + *arrow.x=0; + *arrow.y=5; + *this.addChild(arrow); + *} + *} + * + */ + //class laya.ui.Tree extends laya.ui.Box + var Tree=(function(_super){ + function Tree(){ + this._list=null; + this._source=null; + this._renderHandler=null; + this._spaceLeft=10; + this._spaceBottom=0; + this._keepStatus=true; + Tree.__super.call(this); + this.width=this.height=200; + } + + __class(Tree,'laya.ui.Tree',_super); + var __proto=Tree.prototype; + Laya.imps(__proto,{"laya.ui.IRender":true}) + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + laya.ui.Component.prototype.destroy.call(this,destroyChild); + this._list && this._list.destroy(destroyChild); + this._list=null; + this._source=null; + this._renderHandler=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._list=new List()); + this._list.renderHandler=Handler.create(this,this.renderItem,null,false); + this._list.repeatX=1; + this._list.on(/*laya.events.Event.CHANGE*/"change",this,this.onListChange); + } + + /** + *@private + *此对象包含的List实例的Event.CHANGE事件侦听处理函数。 + */ + __proto.onListChange=function(e){ + this.event(/*laya.events.Event.CHANGE*/"change"); + } + + /** + *@private + *获取数据源集合。 + */ + __proto.getArray=function(){ + var arr=[]; + var item; + /*for each*/for(var $each_item in this._source){ + item=this._source[$each_item]; + if (this.getParentOpenStatus(item)){ + item.x=this._spaceLeft *this.getDepth(item); + arr.push(item); + } + } + return arr; + } + + /** + *@private + *获取项对象的深度。 + */ + __proto.getDepth=function(item,num){ + (num===void 0)&& (num=0); + if (item.nodeParent==null)return num; + else return this.getDepth(item.nodeParent,num+1); + } + + /** + *@private + *获取项对象的上一级的打开状态。 + */ + __proto.getParentOpenStatus=function(item){ + var parent=item.nodeParent; + if (parent==null){ + return true; + }else { + if (parent.isOpen){ + if (parent.nodeParent !=null)return this.getParentOpenStatus(parent); + else return true; + }else { + return false; + } + } + } + + /** + *@private + *渲染一个项对象。 + *@param cell 一个项对象。 + *@param index 项的索引。 + */ + __proto.renderItem=function(cell,index){ + var item=cell.dataSource; + if (item){ + cell.left=item.x; + var arrow=cell.getChildByName("arrow"); + if (arrow){ + if (item.hasChild){ + arrow.visible=true; + arrow.index=item.isOpen ? 1 :0; + arrow.tag=index; + arrow.off(/*laya.events.Event.CLICK*/"click",this,this.onArrowClick); + arrow.on(/*laya.events.Event.CLICK*/"click",this,this.onArrowClick); + }else { + arrow.visible=false; + } + }; + var folder=cell.getChildByName("folder"); + if (folder){ + if (folder.clipY==2){ + folder.index=item.isDirectory ? 0 :1; + }else { + folder.index=item.isDirectory ? item.isOpen ? 1 :0 :2; + } + } + this._renderHandler && this._renderHandler.runWith([cell,index]); + } + } + + /** + *@private + */ + __proto.onArrowClick=function(e){ + var arrow=e.currentTarget; + var index=arrow.tag; + this._list.array[index].isOpen=!this._list.array[index].isOpen; + this._list.array=this.getArray(); + } + + /** + *设置指定项索引的项对象的打开状态。 + *@param index 项索引。 + *@param isOpen 是否处于打开状态。 + */ + __proto.setItemState=function(index,isOpen){ + if (!this._list.array[index])return; + this._list.array[index].isOpen=isOpen; + this._list.array=this.getArray(); + } + + /** + *刷新项列表。 + */ + __proto.fresh=function(){ + this._list.array=this.getArray(); + this.repaint(); + } + + /** + *@private + *解析并处理XML类型的数据源。 + */ + __proto.parseXml=function(xml,source,nodeParent,isRoot){ + var obj; + var list=xml.childNodes; + var childCount=list.length; + if (!isRoot){ + obj={}; + var list2=xml.attributes; + var attrs; + /*for each*/for(var $each_attrs in list2){ + attrs=list2[$each_attrs]; + var prop=attrs.nodeName; + var value=attrs.nodeValue; + obj[prop]=value=="true" ? true :value=="false" ? false :value; + } + obj.nodeParent=nodeParent; + if (childCount > 0)obj.isDirectory=true; + obj.hasChild=childCount > 0; + source.push(obj); + } + for (var i=0;i < childCount;i++){ + var node=list[i]; + this.parseXml(node,source,obj,false); + } + } + + /** + *@private + *处理数据项的打开状态。 + */ + __proto.parseOpenStatus=function(oldSource,newSource){ + for (var i=0,n=newSource.length;i < n;i++){ + var newItem=newSource[i]; + if (newItem.isDirectory){ + for (var j=0,m=oldSource.length;j < m;j++){ + var oldItem=oldSource[j]; + if (oldItem.isDirectory && this.isSameParent(oldItem,newItem)&& newItem.label==oldItem.label){ + newItem.isOpen=oldItem.isOpen; + break ; + } + } + } + } + } + + /** + *@private + *判断两个项对象在树结构中的父节点是否相同。 + *@param item1 项对象。 + *@param item2 项对象。 + *@return 如果父节点相同值为true,否则值为false。 + */ + __proto.isSameParent=function(item1,item2){ + if (item1.nodeParent==null && item2.nodeParent==null)return true; + else if (item1.nodeParent==null || item2.nodeParent==null)return false + else { + if (item1.nodeParent.label==item2.nodeParent.label)return this.isSameParent(item1.nodeParent,item2.nodeParent); + else return false; + } + } + + /** + *更新项列表,显示指定键名的数据项。 + *@param key 键名。 + */ + __proto.filter=function(key){ + if (Boolean(key)){ + var result=[]; + this.getFilterSource(this._source,result,key); + this._list.array=result; + }else { + this._list.array=this.getArray(); + } + } + + /** + *@private + *获取数据源中指定键名的值。 + */ + __proto.getFilterSource=function(array,result,key){ + key=key.toLocaleLowerCase(); + var item; + /*for each*/for(var $each_item in array){ + item=array[$each_item]; + if (!item.isDirectory && String(item.label).toLowerCase().indexOf(key)>-1){ + item.x=0; + result.push(item); + } + if (item.child && item.child.length > 0){ + this.getFilterSource(item.child,result,key); + } + } + } + + /** + *每一项之间的间隔距离(以像素为单位)。 + */ + __getset(0,__proto,'spaceBottom',function(){ + return this._list.spaceY; + },function(value){ + this._list.spaceY=value; + }); + + /** + *数据源发生变化后,是否保持之前打开状态,默认为true。 + *

    取值: + *

  • true:保持之前打开状态。
  • + *
  • false:不保持之前打开状态。
  • + *

    + */ + __getset(0,__proto,'keepStatus',function(){ + return this._keepStatus; + },function(value){ + this._keepStatus=value; + }); + + /** + *此对象包含的List实例的单元格渲染器。 + *

    取值: + *

      + *
    1. 单元格类对象。
    2. + *
    3. UI 的 JSON 描述。
    4. + *

    + */ + __getset(0,__proto,'itemRender',function(){ + return this._list.itemRender; + },function(value){ + this._list.itemRender=value; + }); + + /** + *列表数据源,只包含当前可视节点数据。 + */ + __getset(0,__proto,'array',function(){ + return this._list.array; + },function(value){ + if (this._keepStatus && this._list.array && value){ + this.parseOpenStatus(this._list.array,value); + } + this._source=value; + this._list.array=this.getArray(); + }); + + /** + *单元格鼠标事件处理器。 + *

    默认返回参数(e:Event,index:int)。

    + */ + __getset(0,__proto,'mouseHandler',function(){ + return this._list.mouseHandler; + },function(value){ + this._list.mouseHandler=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + _super.prototype._$set_dataSource.call(this,value); + }); + + /** + *数据源,全部节点数据。 + */ + __getset(0,__proto,'source',function(){ + return this._source; + }); + + /**滚动条*/ + __getset(0,__proto,'scrollBar',function(){ + return this._list.scrollBar; + }); + + /** + *此对象包含的List实例对象。 + */ + __getset(0,__proto,'list',function(){ + return this._list; + }); + + /** + *滚动条皮肤。 + */ + __getset(0,__proto,'scrollBarSkin',function(){ + return this._list.vScrollBarSkin; + },function(value){ + this._list.vScrollBarSkin=value; + }); + + /** + *Tree 实例的渲染处理器。 + */ + __getset(0,__proto,'renderHandler',function(){ + return this._renderHandler; + },function(value){ + this._renderHandler=value; + }); + + /** + *表示当前选择的项索引。 + */ + __getset(0,__proto,'selectedIndex',function(){ + return this._list.selectedIndex; + },function(value){ + this._list.selectedIndex=value; + }); + + /** + *左侧缩进距离(以像素为单位)。 + */ + __getset(0,__proto,'spaceLeft',function(){ + return this._spaceLeft; + },function(value){ + this._spaceLeft=value; + }); + + /** + *当前选中的项对象的数据源。 + */ + __getset(0,__proto,'selectedItem',function(){ + return this._list.selectedItem; + },function(value){ + this._list.selectedItem=value; + }); + + /** + *@inheritDoc + */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._list.width=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._list.height=value; + }); + + /** + *xml结构的数据源。 + */ + __getset(0,__proto,'xml',null,function(value){ + var arr=[]; + this.parseXml(value.childNodes[0],arr,null,true); + this.array=arr; + }); + + /** + *表示选择的树节点项的path属性值。 + */ + __getset(0,__proto,'selectedPath',function(){ + if (this._list.selectedItem){ + return this._list.selectedItem.path; + } + return null; + }); + + return Tree; + })(Box) + + + /** + *ViewStack 类用于视图堆栈类,用于视图的显示等设置处理。 + */ + //class laya.ui.ViewStack extends laya.ui.Box + var ViewStack=(function(_super){ + function ViewStack(){ + this._items=null; + this._selectedIndex=0; + ViewStack.__super.call(this); + this._setIndexHandler=Handler.create(this,this.setIndex,null,false); + } + + __class(ViewStack,'laya.ui.ViewStack',_super); + var __proto=ViewStack.prototype; + Laya.imps(__proto,{"laya.ui.IItem":true}) + /** + *批量设置视图对象。 + *@param views 视图对象数组。 + */ + __proto.setItems=function(views){ + this.removeChildren(); + var index=0; + for (var i=0,n=views.length;i < n;i++){ + var item=views[i]; + if (item){ + item.name="item"+index; + this.addChild(item); + index++; + } + } + this.initItems(); + } + + /** + *添加视图。 + *@internal 添加视图对象,并设置此视图对象的name 属性。 + *@param view 需要添加的视图对象。 + */ + __proto.addItem=function(view){ + view.name="item"+this._items.length; + this.addChild(view); + this.initItems(); + } + + /** + *初始化视图对象集合。 + */ + __proto.initItems=function(){ + this._items=[]; + for (var i=0;i < 10000;i++){ + var item=this.getChildByName("item"+i); + if (item==null){ + break ; + } + this._items.push(item); + item.visible=(i==this._selectedIndex); + } + } + + /** + *@private + *通过对象的索引设置项对象的 selected 属性值。 + *@param index 需要设置的对象的索引。 + *@param selected 表示对象的选中状态。 + */ + __proto.setSelect=function(index,selected){ + if (this._items && index >-1 && index < this._items.length){ + this._items[index].visible=selected; + } + } + + /** + *@private + *设置属性selectedIndex的值。 + *@param index 选中项索引值。 + */ + __proto.setIndex=function(index){ + this.selectedIndex=index; + } + + /**@inheritDoc */ + __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){ + this._dataSource=value; + if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string')){ + this.selectedIndex=parseInt(value); + }else { + for (var prop in this._dataSource){ + if (this.hasOwnProperty(prop)){ + this[prop]=this._dataSource[prop]; + } + } + } + }); + + /** + *表示当前视图索引。 + */ + __getset(0,__proto,'selectedIndex',function(){ + return this._selectedIndex; + },function(value){ + if (this._selectedIndex !=value){ + this.setSelect(this._selectedIndex,false); + this._selectedIndex=value; + this.setSelect(this._selectedIndex,true); + } + }); + + /** + *获取或设置当前选择的项对象。 + */ + __getset(0,__proto,'selection',function(){ + return this._selectedIndex >-1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] :null; + },function(value){ + this.selectedIndex=this._items.indexOf(value); + }); + + /** + *视图集合数组。 + */ + __getset(0,__proto,'items',function(){ + return this._items; + }); + + /** + *索引设置处理器。 + *

    默认回调参数:index:int

    + */ + __getset(0,__proto,'setIndexHandler',function(){ + return this._setIndexHandler; + },function(value){ + this._setIndexHandler=value; + }); + + return ViewStack; + })(Box) + + + /** + * + *使用 VScrollBar (垂直 ScrollBar )控件,可以在因数据太多而不能在显示区域完全显示时控制显示的数据部分。 + * + *@example 以下示例代码,创建了一个 VScrollBar 实例。 + *+ *package + *{ + *import laya.ui.vScrollBar; + *import laya.ui.VScrollBar; + *import laya.utils.Handler; + *public class VScrollBar_Example + *{ + *private var vScrollBar:VScrollBar; + *public function VScrollBar_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,onLoadComplete)); + *} + *private function onLoadComplete():void + *{ + *vScrollBar=new VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。 + *vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。 + *vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。 + *vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。 + *vScrollBar.changeHandler=new Handler(this,onChange);//设置 vScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(vScrollBar);//将此 vScrollBar 对象添加到显示列表。 + *} + *private function onChange(value:Number):void + *{ + *trace("滚动条的位置: value="+value); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var vScrollBar; + *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"]; + *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *vScrollBar=new laya.ui.VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。 + *vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。 + *vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。 + *vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。 + *vScrollBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 vScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(vScrollBar);//将此 vScrollBar 对象添加到显示列表。 + *} + *function onChange(value){ + *console.log("滚动条的位置: value="+value); + *} + * + *+ *import VScrollBar=laya.ui.VScrollBar; + *import Handler=laya.utils.Handler; + *class VScrollBar_Example { + *private vScrollBar:VScrollBar; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,this.onLoadComplete)); + *} + *private onLoadComplete():void { + *this.vScrollBar=new VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。 + *this.vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。 + *this.vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。 + *this.vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。 + *this.vScrollBar.changeHandler=new Handler(this,this.onChange);//设置 vScrollBar 的滚动变化处理器。 + *Laya.stage.addChild(this.vScrollBar);//将此 vScrollBar 对象添加到显示列表。 + *} + *private onChange(value:number):void { + *console.log("滚动条的位置: value="+value); + *} + *} + * + */ + //class laya.ui.VScrollBar extends laya.ui.ScrollBar + var VScrollBar=(function(_super){ + function VScrollBar(){VScrollBar.__super.call(this);; + }; + + __class(VScrollBar,'laya.ui.VScrollBar',_super); + return VScrollBar; + })(ScrollBar) + + + /** + *TextInput 类用于创建显示对象以显示和输入文本。 + * + *@example 以下示例代码,创建了一个 TextInput 实例。 + *+ *package + *{ + *import laya.display.Stage; + *import laya.ui.TextInput; + *import laya.utils.Handler; + *public class TextInput_Example + *{ + *public function TextInput_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *var textInput:TextInput=new TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。 + *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。 + *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。 + *textInput.color="#008fff";//设置 textInput 的文本颜色。 + *textInput.font="Arial";//设置 textInput 的文本字体。 + *textInput.bold=true;//设置 textInput 的文本显示为粗体。 + *textInput.fontSize=30;//设置 textInput 的字体大小。 + *textInput.wordWrap=true;//设置 textInput 的文本自动换行。 + *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。 + *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。 + *textInput.width=300;//设置 textInput 的宽度。 + *textInput.height=200;//设置 textInput 的高度。 + *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。 + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load(["resource/ui/input.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *var textInput=new laya.ui.TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。 + *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。 + *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。 + *textInput.color="#008fff";//设置 textInput 的文本颜色。 + *textInput.font="Arial";//设置 textInput 的文本字体。 + *textInput.bold=true;//设置 textInput 的文本显示为粗体。 + *textInput.fontSize=30;//设置 textInput 的字体大小。 + *textInput.wordWrap=true;//设置 textInput 的文本自动换行。 + *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。 + *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。 + *textInput.width=300;//设置 textInput 的宽度。 + *textInput.height=200;//设置 textInput 的高度。 + *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。 + *} + * + *+ *import Stage=laya.display.Stage; + *import TextInput=laya.ui.TextInput; + *import Handler=laya.utils.Handler; + *class TextInput_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *var textInput:TextInput=new TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。 + *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。 + *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。 + *textInput.color="#008fff";//设置 textInput 的文本颜色。 + *textInput.font="Arial";//设置 textInput 的文本字体。 + *textInput.bold=true;//设置 textInput 的文本显示为粗体。 + *textInput.fontSize=30;//设置 textInput 的字体大小。 + *textInput.wordWrap=true;//设置 textInput 的文本自动换行。 + *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。 + *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。 + *textInput.width=300;//设置 textInput 的宽度。 + *textInput.height=200;//设置 textInput 的高度。 + *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。 + *} + *} + * + */ + //class laya.ui.TextInput extends laya.ui.Label + var TextInput=(function(_super){ + function TextInput(text){ + this._bg=null; + this._skin=null; + TextInput.__super.call(this); + (text===void 0)&& (text=""); + this.text=text; + this.skin=this.skin; + } + + __class(TextInput,'laya.ui.TextInput',_super); + var __proto=TextInput.prototype; + /**@inheritDoc */ + __proto.preinitialize=function(){ + this.mouseEnabled=true; + } + + /**@inheritDoc */ + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._bg && this._bg.destroy(); + this._bg=null; + } + + /**@inheritDoc */ + __proto.createChildren=function(){ + this.addChild(this._tf=new Input()); + this._tf.padding=Styles.inputLabelPadding; + this._tf.on(/*laya.events.Event.INPUT*/"input",this,this._onInput); + this._tf.on(/*laya.events.Event.ENTER*/"enter",this,this._onEnter); + this._tf.on(/*laya.events.Event.BLUR*/"blur",this,this._onBlur); + this._tf.on(/*laya.events.Event.FOCUS*/"focus",this,this._onFocus); + } + + /** + *@private + */ + __proto._onFocus=function(){ + this.event(/*laya.events.Event.FOCUS*/"focus",this); + } + + /** + *@private + */ + __proto._onBlur=function(){ + this.event(/*laya.events.Event.BLUR*/"blur",this); + } + + /** + *@private + */ + __proto._onInput=function(){ + this.event(/*laya.events.Event.INPUT*/"input",this); + } + + /** + *@private + */ + __proto._onEnter=function(){ + this.event(/*laya.events.Event.ENTER*/"enter",this); + } + + /**@inheritDoc */ + __proto.initialize=function(){ + this.width=128; + this.height=22; + } + + /**选中输入框内的文本。*/ + __proto.select=function(){ + (this._tf).select(); + } + + __proto.setSelection=function(startIndex,endIndex){ + (this._tf).setSelection(startIndex,endIndex); + } + + /** + *表示此对象包含的文本背景 AutoBitmap 组件实例。 + */ + __getset(0,__proto,'bg',function(){ + return this._bg; + },function(value){ + this.graphics=this._bg=value; + }); + + /** + *

    指示当前是否是文本域。

    + *值为true表示当前是文本域,否则不是文本域。 + */ + __getset(0,__proto,'multiline',function(){ + return (this._tf).multiline; + },function(value){ + (this._tf).multiline=value; + }); + + /** + *设置原生input输入框的y坐标偏移。 + */ + __getset(0,__proto,'inputElementYAdjuster',function(){ + return (this._tf).inputElementYAdjuster; + },function(value){ + (this._tf).inputElementYAdjuster=value; + }); + + /** + *@copy laya.ui.Image#skin + */ + __getset(0,__proto,'skin',function(){ + return this._skin; + },function(value){ + if (this._skin !=value){ + this._skin=value; + this._bg || (this.graphics=this._bg=new AutoBitmap()); + this._bg.source=Loader.getRes(this._skin); + this._width && (this._bg.width=this._width); + this._height && (this._bg.height=this._height); + } + }); + + /** + *

    当前实例的背景图( AutoBitmap )实例的有效缩放网格数据。

    + *

    数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。 + *

    • 例如:"4,4,4,4,1"

    + *@see laya.ui.AutoBitmap.sizeGrid + */ + __getset(0,__proto,'sizeGrid',function(){ + return this._bg && this._bg.sizeGrid ? this._bg.sizeGrid.join(","):null; + },function(value){ + this._bg || (this.graphics=this._bg=new AutoBitmap()); + this._bg.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number); + }); + + /** + *设置原生input输入框的x坐标偏移。 + */ + __getset(0,__proto,'inputElementXAdjuster',function(){ + return (this._tf).inputElementXAdjuster; + },function(value){ + (this._tf).inputElementXAdjuster=value; + }); + + /**@inheritDoc */ + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this._bg && (this._bg.width=value); + }); + + /**@inheritDoc */ + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this._bg && (this._bg.height=value); + }); + + /** + *设置可编辑状态。 + */ + __getset(0,__proto,'editable',function(){ + return (this._tf).editable; + },function(value){ + (this._tf).editable=value; + }); + + /**限制输入的字符。*/ + __getset(0,__proto,'restrict',function(){ + return (this._tf).restrict; + },function(pattern){ + (this._tf).restrict=pattern; + }); + + /** + *@copy laya.display.Input#prompt + */ + __getset(0,__proto,'prompt',function(){ + return (this._tf).prompt; + },function(value){ + (this._tf).prompt=value; + }); + + /** + *@copy laya.display.Input#promptColor + */ + __getset(0,__proto,'promptColor',function(){ + return (this._tf).promptColor; + },function(value){ + (this._tf).promptColor=value; + }); + + /** + *@copy laya.display.Input#maxChars + */ + __getset(0,__proto,'maxChars',function(){ + return (this._tf).maxChars; + },function(value){ + (this._tf).maxChars=value; + }); + + /** + *@copy laya.display.Input#focus + */ + __getset(0,__proto,'focus',function(){ + return (this._tf).focus; + },function(value){ + (this._tf).focus=value; + }); + + /** + *@copy laya.display.Input#type + */ + __getset(0,__proto,'type',function(){ + return (this._tf).type; + },function(value){ + (this._tf).type=value; + }); + + /** + *@copy laya.display.Input#asPassword + */ + __getset(0,__proto,'asPassword',function(){ + return (this._tf).asPassword; + },function(value){ + (this._tf).asPassword=value; + }); + + return TextInput; + })(Label) + + + /** + *使用 VSlider 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。 + *

    VSlider 控件采用垂直方向。滑块轨道从下往上扩展,而标签位于轨道的左右两侧。

    + * + *@example 以下示例代码,创建了一个 VSlider 实例。 + *+ *package + *{ + *import laya.ui.HSlider; + *import laya.ui.VSlider; + *import laya.utils.Handler; + *public class VSlider_Example + *{ + *private var vSlider:VSlider; + *public function VSlider_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *vSlider=new VSlider();//创建一个 VSlider 类的实例对象 vSlider 。 + *vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。 + *vSlider.min=0;//设置 vSlider 最低位置值。 + *vSlider.max=10;//设置 vSlider 最高位置值。 + *vSlider.value=2;//设置 vSlider 当前位置值。 + *vSlider.tick=1;//设置 vSlider 刻度值。 + *vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。 + *vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。 + *vSlider.changeHandler=new Handler(this,onChange);//设置 vSlider 位置变化处理器。 + *Laya.stage.addChild(vSlider);//把 vSlider 添加到显示列表。 + *} + *private function onChange(value:Number):void + *{ + *trace("滑块的位置: value="+value); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var vSlider; + *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *vSlider=new laya.ui.VSlider();//创建一个 VSlider 类的实例对象 vSlider 。 + *vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。 + *vSlider.min=0;//设置 vSlider 最低位置值。 + *vSlider.max=10;//设置 vSlider 最高位置值。 + *vSlider.value=2;//设置 vSlider 当前位置值。 + *vSlider.tick=1;//设置 vSlider 刻度值。 + *vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。 + *vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。 + *vSlider.changeHandler=new laya.utils.Handler(this,onChange);//设置 vSlider 位置变化处理器。 + *Laya.stage.addChild(vSlider);//把 vSlider 添加到显示列表。 + *} + *function onChange(value){ + *console.log("滑块的位置: value="+value); + *} + * + *+ *import HSlider=laya.ui.HSlider; + *import VSlider=laya.ui.VSlider; + *import Handler=laya.utils.Handler; + *class VSlider_Example { + *private vSlider:VSlider; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *this.vSlider=new VSlider();//创建一个 VSlider 类的实例对象 vSlider 。 + *this.vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。 + *this.vSlider.min=0;//设置 vSlider 最低位置值。 + *this.vSlider.max=10;//设置 vSlider 最高位置值。 + *this.vSlider.value=2;//设置 vSlider 当前位置值。 + *this.vSlider.tick=1;//设置 vSlider 刻度值。 + *this.vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。 + *this.vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。 + *this.vSlider.changeHandler=new Handler(this,this.onChange);//设置 vSlider 位置变化处理器。 + *Laya.stage.addChild(this.vSlider);//把 vSlider 添加到显示列表。 + *} + *private onChange(value:number):void { + *console.log("滑块的位置: value="+value); + *} + *} + * + *@see laya.ui.Slider + */ + //class laya.ui.VSlider extends laya.ui.Slider + var VSlider=(function(_super){ + function VSlider(){VSlider.__super.call(this);; + }; + + __class(VSlider,'laya.ui.VSlider',_super); + return VSlider; + })(Slider) + + + /** + *Dialog 组件是一个弹出对话框。 + * + *@example 以下示例代码,创建了一个 Dialog 实例。 + *+ *package + *{ + *import laya.ui.Dialog; + *import laya.utils.Handler; + *public class Dialog_Example + *{ + *private var dialog:Dialog_Instance; + *public function Dialog_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/btn_close.png",Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *dialog=new Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。 + *dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。 + *dialog.show();//显示 dialog。 + *dialog.closeHandler=new Handler(this,onClose);//设置 dialog 的关闭函数处理器。 + *} + *private function onClose(name:String):void + *{ + *if (name==Dialog.CLOSE) + *{ + *trace("通过点击 name 为"+name+"的组件,关闭了dialog。"); + *} + *} + *} + *} + *import laya.ui.Button; + *import laya.ui.Dialog; + *import laya.ui.Image; + *class Dialog_Instance extends Dialog + *{ + *function Dialog_Instance():void + *{ + *var bg:Image=new Image("resource/ui/bg.png"); + *bg.sizeGrid="40,10,5,10"; + *bg.width=150; + *bg.height=250; + *addChild(bg); + *var image:Image=new Image("resource/ui/image.png"); + *addChild(image); + *var button:Button=new Button("resource/ui/btn_close.png"); + *button.name=Dialog.CLOSE;//设置button的name属性值。 + *button.x=0; + *button.y=0; + *addChild(button); + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高、渲染模式 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *var dialog; + *Laya.loader.load("resource/ui/btn_close.png",laya.utils.Handler.create(this,loadComplete));//加载资源 + *(function (_super){//新建一个类Dialog_Instance继承自laya.ui.Dialog。 + *function Dialog_Instance(){ + *Dialog_Instance.__super.call(this);//初始化父类 + *var bg=new laya.ui.Image("resource/ui/bg.png");//新建一个 Image 类的实例 bg 。 + *bg.sizeGrid="10,40,10,5";//设置 bg 的网格信息。 + *bg.width=150;//设置 bg 的宽度。 + *bg.height=250;//设置 bg 的高度。 + *this.addChild(bg);//将 bg 添加到显示列表。 + *var image=new laya.ui.Image("resource/ui/image.png");//新建一个 Image 类的实例 image 。 + *this.addChild(image);//将 image 添加到显示列表。 + *var button=new laya.ui.Button("resource/ui/btn_close.png");//新建一个 Button 类的实例 bg 。 + *button.name=laya.ui.Dialog.CLOSE;//设置 button 的 name 属性值。 + *button.x=0;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。 + *button.y=0;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。 + *this.addChild(button);//将 button 添加到显示列表。 + *}; + *Laya.class(Dialog_Instance,"mypackage.dialogExample.Dialog_Instance",_super);//注册类Dialog_Instance。 + *})(laya.ui.Dialog); + *function loadComplete(){ + *console.log("资源加载完成!"); + *dialog=new mypackage.dialogExample.Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。 + *dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。 + *dialog.show();//显示 dialog。 + *dialog.closeHandler=new laya.utils.Handler(this,onClose);//设置 dialog 的关闭函数处理器。 + *} + *function onClose(name){ + *if (name==laya.ui.Dialog.CLOSE){ + *console.log("通过点击 name 为"+name+"的组件,关闭了dialog。"); + *} + *} + * + *+ *import Dialog=laya.ui.Dialog; + *import Handler=laya.utils.Handler; + *class Dialog_Example { + *private dialog:Dialog_Instance; + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load("resource/ui/btn_close.png",Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *this.dialog=new Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。 + *this.dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。 + *this.dialog.show();//显示 dialog。 + *this.dialog.closeHandler=new Handler(this,this.onClose);//设置 dialog 的关闭函数处理器。 + *} + *private onClose(name:string):void { + *if (name==Dialog.CLOSE){ + *console.log("通过点击 name 为"+name+"的组件,关闭了dialog。"); + *} + *} + *} + *import Button=laya.ui.Button; + *class Dialog_Instance extends Dialog { + *Dialog_Instance():void { + *var bg:laya.ui.Image=new laya.ui.Image("resource/ui/bg.png"); + *bg.sizeGrid="40,10,5,10"; + *bg.width=150; + *bg.height=250; + *this.addChild(bg); + *var image:laya.ui.Image=new laya.ui.Image("resource/ui/image.png"); + *this.addChild(image); + *var button:Button=new Button("resource/ui/btn_close.png"); + *button.name=Dialog.CLOSE;//设置button的name属性值。 + *button.x=0; + *button.y=0; + *this.addChild(button); + *} + *} + * + */ + //class laya.ui.Dialog extends laya.ui.View + var Dialog=(function(_super){ + var DialogManager; + function Dialog(){ + this.popupCenter=true; + this.closeHandler=null; + this._dragArea=null; + Dialog.__super.call(this); + } + + __class(Dialog,'laya.ui.Dialog',_super); + var __proto=Dialog.prototype; + /**@inheritDoc */ + __proto.initialize=function(){ + var dragTarget=this.getChildByName("drag"); + if (dragTarget){ + this.dragArea=dragTarget.x+","+dragTarget.y+","+dragTarget.width+","+dragTarget.height; + dragTarget.removeSelf(); + } + this.on(/*laya.events.Event.CLICK*/"click",this,this._onClick); + } + + /** + *@private (protected) + *对象的 Event.CLICK 点击事件侦听处理函数。 + */ + __proto._onClick=function(e){ + var btn=e.target; + if (btn){ + switch (btn.name){ + case "close": + case "cancel": + case "sure": + case "no": + case "ok": + case "yes": + this.close(btn.name); + break ; + } + } + } + + /** + *显示对话框(以非模式窗口方式显示)。 + *@param closeOther 是否关闭其它的对话框。若值为true则关闭其它对话框。 + */ + __proto.show=function(closeOther){ + (closeOther===void 0)&& (closeOther=false); + Dialog.manager.show(this,closeOther); + } + + /** + *显示对话框(以模式窗口方式显示)。 + *@param closeOther 是否关闭其它的对话框。若值为true则关闭其它对话框。 + */ + __proto.popup=function(closeOther){ + (closeOther===void 0)&& (closeOther=false); + Dialog.manager.popup(this,closeOther); + } + + /** + *关闭对话框。 + *@param type 如果是点击默认关闭按钮触发,则传入关闭按钮的名字(name),否则为null。 + */ + __proto.close=function(type){ + Dialog.manager.close(this); + this.closeHandler && this.closeHandler.runWith(type); + } + + /** + *@private + */ + __proto._onMouseDown=function(e){ + var point=this.getMousePoint(); + if (this._dragArea.contains(point.x,point.y))this.startDrag(); + else this.stopDrag(); + } + + /** + *用来指定对话框的拖拽区域。默认值为"0,0,0,0"。 + *

    格式:构成一个矩形所需的 x,y,width,heith 值,用逗号连接为字符串。 + *例如:"0,0,100,200"。 + *

    + * + *@see #includeExamplesSummary 请参考示例 + *@return + */ + __getset(0,__proto,'dragArea',function(){ + if (this._dragArea)return this._dragArea.toString(); + return null; + },function(value){ + if (value){ + var a=UIUtils.fillArray([0,0,0,0],value,Number); + this._dragArea=new Rectangle(a[0],a[1],a[2],a[3]); + this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onMouseDown); + }else { + this._dragArea=null; + this.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onMouseDown); + } + }); + + /** + *弹出框的显示状态;如果弹框处于显示中,则为true,否则为false; + *@return + */ + __getset(0,__proto,'isPopup',function(){ + return this.parent !=null; + }); + + /**@private 获取对话框管理器。*/ + __getset(1,Dialog,'manager',function(){ + return Dialog._manager || (Dialog._manager=new DialogManager()); + },laya.ui.View._$SET_manager); + + Dialog.closeAll=function(){ + Dialog.manager.closeAll(); + } + + Dialog.CLOSE="close"; + Dialog.CANCEL="cancel"; + Dialog.SURE="sure"; + Dialog.NO="no"; + Dialog.OK="ok"; + Dialog.YES="yes"; + Dialog._manager=null + Dialog.__init$=function(){ + /** + *DialogManager 类用来管理对话框。 + */ + //class DialogManager extends laya.display.Sprite + DialogManager=(function(_super){ + function DialogManager(){ + this._stage=null; + DialogManager.__super.call(this); + this.dialogLayer=new Sprite(); + this.modalLayer=new Sprite(); + this.maskLayer=new Sprite(); + this.mouseEnabled=this.dialogLayer.mouseEnabled=this.modalLayer.mouseEnabled=this.maskLayer.mouseEnabled=true; + this.addChild(this.dialogLayer); + this.addChild(this.modalLayer); + this._stage=Laya.stage; + this._stage.addChild(this); + this._stage.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize); + this.onResize(null); + } + __class(DialogManager,'',_super); + var __proto=DialogManager.prototype; + /** + *@private + *舞台的 Event.RESIZE 事件侦听处理函数。 + *@param e + */ + __proto.onResize=function(e){ + var width=this.maskLayer.width=this._stage.width; + var height=this.maskLayer.height=this._stage.height; + this.maskLayer.graphics.clear(); + this.maskLayer.graphics.drawRect(0,0,width,height,UIConfig.popupBgColor); + this.maskLayer.alpha=UIConfig.popupBgAlpha; + for (var i=this.dialogLayer.numChildren-1;i >-1;i--){ + var item=this.dialogLayer.getChildAt(i); + if (item.popupCenter)this._centerDialog(item); + } + for (i=this.modalLayer.numChildren-1;i >-1;i--){ + item=this.modalLayer.getChildAt(i); + if (item.isPopup){ + if (item.popupCenter)this._centerDialog(item); + } + } + } + __proto._centerDialog=function(dialog){ + dialog.x=Math.round(((this._stage.width-dialog.width)>> 1)+dialog.pivotX); + dialog.y=Math.round(((this._stage.height-dialog.height)>> 1)+dialog.pivotY); + } + /** + *显示对话框(非模式窗口类型)。 + *@param dialog 需要显示的对象框 Dialog 实例。 + *@param closeOther 是否关闭其它对话框,若值为ture,则关闭其它的对话框。 + */ + __proto.show=function(dialog,closeOther){ + (closeOther===void 0)&& (closeOther=false); + if (closeOther)this.dialogLayer.removeChildren(); + if (dialog.popupCenter)this._centerDialog(dialog); + this.dialogLayer.addChild(dialog); + this.event(/*laya.events.Event.OPEN*/"open"); + } + /** + *显示对话框(模式窗口类型)。 + *@param dialog 需要显示的对象框 Dialog 实例。 + *@param closeOther 是否关闭其它对话框,若值为ture,则关闭其它的对话框。 + */ + __proto.popup=function(dialog,closeOther){ + (closeOther===void 0)&& (closeOther=false); + if (closeOther)this.modalLayer.removeChildren(); + if (dialog.popupCenter)this._centerDialog(dialog); + this.modalLayer.addChild(this.maskLayer); + this.modalLayer.addChild(dialog); + this.event(/*laya.events.Event.OPEN*/"open"); + } + /** + *关闭对话框。 + *@param dialog 需要关闭的对象框 Dialog 实例。 + */ + __proto.close=function(dialog){ + dialog.removeSelf(); + if (this.modalLayer.numChildren < 2){ + this.maskLayer.removeSelf(); + }else { + this.modalLayer.setChildIndex(this.maskLayer,this.modalLayer.numChildren-2); + } + this.event(/*laya.events.Event.CLOSE*/"close"); + } + /** + *关闭所有的对话框。 + */ + __proto.closeAll=function(){ + this.dialogLayer.removeChildren(); + this.modalLayer.removeChildren(); + this.maskLayer.removeSelf(); + this.event(/*laya.events.Event.CLOSE*/"close"); + } + return DialogManager; + })(Sprite) + } + + return Dialog; + })(View) + + + /** + *VBox 是一个垂直布局容器类。 + */ + //class laya.ui.HBox extends laya.ui.LayoutBox + var HBox=(function(_super){ + function HBox(){HBox.__super.call(this);; + }; + + __class(HBox,'laya.ui.HBox',_super); + var __proto=HBox.prototype; + /**@inheritDoc */ + __proto.sortItem=function(items){ + if (items)items.sort(function(a,b){return a.x > b.x ? 1 :-1 + }); + } + + /**@inheritDoc */ + __proto.changeItems=function(){ + this._itemChanged=false; + var items=[]; + var maxHeight=0; + for (var i=0,n=this.numChildren;i < n;i++){ + var item=this.getChildAt(i); + if (item){ + items.push(item); + maxHeight=Math.max(maxHeight,item.height *item.scaleY); + } + } + this.sortItem(items); + var left=0; + for (i=0,n=this.numChildren;i < n;i++){ + item=items[i]; + item.x=left; + left+=item.width *item.scaleX+this._space; + if (this._align=="top"){ + item.y=0; + }else if (this._align=="middle"){ + item.y=(maxHeight-item.height *item.scaleY)*0.5; + }else if (this._align=="bottom"){ + item.y=maxHeight-item.height *item.scaleY; + } + } + this.changeSize(); + } + + HBox.NONE="none"; + HBox.TOP="top"; + HBox.MIDDLE="middle"; + HBox.BOTTOM="bottom"; + return HBox; + })(LayoutBox) + + + /** + *VBox 是一个垂直布局容器类。 + */ + //class laya.ui.VBox extends laya.ui.LayoutBox + var VBox=(function(_super){ + function VBox(){VBox.__super.call(this);; + }; + + __class(VBox,'laya.ui.VBox',_super); + var __proto=VBox.prototype; + /**@inheritDoc */ + __proto.changeItems=function(){ + this._itemChanged=false; + var items=[]; + var maxWidth=0; + for (var i=0,n=this.numChildren;i < n;i++){ + var item=this.getChildAt(i); + if (item){ + items.push(item); + maxWidth=Math.max(maxWidth,item.width *item.scaleX); + } + } + this.sortItem(items); + var top=0; + for (i=0,n=this.numChildren;i < n;i++){ + item=items[i]; + item.y=top; + top+=item.height *item.scaleY+this._space; + if (this._align=="left"){ + item.x=0; + }else if (this._align=="center"){ + item.x=(maxWidth-item.width *item.scaleX)*0.5; + }else if (this._align=="right"){ + item.x=maxWidth-item.width *item.scaleX; + } + } + this.changeSize(); + } + + VBox.NONE="none"; + VBox.LEFT="left"; + VBox.CENTER="center"; + VBox.RIGHT="right"; + return VBox; + })(LayoutBox) + + + /** + *RadioGroup 控件定义一组 Radio 控件,这些控件相互排斥; + *因此,用户每次只能选择一个 Radio 控件。 + * + *@example 以下示例代码,创建了一个 RadioGroup 实例。 + *+ *package + *{ + *import laya.ui.Radio; + *import laya.ui.RadioGroup; + *import laya.utils.Handler; + *public class RadioGroup_Example + *{ + *public function RadioGroup_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/radio.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *var radioGroup:RadioGroup=new RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。 + *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。 + *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。 + *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。 + *radioGroup.space=10;//设置 radioGroup 的项间隔距离。 + *radioGroup.selectHandler=new Handler(this,onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。 + *} + *private function onSelect(index:int):void + *{ + *trace("当前选择的单选按钮索引: index= ",index); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高、渲染模式 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load(["resource/ui/radio.png"],laya.utils.Handler.create(this,onLoadComplete)); + *function onLoadComplete(){ + *var radioGroup=new laya.ui.RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。 + *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。 + *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。 + *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。 + *radioGroup.space=10;//设置 radioGroup 的项间隔距离。 + *radioGroup.selectHandler=new laya.utils.Handler(this,onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。 + *} + *function onSelect(index){ + *console.log("当前选择的单选按钮索引: index= ",index); + *} + * + *+ *import Radio=laya.ui.Radio; + *import RadioGroup=laya.ui.RadioGroup; + *import Handler=laya.utils.Handler; + *class RadioGroup_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/radio.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *var radioGroup:RadioGroup=new RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。 + *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。 + *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。 + *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。 + *radioGroup.space=10;//设置 radioGroup 的项间隔距离。 + *radioGroup.selectHandler=new Handler(this,this.onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。 + *} + *private onSelect(index:number):void { + *console.log("当前选择的单选按钮索引: index= ",index); + *} + *} + * + */ + //class laya.ui.RadioGroup extends laya.ui.UIGroup + var RadioGroup=(function(_super){ + function RadioGroup(){RadioGroup.__super.call(this);; + }; + + __class(RadioGroup,'laya.ui.RadioGroup',_super); + var __proto=RadioGroup.prototype; + /**@inheritDoc */ + __proto.createItem=function(skin,label){ + return new Radio(skin,label); + } + + return RadioGroup; + })(UIGroup) + + + /** + *Tab 组件用来定义选项卡按钮组。 * + *@internal

    属性:selectedIndex 的默认值为-1。

    + * + *@example 以下示例代码,创建了一个 Tab 实例。 + *+ *package + *{ + *import laya.ui.Tab; + *import laya.utils.Handler; + *public class Tab_Example + *{ + *public function Tab_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/tab.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *var tab:Tab=new Tab();//创建一个 Tab 类的实例对象 tab 。 + *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。 + *tab.labels="item0,item1,item2";//设置 tab 的标签集。 + *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。 + *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。 + *tab.selectHandler=new Handler(this,onSelect);//设置 tab 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(tab);//将 tab 添到显示列表。 + *} + *private function onSelect(index:int):void + *{ + *trace("当前选择的表情页索引: index= ",index); + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load(["resource/ui/tab.png"],laya.utils.Handler.create(this,onLoadComplete)); + *function onLoadComplete(){ + *var tab=new laya.ui.Tab();//创建一个 Tab 类的实例对象 tab 。 + *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。 + *tab.labels="item0,item1,item2";//设置 tab 的标签集。 + *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。 + *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。 + *tab.selectHandler=new laya.utils.Handler(this,onSelect);//设置 tab 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(tab);//将 tab 添到显示列表。 + *} + *function onSelect(index){ + *console.log("当前选择的标签页索引: index= ",index); + *} + * + *+ *import Tab=laya.ui.Tab; + *import Handler=laya.utils.Handler; + *class Tab_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/tab.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *var tab:Tab=new Tab();//创建一个 Tab 类的实例对象 tab 。 + *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。 + *tab.labels="item0,item1,item2";//设置 tab 的标签集。 + *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。 + *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。 + *tab.selectHandler=new Handler(this,this.onSelect);//设置 tab 的选择项发生改变时执行的处理器。 + *Laya.stage.addChild(tab);//将 tab 添到显示列表。 + *} + *private onSelect(index:number):void { + *console.log("当前选择的表情页索引: index= ",index); + *} + *} + * + */ + //class laya.ui.Tab extends laya.ui.UIGroup + var Tab=(function(_super){ + function Tab(){Tab.__super.call(this);; + }; + + __class(Tab,'laya.ui.Tab',_super); + var __proto=Tab.prototype; + /** + *@private + *@inheritDoc + */ + __proto.createItem=function(skin,label){ + return new Button(skin,label); + } + + return Tab; + })(UIGroup) + + + /** + *TextArea 类用于创建显示对象以显示和输入文本。 + *@example 以下示例代码,创建了一个 TextArea 实例。 + *+ *package + *{ + *import laya.ui.TextArea; + *import laya.utils.Handler; + *public class TextArea_Example + *{ + *public function TextArea_Example() + *{ + *Laya.init(640,800);//设置游戏画布宽高。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,onLoadComplete));//加载资源。 + *} + *private function onLoadComplete():void + *{ + *var textArea:TextArea=new TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。 + *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。 + *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。 + *textArea.color="#008fff";//设置 textArea 的文本颜色。 + *textArea.font="Arial";//设置 textArea 的字体。 + *textArea.bold=true;//设置 textArea 的文本显示为粗体。 + *textArea.fontSize=20;//设置 textArea 的文本字体大小。 + *textArea.wordWrap=true;//设置 textArea 的文本自动换行。 + *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。 + *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。 + *textArea.width=300;//设置 textArea 的宽度。 + *textArea.height=200;//设置 textArea 的高度。 + *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。 + *} + *} + *} + * + *+ *Laya.init(640,800);//设置游戏画布宽高、渲染模式 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色 + *Laya.loader.load(["resource/ui/input.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。 + *function onLoadComplete(){ + *var textArea=new laya.ui.TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。 + *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。 + *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。 + *textArea.color="#008fff";//设置 textArea 的文本颜色。 + *textArea.font="Arial";//设置 textArea 的字体。 + *textArea.bold=true;//设置 textArea 的文本显示为粗体。 + *textArea.fontSize=20;//设置 textArea 的文本字体大小。 + *textArea.wordWrap=true;//设置 textArea 的文本自动换行。 + *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。 + *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。 + *textArea.width=300;//设置 textArea 的宽度。 + *textArea.height=200;//设置 textArea 的高度。 + *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。 + *} + * + *+ *import TextArea=laya.ui.TextArea; + *import Handler=laya.utils.Handler; + *class TextArea_Example { + *constructor(){ + *Laya.init(640,800);//设置游戏画布宽高、渲染模式。 + *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。 + *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,this.onLoadComplete));//加载资源。 + *} + *private onLoadComplete():void { + *var textArea:TextArea=new TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。 + *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。 + *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。 + *textArea.color="#008fff";//设置 textArea 的文本颜色。 + *textArea.font="Arial";//设置 textArea 的字体。 + *textArea.bold=true;//设置 textArea 的文本显示为粗体。 + *textArea.fontSize=20;//设置 textArea 的文本字体大小。 + *textArea.wordWrap=true;//设置 textArea 的文本自动换行。 + *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。 + *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。 + *textArea.width=300;//设置 textArea 的宽度。 + *textArea.height=200;//设置 textArea 的高度。 + *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。 + *} + *} + * + */ + //class laya.ui.TextArea extends laya.ui.TextInput + var TextArea=(function(_super){ + function TextArea(text){ + this._vScrollBar=null; + this._hScrollBar=null; + (text===void 0)&& (text=""); + TextArea.__super.call(this,text); + } + + __class(TextArea,'laya.ui.TextArea',_super); + var __proto=TextArea.prototype; + __proto.destroy=function(destroyChild){ + (destroyChild===void 0)&& (destroyChild=true); + _super.prototype.destroy.call(this,destroyChild); + this._vScrollBar && this._vScrollBar.destroy(); + this._hScrollBar && this._hScrollBar.destroy(); + this._vScrollBar=null; + this._hScrollBar=null; + } + + __proto.initialize=function(){ + this.width=180; + this.height=150; + this._tf.wordWrap=true; + this.multiline=true; + } + + __proto.onVBarChanged=function(e){ + if (this._tf.scrollY !=this._vScrollBar.value){ + this._tf.scrollY=this._vScrollBar.value; + } + } + + __proto.onHBarChanged=function(e){ + if (this._tf.scrollX !=this._hScrollBar.value){ + this._tf.scrollX=this._hScrollBar.value; + } + } + + __proto.changeScroll=function(){ + var vShow=this._vScrollBar && this._tf.maxScrollY > 0; + var hShow=this._hScrollBar && this._tf.maxScrollX > 0; + var showWidth=vShow ? this._width-this._vScrollBar.width :this._width; + var showHeight=hShow ? this._height-this._hScrollBar.height :this._height; + var padding=this._tf.padding || Styles.labelPadding; + this._tf.width=showWidth; + this._tf.height=showHeight; + if (this._vScrollBar){ + this._vScrollBar.x=this._width-this._vScrollBar.width-padding[2]; + this._vScrollBar.y=padding[1]; + this._vScrollBar.height=this._height-(hShow ? this._hScrollBar.height :0)-padding[1]-padding[3]; + this._vScrollBar.scrollSize=1; + this._vScrollBar.thumbPercent=showHeight / Math.max(this._tf.textHeight,showHeight); + this._vScrollBar.setScroll(1,this._tf.maxScrollY,this._tf.scrollY); + this._vScrollBar.visible=vShow; + } + if (this._hScrollBar){ + this._hScrollBar.x=padding[0]; + this._hScrollBar.y=this._height-this._hScrollBar.height-padding[3]; + this._hScrollBar.width=this._width-(vShow ? this._vScrollBar.width :0)-padding[0]-padding[2]; + this._hScrollBar.scrollSize=Math.max(showWidth *0.033,1); + this._hScrollBar.thumbPercent=showWidth / Math.max(this._tf.textWidth,showWidth); + this._hScrollBar.setScroll(0,this.maxScrollX,this.scrollX); + this._hScrollBar.visible=hShow; + } + } + + /**滚动到某个位置*/ + __proto.scrollTo=function(y){ + this.commitMeasure(); + this._tf.scrollY=y; + } + + /**垂直滚动值*/ + __getset(0,__proto,'scrollY',function(){ + return this._tf.scrollY; + }); + + __getset(0,__proto,'width',_super.prototype._$get_width,function(value){ + _super.prototype._$set_width.call(this,value); + this.callLater(this.changeScroll); + }); + + /**水平滚动条实体*/ + __getset(0,__proto,'hScrollBar',function(){ + return this._hScrollBar; + }); + + __getset(0,__proto,'height',_super.prototype._$get_height,function(value){ + _super.prototype._$set_height.call(this,value); + this.callLater(this.changeScroll); + }); + + /**水平滚动最大值*/ + __getset(0,__proto,'maxScrollX',function(){ + return this._tf.maxScrollX; + }); + + /**垂直滚动条皮肤*/ + __getset(0,__proto,'vScrollBarSkin',function(){ + return this._vScrollBar ? this._vScrollBar.skin :null; + },function(value){ + if (this._vScrollBar==null){ + this.addChild(this._vScrollBar=new VScrollBar()); + this._vScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onVBarChanged); + this._vScrollBar.target=this._tf; + this.callLater(this.changeScroll); + } + this._vScrollBar.skin=value; + }); + + /**水平滚动条皮肤*/ + __getset(0,__proto,'hScrollBarSkin',function(){ + return this._hScrollBar ? this._hScrollBar.skin :null; + },function(value){ + if (this._hScrollBar==null){ + this.addChild(this._hScrollBar=new HScrollBar()); + this._hScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onHBarChanged); + this._hScrollBar.mouseWheelEnable=false; + this._hScrollBar.target=this._tf; + this.callLater(this.changeScroll); + } + this._hScrollBar.skin=value; + }); + + /**垂直滚动条实体*/ + __getset(0,__proto,'vScrollBar',function(){ + return this._vScrollBar; + }); + + /**垂直滚动最大值*/ + __getset(0,__proto,'maxScrollY',function(){ + return this._tf.maxScrollY; + }); + + /**水平滚动值*/ + __getset(0,__proto,'scrollX',function(){ + return this._tf.scrollX; + }); + + return TextArea; + })(TextInput) + + + Laya.__init([Dialog,View]); +})(window,document,Laya); diff --git a/games/laya-snakes/libs/laya.webgl.js b/games/laya-snakes/libs/laya.webgl.js new file mode 100644 index 0000000..d406cd3 --- /dev/null +++ b/games/laya-snakes/libs/laya.webgl.js @@ -0,0 +1,5 @@ + +(function(window,document,Laya){ + var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; + +})(window,document,Laya); diff --git a/games/laya-snakes/libs/matter-RenderLaya.js b/games/laya-snakes/libs/matter-RenderLaya.js new file mode 100644 index 0000000..408f4f8 --- /dev/null +++ b/games/laya-snakes/libs/matter-RenderLaya.js @@ -0,0 +1,319 @@ +var Browser = laya.utils.Browser; + +var Composite = Matter.Composite; +var Events = Matter.Events; +var Bounds = Matter.Bounds; +var Common = Matter.Common; +var Vertices = Matter.Vertices; +var Vector = Matter.Vector; +var Sleeping = Matter.Sleeping; +var Axes = Matter.Axes; +var Body = Matter.Body; +var SAT = Matter.SAT; +var Contact = Matter.Contact; +var Pair = Matter.Pair; +var Detector = Matter.Detector; +var Grid = Matter.Grid; + +var LayaRender = {}; + +(function() +{ + var graphics, + spriteCon, + graphicsCon; + + LayaRender.create = function(options) + { + var defaults = { + controller: LayaRender, + element: null, + canvas: null, + mouse: null, + options: + { + width: 800, + height: 600, + pixelRatio: 1, + background: '#fafafa', + wireframeBackground: '#222', + hasBounds: !!options.bounds, + enabled: true, + wireframes: true, + showSleeping: true, + showDebug: false, + showBroadphase: false, + showBounds: false, + showVelocity: false, + showCollisions: false, + showSeparations: false, + showAxes: false, + showPositions: false, + showAngleIndicator: false, + showIds: false, + showShadows: false, + showVertexNumbers: false, + showConvexHulls: false, + showInternalEdges: false, + showMousePosition: false + } + }; + + var render = Common.extend(defaults, options); + + render.canvas = laya.renders.Render.canvas; + render.context = laya.renders.Render.context.ctx; + + render.textures = {}; + + render.bounds = render.bounds || + { + min: + { + x: 0, + y: 0 + }, + max: + { + x: Laya.stage.width, + y: Laya.stage.height + } + }; + + createContainer(render); + setBackground(render); + setPixelRatio(); + + return render; + }; + + function createContainer(render) + { + var con = render.container; + + spriteCon = new Laya.Sprite(); + graphicsCon = new Laya.Sprite(); + + render.spriteContainer = spriteCon; + render.graphicsContainer = graphicsCon; + + con.addChild(spriteCon); + con.addChild(graphicsCon); + + graphics = graphicsCon.graphics; + } + + // 设置背景 + function setBackground(render) + { + var bg = render.options.background; + // 纯色背景 + if (bg.length == 7 && bg[0] == '#') + { + spriteCon.graphics.drawRect( + 0, 0, + render.options.width, render.options.height, + bg); + } + // 图片背景 + else + { + spriteCon.loadImage(bg); + } + } + + function setPixelRatio() + { + var pixelRatio; + pixelRatio = 1; + Laya.Render.canvas.setAttribute('data-pixel-ratio', pixelRatio); + } + + /** + * Renders the given `engine`'s `Matter.World` object. + * This is the entry point for all rendering and should be called every time the scene changes. + * @method world + * @param {engine} engine + */ + LayaRender.world = function(engine) + { + var render = engine.render, + world = engine.world, + options = render.options, + allConstraints = Composite.allConstraints(world), + bodies = Composite.allBodies(world), + constraints = [], + i; + + // handle bounds + if (options.hasBounds) + { + var boundsWidth = render.bounds.max.x - render.bounds.min.x, + boundsHeight = render.bounds.max.y - render.bounds.min.y, + boundsScaleX = boundsWidth / options.width, + boundsScaleY = boundsHeight / options.height; + + // filter out bodies that are not in view + for (i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); + } + + // filter out constraints that are not in view + for (i = 0; i < allConstraints.length; i++) + { + var constraint = allConstraints[i], + bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointAWorld = constraint.pointA, + pointBWorld = constraint.pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); + + if (!pointAWorld || !pointBWorld) + continue; + + if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) + constraints.push(constraint); + } + + // transform the view + // context.scale(1 / boundsScaleX, 1 / boundsScaleY); + // context.translate(-render.bounds.min.x, -render.bounds.min.y); + } + else + { + constraints = allConstraints; + } + + graphics.clear(); + for (i = 0; i < bodies.length; i++) + LayaRender.body(engine, bodies[i]); + + for (i = 0; i < constraints.length; i++) + LayaRender.constraint(engine, constraints[i]); + }; + LayaRender.body = function(engine, body) + { + var render = engine.render, + bodyRender = body.render; + + if (!bodyRender.visible) + { + return; + } + + var spInfo = bodyRender.sprite; + var sp = body.sprite; + if (bodyRender.sprite && bodyRender.sprite.texture) + { + // initialize body sprite if not existing + if (!sp) + { + sp = body.sprite = createBodySprite(spInfo.xOffset, spInfo.yOffset); + sp.loadImage(spInfo.texture); + } + + sp.scale(spInfo.xScale, spInfo.yScale); + sp.pos(body.position.x, body.position.y); + sp.rotation = body.angle * 180 / Math.PI; + } + else + { + var options = render.options; + // handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) + { + part = body.parts[k]; + + if (!part.render.visible) + continue; + + var fillStyle = options.wireframes ? null : part.render.fillStyle; + var lineWidth = part.render.lineWidth; + var strokeStyle = part.render.strokeStyle; + // part polygon + if (part.circleRadius) + { + graphics.drawCircle(part.position.x, part.position.y, part.circleRadius, fillStyle, strokeStyle, lineWidth); + } + else + { + var path = []; + path.push(part.vertices[0].x, part.vertices[0].y); + + for (var j = 1; j < part.vertices.length; j++) + { + if (!part.vertices[j - 1].isInternal || showInternalEdges) + { + path.push(part.vertices[j].x, part.vertices[j].y); + } + else + { + path.push(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) + { + path.push(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); + } + } + + graphics.drawPoly(0, 0, path, fillStyle, strokeStyle, lineWidth); + } + } + } + }; + + LayaRender.constraint = function(engine, constraint) + { + var sx, sy, ex, ey; + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + { + return; + } + + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB; + + if (bodyA) + { + sx = bodyA.position.x + constraint.pointA.x; + sy = bodyA.position.y + constraint.pointA.y; + } + else + { + sx = constraint.pointA.x; + sy = constraint.pointA.y; + } + + if (bodyB) + { + ex = bodyB.position.x + constraint.pointB.x; + ey = bodyB.position.y + constraint.pointB.y; + } + else + { + ex = constraint.pointB.x; + ey = constraint.pointB.y; + } + + graphics.drawLine( + sx, sy, ex, ey, + constraint.render.strokeStyle, + constraint.render.lineWidth); + }; + + function createBodySprite(xOffset, yOffset) + { + var sp = new Laya.Sprite(); + + sp.pivot(xOffset, yOffset); + sp.pos(-9999, -9999); + spriteCon.addChild(sp); + + return sp; + } +})(); \ No newline at end of file diff --git a/games/laya-snakes/libs/matter.js b/games/laya-snakes/libs/matter.js new file mode 100644 index 0000000..c058e5f --- /dev/null +++ b/games/laya-snakes/libs/matter.js @@ -0,0 +1,9168 @@ +/** +* matter-js 0.9.3 by @liabru 2016-04-19 +* http://brm.io/matter-js/ +* License MIT +*/ + +/** + * The MIT License (MIT) + * + * Copyright (c) 2014 Liam Brummitt + * + * 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 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. + */ + +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Matter = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + Vector.rotateAbout(part.position, delta, body.position, part.position); + } + } + }; + + /** + * Sets the linear velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. + * @method setVelocity + * @param {body} body + * @param {vector} velocity + */ + Body.setVelocity = function(body, velocity) { + body.positionPrev.x = body.position.x - velocity.x; + body.positionPrev.y = body.position.y - velocity.y; + body.velocity.x = velocity.x; + body.velocity.y = velocity.y; + body.speed = Vector.magnitude(body.velocity); + }; + + /** + * Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. + * @method setAngularVelocity + * @param {body} body + * @param {number} velocity + */ + Body.setAngularVelocity = function(body, velocity) { + body.anglePrev = body.angle - velocity; + body.angularVelocity = velocity; + body.angularSpeed = Math.abs(body.angularVelocity); + }; + + /** + * Moves a body by a given vector relative to its current position, without imparting any velocity. + * @method translate + * @param {body} body + * @param {vector} translation + */ + Body.translate = function(body, translation) { + Body.setPosition(body, Vector.add(body.position, translation)); + }; + + /** + * Rotates a body by a given angle relative to its current angle, without imparting any angular velocity. + * @method rotate + * @param {body} body + * @param {number} rotation + */ + Body.rotate = function(body, rotation) { + Body.setAngle(body, body.angle + rotation); + }; + + /** + * Scales the body, including updating physical properties (mass, area, axes, inertia), from a world-space point (default is body centre). + * @method scale + * @param {body} body + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} [point] + */ + Body.scale = function(body, scaleX, scaleY, point) { + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + + // scale vertices + Vertices.scale(part.vertices, scaleX, scaleY, body.position); + + // update properties + part.axes = Axes.fromVertices(part.vertices); + + if (!body.isStatic) { + part.area = Vertices.area(part.vertices); + Body.setMass(part, body.density * part.area); + + // update inertia (requires vertices to be at origin) + Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); + Body.setInertia(part, Vertices.inertia(part.vertices, part.mass)); + Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); + } + + // update bounds + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + // handle circles + if (body.circleRadius) { + if (scaleX === scaleY) { + body.circleRadius *= scaleX; + } else { + // body is no longer a circle + body.circleRadius = null; + } + } + + if (!body.isStatic) { + var total = _totalProperties(body); + body.area = total.area; + Body.setMass(body, total.mass); + Body.setInertia(body, total.inertia); + } + }; + + /** + * Performs a simulation step for the given `body`, including updating position and angle using Verlet integration. + * @method update + * @param {body} body + * @param {number} deltaTime + * @param {number} timeScale + * @param {number} correction + */ + Body.update = function(body, deltaTime, timeScale, correction) { + var deltaTimeSquared = Math.pow(deltaTime * timeScale * body.timeScale, 2); + + // from the previous step + var frictionAir = 1 - body.frictionAir * timeScale * body.timeScale, + velocityPrevX = body.position.x - body.positionPrev.x, + velocityPrevY = body.position.y - body.positionPrev.y; + + // update velocity with Verlet integration + body.velocity.x = (velocityPrevX * frictionAir * correction) + (body.force.x / body.mass) * deltaTimeSquared; + body.velocity.y = (velocityPrevY * frictionAir * correction) + (body.force.y / body.mass) * deltaTimeSquared; + + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; + body.position.x += body.velocity.x; + body.position.y += body.velocity.y; + + // update angular velocity with Verlet integration + body.angularVelocity = ((body.angle - body.anglePrev) * frictionAir * correction) + (body.torque / body.inertia) * deltaTimeSquared; + body.anglePrev = body.angle; + body.angle += body.angularVelocity; + + // track speed and acceleration + body.speed = Vector.magnitude(body.velocity); + body.angularSpeed = Math.abs(body.angularVelocity); + + // transform the body geometry + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + + Vertices.translate(part.vertices, body.velocity); + + if (i > 0) { + part.position.x += body.velocity.x; + part.position.y += body.velocity.y; + } + + if (body.angularVelocity !== 0) { + Vertices.rotate(part.vertices, body.angularVelocity, body.position); + Axes.rotate(part.axes, body.angularVelocity); + if (i > 0) { + Vector.rotateAbout(part.position, body.angularVelocity, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + }; + + /** + * Applies a force to a body from a given world-space position, including resulting torque. + * @method applyForce + * @param {body} body + * @param {vector} position + * @param {vector} force + */ + Body.applyForce = function(body, position, force) { + body.force.x += force.x; + body.force.y += force.y; + var offset = { x: position.x - body.position.x, y: position.y - body.position.y }; + body.torque += offset.x * force.y - offset.y * force.x; + }; + + /** + * Returns the sums of the properties of all compound parts of the parent body. + * @method _totalProperties + * @private + * @param {body} body + * @return {} + */ + var _totalProperties = function(body) { + // https://ecourses.ou.edu/cgi-bin/ebook.cgi?doc=&topic=st&chap_sec=07.2&page=theory + // http://output.to/sideway/default.asp?qno=121100087 + + var properties = { + mass: 0, + area: 0, + inertia: 0, + centre: { x: 0, y: 0 } + }; + + // sum the properties of all compound parts of the parent body + for (var i = body.parts.length === 1 ? 0 : 1; i < body.parts.length; i++) { + var part = body.parts[i]; + properties.mass += part.mass; + properties.area += part.area; + properties.inertia += part.inertia; + properties.centre = Vector.add(properties.centre, + Vector.mult(part.position, part.mass !== Infinity ? part.mass : 1)); + } + + properties.centre = Vector.div(properties.centre, + properties.mass !== Infinity ? properties.mass : body.parts.length); + + return properties; + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when a body starts sleeping (where `this` is the body). + * + * @event sleepStart + * @this {body} The body that has started sleeping + * @param {} event An event object + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a body ends sleeping (where `this` is the body). + * + * @event sleepEnd + * @this {body} The body that has ended sleeping + * @param {} event An event object + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Body.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "body" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Body" + */ + + /** + * An array of bodies that make up this body. + * The first body in the array must always be a self reference to the current body instance. + * All bodies in the `parts` array together form a single rigid compound body. + * Parts are allowed to overlap, have gaps or holes or even form concave bodies. + * Parts themselves should never be added to a `World`, only the parent body should be. + * Use `Body.setParts` when setting parts to ensure correct updates of all properties. + * + * @property parts + * @type body[] + */ + + /** + * A self reference if the body is _not_ a part of another body. + * Otherwise this is a reference to the body that this is a part of. + * See `body.parts`. + * + * @property parent + * @type body + */ + + /** + * A `Number` specifying the angle of the body, in radians. + * + * @property angle + * @type number + * @default 0 + */ + + /** + * An array of `Vector` objects that specify the convex hull of the rigid body. + * These should be provided about the origin `(0, 0)`. E.g. + * + * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] + * + * When passed via `Body.create`, the vertices are translated relative to `body.position` (i.e. world-space, and constantly updated by `Body.update` during simulation). + * The `Vector` objects are also augmented with additional properties required for efficient collision detection. + * + * Other properties such as `inertia` and `bounds` are automatically calculated from the passed vertices (unless provided via `options`). + * Concave hulls are not currently supported. The module `Matter.Vertices` contains useful methods for working with vertices. + * + * @property vertices + * @type vector[] + */ + + /** + * A `Vector` that specifies the current world-space position of the body. + * + * @property position + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the force to apply in the current step. It is zeroed after every `Body.update`. See also `Body.applyForce`. + * + * @property force + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the torque (turning force) to apply in the current step. It is zeroed after every `Body.update`. + * + * @property torque + * @type number + * @default 0 + */ + + /** + * A `Number` that _measures_ the current speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.velocity`). + * + * @readOnly + * @property speed + * @type number + * @default 0 + */ + + /** + * A `Number` that _measures_ the current angular speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.angularVelocity`). + * + * @readOnly + * @property angularSpeed + * @type number + * @default 0 + */ + + /** + * A `Vector` that _measures_ the current velocity of the body after the last `Body.update`. It is read-only. + * If you need to modify a body's velocity directly, you should either apply a force or simply change the body's `position` (as the engine uses position-Verlet integration). + * + * @readOnly + * @property velocity + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that _measures_ the current angular velocity of the body after the last `Body.update`. It is read-only. + * If you need to modify a body's angular velocity directly, you should apply a torque or simply change the body's `angle` (as the engine uses position-Verlet integration). + * + * @readOnly + * @property angularVelocity + * @type number + * @default 0 + */ + + /** + * A flag that indicates whether a body is considered static. A static body can never change position or angle and is completely fixed. + * If you need to set a body as static after its creation, you should use `Body.setStatic` as this requires more than just setting this flag. + * + * @property isStatic + * @type boolean + * @default false + */ + + /** + * A flag that indicates whether a body is a sensor. Sensor triggers collision events, but doesn't react with colliding body physically. + * + * @property isSensor + * @type boolean + * @default false + */ + + /** + * A flag that indicates whether the body is considered sleeping. A sleeping body acts similar to a static body, except it is only temporary and can be awoken. + * If you need to set a body as sleeping, you should use `Sleeping.set` as this requires more than just setting this flag. + * + * @property isSleeping + * @type boolean + * @default false + */ + + /** + * A `Number` that _measures_ the amount of movement a body currently has (a combination of `speed` and `angularSpeed`). It is read-only and always positive. + * It is used and updated by the `Matter.Sleeping` module during simulation to decide if a body has come to rest. + * + * @readOnly + * @property motion + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping by the `Matter.Sleeping` module (if sleeping is enabled by the engine). + * + * @property sleepThreshold + * @type number + * @default 60 + */ + + /** + * A `Number` that defines the density of the body, that is its mass per unit area. + * If you pass the density via `Body.create` the `mass` property is automatically calculated for you based on the size (area) of the object. + * This is generally preferable to simply setting mass and allows for more intuitive definition of materials (e.g. rock has a higher density than wood). + * + * @property density + * @type number + * @default 0.001 + */ + + /** + * A `Number` that defines the mass of the body, although it may be more appropriate to specify the `density` property instead. + * If you modify this value, you must also modify the `body.inverseMass` property (`1 / mass`). + * + * @property mass + * @type number + */ + + /** + * A `Number` that defines the inverse mass of the body (`1 / mass`). + * If you modify this value, you must also modify the `body.mass` property. + * + * @property inverseMass + * @type number + */ + + /** + * A `Number` that defines the moment of inertia (i.e. second moment of area) of the body. + * It is automatically calculated from the given convex hull (`vertices` array) and density in `Body.create`. + * If you modify this value, you must also modify the `body.inverseInertia` property (`1 / inertia`). + * + * @property inertia + * @type number + */ + + /** + * A `Number` that defines the inverse moment of inertia of the body (`1 / inertia`). + * If you modify this value, you must also modify the `body.inertia` property. + * + * @property inverseInertia + * @type number + */ + + /** + * A `Number` that defines the restitution (elasticity) of the body. The value is always positive and is in the range `(0, 1)`. + * A value of `0` means collisions may be perfectly inelastic and no bouncing may occur. + * A value of `0.8` means the body may bounce back with approximately 80% of its kinetic energy. + * Note that collision response is based on _pairs_ of bodies, and that `restitution` values are _combined_ with the following formula: + * + * Math.max(bodyA.restitution, bodyB.restitution) + * + * @property restitution + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the friction of the body. The value is always positive and is in the range `(0, 1)`. + * A value of `0` means that the body may slide indefinitely. + * A value of `1` means the body may come to a stop almost instantly after a force is applied. + * + * The effects of the value may be non-linear. + * High values may be unstable depending on the body. + * The engine uses a Coulomb friction model including static and kinetic friction. + * Note that collision response is based on _pairs_ of bodies, and that `friction` values are _combined_ with the following formula: + * + * Math.min(bodyA.friction, bodyB.friction) + * + * @property friction + * @type number + * @default 0.1 + */ + + /** + * A `Number` that defines the static friction of the body (in the Coulomb friction model). + * A value of `0` means the body will never 'stick' when it is nearly stationary and only dynamic `friction` is used. + * The higher the value (e.g. `10`), the more force it will take to initially get the body moving when nearly stationary. + * This value is multiplied with the `friction` property to make it easier to change `friction` and maintain an appropriate amount of static friction. + * + * @property frictionStatic + * @type number + * @default 0.5 + */ + + /** + * A `Number` that defines the air friction of the body (air resistance). + * A value of `0` means the body will never slow as it moves through space. + * The higher the value, the faster a body slows when moving through space. + * The effects of the value are non-linear. + * + * @property frictionAir + * @type number + * @default 0.01 + */ + + /** + * An `Object` that specifies the collision filtering properties of this body. + * + * Collisions between two bodies will obey the following rules: + * - If the two bodies have the same non-zero value of `collisionFilter.group`, + * they will always collide if the value is positive, and they will never collide + * if the value is negative. + * - If the two bodies have different values of `collisionFilter.group` or if one + * (or both) of the bodies has a value of 0, then the category/mask rules apply as follows: + * + * Each body belongs to a collision category, given by `collisionFilter.category`. This + * value is used as a bit field and the category should have only one bit set, meaning that + * the value of this property is a power of two in the range [1, 2^31]. Thus, there are 32 + * different collision categories available. + * + * Each body also defines a collision bitmask, given by `collisionFilter.mask` which specifies + * the categories it collides with (the value is the bitwise AND value of all these categories). + * + * Using the category/mask rules, two bodies `A` and `B` collide if each includes the other's + * category in its mask, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` + * are both true. + * + * @property collisionFilter + * @type object + */ + + /** + * An Integer `Number`, that specifies the collision group this body belongs to. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.group + * @type object + * @default 0 + */ + + /** + * A bit field that specifies the collision category this body belongs to. + * The category value should have only one bit set, for example `0x0001`. + * This means there are up to 32 unique collision categories available. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.category + * @type object + * @default 1 + */ + + /** + * A bit mask that specifies the collision categories this body may collide with. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.mask + * @type object + * @default -1 + */ + + /** + * A `Number` that specifies a tolerance on how far a body is allowed to 'sink' or rotate into other bodies. + * Avoid changing this value unless you understand the purpose of `slop` in physics engines. + * The default should generally suffice, although very large bodies may require larger values for stable stacking. + * + * @property slop + * @type number + * @default 0.05 + */ + + /** + * A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. + * + * @property timeScale + * @type number + * @default 1 + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the body should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * Sets the opacity to use when rendering. + * + * @property render.opacity + * @type number + * @default 1 + */ + + /** + * An `Object` that defines the sprite properties to use when rendering, if any. + * + * @property render.sprite + * @type object + */ + + /** + * An `String` that defines the path to the image to use as the sprite texture, if any. + * + * @property render.sprite.texture + * @type string + */ + + /** + * A `Number` that defines the scaling in the x-axis for the sprite, if any. + * + * @property render.sprite.xScale + * @type number + * @default 1 + */ + + /** + * A `Number` that defines the scaling in the y-axis for the sprite, if any. + * + * @property render.sprite.yScale + * @type number + * @default 1 + */ + + /** + * A `Number` that defines the offset in the x-axis for the sprite (normalised by texture width). + * + * @property render.sprite.xOffset + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the offset in the y-axis for the sprite (normalised by texture height). + * + * @property render.sprite.yOffset + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the line width to use when rendering the body outline (if a sprite is not defined). + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 1.5 + */ + + /** + * A `String` that defines the fill style to use when rendering the body (if a sprite is not defined). + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.fillStyle + * @type string + * @default a random colour + */ + + /** + * A `String` that defines the stroke style to use when rendering the body outline (if a sprite is not defined). + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * An array of unique axis vectors (edge normals) used for collision detection. + * These are automatically calculated from the given convex hull (`vertices` array) in `Body.create`. + * They are constantly updated by `Body.update` during the simulation. + * + * @property axes + * @type vector[] + */ + + /** + * A `Number` that _measures_ the area of the body's convex hull, calculated at creation by `Body.create`. + * + * @property area + * @type string + * @default + */ + + /** + * A `Bounds` object that defines the AABB region for the body. + * It is automatically calculated from the given convex hull (`vertices` array) in `Body.create` and constantly updated by `Body.update` during simulation. + * + * @property bounds + * @type bounds + */ + +})(); + +},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29}],2:[function(require,module,exports){ +/** +* The `Matter.Composite` module contains methods for creating and manipulating composite bodies. +* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. +* It is important to use the functions in this module to modify composites, rather than directly modifying their properties. +* Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composite +*/ + +var Composite = {}; + +module.exports = Composite; + +var Events = require('../core/Events'); +var Common = require('../core/Common'); +var Body = require('./Body'); + +(function() { + + /** + * Creates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properites section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} [options] + * @return {composite} A new composite + */ + Composite.create = function(options) { + return Common.extend({ + id: Common.nextId(), + type: 'composite', + parent: null, + isModified: false, + bodies: [], + constraints: [], + composites: [], + label: 'Composite' + }, options); + }; + + /** + * Sets the composite's `isModified` flag. + * If `updateParents` is true, all parents will be set (default: false). + * If `updateChildren` is true, all children will be set (default: false). + * @method setModified + * @param {composite} composite + * @param {boolean} isModified + * @param {boolean} [updateParents=false] + * @param {boolean} [updateChildren=false] + */ + Composite.setModified = function(composite, isModified, updateParents, updateChildren) { + composite.isModified = isModified; + + if (updateParents && composite.parent) { + Composite.setModified(composite.parent, isModified, updateParents, updateChildren); + } + + if (updateChildren) { + for(var i = 0; i < composite.composites.length; i++) { + var childComposite = composite.composites[i]; + Composite.setModified(childComposite, isModified, updateParents, updateChildren); + } + } + }; + + /** + * Generic add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite. + * Triggers `beforeAdd` and `afterAdd` events on the `composite`. + * @method add + * @param {composite} composite + * @param {} object + * @return {composite} The original composite with the objects added + */ + Composite.add = function(composite, object) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeAdd', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + // skip adding compound parts + if (obj.parent !== obj) { + Common.log('Composite.add: skipped adding a compound body part (you must add its parent instead)', 'warn'); + break; + } + + Composite.addBody(composite, obj); + break; + case 'constraint': + Composite.addConstraint(composite, obj); + break; + case 'composite': + Composite.addComposite(composite, obj); + break; + case 'mouseConstraint': + Composite.addConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterAdd', { object: object }); + + return composite; + }; + + /** + * Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. + * Optionally searching its children recursively. + * Triggers `beforeRemove` and `afterRemove` events on the `composite`. + * @method remove + * @param {composite} composite + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original composite with the objects removed + */ + Composite.remove = function(composite, object, deep) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeRemove', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + Composite.removeBody(composite, obj, deep); + break; + case 'constraint': + Composite.removeConstraint(composite, obj, deep); + break; + case 'composite': + Composite.removeComposite(composite, obj, deep); + break; + case 'mouseConstraint': + Composite.removeConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterRemove', { object: object }); + + return composite; + }; + + /** + * Adds a composite to the given composite. + * @private + * @method addComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @return {composite} The original compositeA with the objects from compositeB added + */ + Composite.addComposite = function(compositeA, compositeB) { + compositeA.composites.push(compositeB); + compositeB.parent = compositeA; + Composite.setModified(compositeA, true, true, false); + return compositeA; + }; + + /** + * Removes a composite from the given composite, and optionally searching its children recursively. + * @private + * @method removeComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @param {boolean} [deep=false] + * @return {composite} The original compositeA with the composite removed + */ + Composite.removeComposite = function(compositeA, compositeB, deep) { + var position = Common.indexOf(compositeA.composites, compositeB); + if (position !== -1) { + Composite.removeCompositeAt(compositeA, position); + Composite.setModified(compositeA, true, true, false); + } + + if (deep) { + for (var i = 0; i < compositeA.composites.length; i++){ + Composite.removeComposite(compositeA.composites[i], compositeB, true); + } + } + + return compositeA; + }; + + /** + * Removes a composite from the given composite. + * @private + * @method removeCompositeAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the composite removed + */ + Composite.removeCompositeAt = function(composite, position) { + composite.composites.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a body to the given composite. + * @private + * @method addBody + * @param {composite} composite + * @param {body} body + * @return {composite} The original composite with the body added + */ + Composite.addBody = function(composite, body) { + composite.bodies.push(body); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a body from the given composite, and optionally searching its children recursively. + * @private + * @method removeBody + * @param {composite} composite + * @param {body} body + * @param {boolean} [deep=false] + * @return {composite} The original composite with the body removed + */ + Composite.removeBody = function(composite, body, deep) { + var position = Common.indexOf(composite.bodies, body); + if (position !== -1) { + Composite.removeBodyAt(composite, position); + Composite.setModified(composite, true, true, false); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeBody(composite.composites[i], body, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeBodyAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the body removed + */ + Composite.removeBodyAt = function(composite, position) { + composite.bodies.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a constraint to the given composite. + * @private + * @method addConstraint + * @param {composite} composite + * @param {constraint} constraint + * @return {composite} The original composite with the constraint added + */ + Composite.addConstraint = function(composite, constraint) { + composite.constraints.push(constraint); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a constraint from the given composite, and optionally searching its children recursively. + * @private + * @method removeConstraint + * @param {composite} composite + * @param {constraint} constraint + * @param {boolean} [deep=false] + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraint = function(composite, constraint, deep) { + var position = Common.indexOf(composite.constraints, constraint); + if (position !== -1) { + Composite.removeConstraintAt(composite, position); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeConstraint(composite.composites[i], constraint, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeConstraintAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraintAt = function(composite, position) { + composite.constraints.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes all bodies, constraints and composites from the given composite. + * Optionally clearing its children recursively. + * @method clear + * @param {composite} composite + * @param {boolean} keepStatic + * @param {boolean} [deep=false] + */ + Composite.clear = function(composite, keepStatic, deep) { + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.clear(composite.composites[i], keepStatic, true); + } + } + + if (keepStatic) { + composite.bodies = composite.bodies.filter(function(body) { return body.isStatic; }); + } else { + composite.bodies.length = 0; + } + + composite.constraints.length = 0; + composite.composites.length = 0; + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Returns all bodies in the given composite, including all bodies in its children, recursively. + * @method allBodies + * @param {composite} composite + * @return {body[]} All the bodies + */ + Composite.allBodies = function(composite) { + var bodies = [].concat(composite.bodies); + + for (var i = 0; i < composite.composites.length; i++) + bodies = bodies.concat(Composite.allBodies(composite.composites[i])); + + return bodies; + }; + + /** + * Returns all constraints in the given composite, including all constraints in its children, recursively. + * @method allConstraints + * @param {composite} composite + * @return {constraint[]} All the constraints + */ + Composite.allConstraints = function(composite) { + var constraints = [].concat(composite.constraints); + + for (var i = 0; i < composite.composites.length; i++) + constraints = constraints.concat(Composite.allConstraints(composite.composites[i])); + + return constraints; + }; + + /** + * Returns all composites in the given composite, including all composites in its children, recursively. + * @method allComposites + * @param {composite} composite + * @return {composite[]} All the composites + */ + Composite.allComposites = function(composite) { + var composites = [].concat(composite.composites); + + for (var i = 0; i < composite.composites.length; i++) + composites = composites.concat(Composite.allComposites(composite.composites[i])); + + return composites; + }; + + /** + * Searches the composite recursively for an object matching the type and id supplied, null if not found. + * @method get + * @param {composite} composite + * @param {number} id + * @param {string} type + * @return {object} The requested object, if found + */ + Composite.get = function(composite, id, type) { + var objects, + object; + + switch (type) { + case 'body': + objects = Composite.allBodies(composite); + break; + case 'constraint': + objects = Composite.allConstraints(composite); + break; + case 'composite': + objects = Composite.allComposites(composite).concat(composite); + break; + } + + if (!objects) + return null; + + object = objects.filter(function(object) { + return object.id.toString() === id.toString(); + }); + + return object.length === 0 ? null : object[0]; + }; + + /** + * Moves the given object(s) from compositeA to compositeB (equal to a remove followed by an add). + * @method move + * @param {compositeA} compositeA + * @param {object[]} objects + * @param {compositeB} compositeB + * @return {composite} Returns compositeA + */ + Composite.move = function(compositeA, objects, compositeB) { + Composite.remove(compositeA, objects); + Composite.add(compositeB, objects); + return compositeA; + }; + + /** + * Assigns new ids for all objects in the composite, recursively. + * @method rebase + * @param {composite} composite + * @return {composite} Returns composite + */ + Composite.rebase = function(composite) { + var objects = Composite.allBodies(composite) + .concat(Composite.allConstraints(composite)) + .concat(Composite.allComposites(composite)); + + for (var i = 0; i < objects.length; i++) { + objects[i].id = Common.nextId(); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Translates all children in the composite by a given vector relative to their current positions, + * without imparting any velocity. + * @method translate + * @param {composite} composite + * @param {vector} translation + * @param {bool} [recursive=true] + */ + Composite.translate = function(composite, translation, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + Body.translate(bodies[i], translation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Rotates all children in the composite by a given angle about the given point, without imparting any angular velocity. + * @method rotate + * @param {composite} composite + * @param {number} rotation + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.rotate = function(composite, rotation, point, recursive) { + var cos = Math.cos(rotation), + sin = Math.sin(rotation), + bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + (dx * cos - dy * sin), + y: point.y + (dx * sin + dy * cos) + }); + + Body.rotate(body, rotation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Scales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point. + * @method scale + * @param {composite} composite + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.scale = function(composite, scaleX, scaleY, point, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + dx * scaleX, + y: point.y + dy * scaleY + }); + + Body.scale(body, scaleX, scaleY); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when a call to `Composite.add` is made, before objects have been added. + * + * @event beforeAdd + * @param {} event An event object + * @param {} event.object The object(s) to be added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.add` is made, after objects have been added. + * + * @event afterAdd + * @param {} event An event object + * @param {} event.object The object(s) that have been added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, before objects have been removed. + * + * @event beforeRemove + * @param {} event An event object + * @param {} event.object The object(s) to be removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, after objects have been removed. + * + * @event afterRemove + * @param {} event An event object + * @param {} event.object The object(s) that have been removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "composite" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage composites. + * + * @property label + * @type string + * @default "Composite" + */ + + /** + * A flag that specifies whether the composite has been modified during the current step. + * Most `Matter.Composite` methods will automatically set this flag to `true` to inform the engine of changes to be handled. + * If you need to change it manually, you should use the `Composite.setModified` method. + * + * @property isModified + * @type boolean + * @default false + */ + + /** + * The `Composite` that is the parent of this composite. It is automatically managed by the `Matter.Composite` methods. + * + * @property parent + * @type composite + * @default null + */ + + /** + * An array of `Body` that are _direct_ children of this composite. + * To add or remove bodies you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allBodies` method. + * + * @property bodies + * @type body[] + * @default [] + */ + + /** + * An array of `Constraint` that are _direct_ children of this composite. + * To add or remove constraints you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allConstraints` method. + * + * @property constraints + * @type constraint[] + * @default [] + */ + + /** + * An array of `Composite` that are _direct_ children of this composite. + * To add or remove composites you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allComposites` method. + * + * @property composites + * @type composite[] + * @default [] + */ + +})(); + +},{"../core/Common":14,"../core/Events":16,"./Body":1}],3:[function(require,module,exports){ +/** +* The `Matter.World` module contains methods for creating and manipulating the world composite. +* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. +* A `Matter.World` has a few additional properties including `gravity` and `bounds`. +* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. +* There are also a few methods here that alias those in `Matter.Composite` for easier readability. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class World +* @extends Composite +*/ + +var World = {}; + +module.exports = World; + +var Composite = require('./Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @constructor + * @param {} options + * @return {world} A new world + */ + World.create = function(options) { + var composite = Composite.create(); + + var defaults = { + label: 'World', + gravity: { + x: 0, + y: 1, + scale: 0.001 + }, + bounds: { + min: { x: -Infinity, y: -Infinity }, + max: { x: Infinity, y: Infinity } + } + }; + + return Common.extend(composite, defaults, options); + }; + + /* + * + * Properties Documentation + * + */ + + /** + * The gravity to apply on the world. + * + * @property gravity + * @type object + */ + + /** + * The gravity x component. + * + * @property gravity.x + * @type object + * @default 0 + */ + + /** + * The gravity y component. + * + * @property gravity.y + * @type object + * @default 1 + */ + + /** + * The gravity scale factor. + * + * @property gravity.scale + * @type object + * @default 0.001 + */ + + /** + * A `Bounds` object that defines the world bounds for collision detection. + * + * @property bounds + * @type bounds + * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } + */ + + // World is a Composite body + // see src/module/Outro.js for these aliases: + + /** + * An alias for Composite.clear + * @method clear + * @param {world} world + * @param {boolean} keepStatic + */ + + /** + * An alias for Composite.add + * @method addComposite + * @param {world} world + * @param {composite} composite + * @return {world} The original world with the objects from composite added + */ + + /** + * An alias for Composite.addBody + * @method addBody + * @param {world} world + * @param {body} body + * @return {world} The original world with the body added + */ + + /** + * An alias for Composite.addConstraint + * @method addConstraint + * @param {world} world + * @param {constraint} constraint + * @return {world} The original world with the constraint added + */ + +})(); + +},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(require,module,exports){ +/** +* The `Matter.Contact` module contains methods for creating and manipulating collision contacts. +* +* @class Contact +*/ + +var Contact = {}; + +module.exports = Contact; + +(function() { + + /** + * Creates a new contact. + * @method create + * @param {vertex} vertex + * @return {contact} A new contact + */ + Contact.create = function(vertex) { + return { + id: Contact.id(vertex), + vertex: vertex, + normalImpulse: 0, + tangentImpulse: 0 + }; + }; + + /** + * Generates a contact id. + * @method id + * @param {vertex} vertex + * @return {string} Unique contactID + */ + Contact.id = function(vertex) { + return vertex.body.id + '_' + vertex.index; + }; + +})(); + +},{}],5:[function(require,module,exports){ +/** +* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. +* +* @class Detector +*/ + +// TODO: speculative contacts + +var Detector = {}; + +module.exports = Detector; + +var SAT = require('./SAT'); +var Pair = require('./Pair'); +var Bounds = require('../geometry/Bounds'); + +(function() { + + /** + * Finds all collisions given a list of pairs. + * @method collisions + * @param {pair[]} broadphasePairs + * @param {engine} engine + * @return {array} collisions + */ + Detector.collisions = function(broadphasePairs, engine) { + var collisions = [], + pairsTable = engine.pairs.table; + + + for (var i = 0; i < broadphasePairs.length; i++) { + var bodyA = broadphasePairs[i][0], + bodyB = broadphasePairs[i][1]; + + if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) + continue; + + if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) + continue; + + + // mid phase + if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { + for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { + var partA = bodyA.parts[j]; + + for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { + var partB = bodyB.parts[k]; + + if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { + // find a previous collision we could reuse + var pairId = Pair.id(partA, partB), + pair = pairsTable[pairId], + previousCollision; + + if (pair && pair.isActive) { + previousCollision = pair.collision; + } else { + previousCollision = null; + } + + // narrow phase + var collision = SAT.collides(partA, partB, previousCollision); + + + if (collision.collided) { + collisions.push(collision); + } + } + } + } + } + } + + return collisions; + }; + + /** + * Returns `true` if both supplied collision filters will allow a collision to occur. + * See `body.collisionFilter` for more information. + * @method canCollide + * @param {} filterA + * @param {} filterB + * @return {bool} `true` if collision can occur + */ + Detector.canCollide = function(filterA, filterB) { + if (filterA.group === filterB.group && filterA.group !== 0) + return filterA.group > 0; + + return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; + }; + +})(); + +},{"../geometry/Bounds":24,"./Pair":7,"./SAT":11}],6:[function(require,module,exports){ +/** +* The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures. +* +* @class Grid +*/ + +var Grid = {}; + +module.exports = Grid; + +var Pair = require('./Pair'); +var Detector = require('./Detector'); +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a new grid. + * @method create + * @param {} options + * @return {grid} A new grid + */ + Grid.create = function(options) { + var defaults = { + controller: Grid, + detector: Detector.collisions, + buckets: {}, + pairs: {}, + pairsList: [], + bucketWidth: 48, + bucketHeight: 48 + }; + + return Common.extend(defaults, options); + }; + + /** + * The width of a single grid bucket. + * + * @property bucketWidth + * @type number + * @default 48 + */ + + /** + * The height of a single grid bucket. + * + * @property bucketHeight + * @type number + * @default 48 + */ + + /** + * Updates the grid. + * @method update + * @param {grid} grid + * @param {body[]} bodies + * @param {engine} engine + * @param {boolean} forceUpdate + */ + Grid.update = function(grid, bodies, engine, forceUpdate) { + var i, col, row, + world = engine.world, + buckets = grid.buckets, + bucket, + bucketId, + gridChanged = false; + + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isSleeping && !forceUpdate) + continue; + + // don't update out of world bodies + if (body.bounds.max.x < world.bounds.min.x || body.bounds.min.x > world.bounds.max.x + || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) + continue; + + var newRegion = _getRegion(grid, body); + + // if the body has changed grid region + if (!body.region || newRegion.id !== body.region.id || forceUpdate) { + + + if (!body.region || forceUpdate) + body.region = newRegion; + + var union = _regionUnion(newRegion, body.region); + + // update grid buckets affected by region change + // iterate over the union of both regions + for (col = union.startCol; col <= union.endCol; col++) { + for (row = union.startRow; row <= union.endRow; row++) { + bucketId = _getBucketId(col, row); + bucket = buckets[bucketId]; + + var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol + && row >= newRegion.startRow && row <= newRegion.endRow); + + var isInsideOldRegion = (col >= body.region.startCol && col <= body.region.endCol + && row >= body.region.startRow && row <= body.region.endRow); + + // remove from old region buckets + if (!isInsideNewRegion && isInsideOldRegion) { + if (isInsideOldRegion) { + if (bucket) + _bucketRemoveBody(grid, bucket, body); + } + } + + // add to new region buckets + if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { + if (!bucket) + bucket = _createBucket(buckets, bucketId); + _bucketAddBody(grid, bucket, body); + } + } + } + + // set the new region + body.region = newRegion; + + // flag changes so we can update pairs + gridChanged = true; + } + } + + // update pairs list only if pairs changed (i.e. a body changed region) + if (gridChanged) + grid.pairsList = _createActivePairsList(grid); + }; + + /** + * Clears the grid. + * @method clear + * @param {grid} grid + */ + Grid.clear = function(grid) { + grid.buckets = {}; + grid.pairs = {}; + grid.pairsList = []; + }; + + /** + * Finds the union of two regions. + * @method _regionUnion + * @private + * @param {} regionA + * @param {} regionB + * @return {} region + */ + var _regionUnion = function(regionA, regionB) { + var startCol = Math.min(regionA.startCol, regionB.startCol), + endCol = Math.max(regionA.endCol, regionB.endCol), + startRow = Math.min(regionA.startRow, regionB.startRow), + endRow = Math.max(regionA.endRow, regionB.endRow); + + return _createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Gets the region a given body falls in for a given grid. + * @method _getRegion + * @private + * @param {} grid + * @param {} body + * @return {} region + */ + var _getRegion = function(grid, body) { + var bounds = body.bounds, + startCol = Math.floor(bounds.min.x / grid.bucketWidth), + endCol = Math.floor(bounds.max.x / grid.bucketWidth), + startRow = Math.floor(bounds.min.y / grid.bucketHeight), + endRow = Math.floor(bounds.max.y / grid.bucketHeight); + + return _createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Creates a region. + * @method _createRegion + * @private + * @param {} startCol + * @param {} endCol + * @param {} startRow + * @param {} endRow + * @return {} region + */ + var _createRegion = function(startCol, endCol, startRow, endRow) { + return { + id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, + startCol: startCol, + endCol: endCol, + startRow: startRow, + endRow: endRow + }; + }; + + /** + * Gets the bucket id at the given position. + * @method _getBucketId + * @private + * @param {} column + * @param {} row + * @return {string} bucket id + */ + var _getBucketId = function(column, row) { + return column + ',' + row; + }; + + /** + * Creates a bucket. + * @method _createBucket + * @private + * @param {} buckets + * @param {} bucketId + * @return {} bucket + */ + var _createBucket = function(buckets, bucketId) { + var bucket = buckets[bucketId] = []; + return bucket; + }; + + /** + * Adds a body to a bucket. + * @method _bucketAddBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + var _bucketAddBody = function(grid, bucket, body) { + // add new pairs + for (var i = 0; i < bucket.length; i++) { + var bodyB = bucket[i]; + + if (body.id === bodyB.id || (body.isStatic && bodyB.isStatic)) + continue; + + // keep track of the number of buckets the pair exists in + // important for Grid.update to work + var pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) { + pair[2] += 1; + } else { + grid.pairs[pairId] = [body, bodyB, 1]; + } + } + + // add to bodies (after pairs, otherwise pairs with self) + bucket.push(body); + }; + + /** + * Removes a body from a bucket. + * @method _bucketRemoveBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + var _bucketRemoveBody = function(grid, bucket, body) { + // remove from bucket + bucket.splice(Common.indexOf(bucket, body), 1); + + // update pair counts + for (var i = 0; i < bucket.length; i++) { + // keep track of the number of buckets the pair exists in + // important for _createActivePairsList to work + var bodyB = bucket[i], + pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) + pair[2] -= 1; + } + }; + + /** + * Generates a list of the active pairs in the grid. + * @method _createActivePairsList + * @private + * @param {} grid + * @return [] pairs + */ + var _createActivePairsList = function(grid) { + var pairKeys, + pair, + pairs = []; + + // grid.pairs is used as a hashmap + pairKeys = Common.keys(grid.pairs); + + // iterate over grid.pairs + for (var k = 0; k < pairKeys.length; k++) { + pair = grid.pairs[pairKeys[k]]; + + // if pair exists in at least one bucket + // it is a pair that needs further collision testing so push it + if (pair[2] > 0) { + pairs.push(pair); + } else { + delete grid.pairs[pairKeys[k]]; + } + } + + return pairs; + }; + +})(); + +},{"../core/Common":14,"./Detector":5,"./Pair":7}],7:[function(require,module,exports){ +/** +* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. +* +* @class Pair +*/ + +var Pair = {}; + +module.exports = Pair; + +var Contact = require('./Contact'); + +(function() { + + /** + * Creates a pair. + * @method create + * @param {collision} collision + * @param {number} timestamp + * @return {pair} A new pair + */ + Pair.create = function(collision, timestamp) { + var bodyA = collision.bodyA, + bodyB = collision.bodyB, + parentA = collision.parentA, + parentB = collision.parentB; + + var pair = { + id: Pair.id(bodyA, bodyB), + bodyA: bodyA, + bodyB: bodyB, + contacts: {}, + activeContacts: [], + separation: 0, + isActive: true, + isSensor: bodyA.isSensor || bodyB.isSensor, + timeCreated: timestamp, + timeUpdated: timestamp, + inverseMass: parentA.inverseMass + parentB.inverseMass, + friction: Math.min(parentA.friction, parentB.friction), + frictionStatic: Math.max(parentA.frictionStatic, parentB.frictionStatic), + restitution: Math.max(parentA.restitution, parentB.restitution), + slop: Math.max(parentA.slop, parentB.slop) + }; + + Pair.update(pair, collision, timestamp); + + return pair; + }; + + /** + * Updates a pair given a collision. + * @method update + * @param {pair} pair + * @param {collision} collision + * @param {number} timestamp + */ + Pair.update = function(pair, collision, timestamp) { + var contacts = pair.contacts, + supports = collision.supports, + activeContacts = pair.activeContacts, + parentA = collision.parentA, + parentB = collision.parentB; + + pair.collision = collision; + pair.inverseMass = parentA.inverseMass + parentB.inverseMass; + pair.friction = Math.min(parentA.friction, parentB.friction); + pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); + pair.restitution = Math.max(parentA.restitution, parentB.restitution); + pair.slop = Math.max(parentA.slop, parentB.slop); + activeContacts.length = 0; + + if (collision.collided) { + for (var i = 0; i < supports.length; i++) { + var support = supports[i], + contactId = Contact.id(support), + contact = contacts[contactId]; + + if (contact) { + activeContacts.push(contact); + } else { + activeContacts.push(contacts[contactId] = Contact.create(support)); + } + } + + pair.separation = collision.depth; + Pair.setActive(pair, true, timestamp); + } else { + if (pair.isActive === true) + Pair.setActive(pair, false, timestamp); + } + }; + + /** + * Set a pair as active or inactive. + * @method setActive + * @param {pair} pair + * @param {bool} isActive + * @param {number} timestamp + */ + Pair.setActive = function(pair, isActive, timestamp) { + if (isActive) { + pair.isActive = true; + pair.timeUpdated = timestamp; + } else { + pair.isActive = false; + pair.activeContacts.length = 0; + } + }; + + /** + * Get the id for the given pair. + * @method id + * @param {body} bodyA + * @param {body} bodyB + * @return {string} Unique pairId + */ + Pair.id = function(bodyA, bodyB) { + if (bodyA.id < bodyB.id) { + return bodyA.id + '_' + bodyB.id; + } else { + return bodyB.id + '_' + bodyA.id; + } + }; + +})(); + +},{"./Contact":4}],8:[function(require,module,exports){ +/** +* The `Matter.Pairs` module contains methods for creating and manipulating collision pair sets. +* +* @class Pairs +*/ + +var Pairs = {}; + +module.exports = Pairs; + +var Pair = require('./Pair'); +var Common = require('../core/Common'); + +(function() { + + var _pairMaxIdleLife = 1000; + + /** + * Creates a new pairs structure. + * @method create + * @param {object} options + * @return {pairs} A new pairs structure + */ + Pairs.create = function(options) { + return Common.extend({ + table: {}, + list: [], + collisionStart: [], + collisionActive: [], + collisionEnd: [] + }, options); + }; + + /** + * Updates pairs given a list of collisions. + * @method update + * @param {object} pairs + * @param {collision[]} collisions + * @param {number} timestamp + */ + Pairs.update = function(pairs, collisions, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + collisionStart = pairs.collisionStart, + collisionEnd = pairs.collisionEnd, + collisionActive = pairs.collisionActive, + activePairIds = [], + collision, + pairId, + pair, + i; + + // clear collision state arrays, but maintain old reference + collisionStart.length = 0; + collisionEnd.length = 0; + collisionActive.length = 0; + + for (i = 0; i < collisions.length; i++) { + collision = collisions[i]; + + if (collision.collided) { + pairId = Pair.id(collision.bodyA, collision.bodyB); + activePairIds.push(pairId); + + pair = pairsTable[pairId]; + + if (pair) { + // pair already exists (but may or may not be active) + if (pair.isActive) { + // pair exists and is active + collisionActive.push(pair); + } else { + // pair exists but was inactive, so a collision has just started again + collisionStart.push(pair); + } + + // update the pair + Pair.update(pair, collision, timestamp); + } else { + // pair did not exist, create a new pair + pair = Pair.create(collision, timestamp); + pairsTable[pairId] = pair; + + // push the new pair + collisionStart.push(pair); + pairsList.push(pair); + } + } + } + + // deactivate previously active pairs that are now inactive + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + if (pair.isActive && Common.indexOf(activePairIds, pair.id) === -1) { + Pair.setActive(pair, false, timestamp); + collisionEnd.push(pair); + } + } + }; + + /** + * Finds and removes pairs that have been inactive for a set amount of time. + * @method removeOld + * @param {object} pairs + * @param {number} timestamp + */ + Pairs.removeOld = function(pairs, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + indexesToRemove = [], + pair, + collision, + pairIndex, + i; + + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + collision = pair.collision; + + // never remove sleeping pairs + if (collision.bodyA.isSleeping || collision.bodyB.isSleeping) { + pair.timeUpdated = timestamp; + continue; + } + + // if pair is inactive for too long, mark it to be removed + if (timestamp - pair.timeUpdated > _pairMaxIdleLife) { + indexesToRemove.push(i); + } + } + + // remove marked pairs + for (i = 0; i < indexesToRemove.length; i++) { + pairIndex = indexesToRemove[i] - i; + pair = pairsList[pairIndex]; + delete pairsTable[pair.id]; + pairsList.splice(pairIndex, 1); + } + }; + + /** + * Clears the given pairs structure. + * @method clear + * @param {pairs} pairs + * @return {pairs} pairs + */ + Pairs.clear = function(pairs) { + pairs.table = {}; + pairs.list.length = 0; + pairs.collisionStart.length = 0; + pairs.collisionActive.length = 0; + pairs.collisionEnd.length = 0; + return pairs; + }; + +})(); + +},{"../core/Common":14,"./Pair":7}],9:[function(require,module,exports){ +/** +* The `Matter.Query` module contains methods for performing collision queries. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Query +*/ + +var Query = {}; + +module.exports = Query; + +var Vector = require('../geometry/Vector'); +var SAT = require('./SAT'); +var Bounds = require('../geometry/Bounds'); +var Bodies = require('../factory/Bodies'); +var Vertices = require('../geometry/Vertices'); + +(function() { + + /** + * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. + * @method ray + * @param {body[]} bodies + * @param {vector} startPoint + * @param {vector} endPoint + * @param {number} [rayWidth] + * @return {object[]} Collisions + */ + Query.ray = function(bodies, startPoint, endPoint, rayWidth) { + rayWidth = rayWidth || 1e-100; + + var rayAngle = Vector.angle(startPoint, endPoint), + rayLength = Vector.magnitude(Vector.sub(startPoint, endPoint)), + rayX = (endPoint.x + startPoint.x) * 0.5, + rayY = (endPoint.y + startPoint.y) * 0.5, + ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), + collisions = []; + + for (var i = 0; i < bodies.length; i++) { + var bodyA = bodies[i]; + + if (Bounds.overlaps(bodyA.bounds, ray.bounds)) { + for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { + var part = bodyA.parts[j]; + + if (Bounds.overlaps(part.bounds, ray.bounds)) { + var collision = SAT.collides(part, ray); + if (collision.collided) { + collision.body = collision.bodyA = collision.bodyB = bodyA; + collisions.push(collision); + break; + } + } + } + } + } + + return collisions; + }; + + /** + * Returns all bodies whose bounds are inside (or outside if set) the given set of bounds, from the given set of bodies. + * @method region + * @param {body[]} bodies + * @param {bounds} bounds + * @param {bool} [outside=false] + * @return {body[]} The bodies matching the query + */ + Query.region = function(bodies, bounds, outside) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + overlaps = Bounds.overlaps(body.bounds, bounds); + if ((overlaps && !outside) || (!overlaps && outside)) + result.push(body); + } + + return result; + }; + + /** + * Returns all bodies whose vertices contain the given point, from the given set of bodies. + * @method point + * @param {body[]} bodies + * @param {vector} point + * @return {body[]} The bodies matching the query + */ + Query.point = function(bodies, point) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (Bounds.contains(body.bounds, point)) { + for (var j = body.parts.length === 1 ? 0 : 1; j < body.parts.length; j++) { + var part = body.parts[j]; + + if (Bounds.contains(part.bounds, point) + && Vertices.contains(part.vertices, point)) { + result.push(body); + break; + } + } + } + } + + return result; + }; + +})(); + +},{"../factory/Bodies":21,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"./SAT":11}],10:[function(require,module,exports){ +/** +* The `Matter.Resolver` module contains methods for resolving collision pairs. +* +* @class Resolver +*/ + +var Resolver = {}; + +module.exports = Resolver; + +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); + +(function() { + + Resolver._restingThresh = 4; + Resolver._restingThreshTangent = 6; + Resolver._positionDampen = 0.9; + Resolver._positionWarming = 0.8; + Resolver._frictionNormalMultiplier = 5; + + /** + * Prepare pairs for position solving. + * @method preSolvePosition + * @param {pair[]} pairs + */ + Resolver.preSolvePosition = function(pairs) { + var i, + pair, + activeCount; + + // find total contacts on each body + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + activeCount = pair.activeContacts.length; + pair.collision.parentA.totalContacts += activeCount; + pair.collision.parentB.totalContacts += activeCount; + } + }; + + /** + * Find a solution for pair positions. + * @method solvePosition + * @param {pair[]} pairs + * @param {number} timeScale + */ + Resolver.solvePosition = function(pairs, timeScale) { + var i, + pair, + collision, + bodyA, + bodyB, + normal, + bodyBtoA, + contactShare, + positionImpulse, + contactCount = {}, + tempA = Vector._temp[0], + tempB = Vector._temp[1], + tempC = Vector._temp[2], + tempD = Vector._temp[3]; + + // find impulses required to resolve penetration + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + + // get current separation between body edges involved in collision + bodyBtoA = Vector.sub(Vector.add(bodyB.positionImpulse, bodyB.position, tempA), + Vector.add(bodyA.positionImpulse, + Vector.sub(bodyB.position, collision.penetration, tempB), tempC), tempD); + + pair.separation = Vector.dot(normal, bodyBtoA); + } + + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor || pair.separation < 0) + continue; + + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + positionImpulse = (pair.separation - pair.slop) * timeScale; + + if (bodyA.isStatic || bodyB.isStatic) + positionImpulse *= 2; + + if (!(bodyA.isStatic || bodyA.isSleeping)) { + contactShare = Resolver._positionDampen / bodyA.totalContacts; + bodyA.positionImpulse.x += normal.x * positionImpulse * contactShare; + bodyA.positionImpulse.y += normal.y * positionImpulse * contactShare; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + contactShare = Resolver._positionDampen / bodyB.totalContacts; + bodyB.positionImpulse.x -= normal.x * positionImpulse * contactShare; + bodyB.positionImpulse.y -= normal.y * positionImpulse * contactShare; + } + } + }; + + /** + * Apply position resolution. + * @method postSolvePosition + * @param {body[]} bodies + */ + Resolver.postSolvePosition = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset contact count + body.totalContacts = 0; + + if (body.positionImpulse.x !== 0 || body.positionImpulse.y !== 0) { + // update body geometry + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + Vertices.translate(part.vertices, body.positionImpulse); + Bounds.update(part.bounds, part.vertices, body.velocity); + part.position.x += body.positionImpulse.x; + part.position.y += body.positionImpulse.y; + } + + // move the body without changing velocity + body.positionPrev.x += body.positionImpulse.x; + body.positionPrev.y += body.positionImpulse.y; + + if (Vector.dot(body.positionImpulse, body.velocity) < 0) { + // reset cached impulse if the body has velocity along it + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + } else { + // warm the next iteration + body.positionImpulse.x *= Resolver._positionWarming; + body.positionImpulse.y *= Resolver._positionWarming; + } + } + } + }; + + /** + * Prepare pairs for velocity solving. + * @method preSolveVelocity + * @param {pair[]} pairs + */ + Resolver.preSolveVelocity = function(pairs) { + var i, + j, + pair, + contacts, + collision, + bodyA, + bodyB, + normal, + tangent, + contact, + contactVertex, + normalImpulse, + tangentImpulse, + offset, + impulse = Vector._temp[0], + tempA = Vector._temp[1]; + + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + contacts = pair.activeContacts; + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + tangent = collision.tangent; + + // resolve each contact + for (j = 0; j < contacts.length; j++) { + contact = contacts[j]; + contactVertex = contact.vertex; + normalImpulse = contact.normalImpulse; + tangentImpulse = contact.tangentImpulse; + + if (normalImpulse !== 0 || tangentImpulse !== 0) { + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + offset = Vector.sub(contactVertex, bodyA.position, tempA); + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offset, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + offset = Vector.sub(contactVertex, bodyB.position, tempA); + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offset, impulse) * bodyB.inverseInertia; + } + } + } + } + }; + + /** + * Find a solution for pair velocities. + * @method solveVelocity + * @param {pair[]} pairs + * @param {number} timeScale + */ + Resolver.solveVelocity = function(pairs, timeScale) { + var timeScaleSquared = timeScale * timeScale, + impulse = Vector._temp[0], + tempA = Vector._temp[1], + tempB = Vector._temp[2], + tempC = Vector._temp[3], + tempD = Vector._temp[4], + tempE = Vector._temp[5]; + + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + var collision = pair.collision, + bodyA = collision.parentA, + bodyB = collision.parentB, + normal = collision.normal, + tangent = collision.tangent, + contacts = pair.activeContacts, + contactShare = 1 / contacts.length; + + // update body velocities + bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x; + bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y; + bodyB.velocity.x = bodyB.position.x - bodyB.positionPrev.x; + bodyB.velocity.y = bodyB.position.y - bodyB.positionPrev.y; + bodyA.angularVelocity = bodyA.angle - bodyA.anglePrev; + bodyB.angularVelocity = bodyB.angle - bodyB.anglePrev; + + // resolve each contact + for (var j = 0; j < contacts.length; j++) { + var contact = contacts[j], + contactVertex = contact.vertex, + offsetA = Vector.sub(contactVertex, bodyA.position, tempA), + offsetB = Vector.sub(contactVertex, bodyB.position, tempB), + velocityPointA = Vector.add(bodyA.velocity, Vector.mult(Vector.perp(offsetA), bodyA.angularVelocity), tempC), + velocityPointB = Vector.add(bodyB.velocity, Vector.mult(Vector.perp(offsetB), bodyB.angularVelocity), tempD), + relativeVelocity = Vector.sub(velocityPointA, velocityPointB, tempE), + normalVelocity = Vector.dot(normal, relativeVelocity); + + var tangentVelocity = Vector.dot(tangent, relativeVelocity), + tangentSpeed = Math.abs(tangentVelocity), + tangentVelocityDirection = Common.sign(tangentVelocity); + + // raw impulses + var normalImpulse = (1 + pair.restitution) * normalVelocity, + normalForce = Common.clamp(pair.separation + normalVelocity, 0, 1) * Resolver._frictionNormalMultiplier; + + // coulomb friction + var tangentImpulse = tangentVelocity, + maxFriction = Infinity; + + if (tangentSpeed > pair.friction * pair.frictionStatic * normalForce * timeScaleSquared) { + maxFriction = tangentSpeed; + tangentImpulse = Common.clamp( + pair.friction * tangentVelocityDirection * timeScaleSquared, + -maxFriction, maxFriction + ); + } + + // modify impulses accounting for mass, inertia and offset + var oAcN = Vector.cross(offsetA, normal), + oBcN = Vector.cross(offsetB, normal), + share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN); + + normalImpulse *= share; + tangentImpulse *= share; + + // handle high velocity and resting collisions separately + if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) { + // high normal velocity so clear cached contact normal impulse + contact.normalImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // impulse constraint tends to 0 + var contactNormalImpulse = contact.normalImpulse; + contact.normalImpulse = Math.min(contact.normalImpulse + normalImpulse, 0); + normalImpulse = contact.normalImpulse - contactNormalImpulse; + } + + // handle high velocity and resting collisions separately + if (tangentVelocity * tangentVelocity > Resolver._restingThreshTangent * timeScaleSquared) { + // high tangent velocity so clear cached contact tangent impulse + contact.tangentImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // tangent impulse tends to -tangentSpeed or +tangentSpeed + var contactTangentImpulse = contact.tangentImpulse; + contact.tangentImpulse = Common.clamp(contact.tangentImpulse + tangentImpulse, -maxFriction, maxFriction); + tangentImpulse = contact.tangentImpulse - contactTangentImpulse; + } + + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offsetA, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offsetB, impulse) * bodyB.inverseInertia; + } + } + } + }; + +})(); + +},{"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],11:[function(require,module,exports){ +/** +* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. +* +* @class SAT +*/ + +// TODO: true circles and curves + +var SAT = {}; + +module.exports = SAT; + +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); + +(function() { + + /** + * Detect collision between two bodies using the Separating Axis Theorem. + * @method collides + * @param {body} bodyA + * @param {body} bodyB + * @param {collision} previousCollision + * @return {collision} collision + */ + SAT.collides = function(bodyA, bodyB, previousCollision) { + var overlapAB, + overlapBA, + minOverlap, + collision, + prevCol = previousCollision, + canReusePrevCol = false; + + if (prevCol) { + // estimate total motion + var parentA = bodyA.parent, + parentB = bodyB.parent, + motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed + + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; + + // we may be able to (partially) reuse collision result + // but only safe if collision was resting + canReusePrevCol = prevCol && prevCol.collided && motion < 0.2; + + // reuse collision object + collision = prevCol; + } else { + collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; + } + + if (prevCol && canReusePrevCol) { + // if we can reuse the collision result + // we only need to test the previously found axis + var axisBodyA = collision.axisBody, + axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, + axes = [axisBodyA.axes[prevCol.axisNumber]]; + + minOverlap = _overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); + collision.reused = true; + + if (minOverlap.overlap <= 0) { + collision.collided = false; + return collision; + } + } else { + // if we can't reuse a result, perform a full SAT test + + overlapAB = _overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); + + if (overlapAB.overlap <= 0) { + collision.collided = false; + return collision; + } + + overlapBA = _overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); + + if (overlapBA.overlap <= 0) { + collision.collided = false; + return collision; + } + + if (overlapAB.overlap < overlapBA.overlap) { + minOverlap = overlapAB; + collision.axisBody = bodyA; + } else { + minOverlap = overlapBA; + collision.axisBody = bodyB; + } + + // important for reuse later + collision.axisNumber = minOverlap.axisNumber; + } + + collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; + collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; + collision.collided = true; + collision.normal = minOverlap.axis; + collision.depth = minOverlap.overlap; + collision.parentA = collision.bodyA.parent; + collision.parentB = collision.bodyB.parent; + + bodyA = collision.bodyA; + bodyB = collision.bodyB; + + // ensure normal is facing away from bodyA + if (Vector.dot(collision.normal, Vector.sub(bodyB.position, bodyA.position)) > 0) + collision.normal = Vector.neg(collision.normal); + + collision.tangent = Vector.perp(collision.normal); + + collision.penetration = { + x: collision.normal.x * collision.depth, + y: collision.normal.y * collision.depth + }; + + // find support points, there is always either exactly one or two + var verticesB = _findSupports(bodyA, bodyB, collision.normal), + supports = collision.supports || []; + supports.length = 0; + + // find the supports from bodyB that are inside bodyA + if (Vertices.contains(bodyA.vertices, verticesB[0])) + supports.push(verticesB[0]); + + if (Vertices.contains(bodyA.vertices, verticesB[1])) + supports.push(verticesB[1]); + + // find the supports from bodyA that are inside bodyB + if (supports.length < 2) { + var verticesA = _findSupports(bodyB, bodyA, Vector.neg(collision.normal)); + + if (Vertices.contains(bodyB.vertices, verticesA[0])) + supports.push(verticesA[0]); + + if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) + supports.push(verticesA[1]); + } + + // account for the edge case of overlapping but no vertex containment + if (supports.length < 1) + supports = [verticesB[0]]; + + collision.supports = supports; + + return collision; + }; + + /** + * Find the overlap between two sets of vertices. + * @method _overlapAxes + * @private + * @param {} verticesA + * @param {} verticesB + * @param {} axes + * @return result + */ + var _overlapAxes = function(verticesA, verticesB, axes) { + var projectionA = Vector._temp[0], + projectionB = Vector._temp[1], + result = { overlap: Number.MAX_VALUE }, + overlap, + axis; + + for (var i = 0; i < axes.length; i++) { + axis = axes[i]; + + _projectToAxis(projectionA, verticesA, axis); + _projectToAxis(projectionB, verticesB, axis); + + overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); + + if (overlap <= 0) { + result.overlap = overlap; + return result; + } + + if (overlap < result.overlap) { + result.overlap = overlap; + result.axis = axis; + result.axisNumber = i; + } + } + + return result; + }; + + /** + * Projects vertices on an axis and returns an interval. + * @method _projectToAxis + * @private + * @param {} projection + * @param {} vertices + * @param {} axis + */ + var _projectToAxis = function(projection, vertices, axis) { + var min = Vector.dot(vertices[0], axis), + max = min; + + for (var i = 1; i < vertices.length; i += 1) { + var dot = Vector.dot(vertices[i], axis); + + if (dot > max) { + max = dot; + } else if (dot < min) { + min = dot; + } + } + + projection.min = min; + projection.max = max; + }; + + /** + * Finds supporting vertices given two bodies along a given direction using hill-climbing. + * @method _findSupports + * @private + * @param {} bodyA + * @param {} bodyB + * @param {} normal + * @return [vector] + */ + var _findSupports = function(bodyA, bodyB, normal) { + var nearestDistance = Number.MAX_VALUE, + vertexToBody = Vector._temp[0], + vertices = bodyB.vertices, + bodyAPosition = bodyA.position, + distance, + vertex, + vertexA, + vertexB; + + // find closest vertex on bodyB + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + + if (distance < nearestDistance) { + nearestDistance = distance; + vertexA = vertex; + } + } + + // find next closest vertex using the two connected to it + var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; + vertex = vertices[prevIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + nearestDistance = -Vector.dot(normal, vertexToBody); + vertexB = vertex; + + var nextIndex = (vertexA.index + 1) % vertices.length; + vertex = vertices[nextIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + if (distance < nearestDistance) { + vertexB = vertex; + } + + return [vertexA, vertexB]; + }; + +})(); + +},{"../geometry/Vector":26,"../geometry/Vertices":27}],12:[function(require,module,exports){ +/** +* The `Matter.Constraint` module contains methods for creating and manipulating constraints. +* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). +* The stiffness of constraints can be modified to create springs or elastic. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Constraint +*/ + +// TODO: fix instability issues with torque +// TODO: linked constraints +// TODO: breakable constraints +// TODO: collision constraints +// TODO: allow constrained bodies to sleep +// TODO: handle 0 length constraints properly +// TODO: impulse caching and warming + +var Constraint = {}; + +module.exports = Constraint; + +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); +var Sleeping = require('../core/Sleeping'); +var Bounds = require('../geometry/Bounds'); +var Axes = require('../geometry/Axes'); +var Common = require('../core/Common'); + +(function() { + + var _minLength = 0.000001, + _minDifference = 0.001; + + /** + * Creates a new constraint. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} options + * @return {constraint} constraint + */ + Constraint.create = function(options) { + var constraint = options; + + // if bodies defined but no points, use body centre + if (constraint.bodyA && !constraint.pointA) + constraint.pointA = { x: 0, y: 0 }; + if (constraint.bodyB && !constraint.pointB) + constraint.pointB = { x: 0, y: 0 }; + + // calculate static length using initial world space points + var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, + initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, + length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); + + constraint.length = constraint.length || length || _minLength; + + // render + var render = { + visible: true, + lineWidth: 2, + strokeStyle: '#666666' + }; + + constraint.render = Common.extend(render, constraint.render); + + // option defaults + constraint.id = constraint.id || Common.nextId(); + constraint.label = constraint.label || 'Constraint'; + constraint.type = 'constraint'; + constraint.stiffness = constraint.stiffness || 1; + constraint.angularStiffness = constraint.angularStiffness || 0; + constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; + constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; + + return constraint; + }; + + /** + * Solves all constraints in a list of collisions. + * @private + * @method solveAll + * @param {constraint[]} constraints + * @param {number} timeScale + */ + Constraint.solveAll = function(constraints, timeScale) { + for (var i = 0; i < constraints.length; i++) { + Constraint.solve(constraints[i], timeScale); + } + }; + + /** + * Solves a distance constraint with Gauss-Siedel method. + * @private + * @method solve + * @param {constraint} constraint + * @param {number} timeScale + */ + Constraint.solve = function(constraint, timeScale) { + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointA = constraint.pointA, + pointB = constraint.pointB; + + // update reference angle + if (bodyA && !bodyA.isStatic) { + constraint.pointA = Vector.rotate(pointA, bodyA.angle - constraint.angleA); + constraint.angleA = bodyA.angle; + } + + // update reference angle + if (bodyB && !bodyB.isStatic) { + constraint.pointB = Vector.rotate(pointB, bodyB.angle - constraint.angleB); + constraint.angleB = bodyB.angle; + } + + var pointAWorld = pointA, + pointBWorld = pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); + + if (!pointAWorld || !pointBWorld) + return; + + var delta = Vector.sub(pointAWorld, pointBWorld), + currentLength = Vector.magnitude(delta); + + // prevent singularity + if (currentLength === 0) + currentLength = _minLength; + + // solve distance constraint with Gauss-Siedel method + var difference = (currentLength - constraint.length) / currentLength, + normal = Vector.div(delta, currentLength), + force = Vector.mult(delta, difference * 0.5 * constraint.stiffness * timeScale * timeScale); + + // if difference is very small, we can skip + if (Math.abs(1 - (currentLength / constraint.length)) < _minDifference * timeScale) + return; + + var velocityPointA, + velocityPointB, + offsetA, + offsetB, + oAn, + oBn, + bodyADenom, + bodyBDenom; + + if (bodyA && !bodyA.isStatic) { + // point body offset + offsetA = { + x: pointAWorld.x - bodyA.position.x + force.x, + y: pointAWorld.y - bodyA.position.y + force.y + }; + + // update velocity + bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x; + bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y; + bodyA.angularVelocity = bodyA.angle - bodyA.anglePrev; + + // find point velocity and body mass + velocityPointA = Vector.add(bodyA.velocity, Vector.mult(Vector.perp(offsetA), bodyA.angularVelocity)); + oAn = Vector.dot(offsetA, normal); + bodyADenom = bodyA.inverseMass + bodyA.inverseInertia * oAn * oAn; + } else { + velocityPointA = { x: 0, y: 0 }; + bodyADenom = bodyA ? bodyA.inverseMass : 0; + } + + if (bodyB && !bodyB.isStatic) { + // point body offset + offsetB = { + x: pointBWorld.x - bodyB.position.x - force.x, + y: pointBWorld.y - bodyB.position.y - force.y + }; + + // update velocity + bodyB.velocity.x = bodyB.position.x - bodyB.positionPrev.x; + bodyB.velocity.y = bodyB.position.y - bodyB.positionPrev.y; + bodyB.angularVelocity = bodyB.angle - bodyB.anglePrev; + + // find point velocity and body mass + velocityPointB = Vector.add(bodyB.velocity, Vector.mult(Vector.perp(offsetB), bodyB.angularVelocity)); + oBn = Vector.dot(offsetB, normal); + bodyBDenom = bodyB.inverseMass + bodyB.inverseInertia * oBn * oBn; + } else { + velocityPointB = { x: 0, y: 0 }; + bodyBDenom = bodyB ? bodyB.inverseMass : 0; + } + + var relativeVelocity = Vector.sub(velocityPointB, velocityPointA), + normalImpulse = Vector.dot(normal, relativeVelocity) / (bodyADenom + bodyBDenom); + + if (normalImpulse > 0) normalImpulse = 0; + + var normalVelocity = { + x: normal.x * normalImpulse, + y: normal.y * normalImpulse + }; + + var torque; + + if (bodyA && !bodyA.isStatic) { + torque = Vector.cross(offsetA, normalVelocity) * bodyA.inverseInertia * (1 - constraint.angularStiffness); + + // keep track of applied impulses for post solving + bodyA.constraintImpulse.x -= force.x; + bodyA.constraintImpulse.y -= force.y; + bodyA.constraintImpulse.angle += torque; + + // apply forces + bodyA.position.x -= force.x; + bodyA.position.y -= force.y; + bodyA.angle += torque; + } + + if (bodyB && !bodyB.isStatic) { + torque = Vector.cross(offsetB, normalVelocity) * bodyB.inverseInertia * (1 - constraint.angularStiffness); + + // keep track of applied impulses for post solving + bodyB.constraintImpulse.x += force.x; + bodyB.constraintImpulse.y += force.y; + bodyB.constraintImpulse.angle -= torque; + + // apply forces + bodyB.position.x += force.x; + bodyB.position.y += force.y; + bodyB.angle -= torque; + } + + }; + + /** + * Performs body updates required after solving constraints. + * @private + * @method postSolveAll + * @param {body[]} bodies + */ + Constraint.postSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0) { + continue; + } + + Sleeping.set(body, false); + + // update geometry and reset + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + + Vertices.translate(part.vertices, impulse); + + if (j > 0) { + part.position.x += impulse.x; + part.position.y += impulse.y; + } + + if (impulse.angle !== 0) { + Vertices.rotate(part.vertices, impulse.angle, body.position); + Axes.rotate(part.axes, impulse.angle); + if (j > 0) { + Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + impulse.angle = 0; + impulse.x = 0; + impulse.y = 0; + } + }; + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "constraint" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Constraint" + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the constraint should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * A `Number` that defines the line width to use when rendering the constraint outline. + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 2 + */ + + /** + * A `String` that defines the stroke style to use when rendering the constraint outline. + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * The first possible `Body` that this constraint is attached to. + * + * @property bodyA + * @type body + * @default null + */ + + /** + * The second possible `Body` that this constraint is attached to. + * + * @property bodyB + * @type body + * @default null + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointA + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointB + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. + * A value of `1` means the constraint should be very stiff. + * A value of `0.2` means the constraint acts like a soft spring. + * + * @property stiffness + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the target resting length of the constraint. + * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. + * + * @property length + * @type number + */ + +})(); + +},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],13:[function(require,module,exports){ +/** +* The `Matter.MouseConstraint` module contains methods for creating mouse constraints. +* Mouse constraints are used for allowing user interaction, providing the ability to move bodies via the mouse or touch. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class MouseConstraint +*/ + +var MouseConstraint = {}; + +module.exports = MouseConstraint; + +var Vertices = require('../geometry/Vertices'); +var Sleeping = require('../core/Sleeping'); +var Mouse = require('../core/Mouse'); +var Events = require('../core/Events'); +var Detector = require('../collision/Detector'); +var Constraint = require('./Constraint'); +var Composite = require('../body/Composite'); +var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); + +(function() { + + /** + * Creates a new mouse constraint. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {engine} engine + * @param {} options + * @return {MouseConstraint} A new MouseConstraint + */ + MouseConstraint.create = function(engine, options) { + var mouse = (engine ? engine.mouse : null) || (options ? options.mouse : null); + + if (!mouse) { + if (engine && engine.render && engine.render.canvas) { + mouse = Mouse.create(engine.render.canvas); + } else { + mouse = Mouse.create(); + Common.log('MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected', 'warn'); + } + } + + var constraint = Constraint.create({ + label: 'Mouse Constraint', + pointA: mouse.position, + pointB: { x: 0, y: 0 }, + length: 0.01, + stiffness: 0.1, + angularStiffness: 1, + render: { + strokeStyle: '#90EE90', + lineWidth: 3 + } + }); + + var defaults = { + type: 'mouseConstraint', + mouse: mouse, + body: null, + constraint: constraint, + collisionFilter: { + category: 0x0001, + mask: 0xFFFFFFFF, + group: 0 + } + }; + + var mouseConstraint = Common.extend(defaults, options); + + Events.on(engine, 'tick', function() { + var allBodies = Composite.allBodies(engine.world); + MouseConstraint.update(mouseConstraint, allBodies); + _triggerEvents(mouseConstraint); + }); + + return mouseConstraint; + }; + + /** + * Updates the given mouse constraint. + * @private + * @method update + * @param {MouseConstraint} mouseConstraint + * @param {body[]} bodies + */ + MouseConstraint.update = function(mouseConstraint, bodies) { + var mouse = mouseConstraint.mouse, + constraint = mouseConstraint.constraint, + body = mouseConstraint.body; + + if (mouse.button === 0) { + if (!constraint.bodyB) { + for (var i = 0; i < bodies.length; i++) { + body = bodies[i]; + if (Bounds.contains(body.bounds, mouse.position) + && Detector.canCollide(body.collisionFilter, mouseConstraint.collisionFilter)) { + for (var j = body.parts.length > 1 ? 1 : 0; j < body.parts.length; j++) { + var part = body.parts[j]; + if (Vertices.contains(part.vertices, mouse.position)) { + constraint.pointA = mouse.position; + constraint.bodyB = mouseConstraint.body = body; + constraint.pointB = { x: mouse.position.x - body.position.x, y: mouse.position.y - body.position.y }; + constraint.angleB = body.angle; + + Sleeping.set(body, false); + Events.trigger(mouseConstraint, 'startdrag', { mouse: mouse, body: body }); + + break; + } + } + } + } + } else { + Sleeping.set(constraint.bodyB, false); + constraint.pointA = mouse.position; + } + } else { + constraint.bodyB = mouseConstraint.body = null; + constraint.pointB = null; + + if (body) + Events.trigger(mouseConstraint, 'enddrag', { mouse: mouse, body: body }); + } + }; + + /** + * Triggers mouse constraint events. + * @method _triggerEvents + * @private + * @param {mouse} mouseConstraint + */ + var _triggerEvents = function(mouseConstraint) { + var mouse = mouseConstraint.mouse, + mouseEvents = mouse.sourceEvents; + + if (mouseEvents.mousemove) + Events.trigger(mouseConstraint, 'mousemove', { mouse: mouse }); + + if (mouseEvents.mousedown) + Events.trigger(mouseConstraint, 'mousedown', { mouse: mouse }); + + if (mouseEvents.mouseup) + Events.trigger(mouseConstraint, 'mouseup', { mouse: mouse }); + + // reset the mouse state ready for the next step + Mouse.clearSourceEvents(mouse); + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when the mouse has moved (or a touch moves) during the last step + * + * @event mousemove + * @param {} event An event object + * @param {mouse} event.mouse The engine's mouse instance + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when the mouse is down (or a touch has started) during the last step + * + * @event mousedown + * @param {} event An event object + * @param {mouse} event.mouse The engine's mouse instance + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when the mouse is up (or a touch has ended) during the last step + * + * @event mouseup + * @param {} event An event object + * @param {mouse} event.mouse The engine's mouse instance + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when the user starts dragging a body + * + * @event startdrag + * @param {} event An event object + * @param {mouse} event.mouse The engine's mouse instance + * @param {body} event.body The body being dragged + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when the user ends dragging a body + * + * @event enddrag + * @param {} event An event object + * @param {mouse} event.mouse The engine's mouse instance + * @param {body} event.body The body that has stopped being dragged + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "constraint" + * @readOnly + */ + + /** + * The `Mouse` instance in use. If not supplied in `MouseConstraint.create`, one will be created. + * + * @property mouse + * @type mouse + * @default mouse + */ + + /** + * The `Body` that is currently being moved by the user, or `null` if no body. + * + * @property body + * @type body + * @default null + */ + + /** + * The `Constraint` object that is used to move the body during interaction. + * + * @property constraint + * @type constraint + */ + + /** + * An `Object` that specifies the collision filter properties. + * The collision filter allows the user to define which types of body this mouse constraint can interact with. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter + * @type object + */ + +})(); + +},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":18,"../core/Sleeping":20,"../geometry/Bounds":24,"../geometry/Vertices":27,"./Constraint":12}],14:[function(require,module,exports){ +/** +* The `Matter.Common` module contains utility functions that are common to all modules. +* +* @class Common +*/ + +var Common = {}; + +module.exports = Common; + +(function() { + + Common._nextId = 0; + Common._seed = 0; + + /** + * Extends the object in the first argument using the object in the second argument. + * @method extend + * @param {} obj + * @param {boolean} deep + * @return {} obj extended + */ + Common.extend = function(obj, deep) { + var argsStart, + args, + deepClone; + + if (typeof deep === 'boolean') { + argsStart = 2; + deepClone = deep; + } else { + argsStart = 1; + deepClone = true; + } + + args = Array.prototype.slice.call(arguments, argsStart); + + for (var i = 0; i < args.length; i++) { + var source = args[i]; + + if (source) { + for (var prop in source) { + if (deepClone && source[prop] && source[prop].constructor === Object) { + if (!obj[prop] || obj[prop].constructor === Object) { + obj[prop] = obj[prop] || {}; + Common.extend(obj[prop], deepClone, source[prop]); + } else { + obj[prop] = source[prop]; + } + } else { + obj[prop] = source[prop]; + } + } + } + } + + return obj; + }; + + /** + * Creates a new clone of the object, if deep is true references will also be cloned. + * @method clone + * @param {} obj + * @param {bool} deep + * @return {} obj cloned + */ + Common.clone = function(obj, deep) { + return Common.extend({}, deep, obj); + }; + + /** + * Returns the list of keys for the given object. + * @method keys + * @param {} obj + * @return {string[]} keys + */ + Common.keys = function(obj) { + if (Object.keys) + return Object.keys(obj); + + // avoid hasOwnProperty for performance + var keys = []; + for (var key in obj) + keys.push(key); + return keys; + }; + + /** + * Returns the list of values for the given object. + * @method values + * @param {} obj + * @return {array} Array of the objects property values + */ + Common.values = function(obj) { + var values = []; + + if (Object.keys) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + values.push(obj[keys[i]]); + } + return values; + } + + // avoid hasOwnProperty for performance + for (var key in obj) + values.push(obj[key]); + return values; + }; + + /** + * Returns a hex colour string made by lightening or darkening color by percent. + * @method shadeColor + * @param {string} color + * @param {number} percent + * @return {string} A hex colour + */ + Common.shadeColor = function(color, percent) { + // http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color + var colorInteger = parseInt(color.slice(1),16), + amount = Math.round(2.55 * percent), + R = (colorInteger >> 16) + amount, + B = (colorInteger >> 8 & 0x00FF) + amount, + G = (colorInteger & 0x0000FF) + amount; + return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R :255) * 0x10000 + + (B < 255 ? B < 1 ? 0 : B : 255) * 0x100 + + (G < 255 ? G < 1 ? 0 : G : 255)).toString(16).slice(1); + }; + + /** + * Shuffles the given array in-place. + * The function uses a seeded random generator. + * @method shuffle + * @param {array} array + * @return {array} array shuffled randomly + */ + Common.shuffle = function(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Common.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; + }; + + /** + * Randomly chooses a value from a list with equal probability. + * The function uses a seeded random generator. + * @method choose + * @param {array} choices + * @return {object} A random choice object from the array + */ + Common.choose = function(choices) { + return choices[Math.floor(Common.random() * choices.length)]; + }; + + /** + * Returns true if the object is a HTMLElement, otherwise false. + * @method isElement + * @param {object} obj + * @return {boolean} True if the object is a HTMLElement, otherwise false + */ + Common.isElement = function(obj) { + // http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object + try { + return obj instanceof HTMLElement; + } + catch(e){ + return (typeof obj==="object") && + (obj.nodeType===1) && (typeof obj.style === "object") && + (typeof obj.ownerDocument ==="object"); + } + }; + + /** + * Returns true if the object is an array. + * @method isArray + * @param {object} obj + * @return {boolean} True if the object is an array, otherwise false + */ + Common.isArray = function(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + + /** + * Returns the given value clamped between a minimum and maximum value. + * @method clamp + * @param {number} value + * @param {number} min + * @param {number} max + * @return {number} The value clamped between min and max inclusive + */ + Common.clamp = function(value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + + /** + * Returns the sign of the given value. + * @method sign + * @param {number} value + * @return {number} -1 if negative, +1 if 0 or positive + */ + Common.sign = function(value) { + return value < 0 ? -1 : 1; + }; + + /** + * Returns the current timestamp (high-res if available). + * @method now + * @return {number} the current timestamp (high-res if available) + */ + Common.now = function() { + // http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript + // https://gist.github.com/davidwaterston/2982531 + + var performance = window.performance || {}; + + performance.now = (function() { + return performance.now || + performance.webkitNow || + performance.msNow || + performance.oNow || + performance.mozNow || + function() { return +(new Date()); }; + })(); + + return performance.now(); + }; + + + /** + * Returns a random value between a minimum and a maximum value inclusive. + * The function uses a seeded random generator. + * @method random + * @param {number} min + * @param {number} max + * @return {number} A random number between min and max inclusive + */ + Common.random = function(min, max) { + min = (typeof min !== "undefined") ? min : 0; + max = (typeof max !== "undefined") ? max : 1; + return min + _seededRandom() * (max - min); + }; + + /** + * Converts a CSS hex colour string into an integer. + * @method colorToNumber + * @param {string} colorString + * @return {number} An integer representing the CSS hex string + */ + Common.colorToNumber = function(colorString) { + colorString = colorString.replace('#',''); + + if (colorString.length == 3) { + colorString = colorString.charAt(0) + colorString.charAt(0) + + colorString.charAt(1) + colorString.charAt(1) + + colorString.charAt(2) + colorString.charAt(2); + } + + return parseInt(colorString, 16); + }; + + /** + * A wrapper for console.log, for providing errors and warnings. + * @method log + * @param {string} message + * @param {string} type + */ + Common.log = function(message, type) { + if (!console || !console.log || !console.warn) + return; + + switch (type) { + + case 'warn': + console.warn('Matter.js:', message); + break; + case 'error': + console.log('Matter.js:', message); + break; + + } + }; + + /** + * Returns the next unique sequential ID. + * @method nextId + * @return {Number} Unique sequential ID + */ + Common.nextId = function() { + return Common._nextId++; + }; + + /** + * A cross browser compatible indexOf implementation. + * @method indexOf + * @param {array} haystack + * @param {object} needle + */ + Common.indexOf = function(haystack, needle) { + if (haystack.indexOf) + return haystack.indexOf(needle); + + for (var i = 0; i < haystack.length; i++) { + if (haystack[i] === needle) + return i; + } + + return -1; + }; + + var _seededRandom = function() { + // https://gist.github.com/ngryman/3830489 + Common._seed = (Common._seed * 9301 + 49297) % 233280; + return Common._seed / 233280; + }; + +})(); + +},{}],15:[function(require,module,exports){ +/** +* The `Matter.Engine` module contains methods for creating and manipulating engines. +* An engine is a controller that manages updating the simulation of the world. +* See `Matter.Runner` for an optional game loop utility. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Engine +*/ + +var Engine = {}; + +module.exports = Engine; + +var World = require('../body/World'); +var Sleeping = require('./Sleeping'); +var Resolver = require('../collision/Resolver'); +var Render = require('../render/Render'); +var Pairs = require('../collision/Pairs'); +var Metrics = require('./Metrics'); +var Grid = require('../collision/Grid'); +var Events = require('./Events'); +var Composite = require('../body/Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('./Common'); +var Body = require('../body/Body'); + +(function() { + + /** + * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {HTMLElement} [element] + * @param {object} [options] + * @return {engine} engine + */ + Engine.create = function(element, options) { + // options may be passed as the first (and only) argument + options = Common.isElement(element) ? options : element; + element = Common.isElement(element) ? element : null; + + options = options || {}; + + var defaults = { + positionIterations: 6, + velocityIterations: 4, + constraintIterations: 2, + enableSleeping: false, + events: [], + timing: { + timestamp: 0, + timeScale: 1 + }, + broadphase: { + controller: Grid + } + }; + + var engine = Common.extend(defaults, options); + + if (element || engine.render) { + var renderDefaults = { + element: element, + controller: Render + }; + + engine.render = Common.extend(renderDefaults, engine.render); + } + + if (engine.render && engine.render.controller) { + engine.render = engine.render.controller.create(engine.render); + } + + engine.world = options.world || World.create(engine.world); + engine.pairs = Pairs.create(); + engine.broadphase = engine.broadphase.controller.create(engine.broadphase); + engine.metrics = engine.metrics || { extended: false }; + + + return engine; + }; + + /** + * Moves the simulation forward in time by `delta` ms. + * The `correction` argument is an optional `Number` that specifies the time correction factor to apply to the update. + * This can help improve the accuracy of the simulation in cases where `delta` is changing between updates. + * The value of `correction` is defined as `delta / lastDelta`, i.e. the percentage change of `delta` over the last step. + * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + * + * Triggers `beforeUpdate` and `afterUpdate` events. + * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. + * @method update + * @param {engine} engine + * @param {number} [delta=16.666] + * @param {number} [correction=1] + */ + Engine.update = function(engine, delta, correction) { + delta = delta || 1000 / 60; + correction = correction || 1; + + var world = engine.world, + timing = engine.timing, + broadphase = engine.broadphase, + broadphasePairs = [], + i; + + // increment timestamp + timing.timestamp += delta * timing.timeScale; + + // create an event object + var event = { + timestamp: timing.timestamp + }; + + Events.trigger(engine, 'beforeUpdate', event); + + // get lists of all bodies and constraints, no matter what composites they are in + var allBodies = Composite.allBodies(world), + allConstraints = Composite.allConstraints(world); + + + // if sleeping enabled, call the sleeping controller + if (engine.enableSleeping) + Sleeping.update(allBodies, timing.timeScale); + + // applies gravity to all bodies + _bodiesApplyGravity(allBodies, world.gravity); + + // update all body position and rotation by integration + _bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); + + // update all constraints + for (i = 0; i < engine.constraintIterations; i++) { + Constraint.solveAll(allConstraints, timing.timeScale); + } + Constraint.postSolveAll(allBodies); + + // broadphase pass: find potential collision pairs + if (broadphase.controller) { + + // if world is dirty, we must flush the whole grid + if (world.isModified) + broadphase.controller.clear(broadphase); + + // update the grid buckets based on current bodies + broadphase.controller.update(broadphase, allBodies, engine, world.isModified); + broadphasePairs = broadphase.pairsList; + } else { + + // if no broadphase set, we just pass all bodies + broadphasePairs = allBodies; + } + + // clear all composite modified flags + if (world.isModified) { + Composite.setModified(world, false, false, true); + } + + // narrowphase pass: find actual collisions, then create or update collision pairs + var collisions = broadphase.detector(broadphasePairs, engine); + + // update collision pairs + var pairs = engine.pairs, + timestamp = timing.timestamp; + Pairs.update(pairs, collisions, timestamp); + Pairs.removeOld(pairs, timestamp); + + // wake up bodies involved in collisions + if (engine.enableSleeping) + Sleeping.afterCollisions(pairs.list, timing.timeScale); + + // trigger collision events + if (pairs.collisionStart.length > 0) + Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); + + // iteratively resolve position between collisions + Resolver.preSolvePosition(pairs.list); + for (i = 0; i < engine.positionIterations; i++) { + Resolver.solvePosition(pairs.list, timing.timeScale); + } + Resolver.postSolvePosition(allBodies); + + // iteratively resolve velocity between collisions + Resolver.preSolveVelocity(pairs.list); + for (i = 0; i < engine.velocityIterations; i++) { + Resolver.solveVelocity(pairs.list, timing.timeScale); + } + + // trigger collision events + if (pairs.collisionActive.length > 0) + Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive }); + + if (pairs.collisionEnd.length > 0) + Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd }); + + + // clear force buffers + _bodiesClearForces(allBodies); + + Events.trigger(engine, 'afterUpdate', event); + + return engine; + }; + + /** + * Merges two engines by keeping the configuration of `engineA` but replacing the world with the one from `engineB`. + * @method merge + * @param {engine} engineA + * @param {engine} engineB + */ + Engine.merge = function(engineA, engineB) { + Common.extend(engineA, engineB); + + if (engineB.world) { + engineA.world = engineB.world; + + Engine.clear(engineA); + + var bodies = Composite.allBodies(engineA.world); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + Sleeping.set(body, false); + body.id = Common.nextId(); + } + } + }; + + /** + * Clears the engine including the world, pairs and broadphase. + * @method clear + * @param {engine} engine + */ + Engine.clear = function(engine) { + var world = engine.world; + + Pairs.clear(engine.pairs); + + var broadphase = engine.broadphase; + if (broadphase.controller) { + var bodies = Composite.allBodies(world); + broadphase.controller.clear(broadphase); + broadphase.controller.update(broadphase, bodies, engine, true); + } + }; + + /** + * Zeroes the `body.force` and `body.torque` force buffers. + * @method bodiesClearForces + * @private + * @param {body[]} bodies + */ + var _bodiesClearForces = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset force buffers + body.force.x = 0; + body.force.y = 0; + body.torque = 0; + } + }; + + /** + * Applys a mass dependant force to all given bodies. + * @method bodiesApplyGravity + * @private + * @param {body[]} bodies + * @param {vector} gravity + */ + var _bodiesApplyGravity = function(bodies, gravity) { + var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; + + if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { + return; + } + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isStatic || body.isSleeping) + continue; + + // apply gravity + body.force.y += body.mass * gravity.y * gravityScale; + body.force.x += body.mass * gravity.x * gravityScale; + } + }; + + /** + * Applys `Body.update` to all given `bodies`. + * @method updateAll + * @private + * @param {body[]} bodies + * @param {number} deltaTime + * The amount of time elapsed between updates + * @param {number} timeScale + * @param {number} correction + * The Verlet correction factor (deltaTime / lastDeltaTime) + * @param {bounds} worldBounds + */ + var _bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isStatic || body.isSleeping) + continue; + + Body.update(body, deltaTime, timeScale, correction); + } + }; + + /** + * An alias for `Runner.run`, see `Matter.Runner` for more information. + * @method run + * @param {engine} engine + */ + + /** + * Fired just before an update + * + * @event beforeUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update and all collision events + * + * @event afterUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have started to collide in the current tick (if any) + * + * @event collisionStart + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any) + * + * @event collisionActive + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have ended collision in the current tick (if any) + * + * @event collisionEnd + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` that specifies the number of position iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property positionIterations + * @type number + * @default 6 + */ + + /** + * An integer `Number` that specifies the number of velocity iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property velocityIterations + * @type number + * @default 4 + */ + + /** + * An integer `Number` that specifies the number of constraint iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * The default value of `2` is usually very adequate. + * + * @property constraintIterations + * @type number + * @default 2 + */ + + /** + * A flag that specifies whether the engine should allow sleeping via the `Matter.Sleeping` module. + * Sleeping can improve stability and performance, but often at the expense of accuracy. + * + * @property enableSleeping + * @type boolean + * @default false + */ + + /** + * An `Object` containing properties regarding the timing systems of the engine. + * + * @property timing + * @type object + */ + + /** + * A `Number` that specifies the global scaling factor of time for all bodies. + * A value of `0` freezes the simulation. + * A value of `0.1` gives a slow-motion effect. + * A value of `1.2` gives a speed-up effect. + * + * @property timing.timeScale + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the current simulation-time in milliseconds starting from `0`. + * It is incremented on every `Engine.update` by the given `delta` argument. + * + * @property timing.timestamp + * @type number + * @default 0 + */ + + /** + * An instance of a `Render` controller. The default value is a `Matter.Render` instance created by `Engine.create`. + * One may also develop a custom renderer module based on `Matter.Render` and pass an instance of it to `Engine.create` via `options.render`. + * + * A minimal custom renderer object must define at least three functions: `create`, `clear` and `world` (see `Matter.Render`). + * It is also possible to instead pass the _module_ reference via `options.render.controller` and `Engine.create` will instantiate one for you. + * + * @property render + * @type render + * @default a Matter.Render instance + */ + + /** + * An instance of a broadphase controller. The default value is a `Matter.Grid` instance created by `Engine.create`. + * + * @property broadphase + * @type grid + * @default a Matter.Grid instance + */ + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + * + * @property world + * @type world + * @default a Matter.World instance + */ + +})(); + +},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":29,"./Common":14,"./Events":16,"./Metrics":17,"./Sleeping":20}],16:[function(require,module,exports){ +/** +* The `Matter.Events` module contains methods to fire and listen to events on other objects. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Events +*/ + +var Events = {}; + +module.exports = Events; + +var Common = require('./Common'); + +(function() { + + /** + * Subscribes a callback function to the given object's `eventName`. + * @method on + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.on = function(object, eventNames, callback) { + var names = eventNames.split(' '), + name; + + for (var i = 0; i < names.length; i++) { + name = names[i]; + object.events = object.events || {}; + object.events[name] = object.events[name] || []; + object.events[name].push(callback); + } + + return callback; + }; + + /** + * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. + * @method off + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.off = function(object, eventNames, callback) { + if (!eventNames) { + object.events = {}; + return; + } + + // handle Events.off(object, callback) + if (typeof eventNames === 'function') { + callback = eventNames; + eventNames = Common.keys(object.events).join(' '); + } + + var names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + var callbacks = object.events[names[i]], + newCallbacks = []; + + if (callback && callbacks) { + for (var j = 0; j < callbacks.length; j++) { + if (callbacks[j] !== callback) + newCallbacks.push(callbacks[j]); + } + } + + object.events[names[i]] = newCallbacks; + } + }; + + /** + * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. + * @method trigger + * @param {} object + * @param {string} eventNames + * @param {} event + */ + Events.trigger = function(object, eventNames, event) { + var names, + name, + callbacks, + eventClone; + + if (object.events) { + if (!event) + event = {}; + + names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + name = names[i]; + callbacks = object.events[name]; + + if (callbacks) { + eventClone = Common.clone(event, false); + eventClone.name = name; + eventClone.source = object; + + for (var j = 0; j < callbacks.length; j++) { + callbacks[j].apply(object, [eventClone]); + } + } + } + } + }; + +})(); + +},{"./Common":14}],17:[function(require,module,exports){ + +},{"../body/Composite":2,"./Common":14}],18:[function(require,module,exports){ +/** +* The `Matter.Mouse` module contains methods for creating and manipulating mouse inputs. +* +* @class Mouse +*/ + +var Mouse = {}; + +module.exports = Mouse; + +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a mouse input. + * @method create + * @param {HTMLElement} element + * @return {mouse} A new mouse + */ + Mouse.create = function(element) { + var mouse = {}; + + if (!element) { + Common.log('Mouse.create: element was undefined, defaulting to document.body', 'warn'); + } + + mouse.element = element || document.body; + mouse.absolute = { x: 0, y: 0 }; + mouse.position = { x: 0, y: 0 }; + mouse.mousedownPosition = { x: 0, y: 0 }; + mouse.mouseupPosition = { x: 0, y: 0 }; + mouse.offset = { x: 0, y: 0 }; + mouse.scale = { x: 1, y: 1 }; + mouse.wheelDelta = 0; + mouse.button = -1; + mouse.pixelRatio = mouse.element.getAttribute('data-pixel-ratio') || 1; + + mouse.sourceEvents = { + mousemove: null, + mousedown: null, + mouseup: null, + mousewheel: null + }; + + mouse.mousemove = function(event) { + var position = _getRelativeMousePosition(event, mouse.element, mouse.pixelRatio), + touches = event.changedTouches; + + if (touches) { + mouse.button = 0; + event.preventDefault(); + } + + mouse.absolute.x = position.x; + mouse.absolute.y = position.y; + mouse.position.x = mouse.absolute.x * mouse.scale.x + mouse.offset.x; + mouse.position.y = mouse.absolute.y * mouse.scale.y + mouse.offset.y; + mouse.sourceEvents.mousemove = event; + }; + + mouse.mousedown = function(event) { + var position = _getRelativeMousePosition(event, mouse.element, mouse.pixelRatio), + touches = event.changedTouches; + + if (touches) { + mouse.button = 0; + event.preventDefault(); + } else { + mouse.button = event.button; + } + + mouse.absolute.x = position.x; + mouse.absolute.y = position.y; + mouse.position.x = mouse.absolute.x * mouse.scale.x + mouse.offset.x; + mouse.position.y = mouse.absolute.y * mouse.scale.y + mouse.offset.y; + mouse.mousedownPosition.x = mouse.position.x; + mouse.mousedownPosition.y = mouse.position.y; + mouse.sourceEvents.mousedown = event; + }; + + mouse.mouseup = function(event) { + var position = _getRelativeMousePosition(event, mouse.element, mouse.pixelRatio), + touches = event.changedTouches; + + if (touches) { + event.preventDefault(); + } + + mouse.button = -1; + mouse.absolute.x = position.x; + mouse.absolute.y = position.y; + mouse.position.x = mouse.absolute.x * mouse.scale.x + mouse.offset.x; + mouse.position.y = mouse.absolute.y * mouse.scale.y + mouse.offset.y; + mouse.mouseupPosition.x = mouse.position.x; + mouse.mouseupPosition.y = mouse.position.y; + mouse.sourceEvents.mouseup = event; + }; + + mouse.mousewheel = function(event) { + mouse.wheelDelta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail)); + event.preventDefault(); + }; + + Mouse.setElement(mouse, mouse.element); + + return mouse; + }; + + /** + * Sets the element the mouse is bound to (and relative to). + * @method setElement + * @param {mouse} mouse + * @param {HTMLElement} element + */ + Mouse.setElement = function(mouse, element) { + mouse.element = element; + + element.addEventListener('mousemove', mouse.mousemove); + element.addEventListener('mousedown', mouse.mousedown); + element.addEventListener('mouseup', mouse.mouseup); + + element.addEventListener('mousewheel', mouse.mousewheel); + element.addEventListener('DOMMouseScroll', mouse.mousewheel); + + element.addEventListener('touchmove', mouse.mousemove); + element.addEventListener('touchstart', mouse.mousedown); + element.addEventListener('touchend', mouse.mouseup); + }; + + /** + * Clears all captured source events. + * @method clearSourceEvents + * @param {mouse} mouse + */ + Mouse.clearSourceEvents = function(mouse) { + mouse.sourceEvents.mousemove = null; + mouse.sourceEvents.mousedown = null; + mouse.sourceEvents.mouseup = null; + mouse.sourceEvents.mousewheel = null; + mouse.wheelDelta = 0; + }; + + /** + * Sets the mouse position offset. + * @method setOffset + * @param {mouse} mouse + * @param {vector} offset + */ + Mouse.setOffset = function(mouse, offset) { + mouse.offset.x = offset.x; + mouse.offset.y = offset.y; + mouse.position.x = mouse.absolute.x * mouse.scale.x + mouse.offset.x; + mouse.position.y = mouse.absolute.y * mouse.scale.y + mouse.offset.y; + }; + + /** + * Sets the mouse position scale. + * @method setScale + * @param {mouse} mouse + * @param {vector} scale + */ + Mouse.setScale = function(mouse, scale) { + mouse.scale.x = scale.x; + mouse.scale.y = scale.y; + mouse.position.x = mouse.absolute.x * mouse.scale.x + mouse.offset.x; + mouse.position.y = mouse.absolute.y * mouse.scale.y + mouse.offset.y; + }; + + /** + * Gets the mouse position relative to an element given a screen pixel ratio. + * @method _getRelativeMousePosition + * @private + * @param {} event + * @param {} element + * @param {number} pixelRatio + * @return {} + */ + var _getRelativeMousePosition = function(event, element, pixelRatio) { + var elementBounds = element.getBoundingClientRect(), + rootNode = (document.documentElement || document.body.parentNode || document.body), + scrollX = (window.pageXOffset !== undefined) ? window.pageXOffset : rootNode.scrollLeft, + scrollY = (window.pageYOffset !== undefined) ? window.pageYOffset : rootNode.scrollTop, + touches = event.changedTouches, + x, y; + + if (touches) { + x = touches[0].pageX - elementBounds.left - scrollX; + y = touches[0].pageY - elementBounds.top - scrollY; + } else { + x = event.pageX - elementBounds.left - scrollX; + y = event.pageY - elementBounds.top - scrollY; + } + + return { + x: x / (element.clientWidth / element.width * pixelRatio), + y: y / (element.clientHeight / element.height * pixelRatio) + }; + }; + +})(); + +},{"../core/Common":14}],19:[function(require,module,exports){ +/** +* The `Matter.Runner` module is an optional utility which provides a game loop, +* that handles updating and rendering a `Matter.Engine` for you within a browser. +* It is intended for demo and testing purposes, but may be adequate for simple games. +* If you are using your own game loop instead, then you do not need the `Matter.Runner` module. +* Instead just call `Engine.update(engine, delta)` in your own loop. +* Note that the method `Engine.run` is an alias for `Runner.run`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Runner +*/ + +var Runner = {}; + +module.exports = Runner; + +var Events = require('./Events'); +var Engine = require('./Engine'); +var Common = require('./Common'); + +(function() { + + var _requestAnimationFrame, + _cancelAnimationFrame; + + if (typeof window !== 'undefined') { + _requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame + || window.mozRequestAnimationFrame || window.msRequestAnimationFrame + || function(callback){ window.setTimeout(function() { callback(Common.now()); }, 1000 / 60); }; + + _cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame + || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame; + } + + /** + * Creates a new Runner. The options parameter is an object that specifies any properties you wish to override the defaults. + * @method create + * @param {} options + */ + Runner.create = function(options) { + var defaults = { + fps: 60, + correction: 1, + deltaSampleSize: 60, + counterTimestamp: 0, + frameCounter: 0, + deltaHistory: [], + timePrev: null, + timeScalePrev: 1, + frameRequestId: null, + isFixed: false, + enabled: true + }; + + var runner = Common.extend(defaults, options); + + runner.delta = runner.delta || 1000 / runner.fps; + runner.deltaMin = runner.deltaMin || 1000 / runner.fps; + runner.deltaMax = runner.deltaMax || 1000 / (runner.fps * 0.5); + runner.fps = 1000 / runner.delta; + + return runner; + }; + + /** + * Continuously ticks a `Matter.Engine` by calling `Runner.tick` on the `requestAnimationFrame` event. + * @method run + * @param {engine} engine + */ + Runner.run = function(runner, engine) { + // create runner if engine is first argument + if (typeof runner.positionIterations !== 'undefined') { + engine = runner; + runner = Runner.create(); + } + + (function render(time){ + runner.frameRequestId = _requestAnimationFrame(render); + + if (time && runner.enabled) { + Runner.tick(runner, engine, time); + } + })(); + + return runner; + }; + + /** + * A game loop utility that updates the engine and renderer by one step (a 'tick'). + * Features delta smoothing, time correction and fixed or dynamic timing. + * Triggers `beforeTick`, `tick` and `afterTick` events on the engine. + * Consider just `Engine.update(engine, delta)` if you're using your own loop. + * @method tick + * @param {runner} runner + * @param {engine} engine + * @param {number} time + */ + Runner.tick = function(runner, engine, time) { + var timing = engine.timing, + correction = 1, + delta; + + // create an event object + var event = { + timestamp: timing.timestamp + }; + + Events.trigger(runner, 'beforeTick', event); + Events.trigger(engine, 'beforeTick', event); // @deprecated + + if (runner.isFixed) { + // fixed timestep + delta = runner.delta; + } else { + // dynamic timestep based on wall clock between calls + delta = (time - runner.timePrev) || runner.delta; + runner.timePrev = time; + + // optimistically filter delta over a few frames, to improve stability + runner.deltaHistory.push(delta); + runner.deltaHistory = runner.deltaHistory.slice(-runner.deltaSampleSize); + delta = Math.min.apply(null, runner.deltaHistory); + + // limit delta + delta = delta < runner.deltaMin ? runner.deltaMin : delta; + delta = delta > runner.deltaMax ? runner.deltaMax : delta; + + // correction for delta + correction = delta / runner.delta; + + // update engine timing object + runner.delta = delta; + } + + // time correction for time scaling + if (runner.timeScalePrev !== 0) + correction *= timing.timeScale / runner.timeScalePrev; + + if (timing.timeScale === 0) + correction = 0; + + runner.timeScalePrev = timing.timeScale; + runner.correction = correction; + + // fps counter + runner.frameCounter += 1; + if (time - runner.counterTimestamp >= 1000) { + runner.fps = runner.frameCounter * ((time - runner.counterTimestamp) / 1000); + runner.counterTimestamp = time; + runner.frameCounter = 0; + } + + Events.trigger(runner, 'tick', event); + Events.trigger(engine, 'tick', event); // @deprecated + + // if world has been modified, clear the render scene graph + if (engine.world.isModified + && engine.render + && engine.render.controller + && engine.render.controller.clear) { + engine.render.controller.clear(engine.render); + } + + // update + Events.trigger(runner, 'beforeUpdate', event); + Engine.update(engine, delta, correction); + Events.trigger(runner, 'afterUpdate', event); + + // render + if (engine.render && engine.render.controller) { + Events.trigger(runner, 'beforeRender', event); + Events.trigger(engine, 'beforeRender', event); // @deprecated + + engine.render.controller.world(engine); + + Events.trigger(runner, 'afterRender', event); + Events.trigger(engine, 'afterRender', event); // @deprecated + } + + Events.trigger(runner, 'afterTick', event); + Events.trigger(engine, 'afterTick', event); // @deprecated + }; + + /** + * Ends execution of `Runner.run` on the given `runner`, by canceling the animation frame request event loop. + * If you wish to only temporarily pause the engine, see `engine.enabled` instead. + * @method stop + * @param {runner} runner + */ + Runner.stop = function(runner) { + _cancelAnimationFrame(runner.frameRequestId); + }; + + /** + * Alias for `Runner.run`. + * @method start + * @param {runner} runner + * @param {engine} engine + */ + Runner.start = function(runner, engine) { + Runner.run(runner, engine); + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired at the start of a tick, before any updates to the engine or timing + * + * @event beforeTick + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine timing updated, but just before update + * + * @event tick + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired at the end of a tick, after engine update and after rendering + * + * @event afterTick + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired before update + * + * @event beforeUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after update + * + * @event afterUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired before rendering + * + * @event beforeRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after rendering + * + * @event afterRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * A flag that specifies whether the runner is running or not. + * + * @property enabled + * @type boolean + * @default true + */ + + /** + * A `Boolean` that specifies if the runner should use a fixed timestep (otherwise it is variable). + * If timing is fixed, then the apparent simulation speed will change depending on the frame rate (but behaviour will be deterministic). + * If the timing is variable, then the apparent simulation speed will be constant (approximately, but at the cost of determininism). + * + * @property isFixed + * @type boolean + * @default false + */ + + /** + * A `Number` that specifies the time step between updates in milliseconds. + * If `engine.timing.isFixed` is set to `true`, then `delta` is fixed. + * If it is `false`, then `delta` can dynamically change to maintain the correct apparent simulation speed. + * + * @property delta + * @type number + * @default 1000 / 60 + */ + +})(); + +},{"./Common":14,"./Engine":15,"./Events":16}],20:[function(require,module,exports){ +/** +* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. +* +* @class Sleeping +*/ + +var Sleeping = {}; + +module.exports = Sleeping; + +var Events = require('./Events'); + +(function() { + + Sleeping._motionWakeThreshold = 0.18; + Sleeping._motionSleepThreshold = 0.08; + Sleeping._minBias = 0.9; + + /** + * Puts bodies to sleep or wakes them up depending on their motion. + * @method update + * @param {body[]} bodies + * @param {number} timeScale + */ + Sleeping.update = function(bodies, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; + + // update bodies sleeping status + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; + + // wake up bodies if they have a force applied + if (body.force.x !== 0 || body.force.y !== 0) { + Sleeping.set(body, false); + continue; + } + + var minMotion = Math.min(body.motion, motion), + maxMotion = Math.max(body.motion, motion); + + // biased average motion estimation between frames + body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; + + if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { + body.sleepCounter += 1; + + if (body.sleepCounter >= body.sleepThreshold) + Sleeping.set(body, true); + } else if (body.sleepCounter > 0) { + body.sleepCounter -= 1; + } + } + }; + + /** + * Given a set of colliding pairs, wakes the sleeping bodies involved. + * @method afterCollisions + * @param {pair[]} pairs + * @param {number} timeScale + */ + Sleeping.afterCollisions = function(pairs, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; + + // wake up bodies involved in collisions + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + // don't wake inactive pairs + if (!pair.isActive) + continue; + + var collision = pair.collision, + bodyA = collision.bodyA.parent, + bodyB = collision.bodyB.parent; + + // don't wake if at least one body is static + if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) + continue; + + if (bodyA.isSleeping || bodyB.isSleeping) { + var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, + movingBody = sleepingBody === bodyA ? bodyB : bodyA; + + if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { + Sleeping.set(sleepingBody, false); + } + } + } + }; + + /** + * Set a body as sleeping or awake. + * @method set + * @param {body} body + * @param {boolean} isSleeping + */ + Sleeping.set = function(body, isSleeping) { + var wasSleeping = body.isSleeping; + + if (isSleeping) { + body.isSleeping = true; + body.sleepCounter = body.sleepThreshold; + + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; + + body.anglePrev = body.angle; + body.speed = 0; + body.angularSpeed = 0; + body.motion = 0; + + if (!wasSleeping) { + Events.trigger(body, 'sleepStart'); + } + } else { + body.isSleeping = false; + body.sleepCounter = 0; + + if (wasSleeping) { + Events.trigger(body, 'sleepEnd'); + } + } + }; + +})(); + +},{"./Events":16}],21:[function(require,module,exports){ +/** +* The `Matter.Bodies` module contains factory methods for creating rigid body models +* with commonly used body configurations (such as rectangles, circles and other polygons). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Bodies +*/ + +// TODO: true circle bodies + +var Bodies = {}; + +module.exports = Bodies; + +var Vertices = require('../geometry/Vertices'); +var Common = require('../core/Common'); +var Body = require('../body/Body'); +var Bounds = require('../geometry/Bounds'); +var Vector = require('../geometry/Vector'); + +(function() { + + /** + * Creates a new rigid body model with a rectangle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method rectangle + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {object} [options] + * @return {body} A new rectangle body + */ + Bodies.rectangle = function(x, y, width, height, options) { + options = options || {}; + + var rectangle = { + label: 'Rectangle Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, rectangle, options)); + }; + + /** + * Creates a new rigid body model with a trapezoid hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method trapezoid + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number} slope + * @param {object} [options] + * @return {body} A new trapezoid body + */ + Bodies.trapezoid = function(x, y, width, height, slope, options) { + options = options || {}; + + slope *= 0.5; + var roof = (1 - (slope * 2)) * width; + + var x1 = width * slope, + x2 = x1 + roof, + x3 = x2 + x1, + verticesPath; + + if (slope < 0.5) { + verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } else { + verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } + + var trapezoid = { + label: 'Trapezoid Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(verticesPath) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, trapezoid, options)); + }; + + /** + * Creates a new rigid body model with a circle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method circle + * @param {number} x + * @param {number} y + * @param {number} radius + * @param {object} [options] + * @param {number} [maxSides] + * @return {body} A new circle body + */ + Bodies.circle = function(x, y, radius, options, maxSides) { + options = options || {}; + + var circle = { + label: 'Circle Body', + circleRadius: radius + }; + + // approximate circles with polygons until true circles implemented in SAT + maxSides = maxSides || 25; + var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); + + // optimisation: always use even number of sides (half the number of unique axes) + if (sides % 2 === 1) + sides += 1; + + return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); + }; + + /** + * Creates a new rigid body model with a regular polygon hull with the given number of sides. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method polygon + * @param {number} x + * @param {number} y + * @param {number} sides + * @param {number} radius + * @param {object} [options] + * @return {body} A new regular polygon body + */ + Bodies.polygon = function(x, y, sides, radius, options) { + options = options || {}; + + if (sides < 3) + return Bodies.circle(x, y, radius, options); + + var theta = 2 * Math.PI / sides, + path = '', + offset = theta * 0.5; + + for (var i = 0; i < sides; i += 1) { + var angle = offset + (i * theta), + xx = Math.cos(angle) * radius, + yy = Math.sin(angle) * radius; + + path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; + } + + var polygon = { + label: 'Polygon Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(path) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, polygon, options)); + }; + + /** + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). + * If the vertices are convex, they will pass through as supplied. + * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. + * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). + * By default the decomposition will discard collinear edges (to improve performance). + * It can also optionally discard any parts that have an area less than `minimumArea`. + * If the vertices can not be decomposed, the result will fall back to using the convex hull. + * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method fromVertices + * @param {number} x + * @param {number} y + * @param [[vector]] vertexSets + * @param {object} [options] + * @param {bool} [flagInternal=false] + * @param {number} [removeCollinear=0.01] + * @param {number} [minimumArea=10] + * @return {body} + */ + Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { + var body, + parts, + isConvex, + vertices, + i, + j, + k, + v, + z; + + options = options || {}; + parts = []; + + flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; + removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; + minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; + + if (!window.decomp) { + Common.log('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.', 'warn'); + } + + // ensure vertexSets is an array of arrays + if (!Common.isArray(vertexSets[0])) { + vertexSets = [vertexSets]; + } + + for (v = 0; v < vertexSets.length; v += 1) { + vertices = vertexSets[v]; + isConvex = Vertices.isConvex(vertices); + + if (isConvex || !window.decomp) { + if (isConvex) { + vertices = Vertices.clockwiseSort(vertices); + } else { + // fallback to convex hull when decomposition is not possible + vertices = Vertices.hull(vertices); + } + + parts.push({ + position: { x: x, y: y }, + vertices: vertices + }); + } else { + // initialise a decomposition + var concave = new decomp.Polygon(); + for (i = 0; i < vertices.length; i++) { + concave.vertices.push([vertices[i].x, vertices[i].y]); + } + + // vertices are concave and simple, we can decompose into parts + concave.makeCCW(); + if (removeCollinear !== false) + concave.removeCollinearPoints(removeCollinear); + + // use the quick decomposition algorithm (Bayazit) + var decomposed = concave.quickDecomp(); + + // for each decomposed chunk + for (i = 0; i < decomposed.length; i++) { + var chunk = decomposed[i], + chunkVertices = []; + + // convert vertices into the correct structure + for (j = 0; j < chunk.vertices.length; j++) { + chunkVertices.push({ x: chunk.vertices[j][0], y: chunk.vertices[j][1] }); + } + + // skip small chunks + if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) + continue; + + // create a compound part + parts.push({ + position: Vertices.centre(chunkVertices), + vertices: chunkVertices + }); + } + } + } + + // create body parts + for (i = 0; i < parts.length; i++) { + parts[i] = Body.create(Common.extend(parts[i], options)); + } + + // flag internal edges (coincident part edges) + if (flagInternal) { + var coincident_max_dist = 5; + + for (i = 0; i < parts.length; i++) { + var partA = parts[i]; + + for (j = i + 1; j < parts.length; j++) { + var partB = parts[j]; + + if (Bounds.overlaps(partA.bounds, partB.bounds)) { + var pav = partA.vertices, + pbv = partB.vertices; + + // iterate vertices of both parts + for (k = 0; k < partA.vertices.length; k++) { + for (z = 0; z < partB.vertices.length; z++) { + // find distances between the vertices + var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), + db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); + + // if both vertices are very close, consider the edge concident (internal) + if (da < coincident_max_dist && db < coincident_max_dist) { + pav[k].isInternal = true; + pbv[z].isInternal = true; + } + } + } + + } + } + } + } + + if (parts.length > 1) { + // create the parent body to be returned, that contains generated compound parts + body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); + Body.setPosition(body, { x: x, y: y }); + + return body; + } else { + return parts[0]; + } + }; + +})(); +},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],22:[function(require,module,exports){ +/** +* The `Matter.Composites` module contains factory methods for creating composite bodies +* with commonly used configurations (such as stacks and chains). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composites +*/ + +var Composites = {}; + +module.exports = Composites; + +var Composite = require('../body/Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('../core/Common'); +var Body = require('../body/Body'); +var Bodies = require('./Bodies'); + +(function() { + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method stack + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.stack = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + var stack = Composite.create({ label: 'Stack' }), + x = xx, + y = yy, + lastBody, + i = 0; + + for (var row = 0; row < rows; row++) { + var maxHeight = 0; + + for (var column = 0; column < columns; column++) { + var body = callback(x, y, column, row, lastBody, i); + + if (body) { + var bodyHeight = body.bounds.max.y - body.bounds.min.y, + bodyWidth = body.bounds.max.x - body.bounds.min.x; + + if (bodyHeight > maxHeight) + maxHeight = bodyHeight; + + Body.translate(body, { x: bodyWidth * 0.5, y: bodyHeight * 0.5 }); + + x = body.bounds.max.x + columnGap; + + Composite.addBody(stack, body); + + lastBody = body; + i += 1; + } else { + x += columnGap; + } + } + + y += maxHeight + rowGap; + x = xx; + } + + return stack; + }; + + /** + * Chains all bodies in the given composite together using constraints. + * @method chain + * @param {composite} composite + * @param {number} xOffsetA + * @param {number} yOffsetA + * @param {number} xOffsetB + * @param {number} yOffsetB + * @param {object} options + * @return {composite} A new composite containing objects chained together with constraints + */ + Composites.chain = function(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) { + var bodies = composite.bodies; + + for (var i = 1; i < bodies.length; i++) { + var bodyA = bodies[i - 1], + bodyB = bodies[i], + bodyAHeight = bodyA.bounds.max.y - bodyA.bounds.min.y, + bodyAWidth = bodyA.bounds.max.x - bodyA.bounds.min.x, + bodyBHeight = bodyB.bounds.max.y - bodyB.bounds.min.y, + bodyBWidth = bodyB.bounds.max.x - bodyB.bounds.min.x; + + var defaults = { + bodyA: bodyA, + pointA: { x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA }, + bodyB: bodyB, + pointB: { x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB } + }; + + var constraint = Common.extend(defaults, options); + + Composite.addConstraint(composite, Constraint.create(constraint)); + } + + composite.label += ' Chain'; + + return composite; + }; + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * @method mesh + * @param {composite} composite + * @param {number} columns + * @param {number} rows + * @param {boolean} crossBrace + * @param {object} options + * @return {composite} The composite containing objects meshed together with constraints + */ + Composites.mesh = function(composite, columns, rows, crossBrace, options) { + var bodies = composite.bodies, + row, + col, + bodyA, + bodyB, + bodyC; + + for (row = 0; row < rows; row++) { + for (col = 1; col < columns; col++) { + bodyA = bodies[(col - 1) + (row * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + } + + if (row > 0) { + for (col = 0; col < columns; col++) { + bodyA = bodies[col + ((row - 1) * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + + if (crossBrace && col > 0) { + bodyC = bodies[(col - 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + + if (crossBrace && col < columns - 1) { + bodyC = bodies[(col + 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + } + } + } + + composite.label += ' Mesh'; + + return composite; + }; + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method pyramid + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.pyramid = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + return Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y, column, row, lastBody, i) { + var actualRows = Math.min(rows, Math.ceil(columns / 2)), + lastBodyWidth = lastBody ? lastBody.bounds.max.x - lastBody.bounds.min.x : 0; + + if (row > actualRows) + return; + + // reverse row order + row = actualRows - row; + + var start = row, + end = columns - 1 - row; + + if (column < start || column > end) + return; + + // retroactively fix the first body's position, since width was unknown + if (i === 1) { + Body.translate(lastBody, { x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0 }); + } + + var xOffset = lastBody ? column * lastBodyWidth : 0; + + return callback(xx + xOffset + column * columnGap, y, column, row, lastBody, i); + }); + }; + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * @method newtonsCradle + * @param {number} xx + * @param {number} yy + * @param {number} number + * @param {number} size + * @param {number} length + * @return {composite} A new composite newtonsCradle body + */ + Composites.newtonsCradle = function(xx, yy, number, size, length) { + var newtonsCradle = Composite.create({ label: 'Newtons Cradle' }); + + for (var i = 0; i < number; i++) { + var separation = 1.9, + circle = Bodies.circle(xx + i * (size * separation), yy + length, size, + { inertia: Infinity, restitution: 1, friction: 0, frictionAir: 0.0001, slop: 1 }), + constraint = Constraint.create({ pointA: { x: xx + i * (size * separation), y: yy }, bodyB: circle }); + + Composite.addBody(newtonsCradle, circle); + Composite.addConstraint(newtonsCradle, constraint); + } + + return newtonsCradle; + }; + + /** + * Creates a composite with simple car setup of bodies and constraints. + * @method car + * @param {number} xx + * @param {number} yy + * @param {number} width + * @param {number} height + * @param {number} wheelSize + * @return {composite} A new composite car body + */ + Composites.car = function(xx, yy, width, height, wheelSize) { + var group = Body.nextGroup(true), + wheelBase = -20, + wheelAOffset = -width * 0.5 + wheelBase, + wheelBOffset = width * 0.5 - wheelBase, + wheelYOffset = 0; + + var car = Composite.create({ label: 'Car' }), + body = Bodies.trapezoid(xx, yy, width, height, 0.3, { + collisionFilter: { + group: group + }, + friction: 0.01, + chamfer: { + radius: 10 + } + }); + + var wheelA = Bodies.circle(xx + wheelAOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8, + density: 0.01 + }); + + var wheelB = Bodies.circle(xx + wheelBOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8, + density: 0.01 + }); + + var axelA = Constraint.create({ + bodyA: body, + pointA: { x: wheelAOffset, y: wheelYOffset }, + bodyB: wheelA, + stiffness: 0.2 + }); + + var axelB = Constraint.create({ + bodyA: body, + pointA: { x: wheelBOffset, y: wheelYOffset }, + bodyB: wheelB, + stiffness: 0.2 + }); + + Composite.addBody(car, body); + Composite.addBody(car, wheelA); + Composite.addBody(car, wheelB); + Composite.addConstraint(car, axelA); + Composite.addConstraint(car, axelB); + + return car; + }; + + /** + * Creates a simple soft body like object. + * @method softBody + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {boolean} crossBrace + * @param {number} particleRadius + * @param {} particleOptions + * @param {} constraintOptions + * @return {composite} A new composite softBody + */ + Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) { + particleOptions = Common.extend({ inertia: Infinity }, particleOptions); + constraintOptions = Common.extend({ stiffness: 0.4 }, constraintOptions); + + var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) { + return Bodies.circle(x, y, particleRadius, particleOptions); + }); + + Composites.mesh(softBody, columns, rows, crossBrace, constraintOptions); + + softBody.label = 'Soft Body'; + + return softBody; + }; + +})(); + +},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":21}],23:[function(require,module,exports){ +/** +* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. +* +* @class Axes +*/ + +var Axes = {}; + +module.exports = Axes; + +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a new set of axes from the given vertices. + * @method fromVertices + * @param {vertices} vertices + * @return {axes} A new axes from the given vertices + */ + Axes.fromVertices = function(vertices) { + var axes = {}; + + // find the unique axes, using edge normal gradients + for (var i = 0; i < vertices.length; i++) { + var j = (i + 1) % vertices.length, + normal = Vector.normalise({ + x: vertices[j].y - vertices[i].y, + y: vertices[i].x - vertices[j].x + }), + gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); + + // limit precision + gradient = gradient.toFixed(3).toString(); + axes[gradient] = normal; + } + + return Common.values(axes); + }; + + /** + * Rotates a set of axes by the given angle. + * @method rotate + * @param {axes} axes + * @param {number} angle + */ + Axes.rotate = function(axes, angle) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < axes.length; i++) { + var axis = axes[i], + xx; + xx = axis.x * cos - axis.y * sin; + axis.y = axis.x * sin + axis.y * cos; + axis.x = xx; + } + }; + +})(); + +},{"../core/Common":14,"../geometry/Vector":26}],24:[function(require,module,exports){ +/** +* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). +* +* @class Bounds +*/ + +var Bounds = {}; + +module.exports = Bounds; + +(function() { + + /** + * Creates a new axis-aligned bounding box (AABB) for the given vertices. + * @method create + * @param {vertices} vertices + * @return {bounds} A new bounds object + */ + Bounds.create = function(vertices) { + var bounds = { + min: { x: 0, y: 0 }, + max: { x: 0, y: 0 } + }; + + if (vertices) + Bounds.update(bounds, vertices); + + return bounds; + }; + + /** + * Updates bounds using the given vertices and extends the bounds given a velocity. + * @method update + * @param {bounds} bounds + * @param {vertices} vertices + * @param {vector} velocity + */ + Bounds.update = function(bounds, vertices, velocity) { + bounds.min.x = Infinity; + bounds.max.x = -Infinity; + bounds.min.y = Infinity; + bounds.max.y = -Infinity; + + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; + if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; + if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; + if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; + } + + if (velocity) { + if (velocity.x > 0) { + bounds.max.x += velocity.x; + } else { + bounds.min.x += velocity.x; + } + + if (velocity.y > 0) { + bounds.max.y += velocity.y; + } else { + bounds.min.y += velocity.y; + } + } + }; + + /** + * Returns true if the bounds contains the given point. + * @method contains + * @param {bounds} bounds + * @param {vector} point + * @return {boolean} True if the bounds contain the point, otherwise false + */ + Bounds.contains = function(bounds, point) { + return point.x >= bounds.min.x && point.x <= bounds.max.x + && point.y >= bounds.min.y && point.y <= bounds.max.y; + }; + + /** + * Returns true if the two bounds intersect. + * @method overlaps + * @param {bounds} boundsA + * @param {bounds} boundsB + * @return {boolean} True if the bounds overlap, otherwise false + */ + Bounds.overlaps = function(boundsA, boundsB) { + return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x + && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); + }; + + /** + * Translates the bounds by the given vector. + * @method translate + * @param {bounds} bounds + * @param {vector} vector + */ + Bounds.translate = function(bounds, vector) { + bounds.min.x += vector.x; + bounds.max.x += vector.x; + bounds.min.y += vector.y; + bounds.max.y += vector.y; + }; + + /** + * Shifts the bounds to the given position. + * @method shift + * @param {bounds} bounds + * @param {vector} position + */ + Bounds.shift = function(bounds, position) { + var deltaX = bounds.max.x - bounds.min.x, + deltaY = bounds.max.y - bounds.min.y; + + bounds.min.x = position.x; + bounds.max.x = position.x + deltaX; + bounds.min.y = position.y; + bounds.max.y = position.y + deltaY; + }; + +})(); + +},{}],25:[function(require,module,exports){ +/** +* The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. +* +* To use this module you also need the SVGPathSeg polyfill: https://github.com/progers/pathseg +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Svg +*/ + +var Svg = {}; + +module.exports = Svg; + +var Bounds = require('../geometry/Bounds'); + +(function() { + + /** + * Converts an SVG path into an array of vector points. + * If the input path forms a concave shape, you must decompose the result into convex parts before use. + * See `Bodies.fromVertices` which provides support for this. + * Note that this function is not guaranteed to support complex paths (such as those with holes). + * @method pathToVertices + * @param {SVGPathElement} path + * @param {Number} [sampleLength=15] + * @return {Vector[]} points + */ + Svg.pathToVertices = function(path, sampleLength) { + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js + var i, il, total, point, segment, segments, + segmentsQueue, lastSegment, + lastPoint, segmentIndex, points = [], + lx, ly, length = 0, x = 0, y = 0; + + sampleLength = sampleLength || 15; + + var addPoint = function(px, py, pathSegType) { + // all odd-numbered path types are relative except PATHSEG_CLOSEPATH (1) + var isRelative = pathSegType % 2 === 1 && pathSegType > 1; + + // when the last point doesn't equal the current point add the current point + if (!lastPoint || px != lastPoint.x || py != lastPoint.y) { + if (lastPoint && isRelative) { + lx = lastPoint.x; + ly = lastPoint.y; + } else { + lx = 0; + ly = 0; + } + + var point = { + x: lx + px, + y: ly + py + }; + + // set last point + if (isRelative || !lastPoint) { + lastPoint = point; + } + + points.push(point); + + x = lx + px; + y = ly + py; + } + }; + + var addSegmentPoint = function(segment) { + var segType = segment.pathSegTypeAsLetter.toUpperCase(); + + // skip path ends + if (segType === 'Z') + return; + + // map segment to x and y + switch (segType) { + + case 'M': + case 'L': + case 'T': + case 'C': + case 'S': + case 'Q': + x = segment.x; + y = segment.y; + break; + case 'H': + x = segment.x; + break; + case 'V': + y = segment.y; + break; + } + + addPoint(x, y, segment.pathSegType); + }; + + // ensure path is absolute + _svgPathToAbsolute(path); + + // get total length + total = path.getTotalLength(); + + // queue segments + segments = []; + for (i = 0; i < path.pathSegList.numberOfItems; i += 1) + segments.push(path.pathSegList.getItem(i)); + + segmentsQueue = segments.concat(); + + // sample through path + while (length < total) { + // get segment at position + segmentIndex = path.getPathSegAtLength(length); + segment = segments[segmentIndex]; + + // new segment + if (segment != lastSegment) { + while (segmentsQueue.length && segmentsQueue[0] != segment) + addSegmentPoint(segmentsQueue.shift()); + + lastSegment = segment; + } + + // add points in between when curving + // TODO: adaptive sampling + switch (segment.pathSegTypeAsLetter.toUpperCase()) { + + case 'C': + case 'T': + case 'S': + case 'Q': + case 'A': + point = path.getPointAtLength(length); + addPoint(point.x, point.y, 0); + break; + + } + + // increment by sample value + length += sampleLength; + } + + // add remaining segments not passed by sampling + for (i = 0, il = segmentsQueue.length; i < il; ++i) + addSegmentPoint(segmentsQueue[i]); + + return points; + }; + + var _svgPathToAbsolute = function(path) { + // http://phrogz.net/convert-svg-path-to-all-absolute-commands + var x0, y0, x1, y1, x2, y2, segs = path.pathSegList, + x = 0, y = 0, len = segs.numberOfItems; + + for (var i = 0; i < len; ++i) { + var seg = segs.getItem(i), + segType = seg.pathSegTypeAsLetter; + + if (/[MLHVCSQTA]/.test(segType)) { + if ('x' in seg) x = seg.x; + if ('y' in seg) y = seg.y; + } else { + if ('x1' in seg) x1 = x + seg.x1; + if ('x2' in seg) x2 = x + seg.x2; + if ('y1' in seg) y1 = y + seg.y1; + if ('y2' in seg) y2 = y + seg.y2; + if ('x' in seg) x += seg.x; + if ('y' in seg) y += seg.y; + + switch (segType) { + + case 'm': + segs.replaceItem(path.createSVGPathSegMovetoAbs(x, y), i); + break; + case 'l': + segs.replaceItem(path.createSVGPathSegLinetoAbs(x, y), i); + break; + case 'h': + segs.replaceItem(path.createSVGPathSegLinetoHorizontalAbs(x), i); + break; + case 'v': + segs.replaceItem(path.createSVGPathSegLinetoVerticalAbs(y), i); + break; + case 'c': + segs.replaceItem(path.createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), i); + break; + case 's': + segs.replaceItem(path.createSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2), i); + break; + case 'q': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticAbs(x, y, x1, y1), i); + break; + case 't': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticSmoothAbs(x, y), i); + break; + case 'a': + segs.replaceItem(path.createSVGPathSegArcAbs(x, y, seg.r1, seg.r2, seg.angle, seg.largeArcFlag, seg.sweepFlag), i); + break; + case 'z': + case 'Z': + x = x0; + y = y0; + break; + + } + } + + if (segType == 'M' || segType == 'm') { + x0 = x; + y0 = y; + } + } + }; + +})(); +},{"../geometry/Bounds":24}],26:[function(require,module,exports){ +/** +* The `Matter.Vector` module contains methods for creating and manipulating vectors. +* Vectors are the basis of all the geometry related operations in the engine. +* A `Matter.Vector` object is of the form `{ x: 0, y: 0 }`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vector +*/ + +// TODO: consider params for reusing vector objects + +var Vector = {}; + +module.exports = Vector; + +(function() { + + /** + * Creates a new vector. + * @method create + * @param {number} x + * @param {number} y + * @return {vector} A new vector + */ + Vector.create = function(x, y) { + return { x: x || 0, y: y || 0 }; + }; + + /** + * Returns a new vector with `x` and `y` copied from the given `vector`. + * @method clone + * @param {vector} vector + * @return {vector} A new cloned vector + */ + Vector.clone = function(vector) { + return { x: vector.x, y: vector.y }; + }; + + /** + * Returns the magnitude (length) of a vector. + * @method magnitude + * @param {vector} vector + * @return {number} The magnitude of the vector + */ + Vector.magnitude = function(vector) { + return Math.sqrt((vector.x * vector.x) + (vector.y * vector.y)); + }; + + /** + * Returns the magnitude (length) of a vector (therefore saving a `sqrt` operation). + * @method magnitudeSquared + * @param {vector} vector + * @return {number} The squared magnitude of the vector + */ + Vector.magnitudeSquared = function(vector) { + return (vector.x * vector.x) + (vector.y * vector.y); + }; + + /** + * Rotates the vector about (0, 0) by specified angle. + * @method rotate + * @param {vector} vector + * @param {number} angle + * @return {vector} A new vector rotated about (0, 0) + */ + Vector.rotate = function(vector, angle) { + var cos = Math.cos(angle), sin = Math.sin(angle); + return { + x: vector.x * cos - vector.y * sin, + y: vector.x * sin + vector.y * cos + }; + }; + + /** + * Rotates the vector about a specified point by specified angle. + * @method rotateAbout + * @param {vector} vector + * @param {number} angle + * @param {vector} point + * @param {vector} [output] + * @return {vector} A new vector rotated about the point + */ + Vector.rotateAbout = function(vector, angle, point, output) { + var cos = Math.cos(angle), sin = Math.sin(angle); + if (!output) output = {}; + var x = point.x + ((vector.x - point.x) * cos - (vector.y - point.y) * sin); + output.y = point.y + ((vector.x - point.x) * sin + (vector.y - point.y) * cos); + output.x = x; + return output; + }; + + /** + * Normalises a vector (such that its magnitude is `1`). + * @method normalise + * @param {vector} vector + * @return {vector} A new vector normalised + */ + Vector.normalise = function(vector) { + var magnitude = Vector.magnitude(vector); + if (magnitude === 0) + return { x: 0, y: 0 }; + return { x: vector.x / magnitude, y: vector.y / magnitude }; + }; + + /** + * Returns the dot-product of two vectors. + * @method dot + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The dot product of the two vectors + */ + Vector.dot = function(vectorA, vectorB) { + return (vectorA.x * vectorB.x) + (vectorA.y * vectorB.y); + }; + + /** + * Returns the cross-product of two vectors. + * @method cross + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The cross product of the two vectors + */ + Vector.cross = function(vectorA, vectorB) { + return (vectorA.x * vectorB.y) - (vectorA.y * vectorB.x); + }; + + /** + * Returns the cross-product of three vectors. + * @method cross3 + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} vectorC + * @return {number} The cross product of the three vectors + */ + Vector.cross3 = function(vectorA, vectorB, vectorC) { + return (vectorB.x - vectorA.x) * (vectorC.y - vectorA.y) - (vectorB.y - vectorA.y) * (vectorC.x - vectorA.x); + }; + + /** + * Adds the two vectors. + * @method add + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB added + */ + Vector.add = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x + vectorB.x; + output.y = vectorA.y + vectorB.y; + return output; + }; + + /** + * Subtracts the two vectors. + * @method sub + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB subtracted + */ + Vector.sub = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x - vectorB.x; + output.y = vectorA.y - vectorB.y; + return output; + }; + + /** + * Multiplies a vector and a scalar. + * @method mult + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector multiplied by scalar + */ + Vector.mult = function(vector, scalar) { + return { x: vector.x * scalar, y: vector.y * scalar }; + }; + + /** + * Divides a vector and a scalar. + * @method div + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector divided by scalar + */ + Vector.div = function(vector, scalar) { + return { x: vector.x / scalar, y: vector.y / scalar }; + }; + + /** + * Returns the perpendicular vector. Set `negate` to true for the perpendicular in the opposite direction. + * @method perp + * @param {vector} vector + * @param {bool} [negate=false] + * @return {vector} The perpendicular vector + */ + Vector.perp = function(vector, negate) { + negate = negate === true ? -1 : 1; + return { x: negate * -vector.y, y: negate * vector.x }; + }; + + /** + * Negates both components of a vector such that it points in the opposite direction. + * @method neg + * @param {vector} vector + * @return {vector} The negated vector + */ + Vector.neg = function(vector) { + return { x: -vector.x, y: -vector.y }; + }; + + /** + * Returns the angle in radians between the two vectors relative to the x-axis. + * @method angle + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The angle in radians + */ + Vector.angle = function(vectorA, vectorB) { + return Math.atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x); + }; + + /** + * Temporary vector pool (not thread-safe). + * @property _temp + * @type {vector[]} + * @private + */ + Vector._temp = [Vector.create(), Vector.create(), + Vector.create(), Vector.create(), + Vector.create(), Vector.create()]; + +})(); +},{}],27:[function(require,module,exports){ +/** +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vertices +*/ + +var Vertices = {}; + +module.exports = Vertices; + +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a new set of `Matter.Body` compatible vertices. + * The `points` argument accepts an array of `Matter.Vector` points orientated around the origin `(0, 0)`, for example: + * + * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] + * + * The `Vertices.create` method returns a new array of vertices, which are similar to Matter.Vector objects, + * but with some additional references required for efficient collision detection routines. + * + * Note that the `body` argument is not optional, a `Matter.Body` reference must be provided. + * + * @method create + * @param {vector[]} points + * @param {body} body + */ + Vertices.create = function(points, body) { + var vertices = []; + + for (var i = 0; i < points.length; i++) { + var point = points[i], + vertex = { + x: point.x, + y: point.y, + index: i, + body: body, + isInternal: false + }; + + vertices.push(vertex); + } + + return vertices; + }; + + /** + * Parses a string containing ordered x y pairs separated by spaces (and optionally commas), + * into a `Matter.Vertices` object for the given `Matter.Body`. + * For parsing SVG paths, see `Svg.pathToVertices`. + * @method fromPath + * @param {string} path + * @param {body} body + * @return {vertices} vertices + */ + Vertices.fromPath = function(path, body) { + var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig, + points = []; + + path.replace(pathPattern, function(match, x, y) { + points.push({ x: parseFloat(x), y: parseFloat(y) }); + }); + + return Vertices.create(points, body); + }; + + /** + * Returns the centre (centroid) of the set of vertices. + * @method centre + * @param {vertices} vertices + * @return {vector} The centre point + */ + Vertices.centre = function(vertices) { + var area = Vertices.area(vertices, true), + centre = { x: 0, y: 0 }, + cross, + temp, + j; + + for (var i = 0; i < vertices.length; i++) { + j = (i + 1) % vertices.length; + cross = Vector.cross(vertices[i], vertices[j]); + temp = Vector.mult(Vector.add(vertices[i], vertices[j]), cross); + centre = Vector.add(centre, temp); + } + + return Vector.div(centre, 6 * area); + }; + + /** + * Returns the average (mean) of the set of vertices. + * @method mean + * @param {vertices} vertices + * @return {vector} The average point + */ + Vertices.mean = function(vertices) { + var average = { x: 0, y: 0 }; + + for (var i = 0; i < vertices.length; i++) { + average.x += vertices[i].x; + average.y += vertices[i].y; + } + + return Vector.div(average, vertices.length); + }; + + /** + * Returns the area of the set of vertices. + * @method area + * @param {vertices} vertices + * @param {bool} signed + * @return {number} The area + */ + Vertices.area = function(vertices, signed) { + var area = 0, + j = vertices.length - 1; + + for (var i = 0; i < vertices.length; i++) { + area += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + j = i; + } + + if (signed) + return area / 2; + + return Math.abs(area) / 2; + }; + + /** + * Returns the moment of inertia (second moment of area) of the set of vertices given the total mass. + * @method inertia + * @param {vertices} vertices + * @param {number} mass + * @return {number} The polygon's moment of inertia + */ + Vertices.inertia = function(vertices, mass) { + var numerator = 0, + denominator = 0, + v = vertices, + cross, + j; + + // find the polygon's moment of inertia, using second moment of area + // http://www.physicsforums.com/showthread.php?t=25293 + for (var n = 0; n < v.length; n++) { + j = (n + 1) % v.length; + cross = Math.abs(Vector.cross(v[j], v[n])); + numerator += cross * (Vector.dot(v[j], v[j]) + Vector.dot(v[j], v[n]) + Vector.dot(v[n], v[n])); + denominator += cross; + } + + return (mass / 6) * (numerator / denominator); + }; + + /** + * Translates the set of vertices in-place. + * @method translate + * @param {vertices} vertices + * @param {vector} vector + * @param {number} scalar + */ + Vertices.translate = function(vertices, vector, scalar) { + var i; + if (scalar) { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x * scalar; + vertices[i].y += vector.y * scalar; + } + } else { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x; + vertices[i].y += vector.y; + } + } + + return vertices; + }; + + /** + * Rotates the set of vertices in-place. + * @method rotate + * @param {vertices} vertices + * @param {number} angle + * @param {vector} point + */ + Vertices.rotate = function(vertices, angle, point) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + dx = vertice.x - point.x, + dy = vertice.y - point.y; + + vertice.x = point.x + (dx * cos - dy * sin); + vertice.y = point.y + (dx * sin + dy * cos); + } + + return vertices; + }; + + /** + * Returns `true` if the `point` is inside the set of `vertices`. + * @method contains + * @param {vertices} vertices + * @param {vector} point + * @return {boolean} True if the vertices contains point, otherwise false + */ + Vertices.contains = function(vertices, point) { + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + nextVertice = vertices[(i + 1) % vertices.length]; + if ((point.x - vertice.x) * (nextVertice.y - vertice.y) + (point.y - vertice.y) * (vertice.x - nextVertice.x) > 0) { + return false; + } + } + + return true; + }; + + /** + * Scales the vertices from a point (default is centre) in-place. + * @method scale + * @param {vertices} vertices + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point + */ + Vertices.scale = function(vertices, scaleX, scaleY, point) { + if (scaleX === 1 && scaleY === 1) + return vertices; + + point = point || Vertices.centre(vertices); + + var vertex, + delta; + + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + delta = Vector.sub(vertex, point); + vertices[i].x = point.x + delta.x * scaleX; + vertices[i].y = point.y + delta.y * scaleY; + } + + return vertices; + }; + + /** + * Chamfers a set of vertices by giving them rounded corners, returns a new set of vertices. + * The radius parameter is a single number or an array to specify the radius for each vertex. + * @method chamfer + * @param {vertices} vertices + * @param {number[]} radius + * @param {number} quality + * @param {number} qualityMin + * @param {number} qualityMax + */ + Vertices.chamfer = function(vertices, radius, quality, qualityMin, qualityMax) { + radius = radius || [8]; + + if (!radius.length) + radius = [radius]; + + // quality defaults to -1, which is auto + quality = (typeof quality !== 'undefined') ? quality : -1; + qualityMin = qualityMin || 2; + qualityMax = qualityMax || 14; + + var newVertices = []; + + for (var i = 0; i < vertices.length; i++) { + var prevVertex = vertices[i - 1 >= 0 ? i - 1 : vertices.length - 1], + vertex = vertices[i], + nextVertex = vertices[(i + 1) % vertices.length], + currentRadius = radius[i < radius.length ? i : radius.length - 1]; + + if (currentRadius === 0) { + newVertices.push(vertex); + continue; + } + + var prevNormal = Vector.normalise({ + x: vertex.y - prevVertex.y, + y: prevVertex.x - vertex.x + }); + + var nextNormal = Vector.normalise({ + x: nextVertex.y - vertex.y, + y: vertex.x - nextVertex.x + }); + + var diagonalRadius = Math.sqrt(2 * Math.pow(currentRadius, 2)), + radiusVector = Vector.mult(Common.clone(prevNormal), currentRadius), + midNormal = Vector.normalise(Vector.mult(Vector.add(prevNormal, nextNormal), 0.5)), + scaledVertex = Vector.sub(vertex, Vector.mult(midNormal, diagonalRadius)); + + var precision = quality; + + if (quality === -1) { + // automatically decide precision + precision = Math.pow(currentRadius, 0.32) * 1.75; + } + + precision = Common.clamp(precision, qualityMin, qualityMax); + + // use an even value for precision, more likely to reduce axes by using symmetry + if (precision % 2 === 1) + precision += 1; + + var alpha = Math.acos(Vector.dot(prevNormal, nextNormal)), + theta = alpha / precision; + + for (var j = 0; j < precision; j++) { + newVertices.push(Vector.add(Vector.rotate(radiusVector, theta * j), scaledVertex)); + } + } + + return newVertices; + }; + + /** + * Sorts the input vertices into clockwise order in place. + * @method clockwiseSort + * @param {vertices} vertices + * @return {vertices} vertices + */ + Vertices.clockwiseSort = function(vertices) { + var centre = Vertices.mean(vertices); + + vertices.sort(function(vertexA, vertexB) { + return Vector.angle(centre, vertexA) - Vector.angle(centre, vertexB); + }); + + return vertices; + }; + + /** + * Returns true if the vertices form a convex shape (vertices must be in clockwise order). + * @method isConvex + * @param {vertices} vertices + * @return {bool} `true` if the `vertices` are convex, `false` if not (or `null` if not computable). + */ + Vertices.isConvex = function(vertices) { + // http://paulbourke.net/geometry/polygonmesh/ + + var flag = 0, + n = vertices.length, + i, + j, + k, + z; + + if (n < 3) + return null; + + for (i = 0; i < n; i++) { + j = (i + 1) % n; + k = (i + 2) % n; + z = (vertices[j].x - vertices[i].x) * (vertices[k].y - vertices[j].y); + z -= (vertices[j].y - vertices[i].y) * (vertices[k].x - vertices[j].x); + + if (z < 0) { + flag |= 1; + } else if (z > 0) { + flag |= 2; + } + + if (flag === 3) { + return false; + } + } + + if (flag !== 0){ + return true; + } else { + return null; + } + }; + + /** + * Returns the convex hull of the input vertices as a new array of points. + * @method hull + * @param {vertices} vertices + * @return [vertex] vertices + */ + Vertices.hull = function(vertices) { + // http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain + + var upper = [], + lower = [], + vertex, + i; + + // sort vertices on x-axis (y-axis for ties) + vertices = vertices.slice(0); + vertices.sort(function(vertexA, vertexB) { + var dx = vertexA.x - vertexB.x; + return dx !== 0 ? dx : vertexA.y - vertexB.y; + }); + + // build lower hull + for (i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + + while (lower.length >= 2 + && Vector.cross3(lower[lower.length - 2], lower[lower.length - 1], vertex) <= 0) { + lower.pop(); + } + + lower.push(vertex); + } + + // build upper hull + for (i = vertices.length - 1; i >= 0; i--) { + vertex = vertices[i]; + + while (upper.length >= 2 + && Vector.cross3(upper[upper.length - 2], upper[upper.length - 1], vertex) <= 0) { + upper.pop(); + } + + upper.push(vertex); + } + + // concatenation of the lower and upper hulls gives the convex hull + // omit last points because they are repeated at the beginning of the other list + upper.pop(); + lower.pop(); + + return upper.concat(lower); + }; + +})(); + +},{"../core/Common":14,"../geometry/Vector":26}],28:[function(require,module,exports){ +var Matter = module.exports = {}; +Matter.version = 'master'; + +Matter.Body = require('../body/Body'); +Matter.Composite = require('../body/Composite'); +Matter.World = require('../body/World'); + +Matter.Contact = require('../collision/Contact'); +Matter.Detector = require('../collision/Detector'); +Matter.Grid = require('../collision/Grid'); +Matter.Pairs = require('../collision/Pairs'); +Matter.Pair = require('../collision/Pair'); +Matter.Query = require('../collision/Query'); +Matter.Resolver = require('../collision/Resolver'); +Matter.SAT = require('../collision/SAT'); + +Matter.Constraint = require('../constraint/Constraint'); +Matter.MouseConstraint = require('../constraint/MouseConstraint'); + +Matter.Common = require('../core/Common'); +Matter.Engine = require('../core/Engine'); +Matter.Events = require('../core/Events'); +Matter.Mouse = require('../core/Mouse'); +Matter.Runner = require('../core/Runner'); +Matter.Sleeping = require('../core/Sleeping'); + + +Matter.Bodies = require('../factory/Bodies'); +Matter.Composites = require('../factory/Composites'); + +Matter.Axes = require('../geometry/Axes'); +Matter.Bounds = require('../geometry/Bounds'); +Matter.Svg = require('../geometry/Svg'); +Matter.Vector = require('../geometry/Vector'); +Matter.Vertices = require('../geometry/Vertices'); + +Matter.Render = require('../render/Render'); +Matter.RenderPixi = require('../render/RenderPixi'); + +// aliases + +Matter.World.add = Matter.Composite.add; +Matter.World.remove = Matter.Composite.remove; +Matter.World.addComposite = Matter.Composite.addComposite; +Matter.World.addBody = Matter.Composite.addBody; +Matter.World.addConstraint = Matter.Composite.addConstraint; +Matter.World.clear = Matter.Composite.clear; +Matter.Engine.run = Matter.Runner.run; + +},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Metrics":17,"../core/Mouse":18,"../core/Runner":19,"../core/Sleeping":20,"../factory/Bodies":21,"../factory/Composites":22,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Svg":25,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29,"../render/RenderPixi":30}],29:[function(require,module,exports){ +/** +* The `Matter.Render` module is the default `render.controller` used by a `Matter.Engine`. +* This renderer is HTML5 canvas based and supports a number of drawing options including sprites and viewports. +* +* It is possible develop a custom renderer module based on `Matter.Render` and pass an instance of it to `Engine.create` via `options.render`. +* A minimal custom renderer object must define at least three functions: `create`, `clear` and `world` (see `Matter.Render`). +* +* See also `Matter.RenderPixi` for an alternate WebGL, scene-graph based renderer. +* +* @class Render +*/ + +var Render = {}; + +module.exports = Render; + +var Common = require('../core/Common'); +var Composite = require('../body/Composite'); +var Bounds = require('../geometry/Bounds'); +var Events = require('../core/Events'); +var Grid = require('../collision/Grid'); +var Vector = require('../geometry/Vector'); + +(function() { + + /** + * Creates a new renderer. The options parameter is an object that specifies any properties you wish to override the defaults. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {object} [options] + * @return {render} A new renderer + */ + Render.create = function(options) { + var defaults = { + controller: Render, + element: null, + canvas: null, + mouse: null, + options: { + width: 800, + height: 600, + pixelRatio: 1, + background: '#fafafa', + wireframeBackground: '#222', + hasBounds: !!options.bounds, + enabled: true, + wireframes: true, + showSleeping: true, + showDebug: false, + showBroadphase: false, + showBounds: false, + showVelocity: false, + showCollisions: false, + showSeparations: false, + showAxes: false, + showPositions: false, + showAngleIndicator: false, + showIds: false, + showShadows: false, + showVertexNumbers: false, + showConvexHulls: false, + showInternalEdges: false, + showMousePosition: false + } + }; + + var render = Common.extend(defaults, options); + + if (render.canvas) { + render.canvas.width = render.options.width || render.canvas.width; + render.canvas.height = render.options.height || render.canvas.height; + } + + render.canvas = render.canvas || _createCanvas(render.options.width, render.options.height); + render.context = render.canvas.getContext('2d'); + render.textures = {}; + + render.bounds = render.bounds || { + min: { + x: 0, + y: 0 + }, + max: { + x: render.canvas.width, + y: render.canvas.height + } + }; + + if (render.options.pixelRatio !== 1) { + Render.setPixelRatio(render, render.options.pixelRatio); + } + + if (Common.isElement(render.element)) { + render.element.appendChild(render.canvas); + } else { + Common.log('Render.create: options.element was undefined, render.canvas was created but not appended', 'warn'); + } + + return render; + }; + + /** + * Sets the pixel ratio of the renderer and updates the canvas. + * To automatically detect the correct ratio, pass the string `'auto'` for `pixelRatio`. + * @method setPixelRatio + * @param {render} render + * @param {number} pixelRatio + */ + Render.setPixelRatio = function(render, pixelRatio) { + var options = render.options, + canvas = render.canvas; + + if (pixelRatio === 'auto') { + pixelRatio = _getPixelRatio(canvas); + } + + options.pixelRatio = pixelRatio; + canvas.setAttribute('data-pixel-ratio', pixelRatio); + canvas.width = options.width * pixelRatio; + canvas.height = options.height * pixelRatio; + canvas.style.width = options.width + 'px'; + canvas.style.height = options.height + 'px'; + render.context.scale(pixelRatio, pixelRatio); + }; + + /** + * Renders the given `engine`'s `Matter.World` object. + * This is the entry point for all rendering and should be called every time the scene changes. + * @method world + * @param {engine} engine + */ + Render.world = function(engine) { + var render = engine.render, + world = engine.world, + canvas = render.canvas, + context = render.context, + options = render.options, + allBodies = Composite.allBodies(world), + allConstraints = Composite.allConstraints(world), + background = options.wireframes ? options.wireframeBackground : options.background, + bodies = [], + constraints = [], + i; + + var event = { + timestamp: engine.timing.timestamp + }; + + Events.trigger(render, 'beforeRender', event); + + // apply background if it has changed + if (render.currentBackground !== background) + _applyBackground(render, background); + + // clear the canvas with a transparent fill, to allow the canvas background to show + context.globalCompositeOperation = 'source-in'; + context.fillStyle = "transparent"; + context.fillRect(0, 0, canvas.width, canvas.height); + context.globalCompositeOperation = 'source-over'; + + // handle bounds + if (options.hasBounds) { + var boundsWidth = render.bounds.max.x - render.bounds.min.x, + boundsHeight = render.bounds.max.y - render.bounds.min.y, + boundsScaleX = boundsWidth / options.width, + boundsScaleY = boundsHeight / options.height; + + // filter out bodies that are not in view + for (i = 0; i < allBodies.length; i++) { + var body = allBodies[i]; + if (Bounds.overlaps(body.bounds, render.bounds)) + bodies.push(body); + } + + // filter out constraints that are not in view + for (i = 0; i < allConstraints.length; i++) { + var constraint = allConstraints[i], + bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointAWorld = constraint.pointA, + pointBWorld = constraint.pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); + + if (!pointAWorld || !pointBWorld) + continue; + + if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) + constraints.push(constraint); + } + + // transform the view + context.scale(1 / boundsScaleX, 1 / boundsScaleY); + context.translate(-render.bounds.min.x, -render.bounds.min.y); + } else { + constraints = allConstraints; + bodies = allBodies; + } + + if (!options.wireframes || (engine.enableSleeping && options.showSleeping)) { + // fully featured rendering of bodies + Render.bodies(engine, bodies, context); + } else { + if (options.showConvexHulls) + Render.bodyConvexHulls(engine, bodies, context); + + // optimised method for wireframes only + Render.bodyWireframes(engine, bodies, context); + } + + if (options.showBounds) + Render.bodyBounds(engine, bodies, context); + + if (options.showAxes || options.showAngleIndicator) + Render.bodyAxes(engine, bodies, context); + + if (options.showPositions) + Render.bodyPositions(engine, bodies, context); + + if (options.showVelocity) + Render.bodyVelocity(engine, bodies, context); + + if (options.showIds) + Render.bodyIds(engine, bodies, context); + + if (options.showSeparations) + Render.separations(engine, engine.pairs.list, context); + + if (options.showCollisions) + Render.collisions(engine, engine.pairs.list, context); + + if (options.showVertexNumbers) + Render.vertexNumbers(engine, bodies, context); + + if (options.showMousePosition) + Render.mousePosition(engine, render.mouse, context); + + Render.constraints(constraints, context); + + if (options.showBroadphase && engine.broadphase.controller === Grid) + Render.grid(engine, engine.broadphase, context); + + if (options.showDebug) + Render.debug(engine, context); + + if (options.hasBounds) { + // revert view transforms + context.setTransform(options.pixelRatio, 0, 0, options.pixelRatio, 0, 0); + } + + Events.trigger(render, 'afterRender', event); + }; + + /** + * Description + * @private + * @method debug + * @param {engine} engine + * @param {RenderingContext} context + */ + Render.debug = function(engine, context) { + var c = context, + world = engine.world, + render = engine.render, + metrics = engine.metrics, + options = render.options, + bodies = Composite.allBodies(world), + space = " "; + + if (engine.timing.timestamp - (render.debugTimestamp || 0) >= 500) { + var text = ""; + + if (metrics.timing) { + text += "fps: " + Math.round(metrics.timing.fps) + space; + } + + + render.debugString = text; + render.debugTimestamp = engine.timing.timestamp; + } + + if (render.debugString) { + c.font = "12px Arial"; + + if (options.wireframes) { + c.fillStyle = 'rgba(255,255,255,0.5)'; + } else { + c.fillStyle = 'rgba(0,0,0,0.5)'; + } + + var split = render.debugString.split('\n'); + + for (var i = 0; i < split.length; i++) { + c.fillText(split[i], 50, 50 + i * 18); + } + } + }; + + /** + * Description + * @private + * @method constraints + * @param {constraint[]} constraints + * @param {RenderingContext} context + */ + Render.constraints = function(constraints, context) { + var c = context; + + for (var i = 0; i < constraints.length; i++) { + var constraint = constraints[i]; + + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + continue; + + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB; + + if (bodyA) { + c.beginPath(); + c.moveTo(bodyA.position.x + constraint.pointA.x, bodyA.position.y + constraint.pointA.y); + } else { + c.beginPath(); + c.moveTo(constraint.pointA.x, constraint.pointA.y); + } + + if (bodyB) { + c.lineTo(bodyB.position.x + constraint.pointB.x, bodyB.position.y + constraint.pointB.y); + } else { + c.lineTo(constraint.pointB.x, constraint.pointB.y); + } + + c.lineWidth = constraint.render.lineWidth; + c.strokeStyle = constraint.render.strokeStyle; + c.stroke(); + } + }; + + /** + * Description + * @private + * @method bodyShadows + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyShadows = function(engine, bodies, context) { + var c = context, + render = engine.render; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (!body.render.visible) + continue; + + if (body.circleRadius) { + c.beginPath(); + c.arc(body.position.x, body.position.y, body.circleRadius, 0, 2 * Math.PI); + c.closePath(); + } else { + c.beginPath(); + c.moveTo(body.vertices[0].x, body.vertices[0].y); + for (var j = 1; j < body.vertices.length; j++) { + c.lineTo(body.vertices[j].x, body.vertices[j].y); + } + c.closePath(); + } + + var distanceX = body.position.x - render.options.width * 0.5, + distanceY = body.position.y - render.options.height * 0.2, + distance = Math.abs(distanceX) + Math.abs(distanceY); + + c.shadowColor = 'rgba(0,0,0,0.15)'; + c.shadowOffsetX = 0.05 * distanceX; + c.shadowOffsetY = 0.05 * distanceY; + c.shadowBlur = 1 + 12 * Math.min(1, distance / 1000); + + c.fill(); + + c.shadowColor = null; + c.shadowOffsetX = null; + c.shadowOffsetY = null; + c.shadowBlur = null; + } + }; + + /** + * Description + * @private + * @method bodies + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodies = function(engine, bodies, context) { + var c = context, + render = engine.render, + options = render.options, + showInternalEdges = options.showInternalEdges || !options.wireframes, + body, + part, + i, + k; + + for (i = 0; i < bodies.length; i++) { + body = bodies[i]; + + if (!body.render.visible) + continue; + + // handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) { + part = body.parts[k]; + + if (!part.render.visible) + continue; + + if (options.showSleeping && body.isSleeping) { + c.globalAlpha = 0.5 * part.render.opacity; + } else if (part.render.opacity !== 1) { + c.globalAlpha = part.render.opacity; + } + + if (part.render.sprite && part.render.sprite.texture && !options.wireframes) { + // part sprite + var sprite = part.render.sprite, + texture = _getTexture(render, sprite.texture); + + c.translate(part.position.x, part.position.y); + c.rotate(part.angle); + + c.drawImage( + texture, + texture.width * -sprite.xOffset * sprite.xScale, + texture.height * -sprite.yOffset * sprite.yScale, + texture.width * sprite.xScale, + texture.height * sprite.yScale + ); + + // revert translation, hopefully faster than save / restore + c.rotate(-part.angle); + c.translate(-part.position.x, -part.position.y); + } else { + // part polygon + if (part.circleRadius) { + c.beginPath(); + c.arc(part.position.x, part.position.y, part.circleRadius, 0, 2 * Math.PI); + } else { + c.beginPath(); + c.moveTo(part.vertices[0].x, part.vertices[0].y); + + for (var j = 1; j < part.vertices.length; j++) { + if (!part.vertices[j - 1].isInternal || showInternalEdges) { + c.lineTo(part.vertices[j].x, part.vertices[j].y); + } else { + c.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) { + c.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); + } + } + + c.lineTo(part.vertices[0].x, part.vertices[0].y); + c.closePath(); + } + + if (!options.wireframes) { + c.fillStyle = part.render.fillStyle; + c.lineWidth = part.render.lineWidth; + c.strokeStyle = part.render.strokeStyle; + c.fill(); + } else { + c.lineWidth = 1; + c.strokeStyle = '#bbb'; + } + + c.stroke(); + } + + c.globalAlpha = 1; + } + } + }; + + /** + * Optimised method for drawing body wireframes in one pass + * @private + * @method bodyWireframes + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyWireframes = function(engine, bodies, context) { + var c = context, + showInternalEdges = engine.render.options.showInternalEdges, + body, + part, + i, + j, + k; + + c.beginPath(); + + // render all bodies + for (i = 0; i < bodies.length; i++) { + body = bodies[i]; + + if (!body.render.visible) + continue; + + // handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) { + part = body.parts[k]; + + c.moveTo(part.vertices[0].x, part.vertices[0].y); + + for (j = 1; j < part.vertices.length; j++) { + if (!part.vertices[j - 1].isInternal || showInternalEdges) { + c.lineTo(part.vertices[j].x, part.vertices[j].y); + } else { + c.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) { + c.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); + } + } + + c.lineTo(part.vertices[0].x, part.vertices[0].y); + } + } + + c.lineWidth = 1; + c.strokeStyle = '#bbb'; + c.stroke(); + }; + + /** + * Optimised method for drawing body convex hull wireframes in one pass + * @private + * @method bodyConvexHulls + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyConvexHulls = function(engine, bodies, context) { + var c = context, + body, + part, + i, + j, + k; + + c.beginPath(); + + // render convex hulls + for (i = 0; i < bodies.length; i++) { + body = bodies[i]; + + if (!body.render.visible || body.parts.length === 1) + continue; + + c.moveTo(body.vertices[0].x, body.vertices[0].y); + + for (j = 1; j < body.vertices.length; j++) { + c.lineTo(body.vertices[j].x, body.vertices[j].y); + } + + c.lineTo(body.vertices[0].x, body.vertices[0].y); + } + + c.lineWidth = 1; + c.strokeStyle = 'rgba(255,255,255,0.2)'; + c.stroke(); + }; + + /** + * Renders body vertex numbers. + * @private + * @method vertexNumbers + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.vertexNumbers = function(engine, bodies, context) { + var c = context, + i, + j, + k; + + for (i = 0; i < bodies.length; i++) { + var parts = bodies[i].parts; + for (k = parts.length > 1 ? 1 : 0; k < parts.length; k++) { + var part = parts[k]; + for (j = 0; j < part.vertices.length; j++) { + c.fillStyle = 'rgba(255,255,255,0.2)'; + c.fillText(i + '_' + j, part.position.x + (part.vertices[j].x - part.position.x) * 0.8, part.position.y + (part.vertices[j].y - part.position.y) * 0.8); + } + } + } + }; + + /** + * Renders mouse position. + * @private + * @method mousePosition + * @param {engine} engine + * @param {mouse} mouse + * @param {RenderingContext} context + */ + Render.mousePosition = function(engine, mouse, context) { + var c = context; + c.fillStyle = 'rgba(255,255,255,0.8)'; + c.fillText(mouse.position.x + ' ' + mouse.position.y, mouse.position.x + 5, mouse.position.y - 5); + }; + + /** + * Draws body bounds + * @private + * @method bodyBounds + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyBounds = function(engine, bodies, context) { + var c = context, + render = engine.render, + options = render.options; + + c.beginPath(); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.render.visible) { + var parts = bodies[i].parts; + for (var j = parts.length > 1 ? 1 : 0; j < parts.length; j++) { + var part = parts[j]; + c.rect(part.bounds.min.x, part.bounds.min.y, part.bounds.max.x - part.bounds.min.x, part.bounds.max.y - part.bounds.min.y); + } + } + } + + if (options.wireframes) { + c.strokeStyle = 'rgba(255,255,255,0.08)'; + } else { + c.strokeStyle = 'rgba(0,0,0,0.1)'; + } + + c.lineWidth = 1; + c.stroke(); + }; + + /** + * Draws body angle indicators and axes + * @private + * @method bodyAxes + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyAxes = function(engine, bodies, context) { + var c = context, + render = engine.render, + options = render.options, + part, + i, + j, + k; + + c.beginPath(); + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i], + parts = body.parts; + + if (!body.render.visible) + continue; + + if (options.showAxes) { + // render all axes + for (j = parts.length > 1 ? 1 : 0; j < parts.length; j++) { + part = parts[j]; + for (k = 0; k < part.axes.length; k++) { + var axis = part.axes[k]; + c.moveTo(part.position.x, part.position.y); + c.lineTo(part.position.x + axis.x * 20, part.position.y + axis.y * 20); + } + } + } else { + for (j = parts.length > 1 ? 1 : 0; j < parts.length; j++) { + part = parts[j]; + for (k = 0; k < part.axes.length; k++) { + // render a single axis indicator + c.moveTo(part.position.x, part.position.y); + c.lineTo((part.vertices[0].x + part.vertices[part.vertices.length-1].x) / 2, + (part.vertices[0].y + part.vertices[part.vertices.length-1].y) / 2); + } + } + } + } + + if (options.wireframes) { + c.strokeStyle = 'indianred'; + } else { + c.strokeStyle = 'rgba(0,0,0,0.8)'; + c.globalCompositeOperation = 'overlay'; + } + + c.lineWidth = 1; + c.stroke(); + c.globalCompositeOperation = 'source-over'; + }; + + /** + * Draws body positions + * @private + * @method bodyPositions + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyPositions = function(engine, bodies, context) { + var c = context, + render = engine.render, + options = render.options, + body, + part, + i, + k; + + c.beginPath(); + + // render current positions + for (i = 0; i < bodies.length; i++) { + body = bodies[i]; + + if (!body.render.visible) + continue; + + // handle compound parts + for (k = 0; k < body.parts.length; k++) { + part = body.parts[k]; + c.arc(part.position.x, part.position.y, 3, 0, 2 * Math.PI, false); + c.closePath(); + } + } + + if (options.wireframes) { + c.fillStyle = 'indianred'; + } else { + c.fillStyle = 'rgba(0,0,0,0.5)'; + } + c.fill(); + + c.beginPath(); + + // render previous positions + for (i = 0; i < bodies.length; i++) { + body = bodies[i]; + if (body.render.visible) { + c.arc(body.positionPrev.x, body.positionPrev.y, 2, 0, 2 * Math.PI, false); + c.closePath(); + } + } + + c.fillStyle = 'rgba(255,165,0,0.8)'; + c.fill(); + }; + + /** + * Draws body velocity + * @private + * @method bodyVelocity + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyVelocity = function(engine, bodies, context) { + var c = context; + + c.beginPath(); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (!body.render.visible) + continue; + + c.moveTo(body.position.x, body.position.y); + c.lineTo(body.position.x + (body.position.x - body.positionPrev.x) * 2, body.position.y + (body.position.y - body.positionPrev.y) * 2); + } + + c.lineWidth = 3; + c.strokeStyle = 'cornflowerblue'; + c.stroke(); + }; + + /** + * Draws body ids + * @private + * @method bodyIds + * @param {engine} engine + * @param {body[]} bodies + * @param {RenderingContext} context + */ + Render.bodyIds = function(engine, bodies, context) { + var c = context, + i, + j; + + for (i = 0; i < bodies.length; i++) { + if (!bodies[i].render.visible) + continue; + + var parts = bodies[i].parts; + for (j = parts.length > 1 ? 1 : 0; j < parts.length; j++) { + var part = parts[j]; + c.font = "12px Arial"; + c.fillStyle = 'rgba(255,255,255,0.5)'; + c.fillText(part.id, part.position.x + 10, part.position.y - 10); + } + } + }; + + /** + * Description + * @private + * @method collisions + * @param {engine} engine + * @param {pair[]} pairs + * @param {RenderingContext} context + */ + Render.collisions = function(engine, pairs, context) { + var c = context, + options = engine.render.options, + pair, + collision, + corrected, + bodyA, + bodyB, + i, + j; + + c.beginPath(); + + // render collision positions + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + collision = pair.collision; + for (j = 0; j < pair.activeContacts.length; j++) { + var contact = pair.activeContacts[j], + vertex = contact.vertex; + c.rect(vertex.x - 1.5, vertex.y - 1.5, 3.5, 3.5); + } + } + + if (options.wireframes) { + c.fillStyle = 'rgba(255,255,255,0.7)'; + } else { + c.fillStyle = 'orange'; + } + c.fill(); + + c.beginPath(); + + // render collision normals + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + collision = pair.collision; + + if (pair.activeContacts.length > 0) { + var normalPosX = pair.activeContacts[0].vertex.x, + normalPosY = pair.activeContacts[0].vertex.y; + + if (pair.activeContacts.length === 2) { + normalPosX = (pair.activeContacts[0].vertex.x + pair.activeContacts[1].vertex.x) / 2; + normalPosY = (pair.activeContacts[0].vertex.y + pair.activeContacts[1].vertex.y) / 2; + } + + if (collision.bodyB === collision.supports[0].body || collision.bodyA.isStatic === true) { + c.moveTo(normalPosX - collision.normal.x * 8, normalPosY - collision.normal.y * 8); + } else { + c.moveTo(normalPosX + collision.normal.x * 8, normalPosY + collision.normal.y * 8); + } + + c.lineTo(normalPosX, normalPosY); + } + } + + if (options.wireframes) { + c.strokeStyle = 'rgba(255,165,0,0.7)'; + } else { + c.strokeStyle = 'orange'; + } + + c.lineWidth = 1; + c.stroke(); + }; + + /** + * Description + * @private + * @method separations + * @param {engine} engine + * @param {pair[]} pairs + * @param {RenderingContext} context + */ + Render.separations = function(engine, pairs, context) { + var c = context, + options = engine.render.options, + pair, + collision, + corrected, + bodyA, + bodyB, + i, + j; + + c.beginPath(); + + // render separations + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + collision = pair.collision; + bodyA = collision.bodyA; + bodyB = collision.bodyB; + + var k = 1; + + if (!bodyB.isStatic && !bodyA.isStatic) k = 0.5; + if (bodyB.isStatic) k = 0; + + c.moveTo(bodyB.position.x, bodyB.position.y); + c.lineTo(bodyB.position.x - collision.penetration.x * k, bodyB.position.y - collision.penetration.y * k); + + k = 1; + + if (!bodyB.isStatic && !bodyA.isStatic) k = 0.5; + if (bodyA.isStatic) k = 0; + + c.moveTo(bodyA.position.x, bodyA.position.y); + c.lineTo(bodyA.position.x + collision.penetration.x * k, bodyA.position.y + collision.penetration.y * k); + } + + if (options.wireframes) { + c.strokeStyle = 'rgba(255,165,0,0.5)'; + } else { + c.strokeStyle = 'orange'; + } + c.stroke(); + }; + + /** + * Description + * @private + * @method grid + * @param {engine} engine + * @param {grid} grid + * @param {RenderingContext} context + */ + Render.grid = function(engine, grid, context) { + var c = context, + options = engine.render.options; + + if (options.wireframes) { + c.strokeStyle = 'rgba(255,180,0,0.1)'; + } else { + c.strokeStyle = 'rgba(255,180,0,0.5)'; + } + + c.beginPath(); + + var bucketKeys = Common.keys(grid.buckets); + + for (var i = 0; i < bucketKeys.length; i++) { + var bucketId = bucketKeys[i]; + + if (grid.buckets[bucketId].length < 2) + continue; + + var region = bucketId.split(','); + c.rect(0.5 + parseInt(region[0], 10) * grid.bucketWidth, + 0.5 + parseInt(region[1], 10) * grid.bucketHeight, + grid.bucketWidth, + grid.bucketHeight); + } + + c.lineWidth = 1; + c.stroke(); + }; + + /** + * Description + * @private + * @method inspector + * @param {inspector} inspector + * @param {RenderingContext} context + */ + Render.inspector = function(inspector, context) { + var engine = inspector.engine, + selected = inspector.selected, + render = engine.render, + options = render.options, + bounds; + + if (options.hasBounds) { + var boundsWidth = render.bounds.max.x - render.bounds.min.x, + boundsHeight = render.bounds.max.y - render.bounds.min.y, + boundsScaleX = boundsWidth / render.options.width, + boundsScaleY = boundsHeight / render.options.height; + + context.scale(1 / boundsScaleX, 1 / boundsScaleY); + context.translate(-render.bounds.min.x, -render.bounds.min.y); + } + + for (var i = 0; i < selected.length; i++) { + var item = selected[i].data; + + context.translate(0.5, 0.5); + context.lineWidth = 1; + context.strokeStyle = 'rgba(255,165,0,0.9)'; + context.setLineDash([1,2]); + + switch (item.type) { + + case 'body': + + // render body selections + bounds = item.bounds; + context.beginPath(); + context.rect(Math.floor(bounds.min.x - 3), Math.floor(bounds.min.y - 3), + Math.floor(bounds.max.x - bounds.min.x + 6), Math.floor(bounds.max.y - bounds.min.y + 6)); + context.closePath(); + context.stroke(); + + break; + + case 'constraint': + + // render constraint selections + var point = item.pointA; + if (item.bodyA) + point = item.pointB; + context.beginPath(); + context.arc(point.x, point.y, 10, 0, 2 * Math.PI); + context.closePath(); + context.stroke(); + + break; + + } + + context.setLineDash([]); + context.translate(-0.5, -0.5); + } + + // render selection region + if (inspector.selectStart !== null) { + context.translate(0.5, 0.5); + context.lineWidth = 1; + context.strokeStyle = 'rgba(255,165,0,0.6)'; + context.fillStyle = 'rgba(255,165,0,0.1)'; + bounds = inspector.selectBounds; + context.beginPath(); + context.rect(Math.floor(bounds.min.x), Math.floor(bounds.min.y), + Math.floor(bounds.max.x - bounds.min.x), Math.floor(bounds.max.y - bounds.min.y)); + context.closePath(); + context.stroke(); + context.fill(); + context.translate(-0.5, -0.5); + } + + if (options.hasBounds) + context.setTransform(1, 0, 0, 1, 0, 0); + }; + + /** + * Description + * @method _createCanvas + * @private + * @param {} width + * @param {} height + * @return canvas + */ + var _createCanvas = function(width, height) { + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + canvas.oncontextmenu = function() { return false; }; + canvas.onselectstart = function() { return false; }; + return canvas; + }; + + /** + * Gets the pixel ratio of the canvas. + * @method _getPixelRatio + * @private + * @param {HTMLElement} canvas + * @return {Number} pixel ratio + */ + var _getPixelRatio = function(canvas) { + var context = canvas.getContext('2d'), + devicePixelRatio = window.devicePixelRatio || 1, + backingStorePixelRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio + || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio + || context.backingStorePixelRatio || 1; + + return devicePixelRatio / backingStorePixelRatio; + }; + + /** + * Gets the requested texture (an Image) via its path + * @method _getTexture + * @private + * @param {render} render + * @param {string} imagePath + * @return {Image} texture + */ + var _getTexture = function(render, imagePath) { + var image = render.textures[imagePath]; + + if (image) + return image; + + image = render.textures[imagePath] = new Image(); + image.src = imagePath; + + return image; + }; + + /** + * Applies the background to the canvas using CSS. + * @method applyBackground + * @private + * @param {render} render + * @param {string} background + */ + var _applyBackground = function(render, background) { + var cssBackground = background; + + if (/(jpg|gif|png)$/.test(background)) + cssBackground = 'url(' + background + ')'; + + render.canvas.style.background = cssBackground; + render.canvas.style.backgroundSize = "contain"; + render.currentBackground = background; + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired before rendering + * + * @event beforeRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after rendering + * + * @event afterRender + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * A back-reference to the `Matter.Render` module. + * + * @property controller + * @type render + */ + + /** + * A reference to the element where the canvas is to be inserted (if `render.canvas` has not been specified) + * + * @property element + * @type HTMLElement + * @default null + */ + + /** + * The canvas element to render to. If not specified, one will be created if `render.element` has been specified. + * + * @property canvas + * @type HTMLCanvasElement + * @default null + */ + + /** + * The configuration options of the renderer. + * + * @property options + * @type {} + */ + + /** + * The target width in pixels of the `render.canvas` to be created. + * + * @property options.width + * @type number + * @default 800 + */ + + /** + * The target height in pixels of the `render.canvas` to be created. + * + * @property options.height + * @type number + * @default 600 + */ + + /** + * A flag that specifies if `render.bounds` should be used when rendering. + * + * @property options.hasBounds + * @type boolean + * @default false + */ + + /** + * A `Bounds` object that specifies the drawing view region. + * Rendering will be automatically transformed and scaled to fit within the canvas size (`render.options.width` and `render.options.height`). + * This allows for creating views that can pan or zoom around the scene. + * You must also set `render.options.hasBounds` to `true` to enable bounded rendering. + * + * @property bounds + * @type bounds + */ + + /** + * The 2d rendering context from the `render.canvas` element. + * + * @property context + * @type CanvasRenderingContext2D + */ + + /** + * The sprite texture cache. + * + * @property textures + * @type {} + */ + +})(); + +},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":24,"../geometry/Vector":26}],30:[function(require,module,exports){ +/** +* The `Matter.RenderPixi` module is an example renderer using pixi.js. +* See also `Matter.Render` for a canvas based renderer. +* +* @class RenderPixi +*/ + +var RenderPixi = {}; + +module.exports = RenderPixi; + +var Composite = require('../body/Composite'); +var Common = require('../core/Common'); + +(function() { + + /** + * Creates a new Pixi.js WebGL renderer + * @method create + * @param {object} options + * @return {RenderPixi} A new renderer + */ + RenderPixi.create = function(options) { + var defaults = { + controller: RenderPixi, + element: null, + canvas: null, + renderer: null, + container: null, + spriteContainer: null, + pixiOptions: null, + options: { + width: 800, + height: 600, + background: '#fafafa', + wireframeBackground: '#222', + hasBounds: false, + enabled: true, + wireframes: true, + showSleeping: true, + showDebug: false, + showBroadphase: false, + showBounds: false, + showVelocity: false, + showCollisions: false, + showAxes: false, + showPositions: false, + showAngleIndicator: false, + showIds: false, + showShadows: false + } + }; + + var render = Common.extend(defaults, options), + transparent = !render.options.wireframes && render.options.background === 'transparent'; + + // init pixi + render.pixiOptions = render.pixiOptions || { + view: render.canvas, + transparent: transparent, + antialias: true, + backgroundColor: options.background + }; + + render.renderer = render.renderer || new PIXI.WebGLRenderer(render.options.width, render.options.height, render.pixiOptions); + render.container = render.container || new PIXI.Container(); + render.spriteContainer = render.spriteContainer || new PIXI.Container(); + render.canvas = render.canvas || render.renderer.view; + render.bounds = render.bounds || { + min: { + x: 0, + y: 0 + }, + max: { + x: render.options.width, + y: render.options.height + } + }; + + // caches + render.textures = {}; + render.sprites = {}; + render.primitives = {}; + + // use a sprite batch for performance + render.container.addChild(render.spriteContainer); + + // insert canvas + if (Common.isElement(render.element)) { + render.element.appendChild(render.canvas); + } else { + Common.log('No "render.element" passed, "render.canvas" was not inserted into document.', 'warn'); + } + + // prevent menus on canvas + render.canvas.oncontextmenu = function() { return false; }; + render.canvas.onselectstart = function() { return false; }; + + return render; + }; + + /** + * Clears the scene graph + * @method clear + * @param {RenderPixi} render + */ + RenderPixi.clear = function(render) { + var container = render.container, + spriteContainer = render.spriteContainer; + + // clear stage container + while (container.children[0]) { + container.removeChild(container.children[0]); + } + + // clear sprite batch + while (spriteContainer.children[0]) { + spriteContainer.removeChild(spriteContainer.children[0]); + } + + var bgSprite = render.sprites['bg-0']; + + // clear caches + render.textures = {}; + render.sprites = {}; + render.primitives = {}; + + // set background sprite + render.sprites['bg-0'] = bgSprite; + if (bgSprite) + container.addChildAt(bgSprite, 0); + + // add sprite batch back into container + render.container.addChild(render.spriteContainer); + + // reset background state + render.currentBackground = null; + + // reset bounds transforms + container.scale.set(1, 1); + container.position.set(0, 0); + }; + + /** + * Sets the background of the canvas + * @method setBackground + * @param {RenderPixi} render + * @param {string} background + */ + RenderPixi.setBackground = function(render, background) { + if (render.currentBackground !== background) { + var isColor = background.indexOf && background.indexOf('#') !== -1, + bgSprite = render.sprites['bg-0']; + + if (isColor) { + // if solid background color + var color = Common.colorToNumber(background); + render.renderer.backgroundColor = color; + + // remove background sprite if existing + if (bgSprite) + render.container.removeChild(bgSprite); + } else { + // initialise background sprite if needed + if (!bgSprite) { + var texture = _getTexture(render, background); + + bgSprite = render.sprites['bg-0'] = new PIXI.Sprite(texture); + bgSprite.position.x = 0; + bgSprite.position.y = 0; + render.container.addChildAt(bgSprite, 0); + } + } + + render.currentBackground = background; + } + }; + + /** + * Description + * @method world + * @param {engine} engine + */ + RenderPixi.world = function(engine) { + var render = engine.render, + world = engine.world, + renderer = render.renderer, + container = render.container, + options = render.options, + bodies = Composite.allBodies(world), + allConstraints = Composite.allConstraints(world), + constraints = [], + i; + + if (options.wireframes) { + RenderPixi.setBackground(render, options.wireframeBackground); + } else { + RenderPixi.setBackground(render, options.background); + } + + // handle bounds + var boundsWidth = render.bounds.max.x - render.bounds.min.x, + boundsHeight = render.bounds.max.y - render.bounds.min.y, + boundsScaleX = boundsWidth / render.options.width, + boundsScaleY = boundsHeight / render.options.height; + + if (options.hasBounds) { + // Hide bodies that are not in view + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); + } + + // filter out constraints that are not in view + for (i = 0; i < allConstraints.length; i++) { + var constraint = allConstraints[i], + bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointAWorld = constraint.pointA, + pointBWorld = constraint.pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); + + if (!pointAWorld || !pointBWorld) + continue; + + if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) + constraints.push(constraint); + } + + // transform the view + container.scale.set(1 / boundsScaleX, 1 / boundsScaleY); + container.position.set(-render.bounds.min.x * (1 / boundsScaleX), -render.bounds.min.y * (1 / boundsScaleY)); + } else { + constraints = allConstraints; + } + + for (i = 0; i < bodies.length; i++) + RenderPixi.body(engine, bodies[i]); + + for (i = 0; i < constraints.length; i++) + RenderPixi.constraint(engine, constraints[i]); + + renderer.render(container); + }; + + + /** + * Description + * @method constraint + * @param {engine} engine + * @param {constraint} constraint + */ + RenderPixi.constraint = function(engine, constraint) { + var render = engine.render, + bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointA = constraint.pointA, + pointB = constraint.pointB, + container = render.container, + constraintRender = constraint.render, + primitiveId = 'c-' + constraint.id, + primitive = render.primitives[primitiveId]; + + // initialise constraint primitive if not existing + if (!primitive) + primitive = render.primitives[primitiveId] = new PIXI.Graphics(); + + // don't render if constraint does not have two end points + if (!constraintRender.visible || !constraint.pointA || !constraint.pointB) { + primitive.clear(); + return; + } + + // add to scene graph if not already there + if (Common.indexOf(container.children, primitive) === -1) + container.addChild(primitive); + + // render the constraint on every update, since they can change dynamically + primitive.clear(); + primitive.beginFill(0, 0); + primitive.lineStyle(constraintRender.lineWidth, Common.colorToNumber(constraintRender.strokeStyle), 1); + + if (bodyA) { + primitive.moveTo(bodyA.position.x + pointA.x, bodyA.position.y + pointA.y); + } else { + primitive.moveTo(pointA.x, pointA.y); + } + + if (bodyB) { + primitive.lineTo(bodyB.position.x + pointB.x, bodyB.position.y + pointB.y); + } else { + primitive.lineTo(pointB.x, pointB.y); + } + + primitive.endFill(); + }; + + /** + * Description + * @method body + * @param {engine} engine + * @param {body} body + */ + RenderPixi.body = function(engine, body) { + var render = engine.render, + bodyRender = body.render; + + if (!bodyRender.visible) + return; + + if (bodyRender.sprite && bodyRender.sprite.texture) { + var spriteId = 'b-' + body.id, + sprite = render.sprites[spriteId], + spriteContainer = render.spriteContainer; + + // initialise body sprite if not existing + if (!sprite) + sprite = render.sprites[spriteId] = _createBodySprite(render, body); + + // add to scene graph if not already there + if (Common.indexOf(spriteContainer.children, sprite) === -1) + spriteContainer.addChild(sprite); + + // update body sprite + sprite.position.x = body.position.x; + sprite.position.y = body.position.y; + sprite.rotation = body.angle; + sprite.scale.x = bodyRender.sprite.xScale || 1; + sprite.scale.y = bodyRender.sprite.yScale || 1; + } else { + var primitiveId = 'b-' + body.id, + primitive = render.primitives[primitiveId], + container = render.container; + + // initialise body primitive if not existing + if (!primitive) { + primitive = render.primitives[primitiveId] = _createBodyPrimitive(render, body); + primitive.initialAngle = body.angle; + } + + // add to scene graph if not already there + if (Common.indexOf(container.children, primitive) === -1) + container.addChild(primitive); + + // update body primitive + primitive.position.x = body.position.x; + primitive.position.y = body.position.y; + primitive.rotation = body.angle - primitive.initialAngle; + } + }; + + /** + * Creates a body sprite + * @method _createBodySprite + * @private + * @param {RenderPixi} render + * @param {body} body + * @return {PIXI.Sprite} sprite + */ + var _createBodySprite = function(render, body) { + var bodyRender = body.render, + texturePath = bodyRender.sprite.texture, + texture = _getTexture(render, texturePath), + sprite = new PIXI.Sprite(texture); + + sprite.anchor.x = body.render.sprite.xOffset; + sprite.anchor.y = body.render.sprite.yOffset; + + return sprite; + }; + + /** + * Creates a body primitive + * @method _createBodyPrimitive + * @private + * @param {RenderPixi} render + * @param {body} body + * @return {PIXI.Graphics} graphics + */ + var _createBodyPrimitive = function(render, body) { + var bodyRender = body.render, + options = render.options, + primitive = new PIXI.Graphics(), + fillStyle = Common.colorToNumber(bodyRender.fillStyle), + strokeStyle = Common.colorToNumber(bodyRender.strokeStyle), + strokeStyleIndicator = Common.colorToNumber(bodyRender.strokeStyle), + strokeStyleWireframe = Common.colorToNumber('#bbb'), + strokeStyleWireframeIndicator = Common.colorToNumber('#CD5C5C'), + part; + + primitive.clear(); + + // handle compound parts + for (var k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) { + part = body.parts[k]; + + if (!options.wireframes) { + primitive.beginFill(fillStyle, 1); + primitive.lineStyle(bodyRender.lineWidth, strokeStyle, 1); + } else { + primitive.beginFill(0, 0); + primitive.lineStyle(1, strokeStyleWireframe, 1); + } + + primitive.moveTo(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); + + for (var j = 1; j < part.vertices.length; j++) { + primitive.lineTo(part.vertices[j].x - body.position.x, part.vertices[j].y - body.position.y); + } + + primitive.lineTo(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); + + primitive.endFill(); + + // angle indicator + if (options.showAngleIndicator || options.showAxes) { + primitive.beginFill(0, 0); + + if (options.wireframes) { + primitive.lineStyle(1, strokeStyleWireframeIndicator, 1); + } else { + primitive.lineStyle(1, strokeStyleIndicator); + } + + primitive.moveTo(part.position.x - body.position.x, part.position.y - body.position.y); + primitive.lineTo(((part.vertices[0].x + part.vertices[part.vertices.length-1].x) / 2 - body.position.x), + ((part.vertices[0].y + part.vertices[part.vertices.length-1].y) / 2 - body.position.y)); + + primitive.endFill(); + } + } + + return primitive; + }; + + /** + * Gets the requested texture (a PIXI.Texture) via its path + * @method _getTexture + * @private + * @param {RenderPixi} render + * @param {string} imagePath + * @return {PIXI.Texture} texture + */ + var _getTexture = function(render, imagePath) { + var texture = render.textures[imagePath]; + + if (!texture) + texture = render.textures[imagePath] = PIXI.Texture.fromImage(imagePath); + + return texture; + }; + +})(); + +},{"../body/Composite":2,"../core/Common":14}]},{},[28])(28) +}); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.ani.min.js b/games/laya-snakes/libs/min/laya.ani.min.js new file mode 100644 index 0000000..8628a68 --- /dev/null +++ b/games/laya-snakes/libs/min/laya.ani.min.js @@ -0,0 +1,2 @@ +!function(t,i,e){var a=(e.un,e.uns,e["static"]),s=e["class"],r=e.getset,n=e.__newvec,h=laya.utils.Browser,l=laya.utils.Byte,o=laya.events.Event,u=laya.events.EventDispatcher,c=laya.display.Graphics,p=laya.utils.Handler,_=laya.net.Loader,d=laya.maths.MathUtil,f=laya.maths.Matrix,m=laya.renders.Render,x=laya.resource.Resource,y=laya.utils.RunDriver,g=laya.display.Sprite,v=laya.utils.Stat,M=laya.resource.Texture,D=laya.net.URL,I=(function(){function t(){}return s(t,"laya.ani.AnimationState"),t.stopped=0,t.paused=1,t.playing=2,t}(),function(){function t(){this.name=null,this.root=null,this.parentBone=null,this.length=10,this.transform=null,this.inheritScale=!0,this.inheritRotation=!0,this.rotation=NaN,this.resultRotation=NaN,this._tempMatrix=null,this._sprite=null,this.resultTransform=new E,this.resultMatrix=new f,this._children=[]}s(t,"laya.ani.bone.Bone");var i=t.prototype;return i.setTempMatrix=function(t){this._tempMatrix=t;var i,e=0,a=0;for(e=0,a=this._children.length;a>e;e++)i=this._children[e],i.setTempMatrix(this._tempMatrix)},i.update=function(t){this.rotation=this.transform.skX;var i;if(t)i=this.resultTransform.getMatrix(),f.mul(i,t,this.resultMatrix),this.resultRotation=this.rotation;else if(this.resultRotation=this.rotation+this.parentBone.resultRotation,this.parentBone)if(this.inheritRotation&&this.inheritScale)i=this.resultTransform.getMatrix(),f.mul(i,this.parentBone.resultMatrix,this.resultMatrix);else{var e=this.parentBone,a=NaN,s=NaN,r=NaN,n=this.parentBone.resultMatrix,h=n.a*this.transform.x+n.c*this.transform.y+n.tx,l=n.b*this.transform.x+n.d*this.transform.y+n.ty,o=new f;this.inheritRotation?(a=Math.atan2(e.resultMatrix.b,e.resultMatrix.a),s=Math.cos(a),r=Math.sin(a),o.setTo(s,r,-r,s,0,0),f.mul(this._tempMatrix,o,f.TEMP),f.TEMP.copyTo(o),i=this.resultTransform.getMatrix(),f.mul(i,o,this.resultMatrix),this.resultMatrix.tx=h,this.resultMatrix.ty=l):this.inheritScale?(i=this.resultTransform.getMatrix(),f.TEMP.identity(),f.TEMP.d=-1,f.mul(i,f.TEMP,this.resultMatrix),this.resultMatrix.tx=h,this.resultMatrix.ty=l):(i=this.resultTransform.getMatrix(),f.TEMP.identity(),f.TEMP.d=-1,f.mul(i,f.TEMP,this.resultMatrix),this.resultMatrix.tx=h,this.resultMatrix.ty=l)}else i=this.resultTransform.getMatrix(),i.copyTo(this.resultMatrix);var u,c=0,p=0;for(c=0,p=this._children.length;p>c;c++)u=this._children[c],u.update()},i.updateChild=function(){var t,i=0,e=0;for(i=0,e=this._children.length;e>i;i++)t=this._children[i],t.update()},i.updateDraw=function(t,i){this._sprite?(this._sprite.x=t+this.resultMatrix.tx,this._sprite.y=i+this.resultMatrix.ty):(this._sprite=new g,this._sprite.graphics.drawCircle(0,0,5,"#ff0000"),this._sprite.graphics.fillText(this.name,0,0,"20px Arial","#00ff00","center"),e.stage.addChild(this._sprite),this._sprite.x=t+this.resultMatrix.tx,this._sprite.y=i+this.resultMatrix.ty);var a,s=0,r=0;for(s=0,r=this._children.length;r>s;s++)a=this._children[s],a.updateDraw(t,i)},i.addChild=function(t){this._children.push(t),t.parentBone=this},i.findBone=function(t){if(this.name==t)return this;var i,e,a=0,s=0;for(a=0,s=this._children.length;s>a;a++)if(i=this._children[a],e=i.findBone(t))return e;return null},i.localToWorld=function(t){var i=t[0],e=t[1];t[0]=i*this.resultMatrix.a+e*this.resultMatrix.c+this.resultMatrix.tx,t[1]=i*this.resultMatrix.b+e*this.resultMatrix.d+this.resultMatrix.ty},t}()),b=function(){function t(){this.name=null,this.parent=null,this.attachmentName=null,this.srcDisplayIndex=-1,this.type="src",this.templet=null,this.currSlotData=null,this.currTexture=null,this.currDisplayData=null,this.displayIndex=-1,this._diyTexture=null,this._parentMatrix=null,this._resultMatrix=null,this._skinSprite=null,this.deformData=null}s(t,"laya.ani.bone.BoneSlot");var i=t.prototype;return i.showSlotData=function(t){this.currSlotData=t,this.displayIndex=this.srcDisplayIndex,this.currDisplayData=null,this.currTexture=null},i.showDisplayByName=function(t){this.currSlotData&&this.showDisplayByIndex(this.currSlotData.getDisplayByName(t))},i.showDisplayByIndex=function(t){if(this.currSlotData&&t>-1&&tthis.currDisplayData.uvs[5]&&(o.d=-1),this.currDisplayData.uvs[0]>this.currDisplayData.uvs[4]&&this.currDisplayData.uvs[1]>this.currDisplayData.uvs[5]&&(h=!0,o.rotate(-Math.PI/2)),f.mul(o,f.TEMP,l)}else f.TEMP.copyTo(l);h?t.drawTexture(s,-this.currDisplayData.height/2,-this.currDisplayData.width/2,this.currDisplayData.height,this.currDisplayData.width,l):t.drawTexture(s,-this.currDisplayData.width/2,-this.currDisplayData.height/2,this.currDisplayData.width,this.currDisplayData.height,l)}}}break;case 1:if(e?(null==this._skinSprite&&(this._skinSprite=y.skinAniSprite()),r=this._skinSprite):r=y.skinAniSprite(),null==r)return;var u=[],c=[],p=1,_=1,d=1,x=1;if(null==this.currDisplayData.bones){var g=this.currDisplayData.weights;this.deformData&&(g=this.deformData);for(var v=0,M=0;vv;v++)c.push(this.currDisplayData.triangles[3*v]),c.push(this.currDisplayData.triangles[3*v+1]),c.push(this.currDisplayData.triangles[3*v+2]);r.init(this.currTexture,u,c);var N=this.getDisplayMatrix();if(this._parentMatrix&&N){f.mul(N,this._parentMatrix,f.TEMP);var A;e?(null==this._resultMatrix&&(this._resultMatrix=new f),A=this._resultMatrix):A=new f,f.TEMP.copyTo(A),r.transform=A}}else this.skinMesh(i,r,a);t.drawSkin(r);break;case 2:if(e?(null==this._skinSprite&&(this._skinSprite=y.skinAniSprite()),r=this._skinSprite):r=y.skinAniSprite(),null==r)return;this.skinMesh(i,r,a),t.drawSkin(r);break;case 3:}}},i.skinMesh=function(t,i,e){var a,s=this.currDisplayData.bones,r=this.currDisplayData.uvs,n=this.currDisplayData.weights,h=this.currDisplayData.triangles,l=[],o=[],u=0,c=0,p=0,_=NaN,d=NaN,f=0,m=0,x=[],y=0,g=0,v=0,M=1,D=1,I=1,b=e;if(this.deformData&&this.deformData.length>0){var N=0;for(y=0,v=s.length;v>y;){for(p=s[y++]+y,u=0,c=0;p>y;y++)a=t[s[y]],_=n[f]+this.deformData[N++],d=n[f+1]+this.deformData[N++],m=n[f+2],u+=(_*a.a+d*a.c+a.tx)*m,c+=(_*a.b+d*a.d+a.ty)*m,f+=3;x.push(u,c)}}else for(y=0,v=s.length;v>y;){for(p=s[y++]+y,u=0,c=0;p>y;y++)a=t[s[y]],_=n[f],d=n[f+1],m=n[f+2],u+=(_*a.a+d*a.c+a.tx)*m,c+=(_*a.b+d*a.d+a.ty)*m,f+=3;x.push(u,c)}for(y=0,g=0;yy;y++)o.push(h[y]);i.init(this.currTexture,l,o)},i.drawBonePoint=function(t){t&&this._parentMatrix&&t.drawCircle(this._parentMatrix.tx,this._parentMatrix.ty,5,"#ff0000")},i.getDisplayMatrix=function(){return this.currDisplayData?this.currDisplayData.transform.getMatrix():null},i.getMatrix=function(){return this._resultMatrix},i.copy=function(){var i=new t;return i.type="copy",i.name=this.name,i.attachmentName=this.attachmentName,i.srcDisplayIndex=this.srcDisplayIndex,i.parent=this.parent,i.displayIndex=this.displayIndex,i.templet=this.templet,i.currSlotData=this.currSlotData,i.currTexture=this.currTexture,i.currDisplayData=this.currDisplayData,i},t}(),N=function(){function t(){this.skinName=null,this.deformSlotDataList=[]}return s(t,"laya.ani.bone.DeformAniData"),t}(),A=function(){function t(){this.deformSlotDisplayList=[]}return s(t,"laya.ani.bone.DeformSlotData"),t}(),T=function(){function t(){this.boneSlot=null,this.slotIndex=-1,this.attachment=null,this.deformData=null,this.frameIndex=0,this.timeList=[],this.vectices=[],this.tweenKeyList=[]}s(t,"laya.ani.bone.DeformSlotDisplayData");var i=t.prototype;return i.binarySearch1=function(t,i){var e=0,a=t.length-2;if(0==a)return 1;for(var s=a>>>1;;){if(t[Math.floor(s+1)]<=i?e=s+1:a=s,e==a)return e+1;s=e+a>>>1}return 0},i.apply=function(t,i,e){if(void 0===e&&(e=1),!(this.timeList.length<=0)){var a=0,s=this.timeList[0];if(!(s>t)){var r=this.vectices[0].length,n=[],h=this.binarySearch1(this.timeList,t);if(this.frameIndex=h,t>=this.timeList[this.timeList.length-1]){var l=this.vectices[this.vectices.length-1];if(1>e)for(a=0;r>a;a++)n[a]+=(l[a]-n[a])*e;else for(a=0;r>a;a++)n[a]=l[a];return void(this.deformData=n)}var o=(this.tweenKeyList[this.frameIndex],this.vectices[this.frameIndex-1]),u=this.vectices[this.frameIndex],c=this.timeList[this.frameIndex-1],p=this.timeList[this.frameIndex];this.tweenKeyList[h-1]&&(e=(t-c)/(p-c));var _=NaN;for(a=0;r>a;a++)_=o[a],n[a]=_+(u[a]-_)*e;this.deformData=n}}},t}(),S=function(){function t(){this.time=NaN,this.drawOrder=[]}return s(t,"laya.ani.bone.DrawOrderData"),t}(),F=function(){function t(){this.name=null,this.intValue=0,this.floatValue=NaN,this.stringValue=null,this.time=NaN}return s(t,"laya.ani.bone.EventData"),t}(),k=function(){function t(t,i){this._targetBone=null,this._bones=null,this._data=null,this.name=null,this.mix=NaN,this.bendDirection=NaN,this._data=t,this._targetBone=i[t.targetBoneIndex],null==this._bones&&(this._bones=[]),this._bones.length=0;for(var e=0,a=t.boneIndexs.length;a>e;e++)this._bones.push(i[t.boneIndexs[e]]);this.name=t.name,this.mix=t.mix,this.bendDirection=t.bendDirection}s(t,"laya.ani.bone.IkConstraint");var i=t.prototype;return i.apply=function(){switch(this._bones.length){case 1:this._applyIk1(this._bones[0],this._targetBone.resultMatrix.tx,this._targetBone.resultMatrix.ty,this.mix);break;case 2:this._applyIk2(this._bones[0],this._bones[1],this._targetBone.resultMatrix.tx,this._targetBone.resultMatrix.ty,this.bendDirection,this.mix)}},i._applyIk1=function(i,e,a,s){var r=i.parentBone,n=1/(r.resultMatrix.a*r.resultMatrix.d-r.resultMatrix.b*r.resultMatrix.c),h=e-r.resultMatrix.tx,l=a-r.resultMatrix.ty,o=(h*r.resultMatrix.d-l*r.resultMatrix.c)*n-i.transform.x,u=(l*r.resultMatrix.a-h*r.resultMatrix.b)*n-i.transform.y,c=Math.atan2(u,o)*t.radDeg-0-i.transform.skX;i.transform.scX<0&&(c+=180),c>180?c-=360:-180>c&&(c+=360),i.transform.skX=i.transform.skY=i.transform.skX+c*s,i.update()},i._applyIk2=function(i,e,a,s,r,n){if(0!=n){var h=i.resultTransform.x,l=i.resultTransform.y,o=i.transform.scX,u=i.transform.scY,c=e.transform.scX,p=0,_=0,d=0;0>o?(o=-o,p=180,d=-1):(p=0,d=1),0>u&&(u=-u,d=-d),0>c?(c=-c,_=180):_=0;var f=e.resultTransform.x,m=NaN,x=NaN,y=NaN,g=i.resultMatrix.a,v=i.resultMatrix.c,M=i.resultMatrix.b,D=i.resultMatrix.d,I=Math.abs(o-u)<=1e-4;I?(m=e.resultTransform.y,x=g*f+v*m+i.resultMatrix.tx,y=M*f+D*m+i.resultMatrix.ty):(m=0,x=g*f+i.resultMatrix.tx,y=M*f+i.resultMatrix.ty);var b=i.parentBone;g=b.resultMatrix.a,v=b.resultMatrix.c,M=b.resultMatrix.b,D=b.resultMatrix.d;var N=1/(g*D-v*M),A=a-b.resultMatrix.tx,T=s-b.resultMatrix.ty,S=(A*D-T*v)*N-h,F=(T*g-A*M)*N-l;A=x-b.resultMatrix.tx,T=y-b.resultMatrix.ty;var k=(A*D-T*v)*N-h,C=(T*g-A*M)*N-l,w=Math.sqrt(k*k+C*C),P=e.length*c,L=NaN,B=NaN;if(I){P*=o;var U=(S*S+F*F-w*w-P*P)/(2*w*P);-1>U?U=-1:U>1&&(U=1),B=Math.acos(U)*r,g=w+P*U,v=P*Math.sin(B),L=Math.atan2(F*g-S*v,S*g+F*v)}else{g=o*P,v=u*P;var R=g*g,O=v*v,E=S*S+F*F,Y=Math.atan2(F,S);M=O*w*w+R*E-R*O;var X=-2*O*w,K=O-R;if(D=X*X-4*K*M,D>0){var W=Math.sqrt(D);0>X&&(W=-W),W=-(X+W)/2;var G=W/K,q=M/W,V=Math.abs(G)=V*V&&(T=Math.sqrt(E-V*V)*r,L=Y-Math.atan2(T,V),B=Math.atan2(T/u,(V-w)/o))}var H=0,z=Number.MAX_VALUE,Q=0,Z=0,$=0,j=0,J=0,tt=0;A=w+g,D=A*A,D>j&&($=0,j=D,J=A),A=w-g,D=A*A,z>D&&(H=Math.PI,z=D,Q=A);var it=Math.acos(-g*w/(R-O));A=g*Math.cos(it)+w,T=v*Math.sin(it),D=A*A+T*T,z>D&&(H=it,z=D,Q=A,Z=T),D>j&&($=it,j=D,J=A,tt=T),(z+j)/2>=E?(L=Y-Math.atan2(Z*r,Q),B=H*r):(L=Y-Math.atan2(tt*r,J),B=$*r)}var et=Math.atan2(m,f)*d,at=i.resultTransform.skX;L=(L-et)*t.radDeg+p-at,L>180?L-=360:-180>L&&(L+=360),i.resultTransform.x=h,i.resultTransform.y=l,i.resultTransform.skX=i.resultTransform.skY=at+L*n,at=e.resultTransform.skX,at%=360,B=((B+et)*t.radDeg-0)*d+_-at,B>180?B-=360:-180>B&&(B+=360),e.resultTransform.x=f,e.resultTransform.y=m,e.resultTransform.skX=e.resultTransform.skY=e.resultTransform.skY+B*n,i.update()}},a(t,["radDeg",function(){return this.radDeg=180/Math.PI},"degRad",function(){return this.degRad=Math.PI/180}]),t}(),C=function(){function t(){this.name=null,this.targetBoneName=null,this.bendDirection=1,this.mix=1,this.targetBoneIndex=-1,this.boneNames=[],this.boneIndexs=[]}return s(t,"laya.ani.bone.IkConstraintData"),t}(),w=function(){function t(t,i){this.target=null,this.data=null,this.bones=null,this.position=NaN,this.spacing=NaN,this.rotateMix=NaN,this.translateMix=NaN,this._debugKey=!1,this._spaces=null,this._segments=[],this._curves=[],this.data=t,this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.bones=[];for(var e=this.data.bones,a=0,s=e.length;s>a;a++)this.bones.push(i[e[a]])}s(t,"laya.ani.bone.PathConstraint");var i=t.prototype;return i.apply=function(t,i){var e=this.translateMix,a=this.translateMix,s=a>0,r=this.data.spacingMode,n="length"==r,h=this.data.rotateMode,l="tangent"==h,o="chainScale"==h,u=[],c=this.bones.length,p=l?c:c+1,_=[];this._spaces=_,_[0]=this.position;var d=this.spacing;if(o||n)for(var f=0,m=p-1;m>f;){var x=this.bones[f],y=x.length,g=y*x.transform.getMatrix().a,v=y*x.transform.getMatrix().c;y=Math.sqrt(g*g+v*v),o&&(u[f]=y),_[++f]=n?Math.max(0,y+d):d}else for(f=1;p>f;f++)_[f]=d;var M=this.computeWorldPositions(this.target,t,i,p,l,"percent"==this.data.positionMode,"percent"==r);if(this._debugKey){for(f=0;ff;f++,T+=3){x=this.bones[f],x.resultMatrix.tx+=(I-x.resultMatrix.tx)*e,x.resultMatrix.ty+=(b-x.resultMatrix.ty)*e,g=M[T],v=M[T+1];var S=g-I,F=v-b;if(o&&(y=u[f],0!=y)){var k=(Math.sqrt(S*S+F*F)/y-1)*a+1;x.resultMatrix.a*=k,x.resultMatrix.c*=k}if(I=g,b=v,s){var C=x.resultMatrix.a,w=x.resultMatrix.b,P=x.resultMatrix.c,L=x.resultMatrix.d,B=NaN,U=NaN,R=NaN;B=l?M[T-1]:0==_[f+1]?M[T+2]:Math.atan2(F,S),B-=Math.atan2(P,C)-N/180*Math.PI,A&&(U=Math.cos(B),R=Math.sin(B),y=x.length,I+=(y*(U*C-R*P)-S)*a,b+=(y*(R*C+U*P)-F)*a),B>Math.PI?B-=2*Math.PI:B<-Math.PI&&(B+=2*Math.PI),B*=a,U=Math.cos(B),R=Math.sin(B),x.resultMatrix.a=U*C-R*P,x.resultMatrix.c=U*w-R*L,x.resultMatrix.b=R*C+U*P,x.resultMatrix.d=R*w+U*L}}},i.computeWorldVertices2=function(t,i,e,a,s,r){var n,h=t.currDisplayData.bones,l=t.currDisplayData.weights,o=(t.currDisplayData.triangles,0),u=0,c=0,p=0,_=0,d=0,f=0,m=0,x=0,y=0;for(o=0;e>o;o+=2)p=h[u],u+=p+1,c+=p;var g=i;for(_=r,d=3*c;a>_;_+=2){for(f=0,m=0,p=h[u++],p+=u;p>u;u++,d+=3){n=g[h[u]].resultMatrix,x=l[d],y=l[d+1];var v=l[d+2];f+=(x*n.a+y*n.c+n.tx)*v,m+=(x*n.b+y*n.d+n.ty)*v}s[_]=f,s[_+1]=m}},i.computeWorldPositions=function(t,i,e,a,s,r,n){var h=(t.currDisplayData.bones,t.currDisplayData.weights,t.currDisplayData.triangles,[]),l=0,o=t.currDisplayData.verLen,u=this.position,c=this._spaces,p=[],_=[],d=!1,f=o/6,m=-1,x=NaN,y=0,g=0,v=NaN,M=NaN,D=NaN,I=NaN;if(d)o+=2,p[o-2]=p[0],p[o-1]=p[1];else{if(f--,o-=4,this.computeWorldVertices2(t,i,2,o,h,0),this._debugKey)for(l=0;ll;l++,X+=6)T=p[X],S=p[X+1],F=p[X+2],k=p[X+3],C=p[X+4],w=p[X+5],P=.1875*(N-2*T+F),L=.1875*(A-2*S+k),B=.09375*(3*(T-F)-N+C),U=.09375*(3*(S-k)-A+w),R=2*P+B,O=2*L+U,E=.75*(T-N)+P+.16666667*B,Y=.75*(S-A)+L+.16666667*U,x+=Math.sqrt(E*E+Y*Y),E+=R,Y+=O,R+=B,O+=U,x+=Math.sqrt(E*E+Y*Y),E+=R,Y+=O,x+=Math.sqrt(E*E+Y*Y),E+=R+B,Y+=O+U,x+=Math.sqrt(E*E+Y*Y),b[l]=x,N=C,A=w;if(r&&(u*=x),n)for(l=0;a>l;l++)c[l]*=x;var K=this._segments,W=0,G=0;for(l=0,y=0,g=0,G=0;a>l;l++,y+=3){if(M=c[l],u+=M,v=u,d)v%=x,0>v&&(v+=x),g=0;else{if(0>v){this.addBeforePosition(v,p,0,_,y);continue}if(v>x){this.addAfterPosition(v-x,p,o-4,_,y);continue}}for(;;g++)if(I=b[g],!(v>I)){0==g?v/=I:(D=b[g-1],v=(v-D)/(I-D));break}if(g!=m){m=g;var q=6*g;for(N=p[q],A=p[q+1],T=p[q+2],S=p[q+3],F=p[q+4],k=p[q+5],C=p[q+6],w=p[q+7],P=.03*(N-2*T+F),L=.03*(A-2*S+k),B=.006*(3*(T-F)-N+C),U=.006*(3*(S-k)-A+w),R=2*P+B,O=2*L+U,E=.3*(T-N)+P+.16666667*B,Y=.3*(S-A)+L+.16666667*U,W=Math.sqrt(E*E+Y*Y),K[0]=W,q=1;8>q;q++)E+=R,Y+=O,R+=B,O+=U,W+=Math.sqrt(E*E+Y*Y),K[q]=W;E+=R,Y+=O,W+=Math.sqrt(E*E+Y*Y),K[8]=W,E+=R+B,Y+=O+U,W+=Math.sqrt(E*E+Y*Y),K[9]=W,G=0}for(v*=W;;G++)if(I=K[G],!(v>I)){0==G?v/=I:(D=K[G-1],v=G+(v-D)/(I-D));break}this.addCurvePosition(.1*v,N,A,T,S,F,k,C,w,_,y,s||l>0&&0==M)}return _},i.addBeforePosition=function(t,i,e,a,s){var r=i[e],n=i[e+1],h=i[e+2]-r,l=i[e+3]-n,o=Math.atan2(l,h);a[s]=r+t*Math.cos(o),a[s+1]=n+t*Math.sin(o),a[s+2]=o},i.addAfterPosition=function(t,i,e,a,s){var r=i[e+2],n=i[e+3],h=r-i[e],l=n-i[e+1],o=Math.atan2(l,h);a[s]=r+t*Math.cos(o),a[s+1]=n+t*Math.sin(o),a[s+2]=o},i.addCurvePosition=function(t,i,e,a,s,r,n,h,l,o,u,c){0==t&&(t=1e-4);var p=t*t,_=p*t,d=1-t,f=d*d,m=f*d,x=d*t,y=3*x,g=d*y,v=y*t,M=i*m+a*g+r*v+h*_,D=e*m+s*g+n*v+l*_;o[u]=M,o[u+1]=D,c?o[u+2]=Math.atan2(D-(e*f+s*x*2+n*p),M-(i*f+a*x*2+r*p)):o[u+2]=0},t.NONE=-1,t.BEFORE=-2,t.AFTER=-3,t}(),P=function(){function t(){this.name=null,this.target=null,this.positionMode=null,this.spacingMode=null,this.rotateMode=null,this.offsetRotation=NaN,this.position=NaN,this.spacing=NaN,this.rotateMix=NaN,this.translateMix=NaN,this.bones=[]}return s(t,"laya.ani.bone.PathConstraintData"),t}(),L=function(){function t(){this.name=null,this.slotArr=[]}return s(t,"laya.ani.bone.SkinData"),t}(),B=function(){function t(){this.name=null,this.attachmentName=null,this.type=0,this.transform=null,this.width=NaN,this.height=NaN,this.texture=null,this.bones=null,this.uvs=null,this.weights=null,this.triangles=null,this.vertices=null,this.lengths=null,this.verLen=0}s(t,"laya.ani.bone.SkinSlotDisplayData");var i=t.prototype;return i.createTexture=function(t){return this.texture?this.texture:(this.texture=new M(t.bitmap,this.uvs),this.uvs[0]>this.uvs[4]&&this.uvs[1]>this.uvs[5]?(this.texture.width=t.height,this.texture.height=t.width,this.texture.offsetX=-t.offsetX,this.texture.offsetY=-t.offsetY,this.texture.sourceWidth=t.sourceHeight,this.texture.sourceHeight=t.sourceWidth):(this.texture.width=t.width,this.texture.height=t.height,this.texture.offsetX=-t.offsetX,this.texture.offsetY=-t.offsetY,this.texture.sourceWidth=t.sourceWidth,this.texture.sourceHeight=t.sourceHeight),this.texture)},i.destory=function(){this.texture&&this.texture.destroy()},t}(),U=function(){function t(){this.name=null,this.displayArr=[]}s(t,"laya.ani.bone.SlotData");var i=t.prototype;return i.getDisplayByName=function(t){for(var i,e=0,a=this.displayArr.length;a>e;e++)if(i=this.displayArr[e],i.attachmentName==t)return e;return-1},t}(),R=function(){function t(t,i){this._data=null,this._bones=null,this.target=null,this.rotateMix=NaN,this.translateMix=NaN,this.scaleMix=NaN,this.shearMix=NaN,this._temp=n(2,0),this._data=t,null==this._bones&&(this._bones=[]),this.target=i[t.targetIndex];var e=0,a=0;for(e=0,a=t.boneIndexs.length;a>e;e++)this._bones.push(i[t.boneIndexs[e]]);this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix}s(t,"laya.ani.bone.TfConstraint");var i=t.prototype;return i.apply=function(){for(var t,i=this.target.resultMatrix.a,e=this.target.resultMatrix.b,a=this.target.resultMatrix.c,s=this.target.resultMatrix.d,r=0,n=this._bones.length;n>r;r++){if(t=this._bones[r],this.rotateMix>0){var h=t.resultMatrix.a,l=t.resultMatrix.b,o=t.resultMatrix.c,u=t.resultMatrix.d,c=Math.atan2(a,i)-Math.atan2(o,h)+this._data.offsetRotation*Math.PI/180;c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),c*=this.rotateMix;var p=Math.cos(c),_=Math.sin(c);t.resultMatrix.a=p*h-_*o,t.resultMatrix.b=p*l-_*u,t.resultMatrix.c=_*h+p*o,t.resultMatrix.d=_*l+p*u}if(this.translateMix&&(this._temp[0]=this._data.offsetX,this._temp[1]=this._data.offsetY,this.target.localToWorld(this._temp),t.resultMatrix.tx+=(this._temp[0]-t.resultMatrix.tx)*this.translateMix,t.resultMatrix.ty+=(this._temp[1]-t.resultMatrix.ty)*this.translateMix,t.updateChild()),this.scaleMix>0){var d=Math.sqrt(t.resultMatrix.a*t.resultMatrix.a+t.resultMatrix.c*t.resultMatrix.c),f=Math.sqrt(i*i+a*a),m=d>1e-5?(d+(f-d+this._data.offsetScaleX)*this.scaleMix)/d:0;t.resultMatrix.a*=m,t.resultMatrix.c*=m,d=Math.sqrt(t.resultMatrix.b*t.resultMatrix.b+t.resultMatrix.d*t.resultMatrix.d),f=Math.sqrt(e*e+s*s),m=d>1e-5?(d+(f-d+this._data.offsetScaleY)*this.scaleMix)/d:0,t.resultMatrix.b*=m,t.resultMatrix.d*=m}if(this.shearMix>0){l=t.resultMatrix.b,u=t.resultMatrix.d;var x=Math.atan2(u,l);c=Math.atan2(s,e)-Math.atan2(a,i)-(x-Math.atan2(t.resultMatrix.c,t.resultMatrix.a)),c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),c=x+(c+this._data.offsetShearY*Math.PI/180)*this.shearMix,m=Math.sqrt(l*l+u*u),t.resultMatrix.b=Math.cos(c)*m,t.resultMatrix.d=Math.sin(c)*m}}},t}(),O=function(){function t(){this.name=null,this.targetIndex=0,this.rotateMix=NaN,this.translateMix=NaN,this.scaleMix=NaN,this.shearMix=NaN,this.offsetRotation=NaN,this.offsetX=NaN,this.offsetY=NaN,this.offsetScaleX=NaN,this.offsetScaleY=NaN,this.offsetShearY=NaN,this.boneIndexs=[]}return s(t,"laya.ani.bone.TfConstraintData"),t}(),E=function(){function t(){this.skX=0,this.skY=0,this.scX=1,this.scY=1,this.x=0,this.y=0,this.mMatrix=null}s(t,"laya.ani.bone.Transform");var i=t.prototype;return i.initData=function(t){void 0!=t.x&&(this.x=t.x),void 0!=t.y&&(this.y=t.y),void 0!=t.skX&&(this.skX=t.skX),void 0!=t.skY&&(this.skY=t.skY),void 0!=t.scX&&(this.scX=t.scX),void 0!=t.scY&&(this.scY=t.scY)},i.getMatrix=function(){var t;if(t=this.mMatrix?this.mMatrix:this.mMatrix=new f,t.a=Math.cos(this.skY),0!=this.skX||0!=this.skY){var i=this.skX*Math.PI/180,e=Math.cos(i),a=Math.sin(i);t.setTo(this.scX*e,this.scX*a,this.scY*-a,this.scY*e,this.x,this.y)}else t.setTo(this.scX,this.skX,this.skY,this.scY,this.x,this.y);return t},t}(),Y=function(t){function i(){this._templet=null,this._currentTime=NaN,this._currentFrameTime=NaN,this._playStart=NaN,this._playEnd=NaN,this._playDuration=NaN,this._overallDuration=NaN,this._stopWhenCircleFinish=!1,this._elapsedPlaybackTime=NaN,this._startUpdateLoopCount=NaN,this._currentAnimationClipIndex=0,this._currentKeyframeIndex=0,this._paused=!1,this._cacheFrameRate=0,this._cacheFrameRateInterval=NaN,this._cachePlayRate=NaN,this._fullFrames=null,this.isCache=!0,this.playbackRate=1,this.returnToZeroStopped=!0,i.__super.call(this),this._currentAnimationClipIndex=-1,this._currentKeyframeIndex=-1,this._currentTime=0,this._overallDuration=Number.MAX_VALUE,this._stopWhenCircleFinish=!1,this._elapsedPlaybackTime=0,this._startUpdateLoopCount=-1,this._cachePlayRate=1,this.cacheFrameRate=60}s(i,"laya.ani.AnimationPlayer",t);var e=i.prototype;return e._onTempletLoadedComputeFullKeyframeIndices=function(t,i,e){this._templet===e&&this._cachePlayRate===t&&this._cacheFrameRate===i&&this._computeFullKeyframeIndices()},e._computeFullKeyframeIndices=function(){for(var t=this._fullFrames=[],i=this._templet,e=this._cacheFrameRateInterval*this._cachePlayRate,a=0,s=i.getAnimationCount();s>a;a++){for(var r=[],n=0,h=i.getAnimation(a).nodes.length;h>n;n++){for(var l=i.getAnimation(a).nodes[n],u=Math.floor(l.playTime/e),c=new Uint16Array(u+1),p=-1,_=0,d=l.keyFrame.length;d>_;_++){var f=l.keyFrame[_],m=f.startTime,x=m+f.duration+e;do{for(var y=Math.floor(m/e+.5),g=p+1;y>g;g++)c[g]=_;p=y,c[y]=_,m+=e}while(x>=m)}r.push(c)}t.push(r)}this.event(o.CACHEFRAMEINDEX_CHANGED,this)},e._calculatePlayDuration=function(){if(0!==this.state){var t=this._templet.getAniDuration(this._currentAnimationClipIndex);0===this._playEnd&&(this._playEnd=t),Math.floor(this._playEnd)>t&&(this._playEnd=t),this._playDuration=this._playEnd-this._playStart}},e.play=function(t,i,e,a,s){if(void 0===t&&(t=0),void 0===i&&(i=1),void 0===e&&(e=2147483647),void 0===a&&(a=0),void 0===s&&(s=0),!this._templet)throw new Error("AnimationPlayer:templet must not be null,maybe you need to set url.");if(0>e||0>a||0>s)throw new Error("AnimationPlayer:overallDuration,playStart and playEnd must large than zero.");if(0!==s&&a>s)throw new Error("AnimationPlayer:start must less than end.");this._currentTime=0,this._currentFrameTime=0,this._elapsedPlaybackTime=0,this.playbackRate=i,this._overallDuration=e,this._playStart=a,this._playEnd=s,this._paused=!1,this._currentAnimationClipIndex=t,this._currentKeyframeIndex=0,this._startUpdateLoopCount=v.loopCount,this.event("played"),this._templet.loaded?this._calculatePlayDuration():this._templet.once("loaded",this,this._calculatePlayDuration),this.update(0)},e.playByFrame=function(t,i,e,a,s,r){void 0===t&&(t=0),void 0===i&&(i=1),void 0===e&&(e=9007199254740991),void 0===a&&(a=0),void 0===s&&(s=0),void 0===r&&(r=30);var n=1e3/r;this.play(t,i,e,a*n,s*n)},e.stop=function(t){void 0===t&&(t=!0),t?(this._currentAnimationClipIndex=this._currentKeyframeIndex=-1,this.event("stopped")):this._stopWhenCircleFinish=!0},e.update=function(t){if(-1!==this._currentAnimationClipIndex&&!this._paused&&this._templet&&this._templet.loaded){var i=this._cacheFrameRateInterval*this._cachePlayRate,e=0;this._startUpdateLoopCount!==v.loopCount&&(e=t*this.playbackRate,this._elapsedPlaybackTime+=e);var a=this.playDuration;if(0!==this._overallDuration&&this._elapsedPlaybackTime>=this._overallDuration||0===this._overallDuration&&this._elapsedPlaybackTime>=a)return this._currentAnimationClipIndex=this._currentKeyframeIndex=-1,void this.event("stopped");if(e+=this._currentTime,a>0){for(;e>=a;){if(this._stopWhenCircleFinish)return this._currentAnimationClipIndex=this._currentKeyframeIndex=-1,this._stopWhenCircleFinish=!1,void this.event("stopped");e-=a,this.event("complete")}this._currentTime=e,this._currentKeyframeIndex=Math.floor(this.currentPlayTime/i),this._currentFrameTime=this._currentKeyframeIndex*i}else{if(this._stopWhenCircleFinish)return this._currentAnimationClipIndex=this._currentKeyframeIndex=-1,this._stopWhenCircleFinish=!1,void this.event("stopped");this._currentTime=this._currentFrameTime=this._currentKeyframeIndex=0,this.event("complete")}}},r(0,e,"playEnd",function(){return this._playEnd}),r(0,e,"templet",function(){return this._templet},function(t){0===!this.state&&this.stop(!0),this._templet!==t&&(this._templet=t,t.loaded?this._computeFullKeyframeIndices():t.once("loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[this._cachePlayRate,this._cacheFrameRate]))}),r(0,e,"playStart",function(){return this._playStart}),r(0,e,"playDuration",function(){return this._playDuration}),r(0,e,"state",function(){return-1===this._currentAnimationClipIndex?0:this._paused?1:2}),r(0,e,"currentKeyframeIndex",function(){return this._currentKeyframeIndex}),r(0,e,"overallDuration",function(){return this._overallDuration}),r(0,e,"currentFrameTime",function(){return this._currentFrameTime}),r(0,e,"currentAnimationClipIndex",function(){return this._currentAnimationClipIndex}),r(0,e,"currentPlayTime",function(){return this._currentTime+this._playStart}),r(0,e,"cachePlayRate",function(){return this._cachePlayRate},function(t){this._cachePlayRate!==t&&(this._cachePlayRate=t,this._templet&&(this._templet.loaded?this._computeFullKeyframeIndices():this._templet.once("loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[t,this._cacheFrameRate])))}),r(0,e,"cacheFrameRate",function(){return this._cacheFrameRate},function(t){this._cacheFrameRate!==t&&(this._cacheFrameRate=t,this._cacheFrameRateInterval=1e3/this._cacheFrameRate,this._templet&&(this._templet.loaded?this._computeFullKeyframeIndices():this._templet.once("loaded",this,this._onTempletLoadedComputeFullKeyframeIndices,[this._cachePlayRate,t])))}),r(0,e,"currentTime",null,function(t){if(-1!==this._currentAnimationClipIndex&&this._templet&&this._templet.loaded){if(tthis._playEnd)throw new Error("AnimationPlayer:value must large than playStartTime,small than playEndTime.");this._startUpdateLoopCount=v.loopCount;var i=this._cacheFrameRateInterval*this._cachePlayRate;this._currentTime=t,this._currentKeyframeIndex=Math.floor(this.currentPlayTime/i),this._currentFrameTime=this._currentKeyframeIndex*i}}),r(0,e,"paused",function(){return this._paused},function(t){this._paused=t,t&&this.event("paused")}),r(0,e,"cacheFrameRateInterval",function(){return this._cacheFrameRateInterval}),i}(u),X=function(t){function i(){i.__super.call(this),m.isConchNode&&(this.drawSkin=function(t){t.transform||(t.transform=f.EMPTY),this.setSkinMesh&&this.setSkinMesh(t._ps,t.mVBData,t.mEleNum,0,t.mTexture,t.transform)})}s(i,"laya.ani.GraphicsAni",t);var e=i.prototype;return e.drawSkin=function(t){var i=[t];this._saveToCmd(m._context._drawSkin,i)},i}(c),K=function(t){function i(){this._aniMap={},this.unfixedLastAniIndex=-1,i.__super.call(this),this._anis=new Array}s(i,"laya.ani.AnimationTemplet",t);var a=i.prototype;return a._endLoaded=function(){this._loaded=!0,this.event("loaded",this)},a.parse=function(t){var e=0,a=0,s=0,r=0,n=0,h=new l(t);this._aniVersion=h.readUTFString();var o,u=(h.readUTFString(),h.readUTFString().split("\n")),c=h.getUint8(),p=h.getUint32(),_=h.getUint32();p>0&&(o=t.slice(p,_));var d=new l(o);for(_>0&&(this._publicExtData=t.slice(_,t.byteLength)),this._useParent=!!h.getUint8(),this._anis.length=c,e=0;c>e;e++){var f=this._anis[e]={};f.nodes=new Array;var m=f.name=u[h.getUint16()];this._aniMap[m]=e,f.bone3DMap={},f.playTime=h.getFloat32();var x=f.nodes.length=h.getUint8();for(f.totalKeyframesLength=0,a=0;x>a;a++){var y=f.nodes[a]={};y.childs=[];var g=h.getInt16();g>=0&&(y.name=u[g],f.bone3DMap[y.name]=a),y.keyFrame=new Array,y.parentIndex=h.getInt16(),-1==y.parentIndex?y.parent=null:y.parent=f.nodes[y.parentIndex];var v=!!h.getUint8(),M=h.getUint32();d.pos=M;var D=y.keyframeWidth=d.getUint16();if(f.totalKeyframesLength+=D,v)for(y.interpolationMethod=[],y.interpolationMethod.length=D,s=0;D>s;s++)y.interpolationMethod[s]=i.interpolation[d.getUint8()];null!=y.parent&&y.parent.childs.push(y);var I=h.getUint16();I>0&&(y.extenData=t.slice(h.pos,h.pos+I),h.pos+=I);var b=h.getUint16();y.keyFrame.length=b;var N=0;for(s=0,r=b;r>s;s++){var A=y.keyFrame[s]={};for(A.duration=h.getFloat32(),A.startTime=N,A.data=new Float32Array(D),A.dData=new Float32Array(D),A.nextData=new Float32Array(D),n=0;D>n;n++)A.data[n]=h.getFloat32(),A.data[n]>-1e-8&&A.data[n]<1e-8&&(A.data[n]=0);N+=A.duration}y.playTime=f.playTime,this._calculateKeyFrame(y,b,D)}}},a._calculateKeyFrame=function(t,i,e){var a=t.keyFrame;a[i]=a[0];for(var s=0;i>s;s++)for(var r=a[s],n=0;e>n;n++)r.dData[n]=0===r.duration?0:(a[s+1].data[n]-r.data[n])/r.duration,r.nextData[n]=a[s+1].data[n];a.length--},a.onAsynLoaded=function(t,i){this.parse(i),this._endLoaded()},a.getAnimationCount=function(){return this._anis.length},a.getAnimation=function(t){return this._anis[t]},a.getAniDuration=function(t){return this._anis[t].playTime},a.getNodes=function(t){return this._anis[t].nodes},a.getNodeIndexWithName=function(t,i){ +return this._anis[t].bone3DMap[i]},a.getNodeCount=function(t){return this._anis[t].nodes.length},a.getTotalkeyframesLength=function(t){return this._anis[t].totalKeyframesLength},a.getPublicExtData=function(){return this._publicExtData},a.getAnimationDataWithCache=function(t,i,e,a){var s=i[e];if(s){var r=s[t];return r?r[a]:null}return null},a.setAnimationDataWithCache=function(t,i,e,a,s){var r=i[e]||(i[e]={}),n=r[t]||(r[t]=[]);n[a]=s},a.getOriginalData=function(t,i,e,a,s){for(var r=this._anis[t],n=r.nodes,h=0,l=0,o=n.length,u=0;o>l;l++){var c,p=n[l];c=p.keyFrame[e[l][a]],p.dataOffset=u;var _=s-c.startTime;for(h=0;hs;s++){var n=a[s];for(ithis.unfixedCurrentTimes[s]);)this.unfixedCurrentFrameIndexes[s]++;this.unfixedCurrentFrameIndexes[s]--}return this.unfixedCurrentFrameIndexes},a.getOriginalDataUnfixedRate=function(t,i,e){var a=this._anis[t],s=a.nodes;t!==this.unfixedLastAniIndex&&(this.unfixedCurrentFrameIndexes=new Uint32Array(s.length),this.unfixedCurrentTimes=new Float32Array(s.length),this.unfixedKeyframes=n(s.length),this.unfixedLastAniIndex=t);for(var r=0,h=0,l=s.length,o=0;l>h;h++){var u=s[h];for(ethis.unfixedCurrentTimes[h]);)this.unfixedKeyframes[h]=u.keyFrame[this.unfixedCurrentFrameIndexes[h]],this.unfixedCurrentFrameIndexes[h]++;var c=this.unfixedKeyframes[h];u.dataOffset=o;var p=e-c.startTime;for(r=0;ro;o++,i++)e[a+o]=s[i]+r*n[i];return 16},i._NoInterpolation_5=function(t,i,e,a,s,r,n,h,l){return e[a]=s[i],1},i.load=function(t){return e.loader.create(t,null,null,i)},i.interpolation=[i._LinearInterpolation_0,i._QuaternionInterpolation_1,i._AngleInterpolation_2,i._RadiansInterpolation_3,i._Matrix4x4Interpolation_4,i._NoInterpolation_5],i.LAYA_ANIMATION_VISION="LAYAANIMATION:1.0.6",i}(x),W=function(t){function i(t,e){this._templet=null,this._player=null,this._curOriginalData=null,this._boneMatrixArray=[],this._lastTime=0,this._currAniName=null,this._currAniIndex=-1,this._pause=!0,this._aniClipIndex=-1,this._clipIndex=-1,this._skinIndex=0,this._skinName="default",this._aniMode=0,this._graphicsCache=null,this._boneSlotDic=null,this._bindBoneBoneSlotDic=null,this._boneSlotArray=null,this._index=-1,this._total=-1,this._indexControl=!1,this._aniPath=null,this._texturePath=null,this._complete=null,this._loadAniMode=0,this._yReverseMatrix=null,this._ikArr=null,this._tfArr=null,this._pathDic=null,this._rootBone=null,this._boneList=null,this._aniSectionDic=null,this._eventIndex=0,this._drawOrderIndex=0,this._drawOrder=null,this._lastAniClipIndex=-1,i.__super.call(this),void 0===e&&(e=0),t&&this.init(t,e)}s(i,"laya.ani.bone.Skeleton",t);var a=i.prototype;return a.init=function(t,i){void 0===i&&(i=0);var e=0,a=0;if(1==i)for(this._graphicsCache=[],e=0,a=t.getAnimationCount();a>e;e++)this._graphicsCache.push([]);if(this._yReverseMatrix=t.yReverseMatrix,this._aniMode=i,this._templet=t,this._player=new Y,this._player.cacheFrameRate=t.rate,this._player.templet=t,this._player.play(),this._parseSrcBoneMatrix(),this._boneList=t.mBoneArr,this._rootBone=t.mRootBone,this._aniSectionDic=t.aniSectionDic,t.ikArr.length>0)for(this._ikArr=[],e=0,a=t.ikArr.length;a>e;e++)this._ikArr.push(new k(t.ikArr[e],this._boneList));if(t.pathArr.length>0){var s,r;null==this._pathDic&&(this._pathDic={});var n;for(e=0,a=t.pathArr.length;a>e;e++)s=t.pathArr[e],r=new w(s,this._boneList),n=this._boneSlotDic[s.name],n&&(r=new w(s,this._boneList),r.target=n),this._pathDic[s.name]=r}if(t.tfArr.length>0)for(this._tfArr=[],e=0,a=t.tfArr.length;a>e;e++)this._tfArr.push(new R(t.tfArr[e],this._boneList));if(t.skinDataArray.length>0){var h=this._templet.skinDataArray[this._skinIndex];this._skinName=h.name}this._player.on("played",this,this._onPlay),this._player.on("stopped",this,this._onStop),this._player.on("paused",this,this._onPause)},a.load=function(t,i,a){void 0===a&&(a=0),this._aniPath=t,this._complete=i,this._loadAniMode=a,this._texturePath=t.replace(".sk",".png").replace(".bin",".png"),e.loader.load([{url:t,type:"arraybuffer"},{url:this._texturePath,type:"image"}],p.create(this,this._onLoaded))},a._onLoaded=function(){var t=_.getRes(this._texturePath),i=_.getRes(this._aniPath);if(null!=t&&null!=i){null==G.TEMPLET_DICTIONARY&&(G.TEMPLET_DICTIONARY={});var e;e=G.TEMPLET_DICTIONARY[this._aniPath],e?e.isParseFail?this._parseFail():this._parseComplete():(e=new G,e.url=this._aniPath,G.TEMPLET_DICTIONARY[this._aniPath]=e,e.on("complete",this,this._parseComplete),e.on("error",this,this._parseFail),e.parseData(t,i,60))}},a._parseComplete=function(){var t=G.TEMPLET_DICTIONARY[this._aniPath];t&&(this.init(t,this._loadAniMode),this.play(0,!0)),this._complete&&this._complete.runWith(this)},a._parseFail=function(){console.log("[Error]:"+this._aniPath+"解析失败")},a._onPlay=function(){this.event("played")},a._onStop=function(){var t,i=this._templet.eventAniArr,e=i[this._aniClipIndex];if(e&&this._eventIndex=this._player.playStart&&t.time<=this._player.playEnd&&this.event("label",t);this._eventIndex=0,this._drawOrder=null,this.event("stopped")},a._onPause=function(){this.event("paused")},a._parseSrcBoneMatrix=function(){var t=0,i=0;for(i=this._templet.srcBoneMatrixArr.length,t=0;i>t;t++)this._boneMatrixArray.push(new f);if(0==this._aniMode)this._boneSlotDic=this._templet.boneSlotDic,this._bindBoneBoneSlotDic=this._templet.bindBoneBoneSlotDic,this._boneSlotArray=this._templet.boneSlotArray;else{null==this._boneSlotDic&&(this._boneSlotDic={}),null==this._bindBoneBoneSlotDic&&(this._bindBoneBoneSlotDic={}),null==this._boneSlotArray&&(this._boneSlotArray=[]);var e,a,s=this._templet.boneSlotArray;for(t=0,i=s.length;i>t;t++)e=s[t],a=this._bindBoneBoneSlotDic[e.parent],null==a&&(this._bindBoneBoneSlotDic[e.parent]=a=[]),this._boneSlotDic[e.name]=e=e.copy(),a.push(e),this._boneSlotArray.push(e)}},a._update=function(t){if(void 0===t&&(t=!0),!(this._pause||t&&this._indexControl)){var i=e.timer.currTimer;t&&this._player.update(i-this._lastTime),this._lastTime=i,this._aniClipIndex=this._player.currentAnimationClipIndex,this._clipIndex=this._player.currentKeyframeIndex;var a,s=this._templet.eventAniArr,r=s[this._aniClipIndex];if(r&&this._eventIndex=this._player.playStart&&a.time<=this._player.playEnd?this._player.currentPlayTime>=a.time&&(this.event("label",a),this._eventIndex++):this._eventIndex++),-1!=this._aniClipIndex){var n;if(0==this._aniMode){if(n=this._templet.getGrahicsDataWithCache(this._aniClipIndex,this._clipIndex))return void(this.graphics!=n&&(this.graphics=n))}else if(1==this._aniMode&&(n=this._getGrahicsDataWithCache(this._aniClipIndex,this._clipIndex)))return void(this.graphics!=n&&(this.graphics=n));this._createGraphics()}}},a._createGraphics=function(){var t,i=this._templet.drawOrderAniArr,e=i[this._aniClipIndex];if(e&&e.length>0)for(this._drawOrderIndex=0,t=e[this._drawOrderIndex];this._player.currentPlayTime>=t.time&&(this._drawOrder=t.drawOrder,this._drawOrderIndex++,!(this._drawOrderIndex>=e.length));)t=e[this._drawOrderIndex];var a;0==this._aniMode||1==this._aniMode?this.graphics=new X:this.graphics instanceof laya.ani.GraphicsAni?this.graphics.clear():this.graphics=new X,a=this.graphics;var s=this._templet.getNodes(this._aniClipIndex);this._templet.getOriginalData(this._aniClipIndex,this._curOriginalData,this._player._fullFrames[this._aniClipIndex],this._clipIndex,this._player.currentFrameTime);var r,n,h,o,u=this._aniSectionDic[this._aniClipIndex],c=0,p=0,_=0,d=0,m=0,x=this._templet.srcBoneMatrixArr.length;for(p=0,m=u[0];x>p;p++)o=this._boneList[p],h=this._templet.srcBoneMatrixArr[p],o.resultTransform.scX=h.scX*this._curOriginalData[c++],o.resultTransform.skX=h.skX+this._curOriginalData[c++],o.resultTransform.skY=h.skY+this._curOriginalData[c++],o.resultTransform.scY=h.scY*this._curOriginalData[c++],o.resultTransform.x=h.x+this._curOriginalData[c++],o.resultTransform.y=h.y+this._curOriginalData[c++];var y,g={},v={};for(m+=u[1];m>p;p++)y=s[p],g[y.name]=this._curOriginalData[c++],v[y.name]=this._curOriginalData[c++],this._curOriginalData[c++],this._curOriginalData[c++],this._curOriginalData[c++],this._curOriginalData[c++];var M={},D={};for(m+=u[2];m>p;p++)y=s[p],M[y.name]=this._curOriginalData[c++],D[y.name]=this._curOriginalData[c++],this._curOriginalData[c++],this._curOriginalData[c++],this._curOriginalData[c++];if(this._pathDic){var I;for(m+=u[3];m>p;p++)if(y=s[p],I=this._pathDic[y.name]){var b=new l(y.extenData);switch(b.getByte()){case 1:I.position=this._curOriginalData[c++];break;case 2:I.spacing=this._curOriginalData[c++];break;case 3:I.rotateMix=this._curOriginalData[c++],I.translateMix=this._curOriginalData[c++]}}}if(this._yReverseMatrix?this._rootBone.update(this._yReverseMatrix):this._rootBone.update(f.TEMP.identity()),this._ikArr){var N;for(p=0,m=this._ikArr.length;m>p;p++)N=this._ikArr[p],M.hasOwnProperty(N.name)&&(N.bendDirection=M[N.name]),D.hasOwnProperty(N.name)&&(N.mix=D[N.name]),N.apply()}if(this._pathDic)for(var A in this._pathDic)I=this._pathDic[A],I.apply(this._boneList,a);if(this._tfArr){var T;for(p=0,d=this._tfArr.length;d>p;p++)T=this._tfArr[p],T.apply()}for(p=0,d=this._boneList.length;d>p;p++)if(o=this._boneList[p],n=this._bindBoneBoneSlotDic[o.name],o.resultMatrix.copyTo(this._boneMatrixArray[p]),n)for(_=0,m=n.length;m>_;_++)r=n[_],r&&r.setParentMatrix(o.resultMatrix);var S,F,k,C={},w=this._templet.deformAniArr;if(w&&w.length>0){if(this._lastAniClipIndex!=this._aniClipIndex)for(this._lastAniClipIndex=this._aniClipIndex,p=0,m=this._boneSlotArray.length;m>p;p++)r=this._boneSlotArray[p],r.deformData=null;var P=w[this._aniClipIndex];if(S=P["default"])for(p=0,m=S.deformSlotDataList.length;m>p;p++)for(F=S.deformSlotDataList[p],_=0;_p;p++)for(F=S.deformSlotDataList[p],_=0;_p;p++)r=this._boneSlotArray[this._drawOrder[p]],L=g[r.name],B=v[r.name],isNaN(B)||(a.save(),a.alpha(B)),isNaN(L)||(this._templet.attachmentNames?r.showDisplayByName(this._templet.attachmentNames[L]):r.showDisplayByIndex(L)),C[this._drawOrder[p]]?(U=C[this._drawOrder[p]],r.currDisplayData&&U[r.currDisplayData.attachmentName]?r.deformData=U[r.currDisplayData.attachmentName]:r.deformData=null):r.deformData=null,isNaN(B)?r.draw(a,this._boneMatrixArray,2==this._aniMode):r.draw(a,this._boneMatrixArray,2==this._aniMode,B),isNaN(B)||a.restore();else for(p=0,m=this._boneSlotArray.length;m>p;p++)r=this._boneSlotArray[p],L=g[r.name],B=v[r.name],isNaN(B)||(a.save(),a.alpha(B)),isNaN(L)||(this._templet.attachmentNames?r.showDisplayByName(this._templet.attachmentNames[L]):r.showDisplayByIndex(L)),C[p]?(U=C[p],r.currDisplayData&&U[r.currDisplayData.attachmentName]?r.deformData=U[r.currDisplayData.attachmentName]:r.deformData=null):r.deformData=null,isNaN(B)?r.draw(a,this._boneMatrixArray,2==this._aniMode):r.draw(a,this._boneMatrixArray,2==this._aniMode,B),isNaN(B)||a.restore();0==this._aniMode?this._templet.setGrahicsDataWithCache(this._aniClipIndex,this._clipIndex,a):1==this._aniMode&&this._setGrahicsDataWithCache(this._aniClipIndex,this._clipIndex,a)},a.getAnimNum=function(){return this._templet.getAnimationCount()},a.getAniNameByIndex=function(t){return this._templet.getAniNameByIndex(t)},a.getSlotByName=function(t){return this._boneSlotDic[t]},a.showSkinByName=function(t){this.showSkinByIndex(this._templet.getSkinIndexByName(t))},a.showSkinByIndex=function(t){for(var i=0;it;t++)this._graphicsCache[t].length=0},a.play=function(t,i,a,s,r){void 0===a&&(a=!0),void 0===s&&(s=0),void 0===r&&(r=0),this._indexControl=!1;var n=-1,l=NaN;if(l=i?2147483647:0,"string"==typeof t)for(var o=0,u=this._templet.getAnimationCount();u>o;o++){var c=this._templet.getAnimation(o);if(c&&t==c.name){n=o;break}}else n=t;n>-1&&nt;t++)this._movieClipList[t]&&this._movieClipList[t]._update()}},a.addLabel=function(t,i){this._labels||(this._labels={}),this._labels[i]=t},a.removeLabel=function(t){if(t){if(!this._labels)for(var i in this._labels)if(this._labels[i]===t){delete this._labels[i];break}}else this._labels=null},a._update=function(){if(this._data&&this._playing){if(this._playIndex++,this._playIndex>=this._count){if(!this.loop)return this._playIndex--,void this.stop();this._playIndex=0}this._parse(this._playIndex),this._labels&&this._labels[this._playIndex]&&this.event("label",this._labels[this._playIndex])}},a.stop=function(){this._playing=!1},a.gotoAndStop=function(t){this.index=t,this.stop()},a._clear=function(){if(this.stop(),this._idOfSprite.length=0,!this._parentMovieClip){e.timer.clear(this,this.updates);var t=0,i=0;for(i=this._movieClipList.length,t=0;i>t;t++)this._movieClipList[t]!=this&&this._movieClipList[t]._clear();this._movieClipList.length=0}var a;for(a in this._loadedImage)this._loadedImage[a]&&(_.clearRes(a),this._loadedImage[a]=!1);this.removeChildren(),this.graphics=null,this._parentMovieClip=null},a.play=function(t,i){void 0===t&&(t=0),void 0===i&&(i=!0),this.loop=i,this._playing=!0,this._data&&this._displayFrame(t)},a._displayFrame=function(t){void 0===t&&(t=-1),-1!=t&&(this._curIndex>t&&this._reset(),this._parse(t))},a._reset=function(t){void 0===t&&(t=!0),t&&1!=this._curIndex&&this.removeChildren(),this._preIndex=this._curIndex=-1,this._Pos=this._start},a._parse=function(t){var e,a,s,r=0,n=0,h=0,l=0,o=!1,u=this._idOfSprite,c=this._data;for(this._ended&&this._reset(),c.pos=this._Pos,this._ended=!1,this._playIndex=t,this._curIndex>t&&t0;break;case 7:a=u[c.getUint16()];var m=a.transform||f.create();m.setTo(c.getFloat32(),c.getFloat32(),c.getFloat32(),c.getFloat32(),c.getFloat32(),c.getFloat32()),a.transform=m;break;case 8:u[c.getUint16()].setPos(c.getFloat32(),c.getFloat32());break;case 9:u[c.getUint16()].setSize(c.getFloat32(),c.getFloat32());break;case 10:u[c.getUint16()].alpha=c.getFloat32();break;case 11:u[c.getUint16()].setScale(c.getFloat32(),c.getFloat32());break;case 98:s=c.getString(),this.event(s),"stop"==s&&this.stop();break;case 99:this._curIndex=c.getUint16(),o&&this.updateZOrder();break;case 100:this._count=this._curIndex+1,this._ended=!0,this._playing&&(this.event("enterframe"),this.event("end"),this.event("complete")),this._reset(!1)}this._playing&&!this._ended&&this.event("enterframe"),this._Pos=c.pos},a._setData=function(t,i){this._data=t,this._start=i+3},a.load=function(t,i,a){void 0===i&&(i=!1),this._url=t=D.formatURL(t),i&&(this._atlasPath=a?a:t.split(".swf")[0]+".json"),this.stop(),this._clear(),this._movieClipList=[this];var s;s=[{url:t,type:"arraybuffer"}],this._atlasPath&&s.push({url:this._atlasPath,type:"atlas"}),e.loader.load(s,p.create(this,this._onLoaded))},a._onLoaded=function(){this.basePath=this._atlasPath?_.getAtlas(this._atlasPath).dir:this._url.split(".swf")[0]+"/image/";var t;t=_.getRes(this._url),t&&this._initData(t)},a._initState=function(){this._reset(),this._ended=!1;var t=this._playing;for(this._playing=!1,this._curIndex=0;!this._ended;)this._parse(++this._curIndex);this._playing=t},a._initData=function(t){this._data=new l(t);var i=0,a=this._data.getUint16();for(i=0;a>i;i++)this._ids[this._data.getInt16()]=this._data.getInt32();this.interval=1e3/this._data.getUint16(),this._setData(this._data,this._ids[32767]),this._initState(),this.play(0),this.event("loaded"),this._parentMovieClip||e.timer.loop(this.interval,this,this.updates,null,!0)},r(0,a,"index",function(){return this._playIndex},function(t){this._playIndex=t,this._data&&this._displayFrame(this._playIndex),this._labels&&this._labels[t]&&this.event("label",this._labels[t])}),r(0,a,"count",function(){return this._count}),r(0,a,"playing",function(){return this._playing}),r(0,a,"url",null,function(t){this.load(t)}),i._ValueList=["x","y","width","height","scaleX","scaleY","rotation","alpha"],i}(g),function(t){function i(){this._mainTexture=null,this._textureJson=null,this._graphicsCache=[],this.srcBoneMatrixArr=[],this.ikArr=[],this.tfArr=[],this.pathArr=[],this.boneSlotDic={},this.bindBoneBoneSlotDic={},this.boneSlotArray=[],this.skinDataArray=[],this.skinDic={},this.subTextureDic={},this.isParseFail=!1,this.url=null,this.yReverseMatrix=null,this.drawOrderAniArr=[],this.eventAniArr=[],this.attachmentNames=null,this.deformAniArr=[],this._rate=60,this.aniSectionDic={},this._skBufferUrl=null,this._textureDic={},this._loadList=null,this._path=null,this.mRootBone=null,i.__super.call(this),this.skinSlotDisplayDataArr=[],this.mBoneArr=[]}s(i,"laya.ani.bone.Templet",t);var a=i.prototype;return a.loadAni=function(t){this._skBufferUrl=t,e.loader.load(t,p.create(this,this.onComplete),null,"arraybuffer")},a.onComplete=function(t){var i=_.getRes(this._skBufferUrl);this._path=this._skBufferUrl.slice(0,this._skBufferUrl.lastIndexOf("/"))+"/",this.parseData(null,i)},a.parseData=function(t,i,e){void 0===e&&(e=60),this._mainTexture=t,this._mainTexture&&m.isWebGL&&t.bitmap&&(t.bitmap.enableMerageInAtlas=!1),this._rate=e,this.parse(i)},a.buildArmature=function(t){return void 0===t&&(t=0),new W(this,t)},a.parse=function(i){t.prototype.parse.call(this,i),this._endLoaded(),this._aniVersion!=K.LAYA_ANIMATION_VISION&&(console.log("[Error] 版本不一致,请使用IDE版本(1.5.3)重新导出"),this._loaded=!1),this._loaded?this._mainTexture?this._parsePublicExtData():this._parseTexturePath():(this.event("error",this),this.isParseFail=!0)},a._parseTexturePath=function(){var t=0;this._loadList=[];var i,a=new l(this.getPublicExtData()),s=0,r=0,n=0,h=0,o=0,u=0,c=0,_=0,d=0,f=a.getUint8(),m=a.readUTFString(),x=m.split("\n");for(t=0;f>t;t++)i=this._path+x[2*t],m=x[2*t+1],s=a.getFloat32(),r=a.getFloat32(),n=a.getFloat32(),h=a.getFloat32(),d=a.getFloat32(),o=isNaN(d)?0:d,d=a.getFloat32(),u=isNaN(d)?0:d,d=a.getFloat32(),c=isNaN(d)?n:d,d=a.getFloat32(),_=isNaN(d)?h:d,-1==this._loadList.indexOf(i)&&this._loadList.push(i);e.loader.load(this._loadList,p.create(this,this._textureComplete))},a._textureComplete=function(){for(var t,i,e=0,a=this._loadList.length;a>e;e++)i=this._loadList[e],t=this._textureDic[i]=_.getRes(i),m.isWebGL&&t&&t.bitmap&&(t.bitmap.enableMerageInAtlas=!1);this._parsePublicExtData()},a._parsePublicExtData=function(){var t=0,i=0,e=0,a=0,s=0;for(t=0,s=this.getAnimationCount();s>t;t++)this._graphicsCache.push([]);var r,n,h=new l(this.getPublicExtData()),o=0,u=0,c=0,p=0,_=0,d=0,m=0,x=0,y=0,g=h.getUint8(),v=h.readUTFString(),D=v.split("\n");for(t=0;g>t;t++)r=this._mainTexture,n=this._path+D[2*t],v=D[2*t+1],null==this._mainTexture&&(r=this._textureDic[n]),o=h.getFloat32(),u=h.getFloat32(),c=h.getFloat32(),p=h.getFloat32(),y=h.getFloat32(),_=isNaN(y)?0:y,y=h.getFloat32(),d=isNaN(y)?0:y,y=h.getFloat32(),m=isNaN(y)?c:y,y=h.getFloat32(),x=isNaN(y)?p:y,this.subTextureDic[v]=M.create(r,o,u,c,p,-_,-d,m,x);this._mainTexture=r;var k,w=h.getUint16();for(t=0;w>t;t++)k=[],k.push(h.getUint16()),k.push(h.getUint16()),k.push(h.getUint16()),k.push(h.getUint16()),this.aniSectionDic[t]=k;var R,Y,X,K,W,G=h.getInt16(),q={};for(t=0;G>t;t++)R=new I,0==t?W=R:R.root=W,X=h.readUTFString(),K=h.readUTFString(),R.length=h.getFloat32(),1==h.getByte()&&(R.inheritRotation=!1),1==h.getByte()&&(R.inheritScale=!1),R.name=X,K&&(Y=q[K],Y?Y.addChild(R):this.mRootBone=R),q[X]=R,this.mBoneArr.push(R);var V,H=h.getUint16(),z=h.getUint16(),Q=Math.floor(z/H),Z=this.srcBoneMatrixArr;for(t=0;Q>t;t++)V=new E,V.scX=h.getFloat32(),V.skX=h.getFloat32(),V.skY=h.getFloat32(),V.scY=h.getFloat32(),V.x=h.getFloat32(),V.y=h.getFloat32(),Z.push(V),R=this.mBoneArr[t],R.transform=V;var $,j=h.getUint16(),J=0;for(t=0;j>t;t++){for($=new C,J=h.getUint16(),i=0;J>i;i++)$.boneNames.push(h.readUTFString()),$.boneIndexs.push(h.getInt16());$.name=h.readUTFString(),$.targetBoneName=h.readUTFString(),$.targetBoneIndex=h.getInt16(),$.bendDirection=h.getFloat32(),$.mix=h.getFloat32(),this.ikArr.push($)}var tt,it=h.getUint16(),et=0;for(t=0;it>t;t++){for(tt=new O,et=h.getUint16(),i=0;et>i;i++)tt.boneIndexs.push(h.getInt16());tt.name=h.getUTFString(),tt.targetIndex=h.getInt16(),tt.rotateMix=h.getFloat32(),tt.translateMix=h.getFloat32(),tt.scaleMix=h.getFloat32(),tt.shearMix=h.getFloat32(),tt.offsetRotation=h.getFloat32(),tt.offsetX=h.getFloat32(),tt.offsetY=h.getFloat32(),tt.offsetScaleX=h.getFloat32(),tt.offsetScaleY=h.getFloat32(),tt.offsetShearY=h.getFloat32(),this.tfArr.push(tt)}var at,st=h.getUint16(),rt=0;for(t=0;st>t;t++){for(at=new P,at.name=h.readUTFString(),rt=h.getUint16(),i=0;rt>i;i++)at.bones.push(h.getInt16());at.target=h.readUTFString(),at.positionMode=h.readUTFString(),at.spacingMode=h.readUTFString(),at.rotateMode=h.readUTFString(),at.offsetRotation=h.getFloat32(),at.position=h.getFloat32(),at.spacing=h.getFloat32(),at.rotateMix=h.getFloat32(),at.translateMix=h.getFloat32(),this.pathArr.push(at)}var nt,ht,lt,ot,ut,ct=0,pt=0,_t=0,dt=0,ft=NaN,mt=0,xt=h.getInt16();for(t=0;xt>t;t++){var yt=h.getUint8(),gt={};this.deformAniArr.push(gt);for(var vt=0;yt>vt;vt++)for(ht=new N,ht.skinName=h.getUTFString(),gt[ht.skinName]=ht,ct=h.getInt16(),i=0;ct>i;i++)for(lt=new A,ht.deformSlotDataList.push(lt),pt=h.getInt16(),e=0;pt>e;e++)for(ot=new T,lt.deformSlotDisplayList.push(ot),ot.slotIndex=_t=h.getInt16(),ot.attachment=nt=h.getUTFString(),dt=h.getInt16(),a=0;dt>a;a++)for(1==h.getByte()?ot.tweenKeyList.push(!0):ot.tweenKeyList.push(!1),ft=h.getFloat32(),ot.timeList.push(ft),ut=[],ot.vectices.push(ut),mt=h.getInt16(),s=0;mt>s;s++)ut.push(h.getFloat32())}var Mt,Dt,It=h.getInt16(),bt=0,Nt=0;for(t=0;It>t;t++){for(bt=h.getInt16(),Mt=[],i=0;bt>i;i++){for(Dt=new S,Dt.time=h.getFloat32(),Nt=h.getInt16(),e=0;Nt>e;e++)Dt.drawOrder.push(h.getInt16());Mt.push(Dt)}this.drawOrderAniArr.push(Mt)}var At,Tt,St=h.getInt16(),Ft=0;for(t=0;St>t;t++){for(Ft=h.getInt16(),At=[],i=0;Ft>i;i++)Tt=new F,Tt.name=h.getUTFString(),Tt.intValue=h.getInt32(),Tt.floatValue=h.getFloat32(),Tt.stringValue=h.getUTFString(),Tt.time=h.getFloat32(),At.push(Tt);this.eventAniArr.push(At)}var kt=h.getInt16();if(kt>0)for(this.attachmentNames=[],t=0;kt>t;t++)this.attachmentNames.push(h.getUTFString());var Ct,wt,Pt=h.getInt16();for(t=0;Pt>t;t++)Ct=new b,Ct.name=h.readUTFString(),Ct.parent=h.readUTFString(),Ct.attachmentName=h.readUTFString(),Ct.srcDisplayIndex=Ct.displayIndex=h.getInt16(),Ct.templet=this,this.boneSlotDic[Ct.name]=Ct,wt=this.bindBoneBoneSlotDic[Ct.parent],null==wt&&(this.bindBoneBoneSlotDic[Ct.parent]=wt=[]),wt.push(Ct),this.boneSlotArray.push(Ct);var Lt,Bt,Ut,Rt=h.readUTFString(),Ot=Rt.split("\n"),Et=0,Yt=h.getUint8(),Xt=0,Kt=0,Wt=0,Gt=0,qt=0,Vt=0,Ht=0;for(t=0;Yt>t;t++){for(Lt=new L,Lt.name=Ot[Et++],Xt=h.getUint8(),i=0;Xt>i;i++){for(Bt=new U,Bt.name=Ot[Et++],Ct=this.boneSlotDic[Bt.name],Kt=h.getUint8(),e=0;Kt>e;e++){if(Ut=new B,this.skinSlotDisplayDataArr.push(Ut),Ut.name=Ot[Et++],Ut.attachmentName=Ot[Et++],Ut.transform=new E,Ut.transform.scX=h.getFloat32(),Ut.transform.skX=h.getFloat32(),Ut.transform.skY=h.getFloat32(),Ut.transform.scY=h.getFloat32(),Ut.transform.x=h.getFloat32(),Ut.transform.y=h.getFloat32(),Bt.displayArr.push(Ut),Ut.width=h.getFloat32(),Ut.height=h.getFloat32(),Ut.type=h.getUint8(),Ut.verLen=h.getUint16(),G=h.getUint16(),G>0)for(Ut.bones=[],a=0;G>a;a++){var zt=h.getUint16();Ut.bones.push(zt)}if(Wt=h.getUint16(),Wt>0)for(Ut.uvs=[],a=0;Wt>a;a++)Ut.uvs.push(h.getFloat32());if(Gt=h.getUint16(),Gt>0)for(Ut.weights=[],a=0;Gt>a;a++)Ut.weights.push(h.getFloat32());if(qt=h.getUint16(),qt>0)for(Ut.triangles=[],a=0;qt>a;a++)Ut.triangles.push(h.getUint16());if(Vt=h.getUint16(),Vt>0)for(Ut.vertices=[],a=0;Vt>a;a++)Ut.vertices.push(h.getFloat32());if(Ht=h.getUint16(),Ht>0)for(Ut.lengths=[],a=0;Ht>a;a++)Ut.lengths.push(h.getFloat32())}Lt.slotArr.push(Bt)}this.skinDic[Lt.name]=Lt,this.skinDataArray.push(Lt)}var Qt=h.getUint8();1==Qt?(this.yReverseMatrix=new f(1,0,0,-1,0,0),W&&W.setTempMatrix(this.yReverseMatrix)):W&&W.setTempMatrix(new f),this.showSkinByIndex(this.boneSlotDic,0),this.event("complete",this)},a.getTexture=function(t){var i=this.subTextureDic[t];return null==i?this._mainTexture:i},a.showSkinByIndex=function(t,i){if(0>i&&i>=this.skinDataArray.length)return!1;var e,a,s=0,r=0,n=this.skinDataArray[i];if(n){for(s=0,r=n.slotArr.length;r>s;s++)a=n.slotArr[s],a&&(e=t[a.name],e&&(e.showSlotData(a),"undefined"!=e.attachmentName&&"null"!=e.attachmentName?e.showDisplayByName(e.attachmentName):e.showDisplayByIndex(e.displayIndex)));return!0}return!1},a.getSkinIndexByName=function(t){for(var i,e=0,a=this.skinDataArray.length;a>e;e++)if(i=this.skinDataArray[e],i.name==t)return e;return-1},a.getGrahicsDataWithCache=function(t,i){return this._graphicsCache[t][i]},a.setGrahicsDataWithCache=function(t,i,e){this._graphicsCache[t][i]=e},a.destroy=function(){var t;for(var e in this.subTextureDic)t=this.subTextureDic[e],t.destroy();var e;for(e in this._textureDic)t=this._textureDic[e],t.destroy();for(var a,s=0,r=this.skinSlotDisplayDataArr.length;r>s;s++)a=this.skinSlotDisplayDataArr[s],a.destory();this.skinSlotDisplayDataArr.length=0,this.url&&delete i.TEMPLET_DICTIONARY[this.url]},a.getAniNameByIndex=function(t){var i=this.getAnimation(t);return i?i.name:null},r(0,a,"rate",function(){return this._rate}),i.TEMPLET_DICTIONARY=null,i}(K))}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.core.min.js b/games/laya-snakes/libs/min/laya.core.min.js new file mode 100644 index 0000000..e9a5ee2 --- /dev/null +++ b/games/laya-snakes/libs/min/laya.core.min.js @@ -0,0 +1,13 @@ +var window=window||global,document=document||(window.document={}),Laya=window.Laya=function(t,e){var i={__internals:[],__packages:{},__classmap:{Object:Object,Function:Function,Array:Array,String:String},__sysClass:{object:"Object",array:"Array",string:"String",dictionary:"Dictionary"},__propun:{writable:!0,enumerable:!1,configurable:!0},__presubstr:String.prototype.substr,__substr:function(t,e){return 1==arguments.length?i.__presubstr.call(this,t):i.__presubstr.call(this,t,e>0?e:this.length+e)},__init:function(t){t.forEach(function(t){t.__init$&&t.__init$()})},__isClass:function(t){return t&&(t.__isclass||t==Object||t==String||t==Array)},__newvec:function(t,e){var i=[];i.length=t;for(var n=0;t>n;n++)i[n]=e;return i},__extend:function(t,e){function n(){i.un(this,"constructor",t)}for(var s in e)if(e.hasOwnProperty(s)){var r=Object.getOwnPropertyDescriptor(e,s),a=r.get,o=r.set;a||o?a&&o?Object.defineProperty(t,s,r):(a&&Object.defineProperty(t,s,a),o&&Object.defineProperty(t,s,o)):t[s]=e[s]}n.prototype=e.prototype,t.prototype=new n,i.un(t.prototype,"__imps",i.__copy({},e.prototype.__imps))},__copy:function(t,e){if(!e)return null;t=t||{};for(var i in e)t[i]=e[i];return t},__package:function(e,n){if(!i.__packages[e]){i.__packages[e]=!0;var s=t,r=e.split(".");if(r.length>1)for(var a=0,o=r.length-1;o>a;a++){var h=s[r[a]];s=h?h:s[r[a]]={}}s[r[r.length-1]]||(s[r[r.length-1]]=n||{})}},__hasOwnProperty:function(t,e){function i(t,e){if(Object.hasOwnProperty.call(e.prototype,t))return!0;var n=e.prototype.__super;return null==n?null:i(t,n)}return e=e||this,Object.hasOwnProperty.call(e,t)||i(t,e.__class)},__typeof:function(t,e){if(!t||!e)return!1;if(e===String)return"string"==typeof t;if(e===Number)return"number"==typeof t;if(e.__interface__)e=e.__interface__;else if("string"!=typeof e)return t instanceof e;return t.__imps&&t.__imps[e]||t.__class==e},__as:function(t,e){return this.__typeof(t,e)?t:null},"interface":function(e,n){i.__package(e,{});var s=i.__internals,r=s[e]=s[e]||{self:e};if(n){var a=n.split(",");r.extend=[];for(var o=0;o0){if(0==n.indexOf("laya.")){var a=n.split(".");r=r||a[a.length-1],i[r]&&console.log("Warning!,this class["+r+"] already exist:",i[r]),i[r]=e}}else"Main"==n?t.Main=e:(i[n]&&console.log("Error!,this class["+n+"] already exist:",i[n]),i[n]=e);var o=i.un,h=e.prototype;o(h,"hasOwnProperty",i.__hasOwnProperty),o(h,"__class",e),o(h,"__super",s),o(h,"__className",n),o(e,"__super",s),o(e,"__className",n),o(e,"__isclass",!0),o(e,"super",function(t){this.__super.call(t)})},imps:function(t,e){function n(t){var e,r;if((e=i.__internals[t])&&(s[t]=!0,r=e.extend))for(var a=0;an;n+=2)"length"==e[n]?t.length=e[n+1].call(t):i()},un:function(t,e,n){return n||(n=t[e]),i.__propun.value=n,Object.defineProperty(t,e,i.__propun),n},uns:function(t,e){e.forEach(function(e){i.un(t,e)})}};return t.console=t.console||{log:function(){}},t.trace=t.console.log,Error.prototype.throwError=function(){throw arguments},String.prototype.substr=i.__substr,Object.defineProperty(Array.prototype,"fixed",{enumerable:!1}),i}(window,document);!function(t,e,i){i.un,i.uns,i["static"],i["class"],i.getset,i.__newvec}(window,document,Laya),function(window,document,Laya){var __un=Laya.un,__uns=Laya.uns,__static=Laya["static"],__class=Laya["class"],__getset=Laya.getset,__newvec=Laya.__newvec;Laya["interface"]("laya.runtime.IMarket"),Laya["interface"]("laya.filters.IFilter"),Laya["interface"]("laya.display.ILayout"),Laya["interface"]("laya.resource.IDispose"),Laya["interface"]("laya.runtime.IPlatform"),Laya["interface"]("laya.resource.IDestroy"),Laya["interface"]("laya.runtime.IConchNode"),Laya["interface"]("laya.filters.IFilterAction"),Laya["interface"]("laya.runtime.ICPlatformClass"),Laya["interface"]("laya.resource.ICreateResource"),Laya["interface"]("laya.runtime.IPlatformClass","laya.runtime.IPlatform");var RunDriver=function(){function t(){}return __class(t,"laya.utils.RunDriver"),t.FILTER_ACTIONS=[],t.pixelRatio=-1,t._charSizeTestDiv=null,t.now=function(){return Date.now()},t.getWindow=function(){return window},t.newWebGLContext=function(t,e){return t.getContext(e,{stencil:!0,alpha:Config.isAlpha,antialias:Config.isAntialias,premultipliedAlpha:Config.premultipliedAlpha})},t.getPixelRatio=function(){if(t.pixelRatio<0){var e=Browser.context,i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;t.pixelRatio=(Browser.window.devicePixelRatio||1)/i}return t.pixelRatio},t.getIncludeStr=function(t){return null},t.createShaderCondition=function(t){var e="(function() {return "+t+";})";return Browser.window.eval(e)},t.measureText=function(e,i){if(Render.isConchApp){var n=ConchTextCanvas;return n.font=i,n.measureText(e)}return null==t._charSizeTestDiv&&(t._charSizeTestDiv=Browser.createElement("div"),t._charSizeTestDiv.style.cssText="z-index:10000000;padding:0px;position: absolute;left:0px;visibility:hidden;top:0px;background:white",Browser.container.appendChild(t._charSizeTestDiv)),t._charSizeTestDiv.style.font=i,t._charSizeTestDiv.innerText=" "==e?"i":e,{width:t._charSizeTestDiv.offsetWidth,height:t._charSizeTestDiv.offsetHeight}},t.beginFlush=function(){},t.endFinish=function(){},t.addToAtlas=null,t.flashFlushImage=function(t){},t.drawToCanvas=function(t,e,i,n,s,r){var a=HTMLCanvas.create("2D"),o=new RenderContext(i,n,a);return RenderSprite.renders[e]._fun(t,o,s,r),a},t.createParticleTemplate2D=null,t.createGLTextur=null,t.createWebGLContext2D=null,t.changeWebGLSize=function(t,e){},t.createRenderSprite=function(t,e){return new RenderSprite(t,e)},t.createFilterAction=function(t){return new ColorFilterAction},t.createGraphics=function(){return new Graphics},t.clear=function(t){Render._context.ctx.clear()},t.clearAtlas=function(t){},t.addTextureToAtlas=function(t){},t.getTexturePixels=function(t,e,i,n,s){return null},t.skinAniSprite=function(){return null},t}(),___Laya=function(){return __getset(1,Laya,"alertGlobalError",null,function(t){var e=0;t?Browser.window.onerror=function(t,i,n,s,r){e++<5&&r&&alert("出错啦,请把此信息截图给研发商\n"+t+"\n"+r.stack)}:Browser.window.onerror=null}),Laya.init=function(t,e,i){for(var n=[],s=2,r=arguments.length;r>s;s++)n.push(arguments[s]);if(!Laya._isinit){Laya._isinit=!0,Browser.__init__(),Context.__init__(),Graphics.__init__(),Laya.timer=new Timer,Laya.loader=new LoaderManager;for(var s=0,a=n.length;a>s;s++)n[s].enable&&n[s].enable();Font.__init__(),Style.__init__(),ResourceManager.__init__(),CacheManger.beginCheck(),Laya.stageBox=Laya.stage=new Stage,Laya.stage.model&&Laya.stage.model.setRootNode();var o=Browser.window.location,h=o.pathname;return h=":"==h.charAt(2)?h.substring(1):h,URL.rootPath=URL.basePath=URL.getPath("file:"==o.protocol?h:o.protocol+"//"+o.host+o.pathname),Laya.render=new Render(0,0),Laya.stage.size(t,e),RenderSprite.__init__(),KeyBoardManager.__init__(),MouseManager.instance.__init__(Laya.stage,Render.canvas),Input.__init__(),SoundManager.autoStopMusic=!0,LocalStorage.__init__(),Render.canvas}},Laya.stage=null,Laya.timer=null,Laya.loader=null,Laya.render=null,Laya.version="1.5.5",Laya.stageBox=null,Laya._isinit=!1,__static(Laya,["conchMarket",function(){return this.conchMarket=window.conch?conchMarket:null},"PlatformClass",function(){return this.PlatformClass=window.PlatformClass}]),Laya}(),Config=function(){function t(){}return __class(t,"Config"),t.WebGLTextCacheCount=500,t.atlasEnable=!1,t.showCanvasMark=!1,t.CPUMemoryLimit=125829120,t.GPUMemoryLimit=167772160,t.animationInterval=50,t.isAntialias=!1,t.isAlpha=!1,t.premultipliedAlpha=!1,t}(),EventDispatcher=function(){function t(){this._events=null}var e;__class(t,"laya.events.EventDispatcher");var i=t.prototype;return i.hasListener=function(t){var e=this._events&&this._events[t];return!!e},i.event=function(t,e){if(!this._events||!this._events[t])return!1;var i=this._events[t];if(i.run)i.once&&delete this._events[t],null!=e?i.runWith(e):i.run();else{for(var n=0,s=i.length;s>n;n++){var r=i[n];r&&(null!=e?r.runWith(e):r.run()),r&&!r.once||(i.splice(n,1),n--,s--)}0===i.length&&delete this._events[t]}return!0},i.on=function(t,e,i,n){return this._createListener(t,e,i,n,!1)},i.once=function(t,e,i,n){return this._createListener(t,e,i,n,!0)},i._createListener=function(t,i,n,s,r,a){void 0===a&&(a=!0),a&&this.off(t,i,n,r);var o=e.create(i||this,n,s,r);this._events||(this._events={});var h=this._events;return h[t]?h[t].run?h[t]=[h[t],o]:h[t].push(o):h[t]=o,this},i.off=function(t,e,i,n){if(void 0===n&&(n=!1),!this._events||!this._events[t])return this;var s=this._events[t];if(null!=i)if(s.run)e&&s.caller!==e||s.method!==i||n&&!s.once||(delete this._events[t],s.recover());else{for(var r=0,a=0,o=s.length;o>a;a++){var h=s[a];!h||e&&h.caller!==e||h.method!==i||n&&!h.once||(r++,s[a]=null,h.recover())}r===o&&delete this._events[t]}return this},i.offAll=function(t){var e=this._events;if(!e)return this;if(t)this._recoverHandlers(e[t]),delete e[t];else{for(var i in e)this._recoverHandlers(e[i]);this._events=null}return this},i._recoverHandlers=function(t){if(t)if(t.run)t.recover();else for(var e=t.length-1;e>-1;e--)t[e]&&(t[e].recover(),t[e]=null)},i.isMouseEvent=function(e){return t.MOUSE_EVENTS[e]},t.MOUSE_EVENTS={rightmousedown:!0,rightmouseup:!0,rightclick:!0,mousedown:!0,mouseup:!0,mousemove:!0,mouseover:!0,mouseout:!0,click:!0,doubleclick:!0},t.__init$=function(){e=function(t){function e(t,i,n,s){e.__super.call(this,t,i,n,s)}__class(e,"",t);var i=e.prototype;return i.recover=function(){this._id>0&&(this._id=0,e._pool.push(this.clear()))},e.create=function(t,i,n,s){return void 0===s&&(s=!0),e._pool.length?e._pool.pop().setTo(t,i,n,s):new e(t,i,n,s)},e._pool=[],e}(Handler)},t}(),Handler=function(){function t(t,e,i,n){this.once=!1,this._id=0,void 0===n&&(n=!1),this.setTo(t,e,i,n)}__class(t,"laya.utils.Handler");var e=t.prototype;return e.setTo=function(e,i,n,s){return this._id=t._gid++,this.caller=e,this.method=i,this.args=n,this.once=s,this},e.run=function(){if(null==this.method)return null;var t=this._id,e=this.method.apply(this.caller,this.args);return this._id===t&&this.once&&this.recover(),e},e.runWith=function(t){if(null==this.method)return null;var e=this._id;if(null==t)var i=this.method.apply(this.caller,this.args);else i=this.args||t.unshift?this.args?this.method.apply(this.caller,this.args.concat(t)):this.method.apply(this.caller,t):this.method.call(this.caller,t);return this._id===e&&this.once&&this.recover(),i},e.clear=function(){return this.caller=null,this.method=null,this.args=null,this},e.recover=function(){this._id>0&&(this._id=0,t._pool.push(this.clear()))},t.create=function(e,i,n,s){return void 0===s&&(s=!0),t._pool.length?t._pool.pop().setTo(e,i,n,s):new t(e,i,n,s)},t._pool=[],t._gid=1,t}(),BitmapFont=function(){function t(){this.fontSize=12,this.autoScaleSize=!1,this._texture=null,this._fontCharDic={},this._complete=null,this._path=null,this._maxHeight=0,this._maxWidth=0,this._spaceWidth=10,this._leftPadding=0,this._rightPadding=0,this._letterSpacing=0}__class(t,"laya.display.BitmapFont");var e=t.prototype;return e.loadFont=function(t,e){this._path=t,this._complete=e,Laya.loader.load([{url:this._path,type:"xml"},{url:this._path.replace(".fnt",".png"),type:"image"}],Handler.create(this,this.onLoaded))},e.onLoaded=function(){this.parseFont(Loader.getRes(this._path),Loader.getRes(this._path.replace(".fnt",".png"))),this._complete&&this._complete.run()},e.parseFont=function(t,e){if(null!=t&&null!=e){this._texture=e;var i=1,n=t.getElementsByTagName("info");this.fontSize=parseInt(n[0].attributes.size.nodeValue);var s=n[0].attributes.padding.nodeValue,r=s.split(","),a=parseInt(r[0]),o=parseInt(r[2]);this._leftPadding=parseInt(r[3]),this._rightPadding=parseInt(r[1]);var h=t.getElementsByTagName("char"),l=0;for(l=0;li;i++)e+=this.getCharWidth(t.charAt(i));return e},e.getMaxWidth=function(){return this._maxWidth+this._letterSpacing},e.getMaxHeight=function(){return this._maxHeight},e.drawText=function(t,e,i,n,s,r){for(var a,o=0,h=0,l=t.length;l>h;h++)o+=this.getCharWidth(t.charAt(h));var u=this._leftPadding;"center"===s&&(u=(r-o)/2),"right"===s&&(u=r-o-this._rightPadding);var c=0;for(h=0,l=t.length;l>h;h++)a=this.getCharTexture(t.charAt(h)),a&&e.graphics.drawTexture(a,i+c+u,n,a.width,a.height),c+=this.getCharWidth(t.charAt(h))},__getset(0,e,"letterSpacing",function(){return this._letterSpacing},function(t){this._letterSpacing=t}),t}(),Style=function(){function t(){this.alpha=1,this.visible=!0,this.scrollRect=null,this.blendMode=null,this._type=0,this._tf=t._TF_EMPTY}__class(t,"laya.display.css.Style");var e=t.prototype;return e.getTransform=function(){return this._tf},e.setTransform=function(e){this._tf="none"!==e&&e?e:t._TF_EMPTY},e.setTranslateX=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.translateX=e},e.setTranslateY=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.translateY=e},e.setScaleX=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.scaleX=e},e.setScaleY=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.scaleY=e},e.setRotate=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.rotate=e},e.setSkewX=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.skewX=e},e.setSkewY=function(e){this._tf===t._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.skewY=e},e.destroy=function(){this.scrollRect=null},e.render=function(t,e,i,n){},e.getCSSStyle=function(){return CSSStyle.EMPTY},e._enableLayout=function(){return!1},__getset(0,e,"scaleX",function(){return this._tf.scaleX},function(t){this.setScaleX(t)}),__getset(0,e,"transform",function(){return this.getTransform()},function(t){this.setTransform(t)}),__getset(0,e,"translateX",function(){return this._tf.translateX},function(t){this.setTranslateX(t)}),__getset(0,e,"translateY",function(){return this._tf.translateY},function(t){this.setTranslateY(t)}),__getset(0,e,"scaleY",function(){return this._tf.scaleY},function(t){this.setScaleY(t)}),__getset(0,e,"block",function(){return 0!=(1&this._type)}),__getset(0,e,"skewY",function(){return this._tf.skewY},function(t){this.setSkewY(t)}),__getset(0,e,"rotate",function(){return this._tf.rotate},function(t){this.setRotate(t)}),__getset(0,e,"skewX",function(){return this._tf.skewX},function(t){this.setSkewX(t)}),__getset(0,e,"paddingLeft",function(){return 0}),__getset(0,e,"paddingTop",function(){return 0}),__getset(0,e,"absolute",function(){return!0}),t.__init__=function(){t._TF_EMPTY=new TransformInfo,t.EMPTY=new t},t.EMPTY=null,t._TF_EMPTY=null,t}(),Font=function(){function t(e){this._type=0,this._weight=0,this._decoration=null,this._text=null,this.indent=0,this._color=Color.create(t.defaultColor),this.family=t.defaultFamily,this.stroke=t._STROKE,this.size=t.defaultSize,e&&e!==t.EMPTY&&e.copyTo(this)}__class(t,"laya.display.css.Font");var e=t.prototype;return e.set=function(t){this._text=null;for(var e=t.split(" "),i=0,n=e.length;n>i;i++){var s=e[i];switch(s){case"italic":this.italic=!0;continue;case"bold":this.bold=!0;continue}s.indexOf("px")>0&&(this.size=parseInt(s),this.family=e[i+1],i++)}},e.toString=function(){return this._text="",this.italic&&(this._text+="italic "),this.bold&&(this._text+="bold "),this._text+=this.size+"px "+this.family},e.copyTo=function(e){e._type=this._type,e._text=this._text,e._weight=this._weight,e._color=this._color,e.family=this.family,e.stroke=this.stroke!=t._STROKE?this.stroke.slice():t._STROKE,e.indent=this.indent,e.size=this.size},__getset(0,e,"password",function(){return 0!==(1024&this._type)},function(t){t?this._type|=1024:this._type&=-1025}),__getset(0,e,"color",function(){return this._color.strColor},function(t){this._color=Color.create(t)}),__getset(0,e,"italic",function(){return 0!==(512&this._type)},function(t){t?this._type|=512:this._type&=-513}),__getset(0,e,"bold",function(){return 0!==(2048&this._type)},function(t){t?this._type|=2048:this._type&=-2049}),__getset(0,e,"weight",function(){return""+this._weight},function(t){var e=0;switch(t){case"normal":break;case"bold":this.bold=!0,e=700;break;case"bolder":e=800;break;case"lighter":e=100;break;default:e=parseInt(t)}this._weight=e,this._text=null}),__getset(0,e,"decoration",function(){return this._decoration?this._decoration.value:"none"},function(t){var e=t.split(" ");switch(this._decoration||(this._decoration={}),e[0]){case"_":this._decoration.type="underline";break;case"-":this._decoration.type="line-through";break;case"overline":this._decoration.type="overline";break;default:this._decoration.type=e[0]}e[1]&&(this._decoration.color=Color.create(e)),this._decoration.value=t}),t.__init__=function(){t.EMPTY=new t(null)},t.EMPTY=null,t.defaultColor="#000000",t.defaultSize=12,t.defaultFamily="Arial",t.defaultFont="12px Arial",t._STROKE=[0,"#000000"],t._ITALIC=512,t._PASSWORD=1024,t._BOLD=2048,t}(),TransformInfo=function(){function t(){this.translateX=0,this.translateY=0,this.scaleX=1,this.scaleY=1,this.rotate=0,this.skewX=0,this.skewY=0}return __class(t,"laya.display.css.TransformInfo"),t}(),Graphics=function(){function t(){this._one=null,this._cmds=null,this._render=this._renderEmpty,this._render=this._renderEmpty,Render.isConchNode&&(this._nativeObj=new _conchGraphics,this.id=this._nativeObj.conchID)}__class(t,"laya.display.Graphics");var e=t.prototype;return e.destroy=function(){this.clear(),this._temp=null,this._bounds=null,this._rstBoundPoints=null,this._sp&&(this._sp._renderType=0),this._sp=null},e.clear=function(){if(this._one=null,this._render=this._renderEmpty,this._cmds=null,this._temp&&(this._temp.length=0),this._sp&&(this._sp._renderType&=-2),this._sp&&(this._sp._renderType&=-257),this._repaint(),this._vectorgraphArray){for(var t=0,e=this._vectorgraphArray.length;e>t;t++)VectorGraphManager.getInstance().deleteShape(this._vectorgraphArray[t]);this._vectorgraphArray.length=0}},e._repaint=function(){this._temp&&(this._temp.length=0),this._sp&&this._sp.repaint()},e._isOnlyOne=function(){return!this._cmds||0===this._cmds.length},e.getBounds=function(){return(!this._bounds||!this._temp||this._temp.length<1)&&(this._bounds=Rectangle._getWrapRec(this.getBoundPoints(),this._bounds)),this._bounds},e.getBoundPoints=function(){return(!this._temp||this._temp.length<1)&&(this._temp=this._getCmdPoints()),this._rstBoundPoints=Utils.copyArray(this._rstBoundPoints,this._temp)},e._addCmd=function(t){this._cmds=this._cmds||[],t.callee=t.shift(),this._cmds.push(t)},e._getCmdPoints=function(){var e,i=Render._context,n=this._cmds;if(e=this._temp||(this._temp=[]),e.length=0,n||null==this._one||(t._tempCmds.length=0,t._tempCmds.push(this._one),n=t._tempCmds),!n)return e;var s;s=t._tempMatrixArrays,s.length=0;var r=t._initMatrix;r.identity();for(var a,o=t._tempMatrix,h=0,l=n.length;l>h;h++)switch(a=n[h],a.callee){case i.save:case 7:s.push(r),r=r.clone();break;case i.restore:case 8:r=s.pop();break;case i._scale:case 5:o.identity(),o.translate(-a[2],-a[3]),o.scale(a[0],a[1]),o.translate(a[2],a[3]),this._switchMatrix(r,o);break;case i._rotate:case 3:o.identity(),o.translate(-a[1],-a[2]),o.rotate(a[0]),o.translate(a[1],a[2]),this._switchMatrix(r,o);break;case i._translate:case 6:o.identity(),o.translate(a[0],a[1]),this._switchMatrix(r,o);break;case i._transform:case 4:o.identity(),o.translate(-a[1],-a[2]),o.concat(a[0]),o.translate(a[1],a[2]),this._switchMatrix(r,o);break;case 16:case 24:t._addPointArrToRst(e,Rectangle._getBoundPointS(a[0],a[1],a[2],a[3]),r);break;case 17:r.copyTo(o),o.concat(a[4]),t._addPointArrToRst(e,Rectangle._getBoundPointS(a[0],a[1],a[2],a[3]),o);break;case i._drawTexture:case i._fillTexture:if(a[3]&&a[4])t._addPointArrToRst(e,Rectangle._getBoundPointS(a[1],a[2],a[3],a[4]),r);else{var u=a[0];t._addPointArrToRst(e,Rectangle._getBoundPointS(a[1],a[2],u.width,u.height),r)}break;case i._drawTextureWithTransform:var c;a[5]?(r.copyTo(o),o.concat(a[5]),c=o):c=r,a[3]&&a[4]?t._addPointArrToRst(e,Rectangle._getBoundPointS(a[1],a[2],a[3],a[4]),c):(u=a[0],t._addPointArrToRst(e,Rectangle._getBoundPointS(a[1],a[2],u.width,u.height),c));break;case i._drawRect:case 13:t._addPointArrToRst(e,Rectangle._getBoundPointS(a[0],a[1],a[2],a[3]),r);break;case i._drawCircle:case i._fillCircle:case 14:t._addPointArrToRst(e,Rectangle._getBoundPointS(a[0]-a[2],a[1]-a[2],a[2]+a[2],a[2]+a[2]),r);break;case i._drawLine:case 20:t._tempPoints.length=0;var _=NaN;_=.5*a[5],a[0]==a[2]?t._tempPoints.push(a[0]+_,a[1],a[2]+_,a[3],a[0]-_,a[1],a[2]-_,a[3]):a[1]==a[3]?t._tempPoints.push(a[0],a[1]+_,a[2],a[3]+_,a[0],a[1]-_,a[2],a[3]-_):t._tempPoints.push(a[0],a[1],a[2],a[3]),t._addPointArrToRst(e,t._tempPoints,r);break;case i._drawCurves:case 22:t._addPointArrToRst(e,Bezier.I.getBezierPoints(a[2]),r,a[0],a[1]);break;case i._drawPoly:case i._drawLines:case 18:t._addPointArrToRst(e,a[2],r,a[0],a[1]);break;case i._drawPath:case 19:t._addPointArrToRst(e,this._getPathPoints(a[2]),r,a[0],a[1]);break;case i._drawPie:case 15:t._addPointArrToRst(e,this._getPiePoints(a[0],a[1],a[2],a[3],a[4]),r)}return e.length>200?e=Utils.copyArray(e,Rectangle._getWrapRec(e)._getBoundPoints()):e.length>8&&(e=GrahamScan.scanPList(e)),e},e._switchMatrix=function(t,e){e.concat(t),e.copyTo(t)},e.drawTexture=function(t,e,i,n,s,r,a){if(void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=1),t&&(n||(n=t.sourceWidth),s||(s=t.sourceHeight),n=n-t.sourceWidth+t.width,s=s-t.sourceHeight+t.height,!t.loaded||!(0>=n||0>=s))){e+=t.offsetX,i+=t.offsetY,this._sp&&(this._sp._renderType|=256);var o=[t,e,i,n,s,r,a];o.callee=r||1!=a?Render._context._drawTextureWithTransform:Render._context._drawTexture,null!=this._one||r||1!=a?this._saveToCmd(o.callee,o):(this._one=o,this._render=this._renderOneImg),t.loaded||t.once("loaded",this,this._textureLoaded,[t,o]),this._repaint()}},e.cleanByTexture=function(t,e,i,n,s){return void 0===n&&(n=0),void 0===s&&(s=0),t?void(this._one&&this._render===this._renderOneImg?(n||(n=t.sourceWidth),s||(s=t.sourceHeight),n=n-t.sourceWidth+t.width,s=s-t.sourceHeight+t.height,e+=t.offsetX,i+=t.offsetY,this._one[0]=t,this._one[1]=e,this._one[2]=i,this._one[3]=n,this._one[4]=s):(this.clear(),t&&this.drawTexture(t,e,i,n,s))):this.clear()},e.drawTextures=function(t,e){t&&this._saveToCmd(Render._context._drawTextures,[t,e])},e.fillTexture=function(t,e,i,n,s,r,a){if(void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r="repeat"),t){var o=[t,e,i,n,s,r,a||Point.EMPTY,{}];t.loaded||t.once("loaded",this,this._textureLoaded,[t,o]),this._saveToCmd(Render._context._fillTexture,o)}},e._textureLoaded=function(t,e){e[3]=e[3]||t.width,e[4]=e[4]||t.height,this._repaint()},e._saveToCmd=function(t,e){return this._sp&&(this._sp._renderType|=256),null==this._one?(this._one=e,this._render=this._renderOne):(this._sp&&(this._sp._renderType&=-2),this._render=this._renderAll,0===(this._cmds||(this._cmds=[])).length&&this._cmds.push(this._one),this._cmds.push(e)),e.callee=t,this._temp&&(this._temp.length=0),this._repaint(),e},e.clipRect=function(t,e,i,n){this._saveToCmd(Render._context._clipRect,[t,e,i,n])},e.fillText=function(t,e,i,n,s,r){this._saveToCmd(Render._context._fillText,[t,e,i,n||Font.defaultFont,s,r])},e.fillBorderText=function(t,e,i,n,s,r,a,o){this._saveToCmd(Render._context._fillBorderText,[t,e,i,n||Font.defaultFont,s,r,a,o])},e.strokeText=function(t,e,i,n,s,r,a){this._saveToCmd(Render._context._strokeText,[t,e,i,n||Font.defaultFont,s,r,a])},e.alpha=function(t){this._saveToCmd(Render._context._alpha,[t])},e.transform=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),this._saveToCmd(Render._context._transform,[t,e,i])},e.rotate=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),this._saveToCmd(Render._context._rotate,[t,e,i])},e.scale=function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this._saveToCmd(Render._context._scale,[t,e,i,n])},e.translate=function(t,e){this._saveToCmd(Render._context._translate,[t,e])},e.save=function(){this._saveToCmd(Render._context._save,[])},e.restore=function(){this._saveToCmd(Render._context._restore,[])},e.replaceText=function(t){this._repaint();var e=this._cmds;if(e){for(var i=e.length-1;i>-1;i--)if(this._isTextCmd(e[i].callee))return e[i][0].toUpperCase?e[i][0]=t:e[i][0].setText(t),!0}else if(this._one&&this._isTextCmd(this._one.callee))return this._one[0].toUpperCase?this._one[0]=t:this._one[0].setText(t),!0;return!1},e._isTextCmd=function(t){return t===Render._context._fillText||t===Render._context._fillBorderText||t===Render._context._strokeText},e.replaceTextColor=function(t){this._repaint();var e=this._cmds;if(e)for(var i=e.length-1;i>-1;i--)this._isTextCmd(e[i].callee)&&(e[i][4]=t,e[i][0].toUpperCase||(e[i][0].changed=!0));else this._one&&this._isTextCmd(this._one.callee)&&(this._one[4]=t,this._one[0].toUpperCase||(this._one[0].changed=!0))},e.loadImage=function(t,e,i,n,s,r){function a(t){t&&(o.drawTexture(t,e,i,n,s),null!=r&&r.call(o._sp,t))}var o=this;void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0);var h=Loader.getRes(t);h?a(h):Laya.loader.load(t,Handler.create(null,a),null,"image")},e._renderEmpty=function(t,e,i,n){},e._renderAll=function(t,e,i,n){for(var s,r=this._cmds,a=0,o=r.length;o>a;a++)(s=r[a]).callee.call(e,i,n,s)},e._renderOne=function(t,e,i,n){this._one.callee.call(e,i,n,this._one)},e._renderOneImg=function(t,e,i,n){this._one.callee.call(e,i,n,this._one),2305!==t._renderType&&(t._renderType|=1)},e.drawLine=function(t,e,i,n,s,r){void 0===r&&(r=1);var a=0;Render.isWebGL&&(a=VectorGraphManager.getInstance().getId(),null==this._vectorgraphArray&&(this._vectorgraphArray=[]),this._vectorgraphArray.push(a));var o=[t+.5,e+.5,i+.5,n+.5,s,r,a];this._saveToCmd(Render._context._drawLine,o)},e.drawLines=function(t,e,i,n,s){void 0===s&&(s=1);var r=0;Render.isWebGL&&(r=VectorGraphManager.getInstance().getId(),null==this._vectorgraphArray&&(this._vectorgraphArray=[]),this._vectorgraphArray.push(r));var a=[t+.5,e+.5,i,n,s,r];this._saveToCmd(Render._context._drawLines,a)},e.drawCurves=function(t,e,i,n,s){void 0===s&&(s=1);var r=[t+.5,e+.5,i,n,s];this._saveToCmd(Render._context._drawCurves,r)},e.drawRect=function(t,e,i,n,s,r,a){void 0===a&&(a=1);var o=r?.5:0,h=[t+o,e+o,i,n,s,r,a];this._saveToCmd(Render._context._drawRect,h)},e.drawCircle=function(t,e,i,n,s,r){void 0===r&&(r=1);var a=s?.5:0,o=0;Render.isWebGL&&(o=VectorGraphManager.getInstance().getId(),null==this._vectorgraphArray&&(this._vectorgraphArray=[]),this._vectorgraphArray.push(o));var h=[t+a,e+a,i,n,s,r,o];this._saveToCmd(Render._context._drawCircle,h)},e.drawPie=function(t,e,i,n,s,r,a,o){void 0===o&&(o=1);var h=a?.5:0,l=0;Render.isWebGL&&(l=VectorGraphManager.getInstance().getId(),null==this._vectorgraphArray&&(this._vectorgraphArray=[]),this._vectorgraphArray.push(l));var u=[t+h,e+h,i,n,s,r,a,o,l];u[3]=Utils.toRadian(n),u[4]=Utils.toRadian(s),this._saveToCmd(Render._context._drawPie,u)},e._getPiePoints=function(e,i,n,s,r){var a=t._tempPoints;t._tempPoints.length=0,a.push(e,i);var o=Math.PI/10,h=NaN;for(h=s;r>h;h+=o)a.push(e+n*Math.cos(h),i+n*Math.sin(h));return r!=h&&a.push(e+n*Math.cos(r),i+n*Math.sin(r)),a},e.drawPoly=function(t,e,i,n,s,r){void 0===r&&(r=1);var a=s?.5:0,o=0;if(Render.isWebGL){o=VectorGraphManager.getInstance().getId(),null==this._vectorgraphArray&&(this._vectorgraphArray=[]),this._vectorgraphArray.push(o);var h=!1;h=!(i.length>6)}var l=[t+a,e+a,i,n,s,r,o,h];this._saveToCmd(Render._context._drawPoly,l)},e._getPathPoints=function(e){var i=0,n=0,s=t._tempPoints;s.length=0,n=e.length;var r;for(i=0;n>i;i++)r=e[i],r.length>1&&(s.push(r[1],r[2]),r.length>3&&s.push(r[3],r[4]));return s},e.drawPath=function(t,e,i,n,s){var r=[t+.5,e+.5,i,n,s];this._saveToCmd(Render._context._drawPath,r)},__getset(0,e,"cmds",function(){return this._cmds},function(t){this._sp&&(this._sp._renderType|=256),this._cmds=t,this._render=this._renderAll,this._repaint()}),t.__init__=function(){if(Render.isConchNode){for(var t=laya.display.Graphics.prototype,e=ConchGraphics.prototype,i=["clear","destroy","alpha","rotate","transform","scale","translate","save","restore","clipRect","blendMode","fillText","fillBorderText","_fands","drawRect","drawCircle","drawPie","drawPoly","drawPath","drawImageM","drawLine","drawLines","_drawPs","drawCurves","replaceText","replaceTextColor","_fillImage","fillTexture","setSkinMesh","drawParticle","drawImageS"],n=0,s=i.length;s>=n;n++){var r=i[n];t[r]=e[r]}t._saveToCmd=null,e.drawImageS&&(t.drawTextures=function(t,e){if(t&&t.loaded&&t.bitmap&&t.source){var i=t.uv,n=t.bitmap.width,s=t.bitmap.height;this.drawImageS(t.bitmap.source,i[0]*n,i[1]*s,(i[2]-i[0])*n,(i[5]-i[3])*s,t.offsetX,t.offsetY,t.width,t.height,e)}}),t.drawTexture=function(t,e,i,n,s,r){if(void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),t&&t.loaded&&t.bitmap&&t.source&&(n||(n=t.sourceWidth),s||(s=t.sourceHeight),n=n-t.sourceWidth+t.width,s=s-t.sourceHeight+t.height,!(0>=n||0>=s))){e+=t.offsetX,i+=t.offsetY;var a=t.uv,o=t.bitmap.width,h=t.bitmap.height;this.drawImageM(t.bitmap.source,a[0]*o,a[1]*h,(a[2]-a[0])*o,(a[5]-a[3])*h,e,i,n,s,r)}},t.fillTexture=function(t,e,i,n,s,r,a){if(void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r="repeat"),t&&t.loaded){var o,h=Render._context.ctx,l=t.bitmap.width,u=t.bitmap.height,c=t.uv;o=t.uv!=Texture.DEF_UV?h.createPattern(t.bitmap.source,r,c[0]*l,c[1]*u,(c[2]-c[0])*l,(c[5]-c[3])*u):h.createPattern(t.bitmap.source,r);var _=0,d=0;a&&(e+=a.x%t.width,i+=a.y%t.height,_-=a.x%t.width,d-=a.y%t.height),this._fillImage(o,e,i,_,d,n,s)}}}},t._addPointArrToRst=function(e,i,n,s,r){void 0===s&&(s=0),void 0===r&&(r=0);var a=0,o=0;for(o=i.length,a=0;o>a;a+=2)t._addPointToRst(e,i[a]+s,i[a+1]+r,n)},t._addPointToRst=function(t,e,i,n){var s=Point.TEMP;s.setTo(e?e:0,i?i:0),n.transformPoint(s),t.push(s.x,s.y)},t._tempPoints=[],t._tempMatrixArrays=[],t._tempCmds=[],__static(t,["_tempMatrix",function(){return this._tempMatrix=new Matrix},"_initMatrix",function(){return this._initMatrix=new Matrix}]),t}(),Event=function(){function t(){}__class(t,"laya.events.Event");var e=t.prototype;return e.setTo=function(t,e,i){ +return this.type=t,this.currentTarget=e,this.target=i,this},e.stopPropagation=function(){this._stoped=!0},__getset(0,e,"stageY",function(){return Laya.stage.mouseY}),__getset(0,e,"charCode",function(){return this.nativeEvent.charCode}),__getset(0,e,"touches",function(){var t=this.nativeEvent.touches;if(t)for(var e=Laya.stage,i=0,n=t.length;n>i;i++){var s=t[i],r=Point.TEMP;r.setTo(s.clientX,s.clientY),e._canvasTransform.invertTransformPoint(r),e.transform.invertTransformPoint(r),s.stageX=r.x,s.stageY=r.y}return t}),__getset(0,e,"keyLocation",function(){return this.nativeEvent.keyLocation}),__getset(0,e,"ctrlKey",function(){return this.nativeEvent.ctrlKey}),__getset(0,e,"altKey",function(){return this.nativeEvent.altKey}),__getset(0,e,"shiftKey",function(){return this.nativeEvent.shiftKey}),__getset(0,e,"stageX",function(){return Laya.stage.mouseX}),t.EMPTY=new t,t.MOUSE_DOWN="mousedown",t.MOUSE_UP="mouseup",t.CLICK="click",t.RIGHT_MOUSE_DOWN="rightmousedown",t.RIGHT_MOUSE_UP="rightmouseup",t.RIGHT_CLICK="rightclick",t.MOUSE_MOVE="mousemove",t.MOUSE_OVER="mouseover",t.MOUSE_OUT="mouseout",t.MOUSE_WHEEL="mousewheel",t.ROLL_OVER="mouseover",t.ROLL_OUT="mouseout",t.DOUBLE_CLICK="doubleclick",t.CHANGE="change",t.CHANGED="changed",t.RESIZE="resize",t.ADDED="added",t.REMOVED="removed",t.DISPLAY="display",t.UNDISPLAY="undisplay",t.ERROR="error",t.COMPLETE="complete",t.LOADED="loaded",t.PROGRESS="progress",t.INPUT="input",t.RENDER="render",t.OPEN="open",t.MESSAGE="message",t.CLOSE="close",t.KEY_DOWN="keydown",t.KEY_PRESS="keypress",t.KEY_UP="keyup",t.FRAME="enterframe",t.DRAG_START="dragstart",t.DRAG_MOVE="dragmove",t.DRAG_END="dragend",t.ENTER="enter",t.SELECT="select",t.BLUR="blur",t.FOCUS="focus",t.PLAYED="played",t.PAUSED="paused",t.STOPPED="stopped",t.START="start",t.END="end",t.ENABLED_CHANGED="enabledchanged",t.COMPONENT_ADDED="componentadded",t.COMPONENT_REMOVED="componentremoved",t.ACTIVE_CHANGED="activechanged",t.LAYER_CHANGED="layerchanged",t.HIERARCHY_LOADED="hierarchyloaded",t.RECOVERING="recovering",t.RECOVERED="recovered",t.RELEASED="released",t.LINK="link",t.LABEL="label",t.FULL_SCREEN_CHANGE="fullscreenchange",t.DEVICE_LOST="devicelost",t.MESH_CHANGED="meshchanged",t.MATERIAL_CHANGED="materialchanged",t.RENDERQUEUE_CHANGED="renderqueuechanged",t.WORLDMATRIX_NEEDCHANGE="worldmatrixneedchanged",t.ANIMATION_CHANGED="animationchanged",t}(),Keyboard=function(){function t(){}return __class(t,"laya.events.Keyboard"),t.NUMBER_0=48,t.NUMBER_1=49,t.NUMBER_2=50,t.NUMBER_3=51,t.NUMBER_4=52,t.NUMBER_5=53,t.NUMBER_6=54,t.NUMBER_7=55,t.NUMBER_8=56,t.NUMBER_9=57,t.A=65,t.B=66,t.C=67,t.D=68,t.E=69,t.F=70,t.G=71,t.H=72,t.I=73,t.J=74,t.K=75,t.L=76,t.M=77,t.N=78,t.O=79,t.P=80,t.Q=81,t.R=82,t.S=83,t.T=84,t.U=85,t.V=86,t.W=87,t.X=88,t.Y=89,t.Z=90,t.F1=112,t.F2=113,t.F3=114,t.F4=115,t.F5=116,t.F6=117,t.F7=118,t.F8=119,t.F9=120,t.F10=121,t.F11=122,t.F12=123,t.F13=124,t.F14=125,t.F15=126,t.NUMPAD=21,t.NUMPAD_0=96,t.NUMPAD_1=97,t.NUMPAD_2=98,t.NUMPAD_3=99,t.NUMPAD_4=100,t.NUMPAD_5=101,t.NUMPAD_6=102,t.NUMPAD_7=103,t.NUMPAD_8=104,t.NUMPAD_9=105,t.NUMPAD_ADD=107,t.NUMPAD_DECIMAL=110,t.NUMPAD_DIVIDE=111,t.NUMPAD_ENTER=108,t.NUMPAD_MULTIPLY=106,t.NUMPAD_SUBTRACT=109,t.SEMICOLON=186,t.EQUAL=187,t.COMMA=188,t.MINUS=189,t.PERIOD=190,t.SLASH=191,t.BACKQUOTE=192,t.LEFTBRACKET=219,t.BACKSLASH=220,t.RIGHTBRACKET=221,t.QUOTE=222,t.ALTERNATE=18,t.BACKSPACE=8,t.CAPS_LOCK=20,t.COMMAND=15,t.CONTROL=17,t.DELETE=46,t.ENTER=13,t.ESCAPE=27,t.PAGE_UP=33,t.PAGE_DOWN=34,t.END=35,t.HOME=36,t.LEFT=37,t.UP=38,t.RIGHT=39,t.DOWN=40,t.SHIFT=16,t.SPACE=32,t.TAB=9,t.INSERT=45,t}(),KeyBoardManager=function(){function t(){}return __class(t,"laya.events.KeyBoardManager"),t.__init__=function(){t._addEvent("keydown"),t._addEvent("keypress"),t._addEvent("keyup")},t._addEvent=function(t){Browser.document.addEventListener(t,function(e){laya.events.KeyBoardManager._dispatch(e,t)},!0)},t._dispatch=function(e,i){if(t.enabled){t._event._stoped=!1,t._event.nativeEvent=e,t._event.keyCode=e.keyCode||e.which||e.charCode,"keydown"===i?t._pressKeys[t._event.keyCode]=!0:"keyup"===i&&(t._pressKeys[t._event.keyCode]=null);for(var n=Laya.stage.focus&&null!=Laya.stage.focus.event?Laya.stage.focus:Laya.stage,s=n;s;)s.event(i,t._event.setTo(i,s,n)),s=s.parent}},t.hasKeyDown=function(e){return t._pressKeys[e]},t._pressKeys={},t.enabled=!0,__static(t,["_event",function(){return this._event=new Event}]),t}(),KeyLocation=function(){function t(){}return __class(t,"laya.events.KeyLocation"),t.STANDARD=0,t.LEFT=1,t.RIGHT=2,t.NUM_PAD=3,t}(),MouseManager=function(){function t(){this.mouseX=0,this.mouseY=0,this.disableMouseEvent=!1,this.mouseDownTime=0,this.mouseMoveAccuracy=2,this._stage=null,this._target=null,this._lastOvers=[],this._currOvers=[],this._lastClickTimer=0,this._lastMoveTimer=0,this._isDoubleClick=!1,this._isLeftMouse=!1,this._eventList=[],this._touchIDs={},this._id=1,this._event=new Event,this._matrix=new Matrix,this._point=new Point,this._rect=new Rectangle,this._prePoint=new Point}__class(t,"laya.events.MouseManager");var e=t.prototype;return e.__init__=function(e,i){var n=this;this._stage=e;var s=this,r=this._eventList;i.oncontextmenu=function(e){return t.enabled?!1:void 0},i.addEventListener("mousedown",function(e){t.enabled&&(e.preventDefault(),r.push(e),s.mouseDownTime=Browser.now())}),i.addEventListener("mouseup",function(e){t.enabled&&(e.preventDefault(),r.push(e),s.mouseDownTime=-Browser.now())},!0),i.addEventListener("mousemove",function(e){if(t.enabled){e.preventDefault();var i=Browser.now();if(i-s._lastMoveTimer<10)return;s._lastMoveTimer=i,r.push(e)}},!0),i.addEventListener("mouseout",function(e){t.enabled&&r.push(e)}),i.addEventListener("mouseover",function(e){t.enabled&&r.push(e)}),i.addEventListener("touchstart",function(e){t.enabled&&(r.push(e),n.runEvent(),Input.isInputting||e.preventDefault(),s.mouseDownTime=Browser.now())}),i.addEventListener("touchend",function(e){t.enabled&&(Input.isInputting||e.preventDefault(),r.push(e),s.mouseDownTime=-Browser.now())},!0),i.addEventListener("touchmove",function(e){t.enabled&&(e.preventDefault(),r.push(e))},!0),i.addEventListener("mousewheel",function(e){t.enabled&&r.push(e)}),i.addEventListener("DOMMouseScroll",function(e){t.enabled&&r.push(e)})},e.initEvent=function(t,e){var i=this;i._event._stoped=!1,i._event.nativeEvent=e||t,i._target=null,this._point.setTo(t.clientX,t.clientY),this._stage._canvasTransform.invertTransformPoint(this._point),i.mouseX=this._point.x,i.mouseY=this._point.y,i._event.touchId=t.identifier||0},e.checkMouseWheel=function(t){this._event.delta=t.wheelDelta?.025*t.wheelDelta:-t.detail;for(var e=0,i=this._lastOvers.length;i>e;e++){var n=this._lastOvers[e];n.event("mousewheel",this._event.setTo("mousewheel",n,this._target))}this._stage.event("mousewheel",this._event.setTo("mousewheel",this._stage,this._target))},e.checkMouseOut=function(){if(!this.disableMouseEvent){for(var t=0,e=this._lastOvers.length;e>t;t++){var i=this._lastOvers[t];!i.destroyed&&this._currOvers.indexOf(i)<0&&(i._set$P("$_MOUSEOVER",!1),i.event("mouseout",this._event.setTo("mouseout",i,this._target)))}var n=this._lastOvers;this._lastOvers=this._currOvers,this._currOvers=n,this._currOvers.length=0}},e.onMouseMove=function(t){this.sendMouseMove(t),this._event._stoped=!1,this.sendMouseOver(this._target)},e.sendMouseMove=function(t){t.event("mousemove",this._event.setTo("mousemove",t,this._target)),!this._event._stoped&&t.parent&&this.sendMouseMove(t.parent)},e.sendMouseOver=function(t){(t.parent||t===this._stage)&&(t._get$P("$_MOUSEOVER")||(t._set$P("$_MOUSEOVER",!0),t.event("mouseover",this._event.setTo("mouseover",t,this._target))),this._currOvers.push(t)),!this._event._stoped&&t.parent&&this.sendMouseOver(t.parent)},e.onMouseDown=function(t){Input.isInputting&&Laya.stage.focus&&Laya.stage.focus.focus&&!Laya.stage.focus.contains(this._target)&&(Laya.stage.focus.focus=!1),this._onMouseDown(t)},e._onMouseDown=function(t){this._isLeftMouse?(t._set$P("$_MOUSEDOWN",this._touchIDs[this._event.touchId]),t.event("mousedown",this._event.setTo("mousedown",t,this._target))):(t._set$P("$_RIGHTMOUSEDOWN",this._touchIDs[this._event.touchId]),t.event("rightmousedown",this._event.setTo("rightmousedown",t,this._target))),!this._event._stoped&&t.parent&&this.onMouseDown(t.parent)},e.onMouseUp=function(t){var e=this._isLeftMouse?"mouseup":"rightmouseup";this.sendMouseUp(t,e),this._event._stoped=!1,this.sendClick(this._target,e)},e.sendMouseUp=function(t,e){t.event(e,this._event.setTo(e,t,this._target)),!this._event._stoped&&t.parent&&this.sendMouseUp(t.parent,e)},e.sendClick=function(t,e){t.destroyed||("mouseup"===e&&t._get$P("$_MOUSEDOWN")===this._touchIDs[this._event.touchId]?(t._set$P("$_MOUSEDOWN",-1),t.event("click",this._event.setTo("click",t,this._target)),this._isDoubleClick&&t.event("doubleclick",this._event.setTo("doubleclick",t,this._target))):"rightmouseup"===e&&t._get$P("$_RIGHTMOUSEDOWN")===this._touchIDs[this._event.touchId]&&(t._set$P("$_RIGHTMOUSEDOWN",-1),t.event("rightclick",this._event.setTo("rightclick",t,this._target))),!this._event._stoped&&t.parent&&this.sendClick(t.parent,e))},e.check=function(t,e,i,n){var s=t.transform||this._matrix,r=t.pivotX,a=t.pivotY;if(0===r&&0===a)s.setTranslate(t.x,t.y);else if(s===this._matrix)s.setTranslate(t.x-r,t.y-a);else{var o=s.cos,h=s.sin;s.setTranslate(t.x-(r*o-a*h)*t.scaleX,t.y-(r*h+a*o)*t.scaleY)}s.invertTransformPoint(this._point.setTo(e,i)),s.setTranslate(0,0),e=this._point.x,i=this._point.y;var l=t.scrollRect;if(l){this._rect.setTo(0,0,l.width,l.height);var u=this._rect.contains(e,i);if(!u)return!1}if(!this.disableMouseEvent){var c=!1;if(t.hitTestPrior&&!t.mouseThrough&&!this.hitTest(t,e,i))return!1;for(var _=t._childs.length-1;_>-1;_--){var d=t._childs[_];if(!d.destroyed&&d.mouseEnabled&&d.visible&&(c=this.check(d,e+(l?l.x:0),i+(l?l.y:0),n)))return!0}}return u=this.hitTest(t,e,i),u?(this._target=t,n.call(this,t)):n===this.onMouseUp&&t===this._stage&&(this._target=this._stage,n.call(this,this._target)),u},e.hitTest=function(t,e,i){var n=!1;if(t.hitArea instanceof laya.utils.HitArea)return t.hitArea.isHit(e,i);if(t.width>0&&t.height>0||t.mouseThrough||t.hitArea){var s=this._rect;t.mouseThrough?n=t.getGraphicBounds().contains(e,i):(t.hitArea?s=t.hitArea:s.setTo(0,0,t.width,t.height),n=s.contains(e,i))}return n},e.runEvent=function(){var e=this._eventList.length;if(e){for(var i=this,n=0;e>n;){var s=this._eventList[n];switch("mousemove"!==s.type&&(this._prePoint.x=this._prePoint.y=-1e6),s.type){case"mousedown":this._touchIDs[0]=this._id++,t._isTouchRespond?t._isTouchRespond=!1:(i._isLeftMouse=0===s.button,i.initEvent(s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseDown));break;case"mouseup":i._isLeftMouse=0===s.button;var r=Browser.now();i._isDoubleClick=r-i._lastClickTimer<300,i._lastClickTimer=r,i.initEvent(s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseUp);break;case"mousemove":Math.abs(this._prePoint.x-s.clientX)+Math.abs(this._prePoint.y-s.clientY)>=this.mouseMoveAccuracy&&(this._prePoint.x=s.clientX,this._prePoint.y=s.clientY,i.initEvent(s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseMove),i.checkMouseOut());break;case"touchstart":t._isTouchRespond=!0,i._isLeftMouse=!0;for(var a=s.changedTouches,o=0,h=a.length;h>o;o++){var l=a[o];this._id%200===0&&(this._touchIDs={}),this._touchIDs[l.identifier]=this._id++,i.initEvent(l,s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseDown)}break;case"touchend":t._isTouchRespond=!0,i._isLeftMouse=!0,r=Browser.now(),i._isDoubleClick=r-i._lastClickTimer<300,i._lastClickTimer=r;var u=s.changedTouches;for(o=0,h=u.length;h>o;o++)i.initEvent(u[o],s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseUp);break;case"touchmove":var c=s.changedTouches;for(o=0,h=c.length;h>o;o++)i.initEvent(c[o],s),i.check(i._stage,i.mouseX,i.mouseY,i.onMouseMove);i.checkMouseOut();break;case"wheel":case"mousewheel":case"DOMMouseScroll":i.checkMouseWheel(s);break;case"mouseout":i._stage.event("mouseout",i._event.setTo("mouseout",i._stage,i._stage));break;case"mouseover":i._stage.event("mouseover",i._event.setTo("mouseover",i._stage,i._stage))}n++}this._eventList.length=0}},t.enabled=!0,t._isTouchRespond=!1,__static(t,["instance",function(){return this.instance=new t}]),t}(),Filter=function(){function t(){this._action=null}__class(t,"laya.filters.Filter");var e=t.prototype;return Laya.imps(e,{"laya.filters.IFilter":!0}),e.callNative=function(t){},__getset(0,e,"type",function(){return-1}),__getset(0,e,"action",function(){return this._action}),t.BLUR=16,t.COLOR=32,t.GLOW=8,t._filterStart=null,t._filterEnd=null,t._EndTarget=null,t._recycleScope=null,t._filter=null,t._useSrc=null,t._endSrc=null,t._useOut=null,t._endOut=null,t}(),ColorFilterAction=function(){function t(){this.data=null}__class(t,"laya.filters.ColorFilterAction");var e=t.prototype;return Laya.imps(e,{"laya.filters.IFilterAction":!0}),e.apply=function(t){var e=t.ctx.ctx,i=t.ctx.ctx.canvas;if(0==i.width||0==i.height)return i;for(var n,s=e.getImageData(0,0,i.width,i.height),r=s.data,a=0,o=r.length;o>a;a+=4)n=this.getColor(r[a],r[a+1],r[a+2],r[a+3]),0!=r[a+3]&&(r[a]=n[0],r[a+1]=n[1],r[a+2]=n[2],r[a+3]=n[3]);return e.putImageData(s,0,0),t},e.getColor=function(t,e,i,n){var s=[];if(this.data._mat&&this.data._alpha){var r=this.data._mat,a=this.data._alpha;s[0]=r[0]*t+r[1]*e+r[2]*i+r[3]*n+a[0],s[1]=r[4]*t+r[5]*e+r[6]*i+r[7]*n+a[1],s[2]=r[8]*t+r[9]*e+r[10]*i+r[11]*n+a[2],s[3]=r[12]*t+r[13]*e+r[14]*i+r[15]*n+a[3]}return s},t}(),Arith=function(){function t(){}return __class(t,"laya.maths.Arith"),t.formatR=function(t){return t>Math.PI&&(t-=2*Math.PI),t<-Math.PI&&(t+=2*Math.PI),t},t.isPOT=function(t,e){return t>0&&0===(t&t-1)&&e>0&&0===(e&e-1)},t.setMatToArray=function(t,e){t.a,t.b,t.c,t.d,t.tx+20,t.ty+20,1,e[0]=t.a,e[1]=t.b,e[4]=t.c,e[5]=t.d,e[12]=t.tx,e[13]=t.ty},t}(),Bezier=function(){function t(){this._controlPoints=[new Point,new Point,new Point],this._calFun=this.getPoint2}__class(t,"laya.maths.Bezier");var e=t.prototype;return e._switchPoint=function(t,e){var i=this._controlPoints.shift();i.setTo(t,e),this._controlPoints.push(i)},e.getPoint2=function(t,e){var i=this._controlPoints[0],n=this._controlPoints[1],s=this._controlPoints[2],r=Math.pow(1-t,2)*i.x+2*t*(1-t)*n.x+Math.pow(t,2)*s.x,a=Math.pow(1-t,2)*i.y+2*t*(1-t)*n.y+Math.pow(t,2)*s.y;e.push(r,a)},e.getPoint3=function(t,e){var i=this._controlPoints[0],n=this._controlPoints[1],s=this._controlPoints[2],r=this._controlPoints[3],a=Math.pow(1-t,3)*i.x+3*n.x*t*(1-t)*(1-t)+3*s.x*t*t*(1-t)+r.x*Math.pow(t,3),o=Math.pow(1-t,3)*i.y+3*n.y*t*(1-t)*(1-t)+3*s.y*t*t*(1-t)+r.y*Math.pow(t,3);e.push(a,o)},e.insertPoints=function(t,e){var i=NaN;t=t>0?t:5;var n=NaN;for(n=1/t,i=0;1>=i;i+=n)this._calFun(i,e)},e.getBezierPoints=function(t,e,i){void 0===e&&(e=5),void 0===i&&(i=2);var n=0,s=0;if(s=t.length,2*(i+1)>s)return[];var r;switch(r=[],i){case 2:this._calFun=this.getPoint2;break;case 3:this._calFun=this.getPoint3;break;default:return[]}for(;this._controlPoints.length<=i;)this._controlPoints.push(new Point);for(n=0;2*i>n;n+=2)this._switchPoint(t[n],t[n+1]);for(n=2*i;s>n;n+=2)this._switchPoint(t[n],t[n+1]),n/2%i==0&&this.insertPoints(e,r);return r},__static(t,["I",function(){return this.I=new t}]),t}(),GrahamScan=function(){function t(){}return __class(t,"laya.maths.GrahamScan"),t.multiply=function(t,e,i){return(t.x-i.x)*(e.y-i.y)-(e.x-i.x)*(t.y-i.y)},t.dis=function(t,e){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)},t._getPoints=function(e,i,n){for(void 0===i&&(i=!1),t._mPointList||(t._mPointList=[]);t._mPointList.lengthn;n++)t.push(e[n]);return t},t.getFromR=function(t,e,i){var n=0;for(n=0;i>n;n++)t.push(e.pop());return t},t.pListToPointList=function(e,i){void 0===i&&(i=!1);var n=0,s=e.length/2,r=t._getPoints(s,i,t._tempPointList);for(n=0;s>n;n++)r[n].setTo(e[n+n],e[n+n+1]);return r},t.pointListToPlist=function(e){var i,n=0,s=e.length,r=t._temPList;for(r.length=0,n=0;s>n;n++)i=e[n],r.push(i.x,i.y);return r},t.scanPList=function(e){return Utils.copyArray(e,t.pointListToPlist(t.scan(t.pListToPointList(e,!0))))},t.scan=function(e){var i,n,s,r=0,a=0,o=0,h=e.length,l={};for(n=t._temArr,n.length=0,h=e.length,r=h-1;r>=0;r--)i=e[r],s=i.x+"_"+i.y,l.hasOwnProperty(s)||(l[s]=!0,n.push(i));for(h=n.length,Utils.copyArray(e,n),r=1;h>r;r++)(e[r].yr;r++){for(o=r,a=r+1;h>a;a++)(t.multiply(e[a],e[o],e[0])>0||0==t.multiply(e[a],e[o],e[0])&&t.dis(e[0],e[a])r;r++){for(;n.length>=2&&t.multiply(e[r],n[n.length-1],n[n.length-2])>=0;)n.pop();e[r]&&n.push(e[r])}return n},t._mPointList=null,t._tempPointList=[],t._temPList=[],t._temArr=[],t}(),MathUtil=function(){function t(){}return __class(t,"laya.maths.MathUtil"),t.subtractVector3=function(t,e,i){i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2]},t.lerp=function(t,e,i){return t*(1-i)+e*i},t.scaleVector3=function(t,e,i){i[0]=t[0]*e,i[1]=t[1]*e,i[2]=t[2]*e},t.lerpVector3=function(t,e,i,n){var s=t[0],r=t[1],a=t[2];n[0]=s+i*(e[0]-s),n[1]=r+i*(e[1]-r),n[2]=a+i*(e[2]-a)},t.lerpVector4=function(t,e,i,n){var s=t[0],r=t[1],a=t[2],o=t[3];n[0]=s+i*(e[0]-s),n[1]=r+i*(e[1]-r),n[2]=a+i*(e[2]-a),n[3]=o+i*(e[3]-o)},t.slerpQuaternionArray=function(t,e,i,n,s,r,a){var o,h,l,u,c,_=t[e+0],d=t[e+1],f=t[e+2],p=t[e+3],g=i[n+0],m=i[n+1],v=i[n+2],y=i[n+3];return h=_*g+d*m+f*v+p*y,0>h&&(h=-h,g=-g,m=-m,v=-v,y=-y),1-h>1e-6?(o=Math.acos(h),l=Math.sin(o),u=Math.sin((1-s)*o)/l,c=Math.sin(s*o)/l):(u=1-s,c=s),r[a+0]=u*_+c*g,r[a+1]=u*d+c*m,r[a+2]=u*f+c*v,r[a+3]=u*p+c*y,r},t.getRotation=function(t,e,i,n){return Math.atan2(n-e,i-t)/Math.PI*180},t.sortBigFirst=function(t,e){return t==e?0:e>t?1:-1},t.sortSmallFirst=function(t,e){return t==e?0:e>t?-1:1},t.sortNumBigFirst=function(t,e){return parseFloat(e)-parseFloat(t)},t.sortNumSmallFirst=function(t,e){return parseFloat(t)-parseFloat(e)},t.sortByKey=function(e,i,n){void 0===i&&(i=!1),void 0===n&&(n=!0);var s;return s=i?n?t.sortNumBigFirst:t.sortBigFirst:n?t.sortNumSmallFirst:t.sortSmallFirst,function(t,i){return s(t[e],i[e])}},t}(),Matrix=function(){function t(t,e,i,n,s,r){this.cos=1,this.sin=0,this.inPool=!1,this.bTransform=!1,void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r,this._checkTransform()}__class(t,"laya.maths.Matrix");var e=t.prototype;return e.identity=function(){return this.a=this.d=1,this.b=this.tx=this.ty=this.c=0,this.bTransform=!1,this},e._checkTransform=function(){return this.bTransform=1!==this.a||0!==this.b||0!==this.c||1!==this.d},e.setTranslate=function(t,e){return this.tx=t,this.ty=e,this},e.translate=function(t,e){return this.tx+=t,this.ty+=e,this},e.scale=function(t,e){this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this.bTransform=!0},e.rotate=function(t){var e=this.cos=Math.cos(t),i=this.sin=Math.sin(t),n=this.a,s=this.c,r=this.tx;this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this.bTransform=!0},e.skew=function(t,e){var i=Math.tan(t),n=Math.tan(e),s=this.a,r=this.b;return this.a+=n*this.c,this.b+=n*this.d,this.c+=i*s,this.d+=i*r,this},e.invertTransformPoint=function(t){var e=this.a,i=this.b,n=this.c,s=this.d,r=this.tx,a=e*s-i*n,o=s/a,h=-i/a,l=-n/a,u=e/a,c=(n*this.ty-s*r)/a,_=-(e*this.ty-i*r)/a;return t.setTo(o*t.x+l*t.y+c,h*t.x+u*t.y+_)},e.transformPoint=function(t){return t.setTo(this.a*t.x+this.c*t.y+this.tx,this.b*t.x+this.d*t.y+this.ty)},e.transformPointArray=function(t,e){for(var i=t.length,n=0;i>n;n+=2){var s=t[n],r=t[n+1];e[n]=this.a*s+this.c*r+this.tx,e[n+1]=this.b*s+this.d*r+this.ty}return e},e.transformPointArrayScale=function(t,e){for(var i=t.length,n=0;i>n;n+=2){var s=t[n],r=t[n+1];e[n]=this.a*s+this.c*r,e[n+1]=this.b*s+this.d*r}return e},e.getScaleX=function(){return 0===this.b?this.a:Math.sqrt(this.a*this.a+this.b*this.b)},e.getScaleY=function(){return 0===this.c?this.d:Math.sqrt(this.c*this.c+this.d*this.d)},e.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,r=t*n-e*i;return this.a=n/r,this.b=-e/r,this.c=-i/r,this.d=t/r,this.tx=(i*this.ty-n*s)/r,this.ty=-(t*this.ty-e*s)/r,this},e.setTo=function(t,e,i,n,s,r){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=r,this},e.concat=function(t){var e=this.a,i=this.c,n=this.tx;return this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d,this.tx=n*t.a+this.ty*t.c+t.tx,this.ty=n*t.b+this.ty*t.d+t.ty,this},e.scaleEx=function(t,e){var i=this.a,n=this.b,s=this.c,r=this.d;0!==n||0!==s?(this.a=t*i,this.b=t*n,this.c=e*s,this.d=e*r):(this.a=t*i,this.b=0*r,this.c=0*i,this.d=e*r),this.bTransform=!0},e.rotateEx=function(t){var e=Math.cos(t),i=Math.sin(t),n=this.a,s=this.b,r=this.c,a=this.d;0!==s||0!==r?(this.a=e*n+i*r,this.b=e*s+i*a,this.c=-i*n+e*r,this.d=-i*s+e*a):(this.a=e*n,this.b=i*a,this.c=-i*n,this.d=e*a),this.bTransform=!0},e.clone=function(){var e=t._cache,i=e._length?e[--e._length]:new t;return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i.bTransform=this.bTransform,i},e.copyTo=function(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t.bTransform=this.bTransform,t},e.toString=function(){return this.a+","+this.b+","+this.c+","+this.d+","+this.tx+","+this.ty},e.destroy=function(){if(!this.inPool){var e=t._cache;this.inPool=!0,e._length||(e._length=0),e[e._length++]=this,this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this.bTransform=!1}},t.mul=function(t,e,i){var n=t.a,s=t.b,r=t.c,a=t.d,o=t.tx,h=t.ty,l=e.a,u=e.b,c=e.c,_=e.d,d=e.tx,f=e.ty;return 0!==u||0!==c?(i.a=n*l+s*c,i.b=n*u+s*_,i.c=r*l+a*c,i.d=r*u+a*_,i.tx=l*o+c*h+d,i.ty=u*o+_*h+f):(i.a=n*l,i.b=s*_,i.c=r*l,i.d=a*_,i.tx=l*o+d,i.ty=_*h+f),i},t.mulPre=function(t,e,i,n,s,r,a,o){var h=t.a,l=t.b,u=t.c,c=t.d,_=t.tx,d=t.ty;return 0!==i||0!==n?(o.a=h*e+l*n,o.b=h*i+l*s,o.c=u*e+c*n,o.d=u*i+c*s,o.tx=e*_+n*d+r,o.ty=i*_+s*d+a):(o.a=h*e,o.b=l*s,o.c=u*e,o.d=c*s,o.tx=e*_+r,o.ty=s*d+a),o},t.mulPos=function(t,e,i,n,s,r,a,o){var h=t.a,l=t.b,u=t.c,c=t.d,_=t.tx,d=t.ty;return 0!==l||0!==u?(o.a=e*h+i*u,o.b=e*l+i*c,o.c=n*h+s*u,o.d=n*l+s*c,o.tx=h*r+u*a+_,o.ty=l*r+c*a+d):(o.a=e*h,o.b=i*c,o.c=n*h,o.d=s*c,o.tx=h*r+_,o.ty=c*a+d),o},t.preMul=function(t,e,i){var n=t.a,s=t.b,r=t.c,a=t.d,o=e.a,h=e.b,l=e.c,u=e.d,c=e.tx,_=e.ty;return i.a=o*n,i.b=i.c=0,i.d=u*a,i.tx=c*n+t.tx,i.ty=_*a+t.ty,0===h&&0===l&&0===s&&0===r||(i.a+=h*r,i.d+=l*s,i.b+=o*s+h*a,i.c+=l*n+u*r,i.tx+=_*r,i.ty+=c*s),i},t.preMulXY=function(t,e,i,n){var s=t.a,r=t.b,a=t.c,o=t.d;return n.a=s,n.b=r,n.c=a,n.d=o,n.tx=e*s+t.tx+i*a,n.ty=i*o+t.ty+e*r,n},t.create=function(){var e=t._cache,i=e._length?e[--e._length]:new t;return i.inPool=!1,i},t.EMPTY=new t,t.TEMP=new t,t._cache=[],t}(),Point=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}__class(t,"laya.maths.Point");var e=t.prototype;return e.setTo=function(t,e){return this.x=t,this.y=e,this},e.distance=function(t,e){return Math.sqrt((this.x-t)*(this.x-t)+(this.y-e)*(this.y-e))},e.toString=function(){return this.x+","+this.y},e.normalize=function(){var t=Math.sqrt(this.x*this.x+this.y*this.y);if(t>0){var e=1/t;this.x*=e,this.y*=e}},t.TEMP=new t,t.EMPTY=new t,t}(),Rectangle=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}__class(t,"laya.maths.Rectangle");var e=t.prototype;return e.setTo=function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},e.contains=function(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&ethis.x+this.width||t.x+t.widththis.y+this.height||t.y+t.heightt&&(this.width+=this.x-t,this.x=t),this.y>e&&(this.height+=this.y-e,this.y=e),this.widthn;n+=2)l.x=e[n],l.y=e[n+1],s=sl.x?r:l.x,o=o>l.y?o:l.y;return i.setTo(s,a,r-s,o-a)},t.EMPTY=new t,t.TEMP=new t,t._temB=[],t._temA=[],t}(),SoundManager=function(){function t(){}return __class(t,"laya.media.SoundManager"),__getset(1,t,"autoStopMusic",function(){return t._autoStopMusic},function(e){Laya.stage.off("blur",null,t._stageOnBlur),Laya.stage.off("focus",null,t._stageOnFocus),t._autoStopMusic=e,e&&(Laya.stage.on("blur",null,t._stageOnBlur),Laya.stage.on("focus",null,t._stageOnFocus))}),__getset(1,t,"muted",function(){return t._muted},function(e){e&&t.stopAll(),t._muted=e}),__getset(1,t,"musicMuted",function(){return t._musicMuted},function(e){e?(t._tMusic&&t.stopSound(t._tMusic),t._musicMuted=e):(t._musicMuted=e,t._tMusic&&t.playMusic(t._tMusic))}),__getset(1,t,"soundMuted",function(){return t._soundMuted},function(e){t._soundMuted=e}),t.addChannel=function(e){t._channels.indexOf(e)>=0||t._channels.push(e)},t.removeChannel=function(e){var i=0;for(i=t._channels.length-1;i>=0;i--)t._channels[i]==e&&t._channels.splice(i,1)},t._stageOnBlur=function(){t._musicChannel&&(t._musicChannel.isStopped||(t._blurPaused=!0,t._musicLoops=t._musicChannel.loops,t._musicCompleteHandler=t._musicChannel.completeHandler,t._musicPosition=t._musicChannel.position,t._musicChannel.stop(),Laya.stage.once("mousedown",null,t._stageOnFocus)))},t._stageOnFocus=function(){Laya.stage.off("mousedown",null,t._stageOnFocus),t._blurPaused&&(t.playMusic(t._tMusic,t._musicLoops,t._musicCompleteHandler,t._musicPosition),t._blurPaused=!1)},t.playSound=function(e,i,n,s,r){if(void 0===i&&(i=1),void 0===r&&(r=0),t._muted)return null;if(e==t._tMusic){if(t._musicMuted)return null}else if(t._soundMuted)return null;var a=Laya.loader.getRes(e);s||(s=t._soundClass),a||(a=new s,a.load(e),Loader.cacheRes(e,a));var o;return o=a.play(r,i),o.url=e,o.volume=e==t._tMusic?t.musicVolume:t.soundVolume,o.completeHandler=n,o},t.destroySound=function(t){var e=Laya.loader.getRes(t);e&&(Loader.clearRes(t),e.dispose())},t.playMusic=function(e,i,n,s){return void 0===i&&(i=0),void 0===s&&(s=0),t._tMusic=e,t._musicChannel&&t._musicChannel.stop(),t._musicChannel=t.playSound(e,i,n,null,s)},t.stopSound=function(e){var i,n=0;for(n=t._channels.length-1;n>=0;n--)i=t._channels[n],i.url==e&&i.stop()},t.stopAll=function(){var e,i=0;for(i=t._channels.length-1;i>=0;i--)e=t._channels[i],e.stop()},t.stopMusic=function(){t._musicChannel&&t._musicChannel.stop()},t.setSoundVolume=function(e,i){i?t._setVolume(i,e):t.soundVolume=e},t.setMusicVolume=function(e){t.musicVolume=e,t._setVolume(t._tMusic,e)},t._setVolume=function(e,i){var n,s=0;for(s=t._channels.length-1;s>=0;s--)n=t._channels[s],n.url==e&&(n.volume=i)},t.musicVolume=1,t.soundVolume=1,t._muted=!1,t._soundMuted=!1,t._musicMuted=!1,t._tMusic=null,t._musicChannel=null,t._channels=[],t._autoStopMusic=!1,t._blurPaused=!1,t._musicLoops=0,t._musicPosition=0,t._musicCompleteHandler=null,t._soundClass=null,t}(),LocalStorage=function(){function t(){}var e;return __class(t,"laya.net.LocalStorage"),t.__init__=function(){t._baseClass||(t._baseClass=e,e.init()),t.items=t._baseClass.items,t.support=t._baseClass.support},t.setItem=function(e,i){t._baseClass.setItem(e,i)},t.getItem=function(e){return t._baseClass.getItem(e)},t.setJSON=function(e,i){t._baseClass.setJSON(e,i)},t.getJSON=function(e){return t._baseClass.getJSON(e)},t.removeItem=function(e){t._baseClass.removeItem(e)},t.clear=function(){t._baseClass.clear()},t._baseClass=null,t.items=null,t.support=!1,t.__init$=function(){e=function(){function t(){}return __class(t,""),t.init=function(){try{t.items=window.localStorage,t.setItem("laya","1"),t.removeItem("laya"),t.support=!0}catch(e){}t.support||console.log("LocalStorage is not supprot or browser is private mode.")},t.setItem=function(e,i){try{t.support&&t.items.setItem(e,i)}catch(n){console.log("set localStorage failed",n)}},t.getItem=function(e){return t.support?t.items.getItem(e):null},t.setJSON=function(e,i){try{t.support&&t.items.setItem(e,JSON.stringify(i))}catch(n){console.log("set localStorage failed",n)}},t.getJSON=function(e){return JSON.parse(t.support?t.items.getItem(e):null)},t.removeItem=function(e){t.support&&t.items.removeItem(e)},t.clear=function(){t.support&&t.items.clear()},t.items=null,t.support=!0,t}()},t}(),URL=function(){function t(e){this._url=null,this._path=null,this._url=t.formatURL(e),this._path=t.getPath(e)}__class(t,"laya.net.URL");var e=t.prototype;return __getset(0,e,"path",function(){return this._path}),__getset(0,e,"url",function(){return this._url}),t.formatURL=function(e,i){if(null!=t.customFormat&&(e=t.customFormat(e,i)),!e)return"null path";if(0===e.indexOf("data:image"))return e;if(0==Render.isConchApp&&t.version[e]&&(e+="?v="+t.version[e]),"~"==e.charAt(0))return t.rootPath+e.substring(1);if(t.isAbsolute(e))return e;var n=(i||t.basePath)+e;return t.formatRelativePath(n)},t.formatRelativePath=function(t){if(t.indexOf("../")>-1){for(var e=t.split("/"),i=0,n=e.length;n>i;i++)".."==e[i]&&(e.splice(i-1,2),i-=2);return e.join("/")}return t},t.isAbsolute=function(t){return t.indexOf(":")>0||"/"==t.charAt(0)},t.getPath=function(t){var e=t.lastIndexOf("/");return e>0?t.substr(0,e+1):""},t.getFileName=function(t){var e=t.lastIndexOf("/");return e>0?t.substr(e+1):t},t.version={},t.basePath="",t.rootPath="",t.customFormat=null,t}(),Render=function(){function t(e,i){function n(){Laya.stage._loop(),Browser.window.requestAnimationFrame(n)}this._timeId=0;var s=t._mainCanvas.source.style;s.position="absolute",s.top=s.left="0px",s.background="#000000",t._mainCanvas.source.id=t._mainCanvas.source.id||"layaCanvas";var r=laya.renders.Render.isWebGL;r&&t.WebGL.init(t._mainCanvas,e,i),(t._mainCanvas.source.nodeName||laya.renders.Render.isConchApp)&&Browser.container.appendChild(t._mainCanvas.source),t._context=new RenderContext(e,i,r?null:t._mainCanvas),t._context.ctx.setIsMainContext(),Browser.window.requestAnimationFrame(n),Laya.stage.on("blur",this,this._onBlur),Laya.stage.on("focus",this,this._onFocus)}__class(t,"laya.renders.Render");var e=t.prototype;return e._onFocus=function(){Browser.window.clearInterval(this._timeId)},e._onBlur=function(){this._timeId=Browser.window.setInterval(this._enterFrame,1e3)},e._enterFrame=function(t){Laya.stage._loop()},__getset(1,t,"isConchApp",function(){ +return 4==(4&window.ConchRenderType)}),__getset(1,t,"context",function(){return t._context}),__getset(1,t,"isConchNode",function(){return 5==(5&window.ConchRenderType)},function(t){t?window.ConchRenderType|=1:window.ConchRenderType&=-2}),__getset(1,t,"isConchWebGL",function(){return 6==window.ConchRenderType},function(e){e?(t.isConchNode=!1,window.ConchRenderType|=2):window.ConchRenderType&=-3}),__getset(1,t,"canvas",function(){return t._mainCanvas.source}),t._context=null,t._mainCanvas=null,t.WebGL=null,t.NODE=1,t.WEBGL=2,t.CONCH=4,t.isWebGL=!1,t.is3DMode=!1,t.optimizeTextureMemory=function(t,e){return!0},t.__init$=function(){window.ConchRenderType=window.ConchRenderType||1,window.ConchRenderType|=window.conch?4:0},t}(),RenderContext=function(){function t(e,i,n){this.x=0,this.y=0,this._drawTexture=function(t,e,i){i[0].loaded&&this.ctx.drawTexture(i[0],i[1],i[2],i[3],i[4],t,e)},this._fillTexture=function(t,e,i){i[0].loaded&&this.ctx.fillTexture(i[0],i[1]+t,i[2]+e,i[3],i[4],i[5],i[6],i[7])},this._drawTextureWithTransform=function(t,e,i){i[0].loaded&&this.ctx.drawTextureWithTransform(i[0],i[1],i[2],i[3],i[4],i[5],t,e,i[6])},this._fillQuadrangle=function(t,e,i){this.ctx.fillQuadrangle(i[0],i[1],i[2],i[3],i[4])},this._drawRect=function(t,e,i){var n=this.ctx;null!=i[4]&&(n.fillStyle=i[4],n.fillRect(t+i[0],e+i[1],i[2],i[3],null)),null!=i[5]&&(n.strokeStyle=i[5],n.lineWidth=i[6],n.strokeRect(t+i[0],e+i[1],i[2],i[3],i[6]))},this._drawPie=function(t,e,i){var n=this.ctx;Render.isWebGL&&n.setPathId(i[8]),n.beginPath(),Render.isWebGL?(n.movePath(i[0]+t,i[1]+e),n.moveTo(0,0)):n.moveTo(t+i[0],e+i[1]),n.arc(t+i[0],e+i[1],i[2],i[3],i[4]),n.closePath(),this._fillAndStroke(i[5],i[6],i[7],!0)},this._clipRect=function(t,e,i){this.ctx.clipRect(t+i[0],e+i[1],i[2],i[3])},this._fillRect=function(t,e,i){this.ctx.fillRect(t+i[0],e+i[1],i[2],i[3],i[4])},this._drawCircle=function(e,i,n){var s=this.ctx;Render.isWebGL&&s.setPathId(n[6]),Stat.drawCall++,s.beginPath(),Render.isWebGL&&s.movePath(n[0]+e,n[1]+i),s.arc(n[0]+e,n[1]+i,n[2],0,t.PI2),s.closePath(),this._fillAndStroke(n[3],n[4],n[5],!0)},this._fillCircle=function(e,i,n){Stat.drawCall++;var s=this.ctx;s.beginPath(),s.fillStyle=n[3],s.arc(n[0]+e,n[1]+i,n[2],0,t.PI2),s.fill()},this._setShader=function(t,e,i){this.ctx.setShader(i[0])},this._drawLine=function(t,e,i){var n=this.ctx;Render.isWebGL&&n.setPathId(i[6]),n.beginPath(),n.strokeStyle=i[4],n.lineWidth=i[5],Render.isWebGL?(n.movePath(t,e),n.moveTo(i[0],i[1]),n.lineTo(i[2],i[3])):(n.moveTo(t+i[0],e+i[1]),n.lineTo(t+i[2],e+i[3])),n.stroke()},this._drawLines=function(t,e,i){var n=this.ctx;Render.isWebGL&&n.setPathId(i[5]),n.beginPath(),t+=i[0],e+=i[1],Render.isWebGL&&n.movePath(t,e),n.strokeStyle=i[3],n.lineWidth=i[4];var s=i[2],r=2,a=s.length;if(Render.isWebGL)for(n.moveTo(s[0],s[1]);a>r;)n.lineTo(s[r++],s[r++]);else for(n.moveTo(t+s[0],e+s[1]);a>r;)n.lineTo(t+s[r++],e+s[r++]);n.stroke()},this._drawLinesWebGL=function(t,e,i){this.ctx.drawLines(t+this.x+i[0],e+this.y+i[1],i[2],i[3],i[4])},this._drawCurves=function(t,e,i){var n=this.ctx;Render.isWebGL&&n.setPathId(-1),n.beginPath(),n.strokeStyle=i[3],n.lineWidth=i[4];var s=i[2];t+=i[0],e+=i[1],n.moveTo(t+s[0],e+s[1]);for(var r=2,a=s.length;a>r;)n.quadraticCurveTo(t+s[r++],e+s[r++],t+s[r++],e+s[r++]);n.stroke()},this._draw=function(t,e,i){i[0].call(null,this,t,e)},this._transformByMatrix=function(t,e,i){this.ctx.transformByMatrix(i[0])},this._setTransform=function(t,e,i){this.ctx.setTransform(i[0],i[1],i[2],i[3],i[4],i[5])},this._setTransformByMatrix=function(t,e,i){this.ctx.setTransformByMatrix(i[0])},this._save=function(t,e,i){this.ctx.save()},this._restore=function(t,e,i){this.ctx.restore()},this._translate=function(t,e,i){this.ctx.translate(i[0],i[1])},this._transform=function(t,e,i){this.ctx.translate(i[1]+t,i[2]+e);var n=i[0];this.ctx.transform(n.a,n.b,n.c,n.d,n.tx,n.ty),this.ctx.translate(-t-i[1],-e-i[2])},this._rotate=function(t,e,i){this.ctx.translate(i[1]+t,i[2]+e),this.ctx.rotate(i[0]),this.ctx.translate(-t-i[1],-e-i[2])},this._scale=function(t,e,i){this.ctx.translate(i[2]+t,i[3]+e),this.ctx.scale(i[0],i[1]),this.ctx.translate(-t-i[2],-e-i[3])},this._alpha=function(t,e,i){this.ctx.globalAlpha*=i[0]},this._setAlpha=function(t,e,i){this.ctx.globalAlpha=i[0]},this._fillText=function(t,e,i){this.ctx.fillText(i[0],i[1]+t,i[2]+e,i[3],i[4],i[5])},this._strokeText=function(t,e,i){this.ctx.strokeText(i[0],i[1]+t,i[2]+e,i[3],i[4],i[5],i[6])},this._fillBorderText=function(t,e,i){this.ctx.fillBorderText(i[0],i[1]+t,i[2]+e,i[3],i[4],i[5],i[6],i[7])},this._blendMode=function(t,e,i){this.ctx.globalCompositeOperation=i[0]},this._beginClip=function(t,e,i){this.ctx.beginClip&&this.ctx.beginClip(t+i[0],e+i[1],i[2],i[3])},this._setIBVB=function(t,e,i){this.ctx.setIBVB(i[0]+t,i[1]+e,i[2],i[3],i[4],i[5],i[6],i[7])},this._fillTrangles=function(t,e,i){this.ctx.fillTrangles(i[0],i[1]+t,i[2]+e,i[3],i[4])},this._drawPath=function(t,e,i){var n=this.ctx;Render.isWebGL&&n.setPathId(-1),n.beginPath(),t+=i[0],e+=i[1];for(var s=i[2],r=0,a=s.length;a>r;r++){var o=s[r];switch(o[0]){case"moveTo":n.moveTo(t+o[1],e+o[2]);break;case"lineTo":n.lineTo(t+o[1],e+o[2]);break;case"arcTo":n.arcTo(t+o[1],e+o[2],t+o[3],e+o[4],o[5]);break;case"closePath":n.closePath()}}var h=i[3];null!=h&&(n.fillStyle=h.fillStyle,n.fill());var l=i[4];null!=l&&(n.strokeStyle=l.strokeStyle,n.lineWidth=l.lineWidth||1,n.lineJoin=l.lineJoin,n.lineCap=l.lineCap,n.miterLimit=l.miterLimit,n.stroke())},this.drawPoly=function(t,e,i){this.ctx.drawPoly(t+this.x+i[0],e+this.y+i[1],i[2],i[3],i[4],i[5],i[6])},this._drawPoly=function(t,e,i){var n=this.ctx,s=i[2],r=2,a=s.length;if(Render.isWebGL)for(n.setPathId(i[6]),n.beginPath(),t+=i[0],e+=i[1],n.movePath(t,e),n.moveTo(s[0],s[1]);a>r;)n.lineTo(s[r++],s[r++]);else for(n.beginPath(),t+=i[0],e+=i[1],n.moveTo(t+s[0],e+s[1]);a>r;)n.lineTo(t+s[r++],e+s[r++]);n.closePath(),this._fillAndStroke(i[3],i[4],i[5],i[7])},this._drawSkin=function(t,e,i){var n=i[0];if(n){var s=this.ctx;n.render(s,t,e)}},this._drawParticle=function(t,e,i){this.ctx.drawParticle(t+this.x,e+this.y,i[0])},n?this.ctx=n.getContext("2d"):(n=HTMLCanvas.create("3D"),this.ctx=RunDriver.createWebGLContext2D(n),n._setContext(this.ctx)),n.size(e,i),this.canvas=n}__class(t,"laya.renders.RenderContext");var e=t.prototype;return e.destroy=function(){this.canvas&&(this.canvas.destroy(),this.canvas=null),this.ctx&&(this.ctx.destroy(),this.ctx=null)},e.drawTexture=function(t,e,i,n,s){t.loaded&&this.ctx.drawTexture(t,e,i,n,s,this.x,this.y)},e._drawTextures=function(t,e,i){i[0].loaded&&this.ctx.drawTextures(i[0],i[1],t+this.x,e+this.y)},e.drawTextureWithTransform=function(t,e,i,n,s,r,a){t.loaded&&this.ctx.drawTextureWithTransform(t,e,i,n,s,r,this.x,this.y,a)},e.fillQuadrangle=function(t,e,i,n,s){this.ctx.fillQuadrangle(t,e,i,n,s)},e.drawCanvas=function(t,e,i,n,s){this.ctx.drawCanvas(t,e+this.x,i+this.y,n,s)},e.drawRect=function(t,e,i,n,s,r){void 0===r&&(r=1);var a=this.ctx;a.strokeStyle=s,a.lineWidth=r,a.strokeRect(t+this.x,e+this.y,i,n,r)},e._fillAndStroke=function(t,e,i,n){void 0===n&&(n=!1);var s=this.ctx;null!=t&&(s.fillStyle=t,Render.isWebGL?s.fill(n):s.fill()),null!=e&&i>0&&(s.strokeStyle=e,s.lineWidth=i,s.stroke())},e.clipRect=function(t,e,i,n){this.ctx.clipRect(t+this.x,e+this.y,i,n)},e.fillRect=function(t,e,i,n,s){this.ctx.fillRect(t+this.x,e+this.y,i,n,s)},e.drawCircle=function(e,i,n,s,r){void 0===r&&(r=1),Stat.drawCall++;var a=this.ctx;a.beginPath(),a.strokeStyle=s,a.lineWidth=r,a.arc(e+this.x,i+this.y,n,0,t.PI2),a.stroke()},e.fillCircle=function(e,i,n,s){Stat.drawCall++;var r=this.ctx;r.beginPath(),r.fillStyle=s,r.arc(e+this.x,i+this.y,n,0,t.PI2),r.fill()},e.setShader=function(t){this.ctx.setShader(t)},e.drawLine=function(t,e,i,n,s,r){void 0===r&&(r=1);var a=this.ctx;a.beginPath(),a.strokeStyle=s,a.lineWidth=r,a.moveTo(this.x+t,this.y+e),a.lineTo(this.x+i,this.y+n),a.stroke()},e.clear=function(){this.ctx.clear()},e.transformByMatrix=function(t){this.ctx.transformByMatrix(t)},e.setTransform=function(t,e,i,n,s,r){this.ctx.setTransform(t,e,i,n,s,r)},e.setTransformByMatrix=function(t){this.ctx.setTransformByMatrix(t)},e.save=function(){this.ctx.save()},e.restore=function(){this.ctx.restore()},e.translate=function(t,e){this.ctx.translate(t,e)},e.transform=function(t,e,i,n,s,r){this.ctx.transform(t,e,i,n,s,r)},e.rotate=function(t){this.ctx.rotate(t)},e.scale=function(t,e){this.ctx.scale(t,e)},e.alpha=function(t){this.ctx.globalAlpha*=t},e.setAlpha=function(t){this.ctx.globalAlpha=t},e.fillWords=function(t,e,i,n,s){this.ctx.fillWords(t,e,i,n,s)},e.fillText=function(t,e,i,n,s,r){this.ctx.fillText(t,e+this.x,i+this.y,n,s,r)},e.strokeText=function(t,e,i,n,s,r,a){this.ctx.strokeText(t,e+this.x,i+this.y,n,s,r,a)},e.blendMode=function(t){this.ctx.globalCompositeOperation=t},e.flush=function(){this.ctx.flush&&this.ctx.flush()},e.addRenderObject=function(t){this.ctx.addRenderObject(t)},e.beginClip=function(t,e,i,n){this.ctx.beginClip&&this.ctx.beginClip(t,e,i,n)},e.endClip=function(){this.ctx.endClip&&this.ctx.endClip()},e.fillTrangles=function(t,e,i){this.ctx.fillTrangles(i[0],i[1],i[2],i[3],i.length>4?i[4]:null)},t.PI2=2*Math.PI,t}(),RenderSprite=function(){function t(e,i){switch(this._next=i||t.NORENDER,e){case 0:return void(this._fun=this._no);case 1:return void(this._fun=this._image);case 2:return void(this._fun=this._alpha);case 4:return void(this._fun=this._transform);case 32:return void(this._fun=this._blend);case 8:return void(this._fun=this._canvas);case 64:return void(this._fun=this._clip);case 128:return void(this._fun=this._style);case 256:return void(this._fun=this._graphics);case 2048:return void(this._fun=this._childs);case 512:return void(this._fun=this._custom);case 257:return void(this._fun=this._image2);case 261:return void(this._fun=this._image2);case 16:return void(this._fun=Filter._filter);case 69905:return void(this._fun=t._initRenderFun)}this.onCreate(e)}__class(t,"laya.renders.RenderSprite");var e=t.prototype;return e.onCreate=function(t){},e._style=function(t,e,i,n){t._style.render(t,e,i,n);var s=this._next;s._fun.call(s,t,e,i,n)},e._no=function(t,e,i,n){},e._custom=function(t,e,i,n){t.customRender(e,i,n);var s=t._style._tf;this._next._fun.call(this._next,t,e,i-s.translateX,n-s.translateY)},e._clip=function(e,i,n,s){var r=this._next;if(r!=t.NORENDER){var a=e._style.scrollRect;i.ctx.save(),i.ctx.clipRect(n,s,a.width,a.height),r._fun.call(r,e,i,n-a.x,s-a.y),i.ctx.restore()}},e._blend=function(t,e,i,n){var s=t._style;s.blendMode&&(e.ctx.globalCompositeOperation=s.blendMode);var r=this._next;r._fun.call(r,t,e,i,n);var a=t.mask;a&&(e.ctx.globalCompositeOperation="destination-in",(a.numChildren>0||!a.graphics._isOnlyOne())&&(a.cacheAsBitmap=!0),a.render(e,i,n)),e.ctx.globalCompositeOperation="source-over"},e._graphics=function(t,e,i,n){var s=t._style._tf;t._graphics&&t._graphics._render(t,e,i-s.translateX,n-s.translateY);var r=this._next;r._fun.call(r,t,e,i,n)},e._image=function(t,e,i,n){var s=t._style;e.ctx.drawTexture2(i,n,s._tf.translateX,s._tf.translateY,t.transform,s.alpha,s.blendMode,t._graphics._one)},e._image2=function(t,e,i,n){var s=t._style._tf;e.ctx.drawTexture2(i,n,s.translateX,s.translateY,t.transform,1,null,t._graphics._one)},e._alpha=function(t,e,i,n){var s,r=t._style;if((s=r.alpha)>.01){var a=e.ctx.globalAlpha;e.ctx.globalAlpha*=s;var o=this._next;o._fun.call(o,t,e,i,n),e.ctx.globalAlpha=a}},e._transform=function(e,i,n,s){var r=e.transform,a=this._next;r&&a!=t.NORENDER?(i.save(),i.transform(r.a,r.b,r.c,r.d,r.tx+n,r.ty+s),a._fun.call(a,e,i,0,0),i.restore()):a._fun.call(a,e,i,n,s)},e._childs=function(t,e,i,n){var s=t._style;if(i+=-s._tf.translateX+s.paddingLeft,n+=-s._tf.translateY+s.paddingTop,s._calculation){var r=t._getWords();r&&e.fillWords(r,i,n,s.font,s.color)}var a,o=t._childs,h=o.length;if(t.viewport&&t.optimizeScrollRect){var l=t.viewport,u=l.x,c=l.y,_=l.right,d=l.bottom,f=NaN,p=NaN;for(g=0;h>g;++g)(a=o[g]).visible&&(f=a._x)<_&&f+a.width>u&&(p=a._y)c&&a.render(e,i,n)}else for(var g=0;h>g;++g)(a=o[g])._style.visible&&a.render(e,i,n)},e._canvas=function(t,e,i,n){var s=t._$P.cacheCanvas,r=this._next;if(!s)return void r._fun.call(r,t,u,i,n);var a,o,h,l,u=s.ctx,c=t._needRepaint()||!u;if("bitmap"===s.type?Stat.canvasBitmap++:Stat.canvasNormal++,c){s._cacheRec||(s._cacheRec=new Rectangle);var _,d;l=t.getSelfBounds(),l.x-=t.pivotX,l.y-=t.pivotY,l.x-=10,l.y-=10,l.width+=20,l.height+=20,l.x=Math.floor(l.x+i)-i,l.y=Math.floor(l.y+n)-n,l.width=Math.floor(l.width),l.height=Math.floor(l.height),s._cacheRec.copyFrom(l),l=s._cacheRec;var f=Render.isWebGL?1:Browser.pixelRatio*Laya.stage.clientScaleX,p=Render.isWebGL?1:Browser.pixelRatio*Laya.stage.clientScaleY;if(!Render.isWebGL){var g,m=1,v=1;for(g=t;g&&g!=Laya.stage;)m*=g.scaleX,v*=g.scaleY,g=g.parent;Render.isWebGL?(1>m&&(f*=m),1>v&&(p*=v)):(m>1&&(f*=m),v>1&&(p*=v))}if(_=l.width*f,d=l.height*p,o=l.x,h=l.y,Render.isWebGL&&"bitmap"===s.type&&(_>2048||d>2048))return console.log("cache bitmap size larger than 2048,cache ignored"),s.ctx&&(Pool.recover("RenderContext",s.ctx),s.ctx=null),void r._fun.call(r,t,e,i,n);u||(u=s.ctx=Pool.getItem("RenderContext")||new RenderContext(_,d,HTMLCanvas.create("AUTO")),u.ctx.sprite=t),a=u.canvas,"bitmap"===s.type&&(a.context.asBitmap=!0),a.clear(),(a.width!=_||a.height!=d)&&a.size(_,d);var y;if(1!=f||1!=p){var x=u.ctx;x.save(),x.scale(f,p),!Render.isConchWebGL&&Render.isConchApp&&(y=t._$P.cf,y&&x.setFilterMatrix&&x.setFilterMatrix(y._mat,y._alpha)),r._fun.call(r,t,u,-o,-h),x.restore(),Render.isConchApp&&!Render.isConchWebGL||t._applyFilters()}else x=u.ctx,!Render.isConchWebGL&&Render.isConchApp&&(y=t._$P.cf,y&&x.setFilterMatrix&&x.setFilterMatrix(y._mat,y._alpha)),r._fun.call(r,t,u,-o,-h),Render.isConchApp&&!Render.isConchWebGL||t._applyFilters();t._$P.staticCache&&(s.reCache=!1),Stat.canvasReCache++}else l=s._cacheRec,o=l.x,h=l.y,a=u.canvas;e.drawCanvas(a,i+o,n+h,l.width,l.height)},t.__init__=function(){function e(e,i){for(var n=0,s=0;sn;n++)t.renders[n]=i;t.renders[0]=RunDriver.createRenderSprite(0,null),e([1,256,4,2],new t(1,null)),t.renders[257]=RunDriver.createRenderSprite(257,null),t.renders[261]=new t(261,null)},t._initRenderFun=function(e,i,n,s){var r=e._renderType,a=t.renders[r]=t._getTypeRender(r);a._fun(e,i,n,s)},t._getTypeRender=function(t){for(var e=null,i=2048;i>1;)i&t&&(e=RunDriver.createRenderSprite(i,e)),i>>=1;return e},t.IMAGE=1,t.ALPHA=2,t.TRANSFORM=4,t.CANVAS=8,t.FILTERS=16,t.BLEND=32,t.CLIP=64,t.STYLE=128,t.GRAPHICS=256,t.CUSTOM=512,t.CHILDS=2048,t.INIT=69905,t.renders=[],t.NORENDER=new t(0,null),t}(),Context=function(){function t(){this._repaint=!1}__class(t,"laya.resource.Context");var e=t.prototype;return e.setIsMainContext=function(){},e.drawTextures=function(t,e,i,n){Stat.drawCall+=e.length/2;for(var s=t.bitmap.width,r=t.bitmap.height,a=0,o=e.length;o>a;a+=2)this.drawTexture(t,e[a],e[a+1],s,r,i,n)},e.drawCanvas=function(t,e,i,n,s){Stat.drawCall++,this.drawImage(t.source,e,i,n,s)},e.fillRect=function(t,e,i,n,s){Stat.drawCall++,s&&(this.fillStyle=s),this.__fillRect(t,e,i,n)},e.fillText=function(t,e,i,n,s,r){Stat.drawCall++,arguments.length>3&&null!=n&&(this.font=n,this.fillStyle=s,this.textAlign=r,this.textBaseline="top"),this.__fillText(t,e,i)},e.fillBorderText=function(t,e,i,n,s,r,a,o){Stat.drawCall++,this.font=n,this.fillStyle=s,this.textBaseline="top",this.strokeStyle=r,this.lineWidth=a,this.textAlign=o,this.__strokeText(t,e,i),this.__fillText(t,e,i)},e.strokeText=function(t,e,i,n,s,r,a){Stat.drawCall++,arguments.length>3&&null!=n&&(this.font=n,this.strokeStyle=s,this.lineWidth=r,this.textAlign=a,this.textBaseline="top"),this.__strokeText(t,e,i)},e.transformByMatrix=function(t){this.transform(t.a,t.b,t.c,t.d,t.tx,t.ty)},e.setTransformByMatrix=function(t){this.setTransform(t.a,t.b,t.c,t.d,t.tx,t.ty)},e.clipRect=function(t,e,i,n){Stat.drawCall++,this.beginPath(),this.rect(t,e,i,n),this.clip()},e.drawTexture=function(t,e,i,n,s,r,a){Stat.drawCall++;var o=t.uv,h=t.bitmap.width,l=t.bitmap.height;this.drawImage(t.source,o[0]*h,o[1]*l,(o[2]-o[0])*h,(o[5]-o[3])*l,e+r,i+a,n,s)},e.drawTextureWithTransform=function(t,e,i,n,s,r,a,o,h){Stat.drawCall++;var l=t.uv,u=t.bitmap.width,c=t.bitmap.height;this.save(),1!=h&&(this.globalAlpha*=h),r?(this.transform(r.a,r.b,r.c,r.d,r.tx+a,r.ty+o),this.drawImage(t.source,l[0]*u,l[1]*c,(l[2]-l[0])*u,(l[5]-l[3])*c,e,i,n,s)):this.drawImage(t.source,l[0]*u,l[1]*c,(l[2]-l[0])*u,(l[5]-l[3])*c,e+a,i+o,n,s),this.restore()},e.drawTexture2=function(t,e,i,n,s,r,a,o){"use strict";var h=o[0];if(h.loaded&&h.bitmap&&h.source){Stat.drawCall++;var l=1!==r;if(l){var u=this.globalAlpha;this.globalAlpha*=r}var c=h.uv,_=h.bitmap.width,d=h.bitmap.height;s?(this.save(),this.transform(s.a,s.b,s.c,s.d,s.tx+t,s.ty+e),this.drawImage(h.source,c[0]*_,c[1]*d,(c[2]-c[0])*_,(c[5]-c[3])*d,o[1]-i,o[2]-n,o[3],o[4]),this.restore()):this.drawImage(h.source,c[0]*_,c[1]*d,(c[2]-c[0])*_,(c[5]-c[3])*d,o[1]-i+t,o[2]-n+e,o[3],o[4]),l&&(this.globalAlpha=u)}},e.fillTexture=function(t,e,i,n,s,r,a,o){if(!o.pat){if(t.uv!=Texture.DEF_UV){var h=new HTMLCanvas("2D");h.getContext("2d"),h.size(t.width,t.height),h.context.drawTexture(t,0,0,t.width,t.height,0,0),t=new Texture(h)}o.pat=this.createPattern(t.bitmap.source,r)}var l=e,u=i,c=0,_=0;a&&(l+=a.x%t.width,u+=a.y%t.height,c-=a.x%t.width,_-=a.y%t.height),this.translate(l,u),this.fillRect(c,_,n,s,o.pat),this.translate(-l,-u)},e.flush=function(){return 0},e.fillWords=function(t,e,i,n,s){n&&(this.font=n),s&&(this.fillStyle=s);this.textBaseline="top",this.textAlign="left";for(var r=0,a=t.length;a>r;r++){var o=t[r];this.__fillText(o["char"],o.x+e,o.y+i)}},e.destroy=function(){this.canvas.width=this.canvas.height=0},e.clear=function(){this.clearRect(0,0,this._canvas.width,this._canvas.height),this._repaint=!1},t.__init__=function(t){var e=laya.resource.Context.prototype;t=t||CanvasRenderingContext2D.prototype,t.__fillText=t.fillText,t.__fillRect=t.fillRect,t.__strokeText=t.strokeText;var i=["drawTextures","fillWords","setIsMainContext","fillRect","strokeText","fillTexture","fillText","transformByMatrix","setTransformByMatrix","clipRect","drawTexture","drawTexture2","drawTextureWithTransform","flush","clear","destroy","drawCanvas","fillBorderText"];i.forEach(function(i){t[i]=e[i]||t[i]})},t._default=new t,t}(),ResourceManager=function(){function t(){this._id=0,this._name=null,this._resources=null,this._memorySize=0,this._garbageCollectionRate=NaN,this._isOverflow=!1,this.autoRelease=!1,this.autoReleaseMaxSize=0,this._id=++t._uniqueIDCounter,this._name="Content Manager",t._isResourceManagersSorted=!1,this._memorySize=0,this._isOverflow=!1,this.autoRelease=!1,this.autoReleaseMaxSize=536870912,this._garbageCollectionRate=.2,t._resourceManagers.push(this),this._resources=[]}__class(t,"laya.resource.ResourceManager");var e=t.prototype;return Laya.imps(e,{"laya.resource.IDispose":!0}),e.getResourceByIndex=function(t){return this._resources[t]},e.getResourcesLength=function(){return this._resources.length},e.addResource=function(t){t.resourceManager&&t.resourceManager.removeResource(t);var e=this._resources.indexOf(t);return-1===e?(t._resourceManager=this,this._resources.push(t),this.addSize(t.memorySize),!0):!1},e.removeResource=function(t){var e=this._resources.indexOf(t);return-1!==e?(this._resources.splice(e,1),t._resourceManager=null,this._memorySize-=t.memorySize,!0):!1},e.unload=function(){for(var t=this._resources.slice(0,this._resources.length),e=0;e0&&this._memorySize+t>this.autoReleaseMaxSize&&this.garbageCollection((1-this._garbageCollectionRate)*this.autoReleaseMaxSize),this._memorySize+=t)},e.garbageCollection=function(t){var e=this._resources;e=e.slice(),e.sort(function(t,e){if(!t||!e)throw new Error("a或b不能为空!");return t.released&&e.released?0:t.released?1:e.released?-1:t.lastUseFrameCount-e.lastUseFrameCount});for(var i=Stat.loopCount,n=0,s=e.length;s>n;n++){var r=e[n];if(!(i-r.lastUseFrameCount>1))return void(this._memorySize>=t&&(this._isOverflow=!0));if(r.releaseResource(),this._memorySize-1,t.onIPhone=t.u.indexOf("iPhone")>-1,t.onIPad=t.u.indexOf("iPad")>-1,t.onAndriod=t.u.indexOf("Android")>-1||t.u.indexOf("Adr")>-1,t.onWP=t.u.indexOf("Windows Phone")>-1,t.onQQBrowser=t.u.indexOf("QQBrowser")>-1,t.onMQQBrowser=t.u.indexOf("MQQBrowser")>-1,t.onWeiXin=t.u.indexOf("MicroMessenger")>-1,t.onPC=!t.onMobile,t.onSafari=!!t.u.match(/Version\/\d+\.\d\x20Mobile\/\S+\x20Safari/),t.httpProtocol="http:"==t.window.location.protocol,t.webAudioEnabled=!!(t.window.AudioContext||t.window.webkitAudioContext||t.window.mozAudioContext),t.soundType=t.webAudioEnabled?"WEBAUDIOSOUND":"AUDIOSOUND",Sound=t.webAudioEnabled?WebAudioSound:AudioSound,t.webAudioEnabled&&WebAudioSound.initWebAudio(),t.enableTouch="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,window.focus(),SoundManager._soundClass=Sound;var o=null;if(t.window.MainCanvasID){var h=wx;if(h&&!h.createContext&&(h=null),null!=(WXCanvas.wx=h)){o=new WXCanvas(t.window.MainCanvasID);var l=Context.prototype;l.flush=null,t.window.Image=function(){this.setSrc=function(t){this.__src=t;this.success()},this.success=function(t){this.width=200,this.height=200,this.tempFilePath=t?t.tempFilePath:this.__src,this.onload&&this.onload()},this.getSrc=function(){return this.__src},Object.defineProperty(this,"src",{get:this.getSrc,set:this.setSrc,enumerable:!1})}}else o=t.document.getElementById(t.window.MainCanvasID)}Render._mainCanvas=Render._mainCanvas||HTMLCanvas.create("2D",o),t.canvas||(t.canvas=HTMLCanvas.create("2D"),t.context=t.canvas.getContext("2d"))}},t._onMessage=function(e){if(e.data&&"size"==e.data.name){if(t.window.innerWidth=e.data.width,t.window.innerHeight=e.data.height,t.window.__innerHeight=e.data.clientHeight,!t.document.createEvent)return void console.log("no document.createEvent");var i=t.document.createEvent("HTMLEvents");return i.initEvent("resize",!1,!1),void t.window.dispatchEvent(i)}},t.createElement=function(e){return t.__init__(),t.document.__createElement(e)},t.getElementById=function(e){return t.__init__(),t.document.getElementById(e)},t.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},t.now=function(){return RunDriver.now()},t._window=null,t._document=null,t._container=null,t.userAgent=null,t.u=null,t.onIOS=!1,t.onMobile=!1,t.onIPhone=!1,t.onIPad=!1,t.onAndriod=!1,t.onWP=!1,t.onQQBrowser=!1,t.onMQQBrowser=!1,t.onSafari=!1,t.onWeiXin=!1,t.onPC=!1,t.httpProtocol=!1,t.webAudioEnabled=!1,t.soundType=null,t.enableTouch=!1,t.canvas=null,t.context=null,t.__init$=function(){},t}(),Byte=function(){function t(t){this._xd_=!0,this._allocated_=8,this._pos_=0,this._length=0,t?(this._u8d_=new Uint8Array(t),this._d_=new DataView(this._u8d_.buffer),this._length=this._d_.byteLength):this.___resizeBuffer(this._allocated_)}__class(t,"laya.utils.Byte");var e=t.prototype;return e.___resizeBuffer=function(t){try{var e=new Uint8Array(t);null!=this._u8d_&&(this._u8d_.length<=t?e.set(this._u8d_):e.set(this._u8d_.subarray(0,t))),this._u8d_=e,this._d_=new DataView(e.buffer)}catch(i){throw"___resizeBuffer err:"+t}},e.getString=function(){return this.rUTF(this.getUint16())},e.getFloat32Array=function(t,e){var i=new Float32Array(this._d_.buffer.slice(t,t+e));return this._pos_+=e,i},e.getUint8Array=function(t,e){var i=new Uint8Array(this._d_.buffer.slice(t,t+e));return this._pos_+=e,i},e.getInt16Array=function(t,e){var i=new Int16Array(this._d_.buffer.slice(t,t+e));return this._pos_+=e,i},e.getFloat32=function(){var t=this._d_.getFloat32(this._pos_,this._xd_);return this._pos_+=4,t},e.getFloat64=function(){var t=this._d_.getFloat64(this._pos_,this._xd_);return this._pos_+=8,t},e.writeFloat32=function(t){this.ensureWrite(this._pos_+4),this._d_.setFloat32(this._pos_,t,this._xd_),this._pos_+=4},e.writeFloat64=function(t){this.ensureWrite(this._pos_+8),this._d_.setFloat64(this._pos_,t,this._xd_),this._pos_+=8},e.getInt32=function(){var t=this._d_.getInt32(this._pos_,this._xd_);return this._pos_+=4,t},e.getUint32=function(){var t=this._d_.getUint32(this._pos_,this._xd_);return this._pos_+=4,t},e.writeInt32=function(t){this.ensureWrite(this._pos_+4),this._d_.setInt32(this._pos_,t,this._xd_),this._pos_+=4},e.writeUint32=function(t){this.ensureWrite(this._pos_+4),this._d_.setUint32(this._pos_,t,this._xd_),this._pos_+=4},e.getInt16=function(){var t=this._d_.getInt16(this._pos_,this._xd_);return this._pos_+=2,t},e.getUint16=function(){var t=this._d_.getUint16(this._pos_,this._xd_);return this._pos_+=2,t},e.writeUint16=function(t){this.ensureWrite(this._pos_+2),this._d_.setUint16(this._pos_,t,this._xd_),this._pos_+=2},e.writeInt16=function(t){this.ensureWrite(this._pos_+2),this._d_.setInt16(this._pos_,t,this._xd_),this._pos_+=2},e.getUint8=function(){return this._d_.getUint8(this._pos_++)},e.writeUint8=function(t){this.ensureWrite(this._pos_+1),this._d_.setUint8(this._pos_,t,this._xd_),this._pos_++},e._getUInt8=function(t){return this._d_.getUint8(t)},e._getUint16=function(t){return this._d_.getUint16(t,this._xd_)},e._getMatrix=function(){var t=new Matrix(this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32());return t},e.rUTF=function(t){for(var e="",i=this._pos_+t,n=0,s=0,r=0,a=String.fromCharCode,o=this._u8d_,h=0;this._pos_n?0!=n&&(e+=a(n)):224>n?e+=a((63&n)<<6|127&o[this._pos_++]):240>n?(s=o[this._pos_++], +e+=a((31&n)<<12|(127&s)<<6|127&o[this._pos_++])):(s=o[this._pos_++],r=o[this._pos_++],e+=a((15&n)<<18|(127&s)<<12|r<<6&127|127&o[this._pos_++])),h++;return e},e.getCustomString=function(t){for(var e="",i=0,n=0,s=0,r=String.fromCharCode,a=this._u8d_;t>0;)if(n=a[this._pos_],128>n)e+=r(n),this._pos_++,t--;else for(i=n-128,this._pos_++,t-=i;i>0;)n=a[this._pos_++],s=a[this._pos_++],e+=r(s<<8|n),i--;return e},e.clear=function(){this._pos_=0,this.length=0},e.__getBuffer=function(){return this._d_.buffer},e.writeUTFBytes=function(t){t+="";for(var e=0,i=t.length;i>e;e++){var n=t.charCodeAt(e);127>=n?this.writeByte(n):2047>=n?(this.writeByte(192|n>>6),this.writeByte(128|63&n)):65535>=n?(this.writeByte(224|n>>12),this.writeByte(128|n>>6&63),this.writeByte(128|63&n)):(this.writeByte(240|n>>18),this.writeByte(128|n>>12&63),this.writeByte(128|n>>6&63),this.writeByte(128|63&n))}},e.writeUTFString=function(t){var e=0;e=this.pos,this.writeUint16(1),this.writeUTFBytes(t);var i=0;i=this.pos-e-2,this._d_.setUint16(e,i,this._xd_)},e.readUTFString=function(){var t=0;t=this.pos;var e=0;return e=this.getUint16(),this.readUTFBytes(e)},e.getUTFString=function(){return this.readUTFString()},e.readUTFBytes=function(t){return void 0===t&&(t=-1),0==t?"":(t=t>0?t:this.bytesAvailable,this.rUTF(t))},e.getUTFBytes=function(t){return void 0===t&&(t=-1),this.readUTFBytes(t)},e.writeByte=function(t){this.ensureWrite(this._pos_+1),this._d_.setInt8(this._pos_,t),this._pos_+=1},e.readByte=function(){return this._d_.getInt8(this._pos_++)},e.getByte=function(){return this.readByte()},e.ensureWrite=function(t){this._lengthe||0>i)throw"writeArrayBuffer error - Out of bounds";0==i&&(i=t.byteLength-e),this.ensureWrite(this._pos_+i);var n=new Uint8Array(t);this._u8d_.set(n.subarray(e,e+i),this._pos_),this._pos_+=i},__getset(0,e,"buffer",function(){var t=this._d_.buffer;return t.byteLength==this.length?t:t.slice(0,this.length)}),__getset(0,e,"endian",function(){return this._xd_?"littleEndian":"bigEndian"},function(t){this._xd_="littleEndian"==t}),__getset(0,e,"length",function(){return this._length},function(t){this._allocated_t&&this.___resizeBuffer(this._allocated_=t),this._length=t}),__getset(0,e,"pos",function(){return this._pos_},function(t){this._pos_=t,this._d_.byteOffset=t}),__getset(0,e,"bytesAvailable",function(){return this.length-this._pos_}),t.getSystemEndian=function(){if(!t._sysEndian){var e=new ArrayBuffer(2);new DataView(e).setInt16(0,256,!0),t._sysEndian=256===new Int16Array(e)[0]?"littleEndian":"bigEndian"}return t._sysEndian},t.BIG_ENDIAN="bigEndian",t.LITTLE_ENDIAN="littleEndian",t._sysEndian=null,t}(),CacheManger=function(){function t(){}return __class(t,"laya.utils.CacheManger"),t.regCacheByFunction=function(e,i){t.unRegCacheByFunction(e,i);var n;n={tryDispose:e,getCacheList:i},t._cacheList.push(n)},t.unRegCacheByFunction=function(e,i){var n=0,s=0;for(s=t._cacheList.length,n=0;s>n;n++)if(t._cacheList[n].tryDispose==e&&t._cacheList[n].getCacheList==i)return void t._cacheList.splice(n,1)},t.forceDispose=function(){var e=0,i=t._cacheList.length;for(e=0;i>e;e++)t._cacheList[e].tryDispose(!0)},t.beginCheck=function(e){void 0===e&&(e=15e3),Laya.timer.loop(e,null,t._checkLoop)},t.stopCheck=function(){Laya.timer.clear(null,t._checkLoop)},t._checkLoop=function(){var e=t._cacheList;if(!(e.length<1)){var i=Browser.now(),n=0,s=0;for(s=n=e.length;n>0&&(t._index++,t._index=t._index%s,e[t._index].tryDispose(!1),!(Browser.now()-i>t.loopTimeLimit));)n--}},t.loopTimeLimit=2,t._cacheList=[],t._index=0,t}(),ClassUtils=function(){function t(){}return __class(t,"laya.utils.ClassUtils"),t.regClass=function(e,i){t._classMap[e]=i},t.getRegClass=function(e){return t._classMap[e]},t.getInstance=function(e){var i=t.getClass(e);return i?new i:(console.log("[error] Undefined class:",e),null)},t.createByJson=function(e,i,n,s,r){"string"==typeof e&&(e=JSON.parse(e));var a=e.props;if(!i&&(i=r?r.runWith(e):t.getInstance(a.runtime||e.type),!i))return null;var o=e.child;if(o)for(var h=0,l=o.length;l>h;h++){var u=o[h];if("render"!==u.props.name&&"render"!==u.props.renderType||!i._$set_itemRender)if("Graphic"==u.type)t.addGraphicsToSprite(u,i);else if(t.isDrawType(u.type))t.addGraphicToSprite(u,i,!0);else{var c=t.createByJson(u,null,n,s,r);"Script"==u.type?c.owner=i:"mask"==u.props.renderType?i.mask=c:i.addChild(c)}else i.itemRender=u}if(a)for(var _ in a){var d=a[_];"var"===_&&n?n[d]=i:d instanceof Array&&"function"==typeof i[_]?i[_].apply(i,d):i[_]=d}return s&&e.customProps&&s.runWith([i,e]),i.created&&i.created(),i},t.addGraphicsToSprite=function(e,i){var n;if(n=e.child,n&&!(n.length<1)){var s;s=t._getGraphicsFromSprite(e,i);var r=0,a=0;e.props&&(r=t._getObjVar(e.props,"x",0),a=t._getObjVar(e.props,"y",0)),0!=r&&0!=a&&s.translate(r,a);var o=0,h=0;for(h=n.length,o=0;h>o;o++)t._addGraphicToGraphics(n[o],s);0!=r&&0!=a&&s.translate(-r,-a)}},t.addGraphicToSprite=function(e,i,n){void 0===n&&(n=!1);var s;s=n?t._getGraphicsFromSprite(e,i):i.graphics,t._addGraphicToGraphics(e,s)},t._getGraphicsFromSprite=function(t,e){var i;if(!t||!t.props)return e.graphics;var n;switch(n=t.props.renderType){case"hit":case"unHit":var s;e.hitArea||(e.hitArea=new HitArea),s=e.hitArea,s[n]||(s[n]=new Graphics),i=s[n]}return i||(i=e.graphics),i},t._getTransformData=function(e){var i;(e.hasOwnProperty("pivotX")||e.hasOwnProperty("pivotY"))&&(i=i||new Matrix,i.translate(-t._getObjVar(e,"pivotX",0),-t._getObjVar(e,"pivotY",0)));var n=t._getObjVar(e,"scaleX",1),s=t._getObjVar(e,"scaleY",1),r=t._getObjVar(e,"rotation",0);t._getObjVar(e,"skewX",0),t._getObjVar(e,"skewY",0);return 1==n&&1==s&&0==r||(i=i||new Matrix,i.scale(n,s),i.rotate(.0174532922222222*r)),i},t._addGraphicToGraphics=function(e,i){var n;if(n=e.props){var s;if(s=t.DrawTypeDic[e.type]){var r;r=i;var a,o=t._getParams(n,s[1],s[2],s[3]);a=t._tM,(a||1!=t._alpha)&&(r.save(),a&&r.transform(a),1!=t._alpha&&r.alpha(t._alpha)),r[s[0]].apply(r,o),(a||1!=t._alpha)&&r.restore()}}},t._adptLineData=function(t){return t[2]=parseFloat(t[0])+parseFloat(t[2]),t[3]=parseFloat(t[1])+parseFloat(t[3]),t},t._adptTextureData=function(t){return t[0]=Loader.getRes(t[0]),t},t._adptLinesData=function(e){return e[2]=t._getPointListByStr(e[2]),e},t.isDrawType=function(e){return"Image"==e?!1:t.DrawTypeDic.hasOwnProperty(e)},t._getParams=function(e,i,n,s){void 0===n&&(n=0);var r;r=t._temParam,r.length=i.length;var a=0,o=0;for(o=i.length,a=0;o>a;a++)r[a]=t._getObjVar(e,i[a][0],i[a][1]);t._alpha=t._getObjVar(e,"alpha",1);var h;return h=t._getTransformData(e),h?(n||(n=0),h.translate(r[n],r[n+1]),r[n]=r[n+1]=0,t._tM=h):t._tM=null,s&&t[s]&&(r=t[s](r)),r},t._getPointListByStr=function(t){var e;e=t.split(",");var i=0,n=0;for(n=e.length,i=0;n>i;i++)e[i]=parseFloat(e[i]);return e},t._getObjVar=function(t,e,i){return t.hasOwnProperty(e)?t[e]:i},t._temParam=[],t._classMap={Sprite:"laya.display.Sprite",Text:"laya.display.Text",Animation:"laya.display.Animation",Skeleton:"laya.ani.bone.Skeleton",Particle2D:"laya.particle.Particle2D",div:"laya.html.dom.HTMLDivElement",p:"laya.html.dom.HTMLElement",img:"laya.html.dom.HTMLImageElement",span:"laya.html.dom.HTMLElement",br:"laya.html.dom.HTMLBrElement",style:"laya.html.dom.HTMLStyleElement",font:"laya.html.dom.HTMLElement",a:"laya.html.dom.HTMLElement","#text":"laya.html.dom.HTMLElement"},t.getClass=function(e){var i=t._classMap[e]||e;return"string"==typeof i?Laya.__classmap[i]:i},t._tM=null,t._alpha=NaN,__static(t,["DrawTypeDic",function(){return this.DrawTypeDic={Rect:["drawRect",[["x",0],["y",0],["width",0],["height",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],Circle:["drawCircle",[["x",0],["y",0],["radius",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],Pie:["drawPie",[["x",0],["y",0],["radius",0],["startAngle",0],["endAngle",0],["fillColor",null],["lineColor",null],["lineWidth",1]]],Image:["drawTexture",[["x",0],["y",0],["width",0],["height",0]]],Texture:["drawTexture",[["skin",null],["x",0],["y",0],["width",0],["height",0]],1,"_adptTextureData"],FillTexture:["fillTexture",[["skin",null],["x",0],["y",0],["width",0],["height",0],["repeat",null]],1,"_adptTextureData"],FillText:["fillText",[["text",""],["x",0],["y",0],["font",null],["color",null],["textAlign",null]],1],Line:["drawLine",[["x",0],["y",0],["toX",0],["toY",0],["lineColor",null],["lineWidth",0]],0,"_adptLineData"],Lines:["drawLines",[["x",0],["y",0],["points",""],["lineColor",null],["lineWidth",0]],0,"_adptLinesData"],Curves:["drawCurves",[["x",0],["y",0],["points",""],["lineColor",null],["lineWidth",0]],0,"_adptLinesData"],Poly:["drawPoly",[["x",0],["y",0],["points",""],["fillColor",null],["lineColor",null],["lineWidth",1]],0,"_adptLinesData"]}}]),t}(),Color=function(){function t(e){if(this._color=[],"string"==typeof e){this.strColor=e,null===e&&(e="#000000"),"#"==e.charAt(0)&&(e=e.substr(1));var i=this.numColor=parseInt(e,16),n=8==e.length;if(n)return void(this._color=[parseInt(e.substr(0,2),16)/255,((16711680&i)>>16)/255,((65280&i)>>8)/255,(255&i)/255])}else i=this.numColor=e,this.strColor=Utils.toHexColor(i);this._color=[((16711680&i)>>16)/255,((65280&i)>>8)/255,(255&i)/255,1],this._color.__id=++t._COLODID}return __class(t,"laya.utils.Color"),t._initDefault=function(){t._DEFAULT={};for(var e in t._COLOR_MAP)t._SAVE[e]=t._DEFAULT[e]=new t(t._COLOR_MAP[e]);return t._DEFAULT},t._initSaveMap=function(){t._SAVE_SIZE=0,t._SAVE={};for(var e in t._DEFAULT)t._SAVE[e]=t._DEFAULT[e]},t.create=function(e){var i=t._SAVE[e+""];return null!=i?i:(t._SAVE_SIZE<1e3||t._initSaveMap(),t._SAVE[e+""]=new t(e))},t._SAVE={},t._SAVE_SIZE=0,t._COLOR_MAP={white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",black:"#000000",yellow:"#FFFF00",gray:"#AAAAAA"},t._DEFAULT=t._initDefault(),t._COLODID=1,t}(),Dictionary=function(){function t(){this._values=[],this._keys=[]}__class(t,"laya.utils.Dictionary");var e=t.prototype;return e.set=function(t,e){var i=this.indexOf(t);return i>=0?void(this._values[i]=e):(this._keys.push(t),void this._values.push(e))},e.indexOf=function(t){var e=this._keys.indexOf(t);return e>=0?e:(t="string"==typeof t?Number(t):"number"==typeof t?t.toString():t,this._keys.indexOf(t))},e.get=function(t){var e=this.indexOf(t);return 0>e?null:this._values[e]},e.remove=function(t){var e=this.indexOf(t);return e>=0?(this._keys.splice(e,1),this._values.splice(e,1),!0):!1},e.clear=function(){this._values.length=0,this._keys.length=0},__getset(0,e,"values",function(){return this._values}),__getset(0,e,"keys",function(){return this._keys}),t}(),Dragging=function(){function t(){this.ratio=.92,this.maxOffset=60,this._dragging=!1,this._clickOnly=!0}__class(t,"laya.utils.Dragging");var e=t.prototype;return e.start=function(t,e,i,n,s,r,a,o){void 0===o&&(o=.92),this.clearTimer(),this.target=t,this.area=e,this.hasInertia=i,this.elasticDistance=e?n:0,this.elasticBackTime=s,this.data=r,this._disableMouseEvent=a,this.ratio=o,1!=t.globalScaleX||1!=t.globalScaleY?this._parent=t.parent:this._parent=Laya.stage,this._clickOnly=!0,this._dragging=!0,this._elasticRateX=this._elasticRateY=1,this._lastX=this._parent.mouseX,this._lastY=this._parent.mouseY,Laya.stage.on("mouseup",this,this.onStageMouseUp),Laya.stage.on("mouseout",this,this.onStageMouseUp),Laya.timer.frameLoop(1,this,this.loop)},e.clearTimer=function(){Laya.timer.clear(this,this.loop),Laya.timer.clear(this,this.tweenMove),this._tween&&(this._tween.recover(),this._tween=null)},e.stop=function(){this._dragging&&(MouseManager.instance.disableMouseEvent=!1,Laya.stage.off("mouseup",this,this.onStageMouseUp),Laya.stage.off("mouseout",this,this.onStageMouseUp),this._dragging=!1,this.target&&this.area&&this.backToArea(),this.clear())},e.loop=function(){var t=this._parent.getMousePoint(),e=t.x,i=t.y,n=e-this._lastX,s=i-this._lastY;if(this._clickOnly){if(!(Math.abs(n*Laya.stage._canvasTransform.getScaleX())>1||Math.abs(s*Laya.stage._canvasTransform.getScaleY())>1))return;this._clickOnly=!1,this._offsets||(this._offsets=[]),this._offsets.length=0,this.target.event("dragstart",this.data),MouseManager.instance.disableMouseEvent=this._disableMouseEvent,this.target._set$P("$_MOUSEDOWN",!1)}else this._offsets.push(n,s);0===n&&0===s||(this._lastX=e,this._lastY=i,this.target.x+=n*this._elasticRateX,this.target.y+=s*this._elasticRateY,this.area&&this.checkArea(),this.target.event("dragmove",this.data))},e.checkArea=function(){if(this.elasticDistance<=0)this.backToArea();else{if(this.target.xthis.area.x+this.area.width?this.target.x-this.area.x-this.area.width:0;if(this._elasticRateX=Math.max(0,1-t/this.elasticDistance),this.target.ythis.area.y+this.area.height?this.target.y-this.area.y-this.area.height:0;this._elasticRateY=Math.max(0,1-e/this.elasticDistance)}},e.backToArea=function(){this.target.x=Math.min(Math.max(this.target.x,this.area.x),this.area.x+this.area.width),this.target.y=Math.min(Math.max(this.target.y,this.area.y),this.area.y+this.area.height)},e.onStageMouseUp=function(t){if(MouseManager.instance.disableMouseEvent=!1,Laya.stage.off("mouseup",this,this.onStageMouseUp),Laya.stage.off("mouseout",this,this.onStageMouseUp),Laya.timer.clear(this,this.loop),!this._clickOnly&&this.target)if(this.hasInertia){this._offsets.length<1&&this._offsets.push(this._parent.mouseX-this._lastX,this._parent.mouseY-this._lastY),this._offsetX=this._offsetY=0;for(var e=this._offsets.length,i=Math.min(e,6),n=this._offsets.length-i,s=e-1;s>n;s--)this._offsetY+=this._offsets[s--],this._offsetX+=this._offsets[s];this._offsetX=this._offsetX/i*2,this._offsetY=this._offsetY/i*2,Math.abs(this._offsetX)>this.maxOffset&&(this._offsetX=this._offsetX>0?this.maxOffset:-this.maxOffset),Math.abs(this._offsetY)>this.maxOffset&&(this._offsetY=this._offsetY>0?this.maxOffset:-this.maxOffset),Laya.timer.frameLoop(1,this,this.tweenMove)}else this.elasticDistance>0?this.checkElastic():this.clear()},e.checkElastic=function(){var t=NaN,e=NaN;if(this.target.xthis.area.x+this.area.width&&(t=this.area.x+this.area.width),this.target.ythis.area.y+this.area.height&&(e=this.area.y+this.area.height),isNaN(t)&&isNaN(e))this.clear();else{var i={};isNaN(t)||(i.x=t),isNaN(e)||(i.y=e),this._tween=Tween.to(this.target,i,this.elasticBackTime,Ease.sineOut,Handler.create(this,this.clear),0,!1,!1)}},e.tweenMove=function(){this._offsetX*=this.ratio*this._elasticRateX,this._offsetY*=this.ratio*this._elasticRateY,this.target.x+=this._offsetX,this.target.y+=this._offsetY,this.area&&this.checkArea(),this.target.event("dragmove",this.data),(Math.abs(this._offsetX)<1&&Math.abs(this._offsetY)<1||this._elasticRateX<.5||this._elasticRateY<.5)&&(Laya.timer.clear(this,this.tweenMove),this.elasticDistance>0?this.checkElastic():this.clear())},e.clear=function(){if(this.target){this.clearTimer();var t=this.target;this.target=null,this._parent=null,t.event("dragend",this.data)}},t}(),Ease=function(){function t(){}return __class(t,"laya.utils.Ease"),t.linearNone=function(t,e,i,n){return i*t/n+e},t.linearIn=function(t,e,i,n){return i*t/n+e},t.linearInOut=function(t,e,i,n){return i*t/n+e},t.linearOut=function(t,e,i,n){return i*t/n+e},t.bounceIn=function(e,i,n,s){return n-t.bounceOut(s-e,0,n,s)+i},t.bounceInOut=function(e,i,n,s){return.5*s>e?.5*t.bounceIn(2*e,0,n,s)+i:.5*t.bounceOut(2*e-s,0,n,s)+.5*n+i},t.bounceOut=function(t,e,i,n){return(t/=n)<1/2.75?i*(7.5625*t*t)+e:2/2.75>t?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:2.5/2.75>t?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},t.backIn=function(t,e,i,n,s){return void 0===s&&(s=1.70158),i*(t/=n)*t*((s+1)*t-s)+e},t.backInOut=function(t,e,i,n,s){return void 0===s&&(s=1.70158),(t/=.5*n)<1?.5*i*(t*t*(((s*=1.525)+1)*t-s))+e:i/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+e},t.backOut=function(t,e,i,n,s){return void 0===s&&(s=1.70158),i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},t.elasticIn=function(e,i,n,s,r,a){void 0===r&&(r=0),void 0===a&&(a=0);var o;return 0==e?i:1==(e/=s)?i+n:(a||(a=.3*s),!r||n>0&&n>r||0>n&&-n>r?(r=n,o=a/4):o=a/t.PI2*Math.asin(n/r),-(r*Math.pow(2,10*(e-=1))*Math.sin((e*s-o)*t.PI2/a))+i)},t.elasticInOut=function(e,i,n,s,r,a){void 0===r&&(r=0),void 0===a&&(a=0);var o;return 0==e?i:2==(e/=.5*s)?i+n:(a||(a=s*(.3*1.5)),!r||n>0&&n>r||0>n&&-n>r?(r=n,o=a/4):o=a/t.PI2*Math.asin(n/r),1>e?-.5*(r*Math.pow(2,10*(e-=1))*Math.sin((e*s-o)*t.PI2/a))+i:r*Math.pow(2,-10*(e-=1))*Math.sin((e*s-o)*t.PI2/a)*.5+n+i)},t.elasticOut=function(e,i,n,s,r,a){void 0===r&&(r=0),void 0===a&&(a=0);var o;return 0==e?i:1==(e/=s)?i+n:(a||(a=.3*s),!r||n>0&&n>r||0>n&&-n>r?(r=n,o=a/4):o=a/t.PI2*Math.asin(n/r),r*Math.pow(2,-10*e)*Math.sin((e*s-o)*t.PI2/a)+n+i)},t.strongIn=function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},t.strongInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*i*t*t*t*t*t+e:.5*i*((t-=2)*t*t*t*t+2)+e},t.strongOut=function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},t.sineInOut=function(t,e,i,n){return.5*-i*(Math.cos(Math.PI*t/n)-1)+e},t.sineIn=function(e,i,n,s){return-n*Math.cos(e/s*t.HALF_PI)+n+i},t.sineOut=function(e,i,n,s){return n*Math.sin(e/s*t.HALF_PI)+i},t.quintIn=function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},t.quintInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*i*t*t*t*t*t+e:.5*i*((t-=2)*t*t*t*t+2)+e},t.quintOut=function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},t.quartIn=function(t,e,i,n){return i*(t/=n)*t*t*t+e},t.quartInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*i*t*t*t*t+e:.5*-i*((t-=2)*t*t*t-2)+e},t.quartOut=function(t,e,i,n){return-i*((t=t/n-1)*t*t*t-1)+e},t.cubicIn=function(t,e,i,n){return i*(t/=n)*t*t+e},t.cubicInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*i*t*t*t+e:.5*i*((t-=2)*t*t+2)+e},t.cubicOut=function(t,e,i,n){return i*((t=t/n-1)*t*t+1)+e},t.quadIn=function(t,e,i,n){return i*(t/=n)*t+e},t.quadInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*i*t*t+e:.5*-i*(--t*(t-2)-1)+e},t.quadOut=function(t,e,i,n){return-i*(t/=n)*(t-2)+e},t.expoIn=function(t,e,i,n){return 0==t?e:i*Math.pow(2,10*(t/n-1))+e-.001*i},t.expoInOut=function(t,e,i,n){return 0==t?e:t==n?e+i:(t/=.5*n)<1?.5*i*Math.pow(2,10*(t-1))+e:.5*i*(-Math.pow(2,-10*--t)+2)+e},t.expoOut=function(t,e,i,n){return t==n?e+i:i*(-Math.pow(2,-10*t/n)+1)+e},t.circIn=function(t,e,i,n){return-i*(Math.sqrt(1-(t/=n)*t)-1)+e},t.circInOut=function(t,e,i,n){return(t/=.5*n)<1?.5*-i*(Math.sqrt(1-t*t)-1)+e:.5*i*(Math.sqrt(1-(t-=2)*t)+1)+e},t.circOut=function(t,e,i,n){return i*Math.sqrt(1-(t=t/n-1)*t)+e},t.HALF_PI=.5*Math.PI,t.PI2=2*Math.PI,t}(),HitArea=function(){function t(){this._hit=null,this._unHit=null}__class(t,"laya.utils.HitArea");var e=t.prototype;return e.isHit=function(e,i){return t.isHitGraphic(e,i,this.hit)?!t.isHitGraphic(e,i,this.unHit):!1},__getset(0,e,"hit",function(){return this._hit||(this._hit=new Graphics),this._hit},function(t){this._hit=t}),__getset(0,e,"unHit",function(){return this._unHit||(this._unHit=new Graphics),this._unHit},function(t){this._unHit=t}),t.isHitGraphic=function(e,i,n){if(!n)return!1;var s;if(s=n.cmds,!s&&n._one&&(s=t._cmds,s.length=1,s[0]=n._one),!s)return!1;var r=0,a=0;a=s.length;var o;for(r=0;a>r;r++)if(o=s[r]){var h=Render._context;switch(o.callee){case h._translate:case 6:e-=o[0],i-=o[1]}if(t.isHitCmd(e,i,o))return!0}return!1},t.isHitCmd=function(e,i,n){if(!n)return!1;var s=Render._context,r=!1;switch(n.callee){case s._drawRect:case 13:t._rec.setTo(n[0],n[1],n[2],n[3]),r=t._rec.contains(e,i);break;case s._drawCircle:case s._fillCircle:case 14:var a=NaN;e-=n[0],i-=n[1],a=e*e+i*i,r=ac;c+=2)if(a=n[c],o=n[c+1],h=n[(c+2)%u],l=n[(c+3)%u],o!=l&&!(s.y=Math.max(o,l))){var _=(s.y-o)*(h-a)/(l-o)+a;_>s.x&&r++}return r%2==1},t._cmds=[],__static(t,["_rec",function(){return this._rec=new Rectangle},"_ptPoint",function(){return this._ptPoint=new Point}]),t}(),HTMLChar=function(){function t(e,i,n,s){this["char"]=e,this.charNum=e.charCodeAt(0),this._x=this._y=0,this.width=i,this.height=n,this.style=s,this.isWord=!t._isWordRegExp.test(e)}__class(t,"laya.utils.HTMLChar");var e=t.prototype;return Laya.imps(e,{"laya.display.ILayout":!0}),e.setSprite=function(t){this._sprite=t},e.getSprite=function(){return this._sprite},e._isChar=function(){return!0},e._getCSSStyle=function(){return this.style},__getset(0,e,"width",function(){return this._w},function(t){this._w=t}),__getset(0,e,"x",function(){return this._x},function(t){this._sprite&&(this._sprite.x=t),this._x=t}),__getset(0,e,"y",function(){return this._y},function(t){this._sprite&&(this._sprite.y=t),this._y=t}),__getset(0,e,"height",function(){return this._h},function(t){this._h=t}),t._isWordRegExp=new RegExp("[\\w.]",""),t}(),Log=function(){function t(){}return __class(t,"laya.utils.Log"),t.enable=function(){t._logdiv||(t._logdiv=Browser.window.document.createElement("div"),Browser.window.document.body.appendChild(t._logdiv),t._logdiv.style.cssText="pointer-events:none;border:white;overflow:hidden;z-index:1000000;background:rgba(100,100,100,0.6);color:white;position: absolute;left:0px;top:0px;width:50%;height:50%;")},t.toggle=function(){var e=t._logdiv.style;"1px"==e.width?e.width=e.height="50%":e.width=e.height="1px"},t.print=function(e){t._logdiv&&(t._count>=t.maxCount&&t.clear(),t._count++,t._logdiv.innerText+=e+"\n",t._logdiv.scrollTop=t._logdiv.scrollHeight)},t.clear=function(){t._logdiv.innerText="",t._count=0},t._logdiv=null,t._count=0,t.maxCount=20,t}(),Mouse=function(){function t(){}return __class(t,"laya.utils.Mouse"),__getset(1,t,"cursor",function(){return t._style.cursor},function(e){t._style.cursor=e}),t.hide=function(){"none"!=t.cursor&&(t._preCursor=t.cursor,t.cursor="none")},t.show=function(){"none"==t.cursor&&(t._preCursor?t.cursor=t._preCursor:t.cursor="auto")},t._preCursor=null,__static(t,["_style",function(){return this._style=Browser.document.body.style}]),t}(),Pool=function(){function t(){}return __class(t,"laya.utils.Pool"),t.getPoolBySign=function(e){return t._poolDic[e]||(t._poolDic[e]=[])},t.clearBySign=function(e){t._poolDic[e]&&(t._poolDic[e].length=0)},t.recover=function(e,i){i.__InPool||(i.__InPool=!0,t.getPoolBySign(e).push(i))},t.getItemByClass=function(e,i){var n=t.getPoolBySign(e),s=n.length?n.pop():new i;return s.__InPool=!1,s},t.getItemByCreateFun=function(e,i){var n=t.getPoolBySign(e),s=n.length?n.pop():i();return s.__InPool=!1,s},t.getItem=function(e){var i=t.getPoolBySign(e),n=i.length?i.pop():null;return n&&(n.__InPool=!1),n},t._poolDic={},t.InPoolSign="__InPool",t}(),PoolCache=function(){function t(){this.sign=null,this.maxCount=1e3}__class(t,"laya.utils.PoolCache");var e=t.prototype;return e.getCacheList=function(){return Pool.getPoolBySign(this.sign)},e.tryDispose=function(t){var e;e=Pool.getPoolBySign(this.sign),e.length>this.maxCount&&e.splice(this.maxCount,e.length-this.maxCount)},t.addPoolCacheManager=function(e,i){void 0===i&&(i=100);var n;n=new t,n.sign=e,n.maxCount=i,CacheManger.regCacheByFunction(Utils.bind(n.tryDispose,n),Utils.bind(n.getCacheList,n))},t}(),Stat=function(){function t(){}return __class(t,"laya.utils.Stat"),__getset(1,t,"onclick",null,function(e){t._canvas.source.onclick=e,t._canvas.source.style.pointerEvents=""}),t.show=function(e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),Render.isConchApp)return void(conch.showFPS&&conch.showFPS(e,i));var n=Browser.pixelRatio;t._width=120*n,t._vx=70*n,t._view[0]={title:"FPS(Canvas)",value:"_fpsStr",color:"yellow",units:"int"},t._view[1]={title:"Sprite",value:"spriteCount",color:"white",units:"int"},t._view[2]={title:"DrawCall",value:"drawCall",color:"white",units:"int"},t._view[3]={title:"CurMem",value:"currentMemorySize",color:"yellow",units:"M"},Render.isWebGL?(t._view[4]={title:"Shader",value:"shaderCall",color:"white",units:"int"},Render.is3DMode?(t._view[0].title="FPS(3D)",t._view[5]={title:"TriFaces",value:"trianglesFaces",color:"white",units:"int"}):(t._view[0].title="FPS(WebGL)",t._view[5]={title:"Canvas",value:"_canvasStr",color:"white",units:"int"})):t._view[4]={title:"Canvas",value:"_canvasStr",color:"white",units:"int"},t._fontSize=12*n;for(var s=0;sa;a++)if(h=n[a],null!==h.method){var s=h.userFrame?t:i;s>=h.exeTime&&(h.repeat?s>h.exeTime&&(h.exeTime+=h.delay,h.run(!1),s>h.exeTime&&(h.exeTime+=Math.ceil((s-h.exeTime)/h.delay)*h.delay)):h.run(!0))}else this._count++;(this._count>30||t%200===0)&&this._clearHandlers();for(var r=this._laters,a=0,o=r.length-1;o>=a;a++){var h=r[a];null!==h.method&&h.run(!1),this._recoverHandler(h),a===o&&(o=r.length-1)}r.length=0},i._clearHandlers=function(){for(var t=this._handlers,e=0,i=t.length;i>e;e++){var n=t[e];null!==n.method?this._temp.push(n):this._recoverHandler(n)}this._handlers=this._temp,this._temp=t,this._temp.length=0},i._recoverHandler=function(e){this._map[e.key]=null,e.clear(),t._pool.push(e)},i._create=function(i,n,s,r,a,o,h){if(!s)return void a.apply(r,o);if(h){var l=this._getHandler(r,a);if(l)return l.repeat=n,l.userFrame=i,l.delay=s,l.caller=r,l.method=a,l.args=o,void(l.exeTime=s+(i?this.currFrame:this.currTimer))}l=t._pool.length>0?t._pool.pop():new e,l.repeat=n,l.userFrame=i,l.delay=s,l.caller=r,l.method=a,l.args=o,l.exeTime=s+(i?this.currFrame:this.currTimer),this._indexHandler(l),this._handlers.push(l)},i._indexHandler=function(t){var e=t.caller,i=t.method,n=e?e.$_GID||(e.$_GID=Utils.getGID()):0,s=i.$_TID||(i.$_TID=1e5*this._mid++);t.key=n+s,this._map[t.key]=t},i.once=function(t,e,i,n,s){void 0===s&&(s=!0),this._create(!1,!1,t,e,i,n,s)},i.loop=function(t,e,i,n,s){void 0===s&&(s=!0),this._create(!1,!0,t,e,i,n,s)},i.frameOnce=function(t,e,i,n,s){void 0===s&&(s=!0),this._create(!0,!1,t,e,i,n,s)},i.frameLoop=function(t,e,i,n,s){void 0===s&&(s=!0),this._create(!0,!0,t,e,i,n,s)},i.toString=function(){return"callLater:"+this._laters.length+" handlers:"+this._handlers.length+" pool:"+t._pool.length},i.clear=function(t,e){var i=this._getHandler(t,e);i&&(this._map[i.key]=null,i.key=0,i.clear())},i.clearAll=function(t){for(var e=0,i=this._handlers.length;i>e;e++){var n=this._handlers[e];n.caller===t&&(this._map[n.key]=null,n.key=0,n.clear())}},i._getHandler=function(t,e){var i=t?t.$_GID||(t.$_GID=Utils.getGID()):0,n=e.$_TID||(e.$_TID=1e5*this._mid++);return this._map[i+n]},i.callLater=function(i,n,s){if(null==this._getHandler(i,n)){if(t._pool.length)var r=t._pool.pop();else r=new e;r.caller=i,r.method=n,r.args=s,this._indexHandler(r),this._laters.push(r)}},i.runCallLater=function(t,e){var i=this._getHandler(t,e);i&&null!=i.method&&(this._map[i.key]=null,i.run(!0))},__getset(0,i,"delta",function(){return this._delta}),t._pool=[],t.__init$=function(){e=function(){function t(){this.key=0,this.repeat=!1,this.delay=0,this.userFrame=!1,this.exeTime=0,this.caller=null,this.method=null,this.args=null}__class(t,"");var e=t.prototype;return e.clear=function(){this.caller=null,this.method=null,this.args=null},e.run=function(t){var e=this.caller;if(e&&e.destroyed)return this.clear();var i=this.method,n=this.args;t&&this.clear(),null!=i&&(n?i.apply(e,n):i.call(e))},t}()},t}(),Tween=function(){function t(){this.gid=0}__class(t,"laya.utils.Tween");var e=t.prototype;return e.to=function(t,e,i,n,s,r,a){return void 0===r&&(r=0),void 0===a&&(a=!1),this._create(t,e,i,n,s,r,a,!0,!1,!0)},e.from=function(t,e,i,n,s,r,a){return void 0===r&&(r=0),void 0===a&&(a=!1),this._create(t,e,i,n,s,r,a,!1,!1,!0)},e._create=function(e,i,n,s,r,a,o,h,l,u){if(!e)throw new Error("Tween:target is null");this._target=e,this._duration=n,this._ease=s||i.ease||t.easeNone,this._complete=r||i.complete,this._delay=a,this._props=[],this._usedTimer=0,this._startTimer=Browser.now(),this._usedPool=l,this.update=i.update;var c=e.$_GID||(e.$_GID=Utils.getGID());return t.tweenMap[c]?(o&&t.clearTween(e),t.tweenMap[c].push(this)):t.tweenMap[c]=[this],u?0>=a?this.firstStart(e,i,h):Laya.timer.once(a,this,this.firstStart,[e,i,h]):this._initProps(e,i,h),this},e.firstStart=function(t,e,i){this._initProps(t,e,i),this._beginLoop()},e._initProps=function(t,e,i){for(var n in e)if("number"==typeof t[n]){var s=i?t[n]:e[n],r=i?e[n]:t[n];this._props.push([n,s,r-s])}},e._beginLoop=function(){Laya.timer.frameLoop(1,this,this._doEase)},e._doEase=function(){this._updateEase(Browser.now())},e._updateEase=function(e){var i=this._target;if(i.destroyed)return t.clearTween(i);var n=this._usedTimer=e-this._startTimer-this._delay;if(!(0>n)){if(n>=this._duration)return this.complete();for(var s=n>0?this._ease(n,0,1,this._duration):0,r=this._props,a=0,o=r.length;o>a;a++){var h=r[a];i[h[0]]=h[1]+s*h[2]}this.update&&this.update.run()}},e.complete=function(){if(this._target){for(var t=this._target,e=this._props,i=this._complete,n=0,s=e.length;s>n;n++){ +var r=e[n];t[r[0]]=r[1]+r[2]}this.update&&this.update.run(),this.clear(),i&&i.run()}},e.pause=function(){Laya.timer.clear(this,this._beginLoop),Laya.timer.clear(this,this._doEase)},e.setStartTime=function(t){this._startTimer=t},e.clear=function(){this._target&&(this._remove(),this._clear())},e._clear=function(){this.pause(),Laya.timer.clear(this,this.firstStart),this._complete=null,this._target=null,this._ease=null,this._props=null,this._usedPool&&(this.update=null,Pool.recover("tween",this))},e.recover=function(){this._usedPool=!0,this._clear()},e._remove=function(){var e=t.tweenMap[this._target.$_GID];if(e)for(var i=0,n=e.length;n>i;i++)if(e[i]===this){e.splice(i,1);break}},e.restart=function(){this.pause(),this._usedTimer=0,this._startTimer=Browser.now();for(var t=this._props,e=0,i=t.length;i>e;e++){var n=t[e];this._target[n[0]]=n[1]}Laya.timer.once(this._delay,this,this._beginLoop)},e.resume=function(){this._usedTimer>=this._duration||(this._startTimer=Browser.now()-this._usedTimer-this._delay,this._beginLoop())},__getset(0,e,"progress",null,function(t){var e=t*this._duration;this._startTimer=Browser.now()-this._delay-e}),t.to=function(e,i,n,s,r,a,o,h){return void 0===a&&(a=0),void 0===o&&(o=!1),void 0===h&&(h=!0),Pool.getItemByClass("tween",t)._create(e,i,n,s,r,a,o,!0,h,!0)},t.from=function(e,i,n,s,r,a,o,h){return void 0===a&&(a=0),void 0===o&&(o=!1),void 0===h&&(h=!0),Pool.getItemByClass("tween",t)._create(e,i,n,s,r,a,o,!1,h,!0)},t.clearAll=function(e){if(e&&e.$_GID){var i=t.tweenMap[e.$_GID];if(i){for(var n=0,s=i.length;s>n;n++)i[n]._clear();i.length=0}}},t.clear=function(t){t.clear()},t.clearTween=function(e){t.clearAll(e)},t.easeNone=function(t,e,i,n){return i*t/n+e},t.tweenMap={},t}(),Utils=function(){function t(){}return __class(t,"laya.utils.Utils"),t.toRadian=function(e){return e*t._pi2},t.toAngle=function(e){return e*t._pi},t.toHexColor=function(t){if(0>t||isNaN(t))return null;for(var e=t.toString(16);e.length<6;)e="0"+e;return"#"+e},t.getGID=function(){return t._gid++},t.concatArray=function(t,e){if(!e)return t;if(!t)return e;var i=0,n=e.length;for(i=0;n>i;i++)t.push(e[i]);return t},t.clearArray=function(t){return t?(t.length=0,t):t},t.copyArray=function(t,e){if(t||(t=[]),!e)return t;t.length=e.length;var i=0,n=e.length;for(i=0;n>i;i++)t[i]=e[i];return t},t.getGlobalRecByPoints=function(t,e,i,n,s){var r;r=new Point(e,i),r=t.localToGlobal(r);var a;return a=new Point(n,s),a=t.localToGlobal(a),Rectangle._getWrapRec([r.x,r.y,a.x,a.y])},t.getGlobalPosAndScale=function(e){return t.getGlobalRecByPoints(e,0,0,1,1)},t.bind=function(t,e){var i=t;return i=t.bind(e)},t.measureText=function(t,e){return RunDriver.measureText(t,e)},t.updateOrder=function(t){if(!t||t.length<2)return!1;for(var e,i=1,n=0,s=t.length,r=NaN;s>i;){for(n=i,e=t[n],r=t[n]._zOrder;--n>-1&&t[n]._zOrder>r;)t[n+1]=t[n];t[n+1]=e,i++}var a=e.parent.model;if(a)if(a.updateZOrder)a.updateZOrder();else{for(i=0;s>i;i++)a.removeChild(t[i].model);for(i=0;s>i;i++)a.addChildAt(t[i].model,i)}return!0},t.transPointList=function(t,e,i){var n=0,s=t.length;for(n=0;s>n;n+=2)t[n]+=e,t[n+1]+=i},t.parseInt=function(t,e){void 0===e&&(e=0);var i=Browser.window.parseInt(t,e);return isNaN(i)?0:i},t.getFileExtension=function(e){t._extReg.lastIndex=e.lastIndexOf(".");var i=t._extReg.exec(e);return i&&i.length>1?i[1].toLowerCase():null},t._gid=1,t._pi=180/Math.PI,t._pi2=Math.PI/180,t._extReg=/\.(\w+)\??/g,t.parseXMLFromString=function(t){var e;if(t=t.replace(/>\s+<"),e=(new DOMParser).parseFromString(t,"text/xml"),e.firstChild.textContent.indexOf("This page contains the following errors")>-1)throw new Error(e.firstChild.firstChild.textContent);return e},t}(),VectorGraphManager=function(){function t(){this.useDic={},this.shapeDic={},this.shapeLineDic={},this._id=0,this._checkKey=!1,this._freeIdArray=[],Render.isWebGL&&CacheManger.regCacheByFunction(Utils.bind(this.startDispose,this),Utils.bind(this.getCacheList,this))}__class(t,"laya.utils.VectorGraphManager");var e=t.prototype;return e.getId=function(){return this._id++},e.addShape=function(t,e){this.shapeDic[t]=e,this.useDic[t]||(this.useDic[t]=!0)},e.addLine=function(t,e){this.shapeLineDic[t]=e,this.shapeLineDic[t]||(this.shapeLineDic[t]=!0)},e.getShape=function(t){this._checkKey&&null!=this.useDic[t]&&(this.useDic[t]=!0)},e.deleteShape=function(t){this.shapeDic[t]&&(this.shapeDic[t]=null,delete this.shapeDic[t]),this.shapeLineDic[t]&&(this.shapeLineDic[t]=null,delete this.shapeLineDic[t]),null!=this.useDic[t]&&delete this.useDic[t]},e.getCacheList=function(){var t,e=[];for(t in this.shapeDic)e.push(this.shapeDic[t]);for(t in this.shapeLineDic)e.push(this.shapeLineDic[t]);return e},e.startDispose=function(t){var e;for(e in this.useDic)this.useDic[e]=!1;this._checkKey=!0},e.endDispose=function(){if(this._checkKey){var t;for(t in this.useDic)this.useDic[t]||this.deleteShape(t);this._checkKey=!1}},t.getInstance=function(){return t.instance=t.instance||new t},t.instance=null,t}(),WordText=function(){function t(){this.id=NaN,this.save=[],this.toUpperCase=null,this.changed=!1,this._text=null}__class(t,"laya.utils.WordText");var e=t.prototype;return e.setText=function(t){this.changed=!0,this._text=t},e.toString=function(){return this._text},e.charCodeAt=function(t){return this._text?this._text.charCodeAt(t):NaN},e.charAt=function(t){return this._text?this._text.charAt(t):null},__getset(0,e,"length",function(){return this._text?this._text.length:0}),t}(),Node=function(t){function e(){this.name="",this.destroyed=!1,this._displayedInStage=!1,this._parent=null,this.model=null,e.__super.call(this),this._childs=e.ARRAY_EMPTY,this.timer=Laya.timer,this._$P=e.PROP_EMPTY,this.model=Render.isConchNode?new ConchNode:null}__class(e,"laya.display.Node",t);var i=e.prototype;return i.destroy=function(t){void 0===t&&(t=!0),this.destroyed=!0,this._parent&&this._parent.removeChild(this),this._childs&&(t?this.destroyChildren():this.removeChildren()),this._childs=null,this._$P=null,this.offAll()},i.destroyChildren=function(){if(this._childs)for(var t=this._childs.length-1;t>-1;t--)this._childs[t].destroy(!0)},i.addChild=function(t){return this.destroyed||t===this?t:(t._parent===this?(this._childs.splice(this.getChildIndex(t),1),this._childs.push(t),this.model&&(this.model.removeChild(t.model),this.model.addChildAt(t.model,this._childs.length-1)),this._childChanged()):(t.parent&&t.parent.removeChild(t),this._childs===e.ARRAY_EMPTY&&(this._childs=[]),this._childs.push(t),this.model&&this.model.addChildAt(t.model,this._childs.length-1),t.parent=this,this._childChanged()),t)},i.addChildren=function(t){for(var e=arguments,i=0,n=e.length;n>i;)this.addChild(e[i++])},i.addChildAt=function(t,i){if(this.destroyed||t===this)return t;if(i>=0&&i<=this._childs.length){if(t._parent===this){var n=this.getChildIndex(t);this._childs.splice(n,1),this._childs.splice(i,0,t),this.model&&(this.model.removeChild(t.model),this.model.addChildAt(t.model,i)),this._childChanged()}else t.parent&&t.parent.removeChild(t),this._childs===e.ARRAY_EMPTY&&(this._childs=[]),this._childs.splice(i,0,t),this.model&&this.model.addChildAt(t.model,i),t.parent=this;return t}throw new Error("appendChildAt:The index is out of bounds")},i.getChildIndex=function(t){return this._childs.indexOf(t)},i.getChildByName=function(t){for(var e=this._childs,i=0,n=e.length;n>i;i++){var s=e[i];if(s.name===t)return s}return null},i._get$P=function(t){return this._$P[t]},i._set$P=function(t,i){return this.destroyed||(this._$P===e.PROP_EMPTY&&(this._$P={}),this._$P[t]=i),i},i.getChildAt=function(t){return this._childs[t]},i.setChildIndex=function(t,e){var i=this._childs;if(0>e||e>=i.length)throw new Error("setChildIndex:The index is out of bounds.");var n=this.getChildIndex(t);if(0>n)throw new Error("setChildIndex:node is must child of this object.");return i.splice(n,1),i.splice(e,0,t),this.model&&(this.model.removeChild(t.model),this.model.addChildAt(t.model,e)),this._childChanged(),t},i._childChanged=function(t){},i.removeChild=function(t){if(!this._childs)return t;var e=this._childs.indexOf(t);return this.removeChildAt(e)},i.removeSelf=function(){return this._parent&&this._parent.removeChild(this),this},i.removeChildByName=function(t){var e=this.getChildByName(t);return e&&this.removeChild(e),e},i.removeChildAt=function(t){var e=this.getChildAt(t);return e&&(this._childs.splice(t,1),this.model&&this.model.removeChild(e.model),e.parent=null),e},i.removeChildren=function(t,i){if(void 0===t&&(t=0),void 0===i&&(i=2147483647),this._childs&&this._childs.length>0){var n=this._childs;if(0===t&&i>=a){var s=n;this._childs=e.ARRAY_EMPTY}else s=n.splice(t,i-t);for(var r=0,a=s.length;a>r;r++)s[r].parent=null,this.model&&this.model.removeChild(s[r].model)}return this},i.replaceChild=function(t,e){var i=this._childs.indexOf(e);return i>-1?(this._childs.splice(i,1,t),this.model&&(this.model.removeChild(e.model),this.model.addChildAt(t.model,i)),e.parent=null,t.parent=this,t):null},i._setDisplay=function(t){this._displayedInStage!==t&&(this._displayedInStage=t,t?this.event("display"):this.event("undisplay"))},i._displayChild=function(t,e){var i=t._childs;if(i)for(var n=i.length-1;n>-1;n--){var s=i[n];s._setDisplay(e),s._childs.length&&this._displayChild(s,e)}t._setDisplay(e)},i.contains=function(t){if(t===this)return!0;for(;t;){if(t.parent===this)return!0;t=t.parent}return!1},i.timerLoop=function(t,e,i,n,s){void 0===s&&(s=!0),this.timer._create(!1,!0,t,e,i,n,s)},i.timerOnce=function(t,e,i,n,s){void 0===s&&(s=!0),this.timer._create(!1,!1,t,e,i,n,s)},i.frameLoop=function(t,e,i,n,s){void 0===s&&(s=!0),this.timer._create(!0,!0,t,e,i,n,s)},i.frameOnce=function(t,e,i,n,s){void 0===s&&(s=!0),this.timer._create(!0,!1,t,e,i,n,s)},i.clearTimer=function(t,e){this.timer.clear(t,e)},__getset(0,i,"numChildren",function(){return this._childs.length}),__getset(0,i,"parent",function(){return this._parent},function(t){this._parent!==t&&(t?(this._parent=t,this.event("added"),t.displayedInStage&&this._displayChild(this,!0),t._childChanged(this)):(this.event("removed"),this._parent._childChanged(),this._displayChild(this,!1),this._parent=t))}),__getset(0,i,"displayedInStage",function(){return this._displayedInStage}),e.ARRAY_EMPTY=[],e.PROP_EMPTY={},e}(EventDispatcher),CSSStyle=function(t){function e(t){this._bgground=null,this._border=null,this._rect=null,this.lineHeight=0,e.__super.call(this),this._padding=e._PADDING,this._spacing=e._SPACING,this._aligns=e._ALIGNS,this._font=Font.EMPTY,this._ower=t}__class(e,"laya.display.css.CSSStyle",t);var i=e.prototype;return i.destroy=function(){this._ower=null,this._font=null,this._rect=null},i.inherit=function(t){this._font=t._font,this._spacing=t._spacing===e._SPACING?e._SPACING:t._spacing.slice(),this.lineHeight=t.lineHeight},i._widthAuto=function(){return 0!==(262144&this._type)},i.widthed=function(t){return 0!=(8&this._type)},i._calculation=function(t,e){function i(t,e,i){return t*i[0]+e*i[1]+i[2]}function n(t){var e=r.width,n=s.width;a.width&&(s.width=i(e,n,a.width)),a.height&&(s.height=i(e,n,a.height)),a.left&&(s.x=i(e,n,a.left)),a.top&&(s.y=i(e,n,a.top))}if(e.indexOf("%")<0)return!1;var s=this._ower,r=s.parent,a=this._rect;null===a&&(r._getCSSStyle()._type|=524288,r.on("resize",this,n),this._rect=a={input:{}});var o=e.split(" ");return o[0]=parseFloat(o[0])/100,1==o.length?o[1]=o[2]=0:(o[1]=parseFloat(o[1])/100,o[2]=parseFloat(o[2])),a[t]=o,a.input[t]=e,n(t),!0},i.heighted=function(t){return 0!=(8192&this._type)},i.size=function(t,e){var i=this._ower,n=!1;-1!==t&&t!=this._ower.width&&(this._type|=8,this._ower.width=t,n=!0),-1!==e&&e!=this._ower.height&&(this._type|=8192,this._ower.height=e,n=!0),n&&(i._layoutLater(),524288&this._type&&i.event("resize",this))},i._getAlign=function(){return this._aligns[0]},i._getValign=function(){return this._aligns[1]},i._getCssFloat=function(){return 0!=(32768&this._type)?32768:0},i._createFont=function(){return 4096&this._type?this._font:(this._type|=4096,this._font=new Font(this._font))},i.render=function(t,e,i,n){var s=t.width,r=t.height;i-=t.pivotX,n-=t.pivotY,this._bgground&&null!=this._bgground.color&&e.ctx.fillRect(i,n,s,r,this._bgground.color),this._border&&this._border.color&&e.drawRect(i,n,s,r,this._border.color.strColor,this._border.size)},i.getCSSStyle=function(){return this},i.cssText=function(t){this.attrs(e.parseOneCSS(t,";"))},i.attrs=function(t){if(t)for(var e=0,i=t.length;i>e;e++){var n=t[e];this[n[0]]=n[1]}},i.setTransform=function(t){"none"===t?this._tf=Style._TF_EMPTY:this.attrs(e.parseOneCSS(t,","))},i.translate=function(t,e){this._tf===Style._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.translateX=t,this._tf.translateY=e},i.scale=function(t,e){this._tf===Style._TF_EMPTY&&(this._tf=new TransformInfo),this._tf.scaleX=t,this._tf.scaleY=e},i._enableLayout=function(){return 0===(2&this._type)&&0===(4&this._type)},__getset(0,i,"block",t.prototype._$get_block,function(t){t?this._type|=1:this._type&=-2}),__getset(0,i,"valign",function(){return e._valigndef[this._aligns[1]]},function(t){this._aligns===e._ALIGNS&&(this._aligns=[0,0,0]),this._aligns[1]=e._valigndef[t]}),__getset(0,i,"height",null,function(t){if(this._type|=8192,"string"==typeof t){if(this._calculation("height",t))return;t=parseInt(t)}this.size(-1,t)}),__getset(0,i,"width",null,function(t){if(this._type|=8,"string"==typeof t){var e=t.indexOf("auto");if(e>=0&&(this._type|=262144,t=t.substr(0,e)),this._calculation("width",t))return;t=parseInt(t)}this.size(t,-1)}),__getset(0,i,"fontWeight",function(){return this._font.weight},function(t){this._createFont().weight=t}),__getset(0,i,"left",null,function(t){var e=this._ower;if("string"==typeof t){if("center"===t?t="50% -50% 0":"right"===t&&(t="100% -100% 0"),this._calculation("left",t))return;t=parseInt(t)}e.x=t}),__getset(0,i,"_translate",null,function(t){this.translate(t[0],t[1])}),__getset(0,i,"absolute",function(){return 0!==(4&this._type)}),__getset(0,i,"top",null,function(t){var e=this._ower;if("string"==typeof t){if("middle"===t?t="50% -50% 0":"bottom"===t&&(t="100% -100% 0"),this._calculation("top",t))return;t=parseInt(t)}e.y=t}),__getset(0,i,"align",function(){return e._aligndef[this._aligns[0]]},function(t){this._aligns===e._ALIGNS&&(this._aligns=[0,0,0]),this._aligns[0]=e._aligndef[t]}),__getset(0,i,"bold",function(){return this._font.bold},function(t){this._createFont().bold=t}),__getset(0,i,"padding",function(){return this._padding},function(t){this._padding=t}),__getset(0,i,"leading",function(){return this._spacing[1]},function(t){"string"==typeof t&&(t=parseInt(t+"")),this._spacing===e._SPACING&&(this._spacing=[0,0]),this._spacing[1]=t}),__getset(0,i,"lineElement",function(){return 0!=(65536&this._type)},function(t){t?this._type|=65536:this._type&=-65537}),__getset(0,i,"cssFloat",function(){return 0!=(32768&this._type)?"right":"left"},function(t){this.lineElement=!1,"right"===t?this._type|=32768:this._type&=-32769}),__getset(0,i,"textDecoration",function(){return this._font.decoration},function(t){this._createFont().decoration=t}),__getset(0,i,"whiteSpace",function(){return 131072&this._type?"nowrap":""},function(t){"nowrap"===t&&(this._type|=131072),"none"===t&&(this._type&=-131073)}),__getset(0,i,"background",null,function(t){return t?(this._bgground||(this._bgground={}),this._bgground.color=t,this._ower.model&&this._ower.model.bgColor(t),this._type|=16384,void(this._ower._renderType|=128)):void(this._bgground=null)}),__getset(0,i,"wordWrap",function(){return 0===(131072&this._type)},function(t){t?this._type&=-131073:this._type|=131072}),__getset(0,i,"color",function(){return this._font.color},function(t){this._createFont().color=t}),__getset(0,i,"password",function(){return this._font.password},function(t){this._createFont().password=t}),__getset(0,i,"backgroundColor",function(){return this._bgground?this._bgground.color:null},function(t){"none"===t?this._bgground=null:(this._bgground||(this._bgground={}),this._bgground.color=t),this._ower.model&&this._ower.model.bgColor(t),this._ower._renderType|=128}),__getset(0,i,"font",function(){return this._font.toString()},function(t){this._createFont().set(t)}),__getset(0,i,"weight",null,function(t){this._createFont().weight=t}),__getset(0,i,"letterSpacing",function(){return this._spacing[0]},function(t){"string"==typeof t&&(t=parseInt(t+"")),this._spacing===e._SPACING&&(this._spacing=[0,0]),this._spacing[0]=t}),__getset(0,i,"fontSize",function(){return this._font.size},function(t){this._createFont().size=t}),__getset(0,i,"italic",function(){return this._font.italic},function(t){this._createFont().italic=t}),__getset(0,i,"fontFamily",function(){return this._font.family},function(t){this._createFont().family=t}),__getset(0,i,"stroke",function(){return this._font.stroke[0]},function(t){this._createFont().stroke===Font._STROKE&&(this._font.stroke=[0,"#000000"]),this._font.stroke[0]=t}),__getset(0,i,"strokeColor",function(){return this._font.stroke[1]},function(t){this._createFont().stroke===Font._STROKE&&(this._font.stroke=[0,"#000000"]),this._font.stroke[1]=t}),__getset(0,i,"border",function(){return this._border?this._border.value:""},function(t){if("none"==t)return void(this._border=null);this._border||(this._border={}),this._border.value=t;var e=t.split(" ");if(this._border.color=Color.create(e[e.length-1]),1==e.length)return this._border.size=1,void(this._border.type="solid");var i=0;e[0].indexOf("px")>0?(this._border.size=parseInt(e[0]),i++):this._border.size=1,this._border.type=e[i],this._ower._renderType|=128}),__getset(0,i,"borderColor",function(){return this._border&&this._border.color?this._border.color.strColor:null},function(t){return t?(this._border||(this._border={size:1,type:"solid"}),this._border.color=null==t?null:Color.create(t),this._ower.model&&this._ower.model.border(this._border.color.strColor),void(this._ower._renderType|=128)):void(this._border=null)}),__getset(0,i,"position",function(){return 4&this._type?"absolute":""},function(t){"absolute"==t?this._type|=4:this._type&=-5}),__getset(0,i,"display",null,function(t){switch(t){case"":this._type&=-3,this.visible=!0;break;case"none":this._type|=2,this.visible=!1,this._ower._layoutLater()}}),__getset(0,i,"paddingLeft",function(){return this.padding[3]}),__getset(0,i,"paddingTop",function(){return this.padding[0]}),__getset(0,i,"_scale",null,function(t){this._ower.scale(t[0],t[1])}),__getset(0,i,"_rotate",null,function(t){this._ower.rotation=t}),e.parseOneCSS=function(t,i){for(var n,s=[],r=t.split(i),a=0,o=r.length;o>a;a++){var h=r[a],l=h.indexOf(":"),u=h.substr(0,l).replace(/^\s+|\s+$/g,"");if(0!=u.length){var c=h.substr(l+1).replace(/^\s+|\s+$/g,""),_=[u,c];switch(u){case"italic":case"bold":_[1]="true"==c;break;case"line-height":_[0]="lineHeight",_[1]=parseInt(c);break;case"font-size":_[0]="fontSize",_[1]=parseInt(c);break;case"padding":n=c.split(" "),n.length>1||(n[1]=n[2]=n[3]=n[0]),_[1]=[parseInt(n[0]),parseInt(n[1]),parseInt(n[2]),parseInt(n[3])];break;case"rotate":_[0]="_rotate",_[1]=parseFloat(c);break;case"scale":n=c.split(" "),_[0]="_scale",_[1]=[parseFloat(n[0]),parseFloat(n[1])];break;case"translate":n=c.split(" "),_[0]="_translate",_[1]=[parseInt(n[0]),parseInt(n[1])];break;default:(_[0]=e._CSSTOVALUE[u])||(_[0]=u)}s.push(_)}}return s},e.parseCSS=function(t,i){for(var n;null!=(n=e._parseCSSRegExp.exec(t));)e.styleSheets[n[1]]=e.parseOneCSS(n[2],";")},e.EMPTY=new e(null),e._CSSTOVALUE={"letter-spacing":"letterSpacing","line-spacing":"lineSpacing","white-space":"whiteSpace","line-height":"lineHeight","scale-x":"scaleX","scale-y":"scaleY","translate-x":"translateX","translate-y":"translateY","font-family":"fontFamily","font-weight":"fontWeight","vertical-align":"valign","text-decoration":"textDecoration","background-color":"backgroundColor","border-color":"borderColor","float":"cssFloat"},e._parseCSSRegExp=new RegExp("([.#]\\w+)\\s*{([\\s\\S]*?)}","g"),e._aligndef={left:0,center:1,right:2,0:"left",1:"center",2:"right"},e._valigndef={top:0,middle:1,bottom:2,0:"top",1:"middle",2:"bottom"},e.styleSheets={},e.ALIGN_CENTER=1,e.ALIGN_RIGHT=2,e.VALIGN_MIDDLE=1,e.VALIGN_BOTTOM=2,e._CSS_BLOCK=1,e._DISPLAY_NONE=2,e._ABSOLUTE=4,e._WIDTH_SET=8,e._PADDING=[0,0,0,0],e._RECT=[-1,-1,-1,-1],e._SPACING=[0,0],e._ALIGNS=[0,0,0],e.ADDLAYOUTED=512,e._NEWFONT=4096,e._HEIGHT_SET=8192,e._BACKGROUND_SET=16384,e._FLOAT_RIGHT=32768,e._LINE_ELEMENT=65536,e._NOWARP=131072,e._WIDTHAUTO=262144,e._LISTERRESZIE=524288,e}(Style),AudioSound=function(t){function e(){this.url=null,this.audio=null,this.loaded=!1,e.__super.call(this)}__class(e,"laya.media.h5audio.AudioSound",t);var i=e.prototype;return i.dispose=function(){var t=e._audioCache[this.url];t&&(t.src="",delete e._audioCache[this.url])},i.load=function(t){function i(){s(),a.loaded=!0,a.event("complete")}function n(){s(),a.event("error")}function s(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",n)}this.url=t;var r=e._audioCache[t];if(r&&r.readyState>=2)return void this.event("complete");r||(r=Browser.createElement("audio"),r.src=t,e._audioCache[t]=r),r.addEventListener("canplaythrough",i),r.addEventListener("error",n);var a=this;this.audio=r,r.load?r.load():n()},i.play=function(t,i){if(void 0===t&&(t=0),void 0===i&&(i=0),!this.url)return null;var n;if(n=e._audioCache[this.url],!n)return null;var s;s=Pool.getItem("audio:"+this.url),s=s?s:n.cloneNode(!0);var r=new AudioSoundChannel(s);return r.url=this.url,r.loops=i,r.startTime=t,r.play(),SoundManager.addChannel(r),r},__getset(0,i,"duration",function(){var t;return t=e._audioCache[this.url],t?t.duration:0}),e._audioCache={},e}(EventDispatcher),SoundChannel=function(t){function e(){this.url=null,this.loops=0,this.startTime=NaN,this.isStopped=!1,this.completeHandler=null,e.__super.call(this)}__class(e,"laya.media.SoundChannel",t);var i=e.prototype;return i.play=function(){},i.stop=function(){},i.__runComplete=function(t){t&&t.run()},__getset(0,i,"volume",function(){return 1},function(t){}),__getset(0,i,"position",function(){return 0}),__getset(0,i,"duration",function(){return 0}),e}(EventDispatcher),Sound=function(t){function e(){e.__super.call(this)}__class(e,"laya.media.Sound",t);var i=e.prototype;return i.load=function(t){},i.play=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),null},i.dispose=function(){},__getset(0,i,"duration",function(){return 0}),e}(EventDispatcher),WebAudioSound=function(t){function e(){this.url=null,this.loaded=!1,this.data=null,this.audioBuffer=null,this.__toPlays=null,e.__super.call(this)}__class(e,"laya.media.webaudio.WebAudioSound",t);var i=e.prototype;return i.load=function(t){var i=this;if(this.url=t,this.audioBuffer=e._dataCache[t],this.audioBuffer)return void this._loaded(this.audioBuffer);if(e.e.on("loaded:"+t,this,this._loaded),e.e.on("err:"+t,this,this._err),!e.__loadingSound[t]){e.__loadingSound[t]=!0;var n=new Browser.window.XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=function(){i.data=n.response,e.buffs.push({buffer:i.data,url:i.url}),e.decode()},n.onerror=function(t){i._err()},n.send()}},i._err=function(){this._removeLoadEvents(),e.__loadingSound[this.url]=!1,this.event("error")},i._loaded=function(t){this._removeLoadEvents(),this.audioBuffer=t,e._dataCache[this.url]=this.audioBuffer,this.loaded=!0,this.event("complete")},i._removeLoadEvents=function(){e.e.off("loaded:"+this.url,this,this._loaded),e.e.off("err:"+this.url,this,this._err)},i.__playAfterLoaded=function(){if(this.__toPlays){var t,e=0,i=0;t=this.__toPlays,i=t.length;var n;for(e=0;i>e;e++)n=t[e],n[2]&&!n[2].isStopped&&this.play(n[0],n[1],n[2]);this.__toPlays.length=0}},i.play=function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),i=i?i:new WebAudioSoundChannel,this.audioBuffer||this.url&&(this.__toPlays||(this.__toPlays=[]),this.__toPlays.push([t,e,i]),this.once("complete",this,this.__playAfterLoaded),this.load(this.url)),i.url=this.url,i.loops=e,i.audioBuffer=this.audioBuffer,i.startTime=t,i.play(),SoundManager.addChannel(i),i},i.dispose=function(){delete e._dataCache[this.url],delete e.__loadingSound[this.url]},__getset(0,i,"duration",function(){return this.audioBuffer?this.audioBuffer.duration:0}),e.decode=function(){e.buffs.length<=0||e.isDecoding||(e.isDecoding=!0,e.tInfo=e.buffs.shift(),e.ctx.decodeAudioData(e.tInfo.buffer,e._done,e._fail))},e._done=function(t){e.e.event("loaded:"+e.tInfo.url,t),e.isDecoding=!1,e.decode()},e._fail=function(){e.e.event("err:"+e.tInfo.url,null),e.isDecoding=!1,e.decode()},e._playEmptySound=function(){if(null!=e.ctx){var t=e.ctx.createBufferSource();t.buffer=e._miniBuffer,t.connect(e.ctx.destination),t.start(0,0,0)}},e._unlock=function(){e._unlocked||(e._playEmptySound(),"running"==e.ctx.state&&(Browser.document.removeEventListener("mousedown",e._unlock,!0),Browser.document.removeEventListener("touchend",e._unlock,!0),e._unlocked=!0))},e.initWebAudio=function(){"running"!=e.ctx.state&&(e._unlock(),Browser.document.addEventListener("mousedown",e._unlock,!0),Browser.document.addEventListener("touchend",e._unlock,!0))},e._dataCache={},e.buffs=[],e.isDecoding=!1,e._unlocked=!1,e.tInfo=null,e.__loadingSound={},__static(e,["window",function(){return this.window=Browser.window},"webAudioEnabled",function(){return this.webAudioEnabled=e.window.AudioContext||e.window.webkitAudioContext||e.window.mozAudioContext},"ctx",function(){return this.ctx=e.webAudioEnabled?new(e.window.AudioContext||e.window.webkitAudioContext||e.window.mozAudioContext):void 0},"_miniBuffer",function(){return this._miniBuffer=e.ctx.createBuffer(1,1,22050)},"e",function(){return this.e=new EventDispatcher}]),e}(EventDispatcher),HttpRequest=function(t){function e(){this._responseType=null,this._data=null,e.__super.call(this),this._http=new Browser.window.XMLHttpRequest}__class(e,"laya.net.HttpRequest",t);var i=e.prototype;return i.send=function(t,e,i,n,s){void 0===i&&(i="get"),void 0===n&&(n="text"),this._responseType=n,this._data=null;var r=this,a=this._http;if(a.open(i,t,!0),s)for(var o=0;o=0?"/":"\\",a=this._url.lastIndexOf(r),o=a>=0?this._url.substr(0,a+1):"";a=this._url.indexOf("?");var h;h=a>=0?this._url.substr(a):"";for(var l=0,u=s.length;u>l;l++)s[l]=o+s[l]+h}else s=[this._url.replace(".json",".png")];s.reverse(),t.toLoads=s,t.pics=[]}return this.event("progress",.3+1/s.length*.6),this._loadImage(URL.formatURL(s.pop()))}if(this._data.pics.push(t),this._data.toLoads.length>0)return this.event("progress",.3+1/this._data.toLoads.length*.6),this._loadImage(URL.formatURL(this._data.toLoads.pop()));var c=this._data.frames,_=this._url.split("?")[0],d=this._data.meta&&this._data.meta.prefix?URL.basePath+this._data.meta.prefix:_.substring(0,_.lastIndexOf("."))+"/",f=this._data.pics,p=e.atlasMap[this._url]||(e.atlasMap[this._url]=[]);p.dir=d;for(var g in c){var m=c[g],v=f[m.frame.idx?m.frame.idx:0],y=d+g;e.cacheRes(y,Texture.create(v,m.frame.x,m.frame.y,m.frame.w,m.frame.h,m.spriteSourceSize.x,m.spriteSourceSize.y,m.sourceSize.w,m.sourceSize.h)),e.loadedMap[y].url=y,p.push(y)}this.complete(this._data)}else if("font"==i){if(!t.src)return this._data=t,this.event("progress",.5),this._loadImage(URL.formatURL(this._url.replace(".fnt",".png")));var x;x=new BitmapFont,x.parseFont(this._data,t);var w=this._url.split(".fnt")[0].split("/"),b=w[w.length-1];Text.registerBitmapFont(b,x),this._data=x,this.complete(this._data)}else this.complete(t)},i.complete=function(t){this._data=t,e._loaders.push(this),e._isWorking||e.checkNext()},i.endLoad=function(t){t&&(this._data=t),this._cache&&e.cacheRes(this._url,this._data),this.event("progress",1),this.event("complete",this.data instanceof Array?[this.data]:this.data)},__getset(0,i,"url",function(){return this._url}),__getset(0,i,"data",function(){return this._data}),__getset(0,i,"cache",function(){return this._cache}),__getset(0,i,"type",function(){return this._type}),e.checkNext=function(){e._isWorking=!0;for(var t=Browser.now(),i=t;e._startIndexe.maxTimeOut)return console.log("loader callback cost a long time:"+(Browser.now()-t)+" url="+e._loaders[e._startIndex-1].url),void Laya.timer.frameOnce(1,null,e.checkNext);e._loaders.length=0, +e._startIndex=0,e._isWorking=!1},e.clearRes=function(t,i){void 0===i&&(i=!1),t=URL.formatURL(t);var n=e.atlasMap[t];if(n){for(var s=0,r=n.length;r>s;s++){var a=n[s],o=e.getRes(a);o&&o.destroy(i),delete e.loadedMap[a]}n.length=0,delete e.atlasMap[t],delete e.loadedMap[t]}else{var h=e.loadedMap[t];h&&(h instanceof laya.resource.Texture&&h.bitmap&&h.destroy(i),delete e.loadedMap[t])}},e.getRes=function(t){return e.loadedMap[URL.formatURL(t)]},e.getAtlas=function(t){return e.atlasMap[URL.formatURL(t)]},e.cacheRes=function(t,i){t=URL.formatURL(t),null!=e.loadedMap[t]?console.log("Resources already exist,is repeated loading:",t):e.loadedMap[t]=i},e.setGroup=function(t,i){e.groupMap[i]||(e.groupMap[i]=[]),e.groupMap[i].push(t)},e.clearResByGroup=function(t){if(e.groupMap[t]){var i=e.groupMap[t],n=0,s=i.length;for(n=0;s>n;n++)e.clearRes(i[n]);i.length=0}},e.TEXT="text",e.JSON="json",e.XML="xml",e.BUFFER="arraybuffer",e.IMAGE="image",e.SOUND="sound",e.ATLAS="atlas",e.FONT="font",e.typeMap={png:"image",jpg:"image",jpeg:"image",txt:"text",json:"json",xml:"xml",als:"atlas",mp3:"sound",ogg:"sound",wav:"sound",part:"json",fnt:"font"},e.parserMap={},e.loadedMap={},e.groupMap={},e.maxTimeOut=100,e.atlasMap={},e._loaders=[],e._isWorking=!1,e._startIndex=0,e}(EventDispatcher),ColorFilter=function(t){function e(t){e.__super.call(this),t||(t=[.3,.59,.11,0,0,.3,.59,.11,0,0,.3,.59,.11,0,0,0,0,0,1,0]),this._mat=new Float32Array(16),this._alpha=new Float32Array(4);for(var i=0,n=0,s=0;20>s;s++)s%5!=4?this._mat[i++]=t[s]:this._alpha[n++]=t[s];this._action=RunDriver.createFilterAction(32),this._action.data=this}__class(e,"laya.filters.ColorFilter",t);var i=e.prototype;return Laya.imps(i,{"laya.filters.IFilter":!0}),i.callNative=function(t){t._$P.cf=this;t.model&&t.model.setFilterMatrix&&t.model.setFilterMatrix(this._mat,this._alpha)},__getset(0,i,"type",function(){return 32}),__getset(0,i,"action",function(){return this._action}),__getset(1,e,"DEFAULT",function(){return e._DEFAULT||(e._DEFAULT=new e([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0])),e._DEFAULT},laya.filters.Filter._$SET_DEFAULT),__getset(1,e,"GRAY",function(){return e._GRAY||(e._GRAY=new e([.3,.59,.11,0,0,.3,.59,.11,0,0,.3,.59,.11,0,0,0,0,0,1,0])),e._GRAY},laya.filters.Filter._$SET_GRAY),e._DEFAULT=null,e._GRAY=null,e}(Filter),LoaderManager=function(t){function e(){this.retryNum=1,this.maxLoader=5,this._loaders=[],this._loaderCount=0,this._resInfos=[],this._infoPool=[],this._maxPriority=5,this._failRes={},e.__super.call(this);for(var t=0;tn;n++){var s=h[n];i+=s.progress}var r=i/l;c.runWith(r)}if(void 0===s&&(s=1),void 0===r&&(r=!0),t instanceof Array){var h=t,l=h.length,u=0;if(i)var c=Handler.create(i.caller,i.method,i.args,!1);for(var _=0;l>_;_++){var d=h[_];"string"==typeof d&&(d=h[_]={url:d}),d.progress=0;var f=i?Handler.create(null,o,[d],!1):null,p=i||e?Handler.create(null,a,[d]):null;this._create(d.url,p,f,d.clas||n,d.priority||s,r)}return!0}return this._create(t,e,i,n,s,r)},n._create=function(t,i,n,s,r,a){function o(e){h&&h.onAsynLoaded.call(h,t,e),i&&i.run()}void 0===r&&(r=1),void 0===a&&(a=!0);var h=this.getRes(t);if(h)n&&n.runWith(1),i&&i.run();else{var l=Utils.getFileExtension(t),u=e.createMap[l];s||(s=u[0]);var c=u[1];s===Texture&&(c="htmlimage"),h=s?new s:null,this.load(t,Handler.create(null,o),n,c,r,!1,null,!0),a&&e.cacheRes(t,h)}return h},n.load=function(t,n,s,r,a,o,h,l){if(void 0===a&&(a=1),void 0===o&&(o=!0),void 0===l&&(l=!1),t instanceof Array)return this._loadAssets(t,n,s,r,a,o,h);t=URL.formatURL(t);var u=Loader.getRes(t);if(null!=u)s&&s.runWith(1),n&&n.runWith(u),this._loaderCount||this.event("complete");else{var c=e._resMap[t];c?(n&&c._createListener("complete",n.caller,n.method,n.args,!1,!1),s&&c._createListener("progress",s.caller,s.method,s.args,!1,!1)):(c=this._infoPool.length?this._infoPool.pop():new i,c.url=t,c.type=r,c.cache=o,c.group=h,c.ignoreCache=l,n&&c.on("complete",n.caller,n.method,n.args),s&&c.on("progress",s.caller,s.method,s.args),e._resMap[t]=c,a=a=this.maxLoader)){for(var t=0;t0){var i=e.shift();if(i)return this._doLoad(i)}}this._loaderCount||this.event("complete")}},n._doLoad=function(t){function e(e){i.offAll(),i._data=null,n._loaders.push(i),n._endLoad(t,e instanceof Array?[e]:e),n._loaderCount--,n._next()}this._loaderCount++;var i=this._loaders.length?this._loaders.pop():new Loader;i.on("complete",null,e),i.on("progress",null,function(e){t.event("progress",e)}),i.on("error",null,function(t){e(null)});var n=this;i.load(t.url,t.type,t.cache,t.group,t.ignoreCache)},n._endLoad=function(t,i){if(null===i){var n=this._failRes[t.url]||0;if(n-1;n--){var s=i[n];s&&(s.offAll(),this._infoPool.push(s))}i.length=0}this._loaderCount=0,e._resMap={}},n.cancelLoadByUrls=function(t){if(t)for(var e=0,i=t.length;i>e;e++)this.cancelLoadByUrl(t[e])},n.cancelLoadByUrl=function(t){t=URL.formatURL(t);for(var i=0;i-1;s--){var r=n[s];r&&r.url===t&&(n[s]=null,r.offAll(),this._infoPool.push(r))}e._resMap[t]&&delete e._resMap[t]},n._loadAssets=function(t,e,i,n,s,r,a){function o(t,i){u++,t.progress=1,u===l&&e&&e.run()}function h(t,e){if(null!=i){t.progress=e;for(var n=0,s=0;s<_.length;s++){var r=_[s];n+=r.size*r.progress}var a=n/c;i.runWith(a)}}void 0===s&&(s=1),void 0===r&&(r=!0);for(var l=t.length,u=0,c=0,_=[],d=n||"image",f=0;l>f;f++){var p=t[f];"string"==typeof p&&(p={url:p,type:d,size:1,priority:s}),p.size||(p.size=1),p.progress=0,c+=p.size,_.push(p);var g=i?Handler.create(null,h,[p],!1):null,m=e||i?Handler.create(null,o,[p]):null;this.load(p.url,m,g,p.type,p.priority||1,r,p.group||a)}return this},e.cacheRes=function(t,e){Loader.cacheRes(t,e)},e._resMap={},__static(e,["createMap",function(){return this.createMap={atlas:[null,"atlas"]}}]),e.__init$=function(){i=function(t){function e(){this.url=null,this.type=null,this.cache=!1,this.group=null,this.ignoreCache=!1,e.__super.call(this)}return __class(e,"",t),e}(EventDispatcher)},e}(EventDispatcher),Socket=function(t){function e(t,i,n){this._endian=null,this._stamp=NaN,this._socket=null,this._connected=!1,this._addInputPosition=0,this._input=null,this._output=null,this.timeout=0,this.objectEncoding=0,this.disableInput=!1,this._byteClass=null,void 0===i&&(i=0),e.__super.call(this),this._byteClass=n,this._byteClass=this._byteClass?this._byteClass:Byte,this.endian="bigEndian",this.timeout=2e4,this._addInputPosition=0,t&&i>0&&65535>i&&this.connect(t,i)}__class(e,"laya.net.Socket",t);var i=e.prototype;return i.connect=function(t,e){var i="ws://"+t+":"+e;this.connectByUrl(i)},i.connectByUrl=function(t){var e=this;null!=this._socket&&this.close(),this._socket&&this._cleanSocket(),this._socket=new Browser.window.WebSocket(t),this._socket.binaryType="arraybuffer",this._output=new this._byteClass,this._output.endian=this.endian,this._input=new this._byteClass,this._input.endian=this.endian,this._addInputPosition=0,this._socket.onopen=function(t){e._onOpen(t)},this._socket.onmessage=function(t){e._onMessage(t)},this._socket.onclose=function(t){e._onClose(t)},this._socket.onerror=function(t){e._onError(t)}},i._cleanSocket=function(){try{this._socket.close()}catch(t){}this._connected=!1,this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null,this._socket=null},i.close=function(){null!=this._socket&&this._cleanSocket()},i._onOpen=function(t){this._connected=!0,this.event("open",t)},i._onMessage=function(t){if(t&&t.data){var e=t.data;if(this.disableInput&&e)return void this.event("message",e);this._input.length>0&&this._input.bytesAvailable<1&&(this._input.clear(),this._addInputPosition=0);var i=this._input.pos;!this._addInputPosition&&(this._addInputPosition=0),this._input.pos=this._addInputPosition,e&&("string"==typeof e?this._input.writeUTFBytes(e):this._input.writeArrayBuffer(e),this._addInputPosition=this._input.pos,this._input.pos=i),this.event("message",e)}},i._onClose=function(t){this._connected=!1,this.event("close",t)},i._onError=function(t){this.event("error",t)},i.send=function(t){this._socket.send(t)},i.flush=function(){if(this._output&&this._output.length>0){var t;try{this._socket&&this._socket.send(this._output.__getBuffer().slice(0,this._output.length))}catch(e){t=e}this._output.endian=this.endian,this._output.clear(),t&&this.event("error",t)}},__getset(0,i,"input",function(){return this._input}),__getset(0,i,"output",function(){return this._output}),__getset(0,i,"connected",function(){return this._connected}),__getset(0,i,"endian",function(){return this._endian},function(t){this._endian=t,null!=this._input&&(this._input.endian=t),null!=this._output&&(this._output.endian=t)}),e.LITTLE_ENDIAN="littleEndian",e.BIG_ENDIAN="bigEndian",e}(EventDispatcher),Resource=function(t){function e(){this._id=0,this._lastUseFrameCount=0,this._memorySize=0,this._name=null,this._loaded=!1,this._released=!1,this._resourceManager=null,this.lock=!1,e.__super.call(this),this._$1__id=++e._uniqueIDCounter,e._loadedResources.push(this),e._isLoadedResourcesSorted=!1,this._released=!0,this.lock=!1,this._memorySize=0,this._lastUseFrameCount=-1,ResourceManager.currentResourceManager&&ResourceManager.currentResourceManager.addResource(this)}__class(e,"laya.resource.Resource",t);var i=e.prototype;return Laya.imps(i,{"laya.resource.ICreateResource":!0,"laya.resource.IDispose":!0}),i.recreateResource=function(){this.startCreate(),this.completeCreate()},i.detoryResource=function(){},i.activeResource=function(t){void 0===t&&(t=!1),this._lastUseFrameCount=Stat.loopCount,(this._released||t)&&this.recreateResource()},i.releaseResource=function(t){return void 0===t&&(t=!1),!t&&this.lock?!1:!this._released||t?(this.detoryResource(),this._released=!0,this._lastUseFrameCount=-1,this.event("released",this),!0):!1},i.setUniqueName=function(t){for(var i=!0,n=0;n0;var n=this;if(this._loaded)RunDriver.addToAtlas&&RunDriver.addToAtlas(n);else{var s=t;s instanceof laya.resource.HTMLImage&&s.image&&s.image.addEventListener("load",function(t){RunDriver.addToAtlas&&RunDriver.addToAtlas(n)},!1)}}},i.active=function(){this.bitmap.activeResource()},i.destroy=function(t){void 0===t&&(t=!1),this.bitmap&&this.bitmap.useNum>0&&(t?(this.bitmap.dispose(),this.bitmap.useNum=0):(this.bitmap.useNum--,0==this.bitmap.useNum&&this.bitmap.dispose()),this.bitmap=null,this.url&&this===Laya.loader.getRes(this.url)&&Laya.loader.clearRes(this.url),this._loaded=!1)},i.load=function(t){var e=this;this._loaded=!1;var i=this.bitmap||(this.bitmap=HTMLImage.create(URL.formatURL(t)));i&&i.useNum++;var n=this;i.onload=function(){i.onload=null,n._loaded=!0,e.sourceWidth=e._w=i.width,e.sourceHeight=e._h=i.height,n.event("loaded",this),RunDriver.addToAtlas&&RunDriver.addToAtlas(n)}},i.addTextureToAtlas=function(t){RunDriver.addTextureToAtlas(this)},i.getPixels=function(t,e,i,n){if(Render.isWebGL)return RunDriver.getTexturePixels(this,t,e,i,n);Browser.canvas.size(i,n),Browser.canvas.clear(),Browser.context.drawTexture(this,-t,-e,this.width,this.height,0,0);var s=Browser.context.getImageData(0,0,i,n);return s.data},i.onAsynLoaded=function(t,e){e&&e.useNum++,this.setTo(e,this.uv)},__getset(0,i,"source",function(){return this.bitmap.activeResource(),this.bitmap.source}),__getset(0,i,"loaded",function(){return this._loaded}),__getset(0,i,"released",function(){return this.bitmap.released}),__getset(0,i,"width",function(){return this._w?this._w:this.uv&&this.uv!==e.DEF_UV?(this.uv[2]-this.uv[0])*this.bitmap.width:this.bitmap.width},function(t){this._w=t,this.sourceWidth||(this.sourceWidth=t)}),__getset(0,i,"repeat",function(){return Render.isWebGL&&this.bitmap?this.bitmap.repeat:!0},function(t){t&&Render.isWebGL&&this.bitmap&&(this.bitmap.repeat=t,t&&(this.bitmap.enableMerageInAtlas=!1))}),__getset(0,i,"height",function(){return this._h?this._h:this.uv&&this.uv!==e.DEF_UV?(this.uv[5]-this.uv[1])*this.bitmap.height:this.bitmap.height},function(t){this._h=t,this.sourceHeight||(this.sourceHeight=t)}),__getset(0,i,"isLinearSampling",function(){return Render.isWebGL?9728!=this.bitmap.minFifter:!0},function(t){!t&&Render.isWebGL&&(t||-1!=this.bitmap.minFifter||-1!=this.bitmap.magFifter||(this.bitmap.minFifter=9728,this.bitmap.magFifter=9728,this.bitmap.enableMerageInAtlas=!1))}),e.moveUV=function(t,e,i){for(var n=0;8>n;n+=2)i[n]+=t,i[n+1]+=e;return i},e.create=function(t,i,n,s,r,a,o,h,l){void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),void 0===l&&(l=0);var u=t instanceof laya.resource.Texture,c=u?t.uv:e.DEF_UV,_=u?t.bitmap:t,d=new e(_,null);d.width=s,d.height=r,d.offsetX=a,d.offsetY=o,d.sourceWidth=h||s,d.sourceHeight=l||r;var f=1/_.width,p=1/_.height;i*=f,n*=p,s*=f,r*=p;var g=d.uv[0],m=d.uv[1],v=d.uv[4],y=d.uv[5],x=v-g,w=y-m,b=e.moveUV(c[0],c[1],[i,n,i+s,n,i+s,n+r,i,n+r]);return d.uv=[g+b[0]*x,m+b[1]*w,v-(1-b[2])*x,m+b[3]*w,v-(1-b[4])*x,y-(1-b[5])*w,g+b[6]*x,y-(1-b[7])*w],d},e.createFromTexture=function(t,i,n,s,r){var a=Rectangle.TEMP.setTo(i-t.offsetX,n-t.offsetY,s,r),o=a.intersection(e._rect1.setTo(0,0,t.width,t.height),e._rect2);if(!o)return null;var h=e.create(t,o.x,o.y,o.width,o.height,o.x-a.x,o.y-a.y,s,r);return h.bitmap.useNum--,h},e.DEF_UV=[0,0,1,0,1,1,0,1],e.INV_UV=[0,1,1,1,1,0,0,0],e._rect1=new Rectangle,e._rect2=new Rectangle,e}(EventDispatcher),TimeLine=function(t){function e(){this._labelDic=null,this._tweenDic={},this._tweenDataList=[],this._endTweenDataList=null,this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this._gidIndex=0,this._firstTweenDic={},this._startTimeSort=!1,this._endTimeSort=!1,this._loopKey=!1,this.scale=1,this._frameRate=60,this._frameIndex=0,this._total=0,e.__super.call(this)}var i;__class(e,"laya.utils.TimeLine",t);var n=e.prototype;return n.to=function(t,e,i,n,s){return void 0===s&&(s=0),this._create(t,e,i,n,s,!0)},n.from=function(t,e,i,n,s){return void 0===s&&(s=0),this._create(t,e,i,n,s,!1)},n._create=function(t,e,n,s,r,a){var o=new i;return o.isTo=a,o.type=0,o.target=t,o.duration=n,o.data=e,o.startTime=this._startTime+r,o.endTime=o.startTime+o.duration,o.ease=s,this._startTime=Math.max(o.endTime,this._startTime),this._tweenDataList.push(o),this._startTimeSort=!0,this._endTimeSort=!0,this},n.addLabel=function(t,e){var n=new i;return n.type=1,n.data=t,n.endTime=n.startTime=this._startTime+e,this._labelDic||(this._labelDic={}),this._labelDic[t]=n,this._tweenDataList.push(n),this},n.removeLabel=function(t){if(this._labelDic&&this._labelDic[t]){var e=this._labelDic[t];if(e){var i=this._tweenDataList.indexOf(e);i>-1&&this._tweenDataList.splice(i,1)}delete this._labelDic[t]}},n.gotoTime=function(t){function e(t,e){return t.endTime>e.endTime?1:t.endTimeh;h++)if(o=a[h],0==o.type){if(!(t>=o.endTime))break;this._index=Math.max(this._index,h+1);var u=o.data;for(var c in u)o.isTo&&(o.target[c]=u[c])}for(h=0,l=this._tweenDataList.length;l>h;h++)o=this._tweenDataList[h],0==o.type&&t>=o.startTime&&te.startTime?1:t.startTimen;n++){var r=this._tweenDataList[n];if(null!=r&&0==r.type){var a=r.target,o=a.$_GID||(a.$_GID=Utils.getGID()),h=null;null==this._firstTweenDic[o]?(h={},h.diyTarget=a,this._firstTweenDic[o]=h):h=this._firstTweenDic[o];for(var l in r.data)null==h[l]&&(h[l]=a[l])}}}"string"==typeof t?this.gotoLabel(t):this.gotoTime(t),this._loopKey=e,this._lastTime=Browser.now(),Laya.timer.frameLoop(1,this,this._update)},n._update=function(){if(this._currTime>=this._startTime){if(!this._loopKey)return this._complete(),void this.pause();this._complete(),this.gotoTime(0)}var t=Browser.now(),e=t-this._lastTime,i=this._currTime+=e*this.scale;this._lastTime=t;var n;if(0!=this._tweenDataList.length&&this._index=s.startTime&&(this._index++,0==s.type?(this._gidIndex++,n=Pool.getItemByClass("tween",Tween),n._create(s.target,s.data,s.duration,s.ease,new Handler(this,this._animComplete,[this._gidIndex]),0,!1,s.isTo,!0,!1),n.setStartTime(i),n.gid=this._gidIndex,this._tweenDic[this._gidIndex]=n):this.event("label",s.data))}for(var r in this._tweenDic)n=this._tweenDic[r],n._updateEase(i)},n._animComplete=function(t){var e=this._tweenDic[t];e&&delete this._tweenDic[t]},n._complete=function(){this.event("complete")},n.reset=function(){var t;if(this._labelDic)for(t in this._labelDic)delete this._labelDic[t];var e;for(t in this._tweenDic)e=this._tweenDic[t],e.clear(),delete this._tweenDic[t];for(t in this._firstTweenDic)delete this._firstTweenDic[t];this._endTweenDataList=null,this._tweenDataList.length=0,this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this._gidIndex=0,this.scale=1,Laya.timer.clear(this,this._update)},n.destroy=function(){this.reset(),this._labelDic=null,this._tweenDic=null,this._tweenDataList=null,this._firstTweenDic=null},__getset(0,n,"index",function(){return this._frameIndex},function(t){this._frameIndex=t,this.gotoTime(this._frameIndex/this._frameRate*1e3)}),__getset(0,n,"total",function(){return this._total=Math.floor(this._startTime/1e3*this._frameRate),this._total}),e.to=function(t,i,n,s,r){return void 0===r&&(r=0),(new e).to(t,i,n,s,r)},e.from=function(t,i,n,s,r){return void 0===r&&(r=0),(new e).from(t,i,n,s,r)},e.__init$=function(){i=function(){function t(){this.type=0,this.isTo=!0,this.startTime=NaN,this.endTime=NaN,this.target=null,this.duration=NaN,this.ease=null,this.data=null}return __class(t,""),t}()},e}(EventDispatcher),Sprite=function(t){function e(){this.mouseThrough=!1,this._transform=null,this._tfChanged=!1,this._x=0,this._y=0,this._width=0,this._height=0,this._repaint=1,this._changeType=0,this._mouseEnableState=0,this._zOrder=0,this._graphics=null,this._renderType=0,this.autoSize=!1,this.hitTestPrior=!1,this.viewport=null,this._optimizeScrollRect=!1,this._texture=null,e.__super.call(this),this._style=Style.EMPTY}__class(e,"laya.display.Sprite",t);var i=e.prototype;return Laya.imps(i,{"laya.display.ILayout":!0}),i.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this._style&&this._style.destroy(),this._transform=null,this._style=null,this._graphics=null},i.updateZOrder=function(){Utils.updateOrder(this._childs)&&this.repaint()},i.reCache=function(){this._$P.cacheCanvas&&(this._$P.cacheCanvas.reCache=!0)},i.setBounds=function(t){this._set$P("uBounds",t)},i.getBounds=function(){return this._$P.mBounds||this._set$P("mBounds",new Rectangle),Rectangle._getWrapRec(this._boundPointsToParent(),this._$P.mBounds)},i.getSelfBounds=function(){return this._$P.mBounds||this._set$P("mBounds",new Rectangle),Rectangle._getWrapRec(this._getBoundPointsM(!1),this._$P.mBounds)},i._boundPointsToParent=function(t){void 0===t&&(t=!1);var e=0,i=0;this._style&&(e=this._style._tf.translateX,i=this._style._tf.translateY,t=t||0!==this._style._tf.rotate,this._style.scrollRect&&(e+=this._style.scrollRect.x,i+=this._style.scrollRect.y));var n=this._getBoundPointsM(t);if(!n||n.length<1)return n;if(8!=n.length&&(n=t?GrahamScan.scanPList(n):Rectangle._getWrapRec(n,Rectangle.TEMP)._getBoundPoints()),!this.transform)return Utils.transPointList(n,this.x-e,this.y-i),n;var s=Point.TEMP,r=0,a=n.length;for(r=0;a>r;r+=2)s.x=n[r],s.y=n[r+1],this.toParentPoint(s),n[r]=s.x,n[r+1]=s.y;return n},i.getGraphicBounds=function(){return this._graphics?this._graphics.getBounds():Rectangle.TEMP.setTo(0,0,0,0)},i._getBoundPointsM=function(t){if(void 0===t&&(t=!1),this._$P.uBounds)return this._$P.uBounds._getBoundPoints();if(this._$P.temBM||this._set$P("temBM",[]),this.scrollRect){var e=Utils.clearArray(this._$P.temBM),i=Rectangle.TEMP;return i.copyFrom(this.scrollRect),Utils.concatArray(e,i._getBoundPoints()),e}var n,s,r,a=this._graphics?this._graphics.getBoundPoints():Utils.clearArray(this._$P.temBM);r=this._childs;for(var o=0,h=r.length;h>o;o++)n=r[o],n instanceof laya.display.Sprite&&1==n.visible&&(s=n._boundPointsToParent(t),s&&(a=a?Utils.concatArray(a,s):s));return a},i.getStyle=function(){return this._style===Style.EMPTY&&(this._style=new Style),this._style},i.setStyle=function(t){this._style=t},i._adjustTransform=function(){"use strict";this._tfChanged=!1;var t,e=this._style,i=e._tf,n=i.scaleX,s=i.scaleY;if(i.rotate||1!==n||1!==s||i.skewX||i.skewY){if(t=this._transform||(this._transform=Matrix.create()),t.bTransform=!0,i.rotate){var r=.0174532922222222*i.rotate,a=t.cos=Math.cos(r),o=t.sin=Math.sin(r);return t.a=n*a,t.b=n*o,t.c=-s*o,t.d=s*a,t.tx=t.ty=0,t}return t.a=n,t.d=s,t.c=t.b=t.tx=t.ty=0,i.skewX||i.skewY?t.skew(.0174532922222222*i.skewX,.0174532922222222*i.skewY):t}return this._transform&&this._transform.destroy(),this._transform=null,this._renderType&=-5,t},i.pos=function(t,e){return this._x===t&&this._y===e||(this.x=t,this.y=e),this},i.pivot=function(t,e){return this.pivotX=t,this.pivotY=e,this},i.size=function(t,e){return this.width=t,this.height=e,this},i.scale=function(t,e){return this.scaleX=t,this.scaleY=e,this},i.skew=function(t,e){return this.skewX=t,this.skewY=e,this},i.render=function(t,e,i){Stat.spriteCount++,RenderSprite.renders[this._renderType]._fun(this,t,e+this._x,i+this._y),this._repaint=0},i.drawToCanvas=function(t,e,i,n){return RunDriver.drawToCanvas(this,this._renderType,t,e,i,n)},i.customRender=function(t,e,i){this._renderType|=512},i._applyFilters=function(){if(!Render.isWebGL){var t;if(t=this._$P.filters,t&&!(t.length<1))for(var e=0,i=t.length;i>e;e++)t[e].action.apply(this._$P.cacheCanvas)}},i._isHaveGlowFilter=function(){var t=0,e=0;if(this.filters)for(t=0;tt;t++)if(this._childs[t]._isHaveGlowFilter())return!0;return!1},i.localToGlobal=function(t,e){if(void 0===e&&(e=!1),!this._displayedInStage||!t)return t;e===!0&&(t=new Point(t.x,t.y));for(var i=this;i&&i!=Laya.stage;)t=i.toParentPoint(t),i=i.parent;return t},i.globalToLocal=function(t,e){if(void 0===e&&(e=!1),!this._displayedInStage||!t)return t;e===!0&&(t=new Point(t.x,t.y));for(var i=this,n=[];i&&i!=Laya.stage;)n.push(i),i=i.parent;for(var s=n.length-1;s>=0;)i=n[s],t=i.fromParentPoint(t),s--;return t},i.toParentPoint=function(t){if(!t)return t;t.x-=this.pivotX,t.y-=this.pivotY,this.transform&&this._transform.transformPoint(t),t.x+=this._x,t.y+=this._y;var e=this._style.scrollRect;return e&&(t.x-=e.x,t.y-=e.y),t},i.fromParentPoint=function(t){if(!t)return t;t.x-=this._x,t.y-=this._y;var e=this._style.scrollRect;return e&&(t.x+=e.x,t.y+=e.y),this.transform&&this._transform.invertTransformPoint(t),t.x+=this.pivotX,t.y+=this.pivotY,t},i.on=function(t,e,i,n){return 1!==this._mouseEnableState&&this.isMouseEvent(t)&&(this._displayedInStage?this._$2__onDisplay():laya.events.EventDispatcher.prototype.once.call(this,"display",this,this._$2__onDisplay)),laya.events.EventDispatcher.prototype.on.call(this,t,e,i,n)},i.once=function(t,e,i,n){return 1!==this._mouseEnableState&&this.isMouseEvent(t)&&(this._displayedInStage?this._$2__onDisplay():laya.events.EventDispatcher.prototype.once.call(this,"display",this,this._$2__onDisplay)),laya.events.EventDispatcher.prototype.once.call(this,t,e,i,n)},i._$2__onDisplay=function(){if(1!==this._mouseEnableState)for(var t=this;t&&1!==t._mouseEnableState;)t.mouseEnabled=!0,t=t.parent},i.loadImage=function(t,e,i,n,s,r){function a(t){o.destroyed||(o.size(e+(n||t.width),i+(s||t.height)),o.repaint(),r&&r.runWith(t))}var o=this;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),this.graphics.loadImage(t,e,i,n,s,a),this},i.repaint=function(){this.model&&this.model.repaint&&this.model.repaint(),0===this._repaint&&(this._repaint=1,this.parentRepaint()),this._$P&&this._$P.maskParent&&this._$P.maskParent.repaint()},i._needRepaint=function(){return 0!==this._repaint&&this._$P.cacheCanvas&&this._$P.cacheCanvas.reCache},i._childChanged=function(t){this._childs.length?this._renderType|=2048:this._renderType&=-2049,t&&t.zOrder&&Laya.timer.callLater(this,this.updateZOrder),this.repaint()},i.parentRepaint=function(){var t=this._parent;t&&0===t._repaint&&(t._repaint=1,t.parentRepaint())},i.startDrag=function(t,e,i,n,s,r,a){void 0===e&&(e=!1),void 0===i&&(i=0),void 0===n&&(n=300),void 0===r&&(r=!1),void 0===a&&(a=.92),this._$P.dragging||this._set$P("dragging",new Dragging),this._$P.dragging.start(this,t,e,i,n,s,r,a)},i.stopDrag=function(){this._$P.dragging&&this._$P.dragging.stop()},i._setDisplay=function(e){if(!e&&this._$P.cacheCanvas&&this._$P.cacheCanvas.ctx&&(Pool.recover("RenderContext",this._$P.cacheCanvas.ctx),this._$P.cacheCanvas.ctx=null),!e){var i=this._$P._filterCache;i&&(i.destroy(),i.recycle(),this._set$P("_filterCache",null)),this._$P._isHaveGlowFilter&&this._set$P("_isHaveGlowFilter",!1)}t.prototype._setDisplay.call(this,e)},i.hitTestPoint=function(t,e){var i=this.globalToLocal(Point.TEMP.setTo(t,e)),n=this._$P.hitArea?this._$P.hitArea:Rectangle.EMPTY.setTo(0,0,this._width,this._height);return n.contains(i.x,i.y)},i.getMousePoint=function(){return this.globalToLocal(Point.TEMP.setTo(Laya.stage.mouseX,Laya.stage.mouseY))},i._getWords=function(){return null},i._addChildsToLayout=function(t){var e=this._getWords();if(null==e&&0==this._childs.length)return!1;if(e)for(var i=0,n=e.length;n>i;i++)t.push(e[i]);return this._childs.forEach(function(e,i,n){e._style._enableLayout()&&e._addToLayout(t)}),!0},i._addToLayout=function(t){this._style.absolute||(this._style.block?t.push(this):this._addChildsToLayout(t)&&(this.x=this.y=0))},i._isChar=function(){return!1},i._getCSSStyle=function(){return this._style.getCSSStyle()},i._setAttributes=function(t,e){switch(t){case"x":this.x=parseFloat(e);break;case"y":this.y=parseFloat(e);break;case"width":this.width=parseFloat(e);break;case"height":this.height=parseFloat(e);break;default:this[t]=e}},i._layoutLater=function(){this.parent&&this.parent._layoutLater()},__getset(0,i,"optimizeScrollRect",function(){return this._optimizeScrollRect},function(t){this._optimizeScrollRect!=t&&(this._optimizeScrollRect=t,this.model&&this.model.optimizeScrollRect(t))}),__getset(0,i,"customRenderEnable",null,function(t){if(t&&(this._renderType|=512,Render.isConchNode)){laya.display.Sprite.CustomList.push(this);var e=new HTMLCanvas("2d");e._setContext(new CanvasRenderingContext2D),this.customContext=new RenderContext(0,0,e),e.context.setCanvasType&&e.context.setCanvasType(2),this.model.custom(e.context)}}),__getset(0,i,"cacheAsBitmap",function(){return"none"!==this.cacheAs},function(t){this.cacheAs=t?this._$P.hasFilter?"none":"normal":"none"}),__getset(0,i,"cacheAs",function(){return null==this._$P.cacheCanvas?"none":this._$P.cacheCanvas.type},function(t){var e=this._$P.cacheCanvas;t!==(e?e.type:"none")&&("none"!==t?(e||(e=this._set$P("cacheCanvas",Pool.getItemByClass("cacheCanvas",Object))),e.type=t,e.reCache=!0,this._renderType|=8,"bitmap"==t&&this.model&&this.model.cacheAs(1),this._set$P("cacheForFilters",!1)):this._$P.hasFilter?this._set$P("cacheForFilters",!0):(e&&Pool.recover("cacheCanvas",e),this._$P.cacheCanvas=null,this._renderType&=-9,this.model&&this.model.cacheAs(0)),this.repaint())}),__getset(0,i,"zOrder",function(){return this._zOrder},function(t){this._zOrder!=t&&(this._zOrder=t,this.model&&this.model.setZOrder&&this.model.setZOrder(t),this._parent&&Laya.timer.callLater(this._parent,this.updateZOrder))}),__getset(0,i,"rotation",function(){return this._style._tf.rotate},function(t){var e=this.getStyle(); +if(e._tf.rotate!==t){this._changeType|=16,e.setRotate(t),this._tfChanged=!0,this.model&&this.model.rotate(t),this._renderType|=4;var i=this._parent;i&&0===i._repaint&&(i._repaint=1,i.parentRepaint())}}),__getset(0,i,"width",function(){return this.autoSize?this.getSelfBounds().width:this._width},function(t){this._width!==t&&(this._width=t,this.model&&this.model.size(t,this._height),this.repaint())}),__getset(0,i,"x",function(){return this._x},function(t){if(this._x!==t){if(this.destroyed)return;this._x=t,this.model&&this.model.pos(t,this._y);var e=this._parent;e&&0===e._repaint&&(e._repaint=1,e.parentRepaint()),this._$P.maskParent&&0===this._$P.maskParent._repaint&&(this._$P.maskParent._repaint=1,this._$P.maskParent.parentRepaint())}}),__getset(0,i,"globalScaleY",function(){for(var t=1,e=this;e&&e!==Laya.stage;)t*=e.scaleX,e=e.parent;return t}),__getset(0,i,"hitArea",function(){return this._$P.hitArea},function(t){this._set$P("hitArea",t)}),__getset(0,i,"staticCache",function(){return this._$P.staticCache},function(t){this._set$P("staticCache",t),!t&&this._$P.cacheCanvas&&(this._$P.cacheCanvas.reCache=!0)}),__getset(0,i,"texture",function(){return this._texture},function(t){this._texture!=t&&(this._texture=t,this.graphics.cleanByTexture(t,0,0))}),__getset(0,i,"y",function(){return this._y},function(t){if(this._y!==t){if(this.destroyed)return;this._y=t,this.model&&this.model.pos(this._x,t);var e=this._parent;e&&0===e._repaint&&(e._repaint=1,e.parentRepaint()),this._$P.maskParent&&0===this._$P.maskParent._repaint&&(this._$P.maskParent._repaint=1,this._$P.maskParent.parentRepaint())}}),__getset(0,i,"height",function(){return this.autoSize?this.getSelfBounds().height:this._height},function(t){this._height!==t&&(this._height=t,this.model&&this.model.size(this._width,t),this.repaint())}),__getset(0,i,"blendMode",function(){return this._style.blendMode},function(t){this.getStyle().blendMode=t,this.model&&this.model.blendMode(t),t&&"source-over"!=t?this._renderType|=32:this._renderType&=-33,this.parentRepaint()}),__getset(0,i,"scaleX",function(){return this._style._tf.scaleX},function(t){var e=this.getStyle();if(e._tf.scaleX!==t){e.setScaleX(t),this._changeType|=16,this._tfChanged=!0,this.model&&this.model.scale(t,e._tf.scaleY),this._renderType|=4;var i=this._parent;i&&0===i._repaint&&(i._repaint=1,i.parentRepaint())}}),__getset(0,i,"scaleY",function(){return this._style._tf.scaleY},function(t){var e=this.getStyle();if(e._tf.scaleY!==t){e.setScaleY(t),this._changeType|=16,this._tfChanged=!0,this.model&&this.model.scale(e._tf.scaleX,t),this._renderType|=4;var i=this._parent;i&&0===i._repaint&&(i._repaint=1,i.parentRepaint())}}),__getset(0,i,"stage",function(){return Laya.stage}),__getset(0,i,"skewX",function(){return this._style._tf.skewX},function(t){var e=this.getStyle();if(e._tf.skewX!==t){e.setSkewX(t),this._tfChanged=!0,this._renderType|=4;var i=this._parent;i&&0===i._repaint&&(i._repaint=1,i.parentRepaint())}}),__getset(0,i,"scrollRect",function(){return this._style.scrollRect},function(t){this.getStyle().scrollRect=t,this.viewport=t,this.repaint(),t?(this._renderType|=64,this.model&&this.model.scrollRect(t.x,t.y,t.width,t.height)):(this._renderType&=-65,this.model&&this.model.removeType(64))}),__getset(0,i,"skewY",function(){return this._style._tf.skewY},function(t){var e=this.getStyle();if(e._tf.skewY!==t){e.setSkewY(t),this._tfChanged=!0,this.model&&this.model.skew(e._tf.skewX,t),this._renderType|=4;var i=this._parent;i&&0===i._repaint&&(i._repaint=1,i.parentRepaint())}}),__getset(0,i,"transform",function(){return this._tfChanged?this._adjustTransform():this._transform},function(t){this._tfChanged=!1,this._transform=t,t&&(this._x=t.tx,this._y=t.ty,t.tx=t.ty=0,this.model&&this.model.transform(t.a,t.b,t.c,t.d,this._x,this._y)),t?this._renderType|=4:(this._renderType&=-5,this.model&&this.model.removeType(4)),this.parentRepaint()}),__getset(0,i,"pivotX",function(){return this._style._tf.translateX},function(t){this.getStyle().setTranslateX(t),this._changeType|=16,this.model&&this.model.pivot(t,this._style._tf.translateY),this.repaint()}),__getset(0,i,"pivotY",function(){return this._style._tf.translateY},function(t){this.getStyle().setTranslateY(t),this._changeType|=16,this.model&&this.model.pivot(this._style._tf.translateX,t),this.repaint()}),__getset(0,i,"alpha",function(){return this._style.alpha},function(t){this._style&&this._style.alpha!==t&&(t=0>t?0:t>1?1:t,this.getStyle().alpha=t,this.model&&this.model.alpha(t),1!==t?this._renderType|=2:this._renderType&=-3,this.parentRepaint())}),__getset(0,i,"visible",function(){return this._style.visible},function(t){this._style&&this._style.visible!==t&&(this.getStyle().visible=t,this.model&&this.model.visible(t),this.parentRepaint())}),__getset(0,i,"graphics",function(){return this._graphics||(this.graphics=RunDriver.createGraphics())},function(t){this._graphics&&(this._graphics._sp=null),this._graphics=t,t?(this._renderType&=-2,this._renderType|=256,t._sp=this,this.model&&this.model.graphics(this._graphics)):(this._renderType&=-257,this._renderType&=-2,this.model&&this.model.removeType(256)),this.repaint()}),__getset(0,i,"filters",function(){return this._$P.filters},function(t){t&&0===t.length&&(t=null),this._$P.filters!=t&&(this._set$P("filters",t?t.slice():null),Render.isConchApp&&(this.model&&this.model.removeType(16),this._$P.filters&&1==this._$P.filters.length&&this._$P.filters[0].callNative(this)),Render.isWebGL&&(t&&t.length?this._renderType|=16:this._renderType&=-17),t&&t.length>0?Render.isWebGL&&1==t.length&&t[0]instanceof laya.filters.ColorFilter||("bitmap"!=this.cacheAs&&(Render.isConchNode||(this.cacheAs="bitmap"),this._set$P("cacheForFilters",!0)),this._set$P("hasFilter",!0)):(this._set$P("hasFilter",!1),this._$P.cacheForFilters&&"bitmap"==this.cacheAs&&(this.cacheAs="none")),this.repaint())}),__getset(0,i,"mask",function(){return this._$P._mask},function(t){t&&this.mask&&this.mask._$P.maskParent||(t?(this.cacheAs="bitmap",this._set$P("_mask",t),t._set$P("maskParent",this)):(this.cacheAs="none",this.mask&&this.mask._set$P("maskParent",null),this._set$P("_mask",t)),this.model&&this.model.mask(t?t.model:null),this._renderType|=32,this.parentRepaint())}),__getset(0,i,"mouseEnabled",function(){return this._mouseEnableState>1},function(t){this._mouseEnableState=t?2:1}),__getset(0,i,"globalScaleX",function(){for(var t=1,e=this;e&&e!==Laya.stage;)t*=e.scaleX,e=e.parent;return t}),__getset(0,i,"mouseX",function(){return this.getMousePoint().x}),__getset(0,i,"mouseY",function(){return this.getMousePoint().y}),e.fromImage=function(t){return(new e).loadImage(t)},e.CHG_VIEW=16,e.CHG_SCALE=256,e.CHG_TEXTURE=4096,e.CustomList=[],e}(Node),AudioSoundChannel=function(t){function e(t){this._audio=null,this._onEnd=null,this._resumePlay=null,e.__super.call(this),this._onEnd=Utils.bind(this.__onEnd,this),this._resumePlay=Utils.bind(this.__resumePlay,this),t.addEventListener("ended",this._onEnd),this._audio=t}__class(e,"laya.media.h5audio.AudioSoundChannel",t);var i=e.prototype;return i.__onEnd=function(){return 1==this.loops?(this.completeHandler&&(Laya.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event("complete")):(this.loops>0&&this.loops--,void this.play())},i.__resumePlay=function(){this._audio&&this._audio.removeEventListener("canplay",this._resumePlay);try{this._audio.currentTime=this.startTime,Browser.container.appendChild(this._audio),this._audio.play()}catch(t){this.event("error")}},i.play=function(){try{this._audio.currentTime=this.startTime}catch(t){return void this._audio.addEventListener("canplay",this._resumePlay)}Browser.container.appendChild(this._audio),"play"in this._audio&&this._audio.play()},i.stop=function(){this.isStopped=!0,SoundManager.removeChannel(this),this.completeHandler=null,this._audio&&("pause"in this._audio&&this._audio.pause(),this._audio.removeEventListener("ended",this._onEnd),this._audio.removeEventListener("canplay",this._resumePlay),Pool.recover("audio:"+this.url,this._audio),Browser.removeElement(this._audio),this._audio=null)},__getset(0,i,"position",function(){return this._audio?this._audio.currentTime:0}),__getset(0,i,"duration",function(){return this._audio?this._audio.duration:0}),__getset(0,i,"volume",function(){return this._audio?this._audio.volume:1},function(t){this._audio&&(this._audio.volume=t)}),e}(SoundChannel),WebAudioSoundChannel=function(t){function e(){this.audioBuffer=null,this.gain=null,this.bufferSource=null,this._currentTime=0,this._volume=1,this._startTime=0,this._onPlayEnd=null,this.context=WebAudioSound.ctx,e.__super.call(this),this._onPlayEnd=Utils.bind(this.__onPlayEnd,this),this.context.createGain?this.gain=this.context.createGain():this.gain=this.context.createGainNode()}__class(e,"laya.media.webaudio.WebAudioSoundChannel",t);var i=e.prototype;return i.play=function(){if(this._clearBufferSource(),this.audioBuffer){var t=this.context,e=this.gain,i=t.createBufferSource();this.bufferSource=i,i.buffer=this.audioBuffer,i.connect(e),e&&e.disconnect(),e.connect(t.destination),i.onended=this._onPlayEnd,this._startTime=Browser.now(),this.gain.gain.value=this._volume,0==this.loops&&(i.loop=!0),i.start(0,this.startTime),this._currentTime=0}},i.__onPlayEnd=function(){return 1==this.loops?(this.completeHandler&&(Laya.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event("complete")):(this.loops>0&&this.loops--,void this.play())},i._clearBufferSource=function(){if(this.bufferSource){var t=this.bufferSource;t.stop?t.stop(0):t.noteOff(0),t.disconnect(0),t.onended=null,e._tryCleanFailed||this._tryClearBuffer(t),this.bufferSource=null}},i._tryClearBuffer=function(t){try{t.buffer=WebAudioSound._miniBuffer}catch(i){e._tryCleanFailed=!0}},i.stop=function(){this._clearBufferSource(),this.audioBuffer=null,this.gain&&this.gain.disconnect(),this.isStopped=!0,SoundManager.removeChannel(this),this.completeHandler=null},__getset(0,i,"position",function(){return this.bufferSource?(Browser.now()-this._startTime)/1e3+this.startTime:0}),__getset(0,i,"duration",function(){return this.audioBuffer?this.audioBuffer.duration:0}),__getset(0,i,"volume",function(){return this._volume},function(t){this.isStopped||(this._volume=t,this.gain.gain.value=t)}),e._tryCleanFailed=!1,e}(SoundChannel),Bitmap=function(t){function e(){this.useNum=0,e.__super.call(this),this._w=0,this._h=0}__class(e,"laya.resource.Bitmap",t);var i=e.prototype;return i.dispose=function(){this._resourceManager.removeResource(this),t.prototype.dispose.call(this)},__getset(0,i,"width",function(){return this._w}),__getset(0,i,"height",function(){return this._h}),__getset(0,i,"source",function(){return this._source}),e}(Resource),AnimationPlayerBase=function(t){function e(){this.loop=!1,this.wrapMode=0,this._index=0,this._count=0,this._isPlaying=!1,this._labels=null,this._isReverse=!1,this._frameRateChanged=!1,this._controlNode=null,this._actionName=null,e.__super.call(this),this._interval=Config.animationInterval}__class(e,"laya.display.AnimationPlayerBase",t);var i=e.prototype;return i.play=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=!0),void 0===i&&(i=""),this._isPlaying=!0,this.index="string"==typeof t?this._getFrameByLabel(t):t,this.loop=e,this._actionName=i,this._isReverse=1==this.wrapMode,this.interval>0&&this.timerLoop(this.interval,this,this._frameLoop,null,!0)},i._getFrameByLabel=function(t){var e=0;for(e=0;e0?1:0,this._isReverse=!1):this._index=this._count-1,this.event("complete")}}else if(this._index++,this._index>=this._count){if(!this.loop)return this._index--,this.stop(),void this.event("complete");2==this.wrapMode?(this._index=this._count-2>=0?this._count-2:0,this._isReverse=!0):this._index=0,this.event("complete")}this.index=this._index},i._setControlNode=function(t){this._controlNode&&(this._controlNode.off("display",this,this._$3__onDisplay),this._controlNode.off("undisplay",this,this._$3__onDisplay)),this._controlNode=t,t&&t!=this&&(t.on("display",this,this._$3__onDisplay),t.on("undisplay",this,this._$3__onDisplay))},i._setDisplay=function(e){t.prototype._setDisplay.call(this,e),this._$3__onDisplay()},i._$3__onDisplay=function(){this._isPlaying&&(this._controlNode.displayedInStage?this.play(this._index,this.loop,this._actionName):this.clearTimer(this,this._frameLoop))},i.stop=function(){this._isPlaying=!1,this.clearTimer(this,this._frameLoop)},i.addLabel=function(t,e){this._labels||(this._labels={}),this._labels[e]=t},i.removeLabel=function(t){if(t){if(this._labels)for(var e in this._labels)if(this._labels[e]===t){delete this._labels[e];break}}else this._labels=null},i.gotoAndStop=function(t){this.index="string"==typeof t?this._getFrameByLabel(t):t,this.stop()},i._displayToIndex=function(t){},i.clear=function(){this.stop(),this._labels=null},__getset(0,i,"interval",function(){return this._interval},function(t){this._interval!=t&&(this._frameRateChanged=!0,this._interval=t,this._isPlaying&&t>0&&this.timerLoop(t,this,this._frameLoop,null,!0))}),__getset(0,i,"isPlaying",function(){return this._isPlaying}),__getset(0,i,"index",function(){return this._index},function(t){this._index=t,this._displayToIndex(t),this._labels&&this._labels[t]&&this.event("label",this._labels[t])}),__getset(0,i,"count",function(){return this._count}),e}(Sprite),Text=function(t){function e(){this._clipPoint=null,this._currBitmapFont=null,this._text=null,this._isChanged=!1,this._textWidth=0,this._textHeight=0,this._lines=[],this._lineWidths=[],this._startX=NaN,this._startY=NaN,this._lastVisibleLineIndex=-1,this._words=null,this._charSize={},this.underline=!1,this._underlineColor=null,e.__super.call(this),this.overflow=e.VISIBLE,this._style=new CSSStyle(this),this._style.wordWrap=!1}__class(e,"laya.display.Text",t);var i=e.prototype;return i.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this._lines=null,this._words&&(this._words.length=0,this._words=null)},i._getBoundPointsM=function(t){void 0===t&&(t=!1);var e=Rectangle.TEMP;return e.setTo(0,0,this.width,this.height),e._getBoundPoints()},i.getGraphicBounds=function(){var t=Rectangle.TEMP;return t.setTo(0,0,this.width,this.height),t},i._getCSSStyle=function(){return this._style},i.lang=function(t,i,n,s,r,a,o,h,l,u,c){if(t=e.langPacks&&e.langPacks[t]?e.langPacks[t]:t,arguments.length<2)this._text=t;else{for(var _=0,d=arguments.length;d>_;_++)t=t.replace("{"+_+"}",arguments[_+1]);this._text=t}},i.renderText=function(t,e){var i=this.graphics;i.clear();var n=(this.italic?"italic ":"")+(this.bold?"bold ":"")+this.fontSize+"px "+this.font;Browser.context.font=n;var s=this.padding,r=s[3],a="left",o=this._lines,h=this.leading+this._charSize.height,l=this._currBitmapFont;l&&(h=this.leading+l.getMaxHeight());var u=s[0];if(!l&&this._width>0&&this._textWidth<=this._width&&("right"==this.align?(a="right",r=this._width-s[1]):"center"==this.align&&(a="center",r=.5*this._width+s[3]-s[1])),this._height>0){var c=this._textHeight>this._height?"top":this.valign;"middle"===c?u=.5*(this._height-e*h)+s[0]-s[2]:"bottom"===c&&(u=this._height-e*h-s[2])}var _=this._style;if(l&&l.autoScaleSize)var d=l.fontSize/this.fontSize;if(this._clipPoint)if(i.save(),l&&l.autoScaleSize){var f=0,p=0;f=this._width?this._width-s[3]-s[1]:this._textWidth,p=this._height?this._height-s[0]-s[2]:this._textHeight,f*=d,p*=d,i.clipRect(s[3],s[0],f,p)}else i.clipRect(s[3],s[0],this._width?this._width-s[3]-s[1]:this._textWidth,this._height?this._height-s[0]-s[2]:this._textHeight);var g=_.password;"prompt"in this&&this.prompt==this._text&&(g=!1);for(var m=0,v=0,y=Math.min(this._lines.length,e+t)||1,x=t;y>x;x++){var w,b=o[x];if(g){var T=b.length;b="";for(var S=T;S>0;S--)b+="●"}if(m=r-(this._clipPoint?this._clipPoint.x:0),v=u+h*x-(this._clipPoint?this._clipPoint.y:0),this.underline&&this.drawUnderline(a,m,v,x),l){var C=this.width;l.autoScaleSize&&(C=this.width*d),l.drawText(b,this,m,v,this.align,C)}else Render.isWebGL?(this._words||(this._words=[]),w=this._words.length>x-t?this._words[x-t]:new WordText,w.setText(b)):w=b,_.stroke?i.fillBorderText(w,m,v,n,this.color,_.strokeColor,_.stroke,a):i.fillText(w,m,v,n,this.color,a)}if(l&&l.autoScaleSize){var M=1/d;this.scale(M,M)}this._clipPoint&&i.restore(),this._startX=r,this._startY=u},i.drawUnderline=function(t,e,i,n){var s=this._lineWidths[n];switch(t){case"center":e-=s/2;break;case"right":e-=s;break;case"left":}i+=this._charSize.height,this._graphics.drawLine(e,i,e+s,i,this.underlineColor||this.color,1)},i.typeset=function(){if(this._isChanged=!1,!this._text)return this._clipPoint=null,this._textWidth=this._textHeight=0,void this.graphics.clear();Browser.context.font=this._getCSSStyle().font,this._lines.length=0,this._lineWidths.length=0,this.parseLines(this._text),this.evalTextSize(),this.checkEnabledViewportOrNot()?this._clipPoint||(this._clipPoint=new Point(0,0)):this._clipPoint=null;var t=this._lines.length;if(this.overflow!=e.VISIBLE){var i=this.overflow==e.HIDDEN?Math.floor:Math.ceil;t=Math.min(t,i((this.height-this.padding[0]-this.padding[2])/(this.leading+this._charSize.height)))}var n=this.scrollY/(this._charSize.height+this.leading)|0;this.renderText(n,t),this.repaint()},i.evalTextSize=function(){var t=NaN,e=NaN;t=Math.max.apply(this,this._lineWidths),e=this._currBitmapFont?this._lines.length*(this._currBitmapFont.getMaxHeight()+this.leading)+this.padding[0]+this.padding[2]:this._lines.length*(this._charSize.height+this.leading)+this.padding[0]+this.padding[2],t==this._textWidth&&e==this._textHeight||(this._textWidth=t,this._textHeight=e,this._width&&this._height||this.model&&this.model.size(this._width||this._textWidth,this._height||this._textHeight))},i.checkEnabledViewportOrNot=function(){return this.overflow==e.SCROLL&&(this._width>0&&this._textWidth>this._width||this._height>0&&this._textHeight>this._height)},i.changeText=function(t){this._text!==t&&(this.lang(t+""),this._graphics&&this._graphics.replaceText(this._text)||this.typeset())},i.parseLines=function(t){var i=this.wordWrap||this.overflow==e.HIDDEN;if(i)var n=this.getWordWrapWidth();var s=Browser.context.measureText("阳");this._charSize.width=s.width,this._charSize.height=s.height||this.fontSize;for(var r=t.replace(/\r\n/g,"\n").split("\n"),a=0,o=r.length;o>a;a++){o-1>a&&(r[a]+="\n");var h=r[a];i?this.parseLine(h,n):(this._lineWidths.push(this.getTextWidth(h)),this._lines.push(h))}},i.parseLine=function(t,i){var n,s=(Browser.context,this._lines),r=0,a=NaN,o=NaN,h=0;if(a=this.getTextWidth(t),i>=a)return s.push(t),void this._lineWidths.push(a);a=this._currBitmapFont?this._currBitmapFont.getMaxWidth():this._charSize.width,r=Math.floor(i/a),0==r&&(r=1),a=this.getTextWidth(t.substring(0,r)),o=a;for(var l=r,u=t.length;u>l;l++)if(a=this.getTextWidth(t.charAt(l)),o+=a,o>i)if(this.wordWrap){var c=t.substring(h,l);if(c.charCodeAt(c.length-1)<255&&(n=/[^\x20-]+$/.exec(c),n&&(l=n.index+h,0==n.index?l+=c.length:c=t.substring(h,l))),s.push(c),this._lineWidths.push(o-a),h=l,!(u>l+r)){s.push(t.substring(h,u)),this._lineWidths.push(this.getTextWidth(s[s.length-1])),h=-1;break}l+=r,a=this.getTextWidth(t.substring(h,l)),o=a,l--}else if(this.overflow==e.HIDDEN)return s.push(t.substring(0,l)),void this._lineWidths.push(this.getTextWidth(s[s.length-1]));this.wordWrap&&-1!=h&&(s.push(t.substring(h,u)),this._lineWidths.push(this.getTextWidth(s[s.length-1])))},i.getTextWidth=function(t){return this._currBitmapFont?this._currBitmapFont.getTextWidth(t):Browser.context.measureText(t).width},i.getWordWrapWidth=function(){var t=this.padding,e=NaN;return e=this._currBitmapFont&&this._currBitmapFont.autoScaleSize?this._width*(this._currBitmapFont.fontSize/this.fontSize):this._width,0>=e&&(e=this.wordWrap?100:Browser.width),0>=e&&(e=100),e-t[3]-t[1]},i.getCharPoint=function(t,e){this._isChanged&&Laya.timer.runCallLater(this,this.typeset);for(var i=0,n=this._lines,s=0,r=0,a=n.length;a>r;r++){if(i+=n[r].length,i>t){var o=r;break}s=i}var h=(this.italic?"italic ":"")+(this.bold?"bold ":"")+this.fontSize+"px "+this.font;Browser.context.font=h;var l=this.getTextWidth(this._text.substring(s,t)),u=e||new Point;return u.setTo(this._startX+l-(this._clipPoint?this._clipPoint.x:0),this._startY+o*(this._charSize.height+this.leading)-(this._clipPoint?this._clipPoint.y:0))},__getset(0,i,"width",function(){return this._width?this._width:this.textWidth+this.padding[1]+this.padding[3]},function(e){e!=this._width&&(t.prototype._$set_width.call(this,e),this.isChanged=!0)}),__getset(0,i,"textWidth",function(){return this._isChanged&&Laya.timer.runCallLater(this,this.typeset),this._textWidth}),__getset(0,i,"height",function(){return this._height?this._height:this.textHeight+this.padding[0]+this.padding[2]},function(e){e!=this._height&&(t.prototype._$set_height.call(this,e),this.isChanged=!0)}),__getset(0,i,"textHeight",function(){return this._isChanged&&Laya.timer.runCallLater(this,this.typeset),this._textHeight}),__getset(0,i,"padding",function(){return this._getCSSStyle().padding},function(t){this._getCSSStyle().padding=t,this.isChanged=!0}),__getset(0,i,"bold",function(){return this._getCSSStyle().bold},function(t){this._getCSSStyle().bold=t,this.isChanged=!0}),__getset(0,i,"text",function(){return this._text||""},function(t){this._text!==t&&(this.lang(t+""),this.isChanged=!0,this.event("change"))}),__getset(0,i,"color",function(){return this._getCSSStyle().color},function(t){this._getCSSStyle().color!=t&&(this._getCSSStyle().color=t,!this._isChanged&&this._graphics?this._graphics.replaceTextColor(this.color):this.isChanged=!0)}),__getset(0,i,"font",function(){return this._getCSSStyle().fontFamily},function(t){this._currBitmapFont&&(this._currBitmapFont=null,this.scale(1,1)),e._bitmapFonts&&e._bitmapFonts[t]&&(this._currBitmapFont=e._bitmapFonts[t]),this._getCSSStyle().fontFamily=t,this.isChanged=!0}),__getset(0,i,"fontSize",function(){return this._getCSSStyle().fontSize},function(t){this._getCSSStyle().fontSize=t,this.isChanged=!0}),__getset(0,i,"italic",function(){return this._getCSSStyle().italic},function(t){this._getCSSStyle().italic=t,this.isChanged=!0}),__getset(0,i,"align",function(){return this._getCSSStyle().align},function(t){this._getCSSStyle().align=t,this.isChanged=!0}),__getset(0,i,"valign",function(){return this._getCSSStyle().valign},function(t){this._getCSSStyle().valign=t,this.isChanged=!0}),__getset(0,i,"wordWrap",function(){return this._getCSSStyle().wordWrap},function(t){this._getCSSStyle().wordWrap=t,this.isChanged=!0}),__getset(0,i,"leading",function(){return this._getCSSStyle().leading},function(t){this._getCSSStyle().leading=t,this.isChanged=!0}),__getset(0,i,"bgColor",function(){return this._getCSSStyle().backgroundColor},function(t){this._getCSSStyle().backgroundColor=t,this.isChanged=!0}),__getset(0,i,"borderColor",function(){return this._getCSSStyle().borderColor},function(t){this._getCSSStyle().borderColor=t,this.isChanged=!0}),__getset(0,i,"stroke",function(){return this._getCSSStyle().stroke},function(t){this._getCSSStyle().stroke=t,this.isChanged=!0}),__getset(0,i,"strokeColor",function(){return this._getCSSStyle().strokeColor},function(t){this._getCSSStyle().strokeColor=t,this.isChanged=!0}),__getset(0,i,"isChanged",null,function(t){this._isChanged!==t&&(this._isChanged=t,t&&Laya.timer.callLater(this,this.typeset))}),__getset(0,i,"scrollX",function(){return this._clipPoint?this._clipPoint.x:0},function(t){if(!(this.overflow!=e.SCROLL||this.textWidthi?i:t;var n=this._height/(this._charSize.height+this.leading)|1;this._clipPoint.x=t,this.renderText(this._lastVisibleLineIndex,n)}}),__getset(0,i,"scrollY",function(){return this._clipPoint?this._clipPoint.y:0},function(t){if(!(this.overflow!=e.SCROLL||this.textHeighti?i:t;var n=t/(this._charSize.height+this.leading)|0;this._lastVisibleLineIndex=n;var s=(this._height/(this._charSize.height+this.leading)|0)+1;this._clipPoint.y=t,this.renderText(n,s)}}),__getset(0,i,"maxScrollX",function(){return this.textWidtht/e?"vertical":"horizontal";if(i=n!==this._screenMode){var s=e;e=t,t=s}}this.canvasRotation=i;var r=Render._mainCanvas,a=r.source.style,o=this._canvasTransform.identity(),h=this._scaleMode,l=t/this.desginWidth,u=e/this.desginHeight,c=this.desginWidth,_=this.desginHeight,d=t,f=e,p=Browser.pixelRatio;switch(this._width=this.desginWidth,this._height=this.desginHeight,h){case"noscale":l=u=1,d=this.desginWidth,f=this.desginHeight;break;case"showall":l=u=Math.min(l,u),c=d=Math.round(this.desginWidth*l),_=f=Math.round(this.desginHeight*u);break;case"noborder":l=u=Math.max(l,u),d=Math.round(this.desginWidth*l),f=Math.round(this.desginHeight*u);break;case"full":l=u=1,this._width=c=t,this._height=_=e;break;case"fixedwidth":u=l,this._height=e/l,_=Math.round(e/l);break;case"fixedheight":l=u,this._width=t/u,c=Math.round(t/u)}l*=this.scaleX,u*=this.scaleY,1===l&&1===u?this.transform.identity():(this.transform.a=this._formatData(l/(d/c)),this.transform.d=this._formatData(u/(f/_)),this.model&&this.model.scale(this.transform.a,this.transform.d)),r.size(c,_),RunDriver.changeWebGLSize(c,_),o.scale(d/c/p,f/_/p),"left"===this._alignH?this.offset.x=0:"right"===this._alignH?this.offset.x=t-d:this.offset.x=.5*(t-d)/p,"top"===this._alignV?this.offset.y=0:"bottom"===this._alignV?this.offset.y=e-f:this.offset.y=.5*(e-f)/p,this.offset.x=Math.round(this.offset.x),this.offset.y=Math.round(this.offset.y),o.translate(this.offset.x,this.offset.y),this._safariOffsetY&&0===parseInt(a.top)&&(a.top=this._safariOffsetY+"px"),this.canvasDegree=0,i&&("horizontal"===this._screenMode?(o.rotate(Math.PI/2),o.translate(e/p,0),this.canvasDegree=90):(o.rotate(-Math.PI/2),o.translate(0,t/p),this.canvasDegree=-90)),o.a=this._formatData(o.a),o.d=this._formatData(o.d),o.tx=this._formatData(o.tx),o.ty=this._formatData(o.ty),a.transformOrigin=a.webkitTransformOrigin=a.msTransformOrigin=a.mozTransformOrigin=a.oTransformOrigin="0px 0px 0px",a.transform=a.webkitTransform=a.msTransform=a.mozTransform=a.oTransform="matrix("+o.toString()+")",o.translate(parseInt(a.left)||0,parseInt(a.top)||0),this.visible=!0,this._repaint=1,this.event("resize")},i._formatData=function(t){return Math.abs(t)<1e-6?0:Math.abs(1-t)<.001?t>0?1:-1:t},i.getMousePoint=function(){return Point.TEMP.setTo(this.mouseX,this.mouseY)},i.repaint=function(){this._repaint=1},i.parentRepaint=function(){},i._loop=function(){return this.render(Render.context,0,0),!0},i._onmouseMove=function(t){this._mouseMoveTime=Browser.now()},i.getTimeFromFrameStart=function(){return Browser.now()-this._frameStartTime},i.render=function(e,i,n){if("sleep"===this.frameRate){var s=Browser.now();if(!(s-this._frameStartTime>=1e3))return;this._frameStartTime=s}if(this._renderCount++,Render.isFlash&&this.repaint(),!this.visible)return void(this._renderCount%5===0&&(Stat.loopCount++,MouseManager.instance.runEvent(),Laya.timer._update()));this._frameStartTime=Browser.now();var r="mouse"===this.frameRate?this._frameStartTime-this._mouseMoveTime<2e3?"fast":"slow":this.frameRate,a="slow"!==r,o=this._renderCount%2===0;if(Stat.renderSlow=!a,a||o){Stat.loopCount++,MouseManager.instance.runEvent(),Laya.timer._update();var h=0,l=0;for(h=0,l=this._scenes.length;l>h;h++){var u=this._scenes[h];u&&u._updateScene()}if(Render.isConchNode){var c=Sprite.CustomList;for(h=0,l=c.length;l>h;h++){var _=c[h];_.customRender(_.customContext,0,0)}return}Render.isWebGL&&this.renderingEnabled&&(e.clear(),t.prototype.render.call(this,e,i,n))}Render.isConchNode||!this.renderingEnabled||!a&&o||(Render.isWebGL?(RunDriver.clear(this._bgColor),RunDriver.beginFlush(),e.flush(),RunDriver.endFinish(),VectorGraphManager.instance&&VectorGraphManager.getInstance().endDispose()):(RunDriver.clear(this._bgColor),t.prototype.render.call(this,e,i,n)))},i._requestFullscreen=function(){var t=Browser.document.documentElement;t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()},i._fullScreenChanged=function(){Laya.stage.event("fullscreenchange")},i.exitFullscreen=function(){var t=Browser.document;t.exitFullscreen?t.exitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()},__getset(0,i,"mouseY",function(){return Math.round(MouseManager.instance.mouseY/this.clientScaleY); +}),__getset(0,i,"clientScaleY",function(){return this._transform?this._transform.getScaleY():1}),__getset(0,i,"width",t.prototype._$get_width,function(e){this.desginWidth=e,t.prototype._$set_width.call(this,e),Laya.timer.callLater(this,this._changeCanvasSize)}),__getset(0,i,"alignH",function(){return this._alignH},function(t){this._alignH=t,Laya.timer.callLater(this,this._changeCanvasSize)}),__getset(0,i,"height",t.prototype._$get_height,function(e){this.desginHeight=e,t.prototype._$set_height.call(this,e),Laya.timer.callLater(this,this._changeCanvasSize)}),__getset(0,i,"scaleMode",function(){return this._scaleMode},function(t){this._scaleMode=t,Laya.timer.callLater(this,this._changeCanvasSize)}),__getset(0,i,"alignV",function(){return this._alignV},function(t){this._alignV=t,Laya.timer.callLater(this,this._changeCanvasSize)}),__getset(0,i,"bgColor",function(){return this._bgColor},function(t){this._bgColor=t,this.model&&this.model.bgColor(t),t?Render.canvas.style.background=t:Render.canvas.style.background="none"}),__getset(0,i,"clientScaleX",function(){return this._transform?this._transform.getScaleX():1}),__getset(0,i,"mouseX",function(){return Math.round(MouseManager.instance.mouseX/this.clientScaleX)}),__getset(0,i,"screenMode",function(){return this._screenMode},function(t){this._screenMode=t}),__getset(0,i,"visible",t.prototype._$get_visible,function(e){if(this.visible!==e){t.prototype._$set_visible.call(this,e);var i=Render._mainCanvas.source.style;i.visibility=e?"visible":"hidden"}}),__getset(0,i,"fullScreenEnabled",null,function(t){var e=Browser.document,i=Render.canvas;t?(i.addEventListener("mousedown",this._requestFullscreen),i.addEventListener("touchstart",this._requestFullscreen),e.addEventListener("fullscreenchange",this._fullScreenChanged),e.addEventListener("mozfullscreenchange",this._fullScreenChanged),e.addEventListener("webkitfullscreenchange",this._fullScreenChanged),e.addEventListener("msfullscreenchange",this._fullScreenChanged)):(i.removeEventListener("mousedown",this._requestFullscreen),i.removeEventListener("touchstart",this._requestFullscreen),e.removeEventListener("fullscreenchange",this._fullScreenChanged),e.removeEventListener("mozfullscreenchange",this._fullScreenChanged),e.removeEventListener("webkitfullscreenchange",this._fullScreenChanged),e.removeEventListener("msfullscreenchange",this._fullScreenChanged))}),e.SCALE_NOSCALE="noscale",e.SCALE_EXACTFIT="exactfit",e.SCALE_SHOWALL="showall",e.SCALE_NOBORDER="noborder",e.SCALE_FULL="full",e.SCALE_FIXED_WIDTH="fixedwidth",e.SCALE_FIXED_HEIGHT="fixedheight",e.ALIGN_LEFT="left",e.ALIGN_RIGHT="right",e.ALIGN_CENTER="center",e.ALIGN_TOP="top",e.ALIGN_MIDDLE="middle",e.ALIGN_BOTTOM="bottom",e.SCREEN_NONE="none",e.SCREEN_HORIZONTAL="horizontal",e.SCREEN_VERTICAL="vertical",e.FRAME_FAST="fast",e.FRAME_SLOW="slow",e.FRAME_MOUSE="mouse",e.FRAME_SLEEP="sleep",e}(Sprite),SoundNode=function(t){function e(){this.url=null,this._channel=null,this._tar=null,this._playEvents=null,this._stopEvents=null,e.__super.call(this),this.visible=!1,this.on("added",this,this._onParentChange),this.on("removed",this,this._onParentChange)}__class(e,"laya.media.SoundNode",t);var i=e.prototype;return i._onParentChange=function(){this.target=this.parent},i.play=function(t,e){void 0===t&&(t=1),isNaN(t)&&(t=1),this.url&&(this.stop(),this._channel=SoundManager.playSound(this.url,t,e))},i.stop=function(){this._channel&&!this._channel.isStopped&&this._channel.stop(),this._channel=null},i._setPlayAction=function(t,e,i,n){void 0===n&&(n=!0),this[i]&&t&&(n?t.on(e,this,this[i]):t.off(e,this,this[i]))},i._setPlayActions=function(t,e,i,n){if(void 0===n&&(n=!0),t&&e){var s=e.split(","),r=0,a=0;for(a=s.length,r=0;a>r;r++)this._setPlayAction(t,s[r],i,n)}},__getset(0,i,"playEvent",null,function(t){this._playEvents=t,t&&this._tar&&this._setPlayActions(this._tar,t,"play")}),__getset(0,i,"target",null,function(t){this._tar&&(this._setPlayActions(this._tar,this._playEvents,"play",!1),this._setPlayActions(this._tar,this._stopEvents,"stop",!1)),this._tar=t,this._tar&&(this._setPlayActions(this._tar,this._playEvents,"play",!0),this._setPlayActions(this._tar,this._stopEvents,"stop",!0))}),__getset(0,i,"stopEvent",null,function(t){this._stopEvents=t,t&&this._tar&&this._setPlayActions(this._tar,t,"stop")}),e}(Sprite),Scene2D=function(t){function e(){e.__super.call(this),this.createChildren()}__class(e,"laya.scene.Scene2D",t);var i=e.prototype;return i.createChildren=function(){},i.createView=function(t){ClassUtils.createByJson(t,this,this)},e}(Sprite),FileBitmap=function(t){function e(){this._src=null,this._onload=null,this._onerror=null,e.__super.call(this)}__class(e,"laya.resource.FileBitmap",t);var i=e.prototype;return __getset(0,i,"src",function(){return this._src},function(t){this._src=t}),__getset(0,i,"onload",null,function(t){}),__getset(0,i,"onerror",null,function(t){}),e}(Bitmap),HTMLCanvas=function(t){function e(t,i){this._is2D=!1,e.__super.call(this);var n=this;if(this._source=this,"2D"===t||"AUTO"===t&&!Render.isWebGL){this._is2D=!0,this._source=i||Browser.createElement("canvas");var s=this;s.getContext=function(t,e){if(n._ctx)return n._ctx;var i=n._ctx=n._source.getContext(t,e);return i&&(i._canvas=s,Render.isFlash||(i.size=function(t,e){})),i}}else this._source={}}__class(e,"laya.resource.HTMLCanvas",t);var i=e.prototype;return i.clear=function(){this._ctx&&this._ctx.clear()},i.destroy=function(){this._ctx&&this._ctx.destroy(),this._ctx=null},i.release=function(){},i._setContext=function(t){this._ctx=t},i.getContext=function(t,i){return this._ctx?this._ctx:this._ctx=e._createContext(this)},i.getMemSize=function(){return 0},i.size=function(t,e){this._w==t&&this._h==e||(this._w=t,this._h=e,this._ctx&&this._ctx.size(t,e),this._source&&(this._source.height=e,this._source.width=t))},__getset(0,i,"context",function(){return this._ctx}),__getset(0,i,"asBitmap",null,function(t){}),e.create=function(t,i){return new e(t,i)},e.TYPE2D="2D",e.TYPE3D="3D",e.TYPEAUTO="AUTO",e._createContext=null,e}(Bitmap),HTMLSubImage=function(t){function e(t,i,n,s,r,a,o,h){throw e.__super.call(this),new Error("不允许new!")}return __class(e,"laya.resource.HTMLSubImage",t),e.create=function(t,i,n,s,r,a,o,h){return void 0===h&&(h=!1),new e(t,i,n,s,r,a,o,h)},e}(Bitmap),Animation=function(t){function e(){this._frames=null,this._url=null,e.__super.call(this),this._setControlNode(this)}__class(e,"laya.display.Animation",t);var i=e.prototype;return i.destroy=function(t){void 0===t&&(t=!0),this.stop(),laya.display.Sprite.prototype.destroy.call(this,t),this._frames=null,this._labels=null},i.play=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=!0),void 0===i&&(i=""),i&&this._setFramesFromCache(i),this._isPlaying=!0,this.index="string"==typeof t?this._getFrameByLabel(t):t,this.loop=e,this._actionName=i,this._isReverse=1==this.wrapMode,this._frames&&this.interval>0&&this.timerLoop(this.interval,this,this._frameLoop,null,!0)},i._setFramesFromCache=function(t){return this._url&&(t=this._url+"#"+t),t&&e.framesMap[t]?(this._frames=e.framesMap[t],this._count=this._frames.length,!this._frameRateChanged&&e.framesMap[t+"$len"]&&(this._interval=e.framesMap[t+"$len"]),!0):!1},i._frameLoop=function(){this._style.visible&&this._style.alpha>.01&&t.prototype._frameLoop.call(this)},i._displayToIndex=function(t){this._frames&&(this.graphics=this._frames[t])},i.clear=function(){this.stop(),this.graphics=null,this._frames=null,this._labels=null},i.loadImages=function(t,i){return void 0===i&&(i=""),this._url="",this._setFramesFromCache(i)||(this.frames=e.framesMap[i]?e.framesMap[i]:e.createFrames(t,i)),this},i.loadAtlas=function(t,i,n){function s(s){t===s&&(r.frames=e.framesMap[n]?e.framesMap[n]:e.createFrames(t,n),i&&i.run())}void 0===n&&(n=""),this._url="";var r=this;return r._setFramesFromCache(n)||(Loader.getAtlas(t)?s(t):Laya.loader.load(t,Handler.create(null,s,[t]),null,"atlas")),this},i.loadAnimation=function(t,i){function n(n){if(t===n){if(e.framesMap[t+"#"])s._frameRateChanged||(s._interval=e.framesMap[t+"#$len"]),s.frames=e.framesMap[t+"#"];else{var r=s._parseGraphicAnimation(Loader.getRes(t));if(!r)return;var a=r.animationDic,o=!0;for(var h in a){var l=a[h];l.frames.length?(e.framesMap[t+"#"+h]=l.frames,e.framesMap[t+"#"+h+"$len"]=l.interval):o=!1}s._frameRateChanged||(s._interval=r.animationList[0].interval),s.frames=r.animationList[0].frames,o&&(e.framesMap[t+"#$len"]=r.animationList[0].interval,e.framesMap[t+"#"]=s.frames)}i&&i.run()}}this._url=t;var s=this;return s._setFramesFromCache("")||(Loader.getRes(t)?n(t):Laya.loader.load(t,Handler.create(null,n,[t]),null,"json"),Loader.clearRes(t)),this},i._parseGraphicAnimation=function(t){return GraphicAnimation.parseAnimationData(t)},__getset(0,i,"frames",function(){return this._frames},function(t){this._frames=t,t&&(this._count=t.length,this._isPlaying?this.play(this._index,this.loop,this._actionName):this.index=this._index)}),__getset(0,i,"autoPlay",null,function(t){t?this.play():this.stop()}),__getset(0,i,"source",null,function(t){t.indexOf(".ani")>-1?this.loadAnimation(t):t.indexOf(".json")>-1||t.indexOf("als")>-1?this.loadAtlas(t):this.loadImages(t.split(","))}),e.createFrames=function(t,i){var n;if("string"==typeof t){var s=Loader.getAtlas(t);if(s&&s.length){n=[];for(var r=0,a=s.length;a>r;r++){var o=new Graphics;o.drawTexture(Loader.getRes(s[r]),0,0),n.push(o)}}}else if(t instanceof Array)for(n=[],r=0,a=t.length;a>r;r++)o=new Graphics,o.loadImage(t[r],0,0),n.push(o);return i&&(e.framesMap[i]=n),n},e.clearCache=function(t){var i,n=e.framesMap,s=t+"#";for(i in n)i!==t&&0!=i.indexOf(s)||delete e.framesMap[i]},e.framesMap={},e}(AnimationPlayerBase),FrameAnimation=function(t){function e(){this._targetDic=null,this._animationData=null,e.__super.call(this),null==e._sortIndexFun&&(e._sortIndexFun=MathUtil.sortByKey("index",!1,!0))}__class(e,"laya.display.FrameAnimation",t);var i=e.prototype;return i._setUp=function(t,e){this._labels=null,this._targetDic=t,this._animationData=e,this.interval=1e3/e.frameRate,e.parsed?this._count=e.count:this._calculateDatas(),e.parsed=!0,e.count=this._count},i.clear=function(){t.prototype.clear.call(this),this._targetDic=null,this._animationData=null},i._displayToIndex=function(t){if(this._animationData){0>t&&(t=0),t>this._count&&(t=this._count);var e=this._animationData.nodes,i=0,n=e.length;for(i=0;n>i;i++)this._displayNodeToFrame(e[i],t)}},i._displayNodeToFrame=function(t,e,i){i||(i=this._targetDic);var n=i[t.target];if(n){var s,r,a,o=t.frames,h=t.keys,l=0,u=h.length;for(l=0;u>l;l++)s=h[l],r=o[s],a=r.length>e?r[e]:r[r.length-1],n[s]=a}},i._calculateDatas=function(){if(this._animationData){var t,e=this._animationData.nodes,i=0,n=e.length;for(this._count=0,i=0;n>i;i++)t=e[i],this._calculateNodeKeyFrames(t);this._count+=1}},i._calculateNodeKeyFrames=function(t){var i,n,s=t.keyframes,r=t.target;t.frames||(t.frames={}),t.keys?t.keys.length=0:t.keys=[];for(i in s)n=s[i],t.frames[i]||(t.frames[i]=[]),n.sort(e._sortIndexFun),t.keys.push(i),this._calculateNodePropFrames(n,t.frames[i],i,r)},i._calculateNodePropFrames=function(t,e,i,n){var s=0,r=t.length-1;for(e.length=t[r].index+1,s=0;r>s;s++)this._dealKeyFrame(t[s]),this._calculateFrameValues(t[s],t[s+1],e);0==r&&(e[0]=t[0].value),this._dealKeyFrame(t[s])},i._dealKeyFrame=function(t){t.label&&""!=t.label&&this.addLabel(t.label,t.index)},i._calculateFrameValues=function(t,e,i){var n,s=0,r=t.index,a=e.index,o=t.value,h=e.value-t.value,l=a-r;if(a>this._count&&(this._count=a),t.tween)for(n=Ease[t.tweenMethod],null==n&&(n=Ease.linearNone),s=r;a>s;s++)i[s]=n(s-r,o,h,l);else for(s=r;a>s;s++)i[s]=o;i[e.index]=e.value},e._sortIndexFun=null,e}(AnimationPlayerBase),Input=function(t){function e(){this._focus=!1,this._multiline=!1,this._editable=!0,this._restrictPattern=null,this._type="text",this._prompt="",this._promptColor="#A9A9A9",this._originColor="#000000",this._content="",e.__super.call(this),this._maxChars=1e5,this._width=100,this._height=20,this.multiline=!1,this.overflow=Text.SCROLL,this.on("mousedown",this,this._onMouseDown),this.on("undisplay",this,this._onUnDisplay)}__class(e,"laya.display.Input",t);var i=e.prototype;return i.setSelection=function(t,e){laya.display.Input.inputElement.selectionStart=t,laya.display.Input.inputElement.selectionEnd=e},i._onUnDisplay=function(t){this.focus=!1},i._onMouseDown=function(t){this.focus=!0,Laya.stage.on("mousedown",this,this._checkBlur)},i._checkBlur=function(t){t.nativeEvent.target!=laya.display.Input.input&&t.nativeEvent.target!=laya.display.Input.area&&t.target!=this&&(this.focus=!1)},i.render=function(t,e,i){laya.display.Sprite.prototype.render.call(this,t,e,i)},i._syncInputTransform=function(){var t,i=(this.nativeInput.style,Laya.stage);t=Utils.getGlobalPosAndScale(this);var n=i._canvasTransform.clone(),s=n.clone();s.rotate(-Math.PI/180*Laya.stage.canvasDegree),s.scale(Laya.stage.clientScaleX,Laya.stage.clientScaleY);var r=Laya.stage.canvasDegree%180!=0,a=r?s.d:s.a,o=r?s.a:s.d;s.destroy();var h=this.padding[3],l=this.padding[0];0==Laya.stage.canvasDegree?(h+=t.x,l+=t.y,h*=a,l*=o,h+=n.tx,l+=n.ty):90==Laya.stage.canvasDegree?(h+=t.y,l+=t.x,h*=a,l*=o,h=n.tx-h,l+=n.ty):(h+=t.y,l+=t.x,h*=a,l*=o,h+=n.tx,l=n.ty-l);var u=.785,c=Math.atan2(t.height,t.width)-u,_=Math.sin(c),d=Math.cos(c),f=d*t.width+_*t.height,p=d*t.height-_*t.width;a*=r?p:f,o*=r?f:p,n.tx=0,n.ty=0,c*=180/3.1415,e.inputContainer.style.transform="scale("+a+","+o+") rotate("+(Laya.stage.canvasDegree+c)+"deg)",e.inputContainer.style.webkitTransform="scale("+a+","+o+") rotate("+(Laya.stage.canvasDegree+c)+"deg)",e.inputContainer.setPos(h,l),n.destroy();var g=this._width-this.padding[1]-this.padding[3],m=this._height-this.padding[0]-this.padding[2];this.nativeInput.setSize(g,m),Render.isConchApp&&(this.nativeInput.setPos(h,l),this.nativeInput.setScale(a,o))},i.select=function(){this.nativeInput.select()},i._setInputMethod=function(){e.input.parentElement&&e.inputContainer.removeChild(e.input),e.area.parentElement&&e.inputContainer.removeChild(e.area),e.inputElement=this._multiline?e.area:e.input,e.inputContainer.appendChild(e.inputElement)},i._focusIn=function(){laya.display.Input.isInputting=!0;var t=this.nativeInput;this._focus=!0;var e=t.style;e.whiteSpace=this.wordWrap?"pre-wrap":"nowrap",this._setPromptColor(),t.readOnly=!this._editable,t.maxLength=this._maxChars;this.padding;t.type=this._type,t.value=this._content,t.placeholder=this._prompt,Laya.stage.off("keydown",this,this._onKeyDown),Laya.stage.on("keydown",this,this._onKeyDown),Laya.stage.focus=this,this.event("focus"),Browser.onPC&&t.focus();this._text;this._text=null,this.typeset(),t.setColor(this._originColor),t.setFontSize(this.fontSize),t.setFontFace(this.font),Render.isConchApp&&t.setMultiAble&&t.setMultiAble(this._multiline),e.lineHeight=this.leading+this.fontSize+"px",e.fontStyle=this.italic?"italic":"normal",e.fontWeight=this.bold?"bold":"normal",e.textAlign=this.align,e.padding="0 0",this._syncInputTransform(),!Render.isConchApp&&Browser.onPC&&Laya.timer.frameLoop(1,this,this._syncInputTransform)},i._setPromptColor=function(){e.promptStyleDOM=Browser.getElementById("promptStyle"),e.promptStyleDOM||(e.promptStyleDOM=Browser.createElement("style"),Browser.document.head.appendChild(e.promptStyleDOM)),e.promptStyleDOM.innerText="input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {color:"+this._promptColor+"}input:-moz-placeholder, textarea:-moz-placeholder {color:"+this._promptColor+"}input::-moz-placeholder, textarea::-moz-placeholder {color:"+this._promptColor+"}input:-ms-input-placeholder, textarea:-ms-input-placeholder {color:"+this._promptColor+"}"},i._focusOut=function(){laya.display.Input.isInputting=!1,this._focus=!1,this._text=null,this._content=this.nativeInput.value,this._content?(t.prototype._$set_text.call(this,this._content),t.prototype._$set_color.call(this,this._originColor)):(t.prototype._$set_text.call(this,this._prompt),t.prototype._$set_color.call(this,this._promptColor)),Laya.stage.off("keydown",this,this._onKeyDown),Laya.stage.focus=null,this.event("blur"),Render.isConchApp&&this.nativeInput.blur(),Browser.onPC&&Laya.timer.clear(this,this._syncInputTransform),Laya.stage.off("mousedown",this,this._checkBlur)},i._onKeyDown=function(t){13===t.keyCode&&(Browser.onMobile&&!this._multiline&&(this.focus=!1),this.event("enter"))},i.changeText=function(e){this._content=e,this._focus?(this.nativeInput.value=e||"",this.event("change")):t.prototype.changeText.call(this,e)},__getset(0,i,"color",t.prototype._$get_color,function(e){this._focus&&this.nativeInput.setColor(e),t.prototype._$set_color.call(this,this._content?e:this._promptColor),this._originColor=e}),__getset(0,i,"inputElementYAdjuster",function(){return console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementYAdjuster已弃用。"),0},function(t){console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementYAdjuster已弃用。")}),__getset(0,i,"multiline",function(){return this._multiline},function(t){this._multiline=t,this.valign=t?"top":"middle"}),__getset(0,i,"maxChars",function(){return this._maxChars},function(t){0>=t&&(t=1e5),this._maxChars=t}),__getset(0,i,"text",function(){return this._focus?this.nativeInput.value:this._content||""},function(e){t.prototype._$set_color.call(this,this._originColor),e+="",this._focus?(this.nativeInput.value=e||"",this.event("change")):(this._multiline||(e=e.replace(/\r?\n/g,"")),this._content=e,e?t.prototype._$set_text.call(this,e):(t.prototype._$set_text.call(this,this._prompt),t.prototype._$set_color.call(this,this.promptColor)))}),__getset(0,i,"nativeInput",function(){return this._multiline?e.area:e.input}),__getset(0,i,"prompt",function(){return this._prompt},function(e){!this._text&&e&&t.prototype._$set_color.call(this,this._promptColor),this.promptColor=this._promptColor,this._text?t.prototype._$set_text.call(this,this._text==this._prompt?e:this._text):t.prototype._$set_text.call(this,e),this._prompt=e}),__getset(0,i,"focus",function(){return this._focus},function(t){var i=this.nativeInput;this._focus!==t&&(t?(i.target&&(i.target.focus=!1),i.target=this,this._setInputMethod(),this._focusIn()):(i.target=null,this._focusOut(),i.blur(),Render.isConchApp?i.setPos(-1e4,-1e4):e.inputContainer.contains(i)&&e.inputContainer.removeChild(i)))}),__getset(0,i,"restrict",function(){return this._restrictPattern?this._restrictPattern.source:""},function(t){t?(t="[^"+t+"]",t.indexOf("^^")>-1&&(t=t.replace("^^","")),this._restrictPattern=new RegExp(t,"g")):this._restrictPattern=null}),__getset(0,i,"editable",function(){return this._editable},function(t){this._editable=t}),__getset(0,i,"promptColor",function(){return this._promptColor},function(e){this._promptColor=e,this._content||t.prototype._$set_color.call(this,e)}),__getset(0,i,"type",function(){return this._type},function(t){"password"==t?this._getCSSStyle().password=!0:this._getCSSStyle().password=!1,this._type=t}),__getset(0,i,"inputElementXAdjuster",function(){return console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementXAdjuster已弃用。"),0},function(t){console.warn("deprecated: 由于即使设置了该值,在各平台和浏览器之间也不一定一致,inputElementXAdjuster已弃用。")}),__getset(0,i,"asPassword",function(){return this._getCSSStyle().password},function(t){this._getCSSStyle().password=t,this._type="password",console.warn('deprecated: 使用type="password"替代设置asPassword, asPassword将在下次重大更新时删去'),this.isChanged=!0}),e.__init__=function(){e._createInputElement(),Browser.onMobile&&Render.canvas.addEventListener(e.IOS_IFRAME?"click":"touchend",e._popupInputMethod)},e._popupInputMethod=function(t){if(laya.display.Input.isInputting){var e=laya.display.Input.inputElement;e.focus()}},e._createInputElement=function(){e._initInput(e.area=Browser.createElement("textarea")),e._initInput(e.input=Browser.createElement("input")),e.inputContainer=Browser.createElement("div"),e.inputContainer.style.position="absolute",e.inputContainer.style.zIndex=1e5,Browser.container.appendChild(e.inputContainer),e.inputContainer.setPos=function(t,i){e.inputContainer.style.left=t+"px",e.inputContainer.style.top=i+"px"}},e._initInput=function(t){var i=t.style;i.cssText="position:absolute;overflow:hidden;resize:none;transform-origin:0 0;-webkit-transform-origin:0 0;-moz-transform-origin:0 0;-o-transform-origin:0 0;",i.resize="none",i.backgroundColor="transparent",i.border="none",i.outline="none",i.zIndex=1,t.addEventListener("input",e._processInputting),t.addEventListener("mousemove",e._stopEvent),t.addEventListener("mousedown",e._stopEvent),t.addEventListener("touchmove",e._stopEvent),Render.isConchApp||(t.setColor=function(e){t.style.color=e},t.setFontSize=function(e){t.style.fontSize=e+"px"},t.setSize=function(e,i){t.style.width=e+"px",t.style.height=i+"px"}),t.setFontFace=function(e){t.style.fontFamily=e}},e._processInputting=function(t){var e=laya.display.Input.inputElement.target;if(e){var i=laya.display.Input.inputElement.value;e._restrictPattern&&(i=i.replace(/\u2006|\x27/g,""),e._restrictPattern.test(i)&&(i=i.replace(e._restrictPattern,""),laya.display.Input.inputElement.value=i)),e._text=i,e.event("input")}},e._stopEvent=function(t){"touchmove"==t.type&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},e.TYPE_TEXT="text",e.TYPE_PASSWORD="password",e.TYPE_EMAIL="email",e.TYPE_URL="url",e.TYPE_NUMBER="number",e.TYPE_RANGE="range",e.TYPE_DATE="date",e.TYPE_MONTH="month",e.TYPE_WEEK="week",e.TYPE_TIME="time",e.TYPE_DATE_TIME="datetime",e.TYPE_DATE_TIME_LOCAL="datetime-local",e.TYPE_SEARCH="search",e.input=null,e.area=null,e.inputElement=null,e.inputContainer=null,e.confirmButton=null,e.promptStyleDOM=null,e.inputHeight=45,e.isInputting=!1,__static(e,["IOS_IFRAME",function(){return this.IOS_IFRAME=Browser.onIOS&&Browser.window.top!=Browser.window.self}]),e}(Text),HTMLImage=function(t){function e(t,i){this._recreateLock=!1,this._needReleaseAgain=!1,e.__super.call(this),this._init_(t,i)}__class(e,"laya.resource.HTMLImage",t);var i=e.prototype;return i._init_=function(t,e){this._src=t,this._source=new Browser.window.Image,e&&(e.onload&&(this.onload=e.onload),e.onerror&&(this.onerror=e.onerror),e.onCreate&&e.onCreate(this)),0!=t.indexOf("data:image")&&(this._source.crossOrigin=""),t&&(this._source.src=t)},i.recreateResource=function(){var t=this;if(""===this._src)throw new Error("src no null!");if(this._needReleaseAgain=!1,this._source){if(this._recreateLock)return;this.startCreate(),this.memorySize=this._w*this._h*4,this._recreateLock=!1,this.completeCreate()}else{this._recreateLock=!0,this.startCreate();var e=this;this._source=new Browser.window.Image,this._source.crossOrigin="",this._source.onload=function(){return e._needReleaseAgain?(e._needReleaseAgain=!1,e._source.onload=null,void(e._source=null)):(e._source.onload=null,e.memorySize=t._w*t._h*4,e._recreateLock=!1,void e.completeCreate())},this._source.src=this._src}},i.detoryResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(this._source=null,this.memorySize=0)},i.onresize=function(){this._w=this._source.width,this._h=this._source.height},__getset(0,i,"onload",null,function(t){var e=this;this._onload=t,this._source&&(this._source.onload=null!=this._onload?function(){e.onresize(),e._onload()}:null)}),__getset(0,i,"onerror",null,function(t){var e=this;this._onerror=t,this._source&&(this._source.onerror=null!=this._onerror?function(){e._onerror()}:null)}),e.create=function(t,i){return new e(t,i)},e}(FileBitmap),GraphicAnimation=function(t){function e(){this.animationList=null,this.animationDic=null,this._nodeList=null,this._nodeDefaultProps=null,this._gList=null,this._nodeIDAniDic={},e.__super.call(this)}__class(e,"laya.display.GraphicAnimation",t);var i=e.prototype;return i._parseNodeList=function(t){this._nodeList||(this._nodeList=[]),this._nodeDefaultProps[t.compId]=t.props,t.compId&&this._nodeList.push(t.compId);var e=t.child;if(e){var i=0,n=e.length;for(i=0;n>i;i++)this._parseNodeList(e[i])}},i._calGraphicData=function(t){this._setUp(null,t),this._createGraphicData()},i._createGraphicData=function(){var t=[],e=0,i=this.count;for(e=0;i>e;e++)t.push(this._createFrameGraphic(e));this._gList=t},i._createFrameGraphic=function(t){var e=new Graphics,i=0,n=this._nodeList.length,s=0;for(i=0;n>i;i++)s=this._nodeList[i],this._addNodeGraphic(s,e,t);return e},i._calculateNodeKeyFrames=function(e){t.prototype._calculateNodeKeyFrames.call(this,e),this._nodeIDAniDic[e.target]=e},i.getNodeDataByID=function(t){return this._nodeIDAniDic[t]},i._getParams=function(t,i,n,s){var r=e._temParam;r.length=i.length;var a=0,o=i.length;for(a=0;o>a;a++)r[a]=this._getObjVar(t,i[a][0],n,i[a][1],s);return r},i._getObjVar=function(t,e,i,n,s){if(t.hasOwnProperty(e)){var r=t[e];return i>=r.length&&(i=r.length-1),t[e][i]}return s.hasOwnProperty(e)?s[e]:n},i._addNodeGraphic=function(t,i,n){var s=this.getNodeDataByID(t);if(s){var r=s.frames,a=this._getParams(r,e._drawTextureCmd,n,this._nodeDefaultProps[t]),o=a[0];if(o){if(a[0]=this._getTextureByUrl(o),!a[0])throw console.log("lost:",o),new Error("texture not loaded:"+o);var h,l=a[5],u=a[6];0==l&&0==u||(h=h||new Matrix,h.translate(-l,-u));var c=a[7],_=a[8],d=a[9];1==c&&1==_&&0==d||(h=h||new Matrix,h.scale(c,_),h.rotate(.0174532922222222*d)),h&&(h.translate(a[1],a[2]),a[1]=a[2]=0),i.drawTexture(a[0],a[1],a[2],a[3],a[4],h,a[10])}}},i._getTextureByUrl=function(t){return Loader.getRes(t)},i.setAniData=function(t){if(t.animations){this._nodeDefaultProps={},this._nodeList&&(this._nodeList.length=0),this._parseNodeList(t);var i,n={},s=[],r=t.animations,a=0,o=r.length;for(a=0;o>a;a++)if(i=r[a]){try{this._calGraphicData(i)}catch(h){console.log("parse animation fail:"+i.name+",empty animation created"),this._gList=[]}var l={};l.interval=1e3/i.frameRate,l.frames=this._gList,s.push(l),n[i.name]=l}this.animationList=s,this.animationDic=n}e._temParam.length=0},i._clear=function(){this.animationList=null,this.animationDic=null,this._gList=null},e.parseAnimationData=function(t){e._I||(e._I=new e),e._I.setAniData(t);var i;return i={},i.animationList=e._I.animationList,i.animationDic=e._I.animationDic,e._I._clear(),i},e._temParam=[],e._I=null,__static(e,["_drawTextureCmd",function(){return this._drawTextureCmd=[["skin",null],["x",0],["y",0],["width",0],["height",0],["pivotX",0],["pivotY",0],["scaleX",1],["scaleY",1],["rotation",0],["alpha",1]]}]),e}(FrameAnimation);Laya.__init([EventDispatcher,LoaderManager,Render,Browser,Timer,LocalStorage,TimeLine])}(window,document,Laya),function(t,e,i){var n=(i.un,i.uns,i["static"]),s=i["class"],r=i.getset,a=i.__newvec,o=laya.maths.Arith,h=laya.maths.Bezier,l=laya.resource.Bitmap,u=laya.utils.Browser,c=laya.utils.Color,_=(laya.filters.ColorFilter,i.Config),d=laya.resource.Context,f=(laya.events.Event,laya.filters.Filter),p=laya.display.Graphics,g=laya.resource.HTMLCanvas,m=(laya.utils.HTMLChar,laya.resource.HTMLImage),v=(laya.utils.Handler,laya.maths.Matrix),y=laya.maths.Point,x=laya.maths.Rectangle,w=laya.renders.Render,b=(laya.renders.RenderContext,laya.renders.RenderSprite),T=laya.resource.Resource,S=laya.resource.ResourceManager,C=laya.utils.RunDriver,M=laya.display.Sprite,A=laya.utils.Stat,L=laya.utils.StringKey,P=(laya.display.css.Style,laya.system.System),R=laya.resource.Texture,I=laya.utils.Utils,E=laya.utils.VectorGraphManager;laya.utils.WordText;i["interface"]("laya.webgl.shapes.IShape"),i["interface"]("laya.webgl.submit.ISubmit"),i["interface"]("laya.webgl.text.ICharSegment"),i["interface"]("laya.webgl.canvas.save.ISaveData"),i["interface"]("laya.webgl.resource.IMergeAtlasBitmap"),i["interface"]("laya.filters.IFilterActionGL","laya.filters.IFilterAction");var D=function(){function t(){}return s(t,"LayaMain"),t}(),F=function(){function t(){}s(t,"laya.filters.webgl.FilterActionGL");var e=t.prototype;return i.imps(e,{"laya.filters.IFilterActionGL":!0}),e.setValue=function(t){},e.setValueMix=function(t){},e.apply3d=function(t,e,i,n,s){return null},e.apply=function(t){return null},r(0,e,"typeMix",function(){return 0}),t}(),B=function(){function t(){}return s(t,"laya.webgl.shader.ShaderValue"),t}(),k=function(){function t(t,e,n){this._atlasID=0,this._width=0,this._height=0,this._texCount=0,this._rowInfo=null,this._cells=null,this._failSize=new i,void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this._cells=null,this._rowInfo=null,this._init(t,e),this._atlasID=n}var e,i;s(t,"laya.webgl.atlas.AtlasGrid");var n=t.prototype;return n.getAltasID=function(){return this._atlasID},n.setAltasID=function(t){t>=0&&(this._atlasID=t)},n.addTex=function(t,e,i){var n=this._get(e,i);return 0==n.ret?n:(this._fill(n.x,n.y,e,i,t),this._texCount++,n)},n._release=function(){null!=this._cells&&(this._cells.length=0,this._cells=null),this._rowInfo&&(this._rowInfo.length=0,this._rowInfo=null)},n._init=function(t,i){if(this._width=t,this._height=i,this._release(),0==this._width)return!1;this._cells=new Uint8Array(this._width*this._height*3),this._rowInfo=a(this._height);for(var n=0;n=this._failSize.width&&e>=this._failSize.height)return i;for(var n=-1,s=-1,r=this._width,a=this._height,o=this._cells,h=0;a>h;h++)if(!(this._rowInfo[h].spaceCountl;){var u=3*(h*r+l);if(0!=o[u]||o[u+1]c;c++)if(o[3*c+u+2]n))return i.ret=!0,i.x=n,i.y=s,i;l+=o[u+1]}}return i},n._fill=function(t,e,i,n,s){var r=this._width,a=this._height;this._check(r>=t+i&&a>=e+n);for(var o=e;n+e>o;++o){this._check(this._rowInfo[o].spaceCount>=i),this._rowInfo[o].spaceCount-=i;for(var h=0;i>h;h++){var l=3*(t+o*r+h);this._check(0==this._cells[l]),this._cells[l]=s,this._cells[l+1]=i,this._cells[l+2]=n}}if(t>0)for(o=0;n>o;++o){var u=0;for(h=t-1;h>=0&&0==this._cells[3*((e+o)*r+h)];--h,++u);for(h=u;h>0;--h)this._cells[3*((e+o)*r+t-h)+1]=h,this._check(h>0)}if(e>0)for(h=t;t+i>h;++h){for(u=0,o=e-1;o>=0&&0==this._cells[3*(h+o*r)];--o,u++);for(o=u;o>0;--o)this._cells[3*(h+(e-o)*r)+2]=o,this._check(o>0)}},n._check=function(t){0==t&&console.log("xtexMerger 错误啦")},n._clear=function(){this._texCount=0;for(var t=0;tr;r++){for(var a=this._maxAtlaserCount,o=0;a>o;o++){var h=(this._curAtlasIndex+o)%a;this._atlaserArray.length-1>=h||this._atlaserArray.push(new wt(this._gridNumX,this._gridNumY,this._width,this._height,t._sid_++));var l=this._atlaserArray[h],u=e.bitmap,c=l.inAtlasWebGLImagesKey.indexOf(u),_=0,d=0;if(-1!=c){var f=l.InAtlasWebGLImagesOffsetValue[c];_=f[0],d=f[1],l.addToAtlas(e,_,d),s=!0,this._curAtlasIndex=h;break}var p=l.addTex(1,i,n);if(p.ret){_=p.x*this._gridSize+1,d=p.y*this._gridSize+1, +u.lock=!0,l.addToAtlasTexture(u,_,d),l.addToAtlas(e,_,d),s=!0,this._curAtlasIndex=h;break}}if(s)break;this._atlaserArray.push(new wt(this._gridNumX,this._gridNumY,this._width,this._height,t._sid_++)),this._needGC=!0,this.garbageCollection(),this._curAtlasIndex=this._atlaserArray.length-1}return s||console.log(">>>AtlasManager pushData error"),s},e.addToAtlas=function(t){laya.webgl.atlas.AtlasResourceManager.instance.pushData(t)},e.garbageCollection=function(){if(this._needGC===!0){for(var t=this._atlaserArray.length-this._maxAtlaserCount,e=0;t>e;e++)this._atlaserArray[e].dispose();this._atlaserArray.splice(0,t),this._needGC=!1}return!0},e.freeAll=function(){for(var t=0,e=this._atlaserArray.length;e>t;t++)this._atlaserArray[t].dispose();this._atlaserArray.length=0,this._curAtlasIndex=0},e.getAtlaserCount=function(){return this._atlaserArray.length},e.getAtlaserByIndex=function(t){return this._atlaserArray[t]},r(1,t,"instance",function(){return t._Instance||(t._Instance=new t(laya.webgl.atlas.AtlasResourceManager.atlasTextureWidth,laya.webgl.atlas.AtlasResourceManager.atlasTextureHeight,16,laya.webgl.atlas.AtlasResourceManager.maxTextureCount)),t._Instance}),r(1,t,"enabled",function(){return t._enabled}),r(1,t,"atlasLimitWidth",function(){return t._atlasLimitWidth},function(e){t._atlasLimitWidth=e}),r(1,t,"atlasLimitHeight",function(){return t._atlasLimitHeight},function(e){t._atlasLimitHeight=e}),t._enable=function(){t._enabled=!0,_.atlasEnable=!0},t._disable=function(){t._enabled=!1,_.atlasEnable=!1},t.__init__=function(){t.atlasTextureWidth=2048,t.atlasTextureHeight=2048,t.maxTextureCount=6,t.atlasLimitWidth=512,t.atlasLimitHeight=512},t._enabled=!1,t._atlasLimitWidth=0,t._atlasLimitHeight=0,t.gridSize=16,t.atlasTextureWidth=0,t.atlasTextureHeight=0,t.maxTextureCount=0,t._atlasRestore=0,t.BOARDER_TYPE_NO=0,t.BOARDER_TYPE_RIGHT=1,t.BOARDER_TYPE_LEFT=2,t.BOARDER_TYPE_BOTTOM=4,t.BOARDER_TYPE_TOP=8,t.BOARDER_TYPE_ALL=15,t._sid_=0,t._Instance=null,t}(),N=function(){function t(){this.x=0,this.y=0,this.ret=!1,this.ret=!1,this.x=0,this.y=0}return s(t,"laya.webgl.atlas.MergeFillInfo"),t}(),W=function(){function t(){}return s(t,"laya.webgl.canvas.BlendMode"),t._init_=function(e){t.fns=[t.BlendNormal,t.BlendAdd,t.BlendMultiply,t.BlendScreen,t.BlendOverlay,t.BlendLight,t.BlendMask,t.BlendDestinationOut],t.targetFns=[t.BlendNormalTarget,t.BlendAddTarget,t.BlendMultiplyTarget,t.BlendScreenTarget,t.BlendOverlayTarget,t.BlendLightTarget,t.BlendMask,t.BlendDestinationOut]},t.BlendNormal=function(t){t.blendFuncSeparate(770,771,1,1)},t.BlendAdd=function(t){t.blendFunc(770,772)},t.BlendMultiply=function(t){t.blendFunc(774,771)},t.BlendScreen=function(t){t.blendFunc(770,1)},t.BlendOverlay=function(t){t.blendFunc(1,769)},t.BlendLight=function(t){t.blendFunc(770,1)},t.BlendNormalTarget=function(t){t.blendFuncSeparate(770,771,1,771)},t.BlendAddTarget=function(t){t.blendFunc(770,772)},t.BlendMultiplyTarget=function(t){t.blendFunc(774,771)},t.BlendScreenTarget=function(t){t.blendFunc(770,1)},t.BlendOverlayTarget=function(t){t.blendFunc(1,769)},t.BlendLightTarget=function(t){t.blendFunc(770,1)},t.BlendMask=function(t){t.blendFunc(0,770)},t.BlendDestinationOut=function(t){t.blendFunc(0,0)},t.activeBlendFunction=null,t.NAMES=["normal","add","multiply","screen","overlay","light","mask","destination-out"],t.TOINT={normal:0,add:1,multiply:2,screen:3,lighter:1,overlay:4,light:5,mask:6,"destination-out":7},t.NORMAL="normal",t.ADD="add",t.MULTIPLY="multiply",t.SCREEN="screen",t.LIGHT="light",t.OVERLAY="overlay",t.DESTINATIONOUT="destination-out",t.fns=[],t.targetFns=[],t}(),U=function(){function t(t){this._color=c.create("black"),this.setValue(t)}s(t,"laya.webgl.canvas.DrawStyle");var e=t.prototype;return e.setValue=function(t){if(t){if("string"==typeof t)return void(this._color=c.create(t));if(t instanceof laya.utils.Color)return void(this._color=t)}},e.reset=function(){this._color=c.create("black")},e.equal=function(t){return"string"==typeof t?this._color.strColor===t:t instanceof laya.utils.Color?this._color.numColor===t.numColor:!1},e.toColorStr=function(){return this._color.strColor},t.create=function(e){if(e){var i;if("string"==typeof e?i=c.create(e):e instanceof laya.utils.Color&&(i=e),i)return i._drawStyle||(i._drawStyle=new t(e))}return null},t.DEFAULT=new t("#000000"),t}(),V=function(){function t(){this._x=0,this._y=0,this.dirty=!1,this.offset=0,this.count=0,this.geoStart=0,this.tempArray=[],this.closePath=!1,this.geomatrys=[];ft.mainContext;this.ib=Ht.create(35048),this.vb=zt.create(5)}s(t,"laya.webgl.canvas.Path");var e=t.prototype;return e.addPoint=function(t,e){this.tempArray.push(t,e)},e.getEndPointX=function(){return this.tempArray[this.tempArray.length-2]},e.getEndPointY=function(){return this.tempArray[this.tempArray.length-1]},e.polygon=function(t,e,i,n,s,r){var a;return this.geomatrys.push(this._curGeomatry=a=new Ct(t,e,i,n,s,r)),n||(a.fill=!1),void 0==r&&(a.borderWidth=0),a},e.setGeomtry=function(t){this.geomatrys.push(this._curGeomatry=t)},e.drawLine=function(t,e,i,n,s){var r;return this.closePath?this.geomatrys.push(this._curGeomatry=r=new St(t,e,i,n,s)):this.geomatrys.push(this._curGeomatry=r=new Tt(t,e,i,n,s)),r.fill=!1,r},e.update=function(){var t=this.ib.byteLength,e=this.geomatrys.length;this.offset=t;for(var i=this.geoStart;e>i;i++)this.geomatrys[i].getData(this.ib,this.vb,this.vb.byteLength/20);this.geoStart=e,this.count=(this.ib.byteLength-t)/ut.BYTES_PIDX},e.reset=function(){this.vb.clear(),this.ib.clear(),this.offset=this.count=this.geoStart=0,this.geomatrys.length=0},t}(),H=function(){function t(){}s(t,"laya.webgl.canvas.save.SaveBase");var e=t.prototype;return i.imps(e,{"laya.webgl.canvas.save.ISaveData":!0}),e.isSaveMark=function(){return!1},e.restore=function(e){this._dataObj[this._valueName]=this._value,t._cache[t._cache._length++]=this,this._newSubmit&&(e._curSubmit=J.RENDERBASE,e._renderKey=0)},t._createArray=function(){var t=[];return t._length=0,t},t._init=function(){var e=t._namemap={};return e[1]="ALPHA",e[2]="fillStyle",e[8]="font",e[256]="lineWidth",e[512]="strokeStyle",e[8192]="_mergeID",e[1024]=e[2048]=e[4096]=[],e[16384]="textBaseline",e[32768]="textAlign",e[65536]="_nBlendType",e[524288]="shader",e[1048576]="filters",e},t.save=function(e,i,n,s){if((e._saveMark._saveuse&i)!==i){e._saveMark._saveuse|=i;var r=t._cache,a=r._length>0?r[--r._length]:new t;a._value=n[a._valueName=t._namemap[i]],a._dataObj=n,a._newSubmit=s;var o=e._save;o[o._length++]=a}},t._cache=laya.webgl.canvas.save.SaveBase._createArray(),t._namemap=t._init(),t}(),z=function(){function t(){this._clipRect=new x}s(t,"laya.webgl.canvas.save.SaveClipRect");var e=t.prototype;return i.imps(e,{"laya.webgl.canvas.save.ISaveData":!0}),e.isSaveMark=function(){return!1},e.restore=function(e){e._clipRect=this._clipSaveRect,t._cache[t._cache._length++]=this,this._submitScissor.submitLength=e._submits._length-this._submitScissor.submitIndex,e._curSubmit=J.RENDERBASE,e._renderKey=0},t.save=function(e,i){if(131072!=(131072&e._saveMark._saveuse)){e._saveMark._saveuse|=131072;var n=t._cache,s=n._length>0?n[--n._length]:new t;s._clipSaveRect=e._clipRect,e._clipRect=s._clipRect.copyFrom(e._clipRect),s._submitScissor=i;var r=e._save;r[r._length++]=s}},t._cache=H._createArray(),t}(),G=function(){function t(){this._saveuse=0}s(t,"laya.webgl.canvas.save.SaveMark");var e=t.prototype;return i.imps(e,{"laya.webgl.canvas.save.ISaveData":!0}),e.isSaveMark=function(){return!0},e.restore=function(e){e._saveMark=this._preSaveMark,t._no[t._no._length++]=this},t.Create=function(e){var i=t._no,n=i._length>0?i[--i._length]:new t;return n._saveuse=0,n._preSaveMark=e._saveMark,e._saveMark=n,n},t._no=H._createArray(),t}(),Y=function(){function t(){this._matrix=new v}s(t,"laya.webgl.canvas.save.SaveTransform");var e=t.prototype;return i.imps(e,{"laya.webgl.canvas.save.ISaveData":!0}),e.isSaveMark=function(){return!1},e.restore=function(e){e._curMat=this._savematrix,t._no[t._no._length++]=this},t.save=function(e){var i=e._saveMark;if(2048!==(2048&i._saveuse)){i._saveuse|=2048;var n=t._no,s=n._length>0?n[--n._length]:new t;s._savematrix=e._curMat,e._curMat=e._curMat.copyTo(s._matrix);var r=e._save;r[r._length++]=s}},t._no=H._createArray(),t}(),X=function(){function t(){}s(t,"laya.webgl.canvas.save.SaveTranslate");var e=t.prototype;return i.imps(e,{"laya.webgl.canvas.save.ISaveData":!0}),e.isSaveMark=function(){return!1},e.restore=function(e){e._curMat;e._x=this._x,e._y=this._y,t._no[t._no._length++]=this},t.save=function(e){var i=t._no,n=i._length>0?i[--i._length]:new t;n._x=e._x,n._y=e._y;var s=e._save;s[s._length++]=n},t._no=H._createArray(),t}(),$=function(){function t(){this.targets=null,this.oneTargets=null,this.repaint=!1,this._width=NaN,this._height=NaN,this._clipRect=new x}var e;s(t,"laya.webgl.resource.RenderTargetMAX");var i=t.prototype;return i.size=function(t,i){this._width===t&&this._height===i||(this.repaint=!0,this._width=t,this._height=i,this.oneTargets?this.oneTargets.target.size(t,i):this.oneTargets=new e(t,i))},i._flushToTarget=function(e,i){var n=_t.worldScissorTest,s=_t.worldClipRect;_t.worldClipRect=this._clipRect,this._clipRect.x=this._clipRect.y=0,this._clipRect.width=this._width,this._clipRect.height=this._height,_t.worldScissorTest=!1,ft.mainContext.disable(3089);var r=_t.worldAlpha,a=_t.worldMatrix4,o=_t.worldMatrix,h=_t.worldFilters,l=_t.worldShaderDefines;if(_t.worldMatrix=t._matrixDefault,_t.restoreTempArray(),_t.worldMatrix4=_t.TEMPMAT4_ARRAY,_t.worldAlpha=1,_t.worldFilters=null,_t.worldShaderDefines=null,Lt.activeShader=null,i.start(),_.showCanvasMark?i.clear(0,1,0,.3):i.clear(0,0,0,0),e.flush(),i.end(),Lt.activeShader=null,_t.worldAlpha=r,_t.worldMatrix4=a,_t.worldMatrix=o,_t.worldFilters=h,_t.worldShaderDefines=l,_t.worldScissorTest=n,n){var u=_t.height-s.y-s.height;ft.mainContext.scissor(s.x,u,s.width,s.height),ft.mainContext.enable(3089)}_t.worldClipRect=s},i.flush=function(t){this.repaint&&(this._flushToTarget(t,this.oneTargets.target),this.repaint=!1)},i.drawTo=function(t,e,i,n,s){t.drawTexture(this.oneTargets.target.getTexture(),e,i,n,s,0,0)},i.destroy=function(){this.oneTargets&&(this.oneTargets.target.destroy(),this.oneTargets.target=null,this.oneTargets=null)},n(t,["_matrixDefault",function(){return this._matrixDefault=new v}]),t.__init$=function(){e=function(){function t(t,e){this.width=t,this.height=e,this.target=Pt.create(t,e)}return s(t,""),t}()},t}(),K=function(){function t(){this.ALPHA=1,this.shaderType=0,this.defines=new bt}return s(t,"laya.webgl.shader.d2.Shader2D"),t.__init__=function(){Lt.addInclude("parts/ColorFilter_ps_uniform.glsl","uniform vec4 colorAlpha;\nuniform mat4 colorMat;"),Lt.addInclude("parts/ColorFilter_ps_logic.glsl","gl_FragColor = gl_FragColor * colorMat + colorAlpha/255.0;"),Lt.addInclude("parts/GlowFilter_ps_uniform.glsl","uniform vec4 u_color;\nuniform float u_strength;\nuniform float u_blurX;\nuniform float u_blurY;\nuniform float u_offsetX;\nuniform float u_offsetY;\nuniform float u_textW;\nuniform float u_textH;"),Lt.addInclude("parts/GlowFilter_ps_logic.glsl","const float c_IterationTime = 10.0;\nfloat floatIterationTotalTime = c_IterationTime * c_IterationTime;\nvec4 vec4Color = vec4(0.0,0.0,0.0,0.0);\nvec2 vec2FilterDir = vec2(-(u_offsetX)/u_textW,-(u_offsetY)/u_textH);\nvec2 vec2FilterOff = vec2(u_blurX/u_textW/c_IterationTime * 2.0,u_blurY/u_textH/c_IterationTime * 2.0);\nfloat maxNum = u_blurX * u_blurY;\nvec2 vec2Off = vec2(0.0,0.0);\nfloat floatOff = c_IterationTime/2.0;\nfor(float i = 0.0;i<=c_IterationTime; ++i){\n for(float j = 0.0;j<=c_IterationTime; ++j){\n vec2Off = vec2(vec2FilterOff.x * (i - floatOff),vec2FilterOff.y * (j - floatOff));\n vec4Color += texture2D(texture, v_texcoord + vec2FilterDir + vec2Off)/floatIterationTotalTime;\n }\n}\ngl_FragColor = vec4(u_color.rgb,vec4Color.a * u_strength);"),Lt.addInclude("parts/BlurFilter_ps_logic.glsl","gl_FragColor=vec4(0.0);\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 0])*0.004431848411938341;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 1])*0.05399096651318985;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 2])*0.2419707245191454;\ngl_FragColor += texture2D(texture, v_texcoord )*0.3989422804014327;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 3])*0.2419707245191454;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 4])*0.05399096651318985;\ngl_FragColor += texture2D(texture, vBlurTexCoords[ 5])*0.004431848411938341;"),Lt.addInclude("parts/BlurFilter_ps_uniform.glsl","varying vec2 vBlurTexCoords[6];"),Lt.addInclude("parts/BlurFilter_vs_uniform.glsl","uniform float strength;\nvarying vec2 vBlurTexCoords[6];"),Lt.addInclude("parts/BlurFilter_vs_logic.glsl","\nvBlurTexCoords[ 0] = v_texcoord + vec2(-0.012 * strength, 0.0);\nvBlurTexCoords[ 1] = v_texcoord + vec2(-0.008 * strength, 0.0);\nvBlurTexCoords[ 2] = v_texcoord + vec2(-0.004 * strength, 0.0);\nvBlurTexCoords[ 3] = v_texcoord + vec2( 0.004 * strength, 0.0);\nvBlurTexCoords[ 4] = v_texcoord + vec2( 0.008 * strength, 0.0);\nvBlurTexCoords[ 5] = v_texcoord + vec2( 0.012 * strength, 0.0);"),Lt.addInclude("parts/ColorAdd_ps_uniform.glsl","uniform vec4 colorAdd;\n"),Lt.addInclude("parts/ColorAdd_ps_logic.glsl","gl_FragColor = vec4(colorAdd.rgb,colorAdd.a*gl_FragColor.a);");var t,e;t='attribute vec4 position;\nattribute vec2 texcoord;\nuniform vec2 size;\n\n#ifdef WORLDMAT\nuniform mat4 mmat;\n#endif\nvarying vec2 v_texcoord;\n\n#include?BLUR_FILTER "parts/BlurFilter_vs_uniform.glsl";\nvoid main() {\n #ifdef WORLDMAT\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n #else\n gl_Position =vec4((position.x/size.x-0.5)*2.0,(0.5-position.y/size.y)*2.0,position.z,1.0);\n #endif\n \n v_texcoord = texcoord;\n #include?BLUR_FILTER "parts/BlurFilter_vs_logic.glsl";\n}',e='precision mediump float;\n//precision highp float;\nvarying vec2 v_texcoord;\nuniform sampler2D texture;\nuniform float alpha;\n#include?BLUR_FILTER "parts/BlurFilter_ps_uniform.glsl";\n#include?COLOR_FILTER "parts/ColorFilter_ps_uniform.glsl";\n#include?GLOW_FILTER "parts/GlowFilter_ps_uniform.glsl";\n#include?COLOR_ADD "parts/ColorAdd_ps_uniform.glsl";\n\nvoid main() {\n vec4 color= texture2D(texture, v_texcoord);\n color.a*=alpha;\n gl_FragColor=color;\n #include?COLOR_ADD "parts/ColorAdd_ps_logic.glsl"; \n #include?BLUR_FILTER "parts/BlurFilter_ps_logic.glsl";\n #include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";\n #include?GLOW_FILTER "parts/GlowFilter_ps_logic.glsl";\n}',Lt.preCompile2D(0,1,t,e,null),t="attribute vec4 position;\nuniform vec2 size;\nuniform mat4 mmat;\nvoid main() {\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n}",e='precision mediump float;\nuniform vec4 color;\nuniform float alpha;\n#include?COLOR_FILTER "parts/ColorFilter_ps_uniform.glsl";\nvoid main() {\n vec4 a = vec4(color.r, color.g, color.b, color.a);\n a.w = alpha;\n gl_FragColor = a;\n #include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";\n}',Lt.preCompile2D(0,2,t,e,null),t="attribute vec4 position;\nattribute vec3 a_color;\nuniform mat4 mmat;\nuniform mat4 u_mmat2;\nuniform vec2 u_pos;\nuniform vec2 size;\nvarying vec3 color;\nvoid main(){\n vec4 tPos = vec4(position.x + u_pos.x,position.y + u_pos.y,position.z,position.w);\n vec4 pos=mmat*u_mmat2*tPos;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n color=a_color;\n}",e="precision mediump float;\n//precision mediump float;\nvarying vec3 color;\nuniform float alpha;\nvoid main(){\n //vec4 a=vec4(color.r, color.g, color.b, 1);\n //a.a*=alpha;\n gl_FragColor=vec4(color.r, color.g, color.b, alpha);\n}",Lt.preCompile2D(0,4,t,e,null),t='attribute vec4 position;\nattribute vec2 texcoord;\nuniform vec2 size;\n\n#ifdef WORLDMAT\nuniform mat4 mmat;\n#endif\nvarying vec2 v_texcoord;\n\n#include?BLUR_FILTER "parts/BlurFilter_vs_uniform.glsl";\nvoid main() {\n #ifdef WORLDMAT\n vec4 pos=mmat*position;\n gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n #else\n gl_Position =vec4((position.x/size.x-0.5)*2.0,(0.5-position.y/size.y)*2.0,position.z,1.0);\n #endif\n \n v_texcoord = texcoord;\n #include?BLUR_FILTER "parts/BlurFilter_vs_logic.glsl";\n}',e='precision mediump float;\n//precision highp float;\nvarying vec2 v_texcoord;\nuniform sampler2D texture;\nuniform float alpha;\nuniform vec4 u_TexRange;\nuniform vec2 u_offset;\n#include?BLUR_FILTER "parts/BlurFilter_ps_uniform.glsl";\n#include?COLOR_FILTER "parts/ColorFilter_ps_uniform.glsl";\n#include?GLOW_FILTER "parts/GlowFilter_ps_uniform.glsl";\n#include?COLOR_ADD "parts/ColorAdd_ps_uniform.glsl";\n\nvoid main() {\n vec2 newTexCoord;\n newTexCoord.x = mod(u_offset.x + v_texcoord.x,u_TexRange.y) + u_TexRange.x;\n newTexCoord.y = mod(u_offset.y + v_texcoord.y,u_TexRange.w) + u_TexRange.z;\n vec4 color= texture2D(texture, newTexCoord);\n color.a*=alpha;\n gl_FragColor=color;\n #include?COLOR_ADD "parts/ColorAdd_ps_logic.glsl"; \n #include?BLUR_FILTER "parts/BlurFilter_ps_logic.glsl";\n #include?COLOR_FILTER "parts/ColorFilter_ps_logic.glsl";\n #include?GLOW_FILTER "parts/GlowFilter_ps_logic.glsl";\n}',Lt.preCompile2D(0,256,t,e,null),t="attribute vec2 position;\nattribute vec2 texcoord;\nattribute vec4 color;\nuniform vec2 size;\nuniform float offsetX;\nuniform float offsetY;\nuniform mat4 mmat;\nuniform mat4 u_mmat2;\nvarying vec2 v_texcoord;\nvarying vec4 v_color;\nvoid main() {\n vec4 pos=mmat*u_mmat2*vec4(offsetX+position.x,offsetY+position.y,0,1 );\n gl_Position = vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\n v_color = color;\n v_texcoord = texcoord; \n}",e="precision mediump float;\nvarying vec2 v_texcoord;\nvarying vec4 v_color;\nuniform sampler2D texture;\nuniform float alpha;\nvoid main() {\n vec4 t_color = texture2D(texture, v_texcoord);\n gl_FragColor = t_color.rgba * v_color;\n gl_FragColor.a = gl_FragColor.a * alpha;\n}",Lt.preCompile2D(0,512,t,e,null)},t}(),j=function(){function t(t,e,i){this._value=0,this._name2int=t,this._int2name=e,this._int2nameMap=i}s(t,"laya.webgl.shader.ShaderDefines");var e=t.prototype;return e.add=function(t){return"string"==typeof t&&(t=this._name2int[t]),this._value|=t,this._value},e.addInt=function(t){return this._value|=t,this._value},e.remove=function(t){return"string"==typeof t&&(t=this._name2int[t]),this._value&=~t,this._value},e.isDefine=function(t){return(this._value&t)===t},e.getValue=function(){return this._value},e.setValue=function(t){this._value=t},e.toNameDic=function(){var e=this._int2nameMap[this._value];return e?e:t._toText(this._value,this._int2name,this._int2nameMap)},t._reg=function(t,e,i,n){i[t]=e,n[e]=t},t._toText=function(t,e,i){var n=i[t];if(n)return n;for(var s={},r=1,a=0;32>a&&(r=1<t));a++)if(t&r){var o=e[r];o&&(s[o]="")}return i[t]=s,s},t._toInt=function(t,e){for(var i=t.split("."),n=0,s=0,r=i.length;r>s;s++){var a=e[i[s]];if(!a)throw new Error("Defines to int err:"+t+"/"+i[s]);n|=a}return n},t}(),q=function(){function t(){this.mVBBuffer=null,this.mIBBuffer=null,this.mVBData=null,this.mIBData=null,this.mEleNum=0,this.mTexture=null,this.transform=null,this._vs=null,this._ps=null,this._resultPs=null,this._start=-1,this._indexStart=-1,this._tempMatrix=new v}s(t,"laya.webgl.shader.d2.skinAnishader.SkinMesh");var e=t.prototype;return e.init=function(t,e,i){if(e)this._vs=e;else{this._vs=[];var n=t.width,s=t.height,r=1,a=1,o=1,h=1;this._vs.push(0,0,0,0,r,a,o,h),this._vs.push(n,0,1,0,r,a,o,h),this._vs.push(n,s,1,1,r,a,o,h),this._vs.push(0,s,0,1,r,a,o,h)}i?this._ps=i:(this._ps=[],this._ps.push(0,1,3,3,1,2)),this.mVBData=new Float32Array(this._vs),this.mEleNum=this._ps.length,this.mTexture=t},e.getData=function(t,e,i){this.mVBBuffer=t,this.mIBBuffer=e,t.append(this.mVBData),this._start=i,this._indexStart=e.byteLength,null==this._resultPs&&(this._resultPs=[]),this._resultPs.length=0;for(var n=0,s=this._ps.length;s>n;n++)this._resultPs.push(this._ps[n]+i);this.mIBData=new Uint16Array(this._resultPs),e.append(this.mIBData)},e.render=function(t,e,i){if(w.isWebGL&&this.mTexture){t._renderKey=0,t._shader2D.glTexture=null,Q.getInstance().addSkinMesh(this);var n=J.createShape(t,this.mIBBuffer,this.mVBBuffer,this.mEleNum,this._indexStart,vt.create(512,0));this.transform||(this.transform=v.EMPTY),this.transform.translate(e,i),v.mul(this.transform,t._curMat,this._tempMatrix),this.transform.translate(-e,-i);var s=_t.getMatrArray();_t.mat2MatArray(this._tempMatrix,s);var r=n.shaderValue;r.textureHost=this.mTexture,r.offsetX=0,r.offsetY=0,r.u_mmat2=s,r.ALPHA=t._shader2D.ALPHA,t._submits[t._submits._length++]=n}else w.isConchApp&&this.mTexture&&(this.transform||(this.transform=v.EMPTY),t.setSkinMesh&&t.setSkinMesh(e,i,this._ps,this.mVBData,this.mEleNum,0,this.mTexture,this.transform))},t}(),Q=function(){function t(){this.ib=null,this.vb=null;ft.mainContext;this.ib=Ht.create(35048),this.vb=zt.create(8)}s(t,"laya.webgl.shader.d2.skinAnishader.SkinMeshBuffer");var e=t.prototype;return e.addSkinMesh=function(t){t.getData(this.vb,this.ib,this.vb.byteLength/32)},e.reset=function(){this.vb.clear(),this.ib.clear()},t.getInstance=function(){return t.instance=t.instance||new t},t.instance=null,t}(),Z=function(){function t(t,e,i,n,s,r,a,o,h){this.r0=0,this.fill=!0,this.r1=Math.PI/2,void 0===h&&(h=0),this.x=t,this.y=e,this.width=i,this.height=n,this.edges=s,this.color=r,this.borderWidth=a,this.borderColor=o}s(t,"laya.webgl.shapes.BasePoly");var e=t.prototype;return i.imps(e,{"laya.webgl.shapes.IShape":!0}),e.getData=function(t,e,i){},e.sector=function(t,e,i){var n=this.x,s=this.y,r=this.edges,a=(this.r1-this.r0)/r,o=this.width,h=this.height,l=this.color,u=(l>>16&255)/255,c=(l>>8&255)/255,_=(255&l)/255;t.push(n,s,u,c,_);for(var d=0;r+1>d;d++)t.push(n+Math.sin(a*d+this.r0)*o,s+Math.cos(a*d+this.r0)*h),t.push(u,c,_);for(d=0;r>d;d++)e.push(i,i+d+1,i+d+2)},e.createLine2=function(t,e,i,n,s,r){var a,o,h,l,u,c,_,d,f,p,g,m,v,y,x,w,b,T,S,C,M,A=t.concat(),L=s,P=this.borderColor,R=(P>>16&255)/255,I=(P>>8&255)/255,E=(255&P)/255,D=A.length/2,F=n,B=i/2;h=A[0],l=A[1],u=A[2],c=A[3],f=-(l-c),p=h-u,M=Math.sqrt(f*f+p*p),f=f/M*B,p=p/M*B,L.push(h-f+this.x,l-p+this.y,R,I,E,h+f+this.x,l+p+this.y,R,I,E);for(var k=1;D-1>k;k++)h=A[2*(k-1)],l=A[2*(k-1)+1],u=A[2*k],c=A[2*k+1],_=A[2*(k+1)],d=A[2*(k+1)+1],f=-(l-c),p=h-u,M=Math.sqrt(f*f+p*p),f=f/M*B,p=p/M*B,g=-(c-d),m=u-_,M=Math.sqrt(g*g+m*m),g=g/M*B,m=m/M*B,v=-p+l-(-p+c),y=-f+u-(-f+h),x=(-f+h)*(-p+c)-(-f+u)*(-p+l),w=-m+d-(-m+c),b=-g+u-(-g+_),T=(-g+_)*(-m+c)-(-g+u)*(-m+d),S=v*b-w*y,Math.abs(S)<.1?(S+=10.1,L.push(u-f+this.x,c-p+this.y,R,I,E,u+f+this.x,c+p+this.y,R,I,E)):(a=(y*T-b*x)/S,o=(w*x-v*T)/S,C=(a-u)*(a-u)+(o-c)+(o-c),L.push(a+this.x,o+this.y,R,I,E,u-(a-u)+this.x,c-(o-c)+this.y,R,I,E));h=A[A.length-4],l=A[A.length-3],u=A[A.length-2],c=A[A.length-1],f=-(l-c),p=h-u,M=Math.sqrt(f*f+p*p),f=f/M*B,p=p/M*B,L.push(u-f+this.x,c-p+this.y,R,I,E,u+f+this.x,c+p+this.y,R,I,E);var O=r;for(k=1;O>k;k++)e.push(F+2*(k-1),F+2*(k-1)+1,F+2*k+1,F+2*k+1,F+2*k,F+2*(k-1));return L},e.createLine=function(t,e,i,n){var s=t.concat(),r=t,a=this.borderColor,o=(a>>16&255)/255,h=(a>>8&255)/255,l=(255&a)/255;s.splice(0,5);var u,c,_,d,f,p,g,m,v,y,x,w,b,T,S,C,M,A,L,P,R,I=s.length/5,E=n,D=i/2;_=s[0],d=s[1],f=s[5],p=s[6],v=-(d-p),y=_-f,R=Math.sqrt(v*v+y*y),v=v/R*D,y=y/R*D,r.push(_-v,d-y,o,h,l,_+v,d+y,o,h,l);for(var F=1;I-1>F;F++)_=s[5*(F-1)],d=s[5*(F-1)+1],f=s[5*F],p=s[5*F+1],g=s[5*(F+1)],m=s[5*(F+1)+1],v=-(d-p),y=_-f,R=Math.sqrt(v*v+y*y),v=v/R*D,y=y/R*D,x=-(p-m),w=f-g,R=Math.sqrt(x*x+w*w),x=x/R*D,w=w/R*D,b=-y+d-(-y+p),T=-v+f-(-v+_),S=(-v+_)*(-y+p)-(-v+f)*(-y+d),C=-w+m-(-w+p),M=-x+f-(-x+g),A=(-x+g)*(-w+p)-(-x+f)*(-w+m),L=b*M-C*T,Math.abs(L)<.1?(L+=10.1,r.push(f-v,p-y,o,h,l,f+v,p+y,o,h,l)):(u=(T*A-M*S)/L,c=(C*S-b*A)/L,P=(u-f)*(u-f)+(c-p)+(c-p),r.push(u,c,o,h,l,f-(u-f),p-(c-p),o,h,l));_=s[s.length-10],d=s[s.length-9],f=s[s.length-5],p=s[s.length-4],v=-(d-p),y=_-f,R=Math.sqrt(v*v+y*y),v=v/R*D,y=y/R*D,r.push(f-v,p-y,o,h,l,f+v,p+y,o,h,l);var B=this.edges+1;for(F=1;B>F;F++)e.push(E+2*(F-1),E+2*(F-1)+1,E+2*F+1,E+2*F+1,E+2*F,E+2*(F-1));return r},e.createLoopLine=function(t,e,i,n,s,r){var a=t.concat(),o=s?s:t,h=this.borderColor,l=(h>>16&255)/255,u=(h>>8&255)/255,c=(255&h)/255;a.splice(0,5);var _=[a[0],a[1]],d=[a[a.length-5],a[a.length-4]],f=d[0]+.5*(_[0]-d[0]),p=d[1]+.5*(_[1]-d[1]);a.unshift(f,p,0,0,0),a.push(f,p,0,0,0);var g,m,v,y,x,w,b,T,S,C,M,A,L,P,R,I,E,D,F,B,k,O=a.length/5,N=n,W=i/2;v=a[0],y=a[1],x=a[5],w=a[6],S=-(y-w),C=v-x,k=Math.sqrt(S*S+C*C),S=S/k*W,C=C/k*W,o.push(v-S,y-C,l,u,c,v+S,y+C,l,u,c);for(var U=1;O-1>U;U++)v=a[5*(U-1)],y=a[5*(U-1)+1],x=a[5*U],w=a[5*U+1],b=a[5*(U+1)],T=a[5*(U+1)+1],S=-(y-w),C=v-x,k=Math.sqrt(S*S+C*C),S=S/k*W,C=C/k*W,M=-(w-T),A=x-b,k=Math.sqrt(M*M+A*A),M=M/k*W,A=A/k*W,L=-C+y-(-C+w),P=-S+x-(-S+v),R=(-S+v)*(-C+w)-(-S+x)*(-C+y),I=-A+T-(-A+w),E=-M+x-(-M+b),D=(-M+b)*(-A+w)-(-M+x)*(-A+T),F=L*E-I*P,Math.abs(F)<.1?(F+=10.1,o.push(x-S,w-C,l,u,c,x+S,w+C,l,u,c)):(g=(P*D-E*R)/F,m=(I*R-L*D)/F,B=(g-x)*(g-x)+(m-w)+(m-w),o.push(g,m,l,u,c,x-(g-x),w-(m-w),l,u,c));r&&(e=r);var V=this.edges+1;for(U=1;V>U;U++)e.push(N+2*(U-1),N+2*(U-1)+1,N+2*U+1,N+2*U+1,N+2*U,N+2*(U-1));return e.push(N+2*(U-1),N+2*(U-1)+1,N+1,N+1,N,N+2*(U-1)),o},t}(),J=(function(){function t(t,e,i,n,s,r,a){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this.fillColor=n,this.fillAlpha=s,this.shape=a,this.fill=r}s(t,"laya.webgl.shapes.GeometryData");var e=t.prototype;return e.clone=function(){return new t(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.getIndexData=function(){return null},e.getVertexData=function(){return null},e.destroy=function(){this.shape=null},t}(),function(){function t(t){if(t instanceof Float32Array)this.points=t;else if(t instanceof Array){t.length;this.points=new Float32Array(t)}}s(t,"laya.webgl.shapes.Vertex");var e=t.prototype;return i.imps(e,{"laya.webgl.shapes.IShape":!0}),e.getData=function(t,e,i){},t}(),function(){function t(t){void 0===t&&(t=1e4),this._renderType=t}s(t,"laya.webgl.submit.Submit");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e.releaseRender=function(){var e=t._cache;e[e._length++]=this,this.shaderValue.release(),this._vb=null},e.getRenderType=function(){return this._renderType},e.renderSubmit=function(){if(0===this._numEle)return 1;var t=this.shaderValue.textureHost;if(t){var e=t.source;if(!t.bitmap||!e)return 1;this.shaderValue.texture=e}this._vb.bind_upload(this._ib);var i=ft.mainContext;return this.shaderValue.upload(),W.activeBlendFunction!==this._blendFn&&(i.enable(3042),this._blendFn(i),W.activeBlendFunction=this._blendFn),A.drawCall++,A.trianglesFaces+=this._numEle/3,i.drawElements(4,this._numEle,5123,this._startIdx),1},t.__init__=function(){var e=t.RENDERBASE=new t(-1);e.shaderValue=new vt(0,0),e.shaderValue.ALPHA=-1234},t.create=function(e,i,n,s,r){var a=t._cache._length?t._cache[--t._cache._length]:new t;null==n&&(n=a._selfVb||(a._selfVb=zt.create(-1)),n.clear(),s=0),a._ib=i,a._vb=n,a._startIdx=s*ut.BYTES_PIDX,a._numEle=0;var o=e._nBlendType;a._blendFn=e._targets?W.targetFns[o]:W.fns[o],a.shaderValue=r,a.shaderValue.setValue(e._shader2D);var h=e._shader2D.filters;return h&&a.shaderValue.setFilters(h),a},t.createShape=function(e,i,n,s,r,a){var o=t._cache._length?t._cache[--t._cache._length]:new t;o._ib=i,o._vb=n,o._numEle=s,o._startIdx=r,o.shaderValue=a,o.shaderValue.setValue(e._shader2D);var h=e._nBlendType;return o._blendFn=e._targets?W.targetFns[h]:W.fns[h],o},t.TYPE_2D=1e4,t.TYPE_CANVAS=10003,t.TYPE_CMDSETRT=10004,t.TYPE_CUSTOM=10005,t.TYPE_BLURRT=10006,t.TYPE_CMDDESTORYPRERT=10007,t.TYPE_DISABLESTENCIL=10008,t.TYPE_OTHERIBVB=10009,t.TYPE_PRIMITIVE=10010,t.TYPE_RT=10011,t.TYPE_BLUR_RT=10012,t.TYPE_TARGET=10013,t.TYPE_CHANGE_VALUE=10014,t.TYPE_SHAPE=10015,t.TYPE_TEXTURE=10016,t.RENDERBASE=null,t._cache=(t._cache=[],t._cache._length=0,t._cache),t}()),tt=function(){function t(){this.fun=null,this.args=null}s(t,"laya.webgl.submit.SubmitCMD");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e.renderSubmit=function(){return this.fun.apply(null,this.args),1},e.getRenderType=function(){return 0},e.releaseRender=function(){var e=t._cache;e[e._length++]=this},t.create=function(e,i){var n=t._cache._length?t._cache[--t._cache._length]:new t;return n.fun=i,n.args=e,n},t._cache=(t._cache=[],t._cache._length=0,t._cache),t}(),et=function(){function t(){this.variables={}}s(t,"laya.webgl.submit.SubmitCMDScope");var e=t.prototype;return e.getValue=function(t){return this.variables[t]},e.addValue=function(t,e){return this.variables[t]=e},e.setValue=function(t,e){return this.variables.hasOwnProperty(t)?this.variables[t]=e:null},e.clear=function(){for(var t in this.variables)delete this.variables[t]},e.recycle=function(){this.clear(),t.POOL.push(this)},t.create=function(){var e=t.POOL.pop();return e||(e=new t),e},t.POOL=[],t}(),it=function(){function t(){this.offset=0,this.startIndex=0,this._mat=v.create()}s(t,"laya.webgl.submit.SubmitOtherIBVB");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e.releaseRender=function(){var e=t._cache;e[e._length++]=this},e.getRenderType=function(){return 10009},e.renderSubmit=function(){var e=this._shaderValue.textureHost;if(e){var i=e.source;if(!e.bitmap||!i)return 1;this._shaderValue.texture=i}this._vb.bind_upload(this._ib);var n=_t.worldMatrix4,s=v.TEMP;v.mulPre(this._mat,n[0],n[1],n[4],n[5],n[12],n[13],s);var r=_t.worldMatrix4=t.tempMatrix4;r[0]=s.a,r[1]=s.b,r[4]=s.c,r[5]=s.d,r[12]=s.tx,r[13]=s.ty,this._shader._offset=this.offset,this._shaderValue.refresh(),this._shader.upload(this._shaderValue),this._shader._offset=0;var a=ft.mainContext;return W.activeBlendFunction!==this._blendFn&&(a.enable(3042),this._blendFn(a),W.activeBlendFunction=this._blendFn),A.drawCall++,A.trianglesFaces+=this._numEle/3,a.drawElements(4,this._numEle,5123,this.startIndex),_t.worldMatrix4=n,Lt.activeShader=null,1},t.create=function(e,i,n,s,r,a,o,h,l){void 0===l&&(l=0);var u=t._cache._length?t._cache[--t._cache._length]:new t;u._ib=n,u._vb=i,u._numEle=s,u._shader=r,u._shaderValue=a;var c=e._nBlendType;switch(u._blendFn=e._targets?W.targetFns[c]:W.fns[c],l){case 0:u.offset=0,u.startIndex=h/(ut.BYTES_PE*i.vertexStride)*1.5,u.startIndex*=ut.BYTES_PIDX;break;case 1:u.startIndex=o,u.offset=h}return u},t._cache=(t._cache=[],t._cache._length=0,t._cache),t.tempMatrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t}(),nt=function(){function t(){this.submitIndex=0,this.submitLength=0,this.context=null,this.clipRect=new x,this.screenRect=new x}s(t,"laya.webgl.submit.SubmitScissor");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e._scissor=function(t,e,i,n){var s=_t.worldMatrix4,r=s[0],a=s[5],o=s[12],h=s[13];if(t=t*r+o,e=e*a+h,i*=r,n*=a,1>i||1>n)return!1;var l=t+i,u=e+n;0>t&&(t=0,i=l-t),0>e&&(e=0,n=u-e);var c=_t.worldClipRect;if(t=Math.max(t,c.x),e=Math.max(e,c.y),i=Math.min(l,c.right)-t,n=Math.min(u,c.bottom)-e,1>i||1>n)return!1;var _=_t.worldScissorTest;return this.screenRect.copyFrom(c),c.x=t,c.y=e,c.width=i,c.height=n,_t.worldScissorTest=!0,e=_t.height-e-n,ft.mainContext.scissor(t,e,i,n),ft.mainContext.enable(3089),this.context.submitElement(this.submitIndex,this.submitIndex+this.submitLength),_?(e=_t.height-this.screenRect.y-this.screenRect.height,ft.mainContext.scissor(this.screenRect.x,e,this.screenRect.width,this.screenRect.height),ft.mainContext.enable(3089)):(ft.mainContext.disable(3089),_t.worldScissorTest=!1),c.copyFrom(this.screenRect),!0},e._scissorWithTagart=function(t,e,i,n){if(1>i||1>n)return!1;var s=t+i,r=e+n;0>t&&(t=0,i=s-t),0>e&&(e=0,n=r-e);var a=_t.worldClipRect;if(t=Math.max(t,a.x),e=Math.max(e,a.y),i=Math.min(s,a.right)-t,n=Math.min(r,a.bottom)-e,1>i||1>n)return!1;var o=_t.worldScissorTest;return this.screenRect.copyFrom(a),_t.worldScissorTest=!0,a.x=t,a.y=e,a.width=i,a.height=n,e=_t.height-e-n,ft.mainContext.scissor(t,e,i,n),ft.mainContext.enable(3089), +this.context.submitElement(this.submitIndex,this.submitIndex+this.submitLength),o?(e=_t.height-this.screenRect.y-this.screenRect.height,ft.mainContext.scissor(this.screenRect.x,e,this.screenRect.width,this.screenRect.height),ft.mainContext.enable(3089)):(ft.mainContext.disable(3089),_t.worldScissorTest=!1),a.copyFrom(this.screenRect),!0},e.renderSubmit=function(){return this.submitLength=Math.min(this.context._submits._length-1,this.submitLength),this.submitLength<1||this.clipRect.width<1||this.clipRect.height<1?this.submitLength+1:(this.context._targets?this._scissorWithTagart(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height):this._scissor(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height),this.submitLength+1)},e.getRenderType=function(){return 0},e.releaseRender=function(){var e=t._cache;e[e._length++]=this,this.context=null},t.create=function(e){var i=t._cache._length?t._cache[--t._cache._length]:new t;return i.context=e,i},t._cache=(t._cache=[],t._cache._length=0,t._cache),t}(),st=function(){function t(){this.step=0,this.blendMode=null,this.level=0}s(t,"laya.webgl.submit.SubmitStencil");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e.renderSubmit=function(){switch(this.step){case 1:this.do1();break;case 2:this.do2();break;case 3:this.do3();break;case 4:this.do4();break;case 5:this.do5();break;case 6:this.do6()}return 1},e.getRenderType=function(){return 0},e.releaseRender=function(){var e=t._cache;e[e._length++]=this},e.do1=function(){var t=ft.mainContext;t.enable(2960),t.clear(1024),t.colorMask(!1,!1,!1,!1),t.stencilFunc(514,this.level,255),t.stencilOp(7680,7680,7682)},e.do2=function(){var t=ft.mainContext;t.stencilFunc(514,this.level+1,255),t.colorMask(!0,!0,!0,!0),t.stencilOp(7680,7680,7680)},e.do3=function(){var t=ft.mainContext;t.colorMask(!0,!0,!0,!0),t.stencilOp(7680,7680,7680),t.clear(1024),t.disable(2960)},e.do4=function(){var t=ft.mainContext;t.enable(2960),t.clear(1024),t.colorMask(!1,!1,!1,!1),t.stencilFunc(519,this.level,255),t.stencilOp(7680,7680,5386)},e.do5=function(){var t=ft.mainContext;t.stencilFunc(514,255,255),t.colorMask(!0,!0,!0,!0),t.stencilOp(7680,7680,7680)},e.do6=function(){var t=ft.mainContext;W.targetFns[W.TOINT[this.blendMode]](t)},t.create=function(e){var i=t._cache._length?t._cache[--t._cache._length]:new t;return i.step=e,i},t._cache=(t._cache=[],t._cache._length=0,t._cache),t}(),rt=function(){function t(){this._renderType=0,this._vb=null,this._ib=null,this._startIdx=0,this._numEle=0,this.shaderValue=null,this.blendType=0,this.proName=null,this.scope=null}s(t,"laya.webgl.submit.SubmitTarget");var e=t.prototype;return i.imps(e,{"laya.webgl.submit.ISubmit":!0}),e.renderSubmit=function(){this._vb.bind_upload(this._ib);var t=this.scope.getValue(this.proName);return t&&(this.shaderValue.texture=t.source,this.shaderValue.upload(),this.blend(),A.drawCall++,A.trianglesFaces+=this._numEle/3,ft.mainContext.drawElements(4,this._numEle,5123,this._startIdx)),1},e.blend=function(){if(W.activeBlendFunction!==W.fns[this.blendType]){var t=ft.mainContext;t.enable(3042),W.fns[this.blendType](t),W.activeBlendFunction=W.fns[this.blendType]}},e.getRenderType=function(){return 0},e.releaseRender=function(){var e=t._cache;e[e._length++]=this},t.create=function(e,i,n,s,r,a){var o=t._cache._length?t._cache[--t._cache._length]:new t;return o._ib=i,o._vb=n,o.proName=a,o._startIdx=s*ut.BYTES_PIDX,o._numEle=0,o.blendType=e._nBlendType,o.shaderValue=r,o.shaderValue.setValue(e._shader2D),o},t._cache=(t._cache=[],t._cache._length=0,t._cache),t}(),at=function(){function t(){this._sourceStr=null}s(t,"laya.webgl.text.CharSegment");var e=t.prototype;return i.imps(e,{"laya.webgl.text.ICharSegment":!0}),e.textToSpit=function(t){this._sourceStr=t},e.getChar=function(t){return this._sourceStr.charAt(t)},e.getCharCode=function(t){return this._sourceStr.charCodeAt(t)},e.length=function(){return this._sourceStr.length},t}(),ot=function(){function t(){}var e;return s(t,"laya.webgl.text.DrawText"),t.__init__=function(){t._charsTemp=new Array,t._drawValue=new e,t._charSeg=new at},t.customCharSeg=function(e){t._charSeg=e},t.getChar=function(e,i,n){return t._charsCache[i]=ht.createOneChar(e,n)},t._drawSlow=function(e,i,n,s,r,a,o,h,l,u,c,_,d,f){var p,g,m=t._drawValue.value(a,h,l,u,d,f),v=0,y=0,x=t._charsTemp,w=0,b=NaN;if(s)for(x.length=s.length,v=0,y=s.length;y>v;v++)g=s[v],b=g.charNum+m.txtID,x[v]=p=t._charsCache[b]||t.getChar(g["char"],b,m),p.active();else{n instanceof laya.utils.WordText?t._charSeg.textToSpit(n.toString()):t._charSeg.textToSpit(n);var T=t._charSeg.length();for(x.length=T,v=0,y=T;y>v;v++)b=t._charSeg.getCharCode(v)+m.txtID,x[v]=p=t._charsCache[b]||t.getChar(t._charSeg.getChar(v),b,m),p.active(),w+=p.width}var S=0;null!==o&&"left"!==o&&(S=-("center"==o?w/2:w));var C,M,A=NaN,L=0;if(s)for(v=0,y=x.length;y>v;v++)p=x[v],p.isSpace||(g=s[v],A=p.borderSize,C=p.texture,i._drawText(C,c+S+g.x*d-A,_+g.y*f-A,C.width,C.height,r,0,0,0,0));else{for(v=0,y=x.length;y>v;v++)p=x[v],p.isSpace||(A=p.borderSize,C=p.texture,i._drawText(C,c+S-A,_-A,C.width,C.height,r,0,0,0,0),e&&(M=e[L++],M||(M=e[L-1]=[]),M[0]=C,M[1]=S-A,M[2]=-A)),S+=p.width;e&&(e.length=L)}},t._drawFast=function(t,e,i,n,s){for(var r,a,o=0,h=t.length;h>o;o++)a=t[o],r=a[0],r.active(),e._drawText(r,n+a[1],s+a[2],r.width,r.height,i,0,0,0,0)},t.drawText=function(e,n,s,r,a,o,h,l,u,c,d){if(!(n&&0===n.length||s&&0===s.length)){var f=r.a,p=r.d;(0!==r.b||0!==r.c)&&(f=p=1);var g=1!==f||1!==p;if(g&&i.stage.transform){var m=i.stage.transform;g=m.a===f&&m.d===p}else g=!1;if(g?(r=r.copyTo(mt._tmpMatrix),r.scale(1/f,1/p),r._checkTransform(),c*=f,d*=p):f=p=1,s)t._drawSlow(null,e,n,s,r,a,o,h,l,u,c,d,f,p);else{if(null===n.toUpperCase){var v=f+1e5*p,y=n;return void(y.changed||y.id!==v?(y.id=v,y.changed=!1,t._drawSlow(y.save,e,n,s,r,a,o,h,l,u,c,d,f,p)):t._drawFast(y.save,e,r,c,d))}var x=n+a.toString()+h+l+u+f+p+o,w=t._textsCache[x];w?t._drawFast(w,e,r,c,d):(t._textsCache.__length||(t._textsCache.__length=0),t._textsCache.__length>_.WebGLTextCacheCount&&(t._textsCache={},t._textsCache.__length=0,t._curPoolIndex=0),t._textCachesPool[t._curPoolIndex]?(w=t._textsCache[x]=t._textCachesPool[t._curPoolIndex],w.length=0):t._textCachesPool[t._curPoolIndex]=w=t._textsCache[x]=[],t._textsCache.__length++,t._curPoolIndex++,t._drawSlow(w,e,n,s,r,a,o,h,l,u,c,d,f,p))}}},t._charsTemp=null,t._textCachesPool=[],t._curPoolIndex=0,t._charsCache={},t._textsCache={},t._drawValue=null,t.d=[],t._charSeg=null,t.__init$=function(){e=function(){function t(){}s(t,"");var e=t.prototype;return e.value=function(e,i,n,s,r,a){this.font=e,this.fillColor=i,this.borderColor=n,this.lineWidth=s,this.scaleX=r,this.scaleY=a;var o=e.toString()+r+a+s+i+n;return this.txtID=t._keymap[o],this.txtID||(this.txtID=1e-7*++t._keymapCount,t._keymap[o]=this.txtID),this},t.clear=function(){t._keymap={},t._keymapCount=1},t._keymap={},t._keymapCount=1,t}()},t}(),ht=function(){function t(t,e){this["char"]=t,this.isSpace=" "===t,this.xs=e.scaleX,this.ys=e.scaleY,this.font=e.font.toString(),this.fontSize=e.font.size,this.fillColor=e.fillColor,this.borderColor=e.borderColor,this.lineWidth=e.lineWidth;var i=w.isConchApp;if(i){var n=ConchTextCanvas;n._source=ConchTextCanvas,n._source.canvas=ConchTextCanvas,this.texture=new R(new Ot(n,this))}else this.texture=new R(new Ot(u.canvas.source,this))}s(t,"laya.webgl.text.DrawTextChar");var e=t.prototype;return e.active=function(){this.texture.active()},t.createOneChar=function(e,i){var n=new t(e,i);return n},t}(),lt=function(){function t(t){this._index=0,this._size=14,this._italic=-2,this.setFont(t||"14px Arial")}s(t,"laya.webgl.text.FontInContext");var e=t.prototype;return e.setFont=function(t){this._words=t.split(" ");for(var e=0,i=this._words.length;i>e;e++)if(this._words[e].indexOf("px")>0){this._index=e;break}this._size=parseInt(this._words[this._index]),this._text=null,this._italic=-2},e.getItalic=function(){return-2===this._italic&&(this._italic=this.hasType("italic")),this._italic},e.hasType=function(t){for(var e=0,i=this._words.length;i>e;e++)if(this._words[e]===t)return e;return-1},e.removeType=function(t){for(var e=0,i=this._words.length;i>e;e++)if(this._words[e]===t){this._words.splice(e,1),this._index>e&&this._index--;break}this._text=null,this._italic=-2},e.copyTo=function(t){return t._text=this._text,t._size=this._size,t._index=this._index,t._words=this._words.slice(),t._italic=-2,t},e.toString=function(){return this._text?this._text:this._text=this._words.join(" ")},r(0,e,"size",function(){return this._size},function(t){this._size=t,this._words[this._index]=t+"px",this._text=null}),t.create=function(e){var i=t._cache[e];return i?i:i=t._cache[e]=new t(e)},t.EMPTY=new t,t._cache={},t}(),ut=function(){function t(){}return s(t,"laya.webgl.utils.CONST3D2D"),t.defaultMatrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t.defaultMinusYMatrix4=[1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1],t.uniformMatrix3=[1,0,0,0,0,1,0,0,0,0,1,0],t._TMPARRAY=[],t._OFFSETX=0,t._OFFSETY=0,n(t,["BYTES_PE",function(){return this.BYTES_PE=Float32Array.BYTES_PER_ELEMENT},"BYTES_PIDX",function(){return this.BYTES_PIDX=Uint16Array.BYTES_PER_ELEMENT}]),t}(),ct=function(){function t(){}return s(t,"laya.webgl.utils.GlUtils"),t.make2DProjection=function(t,e,i){return[2/t,0,0,0,0,-2/e,0,0,0,0,2/i,0,-1,1,0,1]},t.fillIBQuadrangle=function(t,e){if(e>65535/4)throw Error("IBQuadrangle count:"+e+" must<:"+Math.floor(65535/4));e=Math.floor(e),t._resizeBuffer(6*(e+1)*2,!1),t.byteLength=t.bufferLength;for(var i=t.getUint16Array(),n=0,s=0;e>s;s++)i[n++]=4*s,i[n++]=4*s+2,i[n++]=4*s+1,i[n++]=4*s,i[n++]=4*s+3,i[n++]=4*s+2;return t.setNeedUpload(),!0},t.expandIBQuadrangle=function(e,i){e.bufferLength>=6*i*2||t.fillIBQuadrangle(e,i)},t.mathCeilPowerOfTwo=function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t},t.fillQuadrangleImgVb=function(t,e,i,n,s,r,a,o){"use strict";var h=(t._byteLength>>2)+16;t.byteLength=h<<2;var l=t.getFloat32Array();h-=16,l[h+2]=s[0],l[h+3]=s[1],l[h+6]=s[2],l[h+7]=s[3],l[h+10]=s[4],l[h+11]=s[5],l[h+14]=s[6],l[h+15]=s[7];var u=r.a,c=r.b,_=r.c,d=r.d;if(1!==u||0!==c||0!==_||1!==d){r.bTransform=!0;var f=r.tx+a,p=r.ty+o;l[h]=(n[0]+e)*u+(n[1]+i)*_+f,l[h+1]=(n[0]+e)*c+(n[1]+i)*d+p,l[h+4]=(n[2]+e)*u+(n[3]+i)*_+f,l[h+5]=(n[2]+e)*c+(n[3]+i)*d+p,l[h+8]=(n[4]+e)*u+(n[5]+i)*_+f,l[h+9]=(n[4]+e)*c+(n[5]+i)*d+p,l[h+12]=(n[6]+e)*u+(n[7]+i)*_+f,l[h+13]=(n[6]+e)*c+(n[7]+i)*d+p}else r.bTransform=!1,e+=r.tx+a,i+=r.ty+o,l[h]=e+n[0],l[h+1]=i+n[1],l[h+4]=e+n[2],l[h+5]=i+n[3],l[h+8]=e+n[4],l[h+9]=i+n[5],l[h+12]=e+n[6],l[h+13]=i+n[7];return t._upload=!0,!0},t.fillTranglesVB=function(t,e,i,n,s,r,a){"use strict";var o=(t._byteLength>>2)+n.length;t.byteLength=o<<2;var h=t.getFloat32Array();o-=n.length;for(var l=n.length,u=s.a,c=s.b,_=s.c,d=s.d,f=0;l>f;f+=4)if(h[o+f+2]=n[f+2],h[o+f+3]=n[f+3],1!==u||0!==c||0!==_||1!==d){s.bTransform=!0;var p=s.tx+r,g=s.ty+a;h[o+f]=(n[f]+e)*u+(n[f+1]+i)*_+p,h[o+f+1]=(n[f]+e)*c+(n[f+1]+i)*d+g}else s.bTransform=!1,e+=s.tx+r,i+=s.ty+a,h[o+f]=e+n[f],h[o+f+1]=i+n[f+1];return t._upload=!0,!0},t.copyPreImgVb=function(t,e,i){var n=t._byteLength>>2;t.byteLength=n+16<<2;for(var s=t.getFloat32Array(),r=0,a=n-16;4>r;r++)s[n]=s[a]+e,++n,++a,s[n]=s[a]+i,++n,++a,s[n]=s[a],++n,++a,s[n]=s[a],++n,++a;t._upload=!0},t.fillRectImgVb=function(t,e,i,n,s,r,a,o,h,l,u,c,_){void 0===_&&(_=!1);var d,f,p,g,m,v,y,x,w,b,T,S,C,M,A,L,P=1,R=o.a,I=o.b,E=o.c,D=o.d,F=e.width<99999999;if(1!==R||0!==I||0!==E||1!==D?(o.bTransform=!0,0===I&&0===E&&(P=23,w=s+i,b=r+n,T=o.tx+h,S=o.ty+l,d=R*i+T,p=R*w+T,f=D*n+S,g=D*b+S)):(P=23,o.bTransform=!1,d=i+o.tx+h,p=d+s,f=n+o.ty+l,g=f+r),F&&(m=e.x,v=e.y,y=e.width+m,x=e.height+v),1!==P&&(d>=y||f>=x||m>=p||v>=g))return!1;var B=t._byteLength>>2;t.byteLength=B+16<<2;var k=t.getFloat32Array();switch(k[B+2]=a[0],k[B+3]=a[1],k[B+6]=a[2],k[B+7]=a[3],k[B+10]=a[4],k[B+11]=a[5],k[B+14]=a[6],k[B+15]=a[7],P){case 1:T=o.tx+h,S=o.ty+l,w=s+i,b=r+n;var O=i,N=n,W=R*O,U=E*N,V=D*N,H=I*O,z=R*w,G=E*b,Y=D*b,X=I*w;_?(C=W+U+T,A=Math.round(C)-C,M=V+H+S,L=Math.round(M)-M,k[B]=C+A,k[B+1]=M+L,k[B+4]=z+U+T+A,k[B+5]=V+X+S+L,k[B+8]=z+G+T+A,k[B+9]=Y+X+S+L,k[B+12]=W+G+T+A,k[B+13]=Y+H+S+L):(k[B]=W+U+T,k[B+1]=V+H+S,k[B+4]=z+U+T,k[B+5]=V+X+S,k[B+8]=z+G+T,k[B+9]=Y+X+S,k[B+12]=W+G+T,k[B+13]=Y+H+S);break;case 23:_?(C=d+u,A=Math.round(C)-C,M=f,L=Math.round(M)-M,k[B]=C+A,k[B+1]=M+L,k[B+4]=p+u+A,k[B+5]=f+L,k[B+8]=p+A,k[B+9]=g+L,k[B+12]=d+A,k[B+13]=g+L):(k[B]=d+u,k[B+1]=f,k[B+4]=p+u,k[B+5]=f,k[B+8]=p,k[B+9]=g,k[B+12]=d,k[B+13]=g)}return t._upload=!0,!0},t.fillLineVb=function(e,i,n,s,r,a,o,h){"use strict";var l=.5*o,u=t._fillLineArray,c=-(s-a),_=n-r,d=Math.sqrt(c*c+_*_);c/=d,_/=d,c*=l,_*=l,u[0]=n-c,u[1]=s-_,u[4]=n+c,u[5]=s+_,u[8]=r+c,u[9]=a+_,u[12]=r-c,u[13]=a-_,h&&h.transformPointArray(u,u);var f=(e._byteLength>>2)+16;return e.byteLength=f<<2,e.insertData(u,f-16),!0},t._fillLineArray=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],t}(),_t=(function(){function t(){}return s(t,"laya.webgl.utils.MatirxArray"),t.ArrayMul=function(e,i,n){if(!e)return void t.copyArray(i,n);if(!i)return void t.copyArray(e,n);for(var s=NaN,r=NaN,a=NaN,o=NaN,h=0;4>h;h++)s=e[h],r=e[h+4],a=e[h+8],o=e[h+12],n[h]=s*i[0]+r*i[1]+a*i[2]+o*i[3],n[h+4]=s*i[4]+r*i[5]+a*i[6]+o*i[7],n[h+8]=s*i[8]+r*i[9]+a*i[10]+o*i[11],n[h+12]=s*i[12]+r*i[13]+a*i[14]+o*i[15]},t.copyArray=function(t,e){if(t&&e)for(var i=0;i0&&i.push(e[n]);return i}function o(t){var i,n,s=0,o=0,h=0,l=new e(0,null,null,null),u=l,c=t.split("\n");for(s=0,o=c.length;o>s;s++){var _=c[s];if(_.indexOf("#ifdef")>=0)i=a(_),u=new e(1,i[1],"",u);else if(_.indexOf("#else")>=0)n=u.condition,u=new e(2,null,"",u.parent),u.condition=n;else if(_.indexOf("#endif")>=0)u=u.parent;else if(_.indexOf("#include")>=0){i=a(_);var d=i[1],f=d.charAt(0);'"'!==f&&"'"!==f||(d=d.substr(1,d.length-2),h=d.lastIndexOf(f),h>0&&(d=d.substr(0,h))),h=i[0].indexOf("?");var p=h>0?i[0].substr(h+1):i[0];new e(1,p,r[d],u)}else u.childs.length>0&&0===u.childs[u.childs.length-1].type?u.childs[u.childs.length-1].text+="\n"+_:new e(0,null,_,u)}return l}this._VSTXT=i,this._PSTXT=n,this._VS=o(i),this._PS=o(n),this._nameMap=s}var e;s(t,"laya.webgl.utils.ShaderCompile");var i=t.prototype;return i.createShader=function(t,e,i){var n={},s="";if(t)for(var r in t)s+="#define "+r+"\n",n[r]=!0;var a=this._VS.toscript(n,[]),o=this._PS.toscript(n,[]);return(i||Lt.create)(s+a.join("\n"),s+o.join("\n"),e,this._nameMap)},t.IFDEF_NO=0,t.IFDEF_YES=1,t.IFDEF_ELSE=2,t.__init$=function(){e=function(){function t(t,e,i,n){if(this.childs=new Array,this.type=t,this.text=i,this.parent=n,n&&n.childs.push(this),e){for(var s="",r=!1,a=!1,o=0,h=e.length;h>o;o++){var l=e.charAt(o);a="!&|() ".indexOf(l)<0,r!=a&&(a&&(s+="this."),r=a),s+=l}this.condition=C.createShaderCondition(s)}}s(t,"");var e=t.prototype;return e.toscript=function(t,e){if(0===this.type&&this.text&&e.push(this.text),this.childs.length<1&&!this.text)return e;if(0!==this.type){var i=!!this.condition.call(t);if(2===this.type&&(i=!i),!i)return e;this.text&&e.push(this.text)}return this.childs.length>0&&this.childs.forEach(function(i,n,s){i.toscript(t,e)}),e},t}()},t}(),ft=(function(){function t(){this._data=[],this._length=0,this._data._length=0}s(t,"laya.webgl.utils.ValusArray");var e=t.prototype;return e.pushValue=function(t,e){this.setValue(this._length,t,e),this._length+=2},e.setValue=function(t,e,i){this._data[t++]=e,this._data[t]=i},e.pushArray=function(t){for(var e=this._data,i=this._length,n=t._data,s=0,r=t.length;r>s;s++,i++)e[i++]=n[s++],e[i]=n[s];this._length=i},r(0,e,"data",function(){return this._data}),r(0,e,"length",function(){return this._length},function(t){this._length=t}),t}(),function(){function t(){}return s(t,"laya.webgl.WebGL"),t._float32ArraySlice=function(){for(var t=this,e=t.length,i=new Float32Array(t.length),n=0;e>n;n++)i[n]=t[n];return i},t._uint16ArraySlice=function(t){var e,i=arguments,n=this,s=0,r=0;if(0===i.length)for(s=n.length,e=new Uint16Array(s),r=0;s>r;r++)e[r]=n[r];else if(2===i.length){var a=i[0],o=i[1];if(o>a)for(s=o-a,e=new Uint16Array(s),r=a;o>r;r++)e[r-a]=n[r];else e=new Uint16Array(0)}return e},t.expandContext=function(){var t=d.prototype,e=CanvasRenderingContext2D.prototype;e.fillTrangles=t.fillTrangles,Ut.__int__(null),e.setIBVB=function(t,e,i,n,s,r,a,o,h,l){void 0===h&&(h=0),void 0===l&&(l=0),null===i&&(this._ib=this._ib||Ht.QuadrangleIB,i=this._ib,ct.expandIBQuadrangle(i,n.byteLength/64+8)),this._setIBVB(t,e,i,n,s,r,a,o,h,l)},e.fillTrangles=function(t,e,i,n,s){this._curMat=this._curMat||v.create(),this._vb=this._vb||zt.create(),this._ib||(this._ib=Ht.create(),ct.fillIBQuadrangle(this._ib,a/4));var r=this._vb,a=n.length>>4;ct.fillTranglesVB(r,e,i,n,s||this._curMat,0,0),ct.expandIBQuadrangle(this._ib,r.byteLength/64+8);var o=new vt(1,0);o.textureHost=t;var h=new Wt("attribute vec2 position; attribute vec2 texcoord; uniform vec2 size; uniform mat4 mmat; varying vec2 v_texcoord; void main() { vec4 p=vec4(position.xy,0.0,1.0);vec4 pos=mmat*p; gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0); v_texcoord = texcoord; }","precision mediump float; varying vec2 v_texcoord; uniform sampler2D texture; void main() {vec4 color= texture2D(texture, v_texcoord); color.a*=1.0; gl_FragColor= color;}");r._vertType=3,this._setIBVB(e,i,this._ib,r,6*a,s,h,o,0,0)}},t.enable=function(){if(w.isConchApp&&!w.isConchWebGL)return C.skinAniSprite=function(){var t=new q;return t},t.expandContext(),!1;if(!t.isWebGLSupported())return!1;if(w.isWebGL)return!0;m.create=function(t,e){return new Gt(t,e)},w.WebGL=t,w.isWebGL=!0,ot.__init__(),C.createRenderSprite=function(t,e){return new yt(t,e)},C.createWebGLContext2D=function(t){return new mt(t)},C.changeWebGLSize=function(t,e){laya.webgl.WebGL.onStageResize(t,e)},C.createGraphics=function(){return new gt};var e=C.createFilterAction;return C.createFilterAction=e?e:function(t){return new xt},C.clear=function(t){if(_t.worldScissorTest&&laya.webgl.WebGL.mainContext.disable(3089),null==t)w.context.ctx.clearBG(0,0,0,0);else{var e=c.create(t)._color;w.context.ctx.clearBG(e[0],e[1],e[2],e[3])}_t.clear()},C.addToAtlas=function(t,e){void 0===e&&(e=!1);var n=t.bitmap;return w.optimizeTextureMemory(t.url,t)?void(i.__typeof(n,"laya.webgl.resource.IMergeAtlasBitmap")&&n.allowMerageInAtlas&&n.on("recovered",t,t.addTextureToAtlas)):void(n.enableMerageInAtlas=!1)},O._enable(),C.beginFlush=function(){for(var t=O.instance,e=t.getAtlaserCount(),i=0;e>i;i++){var n=t.getAtlaserByIndex(i).texture;n._flashCacheImageNeedFlush&&C.flashFlushImage(n)}},C.drawToCanvas=function(t,e,i,n,s,r){var a=new Pt(i,n,6408,5121,0,!1);a.start(),a.clear(1,0,0,1),t.render(w.context,-s,_t.height-n-r),w.context.flush(),a.end();var o=a.getData(0,0,a.width,a.height);return a.dispose(),o},C.createFilterAction=function(t){var e;switch(t){case 32:e=new xt}return e},C.addTextureToAtlas=function(t){t._uvID++,O._atlasRestore++,t.bitmap.enableMerageInAtlas&&O.instance.addToAtlas(t)},C.getTexturePixels=function(t,e,i,n,s){w.context.ctx.clear();var r=new M;r.graphics.drawTexture(t,-e,-i);var a=Pt.create(n,s);a.start(),a.clear(0,0,0,0),r.render(w.context,0,0),w.context.ctx.flush(),a.end();for(var o=a.getData(0,0,n,s),h=[],l=0,u=s-1;u>=0;u--)for(var c=0;n>c;c++)l=4*(u*n+c),h.push(o[l]),h.push(o[l+1]),h.push(o[l+2]),h.push(o[l+3]);return h},C.skinAniSprite=function(){var t=new q;return t},f._filterStart=function(t,e,i,n,s){var r=t.getValue("bounds"),a=Pt.create(r.width,r.height);if(a.start(),a.clear(0,0,0,0),t.addValue("src",a),t.addValue("ScissorTest",_t.worldScissorTest),_t.worldScissorTest){var o=new x;o.copyFrom(i.ctx._clipRect),t.addValue("clipRect",o),_t.worldScissorTest=!1,laya.webgl.WebGL.mainContext.disable(3089)}},f._filterEnd=function(t,e,i,n,s){var r=t.getValue("bounds"),a=t.getValue("src");a.end();var o=Pt.create(r.width,r.height);o.start(),o.clear(0,0,0,0),t.addValue("out",o),e._set$P("_filterCache",o),e._set$P("_isHaveGlowFilter",t.getValue("_isHaveGlowFilter"))},f._EndTarget=function(t,e){var i=t.getValue("src");i.recycle();var n=t.getValue("out");n.end();var s=t.getValue("ScissorTest");if(s){_t.worldScissorTest=!0,laya.webgl.WebGL.mainContext.enable(3089),e.ctx.save();var r=t.getValue("clipRect");e.ctx.clipRect(r.x,r.y,r.width,r.height)}},f._useSrc=function(t){var e=t.getValue("out");e.end(),e=t.getValue("src"),e.start(),e.clear(0,0,0,0)},f._endSrc=function(t){var e=t.getValue("src");e.end()},f._useOut=function(t){var e=t.getValue("src");e.end(),e=t.getValue("out"),e.start(),e.clear(0,0,0,0)},f._endOut=function(t){var e=t.getValue("out");e.end()},f._recycleScope=function(t){t.recycle()},f._filter=function(t,e,i,n){var s=this._next;if(s){var r=t.filters,a=r.length;if(1==a&&32==r[0].type)return e.ctx.save(),e.ctx.setFilters([r[0]]),s._fun.call(s,t,e,i,n),void e.ctx.restore();var o,h,l=et.create(),u=y.TEMP,c=e.ctx._getTransformMatrix(),_=v.create();c.copyTo(_);var d=0,p=0,g=!1,m=t._$P._filterCache?t._$P._filterCache:null;if(!m||t._repaint){g=t._isHaveGlowFilter(),l.addValue("_isHaveGlowFilter",g),g&&(d=50,p=25),h=new x,h.copyFrom(t.getBounds());var w=h.x,b=h.y;if(h.width+=d,h.height+=d,u.x=h.x*_.a+h.y*_.c,u.y=h.y*_.d+h.x*_.b,h.x=u.x,h.y=u.y,u.x=h.width*_.a+h.height*_.c,u.y=h.height*_.d+h.width*_.b,h.width=u.x,h.height=u.y,h.width<=0||h.height<=0)return;m&&m.recycle(),l.addValue("bounds",h);var T=tt.create([l,t,e,0,0],f._filterStart);e.addRenderObject(T),e.ctx._renderKey=0,e.ctx._shader2D.glTexture=null;var S=t.x-w+p,C=t.y-b+p;s._fun.call(s,t,e,S,C),T=tt.create([l,t,e,0,0],f._filterEnd),e.addRenderObject(T);for(var M=0;a>M;M++){0!=M&&(T=tt.create([l],f._useSrc),e.addRenderObject(T),o=vt.create(1,0),v.TEMP.identity(),e.ctx.drawTarget(l,0,0,h.width,h.height,v.TEMP,"out",o,null,W.TOINT.overlay),T=tt.create([l],f._useOut),e.addRenderObject(T));var A=r[M];A.action.apply3d(l,t,e,0,0)}T=tt.create([l,e],f._EndTarget),e.addRenderObject(T)}else{if(g=t._$P._isHaveGlowFilter?t._$P._isHaveGlowFilter:!1,g&&(d=50,p=25),h=t.getBounds(),h.width<=0||h.height<=0)return;h.width+=d,h.height+=d,u.x=h.x*_.a+h.y*_.c,u.y=h.y*_.d+h.x*_.b,h.x=u.x,h.y=u.y,u.x=h.width*_.a+h.height*_.c,u.y=h.height*_.d+h.width*_.b,h.width=u.x,h.height=u.y,l.addValue("out",m)}i=i-p-t.x,n=n-p-t.y,u.setTo(i,n),_.transformPoint(u),i=u.x+h.x,n=u.y+h.y,o=vt.create(1,0),v.TEMP.identity(),e.ctx.drawTarget(l,i,n,h.width,h.height,v.TEMP,"out",o,null,W.TOINT.overlay),T=tt.create([l],f._recycleScope),e.addRenderObject(T),_.destroy()}},Float32Array.prototype.slice||(Float32Array.prototype.slice=t._float32ArraySlice),Uint16Array.prototype.slice||(Uint16Array.prototype.slice=t._uint16ArraySlice),!0},t.isWebGLSupported=function(){for(var t,e=u.createElement("canvas"),i=["webgl","experimental-webgl","webkit-3d","moz-webgl"],n=0;nt;t++)this._submits[t].releaseRender();this._submits._length=0,this._curMat.identity(),this._other.clear(),this._saveMark=this._save[0],this._save._length=1},o.size=function(t,e){this._width=t,this._height=e,this._targets&&this._targets.size(t,e)},o._getTransformMatrix=function(){return this._curMat},o.translate=function(t,e){0===t&&0===e||(X.save(this),this._curMat.bTransform&&(Y.save(this),this._curMat.transformPoint(y.TEMP.setTo(t,e)),t=y.TEMP.x,e=y.TEMP.y),this._x+=t,this._y+=e)},o.save=function(){this._save[this._save._length++]=G.Create(this)},o.restore=function(){var t=this._save._length;if(!(1>t))for(var e=t-1;e>=0;e--){var i=this._save[e];if(i.restore(this),i.isSaveMark())return void(this._save._length=e)}},o.measureText=function(t){return C.measureText(t,this._other.font.toString())},o._fillText=function(t,e,i,n,s,r,a){var o=this._shader2D,h=this._curSubmit.shaderValue,l=s?lt.create(s):this._other.font;if(O.enabled)o.ALPHA!==h.ALPHA&&(o.glTexture=null),ot.drawText(this,t,e,this._curMat,l,a||this._other.textAlign,r,null,-1,i,n);else{var u=(this._shader2D.defines.getValue(),r?c.create(r)._color:o.colorAdd);o.ALPHA===h.ALPHA&&u===o.colorAdd&&h.colorAdd===o.colorAdd||(o.glTexture=null,o.colorAdd=u),ot.drawText(this,t,e,this._curMat,l,a||this._other.textAlign,r,null,-1,i,n)}},o.fillWords=function(t,e,i,n,s){t.length>0&&this._fillText(null,t,e,i,n,s,null)},o.fillText=function(t,e,i,n,s,r){t.length>0&&this._fillText(t,null,e,i,n,s,r)},o.strokeText=function(t,i,n,s,r,a,o){if(0!==t.length){var h=this._shader2D,l=this._curSubmit.shaderValue,u=s?(e._fontTemp.setFont(s),e._fontTemp):this._other.font;if(O.enabled)h.ALPHA!==l.ALPHA&&(h.glTexture=null),ot.drawText(this,t,null,this._curMat,u,o||this._other.textAlign,null,r,a||1,i,n);else{var _=(this._shader2D.defines.getValue(),r?c.create(r)._color:h.colorAdd);h.ALPHA===l.ALPHA&&_===h.colorAdd&&l.colorAdd===h.colorAdd||(h.glTexture=null,h.colorAdd=_),ot.drawText(this,t,null,this._curMat,u,o||this._other.textAlign,null,r,a||1,i,n)}}},o.fillBorderText=function(t,i,n,s,r,a,o,h){if(0!==t.length){if(!O.enabled)return this.strokeText(t,i,n,s,a,o,h),void this.fillText(t,i,n,s,r,h);var l=this._shader2D,u=this._curSubmit.shaderValue;l.ALPHA!==u.ALPHA&&(l.glTexture=null);var c=s?(e._fontTemp.setFont(s),e._fontTemp):this._other.font;ot.drawText(this,t,null,this._curMat,c,h||this._other.textAlign,r,a,o||1,i,n)}},o.fillRect=function(t,e,i,n,s){var r=this._vb;if(ct.fillRectImgVb(r,this._clipRect,t,e,i,n,R.DEF_UV,this._curMat,this._x,this._y,0,0)){this._renderKey=0;var a=this._shader2D.fillStyle;s&&(this._shader2D.fillStyle=U.create(s));var o=this._shader2D,h=this._curSubmit.shaderValue;if(o.fillStyle!==h.fillStyle||o.ALPHA!==h.ALPHA){o.glTexture=null;var l=this._curSubmit=J.create(this,this._ib,r,(r._byteLength-64)/32*3,vt.create(2,0));l.shaderValue.color=o.fillStyle._color._color,l.shaderValue.ALPHA=o.ALPHA,this._submits[this._submits._length++]=l}this._curSubmit._numEle+=6,this._shader2D.fillStyle=a}},o.fillTexture=function(t,e,i,n,s,r,a,o){var h=this._vb,l=t.bitmap.width,u=t.bitmap.height,c=t.uv;if(l!=o.w||u!=o.h){switch(r){case"repeat":o.width=n,o.height=s;break;case"repeat-x":o.width=n,o.height=t.height>s?s:t.height;break;case"repeat-y":o.width=t.width>n?n:t.width,o.height=s;break;default:o.width=n,o.height=s}o.w=l,o.h=u,o.uv=[0,0,o.width/l,0,o.width/l,o.height/u,0,o.height/u]}if(ct.fillRectImgVb(h,this._clipRect,e,i,o.width,o.height,o.uv,this._curMat,this._x,this._y,0,0)){ +this._renderKey=0;var _=this._curSubmit=J.create(this,this._ib,h,(h._byteLength-64)/32*3,vt.create(256,0));this._submits[this._submits._length++]=_;var d=_.shaderValue;d.textureHost=t;var f=c[0]*l,p=c[1]*u,g=(c[2]-c[0])*l,m=(c[5]-c[3])*u,v=-a.x/l,y=-a.y/u;d.u_TexRange[0]=f/l,d.u_TexRange[1]=g/l,d.u_TexRange[2]=p/u,d.u_TexRange[3]=m/u,d.u_offset[0]=v,d.u_offset[1]=y,_._renderType=10016,this._curSubmit._numEle+=6}},o.setShader=function(t){H.save(this,524288,this._shader2D,!0),this._shader2D.shader=t},o.setFilters=function(t){H.save(this,1048576,this._shader2D,!0),this._shader2D.filters=t,this._curSubmit=J.RENDERBASE,this._renderKey=0,this._drawCount++},o.drawTexture=function(t,e,i,n,s,r,a){this._drawTextureM(t,e,i,n,s,r,a,null,1)},o.addTextureVb=function(t,e,i){var n=this._curSubmit._vb||this._vb,s=n._byteLength>>2;n.byteLength=s+16<<2;for(var r=n.getFloat32Array(),a=0;16>a;a+=4)r[s++]=t[a]+e,r[s++]=t[a+1]+i,r[s++]=t[a+2],r[s++]=t[a+3];this._curSubmit._numEle+=6,this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle),n._upload=!0},o.willDrawTexture=function(t,e){if(!(t.loaded&&t.bitmap&&t.source))return this.sprite&&i.timer.callLater(this,this._repaintSprite),0;var n=t.bitmap,s=n.id+this._shader2D.ALPHA*e+10016;if(s==this._renderKey)return s;var r=this._shader2D,a=r.ALPHA,o=this._curSubmit.shaderValue;r.ALPHA*=e,this._renderKey=s,this._drawCount++,r.glTexture=n;var h=this._vb,l=null,u=h._byteLength/32*3;return l=At.create(this,this._ib,h,u,vt.create(1,0)),this._submits[this._submits._length++]=l,l.shaderValue.textureHost=t,l._renderType=10016,l._preIsSameTextureShader=10016===this._curSubmit._renderType&&r.ALPHA===o.ALPHA,this._curSubmit=l,r.ALPHA=a,s},o.drawTextures=function(t,n,s,r){if(!(t.loaded&&t.bitmap&&t.source))return void(this.sprite&&i.timer.callLater(this,this._repaintSprite));var a=this._clipRect;if(this._clipRect=e.MAXCLIPRECT,!this._drawTextureM(t,n[0],n[1],t.width,t.height,s,r,null,1))return void alert("drawTextures err");if(this._clipRect=a,A.drawCall+=n.length/2,!(n.length<4)){for(var o=this._curSubmit._vb||this._vb,h=this._curMat.a,l=this._curMat.d,u=2,c=n.length;c>u;u+=2)ct.copyPreImgVb(o,(n[u]-n[u-2])*h,(n[u+1]-n[u-1])*l),this._curSubmit._numEle+=6;this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle)}},o._drawTextureM=function(t,e,n,s,r,a,o,h,l){if(!(t.loaded&&t.bitmap&&t.source))return this.sprite&&i.timer.callLater(this,this._repaintSprite),!1;var u=this._curSubmit._vb||this._vb,c=t.bitmap;e+=a,n+=o,this._drawCount++;var _=c.id+this._shader2D.ALPHA*l+10016;if(_!=this._renderKey){this._renderKey=_;var d=this._curSubmit.shaderValue,f=this._shader2D,p=f.ALPHA;f.ALPHA*=l,f.glTexture=c;var g=this._vb,m=null,v=g._byteLength/32*3;m=At.create(this,this._ib,g,v,vt.create(1,0)),this._submits[this._submits._length++]=m,m.shaderValue.textureHost=t,m._renderType=10016,m._preIsSameTextureShader=10016===this._curSubmit._renderType&&f.ALPHA===d.ALPHA,this._curSubmit=m,u=this._curSubmit._vb||this._vb,f.ALPHA=p}return ct.fillRectImgVb(u,this._clipRect,e,n,s||t.width,r||t.height,t.uv,h||this._curMat,this._x,this._y,0,0)?(O.enabled&&!this._isMain&&this._curSubmit.addTexture(t,(u._byteLength>>2)-16),this._curSubmit._numEle+=6,this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle),!0):!1},o._repaintSprite=function(){this.sprite.repaint()},o._drawText=function(t,e,i,n,s,r,a,o,h,l){var u=t.bitmap;this._drawCount++;var c=u.id+this._shader2D.ALPHA+10016;if(c!=this._renderKey){this._renderKey=c;var _=this._curSubmit.shaderValue,d=this._shader2D;d.glTexture=u;var f=this._vb,p=null,g=f._byteLength/32*3;p=O.enabled?At.create(this,this._ib,f,g,vt.create(1,0)):At.create(this,this._ib,f,g,Vt.create()),p._preIsSameTextureShader=10016===this._curSubmit._renderType&&d.ALPHA===_.ALPHA,this._submits[this._submits._length++]=p,p.shaderValue.textureHost=t,p._renderType=10016,this._curSubmit=p}t.active();var m=this._curSubmit._vb||this._vb;ct.fillRectImgVb(m,this._clipRect,e+a,i+o,n||t.width,s||t.height,t.uv,r||this._curMat,this._x,this._y,h,l,!0)&&(O.enabled&&!this._isMain&&this._curSubmit.addTexture(t,(m._byteLength>>2)-16),this._curSubmit._numEle+=6,this._maxNumEle=Math.max(this._maxNumEle,this._curSubmit._numEle))},o.drawTextureWithTransform=function(t,i,n,s,r,a,o,h,l){var u=this._curMat;(0!==o||0!==h)&&(this._x=o*u.a+h*u.c,this._y=h*u.d+o*u.b),a&&u.bTransform?(v.mul(a,u,e._tmpMatrix),a=e._tmpMatrix,a._checkTransform()):(this._x+=u.tx,this._y+=u.ty),this._drawTextureM(t,i,n,s,r,0,0,a,l),this._x=this._y=0},o.fillQuadrangle=function(t,e,i,n,s){var r=this._curSubmit,a=this._vb,o=this._shader2D,h=r.shaderValue;if(this._renderKey=0,t.bitmap){var l=t.bitmap;o.glTexture==l&&o.ALPHA===h.ALPHA||(o.glTexture=l,r=this._curSubmit=J.create(this,this._ib,a,a._byteLength/32*3,vt.create(1,0)),r.shaderValue.glTexture=l,this._submits[this._submits._length++]=r),ct.fillQuadrangleImgVb(a,e,i,n,t.uv,s||this._curMat,this._x,this._y)}else r.shaderValue.fillStyle&&r.shaderValue.fillStyle.equal(t)&&o.ALPHA===h.ALPHA||(o.glTexture=null,r=this._curSubmit=J.create(this,this._ib,a,a._byteLength/32*3,vt.create(2,0)),r.shaderValue.defines.add(2),r.shaderValue.fillStyle=U.create(t),this._submits[this._submits._length++]=r),ct.fillQuadrangleImgVb(a,e,i,n,R.DEF_UV,s||this._curMat,this._x,this._y);r._numEle+=6},o.drawTexture2=function(t,i,n,s,r,a,o,h){var l=this._curMat;if(this._x=t*l.a+i*l.c,this._y=i*l.d+t*l.b,r&&(l.bTransform||r.bTransform?(v.mul(r,l,e._tmpMatrix),r=e._tmpMatrix):(this._x+=r.tx+l.tx,this._y+=r.ty+l.ty,r=v.EMPTY)),1!==a||o){var u=this._shader2D.ALPHA,c=this._nBlendType;this._shader2D.ALPHA=a,o&&(this._nBlendType=W.TOINT(o)),this._drawTextureM(h[0],h[1]-n,h[2]-s,h[3],h[4],0,0,r,1),this._shader2D.ALPHA=u,this._nBlendType=c}else this._drawTextureM(h[0],h[1]-n,h[2]-s,h[3],h[4],0,0,r,1);this._x=this._y=0},o.drawCanvas=function(t,e,i,n,s){var r=t.context;if(this._renderKey=0,r._targets)this._submits[this._submits._length++]=Mt.create(r,0,null),this._curSubmit=J.RENDERBASE,r._targets.drawTo(this,e,i,n,s);else{var a=this._submits[this._submits._length++]=Mt.create(r,this._shader2D.ALPHA,this._shader2D.filters),o=n/t.width,h=s/t.height,l=a._matrix;this._curMat.copyTo(l),1!=o&&1!=h&&l.scale(o,h);var u=l.tx,c=l.ty;l.tx=l.ty=0,l.transformPoint(y.TEMP.setTo(e,i)),l.translate(y.TEMP.x+u,y.TEMP.y+c),this._curSubmit=J.RENDERBASE}_.showCanvasMark&&(this.save(),this.lineWidth=4,this.strokeStyle=r._targets?"yellow":"green",this.strokeRect(e-1,i-1,n+2,s+2,1),this.strokeRect(e,i,n,s,1),this.restore())},o.drawTarget=function(t,e,i,n,s,r,a,o,h,l){void 0===l&&(l=-1);var u=this._vb;if(ct.fillRectImgVb(u,this._clipRect,e,i,n,s,h||R.DEF_UV,r||this._curMat,this._x,this._y,0,0)){this._renderKey=0;var c=this._shader2D;c.glTexture=null;var _=(this._curSubmit.shaderValue,this._curSubmit=rt.create(this,this._ib,u,(u._byteLength-64)/32*3,o,a));-1==l?_.blendType=this._nBlendType:_.blendType=l,_.scope=t,this._submits[this._submits._length++]=_,this._curSubmit._numEle+=6}},o.transform=function(t,e,i,n,s,r){Y.save(this),v.mul(v.TEMP.setTo(t,e,i,n,s,r),this._curMat,this._curMat),this._curMat._checkTransform()},o.setTransformByMatrix=function(t){t.copyTo(this._curMat)},o.transformByMatrix=function(t){Y.save(this),v.mul(t,this._curMat,this._curMat),this._curMat._checkTransform()},o.rotate=function(t){Y.save(this),this._curMat.rotateEx(t)},o.scale=function(t,e){Y.save(this),this._curMat.scaleEx(t,e)},o.clipRect=function(t,e,i,n){i*=this._curMat.a,n*=this._curMat.d;var s=y.TEMP;this._curMat.transformPoint(s.setTo(t,e)),this._renderKey=0;var r=this._curSubmit=nt.create(this);this._submits[this._submits._length++]=r,r.submitIndex=this._submits._length,r.submitLength=9999999,z.save(this,r);var a=this._clipRect,o=a.x,h=a.y,l=s.x+i,u=s.y+n;o>4,u=t.bitmap;this._renderKey=0,o.glTexture==u&&o.ALPHA===h.ALPHA||(r=this._curSubmit=J.create(this,this._ib,a,a._byteLength/32*3,vt.create(1,0)),r.shaderValue.textureHost=t,this._submits[this._submits._length++]=r),ct.fillTranglesVB(a,e,i,n,s||this._curMat,this._x,this._y),r._numEle+=6*l},o.submitElement=function(t,e){var i=this._submits;for(0>e&&(e=i._length);e>t;)t+=i[t].renderSubmit()},o.finish=function(){ft.mainContext.finish()},o.flush=function(){var t=Math.max(this._vb.byteLength/64,this._maxNumEle/6)+8;if(t>this._ib.bufferLength/12&&ct.expandIBQuadrangle(this._ib,t),!this._isMain&&O.enabled&&O._atlasRestore>this._atlasResourceChange){this._atlasResourceChange=O._atlasRestore;for(var e=this._submits,i=0,n=e._length;n>i;i++){var s=e[i];10016===s.getRenderType()&&s.checkTexture()}}return this.submitElement(0,this._submits._length),this._path&&this._path.reset(),Q.instance&&Q.getInstance().reset(),this._curSubmit=J.RENDERBASE,this._renderKey=0,this._submits._length},o.setPathId=function(t){if(this.mId=t,-1!=this.mId){this.mHaveKey=!1;var e=E.getInstance();e.shapeDic[this.mId]&&(this.mHaveKey=!0),this.mHaveLineKey=!1,e.shapeLineDic[this.mId]&&(this.mHaveLineKey=!0)}},o.movePath=function(t,e){this.mX+=t,this.mY+=e},o.beginPath=function(){var t=this._getPath();t.tempArray.length=0,t.closePath=!1,this.mX=0,this.mY=0},o.closePath=function(){this._path.closePath=!0},o.fill=function(t){void 0===t&&(t=!1);var e=this._getPath();this.drawPoly(0,0,e.tempArray,this.fillStyle._color.numColor,0,0,t)},o.stroke=function(){var t=this._getPath();if(this.lineWidth>0){if(-1==this.mId)t.drawLine(0,0,t.tempArray,this.lineWidth,this.strokeStyle._color.numColor);else if(this.mHaveLineKey){var e=E.getInstance().shapeLineDic[this.mId];t.setGeomtry(e)}else E.getInstance().addLine(this.mId,t.drawLine(0,0,t.tempArray,this.lineWidth,this.strokeStyle._color.numColor));t.update();var i=_t.getMatrArray();_t.mat2MatArray(this._curMat,i);var n=[this.mX,this.mY],s=J.createShape(this,t.ib,t.vb,t.count,t.offset,vt.create(4,0));s.shaderValue.ALPHA=this._shader2D.ALPHA,s.shaderValue.u_pos=n,s.shaderValue.u_mmat2=i,this._submits[this._submits._length++]=s}},o.line=function(t,e,i,n,s,r){var a=this._curSubmit,o=this._vb;if(ct.fillLineVb(o,this._clipRect,t,e,i,n,s,r)){this._renderKey=0;var h=this._shader2D,l=a.shaderValue;h.strokeStyle===l.strokeStyle&&h.ALPHA===l.ALPHA||(h.glTexture=null,a=this._curSubmit=J.create(this,this._ib,o,(o._byteLength-64)/32*3,vt.create(2,0)),a.shaderValue.strokeStyle=h.strokeStyle,a.shaderValue.mainID=2,a.shaderValue.ALPHA=h.ALPHA,this._submits[this._submits._length++]=a),a._numEle+=6}},o.moveTo=function(t,e){var i=this._getPath();i.addPoint(t,e)},o.lineTo=function(t,e){var i=this._getPath();i.addPoint(t,e)},o.arcTo=function(t,e,i,n,s){if(-1==this.mId||!this.mHaveKey){var r=this._getPath(),a=r.getEndPointX(),o=r.getEndPointY(),h=NaN,l=NaN,u=NaN,c=NaN,_=NaN,d=NaN,f=NaN,p=NaN,g=NaN,m=NaN,v=!1;h=a-t,l=o-e,u=i-t,c=n-e,y.TEMP.setTo(h,l),y.TEMP.normalize(),h=y.TEMP.x,l=y.TEMP.y,y.TEMP.setTo(u,c),y.TEMP.normalize(),u=y.TEMP.x,c=y.TEMP.y,_=Math.acos(h*u+l*c);var x=Math.tan(_/2);if(d=s/x,d>1e4)return void this.lineTo(t,e);0>=h*c-u*l?(f=t+h*d+l*s,p=e+l*d-h*s,g=Math.atan2(h,-l),m=Math.atan2(-u,c),v=!1):(f=t+h*d-l*s,p=e+l*d+h*s,g=Math.atan2(-h,l),m=Math.atan2(u,-c),v=!0),this.arc(f,p,s,g,m,v)}},o.arc=function(t,e,i,n,s,r){if(void 0===r&&(r=!1),-1!=this.mId){if(this.mHaveKey)return;t=0,e=0}var a=0,o=0,h=0,l=0,u=0,c=0,_=0,d=0,f=0,p=0,g=0;if(o=s-n,r)if(Math.abs(o)>=2*Math.PI)o=2*-Math.PI;else for(;o>0;)o-=2*Math.PI;else if(Math.abs(o)>=2*Math.PI)o=2*Math.PI;else for(;0>o;)o+=2*Math.PI;p=101>i?Math.max(10,o*i/5):201>i?Math.max(10,o*i/20):Math.max(10,o*i/40),h=o/p/2,l=Math.abs(4/3*(1-Math.cos(h))/Math.sin(h)),r&&(l=-l),g=0;var m=this._getPath();for(f=0;p>=f;f++)a=n+o*(f/p),u=Math.cos(a),c=Math.sin(a),_=t+u*i,d=e+c*i,_==this._path.getEndPointX()&&d==this._path.getEndPointY()||m.addPoint(_,d);u=Math.cos(s),c=Math.sin(s),_=t+u*i,d=e+c*i,_==this._path.getEndPointX()&&d==this._path.getEndPointY()||m.addPoint(_,d)},o.quadraticCurveTo=function(t,e,i,n){for(var s=h.I,r=s.getBezierPoints([this._path.getEndPointX(),this._path.getEndPointY(),t,e,i,n],30,2),a=0,o=r.length/2;o>a;a++)this.lineTo(r[2*a],r[2*a+1]);this.lineTo(i,n)},o.rect=function(t,e,i,n){this._other=this._other.make(),this._other.path||(this._other.path=new V),this._other.path.rect(t,e,i,n)},o.strokeRect=function(t,e,i,n,s){var r=.5*s;this.line(t-r,e,t+i+r,e,s,this._curMat),this.line(t+i,e,t+i,e+n,s,this._curMat),this.line(t,e,t,e+n,s,this._curMat),this.line(t-r,e+n,t+i+r,e+n,s,this._curMat)},o.clip=function(){},o.drawPoly=function(t,e,i,n,s,r,a){void 0===a&&(a=!1),this._renderKey=0,this._shader2D.glTexture=null;var o=this._getPath();if(-1==this.mId)o.polygon(t,e,i,n,s?s:1,r);else if(this.mHaveKey){var h=E.getInstance().shapeDic[this.mId];o.setGeomtry(h)}else E.getInstance().addShape(this.mId,o.polygon(t,e,i,n,s?s:1,r));o.update();var l=[this.mX,this.mY],u=_t.getMatrArray();_t.mat2MatArray(this._curMat,u);var c;if(!a){var _=st.create(4);this.addRenderObject(_),c=J.createShape(this,o.ib,o.vb,o.count,o.offset,vt.create(4,0)),c.shaderValue.ALPHA=this._shader2D.ALPHA,c.shaderValue.u_pos=l,c.shaderValue.u_mmat2=u,this._submits[this._submits._length++]=c,_=st.create(5),this.addRenderObject(_)}if(c=J.createShape(this,o.ib,o.vb,o.count,o.offset,vt.create(4,0)),c.shaderValue.ALPHA=this._shader2D.ALPHA,c.shaderValue.u_pos=l,c.shaderValue.u_mmat2=u,this._submits[this._submits._length++]=c,a||(_=st.create(3),this.addRenderObject(_)),s>0){if(this.mHaveLineKey){var d=E.getInstance().shapeLineDic[this.mId];o.setGeomtry(d)}else E.getInstance().addShape(this.mId,o.drawLine(t,e,i,s,r));o.update(),c=J.createShape(this,o.ib,o.vb,o.count,o.offset,vt.create(4,0)),c.shaderValue.ALPHA=this._shader2D.ALPHA,c.shaderValue.u_mmat2=u,this._submits[this._submits._length++]=c}},o.drawParticle=function(t,e,i){i.x=t,i.y=e,this._submits[this._submits._length++]=i},o._getPath=function(){return this._path||(this._path=new V)},r(0,o,"globalCompositeOperation",function(){return W.NAMES[this._nBlendType]},function(t){var e=W.TOINT[t];null==e||this._nBlendType===e||(H.save(this,65536,this,!0),this._curSubmit=J.RENDERBASE,this._renderKey=0,this._nBlendType=e)}),r(0,o,"strokeStyle",function(){return this._shader2D.strokeStyle},function(t){this._shader2D.strokeStyle.equal(t)||(H.save(this,512,this._shader2D,!1),this._shader2D.strokeStyle=U.create(t))}),r(0,o,"globalAlpha",function(){return this._shader2D.ALPHA},function(t){t=Math.floor(1e3*t)/1e3,t!=this._shader2D.ALPHA&&(H.save(this,1,this._shader2D,!0),this._shader2D.ALPHA=t)}),r(0,o,"asBitmap",null,function(t){if(t){if(this._targets||(this._targets=new $),this._targets.repaint=!0,!this._width||!this._height)throw Error("asBitmap no size!");this._targets.size(this._width,this._height)}else this._targets=null}),r(0,o,"fillStyle",function(){return this._shader2D.fillStyle},function(t){this._shader2D.fillStyle.equal(t)||(H.save(this,2,this._shader2D,!1),this._shader2D.fillStyle=U.create(t))}),r(0,o,"textAlign",function(){return this._other.textAlign},function(t){this._other.textAlign===t||(this._other=this._other.make(),H.save(this,32768,this._other,!1),this._other.textAlign=t)}),r(0,o,"lineWidth",function(){return this._other.lineWidth},function(t){this._other.lineWidth===t||(this._other=this._other.make(),H.save(this,256,this._other,!1),this._other.lineWidth=t)}),r(0,o,"textBaseline",function(){return this._other.textBaseline},function(t){this._other.textBaseline===t||(this._other=this._other.make(),H.save(this,16384,this._other,!1),this._other.textBaseline=t)}),r(0,o,"font",null,function(t){t!=this._other.font.toString()&&(this._other=this._other.make(),H.save(this,8,this._other,!1),this._other.font===lt.EMPTY?this._other.font=new lt(t):this._other.font.setFont(t))}),e.__init__=function(){a.DEFAULT=new a},e._SUBMITVBSIZE=32e3,e._MAXSIZE=99999999,e._RECTVBSIZE=16,e.MAXCLIPRECT=new x(0,0,99999999,99999999),e._COUNT=0,e._tmpMatrix=new v,n(e,["_fontTemp",function(){return this._fontTemp=new lt},"_drawStyleTemp",function(){return this._drawStyleTemp=new U(null)}]),e.__init$=function(){a=function(){function t(){this.lineWidth=1,this.path=null,this.textAlign=null,this.textBaseline=null,this.font=lt.EMPTY}s(t,"");var e=t.prototype;return e.clear=function(){this.lineWidth=1,this.path&&this.path.clear(),this.textAlign=this.textBaseline=null,this.font=lt.EMPTY},e.make=function(){return this===t.DEFAULT?new t:this},t.DEFAULT=null,t}()},e}(d),vt=function(t){function e(t,i){this.size=[0,0],this.alpha=1,this.ALPHA=1,this.subID=0,this._cacheID=0,e.__super.call(this),this.defines=new bt,this.position=e._POSITION,this.mainID=t,this.subID=i,this.textureHost=null,this.texture=null,this.fillStyle=null,this.color=null,this.strokeStyle=null,this.colorAdd=null,this.glTexture=null,this.u_mmat2=null,this._cacheID=t|i,this._inClassCache=e._cache[this._cacheID],t>0&&!this._inClassCache&&(this._inClassCache=e._cache[this._cacheID]=[],this._inClassCache._length=0),this.clear()}s(e,"laya.webgl.shader.d2.value.Value2D",t);var i=e.prototype;return i.setValue=function(t){},i.refresh=function(){var t=this.size;return t[0]=_t.width,t[1]=_t.height,this.alpha=this.ALPHA*_t.worldAlpha,this.mmat=_t.worldMatrix4,this},i._ShaderWithCompile=function(){return Lt.withCompile2D(0,this.mainID,this.defines.toNameDic(),this.mainID|this.defines._value,Wt.create)},i._withWorldShaderDefines=function(){var t=_t.worldShaderDefines,e=Lt.sharders[this.mainID|this.defines._value|t.getValue()];if(!e){var i,n,s={};i=this.defines.toNameDic();for(n in i)s[n]="";i=t.toNameDic();for(n in i)s[n]="";e=Lt.withCompile2D(0,this.mainID,s,this.mainID|this.defines._value|t.getValue(),Wt.create)}var r=_t.worldFilters;if(!r)return e;for(var a,o=r.length,h=0;o>h;h++)(a=r[h])&&a.action.setValue(this);return e},i.upload=function(){var t=_t;this.alpha=this.ALPHA*t.worldAlpha,_t.worldMatrix4!==_t.TEMPMAT4_ARRAY&&this.defines.add(128);var e,i=t.worldShaderDefines?this._withWorldShaderDefines():Lt.sharders[this.mainID|this.defines._value]||this._ShaderWithCompile();this.size[0]=t.width,this.size[1]=t.height,this.mmat=t.worldMatrix4,Lt.activeShader!==i?(i._shaderValueWidth!==t.width||i._shaderValueHeight!==t.height?(i._shaderValueWidth=t.width,i._shaderValueHeight=t.height):e=i._params2dQuick2||i._make2dQuick2(),i.upload(this,e)):(i._shaderValueWidth!==t.width||i._shaderValueHeight!==t.height?(i._shaderValueWidth=t.width,i._shaderValueHeight=t.height):e=i._params2dQuick1||i._make2dQuick1(),i.upload(this,e))},i.setFilters=function(t){if(this.filters=t,t)for(var e,i=t.length,n=0;i>n;n++)e=t[n],e&&(this.defines.add(e.type),e.action.setValue(this))},i.clear=function(){this.defines.setValue(this.subID)},i.release=function(){this._inClassCache[this._inClassCache._length++]=this,this.fillStyle=null,this.strokeStyle=null,this.clear()},e._initone=function(t,i){e._typeClass[t]=i,e._cache[t]=[],e._cache[t]._length=0},e.__init__=function(){e._POSITION=[2,5126,!1,4*ut.BYTES_PE,0],e._TEXCOORD=[2,5126,!1,4*ut.BYTES_PE,2*ut.BYTES_PE],e._initone(2,Et),e._initone(4,Bt),e._initone(256,Dt),e._initone(512,It),e._initone(1,Ft),e._initone(65,Vt),e._initone(9,Ft)},e.create=function(t,i){var n=e._cache[t|i];return n._length?n[--n._length]:new e._typeClass[t|i](i)},e._POSITION=null,e._TEXCOORD=null,e._cache=[],e._typeClass=[],e.TEMPMAT4_ARRAY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e}(B),yt=function(t){function e(t,i){e.__super.call(this,t,i)}s(e,"laya.webgl.utils.RenderSprite3D",t);var i=e.prototype;return i.onCreate=function(t){switch(t){case 32:return void(this._fun=this._blend);case 4:return void(this._fun=this._transform)}},i._blend=function(t,e,i,n){var s,r,a=t._style,o=this._next,h=t.mask;if(e.ctx.save(),h){var l=e.ctx.globalCompositeOperation,u=new x;if(u.copyFrom(h.getBounds()),u.width>0&&u.height>0){var c=et.create();c.addValue("bounds",u),s=tt.create([c,e],laya.webgl.utils.RenderSprite3D.tmpTarget),e.addRenderObject(s),h.render(e,-u.x,-u.y),s=tt.create([c],laya.webgl.utils.RenderSprite3D.endTmpTarget),e.addRenderObject(s),e.ctx.save(),e.clipRect(i+u.x,n+u.y,u.width,u.height),o._fun.call(o,t,e,i,n),e.ctx.restore(),r=st.create(6),l=e.ctx.globalCompositeOperation,r.blendMode="mask",e.addRenderObject(r),v.TEMP.identity();var _=vt.create(1,0);e.ctx.drawTarget(c,i+u.x,n+u.y,u.width,u.height,v.TEMP,"tmpTarget",_,R.INV_UV,6),s=tt.create([c],laya.webgl.utils.RenderSprite3D.recycleTarget),e.addRenderObject(s),r=st.create(6),r.blendMode=l,e.addRenderObject(r)}}else e.ctx.globalCompositeOperation=a.blendMode,o=this._next,o._fun.call(o,t,e,i,n);e.ctx.restore()},i._transform=function(t,e,i,n){"use strict";var s=t.transform,r=this._next;if(s&&r!=b.NORENDER){var a=e.ctx;t._style;s.tx=i,s.ty=n;var o=a._getTransformMatrix(),h=o.clone();v.mul(s,o,o),o._checkTransform(),r._fun.call(r,t,e,0,0),h.copyTo(o),h.destroy(),s.tx=s.ty=0}else r._fun.call(r,t,e,i,n)},e.tmpTarget=function(t,e){var i=t.getValue("bounds"),n=Pt.create(i.width,i.height);n.start(),n.clear(0,0,0,0),t.addValue("tmpTarget",n)},e.endTmpTarget=function(t){var e=t.getValue("tmpTarget");e.end()},e.recycleTarget=function(t){var e=t.getValue("tmpTarget");e.recycle(),t.recycle()},e}(b),xt=function(t){function e(){this.data=null,e.__super.call(this)}s(e,"laya.filters.webgl.ColorFilterActionGL",t);var n=e.prototype;return i.imps(n,{"laya.filters.IFilterActionGL":!0}),n.setValue=function(t){t.colorMat=this.data._mat,t.colorAlpha=this.data._alpha},n.apply3d=function(t,e,i,n,s){var r=t.getValue("bounds"),a=vt.create(1,0);a.setFilters([this.data]);var o=v.EMPTY;o.identity(),i.ctx.drawTarget(t,0,0,r.width,r.height,o,"src",a)},e}(F),wt=function(t){function e(t,i,n,s,r){this._atlasCanvas=null,this._inAtlasTextureKey=null,this._inAtlasTextureBitmapValue=null,this._inAtlasTextureOriUVValue=null,this._InAtlasWebGLImagesKey=null,this._InAtlasWebGLImagesOffsetValue=null,e.__super.call(this,t,i,r),this._inAtlasTextureKey=[],this._inAtlasTextureBitmapValue=[],this._inAtlasTextureOriUVValue=[],this._InAtlasWebGLImagesKey=[],this._InAtlasWebGLImagesOffsetValue=[],this._atlasCanvas=new kt,this._atlasCanvas.width=n,this._atlasCanvas.height=s,this._atlasCanvas.activeResource(),this._atlasCanvas.lock=!0}s(e,"laya.webgl.atlas.Atlaser",t);var i=e.prototype;return i.computeUVinAtlasTexture=function(t,e,i,n){var s=O.atlasTextureWidth,r=O.atlasTextureHeight,a=i/s,o=n/r,h=(i+t.bitmap.width)/s,l=(n+t.bitmap.height)/r,u=t.bitmap.width/s,c=t.bitmap.height/r;t.uv=[a+e[0]*u,o+e[1]*c,h-(1-e[2])*u,o+e[3]*c,h-(1-e[4])*u,l-(1-e[5])*c,a+e[6]*u,l-(1-e[7])*c]},i.addToAtlasTexture=function(t,e,i){t instanceof laya.webgl.resource.WebGLImage&&(this._InAtlasWebGLImagesKey.push(t),this._InAtlasWebGLImagesOffsetValue.push([e,i])),this._atlasCanvas.texSubImage2D(e,i,t.atlasSource),t.clearAtlasSource()},i.addToAtlas=function(t,e,i){var n=t.uv.slice(),s=t.bitmap;this._inAtlasTextureKey.push(t),this._inAtlasTextureOriUVValue.push(n),this._inAtlasTextureBitmapValue.push(s),this.computeUVinAtlasTexture(t,n,e,i),t.bitmap=this._atlasCanvas},i.clear=function(){for(var t=0,e=this._inAtlasTextureKey.length;e>t;t++)this._inAtlasTextureKey[t].bitmap=this._inAtlasTextureBitmapValue[t],this._inAtlasTextureKey[t].uv=this._inAtlasTextureOriUVValue[t],this._inAtlasTextureKey[t].bitmap.lock=!1,this._inAtlasTextureKey[t].bitmap.releaseResource();this._inAtlasTextureKey.length=0,this._inAtlasTextureBitmapValue.length=0,this._inAtlasTextureOriUVValue.length=0,this._InAtlasWebGLImagesKey.length=0,this._InAtlasWebGLImagesOffsetValue.length=0},i.dispose=function(){this.clear(),this._atlasCanvas.dispose()},r(0,i,"InAtlasWebGLImagesOffsetValue",function(){return this._InAtlasWebGLImagesOffsetValue}),r(0,i,"texture",function(){return this._atlasCanvas}),r(0,i,"inAtlasWebGLImagesKey",function(){return this._InAtlasWebGLImagesKey}),e}(k),bt=function(t){function e(){e.__super.call(this,e.__name2int,e.__int2name,e.__int2nameMap)}return s(e,"laya.webgl.shader.d2.ShaderDefines2D",t),e.__init__=function(){e.reg("TEXTURE2D",1),e.reg("COLOR2D",2),e.reg("PRIMITIVE",4),e.reg("GLOW_FILTER",8),e.reg("BLUR_FILTER",16),e.reg("COLOR_FILTER",32),e.reg("COLOR_ADD",64),e.reg("WORLDMAT",128),e.reg("FILLTEXTURE",256)},e.reg=function(t,i){j._reg(t,i,e.__name2int,e.__int2name)},e.toText=function(t,e,i){return j._toText(t,e,i)},e.toInt=function(t){return j._toInt(t,e.__name2int)},e.TEXTURE2D=1,e.COLOR2D=2,e.PRIMITIVE=4,e.FILTERGLOW=8,e.FILTERBLUR=16,e.FILTERCOLOR=32,e.COLORADD=64,e.WORLDMAT=128,e.FILLTEXTURE=256,e.SKINMESH=512,e.__name2int={},e.__int2name=[],e.__int2nameMap=[],e}(j),Tt=(function(t){function e(t,i,n,s,r,a,o){e.__super.call(this,t,i,n,s,40,r,a,o)}return s(e,"laya.webgl.shapes.Ellipse",t),e}(Z),function(t){function e(t,i,n,s,r){this._points=[];for(var a=NaN,o=NaN,h=-1,l=-1,u=n.length/2,c=0;u>c;c++)a=n[2*c],o=n[2*c+1],(Math.abs(h-a)>.01||Math.abs(l-o)>.01)&&this._points.push(a,o),h=a,l=o;e.__super.call(this,t,i,0,0,0,r,s,r,0)}s(e,"laya.webgl.shapes.Line",t);var i=e.prototype;return i.getData=function(t,e,i){var n=[],s=[];this.borderWidth>0&&this.createLine2(this._points,n,this.borderWidth,i,s,this._points.length/2),t.append(new Uint16Array(n)),e.append(new Float32Array(s))},e}(Z)),St=function(t){function e(t,i,n,s,r){this._points=[];for(var a=NaN,o=NaN,h=-1,l=-1,u=n.length/2-1,c=0;u>c;c++)a=n[2*c],o=n[2*c+1],(Math.abs(h-a)>.01||Math.abs(l-o)>.01)&&this._points.push(a,o),h=a,l=o;a=n[2*u],o=n[2*u+1],h=this._points[0],l=this._points[1],(Math.abs(h-a)>.01||Math.abs(l-o)>.01)&&this._points.push(a,o),e.__super.call(this,t,i,0,0,this._points.length/2,0,s,r)}s(e,"laya.webgl.shapes.LoopLine",t);var i=e.prototype;return i.getData=function(t,e,i){if(this.borderWidth>0){for(var n=this.color,s=(n>>16&255)/255,r=(n>>8&255)/255,a=(255&n)/255,o=[],h=0,l=0,u=[],c=Math.floor(this._points.length/2),_=0;c>_;_++)h=this._points[2*_],l=this._points[2*_+1],o.push(this.x+h,this.y+l,s,r,a);this.createLoopLine(o,u,this.borderWidth,i+o.length/5),t.append(new Uint16Array(u)),e.append(new Float32Array(o))}},i.createLoopLine=function(t,e,i,n,s,r){var a=(t.length/5,t.concat()),o=s?s:t,h=this.borderColor,l=(h>>16&255)/255,u=(h>>8&255)/255,c=(255&h)/255,_=[a[0],a[1]],d=[a[a.length-5],a[a.length-4]],f=d[0]+.5*(_[0]-d[0]),p=d[1]+.5*(_[1]-d[1]);a.unshift(f,p,0,0,0),a.push(f,p,0,0,0);var g,m,v,y,x,w,b,T,S,C,M,A,L,P,R,I,E,D,F,B,k,O=a.length/5,N=n,W=i/2;v=a[0],y=a[1],x=a[5],w=a[6],S=-(y-w),C=v-x,k=Math.sqrt(S*S+C*C),S=S/k*W,C=C/k*W,o.push(v-S,y-C,l,u,c,v+S,y+C,l,u,c);for(var U=1;O-1>U;U++)v=a[5*(U-1)],y=a[5*(U-1)+1],x=a[5*U],w=a[5*U+1],b=a[5*(U+1)],T=a[5*(U+1)+1],S=-(y-w),C=v-x,k=Math.sqrt(S*S+C*C),S=S/k*W,C=C/k*W,M=-(w-T),A=x-b,k=Math.sqrt(M*M+A*A),M=M/k*W,A=A/k*W,L=-C+y-(-C+w),P=-S+x-(-S+v),R=(-S+v)*(-C+w)-(-S+x)*(-C+y),I=-A+T-(-A+w),E=-M+x-(-M+b),D=(-M+b)*(-A+w)-(-M+x)*(-A+T),F=L*E-I*P,Math.abs(F)<.1?(F+=10.1,o.push(x-S,w-C,l,u,c,x+S,w+C,l,u,c)):(g=(P*D-E*R)/F,m=(I*R-L*D)/F,B=(g-x)*(g-x)+(m-w)+(m-w),o.push(g,m,l,u,c,x-(g-x),w-(m-w),l,u,c));r&&(e=r);var V=this.edges+1;for(U=1;V>U;U++)e.push(N+2*(U-1),N+2*(U-1)+1,N+2*U+1,N+2*U+1,N+2*U,N+2*(U-1));return e.push(N+2*(U-1),N+2*(U-1)+1,N+1,N+1,N,N+2*(U-1)),o},e}(Z),Ct=function(t){function e(t,i,n,s,r,a){this._points=null,this._start=-1,this.mUint16Array=null,this.mFloat32Array=null,this._points=n.slice(0,n.length),e.__super.call(this,t,i,0,0,this._points.length/2,s,r,a)}s(e,"laya.webgl.shapes.Polygon",t);var i=e.prototype;return i.getData=function(t,e,i){var n,s=0,r=this._points,a=0;if(this.mUint16Array&&this.mFloat32Array){if(this._start!=i){for(this._start=i,n=[],a=Math.floor(r.length/2),s=2;a>s;s++)n.push(i,i+s-1,i+s);this.mUint16Array=new Uint16Array(n)}}else{this._start=i,n=[];var o=[],h=this.color,l=(h>>16&255)/255,u=(h>>8&255)/255,c=(255&h)/255;for(a=Math.floor(r.length/2),s=0;a>s;s++)o.push(this.x+r[2*s],this.y+r[2*s+1],l,u,c);for(s=2;a>s;s++)n.push(i,i+s-1,i+s);this.mUint16Array=new Uint16Array(n),this.mFloat32Array=new Float32Array(o)}t.append(this.mUint16Array),e.append(this.mFloat32Array)},e}(Z),Mt=function(t){function e(){this._matrix=new v,this._matrix4=ut.defaultMatrix4.concat(),e.__super.call(this,1e4),this.shaderValue=new vt(0,0)}s(e,"laya.webgl.submit.SubmitCanvas",t);var i=e.prototype;return i.renderSubmit=function(){if(this._ctx_src._targets)return this._ctx_src._targets.flush(this._ctx_src),1;var t=_t.worldAlpha,e=_t.worldMatrix4,i=_t.worldMatrix,n=_t.worldFilters,s=_t.worldShaderDefines,r=this.shaderValue,a=this._matrix,o=this._matrix4,h=v.TEMP;return v.mul(a,i,h),o[0]=h.a,o[1]=h.b,o[4]=h.c,o[5]=h.d,o[12]=h.tx,o[13]=h.ty,_t.worldMatrix=h.clone(),_t.worldMatrix4=o,_t.worldAlpha=_t.worldAlpha*r.alpha,r.filters&&r.filters.length&&(_t.worldFilters=r.filters,_t.worldShaderDefines=r.defines),this._ctx_src.flush(),_t.worldAlpha=t,_t.worldMatrix4=e,_t.worldMatrix.destroy(),_t.worldMatrix=i,_t.worldFilters=n,_t.worldShaderDefines=s,1},i.releaseRender=function(){var t=e._cache;t[t._length++]=this},i.getRenderType=function(){return 10003},e.create=function(t,i,n){var s=e._cache._length?e._cache[--e._cache._length]:new e;s._ctx_src=t;var r=s.shaderValue;return r.alpha=i,r.defines.setValue(0),n&&n.length&&r.setFilters(n),s},e._cache=(e._cache=[],e._cache._length=0,e._cache),e}(J),At=function(t){function e(t){this._preIsSameTextureShader=!1,this._isSameTexture=!0,this._texs=new Array,this._texsID=new Array,this._vbPos=new Array,void 0===t&&(t=1e4),e.__super.call(this,t)}s(e,"laya.webgl.submit.SubmitTexture",t);var i=e.prototype;return i.releaseRender=function(){var t=e._cache;t[t._length++]=this,this.shaderValue.release(),this._preIsSameTextureShader=!1,this._vb=null,this._texs.length=0,this._isSameTexture=!0},i.addTexture=function(t,e){this._texsID[this._texs.length]=t._uvID,this._texs.push(t),this._vbPos.push(e)},i.checkTexture=function(){if(this._texs.length<1)return void(this._isSameTexture=!0);var t=this.shaderValue.textureHost,e=t.bitmap;if(null!==e)for(var i=this._vb.getFloat32Array(),n=0,s=this._texs.length;s>n;n++){var r=this._texs[n];r.active();var a=r.uv;if(this._texsID[n]!==r._uvID){this._texsID[n]=r._uvID;var o=this._vbPos[n];i[o+2]=a[0],i[o+3]=a[1],i[o+6]=a[2],i[o+7]=a[3],i[o+10]=a[4],i[o+11]=a[5],i[o+14]=a[6],i[o+15]=a[7],this._vb.setNeedUpload()}r.bitmap!==e&&(this._isSameTexture=!1)}},i.renderSubmit=function(){if(0===this._numEle)return 1;var t=this.shaderValue.textureHost;if(t){var i=t.source;if(!t.bitmap||!i)return e._shaderSet=!1,1;this.shaderValue.texture=i}this._vb.bind_upload(this._ib);var n=ft.mainContext;if(W.activeBlendFunction!==this._blendFn&&(n.enable(3042),this._blendFn(n),W.activeBlendFunction=this._blendFn),A.drawCall++,A.trianglesFaces+=this._numEle/3,this._preIsSameTextureShader&&Lt.activeShader&&e._shaderSet?Lt.activeShader.uploadTexture2D(this.shaderValue.texture):this.shaderValue.upload(),e._shaderSet=!0,this._texs.length>1&&!this._isSameTexture)for(var s=t.bitmap,r=0,a=Lt.activeShader,o=0,h=this._texs.length;h>o;o++){var l=this._texs[o];l.bitmap===s&&o+1!==h||(a.uploadTexture2D(l.source),n.drawElements(4,6*(o-r+1),5123,this._startIdx+6*r*ut.BYTES_PIDX),s=l.bitmap,r=o)}else n.drawElements(4,this._numEle,5123,this._startIdx);return 1},e.create=function(t,i,n,s,r){var a=e._cache._length?e._cache[--e._cache._length]:new e;null==n&&(n=a._selfVb||(a._selfVb=zt.create(-1)),n.clear(),s=0),a._ib=i,a._vb=n,a._startIdx=s*ut.BYTES_PIDX,a._numEle=0;var o=t._nBlendType; +a._blendFn=t._targets?W.targetFns[o]:W.fns[o],a.shaderValue=r,a.shaderValue.setValue(t._shader2D);var h=t._shader2D.filters;return h&&a.shaderValue.setFilters(h),a},e._cache=(e._cache=[],e._cache._length=0,e._cache),e._shaderSet=!0,e}(J),Lt=function(t){function e(t,i,n,s){if(this.customCompile=!1,this._curActTexIndex=0,this.tag={},this._program=null,this._params=null,this._paramsMap={},this._offset=0,e.__super.call(this),!t||!i)throw"Shader Error";(w.isConchApp||w.isFlash)&&(this.customCompile=!0),this._id=++e._count,this._vs=t,this._ps=i,this._nameMap=s?s:{},null!=n&&(e.sharders[n]=this)}s(e,"laya.webgl.shader.Shader",t);var i=e.prototype;return i.recreateResource=function(){this.startCreate(),this._compile(),this.completeCreate(),this.memorySize=0},i.detoryResource=function(){ft.mainContext.deleteShader(this._vshader),ft.mainContext.deleteShader(this._pshader),ft.mainContext.deleteProgram(this._program),this._vshader=this._pshader=this._program=null,this._params=null,this._paramsMap={},this.memorySize=0,this._curActTexIndex=0},i._compile=function(){if(this._vs&&this._ps&&!this._params){this._reCompile=!0,this._params=[];var t,i=[this._vs,this._ps];this.customCompile&&(t=this._preGetParams(this._vs,this._ps));var n=ft.mainContext;if(this._program=n.createProgram(),this._vshader=e._createShader(n,i[0],35633),this._pshader=e._createShader(n,i[1],35632),n.attachShader(this._program,this._vshader),n.attachShader(this._program,this._pshader),n.linkProgram(this._program),!this.customCompile&&!n.getProgramParameter(this._program,35714))throw n.getProgramInfoLog(this._program);var s,r,a=0,o=0,h=this.customCompile?t.attributes.length:n.getProgramParameter(this._program,35721);for(a=0;h>a;a++){var l=this.customCompile?t.attributes[a]:n.getActiveAttrib(this._program,a);r=n.getAttribLocation(this._program,l.name),s={vartype:"attribute",ivartype:0,attrib:l,location:r,name:l.name,type:l.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0},this._params.push(s)}var u=this.customCompile?t.uniforms.length:n.getProgramParameter(this._program,35718);for(a=0;u>a;a++){var c=this.customCompile?t.uniforms[a]:n.getActiveUniform(this._program,a);r=n.getUniformLocation(this._program,c.name),s={vartype:"uniform",ivartype:1,attrib:l,location:r,name:c.name,type:c.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0},s.name.indexOf("[0]")>0&&(s.name=s.name.substr(0,s.name.length-3),s.isArray=!0,s.location=n.getUniformLocation(this._program,s.name)),this._params.push(s)}for(a=0,o=this._params.length;o>a;a++)if(s=this._params[a],s.indexOfParams=a,s.index=1,s.value=[s.location,null],s.codename=s.name,s.name=this._nameMap[s.codename]?this._nameMap[s.codename]:s.codename,this._paramsMap[s.name]=s,s._this=this,s.uploadedValue=[],"attribute"!==s.vartype)switch(s.type){case 5124:s.fun=s.isArray?this._uniform1iv:this._uniform1i;break;case 5126:s.fun=s.isArray?this._uniform1fv:this._uniform1f;break;case 35664:s.fun=s.isArray?this._uniform_vec2v:this._uniform_vec2;break;case 35665:s.fun=s.isArray?this._uniform_vec3v:this._uniform_vec3;break;case 35666:s.fun=s.isArray?this._uniform_vec4v:this._uniform_vec4;break;case 35678:s.fun=this._uniform_sampler2D;break;case 35680:s.fun=this._uniform_samplerCube;break;case 35676:s.fun=this._uniformMatrix4fv;break;case 35670:s.fun=this._uniform1i;break;case 35674:case 35675:throw new Error("compile shader err!");default:throw new Error("compile shader err!")}else s.fun=this._attribute}},i.getUniform=function(t){return this._paramsMap[t]},i._attribute=function(t,e){var i=ft.mainContext;return i.enableVertexAttribArray(t.location),i.vertexAttribPointer(t.location,e[0],e[1],e[2],e[3],e[4]+this._offset),2},i._uniform1f=function(t,e){var i=t.uploadedValue;return i[0]!==e?(ft.mainContext.uniform1f(t.location,i[0]=e),1):0},i._uniform1fv=function(t,e){if(e.length<4){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3]?(ft.mainContext.uniform1fv(t.location,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],1):0}return ft.mainContext.uniform1fv(t.location,e),1},i._uniform_vec2=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]?(ft.mainContext.uniform2f(t.location,i[0]=e[0],i[1]=e[1]),1):0},i._uniform_vec2v=function(t,e){if(e.length<2){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3]?(ft.mainContext.uniform2fv(t.location,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],1):0}return ft.mainContext.uniform2fv(t.location,e),1},i._uniform_vec3=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]?(ft.mainContext.uniform3f(t.location,i[0]=e[0],i[1]=e[1],i[2]=e[2]),1):0},i._uniform_vec3v=function(t,e){return ft.mainContext.uniform3fv(t.location,e),1},i._uniform_vec4=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3]?(ft.mainContext.uniform4f(t.location,i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3]),1):0},i._uniform_vec4v=function(t,e){return ft.mainContext.uniform4fv(t.location,e),1},i._uniformMatrix2fv=function(t,e){return ft.mainContext.uniformMatrix2fv(t.location,!1,e),1},i._uniformMatrix3fv=function(t,e){return ft.mainContext.uniformMatrix3fv(t.location,!1,e),1},i._uniformMatrix4fv=function(t,e){return ft.mainContext.uniformMatrix4fv(t.location,!1,e),1},i._uniform1i=function(t,e){var i=t.uploadedValue;return i[0]!==e?(ft.mainContext.uniform1i(t.location,i[0]=e),1):0},i._uniform1iv=function(t,e){return ft.mainContext.uniform1iv(t.location,e),1},i._uniform_ivec2=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]?(ft.mainContext.uniform2i(t.location,i[0]=e[0],i[1]=e[1]),1):0},i._uniform_ivec2v=function(t,e){return ft.mainContext.uniform2iv(t.location,e),1},i._uniform_vec3i=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]?(ft.mainContext.uniform3i(t.location,i[0]=e[0],i[1]=e[1],i[2]=e[2]),1):0},i._uniform_vec3vi=function(t,e){return ft.mainContext.uniform3iv(t.location,e),1},i._uniform_vec4i=function(t,e){var i=t.uploadedValue;return i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3]?(ft.mainContext.uniform4i(t.location,i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3]),1):0},i._uniform_vec4vi=function(t,e){return ft.mainContext.uniform4iv(t.location,e),1},i._uniform_sampler2D=function(t,i){var n=ft.mainContext,s=t.uploadedValue;return null==s[0]?(s[0]=this._curActTexIndex,n.uniform1i(t.location,this._curActTexIndex),n.activeTexture(e._TEXTURES[this._curActTexIndex]),pt.bindTexture(n,3553,i),this._curActTexIndex++,1):(n.activeTexture(e._TEXTURES[s[0]]),pt.bindTexture(n,3553,i),0)},i._uniform_samplerCube=function(t,i){var n=ft.mainContext,s=t.uploadedValue;return null==s[0]?(s[0]=this._curActTexIndex,n.uniform1i(t.location,this._curActTexIndex),n.activeTexture(e._TEXTURES[this._curActTexIndex]),pt.bindTexture(n,34067,i),this._curActTexIndex++,1):(n.activeTexture(e._TEXTURES[s[0]]),pt.bindTexture(n,34067,i),0)},i._noSetValue=function(t){console.log("no....:"+t.name)},i.uploadOne=function(t,e){this.activeResource(),pt.UseProgram(this._program);var i=this._paramsMap[t];i.fun.call(this,i,e)},i.uploadTexture2D=function(t){A.shaderCall++;var e=ft.mainContext;e.activeTexture(33984),pt.bindTexture(e,3553,t)},i.upload=function(t,i){e.activeShader=this,this.activeResource(),pt.UseProgram(this._program),this._reCompile?(i=this._params,this._reCompile=!1):i=i||this._params;for(var n,s,r=i.length,a=0,o=0;r>o;o++)n=i[o],null!==(s=t[n.name])&&(a+=n.fun.call(this,n,s));A.shaderCall+=a},i.uploadArray=function(t,i,n){e.activeShader=this,this.activeResource(),pt.UseProgram(this._program);for(var s,r,a=(this._params,0),o=i-2;o>=0;o-=2)r=this._paramsMap[t[o]],r&&(s=t[o+1],null!=s&&(n&&n[r.name]&&n[r.name].bind(),a+=r.fun.call(this,r,s)));A.shaderCall+=a},i.getParams=function(){return this._params},i._preGetParams=function(t,e){var i=[t,e],n={},s=[],r=[],a={},o=[];n.attributes=s,n.uniforms=r,n.defines=a;for(var h=new RegExp("(/\\*([^*]|[\\r\\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)","g"),l=new RegExp("(\".*\")|('.*')|([#\\w\\*-\\.+/()=<>{}\\\\]+)|([,;:\\\\])","g"),u=0,c=0,_=0;2>_;_++){i[_]=i[_].replace(h,"");var d,f=i[_].match(l);for(u=0,c=f.length;c>u;u++){var p=f[u];if("attribute"==p||"uniform"==p)u=this.parseOne(s,r,f,u,p,!0);else{if("#define"==p){p=f[++u],o[p]=1;continue}if("#ifdef"==p){d=f[++u];a[d]=a[d]||[];for(u++;c>u;u++)if(p=f[u],"attribute"==p||"uniform"==p)u=this.parseOne(s,r,f,u,p,o[d]);else if("#else"==p)for(u++;c>u;u++)if(p=f[u],"attribute"==p||"uniform"==p)u=this.parseOne(s,r,f,u,p,!o[d]);else if("#endif"==p)break}}}}return n},i.parseOne=function(t,i,n,s,r,a){var o={type:e.shaderParamsMap[n[s+1]],name:n[s+2],size:isNaN(parseInt(n[s+3]))?1:parseInt(n[s+3])};return a&&("attribute"==r?t.push(o):i.push(o)),":"==n[s+3]&&(o.type=n[s+4],s+=2),s+=2},i.dispose=function(){this.resourceManager.removeResource(this),t.prototype.dispose.call(this)},e.getShader=function(t){return e.sharders[t]},e.create=function(t,i,n,s){return new e(t,i,n,s)},e.withCompile=function(t,i,n,s){if(n&&e.sharders[n])return e.sharders[n];var r=e._preCompileShader[2e-4*t];if(!r)throw new Error("withCompile shader err!"+t);return r.createShader(i,n,s)},e.withCompile2D=function(t,i,n,s,r){if(s&&e.sharders[s])return e.sharders[s];var a=e._preCompileShader[2e-4*t+i];if(!a)throw new Error("withCompile shader err!"+t+" "+i);return a.createShader(n,s,r)},e.addInclude=function(t,i){if(!i||0===i.length)throw new Error("add shader include file err:"+t);if(e._includeFiles[t])throw new Error("add shader include file err, has add:"+t);e._includeFiles[t]=i},e.preCompile=function(t,i,n,s){var r=2e-4*t;e._preCompileShader[r]=new dt(r,i,n,s,e._includeFiles)},e.preCompile2D=function(t,i,n,s,r){var a=2e-4*t+i;e._preCompileShader[a]=new dt(a,n,s,r,e._includeFiles)},e._createShader=function(t,e,i){var n=t.createShader(i);if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,35713))throw t.getShaderInfoLog(n);return n},e._TEXTURES=[33984,33985,33986,33987,33988,33989,33990,,33991,33992],e._includeFiles={},e._count=0,e._preCompileShader={},e.SHADERNAME2ID=2e-4,e.activeShader=null,e.sharders=(e.sharders=[],e.sharders.length=32,e.sharders),n(e,["shaderParamsMap",function(){return this.shaderParamsMap={"float":5126,"int":5124,bool:35670,vec2:35664,vec3:35665,vec4:35666,ivec2:35667,ivec3:35668,ivec4:35669,bvec2:35671,bvec3:35672,bvec4:35673,mat2:35674,mat3:35675,mat4:35676,sampler2D:35678,samplerCube:35680}},"nameKey",function(){return this.nameKey=new L}]),e}(T),Pt=function(t){function e(t,i,n,s,r,a,o,h,l){this._type=0,this._svWidth=NaN,this._svHeight=NaN,this._preRenderTarget=null,this._alreadyResolved=!1,this._looked=!1,this._surfaceFormat=0,this._surfaceType=0,this._depthStencilFormat=0,this._mipMap=!1,this._repeat=!1,this._minFifter=0,this._magFifter=0,this._destroy=!1,void 0===n&&(n=6408),void 0===s&&(s=5121),void 0===r&&(r=33189),void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===h&&(h=-1),void 0===l&&(l=-1),this._type=1,this._w=t,this._h=i,this._surfaceFormat=n,this._surfaceType=s,this._depthStencilFormat=r,this._mipMap=a,this._repeat=o,this._minFifter=h,this._magFifter=l,this._createWebGLRenderTarget(),this.bitmap.lock=!0,e.__super.call(this,this.bitmap,R.INV_UV)}s(e,"laya.webgl.resource.RenderTarget2D",t);var n=e.prototype;return i.imps(n,{"laya.resource.IDispose":!0}),n.getType=function(){return this._type},n.getTexture=function(){return this},n.size=function(t,e){this.bitmap&&this._w==t&&this._h==e||(this._w=t,this._h=e,this.release(),this._createWebGLRenderTarget())},n.release=function(){this.destroy()},n.recycle=function(){e.POOL.push(this)},n.start=function(){var t=ft.mainContext;return this._preRenderTarget=_t.curRenderTarget,_t.curRenderTarget=this,t.bindFramebuffer(36160,this.bitmap.frameBuffer),this._alreadyResolved=!1,1==this._type&&(t.viewport(0,0,this._w,this._h),this._svWidth=_t.width,this._svHeight=_t.height,_t.width=this._w,_t.height=this._h,Lt.activeShader=null),this},n.clear=function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1);var s=ft.mainContext;s.clearColor(t,e,i,n);var r=16384;switch(this._depthStencilFormat){case 33189:r|=256;break;case 36168:r|=1024;break;case 34041:r|=256,r|=1024}s.clear(r)},n.end=function(){var t=ft.mainContext;t.bindFramebuffer(36160,this._preRenderTarget?this._preRenderTarget.bitmap.frameBuffer:null),this._alreadyResolved=!0,_t.curRenderTarget=this._preRenderTarget,1==this._type?(t.viewport(0,0,this._svWidth,this._svHeight),_t.width=this._svWidth,_t.height=this._svHeight,Lt.activeShader=null):t.viewport(0,0,i.stage.width,i.stage.height)},n.getData=function(t,e,i,n){var s=ft.mainContext;s.bindFramebuffer(36160,this.bitmap.frameBuffer);var r=36053===s.checkFramebufferStatus(36160);if(!r)return s.bindFramebuffer(36160,null),null;var a=new Uint8Array(this._w*this._h*4);return s.readPixels(t,e,i,n,this._surfaceFormat,this._surfaceType,a),s.bindFramebuffer(36160,null),a},n.destroy=function(e){void 0===e&&(e=!1),this._destroy||(this._loaded=!1,this.bitmap.dispose(),this.bitmap=null,this._destroy=!0,t.prototype.destroy.call(this))},n.dispose=function(){},n._createWebGLRenderTarget=function(){this.bitmap=new Nt(this.width,this.height,this._surfaceFormat,this._surfaceType,this._depthStencilFormat,this._mipMap,this._repeat,this._minFifter,this._magFifter),this.bitmap.activeResource(),this._alreadyResolved=!0,this._destroy=!1,this._loaded=!0},r(0,n,"surfaceFormat",function(){return this._surfaceFormat}),r(0,n,"magFifter",function(){return this._magFifter}),r(0,n,"surfaceType",function(){return this._surfaceType}),r(0,n,"mipMap",function(){return this._mipMap}),r(0,n,"depthStencilFormat",function(){return this._depthStencilFormat}),r(0,n,"minFifter",function(){return this._minFifter}),r(0,n,"source",function(){if(this._alreadyResolved)return t.prototype._$get_source.call(this);throw new Error("RenderTarget 还未准备好!")}),e.create=function(t,i,n,s,r,a,o,h,l){void 0===n&&(n=6408),void 0===s&&(s=5121),void 0===r&&(r=33189),void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===h&&(h=-1),void 0===l&&(l=-1);var u=e.POOL.pop();return u||(u=new e(t,i)),u.bitmap&&u._w==t&&u._h==i&&u._surfaceFormat==n&&u._surfaceType==s&&u._depthStencilFormat==r&&u._mipMap==a&&u._repeat==o&&u._minFifter==h&&u._magFifter==l||(u._w=t,u._h=i,u._surfaceFormat=n,u._surfaceType=s,u._depthStencilFormat=r,u._mipMap=a,u._repeat=o,u._minFifter=h,u._magFifter=l,u.release(),u._createWebGLRenderTarget()),u},e.TYPE2D=1,e.TYPE3D=2,e.POOL=[],e}(R),Rt=function(t){function e(){this._glBuffer=null,this._buffer=null,this._bufferType=0,this._bufferUsage=0,this._byteLength=0,e.__super.call(this),e._gl=ft.mainContext}s(e,"laya.webgl.utils.Buffer",t);var i=e.prototype;return i._bind=function(){this.activeResource(),e._bindActive[this._bufferType]===this._glBuffer||(e._gl.bindBuffer(this._bufferType,e._bindActive[this._bufferType]=this._glBuffer),Lt.activeShader=null)},i.recreateResource=function(){this.startCreate(),this._glBuffer||(this._glBuffer=e._gl.createBuffer()),this.completeCreate()},i.detoryResource=function(){this._glBuffer&&(ft.mainContext.deleteBuffer(this._glBuffer),this._glBuffer=null),this.memorySize=0},i.dispose=function(){this.resourceManager.removeResource(this),t.prototype.dispose.call(this)},r(0,i,"byteLength",function(){return this._byteLength}),r(0,i,"bufferType",function(){return this._bufferType}),r(0,i,"bufferUsage",function(){return this._bufferUsage}),e._gl=null,e._bindActive={},e}(T),It=function(t){function e(t){this.texcoord=null,this.offsetX=300,this.offsetY=0,e.__super.call(this,512,0);var i=8*ut.BYTES_PE;this.position=[2,5126,!1,i,0],this.texcoord=[2,5126,!1,i,2*ut.BYTES_PE],this.color=[4,5126,!1,i,4*ut.BYTES_PE]}return s(e,"laya.webgl.shader.d2.skinAnishader.SkinSV",t),e}(vt),Et=function(t){function e(t){e.__super.call(this,2,0),this.color=[]}s(e,"laya.webgl.shader.d2.value.Color2dSV",t);var i=e.prototype;return i.setValue=function(t){t.fillStyle&&(this.color=t.fillStyle._color._color),t.strokeStyle&&(this.color=t.strokeStyle._color._color)},e}(vt),Dt=function(t){function e(t){this.u_colorMatrix=null,this.strength=0,this.colorMat=null,this.colorAlpha=null,this.u_TexRange=[0,1,0,1],this.u_offset=[0,0],this.texcoord=vt._TEXCOORD,e.__super.call(this,256,0)}s(e,"laya.webgl.shader.d2.value.FillTextureSV",t);var i=e.prototype;return i.setValue=function(t){this.ALPHA=t.ALPHA,t.filters&&this.setFilters(t.filters)},i.clear=function(){this.texture=null,this.shader=null,this.defines.setValue(0)},e}(vt),Ft=function(t){function e(t){this.u_colorMatrix=null,this.strength=0,this.colorMat=null,this.colorAlpha=null,this.texcoord=vt._TEXCOORD,void 0===t&&(t=0),e.__super.call(this,1,t)}s(e,"laya.webgl.shader.d2.value.TextureSV",t);var i=e.prototype;return i.setValue=function(t){this.ALPHA=t.ALPHA,t.filters&&this.setFilters(t.filters)},i.clear=function(){this.texture=null,this.shader=null,this.defines.setValue(0)},e}(vt),Bt=function(t){function e(t){this.a_color=null,this.u_pos=[0,0],e.__super.call(this,4,0),this.position=[2,5126,!1,5*ut.BYTES_PE,0],this.a_color=[3,5126,!1,5*ut.BYTES_PE,2*ut.BYTES_PE]}return s(e,"laya.webgl.shader.d2.value.PrimitiveSV",t),e}(vt),kt=function(t){function e(){this._flashCacheImage=null,this._flashCacheImageNeedFlush=!1,e.__super.call(this)}s(e,"laya.webgl.atlas.AtlasWebGLCanvas",t);var i=e.prototype;return i.recreateResource=function(){this.startCreate();var t=ft.mainContext,e=this._source=t.createTexture(),i=pt.curBindTexTarget,n=pt.curBindTexValue;pt.bindTexture(t,3553,e),t.texImage2D(3553,0,6408,this._w,this._h,0,6408,5121,null),t.texParameteri(3553,10241,9729),t.texParameteri(3553,10240,9729),t.texParameteri(3553,10242,33071),t.texParameteri(3553,10243,33071),i&&n&&pt.bindTexture(t,i,n),this.memorySize=this._w*this._h*4,this.completeCreate()},i.detoryResource=function(){this._source&&(ft.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},i.texSubImage2D=function(t,e,i){if(w.isFlash){this._flashCacheImage||(this._flashCacheImage=m.create(null),this._flashCacheImage.image.createCanvas(this._w,this._h));var n=i.bitmapdata;t-1>=0&&this._flashCacheImage.image.copyPixels(n,0,0,n.width-1,n.height,t,e),t+1<=this._w&&this._flashCacheImage.image.copyPixels(n,0,0,n.width+1,n.height,t,e),e-1>=0&&this._flashCacheImage.image.copyPixels(n,0,0,n.width,n.height-1,t,e),e+1<=this._h&&this._flashCacheImage.image.copyPixels(n,0,0,n.width+1,n.height,t,e),this._flashCacheImage.image.copyPixels(n,0,0,n.width,n.height,t,e),this._flashCacheImageNeedFlush||(this._flashCacheImageNeedFlush=!0)}else{var s=ft.mainContext,r=pt.curBindTexTarget,a=pt.curBindTexValue;pt.bindTexture(s,3553,this._source),t-1>=0&&s.texSubImage2D(3553,0,t-1,e,6408,5121,i),t+1<=this._w&&s.texSubImage2D(3553,0,t+1,e,6408,5121,i),e-1>=0&&s.texSubImage2D(3553,0,t,e-1,6408,5121,i),e+1<=this._h&&s.texSubImage2D(3553,0,t,e+1,6408,5121,i),s.texSubImage2D(3553,0,t,e,6408,5121,i),r&&a&&pt.bindTexture(s,r,a)}},i.texSubImage2DPixel=function(t,e,i,n,s){var r=ft.mainContext,a=pt.curBindTexTarget,o=pt.curBindTexValue;pt.bindTexture(r,3553,this._source);var h=new Uint8Array(s.data);r.texSubImage2D(3553,0,t,e,i,n,6408,5121,h),a&&o&&pt.bindTexture(r,a,o)},r(0,i,"width",t.prototype._$get_width,function(t){this._w=t}),r(0,i,"height",t.prototype._$get_height,function(t){this._h=t}),e}(l),Ot=(function(t){function e(t){this._is2D=!1;var i=this;if(e.__super.call(this),this._canvas=this,"2D"===t||"AUTO"===t&&!w.isWebGL){this._is2D=!0,this._canvas=this._source=u.createElement("canvas"),this.iscpuSource=!0;var n=this;n.getContext=function(t,e){if(i._ctx)return i._ctx;var s=i._ctx=i._canvas.getContext(t,e);return s&&(s._canvas=n,s.size=function(){}),s}}else this._canvas={}}s(e,"laya.webgl.resource.WebGLCanvas",t);var i=e.prototype;return i.clear=function(){this._ctx&&this._ctx.clear()},i.destroy=function(){this._ctx&&this._ctx.destroy(),this._ctx=null},i._setContext=function(t){this._ctx=t},i.getContext=function(t,i){return this._ctx?this._ctx:this._ctx=e._createContext(this)},i.size=function(t,e){this._w==t&&this._h==e||(this._w=t,this._h=e,this._ctx&&this._ctx.size(t,e),this._canvas&&(this._canvas.height=e,this._canvas.width=t))},i.recreateResource=function(){this.startCreate(),this.createWebGlTexture(),this.completeCreate()},i.detoryResource=function(){this._source&&!this.iscpuSource&&(ft.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},i.createWebGlTexture=function(){var t=ft.mainContext;if(!this._canvas)throw"create GLTextur err:no data:"+this._canvas;var e=this._source=t.createTexture();this.iscpuSource=!1;var i=pt.curBindTexTarget,n=pt.curBindTexValue;pt.bindTexture(t,3553,e),t.texImage2D(3553,0,6408,this._w,this._h,0,6408,5121,null),t.texParameteri(3553,10240,9729),t.texParameteri(3553,10241,9729),t.texParameteri(3553,10242,33071),t.texParameteri(3553,10243,33071),this.memorySize=this._w*this._h*4,i&&n&&pt.bindTexture(t,i,n),this._canvas=null},i.texSubImage2D=function(t,e,i){var n=ft.mainContext,s=pt.curBindTexTarget,r=pt.curBindTexValue;pt.bindTexture(n,3553,this._source),n.texSubImage2D(3553,0,e,i,6408,5121,t._source),s&&r&&pt.bindTexture(n,s,r)},r(0,i,"canvas",function(){return this._canvas}),r(0,i,"context",function(){return this._ctx}),r(0,i,"asBitmap",null,function(t){this._ctx&&(this._ctx.asBitmap=t)}),e.create=function(t){return new e(t)},e._createContext=null,e}(l),function(t){function e(t,i){this.borderSize=12,e.__super.call(this),this.canvas=t,this["char"]=i,this._enableMerageInAtlas=!0;var n=w.isConchApp;n?this._ctx=t:this._ctx=t.getContext("2d",void 0);var s=i.xs,r=i.ys,a=null;n?(this._ctx.font=i.font,a=this._ctx.measureText(i["char"]),i.width=a.width*s,i.height=a.height*r):(a=I.measureText(i["char"],i.font),i.width=a.width*s,i.height=a.height*r),this.onresize(i.width+2*this.borderSize,i.height+2*this.borderSize)}s(e,"laya.webgl.resource.WebGLCharImage",t);var n=e.prototype;return i.imps(n,{"laya.webgl.resource.IMergeAtlasBitmap":!0}),n.recreateResource=function(){this.startCreate();var t=this["char"],e=w.isConchApp,i=t.xs,n=t.ys;if(this.onresize(t.width+2*this.borderSize,t.height+2*this.borderSize),this.canvas&&(this.canvas.height=this._h,this.canvas.width=this._w),e){var s=t.fontSize;1==i&&1==n||(s=parseInt(s*(i>n?i:n)+""));var r="normal 100 "+s+"px Arial";t.borderColor&&(r+=" 1 "+t.borderColor),this._ctx.font=r,this._ctx.textBaseline="top",this._ctx.fillStyle=t.fillColor,this._ctx.fillText(t["char"],this.borderSize,this.borderSize,null,null,null)}else this._ctx.save(),this._ctx.clearRect(0,0,t.width+2*this.borderSize,t.height+2*this.borderSize),this._ctx.font=t.font,this._ctx.textBaseline="top",this._ctx.translate(this.borderSize,this.borderSize),1==i&&1==n||this._ctx.scale(i,n),t.fillColor&&t.borderColor?(this._ctx.strokeStyle=t.borderColor,this._ctx.lineWidth=t.lineWidth,this._ctx.strokeText(t["char"],0,0,null,null,0,null),this._ctx.fillStyle=t.fillColor,this._ctx.fillText(t["char"],0,0,null,null,null)):-1===t.lineWidth?(this._ctx.fillStyle=t.fillColor?t.fillColor:"white",this._ctx.fillText(t["char"],0,0,null,null,null)):(this._ctx.strokeStyle=t.borderColor?t.borderColor:"white",this._ctx.lineWidth=t.lineWidth,this._ctx.strokeText(t["char"],0,0,null,null,0,null)),this._ctx.restore();t.borderSize=this.borderSize,this.completeCreate()},n.onresize=function(t,e){if(this._w=t,this._h=e,!(this._wi;i++)t=e[i],(w.isFlash||"size"!==t.name&&"mmat"!==t.name&&"position"!==t.name&&"texcoord"!==t.name)&&this._params2dQuick1.push(t)}return this._params2dQuick1},i.detoryResource=function(){t.prototype.detoryResource.call(this),this._params2dQuick1=null,this._params2dQuick2=null},i.upload2dQuick2=function(t){this.upload(t,this._params2dQuick2||this._make2dQuick2())},i._make2dQuick2=function(){if(!this._params2dQuick2){this.activeResource(),this._params2dQuick2=[];for(var t,e=this._params,i=0,n=e.length;n>i;i++)t=e[i],(w.isFlash||"size"!==t.name)&&this._params2dQuick2.push(t)}return this._params2dQuick2},e.create=function(t,i,n,s){return new e(t,i,n,s)},e}(Lt)),Ut=function(t){function e(){this._maxsize=0,this._upload=!0,this._uploadSize=0,e.__super.call(this),this.lock=!0}s(e,"laya.webgl.utils.Buffer2D",t);var i=e.prototype;return i._bufferData=function(){this._maxsize=Math.max(this._maxsize,this._byteLength),A.loopCount%30==0&&(this._buffer.byteLength>this._maxsize+64&&(this.memorySize=this._buffer.byteLength,this._buffer=this._buffer.slice(0,this._maxsize+64),this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSizethis._maxsize+64&&(this.memorySize=this._buffer.byteLength,this._buffer=this._buffer.slice(0,this._maxsize+64),this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSize0){var i=new ArrayBuffer(t),n=new Uint8Array(i);n.set(new Uint8Array(this._buffer),0),this._buffer=i}else this._buffer=new ArrayBuffer(t);return this._checkArrayUse(),this._upload=!0,this},i.append=function(t){this._upload=!0;var e,i=0;i=t.byteLength,t instanceof Uint8Array?(this._resizeBuffer(this._byteLength+i,!0),e=new Uint8Array(this._buffer,this._byteLength)):t instanceof Uint16Array?(this._resizeBuffer(this._byteLength+i,!0),e=new Uint16Array(this._buffer,this._byteLength)):t instanceof Float32Array&&(this._resizeBuffer(this._byteLength+i,!0),e=new Float32Array(this._buffer,this._byteLength)),e.set(t,0),this._byteLength+=i,this._checkArrayUse(); +},i.getBuffer=function(){return this._buffer},i.setNeedUpload=function(){this._upload=!0},i.getNeedUpload=function(){return this._upload},i.upload=function(){var t=this._bind_upload();return Rt._gl.bindBuffer(this._bufferType,null),Rt._bindActive[this._bufferType]=null,Lt.activeShader=null,t},i.subUpload=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0);var n=this._bind_subUpload();return Rt._gl.bindBuffer(this._bufferType,null),Rt._bindActive[this._bufferType]=null,Lt.activeShader=null,n},i.detoryResource=function(){t.prototype.detoryResource.call(this),this._upload=!0,this._uploadSize=0},i.clear=function(){this._byteLength=0,this._upload=!0},r(0,i,"bufferLength",function(){return this._buffer.byteLength}),r(0,i,"byteLength",t.prototype._$get_byteLength,function(t){this._byteLength!==t&&(t<=this._buffer.byteLength||this._resizeBuffer(2*t+256,!0),this._byteLength=t)}),e.__int__=function(t){Ht.QuadrangleIB=Ht.create(35044),ct.fillIBQuadrangle(Ht.QuadrangleIB,16)},e.FLOAT32=4,e.SHORT=2,e}(Rt),Vt=(function(t){function e(t){this.u_blurX=!1,this.u_color=null,this.u_offset=null,this.u_strength=NaN,this.u_texW=0,this.u_texH=0,e.__super.call(this,9)}s(e,"laya.webgl.shader.d2.value.GlowSV",t);var i=e.prototype;return i.setValue=function(e){t.prototype.setValue.call(this,e)},i.clear=function(){t.prototype.clear.call(this)},e}(Ft),function(t){function e(t){e.__super.call(this,64),this.defines.add(64)}s(e,"laya.webgl.shader.d2.value.TextSV",t);var i=e.prototype;return i.release=function(){e.pool[e._length++]=this,this.clear()},i.clear=function(){t.prototype.clear.call(this)},e.create=function(){return e._length?e.pool[--e._length]:new e(null)},e.pool=[],e._length=0,e}(Ft)),Ht=function(t){function e(t){this._uint8Array=null,this._uint16Array=null,void 0===t&&(t=35044),e.__super.call(this),this._bufferUsage=t,this._bufferType=34963,w.isFlash||(this._buffer=new ArrayBuffer(8))}s(e,"laya.webgl.utils.IndexBuffer2D",t);var i=e.prototype;return i._checkArrayUse=function(){this._uint8Array&&(this._uint8Array=new Uint8Array(this._buffer)),this._uint16Array&&(this._uint16Array=new Uint16Array(this._buffer))},i.getUint8Array=function(){return this._uint8Array||(this._uint8Array=new Uint8Array(this._buffer))},i.getUint16Array=function(){return this._uint16Array||(this._uint16Array=new Uint16Array(this._buffer))},e.QuadrangleIB=null,e.create=function(t){return void 0===t&&(t=35044),new e(t)},e}(Ut),zt=function(t){function e(t,i){this._floatArray32=null,this._vertexStride=0,e.__super.call(this),this._vertexStride=t,this._bufferUsage=i,this._bufferType=34962,w.isFlash||(this._buffer=new ArrayBuffer(8)),this.getFloat32Array()}s(e,"laya.webgl.utils.VertexBuffer2D",t);var i=e.prototype;return i.getFloat32Array=function(){return this._floatArray32||(this._floatArray32=new Float32Array(this._buffer))},i.bind=function(t){t&&t._bind(),this._bind()},i.insertData=function(t,e){var i=this.getFloat32Array();i.set(t,e),this._upload=!0},i.bind_upload=function(t){t._bind_upload()||t._bind(),this._bind_upload()||this._bind()},i._checkArrayUse=function(){this._floatArray32&&(this._floatArray32=new Float32Array(this._buffer))},i.detoryResource=function(){t.prototype.detoryResource.call(this);for(var e=0;10>e;e++)ft.mainContext.disableVertexAttribArray(e)},r(0,i,"vertexStride",function(){return this._vertexStride}),e.create=function(t,i){return void 0===i&&(i=35048),new e(t,i)},e}(Ut),Gt=function(t){function e(t,i){this._image=null,this._allowMerageInAtlas=!1,this._enableMerageInAtlas=!1,this.repeat=!1,this.mipmap=!1,this.minFifter=0,this.magFifter=0,e.__super.call(this,t,i),this.repeat=!1,this.mipmap=!1,this.minFifter=-1,this.magFifter=-1,this._src=t,this._image=new u.window.Image,i&&(i.onload&&(this.onload=i.onload),i.onerror&&(this.onerror=i.onerror),i.onCreate&&i.onCreate(this)),this._image.crossOrigin=t&&0==t.indexOf("data:")?null:"",t&&(this._image.src=t),this._enableMerageInAtlas=!0}s(e,"laya.webgl.resource.WebGLImage",t);var n=e.prototype;return i.imps(n,{"laya.webgl.resource.IMergeAtlasBitmap":!0}),n._init_=function(t,e){},n._createWebGlTexture=function(){if(!this._image)throw"create GLTextur err:no data:"+this._image;var t=ft.mainContext,e=this._source=t.createTexture(),i=pt.curBindTexTarget,n=pt.curBindTexValue;pt.bindTexture(t,3553,e),t.texImage2D(3553,0,6408,6408,5121,this._image);var s=this.minFifter,r=this.magFifter,a=this.repeat?10497:33071,h=o.isPOT(this._w,this._h);h?(this.mipmap?-1!==s||(s=9987):-1!==s||(s=9729),-1!==r||(r=9729),t.texParameteri(3553,10241,s),t.texParameteri(3553,10240,r),t.texParameteri(3553,10242,a),t.texParameteri(3553,10243,a),this.mipmap&&t.generateMipmap(3553)):(-1!==s||(s=9729),-1!==r||(r=9729),t.texParameteri(3553,10241,s),t.texParameteri(3553,10240,r),t.texParameteri(3553,10242,33071),t.texParameteri(3553,10243,33071)),i&&n&&pt.bindTexture(t,i,n),this._image.onload=null,this._image=null,h?this.memorySize=this._w*this._h*4*(1+1/3):this.memorySize=this._w*this._h*4,this._recreateLock=!1},n.recreateResource=function(){var t=this;if(null!=this._src&&""!==this._src)if(this._needReleaseAgain=!1,this._image){if(this._recreateLock)return;this.startCreate(),this._allowMerageInAtlas&&this._enableMerageInAtlas?(this.memorySize=0,this._recreateLock=!1):this._createWebGlTexture(),this.completeCreate()}else{this._recreateLock=!0,this.startCreate();var e=this;this._image=new u.window.Image,this._image.crossOrigin=0==this._src.indexOf("data:")?null:"",this._image.onload=function(){return e._needReleaseAgain?(e._needReleaseAgain=!1,e._image.onload=null,void(e._image=null)):(e._allowMerageInAtlas&&e._enableMerageInAtlas?(t.memorySize=0,t._recreateLock=!1):e._createWebGlTexture(),void e.completeCreate())},this._image.src=this._src}},n.detoryResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(ft.mainContext.deleteTexture(this._source),this._source=null,this._image=null,this.memorySize=0)},n.onresize=function(){this._w=this._image.width,this._h=this._image.height,O.enabled&&this._w=0&&e=0&&tl;l++){for(var h=t.getSubMesh(l),u=h._getVertexBuffer(),c=u.getData(),_=[],d=0;dO;O++){var b=g+O*A;I._datas[O]=[];for(var P=0;i>P;P++){var w=v+P*R,N=C.origin.elements;N[0]=w,N[2]=b;var B=e._getPosition(C,a,s);I._datas[O][P]=B===Number.MAX_VALUE?NaN:L-B}}return I},e.createFromImage=function(t,n,i){var r=t.width,a=t.height,s=new e(r,a,n,i),o=(i-n)/254;h.canvas.size(r,a),h.context.drawImage(t._image,0,0,r,a);for(var l=h.context.getImageData(0,0,r,a).data,u=0,c=0;r>c;c++)for(var _=s._datas[c]=[],d=0;a>d;d++){var m=l[u++],f=l[u++],p=l[u++],v=l[u++];255==m&&255==f&&255==p&&255==v?_[d]=NaN:_[d]=(m+f+p)/3*o+n}return s},e._getPosition=function(e,t,n){for(var i=Number.MAX_VALUE,r=0;rc&&(i=c)}return i},i(e,["_tempRay",function(){return this._tempRay=new qe(new Qe,new Qe)}]),e}(),U=function(){function e(){if(this._id=0,this._number=0,this._mask=0,this._active=!0,this._visible=!0,this.name=null,this._id=e._uniqueIDCounter,e._uniqueIDCounter++,this._id>32)throw new Error("不允许创建Layer,请参考函数getLayerByNumber、getLayerByMask、getLayerByName!")}r(e,"laya.d3.core.Layer");var t=e.prototype;return a(0,t,"number",function(){return this._number}),a(0,t,"visible",function(){return this._visible},function(t){29!==this._number&&30!=this._number&&(this._visible=t,t?e._visibleLayers=e._visibleLayers|this.mask:e._visibleLayers=e._visibleLayers&~this.mask)}),a(0,t,"mask",function(){return this._mask}),a(0,t,"active",function(){return this._active},function(t){29!==this._number&&30!=this._number&&(this._active=t,t?e._activeLayers=e._activeLayers|this.mask:e._activeLayers=e._activeLayers&~this.mask)}),a(1,e,"activeLayers",function(){return e._activeLayers},function(t){e._activeLayers=t|e.getLayerByNumber(29).mask|e.getLayerByNumber(30).mask;for(var n=0;nt;t++){var n=new e;e._layerList[t]=n,0===t?n.name="Default Layer":29===t?n.name="Reserved Layer0":30===t?n.name="Reserved Layer1":n.name="Layer-"+t,n._number=t,n._mask=Math.pow(2,t)}e._activeLayers=2147483647,e._visibleLayers=2147483647,e._currentCameraCullingMask=2147483647,e.currentCreationLayer=e._layerList[0]},e.getLayerByNumber=function(t){if(0>t||t>30)throw new Error("无法返回指定Layer,该number超出范围!");return e._layerList[t]},e.getLayerByMask=function(t){for(var n=0;31>n;n++)if(e._layerList[n].mask===t)return e._layerList[n];throw new Error("无法返回指定Layer,该mask不存在")},e.getLayerByName=function(t){for(var n=0;31>n;n++)if(e._layerList[n].name===t)return e._layerList[n];throw new Error("无法返回指定Layer,该name不存在")},e.isActive=function(t){return 0!=(t&e._activeLayers)},e.isVisible=function(t){return 0!=(t&e._currentCameraCullingMask&e._visibleLayers)},e._uniqueIDCounter=1,e._layerCount=31,e._layerList=[],e._activeLayers=0,e._visibleLayers=0,e._currentCameraCullingMask=0,e.currentCreationLayer=null,e}(),G=function(){function e(e,t,n){this._time=NaN,this._minCount=0,this._maxCount=0,this._time=e,this._minCount=t,this._maxCount=n}r(e,"laya.d3.core.particleShuriKen.module.Burst");var t=e.prototype;return a(0,t,"time",function(){return this._time}),a(0,t,"minCount",function(){return this._minCount}),a(0,t,"maxCount",function(){return this._maxCount}),e}(),z=function(){function e(e){this._color=null,this.enbale=!1,this._color=e}r(e,"laya.d3.core.particleShuriKen.module.ColorOverLifetime");var t=e.prototype;return t.cloneTo=function(e){var t=e;this._color.cloneTo(t._color),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"color",function(){return this._color}),e}(),H=function(){function e(){this._type=0,this._constant=0,this._overTime=null,this._constantMin=0,this._constantMax=0,this._overTimeMin=null,this._overTimeMax=null}r(e,"laya.d3.core.particleShuriKen.module.FrameOverTime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._constant=this._constant,this._overTime.cloneTo(t._overTime),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._overTimeMin.cloneTo(t._overTimeMin),this._overTimeMax.cloneTo(t._overTimeMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"frameOverTimeData",function(){return this._overTime}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"frameOverTimeDataMin",function(){return this._overTimeMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"frameOverTimeDataMax",function(){return this._overTimeMax}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByOverTime=function(t){var n=new e;return n._type=1,n._overTime=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoOverTime=function(t,n){var i=new e;return i._type=3,i._overTimeMin=t,i._overTimeMax=n,i},e}(),k=function(){function e(){this._type=0,this._separateAxes=!1,this._constant=NaN,this._constantSeparate=null,this._gradient=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=NaN,this._constantMax=NaN,this._constantMinSeparate=null,this._constantMaxSeparate=null,this._gradientMin=null,this._gradientMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientAngularVelocity");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._separateAxes=this._separateAxes,t._constant=this._constant,this._constantSeparate.cloneTo(t._constantSeparate),this._gradient.cloneTo(t._gradient),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(t._constantMinSeparate),this._constantMaxSeparate.cloneTo(t._constantMaxSeparate),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientZ",function(){return this._gradientZ}),a(0,t,"constant",function(){return this._constant}),a(0,t,"gradient",function(){return this._gradient}),a(0,t,"separateAxes",function(){return this._separateAxes}),a(0,t,"type",function(){return this._type}),a(0,t,"constantSeparate",function(){return this._constantSeparate}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientX",function(){return this._gradientX}),a(0,t,"gradientY",function(){return this._gradientY}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),a(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._separateAxes=!1,n._constant=t,n},e.createByConstantSeparate=function(t){var n=new e;return n._type=0,n._separateAxes=!0,n._constantSeparate=t,n},e.createByGradient=function(t){var n=new e;return n._type=1,n._separateAxes=!1,n._gradient=t,n},e.createByGradientSeparate=function(t,n,i){var r=new e;return r._type=1,r._separateAxes=!0,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._separateAxes=!1,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoConstantSeparate=function(t,n){var i=new e;return i._type=2,i._separateAxes=!0,i._constantMinSeparate=t,i._constantMaxSeparate=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=3,i._separateAxes=!1,i._gradientMin=t,i._gradientMax=n,i},e.createByRandomTwoGradientSeparate=function(t,n,i,r,a,s){var o=new e;return o._type=3,o._separateAxes=!0,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}(),X=function(){function e(){this._type=0,this._constant=null,this._constantMin=null,this._constantMax=null,this._gradient=null,this._gradientMin=null,this._gradientMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientColor");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,this._constant.cloneTo(t._constant),this._constantMin.cloneTo(t._constantMin),this._constantMax.cloneTo(t._constantMax),this._gradient.cloneTo(t._gradient),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradient",function(){return this._gradient}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByGradient=function(t){var n=new e;return n._type=1,n._gradient=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=3,i._gradientMin=t,i._gradientMax=n,i},e}(),Y=function(){function e(){this._alphaCurrentLength=0,this._rgbCurrentLength=0,this._alphaElements=null,this._rgbElements=null,this._alphaElements=new Float32Array(8),this._rgbElements=new Float32Array(16)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataColor");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.addAlpha=function(e,t){if(!(this._alphaCurrentLength<8))throw new Error("GradientDataColor:Alpha count must less than 4.");this._alphaElements[this._alphaCurrentLength++]=e,this._alphaElements[this._alphaCurrentLength++]=t},t.addRGB=function(e,t){if(!(this._rgbCurrentLength<16))throw new Error("GradientDataColor:RGB count must less than 4.");this._rgbElements[this._rgbCurrentLength++]=e,this._rgbElements[this._rgbCurrentLength++]=t.x,this._rgbElements[this._rgbCurrentLength++]=t.y,this._rgbElements[this._rgbCurrentLength++]=t.z},t.cloneTo=function(e){var t=e,n=0,i=0;t._alphaCurrentLength=this._alphaCurrentLength;var r=t._alphaElements;for(r.length=this._alphaElements.length,n=0,i=this._alphaElements.length;i>n;n++)r[n]=this._alphaElements[n];t._rgbCurrentLength=this._rgbCurrentLength;var a=t._rgbElements;for(a.length=this._rgbElements.length,n=0,i=this._rgbElements.length;i>n;n++)a[n]=this._rgbElements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"alphaGradientCount",function(){return this._alphaCurrentLength/2}),a(0,t,"rgbGradientCount",function(){return this._rgbCurrentLength/4}),e}(),j=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataInt");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataInt: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),W=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataNumber");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataNumber: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t},t.getKeyByIndex=function(e){return this._elements[2*e]},t.getValueByIndex=function(e){return this._elements[2*e+1]},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),Z=(function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(12)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataVector2");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataVector2: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t.x,this._elements[this._currentLength++]=t.y},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/3}),e}(),function(){function e(){this._type=0,this._separateAxes=!1,this._gradient=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=NaN,this._constantMax=NaN,this._constantMinSeparate=null,this._constantMaxSeparate=null,this._gradientMin=null,this._gradientMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientSize");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._separateAxes=this._separateAxes,this._gradient.cloneTo(t._gradient),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(t._constantMinSeparate),this._constantMaxSeparate.cloneTo(t._constantMaxSeparate),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"separateAxes",function(){return this._separateAxes}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientSizeX",function(){return this._gradientX}),a(0,t,"gradientSize",function(){return this._gradient}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientSizeY",function(){return this._gradientY}),a(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),a(0,t,"gradientSizeZ",function(){return this._gradientZ}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByGradient=function(t){var n=new e;return n._type=0,n._separateAxes=!1,n._gradient=t,n},e.createByGradientSeparate=function(t,n,i){var r=new e;return r._type=0,r._separateAxes=!0,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=1,i._separateAxes=!1,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoConstantSeparate=function(t,n){var i=new e;return i._type=1,i._separateAxes=!0,i._constantMinSeparate=t,i._constantMaxSeparate=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=2,i._separateAxes=!1,i._gradientMin=t,i._gradientMax=n,i},e.createByRandomTwoGradientSeparate=function(t,n,i,r,a,s){var o=new e;return o._type=2,o._separateAxes=!0,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}()),q=function(){function e(){this._type=0,this._constant=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=null,this._constantMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientVelocity");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,this._constant.cloneTo(t._constant),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),this._constantMin.cloneTo(t._constantMin),this._constantMax.cloneTo(t._constantMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientZ",function(){return this._gradientZ}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientX",function(){return this._gradientX}),a(0,t,"gradientY",function(){return this._gradientY}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByGradient=function(t,n,i){var r=new e;return r._type=1,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoGradient=function(t,n,i,r,a,s){var o=new e;return o._type=3,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}(),K=function(){function e(e){this._angularVelocity=null,this.enbale=!1,this._angularVelocity=e}r(e,"laya.d3.core.particleShuriKen.module.RotationOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._angularVelocity.cloneTo(t._angularVelocity),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"angularVelocity",function(){return this._angularVelocity}),e}(),Q=function(){function e(){this.enbale=!1}r(e,"laya.d3.core.particleShuriKen.module.shape.BaseShape");var t=e.prototype;return t.generatePositionAndDirection=function(e,t){throw new Error("BaseShape: must override it.")},e}(),$=function(){function e(){}return r(e,"laya.d3.core.particleShuriKen.module.shape.ShapeUtils"),e._randomPointUnitArcCircle=function(e,t){var n=t.elements,i=Math.random()*e;n[0]=Math.cos(i),n[1]=Math.sin(i)},e._randomPointInsideUnitArcCircle=function(t,n){var i=n.elements;e._randomPointUnitArcCircle(t,n);var r=Math.pow(Math.random(),.5);i[0]=i[0]*r,i[1]=i[1]*r},e._randomPointUnitCircle=function(e){var t=e.elements,n=Math.random()*Math.PI*2;t[0]=Math.cos(n),t[1]=Math.sin(n)},e._randomPointInsideUnitCircle=function(t){var n=t.elements;e._randomPointUnitCircle(t);var i=Math.pow(Math.random(),.5);n[0]=n[0]*i,n[1]=n[1]*i},e._randomPointUnitSphere=function(e){var t=e.elements,n=t[2]=2*Math.random()-1,i=Math.random()*Math.PI*2,r=Math.sqrt(1-n*n);t[0]=r*Math.cos(i),t[1]=r*Math.sin(i)},e._randomPointInsideUnitSphere=function(t){var n=t.elements;e._randomPointUnitSphere(t);var i=Math.pow(Math.random(),1/3);n[0]=n[0]*i,n[1]=n[1]*i,n[2]=n[2]*i},e._randomPointInsideHalfUnitBox=function(e){var t=e.elements;t[0]=Math.random()-.5,t[1]=Math.random()-.5,t[2]=Math.random()-.5},e}(),J=function(){function e(e){this._size=null,this.enbale=!1,this._size=e}r(e,"laya.d3.core.particleShuriKen.module.SizeOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._size.cloneTo(t._size),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"size",function(){return this._size}),e}(),ee=function(){function e(){this._type=0,this._constant=NaN,this._constantMin=NaN,this._constantMax=NaN}r(e,"laya.d3.core.particleShuriKen.module.StartFrame");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._constant=this._constant,t._constantMin=this._constantMin,t._constantMax=this._constantMax},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=1,i._constantMin=t,i._constantMax=n,i},e}(),te=function(){function e(e,t){this.tiles=null,this.type=0,this.randomRow=!1,this.frame=null,this.startFrame=null,this.cycles=0,this.enableUVChannels=0,this.enbale=!1,this.tiles=new Ke(1,1),this.type=0,this.randomRow=!0,this.cycles=1,this.enableUVChannels=1,this.frame=e,this.startFrame=t}r(e,"laya.d3.core.particleShuriKen.module.TextureSheetAnimation");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this.tiles.clone(t.tiles),t.type=this.type,t.randomRow=this.randomRow,this.frame.cloneTo(t.frame),this.startFrame.cloneTo(t.startFrame),t.cycles=this.cycles,t.enableUVChannels=this.enableUVChannels,t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e}(),ne=function(){function e(e){this._velocity=null,this.enbale=!1,this.space=0,this._velocity=e}r(e,"laya.d3.core.particleShuriKen.module.VelocityOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._velocity.cloneTo(t._velocity),t.enbale=this.enbale,t.space=this.space},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"velocity",function(){return this._velocity}),e}(),ie=function(){function e(){this.startLifeTime=NaN,this.position=null,this.direction=null,this.startColor=null,this.startSize=null,this.startRotation0=null,this.startRotation1=null,this.startRotation2=null,this.time=NaN,this.startSpeed=NaN,this.startUVInfo=null,this.simulationWorldPostion=null}return r(e,"laya.d3.core.particleShuriKen.ShurikenParticleData"),e._getStartLifetimeFromGradient=function(e,t){for(var n=1,i=e.gradientCount;i>n;n++){var r=e.getKeyByIndex(n);if(r>=t){var a=e.getKeyByIndex(n-1),s=(t-a)/(r-a);return x.lerp(e.getValueByIndex(n-1),e.getValueByIndex(n),s)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")},e.create=function(t,n,i,r,a,s){var o=new e;switch(o.position=i,x.scaleVector3(r,1,e._tempDirection),o.direction=e._tempDirection,o.startColor=e._tempStartColor,t.startColorType){case 0:var l=o.startColor,h=t.startColorConstant.elements;l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3];break;case 2:x.lerpVector4(t.startColorConstantMin.elements,t.startColorConstantMax.elements,Math.random(),o.startColor)}var u=t.colorOverLifetime;if(u&&u.enbale){var c=o.startColor,_=u.color;switch(_.type){case 0:c[0]=c[0]*_.constant.x,c[1]=c[1]*_.constant.y,c[2]=c[2]*_.constant.z,c[3]=c[3]*_.constant.w;break;case 2:var d=Math.random(),m=_.constantMin,f=_.constantMax;c[0]=c[0]*x.lerp(m.x,f.x,d),c[1]=c[1]*x.lerp(m.y,f.y,d),c[2]=c[2]*x.lerp(m.z,f.z,d),c[3]=c[3]*x.lerp(m.w,f.w,d)}}o.startSize=e._tempStartSize;var p=o.startSize;switch(t.startSizeType){case 0:if(t.threeDStartSize){var v=t.startSizeConstantSeparate;p[0]=v.x,p[1]=v.y,p[2]=v.z}else p[0]=p[1]=p[2]=t.startSizeConstant;break;case 2:if(t.threeDStartSize){var g=t.startSizeConstantMinSeparate,T=t.startSizeConstantMaxSeparate;p[0]=x.lerp(g.x,T.x,Math.random()),p[1]=x.lerp(g.y,T.y,Math.random()),p[2]=x.lerp(g.z,T.z,Math.random())}else p[0]=p[1]=p[2]=x.lerp(t.startSizeConstantMin,t.startSizeConstantMax,Math.random())}var M=t.sizeOverLifetime;if(M&&M.enbale&&1===M.size.type){var E=M.size;if(E.separateAxes)p[0]=p[0]*x.lerp(E.constantMinSeparate.x,E.constantMaxSeparate.x,Math.random()),p[1]=p[1]*x.lerp(E.constantMinSeparate.y,E.constantMaxSeparate.y,Math.random()),p[2]=p[2]*x.lerp(E.constantMinSeparate.z,E.constantMaxSeparate.z,Math.random());else{var y=x.lerp(E.constantMin,E.constantMax,Math.random());p[0]=p[0]*y,p[1]=p[1]*y,p[2]=p[2]*y}}var S,R,A,I;switch(t.startRotationType){case 0:if(t.threeDStartRotation&&1!==n.renderMode&&1!==n.renderMode){var C=t.startRotationConstantSeparate;je.createRotationYawPitchRoll(C.y,C.x,C.z,e._tempRotationMatrix),I=e._tempRotationMatrix.elements,o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=I[0],S[1]=I[1],S[2]=I[2],o.startRotation1=e._tempStartRotation1,R=o.startRotation1,R[0]=I[4],R[1]=I[5],R[2]=I[6],o.startRotation2=e._tempStartRotation2,A=o.startRotation2,A[0]=I[8],A[1]=I[9],A[2]=I[10]}else o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=S[1]=S[2]=t.startRotationConstant;break;case 2:if(t.threeDStartRotation&&1!==n.renderMode&&2!==n.renderMode){o.startRotation0=e._tempStartRotation0,S=o.startRotation0;var V=t.startRotationConstantMinSeparate,D=t.startRotationConstantMaxSeparate;je.createRotationYawPitchRoll(x.lerp(V.y,D.y,Math.random()),x.lerp(V.x,D.x,Math.random()),x.lerp(V.z,D.z,Math.random()),e._tempRotationMatrix),I=e._tempRotationMatrix.elements,o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=I[0],S[1]=I[1],S[2]=I[2],o.startRotation1=e._tempStartRotation1,R=o.startRotation1,R[0]=I[4],R[1]=I[5],R[2]=I[6],o.startRotation2=e._tempStartRotation2,A=o.startRotation2,A[0]=I[8],A[1]=I[9],A[2]=I[10]}else o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=S[1]=S[2]=x.lerp(t.startRotationConstantMin,t.startRotationConstantMax,Math.random())}switch(Math.random()=this._maxParticles&&(this._firstActiveElement=0)}},t._freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*4+27];if(this.isPerformanceMode&&3>e)break;this._firstRetiredElement++,this._firstRetiredElement>=this._maxParticles&&(this._firstRetiredElement=0)}},t._setPartVertexDatas=function(e,t,n,i){for(var r=0;r=this._firstRetiredElement?this._aliveParticleCount=this._firstNewElement-this._firstRetiredElement:this._aliveParticleCount=this._maxParticles-this._firstRetiredElement+this._firstNewElement},t.addParticle=function(e,t,n){Qe.normalize(t,t);var i=e.elements,r=t.elements,a=this._firstFreeElement+1;if(a>=this._maxParticles&&(a=0),a===this._firstRetiredElement)return!1;var s=ie.create(this,this._owner.particleRender,i,r,this._currentTime,n),o=this._firstFreeElement*this._floatCountPerVertex*4,l=Math.random(),h=Math.random(),u=Math.random(),c=Math.random(),_=Math.random(),d=Math.random(),m=Math.random(),f=Math.random(),p=s.startUVInfo[0],v=s.startUVInfo[1],g=s.startUVInfo[2],T=s.startUVInfo[3];this._vertices[o+2]=g,this._vertices[o+3]=T+v,this._vertices[o+this._floatCountPerVertex+2]=g+p,this._vertices[o+this._floatCountPerVertex+3]=T+v,this._vertices[o+2*this._floatCountPerVertex+2]=g+p,this._vertices[o+2*this._floatCountPerVertex+3]=T,this._vertices[o+3*this._floatCountPerVertex+2]=g,this._vertices[o+3*this._floatCountPerVertex+3]=T;for(var x=0;4>x;x++){var M=o+x*this._floatCountPerVertex,E=0,y=0;for(E=0,y=4;3>E;E++)this._vertices[M+y+E]=s.position[E];for(E=0,y=7;3>E;E++)this._vertices[M+y+E]=s.direction[E];for(E=0,y=10;4>E;E++)this._vertices[M+y+E]=s.startColor[E];for(E=0,y=14;3>E;E++)this._vertices[M+y+E]=s.startSize[E];for(E=0,y=17;3>E;E++)this._vertices[M+y+E]=s.startRotation0[E];for(E=0,y=20;3>E;E++)this._vertices[M+y+E]=s.startRotation1[E];for(E=0,y=23;3>E;E++)this._vertices[M+y+E]=s.startRotation2[E];for(this._vertices[M+26]=s.startLifeTime,this._vertices[M+27]=s.time,this._vertices[M+28]=s.startSpeed,this._vertices[M+29]=l,this._vertices[M+30]=h,this._vertices[M+31]=u,this._vertices[M+32]=c,this._vertices[M+33]=_,this._vertices[M+34]=d,this._vertices[M+35]=m,this._vertices[M+36]=f,E=0,y=37;3>E;E++)this._vertices[M+y+E]=s.simulationWorldPostion[E]}return this._firstFreeElement=a,!0},t.addNewParticlesToVertexBuffer=function(){var e=0;this._firstNewElement0&&this._vertexBuffer.setData(this._vertices,0,0,4*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},t._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer._bind(),this._indexBuffer._bind(),!0):!1},t._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement0&&(t=6*this._firstFreeElement,n.drawElements(4,t,5123,0),L.trianglesFaces+=t/3,L.drawCall++))},a(0,t,"currentTime",function(){return this._currentTime}),a(0,t,"indexOfHost",function(){return 0}),a(0,t,"maxParticles",function(){return this._maxParticles-1},function(e){var t=e+1;t!==this._maxParticles&&(this._maxParticles=t,this._vertexBuffer&&(this._vertexBuffer.dispose(),this._indexBuffer.dispose()),this._initPartVertexDatas(),this._initIndexDatas())}),a(0,t,"isAlive",function(){return!!(this._emission.isPlaying||this._aliveParticleCount>0)}),a(0,t,"shape",function(){return this._shape},function(e){this._shape=e,this._emission._shape=e}),a(0,t,"emission",function(){return this._emission},function(e){this._emission=e,e._particleSystem=this,e._shape=this._shape}),a(0,t,"aliveParticleCount",function(){return this._aliveParticleCount}),a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),e}(),ae=(function(){function e(){this._tempInt0=0,this._tempInt1=0,this._tempUint0=0,this._tempUint1=0,this._tempUint2=0,this._tempUint3=0,this._tempUint4=0,this._tempUint5=0,this._tempUint6=0,this._tempUint7=0,this._tempNumver0=NaN,this._tempNumver1=NaN,this._tempNumver2=NaN,this._tempNumver3=NaN,this._floatSizePerVer=7,this._defaultBufferSize=600*this._floatSizePerVer,this._vb=null,this._posInVBData=0,this._ib=null,this._posInIBData=0,this._primitiveType=NaN,this._hasBegun=!1,this._numVertsPerPrimitive=0,this._renderState=null,this._sharderNameID=0,this._shader=null,this._posShaderValue=[3,5126,!1,28,0],this._colorShaderValue=[4,5126,!1,28,12],this._albedo=new $e(1,1,1,1),this._vbData=new Float32Array(this._defaultBufferSize),this._ibData=new Uint16Array(this._defaultBufferSize),this._wvpMatrix=new je,this._vb=new P(-1,35048),this._ib=new v,this._sharderNameID=C.nameKey.get("SIMPLE")}r(e,"laya.d3.core.PhasorSpriter3D");var t=e.prototype;return t.line=function(e,t,n,i,r,a,s,o,l,h,u,c,_,d){return this._hasBegun&&1===this._primitiveType||this.drawLinesException(),(this._posInVBData+2*this._floatSizePerVer>this._vbData.length||this._posInIBData+2>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e,t,n,i,r,a,s),this.addVertex(o,l,h,u,c,_,d),this.addIndexes(this._tempUint0,this._tempUint0+1),this},t.circle=function(e,t,n,i,r,a){for(this._hasBegun&&1===this._primitiveType||this.drawLinesException(),this._tempUint0=2*t,(this._posInVBData+this._tempUint0*this._floatSizePerVer>this._vbData.length||this._posInIBData+2*this._tempUint0>this._ibData.length)&&this.flush(),this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=0,this._tempInt0=0;this._tempNumver0<6.2832;this._tempNumver0=this._tempNumver0+3.1416/t,this._tempInt0++)this.addVertex(Math.sin(this._tempNumver0)*e,Math.cos(this._tempNumver0)*e,0,n,i,r,a),0===this._tempInt0?this.addIndexes(this._tempUint1):this._tempInt0===this._tempUint0-1?(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2,this._tempUint1)):(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2));return this},t.plane=function(e,t,n,i,r,a,s,o,l){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+4*this._floatSizePerVer>this._vbData.length||this._posInIBData+6>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n,a,s,o,l),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n,a,s,o,l),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n,a,s,o,l),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n,a,s,o,l),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint0+3),this},t.box=function(e,t,n,i,r,a,s,o,l,h){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+8*this._floatSizePerVer>this._vbData.length||this._posInIBData+36>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempNumver2=a/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,s,o,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint3,this._tempUint4,this._tempUint5,this._tempUint6,this._tempUint6,this._tempUint5,this._tempUint7,this._tempUint5,this._tempUint0,this._tempUint7,this._tempUint7,this._tempUint0,this._tempUint2,this._tempUint1,this._tempUint4,this._tempUint3,this._tempUint3,this._tempUint4,this._tempUint6,this._tempUint5,this._tempUint4,this._tempUint0,this._tempUint0,this._tempUint4,this._tempUint1,this._tempUint2,this._tempUint3,this._tempUint7,this._tempUint7,this._tempUint3,this._tempUint6),this},t.cone=function(e,t,n,i,r,a,s){for(this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+(2*n+2)*this._floatSizePerVer>this._vbData.length||this._posInIBData+6*n>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData,this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=2*Math.PI/n,this.addVertexIndex(0,t,0,i,r,a,s,this._tempUint0),this.addVertexIndex(0,0,0,i,r,a,s,this._tempUint0+this._floatSizePerVer),this._tempInt0=2,this._tempNumver1=0,this._tempInt1=0;this._tempInt1this._vbData.length||this._posInIBData+48>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e,r,a,s,o,l,h),this.addVertex(i,r,a,s,o,l,h),this.addVertex(e,t,a,s,o,l,h),this.addVertex(i,t,a,s,o,l,h),this.addVertex(i,r,n,s,o,l,h),this.addVertex(e,r,n,s,o,l,h),this.addVertex(i,t,n,s,o,l,h),this.addVertex(e,t,n,s,o,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint1,this._tempUint3,this._tempUint3,this._tempUint2,this._tempUint2,this._tempUint0,this._tempUint4,this._tempUint5,this._tempUint5,this._tempUint7,this._tempUint7,this._tempUint6,this._tempUint6,this._tempUint4,this._tempUint5,this._tempUint0,this._tempUint0,this._tempUint2,this._tempUint2,this._tempUint7,this._tempUint7,this._tempUint5,this._tempUint1,this._tempUint4,this._tempUint4,this._tempUint6,this._tempUint6,this._tempUint3,this._tempUint3,this._tempUint1,this._tempUint5,this._tempUint4,this._tempUint4,this._tempUint1,this._tempUint1,this._tempUint0,this._tempUint0,this._tempUint5,this._tempUint2,this._tempUint3,this._tempUint3,this._tempUint6,this._tempUint6,this._tempUint7,this._tempUint7,this._tempUint2),this},t.addVertex=function(e,t,n,i,r,a,s){return this._hasBegun||this.addVertexIndexException(),this._vbData[this._posInVBData]=e,this._vbData[this._posInVBData+1]=t,this._vbData[this._posInVBData+2]=n,this._vbData[this._posInVBData+3]=i,this._vbData[this._posInVBData+4]=r,this._vbData[this._posInVBData+5]=a,this._vbData[this._posInVBData+6]=s,this._posInVBData+=this._floatSizePerVer,this},t.addVertexIndex=function(e,t,n,i,r,a,s,o){return this._hasBegun||this.addVertexIndexException(),this._vbData[o]=e,this._vbData[o+1]=t,this._vbData[o+2]=n,this._vbData[o+3]=i,this._vbData[o+4]=r,this._vbData[o+5]=a,this._vbData[o+6]=s,o+=this._floatSizePerVer,o>this._posInVBData&&(this._posInVBData=o),this},t.addIndexes=function(e){var t=arguments;this._hasBegun||this.addVertexIndexException();for(var n=0;nm;m+=d){var p=m+s;rt.transformVector3ArrayToVector3ArrayCoordinate(r,p,c,r,p),rt.transformVector3ArrayByQuat(r,o,_,r,o)}return r},t.getDynamicBatchBakedVertexs=function(e){for(var t=4,n=this._renderObj._getVertexBuffer(e),i=n.getData().slice(),r=n.vertexDeclaration,a=r.getVertexElementByUsage("POSITION").offset/t,s=r.getVertexElementByUsage("NORMAL").offset/t,o=this._sprite3D.transform,l=o.worldMatrix,h=o.rotation,u=r.vertexStride/t,c=0,_=i.length;_>c;c+=u){var d=c+a;rt.transformVector3ArrayToVector3ArrayCoordinate(i,d,l,i,d),rt.transformVector3ArrayByQuat(i,s,h,i,s)}return i},t.getBakedIndices=function(){return this._renderObj._getIndexBuffer().getData()},a(0,t,"renderObj",function(){return this._renderObj},function(e){this._renderObj!==e&&(this._renderObj=e)}),i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempQuaternion0",function(){return this._tempQuaternion0=new Ze},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je}]),e}(),oe=function(){function e(t,n){this._id=0,this._needSort=!1,this._renderElements=null,this._staticBatches=null,this._renderableRenderObjects=null,this._renderConfig=null,this._staticBatchCombineRenderElements=null,this._dynamicBatchCombineRenderElements=null,this._finalElements=null,this._scene=null,this._id=++e._uniqueIDCounter,this._needSort=!1,this._renderConfig=t,this._scene=n,this._renderElements=[],this._renderableRenderObjects=[],this._staticBatchCombineRenderElements=[],this._dynamicBatchCombineRenderElements=[],this._staticBatches=[]}r(e,"laya.d3.core.render.RenderQueue");var t=e.prototype;return t._sortAlphaFunc=function(t,n){return t._renderObject&&n._renderObject?Qe.distance(n._renderObject._boundingSphere.center,e._cameraPosition)-Qe.distance(t._renderObject._boundingSphere.center,e._cameraPosition):0},t._begainRenderElement=function(e,t,n){return t._beforeRender(e)?(e.shaderValue.pushArray(t._getVertexBuffer(0).vertexDeclaration.shaderValues),!0):!1},t._endRenderElement=function(e,t,n){n._upload(e,t._getVertexBuffer(0).vertexDeclaration,null),t._render(e)},t._preRenderUpdateComponents=function(e,t){for(var n=0;nt;t++)this._staticBatches[t]._getRenderElement(this._staticBatchCombineRenderElements);this._finalElements=this._renderElements.concat(this._staticBatchCombineRenderElements,this._dynamicBatchCombineRenderElements)},t._render=function(e){for(var t=e.shaderValue.length,n=e.shaderDefines.getValue(),i=0,r=this._finalElements.length;r>i;i++){var a,s,o=this._finalElements[i];if(0===o._type){var l=o._sprite3D;e.owner=l,e.renderElement=o,this._preRenderUpdateComponents(l,e),a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(s._setLoopShaderParams(e,e.projectionViewMatrix,l.transform.worldMatrix,o.renderObj,s),this._endRenderElement(e,a,s)),this._postRenderUpdateComponents(l,e)}else if(1===o._type){var h=o.renderObj;e.owner=null,e.renderElement=o,e._batchIndexStart=o._batchIndexStart,e._batchIndexEnd=o._batchIndexEnd,a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(o._material._setLoopShaderParams(e,e.projectionViewMatrix,h._rootSprite.transform.worldMatrix,o.renderObj,o._material),this._endRenderElement(e,a,s))}else if(2===o._type){o.renderObj;e.owner=null,e.renderElement=o,e._batchIndexStart=o._batchIndexStart,e._batchIndexEnd=o._batchIndexEnd,a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(o._material._setLoopShaderParams(e,e.projectionViewMatrix,je.DEFAULT,o.renderObj,o._material),this._endRenderElement(e,a,s))}e.shaderDefines.setValue(n),e.shaderValue.length=t}},t._clearRenderElements=function(){this._staticBatches.length=0,this._dynamicBatchCombineRenderElements.length=0,this._renderElements.length=0,this._needSort=!0},t._addRenderElement=function(e){this._renderElements.push(e),this._needSort=!0},t._addStaticBatch=function(e){this._staticBatches.push(e)},t._addDynamicBatchElement=function(e){this._dynamicBatchCombineRenderElements.push(e)},a(0,t,"id",function(){return this._id}),e._uniqueIDCounter=0,e.OPAQUE=1,e.OPAQUE_DOUBLEFACE=2,e.ALPHA_BLEND=3,e.ALPHA_BLEND_DOUBLEFACE=4,e.ALPHA_ADDTIVE_BLEND=5,e.ALPHA_ADDTIVE_BLEND_DOUBLEFACE=6,e.DEPTHREAD_ALPHA_BLEND=7,e.DEPTHREAD_ALPHA_BLEND_DOUBLEFACE=8,e.DEPTHREAD_ALPHA_ADDTIVE_BLEND=9,e.DEPTHREAD_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=10,e.NONDEPTH_ALPHA_BLEND=11,e.NONDEPTH_ALPHA_BLEND_DOUBLEFACE=12,e.NONDEPTH_ALPHA_ADDTIVE_BLEND=13,e.NONDEPTH_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=14,e._cameraPosition=null,e}(),le=function(){function e(){this.elapsedTime=NaN,this.loopCount=0,this.context=null,this.scene=null,this.owner=null,this.renderElement=null,this._staticBatch=null,this._batchIndexStart=0,this._batchIndexEnd=0,this.camera=null,this.viewMatrix=null,this.projectionMatrix=null,this.projectionViewMatrix=null,this.cameraBoundingFrustum=null,this.viewport=null,this.shaderValue=new b,this.shaderDefines=new ct,this.reset()}r(e,"laya.d3.core.render.RenderState");var t=e.prototype;return t.reset=function(){this.shaderValue.length=0,this.shaderDefines.setValue(0)},e.VERTEXSHADERING=4,e.PIXELSHADERING=8,e.clientWidth=0,e.clientHeight=0,e}(),he=function(){function e(e){this._vertexDeclaration=null,this._vertexDatas=null,this._indexDatas=null,this._vertexBuffer=null,this._indexBuffer=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._combineRenderElements=null,this._materials=null,this._materialToRenderElementsOffsets=null,this._merageElements=null,this._combineRenderElementPool=null,this._combineRenderElementPoolIndex=0,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._combineRenderElements=[],this._materialToRenderElementsOffsets=[],this._materials=[],this._merageElements=[],this._combineRenderElementPool=[],this._combineRenderElementPoolIndex=0,this._vertexDeclaration=e}r(e,"laya.d3.graphics.DynamicBatch");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._getCombineRenderElementFromPool=function(){var e=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return e||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new se)},t._getRenderElement=function(){this._vertexDatas||(this._vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride/4*e.maxVertexCount), +this._indexDatas=new Uint16Array(e.maxIndexCount),this._vertexBuffer=Bt.create(this._vertexDeclaration,e.maxVertexCount,35048),this._indexBuffer=Nt.create("ushort",e.maxIndexCount,35048)),this._merageElements.length=0;for(var t=0,n=0,i=0,r=this._combineRenderElements.length;r>i;i++){var a=this._combineRenderElements[i],s=a.getDynamicBatchBakedVertexs(0),o=a.getBakedIndices(),l=t/(this._vertexDeclaration.vertexStride/4),h=n,u=h+o.length;a._batchIndexStart=h,a._batchIndexEnd=u,this._indexDatas.set(o,n);for(var c=h;u>c;c++)this._indexDatas[c]=l+this._indexDatas[c];n+=o.length,this._vertexDatas.set(s,t),t+=s.length}for(this._vertexBuffer.setData(this._vertexDatas),this._indexBuffer.setData(this._indexDatas),this._combineRenderElementPoolIndex=0,i=0,r=this._materials.length;r>i;i++){var _=this._getCombineRenderElementFromPool();_._type=2,_._staticBatch=null,_.renderObj=this;var d=this._combineRenderElements[this._materialToRenderElementsOffsets[i]]._batchIndexStart,m=i+1===this._materialToRenderElementsOffsets.length?n:this._combineRenderElements[this._materialToRenderElementsOffsets[i+1]]._batchIndexStart;_._batchIndexStart=d,_._batchIndexEnd=m,_._material=this._materials[i],this._merageElements.push(_)}},t._addCombineRenderObjTest=function(t){var n=t.renderObj,i=this._currentCombineIndexCount+n._getIndexBuffer().indexCount,r=this._currentCombineVertexCount+n._getVertexBuffer().vertexCount;return!(r>e.maxVertexCount||i>e.maxIndexCount)},t._addCombineRenderObj=function(e){var t=e.renderObj;this._combineRenderElements.push(e),this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount},t._addCombineMaterial=function(e){this._materials.push(e)},t._addMaterialToRenderElementOffset=function(e){this._materialToRenderElementsOffsets.push(e)},t._clearRenderElements=function(){this._combineRenderElements.length=0,this._materials.length=0,this._materialToRenderElementsOffsets.length=0,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0},t._addToRenderQueue=function(e){this._getRenderElement();for(var t=0,n=this._materials.length;n>t;t++)e.getRenderQueue(this._materials[t].renderQueue)._addDynamicBatchElement(this._merageElements[t])},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;e.context.drawElements(4,t,5123,2*e._batchIndexStart),L.drawCall++,L.trianglesFaces+=t/3},a(0,t,"indexOfHost",function(){return 0}),a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),a(0,t,"combineRenderElementsCount",function(){return this._combineRenderElements.length}),e.maxVertexCount=2e4,e.maxIndexCount=4e4,e.maxCombineTriangleCount=50,e}(),ue=function(){function e(){this._dynamicBatches=null,this._prepareDynamicBatchCombineElements=null,this._dynamicBatches={},this._prepareDynamicBatchCombineElements=[]}r(e,"laya.d3.graphics.DynamicBatchManager");var t=e.prototype;return t.getDynamicBatch=function(e,t){var n,i=e.id.toString()+t;return this._dynamicBatches[i]?n=this._dynamicBatches[i]:this._dynamicBatches[i]=n=new he(e),n},t._garbageCollection=function(){for(var e in this._dynamicBatches)0===this._dynamicBatches[e].combineRenderElementsCount&&delete this._dynamicBatches[e]},t._addPrepareRenderElement=function(e){this._prepareDynamicBatchCombineElements.push(e)},t._finishCombineDynamicBatch=function(t){this._prepareDynamicBatchCombineElements.sort(e._sortPrepareDynamicBatch);for(var n,i,r,a,s,o,l,h,u=-1,c=!0,_=0,d=-1,m=0,f=this._prepareDynamicBatchCombineElements.length;f>m;m++){s=this._prepareDynamicBatchCombineElements[m];var p=s.renderObj._getVertexBuffer(0).vertexDeclaration,v=i!==p;v&&(_=0,i=p);var g=_!==u;if(g&&(u=_),(v||g)&&(o=this.getDynamicBatch(p,_),n=null),c)if(o._addCombineRenderObjTest(s)){if(a=s._material,n!==a)l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),l=a,d=o.combineRenderElementsCount,h=s,n=a;else if(l){var T=h.renderObj,x=s.renderObj;T._getVertexBuffer().vertexCount+x._getVertexBuffer().vertexCount>he.maxVertexCount||T._getIndexBuffer().indexCount+x._getIndexBuffer().indexCount>he.maxIndexCount?(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=a,d=o.combineRenderElementsCount,h=s):(o._addCombineMaterial(l),o._addMaterialToRenderElementOffset(d),o._addCombineRenderObj(h),l=null,h=null,d=-1,o._addCombineRenderObj(s))}else o._addCombineRenderObj(s);c=!0}else l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),_++,c=!1;else r=this._prepareDynamicBatchCombineElements[m-1],o._addMaterialToRenderElementOffset(o.combineRenderElementsCount),n=r._material,o._addCombineMaterial(n),o._addCombineRenderObj(r),c=!0,a=s._material,n!==a?(l=a,d=o.combineRenderElementsCount,h=s):o._addCombineRenderObj(s),n=a}l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),this._prepareDynamicBatchCombineElements.length=0},t._clearRenderElements=function(){for(var e in this._dynamicBatches)this._dynamicBatches[e]._clearRenderElements()},t._addToRenderQueue=function(e){for(var t in this._dynamicBatches){var n=this._dynamicBatches[t];n.combineRenderElementsCount>0&&n._addToRenderQueue(e)}},t.dispose=function(){this._dynamicBatches=null},e._sortPrepareDynamicBatch=function(e,t){return e._mainSortID-t._mainSortID},e}(),ce=function(){function e(){}return r(e,"laya.d3.graphics.FrustumCulling"),e.RenderObjectCulling=function(e,t){var n,i,r=0,a=0,s=0,o=0,l=t._quenes,h=t._staticBatchManager,u=t._dynamicBatchManager,c=t._frustumCullingObjects;for(r=0,a=l.length;a>r;r++)l[r]&&l[r]._clearRenderElements();for(h._clearRenderElements(),u._clearRenderElements(),r=0,a=c.length;a>r;r++)if(n=c[r],U.isVisible(n._layerMask)&&n._ownerEnable&&n._enable&&0!==e.ContainsBoundSphere(n._boundingSphere))for(s=0,o=n._renderElements.length;o>s;s++){i=n._renderElements[s];var _=i._staticBatch;if(_&&_._material===i._material)_._addRenderElement(i);else{var d=i.renderObj;d.triangleCount<50&&1===d._vertexBufferCount&&d._getIndexBuffer()&&i._material.renderQueue<3&&i._canDynamicBatch?u._addPrepareRenderElement(i):t.getRenderQueue(i._material.renderQueue)._addRenderElement(i)}}h._addToRenderQueue(t),u._finishCombineDynamicBatch(t),u._addToRenderQueue(t)},e}(),_e=function(){function e(){this._render=null,this._renderElements=null,this._layerMask=0,this._ownerEnable=!1,this._enable=!1,this._renderElements=[]}r(e,"laya.d3.graphics.RenderObject");var t=e.prototype;return a(0,t,"_boundingSphere",function(){return this._render.boundingSphere}),e}(),de=function(){function e(e,t,n){this._vertexBuffer=null,this._indexBuffer=null,this._renderElements=null,this._combineRenderElementPool=null,this._combineRenderElementPoolIndex=0,this._combineRenderElements=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._needFinishCombine=!1,this._rootSprite=null,this._vertexDeclaration=null,this._material=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._needFinishCombine=!1,this._renderElements=[],this._combineRenderElements=[],this._combineRenderElementPool=[],this._combineRenderElementPoolIndex=0,this._rootSprite=e,this._vertexDeclaration=t,this._material=n}r(e,"laya.d3.graphics.StaticBatch");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._getCombineRenderElementFromPool=function(){var e=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return e||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new se)},t._addCombineRenderObjTest=function(t){var n=t.renderObj,i=this._currentCombineVertexCount+n._getVertexBuffer().vertexCount;return!(i>e.maxVertexCount)},t._addCombineRenderObj=function(e){var t=e.renderObj;this._combineRenderElements.push(e),e._staticBatch=this,this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount,this._needFinishCombine=!0},t._deleteCombineRenderObj=function(e){var t=e.renderObj,n=this._combineRenderElements.indexOf(e);-1!==n&&(this._combineRenderElements.splice(n,1),e._staticBatch=null,this._currentCombineIndexCount=this._currentCombineIndexCount-t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-t._getVertexBuffer().vertexCount,this._needFinishCombine=!0)},t._finshCombine=function(){if(this._needFinishCombine){var e=0,t=0,n=new Float32Array(this._vertexDeclaration.vertexStride/4*this._currentCombineVertexCount),i=new Uint16Array(this._currentCombineIndexCount);this._vertexBuffer&&(this._vertexBuffer.dispose(),this._indexBuffer.dispose()),this._vertexBuffer=Bt.create(this._vertexDeclaration,this._currentCombineVertexCount,35044),this._indexBuffer=Nt.create("ushort",this._currentCombineIndexCount,35044);for(var r=0,a=this._combineRenderElements.length;a>r;r++){var s=this._combineRenderElements[r],o=s.getStaticBatchBakedVertexs(0),l=s.getBakedIndices(),h=e/(this._vertexDeclaration.vertexStride/4),u=t,c=u+l.length;s._batchIndexStart=u,s._batchIndexEnd=c,i.set(l,t);for(var _=u;c>_;_++)i[_]=h+i[_];t+=l.length,n.set(o,e),e+=o.length}this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this._needFinishCombine=!1}},t._clearRenderElements=function(){this._renderElements.length=0},t._addRenderElement=function(e){for(var t=0,n=this._renderElements.length;n>t;t++)if(this._renderElements[t]._batchIndexStart>e._batchIndexStart)return void this._renderElements.splice(t,0,e);this._renderElements.push(e)},t._getRenderElement=function(e){this._combineRenderElementPoolIndex=0;var t=this._renderElements.length,n=this._getCombineRenderElementFromPool();if(n._type=1,n._staticBatch=null,n.renderObj=this,n._batchIndexStart=this._renderElements[0]._batchIndexStart,n._batchIndexEnd=this._renderElements[0]._batchIndexEnd,n._material=this._material,n._material=this._material,e.push(n),t>1)for(var i=1;t>i;i++){var r=this._renderElements[i];this._renderElements[i-1]._batchIndexEnd!==r._batchIndexStart?(n=this._getCombineRenderElementFromPool(),n._type=1,n._staticBatch=null,n.renderObj=this,n._batchIndexStart=r._batchIndexStart,n._batchIndexEnd=r._batchIndexEnd,n._material=this._material,e.push(n)):n._batchIndexEnd=r._batchIndexEnd}},t._addToRenderQueue=function(e){this._renderElements.length>0&&e.getRenderQueue(this._material.renderQueue)._addStaticBatch(this)},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;e.context.drawElements(4,t,5123,2*e._batchIndexStart),L.drawCall++,L.trianglesFaces+=t/3},a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"indexOfHost",function(){return 0}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),e._addToRenderQueueStaticBatch=function(t,n){var i=0,r=0;if(n instanceof laya.d3.core.MeshSprite3D&&n.isStatic){var a=n.meshRender.renderObject._renderElements;for(i=0,r=a.length;r>i;i++){var s=a[i];1===s.renderObj._vertexBufferCount&&t._staticBatchManager._addPrepareRenderElement(s)}}for(i=0,r=n.numChildren;r>i;i++)e._addToRenderQueueStaticBatch(t,n._childs[i])},e.combine=function(t){var n=t.scene;if(!n)throw new Error("BaseScene: staticBatchRoot is not a part of scene.");e._addToRenderQueueStaticBatch(n,t),n._staticBatchManager._finishCombineStaticBatch(t)},e.maxVertexCount=65535,e}(),me=function(){function e(){this._staticBatches=null,this._prepareStaticBatchCombineElements=null,this._staticBatches={},this._prepareStaticBatchCombineElements=[]}r(e,"laya.d3.graphics.StaticBatchManager");var t=e.prototype;return t._finshCombine=function(){for(var e in this._staticBatches)this._staticBatches[e]._finshCombine()},t.getStaticBatch=function(e,t,n,i){var r,a=e.id.toString()+n.id.toString()+t.id.toString()+i;return this._staticBatches[a]?r=this._staticBatches[a]:this._staticBatches[a]=r=new de(e,t,n),r},t._garbageCollection=function(){for(var e in this._staticBatches)0===this._staticBatches[e].combineRenderElementsCount&&delete this._staticBatches[e]},t._addPrepareRenderElement=function(e){this._prepareStaticBatchCombineElements.push(e)},t._finishCombineStaticBatch=function(t){this._prepareStaticBatchCombineElements.sort(e._sortPrepareStaticBatch);for(var n,i,r,a,s,o,l,h=!1,u=0,c=0,_=this._prepareStaticBatchCombineElements.length;_>c;c++){if(a=this._prepareStaticBatchCombineElements[c],o=a.renderObj._getVertexBuffer(0),i===o.vertexDeclaration&&n===a._material)if(h)r._addCombineRenderObjTest(a)?(l=a._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(a),r._addCombineRenderObj(a)):(h=!1,u++);else{s=this._prepareStaticBatchCombineElements[c-1];var d=s.renderObj,m=a.renderObj;d._getVertexBuffer().vertexCount+m._getVertexBuffer().vertexCount>de.maxVertexCount?h=!1:(r=this.getStaticBatch(t,i,n,u),l=s._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(s),r._addCombineRenderObj(s),l=a._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(a),r._addCombineRenderObj(a),h=!0)}else h=!1,u=0;n=a._material,i=o.vertexDeclaration}this._garbageCollection(),this._finshCombine(),this._prepareStaticBatchCombineElements.length=0},t._clearRenderElements=function(){for(var e in this._staticBatches)this._staticBatches[e]._clearRenderElements()},t._addToRenderQueue=function(e){for(var t in this._staticBatches)this._staticBatches[t]._addToRenderQueue(e)},t.dispose=function(){this._staticBatches=null},e._sortPrepareStaticBatch=function(e,t){var n=e._mainSortID-t._mainSortID;return 0===n?e.renderObj.triangleCount-t.renderObj.triangleCount:n},e}(),fe=function(){function e(t,n){if(this._id=0,this._shaderValues=null,this._shaderDefineValue=0,this._vertexStride=0,this._vertexElements=null,this._vertexElementsDic=null,this._id=++e._uniqueIDCounter,this._id>e.maxVertexDeclaration)throw new Error("VertexDeclaration: VertexDeclaration count should not large than ",e.maxVertexDeclaration);this._shaderValues=new b,this._vertexElementsDic={},this._vertexStride=t,this._vertexElements=n;for(var i=0;in&&(n=a)}return n},e._maxVertexDeclarationBit=1e3,e._uniqueIDCounter=1,i(e,["maxVertexDeclaration",function(){return this.maxVertexDeclaration=2147483647-1e3*Math.floor(2147483.647)}]),e}(),pe=function(){function e(e,t,n){this.offset=0,this.elementFormat=null,this.elementUsage=null,this.offset=e,this.elementFormat=t,this.elementUsage=n}return r(e,"laya.d3.graphics.VertexElement"),e}(),ve=(function(){function e(){}return r(e,"laya.d3.graphics.VertexElementFormat"),e.Single="single",e.Vector2="vector2",e.Vector3="vector3",e.Vector4="vector4",e.Color="color",e.Byte4="byte4",e.Short2="short2",e.Short4="short4",e.NormalizedShort2="normalizedshort2",e.NormalizedShort4="normalizedshort4",e.HalfVector2="halfvector2",e.HalfVector4="halfvector4",e}(),function(){function e(){}return r(e,"laya.d3.graphics.VertexElementUsage"),e.POSITION0="POSITION",e.COLOR0="COLOR",e.TEXTURECOORDINATE0="UV",e.NORMAL0="NORMAL",e.BINORMAL0="BINORMAL",e.TANGENT0="TANGENT0",e.BLENDINDICES0="BLENDINDICES",e.BLENDWEIGHT0="BLENDWEIGHT",e.DEPTH0="DEPTH",e.FOG0="FOG",e.POINTSIZE0="POINTSIZE",e.SAMPLE0="SAMPLE",e.TESSELLATEFACTOR0="TESSELLATEFACTOR",e.COLOR1="COLOR1",e.NEXTTEXTURECOORDINATE0="NEXTUV",e.TEXTURECOORDINATE1="UV1",e.NEXTTEXTURECOORDINATE1="NEXTUV1",e.CORNERTEXTURECOORDINATE0="CORNERTEXTURECOORDINATE",e.VELOCITY0="VELOCITY",e.STARTCOLOR0="STARTCOLOR",e.STARTSIZE="STARTSIZE",e.AGEADDSCALE0="AGEADDSCALE0",e.STARTROTATION0="STARTROTATION0",e.STARTROTATION1="STARTROTATION1",e.STARTROTATION2="STARTROTATION2",e.ENDCOLOR0="ENDCOLOR",e.SIZEROTATION0="SIZEROTATION",e.RADIUS0="RADIUS",e.RADIAN0="RADIAN",e.STARTLIFETIME="STARTLIFETIME",e.STARTSPEED="STARTSPEED",e.DIRECTION="DIRECTION",e.TIME0="TIME",e.RANDOM0="RANDOM0",e.RANDOM1="RANDOM1",e.SIMULATIONWORLDPOSTION="SIMULATIONWORLDPOSTION",e}(),function(){function e(e,t,n){this._position=null,this._textureCoordinate0=null,this._time=NaN,this._position=e,this._textureCoordinate0=t,this._time=n}r(e,"laya.d3.graphics.VertexGlitter");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate0}),a(0,t,"position",function(){return this._position}),a(0,t,"time",function(){return this._time}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(24,[new pe(0,"vector3","POSITION"),new pe(12,"vector2","UV"),new pe(20,"single","TIME")])}]),e}()),ge=function(){function e(e,t,n,i,r,a,s,o,l,h){this._cornerTextureCoordinate=null,this._position=null,this._velocity=null,this._startColor=null,this._endColor=null,this._sizeRotation=null,this._radius=null,this._radian=null,this._ageAddScale=NaN,this._time=NaN,this._cornerTextureCoordinate=e,this._position=t,this._velocity=n,this._startColor=i,this._endColor=r,this._sizeRotation=a,this._radius=s,this._radian=o,this._ageAddScale=l,this._time=h}r(e,"laya.d3.graphics.VertexParticle");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"endColor",function(){return this._endColor}),a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"sizeRotation",function(){return this._sizeRotation}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"position",function(){return this._position}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"radius",function(){return this._radius}),a(0,t,"radian",function(){return this._radian}),a(0,t,"ageAddScale",function(){return this._ageAddScale}),a(0,t,"time",function(){return this._time}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(116,[new pe(0,"vector4","CORNERTEXTURECOORDINATE"),new pe(16,"vector3","POSITION"),new pe(28,"vector3","VELOCITY"),new pe(40,"vector4","STARTCOLOR"),new pe(56,"vector4","ENDCOLOR"),new pe(72,"vector3","SIZEROTATION"),new pe(84,"vector2","RADIUS"),new pe(92,"vector4","RADIAN"),new pe(108,"single","STARTLIFETIME"),new pe(112,"single","TIME")])}]),e}(),Te=function(){function e(e,t,n,i,r,a,s,o,l,h,u,c,_,d){this._cornerTextureCoordinate=null,this._position=null,this._velocity=null,this._startColor=null,this._startSize=null,this._startRotation0=null,this._startRotation1=null,this._startRotation2=null,this._startLifeTime=NaN,this._time=NaN,this._startSpeed=NaN,this._randoms0=null,this._randoms1=null,this._simulationWorldPostion=null,this._cornerTextureCoordinate=e,this._position=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=s,this._startRotation2=o,this._startLifeTime=l,this._time=h,this._startSpeed=u,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=d}r(e,"laya.d3.graphics.VertexParticleShuriken");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"position",function(){return this._position}),a(0,t,"random0",function(){return this._randoms0}),a(0,t,"startSize",function(){return this._startSize}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"startRotation0",function(){return this._startRotation0}),a(0,t,"startRotation1",function(){return this._startRotation1}),a(0,t,"random1",function(){return this._randoms1}),a(0,t,"startRotation2",function(){return this._startRotation2}),a(0,t,"startLifeTime",function(){return this._startLifeTime}),a(0,t,"time",function(){return this._time}),a(0,t,"startSpeed",function(){return this._startSpeed}),a(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(160,[new pe(0,"vector4","CORNERTEXTURECOORDINATE"),new pe(16,"vector3","POSITION"),new pe(28,"vector3","DIRECTION"),new pe(40,"vector4","STARTCOLOR"),new pe(56,"vector3","STARTSIZE"),new pe(68,"vector3","STARTROTATION0"),new pe(80,"vector3","STARTROTATION1"),new pe(92,"vector3","STARTROTATION2"),new pe(104,"single","STARTLIFETIME"),new pe(108,"single","TIME"),new pe(112,"single","STARTSPEED"),new pe(116,"vector4","RANDOM0"),new pe(132,"vector4","RANDOM1"),new pe(148,"vector3","SIMULATIONWORLDPOSTION")])}]),e}(),xe=function(){function e(e,t,n){this._position=null,this._normal=null,this._color=null,this._position=e,this._normal=t,this._color=n}r(e,"laya.d3.graphics.VertexPositionNormalColor");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(40,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR")])}]),e}(),Me=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._blendIndex=i,this._blendWeight=r}r(e,"laya.d3.graphics.VertexPositionNormalColorSkin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(72,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES")])}]),e}(),Ee=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._color=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._tangent=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalColorSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(84,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES"),new pe(72,"vector3","TANGENT0")])}]),e}(),ye=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._color=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._tangent=i}r(e,"laya.d3.graphics.VertexPositionNormalColorTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(52,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector3","TANGENT0")])}]),e}(),Se=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(48,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV")])}]),e}(),Re=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(56,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1")])}]),e}(),Ae=function(){function e(e,t,n,i,r,a,s){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._blendIndex=a,this._blendWeight=s}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(88,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector4","BLENDWEIGHT"),new pe(72,"vector4","BLENDINDICES")])}]),e}(),Ie=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalColorTexture0SkinTangent=function(e,t,n,i,r,a,s,o){this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a,this._blendIndex=s,this._blendWeight=o},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(100,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector4","BLENDWEIGHT"),new pe(72,"vector4","BLENDINDICES"),new pe(88,"vector3","TANGENT0")])}]),e}(),Ce=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalColorTexture0Tangent=function(e,t,n,i,r,a){this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(68,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector3","TANGENT0")])}]),e}(),Ve=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkin"); +var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(80,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector4","BLENDWEIGHT"),new pe(64,"vector4","BLENDINDICES")])}]),e}(),De=function(){function e(e,t,n,i,r,a,s){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._tangent=r,this._blendIndex=a,this._blendWeight=s}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(92,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector4","BLENDWEIGHT"),new pe(64,"vector4","BLENDINDICES"),new pe(80,"vector3","TANGENT0")])}]),e}(),Le=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._tangent=r}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(60,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector3","TANGENT0")])}]),e}(),Oe=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}r(e,"laya.d3.graphics.VertexPositionNormalTexture");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(32,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV")])}]),e}(),be=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(40,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1")])}]),e}(),Pe=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(72,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES")])}]),e}(),we=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalTexture0SkinTangent=function(e,t,n,i,r,a,s){this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r,this._blendIndex=a,this._blendWeight=s},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(84,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES"),new pe(72,"vector3","TANGENT0")])}]),e}(),Ne=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalTexture0Tangent=function(e,t,n,i,r){this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(52,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector3","TANGENT0")])}]),e}(),Be=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._blendIndex=i,this._blendWeight=r}r(e,"laya.d3.graphics.VertexPositionNormalTextureSkin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(64,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector4","BLENDWEIGHT"),new pe(48,"vector4","BLENDINDICES")])}]),e}(),Fe=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._tangent=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalTextureSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(76,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector4","BLENDWEIGHT"),new pe(48,"vector4","BLENDINDICES"),new pe(64,"vector3","TANGENT0")])}]),e}(),Ue=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._textureCoordinate=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._tangent=i}r(e,"laya.d3.graphics.VertexPositionNormalTextureTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(44,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector3","TANGENT0")])}]),e}(),Ge=function(){function e(e,t,n,i){this._version=null,this._strings=["BLOCK","DATA","STRINGS"],this._materials=null,this._materialMap=null,this._fileData=null,this._readData=null,this._mesh=null,this._BLOCK={count:0},this._DATA={offset:0,size:0},this._STRINGS={offset:0,size:0},this._shaderAttributes=null,this._mesh=t,this._materials=n,this._materialMap=i,this._onLoaded(e)}r(e,"laya.d3.loaders.LoadModel");var t=e.prototype;return t._onLoaded=function(e){this._fileData=e,this._readData=new c(this._fileData),this._readData.pos=0,this._version=this._readData.readUTFString(),this.READ_BLOCK();for(var t=0;tt;t+=16){var s=new je(a[t+0],a[t+1],a[t+2],a[t+3],a[t+4],a[t+5],a[t+6],a[t+7],a[t+8],a[t+9],a[t+10],a[t+11],a[t+12],a[t+13],a[t+14],a[t+15]);this.mesh._bindPoses.push(s)}var o=this._readData.getUint32(),l=this._readData.getUint32(),h=new Float32Array(e.slice(o+this._DATA.offset,o+this._DATA.offset+l));for(this.mesh._inverseBindPoses=[],t=0,n=h.length;n>t;t+=16){var u=new je(h[t+0],h[t+1],h[t+2],h[t+3],h[t+4],h[t+5],h[t+6],h[t+7],h[t+8],h[t+9],h[t+10],h[t+11],h[t+12],h[t+13],h[t+14],h[t+15]);this.mesh._inverseBindPoses.push(u)}break;default:throw new Error("LoadModel:unknown version.")}return!0},t.READ_SUBMESH=function(){var t=(this._readString(),this._readData.getUint8(),this._readString());this._shaderAttributes=t.match(e._attrReg);var n=this._readData.getUint32(),i=this._readData.getUint32(),r=(this._readData.getUint32(),this._readData.getUint32(),this._readData.getUint32()),a=this._readData.getUint32(),s=this._readData.getUint32(),o=this._readData.getUint32(),l=this._readData.__getBuffer(),h=new et,u=this._getVertexDeclaration(),c=Bt.create(u,a/u.vertexStride,35044,!0),_=r+this._DATA.offset,d=l.slice(_,_+a);c.setData(new Float32Array(d)),h._vertexBuffer=c;for(var m=c.vertexDeclaration.getVertexElements(),f=0;fi;i++){switch(i){case 0:n=Xe.intersectsPlaneAndPoint(this._near,e);break;case 1:n=Xe.intersectsPlaneAndPoint(this._far,e);break;case 2:n=Xe.intersectsPlaneAndPoint(this._left,e);break;case 3:n=Xe.intersectsPlaneAndPoint(this._right,e);break;case 4:n=Xe.intersectsPlaneAndPoint(this._top,e);break;case 5:n=Xe.intersectsPlaneAndPoint(this._bottom,e)}switch(n){case We.PlaneIntersectionType_Back:return 0;case We.PlaneIntersectionType_Intersecting:t=We.PlaneIntersectionType_Intersecting}}switch(t){case We.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t.ContainsBoundBox=function(t){for(var n,i=1,r=0;6>r;r++){if(n=this.getPlane(r),this._getBoxToPlanePVertexNVertex(t,n.normal,e._tempV30,e._tempV31),Xe.intersectsPlaneAndPoint(n,e._tempV30)==We.PlaneIntersectionType_Back)return 0;Xe.intersectsPlaneAndPoint(n,e._tempV31)==We.PlaneIntersectionType_Back&&(i=2)}return i},t.ContainsBoundSphere=function(e){for(var t=We.PlaneIntersectionType_Front,n=We.PlaneIntersectionType_Front,i=0;6>i;i++){switch(i){case 0:n=Xe.intersectsPlaneAndSphere(this._near,e);break;case 1:n=Xe.intersectsPlaneAndSphere(this._far,e);break;case 2:n=Xe.intersectsPlaneAndSphere(this._left,e);break;case 3:n=Xe.intersectsPlaneAndSphere(this._right,e);break;case 4:n=Xe.intersectsPlaneAndSphere(this._top,e);break;case 5:n=Xe.intersectsPlaneAndSphere(this._bottom,e)}switch(n){case We.PlaneIntersectionType_Back:return 0;case We.PlaneIntersectionType_Intersecting:t=We.PlaneIntersectionType_Intersecting}}switch(t){case We.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t._getBoxToPlanePVertexNVertex=function(e,t,n,i){var r=e.min,a=r.elements,s=e.max,o=s.elements,l=t.elements,h=l[0],u=l[1],c=l[2];n=r;var _=n.elements;h>=0&&(_[0]=o[0]),u>=0&&(_[1]=o[1]),c>=0&&(_[2]=o[2]),i=s;var d=i.elements;h>=0&&(d[0]=a[0]),u>=0&&(d[1]=a[1]),c>=0&&(d[2]=a[2])},a(0,t,"top",function(){return this._top}),a(0,t,"matrix",function(){return this._matrix},function(t){this._matrix=t,e._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}),a(0,t,"near",function(){return this._near}),a(0,t,"far",function(){return this._far}),a(0,t,"left",function(){return this._left}),a(0,t,"right",function(){return this._right}),a(0,t,"bottom",function(){return this._bottom}),e._getPlanesFromMatrix=function(e,t,n,i,r,a,s){var o=e.elements,l=o[0],h=o[1],u=o[2],c=o[3],_=o[4],d=o[5],m=o[6],f=o[7],p=o[8],v=o[9],g=o[10],T=o[11],x=o[12],M=o[13],E=o[14],y=o[15],S=t.normal.elements;S[0]=u,S[1]=m,S[2]=g,t.distance=E,t.normalize();var R=n.normal.elements;R[0]=c-u,R[1]=f-m,R[2]=T-g,n.distance=y-E,n.normalize();var A=i.normal.elements;A[0]=c+l,A[1]=f+_,A[2]=T+p,i.distance=y+x,i.normalize();var I=r.normal.elements;I[0]=c-l,I[1]=f-_,I[2]=T-p,r.distance=y-x,r.normalize();var C=a.normal.elements;C[0]=c-h,C[1]=f-d,C[2]=T-v,a.distance=y-M,a.normalize();var V=s.normal.elements;V[0]=c+h,V[1]=f+d,V[2]=T+v,s.distance=y+M,s.normalize()},e.get3PlaneInterPoint=function(t,n,i){var r=t.normal,a=n.normal,s=i.normal;Qe.cross(a,s,e._tempV30),Qe.cross(s,r,e._tempV31),Qe.cross(r,a,e._tempV32);var o=Qe.dot(r,e._tempV30),l=Qe.dot(a,e._tempV31),h=Qe.dot(s,e._tempV32);Qe.scale(e._tempV30,-t.distance/o,e._tempV33),Qe.scale(e._tempV31,-n.distance/l,e._tempV34),Qe.scale(e._tempV32,-i.distance/h,e._tempV35),Qe.add(e._tempV33,e._tempV34,e._tempV36),Qe.add(e._tempV35,e._tempV36,e._tempV37);var u=e._tempV37;return u},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempV35",function(){return this._tempV35=new Qe},"_tempV36",function(){return this._tempV36=new Qe},"_tempV37",function(){return this._tempV37=new Qe}]),e}(),ke=function(){function e(e,t){this.center=null,this.radius=NaN,this.center=e,this.radius=t}r(e,"laya.d3.math.BoundSphere");var t=e.prototype;return t.toDefault=function(){this.center.toDefault(),this.radius=0},e.createFromSubPoints=function(t,n,i,r){if(null==t)throw new Error("points");if(0>n||n>=t.length)throw new Error("start"+n+"Must be in the range [0, "+(t.length-1)+"]");if(0>i||n+i>t.length)throw new Error("count"+i+"Must be in the range <= "+t.length+"}");var a=n+i,s=e._tempVector3;s.elements[0]=0,s.elements[1]=0,s.elements[2]=0;for(var o=n;a>o;++o)Qe.add(t[o],s,s);var l=r.center;Qe.scale(s,1/i,l);var h=0;for(o=n;a>o;++o){var u=Qe.distanceSquared(l,t[o]);u>h&&(h=u)}r.radius=Math.sqrt(h)},e.createfromPoints=function(t,n){if(null==t)throw new Error("points");e.createFromSubPoints(t,0,t.length,n)},i(e,["_tempVector3",function(){return this._tempVector3=new Qe}]),e}(),Xe=function(){function e(){}return r(e,"laya.d3.math.Collision"),e.distancePlaneToPoint=function(e,t){var n=Qe.dot(e.normal,t);return n-e.distance},e.distanceBoxToPoint=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.elements,c=u[0],_=u[1],d=u[2],m=0;return i>c&&(m+=(i-c)*(i-c)),c>o&&(m+=(o-c)*(o-c)),r>_&&(m+=(r-_)*(r-_)),_>l&&(m+=(l-_)*(l-_)),a>d&&(m+=(a-d)*(a-d)),d>h&&(m+=(h-d)*(h-d)),Math.sqrt(m)},e.distanceBoxToBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.min.elements,c=u[0],_=u[1],d=u[2],m=t.max.elements,f=m[0],p=m[1],v=m[2],g=0,T=NaN;return i>f?(T=i-f,g+=T*T):c>o&&(T=c-o,g+=T*T),r>p?(T=r-p,g+=T*T):_>l&&(T=_-l,g+=T*T),a>v?(T=a-v,g+=T*T):d>h&&(T=d-h,g+=T*T),Math.sqrt(g)},e.distanceSphereToPoint=function(e,t){var n=Math.sqrt(Qe.distanceSquared(e.center,t));return n-=e.radius,Math.max(n,0)},e.distanceSphereToSphere=function(e,t){var n=Math.sqrt(Qe.distanceSquared(e.center,t.center));return n-=e.radius+t.radius,Math.max(n,0)},e.intersectsRayAndTriangleRD=function(t,n,i,r,a){var s=t.origin,o=s.elements,l=o[0],h=o[1],u=o[2],c=t.direction,_=c.elements,d=_[0],m=_[1],f=_[2],p=n.elements,v=p[0],g=p[1],T=p[2],x=i.elements,M=x[0],E=x[1],y=x[2],S=r.elements,R=S[0],A=S[1],I=S[2],C=e._tempV30.elements,V=C[0],D=C[1],L=C[2];V=M-v,D=E-g,L=y-T;var O=e._tempV31.elements,b=O[0],P=O[1],w=O[2];b=R-v,P=A-g,w=I-T;var N=e._tempV32.elements,B=N[0],F=N[1],U=N[2];B=m*w-f*P,F=f*b-d*w,U=d*P-m*b;var G=V*B+D*F+L*U;if(Ye.isZero(G))return a=0,!1;var z=1/G,H=e._tempV33.elements,k=H[0],X=H[1],Y=H[2];k=l-v,X=h-g,Y=u-T;var j=k*B+X*F+Y*U;if(j*=z,0>j||j>1)return a=0,!1;var W=e._tempV34.elements,Z=W[0],q=W[1],K=W[2];Z=X*L-Y*D,q=Y*V-k*L,K=k*D-X*V;var Q=d*Z+m*q+f*K;if(Q*=z,0>Q||j+Q>1)return a=0,!1;var $=b*Z+P*q+w*K;return $*=z,0>$?(a=0,!1):(a=$,!0)},e.intersectsRayAndTriangleRP=function(t,n,i,r,a){var s=NaN;return e.intersectsRayAndTriangleRD(t,n,i,r,s)?(Qe.scale(t.direction,s,e._tempV30),Qe.add(t.origin,e._tempV30,a),!0):(a=Qe.ZERO,!1)},e.intersectsRayAndPoint=function(t,n){Qe.subtract(t.origin,n,e._tempV30);var i=Qe.dot(e._tempV30,t.direction),r=Qe.dot(e._tempV30,e._tempV30)-Ye.zeroTolerance;if(r>0&&i>0)return!1;var a=i*i-r;return!(0>a)},e.intersectsRayAndRay=function(t,n,i){var r=t.origin,a=r.elements,s=a[0],o=a[1],l=a[2],h=t.direction,u=h.elements,c=u[0],_=u[1],d=u[2],m=n.origin,f=m.elements,p=f[0],v=f[1],g=f[2],T=n.direction,x=T.elements,M=x[0],E=x[1],y=x[2];Qe.cross(h,T,e._tempV30);var S=e._tempV30.elements,R=Qe.scalarLength(e._tempV30);if(Ye.isZero(R)&&Ye.nearEqual(p,s)&&Ye.nearEqual(v,o)&&Ye.nearEqual(g,l))return i=Qe.ZERO,!0;R*=R;var A=p-s,I=v-o,C=g-l,V=M,D=E,L=y,O=S[0],b=S[1],P=S[2],w=A*D*P+I*L*O+C*V*b-A*L*b-I*V*P-C*D*O;V=c,D=_,L=d;var N=w/R;Qe.scale(h,N,e._tempV30),Qe.scale(T,N,e._tempV31),Qe.add(r,e._tempV30,e._tempV32),Qe.add(m,e._tempV31,e._tempV33);var B=e._tempV32.elements,F=e._tempV33.elements;return Ye.nearEqual(F[0],B[0])&&Ye.nearEqual(F[1],B[1])&&Ye.nearEqual(F[2],B[2])?(i=e._tempV32,!0):(i=Qe.ZERO,!1)},e.intersectsPlaneAndTriangle=function(t,n,i,r){var a=e.intersectsPlaneAndPoint(t,n),s=e.intersectsPlaneAndPoint(t,i),o=e.intersectsPlaneAndPoint(t,r);return a==We.PlaneIntersectionType_Front&&s==We.PlaneIntersectionType_Front&&o==We.PlaneIntersectionType_Front?We.PlaneIntersectionType_Front:a==We.PlaneIntersectionType_Back&&s==We.PlaneIntersectionType_Back&&o==We.PlaneIntersectionType_Back?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsRayAndPlaneRD=function(e,t,n){var i=t.normal,r=Qe.dot(i,e.direction);if(Ye.isZero(r))return n=0,!1;var a=Qe.dot(i,e.origin);return n=(-t.distance-a)/r,0>n?(n=0,!1):!0},e.intersectsRayAndPlaneRP=function(t,n,i){var r=NaN;return e.intersectsRayAndPlaneRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsRayAndBoxRD=function(e,t,n){var i=e.origin.elements,r=i[0],a=i[1],s=i[2],o=e.direction.elements,l=o[0],h=o[1],u=o[2],c=t.min.elements,_=c[0],d=c[1],m=c[2],f=t.max.elements,p=f[0],v=f[1],g=f[2];n=0;var T=Ye.MaxValue;if(Ye.isZero(l)){if(_>r||r>p)return n=0,!1}else{var x=1/l,M=(_-r)*x,E=(p-r)*x;if(M>E){var y=M;M=E,E=y}if(n=Math.max(M,n),T=Math.min(E,T),n>T)return n=0,!1}if(Ye.isZero(h)){if(d>a||a>v)return n=0,!1}else{var S=1/h,R=(d-a)*S,A=(v-a)*S;if(R>A){var I=R;R=A,A=I}if(n=Math.max(R,n),T=Math.min(A,T),n>T)return n=0,!1}if(Ye.isZero(u)){if(m>s||s>g)return n=0,!1}else{var C=1/u,V=(m-s)*C,D=(g-s)*C;if(V>D){var L=V;V=D,D=L}if(n=Math.max(V,n),T=Math.min(D,T),n>T)return n=0,!1}return!0},e.intersectsRayAndBoxRP=function(t,n,i){var r=NaN;return e.intersectsRayAndBoxRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsRayAndSphereRD=function(t,n,i){var r=n.radius;Qe.subtract(t.origin,n.center,e._tempV30);var a=Qe.dot(e._tempV30,t.direction),s=Qe.dot(e._tempV30,e._tempV30)-r*r;if(s>0&&a>0)return i=0,!1;var o=a*a-s;return 0>o?(i=0,!1):(i=-a-Math.sqrt(o),0>i&&(i=0),!0)},e.intersectsRayAndSphereRP=function(t,n,i){var r=NaN;return e.intersectsRayAndSphereRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsSphereAndTriangle=function(t,n,i,r){var a=t.center,s=t.radius;e.closestPointPointTriangle(a,n,i,r,e._tempV30),Qe.subtract(e._tempV30,a,e._tempV31);var o=Qe.dot(e._tempV31,e._tempV31);return s*s>=o},e.intersectsPlaneAndPoint=function(e,t){var n=Qe.dot(e.normal,t)+e.distance;return n>0?We.PlaneIntersectionType_Front:0>n?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsPlaneAndPlane=function(t,n){Qe.cross(t.normal,n.normal,e._tempV30);var i=Qe.dot(e._tempV30,e._tempV30);return!Ye.isZero(i)},e.intersectsPlaneAndPlaneRL=function(t,n,i){var r=t.normal,a=n.normal;Qe.cross(r,a,e._tempV34);var s=Qe.dot(e._tempV34,e._tempV34);return Ye.isZero(s)?!1:(Qe.scale(a,t.distance,e._tempV30),Qe.scale(r,n.distance,e._tempV31),Qe.subtract(e._tempV30,e._tempV31,e._tempV32),Qe.cross(e._tempV32,e._tempV34,e._tempV33),Qe.normalize(e._tempV34,e._tempV34),i=new qe(e._tempV33,e._tempV34),!0)},e.intersectsPlaneAndBox=function(t,n){var i=t.distance,r=t.normal,a=r.elements,s=a[0],o=a[1],l=a[2],h=n.min.elements,u=h[0],c=h[1],_=h[2],d=n.max.elements,m=d[0],f=d[1],p=d[2];e._tempV30.elements[0]=s>0?u:m,e._tempV30.elements[1]=o>0?c:f,e._tempV30.elements[2]=l>0?_:p,e._tempV31.elements[0]=s>0?m:u,e._tempV31.elements[1]=o>0?f:c,e._tempV31.elements[2]=l>0?p:_;var v=Qe.dot(r,e._tempV30);return v+i>0?We.PlaneIntersectionType_Front:(v=Qe.dot(r,e._tempV31),0>v+i?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting)},e.intersectsPlaneAndSphere=function(e,t){var n=t.radius,i=Qe.dot(e.normal,t.center)+e.distance;return i>n?We.PlaneIntersectionType_Front:-n>i?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsBoxAndBox=function(e,t){var n=e.min.elements,i=e.max.elements,r=t.min.elements,a=t.max.elements;return n[0]>a[0]||r[0]>i[0]?!1:n[1]>a[1]||r[1]>i[1]?!1:!(n[2]>a[2]||r[2]>i[2])},e.intersectsBoxAndSphere=function(t,n){var i=n.center,r=n.radius;Qe.Clamp(i,t.min,t.max,e._tempV30);var a=Qe.distanceSquared(i,e._tempV30);return r*r>=a},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return Qe.distanceSquared(e.center,t.center)<=n*n},e.boxContainsPoint=function(e,t){var n=e.min.elements,i=e.max.elements,r=t.elements;return n[0]<=r[0]&&i[0]>=r[0]&&n[1]<=r[1]&&i[1]>=r[1]&&n[2]<=r[2]&&i[2]>=r[2]?1:0},e.boxContainsBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.min.elements,c=u[0],_=u[1],d=u[2],m=t.max.elements,f=m[0],p=m[1],v=m[2];return c>o||i>f?0:_>l||r>p?0:d>h||a>v?0:c>=i&&c>=f&&_>=r&&l>=p&&d>=a&&h>=v?1:2},e.boxContainsSphere=function(t,n){var i=t.min,r=i.elements,a=r[0],s=r[1],o=r[2],l=t.max,h=l.elements,u=h[0],c=h[1],_=h[2],d=n.center,m=d.elements,f=m[0],p=m[1],v=m[2],g=n.radius;Qe.Clamp(d,i,l,e._tempV30);var T=Qe.distanceSquared(d,e._tempV30);return T>g*g?0:f>=a+g&&u-g>=f&&u-a>g&&p>=s+g&&c-g>=p&&c-s>g&&v>=o+g&&_-g>=v&&_-o>g?1:2},e.sphereContainsPoint=function(e,t){return Qe.distanceSquared(t,e.center)<=e.radius*e.radius?1:0},e.sphereContainsTriangle=function(t,n,i,r){var a=e.sphereContainsPoint(t,n),s=e.sphereContainsPoint(t,i),o=e.sphereContainsPoint(t,r);return 1==a&&1==s&&1==o?1:e.intersectsSphereAndTriangle(t,n,i,r)?2:0},e.sphereContainsBox=function(t,n){var i=t.center,r=i.elements,a=r[0],s=r[1],o=r[2],l=t.radius,h=n.min,u=h.elements,c=u[0],_=u[1],d=u[2],m=n.max,f=m.elements,p=f[0],v=f[1],g=f[2],T=e._tempV30.elements,x=T[0],M=T[1],E=T[2]; +if(!e.intersectsBoxAndSphere(n,t))return 0;var y=l*l;return x=a-c,M=s-v,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-v,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-_,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-_,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-v,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-v,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-_,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-_,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:1)))))))},e.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,r=Qe.distance(e.center,t.center);return r>n+i?0:r>n-i?2:1},e.closestPointPointTriangle=function(t,n,i,r,a){Qe.subtract(i,n,e._tempV30),Qe.subtract(r,n,e._tempV31),Qe.subtract(t,n,e._tempV32),Qe.subtract(t,i,e._tempV33),Qe.subtract(t,r,e._tempV34);var s=Qe.dot(e._tempV30,e._tempV32),o=Qe.dot(e._tempV31,e._tempV32),l=Qe.dot(e._tempV30,e._tempV33),h=Qe.dot(e._tempV31,e._tempV33),u=Qe.dot(e._tempV30,e._tempV34),c=Qe.dot(e._tempV31,e._tempV34);if(0>=s&&0>=o)return void n.cloneTo(a);if(l>=0&&l>=h)return void i.cloneTo(a);var _=s*h-l*o;if(0>=_&&s>=0&&0>=l){var d=s/(s-l);return Qe.scale(e._tempV30,d,a),void Qe.add(n,a,a)}if(c>=0&&c>=u)return void r.cloneTo(a);var m=u*o-s*c;if(0>=m&&o>=0&&0>=c){var f=o/(o-c);return Qe.scale(e._tempV31,f,a),void Qe.add(n,a,a)}var p=l*c-u*h;if(0>=p&&h-l>=0&&u-c>=0){var v=(h-l)/(h-l+(u-c));return Qe.subtract(r,i,a),Qe.scale(a,v,a),void Qe.add(i,a,a)}var g=1/(p+m+_),T=m*g,x=_*g;Qe.scale(e._tempV30,T,e._tempV35),Qe.scale(e._tempV31,x,e._tempV36),Qe.add(e._tempV35,e._tempV36,a),Qe.add(n,a,a)},e.closestPointPlanePoint=function(t,n,i){var r=t.normal,a=Qe.dot(r,n)-t.distance;Qe.scale(r,a,e._tempV30),Qe.subtract(n,e._tempV30,i)},e.closestPointBoxPoint=function(t,n,i){Qe.max(n,t.min,e._tempV30),Qe.min(e._tempV30,t.max,i)},e.closestPointSpherePoint=function(e,t,n){var i=e.center;Qe.subtract(t,i,n),Qe.normalize(n,n),Qe.scale(n,e.radius,n),Qe.add(n,i,n)},e.closestPointSphereSphere=function(e,t,n){var i=e.center;Qe.subtract(t.center,i,n),Qe.normalize(n,n),Qe.scale(n,e.radius,n),Qe.add(n,i,n)},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempV35",function(){return this._tempV35=new Qe},"_tempV36",function(){return this._tempV36=new Qe}]),e}(),Ye=(function(){function e(){}return r(e,"laya.d3.math.ContainmentType"),e.Disjoint=0,e.Contains=1,e.Intersects=2,e}(),function(){function e(){}return r(e,"laya.d3.math.MathUtils3D"),e.isZero=function(t){return Math.abs(t)t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;9>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;9>t;++t)n[t]=e[t]},e.createFromTranslation=function(e,t){var n=(t.elements,e.elements);t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=n[0],t[7]=n[1],t[8]=1},e.createFromRotation=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[0]=r,n[1]=i,n[2]=0,n[3]=-i,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.createFromScaling=function(e,t){var n=t.elements,i=e.elements;n[0]=i[0],n[1]=0,n[2]=0,n[3]=0,n[4]=i[1],n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.createFromMatrix4x4=function(e,t){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]},e.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,s=r[0],o=r[1],l=r[2],h=r[3],u=r[4],c=r[5],_=r[6],d=r[7],m=r[8],f=a[0],p=a[1],v=a[2],g=a[3],T=a[4],x=a[5],M=a[6],E=a[7],y=a[8];i[0]=f*s+p*h+v*_,i[1]=f*o+p*u+v*d,i[2]=f*l+p*c+v*m,i[3]=g*s+T*h+x*_,i[4]=g*o+T*u+x*d,i[5]=g*l+T*c+x*m,i[6]=M*s+E*h+y*_,i[7]=M*o+E*u+y*d,i[8]=M*l+E*c+y*m},e.DEFAULT=new e,e}(),function(){function e(e,t,n,i,r,a,s,o,l,h,u,c,_,d,m,f){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===l&&(l=0),void 0===h&&(h=0),void 0===u&&(u=1),void 0===c&&(c=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===m&&(m=0),void 0===f&&(f=1);var p=this.elements=new Float32Array(16);p[0]=e,p[1]=t,p[2]=n,p[3]=i,p[4]=r,p[5]=a,p[6]=s,p[7]=o,p[8]=l,p[9]=h,p[10]=u,p[11]=c,p[12]=_,p[13]=d,p[14]=m,p[15]=f}r(e,"laya.d3.math.Matrix4x4");var t=e.prototype;return t.equalsOtherMatrix=function(e){var t=this.elements,n=e.elements;return Ye.nearEqual(t[0],n[0])&&Ye.nearEqual(t[1],n[1])&&Ye.nearEqual(t[2],n[2])&&Ye.nearEqual(t[3],n[3])&&Ye.nearEqual(t[4],n[4])&&Ye.nearEqual(t[5],n[5])&&Ye.nearEqual(t[6],n[6])&&Ye.nearEqual(t[7],n[7])&&Ye.nearEqual(t[8],n[8])&&Ye.nearEqual(t[9],n[9])&&Ye.nearEqual(t[10],n[10])&&Ye.nearEqual(t[11],n[11])&&Ye.nearEqual(t[12],n[12])&&Ye.nearEqual(t[13],n[13])&&Ye.nearEqual(t[14],n[14])&&Ye.nearEqual(t[15],n[15])},t.decompose=function(t,n,i){var r=this.elements,a=t.elements,s=n.elements,o=i.elements;if(a[0]=r[12],a[1]=r[13],a[2]=r[14],o[0]=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),o[1]=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),o[2]=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),Ye.isZero(o[0])||Ye.isZero(o[1])||Ye.isZero(o[2]))return s[0]=s[1]=s[2]=0,s[3]=1,!1;var l=new e,h=l.elements;return h[0]=r[0]/o[0],h[1]=r[1]/o[0],h[2]=r[2]/o[0],h[4]=r[4]/o[1],h[5]=r[5]/o[1],h[6]=r[6]/o[1],h[8]=r[8]/o[2],h[9]=r[9]/o[2],h[10]=r[10]/o[2],l[15]=1,Ze.createFromMatrix4x4(l,n),!0},t.normalize=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=Math.sqrt(t*t+n*n+i*i);return r?void(1!=r&&(r=1/r,e[0]=t*r,e[1]=n*r,e[2]=i*r)):(e[0]=0,e[1]=0,void(e[2]=0))},t.transpose=function(){var e,t;return e=this.elements,t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},t.invert=function(e){var t=this.elements,n=e.elements,i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],h=t[6],u=t[7],c=t[8],_=t[9],d=t[10],m=t[11],f=t[12],p=t[13],v=t[14],g=t[15],T=i*l-r*o,x=i*h-a*o,M=i*u-s*o,E=r*h-a*l,y=r*u-s*l,S=a*u-s*h,R=c*p-_*f,A=c*v-d*f,I=c*g-m*f,C=_*v-d*p,V=_*g-m*p,D=d*g-m*v,L=T*D-x*V+M*C+E*I-y*A+S*R;0!==Math.abs(L)&&(L=1/L,n[0]=(l*D-h*V+u*C)*L,n[1]=(a*V-r*D-s*C)*L,n[2]=(p*S-v*y+g*E)*L,n[3]=(d*y-_*S-m*E)*L,n[4]=(h*I-o*D-u*A)*L,n[5]=(i*D-a*I+s*A)*L,n[6]=(v*M-f*S-g*x)*L,n[7]=(c*S-d*M+m*x)*L,n[8]=(o*V-l*I+u*R)*L,n[9]=(r*I-i*V-s*R)*L,n[10]=(f*y-p*M+g*T)*L,n[11]=(_*M-c*y-m*T)*L,n[12]=(l*A-o*C-h*R)*L,n[13]=(i*C-r*A+a*R)*L,n[14]=(p*x-f*E-v*T)*L,n[15]=(c*E-_*x+d*T)*L)},t.identity=function(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1},t.cloneTo=function(e){var t,n,i;if(n=this.elements,i=e.elements,n!==i)for(t=0;16>t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;16>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;16>t;++t)n[t]=e[t]},a(0,t,"translationVector",function(){var t=this.elements,n=e._translationVector.elements;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e._translationVector},function(e){var t=this.elements,n=e.elements;t[12]=n[0],t[13]=n[1],t[14]=n[2]}),e.createRotationX=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[2]=n[3]=n[4]=n[7]=n[8]=n[11]=n[12]=n[13]=n[14]=0,n[0]=n[15]=1,n[5]=n[10]=r,n[6]=i,n[9]=-i},e.createRotationY=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[3]=n[4]=n[6]=n[7]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[5]=n[15]=1,n[0]=n[10]=r,n[2]=-i,n[8]=i},e.createRotationZ=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[2]=n[3]=n[6]=n[7]=n[8]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[10]=n[15]=1,n[0]=n[5]=r,n[1]=i,n[4]=-i},e.createRotationYawPitchRoll=function(t,n,i,r){Ze.createFromYawPitchRoll(t,n,i,e._tempQuaternion),e.createRotationQuaternion(e._tempQuaternion,r)},e.createRotationQuaternion=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],s=n[2],o=n[3],l=r*r,h=a*a,u=s*s,c=r*a,_=s*o,d=s*r,m=a*o,f=a*s,p=r*o;i[3]=i[7]=i[11]=i[12]=i[13]=i[14]=0,i[15]=1,i[0]=1-2*(h+u),i[1]=2*(c+_),i[2]=2*(d-m),i[4]=2*(c-_),i[5]=1-2*(u+l),i[6]=2*(f+p),i[8]=2*(d+m),i[9]=2*(f-p),i[10]=1-2*(h+l)},e.createTranslate=function(e,t){var n=e.elements,i=t.elements;i[4]=i[8]=i[1]=i[9]=i[2]=i[6]=i[3]=i[7]=i[11]=0,i[0]=i[5]=i[10]=i[15]=1,i[12]=n[0],i[13]=n[1],i[14]=n[2]},e.createScaling=function(e,t){var n=e.elements,i=t.elements;i[0]=n[0],i[5]=n[1],i[10]=n[2],i[1]=i[4]=i[8]=i[12]=i[9]=i[13]=i[2]=i[6]=i[14]=i[3]=i[7]=i[11]=0,i[15]=1},e.multiply=function(e,t,n){var i,r,a,s,o,l,h,u;if(r=n.elements,a=e.elements,s=t.elements,r===s)for(s=new Float32Array(16),i=0;16>i;++i)s[i]=r[i];for(i=0;4>i;i++)o=a[i],l=a[i+4],h=a[i+8],u=a[i+12],r[i]=o*s[0]+l*s[1]+h*s[2]+u*s[3],r[i+4]=o*s[4]+l*s[5]+h*s[6]+u*s[7],r[i+8]=o*s[8]+l*s[9]+h*s[10]+u*s[11],r[i+12]=o*s[12]+l*s[13]+h*s[14]+u*s[15]},e.createFromQuaternion=function(e,t){var n=t.elements,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=r+r,h=a+a,u=s+s,c=r*l,_=a*l,d=a*h,m=s*l,f=s*h,p=s*u,v=o*l,g=o*h,T=o*u;n[0]=1-d-p,n[1]=_+T,n[2]=m-g,n[3]=0,n[4]=_-T,n[5]=1-c-p,n[6]=f+v,n[7]=0,n[8]=m+g,n[9]=f-v,n[10]=1-c-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,t[15]=1},e.createAffineTransformation=function(e,t,n,i){var r=e.elements,a=t.elements,s=n.elements,o=i.elements,l=a[0],h=a[1],u=a[2],c=a[3],_=l+l,d=h+h,m=u+u,f=l*_,p=l*d,v=l*m,g=h*d,T=h*m,x=u*m,M=c*_,E=c*d,y=c*m,S=s[0],R=s[1],A=s[2];o[0]=(1-(g+x))*S,o[1]=(p+y)*S,o[2]=(v-E)*S,o[3]=0,o[4]=(p-y)*R,o[5]=(1-(f+x))*R,o[6]=(T+M)*R,o[7]=0,o[8]=(v+E)*A,o[9]=(T-M)*A,o[10]=(1-(f+g))*A,o[11]=0,o[12]=r[0],o[13]=r[1],o[14]=r[2],o[15]=1},e.createLookAt=function(e,t,n,i){var r,a,s,o,l,h,u,c,_,d,m=e.elements,f=t.elements,p=n.elements,v=i.elements,g=m[0],T=m[1],x=m[2],M=p[0],E=p[1],y=p[2],S=f[0],R=f[1],A=f[2];return Math.abs(g-S)o&&r>l&&a>h?1:0},t.containsSphere=function(t,n){void 0===n&&(n=!1);var i=this.extents.elements,r=i[0],a=i[1],s=i[2],o=t.radius;this.transformation.invert(e._tempM0),Qe.transformCoordinate(t.center,e._tempM0,e._tempV30);var l=NaN;n?l=o:(Qe.scale(Qe.UnitX,o,e._tempV31),Qe.TransformNormal(e._tempV31,e._tempM0,e._tempV31),l=Qe.scalarLength(e._tempV31)),Qe.scale(this.extents,-1,e._tempV32),Qe.Clamp(e._tempV30,e._tempV32,this.extents,e._tempV33);var h=Qe.distanceSquared(e._tempV30,e._tempV33);if(h>l*l)return 0;var u=e._tempV30.elements,c=u[0],_=u[1],d=u[2],m=e._tempV32.elements,f=m[0],p=m[1],v=m[2];return c>=f+l&&r-l>=c&&r-f>l&&_>=p+l&&a-l>=_&&a-p>l&&d>=v+l&&s-l>=d&&s-v>l?1:2},e._getRows=function(e,t){t.length=3;var n=e.elements,i=t[0].elements;i[0]=n[0],i[1]=n[1],i[2]=n[2];var r=t[1].elements;r[0]=n[4],r[1]=n[5],r[2]=n[6];var a=t[2].elements;a[0]=n[8],a[1]=n[9],a[2]=n[10]},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempM0",function(){return this._tempM0=new je},"_tempM1",function(){return this._tempM1=new je}]),e}(),function(){function e(e,t){this.normal=null,this.distance=NaN,void 0===t&&(t=0),this.normal=e,this.distance=t}r(e,"laya.d3.math.Plane");var t=e.prototype;return t.normalize=function(){var e=this.normal.elements,t=e[0],n=e[1],i=e[2],r=1/Math.sqrt(t*t+n*n+i*i);e[0]=t*r,e[1]=n*r,e[2]=i*r,this.distance*=r},e.createPlaneBy3P=function(t,n,i){var r=t.elements,a=n.elements,s=i.elements,o=a[0]-r[0],l=a[1]-r[1],h=a[2]-r[2],u=s[0]-r[0],c=s[1]-r[1],_=s[2]-r[2],d=l*_-h*c,m=h*u-o*_,f=o*c-l*u,p=1/Math.sqrt(d*d+m*m+f*f),v=d*p,g=m*p,T=f*p,x=e._TEMPVec3.elements;x[0]=v,x[1]=g,x[2]=T;var M=-(v*r[0]+g*r[1]+T*r[2]),E=new e(e._TEMPVec3,M);return E},e.PlaneIntersectionType_Back=0,e.PlaneIntersectionType_Front=1,e.PlaneIntersectionType_Intersecting=2,i(e,["_TEMPVec3",function(){return this._TEMPVec3=new Qe}]),e}()),Ze=function(){function e(e,t,n,i){this.elements=new Float32Array(4),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this.elements[0]=e,this.elements[1]=t,this.elements[2]=n,this.elements[3]=i}r(e,"laya.d3.math.Quaternion");var t=e.prototype;return t.scaling=function(e,t){var n=t.elements,i=this.elements;n[0]=i[0]*e,n[1]=i[1]*e,n[2]=i[2]*e,n[3]=i[3]*e},t.normalize=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=i*i+r*r+a*a+s*s;o>0&&(o=1/Math.sqrt(o),t[0]=i*o,t[1]=r*o,t[2]=a*o,t[3]=s*o)},t.length=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)},t.rotateX=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+o*l,n[1]=a*h+s*l,n[2]=s*h-a*l,n[3]=o*h-r*l},t.rotateY=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h-s*l,n[1]=a*h+o*l,n[2]=s*h+r*l,n[3]=o*h-a*l},t.rotateZ=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+a*l,n[1]=a*h-r*l,n[2]=s*h+o*l,n[3]=o*h-s*l},t.getYawPitchRoll=function(t){Qe.transformQuat(Qe.ForwardRH,this,e.TEMPVector31),Qe.transformQuat(Qe.Up,this,e.TEMPVector32);var n=e.TEMPVector32.elements;e.angleTo(Qe.ZERO,e.TEMPVector31,e.TEMPVector33);var i=e.TEMPVector33.elements;i[0]==Math.PI/2?(i[1]=e.arcTanAngle(n[2],n[0]),i[2]=0):i[0]==-Math.PI/2?(i[1]=e.arcTanAngle(-n[2],-n[0]),i[2]=0):(je.createRotationY(-i[1],e.TEMPMatrix0),je.createRotationX(-i[0],e.TEMPMatrix1),Qe.transformCoordinate(e.TEMPVector32,e.TEMPMatrix0,e.TEMPVector32),Qe.transformCoordinate(e.TEMPVector32,e.TEMPMatrix1,e.TEMPVector32),i[2]=e.arcTanAngle(n[1],-n[0])),i[1]<=-Math.PI&&(i[1]=Math.PI),i[2]<=-Math.PI&&(i[2]=Math.PI),i[1]>=Math.PI&&i[2]>=Math.PI&&(i[1]=0,i[2]=0,i[0]=Math.PI-i[0]);var r=t.elements;r[0]=i[1],r[1]=i[0],r[2]=i[2]},t.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=i*i+r*r+a*a+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-r*l,t[2]=-a*l,t[3]=s*l},t.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},t.cloneTo=function(e){var t,n,i;if(n=this.elements,i=e.elements,n!==i)for(t=0;4>t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;4>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;4>t;++t)n[t]=e[t]},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),a(0,t,"z",function(){return this.elements[2]}),a(0,t,"w",function(){return this.elements[3]}),e.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,s=.5*e,o=Math.sin(r),l=Math.cos(r),h=Math.sin(a),u=Math.cos(a),c=Math.sin(s),_=Math.cos(s),d=i.elements;d[0]=_*h*l+c*u*o,d[1]=c*u*l-_*h*o,d[2]=_*u*o-c*h*l,d[3]=_*u*l+c*h*o},e.multiply=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,s=i[0],o=i[1],l=i[2],h=i[3],u=r[0],c=r[1],_=r[2],d=r[3],m=o*_-l*c,f=l*u-s*_,p=s*c-o*u,v=s*u+o*c+l*_;a[0]=s*d+u*h+m,a[1]=o*d+c*h+f,a[2]=l*d+_*h+p,a[3]=h*d-v},e.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):0>e?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},e.angleTo=function(t,n,i){Qe.subtract(n,t,e.TEMPVector30),Qe.normalize(e.TEMPVector30,e.TEMPVector30),i.elements[0]=Math.asin(e.TEMPVector30.y),i.elements[1]=e.arcTanAngle(-e.TEMPVector30.z,-e.TEMPVector30.x)},e.createFromAxisAngle=function(e,t,n){var i=n.elements,r=e.elements;t=.5*t;var a=Math.sin(t);i[0]=a*r[0],i[1]=a*r[1],i[2]=a*r[2],i[3]=Math.cos(t)},e.createFromMatrix3x3=function(e,t){var n,i=t.elements,r=e.elements,a=r[0]+r[4]+r[8];if(a>0)n=Math.sqrt(a+1),i[3]=.5*n,n=.5/n,i[0]=(r[5]-r[7])*n,i[1]=(r[6]-r[2])*n,i[2]=(r[1]-r[3])*n;else{var s=0;r[4]>r[0]&&(s=1),r[8]>r[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;n=Math.sqrt(r[3*s+s]-r[3*o+o]-r[3*l+l]+1),i[s]=.5*n,n=.5/n,i[3]=(r[3*o+l]-r[3*l+o])*n,i[o]=(r[3*o+s]+r[3*s+o])*n,i[l]=(r[3*l+s]+r[3*s+l])*n}},e.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,a=t.elements,s=r[0]+r[5]+r[10];s>0?(n=Math.sqrt(s+1),a[3]=.5*n,n=.5/n,a[0]=(r[6]-r[9])*n,a[1]=(r[8]-r[2])*n,a[2]=(r[1]-r[4])*n):r[0]>=r[5]&&r[0]>=r[10]?(n=Math.sqrt(1+r[0]-r[5]-r[10]),i=.5/n,a[0]=.5*n,a[1]=(r[1]+r[4])*i,a[2]=(r[2]+r[8])*i,a[3]=(r[6]-r[9])*i):r[5]>r[10]?(n=Math.sqrt(1+r[5]-r[0]-r[10]),i=.5/n,a[0]=(r[4]+r[1])*i,a[1]=.5*n,a[2]=(r[9]+r[6])*i,a[3]=(r[8]-r[2])*i):(n=Math.sqrt(1+r[10]-r[0]-r[5]),i=.5/n,a[0]=(r[8]+r[2])*i,a[1]=(r[9]+r[6])*i,a[2]=.5*n,a[3]=(r[1]-r[4])*i)},e.slerp=function(e,t,n,i){var r,a,s,o,l,h=e.elements,u=t.elements,c=i.elements,_=h[0],d=h[1],m=h[2],f=h[3],p=u[0],v=u[1],g=u[2],T=u[3];return a=_*p+d*v+m*g+f*T,0>a&&(a=-a,p=-p,v=-v,g=-g,T=-T),1-a>1e-6?(r=Math.acos(a),s=Math.sin(r),o=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(o=1-n,l=n),c[0]=o*_+l*p,c[1]=o*d+l*v,c[2]=o*m+l*g,c[3]=o*f+l*T,c},e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2],u=a[3];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h),r[3]=u+n*(s[3]-u)},e.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3]},e.dot=function(e,t){var n=e.elements,i=t.elements;return n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]*i[3]},e.DEFAULT=new e,i(e,["TEMPVector30",function(){return this.TEMPVector30=new Qe},"TEMPVector31",function(){return this.TEMPVector31=new Qe},"TEMPVector32",function(){return this.TEMPVector32=new Qe},"TEMPVector33",function(){return this.TEMPVector33=new Qe},"TEMPMatrix0",function(){return this.TEMPMatrix0=new je},"TEMPMatrix1",function(){return this.TEMPMatrix1=new je}]),e}(),qe=function(){function e(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}return r(e,"laya.d3.math.Ray"),e}(),Ke=function(){function e(e,t){this.elements=new Float32Array(2),void 0===e&&(e=0),void 0===t&&(t=0);var n=this.elements;n[0]=e,n[1]=t}r(e,"laya.d3.math.Vector2");var t=e.prototype;return t.clone=function(e){var t=this.elements,n=e.elements;t[0]=n[0],t[1]=n[1]},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),e.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t},i(e,["ZERO",function(){return this.ZERO=new e(0,0)},"ONE",function(){return this.ONE=new e(1,1)}]),e}(),Qe=function(){function e(e,t,n){this.elements=new Float32Array(3),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0);var i=this.elements;i[0]=e,i[1]=t,i[2]=n}r(e,"laya.d3.math.Vector3");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e,n=t.elements,i=this.elements;n[0]=i[0],n[1]=i[1],n[2]=i[2]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.toDefault=function(){this.elements[0]=0,this.elements[1]=0,this.elements[2]=0},a(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),a(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),a(0,t,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),e.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],s=n[2]-i[2];return r*r+a*a+s*s},e.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],s=n[2]-i[2];return Math.sqrt(r*r+a*a+s*s)},e.min=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.min(r[0],a[0]),i[1]=Math.min(r[1],a[1]),i[2]=Math.min(r[2],a[2])},e.max=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.max(r[0],a[0]),i[1]=Math.max(r[1],a[1]),i[2]=Math.max(r[2],a[2])},e.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,s=r[0],o=r[1],l=r[2],h=a[0],u=a[1],c=a[2],_=a[3],d=_*s+u*l-c*o,m=_*o+c*s-h*l,f=_*l+h*o-u*s,p=-h*s-u*o-c*l;i[0]=d*_+p*-h+m*-c-f*-u,i[1]=m*_+p*-u+f*-h-d*-c,i[2]=f*_+p*-c+d*-u-m*-h},e.scalarLength=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return Math.sqrt(n*n+i*i+r*r)},e.scalarLengthSquared=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return n*n+i*i+r*r},e.normalize=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],s=n[2],o=r*r+a*a+s*s;o>0&&(o=1/Math.sqrt(o),i[0]=n[0]*o,i[1]=n[1]*o,i[2]=n[2]*o)},e.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]*a[0],i[1]=r[1]*a[1],i[2]=r[2]*a[2]},e.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t},e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h)},e.transformV3ToV3=function(t,n,i){var r=new $e;e.transformV3ToV4(t,n,r);var a=r.elements,s=i.elements;s[0]=a[0],s[1]=a[1],s[2]=a[2]},e.transformV3ToV4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],s=i[2],o=t.elements,l=n.elements;l[0]=r*o[0]+a*o[4]+s*o[8]+o[12],l[1]=r*o[1]+a*o[5]+s*o[9]+o[13],l[2]=r*o[2]+a*o[6]+s*o[10]+o[14],l[3]=r*o[3]+a*o[7]+s*o[11]+o[15]},e.TransformNormal=function(e,t,n){var i=e.elements,r=i[0],a=i[1],s=i[2],o=t.elements,l=n.elements;l[0]=r*o[0]+a*o[4]+s*o[8],l[1]=r*o[1]+a*o[5]+s*o[9],l[2]=r*o[2]+a*o[6]+s*o[10]},e.transformCoordinate=function(t,n,i){var r=e.TEMPVec4.elements,a=t.elements,s=a[0],o=a[1],l=a[2],h=n.elements;r[0]=s*h[0]+o*h[4]+l*h[8]+h[12],r[1]=s*h[1]+o*h[5]+l*h[9]+h[13],r[2]=s*h[2]+o*h[6]+l*h[10]+h[14],r[3]=1/(s*h[3]+o*h[7]+l*h[11]+h[15]);var u=i.elements;u[0]=r[0]*r[3],u[1]=r[1]*r[3],u[2]=r[2]*r[3]},e.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],s=r[1],o=r[2],l=t.elements,h=l[0],u=l[1],c=l[2],_=n.elements,d=_[0],m=_[1],f=_[2],p=i.elements;a=a>d?d:a,a=h>a?h:a,s=s>m?m:s,s=u>s?u:s,o=o>f?f:o,o=c>o?c:o,p[0]=a,p[1]=s,p[2]=o},e.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2]},e.subtract=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2]},e.cross=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,s=i[0],o=i[1],l=i[2],h=r[0],u=r[1],c=r[2];a[0]=o*c-l*u,a[1]=l*h-s*c,a[2]=s*u-o*h},e.dot=function(e,t){var n=e.elements,i=t.elements,r=n[0]*i[0]+n[1]*i[1]+n[2]*i[2];return r},e.equals=function(e,t){var n=e.elements,i=t.elements;return Ye.nearEqual(Math.abs(n[0]),Math.abs(i[0]))&&Ye.nearEqual(Math.abs(n[1]),Math.abs(i[1]))&&Ye.nearEqual(Math.abs(n[2]),Math.abs(i[2]))},i(e,["TEMPVec4",function(){return this.TEMPVec4=new $e},"ZERO",function(){return this.ZERO=new e(0,0,0)},"ONE",function(){return this.ONE=new e(1,1,1)},"NegativeUnitX",function(){return this.NegativeUnitX=new e(-1,0,0)},"UnitX",function(){return this.UnitX=new e(1,0,0)},"UnitY",function(){return this.UnitY=new e(0,1,0)},"UnitZ",function(){return this.UnitZ=new e(0,0,1)},"ForwardRH",function(){return this.ForwardRH=new e(0,0,-1)},"ForwardLH",function(){return this.ForwardLH=new e(0,0,1)},"Up",function(){return this.Up=new e(0,1,0)}]),e}(),$e=function(){function e(e,t,n,i){this.elements=new Float32Array(4),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0);var r=this.elements;r[0]=e,r[1]=t,r[2]=n,r[3]=i}r(e,"laya.d3.math.Vector4");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e,n=t.elements,i=this.elements;n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),a(0,t,"z",function(){return this.elements[2]}),a(0,t,"w",function(){return this.elements[3]}),e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2],u=a[3];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h),r[3]=u+n*(s[3]-u)},i(e,["ZERO",function(){return this.ZERO=new e}]),e}(),Je=function(){function e(e,t,n,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=n,this.height=i}r(e,"laya.d3.math.Viewport");var t=e.prototype;return t.project=function(e,t,n){Qe.transformV3ToV3(e,t,n);var i=e.elements,r=t.elements,a=n.elements,s=i[0]*r[3]+i[1]*r[7]+i[2]*r[11]+r[15];1!==s&&(a[0]=a[0]/s,a[1]=a[1]/s,a[2]=a[2]/s),a[0]=.5*(a[0]+1)*this.width+this.x,a[1]=.5*(-a[1]+1)*this.height+this.y,a[2]=a[2]*(this.maxDepth-this.minDepth)+this.minDepth},t.unprojectFromMat=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements;a[0]=(i[0]-this.x)/this.width*2-1,a[1]=-((i[1]-this.y)/this.height*2-1);var s=(this.maxDepth-this.minDepth)/2;a[2]=(i[2]-this.minDepth-s)/s;var o=a[0]*r[3]+a[1]*r[7]+a[2]*r[11]+r[15];Qe.transformV3ToV3(n,t,n),1!==o&&(a[0]=a[0]/o,a[1]=a[1]/o,a[2]=a[2]/o)},t.unprojectFromWVP=function(t,n,i,r,a){je.multiply(n,i,e._tempMatrix4x4),r&&je.multiply(e._tempMatrix4x4,r,e._tempMatrix4x4),e._tempMatrix4x4.invert(e._tempMatrix4x4),this.unprojectFromMat(t,e._tempMatrix4x4,a)},i(e,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new je}]),e}(),et=function(){function e(){this._indexBuffer=null,this._vertexBuffer=null,this._boneIndices=null,this._bufferUsage=null,this._indexInMesh=0,this._bufferUsage={}}r(e,"laya.d3.resource.models.SubMesh");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0,"laya.resource.IDispose":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=this._indexBuffer.indexCount;e.context.drawElements(4,t,5123,0),L.drawCall++,L.trianglesFaces+=t/3},t.dispose=function(){this._boneIndices=null,this._indexBuffer.dispose(),this._vertexBuffer.dispose()},a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"indexOfHost",function(){return this._indexInMesh}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3; +}),e}(),tt=(function(){function e(){}return r(e,"laya.d3.utils.Physics"),e.rayCastNode=function(t,n,i){if(n instanceof laya.d3.core.MeshSprite3D){var r=n,a=n.transform.worldMatrix,s=e._tempMatrix4x40;a.invert(s);var o=e._tempVector30,l=e._tempVector31,h=t.origin,u=t.direction;h.cloneTo(o),u.cloneTo(l),Qe.transformCoordinate(h,s,h),Qe.TransformNormal(u,s,u),Qe.normalize(u,u);for(var c=r.meshRender.renderObject._renderElements,_=0,d=c.length;d>_;_++){var m=c[_].renderObj,f=m._getVertexBuffer(0),p=f.getData(),v=m._getIndexBuffer().getData(),g=e._tempRaycastHit0,T=tt.rayIntersectsPositionsAndIndices(t,p,f.vertexDeclaration,v,g);if(T){Qe.transformCoordinate(g.position,a,g.position);var x=g.trianglePositions;Qe.transformCoordinate(x[0],a,x[0]),Qe.transformCoordinate(x[1],a,x[1]),Qe.transformCoordinate(x[2],a,x[2]);var M=g.triangleNormals;Qe.transformCoordinate(M[0],a,M[0]),Qe.transformCoordinate(M[1],a,M[1]),Qe.transformCoordinate(M[2],a,M[2]);var E=e._tempVector33;Qe.subtract(o,g.position,E),i.distance=Qe.scalarLength(E)}T&&g.distancey;y++)e.rayCast(t,n._childs[y],i)},e.rayCast=function(t,n,i){i.position.toDefault(),i.distance=Number.MAX_VALUE,i.trianglePositions[0].toDefault(),i.trianglePositions[1].toDefault(),i.trianglePositions[2].toDefault(),i.triangleNormals[0].toDefault(),i.triangleNormals[1].toDefault(),i.triangleNormals[2].toDefault(),e.rayCastNode(t,n,i)},i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempVector33",function(){return this._tempVector33=new Qe},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempRaycastHit0",function(){return this._tempRaycastHit0=new nt}]),e}(),function(){function e(){}return r(e,"laya.d3.utils.Picker"),e.calculateCursorRay=function(t,n,i,r,a,s){var o=t.elements[0],l=t.elements[1],h=e._tempVector30,u=h.elements;u[0]=o,u[1]=l,u[2]=n.minDepth;var c=e._tempVector31,_=c.elements;_[0]=o,_[1]=l,_[2]=n.maxDepth;var d=s.origin,m=e._tempVector32;n.unprojectFromWVP(h,i,r,a,d),n.unprojectFromWVP(c,i,r,a,m);var f=s.direction.elements;f[0]=m.x-d.x,f[1]=m.y-d.y,f[2]=m.z-d.z,Qe.normalize(s.direction,s.direction)},e.rayIntersectsPositionsAndIndices=function(t,n,i,r,a){for(var s=i.vertexStride/4,o=i.getVertexElementByUsage("POSITION").offset/4,l=Number.MAX_VALUE,h=-1,u=-1,c=-1,_=0;_R&&(l=R,h=f,u=T,c=y)}if(l!==Number.MAX_VALUE){a.distance=l,Qe.normalize(t.direction,t.direction),Qe.scale(t.direction,l,a.position),Qe.add(t.origin,a.position,a.position);var A=a.trianglePositions,I=A[0],C=A[1],V=A[2],D=I.elements,L=C.elements,O=V.elements,b=h+o;D[0]=n[b],D[1]=n[b+1],D[2]=n[b+2];var P=u+o;L[0]=n[P],L[1]=n[P+1],L[2]=n[P+2];var w=c+o;O[0]=n[w],O[1]=n[w+1],O[2]=n[w+2];var N=i.getVertexElementByUsage("NORMAL");if(N){var B=N.offset/4,F=a.triangleNormals,U=F[0],G=F[1],z=F[2],H=U.elements,k=G.elements,X=z.elements,Y=h+B;H[0]=n[Y],H[1]=n[Y+1],H[2]=n[Y+2];var j=u+B;k[0]=n[j],k[1]=n[j+1],k[2]=n[j+2];var W=c+B;X[0]=n[W],X[1]=n[W+1],X[2]=n[W+2]}return!0}return a.position.toDefault(),a.distance=Number.MAX_VALUE,a.trianglePositions[0].toDefault(),a.trianglePositions[1].toDefault(),a.trianglePositions[2].toDefault(),a.triangleNormals[0].toDefault(),a.triangleNormals[1].toDefault(),a.triangleNormals[2].toDefault(),!1},e.rayIntersectsTriangle=function(t,n,i,r){var a,s=e._tempVector30,o=e._tempVector31;Qe.subtract(i,n,s),Qe.subtract(r,n,o);var l=e._tempVector32;Qe.cross(t.direction,o,l);var h;if(h=Qe.dot(s,l),h>-Number.MIN_VALUE&&h_||_>1)return a=Number.NaN;var d=e._tempVector34;Qe.cross(c,s,d);var m;if(m=Qe.dot(t.direction,d),m*=u,0>m||_+m>1)return a=Number.NaN;var f;return f=Qe.dot(o,d),f*=u,a=0>f?Number.NaN:f},i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempVector32",function(){return this._tempVector32=new Qe},"_tempVector33",function(){return this._tempVector33=new Qe},"_tempVector34",function(){return this._tempVector34=new Qe},"_tempVector35",function(){return this._tempVector35=new Qe},"_tempVector36",function(){return this._tempVector36=new Qe},"_tempVector37",function(){return this._tempVector37=new Qe}]),e}()),nt=function(){function e(){this.distance=NaN,this.trianglePositions=null,this.triangleNormals=null,this.position=null,this.distance=Number.MAX_VALUE,this.trianglePositions=[new Qe,new Qe,new Qe],this.trianglePositions.length=3,this.triangleNormals=[new Qe,new Qe,new Qe],this.triangleNormals.length=3,this.position=new Qe}r(e,"laya.d3.utils.RaycastHit");var t=e.prototype;return t.copy=function(e){e.distance=this.distance,this.trianglePositions[0].cloneTo(e.trianglePositions[0]),this.trianglePositions[1].cloneTo(e.trianglePositions[1]),this.trianglePositions[2].cloneTo(e.trianglePositions[2]),this.triangleNormals[0].cloneTo(e.triangleNormals[0]),this.triangleNormals[1].cloneTo(e.triangleNormals[1]),this.triangleNormals[2].cloneTo(e.triangleNormals[2]),this.position.cloneTo(e.position)},e}(),it=function(){function e(e,t){this._width=0,this._height=0,this._width=e,this._height=t}r(e,"laya.d3.utils.Size");var t=e.prototype;return a(0,t,"width",function(){return-1===this._width?le.clientWidth:this._width}),a(0,t,"height",function(){return-1===this._height?le.clientHeight:this._height}),a(1,e,"fullScreen",function(){return new e(-1,-1)}),e}(),rt=function(){function e(){}r(e,"laya.d3.utils.Utils3D");var t=e.prototype;return t.testTangent=function(e,t,n,i){var r=t.vertexDeclaration,a=e._material;if(a.normalTexture&&!r.getVertexElementByUsage("TANGENT0")){var s=t.getData(),o=laya.d3.utils.Utils3D.generateTangent(s,r.vertexStride/4,r.getVertexElementByUsage("POSITION").offset/4,r.getVertexElementByUsage("UV").offset/4,n.getData());r=laya.d3.utils.Utils3D.getVertexTangentDeclaration(r.getVertexElements());var l=Bt.create(r,35044);return l.setData(o),t.dispose(),i.TANGENT0=l,l}return t},e._getTexturePath=function(e){var t=e.length-4;return e.indexOf(".dds")!=t&&e.indexOf(".tga")!=t&&e.indexOf(".exr")!=t&&e.indexOf(".DDS")!=t&&e.indexOf(".TGA")!=t&&e.indexOf(".EXR")!=t||(e=e.substr(0,t)+".png"),e=O.formatURL(e)},e._rotationTransformScaleSkinAnimation=function(t,n,i,r,a,s,o,l,h,u,c,_){var d=e._tempArray16_0,m=e._tempArray16_1,f=e._tempArray16_2,p=r+r,v=a+a,g=s+s,T=r*p,x=a*p,M=a*v,E=s*p,y=s*v,S=s*g,R=o*p,A=o*v,I=o*g;d[15]=1,d[0]=1-M-S,d[1]=x+I,d[2]=E-A,d[4]=x-I,d[5]=1-T-S,d[6]=y+R,d[8]=E+A,d[9]=y-R,d[10]=1-T-M,m[15]=1,m[0]=l,m[5]=h,m[10]=u;var C,V,D,L,O;for(C=0;4>C;C++)V=d[C],D=d[C+4],L=d[C+8],O=d[C+12],f[C]=V,f[C+4]=D,f[C+8]=L,f[C+12]=V*t+D*n+L*i+O;for(C=0;4>C;C++)V=f[C],D=f[C+4],L=f[C+8],O=f[C+12],c[C+_]=V*m[0]+D*m[1]+L*m[2]+O*m[3],c[C+_+4]=V*m[4]+D*m[5]+L*m[6]+O*m[7],c[C+_+8]=V*m[8]+D*m[9]+L*m[10]+O*m[11],c[C+_+12]=V*m[12]+D*m[13]+L*m[14]+O*m[15]},e._applyMeshMaterials=function(e,t){for(var n=e.meshRender,i=n.sharedMaterials,r=t.materials,a=0,s=r.length;s>a;a++)i[a]||(i[a]=r[a]);n.sharedMaterials=i},e._loadParticle=function(t,n,i){var r=Math.PI/180,a=0,s=0,o=new Ft;o.diffuseTexture=i?g.getRes(i[t.texturePath]):kt.load(t.texturePath),o.renderMode=8,n.particleRender.sharedMaterial=o;var l=n.particleSystem;l.isPerformanceMode=t.isPerformanceMode,l.duration=t.duration,l.looping=t.looping,l.prewarm=t.prewarm,l.startDelayType=t.startDelayType,l.startDelay=t.startDelay,l.startDelayMin=t.startDelayMin,l.startDelayMax=t.startDelayMax,l.startLifetimeType=t.startLifetimeType,l.startLifetimeConstant=t.startLifetimeConstant,l.startLifeTimeGradient=e._initStartLife(t.startLifetimeGradient),l.startLifetimeConstantMin=t.startLifetimeConstantMin,l.startLifetimeConstantMax=t.startLifetimeConstantMax,l.startLifeTimeGradientMin=e._initStartLife(t.startLifetimeGradientMin),l.startLifeTimeGradientMax=e._initStartLife(t.startLifetimeGradientMax),l.startSpeedType=t.startSpeedType,l.startSpeedConstant=t.startSpeedConstant,l.startSpeedConstantMin=t.startSpeedConstantMin,l.startSpeedConstantMax=t.startSpeedConstantMax,l.threeDStartSize=t.threeDStartSize,l.startSizeType=t.startSizeType,l.startSizeConstant=t.startSizeConstant;var h=t.startSizeConstantSeparate,u=l.startSizeConstantSeparate.elements;u[0]=h[0],u[1]=h[1],u[2]=h[2],l.startSizeConstantMin=t.startSizeConstantMin,l.startSizeConstantMax=t.startSizeConstantMax;var c=t.startSizeConstantMinSeparate,_=l.startSizeConstantMinSeparate.elements;_[0]=c[0],_[1]=c[1],_[2]=c[2];var d=t.startSizeConstantMaxSeparate,m=l.startSizeConstantMaxSeparate.elements;m[0]=d[0],m[1]=d[1],m[2]=d[2],l.threeDStartRotation=t.threeDStartRotation,l.startRotationType=t.startRotationType,l.startRotationConstant=t.startRotationConstant*r;var f=t.startRotationConstantSeparate,p=l.startRotationConstantSeparate.elements;p[0]=f[0]*r,p[1]=f[1]*r,p[2]=f[2]*r,l.startRotationConstantMin=t.startRotationConstantMin*r,l.startRotationConstantMax=t.startRotationConstantMax*r;var v=t.startRotationConstantMinSeparate,T=l.startRotationConstantMinSeparate.elements;T[0]=v[0]*r,T[1]=v[1]*r,T[2]=v[2]*r;var x=t.startRotationConstantMaxSeparate,M=l.startRotationConstantMaxSeparate.elements;M[0]=x[0]*r,M[1]=x[1]*r,M[2]=x[2]*r,l.randomizeRotationDirection=t.randomizeRotationDirection,l.startColorType=t.startColorType;var E=t.startColorConstant,y=l.startColorConstant.elements;y[0]=E[0],y[1]=E[1],y[2]=E[2],y[3]=E[3];var S=t.startColorConstantMin,R=l.startColorConstantMin.elements;R[0]=S[0],R[1]=S[1],R[2]=S[2],R[3]=S[3];var A=t.startColorConstantMax,I=l.startColorConstantMax.elements;I[0]=A[0],I[1]=A[1],I[2]=A[2],I[3]=A[3];var C=t.gravity,V=l.gravity.elements;V[0]=C[0],V[1]=C[1],V[2]=C[2],l.gravityModifier=t.gravityModifier,l.simulationSpace=t.simulationSpace,l.scaleMode=t.scaleMode,l.playOnAwake=t.playOnAwake,l.maxParticles=t.maxParticles;var D=t.emission,L=new lt;L.emissionRate=D.emissionRate;var O=D.bursts;if(O)for(a=0,s=O.length;s>a;a++){var b=O[a];L.addBurst(new G(b.time,b.min,b.max))}L.enbale=D.enable,l.emission=L;var P,w=t.shape;switch(w.shapeType){case 0:var N;P=N=new pt,N.radius=w.sphereRadius,N.emitFromShell=w.sphereEmitFromShell,N.randomDirection=w.sphereRandomDirection;break;case 1:var B;P=B=new ft,B.radius=w.hemiSphereRadius,B.emitFromShell=w.hemiSphereEmitFromShell,B.randomDirection=w.hemiSphereRandomDirection;break;case 2:var F;P=F=new mt,F.angle=w.coneAngle*r,F.radius=w.coneRadius,F.length=w.coneLength,F.emitType=w.coneEmitType,F.randomDirection=w.coneRandomDirection;break;case 3:var U;P=U=new _t,U.x=w.boxX,U.y=w.boxY,U.z=w.boxZ,U.randomDirection=w.boxRandomDirection;break;case 7:var Y;P=Y=new dt,Y.radius=w.circleRadius,Y.arc=w.circleArc*r,Y.emitFromEdge=w.circleEmitFromEdge,Y.randomDirection=w.circleRandomDirection}P.enbale=w.enable,l.shape=P;var j=t.velocityOverLifetime;if(j){var W,Q=j.velocity;switch(Q.type){case 0:var $=Q.constant;W=q.createByConstant(new Qe($[0],$[1],$[2]));break;case 1:W=q.createByGradient(e._initParticleVelocity(Q.gradientX),e._initParticleVelocity(Q.gradientY),e._initParticleVelocity(Q.gradientZ));break;case 2:var ie=Q.constantMin,re=Q.constantMax;W=q.createByRandomTwoConstant(new Qe(ie[0],ie[1],ie[2]),new Qe(re[0],re[1],re[2]));break;case 3:W=q.createByRandomTwoGradient(e._initParticleVelocity(Q.gradientXMin),e._initParticleVelocity(Q.gradientXMax),e._initParticleVelocity(Q.gradientYMin),e._initParticleVelocity(Q.gradientYMax),e._initParticleVelocity(Q.gradientZMin),e._initParticleVelocity(Q.gradientZMax))}var ae=new ne(W);ae.space=j.space,ae.enbale=j.enable,l.velocityOverLifetime=ae}var se=t.colorOverLifetime;if(se){var oe,le=se.color;switch(le.type){case 0:var he=le.constant;oe=X.createByConstant(new $e(he[0],he[1],he[2],he[3]));break;case 1:oe=X.createByGradient(e._initParticleColor(le.gradient));break;case 2:var ue=le.constantMin,ce=le.constantMax;oe=X.createByRandomTwoConstant(new $e(ue[0],ue[1],ue[2],ue[3]),new $e(ce[0],ce[1],ce[2],ce[3]));break;case 3:oe=X.createByRandomTwoGradient(e._initParticleColor(le.gradientMin),e._initParticleColor(le.gradientMax))}var _e=new z(oe);_e.enbale=se.enable,l.colorOverLifetime=_e}var de=t.sizeOverLifetime;if(de){var me,fe=de.size;switch(fe.type){case 0:me=fe.separateAxes?Z.createByGradientSeparate(e._initParticleSize(fe.gradientX),e._initParticleSize(fe.gradientY),e._initParticleSize(fe.gradientZ)):Z.createByGradient(e._initParticleSize(fe.gradient));break;case 1:if(fe.separateAxes){var pe=fe.constantMinSeparate,ve=fe.constantMaxSeparate;me=Z.createByRandomTwoConstantSeparate(new Qe(pe[0],pe[1],pe[2]),new Qe(ve[0],ve[1],ve[2]))}else me=Z.createByRandomTwoConstant(fe.constantMin,fe.constantMax);break;case 2:me=fe.separateAxes?Z.createByRandomTwoGradientSeparate(e._initParticleSize(fe.gradientXMin),e._initParticleSize(fe.gradientYMin),e._initParticleSize(fe.gradientZMin),e._initParticleSize(fe.gradientXMax),e._initParticleSize(fe.gradientYMax),e._initParticleSize(fe.gradientZMax)):Z.createByRandomTwoGradient(e._initParticleSize(fe.gradientMin),e._initParticleSize(fe.gradientMax))}var ge=new J(me);ge.enbale=de.enable,l.sizeOverLifetime=ge}var Te=t.rotationOverLifetime;if(Te){var xe,Me=Te.angularVelocity;switch(Me.type){case 0:Me.separateAxes||(xe=k.createByConstant(Me.constant*r));break;case 1:Me.separateAxes||(xe=k.createByGradient(e._initParticleRotation(Me.gradient)));break;case 2:Me.separateAxes||(xe=k.createByRandomTwoConstant(Me.constantMin*r,Me.constantMax*r));break;case 3:Me.separateAxes||(xe=k.createByRandomTwoGradient(e._initParticleRotation(Me.gradientMin),e._initParticleRotation(Me.gradientMax)))}var Ee=new K(xe);Ee.enbale=Te.enable,l.rotationOverLifetime=Ee}var ye=t.textureSheetAnimation;if(ye){var Se,Re=ye.frame;switch(Re.type){case 0:Se=H.createByConstant(Re.constant);break;case 1:Se=H.createByOverTime(e._initParticleFrame(Re.overTime));break;case 2:Se=H.createByRandomTwoConstant(Re.constantMin,Re.constantMax);break;case 3:Se=H.createByRandomTwoOverTime(e._initParticleFrame(Re.overTimeMin),e._initParticleFrame(Re.overTimeMax))}var Ae,Ie=ye.startFrame;switch(Ie.type){case 0:Ae=ee.createByConstant(Ie.constant);break;case 1:Ae=ee.createByRandomTwoConstant(Ie.constantMin,Ie.constantMax)}var Ce=new te(Se,Ae);Ce.enbale=ye.enable;var Ve=ye.tiles;Ce.tiles=new Ke(Ve[0],Ve[1]),Ce.type=ye.type,Ce.randomRow=ye.randomRow,Ce.cycles=ye.cycles,l.textureSheetAnimation=Ce}var De=n.particleRender;De.renderMode=t.renderMode,De.stretchedBillboardCameraSpeedScale=t.stretchedBillboardCameraSpeedScale,De.stretchedBillboardSpeedScale=t.stretchedBillboardSpeedScale,De.stretchedBillboardLengthScale=t.stretchedBillboardLengthScale,l.playOnAwake&&L.play()},e._parseHierarchyProp=function(t,n,i){var r=i.customProps,a=r.translate,s=n.transform.localPosition,o=s.elements;o[0]=a[0],o[1]=a[1],o[2]=a[2],n.transform.localPosition=s;var l=r.rotation,h=n.transform.localRotation,u=h.elements;u[0]=l[0],u[1]=l[1],u[2]=l[2],u[3]=l[3],n.transform.localRotation=h;var c=r.scale,_=n.transform.localScale,d=_.elements;switch(d[0]=c[0],d[1]=c[1],d[2]=c[2],n.transform.localScale=_,i.type){case"Sprite3D":break;case"MeshSprite3D":var m=g.getRes(t[i.instanceParams.loadPath]),f=n;f.meshFilter.sharedMesh=m,m.loaded?f.meshRender.sharedMaterials=m.materials:m.once("loaded",f,f._applyMeshMaterials);break;case"ShuriKenParticle3D":var p=n;e._loadParticle(r,p,t)}},e._parseHierarchyNode=function(e){switch(e.type){case"Sprite3D":return new vt;case"MeshSprite3D":return new Lt;case"ShuriKenParticle3D":return new Ot;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}},e._initStartLife=function(e){for(var t=new W,n=e.startLifetimes,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleVelocity=function(e){for(var t=new W,n=e.velocitys,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleColor=function(e){var t=new Y,n=e.alphas,i=0,r=0;for(i=0,r=n.length;r>i;i++){var a=n[i];t.addAlpha(a.key,a.value)}var s=e.rgbs;for(i=0,r=s.length;r>i;i++){var o=s[i],l=o.value;t.addRGB(o.key,new Qe(l[0],l[1],l[2]))}return t},e._initParticleSize=function(e){for(var t=new W,n=e.sizes,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleRotation=function(e){for(var t=new W,n=e.angularVelocitys,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value/180*Math.PI)}return t},e._initParticleFrame=function(e){for(var t=new j,n=e.frames,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._parseMaterial=function(e,t,n){var i=n.customProps,r=i.ambientColor;t.ambientColor=new Qe(r[0],r[1],r[2]);var a=i.diffuseColor;t.diffuseColor=new Qe(a[0],a[1],a[2]);var s=i.specularColor;t.specularColor=new $e(s[0],s[1],s[2],s[3]);var o=i.reflectColor;t.reflectColor=new Qe(o[0],o[1],o[2]);var l=i.diffuseTexture.texture2D;l&&(t.diffuseTexture=g.getRes(e[l]));var h=i.normalTexture.texture2D;h&&(t.normalTexture=g.getRes(e[h]));var u=i.specularTexture.texture2D;u&&(t.specularTexture=g.getRes(e[u]));var c=i.emissiveTexture.texture2D;c&&(t.emissiveTexture=g.getRes(e[c]));var _=i.ambientTexture.texture2D;_&&(t.ambientTexture=g.getRes(e[_]));var d=i.reflectTexture.texture2D;d&&(t.reflectTexture=g.getRes(e[d]))},e._computeBoneAndAnimationDatas=function(e,t,n,i,r){var a,s,o=0,l=0,h=n.length/2,u=e.length;for(a=0;u>a;o+=e[a].keyframeWidth,l+=16,a++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],i,l),0!=a&&(s=16*e[a].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,s,i,l,i,l));for(a=0;h>a;a+=16)laya.d3.utils.Utils3D.mulMatrixByArrayFast(i,a,n,h+a,r,a)},e._computeAnimationDatas=function(e,t,n){for(var i=e.length/2,r=0;i>r;r+=16)laya.d3.utils.Utils3D.mulMatrixByArrayFast(t,r,e,i+r,n,r)},e._computeBoneAndAnimationDatasByBindPoseMatrxix=function(e,t,n,i,r){var a,s,o=0,l=0,h=e.length;for(a=0;h>a;o+=e[a].keyframeWidth,l+=16,a++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],i,l),0!=a&&(s=16*e[a].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,s,i,l,i,l));var u=n.length;for(a=0;u>a;a++){var c=16*a;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,c,n[a],r,c)}},e._computeAnimationDatasByArrayAndMatrixFast=function(e,t,n){for(var i=e.length,r=0;i>r;r++){var a=16*r;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(t,a,e[r],n,a)}},e._computeRootAnimationData=function(e,t,n){for(var i=0,r=0,a=0,s=e.length;s>i;r+=e[i].keyframeWidth,a+=16,i++)laya.d3.utils.Utils3D.createAffineTransformationArray(t[r+0],t[r+1],t[r+2],t[r+3],t[r+4],t[r+5],t[r+6],t[r+7],t[r+8],t[r+9],n,a)},e.generateTangent=function(t,n,i,r,a){for(var s=3,o=n+s,l=new Float32Array(o*(t.length/n)),h=0;hL;L++)l[o*u+L]=t[n*u+L];for(L=0;s>L;L++)l[o*u+n+L]=+D.elements[L];for(L=0;n>L;L++)l[o*c+L]=t[n*c+L];for(L=0;s>L;L++)l[o*c+n+L]=+D.elements[L];for(L=0;n>L;L++)l[o*_+L]=t[n*_+L];for(L=0;s>L;L++)l[o*_+n+L]=+D.elements[L]}for(h=0;ho;++o)i[o]=a[s+o];r=0}for(o=0;4>o;o++)l=t[n+o],h=t[n+o+4],u=t[n+o+8],c=t[n+o+12],a[s+o]=l*i[r+0]+h*i[r+1]+u*i[r+2]+c*i[r+3],a[s+o+4]=l*i[r+4]+h*i[r+5]+u*i[r+6]+c*i[r+7],a[s+o+8]=l*i[r+8]+h*i[r+9]+u*i[r+10]+c*i[r+11],a[s+o+12]=l*i[r+12]+h*i[r+13]+u*i[r+14]+c*i[r+15]},e.mulMatrixByArrayFast=function(e,t,n,i,r,a){var s,o,l,h,u;for(s=0;4>s;s++)o=e[t+s],l=e[t+s+4],h=e[t+s+8],u=e[t+s+12],r[a+s]=o*n[i+0]+l*n[i+1]+h*n[i+2]+u*n[i+3],r[a+s+4]=o*n[i+4]+l*n[i+5]+h*n[i+6]+u*n[i+7],r[a+s+8]=o*n[i+8]+l*n[i+9]+h*n[i+10]+u*n[i+11],r[a+s+12]=o*n[i+12]+l*n[i+13]+h*n[i+14]+u*n[i+15]},e.mulMatrixByArrayAndMatrixFast=function(e,t,n,i,r){var a,s,o,l,h,u=n.elements,c=u[0],_=u[1],d=u[2],m=u[3],f=u[4],p=u[5],v=u[6],g=u[7],T=u[8],x=u[9],M=u[10],E=u[11],y=u[12],S=u[13],R=u[14],A=u[15],I=t,C=t+4,V=t+8,D=t+12,L=r,O=r+4,b=r+8,P=r+12;for(a=0;4>a;a++)s=e[I+a],o=e[C+a],l=e[V+a],h=e[D+a],i[L+a]=s*c+o*_+l*d+h*m,i[O+a]=s*f+o*p+l*v+h*g,i[b+a]=s*T+o*x+l*M+h*E,i[P+a]=s*y+o*S+l*R+h*A},e.createAffineTransformationArray=function(e,t,n,i,r,a,s,o,l,h,u,c){var _=i+i,d=r+r,m=a+a,f=i*_,p=i*d,v=i*m,g=r*d,T=r*m,x=a*m,M=s*_,E=s*d,y=s*m;u[c+0]=(1-(g+x))*o,u[c+1]=(p+y)*o,u[c+2]=(v-E)*o,u[c+3]=0,u[c+4]=(p-y)*l,u[c+5]=(1-(f+x))*l,u[c+6]=(T+M)*l,u[c+7]=0,u[c+8]=(v+E)*h,u[c+9]=(T-M)*h,u[c+10]=(1-(f+g))*h,u[c+11]=0,u[c+12]=e,u[c+13]=t,u[c+14]=n,u[c+15]=1},e.transformVector3ArrayToVector3ArrayCoordinate=function(t,n,i,r,a){var s=e._tempArray4_0,o=t[n+0],l=t[n+1],h=t[n+2],u=i.elements;s[0]=o*u[0]+l*u[4]+h*u[8]+u[12],s[1]=o*u[1]+l*u[5]+h*u[9]+u[13],s[2]=o*u[2]+l*u[6]+h*u[10]+u[14],s[3]=1/(o*u[3]+l*u[7]+h*u[11]+u[15]),r[a+0]=s[0]*s[3],r[a+1]=s[1]*s[3],r[a+2]=s[2]*s[3]},e.convert3DCoordTo2DScreenCoord=function(e,t){var n=e.elements,i=t.elements;i[0]=-le.clientWidth/2+n[0],i[1]=le.clientHeight/2-n[1],i[2]=n[2]},e.getURLVerion=function(e){var t=e.indexOf("?");return t>=0?e.substr(t):null},e._tempVector3_0=new Qe,e._tempVector3_1=new Qe,e._tempVector3_2=new Qe,e._tempVector3_3=new Qe,e._tempVector3_4=new Qe,e._tempVector3_5=new Qe,e._tempVector3_6=new Qe,e._tempArray4_0=new Float32Array(4),e._tempArray16_0=new Float32Array(16),e._tempArray16_1=new Float32Array(16),e._tempArray16_2=new Float32Array(16),e._tempArray16_3=new Float32Array(16),i(e,["_typeToFunO",function(){return this._typeToFunO={INT16:"writeInt16",SHORT:"writeInt16",UINT16:"writeUint16",UINT32:"writeUint32",FLOAT32:"writeFloat32",INT:"writeInt32",UINT:"writeUint32",BYTE:"writeByte",STRING:"writeUTFString"}}]),e}(),at=(function(){function e(){}return r(e,"Laya3D"),e._changeWebGLSize=function(e,t){w.onStageResize(e,t),le.clientWidth=e,le.clientHeight=t},e._initShader=function(){C.addInclude("LightHelper.glsl","\nstruct DirectionLight\n{\n vec3 Direction;\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n};\n\nstruct PointLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n vec3 Direction;\n float Spot;\n float Range;\n};\n\n\nvoid computeDirectionLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in DirectionLight dirLight,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);//不初始化在IOS中闪烁,PC中不会闪烁\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec=-normalize(dirLight.Direction);\n \n amb=matAmb*dirLight.Ambient;\n \n float diffuseFactor=dot(lightVec, normal);\n \n if(diffuseFactor>0.0)\n {\n vec3 v = reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * dirLight.Diffuse;\n spec = specFactor * matSpe.rgb * dirLight.Specular;\n }\n \n}\n\nvoid computePointLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in PointLight poiLight, in vec3 pos,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec = poiLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > poiLight.Range )\n return;\n \n lightVec /= d; \n \n amb = matAmb * poiLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if( diffuseFactor > 0.0 )\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * poiLight.Diffuse;\n spec = specFactor * matSpe.rgb * poiLight.Specular;\n }\n\n float attenuate = 1.0 / dot(poiLight.Attenuation, vec3(1.0, d, d*d));\n\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvoid ComputeSpotLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in SpotLight spoLight,in vec3 pos, in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n amb = vec3(0.0);\n dif =vec3(0.0);\n spec= vec3(0.0);\n vec3 lightVec = spoLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > spoLight.Range)\n return;\n \n lightVec /= d; \n \n amb = matAmb * spoLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if(diffuseFactor > 0.0)\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * spoLight.Diffuse;\n spec = specFactor * matSpe.rgb * spoLight.Specular;\n }\n \n float spot = pow(max(dot(-lightVec, normalize(spoLight.Direction)), 0.0), spoLight.Spot);\n\n float attenuate = spot/dot(spoLight.Attenuation, vec3(1.0, d, d*d));\n\n amb *= spot;\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent)\n{\n vec3 normalT = 2.0*normalMapSample - 1.0;\n\n // Build orthonormal basis.\n vec3 N = normalize(unitNormal);\n vec3 T = normalize(tangent- dot(tangent, N)*N);\n vec3 B = cross(T, N);\n\n mat3 TBN = mat3(T, B, N);\n\n // Transform from tangent space to world space.\n vec3 bumpedNormal = TBN*normalT;\n\n return bumpedNormal;\n}\n"),C.addInclude("VRHelper.glsl","\nvec4 DistortFishEye(vec4 p)\n{\n vec2 v = p.xy / p.w;\n float radius = length(v);// Convert to polar coords\n if (radius > 0.0)\n {\n float theta = atan(v.y,v.x);\n \n radius = pow(radius, 0.93);// Distort:\n\n v.x = radius * cos(theta);// Convert back to Cartesian\n v.y = radius * sin(theta);\n p.xy = v.xy * p.w;\n }\n return p;\n}");var e,t,n={a_Position:"POSITION",a_Color:"COLOR",a_Normal:"NORMAL",a_Texcoord0:"UV",a_Texcoord1:"UV1",a_TexcoordNext0:"NEXTUV",a_BoneWeights:"BLENDWEIGHT",a_BoneIndices:"BLENDINDICES",a_Tangent0:"TANGENT0",u_CameraPos:"CAMERAPOS",u_FogStart:"FOGSTART",u_FogRange:"FOGRANGE",u_FogColor:"FOGCOLOR","u_DirectionLight.Direction":"LIGHTDIRECTION","u_DirectionLight.Diffuse":"LIGHTDIRDIFFUSE","u_DirectionLight.Ambient":"LIGHTDIRAMBIENT","u_DirectionLight.Specular":"LIGHTDIRSPECULAR","u_PointLight.Position":"POINTLIGHTPOS","u_PointLight.Range":"POINTLIGHTRANGE","u_PointLight.Attenuation":"POINTLIGHTATTENUATION","u_PointLight.Diffuse":"POINTLIGHTDIFFUSE","u_PointLight.Ambient":"POINTLIGHTAMBIENT","u_PointLight.Specular":"POINTLIGHTSPECULAR","u_SpotLight.Position":"SPOTLIGHTPOS","u_SpotLight.Direction":"SPOTLIGHTDIRECTION","u_SpotLight.Range":"SPOTLIGHTRANGE","u_SpotLight.Spot":"SPOTLIGHTSPOT","u_SpotLight.Attenuation":"SPOTLIGHTATTENUATION","u_SpotLight.Diffuse":"SPOTLIGHTDIFFUSE","u_SpotLight.Ambient":"SPOTLIGHTAMBIENT","u_SpotLight.Specular":"SPOTLIGHTSPECULAR",u_WorldMat:"MATRIX1",u_DiffuseTexture:"DIFFUSETEXTURE",u_SpecularTexture:"SPECULARTEXTURE",u_NormalTexture:"NORMALTEXTURE",u_AmbientTexture:"AMBIENTTEXTURE",u_ReflectTexture:"REFLECTTEXTURE",u_MvpMatrix:"MVPMATRIX",u_Bones:"MATRIXARRAY0",u_Albedo:"ALBEDO",u_AlphaTestValue:"ALPHATESTVALUE",u_UVMatrix:"MATRIX2",u_UVAge:"FLOAT0",u_UVAniAge:"UVAGEX",u_MaterialDiffuse:"MATERIALDIFFUSE",u_MaterialAmbient:"MATERIALAMBIENT",u_MaterialSpecular:"MATERIALSPECULAR",u_MaterialReflect:"MATERIALREFLECT"},i=C.nameKey.add("SIMPLE");e='#include?VR "VRHelper.glsl";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM \n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP)&&NORMALMAP\nattribute vec3 a_Tangent0;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n\n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n mat3 worldMat;\n #ifdef BONE\n worldMat=mat3(u_WorldMat*skinTransform);\n #else\n worldMat=mat3(u_WorldMat);\n #endif \n v_Normal=worldMat*a_Normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n v_Tangent0=worldMat*a_Tangent0;\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG\n #ifdef BONE\n v_PositionWorld=(u_WorldMat*position).xyz;\n #else\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n #endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}',t='#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT "LightHelper.glsl";\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP \n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\nuniform sampler2D u_NormalTexture;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n vec3 normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n vec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n normal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent0));\n #else\n normal = normalize(v_Normal);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n vec3 diffuse = vec3(0.0);\n vec3 ambient = vec3(0.0);\n vec3 specular= vec3(0.0);\n vec3 dif, amb, spe;\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n vec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n #else\n toEye=normalize(u_CameraPos-v_PositionWorld);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT\n computeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n #ifdef POINTLIGHT\n computePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n\n #ifdef SPOTLIGHT\n ComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n\n \n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n specular =specular*texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n #endif\n gl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular,gl_FragColor.a);\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -toEye;\n vec3 reflectionVector = reflect(incident,normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n', +C.preCompile(i,e,t,n);var r=C.nameKey.add("SIMPLEVEXTEX");e='#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT "LightHelper.glsl";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n#include?VR "VRHelper.glsl";\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM\n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_ToEye;\nvarying vec3 v_Normal;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n \n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n #ifdef BONE\n vec3 normal=normalize( mat3(u_WorldMat*skinTransform)*a_Normal);\n #else\n vec3 normal=normalize( mat3(u_WorldMat)*a_Normal);\n #endif\n \n #ifdef REFLECTMAP\n v_Normal=normal;\n #endif\n#endif\n \n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n v_Diffuse=vec3(0.0);\n v_Ambient=vec3(0.0);\n v_Specular=vec3(0.0);\n vec3 dif, amb, spe;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n #ifdef BONE\n vec3 positionWorld=(u_WorldMat*position).xyz;\n #else\n vec3 positionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nvec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-positionWorld;\n v_ToEyeLength=length(toEye);\n toEye/=v_ToEyeLength;\n #else\n toEye=normalize(u_CameraPos-positionWorld);\n #endif\n \n #ifdef REFLECTMAP\n v_ToEye=toEye;\n #endif\n#endif\n \n#ifdef DIRECTIONLIGHT\ncomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef POINTLIGHT\ncomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\nComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}',t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_Normal;\nvarying vec3 v_ToEye;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef REFLECTMAP\n vec3 normal=normalize(v_Normal);\n #endif \n\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n vec3 specular =v_Specular*texture2D(u_SpecularTexture,v_Texcoord0).rgb;\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+specular,gl_FragColor.a);\n #else\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+v_Specular,gl_FragColor.a);\n #endif\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -v_ToEye;\n vec3 reflectionVector = reflect(incident,v_Normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((v_ToEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n",C.preCompile(r,e,t,n),n={a_Position:"POSITION",a_Texcoord:"UV",u_FogStart:"FOGSTART",u_FogRange:"FOGRANGE",u_FogColor:"FOGCOLOR",u_CameraPos:"CAMERAPOS",u_WorldMat:"MATRIX1",u_BlendTexture:"DIFFUSETEXTURE",u_LayerTexture0:"NORMALTEXTURE",u_LayerTexture1:"SPECULARTEXTURE",u_LayerTexture2:"EMISSIVETEXTURE",u_LayerTexture3:"AMBIENTTEXTURE",u_MvpMatrix:"MVPMATRIX",u_Albedo:"ALBEDO",u_Ambient:"MATERIALAMBIENT",u_UVMatrix:"MATRIX2"};var a=C.nameKey.add("TERRAIN");e='#include?VR "VRHelper.glsl";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_UVMatrix;\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\nattribute vec2 a_Texcoord;\nvarying vec2 v_Texcoord;\nvarying vec2 v_TiledTexcoord;\n#endif\n\n#ifdef FOG\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n \n #ifdef FOG\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n v_Texcoord=a_Texcoord;\n v_TiledTexcoord=(u_UVMatrix*vec4(a_Texcoord,0.0,1.0)).xy;\n #endif\n}',t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform vec3 u_Ambient;\n\n#ifdef FOG\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n varying vec2 v_Texcoord;\n varying vec2 v_TiledTexcoord;\n uniform sampler2D u_BlendTexture;\n uniform sampler2D u_LayerTexture0;\n uniform sampler2D u_LayerTexture1;\n uniform sampler2D u_LayerTexture2;\n uniform sampler2D u_LayerTexture3;\n#endif\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n vec4 blend=texture2D(u_BlendTexture, v_Texcoord);\n vec4 c0=texture2D(u_LayerTexture0, v_TiledTexcoord);\n vec4 c1=texture2D(u_LayerTexture1, v_TiledTexcoord);\n vec4 c2=texture2D(u_LayerTexture2, v_TiledTexcoord);\n vec4 c3=texture2D(u_LayerTexture3, v_TiledTexcoord);\n vec4 texColor = c0;\n texColor = mix(texColor, c1, blend.r);\n texColor = mix(texColor, c2, blend.g);\n texColor = mix(texColor, c3, blend.b);\n gl_FragColor=vec4(texColor.rgb*u_Ambient.rgb*blend.a,1.0);\n gl_FragColor=gl_FragColor*u_Albedo;\n #endif \n \n #ifdef FOG\n vec3 toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n \n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n",C.preCompile(a,e,t,n),n={a_CornerTextureCoordinate:"CORNERTEXTURECOORDINATE",a_Position:"POSITION",a_Velocity:"VELOCITY",a_StartColor:"STARTCOLOR",a_EndColor:"ENDCOLOR",a_SizeRotation:"SIZEROTATION",a_Radius:"RADIUS",a_Radian:"RADIAN",a_AgeAddScale:"STARTLIFETIME",a_Time:"TIME",u_WorldMat:"MVPMATRIX",u_View:"MATRIX1",u_Projection:"MATRIX2",u_ViewportScale:"VIEWPORTSCALE",u_CurrentTime:"CURRENTTIME",u_Duration:"DURATION",u_Gravity:"GRAVITY",u_EndVelocity:"ENDVELOCITY",u_texture:"DIFFUSETEXTURE"};var s=C.nameKey.add("PARTICLE");C.preCompile(s,E.vs,E.ps,n),n={a_CornerTextureCoordinate:"CORNERTEXTURECOORDINATE",a_Position:"POSITION",a_Direction:"DIRECTION",a_StartColor:"STARTCOLOR",a_EndColor:"ENDCOLOR",a_StartSize:"STARTSIZE",a_StartRotation0:"STARTROTATION0",a_StartRotation1:"STARTROTATION1",a_StartRotation2:"STARTROTATION2",a_StartLifeTime:"STARTLIFETIME",a_StartSpeed:"STARTSPEED",a_Time:"TIME",a_Random0:"RANDOM0",a_Random1:"RANDOM1",a_SimulationWorldPostion:"SIMULATIONWORLDPOSTION",u_WorldPosition:"WORLDPOSITION",u_WorldRotationMat:"WORLDROTATIONMATRIX",u_ThreeDStartRotation:"THREEDSTARTROTATION",u_ScalingMode:"SCALINGMODE",u_PositionScale:"POSITIONSCALE",u_SizeScale:"SIZESCALE",u_View:"MATRIX1",u_Projection:"MATRIX2",u_CurrentTime:"CURRENTTIME",u_Gravity:"GRAVITY",u_texture:"DIFFUSETEXTURE",u_CameraDirection:"CAMERADIRECTION",u_CameraUp:"CAMERAUP",u_StretchedBillboardLengthScale:"STRETCHEDBILLBOARDLENGTHSCALE",u_StretchedBillboardSpeedScale:"STRETCHEDBILLBOARDSPEEDSCALE",u_ColorOverLifeGradientAlphas:"COLOROVERLIFEGRADIENTALPHAS",u_ColorOverLifeGradientColors:"COLOROVERLIFEGRADIENTCOLORS",u_MaxColorOverLifeGradientAlphas:"MAXCOLOROVERLIFEGRADIENTALPHAS",u_MaxColorOverLifeGradientColors:"MAXCOLOROVERLIFEGRADIENTCOLORS",u_SimulationSpace:"SIMULATIONSPACE",u_VOLType:"VOLTYPE",u_VOLVelocityConst:"VOLVELOCITYCONST",u_VOLVelocityGradientX:"VOLVELOCITYGRADIENTX",u_VOLVelocityGradientY:"VOLVELOCITYGRADIENTY",u_VOLVelocityGradientZ:"VOLVELOCITYGRADIENTZ",u_VOLVelocityConstMax:"VOLVELOCITYCONSTMAX",u_VOLVelocityGradientMaxX:"VOLVELOCITYGRADIENTXMAX",u_VOLVelocityGradientMaxY:"VOLVELOCITYGRADIENTYMAX",u_VOLVelocityGradientMaxZ:"VOLVELOCITYGRADIENTZMAX",u_VOLSpaceType:"VOLSPACETYPE",u_SOLType:"SOLTYPE",u_SOLSeprarate:"SOLSEPRARATE",u_SOLSizeGradient:"SOLSIZEGRADIENT",u_SOLSizeGradientX:"SOLSIZEGRADIENTX",u_SOLSizeGradientY:"SOLSIZEGRADIENTY",u_SOLSizeGradientZ:"SOLSizeGradientZ",u_SOLSizeGradientMax:"SOLSizeGradientMax",u_SOLSizeGradientMaxX:"SOLSIZEGRADIENTXMAX",u_SOLSizeGradientMaxY:"SOLSIZEGRADIENTYMAX",u_SOLSizeGradientMaxZ:"SOLSizeGradientZMAX",u_ROLType:"ROLTYPE",u_ROLSeprarate:"ROLSEPRARATE",u_ROLAngularVelocityConst:"ROLANGULARVELOCITYCONST",u_ROLAngularVelocityConstSeprarate:"ROLANGULARVELOCITYCONSTSEPRARATE",u_ROLAngularVelocityGradient:"ROLANGULARVELOCITYGRADIENT",u_ROLAngularVelocityGradientX:"ROLANGULARVELOCITYGRADIENTX",u_ROLAngularVelocityGradientY:"ROLANGULARVELOCITYGRADIENTY",u_ROLAngularVelocityGradientZ:"ROLANGULARVELOCITYGRADIENTZ",u_ROLAngularVelocityConstMax:"ROLANGULARVELOCITYCONSTMAX",u_ROLAngularVelocityConstMaxSeprarate:"ROLANGULARVELOCITYCONSTMAXSEPRARATE",u_ROLAngularVelocityGradientMax:"ROLANGULARVELOCITYGRADIENTMAX",u_ROLAngularVelocityGradientMaxX:"ROLANGULARVELOCITYGRADIENTXMAX",u_ROLAngularVelocityGradientMaxY:"ROLANGULARVELOCITYGRADIENTYMAX",u_ROLAngularVelocityGradientMaxZ:"ROLANGULARVELOCITYGRADIENTZMAX",u_TSAType:"TEXTURESHEETANIMATIONTYPE",u_TSACycles:"TEXTURESHEETANIMATIONCYCLES",u_TSASubUVLength:"TEXTURESHEETANIMATIONSUBUVLENGTH",u_TSAGradientUVs:"TEXTURESHEETANIMATIONGRADIENTUVS",u_TSAMaxGradientUVs:"TEXTURESHEETANIMATIONGRADIENTMAXUVS"};var o=C.nameKey.add("PARTICLESHURIKEN");e="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Direction;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute vec3 a_StartRotation1;\nattribute vec3 a_StartRotation2;\nattribute float a_StartLifeTime;\nattribute float a_Time;\nattribute float a_StartSpeed;\n#ifdef VELOCITYOVERLIFETIME||COLOROVERLIFETIME||RANDOMCOLOROVERLIFETIME||SIZEOVERLIFETIME||ROTATIONOVERLIFETIME\n attribute vec4 a_Random0;\n#endif\n#ifdef TEXTURESHEETANIMATION\n attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform mat4 u_WorldRotationMat;\nuniform bool u_ThreeDStartRotation;\nuniform int u_ScalingMode;\nuniform vec3 u_PositionScale;\nuniform vec3 u_SizeScale;\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform float u_StretchedBillboardLengthScale;\nuniform float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#ifdef VELOCITYOVERLIFETIME\n uniform int u_VOLType;\n uniform vec3 u_VOLVelocityConst;\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\n uniform vec3 u_VOLVelocityConstMax;\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\n uniform int u_VOLSpaceType;\n#endif\n\n#ifdef COLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef RANDOMCOLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef SIZEOVERLIFETIME\n uniform int u_SOLType;\n uniform bool u_SOLSeprarate;\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\n#endif\n\n\n#ifdef ROTATIONOVERLIFETIME\n uniform int u_ROLType;\n uniform bool u_ROLSeprarate;\n uniform float u_ROLAngularVelocityConst;\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientZ[4];//x为key,y为旋转\n uniform float u_ROLAngularVelocityConstMax;\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];//x为key,y为旋转\n#endif\n\n#ifdef TEXTURESHEETANIMATION\n uniform int u_TSAType;\n uniform float u_TSACycles;\n uniform vec2 u_TSASubUVLength;\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float curValue;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n curValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n break;\n }\n }\n return curValue;\n}\n\n#ifdef VELOCITYOVERLIFETIME\n//float getTotalPositionFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n//{\n// float totalPosition=0.0;\n// for(int i=1;i<4;i++)\n// {\n// vec2 gradientNumber=gradientNumbers[i];\n// float key=gradientNumber.x;\n// vec2 lastGradientNumber=gradientNumbers[i-1];\n// float lastValue=lastGradientNumber.y;\n// \n// if(key>=normalizedAge){\n// float lastKey=lastGradientNumber.x;\n// float age=(normalizedAge-lastKey)/(key-lastKey);\n// \n// float velocity=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(normalizedAge-lastKey);//TODO:计算POSITION时可用优化,用已计算好速度\n// break;\n// }\n// else{\n// float velocity=(lastValue+gradientNumber.y)/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(key-lastGradientNumber.x);\n// }\n// }\n// return totalPosition;\n//}\n#endif\n\n\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float totalValue=0.0;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastValue=lastGradientNumber.y;\n \n if(key>=normalizedAge){\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n totalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_StartLifeTime*(normalizedAge-lastKey);\n break;\n }\n else{\n totalValue+=(lastValue+gradientNumber.y)/2.0*a_StartLifeTime*(key-lastGradientNumber.x);\n }\n }\n return totalValue;\n}\n\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n vec4 overTimeColor;\n for(int i=1;i<4;i++)\n {\n vec2 gradientAlpha=gradientAlphas[i];\n float alphaKey=gradientAlpha.x;\n if(alphaKey>=normalizedAge)\n {\n vec2 lastGradientAlpha=gradientAlphas[i-1];\n float lastAlphaKey=lastGradientAlpha.x;\n float age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n overTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n break;\n }\n }\n \n for(int i=1;i<4;i++)\n {\n vec4 gradientColor=gradientColors[i];\n float colorKey=gradientColor.x;\n if(colorKey>=normalizedAge)\n {\n vec4 lastGradientColor=gradientColors[i-1];\n float lastColorKey=lastGradientColor.x;\n float age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n overTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n break;\n }\n }\n return overTimeColor;\n}\n\n\n\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n float overTimeFrame;\n for(int i=1;i<4;i++)\n {\n vec2 gradientFrame=gradientFrames[i];\n float key=gradientFrame.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientFrame=gradientFrames[i-1];\n float lastKey=lastGradientFrame.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n overTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n break;\n }\n }\n return floor(overTimeFrame);\n}\n\n#ifdef VELOCITYOVERLIFETIME\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n if(u_VOLType==0)\n outLifeVelocity=u_VOLVelocityConst; \n else if(u_VOLType==1)\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n else if(u_VOLType==2)\n outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,a_Random0.x); \n else if(u_VOLType==3)\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n \n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLType==0){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==1){\n startPosition=startVelocity*age;\n lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n }\n else if(u_VOLType==2){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==3){\n startPosition=startVelocity*age;\n lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n }\n \n vec3 finalPosition;\n if(u_VOLSpaceType==0){\n if(u_ScalingMode!=2)\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition+lifePosition));\n else\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition+lifePosition);\n }\n else{\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition))+lifePosition;\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition)+lifePosition;\n }\n #else\n startPosition=startVelocity*age;\n vec3 finalPosition;\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition));\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=u_Gravity*age*normalizedAge;//计算受重力影响的位置//TODO:移除\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n #ifdef COLOROVERLIFETIME\n color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n #endif\n \n #ifdef RANDOMCOLOROVERLIFETIME\n color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n #endif\n\n return color;\n}\n\nvec2 computeParticleSize(in vec2 size,in float normalizedAge)\n{\n #ifdef SIZEOVERLIFETIME\n if(u_SOLType==0){\n if(u_SOLSeprarate){\n size*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n }\n else{\n size*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n }\n }\n else if(u_SOLType==2){\n if(u_SOLSeprarate){\n size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n }\n else{\n size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n }\n }\n #endif\n return size;\n}\n\nvec3 computeParticleRotation(in vec3 rotation,in float age,in float normalizedAge)//TODO:不分轴是否无需计算XY,Billboard模式下好像是,待确认。\n{ \n #ifdef ROTATIONOVERLIFETIME\n if(u_ROLType==0){\n if(u_ROLSeprarate){\n vec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=u_ROLAngularVelocityConst*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==1){\n if(u_ROLSeprarate){\n rotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n }\n else{\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n }\n }\n else if(u_ROLType==2){\n if(u_ROLSeprarate){\n vec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==3){\n if(u_ROLSeprarate){\n rotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n }\n else{\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n }\n }\n #endif\n return rotation;\n}\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n #ifdef TEXTURESHEETANIMATION\n if(u_TSAType==1){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n else if(u_TSAType==3){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n #endif\n return uv;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n float normalizedAge = age/a_StartLifeTime;\n vec3 lifeVelocity;\n if(normalizedAge<1.0){ \n vec3 startVelocity=a_Direction*a_StartSpeed;\n #ifdef VELOCITYOVERLIFETIME\n lifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n #endif \n \n vec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge);//计算粒子位置\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n \n #ifdef SPHERHBILLBOARD\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n if(u_ThreeDStartRotation){\n center += u_SizeScale.xzy*(mat3(a_StartRotation0,a_StartRotation1,a_StartRotation2)*(corner.x*sideVector+corner.y*upVector));\n }\n else{\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner;\n center += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n }\n \n #endif\n \n #ifdef STRETCHEDBILLBOARD\n vec3 velocity;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLSpaceType==0)\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*(startVelocity+lifeVelocity));\n else\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity)+lifeVelocity;\n #else\n velocity= mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity);\n #endif \n vec3 cameraUpVector =normalize(velocity);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec2 size=computeParticleSize(a_StartSize.xy,normalizedAge);\n const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n corner=rotaionZHalfPI*corner;\n corner.y=corner.y-abs(corner.y);\n float speed=length(velocity);//TODO:\n center +=u_SizeScale.xzy*size.x*corner.x*sideVector+((cameraUpVector*speed)*u_StretchedBillboardSpeedScale+cameraUpVector*size.y*u_StretchedBillboardLengthScale)*corner.y;\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,0.0,-1.0);\n const vec3 sideVector = vec3(1.0,0.0,0.0);\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n v_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n v_Discard=0.0;\n }\n else\n {\n v_Discard=1.0;\n }\n}\n\n", +t="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP\n if(v_Discard!=0.0)\n discard;\n gl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n #else\n gl_FragColor=vec4(0.0);\n #endif\n}",C.preCompile(o,e,t,n),n={a_Position:"POSITION",a_Texcoord0:"UV",a_Time:"TIME",u_Texture:"DIFFUSETEXTURE",u_MvpMatrix:"MVPMATRIX",u_Albedo:"ALBEDO",u_CurrentTime:"CURRENTTIME",u_Color:"UNICOLOR",u_Duration:"DURATION"};var l=C.nameKey.add("GLITTER");e="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nattribute float a_Time;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_CurrentTime;\nuniform vec4 u_Color;\nuniform float u_Duration;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n \n float age = u_CurrentTime-a_Time;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n \n v_Texcoord=a_Texcoord0;\n \n v_Color=u_Color;\n v_Color.a*=1.0-normalizedAge;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform sampler2D u_Texture;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{ \n gl_FragColor=texture2D(u_Texture, v_Texcoord)*v_Color;\n gl_FragColor=gl_FragColor*u_Albedo;\n}\n\n",C.preCompile(l,e,t,n),n={a_Position:"POSITION",u_MvpMatrix:"MVPMATRIX",u_Intensity:"INTENSITY",u_AlphaBlending:"ALPHABLENDING",u_CubeTexture:"DIFFUSETEXTURE"};var h=C.nameKey.add("SkyBox");e="attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord=a_Position.xyz;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform samplerCube u_CubeTexture;\n\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(textureCube(u_CubeTexture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",C.preCompile(h,e,t,n),n={a_Position:"POSITION",a_Texcoord0:"UV",u_MvpMatrix:"MVPMATRIX",u_Intensity:"INTENSITY",u_AlphaBlending:"ALPHABLENDING",u_texture:"DIFFUSETEXTURE"};var u=C.nameKey.add("SkyDome");e="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nuniform mat4 u_MvpMatrix;\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord = a_Texcoord0;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform sampler2D u_texture;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(texture2D(u_texture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",C.preCompile(u,e,t,n)},e._initResourceLoad=function(){var t=T.createMap;t.lh=[vt,"SPRITE3DHIERARCHY"],t.lm=[zt,"MESH"],t.lmat=[wt,"MATERIAL"],t.ltc=[Xt,"TEXTURECUBE"],t.jpg=[kt,"nativeimage"],t.jpeg=[kt,"nativeimage"],t.png=[kt,"nativeimage"],t.lsani=[o,"arraybuffer"],t.lrani=[o,"arraybuffer"],t.ani=[o,"arraybuffer"],t.lani=[o,"arraybuffer"],g.parserMap.SPRITE3DHIERARCHY=e._loadSprite3DHierarchy,g.parserMap.MESH=e._loadMesh,g.parserMap.MATERIAL=e._loadMaterial,g.parserMap.TEXTURECUBE=e._loadTextureCube},e.READ_BLOCK=function(){return e._readData.pos+=4,!0},e.READ_DATA=function(){return e._DATA.offset=e._readData.getUint32(),e._DATA.size=e._readData.getUint32(),!0},e.READ_STRINGS=function(){var t=[],n={offset:0,size:0};n.offset=e._readData.getUint16(),n.size=e._readData.getUint16();e._readData.pos;e._readData.pos=n.offset+e._DATA.offset;for(var i=0;ih;h++)e._getSprite3DHierarchyInnerUrls(l[h],n,i,r)},e._loadSprite3DHierarchy=function(t){var n=new g;n.on("complete",null,e._onSprite3DHierarchylhLoaded,[t]),n.load(t.url,"text",!1,null,!0)},e._onSprite3DHierarchylhLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s=[],o={},l=JSON.parse(n);e._getSprite3DHierarchyInnerUrls(l,s,o,r);var h=s.length,u=h+1,c=1/u;if(e._onProcessChange(t,0,c,1),h>0){var _=p.create(null,e._onProcessChange,[t,c,h/u],!1);e._innerSprite3DHierarchyLoaderManager.create(s,p.create(null,e._onSprite3DMeshsLoaded,[t,_,n,o]),_)}else e._onSprite3DMeshsLoaded(t,null,n,null);O.basePath=a},e._onSprite3DMeshsLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},e._loadMesh=function(t){var n=new g;n.on("complete",null,e._onMeshLmLoaded,[t]),n.load(t.url,"arraybuffer",!1,null,!0)},e._onMeshLmLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s,o,l={};e._readData=new c(n),e._readData.pos=0,e._readData.readUTFString(),e.READ_BLOCK();var h=0,u=0;for(h=0;2>h;h++){var _=e._readData.getUint16(),d=e._strings[_],m=e["READ_"+d];if(null==m)throw new Error("model file err,no this function:"+_+" "+d);1===h?s=m.call():m.call()}for(h=0,u=s.length;u>h;h++){var f=s[h];o=O.formatURL(f),r&&(o+=r),s[h]=o,l[f]=o}var v=1,g=v+1,T=1/g;e._onProcessChange(t,0,T,1);var x=p.create(null,e._onProcessChange,[t,T,v/g],!1);e._innerMeshLoaderManager.create(s,p.create(null,e._onMeshMateialLoaded,[t,x,n,l]),x,wt),O.basePath=a},e._onMeshMateialLoaded=function(e,t,n,i){e.endLoad([n,i]),t.recover()},e._getMaterialTexturePath=function(e,t){var n=e.length-4;return e.indexOf(".dds")!=n&&e.indexOf(".tga")!=n&&e.indexOf(".exr")!=n&&e.indexOf(".DDS")!=n&&e.indexOf(".TGA")!=n&&e.indexOf(".EXR")!=n||(e=e.substr(0,n)+".png"),e=O.formatURL(e),t&&(e+=t),e},e._loadMaterial=function(t){var n=new g;n.on("complete",null,e._onMaterilLmatLoaded,[t]),n.load(t.url,"json",!1,null,!0)},e._onMaterilLmatLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s,o=[],l={},h=n.customProps,u=h.diffuseTexture.texture2D;u&&(s=e._getMaterialTexturePath(u,r),o.push(s),l[u]=s);var c=h.normalTexture.texture2D;c&&(s=e._getMaterialTexturePath(c,r),o.push(s),l[c]=s);var _=h.specularTexture.texture2D;_&&(s=e._getMaterialTexturePath(_,r),o.push(s),l[_]=s);var d=h.emissiveTexture.texture2D;d&&(s=e._getMaterialTexturePath(d,r),o.push(s),l[d]=s);var m=h.ambientTexture.texture2D;m&&(s=e._getMaterialTexturePath(m,r),o.push(s),l[m]=s);var f=h.reflectTexture.texture2D;f&&(s=e._getMaterialTexturePath(f,r),o.push(s),l[f]=s);var v=o.length,g=v+1,T=1/g;if(e._onProcessChange(t,0,T,1),v>0){var x=p.create(null,e._onProcessChange,[t,T,v/g],!1);e._innerMaterialLoaderManager.create(o,p.create(null,e._onMateialTexturesLoaded,[t,x,n,l]),x,kt)}else e._onMateialTexturesLoaded(t,null,n,null);O.basePath=a},e._onMateialTexturesLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},e._loadTextureCube=function(t){var n=new g;n.on("complete",null,e._onTextureCubeLtcLoaded,[t]),n.load(t.url,"json",!1,null,!0)},e._onTextureCubeLtcLoaded=function(t,n){var i=O.basePath;O.basePath=O.getPath(O.formatURL(t.url));var r=[O.formatURL(n.px),O.formatURL(n.nx),O.formatURL(n.py),O.formatURL(n.ny),O.formatURL(n.pz),O.formatURL(n.nz)],a=1/7;e._onProcessChange(t,0,a,1);var s=p.create(null,e._onProcessChange,[t,a,6/7],!1);e._innerTextureCubeLoaderManager.load(r,p.create(null,e._onTextureCubeImagesLoaded,[t,r,s]),s,"nativeimage"),O.basePath=i},e._onTextureCubeImagesLoaded=function(e,t,n){var i=[];i.length=6;for(var r=0;6>r;r++){var a=t[r];i[r]=g.getRes(a),g.clearRes(a)}e.endLoad(i),n.recover()},e._onProcessChange=function(e,t,n,i){var i=t+i*n;1>i&&e.event("progress",i)},e.init=function(t,i,r,a,s){return void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===s&&(s=!1),w.enable()?(e._innerTextureCubeLoaderManager.maxLoader=1,e._innerMaterialLoaderManager.maxLoader=1,e._innerMeshLoaderManager.maxLoader=1,e._innerSprite3DHierarchyLoaderManager.maxLoader=1,I.changeWebGLSize=e._changeWebGLSize,d.isAntialias=r,d.isAlpha=a,d.premultipliedAlpha=s,S.is3DMode=!0,n.init(t,i),U.__init__(),ct.__init__(),e._initShader(),void e._initResourceLoad()):void alert("Laya3D init err,must support webGL!")},e._readData=null,e.SPRITE3DHIERARCHY="SPRITE3DHIERARCHY",e.MESH="MESH",e.MATERIAL="MATERIAL",e.TEXTURECUBE="TEXTURECUBE",i(e,["_DATA",function(){return this._DATA={offset:0,size:0}},"_strings",function(){return this._strings=["BLOCK","DATA","STRINGS"]},"_innerTextureCubeLoaderManager",function(){return this._innerTextureCubeLoaderManager=new T},"_innerMaterialLoaderManager",function(){return this._innerMaterialLoaderManager=new T},"_innerMeshLoaderManager",function(){return this._innerMeshLoaderManager=new T},"_innerSprite3DHierarchyLoaderManager",function(){return this._innerSprite3DHierarchyLoaderManager=new T}]),e}(),function(e){function t(){this._id=0,this._cachedOwnerLayerMask=0,this._cachedOwnerEnable=!1,this._enable=!1,this._owner=null,this.started=!1,t.__super.call(this),this._id=t._uniqueIDCounter,t._uniqueIDCounter++}r(t,"laya.d3.component.Component3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IUpdate":!0}),i._onLayerChanged=function(e){this._cachedOwnerLayerMask=e.mask},i._onEnableChanged=function(e){this._cachedOwnerEnable=e},i._initialize=function(e){this._owner=e,this.enable=!0,this.started=!1,this._cachedOwnerLayerMask=e.layer.mask,this._owner.on("layerchanged",this,this._onLayerChanged),this._cachedOwnerEnable=e.enable,this._owner.on("enabledchanged",this,this._onEnableChanged),this._load(e)},i._uninitialize=function(){this._unload(this.owner),this._owner=null},i._load=function(e){},i._start=function(e){},i._update=function(e){},i._lateUpdate=function(e){},i._preRenderUpdate=function(e){},i._postRenderUpdate=function(e){},i._unload=function(e){this.offAll()},a(0,i,"id",function(){return this._id}),a(0,i,"owner",function(){return this._owner}),a(0,i,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enabledchanged",this._enable))}),a(0,i,"isActive",function(){return U.isActive(this._cachedOwnerLayerMask)&&this._cachedOwnerEnable&&this._enable}),a(0,i,"isVisible",function(){return U.isVisible(this._cachedOwnerLayerMask)&&this._cachedOwnerEnable&&this._enable}),t._uniqueIDCounter=1,t}(f)),st=function(e){function t(e){this._owner=null,this._enable=!1,this._renderObject=null,this._materials=null,this._boundingSphereNeedChange=!1,this._boundingBoxNeedChange=!1,this._boundingSphere=null,this._boundingBox=null,t.__super.call(this),this._owner=e,this._enable=!0,this._boundingBox=new ze(new Qe,new Qe),this._boundingSphere=new ke(new Qe,0),this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0,this._renderObject=new _e,this._renderObject._render=this,this._renderObject._layerMask=this._owner.layer.mask,this._renderObject._ownerEnable=this._owner.enable,this._renderObject._enable=this._enable,this._materials=[],this._owner.transform.on("worldmatrixneedchanged",this,this._onWorldMatNeedChange),this._owner.on("layerchanged",this,this._onOwnerLayerChanged),this._owner.on("enabledchanged",this,this._onOwnerEnableChanged),this.on("enabledchanged",this,this._onEnableChanged)}r(t,"laya.d3.core.render.BaseRender",e);var i=t.prototype;return n.imps(i,{"laya.resource.IDestroy":!0}),i._onWorldMatNeedChange=function(){this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0},i._onOwnerLayerChanged=function(e){this._renderObject._layerMask=e.mask},i._onOwnerEnableChanged=function(e){this._renderObject._ownerEnable=e},i._onEnableChanged=function(e,t){this._renderObject._enable=t},i._calculateBoundingSphere=function(){throw"BaseRender: must override it."},i._calculateBoundingBox=function(){throw"BaseRender: must override it."},i._destroy=function(){this.offAll(),this._owner=null,this._renderObject=null,this._materials=null,this._boundingBox=null,this._boundingSphere=null},a(0,i,"enable",function(){return this._enable},function(e){this._enable=e,this.event("enabledchanged",[this,e])}),a(0,i,"boundingBox",function(){return this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox}),a(0,i,"sharedMaterials",function(){var e=this._materials.slice();return e},function(e){if(!e)throw new Error("MeshRender: shadredMaterials value can't be null.");this._materials=e;for(var t=0,n=e.length;n>t;t++)this.event("materialchanged",[this,t,e[t]])}),a(0,i,"renderObject",function(){return this._renderObject}),a(0,i,"boundingSphere",function(){return this._boundingSphereNeedChange&&(this._calculateBoundingSphere(),this._boundingSphereNeedChange=!1),this._boundingSphere}),a(0,i,"material",function(){var e=this._materials[0];if(e&&!e._isInstance){var t=new e.constructor;e.cloneTo(t),t.name=t.name+"(Instance)",t._isInstance=!0,this._materials[0]=t,this.event("materialchanged",[this,0,t])}return this._materials[0]},function(e){this._materials[0]=e,this.event("materialchanged",[this,0,e])}),a(0,i,"materials",function(){for(var e=0,t=this._materials.length;t>e;e++){var n=this._materials[e];if(!n._isInstance){var i=new n.constructor;n.cloneTo(i),i.name=i.name+"(Instance)",i._isInstance=!0,this._materials[e]=i,this.event("materialchanged",[this,e,i])}}return this._materials.slice()},function(e){if(!e)throw new Error("MeshRender: materials value can't be null.");this._materials=e;for(var t=0,n=e.length;n>t;t++)this.event("materialchanged",[this,t,e[t]])}),a(0,i,"sharedMaterial",function(){return this._materials[0]},function(e){this._materials[0]=e,this.event("materialchanged",[this,0,e])}),t}(f),ot=function(e){function t(e){this._owner=null,this._sharedMesh=null,t.__super.call(this),this._owner=e}r(t,"laya.d3.core.MeshFilter",e);var i=t.prototype;return n.imps(i,{"laya.resource.IDestroy":!0}),i._destroy=function(){this.offAll(),this._owner=null,this._sharedMesh=null},a(0,i,"sharedMesh",function(){return this._sharedMesh},function(e){var t=this._sharedMesh;this._sharedMesh=e,this.event("meshchanged",[this,t,e])}),t}(f),lt=function(e){function t(){this._burstsIndex=0,this._bursts=null,this._startDelay=NaN,this._isPlaying=!1,this._isPaused=!1,this._frameTime=NaN,this._emissionTime=NaN,this._playbackTime=NaN,this._minEmissionTime=NaN,this._emissionRate=0,this._particleSystem=null,this._shape=null,this.enbale=!1,t.__super.call(this),this._burstsIndex=0,this._isPlaying=!1,this._isPaused=!1,this._frameTime=0,this._emissionTime=0,this._playbackTime=0,this.emissionRate=10,this._bursts=[]}r(t,"laya.d3.core.particleShuriKen.module.Emission",e);var s=t.prototype;return n.imps(s,{"laya.resource.IDestroy":!0}),s._burst=function(e,t){for(var n=0,i=this._bursts.length;this._burstsIndex=e&&t>=a))break;var s=x.lerp(r.minCount,r.maxCount,Math.random());n+=s}return n},s._advanceTime=function(e,t){if(this._isPlaying&&!this._isPaused&&(this._playbackTime+=e,!(this._playbackTimer){if(a+=this._burst(i,r),!this._particleSystem.looping){for(this._isPlaying=!1,a=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,a),n=0;a>n;n++)this.emit(t);return void this.event("stopped")}this._emissionTime-=r,this.event("complete"),this._burstsIndex=0,a+=this._burst(0,this._emissionTime)}else a+=this._burst(i,this._emissionTime);for(a=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,a),n=0;a>n;n++)this.emit(t);if(this._frameTime+=e,!(this._frameTimethis._minEmissionTime&&this.emit(t);)this._frameTime-=this._minEmissionTime}},s._destroy=function(){this.offAll(),this._bursts=null,this._particleSystem=null},s.play=function(){switch(this._burstsIndex=0,this._isPlaying=!0,this._isPaused=!1,this._frameTime=0,this._emissionTime=0,this._playbackTime=0,this._particleSystem.startDelayType){case 0:this._startDelay=this._particleSystem.startDelay;break;case 1:this._startDelay=x.lerp(this._particleSystem.startDelayMin,this._particleSystem.startDelayMax,Math.random());break;default:throw new Error("Utils3D: startDelayType is invalid.")}this._particleSystem._startUpdateLoopCount=L.loopCount,this.event("played")},s.pause=function(){this._isPaused=!0,this.event("paused")},s.stop=function(){this._burstsIndex=0,this._frameTime=0,this._isPlaying=!1,this._isPaused=!1,this._emissionTime=0,this._playbackTime=0,this.event("stopped")},s.getBurstsCount=function(){return this._bursts.length},s.getBurstByIndex=function(e){return this._bursts[e]},s.addBurst=function(e){var t=this._bursts.length;if(t>0)for(var n=0;t>n;n++)this._bursts[n].time>e.time&&this._bursts.splice(n,0,e);else this._bursts.push(e)},s.removeBurst=function(e){var t=this._bursts.indexOf(e);if(-1!==t){this._bursts.splice(t,1);var n=this._bursts.length;this._burstsIndex>n&&(this._burstsIndex=n)}},s.removeBurstByIndex=function(e){this._bursts.splice(e,1);var t=this._bursts.length;this._burstsIndex>t&&(this._burstsIndex=t)},s.clearBurst=function(){this._burstsIndex=0,this._bursts.length=0},s.update=function(e,t){this.enbale&&this._advanceTime(e,t)},s.emit=function(e){var n=t._tempPosition,i=t._tempDirection;if(this._shape.enbale)this._shape.generatePositionAndDirection(n,i);else{var r=n.elements,a=i.elements;r[0]=r[1]=r[2]=0,a[0]=a[1]=0,a[2]=1}return this._particleSystem.addParticle(n,i,e)},a(0,s,"playbackTime",function(){return this._playbackTime}),a(0,s,"isPlaying",function(){return this._isPlaying}),a(0,s,"isPaused",function(){return this._isPaused}),a(0,s,"emissionTime",function(){var e=this._particleSystem.duration;return this._emissionTime>e?e:this._emissionTime}),a(0,s,"emissionRate",function(){return this._emissionRate},function(e){if(0>e)throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");this._emissionRate=e,0===e?this._minEmissionTime=2147483647:this._minEmissionTime=1/e}),i(t,["_tempPosition",function(){return this._tempPosition=new Qe},"_tempDirection",function(){return this._tempDirection=new Qe}]),t}(f),ht=function(e){function t(e){this._owner=null,this._preWorldTransformModifyID=-1,this._localUpdate=!1,this._worldUpdate=!0,this._parent=null,t.__super.call(this),this._tempMatrix0=new je,this._tempQuaternion0=new Ze,this._tempVector30=new Qe,this._localPosition=new Qe,this._localRotation=new Ze(0,0,0,1),this._localScale=new Qe(1,1,1),this._localMatrix=new je,this._position=new Qe,this._rotation=new Ze(0,0,0,1),this._scale=new Qe(1,1,1),this._worldMatrix=new je,this._forward=new Qe,this._up=new Qe,this._right=new Qe,this._owner=e}r(t,"laya.d3.core.Transform3D",e);var n=t.prototype;return n._updateLocalMatrix=function(){je.createAffineTransformation(this._localPosition,this._localRotation,this._localScale,this._localMatrix)},n._onLocalTransform=function(){this._localUpdate=!0},n._onWorldTransform=function(){if(!this._worldUpdate){this._worldUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._owner._childs.length;t>e;e++)this._owner._childs[e].transform._onWorldTransform()}},n.translate=function(e,t){void 0===t&&(t=!0),t?(je.createFromQuaternion(this.localRotation,this._tempMatrix0),Qe.transformCoordinate(e,this._tempMatrix0,this._tempVector30),Qe.add(this.localPosition,this._tempVector30,this._localPosition),this.localPosition=this._localPosition):(Qe.add(this.position,e,this._position),this.position=this._position)},n.rotate=function(e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!0);var i;n?i=e:(Qe.scale(e,Math.PI/180,this._tempVector30),i=this._tempVector30),Ze.createFromYawPitchRoll(i.y,i.x,i.z,this._tempQuaternion0),t?(Ze.multiply(this._localRotation,this._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(Ze.multiply(this._tempQuaternion0,this.rotation,this._rotation),this.rotation=this._rotation)},a(0,n,"localRotation",function(){return this._localRotation},function(e){this._localRotation=e,this._localRotation.normalize(this._localRotation),this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"worldMatrix",function(){return this._worldUpdate?(null!=this._parent?je.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix):this.localMatrix.cloneTo(this._worldMatrix),this._worldUpdate=!1,this._worldMatrix):this._worldMatrix},function(e){null===this._parent?this.localMatrix=e:(this._parent.worldMatrix.invert(this._localMatrix),je.multiply(this._localMatrix,e,this._localMatrix),this.localMatrix=this._localMatrix)}),a(0,n,"worldNeedUpdate",function(){return this._worldUpdate}),a(0,n,"localMatrix",function(){return this._localUpdate&&(this._updateLocalMatrix(),this._localUpdate=!1),this._localMatrix},function(e){this._localMatrix=e,this._localMatrix.decompose(this._localPosition,this._localRotation,this._localScale),this._onWorldTransform()}),a(0,n,"localPosition",function(){return this._localPosition},function(e){this._localPosition=e,this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"localScale",function(){return this._localScale},function(e){this._localScale=e,this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"position",function(){if(null!==this._parent){var e=this.worldMatrix.elements;this._position.elements[0]=e[12],this._position.elements[1]=e[13],this._position.elements[2]=e[14]}else this._localPosition.cloneTo(this._position);return this._position},function(e){null!==this._parent?(this._parent.worldMatrix.invert(this._tempMatrix0),Qe.transformCoordinate(e,this._tempMatrix0,this._localPosition),this.localPosition=this._localPosition):(e.cloneTo(this._localPosition),this.localPosition=this._localPosition)}),a(0,n,"rotation",function(){return null!==this._parent?this.worldMatrix.decompose(this._position,this._rotation,this._scale):this._localRotation.cloneTo(this._rotation),this._rotation},function(e){null!==this._parent?(this._parent.rotation.invert(this._tempQuaternion0),Ze.multiply(e,this._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(e.cloneTo(this._localRotation),this.localRotation=this._localRotation)}),a(0,n,"localRotationEuler",null,function(e){Ze.createFromYawPitchRoll(e.y,e.x,e.z,this._localRotation),this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"scale",function(){return null!==this._parent?Qe.multiply(this._parent.scale,this._localScale,this._scale):this._localScale.cloneTo(this._scale),this._scale}),a(0,n,"rotationEuler",null,function(e){Ze.createFromYawPitchRoll(e.y,e.x,e.z,this._rotation),this.rotation=this._rotation}),a(0,n,"forward",function(){var e=this.worldMatrix.elements;return this._forward.elements[0]=-e[8],this._forward.elements[1]=-e[9],this._forward.elements[2]=-e[10],this._forward}),a(0,n,"up",function(){var e=this.worldMatrix.elements;return this._up.elements[0]=e[4],this._up.elements[1]=e[5],this._up.elements[2]=e[6],this._up}),a(0,n,"right",function(){var e=this.worldMatrix.elements;return this._right.elements[0]=e[0],this._right.elements[1]=e[1],this._right.elements[2]=e[2],this._right}),a(0,n,"parent",null,function(e){this._parent=e,this._onWorldTransform()}),t}(f),ut=(function(e){function t(){this._rotation=0,this._matNeedUpdte=!1,t.__super.call(this),this._tempTitlingV3=new Qe,this._tempRotationMatrix=new je,this._tempTitlingMatrix=new je,this._matrix=new je,this._offset=new Ke,this._tiling=new Ke}r(t,"laya.d3.core.TransformUV",e);var n=t.prototype;return n._updateMatrix=function(){this._tempTitlingV3.elements[0]=this._tiling.x,this._tempTitlingV3.elements[1]=this._tiling.y,this._tempTitlingV3.elements[2]=1,je.createScaling(this._tempTitlingV3,this._tempTitlingMatrix),je.createRotationZ(this._rotation,this._tempRotationMatrix),je.multiply(this._tempRotationMatrix,this._tempTitlingMatrix,this._matrix);var e=this._matrix.elements;e[12]=this._offset.x,e[13]=this._offset.y,e[14]=0},a(0,n,"matrix",function(){return this._matNeedUpdte&&(this._updateMatrix(),this._matNeedUpdte=!1),this._matrix}),a(0,n,"tiling",function(){return this._tiling},function(e){this._tiling=e,this._matNeedUpdte=!0}),a(0,n,"offset",function(){return this._offset},function(e){this._offset=e,this._matNeedUpdte=!0}),a(0,n,"rotation",function(){return this._rotation},function(e){this._rotation=e,this._matNeedUpdte=!0}),t}(f),function(e){function t(e){this._floatCountPerVertex=6,this._owner=null,this._vertices=null,this._vertexBuffer=null,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=NaN,this._drawCounter=0,this.scLeft=null,this.scRight=null,this._numPositionMode=0,this._numPositionVelocityMode=0,this._lastTime=NaN,this._needPatch=!1,this._lastPatchAddPos0=null,this._lastPatchAddPos1=null,this._lastPatchAddTime=NaN,this.lifeTime=NaN,this.minSegmentDistance=NaN,this.minInterpDistance=NaN,this.maxSlerpCount=0,this.color=null,this._maxSegments=0,t.__super.call(this),this._tempVector0=new Qe,this._tempVector1=new Qe,this._tempVector2=new Qe,this._tempVector3=new Qe,this._albedo=new $e(1,1,1,1),this._posModeLastPosition0=new Qe,this._posModeLastPosition1=new Qe,this._posModePosition0=new Qe,this._posModePosition1=new Qe,this._posVelModePosition0=new Qe,this._posVelModeVelocity0=new Qe,this._posVelModePosition1=new Qe,this._posVelModeVelocity1=new Qe,this._owner=e,this._lastTime=0,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=0,this._drawCounter=0,this._needPatch=!1,this._lastPatchAddPos0=new Qe,this._lastPatchAddPos1=new Qe,this.scLeft=new B,this.scRight=new B,this.lifeTime=.5,this.minSegmentDistance=.1,this.minInterpDistance=.6,this.maxSlerpCount=128,this.color=new $e(1,1,1,1),this._maxSegments=200,this._owner.on("enabledchanged",this,this._onEnableChanged)}r(t,"laya.d3.resource.tempelet.GlitterTemplet",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IRenderable":!0}),i._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},i._getIndexBuffer=function(){return null},i._initialize=function(){this._vertexBuffer=Bt.create(ve.vertexDeclaration,2*this.maxSegments,35048),this._vertices=new Float32Array(this.maxSegments*this._floatCountPerVertex*2)},i._onEnableChanged=function(e){e||(this._numPositionMode=0,this._numPositionVelocityMode=0,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=0,this._drawCounter=0)},i._updateTextureCoordinates=function(){this._firstActiveElement0&&this._updateSubTextureCoordinates(0,2*this._firstFreeElement))},i._updateSubTextureCoordinates=function(e,t){for(var n=2*e,i=0;t>i;i+=2){var r=n+i,a=r*this._floatCountPerVertex,s=(r+1)*this._floatCountPerVertex;this._vertices[a+3]=this._vertices[s+3]=(this._vertices[a+5]-this._currentTime)/this.lifeTime}},i._retireActiveGlitter=function(){for(var e=this.lifeTime,t=2*this._floatCountPerVertex;this._firstActiveElement!=this._firstNewElement;){var n=this._firstActiveElement*t+5,i=this._currentTime-this._vertices[n];if(e>i)break;this._vertices[n]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this.maxSegments&&(this._firstActiveElement=0)}},i._freeRetiredGlitter=function(){for(var e=2*this._floatCountPerVertex;this._firstRetiredElement!=this._firstActiveElement;){var t=this._drawCounter-this._vertices[this._firstRetiredElement*e+5];if(3>t)break;this._firstRetiredElement++,this._firstRetiredElement>=this.maxSegments&&(this._firstRetiredElement=0)}},i._calcVelocity=function(e,t,n){Qe.subtract(e,t,n),Qe.scale(n,.5,n)},i._addNewGlitterSegementToVertexBuffer=function(){var e=0;this._firstActiveElement0&&this._vertexBuffer.setData(this._vertices,0,0,2*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},i._addGlitter=function(e,t,n){this._needPatch&&(this._needPatch=!1,this._addGlitter(this._lastPatchAddPos0,this._lastPatchAddPos1,this._lastPatchAddTime));var i=this._firstFreeElement+1;if(i>=this.maxSegments&&(i=0,e.cloneTo(this._lastPatchAddPos0),t.cloneTo(this._lastPatchAddPos1),this._lastPatchAddTime=n,this._needPatch=!0),i===this._firstRetiredElement)throw new Error("GlitterTemplet:current segement count have large than maxSegments,please adjust the value of maxSegments or add Glitter Vertex Frequency.");var r=e.elements,a=t.elements,s=0,o=this._firstFreeElement*this._floatCountPerVertex*2;for(s=0;3>s;s++)this._vertices[o+s]=r[s];this._vertices[o+3]=0,this._vertices[o+4]=0,this._vertices[o+5]=n;var l=o+this._floatCountPerVertex;for(s=0;3>s;s++)this._vertices[l+s]=a[s];this._vertices[l+3]=0,this._vertices[l+4]=1,this._vertices[l+5]=n,this._firstFreeElement=i},i._update=function(e){this._currentTime+=e/1e3,this._retireActiveGlitter(),this._freeRetiredGlitter(),this._firstActiveElement==this._firstFreeElement&&(this._currentTime=0),this._firstRetiredElement==this._firstActiveElement&&(this._drawCounter=0),this._updateTextureCoordinates()},i._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this._addNewGlitterSegementToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer.bindWithIndexBuffer(null),!0):!1},i._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement0&&(t=2*this._firstFreeElement,n.drawArrays(5,0,t),L.trianglesFaces+=t-2,L.drawCall++))},i.addVertexPosition=function(e,t){if(this._owner.enable)if(this._numPositionMode<2)0===this._numPositionMode?(e.cloneTo(this._posModeLastPosition0),t.cloneTo(this._posModeLastPosition1)):(e.cloneTo(this._posModePosition0),t.cloneTo(this._posModePosition1)),this._numPositionMode++;else{var n=this._tempVector2;this._calcVelocity(e,this._posModeLastPosition0,n);var i=this._tempVector3;this._calcVelocity(t,this._posModeLastPosition1,i),this.addVertexPositionVelocity(this._posModePosition0,n,this._posModePosition1,i),this._posModePosition0.cloneTo(this._posModeLastPosition0),this._posModePosition1.cloneTo(this._posModeLastPosition1),e.cloneTo(this._posModePosition0),t.cloneTo(this._posModePosition1)}},i.addVertexPositionVelocity=function(e,t,n,i){if(this._owner.enable){if(0===this._numPositionVelocityMode)this._numPositionVelocityMode++;else{var r=this._tempVector0;Qe.subtract(e,this._posVelModePosition0,r);var a=Qe.scalarLength(r);Qe.subtract(n,this._posVelModePosition1,r);var s=Qe.scalarLength(r),o=0,l=l;if(l>a&&l>s)return;if(o=1+Math.floor(Math.max(a,s)/this.minInterpDistance),1===o)this._addGlitter(e,n,this._currentTime);else{o=Math.min(o,this.maxSlerpCount),this.scLeft.Init(this._posVelModePosition0,this._posVelModeVelocity0,e,t),this.scRight.Init(this._posVelModePosition1,this._posVelModeVelocity1,n,i); +for(var h=1/o,u=h,c=this._currentTime-this._lastTime,_=1;o>=_;_++){var d=this._tempVector0;this.scLeft.Slerp(u,d);var m=this._tempVector1;this.scRight.Slerp(u,m);var f=this._lastTime+c*_/o;this._addGlitter(d,m,f),u+=h}}}this._lastTime=this._currentTime,e.cloneTo(this._posVelModePosition0),t.cloneTo(this._posVelModeVelocity0),n.cloneTo(this._posVelModePosition1),i.cloneTo(this._posVelModeVelocity1)}},i.dispose=function(){this._owner.off("enabledchanged",this,this._onEnableChanged)},a(0,i,"maxSegments",function(){return this._maxSegments-1},function(e){var t=e+1;t!==this._maxSegments&&(this._maxSegments=t,this._vertexBuffer&&this._vertexBuffer.dispose(),this._initialize())}),a(0,i,"indexOfHost",function(){return 0}),a(0,i,"_vertexBufferCount",function(){return 1}),a(0,i,"triangleCount",function(){var e=0;return this._firstActiveElementi;i++)this.centerPosition.elements[i]=n.boxEmitterCenterPosition[i],this.size.elements[i]=n.boxEmitterSize[i],this.velocity.elements[i]=n.boxEmitterVelocity[i],this.velocityAddVariance.elements[i]=n.boxEmitterVelocityAddVariance[i];this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterBox",e);var n=t.prototype;return n._randomPositionOnBox=function(){var e=this._resultPosition.elements,t=this.centerPosition.elements,n=this.size.elements;return e[0]=t[0]+n[0]*(Math.random()-.5),e[1]=t[1]+n[1]*(Math.random()-.5),e[2]=t[2]+n[2]*(Math.random()-.5),this._resultPosition},n._randomVelocityOnBox=function(){var e=this._resultVelocity.elements,t=this.velocity.elements,n=this.velocityAddVariance.elements;return e[0]=t[0]+n[0]*Math.random(),e[1]=t[1]+n[1]*Math.random(),e[2]=t[2]+n[2]*Math.random(),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnBox(),this._randomVelocityOnBox())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,t.__super.call(this),this._resultPosition=new Qe,this._resultVelocity=new Qe,this.position=new Qe,this.positionVariance=new Qe,this.velocity=new Qe,this.velocityAddVariance=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.position.elements[i]=n.pointEmitterPosition[i],this.positionVariance.elements[i]=n.pointEmitterPositionVariance[i],this.velocity.elements[i]=n.pointEmitterVelocity[i],this.velocityAddVariance.elements[i]=n.pointEmitterVelocityAddVariance[i];this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterPoint",e);var n=t.prototype;return n._randomPositionOnPoint=function(){var e=this._resultPosition.elements,t=this.position.elements,n=this.positionVariance.elements;return e[0]=t[0]+n[0]*(Math.random()-.5)*2,e[1]=t[1]+n[1]*(Math.random()-.5)*2,e[2]=t[2]+n[2]*(Math.random()-.5)*2,this._resultPosition},n._randomVelocityOnPoint=function(){var e=this._resultVelocity.elements,t=this.velocity.elements,n=this.velocityAddVariance.elements;return e[0]=t[0]+n[0]*Math.random(),e[1]=t[1]+n[1]*Math.random(),e[2]=t[2]+n[2]*Math.random(),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnPoint(),this._randomVelocityOnPoint())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,this.radius=30,this.velocity=0,this.velocityAddVariance=0,this.up=2,t.__super.call(this),this._resultPosition=new Qe,this._resultVelocity=new Qe,this._direction=new Qe,this.centerPosition=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.centerPosition.elements[i]=n.ringEmitterCenterPosition[i];this.radius=n.ringEmitterRadius,this.velocity=n.ringEmitterVelocity,this.velocityAddVariance=n.ringEmitterVelocityAddVariance,this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterRing",e);var n=t.prototype;return n._randomPointOnRing=function(){var e=Math.random()*Math.PI*2,t=Math.cos(e),n=Math.sin(e),i=this._resultPosition.elements,r=this.centerPosition.elements;switch(this.up){case 0:i[0]=r[0]+0,i[1]=r[1]+t*this.radius,i[2]=r[2]+n*this.radius;break;case 1:i[0]=r[0]+t*this.radius,i[1]=r[1]+0,i[2]=r[2]+n*this.radius;break;case 2:i[0]=r[0]+t*this.radius,i[1]=r[1]+n*this.radius,i[2]=r[2]+0}return this._resultPosition},n._randomVelocityOnRing=function(){var e=this._resultVelocity.elements;this._resultPosition.cloneTo(this._direction),Qe.normalize(this._direction,this._direction);var t=this._direction.elements;return e[0]=t[0]*(this.velocity+this.velocityAddVariance*Math.random()),e[1]=t[1]*(this.velocity+this.velocityAddVariance*Math.random()),e[2]=t[2]*(this.velocity+this.velocityAddVariance*Math.random()),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPointOnRing(),this._randomVelocityOnRing())},n.update=function(e){this.advanceTime(e/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,this.radius=1,this.velocity=0,this.velocityAddVariance=0,t.__super.call(this),this._reultPosition=new Qe,this._resultVelocity=new Qe,this._direction=new Qe,this.centerPosition=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.centerPosition.elements[i]=n.sphereEmitterCenterPosition[i];this.radius=n.sphereEmitterRadius,this.velocity=n.sphereEmitterVelocity,this.velocityAddVariance=n.sphereEmitterVelocityAddVariance,this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterSphere",e);var n=t.prototype;return n._randomPositionOnSphere=function(){var e=Math.random()*Math.PI*2,t=Math.random()*Math.PI*2,n=Math.cos(e)*this.radius,i=Math.sin(e)*this.radius,r=Math.cos(t)*n,a=Math.sin(t)*n,s=this._reultPosition.elements,o=this.centerPosition.elements;return s[0]=o[0]+r,s[1]=o[1]+i,s[2]=o[2]+a,this._reultPosition},n._randomVelocityOnSphere=function(){var e=this._resultVelocity.elements;this._reultPosition.cloneTo(this._direction),Qe.normalize(this._direction,this._direction);var t=this._direction.elements;return e[0]=t[0]*(this.velocity+this.velocityAddVariance*Math.random()),e[1]=t[1]*(this.velocity+this.velocityAddVariance*Math.random()),e[2]=t[2]*(this.velocity+this.velocityAddVariance*Math.random()),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnSphere(),this._randomVelocityOnSphere())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(){t.__super.call(this)}r(t,"laya.d3.core.glitter.SplineCurvePosition",e);var n=t.prototype;return n._CalcVelocity=function(e,t,n){Qe.subtract(e,t,n),Qe.scale(n,.5,n)},n.Init=function(t,n,i,r){this._CalcVelocity(n,t,this._tempVector30),this._CalcVelocity(r,i,this._tempVector31),e.prototype.Init.call(this,n,this._tempVector30,r,this._tempVector31)},t}(B),function(e){function t(){t.__super.call(this,t._name2int,t._int2name,t._int2nameMap)}return r(t,"laya.d3.shader.ShaderDefines3D",e),t.__init__=function(){t.reg("FSHIGHPRECISION",128),t.reg("DIFFUSEMAP",1),t.reg("NORMALMAP",2),t.reg("SPECULARMAP",4),t.reg("EMISSIVEMAP",8),t.reg("AMBIENTMAP",16),t.reg("REFLECTMAP",32),t.reg("PARTICLE3D",262144),t.reg("COLOR",2048),t.reg("UV",1024),t.reg("SKINNED",65536),t.reg("DIRECTIONLIGHT",4096),t.reg("POINTLIGHT",8192),t.reg("SPOTLIGHT",16384),t.reg("BONE",32768),t.reg("ALPHATEST",131072),t.reg("UVTRANSFORM",256),t.reg("FOG",512),t.reg("VR",64),t.reg("SPHERHBILLBOARD",524288),t.reg("STRETCHEDBILLBOARD",1048576),t.reg("HORIZONTALBILLBOARD",2097152),t.reg("VERTICALBILLBOARD",4194304),t.reg("COLOROVERLIFETIME",8388608),t.reg("RANDOMCOLOROVERLIFETIME",16777216),t.reg("SIZEOVERLIFETIME",33554432),t.reg("ROTATIONOVERLIFETIME",67108864),t.reg("TEXTURESHEETANIMATION",134217728),t.reg("VELOCITYOVERLIFETIME",268435456)},t.reg=function(e,n){V._reg(e,n,t._name2int,t._int2name)},t.toText=function(e,t,n){return V._toText(e,t,n)},t.toInt=function(e){return V._toInt(e,t._name2int)},t.FSHIGHPRECISION=128,t.VR=64,t.FOG=512,t.DIRECTIONLIGHT=4096,t.POINTLIGHT=8192,t.SPOTLIGHT=16384,t.DIFFUSEMAP=1,t.NORMALMAP=2,t.SPECULARMAP=4,t.EMISSIVEMAP=8,t.AMBIENTMAP=16,t.REFLECTMAP=32,t.UVTRANSFORM=256,t.UV=1024,t.COLOR=2048,t.BONE=32768,t.SKINNED=65536,t.ALPHATEST=131072,t.PARTICLE3D=262144,t.SPHERHBILLBOARD=524288,t.STRETCHEDBILLBOARD=1048576,t.HORIZONTALBILLBOARD=2097152,t.VERTICALBILLBOARD=4194304,t.COLOROVERLIFETIME=8388608,t.RANDOMCOLOROVERLIFETIME=16777216,t.SIZEOVERLIFETIME=33554432,t.ROTATIONOVERLIFETIME=67108864,t.TEXTURESHEETANIMATION=134217728,t.VELOCITYOVERLIFETIME=268435456,t._name2int={},t._int2name=[],t._int2nameMap=[],t}(V)),_t=function(e){function t(){this.x=NaN,this.y=NaN,this.z=NaN,this.randomDirection=!1,t.__super.call(this),this.x=1,this.y=1,this.z=1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.BoxShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){var n=e.elements,i=t.elements;$._randomPointInsideHalfUnitBox(e),n[0]=this.x*n[0],n[1]=this.y*n[1],n[2]=this.z*n[2],this.randomDirection?$._randomPointUnitSphere(t):(i[0]=0,i[1]=0,i[2]=-1)},t}(Q),dt=function(e){function t(){this.radius=NaN,this.arc=NaN,this.emitFromEdge=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.arc=2*Math.PI,this.emitFromEdge=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.CircleShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,n){var i=e.elements,r=t._tempPositionPoint.elements;this.emitFromEdge?$._randomPointUnitArcCircle(this.arc,t._tempPositionPoint):$._randomPointInsideUnitArcCircle(this.arc,t._tempPositionPoint),i[0]=r[0],i[1]=r[1],i[2]=0,Qe.scale(e,this.radius,e),this.randomDirection?$._randomPointUnitSphere(n):e.cloneTo(n)},i(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Ke}]),t}(Q),mt=function(e){function t(){this.angle=NaN,this.radius=NaN,this.length=NaN,this.emitType=0,this.randomDirection=!1,t.__super.call(this),this.angle=25/180*Math.PI,this.radius=1,this.length=5,this.emitType=0,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.ConeShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,n){var i,r=e.elements,a=n.elements,s=t._tempPositionPoint.elements,o=NaN,l=NaN,h=Math.cos(this.angle),u=Math.sin(this.angle);switch(this.emitType){case 0:$._randomPointInsideUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,this.randomDirection?($._randomPointInsideUnitCircle(t._tempDirectionPoint),i=t._tempDirectionPoint.elements,a[0]=i[0]*u,a[1]=i[1]*u):(a[0]=o*u,a[1]=l*u),a[2]=-h;break;case 1:$._randomPointUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,this.randomDirection?($._randomPointInsideUnitCircle(t._tempDirectionPoint),i=t._tempDirectionPoint.elements,a[0]=i[0]*u,a[1]=i[1]*u):(a[0]=o*u,a[1]=l*u),a[2]=-h;break;case 2:$._randomPointInsideUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,a[0]=o*u,a[1]=l*u,a[2]=-h,Qe.normalize(n,n),Qe.scale(n,this.length*Math.random(),n),Qe.add(e,n,e),this.randomDirection&&$._randomPointUnitSphere(n);break;case 3:$._randomPointUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,a[0]=o*u,a[1]=l*u,a[2]=-h,Qe.normalize(n,n),Qe.scale(n,this.length*Math.random(),n),Qe.add(e,n,e),this.randomDirection&&$._randomPointUnitSphere(n);break;default:throw new Error("ConeShape:emitType is invalid.")}},i(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Ke},"_tempDirectionPoint",function(){return this._tempDirectionPoint=new Ke}]),t}(Q),ft=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.HemisphereShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){var n=e.elements;this.emitFromShell?$._randomPointUnitSphere(e):$._randomPointInsideUnitSphere(e),Qe.scale(e,this.radius,e);var i=n[2];i>0&&(n[2]=-1*i),this.randomDirection?$._randomPointUnitSphere(t):e.cloneTo(t)},t}(Q),pt=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.SphereShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){this.emitFromShell?$._randomPointUnitSphere(e):$._randomPointInsideUnitSphere(e),Qe.scale(e,this.radius,e),this.randomDirection?$._randomPointUnitSphere(t):e.cloneTo(t)},t}(Q),vt=function(e){function t(e){this._id=0,this._enable=!1,this._layerMask=0,this._componentsMap=[],this.transform=null,this.isStatic=!1,t.__super.call(this),this._components=[],e?this.name=e:this.name="Sprite3D-"+t._nameNumberCounter++,this._enable=!0,this._id=++t._uniqueIDCounter,this.layer=U.currentCreationLayer,this.transform=new ht(this),this.on("display",this,this._onDisplay),this.on("undisplay",this,this._onUnDisplay)}r(t,"laya.d3.core.Sprite3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IUpdate":!0,"laya.resource.ICreateResource":!0,"laya.d3.core.IClone":!0}),i._onDisplay=function(){this.transform.parent=this._parent.transform,this._addSelfRenderObjects()},i._onUnDisplay=function(){this.transform.parent=null,this._clearSelfRenderObjects()},i._clearSelfRenderObjects=function(){},i._addSelfRenderObjects=function(){},i._updateComponents=function(e){for(var t=0,n=this._components.length;n>t;t++){var i=this._components[t];!i.started&&(i._start(e),i.started=!0),i.isActive&&i._update(e)}},i._lateUpdateComponents=function(e){for(var t=0;tn;++n)this._childs[n]._update(e)},i._getSortID=function(e,t){return e._getVertexBuffer().vertexDeclaration.id+1e3*t.id},i._update=function(e){e.owner=this,this._enable&&(this._updateComponents(e),this._lateUpdateComponents(e)),L.spriteCount++,this._childs.length&&this._updateChilds(e)},i.loadHierarchy=function(e){this.addChild(laya.d3.core.Sprite3D.load(e))},i.addChildAt=function(t,n){if(!(t instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return e.prototype.addChildAt.call(this,t,n)},i.addChild=function(t){if(!(t instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return e.prototype.addChild.call(this,t)},i.addComponent=function(e){if(-1!==this._componentsMap.indexOf(e))throw new Error("无法创建"+e+"组件,"+e+"组件已存在!");var t=_.getInstance(e);return t._initialize(this),this._componentsMap.push(e),this._components.push(t),this.event("componentadded",t),t},i.getComponentByType=function(e){var t=this._componentsMap.indexOf(e);return-1===t?null:this._components[t]},i.getComponentByIndex=function(e){return this._components[e]},i.removeComponent=function(e){var t=this._componentsMap.indexOf(e);if(-1!==t){var n=this._components[t];this._components.splice(t,1),this._componentsMap.splice(t,1),n._uninitialize(),this.event("componentremoved",n)}},i.removeAllComponent=function(){for(var e in this._componentsMap)this.removeComponent(e)},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1];_.createByJson(n,this,this,p.create(null,rt._parseHierarchyProp,[i],!1),p.create(null,rt._parseHierarchyNode,null,!1)),this.event("hierarchyloaded",[this])},i.cloneTo=function(e){var t=e;t.name=this.name,t.destroyed=this.destroyed,t.timer=this.timer,t._displayedInStage=this._displayedInStage,t._$P=this._$P,t._enable=this._enable,t._layerMask=this._layerMask;var n=t.transform.localMatrix;this.transform.localMatrix.cloneTo(n),t.transform.localMatrix=n,t.isStatic=this.isStatic;var i=0,r=0;for(i=0,r=this._componentsMap.length;r>i;i++)t.addComponent(this._componentsMap[i]);for(i=0,r=this._childs.length;r>i;i++)t.addChild(this._childs[i].clone())},i.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},i.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t);for(var n=0,i=this._components.length;i>n;n++)this._components[n]._uninitialize();this._components=null,this._componentsMap=null,this.transform=null},a(0,i,"componentsCount",function(){return this._components.length}),a(0,i,"id",function(){return this._id}),a(0,i,"layer",function(){return U.getLayerByMask(this._layerMask)},function(e){this._layerMask=e.mask,this.event("layerchanged",e)}),a(0,i,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enabledchanged",this._enable))}),a(0,i,"active",function(){return U.isActive(this._layerMask)&&this._enable}),a(0,i,"visible",function(){return U.isVisible(this._layerMask)&&this._enable}),a(0,i,"scene",function(){return this.parent?this.parent.scene:null}),t.instantiate=function(e,t,n,i,r){void 0===r&&(r=!0);var a,s=e.clone();if(t||n)i&&i.addChild(s),a=s.transform,t&&(a.position=t),n&&(a.rotation=n);else if(r){if(a=s.transform,i){var o=a.position,l=a.rotation;i.addChild(s),a.position=o,a.rotation=l}}else i&&i.addChild(s);return s},t.load=function(e){return n.loader.create(e,null,null,t,1,!1)},t._uniqueIDCounter=0,t._nameNumberCounter=0,t}(M),gt=function(e){function t(){this._renderQueue=0,this._renderMode=0,this._sharderNameID=0,this._shaderDefineValue=0,this._disableShaderDefineValue=0,this._shaderValues=null,this._textureSharderIndices=null,this._colorSharderIndices=null,this._numberSharderIndices=null,this._matrix4x4SharderIndices=null,this._textures=null,this._colors=null,this._numbers=null,this._matrix4x4s=null,this._isInstance=!1,this.shader=null,t.__super.call(this),this._loaded=!0,this._isInstance=!1,this._shaderDefineValue=0,this._disableShaderDefineValue=0,this._shaderValues=new b,this._textures=[],this._colors=[],this._numbers=[],this._matrix4x4s=[],this._textureSharderIndices=[],this._colorSharderIndices=[],this._numberSharderIndices=[],this._matrix4x4SharderIndices=[],this.renderMode=1}r(t,"laya.d3.core.material.BaseMaterial",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.IClone":!0}),i._uploadTextures=function(){for(var e=0,t=this._textures.length;t>e;e++){var n=this._textures[e];if(n){var i=n.source;i?this._uploadTexture(e,i):this._uploadTexture(e,Ht.grayTexture.source)}}},i._getShader=function(e,t){var n=e._value|t|this._shaderDefineValue;this._disableShaderDefineValue&&(n&=~this._disableShaderDefineValue),e._value=n;var i=n+2e-4*this._sharderNameID;this.shader=C.withCompile(this._sharderNameID,e.toNameDic(),i,null)},i._uploadTexture=function(e,t){this._shaderValues.data[this._textureSharderIndices[e]]=t},i._addShaderDefine=function(e){this._shaderDefineValue|=e},i._removeShaderDefine=function(e){this._shaderDefineValue&=~e},i._addDisableShaderDefine=function(e){this._disableShaderDefineValue|=e},i._removeDisableShaderDefine=function(e){this._disableShaderDefineValue&=~e},i._setMatrix4x4=function(e,t,n){var i=this._shaderValues,r=this._matrix4x4SharderIndices[e];!r&&n&&(this._matrix4x4SharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n.elements,this._matrix4x4s[e]=n},i._getMatrix4x4=function(e){return this._matrix4x4s[e]},i._setNumber=function(e,t,n){var i=this._shaderValues,r=this._numberSharderIndices[e];!r&&n&&(this._numberSharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n,this._numbers[e]=n},i._getNumber=function(e){return this._numbers[e]},i._setColor=function(e,t,n){var i=this._shaderValues,r=this._colorSharderIndices[e];!r&&n&&(this._colorSharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n.elements,this._colors[e]=n},i._getColor=function(e){return this._colors[e]},i._setTexture=function(e,t,n){var i=this._shaderValues,r=this._textureSharderIndices[t];!r&&e&&(this._textureSharderIndices[t]=r=i.length+1,i.pushValue(n,null)),this._textures[t]=e},i._getTexture=function(e){return this._textures[e]},i._upload=function(e,t,n){this._uploadTextures(),this._getShader(e.shaderDefines,t.shaderDefineValue);var i=e.shaderValue;i.pushArray(this._shaderValues),this.shader.uploadArray(i.data,i.length,n)},i._setLoopShaderParams=function(e,t,n,i,r){throw new Error("Marterial:must override it.")},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1],r=p.create(null,rt._parseMaterial,[i],!1);_.createByJson(n,this,null,r,null),r.recover(),this.event("loaded",this)},i.setShaderName=function(e){this._sharderNameID=C.nameKey.get(e)},i.cloneTo=function(e){var t=e;t.name=this.name,t._loaded=this._loaded,t._renderQueue=this._renderQueue,t._renderMode=this._renderMode,t.shader=this.shader,t._sharderNameID=this._sharderNameID,t._disableShaderDefineValue=this._disableShaderDefineValue,t._shaderDefineValue=this._shaderDefineValue;var n=0,i=0,r=0,a=t._shaderValues;t._shaderValues.length=this._shaderValues.length,t._colorSharderIndices=this._colorSharderIndices.slice();var s=this._colors.length,o=t._colors;for(o.length=s,n=0,i=s;i>n;n++){var l=o[n];this._colors[n].cloneTo(l),r=this._colorSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=l.elements}t._numberSharderIndices=this._numberSharderIndices.slice();var h=this._numbers.length,u=t._numbers;for(u.length=h,n=0,i=h;i>n;n++){var c=this._numbers[n];u[n]=c,r=this._numberSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=c}t._matrix4x4SharderIndices=this._matrix4x4SharderIndices.slice();var _=this._matrix4x4s.length,d=t._matrix4x4s;for(d.length=_,n=0,i=_;i>n;n++){var m=d[n];this._matrix4x4s[n].cloneTo(m),r=this._matrix4x4SharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=m.elements}t._textureSharderIndices=this._textureSharderIndices.slice();var f=this._textures.length,p=t._textures;for(p.length=f,n=0,i=f;i>n;n++)p[n]=this._textures[n],r=this._textureSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r]},i.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},i.dispose=function(){this.resourceManager.removeResource(this),e.prototype.dispose.call(this)},a(0,i,"renderQueue",function(){return this._renderQueue}),a(0,i,"renderMode",function(){return this._renderMode},function(e){switch(this._renderMode=e,e){case 1:this._renderQueue=1,this.event("renderqueuechanged",this);break;case 2:this._renderQueue=2,this.event("renderqueuechanged",this);break;case 3:this._renderQueue=1,this.event("renderqueuechanged",this);break;case 4:this._renderQueue=2,this.event("renderqueuechanged",this);break;case 13:this._renderQueue=3,this.event("renderqueuechanged",this);break;case 14:this._renderQueue=4,this.event("renderqueuechanged",this);break;case 15:this._renderQueue=5,this.event("renderqueuechanged",this);break;case 16:this._renderQueue=6,this.event("renderqueuechanged",this);break;case 5:this._renderQueue=7,this.event("renderqueuechanged",this);break;case 6:this._renderQueue=8,this.event("renderqueuechanged",this);break;case 7:this._renderQueue=9,this.event("renderqueuechanged",this);break;case 8:this._renderQueue=10,this.event("renderqueuechanged",this);break;case 9:this._renderQueue=11,this.event("renderqueuechanged",this);break;case 10:this._renderQueue=12,this.event("renderqueuechanged",this);break;case 11:this._renderQueue=13,this.event("renderqueuechanged",this);break;case 12:this._renderQueue=14,this.event("renderqueuechanged",this);break;default:throw new Error("Material:renderMode value error.")}3===this._renderMode||4===this._renderMode?this._addShaderDefine(131072):this._removeShaderDefine(131072)}),t.RENDERMODE_OPAQUE=1,t.RENDERMODE_OPAQUEDOUBLEFACE=2,t.RENDERMODE_CUTOUT=3,t.RENDERMODE_CUTOUTDOUBLEFACE=4,t.RENDERMODE_TRANSPARENT=13,t.RENDERMODE_TRANSPARENTDOUBLEFACE=14,t.RENDERMODE_ADDTIVE=15,t.RENDERMODE_ADDTIVEDOUBLEFACE=16,t.RENDERMODE_DEPTHREAD_TRANSPARENT=5,t.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6,t.RENDERMODE_DEPTHREAD_ADDTIVE=7,t.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8,t.RENDERMODE_NONDEPTH_TRANSPARENT=9,t.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10,t.RENDERMODE_NONDEPTH_ADDTIVE=11,t.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12,t}(A),Tt=function(e){function t(){this._width=0,this._height=0,this._size=null,this._repeat=!1,this._mipmap=!1,this._minFifter=0,this._magFifter=0,this._source=null,t.__super.call(this),this._repeat=!0,this._mipmap=!0,this._minFifter=-1,this._magFifter=-1}r(t,"laya.d3.resource.BaseTexture",e);var n=t.prototype;return n.dispose=function(){this.resourceManager.removeResource(this),e.prototype.dispose.call(this)},a(0,n,"width",function(){return this._width}),a(0,n,"repeat",function(){return this._repeat}),a(0,n,"height",function(){return this._height}),a(0,n,"magFifter",function(){return this._magFifter}),a(0,n,"size",function(){return this._size}),a(0,n,"mipmap",function(){return this._mipmap}),a(0,n,"minFifter",function(){return this._minFifter}),a(0,n,"source",function(){return this.activeResource(),this._source}),t}(A),xt=function(e){function t(){this._subMeshCount=0,this._boundingBox=null,this._boundingSphere=null,t.__super.call(this),this._loaded=!1}r(t,"laya.d3.resource.models.BaseMesh",e);var n=t.prototype;return n.getRenderElementsCount=function(){throw new Error("未Override,请重载该属性!")},n.getRenderElement=function(e){throw new Error("未Override,请重载该属性!")},a(0,n,"positions",function(){throw new Error("未Override,请重载该属性!")}),a(0,n,"subMeshCount",function(){return this._subMeshCount}),a(0,n,"boundingBox",function(){return this._boundingBox}),a(0,n,"boundingSphere",function(){return this._boundingSphere}),t}(A),Mt=function(e){function t(){t.__super.call(this)}r(t,"laya.d3.resource.models.Sky",e);var n=t.prototype;return n._render=function(e){},t.MVPMATRIX="MVPMATRIX",t.INTENSITY="INTENSITY",t.ALPHABLENDING="ALPHABLENDING",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t}(A),Et=function(e){function t(){this._player=null,this._templet=null,t.__super.call(this),this._player=new s}r(t,"laya.d3.component.animation.KeyframeAnimations",e);var i=t.prototype;return i._updateAnimtionPlayer=function(){this._player.update(n.timer.delta)},i._addUpdatePlayerToTimer=function(){n.timer.frameLoop(1,this,this._updateAnimtionPlayer)},i._removeUpdatePlayerToTimer=function(){n.timer.clear(this,this._updateAnimtionPlayer)},i._onOwnerEnableChanged=function(e){this._owner.displayedInStage&&(e?this._addUpdatePlayerToTimer():this._removeUpdatePlayerToTimer())},i._onDisplayInStage=function(){this._owner.enable&&this._addUpdatePlayerToTimer()},i._onUnDisplayInStage=function(){this._owner.enable&&this._removeUpdatePlayerToTimer()},i._load=function(e){this._owner.displayedInStage&&this._owner.enable&&this._addUpdatePlayerToTimer(),this._owner.on("enabledchanged",this,this._onOwnerEnableChanged),this._owner.on("display",this,this._onDisplayInStage),this._owner.on("undisplay",this,this._onUnDisplayInStage)},i._unload=function(t){e.prototype._unload.call(this,t),this._owner.displayedInStage&&this._owner.enable&&this._removeUpdatePlayerToTimer(),this._owner.off("enabledchanged",this,this._onOwnerEnableChanged),this._owner.off("display",this,this._onDisplayInStage),this._owner.off("undisplay",this,this._onUnDisplayInStage),this._player._destroy(),this._player=null,this._templet=null},a(0,i,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");var t=n.loader.create(e,null,null,o);this._templet!==t&&(0!==this._player.state&&this._player.stop(!0),this._templet=t,this._player.templet=t,this.event("animationchanged",this))}),a(0,i,"player",function(){return this._player}),a(0,i,"templet",function(){return this._templet},function(e){this._templet!==e&&(0!==this._player.state&&this._player.stop(!0),this._templet=e,this._player.templet=e,this.event("animationchanged",this))}),a(0,i,"currentFrameIndex",function(){return this._player.currentKeyframeIndex}),a(0,i,"currentAnimationClipIndex",function(){return this._player.currentAnimationClipIndex}),a(0,i,"nodeCount",function(){return this._templet.getNodeCount(this._player.currentAnimationClipIndex)}),t}(at),yt=(function(e){function t(){this._attachSkeleton=null,this._data=null,this._extenData=null,this.attachBones=null,this.matrixs=null,t.__super.call(this),this.attachBones=[],this.matrixs=[]}r(t,"laya.d3.component.AttachPoint",e);var n=t.prototype;return n._load=function(t){e.prototype._load.call(this,t),this._attachSkeleton=t.getComponentByType(Ut)},n._update=function(e){if(this._attachSkeleton&&2===this._attachSkeleton.player.state&&this._attachSkeleton.curBonesDatas){var t=this._attachSkeleton.player;this.matrixs.length=this.attachBones.length;for(var n=0;n=i.y&&i.x>=i.z?i.x:i.y>=i.z?i.y:i.z,Qe.transformCoordinate(e.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*t}},n._calculateBoundingBox=function(){if(null===this._meshSprite3DOwner.meshFilter.sharedMesh||null===this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox)this._boundingBox.toDefault();else{var e=this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox,t=this._meshSprite3DOwner.transform.worldMatrix;Qe.transformCoordinate(e.min,t,this._boundingBox.min),Qe.transformCoordinate(e.max,t,this._boundingBox.max)}},n._destroy=function(){e.prototype._destroy.call(this),this._meshSprite3DOwner=null},t}(st),Rt=function(e){function t(e){t.__super.call(this,e)}r(t,"laya.d3.core.ParticleRender",e);var n=t.prototype;return n._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;var t=this._boundingBox.min.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0, +this._boundingSphere.radius=Number.MAX_VALUE},t}(st),At=function(e){function t(e){this.renderMode=0,this.stretchedBillboardCameraSpeedScale=0,this.stretchedBillboardSpeedScale=0,this.stretchedBillboardLengthScale=1,t.__super.call(this,e),this.renderMode=0}r(t,"laya.d3.core.particleShuriKen.ShurikenParticleRender",e);var n=t.prototype;return n._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;var t=this._boundingBox.min.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},t}(st),It=function(e){function t(e,n){this._owner=null,this._vertexBuffer3D=null,this._indexBuffer3D=null,t.__super.call(this,n),this._owner=e,this.initialize(),this._vertexBuffer=this._vertexBuffer3D=Bt.create(ge.vertexDeclaration,4*n.maxPartices,35048),this._indexBuffer=this._indexBuffer3D=Nt.create("ushort",6*n.maxPartices,35044,!0),this.loadContent()}r(t,"laya.d3.resource.tempelet.ParticleTemplet3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IRenderable":!0}),i._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer3D:null},i._getIndexBuffer=function(){return this._indexBuffer3D},i.addParticle=function(e,t){this.addParticleArray(e.elements,t.elements)},i.loadContent=function(){for(var e=new Uint16Array(6*this.settings.maxPartices),t=0;t0&&this._vertexBuffer3D.setData(this._vertices,0,0,4*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},i._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer3D._bind(),this._indexBuffer._bind(),!0):!1},i._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement0&&(t=6*this._firstFreeElement,n.drawElements(4,t,5123,0),L.trianglesFaces+=t/3,L.drawCall++))},a(0,i,"indexOfHost",function(){return 0}),a(0,i,"_vertexBufferCount",function(){return 1}),a(0,i,"triangleCount",function(){return this._indexBuffer3D.indexCount/3}),t}(y),Ct=function(e){function t(){this._invertYProjectionMatrix=null,this._invertYProjectionViewMatrix=null,this._invertYScaleMatrix=null,this._boundFrustum=null,this._enableLightCount=3,this._renderTargetTexture=null,this._customRenderQueneIndex=11,this._lastCurrentTime=NaN,this._staticBatchManager=null,this._dynamicBatchManager=null,this.enableFog=!1,this.fogStart=NaN,this.fogRange=NaN,this.fogColor=null,this.enableLight=!0,t.__super.call(this),this._renderState=new le,this._lights=new Array,this._renderConfigs=[],this._frustumCullingObjects=[],this._quenes=[],this._cameraPool=[],this._invertYProjectionMatrix=new je,this._invertYProjectionViewMatrix=new je,this._invertYScaleMatrix=new je,je.createScaling(new Qe(1,-1,1),this._invertYScaleMatrix),this._staticBatchManager=new me,this._dynamicBatchManager=new ue,this._boundFrustum=new He(je.DEFAULT),this.enableFog=!1,this.fogStart=300,this.fogRange=1e3,this.fogColor=new Qe(.7,.7,.7);var e;e=this._renderConfigs[1]=new ae,e=this._renderConfigs[2]=new ae,e.cullFace=!1,e=this._renderConfigs[3]=new ae,e.blend=!0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[4]=new ae,e.cullFace=!1,e.blend=!0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[5]=new ae,e.blend=!0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[6]=new ae,e.cullFace=!1,e.blend=!0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[7]=new ae,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[9]=new ae,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[8]=new ae,e.cullFace=!1,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[10]=new ae,e.cullFace=!1,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[11]=new ae,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[13]=new ae,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[12]=new ae,e.cullFace=!1,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[14]=new ae,e.cullFace=!1,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=1,this.on("display",this,this._$3__onDisplay),this.on("undisplay",this,this._onUnDisplay)}r(t,"laya.d3.core.scene.BaseScene",e);var i=t.prototype;return n.imps(i,{"laya.webgl.submit.ISubmit":!0}),i._$3__onDisplay=function(){n.stage._scenes.push(this),n.stage._scenes.sort(t._sortScenes)},i._onUnDisplay=function(){var e=n.stage._scenes;e.splice(e.indexOf(this),1)},i._prepareUpdateToRenderState=function(e,t){t.context=w.mainContext,t.elapsedTime=this._lastCurrentTime?this.timer.currTimer-this._lastCurrentTime:0,this._lastCurrentTime=this.timer.currTimer,t.loopCount=L.loopCount,t.scene=this},i._prepareRenderToRenderState=function(e,t){var n=t.shaderDefines;w.frameShaderHighPrecision&&n.addInt(128),U._currentCameraCullingMask=e.cullingMask,t.camera=e;var i=t.shaderValue;if(e&&i.pushValue("CAMERAPOS",e.transform.position.elements),this._lights.length>0)for(var r=0,a=0;athis._enableLightCount)break;s.updateToWorldState(t)}}this.enableFog&&(n.addInt(512),i.pushValue("FOGSTART",this.fogStart),i.pushValue("FOGRANGE",this.fogRange),i.pushValue("FOGCOLOR",this.fogColor.elements))},i._endRenderToRenderState=function(e){e.reset()},i._updateScene=function(){var e=this._renderState;this._prepareUpdateToRenderState(w.mainContext,e),this.beforeUpate(e),this._updateChilds(e),this.lateUpate(e)},i._updateChilds=function(e){for(var t=0,n=this._childs.length;n>t;++t)this._childs[t]._update(e)},i._preRenderScene=function(e,t){this._boundFrustum.matrix=t.projectionViewMatrix,ce.RenderObjectCulling(this._boundFrustum,this);for(var n=0,i=this._quenes.length;i>n;n++)this._quenes[n]&&this._quenes[n]._preRender(t)},i._clear=function(e,t){var n=t.viewport,i=t.camera,r=i.renderTargetSize.height;e.viewport(n.x,r-n.y-n.height,n.width,n.height);var a=0;switch(i.clearFlag){case 0:if(i.clearColor){e.enable(3089),e.scissor(n.x,r-n.y-n.height,n.width,n.height);var s=i.clearColor.elements;if(e.clearColor(s[0],s[1],s[2],s[3]),a=16384,i.renderTarget)switch(i.renderTarget.depthStencilFormat){case 33189:a|=256;break;case 36168:a|=1024;break;case 34041:a|=256,a|=1024}else a|=256;e.clear(a),e.disable(3089)}else e.clear(256);break;case 1:case 2:if(i.renderTarget)switch(i.renderTarget.depthStencilFormat){case 33189:a|=256;break;case 36168:a|=1024;break;case 34041:a|=256,a|=1024}else a|=256;break;case 3:break;default:throw new Error("BaseScene:camera clearFlag invalid.")}},i._renderScene=function(e,t){var n,i=t.camera,r=0,a=0;for(r=0;3>r;r++)n=this._quenes[r],n&&(n._setState(e,t),n._render(t));if(1===i.clearFlag){var s=i.sky;s&&(N.setCullFace(e,!1),N.setDepthFunc(e,515),N.setDepthMask(e,0),s._render(t),N.setDepthFunc(e,513),N.setDepthMask(e,1))}for(r=3,a=this._quenes.length;a>r;r++)n=this._quenes[r],n&&(n._sortAlpha(t.camera.transform.position),n._setState(e,t),n._render(t))},i._set3DRenderConfig=function(e){e.disable(3042),N._blend=!1,e.blendFunc(770,771),N._sFactor=770,N._dFactor=771,e.disable(2929),N._depthTest=!1,e.enable(2884),N._cullFace=!0,e.depthMask(1),N._depthMask=1,e.frontFace(2304),N._frontFace=2304},i._set2DRenderConfig=function(e){N.setBlend(e,!0),N.setBlendFunc(e,770,771),N.setDepthTest(e,!1),N.setCullFace(e,!1),N.setDepthMask(e,1),N.setFrontFaceCCW(e,2305),e.viewport(0,0,R.width,R.height)},i._addLight=function(e){this._lights.indexOf(e)<0&&this._lights.push(e)},i._removeLight=function(e){var t=this._lights.indexOf(e);t>=0&&this._lights.splice(t,1)},i.addChildAt=function(e,t){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return laya.display.Node.prototype.addChildAt.call(this,e,t)},i.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return laya.display.Node.prototype.addChild.call(this,e)},i.addFrustumCullingObject=function(e){this._frustumCullingObjects.push(e)},i.removeFrustumCullingObject=function(e){var t=this._frustumCullingObjects.indexOf(e);-1!==t&&this._frustumCullingObjects.splice(t,1)},i.getRenderQueue=function(e){return this._quenes[e]||(this._quenes[e]=new oe(this._renderConfigs[e],this))},i.addRenderQuene=function(e){this._quenes[this._customRenderQueneIndex++]=new oe(e,this)},i.beforeUpate=function(e){},i.lateUpate=function(e){},i.beforeRender=function(e){},i.lateRender=function(e){},i.render=function(t,n,i){S._context.ctx._shader2D.glTexture=null,this._childs.length>0&&t.addRenderObject(this),this._renderType&=-2049,e.prototype.render.call(this,t,n,i)},i.renderSubmit=function(){return 1},i.getRenderType=function(){return 0},i.releaseRender=function(){},a(0,i,"scene",function(){return this}),t._sortScenes=function(e,i){if(e.parent===n.stage&&i.parent===n.stage){var r=n.stage._childs;return r.indexOf(e)-r.indexOf(i)}return e.parent!==n.stage&&i.parent!==n.stage?t._sortScenes(e.parent,i.parent):e.parent===n.stage?-1:1},t.FOGCOLOR="FOGCOLOR",t.FOGSTART="FOGSTART",t.FOGRANGE="FOGRANGE",t.CAMERAPOS="CAMERAPOS",t.LIGHTDIRECTION="LIGHTDIRECTION",t.LIGHTDIRDIFFUSE="LIGHTDIRDIFFUSE",t.LIGHTDIRAMBIENT="LIGHTDIRAMBIENT",t.LIGHTDIRSPECULAR="LIGHTDIRSPECULAR",t.POINTLIGHTPOS="POINTLIGHTPOS",t.POINTLIGHTRANGE="POINTLIGHTRANGE",t.POINTLIGHTATTENUATION="POINTLIGHTATTENUATION",t.POINTLIGHTDIFFUSE="POINTLIGHTDIFFUSE",t.POINTLIGHTAMBIENT="POINTLIGHTAMBIENT",t.POINTLIGHTSPECULAR="POINTLIGHTSPECULAR",t.SPOTLIGHTPOS="SPOTLIGHTPOS",t.SPOTLIGHTDIRECTION="SPOTLIGHTDIRECTION",t.SPOTLIGHTSPOT="SPOTLIGHTSPOT",t.SPOTLIGHTRANGE="SPOTLIGHTRANGE",t.SPOTLIGHTATTENUATION="SPOTLIGHTATTENUATION",t.SPOTLIGHTDIFFUSE="SPOTLIGHTDIFFUSE",t.SPOTLIGHTAMBIENT="SPOTLIGHTAMBIENT",t.SPOTLIGHTSPECULAR="SPOTLIGHTSPECULAR",t}(D),Vt=function(e){function t(e,i){this._projectionMatrixModifyID=0,t.__super.call(this),void 0===e&&(e=.1),void 0===i&&(i=1e3),this._tempVector3=new Qe,this._position=new Qe,this._up=new Qe,this._forward=new Qe,this._right=new Qe,this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._viewportExpressedInClipSpace=!0,this._renderTargetSize=it.fullScreen,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=i,this.cullingMask=2147483647,this.clearColor=new $e(.26,.26,.26,1),this.clearFlag=0,this._calculateProjectionMatrix(),n.stage.on("resize",this,this._onScreenSizeChanged)}r(t,"laya.d3.core.BaseCamera",e);var i=t.prototype;return i._sortCamerasByRenderingOrder=function(){if(this._displayedInStage)for(var e=this.scene._cameraPool,t=e.length-1,n=0;t>n;n++)if(e[n].renderingOrder>e[t].renderingOrder){var i=e[n];e[n]=e[t],e[t]=i}},i._calculateProjectionMatrix=function(){},i._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},i.addLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask|e.mask)},i.removeLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask&~e.mask)},i.addAllLayers=function(){this.cullingMask=2147483647},i.removeAllLayers=function(){this.cullingMask=0|U.getLayerByNumber(29).mask|U.getLayerByNumber(30).mask},i.ResetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},i.destroy=function(t){void 0===t&&(t=!0),this.sky=null,this.renderTarget=null,n.stage.off("resize",this,this._onScreenSizeChanged),e.prototype.destroy.call(this,t)},i.moveForward=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[1]=0,this._tempVector3.elements[2]=e,this.transform.translate(this._tempVector3)},i.moveRight=function(e){this._tempVector3.elements[1]=this._tempVector3.elements[2]=0,this._tempVector3.elements[0]=e,this.transform.translate(this._tempVector3)},i.moveVertical=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[2]=0,this._tempVector3.elements[1]=e,this.transform.translate(this._tempVector3,!1)},i._addSelfRenderObjects=function(){var e=this.scene._cameraPool,t=e.length;if(t>0){for(var n=t-1;n>=0;n--)if(this.renderingOrder<=e[n].renderingOrder){e.splice(n+1,0,this);break}}else e.push(this)},i._clearSelfRenderObjects=function(){var e=this.scene._cameraPool;e.splice(e.indexOf(this),1)},a(0,i,"forward",function(){var e=this.transform.worldMatrix.elements,t=this._forward.elements;return t[0]=-e[8],t[1]=-e[9],t[2]=-e[10],this._forward}),a(0,i,"position",function(){var e=this.transform.worldMatrix.elements,t=this._position.elements;return t[0]=e[12],t[1]=e[13],t[2]=e[14],this._position}),a(0,i,"farPlane",function(){return this._farPlane},function(e){this._farPlane=e,this._calculateProjectionMatrix()}),a(0,i,"renderTarget",function(){return this._renderTarget},function(e){this._renderTarget=e,null!=e&&(this._renderTargetSize=e.size)}),a(0,i,"up",function(){var e=this.transform.worldMatrix.elements,t=this._up.elements;return t[0]=e[4],t[1]=e[5],t[2]=e[6],this._up}),a(0,i,"right",function(){var e=this.transform.worldMatrix.elements,t=this._right.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],this._right}),a(0,i,"renderTargetSize",function(){return this._renderTargetSize},function(e){null!=this.renderTarget&&this._renderTargetSize!=e,this._renderTargetSize=e,this._calculateProjectionMatrix()}),a(0,i,"fieldOfView",function(){return this._fieldOfView},function(e){this._fieldOfView=e,this._calculateProjectionMatrix()}),a(0,i,"nearPlane",function(){return this._nearPlane},function(e){this._nearPlane=e,this._calculateProjectionMatrix()}),a(0,i,"orthographicProjection",function(){return this._orthographic},function(e){this._orthographic=e,this._calculateProjectionMatrix()}),a(0,i,"orthographicVerticalSize",function(){return this._orthographicVerticalSize},function(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}),a(0,i,"renderingOrder",function(){return this._renderingOrder},function(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}),t.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",t.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",t.CLEARFLAG_SOLIDCOLOR=0,t.CLEARFLAG_SKY=1,t.CLEARFLAG_DEPTHONLY=2,t.CLEARFLAG_NONE=3,t}(vt),Dt=(function(e){function t(){this._templet=null,this._glitterRender=null,t.__super.call(this),this._glitterRender=new yt(this),this._glitterRender.on("materialchanged",this,this._onMaterialChanged);var e=new bt;this._glitterRender.sharedMaterial=e,this._templet=new ut(this),e.renderMode=8,this._changeRenderObject(0)}r(t,"laya.d3.core.glitter.Glitter",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._glitterRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._glitterRender.renderObject;var i=this._glitterRender.sharedMaterials[e];i||(i=bt.defaultMaterial);var r=this._templet;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._glitterRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._glitterRender.renderObject)},n._update=function(e){this._templet._update(e.elapsedTime),e.owner=this,L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.addGlitterByPositions=function(e,t){this._templet.addVertexPosition(e,t)},n.addGlitterByPositionsVelocitys=function(e,t,n,i){this._templet.addVertexPositionVelocity(e,t,n,i)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t,i=n.templet;i.lifeTime=this._templet.lifeTime,i.minSegmentDistance=this._templet.minSegmentDistance,i.minInterpDistance=this._templet.minInterpDistance,i.maxSlerpCount=this._templet.maxSlerpCount,this._templet.color.cloneTo(i.color),i._maxSegments=this._templet._maxSegments;var r=n._glitterRender;r.sharedMaterials=this._glitterRender.sharedMaterials,r.enable=this._glitterRender.enable},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._glitterRender._destroy(),this._templet=null},a(0,n,"templet",function(){return this._templet}),a(0,n,"glitterRender",function(){return this._glitterRender}),t}(vt),function(e){function t(){this._diffuseColor=null,this._ambientColor=null,this._specularColor=null,this._reflectColor=null,t.__super.call(this),this.on("added",this,this._onAdded),this.on("removed",this,this._onRemoved),this._diffuseColor=new Qe(.8,.8,.8),this._ambientColor=new Qe(.6,.6,.6),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1)}r(t,"laya.d3.core.light.LightSprite",e);var n=t.prototype;return n._onRemoved=function(){this.scene._removeLight(this)},n._onAdded=function(){this.scene._addLight(this)},n.updateToWorldState=function(e){},a(0,n,"diffuseColor",function(){return this._diffuseColor},function(e){this._diffuseColor=e}),a(0,n,"ambientColor",function(){return this._ambientColor},function(e){this._ambientColor=e}),a(0,n,"lightType",function(){return-1}),a(0,n,"specularColor",function(){return this._specularColor},function(e){this._specularColor=e}),a(0,n,"reflectColor",function(){return this._reflectColor},function(e){this._reflectColor=e}),t.TYPE_DIRECTIONLIGHT=1,t.TYPE_POINTLIGHT=2,t.TYPE_SPOTLIGHT=3,t}(vt)),Lt=function(e){function t(e,n){this._meshFilter=null,this._meshRender=null,t.__super.call(this,n),this._meshFilter=new ot(this),this._meshRender=new St(this),this._meshFilter.on("meshchanged",this,this._onMeshChanged),this._meshRender.on("materialchanged",this,this._onMaterialChanged),e&&(this._meshFilter.sharedMesh=e,e instanceof laya.d3.resource.models.Mesh&&(e.loaded?this._meshRender.sharedMaterials=e.materials:e.once("loaded",this,this._applyMeshMaterials)))}r(t,"laya.d3.core.MeshSprite3D",e);var n=t.prototype;return n._changeRenderObjectByMesh=function(e){var t=this._meshRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._meshRender.renderObject;var i=this._meshRender.sharedMaterials[e];i||(i=wt.defaultMaterial);var r=this._meshFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(r,i),n._sprite3D=this,n.renderObj=r,n._material=i,n},n._changeRenderObjectByMaterial=function(e,t){var n=this._meshRender.renderObject._renderElements[e],i=this._meshFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(i,t),n._sprite3D=this,n.renderObj=i,n._material=t,n},n._changeRenderObjectsByMesh=function(){var e=this._meshFilter.sharedMesh.getRenderElementsCount();this._meshRender.renderObject._renderElements.length=e;for(var t=0;e>t;t++)this._changeRenderObjectByMesh(t)},n._onMeshChanged=function(e){var t=e.sharedMesh;t.loaded?this._changeRenderObjectsByMesh():t.once("loaded",this,this._onMeshLoaded)},n._onMeshLoaded=function(e){e===this.meshFilter.sharedMesh&&this._changeRenderObjectsByMesh()},n._onMaterialChanged=function(e,t,n){var i=this._meshRender.renderObject._renderElements.length;i>t&&this._changeRenderObjectByMaterial(t,n)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._meshRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._meshRender.renderObject)},n._applyMeshMaterials=function(e){for(var t=this._meshRender.sharedMaterials,n=e.materials,i=0,r=n.length;r>i;i++)t[i]||(t[i]=n[i]);this._meshRender.sharedMaterials=t},n._update=function(e){e.owner=this,this._enable&&(this._updateComponents(e),this._lateUpdateComponents(e)),L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._meshFilter.sharedMesh=this._meshFilter.sharedMesh;var i=n._meshRender;i.enable=this._meshRender.enable,i.sharedMaterials=this._meshRender.sharedMaterials,i.castShadow=this._meshRender.castShadow,i.receiveShadow=this._meshRender.receiveShadow},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._meshFilter._destroy(),this._meshRender._destroy()},a(0,n,"meshFilter",function(){return this._meshFilter}),a(0,n,"meshRender",function(){return this._meshRender}),t}(vt),Ot=(function(e){function t(e){this._setting=null,this._templet=null,this._particleRender=null,t.__super.call(this),this._setting=e,this._particleRender=new Rt(this),this._particleRender.on("materialchanged",this,this._onMaterialChanged);var n=new Pt;e.textureName&&(n.diffuseTexture=kt.load(e.textureName)),this._particleRender.sharedMaterial=n,this._templet=new It(this,e),0===e.blendState?n.renderMode=5:1===e.blendState&&(n.renderMode=7),this._changeRenderObject(0)}r(t,"laya.d3.core.particle.Particle3D",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._particleRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._particleRender.renderObject;var i=this._particleRender.sharedMaterials[e];i||(i=Pt.defaultMaterial);var r=this._templet;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._particleRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._particleRender.renderObject)},n._update=function(e){this._templet.update(e.elapsedTime),e.owner=this,L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.addParticle=function(e,t){Qe.add(this.transform.localPosition,e,e),this._templet.addParticle(e,t)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._templet=this._templet;var i=n._particleRender;i.sharedMaterials=this._particleRender.sharedMaterials,i.enable=this._particleRender.enable},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._particleRender._destroy(),this._templet=null},a(0,n,"templet",function(){return this._templet}),a(0,n,"particleRender",function(){return this._particleRender}),t}(vt),function(e){function t(e){this._particleSystem=null,this._particleRender=null,t.__super.call(this),this._particleRender=new At(this),this._particleRender.on("materialchanged",this,this._onMaterialChanged),this._particleSystem=new re(this),this._changeRenderObject(0),e&&(this._particleRender.sharedMaterial=e)}r(t,"laya.d3.core.particleShuriKen.ShuriKenParticle3D",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._particleRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._particleRender.renderObject;var i=this._particleRender.sharedMaterials[e];i||(i=Ft.defaultMaterial);var r=this._particleSystem;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._particleRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._particleRender.renderObject)},n._update=function(e){e.owner=this,this._particleSystem.update(e),L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t,i=n._particleSystem;i.duration=this._particleSystem.duration,i.looping=this._particleSystem.looping,i.prewarm=this._particleSystem.prewarm,i.startDelayType=this._particleSystem.startDelayType,i.startDelay=this._particleSystem.startDelay,i.startDelayMin=this._particleSystem.startDelayMin,i.startDelayMax=this._particleSystem.startDelayMax,i.startLifetimeType=this._particleSystem.startLifetimeType,i.startLifetimeConstant=this._particleSystem.startLifetimeConstant,this._particleSystem.startLifeTimeGradient.cloneTo(i.startLifeTimeGradient),i.startLifetimeConstantMin=this._particleSystem.startLifetimeConstantMin,i.startLifetimeConstantMax=this._particleSystem.startLifetimeConstantMax,this._particleSystem.startLifeTimeGradientMin.cloneTo(i.startLifeTimeGradientMin),this._particleSystem.startLifeTimeGradientMax.cloneTo(i.startLifeTimeGradientMax),i.startSpeedType=this._particleSystem.startSpeedType,i.startSpeedConstant=this._particleSystem.startSpeedConstant,i.startSpeedConstantMin=this._particleSystem.startSpeedConstantMin,i.startSpeedConstantMax=this._particleSystem.startSpeedConstantMax,i.threeDStartSize=this._particleSystem.threeDStartSize,i.startSizeType=this._particleSystem.startSizeType,i.startSizeConstant=this._particleSystem.startSizeConstant,this._particleSystem.startSizeConstantSeparate.cloneTo(i.startSizeConstantSeparate),i.startSizeConstantMin=this._particleSystem.startSizeConstantMin,i.startSizeConstantMax=this._particleSystem.startSizeConstantMax,this._particleSystem.startSizeConstantMinSeparate.cloneTo(i.startSizeConstantMinSeparate),this._particleSystem.startSizeConstantMaxSeparate.cloneTo(i.startSizeConstantMaxSeparate),i.threeDStartRotation=this._particleSystem.threeDStartRotation,i.startRotationType=this._particleSystem.startRotationType,i.startRotationConstant=this._particleSystem.startRotationConstant,this._particleSystem.startRotationConstantSeparate.cloneTo(i.startRotationConstantSeparate),i.startRotationConstantMin=this._particleSystem.startRotationConstantMin,i.startRotationConstantMax=this._particleSystem.startRotationConstantMax,this._particleSystem.startRotationConstantMinSeparate.cloneTo(i.startRotationConstantMinSeparate),this._particleSystem.startRotationConstantMaxSeparate.cloneTo(i.startRotationConstantMaxSeparate),i.randomizeRotationDirection=this._particleSystem.randomizeRotationDirection,i.startColorType=this._particleSystem.startColorType,this._particleSystem.startColorConstant.cloneTo(i.startColorConstant),this._particleSystem.startColorConstantMin.cloneTo(i.startColorConstantMin),this._particleSystem.startColorConstantMax.cloneTo(i.startColorConstantMax),this._particleSystem.gravity.cloneTo(i.gravity),i.gravityModifier=this._particleSystem.gravityModifier,i.simulationSpace=this._particleSystem.simulationSpace,i.scaleMode=this._particleSystem.scaleMode,i.playOnAwake=this._particleSystem.playOnAwake,this._particleSystem.velocityOverLifetime.cloneTo(i.velocityOverLifetime),this._particleSystem.colorOverLifetime.cloneTo(i.colorOverLifetime),this._particleSystem.sizeOverLifetime.cloneTo(i.sizeOverLifetime),this._particleSystem.rotationOverLifetime.cloneTo(i.rotationOverLifetime),this._particleSystem.textureSheetAnimation.cloneTo(i.textureSheetAnimation),i.isPerformanceMode=this._particleSystem.isPerformanceMode;var r=n._particleRender;r.sharedMaterials=this._particleRender.sharedMaterials,r.enable=this._particleRender.enable,r.renderMode=this._particleRender.renderMode,r.stretchedBillboardCameraSpeedScale=this._particleRender.stretchedBillboardCameraSpeedScale,r.stretchedBillboardSpeedScale=this._particleRender.stretchedBillboardSpeedScale,r.stretchedBillboardLengthScale=this._particleRender.stretchedBillboardLengthScale},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._particleRender._destroy(),this._particleSystem._destroy(),this._particleRender=null,this._particleSystem=null},a(0,n,"particleSystem",function(){return this._particleSystem}),a(0,n,"particleRender",function(){return this._particleRender}),t}(vt)),bt=function(e){function t(){t.__super.call(this),this.setShaderName("GLITTER")}r(t,"laya.d3.core.material.GlitterMaterial",e);var s=t.prototype;return s._setLoopShaderParams=function(e,t,n,i,r){var a=e.owner,s=a.templet;e.shaderValue.pushValue("UNICOLOR",s.color.elements),e.shaderValue.pushValue("MVPMATRIX",e.projectionViewMatrix.elements),e.shaderValue.pushValue("DURATION",s.lifeTime),e.shaderValue.pushValue("ALBEDO",s._albedo.elements),e.shaderValue.pushValue("CURRENTTIME",s._currentTime)},a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),t.load=function(e){return n.loader.create(e,null,null,t)},t.TIME="TIME",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t.MVPMATRIX="MVPMATRIX",t.ALBEDO="ALBEDO",t.CURRENTTIME="CURRENTTIME",t.UNICOLOR="UNICOLOR",t.DURATION="DURATION",t._diffuseTextureIndex=0,i(t,["defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),Pt=function(e){function t(){t.__super.call(this),this._addShaderDefine(262144),this.setShaderName("PARTICLE")}r(t,"laya.d3.core.material.ParticleMaterial",e);var s=t.prototype;return s._setLoopShaderParams=function(e,t,n,i,r){var a=e.owner,s=a.templet,o=s.settings;e.shaderValue.pushValue("DURATION",o.duration),e.shaderValue.pushValue("GRAVITY",o.gravity),e.shaderValue.pushValue("ENDVELOCITY",o.endVelocity),e.shaderValue.pushValue("MVPMATRIX",n.elements),e.shaderValue.pushValue("MATRIX1",e.viewMatrix.elements),e.shaderValue.pushValue("MATRIX2",e.projectionMatrix.elements);var l=e.viewport.width/e.viewport.height,h=new Ke(.5/l,-.5);e.shaderValue.pushValue("VIEWPORTSCALE",h.elements),e.shaderValue.pushValue("CURRENTTIME",s._currentTime)},a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),t.load=function(e){return n.loader.create(e,null,null,t)},t.WORLDMATRIX="MVPMATRIX",t.VIEWMATRIX="MATRIX1",t.PROJECTIONMATRIX="MATRIX2",t.VIEWPORTSCALE="VIEWPORTSCALE",t.CURRENTTIME="CURRENTTIME",t.DURATION="DURATION",t.GRAVITY="GRAVITY",t.ENDVELOCITY="ENDVELOCITY",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t._diffuseTextureIndex=0,i(t,["defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),wt=function(e){function t(){this._transformUV=null,t.__super.call(this),this._setColor(0,"MATERIALAMBIENT",new Qe(.6,.6,.6)),this._setColor(1,"MATERIALDIFFUSE",new Qe(1,1,1)),this._setColor(2,"MATERIALSPECULAR",new $e(1,1,1,8)),this._setColor(3,"MATERIALREFLECT",new Qe(1,1,1)),this._setColor(4,"ALBEDO",new $e(1,1,1,1)),this._setNumber(0,"ALPHATESTVALUE",.5),this.setShaderName("SIMPLE")}r(t,"laya.d3.core.material.StandardMaterial",e);var s=t.prototype;return s.disableLight=function(){this._addDisableShaderDefine(28672)},s.disableFog=function(){this._addDisableShaderDefine(512)},s._setLoopShaderParams=function(e,n,i,r,a){this._transformUV&&this._transformUV.matrix;var s;i===je.DEFAULT?s=n:(s=t._tempMatrix4x40,je.multiply(n,i,s)),e.shaderValue.pushValue("MATRIX1",i.elements),e.shaderValue.pushValue("MVPMATRIX",s.elements)},a(0,s,"ambientColor",function(){return this._getColor(0)},function(e){this._setColor(0,"MATERIALAMBIENT",e)}),a(0,s,"albedo",function(){return this._getColor(4)},function(e){this._setColor(4,"ALBEDO",e)}),a(0,s,"diffuseColor",function(){return this._getColor(1)},function(e){this._setColor(1,"MATERIALDIFFUSE",e)}),a(0,s,"specularColor",function(){return this._getColor(2)},function(e){this._setColor(2,"MATERIALSPECULAR",e)}),a(0,s,"normalTexture",function(){return this._getTexture(1)},function(e){ +e?this._addShaderDefine(2):this._removeShaderDefine(2),this._setTexture(e,1,"NORMALTEXTURE")}),a(0,s,"reflectColor",function(){return this._getColor(3)},function(e){this._setColor(3,"MATERIALREFLECT",e)}),a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),a(0,s,"alphaTestValue",function(){return this._getNumber(0)},function(e){this._setNumber(0,"ALPHATESTVALUE",e)}),a(0,s,"specularTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(4):this._removeShaderDefine(4),this._setTexture(e,2,"SPECULARTEXTURE")}),a(0,s,"emissiveTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(8):this._removeShaderDefine(8),this._setTexture(e,3,"EMISSIVETEXTURE")}),a(0,s,"ambientTexture",function(){return this._getTexture(4)},function(e){e?this._addShaderDefine(16):this._removeShaderDefine(16),this._setTexture(e,4,"AMBIENTTEXTURE")}),a(0,s,"reflectTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(32):this._removeShaderDefine(32),this._setTexture(e,5,"REFLECTTEXTURE")}),a(0,s,"transformUV",function(){return this._transformUV},function(e){this._transformUV=e,this._setMatrix4x4(0,"MATRIX2",e.matrix),e?this._addShaderDefine(256):this._removeShaderDefine(256)}),t.load=function(e){return n.loader.create(e,null,null,t)},t.WORLDMATRIX="MATRIX1",t.MVPMATRIX="MVPMATRIX",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t.NORMALTEXTURE="NORMALTEXTURE",t.SPECULARTEXTURE="SPECULARTEXTURE",t.EMISSIVETEXTURE="EMISSIVETEXTURE",t.AMBIENTTEXTURE="AMBIENTTEXTURE",t.REFLECTTEXTURE="REFLECTTEXTURE",t.Bones="MATRIXARRAY0",t.ALBEDO="ALBEDO",t.ALPHATESTVALUE="ALPHATESTVALUE",t.UVANIAGE="UVAGEX",t.MATERIALAMBIENT="MATERIALAMBIENT",t.MATERIALDIFFUSE="MATERIALDIFFUSE",t.MATERIALSPECULAR="MATERIALSPECULAR",t.MATERIALREFLECT="MATERIALREFLECT",t.UVMATRIX="MATRIX2",t.UVAGE="FLOAT0",t._ambientColorIndex=0,t._diffuseColorIndex=1,t._speclarColorIndex=2,t._reflectColorIndex=3,t._albedoColorIndex=4,t._alphaTestValueIndex=0,t._diffuseTextureIndex=0,t._normalTextureIndex=1,t._specularTextureIndex=2,t._emissiveTextureIndex=3,t._ambientTextureIndex=4,t._reflectTextureIndex=5,t.TRANSFORMUV=0,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),Nt=function(e){function t(e,n,i,r){this._indexType=null,this._indexTypeByteCount=0,this._indexCount=0,this._canRead=!1,void 0===i&&(i=35044),void 0===r&&(r=!1),t.__super.call(this),this._indexType=e,this._indexCount=n,this._bufferUsage=i,this._bufferType=34963,this._canRead=r,this._bind();var a=0;if("ushort"==e)this._indexTypeByteCount=2;else{if("ubyte"!=e)throw new Error("unidentification index type.");this._indexTypeByteCount=1}a=this._indexTypeByteCount*n,this._byteLength=a,u._gl.bufferData(this._bufferType,a,this._bufferUsage),r?("ushort"==e?this._buffer=new Uint16Array(n):"ubyte"==e&&(this._buffer=new Uint8Array(n)),this.memorySize=2*a):this.memorySize=a}r(t,"laya.d3.graphics.IndexBuffer3D",e);var n=t.prototype;return n.setData=function(e,t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=4294967295);var r=0;if("ushort"==this._indexType?(r=2,0===n&&4294967295===i||(e=new Uint16Array(e.buffer,n*r,i))):"ubyte"==this._indexType&&(r=1,0===n&&4294967295===i||(e=new Uint8Array(e.buffer,n*r,i))),this._bind(),u._gl.bufferSubData(this._bufferType,t*r,e),this._canRead)if(0!==t||0!==n||4294967295!==i){var a=this._buffer.length-t;i>a&&(i=a);for(var s=0;i>s;s++)this._buffer[t+s]=e[s]}else this._buffer=e},n.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},n.dispose=function(){this._buffer=null,e.prototype.dispose.call(this),this.memorySize=0},a(0,n,"indexType",function(){return this._indexType}),a(0,n,"indexTypeByteCount",function(){return this._indexTypeByteCount}),a(0,n,"indexCount",function(){return this._indexCount}),a(0,n,"canRead",function(){return this._canRead}),t.INDEXTYPE_UBYTE="ubyte",t.INDEXTYPE_USHORT="ushort",t.create=function(e,n,i,r){return void 0===i&&(i=35044),void 0===r&&(r=!1),new t(e,n,i,r)},t}(u),Bt=function(e){function t(e,n,i,r){this._vertexDeclaration=null,this._vertexCount=0,this._canRead=!1,void 0===r&&(r=!1),t.__super.call(this),this._vertexDeclaration=e,this._vertexCount=n,this._bufferUsage=i,this._bufferType=34962,this._canRead=r,this._bind();var a=this._vertexDeclaration.vertexStride*n;this.memorySize=a,this._byteLength=a,u._gl.bufferData(this._bufferType,a,this._bufferUsage),r&&(this._buffer=new Float32Array(a/4))}r(t,"laya.d3.graphics.VertexBuffer3D",e);var n=t.prototype;return n.bindWithIndexBuffer=function(e){e&&e._bind(),this._bind()},n.setData=function(e,t,n,i){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=4294967295),0===n&&4294967295===i||(e=new Float32Array(e.buffer,4*n,i)),this._bind(),u._gl.bufferSubData(this._bufferType,4*t,e),this._canRead)if(0!==t||0!==n||4294967295!==i){var r=this._buffer.length-t;i>r&&(i=r);for(var a=0;i>a;a++)this._buffer[t+a]=e[a]}else this._buffer=e},n.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},n.detoryResource=function(){for(var t=this._vertexDeclaration.getVertexElements(),n=0;ne;e++)this._tempVector30.elements[e]=this._currentAnimationData[e],this._tempVector31.elements[e]=this._currentAnimationData[e+3],this._tempVector32.elements[e]=this._currentAnimationData[e+6];this._currentTransform||(this._currentTransform=new je),je.createLookAt(this._tempVector30,this._tempVector31,this._tempVector32,this._currentTransform),this._currentTransform.invert(this._currentTransform),this.addMode&&je.multiply(this._originalAnimationTransform,this._currentTransform,this._currentTransform),this.localMode?this.owner.transform.localMatrix=this._currentTransform:this.owner.transform.worldMatrix=this._currentTransform,this._camera.fieldOfView=this._currentAnimationData[9]},i._load=function(e){var t=this;if(!(e instanceof laya.d3.core.Camera))throw new Error("该Sprite3D并非Camera");this._camera=e,this._player.on("stopped",this,function(){t._player.returnToZeroStopped&&(t.localMode?t._originalAnimationTransform&&(e.transform.localMatrix=t._originalAnimationTransform):t._originalAnimationTransform&&(e.transform.worldMatrix=t._originalAnimationTransform),t._camera.fieldOfView=t._originalFov)})},i._update=function(e){if(this._templet&&this._templet.loaded&&2===this._player.state){var t=this._player.playbackRate*n.timer.scale,i=this._player.isCache&&t>=1?this.currentFrameIndex:-1,r=this.currentAnimationClipIndex;if(-1!==i&&this._lastFrameIndex===i)return void laya.d3.component.Component3D.prototype._update.call(this,e);if(this._player.isCache&&t>=1){var a=this._templet.getAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,r,i);if(a)return this._currentAnimationData=a,this._lastFrameIndex=i,laya.d3.component.Component3D.prototype._update.call(this,e),void this._effect()}var s=this._templet.getNodes(r),o=s.length;this._player.isCache&&t>=1?this._currentAnimationData=new Float32Array(10*o):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(10*o)),this._currentAnimationData=this._tempCurAnimationData),this._player.isCache&&t>=1?this._templet.getOriginalData(r,this._currentAnimationData,this._player._fullFrames[r],i,this._player.currentPlayTime):this._templet.getOriginalDataUnfixedRate(r,this._currentAnimationData,this._player.currentPlayTime),this._player.isCache&&t>=1&&this._templet.setAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,r,i,this._currentAnimationData),this._lastFrameIndex=i,laya.d3.component.Component3D.prototype._update.call(this,e),this._effect()}},t}(Et),function(e){function t(){this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._lastFrameIndex=-1,this._curAnimationDatas=null,t.__super.call(this),this._animationSprites=[],this._animationSpritesInitLocalMatrix=[]}r(t,"laya.d3.component.animation.RigidAnimations",e);var i=t.prototype;return i._init=function(){for(var e=this._templet.getNodes(this.currentAnimationClipIndex),t=this._owner,n=e.length,i=0,r=new Uint16Array(this._templet.getPublicExtData()),a=0;n>a;a++){var s=r.slice(i+1,i+1+r[i]);i+=r[i]+1;for(var o=1;ot;t++){for(var i=this._animationSprites[t],r=i.transform.localMatrix,a=r.elements,s=0;16>s;s++)a[s]=this._curAnimationDatas[16*t+s];i.transform.localMatrix=r}},i._load=function(t){e.prototype._load.call(this,t),this._player.on("stopped",this,this._animtionStop),this._player.on("played",this,this._animtionPlay)},i._update=function(e){if(2===this._player.state&&this._templet&&this._templet.loaded){var t=this._player.playbackRate*n.timer.scale,i=this._player.cachePlayRate,r=this._player.isCache&&t>=i,a=r?this.currentFrameIndex:-1;if(-1===a||this._lastFrameIndex!==a){var s=this.currentAnimationClipIndex,o=this._templet.getNodes(s),l=this._templet._animationDatasCache;if(r){var h=this._templet.getAnimationDataWithCache(i,l,s,a);if(h)return this._curAnimationDatas=h,this._lastFrameIndex=a,void this._effectAnimation(o)}var u=16*o.length;r?this._curAnimationDatas=new Float32Array(u):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(u)),this._curAnimationDatas=this._tempCurAnimationData),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(s))),r?this._templet.getOriginalData(s,this._curOriginalData,this._player._fullFrames[s],a,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(s,this._curOriginalData,this._player.currentPlayTime),rt._computeRootAnimationData(o,this._curOriginalData,this._curAnimationDatas),r&&this._templet.setAnimationDataWithCache(i,l,s,a,this._curAnimationDatas),this._lastFrameIndex=a,this._effectAnimation(o)}}},i._unload=function(t){e.prototype._unload.call(this,t),this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._curAnimationDatas=null},a(0,i,"url",null,function(t){e.prototype._$set_url.call(this,t),this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[])}),a(0,i,"templet",e.prototype._$get_templet,function(t){e.prototype._$set_templet.call(this,t),this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[])}),t}(Et),function(e){function t(){this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._extenData=null,this._lastFrameIndex=-1,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null,t.__super.call(this)}r(t,"laya.d3.component.animation.SkinAnimations",e);var i=t.prototype;return i._getAnimationDatasWithCache=function(e,t,n,i,r){var a=n[i];if(a){var s=a[e];if(s){var o=s[t.id];return o?o[r]:null}return null}return null},i._setAnimationDatasWithCache=function(e,t,n,i,r,a){var s=n[i]||(n[i]={}),o=s[e]||(s[e]={}),l=o[t.id]||(o[t.id]=[]);l[r]=a},i._onAnimationPlayMeshLoaded=function(){for(var e=this._ownerMesh.meshRender.renderObject._renderElements,t=0,n=e.length;n>t;t++)e[t]._canDynamicBatch=!1},i._onAnimationPlay=function(){var e=this._ownerMesh.meshFilter.sharedMesh;e.loaded?this._onAnimationPlayMeshLoaded():e.on("loaded",this,this._onAnimationPlayMeshLoaded)},i._onAnimationStop=function(){this._lastFrameIndex=-1,this._player.returnToZeroStopped&&(this._curBonesDatas=null,this._curAnimationDatas=null);for(var e=this._ownerMesh.meshRender.renderObject._renderElements,t=0,n=e.length;n>t;t++)e[t]._canDynamicBatch=!0},i._load=function(t){e.prototype._load.call(this,t),this._ownerMesh=t,this._player.on("played",this,this._onAnimationPlay),this._player.on("stopped",this,this._onAnimationStop)},i.preComputeKeyFrames=function(e){if(!this._templet.loaded||!this._ownerMesh.meshFilter.sharedMesh.loaded)throw new Error("SkinAnimations: must to be sure animation templet and mesh templet has loaded.");for(var n=this._player.cachePlayRate,i=this._player.cacheFrameRateInterval*n,r=Math.floor(this._templet.getAniDuration(e)/i),a=0;r>=a;a++){var s=this._templet._animationDatasCache[0],o=this._templet._animationDatasCache[1],l=this._ownerMesh.meshFilter.sharedMesh,h=this._getAnimationDatasWithCache(n,l,o,e,a);if(!h){var u=this._templet.getNodes(e),c=16*u.length;this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(c));var _=0,d=0;for(this._curAnimationDatas=[],_=0,d=l.getSubMeshCount();d>_;_++)this._curAnimationDatas[_]=new Float32Array(16*l.getSubMesh(_)._boneIndices.length);this._curBonesDatas=new Float32Array(c),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(e))),this._templet.getOriginalData(e,this._curOriginalData,this._player._fullFrames[e],a,i*a);var m=l.InverseAbsoluteBindPoses;for(m?rt._computeBoneAndAnimationDatasByBindPoseMatrxix(u,this._curOriginalData,m,this._curBonesDatas,this._curMeshAnimationData):(this._extenData||(this._extenData=new Float32Array(this._templet.getPublicExtData())),rt._computeBoneAndAnimationDatas(u,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData)),_=0,d=l.getSubMeshCount();d>_;_++){var f=l.getSubMesh(_);t._computeSubMeshAniDatas(_,f._boneIndices,this._curMeshAnimationData,this._curAnimationDatas)}this._setAnimationDatasWithCache(n,l,o,e,a,this._curAnimationDatas),this._templet.setAnimationDataWithCache(n,s,e,a,this._curBonesDatas)}}},i._update=function(e){var i=this._ownerMesh.meshFilter.sharedMesh;if(2===this._player.state&&this._templet&&this._templet.loaded&&i.loaded){var r=this._player.playbackRate*n.timer.scale,a=this._player.cachePlayRate,s=this._player.isCache&&r>=a,o=s?this.currentFrameIndex:-1;if(-1===o||this._lastFrameIndex!==o){var l=this.currentAnimationClipIndex,h=this._templet._animationDatasCache[0],u=this._templet._animationDatasCache[1];if(s){var c=this._getAnimationDatasWithCache(a,i,u,l,o);if(c)return this._curAnimationDatas=c,this._curBonesDatas=this._templet.getAnimationDataWithCache(a,h,l,o),void(this._lastFrameIndex=o)}var _=!1;s&&(this._curBonesDatas=this._templet.getAnimationDataWithCache(a,h,l,o),_=!!this._curBonesDatas);var d=this._templet.getNodes(l),m=16*d.length;this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(m));var f=0,p=0;if(s){for(this._curAnimationDatas=[],f=0,p=i.getSubMeshCount();p>f;f++)this._curAnimationDatas[f]=new Float32Array(16*i.getSubMesh(f)._boneIndices.length);_||(this._curBonesDatas=new Float32Array(m))}else{if(!this._tempCurAnimationData)for(this._tempCurAnimationData=[],f=0,p=i.getSubMeshCount();p>f;f++)this._tempCurAnimationData[f]=new Float32Array(16*i.getSubMesh(f)._boneIndices.length);this._tempCurBonesData||(this._tempCurBonesData=new Float32Array(m)),this._curAnimationDatas=this._tempCurAnimationData,this._curBonesDatas=this._tempCurBonesData}this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(l))),s?this._templet.getOriginalData(l,this._curOriginalData,this._player._fullFrames[l],o,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(l,this._curOriginalData,this._player.currentPlayTime);var v=i.InverseAbsoluteBindPoses;for(v?s&&_?rt._computeAnimationDatasByArrayAndMatrixFast(v,this._curBonesDatas,this._curMeshAnimationData):rt._computeBoneAndAnimationDatasByBindPoseMatrxix(d,this._curOriginalData,v,this._curBonesDatas,this._curMeshAnimationData):(this._extenData||(this._extenData=new Float32Array(this._templet.getPublicExtData())),s&&_?rt._computeAnimationDatas(this._extenData,this._curBonesDatas,this._curMeshAnimationData):rt._computeBoneAndAnimationDatas(d,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData)),f=0,p=i.getSubMeshCount();p>f;f++){var g=i.getSubMesh(f);t._computeSubMeshAniDatas(f,g._boneIndices,this._curMeshAnimationData,this._curAnimationDatas)}s&&(this._setAnimationDatasWithCache(a,i,u,l,o,this._curAnimationDatas),_||this._templet.setAnimationDataWithCache(a,h,l,o,this._curBonesDatas)),this._lastFrameIndex=o}}},i._preRenderUpdate=function(e){if(this._curAnimationDatas){e.shaderDefines.addInt(32768);var t=e.renderElement.renderObj.indexOfHost;e.shaderValue.pushValue("MATRIXARRAY0",this._curAnimationDatas[t])}},i._unload=function(t){e.prototype._unload.call(this,t),this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._extenData=null,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null},a(0,i,"curBonesDatas",function(){return this._curBonesDatas}),a(0,i,"curAnimationDatas",function(){return this._curAnimationDatas}),a(0,i,"url",null,function(t){e.prototype._$set_url.call(this,t),this._curOriginalData=this._extenData=null,this._curMeshAnimationData=null,this._tempCurBonesData=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[[],[]])}),a(0,i,"templet",e.prototype._$get_templet,function(t){e.prototype._$set_templet.call(this,t),this._curOriginalData=this._extenData=null,this._curMeshAnimationData=null,this._tempCurBonesData=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[[],[]])}),t._computeSubMeshAniDatas=function(e,t,n,i){for(var r=i[e],a=0,s=t.length,o=0;s>a;a++)for(var l=0;16>l;l++,o++)r[o]=n[(t[a]<<4)+l]},t._copyBone=function(e,t,n){for(var i=0,r=e.length,a=0;r>i;i++)for(var s=0;16>s;s++,a++)n[a]=t[(e[i]<<4)+s]},t}(Et)),Gt=(function(e){function t(){this._nodes=null,this._lasstInitIndex=-1,this._materials=null,this._mesh=null,this._meshDataInited=!1,this._uvDatasCount=0,this._subMeshIndexToNodeIndex=[],this._keyframeAges=[],this._ages=[],this._bufferUsages=[],this._originalShaderAttributes=[],this._uvShaderValues=[],this._uvNextShaderValues=[],this._uvAnimationBuffers=[],t.__super.call(this),this._meshDataInited=!1}r(t,"laya.d3.component.animation.UVAnimations",e);var n=t.prototype;return n._initMeshData=function(){this._materials=this._mesh.meshRender.sharedMaterials,this._meshDataInited=!0},n._initAnimationData=function(e){},n._load=function(e){if(!(e instanceof laya.d3.core.MeshSprite3D))throw new Error("该Sprite3D并非Mesh");this._mesh=e,e.on("loaded",this,function(e){}),this.on("loaded",this,function(){}),this.player.on("played",this,function(){}),this.player.on("stopped",this,function(){})},n._update=function(e){if(this.player.update(e.elapsedTime),this._templet&&this._templet.loaded&&2===this.player.state){for(var t=this.currentAnimationClipIndex,n=this._templet.getNodesCurrentFrameIndex(t,this.player.currentPlayTime),i=0;it?!1:(this._subMeshes.splice(t,1),this._subMeshCount--,!0)},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1];new Ge(n,this,this._materials,i),this._loaded=!0,this.event("loaded",this)},i.getSubMesh=function(e){return this._subMeshes[e]},i.getSubMeshCount=function(){return this._subMeshes.length},i.getRenderElementsCount=function(){return this._subMeshes.length},i.getRenderElement=function(e){return this._subMeshes[e]},i.dispose=function(){this._resourceManager.removeResource(this),laya.resource.Resource.prototype.dispose.call(this);for(var e=0;en;n++){var i,r=this._subMeshes[n],a=r._getVertexBuffer(),s=a.vertexDeclaration.getVertexElements(),o=0;for(o=0;oT;T++)e[T]=T;this._vertexBuffer=new Bt(t._vertexDeclaration,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},n._addVertex=function(e,t,n){var i=n.elements;return e[t+0]=i[0],e[t+1]=i[1],e[t+2]=i[2],t+3},n.loadShaderParams=function(){this._sharderNameID=C.nameKey.get("SkyBox"),this._shaderValue.pushValue("DIFFUSETEXTURE",null)},n._render=function(e){if(this._textureCube&&this._textureCube.loaded){this._vertexBuffer._bind(),this._indexBuffer._bind(),this._shader=this._getShader(e);var n=this._shaderValue.length;this._shaderValue.pushArray(e.shaderValue),this._shaderValue.pushArray(this._vertexBuffer.vertexDeclaration.shaderValues),e.camera.transform.worldMatrix.cloneTo(t._tempMatrix4x40),t._tempMatrix4x40.transpose(),je.multiply(e.projectionMatrix,t._tempMatrix4x40,t._tempMatrix4x41),this._shaderValue.pushValue("MVPMATRIX",t._tempMatrix4x41.elements),this._shaderValue.pushValue("INTENSITY",this._colorIntensity),this._shaderValue.pushValue("ALPHABLENDING",this.alphaBlending),this._shaderValue.data[1]=this.textureCube.source,this._shader.uploadArray(this._shaderValue.data,this._shaderValue.length,null),this._shaderValue.length=n,w.mainContext.drawElements(4,36,5123,0),L.trianglesFaces+=12,L.drawCall++}},a(0,n,"alphaBlending",function(){return this._alphaBlending},function(e){this._alphaBlending=e,this._alphaBlending<0&&(this._alphaBlending=0),this._alphaBlending>1&&(this._alphaBlending=1)}),a(0,n,"textureCube",function(){return this._textureCube},function(e){this._textureCube=e}),a(0,n,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),t._nameNumber=1,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je},"_vertexDeclaration",function(){return this._vertexDeclaration=new fe(12,[new pe(0,"vector3","POSITION")])}]),t}(Mt),function(e){function t(){this._sharderNameID=0,this._shader=null,this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,this._alphaBlending=1,this._colorIntensity=1,this._texture=null,this._stacks=16,this._slices=16,this._radius=1,this._shaderValue=new b,t.__super.call(this),this.name="SkyDome-"+t._nameNumber,t._nameNumber++,this.loadShaderParams(),this.recreateResource()}r(t,"laya.d3.resource.models.SkyDome",e);var n=t.prototype;return n._getShader=function(e){var t=e.shaderDefines,n=t._value,i=t._value+2e-4*this._sharderNameID;return this._shader=C.withCompile(this._sharderNameID,e.shaderDefines.toNameDic(),i,null),t._value=n,this._shader},n.recreateResource=function(){this.startCreate(),this._numberVertices=(this._stacks+1)*(this._slices+1),this._numberIndices=3*this._stacks*(this._slices+1)*2;for(var e=new Uint16Array(this._numberIndices),n=t._vertexDeclaration.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=Math.PI/this._stacks,a=2*Math.PI/this._slices,s=0,o=0,l=0,h=0;h1&&(this._alphaBlending=1)}),a(0,n,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),a(0,n,"texture",function(){return this._texture},function(e){this._texture=e}),t._nameNumber=1,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je},"_vertexDeclaration",function(){return this._vertexDeclaration=new fe(20,[new pe(0,"vector3","POSITION"),new pe(12,"vector2","UV")])}]),t}(Mt),function(e){function t(){this._src=null,this._image=null,this._recreateLock=!1,this._needReleaseAgain=!1,t.__super.call(this)}r(t,"laya.d3.resource.Texture2D",e);var i=t.prototype;return i._onTextureLoaded=function(e){this._image=e;var t=e.width,n=e.height;this._width=t,this._height=n,this._size=new it(t,n)},i._createWebGlTexture=function(){if(!this._image)throw"create GLTextur err:no data:"+this._image;var e=w.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=N.curBindTexTarget,a=N.curBindTexValue;N.bindTexture(e,3553,t),e.texImage2D(3553,0,6408,6408,5121,this._image);var s=this._minFifter,o=this._magFifter,h=this._repeat?10497:33071,u=l.isPOT(n,i);u?(this._mipmap?-1!==s||(s=9987):-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,h),e.texParameteri(3553,10243,h),this._mipmap&&e.generateMipmap(3553)):(-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071)),r&&a&&N.bindTexture(e,r,a),this._image.onload=null,this._image=null,u?this.memorySize=n*i*4*(1+1/3):this.memorySize=n*i*4,this._recreateLock=!1},i.recreateResource=function(){if(null!=this._src&&""!==this._src)if(this._needReleaseAgain=!1,this._image){if(this._recreateLock)return;this.startCreate(),this._createWebGlTexture(),this.completeCreate()}else{this._recreateLock=!0,this.startCreate();var e=this;this._image=new h.window.Image,this._image.crossOrigin="",this._image.onload=function(){return e._needReleaseAgain?(e._needReleaseAgain=!1,e._image.onload=null,void(e._image=null)):(e._createWebGlTexture(),void e.completeCreate())},this._image.src=this._src}},i.onAsynLoaded=function(e,t){this._src=e,this._onTextureLoaded(t),this.activeResource(),this._loaded=!0,this.event("loaded",this)},i.detoryResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(w.mainContext.deleteTexture(this._source),this._source=null,this._image=null,this.memorySize=0)},a(0,i,"src",function(){return this._src}),t.load=function(e){return n.loader.create(e,null,null,t)},t}(Tt)),Xt=function(e){function t(){this._texCount=6,this._recreateLock=!1,this._needReleaseAgain=!1,t.__super.call(this)}r(t,"laya.d3.resource.TextureCube",e);var i=t.prototype;return i._onTextureLoaded=function(e){this._images=e;for(var t=2147483647,n=2147483647,i=0;6>i;i++){var r=e[i];t=Math.min(t,r.width),n=Math.min(n,r.height)}this._width=t,this._height=n,this._size=new it(t,n)},i._createWebGlTexture=function(){var e=0;for(e=0;ee;e++)this._images[e].onload=null,this._images[e]=null;c?this.memorySize=i*r*4*(1+1/3)*this._texCount:this.memorySize=i*r*4*this._texCount,this._recreateLock=!1},i.recreateResource=function(){var e=this;if(null!=this._srcs)if(this._needReleaseAgain=!1,this._images[0]){if(this._recreateLock)return;this.startCreate(),this._createWebGlTexture(),this.completeCreate()}else{this._recreateLock=!0,this.startCreate();for(var t=this,n=0;nt;t++){var i=this._cameraPool[t];i.enable&&this._renderCamera(e,this._renderState,i)}return this._set2DRenderConfig(e),1},t})(Ct),function(e){function t(){t.__super.call(this)}r(t,"laya.d3.core.scene.VRScene",e);var n=t.prototype;return n.renderCamera=function(e,t,n){this._prepareRenderToRenderState(n,t),t.shaderDefines.add(64),this.beforeRender(t);var i=n.renderTarget;i?(i.start(),je.multiply(this._invertYScaleMatrix,n.leftProjectionMatrix,this._invertYProjectionMatrix),je.multiply(this._invertYScaleMatrix,n.leftProjectionViewMatrix,this._invertYProjectionViewMatrix),t.projectionMatrix=this._invertYProjectionMatrix,t.projectionViewMatrix=this._invertYProjectionViewMatrix):(t.projectionMatrix=n.leftProjectionMatrix,t.projectionViewMatrix=n.leftProjectionViewMatrix),t.viewMatrix=n.leftViewMatrix,t.viewport=n.leftViewport,this._preRenderScene(e,t),this._clear(e,t),this._renderScene(e,t),i?(i.start(),je.multiply(this._invertYScaleMatrix,n.rightProjectionMatrix,this._invertYProjectionMatrix),je.multiply(this._invertYScaleMatrix,n.rightProjectionViewMatrix,this._invertYProjectionViewMatrix),t.projectionMatrix=this._invertYProjectionMatrix,t.projectionViewMatrix=this._invertYProjectionViewMatrix):(t.projectionMatrix=n.rightProjectionMatrix,t.projectionViewMatrix=n.rightProjectionViewMatrix),t.viewMatrix=n.rightViewMatrix,t.viewport=n.rightViewport,this._preRenderScene(e,t),this._clear(e,t),this._renderScene(e,t),this.lateRender(t),i&&i.end()},n.renderSubmit=function(){var e=w.mainContext,t=this._renderState;this._set3DRenderConfig(e);for(var n=0,i=this._cameraPool.length;i>n;n++){var r=this._cameraPool[n];r.enable&&this.renderCamera(e,t,r)}return this._set2DRenderConfig(e),1},t}(Ct),function(e){function t(e,n,i){void 0===e&&(e=0),void 0===n&&(n=.1),void 0===i&&(i=1e3),this._viewMatrix=new je,this._projectionMatrix=new je,this._projectionViewMatrix=new je,this._viewport=new Je(0,0,0,0),this._normalizedViewport=new Je(0,0,1,1),this._aspectRatio=e,t.__super.call(this,n,i)}r(t,"laya.d3.core.Camera",e);var n=t.prototype;return n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n.viewportPointToRay=function(e,t){tt.calculateCursorRay(e,this.viewport,this._projectionMatrix,this.viewMatrix,null,t)},n.normalizedViewportPointToRay=function(e,n){var i=t._tempVector2,r=this.viewport,a=e.elements,s=i.elements;s[0]=a[0]*r.width,s[1]=a[1]*r.height,tt.calculateCursorRay(i,this.viewport,this._projectionMatrix,this.viewMatrix,null,n)},n.worldToViewportPoint=function(e,t){if(je.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.viewport.project(e,this._projectionViewMatrix,t),t.z<0||t.z>1){var n=t.elements;n[0]=n[1]=n[2]=NaN}},n.worldToNormalizedViewportPoint=function(e,t){if(je.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.normalizedViewport.project(e,this._projectionViewMatrix,t),t.z<0||t.z>1){var n=t.elements;n[0]=n[1]=n[2]=NaN}},a(0,n,"projectionViewMatrix",function(){return je.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix),this._projectionViewMatrix}),a(0,n,"aspectRatio",function(){if(0===this._aspectRatio){var e=this.viewport;return e.width/e.height}return this._aspectRatio},function(e){if(0>e)throw new Error("Camera: the aspect ratio has to be a positive real number.");this._aspectRatio=e,this._calculateProjectionMatrix()}),a(0,n,"needViewport",function(){var e=this.normalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"viewport",function(){if(this._viewportExpressedInClipSpace){var e=this._normalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._viewport.x=e.x*n,this._viewport.y=e.y*i,this._viewport.width=e.width*n,this._viewport.height=e.height*i}return this._viewport},function(e){if(null!=this.renderTarget&&(e.x<0||e.y<0||0==e.width||0==e.height))throw new Error("Camera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!1,this._viewport=e,this._calculateProjectionMatrix()}),a(0,n,"normalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._viewport,t=this.renderTargetSize,n=t.width,i=t.height;this._normalizedViewport.x=e.x/n,this._normalizedViewport.y=e.y/i,this._normalizedViewport.width=e.width/n,this._normalizedViewport.height=e.height/i}return this._normalizedViewport},function(e){if(e.x<0||e.y<0||e.x+e.width>1||e.x+e.height>1)throw new Error("Camera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!0,this._normalizedViewport=e,this._calculateProjectionMatrix()}),a(0,n,"projectionMatrix",function(){return this._projectionMatrix},function(e){this._projectionMatrix=e,this._useUserProjectionMatrix=!0}),a(0,n,"viewMatrix",function(){return this.transform.worldMatrix.invert(this._viewMatrix),this._viewMatrix}),i(t,["_tempVector2",function(){return this._tempVector2=new Ke}]),t}(Vt),function(e){function t(){this._direction=null,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.6,.6,.6),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1),this._direction=new Qe(0,-.5,-1)}r(t,"laya.d3.core.light.DirectionLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(4096),t.pushValue("LIGHTDIRDIFFUSE",this.diffuseColor.elements),t.pushValue("LIGHTDIRAMBIENT",this.ambientColor.elements),t.pushValue("LIGHTDIRSPECULAR",this.specularColor.elements),t.pushValue("LIGHTDIRECTION",this.direction.elements)}},a(0,n,"direction",function(){return this._direction},function(e){this._direction=e}),a(0,n,"lightType",function(){return 1}),t}(Dt),function(e){function t(){this._attenuation=null,this._range=NaN,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.2,.2,.2),this._specularColor=new Qe(1,0,0),this._reflectColor=new Qe(1,1,1),this.transform.position=new Qe(0,0,0),this._range=6,this._attenuation=new Qe(.6,.6,.6)}r(t,"laya.d3.core.light.PointLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(8192),t.pushValue("POINTLIGHTDIFFUSE",this.diffuseColor.elements),t.pushValue("POINTLIGHTAMBIENT",this.ambientColor.elements),t.pushValue("POINTLIGHTSPECULAR",this.specularColor.elements),t.pushValue("POINTLIGHTPOS",this.transform.position.elements),t.pushValue("POINTLIGHTRANGE",this.range),t.pushValue("POINTLIGHTATTENUATION",this.attenuation.elements)}},a(0,n,"range",function(){return this._range},function(e){this._range=e}),a(0,n,"lightType",function(){return 2}),a(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e}),t}(Dt),function(e){function t(){this._direction=null,this._attenuation=null,this._spot=NaN,this._range=NaN,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.2,.2,.2),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1),this.transform.position=new Qe(0,1,1),this._direction=new Qe(0,-1,-1),this._attenuation=new Qe(.6,.6,.6),this._spot=96,this._range=6}r(t,"laya.d3.core.light.SpotLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(16384),t.pushValue("SPOTLIGHTDIFFUSE",this.diffuseColor.elements),t.pushValue("SPOTLIGHTAMBIENT",this.ambientColor.elements),t.pushValue("SPOTLIGHTSPECULAR",this.specularColor.elements),t.pushValue("SPOTLIGHTPOS",this.transform.position.elements),t.pushValue("SPOTLIGHTDIRECTION",this.direction.elements),t.pushValue("SPOTLIGHTRANGE",this.range),t.pushValue("SPOTLIGHTSPOT",this.spot),t.pushValue("SPOTLIGHTATTENUATION",this.attenuation.elements)}},a(0,n,"range",function(){return this._range},function(e){this._range=e}),a(0,n,"direction",function(){return this._direction},function(e){this._direction=e}),a(0,n,"lightType",function(){return 3}),a(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e}),a(0,n,"spot",function(){return this._spot},function(e){this._spot=e}),t}(Dt),function(e){function t(e,n,i){this._minX=NaN,this._minZ=NaN,this._cellSize=null,this._heightMap=null,t.__super.call(this,e,i),this._heightMap=n,this._cellSize=new Ke}r(t,"laya.d3.core.MeshTerrainSprite3D",e);var n=t.prototype;return n._disableRotation=function(){var e=this.transform.rotation;e.elements[0]=0,e.elements[1]=0,e.elements[2]=0,e.elements[3]=1,this.transform.rotation=e},n._getScaleX=function(){var e=this.transform.worldMatrix,t=e.elements,n=t[0],i=t[1],r=t[2];return Math.sqrt(n*n+i*i+r*r)},n._getScaleZ=function(){var e=this.transform.worldMatrix,t=e.elements,n=t[8],i=t[9],r=t[10];return Math.sqrt(n*n+i*i+r*r)},n._initCreateFromMesh=function(e,t){this._heightMap=F.creatFromMesh(this.meshFilter.sharedMesh,e,t,this._cellSize);var n=this.meshFilter.sharedMesh.boundingBox,i=n.min;n.max;this._minX=i.x,this._minZ=i.z},n._createFromMeshAndHeightMapMeshLoaded=function(e,t,n,i){this._initCreateFromMeshHeightMap(t,n,i)},n._initCreateFromMeshHeightMap=function(e,t,n){var i=this,r=this.meshFilter.sharedMesh.boundingBox;e.loaded?(this._heightMap=F.createFromImage(e,t,n),this._computeCellSize(r)):e.once("loaded",null,function(){i._heightMap=F.createFromImage(e,t,n),i._computeCellSize(r)});var a=r.min;r.max;this._minX=a.x,this._minZ=a.z},n._computeCellSize=function(e){var t=e.min,n=e.max,i=t.x,r=t.z,a=n.x,s=n.z,o=a-i,l=s-r;this._cellSize.elements[0]=o/(this._heightMap.width-1),this._cellSize.elements[1]=l/(this._heightMap.height-1)},n._update=function(t){this._disableRotation(),e.prototype._update.call(this,t)},n.getHeight=function(e,n){t._tempVector3.elements[0]=e,t._tempVector3.elements[1]=0,t._tempVector3.elements[2]=n,this._disableRotation();var i=this.transform.worldMatrix;i.invert(t._tempMatrix4x4),Qe.transformCoordinate(t._tempVector3,t._tempMatrix4x4,t._tempVector3),e=t._tempVector3.elements[0],n=t._tempVector3.elements[2];var r=(e-this._minX)/this._cellSize.x,a=(n-this._minZ)/this._cellSize.y,s=Math.floor(a),o=Math.floor(r),l=r-o,h=a-s,u=NaN,c=NaN,_=i.elements,d=_[4],m=_[5],f=_[6],p=Math.sqrt(d*d+m*m+f*f),v=_[13],g=this._heightMap.getHeight(s,o+1),T=this._heightMap.getHeight(s+1,o);if(isNaN(g)||isNaN(T))return NaN;if(1>=l+h){var x=this._heightMap.getHeight(s,o);return isNaN(x)?NaN:(u=g-x,c=T-x,(x+l*u+h*c)*p+v)}var M=this._heightMap.getHeight(s+1,o+1);return isNaN(M)?NaN:(u=T-M,c=g-M,(M+(1-l)*u+(1-h)*c)*p+v)},a(0,n,"minX",function(){var e=this.transform.worldMatrix,t=e.elements;return this._minX*this._getScaleX()+t[12]}),a(0,n,"width",function(){return(this._heightMap.width-1)*this._cellSize.x*this._getScaleX(); +}),a(0,n,"minZ",function(){var e=this.transform.worldMatrix,t=e.elements;return this._minZ*this._getScaleZ()+t[14]}),a(0,n,"depth",function(){return(this._heightMap.height-1)*this._cellSize.y*this._getScaleZ()}),t.createFromMesh=function(e,n,i,r){var a=new t(e,null,r);return e.loaded?a._initCreateFromMesh(n,i):e.once("loaded",a,a._initCreateFromMesh,[n,i]),a},t.createFromMeshAndHeightMap=function(e,n,i,r,a){var s=new t(e,null,a);return e.loaded?s._initCreateFromMeshHeightMap(n,i,r):e.once("loaded",s,s._createFromMeshAndHeightMapMeshLoaded,[n,r]),s},i(t,["_tempVector3",function(){return this._tempVector3=new Qe},"_tempMatrix4x4",function(){return this._tempMatrix4x4=new je}]),t}(Lt),function(e){function t(e,n,i,r,a){void 0===e&&(e=.1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=.1),void 0===a&&(a=1e3),this._tempMatrix=new je,this._leftViewMatrix=new je,this._leftProjectionMatrix=new je,this._leftProjectionViewMatrix=new je,this._leftViewport=new Je(0,0,0,0),this._leftNormalizedViewport=new Je(0,0,.5,1),this._leftAspectRatio=n,this._rightViewMatrix=new je,this._rightProjectionMatrix=new je,this._rightProjectionViewMatrix=new je,this._rightViewport=new Je(0,0,0,0),this._rightNormalizedViewport=new Je(.5,0,.5,1),this._rightAspectRatio=i,this._pupilDistande=e,t.__super.call(this,r,a)}r(t,"laya.d3.core.VRCamera",e);var n=t.prototype;return n._calculatePupilOffset=function(){var e=this._tempVector3;return Qe.scale(this.right,this._pupilDistande/2,e),e.elements},n._calculateLeftProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n._calculateRightProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.rightAspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,t,t,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize,n=this.orthographicVerticalSize*this.rightAspectRatio*.5,i=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix),je.createOrthogonal(-n,n,i,i,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._leftProjectionMatrix),je.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},a(0,n,"leftNormalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._leftViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._leftNormalizedViewport.x=e.x/n,this._leftNormalizedViewport.y=e.y/i,this._leftNormalizedViewport.width=e.width/n,this._leftNormalizedViewport.height=e.height/i}return this._leftNormalizedViewport}),a(0,n,"rightViewport",function(){if(this._viewportExpressedInClipSpace){var e=this._rightNormalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._rightViewport.x=e.x*n,this._rightViewport.y=e.y*i,this._rightViewport.width=e.width*n,this._rightViewport.height=e.height*i}return this._rightViewport}),a(0,n,"viewport",null,function(e){if(null!=this.renderTarget&&(e.x<0||e.y<0||0==e.width||0==e.height))throw new Error("VRCamera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!1,this._leftViewport=new Je(0,0,e.width/2,e.height),this._rightViewport=new Je(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),a(0,n,"leftAspectRatio",function(){if(0===this._leftAspectRatio){var e=this.leftViewport;return e.width/e.height}return this._leftAspectRatio}),a(0,n,"rightAspectRatio",function(){if(0===this._rightAspectRatio){var e=this.rightViewport;return e.width/e.height}return this._rightAspectRatio}),a(0,n,"aspectRatio",null,function(e){if(0>e)throw new Error("VRCamera: the aspect ratio has to be a positive real number.");this._leftAspectRatio=e,this._rightAspectRatio=e,this._calculateRightProjectionMatrix()}),a(0,n,"rightNormalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._rightViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._rightNormalizedViewport.x=e.x/n,this._rightNormalizedViewport.y=e.y/i,this._rightNormalizedViewport.width=e.width/n,this._rightNormalizedViewport.height=e.height/i}return this._rightNormalizedViewport}),a(0,n,"normalizedViewport",null,function(e){if(e.x<0||e.y<0||e.x+e.width>1||e.x+e.height>1)throw new Error("VRCamera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!0,this._leftNormalizedViewport=new Je(0,0,e.width/2,e.height),this._rightNormalizedViewport=new Je(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),a(0,n,"leftViewport",function(){if(this._viewportExpressedInClipSpace){var e=this._leftNormalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._leftViewport.x=e.x*n,this._leftViewport.y=e.y*i,this._leftViewport.width=e.width*n,this._leftViewport.height=e.height*i}return this._leftViewport}),a(0,n,"needLeftViewport",function(){var e=this.leftNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"needRightViewport",function(){var e=this.rightNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"leftViewMatrix",function(){var e=this._calculatePupilOffset(),t=this._tempMatrix;this.transform.worldMatrix.cloneTo(t);var n=t.elements;return n[12]-=e[0],n[13]-=e[1],n[14]-=e[2],t.invert(this._leftViewMatrix),this._leftViewMatrix}),a(0,n,"rightViewMatrix",function(){var e=this._calculatePupilOffset(),t=this._tempMatrix;this.transform.worldMatrix.cloneTo(t);var n=t.elements;return n[12]+=e[0],n[13]+=e[1],n[14]+=e[2],t.invert(this._rightViewMatrix),this._rightViewMatrix}),a(0,n,"leftProjectionMatrix",function(){return this._leftProjectionMatrix}),a(0,n,"leftProjectionViewMatrix",function(){return je.multiply(this.leftProjectionMatrix,this.leftViewMatrix,this._leftProjectionViewMatrix),this._leftProjectionViewMatrix}),a(0,n,"rightProjectionMatrix",function(){return this._rightProjectionMatrix}),a(0,n,"rightProjectionViewMatrix",function(){return je.multiply(this.rightProjectionMatrix,this.rightViewMatrix,this._rightProjectionViewMatrix),this._rightProjectionViewMatrix}),t}(Vt),function(e){function t(e,n,i){this._long=NaN,this._width=NaN,this._height=NaN,void 0===e&&(e=1),void 0===n&&(n=1),void 0===i&&(i=1),t.__super.call(this),this._long=e,this._width=n,this._height=i,this.recreateResource(),this._loaded=!0;var r=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(r,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(r,this._boundingSphere)}r(t,"laya.d3.resource.models.BoxMesh",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate(),this._numberVertices=24,this._numberIndices=36;var e=new Uint16Array(this._numberIndices),t=Oe.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=this._long/2,a=this._width/2,s=0;i[s+0]=-r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]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[o+1]=1,e[o+2]=2,o+=3,e[o+0]=2,e[o+1]=3,e[o+2]=0,o+=3,e[o+0]=4,e[o+1]=7,e[o+2]=6,o+=3,e[o+0]=6,e[o+1]=5,e[o+2]=4,o+=3,e[o+0]=8,e[o+1]=9,e[o+2]=10,o+=3,e[o+0]=10,e[o+1]=11,e[o+2]=8,o+=3,e[o+0]=12,e[o+1]=15,e[o+2]=14,o+=3,e[o+0]=14,e[o+1]=13,e[o+2]=12,o+=3,e[o+0]=16,e[o+1]=17,e[o+2]=18,o+=3,e[o+0]=18,e[o+1]=19,e[o+2]=16,o+=3,e[o+0]=20,e[o+1]=23,e[o+2]=22,o+=3,e[o+0]=22,e[o+1]=21,e[o+2]=20,this._vertexBuffer=new Bt(t,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},a(0,n,"long",function(){return this._long},function(e){this._long=e,this.recreateResource()}),a(0,n,"width",function(){return this._width},function(e){this._width=e,this.recreateResource()}),a(0,n,"height",function(){return this._height},function(e){this._height=e,this.recreateResource()}),t}(Gt),function(e){function t(e,n,i,r){this._radius=NaN,this._height=NaN,this._slices=0,this._stacks=0,void 0===e&&(e=10),void 0===n&&(n=10),void 0===i&&(i=8),void 0===r&&(r=8),t.__super.call(this),this._radius=e,this._height=n,this._stacks=i,this._slices=r,this.recreateResource(),this._loaded=!0;var a=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(a,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(a,this._boundingSphere)}r(t,"laya.d3.resource.models.CylinderMesh",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate(),this._numberVertices=(this._stacks+1+2)*(this._slices+1),this._numberIndices=2*(this._slices-1+this._stacks*this._slices)*3;for(var e=new Uint16Array(this._numberIndices),t=Oe.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=2*Math.PI/this._slices,a=0,s=.5,o=.5,l=.5,h=.5,u=.5,c=0,_=0,d=1,m=1,f=0,p=0,v=0,g=0;g0&&g>0){var A=p-1,I=p,C=p-(this._slices+1),V=p-(this._slices+1)-1;e[f++]=V,e[f++]=A,e[f++]=I,e[f++]=V,e[f++]=I,e[f++]=C}p++}E+=M}for(g=0;gp&&(l=p),g>u&&(g=u),0>l&&(l=0),0>g&&(g=0),f>p&&(f=p),c>u&&(c=u),0>f&&(f=0),0>c&&(c=0);var _=this._finder.findPath(l,g,f,c,this.grid);this.grid.reset();for(var m=1;m<_.length-1;m++){var D=_[m];D[0]=D[0]*a+o+n,D[1]=D[1]*s+d+h}return 1==_.length?(_[0][0]=r,_[0][1]=r):_.length>1&&(_[0][0]=t,_[0][1]=i,_[_.length-1][0]=r,_[_.length-1][1]=e),_},n(0,r,"setting",function(){return this._setting},function(t){t&&(this._finder=new PathFinding.finders.AStarFinder(t)),this._setting=t}),i}(h)}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.debugtool.min.js b/games/laya-snakes/libs/min/laya.debugtool.min.js new file mode 100644 index 0000000..1a27f1d --- /dev/null +++ b/games/laya-snakes/libs/min/laya.debugtool.min.js @@ -0,0 +1,7 @@ +!function(window,document,Laya){var __un=Laya.un,__uns=Laya.uns,__static=Laya["static"],__class=Laya["class"],__getset=Laya.getset,__newvec=Laya.__newvec,Box=laya.ui.Box,Browser=laya.utils.Browser,Button=laya.ui.Button,Byte=laya.utils.Byte,CSSStyle=laya.display.css.CSSStyle,Component=laya.ui.Component,Config=Laya.Config,Event=laya.events.Event,EventDispatcher=laya.events.EventDispatcher,Filter=laya.filters.Filter,GrahamScan=laya.maths.GrahamScan,Graphics=laya.display.Graphics,HTMLCanvas=laya.resource.HTMLCanvas,Handler=laya.utils.Handler,Image=laya.ui.Image,Input=laya.display.Input,Label=laya.ui.Label,List=laya.ui.List,Loader=laya.net.Loader,LoaderManager=laya.net.LoaderManager,LocalStorage=laya.net.LocalStorage,MathUtil=laya.maths.MathUtil,Matrix=laya.maths.Matrix,Node=laya.display.Node,Point=laya.maths.Point,Pool=laya.utils.Pool,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite,Resource=laya.resource.Resource,ResourceManager=laya.resource.ResourceManager,RunDriver=laya.utils.RunDriver,Sprite=laya.display.Sprite,Stage=laya.display.Stage,Stat=laya.utils.Stat,Style=laya.display.css.Style,Text=laya.display.Text,TextInput=laya.ui.TextInput,Texture=laya.resource.Texture,Tree=laya.ui.Tree,UIEvent=laya.ui.UIEvent,URL=laya.net.URL,Utils=laya.utils.Utils,View=laya.ui.View,Base64AtlasManager=function(){function e(){}return __class(e,"laya.debug.data.Base64AtlasManager"),e.replaceRes=function(t){e.base64.replaceRes(t)},__static(e,["dataO",function(){return this.dataO={"comp/button1.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAABRCAYAAAApS3MNAAABSUlEQVR4Xu3a0QmFMADFUJ1JXM0h3moPZ6qg4AoNeLqAIenFn65jjLE40w2sQkxvcAMI0eggRKSDEEJUDEQ4/COEiBiIYFiEEBEDEQyLECJiIIJhEUJEDEQwLEKIiIEIhkUIETEQwbAIISIGIhgWIUTEQATDIoSIGIhgWIQQEQMRDIsQImIggnEvYvv9IzjfxDiP/XlgJsTcCyDEXP/v14UQImIggmERQkQMRDAsQoiIgQiGRQgRMRDBsAghIgYiGBYhRMRABMMihIgYiGBYhBARAxEMixAiYiCCYRFCRAxEMCxCiIiBCMa7iAjPpzG8fY3kF0KIiIEIhkUIETEQwbAIISIGIhgWIUTEQATDIoSIGIhgWIQQEQMRDIsQImIggmERQkQMRDAsQoiIgQiGRQgRMRDBsAghIgYiGBYhRMRABMMihIgYiGBcGJiOHTRZjZAAAAAASUVORK5CYII=","comp/line2.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAAG0lEQVQYV2NkoDJgpLJ5DIxtra3/qWko1V0IAJvgApS1libIAAAAAElFTkSuQmCC","view/create.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAkCAYAAAC9itu8AAAAdElEQVQ4T2NkwAIWLFjwH5t4QkICIyM2CXQxmAHka/j///9mXDYxMjL6YtgwBDUg+w8crIT8MBQ0oEca55JvWNPS9xgu4tISzADyNfz///8MnrRkgmHDENSALWng9fRQ0DA40xLecglbWhpqGoZCMUNKUQkANAHAJVkE5XwAAAAASUVORK5CYII=","view/rendertime.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAkCAYAAAC9itu8AAABeUlEQVQ4T+2Uv0tCURSAvyNdcwiXBlsaaomWFgeHlqAtCPsDJHwIiUtDSxERtErtmQ6CjkHo4FpDBQ0tbVFR0BYE0eQvOnFF7T17QlOTd3m88873OD8+rtA9uVzOBIPBlIisAwvd8B1QajQahXQ63bIx6QHFYrEEJHrv7qeqZhzHOfYA+Xw+Yow5B+YHoGwymdxW1QAQEFWNAk8i8uEDuZM3gUcLZIEJYNcNqWrVcZyd7p9t8jLwYIFTYBx47UHlcjmcSCQ+B5JtpU0LnAFj3br7kE+yTalb4BCYczVqoT3AjteW4T73FlgFNgY+1IGQz4hPLGCAI2DGbweu2Auw1Vmcqk4C+8DsEOgZOBCR9/6mVdU2vgIsAdOuIVwANRFpezatuahpTYVSop1m+y6pasm8NQqSvvW61KwslkSHuCRkgvErr0taiUXaal1Sr0siWRO/9HfpF+RN9nfpB/qqmrXrv7mktVhYVm5GLo1cct9LI5e8d84/3UvfAgdlKH0EO7MAAAAASUVORK5CYII=","view/cache.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAkCAYAAABSSLCCAAAAcElEQVQ4T2NcsGDB/4SEBEYGBgYGYtmMxCpENhhsA6mA8f///5tHNTEwkBcQpIYcSD15kUtWigi51vR/jVYdOGUQy2YkViGywWSnvTOkhiAonkY1gZIRqSEHTntkRe4g10RWQIyWe5Bgo2O5R7dkBADztyP+yFzirAAAAABJRU5ErkJggg==","comp/clip_selectBox.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAoCAYAAAAIeF9DAAAAsElEQVRoQ+3ZQQ0AMQzEwAuqEgh/Sj2pKObhIrBsrfLonHPu12MMTEGYFg+kIFaPgmA9ClIQzQDG0w0pCGYAw2khBcEMYDgtpCCYAQynhRQEM4DhtJCCYAYwnBZSEMwAhtNCCoIZwHBmd/tTh6IUBIrx/tRbiFWkIFaPFoL1KEhBNAMYTzekIJgBDKeFFAQzgOG0kIJgBjCcFlIQzACG00IKghnAcFpIQTADGE4LwYL8U/BE1dCJ3PsAAAAASUVORK5CYII=","comp/label.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAASCAYAAACQCxruAAAAmElEQVRoQ+3aMQqAQBBDUef+hx4Zq1mrbPnhWylECHmghVZ397OOqqp97TlugdNzgEXFIaaFuwROt0LmBEay5aXb920+FjIpMJItLy1wvhUyKTCSLS8tcL4VMikwki0vLXC+FTIpMJItLy1wvhUyKTCSLS89wPP1Qeh8M0zy+84gMMbruqjA15OxbtjAu7mPa5bj0fb/A8cLgD4n/wQKNiIAAAAASUVORK5CYII=","comp/clip_tree_arrow.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAQCAYAAAArij59AAAAwUlEQVQoU5WRPRKCMBCFWUt6vYQeB06RUDpoBbFDa7yDwm30FGi9dHnOMiQDBgvT5c3b7+0PRVEUlVV9A3NmzL6T//SRfMz5CgCdtVafjlmzaHAigAbM2tE8YVo1pf0yvABoc9D3wACgBbMKIgD4qqDJsqqlMV8VGL5n/88geCJKlijSMBXFZUNx/CSi9WwX1r7R99thzKKqkxXRbMUWSE2u2sEwHsxHCbrMVSq6N4xRD9HAvJstylEkarhurlqnfQC58YP5+CvQNwAAAABJRU5ErkJggg==","view/bg_panel.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMUlEQVRYR+3QQREAAAjDMGZk/l2CDD6pgl7SduexGCBAgAABAgQIECBAgAABAgS+BQ4oyStBhXcy5AAAAABJRU5ErkJggg==","view/bg_top.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMUlEQVRYR+3QQREAAAjDMKZp/rWBDD6pgl7SduexGCBAgAABAgQIECBAgAABAgS+BQ6WyDMhXMLeQgAAAABJRU5ErkJggg==","view/clickselect.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAqCAYAAACDdWrxAAACfElEQVRIS8WVO2iTYRSGn5OWqpMOurg0VRBdVVCsg7GgDjpZECyirl4GEYfSgBlaB5VSpApdxCJIoeKgg7dKC21ALahIiyiKKUjxAiI4qCH1lRP/hPhfAnHpGZPv+c4573nP95ukO/xHmINmtq8RtswsPiipB/gAPAFem5nCbcSWKukIsD84/A2YBh4DL8ysWLkk0qOkDcD5GLF+Ac+Ap35ZHGjAdWB5gtJvgZFYVSWdBHaFwBlg1Mw8K0ngFiAbAm+a2XBij/6HpBbgBrAEmAVeAZ1AFU40QDCWrcBZL0/S4Vq4HtgB7DWzU5XyauDBMhhWz70ryVVdb2ZuhGpI2g1MODjfiMFrxZk3s9WNwJ6snHFxQUlXgXfAPeC5mf2O2Y5oqZLcMceCw1+AseCSSTP7mSiOpM3A7RixfvgYgAd+WUQcSSnfPWBlgtIvgf5YVSVdBA6GQF/mS2bmWcvbERmHJF+payFw0MzO1TWApKXBViwL3h5/Pk4AVTjRAMFY9njJXl6wLccrcD3wAHDUzBwuRw18JtbkbkFJruomM7sf2o4u4Jals/mFRgxeFcfBQm97UyOwM+WMiwums/k3QnMps+HWpuLIRC5TCrcRW2pbT35MRiY4XDRsVmiU5uJQIZfxb0k5Ij229eQPySJ287MLGO8Rd1M0XY6AO3LjzYVSy3fAH+VICL4a6o9VtTWb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ggg==","view/tab_panel.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAABICAYAAADyMAW8AAAAcUlEQVRYR+3WsQ3AMAhE0TCMeyTvP1tShRQo7lxYegxA8fUPLuac97VhwuKXKhTlFxRQ9GPDClawYvGEDwxIZu7pFRZXr4ACinY1ghWsYMX/NxWQr22edyvGGHt6hcV1NqGAon8QVrCCFYteISDnBuQB3xJuQcDkEngAAAAASUVORK5CYII=","view/btn_close.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAqCAYAAACz+XvQAAACmUlEQVRIS7WWS0/bUBCFz7mJmyZxENm06mNVoVZC7LqGn9FNqy55/BSWSEhs2/4uuqFVoA150JLKJvGdaiIH2TfXNoKQpeP5PHPO3GMTK/5xxTwsAUWkBeBZ+qAByb/Zh4pIA8CL9NqY5Dj7vw9YA/ABwDsAfwB8ITnUIhF5CuATgNcAfgH4RnJSCkwLl6AA/lXBtLZQQxFxoTr6q6LOFl2WmuJAtcY7ZuXIixsczfRyTlPfhpSN7BpwBeBtFdQLFJE2gI8AXi7GBBBl3Fdnv5L87XbpWxuFfQbw3NXM0dQLLdrDIH3ylGTiLLYB8CS9lpCc3tmU+xzL1Z9lEXl/n06KavjowCiK1uM4fqMd1Ov1s3a7fZntZjabtSeTiQYHgiC4aLVavZwpbofT6TQYDAaH1tod3bMwDHc7nc5PLZrNZmG/3z8WkS1jzGm32z1oNBqjUqD+6YM2m81xFWyeNkUaulAAlyKyWdTZbdqUmZKFakEVrLRDV7P5zY6m3rQp6tA1AMC5tXY7he51Op0fdwbGcdwdDodHWc2MMdcL9wGM1tbW9sMw/L6UNm6HChuNRifW2g1XM0dTL3TJZS1KkkTDFbVaLQqCIJcm6k0URRpxuvg39Xo9rtzDh5zt1Z/lXq+32rR5dKC1dt0YM08bAGd65BxN1ZB52ojIBcl82rgdWmsDkocAdgDoW22X5DxtSIZJkhyT3AJwCuCAZD5tfCP7oMaYcRVs/tAiDT1QHX2zqLPbtCk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QmCC","comp/textinput.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAAAWCAYAAACv8OArAAAAZElEQVRYR+3UQQkAMAwEwcZI/LtsoSL2NTGwMByZ3b3HJQIDO3H+EdidNezQGjbsUiBs+dmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4EwZdmwQ4Ew9QBe0R29X9x+dwAAAABJRU5ErkJggg==","comp/vscroll.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAhCAYAAAA/F0BXAAAAOklEQVRIS2N8+OzVf2YWFgYmJiYGcgHjqCEYQTcaJpipaTRMRsOEmDJmNJ2MppPRdEJMCIymE2JCCQAYonwDuu2VMAAAAABJRU5ErkJggg==","comp/vscroll$down.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAzCAYAAABxCePHAAAC/klEQVRIS+2WS0wTURSG/zszBcrLFVvjio0LiAqRRDAmGpRodFE1MQQQkOKGqBujRo3ExLjB4MaKgDzUaGQhvoJGYwAjYoioERcuDGxYEIwPkBY6nWvObXuLnXZaSklYOIu5M/fxzZn/nvPPsInJKa5qGhRFQaIH+w8xSbcymtTd+gBFYXAdyjM9sf7ORxgGR0t5/j9jpkhq2t5B0xQwBrgqNsnJ9V0j4BzQdQNtNYXWkKz0NDiaXkBTFTCFoaWmCHVtQ+AGh+4z0HNiO2bmPNYQGiXQvkuPoaqqiIgi8Pl8eHBqtwlA86MKS6Cy8z1gjIFzjqcXHBEBlpBgRNuOd+HVlYqogJiQIChcg/BtW5k8SaSSkxPJ5PRPTttHfkI7kcghIpn8NYfp33NLXp+TnYG1OWvA3ox9499nPSjdkCsgHJxOIjc43VMrugL9dEUD4Oj/PA4CsUfDX/jOjbmisHTDCCzi4t4QgLDrQF+qTYOmqhgYGw9BvLpv0ZNjQwieaU9b7ZCDriFhSt3VBSZNartHA6aUJ7SK+jqO5n5pSp1HiqSw1e3Di0ypwBpiU1X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r8BfgGeWI6+BgEAAAAASUVORK5CYII=","comp/button.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE0AAABFCAYAAAAPWmvdAAABA0lEQVR4Xu3ZMRGDUBRFwXwfKSgxFhfRgAbUxEakkCEO3qmX+p9m5w7NW9v7cz18I4EFbeT1fwxtbgYtmEGDVgRC458GLQiExNKgBYGQWBq0IBASS4MWBEJiadCCQEgsDVoQCImlQQsCIbE0aEEgJJZW0Pbj64Q3hFvQhmL3CQ8atLlAKCwNWhAIiaVBCwIhsTRoQSAklgYtCITE0qAFgZBYGrQgEBJLgxYEQmJp0IJASCwNWhAIiaUVtOfrdMIbwi1oQ7H7hAcN2lwgFJYGLQiExNKgBYGQWBq0IBASS4MWBEJiadCCQEgsDVoQCImlQQsCIbE0aEEgJJYGLQiExNIC2g/MxaMp6CSauwAAAABJRU5ErkJggg==","view/bg_tool.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAMklEQVRYR+3QQREAAAjDMCYG/DsEGXxSBb2ke7YeiwECBAgQIECAAAECBAgQIEDgW+AAAeIuAVS/mngAAAAASUVORK5CYII=","comp/minBtn.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA8CAYAAAB1odqiAAAArUlEQVRYR+3X0QmAMAwE0GQN19B9nM193CmiIH7ZXOAoRc/fpjl8jVDdOj/eOc8USBcXqUjLAtDQRMSOdHb3JatTYCZUXodIy10bGxTI1Lx6/YA0Ima6W2tKFcjmdpGKtCow7NBAdxozy+804Gfx/cDqbLzWDzs0ekNY4B9nOMEehMKTVIEEyKeFSKmc18+MppRtipJuYPCa1SkwEyqvo6Tlxm8bFEijvBt9n/QA/fOPydLHcUIAAAAASUVORK5CYII=","view/zoom_out.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAACy0lEQVRIS92WQU8TQRTH/28oQkj0CL0QOMAJQkz4DkS6A+GA+A00H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cXhKSZsBCyrpdjlwuZwfSO8mLOkdYAHqFXSrRKWvErtXFdOcJcnp0AX96ZwuldQ5uxtTrD+VUmWWXqfujwk8eQ4f68rsuRG+d/gZVb9eIk9kPS6miXvIv91rNc12TXPc5MkTyO/AFhJCujHqZlCAAAAAElFTkSuQmCC","comp/checkbox.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAqCAYAAACDdWrxAAABbUlEQVRIS+2TP0gCURzHv88GRYsrExyOo5cEQVEtWdQQpE4N0R+HxmirXXCrKYigqMF2IRqCQByaLJqNIFpyUIzu4rIwpExODy88ITD/cJ603Rsf7/OGz+/zI5TSEAE20cZRgBMySKni8XrbwICrWAwG2ESZIadFS53J0R25brCyHZNud1vbcRuPV7fDAOu9GXJatNSZHN2R6wb/PfJCrxOZCR8Gbk6hWc6Xg8PrcgBETMIVPdIGSjYG/NoOSHcfkLqDK3qsBSRIrgRAuBF1quUPEUPhYGMwb2dhywrqQ3F0Dt++jSokJMBdhmDO52pB2WwFP7OK8rgH9os99IgppNf3QWwMFP4RNHKALrmoflIj53l6CaWpRcBkgiIkYHl6gDTrh5JJg57v/kJ1YOUixw7jfWELxMpAKUmAXAR7tg3LZ7am3IbjKDBOvPiDqkUmcoj+9H1d7k3nmHdweBubB70ON9wRzQH8pVVQb+Q/zZAEfpwDCU4AAAAASUVORK5CYII=","comp/btn_close.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA8CAYAAAB1odqiAAAE6UlEQVRYR+3Y30+bVRgH8G/T0t/0Jy0USrIsC0E2GMKAVYcRpmSbEzIGZhqyxCxeceGVF3pjvJl/wYyJWZYY4hZBFnBuBBUW2ewYAxlsSMiyLKH8aEt/0vZtSxvM+562We15C6jlxr53zfO8z+ec5z2nOTmCk598tY19fAQs+Hlvz76QX1zpAwd+1NMNXzieU1QtFeKbvn4CXvqgC95wLKegRirC1e8GCPjh+53wMnRwedkG54aLG4yhSI/ycnPawHaKJ5M1MhGuXR8k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F1DqisjLMzPxBwNraasRsdHDD6c7ApDIJVzTMRDJiRQb6EUNkLsPs7DwBa6qrELPZqCNzu/1pG1siEUOhkHK5wWAYkUg0La7T0U9tIrMZc/MLBKw+XImtZTrIMBFEouQkIBEXQJaYXXJ0O8WTeQXlZsw/XSRg1SsVvGDWpbuHIAsu/LlEwMrKCsQDAcQ93j2U2H2qUKuBUKnE4uISBF9f/Hj7wJwVhyordl/hH2Q+W1zCixoLOdNUj98Ei+byYbH5lnPkmJhL6O+18/c0/1m38/c0qVbm72nYVuTvadgu5O9pUtsif0+Tv6dhF8P/657mLz4NfQVdLmZiAAAAAElFTkSuQmCC","comp/textarea.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAAAXCAYAAABkrDOOAAAA4klEQVRoQ+3ZvQrCMBiF4e9rU+sPOErRqxDRe/KG9Fp0EAc3VzuIg1ML4uDmlkaaquDenMUTyJoDD+8W3ZyKlaoshSeogHOy1m1euOmoI1EU+auqQUf/8XHnnBzLp3jsWdaVJEnEGEPsADXU2Ifro8Gej/uSpqnHruvmaVegqirZX+4N9mIy8Nh13XEct7vE18RaK7vzjdiIFoiNUH5vEJvYQAHgFMsmNlAAOMWyiQ0UAE6xbGIDBYBTLJvYQAHgFMsmNlAAOMWyiQ0UAE79lM2fmrDy358a/q6Hhf68ng175QueKdEXxUGVVwAAAABJRU5ErkJggg==","view/re.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAACpklEQVRIS+WWPUgcQRiG3+8O70QEUwTB1EJgsTGdRRrhOMjOtEtSRbBIBMFKuCtkZleES2uRQoWQJggKKW7Of7GyTRvBLkVShhS73OXMfWGOU85Es7uXs0m2XeZh+OZ95xnCHX10R1ykBvu+P5fP59+VSqVvf9pUarBS6jWAR0Q0rbWOboP3BCaiOQAHAKTW+vtN8L8BW96W4zjPPM/78Ss8FlypVEYajYbHzALAJIAHALJdoDWl1Esi4m74rWBmpiAI5pk5AHAvJ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PgbZqmW8aYd9t3ohCVUt4BWARwkyTJZhzHH7Zgdq4MvQbw7ThOw/f9zypgKVoVsS7UX+C+v+kgeI0Oklrvb0Yw03rwlZW8Hnz14OvqjXrw1e/pPyfwCww91CttlMG7AAAAAElFTkSuQmCC","view/save.png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAAA1klEQVRIS+2VzQ3DIAyFwxwdoMMAA/VQ8ZByyEBhmA7QOVxxKLIaOcIoSZUfrlifHw/wM91Ky6zE7SZgANTaDEDhzYJ5odSMC7nA5U7+b4X2dVQr3ic4hHCTlMcY33xPZUUGcwBvdEJwjcfGGIQQ4rd2qenWA3hyAUuABwCP31NtN+i1v02qP4DicRybM885J2ceB/NCyUupfuLxBS4WbmKF9rNUv4p9gq21d0l5SunF91RWZDAH8EYnBNd4nDPPWitnXst0I6Leez+feVowEQ3e+wNk3ge7C/Qp3GfwkgAAAABJRU5ErkJggg=="}},"base64",function(){return this.base64=new Base64Atlas(e.dataO)}]),e}(),DebugTool=function(){function e(){}return __class(e,"laya.debug.DebugTool"),__getset(1,e,"target",function(){return e._target},function(t){e._target=t}),__getset(1,e,"isThisShow",function(){return!1}),__getset(1,e,"showStatu",null,function(t){t?Stat.show():(Stat.hide(),e.clearDebugLayer())}),__getset(1,e,"showBound",function(){return e._showBound},function(t){e._showBound=t,e._showBound||e.clearDebugLayer()}),e.getMenuShowEvent=function(){return Browser.onMobile?"doubleclick":"rightclick"},e.init=function(t,i,o,n,s){void 0===t&&(t=!0),void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===n&&(n=!0),void 0===s&&(s=!1),e.enableCacheAnalyse=t,e.enableCacheAnalyse&&RenderSpriteHook.init(),n&&SpriteRenderHook.init(),e.enableNodeCreateAnalyse=o,e.enableNodeCreateAnalyse&&ClassCreateHook.I.hookClass(Node),i&&LoaderHook.init(),CacheAnalyser.showCacheSprite=s,DisplayHook.initMe(),NodeInfoPanel.init(),e.debugLayer||(e.debugLayer=DebugInfoLayer.I.graphicLayer,e.debugLayer.mouseEnabled=!1,e.debugLayer.mouseThrough=!0,e.showStatu=!0,Laya.stage.on("keydown",null,e.keyHandler),e.cmdToTypeO[1]="IMAGE",e.cmdToTypeO[2]="ALPHA",e.cmdToTypeO[4]="TRANSFORM",e.cmdToTypeO[8]="CANVAS",e.cmdToTypeO[256]="GRAPHICS",e.cmdToTypeO[512]="CUSTOM",e.cmdToTypeO[2048]="CHILDS",DebugExport["export"]())},e.dTrace=function(t){null!=e._traceFun&&e._traceFun(t),console.log(t)},e.keyHandler=function(t){var i;if(i=String.fromCharCode(t.keyCode),t.altKey){switch(t.keyCode){case 38:e.showParent();break;case 40:e.showChild();break;case 37:e.showBrother(e.target,1);break;case 39:e.showBrother(e.target,-1)}e.dealCMDKey(i)}},e.dealCMDKey=function(t){switch(t){case"上":e.showParent();break;case"下":e.showChild();break;case"左":e.showBrother(e.target,1);break;case"右":e.showBrother(e.target,-1);break;case"B":e.showAllBrother();break;case"C":e.showAllChild();break;case"E":e.traceDisMouseEnable();break;case"S":e.traceDisSizeChain();break;case"D":DisControlTool.downDis(e.target);break;case"U":DisControlTool.upDis(e.target);break;case"N":e.getNodeInfo();break;case"M":e.showAllUnderMosue();break;case"I":break;case"O":ObjectCreateView.I.show();break;case"L":DisController.I.switchType();break;case"Q":e.showNodeInfo();break;case"F":e.showToolPanel();break;case"P":e.showToolFilter();break;case"V":e.selectNodeUnderMouse();break;case"A":NodeToolView.I.target&&MouseEventAnalyser.analyseNode(NodeToolView.I.target);break;case"K":NodeUtils.traceStage();break;case"T":e.switchNodeTree();break;case"R":RenderCostRankView.I.show();break;case"X":NodeTree.I.fresh();break;case"mCMD":e.traceCMD();break;case"allCMD":e.traceCMDR()}},e.switchNodeTree=function(){ToolPanel.I.switchShow("Tree")},e.analyseMouseHit=function(){e.target&&MouseEventAnalyser.analyseNode(e.target)},e.selectNodeUnderMouse=function(){DisplayHook.instance.selectDisUnderMouse(),e.showDisBound()},e.showToolPanel=function(){ToolPanel.I.switchShow("Find")},e.showToolFilter=function(){ToolPanel.I.switchShow("Filter")},e.showNodeInfo=function(){NodeInfoPanel.I.isWorkState?NodeInfoPanel.I.recoverNodes():NodeInfoPanel.I.showDisInfo(e.target)},e.switchDisController=function(){DisController.I.target?DisController.I.target=null:e.target&&(DisController.I.target=e.target)},e.showParent=function(t){return t||(t=e.target),t?(e.target=t.parent,void e.autoWork()):(console.log("no targetAvalible"),null)},e.showChild=function(t){return t||(t=e.target),t?void(t.numChildren>0&&(e.target=t.getChildAt(0),e.autoWork())):(console.log("no targetAvalible"),null)},e.showAllChild=function(t){return t||(t=e.target),t?(e.selectedNodes=DisControlTool.getAllChild(t),void e.showSelected()):(console.log("no targetAvalible"),null)},e.showAllUnderMosue=function(){e.selectedNodes=DisControlTool.getObjectsUnderGlobalPoint(Laya.stage),e.showSelected()},e.showParentChain=function(t){if(t){e.selectedNodes=[];var i;for(i=t.parent;i;)e.selectedNodes.push(i),i=i.parent;e.showSelected()}},e.showAllBrother=function(t){return t||(t=e.target),t?void(t.parent&&(e.selectedNodes=DisControlTool.getAllChild(t.parent),e.showSelected())):(console.log("no targetAvalible"),null)},e.showBrother=function(t,i){if(void 0===i&&(i=1),t||(t=e.target),!t)return console.log("no targetAvalible"),null;var o;if(o=t.parent){var n=0;n=o.getChildIndex(t),n+=i,0>n&&(n+=o.numChildren),n>=o.numChildren&&(n-=o.numChildren),e.target=o.getChildAt(n),e.autoWork()}},e.clearDebugLayer=function(){e.debugLayer.graphics&&e.debugLayer.graphics.clear()},e.showSelected=function(){if(e.autoShowSelected&&e.selectedNodes&&!(e.selectedNodes.length<1)){console.log("selected:"),console.log(e.selectedNodes);var t=0,i=0;for(i=e.selectedNodes.length,e.clearDebugLayer(),t=0;i>t;t++)e.showDisBound(e.selectedNodes[t],!1)}},e.getClassCreateInfo=function(e){return RunProfile.getRunInfo(e)},e.autoWork=function(){e.isThisShow&&(e.showBound&&e.showDisBound(),e.autoTraceSpriteInfo&&e.target&&TraceTool.traceSpriteInfo(e.target,e.autoTraceBounds,e.autoTraceSize,e.autoTraceTree),e.target&&(e.autoTraceCMD&&e.traceCMD(),e.autoTraceCMDR&&e.traceCMDR(),e.autoTraceEnable&&e.traceDisMouseEnable(e.target)))},e.traceDisMouseEnable=function(t){if(console.log("traceDisMouseEnable:"),t||(t=e.target),!t)return console.log("no targetAvalible"),null;var i;for(i=["TraceDisMouseEnable"],e.selectedNodes=[];t;)i.push(ClassTool.getNodeClassAndName(t)+":"+t.mouseEnabled+" hitFirst:"+t.hitTestPrior),e.selectedNodes.push(t),t=t.parent;return e.showSelected(),i.join("\n")},e.traceDisSizeChain=function(t){if(console.log("traceDisSizeChain:"),t||(t=e.target),!t)return console.log("no targetAvalible"),null;e.selectedNodes=[];var i; +for(i=["traceDisSizeChain"];t;)e.dTrace(TraceTool.getClassName(t)+":"),i.push(ClassTool.getNodeClassAndName(t)+":"),i.push("Size: x:"+t.x+" y:"+t.y+" w:"+t.width+" h:"+t.height+" scaleX:"+t.scaleX+" scaleY:"+t.scaleY),TraceTool.traceSize(t),e.selectedNodes.push(t),t=t.parent;return e.showSelected(),i.join("\n")},e.showDisBound=function(t,i,o){if(void 0===i&&(i=!0),void 0===o&&(o="#ff0000"),t||(t=e.target),!t)return console.log("no targetAvalible"),null;i&&e.clearDebugLayer();var n;n=t._getBoundPointsM(!0),!n||n.length<1||(n=GrahamScan.pListToPointList(n,!0),WalkTools.walkArr(n,t.localToGlobal,t),n=GrahamScan.pointListToPlist(n),e._disBoundRec=Rectangle._getWrapRec(n,e._disBoundRec),e.debugLayer.graphics.drawRect(e._disBoundRec.x,e._disBoundRec.y,e._disBoundRec.width,e._disBoundRec.height,null,o),DebugInfoLayer.I.setTop())},e.showDisBoundToSprite=function(t,i,o,n){void 0===o&&(o="#ff0000"),void 0===n&&(n=1);var s;s=t._getBoundPointsM(!0),!s||s.length<1||(s=GrahamScan.pListToPointList(s,!0),WalkTools.walkArr(s,t.localToGlobal,t),s=GrahamScan.pointListToPlist(s),e._disBoundRec=Rectangle._getWrapRec(s,e._disBoundRec),i.graphics.drawRect(e._disBoundRec.x,e._disBoundRec.y,e._disBoundRec.width,e._disBoundRec.height,null,o,n))},e.getNodeInfo=function(){return e.counter.reset(),WalkTools.walkTarget(Laya.stage,e.addNodeInfo),console.log("node info:"),e.counter.traceSelf(),e.counter.data},e.findByClass=function(t){return e._classList=[],e._tFindClass=t,WalkTools.walkTarget(Laya.stage,e.addClassNode),e.selectedNodes=e._classList,e.showSelected(),e._classList},e.addClassNode=function(t){var i;i=t.constructor.name,i==e._tFindClass&&e._classList.push(t)},e.traceCMD=function(t){if(t||(t=e.target),!t)return console.log("no targetAvalible"),null;console.log("self CMDs:"),console.log(t.graphics.cmds);var i;for(i=RenderSprite.renders[t._renderType],console.log("renderSprite:",i),e._rSpList.length=0;i&&i._sign>0;)e._rSpList.push(e.cmdToTypeO[i._sign]),i=i._next;return console.log("fun:",e._rSpList.join(",")),e.counter.reset(),e.addCMDs(t.graphics.cmds),e.counter.traceSelf(),e.counter.data},e.addCMDs=function(t){WalkTools.walkArr(t,e.addCMD)},e.addCMD=function(t){e.counter.add(t.callee)},e.traceCMDR=function(t){return t||(t=e.target),t?(e.counter.reset(),WalkTools.walkTarget(t,e.getCMdCount),console.log("cmds include children"),e.counter.traceSelf(),e.counter.data):(console.log("no targetAvalible"),0)},e.getCMdCount=function(t){if(!t)return 0;if(!(t instanceof laya.display.Sprite))return 0;if(!t.graphics.cmds)return 0;e.addCMDs(t.graphics.cmds);var i=t.graphics.cmds.length;return i},e.addNodeInfo=function(t){var i;i=t.constructor.name,e.counter.add(i)},e.find=function(t,i){void 0===i&&(i=!0);var o;return o=e.findTarget(Laya.stage,t),e.selectedNodes=o,e.selectedNodes&&(e.target=e.selectedNodes[0]),i&&e.showSelected(),o},e.findByName=function(t){return e.nameFilter.name=t,e.find(e.nameFilter)},e.findNameStartWith=function(t){return e.nameFilter.name=e.getStartWithFun(t),e.find(e.nameFilter)},e.findNameHas=function(t,i){return void 0===i&&(i=!0),e.nameFilter.name=e.getHasFun(t),e.find(e.nameFilter,i)},e.getStartWithFun=function(e){var t=function(t){return t?0==t.indexOf(e):!1};return t},e.getHasFun=function(e){var t=function(t){return t?t.indexOf(e)>=0:!1};return t},e.findTarget=function(t,i){var o=[];e.isFit(t,i)&&o.push(t);var n,s=0,a=0;for(a=t.numChildren,s=0;a>s;s++)n=t.getChildAt(s),n instanceof laya.display.Sprite&&(o=o.concat(e.findTarget(n,i)));return o},e.findClassHas=function(t,i){var o=[];ClassTool.getClassName(t).indexOf(i)>=0&&o.push(t);var n,s=0,a=0;for(a=t.numChildren,s=0;a>s;s++)n=t.getChildAt(s),n instanceof laya.display.Sprite&&(o=o.concat(e.findClassHas(n,i)));return o},e.isFit=function(e,t){if(!e)return!1;if(!t)return!0;if("function"==typeof t)return t(e);var i;for(i in t)if("function"==typeof t[i]){if(!t[i](e[i]))return!1}else if(e[i]!=t[i])return!1;return!0},e.log=function(t){var i,o=arguments;i=DTrace.getArgArr(o),null!=e._logFun&&e._logFun(i.join(" "))},e.enableCacheAnalyse=!1,e.enableNodeCreateAnalyse=!0,e._traceFun=null,e.debugLayer=null,e._target=null,e.selectedNodes=[],e.autoShowSelected=!0,e._showBound=!0,e._disBoundRec=null,e.autoTraceEnable=!1,e.autoTraceBounds=!1,e.autoTraceSize=!1,e.autoTraceTree=!0,e.autoTraceCMD=!0,e.autoTraceCMDR=!1,e.autoTraceSpriteInfo=!0,e._classList=null,e._tFindClass=null,e._rSpList=[],e._logFun=null,__static(e,["text",function(){return this.text=new Stat},"cmdToTypeO",function(){return this.cmdToTypeO={}},"counter",function(){return this.counter=new CountTool},"nameFilter",function(){return this.nameFilter={name:"name"}}]),e}(),Base64Atlas=function(){function e(e,t){this.data=null,this.replaceO=null,this.idKey=null,this._loadedHandler=null,this.data=e,t||(t=Math.random()+"key"),this.idKey=t,this.init()}__class(e,"laya.debug.tools.Base64Atlas");var t=e.prototype;return t.init=function(){this.replaceO={};var e;for(e in this.data)this.replaceO[e]=this.idKey+"/"+e},t.getAdptUrl=function(e){return this.replaceO[e]},t.preLoad=function(e){this._loadedHandler=e,Laya.loader.load(Base64ImageTool.getPreloads(this.data),new Handler(this,this.preloadEnd))},t.preloadEnd=function(){var e;for(e in this.data){var t;t=Laya.loader.getRes(this.data[e]),Loader.cacheRes(this.replaceO[e],t)}this._loadedHandler&&this._loadedHandler.run()},t.replaceRes=function(e){ObjectTools.replaceValue(e,this.replaceO)},e}(),Base64ImageTool=function(){function e(){}return __class(e,"laya.debug.tools.Base64ImageTool"),e.getCanvasPic=function(e){e=e.bitmap;var t=Browser.createElement("canvas"),i=t.getContext("2d");return t.height=e.height,t.width=e.width,i.drawImage(e.source,0,0),t},e.getBase64Pic=function(t){return e.getCanvasPic(t).toDataURL("image/png")},e.getPreloads=function(e){var t;t=[];var i;for(i in e)t.push({url:e[i],type:"image"});return t},e}(),Base64Tool=function(){function e(){}return __class(e,"laya.debug.tools.Base64Tool"),e.init=function(){if(!e.lookup){e.lookup=new Uint8Array(256);for(var t=0;to;o+=3)s+=e.chars[i[o]>>2],s+=e.chars[(3&i[o])<<4|i[o+1]>>4],s+=e.chars[(15&i[o+1])<<2|i[o+2]>>6],s+=e.chars[63&i[o+2]];return n%3===2?s=s.substring(0,s.length-1)+"=":n%3===1&&(s=s.substring(0,s.length-2)+"=="),s},e.encodeStr=function(t){var i;return i=new Byte,i.writeUTFString(t),e.encodeByte(i)},e.encodeByte=function(t,i,o){return void 0===i&&(i=0),void 0===o&&(o=-1),0>o&&(o=t.length),e.encode(t.buffer.slice(i,o))},e.decodeToByte=function(t){return new Byte(e.decode(t))},e.decode=function(t){e.init();var i=.75*t.length,o=t.length,n=0,s=0,a=0,r=0,l=0,h=0;"="===t[t.length-1]&&(i--,"="===t[t.length-2]&&i--);var c=new ArrayBuffer(i),u=new Uint8Array(c);for(n=0;o>n;n+=4)a=e.lookup[t.charCodeAt(n)],r=e.lookup[t.charCodeAt(n+1)],l=e.lookup[t.charCodeAt(n+2)],h=e.lookup[t.charCodeAt(n+3)],u[s++]=a<<2|r>>4,u[s++]=(15&r)<<4|l>>2,u[s++]=(3&l)<<6|63&h;return c},e.chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e.lookup=null,e}(),CacheAnalyser=function(){function e(){}__class(e,"laya.debug.tools.CacheAnalyser");var t=e.prototype;return t.renderCanvas=function(t,i){void 0===i&&(i=0),e.showCacheSprite&&(DebugInfoLayer.I.isDebugItem(t)||DebugTool.showDisBoundToSprite(t,DebugInfoLayer.I.cacheViewLayer,"#ff0000",2))},t.reCacheCanvas=function(t,i){if(void 0===i&&(i=0),!DebugInfoLayer.I.isDebugItem(t)){var o;o=e.getNodeInfoByNode(t),o.addCount(i),e.counter.addTime(t,i),o.parent||DebugInfoLayer.I.nodeRecInfoLayer.addChild(o)}},e.renderLoopBegin=function(){DebugInfoLayer.I.cacheViewLayer.graphics.clear()},e.getNodeInfoByNode=function(t){IDTools.idObj(t);var i=0;return i=IDTools.getObjID(t),e._nodeInfoDic[i]||(e._nodeInfoDic[i]=new ReCacheRecInfo),e._nodeInfoDic[i].setTarget(t),e._nodeInfoDic[i]},e._nodeInfoDic={},e.showCacheSprite=!1,__static(e,["counter",function(){return this.counter=new ObjTimeCountTool},"I",function(){return this.I=new e}]),e}(),CanvasTools=function(){function e(){}return __class(e,"laya.debug.tools.CanvasTools"),e.createCanvas=function(e,t){var i=new HTMLCanvas("2D");return i.getContext("2d"),i.size(e,t),i},e.renderSpriteToCanvas=function(e,t,i,o){RenderSprite.renders[e._renderType]._fun(e,t.context,i,o)},e.getImageDataFromCanvas=function(e,t,i,o,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===n&&(n=0),0>=o&&(o=e.width),0>=n&&(n=e.height);var s=e.context.getImageData(t,i,o,n);return s},e.getImageDataFromCanvasByRec=function(e,t){var i=e.context.getImageData(t.x,t.y,t.width,t.height);return i},e.getDifferCount=function(t,i){function o(t,i,o,r){e.isPoinSame(o,n,s)||a++}var n=t.data,s=i.data,a=0;return a=0,e.walkImageData(t,o),a},e.getDifferRate=function(t,i){return e.getDifferCount(t,i)/(t.width*t.height)},e.getCanvasDisRec=function(t){var i;i=new Rectangle;var o;o=e.getImageDataFromCanvas(t,0,0);var n=0,s=0,a=0,r=0;n=a=0,s=o.width,r=o.height;var l=0,h=0,c=0,u=0;h=o.width,u=o.height;var f;f=o.data;var d=0;for(c=0;u>c;c++)for(l=0;h>l;l++)e.isEmptyPoint(f,d)||(s>l&&(s=l),l>n&&(n=l),r>c&&(r=c),c>a&&(a=c)),d+=4;return i.setTo(s,r,n-s+1,a-r+1),i},e.fillCanvasRec=function(e,t,i){var o=e.context;o.fillStyle=i,o.fillRect(t.x,t.y,t.width,t.height)},e.isEmptyPoint=function(e,t){return 0==e[t]&&0==e[t+1]&&0==e[t+2]&&0==e[t+3]},e.isPoinSame=function(e,t,i){return t[e]==i[e]&&t[e+1]==i[e+1]&&t[e+2]==i[e+2]&&t[e+3]==i[e+3]},e.walkImageData=function(e,t){var i=0,o=0,n=0,s=0;o=e.width,s=e.height;var a=0,r=e.data;for(i=0;o>i;i++)for(n=0;s>n;n++)t(i,n,a,r),a+=4},e.getSpriteByCanvas=function(e){var t;return t=new Sprite,t.graphics.drawTexture(new Texture(e),0,0,e.width,e.height),t},e.renderSpritesToCanvas=function(t,i,o,n,s){void 0===o&&(o=0),void 0===n&&(n=0),void 0===s&&(s=0);var a=0,r=0;for(r=i.length,a=s;r>a;a++)e.renderSpriteToCanvas(i[a],t,o,n)},e.clearCanvas=function(e){var t=NaN,i=NaN;t=e.width,i=e.height,e.size(t+1,i),e.size(t,i)},e}(),ClassTool=function(){function ClassTool(){}return __class(ClassTool,"laya.debug.tools.ClassTool"),ClassTool.defineProperty=function(e,t,i){Object.defineProperty(e,t,i)},ClassTool.getOwnPropertyDescriptor=function(e,t){var i;return i=Object.getOwnPropertyDescriptor(e,t)},ClassTool.getOwnPropertyNames=function(e){var t;return t=Object.getOwnPropertyNames(e)},ClassTool.getClassName=function(e){return"function"==typeof e?e.name:e.constructor.name},ClassTool.getNodeClassAndName=function(e){if(!e)return"null";var t;return t=e.name?ClassTool.getClassName(e)+"("+e.name+")":ClassTool.getClassName(e)},ClassTool.getClassNameByClz=function(e){return e.name},ClassTool.getClassByName=function(className){var rst;return rst=eval(className)},ClassTool.createObjByName=function(e){var t;return new(t=ClassTool.getClassByName(e))},ClassTool}(),ColorTool=function(){function e(){this.red=NaN,this.green=NaN,this.blue=NaN}return __class(e,"laya.debug.tools.ColorTool"),e.toHexColor=function(e){if(0>e||isNaN(e))return null;for(var t=e.toString(16);t.length<6;)t="0"+t;return"#"+t},e.getRGBByRGBStr=function(e){"#"==e.charAt(0)&&(e=e.substr(1));var t,i=parseInt(e,16);8==e.length;return t=[(16711680&i)>>16,(65280&i)>>8,255&i]},e.getColorBit=function(e){var t;return t=Math.floor(e).toString(16),t=t.length>1?t:"0"+t},e.getRGBStr=function(t){return"#"+e.getColorBit(t[0])+e.getColorBit(t[1])+e.getColorBit(t[2])},e.traseHSB=function(e){console.log("hsb:",e[0],e[1],e[2])},e.rgb2hsb=function(e,t,i){var o=[e,t,i];o.sort(MathTools.sortNumSmallFirst);var n=o[2],s=o[0],a=n/255,r=0==n?0:(n-s)/n,l=0;return n==s?l=1:0==e&&0==t&&0==i||(n==e&&t>=i?l=60*(t-i)/(n-s)+0:n==e&&i>t?l=60*(t-i)/(n-s)+360:n==t?l=60*(i-e)/(n-s)+120:n==i&&(l=60*(e-t)/(n-s)+240)),[l,r,a]},e.hsb2rgb=function(e,t,i){var o=0,n=0,s=0,a=Math.floor(e/60%6),r=e/60-a,l=i*(1-t),h=i*(1-r*t),c=i*(1-(1-r)*t);switch(a){case 0:o=i,n=c,s=l;break;case 1:o=h,n=i,s=l;break;case 2:o=l,n=i,s=c;break;case 3:o=l,n=h,s=i;break;case 4:o=c,n=l,s=i;break;case 5:o=i,n=l,s=h}return[Math.floor(255*o),Math.floor(255*n),Math.floor(255*s)]},e}(),CommonTools=function(){function e(){}return __class(e,"laya.debug.tools.CommonTools"),e.bind=function(e,t){var i;return i=e.bind(t)},e.insertP=function(t,i,o,n,s,a){var r;r=new Sprite,t.parent.addChild(r),r.x=i,r.y=o,r.scaleX=n,r.scaleY=s,r.rotation=a,r.addChild(t),e.count++,r.name="insertP:"+e.count},e.insertChild=function(e,t,i,o,n,s,a){void 0===a&&(a="#ff00ff");var r;return r=new Sprite,e.addChild(r),r.x=t,r.y=i,r.scaleX=o,r.scaleY=n,r.rotation=s,r.graphics.drawRect(0,0,20,20,a),r.name="child:"+e.numChildren,r},e.count=0,e}(),CountTool=function(){function e(){this.data={},this.preO={},this.changeO={},this.count=0}__class(e,"laya.debug.tools.CountTool");var t=e.prototype;return t.reset=function(){this.data={},this.count=0},t.add=function(e,t){void 0===t&&(t=1),this.count++,this.data.hasOwnProperty(e)||(this.data[e]=0),this.data[e]=this.data[e]+t},t.getKeyCount=function(e){return this.data.hasOwnProperty(e)||(this.data[e]=0),this.data[e]},t.getKeyChange=function(e){return this.changeO[e]?this.changeO[e]:0},t.record=function(){var e;for(e in this.changeO)this.changeO[e]=0;for(e in this.data)this.preO[e]||(this.preO[e]=0),this.changeO[e]=this.data[e]-this.preO[e],this.preO[e]=this.data[e]},t.getCount=function(e){var t,i=0;for(t in e)i+=e[t];return i},t.traceSelf=function(e){e||(e=this.data);var t=0;return t=this.getCount(e),console.log("total:"+t),"total:"+t+"\n"+TraceTool.traceObj(e)},t.traceSelfR=function(e){e||(e=this.data);var t=0;return t=this.getCount(e),console.log("total:"+t),"total:"+t+"\n"+TraceTool.traceObjR(e)},e}(),DebugExport=function(){function e(){}return __class(e,"laya.debug.tools.DebugExport"),e["export"]=function(){var t;t=window;var i;for(i in e._exportsDic)t[i]=e._exportsDic[i]},__static(e,["_exportsDic",function(){return this._exportsDic={DebugTool:DebugTool,Watcher:Watcher}}]),e}(),DifferTool=function(){function e(e,t){this.autoTrace=!0,this.sign="",this.obj=null,void 0===e&&(e=""),void 0===t&&(t=!0),this.sign=e,this.autoTrace=t}__class(e,"laya.debug.tools.DifferTool");var t=e.prototype;return t.update=function(e,t){t&&console.log(t);var i=ObjectTools.copyObj(e);this.obj||(this.obj={});var o;return o=ObjectTools.differ(this.obj,i),this.obj=i,this.autoTrace&&(console.log(this.sign+" differ:"),ObjectTools.traceDifferObj(o)),o},e.differ=function(t,i,o){e._differO[t]||(e._differO[t]=new e(t,!0));var n;return n=e._differO[t],n.update(i,o)},e._differO={},e}(),DisController=function(){function e(){this.arrowAxis=null,this._target=null,this.recInfo=null,e.init(),this.arrowAxis=new Axis,this.arrowAxis.mouseEnabled=!0}__class(e,"laya.debug.tools.DisController");var t=e.prototype;return t.switchType=function(){this.arrowAxis.switchType()},t.updateMe=function(){this._target&&(this.recInfo=RecInfo.getGlobalRecInfo(this._target,0,0,1,0,0,1),console.log("rotation:",this.recInfo.rotation),console.log("pos:",this.recInfo.x,this.recInfo.y),console.log("scale:",this.recInfo.width,this.recInfo.height),this.arrowAxis.x=this.recInfo.x,this.arrowAxis.y=this.recInfo.y,this.arrowAxis.rotation=this.recInfo.rotation,this.arrowAxis.yAxis.rotation=this.recInfo.rotationV-this.recInfo.rotation)},__getset(0,t,"target",function(){return this._target},function(t){this._target=t,t?(e._container.addChild(this.arrowAxis),Laya.timer.loop(100,this,this.updateMe)):(this.arrowAxis.removeSelf(),Laya.timer.clear(this,this.updateMe)),this.arrowAxis.target=t,this.updateMe()}),__getset(0,t,"type",function(){return this.arrowAxis.type},function(e){this.arrowAxis.type=e}),e.init=function(){return e._container?void DisControlTool.setTop(e._container):(e._container=new Sprite,e._container.mouseEnabled=!0,void Laya.stage.addChild(e._container))},e._container=null,__static(e,["I",function(){return this.I=new e}]),e}(),DisControlTool=function(){function e(){}return __class(e,"laya.debug.tools.DisControlTool"),e.getObjectsUnderPoint=function(t,i,o,n,s){if(n=n?n:[],null!=s&&!s(t))return n;if(t.getBounds().contains(i,o)){n.push(t);var a=new Point;a.setTo(i,o),a=t.fromParentPoint(a),i=a.x,o=a.y;for(var r=t._childs.length-1;r>-1;r--){var l=t._childs[r];l instanceof laya.display.Sprite&&e.getObjectsUnderPoint(l,i,o,n,s)}}return n},e.getObjectsUnderGlobalPoint=function(t,i){var o=new Point;return o.setTo(Laya.stage.mouseX,Laya.stage.mouseY),t.parent&&(o=t.parent.globalToLocal(o)),e.getObjectsUnderPoint(t,o.x,o.y,null,i)},e.findFirstObjectsUnderGlobalPoint=function(){var t;if(t=e.getObjectsUnderGlobalPoint(Laya.stage),!t)return null;var i,o=0,n=0;for(n=t.length,o=n-1;o>=0;o--)if(i=t[o],i&&i.numChildren<1)return i;return i},e.visibleAndEnableObjFun=function(e){return e.visible&&e.mouseEnabled},e.visibleObjFun=function(e){return e.visible},e.getMousePoint=function(e){var t=new Point;return t.setTo(Laya.stage.mouseX,Laya.stage.mouseY),t=e.globalToLocal(t)},e.isChildE=function(e,t){if(!e)return!1;for(;t;){if(t.parent==e)return!0;t=t.parent}return!1},e.isInTree=function(t,i){return t==i||e.isChildE(t,i)},e.setTop=function(e){if(e&&e.parent){var t;t=e.parent,t.setChildIndex(e,t.numChildren-1)}},e.clearItemRelativeInfo=function(e){var t="NaN";e.getLayout().left=t,e.getLayout().right=t,e.getLayout().top=t,e.getLayout().bottom=t},e.swap=function(e,t){if(e!=t){var i=0;i=e.parent.getChildIndex(e);var o=0;o=t.parent.getChildIndex(t);var n;n=t.parent,e.parent.addChildAt(t,i),n.addChildAt(e,o)}},e.insertToTarParent=function(t,i,o){void 0===o&&(o=!1);var n,s=0;t&&(n=t.parent,n&&(s=n.getChildIndex(t),o&&s++,e.insertToParent(n,i,s)))},e.insertToParent=function(t,i,o){if(void 0===o&&(o=-1),t){0>o&&(o=t.numChildren);var n=0,s=0;for(s=i.length,n=0;s>n;n++)e.transParent(i[n],t),t.addChildAt(i[n],o)}},e.transParent=function(e,t){if(e&&t&&e.parent){var i;i=e.parent;var o;o=new Point(e.x,e.y),o=i.localToGlobal(o),o=t.globalToLocal(o),e.pos(o.x,o.y)}},e.transPoint=function(e,t,i){return i=e.localToGlobal(i),i=t.globalToLocal(i)},e.removeItems=function(e){var t=0,i=0;for(i=e.length,t=0;i>t;t++)e[t].removeSelf()},e.addItems=function(e,t){var i=0,o=0;for(o=e.length,i=0;o>i;i++)t.addChild(e[i])},e.getAllChild=function(e){if(!e)return[];var t=0,i=0,o=[];for(i=e.numChildren,t=0;i>t;t++)o.push(e.getChildAt(t));return o},e.upDis=function(e){if(e&&e.parent){var t;t=e.parent;var i=0;i=t.getChildIndex(e)+1,i>=t.numChildren&&(i=t.numChildren-1),console.log("setChildIndex:"+i),t.setChildIndex(e,i)}},e.downDis=function(e){if(e&&e.parent){var t;t=e.parent;var i=0;i=t.getChildIndex(e)-1,0>i&&(i=0),console.log("setChildIndex:"+i),t.setChildIndex(e,i)}},e.setResizeAbleEx=function(e){var t;t=e.getChildByName("resizeBtn"),t&&SimpleResizer.setResizeAble(t,e)},e.setResizeAble=function(t){t.on("click",null,e.resizeHandler,[t])},e.resizeHandler=function(e){DisResizer.setUp(e)},e.setDragingItem=function(t,i){t.on("mousedown",null,e.dragingHandler,[i]),i.on("dragend",null,e.dragingEnd,[i])},e.dragingHandler=function(e){e&&e.startDrag()},e.dragingEnd=function(t){e.intFyDisPos(t),console.log(t.x,t.y)},e.showToStage=function(t,i,o){void 0===i&&(i=0),void 0===o&&(o=0);var n=t.getBounds();t.x=Laya.stage.mouseX+i,t.y=Laya.stage.mouseY+o,t.x+n.width>Laya.stage.width&&(t.x-=n.width+i),t.y+n.height>Laya.stage.height&&(t.y-=n.height+o),e.intFyDisPos(t)},e.intFyDisPos=function(e){e&&(e.x=Math.round(e.x),e.y=Math.round(e.y))},e.showOnly=function(e,t){var i=0,o=0;for(o=e.length,i=0;o>i;i++)e[i].visible=e[i]==t},e.showOnlyByIndex=function(t,i){e.showOnly(t,t[i])},e.addOnly=function(e,t,i){var o=0,n=0;for(n=e.length,o=0;n>o;o++)e[o]!=t?e[o].removeSelf():i.addChild(e[o])},e.addOnlyByIndex=function(t,i,o){e.addOnly(t,t[i],o)},__static(e,["tempP",function(){return this.tempP=new Point}]),e}(),DisEditor=function(){function e(){this.tar=null,this.rec=new Sprite,this.rootContainer=new Sprite}__class(e,"laya.debug.tools.DisEditor");var t=e.prototype;return t.setTarget=function(e){this.tar=e;var t;t=this.rec.graphics,t.clear();var i;i=this.tar.getSelfBounds(),t.drawRect(i.x,i.y,i.width,i.height,null,"#00ff00"),this.createSameDisChain(),Laya.stage.addChild(this.rootContainer)},t.createSameDisChain=function(){var e,t,i;for(i=this.rec,e=this.tar;e&&e!=Laya.stage;)t=new Sprite,t.addChild(i),t.x=e.x,t.y=e.y,t.scaleX=e.scaleX,t.scaleY=e.scaleY,t.rotation=e.rotation,t.scrollRect=e.scrollRect,i=t,e=e.parent;this.rootContainer.removeChildren(),this.rootContainer.addChild(i)},e}(),DisplayHook=function(){function e(){this.mouseX=NaN,this.mouseY=NaN,this._stage=null,this._target=null,this.isGetting=!1,this._matrix=new Matrix,this._point=new Point,this._rect=new Rectangle,this._event=Event.EMPTY,this._stage=Laya.stage,this.init(Render.context.canvas)}__class(e,"laya.debug.tools.DisplayHook");var t=e.prototype;return t.init=function(t){function i(e,t){n._event._stoped=!1,n._event.nativeEvent=t||e,n._target=null,e.offsetX?(n.mouseX=e.offsetX,n.mouseY=e.offsetY):(n.mouseX=e.clientX-Laya.stage.offset.x,n.mouseY=e.clientY-Laya.stage.offset.y)}var o=this;Browser.window.navigator.msPointerEnabled&&(t.style["-ms-content-zooming"]="none",t.style["-ms-touch-action"]="none");var n=this;Browser.document.addEventListener("mousedown",function(t){o._event._stoped=!1,e.isFirst=!0,n.check(n._stage,t.offsetX,t.offsetY,n.onMouseDown,!0,!1)},!0),Browser.document.addEventListener("touchstart",function(t){o._event._stoped=!1,e.isFirst=!0;for(var s=t.changedTouches,a=0,r=s.length;r>a;a++){var l=s[a];i(l,t),n.check(n._stage,n.mouseX,n.mouseY,n.onMouseDown,!0,!1)}},!0)},t.onMouseMove=function(e,t){this.sendEvent(e,"mousemove")},t.onMouseUp=function(e,t){t&&this.sendEvent(e,"mouseup")},t.onMouseDown=function(e,t){t&&(e.$_MOUSEDOWN=!0,this.sendEvent(e,"mousedown"))},t.sendEvent=function(e,t){this._event._stoped||(e.event(t,this._event.setTo(t,e,e)),"mouseup"===t&&e.$_MOUSEDOWN&&(e.$_MOUSEDOWN=!1,e.event("click",this._event.setTo("click",e,e))))},t.selectDisUnderMouse=function(){e.isFirst=!0,this.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null,!0,!1),SelectInfosView.I.setSelectTarget(DebugTool.target)},t.getDisUnderMouse=function(){return this.isGetting=!0,e.isFirst=!0,DebugTool.target=null,this.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null,!0,!1),this.isGetting=!1,DebugTool.target},t.check=function(t,i,o,n,s,a){if(t==DebugTool.debugLayer)return!1;if(t==DebugInfoLayer.I)return!1;if(this.isGetting&&t==DebugInfoLayer.I)return!1;if(!t.visible||t.getSelfBounds().width<=0)return!1;var r=!1;if(a=!0){var l=!1;if(s&&(this._rect=t.getBounds(),r=this._rect.contains(i,o),this._point.setTo(i,o),t.fromParentPoint(this._point),i=this._point.x,o=this._point.y),r){for(var h=!1,c=t._childs.length-1;c>-1;c--){var u=t._childs[c];if(h=this.check(u,i,o,n,s,!0))break}l=t.getGraphicBounds().contains(i,o),r=h||l,r&&!h&&e.isFirst&&(e.isFirst=!1,t instanceof laya.debug.tools.debugUI.DButton||(DebugTool.target=t,this.isGetting||(DebugTool.autoWork(),Notice.notify("ItemClicked",t))))}}return r},e.initMe=function(){e.instance||(e.instance=new e)},e.ITEM_CLICKED="ItemClicked",e.instance=null,e.isFirst=!1,e}(),DisPool=function(){function e(){}return __class(e,"laya.debug.tools.DisPool"),e.getDis=function(t){var i;i=ClassTool.getClassNameByClz(t),e._objDic[i]||(e._objDic[i]=[]);var o;o=e._objDic[i];var n=0,s=0;for(s=o.length,n=0;s>n;n++)if(!o[n].parent)return o[n];return o.push(new t),o[o.length-1]},e._objDic={},e}(),DTrace=function(){function e(){}return __class(e,"laya.debug.tools.DTrace"),e.getArgArr=function(e){var t;t=[];var i=0,o=e.length;for(i=0;o>i;i++)t.push(e[i]);return t},e.dTrace=function(t){var i=arguments;i=e.getArgArr(i),i.push(TraceTool.getCallLoc(2)),console.log.apply(console,i);var o;o=i.join(" ")},e.timeStart=function(e){console.time(e)},e.timeEnd=function(e){console.timeEnd(e)},e.traceTable=function(e){console.table(e)},e}(),ClassCreateHook=function(){function e(){this.createInfo={}}__class(e,"laya.debug.tools.enginehook.ClassCreateHook");var t=e.prototype;return t.hookClass=function(e){var t=this,i=function(i){t.classCreated(i,e)};FunHook.hook(e,"call",i)},t.classCreated=function(t,i){var o;o=ClassTool.getNodeClassAndName(t);var n,s=0;for(n=t;n&&n!=i;)n=n.__super,s++;e.I.createInfo[o]||(e.I.createInfo[o]=0),e.I.createInfo[o]=e.I.createInfo[o]+1,RunProfile.run(o,s+6)},t.getClassCreateInfo=function(e){var t;return t=ClassTool.getClassName(e),RunProfile.getRunInfo(t)},__static(e,["I",function(){return this.I=new e}]),e}(),FunctionTimeHook=function(){function e(){}return __class(e,"laya.debug.tools.enginehook.FunctionTimeHook"),e.hookFun=function(t,i){if(t&&!t.timeHooked){var o;e.HookID++,o=ClassTool.getNodeClassAndName(t)+"."+i+"():"+e.HookID;var n=function(t){e.funBegin(o)},s=function(t){e.funEnd(o)};t.timeHooked=!0,FunHook.hook(t,i,n,s)}},e.funBegin=function(t){e.funPre[t]=Browser.now()},e.funEnd=function(t){e.funPre[t]||(e.funPre[t]=0),e.counter.add(t,Browser.now()-e.funPre[t])},e.fresh=function(){e.funEnd("TotalSign"),e.counter.record(),e.funBegin("TotalSign")},e.HookID=1,e.funPre={},e.TotalSign="TotalSign",__static(e,["counter",function(){return this.counter=new CountTool}]),e}(),RenderSpriteHook=function(){function e(){}__class(e,"laya.debug.tools.enginehook.RenderSpriteHook");var t=e.prototype;return t.createRenderSprite=function(t,i){var o;return o=new RenderSprite(t,i),8==t&&(o._oldCanvas=o._fun,o._fun=e.I._canvas),o},t._canvas=function(e,t,i,o){if(SpriteRenderForVisibleAnalyse.allowRendering){var n=e._$P.cacheCanvas,s=this._next;if(!n||SpriteRenderForVisibleAnalyse.isVisibleTesting)return void s._fun.call(s,e,t,i,o);var a;a=Browser.now();var r=n.ctx,l=e._needRepaint()||!r;this._oldCanvas(e,t,i,o),Config.showCanvasMark,l?CacheAnalyser.I.reCacheCanvas(e,Browser.now()-a):CacheAnalyser.I.renderCanvas(e,Browser.now()-a)}},e.init=function(){e.I=new e,RunDriver.createRenderSprite=e.I.createRenderSprite},e.IMAGE=1,e.FILTERS=2,e.ALPHA=4,e.TRANSFORM=8,e.CANVAS=16,e.BLEND=32,e.CLIP=64,e.STYLE=128,e.GRAPHICS=256,e.CUSTOM=512,e.ENABLERENDERMERGE=1024,e.CHILDS=2048,e.INIT=69905,e.renders=[],e.I=null,e}(),SpriteRenderForVisibleAnalyse=function(){function e(){this._repaint=1,this._renderType=1,this._x=0,this._y=0,this.target=null,this.isTargetRenderd=!1,this.preFun=null,this._next=null,this.pgraphic=RenderSprite.prototype._graphics,this.pimage=RenderSprite.prototype._image,this.pimage2=RenderSprite.prototype._image2}__class(e,"laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse");var t=e.prototype;return t.setRenderHook=function(){Sprite.prototype.render=e.I.render},t.render=function(t,i,o){var n;if(n=this,!DebugInfoLayer.I.isDebugItem(n))if(n==laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.I.target&&(laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering=!0,laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.I.isTargetRenderd=!0,CanvasTools.clearCanvas(e.mainCanvas)),RenderSprite.renders[this._renderType]._fun(this,t,i+this._x,o+this._y),n==laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.I.target)e.tarRec=CanvasTools.getCanvasDisRec(laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.mainCanvas),console.log("rec",e.tarRec.toString()),e.tarRec.width>0&&e.tarRec.height>0?(e.isTarRecOK=!0,e.preImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec),e.tarImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec)):console.log("tarRec Not OK:",e.tarRec);else if(e.isTarRecOK){e.tImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec);var s=NaN;s=CanvasTools.getDifferRate(e.preImageData,e.tImageData),e.preImageData=e.tImageData,s>0&&VisibleAnalyser.addCoverNode(n,s)}},t.analyseNode=function(t){VisibleAnalyser.resetCoverList(),Sprite.prototype.render!=e.I.render&&(this.preFun=Sprite.prototype.render),this.target=t,Sprite.prototype.render=this.render,e.tarCanvas||(e.tarCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height)),e.mainCanvas||(e.mainCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height)),this.isTargetRenderd=!1,e.isVisibleTesting=!0,e.allowRendering=!1,CanvasTools.clearCanvas(e.mainCanvas),CanvasTools.clearCanvas(e.tarCanvas),e.isTarRecOK=!1;var i=new RenderContext(e.mainCanvas.width,e.mainCanvas.height,e.mainCanvas);e.mainCanvas=i.canvas,this.render.call(Laya.stage,i,0,0),e.isTarRecOK?e.coverRate=CanvasTools.getDifferRate(e.preImageData,e.tarImageData):e.coverRate=0,VisibleAnalyser.coverRate=e.coverRate,VisibleAnalyser.isTarRecOK=e.isTarRecOK,console.log("coverRate:",e.coverRate),this.isTargetRenderd=!1,e.isVisibleTesting=!1,e.allowRendering=!0,Sprite.prototype.render=this.preFun},t.noRenderMode=function(){},t.normalMode=function(){RenderSprite.prototype._graphics=this.pgraphic,RenderSprite.prototype._image=this.pimage,RenderSprite.prototype._image2=this.pimage2},t.inits=function(){this.noRenderMode()},t.m_graphics=function(e,t,i,o){if(laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){var n=e._style._tf;e._graphics&&e._graphics._render(e,t,i-n.translateX,o-n.translateY)}var s=this._next;s._fun.call(s,e,t,i,o)},t.m_image=function(e,t,i,o){if(laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){var n=e._style;t.ctx.drawTexture2(i,o,n._tf.translateX,n._tf.translateY,e.transform,n.alpha,n.blendMode,e._graphics._one)}},t.m_image2=function(e,t,i,o){if(laya.debug.tools.enginehook.SpriteRenderForVisibleAnalyse.allowRendering){var n=e._style._tf;t.ctx.drawTexture2(i,o,n.translateX,n.translateY,e.transform,1,null,e._graphics._one)}},e.tarCanvas=null,e.mainCanvas=null,e.preImageData=null,e.tImageData=null,e.tarImageData=null,e.tarRec=null,e.isTarRecOK=!1,e.isVisibleTesting=!1,e.allowRendering=!0,e.coverRate=NaN,__static(e,["I",function(){return this.I=new e}]),e}(),SpriteRenderHook=function(){function e(){this._repaint=1,this._renderType=1,this._x=0,this._y=0}__class(e,"laya.debug.tools.enginehook.SpriteRenderHook");var t=e.prototype;return t.render=function(e,t,i){this==Laya.stage&&CacheAnalyser.renderLoopBegin();var o=0;o=Browser.now(),Stat.spriteCount++,RenderSprite.renders[this._renderType]._fun(this,e,t+this._x,i+this._y),this._repaint=0,RenderAnalyser.I.render(this,Browser.now()-o)},e.init=function(){e.I=new e,e.setRenderHook()},e.setRenderHook=function(){Sprite.prototype.render=e.I.render},e.I=null,e}(),Observer=function(){function e(){}return __class(e,"laya.debug.tools.exp.Observer"),e.observe=function(e,t){Object.observe(e,t)},e.unobserve=function(e,t){Object.unobserve(e,t)},e.observeDiffer=function(t,i,o){void 0===o&&(o="obDiffer");var n=function(){DifferTool.differ(i,t,o)};e.observe(t,n)},e}(),Watch=function(){function e(){}return __class(e,"laya.debug.tools.exp.Watch"),e.watch=function(e,t,i){e.watch(t,i)},e.unwatch=function(e,t,i){e.unwatch(t,i)},e}(),FilterTool=function(){function e(){}return __class(e,"laya.debug.tools.FilterTool"),e.getArrByFilter=function(e,t){var i=0,o=e.length,n=[];for(i=0;o>i;i++)t(e[i])&&n.push(e[i]);return n},e.getArr=function(e,t,i){var o=0,n=e.length,s=[];for(o=0;n>o;o++)e[o][t]==i&&s.push(e[o]);return s},e}(),FunHook=function(){function e(){}return __class(e,"laya.debug.tools.hook.FunHook"),e.hook=function(t,i,o,n){e.hookFuns(t,i,[o,t[i],n],1)},e.hookAllFun=function(t){var i,o;o=ClassTool.getOwnPropertyNames(t);for(i in o)i=o[i],e.special[i]||(console.log("try hook:",i),"function"==typeof t[i]&&(console.log("hook:",i),e.hookFuns(t,i,[e.getTraceMsg("call:"+i),t[i]],1)));t.__proto__?e.hookAllFun(t.__proto__):console.log("end:",t)},e.getTraceMsg=function(e){var t;return t=function(){console.log(e)}},e.hookFuns=function(e,t,i,o){void 0===o&&(o=-1);var n,s=e[t];n=function(e){var t,n=arguments,s=0,a=0;for(a=i.length,s=0;a>s;s++)i[s]&&(s==o?t=i[s].apply(this,n):i[s].apply(this,n));return t},n.pre=s,e[t]=n},e.removeHook=function(e,t){null!=e[t].pre&&(e[t]=e[t].pre)},e.debugHere=function(){},e.traceLoc=function(e,t){void 0===e&&(e=0),void 0===t&&(t=""),console.log(t,"fun loc:",TraceTool.getCallLoc(3+e))},e.getLocFun=function(t,i){void 0===t&&(t=0),void 0===i&&(i=""),t+=1;var o;return o=function(){e.traceLoc(t,i); +}},__static(e,["special",function(){return this.special={length:!0,name:!0,arguments:!0,caller:!0,prototype:!0,is:!0,isExtensible:!0,isFrozen:!0,isSealed:!0,preventExtensions:!0,seal:!0,unobserve:!0,apply:!0,call:!0,bind:!0,freeze:!0,unobserve:!0}}]),e}(),VarHook=function(){function e(){}return __class(e,"laya.debug.tools.hook.VarHook"),e.hookVar=function(e,t,i,o){i||(i=[]),o||(o=[]);var n,s=e,a=e[t];n=ClassTool.getOwnPropertyDescriptor(e,t);var r={},l=function(e){console.log("var hook set "+t+":",e),a=e},h=function(){return console.log("var hook get"+t+":",a),a};if(n)return r.set=l,r.get=h,r.enumerable=n.enumerable,i.push(r.set),o.push(r.get),FunHook.hookFuns(r,"set",i),FunHook.hookFuns(r,"get",o,o.length-1),void ClassTool.defineProperty(e,t,r);for(;!n&&e.__proto__;)e=e.__proto__,n=ClassTool.getOwnPropertyDescriptor(e,t);n&&(r.set=n.set?n.set:l,r.get=n.get?n.get:h,r.enumerable=n.enumerable,i.push(r.set),o.push(r.get),FunHook.hookFuns(r,"set",i),FunHook.hookFuns(r,"get",o,o.length-1),ClassTool.defineProperty(s,t,r)),n||(console.log("get des fail add directly"),r.set=l,r.get=h,i.push(r.set),o.push(r.get),FunHook.hookFuns(r,"set",i),FunHook.hookFuns(r,"get",o,o.length-1),ClassTool.defineProperty(e,t,r))},e.getLocFun=function(e,t){void 0===e&&(e=""),void 0===t&&(t=0),t+=1;var i;return i=function(){FunHook.traceLoc(t,e)}},e}(),IDTools=function(){function e(){this.tID=1}__class(e,"laya.debug.tools.IDTools");var t=e.prototype;return t.getID=function(){return this.tID++},e.getAID=function(){return e._ID.getID()},e.idObjE=function(t,i){return void 0===i&&(i="default"),t._M_id_?t:(i||(i="default"),e._idDic[i]||(e._idDic[i]=new e),t._M_id_=e._idDic[i].getAID(),t)},e.setObjID=function(e,t){return e._M_id_=t,e},e.idObj=function(t){return t._M_id_?t:(t._M_id_=e.getAID(),t)},e.getObjID=function(e){return e?e._M_id_:-1},e.idSign="_M_id_",__static(e,["_ID",function(){return this._ID=new e},"_idDic",function(){return this._idDic={"default":new e}}]),e}(),JsonTool=function(){function e(){}return __class(e,"laya.debug.tools.JsonTool"),e.getJsonString=function(t,i,o,n,s){void 0===i&&(i=!0),void 0===o&&(o="\n"),void 0===n&&(n=0),void 0===s&&(s=4);var a="";a=e.getEmptyStr(n*s);var r,l;l={};var h,c,u;u=[];for(h in t)u.push(h),c=t[h],e.singleLineKey[h]?l[h]=e.getValueStr(c,!0,o,n+1,s):l[h]=e.getValueStr(c,i,o,n+1,s);var f=0,d=0;d=u.length,u.sort(),u=u.reverse();var g;g=e.getEmptyStr((n+1)*s),i&&(o="",a="",g="");var p;for(p=[],f=0;d>f;f++)h=u[f],p.push(g+e.wrapValue(h)+":"+l[h]);return r="{"+o+p.join(","+o)+o+a+"}"},e.wrapValue=function(e,t){return void 0===t&&(t='"'),t+e+t},e.getArrStr=function(t,i,o,n,s){void 0===i&&(i=!0),void 0===o&&(o="\n"),void 0===n&&(n=0),void 0===s&&(s=4);var a,r=0,l=0;l=t.length;var h;for(h=[],r=0;l>r;r++)h.push(e.getValueStr(t[r],i,o,n+1,s));var c="";return c=e.getEmptyStr((n+1)*s),i&&(o="",c=""),a="["+o+c+h.join(","+o+c)+"]"},e.quote=function(t){return e.escapable.lastIndex=0,e.escapable.test(t)?'"'+t.replace(e.escapable,function(t){var i=e.meta[t];return"string"==typeof i?i:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'},e.getValueStr=function(t,i,o,n,s){void 0===i&&(i=!0),void 0===o&&(o="\n"),void 0===n&&(n=0),void 0===s&&(s=0);var a;return a="string"==typeof t?e.quote(t):null==t?"null":"number"==typeof t||"number"==typeof t&&Math.floor(t)==t||"boolean"==typeof t?t:t instanceof Array?e.getArrStr(t,i,o,n,s):"object"==typeof t?e.getJsonString(t,i,o,n,s):t},e.getEmptyStr=function(t){if(!e.emptyDic.hasOwnProperty(t)){var i=0,o=0;o=t;var n;for(n="",i=0;o>i;i++)n+=" ";e.emptyDic[t]=n}return e.emptyDic[t]},e.emptyDic={},__static(e,["singleLineKey",function(){return this.singleLineKey={props:!0}},"escapable",function(){return this.escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g},"meta",function(){return this.meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}}]),e}(),JSTools=function(){function e(){}return __class(e,"laya.debug.tools.JSTools"),e.showToBody=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0),Browser.document.body.appendChild(e);var o;o=e.style,o.position="absolute",o.top=i+"px",o.left=t+"px"},e.showToParent=function(e,t,i,o){void 0===t&&(t=0),void 0===i&&(i=0),o.appendChild(e);var n;n=e.style,n.position="absolute",n.top=i+"px",n.left=t+"px"},e.addToBody=function(e){Browser.document.body.appendChild(e)},e.setPos=function(e,t,i){var o;o=e.style,o.top=i+"px",o.left=t+"px"},e.setSize=function(e,t,i){var o;o=e.style,o.width=t+"px",o.height=i+"px"},e.setTransform=function(e,t){var i;i=e.style,i.transformOrigin=i.webkitTransformOrigin=i.msTransformOrigin=i.mozTransformOrigin=i.oTransformOrigin="0px 0px 0px",i.transform=i.webkitTransform=i.msTransform=i.mozTransform=i.oTransform="matrix("+t.toString()+")"},e.noMouseEvent=function(e){var t;t=e.style,t["pointer-events"]="none"},e.setMouseEnable=function(e,t){var i;i=e.style,i["pointer-events"]=t?"auto":"none"},e.setZIndex=function(e,t){var i;i=e.style,i["z-index"]=t},e.showAboveSprite=function(t,i,o,n){void 0===o&&(o=0),void 0===n&&(n=0);var s;s=new Point,s=i.localToGlobal(s),s.x+=o,s.y+=n,s.x+=Laya.stage.offset.x,s.y+=Laya.stage.offset.y,e.showToBody(t,s.x,s.y)},e.removeElement=function(e){Browser.removeElement(e)},e.isElementInDom=function(e){return e&&e.parentNode},e.getImageSpriteByFile=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var o;o=new FileReader,o.readAsDataURL(e);var n;return n=new Sprite,o.onload=function(e){var s;s=new Texture,s.load(o.result),n.graphics.drawTexture(s,0,0,t,i)},n},e.getPixelRatio=function(){if(e._pixelRatio>0)return e._pixelRatio;var t=Browser.createElement("canvas"),i=t.getContext("2d"),o=Browser.window.devicePixelRatio||1,n=i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1,s=o/n;return console.log("pixelRatioc:",s),e._pixelRatio=s,s},e._pixelRatio=-1,e}(),Layouter=function(){function e(){this.data=null,this._items=null,this.layoutFun=null,this._sX=0,this._width=0}__class(e,"laya.debug.tools.layout.Layouter");var t=e.prototype;return t.layout=function(){this.layoutFun(this._width,this._items,this.data,this._sX)},t.changed=function(){Laya.timer.callLater(this,this.layout)},t.calSize=function(){var e,t=0,i=0;e=this.items[0],this._sX=e.x;var o=NaN;for(o=this._sX+e.width,i=this.items.length,t=1;i>t;t++)e=this.items[t],this._sX>e.x&&(this._sX=e.x),or;r++)a=t[r],a.x=h,a.width=s,h+=n+s},e.getSameWidthLayout=function(t,i){var o;return o={},o.dWidth=i,e.getLayouter(t,o,laya.debug.tools.layout.LayoutFuns.sameWidth)},e.getLayouter=function(e,t,i){var o;return o=new Layouter,o.items=e,o.data=t,o.layoutFun=i,o},e.sameDis=function(t,i,o,n){void 0===n&&(n=0);var s=NaN;s=t;var a,r=0,l=0;for(l=i.length,e.prepareForLayoutWidth(t,i),r=0;l>r;r++)a=i[r],s-=a.width;i.length>1&&(s/=i.length-1);var h=NaN;for(h=n,l=i.length,r=0;l>r;r++)a=i[r],a.x=h,h+=s+a.width},e.getSameDisLayout=function(t,i){void 0===i&&(i=!1);var o;if(o={},i){var n=0,s=0;s=t.length;var a,r=NaN;for(r=0,n=0;s>n;n++)a=t[n],r+=a.width;for(r=a.x+a.width,n=0;s>n;n++)a=t[n],e.setItemRate(a,a.width/r)}return e.getLayouter(t,o,laya.debug.tools.layout.LayoutFuns.sameDis)},e.fullFill=function(e,t,i,o){void 0===o&&(o=0);var n=0,s=0;i&&(i.dL&&(n=i.dL),i.dR&&(s=i.dR));var a,r=0,l=0;for(l=t.length,r=0;l>r;r++)a=t[r],a.x=o+n,a.width=e-n-s},e.getFullFillLayout=function(t,i,o){void 0===i&&(i=0),void 0===o&&(o=0);var n;return n={},n.dL=i,n.dR=o,e.getLayouter(t,n,laya.debug.tools.layout.LayoutFuns.fullFill)},e.fixPos=function(e,t,i,o){void 0===o&&(o=0);var n=0,s=[],a=!1;i&&(i.dLen&&(n=i.dLen),i.poss&&(s=i.poss),i.isRate&&(a=i.isRate));var r,l=0,h=0;h=s.length;var c=NaN;c=o;var u,f=NaN;for(u=null,l=0;h>l;l++)r=t[l],f=o+s[l],a&&(f=o+s[l]*e),r.x=f,u&&(u.width=r.x-n-u.x),u=r;var d;d=t[t.length-1],d.width=o+e-n-d.x},e.getFixPos=function(t,i,o,n){void 0===i&&(i=0),void 0===o&&(o=!1);var s;s={};var a;a=e.getLayouter(t,s,e.fixPos);var r=0,l=0,h=NaN,c=NaN;if(h=a.x,c=a.width,!n){n=[],l=t.length;var u=NaN;for(r=0;l>r;r++)u=t[r].x-h,o&&(u/=c),n.push(u)}return s.dLen=i,s.poss=n,s.isRate=o,a},e.clearItemsRelativeInfo=function(t){var i=0,o=0;for(o=t.length,i=0;o>i;i++)e.clearItemRelativeInfo(t[i])},e.clearItemRelativeInfo=function(e){var t="NaN";e.getLayout().left=t,e.getLayout().right=t},e.prepareForLayoutWidth=function(t,i){var o=0,n=0;for(n=i.length,o=0;n>o;o++)e.prepareItemForLayoutWidth(t,i[o])},e.getSumWidth=function(e){var t=NaN;t=0;var i=0,o=0;for(o=e.length,i=0;o>i;i++)t+=e[i].width;return t},e.prepareItemForLayoutWidth=function(t,i){e.getItemRate(i)>0&&(i.width=t*e.getItemRate(i))},e.setItemRate=function(e,t){e.layoutRate=t},e.getItemRate=function(e){return e.layoutRate?e.layoutRate:-1},e.setItemFreeSize=function(e,t){void 0===t&&(t=!0),e.layoutFreeSize=t},e.isItemFreeSize=function(e){return e.layoutFreeSize},e.lockedDis=function(t,i,o,n){void 0===n&&(n=0);var s;s=o.dists;var a=NaN;a=o.sumDis;var r,l,h=NaN,c=0,u=0;e.prepareForLayoutWidth(t,i),h=e.getSumWidth(i);var f=NaN;f=t-a-h;var d;for(d=e.getFreeItem(i),d&&(d.width+=f),l=i[0],l.x=n,u=i.length,c=1;u>c;c++)r=i[c],r.x=l.x+l.width+s[c-1],l=r},e.getFreeItem=function(t){var i=0,o=0;for(o=t.length,i=0;o>i;i++)if(e.isItemFreeSize(t[i]))return t[i];return null},e.getLockedDis=function(t){var i;i={};var o,n,s,a=0,r=0,l=NaN;l=0;var h=NaN;for(s=t[0],o=[],r=t.length,a=1;r>a;a++)n=t[a],h=n.x-s.x-s.width,o.push(h),l+=h,s=n;return i.dists=o,i.sumDis=l,e.getLayouter(t,i,laya.debug.tools.layout.LayoutFuns.lockedDis)},e.RateSign="layoutRate",e.FreeSizeSign="layoutFreeSize",e}(),LayoutTools=function(){function e(){}return __class(e,"laya.debug.tools.LayoutTools"),e.layoutToXCount=function(e,t,i,o,n,s){void 0===t&&(t=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===n&&(n=0),void 0===s&&(s=0);var a,r=NaN,l=NaN,h=0,c=0,u=0,f=0;for(u=0,f=0,r=n,l=s,c=e.length,h=0;c>h;h++)a=e[h],a.x=r,a.y=l,a.height>f&&(f=a.height),u++,u>=t?(u%=t,a.y+=f+o,f=0):r+=a.width+i},e.layoutToWidth=function(e,t,i,o,n,s){var a,r=NaN,l=NaN,h=0,c=0;for(r=n,l=s,c=e.length,h=0;c>h;h++)a=e[h],r+a.width+i>t&&(r=n,l+=o+a.height),a.x=r,a.y=l,r+=i+a.width},e}(),MathTools=function(){function e(){}return __class(e,"laya.debug.tools.MathTools"),e.sortBigFirst=function(e,t){return e==t?0:t>e?1:-1},e.sortSmallFirst=function(e,t){return e==t?0:t>e?-1:1},e.sortNumBigFirst=function(e,t){return parseFloat(t)-parseFloat(e)},e.sortNumSmallFirst=function(e,t){return parseFloat(e)-parseFloat(t)},e.sortByKey=function(t,i,o){void 0===i&&(i=!1),void 0===o&&(o=!0);var n;return n=i?o?e.sortNumBigFirst:e.sortBigFirst:o?e.sortNumSmallFirst:e.sortSmallFirst,function(e,i){return n(e[t],i[t])}},e}(),MouseEventAnalyser=function(){function e(){}return __class(e,"laya.debug.tools.MouseEventAnalyser"),e.analyseNode=function(t){DebugTool.showDisBound(t,!0);var i;i=t,ObjectTools.clearObj(e.infoO),ObjectTools.clearObj(e.nodeO),ObjectTools.clearObj(e.hitO);var o;for(o=[];t;)IDTools.idObj(t),e.nodeO[IDTools.getObjID(t)]=t,o.push(t),t=t.parent;e.check(Laya.stage,Laya.stage.mouseX,Laya.stage.mouseY,null);var n;e.hitO[IDTools.getObjID(i)]?(console.log("can hit"),n="can hit"):(console.log("can't hit"),n="can't hit");var s=0,a=0;o=o.reverse(),a=o.length;var r;for(r=["[分析对象]:"+ClassTool.getNodeClassAndName(i)+":"+n],s=0;a>s;s++)t=o[s],e.hitO[IDTools.getObjID(t)]?(console.log("can hit:",ClassTool.getNodeClassAndName(t)),console.log("原因:",e.infoO[IDTools.getObjID(t)]),r.push("can hit: "+ClassTool.getNodeClassAndName(t)),r.push("原因: "+e.infoO[IDTools.getObjID(t)])):(console.log("can't hit:"+ClassTool.getNodeClassAndName(t)),console.log("原因:",e.infoO[IDTools.getObjID(t)]?e.infoO[IDTools.getObjID(t)]:"鼠标事件在父级已停止派发"),r.push("can't hit: "+ClassTool.getNodeClassAndName(t)),r.push("原因: "+(e.infoO[IDTools.getObjID(t)]?e.infoO[IDTools.getObjID(t)]:"鼠标事件在父级已停止派发")));var l;l=r.join("\n"),ToolPanel.I.showTxtInfo(l)},e.check=function(t,i,o,n){IDTools.idObj(t);var s=!1;s=e.nodeO[IDTools.getObjID(t)];var a=t.transform||e._matrix,r=t.pivotX,l=t.pivotY;if(0===r&&0===l)a.setTranslate(t.x,t.y);else if(a===e._matrix)a.setTranslate(t.x-r,t.y-l);else{var h=a.cos,c=a.sin;a.setTranslate(t.x-(r*h-l*c)*t.scaleX,t.y-(r*c+l*h)*t.scaleY)}a.invertTransformPoint(e._point.setTo(i,o)),a.setTranslate(0,0),i=e._point.x,o=e._point.y;var u=t.scrollRect;if(u){e._rect.setTo(0,0,u.width,u.height);var f=e._rect.contains(i,o);if(!f)return s&&(e.infoO[IDTools.getObjID(t)]="scrollRect没有包含鼠标"+e._rect.toString()+":"+i+","+o),!1}var d,g=0,p=0;d=t._childs,p=d.length;var w,v;for(v=null,g=0;p>g;g++)if(w=d[g],IDTools.idObj(w),e.nodeO[IDTools.getObjID(w)]){v=w;break}var y=!1;y=!!v;var m=!1;if(t.hitTestPrior&&!t.mouseThrough&&!e.hitTest(t,i,o))return e.infoO[IDTools.getObjID(t)]="hitTestPrior=true,宽高区域不包含鼠标::"+i+","+o+" size:"+t.width+","+t.height,!1;for(g=t._childs.length-1;g>-1;g--)if(w=t._childs[g],w==v&&(v.mouseEnabled||(e.infoO[IDTools.getObjID(v)]="mouseEnabled=false"),v.visible||(e.infoO[IDTools.getObjID(v)]="visible=false"),y=!1),w.mouseEnabled&&w.visible){if(m=e.check(w,i+(u?u.x:0),o+(u?u.y:0),n))return e.hitO[IDTools.getObjID(t)]=!0,e.infoO[IDTools.getObjID(t)]="子对象被击中",w==v?e.infoO[IDTools.getObjID(t)]="子对象被击中,击中对象在分析链中":(e.infoO[IDTools.getObjID(t)]="子对象被击中,击中对象不在分析链中",y&&(e.infoO[IDTools.getObjID(v)]="被兄弟节点挡住,兄弟节点信息:"+ClassTool.getNodeClassAndName(w)+","+w.getBounds().toString(),DebugTool.showDisBound(w,!1,"#ffff00"))),!0;w==v&&(y=!1)}var A=new Rectangle,b=!1;if(b=t.getGraphicBounds().contains(i,o),t.width>0&&t.height>0){var C=e._rect;t.mouseThrough?(f=b,A.copyFrom(t.getGraphicBounds())):(t.hitArea?C=t.hitArea:C.setTo(0,0,t.width,t.height),A.copyFrom(C),f=C.contains(i,o)),f&&(e.hitO[IDTools.getObjID(t)]=!0)}return f?e.infoO[IDTools.getObjID(t)]="自身区域被击中":b?e.infoO[IDTools.getObjID(t)]="子对象未包含鼠标,实际绘图区域包含鼠标,设置的宽高区域不包含鼠标::"+i+","+o+" hitRec:"+A.toString()+" graphicBounds:"+t.getGraphicBounds().toString()+",设置mouseThrough=true或将宽高设置到实际绘图区域可解决问题":e.infoO[IDTools.getObjID(t)]="子对象未包含鼠标,实际绘图区域不包含鼠标,设置的宽高区域不包含鼠标::"+i+","+o+" hitRec:"+A.toString()+" graphicBounds:"+t.getGraphicBounds().toString(),f},e.hitTest=function(t,i,o){var n=!1;if(t.width>0&&t.height>0||t.mouseThrough||t.hitArea){var s=e._rect;t.mouseThrough?n=t.getGraphicBounds().contains(i,o):(t.hitArea?s=t.hitArea:s.setTo(0,0,t.width,t.height),n=s.contains(i,o))}return n},e.infoO={},e.nodeO={},e.hitO={},__static(e,["_matrix",function(){return this._matrix=new Matrix},"_point",function(){return this._point=new Point},"_rect",function(){return this._rect=new Rectangle}]),e}(),ObjectTools=function(){function e(){}return __class(e,"laya.debug.tools.ObjectTools"),e.getFlatKey=function(t,i){return""==t?i:t+e.sign+i},e.flatObj=function(t,i,o){void 0===o&&(o=""),i=i?i:{};var n,s;for(n in t)"object"==typeof t[n]?e.flatObj(t[n],i,e.getFlatKey(o,n)):(s=t[n],i[e.getFlatKey(o,n)]=t[n]);return i},e.recoverObj=function(t){var i,o={};for(i in t)e.setKeyValue(o,i,t[i]);return o},e.differ=function(t,i){var o;t=e.flatObj(t),i=e.flatObj(i);var n={};for(o in t)i.hasOwnProperty(o)||(n[o]="被删除");for(o in i)i[o]!=t[o]&&(n[o]={pre:t[o],now:i[o]});return n},e.traceDifferObj=function(e){var t,i;for(t in e)"string"==typeof e[t]?console.log(t+":",e[t]):(i=e[t],console.log(t+":","now:",i.now,"pre:",i.pre))},e.setKeyValue=function(t,i,o){if(i.indexOf(e.sign)>=0){for(var n,s=i.split(e.sign);s.length>1;)if(n=s.shift(),t[n]||(t[n]={},console.log("addKeyObj:",n)),t=t[n],!t)return void console.log("wrong flatKey:",i);t[s.shift()]=o}else t[i]=o},e.clearObj=function(e){var t;for(t in e)delete e[t]},e.copyObjFast=function(e){var t;return t=laya.debug.tools.ObjectTools.getJsonString(e),laya.debug.tools.ObjectTools.getObj(t)},e.copyObj=function(t){if(t instanceof Array)return e.copyArr(t);var i,o={};for(i in t)t[i]instanceof Array?o[i]=e.copyArr(t[i]):"object"==typeof t[i]?o[i]=e.copyObj(t[i]):o[i]=t[i];return o},e.copyArr=function(t){var i;i=[];var o=0,n=0;for(n=t.length,o=0;n>o;o++)i.push(e.copyObj(t[o]));return i},e.concatArr=function(e,t){if(!t)return e;if(!e)return t;var i=0,o=t.length;for(i=0;o>i;i++)e.push(t[i]);return e},e.clearArr=function(e){return e?(e.length=0,e):e},e.removeFromArr=function(e,t){var i=0,o=0;for(o=e.length,i=0;o>i;i++)if(e[i]==t)return void e[i].splice(i,1)},e.setValueArr=function(t,i){return t||(t=[]),t.length=0,e.concatArr(t,i)},e.getFrom=function(e,t,i){var o=0;for(o=0;i>o;o++)e.push(t[o]);return e},e.getFromR=function(e,t,i){var o=0;for(o=0;i>o;o++)e.push(t.pop());return e},e.enableDisplayTree=function(e){for(;e;)e.mouseEnabled=!0,e=e.parent},e.getJsonString=function(e){var t;return t=JSON.stringify(e)},e.getObj=function(e){var t;return t=JSON.parse(e)},e.getKeyArr=function(e){var t,i;t=[];for(i in e)t.push(i);return t},e.getObjValues=function(e,t){var i,o=0,n=0;for(n=e.length,i=[],o=0;n>o;o++)i.push(e[o][t]);return i},e.hasKeys=function(e,t){var i=0,o=0;for(o=t.length,i=0;o>i;i++)if(!e.hasOwnProperty(t[i]))return!1;return!0},e.copyValueByArr=function(e,t,i){var o=0,n=i.length;for(o=0;n>o;o++)null!==t[i[o]]&&(e[i[o]]=t[i[o]])},e.insertValue=function(e,t){var i;for(i in t)e[i]=t[i]},e.replaceValue=function(t,i){var o;for(o in t)i.hasOwnProperty(t[o])&&(t[o]=i[t[o]]),"object"==typeof t[o]&&e.replaceValue(t[o],i)},e.setKeyValues=function(e,t,i){var o=0,n=0;for(n=e.length,o=0;n>o;o++)e[o][t]=i},e.findItemPos=function(e,t,i){var o=0,n=0;for(n=e.length,o=0;n>o;o++)if(e[o][t]==i)return o;return-1},e.setObjValue=function(e,t,i){return e[t]=i,e},e.setAutoTypeValue=function(t,i,o){return t.hasOwnProperty(i)&&e.isNumber(t[i])?t[i]=parseFloat(o):t[i]=o,t},e.getAutoValue=function(e){return parseFloat(e)==e?parseFloat(e):e},e.isNumber=function(e){return parseFloat(e)==e},e.isNaNS=function(e){return"NaN"==e.toString()},e.isNaN=function(e){return"number"==typeof e?!1:"string"!=typeof e||"NaN"==parseFloat(e).toString()||parseFloat(e)!=e},e.getStrTypedValue=function(t){return"false"==t?!1:"true"==t?!0:"null"==t?null:"undefined"==t?null:e.getAutoValue(t)},e.createKeyValueDic=function(e,t){var i;i={};var o=0,n=0;n=e.length;var s,a;for(o=0;n>o;o++)s=e[o],a=s[t],i[a]=s;return i},e.sign="_",e}(),ObjTimeCountTool=function(){function e(){this.timeDic={},this.resultDic={},this.countDic={},this.resultCountDic={},this.nodeDic={},this.resultNodeDic={}}__class(e,"laya.debug.tools.ObjTimeCountTool");var t=e.prototype;return t.addTime=function(e,t){IDTools.idObj(e);var i=0;i=IDTools.getObjID(e),this.timeDic.hasOwnProperty(i)||(this.timeDic[i]=0),this.timeDic[i]=this.timeDic[i]+t,this.countDic.hasOwnProperty(i)||(this.countDic[i]=0),this.countDic[i]=this.countDic[i]+1,this.nodeDic[i]=e},t.getTime=function(e){IDTools.idObj(e);var t=0;return t=IDTools.getObjID(e),this.resultDic[t]?this.resultDic[t]:0},t.getCount=function(e){IDTools.idObj(e);var t=0;return t=IDTools.getObjID(e),this.resultCountDic[t]},t.reset=function(){var e;for(e in this.timeDic)this.timeDic[e]=0,this.countDic[e]=0;ObjectTools.clearObj(this.nodeDic)},t.updates=function(){ObjectTools.clearObj(this.resultDic),ObjectTools.insertValue(this.resultDic,this.timeDic),ObjectTools.clearObj(this.resultCountDic),ObjectTools.insertValue(this.resultCountDic,this.countDic),ObjectTools.insertValue(this.resultNodeDic,this.nodeDic),this.reset()},e}(),RecInfo=function(){function e(){this.oX=0,this.oY=0,this.hX=1,this.hY=0,this.vX=0,this.vY=1}__class(e,"laya.debug.tools.RecInfo");var t=e.prototype;return t.initByPoints=function(e,t,i){this.oX=e.x,this.oY=e.y,this.hX=t.x,this.hY=t.y,this.vX=i.x,this.vY=i.y},__getset(0,t,"rotation",function(){return this.rotationRad/Math.PI*180}),__getset(0,t,"width",function(){return Math.sqrt((this.hX-this.oX)*(this.hX-this.oX)+(this.hY-this.oY)*(this.hY-this.oY))}),__getset(0,t,"x",function(){return this.oX}),__getset(0,t,"rotationRadV",function(){var e=this.vX-this.oX,t=this.vY-this.oY;return Math.atan2(t,e)}),__getset(0,t,"y",function(){return this.oY}),__getset(0,t,"rotationRad",function(){var e=this.hX-this.oX,t=this.hY-this.oY;return Math.atan2(t,e)}),__getset(0,t,"height",function(){return Math.sqrt((this.vX-this.oX)*(this.vX-this.oX)+(this.vY-this.oY)*(this.vY-this.oY))}),__getset(0,t,"rotationV",function(){return this.rotationRadV/Math.PI*180}),e.createByPoints=function(t,i,o){var n;return n=new e,n.initByPoints(t,i,o),n},e.getGlobalPoints=function(e,t,i){return e.localToGlobal(new Point(t,i))},e.getGlobalRecInfo=function(t,i,o,n,s,a,r){return void 0===i&&(i=0),void 0===o&&(o=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===r&&(r=1),e.createByPoints(e.getGlobalPoints(t,i,o),e.getGlobalPoints(t,n,s),e.getGlobalPoints(t,a,r))},e}(),RenderAnalyser=function(){function e(){this.timeDic={},this.resultDic={},this.countDic={},this.resultCountDic={},this.nodeDic={},this.isWorking=!1,this.working=!0}__class(e,"laya.debug.tools.RenderAnalyser");var t=e.prototype;return t.render=function(e,t){this.addTime(e,t)},t.addTime=function(e,t){IDTools.idObj(e);var i=0;i=IDTools.getObjID(e),this.timeDic.hasOwnProperty(i)||(this.timeDic[i]=0),this.timeDic[i]=this.timeDic[i]+t,this.countDic.hasOwnProperty(i)||(this.countDic[i]=0),this.countDic[i]=this.countDic[i]+1,this.nodeDic[i]=e},t.getTime=function(e){IDTools.idObj(e);var t=0;return t=IDTools.getObjID(e),this.resultDic[t]?this.resultDic[t]:0},t.getCount=function(e){IDTools.idObj(e);var t=0;return t=IDTools.getObjID(e),this.resultCountDic[t]},t.reset=function(){var e;for(e in this.timeDic)this.timeDic[e]=0,this.countDic[e]=0;ObjectTools.clearObj(this.nodeDic)},t.updates=function(){ObjectTools.clearObj(this.resultDic),ObjectTools.insertValue(this.resultDic,this.timeDic),ObjectTools.clearObj(this.resultCountDic),ObjectTools.insertValue(this.resultCountDic,this.countDic),this.reset()},__getset(0,t,"working",null,function(e){this.isWorking=e,e?Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.updates):Laya.timer.clear(this,this.updates)}),__static(e,["I",function(){return this.I=new e}]),e}(),DisResizer=function(){function e(){}return __class(e,"laya.debug.tools.resizer.DisResizer"),e.init=function(){e._up||(e._up=new AutoFillRec("T"),e._up.height=2,e._up.type=0,e._down=new AutoFillRec("T"),e._down.height=2,e._down.type=0,e._left=new AutoFillRec("R"),e._left.width=2,e._left.type=1,e._right=new AutoFillRec("R"),e._right.width=2,e._right.type=1,e._barList=[e._up,e._down,e._left,e._right],e.addEvent())},e.stageDown=function(t){var i;i=t.target,e._tar&&DisControlTool.isInTree(e._tar,i)||e.clear()},e.clear=function(){e._tar=null,Laya.stage.off("mouseup",null,e.stageDown),DisControlTool.removeItems(e._barList),e.clearDragEvents()},e.addEvent=function(){var t,i=0,o=0;for(o=e._barList.length,i=0;o>i;i++)t=e._barList[i],t.on("mousedown",null,e.barDown)},e.barDown=function(t){if(e.clearDragEvents(),e.tBar=t.target,e.tBar){var i;i=new Rectangle,0==e.tBar.type?(i.x=e.tBar.x,i.width=0,i.y=e.tBar.y-200,i.height=400):(i.x=e.tBar.x-200,i.width=400,i.y=0,i.height=0);var o;o={},o.area=i,e.tBar.record(),e.tBar.startDrag(i),e.tBar.on("dragmove",null,e.draging),e.tBar.on("dragend",null,e.dragEnd)}},e.draging=function(t){if(console.log("draging"),e.tBar&&e._tar){switch(e.tBar){case e._left:e._tar.x+=e.tBar.getDx(),e._tar.width-=e.tBar.getDx(),e._up.width-=e.tBar.getDx(),e._down.width-=e.tBar.getDx(),e._right.x-=e.tBar.getDx(),e.tBar.x-=e.tBar.getDx();break;case e._right:e._tar.width+=e.tBar.getDx(),e._up.width+=e.tBar.getDx(),e._down.width+=e.tBar.getDx();break;case e._up:e._tar.y+=e.tBar.getDy(),e._tar.height-=e.tBar.getDy(),e._right.height-=e.tBar.getDy(),e._left.height-=e.tBar.getDy(),e._down.y-=e.tBar.getDy(),e.tBar.y-=e.tBar.getDy();break;case e._down:e._tar.height+=e.tBar.getDy(),e._right.height+=e.tBar.getDy(),e._left.height+=e.tBar.getDy()}e.tBar.record()}},e.dragEnd=function(t){console.log("dragEnd"),e.clearDragEvents(),e.updates()},e.clearDragEvents=function(){e.tBar&&(e.tBar.off("dragmove",null,e.draging),e.tBar.off("dragend",null,e.dragEnd))},e.setUp=function(t,i){void 0===i&&(i=!1),i&&t==e._tar||(DisControlTool.removeItems(e._barList),(e._tar!=t||(e._tar=null,e.clearDragEvents(),i))&&(e._tar=t,e.updates(),DisControlTool.addItems(e._barList,t),Laya.stage.off("mouseup",null,e.stageDown),Laya.stage.on("mouseup",null,e.stageDown)))},e.updates=function(){var t;if(t=e._tar){var i;i=new Rectangle(0,0,t.width,t.height),e._up.x=i.x,e._up.y=i.y,e._up.width=i.width,e._down.x=i.x,e._down.y=i.y+i.height-2,e._down.width=i.width,e._left.x=i.x,e._left.y=i.y,e._left.height=i.height,e._right.x=i.x+i.width-2,e._right.y=i.y,e._right.height=i.height}},e.Side=2,e.Vertical=1,e.Horizon=0,e._up=null,e._down=null,e._left=null,e._right=null,e._barList=null,e._tar=null,e.barWidth=2,e.useGetBounds=!1,e.tBar=null,e}(),SimpleResizer=function(){function e(){}return __class(e,"laya.debug.tools.resizer.SimpleResizer"),e.setResizeAble=function(t,i,o,n){void 0===o&&(o=150),void 0===n&&(n=150),t.on("mousedown",null,e.onMouseDown,[i,o,n])},e.onMouseDown=function(t,i,o,n){if(e.clearEvents(),t){e.preMousePoint.setTo(Laya.stage.mouseX,Laya.stage.mouseY),e.preTarSize.setTo(t.width,t.height),e.preScale.setTo(1,1);var s;for(s=t;s&&s!=Laya.stage;)e.preScale.x*=s.scaleX,e.preScale.y*=s.scaleY,s=s.parent;Laya.stage.on("mouseup",null,e.onMouseMoveEnd),Laya.timer.loop(100,null,e.onMouseMoving,[t,i,o])}},e.onMouseMoving=function(t,i,o,n){var s=(Laya.stage.mouseX-e.preMousePoint.x)/e.preScale.x+e.preTarSize.x,a=(Laya.stage.mouseY-e.preMousePoint.y)/e.preScale.y+e.preTarSize.y;t.width=s>i?s:i,t.height=a>o?a:o},e.onMouseMoveEnd=function(t){e.clearEvents()},e.clearEvents=function(){Laya.timer.clear(null,e.onMouseMoving),Laya.stage.off("mouseup",null,e.onMouseMoveEnd)},__static(e,["preMousePoint",function(){return this.preMousePoint=new Point},"preTarSize",function(){return this.preTarSize=new Point},"preScale",function(){return this.preScale=new Point}]),e}(),ResTools=function(){function e(){}return __class(e,"laya.debug.tools.ResTools"),e.getCachedResList=function(){return Render.isWebGL?e.getWebGlResList():e.getCanvasResList()},e.getWebGlResList=function(){var e;e=[];var t,i;i=ResourceManager.currentResourceManager._resources;for(var o=0;oo;o++)e();DTrace.timeEnd(i)},e.infoDic={},e._runShowDic={},e}(),SingleTool=function(){function e(){this._objDic={}}__class(e,"laya.debug.tools.SingleTool");var t=e.prototype;return t.getArr=function(e){var t;return t=this.getTypeDic("Array"),t[e]||(t[e]=[]),t[e]},t.getObject=function(e){var t;return t=this.getTypeDic("Object"),t[e]||(t[e]={}),t[e]},t.getByClass=function(e,t,i){var o;return o=this.getTypeDic(t),o[e]||(o[e]=new i),o[e]},t.getTypeDic=function(e){return this._objDic[e]||(this._objDic[e]={}),this._objDic[e]},__static(e,["I",function(){return this.I=new e}]),e}(),StringTool=function(){function e(){}return __class(e,"laya.debug.tools.StringTool"),e.toUpCase=function(e){return e.toUpperCase()},e.toLowCase=function(e){return e.toLowerCase()},e.toUpHead=function(e){var t;return e.length<=1?e.toUpperCase():t=e.charAt(0).toUpperCase()+e.substr(1)},e.toLowHead=function(e){var t;return e.length<=1?e.toLowerCase():t=e.charAt(0).toLowerCase()+e.substr(1)},e.packageToFolderPath=function(e){var t;return t=e.replace(".","/")},e.insert=function(e,t,i){return e.substring(0,i)+t+e.substr(i)},e.insertAfter=function(t,i,o,n){void 0===n&&(n=!1);var s=0;return s=n?t.lastIndexOf(o):t.indexOf(o),s>=0?e.insert(t,i,s+o.length):t},e.insertBefore=function(t,i,o,n){void 0===n&&(n=!1);var s=0;return s=n?t.lastIndexOf(o):t.indexOf(o),s>=0?e.insert(t,i,s):t},e.insertParamToFun=function(t,i){var o;o=e.getParamArr(t);var n;return n=i.join(","),o.length>0&&(n=","+n),e.insertBefore(t,n,")",!0)},e.trim=function(t,i){i||(i=[" ","\r","\n"," ",String.fromCharCode(65279)]);var o,n=0,s=0;for(o=t,s=i.length,n=0;s>n;n++)o=e.getReplace(o,i[n],"");return o},e.isEmpty=function(t){return t.length<1?!0:e.emptyStrDic.hasOwnProperty(t)},e.trimLeft=function(t){var i=0;i=0;var o=0;for(o=t.length;e.isEmpty(t.charAt(i))&&o>i;)i++;return o>i?t.substr(i):""},e.trimRight=function(t){var i=0;for(i=t.length-1;e.isEmpty(t.charAt(i))&&i>=0;)i--;var o;return o=t.substring(0,i),i>=0?t.substring(0,i+1):""},e.trimSide=function(t){var i;return i=e.trimLeft(t),i=e.trimRight(i)},e.isOkFileName=function(t){if(""==laya.debug.tools.StringTool.trimSide(t))return!1;var i=0,o=0;for(o=t.length,i=0;o>i;i++)if(e.specialChars[t.charAt(i)])return!1;return!0},e.trimButEmpty=function(t){return e.trim(t,["\r","\n"," "])},e.removeEmptyStr=function(t){var i=0;i=t.length-1;var o;for(i=i;i>=0;i--)o=t[i],o=laya.debug.tools.StringTool.trimSide(o),e.isEmpty(o)?t.splice(i,1):t[i]=o;return t},e.ifNoAddToTail=function(e,t){return e.indexOf(t)>=0?e:e+t},e.trimEmptyLine=function(t){var i,o,n=0;for(i=t.split("\n"),n=i.length-1;n>=0;n--)o=i[n],e.isEmptyLine(o)&&i.splice(n,1);return i.join("\n")},e.isEmptyLine=function(e){return e=laya.debug.tools.StringTool.trim(e),""==e},e.removeCommentLine=function(t){var i;i=[];var o,n,s=0;s=0;var a=0,r=0;for(a=t.length;a>s;){if(n=o=t[s],r=o.indexOf("/**"),r>=0)for(n=o.substring(0,r-1),e.addIfNotEmpty(i,n);a>s;){if(o=t[s],r=o.indexOf("*/"),r>=0){n=o.substring(r+2),e.addIfNotEmpty(i,n);break}s++}else o.indexOf("//")>=0?0==laya.debug.tools.StringTool.trim(o).indexOf("//")||e.addIfNotEmpty(i,n):e.addIfNotEmpty(i,n);s++}return i},e.addIfNotEmpty=function(t,i){if(i){var o;o=e.trim(i),""!=o&&t.push(i)}},e.trimExt=function(t,i){var o;o=e.trim(t);var n=0,s=0;for(s=i.length,n=0;s>n;n++)o=e.getReplace(o,i[n],"");return o},e.getBetween=function(e,t,i,o){if(void 0===o&&(o=!1),!e)return"";if(!t)return"";if(!i)return"";var n=0,s=0;if(n=e.indexOf(t),0>n)return"";if(o){if(s=e.lastIndexOf(i),n>s)return""}else s=e.indexOf(i,n);return 0>s?"":e.substring(n+t.length,s)},e.getSplitLine=function(e,t){return void 0===t&&(t=" "),e.split(t)},e.getLeft=function(e,t){var i=0;return i=e.indexOf(t),e.substr(0,i)},e.getRight=function(e,t){var i=0;return i=e.indexOf(t),e.substr(i+1)},e.delelteItem=function(e){for(;e.length>0&&""==e[0];)e.shift()},e.getWords=function(t){var i=e.getSplitLine(t);return e.delelteItem(i),i},e.getLinesI=function(e,t,i){var o=0,n=[];for(o=e;t>=o;o++)n.push(i[o]);return n},e.structfy=function(t,i,o){void 0===i&&(i=4),void 0===o&&(o=!0),o&&(t=laya.debug.tools.StringTool.trimEmptyLine(t));var n,s=0;s=0;var a;a=e.getEmptyStr(0),n=t.split("\n");var r,l=0,h=0;for(h=n.length,l=0;h>l;l++)r=n[l],r=laya.debug.tools.StringTool.trimLeft(r), +r=laya.debug.tools.StringTool.trimRight(r),s+=e.getPariCount(r),r.indexOf("}")>=0&&(a=e.getEmptyStr(s*i)),r=a+r,n[l]=r,a=e.getEmptyStr(s*i);return n.join("\n")},e.getEmptyStr=function(t){if(!e.emptyDic.hasOwnProperty(t)){var i=0,o=0;o=t;var n;for(n="",i=0;o>i;i++)n+=" ";e.emptyDic[t]=n}return e.emptyDic[t]},e.getPariCount=function(e,t,i){void 0===t&&(t="{"),void 0===i&&(i="}");var o;o={},o[t]=1,o[i]=-1;var n,s=0,a=0;a=e.length;var r=0;for(r=0,s=0;a>s;s++)n=e.charAt(s),o.hasOwnProperty(n)&&(r+=o[n]);return r},e.readInt=function(e,t){void 0===t&&(t=0);var i=NaN;i=0;var o,n=0,s=!1;s=!1;var a=0;for(a=e.length,n=t;a>n;n++)if(o=e.charAt(n),Number(o)>0||"0"==o)i=10*i+Number(o),i>0&&(s=!0);else if(s)return i;return i},e.getReplace=function(e,t,i){if(!e)return"";var o;return o=e.replace(new RegExp(t,"g"),i)},e.getWordCount=function(e,t){var i=new RegExp(t,"g");return e.match(i).length},e.getResolvePath=function(t,i){if(e.isAbsPath(t))return t;var o;o="\\",i.indexOf("/")>=0&&(o="/"),i.charAt(i.length-1)==o&&(i=i.substr(0,i.length-1));var n;n=".."+o;var s;s="."+o;var a=0;a=e.getWordCount(t,n),t=laya.debug.tools.StringTool.getReplace(t,n,""),t=laya.debug.tools.StringTool.getReplace(t,s,"");var r=0,l=0;l=a;for(r=0;l>r;r++)i=e.removeLastSign(t,o);return i+o+t},e.isAbsPath=function(e){return e.indexOf(":")>=0},e.removeLastSign=function(e,t){var i=0;return i=e.lastIndexOf(t),e=e.substring(0,i)},e.getParamArr=function(t){var i;return i=laya.debug.tools.StringTool.getBetween(t,"(",")",!0),e.trim(i).length<1?[]:i.split(",")},e.copyStr=function(e){return e.substring()},e.ArrayToString=function(t){var i;return i="[{items}]".replace(new RegExp("\\{items\\}","g"),e.getArrayItems(t))},e.getArrayItems=function(t){var i;if(t.length<1)return"";i=e.parseItem(t[0]);var o=0,n=0;for(n=t.length,o=1;n>o;o++)i+=","+e.parseItem(t[o]);return i},e.parseItem=function(e){var t;return t='"'+e+'"',""},e.emptyDic={},__static(e,["emptyStrDic",function(){return this.emptyStrDic={" ":!0,"\r":!0,"\n":!0," ":!0}},"specialChars",function(){return this.specialChars={"*":!0,"&":!0,"%":!0,"#":!0,"?":!0}}]),e}(),TimerControlTool=function(){function e(){}return __class(e,"laya.debug.tools.TimerControlTool"),e.now=function(){return 1!=e._timeRate?e.getRatedNow():Date.now()},e.getRatedNow=function(){var t=NaN;return t=e.getNow()-e._startTime,t*e._timeRate+e._startTime},e.getNow=function(){return Date.now()},e.setTimeRate=function(t){null==e._browerNow&&(e._browerNow=Browser.now),e._startTime=e.getNow(),e._timeRate=t,1!=t?Browser.now=e.now:null!=e._browerNow&&(Browser.now=e._browerNow)},e.recoverRate=function(){e.setTimeRate(1)},e._startTime=NaN,e._timeRate=1,e._browerNow=null,e}(),TimeTool=function(){function e(){}return __class(e,"laya.debug.tools.TimeTool"),e.getTime=function(t,i){void 0===i&&(i=!0),e.timeDic[t]||(e.timeDic[t]=0);var o=NaN;o=Browser.now();var n=NaN;return n=o-e.timeDic[t],e.timeDic[t]=o,n},e.timeDic={},e}(),TraceTool=function(){function e(){}return __class(e,"laya.debug.tools.TraceTool"),e.closeAllLog=function(){var t;t=e.emptyLog,Browser.window.console.log=t},e.emptyLog=function(){},e.traceObj=function(t){e.tempArr.length=0;var i;for(i in t)e.tempArr.push(i+":"+t[i]);var o;return o=e.tempArr.join("\n"),console.log(o),o},e.traceObjR=function(t){e.tempArr.length=0;var i;for(i in t)e.tempArr.push(t[i]+":"+i);var o;return o=e.tempArr.join("\n"),console.log(o),o},e.traceSize=function(e){DebugTool.dTrace("Size: x:"+e.x+" y:"+e.y+" w:"+e.width+" h:"+e.height+" scaleX:"+e.scaleX+" scaleY:"+e.scaleY)},e.traceSplit=function(e){console.log("---------------------"+e+"---------------------------")},e.group=function(e){console.group(e)},e.groupEnd=function(){console.groupEnd()},e.getCallStack=function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);var o;o=e.getCallStack,o=o.caller.caller;var n;for(n="";o&&t>0;)0>=i&&(n+=o+"<-",t--),o=o.caller,i--;return n},e.getCallLoc=function(t){void 0===t&&(t=2);var i;try{e.Erroer.i++}catch(o){var n;n=o.stack.replace(/Error\n/).split(/\n/),i=n[t]?n[t].replace(/^\s+|\s+$/,""):"unknow"}return i},e.traceCallStack=function(){var t;try{e.Erroer.i++}catch(i){t=i.stack}return console.log(t),t},e.getPlaceHolder=function(t){if(!e.holderDic.hasOwnProperty(t)){var i;i="";var o=0;for(o=0;t>o;o++)i+="-";e.holderDic[t]=i}return e.holderDic[t]},e.traceTree=function(t,i,o){if(void 0===i&&(i=0),void 0===o&&(o=!0),o&&console.log("traceTree"),t){var n=0,s=0;if(t.numChildren<1)return void console.log(t);for(e.group(t),s=t.numChildren,i++,n=0;s>n;n++)e.traceTree(t.getChildAt(n),i,!1);e.groupEnd()}},e.getClassName=function(e){return e.constructor.name},e.traceSpriteInfo=function(t,i,o,n){return void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===n&&(n=!0),t instanceof laya.display.Sprite?t?(e.traceSplit("traceSpriteInfo"),DebugTool.dTrace(laya.debug.tools.TraceTool.getClassName(t)+":"+t.name),n?e.traceTree(t):console.log(t),o&&e.traceSize(t),void(i&&console.log("bounds:"+t.getBounds()))):void console.log("null Sprite"):void console.log("not Sprite")},e.tempArr=[],e.Erroer=null,e.holderDic={},e}(),UVTools=function(){function e(){}return __class(e,"laya.debug.tools.UVTools"),e.getUVByRec=function(e,t,i,o){return[e,t,e+i,t,e+i,t+o,e,t+o]},e.getRecFromUV=function(e){var t;return t=new Rectangle(e[0],e[1],e[2]-e[0],e[5]-e[1])},e.isUVRight=function(e){return e[0]!=e[6]?!1:e[1]!=e[3]?!1:e[2]!=e[4]?!1:e[5]==e[7]},e.getTextureRec=function(t){var i;return i=e.getRecFromUV(t.uv),i.x*=t.bitmap.width,i.y*=t.bitmap.height,i.width*=t.bitmap.width,i.height*=t.bitmap.height,i},e}(),ValueChanger=function(){function e(){this.target=null,this.key=null,this._tValue=NaN,this.preValue=0}__class(e,"laya.debug.tools.ValueChanger");var t=e.prototype;return t.record=function(){this.preValue=this.value},t.showValueByAdd=function(e){this.value=this.preValue+e},t.showValueByScale=function(e){this.value=this.preValue*e},t.recover=function(){this.value=this.preValue},t.dispose=function(){this.target=null},__getset(0,t,"value",function(){return this.target&&(this._tValue=this.target[this.key]),this._tValue},function(e){this._tValue=e,this.target&&(this.target[this.key]=e)}),__getset(0,t,"dValue",function(){return this.value-this.preValue}),__getset(0,t,"scaleValue",function(){return this.value/this.preValue}),e.create=function(t,i){var o;return o=new e,o.target=t,o.key=i,o},e}(),VisibleAnalyser=function(){function e(){}return __class(e,"laya.debug.tools.VisibleAnalyser"),e.analyseTarget=function(t){var i=!1;i=t.displayedInStage;var o;o=NodeUtils.getGRec(t);var n=new Rectangle;n.setTo(0,0,Laya.stage.width,Laya.stage.height);var s,a=!1;s=n.intersection(o),a=s.width>0&&s.height>0;var r=NaN;r=NodeUtils.getGAlpha(t);var l=!1;l=NodeUtils.getGVisible(t);var h;h="",h+="isInstage:"+i+"\n",h+="isInVisibleRec:"+a+"\n",h+="gVisible:"+l+"\n",h+="gAlpha:"+r+"\n",i&&a&&l&&r>0&&(Render.isWebGL?e.anlyseRecVisible(t):SpriteRenderForVisibleAnalyse.I.analyseNode(t),h+="coverRate:"+e.coverRate+"\n",e._coverList.length>0&&Laya.timer.once(1e3,null,e.showListLater)),console.log(h),OutPutView.I.showTxt(h)},e.showListLater=function(){NodeListPanelView.I.showList(e._coverList)},e.isCoverByBrother=function(e){var t=e.parent;if(t){var i;i=t._childs;var o=0;if(o=i.indexOf(e),!(0>o)){var n;n=t.getSelfBounds(),n.width<=0||n.height<=0}}},e.anlyseRecVisible=function(t){e.isNodeWalked=!1,e._analyseTarget=t,e.mainCanvas||(e.mainCanvas=CanvasTools.createCanvas(Laya.stage.width,Laya.stage.height)),CanvasTools.clearCanvas(e.mainCanvas),e.tColor=1,e.resetCoverList(),WalkTools.walkTargetEX(Laya.stage,e.recVisibleWalker,null,e.filterFun),e.isTarRecOK?e.coverRate=CanvasTools.getDifferRate(e.preImageData,e.tarImageData):e.coverRate=0,console.log("coverRate:",e.coverRate)},e.getRecArea=function(e){return e.width*e.height},e.addCoverNode=function(t,i){var o;o={},o.path=t,o.label=ClassTool.getNodeClassAndName(t)+":"+i,o.coverRate=i,e._coverList.push(o),console.log("coverByNode:",t,i)},e.resetCoverList=function(){e._coverList.length=0},e.recVisibleWalker=function(t){if(t==e._analyseTarget)e.isNodeWalked=!0,e.tarRec.copyFrom(NodeUtils.getGRec(t)),console.log("tarRec:",e.tarRec.toString()),e.tarRec.width>0&&e.tarRec.height>0?(e.isTarRecOK=!0,e.tColor++,CanvasTools.fillCanvasRec(e.mainCanvas,e.tarRec,ColorTool.toHexColor(e.tColor)),e.preImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec),e.tarImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec)):console.log("tarRec Not OK:",e.tarRec);else if(e.isTarRecOK){var i;if(i=NodeUtils.getGRec(t),e.interRec=e.tarRec.intersection(i,e.interRec),e.interRec&&e.interRec.width>0&&e.interRec.height>0){e.tColor++,CanvasTools.fillCanvasRec(e.mainCanvas,i,ColorTool.toHexColor(e.tColor)),e.tImageData=CanvasTools.getImageDataFromCanvasByRec(e.mainCanvas,e.tarRec);var o=NaN;o=CanvasTools.getDifferRate(e.preImageData,e.tImageData),e.preImageData=e.tImageData,e.addCoverNode(t,o)}}},e.filterFun=function(e){return 0==e.visible?!1:e.alpha<0?!1:!DebugInfoLayer.I.isDebugItem(e)},e.isNodeWalked=!1,e._analyseTarget=null,e.isTarRecOK=!1,e.mainCanvas=null,e.preImageData=null,e.tImageData=null,e.tarImageData=null,e.coverRate=NaN,e.tColor=0,e._coverList=[],__static(e,["tarRec",function(){return this.tarRec=new Rectangle},"interRec",function(){return this.interRec=new Rectangle}]),e}(),WalkTools=function(){function e(){}return __class(e,"laya.debug.tools.WalkTools"),e.walkTarget=function(t,i,o){i.apply(o,[t]);var n,s=0,a=0;for(a=t.numChildren,s=0;a>s;s++)n=t.getChildAt(s),e.walkTarget(n,i,n)},e.walkTargetEX=function(t,i,o,n){if(null==n||n(t)){i.apply(o,[t]);var s,a,r=0,l=0;for(a=t._childs,l=a.length,r=0;l>r;r++)s=a[r],e.walkTarget(s,i,s)}},e.walkChildren=function(t,i,o){!t||t.numChildren<1||e.walkArr(DisControlTool.getAllChild(t),i,o)},e.walkArr=function(e,t,i){if(e){var o=0,n=0;for(n=e.length,o=0;n>o;o++)t.apply(i,[e[o],o])}},e}(),Watcher=function(){function e(){}return __class(e,"laya.debug.tools.Watcher"),e.watch=function(e,t,i){VarHook.hookVar(e,t,i)},e.traceChange=function(t,i,o){void 0===o&&(o="var changed:"),VarHook.hookVar(t,i,[e.getTraceValueFun(i),VarHook.getLocFun(o)])},e.debugChange=function(e,t){VarHook.hookVar(e,t,[VarHook.getLocFun("debug loc"),FunHook.debugHere])},e.differChange=function(t,i,o,n){void 0===n&&(n=""),VarHook.hookVar(t,i,[e.getDifferFun(t,i,o,n)])},e.getDifferFun=function(e,t,i,o){void 0===o&&(o="");var n;return n=function(){DifferTool.differ(i,e[t],o)}},e.traceValue=function(e){console.log("value:",e)},e.getTraceValueFun=function(e){var t;return t=function(t){console.log("set "+e+" :",t)}},e}(),XML2Object=function(){function e(){}return __class(e,"laya.debug.tools.XML2Object"),__getset(1,e,"arrays",function(){return e._arrays||(e._arrays=[]),e._arrays},function(t){e._arrays=t}),e.parse=function(t,i){void 0===i&&(i=!0);var o={};i&&(o.Name=t.localName);var n=t.children.length,s=[],a={};o.c=a,o.cList=s;for(var r=0;n>r;r++){var l,h,c=t.children[r],u=c.localName;l=e.parse(c,!0),s.push(l),a[u]?"array"==e.getTypeof(a[u])?a[u].push(l):a[u]=[a[u],l]:e.isArray(u)?a[u]=[l]:a[u]=l}if(h=0,t.attributes){h=t.attributes.length;var f={};for(o.p=f,r=0;h>r;r++)f[t.attributes[r].name.toString()]=String(t.attributes[r].nodeValue)}return 0==n&&0==h&&(o=""),o},e.getArr=function(t){return t?"array"==e.getTypeof(t)?t:[t]:[]},e.isArray=function(t){for(var i=e._arrays?e._arrays.length:0,o=0;i>o;o++)if(t==e._arrays[o])return!0;return!1},e.getTypeof=function(e){return"object"==typeof e?null==e.length?"object":"number"==typeof e.length?"array":"object":typeof e},e._arrays=null,e}(),NodeMenu=function(){function e(){this._tar=null,this._menu=null,this._shareBtns=["信息面板","边框","进入节点","树定位","Enable链","Size链","节点工具","可见分析","输出到控制台"],this._menuItems=["隐藏节点"],this._menuHide=null,this._menuItemsHide=["显示节点"],this._menu1=null,this._menuItems1=["输出到控制台"]}__class(e,"laya.debug.view.nodeInfo.menus.NodeMenu");var t=e.prototype;return t.showNodeMenu=function(e){return e._style?(this._tar=e,this._menu||(this._menuItems=this._menuItems.concat(this._shareBtns),this._menu=ContextMenu.createMenuByArray(this._menuItems),this._menu.on("select",this,this.onEmunSelect),this._menuItemsHide=this._menuItemsHide.concat(this._shareBtns),this._menuHide=ContextMenu.createMenuByArray(this._menuItemsHide),this._menuHide.on("select",this,this.onEmunSelect)),void(e.visible?this._menu.show():this._menuHide.show())):void DebugTool.log("该节点已不存在,请刷新列表")},t.nodeDoubleClick=function(e){NodeToolView.I.showByNode(e)},t.setNodeListDoubleClickAction=function(e){Browser.onMobile||e.on("doubleclick",this,this.onListDoubleClick,[e])},t.onListDoubleClick=function(e){if(e.selectedItem){var t;t=e.selectedItem.path,laya.debug.view.nodeInfo.menus.NodeMenu.I.nodeDoubleClick(t)}},t.setNodeListAction=function(e){e.on(DebugTool.getMenuShowEvent(),this,this.onListRightClick,[e])},t.onListRightClick=function(e){if(e.selectedItem){var t;t=e.selectedItem.path,laya.debug.view.nodeInfo.menus.NodeMenu.I.objRightClick(t)}},t.objRightClick=function(e){e instanceof laya.display.Sprite?laya.debug.view.nodeInfo.menus.NodeMenu.I.showNodeMenu(e):"object"==typeof e&&laya.debug.view.nodeInfo.menus.NodeMenu.I.showObjectMenu(e)},t.showObjectMenu=function(e){this._tar=e,this._menu1||(this._menu1=ContextMenu.createMenuByArray(this._menuItems1),this._menu1.on("select",this,this.onEmunSelect)),this._menu1.show()},t.onEmunSelect=function(e){var t=e.target.data;if("string"==typeof t){var i;switch(i=t){case"信息面板":ObjectInfoView.showObject(this._tar);break;case"边框":DebugTool.showDisBound(this._tar);break;case"输出到控制台":console.log(this._tar);break;case"树节点":ToolPanel.I.showNodeTree(this._tar);break;case"进入节点":ToolPanel.I.showNodeTree(this._tar);break;case"树定位":ToolPanel.I.showSelectInStage(this._tar);break;case"Enable链":OutPutView.I.dTrace(DebugTool.traceDisMouseEnable(this._tar)),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"Size链":OutPutView.I.dTrace(DebugTool.traceDisSizeChain(this._tar)),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"节点工具":NodeToolView.I.showByNode(this._tar);break;case"显示节点":this._tar.visible=!0;break;case"隐藏节点":this._tar.visible=!1;break;case"可见分析":this._tar&&VisibleAnalyser.analyseTarget(this._tar)}}},__getset(1,e,"I",function(){return e._I||(e._I=new e),e._I}),e._I=null,e}(),NodeConsts=function(){function e(){}return __class(e,"laya.debug.view.nodeInfo.NodeConsts"),e.defaultFitlerStr="x,y,width,height,scaleX,scaleY,alpha,renderCost",e.RenderCostMaxTime=3e3,e}(),NodeUtils=function(){function e(){}return __class(e,"laya.debug.view.nodeInfo.NodeUtils"),e.getFilterdTree=function(t,i){i||(i=e.defaultKeys);var o;o={};var n,s=0,a=0;for(a=i.length,s=0;a>s;s++)n=i[s],o[n]=t[n];var r,l;r=t._childs,a=r.length;var h;for(h=[],s=0;a>s;s++)l=r[s],h.push(e.getFilterdTree(l,i));return o.childs=h,o},e.getPropertyDesO=function(t,i){i||(i=e.defaultKeys);var o={};"object"==typeof t?o.label=""+ClassTool.getNodeClassAndName(t):o.label=""+t,o.type="",o.path=t,o.childs=[],o.isDirectory=!1;var n,s,a=0,r=0;if(t instanceof laya.display.Node){for(o.des=ClassTool.getNodeClassAndName(t),o.isDirectory=!0,r=i.length,a=0;r>a;a++)n=i[a],s=e.getPropertyDesO(t[n],i),t.hasOwnProperty(n)?s.label=""+n+":"+s.des:s.label=""+n+":"+ObjectInfoView.getNodeValue(t,n),o.childs.push(s);n="_childs",s=e.getPropertyDesO(t[n],i),s.label=""+n+":"+s.des,s.isChilds=!0,o.childs.push(s)}else if(t instanceof Array){o.des="Array["+t.length+"]",o.isDirectory=!0;var l;for(l=t,r=l.length,a=0;r>a;a++)s=e.getPropertyDesO(l[a],i),s.label=""+a+":"+s.des,o.childs.push(s)}else if("object"==typeof t){o.des=ClassTool.getNodeClassAndName(t),o.isDirectory=!0;for(n in t)s=e.getPropertyDesO(t[n],i),s.label=""+n+":"+s.des,o.childs.push(s)}else o.des=""+t;return o.hasChild=o.childs.length>0,o},e.adptShowKeys=function(e){var t=0,i=0;for(i=e.length,t=i-1;t>=0;t--)e[t]=StringTool.trimSide(e[t]),e[t].length<1&&e.splice(t,1);return e},e.getNodeTreeData=function(t,i){e.adptShowKeys(i);var o;o=e.getPropertyDesO(t,i);var n;return n=[],e.getTreeArr(o,n),n},e.getTreeArr=function(t,i,o){void 0===o&&(o=!0),o&&i.push(t);var n=t.childs,s=0,a=n.length;for(s=0;a>s;s++)o?n[s].nodeParent=t:n[s].nodeParent=null,n[s].isDirectory?e.getTreeArr(n[s],i):i.push(n[s])},e.traceStage=function(){console.log(e.getFilterdTree(Laya.stage,null)),console.log("treeArr:",e.getNodeTreeData(Laya.stage,null))},e.getNodeCount=function(t,i){if(void 0===i&&(i=!1),i&&!t.visible)return 0;var o=0;o=1;var n,s=0,a=0;for(n=t._childs,a=n.length,s=0;a>s;s++)o+=e.getNodeCount(n[s],i);return o},e.getGVisible=function(e){for(;e;){if(!e.visible)return!1;e=e.parent}return!0},e.getGAlpha=function(e){var t=NaN;for(t=1;e;)t*=e.alpha,e=e.parent;return t},e.getGPos=function(e){var t;return t=new Point,e.localToGlobal(t),t},e.getGRec=function(e){var t;if(t=e._getBoundPointsM(!0),!t||t.length<1)return Rectangle.TEMP.setTo(0,0,0,0);t=GrahamScan.pListToPointList(t,!0),WalkTools.walkArr(t,e.localToGlobal,e),t=GrahamScan.pointListToPlist(t);var i;return i=Rectangle._getWrapRec(t,i)},e.getGGraphicRec=function(e){var t;if(t=e.getGraphicBounds()._getBoundPoints(),!t||t.length<1)return Rectangle.TEMP.setTo(0,0,0,0);t=GrahamScan.pListToPointList(t,!0),WalkTools.walkArr(t,e.localToGlobal,e),t=GrahamScan.pointListToPlist(t);var i;return i=Rectangle._getWrapRec(t,i)},e.getNodeCmdCount=function(e){var t=0;return t=e.graphics?e.graphics.cmds?e.graphics.cmds.length:e.graphics._one?1:0:0},e.getNodeCmdTotalCount=function(t){var i,o=0,n=0,s=0;for(i=t._childs,s=i.length,o=e.getNodeCmdCount(t),n=0;s>n;n++)o+=e.getNodeCmdTotalCount(i[n]);return o},e.getRenderNodeCount=function(t){if("none"!=t.cacheAs)return 1;var i,o=0,n=0,s=0;for(i=t._childs,s=i.length,o=1,n=0;s>n;n++)o+=e.getRenderNodeCount(i[n]);return o},e.getReFreshRenderNodeCount=function(t){var i,o=0,n=0,s=0;for(i=t._childs,s=i.length,o=1,n=0;s>n;n++)o+=e.getRenderNodeCount(i[n]);return o},e.showCachedSpriteRecs=function(){e.g=DebugInfoLayer.I.graphicLayer.graphics,e.g.clear(),WalkTools.walkTarget(Laya.stage,e.drawCachedBounds,null)},e.drawCachedBounds=function(t){if("none"!=t.cacheAs&&!DebugInfoLayer.I.isDebugItem(t)){var i;i=e.getGRec(t),e.g.drawRect(i.x,i.y,i.width,i.height,null,"#0000ff",2)}},e.g=null,__static(e,["defaultKeys",function(){return this.defaultKeys=["x","y","width","height"]}]),e}(),StyleConsts=function(){function e(){}return __class(e,"laya.debug.view.StyleConsts"),e.setViewScale=function(t){t.scaleX=t.scaleY=e.PanelScale},__static(e,["PanelScale",function(){return this.PanelScale=Browser.onPC?1:Browser.pixelRatio}]),e}(),Notice=function(e){function t(){t.__super.call(this)}return __class(t,"laya.debug.tools.Notice",e),t.notify=function(e,i){t.I.event(e,i)},t.listen=function(e,i,o,n,s){void 0===s&&(s=!1),s&&t.cancel(e,i,o),t.I.on(e,i,o,n)},t.cancel=function(e,i,o){t.I.off(e,i,o)},__static(t,["I",function(){return this.I=new t}]),t}(EventDispatcher),LoaderHook=function(e){function t(){t.__super.call(this)}__class(t,"laya.debug.tools.enginehook.LoaderHook",e);var i=t.prototype;return i.checkUrls=function(e){var i;i="string"==typeof e?e:e.url,t.preFails[i]&&t.enableFailDebugger},i.chekUrlList=function(e){var t=0,i=0;for(i=e.length,t=0;i>t;t++)this.checkUrls(e[t])},i.load=function(t,i,o,n,s,a,r,l){return void 0===s&&(s=1),void 0===a&&(a=!0),void 0===l&&(l=!1),t instanceof Array?this.chekUrlList(t):this.checkUrls(t),e.prototype.load.call(this,t,i,o,n,s,a,r,l)},t.init=function(){Laya.loader=new t,Laya.loader.on("error",null,t.onFail),t.preFails=LocalStorage.getJSON("LoadFailItems"),t.preFails||(t.preFails={})},t.onFail=function(e){OutPutView.I.dTrace("LoadFail:"+e),t.nowFails[e]=!0,LocalStorage.setJSON("LoadFailItems",t.nowFails)},t.resetFails=function(){t.nowFails={},LocalStorage.setJSON("LoadFailItems",t.nowFails)},t.preFails={},t.nowFails={},t.enableFailDebugger=!0,t.FailSign="LoadFailItems",t}(LoaderManager),ColorSelector=function(e){function t(){this.sideColor=null,this.mainColor=null,this.demoColor=null,this.posSp=null,this.hPos=null,this.container=null,this.isChanging=!1,this.tColor=null,this.tH=NaN,t.__super.call(this),this.container=this,this.createUI()}__class(t,"laya.debug.tools.ColorSelector",e);var i=t.prototype;return i.createUI=function(){this.sideColor=new Sprite,this.container.addChild(this.sideColor),this.posSp=new Sprite,this.posSp.pos(100,100),this.posSp.graphics.drawCircle(0,0,5,null,"#ff0000"),this.posSp.graphics.drawCircle(0,0,6,null,"#ffff00"),this.posSp.autoSize=!0,this.posSp.cacheAsBitmap=!0,this.sideColor.addChild(this.posSp),this.sideColor.pos(0,0),this.sideColor.size(150,150),this.sideColor.on("mousedown",this,this.sideColorClick);var e=0;this.mainColor=new Sprite;var t;t=this.mainColor.graphics;var i;for(e=0;150>e;e++)i=ColorTool.hsb2rgb(e/150*360,1,1),t.drawLine(0,e,20,e,ColorTool.getRGBStr(i));this.mainColor.pos(160,0),this.mainColor.size(20,e),this.mainColor.cacheAsBitmap=!0,this.hPos=new Sprite,this.hPos.graphics.drawPie(0,0,10,-10,10,"#ff0000"),this.hPos.x=this.mainColor.x+22,this.container.addChild(this.hPos),this.container.addChild(this.mainColor),this.mainColor.on("mousedown",this,this.mainColorClick),this.demoColor=new Sprite,this.demoColor.pos(this.sideColor.x,this.sideColor.y+this.sideColor.height+10),this.demoColor.size(150,20),this.container.addChild(this.demoColor),this.setColorByRGBStr("#099599"),this.posSp.on("dragmove",this,this.posDraging)},i.posMouseDown=function(e){},i.posDraging=function(){this.updatePosSpAndShowColor()},i.posDragEnd=function(){this.isChanging=!1,this.updatePosSpAndShowColor()},i.setColorByRGBStr=function(e){var t;t=ColorTool.getRGBByRGBStr(e),this.setColor(t[0],t[1],t[2])},i.setColor=function(e,t,i,o){void 0===o&&(o=!0);var n;n=ColorTool.rgb2hsb(e,t,i);var s;s=ColorTool.hsb2rgb(n[0],n[1],n[2]),this.setColorByHSB(n[0],n[1],n[2],o)},i.setColorByHSB=function(e,t,i,o){void 0===o&&(o=!0),this.hPos.y=this.mainColor.y+e/360*150,this.posSp.x=150*t,this.posSp.y=150*(1-i),this.updateSideColor(e,o)},i.sideColorClick=function(e){this.isChanging=!0,this.posSp.startDrag(),this.updatePosSpAndShowColor(),Laya.stage.off("mouseup",this,this.sideColorMouseUp),Laya.stage.once("mouseup",this,this.sideColorMouseUp)},i.sideColorMouseUp=function(e){this.isChanging=!1,this.updatePosSpAndShowColor()},i.updatePosSpAndShowColor=function(){this.posSp.x=this.sideColor.mouseX,this.posSp.y=this.sideColor.mouseY,this.posSp.x<0&&(this.posSp.x=0),this.posSp.y<0&&(this.posSp.y=0),this.posSp.x>150&&(this.posSp.x=150),this.posSp.y>150&&(this.posSp.y=150),this.updateDemoColor()},i.updateDemoColor=function(e){void 0===e&&(e=!0);var t=NaN,i=NaN,o=NaN;t=this.tH,i=this.posSp.x/150,o=1-this.posSp.y/150,this.tColor=ColorTool.hsb2rgb(t,i,o);var n;n=this.demoColor.graphics,n.clear(),n.drawRect(0,0,this.demoColor.width,this.demoColor.height,ColorTool.getRGBStr(this.tColor)),this.isChanging||e&&this.event("ColorChanged",this)},i.mainColorClick=function(e){var t=NaN;t=this.mainColor.mouseY,this.hPos.y=t+this.mainColor.y;var i=NaN;i=t/150*360,this.updateSideColor(i)},i.updateSideColor=function(e,t){void 0===t&&(t=!0),this.tH=e;var i;i=this.sideColor.graphics,i.clear(),this.sideColor.cacheAsBitmap=!1;var o;o=ColorTool.hsb2rgb(e,1,1);var n=Browser.context.createLinearGradient(0,0,80,0);n.addColorStop(0,"white"),n.addColorStop(1,ColorTool.getRGBStr(o)),this.sideColor.graphics.drawRect(0,0,150,150,n),this.sideColor.graphics.loadImage("comp/colorpicker_overlay.png",0,0),this.sideColor.size(150,150),this.sideColor.cacheAsBitmap=!0,this.updateDemoColor(t)},t.COLOR_CHANGED="ColorChanged",t.COLOR_CLEARED="COLOR_CLEARED",t.RecWidth=150,t}(Sprite),Arrow=function(e){function t(){t.__super.call(this),this.drawMe()}__class(t,"laya.debug.tools.comps.Arrow",e);var i=t.prototype;return i.drawMe=function(){var e;e=this.graphics,e.clear(),e.drawLine(0,0,-1,-1,"#ff0000"),e.drawLine(0,0,1,-1,"#ff0000")},t}(Sprite),ArrowLine=function(e){function t(e){this.lineLen=160,this.arrowLen=10,this.sign="Y",this._targetChanger=null,this._isMoving=!1,this.lenControl=new Rect,this.rotationControl=new Rect,this.lenChanger=ValueChanger.create(this,"lineLen"),this.lenControlXChanger=ValueChanger.create(this.lenControl,"x"),void 0===e&&(e="X"),t.__super.call(this),this.sign=e,this.addChild(this.lenControl),this.addChild(this.rotationControl),this.lenControl.on("mousedown",this,this.controlMouseDown),this.drawMe()}__class(t,"laya.debug.tools.comps.ArrowLine",e);var i=t.prototype;return i.drawMe=function(){var e;e=this.graphics,e.clear(),e.drawLine(0,0,this.lineLen,0,"#ffff00"),e.drawLine(this.lineLen,0,this.lineLen-this.arrowLen,-this.arrowLen,"#ff0000"),e.drawLine(this.lineLen,0,this.lineLen-this.arrowLen,this.arrowLen,"#ff0000"),e.fillText(this.sign,50,-5,"","#ff0000","left"),this._isMoving&&this._targetChanger&&e.fillText(this._targetChanger.key+":"+this._targetChanger.value.toFixed(2),this.lineLen-15,-25,"","#ffff00","center"),this.lenControl.posTo(this.lineLen-15,0),this.rotationControl.posTo(this.lineLen+10,0),this.size(this.arrowLen,this.lineLen)},i.clearMoveEvents=function(){Laya.stage.off("mousemove",this,this.stageMouseMove),Laya.stage.off("mouseup",this,this.stageMouseUp)},i.controlMouseDown=function(e){this.clearMoveEvents(),this.lenControlXChanger.record(),this.lenChanger.record(),this.targetChanger&&this.targetChanger.record(),this._isMoving=!0,Laya.stage.on("mousemove",this,this.stageMouseMove),Laya.stage.on("mouseup",this,this.stageMouseUp)},i.stageMouseMove=function(e){this.lenControlXChanger.value=this.mouseX,this.lenChanger.showValueByScale(this.lenControlXChanger.scaleValue),this.targetChanger&&this.targetChanger.showValueByScale(this.lenControlXChanger.scaleValue),this.drawMe()},i.stageMouseUp=function(e){this._isMoving=!1,this.noticeChange(),this.clearMoveEvents(),this.lenControlXChanger.recover(),this.lenChanger.recover(),this.drawMe()},i.noticeChange=function(){var e=NaN;e=this.lenChanger.dValue,console.log("lenChange:",e)},__getset(0,i,"targetChanger",function(){return this._targetChanger},function(e){this._targetChanger&&this._targetChanger.dispose(),this._targetChanger=e}),t}(Sprite),AutoSizeRec=function(e){function t(e){this.type=0,this._color="#ffffff",this.preX=NaN,this.preY=NaN,t.__super.call(this)}__class(t,"laya.debug.tools.comps.AutoSizeRec",e);var i=t.prototype;return i.setColor=function(e){this._color=e,this.reRender()},i.changeSize=function(){this.reRender()},i.reRender=function(){var e=this.graphics;e.clear(),e.drawRect(0,0,this.width,this.height,this._color)},i.record=function(){this.preX=this.x,this.preY=this.y},i.getDx=function(){return this.x-this.preX},i.getDy=function(){return this.y-this.preY},__getset(0,i,"height",e.prototype._$get_height,function(t){e.prototype._$set_height.call(this,t),this.changeSize()}),__getset(0,i,"width",e.prototype._$get_width,function(t){e.prototype._$set_width.call(this,t),this.changeSize()}),t}(Sprite),Axis=function(e){function t(){this._target=null,this._lenType=[["width","height"],["scaleX","scaleY"]],this._type=1,this.xAxis=new ArrowLine("X"),this.yAxis=new ArrowLine("Y"),this.controlBox=new Rect,this._point=new Point,this.oPoint=new Point,this.myRotationChanger=ValueChanger.create(this,"rotation"),this.targetRotationChanger=ValueChanger.create(null,"rotation"),this.stageMouseRotationChanger=new ValueChanger,t.__super.call(this),this.mouseEnabled=!0,this.size(1,1),this.initMe(),this.xAxis.rotationControl.on("mousedown",this,this.controlMouseDown),this.yAxis.rotationControl.on("mousedown",this,this.controlMouseDown),this.controlBox.on("mousedown",this,this.controlBoxMouseDown),this.on("dragmove",this,this.dragging)}__class(t,"laya.debug.tools.comps.Axis",e);var i=t.prototype;return i.updateChanges=function(){if(this._target){var e;e=this._lenType[this._type],this.xAxis.targetChanger=ValueChanger.create(this._target,e[0]),this.yAxis.targetChanger=ValueChanger.create(this._target,e[1])}},i.switchType=function(){this._type++,this._type=this._type%this._lenType.length,this.type=this._type},i.controlBoxMouseDown=function(e){this.startDrag()},i.dragging=function(){this._target&&(this._point.setTo(this.x,this.y),DisControlTool.transPoint(this.parent,this._target.parent,this._point),this._target.pos(this._point.x,this._point.y))},i.initMe=function(){this.addChild(this.xAxis),this.addChild(this.yAxis),this.yAxis.rotation=90,this.addChild(this.controlBox),this.controlBox.posTo(0,0)},i.clearMoveEvents=function(){Laya.stage.off("mousemove",this,this.stageMouseMove),Laya.stage.off("mouseup",this,this.stageMouseUp)},i.controlMouseDown=function(e){this.targetRotationChanger.target=this.target,this.clearMoveEvents(),this.oPoint.setTo(0,0),this.myRotationChanger.record(),this.oPoint=this.localToGlobal(this.oPoint),this.stageMouseRotationChanger.value=this.getStageMouseRatation(),this.stageMouseRotationChanger.record(),this.targetRotationChanger.record(),Laya.stage.on("mousemove",this,this.stageMouseMove),Laya.stage.on("mouseup",this,this.stageMouseUp)},i.getStageMouseRatation=function(){return MathUtil.getRotation(this.oPoint.x,this.oPoint.y,Laya.stage.mouseX,Laya.stage.mouseY)},i.stageMouseMove=function(e){this.stageMouseRotationChanger.value=this.getStageMouseRatation();var t=NaN;t=-this.stageMouseRotationChanger.dValue,this.target?this.targetRotationChanger.showValueByAdd(t):this.myRotationChanger.showValueByAdd(t)},i.stageMouseUp=function(e){this.noticeChange(),this.clearMoveEvents()},i.noticeChange=function(){console.log("rotate:",-this.stageMouseRotationChanger.dValue)},__getset(0,i,"target",function(){return this._target},function(e){this._target=e,this.updateChanges()}),__getset(0,i,"type",function(){return this._type},function(e){this._type=e,this.updateChanges()}),t}(Sprite),Rect=function(e){function t(){this.recWidth=10,t.__super.call(this),this.drawMe()}__class(t,"laya.debug.tools.comps.Rect",e);var i=t.prototype;return i.drawMe=function(){var e;e=this.graphics,e.clear(),e.drawRect(0,0,this.recWidth,this.recWidth,"#22ff22"),this.size(this.recWidth,this.recWidth)},i.posTo=function(e,t){this.x=e-.5*this.recWidth,this.y=t-.5*this.recWidth},t}(Sprite),DragBox=function(e){function t(e){this._box=null,this._target=null,this._currDir=null,this._type=0,this.fixScale=NaN,t.__super.call(this),this._left=this.drawBlock(),this._right=this.drawBlock(),this._top=this.drawBlock(),this._bottom=this.drawBlock(),this._topLeft=this.drawBlock(),this._topRight=this.drawBlock(),this._bottomLeft=this.drawBlock(),this._bottomRight=this.drawBlock(),this._lastPoint=new Point,this._type=e=3,this.addChild(this._box=this.drawBorder(0,0,16711680)),1!=e&&3!=e||(this.addChild(this._left),this.addChild(this._right)),2!=e&&3!=e||(this.addChild(this._top),this.addChild(this._bottom)),3==e&&(this.addChild(this._topLeft),this.addChild(this._topRight),this.addChild(this._bottomLeft),this.addChild(this._bottomRight)),this.on("mousedown",this,this.onMouseDown),this.mouseThrough=!0}__class(t,"laya.debug.tools.DragBox",e);var i=t.prototype;return i.onMouseDown=function(e){this._currDir=e.target,e.nativeEvent.shiftKey&&this.initFixScale(),this._currDir!=this&&(this._lastPoint.x=Laya.stage.mouseX,this._lastPoint.y=Laya.stage.mouseY,Laya.stage.on("mousemove",this,this.onMouseMove),Laya.stage.on("mouseup",this,this.onMouseUp),e.stopPropagation())},i.onMouseUp=function(e){Laya.stage.off("mousemove",this,this.onMouseMove),Laya.stage.off("mouseup",this,this.onMouseUp)},i.initFixScale=function(){this.fixScale=this._target.height/this._target.width},i.onMouseMove=function(e){var t=1,i=(Laya.stage.mouseX-this._lastPoint.x)/t,o=(Laya.stage.mouseY-this._lastPoint.y)/t,n=!1,s=NaN,a=NaN;if(e.nativeEvent.shiftKey)switch(this.fixScale<0&&this.initFixScale(),a=i*this.fixScale,s=o/this.fixScale,n=!0,this._currDir){case this._topLeft:case this._bottomLeft:this._currDir=this._left;break;case this._topRight:case this._bottomRight:this._currDir=this._right}if(0!=i||0!=o){this._lastPoint.x+=i*t,this._lastPoint.y+=o*t;var r=i/this._target.scaleX,l=o/this._target.scaleY;this._currDir==this._left?(this._target.x+=i,this._target.width-=r,n&&(this._target.height=this._target.width*this.fixScale)):this._currDir==this._right?(this._target.width+=r, +n&&(this._target.height=this._target.width*this.fixScale)):this._currDir==this._top?(this._target.y+=o,this._target.height-=l,n&&(this._target.width=this._target.height/this.fixScale)):this._currDir==this._bottom?(this._target.height+=l,n&&(this._target.width=this._target.height/this.fixScale)):this._currDir==this._topLeft?(this._target.x+=i,this._target.y+=o,this._target.width-=r,this._target.height-=l):this._currDir==this._topRight?(this._target.y+=o,this._target.width+=r,this._target.height-=l):this._currDir==this._bottomLeft?(this._target.x+=i,this._target.width-=r,this._target.height+=l):this._currDir==this._bottomRight&&(this._target.width+=r,this._target.height+=l),this._target.width<1&&(this._target.width=1),this._target.height<1&&(this._target.height=1),this._target.width=Math.round(this._target.width),this._target.x=Math.round(this._target.x),this._target.y=Math.round(this._target.y),this._target.height=Math.round(this._target.height),this.refresh()}},i.drawBorder=function(e,t,i,o){void 0===o&&(o=1);var n=new Sprite,s=n.graphics;return s.clear(),s.drawRect(0,0,e,t,null,"#"+i),n},i.drawBlock=function(){var e=new Sprite,i=e.graphics;return i.clear(),e.width=t.BLOCK_WIDTH,e.height=t.BLOCK_WIDTH,i.drawRect(.5*-t.BLOCK_WIDTH,.5*-t.BLOCK_WIDTH,t.BLOCK_WIDTH,t.BLOCK_WIDTH,"#ffffff","#ff0000",1),e.mouseEnabled=!0,e.mouseThrough=!0,e},i.setTarget=function(e){this._target=e,this.refresh()},i.refresh=function(){this.changePoint(),this.changeSize()},i.changePoint=function(){var e=this._target.localToGlobal(new Point),t=this.parent.globalToLocal(e);this.x=t.x,this.y=t.y},i.changeSize=function(){var e=this._target.width*this._target.scaleX,t=this._target.height*this._target.scaleY;console.log("change size"),this.rotation=this._target.rotation,this._box.width==e&&this._box.height==t||(this._box.graphics.clear(),this._box.graphics.drawRect(0,0,Math.abs(e),Math.abs(t),null,"#ff0000"),this._box.size(e,t),this.size(e,t),this._box.scaleX=Math.abs(this._box.scaleX)*(this._target.scaleX>0?1:-1),this._box.scaleY=Math.abs(this._box.scaleY)*(this._target.scaleY>0?1:-1),this._left.x=0,this._left.y=.5*t,this._right.x=e,this._right.y=.5*t,this._top.x=.5*e,this._top.y=0,this._bottom.x=.5*e,this._bottom.y=t,this._topLeft.x=this._topLeft.y=0,this._topRight.x=e,this._topRight.y=0,this._bottomLeft.x=0,this._bottomLeft.y=t,this._bottomRight.x=e,this._bottomRight.y=t)},t.BLOCK_WIDTH=6,t}(Sprite),DebugInfoLayer=function(e){function t(){this.nodeRecInfoLayer=null,this.lineLayer=null,this.txtLayer=null,this.popLayer=null,this.graphicLayer=null,this.cacheViewLayer=null,t.__super.call(this),this.nodeRecInfoLayer=new Sprite,this.lineLayer=new Sprite,this.txtLayer=new Sprite,this.popLayer=new Sprite,this.graphicLayer=new Sprite,this.cacheViewLayer=new Sprite,this.nodeRecInfoLayer.name="nodeRecInfoLayer",this.lineLayer.name="lineLayer",this.txtLayer.name="txtLayer",this.popLayer.name="popLayer",this.graphicLayer.name="graphicLayer",this.cacheViewLayer.name="cacheViewLayer",this.addChild(this.lineLayer),this.addChild(this.cacheViewLayer),this.addChild(this.nodeRecInfoLayer),this.addChild(this.txtLayer),this.addChild(this.popLayer),this.addChild(this.graphicLayer),t.I=this,Laya.stage.on("doubleclick",this,this.setTop)}__class(t,"laya.debug.view.nodeInfo.DebugInfoLayer",e);var i=t.prototype;return i.setTop=function(){DisControlTool.setTop(this)},i.isDebugItem=function(e){return DisControlTool.isInTree(this,e)},t.I=null,t}(Sprite),NodeInfoPanel=function(e){function t(){this._stateDic={},this.isWorkState=!1,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.NodeInfoPanel",e);var i=t.prototype;return i.showDisInfo=function(e){this.recoverNodes(),NodeInfosItem.showDisInfos(e),this.showOnly(e),this.isWorkState=!0},i.showOnly=function(e){e&&(this.hideBrothers(e),this.showOnly(e.parent))},i.recoverNodes=function(){NodeInfosItem.hideAllInfos();var e,t,i;for(e in this._stateDic)if(t=this._stateDic[e],i=t.target)try{i.visible=t.visible}catch(o){}this.isWorkState=!1},i.hideOtherChain=function(e){if(e)for(;e;)this.hideBrothers(e),e=e.parent},i.hideChilds=function(e){if(e){var t,i=0,o=0;t=e._childs,o=t.length;var n;for(i=0;o>i;i++)n=t[i],n!=NodeInfosItem.NodeInfoContainer&&(this.saveNodeInfo(n),n.visible=!1)}},i.hideBrothers=function(e){if(e){var t;if(t=e.parent){var i,o=0,n=0;i=t._childs,n=i.length;var s;for(o=0;n>o;o++)s=i[o],s!=NodeInfosItem.NodeInfoContainer&&s!=e&&(this.saveNodeInfo(s),s.visible=!1)}}},i.saveNodeInfo=function(e){if(IDTools.idObj(e),!this._stateDic.hasOwnProperty(IDTools.getObjID(e))){var t;t={},t.target=e,t.visible=e.visible,this._stateDic[IDTools.getObjID(e)]=t}},i.recoverNodeInfo=function(e){if(IDTools.idObj(e),this._stateDic.hasOwnProperty(IDTools.getObjID(e))){var t;t=this._stateDic[IDTools.getObjID(e)],e.visible=t.visible}},t.init=function(){t.I||(t.I=new t,NodeInfosItem.init(),ToolPanel.init())},t.I=null,t}(Sprite),NodeInfosItem=function(e){function t(){this._infoTxt=null,this._tar=null,t.__super.call(this),this._infoTxt=new Text,this._infoTxt.color="#ff0000",this._infoTxt.bgColor="#00ff00",this._infoTxt.fontSize=12}__class(t,"laya.debug.view.nodeInfo.NodeInfosItem",e);var i=t.prototype;return i.removeSelf=function(){return this._infoTxt.removeSelf(),laya.display.Node.prototype.removeSelf.call(this)},i.showToUI=function(){t.NodeInfoContainer.nodeRecInfoLayer.addChild(this),this._infoTxt.removeSelf(),t.NodeInfoContainer.txtLayer.addChild(this._infoTxt),this.findOkPos()},i.randomAPos=function(e){this._infoTxt.x=this.x+Laya.stage.width*Math.random(),this._infoTxt.y=this.y+e*Math.random()},i.findOkPos=function(){var e=0;return e=20,void this.randomAPos(e)},i.isPosOk=function(){var e;e=t.NodeInfoContainer.nodeRecInfoLayer;var i,o=0,n=0;i=e._childs,n=i.length;var s,a;if(a=this._infoTxt.getBounds(),a.x<0)return!1;if(a.y<0)return!1;if(a.right>Laya.stage.width)return!1;for(o=0;n>o;o++)if(s=i[o],s!=this._infoTxt&&a.intersects(s.getBounds()))return!1;return!0},i.showInfo=function(e){if(this._tar=e,e){t._txts.length=0;var i,o=0,n=0;for(n=t.showValues.length,e.name?t._txts.push(ClassTool.getClassName(e)+"("+e.name+")"):t._txts.push(ClassTool.getClassName(e)),o=0;n>o;o++)i=t.showValues[o],t._txts.push(i+":"+t.getNodeValue(e,i));this._infoTxt.text=t._txts.join("\n"),this.graphics.clear();var s;s=e._getBoundPointsM(!0),!s||s.length<1||(s=GrahamScan.pListToPointList(s,!0),WalkTools.walkArr(s,e.localToGlobal,e),s=GrahamScan.pointListToPlist(s),t._disBoundRec=Rectangle._getWrapRec(s,t._disBoundRec),this.graphics.drawRect(0,0,t._disBoundRec.width,t._disBoundRec.height,null,"#00ffff"),this.pos(t._disBoundRec.x,t._disBoundRec.y))}},i.fresh=function(){this.showInfo(this._tar)},i.clearMe=function(){this._tar=null},i.recover=function(){Pool.recover("NodeInfosItem",this)},t.init=function(){t.NodeInfoContainer||(t.NodeInfoContainer=new DebugInfoLayer,Laya.stage.addChild(t.NodeInfoContainer))},t.getNodeInfoByNode=function(e){IDTools.idObj(e);var i=0;return i=IDTools.getObjID(e),t._nodeInfoDic[i]||(t._nodeInfoDic[i]=new t),t._nodeInfoDic[i]},t.hideAllInfos=function(){var e,i;for(e in t._nodeInfoDic)i=t._nodeInfoDic[e],i.removeSelf();t.clearRelations()},t.showNodeInfo=function(e){var i;i=t.getNodeInfoByNode(e),i.showInfo(e),i.showToUI()},t.showDisInfos=function(e){var i;if(i=e,e){for(;e;)t.showNodeInfo(e),e=e.parent;DisControlTool.setTop(t.NodeInfoContainer),t.apdtTxtInfoPoss(i),t.updateRelations()}},t.apdtTxtInfoPoss=function(e){var i;for(i=[];e;)i.push(e),e=e.parent;var o,n,s=0,a=0;a=i.length;var r=NaN;r=Laya.stage.width-150;var l=0;for(l=100,e=i[0],e&&(o=t.getNodeInfoByNode(e),o&&(n=o._infoTxt,r=Laya.stage.width-n.width-10,l=n.height+10)),i=i.reverse(),s=0;a>s;s++)e=i[s],o=t.getNodeInfoByNode(e),o&&(n=o._infoTxt,n.pos(r,l*s))},t.clearRelations=function(){var e;e=t.NodeInfoContainer.lineLayer.graphics,e.clear()},t.updateRelations=function(){var e;e=t.NodeInfoContainer.lineLayer.graphics,e.clear();var i,o;for(i in t._nodeInfoDic)o=t._nodeInfoDic[i],o.parent&&e.drawLine(o.x,o.y,o._infoTxt.x,o._infoTxt.y,"#0000ff")},t.getNodeValue=function(e,i){var o;switch(t._nodePoint.setTo(0,0),i){case"x":o=e.x+" (g:"+e.localToGlobal(t._nodePoint).x+")";break;case"y":o=e.y+" (g:"+e.localToGlobal(t._nodePoint).y+")";break;default:o=e[i]}return o},t.NodeInfoContainer=null,t._nodeInfoDic={},t._txts=[],__static(t,["showValues",function(){return this.showValues=["x","y","scaleX","scaleY","width","height","visible","mouseEnabled"]},"_disBoundRec",function(){return this._disBoundRec=new Rectangle},"_nodePoint",function(){return this._nodePoint=new Point}]),t}(Sprite),NodeRecInfo=function(e){function t(){this.txt=null,this._tar=null,this.recColor="#00ff00",t.__super.call(this),this.txt=new Text,this.txt.color="#ff0000",this.txt.bgColor="#00ff00",this.txt.fontSize=12,this.addChild(this.txt)}__class(t,"laya.debug.view.nodeInfo.recinfos.NodeRecInfo",e);var i=t.prototype;return i.setInfo=function(e){this.txt.text=e},i.setTarget=function(e){this._tar=e},i.showInfo=function(e){if(this._tar=e,e&&e._$P){this.graphics.clear();var i;i=e._getBoundPointsM(!0),!i||i.length<1||(i=GrahamScan.pListToPointList(i,!0),WalkTools.walkArr(i,e.localToGlobal,e),i=GrahamScan.pointListToPlist(i),t._disBoundRec=Rectangle._getWrapRec(i,t._disBoundRec),this.graphics.drawRect(0,0,t._disBoundRec.width,t._disBoundRec.height,null,this.recColor,2),this.pos(t._disBoundRec.x,t._disBoundRec.y))}},i.fresh=function(){this.showInfo(this._tar)},i.clearMe=function(){this._tar=null},__static(t,["_disBoundRec",function(){return this._disBoundRec=new Rectangle}]),t}(Sprite),ToolPanel=function(e){function t(){t.__super.call(this),Base64AtlasManager.base64.preLoad(Handler.create(this,this.showToolBar)),ContextMenu.init(),DisResizer.init();var e;e=new TipManagerForDebug}__class(t,"laya.debug.view.nodeInfo.ToolPanel",e);var i=t.prototype;return i.showToolBar=function(){DebugPanelView.I.show()},i.createViews=function(){t.typeClassDic.Find=FindView,t.typeClassDic.Filter=FilterView,t.typeClassDic.TxtInfo=TxtInfoView,t.typeClassDic.Tree=NodeTreeView},i.switchShow=function(e){var t;t=this.getView(e),t&&t.switchShow()},i.getView=function(e){var i;return i=t.viewDic[e],!i&&t.typeClassDic[e]&&(i=t.viewDic[e]=new t.typeClassDic[e]),i},i.showTxtInfo=function(e){OutPutView.I.showTxt(e)},i.showNodeTree=function(e){NodeTree.I.setDis(e),DebugPanelView.I.switchToTree()},i.showSelectInStage=function(e){NodeTree.I.showSelectInStage(e),DebugPanelView.I.switchToTree()},i.showSelectItems=function(e){DebugPanelView.I.swichToSelect(),SelectInfosView.I.setSelectList(e)},t.init=function(){t.I||(t.I=new t)},t.I=null,t.viewDic={},t.Find="Find",t.Filter="Filter",t.TxtInfo="TxtInfo",t.Tree="Tree",__static(t,["typeClassDic",function(){return this.typeClassDic={}}]),t}(Sprite),DButton=function(e){function t(){t.__super.call(this),this.bgColor="#ffff00",this.wordWrap=!1,this.mouseEnabled=!0}return __class(t,"laya.debug.tools.debugUI.DButton",e),t}(Text),AutoFillRec=function(e){function t(e){this.type=0,this.preX=NaN,this.preY=NaN,t.__super.call(this)}__class(t,"laya.debug.tools.resizer.AutoFillRec",e);var i=t.prototype;return i.changeSize=function(){e.prototype.changeSize.call(this);var t=this.graphics;t.clear(),t.drawRect(0,0,this.width,this.height,"#33c5f5")},i.record=function(){this.preX=this.x,this.preY=this.y},i.getDx=function(){return this.x-this.preX},i.getDy=function(){return this.y-this.preY},t}(Component),TipManagerForDebug=function(e){function t(){this._tipBox=null,this._tipText=null,this._defaultTipHandler=null,t.__super.call(this),this._tipBox=new Component,this._tipBox.addChild(this._tipText=new Text),this._tipText.x=this._tipText.y=5,this._tipText.color=t.tipTextColor,this._defaultTipHandler=this.showDefaultTip,Laya.stage.on("showtip",this,this.onStageShowTip),Laya.stage.on("hidetip",this,this.onStageHideTip)}__class(t,"laya.debug.tools.TipManagerForDebug",e);var i=t.prototype;return i.onStageHideTip=function(e){Laya.timer.clear(this,this.showTip),this.closeAll(),this.removeSelf()},i.onStageShowTip=function(e){Laya.timer.once(t.tipDelay,this,this.showTip,[e],!0)},i.showTip=function(e){if("string"==typeof e){var t=String(e);Boolean(t)&&this._defaultTipHandler(t)}else e instanceof laya.utils.Handler?e.run():"function"==typeof e&&e.apply();Laya.stage.on("mousemove",this,this.onStageMouseMove),Laya.stage.on("mousedown",this,this.onStageMouseDown),this.onStageMouseMove(null)},i.onStageMouseDown=function(e){this.closeAll()},i.onStageMouseMove=function(e){this.showToStage(this,t.offsetX,t.offsetY)},i.showToStage=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var o=e.getBounds();e.x=Laya.stage.mouseX+t,e.y=Laya.stage.mouseY+i,e.x+o.width>Laya.stage.width&&(e.x-=o.width+t),e.y+o.height>Laya.stage.height&&(e.y-=o.height+i)},i.closeAll=function(){Laya.timer.clear(this,this.showTip),Laya.stage.off("mousemove",this,this.onStageMouseMove),Laya.stage.off("mousedown",this,this.onStageMouseDown),this.removeChildren()},i.showDisTip=function(e){this.addChild(e),this.showToStage(this),Laya.stage.addChild(this)},i.showDefaultTip=function(e){this._tipText.text=e;var i=this._tipBox.graphics;i.clear(),i.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,t.tipBackColor),this.addChild(this._tipBox),this.showToStage(this),Laya.stage.addChild(this)},__getset(0,i,"defaultTipHandler",function(){return this._defaultTipHandler},function(e){this._defaultTipHandler=e}),t.offsetX=10,t.offsetY=15,t.tipTextColor="#ffffff",t.tipBackColor="#111111",t.tipDelay=200,t}(Component),UIViewBase=function(e){function t(){this.minHandler=null,this.maxHandler=null,this.isFirstShow=!0,this.dis=null,t.__super.call(this),this.dis=this,this.minHandler=new Handler(this,this.close),this.maxHandler=new Handler(this,this.show),this.createPanel(),this.dis&&(this.dis.on("mousedown",this,this.bringToTop),this.dis.cacheAsBitmap=!0)}__class(t,"laya.debug.view.nodeInfo.views.UIViewBase",e);var i=t.prototype;return i.show=function(){DebugInfoLayer.I.setTop(),DebugInfoLayer.I.popLayer.addChild(this.dis),this.isFirstShow&&(this.firstShowFun(),this.isFirstShow=!1)},i.firstShowFun=function(){this.dis.x=.5*(Laya.stage.width-this.dis.width),this.dis.y=.5*(Laya.stage.height-this.dis.height),DisControlTool.intFyDisPos(this.dis)},i.bringToTop=function(){DisControlTool.setTop(this.dis)},i.switchShow=function(){this.dis.parent?this.close():this.show()},i.close=function(){this.dis.removeSelf()},i.createPanel=function(){},i.getInput=function(){var e;return e=new DInput,e.size(200,30),e.fontSize=30,e},i.getButton=function(){var e;return e=new DButton,e.size(40,30),e.fontSize=30,e},t}(Component),ReCacheRecInfo=function(e){function t(){this.isWorking=!1,this.count=0,this.mTime=0,t.__super.call(this),this.txt.fontSize=12}__class(t,"laya.debug.view.nodeInfo.recinfos.ReCacheRecInfo",e);var i=t.prototype;return i.addCount=function(e){void 0===e&&(e=0),this.count++,this.mTime+=e,this.isWorking||(this.working=!0)},i.updates=function(){this._tar.displayedInStage||(this.working=!1,this.removeSelf()),this.txt.text=ClassTool.getNodeClassAndName(this._tar)+"\nreCache:"+this.count+"\ntime:"+this.mTime,this.count>0?(this.fresh(),Laya.timer.clear(this,this.removeSelfLater)):(this.working=!1,Laya.timer.once(3e3,this,this.removeSelfLater)),this.count=0,this.mTime=0},i.removeSelfLater=function(){this.working=!1,this.removeSelf()},__getset(0,i,"working",null,function(e){this.isWorking=e,e?Laya.timer.loop(1e3,this,this.updates):Laya.timer.clear(this,this.updates)}),t.showTime=3e3,t}(NodeRecInfo),DInput=function(e){function t(){t.__super.call(this),this.bgColor="#11ff00"}return __class(t,"laya.debug.tools.debugUI.DInput",e),t}(Input),ContextMenu=function(e){function t(){this._tY=0,t.__super.call(this),StyleConsts.setViewScale(this)}__class(t,"laya.debug.uicomps.ContextMenu",e);var i=t.prototype;return i.addItem=function(e){this.addChild(e),e.y=this._tY,this._tY+=e.height,e.on("mousedown",this,this.onClick)},i.onClick=function(e){this.event("select",e),this.removeSelf()},i.show=function(e,i){void 0===e&&(e=-999),void 0===i&&(i=-999),Laya.timer.once(100,this,t.showMenu,[this,e,i])},t.init=function(){Laya.stage.on("click",null,t.cleanMenu)},t.cleanMenu=function(e){var i=0,o=0;for(o=t._menuList.length,i=0;o>i;i++)t._menuList[i]&&t._menuList[i].removeSelf();t._menuList.length=0},t.showMenu=function(e,i,o){void 0===i&&(i=-999),void 0===o&&(o=-999),t.cleanMenu(),t.adptMenu(e),Laya.stage.addChild(e),DisControlTool.showToStage(e),-999!=i&&-999!=o&&e.pos(i,o),t._menuList.push(e)},t.createMenu=function(e){var i=arguments;return t.createMenuByArray(i)},t.createMenuByArray=function(e){for(var i,o=new t,n=!1,s=0,a=e.length;a>s;s++){var r=e[s],l={};"string"==typeof r?l.label=r:l=r,""!=l.label?(i=new ContextMenuItem(l.label,n),i.data=r,o.addItem(i),n=!1):(i=new ContextMenuItem("",n),i.data=r,o.addItem(i),n=!0)}return o},t.adptMenu=function(e){var t=80,i=80,o=0,n=e.numChildren;for(o=0;n>o;o++)t=e.getChildAt(o).width,t>i&&(i=t);for(o=0;n>o;o++)e.getChildAt(o).width=i},t._menuList=[],t}(Box),ContextMenuItem=function(e){function t(e,i){this.data=null,this.img=null,t.__super.call(this),this.img||(this.img=new Image),""!=e?(this.label=e,this.name=e):(this.label="------",this.height=5,this.mouseEnabled=!1,this.img.skin=Base64AtlasManager.base64.getAdptUrl("comp/line2.png"),this.img.sizeGrid="0,2,0,2",this.addChild(this.img)),this.labelColors="#000000,#000000,#000000,#000000",this._text.x=10,this._text.padding=[-2,0,0,0],this._text.align="left",this._text.wordWrap=!1,this._text.typeset(),this.width=this._text.width+25,this.sizeGrid="3,3,3,3",this.skin=Base64AtlasManager.base64.getAdptUrl("comp/button1.png")}__class(t,"laya.debug.uicomps.ContextMenuItem",e);var i=t.prototype;return __getset(0,i,"width",e.prototype._$get_width,function(t){e.prototype._$set_width.call(this,t),this.img.width=this.width,this.img.x=0}),t}(Button),CacheRankView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.CacheRankView",e);var i=t.prototype;return i.createPanel=function(){this.view=new Rank,this.view.top=this.view.bottom=this.view.left=this.view.right=0,this.addChild(this.view),NodeMenu.I.setNodeListAction(this.view.itemList),this.view.closeBtn.on("click",this,this.close),this.view.freshBtn.on("click",this,this.fresh),this.view.itemList.scrollBar.hide=!0,this.view.autoUpdate.on("change",this,this.onAutoUpdateChange),this.dis=this,this.view.itemList.array=[],this.onAutoUpdateChange(),this.fresh()},i.onRightClick=function(){var e;if(e=this.view.itemList,e.selectedItem){var t;t=e.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.onAutoUpdateChange=function(){this.autoUpdate=this.view.autoUpdate.selected},i.fresh=function(){CacheAnalyser.counter.updates(),this.view.title.text="ReCache排行",DebugTool.enableCacheAnalyse||(this.view.title.text="ReCache排行(未开启)",this.view.title.toolTip="DebugTool.init(true)可开启该功能");var e;e=CacheAnalyser.counter.resultNodeDic;var i,o,n,s;s=[];for(i in e)o=e[i],t.filterDebugNodes&&DisControlTool.isInTree(DebugInfoLayer.I,o)||CacheAnalyser.counter.getCount(o)<=0||(n={},n.time=CacheAnalyser.counter.getCount(o),n.path=o,n.label=ClassTool.getNodeClassAndName(o)+":"+n.time,s.push(n));s.sort(MathTools.sortByKey("time",!0,!0)),this.view.itemList.array=s},__getset(0,i,"autoUpdate",null,function(e){Laya.timer.clear(this,this.fresh),e&&(this.fresh(),Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.fresh))}),__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.filterDebugNodes=!0,t}(UIViewBase),DebugPanelView=function(e){function t(){this.view=null,this.dragIcon=null,this.tSelectTar=null,this._selectTip=new Sprite,t.__super.call(this),this._selectTip.setBounds(new Rectangle(0,0,0,0))}__class(t,"laya.debug.view.nodeInfo.views.DebugPanelView",e);var i=t.prototype;return i.createPanel=function(){this.view=new DebugPanel,this.dis=this.view,this.view.minBtn.minHandler=this.minHandler,this.view.minBtn.maxHandler=this.maxHandler,this.view.minBtn.tar=this.view,DisControlTool.setDragingItem(this.view.bg,this.view),DisControlTool.setDragingItem(this.view.tab,this.view),DisControlTool.setDragingItem(this.view.clearBtn,this.view),this.clickSelectChange(),this.view.selectWhenClick.on("change",this,this.clickSelectChange),Notice.listen("ItemClicked",this,this.itemClicked),StyleConsts.setViewScale(this.view),this.dragIcon=this.view.dragIcon,this.dragIcon.removeSelf(),this.view.mouseAnalyseBtn.on("mousedown",this,this.mouseAnalyserMouseDown),this.dragIcon.on("dragend",this,this.mouseAnalyserDragEnd),this.view.clearBtn.on("mousedown",this,this.clearBtnClick)},i.clearBtnClick=function(){DebugTool.clearDebugLayer()},i.mouseAnalyserMouseDown=function(){var e=t.tempPos;e.setTo(0,0),e=this.view.mouseAnalyseBtn.localToGlobal(e),this.dragIcon.pos(e.x,e.y),this.dragIcon.mouseEnabled=!1,Laya.stage.addChild(this.dragIcon),this.dragIcon.startDrag()},i.mouseAnalyserDragEnd=function(){this.dragIcon.removeSelf(),this.selectTarget(DisplayHook.instance.getDisUnderMouse()),NodeToolView.I.showByNode(DisplayHook.instance.getDisUnderMouse(),!1)},i.switchToTree=function(){this.view.tab.selectedIndex=0},i.swichToSelect=function(){this.view.tab.selectedIndex=1},i.itemClicked=function(e){t.isClickSelectState&&(t.ignoreDebugTool&&DebugInfoLayer.I.isDebugItem(e)||e instanceof laya.debug.uicomps.ContextMenuItem||e.parent instanceof laya.debug.uicomps.ContextMenuItem||(ToolPanel.I.showSelectInStage(e),NodeToolView.I.showByNode(e,!1),this.view.selectWhenClick.selected=!1,DebugTool.showDisBound(e),this.clickSelectChange()))},i.selectTarget=function(e){e&&(ToolPanel.I.showSelectInStage(e),DebugTool.showDisBound(e))},i.clickSelectChange=function(){t.isClickSelectState=this.view.selectWhenClick.selected,Browser.onPC&&(this.tSelectTar=null,this.clearSelectTip(),t.isClickSelectState?Laya.timer.loop(200,this,this.updateSelectTar,null,!0):Laya.timer.clear(this,this.updateSelectTar))},i.clearSelectTip=function(){this._selectTip.removeSelf()},i.updateSelectTar=function(){if(this.clearSelectTip(),this.tSelectTar=DisplayHook.instance.getDisUnderMouse(),this.tSelectTar&&!DebugInfoLayer.I.isDebugItem(this.tSelectTar)){var e;e=this._selectTip.graphics,e.clear();var t;t=NodeUtils.getGRec(this.tSelectTar),DebugInfoLayer.I.popLayer.addChild(this._selectTip),e.drawRect(0,0,t.width,t.height,null,"#00ffff",2),this._selectTip.pos(t.x,t.y)}},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.ignoreDebugTool=!0,t.isClickSelectState=!1,__static(t,["tempPos",function(){return this.tempPos=new Point}]),t}(UIViewBase),FilterView=function(e){function t(){this.input=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.FilterView",e);var i=t.prototype;return i.createPanel=function(){this.input=new Input,this.input.size(400,500),this.input.multiline=!0,this.input.bgColor="#ff00ff",this.input.fontSize=24,this.addChild(this.input)},i.show=function(){this.input.text=NodeInfosItem.showValues.join("\n"),e.prototype.show.call(this)},i.close=function(){e.prototype.close.call(this),NodeInfosItem.showValues=this.input.text.split("\n")},t}(UIViewBase),FindSmallView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.FindSmallView",e);var i=t.prototype;return i.createPanel=function(){this.view=new FindNodeSmall,StyleConsts.setViewScale(this.view),DisControlTool.setDragingItem(this.view.bg,this.view),this.view.typeSelect.selectedIndex=1,this.view.closeBtn.on("click",this,this.close),this.view.findBtn.on("click",this,this.onFind),this.dis=this.view},i.onFind=function(){var e;e=this.view.findTxt.text,e=StringTool.trimSide(e);var t;t=0==this.view.typeSelect.selectedIndex?DebugTool.findNameHas(e,!1):DebugTool.findClassHas(Laya.stage,e),ToolPanel.I.showSelectItems(t),this.close()},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t}(UIViewBase),FindView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.FindView",e);var i=t.prototype;return i.createPanel=function(){this.view=new FindNode,DisControlTool.setDragingItem(this.view.bg,this.view),this.view.result.scrollBar.hide=!0,this.view.result.array=[],this.view.typeSelect.selectedIndex=1,this.view.closeBtn.on("click",this,this.close),this.view.findBtn.on("click",this,this.onFind),NodeMenu.I.setNodeListAction(this.view.result),this.dis=this.view},i.onRightClick=function(){var e;if(e=this.view.result,e.selectedItem){var t;t=e.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.onFind=function(){var e;e=this.view.findTxt.text,e=StringTool.trimSide(e);var t;t=0==this.view.typeSelect.selectedIndex?DebugTool.findNameHas(e,!1):DebugTool.findClassHas(Laya.stage,e),this.showFindResult(t)},i.showFindResult=function(e){if(e){var t=0,i=0;i=e.length;var o;o=[];var n,s;for(t=0;i>t;t++)s=e[t],n={},n.label=ClassTool.getNodeClassAndName(s),n.path=s,o.push(n);this.view.result.array=o}},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t}(UIViewBase),NodeListPanelView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.NodeListPanelView",e);var i=t.prototype;return i.createPanel=function(){this.view=new NodeListPanel,this.addChild(this.view),DisControlTool.setDragingItem(this.view.bg,this.view),NodeMenu.I.setNodeListAction(this.view.itemList),this.view.closeBtn.on("click",this,this.close),this.view.itemList.scrollBar.hide=!0,this.dis=this,this.view.itemList.array=[]},i.showList=function(e){this.view.itemList.array=e,this.show()},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.filterDebugNodes=!0,t}(UIViewBase),NodeToolView=function(e){function t(){this.view=null,this.dragIcon=null,this._tar=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.NodeToolView",e);var i=t.prototype;return i.show=function(){this.showByNode()},i.createPanel=function(){this.view=new NodeTool,this.addChild(this.view),this.view.on("click",this,this.onBtnClick),this.view.closeBtn.on("click",this,this.onCloseBtn),DisControlTool.setDragingItem(this.view.bg,this.view),this.dis=this.view,this.view.freshBtn.on("click",this,this.onFreshBtn),this.dragIcon=this.view.dragIcon,this.dragIcon.removeSelf(),this.dragIcon.on("dragend",this,this.mouseAnalyserDragEnd),this.view.mouseAnalyseBtn.on("mousedown",this,this.mouseAnalyserMouseDown)},i.mouseAnalyserMouseDown=function(){var e=t.tempPos;e.setTo(0,0),e=this.view.mouseAnalyseBtn.localToGlobal(e),this.dragIcon.pos(e.x,e.y),this.dragIcon.mouseEnabled=!1,Laya.stage.addChild(this.dragIcon),this.dragIcon.startDrag()},i.mouseAnalyserDragEnd=function(){this.dragIcon.removeSelf(),laya.debug.view.nodeInfo.views.NodeToolView.I.target&&MouseEventAnalyser.analyseNode(laya.debug.view.nodeInfo.views.NodeToolView.I.target)},i.onFreshBtn=function(){this._tar&&(this._tar.reCache(),this._tar.repaint())},i.onCloseBtn=function(){this.close()},i.onBtnClick=function(e){if(this._tar){var t;t=e.target,console.log("onBtnClick:",t);var i;switch(i=t.label){case"父链":DebugTool.showParentChain(this._tar),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"子":DebugTool.showAllChild(this._tar),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"兄弟":DebugTool.showAllBrother(this._tar),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"Enable链":OutPutView.I.dTrace(DebugTool.traceDisMouseEnable(this._tar)),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"Size链":OutPutView.I.dTrace(DebugTool.traceDisSizeChain(this._tar)),SelectInfosView.I.setSelectList(DebugTool.selectedNodes);break;case"隐藏旁支":NodeInfoPanel.I.recoverNodes(),NodeInfoPanel.I.hideOtherChain(this._tar);break;case"隐藏兄弟":NodeInfoPanel.I.recoverNodes(),NodeInfoPanel.I.hideBrothers(this._tar);break;case"隐藏子":NodeInfoPanel.I.recoverNodes(),NodeInfoPanel.I.hideChilds(this._tar);break;case"恢复":NodeInfoPanel.I.recoverNodes();break;case"节点树定位":ToolPanel.I.showSelectInStage(this._tar);break;case"显示边框":DebugTool.showDisBound(this._tar);break;case"输出到控制台":console.log(this._tar);break;case"显示切换":this._tar.visible=!this._tar.visible}}},i.showByNode=function(t,i){void 0===i&&(i=!0),t||(t=Laya.stage),i&&e.prototype.show.call(this),this._tar=t,this.fresh()},i.fresh=function(){this._tar&&(this.view.tarTxt.text=ClassTool.getNodeClassAndName(this._tar))},__getset(0,i,"target",function(){return this._tar}),__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,__static(t,["tempPos",function(){return this.tempPos=new Point}]),t}(UIViewBase),NodeTreeSettingView=function(e){function t(){this.view=null,this._handler=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.NodeTreeSettingView",e);var i=t.prototype;return i.createPanel=function(){e.prototype.createPanel.call(this),this.view=new NodeTreeSetting,StyleConsts.setViewScale(this.view),this.addChild(this.view),this.inits(),this.dis=this.view},i.show=function(){e.prototype.show.call(this)},i.showSetting=function(e,t,i){i instanceof laya.display.Node?this.view.showTxt.text=NodeConsts.defaultFitlerStr.split(",").join("\n"):this.view.showTxt.text=e.join("\n"),this._handler=t,this.show()},i.inits=function(){this.view.okBtn.on("click",this,this.onOkBtn),this.view.closeBtn.on("click",this,this.onCloseBtn),DisControlTool.setDragingItem(this.view.bg,this.view),this.dis=this.view},i.onCloseBtn=function(){this.close()},i.onOkBtn=function(){this.close();var e;e=this.view.showTxt.text.split("\n"),this._handler&&(this._handler.runWith([e]),this._handler=null)},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t}(UIViewBase),NodeTreeView=function(e){function t(){this.nodeTree=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.NodeTreeView",e);var i=t.prototype;return i.show=function(){this.showByNode()},i.showByNode=function(e){e||(e=Laya.stage),this.nodeTree.setDis(e)},i.createPanel=function(){e.prototype.createPanel.call(this),this.nodeTree||(this.nodeTree=new NodeTree),this.dis=null;var t;t=this.nodeTree,t.top=t.bottom=t.left=t.right=0,this.addChild(t),this.showByNode(Laya.stage)},i.showSelectInStage=function(e){this.showByNode(Laya.stage),this.nodeTree.selectByNode(e)},t}(UIViewBase),ObjectCreateView=function(e){function t(){this.view=null,this._menu=null,this._menuItems=["统计详情","增量详情"],this._tSelectKey=null,this.preInfo={},t.__super.call(this),t._I=this}__class(t,"laya.debug.view.nodeInfo.views.ObjectCreateView",e);var i=t.prototype;return i.createPanel=function(){this.view=new ObjectCreate,this.view.top=this.view.bottom=this.view.left=this.view.right=0,this.addChild(this.view),this.view.itemList.on(DebugTool.getMenuShowEvent(),this,this.onRightClick),this.view.closeBtn.on("click",this,this.close),this.view.freshBtn.on("click",this,this.fresh),this.view.itemList.scrollBar.hide=!0,this._menu=ContextMenu.createMenuByArray(this._menuItems),this._menu.on("select",this,this.onEmunSelect),this.fresh()},i.onEmunSelect=function(e){if(this._tSelectKey){var t=e.target.data;if("string"==typeof t){var i;i=t;var o;switch(i){case"统计详情":o=RunProfile.getRunInfo(this._tSelectKey),o&&OutPutView.I.showTxt(this._tSelectKey+" createInfo:\n"+o.traceSelfR());break;case"增量详情":o=RunProfile.getRunInfo(this._tSelectKey),o&&OutPutView.I.showTxt(this._tSelectKey+" createInfo:\n"+o.traceSelfR(o.changeO))}}}},i.onRightClick=function(){var e;if(e=this.view.itemList,e.selectedItem){var t;t=e.selectedItem.path,this._tSelectKey=t,this._tSelectKey&&this._menu.show()}},i.show=function(){this.fresh()},i.fresh=function(){var e;e=ClassCreateHook.I.createInfo;var t,i;i=[];var o,n;for(t in e)this.preInfo[t]||(this.preInfo[t]=0),o={},o.path=t,o.count=e[t], +o.add=e[t]-this.preInfo[t],o.add>0?o.label=t+":"+e[t]+" +"+o.add:o.label=t+":"+e[t],n=RunProfile.getRunInfo(t),n&&n.record(),o.rank=1e3*o.add+o.count,this.preInfo[t]=e[t],i.push(o);i.sort(MathTools.sortByKey("rank",!0,!0)),this.view.itemList.array=i},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t}(UIViewBase),ObjectInfoView=function(e){function t(){this.view=null,this.showKeys=["x","y","width","height","renderCost"],this._closeSettingHandler=null,this._tar=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.ObjectInfoView",e);var i=t.prototype;return i.createPanel=function(){e.prototype.createPanel.call(this),this.view=new ObjectInfo,StyleConsts.setViewScale(this.view),this.addChild(this.view),this.inits()},i.inits=function(){this.view.closeBtn.on("click",this,this.close),this.view.settingBtn.on("click",this,this.onSettingBtn),this.view.autoUpdate.on("change",this,this.onAutoUpdateChange),DisControlTool.setDragingItem(this.view.bg,this.view),DisControlTool.setResizeAbleEx(this.view),this._closeSettingHandler=new Handler(this,this.closeSetting),this.dis=this.view},i.onAutoUpdateChange=function(){this.autoUpdate=this.view.autoUpdate.selected},i.onSettingBtn=function(){NodeTreeSettingView.I.showSetting(this.showKeys,this._closeSettingHandler,this._tar)},i.reset=function(){this.showKeys=["x","y","width","height","renderCost"]},i.closeSetting=function(e){this.showKeys=e,this.fresh()},i.showObjectInfo=function(e){this._tar=e,this.fresh(),this.show(),this.onAutoUpdateChange()},i.fresh=function(){this._tar?(this.view.title.text=ClassTool.getNodeClassAndName(this._tar),this.view.showTxt.text=t.getObjValueStr(this._tar,this.showKeys,!1)):(this.view.showTxt.text="",this.view.title.text="未选中对象")},i.freshKeyInfos=function(){this.fresh()},i.close=function(){e.prototype.close.call(this),this.autoUpdate=!1,Pool.recover("ObjectInfoView",this)},i.show=function(){e.prototype.show.call(this)},__getset(0,i,"autoUpdate",null,function(e){Laya.timer.clear(this,this.freshKeyInfos),e&&Laya.timer.loop(2e3,this,this.freshKeyInfos)}),t.getObjValueStr=function(e,i,o){void 0===o&&(o=!0);var n,s=0,a=0;for(t._txts.length=0,a=i.length,o&&(e.name?t._txts.push(ClassTool.getClassName(e)+"("+e.name+")"):t._txts.push(ClassTool.getClassName(e))),s=0;a>s;s++)n=i[s],t._txts.push(n+":"+t.getNodeValue(e,n));return t._txts.join("\n")},t.getNodeValue=function(e,t){var i;if(e instanceof laya.display.Sprite){var o;switch(o=e,t){case"gRec":i=NodeUtils.getGRec(o).toString();break;case"gAlpha":i=NodeUtils.getGAlpha(o)+"";break;case"cmdCount":i=NodeUtils.getNodeCmdCount(o)+"";break;case"cmdAll":i=NodeUtils.getNodeCmdTotalCount(o)+"";break;case"nodeAll":i=""+NodeUtils.getNodeCount(o);break;case"nodeVisible":i=""+NodeUtils.getNodeCount(o,!0);break;case"nodeRender":i=""+NodeUtils.getRenderNodeCount(o);break;case"nodeReCache":i=""+NodeUtils.getReFreshRenderNodeCount(o);break;case"renderCost":i=""+RenderAnalyser.I.getTime(o);break;case"renderCount":i=""+RenderAnalyser.I.getCount(o);break;default:i=e[t]+""}}else i=e[t]+"";return i},t.showObject=function(e){var i;i=Pool.getItemByClass("ObjectInfoView",t),i.reset(),i.showObjectInfo(e)},t._txts=[],t}(UIViewBase),OutPutView=function(e){function t(){this.view=null,t.__super.call(this),DebugTool._logFun=t.log}__class(t,"laya.debug.view.nodeInfo.views.OutPutView",e);var i=t.prototype;return i.createPanel=function(){this.view=new OutPut,DisControlTool.setDragingItem(this.view.txt,this.view),DisControlTool.setDragingItem(this.view.bg,this.view),StyleConsts.setViewScale(this.view),this.view.txt.textField.overflow=Text.SCROLL,this.view.txt.textField.wordWrap=!0,this.view.on("mousewheel",this,this.mouseWheel),this.view.txt.text="",DisControlTool.setResizeAbleEx(this.view),this.view.closeBtn.on("click",this,this.close),this.view.clearBtn.on("click",this,this.onClearBtn),this.dis=this.view},i.onClearBtn=function(){this.clearText()},i.mouseWheel=function(e){this.view.txt.textField.scrollY-=10*e.delta},i.showTxt=function(e){this.view.txt.text=e,this.show(),this.view.txt.textField.scrollY=this.view.txt.textField.maxScrollY},i.clearText=function(){this.view.txt.text=""},i.dTrace=function(e){var t=arguments;this.view.txt.textField.scrollY>1e3&&(this.view.txt.text="");var i,o=0,n=0;for(n=t.length,i=t[0],o=1;n>o;o++)i+=" "+t[o];this.addStr(i)},i.addStr=function(e){this.view.txt.text+="\n"+e,this.show(),this.view.txt.textField.scrollY=this.view.txt.textField.maxScrollY},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t.log=function(e){t.I.addStr(e)},t._I=null,t}(UIViewBase),RenderCostRankView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.RenderCostRankView",e);var i=t.prototype;return i.createPanel=function(){this.view=new Rank,this.view.top=this.view.bottom=this.view.left=this.view.right=0,this.addChild(this.view),NodeMenu.I.setNodeListAction(this.view.itemList),this.view.closeBtn.on("click",this,this.close),this.view.freshBtn.on("click",this,this.fresh),this.view.itemList.scrollBar.hide=!0,this.view.autoUpdate.on("change",this,this.onAutoUpdateChange),this.dis=this,this.view.itemList.array=[],this.onAutoUpdateChange(),this.fresh(),Laya.timer.once(5e3,this,this.fresh)},i.onRightClick=function(){var e;if(e=this.view.itemList,e.selectedItem){var t;t=e.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.onAutoUpdateChange=function(){this.autoUpdate=this.view.autoUpdate.selected},i.fresh=function(){this.view.title.text="渲染用时排行("+NodeConsts.RenderCostMaxTime+"ms)";var e;e=RenderAnalyser.I.nodeDic;var i,o,n,s;s=[];for(i in e)o=e[i],t.filterDebugNodes&&DisControlTool.isInTree(DebugInfoLayer.I,o)||RenderAnalyser.I.getTime(o)<=0||(n={},n.time=RenderAnalyser.I.getTime(o),t.filterDebugNodes&&o==Laya.stage&&(n.time-=RenderAnalyser.I.getTime(DebugInfoLayer.I)),n.path=o,n.label=ClassTool.getNodeClassAndName(o)+":"+n.time,s.push(n));s.sort(MathTools.sortByKey("time",!0,!0)),this.view.itemList.array=s},__getset(0,i,"autoUpdate",null,function(e){Laya.timer.clear(this,this.fresh),e&&(this.fresh(),Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.fresh))}),__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.filterDebugNodes=!0,t}(UIViewBase),ResRankView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.ResRankView",e);var i=t.prototype;return i.createPanel=function(){this.view=new Rank,this.view.top=this.view.bottom=this.view.left=this.view.right=0,this.addChild(this.view),this.view.closeBtn.on("click",this,this.close),this.view.freshBtn.on("click",this,this.fresh),this.view.itemList.scrollBar.hide=!0,this.view.autoUpdate.on("change",this,this.onAutoUpdateChange),this.dis=this,this.view.itemList.array=[],this.view.itemList.on("rightclick",this,this.onRightClick),this.onAutoUpdateChange(),this.fresh()},i.onRightClick=function(){var e;e=this.view.itemList,e.selectedItem&&console.log(e.selectedItem.url)},i.onAutoUpdateChange=function(){this.autoUpdate=this.view.autoUpdate.selected},i.fresh=function(){this.view.title.text="图片缓存列表";var e;e=ResTools.getCachedResList();var t,i;i=[];var o=0,n=0;for(n=e.length,o=0;n>o;o++){t={};var s;s=e[o],s=s.replace(URL.rootPath,""),t.label=s,t.url=s,i.push(t)}this.view.itemList.array=i},__getset(0,i,"autoUpdate",null,function(e){Laya.timer.clear(this,this.fresh),e&&(this.fresh(),Laya.timer.loop(NodeConsts.RenderCostMaxTime,this,this.fresh))}),__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.filterDebugNodes=!0,t}(UIViewBase),SelectInfosView=function(e){function t(){this.showKeys=[],this.view=null,this.fliterTxt=null,this.itemList=null,t.__super.call(this),t._I=this,this.setSelectList(null)}__class(t,"laya.debug.view.nodeInfo.views.SelectInfosView",e);var i=t.prototype;return i.createPanel=function(){this.view=new SelectInfos,this.addChild(this.view),this.view.top=this.view.bottom=this.view.left=this.view.right=0,NodeMenu.I.setNodeListAction(this.view.selectList),this.view.closeBtn.on("click",this,this.close),this.view.selectList.scrollBar.hide=!0,this.dis=null,this.view.findBtn.on("click",this,this.onFindBtn),this.fliterTxt=this.view.fliterTxt,this.view.fliterTxt.on("enter",this,this.onFliterTxtChange),this.view.fliterTxt.on("blur",this,this.onFliterTxtChange)},i.onFliterTxtChange=function(e){var t;t=this.fliterTxt.text,""==t?0!=this.showKeys.length&&(this.showKeys.length=0,this.fresh()):t!=this.showKeys.join(",")&&(this.showKeys=t.split(","),this.fresh())},i.onFindBtn=function(){FindSmallView.I.show()},i.onRightClick=function(){var e;if(e=this.view.selectList,e.selectedItem){var t;t=e.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.setSelectTarget=function(e){e&&this.setSelectList([e])},i.setSelectList=function(e){this.itemList=e,this.fresh()},i.fresh=function(){var e;if(e=this.itemList,!e||e.length<1)return void(this.view.selectList.array=[]);var t,i,o=0,n=0;n=e.length;var s;for(s=[],o=0;n>o;o++)t=e[o],i={},i.label=this.getLabelTxt(t),i.path=t,s.push(i);this.view.selectList.array=s},i.getLabelTxt=function(e){var t;t=ClassTool.getNodeClassAndName(e);var i=0,o=0;for(o=this.showKeys.length,i=0;o>i;i++)t+=","+ObjectInfoView.getNodeValue(e,this.showKeys[i]);return t},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t}(UIViewBase),ToolBarView=function(e){function t(){this.view=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.ToolBarView",e);var i=t.prototype;return i.createPanel=function(){this.view=new ToolBar,this.addChild(this.view),DisControlTool.setDragingItem(this.view.bg,this.view),this.view.on("click",this,this.onBtnClick),this.view.minBtn.minHandler=this.minHandler,this.view.minBtn.maxHandler=this.maxHandler,this.view.minBtn.tar=this.view,this.clickSelectChange(),this.view.selectWhenClick.on("change",this,this.clickSelectChange),Notice.listen("ItemClicked",this,this.itemClicked),this.dis=this.view},i.itemClicked=function(e){t.isClickSelectState&&(DisControlTool.isInTree(this.view.selectWhenClick,e)||t.ignoreDebugTool&&DebugInfoLayer.I.isDebugItem(e))},i.clickSelectChange=function(){t.isClickSelectState=this.view.selectWhenClick.selected},i.firstShowFun=function(){this.dis.x=Laya.stage.width-this.dis.width-20,this.dis.y=5},i.onBtnClick=function(e){switch(e.target){case this.view.treeBtn:ToolPanel.I.switchShow("Tree");break;case this.view.findBtn:ToolPanel.I.switchShow("Find");break;case this.view.clearBtn:DebugTool.clearDebugLayer();break;case this.view.rankBtn:RenderCostRankView.I.show();break;case this.view.nodeRankBtn:ObjectCreateView.I.show();break;case this.view.cacheBtn:NodeUtils.showCachedSpriteRecs()}},__getset(1,t,"I",function(){return t._I||(t._I=new t),t._I},laya.debug.view.nodeInfo.views.UIViewBase._$SET_I),t._I=null,t.ignoreDebugTool=!0,t.isClickSelectState=!1,t}(UIViewBase),TxtInfoView=function(e){function t(){this.input=null,this.btn=null,t.__super.call(this)}__class(t,"laya.debug.view.nodeInfo.views.TxtInfoView",e);var i=t.prototype;return i.createPanel=function(){this.input=new Input,this.input.size(200,400),this.input.multiline=!0,this.input.bgColor="#ff00ff",this.input.fontSize=12,this.input.wordWrap=!0,this.addChild(this.input),this.btn=this.getButton(),this.btn.text="关闭",this.btn.size(50,20),this.btn.align="center",this.btn.on("mousedown",this,this.onCloseBtn),this.btn.pos(5,this.input.height+5),this.addChild(this.btn)},i.showInfo=function(e){this.input.text=e,this.show()},i.show=function(){DebugInfoLayer.I.setTop(),DebugInfoLayer.I.popLayer.addChild(this),this.x=Laya.stage.width-this.width,this.y=0},i.onCloseBtn=function(){this.close()},t}(UIViewBase),CodeUsedResUI=function(e){function t(){this.tab=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.CodeUsedResUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:359,y:91,skin:"comp/button1.png"},type:"Image"},{props:{x:309,y:283,skin:"comp/line2.png"},type:"Image"},{type:"Tab",child:[{props:{skin:"view/create.png",label:" 对象创建",width:70,height:17,name:"item0"},type:"CheckBox"},{props:{x:70,skin:"view/rendertime.png",label:"渲染用时",width:70,height:19,name:"item1"},type:"CheckBox"},{props:{x:140,skin:"view/cache.png",label:"Cache",width:70,height:16,name:"item2"},type:"CheckBox"}],props:{x:76,y:210,selectedIndex:0,"var":"tab"}}],props:{width:600,height:400,base64pic:!0}}}]),t}(View),ListItemUI=function(e){function t(){t.__super.call(this)}__class(t,"laya.debug.ui.debugui.comps.ListItemUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",props:{base64pic:!0,width:244,height:19},child:[{type:"Clip",props:{y:-1,skin:"comp/clip_selectBox.png",clipY:2,height:19,name:"selectBox",left:2,right:2,x:0}},{type:"Label",props:{x:25,text:"render",color:"#dcea36",width:77,height:17,name:"label",y:2,fontSize:12}},{type:"Clip",props:{skin:"comp/clip_tree_arrow.png",clipY:2,name:"arrow",x:8,y:4,mouseEnabled:!1}}]}}]),t}(View),RankListItemUI=function(e){function t(){t.__super.call(this)}__class(t,"laya.debug.ui.debugui.comps.RankListItemUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{y:-1,skin:"comp/clip_selectBox.png",clipY:2,height:19,name:"selectBox",left:0,right:0,x:0},type:"Clip"},{props:{text:"render",color:"#a0a0a0",height:15,name:"label",y:2,left:11,right:5,fontSize:12,x:11,width:163},type:"Label"}],props:{width:179,height:19}}}]),t}(View),DebugPanelUI=function(e){function t(){this.bg=null,this.minBtn=null,this.treePanel=null,this.selectWhenClick=null,this.profilePanel=null,this.resizeBtn=null,this.mouseAnalyseBtn=null,this.dragIcon=null,this.clearBtn=null,this.selectPanel=null,this.tab=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.DebugPanelUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.view.nodeInfo.nodetree.MinBtnComp",MinBtnComp),View.regComponent("laya.debug.view.nodeInfo.views.NodeTreeView",NodeTreeView),View.regComponent("laya.debug.view.nodeInfo.nodetree.Profile",Profile),View.regComponent("laya.debug.view.nodeInfo.views.SelectInfosView",SelectInfosView)},__static(t,["uiView",function(){return this.uiView={type:"View",props:{base64pic:!0,width:260,height:400},child:[{type:"Image",props:{x:205,y:254,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"}},{type:"Image",props:{y:0,skin:"view/bg_top.png",left:0,right:0}},{type:"MinBtnComp",props:{y:-3,"var":"minBtn",runtime:"laya.debug.view.nodeInfo.nodetree.MinBtnComp",right:-3,x:207}},{type:"NodeTree",props:{left:0,right:0,top:32,bottom:0,name:"节点树","var":"treePanel",runtime:"laya.debug.view.nodeInfo.views.NodeTreeView"}},{type:"CheckBox",props:{x:8,y:9,skin:"view/clickselect.png",toolTip:"点击选取","var":"selectWhenClick",mouseEnabled:!0,width:14,height:14}},{type:"Profile",props:{name:"性能",top:32,right:0,left:0,bottom:0,"var":"profilePanel",runtime:"laya.debug.view.nodeInfo.nodetree.Profile"}},{type:"Button",props:{x:169,y:247,skin:"view/resize.png",right:2,bottom:2,name:"resizeBtn","var":"resizeBtn",stateNum:3}},{type:"Clip",props:{y:9,skin:"view/clickanalyse.png","var":"mouseAnalyseBtn",toolTip:"拖动选取",left:33,x:33,clipY:3}},{type:"Clip",props:{y:0,skin:"view/clickanalyse.png","var":"dragIcon",x:33,clipY:3}},{type:"Button",props:{y:7,skin:"view/res.png",stateNum:2,toolTip:"清除边框","var":"clearBtn",right:34,x:184}},{type:"SelectInfos",props:{top:32,left:0,right:0,bottom:0,name:"选中","var":"selectPanel",runtime:"laya.debug.view.nodeInfo.views.SelectInfosView"}},{type:"Tab",props:{x:59,y:0,name:"tab","var":"tab",selectedIndex:0},child:[{type:"Button",props:{skin:"view/tab_panel.png",label:"节点",width:42,height:32,name:"item0",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:42,skin:"view/tab_panel.png",label:"查询",width:42,height:32,name:"item1",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:84,skin:"view/tab_panel.png",label:"性能",width:42,height:32,name:"item2",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}}]}]}}]),t}(View),FindNodeSmallUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.title=null,this.typeSelect=null,this.findTxt=null,this.findBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.FindNodeSmallUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:185,y:234,skin:"view/bg_tool.png",left:0,right:0,top:0,bottom:0,"var":"bg"},type:"Image"},{props:{x:185,y:15,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2},type:"Button"},{props:{x:6,y:4,text:"查找对象",width:67,height:20,color:"#288edf","var":"title"},type:"Label"},{props:{x:60,y:81,skin:"comp/combobox.png",labels:"name,class",width:63,height:21,"var":"typeSelect",sizeGrid:"5,35,5,5",labelColors:"#a0a0a0,#fffff,#ffffff#fffff"},type:"ComboBox"},{props:{x:27,y:83,text:"类型",width:27,height:20,color:"#288edf",align:"right"},type:"Label"},{props:{x:7,y:40,text:"包含内容",width:47,height:20,color:"#288edf",align:"right"},type:"Label"},{props:{x:60,y:37,skin:"comp/textinput.png",text:"Sprite",width:164,height:22,"var":"findTxt",sizeGrid:"5,5,5,5",color:"#a0a0a0"},type:"TextInput"},{props:{x:158,y:79,skin:"comp/button.png",label:"查找",width:65,height:23,"var":"findBtn",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"},type:"Button"}],props:{base64pic:!0,width:233,height:120}}}]),t}(View),FindNodeUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.title=null,this.typeSelect=null,this.findTxt=null,this.result=null,this.findBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.FindNodeUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.RankListItem",RankListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:185,y:234,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:185,y:15,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2},type:"Button"},{props:{x:6,y:4,text:"查找对象",width:67,height:20,color:"#88ef19","var":"title"},type:"Label"},{props:{x:52,y:75,skin:"comp/combobox.png",labels:"name,class",width:63,height:21,"var":"typeSelect",sizeGrid:"5,35,5,5",labelColors:"#a0a0a0,#fffff,#ffffff#fffff"},type:"ComboBox"},{props:{x:10,y:77,text:"类型",width:27,height:20,color:"#88ef19",align:"right"},type:"Label"},{props:{x:7,y:34,text:"包含内容",width:47,height:20,color:"#88ef19",align:"right"},type:"Label"},{props:{x:59,y:31,skin:"comp/textinput.png",text:"Sprite",width:131,height:22,"var":"findTxt",sizeGrid:"5,5,5,5",color:"#a0a0a0"},type:"TextInput"},{type:"List",child:[{type:"RankListItem",props:{y:30,left:5,right:5,name:"render",x:30,runtime:"laya.debug.uicomps.RankListItem"}}],props:{x:6,y:106,width:188,height:180,vScrollBarSkin:"comp/vscroll.png","var":"result"}},{props:{x:125,y:73,skin:"comp/button.png",label:"查找",width:65,height:23,"var":"findBtn",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"},type:"Button"}],props:{width:200,height:300,base64pic:!0}}}]),t}(View),MinBtnCompUI=function(e){function t(){this.minBtn=null,this.maxUI=null,this.bg=null,this.maxBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.MinBtnCompUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:7,y:8,skin:"comp/minBtn.png",stateNum:"3","var":"minBtn",width:22,height:20,toolTip:"最小化"},type:"Button"},{type:"Box",child:[{props:{x:0,y:0,skin:"view/bg_panel.png","var":"bg",width:36,height:36,sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:6,y:8,skin:"view/zoom_out.png",stateNum:"2","var":"maxBtn"},type:"Button"}],props:{"var":"maxUI"}}],props:{width:36,height:36,base64pic:!0}}}]),t}(View),NodeListPanelUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.title=null,this.itemList=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.NodeListPanelUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.RankListItem",RankListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:235,y:284,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:204,y:32,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2,visible:!0},type:"Button"},{props:{x:10,y:6,text:"节点信息",width:147,height:16,color:"#288edf","var":"title"},type:"Label"},{type:"List",child:[{type:"RankListItem",props:{left:5,right:5,name:"render",runtime:"laya.debug.uicomps.RankListItem"}}],props:{vScrollBarSkin:"comp/vscroll.png","var":"itemList",left:2,right:2,top:26,bottom:0,repeatX:1,x:20}}],props:{width:200,height:300}}}]),t}(View),NodeToolUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.tarTxt=null,this.freshBtn=null,this.mouseAnalyseBtn=null,this.dragIcon=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.NodeToolUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",props:{base64pic:!0,width:200,height:341},child:[{type:"Image",props:{x:195,y:244,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"}},{type:"Label",props:{x:9,y:5,text:"当前选中对象",width:67,height:16,color:"#a0a0a0"}},{type:"Button",props:{x:195,y:25,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2}},{type:"Label",props:{x:10,y:25,text:"当前对象",width:67,height:16,color:"#a0a0a0","var":"tarTxt"}},{type:"Button",props:{x:15,y:65,skin:"comp/button.png",label:"父链",width:39,height:23,mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:66,y:65,skin:"comp/button.png",label:"子",width:35,height:23,mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:112,y:65,skin:"comp/button.png",label:"兄弟",width:49,height:23,mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:13,y:117,skin:"comp/button.png",label:"Enable链",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:100,y:117,skin:"comp/button.png",label:"Size链",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Label",props:{x:14,y:97,text:"节点链信息",width:67,height:16,color:"#a0a0a0"}},{type:"Label",props:{x:15,y:45,text:"对象选取",width:67,height:16,color:"#a0a0a0"}},{type:"Label",props:{x:16,y:145,text:"节点显示",width:67,height:16,color:"#a0a0a0"}},{type:"Button",props:{x:13,y:164,skin:"comp/button.png",label:"隐藏旁支",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:100,y:164,skin:"comp/button.png",label:"隐藏兄弟",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:13,y:197,skin:"comp/button.png",label:"隐藏子",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:99,y:197,skin:"comp/button.png",label:"恢复",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Label",props:{x:15,y:228,text:"其他",width:67,height:16,color:"#a0a0a0"}},{type:"Button",props:{x:12,y:247,skin:"comp/button.png",label:"节点树定位",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:99,y:247,skin:"comp/button.png",label:"显示边框",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Label",props:{x:12,y:315,text:"Alt+A分析鼠标能否够点中对象",width:173,height:16,color:"#a0a0a0"}},{type:"Button",props:{x:156,y:1,skin:"view/refresh2.png","var":"freshBtn",left:156,toolTip:"recache节点"}},{type:"Button",props:{x:12,y:279,skin:"comp/button.png",label:"输出到控制台",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Button",props:{x:99,y:279,skin:"comp/button.png",label:"显示切换",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"}},{type:"Clip",props:{y:44,skin:"view/clickanalyse.png","var":"mouseAnalyseBtn",toolTip:"拖动到对象上方判断是否能够点中",left:84,x:84,clipY:3}},{type:"Clip",props:{y:35,skin:"view/clickanalyse.png","var":"dragIcon",x:94,clipY:3}}]}}]),t}(View),NodeTreeSettingUI=function(e){function t(){this.bg=null,this.showTxt=null,this.okBtn=null,this.closeBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.NodeTreeSettingUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:0,y:0,skin:"view/bg_panel.png",left:0,top:0,bottom:0,right:0,"var":"bg",width:200,height:300,sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:9,y:7,text:"要显示的属性",width:76,height:16,color:"#ffffff",align:"left"},type:"Label"},{props:{x:6,y:29,skin:"comp/textinput.png",text:"x\\ny\\nwidth\\nheight",width:188,height:230,multiline:!0,"var":"showTxt",color:"#a0a0a0",sizeGrid:"5,5,5,5"},type:"TextInput"},{props:{x:57,y:269,skin:"comp/button.png",label:"确定","var":"okBtn",mouseEnabled:"true",labelColors:"#ffffff,#ffffff,#ffffff,#ffffff"},type:"Button"},{props:{x:175,y:5,skin:"view/btn_close.png","var":"closeBtn"},type:"Button"}],props:{base64pic:!0,width:200,height:300}}}]),t}(View),NodeTreeUI=function(e){function t(){this.nodeTree=null,this.controlBar=null,this.settingBtn=null,this.freshBtn=null,this.fliterTxt=null,this.closeBtn=null,this.ifShowProps=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.NodeTreeUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.TreeListItem",TreeListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",props:{width:200,height:260,base64pic:!0},child:[{type:"Image",props:{x:-22,y:-47,skin:"view/bg_panel.png",width:211,height:206,left:0,right:0,top:0,bottom:0,sizeGrid:"5,5,5,5"}},{props:{y:0,skin:"view/bg_tool.png",left:0,right:0},type:"Image"},{type:"Tree",props:{x:0,scrollBarSkin:"comp/vscroll.png",width:195,height:229,"var":"nodeTree",left:0,right:0,top:38,bottom:20},child:[{type:"ListItem",props:{y:0,name:"render",left:0,right:0,runtime:"laya.debug.uicomps.TreeListItem"}}]},{type:"Box",props:{x:3,y:5,"var":"controlBar",left:3,right:3,top:5,height:23},child:[{type:"Button",props:{x:6,skin:"view/setting.png",stateNum:3,"var":"settingBtn",toolTip:"设置显示的属性",y:6}},{type:"Button",props:{y:6,skin:"view/refresh.png","var":"freshBtn",left:30,toolTip:"刷新数据"}},{type:"TextInput",props:{y:0,skin:"view/bg_top.png",height:22,"var":"fliterTxt",left:53,right:0,color:"#a0a0a0"}},{type:"Button",props:{x:172,y:2,skin:"view/btn_close.png","var":"closeBtn",right:1,visible:!1}}]},{props:{y:243,skin:"comp/checkbox.png",label:"显示属性","var":"ifShowProps",bottom:3,selected:!0,visible:!0,x:2,width:70,height:14,labelColors:"#a0a0a0,#fffff,#ffffff,#fffff"},type:"CheckBox"}]}}]),t}(View),ObjectCreateUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.itemList=null,this.freshBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.ObjectCreateUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.RankListItem",RankListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:215,y:264,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:184,y:12,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2,visible:!1},type:"Button"},{props:{x:11,y:5,text:"对象创建统计",width:83,height:16,color:"#288edf"},type:"Label"},{type:"List",child:[{type:"RankListItem",props:{y:0,left:5,right:5,name:"render",runtime:"laya.debug.uicomps.RankListItem"}}],props:{vScrollBarSkin:"comp/vscroll.png","var":"itemList",top:26,bottom:5,left:5,right:5,repeatX:1}},{props:{y:1,skin:"view/refresh2.png","var":"freshBtn",toolTip:"刷新数据",right:1,x:178},type:"Button"}],props:{width:200,height:300,base64pic:!0}}}]),t}(View),ObjectInfoUI=function(e){function t(){this.bg=null,this.title=null,this.showTxt=null,this.closeBtn=null,this.autoUpdate=null,this.settingBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.ObjectInfoUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:-1,y:0,skin:"view/bg_panel.png",left:-1,right:1,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:7,y:5,text:"对象类型",width:67,height:20,color:"#ffffff","var":"title",left:7,right:6},type:"Label"},{props:{x:2,skin:"comp/textinput.png",text:"属性内容",width:196,height:228,left:2,right:2,"var":"showTxt",top:25,bottom:20,editable:!1,multiline:!0,sizeGrid:"5,5,5,5",color:"#a0a0a0"},type:"TextArea"},{props:{x:178,y:4,skin:"view/btn_close.png","var":"closeBtn",top:4,right:2},type:"Button"},{props:{skin:"comp/checkbox.png",label:"自动刷新属性","var":"autoUpdate",bottom:2,x:3,labelColors:"#a0a0a0,#fffff,#ffffff,#fffff"},type:"CheckBox"},{props:{x:164,skin:"view/setting.png",stateNum:"3","var":"settingBtn",y:6,top:6,right:24,toolTip:"设置显示属性"},type:"Button"},{props:{x:179,y:257,skin:"view/resize.png",right:2,bottom:2,name:"resizeBtn",stateNum:3},type:"Button"}],props:{base64pic:!0,width:200,height:200}}}]),t}(View),OutPutUI=function(e){function t(){this.bg=null,this.txt=null,this.closeBtn=null,this.clearBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.OutPutUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){},__static(t,["uiView",function(){return this.uiView={type:"View",props:{width:300,height:200,base64pic:!0},child:[{type:"Image",props:{x:205,y:254,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"}},{type:"Label",props:{skin:"comp/textarea.png",text:"TextArea",color:"#a0a0a0","var":"txt",left:5,right:5,top:22,bottom:5,mouseEnabled:!0,sizeGrid:"3,3,3,3"}},{type:"Button",props:{x:185,y:15,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2}},{props:{x:253,y:1,skin:"view/re.png", +stateNum:"2","var":"clearBtn",right:25},type:"Button"},{props:{x:169,y:247,skin:"view/resize.png",right:2,bottom:2,name:"resizeBtn",stateNum:3},type:"Button"}]}}]),t}(View),ProfileUI=function(e){function t(){this.renderPanel=null,this.createPanel=null,this.cachePanel=null,this.tab=null,this.resPanel=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.ProfileUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.view.nodeInfo.views.RenderCostRankView",RenderCostRankView),View.regComponent("laya.debug.view.nodeInfo.views.ObjectCreateView",ObjectCreateView),View.regComponent("laya.debug.view.nodeInfo.views.CacheRankView",CacheRankView),View.regComponent("laya.debug.view.nodeInfo.views.ResRankView",ResRankView)},__static(t,["uiView",function(){return this.uiView={type:"View",props:{width:260,height:329,base64pic:!0},child:[{type:"Image",props:{y:0,skin:"view/bg_tool.png",right:0,left:0}},{type:"Rank",props:{"var":"renderPanel",top:29,runtime:"laya.debug.view.nodeInfo.views.RenderCostRankView",right:0,name:"渲染用时",left:0,bottom:0}},{type:"ObjectCreate",props:{"var":"createPanel",top:29,runtime:"laya.debug.view.nodeInfo.views.ObjectCreateView",right:0,name:"对象创建统计",left:0,bottom:0}},{type:"Rank",props:{x:10,"var":"cachePanel",top:29,runtime:"laya.debug.view.nodeInfo.views.CacheRankView",right:0,name:"cache用时",left:0,bottom:0}},{type:"Tab",props:{y:9,x:7,width:191,"var":"tab",selectedIndex:0,height:19},child:[{type:"CheckBox",props:{y:0,x:0,width:50,skin:"view/create.png",name:"item0",labelColors:"#a0a0a0,#ffffff,#ffffff,#ffffff",label:" 对象",height:17}},{type:"CheckBox",props:{y:0,x:55,width:50,skin:"view/rendertime.png",name:"item1",labelColors:"#a0a0a0,#ffffff,#ffffff,#ffffff",label:" 渲染",height:19}},{type:"CheckBox",props:{y:0,x:110,width:50,skin:"view/cache.png",name:"item2",labelColors:"#a0a0a0,#ffffff,#ffffff,#ffffff",label:" 重绘",height:16}},{type:"CheckBox",props:{y:0,x:165,width:50,skin:"view/cache.png",name:"item3",labelColors:"#a0a0a0,#ffffff,#ffffff,#ffffff",label:" 资源",height:16}}]},{type:"Rank",props:{y:40,x:50,"var":"resPanel",top:29,runtime:"laya.debug.view.nodeInfo.views.ResRankView",right:0,name:"资源缓存",left:0,bottom:0}}]}}]),t}(View),RankUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.title=null,this.itemList=null,this.autoUpdate=null,this.freshBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.RankUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.RankListItem",RankListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:225,y:274,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{x:194,y:22,skin:"view/btn_close.png","var":"closeBtn",top:2,right:2,visible:!1},type:"Button"},{props:{x:8,y:5,text:"渲染用时表(3000ms)",width:109,height:16,color:"#288edf","var":"title"},type:"Label"},{type:"List",child:[{type:"RankListItem",props:{left:5,right:5,name:"render",runtime:"laya.debug.uicomps.RankListItem"}}],props:{vScrollBarSkin:"comp/vscroll.png","var":"itemList",left:2,right:2,top:26,bottom:25,repeatX:1,x:10,y:10}},{props:{skin:"comp/checkbox.png",label:"自动刷新属性","var":"autoUpdate",bottom:3,selected:!1,visible:!0,left:2,labelColors:"#a0a0a0,#fffff,#ffffff,#fffff"},type:"CheckBox"},{props:{y:1,skin:"view/refresh2.png","var":"freshBtn",toolTip:"刷新数据",right:1},type:"Button"}],props:{width:200,height:300}}}]),t}(View),SelectInfosUI=function(e){function t(){this.bg=null,this.closeBtn=null,this.selectList=null,this.findBtn=null,this.fliterTxt=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.SelectInfosUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.uicomps.RankListItem",RankListItem)},__static(t,["uiView",function(){return this.uiView={type:"View",child:[{props:{x:205,y:254,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"},type:"Image"},{props:{skin:"view/btn_close.png","var":"closeBtn",top:32,visible:!1,right:2},type:"Button"},{props:{x:7,y:36,text:"当前选中列表",width:83,height:16,color:"#288edf"},type:"Label"},{type:"List",child:[{type:"RankListItem",props:{left:5,right:5,name:"render",runtime:"laya.debug.uicomps.RankListItem"}}],props:{vScrollBarSkin:"comp/vscroll.png","var":"selectList",left:5,right:5,top:56,bottom:25,repeatX:1,x:20}},{props:{x:6,text:"Alt+V选取鼠标下的对象",width:189,height:16,color:"#a0a0a0",bottom:3},type:"Label"},{type:"Image",props:{y:0,skin:"view/bg_tool.png",left:0,right:0}},{type:"Clip",props:{y:6,skin:"view/search.png",clipY:2,"var":"findBtn",right:5,toolTip:"查找",x:174}},{type:"TextInput",props:{y:6,skin:"view/bg_top.png",height:22,"var":"fliterTxt",left:8,right:45,color:"#a0a0a0",x:8,width:147}}],props:{width:200,height:300,base64pic:!0}}}]),t}(View),ToolBarUI=function(e){function t(){this.bg=null,this.treeBtn=null,this.findBtn=null,this.minBtn=null,this.selectWhenClick=null,this.clearBtn=null,this.rankBtn=null,this.nodeRankBtn=null,this.cacheBtn=null,t.__super.call(this)}__class(t,"laya.debug.ui.debugui.ToolBarUI",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists(),laya.ui.Component.prototype.createChildren.call(this),this.createView(t.uiView)},i.viewMapRegists=function(){View.regComponent("laya.debug.view.nodeInfo.nodetree.MinBtnComp",MinBtnComp)},__static(t,["uiView",function(){return this.uiView={type:"View",props:{base64pic:!0,width:250,height:30},child:[{type:"Image",props:{x:195,y:244,skin:"view/bg_panel.png",left:0,right:0,top:0,bottom:0,"var":"bg",sizeGrid:"5,5,5,5"}},{type:"Button",props:{x:2,y:6,skin:"view/save.png",stateNum:2,"var":"treeBtn",toolTip:"节点树"}},{type:"Button",props:{x:25,y:6,skin:"view/save.png",stateNum:2,"var":"findBtn",toolTip:"查找面板"}},{type:"MinBtnComp",props:{x:218,y:-3,"var":"minBtn",runtime:"laya.debug.view.nodeInfo.nodetree.MinBtnComp"}},{type:"CheckBox",props:{x:124,y:8,skin:"comp/checkbox.png",label:"点击选取","var":"selectWhenClick",labelColors:"#a0a0a0,#fffff,#ffffff,#fffff"}},{type:"Button",props:{x:193,y:5,skin:"view/res.png",stateNum:2,toolTip:"清除边框","var":"clearBtn"}},{type:"Button",props:{x:49,y:6,skin:"view/save.png",stateNum:2,"var":"rankBtn",toolTip:"渲染用时排行"}},{type:"Button",props:{x:72,y:6,skin:"view/save.png",stateNum:2,"var":"nodeRankBtn",toolTip:"创建对象排行"}},{type:"Button",props:{x:94,y:6,skin:"view/save.png",stateNum:2,"var":"cacheBtn",toolTip:"cache对象"}}]}}]),t}(View),ListBase=function(e){function t(){t.__super.call(this)}__class(t,"laya.debug.uicomps.ListBase",e);var i=t.prototype;return __getset(0,i,"selectedIndex",e.prototype._$get_selectedIndex,function(e){if(this._selectedIndex!=e&&(this._selectedIndex=e,this.changeSelectStatus(),this.event("change"),this.selectHandler&&this.selectHandler.runWith(e)),this.selectEnable&&this._scrollBar){var t=this._isVertical?this.repeatX:this.repeatY;(ethis._startIndex+this.repeatX*this.repeatY)&&this.scrollTo(e)}}),t}(List),TreeBase=function(e){function t(){t.__super.call(this)}__class(t,"laya.debug.uicomps.TreeBase",e);var i=t.prototype;return i.createChildren=function(){this.addChild(this._list=new ListBase),this._list.renderHandler=Handler.create(this,this.renderItem,null,!1),this._list.repeatX=1,this._list.on("change",this,this.onListChange)},t}(Tree),RankListItem=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(RankListItemUI.uiView),this.createView(RankListItemUI.uiView)}__class(t,"laya.debug.uicomps.RankListItem",e);var i=t.prototype;return i.createChildren=function(){},t}(RankListItemUI),TreeListItem=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(ListItemUI.uiView),this.createView(ListItemUI.uiView)}__class(t,"laya.debug.uicomps.TreeListItem",e);var i=t.prototype;return i.createChildren=function(){},t}(ListItemUI),DebugPanel=function(e){function t(){this.views=null,t.__super.call(this),this.msRec=new Rectangle,Base64AtlasManager.replaceRes(DebugPanelUI.uiView),this.createView(DebugPanelUI.uiView),DisControlTool.setResizeAbleEx(this),this.views=[this.treePanel,this.selectPanel,this.profilePanel],this.tab.selectedIndex=0,this.tabChange(),this.tab.on("change",this,this.tabChange),this.changeSize()}__class(t,"laya.debug.view.nodeInfo.nodetree.DebugPanel",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},i.tabChange=function(){DisControlTool.addOnlyByIndex(this.views,this.tab.selectedIndex,this),DisControlTool.setTop(this.resizeBtn)},i.changeSize=function(){this.width<245&&(this.width=245),this.height<100&&(this.height=200),laya.ui.Component.prototype.changeSize.call(this),this.msRec.setTo(0,0,this.width,this.height),this.scrollRect=this.msRec},t}(DebugPanelUI),FindNode=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(FindNodeUI.uiView),this.createView(FindNodeUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.FindNode",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},t}(FindNodeUI),FindNodeSmall=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(FindNodeSmallUI.uiView),this.createView(FindNodeSmallUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.FindNodeSmall",e);var i=t.prototype;return i.createChildren=function(){},t}(FindNodeSmallUI),MinBtnComp=function(e){function t(){this.tar=null,this.minHandler=null,this.maxHandler=null,this.prePos=new Point,t.__super.call(this),Base64AtlasManager.replaceRes(MinBtnCompUI.uiView),this.createView(MinBtnCompUI.uiView),this.init()}__class(t,"laya.debug.view.nodeInfo.nodetree.MinBtnComp",e);var i=t.prototype;return i.createChildren=function(){},i.init=function(){this.minBtn.on("click",this,this.onMinBtn),this.maxBtn.on("click",this,this.onMaxBtn),this.minState=!1,this.maxUI.removeSelf(),DisControlTool.setDragingItem(this.bg,this.maxUI)},i.onMaxBtn=function(){this.maxUI.removeSelf(),this.maxHandler&&this.maxHandler.run(),this.tar&&(this.tar.x+=this.maxUI.x-this.prePos.x,this.tar.y+=this.maxUI.y-this.prePos.y)},i.onMinBtn=function(){if(this.displayedInStage){var e;e=Point.TEMP,e.setTo(0,0),e=this.localToGlobal(e),e=DebugInfoLayer.I.popLayer.globalToLocal(e),this.maxUI.pos(e.x,e.y),DebugInfoLayer.I.popLayer.addChild(this.maxUI),this.tar&&this.prePos.setTo(e.x,e.y),this.minHandler&&this.minHandler.run()}},__getset(0,i,"minState",null,function(e){}),t}(MinBtnCompUI),NodeListPanel=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(NodeListPanelUI.uiView),this.createView(NodeListPanelUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.NodeListPanel",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},t}(NodeListPanelUI),NodeTool=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(NodeToolUI.uiView),this.createView(NodeToolUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.NodeTool",e);var i=t.prototype;return i.createChildren=function(){},t}(NodeToolUI),NodeTreeSetting=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(NodeTreeSettingUI.uiView),this.createView(NodeTreeSettingUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.NodeTreeSetting",e);var i=t.prototype;return i.createChildren=function(){},t}(NodeTreeSettingUI),NodeTree=function(e){function t(){this.showProps=!1,this._closeSettingHandler=null,this._tar=null,t.__super.call(this),Base64AtlasManager.replaceRes(NodeTreeUI.uiView),View.regComponent("Tree",TreeBase),this.createView(NodeTreeUI.uiView),View.regComponent("Tree",Tree),this.inits(),t.I=this}__class(t,"laya.debug.view.nodeInfo.nodetree.NodeTree",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},i.inits=function(){this.nodeTree.list.scrollBar.hide=!0,this.nodeTree.list.selectEnable=!0,this.settingBtn.on("click",this,this.onSettingBtn),this.freshBtn.on("click",this,this.fresh),this.closeBtn.on("click",this,this.onCloseBtn),this.fliterTxt.on("enter",this,this.onFliterTxtChange),this.fliterTxt.on("blur",this,this.onFliterTxtChange),NodeMenu.I.setNodeListAction(this.nodeTree.list),this.nodeTree.list.on("click",this,this.onListClick,[this.nodeTree.list]),this.nodeTree.renderHandler=new Handler(this,this.treeRender),this._closeSettingHandler=new Handler(this,this.closeSetting),this.onIfShowPropsChange(),this.ifShowProps.on("change",this,this.onIfShowPropsChange)},i.onIfShowPropsChange=function(){this.showProps=this.ifShowProps.selected,this.fresh()},i.onListClick=function(e){e.selectedItem&&e.selectedItem.isDirectory&&(e.selectedItem.isOpen=!e.selectedItem.isOpen,this.nodeTree.fresh())},i.onFindBtn=function(){FindSmallView.I.show()},i.onCloseBtn=function(){this.removeSelf()},i.onTreeDoubleClick=function(e){if(this.nodeTree.selectedItem){var t;t=this.nodeTree.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.onTreeRightMouseDown=function(e){if(this.nodeTree.selectedItem){var t;t=this.nodeTree.selectedItem.path,NodeMenu.I.objRightClick(t)}},i.onSettingBtn=function(){NodeTreeSettingView.I.showSetting(t.showKeys,this._closeSettingHandler,this._tar)},i.closeSetting=function(e){t.showKeys=e,this.fresh()},i.onFliterTxtChange=function(e){var i;i=this.fliterTxt.text,""!=i&&i!=t.showKeys.join(",")&&(t.showKeys=i.split(","),this.fresh())},i.selecteByFile=function(e){var t;t=this.nodeTree.source;var i;if(i=DebugTool.findNameHas(e,!1),i&&i.length>0){var o;o=i[0],this.parseOpen(t,o)}},i.showSelectInStage=function(e){this.setDis(Laya.stage),this.selectByNode(e)},i.selectByNode=function(e){if(e){var t;t=this.nodeTree.source,this.parseOpen(t,e)}},i.showNodeList=function(e){if(e){var t=0,i=0;i=e.length;var o;o=[];var n,s;for(t=0;i>t;t++)s=e[t],n={},n.label=ClassTool.getNodeClassAndName(s),n.path=s,o.push(n);this.nodeTree.array=o}},i.parseOpen=function(e,t){if(!(e.length<1)&&t){var i=0,o=0;o=e.length;var n;for(i=0;o>i;i++)if(n=e[i],n.path==t){var s;for(s=n;n;)n.isOpen=!0,this.nodeTree.fresh(),n=n.nodeParent;return void(this.nodeTree.selectedItem=s)}}},i.getFilterSource=function(e,t,i){i=i.toLocaleLowerCase();var o;for(var n in e)o=e[n],o.isDirectory&&String(o.label).toLowerCase().indexOf(i)>-1&&(o.x=0,t.push(o)),o.child&&o.child.length>0&&this.getFilterSource(o.child,t,i)},i.onControlDown=function(){this.startDrag()},i.setDis=function(e){this._tar=e,this.fresh()},i.fresh=function(){var e;if(this.nodeTree.selectedItem){var i;for(i=this.nodeTree.selectedItem;i&&!(i.path instanceof laya.display.Sprite);)i=i.nodeParent;i&&i.path&&(e=i.path)}this._tar?this.nodeTree.array=NodeUtils.getNodeTreeData(this._tar,this.showProps?t.showKeys:t.emptyShowKey):this.nodeTree.array=[],e&&this.selectByNode(e)},i.treeRender=function(e,t){var i=e.dataSource;if(i){var o=(i.child||i.isDirectory,e.getChildByName("label"));i.path instanceof laya.display.Node?o.color="#09a4f6":i.isChilds?o.color="#00ff11":o.color="#838bc5"}},t.I=null,t.emptyShowKey=[],__static(t,["showKeys",function(){return this.showKeys=["x","y","width","height","renderCost"]}]),t}(NodeTreeUI),ObjectCreate=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(ObjectCreateUI.uiView),this.createView(ObjectCreateUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.ObjectCreate",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},t}(ObjectCreateUI),ObjectInfo=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(ObjectInfoUI.uiView),this.createView(ObjectInfoUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.ObjectInfo",e);var i=t.prototype;return i.createChildren=function(){},t}(ObjectInfoUI),OutPut=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(OutPutUI.uiView),this.createView(OutPutUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.OutPut",e);var i=t.prototype;return i.createChildren=function(){},t}(OutPutUI),Profile=function(e){function t(){this.views=null,t.__super.call(this),Base64AtlasManager.replaceRes(ProfileUI.uiView),this.createView(ProfileUI.uiView),this.views=[this.createPanel,this.renderPanel,this.cachePanel,this.resPanel],this.tab.selectedIndex=0,this.tabChange(),this.tab.on("change",this,this.tabChange)}__class(t,"laya.debug.view.nodeInfo.nodetree.Profile",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},i.tabChange=function(){DisControlTool.addOnlyByIndex(this.views,this.tab.selectedIndex,this)},t}(ProfileUI),Rank=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(RankUI.uiView),this.createView(RankUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.Rank",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},t}(RankUI),SelectInfos=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(SelectInfosUI.uiView),this.createView(SelectInfosUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.SelectInfos",e);var i=t.prototype;return i.createChildren=function(){this.viewMapRegists()},t}(SelectInfosUI),ToolBar=function(e){function t(){t.__super.call(this),Base64AtlasManager.replaceRes(ToolBarUI.uiView),this.createView(ToolBarUI.uiView)}__class(t,"laya.debug.view.nodeInfo.nodetree.ToolBar",e);var i=t.prototype;return i.createChildren=function(){},t}(ToolBarUI)}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.device.min.js b/games/laya-snakes/libs/min/laya.device.min.js new file mode 100644 index 0000000..261f70e --- /dev/null +++ b/games/laya-snakes/libs/min/laya.device.min.js @@ -0,0 +1 @@ +!function(e,t,n){var i=(n.un,n.uns,n["static"]),a=n["class"],o=n.getset,r=(n.__newvec,laya.resource.Bitmap),s=laya.utils.Browser,c=(laya.events.Event,laya.events.EventDispatcher),l=(laya.utils.Handler,laya.maths.Rectangle,laya.renders.Render),d=laya.display.Sprite,h=(laya.display.Stage,laya.resource.Texture),u=laya.utils.Utils,v=laya.webgl.WebGL,m=laya.webgl.WebGLContext,g=(function(){function e(){}return a(e,"laya.device.geolocation.Geolocation"),e.getCurrentPosition=function(t,n){e.navigator.geolocation.getCurrentPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:laya.device.geolocation.Geolocation.enableHighAccuracy,timeout:laya.device.geolocation.Geolocation.timeout,maximumAge:laya.device.geolocation.Geolocation.maximumAge})},e.watchPosition=function(t,n){return e.navigator.geolocation.watchPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:e.enableHighAccuracy,timeout:e.timeout,maximumAge:e.maximumAge})},e.clearWatch=function(t){e.navigator.geolocation.clearWatch(t)},e.PERMISSION_DENIED=1,e.POSITION_UNAVAILABLE=2,e.TIMEOUT=3,e.enableHighAccuracy=!1,e.maximumAge=0,i(e,["navigator",function(){return this.navigator=s.window.navigator},"position",function(){return this.position=new g},"supported",function(){return this.supported=!!e.navigator.geolocation},"timeout",function(){return this.timeout=1e10}]),e}(),function(){function e(){this.pos=null,this.coords=null}a(e,"laya.device.geolocation.GeolocationInfo");var t=e.prototype;return t.setPosition=function(e){this.pos=e,this.coords=e.coords},o(0,t,"heading",function(){return this.coords.heading}),o(0,t,"latitude",function(){return this.coords.latitude}),o(0,t,"altitudeAccuracy",function(){return this.coords.altitudeAccuracy}),o(0,t,"longitude",function(){return this.coords.longitude}),o(0,t,"altitude",function(){return this.coords.altitude}),o(0,t,"accuracy",function(){return this.coords.accuracy}),o(0,t,"speed",function(){return this.coords.speed}),o(0,t,"timestamp",function(){return this.pos.timestamp}),e}()),f=function(){function e(){}return a(e,"laya.device.media.Media"),e.supported=function(){return!!s.window.navigator.getUserMedia},e.getMedia=function(e,t,n){s.window.navigator.getUserMedia&&s.window.navigator.getUserMedia(e,function(e){t.runWith(s.window.URL.createObjectURL(e))},function(e){n.runWith(e)})},e.__init$=function(){navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia},e}(),p=function(){function e(){this.x=NaN,this.y=NaN,this.z=NaN}return a(e,"laya.device.motion.AccelerationInfo"),e}(),y=function(){function e(){this.absolute=!1,this.alpha=NaN,this.beta=NaN,this.gamma=NaN,this.compassAccuracy=NaN}return a(e,"laya.device.motion.RotationInfo"),e}(),E=function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Accelerator",e);var r=t.prototype;return r.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("devicemotion",this.onDeviceOrientationChange),this},r.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("devicemotion",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},r.onDeviceOrientationChange=function(e){var n=e.interval;t.acceleration.x=e.acceleration.x,t.acceleration.y=e.acceleration.y,t.acceleration.z=e.acceleration.z,t.accelerationIncludingGravity.x=e.accelerationIncludingGravity.x,t.accelerationIncludingGravity.y=e.accelerationIncludingGravity.y,t.accelerationIncludingGravity.z=e.accelerationIncludingGravity.z,t.rotationRate.alpha=-1*e.rotationRate.gamma,t.rotationRate.beta=-1*e.rotationRate.alpha,t.rotationRate.gamma=e.rotationRate.beta,s.onAndriod?(t.onChrome&&(t.rotationRate.alpha*=180/Math.PI,t.rotationRate.beta*=180/Math.PI,t.rotationRate.gamma*=180/Math.PI),t.acceleration.x*=-1,t.accelerationIncludingGravity.x*=-1):s.onIOS&&(t.acceleration.y*=-1,t.acceleration.z*=-1,t.accelerationIncludingGravity.y*=-1,t.accelerationIncludingGravity.z*=-1,n*=1e3),this.event("change",[t.acceleration,t.accelerationIncludingGravity,t.rotationRate,n])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0),t._instance},laya.events.EventDispatcher._$SET_instance),t.getTransformedAcceleration=function(e){t.transformedAcceleration=t.transformedAcceleration||new p,t.transformedAcceleration.z=e.z,90==s.window.orientation?(t.transformedAcceleration.x=e.y,t.transformedAcceleration.y=-e.x):-90==s.window.orientation?(t.transformedAcceleration.x=-e.y,t.transformedAcceleration.y=e.x):s.window.orientation?180==s.window.orientation&&(t.transformedAcceleration.x=-e.x,t.transformedAcceleration.y=-e.y):(t.transformedAcceleration.x=e.x,t.transformedAcceleration.y=e.y);var i=NaN;return-90==n.stage.canvasDegree?(i=t.transformedAcceleration.x,t.transformedAcceleration.x=-t.transformedAcceleration.y,t.transformedAcceleration.y=i):90==n.stage.canvasDegree&&(i=t.transformedAcceleration.x,t.transformedAcceleration.x=t.transformedAcceleration.y,t.transformedAcceleration.y=-i),t.transformedAcceleration},t._instance=null,t.transformedAcceleration=null,i(t,["acceleration",function(){return this.acceleration=new p},"accelerationIncludingGravity",function(){return this.accelerationIncludingGravity=new p},"rotationRate",function(){return this.rotationRate=new y},"onChrome",function(){return this.onChrome=s.userAgent.indexOf("Chrome")>-1}]),t}(c),L=(function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Gyroscope",e);var n=t.prototype;return n.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("deviceorientation",this.onDeviceOrientationChange),this},n.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("deviceorientation",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},n.onDeviceOrientationChange=function(e){t.info.alpha=e.alpha,t.info.beta=e.beta,t.info.gamma=e.gamma,e.webkitCompassHeading&&(t.info.alpha=-1*e.webkitCompassHeading,t.info.compassAccuracy=e.webkitCompassAccuracy),this.event("change",[e.absolute,t.info])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0),t._instance},laya.events.EventDispatcher._$SET_instance),t._instance=null,i(t,["info",function(){return this.info=new y}]),t}(c),function(e){function t(){this.throushold=0,this.shakeInterval=0,this.callback=null,this.lastX=NaN,this.lastY=NaN,this.lastZ=NaN,this.lastMillSecond=NaN,t.__super.call(this)}a(t,"laya.device.Shake",e);var n=t.prototype;return n.start=function(e,t){this.throushold=e,this.shakeInterval=t,this.lastX=this.lastY=this.lastZ=NaN,E.instance.on("change",this,this.onShake)},n.stop=function(){E.instance.off("change",this,this.onShake)},n.onShake=function(e,t,n,i){if(isNaN(this.lastX))return this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z,void(this.lastMillSecond=s.now());var a=Math.abs(this.lastX-t.x),o=Math.abs(this.lastY-t.y),r=Math.abs(this.lastZ-t.z);if(this.isShaked(a,o,r)){var c=s.now()-this.lastMillSecond;c>this.shakeInterval&&(this.event("change"),this.lastMillSecond=s.now())}this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z},n.isShaked=function(e,t,n){return e>this.throushold&&t>this.throushold||e>this.throushold&&n>this.throushold||t>this.throushold&&n>this.throushold},o(1,t,"instance",function(){return t._instance=t._instance||new t,t._instance},laya.events.EventDispatcher._$SET_instance),t._instance=null,t}(c),function(e){function t(e,n){this.htmlVideo=null,this.videoElement=null,this.internalTexture=null,void 0===e&&(e=320),void 0===n&&(n=240),t.__super.call(this),l.isWebGL?this.htmlVideo=new T:this.htmlVideo=new w,this.videoElement=this.htmlVideo.getVideo(),this.videoElement.layaTarget=this,this.internalTexture=new h(this.htmlVideo),this.videoElement.addEventListener("abort",t.onAbort),this.videoElement.addEventListener("canplay",t.onCanplay),this.videoElement.addEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.addEventListener("durationchange",t.onDurationchange),this.videoElement.addEventListener("emptied",t.onEmptied),this.videoElement.addEventListener("error",t.onError),this.videoElement.addEventListener("loadeddata",t.onLoadeddata),this.videoElement.addEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.addEventListener("loadstart",t.onLoadstart),this.videoElement.addEventListener("pause",t.onPause),this.videoElement.addEventListener("play",t.onPlay),this.videoElement.addEventListener("playing",t.onPlaying),this.videoElement.addEventListener("progress",t.onProgress),this.videoElement.addEventListener("ratechange",t.onRatechange),this.videoElement.addEventListener("seeked",t.onSeeked),this.videoElement.addEventListener("seeking",t.onSeeking),this.videoElement.addEventListener("stalled",t.onStalled),this.videoElement.addEventListener("suspend",t.onSuspend),this.videoElement.addEventListener("timeupdate",t.onTimeupdate),this.videoElement.addEventListener("volumechange",t.onVolumechange),this.videoElement.addEventListener("waiting",t.onWaiting),this.videoElement.addEventListener("ended",this.onPlayComplete.bind(this)),this.size(e,n),s.onMobile&&(this.onDocumentClick=this.onDocumentClick.bind(this),s.document.addEventListener("touchend",this.onDocumentClick))}a(t,"laya.device.media.Video",e);var i=t.prototype;return i.onPlayComplete=function(e){n.timer.clear(this,this.renderCanvas),this.event("ended")},i.load=function(e){0==e.indexOf("blob:")?this.videoElement.src=e:this.htmlVideo.setSource(e,laya.device.media.Video.MP4)},i.play=function(){this.videoElement.play(),n.timer.frameLoop(1,this,this.renderCanvas)},i.pause=function(){this.videoElement.pause(),n.timer.clear(this,this.renderCanvas)},i.reload=function(){this.videoElement.load()},i.canPlayType=function(e){var t;switch(e){case laya.device.media.Video.MP4:t="video/mp4";break;case laya.device.media.Video.OGG:t="video/ogg";break;case laya.device.media.Video.WEBM:t="video/webm"}return this.videoElement.canPlayType(t)},i.renderCanvas=function(){0!==this.readyState&&(l.isWebGL&&this.htmlVideo.updateTexture(),this.graphics.clear(),this.graphics.drawTexture(this.internalTexture,0,0,this.width,this.height))},i.onDocumentClick=function(){this.videoElement.play(),this.videoElement.pause(),s.document.removeEventListener("touchend",this.onDocumentClick)},i.size=function(t,n){return e.prototype.size.call(this,t,n),this.videoElement.width=t/s.pixelRatio,this.paused&&this.renderCanvas(),this},i.destroy=function(n){void 0===n&&(n=!0),e.prototype.destroy.call(this,n),this.videoElement.removeEventListener("abort",t.onAbort),this.videoElement.removeEventListener("canplay",t.onCanplay),this.videoElement.removeEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.removeEventListener("durationchange",t.onDurationchange),this.videoElement.removeEventListener("emptied",t.onEmptied),this.videoElement.removeEventListener("error",t.onError),this.videoElement.removeEventListener("loadeddata",t.onLoadeddata),this.videoElement.removeEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.removeEventListener("loadstart",t.onLoadstart),this.videoElement.removeEventListener("pause",t.onPause),this.videoElement.removeEventListener("play",t.onPlay),this.videoElement.removeEventListener("playing",t.onPlaying),this.videoElement.removeEventListener("progress",t.onProgress),this.videoElement.removeEventListener("ratechange",t.onRatechange),this.videoElement.removeEventListener("seeked",t.onSeeked),this.videoElement.removeEventListener("seeking",t.onSeeking),this.videoElement.removeEventListener("stalled",t.onStalled),this.videoElement.removeEventListener("suspend",t.onSuspend),this.videoElement.removeEventListener("timeupdate",t.onTimeupdate),this.videoElement.removeEventListener("volumechange",t.onVolumechange),this.videoElement.removeEventListener("waiting",t.onWaiting),this.videoElement.removeEventListener("ended",this.onPlayComplete)},i.syncVideoPosition=function(){var e,t=n.stage;e=u.getGlobalPosAndScale(this);var i=t._canvasTransform.a,a=t._canvasTransform.d,o=e.x*t.clientScaleX*i+t.offset.x,r=e.y*t.clientScaleY*a+t.offset.y;this.videoElement.style.left=o+"px",this.videoElement.style.top=r+"px",this.videoElement.width=this.width/s.pixelRatio,this.videoElement.height=this.height/s.pixelRatio},o(0,i,"buffered",function(){return this.videoElement.buffered}),o(0,i,"videoWidth",function(){return this.videoElement.videoWidth}),o(0,i,"currentSrc",function(){return this.videoElement.currentSrc}),o(0,i,"currentTime",function(){return this.videoElement.currentTime},function(e){this.videoElement.currentTime=e,this.renderCanvas()}),o(0,i,"ended",function(){return this.videoElement.ended}),o(0,i,"volume",function(){return this.videoElement.volume},function(e){this.videoElement.volume=e}),o(0,i,"videoHeight",function(){return this.videoElement.videoHeight}),o(0,i,"readyState",function(){return this.videoElement.readyState}),o(0,i,"duration",function(){return this.videoElement.duration}),o(0,i,"error",function(){return this.videoElement.error}),o(0,i,"loop",function(){return this.videoElement.loop},function(e){this.videoElement.loop=e}),o(0,i,"playbackRate",function(){return this.videoElement.playbackRate},function(e){this.videoElement.playbackRate=e}),o(0,i,"muted",function(){return this.videoElement.muted},function(e){this.videoElement.muted=e}),o(0,i,"paused",function(){return this.videoElement.paused}),o(0,i,"preload",function(){return this.videoElement.preload},function(e){this.videoElement.preload=e}),o(0,i,"seekable",function(){return this.videoElement.seekable}),o(0,i,"seeking",function(){return this.videoElement.seeking}),o(0,i,"height",e.prototype._$get_height,function(t){e.prototype._$set_height.call(this,t),this.paused&&this.renderCanvas()}),o(0,i,"width",e.prototype._$get_width,function(t){this.videoElement.width=this.width/s.pixelRatio,e.prototype._$set_width.call(this,t),this.paused&&this.renderCanvas()}),t.onAbort=function(e){e.target.layaTarget.event("abort")},t.onCanplay=function(e){e.target.layaTarget.event("canplay")},t.onCanplaythrough=function(e){e.target.layaTarget.event("canplaythrough")},t.onDurationchange=function(e){e.target.layaTarget.event("durationchange")},t.onEmptied=function(e){e.target.layaTarget.event("emptied")},t.onError=function(e){e.target.layaTarget.event("error")},t.onLoadeddata=function(e){e.target.layaTarget.event("loadeddata")},t.onLoadedmetadata=function(e){e.target.layaTarget.event("loadedmetadata")},t.onLoadstart=function(e){e.target.layaTarget.event("loadstart")},t.onPause=function(e){e.target.layaTarget.event("pause")},t.onPlay=function(e){e.target.layaTarget.event("play")},t.onPlaying=function(e){e.target.layaTarget.event("playing")},t.onProgress=function(e){e.target.layaTarget.event("progress")},t.onRatechange=function(e){e.target.layaTarget.event("ratechange")},t.onSeeked=function(e){e.target.layaTarget.event("seeked")},t.onSeeking=function(e){e.target.layaTarget.event("seeking")},t.onStalled=function(e){e.target.layaTarget.event("stalled")},t.onSuspend=function(e){e.target.layaTarget.event("suspend")},t.onTimeupdate=function(e){e.target.layaTarget.event("timeupdate")},t.onVolumechange=function(e){e.target.layaTarget.event("volumechange")},t.onWaiting=function(e){e.target.layaTarget.event("waiting")},t.MP4=1,t.OGG=2,t.CAMERA=4,t.WEBM=8,t.SUPPORT_PROBABLY="probably",t.SUPPORT_MAYBY="maybe",t.SUPPORT_NO="",t}(d)),w=function(e){function t(){this.video=null,t.__super.call(this),this._w=1,this._h=1,this.createDomElement()}a(t,"laya.device.media.HtmlVideo",e);var n=t.prototype;return n.createDomElement=function(){var e=this;this._source=this.video=s.createElement("video");var t=this.video.style;t.position="absolute",t.top="0px",t.left="0px",this.video.addEventListener("loadedmetadata",function(){this._w=e.video.videoWidth,this._h=e.video.videoHeight}.bind(this))},n.setSource=function(e,t){for(;this.video.childElementCount;)this.video.firstChild.remove();t&L.MP4&&this.appendSource(e,"video/mp4"),t&L.OGG&&this.appendSource(e+".ogg","video/ogg")},n.appendSource=function(e,t){var n=s.createElement("source");n.src=e,n.type=t,this.video.appendChild(n)},n.getVideo=function(){return this.video},t.create=function(){return new t},t}(r),T=function(e){function t(){this.gl=null,this.preTarget=null,this.preTexture=null,t.__super.call(this),this.gl=v.mainContext,this._source=this.gl.createTexture(),this.preTarget=m.curBindTexTarget,this.preTexture=m.curBindTexValue,m.bindTexture(this.gl,3553,this._source),this.gl.texParameteri(3553,10242,33071),this.gl.texParameteri(3553,10243,33071),this.gl.texParameteri(3553,10240,9729),this.gl.texParameteri(3553,10241,9729),this.preTarget&&this.preTexture&&m.bindTexture(this.gl,this.preTarget,this.preTexture)}a(t,"laya.device.media.WebGLVideo",e);var n=t.prototype;return n.updateTexture=function(){m.bindTexture(this.gl,3553,this._source),this.gl.texImage2D(3553,0,6407,6407,5121,this.video)},t}(w);n.__init([f])}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.filter.min.js b/games/laya-snakes/libs/min/laya.filter.min.js new file mode 100644 index 0000000..f09f78a --- /dev/null +++ b/games/laya-snakes/libs/min/laya.filter.min.js @@ -0,0 +1 @@ +!function(t,e,i){var r=(i.un,i.uns,i["static"],i["class"]),a=i.getset,n=(i.__newvec,laya.webgl.canvas.BlendMode),l=(laya.utils.Browser,laya.utils.Color),s=laya.filters.ColorFilterAction,u=laya.filters.webgl.ColorFilterActionGL,o=laya.filters.Filter,c=laya.filters.webgl.FilterActionGL,h=laya.maths.Matrix,d=(laya.maths.Rectangle,laya.renders.Render),f=(laya.renders.RenderContext,laya.webgl.resource.RenderTarget2D),_=laya.utils.RunDriver,g=(laya.webgl.shader.d2.ShaderDefines2D,laya.display.Sprite,laya.webgl.submit.SubmitCMD),y=laya.resource.Texture,b=laya.webgl.shader.d2.value.Value2D,p=function(){function t(){this.data=null}r(t,"laya.filters.FilterAction");var e=t.prototype;return i.imps(e,{"laya.filters.IFilterAction":!0}),e.apply=function(t){return null},t}(),w=function(){function t(){}return r(t,"laya.filters.WebGLFilter"),t.enable=function(){t.isInit||(t.isInit=!0,d.isWebGL&&(_.createFilterAction=function(t){var e;switch(t){case 32:e=new u;break;case 16:e=new v;break;case 8:e=new x}return e}))},t.isInit=!1,t.__init$=function(){_.createFilterAction=function(t){var e;switch(t){case 16:e=new p;break;case 8:e=new p;break;case 32:e=new s}return e}},t}(),v=(function(t){function e(t){this.strength=NaN,e.__super.call(this),void 0===t&&(t=4),d.isWebGL&&w.enable(),this.strength=t,this._action=_.createFilterAction(16),this._action.data=this}r(e,"laya.filters.BlurFilter",t);var i=e.prototype;return i.callNative=function(t){t.model&&t.model.blurFilter&&t.model.blurFilter(this.strength)},a(0,i,"action",function(){return this._action}),a(0,i,"type",function(){return 16}),e}(o),function(t){function e(t,i,r,a){this._color=null,e.__super.call(this),this._elements=new Float32Array(9),void 0===i&&(i=4),void 0===r&&(r=6),void 0===a&&(a=6),d.isWebGL&&w.enable(),this._color=new l(t),this.blur=i,this.offX=r,this.offY=a,this._action=_.createFilterAction(8),this._action.data=this}r(e,"laya.filters.GlowFilter",t);var i=e.prototype;return i.getColor=function(){return this._color._color},i.callNative=function(t){t.model&&t.model.glowFilter&&t.model.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6])},a(0,i,"type",function(){return 8}),a(0,i,"action",function(){return this._action}),a(0,i,"offY",function(){return this._elements[6]},function(t){this._elements[6]=t}),a(0,i,"offX",function(){return this._elements[5]},function(t){this._elements[5]=t}),a(0,i,"blur",function(){return this._elements[4]},function(t){this._elements[4]=t}),e}(o),function(t){function e(){this.data=null,e.__super.call(this)}r(e,"laya.filters.webgl.BlurFilterActionGL",t);var i=e.prototype;return i.setValueMix=function(t){t.defines.add(this.data.type)},i.apply3d=function(t,e,i,r,a){var n=t.getValue("bounds"),l=b.create(1,0);l.setFilters([this.data]);var s=h.EMPTY;s.identity(),i.ctx.drawTarget(t,0,0,n.width,n.height,h.EMPTY,"src",l),l.setFilters(null)},i.setValue=function(t){t.strength=this.data.strength},a(0,i,"typeMix",function(){return 16}),e}(c)),x=function(t){function e(){this.data=null,this._initKey=!1,this._textureWidth=0,this._textureHeight=0,e.__super.call(this)}r(e,"laya.filters.webgl.GlowFilterActionGL",t);var l=e.prototype;return i.imps(l,{"laya.filters.IFilterActionGL":!0}),l.setValueMix=function(t){},l.apply3d=function(t,i,r,a,l){var s=t.getValue("bounds");t.addValue("color",this.data.getColor());var u=s.width,o=s.height;this._textureWidth=u,this._textureHeight=o;var c=g.create([t,i,r,0,0],e.tmpTarget);r.ctx.addRenderObject(c);var d,f=h.TEMP;return f.identity(),d=b.create(1,0),d.setFilters([this.data]),r.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,f,"src",d,null,n.TOINT.overlay),c=g.create([t,i,r,0,0],e.startOut),r.ctx.addRenderObject(c),d=b.create(1,0),r.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,f,"tmpTarget",d,y.INV_UV,n.TOINT.overlay),d=b.create(1,0),r.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,f,"src",d),c=g.create([t,i,r,0,0],e.recycleTarget),r.ctx.addRenderObject(c),null},l.setSpriteWH=function(t){this._textureWidth=t.width,this._textureHeight=t.height},l.setValue=function(t){t.u_offsetX=this.data.offX,t.u_offsetY=-this.data.offY,t.u_strength=1,t.u_blurX=this.data.blur,t.u_blurY=this.data.blur,t.u_textW=this._textureWidth,t.u_textH=this._textureHeight,t.u_color=this.data.getColor()},a(0,l,"typeMix",function(){return 8}),e.tmpTarget=function(t,e,i,r,a){var n=t.getValue("bounds"),l=t.getValue("out");l.end();var s=f.create(n.width,n.height);s.start();var u=t.getValue("color");u&&s.clear(u[0],u[1],u[2],0),t.addValue("tmpTarget",s)},e.startOut=function(t,e,i,r,a){var n=t.getValue("tmpTarget");n.end();var l=t.getValue("out");l.start();var s=t.getValue("color");s&&l.clear(s[0],s[1],s[2],0)},e.recycleTarget=function(t,e,i,r,a){var n=(t.getValue("src"),t.getValue("tmpTarget"));n.recycle()},e}(c);i.__init([w])}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.html.min.js b/games/laya-snakes/libs/min/laya.html.min.js new file mode 100644 index 0000000..b427772 --- /dev/null +++ b/games/laya-snakes/libs/min/laya.html.min.js @@ -0,0 +1 @@ +!function(window,document,Laya){var __un=Laya.un,__uns=Laya.uns,__static=Laya["static"],__class=Laya["class"],__getset=Laya.getset,__newvec=Laya.__newvec,Browser=laya.utils.Browser,CSSStyle=laya.display.css.CSSStyle,ClassUtils=laya.utils.ClassUtils,Event=laya.events.Event,HTMLChar=laya.utils.HTMLChar,Loader=laya.net.Loader,Node=laya.display.Node,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite,Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Texture=laya.resource.Texture,URL=laya.net.URL,Utils=laya.utils.Utils,HTMLParse=function(){function t(){}return __class(t,"laya.html.utils.HTMLParse"),t.parse=function(e,i,n){i=i.replace(/
    /g,"
    "),i=""+i+"",i=i.replace(t.spacePattern,t.char255);var s=Utils.parseXMLFromString(i);t._parseXML(e,s.childNodes[0].childNodes,n)},t._parseXML=function(e,i,n,s){var l=0,r=0;if(i.join||i.item)for(l=0,r=i.length;r>l;++l)t._parseXML(e,i[l],n,s);else{var a,h;if(3==i.nodeType){var o;return void(e instanceof laya.html.dom.HTMLDivElement?(null==i.nodeName&&(i.nodeName="#text"),h=i.nodeName.toLowerCase(),o=i.textContent.replace(/^\s+|\s+$/g,""),o.length>0&&(a=ClassUtils.getInstance(h),a&&(e.addChild(a),a.innerTEXT=o.replace(t.char255AndOneSpacePattern," ")))):(o=i.textContent.replace(/^\s+|\s+$/g,""),o.length>0&&(e.innerTEXT=o.replace(t.char255AndOneSpacePattern," "))))}if(h=i.nodeName.toLowerCase(),"#comment"==h)return;if(a=ClassUtils.getInstance(h)){a=e.addChild(a),a.URI=n,a.href=s;var _=i.attributes;if(_&&_.length>0)for(l=0,r=_.length;r>l;++l){var u=_[l],d=u.nodeName,c=u.value;a._setAttributes(d,c)}t._parseXML(a,i.childNodes,n,a.href)}else t._parseXML(e,i.childNodes,n,s)}},t.char255=String.fromCharCode(255),t.spacePattern=/ | /g,t.char255AndOneSpacePattern=new RegExp(String.fromCharCode(255)+"|(\\s+)","g"),t}(),Layout=function(){function t(){}return __class(t,"laya.html.utils.Layout"),t.later=function(e){null==t._will&&(t._will=[],Laya.stage.frameLoop(1,null,function(){if(!(t._will.length<1)){for(var e=0;eo;o++)if(s=n[o],null!=s)if(A=!1,s instanceof laya.html.dom.HTMLBrElement)i(),E.y=T,E.h=y;else{if(s._isChar()){if(a=s,a.isWord)C=R||"\n"===a["char"],E.wordStartIndex=E.elements.length;else{if(M.length>0&&v+S>f&&E.wordStartIndex>0){var U=0;U=E.elements.length-E.wordStartIndex+1,E.elements.length=E.wordStartIndex,o-=U,i();continue}C=!1,I+=a.width}S=a.width+d,H=a.height,R=!1,C=C||v+S>f,C&&i(),E.minTextHeight=Math.min(E.minTextHeight,s.height)}else l=s._getCSSStyle(),h=s,r=l.padding,0===l._getCssFloat()||(x=!0),C=R||l.lineElement,S=h.width*h._style._tf.scaleX+r[1]+r[3]+d,H=h.height*h._style._tf.scaleY+r[0]+r[2],R=l.lineElement,C=C||v+S>f&&l.wordWrap,C&&i();E.elements.push(s),E.h=Math.max(E.h,H),s.x=v,s.y=T,v+=S,E.w=v-d,E.y=T,p=Math.max(v+m,p)}else A||(v+=t.DIV_ELEMENT_PADDING),E.wordStartIndex=E.elements.length;if(T=E.y+E.h,x){var N=0,b=f;for(g&&e.width>0&&(b=e.width),o=0,_=M.length;_>o;o++)M[o].updatePos(0,b,o,N,L,w,y),N+=Math.max(y,M[o].h);T=N}return g&&(e.width=p),T>e.height&&(e.height=T),[p,T]},t._will=null,t.DIV_ELEMENT_PADDING=0,t}(),LayoutLine=function(){function t(){this.x=0,this.y=0,this.w=0,this.h=0,this.wordStartIndex=0,this.minTextHeight=99999,this.mWidth=0,this.elements=new Array}__class(t,"laya.html.utils.LayoutLine");var e=t.prototype;return e.updatePos=function(t,e,i,n,s,l,r){var a,h=0;this.elements.length>0&&(a=this.elements[this.elements.length-1],h=a.x+a.width-this.elements[0].x);var o=0,_=NaN;1===s&&(o=(e-h)/2),2===s&&(o=e-h),0===r||0!=l||(l=1);for(var u=0,d=this.elements.length;d>u;u++){a=this.elements[u];var c=a._getCSSStyle();switch(0!==o&&(a.x+=o),c._getValign()){case 0:a.y=n;break;case 1:var y=0;99999!=this.minTextHeight&&(y=this.minTextHeight);var g=(y+r)/2;g=Math.max(g,this.h),_=a instanceof laya.html.dom.HTMLImageElement?n+g-a.height:n+g-a.height,a.y=_;break;case 2:a.y=n+(r-a.height)}}},t}(),HTMLElement=function(_super){function HTMLElement(){this.URI=null,this._href=null,HTMLElement.__super.call(this),this._text=HTMLElement._EMPTYTEXT,this.setStyle(new CSSStyle(this)),this._getCSSStyle().valign="middle",this.mouseEnabled=!0}__class(HTMLElement,"laya.html.dom.HTMLElement",_super);var __proto=HTMLElement.prototype;return __proto.layaoutCallNative=function(){var t=0;if(this._childs&&(t=this._childs.length)>0)for(var e=0;t>e;e++)this._childs[e].layaoutCallNative&&this._childs[e].layaoutCallNative();var i=this._getWords();i&&HTMLElement.fillWords(this,i,0,0,this.style.font,this.style.color)},__proto.appendChild=function(t){return this.addChild(t)},__proto._getWords=function(){var t=this._text.text;if(!t||0===t.length)return null;var e=this._text.words;if(e&&e.length===t.length)return e;null===e&&(this._text.words=e=[]),e.length=t.length;for(var i,n=this.style,s=n.font,l=0,r=t.length;r>l;l++){i=Utils.measureText(t.charAt(l),s);var a=e[l]=new HTMLChar(t.charAt(l),i.width,i.height,n);if(this.href){var h=new Sprite;this.addChild(h),a.setSprite(h)}}return e},__proto.showLinkSprite=function(){var t=this._text.words;if(t)for(var e,i,n=[],s=0;s0||null!=this._getWords())&&t.block?(Layout.later(this),t._type|=512):this.parent&&this.parent._layoutLater())},__proto._setAttributes=function(t,e){switch(t){case"style":return void this.style.cssText(e);case"class":return void(this.className=e)}_super.prototype._setAttributes.call(this,t,e)},__proto.updateHref=function(){if(null!=this._href){var t=this._getWords();if(t)for(var e,i,n=0;nr;r++){var h=e[r];t.graphics.fillText(h["char"],h.x+i,h.y+n,s,l,"left")}},HTMLElement._EMPTYTEXT={text:null,words:null},HTMLElement}(Sprite),HTMLBrElement=function(t){function e(){e.__super.call(this),this.style.lineElement=!0,this.style.block=!0}return __class(e,"laya.html.dom.HTMLBrElement",t),e}(HTMLElement),HTMLDivElement=function(t){function e(){this.contextHeight=NaN,this.contextWidth=NaN,e.__super.call(this),this.style.block=!0,this.style.lineElement=!0,this.style.width=200,this.style.height=200}__class(e,"laya.html.dom.HTMLDivElement",t);var i=e.prototype;return i.appendHTML=function(t){HTMLParse.parse(this,t,this.URI),this.layout()},i._addChildsToLayout=function(t){var e=this._getWords();if(null==e&&0==this._childs.length)return!1;e&&e.forEach(function(e){t.push(e)});for(var i=!0,n=0,s=this._childs.length;s>n;n++){var l=this._childs[n];i?i=!1:t.push(null),l._addToLayout(t)}return!0},i._addToLayout=function(t){this.layout()},i.layout=function(){this.style._type|=512;var t=Layout.layout(this);if(t){this._$P.mHtmlBounds||this._set$P("mHtmlBounds",new Rectangle);var e=this._$P.mHtmlBounds;e.x=e.y=0,e.width=this.contextWidth=t[0],e.height=this.contextHeight=t[1],this.setBounds(e)}},__getset(0,i,"height",function(){return this._height?this._height:this.contextHeight},t.prototype._$set_height),__getset(0,i,"innerHTML",null,function(t){this.destroyChildren(),this.appendHTML(t)}),__getset(0,i,"width",function(){return this._width?this._width:this.contextWidth},t.prototype._$set_width),e}(HTMLElement),HTMLDocument=function(t){function e(){this.all=new Array,this.styleSheets=CSSStyle.styleSheets,e.__super.call(this)}__class(e,"laya.html.dom.HTMLDocument",t);var i=e.prototype;return i.getElementById=function(t){return this.all[t]},i.setElementById=function(t,e){this.all[t]=e},__static(e,["document",function(){return this.document=new e}]),e}(HTMLElement),HTMLImageElement=function(t){function e(){this._tex=null,this._url=null,this._renderArgs=[],e.__super.call(this),this.style.block=!0}__class(e,"laya.html.dom.HTMLImageElement",t);var i=e.prototype;return i._addToLayout=function(t){!this._style.absolute&&t.push(this)},i.render=function(t,e,i){!this._tex||!this._tex.loaded||!this._tex.loaded||this._width<1||this._height<1||(Stat.spriteCount++,this._renderArgs[0]=this._tex,this._renderArgs[1]=this.x,this._renderArgs[2]=this.y,this._renderArgs[3]=this.width||this._tex.width,this._renderArgs[4]=this.height||this._tex.height,t.ctx.drawTexture2(e,i,this.style.translateX,this.style.translateY,this.transform,this.style.alpha,this.style.blendMode,this._renderArgs))},__getset(0,i,"src",null,function(t){function e(){var t=i._style;t.widthed(i)?-1:i._tex.width,t.heighted(i)?-1:i._tex.height;t.widthed(i)||i._width==i._tex.width||(i.width=i._tex.width,i.parent&&i.parent._layoutLater()),t.heighted(i)||i._height==i._tex.height||(i.height=i._tex.height,i.parent&&i.parent._layoutLater()),Render.isConchApp&&(i._renderArgs[0]=i._tex,i._renderArgs[1]=i.x,i._renderArgs[2]=i.y,i._renderArgs[3]=i.width||i._tex.width,i._renderArgs[4]=i.height||i._tex.height,i.graphics.drawTexture(i._tex,0,0,i._renderArgs[3],i._renderArgs[4]))}var i=this;if(t=this.formatURL(t),this._url!=t){this._url=t,this._tex=Loader.getRes(t),this._tex||(this._tex=new Texture,this._tex.load(t),Loader.cacheRes(t,this._tex));var n=this._tex=Loader.getRes(t);n||(this._tex=n=new Texture,n.load(t),Loader.cacheRes(t,n)),n.loaded?e():n.on("loaded",null,e)}}),e}(HTMLElement),HTMLLinkElement=function(t){function e(){this.type=null,e.__super.call(this),this.visible=!1}__class(e,"laya.html.dom.HTMLLinkElement",t);var i=e.prototype;return i._onload=function(t){switch(this.type){case"text/css":CSSStyle.parseCSS(t,this.URI)}},__getset(0,i,"href",t.prototype._$get_href,function(t){var e=this;t=this.formatURL(t),this.URI=new URL(t);var i=new Loader;i.once("complete",null,function(t){e._onload(t)}),i.load(t,"text")}),e._cuttingStyle=new RegExp("((@keyframes[\\s\\t]+|)(.+))[\\t\\n\\r\\s]*{","g"),e}(HTMLElement),HTMLStyleElement=function(t){function e(){e.__super.call(this),this.visible=!1}__class(e,"laya.html.dom.HTMLStyleElement",t);var i=e.prototype;return __getset(0,i,"text",t.prototype._$get_text,function(t){CSSStyle.parseCSS(t,null)}),e}(HTMLElement),HTMLIframeElement=function(t){function e(){e.__super.call(this),this._getCSSStyle().valign="middle"}__class(e,"laya.html.dom.HTMLIframeElement",t);var i=e.prototype;return __getset(0,i,"href",t.prototype._$get_href,function(t){var e=this;t=this.formatURL(t);var i=new Loader;i.once("complete",null,function(i){var n=e.URI;e.URI=new URL(t),e.innerHTML=i,!n||(e.URI=n)}),i.load(t,"text")}),e}(HTMLDivElement)}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.particle.min.js b/games/laya-snakes/libs/min/laya.particle.min.js new file mode 100644 index 0000000..421c49d --- /dev/null +++ b/games/laya-snakes/libs/min/laya.particle.min.js @@ -0,0 +1 @@ +!function(t,e,i){var a=(i.un,i.uns,i["static"]),r=i["class"],n=i.getset,s=(i.__newvec,laya.webgl.canvas.BlendMode),o=(laya.events.Event,laya.resource.HTMLCanvas),l=laya.utils.Handler,h=laya.webgl.utils.IndexBuffer2D,c=(laya.net.Loader,laya.maths.MathUtil),u=laya.maths.Matrix,d=laya.renders.Render,m=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.webgl.shader.Shader),_=laya.display.Sprite,p=(laya.display.Stage,laya.utils.Stat),f=laya.resource.Texture,v=(laya.utils.Timer,laya.utils.Utils),x=laya.webgl.shader.d2.value.Value2D,y=laya.webgl.utils.VertexBuffer2D,P=laya.webgl.WebGL,C=(laya.webgl.WebGLContext,function(){function t(){this._frameTime=0,this._emissionRate=60,this._emissionTime=0,this.minEmissionTime=1/60,this._particleTemplate=null}r(t,"laya.particle.emitter.EmitterBase");var e=t.prototype;return e.start=function(t){void 0===t&&(t=1.7976931348623157e308),0!=this._emissionRate&&(this._emissionTime=t)},e.stop=function(){this._emissionTime=0},e.clear=function(){this._emissionTime=0},e.emit=function(){},e.advanceTime=function(t){if(void 0===t&&(t=1),this._emissionTime-=t,!(this._emissionTime<0||(this._frameTime+=t,this._frameTimethis.minEmissionTime;)this._frameTime-=this.minEmissionTime,this.emit()},n(0,e,"particleTemplate",null,function(t){this._particleTemplate=t}),n(0,e,"emissionRate",function(){return this._emissionRate},function(t){0>=t||(this._emissionRate=t,t>0&&(this.minEmissionTime=1/t))}),t}()),g=function(){function t(){this.position=null,this.velocity=null,this.startColor=null,this.endColor=null,this.sizeRotation=null,this.radius=null,this.radian=null,this.durationAddScale=NaN,this.time=NaN}return r(t,"laya.particle.ParticleData"),t.Create=function(e,i,a,r){var n=new t;n.position=i,c.scaleVector3(a,e.emitterVelocitySensitivity,t._tempVelocity);var s=c.lerp(e.minHorizontalVelocity,e.maxHorizontalVelocity,Math.random()),o=Math.random()*Math.PI*2;t._tempVelocity[0]+=s*Math.cos(o),t._tempVelocity[2]+=s*Math.sin(o),t._tempVelocity[1]+=c.lerp(e.minVerticalVelocity,e.maxVerticalVelocity,Math.random()),n.velocity=t._tempVelocity,n.startColor=t._tempStartColor,n.endColor=t._tempEndColor;var l=0;if(e.colorComponentInter)for(l=0;4>l;l++)n.startColor[l]=c.lerp(e.minStartColor[l],e.maxStartColor[l],Math.random()),n.endColor[l]=c.lerp(e.minEndColor[l],e.maxEndColor[l],Math.random());else c.lerpVector4(e.minStartColor,e.maxStartColor,Math.random(),n.startColor),c.lerpVector4(e.minEndColor,e.maxEndColor,Math.random(),n.endColor);n.sizeRotation=t._tempSizeRotation;var h=Math.random();n.sizeRotation[0]=c.lerp(e.minStartSize,e.maxStartSize,h),n.sizeRotation[1]=c.lerp(e.minEndSize,e.maxEndSize,h),n.sizeRotation[2]=c.lerp(e.minRotateSpeed,e.maxRotateSpeed,Math.random()),n.radius=t._tempRadius;var u=Math.random();n.radius[0]=c.lerp(e.minStartRadius,e.maxStartRadius,u),n.radius[1]=c.lerp(e.minEndRadius,e.maxEndRadius,u),n.radian=t._tempRadian,n.radian[0]=c.lerp(e.minHorizontalStartRadian,e.maxHorizontalStartRadian,Math.random()),n.radian[1]=c.lerp(e.minVerticalStartRadian,e.maxVerticalStartRadian,Math.random());var d=e.useEndRadian;return n.radian[2]=d?c.lerp(e.minHorizontalEndRadian,e.maxHorizontalEndRadian,Math.random()):n.radian[0],n.radian[3]=d?c.lerp(e.minVerticalEndRadian,e.maxVerticalEndRadian,Math.random()):n.radian[1],n.durationAddScale=e.ageAddScale*Math.random(),n.time=r,n},a(t,["_tempVelocity",function(){return this._tempVelocity=new Float32Array(3)},"_tempStartColor",function(){return this._tempStartColor=new Float32Array(4)},"_tempEndColor",function(){return this._tempEndColor=new Float32Array(4)},"_tempSizeRotation",function(){return this._tempSizeRotation=new Float32Array(3)},"_tempRadius",function(){return this._tempRadius=new Float32Array(2)},"_tempRadian",function(){return this._tempRadian=new Float32Array(4)}]),t}(),R=(function(){function t(t,e,i){this._templet=null,this._timeBetweenParticles=NaN,this._previousPosition=null,this._timeLeftOver=0,this._tempVelocity=new Float32Array([0,0,0]),this._tempPosition=new Float32Array([0,0,0]),this._templet=t,this._timeBetweenParticles=1/e,this._previousPosition=i}r(t,"laya.particle.ParticleEmitter");var e=t.prototype;return e.update=function(t,e){if(t/=1e3,t>0){c.subtractVector3(e,this._previousPosition,this._tempVelocity),c.scaleVector3(this._tempVelocity,1/t,this._tempVelocity);for(var i=this._timeLeftOver+t,a=-this._timeLeftOver;i>this._timeBetweenParticles;)a+=this._timeBetweenParticles,i-=this._timeBetweenParticles,c.lerpVector3(this._previousPosition,e,a/t,this._tempPosition),this._templet.addParticleArray(this._tempPosition,this._tempVelocity);this._timeLeftOver=i}this._previousPosition[0]=e[0],this._previousPosition[1]=e[1],this._previousPosition[2]=e[2]},t}(),function(){function t(){this.textureName=null,this.textureCount=1,this.maxPartices=100,this.duration=1,this.ageAddScale=0,this.emitterVelocitySensitivity=1,this.minStartSize=100,this.maxStartSize=100,this.minEndSize=100,this.maxEndSize=100,this.minHorizontalVelocity=0,this.maxHorizontalVelocity=0,this.minVerticalVelocity=0,this.maxVerticalVelocity=0,this.endVelocity=1,this.minRotateSpeed=0,this.maxRotateSpeed=0,this.minStartRadius=0,this.maxStartRadius=0,this.minEndRadius=0,this.maxEndRadius=0,this.minHorizontalStartRadian=0,this.maxHorizontalStartRadian=0,this.minVerticalStartRadian=0,this.maxVerticalStartRadian=0,this.useEndRadian=!0,this.minHorizontalEndRadian=0,this.maxHorizontalEndRadian=0,this.minVerticalEndRadian=0,this.maxVerticalEndRadian=0,this.colorComponentInter=!1,this.blendState=0,this.emitterType="null",this.emissionRate=0,this.sphereEmitterRadius=1,this.sphereEmitterVelocity=0,this.sphereEmitterVelocityAddVariance=0,this.ringEmitterRadius=30,this.ringEmitterVelocity=0,this.ringEmitterVelocityAddVariance=0,this.ringEmitterUp=2,this.gravity=new Float32Array([0,0,0]),this.minStartColor=new Float32Array([1,1,1,1]),this.maxStartColor=new Float32Array([1,1,1,1]),this.minEndColor=new Float32Array([1,1,1,1]),this.maxEndColor=new Float32Array([1,1,1,1]),this.pointEmitterPosition=new Float32Array([0,0,0]),this.pointEmitterPositionVariance=new Float32Array([0,0,0]),this.pointEmitterVelocity=new Float32Array([0,0,0]),this.pointEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.boxEmitterCenterPosition=new Float32Array([0,0,0]),this.boxEmitterSize=new Float32Array([0,0,0]),this.boxEmitterVelocity=new Float32Array([0,0,0]),this.boxEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.sphereEmitterCenterPosition=new Float32Array([0,0,0]),this.ringEmitterCenterPosition=new Float32Array([0,0,0]),this.positionVariance=new Float32Array([0,0,0])}return r(t,"laya.particle.ParticleSetting"),t.checkSetting=function(e){var i;for(i in t._defaultSetting)e.hasOwnProperty(i)||(e[i]=t._defaultSetting[i])},a(t,["_defaultSetting",function(){return this._defaultSetting=new t}]),t}()),S=function(){function t(){this.settings=null,this.texture=null}r(t,"laya.particle.ParticleTemplateBase");var e=t.prototype;return e.addParticleArray=function(t,e){},t}(),E=function(){function t(){this.u_Duration=NaN,this.u_EndVelocity=NaN,this.u_Gravity=null,this.a_Position=null,this.a_Velocity=null,this.a_StartColor=null,this.a_EndColor=null,this.a_SizeRotation=null,this.a_Radius=null,this.a_Radian=null,this.a_AgeAddScale=NaN,this.gl_Position=null,this.v_Color=null,this.oSize=NaN,this._color=new Float32Array(4),this._position=new Float32Array(3)}r(t,"laya.particle.particleUtils.CanvasShader");var e=t.prototype;return e.getLen=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])},e.ComputeParticlePosition=function(t,e,i,a){this._position[0]=t[0],this._position[1]=t[1],this._position[2]=t[2];var r=this.getLen(e),n=r*this.u_EndVelocity,s=r*a+(n-r)*a*a/2,o=NaN;o=this.getLen(e);var l=0,h=0;for(h=3,l=0;h>l;l++)this._position[l]+=this._position[l]+e[l]/o*s*this.u_Duration,this._position[l]+=this.u_Gravity[l]*i*a;var u=c.lerp(this.a_Radius[0],this.a_Radius[1],a),d=c.lerp(this.a_Radian[0],this.a_Radian[2],a),m=c.lerp(this.a_Radian[1],this.a_Radian[3],a),_=Math.cos(m)*u;return this._position[1]+=Math.sin(m)*u,this._position[0]+=Math.cos(d)*_,this._position[2]+=Math.sin(d)*_,new Float32Array([this._position[0],this._position[1],0,1])},e.ComputeParticleSize=function(t,e,i){var a=c.lerp(t,e,i);return a},e.ComputeParticleRotation=function(t,e){return t*e},e.ComputeParticleColor=function(t,e,i){var a=this._color;return c.lerpVector4(t,e,i,a),a[3]=a[3]*i*(1-i)*(1-i)*6.7,a},e.clamp=function(t,e,i){return e>t?e:t>i?i:t},e.getData=function(t){t*=1+this.a_AgeAddScale;var e=this.clamp(t/this.u_Duration,0,1);this.gl_Position=this.ComputeParticlePosition(this.a_Position,this.a_Velocity,t,e);var i=this.ComputeParticleSize(this.a_SizeRotation[0],this.a_SizeRotation[1],e),a=this.ComputeParticleRotation(this.a_SizeRotation[2],t);this.v_Color=this.ComputeParticleColor(this.a_StartColor,this.a_EndColor,e);var r=new u,n=NaN;n=i/this.oSize*2,r.scale(n,n),r.rotate(a),r.setTranslate(this.gl_Position[0],-this.gl_Position[1]);var s=NaN;return s=this.v_Color[3],[this.v_Color,s,r,this.v_Color[0]*s,this.v_Color[1]*s,this.v_Color[2]*s]},t}(),V=function(){function t(){this.maxIndex=0,this.cmds=null,this.id=0}r(t,"laya.particle.particleUtils.CMDParticle");var e=t.prototype;return e.setCmds=function(t){this.cmds=t,this.maxIndex=t.length-1},t}(),A=function(){function t(){}return r(t,"laya.particle.particleUtils.PicTool"),t.getCanvasPic=function(t,e){t=t.bitmap;var i=new o("2D"),a=i.getContext("2d");i.size(t.width,t.height);var r=e>>16&255,n=e>>8&255,s=255&e;if(d.isConchApp&&a.setFilter(r/255,n/255,s/255,0),a.drawImage(t.source,0,0),!d.isConchApp){for(var l=a.getImageData(0,0,i.width,i.height),h=l.data,c=0,u=h.length;u>c;c+=4)0!=h[c+3]&&(h[c]=r,h[c+1]=n,h[c+2]=s);a.putImageData(l,0,0)}return i},t.getRGBPic=function(e){var i;return i=[new f(t.getCanvasPic(e,16711680)),new f(t.getCanvasPic(e,65280)),new f(t.getCanvasPic(e,255))]},t}(),T=function(t){function e(t){this.setting=null,this._posRange=null,this._canvasTemplate=null,this._emitFun=null,e.__super.call(this),this.template=t}r(e,"laya.particle.emitter.Emitter2D",t);var i=e.prototype;return i.emit=function(){t.prototype.emit.call(this),null!=this._emitFun&&this._emitFun()},i.getRandom=function(t){return(2*Math.random()-1)*t},i.webGLEmit=function(){var t=new Float32Array(3);t[0]=this.getRandom(this._posRange[0]),t[1]=this.getRandom(this._posRange[1]),t[2]=this.getRandom(this._posRange[2]);var e=new Float32Array(3);e[0]=0,e[1]=0,e[2]=0,this._particleTemplate.addParticleArray(t,e)},i.canvasEmit=function(){var t=new Float32Array(3);t[0]=this.getRandom(this._posRange[0]),t[1]=this.getRandom(this._posRange[1]),t[2]=this.getRandom(this._posRange[2]);var e=new Float32Array(3);e[0]=0,e[1]=0,e[2]=0,this._particleTemplate.addParticleArray(t,e)},n(0,i,"template",function(){return this._particleTemplate},function(t){this._particleTemplate=t,t||(this._emitFun=null,this.setting=null,this._posRange=null),this.setting=t.settings,this._posRange=this.setting.positionVariance,this._particleTemplate instanceof laya.particle.ParticleTemplate2D?this._emitFun=this.webGLEmit:this._particleTemplate instanceof laya.particle.ParticleTemplateCanvas&&(this._canvasTemplate=t,this._emitFun=this.canvasEmit)}),e}(C),w=function(t){function e(t){this._vertices=null,this._vertexBuffer=null,this._indexBuffer=null,this._floatCountPerVertex=29,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=0,this._drawCounter=0,e.__super.call(this),this.settings=t}r(e,"laya.particle.ParticleTemplateWebGL",t);var i=e.prototype;return i.initialize=function(){this._vertices=new Float32Array(this.settings.maxPartices*this._floatCountPerVertex*4);for(var t=0,e=0;ei);r+=a);t=e*this._floatCountPerVertex*4,this._vertices[t+0*this._floatCountPerVertex+0]=-1,this._vertices[t+0*this._floatCountPerVertex+1]=-1,this._vertices[t+0*this._floatCountPerVertex+2]=0,this._vertices[t+0*this._floatCountPerVertex+3]=r,this._vertices[t+1*this._floatCountPerVertex+0]=1,this._vertices[t+1*this._floatCountPerVertex+1]=-1,this._vertices[t+1*this._floatCountPerVertex+2]=1,this._vertices[t+1*this._floatCountPerVertex+3]=r,this._vertices[t+2*this._floatCountPerVertex+0]=1,this._vertices[t+2*this._floatCountPerVertex+1]=1,this._vertices[t+2*this._floatCountPerVertex+2]=1,this._vertices[t+2*this._floatCountPerVertex+3]=r+a,this._vertices[t+3*this._floatCountPerVertex+0]=-1,this._vertices[t+3*this._floatCountPerVertex+1]=1,this._vertices[t+3*this._floatCountPerVertex+2]=0,this._vertices[t+3*this._floatCountPerVertex+3]=r+a}},i.loadContent=function(){},i.update=function(t){this._currentTime+=t/1e3,this.retireActiveParticles(),this.freeRetiredParticles(),this._firstActiveElement==this._firstFreeElement&&(this._currentTime=0),this._firstRetiredElement==this._firstActiveElement&&(this._drawCounter=0)},i.retireActiveParticles=function(){for(var t=this.settings.duration;this._firstActiveElement!=this._firstNewElement;){var e=this._firstActiveElement*this._floatCountPerVertex*4+28,i=this._currentTime-this._vertices[e];if(t>i)break;this._vertices[e]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this.settings.maxPartices&&(this._firstActiveElement=0)}},i.freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var t=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*4+28];if(3>t)break;this._firstRetiredElement++,this._firstRetiredElement>=this.settings.maxPartices&&(this._firstRetiredElement=0)}},i.addNewParticlesToVertexBuffer=function(){},i.addParticleArray=function(t,e){var i=this._firstFreeElement+1;if(i>=this.settings.maxPartices&&(i=0),i!==this._firstRetiredElement){for(var a=g.Create(this.settings,t,e,this._currentTime),r=this._firstFreeElement*this._floatCountPerVertex*4,n=0;4>n;n++){var s=0,o=0;for(s=0,o=4;3>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.position[s];for(s=0,o=7;3>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.velocity[s];for(s=0,o=10;4>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.startColor[s];for(s=0,o=14;4>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.endColor[s];for(s=0,o=18;3>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.sizeRotation[s];for(s=0,o=21;2>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radius[s];for(s=0,o=23;4>s;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radian[s];this._vertices[r+n*this._floatCountPerVertex+27]=a.durationAddScale,this._vertices[r+n*this._floatCountPerVertex+28]=a.time}this._firstFreeElement=i}},e}(S),z=function(t){function e(t){this._ready=!1,this.textureList=[],this.particleList=[],this.pX=0,this.pY=0,this.activeParticles=[],this.deadParticles=[],this.iList=[],this._maxNumParticles=0,this.textureWidth=NaN,this.dTextureWidth=NaN,this.colorChange=!0,this.step=1/60,this.canvasShader=new E,e.__super.call(this),this.settings=t,this._maxNumParticles=t.maxPartices,this.texture=new f,this.texture.on("loaded",this,this._textureLoaded),this.texture.load(t.textureName)}r(e,"laya.particle.ParticleTemplateCanvas",t);var i=e.prototype;return i._textureLoaded=function(t){this.setTexture(this.texture),this._ready=!0},i.clear=function(t){void 0===t&&(t=!0),this.deadParticles.length=0,this.activeParticles.length=0,this.textureList.length=0},i.setTexture=function(t){this.texture=t,this.textureWidth=t.width,this.dTextureWidth=1/this.textureWidth,this.pX=.5*-t.width,this.pY=.5*-t.height,this.textureList=e.changeTexture(t,this.textureList),this.particleList.length=0,this.deadParticles.length=0,this.activeParticles.length=0},i._createAParticleData=function(t,e){this.canvasShader.u_EndVelocity=this.settings.endVelocity,this.canvasShader.u_Gravity=this.settings.gravity,this.canvasShader.u_Duration=this.settings.duration;var i;i=g.Create(this.settings,t,e,0),this.canvasShader.a_Position=i.position,this.canvasShader.a_Velocity=i.velocity,this.canvasShader.a_StartColor=i.startColor,this.canvasShader.a_EndColor=i.endColor,this.canvasShader.a_SizeRotation=i.sizeRotation,this.canvasShader.a_Radius=i.radius,this.canvasShader.a_Radian=i.radian,this.canvasShader.a_AgeAddScale=i.durationAddScale,this.canvasShader.oSize=this.textureWidth;var a=new V,r=0,n=this.settings.duration/(1+i.durationAddScale),s=[];for(r=0;n>r;r+=this.step)s.push(this.canvasShader.getData(r));return a.id=this.particleList.length,this.particleList.push(a),a.setCmds(s),a},i.addParticleArray=function(t,e){if(this._ready){var i;this.particleList.length0&&(i=this.deadParticles.pop(),this.iList[i.id]=0,this.activeParticles.push(i))}},i.advanceTime=function(t){if(void 0===t&&(t=1),this._ready){var e,i=this.activeParticles,a=this.deadParticles,r=0,n=i.length,s=0,o=this.iList;for(r=n-1;r>-1;r--)e=i[r],s=o[e.id],s>=e.maxIndex?(s=0,i.splice(r,1),a.push(e)):s+=1,o[e.id]=s}},i.render=function(t,e,i){this._ready&&(this.activeParticles.length<1||this.textureList.length<2||(this.settings.colorComponentInter?this.noColorRender(t,e,i):this.canvasRender(t,e,i)))},i.noColorRender=function(t,e,i){var a,r,n=this.activeParticles,s=0,o=n.length,l=NaN,h=this.pX,c=this.pY,u=2*-h,d=2*-c,m=0,_=(this.textureList,this.iList),p=NaN;for(t.translate(e,i),p=t.ctx.globalAlpha,s=0;o>s;s++)a=n[s],m=_[a.id],r=a.cmds[m],r&&((l=r[1])<=.01||(t.setAlpha(p*l),t.drawTextureWithTransform(this.texture,h,c,u,d,r[2],1)));t.setAlpha(p),t.translate(-e,-i)},i.canvasRender=function(t,e,i){var a,r,n,s=this.activeParticles,o=0,l=s.length,h=NaN,c=this.pX,u=this.pY,d=2*-c,m=2*-u,_=0,p=this.textureList,f=this.iList,v=NaN;for(t.translate(e,i),v=t.ctx.globalAlpha,n=t.ctx.globalCompositeOperation,t.blendMode("lighter"),o=0;l>o;o++)a=s[o],_=f[a.id],r=a.cmds[_],r&&((h=r[1])<=.01||(t.save(),t.transformByMatrix(r[2]),r[3]>.01&&(t.setAlpha(v*r[3]),t.drawTexture(p[0],c,u,d,m)),r[4]>.01&&(t.setAlpha(v*r[4]),t.drawTexture(p[1],c,u,d,m)),r[5]>.01&&(t.setAlpha(v*r[5]),t.drawTexture(p[2],c,u,d,m)),t.restore()));t.setAlpha(v),t.translate(-e,-i),t.blendMode(n)},e.changeTexture=function(t,e,i){return e||(e=[]),e.length=0,i&&i.colorComponentInter?e.push(t,t,t):v.copyArray(e,A.getRGBPic(t)),e},e}(S),F=function(t){function e(t){this._vertexBuffer2D=null,this._indexBuffer2D=null,this.x=0,this.y=0,this._blendFn=null,this._startTime=0,this.sv=new b,e.__super.call(this,t);var a=this;i.loader.load(this.settings.textureName,l.create(null,function(t){t.bitmap.enableMerageInAtlas=!1,a.texture=t})),this.sv.u_Duration=this.settings.duration,this.sv.u_Gravity=this.settings.gravity,this.sv.u_EndVelocity=this.settings.endVelocity,this._blendFn=s.fns[t.blendState],this.initialize(),this._vertexBuffer=this._vertexBuffer2D=y.create(-1,35048),this._indexBuffer=this._indexBuffer2D=h.create(35044),this.loadContent()}r(e,"laya.particle.ParticleTemplate2D",t);var a=e.prototype;return i.imps(a,{"laya.webgl.submit.ISubmit":!0}),a.getRenderType=function(){return-111},a.releaseRender=function(){},a.addParticleArray=function(e,i){e[0]+=this.x,e[1]+=this.y,t.prototype.addParticleArray.call(this,e,i)},a.loadContent=function(){for(var t=new Uint16Array(6*this.settings.maxPartices),e=0;e0&&(this._vertexBuffer2D.setNeedUpload(),this._vertexBuffer2D.subUpload(0,0,4*this._firstFreeElement*this._floatCountPerVertex*4))),this._firstNewElement=this._firstFreeElement},a.renderSubmit=function(){if(this.texture&&this.texture.loaded){if(this.update(i.timer.delta),this.sv.u_CurrentTime=this._currentTime,this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this.blend(),this._firstActiveElement!=this._firstFreeElement){P.mainContext;this._vertexBuffer2D.bind(this._indexBuffer2D),this.sv.u_texture=this.texture.source,this.sv.upload(),this._firstActiveElement0&&P.mainContext.drawElements(4,6*this._firstFreeElement,5123,0)),p.drawCall++}this._drawCounter++}return 1},a.blend=function(){if(s.activeBlendFunction!==this._blendFn){var t=P.mainContext;t.enable(3042),this._blendFn(t),s.activeBlendFunction=this._blendFn}},a.dispose=function(){this._vertexBuffer2D.dispose(),this._indexBuffer2D.dispose()},e.activeBlendType=-1,e}(w),b=function(t){function e(){this.a_CornerTextureCoordinate=[4,5126,!1,116,0],this.a_Position=[3,5126,!1,116,16],this.a_Velocity=[3,5126,!1,116,28],this.a_StartColor=[4,5126,!1,116,40],this.a_EndColor=[4,5126,!1,116,56],this.a_SizeRotation=[3,5126,!1,116,72],this.a_Radius=[2,5126,!1,116,84],this.a_Radian=[4,5126,!1,116,92],this.a_AgeAddScale=[1,5126,!1,116,108],this.a_Time=[1,5126,!1,116,112],this.u_CurrentTime=NaN,this.u_Duration=NaN,this.u_Gravity=null,this.u_EndVelocity=NaN,this.u_texture=null,e.__super.call(this,0,0)}r(e,"laya.particle.shader.value.ParticleShaderValue",t);var i=e.prototype;return i.upload=function(){this.refresh(),e.pShader.upload(this)},a(e,["pShader",function(){return this.pShader=new N}]),e}(x),N=(function(e){function a(t){this._matrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this._particleTemplate=null,this._canvasTemplate=null,this._emitter=null,this.autoPlay=!0,a.__super.call(this),t&&this.setParticleSetting(t)}r(a,"laya.particle.Particle2D",e);var s=a.prototype;return s.load=function(t){i.loader.load(t,l.create(this,this.setParticleSetting),null,"json")},s.setParticleSetting=function(e){var a=this;if(!e)return this.stop();if(R.checkSetting(e),t.ConchParticleTemplate2D&&!d.isWebGL||(this.customRenderEnable=!0),d.isWebGL)this._particleTemplate=new F(e),this.graphics._saveToCmd(d.context._drawParticle,[this._particleTemplate]);else{if(d.isConchApp&&t.ConchParticleTemplate2D){this._particleTemplate=new ConchParticleTemplate2D;var r=this;return i.loader.load(e.textureName,l.create(null,function(t){r._particleTemplate.texture=t,r._particleTemplate.settings=e,d.isConchNode?r.graphics.drawParticle(r._particleTemplate):r.graphics._saveToCmd(d.context._drawParticle,[a._particleTemplate])})),this._emitter={start:function(){}},this.play=this._particleTemplate.play.bind(this._particleTemplate),this.stop=this._particleTemplate.stop.bind(this._particleTemplate),void(this.autoPlay&&this.play())}this._particleTemplate=this._canvasTemplate=new z(e)}this._emitter?this._emitter.template=this._particleTemplate:this._emitter=new T(this._particleTemplate),this.autoPlay&&(this.emitter.start(),this.play())},s.play=function(){i.timer.frameLoop(1,this,this._loop)},s.stop=function(){i.timer.clear(this,this._loop)},s._loop=function(){this.advanceTime(1/60)},s.advanceTime=function(t){void 0===t&&(t=1),this._canvasTemplate&&this._canvasTemplate.advanceTime(t),this._emitter&&this._emitter.advanceTime(t)},s.customRender=function(t,e,i){if(d.isWebGL){this._matrix4[0]=t.ctx._curMat.a,this._matrix4[1]=t.ctx._curMat.b,this._matrix4[4]=t.ctx._curMat.c,this._matrix4[5]=t.ctx._curMat.d,this._matrix4[12]=t.ctx._curMat.tx,this._matrix4[13]=t.ctx._curMat.ty;var a=this._particleTemplate.sv;a.u_mmat=this._matrix4}this._canvasTemplate&&this._canvasTemplate.render(t,e,i)},s.destroy=function(t){void 0===t&&(t=!0),this._particleTemplate instanceof laya.particle.ParticleTemplate2D&&this._particleTemplate.dispose(),e.prototype.destroy.call(this,t)},n(0,s,"url",null,function(t){this.load(t)}),n(0,s,"emitter",function(){return this._emitter}),a}(_),function(t){function e(){e.__super.call(this,e.vs,e.ps,"ParticleShader")}return r(e,"laya.particle.shader.ParticleShader",t),a(e,["vs",function(){return this.vs="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Velocity;\nattribute vec4 a_StartColor;\nattribute vec4 a_EndColor;\nattribute vec3 a_SizeRotation;\nattribute vec2 a_Radius;\nattribute vec4 a_Radian;\nattribute float a_AgeAddScale;\nattribute float a_Time;\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform float u_Duration;\nuniform float u_EndVelocity;\nuniform vec3 u_Gravity;\n\n#ifdef PARTICLE3D\n uniform mat4 u_WorldMat;\n uniform mat4 u_View;\n uniform mat4 u_Projection;\n uniform vec2 u_ViewportScale;\n#else\n uniform vec2 size;\n uniform mat4 mmat;\n uniform mat4 u_mmat;\n#endif\n\nvec4 ComputeParticlePosition(in vec3 position, in vec3 velocity,in float age,in float normalizedAge)\n{\n\n float startVelocity = length(velocity);//起始标量速度\n float endVelocity = startVelocity * u_EndVelocity;//结束标量速度\n\n float velocityIntegral = startVelocity * normalizedAge +(endVelocity - startVelocity) * normalizedAge *normalizedAge/2.0;//计算当前速度的标量(单位空间),vt=v0*t+(1/2)*a*(t^2)\n \n vec3 addPosition = normalize(velocity) * velocityIntegral * u_Duration;//计算受自身速度影响的位置,转换标量到矢量 \n addPosition += u_Gravity * age * normalizedAge;//计算受重力影响的位置\n \n float radius=mix(a_Radius.x, a_Radius.y, normalizedAge); //计算粒子受半径和角度影响(无需计算角度和半径时,可用宏定义优化屏蔽此计算)\n float radianHorizontal =mix(a_Radian.x,a_Radian.z,normalizedAge);\n float radianVertical =mix(a_Radian.y,a_Radian.w,normalizedAge);\n \n float r =cos(radianVertical)* radius;\n addPosition.y += sin(radianVertical) * radius;\n \n addPosition.x += cos(radianHorizontal) *r;\n addPosition.z += sin(radianHorizontal) *r;\n \n #ifdef PARTICLE3D\n position+=addPosition;\n return u_Projection*u_View*u_WorldMat*(vec4(position, 1.0));\n #else\n addPosition.y=-addPosition.y;//2D粒子位置更新需要取负,2D粒子坐标系Y轴正向朝上\n position+=addPosition;\n return vec4(position,1.0);\n #endif\n}\n\nfloat ComputeParticleSize(in float startSize,in float endSize, in float normalizedAge)\n{ \n float size = mix(startSize, endSize, normalizedAge);\n \n #ifdef PARTICLE3D\n //Project the size into screen coordinates.\n return size * u_Projection[1][1];\n #else\n return size;\n #endif\n}\n\nmat2 ComputeParticleRotation(in float rot,in float age)\n{ \n float rotation =rot * age;\n //计算2x2旋转矩阵.\n float c = cos(rotation);\n float s = sin(rotation);\n return mat2(c, -s, s, c);\n}\n\nvec4 ComputeParticleColor(in vec4 startColor,in vec4 endColor,in float normalizedAge)\n{\n vec4 color=mix(startColor,endColor,normalizedAge);\n //硬编码设置,使粒子淡入很快,淡出很慢,6.7的缩放因子把置归一在0到1之间,可以谷歌x*(1-x)*(1-x)*6.7的制图表\n color.a *= normalizedAge * (1.0-normalizedAge) * (1.0-normalizedAge) * 6.7;\n \n return color;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n age *= 1.0 + a_AgeAddScale;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n gl_Position = ComputeParticlePosition(a_Position, a_Velocity, age, normalizedAge);//计算粒子位置\n float pSize = ComputeParticleSize(a_SizeRotation.x,a_SizeRotation.y, normalizedAge);\n mat2 rotation = ComputeParticleRotation(a_SizeRotation.z, age);\n \n #ifdef PARTICLE3D\n gl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize * u_ViewportScale;\n #else\n mat4 mat=u_mmat*mmat;\n gl_Position=vec4((mat*gl_Position).xy,0.0,1.0);\n gl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize*vec2(mat[0][0],mat[1][1]);\n gl_Position=vec4((gl_Position.x/size.x-0.5)*2.0,(0.5-gl_Position.y/size.y)*2.0,0.0,1.0);\n #endif\n \n v_Color = ComputeParticleColor(a_StartColor,a_EndColor, normalizedAge);\n v_TextureCoordinate =a_CornerTextureCoordinate.zw;\n}\n\n"},"ps",function(){return this.ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\nvoid main()\n{ \n gl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n}"}]),e}(m))}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.pathfinding.min.js b/games/laya-snakes/libs/min/laya.pathfinding.min.js new file mode 100644 index 0000000..1f1c2bf --- /dev/null +++ b/games/laya-snakes/libs/min/laya.pathfinding.min.js @@ -0,0 +1 @@ +!function(t,e,i){var n=(i.un,i.uns,i["static"],i["class"]),s=(i.getset,i.__newvec,function(){function t(){}return n(t,"PathFinding.core.DiagonalMovement"),t.Always=1,t.Never=2,t.IfAtMostOneObstacle=3,t.OnlyWhenNoObstacles=4,t}()),a=function(){function t(t,e,i){this.width=0,this.height=0,this.nodes=null;var n=0;"number"==typeof t?n=t:(e=t.length,n=t[0].length,i=t),this.width=n,this.height=e,this.nodes=this._buildNodes(n,e,i)}n(t,"PathFinding.core.Grid");var e=t.prototype;return e._buildNodes=function(t,e,i){var n=0,s=0,a=[];for(n=0;e>n;++n)for(a[n]=[],s=0;t>s;++s)a[n][s]=new o(s,n);if(null==i)return a;if(i.length!=e||i[0].length!=t)throw new Error("Matrix size does not fit");for(n=0;e>n;++n)for(s=0;t>s;++s)i[n][s]&&(a[n][s].walkable=!1);return a},e.getNodeAt=function(t,e){return this.nodes[e][t]},e.isWalkableAt=function(t,e){return this.isInside(t,e)&&this.nodes[e][t].walkable},e.isInside=function(t,e){return t>=0&&t=0&&ee;++e)for(h[e]=[],i=0;n>i;++i)h[e][i]=new o(i,e,a[e][i].walkable);return r.nodes=h,r},e.reset=function(){for(var t,e=0;et?i*t+e:i*e+t},t.chebyshev=function(t,e){return Math.max(t,e)},t}(),o=function(){function t(t,e,i){this.x=0,this.y=0,this.g=0,this.f=0,this.h=0,this.by=0,this.parent=null,this.opened=null,this.closed=null,this.tested=null,this.walkable=!1,void 0===i&&(i=!0),this.x=t,this.y=e,this.walkable=i}return n(t,"PathFinding.core.Node",null,"Node1"),t}(),h=function(){function t(){}return n(t,"PathFinding.core.Util"),t.backtrace=function(t){for(var e=[[t.x,t.y]];t.parent;)t=t.parent,e.push([t.x,t.y]);return e.reverse()},t.biBacktrace=function(e,i){var n=t.backtrace(e),s=t.backtrace(i);return n.concat(s.reverse())},t.pathLength=function(t){var e=0,i=0,n=0,s=0,a=0,r=0;for(e=1;et?1:-1,o=n>e?1:-1,u=h-l;;){if(a.push([t,e]),t==i&&e==n)break;d=2*u,d>-l&&(u-=l,t+=r),h>d&&(u+=h,e+=o)}return a},t.expandPath=function(e){var i,n,s,a=[],r=e.length,o=0,h=0,l=0;if(2>r)return a;for(h=0;r-1>h;++h)for(i=e[h],n=e[h+1],s=t.interpolate(i[0],i[1],n[0],n[1]),o=s.length,l=0;o-1>l;++l)a.push(s[l]);return a.push(e[r-1]),a},t.smoothenPath=function(e,i){var n,s,a,r,o,h=i.length,l=i[0][0],u=i[0][1],d=i[h-1][0],f=i[h-1][1],c=0,p=0,g=0,b=0,m=0,v=0,A=!1;for(c=l,p=u,n=[[c,p]],m=2;h>m;++m){for(s=i[m],g=s[0],b=s[1],a=t.interpolate(c,p,g,b),A=!1,v=1;vv;++v)o=r[v],o.closed||(k=o.x,W=o.y,M=a.g+(k-a.x===0||W-a.y===0?1:m),(!o.opened||Mk;++k)if(o=r[k],!o.closed){if(o.opened===C)return h.biBacktrace(a,o);M=o.x,y=o.y,w=a.g+(M-a.x===0||y-a.y===0?1:A),(!o.opened||wk;++k)if(o=r[k],!o.closed){if(o.opened===N)return h.biBacktrace(o,a);M=o.x,y=o.y,w=a.g+(M-a.x===0||y-a.y===0?1:A),(!o.opened||wb;++b)if(r=a[b],!r.closed)if(r.opened){if(r.by===g)return h.biBacktrace(o,r)}else d.push(r),r.parent=o,r.opened=!0,r.by=p;for(o=f.shift(),o.closed=!0,a=s.getNeighbors(o,c),b=0,m=a.length;m>b;++b)if(r=a[b],!r.closed)if(r.opened){if(r.by===p)return h.biBacktrace(r,o)}else f.push(r),r.parent=o,r.opened=!0,r.by=g}return[]},t}(),function(){function t(t){this.allowDiagonal=!1,this.dontCrossCorners=!1,this.heuristic=null,this.weight=0,this.diagonalMovement=0,t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=s.OnlyWhenNoObstacles:this.diagonalMovement=s.IfAtMostOneObstacle:this.diagonalMovement=s.Never)}n(t,"PathFinding.finders.BreadthFirstFinder");var e=t.prototype;return e.findPath=function(t,e,i,n,s){var a,r,o,l=[],u=this.diagonalMovement,d=s.getNodeAt(t,e),f=s.getNodeAt(i,n),c=0,p=0;for(l.push(d),d.opened=!0;l.length;){if(o=l.shift(),o.closed=!0,o===f)return h.backtrace(f);for(a=s.getNeighbors(o,u),c=0,p=a.length;p>c;++c)r=a[c],r.closed||r.opened||(l.push(r),r.opened=!0,r.parent=o)}return[]},t}(),function(){function t(t){this.allowDiagonal=!1,this.dontCrossCorners=!1,this.heuristic=null,this.weight=0,this.diagonalMovement=0,this.trackRecursion=!1,this.timeLimit=NaN,t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.heuristic=t.heuristic||r.manhattan,this.weight=t.weight||1,this.trackRecursion=t.trackRecursion||!1,this.timeLimit=t.timeLimit||1/0,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=s.OnlyWhenNoObstacles:this.diagonalMovement=s.IfAtMostOneObstacle:this.diagonalMovement=s.Never),this.diagonalMovement===s.Never?this.heuristic=t.heuristic||r.manhattan:this.heuristic=t.heuristic||r.octile}n(t,"PathFinding.finders.IDAStarFinder");var e=t.prototype;return e.findPath=function(t,e,i,n,s){var a,r=this,o=0,h=(new Date).getTime(),l=function(t,e){return r.heuristic(Math.abs(e.x-t.x),Math.abs(e.y-t.y))}.bind(this),u=function(t,e){return t.x===e.x||t.y===e.y?1:Math.SQRT2},d=function(t,e,i,n,a){if(o++,r.timeLimit>0&&(new Date).getTime()-h>1e3*r.timeLimit)return 1/0;var f=e+l(t,c)*r.weight;if(f>i)return f;if(t==c)return n[a]=[t.x,t.y],t;var p,g=0,b=0,m=0,v=s.getNeighbors(t,r.diagonalMovement);for(m=0,g=1/0;p=v[m];++m){if(r.trackRecursion&&(p.retainCount=p.retainCount+1||1,1!=p.tested&&(p.tested=!0)),b=d(p,e+u(t,p),i,n,a+1),b instanceof PathFinding.core.Node)return n[a]=[t.x,t.y],b;r.trackRecursion&&0===--p.retainCount&&(p.tested=!1),g>b&&(g=b)}return g}.bind(this),f=s.getNodeAt(t,e),c=s.getNodeAt(i,n),p=l(f,c),g=0,b=0;for(g=0;!0;++g){if(a=[],b=d(f,0,p,a,0),b==1/0)return[];if(b instanceof PathFinding.core.Node)return a;p=b}},t}(),function(){function t(t){this.grid=null,this.openList=null,this.startNode=null,this.endNode=null,this.heuristic=null,this.trackJumpRecursion=!1,t=t||{},this.heuristic=t.heuristic||r.manhattan,this.trackJumpRecursion=t.trackJumpRecursion||!1}n(t,"PathFinding.finders.JumpPointFinderBase");var e=t.prototype;return e.findPath=function(t,e,i,n,s){var a,r=this.openList=new f(function(t,e){return t.f-e.f}),o=this.startNode=s.getNodeAt(t,e),l=this.endNode=s.getNodeAt(i,n);for(this.grid=s,o.g=0,o.f=0,r.push(o),o.opened=!0;!r.empty();){if(a=r.pop(),a.closed=!0,a==l)return h.expandPath(h.backtrace(l));this._identifySuccessors(a)}return[]},e._identifySuccessors=function(t){var e,i,n,s,a=this.grid,o=this.heuristic,h=this.openList,l=this.endNode.x,u=this.endNode.y,d=0,f=0,c=t.x,p=t.y,g=0,b=0,m=0,v=0,A=Math.abs;Math.max;for(e=this._findNeighbors(t),d=0,f=e.length;f>d;++d)if(i=e[d],n=this._jump(i[0],i[1],c,p)){if(g=n[0],b=n[1],s=a.getNodeAt(g,b),s.closed)continue;m=r.octile(A(g-c),A(b-p)),v=t.g+m,(!s.opened||vb;++b)o=r[b],o.closed||(v=o.x,A=o.y,k=a.g+(v-a.x===0||A-a.y===0?1:g),(!o.opened||kt?-1:t>e?1:0}}n(t,"PathFinding.libs.HeapFunction");var e=t.prototype;return e.insort=function(t,e,i,n,s){var a=NaN;if(null==i&&(i=0),null==s&&(s=this.defaultCmp),0>i)throw new Error("lo must be non-negative");for(null==n&&(n=t.length);n>i;)a=Math.floor((i+n)/2),s(e,t[a])<0?n=a:i=a+1;return[].splice.apply(t,[i,i-i].concat(e)),e},e.heappush=function(t,e,i){return null==i&&(i=this.defaultCmp),t.push(e),this._siftdown(t,0,t.length-1,i)},e.heappop=function(t,e){var i,n;return null==e&&(e=this.defaultCmp),i=t.pop(),t.length?(n=t[0],t[0]=i,this._siftup(t,0,e)):n=i,n},e.heapreplace=function(t,e,i){var n;return null==i&&(i=this.defaultCmp),n=t[0],t[0]=e,this._siftup(t,0,i),n},e.heappushpop=function(t,e,i){var n;return null==i&&(i=this.defaultCmp),t.length&&i(t[0],e)<0&&(n=[t[0],e],e=n[0],t[0]=n[1],this._siftup(t,0,i)),e},e.heapify=function(t,e){var i,n,s,a,r=0,o=0,h=0,l=0;for(null==e&&(e=this.defaultCmp),n=function(){for(a=[],h=0,i=Math.floor(t.length/2);i>=0?i>h:h>i;i>=0?h++:h--)a.push(h);return a}.apply(this).reverse(),s=[],o=0,l=n.length;l>o;o++)r=n[o],s.push(this._siftup(t,r,e));return s},e.updateItem=function(t,e,i){var n=0;return null==i&&(i=this.defaultCmp),n=t.indexOf(e),-1===n?null:(this._siftdown(t,0,n,i),this._siftup(t,n,i))},e.nlargest=function(t,e,i){var n,s,a,r=0,o=0;if(null==i&&(i=this.defaultCmp),s=t.slice(0,e),!s.length)return s;for(this.heapify(s,i),a=t.slice(e),r=0,o=a.length;o>r;r++)n=a[r],this.heappushpop(s,n,i);return s.sort(i).reverse()},e.nsmallest=function(t,e,i){var n,s,a,r,o,h,l,u,d=0,f=0;if(null==i&&(i=this.defaultCmp),10*e<=t.length){if(r=t.slice(0,e).sort(i),!r.length)return r;for(a=r[r.length-1],h=t.slice(e),d=0,o=h.length;o>d;d++)n=h[d],i(n,a)<0&&(this.insort(r,n,0,null,i),r.pop(),a=r[r.length-1]);return r}for(this.heapify(t,i),u=[],s=f=0,l=Math.min(e,t.length);l>=0?l>f:f>l;s=l>=0?++f:--f)u.push(this.heappop(t,i));return u},e._siftdown=function(t,e,i,n){var s,a,r=0;for(null==n&&(n=this.defaultCmp),s=t[i];i>e&&(r=i-1>>1,a=t[r],n(s,a)<0);)t[i]=a,i=r;return t[i]=s},e._siftup=function(t,e,i){var n,s=0,a=0,r=0,o=0;for(null==i&&(i=this.defaultCmp),a=t.length,o=e,n=t[e],s=2*e+1;a>s;)r=s+1,a>r&&!(i(t[s],t[r])<0)&&(s=r),t[e]=t[s],e=s,s=2*e+1;return t[e]=n,this._siftdown(t,o,e,i)},t}(),p=(function(){function t(){var t={allowDiagonal:!0,dontCrossCorners:!1,heuristic:r.manhattan,weight:1},e=new l(t),i=new a(64,36),n=e.findPath(23,16,33,16,i);console.log(n.toString())}return n(t,"TestPathFinding"),t}(),function(t){function e(t){e.__super.call(this,t);var i=this.heuristic;this.heuristic=function(t,e){return 1e6*i(t,e)}}return n(e,"PathFinding.finders.BestFirstFinder",t),e}(l),function(t){function e(t){e.__super.call(this,t);var i=this.heuristic;this.heuristic=function(t,e){return 1e6*i(t,e)}}return n(e,"PathFinding.finders.BiBestFirstFinder",t),e}(u),function(t){function e(t){e.__super.call(this,t),this.heuristic=function(t,e){return 0}}return n(e,"PathFinding.finders.BiDijkstraFinder",t),e}(u),function(t){function e(t){e.__super.call(this,t),this.heuristic=function(t,e){return 0}}return n(e,"PathFinding.finders.DijkstraFinder",t),e}(l),function(t){function e(t){e.__super.call(this,t)}n(e,"PathFinding.finders.JPFAlwaysMoveDiagonally",t);var i=e.prototype;return i._jump=function(t,e,i,n){var s=this.grid,a=t-i,r=e-n;if(!s.isWalkableAt(t,e))return null;if(1==this.trackJumpRecursion&&(s.getNodeAt(t,e).tested=!0),s.getNodeAt(t,e)==this.endNode)return[t,e];if(0!==a&&0!==r){if(s.isWalkableAt(t-a,e+r)&&!s.isWalkableAt(t-a,e)||s.isWalkableAt(t+a,e-r)&&!s.isWalkableAt(t,e-r))return[t,e];if(this._jump(t+a,e,t,e)||this._jump(t,e+r,t,e))return[t,e]}else if(0!==a){if(s.isWalkableAt(t+a,e+1)&&!s.isWalkableAt(t,e+1)||s.isWalkableAt(t+a,e-1)&&!s.isWalkableAt(t,e-1))return[t,e]}else if(s.isWalkableAt(t+1,e+r)&&!s.isWalkableAt(t+1,e)||s.isWalkableAt(t-1,e+r)&&!s.isWalkableAt(t-1,e))return[t,e];return this._jump(t+a,e+r,t,e)},i._findNeighbors=function(t){var e,i,n=t.parent,a=t.x,r=t.y,o=this.grid,h=0,l=0,u=0,d=0,f=[],c=0,p=0;if(n)h=n.x,l=n.y,u=(a-h)/Math.max(Math.abs(a-h),1),d=(r-l)/Math.max(Math.abs(r-l),1),0!==u&&0!==d?(o.isWalkableAt(a,r+d)&&f.push([a,r+d]),o.isWalkableAt(a+u,r)&&f.push([a+u,r]),o.isWalkableAt(a+u,r+d)&&f.push([a+u,r+d]),o.isWalkableAt(a-u,r)||f.push([a-u,r+d]),o.isWalkableAt(a,r-d)||f.push([a+u,r-d])):0===u?(o.isWalkableAt(a,r+d)&&f.push([a,r+d]),o.isWalkableAt(a+1,r)||f.push([a+1,r+d]),o.isWalkableAt(a-1,r)||f.push([a-1,r+d])):(o.isWalkableAt(a+u,r)&&f.push([a+u,r]),o.isWalkableAt(a,r+1)||f.push([a+u,r+1]),o.isWalkableAt(a,r-1)||f.push([a+u,r-1]));else for(e=o.getNeighbors(t,s.Always),c=0,p=e.length;p>c;++c)i=e[c],f.push([i.x,i.y]);return f},e}(d)),g=function(t){function e(t){e.__super.call(this,t)}n(e,"PathFinding.finders.JPFMoveDiagonallyIfAtMostOneObstacle",t);var i=e.prototype;return i._jump=function(t,e,i,n){var s=this.grid,a=t-i,r=e-n;if(!s.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(s.getNodeAt(t,e).tested=!0),s.getNodeAt(t,e)==this.endNode)return[t,e];if(0!==a&&0!==r){if(s.isWalkableAt(t-a,e+r)&&!s.isWalkableAt(t-a,e)||s.isWalkableAt(t+a,e-r)&&!s.isWalkableAt(t,e-r))return[t,e];if(this._jump(t+a,e,t,e)||this._jump(t,e+r,t,e))return[t,e]}else if(0!==a){if(s.isWalkableAt(t+a,e+1)&&!s.isWalkableAt(t,e+1)||s.isWalkableAt(t+a,e-1)&&!s.isWalkableAt(t,e-1))return[t,e]}else if(s.isWalkableAt(t+1,e+r)&&!s.isWalkableAt(t+1,e)||s.isWalkableAt(t-1,e+r)&&!s.isWalkableAt(t-1,e))return[t,e];return s.isWalkableAt(t+a,e)||s.isWalkableAt(t,e+r)?this._jump(t+a,e+r,t,e):null},i._findNeighbors=function(t){var e,i,n=t.parent,a=t.x,r=t.y,o=this.grid,h=0,l=0,u=0,d=0,f=[],c=0,p=0;if(n)h=n.x,l=n.y,u=(a-h)/Math.max(Math.abs(a-h),1),d=(r-l)/Math.max(Math.abs(r-l),1),0!==u&&0!==d?(o.isWalkableAt(a,r+d)&&f.push([a,r+d]),o.isWalkableAt(a+u,r)&&f.push([a+u,r]),(o.isWalkableAt(a,r+d)||o.isWalkableAt(a+u,r))&&f.push([a+u,r+d]),!o.isWalkableAt(a-u,r)&&o.isWalkableAt(a,r+d)&&f.push([a-u,r+d]),!o.isWalkableAt(a,r-d)&&o.isWalkableAt(a+u,r)&&f.push([a+u,r-d])):0===u?o.isWalkableAt(a,r+d)&&(f.push([a,r+d]),o.isWalkableAt(a+1,r)||f.push([a+1,r+d]),o.isWalkableAt(a-1,r)||f.push([a-1,r+d])):o.isWalkableAt(a+u,r)&&(f.push([a+u,r]),o.isWalkableAt(a,r+1)||f.push([a+u,r+1]),o.isWalkableAt(a,r-1)||f.push([a+u,r-1]));else for(e=o.getNeighbors(t,s.IfAtMostOneObstacle),c=0,p=e.length;p>c;++c)i=e[c],f.push([i.x,i.y]);return f},e}(d),b=function(t){function e(t){e.__super.call(this,t)}n(e,"PathFinding.finders.JPFMoveDiagonallyIfNoObstacles",t);var i=e.prototype;return i._jump=function(t,e,i,n){var s=this.grid,a=t-i,r=e-n;if(!s.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(s.getNodeAt(t,e).tested=!0),s.getNodeAt(t,e)===this.endNode)return[t,e];if(0!==a&&0!==r){if(this._jump(t+a,e,t,e)||this._jump(t,e+r,t,e))return[t,e]}else if(0!==a){if(s.isWalkableAt(t,e-1)&&!s.isWalkableAt(t-a,e-1)||s.isWalkableAt(t,e+1)&&!s.isWalkableAt(t-a,e+1))return[t,e]}else if(0!==r&&(s.isWalkableAt(t-1,e)&&!s.isWalkableAt(t-1,e-r)||s.isWalkableAt(t+1,e)&&!s.isWalkableAt(t+1,e-r)))return[t,e];return s.isWalkableAt(t+a,e)&&s.isWalkableAt(t,e+r)?this._jump(t+a,e+r,t,e):null},i._findNeighbors=function(t){var e,i,n=t.parent,a=t.x,r=t.y,o=this.grid,h=0,l=0,u=0,d=0,f=[],c=0,p=0;if(n)if(h=n.x,l=n.y,u=(a-h)/Math.max(Math.abs(a-h),1),d=(r-l)/Math.max(Math.abs(r-l),1),0!==u&&0!==d)o.isWalkableAt(a,r+d)&&f.push([a,r+d]),o.isWalkableAt(a+u,r)&&f.push([a+u,r]),o.isWalkableAt(a,r+d)&&o.isWalkableAt(a+u,r)&&f.push([a+u,r+d]);else{var g;if(0!==u){g=o.isWalkableAt(a+u,r);var b=o.isWalkableAt(a,r+1),m=o.isWalkableAt(a,r-1);g&&(f.push([a+u,r]),b&&f.push([a+u,r+1]),m&&f.push([a+u,r-1])),b&&f.push([a,r+1]),m&&f.push([a,r-1])}else if(0!==d){g=o.isWalkableAt(a,r+d);var v=o.isWalkableAt(a+1,r),A=o.isWalkableAt(a-1,r);g&&(f.push([a,r+d]),v&&f.push([a+1,r+d]),A&&f.push([a-1,r+d])),v&&f.push([a+1,r]),A&&f.push([a-1,r])}}else for(e=o.getNeighbors(t,s.OnlyWhenNoObstacles),c=0,p=e.length;p>c;++c)i=e[c],f.push([i.x,i.y]);return f},e}(d),m=function(t){function e(t){e.__super.call(this,t)}n(e,"PathFinding.finders.JPFNeverMoveDiagonally",t);var i=e.prototype;return i._jump=function(t,e,i,n){var s=this.grid,a=t-i,r=e-n;if(!s.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(s.getNodeAt(t,e).tested=!0),s.getNodeAt(t,e)==this.endNode)return[t,e];if(0!==a){if(s.isWalkableAt(t,e-1)&&!s.isWalkableAt(t-a,e-1)||s.isWalkableAt(t,e+1)&&!s.isWalkableAt(t-a,e+1))return[t,e]}else{if(0===r)throw new Error("Only horizontal and vertical movements are allowed");if(s.isWalkableAt(t-1,e)&&!s.isWalkableAt(t-1,e-r)||s.isWalkableAt(t+1,e)&&!s.isWalkableAt(t+1,e-r))return[t,e];if(this._jump(t+1,e,t,e)||this._jump(t-1,e,t,e))return[t,e]}return this._jump(t+a,e+r,t,e)},i._findNeighbors=function(t){var e,i,n=t.parent,a=t.x,r=t.y,o=this.grid,h=0,l=0,u=0,d=0,f=[],c=0,p=0;if(n)h=n.x,l=n.y,u=(a-h)/Math.max(Math.abs(a-h),1),d=(r-l)/Math.max(Math.abs(r-l),1),0!==u?(o.isWalkableAt(a,r-1)&&f.push([a,r-1]),o.isWalkableAt(a,r+1)&&f.push([a,r+1]),o.isWalkableAt(a+u,r)&&f.push([a+u,r])):0!==d&&(o.isWalkableAt(a-1,r)&&f.push([a-1,r]),o.isWalkableAt(a+1,r)&&f.push([a+1,r]),o.isWalkableAt(a,r+d)&&f.push([a,r+d]));else for(e=o.getNeighbors(t,s.Never),c=0,p=e.length;p>c;++c)i=e[c],f.push([i.x,i.y]);return f},e}(d)}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.tiledmap.min.js b/games/laya-snakes/libs/min/laya.tiledmap.min.js new file mode 100644 index 0000000..41e1c14 --- /dev/null +++ b/games/laya-snakes/libs/min/laya.tiledmap.min.js @@ -0,0 +1 @@ +!function(t,i,e){var r=(e.un,e.uns,e["static"],e["class"]),h=e.getset,a=(e.__newvec,laya.utils.Browser),s=(laya.utils.Handler,laya.net.Loader),o=laya.maths.Point,l=laya.maths.Rectangle,n=laya.renders.Render,_=laya.display.Sprite,p=laya.resource.Texture,m=function(){function t(){this._jsonData=null,this._tileTexSetArr=[],this._texArray=[],this._x=0,this._y=0,this._width=0,this._height=0,this._mapW=0,this._mapH=0,this._mapTileW=0,this._mapTileH=0,this._mapSprite=null,this._layerArray=[],this._gridArray=[],this._showGridKey=!1,this._totalGridNum=0,this._gridW=0,this._gridH=0,this._gridWidth=450,this._gridHeight=450,this._jsonLoader=null,this._loader=null,this._tileSetArray=[],this._currTileSet=null,this._completeHandler=null,this._index=0,this._animationDic={},this._properties=null,this._tileProperties={},this._orientation="orthogonal",this._renderOrder="right-down",this._colorArray=["FF","00","33","66"],this._scale=1,this._pivotScaleX=.5,this._pivotScaleY=.5,this._centerX=0,this._centerY=0,this._viewPortX=0,this._viewPortY=0,this._viewPortWidth=0,this._viewPortHeight=0,this._enableLinear=!0,this._resPath=null,this._pathArray=null,this._limitRange=!1,this._rect=new l,this._paddingRect=new l,this._mapRect=new i,this._mapLastRect=new i}var i,a,o;r(t,"laya.map.TiledMap");var m=t.prototype;return m.createMap=function(t,i,e,r,h,a,o){void 0===a&&(a=!0),void 0===o&&(o=!1),this._enableLinear=a,this._limitRange=o,this._rect.x=i.x,this._rect.y=i.y,this._rect.width=i.width,this._rect.height=i.height,this._viewPortWidth=i.width/this._scale,this._viewPortHeight=i.height/this._scale,this._completeHandler=e,r?this._paddingRect.copyFrom(r):this._paddingRect.setTo(0,0,0,0),h&&(this._gridWidth=h.x,this._gridHeight=h.y);var l=t.lastIndexOf("/");l>-1?(this._resPath=t.substr(0,l),this._pathArray=this._resPath.split("/")):(this._resPath="",this._pathArray=[]),this._jsonLoader=new s,this._jsonLoader.once("complete",this,this.onJsonComplete),this._jsonLoader.load(t,"json",!1)},m.onJsonComplete=function(t){this._mapSprite=new _,e.stage.addChild(this._mapSprite);var i=this._jsonData=t;this._properties=i.properties,this._orientation=i.orientation,this._renderOrder=i.renderorder,this._mapW=i.width,this._mapH=i.height,this._mapTileW=i.tilewidth,this._mapTileH=i.tileheight,this._width=this._mapTileW*this._mapW,this._height=this._mapTileH*this._mapH,this._mapLastRect.top=this._mapLastRect.bottom=this._mapLastRect.left=this._mapLastRect.right=-1;var r,h,l=i.tilesets,n=0;for(n=0;n0){h=this._currTileSet=this._tileSetArray.shift(),this._loader=new s,this._loader.once("complete",this,this.onTextureComplete);var f=this.mergePath(this._resPath,h.image);this._loader.load(f,"image",!1)}},m.mergePath=function(t,i){var e="",r=i.split("/"),h=0,a=0;for(a=r.length-1;a>=0;a--)".."==r[a]&&h++;if(0==h)return e=this._pathArray.length>0?t+"/"+i:i;var s=this._pathArray.length-h;for(0>s&&console.log("[error]path does not exist"),a=0;s>a;a++)0==a?e+=this._pathArray[a]:e=e+"/"+this._pathArray[a];for(a=h;am;m++)for(var c=0;o>c;c++)_=new d,_.offX=e.titleoffsetX,_.offY=e.titleoffsetY-(h-this._mapTileH),_.texture=p.create(i,e.margin+(r+e.spacing)*c,e.margin+(h+e.spacing)*m,r,h),this._tileTexSetArr.push(_),_.gid=this._tileTexSetArr.length;if(this._tileSetArray.length>0){e=this._currTileSet=this._tileSetArray.shift(),this._loader.once("complete",this,this.onTextureComplete);var u=this.mergePath(this._resPath,e.image);this._loader.load(u,"image",!1)}else this._currTileSet=null,this.initMap()},m.initMap=function(){var t=0,i=0;for(var e in this._animationDic){var r=this.getTexture(parseInt(e)+1),h=this._animationDic[e];if(h.mAniIdArray.length>0){for(r.textureArray=[],r.durationTimeArray=h.mDurationTimeArray,r.isAnimation=!0,r.animationTotalTime=0,t=0,i=r.durationTimeArray.length;i>t;t++)r.animationTotalTime+=r.durationTimeArray[t];for(t=0,i=h.mAniIdArray.length;i>t;t++){var a=this.getTexture(h.mAniIdArray[t]+1);r.textureArray.push(a)}}}for(this._gridWidth=Math.floor(this._gridWidth/this._mapTileW)*this._mapTileW,this._gridHeight=Math.floor(this._gridHeight/this._mapTileH)*this._mapTileH,this._gridWidththis._width&&(this._viewPortX=this._width-this._viewPortWidth);var i=this._viewPortY+this._viewPortHeight;i>this._height&&(this._viewPortY=this._height-this._viewPortHeight),this._viewPortX<0&&(this._viewPortX=0),this._viewPortY<0&&(this._viewPortY=0)}var e=this._paddingRect;this._mapRect.top=Math.floor((this._viewPortY-e.y)/this._gridHeight),this._mapRect.bottom=Math.floor((this._viewPortY+this._viewPortHeight+e.height+e.y)/this._gridHeight),this._mapRect.left=Math.floor((this._viewPortX-e.x)/this._gridWidth),this._mapRect.right=Math.floor((this._viewPortX+this._viewPortWidth+e.width+e.x)/this._gridWidth),this.clipViewPort(),this._mapLastRect.top=this._mapRect.top,this._mapLastRect.bottom=this._mapRect.bottom,this._mapLastRect.left=this._mapRect.left,this._mapLastRect.right=this._mapRect.right;for(var r,h=0;hthis._mapLastRect.left){if(t=this._mapRect.left-this._mapLastRect.left,t>0)for(r=this._mapLastRect.left;r0)for(r=this._mapRect.left;rthis._mapLastRect.right){if(i=this._mapRect.right-this._mapLastRect.right,i>0)for(r=this._mapLastRect.right+1;r<=this._mapLastRect.right+i;r++)for(e=this._mapRect.top;e<=this._mapRect.bottom;e++)this.showGrid(r,e)}else if(t=this._mapLastRect.right-this._mapRect.right,t>0)for(r=this._mapRect.right+1;r<=this._mapRect.right+t;r++)for(e=this._mapLastRect.top;e<=this._mapLastRect.bottom;e++)this.hideGrid(r,e);if(this._mapRect.top>this._mapLastRect.top){if(t=this._mapRect.top-this._mapLastRect.top,t>0)for(e=this._mapLastRect.top;e0)for(e=this._mapRect.top;ethis._mapLastRect.bottom){if(i=this._mapRect.bottom-this._mapLastRect.bottom,i>0)for(e=this._mapLastRect.bottom+1;e<=this._mapLastRect.bottom+i;e++)for(r=this._mapRect.left;r<=this._mapRect.right;r++)this.showGrid(r,e)}else if(t=this._mapLastRect.bottom-this._mapRect.bottom,t>0)for(e=this._mapRect.bottom+1;e<=this._mapRect.bottom+t;e++)for(r=this._mapLastRect.left;r<=this._mapLastRect.right;r++)this.hideGrid(r,e)},m.showGrid=function(t,i){if(!(0>t||t>=this._gridW||0>i||i>=this._gridH)){var e,r=0,h=0,a=this._gridArray[i][t];if(null==a){a=this._gridArray[i][t]=[];var s=0,o=0,l=0,n=0,_=this._gridWidth,p=this._gridHeight;switch(this.orientation){case"isometric":s=Math.floor(t*_),o=Math.floor(t*_+_),l=Math.floor(i*p),n=Math.floor(i*p+p);var m=0,d=0,c=0,u=0;break;case"staggered":s=Math.floor(t*_/this._mapTileW),o=Math.floor((t*_+_)/this._mapTileW),l=Math.floor(i*p/(this._mapTileH/2)),n=Math.floor((i*p+p)/(this._mapTileH/2));break;case"orthogonal":s=Math.floor(t*_/this._mapTileW),o=Math.floor((t*_+_)/this._mapTileW),l=Math.floor(i*p/this._mapTileH),n=Math.floor((i*p+p)/this._mapTileH);break;case"hexagonal":var g=2*this._mapTileH/3;s=Math.floor(t*_/this._mapTileW),o=Math.ceil((t*_+_)/this._mapTileW),l=Math.floor(i*p/g),n=Math.ceil((i*p+p)/g)}for(var f=null,y=0;yc&&(c=0),c>=x&&(c=x-1),0>u&&(n=0),u>=x&&(u=x-1),e.zOrder=this._totalGridNum*y+i*this._gridW+t,r=c;u>r;r++)for(h=0;r>=h;h++){var H=r-h,R=h,S=H-R+this._mapW;S>m&&d>=S&&f.drawTileTexture(e,H,R)&&e.drawImageNum++}break;case"staggered":for(e.zOrder=y*this._totalGridNum+i*this._gridW+t,r=l;n>r;r++)for(h=s;o>h;h++)f.drawTileTexture(e,h,r)&&e.drawImageNum++;break;case"orthogonal":case"hexagonal":switch(this._renderOrder){case"right-down":for(e.zOrder=y*this._totalGridNum+i*this._gridW+t,r=l;n>r;r++)for(h=s;o>h;h++)f.drawTileTexture(e,h,r)&&e.drawImageNum++;break;case"right-up":for(e.zOrder=y*this._totalGridNum+(this._gridH-1-i)*this._gridW+t,r=n-1;r>=l;r--)for(h=s;o>h;h++)f.drawTileTexture(e,h,r)&&e.drawImageNum++;break;case"left-down":for(e.zOrder=y*this._totalGridNum+i*this._gridW+(this._gridW-1-t),r=l;n>r;r++)for(h=o-1;h>=s;h--)f.drawTileTexture(e,h,r)&&e.drawImageNum++;break;case"left-up":for(e.zOrder=y*this._totalGridNum+(this._gridH-1-i)*this._gridW+(this._gridW-1-t),r=n-1;r>=l;r--)for(h=o-1;h>=s;h--)f.drawTileTexture(e,h,r)&&e.drawImageNum++}}e.isHaveAnimation||(e.autoSize=!0,e.cacheAs="bitmap",e.autoSize=!1),e.drawImageNum>0&&f.addChild(e),this._showGridKey&&e.graphics.drawRect(0,0,_,p,null,v)}}else for(r=0;r0&&e.show())}}},m.hideGrid=function(t,i){if(!(0>t||t>=this._gridW||0>i||i>=this._gridH)){var e=this._gridArray[i][t];if(e)for(var r,h=0;h0&&null!=r&&r.hide()}},m.getLayerObject=function(t,i){for(var e=null,r=0;r=t||(this._scale=t,this._viewPortWidth=this._rect.width/t,this._viewPortHeight=this._rect.height/t,this._mapSprite.scale(this._scale,this._scale),this.updateViewPort())}),h(0,m,"tileWidth",function(){return this._mapTileW}),h(0,m,"viewPortY",function(){return-this._viewPortY}),h(0,m,"tileHeight",function(){return this._mapTileH}),h(0,m,"width",function(){return this._width}),h(0,m,"numRowsTile",function(){return this._mapH}),h(0,m,"numColumnsTile",function(){return this._mapW}),h(0,m,"height",function(){return this._height}),h(0,m,"viewPortWidth",function(){return this._viewPortWidth}),h(0,m,"viewPortHeight",function(){return this._viewPortHeight}),h(0,m,"x",function(){return this._x}),h(0,m,"y",function(){return this._y}),h(0,m,"gridWidth",function(){return this._gridWidth}),h(0,m,"gridHeight",function(){return this._gridHeight}),h(0,m,"numColumnsGrid",function(){return this._gridW}),h(0,m,"numRowsGrid",function(){return this._gridH}),h(0,m,"renderOrder",function(){return this._renderOrder}),t.ORIENTATION_ORTHOGONAL="orthogonal",t.ORIENTATION_ISOMETRIC="isometric",t.ORIENTATION_STAGGERED="staggered",t.ORIENTATION_HEXAGONAL="hexagonal",t.RENDERORDER_RIGHTDOWN="right-down",t.RENDERORDER_RIGHTUP="right-up",t.RENDERORDER_LEFTDOWN="left-down",t.RENDERORDER_LEFTUP="left-up",t.__init$=function(){i=function(){function t(){this.left=0,this.top=0,this.right=0,this.bottom=0}r(t,"");var i=t.prototype;return i.clearAll=function(){this.left=this.top=this.right=this.bottom=0},t}(),a=function(){function t(){this.mAniIdArray=[],this.mDurationTimeArray=[],this.mTileTexSetArr=[]}return r(t,""),t}(),o=function(){function t(){this.firstgid=0,this.image="",this.imageheight=0,this.imagewidth=0,this.margin=0,this.name=0,this.properties=null,this.spacing=0,this.tileheight=0,this.tilewidth=0,this.titleoffsetX=0,this.titleoffsetY=0,this.tileproperties=null}r(t,"");var i=t.prototype;return i.init=function(t){this.firstgid=t.firstgid,this.image=t.image,this.imageheight=t.imageheight,this.imagewidth=t.imagewidth,this.margin=t.margin,this.name=t.name,this.properties=t.properties,this.spacing=t.spacing,this.tileheight=t.tileheight,this.tilewidth=t.tilewidth,this.tileproperties=t.tileproperties;var i=t.tileoffset;i&&(this.titleoffsetX=i.x,this.titleoffsetY=i.y)},t}()},t}(),d=function(){function t(){this.gid=-1,this.texture=null,this.offX=0,this.offY=0,this.textureArray=null,this.durationTimeArray=null,this.animationTotalTime=0,this.isAnimation=!1,this._spriteNum=0,this._aniDic=null,this._frameIndex=0,this._time=0,this._interval=0,this._preFrameTime=0}r(t,"laya.map.TileTexSet");var i=t.prototype;return i.addAniSprite=function(t,i){if(0!=this.animationTotalTime&&(null==this._aniDic&&(this._aniDic={}),0==this._spriteNum&&(e.timer.frameLoop(3,this,this.animate),this._preFrameTime=a.now(),this._frameIndex=0,this._time=0,this._interval=0),this._spriteNum++,this._aniDic[t]=i,this.textureArray&&this._frameIndex0&&this.durationTimeArray&&this.durationTimeArray.length>0){var t=a.now();this._interval=t-this._preFrameTime,this._preFrameTime=t,this._interval>this.animationTotalTime&&(this._interval=this._interval%this.animationTotalTime),this._time+=this._interval;for(var i=this.durationTimeArray[this._frameIndex];this._time>i;){this._time-=i,this._frameIndex++,(this._frameIndex>=this.durationTimeArray.length||this._frameIndex>=this.textureArray.length)&&(this._frameIndex=0);var e,r=this.textureArray[this._frameIndex];for(var h in this._aniDic)e=this._aniDic[h],this.drawTexture(e,r);i=this.durationTimeArray[this._frameIndex]}}},i.drawTexture=function(t,i){t.graphics.clear(),t.graphics.drawTexture(i.texture,i.offX,i.offY,i.texture.width,i.texture.height)},i.removeAniSprite=function(t){this._aniDic&&this._aniDic[t]&&(delete this._aniDic[t],this._spriteNum--,0==this._spriteNum&&e.timer.clear(this,this.animate))},i.showDebugInfo=function(){var t=null;return this._spriteNum>0&&(t="TileTextureSet::gid:"+this.gid.toString()+" 动画数:"+this._spriteNum.toString()),t},i.clearAll=function(){this.gid=-1,this.texture&&(this.texture.destroy(),this.texture=null),this.offX=0,this.offY=0,this.textureArray=null,this.durationTimeArray=null,this.isAnimation=!1,this._spriteNum=0,this._aniDic=null,this._frameIndex=0,this._preFrameTime=0,this._time=0,this._interval=0},t}(),c=function(t){function i(){this.relativeX=0,this.relativeY=0,this.isAloneObject=!1,this.isHaveAnimation=!1,this.aniSpriteArray=null,this.drawImageNum=0,this._map=null,i.__super.call(this)}r(i,"laya.map.GridSprite",t);var e=i.prototype;return e.initData=function(t,i){void 0===i&&(i=!1),this._map=t,this.isAloneObject=i},e.addAniSprite=function(t){null==this.aniSpriteArray&&(this.aniSpriteArray=[]),this.aniSpriteArray.push(t)},e.show=function(){if(!this.visible){if(this.visible=!0,null==this.aniSpriteArray)return;for(var t,i=0;ithis._map.viewPortWidth||this.y<0||this.y>this._map.viewPortHeight?this.hide():this.show()):this._map&&(this.x=this.relativeX+this._map.viewPortX,this.y=this.relativeY+this._map.viewPortY)},e.clearAll=function(){if(this._map&&(this._map=null),this.visible=!1,null!=this.aniSpriteArray){for(var t,i=0;i0&&(this._objDic={});for(var a,s=NaN,l=NaN,n=0;n=0&&i=0&&t0&&t.updatePos()},e.drawTileTexture=function(t,i,e){if(e>=0&&e=0&&in;n++){var l=h[n];s[n]="true"==l?!0:"false"==l?!1:l,null!=e&&(s[n]=e(l))}return s},t.toColor=function(t){for(var i=t.toString("16");i.length<6;)i="0"+i;return"#"+i},t.gray=function(i,e){void 0===e&&(e=!0),e?t.addFilter(i,t.grayFilter):t.clearFilter(i,r)},t.addFilter=function(t,i){var e=t.filters||[];e.push(i),t.filters=e},t.clearFilter=function(t,i){var s=t.filters;if(null!=s&&s.length>0){for(var h=s.length-1;h>-1;h--){var n=s[h];e.__typeof(n,i)&&s.splice(h,1)}t.filters=s}},s(t,["grayFilter",function(){return this.grayFilter=new r([.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,0,0,0,1,0])}]),t}(),z=function(){function t(){}return h(t,"UIConfig"),t.touchScrollEnable=!0,t.mouseWheelEnable=!0,t.showButtons=!0,t.popupBgColor="#000000",t.popupBgAlpha=.5,t}(),L=function(t){function i(){this.autoCacheCmd=!0,this._width=0,this._height=0,this._source=null,this._sizeGrid=null,this._isChanged=!1,this._offset=null,i.__super.call(this)}h(i,"laya.ui.AutoBitmap",t);var s=i.prototype;return s.destroy=function(){t.prototype.destroy.call(this),this._source=null,this._sizeGrid=null,this._offset=null},s._setChanged=function(){this._isChanged||(this._isChanged=!0,e.timer.callLater(this,this.changeSource))},s.changeSource=function(){i.cacheCount++>50&&i.clearCache(),this._isChanged=!1;var t=this._source;if(t&&t.bitmap){var e=this.width,s=this.height,h=this._sizeGrid,n=t.sourceWidth,o=t.sourceHeight;if(!h||n===e&&o===s)this.cleanByTexture(t,this._offset?this._offset[0]:0,this._offset?this._offset[1]:0,e,s);else{t.$_GID||(t.$_GID=w.getGID());var l=t.$_GID+"."+e+"."+s+"."+h.join(".");if(i.cmdCaches[l])return void(this.cmds=i.cmdCaches[l]);this.clear();var r=h[0],a=h[1],c=h[2],u=h[3],_=h[4];u+a>e&&(a=0),u&&r&&this.drawTexture(i.getTexture(t,0,0,u,r),0,0,u,r),a&&r&&this.drawTexture(i.getTexture(t,n-a,0,a,r),e-a,0,a,r),u&&c&&this.drawTexture(i.getTexture(t,0,o-c,u,c),0,s-c,u,c),a&&c&&this.drawTexture(i.getTexture(t,n-a,o-c,a,c),e-a,s-c,a,c),r&&this.drawBitmap(_,i.getTexture(t,u,0,n-u-a,r),u,0,e-u-a,r),c&&this.drawBitmap(_,i.getTexture(t,u,o-c,n-u-a,c),u,s-c,e-u-a,c),u&&this.drawBitmap(_,i.getTexture(t,0,r,u,o-r-c),0,r,u,s-r-c),a&&this.drawBitmap(_,i.getTexture(t,n-a,r,a,o-r-c),e-a,r,a,s-r-c),this.drawBitmap(_,i.getTexture(t,u,r,n-u-a,o-r-c),u,r,e-u-a,s-r-c),this.autoCacheCmd&&!C.isConchApp&&(i.cmdCaches[l]=this.cmds)}this._repaint()}},s.drawBitmap=function(t,i,e,s,h,n){void 0===h&&(h=0),void 0===n&&(n=0),t?this.fillTexture(i,e,s,h,n):this.drawTexture(i,e,s,h,n)},n(0,s,"sizeGrid",function(){return this._sizeGrid},function(t){this._sizeGrid=t,this._setChanged()}),n(0,s,"width",function(){return this._width?this._width:this._source?this._source.sourceWidth:0},function(t){this._width!=t&&(this._width=t,this._setChanged())}),n(0,s,"height",function(){return this._height?this._height:this._source?this._source.sourceHeight:0},function(t){this._height!=t&&(this._height=t,this._setChanged())}),n(0,s,"source",function(){return this._source},function(t){t?(this._source=t,this._setChanged()):(this._source=null,this.clear())}),i.getTexture=function(t,e,s,h,n){0>=h&&(h=1),0>=n&&(n=1),t.$_GID||(t.$_GID=w.getGID());var o=t.$_GID+"."+e+"."+s+"."+h+"."+n,l=i.textureCache[o];return l||(l=i.textureCache[o]=S.createFromTexture(t,e,s,h,n)),l},i.clearCache=function(){i.cacheCount=0,i.cmdCaches={},i.textureCache={}},i.setCache=function(t,e){i.cacheCount++,i.textureCache[t]=e},i.getCache=function(t){return i.textureCache[t]},i.cmdCaches={},i.cacheCount=0,i.textureCache={},i}(d),M=(function(t){function i(){i.__super.call(this)}return h(i,"laya.ui.UIEvent",t),i.SHOW_TIP="showtip",i.HIDE_TIP="hidetip",i}(c),function(t){function i(){this._comXml=null,this._dataSource=null,this._toolTip=null,this._tag=null,this._disabled=!1,this._gray=!1,i.__super.call(this),this._layout=B.EMPTY,this.preinitialize(),this.createChildren(),this.initialize()}h(i,"laya.ui.Component",t);var s=i.prototype;return e.imps(s,{"laya.ui.IComponent":!0}),s.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._dataSource=this._layout=null,this._tag=null,this._toolTip=null},s.preinitialize=function(){},s.createChildren=function(){},s.initialize=function(){},s.callLater=function(t,i){e.timer.callLater(this,t,i)},s.runCallLater=function(t){e.timer.runCallLater(this,t)},s.commitMeasure=function(){},s.changeSize=function(){this.event("resize")},s.getLayout=function(){return this._layout===B.EMPTY&&(this._layout=new B),this._layout},s.onRemoved=function(){this.parent.off("resize",this,this.onCompResize)},s.onAdded=function(){this.parent.on("resize",this,this.onCompResize),this.resetLayoutX(),this.resetLayoutY()},s.onCompResize=function(){this._layout&&this._layout.enable&&(this.resetLayoutX(),this.resetLayoutY())},s.resetLayoutX=function(){var t=this._layout;isNaN(t.anchorX)||(this.pivotX=t.anchorX*this.width);var i=this.parent;i&&(isNaN(t.centerX)?isNaN(t.left)?isNaN(t.right)||(this.x=i.width-this.displayWidth-t.right+this.pivotX*this.scaleX):(this.x=t.left+this.pivotX*this.scaleX,isNaN(t.right)||(this.width=(i._width-t.left-t.right)/this.scaleX)):this.x=.5*(i.width-this.displayWidth)+t.centerX+this.pivotX*this.scaleX)},s.resetLayoutY=function(){var t=this._layout;isNaN(t.anchorY)||(this.pivotY=t.anchorY*this.height);var i=this.parent;i&&(isNaN(t.centerY)?isNaN(t.top)?isNaN(t.bottom)||(this.y=i.height-this.displayHeight-t.bottom+this.pivotY*this.scaleY):(this.y=t.top+this.pivotY*this.scaleY,isNaN(t.bottom)||(this.height=(i._height-t.top-t.bottom)/this.scaleY)):this.y=.5*(i.height-this.displayHeight)+t.centerY+this.pivotY*this.scaleY)},s.onMouseOver=function(t){e.stage.event("showtip",this._toolTip)},s.onMouseOut=function(t){e.stage.event("hidetip",this._toolTip)},n(0,s,"displayWidth",function(){return this.width*this.scaleX}),n(0,s,"width",function(){return this._width?this._width:this.measureWidth},function(t){this._width!=t&&(this._width=t,this.model&&this.model.size(this._width,this._height),this.callLater(this.changeSize),!this._layout.enable||isNaN(this._layout.centerX)&&isNaN(this._layout.right)&&isNaN(this._layout.anchorX)||this.resetLayoutX())}),n(0,s,"measureWidth",function(){var t=0;this.commitMeasure();for(var i=this.numChildren-1;i>-1;i--){var e=this.getChildAt(i);e.visible&&(t=Math.max(e.x+e.width*e.scaleX,t))}return t}),n(0,s,"layOutEabled",null,function(t){this._layout&&this._layout.enable!=t&&(this._layout.enable=t,this.parent?this.onAdded():(this.on("added",this,this.onAdded),this.on("removed",this,this.onRemoved)))}),n(0,s,"displayHeight",function(){return this.height*this.scaleY}),n(0,s,"height",function(){return this._height?this._height:this.measureHeight},function(t){this._height!=t&&(this._height=t,this.model&&this.model.size(this._width,this._height),this.callLater(this.changeSize),!this._layout.enable||isNaN(this._layout.centerY)&&isNaN(this._layout.bottom)&&isNaN(this._layout.anchorY)||this.resetLayoutY())}),n(0,s,"dataSource",function(){return this._dataSource},function(t){this._dataSource=t;for(var i in this._dataSource)this.hasOwnProperty(i)&&(this[i]=this._dataSource[i])}),n(0,s,"scaleY",t.prototype._$get_scaleY,function(i){t.prototype._$get_scaleY.call(this)!=i&&(t.prototype._$set_scaleY.call(this,i),this.callLater(this.changeSize),this._layout.enable&&this.resetLayoutY())}),n(0,s,"measureHeight",function(){var t=0;this.commitMeasure();for(var i=this.numChildren-1;i>-1;i--){var e=this.getChildAt(i);e.visible&&(t=Math.max(e.y+e.height*e.scaleY,t))}return t}),n(0,s,"scaleX",t.prototype._$get_scaleX,function(i){t.prototype._$get_scaleX.call(this)!=i&&(t.prototype._$set_scaleX.call(this,i),this.callLater(this.changeSize),this._layout.enable&&this.resetLayoutX())}),n(0,s,"top",function(){return this._layout.top},function(t){this.getLayout().top=t,this.layOutEabled=!0,this.resetLayoutY()}),n(0,s,"bottom",function(){return this._layout.bottom},function(t){this.getLayout().bottom=t,this.layOutEabled=!0,this.resetLayoutY()}),n(0,s,"left",function(){return this._layout.left},function(t){this.getLayout().left=t,this.layOutEabled=!0,this.resetLayoutX()}),n(0,s,"right",function(){return this._layout.right},function(t){this.getLayout().right=t,this.layOutEabled=!0,this.resetLayoutX()}),n(0,s,"centerX",function(){return this._layout.centerX},function(t){this.getLayout().centerX=t,this.layOutEabled=!0,this.resetLayoutX()}),n(0,s,"centerY",function(){return this._layout.centerY},function(t){this.getLayout().centerY=t,this.layOutEabled=!0,this.resetLayoutY()}),n(0,s,"anchorX",function(){return this._layout.anchorX},function(t){this.getLayout().anchorX=t,this.layOutEabled=!0,this.resetLayoutX()}),n(0,s,"anchorY",function(){return this._layout.anchorY},function(t){this.getLayout().anchorY=t,this.layOutEabled=!0,this.resetLayoutY()}),n(0,s,"tag",function(){return this._tag},function(t){this._tag=t}),n(0,s,"toolTip",function(){return this._toolTip},function(t){this._toolTip!=t&&(this._toolTip=t,null!=t?(this.on("mouseover",this,this.onMouseOver),this.on("mouseout",this,this.onMouseOut)):(this.off("mouseover",this,this.onMouseOver),this.off("mouseout",this,this.onMouseOut)))}),n(0,s,"comXml",function(){return this._comXml},function(t){this._comXml=t}),n(0,s,"gray",function(){return this._gray},function(t){t!==this._gray&&(this._gray=t,I.gray(this,t))}),n(0,s,"disabled",function(){return this._disabled},function(t){t!==this._disabled&&(this.gray=this._disabled=t,this.mouseEnabled=!t)}),i}(v)),T=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.Box",t);var s=i.prototype;return e.imps(s,{"laya.ui.IBox":!0}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(t){this._dataSource=t;for(var i in t){var e=this.getChildByName(i);e?e.dataSource=t[i]:this.hasOwnProperty(i)&&(this[i]=t[i])}}),i}(M),P=function(t){function i(t,e){this.toggle=!1,this._bitmap=null,this._text=null,this._strokeColors=null,this._state=0,this._selected=!1,this._skin=null,this._autoSize=!0,this._sources=null,this._clickHandler=null,this._stateChanged=!1,i.__super.call(this),this._labelColors=k.buttonLabelColors,this._stateNum=k.buttonStateNum,void 0===e&&(e=""),this.skin=t,this.label=e}h(i,"laya.ui.Button",t);var o=i.prototype;return e.imps(o,{"laya.ui.ISelect":!0}),o.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._bitmap&&this._bitmap.destroy(),this._text&&this._text.destroy(i),this._bitmap=null,this._text=null,this._clickHandler=null,this._labelColors=this._sources=this._strokeColors=null},o.createChildren=function(){this.graphics=this._bitmap=new L},o.createText=function(){this._text||(this._text=new b,this._text.overflow=b.HIDDEN,this._text.align="center",this._text.valign="middle")},o.initialize=function(){this.on("mouseover",this,this.onMouse),this.on("mouseout",this,this.onMouse),this.on("mousedown",this,this.onMouse),this.on("mouseup",this,this.onMouse),this.on("click",this,this.onMouse)},o.onMouse=function(t){return this.toggle===!1&&this._selected?void 0:"click"===t.type?(this.toggle&&(this.selected=!this._selected),void(this._clickHandler&&this._clickHandler.run())):void(!this._selected&&(this.state=i.stateMap[t.type]))},o.changeClips=function(){var t=g.getRes(this._skin);if(!t)return void console.log("lose skin",this._skin);var i=t.sourceWidth,e=t.sourceHeight/this._stateNum,s=this._skin+this._stateNum,h=L.getCache(s);if(h)this._sources=h;else{if(this._sources=[],1===this._stateNum)this._sources.push(t);else for(var n=0;nt?1:t>3?3:t,this.callLater(this.changeClips))}),n(0,o,"strokeColors",function(){return this._strokeColors?this._strokeColors.join(","):""},function(t){this._strokeColors=I.fillArray(k.buttonLabelColors,t,String),this._setStateChanged()}),n(0,o,"labelColors",function(){return this._labelColors.join(",")},function(t){this._labelColors=I.fillArray(k.buttonLabelColors,t,String),this._setStateChanged()}),n(0,o,"measureWidth",function(){return this.runCallLater(this.changeClips),this._autoSize?this._bitmap.width:(this.runCallLater(this.changeState),this._bitmap.width+(this._text?this._text.width:0))}),n(0,o,"label",function(){return this._text?this._text.text:null},function(t){(this._text||t)&&(this.createText(),this._text.text!=t&&(t&&!this._text.displayedInStage&&this.addChild(this._text),this._text.text=(t+"").replace(/\\n/g,"\n"),this._setStateChanged()))}),n(0,o,"selected",function(){return this._selected},function(t){this._selected!=t&&(this._selected=t,this.state=this._selected?2:0,this.event("change"))}),n(0,o,"labelPadding",function(){return this.createText(),this._text.padding.join(",")},function(t){this.createText(),this._text.padding=I.fillArray(k.labelPadding,t,Number)}),n(0,o,"labelSize",function(){return this.createText(),this._text.fontSize},function(t){this.createText(),this._text.fontSize=t}),n(0,o,"labelStroke",function(){return this.createText(),this._text.stroke},function(t){this.createText(),this._text.stroke=t}),n(0,o,"labelBold",function(){return this.createText(),this._text.bold},function(t){this.createText(),this._text.bold=t}),n(0,o,"labelFont",function(){return this.createText(),this._text.font},function(t){this.createText(),this._text.font=t}),n(0,o,"labelAlign",function(){return this.createText(),this._text.align},function(t){this.createText(),this._text.align=t}),n(0,o,"clickHandler",function(){return this._clickHandler},function(t){this._clickHandler=t}),n(0,o,"sizeGrid",function(){return this._bitmap.sizeGrid?this._bitmap.sizeGrid.join(","):null},function(t){this._bitmap.sizeGrid=I.fillArray(k.defaultSizeGrid,t,Number)}),n(0,o,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._autoSize&&(this._bitmap.width=i,this._text&&(this._text.width=i))}),n(0,o,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._autoSize&&(this._bitmap.height=i,this._text&&(this._text.height=i))}),n(0,o,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i||"string"==typeof i?this.label=i+"":t.prototype._$set_dataSource.call(this,i)}),n(0,o,"iconOffset",function(){return this._bitmap._offset?null:this._bitmap._offset.join(",")},function(t){t?this._bitmap._offset=I.fillArray([1,1],t,Number):this._bitmap._offset=[]}),s(i,["stateMap",function(){return this.stateMap={mouseup:0,mouseover:1,mousedown:2,mouseout:0}}]),i}(M),N=function(t){function i(t,e,s){this._sources=null,this._bitmap=null,this._skin=null,this._clipX=1,this._clipY=1,this._clipWidth=0,this._clipHeight=0,this._autoPlay=!1,this._interval=50,this._complete=null,this._isPlaying=!1,this._index=0,this._clipChanged=!1,this._group=null,i.__super.call(this),void 0===e&&(e=1),void 0===s&&(s=1),this._clipX=e,this._clipY=s,this.skin=t}h(i,"laya.ui.Clip",t);var s=i.prototype;return s.destroy=function(i){void 0===i&&(i=!1),t.prototype.destroy.call(this,!0),this._bitmap&&this._bitmap.destroy(),this._bitmap=null,this._sources=null},s.dispose=function(){this.destroy(!0),e.loader.clearRes(this._skin)},s.createChildren=function(){this.graphics=this._bitmap=new L},s.initialize=function(){this.on("display",this,this._onDisplay),this.on("undisplay",this,this._onDisplay)},s._onDisplay=function(t){this._isPlaying?this._displayedInStage?this.play():this.stop():this._autoPlay&&this._displayedInStage&&this.play()},s.changeClip=function(){if(this._clipChanged=!1,this._skin){var t=g.getRes(this._skin);t?this.loadComplete(this._skin,t):e.loader.load(this._skin,f.create(this,this.loadComplete,[this._skin]))}},s.loadComplete=function(t,i){if(t===this._skin&&i){this._clipWidth||(this._clipWidth=Math.ceil(i.sourceWidth/this._clipX)),this._clipHeight||(this._clipHeight=Math.ceil(i.sourceHeight/this._clipY));var e=this._skin+this._clipWidth+this._clipHeight,s=L.getCache(e);if(s)this._sources=s;else{this._sources=[];for(var h=0;h=this._sources.length&&(this._index=0))},s.stop=function(){this._isPlaying=!1,e.timer.clear(this,this._loop)},s._setClipChanged=function(){this._clipChanged||(this._clipChanged=!0,this.callLater(this.changeClip))},n(0,s,"interval",function(){return this._interval},function(t){this._interval!=t&&(this._interval=t,this._isPlaying&&this.play())}),n(0,s,"skin",function(){return this._skin},function(t){this._skin!=t&&(this._skin=t,t?this._setClipChanged():this._bitmap.source=null)}),n(0,s,"sources",function(){return this._sources},function(t){this._sources=t,this.index=this._index,this.event("loaded")}),n(0,s,"clipX",function(){return this._clipX},function(t){this._clipX=t,this._setClipChanged()}),n(0,s,"clipY",function(){return this._clipY},function(t){this._clipY=t,this._setClipChanged()}),n(0,s,"total",function(){return this.runCallLater(this.changeClip),this._sources?this._sources.length:0}),n(0,s,"clipWidth",function(){return this._clipWidth},function(t){this._clipWidth=t,this._setClipChanged()}),n(0,s,"sizeGrid",function(){return this._bitmap.sizeGrid?this._bitmap.sizeGrid.join(","):null},function(t){this._bitmap.sizeGrid=I.fillArray(k.defaultSizeGrid,t,Number)}),n(0,s,"group",function(){return this._group},function(t){t&&this._skin&&g.setGroup(this._skin,t),this._group=t}),n(0,s,"clipHeight",function(){return this._clipHeight},function(t){this._clipHeight=t,this._setClipChanged()}),n(0,s,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._bitmap.width=i}),n(0,s,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._bitmap.height=i}),n(0,s,"measureWidth",function(){return this.runCallLater(this.changeClip),this._bitmap.width}),n(0,s,"measureHeight",function(){return this.runCallLater(this.changeClip),this._bitmap.height}),n(0,s,"index",function(){return this._index},function(t){this._index=t,this._bitmap&&this._sources&&(this._bitmap.source=this._sources[t]),this.event("change")}),n(0,s,"autoPlay",function(){return this._autoPlay},function(t){this._autoPlay!=t&&(this._autoPlay=t,t?this.play():this.stop())}),n(0,s,"isPlaying",function(){return this._isPlaying},function(t){this._isPlaying=t}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i&&Math.floor(i)==i||"string"==typeof i?this.index=parseInt(i):t.prototype._$set_dataSource.call(this,i)}),n(0,s,"bitmap",function(){return this._bitmap}),i}(M),H=function(t){function i(){this.changeHandler=null,this._gridSize=11,this._bgColor="#ffffff",this._borderColor="#000000",this._inputColor="#000000",this._inputBgColor="#efefef",this._colorPanel=null,this._colorTiles=null,this._colorBlock=null,this._colorInput=null,this._colorButton=null,this._colors=[],this._selectedColor="#000000",this._panelChanged=!1,i.__super.call(this)}h(i,"laya.ui.ColorPicker",t);var s=i.prototype;return s.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._colorPanel&&this._colorPanel.destroy(i),this._colorButton&&this._colorButton.destroy(i),this._colorPanel=null,this._colorTiles=null,this._colorBlock=null,this._colorInput=null,this._colorButton=null,this._colors=null,this.changeHandler=null},s.createChildren=function(){this.addChild(this._colorButton=new P),this._colorPanel=new T,this._colorPanel.size(230,166),this._colorPanel.addChild(this._colorTiles=new v),this._colorPanel.addChild(this._colorBlock=new v),this._colorPanel.addChild(this._colorInput=new p)},s.initialize=function(){this._colorButton.on("click",this,this.onColorButtonClick),this._colorBlock.pos(5,5),this._colorInput.pos(60,5),this._colorInput.size(60,20),this._colorInput.on("change",this,this.onColorInputChange),this._colorInput.on("keydown",this,this.onColorFieldKeyDown),this._colorTiles.pos(5,30),this._colorTiles.on("mousemove",this,this.onColorTilesMouseMove),this._colorTiles.on("click",this,this.onColorTilesClick),this._colorTiles.size(20*this._gridSize,12*this._gridSize),this._colorPanel.on("mousedown",this,this.onPanelMouseDown),this.bgColor=this._bgColor},s.onPanelMouseDown=function(t){t.stopPropagation()},s.changePanel=function(){this._panelChanged=!1;var t=this._colorPanel.graphics;t.clear(),t.drawRect(0,0,230,166,this._bgColor,this._borderColor),this.drawBlock(this._selectedColor),this._colorInput.borderColor=this._borderColor,this._colorInput.bgColor=this._inputBgColor,this._colorInput.color=this._inputColor,t=this._colorTiles.graphics,t.clear();for(var i=[0,3355443,6710886,10066329,13421772,16777215,16711680,65280,255,16776960,65535,16711935],e=0;12>e;e++)for(var s=0;20>s;s++){var h=0;h=0===s?i[e]:1===s?0:51*(((3*e+s/6)%3<<0)+3*(e/6<<0))<<16|s%6*51<<8|(e<<0)%6*51;var n=I.toColor(h);this._colors.push(n);var o=s*this._gridSize,l=e*this._gridSize;t.drawRect(o,l,this._gridSize,this._gridSize,n,"#000000")}},s.onColorButtonClick=function(t){this._colorPanel.parent?this.close():this.open()},s.open=function(){var t=this.localToGlobal(new m),i=t.x+this._colorPanel.width<=e.stage.width?t.x:e.stage.width-this._colorPanel.width,s=t.y+this._colorButton.height;s=s+this._colorPanel.height<=e.stage.height?s:t.y-this._colorPanel.height,this._colorPanel.pos(i,s),e.stageBox.addChild(this._colorPanel),e.stage.on("mousedown",this,this.removeColorBox)},s.close=function(){e.stage.off("mousedown",this,this.removeColorBox),this._colorPanel.removeSelf()},s.removeColorBox=function(t){this.close()},s.onColorFieldKeyDown=function(t){13==t.keyCode&&(this._colorInput.text?this.selectedColor=this._colorInput.text:this.selectedColor=null,this.close(),t.stopPropagation())},s.onColorInputChange=function(t){this._colorInput.text?this.drawBlock(this._colorInput.text):this.drawBlock("#FFFFFF")},s.onColorTilesClick=function(t){this.selectedColor=this.getColorByMouse(),this.close()},s.onColorTilesMouseMove=function(t){this._colorInput.focus=!1;var i=this.getColorByMouse();this._colorInput.text=i,this.drawBlock(i)},s.getColorByMouse=function(){var t=this._colorTiles.getMousePoint(),i=Math.floor(t.x/this._gridSize),e=Math.floor(t.y/this._gridSize);return this._colors[20*e+i]},s.drawBlock=function(t){var i=this._colorBlock.graphics;i.clear();var e=t?t:"#ffffff";i.drawRect(0,0,50,20,e,this._borderColor),t||i.drawLine(0,0,50,20,"#ff0000")},s.changeColor=function(){var t=this.graphics;t.clear();var i=this._selectedColor||"#000000";t.drawRect(0,0,this._colorButton.width,this._colorButton.height,i)},s._setPanelChanged=function(){this._panelChanged||(this._panelChanged=!0,this.callLater(this.changePanel))},n(0,s,"inputBgColor",function(){return this._inputBgColor},function(t){this._inputBgColor=t,this._setPanelChanged()}),n(0,s,"selectedColor",function(){return this._selectedColor},function(t){this._selectedColor!=t&&(this._selectedColor=this._colorInput.text=t,this.drawBlock(t),this.changeColor(),this.changeHandler&&this.changeHandler.runWith(this._selectedColor),this.event("change",c.EMPTY.setTo("change",this,this)))}),n(0,s,"skin",function(){return this._colorButton.skin},function(t){this._colorButton.skin=t,this.changeColor()}),n(0,s,"bgColor",function(){return this._bgColor},function(t){this._bgColor=t,this._setPanelChanged()}),n(0,s,"borderColor",function(){return this._borderColor},function(t){this._borderColor=t,this._setPanelChanged()}),n(0,s,"inputColor",function(){return this._inputColor},function(t){this._inputColor=t,this._setPanelChanged()}),i}(M),Y=function(t){function i(t,e){this._visibleNum=6,this._button=null,this._list=null,this._isOpen=!1,this._scrollBar=null,this._itemSize=12,this._labels=[],this._selectedIndex=-1,this._selectHandler=null,this._itemHeight=NaN,this._listHeight=NaN,this._listChanged=!1,this._itemChanged=!1,this._scrollBarSkin=null,this.itemRender=null,i.__super.call(this),this._itemColors=k.comboBoxItemColors,this.skin=t,this.labels=e}h(i,"laya.ui.ComboBox",t);var s=i.prototype;return s.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._button&&this._button.destroy(i),this._list&&this._list.destroy(i),this._scrollBar&&this._scrollBar.destroy(i),this._button=null,this._list=null,this._scrollBar=null,this._itemColors=null,this._labels=null,this._selectHandler=null},s.createChildren=function(){this.addChild(this._button=new P),this._button.text.align="left",this._button.labelPadding="0,0,0,5",this._button.on("mousedown",this,this.onButtonMouseDown)},s._createList=function(){this._list=new W,this._list.selectEnable=!0,this._list.on("mousedown",this,this.onListDown),this._list.mouseHandler=f.create(this,this.onlistItemMouse,null,!1),this._scrollBarSkin&&(this._list.addChild(this._scrollBar=new Z),this._scrollBar.skin=this._scrollBarSkin,this._scrollBar.name="scrollBar",this._scrollBar.y=1,this._scrollBar.on("mousedown",this,this.onScrollBarDown))},s.onListDown=function(t){t.stopPropagation()},s.onScrollBarDown=function(t){t.stopPropagation()},s.onButtonMouseDown=function(t){this.callLater(this.switchTo,[!this._isOpen])},s.changeList=function(){this._listChanged=!1;var t=this.width-2,i=this._itemColors[2];this._itemHeight=this._itemSize+6,this._list.itemRender=this.itemRender||{type:"Box",child:[{type:"Label",props:{name:"label",x:1,padding:"3,3,3,3",width:t,height:this._itemHeight,fontSize:this._itemSize,color:i}}]},this._list.repeatY=this._visibleNum,this._scrollBar&&(this._scrollBar.x=this.width-this._scrollBar.width-1),this._list.refresh()},s.onlistItemMouse=function(t,i){var e=t.type;if("mouseover"===e||"mouseout"===e){var s=this._list.getCell(i);if(!s)return;var h=s.getChildByName("label");h&&("mouseover"===e?(h.bgColor=this._itemColors[0],h.color=this._itemColors[1]):(h.bgColor=null,h.color=this._itemColors[2]))}else"click"===e&&(this.selectedIndex=i,this.isOpen=!1)},s.switchTo=function(t){this.isOpen=t},s.changeOpen=function(){this.isOpen=!this._isOpen},s.changeItem=function(){this._itemChanged=!1,this.runCallLater(this.changeList),this._listHeight=this._labels.length>0?Math.min(this._visibleNum,this._labels.length)*this._itemHeight:this._itemHeight,this._scrollBar&&(this._scrollBar.height=this._listHeight-2);var t=this._list.graphics;t.clear(),t.drawRect(0,0,this.width-1,this._listHeight,this._itemColors[4],this._itemColors[3]);var i=this._list.array||[];i.length=0;for(var e=0,s=this._labels.length;s>e;e++)i.push({label:this._labels[e]});this._list.array=i,this._visibleNum>i.length?this._list.height=this._listHeight:this._list.height=0},s.changeSelected=function(){this._button.label=this.selectedLabel},s.removeList=function(t){this.isOpen=!1},n(0,s,"selectedIndex",function(){return this._selectedIndex},function(t){this._selectedIndex!=t&&(this._selectedIndex=t,this._labels.length>0?this.changeSelected():this.callLater(this.changeSelected),this.event("change",[c.EMPTY.setTo("change",this,this)]),this._selectHandler&&this._selectHandler.runWith(this._selectedIndex))}),n(0,s,"measureHeight",function(){return this._button.height}),n(0,s,"skin",function(){return this._button.skin},function(t){this._button.skin!=t&&(this._button.skin=t,this._listChanged=!0)}),n(0,s,"measureWidth",function(){return this._button.width}),n(0,s,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._button.width=this._width,this._itemChanged=!0,this._listChanged=!0}),n(0,s,"selectedLabel",function(){return this._selectedIndex>-1&&this._selectedIndex0&&(this.selectedIndex=-1),t?this._labels=t.split(","):this._labels.length=0,this._itemChanged=!0}),n(0,s,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._button.height=this._height}),n(0,s,"selectHandler",function(){return this._selectHandler},function(t){this._selectHandler=t}),n(0,s,"visibleNum",function(){return this._visibleNum},function(t){this._visibleNum=t,this._listChanged=!0}),n(0,s,"labelBold",function(){return this._button.text.bold},function(t){this._button.text.bold=t}),n(0,s,"itemColors",function(){return String(this._itemColors)},function(t){this._itemColors=I.fillArray(this._itemColors,t,String),this._listChanged=!0}),n(0,s,"itemSize",function(){return this._itemSize},function(t){this._itemSize=t,this._listChanged=!0}),n(0,s,"scrollBar",function(){return this._scrollBar}),n(0,s,"isOpen",function(){return this._isOpen},function(t){if(this._isOpen!=t)if(this._isOpen=t,this._button.selected=this._isOpen,this._isOpen){this._list||this._createList(),this._listChanged&&this.changeList(),this._itemChanged&&this.changeItem(); +var i=this.localToGlobal(m.TEMP.setTo(0,0)),s=i.y+this._button.height;s=s+this._listHeight<=e.stage.height?s:i.y-this._listHeight,this._list.pos(i.x,s),e.stageBox.addChild(this._list),e.stage.once("mousedown",this,this.removeList),this._list.selectedIndex=this._selectedIndex}else this._list&&this._list.removeSelf()}),n(0,s,"scrollBarSkin",function(){return this._scrollBarSkin},function(t){this._scrollBarSkin=t}),n(0,s,"sizeGrid",function(){return this._button.sizeGrid},function(t){this._button.sizeGrid=t}),n(0,s,"button",function(){return this._button}),n(0,s,"list",function(){return this._list||this._createList(),this._list}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i&&Math.floor(i)==i||"string"==typeof i?this.selectedIndex=parseInt(i):i instanceof Array?this.labels=i.join(","):t.prototype._$set_dataSource.call(this,i)}),n(0,s,"labelColors",function(){return this._button.labelColors},function(t){this._button.labelColors!=t&&(this._button.labelColors=t)}),n(0,s,"labelPadding",function(){return this._button.text.padding.join(",")},function(t){this._button.text.padding=I.fillArray(k.labelPadding,t,Number)}),n(0,s,"labelSize",function(){return this._button.text.fontSize},function(t){this._button.text.fontSize=t}),n(0,s,"labelFont",function(){return this._button.text.font},function(t){this._button.text.font=t}),n(0,s,"stateNum",function(){return this._button.stateNum},function(t){this._button.stateNum=t}),i}(M),X=function(t){function i(t){this.rollRatio=.95,this.changeHandler=null,this.scaleBar=!0,this.autoHide=!1,this.elasticDistance=0,this.elasticBackTime=500,this.upButton=null,this.downButton=null,this.slider=null,this._scrollSize=1,this._skin=null,this._thumbPercent=1,this._target=null,this._lastPoint=null,this._lastOffset=0,this._checkElastic=!1,this._isElastic=!1,this._value=NaN,this._hide=!1,this._clickOnly=!0,this._offsets=null,i.__super.call(this),this._showButtons=z.showButtons,this._touchScrollEnable=z.touchScrollEnable,this._mouseWheelEnable=z.mouseWheelEnable,this.skin=t,this.max=1}h(i,"laya.ui.ScrollBar",t);var s=i.prototype;return s.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this.upButton&&this.upButton.destroy(i),this.downButton&&this.downButton.destroy(i),this.slider&&this.slider.destroy(i),this.upButton=this.downButton=null,this.slider=null,this.changeHandler=null,this._offsets=null},s.createChildren=function(){this.addChild(this.slider=new $),this.addChild(this.upButton=new P),this.addChild(this.downButton=new P)},s.initialize=function(){this.slider.showLabel=!1,this.slider.on("change",this,this.onSliderChange),this.slider.setSlider(0,0,0),this.upButton.on("mousedown",this,this.onButtonMouseDown),this.downButton.on("mousedown",this,this.onButtonMouseDown)},s.onSliderChange=function(){this.value=this.slider.value},s.onButtonMouseDown=function(t){var i=t.currentTarget===this.upButton;this.slide(i),e.timer.once(k.scrollBarDelayTime,this,this.startLoop,[i]),e.stage.once("mouseup",this,this.onStageMouseUp)},s.startLoop=function(t){e.timer.frameLoop(1,this,this.slide,[t])},s.slide=function(t){t?this.value-=this._scrollSize:this.value+=this._scrollSize},s.onStageMouseUp=function(t){e.timer.clear(this,this.startLoop),e.timer.clear(this,this.slide)},s.changeScrollBar=function(){this.upButton.visible=this._showButtons,this.downButton.visible=this._showButtons,this._showButtons&&(this.upButton.skin=this._skin.replace(".png","$up.png"),this.downButton.skin=this._skin.replace(".png","$down.png")),this.slider.isVertical?this.slider.y=this._showButtons?this.upButton.height:0:this.slider.x=this._showButtons?this.upButton.width:0,this.resetPositions()},s.changeSize=function(){t.prototype.changeSize.call(this),this.resetPositions(),this.event("change"),this.changeHandler&&this.changeHandler.runWith(this.value)},s.resetPositions=function(){this.slider.isVertical?this.slider.height=this.height-(this._showButtons?this.upButton.height+this.downButton.height:0):this.slider.width=this.width-(this._showButtons?this.upButton.width+this.downButton.width:0),this.resetButtonPosition()},s.resetButtonPosition=function(){this.slider.isVertical?this.downButton.y=this.slider.y+this.slider.height:this.downButton.x=this.slider.x+this.slider.width},s.setScroll=function(t,i,e){this.runCallLater(this.changeSize),this.slider.setSlider(t,i,e),this.slider.bar.visible=i>0,!this._hide&&this.autoHide&&(this.visible=!1)},s.onTargetMouseWheel=function(t){this.value-=t.delta*this._scrollSize,this.target=this._target},s.onTargetMouseDown=function(t){this._clickOnly=!0,this._lastOffset=0,this._checkElastic=!1,this._lastPoint||(this._lastPoint=new m),this._lastPoint.setTo(e.stage.mouseX,e.stage.mouseY),e.timer.clear(this,this.tweenMove),x.clearTween(this),e.stage.once("mouseup",this,this.onStageMouseUp2),e.stage.once("mouseout",this,this.onStageMouseUp2),e.timer.frameLoop(1,this,this.loop)},s.loop=function(){var t=e.stage.mouseY,i=e.stage.mouseX;if(this._lastOffset=this.isVertical?t-this._lastPoint.y:i-this._lastPoint.x,this._clickOnly){if(!(Math.abs(this._lastOffset*(this.isVertical?e.stage._canvasTransform.getScaleY():e.stage._canvasTransform.getScaleX()))>1))return;this._clickOnly=!1,this._offsets||(this._offsets=[]),this._offsets.length=0,this._target.mouseEnabled=!1,!this.hide&&this.autoHide&&(this.alpha=1,this.visible=!0),this.event("start")}this._offsets.push(this._lastOffset),this._lastPoint.x=i,this._lastPoint.y=t,0!==this._lastOffset&&(this._checkElastic||(this.elasticDistance>0?this._checkElastic||0==this._lastOffset||(this._checkElastic=!0,this._lastOffset>0&&this._value<=this.min||this._lastOffset<0&&this._value>=this.max?this._isElastic=!0:this._isElastic=!1):this._checkElastic=!0),this._checkElastic&&(this._isElastic?this._value<=this.min?this.value-=this._lastOffset*Math.max(0,1-(this.min-this._value)/this.elasticDistance):this._value>=this.max&&(this.value-=this._lastOffset*Math.max(0,1-(this._value-this.max)/this.elasticDistance)):this.value-=this._lastOffset))},s.onStageMouseUp2=function(t){if(e.stage.off("mouseup",this,this.onStageMouseUp2),e.stage.off("mouseout",this,this.onStageMouseUp2),e.timer.clear(this,this.loop),!this._clickOnly)if(this._target.mouseEnabled=!0,this._isElastic)this._valuethis.max&&x.to(this,{value:this.max},this.elasticBackTime,a.sineOut,f.create(this,this.elasticOver));else{this._offsets.length<1&&(this._offsets[0]=this.isVertical?e.stage.mouseY-this._lastPoint.y:e.stage.mouseX-this._lastPoint.x);for(var i=0,s=Math.min(this._offsets.length,3),h=0;s>h;h++)i+=this._offsets[this._offsets.length-1-h];if(this._lastOffset=i/s,i=Math.abs(this._lastOffset),2>i)return void this.event("end");i>60&&(this._lastOffset=this._lastOffset>0?60:-60),e.timer.frameLoop(1,this,this.tweenMove)}},s.elasticOver=function(){this._isElastic=!1,!this.hide&&this.autoHide&&x.to(this,{alpha:0},500),this.event("end")},s.tweenMove=function(){this._lastOffset*=this.rollRatio,this.value-=this._lastOffset,(Math.abs(this._lastOffset)<1||this.value==this.max||this.value==this.min)&&(e.timer.clear(this,this.tweenMove),this.event("end"),!this.hide&&this.autoHide&&x.to(this,{alpha:0},500))},s.stopScroll=function(){this.onStageMouseUp2(null),e.timer.clear(this,this.tweenMove),x.clearTween(this)},n(0,s,"measureHeight",function(){return this.slider.isVertical?100:this.slider.height}),n(0,s,"skin",function(){return this._skin},function(t){this._skin!=t&&(this._skin=t,this.slider.skin=this._skin,this.callLater(this.changeScrollBar))}),n(0,s,"max",function(){return this.slider.max},function(t){this.slider.max=t}),n(0,s,"showButtons",function(){return this._showButtons},function(t){this._showButtons=t,this.callLater(this.changeScrollBar)}),n(0,s,"measureWidth",function(){return this.slider.isVertical?this.slider.width:100}),n(0,s,"min",function(){return this.slider.min},function(t){this.slider.min=t}),n(0,s,"value",function(){return this._value},function(t){t!==this._value&&(this._isElastic?this._value=t:(this.slider.value=t,this._value=this.slider.value),this.event("change"),this.changeHandler&&this.changeHandler.runWith(this.value))}),n(0,s,"isVertical",function(){return this.slider.isVertical},function(t){this.slider.isVertical=t}),n(0,s,"sizeGrid",function(){return this.slider.sizeGrid},function(t){this.slider.sizeGrid=t}),n(0,s,"scrollSize",function(){return this._scrollSize},function(t){this._scrollSize=t}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i||"string"==typeof i?this.value=Number(i):t.prototype._$set_dataSource.call(this,i)}),n(0,s,"thumbPercent",function(){return this._thumbPercent},function(t){this.runCallLater(this.changeScrollBar),this.runCallLater(this.changeSize),t=t>=1?.99:t,this._thumbPercent=t,this.scaleBar&&(this.slider.isVertical?this.slider.bar.height=Math.max(this.slider.height*t,k.scrollBarMinNum):this.slider.bar.width=Math.max(this.slider.width*t,k.scrollBarMinNum))}),n(0,s,"target",function(){return this._target},function(t){this._target&&(this._target.off("mousewheel",this,this.onTargetMouseWheel),this._target.off("mousedown",this,this.onTargetMouseDown)),this._target=t,t&&(this._mouseWheelEnable&&this._target.on("mousewheel",this,this.onTargetMouseWheel),this._touchScrollEnable&&this._target.on("mousedown",this,this.onTargetMouseDown))}),n(0,s,"hide",function(){return this._hide},function(t){this._hide=t,this.visible=!t}),n(0,s,"touchScrollEnable",function(){return this._touchScrollEnable},function(t){this._touchScrollEnable=t,this.target=this._target}),n(0,s,"mouseWheelEnable",function(){return this._mouseWheelEnable},function(t){this._mouseWheelEnable=t}),i}(M),$=function(t){function i(t){this.changeHandler=null,this.isVertical=!0,this.showLabel=!0,this._allowClickBack=!1,this._max=100,this._min=0,this._tick=1,this._value=0,this._skin=null,this._bg=null,this._bar=null,this._tx=NaN,this._ty=NaN,this._maxMove=NaN,this._globalSacle=null,i.__super.call(this),this.skin=t}h(i,"laya.ui.Slider",t);var o=i.prototype;return o.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._bg&&this._bg.destroy(i),this._bar&&this._bar.destroy(i),this._bg=null,this._bar=null,this.changeHandler=null},o.createChildren=function(){this.addChild(this._bg=new A),this.addChild(this._bar=new P)},o.initialize=function(){this._bar.on("mousedown",this,this.onBarMouseDown),this._bg.sizeGrid=this._bar.sizeGrid="4,4,4,4,0",this.allowClickBack=!0},o.onBarMouseDown=function(t){this._globalSacle||(this._globalSacle=new m),this._globalSacle.setTo(this.globalScaleX,this.globalScaleY),this._maxMove=this.isVertical?this.height-this._bar.height:this.width-this._bar.width,this._tx=e.stage.mouseX,this._ty=e.stage.mouseY,e.stage.on("mousemove",this,this.mouseMove),e.stage.once("mouseup",this,this.mouseUp),this.showValueText()},o.showValueText=function(){if(this.showLabel){var t=laya.ui.Slider.label;this.addChild(t),t.textField.changeText(this._value+""),this.isVertical?(t.x=this._bar.x+20,t.y=.5*(this._bar.height-t.height)+this._bar.y):(t.y=this._bar.y-20,t.x=.5*(this._bar.width-t.width)+this._bar.x)}},o.hideValueText=function(){laya.ui.Slider.label&&laya.ui.Slider.label.removeSelf()},o.mouseUp=function(t){e.stage.off("mousemove",this,this.mouseMove),this.sendChangeEvent("changed"),this.hideValueText()},o.mouseMove=function(t){var i=this._value;this.isVertical?(this._bar.y+=(e.stage.mouseY-this._ty)/this._globalSacle.y,this._bar.y>this._maxMove?this._bar.y=this._maxMove:this._bar.y<0&&(this._bar.y=0),this._value=this._bar.y/this._maxMove*(this._max-this._min)+this._min):(this._bar.x+=(e.stage.mouseX-this._tx)/this._globalSacle.x,this._bar.x>this._maxMove?this._bar.x=this._maxMove:this._bar.x<0&&(this._bar.x=0),this._value=this._bar.x/this._maxMove*(this._max-this._min)+this._min),this._tx=e.stage.mouseX,this._ty=e.stage.mouseY;var s=Math.pow(10,(this._tick+"").length-1);this._value=Math.round(Math.round(this._value/this._tick)*this._tick*s)/s,this._value!=i&&this.sendChangeEvent(),this.showValueText()},o.sendChangeEvent=function(t){void 0===t&&(t="change"),this.event(t),this.changeHandler&&this.changeHandler.runWith(this._value)},o.setBarPoint=function(){this.isVertical?this._bar.x=Math.round(.5*(this._bg.width-this._bar.width)):this._bar.y=Math.round(.5*(this._bg.height-this._bar.height))},o.changeSize=function(){t.prototype.changeSize.call(this),this.isVertical?this._bg.height=this.height:this._bg.width=this.width,this.setBarPoint(),this.changeValue()},o.setSlider=function(t,i,e){this._value=-1,this._min=t,this._max=i>t?i:t,this.value=t>e?t:e>i?i:e},o.changeValue=function(){var t=Math.pow(10,(this._tick+"").length-1);this._value=Math.round(Math.round(this._value/this._tick)*this._tick*t)/t,this._value=this._value>this._max?this._max:this._valuei+e}else this._bar.width=this.width*this._value},n(0,e,"measureHeight",function(){return this._bg.height}),n(0,e,"skin",function(){return this._skin},function(t){this._skin!=t&&(this._skin=t,this._bg.skin=this._skin,this._bar.skin=this._skin.replace(".png","$bar.png"),this.callLater(this.changeValue))}),n(0,e,"measureWidth",function(){return this._bg.width}),n(0,e,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._bg.height=this._height,this._bar.height=this._height}),n(0,e,"bar",function(){return this._bar}),n(0,e,"value",function(){return this._value},function(t){this._value!=t&&(t=t>1?1:0>t?0:t,this._value=t,this.callLater(this.changeValue),this.event("change"),this.changeHandler&&this.changeHandler.runWith(t))}),n(0,e,"bg",function(){return this._bg}),n(0,e,"sizeGrid",function(){return this._bg.sizeGrid},function(t){this._bg.sizeGrid=this._bar.sizeGrid=t}),n(0,e,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._bg.width=this._width,this.callLater(this.changeValue)}),n(0,e,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i||"string"==typeof i?this.value=Number(i):t.prototype._$set_dataSource.call(this,i)}),i}(M),R=(function(t){function i(){this._tipBox=null,this._tipText=null,this._defaultTipHandler=null,i.__super.call(this),this._tipBox=new M,this._tipBox.addChild(this._tipText=new b),this._tipText.x=this._tipText.y=5,this._tipText.color=i.tipTextColor,this._defaultTipHandler=this._showDefaultTip,e.stage.on("showtip",this,this._onStageShowTip),e.stage.on("hidetip",this,this._onStageHideTip)}h(i,"laya.ui.TipManager",t);var s=i.prototype;return s._onStageHideTip=function(t){e.timer.clear(this,this._showTip),this.closeAll(),this.removeSelf()},s._onStageShowTip=function(t){e.timer.once(i.tipDelay,this,this._showTip,[t],!0)},s._showTip=function(t){if("string"==typeof t){var i=String(t);Boolean(i)&&this._defaultTipHandler(i)}else t instanceof laya.utils.Handler?t.run():"function"==typeof t&&t.apply();e.stage.on("mousemove",this,this._onStageMouseMove),e.stage.on("mousedown",this,this._onStageMouseDown),this._onStageMouseMove(null)},s._onStageMouseDown=function(t){this.closeAll()},s._onStageMouseMove=function(t){this._showToStage(this,i.offsetX,i.offsetY)},s._showToStage=function(t,i,s){void 0===i&&(i=0),void 0===s&&(s=0);var h=t.getBounds();t.x=e.stage.mouseX+i,t.y=e.stage.mouseY+s,t.x+h.width>e.stage.width&&(t.x-=h.width+i),t.y+h.height>e.stage.height&&(t.y-=h.height+s)},s.closeAll=function(){e.timer.clear(this,this._showTip),e.stage.off("mousemove",this,this._onStageMouseMove),e.stage.off("mousedown",this,this._onStageMouseDown),this.removeChildren()},s.showDislayTip=function(t){this.addChild(t),this._showToStage(this),e.stageBox.addChild(this)},s._showDefaultTip=function(t){this._tipText.text=t;var s=this._tipBox.graphics;s.clear(),s.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,i.tipBackColor),this.addChild(this._tipBox),this._showToStage(this),e.stageBox.addChild(this)},n(0,s,"defaultTipHandler",function(){return this._defaultTipHandler},function(t){this._defaultTipHandler=t}),i.offsetX=10,i.offsetY=15,i.tipTextColor="#ffffff",i.tipBackColor="#111111",i.tipDelay=200,i}(M),function(t){function i(){i.__super.call(this)}return h(i,"laya.ui.FrameClip",t),i}(_)),V=function(t){function i(t,e){void 0===e&&(e=""),i.__super.call(this,t,e)}h(i,"laya.ui.CheckBox",t);var e=i.prototype;return e.preinitialize=function(){laya.ui.Component.prototype.preinitialize.call(this),this.toggle=!0,this._autoSize=!1},e.initialize=function(){t.prototype.initialize.call(this),this.createText(),this._text.align="left",this._text.valign="top",this._text.width=0},n(0,e,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"boolean"==typeof i?this.selected=i:"string"==typeof i?this.selected="true"===i:t.prototype._$set_dataSource.call(this,i)}),i}(P),D=function(t){function i(){this._idMap=null,this._aniList=null,i.__super.call(this)}h(i,"laya.ui.View",t);var n=i.prototype;return n.createView=function(t){if(t.animations&&!this._idMap&&(this._idMap={}),i.createComp(t,this,this),t.animations){var e,s,h=[],n=t.animations,o=0,l=n.length;for(o=0;l>o;o++){switch(e=new R,s=n[o],e._setUp(this._idMap,s),this[s.name]=e,e._setControlNode(this),s.action){case 1:e.play(0,!1);break;case 2:e.play(0,!0)}h.push(e)}this._aniList=h}this._width>0&&null==t.props.hitTestPrior&&!this.mouseThrough&&(this.hitTestPrior=!0)},n.loadUI=function(t){var e=i.uiMap[t];e&&this.createView(e)},n.destroy=function(t){void 0===t&&(t=!0),this._aniList&&(this._aniList.length=0),this._idMap=null,this._aniList=null,laya.ui.Component.prototype.destroy.call(this,t)},i._regs=function(){var t;for(t in i.uiClassMap)l.regClass(t,i.uiClassMap[t])},i.createComp=function(t,s,h){if(s=s||i.getCompInstance(t),!s)return console.log("can not create:"+t.type),null;var n=t.child;if(n)for(var o=0,r=n.length;r>o;o++){var a=n[o];if(!s.hasOwnProperty("itemRender")||"render"!=a.props.name&&"render"!==a.props.renderType)if("Graphic"==a.type)l.addGraphicsToSprite(a,s);else if(l.isDrawType(a.type))l.addGraphicToSprite(a,s,!0);else{var c=i.createComp(a,null,h);"Script"==a.type?c.owner=s:"mask"==a.props.renderType||"mask"==a.props.name?s.mask=c:c instanceof laya.display.Sprite&&s.addChild(c)}else s.itemRender=a}var u=t.props;for(var _ in u){var d=u[_];i.setCompValue(s,_,d,h)}return e.__typeof(s,"laya.ui.IItem")&&s.initItems(),t.compId&&h&&h._idMap&&(h._idMap[t.compId]=s),s},i.setCompValue=function(t,i,e,s){"var"===i&&s?s[e]=t:"x"===i||"y"===i||"width"===i||"height"===i||"number"==typeof t[i]?t[i]=parseFloat(e):t[i]="true"===e?!0:"false"===e?!1:e},i.getCompInstance=function(t){var s,h=t.props?t.props.runtime:"";return s=h?i.viewClassMap[h]||i.uiClassMap[h]||e.__classmap[h]:i.uiClassMap[t.type],s?new s:null},i.regComponent=function(t,e){i.uiClassMap[t]=e,l.regClass(t,e)},i.regViewRuntime=function(t,e){i.viewClassMap[t]=e},i.uiMap={},i.viewClassMap={},s(i,["uiClassMap",function(){return this.uiClassMap={ViewStack:Q,LinkButton:P,TextArea:lt,ColorPicker:H,Box:T,Button:P,CheckBox:V,Clip:N,ComboBox:Y,Component:M,HScrollBar:j,HSlider:q,Image:A,Label:O,List:W,Panel:F,ProgressBar:E,Radio:U,RadioGroup:nt,ScrollBar:X,Slider:$,Tab:ot,TextInput:tt,View:i,VScrollBar:Z,VSlider:it,Tree:J,HBox:st,VBox:ht,Sprite:v,Animation:o,Text:b}}]),i.__init$=function(){i._regs()},i}(T),G=function(t){function i(){this._space=0,this._align="none",this._itemChanged=!1,i.__super.call(this)}h(i,"laya.ui.LayoutBox",t);var e=i.prototype;return e.addChild=function(t){return t.on("resize",this,this.onResize),this._setItemChanged(),laya.display.Node.prototype.addChild.call(this,t)},e.onResize=function(t){this._setItemChanged()},e.addChildAt=function(t,i){return t.on("resize",this,this.onResize),this._setItemChanged(),laya.display.Node.prototype.addChildAt.call(this,t,i)},e.removeChild=function(t){return t.off("resize",this,this.onResize),this._setItemChanged(),laya.display.Node.prototype.removeChild.call(this,t)},e.removeChildAt=function(t){return this.getChildAt(t).off("resize",this,this.onResize),this._setItemChanged(),laya.display.Node.prototype.removeChildAt.call(this,t)},e.refresh=function(){this._setItemChanged()},e.changeItems=function(){this._itemChanged=!1},e.sortItem=function(t){t&&t.sort(function(t,i){return t.y>i.y?1:-1})},e._setItemChanged=function(){this._itemChanged||(this._itemChanged=!0,this.callLater(this.changeItems))},n(0,e,"space",function(){return this._space},function(t){this._space=t,this._setItemChanged()}),n(0,e,"align",function(){return this._align},function(t){this._align=t,this._setItemChanged()}),i}(T),W=function(t){function i(){this.selectHandler=null,this.renderHandler=null,this.mouseHandler=null,this.selectEnable=!1,this.totalPage=0,this._content=null,this._scrollBar=null,this._itemRender=null,this._repeatX=0,this._repeatY=0,this._repeatX2=0,this._repeatY2=0,this._spaceX=0,this._spaceY=0,this._array=null,this._startIndex=0,this._selectedIndex=-1,this._page=0,this._isVertical=!0,this._cellSize=20,this._cellOffset=0,this._isMoved=!1,this.cacheContent=!1,this._createdLine=0,this._cellChanged=!1,i.__super.call(this),this._cells=[]}h(i,"laya.ui.List",t);var s=i.prototype;return e.imps(s,{"laya.ui.IRender":!0,"laya.ui.IItem":!0}),s.destroy=function(t){void 0===t&&(t=!0),laya.ui.Component.prototype.destroy.call(this,t),this._content&&this._content.destroy(t),this._scrollBar&&this._scrollBar.destroy(t),this._content=null,this._scrollBar=null,this._itemRender=null,this._cells=null,this._array=null,this.selectHandler=this.renderHandler=this.mouseHandler=null},s.createChildren=function(){this.addChild(this._content=new T)},s.onScrollStart=function(){this._$P.cacheAs||(this._$P.cacheAs=t.prototype._$get_cacheAs.call(this)),t.prototype._$set_cacheAs.call(this,"none"),this._scrollBar.once("end",this,this.onScrollEnd)},s.onScrollEnd=function(){t.prototype._$set_cacheAs.call(this,this._$P.cacheAs)},s.changeCells=function(){if(this._cellChanged=!1,this._itemRender){for(var t=this._cells.length-1;t>-1;t--)this._cells[t].destroy();this._cells.length=0,this.scrollBar=this.getChildByName("scrollBar");var i=this.createItem(),e=i.width+this._spaceX||1,s=i.height+this._spaceY||1;this._width>0&&(this._repeatX2=this._isVertical?Math.round(this._width/e):Math.ceil(this._width/e)),this._height>0&&(this._repeatY2=this._isVertical?Math.ceil(this._height/s):Math.round(this._height/s));var h=this._width?this._width:e*this.repeatX-this._spaceX,n=this._height?this._height:s*this.repeatY-this._spaceY;this._cellSize=this._isVertical?s:e,this._cellOffset=this._isVertical?s*Math.max(this._repeatY2,this._repeatY)-n-this._spaceY:e*Math.max(this._repeatX2,this._repeatX)-h-this._spaceX,this._isVertical&&this._scrollBar?this._scrollBar.height=n:!this._isVertical&&this._scrollBar&&(this._scrollBar.width=h),this.setContentSize(h,n);var o=this._isVertical?this.repeatX:this.repeatY,l=(this._isVertical?this.repeatY:this.repeatX)+(this._scrollBar?1:0);this._createItems(0,o,l),this._createdLine=l,this._array&&(this.array=this._array,this.runCallLater(this.renderItems))}},s._createItems=function(t,i,e){var s=this._content,h=this.createItem(),n=h.width+this._spaceX,o=h.height+this._spaceY;if(this.cacheContent){var l=new T;l.cacheAsBitmap=!0,l.pos((this._isVertical?0:t)*n,(this._isVertical?t:0)*o),this._content.addChild(l),this._content.optimizeScrollRect=!0,s=l}for(var r=t;e>r;r++)for(var a=0;i>a;a++)h=this.createItem(),h.x=(this._isVertical?a:r)*n-s.x,h.y=(this._isVertical?r:a)*o-s.y,h.name="item"+(r*i+a),s.addChild(h),this.addCell(h)},s.createItem=function(){return"function"==typeof this._itemRender?new this._itemRender:D.createComp(this._itemRender)},s.addCell=function(t){t.on("click",this,this.onCellMouse),t.on("rightclick",this,this.onCellMouse),t.on("mouseover",this,this.onCellMouse),t.on("mouseout",this,this.onCellMouse),t.on("mousedown",this,this.onCellMouse),t.on("mouseup",this,this.onCellMouse),this._cells.push(t)},s.initItems=function(){if(!this._itemRender&&null!=this.getChildByName("item0")){this.repeatX=1;var t=0;t=0;for(var i=0;1e4>i;i++){var e=this.getChildByName("item"+i);{if(!e)break;this.addCell(e),t++}}this.repeatY=t}},s.setContentSize=function(t,i){this._content.width=t,this._content.height=i,this._scrollBar&&(this._content.scrollRect||(this._content.scrollRect=new y),this._content.scrollRect.setTo(0,0,t,i),this._content.model&&this._content.model.scrollRect(0,0,t,i),this.event("resize"))},s.onCellMouse=function(t){"mousedown"===t.type&&(this._isMoved=!1);var i=t.currentTarget,e=this._startIndex+this._cells.indexOf(i);0>e||("click"===t.type||"rightclick"===t.type?this.selectEnable&&!this._isMoved?this.selectedIndex=e:this.changeCellState(i,!0,0):"mouseover"!==t.type&&"mouseout"!==t.type||this._selectedIndex===e||this.changeCellState(i,"mouseover"===t.type,0), +this.mouseHandler&&this.mouseHandler.runWith([t,e]))},s.changeCellState=function(t,i,e){var s=t.getChildByName("selectBox");s&&(this.selectEnable=!0,s.visible=i,s.index=e)},s.changeSize=function(){laya.ui.Component.prototype.changeSize.call(this),this.setContentSize(this.width,this.height),this._scrollBar&&e.timer.once(10,this,this.onScrollBarChange)},s.onScrollBarChange=function(t){this.runCallLater(this.changeCells);var i=this._scrollBar.value,e=this._isVertical?this.repeatX:this.repeatY,s=this._isVertical?this.repeatY:this.repeatX,h=Math.floor(i/this._cellSize);if(this.cacheContent)o=s+1,this._createdLine-hthis._startIndex){var o=n-this._startIndex,l=!0,r=this._startIndex+e*(s+1);this._isMoved=!0}else na;a++){if(l){var c=this._cells.shift();this._cells[this._cells.length]=c;var u=r+a}else c=this._cells.pop(),this._cells.unshift(c),u=r-a;var _=Math.floor(u/e)*this._cellSize;this._isVertical?c.y=_:c.x=_,this.renderItem(c,u)}this._startIndex=n,this.changeSelectStatus()}var d=this._content.scrollRect;this._isVertical?d.y=i:d.x=i,this._content.model&&this._content.model.scrollRect(d.x,d.y,d.width,d.height),this.repaint()},s.posCell=function(t,i){if(this._scrollBar){var e=this._isVertical?this.repeatX:this.repeatY,s=(this._isVertical?this.repeatY:this.repeatX,Math.floor(i/e)*this._cellSize);this._isVertical?t.y=s:t.x=s}},s.changeSelectStatus=function(){for(var t=0,i=this._cells.length;i>t;t++)this.changeCellState(this._cells[t],this._selectedIndex===this._startIndex+t,1)},s.renderItems=function(t,i){void 0===t&&(t=0),void 0===i&&(i=0);for(var e=0,s=i||this._cells.length;s>e;e++)this.renderItem(this._cells[e],this._startIndex+e);this.changeSelectStatus()},s.renderItem=function(t,i){i>=0&&i-1&&t-1&&t=this._startIndex&&t-1&&this._cells?this._cells[(t-this._startIndex)%this._cells.length]:null},s.scrollTo=function(t){if(this._scrollBar){var i=this._isVertical?this.repeatX:this.repeatY;this._scrollBar.value=Math.floor(t/i)*this._cellSize}else this.startIndex=t},s.tweenTo=function(t,i,e){if(void 0===i&&(i=200),this._scrollBar){var s=this._isVertical?this.repeatX:this.repeatY;x.to(this._scrollBar,{value:Math.floor(t/s)*this._cellSize},i,null,e,0,!0)}else this.startIndex=t,e&&e.run()},s._setCellChanged=function(){this._cellChanged||(this._cellChanged=!0,this.callLater(this.changeCells))},n(0,s,"cacheAs",t.prototype._$get_cacheAs,function(i){t.prototype._$set_cacheAs.call(this,i),this._scrollBar&&(this._$P.cacheAs=null,"none"!==i?this._scrollBar.on("start",this,this.onScrollStart):this._scrollBar.off("start",this,this.onScrollStart))}),n(0,s,"content",function(){return this._content}),n(0,s,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._setCellChanged()}),n(0,s,"itemRender",function(){return this._itemRender},function(t){this._itemRender=t,this._setCellChanged()}),n(0,s,"vScrollBarSkin",function(){return this._scrollBar?this._scrollBar.skin:null},function(t){this.removeChildByName("scrollBar");var i=new Z;i.name="scrollBar",i.right=0,i.skin=t,this.scrollBar=i,this.addChild(i),this._setCellChanged()}),n(0,s,"page",function(){return this._page},function(t){this._page=t,this._array&&(this._page=t>0?t:0,this._page=this._page0?this._repeatX:this._repeatX2>0?this._repeatX2:1},function(t){this._repeatX=t,this._setCellChanged()}),n(0,s,"scrollBar",function(){return this._scrollBar},function(t){this._scrollBar!=t&&(this._scrollBar=t,t&&(this.addChild(this._scrollBar),this._scrollBar.on("change",this,this.onScrollBarChange),this._isVertical=this._scrollBar.isVertical))}),n(0,s,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._setCellChanged()}),n(0,s,"repeatY",function(){return this._repeatY>0?this._repeatY:this._repeatY2>0?this._repeatY2:1},function(t){this._repeatY=t,this._setCellChanged()}),n(0,s,"spaceX",function(){return this._spaceX},function(t){this._spaceX=t,this._setCellChanged()}),n(0,s,"spaceY",function(){return this._spaceY},function(t){this._spaceY=t,this._setCellChanged()}),n(0,s,"selectedIndex",function(){return this._selectedIndex},function(t){this._selectedIndex!=t&&(this._selectedIndex=t,this.changeSelectStatus(),this.event("change"),this.selectHandler&&this.selectHandler.runWith(t))}),n(0,s,"selectedItem",function(){return-1!=this._selectedIndex?this._array[this._selectedIndex]:null},function(t){this.selectedIndex=this._array.indexOf(t)}),n(0,s,"length",function(){return this._array.length}),n(0,s,"selection",function(){return this.getCell(this._selectedIndex)},function(t){this.selectedIndex=this._startIndex+this._cells.indexOf(t)}),n(0,s,"startIndex",function(){return this._startIndex},function(t){this._startIndex=t>0?t:0,this.callLater(this.renderItems)}),n(0,s,"array",function(){return this._array},function(t){this.runCallLater(this.changeCells),this._array=t||[];var i=this._array.length;if(this.totalPage=Math.ceil(i/(this.repeatX*this.repeatY)),this._selectedIndex=this._selectedIndex0?this.totalPage+1:this.totalPage;n>1?(this._scrollBar.scrollSize=this._cellSize,this._scrollBar.thumbPercent=s/h,this._scrollBar.setScroll(0,(h-s)*this._cellSize+this._cellOffset,this._isVertical?this._content.scrollRect.y:this._content.scrollRect.x),this._scrollBar.target=this._content):(this._scrollBar.setScroll(0,0,0),this._scrollBar.target=this._content)}}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,"number"==typeof i&&Math.floor(i)==i||"string"==typeof i?this.selectedIndex=parseInt(i):i instanceof Array?this.array=i:t.prototype._$set_dataSource.call(this,i)}),n(0,s,"cells",function(){return this.runCallLater(this.changeCells),this._cells}),i}(T),F=function(t){function i(){this._content=null,this._vScrollBar=null,this._hScrollBar=null,this._scrollChanged=!1,i.__super.call(this),this.width=this.height=100,this._content.optimizeScrollRect=!0}h(i,"laya.ui.Panel",t);var e=i.prototype;return e.destroy=function(t){void 0===t&&(t=!0),laya.ui.Component.prototype.destroy.call(this,t),this._content&&this._content.destroy(t),this._vScrollBar&&this._vScrollBar.destroy(t),this._hScrollBar&&this._hScrollBar.destroy(t),this._vScrollBar=null,this._hScrollBar=null,this._content=null},e.destroyChildren=function(){this._content.destroyChildren()},e.createChildren=function(){laya.display.Node.prototype.addChild.call(this,this._content=new T)},e.addChild=function(t){return t.on("resize",this,this.onResize),this._setScrollChanged(),this._content.addChild(t)},e.onResize=function(){this._setScrollChanged()},e.addChildAt=function(t,i){return t.on("resize",this,this.onResize),this._setScrollChanged(),this._content.addChildAt(t,i)},e.removeChild=function(t){return t.off("resize",this,this.onResize),this._setScrollChanged(),this._content.removeChild(t)},e.removeChildAt=function(t){return this.getChildAt(t).off("resize",this,this.onResize),this._setScrollChanged(),this._content.removeChildAt(t)},e.removeChildren=function(t,i){void 0===t&&(t=0),void 0===i&&(i=2147483647);for(var e=this._content.numChildren-1;e>-1;e--)this._content.removeChildAt(e);return this._setScrollChanged(),this},e.getChildAt=function(t){return this._content.getChildAt(t)},e.getChildByName=function(t){return this._content.getChildByName(t)},e.getChildIndex=function(t){return this._content.getChildIndex(t)},e.changeScroll=function(){this._scrollChanged=!1;var t=this.contentWidth,i=this.contentHeight,e=this._vScrollBar,s=this._hScrollBar,h=e&&i>this._height,n=s&&t>this._width,o=h?this._width-e.width:this._width,l=n?this._height-s.height:this._height;e&&(e.x=this._width-e.width,e.y=0,e.height=this._height-(n?s.height:0),e.scrollSize=Math.max(.033*this._height,1),e.thumbPercent=l/i,e.setScroll(0,i-l,e.value)),s&&(s.x=0,s.y=this._height-s.height,s.width=this._width-(h?e.width:0),s.scrollSize=Math.max(.033*this._width,1),s.thumbPercent=o/t,s.setScroll(0,t-o,s.value))},e.changeSize=function(){laya.ui.Component.prototype.changeSize.call(this),this.setContentSize(this._width,this._height)},e.setContentSize=function(t,i){var e=this._content;e.width=t,e.height=i,e.scrollRect||(e.scrollRect=new y),e.scrollRect.setTo(0,0,t,i),e.model&&e.model.scrollRect(0,0,t,i)},e.onScrollBarChange=function(t){var i=this._content.scrollRect;if(i){var e=Math.round(t.value);t.isVertical?i.y=e:i.x=e,this._content.model&&this._content.model.scrollRect(i.x,i.y,i.width,i.height)}},e.scrollTo=function(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.vScrollBar&&(this.vScrollBar.value=i),this.hScrollBar&&(this.hScrollBar.value=t)},e.refresh=function(){this.changeScroll()},e.onScrollStart=function(){this._$P.cacheAs||(this._$P.cacheAs=t.prototype._$get_cacheAs.call(this)),t.prototype._$set_cacheAs.call(this,"none"),this._hScrollBar&&this._hScrollBar.once("end",this,this.onScrollEnd),this._vScrollBar&&this._vScrollBar.once("end",this,this.onScrollEnd)},e.onScrollEnd=function(){t.prototype._$set_cacheAs.call(this,this._$P.cacheAs)},e._setScrollChanged=function(){this._scrollChanged||(this._scrollChanged=!0,this.callLater(this.changeScroll))},n(0,e,"numChildren",function(){return this._content.numChildren}),n(0,e,"hScrollBarSkin",function(){return this._hScrollBar?this._hScrollBar.skin:null},function(t){null==this._hScrollBar&&(laya.display.Node.prototype.addChild.call(this,this._hScrollBar=new j),this._hScrollBar.on("change",this,this.onScrollBarChange,[this._hScrollBar]),this._hScrollBar.target=this._content,this._setScrollChanged()),this._hScrollBar.skin=t}),n(0,e,"contentWidth",function(){for(var t=0,i=this._content.numChildren-1;i>-1;i--){var e=this._content.getChildAt(i);t=Math.max(e.x+e.width*e.scaleX,t)}return t}),n(0,e,"contentHeight",function(){for(var t=0,i=this._content.numChildren-1;i>-1;i--){var e=this._content.getChildAt(i);t=Math.max(e.y+e.height*e.scaleY,t)}return t}),n(0,e,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._setScrollChanged()}),n(0,e,"hScrollBar",function(){return this._hScrollBar}),n(0,e,"content",function(){return this._content}),n(0,e,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._setScrollChanged()}),n(0,e,"vScrollBarSkin",function(){return this._vScrollBar?this._vScrollBar.skin:null},function(t){null==this._vScrollBar&&(laya.display.Node.prototype.addChild.call(this,this._vScrollBar=new Z),this._vScrollBar.on("change",this,this.onScrollBarChange,[this._vScrollBar]),this._vScrollBar.target=this._content,this._setScrollChanged()),this._vScrollBar.skin=t}),n(0,e,"vScrollBar",function(){return this._vScrollBar}),n(0,e,"cacheAs",t.prototype._$get_cacheAs,function(i){t.prototype._$set_cacheAs.call(this,i),this._$P.cacheAs=null,"none"!==i?(this._hScrollBar&&this._hScrollBar.on("start",this,this.onScrollStart),this._vScrollBar&&this._vScrollBar.on("start",this,this.onScrollStart)):(this._hScrollBar&&this._hScrollBar.off("start",this,this.onScrollStart),this._vScrollBar&&this._vScrollBar.off("start",this,this.onScrollStart))}),i}(T),j=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.HScrollBar",t);var e=i.prototype;return e.initialize=function(){t.prototype.initialize.call(this),this.slider.isVertical=!1},i}(X),U=function(t){function i(t,e){this._value=null,void 0===e&&(e=""),i.__super.call(this,t,e)}h(i,"laya.ui.Radio",t);var e=i.prototype;return e.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._value=null},e.preinitialize=function(){laya.ui.Component.prototype.preinitialize.call(this),this.toggle=!1,this._autoSize=!1},e.initialize=function(){t.prototype.initialize.call(this),this.createText(),this._text.align="left",this._text.valign="top",this._text.width=0,this.on("click",this,this.onClick)},e.onClick=function(t){this.selected=!0},n(0,e,"value",function(){return null!=this._value?this._value:this.label},function(t){this._value=t}),i}(P),K=function(t){function i(t,e){this.selectHandler=null,this._items=null,this._selectedIndex=-1,this._skin=null,this._direction="horizontal",this._space=0,this._labels=null,this._labelColors=null,this._labelStrokeColor=null,this._strokeColors=null,this._labelStroke=NaN,this._labelSize=0,this._labelBold=!1,this._labelPadding=null,this._labelAlign=null,this._stateNum=0,this._labelChanged=!1,i.__super.call(this),this.skin=e,this.labels=t}h(i,"laya.ui.UIGroup",t);var s=i.prototype;return e.imps(s,{"laya.ui.IItem":!0}),s.preinitialize=function(){this.mouseEnabled=!0},s.destroy=function(t){void 0===t&&(t=!0),laya.ui.Component.prototype.destroy.call(this,t),this._items&&(this._items.length=0),this._items=null,this.selectHandler=null},s.addItem=function(t,i){void 0===i&&(i=!0);var e=t,s=this._items.length;if(e.name="item"+s,this.addChild(e),this.initItems(),i&&s>0){var h=this._items[s-1];"horizontal"==this._direction?e.x=h.x+h.width+this._space:e.y=h.y+h.height+this._space}else i&&(e.x=0,e.y=0);return s},s.delItem=function(t,i){void 0===i&&(i=!0);var e=this._items.indexOf(t);if(-1!=e){var s=t;this.removeChild(s);for(var h=e+1,n=this._items.length;n>h;h++){var o=this._items[h];o.name="item"+(h-1),i&&("horizontal"==this._direction?o.x-=s.width+this._space:o.y-=s.height+this._space)}if(this.initItems(),this._selectedIndex>-1){var l=0;l=this._selectedIndext;t++){var i=this.getChildByName("item"+t);if(null==i)break;this._items.push(i),i.selected=t===this._selectedIndex,i.clickHandler=f.create(this,this.itemClick,[t],!1)}},s.itemClick=function(t){this.selectedIndex=t},s.setSelect=function(t,i){this._items&&t>-1&&ti;i++){var s=this._items[i];this._skin&&(s.skin=this._skin),this._labelColors&&(s.labelColors=this._labelColors),this._labelSize&&(s.labelSize=this._labelSize),this._labelStroke&&(s.labelStroke=this._labelStroke),this._labelStrokeColor&&(s.labelStrokeColor=this._labelStrokeColor),this._strokeColors&&(s.strokeColors=this._strokeColors),this._labelBold&&(s.labelBold=this._labelBold),this._labelPadding&&(s.labelPadding=this._labelPadding),this._labelAlign&&(s.labelAlign=this._labelAlign),this._stateNum&&(s.stateNum=this._stateNum),"horizontal"===this._direction?(s.y=0,s.x=t,t+=s.width+this._space):(s.x=0,s.y=t,t+=s.height+this._space)}this.changeSize()},s.commitMeasure=function(){this.runCallLater(this.changeLabels)},s._setLabelChanged=function(){this._labelChanged||(this._labelChanged=!0,this.callLater(this.changeLabels))},n(0,s,"labelStrokeColor",function(){return this._labelStrokeColor},function(t){this._labelStrokeColor!=t&&(this._labelStrokeColor=t,this._setLabelChanged())}),n(0,s,"skin",function(){return this._skin},function(t){this._skin!=t&&(this._skin=t,this._setLabelChanged())}),n(0,s,"selectedIndex",function(){return this._selectedIndex},function(t){this._selectedIndex!=t&&(this.setSelect(this._selectedIndex,!1),this._selectedIndex=t,this.setSelect(t,!0),this.event("change"),this.selectHandler&&this.selectHandler.runWith(this._selectedIndex))}),n(0,s,"labels",function(){return this._labels},function(t){if(this._labels!=t){if(this._labels=t,this.removeChildren(),this._setLabelChanged(),this._labels)for(var i=this._labels.split(","),e=0,s=i.length;s>e;e++){var h=this.createItem(this._skin,i[e]);h.name="item"+e,this.addChild(h)}this.initItems()}}),n(0,s,"strokeColors",function(){return this._strokeColors},function(t){this._strokeColors!=t&&(this._strokeColors=t,this._setLabelChanged())}),n(0,s,"labelColors",function(){return this._labelColors},function(t){this._labelColors!=t&&(this._labelColors=t,this._setLabelChanged())}),n(0,s,"labelStroke",function(){return this._labelStroke},function(t){this._labelStroke!=t&&(this._labelStroke=t,this._setLabelChanged())}),n(0,s,"labelSize",function(){return this._labelSize},function(t){this._labelSize!=t&&(this._labelSize=t,this._setLabelChanged())}),n(0,s,"stateNum",function(){return this._stateNum},function(t){this._stateNum!=t&&(this._stateNum=t,this._setLabelChanged())}),n(0,s,"labelBold",function(){return this._labelBold},function(t){this._labelBold!=t&&(this._labelBold=t,this._setLabelChanged())}),n(0,s,"labelPadding",function(){return this._labelPadding},function(t){this._labelPadding!=t&&(this._labelPadding=t,this._setLabelChanged())}),n(0,s,"direction",function(){return this._direction},function(t){this._direction=t,this._setLabelChanged()}),n(0,s,"space",function(){return this._space},function(t){this._space=t,this._setLabelChanged()}),n(0,s,"items",function(){return this._items}),n(0,s,"selection",function(){return this._selectedIndex>-1&&this._selectedIndex0&&(h.isDirectory=!0),h.hasChild=o>0,i.push(h)}for(var _=0;o>_;_++){var d=n[_];this.parseXml(d,i,h,!1)}},s.parseOpenStatus=function(t,i){for(var e=0,s=i.length;s>e;e++){var h=i[e];if(h.isDirectory)for(var n=0,o=t.length;o>n;n++){var l=t[n];if(l.isDirectory&&this.isSameParent(l,h)&&h.label==l.label){h.isOpen=l.isOpen;break}}}},s.isSameParent=function(t,i){return null==t.nodeParent&&null==i.nodeParent?!0:null==t.nodeParent||null==i.nodeParent?!1:t.nodeParent.label==i.nodeParent.label?this.isSameParent(t.nodeParent,i.nodeParent):!1},s.filter=function(t){if(Boolean(t)){var i=[];this.getFilterSource(this._source,i,t),this._list.array=i}else this._list.array=this.getArray()},s.getFilterSource=function(t,i,e){e=e.toLocaleLowerCase();var s;for(var h in t)s=t[h],!s.isDirectory&&String(s.label).toLowerCase().indexOf(e)>-1&&(s.x=0,i.push(s)),s.child&&s.child.length>0&&this.getFilterSource(s.child,i,e)},n(0,s,"spaceBottom",function(){return this._list.spaceY},function(t){this._list.spaceY=t}),n(0,s,"keepStatus",function(){return this._keepStatus},function(t){this._keepStatus=t}),n(0,s,"itemRender",function(){return this._list.itemRender},function(t){this._list.itemRender=t}),n(0,s,"array",function(){return this._list.array},function(t){this._keepStatus&&this._list.array&&t&&this.parseOpenStatus(this._list.array,t),this._source=t,this._list.array=this.getArray()}),n(0,s,"mouseHandler",function(){return this._list.mouseHandler},function(t){this._list.mouseHandler=t}),n(0,s,"dataSource",t.prototype._$get_dataSource,function(i){this._dataSource=i,t.prototype._$set_dataSource.call(this,i)}),n(0,s,"source",function(){return this._source}),n(0,s,"scrollBar",function(){return this._list.scrollBar}),n(0,s,"list",function(){return this._list}),n(0,s,"scrollBarSkin",function(){return this._list.vScrollBarSkin},function(t){this._list.vScrollBarSkin=t}),n(0,s,"renderHandler",function(){return this._renderHandler},function(t){this._renderHandler=t}),n(0,s,"selectedIndex",function(){return this._list.selectedIndex},function(t){this._list.selectedIndex=t}),n(0,s,"spaceLeft",function(){return this._spaceLeft},function(t){this._spaceLeft=t}),n(0,s,"selectedItem",function(){return this._list.selectedItem},function(t){this._list.selectedItem=t}),n(0,s,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this._list.width=i}),n(0,s,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this._list.height=i}),n(0,s,"xml",null,function(t){var i=[];this.parseXml(t.childNodes[0],i,null,!0),this.array=i}),n(0,s,"selectedPath",function(){return this._list.selectedItem?this._list.selectedItem.path:null}),i}(T),Q=function(t){function i(){this._items=null,this._selectedIndex=0,i.__super.call(this),this._setIndexHandler=f.create(this,this.setIndex,null,!1)}h(i,"laya.ui.ViewStack",t);var s=i.prototype;return e.imps(s,{"laya.ui.IItem":!0}),s.setItems=function(t){this.removeChildren();for(var i=0,e=0,s=t.length;s>e;e++){var h=t[e];h&&(h.name="item"+i,this.addChild(h),i++)}this.initItems()},s.addItem=function(t){t.name="item"+this._items.length,this.addChild(t),this.initItems()},s.initItems=function(){this._items=[];for(var t=0;1e4>t;t++){var i=this.getChildByName("item"+t);if(null==i)break;this._items.push(i),i.visible=t==this._selectedIndex}},s.setSelect=function(t,i){this._items&&t>-1&&t-1&&this._selectedIndex-1;s--){var h=this.dialogLayer.getChildAt(s);h.popupCenter&&this._centerDialog(h)}for(s=this.modalLayer.numChildren-1;s>-1;s--)h=this.modalLayer.getChildAt(s),h.isPopup&&h.popupCenter&&this._centerDialog(h)},s._centerDialog=function(t){t.x=Math.round((this._stage.width-t.width>>1)+t.pivotX),t.y=Math.round((this._stage.height-t.height>>1)+t.pivotY)},s.show=function(t,i){void 0===i&&(i=!1),i&&this.dialogLayer.removeChildren(),t.popupCenter&&this._centerDialog(t),this.dialogLayer.addChild(t),this.event("open")},s.popup=function(t,i){void 0===i&&(i=!1),i&&this.modalLayer.removeChildren(),t.popupCenter&&this._centerDialog(t),this.modalLayer.addChild(this.maskLayer),this.modalLayer.addChild(t),this.event("open")},s.close=function(t){t.removeSelf(),this.modalLayer.numChildren<2?this.maskLayer.removeSelf():this.modalLayer.setChildIndex(this.maskLayer,this.modalLayer.numChildren-2),this.event("close")},s.closeAll=function(){this.dialogLayer.removeChildren(),this.modalLayer.removeChildren(),this.maskLayer.removeSelf(),this.event("close")},i}(v)},i}(D),st=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.HBox",t);var e=i.prototype;return e.sortItem=function(t){t&&t.sort(function(t,i){return t.x>i.x?1:-1})},e.changeItems=function(){this._itemChanged=!1;for(var t=[],i=0,e=0,s=this.numChildren;s>e;e++){var h=this.getChildAt(e);h&&(t.push(h),i=Math.max(i,h.height*h.scaleY))}this.sortItem(t);var n=0;for(e=0,s=this.numChildren;s>e;e++)h=t[e],h.x=n,n+=h.width*h.scaleX+this._space,"top"==this._align?h.y=0:"middle"==this._align?h.y=.5*(i-h.height*h.scaleY):"bottom"==this._align&&(h.y=i-h.height*h.scaleY);this.changeSize()},i.NONE="none", +i.TOP="top",i.MIDDLE="middle",i.BOTTOM="bottom",i}(G),ht=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.VBox",t);var e=i.prototype;return e.changeItems=function(){this._itemChanged=!1;for(var t=[],i=0,e=0,s=this.numChildren;s>e;e++){var h=this.getChildAt(e);h&&(t.push(h),i=Math.max(i,h.width*h.scaleX))}this.sortItem(t);var n=0;for(e=0,s=this.numChildren;s>e;e++)h=t[e],h.y=n,n+=h.height*h.scaleY+this._space,"left"==this._align?h.x=0:"center"==this._align?h.x=.5*(i-h.width*h.scaleX):"right"==this._align&&(h.x=i-h.width*h.scaleX);this.changeSize()},i.NONE="none",i.LEFT="left",i.CENTER="center",i.RIGHT="right",i}(G),nt=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.RadioGroup",t);var e=i.prototype;return e.createItem=function(t,i){return new U(t,i)},i}(K),ot=function(t){function i(){i.__super.call(this)}h(i,"laya.ui.Tab",t);var e=i.prototype;return e.createItem=function(t,i){return new P(t,i)},i}(K),lt=function(t){function i(t){this._vScrollBar=null,this._hScrollBar=null,void 0===t&&(t=""),i.__super.call(this,t)}h(i,"laya.ui.TextArea",t);var e=i.prototype;return e.destroy=function(i){void 0===i&&(i=!0),t.prototype.destroy.call(this,i),this._vScrollBar&&this._vScrollBar.destroy(),this._hScrollBar&&this._hScrollBar.destroy(),this._vScrollBar=null,this._hScrollBar=null},e.initialize=function(){this.width=180,this.height=150,this._tf.wordWrap=!0,this.multiline=!0},e.onVBarChanged=function(t){this._tf.scrollY!=this._vScrollBar.value&&(this._tf.scrollY=this._vScrollBar.value)},e.onHBarChanged=function(t){this._tf.scrollX!=this._hScrollBar.value&&(this._tf.scrollX=this._hScrollBar.value)},e.changeScroll=function(){var t=this._vScrollBar&&this._tf.maxScrollY>0,i=this._hScrollBar&&this._tf.maxScrollX>0,e=t?this._width-this._vScrollBar.width:this._width,s=i?this._height-this._hScrollBar.height:this._height,h=this._tf.padding||k.labelPadding;this._tf.width=e,this._tf.height=s,this._vScrollBar&&(this._vScrollBar.x=this._width-this._vScrollBar.width-h[2],this._vScrollBar.y=h[1],this._vScrollBar.height=this._height-(i?this._hScrollBar.height:0)-h[1]-h[3],this._vScrollBar.scrollSize=1,this._vScrollBar.thumbPercent=s/Math.max(this._tf.textHeight,s),this._vScrollBar.setScroll(1,this._tf.maxScrollY,this._tf.scrollY),this._vScrollBar.visible=t),this._hScrollBar&&(this._hScrollBar.x=h[0],this._hScrollBar.y=this._height-this._hScrollBar.height-h[3],this._hScrollBar.width=this._width-(t?this._vScrollBar.width:0)-h[0]-h[2],this._hScrollBar.scrollSize=Math.max(.033*e,1),this._hScrollBar.thumbPercent=e/Math.max(this._tf.textWidth,e),this._hScrollBar.setScroll(0,this.maxScrollX,this.scrollX),this._hScrollBar.visible=i)},e.scrollTo=function(t){this.commitMeasure(),this._tf.scrollY=t},n(0,e,"scrollY",function(){return this._tf.scrollY}),n(0,e,"width",t.prototype._$get_width,function(i){t.prototype._$set_width.call(this,i),this.callLater(this.changeScroll)}),n(0,e,"hScrollBar",function(){return this._hScrollBar}),n(0,e,"height",t.prototype._$get_height,function(i){t.prototype._$set_height.call(this,i),this.callLater(this.changeScroll)}),n(0,e,"maxScrollX",function(){return this._tf.maxScrollX}),n(0,e,"vScrollBarSkin",function(){return this._vScrollBar?this._vScrollBar.skin:null},function(t){null==this._vScrollBar&&(this.addChild(this._vScrollBar=new Z),this._vScrollBar.on("change",this,this.onVBarChanged),this._vScrollBar.target=this._tf,this.callLater(this.changeScroll)),this._vScrollBar.skin=t}),n(0,e,"hScrollBarSkin",function(){return this._hScrollBar?this._hScrollBar.skin:null},function(t){null==this._hScrollBar&&(this.addChild(this._hScrollBar=new j),this._hScrollBar.on("change",this,this.onHBarChanged),this._hScrollBar.mouseWheelEnable=!1,this._hScrollBar.target=this._tf,this.callLater(this.changeScroll)),this._hScrollBar.skin=t}),n(0,e,"vScrollBar",function(){return this._vScrollBar}),n(0,e,"maxScrollY",function(){return this._tf.maxScrollY}),n(0,e,"scrollX",function(){return this._tf.scrollX}),i}(tt);e.__init([et,D])}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/min/laya.webgl.min.js b/games/laya-snakes/libs/min/laya.webgl.min.js new file mode 100644 index 0000000..9d0b45c --- /dev/null +++ b/games/laya-snakes/libs/min/laya.webgl.min.js @@ -0,0 +1 @@ +!function(n,t,c){c.un,c.uns,c["static"],c["class"],c.getset,c.__newvec}(window,document,Laya); \ No newline at end of file diff --git a/games/laya-snakes/libs/protobuf.js b/games/laya-snakes/libs/protobuf.js new file mode 100644 index 0000000..779a225 --- /dev/null +++ b/games/laya-snakes/libs/protobuf.js @@ -0,0 +1,5239 @@ +/* + Copyright 2013 Daniel Wirtz + + 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. + */ + +/** + * @license protobuf.js (c) 2013 Daniel Wirtz + * Released under the Apache License, Version 2.0 + * see: https://github.com/dcodeIO/protobuf.js for details + */ +(function(global, factory) { + + /* AMD */ if (typeof define === 'function' && define["amd"]) + define(["bytebuffer"], factory); + /* CommonJS */ else if (typeof require === "function" && typeof module === "object" && module && module["exports"]) + module["exports"] = factory(require("bytebuffer"), true); + /* Global */ else + (global["dcodeIO"] = global["dcodeIO"] || {})["ProtoBuf"] = factory(global["dcodeIO"]["ByteBuffer"]); + +})(this, function(ByteBuffer, isCommonJS) { + "use strict"; + + /** + * The ProtoBuf namespace. + * @exports ProtoBuf + * @namespace + * @expose + */ + var ProtoBuf = {}; + + /** + * @type {!function(new: ByteBuffer, ...[*])} + * @expose + */ + ProtoBuf.ByteBuffer = ByteBuffer; + + /** + * @type {?function(new: Long, ...[*])} + * @expose + */ + ProtoBuf.Long = ByteBuffer.Long || null; + + /** + * ProtoBuf.js version. + * @type {string} + * @const + * @expose + */ + ProtoBuf.VERSION = "5.0.1"; + + /** + * Wire types. + * @type {Object.} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES = {}; + + /** + * Varint wire type. + * @type {number} + * @expose + */ + ProtoBuf.WIRE_TYPES.VARINT = 0; + + /** + * Fixed 64 bits wire type. + * @type {number} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES.BITS64 = 1; + + /** + * Length delimited wire type. + * @type {number} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES.LDELIM = 2; + + /** + * Start group wire type. + * @type {number} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES.STARTGROUP = 3; + + /** + * End group wire type. + * @type {number} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES.ENDGROUP = 4; + + /** + * Fixed 32 bits wire type. + * @type {number} + * @const + * @expose + */ + ProtoBuf.WIRE_TYPES.BITS32 = 5; + + /** + * Packable wire types. + * @type {!Array.} + * @const + * @expose + */ + ProtoBuf.PACKABLE_WIRE_TYPES = [ + ProtoBuf.WIRE_TYPES.VARINT, + ProtoBuf.WIRE_TYPES.BITS64, + ProtoBuf.WIRE_TYPES.BITS32 + ]; + + /** + * Types. + * @dict + * @type {!Object.} + * @const + * @expose + */ + ProtoBuf.TYPES = { + // According to the protobuf spec. + "int32": { + name: "int32", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: 0 + }, + "uint32": { + name: "uint32", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: 0 + }, + "sint32": { + name: "sint32", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: 0 + }, + "int64": { + name: "int64", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: ProtoBuf.Long ? ProtoBuf.Long.ZERO : undefined + }, + "uint64": { + name: "uint64", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: ProtoBuf.Long ? ProtoBuf.Long.UZERO : undefined + }, + "sint64": { + name: "sint64", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: ProtoBuf.Long ? ProtoBuf.Long.ZERO : undefined + }, + "bool": { + name: "bool", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: false + }, + "double": { + name: "double", + wireType: ProtoBuf.WIRE_TYPES.BITS64, + defaultValue: 0 + }, + "string": { + name: "string", + wireType: ProtoBuf.WIRE_TYPES.LDELIM, + defaultValue: "" + }, + "bytes": { + name: "bytes", + wireType: ProtoBuf.WIRE_TYPES.LDELIM, + defaultValue: null // overridden in the code, must be a unique instance + }, + "fixed32": { + name: "fixed32", + wireType: ProtoBuf.WIRE_TYPES.BITS32, + defaultValue: 0 + }, + "sfixed32": { + name: "sfixed32", + wireType: ProtoBuf.WIRE_TYPES.BITS32, + defaultValue: 0 + }, + "fixed64": { + name: "fixed64", + wireType: ProtoBuf.WIRE_TYPES.BITS64, + defaultValue: ProtoBuf.Long ? ProtoBuf.Long.UZERO : undefined + }, + "sfixed64": { + name: "sfixed64", + wireType: ProtoBuf.WIRE_TYPES.BITS64, + defaultValue: ProtoBuf.Long ? ProtoBuf.Long.ZERO : undefined + }, + "float": { + name: "float", + wireType: ProtoBuf.WIRE_TYPES.BITS32, + defaultValue: 0 + }, + "enum": { + name: "enum", + wireType: ProtoBuf.WIRE_TYPES.VARINT, + defaultValue: 0 + }, + "message": { + name: "message", + wireType: ProtoBuf.WIRE_TYPES.LDELIM, + defaultValue: null + }, + "group": { + name: "group", + wireType: ProtoBuf.WIRE_TYPES.STARTGROUP, + defaultValue: null + } + }; + + /** + * Valid map key types. + * @type {!Array.>} + * @const + * @expose + */ + ProtoBuf.MAP_KEY_TYPES = [ + ProtoBuf.TYPES["int32"], + ProtoBuf.TYPES["sint32"], + ProtoBuf.TYPES["sfixed32"], + ProtoBuf.TYPES["uint32"], + ProtoBuf.TYPES["fixed32"], + ProtoBuf.TYPES["int64"], + ProtoBuf.TYPES["sint64"], + ProtoBuf.TYPES["sfixed64"], + ProtoBuf.TYPES["uint64"], + ProtoBuf.TYPES["fixed64"], + ProtoBuf.TYPES["bool"], + ProtoBuf.TYPES["string"], + ProtoBuf.TYPES["bytes"] + ]; + + /** + * Minimum field id. + * @type {number} + * @const + * @expose + */ + ProtoBuf.ID_MIN = 1; + + /** + * Maximum field id. + * @type {number} + * @const + * @expose + */ + ProtoBuf.ID_MAX = 0x1FFFFFFF; + + /** + * If set to `true`, field names will be converted from underscore notation to camel case. Defaults to `false`. + * Must be set prior to parsing. + * @type {boolean} + * @expose + */ + ProtoBuf.convertFieldsToCamelCase = false; + + /** + * By default, messages are populated with (setX, set_x) accessors for each field. This can be disabled by + * setting this to `false` prior to building messages. + * @type {boolean} + * @expose + */ + ProtoBuf.populateAccessors = true; + + /** + * By default, messages are populated with default values if a field is not present on the wire. To disable + * this behavior, set this setting to `false`. + * @type {boolean} + * @expose + */ + ProtoBuf.populateDefaults = true; + + /** + * @alias ProtoBuf.Util + * @expose + */ + ProtoBuf.Util = (function() { + "use strict"; + + /** + * ProtoBuf utilities. + * @exports ProtoBuf.Util + * @namespace + */ + var Util = {}; + + /** + * Flag if running in node or not. + * @type {boolean} + * @const + * @expose + */ + Util.IS_NODE = !!( + typeof process === 'object' && process+'' === '[object process]' && !process['browser'] + ); + + /** + * Constructs a XMLHttpRequest object. + * @return {XMLHttpRequest} + * @throws {Error} If XMLHttpRequest is not supported + * @expose + */ + Util.XHR = function() { + // No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html + var XMLHttpFactories = [ + function () {return new XMLHttpRequest()}, + function () {return new ActiveXObject("Msxml2.XMLHTTP")}, + function () {return new ActiveXObject("Msxml3.XMLHTTP")}, + function () {return new ActiveXObject("Microsoft.XMLHTTP")} + ]; + /** @type {?XMLHttpRequest} */ + var xhr = null; + for (var i=0;i} + * @expose + */ + ProtoBuf.Lang = { + + // Characters always ending a statement + DELIM: /[\s\{\}=;:\[\],'"\(\)<>]/g, + + // Field rules + RULE: /^(?:required|optional|repeated|map)$/, + + // Field types + TYPE: /^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/, + + // Names + NAME: /^[a-zA-Z_][a-zA-Z_0-9]*$/, + + // Type definitions + TYPEDEF: /^[a-zA-Z][a-zA-Z_0-9]*$/, + + // Type references + TYPEREF: /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/, + + // Fully qualified type references + FQTYPEREF: /^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/, + + // All numbers + NUMBER: /^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/, + + // Decimal numbers + NUMBER_DEC: /^(?:[1-9][0-9]*|0)$/, + + // Hexadecimal numbers + NUMBER_HEX: /^0[xX][0-9a-fA-F]+$/, + + // Octal numbers + NUMBER_OCT: /^0[0-7]+$/, + + // Floating point numbers + NUMBER_FLT: /^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/, + + // Booleans + BOOL: /^(?:true|false)$/i, + + // Id numbers + ID: /^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/, + + // Negative id numbers (enum values) + NEGID: /^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/, + + // Whitespaces + WHITESPACE: /\s/, + + // All strings + STRING: /(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g, + + // Double quoted strings + STRING_DQ: /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g, + + // Single quoted strings + STRING_SQ: /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g + }; + + /** + * @alias ProtoBuf.DotProto + * @expose + */ + ProtoBuf.DotProto = (function(ProtoBuf, Lang) { + "use strict"; + + /** + * Utilities to parse .proto files. + * @exports ProtoBuf.DotProto + * @namespace + */ + var DotProto = {}; + + /** + * Constructs a new Tokenizer. + * @exports ProtoBuf.DotProto.Tokenizer + * @class prototype tokenizer + * @param {string} proto Proto to tokenize + * @constructor + */ + var Tokenizer = function(proto) { + + /** + * Source to parse. + * @type {string} + * @expose + */ + this.source = proto+""; + + /** + * Current index. + * @type {number} + * @expose + */ + this.index = 0; + + /** + * Current line. + * @type {number} + * @expose + */ + this.line = 1; + + /** + * Token stack. + * @type {!Array.} + * @expose + */ + this.stack = []; + + /** + * Opening character of the current string read, if any. + * @type {?string} + * @private + */ + this._stringOpen = null; + }; + + /** + * @alias ProtoBuf.DotProto.Tokenizer.prototype + * @inner + */ + var TokenizerPrototype = Tokenizer.prototype; + + /** + * Reads a string beginning at the current index. + * @return {string} + * @private + */ + TokenizerPrototype._readString = function() { + var re = this._stringOpen === '"' + ? Lang.STRING_DQ + : Lang.STRING_SQ; + re.lastIndex = this.index - 1; // Include the open quote + var match = re.exec(this.source); + if (!match) + throw Error("unterminated string"); + this.index = re.lastIndex; + this.stack.push(this._stringOpen); + this._stringOpen = null; + return match[1]; + }; + + /** + * Gets the next token and advances by one. + * @return {?string} Token or `null` on EOF + * @expose + */ + TokenizerPrototype.next = function() { + if (this.stack.length > 0) + return this.stack.shift(); + if (this.index >= this.source.length) + return null; + if (this._stringOpen !== null) + return this._readString(); + + var repeat, + prev, + next; + do { + repeat = false; + + // Strip white spaces + while (Lang.WHITESPACE.test(next = this.source.charAt(this.index))) { + if (next === '\n') + ++this.line; + if (++this.index === this.source.length) + return null; + } + + // Strip comments + if (this.source.charAt(this.index) === '/') { + ++this.index; + if (this.source.charAt(this.index) === '/') { // Line + while (this.source.charAt(++this.index) !== '\n') + if (this.index == this.source.length) + return null; + ++this.index; + ++this.line; + repeat = true; + } else if ((next = this.source.charAt(this.index)) === '*') { /* Block */ + do { + if (next === '\n') + ++this.line; + if (++this.index === this.source.length) + return null; + prev = next; + next = this.source.charAt(this.index); + } while (prev !== '*' || next !== '/'); + ++this.index; + repeat = true; + } else + return '/'; + } + } while (repeat); + + if (this.index === this.source.length) + return null; + + // Read the next token + var end = this.index; + Lang.DELIM.lastIndex = 0; + var delim = Lang.DELIM.test(this.source.charAt(end++)); + if (!delim) + while(end < this.source.length && !Lang.DELIM.test(this.source.charAt(end))) + ++end; + var token = this.source.substring(this.index, this.index = end); + if (token === '"' || token === "'") + this._stringOpen = token; + return token; + }; + + /** + * Peeks for the next token. + * @return {?string} Token or `null` on EOF + * @expose + */ + TokenizerPrototype.peek = function() { + if (this.stack.length === 0) { + var token = this.next(); + if (token === null) + return null; + this.stack.push(token); + } + return this.stack[0]; + }; + + /** + * Skips a specific token and throws if it differs. + * @param {string} expected Expected token + * @throws {Error} If the actual token differs + */ + TokenizerPrototype.skip = function(expected) { + var actual = this.next(); + if (actual !== expected) + throw Error("illegal '"+actual+"', '"+expected+"' expected"); + }; + + /** + * Omits an optional token. + * @param {string} expected Expected optional token + * @returns {boolean} `true` if the token exists + */ + TokenizerPrototype.omit = function(expected) { + if (this.peek() === expected) { + this.next(); + return true; + } + return false; + }; + + /** + * Returns a string representation of this object. + * @return {string} String representation as of "Tokenizer(index/length)" + * @expose + */ + TokenizerPrototype.toString = function() { + return "Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"; + }; + + /** + * @alias ProtoBuf.DotProto.Tokenizer + * @expose + */ + DotProto.Tokenizer = Tokenizer; + + /** + * Constructs a new Parser. + * @exports ProtoBuf.DotProto.Parser + * @class prototype parser + * @param {string} source Source + * @constructor + */ + var Parser = function(source) { + + /** + * Tokenizer. + * @type {!ProtoBuf.DotProto.Tokenizer} + * @expose + */ + this.tn = new Tokenizer(source); + + /** + * Whether parsing proto3 or not. + * @type {boolean} + */ + this.proto3 = false; + }; + + /** + * @alias ProtoBuf.DotProto.Parser.prototype + * @inner + */ + var ParserPrototype = Parser.prototype; + + /** + * Parses the source. + * @returns {!Object} + * @throws {Error} If the source cannot be parsed + * @expose + */ + ParserPrototype.parse = function() { + var topLevel = { + "name": "[ROOT]", // temporary + "package": null, + "messages": [], + "enums": [], + "imports": [], + "options": {}, + "services": [] + // "syntax": undefined + }; + var token, + head = true, + weak; + try { + while (token = this.tn.next()) { + switch (token) { + case 'package': + if (!head || topLevel["package"] !== null) + throw Error("unexpected 'package'"); + token = this.tn.next(); + if (!Lang.TYPEREF.test(token)) + throw Error("illegal package name: " + token); + this.tn.skip(";"); + topLevel["package"] = token; + break; + case 'import': + if (!head) + throw Error("unexpected 'import'"); + token = this.tn.peek(); + if (token === "public" || (weak = token === "weak")) // token ignored + this.tn.next(); + token = this._readString(); + this.tn.skip(";"); + if (!weak) // import ignored + topLevel["imports"].push(token); + break; + case 'syntax': + if (!head) + throw Error("unexpected 'syntax'"); + this.tn.skip("="); + if ((topLevel["syntax"] = this._readString()) === "proto3") + this.proto3 = true; + this.tn.skip(";"); + break; + case 'message': + this._parseMessage(topLevel, null); + head = false; + break; + case 'enum': + this._parseEnum(topLevel); + head = false; + break; + case 'option': + this._parseOption(topLevel); + break; + case 'service': + this._parseService(topLevel); + break; + case 'extend': + this._parseExtend(topLevel); + break; + default: + throw Error("unexpected '" + token + "'"); + } + } + } catch (e) { + e.message = "Parse error at line "+this.tn.line+": " + e.message; + throw e; + } + delete topLevel["name"]; + return topLevel; + }; + + /** + * Parses the specified source. + * @returns {!Object} + * @throws {Error} If the source cannot be parsed + * @expose + */ + Parser.parse = function(source) { + return new Parser(source).parse(); + }; + + // ----- Conversion ------ + + /** + * Converts a numerical string to an id. + * @param {string} value + * @param {boolean=} mayBeNegative + * @returns {number} + * @inner + */ + function mkId(value, mayBeNegative) { + var id = -1, + sign = 1; + if (value.charAt(0) == '-') { + sign = -1; + value = value.substring(1); + } + if (Lang.NUMBER_DEC.test(value)) + id = parseInt(value); + else if (Lang.NUMBER_HEX.test(value)) + id = parseInt(value.substring(2), 16); + else if (Lang.NUMBER_OCT.test(value)) + id = parseInt(value.substring(1), 8); + else + throw Error("illegal id value: " + (sign < 0 ? '-' : '') + value); + id = (sign*id)|0; // Force to 32bit + if (!mayBeNegative && id < 0) + throw Error("illegal id value: " + (sign < 0 ? '-' : '') + value); + return id; + } + + /** + * Converts a numerical string to a number. + * @param {string} val + * @returns {number} + * @inner + */ + function mkNumber(val) { + var sign = 1; + if (val.charAt(0) == '-') { + sign = -1; + val = val.substring(1); + } + if (Lang.NUMBER_DEC.test(val)) + return sign * parseInt(val, 10); + else if (Lang.NUMBER_HEX.test(val)) + return sign * parseInt(val.substring(2), 16); + else if (Lang.NUMBER_OCT.test(val)) + return sign * parseInt(val.substring(1), 8); + else if (val === 'inf') + return sign * Infinity; + else if (val === 'nan') + return NaN; + else if (Lang.NUMBER_FLT.test(val)) + return sign * parseFloat(val); + throw Error("illegal number value: " + (sign < 0 ? '-' : '') + val); + } + + // ----- Reading ------ + + /** + * Reads a string. + * @returns {string} + * @private + */ + ParserPrototype._readString = function() { + var value = "", + token, + delim; + do { + delim = this.tn.next(); + if (delim !== "'" && delim !== '"') + throw Error("illegal string delimiter: "+delim); + value += this.tn.next(); + this.tn.skip(delim); + token = this.tn.peek(); + } while (token === '"' || token === '"'); // multi line? + return value; + }; + + /** + * Reads a value. + * @param {boolean=} mayBeTypeRef + * @returns {number|boolean|string} + * @private + */ + ParserPrototype._readValue = function(mayBeTypeRef) { + var token = this.tn.peek(), + value; + if (token === '"' || token === "'") + return this._readString(); + this.tn.next(); + if (Lang.NUMBER.test(token)) + return mkNumber(token); + if (Lang.BOOL.test(token)) + return (token.toLowerCase() === 'true'); + if (mayBeTypeRef && Lang.TYPEREF.test(token)) + return token; + throw Error("illegal value: "+token); + + }; + + // ----- Parsing constructs ----- + + /** + * Parses a namespace option. + * @param {!Object} parent Parent definition + * @param {boolean=} isList + * @private + */ + ParserPrototype._parseOption = function(parent, isList) { + var token = this.tn.next(), + custom = false; + if (token === '(') { + custom = true; + token = this.tn.next(); + } + if (!Lang.TYPEREF.test(token)) + // we can allow options of the form google.protobuf.* since they will just get ignored anyways + // if (!/google\.protobuf\./.test(token)) // FIXME: Why should that not be a valid typeref? + throw Error("illegal option name: "+token); + var name = token; + if (custom) { // (my_method_option).foo, (my_method_option), some_method_option, (foo.my_option).bar + this.tn.skip(')'); + name = '('+name+')'; + token = this.tn.peek(); + if (Lang.FQTYPEREF.test(token)) { + name += token; + this.tn.next(); + } + } + this.tn.skip('='); + this._parseOptionValue(parent, name); + if (!isList) + this.tn.skip(";"); + }; + + /** + * Sets an option on the specified options object. + * @param {!Object.} options + * @param {string} name + * @param {string|number|boolean} value + * @inner + */ + function setOption(options, name, value) { + if (typeof options[name] === 'undefined') + options[name] = value; + else { + if (!Array.isArray(options[name])) + options[name] = [ options[name] ]; + options[name].push(value); + } + } + + /** + * Parses an option value. + * @param {!Object} parent + * @param {string} name + * @private + */ + ParserPrototype._parseOptionValue = function(parent, name) { + var token = this.tn.peek(); + if (token !== '{') { // Plain value + setOption(parent["options"], name, this._readValue(true)); + } else { // Aggregate options + this.tn.skip("{"); + while ((token = this.tn.next()) !== '}') { + if (!Lang.NAME.test(token)) + throw Error("illegal option name: " + name + "." + token); + if (this.tn.omit(":")) + setOption(parent["options"], name + "." + token, this._readValue(true)); + else + this._parseOptionValue(parent, name + "." + token); + } + } + }; + + /** + * Parses a service definition. + * @param {!Object} parent Parent definition + * @private + */ + ParserPrototype._parseService = function(parent) { + var token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal service name at line "+this.tn.line+": "+token); + var name = token; + var svc = { + "name": name, + "rpc": {}, + "options": {} + }; + this.tn.skip("{"); + while ((token = this.tn.next()) !== '}') { + if (token === "option") + this._parseOption(svc); + else if (token === 'rpc') + this._parseServiceRPC(svc); + else + throw Error("illegal service token: "+token); + } + this.tn.omit(";"); + parent["services"].push(svc); + }; + + /** + * Parses a RPC service definition of the form ['rpc', name, (request), 'returns', (response)]. + * @param {!Object} svc Service definition + * @private + */ + ParserPrototype._parseServiceRPC = function(svc) { + var type = "rpc", + token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal rpc service method name: "+token); + var name = token; + var method = { + "request": null, + "response": null, + "request_stream": false, + "response_stream": false, + "options": {} + }; + this.tn.skip("("); + token = this.tn.next(); + if (token.toLowerCase() === "stream") { + method["request_stream"] = true; + token = this.tn.next(); + } + if (!Lang.TYPEREF.test(token)) + throw Error("illegal rpc service request type: "+token); + method["request"] = token; + this.tn.skip(")"); + token = this.tn.next(); + if (token.toLowerCase() !== "returns") + throw Error("illegal rpc service request type delimiter: "+token); + this.tn.skip("("); + token = this.tn.next(); + if (token.toLowerCase() === "stream") { + method["response_stream"] = true; + token = this.tn.next(); + } + method["response"] = token; + this.tn.skip(")"); + token = this.tn.peek(); + if (token === '{') { + this.tn.next(); + while ((token = this.tn.next()) !== '}') { + if (token === 'option') + this._parseOption(method); + else + throw Error("illegal rpc service token: " + token); + } + this.tn.omit(";"); + } else + this.tn.skip(";"); + if (typeof svc[type] === 'undefined') + svc[type] = {}; + svc[type][name] = method; + }; + + /** + * Parses a message definition. + * @param {!Object} parent Parent definition + * @param {!Object=} fld Field definition if this is a group + * @returns {!Object} + * @private + */ + ParserPrototype._parseMessage = function(parent, fld) { + var isGroup = !!fld, + token = this.tn.next(); + var msg = { + "name": "", + "fields": [], + "enums": [], + "messages": [], + "options": {}, + "services": [], + "oneofs": {} + // "extensions": undefined + }; + if (!Lang.NAME.test(token)) + throw Error("illegal "+(isGroup ? "group" : "message")+" name: "+token); + msg["name"] = token; + if (isGroup) { + this.tn.skip("="); + fld["id"] = mkId(this.tn.next()); + msg["isGroup"] = true; + } + token = this.tn.peek(); + if (token === '[' && fld) + this._parseFieldOptions(fld); + this.tn.skip("{"); + while ((token = this.tn.next()) !== '}') { + if (Lang.RULE.test(token)) + this._parseMessageField(msg, token); + else if (token === "oneof") + this._parseMessageOneOf(msg); + else if (token === "enum") + this._parseEnum(msg); + else if (token === "message") + this._parseMessage(msg); + else if (token === "option") + this._parseOption(msg); + else if (token === "service") + this._parseService(msg); + else if (token === "extensions") + if (msg.hasOwnProperty("extensions")) { + msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges()) + } else { + msg["extensions"] = this._parseExtensionRanges(); + } + else if (token === "reserved") + this._parseIgnored(); // TODO + else if (token === "extend") + this._parseExtend(msg); + else if (Lang.TYPEREF.test(token)) { + if (!this.proto3) + throw Error("illegal field rule: "+token); + this._parseMessageField(msg, "optional", token); + } else + throw Error("illegal message token: "+token); + } + this.tn.omit(";"); + parent["messages"].push(msg); + return msg; + }; + + /** + * Parses an ignored statement. + * @private + */ + ParserPrototype._parseIgnored = function() { + while (this.tn.peek() !== ';') + this.tn.next(); + this.tn.skip(";"); + }; + + /** + * Parses a message field. + * @param {!Object} msg Message definition + * @param {string} rule Field rule + * @param {string=} type Field type if already known (never known for maps) + * @returns {!Object} Field descriptor + * @private + */ + ParserPrototype._parseMessageField = function(msg, rule, type) { + if (!Lang.RULE.test(rule)) + throw Error("illegal message field rule: "+rule); + var fld = { + "rule": rule, + "type": "", + "name": "", + "options": {}, + "id": 0 + }; + var token; + if (rule === "map") { + + if (type) + throw Error("illegal type: " + type); + this.tn.skip('<'); + token = this.tn.next(); + if (!Lang.TYPE.test(token) && !Lang.TYPEREF.test(token)) + throw Error("illegal message field type: " + token); + fld["keytype"] = token; + this.tn.skip(','); + token = this.tn.next(); + if (!Lang.TYPE.test(token) && !Lang.TYPEREF.test(token)) + throw Error("illegal message field: " + token); + fld["type"] = token; + this.tn.skip('>'); + token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal message field name: " + token); + fld["name"] = token; + this.tn.skip("="); + fld["id"] = mkId(this.tn.next()); + token = this.tn.peek(); + if (token === '[') + this._parseFieldOptions(fld); + this.tn.skip(";"); + + } else { + + type = typeof type !== 'undefined' ? type : this.tn.next(); + + if (type === "group") { + + // "A [legacy] group simply combines a nested message type and a field into a single declaration. In your + // code, you can treat this message just as if it had a Result type field called result (the latter name is + // converted to lower-case so that it does not conflict with the former)." + var grp = this._parseMessage(msg, fld); + if (!/^[A-Z]/.test(grp["name"])) + throw Error('illegal group name: '+grp["name"]); + fld["type"] = grp["name"]; + fld["name"] = grp["name"].toLowerCase(); + this.tn.omit(";"); + + } else { + + if (!Lang.TYPE.test(type) && !Lang.TYPEREF.test(type)) + throw Error("illegal message field type: " + type); + fld["type"] = type; + token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal message field name: " + token); + fld["name"] = token; + this.tn.skip("="); + fld["id"] = mkId(this.tn.next()); + token = this.tn.peek(); + if (token === "[") + this._parseFieldOptions(fld); + this.tn.skip(";"); + + } + } + msg["fields"].push(fld); + return fld; + }; + + /** + * Parses a message oneof. + * @param {!Object} msg Message definition + * @private + */ + ParserPrototype._parseMessageOneOf = function(msg) { + var token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal oneof name: "+token); + var name = token, + fld; + var fields = []; + this.tn.skip("{"); + while ((token = this.tn.next()) !== "}") { + fld = this._parseMessageField(msg, "optional", token); + fld["oneof"] = name; + fields.push(fld["id"]); + } + this.tn.omit(";"); + msg["oneofs"][name] = fields; + }; + + /** + * Parses a set of field option definitions. + * @param {!Object} fld Field definition + * @private + */ + ParserPrototype._parseFieldOptions = function(fld) { + this.tn.skip("["); + var token, + first = true; + while ((token = this.tn.peek()) !== ']') { + if (!first) + this.tn.skip(","); + this._parseOption(fld, true); + first = false; + } + this.tn.next(); + }; + + /** + * Parses an enum. + * @param {!Object} msg Message definition + * @private + */ + ParserPrototype._parseEnum = function(msg) { + var enm = { + "name": "", + "values": [], + "options": {} + }; + var token = this.tn.next(); + if (!Lang.NAME.test(token)) + throw Error("illegal name: "+token); + enm["name"] = token; + this.tn.skip("{"); + while ((token = this.tn.next()) !== '}') { + if (token === "option") + this._parseOption(enm); + else { + if (!Lang.NAME.test(token)) + throw Error("illegal name: "+token); + this.tn.skip("="); + var val = { + "name": token, + "id": mkId(this.tn.next(), true) + }; + token = this.tn.peek(); + if (token === "[") + this._parseFieldOptions({ "options": {} }); + this.tn.skip(";"); + enm["values"].push(val); + } + } + this.tn.omit(";"); + msg["enums"].push(enm); + }; + + /** + * Parses extension / reserved ranges. + * @returns {!Array.>} + * @private + */ + ParserPrototype._parseExtensionRanges = function() { + var ranges = []; + var token, + range, + value; + do { + range = []; + while (true) { + token = this.tn.next(); + switch (token) { + case "min": + value = ProtoBuf.ID_MIN; + break; + case "max": + value = ProtoBuf.ID_MAX; + break; + default: + value = mkNumber(token); + break; + } + range.push(value); + if (range.length === 2) + break; + if (this.tn.peek() !== "to") { + range.push(value); + break; + } + this.tn.next(); + } + ranges.push(range); + } while (this.tn.omit(",")); + this.tn.skip(";"); + return ranges; + }; + + /** + * Parses an extend block. + * @param {!Object} parent Parent object + * @private + */ + ParserPrototype._parseExtend = function(parent) { + var token = this.tn.next(); + if (!Lang.TYPEREF.test(token)) + throw Error("illegal extend reference: "+token); + var ext = { + "ref": token, + "fields": [] + }; + this.tn.skip("{"); + while ((token = this.tn.next()) !== '}') { + if (Lang.RULE.test(token)) + this._parseMessageField(ext, token); + else if (Lang.TYPEREF.test(token)) { + if (!this.proto3) + throw Error("illegal field rule: "+token); + this._parseMessageField(ext, "optional", token); + } else + throw Error("illegal extend token: "+token); + } + this.tn.omit(";"); + parent["messages"].push(ext); + return ext; + }; + + // ----- General ----- + + /** + * Returns a string representation of this parser. + * @returns {string} + */ + ParserPrototype.toString = function() { + return "Parser at line "+this.tn.line; + }; + + /** + * @alias ProtoBuf.DotProto.Parser + * @expose + */ + DotProto.Parser = Parser; + + return DotProto; + + })(ProtoBuf, ProtoBuf.Lang); + + /** + * @alias ProtoBuf.Reflect + * @expose + */ + ProtoBuf.Reflect = (function(ProtoBuf) { + "use strict"; + + /** + * Reflection types. + * @exports ProtoBuf.Reflect + * @namespace + */ + var Reflect = {}; + + /** + * Constructs a Reflect base class. + * @exports ProtoBuf.Reflect.T + * @constructor + * @abstract + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {?ProtoBuf.Reflect.T} parent Parent object + * @param {string} name Object name + */ + var T = function(builder, parent, name) { + + /** + * Builder reference. + * @type {!ProtoBuf.Builder} + * @expose + */ + this.builder = builder; + + /** + * Parent object. + * @type {?ProtoBuf.Reflect.T} + * @expose + */ + this.parent = parent; + + /** + * Object name in namespace. + * @type {string} + * @expose + */ + this.name = name; + + /** + * Fully qualified class name + * @type {string} + * @expose + */ + this.className; + }; + + /** + * @alias ProtoBuf.Reflect.T.prototype + * @inner + */ + var TPrototype = T.prototype; + + /** + * Returns the fully qualified name of this object. + * @returns {string} Fully qualified name as of ".PATH.TO.THIS" + * @expose + */ + TPrototype.fqn = function() { + var name = this.name, + ptr = this; + do { + ptr = ptr.parent; + if (ptr == null) + break; + name = ptr.name+"."+name; + } while (true); + return name; + }; + + /** + * Returns a string representation of this Reflect object (its fully qualified name). + * @param {boolean=} includeClass Set to true to include the class name. Defaults to false. + * @return String representation + * @expose + */ + TPrototype.toString = function(includeClass) { + return (includeClass ? this.className + " " : "") + this.fqn(); + }; + + /** + * Builds this type. + * @throws {Error} If this type cannot be built directly + * @expose + */ + TPrototype.build = function() { + throw Error(this.toString(true)+" cannot be built directly"); + }; + + /** + * @alias ProtoBuf.Reflect.T + * @expose + */ + Reflect.T = T; + + /** + * Constructs a new Namespace. + * @exports ProtoBuf.Reflect.Namespace + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {?ProtoBuf.Reflect.Namespace} parent Namespace parent + * @param {string} name Namespace name + * @param {Object.=} options Namespace options + * @param {string?} syntax The syntax level of this definition (e.g., proto3) + * @constructor + * @extends ProtoBuf.Reflect.T + */ + var Namespace = function(builder, parent, name, options, syntax) { + T.call(this, builder, parent, name); + + /** + * @override + */ + this.className = "Namespace"; + + /** + * Children inside the namespace. + * @type {!Array.} + */ + this.children = []; + + /** + * Options. + * @type {!Object.} + */ + this.options = options || {}; + + /** + * Syntax level (e.g., proto2 or proto3). + * @type {!string} + */ + this.syntax = syntax || "proto2"; + }; + + /** + * @alias ProtoBuf.Reflect.Namespace.prototype + * @inner + */ + var NamespacePrototype = Namespace.prototype = Object.create(T.prototype); + + /** + * Returns an array of the namespace's children. + * @param {ProtoBuf.Reflect.T=} type Filter type (returns instances of this type only). Defaults to null (all children). + * @return {Array.} + * @expose + */ + NamespacePrototype.getChildren = function(type) { + type = type || null; + if (type == null) + return this.children.slice(); + var children = []; + for (var i=0, k=this.children.length; i} qn Qualified name to resolve + * @param {boolean=} excludeNonNamespace Excludes non-namespace types, defaults to `false` + * @return {?ProtoBuf.Reflect.Namespace} The resolved type or null if not found + * @expose + */ + NamespacePrototype.resolve = function(qn, excludeNonNamespace) { + var part = typeof qn === 'string' ? qn.split(".") : qn, + ptr = this, + i = 0; + if (part[i] === "") { // Fully qualified name, e.g. ".My.Message' + while (ptr.parent !== null) + ptr = ptr.parent; + i++; + } + var child; + do { + do { + if (!(ptr instanceof Reflect.Namespace)) { + ptr = null; + break; + } + child = ptr.getChild(part[i]); + if (!child || !(child instanceof Reflect.T) || (excludeNonNamespace && !(child instanceof Reflect.Namespace))) { + ptr = null; + break; + } + ptr = child; i++; + } while (i < part.length); + if (ptr != null) + break; // Found + // Else search the parent + if (this.parent !== null) + return this.parent.resolve(qn, excludeNonNamespace); + } while (ptr != null); + return ptr; + }; + + /** + * Determines the shortest qualified name of the specified type, if any, relative to this namespace. + * @param {!ProtoBuf.Reflect.T} t Reflection type + * @returns {string} The shortest qualified name or, if there is none, the fqn + * @expose + */ + NamespacePrototype.qn = function(t) { + var part = [], ptr = t; + do { + part.unshift(ptr.name); + ptr = ptr.parent; + } while (ptr !== null); + for (var len=1; len <= part.length; len++) { + var qn = part.slice(part.length-len); + if (t === this.resolve(qn, t instanceof Reflect.Namespace)) + return qn.join("."); + } + return t.fqn(); + }; + + /** + * Builds the namespace and returns the runtime counterpart. + * @return {Object.} Runtime namespace + * @expose + */ + NamespacePrototype.build = function() { + /** @dict */ + var ns = {}; + var children = this.children; + for (var i=0, k=children.length, child; i} + */ + NamespacePrototype.buildOpt = function() { + var opt = {}, + keys = Object.keys(this.options); + for (var i=0, k=keys.length; i}null} Option value or NULL if there is no such option + */ + NamespacePrototype.getOption = function(name) { + if (typeof name === 'undefined') + return this.options; + return typeof this.options[name] !== 'undefined' ? this.options[name] : null; + }; + + /** + * @alias ProtoBuf.Reflect.Namespace + * @expose + */ + Reflect.Namespace = Namespace; + + /** + * Constructs a new Element implementation that checks and converts values for a + * particular field type, as appropriate. + * + * An Element represents a single value: either the value of a singular field, + * or a value contained in one entry of a repeated field or map field. This + * class does not implement these higher-level concepts; it only encapsulates + * the low-level typechecking and conversion. + * + * @exports ProtoBuf.Reflect.Element + * @param {{name: string, wireType: number}} type Resolved data type + * @param {ProtoBuf.Reflect.T|null} resolvedType Resolved type, if relevant + * (e.g. submessage field). + * @param {boolean} isMapKey Is this element a Map key? The value will be + * converted to string form if so. + * @param {string} syntax Syntax level of defining message type, e.g., + * proto2 or proto3. + * @param {string} name Name of the field containing this element (for error + * messages) + * @constructor + */ + var Element = function(type, resolvedType, isMapKey, syntax, name) { + + /** + * Element type, as a string (e.g., int32). + * @type {{name: string, wireType: number}} + */ + this.type = type; + + /** + * Element type reference to submessage or enum definition, if needed. + * @type {ProtoBuf.Reflect.T|null} + */ + this.resolvedType = resolvedType; + + /** + * Element is a map key. + * @type {boolean} + */ + this.isMapKey = isMapKey; + + /** + * Syntax level of defining message type, e.g., proto2 or proto3. + * @type {string} + */ + this.syntax = syntax; + + /** + * Name of the field containing this element (for error messages) + * @type {string} + */ + this.name = name; + + if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0) + throw Error("Invalid map key type: " + type.name); + }; + + var ElementPrototype = Element.prototype; + + /** + * Obtains a (new) default value for the specified type. + * @param type {string|{name: string, wireType: number}} Field type + * @returns {*} Default value + * @inner + */ + function mkDefault(type) { + if (typeof type === 'string') + type = ProtoBuf.TYPES[type]; + if (typeof type.defaultValue === 'undefined') + throw Error("default value for type "+type.name+" is not supported"); + if (type == ProtoBuf.TYPES["bytes"]) + return new ByteBuffer(0); + return type.defaultValue; + } + + /** + * Returns the default value for this field in proto3. + * @function + * @param type {string|{name: string, wireType: number}} the field type + * @returns {*} Default value + */ + Element.defaultFieldValue = mkDefault; + + /** + * Makes a Long from a value. + * @param {{low: number, high: number, unsigned: boolean}|string|number} value Value + * @param {boolean=} unsigned Whether unsigned or not, defaults to reuse it from Long-like objects or to signed for + * strings and numbers + * @returns {!Long} + * @throws {Error} If the value cannot be converted to a Long + * @inner + */ + function mkLong(value, unsigned) { + if (value && typeof value.low === 'number' && typeof value.high === 'number' && typeof value.unsigned === 'boolean' + && value.low === value.low && value.high === value.high) + return new ProtoBuf.Long(value.low, value.high, typeof unsigned === 'undefined' ? value.unsigned : unsigned); + if (typeof value === 'string') + return ProtoBuf.Long.fromString(value, unsigned || false, 10); + if (typeof value === 'number') + return ProtoBuf.Long.fromNumber(value, unsigned || false); + throw Error("not convertible to Long"); + } + + ElementPrototype.toString = function() { + return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element'; + } + + /** + * Checks if the given value can be set for an element of this type (singular + * field or one element of a repeated field or map). + * @param {*} value Value to check + * @return {*} Verified, maybe adjusted, value + * @throws {Error} If the value cannot be verified for this element slot + * @expose + */ + ElementPrototype.verifyValue = function(value) { + var self = this; + function fail(val, msg) { + throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")"); + } + switch (this.type) { + // Signed 32bit + case ProtoBuf.TYPES["int32"]: + case ProtoBuf.TYPES["sint32"]: + case ProtoBuf.TYPES["sfixed32"]: + // Account for !NaN: value === value + if (typeof value !== 'number' || (value === value && value % 1 !== 0)) + fail(typeof value, "not an integer"); + return value > 4294967295 ? value | 0 : value; + + // Unsigned 32bit + case ProtoBuf.TYPES["uint32"]: + case ProtoBuf.TYPES["fixed32"]: + if (typeof value !== 'number' || (value === value && value % 1 !== 0)) + fail(typeof value, "not an integer"); + return value < 0 ? value >>> 0 : value; + + // Signed 64bit + case ProtoBuf.TYPES["int64"]: + case ProtoBuf.TYPES["sint64"]: + case ProtoBuf.TYPES["sfixed64"]: { + if (ProtoBuf.Long) + try { + return mkLong(value, false); + } catch (e) { + fail(typeof value, e.message); + } + else + fail(typeof value, "requires Long.js"); + } + + // Unsigned 64bit + case ProtoBuf.TYPES["uint64"]: + case ProtoBuf.TYPES["fixed64"]: { + if (ProtoBuf.Long) + try { + return mkLong(value, true); + } catch (e) { + fail(typeof value, e.message); + } + else + fail(typeof value, "requires Long.js"); + } + + // Bool + case ProtoBuf.TYPES["bool"]: + if (typeof value !== 'boolean') + fail(typeof value, "not a boolean"); + return value; + + // Float + case ProtoBuf.TYPES["float"]: + case ProtoBuf.TYPES["double"]: + if (typeof value !== 'number') + fail(typeof value, "not a number"); + return value; + + // Length-delimited string + case ProtoBuf.TYPES["string"]: + if (typeof value !== 'string' && !(value && value instanceof String)) + fail(typeof value, "not a string"); + return ""+value; // Convert String object to string + + // Length-delimited bytes + case ProtoBuf.TYPES["bytes"]: + if (ByteBuffer.isByteBuffer(value)) + return value; + return ByteBuffer.wrap(value, "base64"); + + // Constant enum value + case ProtoBuf.TYPES["enum"]: { + var values = this.resolvedType.getChildren(ProtoBuf.Reflect.Enum.Value); + for (i=0; i 4294967295 || value < 0) + fail(typeof value, "not in range for uint32") + return value; + } else { + // proto2 requires enum values to be valid. + fail(value, "not a valid enum value"); + } + } + // Embedded message + case ProtoBuf.TYPES["group"]: + case ProtoBuf.TYPES["message"]: { + if (!value || typeof value !== 'object') + fail(typeof value, "object expected"); + if (value instanceof this.resolvedType.clazz) + return value; + if (value instanceof ProtoBuf.Builder.Message) { + // Mismatched type: Convert to object (see: https://github.com/dcodeIO/ProtoBuf.js/issues/180) + var obj = {}; + for (var i in value) + if (value.hasOwnProperty(i)) + obj[i] = value[i]; + value = obj; + } + // Else let's try to construct one from a key-value object + return new (this.resolvedType.clazz)(value); // May throw for a hundred of reasons + } + } + + // We should never end here + throw Error("[INTERNAL] Illegal value for "+this.toString(true)+": "+value+" (undefined type "+this.type+")"); + }; + + /** + * Calculates the byte length of an element on the wire. + * @param {number} id Field number + * @param {*} value Field value + * @returns {number} Byte length + * @throws {Error} If the value cannot be calculated + * @expose + */ + ElementPrototype.calculateLength = function(id, value) { + if (value === null) return 0; // Nothing to encode + // Tag has already been written + var n; + switch (this.type) { + case ProtoBuf.TYPES["int32"]: + return value < 0 ? ByteBuffer.calculateVarint64(value) : ByteBuffer.calculateVarint32(value); + case ProtoBuf.TYPES["uint32"]: + return ByteBuffer.calculateVarint32(value); + case ProtoBuf.TYPES["sint32"]: + return ByteBuffer.calculateVarint32(ByteBuffer.zigZagEncode32(value)); + case ProtoBuf.TYPES["fixed32"]: + case ProtoBuf.TYPES["sfixed32"]: + case ProtoBuf.TYPES["float"]: + return 4; + case ProtoBuf.TYPES["int64"]: + case ProtoBuf.TYPES["uint64"]: + return ByteBuffer.calculateVarint64(value); + case ProtoBuf.TYPES["sint64"]: + return ByteBuffer.calculateVarint64(ByteBuffer.zigZagEncode64(value)); + case ProtoBuf.TYPES["fixed64"]: + case ProtoBuf.TYPES["sfixed64"]: + return 8; + case ProtoBuf.TYPES["bool"]: + return 1; + case ProtoBuf.TYPES["enum"]: + return ByteBuffer.calculateVarint32(value); + case ProtoBuf.TYPES["double"]: + return 8; + case ProtoBuf.TYPES["string"]: + n = ByteBuffer.calculateUTF8Bytes(value); + return ByteBuffer.calculateVarint32(n) + n; + case ProtoBuf.TYPES["bytes"]: + if (value.remaining() < 0) + throw Error("Illegal value for "+this.toString(true)+": "+value.remaining()+" bytes remaining"); + return ByteBuffer.calculateVarint32(value.remaining()) + value.remaining(); + case ProtoBuf.TYPES["message"]: + n = this.resolvedType.calculate(value); + return ByteBuffer.calculateVarint32(n) + n; + case ProtoBuf.TYPES["group"]: + n = this.resolvedType.calculate(value); + return n + ByteBuffer.calculateVarint32((id << 3) | ProtoBuf.WIRE_TYPES.ENDGROUP); + } + // We should never end here + throw Error("[INTERNAL] Illegal value to encode in "+this.toString(true)+": "+value+" (unknown type)"); + }; + + /** + * Encodes a value to the specified buffer. Does not encode the key. + * @param {number} id Field number + * @param {*} value Field value + * @param {ByteBuffer} buffer ByteBuffer to encode to + * @return {ByteBuffer} The ByteBuffer for chaining + * @throws {Error} If the value cannot be encoded + * @expose + */ + ElementPrototype.encodeValue = function(id, value, buffer) { + if (value === null) return buffer; // Nothing to encode + // Tag has already been written + + switch (this.type) { + // 32bit signed varint + case ProtoBuf.TYPES["int32"]: + // "If you use int32 or int64 as the type for a negative number, the resulting varint is always ten bytes + // long – it is, effectively, treated like a very large unsigned integer." (see #122) + if (value < 0) + buffer.writeVarint64(value); + else + buffer.writeVarint32(value); + break; + + // 32bit unsigned varint + case ProtoBuf.TYPES["uint32"]: + buffer.writeVarint32(value); + break; + + // 32bit varint zig-zag + case ProtoBuf.TYPES["sint32"]: + buffer.writeVarint32ZigZag(value); + break; + + // Fixed unsigned 32bit + case ProtoBuf.TYPES["fixed32"]: + buffer.writeUint32(value); + break; + + // Fixed signed 32bit + case ProtoBuf.TYPES["sfixed32"]: + buffer.writeInt32(value); + break; + + // 64bit varint as-is + case ProtoBuf.TYPES["int64"]: + case ProtoBuf.TYPES["uint64"]: + buffer.writeVarint64(value); // throws + break; + + // 64bit varint zig-zag + case ProtoBuf.TYPES["sint64"]: + buffer.writeVarint64ZigZag(value); // throws + break; + + // Fixed unsigned 64bit + case ProtoBuf.TYPES["fixed64"]: + buffer.writeUint64(value); // throws + break; + + // Fixed signed 64bit + case ProtoBuf.TYPES["sfixed64"]: + buffer.writeInt64(value); // throws + break; + + // Bool + case ProtoBuf.TYPES["bool"]: + if (typeof value === 'string') + buffer.writeVarint32(value.toLowerCase() === 'false' ? 0 : !!value); + else + buffer.writeVarint32(value ? 1 : 0); + break; + + // Constant enum value + case ProtoBuf.TYPES["enum"]: + buffer.writeVarint32(value); + break; + + // 32bit float + case ProtoBuf.TYPES["float"]: + buffer.writeFloat32(value); + break; + + // 64bit float + case ProtoBuf.TYPES["double"]: + buffer.writeFloat64(value); + break; + + // Length-delimited string + case ProtoBuf.TYPES["string"]: + buffer.writeVString(value); + break; + + // Length-delimited bytes + case ProtoBuf.TYPES["bytes"]: + if (value.remaining() < 0) + throw Error("Illegal value for "+this.toString(true)+": "+value.remaining()+" bytes remaining"); + var prevOffset = value.offset; + buffer.writeVarint32(value.remaining()); + buffer.append(value); + value.offset = prevOffset; + break; + + // Embedded message + case ProtoBuf.TYPES["message"]: + var bb = new ByteBuffer().LE(); + this.resolvedType.encode(value, bb); + buffer.writeVarint32(bb.offset); + buffer.append(bb.flip()); + break; + + // Legacy group + case ProtoBuf.TYPES["group"]: + this.resolvedType.encode(value, buffer); + buffer.writeVarint32((id << 3) | ProtoBuf.WIRE_TYPES.ENDGROUP); + break; + + default: + // We should never end here + throw Error("[INTERNAL] Illegal value to encode in "+this.toString(true)+": "+value+" (unknown type)"); + } + return buffer; + }; + + /** + * Decode one element value from the specified buffer. + * @param {ByteBuffer} buffer ByteBuffer to decode from + * @param {number} wireType The field wire type + * @param {number} id The field number + * @return {*} Decoded value + * @throws {Error} If the field cannot be decoded + * @expose + */ + ElementPrototype.decode = function(buffer, wireType, id) { + if (wireType != this.type.wireType) + throw Error("Unexpected wire type for element"); + + var value, nBytes; + switch (this.type) { + // 32bit signed varint + case ProtoBuf.TYPES["int32"]: + return buffer.readVarint32() | 0; + + // 32bit unsigned varint + case ProtoBuf.TYPES["uint32"]: + return buffer.readVarint32() >>> 0; + + // 32bit signed varint zig-zag + case ProtoBuf.TYPES["sint32"]: + return buffer.readVarint32ZigZag() | 0; + + // Fixed 32bit unsigned + case ProtoBuf.TYPES["fixed32"]: + return buffer.readUint32() >>> 0; + + case ProtoBuf.TYPES["sfixed32"]: + return buffer.readInt32() | 0; + + // 64bit signed varint + case ProtoBuf.TYPES["int64"]: + return buffer.readVarint64(); + + // 64bit unsigned varint + case ProtoBuf.TYPES["uint64"]: + return buffer.readVarint64().toUnsigned(); + + // 64bit signed varint zig-zag + case ProtoBuf.TYPES["sint64"]: + return buffer.readVarint64ZigZag(); + + // Fixed 64bit unsigned + case ProtoBuf.TYPES["fixed64"]: + return buffer.readUint64(); + + // Fixed 64bit signed + case ProtoBuf.TYPES["sfixed64"]: + return buffer.readInt64(); + + // Bool varint + case ProtoBuf.TYPES["bool"]: + return !!buffer.readVarint32(); + + // Constant enum value (varint) + case ProtoBuf.TYPES["enum"]: + // The following Builder.Message#set will already throw + return buffer.readVarint32(); + + // 32bit float + case ProtoBuf.TYPES["float"]: + return buffer.readFloat(); + + // 64bit float + case ProtoBuf.TYPES["double"]: + return buffer.readDouble(); + + // Length-delimited string + case ProtoBuf.TYPES["string"]: + return buffer.readVString(); + + // Length-delimited bytes + case ProtoBuf.TYPES["bytes"]: { + nBytes = buffer.readVarint32(); + if (buffer.remaining() < nBytes) + throw Error("Illegal number of bytes for "+this.toString(true)+": "+nBytes+" required but got only "+buffer.remaining()); + value = buffer.clone(); // Offset already set + value.limit = value.offset+nBytes; + buffer.offset += nBytes; + return value; + } + + // Length-delimited embedded message + case ProtoBuf.TYPES["message"]: { + nBytes = buffer.readVarint32(); + return this.resolvedType.decode(buffer, nBytes); + } + + // Legacy group + case ProtoBuf.TYPES["group"]: + return this.resolvedType.decode(buffer, -1, id); + } + + // We should never end here + throw Error("[INTERNAL] Illegal decode type"); + }; + + /** + * Converts a value from a string to the canonical element type. + * + * Legal only when isMapKey is true. + * + * @param {string} str The string value + * @returns {*} The value + */ + ElementPrototype.valueFromString = function(str) { + if (!this.isMapKey) { + throw Error("valueFromString() called on non-map-key element"); + } + + switch (this.type) { + case ProtoBuf.TYPES["int32"]: + case ProtoBuf.TYPES["sint32"]: + case ProtoBuf.TYPES["sfixed32"]: + case ProtoBuf.TYPES["uint32"]: + case ProtoBuf.TYPES["fixed32"]: + return this.verifyValue(parseInt(str)); + + case ProtoBuf.TYPES["int64"]: + case ProtoBuf.TYPES["sint64"]: + case ProtoBuf.TYPES["sfixed64"]: + case ProtoBuf.TYPES["uint64"]: + case ProtoBuf.TYPES["fixed64"]: + // Long-based fields support conversions from string already. + return this.verifyValue(str); + + case ProtoBuf.TYPES["bool"]: + return str === "true"; + + case ProtoBuf.TYPES["string"]: + return this.verifyValue(str); + + case ProtoBuf.TYPES["bytes"]: + return ByteBuffer.fromBinary(str); + } + }; + + /** + * Converts a value from the canonical element type to a string. + * + * It should be the case that `valueFromString(valueToString(val))` returns + * a value equivalent to `verifyValue(val)` for every legal value of `val` + * according to this element type. + * + * This may be used when the element must be stored or used as a string, + * e.g., as a map key on an Object. + * + * Legal only when isMapKey is true. + * + * @param {*} val The value + * @returns {string} The string form of the value. + */ + ElementPrototype.valueToString = function(value) { + if (!this.isMapKey) { + throw Error("valueToString() called on non-map-key element"); + } + + if (this.type === ProtoBuf.TYPES["bytes"]) { + return value.toString("binary"); + } else { + return value.toString(); + } + }; + + /** + * @alias ProtoBuf.Reflect.Element + * @expose + */ + Reflect.Element = Element; + + /** + * Constructs a new Message. + * @exports ProtoBuf.Reflect.Message + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.Namespace} parent Parent message or namespace + * @param {string} name Message name + * @param {Object.=} options Message options + * @param {boolean=} isGroup `true` if this is a legacy group + * @param {string?} syntax The syntax level of this definition (e.g., proto3) + * @constructor + * @extends ProtoBuf.Reflect.Namespace + */ + var Message = function(builder, parent, name, options, isGroup, syntax) { + Namespace.call(this, builder, parent, name, options, syntax); + + /** + * @override + */ + this.className = "Message"; + + /** + * Extensions range. + * @type {!Array.|undefined} + * @expose + */ + this.extensions = undefined; + + /** + * Runtime message class. + * @type {?function(new:ProtoBuf.Builder.Message)} + * @expose + */ + this.clazz = null; + + /** + * Whether this is a legacy group or not. + * @type {boolean} + * @expose + */ + this.isGroup = !!isGroup; + + // The following cached collections are used to efficiently iterate over or look up fields when decoding. + + /** + * Cached fields. + * @type {?Array.} + * @private + */ + this._fields = null; + + /** + * Cached fields by id. + * @type {?Object.} + * @private + */ + this._fieldsById = null; + + /** + * Cached fields by name. + * @type {?Object.} + * @private + */ + this._fieldsByName = null; + }; + + /** + * @alias ProtoBuf.Reflect.Message.prototype + * @inner + */ + var MessagePrototype = Message.prototype = Object.create(Namespace.prototype); + + /** + * Builds the message and returns the runtime counterpart, which is a fully functional class. + * @see ProtoBuf.Builder.Message + * @param {boolean=} rebuild Whether to rebuild or not, defaults to false + * @return {ProtoBuf.Reflect.Message} Message class + * @throws {Error} If the message cannot be built + * @expose + */ + MessagePrototype.build = function(rebuild) { + if (this.clazz && !rebuild) + return this.clazz; + + // Create the runtime Message class in its own scope + var clazz = (function(ProtoBuf, T) { + + var fields = T.getChildren(ProtoBuf.Reflect.Message.Field), + oneofs = T.getChildren(ProtoBuf.Reflect.Message.OneOf); + + /** + * Constructs a new runtime Message. + * @name ProtoBuf.Builder.Message + * @class Barebone of all runtime messages. + * @param {!Object.|string} values Preset values + * @param {...string} var_args + * @constructor + * @throws {Error} If the message cannot be created + */ + var Message = function(values, var_args) { + ProtoBuf.Builder.Message.call(this); + + // Create virtual oneof properties + for (var i=0, k=oneofs.length; i 0) { + var value; + // Set field values from a values object + if (arguments.length === 1 && values !== null && typeof values === 'object' && + /* not _another_ Message */ (typeof values.encode !== 'function' || values instanceof Message) && + /* not a repeated field */ !Array.isArray(values) && + /* not a Map */ !(values instanceof ProtoBuf.Map) && + /* not a ByteBuffer */ !ByteBuffer.isByteBuffer(values) && + /* not an ArrayBuffer */ !(values instanceof ArrayBuffer) && + /* not a Long */ !(ProtoBuf.Long && values instanceof ProtoBuf.Long)) { + this.$set(values); + } else // Set field values from arguments, in declaration order + for (i=0, k=arguments.length; i} keyOrObj String key or plain object holding multiple values + * @param {(*|boolean)=} value Value to set if key is a string, otherwise omitted + * @param {boolean=} noAssert Whether to not assert for an actual field / proper value type, defaults to `false` + * @returns {!ProtoBuf.Builder.Message} this + * @throws {Error} If the value cannot be set + * @expose + */ + MessagePrototype.set = function(keyOrObj, value, noAssert) { + if (keyOrObj && typeof keyOrObj === 'object') { + noAssert = value; + for (var ikey in keyOrObj) + if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined') + this.$set(ikey, value, noAssert); + return this; + } + var field = T._fieldsByName[keyOrObj]; + if (!noAssert) { + if (!field) + throw Error(this+"#"+keyOrObj+" is not a field: undefined"); + if (!(field instanceof ProtoBuf.Reflect.Message.Field)) + throw Error(this+"#"+keyOrObj+" is not a field: "+field.toString(true)); + this[field.name] = (value = field.verifyValue(value)); // May throw + } else + this[keyOrObj] = value; + if (field && field.oneof) { // Field is part of an OneOf (not a virtual OneOf field) + var currentField = this[field.oneof.name]; // Virtual field references currently set field + if (value !== null) { + if (currentField !== null && currentField !== field.name) + this[currentField] = null; // Clear currently set field + this[field.oneof.name] = field.name; // Point virtual field at this field + } else if (/* value === null && */currentField === keyOrObj) + this[field.oneof.name] = null; // Clear virtual field (current field explicitly cleared) + } + return this; + }; + + /** + * Sets a field's value. This is an alias for [@link ProtoBuf.Builder.Message#set}. + * @name ProtoBuf.Builder.Message#$set + * @function + * @param {string|!Object.} keyOrObj String key or plain object holding multiple values + * @param {(*|boolean)=} value Value to set if key is a string, otherwise omitted + * @param {boolean=} noAssert Whether to not assert the value, defaults to `false` + * @throws {Error} If the value cannot be set + * @expose + */ + MessagePrototype.$set = MessagePrototype.set; + + /** + * Gets a field's value. + * @name ProtoBuf.Builder.Message#get + * @function + * @param {string} key Key + * @param {boolean=} noAssert Whether to not assert for an actual field, defaults to `false` + * @return {*} Value + * @throws {Error} If there is no such field + * @expose + */ + MessagePrototype.get = function(key, noAssert) { + if (noAssert) + return this[key]; + var field = T._fieldsByName[key]; + if (!field || !(field instanceof ProtoBuf.Reflect.Message.Field)) + throw Error(this+"#"+key+" is not a field: undefined"); + if (!(field instanceof ProtoBuf.Reflect.Message.Field)) + throw Error(this+"#"+key+" is not a field: "+field.toString(true)); + return this[field.name]; + }; + + /** + * Gets a field's value. This is an alias for {@link ProtoBuf.Builder.Message#$get}. + * @name ProtoBuf.Builder.Message#$get + * @function + * @param {string} key Key + * @return {*} Value + * @throws {Error} If there is no such field + * @expose + */ + MessagePrototype.$get = MessagePrototype.get; + + // Getters and setters + + for (var i=0; i} data Data payload + * @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted. + * @param {boolean=} noVerify Whether to not verify field values, defaults to `false` + * @return {!ByteBuffer} Encoded message as a ByteBuffer + * @expose + */ + Message.encode = function(data, buffer, noVerify) { + return new Message(data).encode(buffer, noVerify); + }; + + /** + * Calculates the byte length of the message. + * @name ProtoBuf.Builder.Message#calculate + * @function + * @returns {number} Byte length + * @throws {Error} If the message cannot be calculated or if required fields are missing. + * @expose + */ + MessagePrototype.calculate = function() { + return T.calculate(this); + }; + + /** + * Encodes the varint32 length-delimited message. + * @name ProtoBuf.Builder.Message#encodeDelimited + * @function + * @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted. + * @param {boolean=} noVerify Whether to not verify field values, defaults to `false` + * @return {!ByteBuffer} Encoded message as a ByteBuffer + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded ByteBuffer in the `encoded` property on the error. + * @expose + */ + MessagePrototype.encodeDelimited = function(buffer, noVerify) { + var isNew = false; + if (!buffer) + buffer = new ByteBuffer(), + isNew = true; + var enc = new ByteBuffer().LE(); + T.encode(this, enc, noVerify).flip(); + buffer.writeVarint32(enc.remaining()); + buffer.append(enc); + return isNew ? buffer.flip() : buffer; + }; + + /** + * Directly encodes the message to an ArrayBuffer. + * @name ProtoBuf.Builder.Message#encodeAB + * @function + * @return {ArrayBuffer} Encoded message as ArrayBuffer + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded ArrayBuffer in the `encoded` property on the error. + * @expose + */ + MessagePrototype.encodeAB = function() { + try { + return this.encode().toArrayBuffer(); + } catch (e) { + if (e["encoded"]) e["encoded"] = e["encoded"].toArrayBuffer(); + throw(e); + } + }; + + /** + * Returns the message as an ArrayBuffer. This is an alias for {@link ProtoBuf.Builder.Message#encodeAB}. + * @name ProtoBuf.Builder.Message#toArrayBuffer + * @function + * @return {ArrayBuffer} Encoded message as ArrayBuffer + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded ArrayBuffer in the `encoded` property on the error. + * @expose + */ + MessagePrototype.toArrayBuffer = MessagePrototype.encodeAB; + + /** + * Directly encodes the message to a node Buffer. + * @name ProtoBuf.Builder.Message#encodeNB + * @function + * @return {!Buffer} + * @throws {Error} If the message cannot be encoded, not running under node.js or if required fields are + * missing. The later still returns the encoded node Buffer in the `encoded` property on the error. + * @expose + */ + MessagePrototype.encodeNB = function() { + try { + return this.encode().toBuffer(); + } catch (e) { + if (e["encoded"]) e["encoded"] = e["encoded"].toBuffer(); + throw(e); + } + }; + + /** + * Returns the message as a node Buffer. This is an alias for {@link ProtoBuf.Builder.Message#encodeNB}. + * @name ProtoBuf.Builder.Message#toBuffer + * @function + * @return {!Buffer} + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded node Buffer in the `encoded` property on the error. + * @expose + */ + MessagePrototype.toBuffer = MessagePrototype.encodeNB; + + /** + * Directly encodes the message to a base64 encoded string. + * @name ProtoBuf.Builder.Message#encode64 + * @function + * @return {string} Base64 encoded string + * @throws {Error} If the underlying buffer cannot be encoded or if required fields are missing. The later + * still returns the encoded base64 string in the `encoded` property on the error. + * @expose + */ + MessagePrototype.encode64 = function() { + try { + return this.encode().toBase64(); + } catch (e) { + if (e["encoded"]) e["encoded"] = e["encoded"].toBase64(); + throw(e); + } + }; + + /** + * Returns the message as a base64 encoded string. This is an alias for {@link ProtoBuf.Builder.Message#encode64}. + * @name ProtoBuf.Builder.Message#toBase64 + * @function + * @return {string} Base64 encoded string + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded base64 string in the `encoded` property on the error. + * @expose + */ + MessagePrototype.toBase64 = MessagePrototype.encode64; + + /** + * Directly encodes the message to a hex encoded string. + * @name ProtoBuf.Builder.Message#encodeHex + * @function + * @return {string} Hex encoded string + * @throws {Error} If the underlying buffer cannot be encoded or if required fields are missing. The later + * still returns the encoded hex string in the `encoded` property on the error. + * @expose + */ + MessagePrototype.encodeHex = function() { + try { + return this.encode().toHex(); + } catch (e) { + if (e["encoded"]) e["encoded"] = e["encoded"].toHex(); + throw(e); + } + }; + + /** + * Returns the message as a hex encoded string. This is an alias for {@link ProtoBuf.Builder.Message#encodeHex}. + * @name ProtoBuf.Builder.Message#toHex + * @function + * @return {string} Hex encoded string + * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still + * returns the encoded hex string in the `encoded` property on the error. + * @expose + */ + MessagePrototype.toHex = MessagePrototype.encodeHex; + + /** + * Clones a message object or field value to a raw object. + * @param {*} obj Object to clone + * @param {boolean} binaryAsBase64 Whether to include binary data as base64 strings or as a buffer otherwise + * @param {boolean} longsAsStrings Whether to encode longs as strings + * @param {!ProtoBuf.Reflect.T=} resolvedType The resolved field type if a field + * @returns {*} Cloned object + * @inner + */ + function cloneRaw(obj, binaryAsBase64, longsAsStrings, resolvedType) { + if (obj === null || typeof obj !== 'object') { + // Convert enum values to their respective names + if (resolvedType && resolvedType instanceof ProtoBuf.Reflect.Enum) { + var name = ProtoBuf.Reflect.Enum.getName(resolvedType.object, obj); + if (name !== null) + return name; + } + // Pass-through string, number, boolean, null... + return obj; + } + // Convert ByteBuffers to raw buffer or strings + if (ByteBuffer.isByteBuffer(obj)) + return binaryAsBase64 ? obj.toBase64() : obj.toBuffer(); + // Convert Longs to proper objects or strings + if (ProtoBuf.Long.isLong(obj)) + return longsAsStrings ? obj.toString() : ProtoBuf.Long.fromValue(obj); + var clone; + // Clone arrays + if (Array.isArray(obj)) { + clone = []; + obj.forEach(function(v, k) { + clone[k] = cloneRaw(v, binaryAsBase64, longsAsStrings, resolvedType); + }); + return clone; + } + clone = {}; + // Convert maps to objects + if (obj instanceof ProtoBuf.Map) { + var it = obj.entries(); + for (var e = it.next(); !e.done; e = it.next()) + clone[obj.keyElem.valueToString(e.value[0])] = cloneRaw(e.value[1], binaryAsBase64, longsAsStrings, obj.valueElem.resolvedType); + return clone; + } + // Everything else is a non-null object + var type = obj.$type, + field = undefined; + for (var i in obj) + if (obj.hasOwnProperty(i)) { + if (type && (field = type.getChild(i))) + clone[i] = cloneRaw(obj[i], binaryAsBase64, longsAsStrings, field.resolvedType); + else + clone[i] = cloneRaw(obj[i], binaryAsBase64, longsAsStrings); + } + return clone; + } + + /** + * Returns the message's raw payload. + * @param {boolean=} binaryAsBase64 Whether to include binary data as base64 strings instead of Buffers, defaults to `false` + * @param {boolean} longsAsStrings Whether to encode longs as strings + * @returns {Object.} Raw payload + * @expose + */ + MessagePrototype.toRaw = function(binaryAsBase64, longsAsStrings) { + return cloneRaw(this, !!binaryAsBase64, !!longsAsStrings, this.$type); + }; + + /** + * Encodes a message to JSON. + * @returns {string} JSON string + * @expose + */ + MessagePrototype.encodeJSON = function() { + return JSON.stringify( + cloneRaw(this, + /* binary-as-base64 */ true, + /* longs-as-strings */ true, + this.$type + ) + ); + }; + + /** + * Decodes a message from the specified buffer or string. + * @name ProtoBuf.Builder.Message.decode + * @function + * @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from + * @param {(number|string)=} length Message length. Defaults to decode all the remainig data. + * @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64 + * @return {!ProtoBuf.Builder.Message} Decoded message + * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still + * returns the decoded message with missing fields in the `decoded` property on the error. + * @expose + * @see ProtoBuf.Builder.Message.decode64 + * @see ProtoBuf.Builder.Message.decodeHex + */ + Message.decode = function(buffer, length, enc) { + if (typeof length === 'string') + enc = length, + length = -1; + if (typeof buffer === 'string') + buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64"); + buffer = ByteBuffer.isByteBuffer(buffer) ? buffer : ByteBuffer.wrap(buffer); // May throw + var le = buffer.littleEndian; + try { + var msg = T.decode(buffer.LE()); + buffer.LE(le); + return msg; + } catch (e) { + buffer.LE(le); + throw(e); + } + }; + + /** + * Decodes a varint32 length-delimited message from the specified buffer or string. + * @name ProtoBuf.Builder.Message.decodeDelimited + * @function + * @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from + * @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64 + * @return {ProtoBuf.Builder.Message} Decoded message or `null` if not enough bytes are available yet + * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still + * returns the decoded message with missing fields in the `decoded` property on the error. + * @expose + */ + Message.decodeDelimited = function(buffer, enc) { + if (typeof buffer === 'string') + buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64"); + buffer = ByteBuffer.isByteBuffer(buffer) ? buffer : ByteBuffer.wrap(buffer); // May throw + if (buffer.remaining() < 1) + return null; + var off = buffer.offset, + len = buffer.readVarint32(); + if (buffer.remaining() < len) { + buffer.offset = off; + return null; + } + try { + var msg = T.decode(buffer.slice(buffer.offset, buffer.offset + len).LE()); + buffer.offset += len; + return msg; + } catch (err) { + buffer.offset += len; + throw err; + } + }; + + /** + * Decodes the message from the specified base64 encoded string. + * @name ProtoBuf.Builder.Message.decode64 + * @function + * @param {string} str String to decode from + * @return {!ProtoBuf.Builder.Message} Decoded message + * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still + * returns the decoded message with missing fields in the `decoded` property on the error. + * @expose + */ + Message.decode64 = function(str) { + return Message.decode(str, "base64"); + }; + + /** + * Decodes the message from the specified hex encoded string. + * @name ProtoBuf.Builder.Message.decodeHex + * @function + * @param {string} str String to decode from + * @return {!ProtoBuf.Builder.Message} Decoded message + * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still + * returns the decoded message with missing fields in the `decoded` property on the error. + * @expose + */ + Message.decodeHex = function(str) { + return Message.decode(str, "hex"); + }; + + /** + * Decodes the message from a JSON string. + * @name ProtoBuf.Builder.Message.decodeJSON + * @function + * @param {string} str String to decode from + * @return {!ProtoBuf.Builder.Message} Decoded message + * @throws {Error} If the message cannot be decoded or if required fields are + * missing. + * @expose + */ + Message.decodeJSON = function(str) { + return new Message(JSON.parse(str)); + }; + + // Utility + + /** + * Returns a string representation of this Message. + * @name ProtoBuf.Builder.Message#toString + * @function + * @return {string} String representation as of ".Fully.Qualified.MessageName" + * @expose + */ + MessagePrototype.toString = function() { + return T.toString(); + }; + + // Properties + + /** + * Message options. + * @name ProtoBuf.Builder.Message.$options + * @type {Object.} + * @expose + */ + var $optionsS; // cc needs this + + /** + * Message options. + * @name ProtoBuf.Builder.Message#$options + * @type {Object.} + * @expose + */ + var $options; + + /** + * Reflection type. + * @name ProtoBuf.Builder.Message.$type + * @type {!ProtoBuf.Reflect.Message} + * @expose + */ + var $typeS; + + /** + * Reflection type. + * @name ProtoBuf.Builder.Message#$type + * @type {!ProtoBuf.Reflect.Message} + * @expose + */ + var $type; + + if (Object.defineProperty) + Object.defineProperty(Message, '$options', { "value": T.buildOpt() }), + Object.defineProperty(MessagePrototype, "$options", { "value": Message["$options"] }), + Object.defineProperty(Message, "$type", { "value": T }), + Object.defineProperty(MessagePrototype, "$type", { "value": T }); + + return Message; + + })(ProtoBuf, this); + + // Static enums and prototyped sub-messages / cached collections + this._fields = []; + this._fieldsById = {}; + this._fieldsByName = {}; + for (var i=0, k=this.children.length, child; i>> 3; + switch (wireType) { + case ProtoBuf.WIRE_TYPES.VARINT: + do tag = buf.readUint8(); + while ((tag & 0x80) === 0x80); + break; + case ProtoBuf.WIRE_TYPES.BITS64: + buf.offset += 8; + break; + case ProtoBuf.WIRE_TYPES.LDELIM: + tag = buf.readVarint32(); // reads the varint + buf.offset += tag; // skips n bytes + break; + case ProtoBuf.WIRE_TYPES.STARTGROUP: + skipTillGroupEnd(id, buf); + break; + case ProtoBuf.WIRE_TYPES.ENDGROUP: + if (id === expectedId) + return false; + else + throw Error("Illegal GROUPEND after unknown group: "+id+" ("+expectedId+" expected)"); + case ProtoBuf.WIRE_TYPES.BITS32: + buf.offset += 4; + break; + default: + throw Error("Illegal wire type in unknown group "+expectedId+": "+wireType); + } + return true; + } + + /** + * Decodes an encoded message and returns the decoded message. + * @param {ByteBuffer} buffer ByteBuffer to decode from + * @param {number=} length Message length. Defaults to decode all remaining data. + * @param {number=} expectedGroupEndId Expected GROUPEND id if this is a legacy group + * @return {ProtoBuf.Builder.Message} Decoded message + * @throws {Error} If the message cannot be decoded + * @expose + */ + MessagePrototype.decode = function(buffer, length, expectedGroupEndId) { + length = typeof length === 'number' ? length : -1; + var start = buffer.offset, + msg = new (this.clazz)(), + tag, wireType, id, field; + while (buffer.offset < start+length || (length === -1 && buffer.remaining() > 0)) { + tag = buffer.readVarint32(); + wireType = tag & 0x07; + id = tag >>> 3; + if (wireType === ProtoBuf.WIRE_TYPES.ENDGROUP) { + if (id !== expectedGroupEndId) + throw Error("Illegal group end indicator for "+this.toString(true)+": "+id+" ("+(expectedGroupEndId ? expectedGroupEndId+" expected" : "not a group")+")"); + break; + } + if (!(field = this._fieldsById[id])) { + // "messages created by your new code can be parsed by your old code: old binaries simply ignore the new field when parsing." + switch (wireType) { + case ProtoBuf.WIRE_TYPES.VARINT: + buffer.readVarint32(); + break; + case ProtoBuf.WIRE_TYPES.BITS32: + buffer.offset += 4; + break; + case ProtoBuf.WIRE_TYPES.BITS64: + buffer.offset += 8; + break; + case ProtoBuf.WIRE_TYPES.LDELIM: + var len = buffer.readVarint32(); + buffer.offset += len; + break; + case ProtoBuf.WIRE_TYPES.STARTGROUP: + while (skipTillGroupEnd(id, buffer)) {} + break; + default: + throw Error("Illegal wire type for unknown field "+id+" in "+this.toString(true)+"#decode: "+wireType); + } + continue; + } + if (field.repeated && !field.options["packed"]) { + msg[field.name].push(field.decode(wireType, buffer)); + } else if (field.map) { + var keyval = field.decode(wireType, buffer); + msg[field.name].set(keyval[0], keyval[1]); + } else { + msg[field.name] = field.decode(wireType, buffer); + if (field.oneof) { // Field is part of an OneOf (not a virtual OneOf field) + var currentField = msg[field.oneof.name]; // Virtual field references currently set field + if (currentField !== null && currentField !== field.name) + msg[currentField] = null; // Clear currently set field + msg[field.oneof.name] = field.name; // Point virtual field at this field + } + } + } + + // Check if all required fields are present and set default values for optional fields that are not + for (var i=0, k=this._fields.length; i=} options Options + * @param {!ProtoBuf.Reflect.Message.OneOf=} oneof Enclosing OneOf + * @param {string?} syntax The syntax level of this definition (e.g., proto3) + * @constructor + * @extends ProtoBuf.Reflect.T + */ + var Field = function(builder, message, rule, keytype, type, name, id, options, oneof, syntax) { + T.call(this, builder, message, name); + + /** + * @override + */ + this.className = "Message.Field"; + + /** + * Message field required flag. + * @type {boolean} + * @expose + */ + this.required = rule === "required"; + + /** + * Message field repeated flag. + * @type {boolean} + * @expose + */ + this.repeated = rule === "repeated"; + + /** + * Message field map flag. + * @type {boolean} + * @expose + */ + this.map = rule === "map"; + + /** + * Message field key type. Type reference string if unresolved, protobuf + * type if resolved. Valid only if this.map === true, null otherwise. + * @type {string|{name: string, wireType: number}|null} + * @expose + */ + this.keyType = keytype || null; + + /** + * Message field type. Type reference string if unresolved, protobuf type if + * resolved. In a map field, this is the value type. + * @type {string|{name: string, wireType: number}} + * @expose + */ + this.type = type; + + /** + * Resolved type reference inside the global namespace. + * @type {ProtoBuf.Reflect.T|null} + * @expose + */ + this.resolvedType = null; + + /** + * Unique message field id. + * @type {number} + * @expose + */ + this.id = id; + + /** + * Message field options. + * @type {!Object.} + * @dict + * @expose + */ + this.options = options || {}; + + /** + * Default value. + * @type {*} + * @expose + */ + this.defaultValue = null; + + /** + * Enclosing OneOf. + * @type {?ProtoBuf.Reflect.Message.OneOf} + * @expose + */ + this.oneof = oneof || null; + + /** + * Syntax level of this definition (e.g., proto3). + * @type {string} + * @expose + */ + this.syntax = syntax || 'proto2'; + + /** + * Original field name. + * @type {string} + * @expose + */ + this.originalName = this.name; // Used to revert camelcase transformation on naming collisions + + /** + * Element implementation. Created in build() after types are resolved. + * @type {ProtoBuf.Element} + * @expose + */ + this.element = null; + + /** + * Key element implementation, for map fields. Created in build() after + * types are resolved. + * @type {ProtoBuf.Element} + * @expose + */ + this.keyElement = null; + + // Convert field names to camel case notation if the override is set + if (this.builder.options['convertFieldsToCamelCase'] && !(this instanceof Message.ExtensionField)) + this.name = ProtoBuf.Util.toCamelCase(this.name); + }; + + /** + * @alias ProtoBuf.Reflect.Message.Field.prototype + * @inner + */ + var FieldPrototype = Field.prototype = Object.create(T.prototype); + + /** + * Builds the field. + * @override + * @expose + */ + FieldPrototype.build = function() { + this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name); + if (this.map) + this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name); + + // In proto3, fields do not have field presence, and every field is set to + // its type's default value ("", 0, 0.0, or false). + if (this.syntax === 'proto3' && !this.repeated && !this.map) + this.defaultValue = Element.defaultFieldValue(this.type); + + // Otherwise, default values are present when explicitly specified + else if (typeof this.options['default'] !== 'undefined') + this.defaultValue = this.verifyValue(this.options['default']); + }; + + /** + * Checks if the given value can be set for this field. + * @param {*} value Value to check + * @param {boolean=} skipRepeated Whether to skip the repeated value check or not. Defaults to false. + * @return {*} Verified, maybe adjusted, value + * @throws {Error} If the value cannot be set for this field + * @expose + */ + FieldPrototype.verifyValue = function(value, skipRepeated) { + skipRepeated = skipRepeated || false; + var self = this; + function fail(val, msg) { + throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")"); + } + if (value === null) { // NULL values for optional fields + if (this.required) + fail(typeof value, "required"); + if (this.syntax === 'proto3' && this.type !== ProtoBuf.TYPES["message"]) + fail(typeof value, "proto3 field without field presence cannot be null"); + return null; + } + var i; + if (this.repeated && !skipRepeated) { // Repeated values as arrays + if (!Array.isArray(value)) + value = [value]; + var res = []; + for (i=0; i 0; + + case ProtoBuf.TYPES["bytes"]: + return value.remaining() > 0; + + case ProtoBuf.TYPES["enum"]: + return value !== 0; + + case ProtoBuf.TYPES["message"]: + return value !== null; + default: + return true; + } + }; + + /** + * Encodes the specified field value to the specified buffer. + * @param {*} value Verified field value + * @param {ByteBuffer} buffer ByteBuffer to encode to + * @param {!ProtoBuf.Builder.Message} message Runtime message + * @return {ByteBuffer} The ByteBuffer for chaining + * @throws {Error} If the field cannot be encoded + * @expose + */ + FieldPrototype.encode = function(value, buffer, message) { + if (this.type === null || typeof this.type !== 'object') + throw Error("[INTERNAL] Unresolved type in "+this.toString(true)+": "+this.type); + if (value === null || (this.repeated && value.length == 0)) + return buffer; // Optional omitted + try { + if (this.repeated) { + var i; + // "Only repeated fields of primitive numeric types (types which use the varint, 32-bit, or 64-bit wire + // types) can be declared 'packed'." + if (this.options["packed"] && ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType) >= 0) { + // "All of the elements of the field are packed into a single key-value pair with wire type 2 + // (length-delimited). Each element is encoded the same way it would be normally, except without a + // tag preceding it." + buffer.writeVarint32((this.id << 3) | ProtoBuf.WIRE_TYPES.LDELIM); + buffer.ensureCapacity(buffer.offset += 1); // We do not know the length yet, so let's assume a varint of length 1 + var start = buffer.offset; // Remember where the contents begin + for (i=0; i 1) { // We need to move the contents + var contents = buffer.slice(start, buffer.offset); + start += varintLen-1; + buffer.offset = start; + buffer.append(contents); + } + buffer.writeVarint32(len, start-varintLen); + } else { + // "If your message definition has repeated elements (without the [packed=true] option), the encoded + // message has zero or more key-value pairs with the same tag number" + for (i=0; i= 0) { + n += ByteBuffer.calculateVarint32((this.id << 3) | ProtoBuf.WIRE_TYPES.LDELIM); + ni = 0; + for (i=0; i= 0) { + if (!skipRepeated) { + nBytes = buffer.readVarint32(); + nBytes = buffer.offset + nBytes; // Limit + var values = []; + while (buffer.offset < nBytes) + values.push(this.decode(this.type.wireType, buffer, true)); + return values; + } + // Read the next value otherwise... + } + + // Handle maps. + if (this.map) { + // Read one (key, value) submessage, and return [key, value] + var key = Element.defaultFieldValue(this.keyType); + value = Element.defaultFieldValue(this.type); + + // Read the length + nBytes = buffer.readVarint32(); + if (buffer.remaining() < nBytes) + throw Error("Illegal number of bytes for "+this.toString(true)+": "+nBytes+" required but got only "+buffer.remaining()); + + // Get a sub-buffer of this key/value submessage + var msgbuf = buffer.clone(); + msgbuf.limit = msgbuf.offset + nBytes; + buffer.offset += nBytes; + + while (msgbuf.remaining() > 0) { + var tag = msgbuf.readVarint32(); + wireType = tag & 0x07; + var id = tag >>> 3; + if (id === 1) { + key = this.keyElement.decode(msgbuf, wireType, id); + } else if (id === 2) { + value = this.element.decode(msgbuf, wireType, id); + } else { + throw Error("Unexpected tag in map field key/value submessage"); + } + } + + return [key, value]; + } + + // Handle singular and non-packed repeated field values. + return this.element.decode(buffer, wireType, this.id); + }; + + /** + * @alias ProtoBuf.Reflect.Message.Field + * @expose + */ + Reflect.Message.Field = Field; + + /** + * Constructs a new Message ExtensionField. + * @exports ProtoBuf.Reflect.Message.ExtensionField + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.Message} message Message reference + * @param {string} rule Rule, one of requried, optional, repeated + * @param {string} type Data type, e.g. int32 + * @param {string} name Field name + * @param {number} id Unique field id + * @param {!Object.=} options Options + * @constructor + * @extends ProtoBuf.Reflect.Message.Field + */ + var ExtensionField = function(builder, message, rule, type, name, id, options) { + Field.call(this, builder, message, rule, /* keytype = */ null, type, name, id, options); + + /** + * Extension reference. + * @type {!ProtoBuf.Reflect.Extension} + * @expose + */ + this.extension; + }; + + // Extends Field + ExtensionField.prototype = Object.create(Field.prototype); + + /** + * @alias ProtoBuf.Reflect.Message.ExtensionField + * @expose + */ + Reflect.Message.ExtensionField = ExtensionField; + + /** + * Constructs a new Message OneOf. + * @exports ProtoBuf.Reflect.Message.OneOf + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.Message} message Message reference + * @param {string} name OneOf name + * @constructor + * @extends ProtoBuf.Reflect.T + */ + var OneOf = function(builder, message, name) { + T.call(this, builder, message, name); + + /** + * Enclosed fields. + * @type {!Array.} + * @expose + */ + this.fields = []; + }; + + /** + * @alias ProtoBuf.Reflect.Message.OneOf + * @expose + */ + Reflect.Message.OneOf = OneOf; + + /** + * Constructs a new Enum. + * @exports ProtoBuf.Reflect.Enum + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.T} parent Parent Reflect object + * @param {string} name Enum name + * @param {Object.=} options Enum options + * @param {string?} syntax The syntax level (e.g., proto3) + * @constructor + * @extends ProtoBuf.Reflect.Namespace + */ + var Enum = function(builder, parent, name, options, syntax) { + Namespace.call(this, builder, parent, name, options, syntax); + + /** + * @override + */ + this.className = "Enum"; + + /** + * Runtime enum object. + * @type {Object.|null} + * @expose + */ + this.object = null; + }; + + /** + * Gets the string name of an enum value. + * @param {!ProtoBuf.Builder.Enum} enm Runtime enum + * @param {number} value Enum value + * @returns {?string} Name or `null` if not present + * @expose + */ + Enum.getName = function(enm, value) { + var keys = Object.keys(enm); + for (var i=0, key; i} + * @expose + */ + EnumPrototype.build = function(rebuild) { + if (this.object && !rebuild) + return this.object; + var enm = new ProtoBuf.Builder.Enum(), + values = this.getChildren(Enum.Value); + for (var i=0, k=values.length; i=} options Options + * @constructor + * @extends ProtoBuf.Reflect.Namespace + */ + var Service = function(builder, root, name, options) { + Namespace.call(this, builder, root, name, options); + + /** + * @override + */ + this.className = "Service"; + + /** + * Built runtime service class. + * @type {?function(new:ProtoBuf.Builder.Service)} + */ + this.clazz = null; + }; + + /** + * @alias ProtoBuf.Reflect.Service.prototype + * @inner + */ + var ServicePrototype = Service.prototype = Object.create(Namespace.prototype); + + /** + * Builds the service and returns the runtime counterpart, which is a fully functional class. + * @see ProtoBuf.Builder.Service + * @param {boolean=} rebuild Whether to rebuild or not + * @return {Function} Service class + * @throws {Error} If the message cannot be built + * @expose + */ + ServicePrototype.build = function(rebuild) { + if (this.clazz && !rebuild) + return this.clazz; + + // Create the runtime Service class in its own scope + return this.clazz = (function(ProtoBuf, T) { + + /** + * Constructs a new runtime Service. + * @name ProtoBuf.Builder.Service + * @param {function(string, ProtoBuf.Builder.Message, function(Error, ProtoBuf.Builder.Message=))=} rpcImpl RPC implementation receiving the method name and the message + * @class Barebone of all runtime services. + * @constructor + * @throws {Error} If the service cannot be created + */ + var Service = function(rpcImpl) { + ProtoBuf.Builder.Service.call(this); + + /** + * Service implementation. + * @name ProtoBuf.Builder.Service#rpcImpl + * @type {!function(string, ProtoBuf.Builder.Message, function(Error, ProtoBuf.Builder.Message=))} + * @expose + */ + this.rpcImpl = rpcImpl || function(name, msg, callback) { + // This is what a user has to implement: A function receiving the method name, the actual message to + // send (type checked) and the callback that's either provided with the error as its first + // argument or null and the actual response message. + setTimeout(callback.bind(this, Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")), 0); // Must be async! + }; + }; + + /** + * @alias ProtoBuf.Builder.Service.prototype + * @inner + */ + var ServicePrototype = Service.prototype = Object.create(ProtoBuf.Builder.Service.prototype); + + /** + * Asynchronously performs an RPC call using the given RPC implementation. + * @name ProtoBuf.Builder.Service.[Method] + * @function + * @param {!function(string, ProtoBuf.Builder.Message, function(Error, ProtoBuf.Builder.Message=))} rpcImpl RPC implementation + * @param {ProtoBuf.Builder.Message} req Request + * @param {function(Error, (ProtoBuf.Builder.Message|ByteBuffer|Buffer|string)=)} callback Callback receiving + * the error if any and the response either as a pre-parsed message or as its raw bytes + * @abstract + */ + + /** + * Asynchronously performs an RPC call using the instance's RPC implementation. + * @name ProtoBuf.Builder.Service#[Method] + * @function + * @param {ProtoBuf.Builder.Message} req Request + * @param {function(Error, (ProtoBuf.Builder.Message|ByteBuffer|Buffer|string)=)} callback Callback receiving + * the error if any and the response either as a pre-parsed message or as its raw bytes + * @abstract + */ + + var rpc = T.getChildren(ProtoBuf.Reflect.Service.RPCMethod); + for (var i=0; i} + * @expose + */ + var $optionsS; // cc needs this + + /** + * Service options. + * @name ProtoBuf.Builder.Service#$options + * @type {Object.} + * @expose + */ + var $options; + + /** + * Reflection type. + * @name ProtoBuf.Builder.Service.$type + * @type {!ProtoBuf.Reflect.Service} + * @expose + */ + var $typeS; + + /** + * Reflection type. + * @name ProtoBuf.Builder.Service#$type + * @type {!ProtoBuf.Reflect.Service} + * @expose + */ + var $type; + + if (Object.defineProperty) + Object.defineProperty(Service, "$options", { "value": T.buildOpt() }), + Object.defineProperty(ServicePrototype, "$options", { "value": Service["$options"] }), + Object.defineProperty(Service, "$type", { "value": T }), + Object.defineProperty(ServicePrototype, "$type", { "value": T }); + + return Service; + + })(ProtoBuf, this); + }; + + /** + * @alias ProtoBuf.Reflect.Service + * @expose + */ + Reflect.Service = Service; + + /** + * Abstract service method. + * @exports ProtoBuf.Reflect.Service.Method + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.Service} svc Service + * @param {string} name Method name + * @param {Object.=} options Options + * @constructor + * @extends ProtoBuf.Reflect.T + */ + var Method = function(builder, svc, name, options) { + T.call(this, builder, svc, name); + + /** + * @override + */ + this.className = "Service.Method"; + + /** + * Options. + * @type {Object.} + * @expose + */ + this.options = options || {}; + }; + + /** + * @alias ProtoBuf.Reflect.Service.Method.prototype + * @inner + */ + var MethodPrototype = Method.prototype = Object.create(T.prototype); + + /** + * Builds the method's '$options' property. + * @name ProtoBuf.Reflect.Service.Method#buildOpt + * @function + * @return {Object.} + */ + MethodPrototype.buildOpt = NamespacePrototype.buildOpt; + + /** + * @alias ProtoBuf.Reflect.Service.Method + * @expose + */ + Reflect.Service.Method = Method; + + /** + * RPC service method. + * @exports ProtoBuf.Reflect.Service.RPCMethod + * @param {!ProtoBuf.Builder} builder Builder reference + * @param {!ProtoBuf.Reflect.Service} svc Service + * @param {string} name Method name + * @param {string} request Request message name + * @param {string} response Response message name + * @param {boolean} request_stream Whether requests are streamed + * @param {boolean} response_stream Whether responses are streamed + * @param {Object.=} options Options + * @constructor + * @extends ProtoBuf.Reflect.Service.Method + */ + var RPCMethod = function(builder, svc, name, request, response, request_stream, response_stream, options) { + Method.call(this, builder, svc, name, options); + + /** + * @override + */ + this.className = "Service.RPCMethod"; + + /** + * Request message name. + * @type {string} + * @expose + */ + this.requestName = request; + + /** + * Response message name. + * @type {string} + * @expose + */ + this.responseName = response; + + /** + * Whether requests are streamed + * @type {bool} + * @expose + */ + this.requestStream = request_stream; + + /** + * Whether responses are streamed + * @type {bool} + * @expose + */ + this.responseStream = response_stream; + + /** + * Resolved request message type. + * @type {ProtoBuf.Reflect.Message} + * @expose + */ + this.resolvedRequestType = null; + + /** + * Resolved response message type. + * @type {ProtoBuf.Reflect.Message} + * @expose + */ + this.resolvedResponseType = null; + }; + + // Extends Method + RPCMethod.prototype = Object.create(Method.prototype); + + /** + * @alias ProtoBuf.Reflect.Service.RPCMethod + * @expose + */ + Reflect.Service.RPCMethod = RPCMethod; + + return Reflect; + + })(ProtoBuf); + + /** + * @alias ProtoBuf.Builder + * @expose + */ + ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) { + "use strict"; + + /** + * Constructs a new Builder. + * @exports ProtoBuf.Builder + * @class Provides the functionality to build protocol messages. + * @param {Object.=} options Options + * @constructor + */ + var Builder = function(options) { + + /** + * Namespace. + * @type {ProtoBuf.Reflect.Namespace} + * @expose + */ + this.ns = new Reflect.Namespace(this, null, ""); // Global namespace + + /** + * Namespace pointer. + * @type {ProtoBuf.Reflect.T} + * @expose + */ + this.ptr = this.ns; + + /** + * Resolved flag. + * @type {boolean} + * @expose + */ + this.resolved = false; + + /** + * The current building result. + * @type {Object.|null} + * @expose + */ + this.result = null; + + /** + * Imported files. + * @type {Array.} + * @expose + */ + this.files = {}; + + /** + * Import root override. + * @type {?string} + * @expose + */ + this.importRoot = null; + + /** + * Options. + * @type {!Object.} + * @expose + */ + this.options = options || {}; + }; + + /** + * @alias ProtoBuf.Builder.prototype + * @inner + */ + var BuilderPrototype = Builder.prototype; + + // ----- Definition tests ----- + + /** + * Tests if a definition most likely describes a message. + * @param {!Object} def + * @returns {boolean} + * @expose + */ + Builder.isMessage = function(def) { + // Messages require a string name + if (typeof def["name"] !== 'string') + return false; + // Messages do not contain values (enum) or rpc methods (service) + if (typeof def["values"] !== 'undefined' || typeof def["rpc"] !== 'undefined') + return false; + return true; + }; + + /** + * Tests if a definition most likely describes a message field. + * @param {!Object} def + * @returns {boolean} + * @expose + */ + Builder.isMessageField = function(def) { + // Message fields require a string rule, name and type and an id + if (typeof def["rule"] !== 'string' || typeof def["name"] !== 'string' || typeof def["type"] !== 'string' || typeof def["id"] === 'undefined') + return false; + return true; + }; + + /** + * Tests if a definition most likely describes an enum. + * @param {!Object} def + * @returns {boolean} + * @expose + */ + Builder.isEnum = function(def) { + // Enums require a string name + if (typeof def["name"] !== 'string') + return false; + // Enums require at least one value + if (typeof def["values"] === 'undefined' || !Array.isArray(def["values"]) || def["values"].length === 0) + return false; + return true; + }; + + /** + * Tests if a definition most likely describes a service. + * @param {!Object} def + * @returns {boolean} + * @expose + */ + Builder.isService = function(def) { + // Services require a string name and an rpc object + if (typeof def["name"] !== 'string' || typeof def["rpc"] !== 'object' || !def["rpc"]) + return false; + return true; + }; + + /** + * Tests if a definition most likely describes an extended message + * @param {!Object} def + * @returns {boolean} + * @expose + */ + Builder.isExtend = function(def) { + // Extends rquire a string ref + if (typeof def["ref"] !== 'string') + return false; + return true; + }; + + // ----- Building ----- + + /** + * Resets the pointer to the root namespace. + * @returns {!ProtoBuf.Builder} this + * @expose + */ + BuilderPrototype.reset = function() { + this.ptr = this.ns; + return this; + }; + + /** + * Defines a namespace on top of the current pointer position and places the pointer on it. + * @param {string} namespace + * @return {!ProtoBuf.Builder} this + * @expose + */ + BuilderPrototype.define = function(namespace) { + if (typeof namespace !== 'string' || !Lang.TYPEREF.test(namespace)) + throw Error("illegal namespace: "+namespace); + namespace.split(".").forEach(function(part) { + var ns = this.ptr.getChild(part); + if (ns === null) // Keep existing + this.ptr.addChild(ns = new Reflect.Namespace(this, this.ptr, part)); + this.ptr = ns; + }, this); + return this; + }; + + /** + * Creates the specified definitions at the current pointer position. + * @param {!Array.} defs Messages, enums or services to create + * @returns {!ProtoBuf.Builder} this + * @throws {Error} If a message definition is invalid + * @expose + */ + BuilderPrototype.create = function(defs) { + if (!defs) + return this; // Nothing to create + if (!Array.isArray(defs)) + defs = [defs]; + else { + if (defs.length === 0) + return this; + defs = defs.slice(); + } + + // It's quite hard to keep track of scopes and memory here, so let's do this iteratively. + var stack = [defs]; + while (stack.length > 0) { + defs = stack.pop(); + + if (!Array.isArray(defs)) // Stack always contains entire namespaces + throw Error("not a valid namespace: "+JSON.stringify(defs)); + + while (defs.length > 0) { + var def = defs.shift(); // Namespaces always contain an array of messages, enums and services + + if (Builder.isMessage(def)) { + var obj = new Reflect.Message(this, this.ptr, def["name"], def["options"], def["isGroup"], def["syntax"]); + + // Create OneOfs + var oneofs = {}; + if (def["oneofs"]) + Object.keys(def["oneofs"]).forEach(function(name) { + obj.addChild(oneofs[name] = new Reflect.Message.OneOf(this, obj, name)); + }, this); + + // Create fields + if (def["fields"]) + def["fields"].forEach(function(fld) { + if (obj.getChild(fld["id"]|0) !== null) + throw Error("duplicate or invalid field id in "+obj.name+": "+fld['id']); + if (fld["options"] && typeof fld["options"] !== 'object') + throw Error("illegal field options in "+obj.name+"#"+fld["name"]); + var oneof = null; + if (typeof fld["oneof"] === 'string' && !(oneof = oneofs[fld["oneof"]])) + throw Error("illegal oneof in "+obj.name+"#"+fld["name"]+": "+fld["oneof"]); + fld = new Reflect.Message.Field(this, obj, fld["rule"], fld["keytype"], fld["type"], fld["name"], fld["id"], fld["options"], oneof, def["syntax"]); + if (oneof) + oneof.fields.push(fld); + obj.addChild(fld); + }, this); + + // Push children to stack + var subObj = []; + if (def["enums"]) + def["enums"].forEach(function(enm) { + subObj.push(enm); + }); + if (def["messages"]) + def["messages"].forEach(function(msg) { + subObj.push(msg); + }); + if (def["services"]) + def["services"].forEach(function(svc) { + subObj.push(svc); + }); + + // Set extension ranges + if (def["extensions"]) { + if (typeof def["extensions"][0] === 'number') // pre 5.0.1 + obj.extensions = [ def["extensions"] ]; + else + obj.extensions = def["extensions"]; + } + + // Create on top of current namespace + this.ptr.addChild(obj); + if (subObj.length > 0) { + stack.push(defs); // Push the current level back + defs = subObj; // Continue processing sub level + subObj = null; + this.ptr = obj; // And move the pointer to this namespace + obj = null; + continue; + } + subObj = null; + + } else if (Builder.isEnum(def)) { + + obj = new Reflect.Enum(this, this.ptr, def["name"], def["options"], def["syntax"]); + def["values"].forEach(function(val) { + obj.addChild(new Reflect.Enum.Value(this, obj, val["name"], val["id"])); + }, this); + this.ptr.addChild(obj); + + } else if (Builder.isService(def)) { + + obj = new Reflect.Service(this, this.ptr, def["name"], def["options"]); + Object.keys(def["rpc"]).forEach(function(name) { + var mtd = def["rpc"][name]; + obj.addChild(new Reflect.Service.RPCMethod(this, obj, name, mtd["request"], mtd["response"], !!mtd["request_stream"], !!mtd["response_stream"], mtd["options"])); + }, this); + this.ptr.addChild(obj); + + } else if (Builder.isExtend(def)) { + + obj = this.ptr.resolve(def["ref"], true); + if (obj) { + def["fields"].forEach(function(fld) { + if (obj.getChild(fld['id']|0) !== null) + throw Error("duplicate extended field id in "+obj.name+": "+fld['id']); + // Check if field id is allowed to be extended + if (obj.extensions) { + var valid = false; + obj.extensions.forEach(function(range) { + if (fld["id"] >= range[0] && fld["id"] <= range[1]) + valid = true; + }); + if (!valid) + throw Error("illegal extended field id in "+obj.name+": "+fld['id']+" (not within valid ranges)"); + } + // Convert extension field names to camel case notation if the override is set + var name = fld["name"]; + if (this.options['convertFieldsToCamelCase']) + name = ProtoBuf.Util.toCamelCase(name); + // see #161: Extensions use their fully qualified name as their runtime key and... + var field = new Reflect.Message.ExtensionField(this, obj, fld["rule"], fld["type"], this.ptr.fqn()+'.'+name, fld["id"], fld["options"]); + // ...are added on top of the current namespace as an extension which is used for + // resolving their type later on (the extension always keeps the original name to + // prevent naming collisions) + var ext = new Reflect.Extension(this, this.ptr, fld["name"], field); + field.extension = ext; + this.ptr.addChild(ext); + obj.addChild(field); + }, this); + + } else if (!/\.?google\.protobuf\./.test(def["ref"])) // Silently skip internal extensions + throw Error("extended message "+def["ref"]+" is not defined"); + + } else + throw Error("not a valid definition: "+JSON.stringify(def)); + + def = null; + obj = null; + } + // Break goes here + defs = null; + this.ptr = this.ptr.parent; // Namespace done, continue at parent + } + this.resolved = false; // Require re-resolve + this.result = null; // Require re-build + return this; + }; + + /** + * Propagates syntax to all children. + * @param {!Object} parent + * @inner + */ + function propagateSyntax(parent) { + if (parent['messages']) { + parent['messages'].forEach(function(child) { + child["syntax"] = parent["syntax"]; + propagateSyntax(child); + }); + } + if (parent['enums']) { + parent['enums'].forEach(function(child) { + child["syntax"] = parent["syntax"]; + }); + } + } + + /** + * Imports another definition into this builder. + * @param {Object.} json Parsed import + * @param {(string|{root: string, file: string})=} filename Imported file name + * @returns {!ProtoBuf.Builder} this + * @throws {Error} If the definition or file cannot be imported + * @expose + */ + BuilderPrototype["import"] = function(json, filename) { + var delim = '/'; + + // Make sure to skip duplicate imports + + if (typeof filename === 'string') { + + if (ProtoBuf.Util.IS_NODE) + filename = require("path")['resolve'](filename); + if (this.files[filename] === true) + return this.reset(); + this.files[filename] = true; + + } else if (typeof filename === 'object') { // Object with root, file. + + var root = filename.root; + if (ProtoBuf.Util.IS_NODE) + root = require("path")['resolve'](root); + if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0) + delim = '\\'; + var fname = root + delim + filename.file; + if (this.files[fname] === true) + return this.reset(); + this.files[fname] = true; + } + + // Import imports + + if (json['imports'] && json['imports'].length > 0) { + var importRoot, + resetRoot = false; + + if (typeof filename === 'object') { // If an import root is specified, override + + this.importRoot = filename["root"]; resetRoot = true; // ... and reset afterwards + importRoot = this.importRoot; + filename = filename["file"]; + if (importRoot.indexOf("\\") >= 0 || filename.indexOf("\\") >= 0) + delim = '\\'; + + } else if (typeof filename === 'string') { + + if (this.importRoot) // If import root is overridden, use it + importRoot = this.importRoot; + else { // Otherwise compute from filename + if (filename.indexOf("/") >= 0) { // Unix + importRoot = filename.replace(/\/[^\/]*$/, ""); + if (/* /file.proto */ importRoot === "") + importRoot = "/"; + } else if (filename.indexOf("\\") >= 0) { // Windows + importRoot = filename.replace(/\\[^\\]*$/, ""); + delim = '\\'; + } else + importRoot = "."; + } + + } else + importRoot = null; + + for (var i=0; i)=} path Specifies what to return. If omitted, the entire namespace will be returned. + * @returns {!ProtoBuf.Builder.Message|!Object.} + * @throws {Error} If a type could not be resolved + * @expose + */ + BuilderPrototype.build = function(path) { + this.reset(); + if (!this.resolved) + this.resolveAll(), + this.resolved = true, + this.result = null; // Require re-build + if (this.result === null) // (Re-)Build + this.result = this.ns.build(); + if (!path) + return this.result; + var part = typeof path === 'string' ? path.split(".") : path, + ptr = this.result; // Build namespace pointer (no hasChild etc.) + for (var i=0; i=} contents Initial contents + * @constructor + */ + var Map = function(field, contents) { + if (!field.map) + throw Error("field is not a map"); + + /** + * The field corresponding to this map. + * @type {!ProtoBuf.Reflect.Field} + */ + this.field = field; + + /** + * Element instance corresponding to key type. + * @type {!ProtoBuf.Reflect.Element} + */ + this.keyElem = new Reflect.Element(field.keyType, null, true, field.syntax); + + /** + * Element instance corresponding to value type. + * @type {!ProtoBuf.Reflect.Element} + */ + this.valueElem = new Reflect.Element(field.type, field.resolvedType, false, field.syntax); + + /** + * Internal map: stores mapping of (string form of key) -> (key, value) + * pair. + * + * We provide map semantics for arbitrary key types, but we build on top + * of an Object, which has only string keys. In order to avoid the need + * to convert a string key back to its native type in many situations, + * we store the native key value alongside the value. Thus, we only need + * a one-way mapping from a key type to its string form that guarantees + * uniqueness and equality (i.e., str(K1) === str(K2) if and only if K1 + * === K2). + * + * @type {!Object} + */ + this.map = {}; + + /** + * Returns the number of elements in the map. + */ + Object.defineProperty(this, "size", { + get: function() { return Object.keys(this.map).length; } + }); + + // Fill initial contents from a raw object. + if (contents) { + var keys = Object.keys(contents); + for (var i = 0; i < keys.length; i++) { + var key = this.keyElem.valueFromString(keys[i]); + var val = this.valueElem.verifyValue(contents[keys[i]]); + this.map[this.keyElem.valueToString(key)] = + { key: key, value: val }; + } + } + }; + + var MapPrototype = Map.prototype; + + /** + * Helper: return an iterator over an array. + * @param {!Array<*>} arr the array + * @returns {!Object} an iterator + * @inner + */ + function arrayIterator(arr) { + var idx = 0; + return { + next: function() { + if (idx < arr.length) + return { done: false, value: arr[idx++] }; + return { done: true }; + } + } + } + + /** + * Clears the map. + */ + MapPrototype.clear = function() { + this.map = {}; + }; + + /** + * Deletes a particular key from the map. + * @returns {boolean} Whether any entry with this key was deleted. + */ + MapPrototype["delete"] = function(key) { + var keyValue = this.keyElem.valueToString(this.keyElem.verifyValue(key)); + var hadKey = keyValue in this.map; + delete this.map[keyValue]; + return hadKey; + }; + + /** + * Returns an iterator over [key, value] pairs in the map. + * @returns {Object} The iterator + */ + MapPrototype.entries = function() { + var entries = []; + var strKeys = Object.keys(this.map); + for (var i = 0, entry; i < strKeys.length; i++) + entries.push([(entry=this.map[strKeys[i]]).key, entry.value]); + return arrayIterator(entries); + }; + + /** + * Returns an iterator over keys in the map. + * @returns {Object} The iterator + */ + MapPrototype.keys = function() { + var keys = []; + var strKeys = Object.keys(this.map); + for (var i = 0; i < strKeys.length; i++) + keys.push(this.map[strKeys[i]].key); + return arrayIterator(keys); + }; + + /** + * Returns an iterator over values in the map. + * @returns {!Object} The iterator + */ + MapPrototype.values = function() { + var values = []; + var strKeys = Object.keys(this.map); + for (var i = 0; i < strKeys.length; i++) + values.push(this.map[strKeys[i]].value); + return arrayIterator(values); + }; + + /** + * Iterates over entries in the map, calling a function on each. + * @param {function(this:*, *, *, *)} cb The callback to invoke with value, key, and map arguments. + * @param {Object=} thisArg The `this` value for the callback + */ + MapPrototype.forEach = function(cb, thisArg) { + var strKeys = Object.keys(this.map); + for (var i = 0, entry; i < strKeys.length; i++) + cb.call(thisArg, (entry=this.map[strKeys[i]]).value, entry.key, this); + }; + + /** + * Sets a key in the map to the given value. + * @param {*} key The key + * @param {*} value The value + * @returns {!ProtoBuf.Map} The map instance + */ + MapPrototype.set = function(key, value) { + var keyValue = this.keyElem.verifyValue(key); + var valValue = this.valueElem.verifyValue(value); + this.map[this.keyElem.valueToString(keyValue)] = + { key: keyValue, value: valValue }; + return this; + }; + + /** + * Gets the value corresponding to a key in the map. + * @param {*} key The key + * @returns {*|undefined} The value, or `undefined` if key not present + */ + MapPrototype.get = function(key) { + var keyValue = this.keyElem.valueToString(this.keyElem.verifyValue(key)); + if (!(keyValue in this.map)) + return undefined; + return this.map[keyValue].value; + }; + + /** + * Determines whether the given key is present in the map. + * @param {*} key The key + * @returns {boolean} `true` if the key is present + */ + MapPrototype.has = function(key) { + var keyValue = this.keyElem.valueToString(this.keyElem.verifyValue(key)); + return (keyValue in this.map); + }; + + return Map; + })(ProtoBuf, ProtoBuf.Reflect); + + + /** + * Loads a .proto string and returns the Builder. + * @param {string} proto .proto file contents + * @param {(ProtoBuf.Builder|string|{root: string, file: string})=} builder Builder to append to. Will create a new one if omitted. + * @param {(string|{root: string, file: string})=} filename The corresponding file name if known. Must be specified for imports. + * @return {ProtoBuf.Builder} Builder to create new messages + * @throws {Error} If the definition cannot be parsed or built + * @expose + */ + ProtoBuf.loadProto = function(proto, builder, filename) { + if (typeof builder === 'string' || (builder && typeof builder["file"] === 'string' && typeof builder["root"] === 'string')) + filename = builder, + builder = undefined; + return ProtoBuf.loadJson(ProtoBuf.DotProto.Parser.parse(proto), builder, filename); + }; + + /** + * Loads a .proto string and returns the Builder. This is an alias of {@link ProtoBuf.loadProto}. + * @function + * @param {string} proto .proto file contents + * @param {(ProtoBuf.Builder|string)=} builder Builder to append to. Will create a new one if omitted. + * @param {(string|{root: string, file: string})=} filename The corresponding file name if known. Must be specified for imports. + * @return {ProtoBuf.Builder} Builder to create new messages + * @throws {Error} If the definition cannot be parsed or built + * @expose + */ + ProtoBuf.protoFromString = ProtoBuf.loadProto; // Legacy + + /** + * Loads a .proto file and returns the Builder. + * @param {string|{root: string, file: string}} filename Path to proto file or an object specifying 'file' with + * an overridden 'root' path for all imported files. + * @param {function(?Error, !ProtoBuf.Builder=)=} callback Callback that will receive `null` as the first and + * the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the + * file will be read synchronously and this function will return the Builder. + * @param {ProtoBuf.Builder=} builder Builder to append to. Will create a new one if omitted. + * @return {?ProtoBuf.Builder|undefined} The Builder if synchronous (no callback specified, will be NULL if the + * request has failed), else undefined + * @expose + */ + ProtoBuf.loadProtoFile = function(filename, callback, builder) { + if (callback && typeof callback === 'object') + builder = callback, + callback = null; + else if (!callback || typeof callback !== 'function') + callback = null; + if (callback) + return ProtoBuf.Util.fetch(typeof filename === 'string' ? filename : filename["root"]+"/"+filename["file"], function(contents) { + if (contents === null) { + callback(Error("Failed to fetch file")); + return; + } + try { + callback(null, ProtoBuf.loadProto(contents, builder, filename)); + } catch (e) { + callback(e); + } + }); + var contents = ProtoBuf.Util.fetch(typeof filename === 'object' ? filename["root"]+"/"+filename["file"] : filename); + return contents === null ? null : ProtoBuf.loadProto(contents, builder, filename); + }; + + /** + * Loads a .proto file and returns the Builder. This is an alias of {@link ProtoBuf.loadProtoFile}. + * @function + * @param {string|{root: string, file: string}} filename Path to proto file or an object specifying 'file' with + * an overridden 'root' path for all imported files. + * @param {function(?Error, !ProtoBuf.Builder=)=} callback Callback that will receive `null` as the first and + * the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the + * file will be read synchronously and this function will return the Builder. + * @param {ProtoBuf.Builder=} builder Builder to append to. Will create a new one if omitted. + * @return {!ProtoBuf.Builder|undefined} The Builder if synchronous (no callback specified, will be NULL if the + * request has failed), else undefined + * @expose + */ + ProtoBuf.protoFromFile = ProtoBuf.loadProtoFile; // Legacy + + + /** + * Constructs a new empty Builder. + * @param {Object.=} options Builder options, defaults to global options set on ProtoBuf + * @return {!ProtoBuf.Builder} Builder + * @expose + */ + ProtoBuf.newBuilder = function(options) { + options = options || {}; + if (typeof options['convertFieldsToCamelCase'] === 'undefined') + options['convertFieldsToCamelCase'] = ProtoBuf.convertFieldsToCamelCase; + if (typeof options['populateAccessors'] === 'undefined') + options['populateAccessors'] = ProtoBuf.populateAccessors; + return new ProtoBuf.Builder(options); + }; + + /** + * Loads a .json definition and returns the Builder. + * @param {!*|string} json JSON definition + * @param {(ProtoBuf.Builder|string|{root: string, file: string})=} builder Builder to append to. Will create a new one if omitted. + * @param {(string|{root: string, file: string})=} filename The corresponding file name if known. Must be specified for imports. + * @return {ProtoBuf.Builder} Builder to create new messages + * @throws {Error} If the definition cannot be parsed or built + * @expose + */ + ProtoBuf.loadJson = function(json, builder, filename) { + if (typeof builder === 'string' || (builder && typeof builder["file"] === 'string' && typeof builder["root"] === 'string')) + filename = builder, + builder = null; + if (!builder || typeof builder !== 'object') + builder = ProtoBuf.newBuilder(); + if (typeof json === 'string') + json = JSON.parse(json); + builder["import"](json, filename); + builder.resolveAll(); + return builder; + }; + + /** + * Loads a .json file and returns the Builder. + * @param {string|!{root: string, file: string}} filename Path to json file or an object specifying 'file' with + * an overridden 'root' path for all imported files. + * @param {function(?Error, !ProtoBuf.Builder=)=} callback Callback that will receive `null` as the first and + * the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the + * file will be read synchronously and this function will return the Builder. + * @param {ProtoBuf.Builder=} builder Builder to append to. Will create a new one if omitted. + * @return {?ProtoBuf.Builder|undefined} The Builder if synchronous (no callback specified, will be NULL if the + * request has failed), else undefined + * @expose + */ + ProtoBuf.loadJsonFile = function(filename, callback, builder) { + if (callback && typeof callback === 'object') + builder = callback, + callback = null; + else if (!callback || typeof callback !== 'function') + callback = null; + if (callback) + return ProtoBuf.Util.fetch(typeof filename === 'string' ? filename : filename["root"]+"/"+filename["file"], function(contents) { + if (contents === null) { + callback(Error("Failed to fetch file")); + return; + } + try { + callback(null, ProtoBuf.loadJson(JSON.parse(contents), builder, filename)); + } catch (e) { + callback(e); + } + }); + var contents = ProtoBuf.Util.fetch(typeof filename === 'object' ? filename["root"]+"/"+filename["file"] : filename); + return contents === null ? null : ProtoBuf.loadJson(JSON.parse(contents), builder, filename); + }; + + return ProtoBuf; +}); diff --git a/games/laya-snakes/map/tile_map.png b/games/laya-snakes/map/tile_map.png new file mode 100644 index 0000000..1c16442 Binary files /dev/null and b/games/laya-snakes/map/tile_map.png differ diff --git a/games/laya-snakes/res/atlas/comp.json b/games/laya-snakes/res/atlas/comp.json new file mode 100644 index 0000000..0ec438f --- /dev/null +++ b/games/laya-snakes/res/atlas/comp.json @@ -0,0 +1 @@ +{"frames":{"bg.png":{"frame":{"x":0,"y":0,"w":100,"h":79,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":100,"h":79},"sourceSize":{"w":100,"h":79}},"blank.png":{"frame":{"x":0,"y":81,"w":10,"h":10,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":10,"h":10},"sourceSize":{"w":10,"h":10}},"btn_close.png":{"frame":{"x":0,"y":93,"w":28,"h":60,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":28,"h":60},"sourceSize":{"w":28,"h":60}},"button.png":{"frame":{"x":0,"y":155,"w":75,"h":69,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":75,"h":69},"sourceSize":{"w":75,"h":69}},"checkbox.png":{"frame":{"x":30,"y":81,"w":14,"h":42,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":42},"sourceSize":{"w":14,"h":42}},"clip_num.png":{"frame":{"x":30,"y":125,"w":240,"h":27,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":240,"h":27},"sourceSize":{"w":240,"h":27}},"clip_selectBox.png":{"frame":{"x":46,"y":81,"w":100,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":100,"h":40},"sourceSize":{"w":100,"h":40}},"clip_tree_arrow.png":{"frame":{"x":0,"y":226,"w":14,"h":28,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":28},"sourceSize":{"w":14,"h":28}},"clip_tree_folder.png":{"frame":{"x":102,"y":0,"w":16,"h":48,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":16,"h":48},"sourceSize":{"w":16,"h":48}},"combobox.png":{"frame":{"x":120,"y":0,"w":91,"h":69,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":91,"h":69},"sourceSize":{"w":91,"h":69}},"hscroll$bar.png":{"frame":{"x":148,"y":71,"w":21,"h":51,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":21,"h":51},"sourceSize":{"w":21,"h":51}},"hscroll$down.png":{"frame":{"x":171,"y":71,"w":17,"h":51,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":51},"sourceSize":{"w":17,"h":51}},"hscroll$up.png":{"frame":{"x":190,"y":71,"w":17,"h":51,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":51},"sourceSize":{"w":17,"h":51}},"hscroll.png":{"frame":{"x":16,"y":226,"w":33,"h":17,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":33,"h":17},"sourceSize":{"w":33,"h":17}},"hslider$bar.png":{"frame":{"x":209,"y":71,"w":14,"h":42,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":42},"sourceSize":{"w":14,"h":42}},"hslider.png":{"frame":{"x":209,"y":115,"w":100,"h":6,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":100,"h":6},"sourceSize":{"w":100,"h":6}},"html.png":{"frame":{"x":51,"y":226,"w":120,"h":18,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":120,"h":18},"sourceSize":{"w":120,"h":18}},"image.png":{"frame":{"x":311,"y":0,"w":150,"h":250,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":150,"h":250},"sourceSize":{"w":150,"h":250}},"label.png":{"frame":{"x":173,"y":154,"w":120,"h":18,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":120,"h":18},"sourceSize":{"w":120,"h":18}},"linkbutton.png":{"frame":{"x":173,"y":174,"w":120,"h":18,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":120,"h":18},"sourceSize":{"w":120,"h":18}},"progress$bar.png":{"frame":{"x":77,"y":154,"w":50,"h":14,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":50,"h":14},"sourceSize":{"w":50,"h":14}},"progress.png":{"frame":{"x":77,"y":170,"w":50,"h":14,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":50,"h":14},"sourceSize":{"w":50,"h":14}},"radio.png":{"frame":{"x":295,"y":123,"w":14,"h":42,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":42},"sourceSize":{"w":14,"h":42}},"radiogroup.png":{"frame":{"x":295,"y":167,"w":14,"h":42,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":42},"sourceSize":{"w":14,"h":42}},"tab.png":{"frame":{"x":225,"y":0,"w":70,"h":78,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":70,"h":78},"sourceSize":{"w":70,"h":78}},"textarea.png":{"frame":{"x":77,"y":186,"w":91,"h":23,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":91,"h":23},"sourceSize":{"w":91,"h":23}},"textinput.png":{"frame":{"x":170,"y":194,"w":91,"h":23,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":91,"h":23},"sourceSize":{"w":91,"h":23}},"vscroll$bar.png":{"frame":{"x":463,"y":0,"w":17,"h":63,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":63},"sourceSize":{"w":17,"h":63}},"vscroll$down.png":{"frame":{"x":263,"y":194,"w":17,"h":51,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":51},"sourceSize":{"w":17,"h":51}},"vscroll$up.png":{"frame":{"x":482,"y":0,"w":17,"h":51,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":51},"sourceSize":{"w":17,"h":51}},"vscroll.png":{"frame":{"x":282,"y":211,"w":17,"h":33,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":17,"h":33},"sourceSize":{"w":17,"h":33}},"vslider$bar.png":{"frame":{"x":482,"y":53,"w":14,"h":42,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":14,"h":42},"sourceSize":{"w":14,"h":42}},"vslider.png":{"frame":{"x":297,"y":0,"w":6,"h":100,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":6,"h":100},"sourceSize":{"w":6,"h":100}}},"meta":{"app":"http://www.layabox.com","prefix":"comp/","version":"1.0","image":"comp.png","format":"","size":{"w":512,"h":256},"scale":"1"}} \ No newline at end of file diff --git a/games/laya-snakes/res/atlas/comp.png b/games/laya-snakes/res/atlas/comp.png new file mode 100644 index 0000000..0ef953a Binary files /dev/null and b/games/laya-snakes/res/atlas/comp.png differ diff --git a/games/laya-snakes/res/atlas/images.json b/games/laya-snakes/res/atlas/images.json new file mode 100644 index 0000000..9b46362 --- /dev/null +++ b/games/laya-snakes/res/atlas/images.json @@ -0,0 +1 @@ +{"frames":{"bean1.png":{"frame":{"x":0,"y":0,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"bean2.png":{"frame":{"x":0,"y":7,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"bean3.png":{"frame":{"x":0,"y":14,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"bean4.png":{"frame":{"x":0,"y":21,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"bean5.png":{"frame":{"x":0,"y":28,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"bean6.png":{"frame":{"x":0,"y":35,"w":5,"h":5,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":5,"h":5},"sourceSize":{"w":5,"h":5}},"body1.png":{"frame":{"x":0,"y":42,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"body2.png":{"frame":{"x":7,"y":0,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"body3.png":{"frame":{"x":0,"y":84,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"body4.png":{"frame":{"x":0,"y":126,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"body5.png":{"frame":{"x":0,"y":168,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"btn-back.png":{"frame":{"x":0,"y":210,"w":45,"h":45,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":45,"h":45},"sourceSize":{"w":45,"h":45}},"btn-restart.png":{"frame":{"x":42,"y":42,"w":45,"h":45,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":45,"h":45},"sourceSize":{"w":45,"h":45}},"control-back.png":{"frame":{"x":42,"y":89,"w":80,"h":80,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":80,"h":80},"sourceSize":{"w":80,"h":80}},"control-flash.png":{"frame":{"x":0,"y":257,"w":80,"h":160,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":80,"h":160},"sourceSize":{"w":80,"h":160}},"control-rocker.png":{"frame":{"x":42,"y":171,"w":35,"h":35,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":35,"h":35},"sourceSize":{"w":35,"h":35}},"gameover-background.png":{"frame":{"x":82,"y":171,"w":341,"h":197,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":341,"h":197},"sourceSize":{"w":341,"h":197}},"head1.png":{"frame":{"x":49,"y":0,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"head2.png":{"frame":{"x":89,"y":42,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"head3.png":{"frame":{"x":91,"y":0,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"head4.png":{"frame":{"x":124,"y":84,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"head5.png":{"frame":{"x":131,"y":42,"w":40,"h":40,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":40,"h":40},"sourceSize":{"w":40,"h":40}},"map-tile.jpg":{"frame":{"x":47,"y":208,"w":11,"h":11,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":11,"h":11},"sourceSize":{"w":11,"h":11}},"s1-btn1.png":{"frame":{"x":166,"y":84,"w":120,"h":80,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":120,"h":80},"sourceSize":{"w":120,"h":80}},"s1-btn2.png":{"frame":{"x":173,"y":0,"w":120,"h":80,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":120,"h":80},"sourceSize":{"w":120,"h":80}},"s1-input.png":{"frame":{"x":288,"y":82,"w":92,"h":24,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":92,"h":24},"sourceSize":{"w":92,"h":24}},"s1-option-background.png":{"frame":{"x":425,"y":0,"w":487,"h":257,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":487,"h":257},"sourceSize":{"w":487,"h":257}},"s1-radio.png":{"frame":{"x":382,"y":0,"w":20,"h":60,"idx":0},"rotated":false,"trimed":false,"spriteSourceSize":{"x":0,"y":0,"w":20,"h":60},"sourceSize":{"w":20,"h":60}}},"meta":{"app":"http://www.layabox.com","prefix":"images/","version":"1.0","image":"images.png","format":"","size":{"w":1024,"h":512},"scale":"1"}} \ No newline at end of file diff --git a/games/laya-snakes/res/atlas/images.png b/games/laya-snakes/res/atlas/images.png new file mode 100644 index 0000000..708f58e Binary files /dev/null and b/games/laya-snakes/res/atlas/images.png differ diff --git a/games/laya-snakes/res/atlas/records/comp$.rec b/games/laya-snakes/res/atlas/records/comp$.rec new file mode 100644 index 0000000..ed6f2b8 --- /dev/null +++ b/games/laya-snakes/res/atlas/records/comp$.rec @@ -0,0 +1,33 @@ +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\bg.png 1477927612 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\blank.png 1477927612 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\btn_close.png 1477927612 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\button.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\checkbox.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\clip_num.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\clip_selectBox.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\clip_tree_arrow.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\clip_tree_folder.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\combobox.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hscroll$bar.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hscroll$down.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hscroll$up.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hscroll.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hslider$bar.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\hslider.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\html.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\image.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\label.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\linkbutton.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\progress$bar.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\progress.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\radio.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\radiogroup.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\tab.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\textarea.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\textinput.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vscroll$bar.png 1477927613 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vscroll$down.png 1477927614 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vscroll$up.png 1477927614 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vscroll.png 1477927614 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vslider$bar.png 1477927614 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\comp\vslider.png 1477927614 diff --git a/games/laya-snakes/res/atlas/records/images$.rec b/games/laya-snakes/res/atlas/records/images$.rec new file mode 100644 index 0000000..dda0a05 --- /dev/null +++ b/games/laya-snakes/res/atlas/records/images$.rec @@ -0,0 +1,30 @@ +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean1.png 1477921866 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean2.png 1477921877 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean3.png 1477921886 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean4.png 1477921930 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean5.png 1477921939 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\bean6.png 1477921948 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\body1.png 1477926450 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\body2.png 1477926462 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\body3.png 1477926479 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\body4.png 1477926492 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\body5.png 1477926505 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\btn-back.png 1477923957 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\btn-restart.png 1477924095 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\control-back.png 1477924806 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\control-flash.png 1477924837 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\control-rocker.png 1477924821 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\gameover-background.png 1477924142 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\head1.png 1477926743 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\head2.png 1477926756 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\head3.png 1477926768 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\head4.png 1477926780 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\head5.png 1477926791 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\map-tile.jpg 1477921635 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\mask.png 1477923736 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-background.jpg 1477921500 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-btn1.png 1477923300 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-btn2.png 1477923312 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-input.png 1477921959 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-option-background.png 1477922146 +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\images\s1-radio.png 1477921969 diff --git a/games/laya-snakes/res/atlas/records/map$.rec b/games/laya-snakes/res/atlas/records/map$.rec new file mode 100644 index 0000000..ac2698b --- /dev/null +++ b/games/laya-snakes/res/atlas/records/map$.rec @@ -0,0 +1 @@ +E:/lanbo_project\Layabox\projects\Snakes\laya\assets\map\tile_map.png 1478006985 diff --git a/games/laya-snakes/tile_map/tile-map.jpg b/games/laya-snakes/tile_map/tile-map.jpg new file mode 100644 index 0000000..ac29282 Binary files /dev/null and b/games/laya-snakes/tile_map/tile-map.jpg differ diff --git a/games/laya-snakes/tile_map/tile_map.json b/games/laya-snakes/tile_map/tile_map.json new file mode 100644 index 0000000..2c2a8fb --- /dev/null +++ b/games/laya-snakes/tile_map/tile_map.json @@ -0,0 +1,35 @@ +{ "height":150, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "height":150, + "name":"\u5757\u5c42 1", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":300, + "x":0, + "y":0 + }], + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tileheight":10, + "tilesets":[ + { + "columns":1, + "firstgid":1, + "image":"tile-map.jpg", + "imageheight":11, + "imagewidth":11, + "margin":0, + "name":"tile-map", + "spacing":0, + "tilecount":1, + "tileheight":10, + "tilewidth":10 + }], + "tilewidth":10, + "version":1, + "width":300 +} \ No newline at end of file diff --git a/games/laya-snakes/tile_map/tile_map.png b/games/laya-snakes/tile_map/tile_map.png new file mode 100644 index 0000000..1c16442 Binary files /dev/null and b/games/laya-snakes/tile_map/tile_map.png differ diff --git a/games/laya-snakes/tile_map/tile_map.tmx b/games/laya-snakes/tile_map/tile_map.tmx new file mode 100644 index 0000000..1593b6f --- /dev/null +++ b/games/laya-snakes/tile_map/tile_map.tmx @@ -0,0 +1,45010 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/games/laya-snakes/unpack.json b/games/laya-snakes/unpack.json new file mode 100644 index 0000000..bc5dd0a --- /dev/null +++ b/games/laya-snakes/unpack.json @@ -0,0 +1 @@ +["images/mask.png","images/s1-background.jpg","map/tile_map.png"] \ No newline at end of file diff --git a/games/lifeRestart/bundle.js b/games/lifeRestart/bundle.js new file mode 100644 index 0000000..1f732aa --- /dev/null +++ b/games/lifeRestart/bundle.js @@ -0,0 +1 @@ +(()=>{var __webpack_modules__={3099:module=>{eval("module.exports = function (it) {\n if (typeof it != 'function') {\n throw TypeError(String(it) + ' is not a function');\n } return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzA5OS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYS1mdW5jdGlvbi5qcz8xYzBiIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7XG4gIGlmICh0eXBlb2YgaXQgIT0gJ2Z1bmN0aW9uJykge1xuICAgIHRocm93IFR5cGVFcnJvcihTdHJpbmcoaXQpICsgJyBpcyBub3QgYSBmdW5jdGlvbicpO1xuICB9IHJldHVybiBpdDtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3099\n")},6077:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\n\nmodule.exports = function (it) {\n if (!isObject(it) && it !== null) {\n throw TypeError(\"Can't set \" + String(it) + ' as a prototype');\n } return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjA3Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2EtcG9zc2libGUtcHJvdG90eXBlLmpzPzNiYmUiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGlzT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2lzLW9iamVjdCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkge1xuICBpZiAoIWlzT2JqZWN0KGl0KSAmJiBpdCAhPT0gbnVsbCkge1xuICAgIHRocm93IFR5cGVFcnJvcihcIkNhbid0IHNldCBcIiArIFN0cmluZyhpdCkgKyAnIGFzIGEgcHJvdG90eXBlJyk7XG4gIH0gcmV0dXJuIGl0O1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6077\n")},1223:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\nvar create = __webpack_require__(30);\nvar definePropertyModule = __webpack_require__(3070);\n\nvar UNSCOPABLES = wellKnownSymbol('unscopables');\nvar ArrayPrototype = Array.prototype;\n\n// Array.prototype[@@unscopables]\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\nif (ArrayPrototype[UNSCOPABLES] == undefined) {\n definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {\n configurable: true,\n value: create(null)\n });\n}\n\n// add a key to Array.prototype[@@unscopables]\nmodule.exports = function (key) {\n ArrayPrototype[UNSCOPABLES][key] = true;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTIyMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9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},1530:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar charAt = __webpack_require__(8710).charAt;\n\n// `AdvanceStringIndex` abstract operation\n// https://tc39.es/ecma262/#sec-advancestringindex\nmodule.exports = function (S, index, unicode) {\n return index + (unicode ? charAt(S, index).length : 1);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTUzMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYWR2YW5jZS1zdHJpbmctaW5kZXguanM/OGFhNSJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgY2hhckF0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3N0cmluZy1tdWx0aWJ5dGUnKS5jaGFyQXQ7XG5cbi8vIGBBZHZhbmNlU3RyaW5nSW5kZXhgIGFic3RyYWN0IG9wZXJhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1hZHZhbmNlc3RyaW5naW5kZXhcbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFMsIGluZGV4LCB1bmljb2RlKSB7XG4gIHJldHVybiBpbmRleCArICh1bmljb2RlID8gY2hhckF0KFMsIGluZGV4KS5sZW5ndGggOiAxKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1530\n")},5787:module=>{eval("module.exports = function (it, Constructor, name) {\n if (!(it instanceof Constructor)) {\n throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');\n } return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTc4Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYW4taW5zdGFuY2UuanM/MTlhYSJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCwgQ29uc3RydWN0b3IsIG5hbWUpIHtcbiAgaWYgKCEoaXQgaW5zdGFuY2VvZiBDb25zdHJ1Y3RvcikpIHtcbiAgICB0aHJvdyBUeXBlRXJyb3IoJ0luY29ycmVjdCAnICsgKG5hbWUgPyBuYW1lICsgJyAnIDogJycpICsgJ2ludm9jYXRpb24nKTtcbiAgfSByZXR1cm4gaXQ7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///5787\n")},9670:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\n\nmodule.exports = function (it) {\n if (!isObject(it)) {\n throw TypeError(String(it) + ' is not an object');\n } return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTY3MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2FuLW9iamVjdC5qcz84MjVhIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBpc09iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pcy1vYmplY3QnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgaWYgKCFpc09iamVjdChpdCkpIHtcbiAgICB0aHJvdyBUeXBlRXJyb3IoU3RyaW5nKGl0KSArICcgaXMgbm90IGFuIG9iamVjdCcpO1xuICB9IHJldHVybiBpdDtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///9670\n")},1285:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar toObject = __webpack_require__(7908);\nvar toAbsoluteIndex = __webpack_require__(1400);\nvar toLength = __webpack_require__(7466);\n\n// `Array.prototype.fill` method implementation\n// https://tc39.es/ecma262/#sec-array.prototype.fill\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var argumentsLength = arguments.length;\n var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);\n var end = argumentsLength > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTI4NS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYXJyYXktZmlsbC5qcz84MWQ1Il0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciB0b09iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1vYmplY3QnKTtcbnZhciB0b0Fic29sdXRlSW5kZXggPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8tYWJzb2x1dGUtaW5kZXgnKTtcbnZhciB0b0xlbmd0aCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1sZW5ndGgnKTtcblxuLy8gYEFycmF5LnByb3RvdHlwZS5maWxsYCBtZXRob2QgaW1wbGVtZW50YXRpb25cbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtYXJyYXkucHJvdG90eXBlLmZpbGxcbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gZmlsbCh2YWx1ZSAvKiAsIHN0YXJ0ID0gMCwgZW5kID0gQGxlbmd0aCAqLykge1xuICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpO1xuICB2YXIgbGVuZ3RoID0gdG9MZW5ndGgoTy5sZW5ndGgpO1xuICB2YXIgYXJndW1lbnRzTGVuZ3RoID0gYXJndW1lbnRzLmxlbmd0aDtcbiAgdmFyIGluZGV4ID0gdG9BYnNvbHV0ZUluZGV4KGFyZ3VtZW50c0xlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQsIGxlbmd0aCk7XG4gIHZhciBlbmQgPSBhcmd1bWVudHNMZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkO1xuICB2YXIgZW5kUG9zID0gZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiB0b0Fic29sdXRlSW5kZXgoZW5kLCBsZW5ndGgpO1xuICB3aGlsZSAoZW5kUG9zID4gaW5kZXgpIE9baW5kZXgrK10gPSB2YWx1ZTtcbiAgcmV0dXJuIE87XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1285\n")},8533:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $forEach = __webpack_require__(2092).forEach;\nvar arrayMethodIsStrict = __webpack_require__(9341);\n\nvar STRICT_METHOD = arrayMethodIsStrict('forEach');\n\n// `Array.prototype.forEach` method implementation\n// https://tc39.es/ecma262/#sec-array.prototype.foreach\nmodule.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {\n return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n// eslint-disable-next-line es/no-array-prototype-foreach -- safe\n} : [].forEach;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODUzMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9hcnJheS1mb3ItZWFjaC5qcz8xN2MyIl0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciAkZm9yRWFjaCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hcnJheS1pdGVyYXRpb24nKS5mb3JFYWNoO1xudmFyIGFycmF5TWV0aG9kSXNTdHJpY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYXJyYXktbWV0aG9kLWlzLXN0cmljdCcpO1xuXG52YXIgU1RSSUNUX01FVEhPRCA9IGFycmF5TWV0aG9kSXNTdHJpY3QoJ2ZvckVhY2gnKTtcblxuLy8gYEFycmF5LnByb3RvdHlwZS5mb3JFYWNoYCBtZXRob2QgaW1wbGVtZW50YXRpb25cbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtYXJyYXkucHJvdG90eXBlLmZvcmVhY2hcbm1vZHVsZS5leHBvcnRzID0gIVNUUklDVF9NRVRIT0QgPyBmdW5jdGlvbiBmb3JFYWNoKGNhbGxiYWNrZm4gLyogLCB0aGlzQXJnICovKSB7XG4gIHJldHVybiAkZm9yRWFjaCh0aGlzLCBjYWxsYmFja2ZuLCBhcmd1bWVudHMubGVuZ3RoID4gMSA/IGFyZ3VtZW50c1sxXSA6IHVuZGVmaW5lZCk7XG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tYXJyYXktcHJvdG90eXBlLWZvcmVhY2ggLS0gc2FmZVxufSA6IFtdLmZvckVhY2g7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8533\n")},8457:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar bind = __webpack_require__(9974);\nvar toObject = __webpack_require__(7908);\nvar callWithSafeIterationClosing = __webpack_require__(3411);\nvar isArrayIteratorMethod = __webpack_require__(7659);\nvar toLength = __webpack_require__(7466);\nvar createProperty = __webpack_require__(6135);\nvar getIterator = __webpack_require__(8554);\nvar getIteratorMethod = __webpack_require__(1246);\n\n// `Array.from` method implementation\n// https://tc39.es/ecma262/#sec-array.from\nmodule.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {\n var O = toObject(arrayLike);\n var C = typeof this == 'function' ? this : Array;\n var argumentsLength = arguments.length;\n var mapfn = argumentsLength > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iteratorMethod = getIteratorMethod(O);\n var index = 0;\n var length, result, step, iterator, next, value;\n if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);\n // if the target is not iterable or it's an array with the default iterator - use a simple case\n if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {\n iterator = getIterator(O, iteratorMethod);\n next = iterator.next;\n result = new C();\n for (;!(step = next.call(iterator)).done; index++) {\n value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;\n createProperty(result, index, value);\n }\n } else {\n length = toLength(O.length);\n result = new C(length);\n for (;length > index; index++) {\n value = mapping ? mapfn(O[index], index) : O[index];\n createProperty(result, index, value);\n }\n }\n result.length = index;\n return result;\n};\n//# sourceURL=[module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webpack_require__)=>{eval("var toIndexedObject = __webpack_require__(5656);\nvar toLength = __webpack_require__(7466);\nvar toAbsoluteIndex = __webpack_require__(1400);\n\n// `Array.prototype.{ indexOf, includes }` methods implementation\nvar createMethod = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIndexedObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare -- NaN check\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare -- NaN check\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) {\n if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.includes` method\n // https://tc39.es/ecma262/#sec-array.prototype.includes\n includes: createMethod(true),\n // `Array.prototype.indexOf` method\n // https://tc39.es/ecma262/#sec-array.prototype.indexof\n indexOf: createMethod(false)\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTMxOC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYXJyYXktaW5jbHVkZXMuanM/NGQ2NCJdLCJzb3VyY2VzQ29udGVudCI6Wy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y8gQXJyYXkjaW5kZXhPZiBpZ25vcmVzIGhvbGVzLCBBcnJheSNpbmNsdWRlcyAtIG5vdFxuICAgIH0gZWxzZSBmb3IgKDtsZW5ndGggPiBpbmRleDsgaW5kZXgrKykge1xuICAgICAgaWYgKChJU19JTkNMVURFUyB8fCBpbmRleCBpbiBPKSAmJiBPW2luZGV4XSA9PT0gZWwpIHJldHVybiBJU19JTkNMVURFUyB8fCBpbmRleCB8fCAwO1xuICAgIH0gcmV0dXJuICFJU19JTkNMVURFUyAmJiAtMTtcbiAgfTtcbn07XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICAvLyBgQXJyYXkucHJvdG90eXBlLmluY2x1ZGVzYCBtZXRob2RcbiAgLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1hcnJheS5wcm90b3R5cGUuaW5jbHVkZXNcbiAgaW5jbHVkZXM6IGNyZWF0ZU1ldGhvZCh0cnVlKSxcbiAgLy8gYEFycmF5LnByb3RvdHlwZS5pbmRleE9mYCBtZXRob2RcbiAgLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1hcnJheS5wcm90b3R5cGUuaW5kZXhvZlxuICBpbmRleE9mOiBjcmVhdGVNZXRob2QoZmFsc2UpXG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1318\n")},2092:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var bind = __webpack_require__(9974);\nvar IndexedObject = __webpack_require__(8361);\nvar toObject = __webpack_require__(7908);\nvar toLength = __webpack_require__(7466);\nvar arraySpeciesCreate = __webpack_require__(5417);\n\nvar push = [].push;\n\n// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var IS_FILTER_REJECT = TYPE == 7;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;\n var value, result;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3: return true; // some\n case 5: return value; // find\n case 6: return index; // findIndex\n case 2: push.call(target, value); // filter\n } else switch (TYPE) {\n case 4: return false; // every\n case 7: push.call(target, value); // filterReject\n }\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.es/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.es/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.es/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.es/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.es/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.es/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.es/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6),\n // `Array.prototype.filterReject` method\n // https://github.com/tc39/proposal-array-filtering\n filterReject: createMethod(7)\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjA5Mi5qcyIsIm1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2QoNiksXG4gIC8vIGBBcnJheS5wcm90b3R5cGUuZmlsdGVyUmVqZWN0YCBtZXRob2RcbiAgLy8gaHR0cHM6Ly9naXRodWIuY29tL3RjMzkvcHJvcG9zYWwtYXJyYXktZmlsdGVyaW5nXG4gIGZpbHRlclJlamVjdDogY3JlYXRlTWV0aG9kKDcpXG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2092\n")},1194:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar V8_VERSION = __webpack_require__(7392);\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (METHOD_NAME) {\n // We can't use this feature detection in V8 since it causes\n // deoptimization and serious performance degradation\n // https://github.com/zloirock/core-js/issues/677\n return V8_VERSION >= 51 || !fails(function () {\n var array = [];\n var constructor = array.constructor = {};\n constructor[SPECIES] = function () {\n return { foo: 1 };\n };\n return array[METHOD_NAME](Boolean).foo !== 1;\n });\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTE5NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2FycmF5LW1ldGhvZC1oYXMtc3BlY2llcy1zdXBwb3J0LmpzPzFkZGUiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGZhaWxzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2ZhaWxzJyk7XG52YXIgd2VsbEtub3duU3ltYm9sID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3dlbGwta25vd24tc3ltYm9sJyk7XG52YXIgVjhfVkVSU0lPTiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9lbmdpbmUtdjgtdmVyc2lvbicpO1xuXG52YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChNRVRIT0RfTkFNRSkge1xuICAvLyBXZSBjYW4ndCB1c2UgdGhpcyBmZWF0dXJlIGRldGVjdGlvbiBpbiBWOCBzaW5jZSBpdCBjYXVzZXNcbiAgLy8gZGVvcHRpbWl6YXRpb24gYW5kIHNlcmlvdXMgcGVyZm9ybWFuY2UgZGVncmFkYXRpb25cbiAgLy8gaHR0cHM6Ly9naXRodWIuY29tL3psb2lyb2NrL2NvcmUtanMvaXNzdWVzLzY3N1xuICByZXR1cm4gVjhfVkVSU0lPTiA+PSA1MSB8fCAhZmFpbHMoZnVuY3Rpb24gKCkge1xuICAgIHZhciBhcnJheSA9IFtdO1xuICAgIHZhciBjb25zdHJ1Y3RvciA9IGFycmF5LmNvbnN0cnVjdG9yID0ge307XG4gICAgY29uc3RydWN0b3JbU1BFQ0lFU10gPSBmdW5jdGlvbiAoKSB7XG4gICAgICByZXR1cm4geyBmb286IDEgfTtcbiAgICB9O1xuICAgIHJldHVybiBhcnJheVtNRVRIT0RfTkFNRV0oQm9vbGVhbikuZm9vICE9PSAxO1xuICB9KTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1194\n")},9341:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar fails = __webpack_require__(7293);\n\nmodule.exports = function (METHOD_NAME, argument) {\n var method = [][METHOD_NAME];\n return !!method && fails(function () {\n // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing\n method.call(null, argument || function () { throw 1; }, 1);\n });\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTM0MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2FycmF5LW1ldGhvZC1pcy1zdHJpY3QuanM/YTY0MCJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgZmFpbHMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZmFpbHMnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoTUVUSE9EX05BTUUsIGFyZ3VtZW50KSB7XG4gIHZhciBtZXRob2QgPSBbXVtNRVRIT0RfTkFNRV07XG4gIHJldHVybiAhIW1ldGhvZCAmJiBmYWlscyhmdW5jdGlvbiAoKSB7XG4gICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLXVzZWxlc3MtY2FsbCxuby10aHJvdy1saXRlcmFsIC0tIHJlcXVpcmVkIGZvciB0ZXN0aW5nXG4gICAgbWV0aG9kLmNhbGwobnVsbCwgYXJndW1lbnQgfHwgZnVuY3Rpb24gKCkgeyB0aHJvdyAxOyB9LCAxKTtcbiAgfSk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9341\n")},7475:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\nvar isArray = __webpack_require__(3157);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar SPECIES = wellKnownSymbol('species');\n\n// a part of `ArraySpeciesCreate` abstract operation\n// https://tc39.es/ecma262/#sec-arrayspeciescreate\nmodule.exports = function (originalArray) {\n var C;\n if (isArray(originalArray)) {\n C = originalArray.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n else if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return C === undefined ? Array : C;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzQ3NS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvYXJyYXktc3BlY2llcy1jb25zdHJ1Y3Rvci5qcz8wYjQyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBpc09iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pcy1vYmplY3QnKTtcbnZhciBpc0FycmF5ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2lzLWFycmF5Jyk7XG52YXIgd2VsbEtub3duU3ltYm9sID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3dlbGwta25vd24tc3ltYm9sJyk7XG5cbnZhciBTUEVDSUVTID0gd2VsbEtub3duU3ltYm9sKCdzcGVjaWVzJyk7XG5cbi8vIGEgcGFydCBvZiBgQXJyYXlTcGVjaWVzQ3JlYXRlYCBhYnN0cmFjdCBvcGVyYXRpb25cbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtYXJyYXlzcGVjaWVzY3JlYXRlXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChvcmlnaW5hbEFycmF5KSB7XG4gIHZhciBDO1xuICBpZiAoaXNBcnJheShvcmlnaW5hbEFycmF5KSkge1xuICAgIEMgPSBvcmlnaW5hbEFycmF5LmNvbnN0cnVjdG9yO1xuICAgIC8vIGNyb3NzLXJlYWxtIGZhbGxiYWNrXG4gICAgaWYgKHR5cGVvZiBDID09ICdmdW5jdGlvbicgJiYgKEMgPT09IEFycmF5IHx8IGlzQXJyYXkoQy5wcm90b3R5cGUpKSkgQyA9IHVuZGVmaW5lZDtcbiAgICBlbHNlIGlmIChpc09iamVjdChDKSkge1xuICAgICAgQyA9IENbU1BFQ0lFU107XG4gICAgICBpZiAoQyA9PT0gbnVsbCkgQyA9IHVuZGVmaW5lZDtcbiAgICB9XG4gIH0gcmV0dXJuIEMgPT09IHVuZGVmaW5lZCA/IEFycmF5IDogQztcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7475\n")},5417:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var arraySpeciesConstructor = __webpack_require__(7475);\n\n// `ArraySpeciesCreate` abstract operation\n// https://tc39.es/ecma262/#sec-arrayspeciescreate\nmodule.exports = function (originalArray, length) {\n return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTQxNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2FycmF5LXNwZWNpZXMtY3JlYXRlLmpzPzY1ZjAiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGFycmF5U3BlY2llc0NvbnN0cnVjdG9yID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FycmF5LXNwZWNpZXMtY29uc3RydWN0b3InKTtcblxuLy8gYEFycmF5U3BlY2llc0NyZWF0ZWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5c3BlY2llc2NyZWF0ZVxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob3JpZ2luYWxBcnJheSwgbGVuZ3RoKSB7XG4gIHJldHVybiBuZXcgKGFycmF5U3BlY2llc0NvbnN0cnVjdG9yKG9yaWdpbmFsQXJyYXkpKShsZW5ndGggPT09IDAgPyAwIDogbGVuZ3RoKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///5417\n")},3411:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\nvar iteratorClose = __webpack_require__(9212);\n\n// call something on iterator step with safe closing on error\nmodule.exports = function (iterator, fn, value, ENTRIES) {\n try {\n return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);\n } catch (error) {\n iteratorClose(iterator, 'throw', error);\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzQxMS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvY2FsbC13aXRoLXNhZmUtaXRlcmF0aW9uLWNsb3NpbmcuanM/OWJkZCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYW5PYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYW4tb2JqZWN0Jyk7XG52YXIgaXRlcmF0b3JDbG9zZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pdGVyYXRvci1jbG9zZScpO1xuXG4vLyBjYWxsIHNvbWV0aGluZyBvbiBpdGVyYXRvciBzdGVwIHdpdGggc2FmZSBjbG9zaW5nIG9uIGVycm9yXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdGVyYXRvciwgZm4sIHZhbHVlLCBFTlRSSUVTKSB7XG4gIHRyeSB7XG4gICAgcmV0dXJuIEVOVFJJRVMgPyBmbihhbk9iamVjdCh2YWx1ZSlbMF0sIHZhbHVlWzFdKSA6IGZuKHZhbHVlKTtcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7XG4gIH1cbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3411\n")},7072:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var called = 0;\n var iteratorWithReturn = {\n next: function () {\n return { done: !!called++ };\n },\n 'return': function () {\n SAFE_CLOSING = true;\n }\n };\n iteratorWithReturn[ITERATOR] = function () {\n return this;\n };\n // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing\n Array.from(iteratorWithReturn, function () { throw 2; });\n} catch (error) { /* empty */ }\n\nmodule.exports = function (exec, SKIP_CLOSING) {\n if (!SKIP_CLOSING && !SAFE_CLOSING) return false;\n var ITERATION_SUPPORT = false;\n try {\n var object = {};\n object[ITERATOR] = function () {\n return {\n next: function () {\n return { done: ITERATION_SUPPORT = true };\n }\n };\n };\n exec(object);\n } catch (error) { /* empty */ }\n return ITERATION_SUPPORT;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzA3Mi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0F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ZWQgZm9yIHRlc3RpbmdcbiAgQXJyYXkuZnJvbShpdGVyYXRvcldpdGhSZXR1cm4sIGZ1bmN0aW9uICgpIHsgdGhyb3cgMjsgfSk7XG59IGNhdGNoIChlcnJvcikgeyAvKiBlbXB0eSAqLyB9XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGV4ZWMsIFNLSVBfQ0xPU0lORykge1xuICBpZiAoIVNLSVBfQ0xPU0lORyAmJiAhU0FGRV9DTE9TSU5HKSByZXR1cm4gZmFsc2U7XG4gIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlO1xuICB0cnkge1xuICAgIHZhciBvYmplY3QgPSB7fTtcbiAgICBvYmplY3RbSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHJldHVybiB7IGRvbmU6IElURVJBVElPTl9TVVBQT1JUID0gdHJ1ZSB9O1xuICAgICAgICB9XG4gICAgICB9O1xuICAgIH07XG4gICAgZXhlYyhvYmplY3QpO1xuICB9IGNhdGNoIChlcnJvcikgeyAvKiBlbXB0eSAqLyB9XG4gIHJldHVybiBJVEVSQVRJT05fU1VQUE9SVDtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7072\n")},4326:module=>{eval("var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDMyNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvY2xhc3NvZi1yYXcuanM/YzZiNiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgdG9TdHJpbmcgPSB7fS50b1N0cmluZztcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgcmV0dXJuIHRvU3RyaW5nLmNhbGwoaXQpLnNsaWNlKDgsIC0xKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///4326\n")},648:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var TO_STRING_TAG_SUPPORT = __webpack_require__(1694);\nvar classofRaw = __webpack_require__(4326);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjQ4LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNB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maW5lZCcgOiBpdCA9PT0gbnVsbCA/ICdOdWxsJ1xuICAgIC8vIEBAdG9TdHJpbmdUYWcgY2FzZVxuICAgIDogdHlwZW9mICh0YWcgPSB0cnlHZXQoTyA9IE9iamVjdChpdCksIFRPX1NUUklOR19UQUcpKSA9PSAnc3RyaW5nJyA/IHRhZ1xuICAgIC8vIGJ1aWx0aW5UYWcgY2FzZVxuICAgIDogQ09SUkVDVF9BUkdVTUVOVFMgPyBjbGFzc29mUmF3KE8pXG4gICAgLy8gRVMzIGFyZ3VtZW50cyBmYWxsYmFja1xuICAgIDogKHJlc3VsdCA9IGNsYXNzb2ZSYXcoTykpID09ICdPYmplY3QnICYmIHR5cGVvZiBPLmNhbGxlZSA9PSAnZnVuY3Rpb24nID8gJ0FyZ3VtZW50cycgOiByZXN1bHQ7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///648\n")},5631:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar defineProperty = __webpack_require__(3070).f;\nvar create = __webpack_require__(30);\nvar redefineAll = __webpack_require__(2248);\nvar bind = __webpack_require__(9974);\nvar anInstance = __webpack_require__(5787);\nvar iterate = __webpack_require__(408);\nvar defineIterator = __webpack_require__(654);\nvar setSpecies = __webpack_require__(6340);\nvar DESCRIPTORS = __webpack_require__(9781);\nvar fastKey = __webpack_require__(2423).fastKey;\nvar InternalStateModule = __webpack_require__(9909);\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n index: create(null),\n first: undefined,\n last: undefined,\n size: 0\n });\n if (!DESCRIPTORS) that.size = 0;\n if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n var previous, index;\n // change existing entry\n if (entry) {\n entry.value = value;\n // create new entry\n } else {\n state.last = entry = {\n index: index = fastKey(key, true),\n key: key,\n value: value,\n previous: previous = state.last,\n next: undefined,\n removed: false\n };\n if (!state.first) state.first = entry;\n if (previous) previous.next = entry;\n if (DESCRIPTORS) state.size++;\n else that.size++;\n // add to index\n if (index !== 'F') state.index[index] = entry;\n } return that;\n };\n\n var getEntry = function (that, key) {\n var state = getInternalState(that);\n // fast case\n var index = fastKey(key);\n var entry;\n if (index !== 'F') return state.index[index];\n // frozen object case\n for (entry = state.first; entry; entry = entry.next) {\n if (entry.key == key) return entry;\n }\n };\n\n redefineAll(C.prototype, {\n // `{ Map, Set }.prototype.clear()` methods\n // https://tc39.es/ecma262/#sec-map.prototype.clear\n // https://tc39.es/ecma262/#sec-set.prototype.clear\n clear: function clear() {\n var that = this;\n var state = getInternalState(that);\n var data = state.index;\n var entry = state.first;\n while (entry) {\n entry.removed = true;\n if (entry.previous) entry.previous = entry.previous.next = undefined;\n delete data[entry.index];\n entry = entry.next;\n }\n state.first = state.last = undefined;\n if (DESCRIPTORS) state.size = 0;\n else that.size = 0;\n },\n // `{ Map, Set }.prototype.delete(key)` methods\n // https://tc39.es/ecma262/#sec-map.prototype.delete\n // https://tc39.es/ecma262/#sec-set.prototype.delete\n 'delete': function (key) {\n var that = this;\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n if (entry) {\n var next = entry.next;\n var prev = entry.previous;\n delete state.index[entry.index];\n entry.removed = true;\n if (prev) prev.next = next;\n if (next) next.previous = prev;\n if (state.first == entry) state.first = next;\n if (state.last == entry) state.last = prev;\n if (DESCRIPTORS) state.size--;\n else that.size--;\n } return !!entry;\n },\n // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods\n // https://tc39.es/ecma262/#sec-map.prototype.foreach\n // https://tc39.es/ecma262/#sec-set.prototype.foreach\n forEach: function forEach(callbackfn /* , that = undefined */) {\n var state = getInternalState(this);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var entry;\n while (entry = entry ? entry.next : state.first) {\n boundFunction(entry.value, entry.key, this);\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n }\n },\n // `{ Map, Set}.prototype.has(key)` methods\n // https://tc39.es/ecma262/#sec-map.prototype.has\n // https://tc39.es/ecma262/#sec-set.prototype.has\n has: function has(key) {\n return !!getEntry(this, key);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // `Map.prototype.get(key)` method\n // https://tc39.es/ecma262/#sec-map.prototype.get\n get: function get(key) {\n var entry = getEntry(this, key);\n return entry && entry.value;\n },\n // `Map.prototype.set(key, value)` method\n // https://tc39.es/ecma262/#sec-map.prototype.set\n set: function set(key, value) {\n return define(this, key === 0 ? 0 : key, value);\n }\n } : {\n // `Set.prototype.add(value)` method\n // https://tc39.es/ecma262/#sec-set.prototype.add\n add: function add(value) {\n return define(this, value = value === 0 ? 0 : value, value);\n }\n });\n if (DESCRIPTORS) defineProperty(C.prototype, 'size', {\n get: function () {\n return getInternalState(this).size;\n }\n });\n return C;\n },\n setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) {\n var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';\n var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);\n var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);\n // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods\n // https://tc39.es/ecma262/#sec-map.prototype.entries\n // https://tc39.es/ecma262/#sec-map.prototype.keys\n // https://tc39.es/ecma262/#sec-map.prototype.values\n // https://tc39.es/ecma262/#sec-map.prototype-@@iterator\n // https://tc39.es/ecma262/#sec-set.prototype.entries\n // https://tc39.es/ecma262/#sec-set.prototype.keys\n // https://tc39.es/ecma262/#sec-set.prototype.values\n // https://tc39.es/ecma262/#sec-set.prototype-@@iterator\n defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {\n setInternalState(this, {\n type: ITERATOR_NAME,\n target: iterated,\n state: getInternalCollectionState(iterated),\n kind: kind,\n last: undefined\n });\n }, function () {\n var state = getInternalIteratorState(this);\n var kind = state.kind;\n var entry = state.last;\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n // get next entry\n if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {\n // or finish the iteration\n state.target = undefined;\n return { value: undefined, done: true };\n }\n // return step by kind\n if (kind == 'keys') return { value: entry.key, done: false };\n if (kind == 'values') return { value: entry.value, done: false };\n return { value: [entry.key, entry.value], done: false };\n }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);\n\n // `{ Map, Set }.prototype[@@species]` accessors\n // https://tc39.es/ecma262/#sec-get-map-@@species\n // https://tc39.es/ecma262/#sec-get-set-@@species\n setSpecies(CONSTRUCTOR_NAME);\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTYzMS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUN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FyIHByZXZpb3VzLCBpbmRleDtcbiAgICAgIC8vIGNoYW5nZSBleGlzdGluZyBlbnRyeVxuICAgICAgaWYgKGVudHJ5KSB7XG4gICAgICAgIGVudHJ5LnZhbHVlID0gdmFsdWU7XG4gICAgICAvLyBjcmVhdGUgbmV3IGVudHJ5XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7XG4gICAgICAgICAgaW5kZXg6IGluZGV4ID0gZmFzdEtleShrZXksIHRydWUpLFxuICAgICAgICAgIGtleToga2V5LFxuICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICAgICAgICBwcmV2aW91czogcHJldmlvdXMgPSBzdGF0ZS5sYXN0LFxuICAgICAgICAgIG5leHQ6IHVuZGVmaW5lZCxcbiAgICAgICAgICByZW1vdmVkOiBmYWxzZVxuICAgICAgICB9O1xuICAgICAgICBpZiAoIXN0YXRlLmZpcnN0KSBzdGF0ZS5maXJzdCA9IGVudHJ5O1xuICAgICAgICBpZiAocHJldmlvdXMpIHByZXZpb3VzLm5leHQgPSBlbnRyeTtcbiAgICAgICAgaWYgKERFU0NSSVBUT1JTKSBzdGF0ZS5zaXplKys7XG4gICAgICAgIGVsc2UgdGhhdC5zaXplKys7XG4gICAgICAgIC8vIGFkZCB0byBpbmRleFxuICAgICAgICBpZiAoaW5kZXggIT09ICdGJykgc3RhdGUuaW5kZXhbaW5kZXhdID0gZW50cnk7XG4gICAgICB9IHJldHVybiB0aGF0O1xuICAgIH07XG5cbiAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7XG4gICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpO1xuICAgICAgLy8gZmFzdCBjYXNlXG4gICAgICB2YXIgaW5kZXggPSBmYXN0S2V5KGtleSk7XG4gICAgICB2YXIgZW50cnk7XG4gICAgICBpZiAoaW5kZXggIT09ICdGJykgcmV0dXJuIHN0YX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gICAgICAgLy8gb3IgZmluaXNoIHRoZSBpdGVyYXRpb25cbiAgICAgICAgc3RhdGUudGFyZ2V0ID0gdW5kZWZpbmVkO1xuICAgICAgICByZXR1cm4geyB2YWx1ZTogdW5kZWZpbmVkLCBkb25lOiB0cnVlIH07XG4gICAgICB9XG4gICAgICAvLyByZXR1cm4gc3RlcCBieSBraW5kXG4gICAgICBpZiAoa2luZCA9PSAna2V5cycpIHJldHVybiB7IHZhbHVlOiBlbnRyeS5rZXksIGRvbmU6IGZhbHNlIH07XG4gICAgICBpZiAoa2luZCA9PSAndmFsdWVzJykgcmV0dXJuIHsgdmFsdWU6IGVudHJ5LnZhbHVlLCBkb25lOiBmYWxzZSB9O1xuICAgICAgcmV0dXJuIHsgdmFsdWU6IFtlbnRyeS5rZXksIGVudHJ5LnZhbHVlXSwgZG9uZTogZmFsc2UgfTtcbiAgICB9LCBJU19NQVAgPyAnZW50cmllcycgOiAndmFsdWVzJywgIUlTX01BUCwgdHJ1ZSk7XG5cbiAgICAvLyBgeyBNYXAsIFNldCB9LnByb3RvdHlwZVtAQHNwZWNpZXNdYCBhY2Nlc3NvcnNcbiAgICAvLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWdldC1tYXAtQEBzcGVjaWVzXG4gICAgLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1nZXQtc2V0LUBAc3BlY2llc1xuICAgIHNldFNwZWNpZXMoQ09OU1RSVUNUT1JfTkFNRSk7XG4gIH1cbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///5631\n")},9320:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar redefineAll = __webpack_require__(2248);\nvar getWeakData = __webpack_require__(2423).getWeakData;\nvar anObject = __webpack_require__(9670);\nvar isObject = __webpack_require__(111);\nvar anInstance = __webpack_require__(5787);\nvar iterate = __webpack_require__(408);\nvar ArrayIterationModule = __webpack_require__(2092);\nvar $has = __webpack_require__(6656);\nvar InternalStateModule = __webpack_require__(9909);\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\nvar find = ArrayIterationModule.find;\nvar findIndex = ArrayIterationModule.findIndex;\nvar id = 0;\n\n// fallback for uncaught frozen keys\nvar uncaughtFrozenStore = function (store) {\n return store.frozen || (store.frozen = new UncaughtFrozenStore());\n};\n\nvar UncaughtFrozenStore = function () {\n this.entries = [];\n};\n\nvar findUncaughtFrozen = function (store, key) {\n return find(store.entries, function (it) {\n return it[0] === key;\n });\n};\n\nUncaughtFrozenStore.prototype = {\n get: function (key) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) return entry[1];\n },\n has: function (key) {\n return !!findUncaughtFrozen(this, key);\n },\n set: function (key, value) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) entry[1] = value;\n else this.entries.push([key, value]);\n },\n 'delete': function (key) {\n var index = findIndex(this.entries, function (it) {\n return it[0] === key;\n });\n if (~index) this.entries.splice(index, 1);\n return !!~index;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n id: id++,\n frozen: undefined\n });\n if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var data = getWeakData(anObject(key), true);\n if (data === true) uncaughtFrozenStore(state).set(key, value);\n else data[state.id] = value;\n return that;\n };\n\n redefineAll(C.prototype, {\n // `{ WeakMap, WeakSet }.prototype.delete(key)` methods\n // https://tc39.es/ecma262/#sec-weakmap.prototype.delete\n // https://tc39.es/ecma262/#sec-weakset.prototype.delete\n 'delete': function (key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state)['delete'](key);\n return data && $has(data, state.id) && delete data[state.id];\n },\n // `{ WeakMap, WeakSet }.prototype.has(key)` methods\n // https://tc39.es/ecma262/#sec-weakmap.prototype.has\n // https://tc39.es/ecma262/#sec-weakset.prototype.has\n has: function has(key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).has(key);\n return data && $has(data, state.id);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // `WeakMap.prototype.get(key)` method\n // https://tc39.es/ecma262/#sec-weakmap.prototype.get\n get: function get(key) {\n var state = getInternalState(this);\n if (isObject(key)) {\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).get(key);\n return data ? data[state.id] : undefined;\n }\n },\n // `WeakMap.prototype.set(key, value)` method\n // https://tc39.es/ecma262/#sec-weakmap.prototype.set\n set: function set(key, value) {\n return define(this, key, value);\n }\n } : {\n // `WeakSet.prototype.add(value)` method\n // https://tc39.es/ecma262/#sec-weakset.prototype.add\n add: function add(value) {\n return define(this, value, true);\n }\n });\n\n return C;\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTMyMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QU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gICB9XG4gICAgfSk7XG5cbiAgICByZXR1cm4gQztcbiAgfVxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///9320\n")},7710:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar global = __webpack_require__(7854);\nvar isForced = __webpack_require__(4705);\nvar redefine = __webpack_require__(1320);\nvar InternalMetadataModule = __webpack_require__(2423);\nvar iterate = __webpack_require__(408);\nvar anInstance = __webpack_require__(5787);\nvar isObject = __webpack_require__(111);\nvar fails = __webpack_require__(7293);\nvar checkCorrectnessOfIteration = __webpack_require__(7072);\nvar setToStringTag = __webpack_require__(8003);\nvar inheritIfRequired = __webpack_require__(9587);\n\nmodule.exports = function (CONSTRUCTOR_NAME, wrapper, common) {\n var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;\n var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;\n var ADDER = IS_MAP ? 'set' : 'add';\n var NativeConstructor = global[CONSTRUCTOR_NAME];\n var NativePrototype = NativeConstructor && NativeConstructor.prototype;\n var Constructor = NativeConstructor;\n var exported = {};\n\n var fixMethod = function (KEY) {\n var nativeMethod = NativePrototype[KEY];\n redefine(NativePrototype, KEY,\n KEY == 'add' ? function add(value) {\n nativeMethod.call(this, value === 0 ? 0 : value);\n return this;\n } : KEY == 'delete' ? function (key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'get' ? function get(key) {\n return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'has' ? function has(key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : function set(key, value) {\n nativeMethod.call(this, key === 0 ? 0 : key, value);\n return this;\n }\n );\n };\n\n var REPLACE = isForced(\n CONSTRUCTOR_NAME,\n typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {\n new NativeConstructor().entries().next();\n }))\n );\n\n if (REPLACE) {\n // create collection constructor\n Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);\n InternalMetadataModule.enable();\n } else if (isForced(CONSTRUCTOR_NAME, true)) {\n var instance = new Constructor();\n // early implementations not supports chaining\n var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;\n // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false\n var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });\n // most early implementations doesn't supports iterables, most modern - not close it correctly\n // eslint-disable-next-line no-new -- required for testing\n var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });\n // for early implementations -0 and +0 not the same\n var BUGGY_ZERO = !IS_WEAK && fails(function () {\n // V8 ~ Chromium 42- fails only with 5+ elements\n var $instance = new NativeConstructor();\n var index = 5;\n while (index--) $instance[ADDER](index, index);\n return !$instance.has(-0);\n });\n\n if (!ACCEPT_ITERABLES) {\n Constructor = wrapper(function (dummy, iterable) {\n anInstance(dummy, Constructor, CONSTRUCTOR_NAME);\n var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);\n if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });\n return that;\n });\n Constructor.prototype = NativePrototype;\n NativePrototype.constructor = Constructor;\n }\n\n if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {\n fixMethod('delete');\n fixMethod('has');\n IS_MAP && fixMethod('get');\n }\n\n if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);\n\n // weak collections should not contains .clear method\n if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;\n }\n\n exported[CONSTRUCTOR_NAME] = Constructor;\n $({ global: true, forced: Constructor != NativeConstructor }, exported);\n\n setToStringTag(Constructor, CONSTRUCTOR_NAME);\n\n if (!IS_WEAK) common.setStrong(Constructor,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m90b3R5cGUuY2xlYXIpIGRlbGV0ZSBOYXRpdmVQcm90b3R5cGUuY2xlYXI7XG4gIH1cblxuICBleHBvcnRlZFtDT05TVFJVQ1RPUl9OQU1FXSA9IENvbnN0cnVjdG9yO1xuICAkKHsgZ2xvYmFsOiB0cnVlLCBmb3JjZWQ6IENvbnN0cnVjdG9yICE9IE5hdGl2ZUNvbnN0cnVjdG9yIH0sIGV4cG9ydGVkKTtcblxuICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7XG5cbiAgaWYgKCFJU19XRUFLKSBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApO1xuXG4gIHJldHVybiBDb25zdHJ1Y3Rvcjtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7710\n")},9920:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var has = __webpack_require__(6656);\nvar ownKeys = __webpack_require__(3887);\nvar getOwnPropertyDescriptorModule = __webpack_require__(1236);\nvar definePropertyModule = __webpack_require__(3070);\n\nmodule.exports = function (target, source) {\n var keys = ownKeys(source);\n var defineProperty = definePropertyModule.f;\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTkyMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvY29weS1jb25zdHJ1Y3Rvci1wcm9wZXJ0aWVzLmpzP2U4OTMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGhhcyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9oYXMnKTtcbnZhciBvd25LZXlzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL293bi1rZXlzJyk7XG52YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yTW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1nZXQtb3duLXByb3BlcnR5LWRlc2NyaXB0b3InKTtcbnZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9vYmplY3QtZGVmaW5lLXByb3BlcnR5Jyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgc291cmNlKSB7XG4gIHZhciBrZXlzID0gb3duS2V5cyhzb3VyY2UpO1xuICB2YXIgZGVmaW5lUHJvcGVydHkgPSBkZWZpbmVQcm9wZXJ0eU1vZHVsZS5mO1xuICB2YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yTW9kdWxlLmY7XG4gIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgIHZhciBrZXkgPSBrZXlzW2ldO1xuICAgIGlmICghaGFzKHRhcmdldCwga2V5KSkgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBrZXksIGdldE93blByb3BlcnR5RGVzY3JpcHRvcihzb3VyY2UsIGtleSkpO1xuICB9XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9920\n")},4964:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\n\nvar MATCH = wellKnownSymbol('match');\n\nmodule.exports = function (METHOD_NAME) {\n var regexp = /./;\n try {\n '/./'[METHOD_NAME](regexp);\n } catch (error1) {\n try {\n regexp[MATCH] = false;\n return '/./'[METHOD_NAME](regexp);\n } catch (error2) { /* empty */ }\n } return false;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDk2NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9jb3JyZWN0LWlzLXJlZ2V4cC1sb2dpYy5qcz9hYjEzIl0sInNvdXJjZXNDb250ZW50IjpbInZhciB3ZWxsS25vd25TeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvd2VsbC1rbm93bi1zeW1ib2wnKTtcblxudmFyIE1BVENIID0gd2VsbEtub3duU3ltYm9sKCdtYXRjaCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChNRVRIT0RfTkFNRSkge1xuICB2YXIgcmVnZXhwID0gLy4vO1xuICB0cnkge1xuICAgICcvLi8nW01FVEhPRF9OQU1FXShyZWdleHApO1xuICB9IGNhdGNoIChlcnJvcjEpIHtcbiAgICB0cnkge1xuICAgICAgcmVnZXhwW01BVENIXSA9IGZhbHNlO1xuICAgICAgcmV0dXJuICcvLi8nW01FVEhPRF9OQU1FXShyZWdleHApO1xuICAgIH0gY2F0Y2ggKGVycm9yMikgeyAvKiBlbXB0eSAqLyB9XG4gIH0gcmV0dXJuIGZhbHNlO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4964\n")},8544:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\n\nmodule.exports = !fails(function () {\n function F() { /* empty */ }\n F.prototype.constructor = null;\n // eslint-disable-next-line es/no-object-getprototypeof -- required for testing\n return Object.getPrototypeOf(new F()) !== F.prototype;\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODU0NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvY29ycmVjdC1wcm90b3R5cGUtZ2V0dGVyLmpzP2UxNzciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGZhaWxzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2ZhaWxzJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHtcbiAgZnVuY3Rpb24gRigpIHsgLyogZW1wdHkgKi8gfVxuICBGLnByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IG51bGw7XG4gIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1vYmplY3QtZ2V0cHJvdG90eXBlb2YgLS0gcmVxdWlyZWQgZm9yIHRlc3RpbmdcbiAgcmV0dXJuIE9iamVjdC5nZXRQcm90b3R5cGVPZihuZXcgRigpKSAhPT0gRi5wcm90b3R5cGU7XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8544\n")},4994:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar IteratorPrototype = __webpack_require__(3383).IteratorPrototype;\nvar create = __webpack_require__(30);\nvar createPropertyDescriptor = __webpack_require__(9114);\nvar setToStringTag = __webpack_require__(8003);\nvar Iterators = __webpack_require__(7497);\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (IteratorConstructor, NAME, next) {\n var TO_STRING_TAG = NAME + ' Iterator';\n IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });\n setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);\n Iterators[TO_STRING_TAG] = returnThis;\n return IteratorConstructor;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDk5NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2NyZWF0ZS1pdGVyYXRvci1jb25zdHJ1Y3Rvci5qcz85ZWQzIl0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciBJdGVyYXRvclByb3RvdHlwZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pdGVyYXRvcnMtY29yZScpLkl0ZXJhdG9yUHJvdG90eXBlO1xudmFyIGNyZWF0ZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9vYmplY3QtY3JlYXRlJyk7XG52YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2NyZWF0ZS1wcm9wZXJ0eS1kZXNjcmlwdG9yJyk7XG52YXIgc2V0VG9TdHJpbmdUYWcgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvc2V0LXRvLXN0cmluZy10YWcnKTtcbnZhciBJdGVyYXRvcnMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXRlcmF0b3JzJyk7XG5cbnZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgeyByZXR1cm4gdGhpczsgfTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoSXRlcmF0b3JDb25zdHJ1Y3RvciwgTkFNRSwgbmV4dCkge1xuICB2YXIgVE9fU1RSSU5HX1RBRyA9IE5BTUUgKyAnIEl0ZXJhdG9yJztcbiAgSXRlcmF0b3JDb25zdHJ1Y3Rvci5wcm90b3R5cGUgPSBjcmVhdGUoSXRlcmF0b3JQcm90b3R5cGUsIHsgbmV4dDogY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDEsIG5leHQpIH0pO1xuICBzZXRUb1N0cmluZ1RhZyhJdGVyYXRvckNvbnN0cnVjdG9yLCBUT19TVFJJTkdfVEFHLCBmYWxzZSwgdHJ1ZSk7XG4gIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7XG4gIHJldHVybiBJdGVyYXRvckNvbnN0cnVjdG9yO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4994\n")},8880:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar definePropertyModule = __webpack_require__(3070);\nvar createPropertyDescriptor = __webpack_require__(9114);\n\nmodule.exports = DESCRIPTORS ? function (object, key, value) {\n return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODg4MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2NyZWF0ZS1ub24tZW51bWVyYWJsZS1wcm9wZXJ0eS5qcz85MTEyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBERVNDUklQVE9SUyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9kZXNjcmlwdG9ycycpO1xudmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1kZWZpbmUtcHJvcGVydHknKTtcbnZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY3JlYXRlLXByb3BlcnR5LWRlc2NyaXB0b3InKTtcblxubW9kdWxlLmV4cG9ydHMgPSBERVNDUklQVE9SUyA/IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHtcbiAgcmV0dXJuIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBrZXksIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigxLCB2YWx1ZSkpO1xufSA6IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHtcbiAgb2JqZWN0W2tleV0gPSB2YWx1ZTtcbiAgcmV0dXJuIG9iamVjdDtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8880\n")},9114:module=>{eval("module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTExNC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvY3JlYXRlLXByb3BlcnR5LWRlc2NyaXB0b3IuanM/NWM2YyJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChiaXRtYXAsIHZhbHVlKSB7XG4gIHJldHVybiB7XG4gICAgZW51bWVyYWJsZTogIShiaXRtYXAgJiAxKSxcbiAgICBjb25maWd1cmFibGU6ICEoYml0bWFwICYgMiksXG4gICAgd3JpdGFibGU6ICEoYml0bWFwICYgNCksXG4gICAgdmFsdWU6IHZhbHVlXG4gIH07XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9114\n")},6135:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar toPropertyKey = __webpack_require__(4948);\nvar definePropertyModule = __webpack_require__(3070);\nvar createPropertyDescriptor = __webpack_require__(9114);\n\nmodule.exports = function (object, key, value) {\n var propertyKey = toPropertyKey(key);\n if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));\n else object[propertyKey] = value;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjEzNS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2NyZWF0ZS1wcm9wZXJ0eS5qcz84NDE4Il0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciB0b1Byb3BlcnR5S2V5ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLXByb3BlcnR5LWtleScpO1xudmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1kZWZpbmUtcHJvcGVydHknKTtcbnZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY3JlYXRlLXByb3BlcnR5LWRlc2NyaXB0b3InKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7XG4gIHZhciBwcm9wZXJ0eUtleSA9IHRvUHJvcGVydHlLZXkoa2V5KTtcbiAgaWYgKHByb3BlcnR5S2V5IGluIG9iamVjdCkgZGVmaW5lUHJvcGVydHlNb2R1bGUuZihvYmplY3QsIHByb3BlcnR5S2V5LCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMCwgdmFsdWUpKTtcbiAgZWxzZSBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///6135\n")},654:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar createIteratorConstructor = __webpack_require__(4994);\nvar getPrototypeOf = __webpack_require__(9518);\nvar setPrototypeOf = __webpack_require__(7674);\nvar setToStringTag = __webpack_require__(8003);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar redefine = __webpack_require__(1320);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar IS_PURE = __webpack_require__(1913);\nvar Iterators = __webpack_require__(7497);\nvar IteratorsCore = __webpack_require__(3383);\n\nvar IteratorPrototype = IteratorsCore.IteratorPrototype;\nvar BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;\nvar ITERATOR = wellKnownSymbol('iterator');\nvar KEYS = 'keys';\nvar VALUES = 'values';\nvar ENTRIES = 'entries';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {\n createIteratorConstructor(IteratorConstructor, NAME, next);\n\n var getIterationMethod = function (KIND) {\n if (KIND === DEFAULT && defaultIterator) return defaultIterator;\n if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];\n switch (KIND) {\n case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };\n case VALUES: return function values() { return new IteratorConstructor(this, KIND); };\n case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };\n } return function () { return new IteratorConstructor(this); };\n };\n\n var TO_STRING_TAG = NAME + ' Iterator';\n var INCORRECT_VALUES_NAME = false;\n var IterablePrototype = Iterable.prototype;\n var nativeIterator = IterablePrototype[ITERATOR]\n || IterablePrototype['@@iterator']\n || DEFAULT && IterablePrototype[DEFAULT];\n var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);\n var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;\n var CurrentIteratorPrototype, methods, KEY;\n\n // fix native\n if (anyNativeIterator) {\n CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));\n if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {\n if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {\n if (setPrototypeOf) {\n setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);\n } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {\n createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);\n }\n }\n // Set @@toStringTag to native iterators\n setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);\n if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;\n }\n }\n\n // fix Array.prototype.{ values, @@iterator }.name in V8 / FF\n if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {\n INCORRECT_VALUES_NAME = true;\n defaultIterator = function values() { return nativeIterator.call(this); };\n }\n\n // define iterator\n if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {\n createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);\n }\n Iterators[NAME] = defaultIterator;\n\n // export additional methods\n if (DEFAULT) {\n methods = {\n values: getIterationMethod(VALUES),\n keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),\n entries: getIterationMethod(ENTRIES)\n };\n if (FORCED) for (KEY in methods) {\n if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {\n redefine(IterablePrototype, KEY, methods[KEY]);\n }\n } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);\n }\n\n return methods;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjU0LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0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ZvciAoS0VZIGluIG1ldGhvZHMpIHtcbiAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHtcbiAgICAgICAgcmVkZWZpbmUoSXRlcmFibGVQcm90b3R5cGUsIEtFWSwgbWV0aG9kc1tLRVldKTtcbiAgICAgIH1cbiAgICB9IGVsc2UgJCh7IHRhcmdldDogTkFNRSwgcHJvdG86IHRydWUsIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUgfSwgbWV0aG9kcyk7XG4gIH1cblxuICByZXR1cm4gbWV0aG9kcztcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///654\n")},7235:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var path = __webpack_require__(857);\nvar has = __webpack_require__(6656);\nvar wrappedWellKnownSymbolModule = __webpack_require__(6061);\nvar defineProperty = __webpack_require__(3070).f;\n\nmodule.exports = function (NAME) {\n var Symbol = path.Symbol || (path.Symbol = {});\n if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {\n value: wrappedWellKnownSymbolModule.f(NAME)\n });\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzIzNS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZGVmaW5lLXdlbGwta25vd24tc3ltYm9sLmpzPzc0NmYiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHBhdGggPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvcGF0aCcpO1xudmFyIGhhcyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9oYXMnKTtcbnZhciB3cmFwcGVkV2VsbEtub3duU3ltYm9sTW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3dlbGwta25vd24tc3ltYm9sLXdyYXBwZWQnKTtcbnZhciBkZWZpbmVQcm9wZXJ0eSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9vYmplY3QtZGVmaW5lLXByb3BlcnR5JykuZjtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoTkFNRSkge1xuICB2YXIgU3ltYm9sID0gcGF0aC5TeW1ib2wgfHwgKHBhdGguU3ltYm9sID0ge30pO1xuICBpZiAoIWhhcyhTeW1ib2wsIE5BTUUpKSBkZWZpbmVQcm9wZXJ0eShTeW1ib2wsIE5BTUUsIHtcbiAgICB2YWx1ZTogd3JhcHBlZFdlbGxLbm93blN5bWJvbE1vZHVsZS5mKE5BTUUpXG4gIH0pO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7235\n")},9781:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\n\n// Detect IE8's incomplete defineProperty implementation\nmodule.exports = !fails(function () {\n // eslint-disable-next-line es/no-object-defineproperty -- required for testing\n return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTc4MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2Rlc2NyaXB0b3JzLmpzPzgzYWIiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGZhaWxzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2ZhaWxzJyk7XG5cbi8vIERldGVjdCBJRTgncyBpbmNvbXBsZXRlIGRlZmluZVByb3BlcnR5IGltcGxlbWVudGF0aW9uXG5tb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7XG4gIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1vYmplY3QtZGVmaW5lcHJvcGVydHkgLS0gcmVxdWlyZWQgZm9yIHRlc3RpbmdcbiAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh7fSwgMSwgeyBnZXQ6IGZ1bmN0aW9uICgpIHsgcmV0dXJuIDc7IH0gfSlbMV0gIT0gNztcbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9781\n")},317:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar isObject = __webpack_require__(111);\n\nvar document = global.document;\n// typeof document.createElement is 'object' in old IE\nvar EXISTS = isObject(document) && isObject(document.createElement);\n\nmodule.exports = function (it) {\n return EXISTS ? document.createElement(it) : {};\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzE3LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZG9jdW1lbnQtY3JlYXRlLWVsZW1lbnQuanM/Y2MxMiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xudmFyIGlzT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2lzLW9iamVjdCcpO1xuXG52YXIgZG9jdW1lbnQgPSBnbG9iYWwuZG9jdW1lbnQ7XG4vLyB0eXBlb2YgZG9jdW1lbnQuY3JlYXRlRWxlbWVudCBpcyAnb2JqZWN0JyBpbiBvbGQgSUVcbnZhciBFWElTVFMgPSBpc09iamVjdChkb2N1bWVudCkgJiYgaXNPYmplY3QoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7XG4gIHJldHVybiBFWElTVFMgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KGl0KSA6IHt9O1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///317\n")},8324:module=>{eval("// iterable DOM collections\n// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods\nmodule.exports = {\n CSSRuleList: 0,\n CSSStyleDeclaration: 0,\n CSSValueList: 0,\n ClientRectList: 0,\n DOMRectList: 0,\n DOMStringList: 0,\n DOMTokenList: 1,\n DataTransferItemList: 0,\n FileList: 0,\n HTMLAllCollection: 0,\n HTMLCollection: 0,\n HTMLFormElement: 0,\n HTMLSelectElement: 0,\n MediaList: 0,\n MimeTypeArray: 0,\n NamedNodeMap: 0,\n NodeList: 1,\n PaintRequestList: 0,\n Plugin: 0,\n PluginArray: 0,\n SVGLengthList: 0,\n SVGNumberList: 0,\n SVGPathSegList: 0,\n SVGPointList: 0,\n SVGStringList: 0,\n SVGTransformList: 0,\n SourceBufferList: 0,\n StyleSheetList: 0,\n TextTrackCueList: 0,\n TextTrackList: 0,\n TouchList: 0\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODMy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G4gIE5vZGVMaXN0OiAxLFxuICBQYWludFJlcXVlc3RMaXN0OiAwLFxuICBQbHVnaW46IDAsXG4gIFBsdWdpbkFycmF5OiAwLFxuICBTVkdMZW5ndGhMaXN0OiAwLFxuICBTVkdOdW1iZXJMaXN0OiAwLFxuICBTVkdQYXRoU2VnTGlzdDogMCxcbiAgU1ZHUG9pbnRMaXN0OiAwLFxuICBTVkdTdHJpbmdMaXN0OiAwLFxuICBTVkdUcmFuc2Zvcm1MaXN0OiAwLFxuICBTb3VyY2VCdWZmZXJMaXN0OiAwLFxuICBTdHlsZVNoZWV0TGlzdDogMCxcbiAgVGV4dFRyYWNrQ3VlTGlzdDogMCxcbiAgVGV4dFRyYWNrTGlzdDogMCxcbiAgVG91Y2hMaXN0OiAwXG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///8324\n")},7871:module=>{eval("module.exports = typeof window == 'object';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzg3MS5qcyIsIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2VuZ2luZS1pcy1icm93c2VyLmpzPzYwNjkiXSwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSB0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7871\n")},1528:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var userAgent = __webpack_require__(8113);\nvar global = __webpack_require__(7854);\n\nmodule.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTUyOC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2VuZ2luZS1pcy1pb3MtcGViYmxlLmpzP2Q0YzMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHVzZXJBZ2VudCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9lbmdpbmUtdXNlci1hZ2VudCcpO1xudmFyIGdsb2JhbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nbG9iYWwnKTtcblxubW9kdWxlLmV4cG9ydHMgPSAvaXBhZHxpcGhvbmV8aXBvZC9pLnRlc3QodXNlckFnZW50KSAmJiBnbG9iYWwuUGViYmxlICE9PSB1bmRlZmluZWQ7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1528\n")},6833:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var userAgent = __webpack_require__(8113);\n\nmodule.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjgzMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9lbmdpbmUtaXMtaW9zLmpzPzFjZGMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHVzZXJBZ2VudCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9lbmdpbmUtdXNlci1hZ2VudCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IC8oPzppcGFkfGlwaG9uZXxpcG9kKS4qYXBwbGV3ZWJraXQvaS50ZXN0KHVzZXJBZ2VudCk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///6833\n")},5268:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var classof = __webpack_require__(4326);\nvar global = __webpack_require__(7854);\n\nmodule.exports = classof(global.process) == 'process';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTI2OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2VuZ2luZS1pcy1ub2RlLmpzPzYwNWQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGNsYXNzb2YgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY2xhc3NvZi1yYXcnKTtcbnZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gY2xhc3NvZihnbG9iYWwucHJvY2VzcykgPT0gJ3Byb2Nlc3MnO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///5268\n")},1036:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var userAgent = __webpack_require__(8113);\n\nmodule.exports = /web0s(?!.*chrome)/i.test(userAgent);\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTAzNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9lbmdpbmUtaXMtd2Vib3Mtd2Via2l0LmpzP2E0YjQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHVzZXJBZ2VudCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9lbmdpbmUtdXNlci1hZ2VudCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IC93ZWIwcyg/IS4qY2hyb21lKS9pLnRlc3QodXNlckFnZW50KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1036\n")},8113:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var getBuiltIn = __webpack_require__(5005);\n\nmodule.exports = getBuiltIn('navigator', 'userAgent') || '';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODExMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9lbmdpbmUtdXNlci1hZ2VudC5qcz8zNDJmIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBnZXRCdWlsdEluID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dldC1idWlsdC1pbicpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGdldEJ1aWx0SW4oJ25hdmlnYXRvcicsICd1c2VyQWdlbnQnKSB8fCAnJztcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8113\n")},7392:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar userAgent = __webpack_require__(8113);\n\nvar process = global.process;\nvar Deno = global.Deno;\nvar versions = process && process.versions || Deno && Deno.version;\nvar v8 = versions && versions.v8;\nvar match, version;\n\nif (v8) {\n match = v8.split('.');\n version = match[0] < 4 ? 1 : match[0] + match[1];\n} else if (userAgent) {\n match = userAgent.match(/Edge\\/(\\d+)/);\n if (!match || match[1] >= 74) {\n match = userAgent.match(/Chrome\\/(\\d+)/);\n if (match) version = match[1];\n }\n}\n\nmodule.exports = version && +version;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzM5Mi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9lbmdpbmUtdjgtdmVyc2lvbi5qcz8yZDAwIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG52YXIgdXNlckFnZW50ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2VuZ2luZS11c2VyLWFnZW50Jyk7XG5cbnZhciBwcm9jZXNzID0gZ2xvYmFsLnByb2Nlc3M7XG52YXIgRGVubyA9IGdsb2JhbC5EZW5vO1xudmFyIHZlcnNpb25zID0gcHJvY2VzcyAmJiBwcm9jZXNzLnZlcnNpb25zIHx8IERlbm8gJiYgRGVuby52ZXJzaW9uO1xudmFyIHY4ID0gdmVyc2lvbnMgJiYgdmVyc2lvbnMudjg7XG52YXIgbWF0Y2gsIHZlcnNpb247XG5cbmlmICh2OCkge1xuICBtYXRjaCA9IHY4LnNwbGl0KCcuJyk7XG4gIHZlcnNpb24gPSBtYXRjaFswXSA8IDQgPyAxIDogbWF0Y2hbMF0gKyBtYXRjaFsxXTtcbn0gZWxzZSBpZiAodXNlckFnZW50KSB7XG4gIG1hdGNoID0gdXNlckFnZW50Lm1hdGNoKC9FZGdlXFwvKFxcZCspLyk7XG4gIGlmICghbWF0Y2ggfHwgbWF0Y2hbMV0gPj0gNzQpIHtcbiAgICBtYXRjaCA9IHVzZXJBZ2VudC5tYXRjaCgvQ2hyb21lXFwvKFxcZCspLyk7XG4gICAgaWYgKG1hdGNoKSB2ZXJzaW9uID0gbWF0Y2hbMV07XG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSB2ZXJzaW9uICYmICt2ZXJzaW9uO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7392\n")},748:module=>{eval("// IE8- don't enum bug keys\nmodule.exports = [\n 'constructor',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'toLocaleString',\n 'toString',\n 'valueOf'\n];\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzQ4LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZW51bS1idWcta2V5cy5qcz83ODM5Il0sInNvdXJjZXNDb250ZW50IjpbIi8vIElFOC0gZG9uJ3QgZW51bSBidWcga2V5c1xubW9kdWxlLmV4cG9ydHMgPSBbXG4gICdjb25zdHJ1Y3RvcicsXG4gICdoYXNPd25Qcm9wZXJ0eScsXG4gICdpc1Byb3RvdHlwZU9mJyxcbiAgJ3Byb3BlcnR5SXNFbnVtZXJhYmxlJyxcbiAgJ3RvTG9jYWxlU3RyaW5nJyxcbiAgJ3RvU3RyaW5nJyxcbiAgJ3ZhbHVlT2YnXG5dO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///748\n")},2109:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar getOwnPropertyDescriptor = __webpack_require__(1236).f;\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar redefine = __webpack_require__(1320);\nvar setGlobal = __webpack_require__(3505);\nvar copyConstructorProperties = __webpack_require__(9920);\nvar isForced = __webpack_require__(4705);\n\n/*\n options.target - name of the target object\n options.global - target is the global object\n options.stat - export as static methods of target\n options.proto - export as prototype methods of target\n options.real - real prototype method for the `pure` version\n options.forced - export even if the native feature is available\n options.bind - bind methods to the target, required for the `pure` version\n options.wrap - wrap constructors to preventing global pollution, required for the `pure` version\n options.unsafe - use the simple assignment of property instead of delete + defineProperty\n options.sham - add a flag to not completely full polyfills\n options.enumerable - export as enumerable property\n options.noTargetGet - prevent calling a getter on target\n*/\nmodule.exports = function (options, source) {\n var TARGET = options.target;\n var GLOBAL = options.global;\n var STATIC = options.stat;\n var FORCED, target, key, targetProperty, sourceProperty, descriptor;\n if (GLOBAL) {\n target = global;\n } else if (STATIC) {\n target = global[TARGET] || setGlobal(TARGET, {});\n } else {\n target = (global[TARGET] || {}).prototype;\n }\n if (target) for (key in source) {\n sourceProperty = source[key];\n if (options.noTargetGet) {\n descriptor = getOwnPropertyDescriptor(target, key);\n targetProperty = descriptor && descriptor.value;\n } else targetProperty = target[key];\n FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);\n // contained in target\n if (!FORCED && targetProperty !== undefined) {\n if (typeof sourceProperty === typeof targetProperty) continue;\n copyConstructorProperties(sourceProperty, targetProperty);\n }\n // add a flag to not completely full polyfills\n if (options.sham || (targetProperty && targetProperty.sham)) {\n createNonEnumerableProperty(sourceProperty, 'sham', true);\n }\n // extend global\n redefine(target, key, sourceProperty, options);\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJz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0eSA9IHRhcmdldFtrZXldO1xuICAgIEZPUkNFRCA9IGlzRm9yY2VkKEdMT0JBTCA/IGtleSA6IFRBUkdFVCArIChTVEFUSUMgPyAnLicgOiAnIycpICsga2V5LCBvcHRpb25zLmZvcmNlZCk7XG4gICAgLy8gY29udGFpbmVkIGluIHRhcmdldFxuICAgIGlmICghRk9SQ0VEICYmIHRhcmdldFByb3BlcnR5ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgIGlmICh0eXBlb2Ygc291cmNlUHJvcGVydHkgPT09IHR5cGVvZiB0YXJnZXRQcm9wZXJ0eSkgY29udGludWU7XG4gICAgICBjb3B5Q29uc3RydWN0b3JQcm9wZXJ0aWVzKHNvdXJjZVByb3BlcnR5LCB0YXJnZXRQcm9wZXJ0eSk7XG4gICAgfVxuICAgIC8vIGFkZCBhIGZsYWcgdG8gbm90IGNvbXBsZXRlbHkgZnVsbCBwb2x5ZmlsbHNcbiAgICBpZiAob3B0aW9ucy5zaGFtIHx8ICh0YXJnZXRQcm9wZXJ0eSAmJiB0YXJnZXRQcm9wZXJ0eS5zaGFtKSkge1xuICAgICAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KHNvdXJjZVByb3BlcnR5LCAnc2hhbScsIHRydWUpO1xuICAgIH1cbiAgICAvLyBleHRlbmQgZ2xvYmFsXG4gICAgcmVkZWZpbmUodGFyZ2V0LCBrZXksIHNvdXJjZVByb3BlcnR5LCBvcHRpb25zKTtcbiAgfVxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2109\n")},7293:module=>{eval("module.exports = function (exec) {\n try {\n return !!exec();\n } catch (error) {\n return true;\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzI5My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2ZhaWxzLmpzP2QwMzkiXSwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYykge1xuICB0cnkge1xuICAgIHJldHVybiAhIWV4ZWMoKTtcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICByZXR1cm4gdHJ1ZTtcbiAgfVxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7293\n")},7007:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\n// TODO: Remove from `core-js@4` since it's moved to entry points\n__webpack_require__(4916);\nvar redefine = __webpack_require__(1320);\nvar regexpExec = __webpack_require__(2261);\nvar fails = __webpack_require__(7293);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar createNonEnumerableProperty = __webpack_require__(8880);\n\nvar SPECIES = wellKnownSymbol('species');\nvar RegExpPrototype = RegExp.prototype;\n\nmodule.exports = function (KEY, exec, FORCED, SHAM) {\n var SYMBOL = wellKnownSymbol(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegEp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n\n if (KEY === 'split') {\n // We can't use real regex here since it causes deoptimization\n // and serious performance degradation in V8\n // https://github.com/zloirock/core-js/issues/306\n re = {};\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n re.flags = '';\n re[SYMBOL] = /./[SYMBOL];\n }\n\n re.exec = function () { execCalled = true; return null; };\n\n re[SYMBOL]('');\n return !execCalled;\n });\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n FORCED\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {\n var $exec = regexp.exec;\n if ($exec === regexpExec || $exec === RegExpPrototype.exec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };\n }\n return { done: true, value: nativeMethod.call(str, regexp, arg2) };\n }\n return { done: false };\n });\n\n redefine(String.prototype, KEY, methods[0]);\n redefine(RegExpPrototype, SYMBOL, methods[1]);\n }\n\n if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzAwNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7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R1cm4geyBkb25lOiB0cnVlLCB2YWx1ZTogbmF0aXZlUmVnRXhwTWV0aG9kLmNhbGwocmVnZXhwLCBzdHIsIGFyZzIpIH07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHsgZG9uZTogdHJ1ZSwgdmFsdWU6IG5hdGl2ZU1ldGhvZC5jYWxsKHN0ciwgcmVnZXhwLCBhcmcyKSB9O1xuICAgICAgfVxuICAgICAgcmV0dXJuIHsgZG9uZTogZmFsc2UgfTtcbiAgICB9KTtcblxuICAgIHJlZGVmaW5lKFN0cmluZy5wcm90b3R5cGUsIEtFWSwgbWV0aG9kc1swXSk7XG4gICAgcmVkZWZpbmUoUmVnRXhwUHJvdG90eXBlLCBTWU1CT0wsIG1ldGhvZHNbMV0pO1xuICB9XG5cbiAgaWYgKFNIQU0pIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShSZWdFeHBQcm90b3R5cGVbU1lNQk9MXSwgJ3NoYW0nLCB0cnVlKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7007\n")},6790:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar isArray = __webpack_require__(3157);\nvar toLength = __webpack_require__(7466);\nvar bind = __webpack_require__(9974);\n\n// `FlattenIntoArray` abstract operation\n// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray\nvar flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {\n var targetIndex = start;\n var sourceIndex = 0;\n var mapFn = mapper ? bind(mapper, thisArg, 3) : false;\n var element;\n\n while (sourceIndex < sourceLen) {\n if (sourceIndex in source) {\n element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];\n\n if (depth > 0 && isArray(element)) {\n targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;\n } else {\n if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');\n target[targetIndex] = element;\n }\n\n targetIndex++;\n }\n sourceIndex++;\n }\n return targetIndex;\n};\n\nmodule.exports = flattenIntoArray;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjc5MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZmxhdHRlbi1pbnRvLWFycmF5LmpzP2EyYmYiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyIGlzQXJyYXkgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtYXJyYXknKTtcbnZhciB0b0xlbmd0aCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1sZW5ndGgnKTtcbnZhciBiaW5kID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Z1bmN0aW9uLWJpbmQtY29udGV4dCcpO1xuXG4vLyBgRmxhdHRlbkludG9BcnJheWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZ2l0aHViLmlvL3Byb3Bvc2FsLWZsYXRNYXAvI3NlYy1GbGF0dGVuSW50b0FycmF5XG52YXIgZmxhdHRlbkludG9BcnJheSA9IGZ1bmN0aW9uICh0YXJnZXQsIG9yaWdpbmFsLCBzb3VyY2UsIHNvdXJjZUxlbiwgc3RhcnQsIGRlcHRoLCBt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:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\n\nmodule.exports = !fails(function () {\n // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing\n return Object.isExtensible(Object.preventExtensions({}));\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjY3Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9mcmVlemluZy5qcz9iYjJmIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBmYWlscyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9mYWlscycpO1xuXG5tb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7XG4gIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1vYmplY3QtaXNleHRlbnNpYmxlLCBlcy9uby1vYmplY3QtcHJldmVudGV4dGVuc2lvbnMgLS0gcmVxdWlyZWQgZm9yIHRlc3RpbmdcbiAgcmV0dXJuIE9iamVjdC5pc0V4dGVuc2libGUoT2JqZWN0LnByZXZlbnRFeHRlbnNpb25zKHt9KSk7XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6677\n")},9974:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var aFunction = __webpack_require__(3099);\n\n// optional / simple context binding\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 0: return function () {\n return fn.call(that);\n };\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTk3NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9mdW5jdGlvbi1iaW5kLWNvbnRleHQuanM/MDM2NiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYUZ1bmN0aW9uID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2EtZnVuY3Rpb24nKTtcblxuLy8gb3B0aW9uYWwgLyBzaW1wbGUgY29udGV4dCBiaW5kaW5nXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCwgbGVuZ3RoKSB7XG4gIGFGdW5jdGlvbihmbik7XG4gIGlmICh0aGF0ID09PSB1bmRlZmluZWQpIHJldHVybiBmbjtcbiAgc3dpdGNoIChsZW5ndGgpIHtcbiAgICBjYXNlIDA6IHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICByZXR1cm4gZm4uY2FsbCh0aGF0KTtcbiAgICB9O1xuICAgIGNhc2UgMTogcmV0dXJuIGZ1bmN0aW9uIChhKSB7XG4gICAgICByZXR1cm4gZm4uY2FsbCh0aGF0LCBhKTtcbiAgICB9O1xuICAgIGNhc2UgMjogcmV0dXJuIGZ1bmN0aW9uIChhLCBiKSB7XG4gICAgICByZXR1cm4gZm4uY2FsbCh0aGF0LCBhLCBiKTtcbiAgICB9O1xuICAgIGNhc2UgMzogcmV0dXJuIGZ1bmN0aW9uIChhLCBiLCBjKSB7XG4gICAgICByZXR1cm4gZm4uY2FsbCh0aGF0LCBhLCBiLCBjKTtcbiAgICB9O1xuICB9XG4gIHJldHVybiBmdW5jdGlvbiAoLyogLi4uYXJncyAqLykge1xuICAgIHJldHVybiBmbi5hcHBseSh0aGF0LCBhcmd1bWVudHMpO1xuICB9O1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///9974\n")},5005:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\n\nvar aFunction = function (variable) {\n return typeof variable == 'function' ? variable : undefined;\n};\n\nmodule.exports = function (namespace, method) {\n return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTAwNS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9nZXQtYnVpbHQtaW4uanM/ZDA2NiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xuXG52YXIgYUZ1bmN0aW9uID0gZnVuY3Rpb24gKHZhcmlhYmxlKSB7XG4gIHJldHVybiB0eXBlb2YgdmFyaWFibGUgPT0gJ2Z1bmN0aW9uJyA/IHZhcmlhYmxlIDogdW5kZWZpbmVkO1xufTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAobmFtZXNwYWNlLCBtZXRob2QpIHtcbiAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPCAyID8gYUZ1bmN0aW9uKGdsb2JhbFtuYW1lc3BhY2VdKSA6IGdsb2JhbFtuYW1lc3BhY2VdICYmIGdsb2JhbFtuYW1lc3BhY2VdW21ldGhvZF07XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///5005\n")},1246:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var classof = __webpack_require__(648);\nvar Iterators = __webpack_require__(7497);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = function (it) {\n if (it != undefined) return it[ITERATOR]\n || it['@@iterator']\n || Iterators[classof(it)];\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTI0Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZ2V0LWl0ZXJhdG9yLW1ldGhvZC5qcz8zNWExIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBjbGFzc29mID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2NsYXNzb2YnKTtcbnZhciBJdGVyYXRvcnMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXRlcmF0b3JzJyk7XG52YXIgd2VsbEtub3duU3ltYm9sID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3dlbGwta25vd24tc3ltYm9sJyk7XG5cbnZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgaWYgKGl0ICE9IHVuZGVmaW5lZCkgcmV0dXJuIGl0W0lURVJBVE9SXVxuICAgIHx8IGl0WydAQGl0ZXJhdG9yJ11cbiAgICB8fCBJdGVyYXRvcnNbY2xhc3NvZihpdCldO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1246\n")},8554:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\nvar getIteratorMethod = __webpack_require__(1246);\n\nmodule.exports = function (it, usingIterator) {\n var iteratorMethod = arguments.length < 2 ? getIteratorMethod(it) : usingIterator;\n if (typeof iteratorMethod != 'function') {\n throw TypeError(String(it) + ' is not iterable');\n } return anObject(iteratorMethod.call(it));\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODU1NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9nZXQtaXRlcmF0b3IuanM/OWExZiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYW5PYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYW4tb2JqZWN0Jyk7XG52YXIgZ2V0SXRlcmF0b3JNZXRob2QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2V0LWl0ZXJhdG9yLW1ldGhvZCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCwgdXNpbmdJdGVyYXRvcikge1xuICB2YXIgaXRlcmF0b3JNZXRob2QgPSBhcmd1bWVudHMubGVuZ3RoIDwgMiA/IGdldEl0ZXJhdG9yTWV0aG9kKGl0KSA6IHVzaW5nSXRlcmF0b3I7XG4gIGlmICh0eXBlb2YgaXRlcmF0b3JNZXRob2QgIT0gJ2Z1bmN0aW9uJykge1xuICAgIHRocm93IFR5cGVFcnJvcihTdHJpbmcoaXQpICsgJyBpcyBub3QgaXRlcmFibGUnKTtcbiAgfSByZXR1cm4gYW5PYmplY3QoaXRlcmF0b3JNZXRob2QuY2FsbChpdCkpO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8554\n")},7854:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var check = function (it) {\n return it && it.Math == Math && it;\n};\n\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nmodule.exports =\n // eslint-disable-next-line es/no-global-this -- safe\n check(typeof globalThis == 'object' && globalThis) ||\n check(typeof window == 'object' && window) ||\n // eslint-disable-next-line no-restricted-globals -- safe\n check(typeof self == 'object' && self) ||\n check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||\n // eslint-disable-next-line no-new-func -- fallback\n (function () { return this; })() || Function('return this')();\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzg1NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvZ2xvYmFsLmpzP2RhODQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGNoZWNrID0gZnVuY3Rpb24gKGl0KSB7XG4gIHJldHVybiBpdCAmJiBpdC5NYXRoID09IE1hdGggJiYgaXQ7XG59O1xuXG4vLyBodHRwczovL2dpdGh1Yi5jb20vemxvaXJvY2svY29yZS1qcy9pc3N1ZXMvODYjaXNzdWVjb21tZW50LTExNTc1OTAyOFxubW9kdWxlLmV4cG9ydHMgPVxuICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tZ2xvYmFsLXRoaXMgLS0gc2FmZVxuICBjaGVjayh0eXBlb2YgZ2xvYmFsVGhpcyA9PSAnb2JqZWN0JyAmJiBnbG9iYWxUaGlzKSB8fFxuICBjaGVjayh0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnICYmIHdpbmRvdykgfHxcbiAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLXJlc3RyaWN0ZWQtZ2xvYmFscyAtLSBzYWZlXG4gIGNoZWNrKHR5cGVvZiBzZWxmID09ICdvYmplY3QnICYmIHNlbGYpIHx8XG4gIGNoZWNrKHR5cGVvZiBnbG9iYWwgPT0gJ29iamVjdCcgJiYgZ2xvYmFsKSB8fFxuICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tbmV3LWZ1bmMgLS0gZmFsbGJhY2tcbiAgKGZ1bmN0aW9uICgpIHsgcmV0dXJuIHRoaXM7IH0pKCkgfHwgRnVuY3Rpb24oJ3JldHVybiB0aGlzJykoKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7854\n")},6656:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var toObject = __webpack_require__(7908);\n\nvar hasOwnProperty = {}.hasOwnProperty;\n\nmodule.exports = Object.hasOwn || function hasOwn(it, key) {\n return hasOwnProperty.call(toObject(it), key);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjY1Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2hhcy5qcz81MTM1Il0sInNvdXJjZXNDb250ZW50IjpbInZhciB0b09iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1vYmplY3QnKTtcblxudmFyIGhhc093blByb3BlcnR5ID0ge30uaGFzT3duUHJvcGVydHk7XG5cbm1vZHVsZS5leHBvcnRzID0gT2JqZWN0Lmhhc093biB8fCBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkge1xuICByZXR1cm4gaGFzT3duUHJvcGVydHkuY2FsbCh0b09iamVjdChpdCksIGtleSk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///6656\n")},3501:module=>{eval("module.exports = {};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzUwMS5qcyIsIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2hpZGRlbi1rZXlzLmpzP2QwMTIiXSwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSB7fTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3501\n")},842:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\n\nmodule.exports = function (a, b) {\n var console = global.console;\n if (console && console.error) {\n arguments.length === 1 ? console.error(a) : console.error(a, b);\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODQyLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9ob3N0LXJlcG9ydC1lcnJvcnMuanM/NDRkZSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhLCBiKSB7XG4gIHZhciBjb25zb2xlID0gZ2xvYmFsLmNvbnNvbGU7XG4gIGlmIChjb25zb2xlICYmIGNvbnNvbGUuZXJyb3IpIHtcbiAgICBhcmd1bWVudHMubGVuZ3RoID09PSAxID8gY29uc29sZS5lcnJvcihhKSA6IGNvbnNvbGUuZXJyb3IoYSwgYik7XG4gIH1cbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///842\n")},490:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var getBuiltIn = __webpack_require__(5005);\n\nmodule.exports = getBuiltIn('document', 'documentElement');\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDkwLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2h0bWwuanM/MWJlNCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2V0QnVpbHRJbiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nZXQtYnVpbHQtaW4nKTtcblxubW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdkb2N1bWVudCcsICdkb2N1bWVudEVsZW1lbnQnKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///490\n")},4664:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar fails = __webpack_require__(7293);\nvar createElement = __webpack_require__(317);\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !DESCRIPTORS && !fails(function () {\n // eslint-disable-next-line es/no-object-defineproperty -- requied for testing\n return Object.defineProperty(createElement('div'), 'a', {\n get: function () { return 7; }\n }).a != 7;\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDY2NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvaWU4LWRvbS1kZWZpbmUuanM/MGNmYiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgREVTQ1JJUFRPUlMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZGVzY3JpcHRvcnMnKTtcbnZhciBmYWlscyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9mYWlscycpO1xudmFyIGNyZWF0ZUVsZW1lbnQgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZG9jdW1lbnQtY3JlYXRlLWVsZW1lbnQnKTtcblxuLy8gVGhhbmsncyBJRTggZm9yIGhpcyBmdW5ueSBkZWZpbmVQcm9wZXJ0eVxubW9kdWxlLmV4cG9ydHMgPSAhREVTQ1JJUFRPUlMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHtcbiAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVzL25vLW9iamVjdC1kZWZpbmVwcm9wZXJ0eSAtLSByZXF1aWVkIGZvciB0ZXN0aW5nXG4gIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoY3JlYXRlRWxlbWVudCgnZGl2JyksICdhJywge1xuICAgIGdldDogZnVuY3Rpb24gKCkgeyByZXR1cm4gNzsgfVxuICB9KS5hICE9IDc7XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4664\n")},8361:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar classof = __webpack_require__(4326);\n\nvar split = ''.split;\n\n// fallback for non-array-like ES3 and non-enumerable old V8 strings\nmodule.exports = fails(function () {\n // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346\n // eslint-disable-next-line no-prototype-builtins -- safe\n return !Object('z').propertyIsEnumerable(0);\n}) ? function (it) {\n return classof(it) == 'String' ? split.call(it, '') : Object(it);\n} : Object;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODM2MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2luZGV4ZWQtb2JqZWN0LmpzPzQ0YWQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGZhaWxzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2ZhaWxzJyk7XG52YXIgY2xhc3NvZiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9jbGFzc29mLXJhdycpO1xuXG52YXIgc3BsaXQgPSAnJy5zcGxpdDtcblxuLy8gZmFsbGJhY2sgZm9yIG5vbi1hcnJheS1saWtlIEVTMyBhbmQgbm9uLWVudW1lcmFibGUgb2xkIFY4IHN0cmluZ3Ncbm1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkge1xuICAvLyB0aHJvd3MgYW4gZXJyb3IgaW4gcmhpbm8sIHNlZSBodHRwczovL2dpdGh1Yi5jb20vbW96aWxsYS9yaGluby9pc3N1ZXMvMzQ2XG4gIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby1wcm90b3R5cGUtYnVpbHRpbnMgLS0gc2FmZVxuICByZXR1cm4gIU9iamVjdCgneicpLnByb3BlcnR5SXNFbnVtZXJhYmxlKDApO1xufSkgPyBmdW5jdGlvbiAoaXQpIHtcbiAgcmV0dXJuIGNsYXNzb2YoaXQpID09ICdTdHJpbmcnID8gc3BsaXQuY2FsbChpdCwgJycpIDogT2JqZWN0KGl0KTtcbn0gOiBPYmplY3Q7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8361\n")},9587:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\nvar setPrototypeOf = __webpack_require__(7674);\n\n// makes subclassing work correct for wrapped built-ins\nmodule.exports = function ($this, dummy, Wrapper) {\n var NewTarget, NewTargetPrototype;\n if (\n // it can work only with native `setPrototypeOf`\n setPrototypeOf &&\n // we haven't completely correct pre-ES6 way for getting `new.target`, so use this\n typeof (NewTarget = dummy.constructor) == 'function' &&\n NewTarget !== Wrapper &&\n isObject(NewTargetPrototype = NewTarget.prototype) &&\n NewTargetPrototype !== Wrapper.prototype\n ) setPrototypeOf($this, NewTargetPrototype);\n return $this;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTU4Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmN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cm4gJHRoaXM7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9587\n")},2788:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var store = __webpack_require__(5465);\n\nvar functionToString = Function.toString;\n\n// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper\nif (typeof store.inspectSource != 'function') {\n store.inspectSource = function (it) {\n return functionToString.call(it);\n };\n}\n\nmodule.exports = store.inspectSource;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjc4OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9pbnNwZWN0LXNvdXJjZS5qcz84OTI1Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBzdG9yZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zaGFyZWQtc3RvcmUnKTtcblxudmFyIGZ1bmN0aW9uVG9TdHJpbmcgPSBGdW5jdGlvbi50b1N0cmluZztcblxuLy8gdGhpcyBoZWxwZXIgYnJva2VuIGluIGBjb3JlLWpzQDMuNC4xLTMuNC40YCwgc28gd2UgY2FuJ3QgdXNlIGBzaGFyZWRgIGhlbHBlclxuaWYgKHR5cGVvZiBzdG9yZS5pbnNwZWN0U291cmNlICE9ICdmdW5jdGlvbicpIHtcbiAgc3RvcmUuaW5zcGVjdFNvdXJjZSA9IGZ1bmN0aW9uIChpdCkge1xuICAgIHJldHVybiBmdW5jdGlvblRvU3RyaW5nLmNhbGwoaXQpO1xuICB9O1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHN0b3JlLmluc3BlY3RTb3VyY2U7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2788\n")},2423:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var $ = __webpack_require__(2109);\nvar hiddenKeys = __webpack_require__(3501);\nvar isObject = __webpack_require__(111);\nvar has = __webpack_require__(6656);\nvar defineProperty = __webpack_require__(3070).f;\nvar getOwnPropertyNamesModule = __webpack_require__(8006);\nvar getOwnPropertyNamesExternalModule = __webpack_require__(1156);\nvar uid = __webpack_require__(9711);\nvar FREEZING = __webpack_require__(6677);\n\nvar REQUIRED = false;\nvar METADATA = uid('meta');\nvar id = 0;\n\n// eslint-disable-next-line es/no-object-isextensible -- safe\nvar isExtensible = Object.isExtensible || function () {\n return true;\n};\n\nvar setMetadata = function (it) {\n defineProperty(it, METADATA, { value: {\n objectID: 'O' + id++, // object ID\n weakData: {} // weak collections IDs\n } });\n};\n\nvar fastKey = function (it, create) {\n // return a primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMetadata(it);\n // return object ID\n } return it[METADATA].objectID;\n};\n\nvar getWeakData = function (it, create) {\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMetadata(it);\n // return the store of weak collections IDs\n } return it[METADATA].weakData;\n};\n\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZING && REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);\n return it;\n};\n\nvar enable = function () {\n meta.enable = function () { /* empty */ };\n REQUIRED = true;\n var getOwnPropertyNames = getOwnPropertyNamesModule.f;\n var splice = [].splice;\n var test = {};\n test[METADATA] = 1;\n\n // prevent exposing of metadata key\n if (getOwnPropertyNames(test).length) {\n getOwnPropertyNamesModule.f = function (it) {\n var result = getOwnPropertyNames(it);\n for (var i = 0, length = result.length; i < length; i++) {\n if (result[i] === METADATA) {\n splice.call(result, i, 1);\n break;\n }\n } return result;\n };\n\n $({ target: 'Object', stat: true, forced: true }, {\n getOwnPropertyNames: getOwnPropertyNamesExternalModule.f\n });\n }\n};\n\nvar meta = module.exports = {\n enable: enable,\n fastKey: fastKey,\n getWeakData: getWeakData,\n onFreeze: onFreeze\n};\n\nhiddenKeys[METADATA] = true;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjQyMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNB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mFtZXNNb2R1bGUuZiA9IGZ1bmN0aW9uIChpdCkge1xuICAgICAgdmFyIHJlc3VsdCA9IGdldE93blByb3BlcnR5TmFtZXMoaXQpO1xuICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbmd0aCA9IHJlc3VsdC5sZW5ndGg7IGkgPCBsZW5ndGg7IGkrKykge1xuICAgICAgICBpZiAocmVzdWx0W2ldID09PSBNRVRBREFUQSkge1xuICAgICAgICAgIHNwbGljZS5jYWxsKHJlc3VsdCwgaSwgMSk7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgIH0gcmV0dXJuIHJlc3VsdDtcbiAgICB9O1xuXG4gICAgJCh7IHRhcmdldDogJ09iamVjdCcsIHN0YXQ6IHRydWUsIGZvcmNlZDogdHJ1ZSB9LCB7XG4gICAgICBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZlxuICAgIH0pO1xuICB9XG59O1xuXG52YXIgbWV0YSA9IG1vZHVsZS5leHBvcnRzID0ge1xuICBlbmFibGU6IGVuYWJsZSxcbiAgZmFzdEtleTogZmFzdEtleSxcbiAgZ2V0V2Vha0RhdGE6IGdldFdlYWtEYXRhLFxuICBvbkZyZWV6ZTogb25GcmVlemVcbn07XG5cbmhpZGRlbktleXNbTUVUQURBVEFdID0gdHJ1ZTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2423\n")},9909:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var NATIVE_WEAK_MAP = __webpack_require__(8536);\nvar global = __webpack_require__(7854);\nvar isObject = __webpack_require__(111);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar objectHas = __webpack_require__(6656);\nvar shared = __webpack_require__(5465);\nvar sharedKey = __webpack_require__(6200);\nvar hiddenKeys = __webpack_require__(3501);\n\nvar OBJECT_ALREADY_INITIALIZED = 'Object already initialized';\nvar WeakMap = global.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n return function (it) {\n var state;\n if (!isObject(it) || (state = get(it)).type !== TYPE) {\n throw TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return state;\n };\n};\n\nif (NATIVE_WEAK_MAP || shared.state) {\n var store = shared.state || (shared.state = new WeakMap());\n var wmget = store.get;\n var wmhas = store.has;\n var wmset = store.set;\n set = function (it, metadata) {\n if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);\n metadata.facade = it;\n wmset.call(store, it, metadata);\n return metadata;\n };\n get = function (it) {\n return wmget.call(store, it) || {};\n };\n has = function (it) {\n return wmhas.call(store, it);\n };\n} else {\n var STATE = sharedKey('state');\n hiddenKeys[STATE] = true;\n set = function (it, metadata) {\n if (objectHas(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);\n metadata.facade = it;\n createNonEnumerableProperty(it, STATE, metadata);\n return metadata;\n };\n get = function (it) {\n return objectHas(it, STATE) ? it[STATE] : {};\n };\n has = function (it) {\n return objectHas(it, STATE);\n };\n}\n\nmodule.exports = {\n set: set,\n get: get,\n has: has,\n enforce: enforce,\n getterFor: getterFor\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTkwOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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G9yZSwgaXQpIHx8IHt9O1xuICB9O1xuICBoYXMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgICByZXR1cm4gd21oYXMuY2FsbChzdG9yZSwgaXQpO1xuICB9O1xufSBlbHNlIHtcbiAgdmFyIFNUQVRFID0gc2hhcmVkS2V5KCdzdGF0ZScpO1xuICBoaWRkZW5LZXlzW1NUQVRFXSA9IHRydWU7XG4gIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHtcbiAgICBpZiAob2JqZWN0SGFzKGl0LCBTVEFURSkpIHRocm93IG5ldyBUeXBlRXJyb3IoT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQpO1xuICAgIG1ldGFkYXRhLmZhY2FkZSA9IGl0O1xuICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShpdCwgU1RBVEUsIG1ldGFkYXRhKTtcbiAgICByZXR1cm4gbWV0YWRhdGE7XG4gIH07XG4gIGdldCA9IGZ1bmN0aW9uIChpdCkge1xuICAgIHJldHVybiBvYmplY3RIYXMoaXQsIFNUQVRFKSA/IGl0W1NUQVRFXSA6IHt9O1xuICB9O1xuICBoYXMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgICByZXR1cm4gb2JqZWN0SGFzKGl0LCBTVEFURSk7XG4gIH07XG59XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICBzZXQ6IHNldCxcbiAgZ2V0OiBnZXQsXG4gIGhhczogaGFzLFxuICBlbmZvcmNlOiBlbmZvcmNlLFxuICBnZXR0ZXJGb3I6IGdldHRlckZvclxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///9909\n")},7659:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\nvar Iterators = __webpack_require__(7497);\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar ArrayPrototype = Array.prototype;\n\n// check on default Array iterator\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzY1OS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2lzLWFycmF5LWl0ZXJhdG9yLW1ldGhvZC5qcz9lOTVhIl0sInNvdXJjZXNDb250ZW50IjpbInZhciB3ZWxsS25vd25TeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvd2VsbC1rbm93bi1zeW1ib2wnKTtcbnZhciBJdGVyYXRvcnMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXRlcmF0b3JzJyk7XG5cbnZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTtcbnZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTtcblxuLy8gY2hlY2sgb24gZGVmYXVsdCBBcnJheSBpdGVyYXRvclxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7659\n")},3157:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var classof = __webpack_require__(4326);\n\n// `IsArray` abstract operation\n// https://tc39.es/ecma262/#sec-isarray\n// eslint-disable-next-line es/no-array-isarray -- safe\nmodule.exports = Array.isArray || function isArray(arg) {\n return classof(arg) == 'Array';\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzE1Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvaXMtYXJyYXkuanM/ZThiNSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgY2xhc3NvZiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9jbGFzc29mLXJhdycpO1xuXG4vLyBgSXNBcnJheWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWlzYXJyYXlcbi8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1hcnJheS1pc2FycmF5IC0tIHNhZmVcbm1vZHVsZS5leHBvcnRzID0gQXJyYXkuaXNBcnJheSB8fCBmdW5jdGlvbiBpc0FycmF5KGFyZykge1xuICByZXR1cm4gY2xhc3NvZihhcmcpID09ICdBcnJheSc7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3157\n")},4705:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\n\nvar replacement = /#|\\.prototype\\./;\n\nvar isForced = function (feature, detection) {\n var value = data[normalize(feature)];\n return value == POLYFILL ? true\n : value == NATIVE ? false\n : typeof detection == 'function' ? fails(detection)\n : !!detection;\n};\n\nvar normalize = isForced.normalize = function (string) {\n return String(string).replace(replacement, '.').toLowerCase();\n};\n\nvar data = isForced.data = {};\nvar NATIVE = isForced.NATIVE = 'N';\nvar POLYFILL = isForced.POLYFILL = 'P';\n\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PSBpc0ZvcmNlZC5OQVRJVkUgPSAnTic7XG52YXIgUE9MWUZJTEwgPSBpc0ZvcmNlZC5QT0xZRklMTCA9ICdQJztcblxubW9kdWxlLmV4cG9ydHMgPSBpc0ZvcmNlZDtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4705\n")},111:module=>{eval("module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTExLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2lzLW9iamVjdC5qcz84NjFkIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7XG4gIHJldHVybiB0eXBlb2YgaXQgPT09ICdvYmplY3QnID8gaXQgIT09IG51bGwgOiB0eXBlb2YgaXQgPT09ICdmdW5jdGlvbic7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///111\n")},1913:module=>{eval("module.exports = false;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTkxMy5qcyIsIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2lzLXB1cmUuanM/YzQzMCJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IGZhbHNlO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1913\n")},7850:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\nvar classof = __webpack_require__(4326);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar MATCH = wellKnownSymbol('match');\n\n// `IsRegExp` abstract operation\n// https://tc39.es/ecma262/#sec-isregexp\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzg1MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9pcy1yZWdleHAuanM/NDRlNyJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgaXNPYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtb2JqZWN0Jyk7XG52YXIgY2xhc3NvZiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9jbGFzc29mLXJhdycpO1xudmFyIHdlbGxLbm93blN5bWJvbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbCcpO1xuXG52YXIgTUFUQ0ggPSB3ZWxsS25vd25TeW1ib2woJ21hdGNoJyk7XG5cbi8vIGBJc1JlZ0V4cGAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWlzcmVnZXhwXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkge1xuICB2YXIgaXNSZWdFeHA7XG4gIHJldHVybiBpc09iamVjdChpdCkgJiYgKChpc1JlZ0V4cCA9IGl0W01BVENIXSkgIT09IHVuZGVmaW5lZCA/ICEhaXNSZWdFeHAgOiBjbGFzc29mKGl0KSA9PSAnUmVnRXhwJyk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7850\n")},2190:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var getBuiltIn = __webpack_require__(5005);\nvar USE_SYMBOL_AS_UID = __webpack_require__(3307);\n\nmodule.exports = USE_SYMBOL_AS_UID ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n var $Symbol = getBuiltIn('Symbol');\n return typeof $Symbol == 'function' && Object(it) instanceof $Symbol;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjE5MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9pcy1zeW1ib2wuanM/ZDliNSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2V0QnVpbHRJbiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nZXQtYnVpbHQtaW4nKTtcbnZhciBVU0VfU1lNQk9MX0FTX1VJRCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy91c2Utc3ltYm9sLWFzLXVpZCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IFVTRV9TWU1CT0xfQVNfVUlEID8gZnVuY3Rpb24gKGl0KSB7XG4gIHJldHVybiB0eXBlb2YgaXQgPT0gJ3N5bWJvbCc7XG59IDogZnVuY3Rpb24gKGl0KSB7XG4gIHZhciAkU3ltYm9sID0gZ2V0QnVpbHRJbignU3ltYm9sJyk7XG4gIHJldHVybiB0eXBlb2YgJFN5bWJvbCA9PSAnZnVuY3Rpb24nICYmIE9iamVjdChpdCkgaW5zdGFuY2VvZiAkU3ltYm9sO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2190\n")},408:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\nvar isArrayIteratorMethod = __webpack_require__(7659);\nvar toLength = __webpack_require__(7466);\nvar bind = __webpack_require__(9974);\nvar getIterator = __webpack_require__(8554);\nvar getIteratorMethod = __webpack_require__(1246);\nvar iteratorClose = __webpack_require__(9212);\n\nvar Result = function (stopped, result) {\n this.stopped = stopped;\n this.result = result;\n};\n\nmodule.exports = function (iterable, unboundFunction, options) {\n var that = options && options.that;\n var AS_ENTRIES = !!(options && options.AS_ENTRIES);\n var IS_ITERATOR = !!(options && options.IS_ITERATOR);\n var INTERRUPTED = !!(options && options.INTERRUPTED);\n var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);\n var iterator, iterFn, index, length, result, next, step;\n\n var stop = function (condition) {\n if (iterator) iteratorClose(iterator, 'normal', condition);\n return new Result(true, condition);\n };\n\n var callFn = function (value) {\n if (AS_ENTRIES) {\n anObject(value);\n return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);\n } return INTERRUPTED ? fn(value, stop) : fn(value);\n };\n\n if (IS_ITERATOR) {\n iterator = iterable;\n } else {\n iterFn = getIteratorMethod(iterable);\n if (typeof iterFn != 'function') throw TypeError('Target is not iterable');\n // optimisation for array iterators\n if (isArrayIteratorMethod(iterFn)) {\n for (index = 0, length = toLength(iterable.length); length > index; index++) {\n result = callFn(iterable[index]);\n if (result && result instanceof Result) return result;\n } return new Result(false);\n }\n iterator = getIterator(iterable, iterFn);\n }\n\n next = iterator.next;\n while (!(step = next.call(iterator)).done) {\n try {\n result = callFn(step.value);\n } catch (error) {\n iteratorClose(iterator, 'throw', error);\n }\n if (typeof result == 'object' && result && result instanceof Result) return result;\n } return new Result(false);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDA4LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvaXRlcmF0ZS5qcz8yMjY2Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBhbk9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hbi1vYmplY3QnKTtcbnZhciBpc0FycmF5SXRlcmF0b3JNZXRob2QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtYXJyYXktaXRlcmF0b3ItbWV0aG9kJyk7XG52YXIgdG9MZW5ndGggPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8tbGVuZ3RoJyk7XG52YXIgYmluZCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9mdW5jdGlvbi1iaW5kLWNvbnRleHQnKTtcbnZhciBnZXRJdGVyYXRvciA9IHJlcXVpcmU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biAgbmV4dCA9IGl0ZXJhdG9yLm5leHQ7XG4gIHdoaWxlICghKHN0ZXAgPSBuZXh0LmNhbGwoaXRlcmF0b3IpKS5kb25lKSB7XG4gICAgdHJ5IHtcbiAgICAgIHJlc3VsdCA9IGNhbGxGbihzdGVwLnZhbHVlKTtcbiAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgaXRlcmF0b3JDbG9zZShpdGVyYXRvciwgJ3Rocm93JywgZXJyb3IpO1xuICAgIH1cbiAgICBpZiAodHlwZW9mIHJlc3VsdCA9PSAnb2JqZWN0JyAmJiByZXN1bHQgJiYgcmVzdWx0IGluc3RhbmNlb2YgUmVzdWx0KSByZXR1cm4gcmVzdWx0O1xuICB9IHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///408\n")},9212:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\n\nmodule.exports = function (iterator, kind, value) {\n var innerResult, innerError;\n anObject(iterator);\n try {\n innerResult = iterator['return'];\n if (innerResult === undefined) {\n if (kind === 'throw') throw value;\n return value;\n }\n innerResult = innerResult.call(iterator);\n } catch (error) {\n innerError = true;\n innerResult = error;\n }\n if (kind === 'throw') throw value;\n if (innerError) throw innerResult;\n anObject(innerResult);\n return value;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTIxMi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9pdGVyYXRvci1jbG9zZS5qcz8yYTYyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBhbk9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hbi1vYmplY3QnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXRlcmF0b3IsIGtpbmQsIHZhbHVlKSB7XG4gIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjtcbiAgYW5PYmplY3QoaXRlcmF0b3IpO1xuICB0cnkge1xuICAgIGlubmVyUmVzdWx0ID0gaXRlcmF0b3JbJ3JldHVybiddO1xuICAgIGlmIChpbm5lclJlc3VsdCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICBpZiAoa2luZCA9PT0gJ3Rocm93JykgdGhyb3cgdmFsdWU7XG4gICAgICByZXR1cm4gdmFsdWU7XG4gICAgfVxuICAgIGlubmVyUmVzdWx0ID0gaW5uZXJSZXN1bHQuY2FsbChpdGVyYXRvcik7XG4gIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgaW5uZXJFcnJvciA9IHRydWU7XG4gICAgaW5uZXJSZXN1bHQgPSBlcnJvcjtcbiAgfVxuICBpZiAoa2luZCA9PT0gJ3Rocm93JykgdGhyb3cgdmFsdWU7XG4gIGlmIChpbm5lckVycm9yKSB0aHJvdyBpbm5lclJlc3VsdDtcbiAgYW5PYmplY3QoaW5uZXJSZXN1bHQpO1xuICByZXR1cm4gdmFsdWU7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9212\n")},3383:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar fails = __webpack_require__(7293);\nvar getPrototypeOf = __webpack_require__(9518);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar has = __webpack_require__(6656);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar IS_PURE = __webpack_require__(1913);\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar BUGGY_SAFARI_ITERATORS = false;\n\nvar returnThis = function () { return this; };\n\n// `%IteratorPrototype%` object\n// https://tc39.es/ecma262/#sec-%iteratorprototype%-object\nvar IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;\n\n/* eslint-disable es/no-array-prototype-keys -- safe */\nif ([].keys) {\n arrayIterator = [].keys();\n // Safari 8 has buggy iterators w/o `next`\n if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;\n else {\n PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));\n if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;\n }\n}\n\nvar NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {\n var test = {};\n // FF44- legacy iterators case\n return IteratorPrototype[ITERATOR].call(test) !== test;\n});\n\nif (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};\n\n// `%IteratorPrototype%[@@iterator]()` method\n// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator\nif ((!IS_PURE || NEW_ITERATOR_PROTOTYPE) && !has(IteratorPrototype, ITERATOR)) {\n createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);\n}\n\nmodule.exports = {\n IteratorPrototype: IteratorPrototype,\n BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzM4My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0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CVJdGVyYXRvclByb3RvdHlwZSVbQEBpdGVyYXRvcl0oKWAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLSVpdGVyYXRvcnByb3RvdHlwZSUtQEBpdGVyYXRvclxuaWYgKCghSVNfUFVSRSB8fCBORVdfSVRFUkFUT1JfUFJPVE9UWVBFKSAmJiAhaGFzKEl0ZXJhdG9yUHJvdG90eXBlLCBJVEVSQVRPUikpIHtcbiAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KEl0ZXJhdG9yUHJvdG90eXBlLCBJVEVSQVRPUiwgcmV0dXJuVGhpcyk7XG59XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICBJdGVyYXRvclByb3RvdHlwZTogSXRlcmF0b3JQcm90b3R5cGUsXG4gIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlNcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3383\n")},7497:module=>{eval("module.exports = {};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzQ5Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL2l0ZXJhdG9ycy5qcz8zZjhjIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0ge307XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7497\n")},5948:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar getOwnPropertyDescriptor = __webpack_require__(1236).f;\nvar macrotask = __webpack_require__(261).set;\nvar IS_IOS = __webpack_require__(6833);\nvar IS_IOS_PEBBLE = __webpack_require__(1528);\nvar IS_WEBOS_WEBKIT = __webpack_require__(1036);\nvar IS_NODE = __webpack_require__(5268);\n\nvar MutationObserver = global.MutationObserver || global.WebKitMutationObserver;\nvar document = global.document;\nvar process = global.process;\nvar Promise = global.Promise;\n// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`\nvar queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');\nvar queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;\n\nvar flush, head, last, notify, toggle, node, promise, then;\n\n// modern engines have queueMicrotask method\nif (!queueMicrotask) {\n flush = function () {\n var parent, fn;\n if (IS_NODE && (parent = process.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (error) {\n if (head) notify();\n else last = undefined;\n throw error;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339\n // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898\n if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {\n toggle = true;\n node = document.createTextNode('');\n new MutationObserver(flush).observe(node, { characterData: true });\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {\n // Promise.resolve without an argument throws an error in LG WebOS 2\n promise = Promise.resolve(undefined);\n // workaround of WebKit ~ iOS Safari 10.1 bug\n promise.constructor = Promise;\n then = promise.then;\n notify = function () {\n then.call(promise, flush);\n };\n // Node.js without promises\n } else if (IS_NODE) {\n notify = function () {\n process.nextTick(flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(global, flush);\n };\n }\n}\n\nmodule.exports = queueMicrotask || function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTk0OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvbWljcm90YXNrLmpzP2I1NzUiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGdsb2JhbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nbG9iYWwnKTtcbnZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWdldC1vd24tcHJv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XRUaW1lb3V0XG4gIH0gZWxzZSB7XG4gICAgbm90aWZ5ID0gZnVuY3Rpb24gKCkge1xuICAgICAgLy8gc3RyYW5nZSBJRSArIHdlYnBhY2sgZGV2IHNlcnZlciBidWcgLSB1c2UgLmNhbGwoZ2xvYmFsKVxuICAgICAgbWFjcm90YXNrLmNhbGwoZ2xvYmFsLCBmbHVzaCk7XG4gICAgfTtcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHF1ZXVlTWljcm90YXNrIHx8IGZ1bmN0aW9uIChmbikge1xuICB2YXIgdGFzayA9IHsgZm46IGZuLCBuZXh0OiB1bmRlZmluZWQgfTtcbiAgaWYgKGxhc3QpIGxhc3QubmV4dCA9IHRhc2s7XG4gIGlmICghaGVhZCkge1xuICAgIGhlYWQgPSB0YXNrO1xuICAgIG5vdGlmeSgpO1xuICB9IGxhc3QgPSB0YXNrO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5948\n")},3366:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\n\nmodule.exports = global.Promise;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzM2Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9uYXRpdmUtcHJvbWlzZS1jb25zdHJ1Y3Rvci5qcz9mZWE5Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZ2xvYmFsLlByb21pc2U7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3366\n")},133:(module,__unused_webpack_exports,__webpack_require__)=>{eval("/* eslint-disable es/no-symbol -- required for testing */\nvar V8_VERSION = __webpack_require__(7392);\nvar fails = __webpack_require__(7293);\n\n// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing\nmodule.exports = !!Object.getOwnPropertySymbols && !fails(function () {\n var symbol = Symbol();\n // Chrome 38 Symbol has incorrect toString conversion\n // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances\n return !String(symbol) || !(Object(symbol) instanceof Symbol) ||\n // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances\n !Symbol.sham && V8_VERSION && V8_VERSION < 41;\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTMzLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvbmF0aXZlLXN5bWJvbC5qcz80OTMwIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIGVzL25vLXN5bWJvbCAtLSByZXF1aXJlZCBmb3IgdGVzdGluZyAqL1xudmFyIFY4X1ZFUlNJT04gPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZW5naW5lLXY4LXZlcnNpb24nKTtcbnZhciBmYWlscyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9mYWlscycpO1xuXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWdldG93bnByb3BlcnR5c3ltYm9scyAtLSByZXF1aXJlZCBmb3IgdGVzdGluZ1xubW9kdWxlLmV4cG9ydHMgPSAhIU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHtcbiAgdmFyIHN5bWJvbCA9IFN5bWJvbCgpO1xuICAvLyBDaHJvbWUgMzggU3ltYm9sIGhhcyBpbmNvcnJlY3QgdG9TdHJpbmcgY29udmVyc2lvblxuICAvLyBgZ2V0LW93bi1wcm9wZXJ0eS1zeW1ib2xzYCBwb2x5ZmlsbCBzeW1ib2xzIGNvbnZlcnRlZCB0byBvYmplY3QgYXJlIG5vdCBTeW1ib2wgaW5zdGFuY2VzXG4gIHJldHVybiAhU3RyaW5nKHN5bWJvbCkgfHwgIShPYmplY3Qoc3ltYm9sKSBpbnN0YW5jZW9mIFN5bWJvbCkgfHxcbiAgICAvLyBDaHJvbWUgMzgtNDAgc3ltYm9scyBhcmUgbm90IGluaGVyaXRlZCBmcm9tIERPTSBjb2xsZWN0aW9ucyBwcm90b3R5cGVzIHRvIGluc3RhbmNlc1xuICAgICFTeW1ib2wuc2hhbSAmJiBWOF9WRVJTSU9OICYmIFY4X1ZFUlNJT04gPCA0MTtcbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///133\n")},8536:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar inspectSource = __webpack_require__(2788);\n\nvar WeakMap = global.WeakMap;\n\nmodule.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODUzNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9uYXRpdmUtd2Vhay1tYXAuanM/N2Y5YSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xudmFyIGluc3BlY3RTb3VyY2UgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaW5zcGVjdC1zb3VyY2UnKTtcblxudmFyIFdlYWtNYXAgPSBnbG9iYWwuV2Vha01hcDtcblxubW9kdWxlLmV4cG9ydHMgPSB0eXBlb2YgV2Vha01hcCA9PT0gJ2Z1bmN0aW9uJyAmJiAvbmF0aXZlIGNvZGUvLnRlc3QoaW5zcGVjdFNvdXJjZShXZWFrTWFwKSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8536\n")},8523:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar aFunction = __webpack_require__(3099);\n\nvar PromiseCapability = function (C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = aFunction(resolve);\n this.reject = aFunction(reject);\n};\n\n// `NewPromiseCapability` abstract operation\n// https://tc39.es/ecma262/#sec-newpromisecapability\nmodule.exports.f = function (C) {\n return new PromiseCapability(C);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODUyMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL25ldy1wcm9taXNlLWNhcGFiaWxpdHkuanM/ZjA2OSJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgYUZ1bmN0aW9uID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2EtZnVuY3Rpb24nKTtcblxudmFyIFByb21pc2VDYXBhYmlsaXR5ID0gZnVuY3Rpb24gKEMpIHtcbiAgdmFyIHJlc29sdmUsIHJlamVjdDtcbiAgdGhpcy5wcm9taXNlID0gbmV3IEMoZnVuY3Rpb24gKCQkcmVzb2x2ZSwgJCRyZWplY3QpIHtcbiAgICBpZiAocmVzb2x2ZSAhPT0gdW5kZWZpbmVkIHx8IHJlamVjdCAhPT0gdW5kZWZpbmVkKSB0aHJvdyBUeXBlRXJyb3IoJ0JhZCBQcm9taXNlIGNvbnN0cnVjdG9yJyk7XG4gICAgcmVzb2x2ZSA9ICQkcmVzb2x2ZTtcbiAgICByZWplY3QgPSAkJHJlamVjdDtcbiAgfSk7XG4gIHRoaXMucmVzb2x2ZSA9IGFGdW5jdGlvbihyZXNvbHZlKTtcbiAgdGhpcy5yZWplY3QgPSBhRnVuY3Rpb24ocmVqZWN0KTtcbn07XG5cbi8vIGBOZXdQcm9taXNlQ2FwYWJpbGl0eWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLW5ld3Byb21pc2VjYXBhYmlsaXR5XG5tb2R1bGUuZXhwb3J0cy5mID0gZnVuY3Rpb24gKEMpIHtcbiAgcmV0dXJuIG5ldyBQcm9taXNlQ2FwYWJpbGl0eShDKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8523\n")},3929:(module,__unused_webpack_exports,__webpack_require__)=>{eval('var isRegExp = __webpack_require__(7850);\n\nmodule.exports = function (it) {\n if (isRegExp(it)) {\n throw TypeError("The method doesn\'t accept regular expressions");\n } return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzkyOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL25vdC1hLXJlZ2V4cC5qcz81YTM0Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBpc1JlZ0V4cCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pcy1yZWdleHAnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgaWYgKGlzUmVnRXhwKGl0KSkge1xuICAgIHRocm93IFR5cGVFcnJvcihcIlRoZSBtZXRob2QgZG9lc24ndCBhY2NlcHQgcmVndWxhciBleHByZXNzaW9uc1wiKTtcbiAgfSByZXR1cm4gaXQ7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3929\n')},3009:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar toString = __webpack_require__(1340);\nvar trim = __webpack_require__(3111).trim;\nvar whitespaces = __webpack_require__(1361);\n\nvar $parseInt = global.parseInt;\nvar hex = /^[+-]?0[Xx]/;\nvar FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22;\n\n// `parseInt` method\n// https://tc39.es/ecma262/#sec-parseint-string-radix\nmodule.exports = FORCED ? function parseInt(string, radix) {\n var S = trim(toString(string));\n return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));\n} : $parseInt;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzAwOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNB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VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3009\n")},30:(module,__unused_webpack_exports,__webpack_require__)=>{eval("/* global ActiveXObject -- old IE, WSH */\nvar anObject = __webpack_require__(9670);\nvar defineProperties = __webpack_require__(6048);\nvar enumBugKeys = __webpack_require__(748);\nvar hiddenKeys = __webpack_require__(3501);\nvar html = __webpack_require__(490);\nvar documentCreateElement = __webpack_require__(317);\nvar sharedKey = __webpack_require__(6200);\n\nvar GT = '>';\nvar LT = '<';\nvar PROTOTYPE = 'prototype';\nvar SCRIPT = 'script';\nvar IE_PROTO = sharedKey('IE_PROTO');\n\nvar EmptyConstructor = function () { /* empty */ };\n\nvar scriptTag = function (content) {\n return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;\n};\n\n// Create object with fake `null` prototype: use ActiveX Object with cleared prototype\nvar NullProtoObjectViaActiveX = function (activeXDocument) {\n activeXDocument.write(scriptTag(''));\n activeXDocument.close();\n var temp = activeXDocument.parentWindow.Object;\n activeXDocument = null; // avoid memory leak\n return temp;\n};\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar NullProtoObjectViaIFrame = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = documentCreateElement('iframe');\n var JS = 'java' + SCRIPT + ':';\n var iframeDocument;\n iframe.style.display = 'none';\n html.appendChild(iframe);\n // https://github.com/zloirock/core-js/issues/475\n iframe.src = String(JS);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(scriptTag('document.F=Object'));\n iframeDocument.close();\n return iframeDocument.F;\n};\n\n// Check for document.domain and active x support\n// No need to use active x approach when document.domain is not set\n// see https://github.com/es-shims/es5-shim/issues/150\n// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346\n// avoid IE GC bug\nvar activeXDocument;\nvar NullProtoObject = function () {\n try {\n activeXDocument = new ActiveXObject('htmlfile');\n } catch (error) { /* ignore */ }\n NullProtoObject = typeof document != 'undefined'\n ? document.domain && activeXDocument\n ? NullProtoObjectViaActiveX(activeXDocument) // old IE\n : NullProtoObjectViaIFrame()\n : NullProtoObjectViaActiveX(activeXDocument); // WSH\n var length = enumBugKeys.length;\n while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];\n return NullProtoObject();\n};\n\nhiddenKeys[IE_PROTO] = true;\n\n// `Object.create` method\n// https://tc39.es/ecma262/#sec-object.create\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n EmptyConstructor[PROTOTYPE] = anObject(O);\n result = new EmptyConstructor();\n EmptyConstructor[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = NullProtoObject();\n return Properties === undefined ? result : defineProperties(result, Properties);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzAuanMiLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtB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ack-internal:///30\n")},6048:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar definePropertyModule = __webpack_require__(3070);\nvar anObject = __webpack_require__(9670);\nvar objectKeys = __webpack_require__(1956);\n\n// `Object.defineProperties` method\n// https://tc39.es/ecma262/#sec-object.defineproperties\n// eslint-disable-next-line es/no-object-defineproperties -- safe\nmodule.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = objectKeys(Properties);\n var length = keys.length;\n var index = 0;\n var key;\n while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);\n return O;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjA0OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LWRlZmluZS1wcm9wZXJ0aWVzLmpzPzM3ZTgiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIERFU0NSSVBUT1JTID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Rlc2NyaXB0b3JzJyk7XG52YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWRlZmluZS1wcm9wZXJ0eScpO1xudmFyIGFuT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FuLW9iamVjdCcpO1xudmFyIG9iamVjdEtleXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWtleXMnKTtcblxuLy8gYE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzYCBtZXRob2Rcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtb2JqZWN0LmRlZmluZXByb3BlcnRpZXNcbi8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1vYmplY3QtZGVmaW5lcHJvcGVydGllcyAtLSBzYWZlXG5tb2R1bGUuZXhwb3J0cyA9IERFU0NSSVBUT1JTID8gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMgOiBmdW5jdGlvbiBkZWZpbmVQcm9wZXJ0aWVzKE8sIFByb3BlcnRpZXMpIHtcbiAgYW5PYmplY3QoTyk7XG4gIHZhciBrZXlzID0gb2JqZWN0S2V5cyhQcm9wZXJ0aWVzKTtcbiAgdmFyIGxlbmd0aCA9IGtleXMubGVuZ3RoO1xuICB2YXIgaW5kZXggPSAwO1xuICB2YXIga2V5O1xuICB3aGlsZSAobGVuZ3RoID4gaW5kZXgpIGRlZmluZVByb3BlcnR5TW9kdWxlLmYoTywga2V5ID0ga2V5c1tpbmRleCsrXSwgUHJvcGVydGllc1trZXldKTtcbiAgcmV0dXJuIE87XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///6048\n")},3070:(__unused_webpack_module,exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar IE8_DOM_DEFINE = __webpack_require__(4664);\nvar anObject = __webpack_require__(9670);\nvar toPropertyKey = __webpack_require__(4948);\n\n// eslint-disable-next-line es/no-object-defineproperty -- safe\nvar $defineProperty = Object.defineProperty;\n\n// `Object.defineProperty` method\n// https://tc39.es/ecma262/#sec-object.defineproperty\nexports.f = DESCRIPTORS ? $defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPropertyKey(P);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return $defineProperty(O, P, Attributes);\n } catch (error) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzA3MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9vYmplY3QtZGVmaW5lLXByb3BlcnR5LmpzPzliZjIiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIERFU0NSSVBUT1JTID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Rlc2NyaXB0b3JzJyk7XG52YXIgSUU4X0RPTV9ERUZJTkUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaWU4LWRvbS1kZWZpbmUnKTtcbnZhciBhbk9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hbi1vYmplY3QnKTtcbnZhciB0b1Byb3BlcnR5S2V5ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLXByb3BlcnR5LWtleScpO1xuXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWRlZmluZXByb3BlcnR5IC0tIHNhZmVcbnZhciAkZGVmaW5lUHJvcGVydHkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7XG5cbi8vIGBPYmplY3QuZGVmaW5lUHJvcGVydHlgIG1ldGhvZFxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1vYmplY3QuZGVmaW5lcHJvcGVydHlcbmV4cG9ydHMuZiA9IERFU0NSSVBUT1JTID8gJGRlZmluZVByb3BlcnR5IDogZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykge1xuICBhbk9iamVjdChPKTtcbiAgUCA9IHRvUHJvcGVydHlLZXkoUCk7XG4gIGFuT2JqZWN0KEF0dHJpYnV0ZXMpO1xuICBpZiAoSUU4X0RPTV9ERUZJTkUpIHRyeSB7XG4gICAgcmV0dXJuICRkZWZpbmVQcm9wZXJ0eShPLCBQLCBBdHRyaWJ1dGVzKTtcbiAgfSBjYXRjaCAoZXJyb3IpIHsgLyogZW1wdHkgKi8gfVxuICBpZiAoJ2dldCcgaW4gQXR0cmlidXRlcyB8fCAnc2V0JyBpbiBBdHRyaWJ1dGVzKSB0aHJvdyBUeXBlRXJyb3IoJ0FjY2Vzc29ycyBub3Qgc3VwcG9ydGVkJyk7XG4gIGlmICgndmFsdWUnIGluIEF0dHJpYnV0ZXMpIE9bUF0gPSBBdHRyaWJ1dGVzLnZhbHVlO1xuICByZXR1cm4gTztcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3070\n")},1236:(__unused_webpack_module,exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar propertyIsEnumerableModule = __webpack_require__(5296);\nvar createPropertyDescriptor = __webpack_require__(9114);\nvar toIndexedObject = __webpack_require__(5656);\nvar toPropertyKey = __webpack_require__(4948);\nvar has = __webpack_require__(6656);\nvar IE8_DOM_DEFINE = __webpack_require__(4664);\n\n// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe\nvar $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor\nexports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {\n O = toIndexedObject(O);\n P = toPropertyKey(P);\n if (IE8_DOM_DEFINE) try {\n return $getOwnPropertyDescriptor(O, P);\n } catch (error) { /* empty */ }\n if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTIzNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9vYmplY3QtZ2V0LW93bi1wcm9wZXJ0eS1kZXNjcmlwdG9yLmpzPzA2Y2YiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIERFU0NSSVBUT1JTID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Rlc2NyaXB0b3JzJyk7XG52YXIgcHJvcGVydHlJc0VudW1lcmFibGVNb2R1bGUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LXByb3BlcnR5LWlzLWVudW1lcmFibGUnKTtcbnZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY3JlYXRlLXByb3BlcnR5LWRlc2NyaXB0b3InKTtcbnZhciB0b0luZGV4ZWRPYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8taW5kZXhlZC1vYmplY3QnKTtcbnZhciB0b1Byb3BlcnR5S2V5ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLXByb3BlcnR5LWtleScpO1xudmFyIGhhcyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9oYXMnKTtcbnZhciBJRThfRE9NX0RFRklORSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9pZTgtZG9tLWRlZmluZScpO1xuXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWdldG93bnByb3BlcnR5ZGVzY3JpcHRvciAtLSBzYWZlXG52YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7XG5cbi8vIGBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yYCBtZXRob2Rcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtb2JqZWN0LmdldG93bnByb3BlcnR5ZGVzY3JpcHRvclxuZXhwb3J0cy5mID0gREVTQ1JJUFRPUlMgPyAkZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yIDogZnVuY3Rpb24gZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE8sIFApIHtcbiAgTyA9IHRvSW5kZXhlZE9iamVjdChPKTtcbiAgUCA9IHRvUHJvcGVydHlLZXkoUCk7XG4gIGlmIChJRThfRE9NX0RFRklORSkgdHJ5IHtcbiAgICByZXR1cm4gJGdldE93blByb3BlcnR5RGVzY3JpcHRvcihPLCBQKTtcbiAgfSBjYXRjaCAoZXJyb3IpIHsgLyogZW1wdHkgKi8gfVxuICBpZiAoaGFzKE8sIFApKSByZXR1cm4gY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKCFwcm9wZXJ0eUlzRW51bWVyYWJsZU1vZHVsZS5mLmNhbGwoTywgUCksIE9bUF0pO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1236\n")},1156:(module,__unused_webpack_exports,__webpack_require__)=>{eval("/* eslint-disable es/no-object-getownpropertynames -- safe */\nvar toIndexedObject = __webpack_require__(5656);\nvar $getOwnPropertyNames = __webpack_require__(8006).f;\n\nvar toString = {}.toString;\n\nvar windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames\n ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function (it) {\n try {\n return $getOwnPropertyNames(it);\n } catch (error) {\n return windowNames.slice();\n }\n};\n\n// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nmodule.exports.f = function getOwnPropertyNames(it) {\n return windowNames && toString.call(it) == '[object Window]'\n ? getWindowNames(it)\n : $getOwnPropertyNames(toIndexedObject(it));\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTE1Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LWdldC1vd24tcHJvcGVydHktbmFtZXMtZXh0ZXJuYWwuanM/MDU3ZiJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBlcy9uby1vYmplY3QtZ2V0b3ducHJvcGVydHluYW1lcyAtLSBzYWZlICovXG52YXIgdG9JbmRleGVkT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLWluZGV4ZWQtb2JqZWN0Jyk7XG52YXIgJGdldE93blByb3BlcnR5TmFtZXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWdldC1vd24tcHJvcGVydHktbmFtZXMnKS5mO1xuXG52YXIgdG9TdHJpbmcgPSB7fS50b1N0cmluZztcblxudmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXNcbiAgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107XG5cbnZhciBnZXRXaW5kb3dOYW1lcyA9IGZ1bmN0aW9uIChpdCkge1xuICB0cnkge1xuICAgIHJldHVybiAkZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7XG4gIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgcmV0dXJuIHdpbmRvd05hbWVzLnNsaWNlKCk7XG4gIH1cbn07XG5cbi8vIGZhbGxiYWNrIGZvciBJRTExIGJ1Z2d5IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHdpdGggaWZyYW1lIGFuZCB3aW5kb3dcbm1vZHVsZS5leHBvcnRzLmYgPSBmdW5jdGlvbiBnZXRPd25Qcm9wZXJ0eU5hbWVzKGl0KSB7XG4gIHJldHVybiB3aW5kb3dOYW1lcyAmJiB0b1N0cmluZy5jYWxsKGl0KSA9PSAnW29iamVjdCBXaW5kb3ddJ1xuICAgID8gZ2V0V2luZG93TmFtZXMoaXQpXG4gICAgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1156\n")},8006:(__unused_webpack_module,exports,__webpack_require__)=>{eval("var internalObjectKeys = __webpack_require__(6324);\nvar enumBugKeys = __webpack_require__(748);\n\nvar hiddenKeys = enumBugKeys.concat('length', 'prototype');\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.es/ecma262/#sec-object.getownpropertynames\n// eslint-disable-next-line es/no-object-getownpropertynames -- safe\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return internalObjectKeys(O, hiddenKeys);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODAwNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LWdldC1vd24tcHJvcGVydHktbmFtZXMuanM/MjQxYyJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgaW50ZXJuYWxPYmplY3RLZXlzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1rZXlzLWludGVybmFsJyk7XG52YXIgZW51bUJ1Z0tleXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZW51bS1idWcta2V5cycpO1xuXG52YXIgaGlkZGVuS2V5cyA9IGVudW1CdWdLZXlzLmNvbmNhdCgnbGVuZ3RoJywgJ3Byb3RvdHlwZScpO1xuXG4vLyBgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXNgIG1ldGhvZFxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1vYmplY3QuZ2V0b3ducHJvcGVydHluYW1lc1xuLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVzL25vLW9iamVjdC1nZXRvd25wcm9wZXJ0eW5hbWVzIC0tIHNhZmVcbmV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHx8IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoTykge1xuICByZXR1cm4gaW50ZXJuYWxPYmplY3RLZXlzKE8sIGhpZGRlbktleXMpO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8006\n")},5181:(__unused_webpack_module,exports)=>{eval("// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe\nexports.f = Object.getOwnPropertySymbols;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTE4MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LWdldC1vd24tcHJvcGVydHktc3ltYm9scy5qcz83NDE4Il0sInNvdXJjZXNDb250ZW50IjpbIi8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcy9uby1vYmplY3QtZ2V0b3ducHJvcGVydHlzeW1ib2xzIC0tIHNhZmVcbmV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///5181\n")},9518:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var has = __webpack_require__(6656);\nvar toObject = __webpack_require__(7908);\nvar sharedKey = __webpack_require__(6200);\nvar CORRECT_PROTOTYPE_GETTER = __webpack_require__(8544);\n\nvar IE_PROTO = sharedKey('IE_PROTO');\nvar ObjectPrototype = Object.prototype;\n\n// `Object.getPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.getprototypeof\n// eslint-disable-next-line es/no-object-getprototypeof -- safe\nmodule.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectPrototype : null;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTUxOC5qcyIsIm1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ZiAoaGFzKE8sIElFX1BST1RPKSkgcmV0dXJuIE9bSUVfUFJPVE9dO1xuICBpZiAodHlwZW9mIE8uY29uc3RydWN0b3IgPT0gJ2Z1bmN0aW9uJyAmJiBPIGluc3RhbmNlb2YgTy5jb25zdHJ1Y3Rvcikge1xuICAgIHJldHVybiBPLmNvbnN0cnVjdG9yLnByb3RvdHlwZTtcbiAgfSByZXR1cm4gTyBpbnN0YW5jZW9mIE9iamVjdCA/IE9iamVjdFByb3RvdHlwZSA6IG51bGw7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9518\n")},6324:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var has = __webpack_require__(6656);\nvar toIndexedObject = __webpack_require__(5656);\nvar indexOf = __webpack_require__(1318).indexOf;\nvar hiddenKeys = __webpack_require__(3501);\n\nmodule.exports = function (object, names) {\n var O = toIndexedObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~indexOf(result, key) || result.push(key);\n }\n return result;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjMyNC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LWtleXMtaW50ZXJuYWwuanM/Y2E4NCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgaGFzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2hhcycpO1xudmFyIHRvSW5kZXhlZE9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1pbmRleGVkLW9iamVjdCcpO1xudmFyIGluZGV4T2YgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYXJyYXktaW5jbHVkZXMnKS5pbmRleE9mO1xudmFyIGhpZGRlbktleXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaGlkZGVuLWtleXMnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBuYW1lcykge1xuICB2YXIgTyA9IHRvSW5kZXhlZE9iamVjdChvYmplY3QpO1xuICB2YXIgaSA9IDA7XG4gIHZhciByZXN1bHQgPSBbXTtcbiAgdmFyIGtleTtcbiAgZm9yIChrZXkgaW4gTykgIWhhcyhoaWRkZW5LZXlzLCBrZXkpICYmIGhhcyhPLCBrZXkpICYmIHJlc3VsdC5wdXNoKGtleSk7XG4gIC8vIERvbid0IGVudW0gYnVnICYgaGlkZGVuIGtleXNcbiAgd2hpbGUgKG5hbWVzLmxlbmd0aCA+IGkpIGlmIChoYXMoTywga2V5ID0gbmFtZXNbaSsrXSkpIHtcbiAgICB+aW5kZXhPZihyZXN1bHQsIGtleSkgfHwgcmVzdWx0LnB1c2goa2V5KTtcbiAgfVxuICByZXR1cm4gcmVzdWx0O1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6324\n")},1956:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var internalObjectKeys = __webpack_require__(6324);\nvar enumBugKeys = __webpack_require__(748);\n\n// `Object.keys` method\n// https://tc39.es/ecma262/#sec-object.keys\n// eslint-disable-next-line es/no-object-keys -- safe\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTk1Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9vYmplY3Qta2V5cy5qcz9kZjc1Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBpbnRlcm5hbE9iamVjdEtleXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWtleXMtaW50ZXJuYWwnKTtcbnZhciBlbnVtQnVnS2V5cyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9lbnVtLWJ1Zy1rZXlzJyk7XG5cbi8vIGBPYmplY3Qua2V5c2AgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLW9iamVjdC5rZXlzXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWtleXMgLS0gc2FmZVxubW9kdWxlLmV4cG9ydHMgPSBPYmplY3Qua2V5cyB8fCBmdW5jdGlvbiBrZXlzKE8pIHtcbiAgcmV0dXJuIGludGVybmFsT2JqZWN0S2V5cyhPLCBlbnVtQnVnS2V5cyk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1956\n")},5296:(__unused_webpack_module,exports)=>{"use strict";eval("\nvar $propertyIsEnumerable = {}.propertyIsEnumerable;\n// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// Nashorn ~ JDK8 bug\nvar NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);\n\n// `Object.prototype.propertyIsEnumerable` method implementation\n// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable\nexports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {\n var descriptor = getOwnPropertyDescriptor(this, V);\n return !!descriptor && descriptor.enumerable;\n} : $propertyIsEnumerable;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTI5Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb2JqZWN0LXByb3BlcnR5LWlzLWVudW1lcmFibGUuanM/ZDFlNyJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgJHByb3BlcnR5SXNFbnVtZXJhYmxlID0ge30ucHJvcGVydHlJc0VudW1lcmFibGU7XG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWdldG93bnByb3BlcnR5ZGVzY3JpcHRvciAtLSBzYWZlXG52YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjtcblxuLy8gTmFzaG9ybiB+IEpESzggYnVnXG52YXIgTkFTSE9STl9CVUcgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgJiYgISRwcm9wZXJ0eUlzRW51bWVyYWJsZS5jYWxsKHsgMTogMiB9LCAxKTtcblxuLy8gYE9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGVgIG1ldGhvZCBpbXBsZW1lbnRhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1vYmplY3QucHJvdG90eXBlLnByb3BlcnR5aXNlbnVtZXJhYmxlXG5leHBvcnRzLmYgPSBOQVNIT1JOX0JVRyA/IGZ1bmN0aW9uIHByb3BlcnR5SXNFbnVtZXJhYmxlKFYpIHtcbiAgdmFyIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGhpcywgVik7XG4gIHJldHVybiAhIWRlc2NyaXB0b3IgJiYgZGVzY3JpcHRvci5lbnVtZXJhYmxlO1xufSA6ICRwcm9wZXJ0eUlzRW51bWVyYWJsZTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5296\n")},7674:(module,__unused_webpack_exports,__webpack_require__)=>{eval("/* eslint-disable no-proto -- safe */\nvar anObject = __webpack_require__(9670);\nvar aPossiblePrototype = __webpack_require__(6077);\n\n// `Object.setPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.setprototypeof\n// Works with __proto__ only. Old v8 can't work with null proto objects.\n// eslint-disable-next-line es/no-object-setprototypeof -- safe\nmodule.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {\n var CORRECT_SETTER = false;\n var test = {};\n var setter;\n try {\n // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe\n setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;\n setter.call(test, []);\n CORRECT_SETTER = test instanceof Array;\n } catch (error) { /* empty */ }\n return function setPrototypeOf(O, proto) {\n anObject(O);\n aPossiblePrototype(proto);\n if (CORRECT_SETTER) setter.call(O, proto);\n else O.__proto__ = proto;\n return O;\n };\n}() : undefined);\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzY3NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0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uZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE9iamVjdC5wcm90b3R5cGUsICdfX3Byb3RvX18nKS5zZXQ7XG4gICAgc2V0dGVyLmNhbGwodGVzdCwgW10pO1xuICAgIENPUlJFQ1RfU0VUVEVSID0gdGVzdCBpbnN0YW5jZW9mIEFycmF5O1xuICB9IGNhdGNoIChlcnJvcikgeyAvKiBlbXB0eSAqLyB9XG4gIHJldHVybiBmdW5jdGlvbiBzZXRQcm90b3R5cGVPZihPLCBwcm90bykge1xuICAgIGFuT2JqZWN0KE8pO1xuICAgIGFQb3NzaWJsZVByb3RvdHlwZShwcm90byk7XG4gICAgaWYgKENPUlJFQ1RfU0VUVEVSKSBzZXR0ZXIuY2FsbChPLCBwcm90byk7XG4gICAgZWxzZSBPLl9fcHJvdG9fXyA9IHByb3RvO1xuICAgIHJldHVybiBPO1xuICB9O1xufSgpIDogdW5kZWZpbmVkKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7674\n")},288:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar TO_STRING_TAG_SUPPORT = __webpack_require__(1694);\nvar classof = __webpack_require__(648);\n\n// `Object.prototype.toString` method implementation\n// https://tc39.es/ecma262/#sec-object.prototype.tostring\nmodule.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {\n return '[object ' + classof(this) + ']';\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjg4LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL29iamVjdC10by1zdHJpbmcuanM/YjA0MSJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLXN0cmluZy10YWctc3VwcG9ydCcpO1xudmFyIGNsYXNzb2YgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY2xhc3NvZicpO1xuXG4vLyBgT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZ2AgbWV0aG9kIGltcGxlbWVudGF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLW9iamVjdC5wcm90b3R5cGUudG9zdHJpbmdcbm1vZHVsZS5leHBvcnRzID0gVE9fU1RSSU5HX1RBR19TVVBQT1JUID8ge30udG9TdHJpbmcgOiBmdW5jdGlvbiB0b1N0cmluZygpIHtcbiAgcmV0dXJuICdbb2JqZWN0ICcgKyBjbGFzc29mKHRoaXMpICsgJ10nO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///288\n")},2140:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\n\n// `OrdinaryToPrimitive` abstract operation\n// https://tc39.es/ecma262/#sec-ordinarytoprimitive\nmodule.exports = function (input, pref) {\n var fn, val;\n if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;\n if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjE0MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb3JkaW5hcnktdG8tcHJpbWl0aXZlLmpzPzQ4NWEiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGlzT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2lzLW9iamVjdCcpO1xuXG4vLyBgT3JkaW5hcnlUb1ByaW1pdGl2ZWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLW9yZGluYXJ5dG9wcmltaXRpdmVcbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGlucHV0LCBwcmVmKSB7XG4gIHZhciBmbiwgdmFsO1xuICBpZiAocHJlZiA9PT0gJ3N0cmluZycgJiYgdHlwZW9mIChmbiA9IGlucHV0LnRvU3RyaW5nKSA9PSAnZnVuY3Rpb24nICYmICFpc09iamVjdCh2YWwgPSBmbi5jYWxsKGlucHV0KSkpIHJldHVybiB2YWw7XG4gIGlmICh0eXBlb2YgKGZuID0gaW5wdXQudmFsdWVPZikgPT0gJ2Z1bmN0aW9uJyAmJiAhaXNPYmplY3QodmFsID0gZm4uY2FsbChpbnB1dCkpKSByZXR1cm4gdmFsO1xuICBpZiAocHJlZiAhPT0gJ3N0cmluZycgJiYgdHlwZW9mIChmbiA9IGlucHV0LnRvU3RyaW5nKSA9PSAnZnVuY3Rpb24nICYmICFpc09iamVjdCh2YWwgPSBmbi5jYWxsKGlucHV0KSkpIHJldHVybiB2YWw7XG4gIHRocm93IFR5cGVFcnJvcihcIkNhbid0IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZVwiKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2140\n")},3887:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var getBuiltIn = __webpack_require__(5005);\nvar getOwnPropertyNamesModule = __webpack_require__(8006);\nvar getOwnPropertySymbolsModule = __webpack_require__(5181);\nvar anObject = __webpack_require__(9670);\n\n// all object keys, includes non-enumerable and symbols\nmodule.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {\n var keys = getOwnPropertyNamesModule.f(anObject(it));\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzg4Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvb3duLWtleXMuanM/NTZlZiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2V0QnVpbHRJbiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nZXQtYnVpbHQtaW4nKTtcbnZhciBnZXRPd25Qcm9wZXJ0eU5hbWVzTW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1nZXQtb3duLXByb3BlcnR5LW5hbWVzJyk7XG52YXIgZ2V0T3duUHJvcGVydHlTeW1ib2xzTW9kdWxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL29iamVjdC1nZXQtb3duLXByb3BlcnR5LXN5bWJvbHMnKTtcbnZhciBhbk9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hbi1vYmplY3QnKTtcblxuLy8gYWxsIG9iamVjdCBrZXlzLCBpbmNsdWRlcyBub24tZW51bWVyYWJsZSBhbmQgc3ltYm9sc1xubW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ293bktleXMnKSB8fCBmdW5jdGlvbiBvd25LZXlzKGl0KSB7XG4gIHZhciBrZXlzID0gZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mKGFuT2JqZWN0KGl0KSk7XG4gIHZhciBnZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPSBnZXRPd25Qcm9wZXJ0eVN5bWJvbHNNb2R1bGUuZjtcbiAgcmV0dXJuIGdldE93blByb3BlcnR5U3ltYm9scyA/IGtleXMuY29uY2F0KGdldE93blByb3BlcnR5U3ltYm9scyhpdCkpIDoga2V5cztcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3887\n")},857:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\n\nmodule.exports = global;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODU3LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3BhdGguanM/NDI4ZiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGdsb2JhbDtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///857\n")},2534:module=>{eval("module.exports = function (exec) {\n try {\n return { error: false, value: exec() };\n } catch (error) {\n return { error: true, value: error };\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjUzNC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3BlcmZvcm0uanM/ZTY2NyJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChleGVjKSB7XG4gIHRyeSB7XG4gICAgcmV0dXJuIHsgZXJyb3I6IGZhbHNlLCB2YWx1ZTogZXhlYygpIH07XG4gIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgcmV0dXJuIHsgZXJyb3I6IHRydWUsIHZhbHVlOiBlcnJvciB9O1xuICB9XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2534\n")},9478:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\nvar isObject = __webpack_require__(111);\nvar newPromiseCapability = __webpack_require__(8523);\n\nmodule.exports = function (C, x) {\n anObject(C);\n if (isObject(x) && x.constructor === C) return x;\n var promiseCapability = newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTQ3OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9wcm9taXNlLXJlc29sdmUuanM/Y2RmOSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYW5PYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYW4tb2JqZWN0Jyk7XG52YXIgaXNPYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtb2JqZWN0Jyk7XG52YXIgbmV3UHJvbWlzZUNhcGFiaWxpdHkgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvbmV3LXByb21pc2UtY2FwYWJpbGl0eScpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChDLCB4KSB7XG4gIGFuT2JqZWN0KEMpO1xuICBpZiAoaXNPYmplY3QoeCkgJiYgeC5jb25zdHJ1Y3RvciA9PT0gQykgcmV0dXJuIHg7XG4gIHZhciBwcm9taXNlQ2FwYWJpbGl0eSA9IG5ld1Byb21pc2VDYXBhYmlsaXR5LmYoQyk7XG4gIHZhciByZXNvbHZlID0gcHJvbWlzZUNhcGFiaWxpdHkucmVzb2x2ZTtcbiAgcmVzb2x2ZSh4KTtcbiAgcmV0dXJuIHByb21pc2VDYXBhYmlsaXR5LnByb21pc2U7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9478\n")},2248:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var redefine = __webpack_require__(1320);\n\nmodule.exports = function (target, src, options) {\n for (var key in src) redefine(target, key, src[key], options);\n return target;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjI0OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9yZWRlZmluZS1hbGwuanM/ZTJjYyJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgcmVkZWZpbmUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvcmVkZWZpbmUnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodGFyZ2V0LCBzcmMsIG9wdGlvbnMpIHtcbiAgZm9yICh2YXIga2V5IGluIHNyYykgcmVkZWZpbmUodGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTtcbiAgcmV0dXJuIHRhcmdldDtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2248\n")},1320:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar has = __webpack_require__(6656);\nvar setGlobal = __webpack_require__(3505);\nvar inspectSource = __webpack_require__(2788);\nvar InternalStateModule = __webpack_require__(9909);\n\nvar getInternalState = InternalStateModule.get;\nvar enforceInternalState = InternalStateModule.enforce;\nvar TEMPLATE = String(String).split('String');\n\n(module.exports = function (O, key, value, options) {\n var unsafe = options ? !!options.unsafe : false;\n var simple = options ? !!options.enumerable : false;\n var noTargetGet = options ? !!options.noTargetGet : false;\n var state;\n if (typeof value == 'function') {\n if (typeof key == 'string' && !has(value, 'name')) {\n createNonEnumerableProperty(value, 'name', key);\n }\n state = enforceInternalState(value);\n if (!state.source) {\n state.source = TEMPLATE.join(typeof key == 'string' ? key : '');\n }\n }\n if (O === global) {\n if (simple) O[key] = value;\n else setGlobal(key, value);\n return;\n } else if (!unsafe) {\n delete O[key];\n } else if (!noTargetGet && O[key]) {\n simple = true;\n }\n if (simple) O[key] = value;\n else createNonEnumerableProperty(O, key, value);\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, 'toString', function toString() {\n return typeof this == 'function' && getInternalState(this).source || inspectSource(this);\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTMyMC5qcyIsIm1hcHBpbmdzIjoiQUF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ZhbHVlO1xuICBlbHNlIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShPLCBrZXksIHZhbHVlKTtcbi8vIGFkZCBmYWtlIEZ1bmN0aW9uI3RvU3RyaW5nIGZvciBjb3JyZWN0IHdvcmsgd3JhcHBlZCBtZXRob2RzIC8gY29uc3RydWN0b3JzIHdpdGggbWV0aG9kcyBsaWtlIExvRGFzaCBpc05hdGl2ZVxufSkoRnVuY3Rpb24ucHJvdG90eXBlLCAndG9TdHJpbmcnLCBmdW5jdGlvbiB0b1N0cmluZygpIHtcbiAgcmV0dXJuIHR5cGVvZiB0aGlzID09ICdmdW5jdGlvbicgJiYgZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKS5zb3VyY2UgfHwgaW5zcGVjdFNvdXJjZSh0aGlzKTtcbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1320\n")},7651:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var classof = __webpack_require__(4326);\nvar regexpExec = __webpack_require__(2261);\n\n// `RegExpExec` abstract operation\n// https://tc39.es/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n var exec = R.exec;\n if (typeof exec === 'function') {\n var result = exec.call(R, S);\n if (typeof result !== 'object') {\n throw TypeError('RegExp exec method returned something other than an Object or null');\n }\n return result;\n }\n\n if (classof(R) !== 'RegExp') {\n throw TypeError('RegExp#exec called on incompatible receiver');\n }\n\n return regexpExec.call(R, S);\n};\n\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzY1MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3JlZ2V4cC1leGVjLWFic3RyYWN0LmpzPzE0YzMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGNsYXNzb2YgPSByZXF1aXJlKCcuL2NsYXNzb2YtcmF3Jyk7XG52YXIgcmVnZXhwRXhlYyA9IHJlcXVpcmUoJy4vcmVnZXhwLWV4ZWMnKTtcblxuLy8gYFJlZ0V4cEV4ZWNgIGFic3RyYWN0IG9wZXJhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1yZWdleHBleGVjXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChSLCBTKSB7XG4gIHZhciBleGVjID0gUi5leGVjO1xuICBpZiAodHlwZW9mIGV4ZWMgPT09ICdmdW5jdGlvbicpIHtcbiAgICB2YXIgcmVzdWx0ID0gZXhlYy5jYWxsKFIsIFMpO1xuICAgIGlmICh0eXBlb2YgcmVzdWx0ICE9PSAnb2JqZWN0Jykge1xuICAgICAgdGhyb3cgVHlwZUVycm9yKCdSZWdFeHAgZXhlYyBtZXRob2QgcmV0dXJuZWQgc29tZXRoaW5nIG90aGVyIHRoYW4gYW4gT2JqZWN0IG9yIG51bGwnKTtcbiAgICB9XG4gICAgcmV0dXJuIHJlc3VsdDtcbiAgfVxuXG4gIGlmIChjbGFzc29mKFIpICE9PSAnUmVnRXhwJykge1xuICAgIHRocm93IFR5cGVFcnJvcignUmVnRXhwI2V4ZWMgY2FsbGVkIG9uIGluY29tcGF0aWJsZSByZWNlaXZlcicpO1xuICB9XG5cbiAgcmV0dXJuIHJlZ2V4cEV4ZWMuY2FsbChSLCBTKTtcbn07XG5cbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7651\n")},2261:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\n/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */\n/* eslint-disable regexp/no-useless-quantifier -- testing */\nvar toString = __webpack_require__(1340);\nvar regexpFlags = __webpack_require__(7066);\nvar stickyHelpers = __webpack_require__(2999);\nvar shared = __webpack_require__(2309);\nvar create = __webpack_require__(30);\nvar getInternalState = __webpack_require__(9909).get;\nvar UNSUPPORTED_DOT_ALL = __webpack_require__(9441);\nvar UNSUPPORTED_NCG = __webpack_require__(8173);\n\nvar nativeExec = RegExp.prototype.exec;\nvar nativeReplace = shared('native-string-replace', String.prototype.replace);\n\nvar patchedExec = nativeExec;\n\nvar UPDATES_LAST_INDEX_WRONG = (function () {\n var re1 = /a/;\n var re2 = /b*/g;\n nativeExec.call(re1, 'a');\n nativeExec.call(re2, 'a');\n return re1.lastIndex !== 0 || re2.lastIndex !== 0;\n})();\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;\n\n// nonparticipating capturing group, copied from es5-shim's String#split patch.\nvar NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;\n\nvar PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;\n\nif (PATCH) {\n // eslint-disable-next-line max-statements -- TODO\n patchedExec = function exec(string) {\n var re = this;\n var state = getInternalState(re);\n var str = toString(string);\n var raw = state.raw;\n var result, reCopy, lastIndex, match, i, object, group;\n\n if (raw) {\n raw.lastIndex = re.lastIndex;\n result = patchedExec.call(raw, str);\n re.lastIndex = raw.lastIndex;\n return result;\n }\n\n var groups = state.groups;\n var sticky = UNSUPPORTED_Y && re.sticky;\n var flags = regexpFlags.call(re);\n var source = re.source;\n var charsAdded = 0;\n var strCopy = str;\n\n if (sticky) {\n flags = flags.replace('y', '');\n if (flags.indexOf('g') === -1) {\n flags += 'g';\n }\n\n strCopy = str.slice(re.lastIndex);\n // Support anchored sticky behavior.\n if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\\n')) {\n source = '(?: ' + source + ')';\n strCopy = ' ' + strCopy;\n charsAdded++;\n }\n // ^(? + rx + ) is needed, in combination with some str slicing, to\n // simulate the 'y' flag.\n reCopy = new RegExp('^(?:' + source + ')', flags);\n }\n\n if (NPCG_INCLUDED) {\n reCopy = new RegExp('^' + source + '$(?!\\\\s)', flags);\n }\n if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;\n\n match = nativeExec.call(sticky ? reCopy : re, strCopy);\n\n if (sticky) {\n if (match) {\n match.input = match.input.slice(charsAdded);\n match[0] = match[0].slice(charsAdded);\n match.index = re.lastIndex;\n re.lastIndex += match[0].length;\n } else re.lastIndex = 0;\n } else if (UPDATES_LAST_INDEX_WRONG && match) {\n re.lastIndex = re.global ? match.index + match[0].length : lastIndex;\n }\n if (NPCG_INCLUDED && match && match.length > 1) {\n // Fix browsers whose `exec` methods don't consistently return `undefined`\n // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/\n nativeReplace.call(match[0], reCopy, function () {\n for (i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undefined) match[i] = undefined;\n }\n });\n }\n\n if (match && groups) {\n match.groups = object = create(null);\n for (i = 0; i < groups.length; i++) {\n group = groups[i];\n object[group[0]] = match[group[1]];\n }\n }\n\n return match;\n };\n}\n\nmodule.exports = patchedExec;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjI2MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FB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T8vXG4gICAgICBuYXRpdmVSZXBsYWNlLmNhbGwobWF0Y2hbMF0sIHJlQ29weSwgZnVuY3Rpb24gKCkge1xuICAgICAgICBmb3IgKGkgPSAxOyBpIDwgYXJndW1lbnRzLmxlbmd0aCAtIDI7IGkrKykge1xuICAgICAgICAgIGlmIChhcmd1bWVudHNbaV0gPT09IHVuZGVmaW5lZCkgbWF0Y2hbaV0gPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmIChtYXRjaCAmJiBncm91cHMpIHtcbiAgICAgIG1hdGNoLmdyb3VwcyA9IG9iamVjdCA9IGNyZWF0ZShudWxsKTtcbiAgICAgIGZvciAoaSA9IDA7IGkgPCBncm91cHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgZ3JvdXAgPSBncm91cHNbaV07XG4gICAgICAgIG9iamVjdFtncm91cFswXV0gPSBtYXRjaFtncm91cFsxXV07XG4gICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIG1hdGNoO1xuICB9O1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHBhdGNoZWRFeGVjO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2261\n")},7066:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar anObject = __webpack_require__(9670);\n\n// `RegExp.prototype.flags` getter implementation\n// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.dotAll) result += 's';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzA2Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3JlZ2V4cC1mbGFncy5qcz9hZDZkIl0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciBhbk9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hbi1vYmplY3QnKTtcblxuLy8gYFJlZ0V4cC5wcm90b3R5cGUuZmxhZ3NgIGdldHRlciBpbXBsZW1lbnRhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1nZXQtcmVnZXhwLnByb3RvdHlwZS5mbGFnc1xubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7XG4gIHZhciB0aGF0ID0gYW5PYmplY3QodGhpcyk7XG4gIHZhciByZXN1bHQgPSAnJztcbiAgaWYgKHRoYXQuZ2xvYmFsKSByZXN1bHQgKz0gJ2cnO1xuICBpZiAodGhhdC5pZ25vcmVDYXNlKSByZXN1bHQgKz0gJ2knO1xuICBpZiAodGhhdC5tdWx0aWxpbmUpIHJlc3VsdCArPSAnbSc7XG4gIGlmICh0aGF0LmRvdEFsbCkgcmVzdWx0ICs9ICdzJztcbiAgaWYgKHRoYXQudW5pY29kZSkgcmVzdWx0ICs9ICd1JztcbiAgaWYgKHRoYXQuc3RpY2t5KSByZXN1bHQgKz0gJ3knO1xuICByZXR1cm4gcmVzdWx0O1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///7066\n")},2999:(__unused_webpack_module,exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar global = __webpack_require__(7854);\n\n// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError\nvar $RegExp = global.RegExp;\n\nexports.UNSUPPORTED_Y = fails(function () {\n var re = $RegExp('a', 'y');\n re.lastIndex = 2;\n return re.exec('abcd') != null;\n});\n\nexports.BROKEN_CARET = fails(function () {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=773687\n var re = $RegExp('^r', 'gy');\n re.lastIndex = 2;\n return re.exec('str') != null;\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjk5OS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9yZWdleHAtc3RpY2t5LWhlbHBlcnMuanM/OWY3ZiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZmFpbHMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZmFpbHMnKTtcbnZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG5cbi8vIGJhYmVsLW1pbmlmeSBhbmQgQ2xvc3VyZSBDb21waWxlciB0cmFuc3BpbGVzIFJlZ0V4cCgnYScsICd5JykgLT4gL2EveSBhbmQgaXQgY2F1c2VzIFN5bnRheEVycm9yXG52YXIgJFJlZ0V4cCA9IGdsb2JhbC5SZWdFeHA7XG5cbmV4cG9ydHMuVU5TVVBQT1JURURfWSA9IGZhaWxzKGZ1bmN0aW9uICgpIHtcbiAgdmFyIHJlID0gJFJlZ0V4cCgnYScsICd5Jyk7XG4gIHJlLmxhc3RJbmRleCA9IDI7XG4gIHJldHVybiByZS5leGVjKCdhYmNkJykgIT0gbnVsbDtcbn0pO1xuXG5leHBvcnRzLkJST0tFTl9DQVJFVCA9IGZhaWxzKGZ1bmN0aW9uICgpIHtcbiAgLy8gaHR0cHM6Ly9idWd6aWxsYS5tb3ppbGxhLm9yZy9zaG93X2J1Zy5jZ2k/aWQ9NzczNjg3XG4gIHZhciByZSA9ICRSZWdFeHAoJ15yJywgJ2d5Jyk7XG4gIHJlLmxhc3RJbmRleCA9IDI7XG4gIHJldHVybiByZS5leGVjKCdzdHInKSAhPSBudWxsO1xufSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2999\n")},9441:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar global = __webpack_require__(7854);\n\n// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError\nvar $RegExp = global.RegExp;\n\nmodule.exports = fails(function () {\n var re = $RegExp('.', 's');\n return !(re.dotAll && re.exec('\\n') && re.flags === 's');\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTQ0MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3JlZ2V4cC11bnN1cHBvcnRlZC1kb3QtYWxsLmpzP2ZjZTMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGZhaWxzID0gcmVxdWlyZSgnLi9mYWlscycpO1xudmFyIGdsb2JhbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nbG9iYWwnKTtcblxuLy8gYmFiZWwtbWluaWZ5IGFuZCBDbG9zdXJlIENvbXBpbGVyIHRyYW5zcGlsZXMgUmVnRXhwKCcuJywgJ3MnKSAtPiAvLi9zIGFuZCBpdCBjYXVzZXMgU3ludGF4RXJyb3JcbnZhciAkUmVnRXhwID0gZ2xvYmFsLlJlZ0V4cDtcblxubW9kdWxlLmV4cG9ydHMgPSBmYWlscyhmdW5jdGlvbiAoKSB7XG4gIHZhciByZSA9ICRSZWdFeHAoJy4nLCAncycpO1xuICByZXR1cm4gIShyZS5kb3RBbGwgJiYgcmUuZXhlYygnXFxuJykgJiYgcmUuZmxhZ3MgPT09ICdzJyk7XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///9441\n")},8173:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar global = __webpack_require__(7854);\n\n// babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError\nvar $RegExp = global.RegExp;\n\nmodule.exports = fails(function () {\n var re = $RegExp('(?b)', 'g');\n return re.exec('b').groups.a !== 'b' ||\n 'b'.replace(re, '$c') !== 'bc';\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODE3My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvcmVnZXhwLXVuc3VwcG9ydGVkLW5jZy5qcz8xMDdjIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBmYWlscyA9IHJlcXVpcmUoJy4vZmFpbHMnKTtcbnZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG5cbi8vIGJhYmVsLW1pbmlmeSBhbmQgQ2xvc3VyZSBDb21waWxlciB0cmFuc3BpbGVzIFJlZ0V4cCgnKD88YT5iKScsICdnJykgLT4gLyg/PGE+YikvZyBhbmQgaXQgY2F1c2VzIFN5bnRheEVycm9yXG52YXIgJFJlZ0V4cCA9IGdsb2JhbC5SZWdFeHA7XG5cbm1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkge1xuICB2YXIgcmUgPSAkUmVnRXhwKCcoPzxhPmIpJywgJ2cnKTtcbiAgcmV0dXJuIHJlLmV4ZWMoJ2InKS5ncm91cHMuYSAhPT0gJ2InIHx8XG4gICAgJ2InLnJlcGxhY2UocmUsICckPGE+YycpICE9PSAnYmMnO1xufSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8173\n")},4488:module=>{eval('// `RequireObjectCoercible` abstract operation\n// https://tc39.es/ecma262/#sec-requireobjectcoercible\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError("Can\'t call method on " + it);\n return it;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDQ4OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9yZXF1aXJlLW9iamVjdC1jb2VyY2libGUuanM/MWQ4MCJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBgUmVxdWlyZU9iamVjdENvZXJjaWJsZWAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXJlcXVpcmVvYmplY3Rjb2VyY2libGVcbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7XG4gIGlmIChpdCA9PSB1bmRlZmluZWQpIHRocm93IFR5cGVFcnJvcihcIkNhbid0IGNhbGwgbWV0aG9kIG9uIFwiICsgaXQpO1xuICByZXR1cm4gaXQ7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///4488\n')},1150:module=>{eval("// `SameValue` abstract operation\n// https://tc39.es/ecma262/#sec-samevalue\n// eslint-disable-next-line es/no-object-is -- safe\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare -- NaN check\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTE1MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NhbWUtdmFsdWUuanM/MTI5ZiJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBgU2FtZVZhbHVlYCBhYnN0cmFjdCBvcGVyYXRpb25cbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtc2FtZXZhbHVlXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXMvbm8tb2JqZWN0LWlzIC0tIHNhZmVcbm1vZHVsZS5leHBvcnRzID0gT2JqZWN0LmlzIHx8IGZ1bmN0aW9uIGlzKHgsIHkpIHtcbiAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLXNlbGYtY29tcGFyZSAtLSBOYU4gY2hlY2tcbiAgcmV0dXJuIHggPT09IHkgPyB4ICE9PSAwIHx8IDEgLyB4ID09PSAxIC8geSA6IHggIT0geCAmJiB5ICE9IHk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1150\n")},3505:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\n\nmodule.exports = function (key, value) {\n try {\n // eslint-disable-next-line es/no-object-defineproperty -- safe\n Object.defineProperty(global, key, { value: value, configurable: true, writable: true });\n } catch (error) {\n global[key] = value;\n } return value;\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzUwNS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NldC1nbG9iYWwuanM/Y2U0ZSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChrZXksIHZhbHVlKSB7XG4gIHRyeSB7XG4gICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVzL25vLW9iamVjdC1kZWZpbmVwcm9wZXJ0eSAtLSBzYWZlXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGdsb2JhbCwga2V5LCB7IHZhbHVlOiB2YWx1ZSwgY29uZmlndXJhYmxlOiB0cnVlLCB3cml0YWJsZTogdHJ1ZSB9KTtcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICBnbG9iYWxba2V5XSA9IHZhbHVlO1xuICB9IHJldHVybiB2YWx1ZTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3505\n")},6340:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar getBuiltIn = __webpack_require__(5005);\nvar definePropertyModule = __webpack_require__(3070);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar DESCRIPTORS = __webpack_require__(9781);\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (CONSTRUCTOR_NAME) {\n var Constructor = getBuiltIn(CONSTRUCTOR_NAME);\n var defineProperty = definePropertyModule.f;\n\n if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {\n defineProperty(Constructor, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjM0MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NldC1zcGVjaWVzLmpzPzI2MjYiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyIGdldEJ1aWx0SW4gPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2V0LWJ1aWx0LWluJyk7XG52YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWRlZmluZS1wcm9wZXJ0eScpO1xudmFyIHdlbGxLbm93blN5bWJvbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbCcpO1xudmFyIERFU0NSSVBUT1JTID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Rlc2NyaXB0b3JzJyk7XG5cbnZhciBTUEVDSUVTID0gd2VsbEtub3duU3ltYm9sKCdzcGVjaWVzJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUpIHtcbiAgdmFyIENvbnN0cnVjdG9yID0gZ2V0QnVpbHRJbihDT05TVFJVQ1RPUl9OQU1FKTtcbiAgdmFyIGRlZmluZVByb3BlcnR5ID0gZGVmaW5lUHJvcGVydHlNb2R1bGUuZjtcblxuICBpZiAoREVTQ1JJUFRPUlMgJiYgQ29uc3RydWN0b3IgJiYgIUNvbnN0cnVjdG9yW1NQRUNJRVNdKSB7XG4gICAgZGVmaW5lUHJvcGVydHkoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHtcbiAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgIGdldDogZnVuY3Rpb24gKCkgeyByZXR1cm4gdGhpczsgfVxuICAgIH0pO1xuICB9XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///6340\n")},8003:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var defineProperty = __webpack_require__(3070).f;\nvar has = __webpack_require__(6656);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n\nmodule.exports = function (it, TAG, STATIC) {\n if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {\n defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });\n }\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODAwMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvc2V0LXRvLXN0cmluZy10YWcuanM/ZDQ0ZSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZGVmaW5lUHJvcGVydHkgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWRlZmluZS1wcm9wZXJ0eScpLmY7XG52YXIgaGFzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2hhcycpO1xudmFyIHdlbGxLbm93blN5bWJvbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbCcpO1xuXG52YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFRBRywgU1RBVElDKSB7XG4gIGlmIChpdCAmJiAhaGFzKGl0ID0gU1RBVElDID8gaXQgOiBpdC5wcm90b3R5cGUsIFRPX1NUUklOR19UQUcpKSB7XG4gICAgZGVmaW5lUHJvcGVydHkoaXQsIFRPX1NUUklOR19UQUcsIHsgY29uZmlndXJhYmxlOiB0cnVlLCB2YWx1ZTogVEFHIH0pO1xuICB9XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///8003\n")},6200:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var shared = __webpack_require__(2309);\nvar uid = __webpack_require__(9711);\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjIwMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvc2hhcmVkLWtleS5qcz9mNzcyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBzaGFyZWQgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvc2hhcmVkJyk7XG52YXIgdWlkID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3VpZCcpO1xuXG52YXIga2V5cyA9IHNoYXJlZCgna2V5cycpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChrZXkpIHtcbiAgcmV0dXJuIGtleXNba2V5XSB8fCAoa2V5c1trZXldID0gdWlkKGtleSkpO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6200\n")},5465:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar setGlobal = __webpack_require__(3505);\n\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || setGlobal(SHARED, {});\n\nmodule.exports = store;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTQ2NS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NoYXJlZC1zdG9yZS5qcz9jNmNkIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZ2xvYmFsJyk7XG52YXIgc2V0R2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3NldC1nbG9iYWwnKTtcblxudmFyIFNIQVJFRCA9ICdfX2NvcmUtanNfc2hhcmVkX18nO1xudmFyIHN0b3JlID0gZ2xvYmFsW1NIQVJFRF0gfHwgc2V0R2xvYmFsKFNIQVJFRCwge30pO1xuXG5tb2R1bGUuZXhwb3J0cyA9IHN0b3JlO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///5465\n")},2309:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var IS_PURE = __webpack_require__(1913);\nvar store = __webpack_require__(5465);\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: '3.17.2',\n mode: IS_PURE ? 'pure' : 'global',\n copyright: '© 2021 Denis Pushkarev (zloirock.ru)'\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjMwOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NoYXJlZC5qcz81NjkyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBJU19QVVJFID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2lzLXB1cmUnKTtcbnZhciBzdG9yZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zaGFyZWQtc3RvcmUnKTtcblxuKG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbiAgcmV0dXJuIHN0b3JlW2tleV0gfHwgKHN0b3JlW2tleV0gPSB2YWx1ZSAhPT0gdW5kZWZpbmVkID8gdmFsdWUgOiB7fSk7XG59KSgndmVyc2lvbnMnLCBbXSkucHVzaCh7XG4gIHZlcnNpb246ICczLjE3LjInLFxuICBtb2RlOiBJU19QVVJFID8gJ3B1cmUnIDogJ2dsb2JhbCcsXG4gIGNvcHlyaWdodDogJ8KpIDIwMjEgRGVuaXMgUHVzaGthcmV2ICh6bG9pcm9jay5ydSknXG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2309\n")},6707:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var anObject = __webpack_require__(9670);\nvar aFunction = __webpack_require__(3099);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `SpeciesConstructor` abstract operation\n// https://tc39.es/ecma262/#sec-speciesconstructor\nmodule.exports = function (O, defaultConstructor) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjcwNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3NwZWNpZXMtY29uc3RydWN0b3IuanM/NDg0MCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYW5PYmplY3QgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYW4tb2JqZWN0Jyk7XG52YXIgYUZ1bmN0aW9uID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2EtZnVuY3Rpb24nKTtcbnZhciB3ZWxsS25vd25TeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvd2VsbC1rbm93bi1zeW1ib2wnKTtcblxudmFyIFNQRUNJRVMgPSB3ZWxsS25vd25TeW1ib2woJ3NwZWNpZXMnKTtcblxuLy8gYFNwZWNpZXNDb25zdHJ1Y3RvcmAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXNwZWNpZXNjb25zdHJ1Y3RvclxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoTywgZGVmYXVsdENvbnN0cnVjdG9yKSB7XG4gIHZhciBDID0gYW5PYmplY3QoTykuY29uc3RydWN0b3I7XG4gIHZhciBTO1xuICByZXR1cm4gQyA9PT0gdW5kZWZpbmVkIHx8IChTID0gYW5PYmplY3QoQylbU1BFQ0lFU10pID09IHVuZGVmaW5lZCA/IGRlZmF1bHRDb25zdHJ1Y3RvciA6IGFGdW5jdGlvbihTKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///6707\n")},8710:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var toInteger = __webpack_require__(9958);\nvar toString = __webpack_require__(1340);\nvar requireObjectCoercible = __webpack_require__(4488);\n\n// `String.prototype.codePointAt` methods implementation\nvar createMethod = function (CONVERT_TO_STRING) {\n return function ($this, pos) {\n var S = toString(requireObjectCoercible($this));\n var position = toInteger(pos);\n var size = S.length;\n var first, second;\n if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;\n first = S.charCodeAt(position);\n return first < 0xD800 || first > 0xDBFF || position + 1 === size\n || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF\n ? CONVERT_TO_STRING ? S.charAt(position) : first\n : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;\n };\n};\n\nmodule.exports = {\n // `String.prototype.codePointAt` method\n // https://tc39.es/ecma262/#sec-string.prototype.codepointat\n codeAt: createMethod(false),\n // `String.prototype.at` method\n // https://github.com/mathiasbynens/String.prototype.at\n charAt: createMethod(true)\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJm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gcmV0dXJuIENPTlZFUlRfVE9fU1RSSU5HID8gJycgOiB1bmRlZmluZWQ7XG4gICAgZmlyc3QgPSBTLmNoYXJDb2RlQXQocG9zaXRpb24pO1xuICAgIHJldHVybiBmaXJzdCA8IDB4RDgwMCB8fCBmaXJzdCA+IDB4REJGRiB8fCBwb3NpdGlvbiArIDEgPT09IHNpemVcbiAgICAgIHx8IChzZWNvbmQgPSBTLmNoYXJDb2RlQXQocG9zaXRpb24gKyAxKSkgPCAweERDMDAgfHwgc2Vjb25kID4gMHhERkZGXG4gICAgICAgID8gQ09OVkVSVF9UT19TVFJJTkcgPyBTLmNoYXJBdChwb3NpdGlvbikgOiBmaXJzdFxuICAgICAgICA6IENPTlZFUlRfVE9fU1RSSU5HID8gUy5zbGljZShwb3NpdGlvbiwgcG9zaXRpb24gKyAyKSA6IChmaXJzdCAtIDB4RDgwMCA8PCAxMCkgKyAoc2Vjb25kIC0gMHhEQzAwKSArIDB4MTAwMDA7XG4gIH07XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IHtcbiAgLy8gYFN0cmluZy5wcm90b3R5cGUuY29kZVBvaW50QXRgIG1ldGhvZFxuICAvLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXN0cmluZy5wcm90b3R5cGUuY29kZXBvaW50YXRcbiAgY29kZUF0OiBjcmVhdGVNZXRob2QoZmFsc2UpLFxuICAvLyBgU3RyaW5nLnByb3RvdHlwZS5hdGAgbWV0aG9kXG4gIC8vIGh0dHBzOi8vZ2l0aHViLmNvbS9tYXRoaWFzYnluZW5zL1N0cmluZy5wcm90b3R5cGUuYXRcbiAgY2hhckF0OiBjcmVhdGVNZXRob2QodHJ1ZSlcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///8710\n")},6091:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var fails = __webpack_require__(7293);\nvar whitespaces = __webpack_require__(1361);\n\nvar non = '\\u200B\\u0085\\u180E';\n\n// check that a method works with the correct list\n// of whitespaces and has a correct name\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;\n });\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjA5MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy9zdHJpbmctdHJpbS1mb3JjZWQuanM/YzhkMiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZmFpbHMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZmFpbHMnKTtcbnZhciB3aGl0ZXNwYWNlcyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93aGl0ZXNwYWNlcycpO1xuXG52YXIgbm9uID0gJ1xcdTIwMEJcXHUwMDg1XFx1MTgwRSc7XG5cbi8vIGNoZWNrIHRoYXQgYSBtZXRob2Qgd29ya3Mgd2l0aCB0aGUgY29ycmVjdCBsaXN0XG4vLyBvZiB3aGl0ZXNwYWNlcyBhbmQgaGFzIGEgY29ycmVjdCBuYW1lXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChNRVRIT0RfTkFNRSkge1xuICByZXR1cm4gZmFpbHMoZnVuY3Rpb24gKCkge1xuICAgIHJldHVybiAhIXdoaXRlc3BhY2VzW01FVEhPRF9OQU1FXSgpIHx8IG5vbltNRVRIT0RfTkFNRV0oKSAhPSBub24gfHwgd2hpdGVzcGFjZXNbTUVUSE9EX05BTUVdLm5hbWUgIT09IE1FVEhPRF9OQU1FO1xuICB9KTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///6091\n")},3111:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var requireObjectCoercible = __webpack_require__(4488);\nvar toString = __webpack_require__(1340);\nvar whitespaces = __webpack_require__(1361);\n\nvar whitespace = '[' + whitespaces + ']';\nvar ltrim = RegExp('^' + whitespace + whitespace + '*');\nvar rtrim = RegExp(whitespace + whitespace + '*$');\n\n// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation\nvar createMethod = function (TYPE) {\n return function ($this) {\n var string = toString(requireObjectCoercible($this));\n if (TYPE & 1) string = string.replace(ltrim, '');\n if (TYPE & 2) string = string.replace(rtrim, '');\n return string;\n };\n};\n\nmodule.exports = {\n // `String.prototype.{ trimLeft, trimStart }` methods\n // https://tc39.es/ecma262/#sec-string.prototype.trimstart\n start: createMethod(1),\n // `String.prototype.{ trimRight, trimEnd }` methods\n // https://tc39.es/ecma262/#sec-string.prototype.trimend\n end: createMethod(2),\n // `String.prototype.trim` method\n // https://tc39.es/ecma262/#sec-string.prototype.trim\n trim: createMethod(3)\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzExMS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvc3RyaW5nLXRyaW0uanM/NThhOCJdLC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dGMzOS5lcy9lY21hMjYyLyNzZWMtc3RyaW5nLnByb3RvdHlwZS50cmltc3RhcnRcbiAgc3RhcnQ6IGNyZWF0ZU1ldGhvZCgxKSxcbiAgLy8gYFN0cmluZy5wcm90b3R5cGUueyB0cmltUmlnaHQsIHRyaW1FbmQgfWAgbWV0aG9kc1xuICAvLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXN0cmluZy5wcm90b3R5cGUudHJpbWVuZFxuICBlbmQ6IGNyZWF0ZU1ldGhvZCgyKSxcbiAgLy8gYFN0cmluZy5wcm90b3R5cGUudHJpbWAgbWV0aG9kXG4gIC8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtc3RyaW5nLnByb3RvdHlwZS50cmltXG4gIHRyaW06IGNyZWF0ZU1ldGhvZCgzKVxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3111\n")},261:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar fails = __webpack_require__(7293);\nvar bind = __webpack_require__(9974);\nvar html = __webpack_require__(490);\nvar createElement = __webpack_require__(317);\nvar IS_IOS = __webpack_require__(6833);\nvar IS_NODE = __webpack_require__(5268);\n\nvar set = global.setImmediate;\nvar clear = global.clearImmediate;\nvar process = global.process;\nvar MessageChannel = global.MessageChannel;\nvar Dispatch = global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar location, defer, channel, port;\n\ntry {\n // Deno throws a ReferenceError on `location` access without `--location` flag\n location = global.location;\n} catch (error) { /* empty */ }\n\nvar run = function (id) {\n // eslint-disable-next-line no-prototype-builtins -- safe\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\n\nvar runner = function (id) {\n return function () {\n run(id);\n };\n};\n\nvar listener = function (event) {\n run(event.data);\n};\n\nvar post = function (id) {\n // old engines have not location.origin\n global.postMessage(String(id), location.protocol + '//' + location.host);\n};\n\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!set || !clear) {\n set = function setImmediate(fn) {\n var args = [];\n var argumentsLength = arguments.length;\n var i = 1;\n while (argumentsLength > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func -- spec requirement\n (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);\n };\n defer(counter);\n return counter;\n };\n clear = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (IS_NODE) {\n defer = function (id) {\n process.nextTick(runner(id));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(runner(id));\n };\n // Browsers with MessageChannel, includes WebWorkers\n // except iOS - https://github.com/zloirock/core-js/issues/624\n } else if (MessageChannel && !IS_IOS) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = bind(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (\n global.addEventListener &&\n typeof postMessage == 'function' &&\n !global.importScripts &&\n location && location.protocol !== 'file:' &&\n !fails(post)\n ) {\n defer = post;\n global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in createElement('script')) {\n defer = function (id) {\n html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {\n html.removeChild(this);\n run(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(runner(id), 0);\n };\n }\n}\n\nmodule.exports = {\n set: set,\n clear: clear\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjYxLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ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yAnb2JqZWN0J1xuICB9IGVsc2UgaWYgKFxuICAgIGdsb2JhbC5hZGRFdmVudExpc3RlbmVyICYmXG4gICAgdHlwZW9mIHBvc3RNZXNzYWdlID09ICdmdW5jdGlvbicgJiZcbiAgICAhZ2xvYmFsLmltcG9ydFNjcmlwdHMgJiZcbiAgICBsb2NhdGlvbiAmJiBsb2NhdGlvbi5wcm90b2NvbCAhPT0gJ2ZpbGU6JyAmJlxuICAgICFmYWlscyhwb3N0KVxuICApIHtcbiAgICBkZWZlciA9IHBvc3Q7XG4gICAgZ2xvYmFsLmFkZEV2ZW50TGlzdGVuZXIoJ21lc3NhZ2UnLCBsaXN0ZW5lciwgZmFsc2UpO1xuICAvLyBJRTgtXG4gIH0gZWxzZSBpZiAoT05SRUFEWVNUQVRFQ0hBTkdFIGluIGNyZWF0ZUVsZW1lbnQoJ3NjcmlwdCcpKSB7XG4gICAgZGVmZXIgPSBmdW5jdGlvbiAoaWQpIHtcbiAgICAgIGh0bWwuYXBwZW5kQ2hpbGQoY3JlYXRlRWxlbWVudCgnc2NyaXB0JykpW09OUkVBRFlTVEFURUNIQU5HRV0gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGh0bWwucmVtb3ZlQ2hpbGQodGhpcyk7XG4gICAgICAgIHJ1bihpZCk7XG4gICAgICB9O1xuICAgIH07XG4gIC8vIFJlc3Qgb2xkIGJyb3dzZXJzXG4gIH0gZWxzZSB7XG4gICAgZGVmZXIgPSBmdW5jdGlvbiAoaWQpIHtcbiAgICAgIHNldFRpbWVvdXQocnVubmVyKGlkKSwgMCk7XG4gICAgfTtcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHtcbiAgc2V0OiBzZXQsXG4gIGNsZWFyOiBjbGVhclxufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///261\n")},1400:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var toInteger = __webpack_require__(9958);\n\nvar max = Math.max;\nvar min = Math.min;\n\n// Helper for a popular repeating case of the spec:\n// Let integer be ? ToInteger(index).\n// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).\nmodule.exports = function (index, length) {\n var integer = toInteger(index);\n return integer < 0 ? max(integer + length, 0) : min(integer, length);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTQwMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy90by1hYnNvbHV0ZS1pbmRleC5qcz8yM2NiIl0sInNvdXJjZXNDb250ZW50IjpbInZhciB0b0ludGVnZXIgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8taW50ZWdlcicpO1xuXG52YXIgbWF4ID0gTWF0aC5tYXg7XG52YXIgbWluID0gTWF0aC5taW47XG5cbi8vIEhlbHBlciBmb3IgYSBwb3B1bGFyIHJlcGVhdGluZyBjYXNlIG9mIHRoZSBzcGVjOlxuLy8gTGV0IGludGVnZXIgYmUgPyBUb0ludGVnZXIoaW5kZXgpLlxuLy8gSWYgaW50ZWdlciA8IDAsIGxldCByZXN1bHQgYmUgbWF4KChsZW5ndGggKyBpbnRlZ2VyKSwgMCk7IGVsc2UgbGV0IHJlc3VsdCBiZSBtaW4oaW50ZWdlciwgbGVuZ3RoKS5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGluZGV4LCBsZW5ndGgpIHtcbiAgdmFyIGludGVnZXIgPSB0b0ludGVnZXIoaW5kZXgpO1xuICByZXR1cm4gaW50ZWdlciA8IDAgPyBtYXgoaW50ZWdlciArIGxlbmd0aCwgMCkgOiBtaW4oaW50ZWdlciwgbGVuZ3RoKTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1400\n")},5656:(module,__unused_webpack_exports,__webpack_require__)=>{eval("// toObject with fallback for non-array-like ES3 strings\nvar IndexedObject = __webpack_require__(8361);\nvar requireObjectCoercible = __webpack_require__(4488);\n\nmodule.exports = function (it) {\n return IndexedObject(requireObjectCoercible(it));\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTY1Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3RvLWluZGV4ZWQtb2JqZWN0LmpzP2ZjNmEiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gdG9PYmplY3Qgd2l0aCBmYWxsYmFjayBmb3Igbm9uLWFycmF5LWxpa2UgRVMzIHN0cmluZ3NcbnZhciBJbmRleGVkT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2luZGV4ZWQtb2JqZWN0Jyk7XG52YXIgcmVxdWlyZU9iamVjdENvZXJjaWJsZSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9yZXF1aXJlLW9iamVjdC1jb2VyY2libGUnKTtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHtcbiAgcmV0dXJuIEluZGV4ZWRPYmplY3QocmVxdWlyZU9iamVjdENvZXJjaWJsZShpdCkpO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5656\n")},9958:module=>{eval("var ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `ToInteger` abstract operation\n// https://tc39.es/ecma262/#sec-tointeger\nmodule.exports = function (argument) {\n return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTk1OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvdG8taW50ZWdlci5qcz9hNjkxIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBjZWlsID0gTWF0aC5jZWlsO1xudmFyIGZsb29yID0gTWF0aC5mbG9vcjtcblxuLy8gYFRvSW50ZWdlcmAgYWJzdHJhY3Qgb3BlcmF0aW9uXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXRvaW50ZWdlclxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHtcbiAgcmV0dXJuIGlzTmFOKGFyZ3VtZW50ID0gK2FyZ3VtZW50KSA/IDAgOiAoYXJndW1lbnQgPiAwID8gZmxvb3IgOiBjZWlsKShhcmd1bWVudCk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9958\n")},7466:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var toInteger = __webpack_require__(9958);\n\nvar min = Math.min;\n\n// `ToLength` abstract operation\n// https://tc39.es/ecma262/#sec-tolength\nmodule.exports = function (argument) {\n return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzQ2Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy90by1sZW5ndGguanM/NTBjNCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgdG9JbnRlZ2VyID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLWludGVnZXInKTtcblxudmFyIG1pbiA9IE1hdGgubWluO1xuXG4vLyBgVG9MZW5ndGhgIGFic3RyYWN0IG9wZXJhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy10b2xlbmd0aFxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHtcbiAgcmV0dXJuIGFyZ3VtZW50ID4gMCA/IG1pbih0b0ludGVnZXIoYXJndW1lbnQpLCAweDFGRkZGRkZGRkZGRkZGKSA6IDA7IC8vIDIgKiogNTMgLSAxID09IDkwMDcxOTkyNTQ3NDA5OTFcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///7466\n")},7908:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var requireObjectCoercible = __webpack_require__(4488);\n\n// `ToObject` abstract operation\n// https://tc39.es/ecma262/#sec-toobject\nmodule.exports = function (argument) {\n return Object(requireObjectCoercible(argument));\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzkwOC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvaW50ZXJuYWxzL3RvLW9iamVjdC5qcz83YjBiIl0sInNvdXJjZXNDb250ZW50IjpbInZhciByZXF1aXJlT2JqZWN0Q29lcmNpYmxlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3JlcXVpcmUtb2JqZWN0LWNvZXJjaWJsZScpO1xuXG4vLyBgVG9PYmplY3RgIGFic3RyYWN0IG9wZXJhdGlvblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy10b29iamVjdFxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHtcbiAgcmV0dXJuIE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGFyZ3VtZW50KSk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7908\n")},7593:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isObject = __webpack_require__(111);\nvar isSymbol = __webpack_require__(2190);\nvar ordinaryToPrimitive = __webpack_require__(2140);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\n\n// `ToPrimitive` abstract operation\n// https://tc39.es/ecma262/#sec-toprimitive\nmodule.exports = function (input, pref) {\n if (!isObject(input) || isSymbol(input)) return input;\n var exoticToPrim = input[TO_PRIMITIVE];\n var result;\n if (exoticToPrim !== undefined) {\n if (pref === undefined) pref = 'default';\n result = exoticToPrim.call(input, pref);\n if (!isObject(result) || isSymbol(result)) return result;\n throw TypeError(\"Can't convert object to primitive value\");\n }\n if (pref === undefined) pref = 'number';\n return ordinaryToPrimitive(input, pref);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzU5My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTt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4b3RpY1RvUHJpbS5jYWxsKGlucHV0LCBwcmVmKTtcbiAgICBpZiAoIWlzT2JqZWN0KHJlc3VsdCkgfHwgaXNTeW1ib2wocmVzdWx0KSkgcmV0dXJuIHJlc3VsdDtcbiAgICB0aHJvdyBUeXBlRXJyb3IoXCJDYW4ndCBjb252ZXJ0IG9iamVjdCB0byBwcmltaXRpdmUgdmFsdWVcIik7XG4gIH1cbiAgaWYgKHByZWYgPT09IHVuZGVmaW5lZCkgcHJlZiA9ICdudW1iZXInO1xuICByZXR1cm4gb3JkaW5hcnlUb1ByaW1pdGl2ZShpbnB1dCwgcHJlZik7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7593\n")},4948:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var toPrimitive = __webpack_require__(7593);\nvar isSymbol = __webpack_require__(2190);\n\n// `ToPropertyKey` abstract operation\n// https://tc39.es/ecma262/#sec-topropertykey\nmodule.exports = function (argument) {\n var key = toPrimitive(argument, 'string');\n return isSymbol(key) ? key : String(key);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDk0OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy90by1wcm9wZXJ0eS1rZXkuanM/YTA0YiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgdG9QcmltaXRpdmUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8tcHJpbWl0aXZlJyk7XG52YXIgaXNTeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtc3ltYm9sJyk7XG5cbi8vIGBUb1Byb3BlcnR5S2V5YCBhYnN0cmFjdCBvcGVyYXRpb25cbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtdG9wcm9wZXJ0eWtleVxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHtcbiAgdmFyIGtleSA9IHRvUHJpbWl0aXZlKGFyZ3VtZW50LCAnc3RyaW5nJyk7XG4gIHJldHVybiBpc1N5bWJvbChrZXkpID8ga2V5IDogU3RyaW5nKGtleSk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///4948\n")},1694:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar test = {};\n\ntest[TO_STRING_TAG] = 'z';\n\nmodule.exports = String(test) === '[object z]';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTY5NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvdG8tc3RyaW5nLXRhZy1zdXBwb3J0LmpzPzAwZWUiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHdlbGxLbm93blN5bWJvbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbCcpO1xuXG52YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTtcbnZhciB0ZXN0ID0ge307XG5cbnRlc3RbVE9fU1RSSU5HX1RBR10gPSAneic7XG5cbm1vZHVsZS5leHBvcnRzID0gU3RyaW5nKHRlc3QpID09PSAnW29iamVjdCB6XSc7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///1694\n")},1340:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var isSymbol = __webpack_require__(2190);\n\nmodule.exports = function (argument) {\n if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a string');\n return String(argument);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTM0MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy90by1zdHJpbmcuanM/NTc3ZSJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgaXNTeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaXMtc3ltYm9sJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7XG4gIGlmIChpc1N5bWJvbChhcmd1bWVudCkpIHRocm93IFR5cGVFcnJvcignQ2Fubm90IGNvbnZlcnQgYSBTeW1ib2wgdmFsdWUgdG8gYSBzdHJpbmcnKTtcbiAgcmV0dXJuIFN0cmluZyhhcmd1bWVudCk7XG59O1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1340\n")},9711:module=>{eval("var id = 0;\nvar postfix = Math.random();\n\nmodule.exports = function (key) {\n return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTcxMS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy91aWQuanM/OTBlMyJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgaWQgPSAwO1xudmFyIHBvc3RmaXggPSBNYXRoLnJhbmRvbSgpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChrZXkpIHtcbiAgcmV0dXJuICdTeW1ib2woJyArIFN0cmluZyhrZXkgPT09IHVuZGVmaW5lZCA/ICcnIDoga2V5KSArICcpXycgKyAoKytpZCArIHBvc3RmaXgpLnRvU3RyaW5nKDM2KTtcbn07XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///9711\n")},3307:(module,__unused_webpack_exports,__webpack_require__)=>{eval("/* eslint-disable es/no-symbol -- required for testing */\nvar NATIVE_SYMBOL = __webpack_require__(133);\n\nmodule.exports = NATIVE_SYMBOL\n && !Symbol.sham\n && typeof Symbol.iterator == 'symbol';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzMwNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy91c2Utc3ltYm9sLWFzLXVpZC5qcz9mZGJmIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIGVzL25vLXN5bWJvbCAtLSByZXF1aXJlZCBmb3IgdGVzdGluZyAqL1xudmFyIE5BVElWRV9TWU1CT0wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvbmF0aXZlLXN5bWJvbCcpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9TWU1CT0xcbiAgJiYgIVN5bWJvbC5zaGFtXG4gICYmIHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT0gJ3N5bWJvbCc7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3307\n")},6061:(__unused_webpack_module,exports,__webpack_require__)=>{eval("var wellKnownSymbol = __webpack_require__(5112);\n\nexports.f = wellKnownSymbol;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjA2MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbC13cmFwcGVkLmpzP2U1MzgiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHdlbGxLbm93blN5bWJvbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy93ZWxsLWtub3duLXN5bWJvbCcpO1xuXG5leHBvcnRzLmYgPSB3ZWxsS25vd25TeW1ib2w7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///6061\n")},5112:(module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar shared = __webpack_require__(2309);\nvar has = __webpack_require__(6656);\nvar uid = __webpack_require__(9711);\nvar NATIVE_SYMBOL = __webpack_require__(133);\nvar USE_SYMBOL_AS_UID = __webpack_require__(3307);\n\nvar WellKnownSymbolsStore = shared('wks');\nvar Symbol = global.Symbol;\nvar createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;\n\nmodule.exports = function (name) {\n if (!has(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {\n if (NATIVE_SYMBOL && has(Symbol, name)) {\n WellKnownSymbolsStore[name] = Symbol[name];\n } else {\n WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);\n }\n } return WellKnownSymbolsStore[name];\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTExMi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9pbnRlcm5hbHMvd2VsbC1rbm93bi1zeW1ib2wuanM/YjYyMiJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZ2xvYmFsID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2dsb2JhbCcpO1xudmFyIHNoYXJlZCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zaGFyZWQnKTtcbnZhciBoYXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvaGFzJyk7XG52YXIgdWlkID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3VpZCcpO1xudmFyIE5BVElWRV9TWU1CT0wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvbmF0aXZlLXN5bWJvbCcpO1xudmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3VzZS1zeW1ib2wtYXMtdWlkJyk7XG5cbnZhciBXZWxsS25vd25TeW1ib2xzU3RvcmUgPSBzaGFyZWQoJ3drcycpO1xudmFyIFN5bWJvbCA9IGdsb2JhbC5TeW1ib2w7XG52YXIgY3JlYXRlV2VsbEtub3duU3ltYm9sID0gVVNFX1NZTUJPTF9BU19VSUQgPyBTeW1ib2wgOiBTeW1ib2wgJiYgU3ltYm9sLndpdGhvdXRTZXR0ZXIgfHwgdWlkO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChuYW1lKSB7XG4gIGlmICghaGFzKFdlbGxLbm93blN5bWJvbHNTdG9yZSwgbmFtZSkgfHwgIShOQVRJVkVfU1lNQk9MIHx8IHR5cGVvZiBXZWxsS25vd25TeW1ib2xzU3RvcmVbbmFtZV0gPT0gJ3N0cmluZycpKSB7XG4gICAgaWYgKE5BVElWRV9TWU1CT0wgJiYgaGFzKFN5bWJvbCwgbmFtZSkpIHtcbiAgICAgIFdlbGxLbm93blN5bWJvbHNTdG9yZVtuYW1lXSA9IFN5bWJvbFtuYW1lXTtcbiAgICB9IGVsc2Uge1xuICAgICAgV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdID0gY3JlYXRlV2VsbEtub3duU3ltYm9sKCdTeW1ib2wuJyArIG5hbWUpO1xuICAgIH1cbiAgfSByZXR1cm4gV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdO1xufTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5112\n")},1361:module=>{eval("// a string of all valid unicode whitespaces\nmodule.exports = '\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u2000\\u2001\\u2002' +\n '\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTM2MS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL2ludGVybmFscy93aGl0ZXNwYWNlcy5qcz81ODk5Il0sInNvdXJjZXNDb250ZW50IjpbIi8vIGEgc3RyaW5nIG9mIGFsbCB2YWxpZCB1bmljb2RlIHdoaXRlc3BhY2VzXG5tb2R1bGUuZXhwb3J0cyA9ICdcXHUwMDA5XFx1MDAwQVxcdTAwMEJcXHUwMDBDXFx1MDAwRFxcdTAwMjBcXHUwMEEwXFx1MTY4MFxcdTIwMDBcXHUyMDAxXFx1MjAwMicgK1xuICAnXFx1MjAwM1xcdTIwMDRcXHUyMDA1XFx1MjAwNlxcdTIwMDdcXHUyMDA4XFx1MjAwOVxcdTIwMEFcXHUyMDJGXFx1MjA1RlxcdTMwMDBcXHUyMDI4XFx1MjAyOVxcdUZFRkYnO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1361\n")},2222:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar fails = __webpack_require__(7293);\nvar isArray = __webpack_require__(3157);\nvar isObject = __webpack_require__(111);\nvar toObject = __webpack_require__(7908);\nvar toLength = __webpack_require__(7466);\nvar createProperty = __webpack_require__(6135);\nvar arraySpeciesCreate = __webpack_require__(5417);\nvar arrayMethodHasSpeciesSupport = __webpack_require__(1194);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar V8_VERSION = __webpack_require__(7392);\n\nvar IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';\n\n// We can't use this feature detection in V8 since it causes\n// deoptimization and serious performance degradation\n// https://github.com/zloirock/core-js/issues/679\nvar IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {\n var array = [];\n array[IS_CONCAT_SPREADABLE] = false;\n return array.concat()[0] !== array;\n});\n\nvar SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');\n\nvar isConcatSpreadable = function (O) {\n if (!isObject(O)) return false;\n var spreadable = O[IS_CONCAT_SPREADABLE];\n return spreadable !== undefined ? !!spreadable : isArray(O);\n};\n\nvar FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;\n\n// `Array.prototype.concat` method\n// https://tc39.es/ecma262/#sec-array.prototype.concat\n// with adding support of @@isConcatSpreadable and @@species\n$({ target: 'Array', proto: true, forced: FORCED }, {\n // eslint-disable-next-line no-unused-vars -- required for `.length`\n concat: function concat(arg) {\n var O = toObject(this);\n var A = arraySpeciesCreate(O, 0);\n var n = 0;\n var i, k, length, len, E;\n for (i = -1, length = arguments.length; i < length; i++) {\n E = i === -1 ? O : arguments[i];\n if (isConcatSpreadable(E)) {\n len = toLength(E.length);\n if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);\n } else {\n if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n createProperty(A, n++, E);\n }\n }\n A.length = n;\n return A;\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjIyMi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUF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RFWF9FWENFRURFRCk7XG4gICAgICAgIGZvciAoayA9IDA7IGsgPCBsZW47IGsrKywgbisrKSBpZiAoayBpbiBFKSBjcmVhdGVQcm9wZXJ0eShBLCBuLCBFW2tdKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmIChuID49IE1BWF9TQUZFX0lOVEVHRVIpIHRocm93IFR5cGVFcnJvcihNQVhJTVVNX0FMTE9XRURfSU5ERVhfRVhDRUVERUQpO1xuICAgICAgICBjcmVhdGVQcm9wZXJ0eShBLCBuKyssIEUpO1xuICAgICAgfVxuICAgIH1cbiAgICBBLmxlbmd0aCA9IG47XG4gICAgcmV0dXJuIEE7XG4gIH1cbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2222\n")},3290:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var $ = __webpack_require__(2109);\nvar fill = __webpack_require__(1285);\nvar addToUnscopables = __webpack_require__(1223);\n\n// `Array.prototype.fill` method\n// https://tc39.es/ecma262/#sec-array.prototype.fill\n$({ target: 'Array', proto: true }, {\n fill: fill\n});\n\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('fill');\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzI5MC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuYXJyYXkuZmlsbC5qcz9jYjI5Il0sInNvdXJjZXNDb250ZW50IjpbInZhciAkID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2V4cG9ydCcpO1xudmFyIGZpbGwgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYXJyYXktZmlsbCcpO1xudmFyIGFkZFRvVW5zY29wYWJsZXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYWRkLXRvLXVuc2NvcGFibGVzJyk7XG5cbi8vIGBBcnJheS5wcm90b3R5cGUuZmlsbGAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS5maWxsXG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBwcm90bzogdHJ1ZSB9LCB7XG4gIGZpbGw6IGZpbGxcbn0pO1xuXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS1AQHVuc2NvcGFibGVzXG5hZGRUb1Vuc2NvcGFibGVzKCdmaWxsJyk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///3290\n")},7327:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar $filter = __webpack_require__(2092).filter;\nvar arrayMethodHasSpeciesSupport = __webpack_require__(1194);\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');\n\n// `Array.prototype.filter` method\n// https://tc39.es/ecma262/#sec-array.prototype.filter\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {\n filter: function filter(callbackfn /* , thisArg */) {\n return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzMyNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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-internal:///7327\n")},9826:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar $find = __webpack_require__(2092).find;\nvar addToUnscopables = __webpack_require__(1223);\n\nvar FIND = 'find';\nvar SKIPS_HOLES = true;\n\n// Shouldn't skip holes\nif (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.find` method\n// https://tc39.es/ecma262/#sec-array.prototype.find\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {\n find: function find(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND);\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTgyNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuYXJyYXkuZmluZC5qcz83ZGIwIl0sInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcbnZhciAkID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2V4cG9ydCcpO1xudmFyICRmaW5kID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FycmF5LWl0ZXJhdGlvbicpLmZpbmQ7XG52YXIgYWRkVG9VbnNjb3BhYmxlcyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hZGQtdG8tdW5zY29wYWJsZXMnKTtcblxudmFyIEZJTkQgPSAnZmluZCc7XG52YXIgU0tJUFNfSE9MRVMgPSB0cnVlO1xuXG4vLyBTaG91bGRuJ3Qgc2tpcCBob2xlc1xuaWYgKEZJTkQgaW4gW10pIEFycmF5KDEpW0ZJTkRdKGZ1bmN0aW9uICgpIHsgU0tJUFNfSE9MRVMgPSBmYWxzZTsgfSk7XG5cbi8vIGBBcnJheS5wcm90b3R5cGUuZmluZGAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS5maW5kXG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBwcm90bzogdHJ1ZSwgZm9yY2VkOiBTS0lQU19IT0xFUyB9LCB7XG4gIGZpbmQ6IGZ1bmN0aW9uIGZpbmQoY2FsbGJhY2tmbiAvKiAsIHRoYXQgPSB1bmRlZmluZWQgKi8pIHtcbiAgICByZXR1cm4gJGZpbmQodGhpcywgY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpO1xuICB9XG59KTtcblxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1hcnJheS5wcm90b3R5cGUtQEB1bnNjb3BhYmxlc1xuYWRkVG9VbnNjb3BhYmxlcyhGSU5EKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///9826\n")},4944:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar flattenIntoArray = __webpack_require__(6790);\nvar toObject = __webpack_require__(7908);\nvar toLength = __webpack_require__(7466);\nvar toInteger = __webpack_require__(9958);\nvar arraySpeciesCreate = __webpack_require__(5417);\n\n// `Array.prototype.flat` method\n// https://tc39.es/ecma262/#sec-array.prototype.flat\n$({ target: 'Array', proto: true }, {\n flat: function flat(/* depthArg = 1 */) {\n var depthArg = arguments.length ? arguments[0] : undefined;\n var O = toObject(this);\n var sourceLen = toLength(O.length);\n var A = arraySpeciesCreate(O, 0);\n A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));\n return A;\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDk0NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLmFycmF5LmZsYXQuanM/MDQ4MSJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgJCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9leHBvcnQnKTtcbnZhciBmbGF0dGVuSW50b0FycmF5ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2ZsYXR0ZW4taW50by1hcnJheScpO1xudmFyIHRvT2JqZWN0ID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLW9iamVjdCcpO1xudmFyIHRvTGVuZ3RoID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3RvLWxlbmd0aCcpO1xudmFyIHRvSW50ZWdlciA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1pbnRlZ2VyJyk7XG52YXIgYXJyYXlTcGVjaWVzQ3JlYXRlID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FycmF5LXNwZWNpZXMtY3JlYXRlJyk7XG5cbi8vIGBBcnJheS5wcm90b3R5cGUuZmxhdGAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS5mbGF0XG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBwcm90bzogdHJ1ZSB9LCB7XG4gIGZsYXQ6IGZ1bmN0aW9uIGZsYXQoLyogZGVwdGhBcmcgPSAxICovKSB7XG4gICAgdmFyIGRlcHRoQXJnID0gYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZDtcbiAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpO1xuICAgIHZhciBzb3VyY2VMZW4gPSB0b0xlbmd0aChPLmxlbmd0aCk7XG4gICAgdmFyIEEgPSBhcnJheVNwZWNpZXNDcmVhdGUoTywgMCk7XG4gICAgQS5sZW5ndGggPSBmbGF0dGVuSW50b0FycmF5KEEsIE8sIE8sIHNvdXJjZUxlbiwgMCwgZGVwdGhBcmcgPT09IHVuZGVmaW5lZCA/IDEgOiB0b0ludGVnZXIoZGVwdGhBcmcpKTtcbiAgICByZXR1cm4gQTtcbiAgfVxufSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///4944\n")},1038:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var $ = __webpack_require__(2109);\nvar from = __webpack_require__(8457);\nvar checkCorrectnessOfIteration = __webpack_require__(7072);\n\nvar INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {\n // eslint-disable-next-line es/no-array-from -- required for testing\n Array.from(iterable);\n});\n\n// `Array.from` method\n// https://tc39.es/ecma262/#sec-array.from\n$({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {\n from: from\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTAzOC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLmFycmF5LmZyb20uanM/YTYzMCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgJCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9leHBvcnQnKTtcbnZhciBmcm9tID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FycmF5LWZyb20nKTtcbnZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvY2hlY2stY29ycmVjdG5lc3Mtb2YtaXRlcmF0aW9uJyk7XG5cbnZhciBJTkNPUlJFQ1RfSVRFUkFUSU9OID0gIWNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHtcbiAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVzL25vLWFycmF5LWZyb20gLS0gcmVxdWlyZWQgZm9yIHRlc3RpbmdcbiAgQXJyYXkuZnJvbShpdGVyYWJsZSk7XG59KTtcblxuLy8gYEFycmF5LmZyb21gIG1ldGhvZFxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1hcnJheS5mcm9tXG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBzdGF0OiB0cnVlLCBmb3JjZWQ6IElOQ09SUkVDVF9JVEVSQVRJT04gfSwge1xuICBmcm9tOiBmcm9tXG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1038\n")},6699:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar $includes = __webpack_require__(1318).includes;\nvar addToUnscopables = __webpack_require__(1223);\n\n// `Array.prototype.includes` method\n// https://tc39.es/ecma262/#sec-array.prototype.includes\n$({ target: 'Array', proto: true }, {\n includes: function includes(el /* , fromIndex = 0 */) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('includes');\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjY5OS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuYXJyYXkuaW5jbHVkZXMuanM/Y2FhZCJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgJCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9leHBvcnQnKTtcbnZhciAkaW5jbHVkZXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYXJyYXktaW5jbHVkZXMnKS5pbmNsdWRlcztcbnZhciBhZGRUb1Vuc2NvcGFibGVzID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2FkZC10by11bnNjb3BhYmxlcycpO1xuXG4vLyBgQXJyYXkucHJvdG90eXBlLmluY2x1ZGVzYCBtZXRob2Rcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtYXJyYXkucHJvdG90eXBlLmluY2x1ZGVzXG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBwcm90bzogdHJ1ZSB9LCB7XG4gIGluY2x1ZGVzOiBmdW5jdGlvbiBpbmNsdWRlcyhlbCAvKiAsIGZyb21JbmRleCA9IDAgKi8pIHtcbiAgICByZXR1cm4gJGluY2x1ZGVzKHRoaXMsIGVsLCBhcmd1bWVudHMubGVuZ3RoID4gMSA/IGFyZ3VtZW50c1sxXSA6IHVuZGVmaW5lZCk7XG4gIH1cbn0pO1xuXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS1AQHVuc2NvcGFibGVzXG5hZGRUb1Vuc2NvcGFibGVzKCdpbmNsdWRlcycpO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///6699\n")},2772:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\n/* eslint-disable es/no-array-prototype-indexof -- required for testing */\nvar $ = __webpack_require__(2109);\nvar $indexOf = __webpack_require__(1318).indexOf;\nvar arrayMethodIsStrict = __webpack_require__(9341);\n\nvar nativeIndexOf = [].indexOf;\n\nvar NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;\nvar STRICT_METHOD = arrayMethodIsStrict('indexOf');\n\n// `Array.prototype.indexOf` method\n// https://tc39.es/ecma262/#sec-array.prototype.indexof\n$({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {\n indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {\n return NEGATIVE_ZERO\n // convert -0 to +0\n ? nativeIndexOf.apply(this, arguments) || 0\n : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjc3Mi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6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HRvICswXG4gICAgICA/IG5hdGl2ZUluZGV4T2YuYXBwbHkodGhpcywgYXJndW1lbnRzKSB8fCAwXG4gICAgICA6ICRpbmRleE9mKHRoaXMsIHNlYXJjaEVsZW1lbnQsIGFyZ3VtZW50cy5sZW5ndGggPiAxID8gYXJndW1lbnRzWzFdIDogdW5kZWZpbmVkKTtcbiAgfVxufSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2772\n")},6992:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar toIndexedObject = __webpack_require__(5656);\nvar addToUnscopables = __webpack_require__(1223);\nvar Iterators = __webpack_require__(7497);\nvar InternalStateModule = __webpack_require__(9909);\nvar defineIterator = __webpack_require__(654);\n\nvar ARRAY_ITERATOR = 'Array Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);\n\n// `Array.prototype.entries` method\n// https://tc39.es/ecma262/#sec-array.prototype.entries\n// `Array.prototype.keys` method\n// https://tc39.es/ecma262/#sec-array.prototype.keys\n// `Array.prototype.values` method\n// https://tc39.es/ecma262/#sec-array.prototype.values\n// `Array.prototype[@@iterator]` method\n// https://tc39.es/ecma262/#sec-array.prototype-@@iterator\n// `CreateArrayIterator` internal method\n// https://tc39.es/ecma262/#sec-createarrayiterator\nmodule.exports = defineIterator(Array, 'Array', function (iterated, kind) {\n setInternalState(this, {\n type: ARRAY_ITERATOR,\n target: toIndexedObject(iterated), // target\n index: 0, // next index\n kind: kind // kind\n });\n// `%ArrayIteratorPrototype%.next` method\n// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next\n}, function () {\n var state = getInternalState(this);\n var target = state.target;\n var kind = state.kind;\n var index = state.index++;\n if (!target || index >= target.length) {\n state.target = undefined;\n return { value: undefined, done: true };\n }\n if (kind == 'keys') return { value: index, done: false };\n if (kind == 'values') return { value: target[index], done: false };\n return { value: [index, target[index]], done: false };\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values%\n// https://tc39.es/ecma262/#sec-createunmappedargumentsobject\n// https://tc39.es/ecma262/#sec-createmappedargumentsobject\nIterators.Arguments = Iterators.Array;\n\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNjk5Mi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLmFycmF5Lml0ZXJhdG9yLmpzP2UyNjAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyIHRvSW5kZXhlZE9iamVjdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy90by1pbmRleGVkLW9iamVjdCcpO1xudmFyIGFkZFRvVW5zY29wYWJsZXMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvYWRkLXRvLXVuc2NvcGFibGVzJyk7XG52YXIgSXRlcmF0b3JzID0gcmVxdWlyZSgnLi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cmdldFtpbmRleF1dLCBkb25lOiBmYWxzZSB9O1xufSwgJ3ZhbHVlcycpO1xuXG4vLyBhcmd1bWVudHNMaXN0W0BAaXRlcmF0b3JdIGlzICVBcnJheVByb3RvX3ZhbHVlcyVcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtY3JlYXRldW5tYXBwZWRhcmd1bWVudHNvYmplY3Rcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtY3JlYXRlbWFwcGVkYXJndW1lbnRzb2JqZWN0XG5JdGVyYXRvcnMuQXJndW1lbnRzID0gSXRlcmF0b3JzLkFycmF5O1xuXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS1AQHVuc2NvcGFibGVzXG5hZGRUb1Vuc2NvcGFibGVzKCdrZXlzJyk7XG5hZGRUb1Vuc2NvcGFibGVzKCd2YWx1ZXMnKTtcbmFkZFRvVW5zY29wYWJsZXMoJ2VudHJpZXMnKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6992\n")},9600:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar IndexedObject = __webpack_require__(8361);\nvar toIndexedObject = __webpack_require__(5656);\nvar arrayMethodIsStrict = __webpack_require__(9341);\n\nvar nativeJoin = [].join;\n\nvar ES3_STRINGS = IndexedObject != Object;\nvar STRICT_METHOD = arrayMethodIsStrict('join', ',');\n\n// `Array.prototype.join` method\n// https://tc39.es/ecma262/#sec-array.prototype.join\n$({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {\n join: function join(separator) {\n return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTYwMC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2VwYXJhdG9yKSB7XG4gICAgcmV0dXJuIG5hdGl2ZUpvaW4uY2FsbCh0b0luZGV4ZWRPYmplY3QodGhpcyksIHNlcGFyYXRvciA9PT0gdW5kZWZpbmVkID8gJywnIDogc2VwYXJhdG9yKTtcbiAgfVxufSk7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///9600\n")},1249:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar $map = __webpack_require__(2092).map;\nvar arrayMethodHasSpeciesSupport = __webpack_require__(1194);\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');\n\n// `Array.prototype.map` method\n// https://tc39.es/ecma262/#sec-array.prototype.map\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {\n map: function map(callbackfn /* , thisArg */) {\n return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTI0OS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuYXJyYXkubWFwLmpzP2Q4MWQiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyICQgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZXhwb3J0Jyk7XG52YXIgJG1hcCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hcnJheS1pdGVyYXRpb24nKS5tYXA7XG52YXIgYXJyYXlNZXRob2RIYXNTcGVjaWVzU3VwcG9ydCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9hcnJheS1tZXRob2QtaGFzLXNwZWNpZXMtc3VwcG9ydCcpO1xuXG52YXIgSEFTX1NQRUNJRVNfU1VQUE9SVCA9IGFycmF5TWV0aG9kSGFzU3BlY2llc1N1cHBvcnQoJ21hcCcpO1xuXG4vLyBgQXJyYXkucHJvdG90eXBlLm1hcGAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWFycmF5LnByb3RvdHlwZS5tYXBcbi8vIHdpdGggYWRkaW5nIHN1cHBvcnQgb2YgQEBzcGVjaWVzXG4kKHsgdGFyZ2V0OiAnQXJyYXknLCBwcm90bzogdHJ1ZSwgZm9yY2VkOiAhSEFTX1NQRUNJRVNfU1VQUE9SVCB9LCB7XG4gIG1hcDogZnVuY3Rpb24gbWFwKGNhbGxiYWNrZm4gLyogLCB0aGlzQXJnICovKSB7XG4gICAgcmV0dXJuICRtYXAodGhpcywgY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpO1xuICB9XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1249\n")},7042:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar isObject = __webpack_require__(111);\nvar isArray = __webpack_require__(3157);\nvar toAbsoluteIndex = __webpack_require__(1400);\nvar toLength = __webpack_require__(7466);\nvar toIndexedObject = __webpack_require__(5656);\nvar createProperty = __webpack_require__(6135);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar arrayMethodHasSpeciesSupport = __webpack_require__(1194);\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');\n\nvar SPECIES = wellKnownSymbol('species');\nvar nativeSlice = [].slice;\nvar max = Math.max;\n\n// `Array.prototype.slice` method\n// https://tc39.es/ecma262/#sec-array.prototype.slice\n// fallback for not array-like ES3 strings and DOM objects\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {\n slice: function slice(start, end) {\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var k = toAbsoluteIndex(start, length);\n var fin = toAbsoluteIndex(end === undefined ? length : end, length);\n // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible\n var Constructor, result, n;\n if (isArray(O)) {\n Constructor = O.constructor;\n // cross-realm fallback\n if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {\n Constructor = undefined;\n } else if (isObject(Constructor)) {\n Constructor = Constructor[SPECIES];\n if (Constructor === null) Constructor = undefined;\n }\n if (Constructor === Array || Constructor === undefined) {\n return nativeSlice.call(O, k, fin);\n }\n }\n result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));\n for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);\n result.length = n;\n return result;\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzA0Mi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2R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iamVjdChDb25zdHJ1Y3RvcikpIHtcbiAgICAgICAgQ29uc3RydWN0b3IgPSBDb25zdHJ1Y3RvcltTUEVDSUVTXTtcbiAgICAgICAgaWYgKENvbnN0cnVjdG9yID09PSBudWxsKSBDb25zdHJ1Y3RvciA9IHVuZGVmaW5lZDtcbiAgICAgIH1cbiAgICAgIGlmIChDb25zdHJ1Y3RvciA9PT0gQXJyYXkgfHwgQ29uc3RydWN0b3IgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICByZXR1cm4gbmF0aXZlU2xpY2UuY2FsbChPLCBrLCBmaW4pO1xuICAgICAgfVxuICAgIH1cbiAgICByZXN1bHQgPSBuZXcgKENvbnN0cnVjdG9yID09PSB1bmRlZmluZWQgPyBBcnJheSA6IENvbnN0cnVjdG9yKShtYXgoZmluIC0gaywgMCkpO1xuICAgIGZvciAobiA9IDA7IGsgPCBmaW47IGsrKywgbisrKSBpZiAoayBpbiBPKSBjcmVhdGVQcm9wZXJ0eShyZXN1bHQsIG4sIE9ba10pO1xuICAgIHJlc3VsdC5sZW5ndGggPSBuO1xuICAgIHJldHVybiByZXN1bHQ7XG4gIH1cbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///7042\n")},561:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar toAbsoluteIndex = __webpack_require__(1400);\nvar toInteger = __webpack_require__(9958);\nvar toLength = __webpack_require__(7466);\nvar toObject = __webpack_require__(7908);\nvar arraySpeciesCreate = __webpack_require__(5417);\nvar createProperty = __webpack_require__(6135);\nvar arrayMethodHasSpeciesSupport = __webpack_require__(1194);\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');\n\nvar max = Math.max;\nvar min = Math.min;\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';\n\n// `Array.prototype.splice` method\n// https://tc39.es/ecma262/#sec-array.prototype.splice\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {\n splice: function splice(start, deleteCount /* , ...items */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var actualStart = toAbsoluteIndex(start, len);\n var argumentsLength = arguments.length;\n var insertCount, actualDeleteCount, A, k, from, to;\n if (argumentsLength === 0) {\n insertCount = actualDeleteCount = 0;\n } else if (argumentsLength === 1) {\n insertCount = 0;\n actualDeleteCount = len - actualStart;\n } else {\n insertCount = argumentsLength - 2;\n actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);\n }\n if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {\n throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);\n }\n A = arraySpeciesCreate(O, actualDeleteCount);\n for (k = 0; k < actualDeleteCount; k++) {\n from = actualStart + k;\n if (from in O) createProperty(A, k, O[from]);\n }\n A.length = actualDeleteCount;\n if (insertCount < actualDeleteCount) {\n for (k = actualStart; k < len - actualDeleteCount; k++) {\n from = k + actualDeleteCount;\n to = k + insertCount;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];\n } else if (insertCount > actualDeleteCount) {\n for (k = len - actualDeleteCount; k > actualStart; k--) {\n from = k + actualDeleteCount - 1;\n to = k + insertCount - 1;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n }\n for (k = 0; k < insertCount; k++) {\n O[k + actualStart] = arguments[k + 2];\n }\n O.length = len - actualDeleteCount + insertCount;\n return A;\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTYxLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFD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IGFjdHVhbERlbGV0ZUNvdW50OyBrKyspIHtcbiAgICAgICAgZnJvbSA9IGsgKyBhY3R1YWxEZWxldGVDb3VudDtcbiAgICAgICAgdG8gPSBrICsgaW5zZXJ0Q291bnQ7XG4gICAgICAgIGlmIChmcm9tIGluIE8pIE9bdG9dID0gT1tmcm9tXTtcbiAgICAgICAgZWxzZSBkZWxldGUgT1t0b107XG4gICAgICB9XG4gICAgICBmb3IgKGsgPSBsZW47IGsgPiBsZW4gLSBhY3R1YWxEZWxldGVDb3VudCArIGluc2VydENvdW50OyBrLS0pIGRlbGV0ZSBPW2sgLSAxXTtcbiAgICB9IGVsc2UgaWYgKGluc2VydENvdW50ID4gYWN0dWFsRGVsZXRlQ291bnQpIHtcbiAgICAgIGZvciAoayA9IGxlbiAtIGFjdHVhbERlbGV0ZUNvdW50OyBrID4gYWN0dWFsU3RhcnQ7IGstLSkge1xuICAgICAgICBmcm9tID0gayArIGFjdHVhbERlbGV0ZUNvdW50IC0gMTtcbiAgICAgICAgdG8gPSBrICsgaW5zZXJ0Q291bnQgLSAxO1xuICAgICAgICBpZiAoZnJvbSBpbiBPKSBPW3RvXSA9IE9bZnJvbV07XG4gICAgICAgIGVsc2UgZGVsZXRlIE9bdG9dO1xuICAgICAgfVxuICAgIH1cbiAgICBmb3IgKGsgPSAwOyBrIDwgaW5zZXJ0Q291bnQ7IGsrKykge1xuICAgICAgT1trICsgYWN0dWFsU3RhcnRdID0gYXJndW1lbnRzW2sgKyAyXTtcbiAgICB9XG4gICAgTy5sZW5ndGggPSBsZW4gLSBhY3R1YWxEZWxldGVDb3VudCArIGluc2VydENvdW50O1xuICAgIHJldHVybiBBO1xuICB9XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///561\n")},8309:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var DESCRIPTORS = __webpack_require__(9781);\nvar defineProperty = __webpack_require__(3070).f;\n\nvar FunctionPrototype = Function.prototype;\nvar FunctionPrototypeToString = FunctionPrototype.toString;\nvar nameRE = /^\\s*function ([^ (]*)/;\nvar NAME = 'name';\n\n// Function instances `.name` property\n// https://tc39.es/ecma262/#sec-function-instances-name\nif (DESCRIPTORS && !(NAME in FunctionPrototype)) {\n defineProperty(FunctionPrototype, NAME, {\n configurable: true,\n get: function () {\n try {\n return FunctionPrototypeToString.call(this).match(nameRE)[1];\n } catch (error) {\n return '';\n }\n }\n });\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODMwOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy9lcy5mdW5jdGlvbi5uYW1lLmpzP2IwYzAiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIERFU0NSSVBUT1JTID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2Rlc2NyaXB0b3JzJyk7XG52YXIgZGVmaW5lUHJvcGVydHkgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvb2JqZWN0LWRlZmluZS1wcm9wZXJ0eScpLmY7XG5cbnZhciBGdW5jdGlvblByb3RvdHlwZSA9IEZ1bmN0aW9uLnByb3RvdHlwZTtcbnZhciBGdW5jdGlvblByb3RvdHlwZVRvU3RyaW5nID0gRnVuY3Rpb25Qcm90b3R5cGUudG9TdHJpbmc7XG52YXIgbmFtZVJFID0gL15cXHMqZnVuY3Rpb24gKFteIChdKikvO1xudmFyIE5BTUUgPSAnbmFtZSc7XG5cbi8vIEZ1bmN0aW9uIGluc3RhbmNlcyBgLm5hbWVgIHByb3BlcnR5XG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLWZ1bmN0aW9uLWluc3RhbmNlcy1uYW1lXG5pZiAoREVTQ1JJUFRPUlMgJiYgIShOQU1FIGluIEZ1bmN0aW9uUHJvdG90eXBlKSkge1xuICBkZWZpbmVQcm9wZXJ0eShGdW5jdGlvblByb3RvdHlwZSwgTkFNRSwge1xuICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcbiAgICAgIHRyeSB7XG4gICAgICAgIHJldHVybiBGdW5jdGlvblByb3RvdHlwZVRvU3RyaW5nLmNhbGwodGhpcykubWF0Y2gobmFtZVJFKVsxXTtcbiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIHJldHVybiAnJztcbiAgICAgIH1cbiAgICB9XG4gIH0pO1xufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///8309\n")},9653:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar DESCRIPTORS = __webpack_require__(9781);\nvar global = __webpack_require__(7854);\nvar isForced = __webpack_require__(4705);\nvar redefine = __webpack_require__(1320);\nvar has = __webpack_require__(6656);\nvar classof = __webpack_require__(4326);\nvar inheritIfRequired = __webpack_require__(9587);\nvar isSymbol = __webpack_require__(2190);\nvar toPrimitive = __webpack_require__(7593);\nvar fails = __webpack_require__(7293);\nvar create = __webpack_require__(30);\nvar getOwnPropertyNames = __webpack_require__(8006).f;\nvar getOwnPropertyDescriptor = __webpack_require__(1236).f;\nvar defineProperty = __webpack_require__(3070).f;\nvar trim = __webpack_require__(3111).trim;\n\nvar NUMBER = 'Number';\nvar NativeNumber = global[NUMBER];\nvar NumberPrototype = NativeNumber.prototype;\n\n// Opera ~12 has broken Object#toString\nvar BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER;\n\n// `ToNumber` abstract operation\n// https://tc39.es/ecma262/#sec-tonumber\nvar toNumber = function (argument) {\n if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a number');\n var it = toPrimitive(argument, 'number');\n var first, third, radix, maxCode, digits, length, index, code;\n if (typeof it == 'string' && it.length > 2) {\n it = trim(it);\n first = it.charCodeAt(0);\n if (first === 43 || first === 45) {\n third = it.charCodeAt(2);\n if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix\n } else if (first === 48) {\n switch (it.charCodeAt(1)) {\n case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i\n case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i\n default: return +it;\n }\n digits = it.slice(2);\n length = digits.length;\n for (index = 0; index < length; index++) {\n code = digits.charCodeAt(index);\n // parseInt parses a string to a first unavailable symbol\n // but ToNumber should return NaN if a string contains unavailable symbols\n if (code < 48 || code > maxCode) return NaN;\n } return parseInt(digits, radix);\n }\n } return +it;\n};\n\n// `Number` constructor\n// https://tc39.es/ecma262/#sec-number-constructor\nif (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {\n var NumberWrapper = function Number(value) {\n var it = arguments.length < 1 ? 0 : value;\n var dummy = this;\n return dummy instanceof NumberWrapper\n // check on 1..constructor(foo) case\n && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classof(dummy) != NUMBER)\n ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);\n };\n for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : (\n // ES3:\n 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +\n // ES2015 (in case, if modules with ES2015 Number statics required before):\n 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +\n 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' +\n // ESNext\n 'fromString,range'\n ).split(','), j = 0, key; keys.length > j; j++) {\n if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {\n defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));\n }\n }\n NumberWrapper.prototype = NumberPrototype;\n NumberPrototype.constructor = NumberWrapper;\n redefine(global, NUMBER, NumberWrapper);\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiOTY1My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy9lcy5udW1iZXIuY29uc3RydWN0b3IuanM/YTllMyJdL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FNJTE9OLGlzRmluaXRlLGlzSW50ZWdlcixpc05hTixpc1NhZmVJbnRlZ2VyLE1BWF9TQUZFX0lOVEVHRVIsJyArXG4gICAgJ01JTl9TQUZFX0lOVEVHRVIscGFyc2VGbG9hdCxwYXJzZUludCxpc0ludGVnZXIsJyArXG4gICAgLy8gRVNOZXh0XG4gICAgJ2Zyb21TdHJpbmcscmFuZ2UnXG4gICkuc3BsaXQoJywnKSwgaiA9IDAsIGtleTsga2V5cy5sZW5ndGggPiBqOyBqKyspIHtcbiAgICBpZiAoaGFzKE5hdGl2ZU51bWJlciwga2V5ID0ga2V5c1tqXSkgJiYgIWhhcyhOdW1iZXJXcmFwcGVyLCBrZXkpKSB7XG4gICAgICBkZWZpbmVQcm9wZXJ0eShOdW1iZXJXcmFwcGVyLCBrZXksIGdldE93blByb3BlcnR5RGVzY3JpcHRvcihOYXRpdmVOdW1iZXIsIGtleSkpO1xuICAgIH1cbiAgfVxuICBOdW1iZXJXcmFwcGVyLnByb3RvdHlwZSA9IE51bWJlclByb3RvdHlwZTtcbiAgTnVtYmVyUHJvdG90eXBlLmNvbnN0cnVjdG9yID0gTnVtYmVyV3JhcHBlcjtcbiAgcmVkZWZpbmUoZ2xvYmFsLCBOVU1CRVIsIE51bWJlcldyYXBwZXIpO1xufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9653\n")},1539:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var TO_STRING_TAG_SUPPORT = __webpack_require__(1694);\nvar redefine = __webpack_require__(1320);\nvar toString = __webpack_require__(288);\n\n// `Object.prototype.toString` method\n// https://tc39.es/ecma262/#sec-object.prototype.tostring\nif (!TO_STRING_TAG_SUPPORT) {\n redefine(Object.prototype, 'toString', toString, { unsafe: true });\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTUzOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMub2JqZWN0LnRvLXN0cmluZy5qcz9kM2I3Il0sInNvdXJjZXNDb250ZW50IjpbInZhciBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvdG8tc3RyaW5nLXRhZy1zdXBwb3J0Jyk7XG52YXIgcmVkZWZpbmUgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvcmVkZWZpbmUnKTtcbnZhciB0b1N0cmluZyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9vYmplY3QtdG8tc3RyaW5nJyk7XG5cbi8vIGBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nYCBtZXRob2Rcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtb2JqZWN0LnByb3RvdHlwZS50b3N0cmluZ1xuaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHtcbiAgcmVkZWZpbmUoT2JqZWN0LnByb3RvdHlwZSwgJ3RvU3RyaW5nJywgdG9TdHJpbmcsIHsgdW5zYWZlOiB0cnVlIH0pO1xufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1539\n")},1058:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var $ = __webpack_require__(2109);\nvar parseIntImplementation = __webpack_require__(3009);\n\n// `parseInt` method\n// https://tc39.es/ecma262/#sec-parseint-string-radix\n$({ global: true, forced: parseInt != parseIntImplementation }, {\n parseInt: parseIntImplementation\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTA1OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLnBhcnNlLWludC5qcz9lMjVlIl0sInNvdXJjZXNDb250ZW50IjpbInZhciAkID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL2V4cG9ydCcpO1xudmFyIHBhcnNlSW50SW1wbGVtZW50YXRpb24gPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvbnVtYmVyLXBhcnNlLWludCcpO1xuXG4vLyBgcGFyc2VJbnRgIG1ldGhvZFxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1wYXJzZWludC1zdHJpbmctcmFkaXhcbiQoeyBnbG9iYWw6IHRydWUsIGZvcmNlZDogcGFyc2VJbnQgIT0gcGFyc2VJbnRJbXBsZW1lbnRhdGlvbiB9LCB7XG4gIHBhcnNlSW50OiBwYXJzZUludEltcGxlbWVudGF0aW9uXG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1058\n")},8674:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar IS_PURE = __webpack_require__(1913);\nvar global = __webpack_require__(7854);\nvar getBuiltIn = __webpack_require__(5005);\nvar NativePromise = __webpack_require__(3366);\nvar redefine = __webpack_require__(1320);\nvar redefineAll = __webpack_require__(2248);\nvar setPrototypeOf = __webpack_require__(7674);\nvar setToStringTag = __webpack_require__(8003);\nvar setSpecies = __webpack_require__(6340);\nvar isObject = __webpack_require__(111);\nvar aFunction = __webpack_require__(3099);\nvar anInstance = __webpack_require__(5787);\nvar inspectSource = __webpack_require__(2788);\nvar iterate = __webpack_require__(408);\nvar checkCorrectnessOfIteration = __webpack_require__(7072);\nvar speciesConstructor = __webpack_require__(6707);\nvar task = __webpack_require__(261).set;\nvar microtask = __webpack_require__(5948);\nvar promiseResolve = __webpack_require__(9478);\nvar hostReportErrors = __webpack_require__(842);\nvar newPromiseCapabilityModule = __webpack_require__(8523);\nvar perform = __webpack_require__(2534);\nvar InternalStateModule = __webpack_require__(9909);\nvar isForced = __webpack_require__(4705);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar IS_BROWSER = __webpack_require__(7871);\nvar IS_NODE = __webpack_require__(5268);\nvar V8_VERSION = __webpack_require__(7392);\n\nvar SPECIES = wellKnownSymbol('species');\nvar PROMISE = 'Promise';\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar getInternalPromiseState = InternalStateModule.getterFor(PROMISE);\nvar NativePromisePrototype = NativePromise && NativePromise.prototype;\nvar PromiseConstructor = NativePromise;\nvar PromiseConstructorPrototype = NativePromisePrototype;\nvar TypeError = global.TypeError;\nvar document = global.document;\nvar process = global.process;\nvar newPromiseCapability = newPromiseCapabilityModule.f;\nvar newGenericPromiseCapability = newPromiseCapability;\nvar DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);\nvar NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function';\nvar UNHANDLED_REJECTION = 'unhandledrejection';\nvar REJECTION_HANDLED = 'rejectionhandled';\nvar PENDING = 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\nvar HANDLED = 1;\nvar UNHANDLED = 2;\nvar SUBCLASSING = false;\nvar Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;\n\nvar FORCED = isForced(PROMISE, function () {\n var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor);\n var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor);\n // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables\n // https://bugs.chromium.org/p/chromium/issues/detail?id=830565\n // We can't detect it synchronously, so just check versions\n if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;\n // We need Promise#finally in the pure version for preventing prototype pollution\n if (IS_PURE && !PromiseConstructorPrototype['finally']) return true;\n // We can't use @@species feature detection in V8 since it causes\n // deoptimization and performance degradation\n // https://github.com/zloirock/core-js/issues/679\n if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false;\n // Detect correctness of subclassing with @@species support\n var promise = new PromiseConstructor(function (resolve) { resolve(1); });\n var FakePromise = function (exec) {\n exec(function () { /* empty */ }, function () { /* empty */ });\n };\n var constructor = promise.constructor = {};\n constructor[SPECIES] = FakePromise;\n SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;\n if (!SUBCLASSING) return true;\n // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT;\n});\n\nvar INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {\n PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });\n});\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\n\nvar notify = function (state, isReject) {\n if (state.notified) return;\n state.notified = true;\n var chain = state.reactions;\n microtask(function () {\n var value = state.value;\n var ok = state.state == FULFILLED;\n var index = 0;\n // variable length - can't use forEach\n while (chain.length > index) {\n var reaction = chain[index++];\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (state.rejection === UNHANDLED) onHandleUnhandled(state);\n state.rejection = HANDLED;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // can throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (error) {\n if (domain && !exited) domain.exit();\n reject(error);\n }\n }\n state.reactions = [];\n state.notified = false;\n if (isReject && !state.rejection) onUnhandled(state);\n });\n};\n\nvar dispatchEvent = function (name, promise, reason) {\n var event, handler;\n if (DISPATCH_EVENT) {\n event = document.createEvent('Event');\n event.promise = promise;\n event.reason = reason;\n event.initEvent(name, false, true);\n global.dispatchEvent(event);\n } else event = { promise: promise, reason: reason };\n if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);\n else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);\n};\n\nvar onUnhandled = function (state) {\n task.call(global, function () {\n var promise = state.facade;\n var value = state.value;\n var IS_UNHANDLED = isUnhandled(state);\n var result;\n if (IS_UNHANDLED) {\n result = perform(function () {\n if (IS_NODE) {\n process.emit('unhandledRejection', value, promise);\n } else dispatchEvent(UNHANDLED_REJECTION, promise, value);\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;\n if (result.error) throw result.value;\n }\n });\n};\n\nvar isUnhandled = function (state) {\n return state.rejection !== HANDLED && !state.parent;\n};\n\nvar onHandleUnhandled = function (state) {\n task.call(global, function () {\n var promise = state.facade;\n if (IS_NODE) {\n process.emit('rejectionHandled', promise);\n } else dispatchEvent(REJECTION_HANDLED, promise, state.value);\n });\n};\n\nvar bind = function (fn, state, unwrap) {\n return function (value) {\n fn(state, value, unwrap);\n };\n};\n\nvar internalReject = function (state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n state.value = value;\n state.state = REJECTED;\n notify(state, true);\n};\n\nvar internalResolve = function (state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n try {\n if (state.facade === value) throw TypeError(\"Promise can't be resolved itself\");\n var then = isThenable(value);\n if (then) {\n microtask(function () {\n var wrapper = { done: false };\n try {\n then.call(value,\n bind(internalResolve, wrapper, state),\n bind(internalReject, wrapper, state)\n );\n } catch (error) {\n internalReject(wrapper, error, state);\n }\n });\n } else {\n state.value = value;\n state.state = FULFILLED;\n notify(state, false);\n }\n } catch (error) {\n internalReject({ done: false }, error, state);\n }\n};\n\n// constructor polyfill\nif (FORCED) {\n // 25.4.3.1 Promise(executor)\n PromiseConstructor = function Promise(executor) {\n anInstance(this, PromiseConstructor, PROMISE);\n aFunction(executor);\n Internal.call(this);\n var state = getInternalState(this);\n try {\n executor(bind(internalResolve, state), bind(internalReject, state));\n } catch (error) {\n internalReject(state, error);\n }\n };\n PromiseConstructorPrototype = PromiseConstructor.prototype;\n // eslint-disable-next-line no-unused-vars -- required for `.length`\n Internal = function Promise(executor) {\n setInternalState(this, {\n type: PROMISE,\n done: false,\n notified: false,\n parent: false,\n reactions: [],\n rejection: false,\n state: PENDING,\n value: undefined\n });\n };\n Internal.prototype = redefineAll(PromiseConstructorPrototype, {\n // `Promise.prototype.then` method\n // https://tc39.es/ecma262/#sec-promise.prototype.then\n then: function then(onFulfilled, onRejected) {\n var state = getInternalPromiseState(this);\n var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = IS_NODE ? process.domain : undefined;\n state.parent = true;\n state.reactions.push(reaction);\n if (state.state != PENDING) notify(state, false);\n return reaction.promise;\n },\n // `Promise.prototype.catch` method\n // https://tc39.es/ecma262/#sec-promise.prototype.catch\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n var state = getInternalState(promise);\n this.promise = promise;\n this.resolve = bind(internalResolve, state);\n this.reject = bind(internalReject, state);\n };\n newPromiseCapabilityModule.f = newPromiseCapability = function (C) {\n return C === PromiseConstructor || C === PromiseWrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n\n if (!IS_PURE && typeof NativePromise == 'function' && NativePromisePrototype !== Object.prototype) {\n nativeThen = NativePromisePrototype.then;\n\n if (!SUBCLASSING) {\n // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs\n redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {\n var that = this;\n return new PromiseConstructor(function (resolve, reject) {\n nativeThen.call(that, resolve, reject);\n }).then(onFulfilled, onRejected);\n // https://github.com/zloirock/core-js/issues/640\n }, { unsafe: true });\n\n // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`\n redefine(NativePromisePrototype, 'catch', PromiseConstructorPrototype['catch'], { unsafe: true });\n }\n\n // make `.constructor === Promise` work for native promise-based APIs\n try {\n delete NativePromisePrototype.constructor;\n } catch (error) { /* empty */ }\n\n // make `instanceof Promise` work for native promise-based APIs\n if (setPrototypeOf) {\n setPrototypeOf(NativePromisePrototype, PromiseConstructorPrototype);\n }\n }\n}\n\n$({ global: true, wrap: true, forced: FORCED }, {\n Promise: PromiseConstructor\n});\n\nsetToStringTag(PromiseConstructor, PROMISE, false, true);\nsetSpecies(PROMISE);\n\nPromiseWrapper = getBuiltIn(PROMISE);\n\n// statics\n$({ target: PROMISE, stat: true, forced: FORCED }, {\n // `Promise.reject` method\n // https://tc39.es/ecma262/#sec-promise.reject\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n capability.reject.call(undefined, r);\n return capability.promise;\n }\n});\n\n$({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {\n // `Promise.resolve` method\n // https://tc39.es/ecma262/#sec-promise.resolve\n resolve: function resolve(x) {\n return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);\n }\n});\n\n$({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {\n // `Promise.all` method\n // https://tc39.es/ecma262/#sec-promise.all\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n var values = [];\n var counter = 0;\n var remaining = 1;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n $promiseResolve.call(C, promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.error) reject(result.value);\n return capability.promise;\n },\n // `Promise.race` method\n // https://tc39.es/ecma262/#sec-promise.race\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n iterate(iterable, function (promise) {\n $promiseResolve.call(C, promise).then(capability.resolve, reject);\n });\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODY3NC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Q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ICB9XG4gICAgICAgICAgaWYgKGhhbmRsZXIgPT09IHRydWUpIHJlc3VsdCA9IHZhbHVlO1xuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKGRvbWFpbikgZG9tYWluLmVudGVyKCk7XG4gICAgICAgICAgICByZXN1bHQgPSBoYW5kbGVyKHZhbHVlKTsgLy8gY2FuIHRocm93XG4gICAgICAgICAgICBpZiAoZG9tYWluKSB7XG4gICAgICAgICAgICAgIGRvbWFpbi5leGl0KCk7XG4gICAgICAgICAgICAgIGV4aXRlZCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChyZXN1bHQgPT09IHJlYWN0aW9uLnByb21pc2UpIHtcbiAgICAgICAgICAgIHJlamVjdChUeXBlRXJyb3IoJ1Byb21pc2UtY2hhaW4gY3ljbGUnKSk7XG4gICAgICAgICAgfSBlbHNlIGlmICh0aGVuID0gaXNUaGVuYWJsZShyZXN1bHQpKSB7XG4gICAgICAgICAgICB0aGVuLmNhbGwocmVzdWx0LCByZXNvbHZlLCByZWplY3QpO1xuICAgICAgICAgIH0gZWxzZSByZXNvbHZlKHJlc3VsdCk7XG4gICAgICAgIH0gZWxzZSByZWplY3QodmFsdWUpO1xuICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgaWYgKGRvbWFpbiAmJiAhZXhpdGVkKSBkb21haW4uZXhpdCgpO1xuICAgICAgICByZWplY3QoZXJyb3IpO1xuICAgICAgfVxuICAgIH1cbiAgICBzdGF0ZS5yZWFjdGlvbnMgPSBbXTtcbiAgICBzdGF0ZS5ub3RpZmllZCA9IGZhbHNlO1xuICAgIGlmIChpc1JlamVjdCAmJiAhc3RhdGUucmVqZWN0aW9uKSBvblVuaGFuZGxlZChzdGF0ZSk7XG4gIH0pO1xufTtcblxudmFyIGRpc3BhdGNoRXZlbnQgPSBmdW5jdGlvbiAobmFtZSwgcHJvbWlzZSwgcmVhc29uKSB7XG4gIHZhci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eS5yZWplY3Q7XG4gICAgdmFyIHJlc3VsdCA9IHBlcmZvcm0oZnVuY3Rpb24gKCkge1xuICAgICAgdmFyICRwcm9taXNlUmVzb2x2ZSA9IGFGdW5jdGlvbihDLnJlc29sdmUpO1xuICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgZnVuY3Rpb24gKHByb21pc2UpIHtcbiAgICAgICAgJHByb21pc2VSZXNvbHZlLmNhbGwoQywgcHJvbWlzZSkudGhlbihjYXBhYmlsaXR5LnJlc29sdmUsIHJlamVjdCk7XG4gICAgICB9KTtcbiAgICB9KTtcbiAgICBpZiAocmVzdWx0LmVycm9yKSByZWplY3QocmVzdWx0LnZhbHVlKTtcbiAgICByZXR1cm4gY2FwYWJpbGl0eS5wcm9taXNlO1xuICB9XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8674\n")},4916:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar exec = __webpack_require__(2261);\n\n// `RegExp.prototype.exec` method\n// https://tc39.es/ecma262/#sec-regexp.prototype.exec\n$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {\n exec: exec\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDkxNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMucmVnZXhwLmV4ZWMuanM/YWMxZiJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgJCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9leHBvcnQnKTtcbnZhciBleGVjID0gcmVxdWlyZSgnLi4vaW50ZXJuYWxzL3JlZ2V4cC1leGVjJyk7XG5cbi8vIGBSZWdFeHAucHJvdG90eXBlLmV4ZWNgIG1ldGhvZFxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1yZWdleHAucHJvdG90eXBlLmV4ZWNcbiQoeyB0YXJnZXQ6ICdSZWdFeHAnLCBwcm90bzogdHJ1ZSwgZm9yY2VkOiAvLi8uZXhlYyAhPT0gZXhlYyB9LCB7XG4gIGV4ZWM6IGV4ZWNcbn0pO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///4916\n")},189:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar collection = __webpack_require__(7710);\nvar collectionStrong = __webpack_require__(5631);\n\n// `Set` constructor\n// https://tc39.es/ecma262/#sec-set-objects\nmodule.exports = collection('Set', function (init) {\n return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionStrong);\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTg5LmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZXMiOlsid2VicGFjazovL3hsc3hfdHJhbnNmb3JtLy4vbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy9lcy5zZXQuanM/NjA2MiJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgY29sbGVjdGlvbiA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9jb2xsZWN0aW9uJyk7XG52YXIgY29sbGVjdGlvblN0cm9uZyA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9jb2xsZWN0aW9uLXN0cm9uZycpO1xuXG4vLyBgU2V0YCBjb25zdHJ1Y3RvclxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1zZXQtb2JqZWN0c1xubW9kdWxlLmV4cG9ydHMgPSBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkge1xuICByZXR1cm4gZnVuY3Rpb24gU2V0KCkgeyByZXR1cm4gaW5pdCh0aGlzLCBhcmd1bWVudHMubGVuZ3RoID8gYXJndW1lbnRzWzBdIDogdW5kZWZpbmVkKTsgfTtcbn0sIGNvbGxlY3Rpb25TdHJvbmcpO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///189\n")},2023:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar notARegExp = __webpack_require__(3929);\nvar requireObjectCoercible = __webpack_require__(4488);\nvar toString = __webpack_require__(1340);\nvar correctIsRegExpLogic = __webpack_require__(4964);\n\n// `String.prototype.includes` method\n// https://tc39.es/ecma262/#sec-string.prototype.includes\n$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {\n includes: function includes(searchString /* , position = 0 */) {\n return !!~toString(requireObjectCoercible(this))\n .indexOf(toString(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjAyMy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuc3RyaW5nLmluY2x1ZGVzLmpzPzI1MzIiXSwic291cmNlc0NvbnRlbnQiOlsiJ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pack_exports,__webpack_require__)=>{"use strict";eval("\nvar charAt = __webpack_require__(8710).charAt;\nvar toString = __webpack_require__(1340);\nvar InternalStateModule = __webpack_require__(9909);\nvar defineIterator = __webpack_require__(654);\n\nvar STRING_ITERATOR = 'String Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);\n\n// `String.prototype[@@iterator]` method\n// https://tc39.es/ecma262/#sec-string.prototype-@@iterator\ndefineIterator(String, 'String', function (iterated) {\n setInternalState(this, {\n type: STRING_ITERATOR,\n string: toString(iterated),\n index: 0\n });\n// `%StringIteratorPrototype%.next` method\n// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next\n}, function next() {\n var state = getInternalState(this);\n var string = state.string;\n var index = state.index;\n var point;\n if (index >= string.length) return { value: undefined, done: true };\n point = charAt(string, index);\n state.index += point.length;\n return { value: point, done: false };\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODc4My5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuc3RyaW5nLml0ZXJhdG9yLmpzPzNjYTMiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyIGNoYXJBdCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zdHJpbmctbXVsdGlieXRlJykuY2hhckF0O1xudmFyIH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3RyaW5nO1xuICB2YXIgaW5kZXggPSBzdGF0ZS5pbmRleDtcbiAgdmFyIHBvaW50O1xuICBpZiAoaW5kZXggPj0gc3RyaW5nLmxlbmd0aCkgcmV0dXJuIHsgdmFsdWU6IHVuZGVmaW5lZCwgZG9uZTogdHJ1ZSB9O1xuICBwb2ludCA9IGNoYXJBdChzdHJpbmcsIGluZGV4KTtcbiAgc3RhdGUuaW5kZXggKz0gcG9pbnQubGVuZ3RoO1xuICByZXR1cm4geyB2YWx1ZTogcG9pbnQsIGRvbmU6IGZhbHNlIH07XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8783\n")},4765:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar fixRegExpWellKnownSymbolLogic = __webpack_require__(7007);\nvar anObject = __webpack_require__(9670);\nvar requireObjectCoercible = __webpack_require__(4488);\nvar sameValue = __webpack_require__(1150);\nvar toString = __webpack_require__(1340);\nvar regExpExec = __webpack_require__(7651);\n\n// @@search logic\nfixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCallNative) {\n return [\n // `String.prototype.search` method\n // https://tc39.es/ecma262/#sec-string.prototype.search\n function search(regexp) {\n var O = requireObjectCoercible(this);\n var searcher = regexp == undefined ? undefined : regexp[SEARCH];\n return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](toString(O));\n },\n // `RegExp.prototype[@@search]` method\n // https://tc39.es/ecma262/#sec-regexp.prototype-@@search\n function (string) {\n var rx = anObject(this);\n var S = toString(string);\n var res = maybeCallNative(nativeSearch, rx, S);\n\n if (res.done) return res.value;\n\n var previousLastIndex = rx.lastIndex;\n if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;\n var result = regExpExec(rx, S);\n if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;\n return result === null ? -1 : result.index;\n }\n ];\n});\n//# sourceURL=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lmICghc2FtZVZhbHVlKHByZXZpb3VzTGFzdEluZGV4LCAwKSkgcngubGFzdEluZGV4ID0gMDtcbiAgICAgIHZhciByZXN1bHQgPSByZWdFeHBFeGVjKHJ4LCBTKTtcbiAgICAgIGlmICghc2FtZVZhbHVlKHJ4Lmxhc3RJbmRleCwgcHJldmlvdXNMYXN0SW5kZXgpKSByeC5sYXN0SW5kZXggPSBwcmV2aW91c0xhc3RJbmRleDtcbiAgICAgIHJldHVybiByZXN1bHQgPT09IG51bGwgPyAtMSA6IHJlc3VsdC5pbmRleDtcbiAgICB9XG4gIF07XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4765\n")},3123:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar fixRegExpWellKnownSymbolLogic = __webpack_require__(7007);\nvar isRegExp = __webpack_require__(7850);\nvar anObject = __webpack_require__(9670);\nvar requireObjectCoercible = __webpack_require__(4488);\nvar speciesConstructor = __webpack_require__(6707);\nvar advanceStringIndex = __webpack_require__(1530);\nvar toLength = __webpack_require__(7466);\nvar toString = __webpack_require__(1340);\nvar callRegExpExec = __webpack_require__(7651);\nvar regexpExec = __webpack_require__(2261);\nvar stickyHelpers = __webpack_require__(2999);\nvar fails = __webpack_require__(7293);\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;\nvar arrayPush = [].push;\nvar min = Math.min;\nvar MAX_UINT32 = 0xFFFFFFFF;\n\n// Chrome 51 has a buggy \"split\" implementation when RegExp#exec !== nativeExec\n// Weex JS has frozen built-in prototypes, so use try / catch wrapper\nvar SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {\n // eslint-disable-next-line regexp/no-empty-group -- required for testing\n var re = /(?:)/;\n var originalExec = re.exec;\n re.exec = function () { return originalExec.apply(this, arguments); };\n var result = 'ab'.split(re);\n return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';\n});\n\n// @@split logic\nfixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {\n var internalSplit;\n if (\n 'abbc'.split(/(b)*/)[1] == 'c' ||\n // eslint-disable-next-line regexp/no-empty-group -- required for testing\n 'test'.split(/(?:)/, -1).length != 4 ||\n 'ab'.split(/(?:ab)*/).length != 2 ||\n '.'.split(/(.?)(.?)/).length != 4 ||\n // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing\n '.'.split(/()()/).length > 1 ||\n ''.split(/.?/).length\n ) {\n // based on es5-shim implementation, need to rework it\n internalSplit = function (separator, limit) {\n var string = toString(requireObjectCoercible(this));\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (separator === undefined) return [string];\n // If `separator` is not a regex, use native split\n if (!isRegExp(separator)) {\n return nativeSplit.call(string, separator, lim);\n }\n var output = [];\n var flags = (separator.ignoreCase ? 'i' : '') +\n (separator.multiline ? 'm' : '') +\n (separator.unicode ? 'u' : '') +\n (separator.sticky ? 'y' : '');\n var lastLastIndex = 0;\n // Make `global` and avoid `lastIndex` issues by working with a copy\n var separatorCopy = new RegExp(separator.source, flags + 'g');\n var match, lastIndex, lastLength;\n while (match = regexpExec.call(separatorCopy, string)) {\n lastIndex = separatorCopy.lastIndex;\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index));\n if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));\n lastLength = match[0].length;\n lastLastIndex = lastIndex;\n if (output.length >= lim) break;\n }\n if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop\n }\n if (lastLastIndex === string.length) {\n if (lastLength || !separatorCopy.test('')) output.push('');\n } else output.push(string.slice(lastLastIndex));\n return output.length > lim ? output.slice(0, lim) : output;\n };\n // Chakra, V8\n } else if ('0'.split(undefined, 0).length) {\n internalSplit = function (separator, limit) {\n return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);\n };\n } else internalSplit = nativeSplit;\n\n return [\n // `String.prototype.split` method\n // https://tc39.es/ecma262/#sec-string.prototype.split\n function split(separator, limit) {\n var O = requireObjectCoercible(this);\n var splitter = separator == undefined ? undefined : separator[SPLIT];\n return splitter !== undefined\n ? splitter.call(separator, O, limit)\n : internalSplit.call(toString(O), separator, limit);\n },\n // `RegExp.prototype[@@split]` method\n // https://tc39.es/ecma262/#sec-regexp.prototype-@@split\n //\n // NOTE: This cannot be properly polyfilled in engines that don't support\n // the 'y' flag.\n function (string, limit) {\n var rx = anObject(this);\n var S = toString(string);\n var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);\n\n if (res.done) return res.value;\n\n var C = speciesConstructor(rx, RegExp);\n\n var unicodeMatching = rx.unicode;\n var flags = (rx.ignoreCase ? 'i' : '') +\n (rx.multiline ? 'm' : '') +\n (rx.unicode ? 'u' : '') +\n (UNSUPPORTED_Y ? 'g' : 'y');\n\n // ^(? + rx + ) is needed, in combination with some S slicing, to\n // simulate the 'y' flag.\n var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];\n var p = 0;\n var q = 0;\n var A = [];\n while (q < S.length) {\n splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;\n var z = callRegExpExec(splitter, UNSUPPORTED_Y ? S.slice(q) : S);\n var e;\n if (\n z === null ||\n (e = min(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p\n ) {\n q = advanceStringIndex(S, q, unicodeMatching);\n } else {\n A.push(S.slice(p, q));\n if (A.length === lim) return A;\n for (var i = 1; i <= z.length - 1; i++) {\n A.push(z[i]);\n if (A.length === lim) return A;\n }\n q = p = e;\n }\n }\n A.push(S.slice(p));\n return A;\n }\n ];\n}, !SPLIT_WORKS_WITH_OVERWRITTEN_E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1kpO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3123\n")},3210:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar $trim = __webpack_require__(3111).trim;\nvar forcedStringTrimMethod = __webpack_require__(6091);\n\n// `String.prototype.trim` method\n// https://tc39.es/ecma262/#sec-string.prototype.trim\n$({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {\n trim: function trim() {\n return $trim(this);\n }\n});\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzIxMC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly94bHN4X3RyYW5zZm9ybS8uL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvZXMuc3RyaW5nLnRyaW0uanM/NDk4YSJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG52YXIgJCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9leHBvcnQnKTtcbnZhciAkdHJpbSA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zdHJpbmctdHJpbScpLnRyaW07XG52YXIgZm9yY2VkU3RyaW5nVHJpbU1ldGhvZCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9zdHJpbmctdHJpbS1mb3JjZWQnKTtcblxuLy8gYFN0cmluZy5wcm90b3R5cGUudHJpbWAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXN0cmluZy5wcm90b3R5cGUudHJpbVxuJCh7IHRhcmdldDogJ1N0cmluZycsIHByb3RvOiB0cnVlLCBmb3JjZWQ6IGZvcmNlZFN0cmluZ1RyaW1NZXRob2QoJ3RyaW0nKSB9LCB7XG4gIHRyaW06IGZ1bmN0aW9uIHRyaW0oKSB7XG4gICAgcmV0dXJuICR0cmltKHRoaXMpO1xuICB9XG59KTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3210\n")},1817:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("// `Symbol.prototype.description` getter\n// https://tc39.es/ecma262/#sec-symbol.prototype.description\n\nvar $ = __webpack_require__(2109);\nvar DESCRIPTORS = __webpack_require__(9781);\nvar global = __webpack_require__(7854);\nvar has = __webpack_require__(6656);\nvar isObject = __webpack_require__(111);\nvar defineProperty = __webpack_require__(3070).f;\nvar copyConstructorProperties = __webpack_require__(9920);\n\nvar NativeSymbol = global.Symbol;\n\nif (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||\n // Safari 12 bug\n NativeSymbol().description !== undefined\n)) {\n var EmptyStringDescriptionStore = {};\n // wrap Symbol constructor for correct work with undefined description\n var SymbolWrapper = function Symbol() {\n var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);\n var result = this instanceof SymbolWrapper\n ? new NativeSymbol(description)\n // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'\n : description === undefined ? NativeSymbol() : NativeSymbol(description);\n if (description === '') EmptyStringDescriptionStore[result] = true;\n return result;\n };\n copyConstructorProperties(SymbolWrapper, NativeSymbol);\n var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;\n symbolPrototype.constructor = SymbolWrapper;\n\n var symbolToString = symbolPrototype.toString;\n var nativeSymbol = String(NativeSymbol('test')) == 'Symbol(test)';\n var regexp = /^Symbol\\((.*)\\)[^)]+$/;\n defineProperty(symbolPrototype, 'description', {\n configurable: true,\n get: function description() {\n var symbol = isObject(this) ? this.valueOf() : this;\n var string = symbolToString.call(symbol);\n if (has(EmptyStringDescriptionStore, symbol)) return '';\n var desc = nativeSymbol ? string.slice(7, -1) : string.replace(regexp, '$1');\n return desc === '' ? undefined : desc;\n }\n });\n\n $({ global: true, forced: true }, {\n Symbol: SymbolWrapper\n });\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTgxNy5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLnN5bWJvbC5kZXNjcmlwdGlvbi5qcz9lMDFhIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIGBTeW1ib2wucHJvdG90eXBlLmRlc2NyaXB0aW9uYCBnZXR0ZXJcbi8vIGh0dHBzOi8vdGMzOS5lcy9lY21hMjYyLyNzZWMtc3ltYm9sLnByb3RvdHlwZS5kZXNjcmlwdGlvblxuJ3VzZSBzdHJpY3QnO1xudmFyICQgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZXhwb3J0Jyk7XG52YXIgREVTQ1JJUFRPUlMgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZGVzY3JpcHRvcnMnKTtcbnZhciBnbG9iYWwgPSByZXF1aXJlKCcuLi9pbn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y52YWx1ZU9mKCkgOiB0aGlzO1xuICAgICAgdmFyIHN0cmluZyA9IHN5bWJvbFRvU3RyaW5nLmNhbGwoc3ltYm9sKTtcbiAgICAgIGlmIChoYXMoRW1wdHlTdHJpbmdEZXNjcmlwdGlvblN0b3JlLCBzeW1ib2wpKSByZXR1cm4gJyc7XG4gICAgICB2YXIgZGVzYyA9IG5hdGl2ZVN5bWJvbCA/IHN0cmluZy5zbGljZSg3LCAtMSkgOiBzdHJpbmcucmVwbGFjZShyZWdleHAsICckMScpO1xuICAgICAgcmV0dXJuIGRlc2MgPT09ICcnID8gdW5kZWZpbmVkIDogZGVzYztcbiAgICB9XG4gIH0pO1xuXG4gICQoeyBnbG9iYWw6IHRydWUsIGZvcmNlZDogdHJ1ZSB9LCB7XG4gICAgU3ltYm9sOiBTeW1ib2xXcmFwcGVyXG4gIH0pO1xufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1817\n")},2165:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var defineWellKnownSymbol = __webpack_require__(7235);\n\n// `Symbol.iterator` well-known symbol\n// https://tc39.es/ecma262/#sec-symbol.iterator\ndefineWellKnownSymbol('iterator');\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjE2NS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLnN5bWJvbC5pdGVyYXRvci5qcz9kMjhiIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBkZWZpbmVXZWxsS25vd25TeW1ib2wgPSByZXF1aXJlKCcuLi9pbnRlcm5hbHMvZGVmaW5lLXdlbGwta25vd24tc3ltYm9sJyk7XG5cbi8vIGBTeW1ib2wuaXRlcmF0b3JgIHdlbGwta25vd24gc3ltYm9sXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXN5bWJvbC5pdGVyYXRvclxuZGVmaW5lV2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2165\n")},2526:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar $ = __webpack_require__(2109);\nvar global = __webpack_require__(7854);\nvar getBuiltIn = __webpack_require__(5005);\nvar IS_PURE = __webpack_require__(1913);\nvar DESCRIPTORS = __webpack_require__(9781);\nvar NATIVE_SYMBOL = __webpack_require__(133);\nvar fails = __webpack_require__(7293);\nvar has = __webpack_require__(6656);\nvar isArray = __webpack_require__(3157);\nvar isObject = __webpack_require__(111);\nvar isSymbol = __webpack_require__(2190);\nvar anObject = __webpack_require__(9670);\nvar toObject = __webpack_require__(7908);\nvar toIndexedObject = __webpack_require__(5656);\nvar toPropertyKey = __webpack_require__(4948);\nvar $toString = __webpack_require__(1340);\nvar createPropertyDescriptor = __webpack_require__(9114);\nvar nativeObjectCreate = __webpack_require__(30);\nvar objectKeys = __webpack_require__(1956);\nvar getOwnPropertyNamesModule = __webpack_require__(8006);\nvar getOwnPropertyNamesExternal = __webpack_require__(1156);\nvar getOwnPropertySymbolsModule = __webpack_require__(5181);\nvar getOwnPropertyDescriptorModule = __webpack_require__(1236);\nvar definePropertyModule = __webpack_require__(3070);\nvar propertyIsEnumerableModule = __webpack_require__(5296);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar redefine = __webpack_require__(1320);\nvar shared = __webpack_require__(2309);\nvar sharedKey = __webpack_require__(6200);\nvar hiddenKeys = __webpack_require__(3501);\nvar uid = __webpack_require__(9711);\nvar wellKnownSymbol = __webpack_require__(5112);\nvar wrappedWellKnownSymbolModule = __webpack_require__(6061);\nvar defineWellKnownSymbol = __webpack_require__(7235);\nvar setToStringTag = __webpack_require__(8003);\nvar InternalStateModule = __webpack_require__(9909);\nvar $forEach = __webpack_require__(2092).forEach;\n\nvar HIDDEN = sharedKey('hidden');\nvar SYMBOL = 'Symbol';\nvar PROTOTYPE = 'prototype';\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(SYMBOL);\nvar ObjectPrototype = Object[PROTOTYPE];\nvar $Symbol = global.Symbol;\nvar $stringify = getBuiltIn('JSON', 'stringify');\nvar nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\nvar nativeDefineProperty = definePropertyModule.f;\nvar nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;\nvar nativePropertyIsEnumerable = propertyIsEnumerableModule.f;\nvar AllSymbols = shared('symbols');\nvar ObjectPrototypeSymbols = shared('op-symbols');\nvar StringToSymbolRegistry = shared('string-to-symbol-registry');\nvar SymbolToStringRegistry = shared('symbol-to-string-registry');\nvar WellKnownSymbolsStore = shared('wks');\nvar QObject = global.QObject;\n// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173\nvar USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDescriptor = DESCRIPTORS && fails(function () {\n return nativeObjectCreate(nativeDefineProperty({}, 'a', {\n get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }\n })).a != 7;\n}) ? function (O, P, Attributes) {\n var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);\n if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];\n nativeDefineProperty(O, P, Attributes);\n if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {\n nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);\n }\n} : nativeDefineProperty;\n\nvar wrap = function (tag, description) {\n var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);\n setInternalState(symbol, {\n type: SYMBOL,\n tag: tag,\n description: description\n });\n if (!DESCRIPTORS) symbol.description = description;\n return symbol;\n};\n\nvar $defineProperty = function defineProperty(O, P, Attributes) {\n if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);\n anObject(O);\n var key = toPropertyKey(P);\n anObject(Attributes);\n if (has(AllSymbols, key)) {\n if (!Attributes.enumerable) {\n if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));\n O[HIDDEN][key] = true;\n } else {\n if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;\n Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });\n } return setSymbolDescriptor(O, key, Attributes);\n } return nativeDefineProperty(O, key, Attributes);\n};\n\nvar $defineProperties = function defineProperties(O, Properties) {\n anObject(O);\n var properties = toIndexedObject(Properties);\n var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));\n $forEach(keys, function (key) {\n if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);\n });\n return O;\n};\n\nvar $create = function create(O, Properties) {\n return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);\n};\n\nvar $propertyIsEnumerable = function propertyIsEnumerable(V) {\n var P = toPropertyKey(V);\n var enumerable = nativePropertyIsEnumerable.call(this, P);\n if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;\n return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;\n};\n\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {\n var it = toIndexedObject(O);\n var key = toPropertyKey(P);\n if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;\n var descriptor = nativeGetOwnPropertyDescriptor(it, key);\n if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {\n descriptor.enumerable = true;\n }\n return descriptor;\n};\n\nvar $getOwnPropertyNames = function getOwnPropertyNames(O) {\n var names = nativeGetOwnPropertyNames(toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);\n });\n return result;\n};\n\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(O) {\n var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;\n var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {\n result.push(AllSymbols[key]);\n }\n });\n return result;\n};\n\n// `Symbol` constructor\n// https://tc39.es/ecma262/#sec-symbol-constructor\nif (!NATIVE_SYMBOL) {\n $Symbol = function Symbol() {\n if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');\n var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);\n var tag = uid(description);\n var setter = function (value) {\n if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);\n if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;\n setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));\n };\n if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });\n return wrap(tag, description);\n };\n\n redefine($Symbol[PROTOTYPE], 'toString', function toString() {\n return getInternalState(this).tag;\n });\n\n redefine($Symbol, 'withoutSetter', function (description) {\n return wrap(uid(description), description);\n });\n\n propertyIsEnumerableModule.f = $propertyIsEnumerable;\n definePropertyModule.f = $defineProperty;\n getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;\n getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;\n getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;\n\n wrappedWellKnownSymbolModule.f = function (name) {\n return wrap(wellKnownSymbol(name), name);\n };\n\n if (DESCRIPTORS) {\n // https://github.com/tc39/proposal-Symbol-description\n nativeDefineProperty($Symbol[PROTOTYPE], 'description', {\n configurable: true,\n get: function description() {\n return getInternalState(this).description;\n }\n });\n if (!IS_PURE) {\n redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });\n }\n }\n}\n\n$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {\n Symbol: $Symbol\n});\n\n$forEach(objectKeys(WellKnownSymbolsStore), function (name) {\n defineWellKnownSymbol(name);\n});\n\n$({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {\n // `Symbol.for` method\n // https://tc39.es/ecma262/#sec-symbol.for\n 'for': function (key) {\n var string = $toString(key);\n if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];\n var symbol = $Symbol(string);\n StringToSymbolRegistry[string] = symbol;\n SymbolToStringRegistry[symbol] = string;\n return symbol;\n },\n // `Symbol.keyFor` method\n // https://tc39.es/ecma262/#sec-symbol.keyfor\n keyFor: function keyFor(sym) {\n if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');\n if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];\n },\n useSetter: function () { USE_SETTER = true; },\n useSimple: function () { USE_SETTER = false; }\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {\n // `Object.create` method\n // https://tc39.es/ecma262/#sec-object.create\n create: $create,\n // `Object.defineProperty` method\n // https://tc39.es/ecma262/#sec-object.defineproperty\n defineProperty: $defineProperty,\n // `Object.defineProperties` method\n // https://tc39.es/ecma262/#sec-object.defineproperties\n defineProperties: $defineProperties,\n // `Object.getOwnPropertyDescriptor` method\n // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors\n getOwnPropertyDescriptor: $getOwnPropertyDescriptor\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {\n // `Object.getOwnPropertyNames` method\n // https://tc39.es/ecma262/#sec-object.getownpropertynames\n getOwnPropertyNames: $getOwnPropertyNames,\n // `Object.getOwnPropertySymbols` method\n // https://tc39.es/ecma262/#sec-object.getownpropertysymbols\n getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives\n// https://bugs.chromium.org/p/v8/issues/detail?id=3443\n$({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {\n getOwnPropertySymbols: function getOwnPropertySymbols(it) {\n return getOwnPropertySymbolsModule.f(toObject(it));\n }\n});\n\n// `JSON.stringify` method behavior with symbols\n// https://tc39.es/ecma262/#sec-json.stringify\nif ($stringify) {\n var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {\n var symbol = $Symbol();\n // MS Edge converts symbol values to JSON as {}\n return $stringify([symbol]) != '[null]'\n // WebKit converts symbol values to JSON as null\n || $stringify({ a: symbol }) != '{}'\n // V8 throws on boxed symbols\n || $stringify(Object(symbol)) != '{}';\n });\n\n $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {\n // eslint-disable-next-line no-unused-vars -- required for `.length`\n stringify: function stringify(it, replacer, space) {\n var args = [it];\n var index = 1;\n var $replacer;\n while (arguments.length > index) args.push(arguments[index++]);\n $replacer = replacer;\n if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined\n if (!isArray(replacer)) replacer = function (key, value) {\n if (typeof $replacer == 'function') value = $replacer.call(this, key, value);\n if (!isSymbol(value)) return value;\n };\n args[1] = replacer;\n return $stringify.apply(null, args);\n }\n });\n}\n\n// `Symbol.prototype[@@toPrimitive]` method\n// https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive\nif (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {\n createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);\n}\n// `Symbol.prototype[@@toStringTag]` property\n// https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag\nsetToStringTag($Symbol, SYMBOL);\n\nhiddenKeys[HIDDEN] = true;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjUyNi5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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heShyZXBsYWNlcikpIHJlcGxhY2VyID0gZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbiAgICAgICAgaWYgKHR5cGVvZiAkcmVwbGFjZXIgPT0gJ2Z1bmN0aW9uJykgdmFsdWUgPSAkcmVwbGFjZXIuY2FsbCh0aGlzLCBrZXksIHZhbHVlKTtcbiAgICAgICAgaWYgKCFpc1N5bWJvbCh2YWx1ZSkpIHJldHVybiB2YWx1ZTtcbiAgICAgIH07XG4gICAgICBhcmdzWzFdID0gcmVwbGFjZXI7XG4gICAgICByZXR1cm4gJHN0cmluZ2lmeS5hcHBseShudWxsLCBhcmdzKTtcbiAgICB9XG4gIH0pO1xufVxuXG4vLyBgU3ltYm9sLnByb3RvdHlwZVtAQHRvUHJpbWl0aXZlXWAgbWV0aG9kXG4vLyBodHRwczovL3RjMzkuZXMvZWNtYTI2Mi8jc2VjLXN5bWJvbC5wcm90b3R5cGUtQEB0b3ByaW1pdGl2ZVxuaWYgKCEkU3ltYm9sW1BST1RPVFlQRV1bVE9fUFJJTUlUSVZFXSkge1xuICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoJFN5bWJvbFtQUk9UT1RZUEVdLCBUT19QUklNSVRJVkUsICRTeW1ib2xbUFJPVE9UWVBFXS52YWx1ZU9mKTtcbn1cbi8vIGBTeW1ib2wucHJvdG90eXBlW0BAdG9TdHJpbmdUYWddYCBwcm9wZXJ0eVxuLy8gaHR0cHM6Ly90YzM5LmVzL2VjbWEyNjIvI3NlYy1zeW1ib2wucHJvdG90eXBlLUBAdG9zdHJpbmd0YWdcbnNldFRvU3RyaW5nVGFnKCRTeW1ib2wsIFNZTUJPTCk7XG5cbmhpZGRlbktleXNbSElEREVOXSA9IHRydWU7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2526\n")},4129:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\nvar global = __webpack_require__(7854);\nvar redefineAll = __webpack_require__(2248);\nvar InternalMetadataModule = __webpack_require__(2423);\nvar collection = __webpack_require__(7710);\nvar collectionWeak = __webpack_require__(9320);\nvar isObject = __webpack_require__(111);\nvar enforceIternalState = __webpack_require__(9909).enforce;\nvar NATIVE_WEAK_MAP = __webpack_require__(8536);\n\nvar IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;\n// eslint-disable-next-line es/no-object-isextensible -- safe\nvar isExtensible = Object.isExtensible;\nvar InternalWeakMap;\n\nvar wrapper = function (init) {\n return function WeakMap() {\n return init(this, arguments.length ? arguments[0] : undefined);\n };\n};\n\n// `WeakMap` constructor\n// https://tc39.es/ecma262/#sec-weakmap-constructor\nvar $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);\n\n// IE11 WeakMap frozen keys fix\n// We can't use feature detection because it crash some old IE builds\n// https://github.com/zloirock/core-js/issues/485\nif (NATIVE_WEAK_MAP && IS_IE11) {\n InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);\n InternalMetadataModule.enable();\n var WeakMapPrototype = $WeakMap.prototype;\n var nativeDelete = WeakMapPrototype['delete'];\n var nativeHas = WeakMapPrototype.has;\n var nativeGet = WeakMapPrototype.get;\n var nativeSet = WeakMapPrototype.set;\n redefineAll(WeakMapPrototype, {\n 'delete': function (key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeDelete.call(this, key) || state.frozen['delete'](key);\n } return nativeDelete.call(this, key);\n },\n has: function has(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) || state.frozen.has(key);\n } return nativeHas.call(this, key);\n },\n get: function get(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);\n } return nativeGet.call(this, key);\n },\n set: function set(key, value) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);\n } else nativeSet.call(this, key, value);\n return this;\n }\n });\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDEyOS5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8veGxzeF90cmFuc2Zvcm0vLi9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzL2VzLndlYWstbWFwLmpzPzEwZDEiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xudmFyIGdsb2JhbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9nbG9iYWwnKTtcbnZhciByZWRlZmluZUFsbCA9IHJlcXVpcmUoJy4uL2ludGVybmFscy9yZWRlZmluZS1hbGwnKTtcbnZ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jdGlvbiBzZXQoa2V5LCB2YWx1ZSkge1xuICAgICAgaWYgKGlzT2JqZWN0KGtleSkgJiYgIWlzRXh0ZW5zaWJsZShrZXkpKSB7XG4gICAgICAgIHZhciBzdGF0ZSA9IGVuZm9yY2VJdGVybmFsU3RhdGUodGhpcyk7XG4gICAgICAgIGlmICghc3RhdGUuZnJvemVuKSBzdGF0ZS5mcm96ZW4gPSBuZXcgSW50ZXJuYWxXZWFrTWFwKCk7XG4gICAgICAgIG5hdGl2ZUhhcy5jYWxsKHRoaXMsIGtleSkgPyBuYXRpdmVTZXQuY2FsbCh0aGlzLCBrZXksIHZhbHVlKSA6IHN0YXRlLmZyb3plbi5zZXQoa2V5LCB2YWx1ZSk7XG4gICAgICB9IGVsc2UgbmF0aXZlU2V0LmNhbGwodGhpcywga2V5LCB2YWx1ZSk7XG4gICAgICByZXR1cm4gdGhpcztcbiAgICB9XG4gIH0pO1xufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///4129\n")},4747:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar DOMIterables = __webpack_require__(8324);\nvar forEach = __webpack_require__(8533);\nvar createNonEnumerableProperty = __webpack_require__(8880);\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {\n createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);\n } catch (error) {\n CollectionPrototype.forEach = forEach;\n }\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNDc0Ny5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUF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oZXJyb3IpIHtcbiAgICBDb2xsZWN0aW9uUHJvdG90eXBlLmZvckVhY2ggPSBmb3JFYWNoO1xuICB9XG59XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///4747\n")},3948:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var global = __webpack_require__(7854);\nvar DOMIterables = __webpack_require__(8324);\nvar ArrayIteratorMethods = __webpack_require__(6992);\nvar createNonEnumerableProperty = __webpack_require__(8880);\nvar wellKnownSymbol = __webpack_require__(5112);\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar ArrayValues = ArrayIteratorMethods.values;\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n if (CollectionPrototype) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[ITERATOR] !== ArrayValues) try {\n createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);\n } catch (error) {\n CollectionPrototype[ITERATOR] = ArrayValues;\n }\n if (!CollectionPrototype[TO_STRING_TAG]) {\n createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);\n }\n if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {\n createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);\n } catch (error) {\n CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];\n }\n }\n }\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzk0OC5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FB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dG9yTWV0aG9kc1tNRVRIT0RfTkFNRV0pIHRyeSB7XG4gICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShDb2xsZWN0aW9uUHJvdG90eXBlLCBNRVRIT0RfTkFNRSwgQXJyYXlJdGVyYXRvck1ldGhvZHNbTUVUSE9EX05BTUVdKTtcbiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIENvbGxlY3Rpb25Qcm90b3R5cGVbTUVUSE9EX05BTUVdID0gQXJyYXlJdGVyYXRvck1ldGhvZHNbTUVUSE9EX05BTUVdO1xuICAgICAgfVxuICAgIH1cbiAgfVxufVxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3948\n")},5666:module=>{eval('/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n "use strict";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === "function" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || "@@iterator";\n var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";\n var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, "");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there\'s no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don\'t have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: "normal", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: "throw", arg: err };\n }\n }\n\n var GenStateSuspendedStart = "suspendedStart";\n var GenStateSuspendedYield = "suspendedYield";\n var GenStateExecuting = "executing";\n var GenStateCompleted = "completed";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don\'t natively support it.\n var IteratorPrototype = {};\n define(IteratorPrototype, iteratorSymbol, function () {\n return this;\n });\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = GeneratorFunctionPrototype;\n define(Gp, "constructor", GeneratorFunctionPrototype);\n define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n "GeneratorFunction"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n ["next", "throw", "return"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === "function" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === "GeneratorFunction"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, "GeneratorFunction");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, "__await")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === "throw") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === "object" &&\n hasOwn.call(value, "__await")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke("next", value, resolve, reject);\n }, function(err) {\n invoke("throw", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke("throw", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n define(AsyncIterator.prototype, asyncIteratorSymbol, function () {\n return this;\n });\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error("Generator is already running");\n }\n\n if (state === GenStateCompleted) {\n if (method === "throw") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === "next") {\n // Setting context._sent for legacy support of Babel\'s\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === "throw") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === "return") {\n context.abrupt("return", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === "normal") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === "throw") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = "throw";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === "throw") {\n // Note: ["return"] must be used for ES3 parsing compatibility.\n if (delegate.iterator["return"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = "return";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === "throw") {\n // If maybeInvokeDelegate(context) changed context.method from\n // "return" to "throw", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = "throw";\n context.arg = new TypeError(\n "The iterator does not provide a \'throw\' method");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === "throw") {\n context.method = "throw";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = "throw";\n context.arg = new TypeError("iterator result is not an object");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was "throw" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was "next", forget context.arg since it has been\n // "consumed" by the delegate iterator. If context.method was\n // "return", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== "return") {\n context.method = "next";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, "Generator");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers\' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn\'t happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n define(Gp, iteratorSymbol, function() {\n return this;\n });\n\n define(Gp, "toString", function() {\n return "[object Generator]";\n });\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = "normal";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: "root" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === "function") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel\'s\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = "next";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === "t" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === "throw") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = "throw";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = "next";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === "root") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle("end");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, "catchLoc");\n var hasFinally = hasOwn.call(entry, "finallyLoc");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error("try statement without catch or finally");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, "finallyLoc") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === "break" ||\n type === "continue") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = "next";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === "throw") {\n throw record.arg;\n }\n\n if (record.type === "break" ||\n record.type === "continue") {\n this.next = record.arg;\n } else if (record.type === "return") {\n this.rval = this.arg = record.arg;\n this.method = "return";\n this.next = "end";\n } else if (record.type === "normal" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n "catch": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === "throw") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error("illegal catch attempt");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === "next") {\n // Deliberately forget the last sent value so that we don\'t\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n true ? module.exports : 0\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, in modern engines\n // we can explicitly access globalThis. In older engines we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you\'ve misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you\'re not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n if (typeof globalThis === "object") {\n globalThis.regeneratorRuntime = runtime;\n } else {\n Function("r", "regeneratorRuntime = r")(runtime);\n }\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTY2Ni5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTt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lvbiBpbnZva2UobWV0aG9kLCBhcmcsIHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgdmFyIHJlY29yZCA9IHRyeUNhdGNoKGdlbmVyYXRvclttZXRob2RdLCBnZW5lcmF0b3IsIGFyZyk7XG4gICAgICBpZiAocmVjb3JkLnR5cGUgPT09IFwidGhyb3dcIikge1xuICAgICAgICByZWplY3QocmVjb3JkLmFyZyk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB2YXIgcmVzdWx0ID0gcmVjb3JkLmFyZztcbiAgICAgICAgdmFyIHZhbHVlID0gcmVzdWx0LnZhbHVlO1xuICAgICAgICBpZiAodmFsdWUgJiZcbiAgICAgICAgICAgIHR5cGVvZiB2YWx1ZSA9PT0gXCJvYmplY3RcIiAmJlxuICAgICAgICAgICAgaGFzT3duLmNhbGwodmFsdWUsIFwiX19hd2FpdFwiKSkge1xuICAgICAgICAgIHJldHVybiBQcm9taXNlSW1wbC5yZXNvbHZlKHZhbHVlLl9fYXdhaXQpLnRoZW4oZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgIGludm9rZShcIm5leHRcIiwgdmFsdWUsIHJlc29sdmUsIHJlamVjdCk7XG4gICAgICAgICAgfSwgZnVuY3Rpb24oZXJyKSB7XG4gICAgICAgICAgICBpbnZva2UoXCJ0aHJvd1wiLCBlcnIsIHJlc29sdmUsIHJlamVjdCk7XG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gUHJvbWlzZUltcGwucmVzb2x2ZSh2YWx1ZSkudGhlbihmdW5jdGlvbih1bndyYXBwZWQpIHtcbiAgICAgICAgICAvLyBXaGVuIGEgeWllbGRlZCBQcm9taXNlIGlzIHJlc29sdmVkLCBpdHMgZmluYWwgdmFsdWUgYmVjb21lc1xuICAgICAgICAgIC8vIHRoZSAudmFsdWUgb2YgdGhlIFByb21pc2U8e3ZhbHVlLGRvbmV9PiByZXN1bHQgZm9yIHRoZVxuICAgICAgICAgIC8vIG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XRlQ29tcGxldGVkO1xuICAgICAgICAgICAgdGhyb3cgY29udGV4dC5hcmc7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgY29udGV4dC5kaXNwYXRjaEV4Y2VwdGlvbihjb250ZXh0LmFyZyk7XG5cbiAgICAgICAgfSBlbHNlIGlmIChjb250ZXh0Lm1ldGhvZCA9PT0gXCJyZXR1cm5cIikge1xuICAgICAgICAgIGNvbnRleHQuYWJydXB0KFwicmV0dXJuXCIsIGNvbnRleHQuYXJnKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHN0YXRlID0gR2VuU3RhdGVFeGVjdXRpbmc7XG5cbiAgICAgICAgdmFyIHJlY29yZCA9IHRyeUNhdGNoKGlubmVyRm4sIHNlbGYsIGNvbnRleHQpO1xuICAgICAgICBpZiAocmVjb3JkLnR5cGUgPT09IFwibm9ybWFsXCIpIHtcbiAgICAgICAgICAvLyBJZiBhbiBleGNlcHRpb24gaXMgdGhyb3duIGZyb20gaW5uZXJGbiwgd2UgbGVhdmUgc3RhdGUgPT09XG4gICAgICAgICAgLy8gR2VuU3RhdGVFeGVjdXRpbmcgYW5kIGxvb3AgYmFjayBmb3IgYW5vdGhlciBpbnZvY2F0aW9uLlxuICAgICAgICAgIHN0YXRlID0gY29udGV4dC5kb25lXG4gICAgICAgICAgICA/IEdlblN0YXRlQ29tcGxldGVkXG4gICAgICAgICAgICA6IEdlblN0YXRlU3VzcGVuZGVkWWllbGQ7XG5cbiAgICAgICAgICBpZiAocmVjb3JkLmFyZyA9PT0gQ29udGludWVTZW50aW5lbCkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHZhbHVlOiByZWNvcmQuYXJnLFxuICAgICAgICAgICAgZG9uZTogY29udGV4dC5kb25lXG4gICAgICAgICAgfTtcblxuICAgICAgICB9IGVsc2UgaWYgKHJlY29yZC50eXBlID09PSBcInRocm93XCIpIHtcbiAgICAgICA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NZXRob2QgPSBpdGVyYWJsZVtpdGVyYXRvclN5bWJvbF07XG4gICAgICBpZiAoaXRlcmF0b3JNZXRob2QpIHtcbiAgICAgICAgcmV0dXJuIGl0ZXJhdG9yTWV0aG9kLmNhbGwoaXRlcmFibGUpO1xuICAgICAgfVxuXG4gICAgICBpZiAodHlwZW9mIGl0ZXJhYmxlLm5leHQgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICByZXR1cm4gaXRlcmFibGU7XG4gICAgICB9XG5cbiAgICAgIGlmICghaXNOYU4oaXRlcmFibGUubGVuZ3RoKSkge1xuICAgICAgICB2YXIgaSA9IC0xLCBuZXh0ID0gZnVuY3Rpb24gbmV4dCgpIHtcbiAgICAgICAgICB3aGlsZSAoKytpIDwgaXRlcmFibGUubGVuZ3RoKSB7XG4gICAgICAgICAgICBpZiAoaGFzT3duLmNhbGwoaXRlcmFibGUsIGkpKSB7XG4gICAgICAgICAgICAgIG5leHQudmFsdWUgPSBpdGVyYWJsZVtpXTtcbiAgICAgICAgICAgICAgbmV4dC5kb25lID0gZmFsc2U7XG4gICAgICAgICAgICAgIHJldHVybiBuZXh0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cblxuICAgICAgICAgIG5leHQudmFsdWUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgbmV4dC5kb25lID0gdHJ1ZTtcblxuICAgICAgICAgIHJldHVybiBuZXh0O1xuICAgICAgICB9O1xuXG4gICAgICAgIHJldHVybiBuZXh0Lm5leHQgPSBuZXh0O1xuICAgICAgfVxuICAgIH1cblxuICAgIC8vIFJldHVybiBhbiBpdGVyYXRvciB3aXRoIG5vIHZhbHVlcy5cbiAgICByZXR1cm4geyBuZXh0OiBkb25lUmVzdWx0IH07XG4gIH1cbiAgZXhwb3J0cy52YWx1ZXMgPSB2YWx1ZXM7XG5cbiAgZnVuY3Rpb24gZG9uZVJlc3VsdCgpIHtcbiAgICByZXR1cm4geyB2YWx1ZTogdW5kZWZpbmVkLCBkb25l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ICBpZiAodGhpcy5wcmV2IDwgZW50cnkuY2F0Y2hMb2MpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIGhhbmRsZShlbnRyeS5jYXRjaExvYywgdHJ1ZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICB9IGVsc2UgaWYgKGhhc0ZpbmFsbHkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnByZXYgPCBlbnRyeS5maW5hbGx5TG9jKSB7XG4gICAgICAgICAgICAgIHJldHVybiBoYW5kbGUoZW50cnkuZmluYWxseUxvYyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwidHJ5IHN0YXRlbWVudCB3aXRob3V0IGNhdGNoIG9yIGZpbmFsbHlcIik7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcblxuICAgIGFicnVwdDogZnVuY3Rpb24odHlwZSwgYXJnKSB7XG4gICAgICBmb3IgKHZhciBpID0gdGhpcy50cnlFbnRyaWVzLmxlbmd0aCAtIDE7IGkgPj0gMDsgLS1pKSB7XG4gICAgICAgIHZhciBlbnRyeSA9IHRoaXMudHJ5RW50cmllc1tpXTtcbiAgICAgICAgaWYgKGVudHJ5LnRyeUxvYyA8PSB0aGlzLnByZXYgJiZcbiAgICAgICAgICAgIGhhc093bi5jYWxsKGVudHJ5LCBcImZpbmFsbHlMb2NcIikgJiZcbiAgICAgICAgICAgIHRoaXMucHJldiA8IGVudHJ5LmZpbmFsbHlMb2MpIHtcbiAgICAgICAgICB2YXIgZmluYWxseUVudHJ5ID0gZW50cnk7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgaWYgKGZpbmFsbHlFbnRyeSAmJlxuICAgICAgICAgICh0eXBlID09PSBcImJyZWFrXCIgfHxcbiAgICAgICAgICAgdHlwZSA9PT0gXCJjb250aW51ZVwiKSAmJlxuICAgICAgICAgIGZpbmFsbHlFbnRyeS50cnlMb2MgPD0gYXJnICYmXG4gICAgICAgICAgYXJnIDw9IGZpbmFsbHlFbnRyeS5maW5hbGx5TG9jKSB7XG4gICAgICAgIC8vIElnbm9yZSB0aGUgZmluYWxseSBlbnRyeSBpZiBjb250cm9sIGlzIG5vdCBqdW1waW5nIHRvIGFcbiAgICAgICAgLy8gbG9jYXRpb24gb3V0c2lkZSB0aGUgdHJ5L2NhdGNoIGJsb2NrLlxuICAgICAgICBmaW5hbGx5RW50cnkgPSBudWxsO1xuICAgICAgfVxuXG4gICAgICB2YXIgcmVjb3JkID0gZmluYWxseUVudHJ5ID8gZmluYWxseUVudHJ5LmNvbXBsZXRpb24gOiB7fTtcbiAgICAgIHJlY29yZC50eXBlID0gdHlwZTtcbiAgICAgIHJlY29yZC5hcmcgPSBhcmc7XG5cbiAgICAgIGlmIChmaW5hbGx5RW50cnkpIHtcbiAgICAgICAgdGhpcy5tZXRob2QgPSBcIm5leHRcIjtcbiAgICAgICAgdGhpcy5uZXh0ID0gZmluYWxseUVudHJ5LmZpbmFsbHlMb2M7XG4gICAgICAgIHJldHVybiBDb250aW51ZVNlbnRpbmVsO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gdGhpcy5jb21wbGV0ZShyZWNvcmQpO1xuICAgIH0sXG5cbiAgICBjb21wbGV0ZTogZnVuY3Rpb24ocmVjb3JkLCBhZnRlckxvYykge1xuICAgICAgaWYgKHJlY29yZC50eXBlID09PSBcInRocm93XCIpIHtcbiAgICAgICAgdGhyb3cgcmVjb3JkLmFyZztcbiAgICAgIH1cblxuICAgICAgaWYgKHJlY29yZC50eXBlID09PSBcImJyZWFrXCIgfHxcbiAgICAgICAgICByZWNvcmQudHlwZSA9PT0gXCJjb250aW51ZVwiKSB7XG4gICAgICAgIHRoaXMubmV4dCA9IHJlY29yZC5hcmc7XG4gICAgICB9IGVsc2UgaWYgKHJlY29yZC50eXBlID09PSBcInJldHVyblwiKSB7XG4gICAgICAgIHRoaXMucnZhbCA9IHRoaXMuYXJnID0gcmVjb3JkLmFyZztcbiAgICAgICAgdGhpcy5tZXRob2QgPSBcInJldHVyblwiO1xuICAgICAgICB0aGlzLm5leHQgPSBcImVuZFwiO1xuICAgICAgfSBlbHNlIGlmIChyZWNvcmQudHlwZSA9PT0gXCJub3JtYWxcIiAmJiBhZnRlckxvYykge1xuICAgICAgICB0aGlzLm5leHQgPSBhZnRlckxvYztcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIENvbnRpbnVlU2VudGluZWw7XG4gICAgfSxcblxuICAgIGZpbmlzaDogZnVuY3Rpb24oZmluYWxseUxvYykge1xuICAgICAgZm9yICh2YXIgaSA9IHRoaXMudHJ5RW50cmllcy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xuICAgICAgICB2YXIgZW50cnkgPSB0aGlzLnRyeUVudHJpZXNbaV07XG4gICAgICAgIGlmIChlbnRyeS5maW5hbGx5TG9jID09PSBmaW5hbGx5TG9jKSB7XG4gICAgICAgICAgdGhpcy5jb21wbGV0ZShlbnRyeS5jb21wbGV0aW9uLCBlbnRyeS5hZnRlckxvYyk7XG4gICAgICAgICAgcmVzZXRUcnlFbnRyeShlbnRyeSk7XG4gICAgICAgICAgcmV0dXJuIENvbnRpbnVlU2VudGluZWw7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuXG4gICAgXCJjYXRjaFwiOiBmdW5jdGlvbih0cnlMb2MpIHtcbiAgICAgIGZvciAodmFyIGkgPSB0aGlzLnRyeUVudHJpZXMubGVuZ3RoIC0gMTsgaSA+PSAwOyAtLWkpIHtcbiAgICAgICAgdmFyIGVudHJ5ID0gdGhpcy50cnlFbnRyaWVzW2ldO1xuICAgICAgICBpZiAoZW50cnkudHJ5TG9jID09PSB0cnlMb2MpIHtcbiAgICAgICAgICB2YXIgcmVjb3JkID0gZW50cnkuY29tcGxldGlvbjtcbiAgICAgICAgICBpZiAocmVjb3JkLnR5cGUgPT09IFwidGhyb3dcIik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n1cbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5666\n')},154:(__unused_webpack___webpack_module__,__unused_webpack___webpack_exports__,__webpack_require__)=>{"use strict";eval('\n// EXTERNAL MODULE: ./node_modules/regenerator-runtime/runtime.js\nvar runtime = __webpack_require__(5666);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.object.to-string.js\nvar es_object_to_string = __webpack_require__(1539);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.js\nvar es_promise = __webpack_require__(8674);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-collections.for-each.js\nvar web_dom_collections_for_each = __webpack_require__(4747);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.iterator.js\nvar es_array_iterator = __webpack_require__(6992);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.js\nvar es_set = __webpack_require__(189);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.iterator.js\nvar es_string_iterator = __webpack_require__(8783);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-collections.iterator.js\nvar web_dom_collections_iterator = __webpack_require__(3948);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.concat.js\nvar es_array_concat = __webpack_require__(2222);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.find.js\nvar es_array_find = __webpack_require__(9826);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.function.name.js\nvar es_function_name = __webpack_require__(8309);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.js\nvar es_symbol = __webpack_require__(2526);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.description.js\nvar es_symbol_description = __webpack_require__(1817);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.map.js\nvar es_array_map = __webpack_require__(1249);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.from.js\nvar es_array_from = __webpack_require__(1038);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.join.js\nvar es_array_join = __webpack_require__(9600);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.number.constructor.js\nvar es_number_constructor = __webpack_require__(9653);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.parse-int.js\nvar es_parse_int = __webpack_require__(1058);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.weak-map.js\nvar es_weak_map = __webpack_require__(4129);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.slice.js\nvar es_array_slice = __webpack_require__(7042);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.iterator.js\nvar es_symbol_iterator = __webpack_require__(2165);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.flat.js\nvar es_array_flat = __webpack_require__(4944);\n;// CONCATENATED MODULE: ./src/functions/util.js\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction _typeof(obj) { "@babel/helpers - typeof"; 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); }\n\nfunction clone(value) {\n switch (_typeof(value)) {\n case \'object\':\n if (Array.isArray(value)) return value.map(function (v) {\n return clone(v);\n });\n var newObj = {};\n\n for (var key in value) {\n newObj[key] = clone(value[key]);\n }\n\n return newObj;\n\n default:\n return value;\n }\n}\n\nfunction max() {\n for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) {\n arr[_key] = arguments[_key];\n }\n\n return Math.max.apply(Math, _toConsumableArray(arr.flat()));\n}\n\nfunction min() {\n for (var _len2 = arguments.length, arr = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n arr[_key2] = arguments[_key2];\n }\n\n return Math.min.apply(Math, _toConsumableArray(arr.flat()));\n}\n\nfunction sum() {\n var s = 0;\n\n for (var _len3 = arguments.length, arr = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n arr[_key3] = arguments[_key3];\n }\n\n arr.flat().forEach(function (v) {\n return s += v;\n });\n return s;\n}\n\nfunction average() {\n for (var _len4 = arguments.length, arr = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n arr[_key4] = arguments[_key4];\n }\n\n var s = sum.apply(void 0, arr);\n return s / arr.flat().length;\n}\n\n\n;// CONCATENATED MODULE: ./src/functions/summary.js\nvar data = {\n "CHR": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 1,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 2,\n "judge": "不佳",\n "grade": 0\n }, {\n "min": 4,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 7,\n "judge": "优秀",\n "grade": 1\n }, {\n "min": 9,\n "judge": "罕见",\n "grade": 2\n }, {\n "min": 11,\n "judge": "逆天",\n "grade": 3\n }],\n "MNY": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 1,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 2,\n "judge": "不佳",\n "grade": 0\n }, {\n "min": 4,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 7,\n "judge": "优秀",\n "grade": 1\n }, {\n "min": 9,\n "judge": "罕见",\n "grade": 2\n }, {\n "min": 11,\n "judge": "逆天",\n "grade": 3\n }],\n "SPR": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 1,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 2,\n "judge": "不幸",\n "grade": 0\n }, {\n "min": 4,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 7,\n "judge": "幸福",\n "grade": 1\n }, {\n "min": 9,\n "judge": "极乐",\n "grade": 2\n }, {\n "min": 11,\n "judge": "天命",\n "grade": 3\n }],\n "INT": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 1,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 2,\n "judge": "不佳",\n "grade": 0\n }, {\n "min": 4,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 7,\n "judge": "优秀",\n "grade": 1\n }, {\n "min": 9,\n "judge": "罕见",\n "grade": 2\n }, {\n "min": 11,\n "judge": "逆天",\n "grade": 3\n }, {\n "min": 21,\n "judge": "识海",\n "grade": 3\n }, {\n "min": 131,\n "judge": "元神",\n "grade": 3\n }, {\n "min": 501,\n "judge": "仙魂",\n "grade": 3\n }],\n "STR": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 1,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 2,\n "judge": "不佳",\n "grade": 0\n }, {\n "min": 4,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 7,\n "judge": "优秀",\n "grade": 1\n }, {\n "min": 9,\n "judge": "罕见",\n "grade": 2\n }, {\n "min": 11,\n "judge": "逆天",\n "grade": 3\n }, {\n "min": 21,\n "judge": "凝气",\n "grade": 3\n }, {\n "min": 101,\n "judge": "筑基",\n "grade": 3\n }, {\n "min": 401,\n "judge": "金丹",\n "grade": 3\n }, {\n "min": 1001,\n "judge": "元婴",\n "grade": 3\n }, {\n "min": 2001,\n "judge": "仙体",\n "grade": 3\n }],\n "AGE": [{\n "judge": "胎死腹中",\n "grade": 0\n }, {\n "min": 1,\n "judge": "早夭",\n "grade": 0\n }, {\n "min": 10,\n "judge": "少年",\n "grade": 0\n }, {\n "min": 18,\n "judge": "盛年",\n "grade": 0\n }, {\n "min": 40,\n "judge": "中年",\n "grade": 0\n }, {\n "min": 60,\n "judge": "花甲",\n "grade": 1\n }, {\n "min": 70,\n "judge": "古稀",\n "grade": 1\n }, {\n "min": 80,\n "judge": "杖朝",\n "grade": 2\n }, {\n "min": 90,\n "judge": "南山",\n "grade": 2\n }, {\n "min": 95,\n "judge": "不老",\n "grade": 3\n }, {\n "min": 100,\n "judge": "修仙",\n "grade": 3\n }, {\n "min": 500,\n "judge": "仙寿",\n "grade": 3\n }],\n "SUM": [{\n "judge": "地狱",\n "grade": 0\n }, {\n "min": 41,\n "judge": "折磨",\n "grade": 0\n }, {\n "min": 50,\n "judge": "不佳",\n "grade": 0\n }, {\n "min": 60,\n "judge": "普通",\n "grade": 0\n }, {\n "min": 80,\n "judge": "优秀",\n "grade": 1\n }, {\n "min": 100,\n "judge": "罕见",\n "grade": 2\n }, {\n "min": 110,\n "judge": "逆天",\n "grade": 3\n }, {\n "min": 120,\n "judge": "传说",\n "grade": 3\n }]\n};\n\nfunction summary(type, value) {\n var length = data[type].length;\n\n while (length--) {\n var _data$type$length = data[type][length],\n min = _data$type$length.min,\n judge = _data$type$length.judge,\n grade = _data$type$length.grade;\n if (min == void 0 || value >= min) return {\n judge: judge,\n grade: grade\n };\n }\n}\n\n\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.filter.js\nvar es_array_filter = __webpack_require__(7327);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.regexp.exec.js\nvar es_regexp_exec = __webpack_require__(4916);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.split.js\nvar es_string_split = __webpack_require__(3123);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.index-of.js\nvar es_array_index_of = __webpack_require__(2772);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.splice.js\nvar es_array_splice = __webpack_require__(561);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.includes.js\nvar es_array_includes = __webpack_require__(6699);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.includes.js\nvar es_string_includes = __webpack_require__(2023);\n;// CONCATENATED MODULE: ./src/property.js\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = property_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction property_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return property_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return property_arrayLikeToArray(o, minLen); }\n\nfunction property_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\n\nfunction _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }\n\nfunction _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; }\n\nfunction _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }\n\nfunction _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\nfunction _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }\n\nfunction _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }\n\nfunction _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }\n\n\n\nvar _ageData = /*#__PURE__*/new WeakMap();\n\nvar _data = /*#__PURE__*/new WeakMap();\n\nvar _record = /*#__PURE__*/new WeakMap();\n\nvar Property = /*#__PURE__*/function () {\n function Property() {\n _classCallCheck(this, Property);\n\n _defineProperty(this, "TYPES", {\n AGE: "AGE",\n CHR: "CHR",\n INT: "INT",\n STR: "STR",\n MNY: "MNY",\n SPR: "SPR",\n LIF: "LIF",\n TLT: "TLT",\n EVT: "EVT"\n });\n\n _classPrivateFieldInitSpec(this, _ageData, {\n writable: true,\n value: void 0\n });\n\n _classPrivateFieldInitSpec(this, _data, {\n writable: true,\n value: void 0\n });\n\n _classPrivateFieldInitSpec(this, _record, {\n writable: true,\n value: void 0\n });\n }\n\n _createClass(Property, [{\n key: "initial",\n value: function initial(_ref) {\n var age = _ref.age;\n\n _classPrivateFieldSet(this, _ageData, age);\n\n for (var a in age) {\n var _event, _talent;\n\n var _age$a = age[a],\n event = _age$a.event,\n talent = _age$a.talent;\n if (!Array.isArray(event)) event = ((_event = event) === null || _event === void 0 ? void 0 : _event.split(\',\')) || [];\n event = event.map(function (v) {\n var value = "".concat(v).split(\'*\').map(function (n) {\n return Number(n);\n });\n if (value.length == 1) value.push(1);\n return value;\n });\n if (!Array.isArray(talent)) talent = ((_talent = talent) === null || _talent === void 0 ? void 0 : _talent.split(\',\')) || [];\n talent = talent.map(function (v) {\n return Number(v);\n });\n age[a] = {\n event: event,\n talent: talent\n };\n }\n }\n }, {\n key: "restart",\n value: function restart(data) {\n var _classPrivateFieldSet2;\n\n _classPrivateFieldSet(this, _data, (_classPrivateFieldSet2 = {}, _defineProperty(_classPrivateFieldSet2, this.TYPES.AGE, -1), _defineProperty(_classPrivateFieldSet2, this.TYPES.CHR, 0), _defineProperty(_classPrivateFieldSet2, this.TYPES.INT, 0), _defineProperty(_classPrivateFieldSet2, this.TYPES.STR, 0), _defineProperty(_classPrivateFieldSet2, this.TYPES.MNY, 0), _defineProperty(_classPrivateFieldSet2, this.TYPES.SPR, 0), _defineProperty(_classPrivateFieldSet2, this.TYPES.LIF, 1), _defineProperty(_classPrivateFieldSet2, this.TYPES.TLT, []), _defineProperty(_classPrivateFieldSet2, this.TYPES.EVT, []), _classPrivateFieldSet2));\n\n for (var key in data) {\n this.change(key, data[key]);\n }\n\n _classPrivateFieldSet(this, _record, []);\n }\n }, {\n key: "get",\n value: function get(prop) {\n switch (prop) {\n case this.TYPES.AGE:\n case this.TYPES.CHR:\n case this.TYPES.INT:\n case this.TYPES.STR:\n case this.TYPES.MNY:\n case this.TYPES.SPR:\n case this.TYPES.LIF:\n case this.TYPES.TLT:\n case this.TYPES.EVT:\n return clone(_classPrivateFieldGet(this, _data)[prop]);\n\n default:\n return 0;\n }\n }\n }, {\n key: "set",\n value: function set(prop, value) {\n switch (prop) {\n case this.TYPES.AGE:\n case this.TYPES.CHR:\n case this.TYPES.INT:\n case this.TYPES.STR:\n case this.TYPES.MNY:\n case this.TYPES.SPR:\n case this.TYPES.LIF:\n case this.TYPES.TLT:\n case this.TYPES.EVT:\n _classPrivateFieldGet(this, _data)[prop] = clone(value);\n break;\n\n default:\n return 0;\n }\n }\n }, {\n key: "record",\n value: function record() {\n var _classPrivateFieldGet2;\n\n _classPrivateFieldGet(this, _record).push((_classPrivateFieldGet2 = {}, _defineProperty(_classPrivateFieldGet2, this.TYPES.AGE, this.get(this.TYPES.AGE)), _defineProperty(_classPrivateFieldGet2, this.TYPES.CHR, this.get(this.TYPES.CHR)), _defineProperty(_classPrivateFieldGet2, this.TYPES.INT, this.get(this.TYPES.INT)), _defineProperty(_classPrivateFieldGet2, this.TYPES.STR, this.get(this.TYPES.STR)), _defineProperty(_classPrivateFieldGet2, this.TYPES.MNY, this.get(this.TYPES.MNY)), _defineProperty(_classPrivateFieldGet2, this.TYPES.SPR, this.get(this.TYPES.SPR)), _classPrivateFieldGet2));\n }\n }, {\n key: "getRecord",\n value: function getRecord() {\n return clone(_classPrivateFieldGet(this, _record));\n }\n }, {\n key: "getLastRecord",\n value: function getLastRecord() {\n return clone(_classPrivateFieldGet(this, _record)[_classPrivateFieldGet(this, _record).length - 1]);\n }\n }, {\n key: "change",\n value: function change(prop, value) {\n if (Array.isArray(value)) {\n var _iterator = _createForOfIteratorHelper(value),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var v = _step.value;\n this.change(prop, Number(v));\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return;\n }\n\n switch (prop) {\n case this.TYPES.AGE:\n case this.TYPES.CHR:\n case this.TYPES.INT:\n case this.TYPES.STR:\n case this.TYPES.MNY:\n case this.TYPES.SPR:\n case this.TYPES.LIF:\n _classPrivateFieldGet(this, _data)[prop] += Number(value);\n break;\n\n case this.TYPES.TLT:\n case this.TYPES.EVT:\n var _v = _classPrivateFieldGet(this, _data)[prop];\n\n if (value < 0) {\n var index = _v.indexOf(value);\n\n if (index != -1) _v.splice(index, 1);\n }\n\n if (!_v.includes(value)) _v.push(value);\n break;\n\n default:\n return;\n }\n }\n }, {\n key: "effect",\n value: function effect(effects) {\n for (var prop in effects) {\n this.change(prop, Number(effects[prop]));\n }\n }\n }, {\n key: "isEnd",\n value: function isEnd() {\n return this.get(this.TYPES.LIF) < 1;\n }\n }, {\n key: "ageNext",\n value: function ageNext() {\n this.change(this.TYPES.AGE, 1);\n var age = this.get(this.TYPES.AGE);\n\n var _this$getAgeData = this.getAgeData(age),\n event = _this$getAgeData.event,\n talent = _this$getAgeData.talent;\n\n return {\n age: age,\n event: event,\n talent: talent\n };\n }\n }, {\n key: "getAgeData",\n value: function getAgeData(age) {\n return clone(_classPrivateFieldGet(this, _ageData)[age]);\n }\n }]);\n\n return Property;\n}();\n\n/* harmony default export */ const property = (Property);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.trim.js\nvar es_string_trim = __webpack_require__(3210);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.search.js\nvar es_string_search = __webpack_require__(4765);\n;// CONCATENATED MODULE: ./src/functions/condition.js\nfunction condition_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = condition_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction condition_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return condition_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return condition_arrayLikeToArray(o, minLen); }\n\nfunction condition_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction parseCondition(condition) {\n var conditions = [];\n var length = condition.length;\n var stack = [];\n stack.unshift(conditions);\n var cursor = 0;\n\n var catchString = function catchString(i) {\n var str = condition.substring(cursor, i).trim();\n cursor = i;\n if (str) stack[0].push(str);\n };\n\n for (var i = 0; i < length; i++) {\n switch (condition[i]) {\n case \' \':\n continue;\n\n case \'(\':\n catchString(i);\n cursor++;\n var sub = [];\n stack[0].push(sub);\n stack.unshift(sub);\n break;\n\n case \')\':\n catchString(i);\n cursor++;\n stack.shift();\n break;\n\n case \'|\':\n case \'&\':\n catchString(i);\n catchString(i + 1);\n break;\n\n default:\n continue;\n }\n }\n\n catchString(length);\n return conditions;\n}\n\nfunction checkCondition(property, condition) {\n var conditions = parseCondition(condition);\n return checkParsedConditions(property, conditions);\n}\n\nfunction checkParsedConditions(property, conditions) {\n if (!Array.isArray(conditions)) return checkProp(property, conditions);\n if (conditions.length == 0) return true;\n if (conditions.length == 1) return checkParsedConditions(property, conditions[0]);\n var ret = checkParsedConditions(property, conditions[0]);\n\n for (var i = 1; i < conditions.length; i += 2) {\n switch (conditions[i]) {\n case \'&\':\n if (ret) ret = checkParsedConditions(property, conditions[i + 1]);\n break;\n\n case \'|\':\n if (ret) return true;\n ret = checkParsedConditions(property, conditions[i + 1]);\n break;\n\n default:\n return false;\n }\n }\n\n return ret;\n}\n\nfunction checkProp(property, condition) {\n var length = condition.length;\n var i = condition.search(/[><\\!\\?=]/);\n var prop = condition.substring(0, i);\n var symbol = condition.substring(i, i += condition[i + 1] == \'=\' ? 2 : 1);\n var d = condition.substring(i, length);\n var propData = property.get(prop);\n var conditionData = d[0] == \'[\' ? JSON.parse(d) : Number(d);\n\n switch (symbol) {\n case \'>\':\n return propData > conditionData;\n\n case \'<\':\n return propData < conditionData;\n\n case \'>=\':\n return propData >= conditionData;\n\n case \'<=\':\n return propData <= conditionData;\n\n case \'=\':\n if (Array.isArray(propData)) return propData.includes(conditionData);\n return propData == conditionData;\n\n case \'!=\':\n if (Array.isArray(propData)) return !propData.includes(conditionData);\n return propData == conditionData;\n\n case \'?\':\n if (Array.isArray(propData)) {\n var _iterator = condition_createForOfIteratorHelper(propData),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var p = _step.value;\n if (conditionData.includes(p)) return true;\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return false;\n }\n\n return conditionData.includes(propData);\n\n case \'!\':\n if (Array.isArray(propData)) {\n var _iterator2 = condition_createForOfIteratorHelper(propData),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var _p = _step2.value;\n if (conditionData.includes(_p)) return false;\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n return true;\n }\n\n return !conditionData.includes(propData);\n\n default:\n return false;\n }\n}\n\n\n;// CONCATENATED MODULE: ./src/event.js\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || event_unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction event_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = event_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction event_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return event_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return event_arrayLikeToArray(o, minLen); }\n\nfunction event_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction event_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction event_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction event_createClass(Constructor, protoProps, staticProps) { if (protoProps) event_defineProperties(Constructor.prototype, protoProps); if (staticProps) event_defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction event_classPrivateFieldInitSpec(obj, privateMap, value) { event_checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\n\nfunction event_checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }\n\nfunction event_classPrivateFieldGet(receiver, privateMap) { var descriptor = event_classExtractFieldDescriptor(receiver, privateMap, "get"); return event_classApplyDescriptorGet(receiver, descriptor); }\n\nfunction event_classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\nfunction event_classPrivateFieldSet(receiver, privateMap, value) { var descriptor = event_classExtractFieldDescriptor(receiver, privateMap, "set"); event_classApplyDescriptorSet(receiver, descriptor, value); return value; }\n\nfunction event_classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }\n\nfunction event_classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }\n\n\n\n\nvar _events = /*#__PURE__*/new WeakMap();\n\nvar Event = /*#__PURE__*/function () {\n function Event() {\n event_classCallCheck(this, Event);\n\n event_classPrivateFieldInitSpec(this, _events, {\n writable: true,\n value: void 0\n });\n }\n\n event_createClass(Event, [{\n key: "initial",\n value: function initial(_ref) {\n var events = _ref.events;\n\n event_classPrivateFieldSet(this, _events, events);\n\n for (var id in events) {\n var event = events[id];\n if (!event.branch) continue;\n event.branch = event.branch.map(function (b) {\n b = b.split(\':\');\n b[1] = Number(b[1]);\n return b;\n });\n }\n }\n }, {\n key: "check",\n value: function check(eventId, property) {\n var _this$get = this.get(eventId),\n include = _this$get.include,\n exclude = _this$get.exclude,\n NoRandom = _this$get.NoRandom;\n\n if (NoRandom) return false;\n if (exclude && checkCondition(property, exclude)) return false;\n if (include) return checkCondition(property, include);\n return true;\n }\n }, {\n key: "get",\n value: function get(eventId) {\n var event = event_classPrivateFieldGet(this, _events)[eventId];\n\n if (!event) throw new Error("[ERROR] No Event[".concat(eventId, "]"));\n return clone(event);\n }\n }, {\n key: "information",\n value: function information(eventId) {\n var _this$get2 = this.get(eventId),\n description = _this$get2.event;\n\n return {\n description: description\n };\n }\n }, {\n key: "do",\n value: function _do(eventId, property) {\n var _this$get3 = this.get(eventId),\n effect = _this$get3.effect,\n branch = _this$get3.branch,\n description = _this$get3.event,\n postEvent = _this$get3.postEvent;\n\n if (branch) {\n var _iterator = event_createForOfIteratorHelper(branch),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _step$value = _slicedToArray(_step.value, 2),\n cond = _step$value[0],\n next = _step$value[1];\n\n if (checkCondition(property, cond)) return {\n effect: effect,\n next: next,\n description: description\n };\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n }\n\n return {\n effect: effect,\n postEvent: postEvent,\n description: description\n };\n }\n }]);\n\n return Event;\n}();\n\n/* harmony default export */ const src_event = (Event);\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.fill.js\nvar es_array_fill = __webpack_require__(3290);\n;// CONCATENATED MODULE: ./src/talent.js\nfunction talent_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = talent_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction talent_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return talent_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return talent_arrayLikeToArray(o, minLen); }\n\nfunction talent_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction talent_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction talent_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction talent_createClass(Constructor, protoProps, staticProps) { if (protoProps) talent_defineProperties(Constructor.prototype, protoProps); if (staticProps) talent_defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction talent_classPrivateFieldInitSpec(obj, privateMap, value) { talent_checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\n\nfunction talent_checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }\n\nfunction talent_classPrivateFieldGet(receiver, privateMap) { var descriptor = talent_classExtractFieldDescriptor(receiver, privateMap, "get"); return talent_classApplyDescriptorGet(receiver, descriptor); }\n\nfunction talent_classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\nfunction talent_classPrivateFieldSet(receiver, privateMap, value) { var descriptor = talent_classExtractFieldDescriptor(receiver, privateMap, "set"); talent_classApplyDescriptorSet(receiver, descriptor, value); return value; }\n\nfunction talent_classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }\n\nfunction talent_classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }\n\n\n\n\nvar _talents = /*#__PURE__*/new WeakMap();\n\nvar Talent = /*#__PURE__*/function () {\n function Talent() {\n talent_classCallCheck(this, Talent);\n\n talent_classPrivateFieldInitSpec(this, _talents, {\n writable: true,\n value: void 0\n });\n }\n\n talent_createClass(Talent, [{\n key: "initial",\n value: function initial(_ref) {\n var talents = _ref.talents;\n\n talent_classPrivateFieldSet(this, _talents, talents);\n\n for (var id in talents) {\n var talent = talents[id];\n talent.id = Number(id);\n talent.grade = Number(talent.grade);\n }\n }\n }, {\n key: "check",\n value: function check(talentId, property) {\n var _this$get = this.get(talentId),\n condition = _this$get.condition;\n\n return checkCondition(property, condition);\n }\n }, {\n key: "get",\n value: function get(talentId) {\n var talent = talent_classPrivateFieldGet(this, _talents)[talentId];\n\n if (!talent) throw new Error("[ERROR] No Talent[".concat(talentId, "]"));\n return clone(talent);\n }\n }, {\n key: "information",\n value: function information(talentId) {\n var _this$get2 = this.get(talentId),\n grade = _this$get2.grade,\n name = _this$get2.name,\n description = _this$get2.description;\n\n return {\n grade: grade,\n name: name,\n description: description\n };\n }\n }, {\n key: "exclusive",\n value: function exclusive(talends, exclusiveId) {\n var _this$get3 = this.get(exclusiveId),\n exclusive = _this$get3.exclusive;\n\n if (!exclusive) return null;\n\n var _iterator = talent_createForOfIteratorHelper(talends),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var talent = _step.value;\n\n var _iterator2 = talent_createForOfIteratorHelper(exclusive),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var e = _step2.value;\n if (talent == e) return talent;\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return null;\n }\n }, {\n key: "talentRandom",\n value: function talentRandom(include) {\n // 1000, 100, 10, 1\n var talentList = {};\n\n for (var talentId in talent_classPrivateFieldGet(this, _talents)) {\n var _classPrivateFieldGet2 = talent_classPrivateFieldGet(this, _talents)[talentId],\n id = _classPrivateFieldGet2.id,\n grade = _classPrivateFieldGet2.grade,\n name = _classPrivateFieldGet2.name,\n description = _classPrivateFieldGet2.description;\n\n if (id == include) {\n include = {\n grade: grade,\n name: name,\n description: description,\n id: id\n };\n continue;\n }\n\n if (!talentList[grade]) talentList[grade] = [{\n grade: grade,\n name: name,\n description: description,\n id: id\n }];else talentList[grade].push({\n grade: grade,\n name: name,\n description: description,\n id: id\n });\n }\n\n return new Array(10).fill(1).map(function (v, i) {\n if (!i && include) return include;\n var gradeRandom = Math.random();\n var grade;\n if (gradeRandom >= 0.111) grade = 0;else if (gradeRandom >= 0.011) grade = 1;else if (gradeRandom >= 0.001) grade = 2;else grade = 3;\n\n while (talentList[grade].length == 0) {\n grade--;\n }\n\n var length = talentList[grade].length;\n var random = Math.floor(Math.random() * length) % length;\n return talentList[grade].splice(random, 1)[0];\n });\n }\n }, {\n key: "allocationAddition",\n value: function allocationAddition(talents) {\n if (Array.isArray(talents)) {\n var addition = 0;\n\n var _iterator3 = talent_createForOfIteratorHelper(talents),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var talent = _step3.value;\n addition += this.allocationAddition(talent);\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n\n return addition;\n }\n\n return Number(this.get(talents).status) || 0;\n }\n }, {\n key: "do",\n value: function _do(talentId, property) {\n var _this$get4 = this.get(talentId),\n effect = _this$get4.effect,\n condition = _this$get4.condition,\n grade = _this$get4.grade,\n name = _this$get4.name,\n description = _this$get4.description;\n\n if (condition && !checkCondition(property, condition)) return null;\n return {\n effect: effect,\n grade: grade,\n name: name,\n description: description\n };\n }\n }]);\n\n return Talent;\n}();\n\n/* harmony default export */ const talent = (Talent);\n;// CONCATENATED MODULE: ./src/life.js\nfunction life_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = life_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction life_slicedToArray(arr, i) { return life_arrayWithHoles(arr) || life_iterableToArrayLimit(arr, i) || life_unsupportedIterableToArray(arr, i) || life_nonIterableRest(); }\n\nfunction life_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }\n\nfunction life_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return life_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return life_arrayLikeToArray(o, minLen); }\n\nfunction life_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction life_iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction life_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }\n\nfunction life_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction life_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction life_createClass(Constructor, protoProps, staticProps) { if (protoProps) life_defineProperties(Constructor.prototype, protoProps); if (staticProps) life_defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction life_classPrivateFieldInitSpec(obj, privateMap, value) { life_checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\n\nfunction life_checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }\n\nfunction life_classPrivateFieldGet(receiver, privateMap) { var descriptor = life_classExtractFieldDescriptor(receiver, privateMap, "get"); return life_classApplyDescriptorGet(receiver, descriptor); }\n\nfunction life_classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\nfunction life_classPrivateFieldSet(receiver, privateMap, value) { var descriptor = life_classExtractFieldDescriptor(receiver, privateMap, "set"); life_classApplyDescriptorSet(receiver, descriptor, value); return value; }\n\nfunction life_classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }\n\nfunction life_classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }\n\n\n\n\n\nvar _property = /*#__PURE__*/new WeakMap();\n\nvar _event = /*#__PURE__*/new WeakMap();\n\nvar _talent = /*#__PURE__*/new WeakMap();\n\nvar _triggerTalents = /*#__PURE__*/new WeakMap();\n\nvar Life = /*#__PURE__*/function () {\n function Life() {\n life_classCallCheck(this, Life);\n\n life_classPrivateFieldInitSpec(this, _property, {\n writable: true,\n value: void 0\n });\n\n life_classPrivateFieldInitSpec(this, _event, {\n writable: true,\n value: void 0\n });\n\n life_classPrivateFieldInitSpec(this, _talent, {\n writable: true,\n value: void 0\n });\n\n life_classPrivateFieldInitSpec(this, _triggerTalents, {\n writable: true,\n value: void 0\n });\n\n life_classPrivateFieldSet(this, _property, new property());\n\n life_classPrivateFieldSet(this, _event, new src_event());\n\n life_classPrivateFieldSet(this, _talent, new talent());\n }\n\n life_createClass(Life, [{\n key: "initial",\n value: function () {\n var _initial = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var _yield$Promise$all, _yield$Promise$all2, age, talents, events;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return Promise.all([json(\'age\'), json(\'talents\'), json(\'events\')]);\n\n case 2:\n _yield$Promise$all = _context.sent;\n _yield$Promise$all2 = life_slicedToArray(_yield$Promise$all, 3);\n age = _yield$Promise$all2[0];\n talents = _yield$Promise$all2[1];\n events = _yield$Promise$all2[2];\n\n life_classPrivateFieldGet(this, _property).initial({\n age: age\n });\n\n life_classPrivateFieldGet(this, _talent).initial({\n talents: talents\n });\n\n life_classPrivateFieldGet(this, _event).initial({\n events: events\n });\n\n case 10:\n case "end":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function initial() {\n return _initial.apply(this, arguments);\n }\n\n return initial;\n }()\n }, {\n key: "restart",\n value: function restart(allocation) {\n life_classPrivateFieldSet(this, _triggerTalents, new Set());\n\n life_classPrivateFieldGet(this, _property).restart(allocation);\n\n this.doTalent();\n\n life_classPrivateFieldGet(this, _property).record();\n }\n }, {\n key: "getTalentAllocationAddition",\n value: function getTalentAllocationAddition(talents) {\n return life_classPrivateFieldGet(this, _talent).allocationAddition(talents);\n }\n }, {\n key: "next",\n value: function next() {\n var _classPrivateFieldGet2 = life_classPrivateFieldGet(this, _property).ageNext(),\n age = _classPrivateFieldGet2.age,\n event = _classPrivateFieldGet2.event,\n talent = _classPrivateFieldGet2.talent;\n\n var talentContent = this.doTalent(talent);\n var eventContent = this.doEvent(this.random(event));\n\n life_classPrivateFieldGet(this, _property).record();\n\n var isEnd = life_classPrivateFieldGet(this, _property).isEnd();\n\n var content = [talentContent, eventContent].flat();\n return {\n age: age,\n content: content,\n isEnd: isEnd\n };\n }\n }, {\n key: "doTalent",\n value: function doTalent(talents) {\n var _this = this;\n\n if (talents) life_classPrivateFieldGet(this, _property).change(life_classPrivateFieldGet(this, _property).TYPES.TLT, talents);\n talents = life_classPrivateFieldGet(this, _property).get(life_classPrivateFieldGet(this, _property).TYPES.TLT).filter(function (talentId) {\n return !life_classPrivateFieldGet(_this, _triggerTalents).has(talentId);\n });\n var contents = [];\n\n var _iterator = life_createForOfIteratorHelper(talents),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var talentId = _step.value;\n\n var result = life_classPrivateFieldGet(this, _talent).do(talentId, life_classPrivateFieldGet(this, _property));\n\n if (!result) continue;\n\n life_classPrivateFieldGet(this, _triggerTalents).add(talentId);\n\n var effect = result.effect,\n name = result.name,\n description = result.description,\n grade = result.grade;\n contents.push({\n type: life_classPrivateFieldGet(this, _property).TYPES.TLT,\n name: name,\n grade: grade,\n description: description\n });\n if (!effect) continue;\n\n life_classPrivateFieldGet(this, _property).effect(effect);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return contents;\n }\n }, {\n key: "doEvent",\n value: function doEvent(eventId) {\n var _classPrivateFieldGet3 = life_classPrivateFieldGet(this, _event).do(eventId, life_classPrivateFieldGet(this, _property)),\n effect = _classPrivateFieldGet3.effect,\n next = _classPrivateFieldGet3.next,\n description = _classPrivateFieldGet3.description,\n postEvent = _classPrivateFieldGet3.postEvent;\n\n life_classPrivateFieldGet(this, _property).change(life_classPrivateFieldGet(this, _property).TYPES.EVT, eventId);\n\n life_classPrivateFieldGet(this, _property).effect(effect);\n\n var content = {\n type: life_classPrivateFieldGet(this, _property).TYPES.EVT,\n description: description,\n postEvent: postEvent\n };\n if (next) return [content, this.doEvent(next)].flat();\n return [content];\n }\n }, {\n key: "random",\n value: function random(events) {\n var _this2 = this;\n\n events = events.filter(function (_ref) {\n var _ref2 = life_slicedToArray(_ref, 1),\n eventId = _ref2[0];\n\n return life_classPrivateFieldGet(_this2, _event).check(eventId, life_classPrivateFieldGet(_this2, _property));\n });\n var totalWeights = 0;\n\n var _iterator2 = life_createForOfIteratorHelper(events),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var _step2$value = life_slicedToArray(_step2.value, 2),\n weight = _step2$value[1];\n\n totalWeights += weight;\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n var random = Math.random() * totalWeights;\n\n var _iterator3 = life_createForOfIteratorHelper(events),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var _step3$value = life_slicedToArray(_step3.value, 2),\n eventId = _step3$value[0],\n _weight = _step3$value[1];\n\n if ((random -= _weight) < 0) return eventId;\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n\n return events[events.length - 1];\n }\n }, {\n key: "talentRandom",\n value: function talentRandom() {\n return life_classPrivateFieldGet(this, _talent).talentRandom(JSON.parse(localStorage.extendTalent || \'null\'));\n }\n }, {\n key: "talentExtend",\n value: function talentExtend(talentId) {\n localStorage.extendTalent = JSON.stringify(talentId);\n }\n }, {\n key: "getRecord",\n value: function getRecord() {\n return life_classPrivateFieldGet(this, _property).getRecord();\n }\n }, {\n key: "getLastRecord",\n value: function getLastRecord() {\n return life_classPrivateFieldGet(this, _property).getLastRecord();\n }\n }, {\n key: "exclusive",\n value: function exclusive(talents, _exclusive) {\n return life_classPrivateFieldGet(this, _talent).exclusive(talents, _exclusive);\n }\n }]);\n\n return Life;\n}();\n\n/* harmony default export */ const life = (Life);\n;// CONCATENATED MODULE: ./src/app.js\nfunction app_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = app_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction app_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return app_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return app_arrayLikeToArray(o, minLen); }\n\nfunction app_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n\nfunction app_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction app_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { app_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { app_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction app_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction app_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction app_createClass(Constructor, protoProps, staticProps) { if (protoProps) app_defineProperties(Constructor.prototype, protoProps); if (staticProps) app_defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction app_classPrivateFieldInitSpec(obj, privateMap, value) { app_checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\n\nfunction app_checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }\n\nfunction app_classPrivateFieldGet(receiver, privateMap) { var descriptor = app_classExtractFieldDescriptor(receiver, privateMap, "get"); return app_classApplyDescriptorGet(receiver, descriptor); }\n\nfunction app_classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\nfunction app_classPrivateFieldSet(receiver, privateMap, value) { var descriptor = app_classExtractFieldDescriptor(receiver, privateMap, "set"); app_classApplyDescriptorSet(receiver, descriptor, value); return value; }\n\nfunction app_classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }\n\nfunction app_classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }\n\n\n\n\n\nvar _life = /*#__PURE__*/new WeakMap();\n\nvar _pages = /*#__PURE__*/new WeakMap();\n\nvar _talentSelected = /*#__PURE__*/new WeakMap();\n\nvar _totalMax = /*#__PURE__*/new WeakMap();\n\nvar _isEnd = /*#__PURE__*/new WeakMap();\n\nvar _selectedExtendTalent = /*#__PURE__*/new WeakMap();\n\nvar _hintTimeout = /*#__PURE__*/new WeakMap();\n\nvar App = /*#__PURE__*/function () {\n function App() {\n app_classCallCheck(this, App);\n\n app_classPrivateFieldInitSpec(this, _life, {\n writable: true,\n value: void 0\n });\n\n app_classPrivateFieldInitSpec(this, _pages, {\n writable: true,\n value: void 0\n });\n\n app_classPrivateFieldInitSpec(this, _talentSelected, {\n writable: true,\n value: new Set()\n });\n\n app_classPrivateFieldInitSpec(this, _totalMax, {\n writable: true,\n value: 20\n });\n\n app_classPrivateFieldInitSpec(this, _isEnd, {\n writable: true,\n value: false\n });\n\n app_classPrivateFieldInitSpec(this, _selectedExtendTalent, {\n writable: true,\n value: null\n });\n\n app_classPrivateFieldInitSpec(this, _hintTimeout, {\n writable: true,\n value: void 0\n });\n\n app_classPrivateFieldSet(this, _life, new life());\n }\n\n app_createClass(App, [{\n key: "initial",\n value: function () {\n var _initial = app_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n var _this = this;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n this.initPages();\n this.switch(\'loading\');\n _context.next = 4;\n return app_classPrivateFieldGet(this, _life).initial();\n\n case 4:\n this.switch(\'index\');\n\n window.onerror = function (event, source, lineno, colno, error) {\n _this.hint("[ERROR] at (".concat(source, ":").concat(lineno, ":").concat(colno, ")\\n\\n").concat((error === null || error === void 0 ? void 0 : error.stack) || error || \'unknow Error\'), \'error\');\n };\n\n case 6:\n case "end":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function initial() {\n return _initial.apply(this, arguments);\n }\n\n return initial;\n }()\n }, {\n key: "initPages",\n value: function initPages() {\n var _this2 = this;\n\n // Loading\n var loadingPage = $("\\n
    \\n
    \\n \\u4EBA\\u751F\\u91CD\\u5F00\\u6A21\\u62DF\\u5668
    \\n
    \\u52A0\\u8F7D\\u4E2D...
    \\n
    \\n
    \\n "); // Index\n\n var indexPage = $("\\n
    \\n
    \\u5DF2\\u91CD\\u5F001\\u6B21
    \\n \\n \\n
    \\n \\u4EBA\\u751F\\u91CD\\u5F00\\u6A21\\u62DF\\u5668
    \\n
    \\u8FD9\\u5783\\u573E\\u4EBA\\u751F\\u4E00\\u79D2\\u4E5F\\u4E0D\\u60F3\\u5446\\u4E86
    \\n
    \\n \\n
    \\n "); // Init theme\n\n this.setTheme(localStorage.getItem(\'theme\'));\n indexPage.find(\'#restart\').click(function () {\n return _this2.switch(\'talent\');\n });\n indexPage.find(\'#rank\').click(function () {\n return _this2.hint(\'别卷了!没有排行榜\');\n });\n indexPage.find("#themeToggleBtn").click(function () {\n if (localStorage.getItem(\'theme\') == \'light\') {\n localStorage.setItem(\'theme\', \'dark\');\n } else {\n localStorage.setItem(\'theme\', \'light\');\n }\n\n _this2.setTheme(localStorage.getItem(\'theme\'));\n }); // Talent\n\n var talentPage = $("\\n
    \\n
    \\u5929\\u8D4B\\u62BD\\u5361
    \\n \\n
      \\n \\n
      \\n ");\n\n var createTalent = function createTalent(_ref) {\n var grade = _ref.grade,\n name = _ref.name,\n description = _ref.description;\n return $("
    • ").concat(name, "\\uFF08").concat(description, "\\uFF09
    • "));\n };\n\n talentPage.find(\'#random\').click(function () {\n talentPage.find(\'#random\').hide();\n var ul = talentPage.find(\'#talents\');\n\n app_classPrivateFieldGet(_this2, _life).talentRandom().forEach(function (talent) {\n var li = createTalent(talent);\n ul.append(li);\n li.click(function () {\n if (li.hasClass(\'selected\')) {\n li.removeClass(\'selected\');\n\n app_classPrivateFieldGet(_this2, _talentSelected).delete(talent);\n\n if (app_classPrivateFieldGet(_this2, _talentSelected).size < 3) {\n talentPage.find(\'#next\').text(\'请选择3个\');\n }\n } else {\n if (app_classPrivateFieldGet(_this2, _talentSelected).size == 3) {\n _this2.hint(\'只能选3个天赋\');\n\n return;\n }\n\n var exclusive = app_classPrivateFieldGet(_this2, _life).exclusive(Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref2) {\n var id = _ref2.id;\n return id;\n }), talent.id);\n\n if (exclusive != null) {\n var _iterator = app_createForOfIteratorHelper(app_classPrivateFieldGet(_this2, _talentSelected)),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _step$value = _step.value,\n name = _step$value.name,\n id = _step$value.id;\n\n if (id == exclusive) {\n _this2.hint("\\u4E0E\\u5DF2\\u9009\\u62E9\\u7684\\u5929\\u8D4B\\u3010".concat(name, "\\u3011\\u51B2\\u7A81"));\n\n return;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return;\n }\n\n li.addClass(\'selected\');\n\n app_classPrivateFieldGet(_this2, _talentSelected).add(talent);\n\n if (app_classPrivateFieldGet(_this2, _talentSelected).size == 3) {\n talentPage.find(\'#next\').text(\'开始新人生\');\n }\n }\n });\n });\n });\n talentPage.find(\'#next\').click(function () {\n if (app_classPrivateFieldGet(_this2, _talentSelected).size != 3) {\n _this2.hint(\'请选择3个天赋\');\n\n return;\n }\n\n app_classPrivateFieldSet(_this2, _totalMax, 20 + app_classPrivateFieldGet(_this2, _life).getTalentAllocationAddition(Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref3) {\n var id = _ref3.id;\n return id;\n })));\n\n _this2.switch(\'property\');\n }); // Property\n // hint of extension tobermory.es6-string-html\n\n var propertyPage = $(\n /*html*/\n "\\n
      \\n
      \\n \\u8C03\\u6574\\u521D\\u59CB\\u5C5E\\u6027
      \\n
      \\u53EF\\u7528\\u5C5E\\u6027\\u70B9\\uFF1A0
      \\n
      \\n
        \\n
          \\n \\n \\n
          \\n ");\n\n propertyPage.mounted = function () {\n propertyPage.find(\'#talentSelectedView\').append("
        • \\u5DF2\\u9009\\u5929\\u8D4B
        • " + Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref4) {\n var name = _ref4.name,\n description = _ref4.description;\n return "
        • ".concat(name, "(").concat(description, ")
        • ");\n }).join(\'\'));\n };\n\n var groups = {};\n\n var total = function total() {\n var t = 0;\n\n for (var type in groups) {\n t += groups[type].get();\n }\n\n return t;\n };\n\n var freshTotal = function freshTotal() {\n propertyPage.find(\'#total\').text("\\u53EF\\u7528\\u5C5E\\u6027\\u70B9\\uFF1A".concat(app_classPrivateFieldGet(_this2, _totalMax) - total()));\n };\n\n var getBtnGroups = function getBtnGroups(name, min, max) {\n var group = $("
        • ".concat(name, "      
        • "));\n var btnSub = $("");\n var inputBox = $("");\n var btnAdd = $("");\n group.append(btnSub);\n group.append(inputBox);\n group.append(btnAdd);\n\n var limit = function limit(v) {\n v = Number(v) || 0;\n v = Math.round(v);\n return v < min ? min : v > max ? max : v;\n };\n\n var get = function get() {\n return Number(inputBox.val());\n };\n\n var set = function set(v) {\n inputBox.val(limit(v));\n freshTotal();\n };\n\n btnAdd.click(function () {\n if (total() >= app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint(\'没有可分配的点数了\');\n\n return;\n }\n\n set(get() + 1);\n });\n btnSub.click(function () {\n return set(get() - 1);\n });\n inputBox.on(\'input\', function () {\n var t = total();\n var val = get();\n\n if (t > app_classPrivateFieldGet(_this2, _totalMax)) {\n val -= t - app_classPrivateFieldGet(_this2, _totalMax);\n }\n\n val = limit(val);\n\n if (val != inputBox.val()) {\n set(val);\n }\n\n freshTotal();\n });\n return {\n group: group,\n get: get,\n set: set\n };\n };\n\n groups.CHR = getBtnGroups("颜值", 0, 10); // 颜值 charm CHR\n\n groups.INT = getBtnGroups("智力", 0, 10); // 智力 intelligence INT\n\n groups.STR = getBtnGroups("体质", 0, 10); // 体质 strength STR\n\n groups.MNY = getBtnGroups("家境", 0, 10); // 家境 money MNY\n\n var ul = propertyPage.find(\'#propertyAllocation\');\n\n for (var type in groups) {\n ul.append(groups[type].group);\n }\n\n propertyPage.find(\'#random\').click(function () {\n var t = app_classPrivateFieldGet(_this2, _totalMax);\n\n var arr = [10, 10, 10, 10];\n\n while (t > 0) {\n var sub = Math.round(Math.random() * (Math.min(t, 10) - 1)) + 1;\n\n while (true) {\n var select = Math.floor(Math.random() * 4) % 4;\n if (arr[select] - sub < 0) continue;\n arr[select] -= sub;\n t -= sub;\n break;\n }\n }\n\n groups.CHR.set(10 - arr[0]);\n groups.INT.set(10 - arr[1]);\n groups.STR.set(10 - arr[2]);\n groups.MNY.set(10 - arr[3]);\n });\n propertyPage.find(\'#start\').click(function () {\n if (total() < app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint("\\u4F60\\u8FD8\\u6709".concat(app_classPrivateFieldGet(_this2, _totalMax) - total(), "\\u5C5E\\u6027\\u70B9\\u6CA1\\u6709\\u5206\\u914D\\u5B8C"));\n\n return;\n } else if (total() > app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint("\\u4F60\\u591A\\u4F7F\\u7528\\u4E86".concat(total() - app_classPrivateFieldGet(_this2, _totalMax), "\\u5C5E\\u6027\\u70B9"));\n\n return;\n }\n\n app_classPrivateFieldGet(_this2, _life).restart({\n CHR: groups.CHR.get(),\n INT: groups.INT.get(),\n STR: groups.STR.get(),\n MNY: groups.MNY.get(),\n SPR: 5,\n TLT: Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref5) {\n var id = _ref5.id;\n return id;\n })\n });\n\n _this2.switch(\'trajectory\');\n\n app_classPrivateFieldGet(_this2, _pages).trajectory.born();\n\n $(document).keydown(function (event) {\n if (event.which == 32 || event.which == 13) {\n $(\'#lifeTrajectory\').click();\n }\n });\n }); // Trajectory\n\n var trajectoryPage = $("\\n
          \\n
            \\n
              \\n \\n
              \\n ");\n trajectoryPage.find(\'#lifeTrajectory\').click(function () {\n if (app_classPrivateFieldGet(_this2, _isEnd)) return;\n\n var trajectory = app_classPrivateFieldGet(_this2, _life).next();\n\n var age = trajectory.age,\n content = trajectory.content,\n isEnd = trajectory.isEnd;\n var li = $("
            • ".concat(age, "\\u5C81\\uFF1A").concat(content.map(function (_ref6) {\n var type = _ref6.type,\n description = _ref6.description,\n grade = _ref6.grade,\n name = _ref6.name,\n postEvent = _ref6.postEvent;\n\n switch (type) {\n case \'TLT\':\n return "\\u5929\\u8D4B\\u3010".concat(name, "\\u3011\\u53D1\\u52A8\\uFF1A").concat(description);\n\n case \'EVT\':\n return description + (postEvent ? "
              ".concat(postEvent) : \'\');\n }\n }).join(\'
              \'), "
            • "));\n li.appendTo(\'#lifeTrajectory\');\n $("#lifeTrajectory").scrollTop($("#lifeTrajectory")[0].scrollHeight);\n\n if (isEnd) {\n $(document).unbind("keydown");\n\n app_classPrivateFieldSet(_this2, _isEnd, true);\n\n trajectoryPage.find(\'#summary\').show();\n } else {\n // 如未死亡,更新数值\n // Update properties if not die yet\n var property = app_classPrivateFieldGet(_this2, _life).getLastRecord();\n\n $("#lifeProperty").html("\\n
            • \\u989C\\u503C\\uFF1A".concat(property.CHR, "
            • \\n
            • \\u667A\\u529B\\uFF1A").concat(property.INT, "
            • \\n
            • \\u4F53\\u8D28\\uFF1A").concat(property.STR, "
            • \\n
            • \\u5BB6\\u5883\\uFF1A").concat(property.MNY, "
            • \\n
            • \\u5FEB\\u4E50\\uFF1A").concat(property.SPR, "
            • "));\n }\n });\n trajectoryPage.find(\'#summary\').click(function () {\n _this2.switch(\'summary\');\n }); // Summary\n\n var summaryPage = $("\\n
              \\n
              \\u4EBA\\u751F\\u603B\\u7ED3
              \\n
                \\n
              • \\u989C\\u503C\\uFF1A9\\u7EA7 \\u7F8E\\u82E5\\u5929\\u4ED9
              • \\n
              • \\u667A\\u529B\\uFF1A4\\u7EA7 \\u667A\\u529B\\u4E00\\u822C
              • \\n
              • \\u4F53\\u8D28\\uFF1A1\\u7EA7 \\u6781\\u5EA6\\u865A\\u5F31
              • \\n
              • \\u5BB6\\u5883\\uFF1A6\\u7EA7 \\u5C0F\\u5EB7\\u4E4B\\u5BB6
              • \\n
              • \\u4EAB\\u5E74\\uFF1A3\\u5C81 \\u65E9\\u592D
              • \\n
              • \\u5FEB\\u4E50\\uFF1A3\\u7EA7 \\u4E0D\\u592A\\u5E78\\u798F\\u7684\\u4EBA\\u751F
              • \\n
              \\n
              \\u5929\\u8D4B\\uFF0C\\u4F60\\u53EF\\u4EE5\\u9009\\u4E00\\u4E2A\\uFF0C\\u4E0B\\u8F88\\u5B50\\u8FD8\\u80FD\\u62BD\\u5230
              \\n
                \\n
              • \\u9ED1\\u5E55\\uFF08\\u9762\\u8BD5\\u4E00\\u5B9A\\u6210\\u529F\\uFF09
              • \\n
              \\n \\n
              \\n ");\n summaryPage.find(\'#again\').click(function () {\n _this2.times++;\n\n app_classPrivateFieldGet(_this2, _life).talentExtend(app_classPrivateFieldGet(_this2, _selectedExtendTalent));\n\n app_classPrivateFieldSet(_this2, _selectedExtendTalent, null);\n\n app_classPrivateFieldGet(_this2, _talentSelected).clear();\n\n app_classPrivateFieldSet(_this2, _totalMax, 20);\n\n app_classPrivateFieldSet(_this2, _isEnd, false);\n\n _this2.switch(\'index\');\n });\n\n app_classPrivateFieldSet(this, _pages, {\n loading: {\n page: loadingPage,\n clear: function clear() {}\n },\n index: {\n page: indexPage,\n btnRank: indexPage.find(\'#rank\'),\n btnRestart: indexPage.find(\'#restart\'),\n hint: indexPage.find(\'.hint\'),\n cnt: indexPage.find(\'#cnt\'),\n clear: function clear() {\n indexPage.find(\'.hint\').hide();\n var times = _this2.times;\n var btnRank = indexPage.find(\'#rank\');\n var cnt = indexPage.find(\'#cnt\');\n\n if (times > 0) {\n btnRank.show();\n cnt.show();\n cnt.text("\\u5DF2\\u91CD\\u5F00".concat(times, "\\u6B21"));\n return;\n }\n\n btnRank.hide();\n cnt.hide();\n }\n },\n talent: {\n page: talentPage,\n clear: function clear() {\n talentPage.find(\'ul.selectlist\').empty();\n talentPage.find(\'#random\').show();\n\n app_classPrivateFieldSet(_this2, _totalMax, 20);\n }\n },\n property: {\n page: propertyPage,\n clear: function clear() {\n freshTotal();\n propertyPage.find(\'#talentSelectedView\').empty();\n }\n },\n trajectory: {\n page: trajectoryPage,\n clear: function clear() {\n trajectoryPage.find(\'#lifeTrajectory\').empty();\n trajectoryPage.find(\'#summary\').hide();\n\n app_classPrivateFieldSet(_this2, _isEnd, false);\n },\n born: function born() {\n trajectoryPage.find(\'#lifeTrajectory\').trigger("click");\n }\n },\n summary: {\n page: summaryPage,\n clear: function clear() {\n var judge = summaryPage.find(\'#judge\');\n var talents = summaryPage.find(\'#talents\');\n judge.empty();\n talents.empty();\n\n app_classPrivateFieldGet(_this2, _talentSelected).forEach(function (talent) {\n var li = createTalent(talent);\n talents.append(li);\n li.click(function () {\n if (li.hasClass(\'selected\')) {\n app_classPrivateFieldSet(_this2, _selectedExtendTalent, null);\n\n li.removeClass(\'selected\');\n } else if (app_classPrivateFieldGet(_this2, _selectedExtendTalent) != null) {\n _this2.hint(\'只能继承一个天赋\');\n\n return;\n } else {\n app_classPrivateFieldSet(_this2, _selectedExtendTalent, talent.id);\n\n li.addClass(\'selected\');\n }\n });\n });\n\n var records = app_classPrivateFieldGet(_this2, _life).getRecord();\n\n var s = function s(type, func) {\n var value = func(records.map(function (_ref7) {\n var v = _ref7[type];\n return v;\n }));\n\n var _summary = summary(type, value),\n judge = _summary.judge,\n grade = _summary.grade;\n\n return {\n judge: judge,\n grade: grade,\n value: value\n };\n };\n\n console.table(records);\n console.debug(records);\n judge.append([function () {\n var _s = s(\'CHR\', max),\n judge = _s.judge,\n grade = _s.grade,\n value = _s.value;\n\n return "
            • \\u989C\\u503C\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var _s2 = s(\'INT\', max),\n judge = _s2.judge,\n grade = _s2.grade,\n value = _s2.value;\n\n return "
            • \\u667A\\u529B\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var _s3 = s(\'STR\', max),\n judge = _s3.judge,\n grade = _s3.grade,\n value = _s3.value;\n\n return "
            • \\u4F53\\u8D28\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var _s4 = s(\'MNY\', max),\n judge = _s4.judge,\n grade = _s4.grade,\n value = _s4.value;\n\n return "
            • \\u5BB6\\u5883\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var _s5 = s(\'SPR\', max),\n judge = _s5.judge,\n grade = _s5.grade,\n value = _s5.value;\n\n return "
            • \\u5FEB\\u4E50\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var _s6 = s(\'AGE\', max),\n judge = _s6.judge,\n grade = _s6.grade,\n value = _s6.value;\n\n return "
            • \\u4EAB\\u5E74\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }(), function () {\n var m = function m(type) {\n return max(records.map(function (_ref8) {\n var value = _ref8[type];\n return value;\n }));\n };\n\n var value = Math.floor(sum(m(\'CHR\'), m(\'INT\'), m(\'STR\'), m(\'MNY\'), m(\'SPR\')) * 2 + m(\'AGE\') / 2);\n\n var _summary2 = summary(\'SUM\', value),\n judge = _summary2.judge,\n grade = _summary2.grade;\n\n return "
            • \\u603B\\u8BC4\\uFF1A").concat(value, " ").concat(judge, "
            • ");\n }()].join(\'\'));\n }\n }\n });\n }\n }, {\n key: "switch",\n value: function _switch(page) {\n var p = app_classPrivateFieldGet(this, _pages)[page];\n\n if (!p) return;\n $(\'#main\').detach();\n p.clear();\n p.page.appendTo(\'body\');\n\n if (typeof p.page.mounted === \'function\') {\n p.page.mounted();\n }\n }\n }, {\n key: "hint",\n value: function hint(message) {\n var _this3 = this;\n\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \'info\';\n\n if (app_classPrivateFieldGet(this, _hintTimeout)) {\n clearTimeout(app_classPrivateFieldGet(this, _hintTimeout));\n\n app_classPrivateFieldSet(this, _hintTimeout, null);\n }\n\n hideBanners();\n requestAnimationFrame(function () {\n var banner = $(".banner.".concat(type));\n banner.addClass(\'visible\');\n banner.find(\'.banner-message\').text(message);\n\n if (type != \'error\') {\n app_classPrivateFieldSet(_this3, _hintTimeout, setTimeout(hideBanners, 3000));\n }\n });\n }\n }, {\n key: "setTheme",\n value: function setTheme(theme) {\n var themeLink = $(document).find(\'#themeLink\');\n\n if (theme == \'light\') {\n themeLink.attr(\'href\', \'light.css\');\n } else {\n themeLink.attr(\'href\', \'dark.css\');\n }\n }\n }, {\n key: "times",\n get: function get() {\n return JSON.parse(localStorage.times || \'0\') || 0;\n },\n set: function set(v) {\n localStorage.times = JSON.stringify(parseInt(v) || 0);\n }\n }]);\n\n return App;\n}();\n\n/* harmony default export */ const app = (App);\n;// CONCATENATED MODULE: ./src/index.js\n\n\n\n\n\nfunction src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction src_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }\n\n\n\nwindow.json = /*#__PURE__*/function () {\n var _ref = src_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(fileName) {\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return fetch("./data/".concat(fileName, ".json"));\n\n case 2:\n _context.next = 4;\n return _context.sent.json();\n\n case 4:\n return _context.abrupt("return", _context.sent);\n\n case 5:\n case "end":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n}(); // Pssst, I\'ve created a github package - https://github.com/brookesb91/dismissible\n\n\nwindow.hideBanners = function (e) {\n document.querySelectorAll(".banner.visible").forEach(function (b) {\n return b.classList.remove("visible");\n });\n};\n\nvar src_app = new app();\nsrc_app.initial();//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTU0LmpzIiwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUFBO0FBQ0E7O0FBQ0E7QUFBQTtBQUFBOztBQUNBOztBQUNBO0FBQUE7QUFOQTtBQVFBOztBQUVBO0FBQUE7QUFBQTtBQUFBOztBQUNBO0FBQ0E7O0FBRUE7QUFBQTtBQUFBO0FBQUE7O0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQURBO0FBQUE7QUFBQTs7QUFFQTtBQUFBO0FBQUE7QUFDQTtBQUNBOztBQUVBO0FBQUE7QUFBQTtBQUFBOztBQUNBO0FBQ0E7QUFDQTs7OztBQzVCQTtBQUNBO0FBQ0E7QUFBQTtBQUFBO0FBQ0E7QUFBQTtBQUFBO0FBQUE7QUFDQTtBQUFBO0FBQUE7QUFBQTtBQUNBO0FBQUE7QUFBQTtBQUFBO0FBQ0E7QUFBQTtBQUFBO0FBQUE7QUFDQTtBQUFBO0FBQUE7QUFBQTtBQUNBO0FBQUE7QUFBQTtBQUFBO0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dn1gLnNwbGl0KCcqJykubWFwKG49Pk51bWJlcihuKSk7XG4gICAgICAgICAgICAgICAgaWYodmFsdWUubGVuZ3RoPT0xKSB2YWx1ZS5wdXNoKDEpO1xuICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICBpZighQXJyYXkuaXNBcnJheSh0YWxlbnQpKVxuICAgICAgICAgICAgICAgIHRhbGVudCA9IHRhbGVudD8uc3BsaXQoJywnKSB8fCBbXTtcblxuICAgICAgICAgICAgdGFsZW50ID0gdGFsZW50Lm1hcCh2PT5OdW1iZXIodikpO1xuXG4gICAgICAgICAgICBhZ2VbYV0gPSB7IGV2ZW50LCB0YWxlbnQgfTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJlc3RhcnQoZGF0YSkge1xuICAgICAgICB0aGlzLiNkYXRhID0ge1xuICAgICAgICAgICAgW3RoaXMuVFlQRVMuQUdFXTogLTEsXG4gICAgICAgICAgICBbdGhpcy5UWVBFUy5DSFJdOiAwLFxuICAgICAgICAgICAgW3RoaXMuVFlQRVMuSU5UXTogMCxcbiAgICAgICAgICAgIFt0aGlzLlRZUEVTLlNUUl06IDAsXG4gICAgICAgICAgICBbdGhpcy5UWVBFUy5NTlldOiAwLFxuICAgICAgICAgICAgW3RoaXMuVFlQRVMuU1BSXTogMCxcbiAgICAgICAgICAgIFt0aGlzLlRZUEVTLkxJRl06IDEsXG4gICAgICAgICAgICBbdGhpcy5UWVBFUy5UTFRdOiBbXSxcbiAgICAgICAgICAgIFt0aGlzLlRZUEVTLkVWVF06IFtdLFxuICAgICAgICB9O1xuICAgICAgICBmb3IoY29uc3Qga2V5IGluIGRhdGEpXG4gICAgICAgICAgICB0aGlzLmNoYW5nZShrZXksIGRhdGFba2V5XSk7XG4gICAgICAgIHRoaXMuI3JlY29yZCA9IFtdO1xuICAgIH1cblxuICAgIGdldChwcm9wKSB7XG4gICAgICAgIHN3aXRjaChwcm9wKSB7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BjYXNlIHRoaXMuVFlQRVMuQUdFOlxuICAgICAgICAgICAgY2FzZSB0aGlzLlRZUEVTLkNIUjpcbiAgICAgICAgICAgIGNhc2UgdGhpcy5UWVBFUy5JTlQ6XG4gICAgICAgICAgICBjYXNlIHRoaXMuVFlQRVMuU1RSOlxuICAgICAgICAgICAgY2FzZSB0aGlzLlRZUEVTLk1OWTpcbiAgICAgICAgICAgIGNhc2UgdGhpcy5UWVBFUy5TUFI6XG4gICAgICAgICAgICBjYXNlIHRoaXMuVFlQRVMuTElGOlxuICAgICAgICAgICAgICAgIHRoaXMuI2RhdGFbcHJvcF0gKz0gTnVtYmVyKHZhbHVlKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgdGhpcy5UWVBFUy5UTFQ6XG4gICAgICAgICAgICBjYXNlIHRoaXMuVFlQRVMuRVZUOlxuICAgICAgICAgICAgICAgIGNvbnN0IHYgPSB0aGlzLiNkYXRhW3Byb3BdO1xuICAgICAgICAgICAgICAgIGlmKHZhbHVlPDApIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB2LmluZGV4T2YodmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBpZihpbmRleCE9LTEpIHYuc3BsaWNlKGluZGV4LDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZighdi5pbmNsdWRlcyh2YWx1ZSkpIHYucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OiByZXR1cm47XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBlZmZlY3QoZWZmZWN0cykge1xuICAgICAgICBmb3IoY29uc3QgcHJvcCBpbiBlZmZlY3RzKVxuICAgICAgICAgICAgdGhpcy5jaGFuZ2UocHJvcCwgTnVtYmVyKGVmZmVjdHNbcHJvcF0pKTtcbiAgICB9XG5cbiAgICBpc0VuZCgpIHtcbiAgICAgICAgcmV0d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uICAgICAgICAgICAgICAgIGNhdGNoU3RyaW5nKGkpO1xuICAgICAgICAgICAgICAgIGN1cnNvciArKztcbiAgICAgICAgICAgICAgICBjb25zdCBzdWIgPSBbXTtcbiAgICAgICAgICAgICAgICBzdGFja1swXS5wdXNoKHN1Yik7XG4gICAgICAgICAgICAgICAgc3RhY2sudW5zaGlmdChzdWIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBjYXNlICcpJzpcbiAgICAgICAgICAgICAgICBjYXRjaFN0cmluZyhpKTtcbiAgICAgICAgICAgICAgICBjdXJzb3IgKys7XG4gICAgICAgICAgICAgICAgc3RhY2suc2hpZnQoKTtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgY2FzZSAnfCc6XG4gICAgICAgICAgICBjYXNlICcmJzpcbiAgICAgICAgICAgICAgICBjYXRjaFN0cmluZyhpKTtcbiAgICAgICAgICAgICAgICBjYXRjaFN0cmluZyhpKzEpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgZGVmYXVsdDogY29udGludWU7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjYXRjaFN0cmluZyhsZW5ndGgpO1xuXG4gICAgcmV0dXJuIGNvbmRpdGlvbnM7XG59XG5cbmZ1bmN0aW9uIGNoZWNrQ29uZGl0aW9uKHByb3BlcnR5LCBjb25kaXRpb24pIHtcbiAgICBjb25zdCBjb25kaXRpb25zID0gcGFyc2VDb25kaXRpb24oY29uZGl0aW9uKTtcbiAgICByZXR1cm4gY2hlY2tQYXJzZWRDb25kaXRpb25zKHByb3BlcnR5LCBjb25kaXRpb25zKTtcbn1cblxuZnVuY3Rpb24gY2hlY2tQYXJzZWRDb25kaXRpb25zKHByb3BlcnR5LCBjb25kaXRpb25zKSB7XG4gICAgaWYoIUFycmF5LmlzQXJyYXkoY29uZGl0aW9ucykpIHJldHVybiBjaGVja1Byb3AocHJvcGVydHksIGNvbmRpdGlvbnMpO1x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ICAgICAgICAgICAgIGZvcihjb25zdCBwIG9mIHByb3BEYXRhKVxuICAgICAgICAgICAgICAgICAgICBpZihjb25kaXRpb25EYXRhLmluY2x1ZGVzKHApKSByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gY29uZGl0aW9uRGF0YS5pbmNsdWRlcyhwcm9wRGF0YSk7XG4gICAgICAgIGNhc2UgJyEnOlxuICAgICAgICAgICAgaWYoQXJyYXkuaXNBcnJheShwcm9wRGF0YSkpIHtcbiAgICAgICAgICAgICAgICBmb3IoY29uc3QgcCBvZiBwcm9wRGF0YSlcbiAgICAgICAgICAgICAgICAgICAgaWYoY29uZGl0aW9uRGF0YS5pbmNsdWRlcyhwKSkgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuICFjb25kaXRpb25EYXRhLmluY2x1ZGVzKHByb3BEYXRhKTtcblxuICAgICAgICBkZWZhdWx0OiByZXR1cm4gZmFsc2U7XG4gICAgfVxufVxuXG5leHBvcnQgeyBjaGVja0NvbmRpdGlvbiB9OyIsImltcG9ydCB7IGNsb25lIH0gZnJvbSAnLi9mdW5jdGlvbnMvdXRpbC5qcyc7XG5pbXBvcnQgeyBjaGVja0NvbmRpdGlvbiB9IGZyb20gJy4vZnVuY3Rpb25zL2NvbmRpdGlvbi5qcyc7XG5cbmNsYXNzIEV2ZW50IHtcbiAgICBjb25zdHJ1Y3RvcigpIHt9XG5cbiAgICAjZXZlbnRzO1xuXG4gICAgaW5pdGlhbCh7ZXZlbnRzfSkge1xuICAgICAgICB0aGlzLiNldmVudHMgPSBldmVudHM7XG4gICAgICAgIGZvcihjb25zdCBpZCBpbiBldmVudHMpIHtcbiAgICAgICAgICAgIGNvbnN0IGV2ZW50ID0gZXZlbnRzW2lkXTtcbiAgICAgICAg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GluIHRoaXMuI3RhbGVudHMpIHtcbiAgICAgICAgICAgIGNvbnN0IHsgaWQsIGdyYWRlLCBuYW1lLCBkZXNjcmlwdGlvbiB9ID0gdGhpcy4jdGFsZW50c1t0YWxlbnRJZF07XG4gICAgICAgICAgICBpZihpZCA9PSBpbmNsdWRlKSB7XG4gICAgICAgICAgICAgICAgaW5jbHVkZSA9IHsgZ3JhZGUsIG5hbWUsIGRlc2NyaXB0aW9uLCBpZCB9O1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYoIXRhbGVudExpc3RbZ3JhZGVdKSB0YWxlbnRMaXN0W2dyYWRlXSA9IFt7IGdyYWRlLCBuYW1lLCBkZXNjcmlwdGlvbiwgaWQgfV07XG4gICAgICAgICAgICBlbHNlIHRhbGVudExpc3RbZ3JhZGVdLnB1c2goeyBncmFkZSwgbmFtZSwgZGVzY3JpcHRpb24sIGlkIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIG5ldyBBcnJheSgxMClcbiAgICAgICAgICAgIC5maWxsKDEpLm1hcCgodiwgaSk9PntcbiAgICAgICAgICAgICAgICBpZighaSAmJiBpbmNsdWRlKSByZXR1cm4gaW5jbHVkZTtcbiAgICAgICAgICAgICAgICBjb25zdCBncmFkZVJhbmRvbSA9IE1hdGgucmFuZG9tKCk7XG4gICAgICAgICAgICAgICAgbGV0IGdyYWRlO1xuICAgICAgICAgICAgICAgIGlmKGdyYWRlUmFuZG9tPj0wLjExMSkgZ3JhZGUgPSAwO1xuICAgICAgICAgICAgICAgIGVsc2UgaWYoZ3JhZGVSYW5kb20+PTAuMDExKSBncmFkZSA9IDE7XG4gICAgICAgICAgICAgICAgZWxzZSBpZihncmFkZVJhbmRvbT49MC4wMDEpIGdyYWRlID0gMjtcbiAgICAgICAgICAgICAgICBlbHNlIGdyYWRlID0gMztcblxuICAgICAgICAgICAgICAgIHdoaWxlKHRhbGVudExpc3RbZ3JhZGVdLmxlbmd0aCA9PSAwKSBncmFkZS0tO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gdGFsZW50TGlzdFtncmFkZV0ubGVuZ3RoO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgcmFuZG9tID0gTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKmxlbmd0aCkgJSBsZW5ndGg7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRhbGVudExpc3RbZ3JhZGVdLnNwbGljZShyYW5kb20sMSlbMF07XG4gICAgICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBhbGxvY2F0aW9uQWRkaXRpb24odGFsZW50cykge1xuICAgICAgICBpZihBcnJheS5pc0FycmF5KHRhbGVudHMpKSB7XG4gICAgICAgICAgICBsZXQgYWRkaXRpb24gPSAwO1xuICAgICAgICAgICAgZm9yKGNvbnN0IHRhbGVudCBvZiB0YWxlbnRzKVxuICAgICAgICAgICAgICAgIGFkZGl0aW9uICs9IHRoaXMuYWxsb2NhdGlvbkFkZGl0aW9uKHRhbGVudCk7XG4gICAgICAgICAgICByZXR1cm4gYWRkaXRpb247XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIE51bWJlcih0aGlzLmdldCh0YWxlbnRzKS5zdGF0dXMpIHx8IDA7XG4gICAgfVxuXG4gICAgZG8odGFsZW50SWQsIHByb3BlcnR5KSB7XG4gICAgICAgIGNvbnN0IHsgZWZmZWN0LCBjb25kaXRpb24sIGdyYWRlLCBuYW1lLCBkZXNjcmlwdGlvbiB9ID0gdGhpcy5nZXQodGFsZW50SWQpO1xuICAgICAgICBpZihjb25kaXRpb24gJiYgIWNoZWNrQ29uZGl0aW9uKHByb3BlcnR5LCBjb25kaXRpb24pKVxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgIHJldHVybiB7IGVmZmVjdCwgZ3JhZGUsIG5hbWUsIGRlc2NyaXB0aW9uIH07XG4gICAgfVxufVxuXG5leHBvcnQgZGVmYXVs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ybWFsO1wiPui/meWeg+WcvuS6uueUn+S4gOenkuS5n+S4jeaDs+WRhuS6hjwvZGl2PlxuICAgICAgICAgICAgPC9kaXY+XG4gICAgICAgICAgICA8YnV0dG9uIGlkPVwicmVzdGFydFwiIGNsYXNzPVwibWFpbmJ0blwiPjxzcGFuIGNsYXNzPVwiaWNvbmZvbnRcIj4mI3hlNmE3Ozwvc3Bhbj7nq4vljbPph43lvIA8L2J1dHRvbj5cbiAgICAgICAgPC9kaXY+XG4gICAgICAgIGApO1xuXG4gICAgICAgIC8vIEluaXQgdGhlbWVcbiAgICAgICAgdGhpcy5zZXRUaGVtZShsb2NhbFN0b3JhZ2UuZ2V0SXRlbSgndGhlbWUnKSlcblxuICAgICAgICBpbmRleFBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjcmVzdGFydCcpXG4gICAgICAgICAgICAuY2xpY2soKCk9PnRoaXMuc3dpdGNoKCd0YWxlbnQnKSk7XG5cbiAgICAgICAgaW5kZXhQYWdlXG4gICAgICAgICAgICAuZmluZCgnI3JhbmsnKVxuICAgICAgICAgICAgLmNsaWNrKCgpPT50aGlzLmhpbnQoJ+WIq+WNt+S6hu+8geayoeacieaOkuihjOamnCcpKTtcblxuICAgICAgICBpbmRleFBhZ2VcbiAgICAgICAgICAgIC5maW5kKFwiI3RoZW1lVG9nZ2xlQnRuXCIpXG4gICAgICAgICAgICAuY2xpY2soKCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmKGxvY2FsU3RvcmFnZS5nZXRJdGVtKCd0aGVtZScpID09ICdsaWdodCcpIHtcbiAgICAgICAgICAgICAgICAgICAgbG9jYWxTdG9yYWdlLnNldEl0ZW0oJ3RoZW1lJywgJ2RhcmsnKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBsb2NhbFN0b3JhZ2Uuc2V0SXRlbSgndGhlbWUnLCAnbGlnaHQnKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLnNldFRoZW1lKGxvY2FsU3RvcmFnZS5nZXRJdGVtKCd0aGVtZScpKVxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgLy8gVGFsZW50XG4gICAgICAgIGNvbnN0IHRhbGVudFBhZ2UgPSAkKGBcbiAgICAgICAgPGRpdiBpZD1cIm1haW5cIj5cbiAgICAgICAgICAgIDxkaXYgY2xhc3M9XCJoZWFkXCIgc3R5bGU9XCJmb250LXNpemU6IDEuNnJlbVwiPuWkqei1i+aKveWNoTwvZGl2PlxuICAgICAgICAgICAgPGJ1dHRvbiBpZD1cInJhbmRvbVwiIGNsYXNzPVwibWFpbmJ0blwiIHN0eWxlPVwidG9wOiA1MCU7XCI+MTDov57mir3vvIE8L2J1dHRvbj5cbiAgICAgICAgICAgIDx1bCBpZD1cInRhbGVudHNcIiBjbGFzcz1cInNlbGVjdGxpc3RcIj48L3VsPlxuICAgICAgICAgICAgPGJ1dHRvbiBpZD1cIm5leHRcIiBjbGFzcz1cIm1haW5idG5cIiBzdHlsZT1cInRvcDphdXRvOyBib3R0b206MC4xZW1cIj7or7fpgInmi6kz5LiqPC9idXR0b24+XG4gICAgICAgIDwvZGl2PlxuICAgICAgICBgKTtcblxuICAgICAgICBjb25zdCBjcmVhdGVUYWxlbnQgPSAoeyBncmFkZSwgbmFtZSwgZGVzY3JpcHRpb24gfSkgPT4ge1xuICAgICAgICAgICAgcmV0dXJuICQoYDxsaSBjbGFzcz1cImdyYWRlJHtncmFkZX1iXCI+JHtuYW1lfe+8iCR7ZGVzY3JpcHRpb25977yJPC9saT5gKVxuICAgICAgICB9O1xuXG4gICAgICAgIHRhbGVudFBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjcmFuZG9tJylcbiAgICAgICAgICAgIC5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgIHRhbGVudFBhZ2UuZmluZCgnI3JhbmRvbScpLmhpZGUoKTtcbiAgICAgICAgICAgICAgICBjb25zdCB1bCA9IHRhbGVudFBhZ2UuZmluZCgnI3RhbGVudHMnKTtcbiAgICAgICAgICAgICAgICB0aGlzLiNsaWZlLnRhbGVudFJhbmRvbSgpXG4gICAgICAgICAgICAgICAgICAgIC5mb3JFYWNoKHRhbGVudD0+e1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGkgPSBjcmVhdGVUYWxlbnQodGFsZW50KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVsLmFwcGVuZChsaSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaS5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGxpLmhhc0NsYXNzKCdzZWxlY3RlZCcpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpLnJlbW92ZUNsYXNzKCdzZWxlY3RlZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3RhbGVudFNlbGVjdGVkLmRlbGV0ZSh0YWxlbnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZih0aGlzLiN0YWxlbnRTZWxlY3RlZC5zaXplPDMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhbGVudFBhZ2UuZmluZCgnI25leHQnKS50ZXh0KCfor7fpgInmi6kz5LiqJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHRoaXMuI3RhbGVudFNlbGVjdGVkLnNpemU9PTMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGludCgn5Y+q6IO96YCJM+S4quWkqei1iycpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhjbHVzaXZlID0gdGhpcy4jbGlmZS5leGNsdXNpdmUoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnJheS5mcm9tKHRoaXMuI3RhbGVudFNlbGVjdGVkKS5tYXAoKHtpZH0pPT5pZCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWxlbnQuaWRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoZXhjbHVzaXZlICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihjb25zdCB7IG5hbWUsIGlkIH0gb2YgdGhpcy4jdGFsZW50U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihpZCA9PSBleGNsdXNpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaW50KGDkuI7lt7LpgInmi6nnmoTlpKnotYvjgJAke25hbWV944CR5Yay56qBYCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGkuYWRkQ2xhc3MoJ3NlbGVjdGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3RhbGVudFNlbGVjdGVkLmFkZCh0YWxlbnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZih0aGlzLiN0YWxlbnRTZWxlY3RlZC5zaXplPT0zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWxlbnRQYWdlLmZpbmQoJyNuZXh0JykudGV4dCgn5byA5aeL5paw5Lq655SfJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgIHRhbGVudFBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjbmV4dCcpXG4gICAgICAgICAgICAuY2xpY2soKCk9PntcbiAgICAgICAgICAgICAgICBpZih0aGlzLiN0YWxlbnRTZWxlY3RlZC5zaXplIT0zKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuaGludCgn6K+36YCJ5oupM+S4quWkqei1iycpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuI3RvdGFsTWF4ID0gMjAgKyB0aGlzLiNsaWZlLmdldFRhbGVudEFsbG9jYXRpb25BZGRpdGlvbihBcnJheS5mcm9tKHRoaXMuI3RhbGVudFNlbGVjdGVkKS5tYXAoKHtpZH0pPT5pZCkpO1xuICAgICAgICAgICAgICAgIHRoaXMuc3dpdGNoKCdwcm9wZXJ0eScpO1xuICAgICAgICAgICAgfSlcblxuICAgICAgICAvLyBQcm9wZXJ0eVxuICAgICAgICAvLyBoaW50IG9mIGV4dGVuc2lvbiB0b2Jlcm1vcnkuZXM2LXN0cmluZy1odG1sXG4gICAgICAgIGNvbnN0IHByb3BlcnR5UGFnZSA9ICQoLypodG1sKi9gXG4gICAgICAgIDxkaXYgaWQ9XCJtYWluXCI+XG4gICAgICAgICAgICA8ZGl2IGNsYXNzPVwiaGVhZFwiIHN0eWxlPVwiZm9udC1zaXplOiAxLjZyZW1cIj5cbiAgICAgICAgICA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FxuICAgICAgICAgICAgICAgIGA8bGk+5bey6YCJ5aSp6LWLPC9saT5gICtcbiAgICAgICAgICAgICAgICBBcnJheS5mcm9tKHRoaXMuI3RhbGVudFNlbGVjdGVkKVxuICAgICAgICAgICAgICAgIC5tYXAoKHtuYW1lLGRlc2NyaXB0aW9ufSk9PmA8bGkgY2xhc3M9XCJncmFkZTBiXCI+JHtuYW1lfSgke2Rlc2NyaXB0aW9ufSk8L2xpPmApXG4gICAgICAgICAgICAgICAgLmpvaW4oJycpXG4gICAgICAgICAgICApXG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgZ3JvdXBzID0ge307XG4gICAgICAgIGNvbnN0IHRvdGFsID0gKCk9PntcbiAgICAgICAgICAgIGxldCB0ID0gMDtcbiAgICAgICAgICAgIGZvcihjb25zdCB0eXBlIGluIGdyb3VwcylcbiAgICAgICAgICAgICAgICB0ICs9IGdyb3Vwc1t0eXBlXS5nZXQoKTtcbiAgICAgICAgICAgIHJldHVybiB0O1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGZyZXNoVG90YWwgPSAoKT0+e1xuICAgICAgICAgICAgcHJvcGVydHlQYWdlLmZpbmQoJyN0b3RhbCcpLnRleHQoYOWPr+eUqOWxnuaAp+eCue+8miR7dGhpcy4jdG90YWxNYXggLSB0b3RhbCgpfWApO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGdldEJ0bkdyb3VwcyA9IChuYW1lLCBtaW4sIG1heCk9PntcbiAgICAgICAgICAgIGNvbnN0IGdyb3VwID0gJChgPGxpPiR7bmFtZX0mbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDs8L2xpPmApO1xuICAgICAgICAgICAgY29uc3QgYnRuU3ViID0gJChgPHNwYW4gY2xhc3M9XCJpY29uZm9udCBwcm9wYnRuXCI+JiN4ZTZhNTs8L3NwYW4+YCk7XG4gICAgICAgICAgICBjb25zdCBpbnB1dEJveCA9ICQoYDxpbnB1dCB2YWx1ZT1cIjBcIj5gKTtcbiAgICAgICAgICAgIGNvbnN0IGJ0bkFkZCA9ICQoYDxzcGFuIGNsYXNzPVwiaWNvbmZvbnQgcHJvcGJ0blwiPiYjeGU2YTY7PC9zcGFuPmApO1xuICAgICAgICAgICAgZ3JvdXAuYXBwZW5kKGJ0blN1Yik7XG4gICAgICAgICAgICBncm91cC5hcHBlbmQoaW5wdXRCb3gpO1xuICAgICAgICAgICAgZ3JvdXAuYXBwZW5kKGJ0bkFkZCk7XG5cbiAgICAgICAgICAgIGNvbnN0IGxpbWl0ID0gdj0+e1xuICAgICAgICAgICAgICAgIHYgPSBOdW1iZXIodil8fDA7XG4gICAgICAgICAgICAgICAgdiA9IE1hdGgucm91bmQodik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHYgPCBtaW4gPyBtaW4gOiAoXG4gICAgICAgICAgICAgICAgICAgIHYgPiBtYXggPyBtYXggOiB2XG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3QgZ2V0ID0gKCk9Pk51bWJlcihpbnB1dEJveC52YWwoKSk7XG4gICAgICAgICAgICBjb25zdCBzZXQgPSB2PT57XG4gICAgICAgICAgICAgICAgaW5wdXRCb3gudmFsKGxpbWl0KHYpKTtcbiAgICAgICAgICAgICAgICBmcmVzaFRvdGFsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBidG5BZGQuY2xpY2soKCk9PntcbiAgICAgICAgICAgICAgICBpZih0b3RhbCgpID49IHRoaXMuI3RvdGFsTWF4KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuaGludCgn5rKh5pyJ5Y+v5YiG6YWN55qE54K55pWw5LqGJyk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2V0KGdldCgpKzEpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBidG5TdWIuY2xpY2soKCk9PnNldChnZXQoKS0xKSk7XG4gICAgICAgICAgICBpbnB1dEJveC5vbignaW5wdXQnLCAoKT0+e1xuICAgICAgICAgICAgICAgIGNvbnN0IHQgPSB0b3RhbCgpO1xuICAgICAgICAgICAgICAgIGxldCB2YWwgPSBnZXQoKTtcbiAgICAgICAgICAgICAgICBpZih0ID4gdGhpcy4jdG90YWxNYXgpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsIC09IHQgLSB0aGlzLiN0b3RhbE1heDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFsID0gbGltaXQodmFsKTtcbiAgICAgICAgICAgICAgICBpZih2YWwgIT0gaW5wdXRCb3gudmFsKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgc2V0KHZhbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGZyZXNoVG90YWwoKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuIHtncm91cCwgZ2V0LCBzZXR9O1xuICAgICAgICB9XG5cbiAgICAgICAgZ3JvdXBzLkNIUiA9IGdldEJ0bkdyb3VwcyhcIuminOWAvFwiLCAwLCAxMCk7IC8vIOminOWAvCBjaGFybSBDSFJcbiAgICAgICAgZ3JvdXBzLklOVCA9IGdldEJ0bkdyb3VwcyhcIuaZuuWKm1wiLCAwLCAxMCk7IC8vIOaZuuWKmyBpbnRlbGxpZ2VuY2UgSU5UXG4gICAgICAgIGdyb3Vwcy5TVFIgPSBnZXRCdG5Hcm91cHMoXCLkvZPotKhcIiwgMCwgMTApOyAvLyDkvZPotKggc3RyZW5ndGggU1RSXG4gICAgICAgIGdyb3Vwcy5NTlkgPSBnZXRCdG5Hcm91cHMoXCLlrrblooNcIiwgMCwgMTApOyAvLyDlrrblooMgbW9uZXkgTU5ZXG5cbiAgICAgICAgY29uc3QgdWwgPSBwcm9wZXJ0eVBhZ2UuZmluZCgnI3Byb3BlcnR5QWxsb2NhdGlvbicpO1xuXG4gICAgICAgIGZvcihjb25zdCB0eXBlIGluIGdyb3Vwcykge1xuICAgICAgICAgICAgdWwuYXBwZW5kKGdyb3Vwc1t0eXBlXS5ncm91cCk7XG4gICAgICAgIH1cblxuICAgICAgICBwcm9wZXJ0eVBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjcmFuZG9tJylcbiAgICAgICAgICAgIC5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgIGxldCB0ID0gdGhpcy4jdG90YWxNYXg7XG4gICAgICAgICAgICAgICAgY29uc3QgYXJyID0gWzEwLCAxMCwgMTAsIDEwXTtcbiAgICAgICAgICAgICAgICB3aGlsZSh0PjApIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViID0gTWF0aC5yb3VuZChNYXRoLnJhbmRvbSgpICogKE1hdGgubWluKHQsIDEwKSAtIDEpKSArIDE7XG4gICAgICAgICAgICAgICAgICAgIHdoaWxlKHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbGVjdCA9IE1hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIDQpICUgNDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGFycltzZWxlY3RdIC0gc3ViIDwwKSBjb250aW51ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFycltzZWxlY3RdIC09IHN1YjtcbiAgICAgICAgICAgICAgICAgICAgICAgIHQgLT0gc3ViO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZ3JvdXBzLkNIUi5zZXQoMTAgLSBhcnJbMF0pO1xuICAgICAgICAgICAgICAgIGdyb3Vwcy5JTlQuc2V0KDEwIC0gYXJyWzFdKTtcbiAgICAgICAgICAgICAgICBncm91cHMuU1RSLnNldCgxMCAtIGFyclsyXSk7XG4gICAgICAgICAgICAgICAgZ3JvdXBzLk1OWS5zZXQoMTAgLSBhcnJbM10pO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydHlQYWdlXG4gICAgICAgICAgICAuZmluZCgnI3N0YXJ0JylcbiAgICAgICAgICAgIC5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgIGlmKHRvdGFsKCkgPCB0aGlzLiN0b3RhbE1heCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmhpbnQoYOS9oOi/mOaciSR7dGhpcy4jdG90YWxNYXgtdG90YWwoKX3lsZ7mgKfngrnmsqHmnInliIbphY3lroxgKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodG90YWwoKSA+IHRoaXMuI3RvdGFsTWF4KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuaGludChg5L2g5aSa5L2/55So5LqGJHt0b3RhbCgpIC0gdGhpcy4jdG90YWxNYXh95bGe5oCn54K5YCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy4jbGlmZS5yZXN0YXJ0KHtcbiAgICAgICAgICAgICAgICAgICAgQ0hSOiBncm91cHMuQ0hSLmdldCgpLFxuICAgICAgICAgICAgICAgICAgICBJTlQ6IGdyb3Vwcy5JTlQuZ2V0KCksXG4gICAgICAgICAgICAgICAgICAgIFNUUjogZ3JvdXBzLlNUUi5nZXQoKSxcbiAgICAgICAgICAgICAgICAgICAgTU5ZOiBncm91cHMuTU5ZLmdldCgpLFxuICAgICAgICAgICAgICAgICAgICBTUFI6IDUsXG4gICAgICAgICAgICAgICAgICAgIFRMVDogQXJyYXkuZnJvbSh0aGlzLiN0YWxlbnRTZWxlY3RlZCkubWFwKCh7aWR9KT0+aWQpLFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHRoaXMuc3dpdGNoKCd0cmFqZWN0b3J5Jyk7XG4gICAgICAgICAgICAgICAgdGhpcy4jcGFnZXMudHJhamVjdG9yeS5ib3JuKCk7XG4gICAgICAgICAgICAgICAgJChkb2N1bWVudCkua2V5ZG93bihmdW5jdGlvbihldmVudCl7XG4gICAgICAgICAgICAgICAgICAgIGlmKGV2ZW50LndoaWNoID09IDMyIHx8IGV2ZW50LndoaWNoID09IDEzKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNsaWZlVHJhamVjdG9yeScpLmNsaWNrKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgLy8gVHJhamVjdG9yeVxuICAgICAgICBjb25zdCB0cmFqZWN0b3J5UGFnZSA9ICQoYFxuICAgICAgICA8ZGl2IGlkPVwibWFpblwiPlxuICAgICAgICAgICAgPHVsIGlkPVwibGlmZVByb3BlcnR5XCIgY2xhc3M9XCJsaWZlUHJvcGVydHlcIj48L3VsPlxuICAgICAgICAgICAgPHVsIGlkPVwibGlmZVRyYWplY3RvcnlcIiBjbGFzcz1cImxpZmVUcmFqZWN0b3J5XCI+PC91bD5cbiAgICAgICAgICAgIDxidXR0b24gaWQ9XCJzdW1tYXJ5XCIgY2xhc3M9XCJtYWluYnRuXCIgc3R5bGU9XCJ0b3A6YXV0bzsgYm90dG9tOjAuMXJlbVwiPuS6uueUn+aAu+e7kzwvYnV0dG9uPlxuICAgICAgICA8L2Rpdj5cbiAgICAgICAgYCk7XG5cbiAgICAgICAgdHJhamVjdG9yeVBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjbGlmZVRyYWplY3RvcnknKVxuICAgICAgICAgICAgLmNsaWNrKCgpPT57XG4gICAgICAgICAgICAgICAgaWYodGhpcy4jaXNFbmQpIHJldHVybjtcbiAgICAgICAgICAgICAgICBjb25zdCB0cmFqZWN0b3J5ID0gdGhpcy4jbGlmZS5uZXh0KCk7XG4gICAgICAgICAgICAgICAgY29uc3QgeyBhZ2UsIGNvbnRlbnQsIGlzRW5kIH0gPSB0cmFqZWN0b3J5O1xuXG4gICAgICAgICAgICAgICAgY29uc3QgbGkgPSAkKGA8bGk+PHNwYW4+JHthZ2V95bKB77yaPC9zcGFuPiR7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQubWFwKFxuICAgICAgICAgICAgICAgICAgICAgICAgKHt0eXBlLCBkZXNjcmlwdGlvbiwgZ3JhZGUsIG5hbWUsIHBvc3RFdmVudH0pID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2godHlwZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUTFQnOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGDlpKnotYvjgJAke25hbWV944CR5Y+R5Yqo77yaJHtkZXNjcmlwdGlvbn1gO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdFVlQnOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlc2NyaXB0aW9uICsgKHBvc3RFdmVudD9gPGJyPiR7cG9zdEV2ZW50fWA6JycpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgKS5qb2luKCc8YnI+JylcbiAgICAgICAgICAgICAgICB9PC9saT5gKTtcbiAgICAgICAgICAgICAgICBsaS5hcHBlbmRUbygnI2xpZmVUcmFqZWN0b3J5Jyk7XG4gICAgICAgICAgICAgICAgJChcIiNsaWZlVHJhamVjdG9yeVwiKS5zY3JvbGxUb3AoJChcIiNsaWZlVHJhamVjdG9yeVwiKVswXS5zY3JvbGxIZWlnaHQpO1xuICAgICAgICAgICAgICAgIGlmKGlzRW5kKSB7XG4gICAgICAgICAgICAgICAgICAgICQoZG9jdW1lbnQpLnVuYmluZChcImtleWRvd25cIik7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzRW5kID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgdHJhamVjdG9yeVBhZ2UuZmluZCgnI3N1bW1hcnknKS5zaG93KCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8g5aaC5pyq5q275Lqh77yM5pu05paw5pWw5YC8XG4gICAgICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSBwcm9wZXJ0aWVzIGlmIG5vdCBkaWUgeWV0XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnR5ID0gdGhpcy4jbGlmZS5nZXRMYXN0UmVjb3JkKCk7XG4gICAgICAgICAgICAgICAgICAgICQoXCIjbGlmZVByb3BlcnR5XCIpLmh0bWwoYFxuICAgICAgICAgICAgICAgICAgICA8bGk+6aKc5YC877yaJHtwcm9wZXJ0eS5DSFJ9IDwvbGk+XG4gICAgICAgICAgICAgICAgICAgIDxsaT7mmbrlipvvvJoke3Byb3BlcnR5LklOVH0gPC9saT5cbiAgICAgICAgICAgICAgICAgICAgPGxpPuS9k+i0qO+8miR7cHJvcGVydHkuU1RSfSA8L2xpPlxuICAgICAgICAgICAgICAgICAgICA8bGk+5a625aKD77yaJHtwcm9wZXJ0eS5NTll9IDwvbGk+XG4gICAgICAgICAgICAgICAgICAgIDxsaT7lv6vkuZDvvJoke3Byb3BlcnR5LlNQUn0gPC9saT5gKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICB0cmFqZWN0b3J5UGFnZVxuICAgICAgICAgICAgLmZpbmQoJyNzdW1tYXJ5JylcbiAgICAgICAgICAgIC5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgIHRoaXMuc3dpdGNoKCdzdW1tYXJ5Jyk7XG4gICAgICAgICAgICB9KVxuXG4gICAgICAgIC8vIFN1bW1hcnlcbiAgICAgICAgY29uc3Qgc3VtbWFyeVBhZ2UgPSAkKGBcbiAgICAgICAgPGRpdiBpZD1cIm1haW5cIj5cbiAgICAgICAgICAgIDxkaXYg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TwvbGk+XG4gICAgICAgICAgICA8L3VsPlxuICAgICAgICAgICAgPGJ1dHRvbiBpZD1cImFnYWluXCIgY2xhc3M9XCJtYWluYnRuXCIgc3R5bGU9XCJ0b3A6YXV0bzsgYm90dG9tOjAuMWVtXCI+PHNwYW4gY2xhc3M9XCJpY29uZm9udFwiPiYjeGU2YTc7PC9zcGFuPuWGjeasoemHjeW8gDwvYnV0dG9uPlxuICAgICAgICA8L2Rpdj5cbiAgICAgICAgYCk7XG5cbiAgICAgICAgc3VtbWFyeVBhZ2VcbiAgICAgICAgICAgIC5maW5kKCcjYWdhaW4nKVxuICAgICAgICAgICAgLmNsaWNrKCgpPT57XG4gICAgICAgICAgICAgICAgdGhpcy50aW1lcyArKztcbiAgICAgICAgICAgICAgICB0aGlzLiNsaWZlLnRhbGVudEV4dGVuZCh0aGlzLiNzZWxlY3RlZEV4dGVuZFRhbGVudCk7XG4gICAgICAgICAgICAgICAgdGhpcy4jc2VsZWN0ZWRFeHRlbmRUYWxlbnQgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuI3RhbGVudFNlbGVjdGVkLmNsZWFyKCk7XG4gICAgICAgICAgICAgICAgdGhpcy4jdG90YWxNYXggPSAyMDtcbiAgICAgICAgICAgICAgICB0aGlzLiNpc0VuZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHRoaXMuc3dpdGNoKCdpbmRleCcpO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy4jcGFnZXMgPSB7XG4gICAgICAgICAgICBsb2FkaW5nOiB7XG4gICAgICAgICAgICAgICAgcGFnZTogbG9hZGluZ1BhZ2UsXG4gICAgICAgICAgICAgICAgY2xlYXI6ICgpPT57fSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBpbmRleDoge1xuICAgICAgICAgICAgICAgIHBhZ2U6IGluZGV4UGFnZSxcbiAgICAgICAgICAgICAgICBidG5SYW5rOiBpbmRleFBhZ2UuZmluZCgnI3JhbmsnKSxcbiAgICAgICAgICAgICAgICBidG5SZXN0YXJ0OiBpbmRleFBhZ2UuZmluZCgnI3Jlc3RhcnQnKSxcbiAgICAgICAgICAgICAgICBoaW50OiBpbmRleFBhZ2UuZmluZCgnLmhpbnQnKSxcbiAgICAgICAgICAgICAgICBjbnQ6IGluZGV4UGFnZS5maW5kKCcjY250JyksXG4gICAgICAgICAgICAgICAgY2xlYXI6ICgpPT57XG4gICAgICAgICAgICAgICAgICAgIGluZGV4UGFnZS5maW5kKCcuaGludCcpLmhpZGUoKTtcblxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0aW1lcyA9IHRoaXMudGltZXM7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ0blJhbmsgPSBpbmRleFBhZ2UuZmluZCgnI3JhbmsnKTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgY250ID0gaW5kZXhQYWdlLmZpbmQoJyNjbnQnKTtcbiAgICAgICAgICAgICAgICAgICAgaWYodGltZXMgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBidG5SYW5rLnNob3coKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNudC5zaG93KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjbnQudGV4dChg5bey6YeN5byAJHt0aW1lc33mrKFgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGJ0blJhbmsuaGlkZSgpO1xuICAgICAgICAgICAgICAgICAgICBjbnQuaGlkZSgpO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgdGFsZW50OiB7XG4gICAgICAgICAgICAgICAgcGFnZTogdGFsZW50UGFnZSxcbiAgICAgICAgICAgICAgICBjbGVhcjogKCk9PntcbiAgICAgICAgICAgICAgICAgICAgdGFsZW50UGFnZS5maW5kKCd1bC5zZWxlY3RsaXN0JykuZW1wdHkoKTtcbiAgICAgICAgICAgICAgICAgICAgdGFsZW50UGFnZS5maW5kKCcjcmFuZG9tJykuc2hvdygpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLiN0b3RhbE1heCA9IDIwO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgcHJvcGVydHk6IHtcbiAgICAgICAgICAgICAgICBwYWdlOiBwcm9wZXJ0eVBhZ2UsXG4gICAgICAgICAgICAgICAgY2xlYXI6ICgpPT57XG4gICAgICAgICAgICAgICAgICAgIGZyZXNoVG90YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlQYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAuZmluZCgnI3RhbGVudFNlbGVjdGVkVmlldycpXG4gICAgICAgICAgICAgICAgICAgICAgICAuZW1wdHkoKTtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHRyYWplY3Rvcnk6IHtcbiAgICAgICAgICAgICAgICBwYWdlOiB0cmFqZWN0b3J5UGFnZSxcbiAgICAgICAgICAgICAgICBjbGVhcjogKCk9PntcbiAgICAgICAgICAgICAgICAgICAgdHJhamVjdG9yeVBhZ2UuZmluZCgnI2xpZmVUcmFqZWN0b3J5JykuZW1wdHkoKTtcbiAgICAgICAgICAgICAgICAgICAgdHJhamVjdG9yeVBhZ2UuZmluZCgnI3N1bW1hcnknKS5oaWRlKCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzRW5kID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBib3JuOiAoKT0+e1xuICAgICAgICAgICAgICAgICAgICB0cmFqZWN0b3J5UGFnZS5maW5kKCcjbGlmZVRyYWplY3RvcnknKS50cmlnZ2VyKFwiY2xpY2tcIik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHN1bW1hcnk6IHtcbiAgICAgICAgICAgICAgICBwYWdlOiBzdW1tYXJ5UGFnZSxcbiAgICAgICAgICAgICAgICBjbGVhcjogKCk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc3QganVkZ2UgPSBzdW1tYXJ5UGFnZS5maW5kKCcjanVkZ2UnKTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFsZW50cyA9IHN1bW1hcnlQYWdlLmZpbmQoJyN0YWxlbnRzJyk7XG4gICAgICAgICAgICAgICAgICAgIGp1ZGdlLmVtcHR5KCk7XG4gICAgICAgICAgICAgICAgICAgIHRhbGVudHMuZW1wdHkoKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy4jdGFsZW50U2VsZWN0ZWQuZm9yRWFjaCh0YWxlbnQ9PntcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpID0gY3JlYXRlVGFsZW50KHRhbGVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0YWxlbnRzLmFwcGVuZChsaSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaS5jbGljaygoKT0+e1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGxpLmhhc0NsYXNzKCdzZWxlY3RlZCcpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3NlbGVjdGVkRXh0ZW5kVGFsZW50ID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGkucmVtb3ZlQ2xhc3MoJ3NlbGVjdGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmKHRoaXMuI3NlbGVjdGVkRXh0ZW5kVGFsZW50ICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaW50KCflj6rog73nu6fmib/kuIDkuKrlpKnotYsnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3NlbGVjdGVkRXh0ZW5kVGFsZW50ID0gdGFsZW50LmlkO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaS5hZGRDbGFzcygnc2VsZWN0ZWQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjb3JkcyA9IHRoaXMuI2xpZmUuZ2V0UmVjb3JkKCk7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHMgPSAodHlwZSwgZnVuYyk9PntcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZnVuYyhyZWNvcmRzLm1hcCgoe1t0eXBlXTp2fSk9PnYpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsganVkZ2UsIGdyYWRlIH0gPSBzdW1tYXJ5KHR5cGUsIHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IGp1ZGdlLCBncmFkZSwgdmFsdWUgfTtcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS50YWJsZShyZWNvcmRzKTtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5kZWJ1ZyhyZWNvcmRzKTtcblxuICAgICAgICAgICAgICAgICAgICBqdWRnZS5hcHBlbmQoW1xuICAgICAgICAgICAgICAgICAgICAgICAgKCgpPT57XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeyBqdWRnZSwgZ3JhZGUsIHZhbHVlIH0gPSBzKCdDSFInLCBtYXgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgPGxpIGNsYXNzPVwiZ3JhZGUke2dyYWRlfVwiPjxzcGFuPuminOWAvO+8mjwvc3Bhbj4ke3ZhbHVlfSAke2p1ZGdlfTwvbGk+YFxuICAgICAgICAgICAgICAgICAgICAgICAgfSkoKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICgoKT0+e1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsganVkZ2UsIGdyYWRlLCB2YWx1ZSB9ID0gcygnSU5UJywgbWF4KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYDxsaSBjbGFzcz1cImdyYWRlJHtncmFkZX1cIj48c3Bhbj7mmbrlipvvvJo8L3NwYW4+JHt2YWx1ZX0gJHtqdWRnZX08L2xpPmBcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAoKCk9PntcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7IGp1ZGdlLCBncmFkZSwgdmFsdWUgfSA9IHMoJ1NUUicsIG1heCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGA8bGkgY2xhc3M9XCJncmFkZSR7Z3JhZGV9XCI+PHNwYW4+5L2T6LSo77yaPC9zcGFuPiR7dmFsdWV9ICR7anVkZ2V9PC9saT5gXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSgpLFxuICAgICAgICAgICAgICAgICAgICAgICAgKCgpPT57XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeyBqdWRnZSwgZ3JhZGUsIHZhbHVlIH0gPSBzKCdNTlknLCBtYXgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgPGxpIGNsYXNzPVwiZ3JhZGUke2dyYWRlfVwiPjxzcGFuPuWutuWig++8mjwvc3Bhbj4ke3ZhbHVlfSAke2p1ZGdlfTwvbGk+YFxuICAgICAgICAgICAgICAgICAgICAgICAgfSkoKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICgoKT0+e1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsganVkZ2UsIGdyYWRlLCB2YWx1ZSB9ID0gcygnU1BSJywgbWF4KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYDxsaSBjbGFzcz1cImdyYWRlJHtncmFkZX1cIj48c3Bhbj7lv6vkuZDvvJo8L3NwYW4+JHt2YWx1ZX0gJHtqdWRnZX08L2xpPmBcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAoKCk9PntcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7IGp1ZGdlLCBncmFkZSwgdmFsdWUgfSA9IHMoJ0FHRScsIG1heCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGA8bGkgY2xhc3M9XCJncmFkZSR7Z3JhZGV9XCI+PHNwYW4+5Lqr5bm077yaPC9zcGFuPiR7dmFsdWV9ICR7anVkZ2V9PC9saT5gXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSgpLFxuICAgICAgICAgICAgICAgICAgICAgICAgKCgpPT57XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbSA9IHR5cGU9Pm1heChyZWNvcmRzLm1hcCgoe1t0eXBlXTogdmFsdWV9KT0+dmFsdWUpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGguZmxvb3Ioc3VtKG0oJ0NIUicpLCBtKCdJTlQnKSwgbSgnU1RSJyksIG0oJ01OWScpLCBtKCdTUFInKSkqMiArIG0oJ0FHRScpLzIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsganVkZ2UsIGdyYWRlIH0gPSBzdW1tYXJ5KCdTVU0nLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGA8bGkgY2xhc3M9XCJncmFkZSR7Z3JhZGV9XCI+PHNwYW4+5oC76K+E77yaPC9zcGFuPiR7dmFsdWV9ICR7anVkZ2V9PC9saT5gXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSgpLFxuICAgICAgICAgICAgICAgICAgICBdLmpvaW4oJycpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzd2l0Y2gocGFnZSkge1xuICAgICAgICBjb25zdCBwID0gdGhpcy4jcGFnZXNbcGFnZV07XG4gICAgICAgIGlmKCFwKSByZXR1cm47XG4gICAgICAgICQoJyNtYWluJykuZGV0YWNoKCk7XG4gICAgICAgIHAuY2xlYXIoKTtcbiAgICAgICAgcC5wYWdlLmFwcGVuZFRvKCdib2R5Jyk7XG4gICAgICAgIGlmKHR5cGVvZiBwLnBhZ2UubW91bnRlZCA9PT0gJ2Z1bmN0aW9uJyl7XG4gICAgICAgICAgICBwLnBhZ2UubW91bnRlZCgpXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBoaW50KG1lc3NhZ2UsIHR5cGU9J2luZm8nKSB7XG4gICAgICAgIGlmKHRoaXMuI2hpbnRUaW1lb3V0KSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy4jaGludFRpbWVvdXQpO1xuICAgICAgICAgICAgdGhpcy4jaGludFRpbWVvdXQgPSBudWxsO1xuICAgICAgICB9XG4gICAgICAgIGhpZGVCYW5uZXJzKCk7XG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSgoKSA9PiB7XG4gICAgICAgICAgICBjb25zdCBiYW5uZXIgPSAkKGAuYmFubmVyLiR7dHlwZX1gKTtcbiAgICAgICAgICAgIGJhbm5lci5hZGRDbGFzcygndmlzaWJsZScpO1xuICAgICAgICAgICAgYmFubmVyLmZpbmQoJy5iYW5uZXItbWVzc2FnZScpLnRleHQobWVzc2FnZSk7XG4gICAgICAgICAgICBpZih0eXBlICE9ICdlcnJvcicpIHtcbiAgICAgICAgICAgICAgICB0aGlzLiNoaW50VGltZW91dCA9IHNldFRpbWVvdXQoaGlkZUJh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dmUoXCJ2aXNpYmxlXCIpKTtcbn07XG5cbmNvbnN0IGFwcCA9IG5ldyBBcHAoKTtcbmFwcC5pbml0aWFsKCk7Il0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///154\n')}},__webpack_module_cache__={};function __webpack_require__(e){var n=__webpack_module_cache__[e];if(void 0!==n)return n.exports;var t=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](t,t.exports,__webpack_require__),t.exports}__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var __webpack_exports__=__webpack_require__(154)})(); \ No newline at end of file diff --git a/games/lifeRestart/dark.css b/games/lifeRestart/dark.css new file mode 100644 index 0000000..1c4917b --- /dev/null +++ b/games/lifeRestart/dark.css @@ -0,0 +1,572 @@ +@media (min-width:640px){html{font-size:24px;}} +@media (min-width:631px) and (max-width:639px){html{font-size:23.66px;}} +@media (min-width:622px) and (max-width:630px){html{font-size:23.33px;}} +@media (min-width:613px) and (max-width:621px){html{font-size:23px;}} +@media (min-width:604px) and (max-width:612px){html{font-size:22.66px;}} +@media (min-width:595px) and (max-width:603px){html{font-size:22.33px;}} +@media (min-width:586px) and (max-width:594px){html{font-size:22px;}} +@media (min-width:577px) and (max-width:585px){html{font-size:21.66px;}} +@media (min-width:568px) and (max-width:576px){html{font-size:21.33px;}} +@media (min-width:559px) and (max-width:567px){html{font-size:21px;}} +@media (min-width:550px) and (max-width:558px){html{font-size:20.66px;}} +@media (min-width:541px) and (max-width:549px){html{font-size:20.33px;}} +@media (min-width:533px) and (max-width:540px){html{font-size:20px;}} +@media (min-width:524px) and (max-width:532px){html{font-size:19.66px;}} +@media (min-width:515px) and (max-width:523px){html{font-size:19.33px;}} +@media (min-width:506px) and (max-width:514px){html{font-size:19px;}} +@media (min-width:497px) and (max-width:505px){html{font-size:18.66px;}} +@media (min-width:488px) and (max-width:496px){html{font-size:18.33px;}} +@media (min-width:480px) and (max-width:487px){html{font-size:18px;}} +@media (min-width:471px) and (max-width:479px){html{font-size:17.66px;}} +@media (min-width:462px) and (max-width:470px){html{font-size:17.33px;}} +@media (min-width:453px) and (max-width:461px){html{font-size:17px;}} +@media (min-width:444px) and (max-width:452px){html{font-size:17.12px;}} +@media (min-width:435px) and (max-width:443px){html{font-size:16.33px;}} +@media (min-width:426px) and (max-width:434px){html{font-size:16px;}} +@media (min-width:417px) and (max-width:425px){html{font-size:15.66px;}} +@media (min-width:408px) and (max-width:416px){html{font-size:15.33px;}} +@media (min-width:400px) and (max-width:407px){html{font-size:15px;}} +@media (min-width:391px) and (max-width:399px){html{font-size:14.66px;}} +@media (min-width:382px) and (max-width:390px){html{font-size:14.33px;}} +@media (min-width:374px) and (max-width:381px){html{font-size:14px;}} +@media (min-width:365px) and (max-width:373px){html{font-size:13.66px;}} +@media (min-width:356px) and (max-width:364px){html{font-size:13.33px;}} +@media (min-width:347px) and (max-width:355px){html{font-size:13px;}} +@media (min-width:338px) and (max-width:346px){html{font-size:12.66px;}} +@media (min-width:329px) and (max-width:337px){html{font-size:12.44px;}} +@media (max-width:328px){html{font-size:12px;}} + +@font-face { + font-family: 'iconfont'; + src: url('iconfont.woff2?t=1628944689555') format('woff2'), + url('iconfont.woff?t=1628944689555') format('woff'), + url('iconfont.ttf?t=1628944689555') format('truetype'); +} + +html { + background-color: #222831; + font-family: PingFangSC, 'Noto Sans CJK SC', 'MS Yahei'; +} + +body { + user-select: none; +} + +#main { + align-content: center; + width: 100%; + height: 100%; + position: relative; +} + +#title { + position: fixed; + font-size: 3rem; + font-weight: 700; + top: 35%; + left: 50%; + white-space: nowrap; + transform: translate(-50%,-50%); + text-align: center; + color: #EEEEEE; +} + +.mainbtn { + position: fixed; + top: 65%; + left: 50%; + padding: 0.5rem 1.5rem; + border: 1px #EEEEEE solid; + border-radius: 0.2rem; + background-color:#393E46; + font-size: 1.6rem; + white-space: nowrap; + transform: translate(-50%,-50%); + cursor: pointer; + z-index:2; + color: #EEEEEE; +} + +.mainbtn:hover { + background: #ff7878; + color: #fff; + transition: all .4s ease 0s; +} + +.iconfont { + font-family: "iconfont" !important; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#rank { + position: fixed; + top: 1rem; + right: 1rem; + padding: 0.1rem 1rem; + border: none; + border-radius: 0.2rem; + background-color:lightsteelblue; + font-size: 1.4rem; + color: #EEEEEE; + cursor: pointer; + z-index:2; +} + +#themeToggleBtn { + position: fixed; + right: 1rem; + bottom: 1rem; + padding: 0.1rem 1rem; + border: none; + border-radius: 0.2rem; + background-color:#EEEEEE; + font-size: 1.4rem; + color: #222831; + cursor: pointer; + z-index:2; +} + +.head { + position: fixed; + font-size: 1.4rem; + top: 1.1rem; + left: 50%; + white-space: nowrap; + transform: translateX(-50%); + text-align: center; + color: #EEEEEE; +} + +.judge, +.lifeTrajectory, +.propinitial, +.selectlist { + position: fixed; + list-style-type: none; + left: 50%; + top: 5rem; + bottom: 8.5rem; + width: 30rem; + max-width: calc(100% - 2rem); + margin: auto; + padding: 0; + overflow: auto; + transform: translateX(-50%); + text-align: center; +} + +.lifeProperty{ + position: fixed; + list-style-type: none; + left: 50%; + top: 2rem; + width: 30rem; + max-width: calc(100% - 2rem); + padding: 0; + overflow: auto; + transform: translateX(-50%); + display: flex; + color: white; +} + +.lifeProperty > li { + width: 100%; + position: relative; + border: 1px #ccc solid; + display: inline-block; + margin: 0.1rem 2px; + font-size: 1rem; + text-align: center; + border-radius: 0.2rem; +} + +.selectlist > li { + position: relative; + border: 1px #EEEEEE solid; + display: inline-block; + width: 95%; + margin: 0.1rem auto; + font-size: 1.4rem; + text-align: center; + border-radius: 0.2rem; + cursor: pointer; + color: #EEEEEE; + user-select: none; +} + +.grade0b { + background-color: #464646; + border: #f8f8f8 2px solid !important; +} +.grade1b { + background-color: #6495ed; + border: #f8f8f8 2px solid !important; +} +.grade2b { + background-color: #e2a7ff; + border: #f8f8f8 2px solid !important; +} +.grade3b { + background-color: #ffa07a; + border: #f8f8f8 2px solid !important; +} + +@media (min-width:1080px) { + .grade0b:hover { + background-color: #c0c0c0; + color: #3b3b3b; + transition: all .3s ease 0s; + } + .grade1b:hover { + background-color: #87cefa; + color: #3b3b3b; + transition: all .3s ease 0s; + } + .grade2b:hover { + background-color: #e7beff; + color: #3b3b3b; + transition: all .3s ease 0s; + } + .grade3b:hover { + background-color: #f7a989; + color: #3b3b3b; + transition: all .3s ease 0s; + } +} +.grade0b.selected { + background-color: #c0c0c0 !important; + box-shadow: #ccc 0px 0px 10px; + color: #3b3b3b; +} + +.grade1b.selected { + background-color: #87cefa !important; + box-shadow: #ccc 0px 0px 10px; + color: #3b3b3b; +} + +.grade2b.selected { + background-color: #e7beff !important; + box-shadow: #ccc 0px 0px 10px; + color: #3b3b3b; +} + +.grade3b.selected { + background-color: #f1bfac !important; + box-shadow: #ccc 0px 0px 10px; + color: #3b3b3b; +} + +.judge > li.grade1 span, +.judge > li.grade1{ + background-color: #87cefa; +} +.judge > li.grade2 span, +.judge > li.grade2{ + background-color: #e7beff; +} +.judge > li.grade3 span, +.judge > li.grade3{ + background-color: #f7a989; +} + +.propinitial { + top: 5rem; + bottom: 17rem; +} + +.propbtn:hover{ + color: #5c5c5c; + transition: all .2s ease 0s; +} + +.propinitial > li { + position: relative; + display: inline-block; + width: 95%; + margin: 0.1rem auto; + font-size: 1.4rem; + text-align: center; + border-radius: 0.2rem; + padding: 0.2rem; + color: #EEEEEE; +} + +.propinitial > li > input { + height: 2.2rem; + width: 2.2rem; + margin: 0 0.5rem; + padding: 0; + text-align: center; + font-size: 2rem; + border: 0.1rem #EEEEEE solid; + background-color: #393E46; + color: #EEEEEE; +} + +.propbtn { + position: relative; + cursor: pointer; + font-size: 2rem; + color: #EEEEEE; +} + +.lifeTrajectory { + border: 1px #9b9b9b solid; + background-color: #393E46; + border-radius: 10px; +} + +.judge > li, +.lifeTrajectory > li { + position: relative; + width: calc(100% - 7rem); + margin: 0.5rem 0; + padding: 0.5rem 1rem 0.5rem 6rem; + font-size: 1.4rem; + background-color: #4a5361; + box-shadow: #EEEEEE 0 0 0.4rem; + color: #EEEEEE; +} + +.judge > li > span, +.lifeTrajectory > li > span { + position: absolute; + left: 0; + width: 6rem; + text-align: right; +} + +.judge > li { + box-shadow: #EEEEEE 0 0 0.4rem; + width: calc(100% - 9rem); + margin: 0.5rem; + padding: 0.5rem 1rem 0.5rem 7rem; + border-radius: 10px; +} + +.judge > li > span { + height: calc(100% - 1rem); + padding: 0.5rem 0; + top: 0; + border-radius: 10px; +} + + +@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700"); +:root { + font-family: "Montserrat"; +} + +html, +body { + margin: 0; + height: 100%; +} + +body { + display: flex; + align-items: center; + justify-content: center; +} + +i { + color: inherit; +} + +.banners-container { + position: fixed; + top: 0; + left: 0; + width: 100%; + z-index: 9; +} + +.banner { + color: white; + font-weight: 700; + padding: 2rem; + display: flex; + flex-direction: row; + align-items: center; +} +.banner .banner-message { + flex: 1; + padding: 0 2rem; + word-break: break-word; + overflow: auto; +} +.banner .banner-close { + display: flex; + align-items: center; + justify-content: center; + padding: 0.1rem; + border-radius: 4px; + cursor: pointer; + transition: background 0.3s; +} + +.banner .iconfont { + font-size: 2rem; +} + +.banner .banner-close:hover { + background: rgba(0, 0, 0, 0.12); +} + +.banner.success { + background: lightgreen; +} +.banner.success::after { + background: lightgreen; +} +.banner.error { + background: #ed1c24; +} +.banner.error::after { + background: #ed1c24; +} +.banner.info { + background: skyblue; +} +.banner.info::after { + background: skyblue; +} + +.banner::after { + content: ""; + position: absolute; + height: 10%; + width: 100%; + bottom: 100%; + left: 0; +} + +.banner:not(.visible) { + display: none; + transform: translateY(-100%); +} + +.banner.visible { + box-shadow: 0 2px 2px 2px rgba(0, 0, 0, 0.12); + animation-name: banner-in; + animation-direction: forwards; + animation-duration: 0.6s; + animation-timing-function: ease-in-out; + animation-fill-mode: forwards; + animation-iteration-count: 1; +} + +@keyframes banner-in { + 0% { + transform: translateY(-100%); + } + 50% { + transform: translateY(10%); + } + 100% { + transform: translateY(0); + } +} +.show-banner { + appearance: none; + background: #ededed; + border: 0; + padding: 1rem 2rem; + border-radius: 4px; + cursor: pointer; + text-transform: uppercase; + margin: 0.25rem; +} + +/** + * @license + * Copyright Akveo. All Rights Reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + .eva-animation { + animation-duration: 1s; + animation-fill-mode: both; } + + .eva-infinite { + animation-iteration-count: infinite; } + + .eva-icon-shake { + animation-name: eva-shake; } + + .eva-icon-zoom { + animation-name: eva-zoomIn; } + + .eva-icon-pulse { + animation-name: eva-pulse; } + + .eva-icon-flip { + animation-name: eva-flipInY; } + + .eva-hover { + display: inline-block; } + + .eva-hover:hover .eva-icon-hover-shake, .eva-parent-hover:hover .eva-icon-hover-shake { + animation-name: eva-shake; } + + .eva-hover:hover .eva-icon-hover-zoom, .eva-parent-hover:hover .eva-icon-hover-zoom { + animation-name: eva-zoomIn; } + + .eva-hover:hover .eva-icon-hover-pulse, .eva-parent-hover:hover .eva-icon-hover-pulse { + animation-name: eva-pulse; } + + .eva-hover:hover .eva-icon-hover-flip, .eva-parent-hover:hover .eva-icon-hover-flip { + animation-name: eva-flipInY; } + + @keyframes eva-flipInY { + from { + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + animation-timing-function: ease-in; + opacity: 0; } + 40% { + transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + animation-timing-function: ease-in; } + 60% { + transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + opacity: 1; } + 80% { + transform: perspective(400px) rotate3d(0, 1, 0, -5deg); } + to { + transform: perspective(400px); } } + + @keyframes eva-shake { + from, + to { + transform: translate3d(0, 0, 0); } + 10%, + 30%, + 50%, + 70%, + 90% { + transform: translate3d(-3px, 0, 0); } + 20%, + 40%, + 60%, + 80% { + transform: translate3d(3px, 0, 0); } } + + @keyframes eva-pulse { + from { + transform: scale3d(1, 1, 1); } + 50% { + transform: scale3d(1.2, 1.2, 1.2); } + to { + transform: scale3d(1, 1, 1); } } + + @keyframes eva-zoomIn { + from { + opacity: 1; + transform: scale3d(0.5, 0.5, 0.5); } + 50% { + opacity: 1; } } + +::-webkit-scrollbar { + width: 0 !important +} \ No newline at end of file diff --git a/games/lifeRestart/data/age.csv b/games/lifeRestart/data/age.csv new file mode 100644 index 0000000..367e531 --- /dev/null +++ b/games/lifeRestart/data/age.csv @@ -0,0 +1,504 @@ +$age,event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[],event[], +年龄,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池,对应的事件池, +0,10001*110,10002*100,10110,10111,10494*999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1,10009*10,10010*10,10011,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +2,10003,10007,10012,10014,10015,10016,10017,10018,10020,10019,10026,10027,10053,10059,10060,10063,10065,10069*0.03,10072,10089,10140*0.1,10141*0.1,10142*0.2,10150,10163,10164,10165,10166,10498*2,10499*2,10500*2,10501*2,10502*3,10503*3,10825,10826,10827,10828,10829,10839,10840,10843,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +3,10005,10007,10012,10014,10015,10016,10017,10018,10020,10021,10019,10022,10023,10026,10027,10029,10039,10043,10048,10050,10052,10053,10059,10060,10064,10069*0.03,10072,10075,10078,10089,10092,10093,10142*0.2,10150,10152,10163,10164,10165,10166,10504*999999,10501,10502,10503,10500,10499,10498,10505*999999,10822*99999999999,10823*99999,10824*99999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +4,10007,10012,10014,10018,10021,10022,10023,10024,10026,10030,10031,10034,10035,10036,10037,10039,10041,10043,10048,10050,10053,10054,10058,10065,10069*0.03,10075,10076,10077,10078,10089,10092,10093,10099,10100,10123,10124,10125,10126,10127,10128,10130,10140*0.1,10141*0.1,10142*0.2,10143,10144,10047,10048,10150,10152,10153,10163,10164,10165,10166,10168,10177,10178,10035,10506,10507,10508,10509,10510,10511,10512,10513,10514,10515,10516,10517,10785,10844*0.1,10845,10846,10847,10848,10849,10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860,10861,10862,10863,10864,10865,10866,10867,10868*0.01,10869*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +5,10007,10012,10014,10022,10023,10024,10026,10031,10034,10035,10036,10037,10039,10041,10043,10044,10047,10048,10049,10050,10051,10052,10053,10058,10059,10060,10061,10066,10069*0.03,10076,10077,10078,10089,10092,10093,10094,10099,10100,10123,10124,10125,10126,10127*2,10128*2,10140*0.1,10141*0.1,10142*0.2,10143,10144,10047,10048,10150,10153,10163,10164,10165,10166,10168,10172,10177,10178,10182,10035,10506,10507,10508,10509,10510,10511,10512,10513,10514,10515,10516,10517,10844*0.1,10845,10846,10847,10848,10849,10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860,10861,10862,10863,10864,10865,10866,10867,10868*0.01,10869*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +6,10007,10012,10014,10022,10023,10036,10037,10043,10044,10045,10047,10048,10049,10050,10052,10054,10057,10058,10061,10065,10067,10069,10072,10073,10075,10076,10077,10078,10089,10091,10093,10094,10095,10096,10098,10099,10100,10101*100,10123,10124,10125*0.1,10126*0.1,10127,10128,10130,10140*0.1,10141*0.1,10142*0.2,10143,10144,10145,10146,10147,10148,10150,10153,10166,10168,10169,10172,10178,10179,10183,10224,10035,20036*3,10518*9999999999,10785,10870*99999999999,10871*99999999999,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +7,10007,10012,10014,10022,10023,10036,10037,10038,10041,10044,10047,10049,10051,10052,10057,10058,10059,10060,10061,10066,10067,10069,10073,10076,10077,10078,10079,10089,10093,10094,10096,10097,10098,10101*100,10102,10103,10104,10105,10106,10107,10108,10109,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127*0.1,10128*0.1,10129,10131,10132,10133,10134,10138,10139,10140*0.1,10141*0.1,10142*0.2,10143,10145,10146,10147,10148,10149,10151,10153,10166,10168,10169,10171,10179,10183,20036,10519,10520,10521,10522,10523,10524,10525,10526,10527,10528,10529,10530,10531,10532,10533,10535,10536,10537,10538,10539,10576*0.01,10577,10872,10873,10874,10875,10876,10877,10878,10879,10880,10881,10901,10883,10884,10885,10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,10898,10899,10902,10903,10904,10905,10906,10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +8,10007,10012,10014,10022,10023,10036,10037,10038,10045,10051,10057,10061,10065,10067,10069,10073,10075,10076,10077,10078,10079*3,10089,10094,10095,10097,10098,10101*9999,10102,10103,10104,10105,10106,10107,10108,10109,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127*0.1,10128*0.1,10129,10130,10131,10132,10133,10134,10138,10139,10142*0.2,10143,10145,10146,10147,10148,10149,10151,10153,10166,10167*5,10169,10170,10173,10174,10176,10177,10179,20036,10519,10520,10521,10522,10523,10524,10525,10526,10527,10528,10529,10530,10531,10532,10533,10535,10536,10537,10538,10539,10576*0.01,10577,10592,10786,10844*0.1,10872,10873,10874,10875,10876,10877,10878,10879,10880,10881,10901,10883,10884,10885,10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,10898,10899,10902,10903,10904,10905,10906,10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +9,10007,10012,10014,10022,10023,10024,10041,10044,10051,10052,10061,10066,10067,10069*0.03,10070*0.03,10071*0.03,10076,10077,10078,10079*5,10089,10091,10098,10102,10103,10104,10105,10106,10107,10108,10109,10112,10113,10114,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127,10128,10129,10130,10131,10132,10133,10134,10135,10138,10139,10142*0.2,10143,10145,10146,10147,10148,10149,10151,10163,10164,10165,10167*5,10169,10170,10172,10175,10176,10177,10179,10180,20036,10519,10520,10521,10522,10523,10524,10525,10526,10527,10528,10529,10530,10531,10532,10533,10535,10536,10537,10538,10539,10576*0.01,10577*2,10844*0.1,10872,10873,10874,10875,10876,10877,10878,10879,10880,10881,10901,10883,10884,10885,10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,10898,10899,10902,10903,10904,10905,10906,10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11261,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +10,10007,10012,10014,10022,10023,10024,10045,10047,10054,10061,10066,10069*0.03,10070*0.03,10071*0.03,10076,10077,10078,10079*5,10080*3,10089,10090*0.5,10103,10104,10105,10106,10107,10108,10109,10112,10113,10114,10115,10116*3,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127*0.1,10128*0.1,10129,10131,10132,10133,10134,10135,10138,10139,10140*0.1,10141*0.1,10142*0.2,10143,10145,10146,10147,10148,10152,10154,10167*4,10169,10170,10172,10176,10179,10180,10309,20036,10519,10520,10521,10522,10523,10524,10525,10526,10527,10528,10529,10530,10531,10532,10533,10534,10535,10536,10537,10538,10539,10540*2,10576*0.01,10577*2,10588*9999999999999999,10592,10844*0.1,10872,10873,10874,10875,10876,10877,10878,10879,10880,10881,10901,10883,10884,10885,10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,10898,10899,10902,10903,10904,10905,10906,10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11261,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +11,10007,10012,10014,10022,10023,10069*0.03,10070*0.03,10071*0.03,10072,10079*3,10080*3,10089,10095,10096,10099,10104,10105,10106,10107,10108,10109,10112,10113,10114,10115,10116*3,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127,10128,10129,10131,10132,10133,10134,10135,10136,10137,10138,10139,10140*0.1,10141*0.1,10142*0.2,10143,10144,10145,10146,10147,10148,10149,10151,10152,10154,10167*3,10169,10170,10171,10172,10176,10180,10311,10463,20036,20054,10519,10520,10521,10522,10523,10524,10525,10526,10527,10528,10529,10530,10531,10532,10533,10534*2,10535,10536,10537,10538,10539,10540,10576*0.01,10577,10592,10786,10872,10873,10874,10875,10876,10877,10878,10879,10880,10881,10901,10883,10884,10885,10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,10898,10899,10902,10903,10904,10905,10906,10907,10908,10909,10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,10934,10935,10936,10937,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11261,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,10008*0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +12,10007,10008*0.1,10012,10014,10022,10023,10069*0.03,10070*0.03,10071*0.03,10079*5,10080*3,10089,10096,10097,10108,10109,10112,10113,10114,10115,10116*3,10117,10118,10119,10120,10121,10122,10123,10124,10125*0.1,10126*0.1,10127,10128,10129,10130,10131,10132,10133,10134,10135,10138,10139,10142*0.2,10143,10145,10146,10147,10148,10150,10149,10151,10154,10155*3,10156,10157*50,10160,10167*2,10169,10171,10172,10176,10180,10182,10214,10311,20036*3,20054*2,10541*9999999999,10542*9999999999,10938*999999999999,10939*999999999999,10940*999999999,10941*999999999,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11451*9999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +13,10007,10008*0.1,10022,10023,10069*0.03,10070*0.03,10071*0.03,10080,10089,10097,10155*3,10156,10157*200,10158,10159*0.01,10160,10161,10162*0.1,10163,10164,10165,10169,10171,10180,10181,10182,10183,10184*10,10185*10,10189,10201,10211,10212,10213,10214,10215,10216,10224,10225,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10309,10311,20054*3,10543*5,10544*5,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,10574,10575,10592,10942*10,10947*999999,10948*99999999,10958*999999,10967,10968,10969,10970,10971*0.1*0.1,10972*0.1,10973*0.1,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993*0.1,10994*0.1,10995*0.1,10996*0.1,10997*0.1,10998*0.1,10999*0.1,11000*0.1,11001*0.1,11002*0.1,11003*0.1,11004*0.1,11005*0.1,11006*0.1,11007*0.1,11008*0.1,11009,11010,11011,11012,11013,11014,11015*0.2,11016*0.2,11017*0.2,11018*0.2,11019*0.2,11020*0.2,11021,11022,11023,11024,11025,11026,11027,11028,11029*0.2,11030*0.2,11031*0.2,11032*0.2,11033*0.2,11034*0.2,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,21045*5,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11219*0.01,11261,11262,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +14,10007,10008*0.1,10022,10023,10069*0.03,10070*0.03,10071*0.03,10080*2,10081*3,10089,10155*3,10156,10157*9999,10158,10159*0.1,10160,10161,10162*0.1,10085,10163,10164,10165,10169,10171,10180,10181,10182,10183,10186*5,10187,10188,10189,10201,10202*10,10211*5,10212*5,10214,10215,10216,10224,10225,10227,10253*0.1,10257*0.1,10309,10311,20054,20055,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,10574,10575,10592,10785,10942*10,10947*999999,10949*999999,10950*999999,10959*999999,10967,10968,10969,10970,10971*0.1,10972*0.1,10973*0.1,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993*0.1,10994*0.1,10995*0.1,10996*0.1,10997*0.1,10998*0.1,10999*0.1,11000*0.1,11001*0.1,11002*0.1,11003*0.1,11004*0.1,11005*0.1,11006*0.1,11007*0.1,11008*0.1,11009,11010,11011,11012,11013,11014,11015*0.2,11016*0.2,11017*0.2,11018*0.2,11019*0.2,11020*0.2,11021,11022,11023,11024,11025,11026,11027,11028,11029*0.2,11030*0.2,11031*0.2,11032*0.2,11033*0.2,11034*0.2,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,21045*5,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11219*0.01,11261,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +15,10007,10008*0.1,10022,10023,10069*0.03,10070*0.03,10071*0.03,10080*5,10081*3,10089,10158,10159*0.1,10161,10162*0.1,10085,10086,10163,10164,10165,10180,10181,10182,10183,10187,10188,10189,10194*5,10198*10000,10199*10000,10200*10000,10201,10203*99999,10211,10212,10213,10214,10215,10216,10224,10225,10226,10227,10254*0.1,10258,10309,10410,10411,10412,10468*3,20054*2,20055,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,10574,10575,10786,10943*9999999,10951*999999,10960*999999,10961*999999,10967,10968,10969,10970,10971*0.1,10972*0.1,10973*0.1,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993*0.1,10994*0.1,10995*0.1,10996*0.1,10997*0.1,10998*0.1,10999*0.1,11000*0.1,11001*0.1,11002*0.1,11003*0.1,11004*0.1,11005*0.1,11006*0.1,11007*0.1,11008*0.1,11009,11010,11011,11012,11013,11014,11015*0.2,11016*0.2,11017*0.2,11018*0.2,11019*0.2,11020*0.2,11021,11022,11023,11024,11025,11026,11027,11028,11029*0.2,11030*0.2,11031*0.2,11032*0.2,11033*0.2,11034*0.2,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,11067*666666,21045*5,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11219*0.01,11261,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +16,10007,10008*0.1,10022,10023,10069*0.03,10070*0.03,10071*0.03,10080*3,10081*3,10089,10161,10162*0.1,10085,10086,10163,10164,10165,10180,10181,10183,10187,10188,10189,10190*10,10194*10,10198*10000,10199*10000,10200*10000,10201,10203*99999,10205*99999,10211,10212,10213,10214,10215,10216,10217,10218*2,10219*3,10224,10225,10226*3,10227,10258,10410,10411,10412,10259*999999,10468*3,20054*3,20055,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,10574,10575,10952*999999,10953*999999,10954*999999999,10955*999999999,10962*999999,10963*999999,10964*999999,10965*999999,10967,10968,10969,10970,10971*0.1,10972*0.1,10973*0.1,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993*0.1,10994*0.1,10995*0.1,10996*0.1,10997*0.1,10998*0.1,10999*0.1,11000*0.1,11001*0.1,11002*0.1,11003*0.1,11004*0.1,11005*0.1,11006*0.1,11007*0.1,11008*0.1,11009,11010,11011,11012,11013,11014,11015*0.2,11016*0.2,11017*0.2,11018*0.2,11019*0.2,11020*0.2,11021,11022,11023,11024,11025,11026,11027,11028,11029*0.2,11030*0.2,11031*0.2,11032*0.2,11033*0.2,11034*0.2,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,11058,11059,11060,11061,11062,11063,11064,11065,11066,11068*999999,21045*5,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11262,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +17,10007,10008*0.1,10022,10023,10069*0.03,10070*0.03,10071*0.03,10080*3,10081*5,10089,10091,10085,10086,10163,10164,10165,10180,10181,10183,10188,10189,10190*10,10191*99999,10194*5,10201,10205*99999,10206*99999,10211,10212,10213,10214,10215,10216,10217*2,10218*3,10219*5,10220*5,10221*5,10223*10,10224,10225,10226*5,10230*9999999,10259*999999,10309,10410,10411,10412,10468*3,10469*2,10470*2,10471*2,10472*2,10473,20055,10545,10546,10547,10548,10549,10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,10574,10575,10578*9999999999,10956*999999,10957*999999,10962*999999,10963*999999,10964*999999,10965*999999,10967,10968,10969,10970,10971*0.1,10972*0.1,10973*0.1,10974,10975,10976,10977,10978,10979,10980,10981,10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993*0.1,10994*0.1,10995*0.1,10996*0.1,10997*0.1,10998*0.1,10999*0.1,11000*0.1,11001*0.1,11002*0.1,11003*0.1,11004*0.1,11005*0.1,11006*0.1,11007*0.1,11008*0.1,11009,11010,11011,11012,11013,11014,11015*0.2,11016*0.2,11017*0.2,11018*0.2,11019*0.2,11020*0.2,11021,11022,11023,11024,11025,11026,11027,11028,11029*0.2,11030*0.2,11031*0.2,11032*0.2,11033*0.2,11034*0.2,11035,11036,11037,11038,11039,11040,11041,11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,11054,11055,11056,11057,11058,11059,11060,11061,11062,11063,11064,11065,11066,11068*999999,11078,11079,11080,11081,11082,11083,11084,11085,11086,21045*3,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.01,11214*0.01,11215*0.01,11216*0.01,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +18,10007,10008*0.1,10069*0.03,10070*0.03,10071*0.03,10081,10083,10090*0.5,10086,10163,10164,10165,10180,10181,10183,10188,10189,10190*10,10191*99999,10192*99999,10194*3,10201,10206*99999,10215,10216,10217,10218*2,10219*3,10220*10,10221*9999999,10223*99999,10224,10226*10,10231*999999,10233*999999,10237*100,10238*100,10239*10,10247,10260*999999,10261*999999,10262*999999,10263*999999,10267*99999,10468*3,10469*2,10470*2,10471*2,10472*2,10473,20055,10579*999999,10580*999999,10581*999999,10582*999999,10583*999999,10584*999999,10586*999999,10587*999999,20580*9999999,10966*999999999,11069*999999999,11070*999999999,11077*99999,11076*6666666,11075*9999999,11071*999999999999,11072*999999999999,11073*999999999999,11074*999999999999,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +19,10007,10008*0.1,10069*0.03,10070*0.03,10071*0.03,10081,10083,10085,10086,10189,10190,10191*99999,10195*1000,10196*4000,10197*1000,10206*99999,10220*15,10221*999999,10222*999999,10223*99999,10230*999999,10237*999999,10238*999999,10239*999999,10247,10249*999999,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10260*999999,10261*999999,10262*999999,10263*999999,10267*99999,10469*2,10470*2,10471*2,10472*2,10473,20055,10585,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602,10603,10604,10605,10606*2,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,10785,11087,11088,11089,11090,11091,11092,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104,11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,11116,11117,11118,11119,11120,11121,11201,11202,11203,11204*0.05,11205,11206,11207,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.02,11214*0.02,11215*0.02,11216*0.02,11219*0.01,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11452*99999999999999999,11453*99999999999999999,11455*33333333333333333,11456*33333333333333333,11457*33333333333333333,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +20,10007,10069*0.03,10070*0.03,10071*0.03,10081,10083,10085*3,10086,10090*0.5,10189,10191,10192*99999,10195*1000,10196*4000,10197*1000,10207*99999,10206,10220*50,10221*999999,10222*999999,10223*99999,10231*999999,10233*999999,10240,10241,10242,10243,10244,10245,10246,10247,10249*999999,10260*999999,10261*999999,10262*999999,10263*999999,10267*99999,10268*2,10269,10270,10271,10410,10411,10412,10463,10469*2,10470*2,10471*2,10472*2,10473,10585,10589*99999999999999,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602,10603,10604,10605,10606*4,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11087,11088,11089,11090,11091,11092,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104,11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,11116,11117,11118,11119,11120,11121,11201,11202,11203,11204*0.05,11205,11206,11207,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.02,11214*0.02,11215*0.02,11216*0.02,11262,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11454*99999999999999999,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +21,10007,10069*0.03,10070*0.03,10071*0.03,10081,10083,10085*5,10086,10189,10192*99999,10195*1000,10196*4000,10197*1000,10206*99999,10222*99999,10223*99999,10240,10241,10242,10243,10244,10245,10246,10247,10249*999999,10260*999999,10261*999999,10262*999999,10263*999999,10267*99999,10273,10274,10275,10276,10430,10431,10432,10433,10434,10435,10469*2,10470*2,10471*2,10472*2,10473,20055,10585,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602,10603,10604,10605,10606*5,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,10785,10786,11087,11088,11089,11090,11091,11092,11094,11095,11096,11097,11098,11099,11100,11101,11102,11103,11104,11105,11106,11107,11108,11109,11110,11111,11112,11113,11114,11115,11116,11117,11118,11119,11120,11121,11201,11202,11203,11204*0.05,11205,11206,11207,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.05,11214*0.05,11215*0.05,11216*0.05,11219*0.01,11262,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +22,10007,10069*0.03,10070*0.03,10071*0.03,10081,10083,10085*10,10086,10189,10195*1000,10196*2000,10197*5000,10206*99999,10228*999999,10240,10241,10242,10243,10244,10245,10246,10249*999999,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10264*9999999,10268*2,10269,10270,10271,10272,10273,10274,10275,10276,10410,10411,10430,10431,10432,10433,10434,10435,10469*2,10470*2,10471*2,10472*2,10473,10585,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602,10603,10604,10605,10606*2,10608*999999999,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11087,11088,11089,11090,11091,11092,11122*999999999,11123*999999999,11124*999999999,11125*999999999,11221,11222,11223,11224,11225,11226,11227,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +23,10007,10069*0.03,10070*0.03,10071*0.03,10081,10083,10085*50,10086,10189,10197*99999,10206*99999,10229*999999,10249*999999,10253,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10266,10273,10274,10275,10276,10410,10411,10430,10431,10432,10433,10434,10435,10469*2,10470*2,10471*2,10472*2,10473,20055,10593,10594,10595,10596,10597,10598,10599,10600,10601,10602,10603,10604,10605,10606*2,10613*9,10614*5,10615*5,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11093*999999999,11126*999999999,11127*999999999,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11152*10,11153*10,11154*10,11172*10,11174*5,11175*5,11176*5,11177*5,11178*5,11221,11222,11223,11224,11225,11226,11227,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +24,10007,10069*0.03,10070*0.03,10071*0.03,10083,10085*500,10086,10087,10189,10207*99999,10234*999999,10250*999999,10251*999999,10253*0.1,10266,10268*2,10269,10270,10271,10272,10273,10274,10275,10276,10281,10282*0.001,10284,10285,10288,10410,10411,10430,10431,10432,10433,10434,10435,10468*3,10469*2,10470*2,10471*2,10472*2,10473,10474*9,10475*3,10476*3,10477*3,10607*9999999,10609*9999999,10613*99,10614*5,10615*5,10618,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,10785,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11123*999999,11155*999999,11164,11165,11166,11167,11168,11169,11170,11173,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.05,11214*0.05,11215*0.05,11216*0.05,11219*0.01,11221,11222,11223,11224,11225,11226,11227,11240,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +25,10007,10069*0.03,10070*0.03,10071*0.03,10083,10085*9999,10086,10087,10088,10189,10210*99999,10252,10257*0.1,10266,10268,10269,10270,10271,10272,10273,10274,10275,10276,10281,10282*0.001,10284,10285,10410,10411,10413,10414,10415,10416,10417,10430,10431,10432,10433,10434,10435,10468*3,10469*2,10470*2,10471*2,10472*2,10473,10474*99,10475*3,10476*3,10477*3,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10591,10610*2,10615,10617,10618,10660,10661,10662,10663,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11164,11165,11166,11167,11168,11169,11170,11173,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11228*999999999,11240*3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +26,10007,10069*0.03,10070*0.03,10071*0.03,10085*9999,10086,10087,10088*10,10189,10210*99999,10252,10256*0.1,10266,10272,10273,10274,10275,10276,10281,10282*0.001,10284,10285,10410,10411,10413,10414,10415,10416,10417,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10468*3,10469*2,10470*2,10471*2,10472*2,10473,10474,10475*3,10476*3,10477*3,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10610*5,10611,10161*9,10617,10618,10660,10661,10662,10663,10664,10665,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11161,11164,11165,11166,11167,11168,11169,11170,11171*3,11173,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11229*999999,11230*999999999,11240*9,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +27,10007,10069*0.03,10070*0.03,10071*0.03,10086,10087,10088*10,10189,10235*999999,10252,10254*0.1,10266,10268,10269,10270,10271,10273,10274,10275,10276,10281,10282*0.001,10410,10411,10413,10414,10415,10416,10417,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10463,10469*2,10470*2,10471*2,10472*2,10473,10474,10591,10610*30,10611*99,10612*5,10616*9999999,10660,10661,10662,10663,10664*5,10665*5,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11161,11164,11165,11166,11167,11168,11169,11170,11171*3,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11219*0.01,11220,11231*999999999,11237*999999,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +28,10007,10069*0.03,10070*0.03,10071*0.03,10086,10087,10088,10189,10236*99999999,10268,10269,10270,10271,10272,10273,10274,10275,10276,10281,10282*0.001,10284,10285,10288,10410,10411,10413,10414,10415,10416,10417,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10469*2,10470*2,10471*2,10472*2,10473,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10591,10610*999999999,10611*999999,10612*99999999,10660,10661,10662,10663,10664,10665*5,10666*5,10667*5,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11161,11164,11165,11166,11167,11168,11169,11170,11171*6,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11232*999999,11238*999999999,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,, +29,10007,10069*0.03,10070*0.03,10071*0.03,10086,10087,10189,10253*0.1,10268,10269,10270,10271,10272,10273,10274,10275,10276,10281,10282*0.001,10284,10285,10410,10411,10413,10414,10415,10416,10417,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10469*2,10470*2,10471*2,10472*2,10473,10474*99,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10591,10619,10620*5,10666*5,10667*5,10668*5,10717,10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,10730,10731,10732,10733,10734,10735,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11164,11165,11166,11167,11168,11169,11170,11171*9,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11232*999999,11235*999999999,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,, +30,10069*0.03,10070*0.03,10071*0.03,10086,10087,10189,10268,10269,10270,10271,10272,10273,10274,10275,10276,10277,10278,10281,10282*0.001,10288,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10411,10413,10414,10415,10416,10417,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10469*2,10470*2,10471*2,10472*2,10473,10589*99999999999999,10619,10620*3,10621,10622,10666*5,10665*5,10667*5,10668*5,10736*99999999999999,10785,10786,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,11150,11151,11156,11157,11158,11159,11160,11164,11165,11166,11167,11168,11169,11170,11171*9,11179,11180,11181,11182,11183,11184*0.05,11185*0.05,11186*0.05,11187*0.05,11188*0.05,11189*0.05,11190*0.05,11191*0.05,11192*0.05,11193*0.05,11194*0.05,11195*0.05,11196*0.05,11197*0.05,11198*0.05,11199*0.05,11200*0.05,11208*0.5,11209*0.5,11210*0.5,11211*0.5,11212*0.5,11213*0.1,11214*0.1,11215*0.1,11216*0.1,11217*0.01,11218*0.01,11219*0.01,11220,11232*999999,11234*333333,11235*999999999,11236*999999999,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*33333333333333333,11466*33333333333333333,11467*33333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,, +31,10069*0.03,10070*0.03,10071*0.03,10086*2,10087,10256,10268,10269,10270,10271,10272,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10284,10285,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10469*2,10470*2,10471*2,10472*2,10473,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10619,10620*2,10621*2,10622,10668*5,10737*99999999999999,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11162*999999,11163*999999,11164,11165,11166,11167,11168,11169,11170,11171*999999,11232*999999,11234*333333,11235*999999999,11236*999999999,11240,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +32,10069*0.03,10070*0.03,10071*0.03,10086*3,10087,10254,10272,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10284,10285,10288,10289*0.01,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10469*2,10470*2,10471*2,10472*2,10473,10591,10621*10,10622,10668*5,10669*5,10670,10738,10739,10740,10785,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11232*999999,11234*333333,11235*999999999,11236*999999999,11239*10,11240*999999,11241,11242*3,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +33,10069*0.03,10070*0.03,10071*0.03,10086*4,10087,10268,10269,10270,10271,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10283,10289*0.01,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10469*2,10470*2,10471*2,10472*2,10473,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10621*99999999,10668*5,10669*5,10670,10738,10739,10740,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11219*0.01,11220,11232*999999,11234*333333,11235*999999999,11236*999999999,11241,11242*3,11243,11244*3,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11259,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +34,10069*0.03,10070*0.03,10071*0.03,10086*5,10087,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10283,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10469*2,10470*2,10471*2,10472*2,10473,10591,10623,10624,10625,10626,10627,10658,10668*5,10669*5,10670,10738,10739,10740,10786,10830*99,10831*9,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11232*999999,11234*666666,11235*999999999,11236*999999999,11241,11242*9,11243,11244*9,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11259,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11314*0.01,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,,,,,,,,,,,,,,,,, +35,10069*0.03,10070*0.03,10071*0.03,10086*6,10087,10268,10269,10270,10271,10273,10274,10275,10276,10277,10278,10281,10282*0.001,10283,10288,10289*0.01,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10469*2,10470*2,10471*2,10472*2,10473,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10623,10624,10625,10626,10627,10658*3,10668*5,10669*5,10670,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10830*99,10831*99,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11232*999999,11234*999999,11235*999999999,11236*999999999,11242*30,11241,11243,11244*30,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256,11259,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999,, +36,10069*0.03,10070*0.03,10071*0.03,10087*7,10253*0.1,10268,10269,10270,10271,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10283,10289*0.01,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10591,10623,10624,10625,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10658*5,10670,10671*2,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10830*9,10831*99,10832,10833,10834,10835,10836,10837,10838,11219*0.01,11220,11232*999999,11234*999999999,11235*999999999,11236*999999999,11242*99999,11241,11243,11244*999,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256*2,11259,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999 +37,10069*0.03,10070*0.03,10071*0.03,10087*8,10254*0.1,10268,10269,10270,10271,10273,10274,10275,10276,10277,10278,10281,10282*0.001,10283,10288,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10591,10623,10624,10625,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10658*10,10670,10671*3,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10830*9,10831*99,10832,10833,10834,10835,10836,10837,10838,11219*0.01,11220,11233*999999999,11235*999999999,11236*999999999,11243,11244*999999,11241,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256*3,11259,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*333333333333333333,11467*333333333333333333,11458*99999999999999999,11459*99999999999999999, +38,10069*0.03,10070*0.03,10071*0.03,10087*9,10255*0.1,10273,10274,10275,10276,10277,10278,10281,10282*0.001,10283,10289*0.01,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10317,10318,10319,10320,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10623,10624,10625,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10658*6,10670,10671*5,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11235*999999999,11236*999999999,11243,11241,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256*4,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11460*33333333333333333,11461*33333333333333333,11462*33333333333333333,11463*33333333333333333,11464*33333333333333333,11465*333333333333333333,11466*9333333333333333333,11467*9333333333333333333,11458*99999999999999999,11459*99999999999999999,,,,,,,,,,,,, +39,10069*0.03,10070*0.03,10071*0.03,10087*10,10256*0.1,10268,10269,10270,10271,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10317,10318,10319,10320,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10625*9,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10658*2,10670,10671*5,10672,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10830*9,10831*9,10832,10833,10834,10835,10836,10837,10838,11236*999999999,11243,11245,11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256*5,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,11466*9333333333333333333,11467*9333333333333333333,,,,,,,,,,,,,,,,,,,, +40,10069*0.03,10070*0.03,10071*0.03,10087,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10288,10289*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10317,10318,10319,10320,10322*0.1,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10590*99999999999999,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10658,10670,10671*5,10672*2,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11243,11256*6,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11350,11351,11352,11353,11354,11355,11356,11357,11358,11359,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11466*9333333333333333333,11467*9333333333333333333,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +41,10069*0.03,10070*0.03,10071*0.03,10087,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10290*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10318,10319,10320,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10591,10626,10627,10628,10629,10630,10631,10632,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10671*5,10672*3,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11256*9,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +42,10069*0.03,10070*0.03,10071*0.03,10087,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10290*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10317,10318,10319,10320,10322,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10590*99999999999999,10626,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10672*5,10673,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,11217*0.02,11218*0.02,11256*99,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11287,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +43,10069*0.03,10070*0.03,10071*0.03,10087,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10288,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10318,10319,10320,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10591,10626,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10648,10672*3,10673,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11256*999999,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11287,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +44,10069*0.03,10070*0.03,10071*0.03,10087,10253*0.1,10254*0.1,10255*0.1,10256*0.1,10257*0.1,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.1,10283,10288,10289*0.01,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10317,10318,10319,10320,10322*0.1,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10463,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10626,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*2,10672*3,10673,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11287,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +45,10069*0.03,10070*0.03,10071*0.03,10087,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10283,10288,10289*0.1,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10317,10318,10319,10320,10410,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10478*2,10479*2,10480*2,10481*2,10482*2,10483*2,10484*2,10485*2,10486*2,10487*2,10488*2,10489*2,10490*2,10491*2,10590*99999999999999,10626,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*3,10672*5,10673,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,11259,11260,11263,11264,11265,11266,11267,11268*0.05,11269,11270,11271,11272,11273,11274,11275,11276*0.03,11277*0.03,11278*0.03,11279,11280,11281,11282,11283,11284,11285,11286*0.3,11287*3,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +46,10069*0.03,10070*0.03,10071*0.03,10087,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10288,10289*0.1,10290*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10317,10318,10319,10320,10322,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*5,10648,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11287*3,11288,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +47,10069*0.03,10070*0.03,10071*0.03,10087,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.1,10290*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10318,10319,10320,10322*0.1,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10591,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*10,10648,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11287*3,11288*3,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +48,10069*0.03,10070*0.03,10071*0.03,10087,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10288,10289*0.1,10290*0.01,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10308,10317,10318,10319,10320,10322,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*50,10647*5,10648,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11287*3,11288*9,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11314*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +49,10069*0.03,10070*0.03,10071*0.03,10087,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10290*0.01,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10317,10318,10319,10320,10322*0.1,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646*100,10647*99,10648,10674,10675,10676,10741,10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,10766,10767,10768*0.01,10832,10833,10834,10835,10836,10837,10838,11217*0.02,11218*0.02,11219*0.01,11220,11287*3,11288*9,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.01,11415*0.01,11416*0.01,11417*0.01,11418*0.01,11419*0.01,11420*0.01,11421*0.01,11422*0.01,11423*0.01,11424*0.01,11425*0.01,11426*0.01,11427*0.01,11428*0.01,11429*0.01,11430*0.01,11431*0.01,11432*0.01,11433*0.01,11434*0.01,11435*0.01,11436*0.01,11437*0.01,11438*0.01,11439*0.01,11440*0.01,11441*0.01,11442*0.01,11443*0.01,11444*0.01,11445*0.01,11446*0.01,11447*0.01,11448*0.01,11449*0.01,11450*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +50,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10289*0.1,10290*0.01,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10317,10318,10319,10320,10321,10322*0.1,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10590*99999999999999,10646*999,10647*99,10648,10677*2,10678*2,10769*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10832,10833,10834,10835,10836,10837,10838,11219*0.01,11220,11257*0.01,11258*0.01,11288*9,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11296*999999,21305*999999999,11300,11305,11312*0.1,11314*0.01,11325,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +51,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.01,10286,10287,10288,10290*0.01,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10308,10317,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10648,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10655,10677*5,10678*5,10769*9999999999,10785,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.01,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11296*999999,21305*999999999,11300,11301,11302,11303,11304,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +52,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10286,10287,10290*0.01,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10317,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10655,10677*10,10678*10,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.01,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11296*999999,21305*999999999,11300,11301,11302,11303,11304,11327,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +53,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10288,10290*0.01,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10317,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10655,10677*10,10678*10,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.01,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11296*999999,21305*999999999,11312*0.1,11314*0.01,11318,11319*999999999,11326,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +54,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.01,10286,10287,10289*0.1,10290*0.01,10292,10293,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10308,10317,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10464,10465*0.5,10466*0.2,10467*0.08,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10655,10677*5,10678*5,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11257*0.01,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11300,11301,11302,11303,11304,11318,11319*999999999,11325,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +55,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10288,10289*0.1,10290*0.01,10292,10293,10291*0.01,10295*66,10296*66,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10317,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10492*999999999,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10677*2,10678*2,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,11219*0.01,11220,11257*0.05,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11295*0.01,11305,11312*0.1,11314*0.01,11318,11319*999999999,11320*999999999,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +56,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286*10,10287*50,10289*0.1,10290*0.01,10291*0.01,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10461*0.1,10462*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10785,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.05,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11295*0.01,11300,11301,11302,11303,11304,11320*999999999,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +57,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286*500,10287*100,10290*0.01,10292,10293,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10785,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.05,11258*0.01,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11295*0.01,11300,11301,11302,11303,11304,11320*999999999,11325,11326,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +58,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10288,10289*0.1,10290*0.01,10292,10293,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.1,11258*0.05,11289*99999999,11290*99999999,11291*99999999,11292,11293,11294*0.1,11295*0.01,11300,11301,11302,11303,11304,11320*999999999,11325,11326,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +59,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.001,10286,10287,10288,10289*0.1,10292,10293,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430*0.1,10431*0.1,10432*0.1,10433*0.1,10434*0.1,10435*0.1,10436*0.1,10437*0.1,10438*0.1,10439*0.1,10440*0.1,10441*0.1,10442*0.1,10443*0.1,10444*0.1,10445*0.1,10446*0.1,10447*0.1,10448*0.1,10449*0.1,10450*0.1,10451*0.1,10452*0.1,10453*0.1,10454*0.1,10455*0.1,10456*0.1,10457*0.1,10458*0.1,10459*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,11219*0.01,11220,11257*0.1,11258*0.05,11289*99999999,11290*99999999,11291*99999999,11320*999999999,11327,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +60,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.01,10281,10282*0.01,10286,10287,10288,10289*0.1,10290*0.01,10292,10293,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307*999,10316,10318,10319,10320,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10493*99999999,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10659,10679,10680,10681,10682,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,11219*0.01,11220,11257*0.1,11258*0.05,11289*99999999,11290*99999999,11291*99999999,11295*0.01,11297*3,11298,11300,11301,11302,11303,11304,11305,11312*0.1,11313*0.5,11314*0.01,11320*999999999,11323*99999999,11325,11326,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +61,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.1,10290*0.01,10292,10293,10291*0.01,10308,10310,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10461*0.1,10462*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10683,10684,10685,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10785,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,11257*0.5,11258*0.1,11289*99999999,11290*99999999,11291*99999999,11299*999999,11298,11320*999999999,11323*99999999,11326,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +62,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.1,10290*0.01,10292,10293,10291*0.01,10308,10310,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10659,10679,10680,10681,10682,10683,10684,10685,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,11219*0.01,11220,11257*0.5,11258*0.1,11289*99999999,11290*99999999,11291*99999999,11295*0.03,11297*3,11299*999999,11300,11301,11302,11303,11304,11305,11312*0.1,11313*0.5,11315*999999,11320*999999999,11323*99999999,11326,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +63,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.1,10290*0.01,10292,10293,10291*0.01,10308,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10461*0.1,10462*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10683,10684,10685,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10786,10785,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,11219*0.01,11220,11257*0.5,11258*0.1,11289*99999999,11290*99999999,11291*99999999,11295*0.03,11320*999999999,11326,11327,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +64,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10290*0.01,10292,10293,10291*0.01,10308,10310,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10461*0.1,10462*0.1,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10654,10655,10679,10680,10681,10682,10683,10684,10685,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10785,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,11219*0.01,11220,11257*0.5,11258*0.1,11289*99999999,11290*99999999,11291*99999999,11295*0.03,11312*0.1,11320*999999999,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +65,10069*0.03,10070*0.03,10071*0.03,10253,10254,10255,10256,10257,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10290*0.1,10292,10293,10291*0.01,10308,10316*3,10321,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10649*0.01,10650*0.01,10651*0.01,10652*0.01,10653*0.01,10654,10655,10659,10679,10680,10681,10682,10683,10684,10685,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10785,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,11219*0.01,11220,11257,11258*0.5,11289*99999999,11290*99999999,11291*99999999,11295*0.03,11298,11320*999999999,11328,11329*0.1,11330,11331*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +66,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10290*0.1,10291*0.1,10308,10310,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649*0.1,10650*0.1,10651*0.1,10652*0.1,10653*0.01,10659,10679,10680,10681,10683,10684,10685,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257,11258*0.5,11289*99999999,11290*99999999,11291*99999999,11295*0.03,11297*9,11299*999999,11300,11301,11302,11303,11304,11306*0.01,11309,11312*0.1,11315*999999,11316*0.3,11320*999999999,11323*99999999,11327,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +67,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10282*0.001,10290*0.1,10291*0.1,10308,10310,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10461*0.1,10462*0.1,10649*0.1,10650*0.1,10651*0.1,10652*0.1,10653*0.01,10679,10680,10681,10683,10684,10685,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10785,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,11257,11258*0.5,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11309,11316*0.3,11320*999999999,11323*99999999,11327,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +68,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10290*0.1,10292,10293,10291*0.1,10310,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649*0.1,10650*0.1,10651*0.1,10652*0.1,10653*0.01,10659,10679,10680,10681,10683,10684,10685,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10786,10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,10814,10815,10841*99999999999999,10842*999999999999,11257,11258*0.5,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11316*0.3,11320*999999999,11323*99999999,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +69,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*0.1,10281,10290*0.1,10292,10293,10291*0.1,10308,10312,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10461*0.1,10462*0.1,10649*0.1,10650*0.1,10651*0.1,10652*0.1,10653*0.01,10679,10680,10681,10683,10684,10685,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257,11258*0.5,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11297*9,11298,11300,11301,11302,11303,11304,11306*0.01,11309,11316*0.3,11320*999999999,11324*9999999,11328,11329*0.1,11330,11331*0.1,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +70,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*0.1,10280,10281,10290*0.1,10292,10293,10291*0.1,10307*999,10310,10312,10316*15,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649*0.1,10650*0.1,10651*0.1,10652*0.1,10653*0.01,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11299*999999,11312*0.1,11315*999999,11320*999999999,11324*9999999,11328,11329*0.1,11330,11332,11333,11334,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +71,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281,10290*0.1,10291*0.1,10310,10312,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649,10650,10651,10652,10653*0.01,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11220,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11306*0.01,11309,11313,11314*0.01,11316*0.3,11320*999999999,11321*99999999,11324*9999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +72,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*3,10290*0.1,10291*0.1,10310,10312,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10461*0.1,10462*0.1,10649,10650,10651,10652,10653*0.1,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11220,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11313,11314*0.01,11316*0.3,11320*999999999,11321*99999999,11324*9999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +73,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*3,10290*0.1,10291*0.1,10312,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649,10650,10651,10652,10653*0.01,10656*0.01,10657*0.01,10659,10679,10680,10681,10683,10684,10685,10686,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11220*5,11289*99999999,11290*99999999,11291*99999999,11295*0.07,11313,11314*0.01,11316*0.3,11320*999999999,11321*99999999,11324*9999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +74,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*3,10290*0.1,10292,10293,10291*0.1,10310,10312,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649,10650,10651,10652,10653*0.01,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11220*5,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11309,11312*0.1,11316*0.3,11317,11320*999999999,11323*99999999,11324*99999999,11327,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +75,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*5,10290*0.1,10292,10293,10291,10310,10312,10313,10314,10316,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10649,10650,10651,10652,10653*0.01,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11257*3,11258,11220*5,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11306*0.01,11314*0.01,11317,11320*999999999,11322*99999999,11323*99999999,11324*99999999,11327,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +76,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*5,10290,10291,10310,10312,10313,10314,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*3,10653*0.01,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*5,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11306*0.01,11308,11313*0.5,11316*0.3,11320*999999999,11321*99999999,11322*99999999,11324*99999999,11327,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +77,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*9,10290,10291,10310,10313,10314,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*2,10653*0.01,10656*0.01,10657*0.01,10659,10679,10680,10681,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11306*0.01,11309,11314*0.01,11316*0.3,11320*999999999,11321*99999999,11322*99999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +78,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*15,10290,10291*5,10310,10313,10314,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*5,10653*0.1,10656*0.01,10657*0.01,10679,10680,10681,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11306*0.01,11309,11314*0.01,11316*0.3,11320*999999999,11321*99999999,11322*999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +79,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*50,10290,10291*5,10310,10313,10314,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460*5,10653*0.1,10656*0.01,10657*0.01,10659,10679,10680,10681,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11289*99999999,11290*99999999,11291*99999999,11295*0.1,11306*0.01,11308,11313*0.5,11316*0.3,11317,11321*99999999,11322*999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +80,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*50,10290,10291*5,10294,10313,10314,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10460,10653*0.1,10656*0.01,10657*0.01,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11295*0.1,11320*999999999,11322*999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +81,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*50,10290*3,10294,10313,10314,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653*0.1,10656*0.01,10657*0.01,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11295*0.1,11306*0.1,11307,11309,11313*0.5,11314*0.01,11316*0.3,11317,11320*999999999,11322*999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +82,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*100,10290*5,10294,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653*0.1,10656*0.01,10657*0.01,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11295*0.1,11308,11310*0.1,11316*0.3,11317,11320*999999999,11321*99999999,11322*9999999999,11323*99999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +83,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*500,10290*5,10291*10,10294,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653*0.1,10656*0.01,10657*0.01,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11295*0.1,11309,11310*0.1,11316*0.3,11317,11320*999999999,11322*9999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +84,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*500,10290,10291*50,10294,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.01,10657*0.01,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,10842*999999999999,11220*9,11295*0.1,11309,11310*0.1,11316*0.3,11317,11320*999999999,11322*9999999999,11324*99999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +85,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5,10280*5,10281*500,10290,10291*999,10294,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.01,10657*0.01,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,11220*9,11295*0.1,11307,11308,11310*0.1,11316*0.3,11320*999999999,11321*99999999,11322*9999999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,11414*0.05,11415*0.05,11416*0.05,11417*0.05,11418*0.05,11419*0.05,11420*0.05,11421*0.05,11422*0.05,11423*0.05,11424*0.05,11425*0.05,11426*0.05,11427*0.05,11428*0.05,11429*0.05,11430*0.05,11431*0.05,11432*0.05,11433*0.05,11434*0.05,11435*0.05,11436*0.05,11437*0.05,11438*0.05,11439*0.05,11440*0.05,11441*0.05,11442*0.05,11443*0.05,11444*0.05,11445*0.05,11446*0.05,11447*0.05,11448*0.05,11449*0.05,11450*0.05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +86,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*10,10280*10,10281*500,10290,10291*559,10294*3,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.1,10657*0.1,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,11220*9,11295*0.1,11307,11309*9,11310*0.5,11316*0.3,11320*999999999,11322*99999999999,11323*99999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +87,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*10,10280*10,10281*500,10290,10291*992,10294*3,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.1,10657*0.1,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,11220*9,11295*0.1,11306*0.1,11309*99,11310*0.5,11316*0.3,11320*999999999,11322*99999999999,11323*99999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +88,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*10,10280*10,10281*500,10290*3,10291*55599,10294*3,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.1,10657*0.1,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,11220*9,11295*0.1,11306*0.1,11309*999,11310*0.5,11316*0.3,11320*999999999,11322*99999999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +89,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*10,10280*10,10281*100,10290*3,10291*999999,10294*5,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.1,10657*0.1,10659,10688,10689,10690,10691,10692,10693,10694,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10715,10716*9999999999,10785,10786,10841*99999999999999,11220*9,11295*0.1,11306*0.1,11308,11310*0.5,11311,11320*999999999,11322*99999999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +90,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*500,10280*500,10281*100,10290*3,10294*5,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*0.1,10657*0.1,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,10841*99999999999999,11220*9,11295*0.1,11310,11320*999999999,11322*99999999999,11324*999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +91,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*500,10280*500,10281*1000,10290*5,10294*5,10313,10315,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656,10657,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11307,11310,11316*0.3,11320*999999999,11321*99999999,11322*99999999999,11324*9999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +92,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*5000,10280*5000,10281*5000,10290*100,10294*10,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656,10657,10659,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11310,11316*0.3,11320*999999999,11322*99999999999,11324*9999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +93,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*50000,10280*50000,10281*5000,10290*1000,10294*50,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656,10657,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11310*9,11311,11316*0.3,11320*999999999,11322*99999999999,11324*999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +94,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*99999,10280*99999,10281*9999,10290*100000,10294*500,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656,10657,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11310*9,11311,11316*0.3,11320*999999999,11322*99999999999,11324*999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +95,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279*99999999,10280*99999999,10281*999999,10290*100000,10294*52554,10313,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*10,10657*10,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11310*9,11311,11316*0.3,11320*999999999,11322*99999999999,11324*999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +96,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*9999999,10290*99999,10294*99999,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*10,10657*10,10659,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11306*0.1,11310*999,11316*0.3,11320*999999999,11322*99999999999,11324*999999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +97,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281*999999999,10290*99999,10294*999999,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*100,10657*100,10695*0.1,10696*0.1,10697*0.1,10698*0.1,10699*0.1,10700*0.1,10701*0.1,10702*0.1,10703*0.1,10704*0.1,10705*0.1,10706*0.1,10707*0.1,10708*0.1,10709*0.1,10710*0.1,10711*0.1,10712*0.1,10713*0.1,10714*0.1,11220*9,11295*0.1,11306*0.1,11307,11310*999,11316*0.3,11320*999999999,11322*99999999999,11324*999999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +98,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281,10290*99999,10294*9999999,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424*0.1,10425*0.01,10430,10431,10432,10433,10434,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10459,10653,10656*108899,10657*108899,10770*0.1,10771*0.1,10772*0.1,10773*0.1,10774*0.1,10775*0.1,10776*0.1,10777*0.1,10778*0.1,10779*0.1,10780*0.1,10781*0.1,10782*0.1,10783*0.1,10784*0.1,11220*9,11295*0.1,11310*99999999999,11311,11316*0.3,11320*999999999,11324*999999999999999,11329*0.1,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +99,10069*0.03,10070*0.03,10071*0.03,10273,10274,10275,10276,10277,10278,10279,10280,10281,10290*99999999,10656*9999999999,10657*9999999999,11220*9,11310*99999999999,11316*0.3,11324*999999999999999999,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +100,10323,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +101,10324,10325,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +102,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +103,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10787*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +104,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +105,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +106,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +107,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +108,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +109,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10496*0.02,10787*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +110,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +111,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +112,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +113,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +114,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +115,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +116,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +117,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +118,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +119,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +120,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +121,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +122,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +123,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +124,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +125,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +126,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +127,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +128,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +129,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +130,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +131,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +132,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +133,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +134,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +135,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +136,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +137,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +138,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +139,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +140,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +141,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +142,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +143,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +144,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +145,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +146,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +147,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +148,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +149,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +150,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +151,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +152,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +153,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +154,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +155,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +156,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +157,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +158,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +159,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +160,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +161,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +162,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +163,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +164,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +165,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +166,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +167,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +168,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +169,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +170,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +171,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +172,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +173,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +174,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +175,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +176,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +177,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +178,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +179,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10816*0.01,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +180,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +181,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +182,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +183,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +184,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +185,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +186,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +187,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +188,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +189,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +190,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +191,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +192,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +193,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +194,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +195,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +196,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +197,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +198,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +199,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,10334*0.01,10335*0.01,10495*0.01,10361,10337,10338,10339,10340,10341,10342,10343,10344,10345,10361,10787*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +200,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346*999999,10349*0.01,10350*0.02,10351*0.1,10361,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +201,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +202,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.002,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +203,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.003,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +204,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.004,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +205,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.005,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +206,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.006,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +207,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.007,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +208,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.008,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +209,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.009,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +210,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.010,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +211,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.011,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +212,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.012,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +213,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.013,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +214,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.014,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +215,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.015,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +216,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.016,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +217,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.017,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +218,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.018,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +219,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.019,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +220,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.020,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +221,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.021,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +222,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.022,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +223,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.023,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +224,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.024,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +225,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.025,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +226,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.026,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +227,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.027,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +228,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.028,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +229,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.029,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +230,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.030,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +231,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.031,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +232,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.032,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +233,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.033,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +234,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.034,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +235,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.035,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +236,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.036,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +237,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.037,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +238,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.038,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +239,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.039,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +240,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.040,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +241,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.041,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +242,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.042,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +243,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.043,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +244,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.044,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +245,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.045,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +246,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.046,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +247,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.047,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +248,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.048,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +249,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.049,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +250,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10817*0.10,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +251,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +252,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +253,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +254,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +255,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +256,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +257,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +258,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +259,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +260,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +261,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +262,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +263,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +264,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +265,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +266,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +267,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +268,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +269,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +270,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +271,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +272,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +273,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +274,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +275,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +276,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +277,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +278,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +279,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +280,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +281,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +282,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +283,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10361,10362,10789*0.005,10818*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,11349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +284,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +285,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +286,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +287,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +288,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +289,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +290,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +291,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +292,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +293,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +294,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +295,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10789*0.005,10818*0.01,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +296,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10821*0.001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +297,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10821*0.001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +298,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10821*0.001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +299,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,10346,10349*0.01,10350*0.02,10351*0.1,10348,10352,10353,10361,10362,10821*0.001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +300,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +301,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.001,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +302,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.002,10821*0.002,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +303,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.003,10821*0.003,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +304,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.004,10821*0.004,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +305,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.005,10821*0.005,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +306,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.006,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +307,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.007,10821*0.002,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +308,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.008,10821*0.003,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +309,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.009,10821*0.004,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +310,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.010,10821*0.005,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +311,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.011,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +312,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.012,10821*0.002,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +313,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.013,10821*0.003,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +314,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.014,10821*0.004,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +315,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.015,10821*0.005,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +316,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.016,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +317,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.017,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +318,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.018,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +319,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.019,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +320,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.020,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +321,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.021,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +322,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.022,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +323,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.023,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +324,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.024,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +325,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.025,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +326,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.026,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +327,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.027,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +328,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.028,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +329,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.029,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +330,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.030,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +331,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.031,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +332,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.032,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +333,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.033,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +334,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.034,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +335,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.035,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +336,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.036,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +337,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.037,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +338,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.038,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +339,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.039,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +340,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.040,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +341,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.041,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +342,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.042,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +343,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.043,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +344,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.044,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +345,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.045,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +346,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.046,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +347,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.047,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +348,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.048,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +349,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.049,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +350,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.10,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +351,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.11,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +352,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.12,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +353,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.13,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +354,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.14,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +355,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.15,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +356,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.16,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +357,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.17,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +358,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.18,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +359,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.19,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +360,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.060,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +361,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.061,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +362,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.062,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +363,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.063,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +364,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.064,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +365,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.065,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +366,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.066,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +367,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.067,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +368,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.068,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +369,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.069,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +370,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.070,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +371,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.071,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +372,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.072,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +373,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.073,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +374,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.074,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +375,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.075,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +376,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.076,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +377,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.077,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +378,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.078,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +379,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.079,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +380,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.080,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +381,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.081,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +382,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.082,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +383,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.083,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +384,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.084,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +385,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.085,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +386,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.086,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +387,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.087,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +388,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.088,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +389,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.089,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +390,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.090,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +391,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.091,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +392,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.092,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +393,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.093,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +394,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.094,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +395,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.095,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +396,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.096,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +397,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.097,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +398,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.098,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +399,10347*999999,10348,10352,10353,10354,10355,10356,10357,10358,10359*0.01,10363*0.01,10364*0.1,10366*0.01,10365,10369,10370,10371,10372,10373,10374,10375,10376,10367,10362,10819*0.099,10821*0.001,11335*0.1,11336*0.1,11337*0.1,11338*0.1,11339*0.1,11340*0.1,11341*0.1,11342*0.1,11343*0.1,11344*0.1,11345*0.1,11346*0.1,11347*0.01,11348*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +400,10368*99999,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +401,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +402,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +403,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +404,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +405,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +406,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +407,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +408,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +409,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +410,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +411,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +412,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +413,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +414,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +415,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +416,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +417,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +418,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +419,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +420,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +421,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +422,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +423,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +424,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +425,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +426,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +427,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +428,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +429,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +430,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +431,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +432,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +433,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +434,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +435,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +436,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +437,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +438,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +439,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +440,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +441,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +442,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +443,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +444,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +445,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +446,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +447,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +448,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +449,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +450,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10819*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +451,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +452,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +453,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +454,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +455,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +456,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +457,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +458,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +459,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +460,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +461,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +462,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +463,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +464,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +465,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +466,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +467,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +468,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +469,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +470,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +471,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +472,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +473,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +474,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +475,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +476,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +477,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +478,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +479,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +480,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +481,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +482,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +483,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +484,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +485,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +486,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +487,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +488,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +489,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +490,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +491,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +492,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +493,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +494,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +495,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +496,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +497,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +498,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +499,10369,10370,10371,10372,10373,10374,10375,10376,10367,10377,10380*0.01,10381*0.01,10382*0.01,10383*0.01,10384*0.01,10385*0.01,10386*0.001,10387*0.001,10388*0.001,10389*0.001,10390*0.001,10820*0.01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +500,10379,10391,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +501,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/games/lifeRestart/data/age.json b/games/lifeRestart/data/age.json new file mode 100644 index 0000000..8de2001 --- /dev/null +++ b/games/lifeRestart/data/age.json @@ -0,0 +1,34820 @@ +{ + "0": { + "age": 0, + "event": [ + "10001*110", + "10002*100", + 10110, + 10111, + "10494*999999" + ] + }, + "1": { + "age": "1", + "event": [ + "10009*10", + "10010*10", + 10011 + ] + }, + "2": { + "age": "2", + "event": [ + 10003, + 10007, + 10012, + 10014, + 10015, + 10016, + 10017, + 10018, + 10020, + 10019, + 10026, + 10027, + 10053, + 10059, + 10060, + 10063, + 10065, + "10069*0.03", + 10072, + 10089, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10150, + 10163, + 10164, + 10165, + 10166, + "10498*2", + "10499*2", + "10500*2", + "10501*2", + "10502*3", + "10503*3", + "10825", + "10826", + "10827", + "10828", + "10829", + "10839", + "10840", + "10843" + ] + }, + "3": { + "age": "3", + "event": [ + 10005, + 10007, + 10012, + 10014, + 10015, + 10016, + 10017, + 10018, + 10020, + 10021, + 10019, + 10022, + 10023, + 10026, + 10027, + 10029, + 10039, + 10043, + 10048, + 10050, + 10052, + 10053, + 10059, + 10060, + 10064, + "10069*0.03", + 10072, + 10075, + 10078, + 10089, + 10092, + 10093, + "10142*0.2", + 10150, + 10152, + 10163, + 10164, + 10165, + 10166, + "10504*999999", + "10501", + "10502", + "10503", + "10500", + "10499", + "10498", + "10505*999999", + "10822*99999999999", + "10823*99999", + "10824*99999" + ] + }, + "4": { + "age": "4", + "event": [ + 10007, + 10012, + 10014, + 10018, + 10021, + 10022, + 10023, + 10024, + 10026, + 10030, + 10031, + 10034, + 10035, + 10036, + 10037, + 10039, + 10041, + 10043, + 10048, + 10050, + 10053, + 10054, + 10058, + 10065, + "10069*0.03", + 10075, + 10076, + 10077, + 10078, + 10089, + 10092, + 10093, + 10099, + 10100, + 10123, + 10124, + 10125, + 10126, + 10127, + 10128, + 10130, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10144, + 10047, + 10048, + 10150, + 10152, + 10153, + 10163, + 10164, + 10165, + 10166, + 10168, + 10177, + 10178, + "10035", + "10506", + "10507", + "10508", + "10509", + "10510", + "10511", + "10512", + "10513", + "10514", + "10515", + "10516", + "10517", + "10785", + "10844*0.1", + "10845", + "10846", + "10847", + "10848", + "10849", + "10850", + "10851", + "10852", + "10853", + "10854", + "10855", + "10856", + "10857", + "10858", + "10859", + "10860", + "10861", + "10862", + "10863", + "10864", + "10865", + "10866", + "10867", + "10868*0.01", + "10869*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "5": { + "age": "5", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10024, + 10026, + 10031, + 10034, + 10035, + 10036, + 10037, + 10039, + 10041, + 10043, + 10044, + 10047, + 10048, + 10049, + 10050, + 10051, + 10052, + 10053, + 10058, + 10059, + 10060, + 10061, + 10066, + "10069*0.03", + 10076, + 10077, + 10078, + 10089, + 10092, + 10093, + 10094, + 10099, + 10100, + 10123, + 10124, + 10125, + 10126, + "10127*2", + "10128*2", + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10144, + 10047, + 10048, + 10150, + 10153, + 10163, + 10164, + 10165, + 10166, + 10168, + 10172, + 10177, + 10178, + 10182, + "10035", + "10506", + "10507", + "10508", + "10509", + "10510", + "10511", + "10512", + "10513", + "10514", + "10515", + "10516", + "10517", + "10844*0.1", + "10845", + "10846", + "10847", + "10848", + "10849", + "10850", + "10851", + "10852", + "10853", + "10854", + "10855", + "10856", + "10857", + "10858", + "10859", + "10860", + "10861", + "10862", + "10863", + "10864", + "10865", + "10866", + "10867", + "10868*0.01", + "10869*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "6": { + "age": "6", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10036, + 10037, + 10043, + 10044, + 10045, + 10047, + 10048, + 10049, + 10050, + 10052, + 10054, + 10057, + 10058, + 10061, + 10065, + 10067, + 10069, + 10072, + 10073, + 10075, + 10076, + 10077, + 10078, + 10089, + 10091, + 10093, + 10094, + 10095, + 10096, + 10098, + 10099, + 10100, + "10101*100", + 10123, + 10124, + "10125*0.1", + "10126*0.1", + 10127, + 10128, + 10130, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10144, + 10145, + 10146, + 10147, + 10148, + 10150, + 10153, + 10166, + 10168, + 10169, + 10172, + 10178, + 10179, + 10183, + 10224, + "10035", + "20036*3", + "10518*9999999999", + "10785", + "10870*99999999999", + "10871*99999999999", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "7": { + "age": "7", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10036, + 10037, + 10038, + 10041, + 10044, + 10047, + 10049, + 10051, + 10052, + 10057, + 10058, + 10059, + 10060, + 10061, + 10066, + 10067, + 10069, + 10073, + 10076, + 10077, + 10078, + 10079, + 10089, + 10093, + 10094, + 10096, + 10097, + 10098, + "10101*100", + 10102, + 10103, + 10104, + 10105, + 10106, + 10107, + 10108, + 10109, + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + "10127*0.1", + "10128*0.1", + 10129, + 10131, + 10132, + 10133, + 10134, + 10138, + 10139, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10145, + 10146, + 10147, + 10148, + 10149, + 10151, + 10153, + 10166, + 10168, + 10169, + 10171, + 10179, + 10183, + "20036", + "10519", + "10520", + "10521", + "10522", + "10523", + "10524", + "10525", + "10526", + "10527", + "10528", + "10529", + "10530", + "10531", + "10532", + "10533", + "10535", + "10536", + "10537", + "10538", + "10539", + "10576*0.01", + "10577", + "10872", + "10873", + "10874", + "10875", + "10876", + "10877", + "10878", + "10879", + "10880", + "10881", + "10901", + "10883", + "10884", + "10885", + "10886", + "10887", + "10888", + "10889", + "10890", + "10891", + "10892", + "10893", + "10894", + "10895", + "10896", + "10897", + "10898", + "10899", + "10902", + "10903", + "10904", + "10905", + "10906", + "10907", + "10908", + "10909", + "10910", + "10911", + "10912", + "10913", + "10914", + "10915", + "10916", + "10917", + "10918", + "10919", + "10920", + "10921", + "10922", + "10923", + "10924", + "10925", + "10926", + "10927", + "10928", + "10929", + "10930", + "10931", + "10932", + "10933", + "10934", + "10935", + "10936", + "10937", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "8": { + "age": "8", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10036, + 10037, + 10038, + 10045, + 10051, + 10057, + 10061, + 10065, + 10067, + 10069, + 10073, + 10075, + 10076, + 10077, + 10078, + "10079*3", + 10089, + 10094, + 10095, + 10097, + 10098, + "10101*9999", + 10102, + 10103, + 10104, + 10105, + 10106, + 10107, + 10108, + 10109, + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + "10127*0.1", + "10128*0.1", + 10129, + 10130, + 10131, + 10132, + 10133, + 10134, + 10138, + 10139, + "10142*0.2", + 10143, + 10145, + 10146, + 10147, + 10148, + 10149, + 10151, + 10153, + 10166, + "10167*5", + 10169, + 10170, + 10173, + 10174, + 10176, + 10177, + 10179, + "20036", + "10519", + "10520", + "10521", + "10522", + "10523", + "10524", + "10525", + "10526", + "10527", + "10528", + "10529", + "10530", + "10531", + "10532", + "10533", + "10535", + "10536", + "10537", + "10538", + "10539", + "10576*0.01", + "10577", + "10592", + "10786", + "10844*0.1", + "10872", + "10873", + "10874", + "10875", + "10876", + "10877", + "10878", + "10879", + "10880", + "10881", + "10901", + "10883", + "10884", + "10885", + "10886", + "10887", + "10888", + "10889", + "10890", + "10891", + "10892", + "10893", + "10894", + "10895", + "10896", + "10897", + "10898", + "10899", + "10902", + "10903", + "10904", + "10905", + "10906", + "10907", + "10908", + "10909", + "10910", + "10911", + "10912", + "10913", + "10914", + "10915", + "10916", + "10917", + "10918", + "10919", + "10920", + "10921", + "10922", + "10923", + "10924", + "10925", + "10926", + "10927", + "10928", + "10929", + "10930", + "10931", + "10932", + "10933", + "10934", + "10935", + "10936", + "10937", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "9": { + "age": "9", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10024, + 10041, + 10044, + 10051, + 10052, + 10061, + 10066, + 10067, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10076, + 10077, + 10078, + "10079*5", + 10089, + 10091, + 10098, + 10102, + 10103, + 10104, + 10105, + 10106, + 10107, + 10108, + 10109, + 10112, + 10113, + 10114, + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + 10127, + 10128, + 10129, + 10130, + 10131, + 10132, + 10133, + 10134, + 10135, + 10138, + 10139, + "10142*0.2", + 10143, + 10145, + 10146, + 10147, + 10148, + 10149, + 10151, + 10163, + 10164, + 10165, + "10167*5", + 10169, + 10170, + 10172, + 10175, + 10176, + 10177, + 10179, + 10180, + "20036", + "10519", + "10520", + "10521", + "10522", + "10523", + "10524", + "10525", + "10526", + "10527", + "10528", + "10529", + "10530", + "10531", + "10532", + "10533", + "10535", + "10536", + "10537", + "10538", + "10539", + "10576*0.01", + "10577*2", + "10844*0.1", + "10872", + "10873", + "10874", + "10875", + "10876", + "10877", + "10878", + "10879", + "10880", + "10881", + "10901", + "10883", + "10884", + "10885", + "10886", + "10887", + "10888", + "10889", + "10890", + "10891", + "10892", + "10893", + "10894", + "10895", + "10896", + "10897", + "10898", + "10899", + "10902", + "10903", + "10904", + "10905", + "10906", + "10907", + "10908", + "10909", + "10910", + "10911", + "10912", + "10913", + "10914", + "10915", + "10916", + "10917", + "10918", + "10919", + "10920", + "10921", + "10922", + "10923", + "10924", + "10925", + "10926", + "10927", + "10928", + "10929", + "10930", + "10931", + "10932", + "10933", + "10934", + "10935", + "10936", + "10937", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11261", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "10": { + "age": "10", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + 10024, + 10045, + 10047, + 10054, + 10061, + 10066, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10076, + 10077, + 10078, + "10079*5", + "10080*3", + 10089, + "10090*0.5", + 10103, + 10104, + 10105, + 10106, + 10107, + 10108, + 10109, + 10112, + 10113, + 10114, + 10115, + "10116*3", + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + "10127*0.1", + "10128*0.1", + 10129, + 10131, + 10132, + 10133, + 10134, + 10135, + 10138, + 10139, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10145, + 10146, + 10147, + 10148, + 10152, + 10154, + "10167*4", + 10169, + 10170, + 10172, + 10176, + 10179, + 10180, + 10309, + "20036", + "10519", + "10520", + "10521", + "10522", + "10523", + "10524", + "10525", + "10526", + "10527", + "10528", + "10529", + "10530", + "10531", + "10532", + "10533", + "10534", + "10535", + "10536", + "10537", + "10538", + "10539", + "10540*2", + "10576*0.01", + "10577*2", + "10588*9999999999999999", + "10592", + "10844*0.1", + "10872", + "10873", + "10874", + "10875", + "10876", + "10877", + "10878", + "10879", + "10880", + "10881", + "10901", + "10883", + "10884", + "10885", + "10886", + "10887", + "10888", + "10889", + "10890", + "10891", + "10892", + "10893", + "10894", + "10895", + "10896", + "10897", + "10898", + "10899", + "10902", + "10903", + "10904", + "10905", + "10906", + "10907", + "10908", + "10909", + "10910", + "10911", + "10912", + "10913", + "10914", + "10915", + "10916", + "10917", + "10918", + "10919", + "10920", + "10921", + "10922", + "10923", + "10924", + "10925", + "10926", + "10927", + "10928", + "10929", + "10930", + "10931", + "10932", + "10933", + "10934", + "10935", + "10936", + "10937", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11261", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1" + ] + }, + "11": { + "age": "11", + "event": [ + 10007, + 10012, + 10014, + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10072, + "10079*3", + "10080*3", + 10089, + 10095, + 10096, + 10099, + 10104, + 10105, + 10106, + 10107, + 10108, + 10109, + 10112, + 10113, + 10114, + 10115, + "10116*3", + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + 10127, + 10128, + 10129, + 10131, + 10132, + 10133, + 10134, + 10135, + 10136, + 10137, + 10138, + 10139, + "10140*0.1", + "10141*0.1", + "10142*0.2", + 10143, + 10144, + 10145, + 10146, + 10147, + 10148, + 10149, + 10151, + 10152, + 10154, + "10167*3", + 10169, + 10170, + 10171, + 10172, + 10176, + 10180, + 10311, + 10463, + "20036", + "20054", + "10519", + "10520", + "10521", + "10522", + "10523", + "10524", + "10525", + "10526", + "10527", + "10528", + "10529", + "10530", + "10531", + "10532", + "10533", + "10534*2", + "10535", + "10536", + "10537", + "10538", + "10539", + "10540", + "10576*0.01", + "10577", + "10592", + "10786", + "10872", + "10873", + "10874", + "10875", + "10876", + "10877", + "10878", + "10879", + "10880", + "10881", + "10901", + "10883", + "10884", + "10885", + "10886", + "10887", + "10888", + "10889", + "10890", + "10891", + "10892", + "10893", + "10894", + "10895", + "10896", + "10897", + "10898", + "10899", + "10902", + "10903", + "10904", + "10905", + "10906", + "10907", + "10908", + "10909", + "10910", + "10911", + "10912", + "10913", + "10914", + "10915", + "10916", + "10917", + "10918", + "10919", + "10920", + "10921", + "10922", + "10923", + "10924", + "10925", + "10926", + "10927", + "10928", + "10929", + "10930", + "10931", + "10932", + "10933", + "10934", + "10935", + "10936", + "10937", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11261", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "10008*0.1", + "11468*0.1" + ] + }, + "12": { + "age": "12", + "event": [ + 10007, + "10008*0.1", + 10012, + 10014, + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10079*5", + "10080*3", + 10089, + 10096, + 10097, + 10108, + 10109, + 10112, + 10113, + 10114, + 10115, + "10116*3", + 10117, + 10118, + 10119, + 10120, + 10121, + 10122, + 10123, + 10124, + "10125*0.1", + "10126*0.1", + 10127, + 10128, + 10129, + 10130, + 10131, + 10132, + 10133, + 10134, + 10135, + 10138, + 10139, + "10142*0.2", + 10143, + 10145, + 10146, + 10147, + 10148, + 10150, + 10149, + 10151, + 10154, + "10155*3", + 10156, + "10157*50", + 10160, + "10167*2", + 10169, + 10171, + 10172, + 10176, + 10180, + 10182, + 10214, + 10311, + "20036*3", + "20054*2", + "10541*9999999999", + "10542*9999999999", + "10938*999999999999", + "10939*999999999999", + "10940*999999999", + "10941*999999999", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11451*9999999999999999" + ] + }, + "13": { + "age": "13", + "event": [ + 10007, + "10008*0.1", + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10080, + 10089, + 10097, + "10155*3", + 10156, + "10157*200", + 10158, + "10159*0.01", + 10160, + 10161, + "10162*0.1", + 10163, + 10164, + 10165, + 10169, + 10171, + 10180, + 10181, + 10182, + 10183, + "10184*10", + "10185*10", + 10189, + 10201, + 10211, + 10212, + 10213, + 10214, + 10215, + 10216, + 10224, + 10225, + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10309, + 10311, + "20054*3", + "10543*5", + "10544*5", + "10545", + "10546", + "10547", + "10548", + "10549", + "10550", + "10551", + "10552", + "10553", + "10554", + "10555", + "10556", + "10557", + "10558", + "10559", + "10560", + "10561", + "10562", + "10563", + "10564", + "10565", + "10566", + "10567", + "10568", + "10569", + "10570", + "10571", + "10572", + "10573", + "10574", + "10575", + "10592", + "10942*10", + "10947*999999", + "10948*99999999", + "10958*999999", + "10967", + "10968", + "10969", + "10970", + "10971*0.1*0.1", + "10972*0.1", + "10973*0.1", + "10974", + "10975", + "10976", + "10977", + "10978", + "10979", + "10980", + "10981", + "10982", + "10983", + "10984", + "10985", + "10986", + "10987", + "10988", + "10989", + "10990", + "10991", + "10992", + "10993*0.1", + "10994*0.1", + "10995*0.1", + "10996*0.1", + "10997*0.1", + "10998*0.1", + "10999*0.1", + "11000*0.1", + "11001*0.1", + "11002*0.1", + "11003*0.1", + "11004*0.1", + "11005*0.1", + "11006*0.1", + "11007*0.1", + "11008*0.1", + "11009", + "11010", + "11011", + "11012", + "11013", + "11014", + "11015*0.2", + "11016*0.2", + "11017*0.2", + "11018*0.2", + "11019*0.2", + "11020*0.2", + "11021", + "11022", + "11023", + "11024", + "11025", + "11026", + "11027", + "11028", + "11029*0.2", + "11030*0.2", + "11031*0.2", + "11032*0.2", + "11033*0.2", + "11034*0.2", + "11035", + "11036", + "11037", + "11038", + "11039", + "11040", + "11041", + "11042", + "11043", + "11044", + "11045", + "11046", + "11047", + "11048", + "11049", + "11050", + "11051", + "11052", + "11053", + "11054", + "11055", + "11056", + "11057", + "21045*5", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11219*0.01", + "11261", + "11262", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333" + ] + }, + "14": { + "age": "14", + "event": [ + 10007, + "10008*0.1", + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10080*2", + "10081*3", + 10089, + "10155*3", + 10156, + "10157*9999", + 10158, + "10159*0.1", + 10160, + 10161, + "10162*0.1", + 10085, + 10163, + 10164, + 10165, + 10169, + 10171, + 10180, + 10181, + 10182, + 10183, + "10186*5", + 10187, + 10188, + 10189, + 10201, + "10202*10", + "10211*5", + "10212*5", + 10214, + 10215, + 10216, + 10224, + 10225, + 10227, + "10253*0.1", + "10257*0.1", + 10309, + 10311, + "20054", + "20055", + "10545", + "10546", + "10547", + "10548", + "10549", + "10550", + "10551", + "10552", + "10553", + "10554", + "10555", + "10556", + "10557", + "10558", + "10559", + "10560", + "10561", + "10562", + "10563", + "10564", + "10565", + "10566", + "10567", + "10568", + "10569", + "10570", + "10571", + "10572", + "10573", + "10574", + "10575", + "10592", + "10785", + "10942*10", + "10947*999999", + "10949*999999", + "10950*999999", + "10959*999999", + "10967", + "10968", + "10969", + "10970", + "10971*0.1", + "10972*0.1", + "10973*0.1", + "10974", + "10975", + "10976", + "10977", + "10978", + "10979", + "10980", + "10981", + "10982", + "10983", + "10984", + "10985", + "10986", + "10987", + "10988", + "10989", + "10990", + "10991", + "10992", + "10993*0.1", + "10994*0.1", + "10995*0.1", + "10996*0.1", + "10997*0.1", + "10998*0.1", + "10999*0.1", + "11000*0.1", + "11001*0.1", + "11002*0.1", + "11003*0.1", + "11004*0.1", + "11005*0.1", + "11006*0.1", + "11007*0.1", + "11008*0.1", + "11009", + "11010", + "11011", + "11012", + "11013", + "11014", + "11015*0.2", + "11016*0.2", + "11017*0.2", + "11018*0.2", + "11019*0.2", + "11020*0.2", + "11021", + "11022", + "11023", + "11024", + "11025", + "11026", + "11027", + "11028", + "11029*0.2", + "11030*0.2", + "11031*0.2", + "11032*0.2", + "11033*0.2", + "11034*0.2", + "11035", + "11036", + "11037", + "11038", + "11039", + "11040", + "11041", + "11042", + "11043", + "11044", + "11045", + "11046", + "11047", + "11048", + "11049", + "11050", + "11051", + "11052", + "11053", + "11054", + "11055", + "11056", + "11057", + "21045*5", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11219*0.01", + "11261", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "15": { + "age": "15", + "event": [ + 10007, + "10008*0.1", + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10080*5", + "10081*3", + 10089, + 10158, + "10159*0.1", + 10161, + "10162*0.1", + 10085, + 10086, + 10163, + 10164, + 10165, + 10180, + 10181, + 10182, + 10183, + 10187, + 10188, + 10189, + "10194*5", + "10198*10000", + "10199*10000", + "10200*10000", + 10201, + "10203*99999", + 10211, + 10212, + 10213, + 10214, + 10215, + 10216, + 10224, + 10225, + 10226, + 10227, + "10254*0.1", + "10258", + 10309, + 10410, + 10411, + 10412, + "10468*3", + "20054*2", + "20055", + "10545", + "10546", + "10547", + "10548", + "10549", + "10550", + "10551", + "10552", + "10553", + "10554", + "10555", + "10556", + "10557", + "10558", + "10559", + "10560", + "10561", + "10562", + "10563", + "10564", + "10565", + "10566", + "10567", + "10568", + "10569", + "10570", + "10571", + "10572", + "10573", + "10574", + "10575", + "10786", + "10943*9999999", + "10951*999999", + "10960*999999", + "10961*999999", + "10967", + "10968", + "10969", + "10970", + "10971*0.1", + "10972*0.1", + "10973*0.1", + "10974", + "10975", + "10976", + "10977", + "10978", + "10979", + "10980", + "10981", + "10982", + "10983", + "10984", + "10985", + "10986", + "10987", + "10988", + "10989", + "10990", + "10991", + "10992", + "10993*0.1", + "10994*0.1", + "10995*0.1", + "10996*0.1", + "10997*0.1", + "10998*0.1", + "10999*0.1", + "11000*0.1", + "11001*0.1", + "11002*0.1", + "11003*0.1", + "11004*0.1", + "11005*0.1", + "11006*0.1", + "11007*0.1", + "11008*0.1", + "11009", + "11010", + "11011", + "11012", + "11013", + "11014", + "11015*0.2", + "11016*0.2", + "11017*0.2", + "11018*0.2", + "11019*0.2", + "11020*0.2", + "11021", + "11022", + "11023", + "11024", + "11025", + "11026", + "11027", + "11028", + "11029*0.2", + "11030*0.2", + "11031*0.2", + "11032*0.2", + "11033*0.2", + "11034*0.2", + "11035", + "11036", + "11037", + "11038", + "11039", + "11040", + "11041", + "11042", + "11043", + "11044", + "11045", + "11046", + "11047", + "11048", + "11049", + "11050", + "11051", + "11052", + "11053", + "11054", + "11055", + "11056", + "11057", + "11067*666666", + "21045*5", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11219*0.01", + "11261", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "10944*9999999", + "10945*9999999", + "10946*9999999" + ] + }, + "16": { + "age": "16", + "event": [ + 10007, + "10008*0.1", + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10080*3", + "10081*3", + 10089, + 10161, + "10162*0.1", + 10085, + 10086, + 10163, + 10164, + 10165, + 10180, + 10181, + 10183, + 10187, + 10188, + 10189, + "10190*10", + "10194*10", + "10198*10000", + "10199*10000", + "10200*10000", + 10201, + "10203*99999", + "10205*99999", + 10211, + 10212, + 10213, + 10214, + 10215, + 10216, + 10217, + "10218*2", + "10219*3", + 10224, + 10225, + "10226*3", + 10227, + "10258", + 10410, + 10411, + 10412, + "10259*999999", + "10468*3", + "20054*3", + "20055", + "10545", + "10546", + "10547", + "10548", + "10549", + "10550", + "10551", + "10552", + "10553", + "10554", + "10555", + "10556", + "10557", + "10558", + "10559", + "10560", + "10561", + "10562", + "10563", + "10564", + "10565", + "10566", + "10567", + "10568", + "10569", + "10570", + "10571", + "10572", + "10573", + "10574", + "10575", + "10952*999999", + "10953*999999", + "10954*999999999", + "10955*999999999", + "10962*999999", + "10963*999999", + "10964*999999", + "10965*999999", + "10967", + "10968", + "10969", + "10970", + "10971*0.1", + "10972*0.1", + "10973*0.1", + "10974", + "10975", + "10976", + "10977", + "10978", + "10979", + "10980", + "10981", + "10982", + "10983", + "10984", + "10985", + "10986", + "10987", + "10988", + "10989", + "10990", + "10991", + "10992", + "10993*0.1", + "10994*0.1", + "10995*0.1", + "10996*0.1", + "10997*0.1", + "10998*0.1", + "10999*0.1", + "11000*0.1", + "11001*0.1", + "11002*0.1", + "11003*0.1", + "11004*0.1", + "11005*0.1", + "11006*0.1", + "11007*0.1", + "11008*0.1", + "11009", + "11010", + "11011", + "11012", + "11013", + "11014", + "11015*0.2", + "11016*0.2", + "11017*0.2", + "11018*0.2", + "11019*0.2", + "11020*0.2", + "11021", + "11022", + "11023", + "11024", + "11025", + "11026", + "11027", + "11028", + "11029*0.2", + "11030*0.2", + "11031*0.2", + "11032*0.2", + "11033*0.2", + "11034*0.2", + "11035", + "11036", + "11037", + "11038", + "11039", + "11040", + "11041", + "11042", + "11043", + "11044", + "11045", + "11046", + "11047", + "11048", + "11049", + "11050", + "11051", + "11052", + "11053", + "11054", + "11055", + "11056", + "11057", + "11058", + "11059", + "11060", + "11061", + "11062", + "11063", + "11064", + "11065", + "11066", + "11068*999999", + "21045*5", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11262", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "17": { + "age": "17", + "event": [ + 10007, + "10008*0.1", + 10022, + 10023, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10080*3", + "10081*5", + 10089, + 10091, + 10085, + 10086, + 10163, + 10164, + 10165, + 10180, + 10181, + 10183, + 10188, + 10189, + "10190*10", + "10191*99999", + "10194*5", + 10201, + "10205*99999", + "10206*99999", + 10211, + 10212, + 10213, + 10214, + 10215, + 10216, + "10217*2", + "10218*3", + "10219*5", + "10220*5", + "10221*5", + "10223*10", + 10224, + 10225, + "10226*5", + "10230*9999999", + "10259*999999", + 10309, + 10410, + 10411, + 10412, + "10468*3", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "20055", + "10545", + "10546", + "10547", + "10548", + "10549", + "10550", + "10551", + "10552", + "10553", + "10554", + "10555", + "10556", + "10557", + "10558", + "10559", + "10560", + "10561", + "10562", + "10563", + "10564", + "10565", + "10566", + "10567", + "10568", + "10569", + "10570", + "10571", + "10572", + "10573", + "10574", + "10575", + "10578*9999999999", + "10956*999999", + "10957*999999", + "10962*999999", + "10963*999999", + "10964*999999", + "10965*999999", + "10967", + "10968", + "10969", + "10970", + "10971*0.1", + "10972*0.1", + "10973*0.1", + "10974", + "10975", + "10976", + "10977", + "10978", + "10979", + "10980", + "10981", + "10982", + "10983", + "10984", + "10985", + "10986", + "10987", + "10988", + "10989", + "10990", + "10991", + "10992", + "10993*0.1", + "10994*0.1", + "10995*0.1", + "10996*0.1", + "10997*0.1", + "10998*0.1", + "10999*0.1", + "11000*0.1", + "11001*0.1", + "11002*0.1", + "11003*0.1", + "11004*0.1", + "11005*0.1", + "11006*0.1", + "11007*0.1", + "11008*0.1", + "11009", + "11010", + "11011", + "11012", + "11013", + "11014", + "11015*0.2", + "11016*0.2", + "11017*0.2", + "11018*0.2", + "11019*0.2", + "11020*0.2", + "11021", + "11022", + "11023", + "11024", + "11025", + "11026", + "11027", + "11028", + "11029*0.2", + "11030*0.2", + "11031*0.2", + "11032*0.2", + "11033*0.2", + "11034*0.2", + "11035", + "11036", + "11037", + "11038", + "11039", + "11040", + "11041", + "11042", + "11043", + "11044", + "11045", + "11046", + "11047", + "11048", + "11049", + "11050", + "11051", + "11052", + "11053", + "11054", + "11055", + "11056", + "11057", + "11058", + "11059", + "11060", + "11061", + "11062", + "11063", + "11064", + "11065", + "11066", + "11068*999999", + "11078", + "11079", + "11080", + "11081", + "11082", + "11083", + "11084", + "11085", + "11086", + "21045*3", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.01", + "11214*0.01", + "11215*0.01", + "11216*0.01", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "18": { + "age": "18", + "event": [ + 10007, + "10008*0.1", + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + "10090*0.5", + 10086, + 10163, + 10164, + 10165, + 10180, + 10181, + 10183, + 10188, + 10189, + "10190*10", + "10191*99999", + "10192*99999", + "10194*3", + 10201, + "10206*99999", + 10215, + 10216, + 10217, + "10218*2", + "10219*3", + "10220*10", + "10221*9999999", + "10223*99999", + 10224, + "10226*10", + "10231*999999", + "10233*999999", + "10237*100", + "10238*100", + "10239*10", + 10247, + "10260*999999", + "10261*999999", + "10262*999999", + "10263*999999", + "10267*99999", + "10468*3", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "20055", + "10579*999999", + "10580*999999", + "10581*999999", + "10582*999999", + "10583*999999", + "10584*999999", + "10586*999999", + "10587*999999", + "20580*9999999", + "10966*999999999", + "11069*999999999", + "11070*999999999", + "11077*99999", + "11076*6666666", + "11075*9999999", + "11071*999999999999", + "11072*999999999999", + "11073*999999999999", + "11074*999999999999", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "11468*0.1" + ] + }, + "19": { + "age": "19", + "event": [ + 10007, + "10008*0.1", + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + 10085, + 10086, + 10189, + 10190, + "10191*99999", + "10195*1000", + "10196*4000", + "10197*1000", + "10206*99999", + "10220*15", + "10221*999999", + "10222*999999", + "10223*99999", + "10230*999999", + "10237*999999", + "10238*999999", + "10239*999999", + 10247, + "10249*999999", + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + "10260*999999", + "10261*999999", + "10262*999999", + "10263*999999", + "10267*99999", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "20055", + "10585", + "10593", + "10594", + "10595", + "10596", + "10597", + "10598", + "10599", + "10600", + "10601", + "10602", + "10603", + "10604", + "10605", + "10606*2", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "10785", + "11087", + "11088", + "11089", + "11090", + "11091", + "11092", + "11094", + "11095", + "11096", + "11097", + "11098", + "11099", + "11100", + "11101", + "11102", + "11103", + "11104", + "11105", + "11106", + "11107", + "11108", + "11109", + "11110", + "11111", + "11112", + "11113", + "11114", + "11115", + "11116", + "11117", + "11118", + "11119", + "11120", + "11121", + "11201", + "11202", + "11203", + "11204*0.05", + "11205", + "11206", + "11207", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.02", + "11214*0.02", + "11215*0.02", + "11216*0.02", + "11219*0.01", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11452*99999999999999999", + "11453*99999999999999999", + "11455*33333333333333333", + "11456*33333333333333333", + "11457*33333333333333333", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "11468*0.1" + ] + }, + "20": { + "age": "20", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + "10085*3", + 10086, + "10090*0.5", + 10189, + 10191, + "10192*99999", + "10195*1000", + "10196*4000", + "10197*1000", + "10207*99999", + 10206, + "10220*50", + "10221*999999", + "10222*999999", + "10223*99999", + "10231*999999", + "10233*999999", + 10240, + 10241, + 10242, + 10243, + 10244, + 10245, + 10246, + 10247, + "10249*999999", + "10260*999999", + "10261*999999", + "10262*999999", + "10263*999999", + "10267*99999", + "10268*2", + 10269, + 10270, + 10271, + 10410, + 10411, + 10412, + 10463, + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10585", + "10589*99999999999999", + "10593", + "10594", + "10595", + "10596", + "10597", + "10598", + "10599", + "10600", + "10601", + "10602", + "10603", + "10604", + "10605", + "10606*4", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11087", + "11088", + "11089", + "11090", + "11091", + "11092", + "11094", + "11095", + "11096", + "11097", + "11098", + "11099", + "11100", + "11101", + "11102", + "11103", + "11104", + "11105", + "11106", + "11107", + "11108", + "11109", + "11110", + "11111", + "11112", + "11113", + "11114", + "11115", + "11116", + "11117", + "11118", + "11119", + "11120", + "11121", + "11201", + "11202", + "11203", + "11204*0.05", + "11205", + "11206", + "11207", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.02", + "11214*0.02", + "11215*0.02", + "11216*0.02", + "11262", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11454*99999999999999999", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "21": { + "age": "21", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + "10085*5", + 10086, + 10189, + "10192*99999", + "10195*1000", + "10196*4000", + "10197*1000", + "10206*99999", + "10222*99999", + "10223*99999", + 10240, + 10241, + 10242, + 10243, + 10244, + 10245, + 10246, + 10247, + "10249*999999", + "10260*999999", + "10261*999999", + "10262*999999", + "10263*999999", + "10267*99999", + 10273, + 10274, + 10275, + 10276, + 10430, + 10431, + 10432, + 10433, + 10434, + 10435, + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "20055", + "10585", + "10593", + "10594", + "10595", + "10596", + "10597", + "10598", + "10599", + "10600", + "10601", + "10602", + "10603", + "10604", + "10605", + "10606*5", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "10785", + "10786", + "11087", + "11088", + "11089", + "11090", + "11091", + "11092", + "11094", + "11095", + "11096", + "11097", + "11098", + "11099", + "11100", + "11101", + "11102", + "11103", + "11104", + "11105", + "11106", + "11107", + "11108", + "11109", + "11110", + "11111", + "11112", + "11113", + "11114", + "11115", + "11116", + "11117", + "11118", + "11119", + "11120", + "11121", + "11201", + "11202", + "11203", + "11204*0.05", + "11205", + "11206", + "11207", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.05", + "11214*0.05", + "11215*0.05", + "11216*0.05", + "11219*0.01", + "11262", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "11468*0.1" + ] + }, + "22": { + "age": "22", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + "10085*10", + 10086, + 10189, + "10195*1000", + "10196*2000", + "10197*5000", + "10206*99999", + "10228*999999", + 10240, + 10241, + 10242, + 10243, + 10244, + 10245, + 10246, + "10249*999999", + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + "10264*9999999", + "10268*2", + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10410, + 10411, + 10430, + 10431, + 10432, + 10433, + 10434, + 10435, + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10585", + "10593", + "10594", + "10595", + "10596", + "10597", + "10598", + "10599", + "10600", + "10601", + "10602", + "10603", + "10604", + "10605", + "10606*2", + "10608*999999999", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11087", + "11088", + "11089", + "11090", + "11091", + "11092", + "11122*999999999", + "11123*999999999", + "11124*999999999", + "11125*999999999", + "11221", + "11222", + "11223", + "11224", + "11225", + "11226", + "11227", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "23": { + "age": "23", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10081, + 10083, + "10085*50", + 10086, + 10189, + "10197*99999", + "10206*99999", + "10229*999999", + "10249*999999", + 10253, + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10266, + 10273, + 10274, + 10275, + 10276, + 10410, + 10411, + 10430, + 10431, + 10432, + 10433, + 10434, + 10435, + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "20055", + "10593", + "10594", + "10595", + "10596", + "10597", + "10598", + "10599", + "10600", + "10601", + "10602", + "10603", + "10604", + "10605", + "10606*2", + "10613*9", + "10614*5", + "10615*5", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11093*999999999", + "11126*999999999", + "11127*999999999", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11152*10", + "11153*10", + "11154*10", + "11172*10", + "11174*5", + "11175*5", + "11176*5", + "11177*5", + "11178*5", + "11221", + "11222", + "11223", + "11224", + "11225", + "11226", + "11227", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001" + ] + }, + "24": { + "age": "24", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10083, + "10085*500", + 10086, + 10087, + 10189, + "10207*99999", + "10234*999999", + "10250*999999", + "10251*999999", + "10253*0.1", + 10266, + "10268*2", + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10284, + 10285, + 10288, + 10410, + 10411, + 10430, + 10431, + 10432, + 10433, + 10434, + 10435, + "10468*3", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10474*9", + "10475*3", + "10476*3", + "10477*3", + "10607*9999999", + "10609*9999999", + "10613*99", + "10614*5", + "10615*5", + "10618", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "10785", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11123*999999", + "11155*999999", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11173", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.05", + "11214*0.05", + "11215*0.05", + "11216*0.05", + "11219*0.01", + "11221", + "11222", + "11223", + "11224", + "11225", + "11226", + "11227", + "11240", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "11468*0.1" + ] + }, + "25": { + "age": "25", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10083, + "10085*9999", + 10086, + 10087, + 10088, + 10189, + "10210*99999", + 10252, + "10257*0.1", + 10266, + 10268, + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10284, + 10285, + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + 10430, + 10431, + 10432, + 10433, + 10434, + 10435, + "10468*3", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10474*99", + "10475*3", + "10476*3", + "10477*3", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10591", + "10610*2", + "10615", + "10617", + "10618", + "10660", + "10661", + "10662", + "10663", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11173", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11228*999999999", + "11240*3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "26": { + "age": "26", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10085*9999", + 10086, + 10087, + "10088*10", + 10189, + "10210*99999", + 10252, + "10256*0.1", + 10266, + 10272, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10284, + 10285, + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10468*3", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + 10474, + "10475*3", + "10476*3", + "10477*3", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10610*5", + "10611", + "10161*9", + 10617, + "10618", + "10660", + "10661", + "10662", + "10663", + "10664", + "10665", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11161", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*3", + "11173", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11229*999999", + "11230*999999999", + "11240*9", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "27": { + "age": "27", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10086, + 10087, + "10088*10", + 10189, + "10235*999999", + 10252, + "10254*0.1", + 10266, + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10463, + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + 10474, + "10591", + "10610*30", + "10611*99", + "10612*5", + "10616*9999999", + "10660", + "10661", + "10662", + "10663", + "10664*5", + "10665*5", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11161", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*3", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11219*0.01", + "11220", + "11231*999999999", + "11237*999999", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "28": { + "age": "28", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10086, + 10087, + 10088, + 10189, + "10236*99999999", + 10268, + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10284, + 10285, + 10288, + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10591", + "10610*999999999", + "10611*999999", + "10612*99999999", + "10660", + "10661", + "10662", + "10663", + "10664", + "10665*5", + "10666*5", + "10667*5", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11161", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*6", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11232*999999", + "11238*999999999", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "29": { + "age": "29", + "event": [ + 10007, + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10086, + 10087, + 10189, + "10253*0.1", + 10268, + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10281, + "10282*0.001", + 10284, + 10285, + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10474*99", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10591", + "10619", + "10620*5", + "10666*5", + "10667*5", + "10668*5", + "10717", + "10718", + "10719", + "10720", + "10721", + "10722", + "10723", + "10724", + "10725", + "10726", + "10727", + "10728", + "10729", + "10730", + "10731", + "10732", + "10733", + "10734", + "10735", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*9", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11232*999999", + "11235*999999999", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "30": { + "age": "30", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10086, + 10087, + 10189, + 10268, + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10281, + "10282*0.001", + 10288, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10411, + 10413, + 10414, + 10415, + 10416, + 10417, + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10589*99999999999999", + "10619", + "10620*3", + "10621", + "10622", + "10666*5", + "10665*5", + "10667*5", + "10668*5", + "10736*99999999999999", + "10785", + "10786", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11128", + "11129", + "11130", + "11131", + "11132", + "11133", + "11134", + "11135", + "11136", + "11137", + "11138", + "11139", + "11140", + "11141", + "11142", + "11143", + "11144", + "11145", + "11146", + "11147", + "11148", + "11149", + "11150", + "11151", + "11156", + "11157", + "11158", + "11159", + "11160", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*9", + "11179", + "11180", + "11181", + "11182", + "11183", + "11184*0.05", + "11185*0.05", + "11186*0.05", + "11187*0.05", + "11188*0.05", + "11189*0.05", + "11190*0.05", + "11191*0.05", + "11192*0.05", + "11193*0.05", + "11194*0.05", + "11195*0.05", + "11196*0.05", + "11197*0.05", + "11198*0.05", + "11199*0.05", + "11200*0.05", + "11208*0.5", + "11209*0.5", + "11210*0.5", + "11211*0.5", + "11212*0.5", + "11213*0.1", + "11214*0.1", + "11215*0.1", + "11216*0.1", + "11217*0.01", + "11218*0.01", + "11219*0.01", + "11220", + "11232*999999", + "11234*333333", + "11235*999999999", + "11236*999999999", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*33333333333333333", + "11466*33333333333333333", + "11467*33333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "31": { + "age": "31", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10086*2", + 10087, + 10256, + 10268, + 10269, + 10270, + 10271, + 10272, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10284, + 10285, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + 10619, + "10620*2", + "10621*2", + "10622", + "10668*5", + "10737*99999999999999", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11162*999999", + "11163*999999", + "11164", + "11165", + "11166", + "11167", + "11168", + "11169", + "11170", + "11171*999999", + "11232*999999", + "11234*333333", + "11235*999999999", + "11236*999999999", + "11240", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1", + "11468*0.1" + ] + }, + "32": { + "age": "32", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10086*3", + 10087, + 10254, + 10272, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10284, + 10285, + 10288, + "10289*0.01", + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10591", + "10621*10", + "10622", + "10668*5", + "10669*5", + "10670", + "10738", + "10739", + "10740", + "10785", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11232*999999", + "11234*333333", + "11235*999999999", + "11236*999999999", + "11239*10", + "11240*999999", + "11241", + "11242*3", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "33": { + "age": "33", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10086*4", + 10087, + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10283, + "10289*0.01", + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10621*99999999", + "10668*5", + "10669*5", + "10670", + "10738", + "10739", + "10740", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11219*0.01", + "11220", + "11232*999999", + "11234*333333", + "11235*999999999", + "11236*999999999", + "11241", + "11242*3", + "11243", + "11244*3", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11259", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1", + "11468*0.1" + ] + }, + "34": { + "age": "34", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10086*5", + 10087, + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10283, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10591", + "10623", + "10624", + "10625", + "10626", + "10627", + "10658", + "10668*5", + "10669*5", + "10670", + "10738", + "10739", + "10740", + "10786", + "10830*99", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11232*999999", + "11234*666666", + "11235*999999999", + "11236*999999999", + "11241", + "11242*9", + "11243", + "11244*9", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11259", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11314*0.01", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999", + "30001*0.1" + ] + }, + "35": { + "age": "35", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10086*6", + 10087, + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10281, + "10282*0.001", + 10283, + 10288, + "10289*0.01", + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10469*2", + "10470*2", + "10471*2", + "10472*2", + 10473, + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10623", + "10624", + "10625", + "10626", + "10627", + "10658*3", + "10668*5", + "10669*5", + "10670", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10830*99", + "10831*99", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11232*999999", + "11234*999999", + "11235*999999999", + "11236*999999999", + "11242*30", + "11241", + "11243", + "11244*30", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11256", + "11259", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "36": { + "age": "36", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10087*7", + "10253*0.1", + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10283, + "10289*0.01", + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10591", + "10623", + "10624", + "10625", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10658*5", + "10670", + "10671*2", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10830*9", + "10831*99", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11219*0.01", + "11220", + "11232*999999", + "11234*999999999", + "11235*999999999", + "11236*999999999", + "11242*99999", + "11241", + "11243", + "11244*999", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11256*2", + "11259", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999" + ], + "__EMPTY": "11459*99999999999999999" + }, + "37": { + "age": "37", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10087*8", + "10254*0.1", + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10281, + "10282*0.001", + 10283, + 10288, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10591", + "10623", + "10624", + "10625", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10658*10", + "10670", + "10671*3", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10830*9", + "10831*99", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11219*0.01", + "11220", + "11233*999999999", + "11235*999999999", + "11236*999999999", + "11243", + "11244*999999", + "11241", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11256*3", + "11259", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*333333333333333333", + "11467*333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "38": { + "age": "38", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10087*9", + "10255*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10281, + "10282*0.001", + 10283, + "10289*0.01", + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10317, + 10318, + 10319, + 10320, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10623", + "10624", + "10625", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10658*6", + "10670", + "10671*5", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11235*999999999", + "11236*999999999", + "11243", + "11241", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11256*4", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11460*33333333333333333", + "11461*33333333333333333", + "11462*33333333333333333", + "11463*33333333333333333", + "11464*33333333333333333", + "11465*333333333333333333", + "11466*9333333333333333333", + "11467*9333333333333333333", + "11458*99999999999999999", + "11459*99999999999999999" + ] + }, + "39": { + "age": "39", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + "10087*10", + "10256*0.1", + 10268, + 10269, + 10270, + 10271, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10317, + 10318, + 10319, + 10320, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10625*9", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10658*2", + "10670", + "10671*5", + "10672", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10830*9", + "10831*9", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11236*999999999", + "11243", + "11245", + "11246", + "11247", + "11248", + "11249", + "11250", + "11251", + "11252", + "11253", + "11254", + "11255", + "11256*5", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11466*9333333333333333333", + "11467*9333333333333333333" + ] + }, + "40": { + "age": "40", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + 10288, + "10289*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10317, + 10318, + 10319, + 10320, + "10322*0.1", + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10590*99999999999999", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10658", + "10670", + "10671*5", + "10672*2", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11243", + "11256*6", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11350", + "11351", + "11352", + "11353", + "11354", + "11355", + "11356", + "11357", + "11358", + "11359", + "11360", + "11361", + "11362", + "11363", + "11364", + "11365", + "11366", + "11367", + "11368", + "11369", + "11370", + "11371", + "11372", + "11373", + "11374", + "11375", + "11376", + "11377", + "11378", + "11379", + "11380", + "11381", + "11382", + "11383", + "11384", + "11385", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11466*9333333333333333333", + "11467*9333333333333333333" + ] + }, + "41": { + "age": "41", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + "10290*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10318, + 10319, + 10320, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10591", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646", + "10671*5", + "10672*3", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11256*9", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "42": { + "age": "42", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + "10290*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10317, + 10318, + 10319, + 10320, + 10322, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10590*99999999999999", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10672*5", + "10673", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "11217*0.02", + "11218*0.02", + "11256*99", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11287", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "43": { + "age": "43", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + 10288, + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10318, + 10319, + 10320, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10591", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646", + "10648", + "10672*3", + "10673", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11256*999999", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11287", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "44": { + "age": "44", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + "10253*0.1", + "10254*0.1", + "10255*0.1", + "10256*0.1", + "10257*0.1", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.1", + 10283, + 10288, + "10289*0.01", + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10317, + 10318, + 10319, + 10320, + "10322*0.1", + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10463, + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*2", + "10672*3", + "10673", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11287", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "45": { + "age": "45", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10283, + 10288, + "10289*0.1", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10317, + 10318, + 10319, + 10320, + 10410, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10478*2", + "10479*2", + "10480*2", + "10481*2", + "10482*2", + "10483*2", + "10484*2", + "10485*2", + "10486*2", + "10487*2", + "10488*2", + "10489*2", + "10490*2", + "10491*2", + "10590*99999999999999", + "10626", + "10627", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*3", + "10672*5", + "10673", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "11259", + "11260", + "11263", + "11264", + "11265", + "11266", + "11267", + "11268*0.05", + "11269", + "11270", + "11271", + "11272", + "11273", + "11274", + "11275", + "11276*0.03", + "11277*0.03", + "11278*0.03", + "11279", + "11280", + "11281", + "11282", + "11283", + "11284", + "11285", + "11286*0.3", + "11287*3", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11386", + "11387", + "11388", + "11389", + "11390", + "11391", + "11392", + "11393", + "11394", + "11395", + "11396", + "11397", + "11398", + "11399", + "11400", + "11401", + "11402", + "11403", + "11404", + "11405", + "11406", + "11407", + "11408", + "11409", + "11410", + "11411", + "11412", + "11413" + ] + }, + "46": { + "age": "46", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10288, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10317, + 10318, + 10319, + 10320, + 10322, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*5", + "10648", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11287*3", + "11288", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01", + "11468*0.1" + ] + }, + "47": { + "age": "47", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.1", + "10290*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10318, + 10319, + 10320, + "10322*0.1", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10591", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*10", + "10648", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11287*3", + "11288*3", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "48": { + "age": "48", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + 10288, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10308, + 10317, + 10318, + 10319, + 10320, + 10322, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*50", + "10647*5", + "10648", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11287*3", + "11288*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11314*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "49": { + "age": "49", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10087, + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + "10290*0.01", + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10308, + 10317, + 10318, + 10319, + 10320, + "10322*0.1", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10628", + "10629", + "10630", + "10631", + "10632", + "10633", + "10634", + "10635", + "10636", + "10637", + "10638", + "10639", + "10640", + "10641", + "10642", + "10643", + "10644", + "10645", + "10646*100", + "10647*99", + "10648", + "10674", + "10675", + "10676", + "10741", + "10742", + "10743", + "10744", + "10745", + "10746", + "10747", + "10748", + "10749", + "10750", + "10751", + "10752", + "10753", + "10754", + "10755", + "10756", + "10757", + "10758", + "10759", + "10760", + "10761", + "10762", + "10763", + "10764", + "10765", + "10766", + "10767", + "10768*0.01", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11217*0.02", + "11218*0.02", + "11219*0.01", + "11220", + "11287*3", + "11288*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.01", + "11415*0.01", + "11416*0.01", + "11417*0.01", + "11418*0.01", + "11419*0.01", + "11420*0.01", + "11421*0.01", + "11422*0.01", + "11423*0.01", + "11424*0.01", + "11425*0.01", + "11426*0.01", + "11427*0.01", + "11428*0.01", + "11429*0.01", + "11430*0.01", + "11431*0.01", + "11432*0.01", + "11433*0.01", + "11434*0.01", + "11435*0.01", + "11436*0.01", + "11437*0.01", + "11438*0.01", + "11439*0.01", + "11440*0.01", + "11441*0.01", + "11442*0.01", + "11443*0.01", + "11444*0.01", + "11445*0.01", + "11446*0.01", + "11447*0.01", + "11448*0.01", + "11449*0.01", + "11450*0.01" + ] + }, + "50": { + "age": "50", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10317, + 10318, + 10319, + 10320, + 10321, + "10322*0.1", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10590*99999999999999", + "10646*999", + "10647*99", + "10648", + "10677*2", + "10678*2", + "10769*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10832", + "10833", + "10834", + "10835", + "10836", + "10837", + "10838", + "11219*0.01", + "11220", + "11257*0.01", + "11258*0.01", + "11288*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11296*999999", + "21305*999999999", + "11300", + "11305", + "11312*0.1", + "11314*0.01", + "11325", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "51": { + "age": "51", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.01", + 10286, + 10287, + 10288, + "10290*0.01", + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10308, + 10317, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10648", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10655", + "10677*5", + "10678*5", + "10769*9999999999", + "10785", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.01", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11296*999999", + "21305*999999999", + "11300", + "11301", + "11302", + "11303", + "11304", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "52": { + "age": "52", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + 10286, + 10287, + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10308, + 10317, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10655", + "10677*10", + "10678*10", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.01", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11296*999999", + "21305*999999999", + "11300", + "11301", + "11302", + "11303", + "11304", + "11327", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "53": { + "age": "53", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + 10288, + "10290*0.01", + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10317, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10655", + "10677*10", + "10678*10", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.01", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11296*999999", + "21305*999999999", + "11312*0.1", + "11314*0.01", + "11318", + "11319*999999999", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "54": { + "age": "54", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.01", + 10286, + 10287, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10308, + 10317, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + 10464, + "10465*0.5", + "10466*0.2", + "10467*0.08", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10655", + "10677*5", + "10678*5", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11257*0.01", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11300", + "11301", + "11302", + "11303", + "11304", + "11318", + "11319*999999999", + "11325", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "55": { + "age": "55", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + 10288, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + "10295*66", + "10296*66", + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10308, + 10317, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10492*999999999", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10677*2", + "10678*2", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "11219*0.01", + "11220", + "11257*0.05", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11295*0.01", + "11305", + "11312*0.1", + "11314*0.01", + "11318", + "11319*999999999", + "11320*999999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05" + ] + }, + "56": { + "age": "56", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + "10286*10", + "10287*50", + "10289*0.1", + "10290*0.01", + "10291*0.01", + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10461*0.1", + "10462*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10785", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.05", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11295*0.01", + "11300", + "11301", + "11302", + "11303", + "11304", + "11320*999999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "57": { + "age": "57", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + "10286*500", + "10287*100", + "10290*0.01", + 10292, + 10293, + 10295, + 10296, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10308, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10785", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.05", + "11258*0.01", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11295*0.01", + "11300", + "11301", + "11302", + "11303", + "11304", + "11320*999999999", + "11325", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "58": { + "age": "58", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + 10288, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10308, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.1", + "11258*0.05", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11292", + "11293", + "11294*0.1", + "11295*0.01", + "11300", + "11301", + "11302", + "11303", + "11304", + "11320*999999999", + "11325", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "59": { + "age": "59", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.001", + 10286, + 10287, + 10288, + "10289*0.1", + 10292, + 10293, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + 10307, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + "10430*0.1", + "10431*0.1", + "10432*0.1", + "10433*0.1", + "10434*0.1", + "10435*0.1", + "10436*0.1", + "10437*0.1", + "10438*0.1", + "10439*0.1", + "10440*0.1", + "10441*0.1", + "10442*0.1", + "10443*0.1", + "10444*0.1", + "10445*0.1", + "10446*0.1", + "10447*0.1", + "10448*0.1", + "10449*0.1", + "10450*0.1", + "10451*0.1", + "10452*0.1", + "10453*0.1", + "10454*0.1", + "10455*0.1", + "10456*0.1", + "10457*0.1", + "10458*0.1", + "10459*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "11219*0.01", + "11220", + "11257*0.1", + "11258*0.05", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11320*999999999", + "11327", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "60": { + "age": "60", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.01", + 10281, + "10282*0.01", + 10286, + 10287, + 10288, + "10289*0.1", + "10290*0.01", + 10292, + 10293, + 10297, + 10298, + 10299, + 10300, + 10301, + 10302, + 10303, + 10304, + 10305, + 10306, + "10307*999", + 10316, + 10318, + 10319, + 10320, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10493*99999999", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10659", + "10679", + "10680", + "10681", + "10682", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "11219*0.01", + "11220", + "11257*0.1", + "11258*0.05", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.01", + "11297*3", + "11298", + "11300", + "11301", + "11302", + "11303", + "11304", + "11305", + "11312*0.1", + "11313*0.5", + "11314*0.01", + "11320*999999999", + "11323*99999999", + "11325", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "61": { + "age": "61", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10308, + 10310, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10461*0.1", + "10462*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10683", + "10684", + "10685", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10785", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "11257*0.5", + "11258*0.1", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11299*999999", + "11298", + "11320*999999999", + "11323*99999999", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "62": { + "age": "62", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10308, + 10310, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10659", + "10679", + "10680", + "10681", + "10682", + "10683", + "10684", + "10685", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "11219*0.01", + "11220", + "11257*0.5", + "11258*0.1", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.03", + "11297*3", + "11299*999999", + "11300", + "11301", + "11302", + "11303", + "11304", + "11305", + "11312*0.1", + "11313*0.5", + "11315*999999", + "11320*999999999", + "11323*99999999", + "11326", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "63": { + "age": "63", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.1", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10308, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10461*0.1", + "10462*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10683", + "10684", + "10685", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10786", + "10785", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "11219*0.01", + "11220", + "11257*0.5", + "11258*0.1", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.03", + "11320*999999999", + "11326", + "11327", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "64": { + "age": "64", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + "10290*0.01", + 10292, + 10293, + "10291*0.01", + 10308, + 10310, + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10461*0.1", + "10462*0.1", + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10654", + "10655", + "10679", + "10680", + "10681", + "10682", + "10683", + "10684", + "10685", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10785", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "11219*0.01", + "11220", + "11257*0.5", + "11258*0.1", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.03", + "11312*0.1", + "11320*999999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "65": { + "age": "65", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10253, + 10254, + 10255, + 10256, + 10257, + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + "10290*0.1", + 10292, + 10293, + "10291*0.01", + 10308, + "10316*3", + 10321, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10649*0.01", + "10650*0.01", + "10651*0.01", + "10652*0.01", + "10653*0.01", + "10654", + "10655", + "10659", + "10679", + "10680", + "10681", + "10682", + "10683", + "10684", + "10685", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10785", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "11219*0.01", + "11220", + "11257", + "11258*0.5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.03", + "11298", + "11320*999999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "66": { + "age": "66", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + "10290*0.1", + "10291*0.1", + 10308, + 10310, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649*0.1", + "10650*0.1", + "10651*0.1", + "10652*0.1", + "10653*0.01", + "10659", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257", + "11258*0.5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.03", + "11297*9", + "11299*999999", + "11300", + "11301", + "11302", + "11303", + "11304", + "11306*0.01", + "11309", + "11312*0.1", + "11315*999999", + "11316*0.3", + "11320*999999999", + "11323*99999999", + "11327", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "67": { + "age": "67", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10282*0.001", + "10290*0.1", + "10291*0.1", + 10308, + 10310, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10461*0.1", + "10462*0.1", + "10649*0.1", + "10650*0.1", + "10651*0.1", + "10652*0.1", + "10653*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10785", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "11257", + "11258*0.5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11309", + "11316*0.3", + "11320*999999999", + "11323*99999999", + "11327", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "68": { + "age": "68", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10290*0.1", + 10292, + 10293, + "10291*0.1", + 10310, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649*0.1", + "10650*0.1", + "10651*0.1", + "10652*0.1", + "10653*0.01", + "10659", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10786", + "10790", + "10791", + "10792", + "10793", + "10794", + "10795", + "10796", + "10797", + "10798", + "10799", + "10800", + "10801", + "10802", + "10803", + "10804", + "10805", + "10806", + "10807", + "10808", + "10809", + "10810", + "10811", + "10812", + "10813", + "10814", + "10815", + "10841*99999999999999", + "10842*999999999999", + "11257", + "11258*0.5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11316*0.3", + "11320*999999999", + "11323*99999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "69": { + "age": "69", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10281, + "10290*0.1", + 10292, + 10293, + "10291*0.1", + 10308, + 10312, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10461*0.1", + "10462*0.1", + "10649*0.1", + "10650*0.1", + "10651*0.1", + "10652*0.1", + "10653*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257", + "11258*0.5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11297*9", + "11298", + "11300", + "11301", + "11302", + "11303", + "11304", + "11306*0.01", + "11309", + "11316*0.3", + "11320*999999999", + "11324*9999999", + "11328", + "11329*0.1", + "11330", + "11331*0.1", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "70": { + "age": "70", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*0.1", + 10280, + 10281, + "10290*0.1", + 10292, + 10293, + "10291*0.1", + "10307*999", + 10310, + 10312, + "10316*15", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649*0.1", + "10650*0.1", + "10651*0.1", + "10652*0.1", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11299*999999", + "11312*0.1", + "11315*999999", + "11320*999999999", + "11324*9999999", + "11328", + "11329*0.1", + "11330", + "11332", + "11333", + "11334", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "71": { + "age": "71", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + 10281, + "10290*0.1", + "10291*0.1", + 10310, + 10312, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649", + "10650", + "10651", + "10652", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11220", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11306*0.01", + "11309", + "11313", + "11314*0.01", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11324*9999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "72": { + "age": "72", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*3", + "10290*0.1", + "10291*0.1", + 10310, + 10312, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10461*0.1", + "10462*0.1", + "10649", + "10650", + "10651", + "10652", + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11220", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11313", + "11314*0.01", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11324*9999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "73": { + "age": "73", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*3", + "10290*0.1", + "10291*0.1", + 10312, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649", + "10650", + "10651", + "10652", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10659", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11220*5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.07", + "11313", + "11314*0.01", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11324*9999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "74": { + "age": "74", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*3", + "10290*0.1", + 10292, + 10293, + "10291*0.1", + 10310, + 10312, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649", + "10650", + "10651", + "10652", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11220*5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11309", + "11312*0.1", + "11316*0.3", + "11317", + "11320*999999999", + "11323*99999999", + "11324*99999999", + "11327", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "75": { + "age": "75", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*5", + "10290*0.1", + 10292, + 10293, + 10291, + 10310, + 10312, + 10313, + 10314, + 10316, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10649", + "10650", + "10651", + "10652", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11257*3", + "11258", + "11220*5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11306*0.01", + "11314*0.01", + "11317", + "11320*999999999", + "11322*99999999", + "11323*99999999", + "11324*99999999", + "11327", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "76": { + "age": "76", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*5", + 10290, + 10291, + 10310, + 10312, + 10313, + 10314, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*3", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*5", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11306*0.01", + "11308", + "11313*0.5", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11322*99999999", + "11324*99999999", + "11327", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "77": { + "age": "77", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*9", + 10290, + 10291, + 10310, + 10313, + 10314, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*2", + "10653*0.01", + "10656*0.01", + "10657*0.01", + "10659", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11306*0.01", + "11309", + "11314*0.01", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11322*99999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "78": { + "age": "78", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*15", + 10290, + "10291*5", + 10310, + 10313, + 10314, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*5", + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11306*0.01", + "11309", + "11314*0.01", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11322*999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "79": { + "age": "79", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*50", + 10290, + "10291*5", + 10310, + 10313, + 10314, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10460*5", + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10659", + "10679", + "10680", + "10681", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11289*99999999", + "11290*99999999", + "11291*99999999", + "11295*0.1", + "11306*0.01", + "11308", + "11313*0.5", + "11316*0.3", + "11317", + "11321*99999999", + "11322*999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "80": { + "age": "80", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*50", + 10290, + "10291*5", + 10294, + 10313, + 10314, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + 10460, + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10683", + "10684", + "10685", + "10686", + "10687", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11295*0.1", + "11320*999999999", + "11322*999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11469" + ] + }, + "81": { + "age": "81", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*50", + "10290*3", + 10294, + 10313, + 10314, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11295*0.1", + "11306*0.1", + "11307", + "11309", + "11313*0.5", + "11314*0.01", + "11316*0.3", + "11317", + "11320*999999999", + "11322*999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11469" + ] + }, + "82": { + "age": "82", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*100", + "10290*5", + 10294, + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11295*0.1", + "11308", + "11310*0.1", + "11316*0.3", + "11317", + "11320*999999999", + "11321*99999999", + "11322*9999999999", + "11323*99999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "83": { + "age": "83", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*500", + "10290*5", + "10291*10", + 10294, + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653*0.1", + "10656*0.01", + "10657*0.01", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11295*0.1", + "11309", + "11310*0.1", + "11316*0.3", + "11317", + "11320*999999999", + "11322*9999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "84": { + "age": "84", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*500", + 10290, + "10291*50", + 10294, + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.01", + "10657*0.01", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "10842*999999999999", + "11220*9", + "11295*0.1", + "11309", + "11310*0.1", + "11316*0.3", + "11317", + "11320*999999999", + "11322*9999999999", + "11324*99999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "85": { + "age": "85", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5", + "10280*5", + "10281*500", + 10290, + "10291*999", + 10294, + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.01", + "10657*0.01", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11307", + "11308", + "11310*0.1", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11322*9999999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "11414*0.05", + "11415*0.05", + "11416*0.05", + "11417*0.05", + "11418*0.05", + "11419*0.05", + "11420*0.05", + "11421*0.05", + "11422*0.05", + "11423*0.05", + "11424*0.05", + "11425*0.05", + "11426*0.05", + "11427*0.05", + "11428*0.05", + "11429*0.05", + "11430*0.05", + "11431*0.05", + "11432*0.05", + "11433*0.05", + "11434*0.05", + "11435*0.05", + "11436*0.05", + "11437*0.05", + "11438*0.05", + "11439*0.05", + "11440*0.05", + "11441*0.05", + "11442*0.05", + "11443*0.05", + "11444*0.05", + "11445*0.05", + "11446*0.05", + "11447*0.05", + "11448*0.05", + "11449*0.05", + "11450*0.05", + "11469" + ] + }, + "86": { + "age": "86", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*10", + "10280*10", + "10281*500", + 10290, + "10291*559", + "10294*3", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.1", + "10657*0.1", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11307", + "11309*9", + "11310*0.5", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11323*99999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "87": { + "age": "87", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*10", + "10280*10", + "10281*500", + 10290, + "10291*992", + "10294*3", + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.1", + "10657*0.1", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11306*0.1", + "11309*99", + "11310*0.5", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11323*99999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "88": { + "age": "88", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*10", + "10280*10", + "10281*500", + "10290*3", + "10291*55599", + "10294*3", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.1", + "10657*0.1", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11306*0.1", + "11309*999", + "11310*0.5", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "89": { + "age": "89", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*10", + "10280*10", + "10281*100", + "10290*3", + "10291*999999", + "10294*5", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.1", + "10657*0.1", + "10659", + "10688", + "10689", + "10690", + "10691", + "10692", + "10693", + "10694", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10715", + "10716*9999999999", + "10785", + "10786", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11306*0.1", + "11308", + "11310*0.5", + "11311", + "11320*999999999", + "11322*99999999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "90": { + "age": "90", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*500", + "10280*500", + "10281*100", + "10290*3", + "10294*5", + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*0.1", + "10657*0.1", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "10841*99999999999999", + "11220*9", + "11295*0.1", + "11310", + "11320*999999999", + "11322*99999999999", + "11324*999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "91": { + "age": "91", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*500", + "10280*500", + "10281*1000", + "10290*5", + "10294*5", + 10313, + 10315, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656", + "10657", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11307", + "11310", + "11316*0.3", + "11320*999999999", + "11321*99999999", + "11322*99999999999", + "11324*9999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "92": { + "age": "92", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*5000", + "10280*5000", + "10281*5000", + "10290*100", + "10294*10", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656", + "10657", + "10659", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11310", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*9999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "93": { + "age": "93", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*50000", + "10280*50000", + "10281*5000", + "10290*1000", + "10294*50", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656", + "10657", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11310*9", + "11311", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "94": { + "age": "94", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*99999", + "10280*99999", + "10281*9999", + "10290*100000", + "10294*500", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656", + "10657", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11310*9", + "11311", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "95": { + "age": "95", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + "10279*99999999", + "10280*99999999", + "10281*999999", + "10290*100000", + "10294*52554", + 10313, + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*10", + "10657*10", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11310*9", + "11311", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "96": { + "age": "96", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*9999999", + "10290*99999", + "10294*99999", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*10", + "10657*10", + "10659", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11306*0.1", + "11310*999", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "97": { + "age": "97", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + "10281*999999999", + "10290*99999", + "10294*999999", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*100", + "10657*100", + "10695*0.1", + "10696*0.1", + "10697*0.1", + "10698*0.1", + "10699*0.1", + "10700*0.1", + "10701*0.1", + "10702*0.1", + "10703*0.1", + "10704*0.1", + "10705*0.1", + "10706*0.1", + "10707*0.1", + "10708*0.1", + "10709*0.1", + "10710*0.1", + "10711*0.1", + "10712*0.1", + "10713*0.1", + "10714*0.1", + "11220*9", + "11295*0.1", + "11306*0.1", + "11307", + "11310*999", + "11316*0.3", + "11320*999999999", + "11322*99999999999", + "11324*999999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "98": { + "age": "98", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + 10281, + "10290*99999", + "10294*9999999", + 10413, + 10414, + 10415, + 10416, + 10417, + 10418, + 10419, + 10420, + 10421, + 10422, + 10423, + "10424*0.1", + "10425*0.01", + 10430, + 10431, + 10432, + 10433, + 10434, + 10436, + 10437, + 10438, + 10439, + 10440, + 10441, + 10442, + 10443, + 10444, + 10445, + 10446, + 10447, + 10448, + 10449, + 10450, + 10451, + 10452, + 10453, + 10454, + 10455, + 10456, + 10457, + 10459, + "10653", + "10656*108899", + "10657*108899", + "10770*0.1", + "10771*0.1", + "10772*0.1", + "10773*0.1", + "10774*0.1", + "10775*0.1", + "10776*0.1", + "10777*0.1", + "10778*0.1", + "10779*0.1", + "10780*0.1", + "10781*0.1", + "10782*0.1", + "10783*0.1", + "10784*0.1", + "11220*9", + "11295*0.1", + "11310*99999999999", + "11311", + "11316*0.3", + "11320*999999999", + "11324*999999999999999", + "11329*0.1", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "99": { + "age": "99", + "event": [ + "10069*0.03", + "10070*0.03", + "10071*0.03", + 10273, + 10274, + 10275, + 10276, + 10277, + 10278, + 10279, + 10280, + 10281, + "10290*99999999", + "10656*9999999999", + "10657*9999999999", + "11220*9", + "11310*99999999999", + "11316*0.3", + "11324*999999999999999999", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "100": { + "age": "100", + "event": [ + 10323, + "20410*99999999999" + ] + }, + "101": { + "age": "101", + "event": [ + 10324, + 10325, + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "102": { + "age": "102", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5" + ] + }, + "103": { + "age": "103", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10787*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "104": { + "age": "104", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "105": { + "age": "105", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "106": { + "age": "106", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "107": { + "age": "107", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "108": { + "age": "108", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "109": { + "age": "109", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10496*0.02", + "10787*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "110": { + "age": "110", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "111": { + "age": "111", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "112": { + "age": "112", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "113": { + "age": "113", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "114": { + "age": "114", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "115": { + "age": "115", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "116": { + "age": "116", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "117": { + "age": "117", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "118": { + "age": "118", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "119": { + "age": "119", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "120": { + "age": "120", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "121": { + "age": "121", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "122": { + "age": "122", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "123": { + "age": "123", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "124": { + "age": "124", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "125": { + "age": "125", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "126": { + "age": "126", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "127": { + "age": "127", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "128": { + "age": "128", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "129": { + "age": "129", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "130": { + "age": "130", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "131": { + "age": "131", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "132": { + "age": "132", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "133": { + "age": "133", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "134": { + "age": "134", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "135": { + "age": "135", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "136": { + "age": "136", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "137": { + "age": "137", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "138": { + "age": "138", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "139": { + "age": "139", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "140": { + "age": "140", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "141": { + "age": "141", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "142": { + "age": "142", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "143": { + "age": "143", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "144": { + "age": "144", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "145": { + "age": "145", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "146": { + "age": "146", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "147": { + "age": "147", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "148": { + "age": "148", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "149": { + "age": "149", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "150": { + "age": "150", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "151": { + "age": "151", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "152": { + "age": "152", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "153": { + "age": "153", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "154": { + "age": "154", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "155": { + "age": "155", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "156": { + "age": "156", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "157": { + "age": "157", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "158": { + "age": "158", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "159": { + "age": "159", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "160": { + "age": "160", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "161": { + "age": "161", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "162": { + "age": "162", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "163": { + "age": "163", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "164": { + "age": "164", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "165": { + "age": "165", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "166": { + "age": "166", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "167": { + "age": "167", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "168": { + "age": "168", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "169": { + "age": "169", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "170": { + "age": "170", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "171": { + "age": "171", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "172": { + "age": "172", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "173": { + "age": "173", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "174": { + "age": "174", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "175": { + "age": "175", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "176": { + "age": "176", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "177": { + "age": "177", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "178": { + "age": "178", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "179": { + "age": "179", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10816*0.01", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "180": { + "age": "180", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "181": { + "age": "181", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "182": { + "age": "182", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "183": { + "age": "183", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "184": { + "age": "184", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "185": { + "age": "185", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "186": { + "age": "186", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "187": { + "age": "187", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "188": { + "age": "188", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "189": { + "age": "189", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "190": { + "age": "190", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "191": { + "age": "191", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "192": { + "age": "192", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "193": { + "age": "193", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "194": { + "age": "194", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "195": { + "age": "195", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "196": { + "age": "196", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "197": { + "age": "197", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "198": { + "age": "198", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10336", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "199": { + "age": "199", + "event": [ + 10324, + 10325, + 10326, + 10327, + 10328, + 10329, + 10330, + 10331, + 10332, + 10333, + "10334*0.01", + "10335*0.01", + "10495*0.01", + "10361", + "10337", + "10338", + "10339", + "10340", + "10341", + "10342", + "10343", + "10344", + "10345", + "10361", + "10787*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349", + "20332*0.01", + "20333*0.01", + "20334*0.1", + "20338*0.03", + "20336*0.1", + "20339*0.05", + "20340*0.1", + "20342*0.5", + "20344*0.1", + "20346*0.1" + ] + }, + "200": { + "age": "200", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + "10346*999999", + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361 + ] + }, + "201": { + "age": "201", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "202": { + "age": "202", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.002", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "203": { + "age": "203", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.003", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "204": { + "age": "204", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.004", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "205": { + "age": "205", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.005", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "206": { + "age": "206", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.006", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "207": { + "age": "207", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.007", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "208": { + "age": "208", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.008", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "209": { + "age": "209", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.009", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "210": { + "age": "210", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.010", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "211": { + "age": "211", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.011", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "212": { + "age": "212", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.012", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "213": { + "age": "213", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.013", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "214": { + "age": "214", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.014", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "215": { + "age": "215", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.015", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "216": { + "age": "216", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.016", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "217": { + "age": "217", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.017", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "218": { + "age": "218", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.018", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "219": { + "age": "219", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.019", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "220": { + "age": "220", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.020", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "221": { + "age": "221", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.021", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "222": { + "age": "222", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.022", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "223": { + "age": "223", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.023", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "224": { + "age": "224", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.024", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "225": { + "age": "225", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.025", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "226": { + "age": "226", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.026", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "227": { + "age": "227", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.027", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "228": { + "age": "228", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.028", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "229": { + "age": "229", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.029", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "230": { + "age": "230", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.030", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "231": { + "age": "231", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.031", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "232": { + "age": "232", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.032", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "233": { + "age": "233", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.033", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "234": { + "age": "234", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.034", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "235": { + "age": "235", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.035", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "236": { + "age": "236", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.036", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "237": { + "age": "237", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.037", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "238": { + "age": "238", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.038", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "239": { + "age": "239", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.039", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "240": { + "age": "240", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.040", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "241": { + "age": "241", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.041", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "242": { + "age": "242", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.042", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "243": { + "age": "243", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.043", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "244": { + "age": "244", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.044", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "245": { + "age": "245", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.045", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "246": { + "age": "246", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.046", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "247": { + "age": "247", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.047", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "248": { + "age": "248", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.048", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "249": { + "age": "249", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.049", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "250": { + "age": "250", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10817*0.10", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "251": { + "age": "251", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "252": { + "age": "252", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "253": { + "age": "253", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "254": { + "age": "254", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "255": { + "age": "255", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "256": { + "age": "256", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "257": { + "age": "257", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "258": { + "age": "258", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "259": { + "age": "259", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "260": { + "age": "260", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "261": { + "age": "261", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "262": { + "age": "262", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "263": { + "age": "263", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "264": { + "age": "264", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "265": { + "age": "265", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "266": { + "age": "266", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "267": { + "age": "267", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "268": { + "age": "268", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "269": { + "age": "269", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "270": { + "age": "270", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "271": { + "age": "271", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "272": { + "age": "272", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "273": { + "age": "273", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "274": { + "age": "274", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "275": { + "age": "275", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "276": { + "age": "276", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "277": { + "age": "277", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "278": { + "age": "278", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "279": { + "age": "279", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "280": { + "age": "280", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "281": { + "age": "281", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "282": { + "age": "282", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "283": { + "age": "283", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10361, + 10362, + "10789*0.005", + "10818*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01", + "11349" + ] + }, + "284": { + "age": "284", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "285": { + "age": "285", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "286": { + "age": "286", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "287": { + "age": "287", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "288": { + "age": "288", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "289": { + "age": "289", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "290": { + "age": "290", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "291": { + "age": "291", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "292": { + "age": "292", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "293": { + "age": "293", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "294": { + "age": "294", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "295": { + "age": "295", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10789*0.005", + "10818*0.01", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "296": { + "age": "296", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10821*0.001" + ] + }, + "297": { + "age": "297", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10821*0.001" + ] + }, + "298": { + "age": "298", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10821*0.001" + ] + }, + "299": { + "age": "299", + "event": [ + 10336, + 10337, + 10338, + 10339, + 10340, + 10341, + 10342, + 10343, + 10344, + 10345, + 10346, + "10349*0.01", + "10350*0.02", + "10351*0.1", + 10348, + 10352, + 10353, + 10361, + 10362, + "10821*0.001" + ] + }, + "300": { + "age": "300", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01" + ] + }, + "301": { + "age": "301", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.001", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "302": { + "age": "302", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.002", + "10821*0.002", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "303": { + "age": "303", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.003", + "10821*0.003", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "304": { + "age": "304", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.004", + "10821*0.004", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "305": { + "age": "305", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.005", + "10821*0.005", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "306": { + "age": "306", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.006", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "307": { + "age": "307", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.007", + "10821*0.002", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "308": { + "age": "308", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.008", + "10821*0.003", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "309": { + "age": "309", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.009", + "10821*0.004", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "310": { + "age": "310", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.010", + "10821*0.005", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "311": { + "age": "311", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.011", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "312": { + "age": "312", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.012", + "10821*0.002", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "313": { + "age": "313", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.013", + "10821*0.003", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "314": { + "age": "314", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.014", + "10821*0.004", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "315": { + "age": "315", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.015", + "10821*0.005", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "316": { + "age": "316", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.016", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "317": { + "age": "317", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.017", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "318": { + "age": "318", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.018", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "319": { + "age": "319", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.019", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "320": { + "age": "320", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.020", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "321": { + "age": "321", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.021", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "322": { + "age": "322", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.022", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "323": { + "age": "323", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.023", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "324": { + "age": "324", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.024", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "325": { + "age": "325", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.025", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "326": { + "age": "326", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.026", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "327": { + "age": "327", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.027", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "328": { + "age": "328", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.028", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "329": { + "age": "329", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.029", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "330": { + "age": "330", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.030", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "331": { + "age": "331", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.031", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "332": { + "age": "332", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.032", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "333": { + "age": "333", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.033", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "334": { + "age": "334", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.034", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "335": { + "age": "335", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.035", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "336": { + "age": "336", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.036", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "337": { + "age": "337", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.037", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "338": { + "age": "338", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.038", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "339": { + "age": "339", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.039", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "340": { + "age": "340", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.040", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "341": { + "age": "341", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.041", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "342": { + "age": "342", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.042", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "343": { + "age": "343", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.043", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "344": { + "age": "344", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.044", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "345": { + "age": "345", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.045", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "346": { + "age": "346", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.046", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "347": { + "age": "347", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.047", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "348": { + "age": "348", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.048", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "349": { + "age": "349", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.049", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "350": { + "age": "350", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.10", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "351": { + "age": "351", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.11", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "352": { + "age": "352", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.12", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "353": { + "age": "353", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.13", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "354": { + "age": "354", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.14", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "355": { + "age": "355", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.15", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "356": { + "age": "356", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.16", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "357": { + "age": "357", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.17", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "358": { + "age": "358", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.18", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "359": { + "age": "359", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.19", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "360": { + "age": "360", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.060", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "361": { + "age": "361", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.061", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "362": { + "age": "362", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.062", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "363": { + "age": "363", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.063", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "364": { + "age": "364", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.064", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "365": { + "age": "365", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.065", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "366": { + "age": "366", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.066", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "367": { + "age": "367", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.067", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "368": { + "age": "368", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.068", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "369": { + "age": "369", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.069", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "370": { + "age": "370", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.070", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "371": { + "age": "371", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.071", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "372": { + "age": "372", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.072", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "373": { + "age": "373", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.073", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "374": { + "age": "374", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.074", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "375": { + "age": "375", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.075", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "376": { + "age": "376", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.076", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "377": { + "age": "377", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.077", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "378": { + "age": "378", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.078", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "379": { + "age": "379", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.079", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "380": { + "age": "380", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.080", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "381": { + "age": "381", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.081", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "382": { + "age": "382", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.082", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "383": { + "age": "383", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.083", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "384": { + "age": "384", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.084", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "385": { + "age": "385", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.085", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "386": { + "age": "386", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.086", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "387": { + "age": "387", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.087", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "388": { + "age": "388", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.088", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "389": { + "age": "389", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.089", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "390": { + "age": "390", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.090", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "391": { + "age": "391", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.091", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "392": { + "age": "392", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.092", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "393": { + "age": "393", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.093", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "394": { + "age": "394", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.094", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "395": { + "age": "395", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.095", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "396": { + "age": "396", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.096", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "397": { + "age": "397", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.097", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "398": { + "age": "398", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.098", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "399": { + "age": "399", + "event": [ + "10347*999999", + 10348, + 10352, + 10353, + 10354, + 10355, + 10356, + 10357, + 10358, + "10359*0.01", + "10363*0.01", + "10364*0.1", + "10366*0.01", + 10365, + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10362, + "10819*0.099", + "10821*0.001", + "11335*0.1", + "11336*0.1", + "11337*0.1", + "11338*0.1", + "11339*0.1", + "11340*0.1", + "11341*0.1", + "11342*0.1", + "11343*0.1", + "11344*0.1", + "11345*0.1", + "11346*0.1", + "11347*0.01", + "11348*0.01" + ] + }, + "400": { + "age": "400", + "event": [ + "10368*99999", + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "20367*0.0001" + ] + }, + "401": { + "age": "401", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "402": { + "age": "402", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "403": { + "age": "403", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "404": { + "age": "404", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "405": { + "age": "405", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "406": { + "age": "406", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "407": { + "age": "407", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "408": { + "age": "408", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "409": { + "age": "409", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "410": { + "age": "410", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "411": { + "age": "411", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "412": { + "age": "412", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "413": { + "age": "413", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "414": { + "age": "414", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "415": { + "age": "415", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "416": { + "age": "416", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "417": { + "age": "417", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "418": { + "age": "418", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "419": { + "age": "419", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "420": { + "age": "420", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "421": { + "age": "421", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "422": { + "age": "422", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "423": { + "age": "423", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "424": { + "age": "424", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "425": { + "age": "425", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "426": { + "age": "426", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "427": { + "age": "427", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "428": { + "age": "428", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "429": { + "age": "429", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "430": { + "age": "430", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "431": { + "age": "431", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "432": { + "age": "432", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "433": { + "age": "433", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "434": { + "age": "434", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "435": { + "age": "435", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "436": { + "age": "436", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "437": { + "age": "437", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "438": { + "age": "438", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "439": { + "age": "439", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "440": { + "age": "440", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "441": { + "age": "441", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "442": { + "age": "442", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "443": { + "age": "443", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "444": { + "age": "444", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "445": { + "age": "445", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "446": { + "age": "446", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "447": { + "age": "447", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "448": { + "age": "448", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "449": { + "age": "449", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "450": { + "age": "450", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10819*0.01", + "20367*0.0001" + ] + }, + "451": { + "age": "451", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "452": { + "age": "452", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "453": { + "age": "453", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "454": { + "age": "454", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "455": { + "age": "455", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "456": { + "age": "456", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "457": { + "age": "457", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "458": { + "age": "458", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "459": { + "age": "459", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "460": { + "age": "460", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "461": { + "age": "461", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "462": { + "age": "462", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "463": { + "age": "463", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "464": { + "age": "464", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "465": { + "age": "465", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "466": { + "age": "466", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "467": { + "age": "467", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "468": { + "age": "468", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "469": { + "age": "469", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "470": { + "age": "470", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "471": { + "age": "471", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "472": { + "age": "472", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "473": { + "age": "473", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "474": { + "age": "474", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "475": { + "age": "475", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "476": { + "age": "476", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "477": { + "age": "477", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "478": { + "age": "478", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "479": { + "age": "479", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "480": { + "age": "480", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "481": { + "age": "481", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "482": { + "age": "482", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "483": { + "age": "483", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "484": { + "age": "484", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "485": { + "age": "485", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "486": { + "age": "486", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "487": { + "age": "487", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "488": { + "age": "488", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "489": { + "age": "489", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "490": { + "age": "490", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "491": { + "age": "491", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "492": { + "age": "492", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "493": { + "age": "493", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "494": { + "age": "494", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "495": { + "age": "495", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "496": { + "age": "496", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "497": { + "age": "497", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "498": { + "age": "498", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "499": { + "age": "499", + "event": [ + 10369, + 10370, + 10371, + 10372, + 10373, + 10374, + 10375, + 10376, + 10367, + 10377, + "10380*0.01", + "10381*0.01", + "10382*0.01", + "10383*0.01", + "10384*0.01", + "10385*0.01", + "10386*0.001", + "10387*0.001", + "10388*0.001", + "10389*0.001", + "10390*0.001", + "10820*0.01", + "20367*0.0001" + ] + }, + "500": { + "age": "500", + "event": [ + 10379, + 10391 + ] + }, + "501": { + "age": "501" + } +} \ No newline at end of file diff --git a/games/lifeRestart/data/age.xlsx b/games/lifeRestart/data/age.xlsx new file mode 100644 index 0000000..d8a643d Binary files /dev/null and b/games/lifeRestart/data/age.xlsx differ diff --git a/games/lifeRestart/data/events.csv b/games/lifeRestart/data/events.csv new file mode 100644 index 0000000..98ea168 --- /dev/null +++ b/games/lifeRestart/data/events.csv @@ -0,0 +1,1572 @@ +$id,event,postEvent,effect:CHR,effect:INT,effect:STR,effect:MNY,effect:SPR,effect:LIF,NoRandom,include,exclude,branch[],branch[] +序号,事件内容,追加事件内容,"颜值 +变化","智力 +变化","体质 +变化","家境 +变化","快乐 +变化","生命 +变化",非随机事件,"有某事件时 +才能被随机到","有某事件时 +一定随机不到",优先分支,分支 +10000,你死了。,,,,,,,-1,1,,,, +10001,你出生了,是个男孩。,,,,,,,,,,"TLT?[1004,1024,1025,1113]",, +10002,你出生了,是个女孩。,,,,,,,,,,"TLT?[1003,1024,1025]",, +10003,你生了场重病。,家里花了不少钱。,,,,-1,-1,,,,STR>6,TLT?[1001]:10004,STR<2&MNY<3:10000 +10004,可能是玉佩保佑,你活了下来。,,,,,,,,1,,,, +10005,刚学会走路,你意外从桌子上跌落。,受了轻伤。,,,,,,,,,INT>7,TLT?[1002]:10006,STR<3&MNY<3:10000 +10006,红肚兜挂在了桌角上,你没有受伤。,,,,,,,,1,,,, +10007,你开始看动漫。,,,,,,1,,,TLT?[1005],"(MNY<3)|(EVT?[10007,10008])",INT>5:20008,CHR>5:20007 +10008,你开始看动漫。,,,,,,1,,,,"(MNY<3)|(EVT?[10007,10008])",INT>5:20008,CHR>5:20007 +20007,你喜欢看画面人设好看的动漫。,,,,,,,,1,,,, +20008,你喜欢看剧情棒的动漫。,,,,,,,,1,,,, +10009,你从小生活在农村,,,,,,,,,(MNY<8)|(TLT?[1012]),"TLT?[1010,1013,1014]",, +10010,你从小生活在城市,,,,,,,,,"(MNY>1)|(TLT?[1010,1013])","TLT?[1012,1014]",, +10011,你出生在美利坚,拥有美国国籍,,,,,,,,,(MNY>8)|(TLT?[1014]),"TLT?[1010,1012]",, +10012,你父母又生了个女儿。,,,,,-1,,,,EVT?[10009],"(EVT?[10001,10014,10016,10017])|(TLT?[1011])",,MNY<2:10013 +10013,你的家庭更加困难,吃不饱饭。,,,,,,,,1,,,,MNY<1:10000 +10014,你父母又生了个儿子。,,,,,-1,,,,EVT?[10009],"(EVT?[10001,10014,10016,10017])|(TLT?[1011])",,MNY<2:10013 +10015,你父母并没有精心照顾你。,,,,-1,,-1,,,,"(EVT?[10015,10011,10019])|(TLT?[1015])",, +10016,你的母亲因病去世。,家庭更加困难了。,,,,-1,-1,,,(EVT?[10009])&(STR<3)&(SPR<3)&(MNY<3),(EVT?[10016])|(TLT?[1029]),EVT?[10017]:10000, +10017,你的父亲因病去世。,家庭更加困难了。,,,,-2,-1,,,(EVT?[10009])&(STR<3)&(SPR<3)&(MNY<3),(EVT?[10017])|(TLT?[1029]),EVT?[10016]:10000, +10018,你的父亲在种地时意外发现一箱金条。,家境有所好转。,,,,2,1,,,EVT?[10009],"EVT?[10018,10017]",, +10019,你的父母对你视若珍宝,呵护备至。,,,,1,,1,,,,"EVT?[10015,10016,10017,10019]",, +10020,你天资聪颖,但家人并不懂如何培养。,,,-1,,,,,,(EVT?[10009])&(INT>7),"EVT?[10021,10020]",, +10021,你天资聪颖,家人很关注你的学习。,,,1,,,,,,(EVT?[10009])&(INT>7)&(MNY>3),"EVT?[10020,10021]",, +10022,你什么事都要让着妹妹。,不开心。,,,,,-1,,,EVT?[10012],"(EVT?[10022,10014])|(TLT?[1015])",, +10023,你什么事都要让着弟弟。,不开心。,,,,,-1,,,EVT?[10014],(EVT?[10023])|(TLT?[1015]),, +10024,家人到城里务工。,你在农村留守。,,,,,-1,,,EVT?[10009],"EVT?[10016,10017,10024]",TLT?[1015]:10025, +10025,你和父母一同进了城。,,,,,,1,,1,,,, +10026,你比其他小朋友长得更可爱。,,,,,,,,,CHR>7,"EVT?[10026,10030]",, +10027,你的母亲救了个人,得到了很多感谢金。,家境有所好转。,,,,2,1,,,EVT?[10009],"EVT?[10027,10016]",, +10028,你很调皮,喜欢在家到处乱跑。,,,,1,,1,,,(STR>3)&(EVT?[10009]),"EVT?[10028,10052]",CHR>7:20029,STR<5:20028 +20028,有次你不小心摔倒撞到了脑袋,智力略微受损。,,,-1,,,,,1,,,, +20029,看在你长得可爱的份上家人不和你计较。,,,,,,,,1,,,, +10029,家人从小就培养你做家务。,,,,1,,,,,EVT?[10009],(EVT?[10029])|(TLT?[1015]),, +10030,你的脸意外被开水烫伤。,毁容了。,-3,,,,-2,,,(CHR>3)&(EVT?[10015]),EVT?[10030],,SPR<2:10062 +10031,你被邻居叔叔绑架了。,没勒索到钱,你被放了。,,,,,-1,,,(CHR>4)&(MNY>4)&(EVT?[10009]),EVT?[10031],"EVT?[10018,10027,10078]:10032","(CHR>7)&(EVT?[10002,10111]):10033" +10032,叔叔向你父母勒索了很多现金。,你被放了回家。,,,,-2,,,1,,,, +10033,叔叔侵犯了你。,你被放了回家。,,,,,-2,,1,,,,STR<3:10000 +10034,你和邻家小孩被定了娃娃亲。,,,,,,,,,(CHR>3)&(EVT?[10009]),"EVT?[10034,10024]",, +10035,你的大姐出嫁,收了很多彩礼。,,,,,1,,,,EVT?[10009],(EVT?[10035])|(TLT?[1011]),CHR>7:20035, +20035,你大姐偷偷告诉你,她一点也不喜欢男方。,,,,,,,,1,,,, +20036,你的大姐自杀了。,,,,,,-1,,,EVT?[20035],EVT?[20036],, +10036,你喜欢用父母的手机玩王者荣耀。,,,,,,1,,,MNY>2,"EVT?[10011,10024,10016,10017,10036,10037,10038]",INT>8:20037,INT>5:20038 +20037,你轻松打上了王者。,,,,,,1,,1,,,, +20038,你打上了黄金段位。,,,,,,,,1,,,, +10037,你喜欢用父母的手机刷抖音。,,,,,,1,,,MNY>2,"EVT?[10011,10024,10016,10017,10036,10037,10038]",, +10038,你玩父母手机时被诈骗。,损失了父母一年的心血。,,,,-1,-1,,,(MNY>2)&(INT<8),"EVT?[10011,10024,10016,10017,10038]",SPR<2:10062,INT>5:10040 +10039,你智力迟钝,仍然不会说话。,,,,,,,,,INT<3,EVT?[10039],, +10040,你告诉父母后,打电话举报。,损失被追回。,,,,1,,,1,,,, +10041,你和村里小孩打架。,战斗力提高了。,,,1,,,,,EVT?[10009],"EVT?[10002,10025]",STR<3:10000,STR>9:10042 +10042,你失手把一个小孩打死了。,父母赔了很多钱。,,,,-2,-1,,1,,,SPR<2:10062, +10043,你想天天吃肉,但父母告诉你吃不起。,,,,,,,,,(MNY<7)&(EVT?[10009]),EVT?[10043],, +10044,你喜欢去周围的小池塘边玩。,,,,,,,,,EVT?[10009],"EVT?[10044,10047,10025,10180]",, +10045,你有次去池塘边玩时掉进了水里。,差点淹死。,,,,,,,,"EVT?[10044,10047,10180]",EVT?[10045],TLT?[1016]:10046,STR<7:10000 +10046,还好你会游泳,没淹死。,,,,,,,,1,,,, +10047,你在周围的池塘钓到了几只小龙虾。,,,,,,1,,,EVT?[10009],"EVT?[10025,10047]",, +10048,你的绘画天赋好像不错。,,,,,,,,,,EVT?[10048],(EVT?[10009])&(CHR<3):20048, +20048,有亲戚笑你画的比长的好看多了。,,,,,,,,1,,,, +10049,你的音乐天赋好像不错。,,,,,,,,,,EVT?[10049],(EVT?[10009])&(CHR<3):20049, +20049,有亲戚遗憾地说你声音很好听,可惜长得太丑了。,,,,,,,,1,,,, +10050,你的数学天赋好像不错。,,,,,,,,,INT>8,EVT?[10050],, +10051,你偷了父母的零钱去买零食。,,,,,,,,,EVT?[10009],EVT?[10051],, +10052,你追得家里的动物鸡飞狗跳。,,,,,,,,,(STR>3)&(EVT?[10009]),EVT?[10052],, +10053,姐姐拿她的旧衣服给你穿。,,,,,,,,,(MNY<6)&(EVT?[10009]),(EVT?[10053])|(TLT?[1011]),(CHR>6)&(EVT?[10001]):20053, +20053,虽然你是男孩子,但并不抗拒。,,,,,,,,1,,,, +20054,你喜欢上了女装。,,1,,,,1,,,EVT?[20053],EVT?[20054],, +20055,你业余时间在家当女装主播。,,,,,1,,,,EVT?[20054],EVT?[20055],MNY<6:20056, +20056,并且有时还接单。,,,,,2,,,1,,,, +10054,你经常在田里玩。,,,1,,,,,,EVT?[10009],EVT?[10025],,INT>7:10055 +10055,你对自然规律有所观察。,,,,,,,,1,,,,INT>9:10056 +10056,你对植物和养生有所领悟。,,,,1,,,,1,,,, +10057,你开始下地干农活。,,,,,,,,,EVT?[10009],"EVT?[10057,10025]",, +10058,下暴雨,发洪水。,田都被淹了。,,,,-1,,,,EVT?[10009],"EVT?[10058,10025]",TLT?[1016]:10046,CHR<4:10000 +10059,大旱灾,颗粒无收。,,,,,-1,,,,EVT?[10009],"EVT?[10059,10025]",,MNY<3:10013 +10060,发生蝗灾,颗粒无收。,,,,,-1,,,,EVT?[10009],"EVT?[10060,10025]",,MNY<3:10013 +10061,一个人在家,非常寂寞。,,,,,,-1,,,EVT?[10024],EVT?[10025],,SPR<2:10062 +10062,你的情绪越来越低落,尝试自杀。,没有成功。,,,,,,,1,,,,SPR<1:10000 +10063,你的爷爷奶奶只想要男孩,把你活埋了。,,,,,,,,,(CHR<3)&(MNY<3)&(EVT?[10009]),"(EVT?[10063,10001])|(TLT?[1015])",,MNY<3:10000 +10064,你被卖给了人贩子。人贩子运送路上你很虚弱。,,,,,,,,,(STR<3)&((MNY<3)&(EVT?[10009]),"(EVT?[10064,10001,10019])|(TLT?[1015])",,STR<3:10000 +10065,空气很新鲜,生活很健康。,,,,1,,,,,EVT?[10009],"EVT?[10065,10025]",, +10066,你的生活很自由,没有什么束缚。,,,,,,1,,,EVT?[10009],EVT?[10066],, +10067,有一只鸟撞在了你家窗户上。,你把它养好后放了。,,,,,,,,EVT?[10009],EVT?[10067],,INT<6:10068 +10068,你把它炖了吃了。,,,,,,,,1,,,, +10069,平平淡淡,没有什么特别的事。,,,,,,,,,,,, +10070,可能是运气不佳,这年里有好多小事让你烦心。,,,,,,-1,,,,"EVT?[10646,10655]",,(INT<6)&(SPR<2):10062 +10071,比较顺风顺水,快乐的一年。,,,,,,1,,,,,, +10072,有天打雷,劈断了你家门口一棵树。,,,,,,,,,EVT?[10009],"EVT?[10072,10025]",, +10073,你意外挖到一个上了锁的盒子。,你打不开,只好扔了。,,,,,,,,EVT?[10009],"EVT?[10073,10025]",,INT>8:10074 +10074,你想方设法打开了锁。,里面有大量珠宝。,,,,2,2,,1,,,, +10075,你的运动天赋好像不错。,,,,,,,,,STR>8,EVT?[10075],INT<3:20075, +20075,可惜智力低了些。,,,,,,,,1,,,, +10076,你发现动物好像都不怎么害怕你。,,,,,,,,,(CHR>9)&(EVT?[10009]),"EVT?[10076,10052]",, +10077,你发现你和其他人的想法好像都不一样。,,,,,,,,,INT>9,"EVT?[10077,10090]",, +10078,你们家成为村里最富的家庭。,,,,,,,,,(MNY>7)&(EVT?[10009]),"EVT?[10078,10025]",, +10079,你的高颜值已经在周边家喻户晓。,,,,,,,,,(CHR>7)&(EVT?[10009]),EVT?[10079],, +10080,有人将你发在了网上,你小有名气。,很多人来你家拍短视频。,,,,,,,,(CHR>8)&(EVT?[10079]),EVT?[10080],, +10081,有星探和公司想带你去大城市发展。,你没有同意。,,,,,,,,EVT?[10080],EVT?[10081],,STR>5&MNY<5:10082 +10082,你来到了一线城市,住进了一家网络公司。,你开始直播生活。,,,,2,1,,1,,,, +10083,你过气了,被公司解除了协议。,你回到了乡下。,,,,,,,,EVT?[10082],EVT?[10083],,"(INT<6)&(EVT?[10002,10111]):10084" +10084,你过惯了奢靡的生活,无法再回乡下了。,你开始出卖身体维持生活质量。,,,-1,,1,,1,,,, +10085,你患上了艾滋病。,,,,-3,,-2,,,"EVT?[10084,10162,10219,20056]","(EVT?[10085,10087])|(TLT?[1017])",,STR<1:10000 +10086,你的病情逐渐加重。,,,,-3,,-1,,,EVT?[10085],,,STR<1:10000 +10087,你已经财务自由,不再出卖身体。,,,,,2,,,,"EVT?[10084,20056]",EVT?[10087],, +10088,你嫁给了一个普通的程序员。,,,,,,2,,,EVT?[10087],(EVT?[10088])|(TLT?[1027]),, +10089,国家扶贫,你家获得了帮助。,,,,,1,1,,,(MNY<4)&(EVT?[10009]),,, +10090,你的智力过高,被外星人抓走做实验。,又放了回来。,,-1,-1,,-1,,,INT>9,EVT?[10090],,STR<5:10000 +10091,你经常在家搞些小发明。,,,1,,,,,,(INT>7)&(EVT?[10009]),EVT?[10091],(INT>9)&(CHR<3):20091,MNY<3:20092 +20091,你发明了颜值提升机,大幅提高了颜值。,,5,,,,,,1,,,, +20092,你发明了许多有用的小东西,卖了不少钱。,,,,,2,,,1,,,, +10092,你被一只蛇咬了。,还好没有毒。,,,,,,,,EVT?[10009],EVT?[10092],,(STR<3)&(TLT![1022]):10000 +10093,你第一次被父母打。,,,,,,-1,,,,"(EVT?[10093,10016,10017,10144,10024])|(TLT?[1015])",, +10094,你第一次坐在躺椅上,看灿烂的银河星空,,,,,,1,,,EVT?[10009],"EVT?[10094,10025]",, +10095,你在晚上和小伙伴一起捉萤火虫。,,,,,,1,,,EVT?[10009],"EVT?[10095,10025]",, +10096,你听说国外发生了很多大事。,但感觉离你很遥远。,,,,,,,,EVT?[10009],EVT?[10096],, +10097,隔壁村的一个孩子淹死了。,你的父母一年都没让你去池塘玩。,,,,,,,,EVT?[10009],"EVT?[10097,10015,10016,10017,10024]",, +10098,你听了轮回转世的神话故事。,感觉好像似曾相识。,,,,,,,,INT>4,EVT?[10098],, +10099,你徒手抓住了一只老鼠。,,,,,,1,,,(INT>6)&(STR>6)&(EVT?[10009]),EVT?[10099],, +10100,你常常坐在家门口发呆,十分无聊。,,,,,,,,,EVT?[10009],"EVT?[10100,10036,10037]",, +10101,你开始上小学了。,,,,,,,,,EVT?[10009],EVT?[10101],, +10102,你在学校交到了新朋友。,,,,,,,,,(INT>2)&(CHR>2)&(EVT?[10101]),EVT?[10102],, +10103,你第一次接触英语。,,,,,,,,,EVT?[10101],EVT?[10103],, +10104,你们的数学老师是一个支教老师。,,,1,,,,,,EVT?[10101],"EVT?[10104,10025]",, +10105,学校老师太少,你们的体育老师还教你们语文课。,,,-1,,,,,,EVT?[10101],"EVT?[10105,10025]",, +10106,你期末考试考了100分。,,,,,,,,,(INT>7)&(EVT?[10101]),EVT?[10106],, +10107,你期末考试全都不及格。,老师来家访。,,,,,-1,,,(INT<3)&(EVT?[10101]),EVT?[10107],, +10108,你当上了体育课代表。,,,,,,,,,(STR>7)&(EVT?[10101]),EVT?[10108],, +10109,你在同学中非常受欢迎。,,,,,,1,,,(CHR>7)&(EVT?[10101]),"EVT?[10109,10113,10114]",, +10110,你出生了,是极为罕见的无性人。,,,,,,,,,,"TLT?[1003,1004,1024,1113]",, +10111,你出生了,是极为罕见的双性人。,,,,,,,,,,"TLT?[1003,1004,1025]",, +10112,同学总是欺负你。,还嘲笑你的长相。,,,,,-2,,,(CHR<3)&(EVT?[10101]),(EVT?[10112])|(TLT?[1037]),, +10113,同学总是欺负你。,还嘲笑你的成绩。,,,,,-2,,,(INT<3)&(EVT?[10101]),"(EVT?[10113,10109])|(TLT?[1037])",, +10114,同学总是欺负你。,嘲笑你不男不女。,,,,,-2,,,"(EVT?[10101])&(EVT?[10110,10111])","(EVT?[10114,10109])|(TLT?[1037])",, +10115,你和同桌偷偷谈起了恋爱。,,,,,,1,,,(INT>2)&(CHR>4)&(EVT?[10101]),"(EVT?[10115,10116,10110,10111])|(TLT?[1026,1027])",, +10116,你和同桌悄悄谈起了恋爱。,,,,,,1,,,(INT>1)&(CHR>3)&(EVT?[10101])&(TLT?[1028]),"(EVT?[10115,10116,10110,10111])|(TLT?[1026,1027])",, +10117,你当上了班长。,,,,,,1,,,(CHR>3)&(INT>6)&(EVT?[10101]),EVT?[10117],, +10118,你当上了领操员。,,,,,,,,,(CHR>3)&(STR>6)&(EVT?[10101]),EVT?[10118],, +10119,你为班级出了一次黑板报。,,,,,,,,,(EVT?[10048])&(EVT?[10101]),EVT?[10119],, +10120,你们班收到了捐赠的书籍文具。,,,,,,,,,EVT?[10101],"EVT?[10120,10025,10120]",, +10121,你们班建立了读书角。,,,,,,,,,EVT?[10101],EVT?[10121],, +10122,学校里盖了一座新楼。,,,,,,,,,EVT?[10101],"EVT?[10122,10025]",, +10123,村中阿婆家新盖了小洋房。,听说是孩子在外面赚了大钱。,,,,,,,,EVT?[10009],"EVT?[10123,10025]",, +10124,夏日的一天村里鞭炮齐鸣。,听说是人家的孩子考上了重点大学。,,,,,,,,EVT?[10009],"EVT?[10124,10025]",, +10125,你的父亲意外去世。,,,,,-2,-2,,,EVT?[10009],"(EVT?[10017,10125])|(TLT?[1029])",, +10126,你的母亲意外去世。,,,,,-1,-2,,,EVT?[10009],"(EVT?[10016,10126])|(TLT?[1029])",, +10127,你的爷爷因病去世。,,,,,,-1,,,EVT?[10009],EVT?[10127],, +10128,你的奶奶因病去世。,,,,,,-1,,,EVT?[10009],EVT?[10128],, +10129,你很努力学习,但成绩就是提不上去。,,,,,,-1,,,(INT<4)&(EVT?[10101]),EVT?[10129],, +10130,今年大丰收,而且你家种的菜也涨价了。,,,,,1,1,,,EVT?[10009],EVT?[10130],, +10131,你获得了第一份奖状。,,,,,,1,,,(INT>4)&(EVT?[10101]),"EVT?[10131,10132,10133]",, +10132,你获评三好学生。,,,,,,1,,,(STR>5)&(INT>5)&(EVT?[10101]),,, +10133,你获评三好标兵。,,,,,,2,,,(STR>7)&(INT>7)&(EVT?[10101]),,, +10134,有同学在班上炫耀新玩具,被老师没收了。,,,,,,,,,EVT?[10101],EVT?[10134],, +10135,你前排的同学在课上偷偷玩手机。,,,,,,,,,EVT?[10101],EVT?[10135],, +10136,老师在班上进行了IQ测试。,你获得了145分,,,,,,,,(INT>7)&(EVT?[10101]),EVT?[10136],, +10137,老师在班上进行了IQ测试。,你获得了135分,,,,,,,,(INT>6)&(EVT?[10101]),EVT?[10137],, +10138,努力学习的一年,能感受到水平的提高。,,,1,,,,,,(INT>3)&(EVT?[10101]),EVT?[10138],, +10139,没有用功学习的一年,能感受到水平的下降。,,,-1,,,,,,(INT<8)&(EVT?[10101]),EVT?[10139],, +10140,你家养的狗被人毒死了。,,,,,,-1,,,EVT?[10009],"(EVT?[10140,10141])|(TLT?[1030])",, +10141,你家养的猫被人毒死了。,,,,,,-1,,,EVT?[10009],"(EVT?[10140,10141])|(TLT?[1030])",, +10142,家里老鼠蟑螂泛滥成灾。,,,,,,,,,(MNY<5)&(EVT?[10009]),,, +10143,隔壁的村花和邻居叔叔结婚了。,,,,,,,,,EVT?[10009],"EVT?[10143,10031,10025]",, +10144,你天天被父母殴打。,,,,,,-2,,,EVT?[10009],"(EVT?[10093,10016,10019,10017,10144,10125,10126,10024])|(TLT?[1015])",, +10145,成为了弹弓高手,一弹一鸟。,,,,,,,,,(INT>3)&(STR>5)&(EVT?[10009]),"EVT?[10145,10002,10025]",, +10146,在田里插秧时,总是被水蛭叮咬。,,,,,,,,,EVT?[10009],"EVT?[10146,10002,10025]",, +10147,村子里基本没几个年轻人了。,,,,,,,,,EVT?[10009],"EVT?[10147,10025]",, +10148,你家装上了全村唯一的wifi,总有人来问密码。,,,,,,,,,(MNY>6)&(EVT?[10009]),"EVT?[10148,10024]",, +10149,教室里唯一较好的窗户也破了。,下雨天靠窗完全不能坐人了。,,,,,,,,EVT?[10101],"EVT?[10149,10025]",, +10150,你家的屋檐上多了个燕子窝。,,,,,,,,,EVT?[10009],EVT?[10150],, +10151,教室窗外多了个马蜂窝。,,,,,,,,,EVT?[10101],EVT?[10151],, +10152,你的床板塌了,只能睡桌椅上了。,,,,-1,,,,,EVT?[10009],EVT?[10152],, +10153,你突然生了场大病。,,,,-2,-1,-1,,,(STR<5)&(EVT?[10009]),EVT?[10153],,STR<1:10000 +10154,你总是遭遇校园暴力。,,,,,,-2,,,(STR<6)&(EVT?[10009]),"(EVT?[10109,10154])|(TLT?[1037])",,SPR<2:10062 +10155,你家人让你能辍学打工,为弟弟攒彩礼钱。,,,,,,,,,(EVT?[10014])&(EVT?[10101]),"(EVT?[10155,10156])|(TLT?[1015])",, +10156,你家人让你能辍学打工,补贴家用。,,,,,,,,,(MNY<5)&(EVT?[10101]),"(EVT?[10155,10156])|(TLT?[1015])",, +10157,你在城里找到了一份工作。,,,,,,,,,"EVT?[10155,10156,10025]",EVT?[10157],, +10158,你买彩票中了个小奖。,虽然钱不多但很快乐。,,,,,1,,,EVT?[10157],EVT?[10158],, +10159,你买彩票中了个大奖。,,,,,2,2,,,EVT?[10157],EVT?[10159],, +10160,你留了一级。,,,,,,,,,(INT<4)&(EVT?[10101]),"EVT?[10160,10025,10156,10155]",, +10161,你遭到了同事的性骚扰。,,,,,,-1,,,(CHR>6)&(EVT?[10157]),,, +10162,你遭到了同事的性侵。,,,,,,-2,,,(STR<5)&(CHR>8)&(EVT?[10157]),,, +10163,过年时拜访了几十家亲戚。,,,,,,,,,(STR>1)&(EVT?[10009]),"EVT?[10163,10025,10156,10155]",, +10164,家里茅坑废弃了,换成了马桶。,,,,,,,,,(MNY>4)&(EVT?[10009]),"EVT?[10164,10025,10156,10155]",, +10165,通了自来水,家里的井不再使用。,,,,,,,,,(MNY>3)&(EVT?[10009]),"EVT?[10164,10165,10025,10156,10155]",, +10166,半夜发烧,爸妈路边等公交车送你去县城医院.,,,,,,,,,(STR<5)&(MNY<5)&(EVT?[10009]),"EVT?[10166,10015,10016,10017,10125,10126]",, +10167,用牙齿咬欺凌自己的人,反而被告老师。,很委屈。,,,,,-1,,,"EVT?[10154,10112,10113,10114]",EVT?[10167],, +10168,被老人讲的鬼故事吓到。,,,,,,,,,EVT?[10009],"EVT?[10168,10127,10128]",, +10169,买小卖部的零食吃,第二天拉肚子发烧。,,,,,,,,,(STR<5)&(MNY>2)&(EVT?[10009]),EVT?[10169],, +10170,被同学取难听的外号。,,,,,,-1,,,(STR<9)&(MNY<9)&(EVT?[10101]),"(EVT?[10170,10109])|(TLT?[1037])",, +10171,过年玩鞭炮被炸伤。,,,,,,,,,EVT?[10009],"EVT?[10171,10002]",, +10172,在外面玩到晚上,被爸妈抓了回来。,,,,,,,,,EVT?[10009],"EVT?[10172,10015,10016,10017,10125,10126]",, +10173,学自行车摔得膝盖流血。,没学会。,,,,,,,,(STR<4)&(EVT?[10009]),TLT?[1038],, +10174,尝试自学自行车。,没学会。,,,,,,,,(INT<5)&(STR<5)&(EVT?[10009]),TLT?[1038],, +10175,尝试自学自行车。,学会了。,,,,,,,,(INT>1)&(STR>1)&(EVT?[10009]),EVT?[10175],, +10176,想买和同学同款的玩具,但买不起。,,,,,,,,,(MNY<4)&(EVT?[10101]),EVT?[10176],, +10177,被爸爸带去打麻将到半夜,睡着了还没回家。,,,,,,,,,EVT?[10009],"EVT?[10177,10015,10017,10125]",, +10178,学着帮家里喂牲畜。,,,,,,,,,EVT?[10009],EVT?[10178],, +10179,下完雨退潮去河边捡田螺。,,,,,,,,,EVT?[10009],EVT?[10179],, +10180,去池塘电鱼吃。,,,,,,,,,EVT?[10009],"EVT?[10180,10025,10156,10155]",, +10181,上山剪橘子差点掉下山。,,,,,,,,,EVT?[10009],"EVT?[10181,10025,10156,10155]",, +10182,被路上的狗堵路追着跑。,,,,,,,,,(STR>2)&(CHR<9)&(EVT?[10009]),"EVT?[10182,10183]",, +10183,被野狗咬了,去县城打狂犬疫苗。,,,,,,-1,,,(MNY>2)&(CHR<9)&(EVT?[10009]),EVT?[10183],, +10184,考上县城初中,每天要走很远去上学。,,,,,,,,,(INT>4)&(MNY>2)&(EVT?[10101]),"EVT?[10184,10025,10156,10155]",, +10185,考上县城初中,但是上不起。,,,,,,,,,(INT>4)&(MNY<3)&(EVT?[10101]),"EVT?[10185,10025,10156,10155]",, +10186,班上大多数都是混混的,课都上不成。,,,,,,,,,EVT?[10101],"EVT?[10184,10025,10156,10155]",TLT?[1108]:20186, +20186,你的性格也很叛逆,和他们一见如故。,,,,,,,,1,,,, +10187,被坏同学影响,开始抽烟喝酒去游戏厅。,,,,,,1,,,EVT?[10101],"EVT?[10184,10187,10025,10156,10155]",, +10188,开始去网吧,沉迷游戏。,,,,,,1,,,EVT?[10009],"EVT?[10188,10194,10002]",, +10189,沉迷二次元,天天追新番。,,,,,,1,,,"EVT?[10007,10008]",EVT?[10189],, +10190,游戏水平很高,远近网吧闻名。,网吧老板允许你免费上网。,,,,,1,,,"(STR>2)&(INT>7)&(EVT?[10188,10194])",EVT?[10190],, +10191,被公司发掘,进入电竞培训队。,前往大城市。,,,,,,,,"EVT?[10190,10942]",EVT?[10191],, +10192,开始为战队打比赛。,但并没有打出什么成绩。,,,-1,,-1,,,EVT?[10191],EVT?[10192],TLT?[1039]:10193,SPR>6:10193 +10193,连续夺得大奖。,,,,-2,2,2,,1,,,, +10194,开始去网吧,沉迷游戏。,,,,,,,,,(TLT?[1039])&(EVT?[10009]),"EVT?[10194,10188]",, +10195,巅峰时期退役。,转行游戏主播。,,,,,,,,EVT?[10193],"EVT?[10195,10196,10197]",, +10196,继续打比赛。,,,,-1,,,,,(STR>3)&(EVT?[10192]),"EVT?[10195,10196,10197]",, +10197,退役。,转行游戏主播。,,,,,,,,EVT?[10192],"EVT?[10195,10196,10197]",, +10198,中考考的很差,没考上高中。,,,,,,,,,"(EVT?[10009])&(INT<4)&(EVT?[10188,10187,10186,10189])","EVT?[10198,10199,10200,10025,10156,10155]",, +10199,中考考的一般,上了县里的高中。,,,,,,,,,EVT?[10101],"(INT<3)|(EVT?[10198,10200,10199,10025,10156,10155])",, +10200,中考考的很好,上了城里的好高中。,,,,,,,,,(MNY>2)&(INT>5)&(EVT?[10101]),"(INT<6)|(EVT?[10198,10200,10199,10025,10156,10155])",, +10201,打篮球、踢足球受伤。,,,,,,,,,(STR>4)&(MNY>2)&(EVT?[10101]),"(STR>9)|(EVT?[10201,10002])",, +10202,被视察的体校教练发掘。去体校训练。,,,,,,,,,(STR>6)&(EVT?[10184]),EVT?[10202],, +10203,进入省队。,刻苦训练。,,,,,,,,"EVT?[10202,10939]","EVT?[10203,10204]",,SPR>8:10204 +10204,表现突出,进入国家队。,,,,,,1,,1,,,, +10205,刻苦训练。,,,,1,,,,,EVT?[10203],"EVT?[10205,10204]",,SPR>8:10204 +10206,刻苦训练。,,,,,,,,,EVT?[10203],EVT?[10206],, +10207,参加奥运会。,夺得奖牌。,,,,1,1,,,EVT?[10204],,,SPR>9:10208 +10208,夺得金牌。,,,,,,1,,1,,,,SPR>10:10209 +10209,并打破世界纪录。,,,,,,1,,1,,,, +10210,退役。,开始当教练。,,,,,,,,EVT?[10203],EVT?[10210],, +10211,和男同学谈恋爱。,,,,,,1,,,"(EVT?[10009])&((EVT?[10002,10110,10111])|(TLT?[1026]))","(EVT?[10211,10198,10025,10156,10155])|(TLT?[1027])",, +10212,和女同学谈恋爱。,,,,,,1,,,"(EVT?[10009])&((EVT?[10001,10110,10111])|(TLT?[1026]))","(EVT?[10212,10198,10025,10156,10155])|(TLT?[1027])",, +10213,有同学翻学校围墙逃课,意外身亡。,,,,,,,,,EVT?[10101],EVT?[10213],TLT?[1108]:20213, +20213,由于你喜欢没事找事,你也试着翻围墙,结果也死了。,,,,,,,,1,,,EVT?[10101]:10000, +10214,性启蒙。,,,,,,,,,EVT?[10009],EVT?[10214],, +10215,遇上街上的黑社会对拼,很震撼。,,,,,,,,,EVT?[10009],"EVT?[10215,10185]",TLT?[1108]:20215, +20215,你想离近点看,结果被流弹击中。,,,,,,,,1,,,EVT?[10009]:10000, +10216,坐公交车被劫车收保护费。,,,,,,,,,EVT?[10009],"EVT?[10216,10185]",, +10217,被同学骗沾染毒品。,,,,-2,-1,1,,,"EVT?[10009,10185,10186,10187,10188]",(EVT?[10217])|(TLT?[1040]),,STR<1:10000 +10218,学会赌博。,,,,,-2,-1,,,"EVT?[10009,10185,10186,10187,10188]",(EVT?[10218])|(TLT?[1040]),, +10219,被同学带去嫖娼。,,,,,,1,,,"(EVT?[10009,10185,10186,10187,10188])&(EVT?[10001])",,, +10220,你吸毒被捕。,进了戒毒所。,,,-1,-1,-1,,,EVT?[10217],EVT?[10220],SPR<2:10062,STR<1:10000 +10221,你日渐消瘦。,,,,-1,,-1,,,EVT?[10217],,SPR<2:10062,STR<1:10000 +10222,你戒掉了毒品。,,,,,,-1,,,EVT?[10217],EVT?[10222],,SPR<2:10062 +10223,你四处借贷,倾家荡产。,,,,,-2,-2,,,EVT?[10218],EVT?[10223],SPR<2:10062,MNY<2:10013 +10224,去城里看亲戚。,你很羡慕他们家什么都有。,,,,,,,,(MNY<5)&(EVT?[10009]),EVT?[10224],, +10225,到同学家借书看。,,,,,,,,,"(CHR>3)&(MNY<5)&(EVT?[10199,10200,10184])",EVT?[10225],, +10226,混不下去了,回老家种田。,,,,,,,,,"(INT<8)&(EVT?[10025,10156,10155])",EVT?[10226],, +10227,有同学退学结婚了。,,,,,,,,,EVT?[10101],EVT?[10227],, +10228,你开始相亲。,,,,,,,,,EVT?[10222],"(EVT?[10228,10229])|(TLT?[1027])",, +10229,你结婚了。,,,,,,1,,,EVT?[10228],"EVT?[10229,11171,11093,10610,10611,10612]",, +10230,你被家人逼着去和一个不喜欢的村民结婚。,,,,,,-2,,,"EVT?[10198,10155,10156,10226]","(EVT?[10230,10016,10017])|(TLT?[1015])",TLT?[1027]:10232,SPR<2:10062 +10231,你和村中一个你喜欢的姑娘在一起了。,,,,,,2,,,"(EVT?[10198,10155,10156])&((EVT?[10001,10110,10111])|(TLT?[1026]))","(EVT?[10230,10231])|(TLT?[1027])",, +10232,你誓死不从,自杀了。,,,,,,,,1,,,TLT?[1027]:10000, +10233,你和隔壁村一个你喜欢的小伙在一起了。,,,,,,2,,,"(EVT?[10198,10155,10156])&((EVT?[10002,10110,10111])|(TLT?[1026]))","(EVT?[10230,10231])|(TLT?[1027])",, +10234,你和另一个游戏主播结婚了。,,,,,,1,,,"EVT?[10195,10197]",(EVT?[10234])|(TLT?[1027]),, +10235,你找到了一个适合的人,结婚了。,,,,,,1,,,(EVT?[10210])&(EVT?[10009]),(EVT?[10235])|(TLT?[1027]),, +10236,你年龄大了,随便找了一个将就着结婚了。,,,,,,,,,EVT?[10009],"(EVT?[10235,10236,10234,10233,10231,10230,10229,10610,10611,10612,10088])|(TLT?[1027])",, +10237,高考,你考上了专科。,,,,,,,,,(INT<6)&(EVT?[10199]),"EVT?[10237,10238,10239,10468]",, +10238,高考,你考上了当地的普通本科。,,,,,,,,,"(INT>5)&(EVT?[10199,10200])","(INT>7)|(EVT?[10238,10237,10239,10468])",, +10239,高考,你考上了大城市的重点本科。,,,,,,1,,,"(INT>7)&(EVT?[10199,10200])","EVT?[10239,10238,10237,10468]",, +10240,你参加了社会实践。,,,,,,,,,"EVT?[10237,10238,10239]",EVT?[10240],, +10241,你参加了志愿者活动。,,,,,,,,,"EVT?[10237,10238,10239]",EVT?[10241],, +10242,发现班上至少一半同学天天翘课。,,,,,,,,,"EVT?[10237,10238,10239]",EVT?[10242],, +10243,你漏了一节思修课没上,打开了开关。,之后经常翘课了。,,,,,,,,"EVT?[10237,10238,10239]",EVT?[10243],, +10244,加入了学生会。,,,,,,,,,"EVT?[10237,10238,10239]",EVT?[10244],, +10245,和同院的一个女生谈恋爱。,,,,,,1,,,"(EVT?[10237,10238,10239])&((EVT?[10001,10110,10111])|(TLT?[1026]))",(EVT?[10245])|(TLT?[1027]),, +10246,和同院的一个男生谈恋爱。,,,,,,1,,,"(EVT?[10237,10238,10239])&((EVT?[10002,10110,10111])|(TLT?[1026]))",(EVT?[10246])|(TLT?[1027]),, +10247,遭到了附近的恶霸殴打,报警不管,举报无门。,只能忍气吞声。,,,,,-2,,,(STR<7)&(EVT?[10009]),EVT?[10247],SPR<3:10248, +10248,你怀恨在心,买了水果刀将恶霸捅死了。,你被刑事拘留。,,,,,1,,1,,,, +10249,恶霸家手眼通天,你被判处死刑。,,,,,,-2,,,EVT?[10248],EVT?[10249],EVT?[10248]:10000, +10250,你和大学对象步入了婚姻的殿堂。,,,,,,1,,,"EVT?[10245,10246]","(EVT?[10250,10251])|(TLT?[1027])",, +10251,你开始相亲。,,,,,,,,,"EVT?[10237,10238,10239]","(EVT?[10251,10236,10229,10250,10245,10246])|(TLT?[1027])",, +10252,你始终找不到合适的对象。,,,,,,-1,,,EVT?[10251],,, +10253,你的父亲因病去世。,母亲也随之去世。,,,,,,,,EVT?[10009],"EVT?[10253,10016,10017,10125,10126,10254,10255,10256,10257]",, +10254,你的母亲发生车祸去世。,,,,,,,,,EVT?[10009],"(EVT?[10253,10016,10126,10254,10257])|(TLT?[1043])",, +10255,你的父亲意外去世。,,,,,,,,,EVT?[10009],"EVT?[10253,10017,10125,10255,10256]",, +10256,你的父亲突发心血管疾病去世。,,,,,,,,,EVT?[10009],"(EVT?[10253,10017,10125,10255,10256])|(TLT?[1044])",, +10257,你的母亲重病去世。,,,,,,,,,EVT?[10009],"EVT?[10253,10016,10126,10254,10257]",, +10258,你想要参军。,,,,,,,,,"(STR>5)&(EVT?[10009,10940])","EVT?[10198,10199,10200,10025,10156,10155,10258]",, +10259,你正式入伍。,,,,,,,,,EVT?[10258],"EVT?[10259,10468]",, +10260,平淡但不平凡的军旅生涯。,,,,,,,,,EVT?[10259],,, +10261,你比其他战士更能吃苦耐劳。,,,,,,1,,,(STR>7)&(EVT?[10259]),EVT?[10261],, +10262,你的智慧让其他人刮目相看。,,,,,,1,,,(INT>7)&(EVT?[10259]),EVT?[10262],, +10263,你的颜值让同性都忍不住多看几眼。,,,,,,,,,(CHR>7)&(EVT?[10259]),EVT?[10263],, +10264,你退伍了。,在县城当上了保安。,,,,1,,,,EVT?[10259],EVT?[10264],TLT?[1045]:10265, +10265,当上了村委书记。,,,,,2,,,1,,,, +10266,你和隔壁村老村委书记家的孩子结婚了。,,,,,,,,,EVT?[10265],(EVT?[10266])|(TLT?[1027]),, +10267,你在一次演习中发生了意外。,运气好,没有受伤。,,,,,,,,EVT?[10259],EVT?[10267],INT<6:10000, +10268,你们生了一个女儿。,,,,,,1,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]","(TLT?[1041,1046,1026])|(EVT?[10269,10110,10279])",, +10269,你们生了一个儿子。,,,,,,1,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]","(TLT?[1041,1046,1026])|(EVT?[10269,10110,10279])",, +10270,因为你不想生孩子,你们离婚了。,,,,,,,,,"(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1041])","(EVT?[10270,10270,10271,11294,11295,10281,10282,20076,10110,10279])|(TLT?[1123])",, +10271,生不出孩子,医院检查发现你功能有问题。,你们离婚了。,,,,,,,,"(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1046])","(EVT?[10271,10279,10270,10271,11294,20076,11295,10281])|(TLT?[1123])",, +10272,你们领养了一个孩子。,,,,,,1,,,"(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1026])","EVT?[10272,11295,10281,10282,10279]",, +10273,普通的家庭生活。,你感觉时间过得越来越快。,,,,,,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]",EVT?[10279],, +10274,你感觉生活越来越无趣,你很怀念小时候。,,,,,,,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]",,, +10275,家庭琐事很多,你们经常吵架。,,,,,,-1,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]","EVT?[10279,11295,10281,20076,10270,10282,10271,11294,20076]",(TLT![1123])&(SPR<3):20076, +10276,结婚周年纪念日,你们分床而睡。,,,,,,,,,"(SPR<4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])","EVT?[10276,11295,10281,10282,10279,20076,10270,10271,11294,20076]",(TLT![1123])&(SPR<3):20076, +20076,你们离婚了。,,,,,,,,1,,,, +10277,小时候一件小事你都能记很久。,现在你却连上个月的事都记不清了。,,,-1,,,,,"(INT<7)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])",EVT?[10277],, +10278,你感觉自己老得越来越快,颜值不再。,,-1,,,,,,,"(CHR>4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])",,, +10279,你的爱人病重。,,,,,-1,-1,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]","(EVT?[10279,20076])|(TLT?[1047])",, +10280,你的爱人病重。,,,,,,-1,,,TLT?[1047],"EVT?[10280,20076]",, +10281,你的爱人去世了。,,,,,,-1,,,"EVT?[10279,10280]","EVT?[10281,20076]",, +10282,你的爱人发生车祸去世。,,,,,,-2,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]","(EVT?[10282,10279,20076])|(TLT?[1043,1047])",, +10283,孩子经常和你吵架。,,,,,,-1,,,"EVT?[10268,10269,10272]",,, +10284,孩子长得越来越可爱。,,,,,,1,,,"(CHR>5)&(EVT?[10268,10269,10272])",,, +10285,孩子很聪明。,,,,,,1,,,"(INT>6)&(EVT?[10268,10269,10272])",EVT?[10285],, +10286,你有孙子了。,,,,,,1,,,"EVT?[10268,10269,10272]","EVT?[10286,20076]",, +10287,你有孙女了。,,,,,,1,,,"EVT?[10268,10269,10272]","EVT?[10287,20076]",, +10288,你为自己而活,过得很快乐。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",,, +10289,你遭遇了严重的车祸。,,,,,,,,,EVT?[10009],TLT?[1043],EVT?[10009]:10000, +10290,你查出了晚期癌症。,,,,,,,,,(STR<6)&(EVT?[10009]),EVT?[10290],EVT?[10009]:10000, +10291,你突发心血管疾病去世。,,,,,,,,,(STR<6)&(EVT?[10009]),TLT?[1044],EVT?[10009]:10000, +10292,你的身体越来越差了。,,,,-1,,,,,(STR<6)&(EVT?[10009]),EVT?[10292],, +10293,你经常锻炼,身体还不错。,,,,,,1,,,(STR>5)&(EVT?[10009]),EVT?[10293],, +10294,你在睡梦中安然离世。,,,,,,1,,,(STR>5)&(EVT?[10009]),(TLT?[1048])|(EVT?[10294]),EVT?[10009]:10000, +10295,你后悔年轻时没有做更多的事。,大人的生活真的很无趣。,,,,,,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]",EVT?[10295],(STR<5)&(MNY>5):20296, +20296,你花钱在周边转了转,但没余力走更远了。,,,,,-1,,,,,,, +10296,你攒了不少钱。,,,,,1,,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10296],, +10297,你去南方旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10297],, +10298,你去北方旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10298],, +10299,你去西藏旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10299],, +10300,你去新疆旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10300],, +10301,你去爬黄山。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10301],, +10302,你去爬泰山。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10302],, +10303,你去杭州看西湖。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10303],, +10304,你去蒙古看草原。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10304],, +10305,你去北京旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10305],, +10306,你去上海旅游。,,,,,,1,,,"(TLT?[1041,1027])&(EVT?[10009])",EVT?[10306],, +10307,你突然发现,从你结婚那天起,你的人生就结束了。,,,,,,,,,"(SPR<4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])",EVT?[10307],, +10308,你小病不断。,,,,,,,,,(STR<5)&(EVT?[10009]),EVT?[10308],, +10309,你近视了。,,,,,,,,,(STR<9)&(EVT?[10009]),EVT?[10309],, +10310,你老花眼了。,,,,,,,,,(STR<5)&(EVT?[10009]),EVT?[10310],, +10311,你换了好几颗牙。,,,,,,,,,EVT?[10009],EVT?[10311],, +10312,你掉了好几颗牙。,,,,,,,,,"(STR<9)&(EVT?[10009,10010])",EVT?[10312],, +10313,你耳朵听不清了。,,,,,,,,,"(STR<9)&(EVT?[10009,10010])",EVT?[10313],, +10314,你有点失忆,忘掉了不少东西。,,,-3,,,1,,,"(INT>2)&(EVT?[10009,10010])",(INT>7)|(EVT?[10314]),, +10315,你瘫痪了。,,,,,,,,,(STR<3)&(EVT?[10009]),EVT?[10315],, +10316,和你同一代的熟人开始纷纷离世。,,,,,,,,,"EVT?[10009,10010]",EVT?[10316],, +10317,你发现自己成了一个无趣的中年人。,,,,,,,,,"EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]",EVT?[10317],INT>5:20317, +20317,为了能和年轻人有共同语言,你开始了解潮流。,,,,,,,,1,,,, +10318,时代在进步,你完全搞不懂新的电子产品。,,,,,,,,,(INT<7)&(EVT?[10009]),EVT?[10318],, +10319,你听不懂年轻人在说什么。,,,,,,,,,(INT<9)&(EVT?[10009]),EVT?[10319],, +10320,你的颜值仍然过人。,,,,,,,,,"(CHR>6)&(EVT?[10009,10010])",EVT?[10320],, +10321,"时代在进步,新一代VR设备你仍然了如指掌。",,,,,,,,,(MNY>4)&(INT>7)&(EVT?[10009]),EVT?[10321],, +10322,你发现孩子不是亲生的。,你装作不知道。,,,,,-2,,,"EVT?[10268,10269]","EVT?[10322,10002]",SPR<2:10062, +10323,你从盒子中获得了练气法门,突破到凝气一层。,寿元提升到200年。,3,3,3,,2,,,TLT?[1048],EVT?[10323],, +10324,练气。,体质提升。,,,1,,,,,TLT?[1048],EVT?[10333],, +10325,你突破到凝气二层。,,,,1,,,,,(EVT?[10323])&(STR>10)&(TLT?[1048]),EVT?[10325],, +10326,你突破到凝气三层。,,,,1,,,,,(EVT?[10325])&(STR>12)&(TLT?[1048]),EVT?[10326],, +10327,你突破到凝气四层。,,,,1,,,,,(EVT?[10326])&(STR>15)&(TLT?[1048]),EVT?[10327],, +10328,你突破到凝气五层。,,,,1,,,,,(EVT?[10327])&(STR>20)&(TLT?[1048]),EVT?[10328],, +10329,你突破到凝气六层。,,,,1,,,,,(EVT?[10328])&(STR>25)&(TLT?[1048]),EVT?[10329],, +10330,你突破到凝气七层。,,,,1,,,,,(EVT?[10329])&(STR>30)&(TLT?[1048]),EVT?[10330],, +10331,你突破到凝气八层。,,,,1,,,,,(EVT?[10330])&(STR>38)&(TLT?[1048]),EVT?[10331],, +10332,你突破到凝气九层。,,,,1,,,,,(EVT?[10331])&(STR>50)&(TLT?[1048]),EVT?[10332],, +10333,你突破到筑基一层。,寿元提升到300年。,,1,10,,,,,(EVT?[10332])&(STR>100)&(TLT?[1048]),EVT?[10333],, +10334,你捡到异果,体质大幅提升。,,,,10,,,,,TLT?[1048],,, +10335,你发现灵气浓郁之处,体质大幅提升。,,,,20,,,,,TLT?[1048],,, +10336,锻体。,体质提升。,,,2,,,,,(EVT?[10333])&(STR>100)&(TLT?[1048]),"EVT?[10345,10361]",, +10337,你突破到筑基二层。,,,,2,,,,,(EVT?[10333])&(STR>120)&(TLT?[1048]),EVT?[10337],, +10338,你突破到筑基三层。,,,,2,,,,,(EVT?[10337])&(STR>140)&(TLT?[1048]),EVT?[10338],, +10339,你突破到筑基四层。,,,,2,,,,,(EVT?[10338])&(STR>160)&(TLT?[1048]),EVT?[10339],, +10340,你突破到筑基五层。,,,,2,,,,,(EVT?[10339])&(STR>190)&(TLT?[1048]),EVT?[10340],, +10341,你突破到筑基六层。,,,,2,,,,,(EVT?[10340])&(STR>220)&(TLT?[1048]),EVT?[10341],, +10342,你突破到筑基七层。,,,,2,,,,,(EVT?[10341])&(STR>250)&(TLT?[1048]),EVT?[10342],, +10343,你突破到筑基八层。,,,,2,,,,,(EVT?[10342])&(STR>280)&(TLT?[1048]),EVT?[10343],, +10344,你突破到筑基九层。,,,,2,,,,,(EVT?[10343])&(STR>320)&(TLT?[1048]),EVT?[10344],, +10345,你突破到金丹一层。,寿元提升到400年。,,2,20,,,,,(EVT?[10344])&(STR>400)&(TLT?[1048]),"EVT?[10345,10361]",, +10346,寿元终。,,,,,,,,,TLT?[1048],EVT?[10333],TLT?[1048]:10000, +10347,寿元终。,,,,,,,,,TLT?[1048],"EVT?[10345,10361]",TLT?[1048]:10000, +10348,你突破到金丹二层。,,,1,3,,,,,"(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])",EVT?[10348],, +10349,图你美色,一个境界极高的人强行和你双修。,体质大幅提升。,,,100,,,,,(EVT?[10333])&(CHR>10)&(TLT?[1048]),EVT?[10349],, +10350,你发现一种加快修行速度的方法。,体质大幅提升。,,,50,,,,,(EVT?[10333])&(INT>10)&(TLT?[1048]),,, +10351,周天经脉通畅,体质再次提升。,,,,5,,,,,(EVT?[10333])&(STR>100)&(TLT?[1048]),,, +10352,你突破到金丹三层。,,,1,3,,,,,(EVT?[10348])&(STR>500)&(INT>15)&(TLT?[1048]),EVT?[10352],, +10353,你突破到金丹四层。,,,1,3,,,,,(EVT?[10352])&(STR>550)&(INT>20)&(TLT?[1048]),EVT?[10353],, +10354,你突破到金丹五层。,,,1,3,,,,,(EVT?[10353])&(STR>600)&(INT>30)&(TLT?[1048]),EVT?[10354],, +10355,你突破到金丹六层。,,,1,3,,,,,(EVT?[10354])&(STR>650)&(INT>40)&(TLT?[1048]),EVT?[10355],, +10356,你突破到金丹七层。,,,1,3,,,,,(EVT?[10355])&(STR>700)&(INT>50)&(TLT?[1048]),EVT?[10356],, +10357,你突破到金丹八层。,,,1,3,,,,,(EVT?[10356])&(STR>750)&(INT>65)&(TLT?[1048]),EVT?[10357],, +10358,你突破到金丹九层。,,,1,3,,,,,(EVT?[10357])&(STR>850)&(INT>80)&(TLT?[1048]),EVT?[10358],, +10359,你遭到元婴大能截杀。,,,,,,,,,TLT?[1048],"EVT?[10359,10365]",STR>1000:10360,STR<1000:10000 +10360,你将其越级反杀。,得到大量宝物。属性提升。,,50,500,,2,,1,,,, +10361,你服用了祖传药丸,突破到了金丹一层。,并且你有两枚金丹。寿元提升到500年。,,50,500,,1,,,(EVT?[10344])&(TLT?[1048])&(TLT?[1065]),"EVT?[10361,10345]",, +10362,蕴丹。,体质、智力提升。,,1,3,,,,,"(EVT?[10345,10361])&(STR>400)&(TLT?[1048])",EVT?[10365],, +10363,你加入了一个隐世宗派成为长老。,得到大量修炼资源。,,10,100,,,,,"(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])",EVT?[10363],, +10364,你斩杀了一个筑基修士,获得少量资源。,,,,10,,,,,"(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])",,, +10365,你突破到元婴一层。,寿元提升到500年。,,30,,,,,,(EVT?[10358])&(STR>1000)&(INT>100)&(TLT?[1048]),EVT?[10365],, +10366,你斩杀了大量筑基修士,获得不少资源。,,,10,100,,,,,"(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])",,, +10367,悟道。,,,2,,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),,, +10368,寿元终。,,,,,,,,,TLT?[1048],"EVT?[10365,10361]",TLT?[1048]:10000, +10369,你突破到元婴二层。,,,2,,,,,,(EVT?[10365])&(INT>150)&(TLT?[1048]),EVT?[10369],, +10370,你突破到元婴三层。,,,2,,,,,,(EVT?[10369])&(INT>180)&(TLT?[1048]),EVT?[10370],, +10371,你突破到元婴四层。,,,2,,,,,,(EVT?[10370])&(INT>210)&(TLT?[1048]),EVT?[10371],, +10372,你突破到元婴五层。,,,2,,,,,,(EVT?[10371])&(INT>240)&(TLT?[1048]),EVT?[10372],, +10373,你突破到元婴六层。,,,2,,,,,,(EVT?[10372])&(INT>280)&(TLT?[1048]),EVT?[10373],, +10374,你突破到元婴七层。,,,2,,,,,,(EVT?[10373])&(INT>320)&(TLT?[1048]),EVT?[10374],, +10375,你突破到元婴八层。,,,2,,,,,,(EVT?[10374])&(INT>360)&(TLT?[1048]),EVT?[10375],, +10376,你突破到元婴九层。,,,2,,,,,,(EVT?[10375])&(INT>400)&(TLT?[1048]),EVT?[10376],, +10377,你突破到渡劫期。,,,10,10,,,,,(EVT?[10375])&(INT>500)&(TLT?[1048]),EVT?[10377],, +10378,准备渡劫。,,,1,10,,,,,(EVT?[10377])&(INT>500)&(TLT?[1048]),EVT?[10378],, +10379,寿元终。,,,,,,,,,TLT?[1048],EVT?[10377],TLT?[1048]:10000, +10380,你悟出水之大道。,,,20,20,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),EVT?[10380],, +10381,你悟出火之大道。,,,20,20,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),EVT?[10381],, +10382,你悟出金之大道。,,,20,20,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),EVT?[10382],, +10383,你悟出木之大道。,,,20,20,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),EVT?[10383],, +10384,你悟出土之大道。,,,20,20,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),EVT?[10384],, +10385,你进入顿悟状态。,,,20,,,,,,(EVT?[10365])&(INT>100)&(TLT?[1048]),,, +10386,你悟出了空间大道。,,,50,50,,,,,(EVT?[10365])&(INT>300)&(TLT?[1048]),EVT?[10386],, +10387,你悟出了时间大道。,,,50,50,,,,,(EVT?[10365])&(INT>300)&(TLT?[1048]),EVT?[10387],, +10388,你悟出了混沌大道。,,,50,50,,,,,(EVT?[10365])&(INT>300)&(TLT?[1048]),EVT?[10388],, +10389,你悟出了生命大道。,,,50,50,,,,,(EVT?[10365])&(INT>300)&(TLT?[1048]),EVT?[10389],, +10390,你悟出了毁灭大道。,,,50,50,,,,,(EVT?[10365])&(INT>300)&(TLT?[1048]),EVT?[10390],, +10391,开始渡劫。九重雷劫开始。,,,,,,,,,EVT?[10377],EVT?[10391],EVT?[10377]:10392, +10392,第一重雷劫落下。,,,,,,,,1,,EVT?[10392],STR>1100:10393,STR<1101:10000 +10393,第二重雷劫落下。,,,,,,,,1,,EVT?[10393],STR>1200:10394,STR<1201:10000 +10394,第三重雷劫落下。,,,,,,,,1,,EVT?[10394],STR>1300:10395,STR<1301:10000 +10395,第四重雷劫落下。,,,,,,,,1,,EVT?[10395],STR>1400:10396,STR<1401:10000 +10396,第五重雷劫落下。,,,,,,,,1,,EVT?[10396],STR>1500:10397,STR<1501:10000 +10397,第六重雷劫落下。,,,,,,,,1,,EVT?[10397],STR>1600:10398,STR<1601:10000 +10398,第七重雷劫落下。,,,,,,,,1,,EVT?[10398],STR>1700:10399,STR<1701:10000 +10399,第八重雷劫落下。,,,,,,,,1,,EVT?[10399],STR>1800:10400,STR<1801:10000 +10400,第九重雷劫落下。,,,,,,,,1,,EVT?[10400],STR>2000:10401,STR<2001:10000 +10401,雷劫度过,元神劫开始。,,,,,,,,1,,EVT?[10401],EVT?[10377]:10402, +10402,金之元神劫落下。,,,,,,,,1,,EVT?[10402],EVT?[10382]:10403,EVT?[10377]:10000 +10403,木之元神劫落下。,,,,,,,,1,,EVT?[10403],EVT?[10383]:10404,EVT?[10377]:10000 +10404,水之元神劫落下。,,,,,,,,1,,EVT?[10404],EVT?[10380]:10405,EVT?[10377]:10000 +10405,火之元神劫落下。,,,,,,,,1,,EVT?[10405],EVT?[10381]:10406,EVT?[10377]:10000 +10406,土之元神劫落下。,,,,,,,,1,,EVT?[10406],EVT?[10384]:10407,EVT?[10377]:10000 +10407,本源元神劫落下。,,,,,,,,1,,EVT?[10407],"EVT?[10386,10387,10388,10389,10390]:10408",EVT?[10377]:10000 +10408,心魔劫降临。,,,,,,,,1,,EVT?[10408],SPR>10:10409,EVT?[10377]:10000 +10409,渡劫成功!你飞升到仙界了。,你作为“人”的人生结束了。,,,,,,-1,1,,EVT?[10409],, +10410,你成为了动漫高手,经常在网上骂战。,,,,,,,,,EVT?[10189],"(EVT?[10410,10002])|(TLT?[1014])",STR>5:20410,INT<6:20411 +20410,你还喜欢在萌战吧、S1和bangumi茶话会发钓鱼帖。,,,,,,2,,1,,,, +20411,你还喜欢在B站评论区和人撕逼然后截图挂QQ群。,,,,,,,,1,,,, +10411,你开始追星。,,,,,,,,,MNY<8,"EVT?[10411,10413]",STR>6:20412,INT<4:20413 +20412,你经常抽时间帮爱豆刷数据。,,,,,,,,1,,,, +20413,你追的爱豆塌房了,被全网封禁。,,,,,,-1,,1,,,, +10412,你有了第一部自己的手机。,,,,,,,,,(MNY>3)&(EVT?[10009]),(MNY>7)|(EVT?[10412]),, +10413,某外籍知名明星因强奸罪被抓。,,,,,,,,,EVT?[10009],"EVT?[10413,20413]",INT<4:20414, +20414,该明星恰好是你家爱豆。你崩溃了。,,,,,,-1,,1,,,, +10414,附近开始流行肺炎,你在家中不敢出门。,,,,,,,,,EVT?[10009],EVT?[10414],, +10415,高考改革,英语被取消了。,,,,,,,,,EVT?[10009],EVT?[10415],"(EVT?[10237,10238,10239])&(INT<8):20415", +20415,你无语,你当年怎么没这么好的事儿。,,,,,,,,1,,,, +10416,高考改革,新增了中特社作为必考科目。,,,,,,,,,"EVT?[10009,10010]",EVT?[10416],, +10417,体育总局新规定,体测成绩必须100米跑进10秒才及格。,,,,,,,,,EVT?[10009],EVT?[10417],STR>9:20417, +20417,你寻思这也不是很难啊。,,,,,,,,1,,,, +10418,塔利班组织占领华盛顿。,,,,,,,,,EVT?[10009],EVT?[10418],INT<2:20418, +20418,你压根儿不知道塔利班和华盛顿是啥东西。,,,,,,,,1,,,, +10419,本·拉登复出,发视频称当年是假死。,,,,,,,,,EVT?[10009],EVT?[10419],INT<2:20419, +20419,你压根儿不知道本·拉登是啥东西。,,,,,,,,1,,,, +10420,希特勒的遗骨被发现。,,,,,,,,,EVT?[10009],EVT?[10420],, +10421,爱因斯坦失窃的部分大脑标本被追回。,,,,,,,,,EVT?[10009],EVT?[10421],(INT<4)&(MNY>8):20421, +20421,然后被你斥巨资购买了。,,,,,-2,,,1,,,, +10422,据说有人在深山里发现了古装的居民。官方通报是在拍电视剧。,,,,,,,,,"EVT?[10009,10010]",EVT?[10422],INT>8:20422, +20422,直觉告诉你事情没这么简单。,,,,,,,,1,,,, +10423,隔壁城市发生特大交通事故,数十人伤亡。,,,,,,,,,"EVT?[10009,10010]",EVT?[10423],(CHR>8)|(MNY>8):20423, +20423,有知情人告诉你不是交通事故,好像是一个在天上飞的人……,,,,,,,,1,,,, +10424,日本发生8.0级地震。,,,,,,,,,"EVT?[10009,10010]","EVT?[10424,10425]",SPR>9:20425, +10425,日本发生9.0级地震。,,,,,,,,,EVT?[10009],"EVT?[10425,10424]",SPR>7:20425, +20425,你意识到这场地震并不寻常……,,,,,,,,1,,,, +10426,中国大陆收复台湾。,,,,,,,,,EVT?[10009],EVT?[10426],(CHR>8)&(MNY>8):20426, +20426,但据你所知,并没有出动军队和武器,好像只派了少量的“人”?,,,,,,,,1,,,, +10427,清华北大合并为清北大学。,,,,,,,,,EVT?[10009],EVT?[10427],, +10428,南京大学和同济大学合并为南同大学。,,,,,,,,,EVT?[10009],"EVT?[10428,10429]",, +10429,南京大学和东南大学合并为京东大学。,,,,,,,,,EVT?[10009],"EVT?[10429,10428]",, +10430,VR技术突破,用户可以意识进入虚拟空间。目前该技术还未进入民用。,,,,,,,,,EVT?[10009],EVT?[10430],INT>9:20431, +20431,你认为这是虚假消息。,,,,,,,,1,,,, +10431,游哈米发布次时代手游大作《神原》。,,,,,,,,,EVT?[10009],EVT?[10431],MNY>6:20432, +20432,你试着玩了玩并且充了点钱,啥好角色都抽不到。,,,,,,,,1,,,, +10432,腾讯收购网易。,,,,,,,,,EVT?[10009],EVT?[10432],SPR>7:20433, +20433,还好你不玩网易游戏。,,,,,,,,1,,,, +10433,拼多多收购阿里巴巴。,,,,,,,,,EVT?[10009],EVT?[10433],, +10434,字节跳动市值超过微软。,,,,,,,,,EVT?[10009],EVT?[10434],, +10435,你和网民争论兰博基尼和法拉利哪个档次高。,,,,,,,,,EVT?[10009],"EVT?[10435,10002]",, +10436,中国开放十八胎生育。,,,,,,,,,EVT?[10009],EVT?[10436],"EVT![10268,10269,10272]:20436", +20436,笑死,一个都不生。,,,,,,,,1,,,, +10437,全球新冠确诊病例首次清零。,,,,,,,,,EVT?[10009],EVT?[10437],STR>2:20437, +20437,你终于可以呼吸到新鲜空气了。,,,,,,,,1,,,, +10438,曹县成功申办2066年奥运会。,,,,,,,,,EVT?[10009],EVT?[10438],, +10439,日本武力攻占珍珠港。,,,,,,,,,EVT?[10009],EVT?[10439],, +20439,据说他们没有使用飞机、舰船和炮弹。,,,,,,,,1,,,(CHR>8)&(STR>8):20439, +10440,朝鲜计划向美国和韩国投下两颗原子弹。,计划败露。,,,,,,,,EVT?[10009],EVT?[10440],, +10441,芜湖机场世界排名升至第一。,,,,,,,,,EVT?[10009],EVT?[10441],, +10442,蚌埠房价一年内翻倍,国家出手调控。,,,,,,,,,EVT?[10009],EVT?[10442],, +10443,我国两极分化迅速减小,人民幸福指数进一步提高。,,,,,,,,,"EVT?[10009,10010]",EVT?[10443],(MNY<4)&(SPR<4):20443, +20443,但你家还是很穷,而且也不算幸福。,,,,,,,,1,,,, +20444,但你家还是很穷。,,,,,,,,1,,,, +10444,中国GDP超过美国。,,,,,,,,,"EVT?[10009,10010]",EVT?[10444],MNY<3:20444, +10445,江苏省省会改为苏州。,,,,,,,,,EVT?[10009],EVT?[10445],, +10446,英国和法国断交。,,,,,,,,,EVT?[10009],EVT?[10446],, +10447,中国当前首富被爆是美国间谍,在机场被抓获。,,,,,,,,,EVT?[10009],EVT?[10447],, +10448,国家公布中产阶级标准:家庭年收入100万。,,,,,,,,,"EVT?[10009,10010]",EVT?[10448],MNY<4:20448, +20448,你感觉太离谱了。,,,,,,,,1,,,, +10449,海底火山爆发,马里亚纳海沟被填平。,,,,,,,,,EVT?[10009],EVT?[10449],, +10450,上海数十名小学生春游,成功登顶珠穆朗玛峰。,,,,,,,,,EVT?[10009],EVT?[10450],, +10451,北京一本录取率首次超过99%。,,,,,,,,,"EVT?[10009,10010]",EVT?[10451],(MNY<4)&(TLT![1010]):20452, +20452,可恶的天龙人。,,,,,,,,1,,,, +10452,特朗普再度当选美国总统。,,,,,,,,,EVT?[10009],EVT?[10452],(SPR>6)&(INT>2):20453, +20453,你感觉又有乐子了。,,,,,,1,,1,,,, +10453,拜登遭到暗杀。,,,,,,,,,EVT?[10009],EVT?[10453],, +10454,云南发现一种红白斑点蘑菇,吃了可以变大。,,,,,,,,,EVT?[10009],EVT?[10454],"EVT?[10188,10194]:20454", +20454,你预测那里还存在一种花,吃了可以发射火球。,,,,,,,,1,,,, +10455,医学奇迹,全球首例断头重生手术成功。,,,,,,,,,EVT?[10009],EVT?[10455],, +10456,女女生育技术取得重大突破。,,,,,,,,,EVT?[10009],EVT?[10456],"(EVT?[10007,10008])&(TLT![1026]):20456", +20456,你感到很高兴。,,,,,,1,,1,,,, +10457,科学家宣布,人类Y染色体再过500年就会灭亡。,,,,,,,,,"EVT?[10009,10010]",EVT?[10457],, +10458,有个乞丐向你推销“仙法”秘籍,你没有搭理他。,,,,,,,,,EVT?[10009],EVT?[10458],, +10459,最新研究显示,人类的寿命极限是500岁。,,,,,,,,,"EVT?[10009,10010]",EVT?[10459],INT<4:20459, +20459,你觉得太荒谬了。,,,,,,,,1,,,, +10460,美国宣布进入社会主义社会。,,,,,,,,,EVT?[10009],EVT?[10460],SPR>6:20460, +20460,你突然感觉人生无憾了。,,,,,,,,1,,,, +10461,奥运会在安徽省会南京成功举办。,,,,,,,,,EVT?[10009],EVT?[10461],, +10462,你被门夹伤了手。,,,,,,,,,EVT?[10009],EVT?[10462],, +10463,你不小心摔了一跤,磕掉了一颗牙。,,,,,,,,,EVT?[10009],,, +10464,你在购物时中了个四等奖:一包纸巾。,,,,,,,,,EVT?[10009],"EVT?[10464,10465,10466,10467]",, +10465,你在购物时中了个三等奖:一个电饭锅。,,,,,,,,,EVT?[10009],"EVT?[10464,10465,10466,10467]",, +10466,你在购物时中了个二等奖:一个电冰箱。,,,,,,1,,,EVT?[10009],"EVT?[10464,10465,10466,10467]",, +10467,你在购物时中了个一等奖:三亚七日游。,你快乐地游玩了一个冬天。,,,,,2,,,EVT?[10009],"EVT?[10464,10465,10466,10467]",, +10468,你进入流水线工厂工作。,,,,,,,,,"EVT?[10237,10025,10156,10155,10198]","EVT?[10475,10476,10477,10226,10468]",, +10469,每天重复的加工十分无聊。,,,,,,,,,EVT?[10468],"EVT?[10469,10473,10226]",, +10470,员工宿舍十几个人挤在一间。,,,,,,,,,EVT?[10468],"EVT?[10470,10473,10226]",, +10471,你工作攒下了一点钱。,,,,,,,,,EVT?[10468],"EVT?[10471,10473,10226]",, +10472,你加工零件非常熟练了。,,,,,,,,,EVT?[10468],"EVT?[10472,10473,10226]",, +10473,工厂倒闭了,厂长带着小姨子跑了。,你失业了。,,,,,-1,,,EVT?[10468],"EVT?[10473,10226]",, +10474,你四处求职,但因为太丑而找不到工作。,,,,,,,,,"(CHR<3)&(EVT?[10237,10238,10239,10198,10199,10200])","EVT?[10226,10468,10202,10259,10191,10475,10476,10477]",, +10475,你大学毕业后回村当了老师。,,,,,,,,,"EVT?[10237,10238,10239]","EVT?[10475,10476,10477,10468]",, +10476,你大学毕业后回村当了护士。,,,,,,,,,"EVT?[10237,10238,10239]","EVT?[10476,10001,10475,10477,10468]",, +10477,你大学毕业后回村当了医生。,,,,,,,,,"EVT?[10237,10238,10239]","EVT?[10477,10475,10476,10468]",, +10478,在乡下工作的一个好处是,没有城市里那么繁忙。,,,,,,,,,"EVT?[10475,10476,10477]",EVT?[10478],, +10479,你的工资虽然不高,但这份工作你挺喜欢的。,,,,,,1,,,"EVT?[10475,10476,10477]","EVT?[10479,10490]",, +10480,孩子们很难教,基础太差了。,,,,,,,,,EVT?[10475],EVT?[10480],, +10481,你现在很受村民们尊重。,,,,,,,,,"(CHR>6)&(EVT?[10475,10477])","EVT?[10481,10484]",, +10482,有的病人很迷信,不听你的话。,,,,,,,,,"EVT?[10476,10477]",EVT?[10482],, +10483,有个村民被车撞了,你连夜为他做手术。,,,,,,,,,EVT?[10477],EVT?[10483],, +10484,你遭到了村民的调戏。,,,,,,,,,EVT?[10476],"EVT?[10484,10481]",, +10485,开家长会,但来的基本都是学生的祖辈,很少有父母来。,,,,,,,,,EVT?[10475],EVT?[10485],, +10486,你出了套试卷,全班学生没有一个及格。,,,,,,,,,EVT?[10475],EVT?[10486],, +10487,工作顺利的一年,没发生什么大事。,,,,,,,,,"EVT?[10475,10476,10477]",,, +10488,像你一样返乡工作的大学生越来越少了。,,,,,,,,,"EVT?[10475,10476,10477]",EVT?[10488],, +10489,村里基本只有老人和孩子。,,,,,,,,,"EVT?[10475,10476,10477]",EVT?[10489],, +10490,你对人生有些迷茫。,,,,,,,,,"EVT?[10475,10476,10477]",EVT?[10490],, +10491,工作的闲暇时,你会看看动漫。,,,,,,,,,"(EVT?[10475,10476,10477])&(EVT?[10007,10008])",,, +10492,你退休了。,,,,,,,,,"EVT?[10475,10476,10477]","EVT?[10492,10001]",, +10493,你退休了。,,,,,,,,,"EVT?[10475,10476,10477]","EVT?[10492,10002]",, +10494,体质过低,胎死腹中。,,,,,,,,,STR<0,TLT?[1071],STR<0:10000, +10495,意外发现古代宗派遗宝。,,,1,10,,1,,,TLT?[1048],EVT?[10495],, +10496,偶遇筑基期散修。,他无视了你。,,,,,,,,TLT?[1048],EVT?[10496],CHR<5:10497, +10497,他嫌你长得丑,把你杀了。,,,,,,,,1,,,CHR<5:10000, +10498,父母经常带你去附近的公园和大学校园玩。,,,,,,,,,(MNY>3)&(EVT?[10011]),EVT?[10498],, +10499,你喜欢在图书馆的儿童区和别的小朋友一起玩。,,,,,,,,,(MNY>3)&(EVT?[10011]),EVT?[10499],, +10500,父母同时教你英语和汉语。,,,,,,,,,EVT?[10011],EVT?[10500],, +10501,父母开始用照片和日记记录下你的点点滴滴。,,,,,,,,,EVT?[10011],EVT?[10501],, +10502,家里很有钱,父母所有东西都为你准备最好的。,,,,,,,,,(MNY>7)&(EVT?[10011]),EVT?[10502],, +10503,家里很穷,但父母尽力为你准备更好的生活。,,,,,,,,,(MNY<4)&(EVT?[10011]),EVT?[10503],, +10504,你开始上幼儿园。,,,,,,,,,(MNY>3)&(EVT?[10011]),EVT?[10504],, +10505,你上不起幼儿园,父母开始教你学习。,,,,,,,,,(MNY<4)&(EVT?[10011]),EVT?[10505],, +10506,你每天和小朋友、老师们玩游戏、做手工、唱歌跳舞。,,,,,,,,,EVT?[10504],EVT?[10506],, +10507,父母给你买了一书架的启蒙童书。,,,,,,,,,EVT?[10504],EVT?[10507],, +10508,每周一次的看动画片时间是你的最爱。,,,,,,,,,EVT?[10011],EVT?[10508],, +10509,你的父母请了家教来教你游泳。,,,,,,,,,EVT?[10504],EVT?[10509],, +10510,你的父母请了家教来教你弹钢琴。,,,,,,,,,EVT?[10504],EVT?[10510],, +10511,你的父母请了家教来教你法语。,,,,,,,,,EVT?[10504],"EVT?[10511,10512]",, +10512,你的父母请了家教来教你西班牙语。,,,,,,,,,EVT?[10504],"EVT?[10511,10512]",, +10513,你平时很少出门,因为父母说外面很危险。,,,,,,-1,,,EVT?[10505],EVT?[10513],, +10514,附近发生了一起枪击案。,,,,,,-1,,,EVT?[10505],EVT?[10514],, +10515,父母说要好好学习,考上好大学离开这里。,,,,,,,,,EVT?[10505],EVT?[10515],, +10516,你比同龄人学了更多的知识。,,,1,,,,,,EVT?[10505],EVT?[10516],, +10517,你的父亲在地铁上被暴徒攻击,受了伤。,,,,,,-1,,,EVT?[10505],EVT?[10517],, +10518,你开始上小学了。,,,,,,,,,EVT?[10011],EVT?[10518],, +10519,你比其他同学更聪明,学得更快懂得更多。,老师很喜欢你。,,,,,,,,(INT>5)&(EVT?[10011]),EVT?[10519],, +10520,虽然你是亚裔,但你没有感觉有什么不同。,,,,,,,,,EVT?[10504],EVT?[10520],, +10521,有好几个小朋友向你表白。,,,,,,1,,,(CHR>6)&(EVT?[10011]),EVT?[10521],, +10522,班上的几个非裔同学经常欺负你。,,,,,,-1,,,(STR<7)&(CHR<7)&(EVT?[10505]),(EVT?[10522])|(TLT![1037]),, +10523,你在家中主要用中文交流,在学校都用英文。,,,,,,,,,EVT?[10011],EVT?[10523],, +10524,你的运动很棒,同学们都很崇拜你。,,,,,,1,,,(STR>7)&(EVT?[10011]),EVT?[10524],, +10525,因为你的成绩最好,老师允许你躺在班上的秋千椅上听课。,,,,,,1,,,(INT>6)&(EVT?[10504]),EVT?[10525],, +10526,课堂上经常做小实验。,,,,,,,,,EVT?[10011],EVT?[10526],, +10527,有次整整一天,老师带你们出去观察昆虫。,,,,,,,,,EVT?[10504],EVT?[10527],, +10528,老师夸你的数学和科学知识已经不比中学生差了。,,,,,,1,,,(INT>6)&(EVT?[10011]),EVT?[10528],, +10529,学校举办唱歌比赛。,,,,,,,,,EVT?[10011],EVT?[10529],EVT?[10049]:20529, +20529,你拿了第一名。,,,,,,1,,1,,,, +10530,在学校经常运动,身体越来越棒。,,,,1,,,,,EVT?[10011],"EVT?[10530,10531]",, +10531,在学校经常运动,身体越来越棒。,,,,1,,,,,EVT?[10011],"EVT?[10530,10531]",, +10532,班上没有几个白人同学,而会说汉语的有好几个。,,,,,,,,,EVT?[10505],EVT?[10532],, +10533,班上有个男孩欺负一个女孩,你勇敢站出来制止了他。,,,,,,,,,(STR>4)&(EVT?[10504]),EVT?[10533],, +10534,有两个学生在班上抽烟,但老师不敢管。,,,,,,-1,,,EVT?[10505],EVT?[10534],TLT?[1108]:20534, +20534,你跳出来管他们,被其中一个学生掏枪打死了。,,,,,,,,1,,,, +10535,你们班里又转来一个中国学生。,,,,,,,,,EVT?[10011],EVT?[10535],, +10536,父母的事业非常成功,家境变得更好了。,,,,,1,,,,EVT?[10504],EVT?[10536],, +10537,父母的事业取得了一定成功,家境有所好转。,,,,,1,,,,EVT?[10505],EVT?[10537],, +10538,老师教你们操作电脑,但你早就会了。,,,,,,,,,EVT?[10504],EVT?[10538],, +10539,老师有时会带来一大堆零食,分给所有同学。,,,,,,1,,,EVT?[10011],EVT?[10539],, +10540,你们把座位布置成了法庭,举行了一场模拟辩论。,,,,,,,,,EVT?[10011],EVT?[10540],, +10541,你上了一个著名的贵族中学。,,,,,,,,,(MNY>7)&(EVT?[10011]),EVT?[10541],, +10542,你上了一个普通的中学。,,,,,,,,,(MNY<8)&(EVT?[10011]),EVT?[10542],, +10543,你的课业很重,学校里的活动也很多,生活非常充实。,,,,,,,,,EVT?[10541],EVT?[10543],, +10544,课业很轻松,几乎没有作业,每天下午放学就有各种活动。,,,,,,,,,EVT?[10542],EVT?[10544],, +10545,你很喜欢放学或周末在学校玩滑雪和曲棍球。,,,,1,,,,,(STR>2)&(EVT?[10541]),EVT?[10545],, +10546,你在学校学会了骑马和高尔夫。,,,,1,,,,,(INT>2)&(STR>2)&(EVT?[10541]),EVT?[10546],, +10547,你中午经常在图书馆和另外两个华裔同学一起学习。,,,,,,,,,EVT?[10541],EVT?[10547],, +10548,你的同班同学中有著名明星的女儿、著名银行家的小儿子。,,,,,,,,,EVT?[10541],"EVT?[10548,10549,10550]",, +10549,你的同班同学中有著名球星的儿子。,,,,,,,,,EVT?[10541],"EVT?[10548,10549,10550]",, +10550,你的同班同学中有著名政客的女儿和某小国皇室的王子。,,,,,,,,,EVT?[10541],"EVT?[10548,10549,10550]",, +10551,虽然课余活动很丰富,不过同学们学习都很认真。,,,,,,,,,EVT?[10541],EVT?[10551],, +10552,学校组织了一场去欧洲的旅行。,,,,,,1,,,EVT?[10541],EVT?[10552],, +10553,你参演了一场戏剧演出。,,,,,,,,,EVT?[10011],EVT?[10553],, +10554,同学们大多自信幽默大方,平易近人。你和他们相处融洽。,,,,,,1,,,EVT?[10541],EVT?[10554],, +10555,回到家父母会给你额外的学习任务。,,,1,,,-1,,,EVT?[10011],EVT?[10555],, +10556,你家的扫地机器人坏了,你自己制作了一个。,,,,,,,,,(MNY>2)&(INT>7)&(EVT?[10011]),EVT?[10556],, +10557,你经常晚上去学校天文台用望远镜看星星。,,,,,,,,,EVT?[10011],EVT?[10557],MNY>7:20557, +20557,你父母在家给你买了一台天文望远镜。,,,,,,,,1,,,, +10558,你参加了学校的舞会。,,,,,,,,,EVT?[10011],EVT?[10558],CHR>7:20558, +20558,你过人的颜值和舞技让你成为万众瞩目。,,,,,,1,,1,,,, +10559,很多同学找你求交往。,,,,,,,,,EVT?[20558],EVT?[10559],, +10560,不少同学找你求交往。,,,,,,,,,(TLT?[1028])&(EVT?[10011]),EVT?[10560],, +10561,你谈了一个女朋友。,,,,,,1,,,"(EVT?[10011])&((EVT?[10001,10110,10111])|(TLT?[1026]))",(EVT?[10561])|(TLT?[1027]),, +10562,你谈了一个男朋友。,,,,,,1,,,"(EVT?[10011])&((EVT?[10002,10110,10111])|(TLT?[1026]))",(EVT?[10562])|(TLT?[1027]),, +10563,学校生活很快乐,每天大多数时间都在玩。,,,,,,1,,,EVT?[10542],EVT?[10563],, +10564,一个从中国转学来的同学说,这里的考试比中国简单多了。,,,,,,,,,EVT?[10542],EVT?[10564],, +10565,学校举办为期一学期的模拟创业活动。,,,,,,,,,EVT?[10011],EVT?[10565],(MNY>7)&(INT>7):20565, +20565,你的创业最成功。,,,,,,1,,1,,,, +10566,美国总统来你们学校演讲。,,,,,,,,,EVT?[10541],EVT?[10566],, +10567,你们学校新开设了保龄球选修课。,,,,,,,,,EVT?[10011],EVT?[10567],, +10568,这次期末考试很难。,你考得一般。,,,,,,,,EVT?[10541],EVT?[10568],INT<3:20568,INT>8:20569 +20568,你考得很差。,,,,,,-1,,1,,,, +20569,但你还是考了第一。,,,,,,,,1,,,, +10569,你在学校选修了日语。,,,,,,,,,"(EVT?[10011])&(EVT?[10007,10008])",EVT?[10569],, +10570,教室里有个浴缸,经常有同学躺在浴缸里听课。,,,,,,,,,EVT?[10542],EVT?[10570],, +10571,美术和音乐教室里的地毯非常好看。,,,,,,,,,EVT?[10542],EVT?[10571],, +10572,学校要求每个同学自带平板电脑。,,,,,,,,,EVT?[10542],EVT?[10572],MNY<3:20572, +20572,你父母忍痛给你买了一个。,,,,,,,,1,,,, +10573,教室里有很多金鱼,每人都认养了一只。,,,,,,,,,EVT?[10542],EVT?[10573],, +10574,你父母拿了份中国中考数学卷给你做。,你觉得有些难。,,,,,,,,EVT?[10011],EVT?[10574],INT<7:20574,INT>8:20575 +20574,你感觉非常难。,,,,,,,,1,,,, +20575,虽然比平时做的难,但还是都做出来了。,,,,,,,,1,,,, +10575,据说附近发生了一起枪击案。,,,,,,-1,,,EVT?[10542],EVT?[10575],TLT?[1108]:20575, +20575,好奇心使你试探着寻找凶手,但一无所获。,,,,,,,,1,,,, +10576,你在上学路上遭遇了枪击。,,,,,,-1,,,EVT?[10505],TLT?[1072],STR>9:20576,EVT?[10505]:10000 +20576,你身手敏捷,侥幸逃得一命。,,,,,,,,1,,,, +10577,你在上学路上看到很多流浪汉和瘾君子。,,,,,,,,,EVT?[10505],EVT?[10577],TLT?[1108]:20577, +20577,你上去挑衅他们,被一群人持械围殴。,,,,,,,,1,,,EVT?[10505]:10000, +10578,你跟随父母回中国了。,,,,,,,,,(INT<7)&(EVT?[10542]),TLT?[1073],, +10579,你考上了世界名校。,,,,,,,,,EVT?[10011],"EVT?[10579,10578]",, +10580,你考上了哈佛大学。,,,,,,,,,(INT>8)&(EVT?[10011]),EVT?[10580],, +20580,你考上了哈佛大学。,,,,,,,,,(TLT?[1073])&(INT>5)&(EVT?[10011]),,, +10581,你考上了耶鲁大学。,,,,,,,,,(INT>8)&(EVT?[10011]),EVT?[10581],, +10582,你考上了麻省理工大学。,,,,,,,,,(INT>8)&(EVT?[10011]),EVT?[10582],, +10583,你考上了加州伯克利。,,,,,,,,,(INT>8)&(EVT?[10011]),EVT?[10583],, +10584,你考上了斯坦福大学。,,,,,,,,,(INT>8)&(EVT?[10011]),EVT?[10584],, +10585,你的一个熟悉的同学因为压力太大退学了。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10585],, +10586,你以留学生身份被清华大学录取。,,,,,,,,,EVT?[10578],(EVT?[10586])|(TLT?[1107]),, +10587,你以留学生身份被北京大学录取。,,,,,,,,,EVT?[10578],EVT?[10587],, +10588,无事发生。,,,,,,,,,TLT?[1103],,, +10589,无事发生。,,,,,,,,,TLT?[1105],,, +10590,时间跳跃。,,,,,,,,,TLT?[1104],,, +10591,你第一次吃肯德基。,,,,,,,,,(MNY<6)&(EVT?[10009]),(TLT?[1106])|(MNY<2)|(EVT?[10591]),, +10592,你家比较穷,经常只能吃麦当劳等垃圾食品。,,,,-1,,,,,(MNY<6)&(EVT?[10011]),(TLT?[1106])|(EVT?[10592]),, +10593,你几乎每天都在图书馆学习到半夜。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10593],, +10594,圣诞节,有学生制造出了无人机雪橇派送礼物。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10594],, +10595,你在舞会上结识了一个漂亮的女生。,你们谈了一阵子恋爱后分手了。,,,,,,,,"(EVT?[10579,10580,10581,10582,10583,10584,10586,10587])&((EVT?[10001,10110,10111])|(TLT?[1026]))","(EVT?[10595,10596])|(TLT?[1027])",CHR>7:20596, +10596,你在舞会上结识了一个帅气的男生。,你们谈了一阵子恋爱后分手了。,,,,,,,,"(EVT?[10579,10580,10581,10582,10583,10584,10586,10587])&((EVT?[10002,10110,10111])|(TLT?[1026]))","(EVT?[10596,10595])|(TLT?[1027])",CHR>7:20596, +20596,很快你们便确定了关系。,,,,,,,,1,,,, +10597,你去友校做了一年交换生。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10597],, +10598,学习压力很大,你向学校心理咨询处咨询。,,,,,,-1,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10598],, +10599,实验项目繁多,论文你总是卡着时间才写完。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10599],, +10600,你总会抽时间去健身房,保证身体健康。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10600],, +10601,一个从中国来的同学比你还忙,因为他还要抽时间打工。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10601],, +10602,你拿到了奖学金。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10602],, +10603,你的生日派对有很多朋友来参加。,,,,,,,,,"(CHR>3)&(EVT?[10579,10580,10581,10582,10583,10584])",EVT?[10603],, +10604,你在一个角落的墙上看到非常艺术感的涂鸦。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10604],, +10605,你阅读了很多中外的文学作品。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10605],, +10606,你对金融和计算机都十分擅长。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]",EVT?[10606],, +10607,你前往华尔街工作,年收入约几十万刀。,,,,,1,,,,EVT?[10606],"EVT?[10607,10608,10609]",, +10608,你前往硅谷创业。,,,,,,,,,"(MNY>8)&(EVT?[10606,10565])","EVT?[10607,10608,10609]",, +10609,你在导师的实验室搞科研。,,,,,,,,,"EVT?[10579,10580,10581,10582,10583,10584]","EVT?[10607,10608,10609]",, +10610,你和大学对象步入了婚姻的殿堂。,,,,,,1,,,EVT?[20596],"EVT?[10610,10611,10612]",, +10611,你和一个同事结婚了。,,,,,,1,,,EVT?[10606],"(EVT?[10611,10610,10612,20596])|(TLT?[1027])",, +10612,你和一个你很满意的对象结婚了。,,,,,,1,,,"EVT?[10579,10580,10581,10582,10583,10584]","(EVT?[10612,10610,10611])|(TLT?[1027])",, +10613,有家里的资金和人脉支持,你的创业非常成功。,,,,,,,,,EVT?[10608],EVT?[10613],, +10614,你结识了许多同学和父母介绍的商业伙伴。,,,,,,,,,"EVT?[10608,10607]",EVT?[10614],, +10615,你非常努力,在社交之中成长很快。,,,,,,,,,"EVT?[10608,10607]",EVT?[10615],, +10616,你的公司越做越大,完成了多轮融资,用户数也突破了千万。,,,,,1,,,,EVT?[10608],EVT?[10616],, +10617,你的公司产品用户数破百万。,,,,,,,,,EVT?[10608],EVT?[10617],, +10618,你请了几位中学大学时的朋友加入你的公司。,,,,,,,,,EVT?[10608],EVT?[10618],, +10619,你的公司产品用户数破亿。,,,,,,,,,EVT?[10608],EVT?[10619],, +10620,你的公司上市了。,,,,,1,,,,EVT?[10608],EVT?[10620],, +10621,你的孩子出生了。,,,,,,,,,"EVT?[10610,10611,10612]","(EVT?[10621])|(TLT?[1041,1046])",, +10622,你的爱人也来你的公司工作。,,,,,,,,,EVT?[10608],EVT?[10622],, +10623,你买了几辆数百万、上千万的豪车。,,,,,,,,,EVT?[10608],EVT?[10623],, +10624,你在几座大城市都购入了豪宅,还买了海边别墅。,,,,,,,,,EVT?[10608],EVT?[10624],, +20625,性格使然,你在网上秀优越,还发布一些挑衅言论。,,,,,,,,1,,,, +10625,你被福布斯评为美国最年轻的百亿富豪排名第一。,,,,,,,,,EVT?[10608],EVT?[10625],TLT?[1108]:20625, +10626,你创立了好几家公司。,,,,,,,,,EVT?[10608],EVT?[10626],, +10627,你不再直接参与公司决策,退居幕后。,,,,,,,,,EVT?[10608],EVT?[10627],, +10628,你收购了好几家创业公司。,,,,,,,,,EVT?[10608],EVT?[10628],, +10629,你开始投资房地产。,,,,,,,,,EVT?[10608],EVT?[10629],, +10630,你开始投资AI、VR和游戏。,,,,,,,,,EVT?[10608],EVT?[10630],, +10631,你开始投资动漫产业。,,,,,,,,,"(EVT?[10608])&(EVT?[10007,10008])",EVT?[10631],, +10632,你开始投资体育、影视产业。,,,,,,,,,EVT?[10608],EVT?[10632],, +10633,你像你父母一样给了孩子最丰厚的条件。,,,,,,,,,EVT?[10621],EVT?[10633],, +10634,你希望孩子未来和你一样努力成为精英。,,,,,,,,,EVT?[10621],EVT?[10634],, +10635,你被评为本世代十大科技人物。,,,,,,,,,EVT?[10608],EVT?[10635],, +10636,你的工作现在很轻松,大多数时间都在家带娃。,,,,,,,,,(EVT?[10608])&(EVT?[10621]),EVT?[10636],, +10637,你们一家搬家到了瑞士。,,,,,,,,,EVT?[10608],EVT?[10637],, +10638,虚拟现实技术已经非常成熟,你玩的兴趣不大。,,,,,,,,,EVT?[10608],EVT?[10638],, +10639,你们家每年光保险开销就比普通美国人一辈子的收入还多。,,,,,,,,,EVT?[10608],EVT?[10639],, +10640,你们一家去了欧洲各国旅游。,,,,,,,,,EVT?[10608],EVT?[10640],, +10641,你们一家去了澳大利亚和新西兰旅游。,,,,,,,,,EVT?[10608],EVT?[10641],, +10642,你们一家去了东南亚旅游。,,,,,,,,,EVT?[10608],EVT?[10642],, +10643,你们一家去了埃及和阿联酋旅游。,,,,,,,,,EVT?[10608],EVT?[10643],, +10644,你们一家去了夏威夷旅游。,,,,,,,,,EVT?[10608],EVT?[10644],, +10645,你们一家去了中国旅游。,,,,,,,,,"EVT?[10608,10607]",EVT?[10645],, +10646,你成为了世界首富。,,,,,,1,,,EVT?[10608],EVT?[10646],, +10647,你的孩子也上了世界名校。,,,,,,,,,EVT?[10621],EVT?[10647],TLT?[1108]:20647, +20647,你有次在网上骂战,不小心暴露孩子考上名校是通过你的关系。,丑闻发酵,你的孩子被退学。,,,,,-1,,1,,,, +10648,你到东京大学、清华大学、香港大学等学府演讲《我的努力》。,,,,,,,,,EVT?[10608],EVT?[10648],, +10649,你的父亲去世。,,,,,,,,,EVT?[10011],"EVT?[10649,10651]",, +10650,你的母亲去世。,,,,,,,,,EVT?[10011],"EVT?[10650,10652]",, +10651,你的父亲因心脏病去世。,,,,,,,,,EVT?[10011],"(EVT?[10651,10649])|(TLT?[1044])",, +10652,你的母亲因心血管疾病去世。,,,,,,,,,EVT?[10011],"(EVT?[10652,10650])|(TLT?[1044])",, +10653,你的爱人因病去世。,,,,,,,,,"EVT?[10610,10611,10612]",EVT?[10653],, +10654,你的孙儿出生了。,,,,,,,,,EVT?[10621],EVT?[10654],, +10655,你住在庄园里,围绕着最新科技,过着养老生活。,,,,,,,,,EVT?[10608],EVT?[10655],, +10656,你因病医治无效去世。,,,,,,,,,EVT?[10011],TLT?[1048],EVT?[10011]:10000, +10657,你在睡梦中安然离世。,,,,,,,,,EVT?[10011],TLT?[1048],EVT?[10011]:10000, +10658,你财务自由,购买了名车和豪宅。,,,,,,,,,EVT?[10607],EVT?[10658],, +10659,你申请了死后冷冻尸体的服务,希望有朝一日能复活。,,,,,,,,,"EVT?[10608,10607]",EVT?[10659],TLT?[1108]:20659, +20659,但你生前得罪了不少人,你的申请被一再延迟。,,,,,,,,1,,,, +10660,你的实验不太顺利。,,,,,,-1,,,EVT?[10609],,, +10661,老板对你很严格,但是也很关心你。,,,,,,,,,EVT?[10609],EVT?[10661],, +10662,你的学术和实验水平进一步提高。,,,1,,,,,,EVT?[10609],,, +10663,你废寝忘食,几乎住在实验室里。,,,,-1,,,,,EVT?[10609],EVT?[10663],, +10664,你的实验取得了突破。,,,,,,,,,EVT?[10609],EVT?[10664],, +10665,你一年内发表了多篇SCI。,,,,,,,,,EVT?[10609],EVT?[10665],, +10666,你和老板发表了一篇Nature。,,,,,,,,,EVT?[10609],EVT?[10666],, +10667,你留校担任助教。,,,,,,,,,EVT?[10609],EVT?[10667],, +10668,你处于做实验和发paper的无尽循环中。,,,,,,,,,EVT?[10609],,, +10669,你担任副教授。,,,,,,,,,EVT?[10609],EVT?[10669],, +10670,你发表一篇一作Nature。,,,,,,,,,EVT?[10609],EVT?[10670],, +10671,你被母校聘为正教授。,,,,,,,,,EVT?[10669],EVT?[10671],, +10672,你被中国多所名校聘为客座教授。,,,,,,,,,EVT?[10609],EVT?[10672],, +10673,你获得多项大奖。,,,,,,,,,EVT?[10609],EVT?[10673],, +10674,你在微观粒子领域取得重要突破。,,,,,,,,,EVT?[10609],"EVT?[10674,10675,10676]",, +10675,你在遗传领域取得重要突破。,,,,,,,,,EVT?[10609],"EVT?[10674,10675,10676]",, +10676,你在材料领域取得重要突破。,,,,,,,,,EVT?[10609],"EVT?[10674,10675,10676]",, +10677,你成为美国科学院院士。,,,,,,,,,EVT?[10609],EVT?[10677],, +10678,你成为中国科学院外籍院士。,,,,,,,,,EVT?[10609],EVT?[10678],, +10679,你获得了诺贝尔物理学奖。,,,,,1,2,,,EVT?[10674],EVT?[10679],, +10680,你获得了诺贝尔生理学或医学奖。,,,,,1,2,,,EVT?[10675],EVT?[10680],, +10681,你获得了诺贝尔化学奖。,,,,,1,2,,,EVT?[10676],EVT?[10681],, +10682,你放弃美国国籍,毅然加入中国国籍前往中国的大学。,,,,,,,,,EVT?[10609],EVT?[10682],, +10683,你创建了一个以你名字命名的慈善基金会。,,,,,,,,,EVT?[10608],EVT?[10683],, +10684,你决定将你的遗产都捐赠给母校。,,,,,,,,,EVT?[10609],"EVT?[10684,10682]",, +10685,你决定将你的遗产都捐赠给中国大学用于建设。,,,,,,,,,EVT?[10682],EVT?[10685],, +10686,你的论文他引超过十万。,,,,,,,,,EVT?[10609],EVT?[10686],, +10687,你在世界巡回讲座。,,,,,,,,,EVT?[10609],,, +10688,你出版了一本教材。,,,,,,,,,EVT?[10609],EVT?[10688],, +10689,你出版了一本自传,介绍你的成功之路。,,,,,,,,,EVT?[10608],EVT?[10689],, +10690,你经常作为嘉宾出现在电视节目。,,,,,,,,,"EVT?[10607,10608]",EVT?[10690],, +10691,有人以你的人生为原本拍摄了电影。,,,,,,,,,EVT?[10608],EVT?[10691],, +10692,你的自传一直超级畅销。人们被你的努力和精神所打动。,,,,,,,,,EVT?[10689],EVT?[10692],, +10693,你不想死,坚持锻炼、经常体检试图延长寿命。,,,,,,,,,"EVT?[10607,10608]",EVT?[10693],, +10694,你的孙子被人绑架,好在成功被警察救出。,,,,,,,,,EVT?[10654],EVT?[10694],, +10695,英国剑桥大学吞并牛津大学。,,,,,,,,,EVT?[10011],EVT?[10695],, +10696,塔利班组织闪击波兰。法国宣布投降。,,,,,,,,,EVT?[10011],EVT?[10696],, +10697,俄罗斯宣布进入社会主义社会。,,,,,,,,,EVT?[10011],EVT?[10697],, +10698,日本动漫产业彻底灭亡。,,,,,,,,,"EVT?[10011,10010]",EVT?[10698],, +10699,日本制造出最新作战兵器:高达。,,,,,,,,,EVT?[10011],EVT?[10699],, +10700,美国总统承认与外星人一直有联系。,,,,,,,,,EVT?[10011],EVT?[10700],, +10701,经济危机爆发。,,,,,,,,,EVT?[10011],EVT?[10701],, +10702,美国精英制定影视音乐作品通用评分标准,引发广泛争议。,,,,,,,,,EVT?[10011],EVT?[10702],, +10703,百慕大三角海底发现中国古代风格建筑。,,,,,,,,,EVT?[10011],EVT?[10703],, +10704,马斯克登陆火星。,,,,,,,,,EVT?[10011],EVT?[10704],, +10705,中国宣布同性恋为犯罪,将至少判处3年以下的有期徒刑。,,,,,,,,,EVT?[10011],EVT?[10705],, +10706,金正恩在朝鲜称帝,改为帝制。,,,,,,,,,EVT?[10011],EVT?[10706],, +10707,你学会了打麻将。,,,,,,,,,"EVT?[10607,10608,10609]",EVT?[10707],, +10708,你以前常去的高尔夫球场被陨石击中。,,,,,,,,,"EVT?[10607,10608]",EVT?[10708],, +10709,你最好的朋友去世。,,,,,,-1,,,EVT?[10011],EVT?[10709],, +10710,城市里到处都是全息投影。,,,,,,,,,"EVT?[10011,10010]",EVT?[10710],, +10711,全息投影彻底取代手机。,,,,,,,,,EVT?[10011],EVT?[10711],, +10712,现在可以通过植入芯片来获得一小段记忆或知识。,,,,,,,,,EVT?[10011],EVT?[10712],, +10713,近视已经可以轻松治愈。,,,,,,,,,"EVT?[10011,10010]",EVT?[10713],, +10714,计算机科学家宣称,我们生活在游戏世界中的概率为100%。,,,,,,,,,EVT?[10011],EVT?[10714],, +10715,你发现了大统一模型。,,,,,,,,,EVT?[10679],EVT?[10715],, +10716,你再次获得诺贝尔物理学奖。,,,,,,,,,EVT?[10715],EVT?[10716],, +10717,你感觉学校的环境各方面都不如美国好。,,,,,,,,,"EVT?[10586,10587]",EVT?[10717],, +10718,你对学校不太满意,但凑合着学,渐渐更多的时间用在了玩乐上。,,,,,,,,,"EVT?[10586,10587]",EVT?[10718],, +10719,你平时都和留学生来往,很少和普通学生交流。,,,,,,,,,"EVT?[10586,10587]",EVT?[10719],, +10720,据说你们的课业要求比普通学生的简单。,,,,,,,,,"EVT?[10586,10587]",EVT?[10720],, +10721,据说老师让很多普通学生故意挂科,保证你们留学生不至于被退学。,,,,,,,,,"EVT?[10586,10587]",EVT?[10721],, +10722,中国的食物你吃不习惯。,,,,,,-1,,,"EVT?[10586,10587]",EVT?[10722],, +10723,北京的空气和气候你很不习惯。,,,,,,-1,,,"EVT?[10586,10587]",EVT?[10723],, +10724,你有时翘课去北京的各景区游玩。,,,,,,,,,"EVT?[10586,10587]",EVT?[10724],, +10725,你的中文说的很流利。,,,,,,,,,"EVT?[10586,10587]",EVT?[10725],, +10726,你没有参加社团,但经常和其他留学生开party。,,,,,,,,,"EVT?[10586,10587]",EVT?[10726],, +10727,你有些想家。,,,,,,,,,"EVT?[10586,10587]",EVT?[10727],, +10728,你父母来北京看望你。,,,,,,,,,"EVT?[10586,10587]",,, +10729,你经常去看电影、音乐会、演唱会。,,,,,,,,,"EVT?[10586,10587]",EVT?[10729],, +10730,你爬了长城,感觉不怎么样,又挤又乱。,,,,,,,,,"EVT?[10586,10587]",EVT?[10730],, +10731,你假期去了上海和香港玩。,,,,,,1,,,"EVT?[10586,10587]",EVT?[10731],, +10732,你假期去西藏旅游。,,,,,,1,,,"EVT?[10586,10587]",EVT?[10732],, +10733,有短视频主播采访你英文水平如何,你假装是普通学生作答。,,,,,,,,,"EVT?[10586,10587]",EVT?[10733],, +10734,你感觉中国的高铁很方便。,,,,,,,,,"EVT?[10586,10587]",EVT?[10734],, +10735,你感觉中国的电子支付很方便。,,,,,,,,,"EVT?[10586,10587]",EVT?[10735],, +10736,你博士毕业了。,,,,,,,,,"EVT?[10586,10587]",EVT?[10736],, +10737,你进入名企工作。,,,,,,,,,"EVT?[10586,10587]",EVT?[10737],, +10738,你的工作并不像其他人盛传的那种996,下午下班后你还去健身。,,,,,,,,,"EVT?[10586,10587]",EVT?[10738],, +10739,公司组织去马尔代夫旅游。,,,,,,1,,,"EVT?[10586,10587]",EVT?[10739],, +10740,公司的休息厅提供西式茶点,令你很满意。,,,,,,1,,,"EVT?[10586,10587]",EVT?[10740],, +10741,普普通通的社畜生活。,,,,,,,,,"EVT?[10586,10587]",EVT?[10741],, +10742,你养了一只猫。,,,,,,,,,"EVT?[10586,10587]","EVT?[10742,10743]",, +10743,你养了一只狗。,,,,,,,,,"EVT?[10586,10587]","EVT?[10743,10742]",, +10744,你养的猫意外死亡。,,,,,,-1,,,EVT?[10742],(EVT?[10744])|(TLT?[1030]),, +10745,你养的狗意外死亡。,,,,,,-1,,,EVT?[10743],(EVT?[10745])|(TLT?[1030]),, +10746,你升职了。,,,,,1,,,,"EVT?[10586,10587]","EVT?[10746,10002,10110,10111]",, +10747,你又升职了。,,,,,1,1,,,EVT?[10746],"EVT?[10747,10002,10110,10111]",, +10748,你有次在地铁上被偷了手机,报警后警方高度重视,立即出动,当天就追回了你的手机。,,,,,,,,,"EVT?[10586,10587]",EVT?[10748],, +10749,你经常阅读一些财经杂志和哲学书籍。,,,,,,,,,"EVT?[10586,10587]",EVT?[10749],, +10750,你在视频APP上分享你的人生,收获大量粉丝。,,,,,,,,,"(CHR>6)&(EVT?[10586,10587])",EVT?[10750],, +10751,你经常逛知乎并回答国外和商业相关问题,迅速成为大V。,,,,,,,,,"EVT?[10586,10587]",EVT?[10751],, +10752,你逐渐意识到你和普通中国人思维方式的不同。,,,,,,,,,"EVT?[10586,10587]",EVT?[10752],, +10753,你经常感到生活中严重的男女不平等。,,,,,,,,,"EVT?[10586,10587]","EVT?[10753,10001]",, +10754,你组织一些线下活动,和很多遭遇性别歧视的人一起讨论方案和分享经历。,,,,,,,,,EVT?[10753],EVT?[10754],, +10755,你出了一本描绘和分析性别歧视现象的书。,,,,,,,,,EVT?[10754],EVT?[10755],, +10756,你的理财收益不错。,,,,,1,,,,"(MNY>6)&(EVT?[10586,10587])",EVT?[10756],, +10757,你去黄山旅游。,,,,,,,,,"EVT?[10586,10587]",EVT?[10757],, +10758,你请了年假一口气游玩了五岳。,,,,,,,,,"EVT?[10586,10587]",EVT?[10758],, +20759,被天价海鲜坑了不少钱。,,,,,,,,1,,,, +10759,你去三亚旅游。,,,,,,,,,"EVT?[10586,10587]",EVT?[10759],INT<7:20759, +10760,你的一位同事代孕了第三胎。,,,,,,,,,"EVT?[10586,10587]",EVT?[10760],, +10761,你参加了一档老外夸中国的综艺节目。,,,,,,,,,"EVT?[10586,10587]",EVT?[10761],, +10762,你网上的粉丝很多,你的网红收入甚至超过你的工资。,,,,,1,,,,"EVT?[10750,10751]",EVT?[10762],, +10763,你的项目大获成功。,,,,,,,,,"EVT?[10586,10587]",EVT?[10763],, +10764,在一次重要的饭局中,你作为翻译出场。,,,,,,,,,"(INT>2)&(EVT?[10586,10587])",EVT?[10764],, +10765,你购买了名车名表。,,,,,,,,,"(MNY>7)&(EVT?[10586,10587])",EVT?[10765],, +10766,你参加了公司里的斯诺克比赛。,,,,,,,,,"(STR>3)&(EVT?[10586,10587])",EVT?[10766],, +10767,你仅凭每月的理财收入就超过99%的人了。,,,,,,,,,"(MNY>7)&(EVT?[10586,10587])",EVT?[10767],, +10768,你在一次旅游中遭遇车祸。,,,,,,,,,"EVT?[10586,10587]",(EVT?[10768])|(TLT?[1043]),STR<9:10000, +10769,你退休了。,,,,,,,,,"EVT?[10586,10587]",EVT?[10769],, +10770,【绝密消息】科学家认为大多数人的天赋都是来人间凑数的。,,,,,,,,,TLT?[1112],EVT?[10770],, +10771,【绝密消息】你捡到一张纸条,上面写着一位策划的联系方式:846945492,,,,,,,,,TLT?[1112],"EVT?[10771,10772]",, +10772,【绝密消息】你捡到一张纸条,上面写着一位程序的联系方式:1281616438。,,,,,,,,,TLT?[1112],"EVT?[10772,10771]",, +10773,【绝密消息】据说,修仙者是真实存在的……,,,,,,,,,TLT?[1112],"EVT?[10773,10774]",, +10774,【绝密消息】据说,正常人无论如何都活不到100岁,除非……有个小盒子?,,,,,,,,,TLT?[1112],"EVT?[10774,10773]",, +10775,【绝密消息】考古学家发现一粒古代的药丸,看上去金灿灿的,不像凡物。,,,,,,,,,TLT?[1112],EVT?[10775],, +10776,【绝密消息】有人说世界上只有中国和美国是真实存在的。,,,,,,,,,TLT?[1112],EVT?[10776],, +10777,【绝密消息】有人说“如果你很有钱,就出生不到农村;很穷,就出生不到城市。一个猜测,不知道对不对。”,,,,,,,,,TLT?[1112],EVT?[10777],, +10778,【绝绝子消息】今日份甜甜碎片已加载完毕??,不是8??,宝!我今天重开人生了??,我真的哭死,呢呢呢,这家的人生好重开到跺jiojio~~~这杯小布丁也有被惊艳到??????无语子,路上还看见一个Java男,大无语事件,哒哒哒,岁月漫长 那就一起拯救地球与乐趣吧??,,,,,,,,,"EVT?[10770,10771,10772,10773,10774,10775,10776,10777,10779,10780]",EVT?[10778],, +10779,【绝密消息】遗传学家说,最好的天赋只有0.1%的几率出现,其次的天赋是1%,比较好的天赋是10%。,,,,,,,,,TLT?[1112],EVT?[10779],, +10780,【绝密消息】专家认为,一些中老年人生活乏味,只能看新闻度日,是因为某人编不出事件了。,,,,,,,,,TLT?[1112],EVT?[10780],, +10781,【绝密消息】据说某游戏由两人制作完成,程序员只花了几个小时就写完了程序,而无业在家的策划花了一周多才写完文案。,,,,,,,,,TLT?[1112],EVT?[10781],, +10782,【绝密消息】你看了一本玄幻小说,小说里想度过天劫需要悟透全部五行大道和任意一种本源大道。,,,,,,,,,TLT?[1112],EVT?[10782],, +10783,【绝密消息】一名不到25岁的作者强行描写完全不懂的中年和婚后生活,遭致大量批评。,,,,,,,,,TLT?[1112],EVT?[10783],, +10784,【绝密消息】某辣鸡游戏十连抽竟然没有保底,就像地球online一样。,,,,,,,,,TLT?[1112],EVT?[10784],, +10785,你患上了严重的急性肠胃炎。,,,,,,-1,,,(STR<5)&(EVT?[10011]),EVT?[10785],STR<2:10000, +10786,你突发过敏性哮喘。,,,,,,-1,,,(STR<2)&(EVT?[10011]),EVT?[10786],STR<2:10000, +10787,你进入了一个渡劫期大能的传承洞府。,虽然没能通过传承,但获得了少量好处。,1,1,1,1,1,,,(INT>5)&(TLT?[1048]),EVT?[10787],INT>13:10788, +10788,获得了传承。所有属性大幅提升。,,2,20,200,2,2,,1,,,, +10789,你捡到一个破碎的仙器,里面有个知识渊博的器魂。,从此智力不再是你修行路上的问题。,,100,,,,,,(MNY>13)&(TLT?[1048]),EVT?[10789],, +10790,你感觉到衰老,很容易疲惫。,,,,-1,,,,,"EVT?[10011,10010]",EVT?[10790],, +10791,你的胃口越来越小,感觉时间过得越来越快。,,,,,,,,,"EVT?[10011,10010]",EVT?[10791],, +10792,你们家装了全自动洗浴间,人进去可以自动完成沐浴和洗漱。,,,,,,,,,EVT?[10011],EVT?[10792],, +10793,你们家买了飞车,全球拥有飞车的人很少很少。,,,,,,,,,EVT?[10011],EVT?[10793],, +10794,你有一些慢性病,需要持续吃药。,,,,-2,,,,,"(STR<9)&(EVT?[10011,10010])",EVT?[10794],, +10795,你开始觉得钱财无用,身体健康才是最重要的。,,,,,,,,,"EVT?[10011,10010]",EVT?[10795],, +10796,你意外吃到一份儿时味道的菜,流下了眼泪。,,,,,,,,,EVT?[10011],EVT?[10796],, +10797,大太空航行时代到来。,,,,,,,,,EVT?[10011],EVT?[10797],, +10798,经常有年轻时的熟人来拜访你。,,,,,,,,,"EVT?[10011,10010]",EVT?[10798],, +10799,基础学科发展缓慢。,,,,,,,,,EVT?[10011],"EVT?[10799,10715]",, +10800,你家设置了模拟外景,可以实时显示世界各地的风光。,,,,,,,,,EVT?[10011],EVT?[10800],, +10801,你家换上了自动地板,可以自动清洁、移动、变温等。,,,,,,,,,EVT?[10011],EVT?[10801],, +10802,你家换上了意识控制家具。脑中思考就可以控制家具家电。,,,,,,,,,EVT?[10011],EVT?[10802],, +10803,你感叹医学发展缓慢,至今仍未攻克癌症和心血管疾病。,,,,,,,,,EVT?[10011],EVT?[10803],, +10804,人工合成肉已经普及,几乎取代了真肉,但你家仍然食用真肉。,,,,,,,,,EVT?[10011],EVT?[10804],, +10805,中国可控核聚变技术完全成熟,进入无限能源的时代。,,,,,,,,,EVT?[10011],EVT?[10805],, +10806,人类几乎可以完全控制天气。,,,,,,,,,"EVT?[10011,10010]",EVT?[10806],, +10807,你越来越喜欢哲学书籍,经常看《道德经》和后现代哲学。,,,,,,,,,(INT>5)&(EVT?[10011]),EVT?[10807],, +10808,你仍然习惯使用笨重的实体电脑,而不是全息计算机。,,,,,,,,,EVT?[10011],EVT?[10808],, +10809,越来越多的人沉迷在虚拟世界,包括你的家人们。,,,,,,,,,EVT?[10011],EVT?[10809],, +10810,书籍这种媒介竟然没有退出历史舞台,你也很意外。,,,,,,,,,"EVT?[10011,10010]",EVT?[10810],, +10811,美国迎来了一位跨性别穆斯林黑人总统。,,,,,,,,,EVT?[10011],EVT?[10811],, +10812,全球变暖严重,专家称100年内日本就会彻底沉没。,,,,,,,,,EVT?[10011],EVT?[10812],, +10813,有哲学家称世界是由信息构成的,物质的运动就是信息的传递。,,,,,,,,,EVT?[10011],EVT?[10813],, +10814,墨西哥毒贩夺取政权,宣布新政府成立。美国从墨西哥撤兵。,,,,,,,,,EVT?[10011],EVT?[10814],, +10815,你开始关注美国底层人民的生活,计划进行一些慈善。,,,,,,,,,EVT?[10011],EVT?[10815],, +10816,你因为容貌被破例进入一座洞府。体质大幅提升。,,,,20,,,,,(CHR>13)&(TLT?[1048]),EVT?[10816],, +10817,你捡到天阶灵器,实力大幅提升。,,,,50,,,,,TLT?[1048],EVT?[10817],, +10818,你和一位相同境界的人结为道侣。,,,,,,,,,TLT?[1048],EVT?[10818],, +10819,你的道侣被人斩杀。,,,,,,-1,,,(TLT?[1048])&(EVT?[10818]),EVT?[10819],, +10820,你走火入魔,体质大幅降低。,,,,-100,,,,,TLT?[1048],,, +10821,你走火入魔,体质大幅降低。,,,,-10,,,,,TLT?[1048],,, +10822,你上了一个昂贵的双语幼儿园。,,,,,,,,,TLT?[1010],EVT?[10822],, +10823,你上了一个昂贵的双语幼儿园。,,,,,,,,,(MNY>7)&(EVT?[10010]),EVT?[10823],, +10824,你上了一个普通的幼儿园。,,,,,,,,,EVT?[10010],(MNY<8)&(EVT?[10824]),, +10825,你的家人给你买了很多玩具。,,,,,,,,,EVT?[10010],EVT?[10825],, +10826,你的家人给你买了很多书。,,,,,,,,,EVT?[10010],EVT?[10826],, +10827,你进入了托儿所。,,,,,,,,,EVT?[10010],EVT?[10827],, +10828,你的家人开始教你学英语。,,,,,,,,,TLT?[1010],EVT?[10828],, +10829,你的家人为你制定了长长的人生计划。,,,,,,,,,EVT?[10010],EVT?[10829],, +10830,你生了二胎。,,,,-1,-1,,,,"(TLT?[1113])&(EVT?[10268,10269,10621])",EVT?[10830],, +10831,你生了三胎。,,,,-1,-1,,,,EVT?[10830],EVT?[10831],, +10832,你患上了严重的妇科疾病。,,,,-1,,,,,EVT?[10830],"EVT?[10832,10836]",, +10833,生育时留下的后遗症,你经常漏尿。,,,,,,,,,EVT?[10830],EVT?[10833],, +10834,三个孩子给你们的生活带来了很多不便。,,,,,,-1,,,EVT?[10831],EVT?[10834],, +10835,你后悔生了三胎。,,,,,,,,,EVT?[10831],EVT?[10835],, +10836,你得了子宫肌瘤。,,,,,,,,,EVT?[10830],"EVT?[10836,10832]",, +10837,你的体态愈发臃肿。,,-2,,,,-1,,,EVT?[10830],EVT?[10837],, +10838,孩子填满了你的生活,你感觉自己仿佛不是自己,而是机器。,,,,,,-1,,,EVT?[10830],EVT?[10838],, +10839,你的家人将一套房产转移到你名下。,,,,,,,,,(MNY>8)&(TLT?[1010]),EVT?[10839],, +10840,你意外一跤摔到了后脑。,,,-1,,,,,,EVT?[10010],EVT?[10840],TLT?[1001]:10004,STR<3:10000 +10841,时间跳跃。,,,,,,,,,TLT?[1114],EVT?[10842],, +10842,时空错乱,你中途被抛出。,,,,,,,,,TLT?[1114],EVT?[10842],, +10843,你的体质极度虚弱。,,,,,,,,,(STR<2)&(EVT?[10010]),EVT?[10843],, +10844,你患重病身亡。,,,,,,,,,EVT?[10843],EVT?[10844],EVT?[10843]:10000, +10845,你开始学习舞蹈。,,,,,,,,,"EVT?[10822,10823]","EVT?[10845,10001]",, +10846,你开始学习书法。,,,,,,,,,"EVT?[10822,10823]",EVT?[10846],, +10847,你开始学习钢琴。,,,,,,,,,"EVT?[10822,10823]",EVT?[10847],, +10848,你的博士妈妈开始教你物理化学生物。,,,,,,,,,"EVT?[10822,10823]","EVT?[10848,10869]",, +10849,你的识字量达到了2000。,,,,,,,,,"EVT?[10822,10823]","EVT?[10856,10857,10849,10850]",, +10850,你的识字量达到了1500。,,,,,,,,,"EVT?[10822,10823]","EVT?[10856,10857,10849,10850]",, +10851,你做了智商测试,智商高达150。,,,,,,,,,(INT>8)&(((MNY>7)&(EVT?[10010]))|(TLT?[1010])),EVT?[10851],, +10852,你开始学习游泳。,,,,,,,,,"EVT?[10822,10823]",EVT?[10852],, +10853,你的高级工程师爸爸开始教你编程。,,,,,,,,,"EVT?[10822,10823]","EVT?[10853,10868]",, +10854,爸妈带你去日本旅游。,,,,,,,,,"EVT?[10822,10823]","EVT?[10854,10868,10869]",, +10855,爸妈带你去美国旅游。,,,,,,,,,"EVT?[10822,10823]","EVT?[10855,10868,10869]",, +10856,你的识字量达到了300。,,,,,,,,,EVT?[10824],"EVT?[10856,10857,10849,10850]",, +10857,你的识字量达到了500。,,,,,,,,,EVT?[10824],"EVT?[10856,10857,10849,10850]",, +10858,幼儿园老师每天都和你们玩游戏。,,,,,,1,,,EVT?[10824],EVT?[10858],, +10859,幼儿园的饭菜不好吃。,,,,,,-1,,,EVT?[10824],EVT?[10859],, +10860,幼儿园要求每天午睡,但你经常睡不着。,,,,,,,,,EVT?[10824],EVT?[10860],, +10861,上课时,你很乖,坐姿端正。,,,,,,,,,EVT?[10824],"EVT?[10861,10862]",, +10862,上课时,你经常偷偷溜出教室。,,,,,,,,,EVT?[10824],"EVT?[10862,10861]",, +10863,你很可爱,很讨老师和小朋友喜欢。,,,,,,1,,,((CHR>7)|(TLT?[1037]))&(EVT?[10824]),EVT?[10863],, +10864,你学会了骑自行车。,,,,,,,,,(EVT?[10010])&(TLT?[1038]),EVT?[10864],, +10865,你喜欢玩迷宫和脑筋急转弯。,,,,,,-1,,,(INT>5)&(EVT?[10824]),EVT?[10865],, +10866,你家长为你请了家庭教师。,,,,,,-1,,,(MNY>5)&(EVT?[10824]),EVT?[10866],, +10867,你的玩电脑和看电视时间都要通过积分兑换。,,,,,,,,,EVT?[10824],EVT?[10867],, +10868,你的父亲意外去世。,,,,,,,,,EVT?[10010],"(EVT?[10868,10869])|(TLT?[1029])",, +10869,你的母亲意外去世。,,,,,,,,,EVT?[10010],"(EVT?[10869,10868])|(TLT?[1029])",, +10870,你上了个普通小学。,,,,,,,,,EVT?[10824],EVT?[10870],, +10871,你上了个名牌小学。,,,,,,,,,"EVT?[10822,10823]",EVT?[10871],, +10872,你获得了机器人大赛金奖。,,,,,,,,,(INT>8)&(EVT?[10853]),EVT?[10872],, +10873,你获得了三好学生。,,,,,,,,,(INT>5)&(EVT?[10824]),EVT?[10873],, +10874,你获得了三好标兵。,,,,,,,,,(INT>6)&(EVT?[10824]),EVT?[10874],, +10875,你获得了市三好学生。,,,,,,,,,"(INT>7)&(EVT?[10822,10823])",EVT?[10875],, +10876,你获得了区三好标生。,,,,,,,,,"(INT>7)&(EVT?[10822,10823])",EVT?[10876],, +10877,你当上了班长。,,,,,,,,,EVT?[10010],EVT?[10877],, +10878,你帮班里出了一期黑板报。,,,,,,,,,(EVT?[10010])&(EVT?[10048]),EVT?[10878],, +10879,你阅读了大量英文小说和杂志。,,,,,,,,,(INT>5)&(EVT?[10871]),EVT?[10879],, +10880,你在运动会上取得了好成绩。,,,,,,,,,(STR>6)&(EVT?[10010]),EVT?[10880],, +10881,你需要上大量课外班,压力很大。,,,,,,-1,,,EVT?[10010],EVT?[10881],TLT?[1108]:10882, +10882,你电话举报了课外班,课外班被查封了。你开心了。,,,,,,1,,1,,,, +10883,你参与了辩论会。,,,,,,,,,(INT>3)&(EVT?[10010]),EVT?[10883],, +10884,你参与了学校的文艺演出。,,,,,,,,,(CHR>3)&(EVT?[10010]),EVT?[10884],, +10885,你喜欢班上的一个小朋友。不过是很纯洁的喜欢。,,,,,,,,,EVT?[10870],EVT?[10885],, +10886,你常常能指出老师的错误。,,,,,,,,,(INT>8)&(EVT?[10010]),EVT?[10886],, +10887,你第一次因为犯错被罚写检查。,,,,,,-1,,,EVT?[10010],"EVT?[10887,10888,10889]",, +10888,你第一次因为犯错被罚站。,,,,,,-1,,,EVT?[10010],"EVT?[10887,10888,10889]",, +10889,你第一次因为犯错被罚抄课文。,,,,,,-1,,,EVT?[10010],"EVT?[10887,10888,10889]",, +10890,你的父母带你四处旅游、参加活动刷履历。,,,,,,,,,EVT?[10871],EVT?[10890],, +10891,你开始学习日语。,,,,,,,,,EVT?[10871],EVT?[10891],, +10892,你开始学习法语。,,,,,,,,,EVT?[10871],EVT?[10892],, +10893,你达到了钢琴10级。,,,,,,,,,EVT?[10847],EVT?[10893],, +10894,你雅思拿到7.5分。,,,,,,,,,(INT>7)&(EVT?[10871]),"EVT?[10894,10895]",, +10895,你的英语词汇量达到10000。,,,,,,,,,(INT>7)&(EVT?[10871]),"EVT?[10895,10894]",, +10896,你参加美国数学竞赛获得一等奖。,,,,,,,,,(INT>7)&(EVT?[10871]),EVT?[10896],, +10897,你们学校组织前往南极修学旅行。,,,,,,,,,EVT?[10871],EVT?[10897],, +10898,你的美貌十分惊艳。,,,,,,,,,(CHR>7)&(EVT?[10010]),EVT?[10898],, +10899,你遭到了一位老师的猥亵。,你逐渐消沉,但不敢和其他人说。,,,,,-2,,,EVT?[10898],EVT?[10899],INT>7:10900, +10900,你报了警,老师被刑拘。,,,,,,1,,1,,,, +10901,你对自然科学和社会科学的常识都了解不少。,,,,,,,,,EVT?[10870],EVT?[10901],, +10902,学校的课程非常重,和普通高中的高三差不多。,,,,,,-1,,,EVT?[10871],EVT?[10902],, +10903,家人给了你一笔资金让你理财。,,,,,,,,,EVT?[10871],EVT?[10903],, +10904,你近视了。,,-1,,,,,,,EVT?[10010],EVT?[10904],, +10905,家人送你去国外读了一年。,,,,,,1,,,EVT?[10871],EVT?[10905],, +10906,你家开始养猫。,,,,,,,,,EVT?[10010],EVT?[10906],, +10907,你家开始养狗。,,,,,,,,,EVT?[10010],EVT?[10907],, +10908,你家的猫意外死亡。,,,,,,-1,,,EVT?[10906],(EVT?[10908])|(TLT?[1030]),, +10909,你家的狗意外死亡。,,,,,,-1,,,EVT?[10907],(EVT?[10909])|(TLT?[1030]),, +10910,你的家人极力阻止你看动漫。,,,,,,-1,,,"(EVT?[10871])&(EVT?[10007,10008])",EVT?[10910],, +10911,你的家人开始禁止你玩电子游戏。,,,,,,-1,,,EVT?[10871],(EVT?[10911])|(TLT?[1039]),, +10912,你第一次当上课代表。,,,,,,,,,EVT?[10870],EVT?[10912],, +10913,有个同学每天在车站等你一起上学。,,,,,,,,,EVT?[10870],EVT?[10913],, +10914,你以班上同学为角色画漫画。,,,,,,,,,EVT?[10870],"EVT?[10914,10926]",, +10915,你们的体育课总是变成自习课。,,,,,,,,,EVT?[10870],EVT?[10915],, +10916,你们的班主任为了生三胎辞职了。,,,,,,,,,EVT?[10010],EVT?[10916],, +10917,信息课上,你和同学玩可以联机的游戏。,,,,,,,,,EVT?[10870],EVT?[10917],TLT?[1039]:20917, +20917,你总是赢。,,,,,,1,,1,,,, +10918,音乐课老师经常放电影。,,,,,,,,,EVT?[10010],EVT?[10918],, +10919,你经常和几个同学打架。,,,,,,-1,,,EVT?[10010],"(EVT?[10919,10002,10926])|(TLT?[1037])",, +10920,你的作文被老师作为范文朗读,但你却很尴尬。,,,,,,,,,EVT?[10010],EVT?[10920],, +10921,你家人经常给你买核桃等坚果补脑。,,,,,,,,,EVT?[10010],EVT?[10921],, +10922,你每天都喝牛奶。,,,,1,,,,,EVT?[10010],EVT?[10922],, +10923,你又要买大一号的新校服了。,,,,,,,,,EVT?[10010],EVT?[10923],, +10924,你每天做作业都要做到凌晨。,,,,-1,,-1,,,EVT?[10871],EVT?[10924],, +10925,你每天做作业都要做到深夜。,,,,-1,,-1,,,EVT?[10870],EVT?[10925],, +10926,虽然你还小,但你几乎和20岁左右的青年差不多成熟了。,,,,,,,,,EVT?[10871],EVT?[10926],, +10927,你开始很严肃地思考未来和制定计划。,,,,,,,,,EVT?[10871],EVT?[10927],, +10928,你写了封寄给10年后自己的信。,,,,,,,,,EVT?[10010],EVT?[10928],, +10929,学校被禁止搞排名,但你老师报成绩时还是默认按顺序来。,,,,,,,,,EVT?[10010],EVT?[10929],, +10930,你喜欢在学校的石质乒乓球台上打球。,,,,,,,,,(STR>2)&(EVT?[10870]),EVT?[10930],, +10931,你加入了学校篮球队。,,,,,,,,,(STR>6)&(EVT?[10010]),"EVT?[10931,10002]",, +10932,你经常和其他同学一起去上厕所。,,,,,,,,,EVT?[10010],EVT?[10932],, +10933,升旗时你经常对口型假唱。,,,,,,,,,EVT?[10010],EVT?[10933],, +10934,学校校长因贪污受贿被捕。,,,,,,,,,EVT?[10871],EVT?[10934],, +10935,你觉得广播体操《舞动青春》的音乐很好听。,,,,,,,,,EVT?[10871],EVT?[10935],, +10936,做操体转运动时,你经常趁机回头看别的同学。,,,,,,,,,EVT?[10010],EVT?[10936],, +10937,你假装没有全学会,避免了压力更大的跳级。,,,,,,,,,(INT>8)&(EVT?[10010]),EVT?[10937],, +10938,你颜值出众,准备走娱乐路线。,,,,,,,,,(EVT?[10898]),EVT?[10938],, +10939,你被体校教练挖走。,,,,,,,,,EVT?[10880],EVT?[10939],, +10940,你升入普通初中。,,,,,,,,,EVT?[10870],EVT?[10940],, +10941,你升入名牌初中。,,,,,,,,,EVT?[10871],EVT?[10941],, +10942,你的游戏技术过人,在学校小有名气。,,,,,,,,,(TLT?[1039])&(EVT?[10940]),EVT?[10942],, +10943,你中考没有考好。,,,,,,,,,(EVT?[10940])&(EVT?[10258]),EVT?[10943],, +10944,你考到了一所重点高中。,,,,,,,,,((INT>6)&(EVT?[10940]))|(EVT?[10941]),"EVT?[10944,10258]",, +10945,你考到了一所普通高中。,,,,,,,,,(INT<7)&(EVT?[10940]),"EVT?[10945,10258]",, +10946,你考上了人大附中。,,,,,,,,,(TLT?[1010])&(INT>6),EVT?[10946],, +10947,训练。,,,,,,,,,EVT?[10939],,, +10948,培训,整容。,,1,,,,,,,(MNY<8)&(EVT?[10938]),EVT?[10948],, +10949,参加选秀。没有能力砸钱,迅速被淘汰。,,,,,,-1,,,EVT?[10948],EVT?[10949],, +10950,加入年轻艺人团体出道。,,,,,,,,,EVT?[10948],EVT?[10950],, +10951,遇冷,彻底被资本家放弃。你退圈了。,,,,,,,,,EVT?[10948],EVT?[10951],, +10952,你转行做颜值主播。,,,,,,,,,EVT?[10951],EVT?[10952],, +10953,你转行从事短视频生产行业。,,,,,,,,,EVT?[10951],EVT?[10953],, +10954,你转行做虚拟主播。,,,,,,,,,"(EVT?[10951])&(EVT?[10008,10007])",EVT?[10954],, +10955,你转行从事动漫UP主行业。,,,,,,,,,"(EVT?[10951])&(EVT?[10008,10007])",EVT?[10955],, +10956,你靠卖肉和开网店维持收入。,,,,,,,,,"EVT?[10952,10953]",EVT?[10956],, +10957,你靠人傻钱多二次元维持生计。,,,,,,,,,"EVT?[10954,10955]",EVT?[10957],, +10958,家人投钱帮你造势。,,,,,,,,,(MNY>7)&(EVT?[10938]),EVT?[10958],, +10959,你参与选秀节目,一举爆红。,,,,,,1,,,EVT?[10958],EVT?[10959],, +10960,你成为最热门的少年天团C位。,,,,,,,,,EVT?[10959],"EVT?[10960,10002]",, +10961,你成为最热门的少女天团C位。,,,,,,,,,EVT?[10959],"EVT?[10961,10001]",, +10962,演出、参加综艺节目。,,,,,,,,,"EVT?[10960,10961]",EVT?[10962],, +10963,出演电影《我的县长父亲》,热度大涨。,,,,,1,,,,"EVT?[10960,10961]",EVT?[10963],, +10964,出演电视剧《幸福农家乐》,广受好评。,,,,,,,,,"EVT?[10960,10961]",EVT?[10964],, +10965,你接取大量广告代言。,,,,,1,,,,"EVT?[10960,10961]",EVT?[10965],, +10966,你被北京电影学院录取。,,,,,,,,,"EVT?[10960,10961]",EVT?[10966],, +10967,你休闲时间喜欢追新番。,,,,,,,,,"(EVT?[10940])&(EVT?[10008,10007])",EVT?[10967],, +10968,你开始看网文,并且还偷偷自己拿小本子写。,,,,,,,,,EVT?[10940],EVT?[10968],, +10969,你入了cos圈。,,,,,,,,,"(EVT?[10940])&(EVT?[10008,10007])",EVT?[10969],, +10970,你经常女装。,,,,,,,,,EVT?[10969],"EVT?[10970,10002,10110,10111]",, +10971,你第一次看黄书。,,,,,,,,,EVT?[10010],"EVT?[10971,10972,10973]",, +10972,你第一次看A片。,,,,,,,,,EVT?[10010],"EVT?[10971,10972,10973]",, +10973,你第一次看里番。,,,,,,,,,"(EVT?[10010])&(EVT?[10008,10007])","EVT?[10971,10972,10973]",, +10974,你谈了一个女朋友。,,,,,,1,,,"(EVT?[10945])&((EVT?[10001,10110,10111])|(TLT?[1026]))",(EVT?[10974])|(TLT?[1027]),, +10975,你谈了一个男朋友。,,,,,,1,,,"(EVT?[10945])&((EVT?[10002,10110,10111])|(TLT?[1026]))",(EVT?[10975])|(TLT?[1027]),, +10976,你的数学老师因为课外补课而被逮捕。,,,,,,,,,EVT?[10940],EVT?[10976],, +10977,你们班的男生玩阿鲁巴,把学校的路灯锯断了。,,,,,,,,,EVT?[10945],EVT?[10977],, +10978,有只狗狗跑进你们班一起听课。,但很快被闻讯而来的城管抓走了。,,,,,,,,EVT?[10940],EVT?[10978],, +10979,有次值日,其他人都跑了,只有你一个人留在班上扫除到很晚。,,,,,,-1,,,EVT?[10940],"EVT?[10944,10979]",, +10980,由于补课禁令,你们下午5点多就放学了。,但课后要做的事更多了。,,,,,,,,EVT?[10945],EVT?[10980],, +10981,眼保健操的功效被证实是虚假信息,学校取消了每天的眼保健操。,,,,,,,,,EVT?[10940],EVT?[10981],, +10982,你的朋友很少。,,,,,,-1,,,(EVT?[10940])&(CHR<3),EVT?[10982],, +10983,你的朋友很多。,,,,,,,,,(EVT?[10940])&(CHR>6),EVT?[10983],, +10984,你能感受到学业难度的提升。,,,,,,,,,EVT?[10945],EVT?[10984],, +10985,有学生上课玩手机被老师抓到,老师将其手机扔出窗外。,,,,,,,,,EVT?[10945],EVT?[10985],, +10986,你同桌的男生很烦人,总是没事招惹你。,,,,,,-1,,,(EVT?[10940])&(EVT?[10002])&(CHR>5),"EVT?[10944,10986]",, +10987,有次写作业时灵光突现,你的智力提高了。,,,1,,,,,,EVT?[10940],EVT?[10987],, +10988,你现在很叛逆,讨厌别人管教你。,,,,,,,,,EVT?[10940],"EVT?[10944,10988]",, +10989,你买小卖部的饮料中了再来一瓶,中的打开又中了再来一瓶。,,,,,,1,,,EVT?[10940],"EVT?[10989,10990]",, +10990,你在学校小卖部买过很多次饮料,从来没中过奖。,,,,,,,,,EVT?[10940],"EVT?[10990,10989]",, +10991,午休时,你喜欢趴在桌子上午睡。,,,,,,,,,EVT?[10945],EVT?[10991],, +10992,越临近考试,你越不想学习。考完后你玩时却觉得没意思了。,,,,,,,,,EVT?[10940],EVT?[10992],, +10993,你做了MBTI测试,发现自己是INFP。,,,,,,,,,(EVT?[10010])&(SPR<4),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10994,你做了MBTI测试,发现自己是INTP。,,,,,,,,,(EVT?[10010])&(INT>7),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10995,你做了MBTI测试,发现自己是INFJ。,,,,,,,,,(EVT?[10010])&(SPR<6)&(CHR>5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10996,你做了MBTI测试,发现自己是ENTP。,,,,,,,,,(EVT?[10010])&(STR>5)&(INT>5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10997,你做了MBTI测试,发现自己是INTJ。,,,,,,,,,(EVT?[10010])&(CHR>4)&(INT>6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10998,你做了MBTI测试,发现自己是ENFP。,,,,,,,,,(EVT?[10010])&(STR>4)&(SPR>6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +10999,你做了MBTI测试,发现自己是ENFJ。,,,,,,,,,(EVT?[10010])&(CHR>4)&(SPR>6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11000,你做了MBTI测试,发现自己是ENTJ。,,,,,,,,,(EVT?[10010])&(CHR<5)&(SPR<5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11001,你做了MBTI测试,发现自己是ISFP。,,,,,,,,,(EVT?[10010])&(CHR>5)&(SPR<5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11002,你做了MBTI测试,发现自己是ISFJ。,,,,,,,,,(EVT?[10010])&(INT>5)&(SPR<5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11003,你做了MBTI测试,发现自己是ISTP。,,,,,,,,,(EVT?[10010])&(INT>5)&(STR<5),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11004,你做了MBTI测试,发现自己是ISTJ。,,,,,,,,,(EVT?[10010])&(INT>4)&(CHR<6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11005,你做了MBTI测试,发现自己是ESFP。,,,,,,,,,(EVT?[10010])&(CHR>5)&(STR>4),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11006,你做了MBTI测试,发现自己是ESTP。,,,,,,,,,(EVT?[10010])&(CHR>5)&(STR<6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11007,你做了MBTI测试,发现自己是ESFJ。,,,,,,,,,(EVT?[10010])&(CHR<6)&(INT<6),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11008,你做了MBTI测试,发现自己是ESTJ。,,,,,,,,,(EVT?[10010])&(CHR<6)&(STR>4),"EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]",, +11009,你梦见自己穿越回古代用现代知识乱杀。,,,,,,,,,EVT?[10940],"EVT?[10944,11009]",, +11010,上课时打了个盹,被老师粉笔头砸醒。,,,,,,,,,EVT?[10940],EVT?[11010],, +11011,同学们偷偷评选班花。,班花不是你。,,,,,,,,EVT?[10940],"EVT?[11011,10001,10110,10111]",CHR>7:21011, +21011,你被评为班花。,,,,,,1,,1,,,, +11012,同学们偷偷评选校草。,校草不是你。,,,,,,,,EVT?[10940],"EVT?[11012,10002,10110,10111]",CHR>8:21012, +21012,你被评为校草。,,,,,,1,,1,,,, +11013,有同学在纸上画游戏给其他同学玩,被老师没收了。,,,,,,,,,EVT?[10940],"EVT?[10944,11013]",, +11014,你后桌的同学抄你作业,不小心把你名字也抄上了。,,,,,,,,,EVT?[10940],"EVT?[10944,11014]",, +11015,学校食堂推出新菜:番茄炒西红柿。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11016,学校食堂推出新菜:去肉牛肉面。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11017,学校食堂推出新菜:青椒炒草莓。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11018,学校食堂推出新菜:酸梅汤豆腐脑。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11019,学校食堂推出新菜:可乐烧黄瓜。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11020,学校食堂推出新菜:面条馅包子。,,,,,,,,,EVT?[10940],"EVT?[10944,11015,11016,11017,11018,11019,11020]",, +11021,最新桌游三国自走棋风靡学校,放学后很多同学一起玩。,,,,,,,,,EVT?[10940],EVT?[11021],, +11022,学校组织在操场上办跳蚤市场。,你卖了些旧书。,,,,,,,,EVT?[10940],EVT?[11022],INT>8:21022, +21022,你买到一副貌似普通的画,竟然是名家真迹。,,,,,1,,,1,,,, +11023,你和一个老师闹了很大矛盾,心态爆炸。,,,,,,-1,,,EVT?[10940],EVT?[11023],SPR<2:10062, +11024,你脑力有限,跟不上课程。,,,,,,,,,(EVT?[10945])&(INT<2),EVT?[11024],, +11025,你身体不好,经常请假去医院。,,,,,,,,,(EVT?[10940])&(STR<2),EVT?[11025],STR<1:21025, +21025,你在一次手术中不幸去世。,,,,,,,,1,,,STR<1:10000, +11026,学校添加了性少数厕所。,,,,,,,,,"(EVT?[10010])&(EVT?[10110,10111,10002])",EVT?[11026],, +11027,校门口发生一起斗殴事件,多人受伤。,,,,,,,,,EVT?[10940],EVT?[11027],TLT?[1108]:21027, +21027,其中一人是你。,,,,-1,,,,,,,, +11028,学习压力很大,你向学校心理老师倾诉。,,,,,,,,,EVT?[10941],EVT?[11028],, +11029,学校食堂推出新菜:挂面炒意面。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11030,学校食堂推出新菜:醋香烤翅。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11031,学校食堂推出新菜:大东南羊肉串。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11032,学校食堂推出新菜:肉包沙拉。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11033,学校食堂推出新菜:酱油捞饭。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11034,学校食堂推出新菜:榴莲馅小笼包。,,,,,,,,,EVT?[10941],"EVT?[11029,11030,11031,11032,11033,11034]",, +11035,你很喜欢实验课。,,,,,,,,,EVT?[10941],EVT?[11035],, +11036,下课铃一响,所有人都抱着书冲向食堂。,,,,,,,,,EVT?[10944],EVT?[11036],, +11037,几乎每节课间你们老师都拖堂到下一节课铃响。,,,,,,,,,EVT?[10941],EVT?[11037],, +11038,你开始提前学后面的内容。,,,,,,,,,(EVT?[10941])&(INT>7),EVT?[11038],, +11039,你被淹没在题海中。,,,,,,-1,,,EVT?[10941],EVT?[11039],, +11040,同校有学生跳楼自杀。被学校压下来了。,,,,,,-1,,,EVT?[10941],EVT?[11040],, +11041,普通的内卷生活。,,,,,,,,,EVT?[10941],EVT?[11041],, +11042,班上有同学提前出国了。,,,,,,,,,EVT?[10941],EVT?[11042],, +11043,你们的英语课有时会让外教上。,,,,,,,,,EVT?[10941],EVT?[11043],, +11044,虽然你住校,但你母亲在学校附近租了个房子住。,,,,,,,,,EVT?[10941],"EVT?[11044,10869]",, +11045,你经常参加各类竞赛。,,,,,,,,,"(EVT?[10941,10946])&(INT>7)","EVT?[11045,21045]",, +21045,你经常参加各类竞赛。,,,,,,,,,"(EVT?[10941,10946])&(INT>5)&(TLT?[1115])","EVT?[11045,21045]",, +11046,你夺得了奥赛金牌。,,,,,,1,,,"(EVT?[11045,21045])&(INT>9)",EVT?[11046],, +11047,你经常参加各种夏令营。,,,,,,,,,EVT?[10941],EVT?[11047],, +11048,学校采取按成绩排考场,班上采取按成绩排座位。,,,,,,,,,EVT?[10941],EVT?[11048],, +11049,很多同学跟不上老师讲课的速度。,,,,,,,,,EVT?[10944],EVT?[11049],, +11050,两天一小考,三天一大考。,,,,,,,,,EVT?[10944],EVT?[11050],, +11051,你刷过的练习册已经一人高了。,,,,,,,,,EVT?[10944],EVT?[11051],, +11052,学校请来搞领导力培训的人到学校开动员大会。,很多同学被刺激到大哭大喊。,,,,,,,,EVT?[10944],EVT?[11052],, +11053,班上的空调坏了,老师故意不找人修,说要锻炼你们。,,,,,,-1,,,EVT?[10944],EVT?[11053],, +11054,你有点怀疑人生的意义。,,,,,,,,,(EVT?[10944])&(SPR<4),EVT?[11054],, +11055,班上挂上了励志条幅。,,,,,,,,,EVT?[10944],EVT?[11055],, +11056,老师用班费给大家买了他新出的辅导书。,,,,,,,,,EVT?[10944],EVT?[11056],, +11057,你的课桌上和抽屉里挤满了书,快要放不下了。,,,,,,,,,EVT?[10941],EVT?[11057],, +11058,你报了很多超难的课程。,,,,,,,,,(EVT?[10946])&(INT>7),EVT?[11058],, +11059,你们班所有老师都是特级教师。,,,,,,,,,EVT?[10946],EVT?[11059],, +11060,你经常参加各种学校社团、活动和节日。,,,,,,1,,,EVT?[10946],EVT?[11060],, +11061,有很多同学早就准备好出国了。,,,,,,,,,EVT?[10946],EVT?[11061],, +11062,你参加一个国际比赛获得一等奖,上了年度开学典礼的表彰。,,,,,,1,,,(EVT?[10946])&(INT>9),EVT?[11062],, +11063,虽然你比同龄人强很多,但你周围总有各方面比你都强的大佬。,,,,,,,,,EVT?[10946],EVT?[11063],, +11064,有老外在校门口用英文采访你,你对答如流。,,,,,,,,,EVT?[10946],EVT?[11064],, +11065,学校提供了很多和国外名校交流的机会。,,,,,,,,,EVT?[10946],EVT?[11065],, +11066,老师说:“少壮不努力,长大去隔壁。”,,,,,,,,,EVT?[10946],EVT?[11066],, +11067,你考上了少年班,提前步入大学。,,,,,,,,,(EVT?[10010])&(INT>9),EVT?[11067],, +11068,努力学习。,,,,,,,,,EVT?[11067],,, +11069,你出国留学。,,,,,,,,,EVT?[11067],EVT?[11069],, +11070,你前往哈佛大学留学。,,,,,,,,,(EVT?[11067])&(TLT?[1073]),EVT?[11070],, +11071,你考上了清华大学。,,,,,,,,,"((EVT?[10944,10945])&(INT>9))|(EVT?[10946])",(EVT?[11071])|(TLT?[1107]),, +11072,你考上了北京大学。,,,,,,,,,"((EVT?[10944,10945])&(INT>9))|(EVT?[10946])",EVT?[11072],, +11073,你被保送清华大学。,,,,,,,,,"EVT?[11046,11062]",(EVT?[11073])|(TLT?[1107]),, +11074,你被保送北京大学。,,,,,,,,,"EVT?[11046,11062]",EVT?[11074],, +11075,你考上一所985大学。,,,,,,,,,"(EVT?[10944,10945])&((INT>7)|(MNY>8))",EVT?[11075],, +11076,你考上一所211大学。,,,,,,,,,"(EVT?[10944,10945])&((INT>6)|(MNY>7))",EVT?[11076],, +11077,你考上一所双非本科。,,,,,,,,,"EVT?[10944,10945]",EVT?[11077],, +11078,高考结束,你们班一本率100%。,,,,,,,,,EVT?[10946],EVT?[11078],, +11079,高考结束,你们班一本率74%。,,,,,,,,,EVT?[10944],EVT?[11079],, +11080,高考结束,你们班一本率67%。,,,,,,,,,EVT?[10944],EVT?[11080],, +11081,高考结束,你们班一本率50%。,,,,,,,,,"EVT?[10944,10945]",EVT?[11081],, +11082,高考结束,你们班一本率92%。,,,,,,,,,EVT?[10944],EVT?[11082],, +11083,高考结束,你们班一本率80%。,,,,,,,,,EVT?[10944],EVT?[11083],, +11084,高考结束,你们班一本率35%。,,,,,,,,,EVT?[10945],EVT?[11084],, +11085,高考结束,你们班一本率40%。,,,,,,,,,EVT?[10945],EVT?[11085],, +11086,高考结束,你们班一本率25%。,,,,,,,,,EVT?[10945],EVT?[11086],, +11087,普通的自媒体生活。,,,,,,,,,"EVT?[10956,10957]",,, +11088,你和一个粉丝开始谈恋爱。,,,,,,,,,"EVT?[10956,10957]",EVT?[11088],, +11089,你和多个粉丝谈恋爱。,,,,,,,,,EVT?[11088],EVT?[11089],, +11090,你的热度逐渐走低。,,,,,,,,,"EVT?[10956,10957]",EVT?[11090],, +11091,你的收入比较低。,,,,,,,,,"EVT?[10956,10957]",EVT?[11091],, +11092,时刻担忧净网新规会对你产生影响。,,,,,,-1,,,"EVT?[10956,10957]",EVT?[11092],, +11093,你结婚了。,,,,,,,,,"EVT?[10956,10957]","(EVT?[11093,10612,11171,10229,10610,10611])|(TLT?[1027])",, +11094,普通的大学生活。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]",EVT?[11094],, +11095,你的生活和高中一样卷,抓紧各种时间看书。,,,,,,,,,"EVT?[11071,11072,11073,11074,11075,11076,11069,11070]",EVT?[11095],, +11096,班上总是有同学翘课,而且越来越多。,,,,,,,,,"EVT?[11077,11075,11076]",EVT?[11096],, +11097,你加入了学生会。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]",EVT?[11097],, +11098,你加入了好几个社团,但参加社团活动的时间并不多。,,,,,,,,,"EVT?[11071,11072,11073,11074,11075,11076,11069,11070]",EVT?[11098],, +11099,你加入了不少社团,课余生活很丰富。,,,,,,,,,EVT?[11077],EVT?[11099],, +11100,你的绩点不错。,,,,,,,,,"(INT>4)&(EVT?[11077,11075,11076,11071,11072,11073,11074])","EVT?[11100,11101,11102]",, +11101,你的绩点不好。,,,,,,,,,"((EVT?[11105,11106])|(INT<5))&(EVT?[11077,11075,11076,11071,11072,11073,11074])","(INT>8)|(EVT?[11100,11101,11102])",, +11102,你的绩点很棒。,,,,,,,,,"(INT>7)&(EVT?[11077,11075,11076,11071,11072,11073,11074])","EVT?[11100,11101,11102]",, +11103,你保研了。,,,,,,,,,EVT?[11102],EVT?[11103],, +11104,你没抢到想选修的课。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]",EVT?[11104],, +11105,你总是和室友去外面玩。,,,,,,,,,EVT?[11077],EVT?[11105],, +11106,你总是和室友在寝室打游戏。,,,,-1,,,,,EVT?[11077],"EVT?[11106,10002]",, +11107,你上课手机不离手。不过其他同学大多也是。,,,,,,,,,EVT?[11077],EVT?[11107],, +11108,你参加了志愿活动和社会实践。虽然是学分要求的。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]",EVT?[11108],, +11109,你挂了好几科。,,,,,,,,,"((EVT?[11105,11106])|(INT<4))&(EVT?[11077,11075,11076,11071,11072,11073,11074])",EVT?[11109],, +11110,你通过了英语和计算机等级考试。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]","EVT?[11110,11105,11106]",, +11111,你一年内谈了三次恋爱。,,1,,,,,,,"(EVT?[11077,11075,11076,11071,11072,11073,11074,11069.11070])&(TLT?[1028])","(EVT?[11111,11112,11113])|(TLT?[1027])",, +11112,你和一个同班同学谈恋爱。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]","(EVT?[11111,11112,11113])|(TLT?[1027])",, +11113,你一直没谈恋爱。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]","(EVT?[11111,11112,11113])|(TLT?[1028])",, +11114,你的寝室总是有蟑螂蚊子。,,,,,,-1,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]",EVT?[11114],, +11115,比起现实生活中的人,你更愿意和网友交流。,,,,,,,,,"EVT?[10993,10994,10995,10997,11001,11002,11003,11004]",EVT?[11115],, +11116,学校里总是有各种大佬的讲座可以听。,,,1,,,,,,"EVT?[11071,11072,11073,11074,11075,11076,11069,11070]",EVT?[11116],, +11117,学校里总是有各种名企来招人。,,,,,,,,,"EVT?[11071,11072,11073,11074,11075,11076,11069,11070]",EVT?[11117],, +11118,你的同学少有出生寒门,多是富二代、官二代、学二代。,,,,,,,,,"EVT?[11071,11072,11073,11074,11069,11070]",EVT?[11118],, +11119,大佬云集,你感到自己仿佛不再那么出众。,,,,,,,,,"EVT?[11071,11072,11073,11074,11069,11070]",EVT?[11119],, +11120,你的视野开阔了许多,很多想法都和在国内时不同。,,,,,,,,,"EVT?[11069,11070]",EVT?[11120],, +11121,你很早就开始寻找和联系导师。,,,,,,,,,"EVT?[11071,11072,11073,11074,11069,11070]",EVT?[11121],, +11122,你开始读研。,,,,,,,,,"EVT?[11103,11071,11072,11073,11074,11069,11070]",EVT?[11122],, +11123,你成为了打工人。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]","EVT?[11123,11124,11103,11121]",, +11124,你开始创业。,,,,,,,,,"(MNY>7)&(EVT?[11077,11075,11076,11071,11072,11073,11074])","EVT?[11124,11103,11121,11123]",, +11125,你开始考公务员。,,,,,,,,,"EVT?[11077,11075,11076,11071,11072,11073,11074]","EVT?[11125,11103,11121]",, +11126,你没有考上公务员。,你成为了打工人。,,,,,,,,EVT?[11025],(EVT?[11126])|(TLT?[1116]),, +11127,你考上了公务员。,,,,,,,,,EVT?[11025],EVT?[11127],, +11128,你开始相亲。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","(EVT?[11128,11171])|(TLT?[1027])",, +11129,你看上了对方,但对方看不上你。,,,,,,,,,EVT?[11128],"EVT?[11129,11131,11171]",, +11130,对方看上了你,但你看不上对方。,,,,,,,,,EVT?[11128],"EVT?[11129,11131,11171]",, +11131,你开始处对象。,,,,,,,,,EVT?[11128],"EVT?[11129,11131,11171]",, +11132,你找不到对象,至今单身。,,,,,,,,,"EVT?[11129,11130]","EVT?[11129,11131,11171]",, +11133,你996上班。,,,,-1,,,,,"EVT?[11123,11126]",EVT?[11133],, +11134,国家宣布禁止强制996。,老板让你们自愿996,不996的话工资很低。,,,,,-1,,,EVT?[11133],EVT?[11134],, +11135,你的私人生活越来越少,工作成为了你生活的大部分。,,,,,,,,,"EVT?[11123,11126]",EVT?[11135],, +11136,比起重复的每个工作日,你宁愿回到中学时光。,,,,,,,,,"EVT?[11123,11126]",EVT?[11136],, +11137,即使下班,也总是有人问你工作上的问题。,,,,,,,,,"EVT?[11123,11126]",EVT?[11137],, +11138,即使下班,晚上也经常有饭局,你的私人时间被进一步剥夺。,,,,,,,,,"EVT?[11123,11126]",EVT?[11138],, +11139,你突然有些厌烦,你更怀念一个人的时候。,,,,,,,,,"(EVT?[11123,11126])&(EVT?[11131])","EVT?[11139,11140]",, +11140,你们分了,又处了新对象。,,,,,,,,,EVT?[11131],,, +11141,你天天摸鱼的工友升职加薪了,你有点怀疑人生。,,,,,,,,,"EVT?[11123,11126]",EVT?[11141],, +11142,工位厕所里加了计时器和信号屏蔽器。,,,,,,,,,"EVT?[11123,11126]",EVT?[11142],, +11143,年会上,你抽奖抽到一台iphoneZ。,,,,,,,,,"EVT?[11123,11126]","EVT?[11143,11144,11145]",, +11144,年会上,你抽到一张玛莎拉蒂5元代金券。,,,,,,,,,"EVT?[11123,11126]","EVT?[11143,11144,11145]",, +11145,年会上,你抽到少量现金。,,,,,,,,,"EVT?[11123,11126]","EVT?[11143,11144,11145]",, +11146,团建,公司找来PUA专家展开动员大会。,,,,,,-1,,,"EVT?[11123,11126]",EVT?[11146],, +11147,普通的打工人生活。,,,,,,,,,"EVT?[11123,11126]",,, +11148,公司的一位领导因为涉嫌性侵被捕了。,,,,,,,,,"EVT?[11123,11126]","EVT?[11148,11149]",, +11149,公司的一位领导因为涉嫌经济犯罪被捕了。,,,,,,,,,"EVT?[11123,11126]","EVT?[11148,11149]",, +11150,规定出台要求强制双休。,你的工资又降低了。,,,,-1,,,,"EVT?[11123,11126]",EVT?[11150],, +11151,聊天时发现新来的员工工资普遍比你高。,,,,,,,,,"EVT?[11123,11126]",EVT?[11151],, +11152,paper日常。,,,,,,,,,EVT?[11122],,, +11153,给导师打杂日常。,,,,,,,,,EVT?[11122],,, +11154,你一天到晚泡在实验室里。,,,,,,,,,EVT?[11122],EVT?[11154],, +11155,你正式步入科研。,,,,,,,,,(INT>7)&(MNY>2)&(EVT?[11122]),EVT?[11155],, +11156,paper日常。,,,,,,,,,EVT?[11155],,, +11157,给导师打杂日常。,,,,,,,,,EVT?[11155],,, +11158,当助教。,,,,,,,,,EVT?[11155],EVT?[11158],, +11159,辅导导师家小孩功课。,,,,,,,,,EVT?[11155],EVT?[11159],, +11160,实验日常。,,,,,,,,,EVT?[11155],,, +11161,你的压力很大,你感觉自己可能不能如期毕业。,,,,,,,,,EVT?[11155],EVT?[11161],, +11162,你留校担任讲师。,,,,,,,,,(INT>8)&(EVT?[11155]),EVT?[11162],, +11163,你前往一所普通高校当老师。,,,,,,,,,EVT?[11155],EVT?[11163],, +11164,安逸的铁饭碗生活。,,,,,,,,,EVT?[11127],,, +11165,你下班回家经常做一些自己喜欢的事。,,,,,,1,,,EVT?[11127],EVT?[11165],, +11166,你有很多空闲时间,经常看短视频和玩游戏消遣。,,,,,,,,,EVT?[11127],"EVT?[11166,11167]",, +11167,你有很多空闲时间,经常看动画消遣。,,,,,,,,,"(EVT?[11127])&(EVT?[10007,10008])","EVT?[11166,11167]",, +11168,你经常和密友小聚。,,,,,,,,,EVT?[11127],EVT?[11168],, +11169,清闲的小日子。,,,,,,,,,EVT?[11127],EVT?[11169],, +11170,领导要给你介绍对象,你又不好拒绝,很尴尬。,,,,,,,,,EVT?[11127],"EVT?[11170,11171]",, +11171,你结婚了。,,,,,,,,,EVT?[10010],"(EVT?[11171,10612,11093,10229,10610,10611])|(TLT?[1027])",, +11172,你创业失败。,家人支持你继续创业。,,,,,,,,EVT?[11124],EVT?[11172],, +11173,你得到了亲友的很多人脉支持。,,,,,,,,,EVT?[11124],EVT?[11173],, +11174,你开了一家互联网公司。,,,,,,,,,EVT?[11124],"EVT?[11174,11175,11176,11177,11178]",, +11175,你开了一家金融公司。,,,,,,,,,EVT?[11124],"EVT?[11174,11175,11176,11177,11178]",, +11176,你开了一家二次元公司。,,,,,,,,,"(EVT?[11124])&(EVT?[10007,10008])","EVT?[11174,11175,11176,11177,11178]",, +11177,你开了一家实业公司。,,,,,,,,,EVT?[11124],"EVT?[11174,11175,11176,11177,11178]",, +11178,你开了一家新技术产业公司。,,,,,,,,,EVT?[11124],"EVT?[11174,11175,11176,11177,11178]",, +11179,你创业过程中结识了许多大佬。,,,,,,,,,EVT?[11124],EVT?[11179],, +11180,你了解了很多行业潜规则。,,,,,,,,,EVT?[11124],EVT?[11180],, +11181,你的公司福利待遇很好。,,,,,,,,,EVT?[11124],EVT?[11181],, +11182,你很努力和员工一起奋斗在一线,拿和普通员工一样的钱。,,,,,,,,,EVT?[11124],EVT?[11182],, +11183,人民企业家艰苦创业的日子。,,,,,,,,,EVT?[11124],,, +11184,虚拟现实技术得到突破,开始爆发式增长。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11184],, +11185,我国可控核聚变技术有所突破,离成功不远了。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11185,11263]",, +11186,人造肉在西方迅速流行。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11186],, +11187,电视机逐渐淡出历史舞台。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11187],, +11188,全球生育率再创新低。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11188],, +11189,你养了一条鱼。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11190,你养了一只鸟。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11191,你养了一只乌龟。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11192,你养了一只仓鼠。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11193,你养了一只猫。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11194,你养了一只狗。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11195,你养了一只守宫。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]","EVT?[11189,11190,11191,11192,11193,11194,11195]",, +11196,中国成功登月。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11196],, +11197,我国首次夺得奥运奖牌榜奖牌总数第一。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11197],, +11198,为减轻生育负担,国家出台多项政策。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11198],, +11199,我国宣布建成社会主义现代化强国。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11199],, +11200,我国人均GDP超过韩国。,,,,,,,,,"EVT?[11127,11123,11126,11122,11124]",EVT?[11200],, +11201,你的专辑《暗线》登顶。,,,,,,,,,EVT?[10966],EVT?[11201],, +11202,你没有时间上课,时间表安排得很满。,,,,,,,,,EVT?[10966],EVT?[11202],, +11203,你的团队开始帮助你艹粉。,,,,,,,,,EVT?[10966],"EVT?[11203,10002,10110,10111]",, +11204,你在一次拍戏过程中意外身故。,,,,,,,,,EVT?[10966],EVT?[11204],EVT?[10966]:10000, +11205,你在一次拍戏过程中划破了手指,上了微博热搜。,,,,,,,,,EVT?[10966],EVT?[11205],, +11206,有网民造你的谣,你发了律师函。,,,,,,,,,EVT?[10966],EVT?[11206],, +11207,努力的演艺生涯。,,,,,,,,,EVT?[10966],,, +11208,你经常在贴吧上吹水。,,,,,,,,,(MNY<7)&(EVT?[10010]),"EVT?[11208,10002,11211,11212]",, +11209,你经常玩soul和小红书。,,,,,,,,,EVT?[10010],"EVT?[11209,10001,11211]",, +11210,你经常用微博。,,,,,,,,,EVT?[10010],"EVT?[11210,11208,11211]",, +11211,你经常用知乎。,,,,,,,,,EVT?[10010],"EVT?[11211,11209,11210,11212]",, +11212,你经常用豆瓣。,,,,,,,,,EVT?[10010],"EVT?[11212,11211,11208]",, +11213,你的爷爷去世。,,,,,,,,,EVT?[10010],EVT?[11213],, +11214,你的奶奶去世。,,,,,,,,,EVT?[10010],EVT?[11214],, +11215,你的外公去世。,,,,,,,,,EVT?[10010],EVT?[11215],, +11216,你的外婆去世。,,,,,,,,,EVT?[10010],EVT?[11216],, +11217,父亲因车祸去世。,,,,,-2,-1,,,EVT?[10010],"(EVT?[11217,10868])|(TLT?[1043])",, +11218,母亲突发心脏病去世。,,,,,-1,-1,,,EVT?[10010],"(EVT?[11218,10869])|(TLT?[1044])",, +11219,你遭遇车祸去世。,,,,,,,,,EVT?[10010],(EVT?[11219])|(TLT?[1043]),EVT?[10010]:10000, +11220,你突发心脏病去世。,,,,,,,,,(STR<2)&(EVT?[10010]),(EVT?[11220])|(TLT?[1044]),EVT?[10010]:10000, +11221,你位列年度艺人排行第3。,,,,,,,,,EVT?[10966],EVT?[11221],, +11222,你名列年度福布斯十大中国名人。,,,,,,,,,EVT?[10966],EVT?[11222],, +11223,有讨厌的私生饭影响你的生活。,,,,,,,,,EVT?[10966],EVT?[11223],, +11224,很多名牌都来找你拍广告。,,,,,1,,,,EVT?[10966],EVT?[11224],, +11225,你养了一只价值数十万的猫。,,,,,,,,,EVT?[10966],EVT?[11225],, +11226,你买了几辆数百万、上千万的豪车。,,,,,,,,,EVT?[10966],EVT?[11226],, +11227,你买了一栋大别墅,一套汤臣一品。,,,,,,,,,EVT?[10966],EVT?[11227],, +11228,国家开始打击娱乐圈。,,,,,,,,,EVT?[10966],EVT?[11228],, +11229,有明星因犯罪入狱。,,,,,,,,,EVT?[10966],EVT?[11229],, +11230,你因涉嫌性侵被捕。,,,,,-5,,,,EVT?[11203],EVT?[11230],, +11231,你被判十年监禁,正式入狱。,,-2,,-2,,-5,,,EVT?[11230],EVT?[11231],, +11232,枯燥的监狱生活。,,,,,,,,,EVT?[11230],EVT?[11234],, +11233,你出狱了。,但过往的一切都飘散如烟。,,,,,,,,EVT?[11230],"EVT?[11233,11234]",, +11234,你减刑提前出狱。,但过往的一切都飘散如烟。,,,,,,,,(EVT?[11230])&(TLT?[1117]),EVT?[11234],, +11235,世界的变化很大,你无所适从。,,,-1,,,,,,"EVT?[11233,11234]",EVT?[11235],, +11236,你找了份普通工作勉强度日。,,,,-1,-1,,,,EVT?[11235],EVT?[11236],, +11237,你的事业遭受沉重打击,热度不复从前。,,,,,-1,,,,EVT?[11229],EVT?[11237],, +11238,你急流勇退,转居幕后,运营公司。,,,,,,,,,EVT?[11229],EVT?[11238],, +11239,你怀孕了,公司找借口把你辞退了。,,,,,-1,-1,,,"(EVT?[11123,11126])&(EVT?[11171])","(EVT?[11239,10001,10110,10111])|(TLT?[1041,1046])",, +11240,你们的孩子出生了。,,,,,,,,,"EVT?[11171,11093]","(EVT?[11240])|(TLT?[1041,1046])",, +11241,你们的二胎出生了。,,,,,,,,,EVT?[11240],"EVT?[11241,11242]",, +11242,你们的二胎出生了。,,,,,,,,,(EVT?[11240])&(TLT?[1113]),"EVT?[11241,11242]",, +11243,你们的三胎出生了。,,,,,,,,,"EVT?[11241,11242]","EVT?[11243,11244]",, +11244,你们的三胎出生了。,,,,,,,,,"(EVT?[11241,11242])&(TLT?[1113])","EVT?[11243,11244]",, +11245,照顾小孩非常麻烦。,,,,,,,,,EVT?[11240],EVT?[11245],, +11246,你的生活被孩子占据了大半。,,,,,,,,,EVT?[11240],EVT?[11246],, +11247,你为孩子计划未来。,,,,,,,,,EVT?[11240],EVT?[11247],, +11248,工作很忙,你很难有时间照顾孩子。,,,,,,,,,"(EVT?[11123,11126])&(EVT?[11240])","EVT?[11248,10002]",, +11249,公司占据了你的私人家庭时间,但你无能为力。,,,,,,,,,"(EVT?[11123,11126])&(EVT?[11240])",EVT?[11249],, +11250,你的科研产出被家庭事务束缚。,,,,,,,,,"(EVT?[11162,11163])&(EVT?[11240])",EVT?[11250],, +11251,你觉得和孩子打交道比实验和论文难多了。,,,,,,,,,"(EVT?[11162,11163])&(EVT?[11240])",EVT?[11251],, +11252,你将一套房产划到孩子名下。,,,,,,,,,(EVT?[11124])&(EVT?[11240]),EVT?[11252],, +11253,你像你父母一样给了孩子最丰厚的条件。,,,,,,,,,(EVT?[11124])&(EVT?[11240]),EVT?[11253],, +11254,你经常陪孩子玩。,,,,,,,,,(EVT?[11127])&(EVT?[11240]),EVT?[11254],, +11255,你给孩子买了很多玩具。,,,,,,,,,(EVT?[11127])&(EVT?[11240]),EVT?[11255],, +11256,你财务自由,退居幕后。,,,,,1,,,,EVT?[11124],EVT?[11256],, +11257,你的父亲去世。,,,,,,,,,EVT?[10010],"EVT?[11257,11217,10868]",, +11258,你的母亲去世。,,,,,,,,,EVT?[10010],"EVT?[11258,11218,10869]",, +11259,你当上了副教授。,,,,,,,,,"EVT?[11162,11163]",EVT?[11259],, +11260,你当上了正教授。,,,,,,,,,EVT?[11259],EVT?[11260],, +11261,同学笑你是怪物。,,,,,,-1,,,"(EVT?[10110,10111])&(EVT?[10009,10010])",EVT?[11261],, +11262,你常常因为性别而遭受暴力和冷暴力。,,,,,,-1,,,"(EVT?[10110,10111])&(EVT?[10009,10010])",,SPR<3:10062, +11263,可控核聚变技术实现。全球迅速向无限能源时代转变。,,,,,,,,,EVT?[10010],EVT?[11263],, +11264,航天技术取得巨大突破。,,,,,,,,,EVT?[10010],EVT?[11264],, +11265,你前往太空旅行。,,,,,,,,,"(STR>6)&(MNY>8)&(EVT?[11264,11263])",EVT?[11265],, +11266,你前往月球旅行。,,,,,,,,,EVT?[11266],EVT?[11266],, +11267,你前往火星旅行。,,,,,,,,,EVT?[11267],EVT?[11267],, +11268,你在太空旅行中意外身亡。,,,,,,,,,EVT?[11264],EVT?[11268],EVT?[10010]:10000, +11269,生产资料所有制正在深刻改变,许多国家向社会主义国家过渡。,,,,,,,,,EVT?[11263],EVT?[11269],, +11270,专家声称燃料是资本主义社会的基础,可控核聚变是共产主义社会的基础。,,,,,,,,,EVT?[11263],EVT?[11270],, +11271,各个产业都取得了巨大的突破,一年的进步顶过去10年。,,,,,,,,,EVT?[11263],EVT?[11271],, +11272,电力彻底免费。,所有燃油燃气都被电力取代。,,,,,,,,EVT?[11263],EVT?[11272],, +11273,你的公司制造出可植入大脑的芯片。可以显著提升人类记忆力。,,,,,,,,,(EVT?[11124])&(EVT?[11263]),EVT?[11273],, +11274,你研发出可植入大脑的芯片。可以直接将知识信息植入大脑。,你往自己大脑植入了,智力显著提升。,,2,,,,,,"(EVT?[11162,11163])&(EVT?[11263])",EVT?[11274],, +11275,社会内卷程度大幅降低,全球全面小康。,,,,,1,,,,EVT?[11263],EVT?[11275],, +11276,你和一个学生发生激烈争执。,,,,,,,,,"EVT?[11162,11163]",EVT?[11276],STR<4:21276, +21276,学生掏出小刀捅了你。,,,,,,,,1,,,STR<4:10000, +11277,因为你颜值过高,有个嫉妒的人突然从天而降把你杀了。,你死前不明白为什么那个人是从天上下来的。,,,,,,,,(CHR>9)&(EVT?[10010]),EVT?[11277],STR<100:10000, +11278,你被一个骗子骗得倾家荡产。,,,,,-5,-5,,,(INT<2)&(EVT?[10010]),"EVT?[11278,11318]",, +11279,你升官了。,,,,,,,,,EVT?[11127],EVT?[11279],, +11280,你经常在网上晒生活。,,,,,,,,,(MNY>4)&(EVT?[10010]),EVT?[11280],, +11281,Web3.0时代完全到来。,,,,,,,,,EVT?[10010],EVT?[11281],, +11282,6G信号覆盖全球大多数地区。,,,,,,,,,EVT?[10010],EVT?[11282],, +11283,手机消亡了,取而代之的是全息投影。,,,,,,,,,EVT?[10010],EVT?[11283],, +11284,据说传送装置正在研制中。,,,,,,,,,EVT?[11271],EVT?[11284],, +11285,人造食物火遍全球。,营养和味道都比天然食物更好。,,,,,,,,EVT?[10010],EVT?[11285],, +11286,你的生活日新月异,感觉时代飞速前进着。,,,,,,,,,"EVT?[11263,11281,11282,11283,11285]",,, +11287,虚拟现实技术取得巨大突破。,,,,,,,,,"EVT?[11272,11184]",EVT?[11287],, +11288,第一个可真实进入的虚拟世界出现了。,全人类疯狂了。,,,,,,,,EVT?[11287],EVT?[11288],, +11289,你终日沉迷在虚拟世界之中。,虚拟世界中的时间过得比现实慢。,,,,,,,,(MNY<9)&(EVT?[11288]),EVT?[11289],, +11290,你依靠生命维持装置活着。所有时间都在虚拟中度过。,不过世界上大多数普通人都和你一样。,-1,-1,-1,,1,,,EVT?[11289],EVT?[11290],, +11291,外界一年,虚拟世界中十年。,现实中的你越来越虚弱,虚拟中的你越来越快乐。,,-1,-1,,1,,,EVT?[11290],,(STR<0)&(INT<0):10000, +11292,你开始投资搞虚拟现实。,,,,,,,,,(MNY>8)&(EVT?[11288]),EVT?[11292],, +11293,“虚拟瘾”者们失去了现实竞争力,各项能力逐渐退化。,但这对于你这样的精英来说并不是坏事。,,,,,,,,EVT?[11292],EVT?[11293],, +11294,你离婚了。,,,,,,,,,EVT?[11171],"(EVT?[11295,11294,11362,11363,11357,10270,10271,11294,20076])|(TLT?[1123])",, +11295,你的爱人去世了。,,,,,,,,,EVT?[11171],"EVT?[11295,11294]",, +11296,高超的洞察力使你发现:现实世界是虚拟的。,,,,,,,,,(INT>10)&(EVT?[11288]),EVT?[11296],INT>10:21296, +21296,突然,时间停止了。,,,,,,,,1,,,INT>10:21297, +21297,你向下方跑,想要逃离这个世界。,,,,,,,,1,,,INT>10:21298, +21298,跑,,,,,,,,1,,,INT>10:21299, +21299, 跑,,,,,,,,1,,,INT>10:21300, +21300, 跑,,,,,,,,1,,,INT>10:21301, +21301, 跑,,,,,,,,1,,,INT>10:21302, +21302, 跑,,,,,,,,1,,,INT>10:21303, +21303, 跑,,,,,,,,1,,,INT>10:21304, +21304, 跑 ,,,,,,,,1,,,, +21305,你的行为终于触发了这个满是BUG的虚拟世界的防卫机制。,,,,,,,,,EVT?[21304],EVT?[21305],INT>10:21306, +21306,世界开始对你做出审判。,,,,,,,,1,,,CHR>5:21307,CHR<6:21308 +21307,你相貌还可以,世界决定抹去你这段记忆让你继续生活。,,,,,,,,1,,,, +21308,你相貌不行,世界决定消灭你。,,,,,,,,1,,,CHR<6:10000, +11297,我国进入共产主义社会。,,,,,,,,,EVT?[11263],"EVT?[11297,11287]",, +11298,第三次世界大战爆发。,,,,,,,,,EVT?[10010],EVT?[11298],, +11299,超级核战争,世界毁灭了。,,,,,,,,,(EVT?[11263])&(EVT?[11298]),EVT?[11299],EVT?[10010]:10000, +11300,探索飞船发现了有低等生命的地外行星。,,,,,,,,,EVT?[11264],EVT?[11300],, +11301,人类派遣船队去地外行星进行改造工作,便于未来殖民。,,,,,,,,,EVT?[11300],EVT?[11301],, +11302,科学家声称外星上可能有未知的致命细菌或病毒,去了就不可贸然返回。,,,,,,,,,EVT?[11300],EVT?[11302],, +11303,人类又发现另外三个有生命的地外行星。,,,,,,,,,EVT?[11300],EVT?[11303],, +11304,有外星人乘飞船来到地球想要占领地球,却不知被谁瞬间消灭。,有传闻称地球上早就有更强大的外星人在了。,,,,,,,,EVT?[11300],EVT?[11304],, +11305,癌症被攻克了。,,,,,,,,,EVT?[10010],EVT?[11305],, +11306,你因为癌症去世。,,,,,,,,,EVT?[10010],"EVT?[11306,11305]",EVT?[10010]:10000, +11307,你重重摔了一跤。,,,,-1,,,,,EVT?[10010],,STR<5:10000, +11308,你的身体状况越来越差。,,,,-1,,,,,EVT?[10010],,, +11309,你得了不治之症去世。,,,,,,,,,(STR<3)&(EVT?[10010]),EVT?[11309],EVT?[10010]:10000, +11310,你在睡梦中安然离世。,,,,,,,,,EVT?[10010],(EVT?[11310])|(TLT?[1048]),EVT?[10010]:10000, +11311,你的孩子去世。,,,,,,-1,,,EVT?[11240],EVT?[11311],, +11312,你被人谋杀了。,,,,,,,,,EVT?[11124],EVT?[11312],EVT?[10010]:10000, +11313,你因抑郁症去世。,,,,,,,,,(SPR<2)&(EVT?[10010]),EVT?[11313],EVT?[10010]:10000, +11314,你意外落水身亡。,,,,,,,,,EVT?[10010],"(EVT?[11314,11318])|(TLT?[1016])",EVT?[10010]:10000, +11315,世界大战结束了。,,,,,,,,,EVT?[11298],EVT?[11315],, +11316,充满各种几乎没有成本的娱乐的老年生活。,,,,,,,,,"EVT?[11263,11281,11282,11283,11285]",,, +11317,和儿时相比,世界早已改天换地。,,,,,,,,,EVT?[10010],EVT?[11317],, +11318,你因为受贿被逮捕。,,,,,,,,,EVT?[11127],EVT?[11318],, +11319,因数额巨大,你被判处终身监禁。,,,,,-5,-5,,,EVT?[11318],EVT?[11319],, +11320,监狱生活。,,,,,,,,,EVT?[11319],"EVT?[11321,11322]",, +11321,你获得了减刑,提前出狱。,,,,,,,,,EVT?[11320],"EVT?[11321,11322]",, +11322,你获得了减刑,提前出狱。,,,,,,,,,(EVT?[11320])&(TLT?[1117]),"EVT?[11321,11322]",, +11323,你在狱中被人打死。,,,,,,,,,(STR<6)&(EVT?[11320]),"EVT?[11321,11322]",EVT?[10010]:10000, +11324,你因病去世。,,,,,,,,,EVT?[11320],"EVT?[11321,11322]",EVT?[10010]:10000, +11325,有一个按钮,按下去后你能得到大量金钱,但人类在1000年内会灭亡。,你没按。,,,,,,,,EVT?[10010],EVT?[11325],(MNY<8)&(SPR<8):21315, +21315,你按了。你获得了大量金钱。,,,,,3,,,1,,,, +11326,科学家发现,有一颗直径20千米的小行星可能在990年后接近地球。,科学家认为它击中地球的几率非常低,不用担心。,,,,,,,,EVT?[21315],EVT?[11326],, +11327,科学家认为一颗距离我们32光年的红超巨星将在100万年内爆发。,,,,,,,,,EVT?[21315],EVT?[11327],, +11328,出现了可以在虚拟世界中创造虚拟世界的虚拟游戏。,,,,,,,,,EVT?[11287],EVT?[11328],, +11329,你一天有半数时间泡在虚拟世界中。,,,,,,,,,EVT?[11287],EVT?[11293],, +11330,交通彻底免费了。,,,,,,,,,EVT?[11263],EVT?[11330],, +11331,你去世界各地旅游。,,,,,,,,,EVT?[11330],"EVT?[11332,11333,11334]",, +11332,你定居空间站。,,,,,,,,,EVT?[11265],"EVT?[11332,11333,11334]",, +11333,你定居月球。,,,,,,,,,EVT?[11266],"EVT?[11332,11333,11334]",, +11334,你定居火星。,,,,,,,,,EVT?[11267],"EVT?[11332,11333,11334]",, +11335,▓#▓……*▓▓▓⊙▓&▓▓▓▓¥(▓▓▓*-+▓▓,,,-1,1,,,,,TLT?[1128],,, +11336,▓▓▓▓▓▓▓&……▓↖▓▓▓▓▓&*¥▓∞▓▓▓▓,,,-1,,1,,,,TLT?[1128],,, +11337,▓▓▓▓*▓*▓▓&▓^▓^▓▓▓▓⊙▓▓▓▓▓&,,,-1,,,1,,,TLT?[1128],,, +11338,¥%▓▓▓∞▓▓▓▓▓▓▓((**,,1,-1,,,,,,TLT?[1128],,, +11339,▓¥@∞▓▓▓▓╱╲▓↖▓▓▓▓▓▓@@▓▓▓▓,,2,-1,,,,,,TLT?[1128],,, +11340,▓▓▓▓▓▓▓▓▓▓▓▓……&*%+-*,,,-1,2,,,,,TLT?[1128],,, +11341,▓》《▓▓▓▓▓▓▓▓▓》》▓,,,-1,,2,,,,TLT?[1128],,, +11342,▓▓▓“{}|▓▓▓▓▓▓—▓▓▓▓&,,,-1,,,2,,,TLT?[1128],,, +11343,:▓▓▓:∞▓▓▓▓▓▓……╱╲▓▓▓▓》,,,-1,3,,,,,TLT?[1128],,, +11344,▓▓▓▓▓▓▓▓▓!~▓!▓+▓=▓‘,,3,-1,,,,,,TLT?[1128],,, +11345,;’▓╱╲,▓Й*-▓▓▓,,,-1,,3,,,,TLT?[1128],,, +11346,;【▓】▁▂▃▓▓▓▓▓▓▓▓、、▓▓▓▓▓?,,,-1,,,3,,,TLT?[1128],,, +11347,▁▂▃▄▅▆▇█▇▆▅▄▃▂▁,,,-1,,,,,,TLT?[1128],,TLT?[1128]:10000, +11348,★☆↑◎¤★☆◎↑¤★☆◎¤◎↑¤★☆↑,,,-1,,,,,,TLT?[1128],,TLT?[1128]:10000, +11349,你没有这段记忆。,,,,,,,,,TLT?[1129],,, +11350,婚后你的丈夫没有之前对你那么好了。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11350,11357,11358,11359,11360,11361,11362,11363,11295]",, +11351,家务几乎全是你在干。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11351,11357,11358,11359,11360,11361,11362,11363,11295]",, +11352,丈夫和你见面的时间越来越少。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11352,11357,11358,11359,11360,11361,11362,11363,11295]",, +11353,结婚周年纪念日,丈夫给了你一个红包,没有准备礼物。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11353,11357,11358,11359,11360,11361,11362,11363,11295]",, +11354,你和婆婆吵架,丈夫站在婆婆那边。,,,,,,-1,,,EVT?[11171],"EVT?[10001,11294,11354,11357,11358,11359,11360,11361,11295,11362,11363]",, +11355,你怀疑丈夫有外遇。,,,,,,-1,,,EVT?[11171],"EVT?[10001,11294,11355,11357,11358,11359,11360,11361,11295,11362,11363]",, +11356,你经常在一个群里和大家一起吐槽婚后生活。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11356,11357,11358,11359,11360,11295,11361,11362,11363]",, +11357,你的丈夫对你始终如一。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11357,11350,11351,11352,11353,11295,11354,11355,11356]",, +11358,结婚周年纪念日,你们一家出去旅游。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11358,11350,11351,11352,11353,11295,11354,11355,11356]",, +11359,丈夫的父母通情达理,和你关系如同朋友。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11359,11350,11351,11352,11353,11295,11354,11355,11356]",, +11360,闺蜜向你吐槽她的丈夫多么不好。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11360,11350,11351,11352,11353,11295,11354,11355,11356]",, +11361,丈夫做了大多数家务,做菜还特别好吃。,,,,,,1,,,EVT?[11171],"EVT?[10001,11294,11361,11350,11351,11352,11353,11295,11354,11355,11356]",, +11362,丈夫特别尊重你的意见,大多数家事都请你做决定。,,,,,,,,,EVT?[11171],"EVT?[10001,11294,11362,11350,11351,11352,11353,11295,11354,11355,11356]",, +11363,每天睡前你们都会聊很长时间的天。,,,,,,1,,,EVT?[11171],"EVT?[10001,11294,11363,11350,11351,11352,11353,11295,11354,11355,11356]",, +11364,很少有时间陪伴家人,你有些愧疚。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11364]",, +11365,你的妻子把行动不便的父母接到你们家里住。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11365]",, +11366,你每月都上缴工资给妻子。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11366,11367]",, +11367,你们家的生活费采用AA。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11366,11367]",, +11368,自从结婚后,你上网和娱乐时间越来越少了。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11368]",, +11369,你无微不至地照顾照顾妻子。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11295,11369]",, +11370,你和妻子之间更像是朋友。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11370,11295]",, +11371,妻子的一个亲戚沉迷赌博,骗了她娘家不少钱。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11371,11295]",, +11372,妻子的父亲去世,继承了一些遗产。,,,,,1,,,,EVT?[11365],"EVT?[10002,11294,11372,11295]",, +11373,婚前的彩礼全部用于运营你们的小家。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11373,11295]",, +11374,你考了驾照。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11374,11295]",, +11375,妻子经常和你一起看动画。,,,,,,,,,"(EVT?[11171])&(EVT?[10007,10008])","EVT?[10002,11294,11375,11295]",, +11376,你经常和妻子一起看综艺和电视剧。,,,,,,,,,EVT?[11171],"EVT?[10002,11294,11376,11295]",, +11377,孩子的健康状况不太好,你们家操碎了心。,,,,,,,,,EVT?[11240],"EVT?[11294,11295,11377]",, +11378,可能是遗传你,孩子不大聪明的样子。,,,,,,,,,(INT<4)&(EVT?[11240]),EVT?[11378],, +11379,可能是遗传你,孩子非常聪明。,,,,,,,,,(INT>6)&(EVT?[11240]),EVT?[11379],, +11380,可能是遗传你,孩子不大好看。,,,,,,,,,(CHR<4)&(EVT?[11240]),EVT?[11380],, +11381,可能是遗传你,孩子非常好看。,,,,,,,,,(CHR>6)&(EVT?[11240]),EVT?[11381],, +11382,孩子不小心烫伤了。,,,,,,,,,EVT?[11240],EVT?[11382],, +11383,孩子得了重病,家里花了很多钱。,,,,,-1,,,,EVT?[11240],EVT?[11383],, +11384,你第一次揍孩子。,,,,,,,,,EVT?[11240],EVT?[11384],, +11385,你们带着孩子一起旅游。,,,,,,1,,,EVT?[11240],"EVT?[11294,11295,11385]",, +11386,为孩子准备升学考试,家里更忙了。,,,,,,,,,EVT?[11240],EVT?[11386],, +11387,孩子在学校闯祸了,你去挨老师批评。,,,,,,,,,EVT?[11240],EVT?[11387],, +11388,孩子成绩退步了,你决定切断孩子的一切娱乐活动。,,,,,,,,,EVT?[11240],EVT?[11388],, +11389,学校不允许排成绩,但你还是设法弄到了排名。,,,,,,,,,EVT?[11240],EVT?[11389],, +11390,孩子的英语出奇的好。,,,,,,,,,EVT?[11240],EVT?[11390],, +11391,孩子喜欢上了看动漫。,,,,,,,,,EVT?[11240],EVT?[11391],, +11392,孩子在学校早恋,你十分生气。,,,,,,-1,,,EVT?[11240],EVT?[11392],, +11393,孩子的成绩进步了。,,,,,,,,,EVT?[11240],EVT?[11393],, +11394,政府宣布禁止开办补习班。,,,,,,,,,EVT?[11240],EVT?[11394],, +11395,政府发文件要求学校放学不得晚于下午5点。,,,,,,,,,EVT?[11240],EVT?[11395],, +11396,教育体系对体育越发重视,你们经常要抽时间带孩子去运动。,,,,,,,,,EVT?[11240],"EVT?[11294,11295,11396]",, +11397,参加家长会,你的颜值震惊全场,直接有家长要你的联系方式。,,,,,,,,,(CHR>8)&(EVT?[11240]),EVT?[11397],, +11398,你的智慧指导孩子功课绰绰有余。,,,,,,,,,(INT>6)&(EVT?[11240]),EVT?[11398],, +11399,你发现孩子学的东西连你都不会。,,,,,,,,,(INT<4)&(EVT?[11240]),EVT?[11399],, +11400,你的家庭越来越困难,温饱都成问题。,,,,,,,,,(MNY<3)&(EVT?[10010]),"EVT?[11400,11401]",, +11401,你买彩票中了奖。家境回暖。,,,,,1,,,,(MNY<3)&(EVT?[10010]),EVT?[11401],, +11402,因为很有钱,总是有人和你家攀亲戚。,,,,,,,,,(MNY>7)&(EVT?[10010]),EVT?[11402],, +11403,总是有人找你借钱。,,,,,,,,,(MNY>5)&(EVT?[10010]),EVT?[11403],, +11404,你感觉自己的知识有些跟不上时代。,,,,,,,,,(INT<4)&(EVT?[10010]),EVT?[11404],, +11405,你总是能跟上时代的潮流。,,,,,,,,,(INT>6)&(EVT?[10010]),EVT?[11405],, +11406,你的健康状况非常不好。,,,,,,,,,(STR<3)&(EVT?[10010]),EVT?[11406],, +11407,你的精神状况非常不好。,,,,,,,,,(SPR<3)&(EVT?[10010]),EVT?[11407],, +11408,你依然和年轻时一样强壮。,,,,,,,,,(STR>7)&(EVT?[10010]),EVT?[11408],, +11409,有健美杂志找你做模特。,,,,,,,,,(STR>8)&(EVT?[10010]),EVT?[11409],, +11410,你家买了最新款的飞车。,,,,,,,,,(MNY>7)&(EVT?[10010]),EVT?[11410],, +11411,你家里家具设施弄了全套物联网。,,,,,,,,,(MNY>5)&(EVT?[10010]),EVT?[11411],, +11412,总有人问你是不是整过容。,,,,,,,,,(CHR>7)&(EVT?[10010]),EVT?[11412],, +11413,因为相貌不佳,生活中平添了不少麻烦。,,,,,,,,,(CHR<4)&(EVT?[10010]),EVT?[11413],, +11414,生物学家突破性完成了猫狗杂交实验。,,,,,,,,,EVT?[10010],EVT?[11414],, +11415,反环保团体在西方国家游行。,,,,,,,,,EVT?[10010],EVT?[11415],, +11416,美国掀起第四次女性主义浪潮。,,,,,,,,,EVT?[10010],"EVT?[11416,11263,11288]",, +11417,一位哲学家开辟了虚拟主义哲学,从世界是虚拟游戏为起点建构了整个体系。,,,,,,,,,EVT?[10010],"EVT?[11417,11263,11288]",, +11418,国家统一全国户口。,,,,,,,,,EVT?[10010],EVT?[11418],, +11419,国家进一步推出限制未成年人消费的法案。,,,,,,,,,EVT?[10010],EVT?[11419],, +11420,生物学家宣称,因为人类过于依赖人造工具,人类天生的工具眼耳手脚等已经停止进化了。,,,,,,,,,EVT?[10010],EVT?[11420],, +11421,为保护言论自由,国家发文禁止媒体设置“评论精选”功能。,,,,,,,,,EVT?[10010],EVT?[11421],, +11422,学者研究发现,人的意识可能是模因复制过程中的副产物。,,,,,,,,,EVT?[10010],EVT?[11422],, +11423,美国为保护人权,禁止出版以“他人的出丑或不幸”作为笑点的作品。,谐音梗开始统治影视界。,,,,,,,,EVT?[10010],EVT?[11423],, +11424,调查显示,84%的人认为自己的颜值是“中上”。,,,,,,,,,EVT?[10010],"EVT?[11424,11425,11426,11263,11288]",, +11425,调查显示,50%的人认为自己比大多数人多点儿小聪明,另外30%的人认为自己的智商显著优于身边的人。,,,,,,,,,EVT?[10010],"EVT?[11424,11425,11426,11263,11288]",, +11426,调查显示,75%的人认为自己的人品好过绝大多数人。,专家表示可能与报道犯罪的新闻过多有关。,,,,,,,,EVT?[10010],"EVT?[11424,11425,11426,11263,11288]",, +11427,你前两年开始使用的一个小众线上社交平台,现在突然火了。,但你感觉平台内的环境一下子乌烟瘴气起来,你很怀念两年前的样子。,,,,,,,,EVT?[10010],"EVT?[11427,11263,11288]",, +11428,一位社会学家发表《人类永生时代的社会学》,引起轰动。,,,,,,,,,EVT?[10010],EVT?[11428],, +11429,有研究表明,历史上所有的生命都可以算成一个个体的一部分。,,,,,,,,,EVT?[10010],EVT?[11429],, +11430,诺贝尔奖停办了。,,,,,,,,,EVT?[10010],EVT?[11430],, +11431,欧盟合并成了一个国家。,,,,,,,,,EVT?[10010],EVT?[11431],, +11432,印度成为了联合国第六常。,,,,,,,,,EVT?[10010],"EVT?[11432,11433]",, +11433,联合国解散了。,,,,,,,,,EVT?[10010],EVT?[11433],, +11434,朝鲜统一韩国。,,,,,,,,,EVT?[10010],EVT?[11434],, +11435,教师行业越来越受到重视,教师工资显著提高。,,,,,,,,,EVT?[10010],EVT?[11435],, +11436,国家宣布演员歌手收入需按工资发放,且不得超过当地公务员平均工资的三倍。,,,,,,,,,EVT?[10010],EVT?[11436],, +11437,动物保护组织游行,宣传放猫狗宠物自由。,,,,,,,,,EVT?[10010],EVT?[11437],, +11438,肉食主义者游行抗议没有纯肉餐厅。,,,,,,,,,EVT?[10010],"EVT?[11438,11263,11288]",, +11439,世界第一个八星级酒店在空间站建成。,在上面能看到八大行星。,,,,,,,,EVT?[10010],"EVT?[11439,11263,11288]",, +11440,广州出现十几平方公里大的巨型蟑螂。,,,,,,,,,EVT?[10010],EVT?[11440],, +11441,某游戏公司向教会出资,将圣经中的“诺亚”冠名成“明日”。,,,,,,,,,EVT?[10010],EVT?[11441],, +11442,有学者预言:22世纪是生物的世纪。,,,,,,,,,EVT?[10010],EVT?[11442],, +11443,由于“缩写效应”,汉语已经简化为纯字母语言。,,,,,,,,,EVT?[10010],EVT?[11443],, +11444,美国将小学入学年龄推迟到10-12岁。,,,,,,,,,EVT?[10010],EVT?[11444],, +11445,本地一醉酒男子路边被人侵犯,媒体称原因是其衣着暴露。,,,,,,,,,EVT?[10010],"EVT?[11445,11263,11288]",, +11446,无声音乐开始流行。,第一个无声音乐会在维也纳金色大厅举行。,,,,,,,,EVT?[10010],EVT?[11446],, +11447,生育率仍在下降,国家取消了父母生育前需要考试的规定。,,,,,,,,,EVT?[10010],EVT?[11447],, +11448,物理学家发现地球可能真的是宇宙的中心。,,,,,,,,,EVT?[10010],EVT?[11448],, +11449,前领导人打破最长寿的人吉尼斯纪录。,,,,,,,,,EVT?[10010],EVT?[11449],, +11450,一颗小行星即将击中地球时突然折返离开。,专家称可能有人许了什么离谱的愿望。,,,,,,,,EVT?[10010],EVT?[11450],, +11451,你使用魔法棒,变身成了魔法少女。,你变强了,但从此你要履行身为魔法少女的使命……,,,80,,,,,"(TLT?[1131])&(EVT?[10002])&(EVT?[10007,10008])",,, +11452,你和人类看不见的怪物战斗。,,,,,,,,,EVT?[11451],EVT?[21457],, +11453,你守护着这个星球。,,,,,,,,,EVT?[11451],EVT?[21457],, +11454,你不再是少女,魔法棒离开了你寻找下一个主人。,你的魔法少女生涯结束了,魔力也都消散了,你变回了普通人。,,,,,,,,EVT?[11451],"EVT?[21457,11454]",, +11455,你和侵入地球的银河帝王战斗。它十分强大。,但你还是赢了。,,,,,,,,EVT?[11456],"EVT?[11455,21457]",STR<88:10000, +11456,一个外星人来地球宣称要统治地球,被你秒杀。,,,,,,,,,EVT?[11451],"EVT?[11456,21457]",, +11457,你遭到了触手女王的攻击。,你消灭了触手女王。,,,,,,,,EVT?[11451],"EVT?[11457,21457]",INT<5:21457, +21457,你意志力不足,被诱导恶堕了。,你变成了触手魔女,从此为女王效力。,,,,,,,1,,,, +11458,你在地球上肆意破坏。,,,,,,,,,EVT?[21457],,, +11459,你引诱其他魔法少女恶堕。,,,,,,,,,EVT?[21457],,, +11460,你摧毁了美国。,,,,,,,,,EVT?[21457],EVT?[11460],, +11461,你摧毁了英国。,,,,,,,,,EVT?[21457],EVT?[11461],, +11462,法国臣服在你裙下。,,,,,,,,,EVT?[21457],EVT?[11462],, +11463,你消灭了日本所有的男性。,,,,,,,,,EVT?[21457],EVT?[11463],, +11464,你摧毁了俄罗斯。,,,,,,,,,EVT?[21457],EVT?[11464],, +11465,你遭遇了一个强大的魔法少女。,"你拼尽全力杀死了对方,并吸取了她的魔力。",,,88,,,,,EVT?[21457],EVT?[11465],STR<88:10000, +11466,一个会飞的人对你出手,他称自己是筑基期修士。,苦战后你杀死了对方。,,,,,,,,EVT?[21457],EVT?[11466],STR<100:10000, +11467,一个会飞的人对你出手,他称自己是渡劫期修士。,你还没看清对方怎么出手就失去了意识。,,,,,,,,EVT?[21457],EVT?[11467],STR<2000:10000, diff --git a/games/lifeRestart/data/events.json b/games/lifeRestart/data/events.json new file mode 100644 index 0000000..fc1a601 --- /dev/null +++ b/games/lifeRestart/data/events.json @@ -0,0 +1,11552 @@ +{ + "10000": { + "id": 10000, + "event": "你死了。", + "effect": { + "LIF": -1 + }, + "NoRandom": 1 + }, + "10001": { + "id": 10001, + "event": "你出生了,是个男孩。", + "exclude": "TLT?[1004,1024,1025,1113]" + }, + "10002": { + "id": 10002, + "event": "你出生了,是个女孩。", + "exclude": "TLT?[1003,1024,1025]" + }, + "10003": { + "id": 10003, + "event": "你生了场重病。", + "postEvent": "家里花了不少钱。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "exclude": "STR>6", + "branch": [ + "TLT?[1001]:10004", + "STR<2&MNY<3:10000" + ] + }, + "10004": { + "id": 10004, + "event": "可能是玉佩保佑,你活了下来。", + "NoRandom": 1 + }, + "10005": { + "id": 10005, + "event": "刚学会走路,你意外从桌子上跌落。", + "postEvent": "受了轻伤。", + "exclude": "INT>7", + "branch": [ + "TLT?[1002]:10006", + "STR<3&MNY<3:10000" + ] + }, + "10006": { + "id": 10006, + "event": "红肚兜挂在了桌角上,你没有受伤。", + "NoRandom": 1 + }, + "10007": { + "id": 10007, + "event": "你开始看动漫。", + "effect": { + "SPR": 1 + }, + "include": "TLT?[1005]", + "exclude": "(MNY<3)|(EVT?[10007,10008])", + "branch": [ + "INT>5:20008", + "CHR>5:20007" + ] + }, + "10008": { + "id": 10008, + "event": "你开始看动漫。", + "effect": { + "SPR": 1 + }, + "exclude": "(MNY<3)|(EVT?[10007,10008])", + "branch": [ + "INT>5:20008", + "CHR>5:20007" + ] + }, + "10009": { + "id": 10009, + "event": "你从小生活在农村", + "include": "(MNY<8)|(TLT?[1012])", + "exclude": "TLT?[1010,1013,1014]" + }, + "10010": { + "id": 10010, + "event": "你从小生活在城市", + "include": "(MNY>1)|(TLT?[1010,1013])", + "exclude": "TLT?[1012,1014]" + }, + "10011": { + "id": 10011, + "event": "你出生在美利坚,拥有美国国籍", + "include": "(MNY>8)|(TLT?[1014])", + "exclude": "TLT?[1010,1012]" + }, + "10012": { + "id": 10012, + "event": "你父母又生了个女儿。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10001,10014,10016,10017])|(TLT?[1011])", + "branch": [ + "MNY<2:10013" + ] + }, + "10013": { + "id": 10013, + "event": "你的家庭更加困难,吃不饱饭。", + "NoRandom": 1, + "branch": [ + "MNY<1:10000" + ] + }, + "10014": { + "id": 10014, + "event": "你父母又生了个儿子。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10001,10014,10016,10017])|(TLT?[1011])", + "branch": [ + "MNY<2:10013" + ] + }, + "10015": { + "id": 10015, + "event": "你父母并没有精心照顾你。", + "effect": { + "STR": -1, + "SPR": -1 + }, + "exclude": "(EVT?[10015,10011,10019])|(TLT?[1015])" + }, + "10016": { + "id": 10016, + "event": "你的母亲因病去世。", + "postEvent": "家庭更加困难了。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "include": "(EVT?[10009])&(STR<3)&(SPR<3)&(MNY<3)", + "exclude": "(EVT?[10016])|(TLT?[1029])", + "branch": [ + "EVT?[10017]:10000" + ] + }, + "10017": { + "id": 10017, + "event": "你的父亲因病去世。", + "postEvent": "家庭更加困难了。", + "effect": { + "MNY": -2, + "SPR": -1 + }, + "include": "(EVT?[10009])&(STR<3)&(SPR<3)&(MNY<3)", + "exclude": "(EVT?[10017])|(TLT?[1029])", + "branch": [ + "EVT?[10016]:10000" + ] + }, + "10018": { + "id": 10018, + "event": "你的父亲在种地时意外发现一箱金条。", + "postEvent": "家境有所好转。", + "effect": { + "MNY": 2, + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10018,10017]" + }, + "10019": { + "id": 10019, + "event": "你的父母对你视若珍宝,呵护备至。", + "effect": { + "STR": 1, + "SPR": 1 + }, + "exclude": "EVT?[10015,10016,10017,10019]" + }, + "10020": { + "id": 10020, + "event": "你天资聪颖,但家人并不懂如何培养。", + "effect": { + "INT": -1 + }, + "include": "(EVT?[10009])&(INT>7)", + "exclude": "EVT?[10021,10020]" + }, + "10021": { + "id": 10021, + "event": "你天资聪颖,家人很关注你的学习。", + "effect": { + "INT": 1 + }, + "include": "(EVT?[10009])&(INT>7)&(MNY>3)", + "exclude": "EVT?[10020,10021]" + }, + "10022": { + "id": 10022, + "event": "你什么事都要让着妹妹。", + "postEvent": "不开心。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10012]", + "exclude": "(EVT?[10022,10014])|(TLT?[1015])" + }, + "10023": { + "id": 10023, + "event": "你什么事都要让着弟弟。", + "postEvent": "不开心。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10014]", + "exclude": "(EVT?[10023])|(TLT?[1015])" + }, + "10024": { + "id": 10024, + "event": "家人到城里务工。", + "postEvent": "你在农村留守。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10016,10017,10024]", + "branch": [ + "TLT?[1015]:10025" + ] + }, + "10025": { + "id": 10025, + "event": "你和父母一同进了城。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10026": { + "id": 10026, + "event": "你比其他小朋友长得更可爱。", + "include": "CHR>7", + "exclude": "EVT?[10026,10030]" + }, + "10027": { + "id": 10027, + "event": "你的母亲救了个人,得到了很多感谢金。", + "postEvent": "家境有所好转。", + "effect": { + "MNY": 2, + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10027,10016]" + }, + "10028": { + "id": 10028, + "event": "你很调皮,喜欢在家到处乱跑。", + "effect": { + "STR": 1, + "SPR": 1 + }, + "include": "(STR>3)&(EVT?[10009])", + "exclude": "EVT?[10028,10052]", + "branch": [ + "CHR>7:20029", + "STR<5:20028" + ] + }, + "10029": { + "id": 10029, + "event": "家人从小就培养你做家务。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10029])|(TLT?[1015])" + }, + "10030": { + "id": 10030, + "event": "你的脸意外被开水烫伤。", + "postEvent": "毁容了。", + "effect": { + "CHR": -3, + "SPR": -2 + }, + "include": "(CHR>3)&(EVT?[10015])", + "exclude": "EVT?[10030]", + "branch": [ + "SPR<2:10062" + ] + }, + "10031": { + "id": 10031, + "event": "你被邻居叔叔绑架了。", + "postEvent": "没勒索到钱,你被放了。", + "effect": { + "SPR": -1 + }, + "include": "(CHR>4)&(MNY>4)&(EVT?[10009])", + "exclude": "EVT?[10031]", + "branch": [ + "EVT?[10018,10027,10078]:10032", + "(CHR>7)&(EVT?[10002,10111]):10033" + ] + }, + "10032": { + "id": 10032, + "event": "叔叔向你父母勒索了很多现金。", + "postEvent": "你被放了回家。", + "effect": { + "MNY": -2 + }, + "NoRandom": 1 + }, + "10033": { + "id": 10033, + "event": "叔叔侵犯了你。", + "postEvent": "你被放了回家。", + "effect": { + "SPR": -2 + }, + "NoRandom": 1, + "branch": [ + "STR<3:10000" + ] + }, + "10034": { + "id": 10034, + "event": "你和邻家小孩被定了娃娃亲。", + "include": "(CHR>3)&(EVT?[10009])", + "exclude": "EVT?[10034,10024]" + }, + "10035": { + "id": 10035, + "event": "你的大姐出嫁,收了很多彩礼。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10035])|(TLT?[1011])", + "branch": [ + "CHR>7:20035" + ] + }, + "10036": { + "id": 10036, + "event": "你喜欢用父母的手机玩王者荣耀。", + "effect": { + "SPR": 1 + }, + "include": "MNY>2", + "exclude": "EVT?[10011,10024,10016,10017,10036,10037,10038]", + "branch": [ + "INT>8:20037", + "INT>5:20038" + ] + }, + "10037": { + "id": 10037, + "event": "你喜欢用父母的手机刷抖音。", + "effect": { + "SPR": 1 + }, + "include": "MNY>2", + "exclude": "EVT?[10011,10024,10016,10017,10036,10037,10038]" + }, + "10038": { + "id": 10038, + "event": "你玩父母手机时被诈骗。", + "postEvent": "损失了父母一年的心血。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "include": "(MNY>2)&(INT<8)", + "exclude": "EVT?[10011,10024,10016,10017,10038]", + "branch": [ + "SPR<2:10062", + "INT>5:10040" + ] + }, + "10039": { + "id": 10039, + "event": "你智力迟钝,仍然不会说话。", + "include": "INT<3", + "exclude": "EVT?[10039]" + }, + "10040": { + "id": 10040, + "event": "你告诉父母后,打电话举报。", + "postEvent": "损失被追回。", + "effect": { + "MNY": 1 + }, + "NoRandom": 1 + }, + "10041": { + "id": 10041, + "event": "你和村里小孩打架。", + "postEvent": "战斗力提高了。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10002,10025]", + "branch": [ + "STR<3:10000", + "STR>9:10042" + ] + }, + "10042": { + "id": 10042, + "event": "你失手把一个小孩打死了。", + "postEvent": "父母赔了很多钱。", + "effect": { + "MNY": -2, + "SPR": -1 + }, + "NoRandom": 1, + "branch": [ + "SPR<2:10062" + ] + }, + "10043": { + "id": 10043, + "event": "你想天天吃肉,但父母告诉你吃不起。", + "include": "(MNY<7)&(EVT?[10009])", + "exclude": "EVT?[10043]" + }, + "10044": { + "id": 10044, + "event": "你喜欢去周围的小池塘边玩。", + "include": "EVT?[10009]", + "exclude": "EVT?[10044,10047,10025,10180]" + }, + "10045": { + "id": 10045, + "event": "你有次去池塘边玩时掉进了水里。", + "postEvent": "差点淹死。", + "include": "EVT?[10044,10047,10180]", + "exclude": "EVT?[10045]", + "branch": [ + "TLT?[1016]:10046", + "STR<7:10000" + ] + }, + "10046": { + "id": 10046, + "event": "还好你会游泳,没淹死。", + "NoRandom": 1 + }, + "10047": { + "id": 10047, + "event": "你在周围的池塘钓到了几只小龙虾。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10025,10047]" + }, + "10048": { + "id": 10048, + "event": "你的绘画天赋好像不错。", + "exclude": "EVT?[10048]", + "branch": [ + "(EVT?[10009])&(CHR<3):20048" + ] + }, + "10049": { + "id": 10049, + "event": "你的音乐天赋好像不错。", + "exclude": "EVT?[10049]", + "branch": [ + "(EVT?[10009])&(CHR<3):20049" + ] + }, + "10050": { + "id": 10050, + "event": "你的数学天赋好像不错。", + "include": "INT>8", + "exclude": "EVT?[10050]" + }, + "10051": { + "id": 10051, + "event": "你偷了父母的零钱去买零食。", + "include": "EVT?[10009]", + "exclude": "EVT?[10051]" + }, + "10052": { + "id": 10052, + "event": "你追得家里的动物鸡飞狗跳。", + "include": "(STR>3)&(EVT?[10009])", + "exclude": "EVT?[10052]" + }, + "10053": { + "id": 10053, + "event": "姐姐拿她的旧衣服给你穿。", + "include": "(MNY<6)&(EVT?[10009])", + "exclude": "(EVT?[10053])|(TLT?[1011])", + "branch": [ + "(CHR>6)&(EVT?[10001]):20053" + ] + }, + "10054": { + "id": 10054, + "event": "你经常在田里玩。", + "effect": { + "INT": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10025]", + "branch": [ + "INT>7:10055" + ] + }, + "10055": { + "id": 10055, + "event": "你对自然规律有所观察。", + "NoRandom": 1, + "branch": [ + "INT>9:10056" + ] + }, + "10056": { + "id": 10056, + "event": "你对植物和养生有所领悟。", + "effect": { + "STR": 1 + }, + "NoRandom": 1 + }, + "10057": { + "id": 10057, + "event": "你开始下地干农活。", + "include": "EVT?[10009]", + "exclude": "EVT?[10057,10025]" + }, + "10058": { + "id": 10058, + "event": "下暴雨,发洪水。", + "postEvent": "田都被淹了。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10058,10025]", + "branch": [ + "TLT?[1016]:10046", + "CHR<4:10000" + ] + }, + "10059": { + "id": 10059, + "event": "大旱灾,颗粒无收。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10059,10025]", + "branch": [ + "MNY<3:10013" + ] + }, + "10060": { + "id": 10060, + "event": "发生蝗灾,颗粒无收。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10060,10025]", + "branch": [ + "MNY<3:10013" + ] + }, + "10061": { + "id": 10061, + "event": "一个人在家,非常寂寞。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10024]", + "exclude": "EVT?[10025]", + "branch": [ + "SPR<2:10062" + ] + }, + "10062": { + "id": 10062, + "event": "你的情绪越来越低落,尝试自杀。", + "postEvent": "没有成功。", + "NoRandom": 1, + "branch": [ + "SPR<1:10000" + ] + }, + "10063": { + "id": 10063, + "event": "你的爷爷奶奶只想要男孩,把你活埋了。", + "include": "(CHR<3)&(MNY<3)&(EVT?[10009])", + "exclude": "(EVT?[10063,10001])|(TLT?[1015])", + "branch": [ + "MNY<3:10000" + ] + }, + "10064": { + "id": 10064, + "event": "你被卖给了人贩子。人贩子运送路上你很虚弱。", + "include": "(STR<3)&((MNY<3)&(EVT?[10009])", + "exclude": "(EVT?[10064,10001,10019])|(TLT?[1015])", + "branch": [ + "STR<3:10000" + ] + }, + "10065": { + "id": 10065, + "event": "空气很新鲜,生活很健康。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10065,10025]" + }, + "10066": { + "id": 10066, + "event": "你的生活很自由,没有什么束缚。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10066]" + }, + "10067": { + "id": 10067, + "event": "有一只鸟撞在了你家窗户上。", + "postEvent": "你把它养好后放了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10067]", + "branch": [ + "INT<6:10068" + ] + }, + "10068": { + "id": 10068, + "event": "你把它炖了吃了。", + "NoRandom": 1 + }, + "10069": { + "id": 10069, + "event": "平平淡淡,没有什么特别的事。" + }, + "10070": { + "id": 10070, + "event": "可能是运气不佳,这年里有好多小事让你烦心。", + "effect": { + "SPR": -1 + }, + "exclude": "EVT?[10646,10655]", + "branch": [ + "(INT<6)&(SPR<2):10062" + ] + }, + "10071": { + "id": 10071, + "event": "比较顺风顺水,快乐的一年。", + "effect": { + "SPR": 1 + } + }, + "10072": { + "id": 10072, + "event": "有天打雷,劈断了你家门口一棵树。", + "include": "EVT?[10009]", + "exclude": "EVT?[10072,10025]" + }, + "10073": { + "id": 10073, + "event": "你意外挖到一个上了锁的盒子。", + "postEvent": "你打不开,只好扔了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10073,10025]", + "branch": [ + "INT>8:10074" + ] + }, + "10074": { + "id": 10074, + "event": "你想方设法打开了锁。", + "postEvent": "里面有大量珠宝。", + "effect": { + "MNY": 2, + "SPR": 2 + }, + "NoRandom": 1 + }, + "10075": { + "id": 10075, + "event": "你的运动天赋好像不错。", + "include": "STR>8", + "exclude": "EVT?[10075]", + "branch": [ + "INT<3:20075" + ] + }, + "10076": { + "id": 10076, + "event": "你发现动物好像都不怎么害怕你。", + "include": "(CHR>9)&(EVT?[10009])", + "exclude": "EVT?[10076,10052]" + }, + "10077": { + "id": 10077, + "event": "你发现你和其他人的想法好像都不一样。", + "include": "INT>9", + "exclude": "EVT?[10077,10090]" + }, + "10078": { + "id": 10078, + "event": "你们家成为村里最富的家庭。", + "include": "(MNY>7)&(EVT?[10009])", + "exclude": "EVT?[10078,10025]" + }, + "10079": { + "id": 10079, + "event": "你的高颜值已经在周边家喻户晓。", + "include": "(CHR>7)&(EVT?[10009])", + "exclude": "EVT?[10079]" + }, + "10080": { + "id": 10080, + "event": "有人将你发在了网上,你小有名气。", + "postEvent": "很多人来你家拍短视频。", + "include": "(CHR>8)&(EVT?[10079])", + "exclude": "EVT?[10080]" + }, + "10081": { + "id": 10081, + "event": "有星探和公司想带你去大城市发展。", + "postEvent": "你没有同意。", + "include": "EVT?[10080]", + "exclude": "EVT?[10081]", + "branch": [ + "STR>5&MNY<5:10082" + ] + }, + "10082": { + "id": 10082, + "event": "你来到了一线城市,住进了一家网络公司。", + "postEvent": "你开始直播生活。", + "effect": { + "MNY": 2, + "SPR": 1 + }, + "NoRandom": 1 + }, + "10083": { + "id": 10083, + "event": "你过气了,被公司解除了协议。", + "postEvent": "你回到了乡下。", + "include": "EVT?[10082]", + "exclude": "EVT?[10083]", + "branch": [ + "(INT<6)&(EVT?[10002,10111]):10084" + ] + }, + "10084": { + "id": 10084, + "event": "你过惯了奢靡的生活,无法再回乡下了。", + "postEvent": "你开始出卖身体维持生活质量。", + "effect": { + "STR": -1, + "SPR": 1 + }, + "NoRandom": 1 + }, + "10085": { + "id": 10085, + "event": "你患上了艾滋病。", + "effect": { + "STR": -3, + "SPR": -2 + }, + "include": "EVT?[10084,10162,10219,20056]", + "exclude": "(EVT?[10085,10087])|(TLT?[1017])", + "branch": [ + "STR<1:10000" + ] + }, + "10086": { + "id": 10086, + "event": "你的病情逐渐加重。", + "effect": { + "STR": -3, + "SPR": -1 + }, + "include": "EVT?[10085]", + "branch": [ + "STR<1:10000" + ] + }, + "10087": { + "id": 10087, + "event": "你已经财务自由,不再出卖身体。", + "effect": { + "MNY": 2 + }, + "include": "EVT?[10084,20056]", + "exclude": "EVT?[10087]" + }, + "10088": { + "id": 10088, + "event": "你嫁给了一个普通的程序员。", + "effect": { + "SPR": 2 + }, + "include": "EVT?[10087]", + "exclude": "(EVT?[10088])|(TLT?[1027])" + }, + "10089": { + "id": 10089, + "event": "国家扶贫,你家获得了帮助。", + "effect": { + "MNY": 1, + "SPR": 1 + }, + "include": "(MNY<4)&(EVT?[10009])" + }, + "10090": { + "id": 10090, + "event": "你的智力过高,被外星人抓走做实验。", + "postEvent": "又放了回来。", + "effect": { + "INT": -1, + "STR": -1, + "SPR": -1 + }, + "include": "INT>9", + "exclude": "EVT?[10090]", + "branch": [ + "STR<5:10000" + ] + }, + "10091": { + "id": 10091, + "event": "你经常在家搞些小发明。", + "effect": { + "INT": 1 + }, + "include": "(INT>7)&(EVT?[10009])", + "exclude": "EVT?[10091]", + "branch": [ + "(INT>9)&(CHR<3):20091", + "MNY<3:20092" + ] + }, + "10092": { + "id": 10092, + "event": "你被一只蛇咬了。", + "postEvent": "还好没有毒。", + "include": "EVT?[10009]", + "exclude": "EVT?[10092]", + "branch": [ + "(STR<3)&(TLT![1022]):10000" + ] + }, + "10093": { + "id": 10093, + "event": "你第一次被父母打。", + "effect": { + "SPR": -1 + }, + "exclude": "(EVT?[10093,10016,10017,10144,10024])|(TLT?[1015])" + }, + "10094": { + "id": 10094, + "event": "你第一次坐在躺椅上,看灿烂的银河星空", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10094,10025]" + }, + "10095": { + "id": 10095, + "event": "你在晚上和小伙伴一起捉萤火虫。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10095,10025]" + }, + "10096": { + "id": 10096, + "event": "你听说国外发生了很多大事。", + "postEvent": "但感觉离你很遥远。", + "include": "EVT?[10009]", + "exclude": "EVT?[10096]" + }, + "10097": { + "id": 10097, + "event": "隔壁村的一个孩子淹死了。", + "postEvent": "你的父母一年都没让你去池塘玩。", + "include": "EVT?[10009]", + "exclude": "EVT?[10097,10015,10016,10017,10024]" + }, + "10098": { + "id": 10098, + "event": "你听了轮回转世的神话故事。", + "postEvent": "感觉好像似曾相识。", + "include": "INT>4", + "exclude": "EVT?[10098]" + }, + "10099": { + "id": 10099, + "event": "你徒手抓住了一只老鼠。", + "effect": { + "SPR": 1 + }, + "include": "(INT>6)&(STR>6)&(EVT?[10009])", + "exclude": "EVT?[10099]" + }, + "10100": { + "id": 10100, + "event": "你常常坐在家门口发呆,十分无聊。", + "include": "EVT?[10009]", + "exclude": "EVT?[10100,10036,10037]" + }, + "10101": { + "id": 10101, + "event": "你开始上小学了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10101]" + }, + "10102": { + "id": 10102, + "event": "你在学校交到了新朋友。", + "include": "(INT>2)&(CHR>2)&(EVT?[10101])", + "exclude": "EVT?[10102]" + }, + "10103": { + "id": 10103, + "event": "你第一次接触英语。", + "include": "EVT?[10101]", + "exclude": "EVT?[10103]" + }, + "10104": { + "id": 10104, + "event": "你们的数学老师是一个支教老师。", + "effect": { + "INT": 1 + }, + "include": "EVT?[10101]", + "exclude": "EVT?[10104,10025]" + }, + "10105": { + "id": 10105, + "event": "学校老师太少,你们的体育老师还教你们语文课。", + "effect": { + "INT": -1 + }, + "include": "EVT?[10101]", + "exclude": "EVT?[10105,10025]" + }, + "10106": { + "id": 10106, + "event": "你期末考试考了100分。", + "include": "(INT>7)&(EVT?[10101])", + "exclude": "EVT?[10106]" + }, + "10107": { + "id": 10107, + "event": "你期末考试全都不及格。", + "postEvent": "老师来家访。", + "effect": { + "SPR": -1 + }, + "include": "(INT<3)&(EVT?[10101])", + "exclude": "EVT?[10107]" + }, + "10108": { + "id": 10108, + "event": "你当上了体育课代表。", + "include": "(STR>7)&(EVT?[10101])", + "exclude": "EVT?[10108]" + }, + "10109": { + "id": 10109, + "event": "你在同学中非常受欢迎。", + "effect": { + "SPR": 1 + }, + "include": "(CHR>7)&(EVT?[10101])", + "exclude": "EVT?[10109,10113,10114]" + }, + "10110": { + "id": 10110, + "event": "你出生了,是极为罕见的无性人。", + "exclude": "TLT?[1003,1004,1024,1113]" + }, + "10111": { + "id": 10111, + "event": "你出生了,是极为罕见的双性人。", + "exclude": "TLT?[1003,1004,1025]" + }, + "10112": { + "id": 10112, + "event": "同学总是欺负你。", + "postEvent": "还嘲笑你的长相。", + "effect": { + "SPR": -2 + }, + "include": "(CHR<3)&(EVT?[10101])", + "exclude": "(EVT?[10112])|(TLT?[1037])" + }, + "10113": { + "id": 10113, + "event": "同学总是欺负你。", + "postEvent": "还嘲笑你的成绩。", + "effect": { + "SPR": -2 + }, + "include": "(INT<3)&(EVT?[10101])", + "exclude": "(EVT?[10113,10109])|(TLT?[1037])" + }, + "10114": { + "id": 10114, + "event": "同学总是欺负你。", + "postEvent": "嘲笑你不男不女。", + "effect": { + "SPR": -2 + }, + "include": "(EVT?[10101])&(EVT?[10110,10111])", + "exclude": "(EVT?[10114,10109])|(TLT?[1037])" + }, + "10115": { + "id": 10115, + "event": "你和同桌偷偷谈起了恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(INT>2)&(CHR>4)&(EVT?[10101])", + "exclude": "(EVT?[10115,10116,10110,10111])|(TLT?[1026,1027])" + }, + "10116": { + "id": 10116, + "event": "你和同桌悄悄谈起了恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(INT>1)&(CHR>3)&(EVT?[10101])&(TLT?[1028])", + "exclude": "(EVT?[10115,10116,10110,10111])|(TLT?[1026,1027])" + }, + "10117": { + "id": 10117, + "event": "你当上了班长。", + "effect": { + "SPR": 1 + }, + "include": "(CHR>3)&(INT>6)&(EVT?[10101])", + "exclude": "EVT?[10117]" + }, + "10118": { + "id": 10118, + "event": "你当上了领操员。", + "include": "(CHR>3)&(STR>6)&(EVT?[10101])", + "exclude": "EVT?[10118]" + }, + "10119": { + "id": 10119, + "event": "你为班级出了一次黑板报。", + "include": "(EVT?[10048])&(EVT?[10101])", + "exclude": "EVT?[10119]" + }, + "10120": { + "id": 10120, + "event": "你们班收到了捐赠的书籍文具。", + "include": "EVT?[10101]", + "exclude": "EVT?[10120,10025,10120]" + }, + "10121": { + "id": 10121, + "event": "你们班建立了读书角。", + "include": "EVT?[10101]", + "exclude": "EVT?[10121]" + }, + "10122": { + "id": 10122, + "event": "学校里盖了一座新楼。", + "include": "EVT?[10101]", + "exclude": "EVT?[10122,10025]" + }, + "10123": { + "id": 10123, + "event": "村中阿婆家新盖了小洋房。", + "postEvent": "听说是孩子在外面赚了大钱。", + "include": "EVT?[10009]", + "exclude": "EVT?[10123,10025]" + }, + "10124": { + "id": 10124, + "event": "夏日的一天村里鞭炮齐鸣。", + "postEvent": "听说是人家的孩子考上了重点大学。", + "include": "EVT?[10009]", + "exclude": "EVT?[10124,10025]" + }, + "10125": { + "id": 10125, + "event": "你的父亲意外去世。", + "effect": { + "MNY": -2, + "SPR": -2 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10017,10125])|(TLT?[1029])" + }, + "10126": { + "id": 10126, + "event": "你的母亲意外去世。", + "effect": { + "MNY": -1, + "SPR": -2 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10016,10126])|(TLT?[1029])" + }, + "10127": { + "id": 10127, + "event": "你的爷爷因病去世。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10127]" + }, + "10128": { + "id": 10128, + "event": "你的奶奶因病去世。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10128]" + }, + "10129": { + "id": 10129, + "event": "你很努力学习,但成绩就是提不上去。", + "effect": { + "SPR": -1 + }, + "include": "(INT<4)&(EVT?[10101])", + "exclude": "EVT?[10129]" + }, + "10130": { + "id": 10130, + "event": "今年大丰收,而且你家种的菜也涨价了。", + "effect": { + "MNY": 1, + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10130]" + }, + "10131": { + "id": 10131, + "event": "你获得了第一份奖状。", + "effect": { + "SPR": 1 + }, + "include": "(INT>4)&(EVT?[10101])", + "exclude": "EVT?[10131,10132,10133]" + }, + "10132": { + "id": 10132, + "event": "你获评三好学生。", + "effect": { + "SPR": 1 + }, + "include": "(STR>5)&(INT>5)&(EVT?[10101])" + }, + "10133": { + "id": 10133, + "event": "你获评三好标兵。", + "effect": { + "SPR": 2 + }, + "include": "(STR>7)&(INT>7)&(EVT?[10101])" + }, + "10134": { + "id": 10134, + "event": "有同学在班上炫耀新玩具,被老师没收了。", + "include": "EVT?[10101]", + "exclude": "EVT?[10134]" + }, + "10135": { + "id": 10135, + "event": "你前排的同学在课上偷偷玩手机。", + "include": "EVT?[10101]", + "exclude": "EVT?[10135]" + }, + "10136": { + "id": 10136, + "event": "老师在班上进行了IQ测试。", + "postEvent": "你获得了145分", + "include": "(INT>7)&(EVT?[10101])", + "exclude": "EVT?[10136]" + }, + "10137": { + "id": 10137, + "event": "老师在班上进行了IQ测试。", + "postEvent": "你获得了135分", + "include": "(INT>6)&(EVT?[10101])", + "exclude": "EVT?[10137]" + }, + "10138": { + "id": 10138, + "event": "努力学习的一年,能感受到水平的提高。", + "effect": { + "INT": 1 + }, + "include": "(INT>3)&(EVT?[10101])", + "exclude": "EVT?[10138]" + }, + "10139": { + "id": 10139, + "event": "没有用功学习的一年,能感受到水平的下降。", + "effect": { + "INT": -1 + }, + "include": "(INT<8)&(EVT?[10101])", + "exclude": "EVT?[10139]" + }, + "10140": { + "id": 10140, + "event": "你家养的狗被人毒死了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10140,10141])|(TLT?[1030])" + }, + "10141": { + "id": 10141, + "event": "你家养的猫被人毒死了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10140,10141])|(TLT?[1030])" + }, + "10142": { + "id": 10142, + "event": "家里老鼠蟑螂泛滥成灾。", + "include": "(MNY<5)&(EVT?[10009])" + }, + "10143": { + "id": 10143, + "event": "隔壁的村花和邻居叔叔结婚了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10143,10031,10025]" + }, + "10144": { + "id": 10144, + "event": "你天天被父母殴打。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10009]", + "exclude": "(EVT?[10093,10016,10019,10017,10144,10125,10126,10024])|(TLT?[1015])" + }, + "10145": { + "id": 10145, + "event": "成为了弹弓高手,一弹一鸟。", + "include": "(INT>3)&(STR>5)&(EVT?[10009])", + "exclude": "EVT?[10145,10002,10025]" + }, + "10146": { + "id": 10146, + "event": "在田里插秧时,总是被水蛭叮咬。", + "include": "EVT?[10009]", + "exclude": "EVT?[10146,10002,10025]" + }, + "10147": { + "id": 10147, + "event": "村子里基本没几个年轻人了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10147,10025]" + }, + "10148": { + "id": 10148, + "event": "你家装上了全村唯一的wifi,总有人来问密码。", + "include": "(MNY>6)&(EVT?[10009])", + "exclude": "EVT?[10148,10024]" + }, + "10149": { + "id": 10149, + "event": "教室里唯一较好的窗户也破了。", + "postEvent": "下雨天靠窗完全不能坐人了。", + "include": "EVT?[10101]", + "exclude": "EVT?[10149,10025]" + }, + "10150": { + "id": 10150, + "event": "你家的屋檐上多了个燕子窝。", + "include": "EVT?[10009]", + "exclude": "EVT?[10150]" + }, + "10151": { + "id": 10151, + "event": "教室窗外多了个马蜂窝。", + "include": "EVT?[10101]", + "exclude": "EVT?[10151]" + }, + "10152": { + "id": 10152, + "event": "你的床板塌了,只能睡桌椅上了。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10152]" + }, + "10153": { + "id": 10153, + "event": "你突然生了场大病。", + "effect": { + "STR": -2, + "MNY": -1, + "SPR": -1 + }, + "include": "(STR<5)&(EVT?[10009])", + "exclude": "EVT?[10153]", + "branch": [ + "STR<1:10000" + ] + }, + "10154": { + "id": 10154, + "event": "你总是遭遇校园暴力。", + "effect": { + "SPR": -2 + }, + "include": "(STR<6)&(EVT?[10009])", + "exclude": "(EVT?[10109,10154])|(TLT?[1037])", + "branch": [ + "SPR<2:10062" + ] + }, + "10155": { + "id": 10155, + "event": "你家人让你能辍学打工,为弟弟攒彩礼钱。", + "include": "(EVT?[10014])&(EVT?[10101])", + "exclude": "(EVT?[10155,10156])|(TLT?[1015])" + }, + "10156": { + "id": 10156, + "event": "你家人让你能辍学打工,补贴家用。", + "include": "(MNY<5)&(EVT?[10101])", + "exclude": "(EVT?[10155,10156])|(TLT?[1015])" + }, + "10157": { + "id": 10157, + "event": "你在城里找到了一份工作。", + "include": "EVT?[10155,10156,10025]", + "exclude": "EVT?[10157]" + }, + "10158": { + "id": 10158, + "event": "你买彩票中了个小奖。", + "postEvent": "虽然钱不多但很快乐。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10157]", + "exclude": "EVT?[10158]" + }, + "10159": { + "id": 10159, + "event": "你买彩票中了个大奖。", + "effect": { + "MNY": 2, + "SPR": 2 + }, + "include": "EVT?[10157]", + "exclude": "EVT?[10159]" + }, + "10160": { + "id": 10160, + "event": "你留了一级。", + "include": "(INT<4)&(EVT?[10101])", + "exclude": "EVT?[10160,10025,10156,10155]" + }, + "10161": { + "id": 10161, + "event": "你遭到了同事的性骚扰。", + "effect": { + "SPR": -1 + }, + "include": "(CHR>6)&(EVT?[10157])" + }, + "10162": { + "id": 10162, + "event": "你遭到了同事的性侵。", + "effect": { + "SPR": -2 + }, + "include": "(STR<5)&(CHR>8)&(EVT?[10157])" + }, + "10163": { + "id": 10163, + "event": "过年时拜访了几十家亲戚。", + "include": "(STR>1)&(EVT?[10009])", + "exclude": "EVT?[10163,10025,10156,10155]" + }, + "10164": { + "id": 10164, + "event": "家里茅坑废弃了,换成了马桶。", + "include": "(MNY>4)&(EVT?[10009])", + "exclude": "EVT?[10164,10025,10156,10155]" + }, + "10165": { + "id": 10165, + "event": "通了自来水,家里的井不再使用。", + "include": "(MNY>3)&(EVT?[10009])", + "exclude": "EVT?[10164,10165,10025,10156,10155]" + }, + "10166": { + "id": 10166, + "event": "半夜发烧,爸妈路边等公交车送你去县城医院.", + "include": "(STR<5)&(MNY<5)&(EVT?[10009])", + "exclude": "EVT?[10166,10015,10016,10017,10125,10126]" + }, + "10167": { + "id": 10167, + "event": "用牙齿咬欺凌自己的人,反而被告老师。", + "postEvent": "很委屈。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10154,10112,10113,10114]", + "exclude": "EVT?[10167]" + }, + "10168": { + "id": 10168, + "event": "被老人讲的鬼故事吓到。", + "include": "EVT?[10009]", + "exclude": "EVT?[10168,10127,10128]" + }, + "10169": { + "id": 10169, + "event": "买小卖部的零食吃,第二天拉肚子发烧。", + "include": "(STR<5)&(MNY>2)&(EVT?[10009])", + "exclude": "EVT?[10169]" + }, + "10170": { + "id": 10170, + "event": "被同学取难听的外号。", + "effect": { + "SPR": -1 + }, + "include": "(STR<9)&(MNY<9)&(EVT?[10101])", + "exclude": "(EVT?[10170,10109])|(TLT?[1037])" + }, + "10171": { + "id": 10171, + "event": "过年玩鞭炮被炸伤。", + "include": "EVT?[10009]", + "exclude": "EVT?[10171,10002]" + }, + "10172": { + "id": 10172, + "event": "在外面玩到晚上,被爸妈抓了回来。", + "include": "EVT?[10009]", + "exclude": "EVT?[10172,10015,10016,10017,10125,10126]" + }, + "10173": { + "id": 10173, + "event": "学自行车摔得膝盖流血。", + "postEvent": "没学会。", + "include": "(STR<4)&(EVT?[10009])", + "exclude": "TLT?[1038]" + }, + "10174": { + "id": 10174, + "event": "尝试自学自行车。", + "postEvent": "没学会。", + "include": "(INT<5)&(STR<5)&(EVT?[10009])", + "exclude": "TLT?[1038]" + }, + "10175": { + "id": 10175, + "event": "尝试自学自行车。", + "postEvent": "学会了。", + "include": "(INT>1)&(STR>1)&(EVT?[10009])", + "exclude": "EVT?[10175]" + }, + "10176": { + "id": 10176, + "event": "想买和同学同款的玩具,但买不起。", + "include": "(MNY<4)&(EVT?[10101])", + "exclude": "EVT?[10176]" + }, + "10177": { + "id": 10177, + "event": "被爸爸带去打麻将到半夜,睡着了还没回家。", + "include": "EVT?[10009]", + "exclude": "EVT?[10177,10015,10017,10125]" + }, + "10178": { + "id": 10178, + "event": "学着帮家里喂牲畜。", + "include": "EVT?[10009]", + "exclude": "EVT?[10178]" + }, + "10179": { + "id": 10179, + "event": "下完雨退潮去河边捡田螺。", + "include": "EVT?[10009]", + "exclude": "EVT?[10179]" + }, + "10180": { + "id": 10180, + "event": "去池塘电鱼吃。", + "include": "EVT?[10009]", + "exclude": "EVT?[10180,10025,10156,10155]" + }, + "10181": { + "id": 10181, + "event": "上山剪橘子差点掉下山。", + "include": "EVT?[10009]", + "exclude": "EVT?[10181,10025,10156,10155]" + }, + "10182": { + "id": 10182, + "event": "被路上的狗堵路追着跑。", + "include": "(STR>2)&(CHR<9)&(EVT?[10009])", + "exclude": "EVT?[10182,10183]" + }, + "10183": { + "id": 10183, + "event": "被野狗咬了,去县城打狂犬疫苗。", + "effect": { + "SPR": -1 + }, + "include": "(MNY>2)&(CHR<9)&(EVT?[10009])", + "exclude": "EVT?[10183]" + }, + "10184": { + "id": 10184, + "event": "考上县城初中,每天要走很远去上学。", + "include": "(INT>4)&(MNY>2)&(EVT?[10101])", + "exclude": "EVT?[10184,10025,10156,10155]" + }, + "10185": { + "id": 10185, + "event": "考上县城初中,但是上不起。", + "include": "(INT>4)&(MNY<3)&(EVT?[10101])", + "exclude": "EVT?[10185,10025,10156,10155]" + }, + "10186": { + "id": 10186, + "event": "班上大多数都是混混的,课都上不成。", + "include": "EVT?[10101]", + "exclude": "EVT?[10184,10025,10156,10155]", + "branch": [ + "TLT?[1108]:20186" + ] + }, + "10187": { + "id": 10187, + "event": "被坏同学影响,开始抽烟喝酒去游戏厅。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10101]", + "exclude": "EVT?[10184,10187,10025,10156,10155]" + }, + "10188": { + "id": 10188, + "event": "开始去网吧,沉迷游戏。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10188,10194,10002]" + }, + "10189": { + "id": 10189, + "event": "沉迷二次元,天天追新番。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10007,10008]", + "exclude": "EVT?[10189]" + }, + "10190": { + "id": 10190, + "event": "游戏水平很高,远近网吧闻名。", + "postEvent": "网吧老板允许你免费上网。", + "effect": { + "SPR": 1 + }, + "include": "(STR>2)&(INT>7)&(EVT?[10188,10194])", + "exclude": "EVT?[10190]" + }, + "10191": { + "id": 10191, + "event": "被公司发掘,进入电竞培训队。", + "postEvent": "前往大城市。", + "include": "EVT?[10190,10942]", + "exclude": "EVT?[10191]" + }, + "10192": { + "id": 10192, + "event": "开始为战队打比赛。", + "postEvent": "但并没有打出什么成绩。", + "effect": { + "STR": -1, + "SPR": -1 + }, + "include": "EVT?[10191]", + "exclude": "EVT?[10192]", + "branch": [ + "TLT?[1039]:10193", + "SPR>6:10193" + ] + }, + "10193": { + "id": 10193, + "event": "连续夺得大奖。", + "effect": { + "STR": -2, + "MNY": 2, + "SPR": 2 + }, + "NoRandom": 1 + }, + "10194": { + "id": 10194, + "event": "开始去网吧,沉迷游戏。", + "include": "(TLT?[1039])&(EVT?[10009])", + "exclude": "EVT?[10194,10188]" + }, + "10195": { + "id": 10195, + "event": "巅峰时期退役。", + "postEvent": "转行游戏主播。", + "include": "EVT?[10193]", + "exclude": "EVT?[10195,10196,10197]" + }, + "10196": { + "id": 10196, + "event": "继续打比赛。", + "effect": { + "STR": -1 + }, + "include": "(STR>3)&(EVT?[10192])", + "exclude": "EVT?[10195,10196,10197]" + }, + "10197": { + "id": 10197, + "event": "退役。", + "postEvent": "转行游戏主播。", + "include": "EVT?[10192]", + "exclude": "EVT?[10195,10196,10197]" + }, + "10198": { + "id": 10198, + "event": "中考考的很差,没考上高中。", + "include": "(EVT?[10009])&(INT<4)&(EVT?[10188,10187,10186,10189])", + "exclude": "EVT?[10198,10199,10200,10025,10156,10155]" + }, + "10199": { + "id": 10199, + "event": "中考考的一般,上了县里的高中。", + "include": "EVT?[10101]", + "exclude": "(INT<3)|(EVT?[10198,10200,10199,10025,10156,10155])" + }, + "10200": { + "id": 10200, + "event": "中考考的很好,上了城里的好高中。", + "include": "(MNY>2)&(INT>5)&(EVT?[10101])", + "exclude": "(INT<6)|(EVT?[10198,10200,10199,10025,10156,10155])" + }, + "10201": { + "id": 10201, + "event": "打篮球、踢足球受伤。", + "include": "(STR>4)&(MNY>2)&(EVT?[10101])", + "exclude": "(STR>9)|(EVT?[10201,10002])" + }, + "10202": { + "id": 10202, + "event": "被视察的体校教练发掘。去体校训练。", + "include": "(STR>6)&(EVT?[10184])", + "exclude": "EVT?[10202]" + }, + "10203": { + "id": 10203, + "event": "进入省队。", + "postEvent": "刻苦训练。", + "include": "EVT?[10202,10939]", + "exclude": "EVT?[10203,10204]", + "branch": [ + "SPR>8:10204" + ] + }, + "10204": { + "id": 10204, + "event": "表现突出,进入国家队。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10205": { + "id": 10205, + "event": "刻苦训练。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10203]", + "exclude": "EVT?[10205,10204]", + "branch": [ + "SPR>8:10204" + ] + }, + "10206": { + "id": 10206, + "event": "刻苦训练。", + "include": "EVT?[10203]", + "exclude": "EVT?[10206]" + }, + "10207": { + "id": 10207, + "event": "参加奥运会。", + "postEvent": "夺得奖牌。", + "effect": { + "MNY": 1, + "SPR": 1 + }, + "include": "EVT?[10204]", + "branch": [ + "SPR>9:10208" + ] + }, + "10208": { + "id": 10208, + "event": "夺得金牌。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1, + "branch": [ + "SPR>10:10209" + ] + }, + "10209": { + "id": 10209, + "event": "并打破世界纪录。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10210": { + "id": 10210, + "event": "退役。", + "postEvent": "开始当教练。", + "include": "EVT?[10203]", + "exclude": "EVT?[10210]" + }, + "10211": { + "id": 10211, + "event": "和男同学谈恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10009])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10211,10198,10025,10156,10155])|(TLT?[1027])" + }, + "10212": { + "id": 10212, + "event": "和女同学谈恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10009])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10212,10198,10025,10156,10155])|(TLT?[1027])" + }, + "10213": { + "id": 10213, + "event": "有同学翻学校围墙逃课,意外身亡。", + "include": "EVT?[10101]", + "exclude": "EVT?[10213]", + "branch": [ + "TLT?[1108]:20213" + ] + }, + "10214": { + "id": 10214, + "event": "性启蒙。", + "include": "EVT?[10009]", + "exclude": "EVT?[10214]" + }, + "10215": { + "id": 10215, + "event": "遇上街上的黑社会对拼,很震撼。", + "include": "EVT?[10009]", + "exclude": "EVT?[10215,10185]", + "branch": [ + "TLT?[1108]:20215" + ] + }, + "10216": { + "id": 10216, + "event": "坐公交车被劫车收保护费。", + "include": "EVT?[10009]", + "exclude": "EVT?[10216,10185]" + }, + "10217": { + "id": 10217, + "event": "被同学骗沾染毒品。", + "effect": { + "STR": -2, + "MNY": -1, + "SPR": 1 + }, + "include": "EVT?[10009,10185,10186,10187,10188]", + "exclude": "(EVT?[10217])|(TLT?[1040])", + "branch": [ + "STR<1:10000" + ] + }, + "10218": { + "id": 10218, + "event": "学会赌博。", + "effect": { + "MNY": -2, + "SPR": -1 + }, + "include": "EVT?[10009,10185,10186,10187,10188]", + "exclude": "(EVT?[10218])|(TLT?[1040])" + }, + "10219": { + "id": 10219, + "event": "被同学带去嫖娼。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10009,10185,10186,10187,10188])&(EVT?[10001])" + }, + "10220": { + "id": 10220, + "event": "你吸毒被捕。", + "postEvent": "进了戒毒所。", + "effect": { + "STR": -1, + "MNY": -1, + "SPR": -1 + }, + "include": "EVT?[10217]", + "exclude": "EVT?[10220]", + "branch": [ + "SPR<2:10062", + "STR<1:10000" + ] + }, + "10221": { + "id": 10221, + "event": "你日渐消瘦。", + "effect": { + "STR": -1, + "SPR": -1 + }, + "include": "EVT?[10217]", + "branch": [ + "SPR<2:10062", + "STR<1:10000" + ] + }, + "10222": { + "id": 10222, + "event": "你戒掉了毒品。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10217]", + "exclude": "EVT?[10222]", + "branch": [ + "SPR<2:10062" + ] + }, + "10223": { + "id": 10223, + "event": "你四处借贷,倾家荡产。", + "effect": { + "MNY": -2, + "SPR": -2 + }, + "include": "EVT?[10218]", + "exclude": "EVT?[10223]", + "branch": [ + "SPR<2:10062", + "MNY<2:10013" + ] + }, + "10224": { + "id": 10224, + "event": "去城里看亲戚。", + "postEvent": "你很羡慕他们家什么都有。", + "include": "(MNY<5)&(EVT?[10009])", + "exclude": "EVT?[10224]" + }, + "10225": { + "id": 10225, + "event": "到同学家借书看。", + "include": "(CHR>3)&(MNY<5)&(EVT?[10199,10200,10184])", + "exclude": "EVT?[10225]" + }, + "10226": { + "id": 10226, + "event": "混不下去了,回老家种田。", + "include": "(INT<8)&(EVT?[10025,10156,10155])", + "exclude": "EVT?[10226]" + }, + "10227": { + "id": 10227, + "event": "有同学退学结婚了。", + "include": "EVT?[10101]", + "exclude": "EVT?[10227]" + }, + "10228": { + "id": 10228, + "event": "你开始相亲。", + "include": "EVT?[10222]", + "exclude": "(EVT?[10228,10229])|(TLT?[1027])" + }, + "10229": { + "id": 10229, + "event": "你结婚了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10228]", + "exclude": "EVT?[10229,11171,11093,10610,10611,10612]" + }, + "10230": { + "id": 10230, + "event": "你被家人逼着去和一个不喜欢的村民结婚。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10198,10155,10156,10226]", + "exclude": "(EVT?[10230,10016,10017])|(TLT?[1015])", + "branch": [ + "TLT?[1027]:10232", + "SPR<2:10062" + ] + }, + "10231": { + "id": 10231, + "event": "你和村中一个你喜欢的姑娘在一起了。", + "effect": { + "SPR": 2 + }, + "include": "(EVT?[10198,10155,10156])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10230,10231])|(TLT?[1027])" + }, + "10232": { + "id": 10232, + "event": "你誓死不从,自杀了。", + "NoRandom": 1, + "branch": [ + "TLT?[1027]:10000" + ] + }, + "10233": { + "id": 10233, + "event": "你和隔壁村一个你喜欢的小伙在一起了。", + "effect": { + "SPR": 2 + }, + "include": "(EVT?[10198,10155,10156])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10230,10231])|(TLT?[1027])" + }, + "10234": { + "id": 10234, + "event": "你和另一个游戏主播结婚了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10195,10197]", + "exclude": "(EVT?[10234])|(TLT?[1027])" + }, + "10235": { + "id": 10235, + "event": "你找到了一个适合的人,结婚了。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10210])&(EVT?[10009])", + "exclude": "(EVT?[10235])|(TLT?[1027])" + }, + "10236": { + "id": 10236, + "event": "你年龄大了,随便找了一个将就着结婚了。", + "include": "EVT?[10009]", + "exclude": "(EVT?[10235,10236,10234,10250,10233,10231,10230,10229,10610,10611,10612,10088])|(TLT?[1027])" + }, + "10237": { + "id": 10237, + "event": "高考,你考上了专科。", + "include": "(INT<6)&(EVT?[10199])", + "exclude": "EVT?[10237,10238,10239,10468]" + }, + "10238": { + "id": 10238, + "event": "高考,你考上了当地的普通本科。", + "include": "(INT>5)&(EVT?[10199,10200])", + "exclude": "(INT>7)|(EVT?[10238,10237,10239,10468])" + }, + "10239": { + "id": 10239, + "event": "高考,你考上了大城市的重点本科。", + "effect": { + "SPR": 1 + }, + "include": "(INT>7)&(EVT?[10199,10200])", + "exclude": "EVT?[10239,10238,10237,10468]" + }, + "10240": { + "id": 10240, + "event": "你参加了社会实践。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10240]" + }, + "10241": { + "id": 10241, + "event": "你参加了志愿者活动。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10241]" + }, + "10242": { + "id": 10242, + "event": "发现班上至少一半同学天天翘课。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10242]" + }, + "10243": { + "id": 10243, + "event": "你漏了一节思修课没上,打开了开关。", + "postEvent": "之后经常翘课了。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10243]" + }, + "10244": { + "id": 10244, + "event": "加入了学生会。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10244]" + }, + "10245": { + "id": 10245, + "event": "和同院的一个女生谈恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10237,10238,10239])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10245])|(TLT?[1027])" + }, + "10246": { + "id": 10246, + "event": "和同院的一个男生谈恋爱。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10237,10238,10239])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10246])|(TLT?[1027])" + }, + "10247": { + "id": 10247, + "event": "遭到了附近的恶霸殴打,报警不管,举报无门。", + "postEvent": "只能忍气吞声。", + "effect": { + "SPR": -2 + }, + "include": "(STR<7)&(EVT?[10009])", + "exclude": "EVT?[10247]", + "branch": [ + "SPR<3:10248" + ] + }, + "10248": { + "id": 10248, + "event": "你怀恨在心,买了水果刀将恶霸捅死了。", + "postEvent": "你被刑事拘留。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10249": { + "id": 10249, + "event": "恶霸家手眼通天,你被判处死刑。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10248]", + "exclude": "EVT?[10249]", + "branch": [ + "EVT?[10248]:10000" + ] + }, + "10250": { + "id": 10250, + "event": "你和大学对象步入了婚姻的殿堂。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10245,10246]", + "exclude": "(EVT?[10250,10251])|(TLT?[1027])" + }, + "10251": { + "id": 10251, + "event": "你开始相亲。", + "include": "EVT?[10237,10238,10239]", + "exclude": "(EVT?[10251,10236,10229,10250,10245,10246])|(TLT?[1027])" + }, + "10252": { + "id": 10252, + "event": "你始终找不到合适的对象。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10251]" + }, + "10253": { + "id": 10253, + "event": "你的父亲因病去世。", + "postEvent": "母亲也随之去世。", + "include": "EVT?[10009]", + "exclude": "EVT?[10253,10016,10017,10125,10126,10254,10255,10256,10257]" + }, + "10254": { + "id": 10254, + "event": "你的母亲发生车祸去世。", + "include": "EVT?[10009]", + "exclude": "(EVT?[10253,10016,10126,10254,10257])|(TLT?[1043])" + }, + "10255": { + "id": 10255, + "event": "你的父亲意外去世。", + "include": "EVT?[10009]", + "exclude": "EVT?[10253,10017,10125,10255,10256]" + }, + "10256": { + "id": 10256, + "event": "你的父亲突发心血管疾病去世。", + "include": "EVT?[10009]", + "exclude": "(EVT?[10253,10017,10125,10255,10256])|(TLT?[1044])" + }, + "10257": { + "id": 10257, + "event": "你的母亲重病去世。", + "include": "EVT?[10009]", + "exclude": "EVT?[10253,10016,10126,10254,10257]" + }, + "10258": { + "id": 10258, + "event": "你想要参军。", + "include": "(STR>5)&(EVT?[10009,10940])", + "exclude": "EVT?[10198,10199,10200,10025,10156,10155,10258]" + }, + "10259": { + "id": 10259, + "event": "你正式入伍。", + "include": "EVT?[10258]", + "exclude": "EVT?[10259,10468]" + }, + "10260": { + "id": 10260, + "event": "平淡但不平凡的军旅生涯。", + "include": "EVT?[10259]" + }, + "10261": { + "id": 10261, + "event": "你比其他战士更能吃苦耐劳。", + "effect": { + "SPR": 1 + }, + "include": "(STR>7)&(EVT?[10259])", + "exclude": "EVT?[10261]" + }, + "10262": { + "id": 10262, + "event": "你的智慧让其他人刮目相看。", + "effect": { + "SPR": 1 + }, + "include": "(INT>7)&(EVT?[10259])", + "exclude": "EVT?[10262]" + }, + "10263": { + "id": 10263, + "event": "你的颜值让同性都忍不住多看几眼。", + "include": "(CHR>7)&(EVT?[10259])", + "exclude": "EVT?[10263]" + }, + "10264": { + "id": 10264, + "event": "你退伍了。", + "postEvent": "在县城当上了保安。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10259]", + "exclude": "EVT?[10264]", + "branch": [ + "TLT?[1045]:10265" + ] + }, + "10265": { + "id": 10265, + "event": "当上了村委书记。", + "effect": { + "MNY": 2 + }, + "NoRandom": 1 + }, + "10266": { + "id": 10266, + "event": "你和隔壁村老村委书记家的孩子结婚了。", + "include": "EVT?[10265]", + "exclude": "(EVT?[10266])|(TLT?[1027])" + }, + "10267": { + "id": 10267, + "event": "你在一次演习中发生了意外。", + "postEvent": "运气好,没有受伤。", + "include": "EVT?[10259]", + "exclude": "EVT?[10267]", + "branch": [ + "INT<6:10000" + ] + }, + "10268": { + "id": 10268, + "event": "你们生了一个女儿。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "(TLT?[1041,1046,1026])|(EVT?[10269,10110,10279])" + }, + "10269": { + "id": 10269, + "event": "你们生了一个儿子。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "(TLT?[1041,1046,1026])|(EVT?[10269,10110,10279])" + }, + "10270": { + "id": 10270, + "event": "因为你不想生孩子,你们离婚了。", + "include": "(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1041])", + "exclude": "(EVT?[10270,10270,10271,11294,11295,10281,10282,20076,10110,10279])|(TLT?[1123])" + }, + "10271": { + "id": 10271, + "event": "生不出孩子,医院检查发现你功能有问题。", + "postEvent": "你们离婚了。", + "include": "(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1046])", + "exclude": "(EVT?[10271,10279,10270,10271,11294,20076,11295,10281])|(TLT?[1123])" + }, + "10272": { + "id": 10272, + "event": "你们领养了一个孩子。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])&(TLT?[1026])", + "exclude": "EVT?[10272,11295,10281,10282,10279]" + }, + "10273": { + "id": 10273, + "event": "普通的家庭生活。", + "postEvent": "你感觉时间过得越来越快。", + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "EVT?[10279]" + }, + "10274": { + "id": 10274, + "event": "你感觉生活越来越无趣,你很怀念小时候。", + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]" + }, + "10275": { + "id": 10275, + "event": "家庭琐事很多,你们经常吵架。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "EVT?[10279,11295,10281,20076,10270,10282,10271,11294,20076]", + "branch": [ + "(TLT![1123])&(SPR<3):20076" + ] + }, + "10276": { + "id": 10276, + "event": "结婚周年纪念日,你们分床而睡。", + "include": "(SPR<4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])", + "exclude": "EVT?[10276,11295,10281,10282,10279,20076,10270,10271,11294,20076]", + "branch": [ + "(TLT![1123])&(SPR<3):20076" + ] + }, + "10277": { + "id": 10277, + "event": "小时候一件小事你都能记很久。", + "postEvent": "现在你却连上个月的事都记不清了。", + "effect": { + "STR": -1 + }, + "include": "(INT<7)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])", + "exclude": "EVT?[10277]" + }, + "10278": { + "id": 10278, + "event": "你感觉自己老得越来越快,颜值不再。", + "effect": { + "CHR": -1 + }, + "include": "(CHR>4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])" + }, + "10279": { + "id": 10279, + "event": "你的爱人病重。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "(EVT?[10279,20076])|(TLT?[1047])" + }, + "10280": { + "id": 10280, + "event": "你的爱人病重。", + "effect": { + "SPR": -1 + }, + "include": "TLT?[1047]", + "exclude": "EVT?[10280,20076]" + }, + "10281": { + "id": 10281, + "event": "你的爱人去世了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10279,10280]", + "exclude": "EVT?[10281,20076]" + }, + "10282": { + "id": 10282, + "event": "你的爱人发生车祸去世。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "(EVT?[10282,10279,20076])|(TLT?[1043,1047])" + }, + "10283": { + "id": 10283, + "event": "孩子经常和你吵架。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10268,10269,10272]" + }, + "10284": { + "id": 10284, + "event": "孩子长得越来越可爱。", + "effect": { + "SPR": 1 + }, + "include": "(CHR>5)&(EVT?[10268,10269,10272])" + }, + "10285": { + "id": 10285, + "event": "孩子很聪明。", + "effect": { + "SPR": 1 + }, + "include": "(INT>6)&(EVT?[10268,10269,10272])", + "exclude": "EVT?[10285]" + }, + "10286": { + "id": 10286, + "event": "你有孙子了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10268,10269,10272]", + "exclude": "EVT?[10286,20076]" + }, + "10287": { + "id": 10287, + "event": "你有孙女了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10268,10269,10272]", + "exclude": "EVT?[10287,20076]" + }, + "10288": { + "id": 10288, + "event": "你为自己而活,过得很快乐。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])" + }, + "10289": { + "id": 10289, + "event": "你遭遇了严重的车祸。", + "include": "EVT?[10009]", + "exclude": "TLT?[1043]", + "branch": [ + "EVT?[10007,10008]:30002", + "EVT?[10009]:10000" + ] + }, + "10290": { + "id": 10290, + "event": "你查出了晚期癌症。", + "include": "(STR<6)&(EVT?[10009])", + "exclude": "EVT?[10290]", + "branch": [ + "EVT?[10009]:10000" + ] + }, + "10291": { + "id": 10291, + "event": "你突发心血管疾病去世。", + "include": "(STR<6)&(EVT?[10009])", + "exclude": "TLT?[1044]", + "branch": [ + "EVT?[10009]:10000" + ] + }, + "10292": { + "id": 10292, + "event": "你的身体越来越差了。", + "effect": { + "STR": -1 + }, + "include": "(STR<6)&(EVT?[10009])", + "exclude": "EVT?[10292]" + }, + "10293": { + "id": 10293, + "event": "你经常锻炼,身体还不错。", + "effect": { + "SPR": 1 + }, + "include": "(STR>5)&(EVT?[10009])", + "exclude": "EVT?[10293]" + }, + "10294": { + "id": 10294, + "event": "你在睡梦中安然离世。", + "effect": { + "SPR": 1 + }, + "include": "(STR>5)&(EVT?[10009])", + "exclude": "(TLT?[1048])|(EVT?[10294])", + "branch": [ + "EVT?[10009]:10000" + ] + }, + "10295": { + "id": 10295, + "event": "你后悔年轻时没有做更多的事。", + "postEvent": "大人的生活真的很无趣。", + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "EVT?[10295]", + "branch": [ + "(STR<5)&(MNY>5):20296" + ] + }, + "10296": { + "id": 10296, + "event": "你攒了不少钱。", + "effect": { + "MNY": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10296]" + }, + "10297": { + "id": 10297, + "event": "你去南方旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10297]" + }, + "10298": { + "id": 10298, + "event": "你去北方旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10298]" + }, + "10299": { + "id": 10299, + "event": "你去西藏旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10299]" + }, + "10300": { + "id": 10300, + "event": "你去新疆旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10300]" + }, + "10301": { + "id": 10301, + "event": "你去爬黄山。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10301]" + }, + "10302": { + "id": 10302, + "event": "你去爬泰山。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10302]" + }, + "10303": { + "id": 10303, + "event": "你去杭州看西湖。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10303]" + }, + "10304": { + "id": 10304, + "event": "你去蒙古看草原。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10304]" + }, + "10305": { + "id": 10305, + "event": "你去北京旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10305]" + }, + "10306": { + "id": 10306, + "event": "你去上海旅游。", + "effect": { + "SPR": 1 + }, + "include": "(TLT?[1041,1027])&(EVT?[10009])", + "exclude": "EVT?[10306]" + }, + "10307": { + "id": 10307, + "event": "你突然发现,从你结婚那天起,你的人生就结束了。", + "include": "(SPR<4)&(EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236])", + "exclude": "EVT?[10307]" + }, + "10308": { + "id": 10308, + "event": "你小病不断。", + "include": "(STR<5)&(EVT?[10009])", + "exclude": "EVT?[10308]" + }, + "10309": { + "id": 10309, + "event": "你近视了。", + "include": "(STR<9)&(EVT?[10009])", + "exclude": "EVT?[10309]" + }, + "10310": { + "id": 10310, + "event": "你老花眼了。", + "include": "(STR<5)&(EVT?[10009])", + "exclude": "EVT?[10310]" + }, + "10311": { + "id": 10311, + "event": "你换了好几颗牙。", + "include": "EVT?[10009]", + "exclude": "EVT?[10311]" + }, + "10312": { + "id": 10312, + "event": "你掉了好几颗牙。", + "include": "(STR<9)&(EVT?[10009,10010])", + "exclude": "EVT?[10312]" + }, + "10313": { + "id": 10313, + "event": "你耳朵听不清了。", + "include": "(STR<9)&(EVT?[10009,10010])", + "exclude": "EVT?[10313]" + }, + "10314": { + "id": 10314, + "event": "你有点失忆,忘掉了不少东西。", + "effect": { + "INT": -3, + "SPR": 1 + }, + "include": "(INT>2)&(EVT?[10009,10010])", + "exclude": "(INT>7)|(EVT?[10314])" + }, + "10315": { + "id": 10315, + "event": "你瘫痪了。", + "include": "(STR<3)&(EVT?[10009])", + "exclude": "EVT?[10315]" + }, + "10316": { + "id": 10316, + "event": "和你同一代的熟人开始纷纷离世。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10316]" + }, + "10317": { + "id": 10317, + "event": "你发现自己成了一个无趣的中年人。", + "include": "EVT?[10235,10236,10234,10233,10231,10230,10229,10088,10236]", + "exclude": "EVT?[10317]", + "branch": [ + "INT>5:20317" + ] + }, + "10318": { + "id": 10318, + "event": "时代在进步,你完全搞不懂新的电子产品。", + "include": "(INT<7)&(EVT?[10009])", + "exclude": "EVT?[10318]" + }, + "10319": { + "id": 10319, + "event": "你听不懂年轻人在说什么。", + "include": "(INT<9)&(EVT?[10009])", + "exclude": "EVT?[10319]" + }, + "10320": { + "id": 10320, + "event": "你的颜值仍然过人。", + "include": "(CHR>6)&(EVT?[10009,10010])", + "exclude": "EVT?[10320]" + }, + "10321": { + "id": 10321, + "event": "时代在进步,新一代VR设备你仍然了如指掌。", + "include": "(MNY>4)&(INT>7)&(EVT?[10009])", + "exclude": "EVT?[10321]" + }, + "10322": { + "id": 10322, + "event": "你发现孩子不是亲生的。", + "postEvent": "你装作不知道。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10268,10269]", + "exclude": "EVT?[10322,10002]", + "branch": [ + "SPR<2:10062" + ] + }, + "10323": { + "id": 10323, + "event": "你从盒子中获得了练气法门,突破到凝气一层。", + "postEvent": "寿元提升到200年。", + "effect": { + "CHR": 3, + "INT": 3, + "STR": 3, + "SPR": 2 + }, + "include": "TLT?[1048]", + "exclude": "EVT?[10323]" + }, + "10324": { + "id": 10324, + "event": "练气。", + "postEvent": "体质提升。", + "effect": { + "STR": 1 + }, + "include": "TLT?[1048]", + "exclude": "EVT?[10333]" + }, + "10325": { + "id": 10325, + "event": "你突破到凝气二层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10323])&(STR>10)&(TLT?[1048])", + "exclude": "EVT?[10325]" + }, + "10326": { + "id": 10326, + "event": "你突破到凝气三层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10325])&(STR>12)&(TLT?[1048])", + "exclude": "EVT?[10326]" + }, + "10327": { + "id": 10327, + "event": "你突破到凝气四层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10326])&(STR>15)&(TLT?[1048])", + "exclude": "EVT?[10327]" + }, + "10328": { + "id": 10328, + "event": "你突破到凝气五层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10327])&(STR>20)&(TLT?[1048])", + "exclude": "EVT?[10328]" + }, + "10329": { + "id": 10329, + "event": "你突破到凝气六层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10328])&(STR>25)&(TLT?[1048])", + "exclude": "EVT?[10329]" + }, + "10330": { + "id": 10330, + "event": "你突破到凝气七层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10329])&(STR>30)&(TLT?[1048])", + "exclude": "EVT?[10330]" + }, + "10331": { + "id": 10331, + "event": "你突破到凝气八层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10330])&(STR>38)&(TLT?[1048])", + "exclude": "EVT?[10331]" + }, + "10332": { + "id": 10332, + "event": "你突破到凝气九层。", + "effect": { + "STR": 1 + }, + "include": "(EVT?[10331])&(STR>50)&(TLT?[1048])", + "exclude": "EVT?[10332]" + }, + "10333": { + "id": 10333, + "event": "你突破到筑基一层。", + "postEvent": "寿元提升到300年。", + "effect": { + "INT": 1, + "STR": 10 + }, + "include": "(EVT?[10332])&(STR>100)&(TLT?[1048])", + "exclude": "EVT?[10333]" + }, + "10334": { + "id": 10334, + "event": "你捡到异果,体质大幅提升。", + "effect": { + "STR": 10 + }, + "include": "TLT?[1048]" + }, + "10335": { + "id": 10335, + "event": "你发现灵气浓郁之处,体质大幅提升。", + "effect": { + "STR": 20 + }, + "include": "TLT?[1048]" + }, + "10336": { + "id": 10336, + "event": "锻体。", + "postEvent": "体质提升。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10333])&(STR>100)&(TLT?[1048])", + "exclude": "EVT?[10345,10361]" + }, + "10337": { + "id": 10337, + "event": "你突破到筑基二层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10333])&(STR>120)&(TLT?[1048])", + "exclude": "EVT?[10337]" + }, + "10338": { + "id": 10338, + "event": "你突破到筑基三层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10337])&(STR>140)&(TLT?[1048])", + "exclude": "EVT?[10338]" + }, + "10339": { + "id": 10339, + "event": "你突破到筑基四层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10338])&(STR>160)&(TLT?[1048])", + "exclude": "EVT?[10339]" + }, + "10340": { + "id": 10340, + "event": "你突破到筑基五层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10339])&(STR>190)&(TLT?[1048])", + "exclude": "EVT?[10340]" + }, + "10341": { + "id": 10341, + "event": "你突破到筑基六层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10340])&(STR>220)&(TLT?[1048])", + "exclude": "EVT?[10341]" + }, + "10342": { + "id": 10342, + "event": "你突破到筑基七层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10341])&(STR>250)&(TLT?[1048])", + "exclude": "EVT?[10342]" + }, + "10343": { + "id": 10343, + "event": "你突破到筑基八层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10342])&(STR>280)&(TLT?[1048])", + "exclude": "EVT?[10343]" + }, + "10344": { + "id": 10344, + "event": "你突破到筑基九层。", + "effect": { + "STR": 2 + }, + "include": "(EVT?[10343])&(STR>320)&(TLT?[1048])", + "exclude": "EVT?[10344]" + }, + "10345": { + "id": 10345, + "event": "你突破到金丹一层。", + "postEvent": "寿元提升到400年。", + "effect": { + "INT": 2, + "STR": 20 + }, + "include": "(EVT?[10344])&(STR>400)&(TLT?[1048])", + "exclude": "EVT?[10345,10361]" + }, + "10346": { + "id": 10346, + "event": "寿元终。", + "include": "TLT?[1048]", + "exclude": "EVT?[10333]", + "branch": [ + "TLT?[1048]:10000" + ] + }, + "10347": { + "id": 10347, + "event": "寿元终。", + "include": "TLT?[1048]", + "exclude": "EVT?[10345,10361]", + "branch": [ + "TLT?[1048]:10000" + ] + }, + "10348": { + "id": 10348, + "event": "你突破到金丹二层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])", + "exclude": "EVT?[10348]" + }, + "10349": { + "id": 10349, + "event": "图你美色,一个境界极高的人强行和你双修。", + "postEvent": "体质大幅提升。", + "effect": { + "STR": 100 + }, + "include": "(EVT?[10333])&(CHR>10)&(TLT?[1048])", + "exclude": "EVT?[10349]" + }, + "10350": { + "id": 10350, + "event": "你发现一种加快修行速度的方法。", + "postEvent": "体质大幅提升。", + "effect": { + "STR": 50 + }, + "include": "(EVT?[10333])&(INT>10)&(TLT?[1048])" + }, + "10351": { + "id": 10351, + "event": "周天经脉通畅,体质再次提升。", + "effect": { + "STR": 5 + }, + "include": "(EVT?[10333])&(STR>100)&(TLT?[1048])" + }, + "10352": { + "id": 10352, + "event": "你突破到金丹三层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10348])&(STR>500)&(INT>15)&(TLT?[1048])", + "exclude": "EVT?[10352]" + }, + "10353": { + "id": 10353, + "event": "你突破到金丹四层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10352])&(STR>550)&(INT>20)&(TLT?[1048])", + "exclude": "EVT?[10353]" + }, + "10354": { + "id": 10354, + "event": "你突破到金丹五层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10353])&(STR>600)&(INT>30)&(TLT?[1048])", + "exclude": "EVT?[10354]" + }, + "10355": { + "id": 10355, + "event": "你突破到金丹六层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10354])&(STR>650)&(INT>40)&(TLT?[1048])", + "exclude": "EVT?[10355]" + }, + "10356": { + "id": 10356, + "event": "你突破到金丹七层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10355])&(STR>700)&(INT>50)&(TLT?[1048])", + "exclude": "EVT?[10356]" + }, + "10357": { + "id": 10357, + "event": "你突破到金丹八层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10356])&(STR>750)&(INT>65)&(TLT?[1048])", + "exclude": "EVT?[10357]" + }, + "10358": { + "id": 10358, + "event": "你突破到金丹九层。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10357])&(STR>850)&(INT>80)&(TLT?[1048])", + "exclude": "EVT?[10358]" + }, + "10359": { + "id": 10359, + "event": "你遭到元婴大能截杀。", + "include": "TLT?[1048]", + "exclude": "EVT?[10359,10365]", + "branch": [ + "STR>1000:10360", + "STR<1000:10000" + ] + }, + "10360": { + "id": 10360, + "event": "你将其越级反杀。", + "postEvent": "得到大量宝物。属性提升。", + "effect": { + "INT": 50, + "STR": 500, + "SPR": 2 + }, + "NoRandom": 1 + }, + "10361": { + "id": 10361, + "event": "你服用了祖传药丸,突破到了金丹一层。", + "postEvent": "并且你有两枚金丹。寿元提升到500年。", + "effect": { + "INT": 50, + "STR": 500, + "SPR": 1 + }, + "include": "(EVT?[10344])&(TLT?[1048])&(TLT?[1065])", + "exclude": "EVT?[10361,10345]" + }, + "10362": { + "id": 10362, + "event": "蕴丹。", + "postEvent": "体质、智力提升。", + "effect": { + "INT": 1, + "STR": 3 + }, + "include": "(EVT?[10345,10361])&(STR>400)&(TLT?[1048])", + "exclude": "EVT?[10365]" + }, + "10363": { + "id": 10363, + "event": "你加入了一个隐世宗派成为长老。", + "postEvent": "得到大量修炼资源。", + "effect": { + "INT": 10, + "STR": 100 + }, + "include": "(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])", + "exclude": "EVT?[10363]" + }, + "10364": { + "id": 10364, + "event": "你斩杀了一个筑基修士,获得少量资源。", + "effect": { + "STR": 10 + }, + "include": "(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])" + }, + "10365": { + "id": 10365, + "event": "你突破到元婴一层。", + "postEvent": "寿元提升到500年。", + "effect": { + "INT": 30 + }, + "include": "(EVT?[10358])&(STR>1000)&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10365]" + }, + "10366": { + "id": 10366, + "event": "你斩杀了大量筑基修士,获得不少资源。", + "effect": { + "INT": 10, + "STR": 100 + }, + "include": "(EVT?[10345,10361])&(STR>450)&(INT>10)&(TLT?[1048])" + }, + "10367": { + "id": 10367, + "event": "悟道。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])" + }, + "10368": { + "id": 10368, + "event": "寿元终。", + "include": "TLT?[1048]", + "exclude": "EVT?[10365,10361]", + "branch": [ + "TLT?[1048]:10000" + ] + }, + "10369": { + "id": 10369, + "event": "你突破到元婴二层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10365])&(INT>150)&(TLT?[1048])", + "exclude": "EVT?[10369]" + }, + "10370": { + "id": 10370, + "event": "你突破到元婴三层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10369])&(INT>180)&(TLT?[1048])", + "exclude": "EVT?[10370]" + }, + "10371": { + "id": 10371, + "event": "你突破到元婴四层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10370])&(INT>210)&(TLT?[1048])", + "exclude": "EVT?[10371]" + }, + "10372": { + "id": 10372, + "event": "你突破到元婴五层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10371])&(INT>240)&(TLT?[1048])", + "exclude": "EVT?[10372]" + }, + "10373": { + "id": 10373, + "event": "你突破到元婴六层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10372])&(INT>280)&(TLT?[1048])", + "exclude": "EVT?[10373]" + }, + "10374": { + "id": 10374, + "event": "你突破到元婴七层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10373])&(INT>320)&(TLT?[1048])", + "exclude": "EVT?[10374]" + }, + "10375": { + "id": 10375, + "event": "你突破到元婴八层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10374])&(INT>360)&(TLT?[1048])", + "exclude": "EVT?[10375]" + }, + "10376": { + "id": 10376, + "event": "你突破到元婴九层。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[10375])&(INT>400)&(TLT?[1048])", + "exclude": "EVT?[10376]" + }, + "10377": { + "id": 10377, + "event": "你突破到渡劫期。", + "effect": { + "INT": 10, + "STR": 10 + }, + "include": "(EVT?[10375])&(INT>500)&(TLT?[1048])", + "exclude": "EVT?[10377]" + }, + "10378": { + "id": 10378, + "event": "准备渡劫。", + "effect": { + "INT": 1, + "STR": 10 + }, + "include": "(EVT?[10377])&(INT>500)&(TLT?[1048])", + "exclude": "EVT?[10378]" + }, + "10379": { + "id": 10379, + "event": "寿元终。", + "include": "TLT?[1048]", + "exclude": "EVT?[10377]", + "branch": [ + "TLT?[1048]:10000" + ] + }, + "10380": { + "id": 10380, + "event": "你悟出水之大道。", + "effect": { + "INT": 20, + "STR": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10380]" + }, + "10381": { + "id": 10381, + "event": "你悟出火之大道。", + "effect": { + "INT": 20, + "STR": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10381]" + }, + "10382": { + "id": 10382, + "event": "你悟出金之大道。", + "effect": { + "INT": 20, + "STR": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10382]" + }, + "10383": { + "id": 10383, + "event": "你悟出木之大道。", + "effect": { + "INT": 20, + "STR": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10383]" + }, + "10384": { + "id": 10384, + "event": "你悟出土之大道。", + "effect": { + "INT": 20, + "STR": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])", + "exclude": "EVT?[10384]" + }, + "10385": { + "id": 10385, + "event": "你进入顿悟状态。", + "effect": { + "INT": 20 + }, + "include": "(EVT?[10365])&(INT>100)&(TLT?[1048])" + }, + "10386": { + "id": 10386, + "event": "你悟出了空间大道。", + "effect": { + "INT": 50, + "STR": 50 + }, + "include": "(EVT?[10365])&(INT>300)&(TLT?[1048])", + "exclude": "EVT?[10386]" + }, + "10387": { + "id": 10387, + "event": "你悟出了时间大道。", + "effect": { + "INT": 50, + "STR": 50 + }, + "include": "(EVT?[10365])&(INT>300)&(TLT?[1048])", + "exclude": "EVT?[10387]" + }, + "10388": { + "id": 10388, + "event": "你悟出了混沌大道。", + "effect": { + "INT": 50, + "STR": 50 + }, + "include": "(EVT?[10365])&(INT>300)&(TLT?[1048])", + "exclude": "EVT?[10388]" + }, + "10389": { + "id": 10389, + "event": "你悟出了生命大道。", + "effect": { + "INT": 50, + "STR": 50 + }, + "include": "(EVT?[10365])&(INT>300)&(TLT?[1048])", + "exclude": "EVT?[10389]" + }, + "10390": { + "id": 10390, + "event": "你悟出了毁灭大道。", + "effect": { + "INT": 50, + "STR": 50 + }, + "include": "(EVT?[10365])&(INT>300)&(TLT?[1048])", + "exclude": "EVT?[10390]" + }, + "10391": { + "id": 10391, + "event": "开始渡劫。九重雷劫开始。", + "include": "EVT?[10377]", + "branch": [ + "EVT?[10377]:10392" + ] + }, + "10392": { + "id": 10392, + "event": "第一重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1100:10393", + "(STR<1101)&(TLT?[1134]):20409", + "STR<1101:10000" + ] + }, + "10393": { + "id": 10393, + "event": "第二重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1200:10394", + "(STR<1201)&(TLT?[1134]):20409", + "STR<1201:10000" + ] + }, + "10394": { + "id": 10394, + "event": "第三重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1300:10395", + "(STR<1301)&(TLT?[1134]):20409", + "STR<1301:10000" + ] + }, + "10395": { + "id": 10395, + "event": "第四重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1400:10396", + "(STR<1401)&(TLT?[1134]):20409", + "STR<1401:10000" + ] + }, + "10396": { + "id": 10396, + "event": "第五重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1500:10397", + "(STR<1501)&(TLT?[1134]):20409", + "STR<1501:10000" + ] + }, + "10397": { + "id": 10397, + "event": "第六重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1600:10398", + "(STR<1601)&(TLT?[1134]):20409", + "STR<1601:10000" + ] + }, + "10398": { + "id": 10398, + "event": "第七重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1700:10399", + "(STR<1701)&(TLT?[1134]):20409", + "STR<1701:10000" + ] + }, + "10399": { + "id": 10399, + "event": "第八重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>1800:10400", + "(STR<1801)&(TLT?[1134]):20409", + "STR<1801:10000" + ] + }, + "10400": { + "id": 10400, + "event": "第九重雷劫落下。", + "NoRandom": 1, + "branch": [ + "STR>2000:10401", + "(STR<2001)&(TLT?[1134]):20409", + "STR<2001:10000" + ] + }, + "10401": { + "id": 10401, + "event": "雷劫度过,元神劫开始。", + "NoRandom": 1, + "branch": [ + "EVT?[10377]:10402" + ] + }, + "10402": { + "id": 10402, + "event": "金之元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10382,20367]:10403", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10403": { + "id": 10403, + "event": "木之元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10383,20367]:10404", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10404": { + "id": 10404, + "event": "水之元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10380,20367]:10405", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10405": { + "id": 10405, + "event": "火之元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10381,20367]:10406", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10406": { + "id": 10406, + "event": "土之元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10384,20367]:10407", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10407": { + "id": 10407, + "event": "本源元神劫落下。", + "NoRandom": 1, + "branch": [ + "EVT?[10386,10387,10388,10389,10390,20367]:10408", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10408": { + "id": 10408, + "event": "心魔劫降临。", + "NoRandom": 1, + "branch": [ + "SPR>10:10409", + "(EVT?[10377])&(TLT?[1134]):20409", + "EVT?[10377]:10000" + ] + }, + "10409": { + "id": 10409, + "event": "渡劫成功!你飞升到仙界了。", + "postEvent": "你作为“人”的人生结束了。", + "effect": { + "LIF": -1 + }, + "NoRandom": 1 + }, + "10410": { + "id": 10410, + "event": "你成为了动漫高手,经常在网上骂战。", + "include": "EVT?[10189]", + "exclude": "(EVT?[10410,10002])|(TLT?[1014])", + "branch": [ + "STR>5:20410", + "INT<6:20411" + ] + }, + "10411": { + "id": 10411, + "event": "你开始追星。", + "include": "MNY<8", + "exclude": "EVT?[10411,10413]", + "branch": [ + "STR>6:20412", + "INT<4:20413" + ] + }, + "10412": { + "id": 10412, + "event": "你有了第一部自己的手机。", + "include": "(MNY>3)&(EVT?[10009])", + "exclude": "(MNY>7)|(EVT?[10412])" + }, + "10413": { + "id": 10413, + "event": "某外籍知名明星因强奸罪被抓。", + "include": "EVT?[10009]", + "exclude": "EVT?[10413,20413]", + "branch": [ + "INT<4:20414" + ] + }, + "10414": { + "id": 10414, + "event": "附近开始流行肺炎,你在家中不敢出门。", + "include": "EVT?[10009]", + "exclude": "EVT?[10414]" + }, + "10415": { + "id": 10415, + "event": "高考改革,英语被取消了。", + "include": "EVT?[10009]", + "exclude": "EVT?[10415]", + "branch": [ + "(EVT?[10237,10238,10239])&(INT<8):20415" + ] + }, + "10416": { + "id": 10416, + "event": "高考改革,新增了中特社作为必考科目。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10416]" + }, + "10417": { + "id": 10417, + "event": "体育总局新规定,体测成绩必须100米跑进10秒才及格。", + "include": "EVT?[10009]", + "exclude": "EVT?[10417]", + "branch": [ + "STR>9:20417" + ] + }, + "10418": { + "id": 10418, + "event": "塔利班组织占领华盛顿。", + "include": "EVT?[10009]", + "exclude": "EVT?[10418]", + "branch": [ + "INT<2:20418" + ] + }, + "10419": { + "id": 10419, + "event": "本·拉登复出,发视频称当年是假死。", + "include": "EVT?[10009]", + "exclude": "EVT?[10419]", + "branch": [ + "INT<2:20419" + ] + }, + "10420": { + "id": 10420, + "event": "希特勒的遗骨被发现。", + "include": "EVT?[10009]", + "exclude": "EVT?[10420]" + }, + "10421": { + "id": 10421, + "event": "爱因斯坦失窃的部分大脑标本被追回。", + "include": "EVT?[10009]", + "exclude": "EVT?[10421]", + "branch": [ + "(INT<4)&(MNY>8):20421" + ] + }, + "10422": { + "id": 10422, + "event": "据说有人在深山里发现了古装的居民。官方通报是在拍电视剧。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10422]", + "branch": [ + "INT>8:20422" + ] + }, + "10423": { + "id": 10423, + "event": "隔壁城市发生特大交通事故,数十人伤亡。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10423]", + "branch": [ + "(CHR>8)|(MNY>8):20423" + ] + }, + "10424": { + "id": 10424, + "event": "日本发生8.0级地震。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10424,10425]", + "branch": [ + "SPR>9:20425" + ] + }, + "10425": { + "id": 10425, + "event": "日本发生9.0级地震。", + "include": "EVT?[10009]", + "exclude": "EVT?[10425,10424]", + "branch": [ + "SPR>7:20425" + ] + }, + "10426": { + "id": 10426, + "event": "中国大陆收复台湾。", + "include": "EVT?[10009]", + "exclude": "EVT?[10426]", + "branch": [ + "(CHR>8)&(MNY>8):20426" + ] + }, + "10427": { + "id": 10427, + "event": "清华北大合并为清北大学。", + "include": "EVT?[10009]", + "exclude": "EVT?[10427]" + }, + "10428": { + "id": 10428, + "event": "南京大学和同济大学合并为南同大学。", + "include": "EVT?[10009]", + "exclude": "EVT?[10428,10429]" + }, + "10429": { + "id": 10429, + "event": "南京大学和东南大学合并为京东大学。", + "include": "EVT?[10009]", + "exclude": "EVT?[10429,10428]" + }, + "10430": { + "id": 10430, + "event": "VR技术突破,用户可以意识进入虚拟空间。目前该技术还未进入民用。", + "include": "EVT?[10009]", + "exclude": "EVT?[10430]", + "branch": [ + "INT>9:20431" + ] + }, + "10431": { + "id": 10431, + "event": "游哈米发布次时代手游大作《神原》。", + "include": "EVT?[10009]", + "exclude": "EVT?[10431]", + "branch": [ + "MNY>6:20432" + ] + }, + "10432": { + "id": 10432, + "event": "腾讯收购网易。", + "include": "EVT?[10009]", + "exclude": "EVT?[10432]", + "branch": [ + "SPR>7:20433" + ] + }, + "10433": { + "id": 10433, + "event": "拼多多收购阿里巴巴。", + "include": "EVT?[10009]", + "exclude": "EVT?[10433]" + }, + "10434": { + "id": 10434, + "event": "字节跳动市值超过微软。", + "include": "EVT?[10009]", + "exclude": "EVT?[10434]" + }, + "10435": { + "id": 10435, + "event": "你和网民争论兰博基尼和法拉利哪个档次高。", + "include": "EVT?[10009]", + "exclude": "EVT?[10435,10002]" + }, + "10436": { + "id": 10436, + "event": "中国开放十八胎生育。", + "include": "EVT?[10009]", + "exclude": "EVT?[10436]", + "branch": [ + "EVT![10268,10269,10272]:20436" + ] + }, + "10437": { + "id": 10437, + "event": "全球新冠确诊病例首次清零。", + "include": "EVT?[10009]", + "exclude": "EVT?[10437]", + "branch": [ + "STR>2:20437" + ] + }, + "10438": { + "id": 10438, + "event": "曹县成功申办2066年奥运会。", + "include": "EVT?[10009]", + "exclude": "EVT?[10438]" + }, + "10439": { + "id": 10439, + "event": "日本武力攻占珍珠港。", + "include": "EVT?[10009]", + "exclude": "EVT?[10439]" + }, + "10440": { + "id": 10440, + "event": "朝鲜计划向美国和韩国投下两颗原子弹。", + "postEvent": "计划败露。", + "include": "EVT?[10009]", + "exclude": "EVT?[10440]" + }, + "10441": { + "id": 10441, + "event": "芜湖机场世界排名升至第一。", + "include": "EVT?[10009]", + "exclude": "EVT?[10441]" + }, + "10442": { + "id": 10442, + "event": "蚌埠房价一年内翻倍,国家出手调控。", + "include": "EVT?[10009]", + "exclude": "EVT?[10442]" + }, + "10443": { + "id": 10443, + "event": "我国两极分化迅速减小,人民幸福指数进一步提高。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10443]", + "branch": [ + "(MNY<4)&(SPR<4):20443" + ] + }, + "10444": { + "id": 10444, + "event": "中国GDP超过美国。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10444]", + "branch": [ + "MNY<3:20444" + ] + }, + "10445": { + "id": 10445, + "event": "江苏省省会改为苏州。", + "include": "EVT?[10009]", + "exclude": "EVT?[10445]" + }, + "10446": { + "id": 10446, + "event": "英国和法国断交。", + "include": "EVT?[10009]", + "exclude": "EVT?[10446]" + }, + "10447": { + "id": 10447, + "event": "中国当前首富被爆是美国间谍,在机场被抓获。", + "include": "EVT?[10009]", + "exclude": "EVT?[10447]" + }, + "10448": { + "id": 10448, + "event": "国家公布中产阶级标准:家庭年收入100万。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10448]", + "branch": [ + "MNY<4:20448" + ] + }, + "10449": { + "id": 10449, + "event": "海底火山爆发,马里亚纳海沟被填平。", + "include": "EVT?[10009]", + "exclude": "EVT?[10449]" + }, + "10450": { + "id": 10450, + "event": "上海数十名小学生春游,成功登顶珠穆朗玛峰。", + "include": "EVT?[10009]", + "exclude": "EVT?[10450]" + }, + "10451": { + "id": 10451, + "event": "北京一本录取率首次超过99%。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10451]", + "branch": [ + "(MNY<4)&(TLT![1010]):20452" + ] + }, + "10452": { + "id": 10452, + "event": "特朗普再度当选美国总统。", + "include": "EVT?[10009]", + "exclude": "EVT?[10452]", + "branch": [ + "(SPR>6)&(INT>2):20453" + ] + }, + "10453": { + "id": 10453, + "event": "拜登遭到暗杀。", + "include": "EVT?[10009]", + "exclude": "EVT?[10453]" + }, + "10454": { + "id": 10454, + "event": "云南发现一种红白斑点蘑菇,吃了可以变大。", + "include": "EVT?[10009]", + "exclude": "EVT?[10454]", + "branch": [ + "EVT?[10188,10194]:20454" + ] + }, + "10455": { + "id": 10455, + "event": "医学奇迹,全球首例断头重生手术成功。", + "include": "EVT?[10009]", + "exclude": "EVT?[10455]" + }, + "10456": { + "id": 10456, + "event": "女女生育技术取得重大突破。", + "include": "EVT?[10009]", + "exclude": "EVT?[10456]", + "branch": [ + "(EVT?[10007,10008])&(TLT![1026]):20456" + ] + }, + "10457": { + "id": 10457, + "event": "科学家宣布,人类Y染色体再过500年就会灭亡。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10457]" + }, + "10458": { + "id": 10458, + "event": "有个乞丐向你推销“仙法”秘籍,你没有搭理他。", + "include": "EVT?[10009]", + "exclude": "EVT?[10458]" + }, + "10459": { + "id": 10459, + "event": "最新研究显示,人类的寿命极限是500岁。", + "include": "EVT?[10009,10010]", + "exclude": "EVT?[10459]", + "branch": [ + "INT<4:20459" + ] + }, + "10460": { + "id": 10460, + "event": "美国宣布进入社会主义社会。", + "include": "EVT?[10009]", + "exclude": "EVT?[10460]", + "branch": [ + "SPR>6:20460" + ] + }, + "10461": { + "id": 10461, + "event": "奥运会在安徽省会南京成功举办。", + "include": "EVT?[10009]", + "exclude": "EVT?[10461]" + }, + "10462": { + "id": 10462, + "event": "你被门夹伤了手。", + "include": "EVT?[10009]", + "exclude": "EVT?[10462]" + }, + "10463": { + "id": 10463, + "event": "你不小心摔了一跤,磕掉了一颗牙。", + "include": "EVT?[10009]" + }, + "10464": { + "id": 10464, + "event": "你在购物时中了个四等奖:一包纸巾。", + "include": "EVT?[10009]", + "exclude": "EVT?[10464,10465,10466,10467]" + }, + "10465": { + "id": 10465, + "event": "你在购物时中了个三等奖:一个电饭锅。", + "include": "EVT?[10009]", + "exclude": "EVT?[10464,10465,10466,10467]" + }, + "10466": { + "id": 10466, + "event": "你在购物时中了个二等奖:一个电冰箱。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10464,10465,10466,10467]" + }, + "10467": { + "id": 10467, + "event": "你在购物时中了个一等奖:三亚七日游。", + "postEvent": "你快乐地游玩了一个冬天。", + "effect": { + "SPR": 2 + }, + "include": "EVT?[10009]", + "exclude": "EVT?[10464,10465,10466,10467]" + }, + "10468": { + "id": 10468, + "event": "你进入流水线工厂工作。", + "include": "EVT?[10237,10025,10156,10155,10198]", + "exclude": "EVT?[10475,10476,10477,10226,10468]" + }, + "10469": { + "id": 10469, + "event": "每天重复的加工十分无聊。", + "include": "EVT?[10468]", + "exclude": "EVT?[10469,10473,10226]" + }, + "10470": { + "id": 10470, + "event": "员工宿舍十几个人挤在一间。", + "include": "EVT?[10468]", + "exclude": "EVT?[10470,10473,10226]" + }, + "10471": { + "id": 10471, + "event": "你工作攒下了一点钱。", + "include": "EVT?[10468]", + "exclude": "EVT?[10471,10473,10226]" + }, + "10472": { + "id": 10472, + "event": "你加工零件非常熟练了。", + "include": "EVT?[10468]", + "exclude": "EVT?[10472,10473,10226]" + }, + "10473": { + "id": 10473, + "event": "工厂倒闭了,厂长带着小姨子跑了。", + "postEvent": "你失业了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10468]", + "exclude": "EVT?[10473,10226]" + }, + "10474": { + "id": 10474, + "event": "你四处求职,但因为太丑而找不到工作。", + "include": "(CHR<3)&(EVT?[10237,10238,10239,10198,10199,10200])", + "exclude": "EVT?[10226,10468,10202,10259,10191,10475,10476,10477]" + }, + "10475": { + "id": 10475, + "event": "你大学毕业后回村当了老师。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10475,10476,10477,10468]" + }, + "10476": { + "id": 10476, + "event": "你大学毕业后回村当了护士。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10476,10001,10475,10477,10468]" + }, + "10477": { + "id": 10477, + "event": "你大学毕业后回村当了医生。", + "include": "EVT?[10237,10238,10239]", + "exclude": "EVT?[10477,10475,10476,10468]" + }, + "10478": { + "id": 10478, + "event": "在乡下工作的一个好处是,没有城市里那么繁忙。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10478]" + }, + "10479": { + "id": 10479, + "event": "你的工资虽然不高,但这份工作你挺喜欢的。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10479,10490]" + }, + "10480": { + "id": 10480, + "event": "孩子们很难教,基础太差了。", + "include": "EVT?[10475]", + "exclude": "EVT?[10480]" + }, + "10481": { + "id": 10481, + "event": "你现在很受村民们尊重。", + "include": "(CHR>6)&(EVT?[10475,10477])", + "exclude": "EVT?[10481,10484]" + }, + "10482": { + "id": 10482, + "event": "有的病人很迷信,不听你的话。", + "include": "EVT?[10476,10477]", + "exclude": "EVT?[10482]" + }, + "10483": { + "id": 10483, + "event": "有个村民被车撞了,你连夜为他做手术。", + "include": "EVT?[10477]", + "exclude": "EVT?[10483]" + }, + "10484": { + "id": 10484, + "event": "你遭到了村民的调戏。", + "include": "EVT?[10476]", + "exclude": "EVT?[10484,10481]" + }, + "10485": { + "id": 10485, + "event": "开家长会,但来的基本都是学生的祖辈,很少有父母来。", + "include": "EVT?[10475]", + "exclude": "EVT?[10485]" + }, + "10486": { + "id": 10486, + "event": "你出了套试卷,全班学生没有一个及格。", + "include": "EVT?[10475]", + "exclude": "EVT?[10486]" + }, + "10487": { + "id": 10487, + "event": "工作顺利的一年,没发生什么大事。", + "include": "EVT?[10475,10476,10477]" + }, + "10488": { + "id": 10488, + "event": "像你一样返乡工作的大学生越来越少了。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10488]" + }, + "10489": { + "id": 10489, + "event": "村里基本只有老人和孩子。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10489]" + }, + "10490": { + "id": 10490, + "event": "你对人生有些迷茫。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10490]" + }, + "10491": { + "id": 10491, + "event": "工作的闲暇时,你会看看动漫。", + "include": "(EVT?[10475,10476,10477])&(EVT?[10007,10008])" + }, + "10492": { + "id": 10492, + "event": "你退休了。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10492,10001]" + }, + "10493": { + "id": 10493, + "event": "你退休了。", + "include": "EVT?[10475,10476,10477]", + "exclude": "EVT?[10492,10002]" + }, + "10494": { + "id": 10494, + "event": "体质过低,胎死腹中。", + "include": "STR<0", + "exclude": "TLT?[1071]", + "branch": [ + "STR<0:10000" + ] + }, + "10495": { + "id": 10495, + "event": "意外发现古代宗派遗宝。", + "effect": { + "INT": 1, + "STR": 10, + "SPR": 1 + }, + "include": "TLT?[1048]", + "exclude": "EVT?[10495]" + }, + "10496": { + "id": 10496, + "event": "偶遇筑基期散修。", + "postEvent": "他无视了你。", + "include": "TLT?[1048]", + "exclude": "EVT?[10496]", + "branch": [ + "CHR<5:10497" + ] + }, + "10497": { + "id": 10497, + "event": "他嫌你长得丑,把你杀了。", + "NoRandom": 1, + "branch": [ + "CHR<5:10000" + ] + }, + "10498": { + "id": 10498, + "event": "父母经常带你去附近的公园和大学校园玩。", + "include": "(MNY>3)&(EVT?[10011])", + "exclude": "EVT?[10498]" + }, + "10499": { + "id": 10499, + "event": "你喜欢在图书馆的儿童区和别的小朋友一起玩。", + "include": "(MNY>3)&(EVT?[10011])", + "exclude": "EVT?[10499]" + }, + "10500": { + "id": 10500, + "event": "父母同时教你英语和汉语。", + "include": "EVT?[10011]", + "exclude": "EVT?[10500]" + }, + "10501": { + "id": 10501, + "event": "父母开始用照片和日记记录下你的点点滴滴。", + "include": "EVT?[10011]", + "exclude": "EVT?[10501]" + }, + "10502": { + "id": 10502, + "event": "家里很有钱,父母所有东西都为你准备最好的。", + "include": "(MNY>7)&(EVT?[10011])", + "exclude": "EVT?[10502]" + }, + "10503": { + "id": 10503, + "event": "家里很穷,但父母尽力为你准备更好的生活。", + "include": "(MNY<4)&(EVT?[10011])", + "exclude": "EVT?[10503]" + }, + "10504": { + "id": 10504, + "event": "你开始上幼儿园。", + "include": "(MNY>3)&(EVT?[10011])", + "exclude": "EVT?[10504]" + }, + "10505": { + "id": 10505, + "event": "你上不起幼儿园,父母开始教你学习。", + "include": "(MNY<4)&(EVT?[10011])", + "exclude": "EVT?[10505]" + }, + "10506": { + "id": 10506, + "event": "你每天和小朋友、老师们玩游戏、做手工、唱歌跳舞。", + "include": "EVT?[10504]", + "exclude": "EVT?[10506]" + }, + "10507": { + "id": 10507, + "event": "父母给你买了一书架的启蒙童书。", + "include": "EVT?[10504]", + "exclude": "EVT?[10507]" + }, + "10508": { + "id": 10508, + "event": "每周一次的看动画片时间是你的最爱。", + "include": "EVT?[10011]", + "exclude": "EVT?[10508]" + }, + "10509": { + "id": 10509, + "event": "你的父母请了家教来教你游泳。", + "include": "EVT?[10504]", + "exclude": "EVT?[10509]" + }, + "10510": { + "id": 10510, + "event": "你的父母请了家教来教你弹钢琴。", + "include": "EVT?[10504]", + "exclude": "EVT?[10510]" + }, + "10511": { + "id": 10511, + "event": "你的父母请了家教来教你法语。", + "include": "EVT?[10504]", + "exclude": "EVT?[10511,10512]" + }, + "10512": { + "id": 10512, + "event": "你的父母请了家教来教你西班牙语。", + "include": "EVT?[10504]", + "exclude": "EVT?[10511,10512]" + }, + "10513": { + "id": 10513, + "event": "你平时很少出门,因为父母说外面很危险。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10513]" + }, + "10514": { + "id": 10514, + "event": "附近发生了一起枪击案。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10514]" + }, + "10515": { + "id": 10515, + "event": "父母说要好好学习,考上好大学离开这里。", + "include": "EVT?[10505]", + "exclude": "EVT?[10515]" + }, + "10516": { + "id": 10516, + "event": "你比同龄人学了更多的知识。", + "effect": { + "INT": 1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10516]" + }, + "10517": { + "id": 10517, + "event": "你的父亲在地铁上被暴徒攻击,受了伤。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10517]" + }, + "10518": { + "id": 10518, + "event": "你开始上小学了。", + "include": "EVT?[10011]", + "exclude": "EVT?[10518]" + }, + "10519": { + "id": 10519, + "event": "你比其他同学更聪明,学得更快懂得更多。", + "postEvent": "老师很喜欢你。", + "include": "(INT>5)&(EVT?[10011])", + "exclude": "EVT?[10519]" + }, + "10520": { + "id": 10520, + "event": "虽然你是亚裔,但你没有感觉有什么不同。", + "include": "EVT?[10504]", + "exclude": "EVT?[10520]" + }, + "10521": { + "id": 10521, + "event": "有好几个小朋友向你表白。", + "effect": { + "SPR": 1 + }, + "include": "(CHR>6)&(EVT?[10011])", + "exclude": "EVT?[10521]" + }, + "10522": { + "id": 10522, + "event": "班上的几个非裔同学经常欺负你。", + "effect": { + "SPR": -1 + }, + "include": "(STR<7)&(CHR<7)&(EVT?[10505])", + "exclude": "(EVT?[10522])|(TLT![1037])" + }, + "10523": { + "id": 10523, + "event": "你在家中主要用中文交流,在学校都用英文。", + "include": "EVT?[10011]", + "exclude": "EVT?[10523]" + }, + "10524": { + "id": 10524, + "event": "你的运动很棒,同学们都很崇拜你。", + "effect": { + "SPR": 1 + }, + "include": "(STR>7)&(EVT?[10011])", + "exclude": "EVT?[10524]" + }, + "10525": { + "id": 10525, + "event": "因为你的成绩最好,老师允许你躺在班上的秋千椅上听课。", + "effect": { + "SPR": 1 + }, + "include": "(INT>6)&(EVT?[10504])", + "exclude": "EVT?[10525]" + }, + "10526": { + "id": 10526, + "event": "课堂上经常做小实验。", + "include": "EVT?[10011]", + "exclude": "EVT?[10526]" + }, + "10527": { + "id": 10527, + "event": "有次整整一天,老师带你们出去观察昆虫。", + "include": "EVT?[10504]", + "exclude": "EVT?[10527]" + }, + "10528": { + "id": 10528, + "event": "老师夸你的数学和科学知识已经不比中学生差了。", + "effect": { + "SPR": 1 + }, + "include": "(INT>6)&(EVT?[10011])", + "exclude": "EVT?[10528]" + }, + "10529": { + "id": 10529, + "event": "学校举办唱歌比赛。", + "include": "EVT?[10011]", + "exclude": "EVT?[10529]", + "branch": [ + "EVT?[10049]:20529" + ] + }, + "10530": { + "id": 10530, + "event": "在学校经常运动,身体越来越棒。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10011]", + "exclude": "EVT?[10530,10531]" + }, + "10531": { + "id": 10531, + "event": "在学校经常运动,身体越来越棒。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10011]", + "exclude": "EVT?[10530,10531]" + }, + "10532": { + "id": 10532, + "event": "班上没有几个白人同学,而会说汉语的有好几个。", + "include": "EVT?[10505]", + "exclude": "EVT?[10532]" + }, + "10533": { + "id": 10533, + "event": "班上有个男孩欺负一个女孩,你勇敢站出来制止了他。", + "include": "(STR>4)&(EVT?[10504])", + "exclude": "EVT?[10533]" + }, + "10534": { + "id": 10534, + "event": "有两个学生在班上抽烟,但老师不敢管。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10534]", + "branch": [ + "TLT?[1108]:20534" + ] + }, + "10535": { + "id": 10535, + "event": "你们班里又转来一个中国学生。", + "include": "EVT?[10011]", + "exclude": "EVT?[10535]" + }, + "10536": { + "id": 10536, + "event": "父母的事业非常成功,家境变得更好了。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10504]", + "exclude": "EVT?[10536]" + }, + "10537": { + "id": 10537, + "event": "父母的事业取得了一定成功,家境有所好转。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10505]", + "exclude": "EVT?[10537]" + }, + "10538": { + "id": 10538, + "event": "老师教你们操作电脑,但你早就会了。", + "include": "EVT?[10504]", + "exclude": "EVT?[10538]" + }, + "10539": { + "id": 10539, + "event": "老师有时会带来一大堆零食,分给所有同学。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10011]", + "exclude": "EVT?[10539]" + }, + "10540": { + "id": 10540, + "event": "你们把座位布置成了法庭,举行了一场模拟辩论。", + "include": "EVT?[10011]", + "exclude": "EVT?[10540]" + }, + "10541": { + "id": 10541, + "event": "你上了一个著名的贵族中学。", + "include": "(MNY>7)&(EVT?[10011])", + "exclude": "EVT?[10541]" + }, + "10542": { + "id": 10542, + "event": "你上了一个普通的中学。", + "include": "(MNY<8)&(EVT?[10011])", + "exclude": "EVT?[10542]" + }, + "10543": { + "id": 10543, + "event": "你的课业很重,学校里的活动也很多,生活非常充实。", + "include": "EVT?[10541]", + "exclude": "EVT?[10543]" + }, + "10544": { + "id": 10544, + "event": "课业很轻松,几乎没有作业,每天下午放学就有各种活动。", + "include": "EVT?[10542]", + "exclude": "EVT?[10544]" + }, + "10545": { + "id": 10545, + "event": "你很喜欢放学或周末在学校玩滑雪和曲棍球。", + "effect": { + "STR": 1 + }, + "include": "(STR>2)&(EVT?[10541])", + "exclude": "EVT?[10545]" + }, + "10546": { + "id": 10546, + "event": "你在学校学会了骑马和高尔夫。", + "effect": { + "STR": 1 + }, + "include": "(INT>2)&(STR>2)&(EVT?[10541])", + "exclude": "EVT?[10546]" + }, + "10547": { + "id": 10547, + "event": "你中午经常在图书馆和另外两个华裔同学一起学习。", + "include": "EVT?[10541]", + "exclude": "EVT?[10547]" + }, + "10548": { + "id": 10548, + "event": "你的同班同学中有著名明星的女儿、著名银行家的小儿子。", + "include": "EVT?[10541]", + "exclude": "EVT?[10548,10549,10550]" + }, + "10549": { + "id": 10549, + "event": "你的同班同学中有著名球星的儿子。", + "include": "EVT?[10541]", + "exclude": "EVT?[10548,10549,10550]" + }, + "10550": { + "id": 10550, + "event": "你的同班同学中有著名政客的女儿和某小国皇室的王子。", + "include": "EVT?[10541]", + "exclude": "EVT?[10548,10549,10550]" + }, + "10551": { + "id": 10551, + "event": "虽然课余活动很丰富,不过同学们学习都很认真。", + "include": "EVT?[10541]", + "exclude": "EVT?[10551]" + }, + "10552": { + "id": 10552, + "event": "学校组织了一场去欧洲的旅行。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10541]", + "exclude": "EVT?[10552]" + }, + "10553": { + "id": 10553, + "event": "你参演了一场戏剧演出。", + "include": "EVT?[10011]", + "exclude": "EVT?[10553]" + }, + "10554": { + "id": 10554, + "event": "同学们大多自信幽默大方,平易近人。你和他们相处融洽。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10541]", + "exclude": "EVT?[10554]" + }, + "10555": { + "id": 10555, + "event": "回到家父母会给你额外的学习任务。", + "effect": { + "INT": 1, + "SPR": -1 + }, + "include": "EVT?[10011]", + "exclude": "EVT?[10555]" + }, + "10556": { + "id": 10556, + "event": "你家的扫地机器人坏了,你自己制作了一个。", + "include": "(MNY>2)&(INT>7)&(EVT?[10011])", + "exclude": "EVT?[10556]" + }, + "10557": { + "id": 10557, + "event": "你经常晚上去学校天文台用望远镜看星星。", + "include": "EVT?[10011]", + "exclude": "EVT?[10557]", + "branch": [ + "MNY>7:20557" + ] + }, + "10558": { + "id": 10558, + "event": "你参加了学校的舞会。", + "include": "EVT?[10011]", + "exclude": "EVT?[10558]", + "branch": [ + "CHR>7:20558" + ] + }, + "10559": { + "id": 10559, + "event": "很多同学找你求交往。", + "include": "EVT?[20558]", + "exclude": "EVT?[10559]" + }, + "10560": { + "id": 10560, + "event": "不少同学找你求交往。", + "include": "(TLT?[1028])&(EVT?[10011])", + "exclude": "EVT?[10560]" + }, + "10561": { + "id": 10561, + "event": "你谈了一个女朋友。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10011])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10561])|(TLT?[1027])" + }, + "10562": { + "id": 10562, + "event": "你谈了一个男朋友。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10011])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10562])|(TLT?[1027])" + }, + "10563": { + "id": 10563, + "event": "学校生活很快乐,每天大多数时间都在玩。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10542]", + "exclude": "EVT?[10563]" + }, + "10564": { + "id": 10564, + "event": "一个从中国转学来的同学说,这里的考试比中国简单多了。", + "include": "EVT?[10542]", + "exclude": "EVT?[10564]" + }, + "10565": { + "id": 10565, + "event": "学校举办为期一学期的模拟创业活动。", + "include": "EVT?[10011]", + "exclude": "EVT?[10565]", + "branch": [ + "(MNY>7)&(INT>7):20565" + ] + }, + "10566": { + "id": 10566, + "event": "美国总统来你们学校演讲。", + "include": "EVT?[10541]", + "exclude": "EVT?[10566]" + }, + "10567": { + "id": 10567, + "event": "你们学校新开设了保龄球选修课。", + "include": "EVT?[10011]", + "exclude": "EVT?[10567]" + }, + "10568": { + "id": 10568, + "event": "这次期末考试很难。", + "postEvent": "你考得一般。", + "include": "EVT?[10541]", + "exclude": "EVT?[10568]", + "branch": [ + "INT<3:20568", + "INT>8:20569" + ] + }, + "10569": { + "id": 10569, + "event": "你在学校选修了日语。", + "include": "(EVT?[10011])&(EVT?[10007,10008])", + "exclude": "EVT?[10569]" + }, + "10570": { + "id": 10570, + "event": "教室里有个浴缸,经常有同学躺在浴缸里听课。", + "include": "EVT?[10542]", + "exclude": "EVT?[10570]" + }, + "10571": { + "id": 10571, + "event": "美术和音乐教室里的地毯非常好看。", + "include": "EVT?[10542]", + "exclude": "EVT?[10571]" + }, + "10572": { + "id": 10572, + "event": "学校要求每个同学自带平板电脑。", + "include": "EVT?[10542]", + "exclude": "EVT?[10572]", + "branch": [ + "MNY<3:20572" + ] + }, + "10573": { + "id": 10573, + "event": "教室里有很多金鱼,每人都认养了一只。", + "include": "EVT?[10542]", + "exclude": "EVT?[10573]" + }, + "10574": { + "id": 10574, + "event": "你父母拿了份中国中考数学卷给你做。", + "postEvent": "你觉得有些难。", + "include": "EVT?[10011]", + "exclude": "EVT?[10574]", + "branch": [ + "INT<7:20574", + "INT>8:20575" + ] + }, + "10575": { + "id": 10575, + "event": "据说附近发生了一起枪击案。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10542]", + "exclude": "EVT?[10575]", + "branch": [ + "TLT?[1108]:20575" + ] + }, + "10576": { + "id": 10576, + "event": "你在上学路上遭遇了枪击。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10505]", + "exclude": "TLT?[1072]", + "branch": [ + "STR>9:20576", + "EVT?[10505]:10000" + ] + }, + "10577": { + "id": 10577, + "event": "你在上学路上看到很多流浪汉和瘾君子。", + "include": "EVT?[10505]", + "exclude": "EVT?[10577]", + "branch": [ + "TLT?[1108]:20577" + ] + }, + "10578": { + "id": 10578, + "event": "你跟随父母回中国了。", + "include": "(INT<7)&(EVT?[10542])", + "exclude": "TLT?[1073]" + }, + "10579": { + "id": 10579, + "event": "你考上了世界名校。", + "include": "EVT?[10011]", + "exclude": "EVT?[10579,10578]" + }, + "10580": { + "id": 10580, + "event": "你考上了哈佛大学。", + "include": "(INT>8)&(EVT?[10011])", + "exclude": "EVT?[10580]" + }, + "10581": { + "id": 10581, + "event": "你考上了耶鲁大学。", + "include": "(INT>8)&(EVT?[10011])", + "exclude": "EVT?[10581]" + }, + "10582": { + "id": 10582, + "event": "你考上了麻省理工大学。", + "include": "(INT>8)&(EVT?[10011])", + "exclude": "EVT?[10582]" + }, + "10583": { + "id": 10583, + "event": "你考上了加州伯克利。", + "include": "(INT>8)&(EVT?[10011])", + "exclude": "EVT?[10583]" + }, + "10584": { + "id": 10584, + "event": "你考上了斯坦福大学。", + "include": "(INT>8)&(EVT?[10011])", + "exclude": "EVT?[10584]" + }, + "10585": { + "id": 10585, + "event": "你的一个熟悉的同学因为压力太大退学了。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10585]" + }, + "10586": { + "id": 10586, + "event": "你以留学生身份被清华大学录取。", + "include": "EVT?[10578]", + "exclude": "(EVT?[10586])|(TLT?[1107])" + }, + "10587": { + "id": 10587, + "event": "你以留学生身份被北京大学录取。", + "include": "EVT?[10578]", + "exclude": "EVT?[10587]" + }, + "10588": { + "id": 10588, + "event": "无事发生。", + "include": "TLT?[1103]" + }, + "10589": { + "id": 10589, + "event": "无事发生。", + "include": "TLT?[1105]" + }, + "10590": { + "id": 10590, + "event": "时间跳跃。", + "include": "TLT?[1104]" + }, + "10591": { + "id": 10591, + "event": "你第一次吃肯德基。", + "include": "(MNY<6)&(EVT?[10009])", + "exclude": "(TLT?[1106])|(MNY<2)|(EVT?[10591])" + }, + "10592": { + "id": 10592, + "event": "你家比较穷,经常只能吃麦当劳等垃圾食品。", + "effect": { + "STR": -1 + }, + "include": "(MNY<6)&(EVT?[10011])", + "exclude": "(TLT?[1106])|(EVT?[10592])" + }, + "10593": { + "id": 10593, + "event": "你几乎每天都在图书馆学习到半夜。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10593]" + }, + "10594": { + "id": 10594, + "event": "圣诞节,有学生制造出了无人机雪橇派送礼物。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10594]" + }, + "10595": { + "id": 10595, + "event": "你在舞会上结识了一个漂亮的女生。", + "postEvent": "你们谈了一阵子恋爱后分手了。", + "include": "(EVT?[10579,10580,10581,10582,10583,10584,10586,10587])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10595,10596])|(TLT?[1027])", + "branch": [ + "CHR>7:20596" + ] + }, + "10596": { + "id": 10596, + "event": "你在舞会上结识了一个帅气的男生。", + "postEvent": "你们谈了一阵子恋爱后分手了。", + "include": "(EVT?[10579,10580,10581,10582,10583,10584,10586,10587])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10596,10595])|(TLT?[1027])", + "branch": [ + "CHR>7:20596" + ] + }, + "10597": { + "id": 10597, + "event": "你去友校做了一年交换生。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10597]" + }, + "10598": { + "id": 10598, + "event": "学习压力很大,你向学校心理咨询处咨询。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10598]" + }, + "10599": { + "id": 10599, + "event": "实验项目繁多,论文你总是卡着时间才写完。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10599]" + }, + "10600": { + "id": 10600, + "event": "你总会抽时间去健身房,保证身体健康。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10600]" + }, + "10601": { + "id": 10601, + "event": "一个从中国来的同学比你还忙,因为他还要抽时间打工。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10601]" + }, + "10602": { + "id": 10602, + "event": "你拿到了奖学金。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10602]" + }, + "10603": { + "id": 10603, + "event": "你的生日派对有很多朋友来参加。", + "include": "(CHR>3)&(EVT?[10579,10580,10581,10582,10583,10584])", + "exclude": "EVT?[10603]" + }, + "10604": { + "id": 10604, + "event": "你在一个角落的墙上看到非常艺术感的涂鸦。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10604]" + }, + "10605": { + "id": 10605, + "event": "你阅读了很多中外的文学作品。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10605]" + }, + "10606": { + "id": 10606, + "event": "你对金融和计算机都十分擅长。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10606]" + }, + "10607": { + "id": 10607, + "event": "你前往华尔街工作,年收入约几十万刀。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10606]", + "exclude": "EVT?[10607,10608,10609]" + }, + "10608": { + "id": 10608, + "event": "你前往硅谷创业。", + "include": "(MNY>8)&(EVT?[10606,10565])", + "exclude": "EVT?[10607,10608,10609]" + }, + "10609": { + "id": 10609, + "event": "你在导师的实验室搞科研。", + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "EVT?[10607,10608,10609]" + }, + "10610": { + "id": 10610, + "event": "你和大学对象步入了婚姻的殿堂。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[20596]", + "exclude": "EVT?[10610,10611,10612]" + }, + "10611": { + "id": 10611, + "event": "你和一个同事结婚了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10606]", + "exclude": "(EVT?[10611,10610,10612,20596])|(TLT?[1027])" + }, + "10612": { + "id": 10612, + "event": "你和一个你很满意的对象结婚了。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10579,10580,10581,10582,10583,10584]", + "exclude": "(EVT?[10612,10610,10611])|(TLT?[1027])" + }, + "10613": { + "id": 10613, + "event": "有家里的资金和人脉支持,你的创业非常成功。", + "include": "EVT?[10608]", + "exclude": "EVT?[10613]" + }, + "10614": { + "id": 10614, + "event": "你结识了许多同学和父母介绍的商业伙伴。", + "include": "EVT?[10608,10607]", + "exclude": "EVT?[10614]" + }, + "10615": { + "id": 10615, + "event": "你非常努力,在社交之中成长很快。", + "include": "EVT?[10608,10607]", + "exclude": "EVT?[10615]" + }, + "10616": { + "id": 10616, + "event": "你的公司越做越大,完成了多轮融资,用户数也突破了千万。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10608]", + "exclude": "EVT?[10616]" + }, + "10617": { + "id": 10617, + "event": "你的公司产品用户数破百万。", + "include": "EVT?[10608]", + "exclude": "EVT?[10617]" + }, + "10618": { + "id": 10618, + "event": "你请了几位中学大学时的朋友加入你的公司。", + "include": "EVT?[10608]", + "exclude": "EVT?[10618]" + }, + "10619": { + "id": 10619, + "event": "你的公司产品用户数破亿。", + "include": "EVT?[10608]", + "exclude": "EVT?[10619]" + }, + "10620": { + "id": 10620, + "event": "你的公司上市了。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10608]", + "exclude": "EVT?[10620]" + }, + "10621": { + "id": 10621, + "event": "你的孩子出生了。", + "include": "EVT?[10610,10611,10612]", + "exclude": "(EVT?[10621])|(TLT?[1041,1046])" + }, + "10622": { + "id": 10622, + "event": "你的爱人也来你的公司工作。", + "include": "EVT?[10608]", + "exclude": "(EVT?[10622])|(TLT?[1027])" + }, + "10623": { + "id": 10623, + "event": "你买了几辆数百万、上千万的豪车。", + "include": "EVT?[10608]", + "exclude": "EVT?[10623]" + }, + "10624": { + "id": 10624, + "event": "你在几座大城市都购入了豪宅,还买了海边别墅。", + "include": "EVT?[10608]", + "exclude": "EVT?[10624]" + }, + "10625": { + "id": 10625, + "event": "你被福布斯评为美国最年轻的百亿富豪排名第一。", + "include": "EVT?[10608]", + "exclude": "EVT?[10625]", + "branch": [ + "TLT?[1108]:20625" + ] + }, + "10626": { + "id": 10626, + "event": "你创立了好几家公司。", + "include": "EVT?[10608]", + "exclude": "EVT?[10626]" + }, + "10627": { + "id": 10627, + "event": "你不再直接参与公司决策,退居幕后。", + "include": "EVT?[10608]", + "exclude": "EVT?[10627]" + }, + "10628": { + "id": 10628, + "event": "你收购了好几家创业公司。", + "include": "EVT?[10608]", + "exclude": "EVT?[10628]" + }, + "10629": { + "id": 10629, + "event": "你开始投资房地产。", + "include": "EVT?[10608]", + "exclude": "EVT?[10629]" + }, + "10630": { + "id": 10630, + "event": "你开始投资AI、VR和游戏。", + "include": "EVT?[10608]", + "exclude": "EVT?[10630]" + }, + "10631": { + "id": 10631, + "event": "你开始投资动漫产业。", + "include": "(EVT?[10608])&(EVT?[10007,10008])", + "exclude": "EVT?[10631]" + }, + "10632": { + "id": 10632, + "event": "你开始投资体育、影视产业。", + "include": "EVT?[10608]", + "exclude": "EVT?[10632]" + }, + "10633": { + "id": 10633, + "event": "你像你父母一样给了孩子最丰厚的条件。", + "include": "EVT?[10621]", + "exclude": "EVT?[10633]" + }, + "10634": { + "id": 10634, + "event": "你希望孩子未来和你一样努力成为精英。", + "include": "EVT?[10621]", + "exclude": "EVT?[10634]" + }, + "10635": { + "id": 10635, + "event": "你被评为本世代十大科技人物。", + "include": "EVT?[10608]", + "exclude": "EVT?[10635]" + }, + "10636": { + "id": 10636, + "event": "你的工作现在很轻松,大多数时间都在家带娃。", + "include": "(EVT?[10608])&(EVT?[10621])", + "exclude": "EVT?[10636]" + }, + "10637": { + "id": 10637, + "event": "你们一家搬家到了瑞士。", + "include": "EVT?[10608]", + "exclude": "EVT?[10637]" + }, + "10638": { + "id": 10638, + "event": "虚拟现实技术已经非常成熟,你玩的兴趣不大。", + "include": "EVT?[10608]", + "exclude": "EVT?[10638]" + }, + "10639": { + "id": 10639, + "event": "你们家每年光保险开销就比普通美国人一辈子的收入还多。", + "include": "EVT?[10608]", + "exclude": "EVT?[10639]" + }, + "10640": { + "id": 10640, + "event": "你们一家去了欧洲各国旅游。", + "include": "EVT?[10608]", + "exclude": "EVT?[10640]" + }, + "10641": { + "id": 10641, + "event": "你们一家去了澳大利亚和新西兰旅游。", + "include": "EVT?[10608]", + "exclude": "EVT?[10641]" + }, + "10642": { + "id": 10642, + "event": "你们一家去了东南亚旅游。", + "include": "EVT?[10608]", + "exclude": "EVT?[10642]" + }, + "10643": { + "id": 10643, + "event": "你们一家去了埃及和阿联酋旅游。", + "include": "EVT?[10608]", + "exclude": "EVT?[10643]" + }, + "10644": { + "id": 10644, + "event": "你们一家去了夏威夷旅游。", + "include": "EVT?[10608]", + "exclude": "EVT?[10644]" + }, + "10645": { + "id": 10645, + "event": "你们一家去了中国旅游。", + "include": "EVT?[10608,10607]", + "exclude": "EVT?[10645]" + }, + "10646": { + "id": 10646, + "event": "你成为了世界首富。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10608]", + "exclude": "EVT?[10646]" + }, + "10647": { + "id": 10647, + "event": "你的孩子也上了世界名校。", + "include": "EVT?[10621]", + "exclude": "EVT?[10647]", + "branch": [ + "TLT?[1108]:20647" + ] + }, + "10648": { + "id": 10648, + "event": "你到东京大学、清华大学、香港大学等学府演讲《我的努力》。", + "include": "EVT?[10608]", + "exclude": "EVT?[10648]" + }, + "10649": { + "id": 10649, + "event": "你的父亲去世。", + "include": "EVT?[10011]", + "exclude": "EVT?[10649,10651]" + }, + "10650": { + "id": 10650, + "event": "你的母亲去世。", + "include": "EVT?[10011]", + "exclude": "EVT?[10650,10652]" + }, + "10651": { + "id": 10651, + "event": "你的父亲因心脏病去世。", + "include": "EVT?[10011]", + "exclude": "(EVT?[10651,10649])|(TLT?[1044])" + }, + "10652": { + "id": 10652, + "event": "你的母亲因心血管疾病去世。", + "include": "EVT?[10011]", + "exclude": "(EVT?[10652,10650])|(TLT?[1044])" + }, + "10653": { + "id": 10653, + "event": "你的爱人因病去世。", + "include": "EVT?[10610,10611,10612]", + "exclude": "EVT?[10653]" + }, + "10654": { + "id": 10654, + "event": "你的孙儿出生了。", + "include": "EVT?[10621]", + "exclude": "EVT?[10654]" + }, + "10655": { + "id": 10655, + "event": "你住在庄园里,围绕着最新科技,过着养老生活。", + "include": "EVT?[10608]", + "exclude": "EVT?[10655]" + }, + "10656": { + "id": 10656, + "event": "你因病医治无效去世。", + "include": "EVT?[10011]", + "exclude": "TLT?[1048]", + "branch": [ + "EVT?[10011]:10000" + ] + }, + "10657": { + "id": 10657, + "event": "你在睡梦中安然离世。", + "include": "EVT?[10011]", + "exclude": "TLT?[1048]", + "branch": [ + "EVT?[10011]:10000" + ] + }, + "10658": { + "id": 10658, + "event": "你财务自由,购买了名车和豪宅。", + "include": "EVT?[10607]", + "exclude": "EVT?[10658]" + }, + "10659": { + "id": 10659, + "event": "你申请了死后冷冻尸体的服务,希望有朝一日能复活。", + "include": "EVT?[10608,10607]", + "exclude": "EVT?[10659]", + "branch": [ + "TLT?[1108]:20659" + ] + }, + "10660": { + "id": 10660, + "event": "你的实验不太顺利。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10609]" + }, + "10661": { + "id": 10661, + "event": "老板对你很严格,但是也很关心你。", + "include": "EVT?[10609]", + "exclude": "EVT?[10661]" + }, + "10662": { + "id": 10662, + "event": "你的学术和实验水平进一步提高。", + "effect": { + "INT": 1 + }, + "include": "EVT?[10609]" + }, + "10663": { + "id": 10663, + "event": "你废寝忘食,几乎住在实验室里。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10609]", + "exclude": "EVT?[10663]" + }, + "10664": { + "id": 10664, + "event": "你的实验取得了突破。", + "include": "EVT?[10609]", + "exclude": "EVT?[10664]" + }, + "10665": { + "id": 10665, + "event": "你一年内发表了多篇SCI。", + "include": "EVT?[10609]", + "exclude": "EVT?[10665]" + }, + "10666": { + "id": 10666, + "event": "你和老板发表了一篇Nature。", + "include": "EVT?[10609]", + "exclude": "EVT?[10666]" + }, + "10667": { + "id": 10667, + "event": "你留校担任助教。", + "include": "EVT?[10609]", + "exclude": "EVT?[10667]" + }, + "10668": { + "id": 10668, + "event": "你处于做实验和发paper的无尽循环中。", + "include": "EVT?[10609]" + }, + "10669": { + "id": 10669, + "event": "你担任副教授。", + "include": "EVT?[10609]", + "exclude": "EVT?[10669]" + }, + "10670": { + "id": 10670, + "event": "你发表一篇一作Nature。", + "include": "EVT?[10609]", + "exclude": "EVT?[10670]" + }, + "10671": { + "id": 10671, + "event": "你被母校聘为正教授。", + "include": "EVT?[10669]", + "exclude": "EVT?[10671]" + }, + "10672": { + "id": 10672, + "event": "你被中国多所名校聘为客座教授。", + "include": "EVT?[10609]", + "exclude": "EVT?[10672]" + }, + "10673": { + "id": 10673, + "event": "你获得多项大奖。", + "include": "EVT?[10609]", + "exclude": "EVT?[10673]" + }, + "10674": { + "id": 10674, + "event": "你在微观粒子领域取得重要突破。", + "include": "EVT?[10609]", + "exclude": "EVT?[10674,10675,10676]" + }, + "10675": { + "id": 10675, + "event": "你在遗传领域取得重要突破。", + "include": "EVT?[10609]", + "exclude": "EVT?[10674,10675,10676]" + }, + "10676": { + "id": 10676, + "event": "你在材料领域取得重要突破。", + "include": "EVT?[10609]", + "exclude": "EVT?[10674,10675,10676]" + }, + "10677": { + "id": 10677, + "event": "你成为美国科学院院士。", + "include": "EVT?[10609]", + "exclude": "EVT?[10677]" + }, + "10678": { + "id": 10678, + "event": "你成为中国科学院外籍院士。", + "include": "EVT?[10609]", + "exclude": "EVT?[10678]" + }, + "10679": { + "id": 10679, + "event": "你获得了诺贝尔物理学奖。", + "effect": { + "MNY": 1, + "SPR": 2 + }, + "include": "EVT?[10674]", + "exclude": "EVT?[10679]" + }, + "10680": { + "id": 10680, + "event": "你获得了诺贝尔生理学或医学奖。", + "effect": { + "MNY": 1, + "SPR": 2 + }, + "include": "EVT?[10675]", + "exclude": "EVT?[10680]" + }, + "10681": { + "id": 10681, + "event": "你获得了诺贝尔化学奖。", + "effect": { + "MNY": 1, + "SPR": 2 + }, + "include": "EVT?[10676]", + "exclude": "EVT?[10681]" + }, + "10682": { + "id": 10682, + "event": "你放弃美国国籍,毅然加入中国国籍前往中国的大学。", + "include": "EVT?[10609]", + "exclude": "EVT?[10682]" + }, + "10683": { + "id": 10683, + "event": "你创建了一个以你名字命名的慈善基金会。", + "include": "EVT?[10608]", + "exclude": "EVT?[10683]" + }, + "10684": { + "id": 10684, + "event": "你决定将你的遗产都捐赠给母校。", + "include": "EVT?[10609]", + "exclude": "EVT?[10684,10682]" + }, + "10685": { + "id": 10685, + "event": "你决定将你的遗产都捐赠给中国大学用于建设。", + "include": "EVT?[10682]", + "exclude": "EVT?[10685]" + }, + "10686": { + "id": 10686, + "event": "你的论文他引超过十万。", + "include": "EVT?[10609]", + "exclude": "EVT?[10686]" + }, + "10687": { + "id": 10687, + "event": "你在世界巡回讲座。", + "include": "EVT?[10609]" + }, + "10688": { + "id": 10688, + "event": "你出版了一本教材。", + "include": "EVT?[10609]", + "exclude": "EVT?[10688]" + }, + "10689": { + "id": 10689, + "event": "你出版了一本自传,介绍你的成功之路。", + "include": "EVT?[10608]", + "exclude": "EVT?[10689]" + }, + "10690": { + "id": 10690, + "event": "你经常作为嘉宾出现在电视节目。", + "include": "EVT?[10607,10608]", + "exclude": "EVT?[10690]" + }, + "10691": { + "id": 10691, + "event": "有人以你的人生为原本拍摄了电影。", + "include": "EVT?[10608]", + "exclude": "EVT?[10691]" + }, + "10692": { + "id": 10692, + "event": "你的自传一直超级畅销。人们被你的努力和精神所打动。", + "include": "EVT?[10689]", + "exclude": "EVT?[10692]" + }, + "10693": { + "id": 10693, + "event": "你不想死,坚持锻炼、经常体检试图延长寿命。", + "include": "EVT?[10607,10608]", + "exclude": "EVT?[10693]" + }, + "10694": { + "id": 10694, + "event": "你的孙子被人绑架,好在成功被警察救出。", + "include": "EVT?[10654]", + "exclude": "EVT?[10694]" + }, + "10695": { + "id": 10695, + "event": "英国剑桥大学吞并牛津大学。", + "include": "EVT?[10011]", + "exclude": "EVT?[10695]" + }, + "10696": { + "id": 10696, + "event": "塔利班组织闪击波兰。法国宣布投降。", + "include": "EVT?[10011]", + "exclude": "EVT?[10696]" + }, + "10697": { + "id": 10697, + "event": "俄罗斯宣布进入社会主义社会。", + "include": "EVT?[10011]", + "exclude": "EVT?[10697]" + }, + "10698": { + "id": 10698, + "event": "日本动漫产业彻底灭亡。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10698]" + }, + "10699": { + "id": 10699, + "event": "日本制造出最新作战兵器:高达。", + "include": "EVT?[10011]", + "exclude": "EVT?[10699]" + }, + "10700": { + "id": 10700, + "event": "美国总统承认与外星人一直有联系。", + "include": "EVT?[10011]", + "exclude": "EVT?[10700]" + }, + "10701": { + "id": 10701, + "event": "经济危机爆发。", + "include": "EVT?[10011]", + "exclude": "EVT?[10701]" + }, + "10702": { + "id": 10702, + "event": "美国精英制定影视音乐作品通用评分标准,引发广泛争议。", + "include": "EVT?[10011]", + "exclude": "EVT?[10702]" + }, + "10703": { + "id": 10703, + "event": "百慕大三角海底发现中国古代风格建筑。", + "include": "EVT?[10011]", + "exclude": "EVT?[10703]" + }, + "10704": { + "id": 10704, + "event": "马斯克登陆火星。", + "include": "EVT?[10011]", + "exclude": "EVT?[10704]" + }, + "10705": { + "id": 10705, + "event": "中国宣布同性恋为犯罪,将至少判处3年以下的有期徒刑。", + "include": "EVT?[10011]", + "exclude": "EVT?[10705]" + }, + "10706": { + "id": 10706, + "event": "金正恩在朝鲜称帝,改为帝制。", + "include": "EVT?[10011]", + "exclude": "EVT?[10706]" + }, + "10707": { + "id": 10707, + "event": "你学会了打麻将。", + "include": "EVT?[10607,10608,10609]", + "exclude": "EVT?[10707]" + }, + "10708": { + "id": 10708, + "event": "你以前常去的高尔夫球场被陨石击中。", + "include": "EVT?[10607,10608]", + "exclude": "EVT?[10708]" + }, + "10709": { + "id": 10709, + "event": "你最好的朋友去世。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10011]", + "exclude": "EVT?[10709]" + }, + "10710": { + "id": 10710, + "event": "城市里到处都是全息投影。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10710]" + }, + "10711": { + "id": 10711, + "event": "全息投影彻底取代手机。", + "include": "EVT?[10011]", + "exclude": "EVT?[10711]" + }, + "10712": { + "id": 10712, + "event": "现在可以通过植入芯片来获得一小段记忆或知识。", + "include": "EVT?[10011]", + "exclude": "EVT?[10712]" + }, + "10713": { + "id": 10713, + "event": "近视已经可以轻松治愈。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10713]" + }, + "10714": { + "id": 10714, + "event": "计算机科学家宣称,我们生活在游戏世界中的概率为100%。", + "include": "EVT?[10011]", + "exclude": "EVT?[10714]" + }, + "10715": { + "id": 10715, + "event": "你发现了大统一模型。", + "include": "EVT?[10679]", + "exclude": "EVT?[10715]" + }, + "10716": { + "id": 10716, + "event": "你再次获得诺贝尔物理学奖。", + "include": "EVT?[10715]", + "exclude": "EVT?[10716]" + }, + "10717": { + "id": 10717, + "event": "你感觉学校的环境各方面都不如美国好。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10717]" + }, + "10718": { + "id": 10718, + "event": "你对学校不太满意,但凑合着学,渐渐更多的时间用在了玩乐上。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10718]" + }, + "10719": { + "id": 10719, + "event": "你平时都和留学生来往,很少和普通学生交流。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10719]" + }, + "10720": { + "id": 10720, + "event": "据说你们的课业要求比普通学生的简单。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10720]" + }, + "10721": { + "id": 10721, + "event": "据说老师让很多普通学生故意挂科,保证你们留学生不至于被退学。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10721]" + }, + "10722": { + "id": 10722, + "event": "中国的食物你吃不习惯。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10722]" + }, + "10723": { + "id": 10723, + "event": "北京的空气和气候你很不习惯。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10723]" + }, + "10724": { + "id": 10724, + "event": "你有时翘课去北京的各景区游玩。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10724]" + }, + "10725": { + "id": 10725, + "event": "你的中文说的很流利。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10725]" + }, + "10726": { + "id": 10726, + "event": "你没有参加社团,但经常和其他留学生开party。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10726]" + }, + "10727": { + "id": 10727, + "event": "你有些想家。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10727]" + }, + "10728": { + "id": 10728, + "event": "你父母来北京看望你。", + "include": "EVT?[10586,10587]" + }, + "10729": { + "id": 10729, + "event": "你经常去看电影、音乐会、演唱会。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10729]" + }, + "10730": { + "id": 10730, + "event": "你爬了长城,感觉不怎么样,又挤又乱。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10730]" + }, + "10731": { + "id": 10731, + "event": "你假期去了上海和香港玩。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10731]" + }, + "10732": { + "id": 10732, + "event": "你假期去西藏旅游。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10732]" + }, + "10733": { + "id": 10733, + "event": "有短视频主播采访你英文水平如何,你假装是普通学生作答。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10733]" + }, + "10734": { + "id": 10734, + "event": "你感觉中国的高铁很方便。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10734]" + }, + "10735": { + "id": 10735, + "event": "你感觉中国的电子支付很方便。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10735]" + }, + "10736": { + "id": 10736, + "event": "你博士毕业了。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10736]" + }, + "10737": { + "id": 10737, + "event": "你进入名企工作。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10737]" + }, + "10738": { + "id": 10738, + "event": "你的工作并不像其他人盛传的那种996,下午下班后你还去健身。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10738]" + }, + "10739": { + "id": 10739, + "event": "公司组织去马尔代夫旅游。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10739]" + }, + "10740": { + "id": 10740, + "event": "公司的休息厅提供西式茶点,令你很满意。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10740]" + }, + "10741": { + "id": 10741, + "event": "普普通通的社畜生活。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10741]" + }, + "10742": { + "id": 10742, + "event": "你养了一只猫。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10742,10743]" + }, + "10743": { + "id": 10743, + "event": "你养了一只狗。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10743,10742]" + }, + "10744": { + "id": 10744, + "event": "你养的猫意外死亡。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10742]", + "exclude": "(EVT?[10744])|(TLT?[1030])" + }, + "10745": { + "id": 10745, + "event": "你养的狗意外死亡。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10743]", + "exclude": "(EVT?[10745])|(TLT?[1030])" + }, + "10746": { + "id": 10746, + "event": "你升职了。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10746,10002,10110,10111]" + }, + "10747": { + "id": 10747, + "event": "你又升职了。", + "effect": { + "MNY": 1, + "SPR": 1 + }, + "include": "EVT?[10746]", + "exclude": "EVT?[10747,10002,10110,10111]" + }, + "10748": { + "id": 10748, + "event": "你有次在地铁上被偷了手机,报警后警方高度重视,立即出动,当天就追回了你的手机。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10748]" + }, + "10749": { + "id": 10749, + "event": "你经常阅读一些财经杂志和哲学书籍。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10749]" + }, + "10750": { + "id": 10750, + "event": "你在视频APP上分享你的人生,收获大量粉丝。", + "include": "(CHR>6)&(EVT?[10586,10587])", + "exclude": "EVT?[10750]" + }, + "10751": { + "id": 10751, + "event": "你经常逛知乎并回答国外和商业相关问题,迅速成为大V。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10751]" + }, + "10752": { + "id": 10752, + "event": "你逐渐意识到你和普通中国人思维方式的不同。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10752]" + }, + "10753": { + "id": 10753, + "event": "你经常感到生活中严重的男女不平等。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10753,10001]" + }, + "10754": { + "id": 10754, + "event": "你组织一些线下活动,和很多遭遇性别歧视的人一起讨论方案和分享经历。", + "include": "EVT?[10753]", + "exclude": "EVT?[10754]" + }, + "10755": { + "id": 10755, + "event": "你出了一本描绘和分析性别歧视现象的书。", + "include": "EVT?[10754]", + "exclude": "EVT?[10755]" + }, + "10756": { + "id": 10756, + "event": "你的理财收益不错。", + "effect": { + "MNY": 1 + }, + "include": "(MNY>6)&(EVT?[10586,10587])", + "exclude": "EVT?[10756]" + }, + "10757": { + "id": 10757, + "event": "你去黄山旅游。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10757]" + }, + "10758": { + "id": 10758, + "event": "你请了年假一口气游玩了五岳。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10758]" + }, + "10759": { + "id": 10759, + "event": "你去三亚旅游。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10759]", + "branch": [ + "INT<7:20759" + ] + }, + "10760": { + "id": 10760, + "event": "你的一位同事代孕了第三胎。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10760]" + }, + "10761": { + "id": 10761, + "event": "你参加了一档老外夸中国的综艺节目。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10761]" + }, + "10762": { + "id": 10762, + "event": "你网上的粉丝很多,你的网红收入甚至超过你的工资。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10750,10751]", + "exclude": "EVT?[10762]" + }, + "10763": { + "id": 10763, + "event": "你的项目大获成功。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10763]" + }, + "10764": { + "id": 10764, + "event": "在一次重要的饭局中,你作为翻译出场。", + "include": "(INT>2)&(EVT?[10586,10587])", + "exclude": "EVT?[10764]" + }, + "10765": { + "id": 10765, + "event": "你购买了名车名表。", + "include": "(MNY>7)&(EVT?[10586,10587])", + "exclude": "EVT?[10765]" + }, + "10766": { + "id": 10766, + "event": "你参加了公司里的斯诺克比赛。", + "include": "(STR>3)&(EVT?[10586,10587])", + "exclude": "EVT?[10766]" + }, + "10767": { + "id": 10767, + "event": "你仅凭每月的理财收入就超过99%的人了。", + "include": "(MNY>7)&(EVT?[10586,10587])", + "exclude": "EVT?[10767]" + }, + "10768": { + "id": 10768, + "event": "你在一次旅游中遭遇车祸。", + "include": "EVT?[10586,10587]", + "exclude": "(EVT?[10768])|(TLT?[1043])", + "branch": [ + "(EVT?[10010])&(EVT?[10007,10008]):30002", + "STR<9:10000" + ] + }, + "10769": { + "id": 10769, + "event": "你退休了。", + "include": "EVT?[10586,10587]", + "exclude": "EVT?[10769]" + }, + "10770": { + "id": 10770, + "event": "【绝密消息】科学家认为大多数人的天赋都是来人间凑数的。", + "include": "TLT?[1112]", + "exclude": "EVT?[10770]" + }, + "10771": { + "id": 10771, + "event": "【绝密消息】你捡到一张纸条,上面写着一位策划的联系方式:846945492。纸条背面又写着:加的人太多了!不加了不加了", + "include": "TLT?[1112]", + "exclude": "EVT?[10771,10772]" + }, + "10772": { + "id": 10772, + "event": "【绝密消息】你捡到一张纸条,上面写着一位程序的联系方式:1281616438。纸条背面又写着:加的人太多了!不加了不加了", + "include": "TLT?[1112]", + "exclude": "EVT?[10772,10771]" + }, + "10773": { + "id": 10773, + "event": "【绝密消息】据说,修仙者是真实存在的……", + "include": "TLT?[1112]", + "exclude": "EVT?[10773,10774]" + }, + "10774": { + "id": 10774, + "event": "【绝密消息】据说,正常人无论如何都活不到100岁,除非……有个小盒子?", + "include": "TLT?[1112]", + "exclude": "EVT?[10774,10773]" + }, + "10775": { + "id": 10775, + "event": "【绝密消息】考古学家发现一粒古代的药丸,看上去金灿灿的,不像凡物。", + "include": "TLT?[1112]", + "exclude": "EVT?[10775]" + }, + "10776": { + "id": 10776, + "event": "【绝密消息】有人说世界上只有中国和美国是真实存在的。", + "include": "TLT?[1112]", + "exclude": "EVT?[10776]" + }, + "10777": { + "id": 10777, + "event": "【绝密消息】有人说“如果你很有钱,就出生不到农村;很穷,就出生不到城市。一个猜测,不知道对不对。”", + "include": "TLT?[1112]", + "exclude": "EVT?[10777]" + }, + "10778": { + "id": 10778, + "event": "【绝绝子消息】今日份甜甜碎片已加载完毕 ,不是8⃣️,宝!我今天重开人生了 ,我真的哭死,呢呢呢,这家的人生好重开到跺jiojio~~~这杯小布丁也有被惊艳到⁉️⁉️⁉️无语子,路上还看见一个Java男,大无语事件,哒哒哒,岁月漫长 那就一起拯救地球与乐趣吧 ", + "include": "EVT?[10770,10771,10772,10773,10774,10775,10776,10777,10779,10780]", + "exclude": "EVT?[10778]" + }, + "10779": { + "id": 10779, + "event": "【绝密消息】遗传学家说,最好的天赋只有0.1%的几率出现,其次的天赋是1%,比较好的天赋是10%。", + "include": "TLT?[1112]", + "exclude": "EVT?[10779]" + }, + "10780": { + "id": 10780, + "event": "【绝密消息】专家认为,一些中老年人生活乏味,只能看新闻度日,是因为某人编不出事件了。", + "include": "TLT?[1112]", + "exclude": "EVT?[10780]" + }, + "10781": { + "id": 10781, + "event": "【绝密消息】据说某游戏由两人制作完成,程序员只花了几个小时就写完了程序,而无业在家的策划花了一周多才写完文案。", + "include": "TLT?[1112]", + "exclude": "EVT?[10781]" + }, + "10782": { + "id": 10782, + "event": "【绝密消息】你看了一本玄幻小说,小说里想度过天劫需要悟透全部五行大道和任意一种本源大道。", + "include": "TLT?[1112]", + "exclude": "EVT?[10782]" + }, + "10783": { + "id": 10783, + "event": "【绝密消息】一名不到25岁的作者强行描写完全不懂的中年和婚后生活,遭致大量批评。", + "include": "TLT?[1112]", + "exclude": "EVT?[10783]" + }, + "10784": { + "id": 10784, + "event": "【绝密消息】某辣鸡游戏十连抽竟然没有保底,就像地球online一样。", + "include": "TLT?[1112]", + "exclude": "EVT?[10784]" + }, + "10785": { + "id": 10785, + "event": "你患上了严重的急性肠胃炎。", + "effect": { + "SPR": -1 + }, + "include": "(STR<5)&(EVT?[10011])", + "exclude": "EVT?[10785]", + "branch": [ + "STR<2:10000" + ] + }, + "10786": { + "id": 10786, + "event": "你突发过敏性哮喘。", + "effect": { + "SPR": -1 + }, + "include": "(STR<2)&(EVT?[10011])", + "exclude": "EVT?[10786]", + "branch": [ + "STR<2:10000" + ] + }, + "10787": { + "id": 10787, + "event": "你进入了一个渡劫期大能的传承洞府。", + "postEvent": "虽然没能通过传承,但获得了少量好处。", + "effect": { + "CHR": 1, + "INT": 1, + "STR": 1, + "MNY": 1, + "SPR": 1 + }, + "include": "(INT>5)&(TLT?[1048])", + "exclude": "EVT?[10787]", + "branch": [ + "INT>13:10788" + ] + }, + "10788": { + "id": 10788, + "event": "获得了传承。所有属性大幅提升。", + "effect": { + "CHR": 2, + "INT": 20, + "STR": 200, + "MNY": 2, + "SPR": 2 + }, + "NoRandom": 1 + }, + "10789": { + "id": 10789, + "event": "你捡到一个破碎的仙器,里面有个知识渊博的器魂。", + "postEvent": "从此智力不再是你修行路上的问题。", + "effect": { + "INT": 100 + }, + "include": "(MNY>13)&(TLT?[1048])", + "exclude": "EVT?[10789]" + }, + "10790": { + "id": 10790, + "event": "你感觉到衰老,很容易疲惫。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10790]" + }, + "10791": { + "id": 10791, + "event": "你的胃口越来越小,感觉时间过得越来越快。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10791]" + }, + "10792": { + "id": 10792, + "event": "你们家装了全自动洗浴间,人进去可以自动完成沐浴和洗漱。", + "include": "EVT?[10011]", + "exclude": "EVT?[10792]" + }, + "10793": { + "id": 10793, + "event": "你们家买了飞车,全球拥有飞车的人很少很少。", + "include": "EVT?[10011]", + "exclude": "EVT?[10793]" + }, + "10794": { + "id": 10794, + "event": "你有一些慢性病,需要持续吃药。", + "effect": { + "STR": -2 + }, + "include": "(STR<9)&(EVT?[10011,10010])", + "exclude": "EVT?[10794]" + }, + "10795": { + "id": 10795, + "event": "你开始觉得钱财无用,身体健康才是最重要的。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10795]" + }, + "10796": { + "id": 10796, + "event": "你意外吃到一份儿时味道的菜,流下了眼泪。", + "include": "EVT?[10011]", + "exclude": "EVT?[10796]" + }, + "10797": { + "id": 10797, + "event": "大太空航行时代到来。", + "include": "EVT?[10011]", + "exclude": "EVT?[10797]" + }, + "10798": { + "id": 10798, + "event": "经常有年轻时的熟人来拜访你。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10798]" + }, + "10799": { + "id": 10799, + "event": "基础学科发展缓慢。", + "include": "EVT?[10011]", + "exclude": "EVT?[10799,10715]" + }, + "10800": { + "id": 10800, + "event": "你家设置了模拟外景,可以实时显示世界各地的风光。", + "include": "EVT?[10011]", + "exclude": "EVT?[10800]" + }, + "10801": { + "id": 10801, + "event": "你家换上了自动地板,可以自动清洁、移动、变温等。", + "include": "EVT?[10011]", + "exclude": "EVT?[10801]" + }, + "10802": { + "id": 10802, + "event": "你家换上了意识控制家具。脑中思考就可以控制家具家电。", + "include": "EVT?[10011]", + "exclude": "EVT?[10802]" + }, + "10803": { + "id": 10803, + "event": "你感叹医学发展缓慢,至今仍未攻克癌症和心血管疾病。", + "include": "EVT?[10011]", + "exclude": "EVT?[10803]" + }, + "10804": { + "id": 10804, + "event": "人工合成肉已经普及,几乎取代了真肉,但你家仍然食用真肉。", + "include": "EVT?[10011]", + "exclude": "EVT?[10804]" + }, + "10805": { + "id": 10805, + "event": "中国可控核聚变技术完全成熟,进入无限能源的时代。", + "include": "EVT?[10011]", + "exclude": "EVT?[10805]" + }, + "10806": { + "id": 10806, + "event": "人类几乎可以完全控制天气。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10806]" + }, + "10807": { + "id": 10807, + "event": "你越来越喜欢哲学书籍,经常看《道德经》和后现代哲学。", + "include": "(INT>5)&(EVT?[10011])", + "exclude": "EVT?[10807]" + }, + "10808": { + "id": 10808, + "event": "你仍然习惯使用笨重的实体电脑,而不是全息计算机。", + "include": "EVT?[10011]", + "exclude": "EVT?[10808]" + }, + "10809": { + "id": 10809, + "event": "越来越多的人沉迷在虚拟世界,包括你的家人们。", + "include": "EVT?[10011]", + "exclude": "EVT?[10809]" + }, + "10810": { + "id": 10810, + "event": "书籍这种媒介竟然没有退出历史舞台,你也很意外。", + "include": "EVT?[10011,10010]", + "exclude": "EVT?[10810]" + }, + "10811": { + "id": 10811, + "event": "美国迎来了一位跨性别穆斯林黑人总统。", + "include": "EVT?[10011]", + "exclude": "EVT?[10811]" + }, + "10812": { + "id": 10812, + "event": "全球变暖严重,专家称100年内日本就会彻底沉没。", + "include": "EVT?[10011]", + "exclude": "EVT?[10812]" + }, + "10813": { + "id": 10813, + "event": "有哲学家称世界是由信息构成的,物质的运动就是信息的传递。", + "include": "EVT?[10011]", + "exclude": "EVT?[10813]" + }, + "10814": { + "id": 10814, + "event": "墨西哥毒贩夺取政权,宣布新政府成立。美国从墨西哥撤兵。", + "include": "EVT?[10011]", + "exclude": "EVT?[10814]" + }, + "10815": { + "id": 10815, + "event": "你开始关注美国底层人民的生活,计划进行一些慈善。", + "include": "EVT?[10011]", + "exclude": "EVT?[10815]" + }, + "10816": { + "id": 10816, + "event": "你因为容貌被破例进入一座洞府。体质大幅提升。", + "effect": { + "STR": 20 + }, + "include": "(CHR>13)&(TLT?[1048])", + "exclude": "EVT?[10816]" + }, + "10817": { + "id": 10817, + "event": "你捡到天阶灵器,实力大幅提升。", + "effect": { + "STR": 50 + }, + "include": "TLT?[1048]", + "exclude": "EVT?[10817]" + }, + "10818": { + "id": 10818, + "event": "你和一位相同境界的人结为道侣。", + "include": "TLT?[1048]", + "exclude": "EVT?[10818]" + }, + "10819": { + "id": 10819, + "event": "你的道侣被人斩杀。", + "effect": { + "SPR": -1 + }, + "include": "(TLT?[1048])&(EVT?[10818])", + "exclude": "EVT?[10819]" + }, + "10820": { + "id": 10820, + "event": "你走火入魔,体质大幅降低。", + "effect": { + "STR": -100 + }, + "include": "TLT?[1048]" + }, + "10821": { + "id": 10821, + "event": "你走火入魔,体质大幅降低。", + "effect": { + "STR": -10 + }, + "include": "TLT?[1048]" + }, + "10822": { + "id": 10822, + "event": "你上了一个昂贵的双语幼儿园。", + "include": "TLT?[1010]", + "exclude": "EVT?[10822]" + }, + "10823": { + "id": 10823, + "event": "你上了一个昂贵的双语幼儿园。", + "include": "(MNY>7)&(EVT?[10010])", + "exclude": "EVT?[10823]" + }, + "10824": { + "id": 10824, + "event": "你上了一个普通的幼儿园。", + "include": "EVT?[10010]", + "exclude": "(MNY<8)&(EVT?[10824])" + }, + "10825": { + "id": 10825, + "event": "你的家人给你买了很多玩具。", + "include": "EVT?[10010]", + "exclude": "EVT?[10825]" + }, + "10826": { + "id": 10826, + "event": "你的家人给你买了很多书。", + "include": "EVT?[10010]", + "exclude": "EVT?[10826]" + }, + "10827": { + "id": 10827, + "event": "你进入了托儿所。", + "include": "EVT?[10010]", + "exclude": "EVT?[10827]" + }, + "10828": { + "id": 10828, + "event": "你的家人开始教你学英语。", + "include": "TLT?[1010]", + "exclude": "EVT?[10828]" + }, + "10829": { + "id": 10829, + "event": "你的家人为你制定了长长的人生计划。", + "include": "EVT?[10010]", + "exclude": "EVT?[10829]" + }, + "10830": { + "id": 10830, + "event": "你生了二胎。", + "effect": { + "STR": -1, + "MNY": -1 + }, + "include": "(TLT?[1113])&(EVT?[10268,10269,10621])", + "exclude": "EVT?[10830]" + }, + "10831": { + "id": 10831, + "event": "你生了三胎。", + "effect": { + "STR": -1, + "MNY": -1 + }, + "include": "EVT?[10830]", + "exclude": "EVT?[10831]" + }, + "10832": { + "id": 10832, + "event": "你患上了严重的妇科疾病。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10830]", + "exclude": "EVT?[10832,10836]" + }, + "10833": { + "id": 10833, + "event": "生育时留下的后遗症,你经常漏尿。", + "include": "EVT?[10830]", + "exclude": "EVT?[10833]" + }, + "10834": { + "id": 10834, + "event": "三个孩子给你们的生活带来了很多不便。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10831]", + "exclude": "EVT?[10834]" + }, + "10835": { + "id": 10835, + "event": "你后悔生了三胎。", + "include": "EVT?[10831]", + "exclude": "EVT?[10835]" + }, + "10836": { + "id": 10836, + "event": "你得了子宫肌瘤。", + "include": "EVT?[10830]", + "exclude": "EVT?[10836,10832]" + }, + "10837": { + "id": 10837, + "event": "你的体态愈发臃肿。", + "effect": { + "CHR": -2, + "SPR": -1 + }, + "include": "EVT?[10830]", + "exclude": "EVT?[10837]" + }, + "10838": { + "id": 10838, + "event": "孩子填满了你的生活,你感觉自己仿佛不是自己,而是机器。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10830]", + "exclude": "EVT?[10838]" + }, + "10839": { + "id": 10839, + "event": "你的家人将一套房产转移到你名下。", + "include": "(MNY>8)&(TLT?[1010])", + "exclude": "EVT?[10839]" + }, + "10840": { + "id": 10840, + "event": "你意外一跤摔到了后脑。", + "effect": { + "INT": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10840]", + "branch": [ + "TLT?[1001]:10004", + "STR<3:10000" + ] + }, + "10841": { + "id": 10841, + "event": "时间跳跃。", + "include": "TLT?[1114]", + "exclude": "EVT?[10842]" + }, + "10842": { + "id": 10842, + "event": "时空错乱,你中途被抛出。", + "include": "TLT?[1114]", + "exclude": "EVT?[10842]" + }, + "10843": { + "id": 10843, + "event": "你的体质极度虚弱。", + "include": "(STR<2)&(EVT?[10010])", + "exclude": "EVT?[10843]" + }, + "10844": { + "id": 10844, + "event": "你患重病身亡。", + "include": "EVT?[10843]", + "exclude": "EVT?[10844]", + "branch": [ + "EVT?[10843]:10000" + ] + }, + "10845": { + "id": 10845, + "event": "你开始学习舞蹈。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10845,10001]" + }, + "10846": { + "id": 10846, + "event": "你开始学习书法。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10846]" + }, + "10847": { + "id": 10847, + "event": "你开始学习钢琴。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10847]" + }, + "10848": { + "id": 10848, + "event": "你的博士妈妈开始教你物理化学生物。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10848,10869]" + }, + "10849": { + "id": 10849, + "event": "你的识字量达到了2000。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10856,10857,10849,10850]" + }, + "10850": { + "id": 10850, + "event": "你的识字量达到了1500。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10856,10857,10849,10850]" + }, + "10851": { + "id": 10851, + "event": "你做了智商测试,智商高达150。", + "include": "(INT>8)&(((MNY>7)&(EVT?[10010]))|(TLT?[1010]))", + "exclude": "EVT?[10851]" + }, + "10852": { + "id": 10852, + "event": "你开始学习游泳。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10852]" + }, + "10853": { + "id": 10853, + "event": "你的高级工程师爸爸开始教你编程。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10853,10868]" + }, + "10854": { + "id": 10854, + "event": "爸妈带你去日本旅游。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10854,10868,10869]" + }, + "10855": { + "id": 10855, + "event": "爸妈带你去美国旅游。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10855,10868,10869]" + }, + "10856": { + "id": 10856, + "event": "你的识字量达到了300。", + "include": "EVT?[10824]", + "exclude": "EVT?[10856,10857,10849,10850]" + }, + "10857": { + "id": 10857, + "event": "你的识字量达到了500。", + "include": "EVT?[10824]", + "exclude": "EVT?[10856,10857,10849,10850]" + }, + "10858": { + "id": 10858, + "event": "幼儿园老师每天都和你们玩游戏。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10824]", + "exclude": "EVT?[10858]" + }, + "10859": { + "id": 10859, + "event": "幼儿园的饭菜不好吃。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10824]", + "exclude": "EVT?[10859]" + }, + "10860": { + "id": 10860, + "event": "幼儿园要求每天午睡,但你经常睡不着。", + "include": "EVT?[10824]", + "exclude": "EVT?[10860]" + }, + "10861": { + "id": 10861, + "event": "上课时,你很乖,坐姿端正。", + "include": "EVT?[10824]", + "exclude": "EVT?[10861,10862]" + }, + "10862": { + "id": 10862, + "event": "上课时,你经常偷偷溜出教室。", + "include": "EVT?[10824]", + "exclude": "EVT?[10862,10861]" + }, + "10863": { + "id": 10863, + "event": "你很可爱,很讨老师和小朋友喜欢。", + "effect": { + "SPR": 1 + }, + "include": "((CHR>7)|(TLT?[1037]))&(EVT?[10824])", + "exclude": "EVT?[10863]" + }, + "10864": { + "id": 10864, + "event": "你学会了骑自行车。", + "include": "(EVT?[10010])&(TLT?[1038])", + "exclude": "EVT?[10864]" + }, + "10865": { + "id": 10865, + "event": "你喜欢玩迷宫和脑筋急转弯。", + "effect": { + "SPR": -1 + }, + "include": "(INT>5)&(EVT?[10824])", + "exclude": "EVT?[10865]" + }, + "10866": { + "id": 10866, + "event": "你家长为你请了家庭教师。", + "effect": { + "SPR": -1 + }, + "include": "(MNY>5)&(EVT?[10824])", + "exclude": "EVT?[10866]" + }, + "10867": { + "id": 10867, + "event": "你的玩电脑和看电视时间都要通过积分兑换。", + "include": "EVT?[10824]", + "exclude": "EVT?[10867]" + }, + "10868": { + "id": 10868, + "event": "你的父亲意外去世。", + "include": "EVT?[10010]", + "exclude": "(EVT?[10868,10869])|(TLT?[1029])" + }, + "10869": { + "id": 10869, + "event": "你的母亲意外去世。", + "include": "EVT?[10010]", + "exclude": "(EVT?[10869,10868])|(TLT?[1029])" + }, + "10870": { + "id": 10870, + "event": "你上了个普通小学。", + "include": "EVT?[10824]", + "exclude": "EVT?[10870]" + }, + "10871": { + "id": 10871, + "event": "你上了个名牌小学。", + "include": "EVT?[10822,10823]", + "exclude": "EVT?[10871]" + }, + "10872": { + "id": 10872, + "event": "你获得了机器人大赛金奖。", + "include": "(INT>8)&(EVT?[10853])", + "exclude": "EVT?[10872]" + }, + "10873": { + "id": 10873, + "event": "你获得了三好学生。", + "include": "(INT>5)&(EVT?[10824])", + "exclude": "EVT?[10873]" + }, + "10874": { + "id": 10874, + "event": "你获得了三好标兵。", + "include": "(INT>6)&(EVT?[10824])", + "exclude": "EVT?[10874]" + }, + "10875": { + "id": 10875, + "event": "你获得了市三好学生。", + "include": "(INT>7)&(EVT?[10822,10823])", + "exclude": "EVT?[10875]" + }, + "10876": { + "id": 10876, + "event": "你获得了区三好标生。", + "include": "(INT>7)&(EVT?[10822,10823])", + "exclude": "EVT?[10876]" + }, + "10877": { + "id": 10877, + "event": "你当上了班长。", + "include": "EVT?[10010]", + "exclude": "EVT?[10877]" + }, + "10878": { + "id": 10878, + "event": "你帮班里出了一期黑板报。", + "include": "(EVT?[10010])&(EVT?[10048])", + "exclude": "EVT?[10878]" + }, + "10879": { + "id": 10879, + "event": "你阅读了大量英文小说和杂志。", + "include": "(INT>5)&(EVT?[10871])", + "exclude": "EVT?[10879]" + }, + "10880": { + "id": 10880, + "event": "你在运动会上取得了好成绩。", + "include": "(STR>6)&(EVT?[10010])", + "exclude": "EVT?[10880]" + }, + "10881": { + "id": 10881, + "event": "你需要上大量课外班,压力很大。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10881]", + "branch": [ + "TLT?[1108]:10882" + ] + }, + "10882": { + "id": 10882, + "event": "你电话举报了课外班,课外班被查封了。你开心了。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10883": { + "id": 10883, + "event": "你参与了辩论会。", + "include": "(INT>3)&(EVT?[10010])", + "exclude": "EVT?[10883]" + }, + "10884": { + "id": 10884, + "event": "你参与了学校的文艺演出。", + "include": "(CHR>3)&(EVT?[10010])", + "exclude": "EVT?[10884]" + }, + "10885": { + "id": 10885, + "event": "你喜欢班上的一个小朋友。不过是很纯洁的喜欢。", + "include": "EVT?[10870]", + "exclude": "EVT?[10885]" + }, + "10886": { + "id": 10886, + "event": "你常常能指出老师的错误。", + "include": "(INT>8)&(EVT?[10010])", + "exclude": "EVT?[10886]" + }, + "10887": { + "id": 10887, + "event": "你第一次因为犯错被罚写检查。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10887,10888,10889]" + }, + "10888": { + "id": 10888, + "event": "你第一次因为犯错被罚站。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10887,10888,10889]" + }, + "10889": { + "id": 10889, + "event": "你第一次因为犯错被罚抄课文。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10887,10888,10889]" + }, + "10890": { + "id": 10890, + "event": "你的父母带你四处旅游、参加活动刷履历。", + "include": "EVT?[10871]", + "exclude": "EVT?[10890]" + }, + "10891": { + "id": 10891, + "event": "你开始学习日语。", + "include": "EVT?[10871]", + "exclude": "EVT?[10891]" + }, + "10892": { + "id": 10892, + "event": "你开始学习法语。", + "include": "EVT?[10871]", + "exclude": "EVT?[10892]" + }, + "10893": { + "id": 10893, + "event": "你达到了钢琴10级。", + "include": "EVT?[10847]", + "exclude": "EVT?[10893]" + }, + "10894": { + "id": 10894, + "event": "你雅思拿到7.5分。", + "include": "(INT>7)&(EVT?[10871])", + "exclude": "EVT?[10894,10895]" + }, + "10895": { + "id": 10895, + "event": "你的英语词汇量达到10000。", + "include": "(INT>7)&(EVT?[10871])", + "exclude": "EVT?[10895,10894]" + }, + "10896": { + "id": 10896, + "event": "你参加美国数学竞赛获得一等奖。", + "include": "(INT>7)&(EVT?[10871])", + "exclude": "EVT?[10896]" + }, + "10897": { + "id": 10897, + "event": "你们学校组织前往南极修学旅行。", + "include": "EVT?[10871]", + "exclude": "EVT?[10897]" + }, + "10898": { + "id": 10898, + "event": "你的美貌十分惊艳。", + "include": "(CHR>7)&(EVT?[10010])", + "exclude": "EVT?[10898]" + }, + "10899": { + "id": 10899, + "event": "你遭到了一位老师的猥亵。", + "postEvent": "你逐渐消沉,但不敢和其他人说。", + "effect": { + "SPR": -2 + }, + "include": "EVT?[10898]", + "exclude": "EVT?[10899]", + "branch": [ + "INT>7:10900" + ] + }, + "10900": { + "id": 10900, + "event": "你报了警,老师被刑拘。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "10901": { + "id": 10901, + "event": "你对自然科学和社会科学的常识都了解不少。", + "include": "EVT?[10870]", + "exclude": "EVT?[10901]" + }, + "10902": { + "id": 10902, + "event": "学校的课程非常重,和普通高中的高三差不多。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10871]", + "exclude": "EVT?[10902]" + }, + "10903": { + "id": 10903, + "event": "家人给了你一笔资金让你理财。", + "include": "EVT?[10871]", + "exclude": "EVT?[10903]" + }, + "10904": { + "id": 10904, + "event": "你近视了。", + "effect": { + "CHR": -1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10904]" + }, + "10905": { + "id": 10905, + "event": "家人送你去国外读了一年。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10871]", + "exclude": "EVT?[10905]" + }, + "10906": { + "id": 10906, + "event": "你家开始养猫。", + "include": "EVT?[10010]", + "exclude": "EVT?[10906]" + }, + "10907": { + "id": 10907, + "event": "你家开始养狗。", + "include": "EVT?[10010]", + "exclude": "EVT?[10907]" + }, + "10908": { + "id": 10908, + "event": "你家的猫意外死亡。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10906]", + "exclude": "(EVT?[10908])|(TLT?[1030])" + }, + "10909": { + "id": 10909, + "event": "你家的狗意外死亡。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10907]", + "exclude": "(EVT?[10909])|(TLT?[1030])" + }, + "10910": { + "id": 10910, + "event": "你的家人极力阻止你看动漫。", + "effect": { + "SPR": -1 + }, + "include": "(EVT?[10871])&(EVT?[10007,10008])", + "exclude": "EVT?[10910]" + }, + "10911": { + "id": 10911, + "event": "你的家人开始禁止你玩电子游戏。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10871]", + "exclude": "(EVT?[10911])|(TLT?[1039])" + }, + "10912": { + "id": 10912, + "event": "你第一次当上课代表。", + "include": "EVT?[10870]", + "exclude": "EVT?[10912]" + }, + "10913": { + "id": 10913, + "event": "有个同学每天在车站等你一起上学。", + "include": "EVT?[10870]", + "exclude": "EVT?[10913]" + }, + "10914": { + "id": 10914, + "event": "你以班上同学为角色画漫画。", + "include": "EVT?[10870]", + "exclude": "EVT?[10914,10926]" + }, + "10915": { + "id": 10915, + "event": "你们的体育课总是变成自习课。", + "include": "EVT?[10870]", + "exclude": "EVT?[10915]" + }, + "10916": { + "id": 10916, + "event": "你们的班主任为了生三胎辞职了。", + "include": "EVT?[10010]", + "exclude": "EVT?[10916]" + }, + "10917": { + "id": 10917, + "event": "信息课上,你和同学玩可以联机的游戏。", + "include": "EVT?[10870]", + "exclude": "EVT?[10917]", + "branch": [ + "TLT?[1039]:20917" + ] + }, + "10918": { + "id": 10918, + "event": "音乐课老师经常放电影。", + "include": "EVT?[10010]", + "exclude": "EVT?[10918]" + }, + "10919": { + "id": 10919, + "event": "你经常和几个同学打架。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "(EVT?[10919,10002,10926])|(TLT?[1037])" + }, + "10920": { + "id": 10920, + "event": "你的作文被老师作为范文朗读,但你却很尴尬。", + "include": "EVT?[10010]", + "exclude": "EVT?[10920]" + }, + "10921": { + "id": 10921, + "event": "你家人经常给你买核桃等坚果补脑。", + "include": "EVT?[10010]", + "exclude": "EVT?[10921]" + }, + "10922": { + "id": 10922, + "event": "你每天都喝牛奶。", + "effect": { + "STR": 1 + }, + "include": "EVT?[10010]", + "exclude": "EVT?[10922]" + }, + "10923": { + "id": 10923, + "event": "你又要买大一号的新校服了。", + "include": "EVT?[10010]", + "exclude": "EVT?[10923]" + }, + "10924": { + "id": 10924, + "event": "你每天做作业都要做到凌晨。", + "effect": { + "STR": -1, + "SPR": -1 + }, + "include": "EVT?[10871]", + "exclude": "EVT?[10924]" + }, + "10925": { + "id": 10925, + "event": "你每天做作业都要做到深夜。", + "effect": { + "STR": -1, + "SPR": -1 + }, + "include": "EVT?[10870]", + "exclude": "EVT?[10925]" + }, + "10926": { + "id": 10926, + "event": "虽然你还小,但你几乎和20岁左右的青年差不多成熟了。", + "include": "EVT?[10871]", + "exclude": "EVT?[10926]" + }, + "10927": { + "id": 10927, + "event": "你开始很严肃地思考未来和制定计划。", + "include": "EVT?[10871]", + "exclude": "EVT?[10927]" + }, + "10928": { + "id": 10928, + "event": "你写了封寄给10年后自己的信。", + "include": "EVT?[10010]", + "exclude": "EVT?[10928]" + }, + "10929": { + "id": 10929, + "event": "学校被禁止搞排名,但你老师报成绩时还是默认按顺序来。", + "include": "EVT?[10010]", + "exclude": "EVT?[10929]" + }, + "10930": { + "id": 10930, + "event": "你喜欢在学校的石质乒乓球台上打球。", + "include": "(STR>2)&(EVT?[10870])", + "exclude": "EVT?[10930]" + }, + "10931": { + "id": 10931, + "event": "你加入了学校篮球队。", + "include": "(STR>6)&(EVT?[10010])", + "exclude": "EVT?[10931,10002]" + }, + "10932": { + "id": 10932, + "event": "你经常和其他同学一起去上厕所。", + "include": "EVT?[10010]", + "exclude": "EVT?[10932]" + }, + "10933": { + "id": 10933, + "event": "升旗时你经常对口型假唱。", + "include": "EVT?[10010]", + "exclude": "EVT?[10933]" + }, + "10934": { + "id": 10934, + "event": "学校校长因贪污受贿被捕。", + "include": "EVT?[10871]", + "exclude": "EVT?[10934]" + }, + "10935": { + "id": 10935, + "event": "你觉得广播体操《舞动青春》的音乐很好听。", + "include": "EVT?[10871]", + "exclude": "EVT?[10935]" + }, + "10936": { + "id": 10936, + "event": "做操体转运动时,你经常趁机回头看别的同学。", + "include": "EVT?[10010]", + "exclude": "EVT?[10936]" + }, + "10937": { + "id": 10937, + "event": "你假装没有全学会,避免了压力更大的跳级。", + "include": "(INT>8)&(EVT?[10010])", + "exclude": "EVT?[10937]" + }, + "10938": { + "id": 10938, + "event": "你颜值出众,准备走娱乐路线。", + "include": "(EVT?[10898])", + "exclude": "EVT?[10938]" + }, + "10939": { + "id": 10939, + "event": "你被体校教练挖走。", + "include": "EVT?[10880]", + "exclude": "EVT?[10939]" + }, + "10940": { + "id": 10940, + "event": "你升入普通初中。", + "include": "EVT?[10870]", + "exclude": "EVT?[10940]" + }, + "10941": { + "id": 10941, + "event": "你升入名牌初中。", + "include": "EVT?[10871]", + "exclude": "EVT?[10941]" + }, + "10942": { + "id": 10942, + "event": "你的游戏技术过人,在学校小有名气。", + "include": "(TLT?[1039])&(EVT?[10940])", + "exclude": "EVT?[10942]" + }, + "10943": { + "id": 10943, + "event": "你中考没有考好。", + "include": "(EVT?[10940])&(EVT?[10258])", + "exclude": "EVT?[10943]" + }, + "10944": { + "id": 10944, + "event": "你考到了一所重点高中。", + "include": "((INT>6)&(EVT?[10940]))|(EVT?[10941])", + "exclude": "EVT?[10944,10258]" + }, + "10945": { + "id": 10945, + "event": "你考到了一所普通高中。", + "include": "(INT<7)&(EVT?[10940])", + "exclude": "EVT?[10945,10258]" + }, + "10946": { + "id": 10946, + "event": "你考上了人大附中。", + "include": "(TLT?[1010])&(INT>6)", + "exclude": "EVT?[10946]" + }, + "10947": { + "id": 10947, + "event": "训练。", + "include": "EVT?[10939]" + }, + "10948": { + "id": 10948, + "event": "培训,整容。", + "effect": { + "CHR": 1 + }, + "include": "(MNY<8)&(EVT?[10938])", + "exclude": "EVT?[10948]" + }, + "10949": { + "id": 10949, + "event": "参加选秀。没有能力砸钱,迅速被淘汰。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10948]", + "exclude": "EVT?[10949]" + }, + "10950": { + "id": 10950, + "event": "加入年轻艺人团体出道。", + "include": "EVT?[10948]", + "exclude": "EVT?[10950]" + }, + "10951": { + "id": 10951, + "event": "遇冷,彻底被资本家放弃。你退圈了。", + "include": "EVT?[10948]", + "exclude": "EVT?[10951]" + }, + "10952": { + "id": 10952, + "event": "你转行做颜值主播。", + "include": "EVT?[10951]", + "exclude": "EVT?[10952]" + }, + "10953": { + "id": 10953, + "event": "你转行从事短视频生产行业。", + "include": "EVT?[10951]", + "exclude": "EVT?[10953]" + }, + "10954": { + "id": 10954, + "event": "你转行做虚拟主播。", + "include": "(EVT?[10951])&(EVT?[10008,10007])", + "exclude": "EVT?[10954]" + }, + "10955": { + "id": 10955, + "event": "你转行从事动漫UP主行业。", + "include": "(EVT?[10951])&(EVT?[10008,10007])", + "exclude": "EVT?[10955]" + }, + "10956": { + "id": 10956, + "event": "你靠卖肉和开网店维持收入。", + "include": "EVT?[10952,10953]", + "exclude": "EVT?[10956]" + }, + "10957": { + "id": 10957, + "event": "你靠人傻钱多二次元维持生计。", + "include": "EVT?[10954,10955]", + "exclude": "EVT?[10957]" + }, + "10958": { + "id": 10958, + "event": "家人投钱帮你造势。", + "include": "(MNY>7)&(EVT?[10938])", + "exclude": "EVT?[10958]" + }, + "10959": { + "id": 10959, + "event": "你参与选秀节目,一举爆红。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10958]", + "exclude": "EVT?[10959]" + }, + "10960": { + "id": 10960, + "event": "你成为最热门的少年天团C位。", + "include": "EVT?[10959]", + "exclude": "EVT?[10960,10002]" + }, + "10961": { + "id": 10961, + "event": "你成为最热门的少女天团C位。", + "include": "EVT?[10959]", + "exclude": "EVT?[10961,10001]" + }, + "10962": { + "id": 10962, + "event": "演出、参加综艺节目。", + "include": "EVT?[10960,10961]", + "exclude": "EVT?[10962]" + }, + "10963": { + "id": 10963, + "event": "出演电影《我的县长父亲》,热度大涨。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10960,10961]", + "exclude": "EVT?[10963]" + }, + "10964": { + "id": 10964, + "event": "出演电视剧《幸福农家乐》,广受好评。", + "include": "EVT?[10960,10961]", + "exclude": "EVT?[10964]" + }, + "10965": { + "id": 10965, + "event": "你接取大量广告代言。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10960,10961]", + "exclude": "EVT?[10965]" + }, + "10966": { + "id": 10966, + "event": "你被北京电影学院录取。", + "include": "EVT?[10960,10961]", + "exclude": "EVT?[10966]" + }, + "10967": { + "id": 10967, + "event": "你休闲时间喜欢追新番。", + "include": "(EVT?[10940])&(EVT?[10008,10007])", + "exclude": "EVT?[10967]" + }, + "10968": { + "id": 10968, + "event": "你开始看网文,并且还偷偷自己拿小本子写。", + "include": "EVT?[10940]", + "exclude": "EVT?[10968]" + }, + "10969": { + "id": 10969, + "event": "你入了cos圈。", + "include": "(EVT?[10940])&(EVT?[10008,10007])", + "exclude": "EVT?[10969]" + }, + "10970": { + "id": 10970, + "event": "你经常女装。", + "include": "EVT?[10969]", + "exclude": "EVT?[10970,10002,10110,10111]" + }, + "10971": { + "id": 10971, + "event": "你第一次看黄书。", + "include": "EVT?[10010]", + "exclude": "EVT?[10971,10972,10973]" + }, + "10972": { + "id": 10972, + "event": "你第一次看A片。", + "include": "EVT?[10010]", + "exclude": "EVT?[10971,10972,10973]" + }, + "10973": { + "id": 10973, + "event": "你第一次看里番。", + "include": "(EVT?[10010])&(EVT?[10008,10007])", + "exclude": "EVT?[10971,10972,10973]" + }, + "10974": { + "id": 10974, + "event": "你谈了一个女朋友。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10945])&((EVT?[10001,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10974])|(TLT?[1027])" + }, + "10975": { + "id": 10975, + "event": "你谈了一个男朋友。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10945])&((EVT?[10002,10110,10111])|(TLT?[1026]))", + "exclude": "(EVT?[10975])|(TLT?[1027])" + }, + "10976": { + "id": 10976, + "event": "你的数学老师因为课外补课而被逮捕。", + "include": "EVT?[10940]", + "exclude": "EVT?[10976]" + }, + "10977": { + "id": 10977, + "event": "你们班的男生玩阿鲁巴,把学校的路灯锯断了。", + "include": "EVT?[10945]", + "exclude": "EVT?[10977]" + }, + "10978": { + "id": 10978, + "event": "有只狗狗跑进你们班一起听课。", + "postEvent": "但很快被闻讯而来的城管抓走了。", + "include": "EVT?[10940]", + "exclude": "EVT?[10978]" + }, + "10979": { + "id": 10979, + "event": "有次值日,其他人都跑了,只有你一个人留在班上扫除到很晚。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10940]", + "exclude": "EVT?[10944,10979]" + }, + "10980": { + "id": 10980, + "event": "由于补课禁令,你们下午5点多就放学了。", + "postEvent": "但课后要做的事更多了。", + "include": "EVT?[10945]", + "exclude": "EVT?[10980]" + }, + "10981": { + "id": 10981, + "event": "眼保健操的功效被证实是虚假信息,学校取消了每天的眼保健操。", + "include": "EVT?[10940]", + "exclude": "EVT?[10981]" + }, + "10982": { + "id": 10982, + "event": "你的朋友很少。", + "effect": { + "SPR": -1 + }, + "include": "(EVT?[10940])&(CHR<3)", + "exclude": "EVT?[10982]" + }, + "10983": { + "id": 10983, + "event": "你的朋友很多。", + "include": "(EVT?[10940])&(CHR>6)", + "exclude": "EVT?[10983]" + }, + "10984": { + "id": 10984, + "event": "你能感受到学业难度的提升。", + "include": "EVT?[10945]", + "exclude": "EVT?[10984]" + }, + "10985": { + "id": 10985, + "event": "有学生上课玩手机被老师抓到,老师将其手机扔出窗外。", + "include": "EVT?[10945]", + "exclude": "EVT?[10985]" + }, + "10986": { + "id": 10986, + "event": "你同桌的男生很烦人,总是没事招惹你。", + "effect": { + "SPR": -1 + }, + "include": "(EVT?[10940])&(EVT?[10002])&(CHR>5)", + "exclude": "EVT?[10944,10986]" + }, + "10987": { + "id": 10987, + "event": "有次写作业时灵光突现,你的智力提高了。", + "effect": { + "INT": 1 + }, + "include": "EVT?[10940]", + "exclude": "EVT?[10987]" + }, + "10988": { + "id": 10988, + "event": "你现在很叛逆,讨厌别人管教你。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,10988]" + }, + "10989": { + "id": 10989, + "event": "你买小卖部的饮料中了再来一瓶,中的打开又中了再来一瓶。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10940]", + "exclude": "EVT?[10989,10990]" + }, + "10990": { + "id": 10990, + "event": "你在学校小卖部买过很多次饮料,从来没中过奖。", + "include": "EVT?[10940]", + "exclude": "EVT?[10990,10989]" + }, + "10991": { + "id": 10991, + "event": "午休时,你喜欢趴在桌子上午睡。", + "include": "EVT?[10945]", + "exclude": "EVT?[10991]" + }, + "10992": { + "id": 10992, + "event": "越临近考试,你越不想学习。考完后你玩时却觉得没意思了。", + "include": "EVT?[10940]", + "exclude": "EVT?[10992]" + }, + "10993": { + "id": 10993, + "event": "你做了MBTI测试,发现自己是INFP。", + "include": "(EVT?[10010])&(SPR<4)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10994": { + "id": 10994, + "event": "你做了MBTI测试,发现自己是INTP。", + "include": "(EVT?[10010])&(INT>7)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10995": { + "id": 10995, + "event": "你做了MBTI测试,发现自己是INFJ。", + "include": "(EVT?[10010])&(SPR<6)&(CHR>5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10996": { + "id": 10996, + "event": "你做了MBTI测试,发现自己是ENTP。", + "include": "(EVT?[10010])&(STR>5)&(INT>5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10997": { + "id": 10997, + "event": "你做了MBTI测试,发现自己是INTJ。", + "include": "(EVT?[10010])&(CHR>4)&(INT>6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10998": { + "id": 10998, + "event": "你做了MBTI测试,发现自己是ENFP。", + "include": "(EVT?[10010])&(STR>4)&(SPR>6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "10999": { + "id": 10999, + "event": "你做了MBTI测试,发现自己是ENFJ。", + "include": "(EVT?[10010])&(CHR>4)&(SPR>6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11000": { + "id": 11000, + "event": "你做了MBTI测试,发现自己是ENTJ。", + "include": "(EVT?[10010])&(CHR<5)&(SPR<5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11001": { + "id": 11001, + "event": "你做了MBTI测试,发现自己是ISFP。", + "include": "(EVT?[10010])&(CHR>5)&(SPR<5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11002": { + "id": 11002, + "event": "你做了MBTI测试,发现自己是ISFJ。", + "include": "(EVT?[10010])&(INT>5)&(SPR<5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11003": { + "id": 11003, + "event": "你做了MBTI测试,发现自己是ISTP。", + "include": "(EVT?[10010])&(INT>5)&(STR<5)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11004": { + "id": 11004, + "event": "你做了MBTI测试,发现自己是ISTJ。", + "include": "(EVT?[10010])&(INT>4)&(CHR<6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11005": { + "id": 11005, + "event": "你做了MBTI测试,发现自己是ESFP。", + "include": "(EVT?[10010])&(CHR>5)&(STR>4)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11006": { + "id": 11006, + "event": "你做了MBTI测试,发现自己是ESTP。", + "include": "(EVT?[10010])&(CHR>5)&(STR<6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11007": { + "id": 11007, + "event": "你做了MBTI测试,发现自己是ESFJ。", + "include": "(EVT?[10010])&(CHR<6)&(INT<6)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11008": { + "id": 11008, + "event": "你做了MBTI测试,发现自己是ESTJ。", + "include": "(EVT?[10010])&(CHR<6)&(STR>4)", + "exclude": "EVT?[10993,10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,11006,11007,11008]" + }, + "11009": { + "id": 11009, + "event": "你梦见自己穿越回古代用现代知识乱杀。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11009]" + }, + "11010": { + "id": 11010, + "event": "上课时打了个盹,被老师粉笔头砸醒。", + "include": "EVT?[10940]", + "exclude": "EVT?[11010]" + }, + "11011": { + "id": 11011, + "event": "同学们偷偷评选班花。", + "postEvent": "班花不是你。", + "include": "EVT?[10940]", + "exclude": "EVT?[11011,10001,10110,10111]", + "branch": [ + "CHR>7:21011" + ] + }, + "11012": { + "id": 11012, + "event": "同学们偷偷评选校草。", + "postEvent": "校草不是你。", + "include": "EVT?[10940]", + "exclude": "EVT?[11012,10002,10110,10111]", + "branch": [ + "CHR>8:21012" + ] + }, + "11013": { + "id": 11013, + "event": "有同学在纸上画游戏给其他同学玩,被老师没收了。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11013]" + }, + "11014": { + "id": 11014, + "event": "你后桌的同学抄你作业,不小心把你名字也抄上了。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11014]" + }, + "11015": { + "id": 11015, + "event": "学校食堂推出新菜:番茄炒西红柿。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11016": { + "id": 11016, + "event": "学校食堂推出新菜:去肉牛肉面。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11017": { + "id": 11017, + "event": "学校食堂推出新菜:青椒炒草莓。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11018": { + "id": 11018, + "event": "学校食堂推出新菜:酸梅汤豆腐脑。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11019": { + "id": 11019, + "event": "学校食堂推出新菜:可乐烧黄瓜。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11020": { + "id": 11020, + "event": "学校食堂推出新菜:面条馅包子。", + "include": "EVT?[10940]", + "exclude": "EVT?[10944,11015,11016,11017,11018,11019,11020]" + }, + "11021": { + "id": 11021, + "event": "最新桌游三国自走棋风靡学校,放学后很多同学一起玩。", + "include": "EVT?[10940]", + "exclude": "EVT?[11021]" + }, + "11022": { + "id": 11022, + "event": "学校组织在操场上办跳蚤市场。", + "postEvent": "你卖了些旧书。", + "include": "EVT?[10940]", + "exclude": "EVT?[11022]", + "branch": [ + "INT>8:21022" + ] + }, + "11023": { + "id": 11023, + "event": "你和一个老师闹了很大矛盾,心态爆炸。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10940]", + "exclude": "EVT?[11023]", + "branch": [ + "SPR<2:10062" + ] + }, + "11024": { + "id": 11024, + "event": "你脑力有限,跟不上课程。", + "include": "(EVT?[10945])&(INT<2)", + "exclude": "EVT?[11024]" + }, + "11025": { + "id": 11025, + "event": "你身体不好,经常请假去医院。", + "include": "(EVT?[10940])&(STR<2)", + "exclude": "EVT?[11025]", + "branch": [ + "STR<1:21025" + ] + }, + "11026": { + "id": 11026, + "event": "学校添加了性少数厕所。", + "include": "(EVT?[10010])&(EVT?[10110,10111,10002])", + "exclude": "EVT?[11026]" + }, + "11027": { + "id": 11027, + "event": "校门口发生一起斗殴事件,多人受伤。", + "include": "EVT?[10940]", + "exclude": "EVT?[11027]", + "branch": [ + "TLT?[1108]:21027" + ] + }, + "11028": { + "id": 11028, + "event": "学习压力很大,你向学校心理老师倾诉。", + "include": "EVT?[10941]", + "exclude": "EVT?[11028]" + }, + "11029": { + "id": 11029, + "event": "学校食堂推出新菜:挂面炒意面。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11030": { + "id": 11030, + "event": "学校食堂推出新菜:醋香烤翅。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11031": { + "id": 11031, + "event": "学校食堂推出新菜:大东南羊肉串。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11032": { + "id": 11032, + "event": "学校食堂推出新菜:肉包沙拉。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11033": { + "id": 11033, + "event": "学校食堂推出新菜:酱油捞饭。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11034": { + "id": 11034, + "event": "学校食堂推出新菜:榴莲馅小笼包。", + "include": "EVT?[10941]", + "exclude": "EVT?[11029,11030,11031,11032,11033,11034]" + }, + "11035": { + "id": 11035, + "event": "你很喜欢实验课。", + "include": "EVT?[10941]", + "exclude": "EVT?[11035]" + }, + "11036": { + "id": 11036, + "event": "下课铃一响,所有人都抱着书冲向食堂。", + "include": "EVT?[10944]", + "exclude": "EVT?[11036]" + }, + "11037": { + "id": 11037, + "event": "几乎每节课间你们老师都拖堂到下一节课铃响。", + "include": "EVT?[10941]", + "exclude": "EVT?[11037]" + }, + "11038": { + "id": 11038, + "event": "你开始提前学后面的内容。", + "include": "(EVT?[10941])&(INT>7)", + "exclude": "EVT?[11038]" + }, + "11039": { + "id": 11039, + "event": "你被淹没在题海中。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10941]", + "exclude": "EVT?[11039]" + }, + "11040": { + "id": 11040, + "event": "同校有学生跳楼自杀。被学校压下来了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10941]", + "exclude": "EVT?[11040]" + }, + "11041": { + "id": 11041, + "event": "普通的内卷生活。", + "include": "EVT?[10941]", + "exclude": "EVT?[11041]" + }, + "11042": { + "id": 11042, + "event": "班上有同学提前出国了。", + "include": "EVT?[10941]", + "exclude": "EVT?[11042]" + }, + "11043": { + "id": 11043, + "event": "你们的英语课有时会让外教上。", + "include": "EVT?[10941]", + "exclude": "EVT?[11043]" + }, + "11044": { + "id": 11044, + "event": "虽然你住校,但你母亲在学校附近租了个房子住。", + "include": "EVT?[10941]", + "exclude": "EVT?[11044,10869]" + }, + "11045": { + "id": 11045, + "event": "你经常参加各类竞赛。", + "include": "(EVT?[10941,10946])&(INT>7)", + "exclude": "EVT?[11045,21045]" + }, + "11046": { + "id": 11046, + "event": "你夺得了奥赛金牌。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[11045,21045])&(INT>9)", + "exclude": "EVT?[11046]" + }, + "11047": { + "id": 11047, + "event": "你经常参加各种夏令营。", + "include": "EVT?[10941]", + "exclude": "EVT?[11047]" + }, + "11048": { + "id": 11048, + "event": "学校采取按成绩排考场,班上采取按成绩排座位。", + "include": "EVT?[10941]", + "exclude": "EVT?[11048]" + }, + "11049": { + "id": 11049, + "event": "很多同学跟不上老师讲课的速度。", + "include": "EVT?[10944]", + "exclude": "EVT?[11049]" + }, + "11050": { + "id": 11050, + "event": "两天一小考,三天一大考。", + "include": "EVT?[10944]", + "exclude": "EVT?[11050]" + }, + "11051": { + "id": 11051, + "event": "你刷过的练习册已经一人高了。", + "include": "EVT?[10944]", + "exclude": "EVT?[11051]" + }, + "11052": { + "id": 11052, + "event": "学校请来搞领导力培训的人到学校开动员大会。", + "postEvent": "很多同学被刺激到大哭大喊。", + "include": "EVT?[10944]", + "exclude": "EVT?[11052]" + }, + "11053": { + "id": 11053, + "event": "班上的空调坏了,老师故意不找人修,说要锻炼你们。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10944]", + "exclude": "EVT?[11053]" + }, + "11054": { + "id": 11054, + "event": "你有点怀疑人生的意义。", + "include": "(EVT?[10944])&(SPR<4)", + "exclude": "EVT?[11054]" + }, + "11055": { + "id": 11055, + "event": "班上挂上了励志条幅。", + "include": "EVT?[10944]", + "exclude": "EVT?[11055]" + }, + "11056": { + "id": 11056, + "event": "老师用班费给大家买了他新出的辅导书。", + "include": "EVT?[10944]", + "exclude": "EVT?[11056]" + }, + "11057": { + "id": 11057, + "event": "你的课桌上和抽屉里挤满了书,快要放不下了。", + "include": "EVT?[10941]", + "exclude": "EVT?[11057]" + }, + "11058": { + "id": 11058, + "event": "你报了很多超难的课程。", + "include": "(EVT?[10946])&(INT>7)", + "exclude": "EVT?[11058]" + }, + "11059": { + "id": 11059, + "event": "你们班所有老师都是特级教师。", + "include": "EVT?[10946]", + "exclude": "EVT?[11059]" + }, + "11060": { + "id": 11060, + "event": "你经常参加各种学校社团、活动和节日。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[10946]", + "exclude": "EVT?[11060]" + }, + "11061": { + "id": 11061, + "event": "有很多同学早就准备好出国了。", + "include": "EVT?[10946]", + "exclude": "EVT?[11061]" + }, + "11062": { + "id": 11062, + "event": "你参加一个国际比赛获得一等奖,上了年度开学典礼的表彰。", + "effect": { + "SPR": 1 + }, + "include": "(EVT?[10946])&(INT>9)", + "exclude": "EVT?[11062]" + }, + "11063": { + "id": 11063, + "event": "虽然你比同龄人强很多,但你周围总有各方面比你都强的大佬。", + "include": "EVT?[10946]", + "exclude": "EVT?[11063]" + }, + "11064": { + "id": 11064, + "event": "有老外在校门口用英文采访你,你对答如流。", + "include": "EVT?[10946]", + "exclude": "EVT?[11064]" + }, + "11065": { + "id": 11065, + "event": "学校提供了很多和国外名校交流的机会。", + "include": "EVT?[10946]", + "exclude": "EVT?[11065]" + }, + "11066": { + "id": 11066, + "event": "老师说:“少壮不努力,长大去隔壁。”", + "include": "EVT?[10946]", + "exclude": "EVT?[11066]" + }, + "11067": { + "id": 11067, + "event": "你考上了少年班,提前步入大学。", + "include": "(EVT?[10010])&(INT>9)", + "exclude": "EVT?[11067]" + }, + "11068": { + "id": 11068, + "event": "努力学习。", + "include": "EVT?[11067]" + }, + "11069": { + "id": 11069, + "event": "你出国留学。", + "include": "EVT?[11067]", + "exclude": "EVT?[11069]" + }, + "11070": { + "id": 11070, + "event": "你前往哈佛大学留学。", + "include": "(EVT?[11067])&(TLT?[1073])", + "exclude": "EVT?[11070]" + }, + "11071": { + "id": 11071, + "event": "你考上了清华大学。", + "include": "((EVT?[10944,10945])&(INT>9))|(EVT?[10946])", + "exclude": "(EVT?[11071])|(TLT?[1107])" + }, + "11072": { + "id": 11072, + "event": "你考上了北京大学。", + "include": "((EVT?[10944,10945])&(INT>9))|(EVT?[10946])", + "exclude": "EVT?[11072]" + }, + "11073": { + "id": 11073, + "event": "你被保送清华大学。", + "include": "EVT?[11046,11062]", + "exclude": "(EVT?[11073])|(TLT?[1107])" + }, + "11074": { + "id": 11074, + "event": "你被保送北京大学。", + "include": "EVT?[11046,11062]", + "exclude": "EVT?[11074]" + }, + "11075": { + "id": 11075, + "event": "你考上一所985大学。", + "include": "(EVT?[10944,10945])&((INT>7)|(MNY>8))", + "exclude": "EVT?[11075]" + }, + "11076": { + "id": 11076, + "event": "你考上一所211大学。", + "include": "(EVT?[10944,10945])&((INT>6)|(MNY>7))", + "exclude": "EVT?[11076]" + }, + "11077": { + "id": 11077, + "event": "你考上一所双非本科。", + "include": "EVT?[10944,10945]", + "exclude": "EVT?[11077]" + }, + "11078": { + "id": 11078, + "event": "高考结束,你们班一本率100%。", + "include": "EVT?[10946]", + "exclude": "EVT?[11078]" + }, + "11079": { + "id": 11079, + "event": "高考结束,你们班一本率74%。", + "include": "EVT?[10944]", + "exclude": "EVT?[11079]" + }, + "11080": { + "id": 11080, + "event": "高考结束,你们班一本率67%。", + "include": "EVT?[10944]", + "exclude": "EVT?[11080]" + }, + "11081": { + "id": 11081, + "event": "高考结束,你们班一本率50%。", + "include": "EVT?[10944,10945]", + "exclude": "EVT?[11081]" + }, + "11082": { + "id": 11082, + "event": "高考结束,你们班一本率92%。", + "include": "EVT?[10944]", + "exclude": "EVT?[11082]" + }, + "11083": { + "id": 11083, + "event": "高考结束,你们班一本率80%。", + "include": "EVT?[10944]", + "exclude": "EVT?[11083]" + }, + "11084": { + "id": 11084, + "event": "高考结束,你们班一本率35%。", + "include": "EVT?[10945]", + "exclude": "EVT?[11084]" + }, + "11085": { + "id": 11085, + "event": "高考结束,你们班一本率40%。", + "include": "EVT?[10945]", + "exclude": "EVT?[11085]" + }, + "11086": { + "id": 11086, + "event": "高考结束,你们班一本率25%。", + "include": "EVT?[10945]", + "exclude": "EVT?[11086]" + }, + "11087": { + "id": 11087, + "event": "普通的自媒体生活。", + "include": "EVT?[10956,10957]" + }, + "11088": { + "id": 11088, + "event": "你和一个粉丝开始谈恋爱。", + "include": "EVT?[10956,10957]", + "exclude": "EVT?[11088]" + }, + "11089": { + "id": 11089, + "event": "你和多个粉丝谈恋爱。", + "include": "EVT?[11088]", + "exclude": "EVT?[11089]" + }, + "11090": { + "id": 11090, + "event": "你的热度逐渐走低。", + "include": "EVT?[10956,10957]", + "exclude": "EVT?[11090]" + }, + "11091": { + "id": 11091, + "event": "你的收入比较低。", + "include": "EVT?[10956,10957]", + "exclude": "EVT?[11091]" + }, + "11092": { + "id": 11092, + "event": "时刻担忧净网新规会对你产生影响。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[10956,10957]", + "exclude": "EVT?[11092]" + }, + "11093": { + "id": 11093, + "event": "你结婚了。", + "include": "EVT?[10956,10957]", + "exclude": "(EVT?[11093,10612,11171,10229,10610,10611])|(TLT?[1027])" + }, + "11094": { + "id": 11094, + "event": "普通的大学生活。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11094]" + }, + "11095": { + "id": 11095, + "event": "你的生活和高中一样卷,抓紧各种时间看书。", + "include": "EVT?[11071,11072,11073,11074,11075,11076,11069,11070]", + "exclude": "EVT?[11095]" + }, + "11096": { + "id": 11096, + "event": "班上总是有同学翘课,而且越来越多。", + "include": "EVT?[11077,11075,11076]", + "exclude": "EVT?[11096]" + }, + "11097": { + "id": 11097, + "event": "你加入了学生会。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11097]" + }, + "11098": { + "id": 11098, + "event": "你加入了好几个社团,但参加社团活动的时间并不多。", + "include": "EVT?[11071,11072,11073,11074,11075,11076,11069,11070]", + "exclude": "EVT?[11098]" + }, + "11099": { + "id": 11099, + "event": "你加入了不少社团,课余生活很丰富。", + "include": "EVT?[11077]", + "exclude": "EVT?[11099]" + }, + "11100": { + "id": 11100, + "event": "你的绩点不错。", + "include": "(INT>4)&(EVT?[11077,11075,11076,11071,11072,11073,11074])", + "exclude": "EVT?[11100,11101,11102]" + }, + "11101": { + "id": 11101, + "event": "你的绩点不好。", + "include": "((EVT?[11105,11106])|(INT<5))&(EVT?[11077,11075,11076,11071,11072,11073,11074])", + "exclude": "(INT>8)|(EVT?[11100,11101,11102])" + }, + "11102": { + "id": 11102, + "event": "你的绩点很棒。", + "include": "(INT>7)&(EVT?[11077,11075,11076,11071,11072,11073,11074])", + "exclude": "EVT?[11100,11101,11102]" + }, + "11103": { + "id": 11103, + "event": "你保研了。", + "include": "EVT?[11102]", + "exclude": "EVT?[11103]" + }, + "11104": { + "id": 11104, + "event": "你没抢到想选修的课。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11104]" + }, + "11105": { + "id": 11105, + "event": "你总是和室友去外面玩。", + "include": "EVT?[11077]", + "exclude": "EVT?[11105]" + }, + "11106": { + "id": 11106, + "event": "你总是和室友在寝室打游戏。", + "effect": { + "STR": -1 + }, + "include": "EVT?[11077]", + "exclude": "EVT?[11106,10002]" + }, + "11107": { + "id": 11107, + "event": "你上课手机不离手。不过其他同学大多也是。", + "include": "EVT?[11077]", + "exclude": "EVT?[11107]" + }, + "11108": { + "id": 11108, + "event": "你参加了志愿活动和社会实践。虽然是学分要求的。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11108]" + }, + "11109": { + "id": 11109, + "event": "你挂了好几科。", + "include": "((EVT?[11105,11106])|(INT<4))&(EVT?[11077,11075,11076,11071,11072,11073,11074])", + "exclude": "EVT?[11109]" + }, + "11110": { + "id": 11110, + "event": "你通过了英语和计算机等级考试。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11110,11105,11106]" + }, + "11111": { + "id": 11111, + "event": "你一年内谈了三次恋爱。", + "effect": { + "CHR": 1 + }, + "include": "(EVT?[11077,11075,11076,11071,11072,11073,11074,11069.11070])&(TLT?[1028])", + "exclude": "(EVT?[11111,11112,11113])|(TLT?[1027])" + }, + "11112": { + "id": 11112, + "event": "你和一个同班同学谈恋爱。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]", + "exclude": "(EVT?[11111,11112,11113])|(TLT?[1027])" + }, + "11113": { + "id": 11113, + "event": "你一直没谈恋爱。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074,11069,11070]", + "exclude": "(EVT?[11111,11112,11113])|(TLT?[1028])" + }, + "11114": { + "id": 11114, + "event": "你的寝室总是有蟑螂蚊子。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11114]" + }, + "11115": { + "id": 11115, + "event": "比起现实生活中的人,你更愿意和网友交流。", + "include": "EVT?[10993,10994,10995,10997,11001,11002,11003,11004]", + "exclude": "EVT?[11115]" + }, + "11116": { + "id": 11116, + "event": "学校里总是有各种大佬的讲座可以听。", + "effect": { + "INT": 1 + }, + "include": "EVT?[11071,11072,11073,11074,11075,11076,11069,11070]", + "exclude": "EVT?[11116]" + }, + "11117": { + "id": 11117, + "event": "学校里总是有各种名企来招人。", + "include": "EVT?[11071,11072,11073,11074,11075,11076,11069,11070]", + "exclude": "EVT?[11117]" + }, + "11118": { + "id": 11118, + "event": "你的同学少有出生寒门,多是富二代、官二代、学二代。", + "include": "EVT?[11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11118]" + }, + "11119": { + "id": 11119, + "event": "大佬云集,你感到自己仿佛不再那么出众。", + "include": "EVT?[11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11119]" + }, + "11120": { + "id": 11120, + "event": "你的视野开阔了许多,很多想法都和在国内时不同。", + "include": "EVT?[11069,11070]", + "exclude": "EVT?[11120]" + }, + "11121": { + "id": 11121, + "event": "你很早就开始寻找和联系导师。", + "include": "EVT?[11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11121]" + }, + "11122": { + "id": 11122, + "event": "你开始读研。", + "include": "EVT?[11103,11071,11072,11073,11074,11069,11070]", + "exclude": "EVT?[11122]" + }, + "11123": { + "id": 11123, + "event": "你成为了打工人。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11123,11124,11103,11121]" + }, + "11124": { + "id": 11124, + "event": "你开始创业。", + "include": "(MNY>7)&(EVT?[11077,11075,11076,11071,11072,11073,11074])", + "exclude": "EVT?[11124,11103,11121,11123]" + }, + "11125": { + "id": 11125, + "event": "你开始考公务员。", + "include": "EVT?[11077,11075,11076,11071,11072,11073,11074]", + "exclude": "EVT?[11125,11103,11121]" + }, + "11126": { + "id": 11126, + "event": "你没有考上公务员。", + "postEvent": "你成为了打工人。", + "include": "EVT?[11025]", + "exclude": "(EVT?[11126])|(TLT?[1116])" + }, + "11127": { + "id": 11127, + "event": "你考上了公务员。", + "include": "EVT?[11025]", + "exclude": "EVT?[11127]" + }, + "11128": { + "id": 11128, + "event": "你开始相亲。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "(EVT?[11128,11171])|(TLT?[1027])" + }, + "11129": { + "id": 11129, + "event": "你看上了对方,但对方看不上你。", + "include": "EVT?[11128]", + "exclude": "EVT?[11129,11131,11171]" + }, + "11130": { + "id": 11130, + "event": "对方看上了你,但你看不上对方。", + "include": "EVT?[11128]", + "exclude": "EVT?[11129,11131,11171]" + }, + "11131": { + "id": 11131, + "event": "你开始处对象。", + "include": "EVT?[11128]", + "exclude": "EVT?[11129,11131,11171]" + }, + "11132": { + "id": 11132, + "event": "你找不到对象,至今单身。", + "include": "EVT?[11129,11130]", + "exclude": "EVT?[11129,11131,11171]" + }, + "11133": { + "id": 11133, + "event": "你996上班。", + "effect": { + "STR": -1 + }, + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11133]" + }, + "11134": { + "id": 11134, + "event": "国家宣布禁止强制996。", + "postEvent": "老板让你们自愿996,不996的话工资很低。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11133]", + "exclude": "EVT?[11134]" + }, + "11135": { + "id": 11135, + "event": "你的私人生活越来越少,工作成为了你生活的大部分。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11135]" + }, + "11136": { + "id": 11136, + "event": "比起重复的每个工作日,你宁愿回到中学时光。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11136]" + }, + "11137": { + "id": 11137, + "event": "即使下班,也总是有人问你工作上的问题。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11137]" + }, + "11138": { + "id": 11138, + "event": "即使下班,晚上也经常有饭局,你的私人时间被进一步剥夺。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11138]" + }, + "11139": { + "id": 11139, + "event": "你突然有些厌烦,你更怀念一个人的时候。", + "include": "(EVT?[11123,11126])&(EVT?[11131])", + "exclude": "EVT?[11139,11140]" + }, + "11140": { + "id": 11140, + "event": "你们分了,又处了新对象。", + "include": "EVT?[11131]" + }, + "11141": { + "id": 11141, + "event": "你天天摸鱼的工友升职加薪了,你有点怀疑人生。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11141]" + }, + "11142": { + "id": 11142, + "event": "工位厕所里加了计时器和信号屏蔽器。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11142]" + }, + "11143": { + "id": 11143, + "event": "年会上,你抽奖抽到一台iphoneZ。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11143,11144,11145]" + }, + "11144": { + "id": 11144, + "event": "年会上,你抽到一张玛莎拉蒂5元代金券。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11143,11144,11145]" + }, + "11145": { + "id": 11145, + "event": "年会上,你抽到少量现金。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11143,11144,11145]" + }, + "11146": { + "id": 11146, + "event": "团建,公司找来PUA专家展开动员大会。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11146]" + }, + "11147": { + "id": 11147, + "event": "普通的打工人生活。", + "include": "EVT?[11123,11126]" + }, + "11148": { + "id": 11148, + "event": "公司的一位领导因为涉嫌性侵被捕了。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11148,11149]" + }, + "11149": { + "id": 11149, + "event": "公司的一位领导因为涉嫌经济犯罪被捕了。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11148,11149]" + }, + "11150": { + "id": 11150, + "event": "规定出台要求强制双休。", + "postEvent": "你的工资又降低了。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11150]" + }, + "11151": { + "id": 11151, + "event": "聊天时发现新来的员工工资普遍比你高。", + "include": "EVT?[11123,11126]", + "exclude": "EVT?[11151]" + }, + "11152": { + "id": 11152, + "event": "paper日常。", + "include": "EVT?[11122]" + }, + "11153": { + "id": 11153, + "event": "给导师打杂日常。", + "include": "EVT?[11122]" + }, + "11154": { + "id": 11154, + "event": "你一天到晚泡在实验室里。", + "include": "EVT?[11122]", + "exclude": "EVT?[11154]" + }, + "11155": { + "id": 11155, + "event": "你正式步入科研。", + "include": "(INT>7)&(MNY>2)&(EVT?[11122])", + "exclude": "EVT?[11155]" + }, + "11156": { + "id": 11156, + "event": "paper日常。", + "include": "EVT?[11155]" + }, + "11157": { + "id": 11157, + "event": "给导师打杂日常。", + "include": "EVT?[11155]" + }, + "11158": { + "id": 11158, + "event": "当助教。", + "include": "EVT?[11155]", + "exclude": "EVT?[11158]" + }, + "11159": { + "id": 11159, + "event": "辅导导师家小孩功课。", + "include": "EVT?[11155]", + "exclude": "EVT?[11159]" + }, + "11160": { + "id": 11160, + "event": "实验日常。", + "include": "EVT?[11155]" + }, + "11161": { + "id": 11161, + "event": "你的压力很大,你感觉自己可能不能如期毕业。", + "include": "EVT?[11155]", + "exclude": "EVT?[11161]" + }, + "11162": { + "id": 11162, + "event": "你留校担任讲师。", + "include": "(INT>8)&(EVT?[11155])", + "exclude": "EVT?[11162]" + }, + "11163": { + "id": 11163, + "event": "你前往一所普通高校当老师。", + "include": "EVT?[11155]", + "exclude": "EVT?[11163]" + }, + "11164": { + "id": 11164, + "event": "安逸的铁饭碗生活。", + "include": "EVT?[11127]" + }, + "11165": { + "id": 11165, + "event": "你下班回家经常做一些自己喜欢的事。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[11127]", + "exclude": "EVT?[11165]" + }, + "11166": { + "id": 11166, + "event": "你有很多空闲时间,经常看短视频和玩游戏消遣。", + "include": "EVT?[11127]", + "exclude": "EVT?[11166,11167]" + }, + "11167": { + "id": 11167, + "event": "你有很多空闲时间,经常看动画消遣。", + "include": "(EVT?[11127])&(EVT?[10007,10008])", + "exclude": "EVT?[11166,11167]" + }, + "11168": { + "id": 11168, + "event": "你经常和密友小聚。", + "include": "EVT?[11127]", + "exclude": "EVT?[11168]" + }, + "11169": { + "id": 11169, + "event": "清闲的小日子。", + "include": "EVT?[11127]", + "exclude": "EVT?[11169]" + }, + "11170": { + "id": 11170, + "event": "领导要给你介绍对象,你又不好拒绝,很尴尬。", + "include": "EVT?[11127]", + "exclude": "EVT?[11170,11171]" + }, + "11171": { + "id": 11171, + "event": "你结婚了。", + "include": "EVT?[10010]", + "exclude": "(EVT?[11171,10612,11093,10229,10610,10611])|(TLT?[1027])" + }, + "11172": { + "id": 11172, + "event": "你创业失败。", + "postEvent": "家人支持你继续创业。", + "include": "EVT?[11124]", + "exclude": "EVT?[11172]" + }, + "11173": { + "id": 11173, + "event": "你得到了亲友的很多人脉支持。", + "include": "EVT?[11124]", + "exclude": "EVT?[11173]" + }, + "11174": { + "id": 11174, + "event": "你开了一家互联网公司。", + "include": "EVT?[11124]", + "exclude": "EVT?[11174,11175,11176,11177,11178]" + }, + "11175": { + "id": 11175, + "event": "你开了一家金融公司。", + "include": "EVT?[11124]", + "exclude": "EVT?[11174,11175,11176,11177,11178]" + }, + "11176": { + "id": 11176, + "event": "你开了一家二次元公司。", + "include": "(EVT?[11124])&(EVT?[10007,10008])", + "exclude": "EVT?[11174,11175,11176,11177,11178]" + }, + "11177": { + "id": 11177, + "event": "你开了一家实业公司。", + "include": "EVT?[11124]", + "exclude": "EVT?[11174,11175,11176,11177,11178]" + }, + "11178": { + "id": 11178, + "event": "你开了一家新技术产业公司。", + "include": "EVT?[11124]", + "exclude": "EVT?[11174,11175,11176,11177,11178]" + }, + "11179": { + "id": 11179, + "event": "你创业过程中结识了许多大佬。", + "include": "EVT?[11124]", + "exclude": "EVT?[11179]" + }, + "11180": { + "id": 11180, + "event": "你了解了很多行业潜规则。", + "include": "EVT?[11124]", + "exclude": "EVT?[11180]" + }, + "11181": { + "id": 11181, + "event": "你的公司福利待遇很好。", + "include": "EVT?[11124]", + "exclude": "EVT?[11181]" + }, + "11182": { + "id": 11182, + "event": "你很努力和员工一起奋斗在一线,拿和普通员工一样的钱。", + "include": "EVT?[11124]", + "exclude": "EVT?[11182]" + }, + "11183": { + "id": 11183, + "event": "人民企业家艰苦创业的日子。", + "include": "EVT?[11124]" + }, + "11184": { + "id": 11184, + "event": "虚拟现实技术得到突破,开始爆发式增长。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11184]" + }, + "11185": { + "id": 11185, + "event": "我国可控核聚变技术有所突破,离成功不远了。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11185,11263]" + }, + "11186": { + "id": 11186, + "event": "人造肉在西方迅速流行。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11186]" + }, + "11187": { + "id": 11187, + "event": "电视机逐渐淡出历史舞台。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11187]" + }, + "11188": { + "id": 11188, + "event": "全球生育率再创新低。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11188]" + }, + "11189": { + "id": 11189, + "event": "你养了一条鱼。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11190": { + "id": 11190, + "event": "你养了一只鸟。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11191": { + "id": 11191, + "event": "你养了一只乌龟。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11192": { + "id": 11192, + "event": "你养了一只仓鼠。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11193": { + "id": 11193, + "event": "你养了一只猫。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11194": { + "id": 11194, + "event": "你养了一只狗。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11195": { + "id": 11195, + "event": "你养了一只守宫。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11189,11190,11191,11192,11193,11194,11195]" + }, + "11196": { + "id": 11196, + "event": "中国成功登月。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11196]" + }, + "11197": { + "id": 11197, + "event": "我国首次夺得奥运奖牌榜奖牌总数第一。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11197]" + }, + "11198": { + "id": 11198, + "event": "为减轻生育负担,国家出台多项政策。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11198]" + }, + "11199": { + "id": 11199, + "event": "我国宣布建成社会主义现代化强国。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11199]" + }, + "11200": { + "id": 11200, + "event": "我国人均GDP超过韩国。", + "include": "EVT?[11127,11123,11126,11122,11124]", + "exclude": "EVT?[11200]" + }, + "11201": { + "id": 11201, + "event": "你的专辑《暗线》登顶。", + "include": "EVT?[10966]", + "exclude": "EVT?[11201]" + }, + "11202": { + "id": 11202, + "event": "你没有时间上课,时间表安排得很满。", + "include": "EVT?[10966]", + "exclude": "EVT?[11202]" + }, + "11203": { + "id": 11203, + "event": "你的团队开始帮助你艹粉。", + "include": "EVT?[10966]", + "exclude": "EVT?[11203,10002,10110,10111]" + }, + "11204": { + "id": 11204, + "event": "你在一次拍戏过程中意外身故。", + "include": "EVT?[10966]", + "exclude": "EVT?[11204]", + "branch": [ + "EVT?[10966]:10000" + ] + }, + "11205": { + "id": 11205, + "event": "你在一次拍戏过程中划破了手指,上了微博热搜。", + "include": "EVT?[10966]", + "exclude": "EVT?[11205]" + }, + "11206": { + "id": 11206, + "event": "有网民造你的谣,你发了律师函。", + "include": "EVT?[10966]", + "exclude": "EVT?[11206]" + }, + "11207": { + "id": 11207, + "event": "努力的演艺生涯。", + "include": "EVT?[10966]" + }, + "11208": { + "id": 11208, + "event": "你经常在贴吧上吹水。", + "include": "(MNY<7)&(EVT?[10010])", + "exclude": "EVT?[11208,10002,11211,11212]" + }, + "11209": { + "id": 11209, + "event": "你经常玩soul和小红书。", + "include": "EVT?[10010]", + "exclude": "EVT?[11209,10001,11211]" + }, + "11210": { + "id": 11210, + "event": "你经常用微博。", + "include": "EVT?[10010]", + "exclude": "EVT?[11210,11208,11211]" + }, + "11211": { + "id": 11211, + "event": "你经常用知乎。", + "include": "EVT?[10010]", + "exclude": "EVT?[11211,11209,11210,11212]" + }, + "11212": { + "id": 11212, + "event": "你经常用豆瓣。", + "include": "EVT?[10010]", + "exclude": "EVT?[11212,11211,11208]" + }, + "11213": { + "id": 11213, + "event": "你的爷爷去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11213]" + }, + "11214": { + "id": 11214, + "event": "你的奶奶去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11214]" + }, + "11215": { + "id": 11215, + "event": "你的外公去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11215]" + }, + "11216": { + "id": 11216, + "event": "你的外婆去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11216]" + }, + "11217": { + "id": 11217, + "event": "父亲因车祸去世。", + "effect": { + "MNY": -2, + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "(EVT?[11217,10868])|(TLT?[1043])" + }, + "11218": { + "id": 11218, + "event": "母亲突发心脏病去世。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "include": "EVT?[10010]", + "exclude": "(EVT?[11218,10869])|(TLT?[1044])" + }, + "11219": { + "id": 11219, + "event": "你遭遇车祸去世。", + "include": "EVT?[10010]", + "exclude": "(EVT?[11219])|(TLT?[1043])", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11220": { + "id": 11220, + "event": "你突发心脏病去世。", + "include": "(STR<2)&(EVT?[10010])", + "exclude": "(EVT?[11220])|(TLT?[1044])", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11221": { + "id": 11221, + "event": "你位列年度艺人排行第3。", + "include": "EVT?[10966]", + "exclude": "EVT?[11221]" + }, + "11222": { + "id": 11222, + "event": "你名列年度福布斯十大中国名人。", + "include": "EVT?[10966]", + "exclude": "EVT?[11222]" + }, + "11223": { + "id": 11223, + "event": "有讨厌的私生饭影响你的生活。", + "include": "EVT?[10966]", + "exclude": "EVT?[11223]" + }, + "11224": { + "id": 11224, + "event": "很多名牌都来找你拍广告。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[10966]", + "exclude": "EVT?[11224]" + }, + "11225": { + "id": 11225, + "event": "你养了一只价值数十万的猫。", + "include": "EVT?[10966]", + "exclude": "EVT?[11225]" + }, + "11226": { + "id": 11226, + "event": "你买了几辆数百万、上千万的豪车。", + "include": "EVT?[10966]", + "exclude": "EVT?[11226]" + }, + "11227": { + "id": 11227, + "event": "你买了一栋大别墅,一套汤臣一品。", + "include": "EVT?[10966]", + "exclude": "EVT?[11227]" + }, + "11228": { + "id": 11228, + "event": "国家开始打击娱乐圈。", + "include": "EVT?[10966]", + "exclude": "EVT?[11228]" + }, + "11229": { + "id": 11229, + "event": "有明星因犯罪入狱。", + "include": "EVT?[10966]", + "exclude": "EVT?[11229]" + }, + "11230": { + "id": 11230, + "event": "你因涉嫌性侵被捕。", + "effect": { + "MNY": -5 + }, + "include": "EVT?[11203]", + "exclude": "EVT?[11230]" + }, + "11231": { + "id": 11231, + "event": "你被判十年监禁,正式入狱。", + "effect": { + "CHR": -2, + "STR": -2, + "SPR": -5 + }, + "include": "EVT?[11230]", + "exclude": "EVT?[11231]" + }, + "11232": { + "id": 11232, + "event": "枯燥的监狱生活。", + "include": "EVT?[11230]", + "exclude": "EVT?[11234]" + }, + "11233": { + "id": 11233, + "event": "你出狱了。", + "postEvent": "但过往的一切都飘散如烟。", + "include": "EVT?[11230]", + "exclude": "EVT?[11233,11234]" + }, + "11234": { + "id": 11234, + "event": "你减刑提前出狱。", + "postEvent": "但过往的一切都飘散如烟。", + "include": "(EVT?[11230])&(TLT?[1117])", + "exclude": "EVT?[11234]" + }, + "11235": { + "id": 11235, + "event": "世界的变化很大,你无所适从。", + "effect": { + "INT": -1 + }, + "include": "EVT?[11233,11234]", + "exclude": "EVT?[11235]" + }, + "11236": { + "id": 11236, + "event": "你找了份普通工作勉强度日。", + "effect": { + "STR": -1, + "MNY": -1 + }, + "include": "EVT?[11235]", + "exclude": "EVT?[11236]" + }, + "11237": { + "id": 11237, + "event": "你的事业遭受沉重打击,热度不复从前。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[11229]", + "exclude": "EVT?[11237]" + }, + "11238": { + "id": 11238, + "event": "你急流勇退,转居幕后,运营公司。", + "include": "EVT?[11229]", + "exclude": "EVT?[11238]" + }, + "11239": { + "id": 11239, + "event": "你怀孕了,公司找借口把你辞退了。", + "effect": { + "MNY": -1, + "SPR": -1 + }, + "include": "(EVT?[11123,11126])&(EVT?[11171])", + "exclude": "(EVT?[11239,10001,10110,10111])|(TLT?[1041,1046])" + }, + "11240": { + "id": 11240, + "event": "你们的孩子出生了。", + "include": "EVT?[11171,11093]", + "exclude": "(EVT?[11240])|(TLT?[1041,1046])" + }, + "11241": { + "id": 11241, + "event": "你们的二胎出生了。", + "include": "EVT?[11240]", + "exclude": "EVT?[11241,11242]" + }, + "11242": { + "id": 11242, + "event": "你们的二胎出生了。", + "include": "(EVT?[11240])&(TLT?[1113])", + "exclude": "EVT?[11241,11242]" + }, + "11243": { + "id": 11243, + "event": "你们的三胎出生了。", + "include": "EVT?[11241,11242]", + "exclude": "EVT?[11243,11244]" + }, + "11244": { + "id": 11244, + "event": "你们的三胎出生了。", + "include": "(EVT?[11241,11242])&(TLT?[1113])", + "exclude": "EVT?[11243,11244]" + }, + "11245": { + "id": 11245, + "event": "照顾小孩非常麻烦。", + "include": "EVT?[11240]", + "exclude": "EVT?[11245]" + }, + "11246": { + "id": 11246, + "event": "你的生活被孩子占据了大半。", + "include": "EVT?[11240]", + "exclude": "EVT?[11246]" + }, + "11247": { + "id": 11247, + "event": "你为孩子计划未来。", + "include": "EVT?[11240]", + "exclude": "EVT?[11247]" + }, + "11248": { + "id": 11248, + "event": "工作很忙,你很难有时间照顾孩子。", + "include": "(EVT?[11123,11126])&(EVT?[11240])", + "exclude": "EVT?[11248,10002]" + }, + "11249": { + "id": 11249, + "event": "公司占据了你的私人家庭时间,但你无能为力。", + "include": "(EVT?[11123,11126])&(EVT?[11240])", + "exclude": "EVT?[11249]" + }, + "11250": { + "id": 11250, + "event": "你的科研产出被家庭事务束缚。", + "include": "(EVT?[11162,11163])&(EVT?[11240])", + "exclude": "EVT?[11250]" + }, + "11251": { + "id": 11251, + "event": "你觉得和孩子打交道比实验和论文难多了。", + "include": "(EVT?[11162,11163])&(EVT?[11240])", + "exclude": "EVT?[11251]" + }, + "11252": { + "id": 11252, + "event": "你将一套房产划到孩子名下。", + "include": "(EVT?[11124])&(EVT?[11240])", + "exclude": "EVT?[11252]" + }, + "11253": { + "id": 11253, + "event": "你像你父母一样给了孩子最丰厚的条件。", + "include": "(EVT?[11124])&(EVT?[11240])", + "exclude": "EVT?[11253]" + }, + "11254": { + "id": 11254, + "event": "你经常陪孩子玩。", + "include": "(EVT?[11127])&(EVT?[11240])", + "exclude": "EVT?[11254]" + }, + "11255": { + "id": 11255, + "event": "你给孩子买了很多玩具。", + "include": "(EVT?[11127])&(EVT?[11240])", + "exclude": "EVT?[11255]" + }, + "11256": { + "id": 11256, + "event": "你财务自由,退居幕后。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[11124]", + "exclude": "EVT?[11256]" + }, + "11257": { + "id": 11257, + "event": "你的父亲去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11257,11217,10868]" + }, + "11258": { + "id": 11258, + "event": "你的母亲去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11258,11218,10869]" + }, + "11259": { + "id": 11259, + "event": "你当上了副教授。", + "include": "EVT?[11162,11163]", + "exclude": "EVT?[11259]" + }, + "11260": { + "id": 11260, + "event": "你当上了正教授。", + "include": "EVT?[11259]", + "exclude": "EVT?[11260]" + }, + "11261": { + "id": 11261, + "event": "同学笑你是怪物。", + "effect": { + "SPR": -1 + }, + "include": "(EVT?[10110,10111])&(EVT?[10009,10010])", + "exclude": "EVT?[11261]" + }, + "11262": { + "id": 11262, + "event": "你常常因为性别而遭受暴力和冷暴力。", + "effect": { + "SPR": -1 + }, + "include": "(EVT?[10110,10111])&(EVT?[10009,10010])", + "branch": [ + "SPR<3:10062" + ] + }, + "11263": { + "id": 11263, + "event": "可控核聚变技术实现。全球迅速向无限能源时代转变。", + "include": "EVT?[10010]", + "exclude": "EVT?[11263]" + }, + "11264": { + "id": 11264, + "event": "航天技术取得巨大突破。", + "include": "EVT?[10010]", + "exclude": "EVT?[11264]" + }, + "11265": { + "id": 11265, + "event": "你前往太空旅行。", + "include": "(STR>6)&(MNY>8)&(EVT?[11264,11263])", + "exclude": "EVT?[11265]" + }, + "11266": { + "id": 11266, + "event": "你前往月球旅行。", + "include": "EVT?[11266]", + "exclude": "EVT?[11266]" + }, + "11267": { + "id": 11267, + "event": "你前往火星旅行。", + "include": "EVT?[11267]", + "exclude": "EVT?[11267]" + }, + "11268": { + "id": 11268, + "event": "你在太空旅行中意外身亡。", + "include": "EVT?[11264]", + "exclude": "EVT?[11268]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11269": { + "id": 11269, + "event": "生产资料所有制正在深刻改变,许多国家向社会主义国家过渡。", + "include": "EVT?[11263]", + "exclude": "EVT?[11269]" + }, + "11270": { + "id": 11270, + "event": "专家声称燃料是资本主义社会的基础,可控核聚变是共产主义社会的基础。", + "include": "EVT?[11263]", + "exclude": "EVT?[11270]" + }, + "11271": { + "id": 11271, + "event": "各个产业都取得了巨大的突破,一年的进步顶过去10年。", + "include": "EVT?[11263]", + "exclude": "EVT?[11271]" + }, + "11272": { + "id": 11272, + "event": "电力彻底免费。", + "postEvent": "所有燃油燃气都被电力取代。", + "include": "EVT?[11263]", + "exclude": "EVT?[11272]" + }, + "11273": { + "id": 11273, + "event": "你的公司制造出可植入大脑的芯片。可以显著提升人类记忆力。", + "include": "(EVT?[11124])&(EVT?[11263])", + "exclude": "EVT?[11273]" + }, + "11274": { + "id": 11274, + "event": "你研发出可植入大脑的芯片。可以直接将知识信息植入大脑。", + "postEvent": "你往自己大脑植入了,智力显著提升。", + "effect": { + "INT": 2 + }, + "include": "(EVT?[11162,11163])&(EVT?[11263])", + "exclude": "EVT?[11274]" + }, + "11275": { + "id": 11275, + "event": "社会内卷程度大幅降低,全球全面小康。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[11263]", + "exclude": "EVT?[11275]" + }, + "11276": { + "id": 11276, + "event": "你和一个学生发生激烈争执。", + "include": "EVT?[11162,11163]", + "exclude": "EVT?[11276]", + "branch": [ + "STR<4:21276" + ] + }, + "11277": { + "id": 11277, + "event": "因为你颜值过高,有个嫉妒的人突然从天而降把你杀了。", + "postEvent": "你死前不明白为什么那个人是从天上下来的。", + "include": "(CHR>9)&(EVT?[10010])", + "exclude": "EVT?[11277]", + "branch": [ + "STR<100:10000" + ] + }, + "11278": { + "id": 11278, + "event": "你被一个骗子骗得倾家荡产。", + "effect": { + "MNY": -5, + "SPR": -5 + }, + "include": "(INT<2)&(EVT?[10010])", + "exclude": "EVT?[11278,11318]" + }, + "11279": { + "id": 11279, + "event": "你升官了。", + "include": "EVT?[11127]", + "exclude": "EVT?[11279]" + }, + "11280": { + "id": 11280, + "event": "你经常在网上晒生活。", + "include": "(MNY>4)&(EVT?[10010])", + "exclude": "EVT?[11280]" + }, + "11281": { + "id": 11281, + "event": "Web3.0时代完全到来。", + "include": "EVT?[10010]", + "exclude": "EVT?[11281]" + }, + "11282": { + "id": 11282, + "event": "6G信号覆盖全球大多数地区。", + "include": "EVT?[10010]", + "exclude": "EVT?[11282]" + }, + "11283": { + "id": 11283, + "event": "手机消亡了,取而代之的是全息投影。", + "include": "EVT?[10010]", + "exclude": "EVT?[11283]" + }, + "11284": { + "id": 11284, + "event": "据说传送装置正在研制中。", + "include": "EVT?[11271]", + "exclude": "EVT?[11284]" + }, + "11285": { + "id": 11285, + "event": "人造食物火遍全球。", + "postEvent": "营养和味道都比天然食物更好。", + "include": "EVT?[10010]", + "exclude": "EVT?[11285]" + }, + "11286": { + "id": 11286, + "event": "你的生活日新月异,感觉时代飞速前进着。", + "include": "EVT?[11263,11281,11282,11283,11285]" + }, + "11287": { + "id": 11287, + "event": "虚拟现实技术取得巨大突破。", + "include": "EVT?[11272,11184]", + "exclude": "EVT?[11287]" + }, + "11288": { + "id": 11288, + "event": "第一个可真实进入的虚拟世界出现了。", + "postEvent": "全人类疯狂了。", + "include": "EVT?[11287]", + "exclude": "EVT?[11288]" + }, + "11289": { + "id": 11289, + "event": "你终日沉迷在虚拟世界之中。", + "postEvent": "虚拟世界中的时间过得比现实慢。", + "include": "(MNY<9)&(EVT?[11288])", + "exclude": "EVT?[11289]" + }, + "11290": { + "id": 11290, + "event": "你依靠生命维持装置活着。所有时间都在虚拟中度过。", + "postEvent": "不过世界上大多数普通人都和你一样。", + "effect": { + "CHR": -1, + "INT": -1, + "STR": -1, + "SPR": 1 + }, + "include": "EVT?[11289]", + "exclude": "EVT?[11290]" + }, + "11291": { + "id": 11291, + "event": "外界一年,虚拟世界中十年。", + "postEvent": "现实中的你越来越虚弱,虚拟中的你越来越快乐。", + "effect": { + "INT": -1, + "STR": -1, + "SPR": 1 + }, + "include": "EVT?[11290]", + "branch": [ + "(STR<0)&(INT<0):10000" + ] + }, + "11292": { + "id": 11292, + "event": "你开始投资搞虚拟现实。", + "include": "(MNY>8)&(EVT?[11288])", + "exclude": "EVT?[11292]" + }, + "11293": { + "id": 11293, + "event": "“虚拟瘾”者们失去了现实竞争力,各项能力逐渐退化。", + "postEvent": "但这对于你这样的精英来说并不是坏事。", + "include": "EVT?[11292]", + "exclude": "EVT?[11293]" + }, + "11294": { + "id": 11294, + "event": "你离婚了。", + "include": "EVT?[11171]", + "exclude": "(EVT?[11295,11294,11362,11363,11357,10270,10271,11294,20076])|(TLT?[1123])" + }, + "11295": { + "id": 11295, + "event": "你的爱人去世了。", + "include": "EVT?[11171]", + "exclude": "EVT?[11295,11294]" + }, + "11296": { + "id": 11296, + "event": "高超的洞察力使你发现:现实世界是虚拟的。", + "include": "(INT>10)&(EVT?[11288])", + "exclude": "EVT?[11296]", + "branch": [ + "INT>10:21296" + ] + }, + "11297": { + "id": 11297, + "event": "我国进入共产主义社会。", + "include": "EVT?[11263]", + "exclude": "EVT?[11297,11287]" + }, + "11298": { + "id": 11298, + "event": "第三次世界大战爆发。", + "include": "EVT?[10010]", + "exclude": "EVT?[11298]" + }, + "11299": { + "id": 11299, + "event": "超级核战争,世界毁灭了。", + "include": "(EVT?[11263])&(EVT?[11298])", + "exclude": "EVT?[11299]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11300": { + "id": 11300, + "event": "探索飞船发现了有低等生命的地外行星。", + "include": "EVT?[11264]", + "exclude": "EVT?[11300]" + }, + "11301": { + "id": 11301, + "event": "人类派遣船队去地外行星进行改造工作,便于未来殖民。", + "include": "EVT?[11300]", + "exclude": "EVT?[11301]" + }, + "11302": { + "id": 11302, + "event": "科学家声称外星上可能有未知的致命细菌或病毒,去了就不可贸然返回。", + "include": "EVT?[11300]", + "exclude": "EVT?[11302]" + }, + "11303": { + "id": 11303, + "event": "人类又发现另外三个有生命的地外行星。", + "include": "EVT?[11300]", + "exclude": "EVT?[11303]" + }, + "11304": { + "id": 11304, + "event": "有外星人乘飞船来到地球想要占领地球,却不知被谁瞬间消灭。", + "postEvent": "有传闻称地球上早就有更强大的外星人在了。", + "include": "EVT?[11300]", + "exclude": "EVT?[11304]" + }, + "11305": { + "id": 11305, + "event": "癌症被攻克了。", + "include": "EVT?[10010]", + "exclude": "EVT?[11305]" + }, + "11306": { + "id": 11306, + "event": "你因为癌症去世。", + "include": "EVT?[10010]", + "exclude": "EVT?[11306,11305]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11307": { + "id": 11307, + "event": "你重重摔了一跤。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10010]", + "branch": [ + "STR<5:10000" + ] + }, + "11308": { + "id": 11308, + "event": "你的身体状况越来越差。", + "effect": { + "STR": -1 + }, + "include": "EVT?[10010]" + }, + "11309": { + "id": 11309, + "event": "你得了不治之症去世。", + "include": "(STR<3)&(EVT?[10010])", + "exclude": "EVT?[11309]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11310": { + "id": 11310, + "event": "你在睡梦中安然离世。", + "include": "EVT?[10010]", + "exclude": "(EVT?[11310])|(TLT?[1048])", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11311": { + "id": 11311, + "event": "你的孩子去世。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11240]", + "exclude": "EVT?[11311]" + }, + "11312": { + "id": 11312, + "event": "你被人谋杀了。", + "include": "EVT?[11124]", + "exclude": "EVT?[11312]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11313": { + "id": 11313, + "event": "你因抑郁症去世。", + "include": "(SPR<2)&(EVT?[10010])", + "exclude": "EVT?[11313]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11314": { + "id": 11314, + "event": "你意外落水身亡。", + "include": "EVT?[10010]", + "exclude": "(EVT?[11314,11318])|(TLT?[1016])", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11315": { + "id": 11315, + "event": "世界大战结束了。", + "include": "EVT?[11298]", + "exclude": "EVT?[11315]" + }, + "11316": { + "id": 11316, + "event": "充满各种几乎没有成本的娱乐的老年生活。", + "include": "EVT?[11263,11281,11282,11283,11285]" + }, + "11317": { + "id": 11317, + "event": "和儿时相比,世界早已改天换地。", + "include": "EVT?[10010]", + "exclude": "EVT?[11317]" + }, + "11318": { + "id": 11318, + "event": "你因为受贿被逮捕。", + "include": "EVT?[11127]", + "exclude": "EVT?[11318]" + }, + "11319": { + "id": 11319, + "event": "因数额巨大,你被判处终身监禁。", + "effect": { + "MNY": -5, + "SPR": -5 + }, + "include": "EVT?[11318]", + "exclude": "EVT?[11319]" + }, + "11320": { + "id": 11320, + "event": "监狱生活。", + "include": "EVT?[11319]", + "exclude": "EVT?[11321,11322]" + }, + "11321": { + "id": 11321, + "event": "你获得了减刑,提前出狱。", + "include": "EVT?[11320]", + "exclude": "EVT?[11321,11322]" + }, + "11322": { + "id": 11322, + "event": "你获得了减刑,提前出狱。", + "include": "(EVT?[11320])&(TLT?[1117])", + "exclude": "EVT?[11321,11322]" + }, + "11323": { + "id": 11323, + "event": "你在狱中被人打死。", + "include": "(STR<6)&(EVT?[11320])", + "exclude": "EVT?[11321,11322]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11324": { + "id": 11324, + "event": "你因病去世。", + "include": "EVT?[11320]", + "exclude": "EVT?[11321,11322]", + "branch": [ + "EVT?[10010]:10000" + ] + }, + "11325": { + "id": 11325, + "event": "有一个按钮,按下去后你能得到大量金钱,但人类在1000年内会灭亡。", + "postEvent": "你没按。", + "include": "EVT?[10010]", + "exclude": "EVT?[11325]", + "branch": [ + "(MNY<8)&(SPR<8):21315" + ] + }, + "11326": { + "id": 11326, + "event": "科学家发现,有一颗直径20千米的小行星可能在990年后接近地球。", + "postEvent": "科学家认为它击中地球的几率非常低,不用担心。", + "include": "EVT?[21315]", + "exclude": "EVT?[11326]" + }, + "11327": { + "id": 11327, + "event": "科学家认为一颗距离我们32光年的红超巨星将在100万年内爆发。", + "include": "EVT?[21315]", + "exclude": "EVT?[11327]" + }, + "11328": { + "id": 11328, + "event": "出现了可以在虚拟世界中创造虚拟世界的虚拟游戏。", + "include": "EVT?[11287]", + "exclude": "EVT?[11328]" + }, + "11329": { + "id": 11329, + "event": "你一天有半数时间泡在虚拟世界中。", + "include": "EVT?[11287]", + "exclude": "EVT?[11293]" + }, + "11330": { + "id": 11330, + "event": "交通彻底免费了。", + "include": "EVT?[11263]", + "exclude": "EVT?[11330]" + }, + "11331": { + "id": 11331, + "event": "你去世界各地旅游。", + "include": "EVT?[11330]", + "exclude": "EVT?[11332,11333,11334]" + }, + "11332": { + "id": 11332, + "event": "你定居空间站。", + "include": "EVT?[11265]", + "exclude": "EVT?[11332,11333,11334]" + }, + "11333": { + "id": 11333, + "event": "你定居月球。", + "include": "EVT?[11266]", + "exclude": "EVT?[11332,11333,11334]" + }, + "11334": { + "id": 11334, + "event": "你定居火星。", + "include": "EVT?[11267]", + "exclude": "EVT?[11332,11333,11334]" + }, + "11335": { + "id": 11335, + "event": "▓#▓……*▓▓▓⊙▓&▓▓▓▓¥(▓▓▓*-+▓▓", + "effect": { + "INT": -1, + "STR": 1 + }, + "include": "TLT?[1128]" + }, + "11336": { + "id": 11336, + "event": "▓▓▓▓▓▓▓&……▓↖▓▓▓▓▓&*¥▓∞▓▓▓▓", + "effect": { + "INT": -1, + "MNY": 1 + }, + "include": "TLT?[1128]" + }, + "11337": { + "id": 11337, + "event": "▓▓▓▓*▓*▓▓&▓^▓^▓▓▓▓⊙▓▓▓▓▓&", + "effect": { + "INT": -1, + "SPR": 1 + }, + "include": "TLT?[1128]" + }, + "11338": { + "id": 11338, + "event": "¥%▓▓▓∞▓▓▓▓▓▓▓((**", + "effect": { + "CHR": 1, + "INT": -1 + }, + "include": "TLT?[1128]" + }, + "11339": { + "id": 11339, + "event": "▓¥@∞▓▓▓▓╱╲▓↖▓▓▓▓▓▓@@▓▓▓▓", + "effect": { + "CHR": 2, + "INT": -1 + }, + "include": "TLT?[1128]" + }, + "11340": { + "id": 11340, + "event": "▓▓▓▓▓▓▓▓▓▓▓▓……&*%+-*", + "effect": { + "INT": -1, + "STR": 2 + }, + "include": "TLT?[1128]" + }, + "11341": { + "id": 11341, + "event": "▓》《▓▓▓▓▓▓▓▓▓》》▓", + "effect": { + "INT": -1, + "MNY": 2 + }, + "include": "TLT?[1128]" + }, + "11342": { + "id": 11342, + "event": "▓▓▓“{}|▓▓▓▓▓▓—▓▓▓▓&", + "effect": { + "INT": -1, + "SPR": 2 + }, + "include": "TLT?[1128]" + }, + "11343": { + "id": 11343, + "event": ":▓▓▓:∞▓▓▓▓▓▓……╱╲▓▓▓▓》", + "effect": { + "INT": -1, + "STR": 3 + }, + "include": "TLT?[1128]" + }, + "11344": { + "id": 11344, + "event": "▓▓▓▓▓▓▓▓▓!~▓!▓+▓=▓‘", + "effect": { + "CHR": 3, + "INT": -1 + }, + "include": "TLT?[1128]" + }, + "11345": { + "id": 11345, + "event": ";’▓╱╲,▓Й*-▓▓▓", + "effect": { + "INT": -1, + "MNY": 3 + }, + "include": "TLT?[1128]" + }, + "11346": { + "id": 11346, + "event": ";【▓】▁▂▃▓▓▓▓▓▓▓▓、、▓▓▓▓▓?", + "effect": { + "INT": -1, + "SPR": 3 + }, + "include": "TLT?[1128]" + }, + "11347": { + "id": 11347, + "event": "▁▂▃▄▅▆▇█▇▆▅▄▃▂▁", + "effect": { + "INT": -1 + }, + "include": "TLT?[1128]", + "branch": [ + "TLT?[1128]:10000" + ] + }, + "11348": { + "id": 11348, + "event": "★☆↑◎¤★☆◎↑¤★☆◎¤◎↑¤★☆↑", + "effect": { + "INT": -1 + }, + "include": "TLT?[1128]", + "branch": [ + "TLT?[1128]:10000" + ] + }, + "11349": { + "id": 11349, + "event": "你没有这段记忆。", + "include": "TLT?[1129]" + }, + "11350": { + "id": 11350, + "event": "婚后你的丈夫没有之前对你那么好了。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11350,11357,11358,11359,11360,11361,11362,11363,11295]" + }, + "11351": { + "id": 11351, + "event": "家务几乎全是你在干。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11351,11357,11358,11359,11360,11361,11362,11363,11295]" + }, + "11352": { + "id": 11352, + "event": "丈夫和你见面的时间越来越少。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11352,11357,11358,11359,11360,11361,11362,11363,11295]" + }, + "11353": { + "id": 11353, + "event": "结婚周年纪念日,丈夫给了你一个红包,没有准备礼物。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11353,11357,11358,11359,11360,11361,11362,11363,11295]" + }, + "11354": { + "id": 11354, + "event": "你和婆婆吵架,丈夫站在婆婆那边。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11354,11357,11358,11359,11360,11361,11295,11362,11363]" + }, + "11355": { + "id": 11355, + "event": "你怀疑丈夫有外遇。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11355,11357,11358,11359,11360,11361,11295,11362,11363]" + }, + "11356": { + "id": 11356, + "event": "你经常在一个群里和大家一起吐槽婚后生活。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11356,11357,11358,11359,11360,11295,11361,11362,11363]" + }, + "11357": { + "id": 11357, + "event": "你的丈夫对你始终如一。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11357,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11358": { + "id": 11358, + "event": "结婚周年纪念日,你们一家出去旅游。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11358,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11359": { + "id": 11359, + "event": "丈夫的父母通情达理,和你关系如同朋友。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11359,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11360": { + "id": 11360, + "event": "闺蜜向你吐槽她的丈夫多么不好。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11360,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11361": { + "id": 11361, + "event": "丈夫做了大多数家务,做菜还特别好吃。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11361,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11362": { + "id": 11362, + "event": "丈夫特别尊重你的意见,大多数家事都请你做决定。", + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11362,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11363": { + "id": 11363, + "event": "每天睡前你们都会聊很长时间的天。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[11171]", + "exclude": "EVT?[10001,11294,11363,11350,11351,11352,11353,11295,11354,11355,11356]" + }, + "11364": { + "id": 11364, + "event": "很少有时间陪伴家人,你有些愧疚。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11364]" + }, + "11365": { + "id": 11365, + "event": "你的妻子把行动不便的父母接到你们家里住。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11365]" + }, + "11366": { + "id": 11366, + "event": "你每月都上缴工资给妻子。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11366,11367]" + }, + "11367": { + "id": 11367, + "event": "你们家的生活费采用AA。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11366,11367]" + }, + "11368": { + "id": 11368, + "event": "自从结婚后,你上网和娱乐时间越来越少了。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11368]" + }, + "11369": { + "id": 11369, + "event": "你无微不至地照顾照顾妻子。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11295,11369]" + }, + "11370": { + "id": 11370, + "event": "你和妻子之间更像是朋友。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11370,11295]" + }, + "11371": { + "id": 11371, + "event": "妻子的一个亲戚沉迷赌博,骗了她娘家不少钱。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11371,11295]" + }, + "11372": { + "id": 11372, + "event": "妻子的父亲去世,继承了一些遗产。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[11365]", + "exclude": "EVT?[10002,11294,11372,11295]" + }, + "11373": { + "id": 11373, + "event": "婚前的彩礼全部用于运营你们的小家。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11373,11295]" + }, + "11374": { + "id": 11374, + "event": "你考了驾照。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11374,11295]" + }, + "11375": { + "id": 11375, + "event": "妻子经常和你一起看动画。", + "include": "(EVT?[11171])&(EVT?[10007,10008])", + "exclude": "EVT?[10002,11294,11375,11295]" + }, + "11376": { + "id": 11376, + "event": "你经常和妻子一起看综艺和电视剧。", + "include": "EVT?[11171]", + "exclude": "EVT?[10002,11294,11376,11295]" + }, + "11377": { + "id": 11377, + "event": "孩子的健康状况不太好,你们家操碎了心。", + "include": "EVT?[11240]", + "exclude": "EVT?[11294,11295,11377]" + }, + "11378": { + "id": 11378, + "event": "可能是遗传你,孩子不大聪明的样子。", + "include": "(INT<4)&(EVT?[11240])", + "exclude": "EVT?[11378]" + }, + "11379": { + "id": 11379, + "event": "可能是遗传你,孩子非常聪明。", + "include": "(INT>6)&(EVT?[11240])", + "exclude": "EVT?[11379]" + }, + "11380": { + "id": 11380, + "event": "可能是遗传你,孩子不大好看。", + "include": "(CHR<4)&(EVT?[11240])", + "exclude": "EVT?[11380]" + }, + "11381": { + "id": 11381, + "event": "可能是遗传你,孩子非常好看。", + "include": "(CHR>6)&(EVT?[11240])", + "exclude": "EVT?[11381]" + }, + "11382": { + "id": 11382, + "event": "孩子不小心烫伤了。", + "include": "EVT?[11240]", + "exclude": "EVT?[11382]" + }, + "11383": { + "id": 11383, + "event": "孩子得了重病,家里花了很多钱。", + "effect": { + "MNY": -1 + }, + "include": "EVT?[11240]", + "exclude": "EVT?[11383]" + }, + "11384": { + "id": 11384, + "event": "你第一次揍孩子。", + "include": "EVT?[11240]", + "exclude": "EVT?[11384]" + }, + "11385": { + "id": 11385, + "event": "你们带着孩子一起旅游。", + "effect": { + "SPR": 1 + }, + "include": "EVT?[11240]", + "exclude": "EVT?[11294,11295,11385]" + }, + "11386": { + "id": 11386, + "event": "为孩子准备升学考试,家里更忙了。", + "include": "EVT?[11240]", + "exclude": "EVT?[11386]" + }, + "11387": { + "id": 11387, + "event": "孩子在学校闯祸了,你去挨老师批评。", + "include": "EVT?[11240]", + "exclude": "EVT?[11387]" + }, + "11388": { + "id": 11388, + "event": "孩子成绩退步了,你决定切断孩子的一切娱乐活动。", + "include": "EVT?[11240]", + "exclude": "EVT?[11388]" + }, + "11389": { + "id": 11389, + "event": "学校不允许排成绩,但你还是设法弄到了排名。", + "include": "EVT?[11240]", + "exclude": "EVT?[11389]" + }, + "11390": { + "id": 11390, + "event": "孩子的英语出奇的好。", + "include": "EVT?[11240]", + "exclude": "EVT?[11390]" + }, + "11391": { + "id": 11391, + "event": "孩子喜欢上了看动漫。", + "include": "EVT?[11240]", + "exclude": "EVT?[11391]" + }, + "11392": { + "id": 11392, + "event": "孩子在学校早恋,你十分生气。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[11240]", + "exclude": "EVT?[11392]" + }, + "11393": { + "id": 11393, + "event": "孩子的成绩进步了。", + "include": "EVT?[11240]", + "exclude": "EVT?[11393]" + }, + "11394": { + "id": 11394, + "event": "政府宣布禁止开办补习班。", + "include": "EVT?[11240]", + "exclude": "EVT?[11394]" + }, + "11395": { + "id": 11395, + "event": "政府发文件要求学校放学不得晚于下午5点。", + "include": "EVT?[11240]", + "exclude": "EVT?[11395]" + }, + "11396": { + "id": 11396, + "event": "教育体系对体育越发重视,你们经常要抽时间带孩子去运动。", + "include": "EVT?[11240]", + "exclude": "EVT?[11294,11295,11396]" + }, + "11397": { + "id": 11397, + "event": "参加家长会,你的颜值震惊全场,直接有家长要你的联系方式。", + "include": "(CHR>8)&(EVT?[11240])", + "exclude": "EVT?[11397]" + }, + "11398": { + "id": 11398, + "event": "你的智慧指导孩子功课绰绰有余。", + "include": "(INT>6)&(EVT?[11240])", + "exclude": "EVT?[11398]" + }, + "11399": { + "id": 11399, + "event": "你发现孩子学的东西连你都不会。", + "include": "(INT<4)&(EVT?[11240])", + "exclude": "EVT?[11399]" + }, + "11400": { + "id": 11400, + "event": "你的家庭越来越困难,温饱都成问题。", + "include": "(MNY<3)&(EVT?[10010])", + "exclude": "EVT?[11400,11401]" + }, + "11401": { + "id": 11401, + "event": "你买彩票中了奖。家境回暖。", + "effect": { + "MNY": 1 + }, + "include": "(MNY<3)&(EVT?[10010])", + "exclude": "EVT?[11401]" + }, + "11402": { + "id": 11402, + "event": "因为很有钱,总是有人和你家攀亲戚。", + "include": "(MNY>7)&(EVT?[10010])", + "exclude": "EVT?[11402]" + }, + "11403": { + "id": 11403, + "event": "总是有人找你借钱。", + "include": "(MNY>5)&(EVT?[10010])", + "exclude": "EVT?[11403]" + }, + "11404": { + "id": 11404, + "event": "你感觉自己的知识有些跟不上时代。", + "include": "(INT<4)&(EVT?[10010])", + "exclude": "EVT?[11404]" + }, + "11405": { + "id": 11405, + "event": "你总是能跟上时代的潮流。", + "include": "(INT>6)&(EVT?[10010])", + "exclude": "EVT?[11405]" + }, + "11406": { + "id": 11406, + "event": "你的健康状况非常不好。", + "include": "(STR<3)&(EVT?[10010])", + "exclude": "EVT?[11406]" + }, + "11407": { + "id": 11407, + "event": "你的精神状况非常不好。", + "include": "(SPR<3)&(EVT?[10010])", + "exclude": "EVT?[11407]" + }, + "11408": { + "id": 11408, + "event": "你依然和年轻时一样强壮。", + "include": "(STR>7)&(EVT?[10010])", + "exclude": "EVT?[11408]" + }, + "11409": { + "id": 11409, + "event": "有健美杂志找你做模特。", + "include": "(STR>8)&(EVT?[10010])", + "exclude": "EVT?[11409]" + }, + "11410": { + "id": 11410, + "event": "你家买了最新款的飞车。", + "include": "(MNY>7)&(EVT?[10010])", + "exclude": "EVT?[11410]" + }, + "11411": { + "id": 11411, + "event": "你家里家具设施弄了全套物联网。", + "include": "(MNY>5)&(EVT?[10010])", + "exclude": "EVT?[11411]" + }, + "11412": { + "id": 11412, + "event": "总有人问你是不是整过容。", + "include": "(CHR>7)&(EVT?[10010])", + "exclude": "EVT?[11412]" + }, + "11413": { + "id": 11413, + "event": "因为相貌不佳,生活中平添了不少麻烦。", + "include": "(CHR<4)&(EVT?[10010])", + "exclude": "EVT?[11413]" + }, + "11414": { + "id": 11414, + "event": "生物学家突破性完成了猫狗杂交实验。", + "include": "EVT?[10010]", + "exclude": "EVT?[11414]" + }, + "11415": { + "id": 11415, + "event": "反环保团体在西方国家游行。", + "include": "EVT?[10010]", + "exclude": "EVT?[11415]" + }, + "11416": { + "id": 11416, + "event": "美国掀起第四次女性主义浪潮。", + "include": "EVT?[10010]", + "exclude": "EVT?[11416,11263,11288]" + }, + "11417": { + "id": 11417, + "event": "一位哲学家开辟了虚拟主义哲学,从世界是虚拟游戏为起点建构了整个体系。", + "include": "EVT?[10010]", + "exclude": "EVT?[11417,11263,11288]" + }, + "11418": { + "id": 11418, + "event": "国家统一全国户口。", + "include": "EVT?[10010]", + "exclude": "EVT?[11418]" + }, + "11419": { + "id": 11419, + "event": "国家进一步推出限制未成年人消费的法案。", + "include": "EVT?[10010]", + "exclude": "EVT?[11419]" + }, + "11420": { + "id": 11420, + "event": "生物学家宣称,因为人类过于依赖人造工具,人类天生的工具眼耳手脚等已经停止进化了。", + "include": "EVT?[10010]", + "exclude": "EVT?[11420]" + }, + "11421": { + "id": 11421, + "event": "为保护言论自由,国家发文禁止媒体设置“评论精选”功能。", + "include": "EVT?[10010]", + "exclude": "EVT?[11421]" + }, + "11422": { + "id": 11422, + "event": "学者研究发现,人的意识可能是模因复制过程中的副产物。", + "include": "EVT?[10010]", + "exclude": "EVT?[11422]" + }, + "11423": { + "id": 11423, + "event": "美国为保护人权,禁止出版以“他人的出丑或不幸”作为笑点的作品。", + "postEvent": "谐音梗开始统治影视界。", + "include": "EVT?[10010]", + "exclude": "EVT?[11423]" + }, + "11424": { + "id": 11424, + "event": "调查显示,84%的人认为自己的颜值是“中上”。", + "include": "EVT?[10010]", + "exclude": "EVT?[11424,11425,11426,11263,11288]" + }, + "11425": { + "id": 11425, + "event": "调查显示,50%的人认为自己比大多数人多点儿小聪明,另外30%的人认为自己的智商显著优于身边的人。", + "include": "EVT?[10010]", + "exclude": "EVT?[11424,11425,11426,11263,11288]" + }, + "11426": { + "id": 11426, + "event": "调查显示,75%的人认为自己的人品好过绝大多数人。", + "postEvent": "专家表示可能与报道犯罪的新闻过多有关。", + "include": "EVT?[10010]", + "exclude": "EVT?[11424,11425,11426,11263,11288]" + }, + "11427": { + "id": 11427, + "event": "你前两年开始使用的一个小众线上社交平台,现在突然火了。", + "postEvent": "但你感觉平台内的环境一下子乌烟瘴气起来,你很怀念两年前的样子。", + "include": "EVT?[10010]", + "exclude": "EVT?[11427,11263,11288]" + }, + "11428": { + "id": 11428, + "event": "一位社会学家发表《人类永生时代的社会学》,引起轰动。", + "include": "EVT?[10010]", + "exclude": "EVT?[11428]" + }, + "11429": { + "id": 11429, + "event": "有研究表明,历史上所有的生命都可以算成一个个体的一部分。", + "include": "EVT?[10010]", + "exclude": "EVT?[11429]" + }, + "11430": { + "id": 11430, + "event": "诺贝尔奖停办了。", + "include": "EVT?[10010]", + "exclude": "EVT?[11430]" + }, + "11431": { + "id": 11431, + "event": "欧盟合并成了一个国家。", + "include": "EVT?[10010]", + "exclude": "EVT?[11431]" + }, + "11432": { + "id": 11432, + "event": "印度成为了联合国第六常。", + "include": "EVT?[10010]", + "exclude": "EVT?[11432,11433]" + }, + "11433": { + "id": 11433, + "event": "联合国解散了。", + "include": "EVT?[10010]", + "exclude": "EVT?[11433]" + }, + "11434": { + "id": 11434, + "event": "朝鲜统一韩国。", + "include": "EVT?[10010]", + "exclude": "EVT?[11434]" + }, + "11435": { + "id": 11435, + "event": "教师行业越来越受到重视,教师工资显著提高。", + "include": "EVT?[10010]", + "exclude": "EVT?[11435]" + }, + "11436": { + "id": 11436, + "event": "国家宣布演员歌手收入需按工资发放,且不得超过当地公务员平均工资的三倍。", + "include": "EVT?[10010]", + "exclude": "EVT?[11436]" + }, + "11437": { + "id": 11437, + "event": "动物保护组织游行,宣传放猫狗宠物自由。", + "include": "EVT?[10010]", + "exclude": "EVT?[11437]" + }, + "11438": { + "id": 11438, + "event": "肉食主义者游行抗议没有纯肉餐厅。", + "include": "EVT?[10010]", + "exclude": "EVT?[11438,11263,11288]" + }, + "11439": { + "id": 11439, + "event": "世界第一个八星级酒店在空间站建成。", + "postEvent": "在上面能看到八大行星。", + "include": "EVT?[10010]", + "exclude": "EVT?[11439,11263,11288]" + }, + "11440": { + "id": 11440, + "event": "广州出现十几平方公里大的巨型蟑螂。", + "include": "EVT?[10010]", + "exclude": "EVT?[11440]" + }, + "11441": { + "id": 11441, + "event": "某游戏公司向教会出资,将圣经中的“诺亚”冠名成“明日”。", + "include": "EVT?[10010]", + "exclude": "EVT?[11441]" + }, + "11442": { + "id": 11442, + "event": "有学者预言:22世纪是生物的世纪。", + "include": "EVT?[10010]", + "exclude": "EVT?[11442]" + }, + "11443": { + "id": 11443, + "event": "由于“缩写效应”,汉语已经简化为纯字母语言。", + "include": "EVT?[10010]", + "exclude": "EVT?[11443]" + }, + "11444": { + "id": 11444, + "event": "美国将小学入学年龄推迟到10-12岁。", + "include": "EVT?[10010]", + "exclude": "EVT?[11444]" + }, + "11445": { + "id": 11445, + "event": "本地一醉酒男子路边被人侵犯,媒体称原因是其衣着暴露。", + "include": "EVT?[10010]", + "exclude": "EVT?[11445,11263,11288]" + }, + "11446": { + "id": 11446, + "event": "无声音乐开始流行。", + "postEvent": "第一个无声音乐会在维也纳金色大厅举行。", + "include": "EVT?[10010]", + "exclude": "EVT?[11446]" + }, + "11447": { + "id": 11447, + "event": "生育率仍在下降,国家取消了父母生育前需要考试的规定。", + "include": "EVT?[10010]", + "exclude": "EVT?[11447]" + }, + "11448": { + "id": 11448, + "event": "物理学家发现地球可能真的是宇宙的中心。", + "include": "EVT?[10010]", + "exclude": "EVT?[11448]" + }, + "11449": { + "id": 11449, + "event": "前领导人打破最长寿的人吉尼斯纪录。", + "include": "EVT?[10010]", + "exclude": "EVT?[11449]" + }, + "11450": { + "id": 11450, + "event": "一颗小行星即将击中地球时突然折返离开。", + "postEvent": "专家称可能有人许了什么离谱的愿望。", + "include": "EVT?[10010]", + "exclude": "EVT?[11450]" + }, + "11451": { + "id": 11451, + "event": "你使用魔法棒,变身成了魔法少女。", + "postEvent": "你变强了,但从此你要履行身为魔法少女的使命……", + "effect": { + "STR": 80 + }, + "include": "(TLT?[1131])&(EVT?[10002])&(EVT?[10007,10008])" + }, + "11452": { + "id": 11452, + "event": "你和人类看不见的怪物战斗。", + "include": "EVT?[11451]", + "exclude": "EVT?[21457]" + }, + "11453": { + "id": 11453, + "event": "你守护着这个星球。", + "include": "EVT?[11451]", + "exclude": "EVT?[21457]" + }, + "11454": { + "id": 11454, + "event": "你不再是少女,魔法棒离开了你寻找下一个主人。", + "postEvent": "你的魔法少女生涯结束了,魔力也都消散了,你变回了普通人。", + "include": "EVT?[11451]", + "exclude": "EVT?[21457,11454]" + }, + "11455": { + "id": 11455, + "event": "你和侵入地球的银河帝王战斗。它十分强大。", + "postEvent": "但你还是赢了。", + "include": "EVT?[11456]", + "exclude": "EVT?[11455,21457]", + "branch": [ + "STR<88:10000" + ] + }, + "11456": { + "id": 11456, + "event": "一个外星人来地球宣称要统治地球,被你秒杀。", + "include": "EVT?[11451]", + "exclude": "EVT?[11456,21457]" + }, + "11457": { + "id": 11457, + "event": "你遭到了触手女王的攻击。", + "postEvent": "你消灭了触手女王。", + "include": "EVT?[11451]", + "exclude": "EVT?[11457,21457]", + "branch": [ + "INT<5:21457" + ] + }, + "11458": { + "id": 11458, + "event": "你在地球上肆意破坏。", + "include": "EVT?[21457]" + }, + "11459": { + "id": 11459, + "event": "你引诱其他魔法少女恶堕。", + "include": "EVT?[21457]" + }, + "11460": { + "id": 11460, + "event": "你摧毁了美国。", + "include": "EVT?[21457]", + "exclude": "EVT?[11460]" + }, + "11461": { + "id": 11461, + "event": "你摧毁了英国。", + "include": "EVT?[21457]", + "exclude": "EVT?[11461]" + }, + "11462": { + "id": 11462, + "event": "法国臣服在你裙下。", + "include": "EVT?[21457]", + "exclude": "EVT?[11462]" + }, + "11463": { + "id": 11463, + "event": "你消灭了日本所有的男性。", + "include": "EVT?[21457]", + "exclude": "EVT?[11463]" + }, + "11464": { + "id": 11464, + "event": "你摧毁了俄罗斯。", + "include": "EVT?[21457]", + "exclude": "EVT?[11464]" + }, + "11465": { + "id": 11465, + "event": "你遭遇了一个强大的魔法少女。", + "postEvent": "你拼尽全力杀死了对方,并吸取了她的魔力。", + "effect": { + "STR": 88 + }, + "include": "EVT?[21457]", + "exclude": "EVT?[11465]", + "branch": [ + "STR<88:10000" + ] + }, + "11466": { + "id": 11466, + "event": "一个会飞的人对你出手,他称自己是筑基期修士。", + "postEvent": "苦战后你杀死了对方。", + "include": "EVT?[21457]", + "exclude": "EVT?[11466]", + "branch": [ + "STR<100:10000" + ] + }, + "11467": { + "id": 11467, + "event": "一个会飞的人对你出手,他称自己是渡劫期修士。", + "postEvent": "你还没看清对方怎么出手就失去了意识。", + "include": "EVT?[21457]", + "exclude": "EVT?[11467]", + "branch": [ + "STR<2000:10000" + ] + }, + "11468": { + "id": 11468, + "event": "时光突然倒流了。", + "effect": { + "AGE": -5 + }, + "include": "TLT?[1133]" + }, + "11469": { + "id": 11469, + "event": "你突然回到了年轻的时候。", + "effect": { + "AGE": -50 + }, + "include": "TLT?[1132]", + "exclude": "EVT?[11469]" + }, + "20007": { + "id": 20007, + "event": "你喜欢看画面人设好看的动漫。", + "NoRandom": 1 + }, + "20008": { + "id": 20008, + "event": "你喜欢看剧情棒的动漫。", + "NoRandom": 1 + }, + "20028": { + "id": 20028, + "event": "有次你不小心摔倒撞到了脑袋,智力略微受损。", + "effect": { + "INT": -1 + }, + "NoRandom": 1 + }, + "20029": { + "id": 20029, + "event": "看在你长得可爱的份上家人不和你计较。", + "NoRandom": 1 + }, + "20035": { + "id": 20035, + "event": "你大姐偷偷告诉你,她一点也不喜欢男方。", + "NoRandom": 1 + }, + "20036": { + "id": 20036, + "event": "你的大姐自杀了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[20035]", + "exclude": "EVT?[20036]" + }, + "20037": { + "id": 20037, + "event": "你轻松打上了王者。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20038": { + "id": 20038, + "event": "你打上了黄金段位。", + "NoRandom": 1 + }, + "20048": { + "id": 20048, + "event": "有亲戚笑你画的比长的好看多了。", + "NoRandom": 1 + }, + "20049": { + "id": 20049, + "event": "有亲戚遗憾地说你声音很好听,可惜长得太丑了。", + "NoRandom": 1 + }, + "20053": { + "id": 20053, + "event": "虽然你是男孩子,但并不抗拒。", + "NoRandom": 1 + }, + "20054": { + "id": 20054, + "event": "你喜欢上了女装。", + "effect": { + "CHR": 1, + "SPR": 1 + }, + "include": "EVT?[20053]", + "exclude": "EVT?[20054]" + }, + "20055": { + "id": 20055, + "event": "你业余时间在家当女装主播。", + "effect": { + "MNY": 1 + }, + "include": "EVT?[20054]", + "exclude": "EVT?[20055]", + "branch": [ + "MNY<6:20056" + ] + }, + "20056": { + "id": 20056, + "event": "并且有时还接单。", + "effect": { + "MNY": 2 + }, + "NoRandom": 1 + }, + "20075": { + "id": 20075, + "event": "可惜智力低了些。", + "NoRandom": 1 + }, + "20076": { + "id": 20076, + "event": "你们离婚了。", + "NoRandom": 1 + }, + "20091": { + "id": 20091, + "event": "你发明了颜值提升机,大幅提高了颜值。", + "effect": { + "CHR": 5 + }, + "NoRandom": 1 + }, + "20092": { + "id": 20092, + "event": "你发明了许多有用的小东西,卖了不少钱。", + "effect": { + "MNY": 2 + }, + "NoRandom": 1 + }, + "20186": { + "id": 20186, + "event": "你的性格也很叛逆,和他们一见如故。", + "NoRandom": 1 + }, + "20213": { + "id": 20213, + "event": "由于你喜欢没事找事,你也试着翻围墙,结果也死了。", + "NoRandom": 1, + "branch": [ + "EVT?[10101]:10000" + ] + }, + "20215": { + "id": 20215, + "event": "你想离近点看,结果被流弹击中。", + "NoRandom": 1, + "branch": [ + "EVT?[10009]:10000" + ] + }, + "20296": { + "id": 20296, + "event": "你花钱在周边转了转,但没余力走更远了。", + "effect": { + "MNY": -1 + } + }, + "20317": { + "id": 20317, + "event": "为了能和年轻人有共同语言,你开始了解潮流。", + "NoRandom": 1 + }, + "20332": { + "id": 20332, + "event": "你遭到了一个恶堕的魔法少女,并展开战斗。", + "postEvent": "你战胜了她。", + "effect": { + "SPR": 1 + }, + "include": "TLT?[1048]", + "exclude": "EVT?[20332]", + "branch": [ + "STR<88:10000" + ] + }, + "20333": { + "id": 20333, + "event": "你意外得到了一个元婴修士的传承。", + "effect": { + "INT": 10, + "STR": 100 + }, + "include": "(INT>9)&(TLT?[1048])", + "exclude": "EVT?[20333]" + }, + "20334": { + "id": 20334, + "event": "你参加一个宗派的入门大比。", + "postEvent": "没有成功。", + "include": "TLT?[1048]", + "exclude": "EVT?[20334]", + "branch": [ + "STR<20:20335" + ] + }, + "20335": { + "id": 20335, + "event": "你通过大比,成为了外门弟子。", + "NoRandom": 1 + }, + "20336": { + "id": 20336, + "event": "你外出执行宗门任务。", + "postEvent": "没有成功,返回宗门。", + "include": "EVT?[20335]", + "exclude": "EVT?[20336]", + "branch": [ + "(STR>30)&(INT>7):20337", + "(STR<25)&(INT<5):10000" + ] + }, + "20337": { + "id": 20337, + "event": "你顺利完成任务,获得奖励。", + "effect": { + "STR": 20, + "MNY": 2 + }, + "NoRandom": 1 + }, + "20338": { + "id": 20338, + "event": "你服用了宗门发放的养颜丹。颜值提升。", + "effect": { + "CHR": 5 + }, + "include": "EVT?[20335]" + }, + "20339": { + "id": 20339, + "event": "你喜欢上了宗门的一个小师妹。", + "include": "((EVT?[20335])&(EVT?[10001]))|((EVT?[20335])&(EVT?[10002])&(TLT?[1026]))", + "exclude": "(EVT?[20339])|(TLT?[1027,1134])" + }, + "20340": { + "id": 20340, + "event": "你喜欢的小师妹在一次外出执行任务中,被一个筑基修士斩杀了。", + "effect": { + "SPR": -1 + }, + "include": "EVT?[20339]", + "exclude": "EVT?[20340]", + "branch": [ + "STR>100:20341" + ] + }, + "20341": { + "id": 20341, + "event": "你外出寻找那个筑基修士报仇。", + "NoRandom": 1 + }, + "20342": { + "id": 20342, + "event": "你找到了那个杀害小师妹的修士,并与之战斗。", + "include": "EVT?[20341]", + "exclude": "EVT?[20342]", + "branch": [ + "STR>119:20343", + "STR<120:10000" + ] + }, + "20343": { + "id": 20343, + "event": "你斩杀了筑基修士,获得少量宝物,和小师妹的一枚戒指。", + "effect": { + "STR": 5 + }, + "NoRandom": 1 + }, + "20344": { + "id": 20344, + "event": "你参加宗门内部大比。", + "postEvent": "在过程中被淘汰。", + "include": "EVT?[20335]", + "exclude": "EVT?[20345]", + "branch": [ + "STR>30:20345" + ] + }, + "20345": { + "id": 20345, + "event": "你晋升成了内门弟子。", + "effect": { + "STR": 5, + "MNY": 1, + "SPR": 1 + }, + "NoRandom": 1 + }, + "20346": { + "id": 20346, + "event": "你参加内门弟子大比。", + "postEvent": "在过程中被淘汰。", + "include": "EVT?[20345]", + "exclude": "EVT?[20347,20348]", + "branch": [ + "STR>150:20348", + "STR>100:20347" + ] + }, + "20347": { + "id": 20347, + "event": "你晋升成了核心弟子。", + "effect": { + "STR": 10, + "MNY": 1, + "SPR": 1 + }, + "NoRandom": 1 + }, + "20348": { + "id": 20348, + "event": "你被宗门长老收为亲传弟子。", + "effect": { + "STR": 20, + "MNY": 2, + "SPR": 1 + }, + "NoRandom": 1 + }, + "20367": { + "id": 20367, + "event": "你悟出了一条天道!", + "postEvent": "属性大幅提升。", + "effect": { + "INT": 100, + "STR": 1000, + "SPR": 10 + }, + "include": "(EVT?[10365])&(INT>520)&(TLT?[1048])" + }, + "20409": { + "id": 20409, + "event": "你没有扛过这一劫。灵魂碎片侥幸逃出,你转世重生了。", + "postEvent": "身体变弱,记忆尽失,但你的道之境界还在。", + "effect": { + "STR": -1000, + "AGE": -500 + }, + "NoRandom": 1 + }, + "20410": { + "id": 20410, + "event": "你还喜欢在萌战吧、S1和bangumi茶话会发钓鱼帖。", + "effect": { + "SPR": 2 + }, + "NoRandom": 1 + }, + "20411": { + "id": 20411, + "event": "你还喜欢在B站评论区和人撕逼然后截图挂QQ群。", + "NoRandom": 1 + }, + "20412": { + "id": 20412, + "event": "你经常抽时间帮爱豆刷数据。", + "NoRandom": 1 + }, + "20413": { + "id": 20413, + "event": "你追的爱豆塌房了,被全网封禁。", + "effect": { + "SPR": -1 + }, + "NoRandom": 1 + }, + "20414": { + "id": 20414, + "event": "该明星恰好是你家爱豆。你崩溃了。", + "effect": { + "SPR": -1 + }, + "NoRandom": 1 + }, + "20415": { + "id": 20415, + "event": "你无语,你当年怎么没这么好的事儿。", + "NoRandom": 1 + }, + "20417": { + "id": 20417, + "event": "你寻思这也不是很难啊。", + "NoRandom": 1 + }, + "20418": { + "id": 20418, + "event": "你压根儿不知道塔利班和华盛顿是啥东西。", + "NoRandom": 1 + }, + "20419": { + "id": 20419, + "event": "你压根儿不知道本·拉登是啥东西。", + "NoRandom": 1 + }, + "20421": { + "id": 20421, + "event": "然后被你斥巨资购买了。", + "effect": { + "MNY": -2 + }, + "NoRandom": 1 + }, + "20422": { + "id": 20422, + "event": "直觉告诉你事情没这么简单。", + "NoRandom": 1 + }, + "20423": { + "id": 20423, + "event": "有知情人告诉你不是交通事故,好像是一个在天上飞的人……", + "NoRandom": 1 + }, + "20425": { + "id": 20425, + "event": "你意识到这场地震并不寻常……", + "NoRandom": 1 + }, + "20426": { + "id": 20426, + "event": "但据你所知,并没有出动军队和武器,好像只派了少量的“人”?", + "NoRandom": 1 + }, + "20431": { + "id": 20431, + "event": "你认为这是虚假消息。", + "NoRandom": 1 + }, + "20432": { + "id": 20432, + "event": "你试着玩了玩并且充了点钱,啥好角色都抽不到。", + "NoRandom": 1 + }, + "20433": { + "id": 20433, + "event": "还好你不玩网易游戏。", + "NoRandom": 1 + }, + "20436": { + "id": 20436, + "event": "笑死,一个都不生。", + "NoRandom": 1 + }, + "20437": { + "id": 20437, + "event": "你终于可以呼吸到新鲜空气了。", + "NoRandom": 1 + }, + "20439": { + "id": 20439, + "event": "据说他们没有使用飞机、舰船和炮弹。", + "NoRandom": 1, + "branch": [ + "(CHR>8)&(STR>8):20439" + ] + }, + "20443": { + "id": 20443, + "event": "但你家还是很穷,而且也不算幸福。", + "NoRandom": 1 + }, + "20444": { + "id": 20444, + "event": "但你家还是很穷。", + "NoRandom": 1 + }, + "20448": { + "id": 20448, + "event": "你感觉太离谱了。", + "NoRandom": 1 + }, + "20452": { + "id": 20452, + "event": "可恶的天龙人。", + "NoRandom": 1 + }, + "20453": { + "id": 20453, + "event": "你感觉又有乐子了。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20454": { + "id": 20454, + "event": "你预测那里还存在一种花,吃了可以发射火球。", + "NoRandom": 1 + }, + "20456": { + "id": 20456, + "event": "你感到很高兴。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20459": { + "id": 20459, + "event": "你觉得太荒谬了。", + "NoRandom": 1 + }, + "20460": { + "id": 20460, + "event": "你突然感觉人生无憾了。", + "NoRandom": 1 + }, + "20529": { + "id": 20529, + "event": "你拿了第一名。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20534": { + "id": 20534, + "event": "你跳出来管他们,被其中一个学生掏枪打死了。", + "NoRandom": 1 + }, + "20557": { + "id": 20557, + "event": "你父母在家给你买了一台天文望远镜。", + "NoRandom": 1 + }, + "20558": { + "id": 20558, + "event": "你过人的颜值和舞技让你成为万众瞩目。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20565": { + "id": 20565, + "event": "你的创业最成功。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "20568": { + "id": 20568, + "event": "你考得很差。", + "effect": { + "SPR": -1 + }, + "NoRandom": 1 + }, + "20569": { + "id": 20569, + "event": "但你还是考了第一。", + "NoRandom": 1 + }, + "20572": { + "id": 20572, + "event": "你父母忍痛给你买了一个。", + "NoRandom": 1 + }, + "20574": { + "id": 20574, + "event": "你感觉非常难。", + "NoRandom": 1 + }, + "20575": { + "id": 20575, + "event": "好奇心使你试探着寻找凶手,但一无所获。", + "NoRandom": 1 + }, + "20576": { + "id": 20576, + "event": "你身手敏捷,侥幸逃得一命。", + "NoRandom": 1 + }, + "20577": { + "id": 20577, + "event": "你上去挑衅他们,被一群人持械围殴。", + "NoRandom": 1, + "branch": [ + "EVT?[10505]:10000" + ] + }, + "20580": { + "id": 20580, + "event": "你考上了哈佛大学。", + "include": "(TLT?[1073])&(INT>5)&(EVT?[10011])" + }, + "20596": { + "id": 20596, + "event": "很快你们便确定了关系。", + "NoRandom": 1 + }, + "20625": { + "id": 20625, + "event": "性格使然,你在网上秀优越,还发布一些挑衅言论。", + "NoRandom": 1 + }, + "20647": { + "id": 20647, + "event": "你有次在网上骂战,不小心暴露孩子考上名校是通过你的关系。", + "postEvent": "丑闻发酵,你的孩子被退学。", + "effect": { + "SPR": -1 + }, + "NoRandom": 1 + }, + "20659": { + "id": 20659, + "event": "但你生前得罪了不少人,你的申请被一再延迟。", + "NoRandom": 1 + }, + "20759": { + "id": 20759, + "event": "被天价海鲜坑了不少钱。", + "NoRandom": 1 + }, + "20917": { + "id": 20917, + "event": "你总是赢。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "21011": { + "id": 21011, + "event": "你被评为班花。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "21012": { + "id": 21012, + "event": "你被评为校草。", + "effect": { + "SPR": 1 + }, + "NoRandom": 1 + }, + "21022": { + "id": 21022, + "event": "你买到一副貌似普通的画,竟然是名家真迹。", + "effect": { + "MNY": 1 + }, + "NoRandom": 1 + }, + "21025": { + "id": 21025, + "event": "你在一次手术中不幸去世。", + "NoRandom": 1, + "branch": [ + "STR<1:10000" + ] + }, + "21027": { + "id": 21027, + "event": "其中一人是你。", + "effect": { + "STR": -1 + } + }, + "21045": { + "id": 21045, + "event": "你经常参加各类竞赛。", + "include": "(EVT?[10941,10946])&(INT>5)&(TLT?[1115])", + "exclude": "EVT?[11045,21045]" + }, + "21276": { + "id": 21276, + "event": "学生掏出小刀捅了你。", + "NoRandom": 1, + "branch": [ + "STR<4:10000" + ] + }, + "21296": { + "id": 21296, + "event": "突然,时间停止了。", + "NoRandom": 1, + "branch": [ + "INT>10:21297" + ] + }, + "21297": { + "id": 21297, + "event": "你向下方跑,想要逃离这个世界。", + "NoRandom": 1, + "branch": [ + "INT>10:21298" + ] + }, + "21298": { + "id": 21298, + "event": "跑", + "NoRandom": 1, + "branch": [ + "INT>10:21299" + ] + }, + "21299": { + "id": 21299, + "event": " 跑", + "NoRandom": 1, + "branch": [ + "INT>10:21300" + ] + }, + "21300": { + "id": 21300, + "event": " 跑", + "NoRandom": 1, + "branch": [ + "INT>10:21301" + ] + }, + "21301": { + "id": 21301, + "event": " 跑", + "NoRandom": 1, + "branch": [ + "INT>10:21302" + ] + }, + "21302": { + "id": 21302, + "event": " 跑", + "NoRandom": 1, + "branch": [ + "INT>10:21303" + ] + }, + "21303": { + "id": 21303, + "event": " 跑", + "NoRandom": 1, + "branch": [ + "INT>10:21304" + ] + }, + "21304": { + "id": 21304, + "event": " 跑 ", + "NoRandom": 1 + }, + "21305": { + "id": 21305, + "event": "你的行为终于触发了这个满是BUG的虚拟世界的防卫机制。", + "include": "EVT?[21304]", + "exclude": "EVT?[21305]", + "branch": [ + "INT>10:21306" + ] + }, + "21306": { + "id": 21306, + "event": "世界开始对你做出审判。", + "NoRandom": 1, + "branch": [ + "CHR>5:21307", + "CHR<6:21308" + ] + }, + "21307": { + "id": 21307, + "event": "你相貌还可以,世界决定抹去你这段记忆让你继续生活。", + "NoRandom": 1 + }, + "21308": { + "id": 21308, + "event": "你相貌不行,世界决定消灭你。", + "NoRandom": 1, + "branch": [ + "CHR<6:10000" + ] + }, + "21315": { + "id": 21315, + "event": "你按了。你获得了大量金钱。", + "effect": { + "MNY": 3 + }, + "NoRandom": 1 + }, + "21457": { + "id": 21457, + "event": "你意志力不足,被诱导恶堕了。", + "postEvent": "你变成了触手魔女,从此为女王效力。", + "NoRandom": 1 + }, + "30001": { + "id": 30001, + "event": "你工作过于劳累,突然晕倒了。", + "include": "(EVT?[11123])&(EVT?[10007,10008])", + "branch": [ + "STR<3:10000", + "STR>2:30002" + ] + }, + "30002": { + "id": 30002, + "event": "你穿越到了异世界。", + "postEvent": "你在原先世界的人生结束了。", + "effect": { + "LIF": -1 + }, + "NoRandom": 1 + } +} \ No newline at end of file diff --git a/games/lifeRestart/data/events.xlsx b/games/lifeRestart/data/events.xlsx new file mode 100644 index 0000000..073cd9a Binary files /dev/null and b/games/lifeRestart/data/events.xlsx differ diff --git a/games/lifeRestart/data/talents.csv b/games/lifeRestart/data/talents.csv new file mode 100644 index 0000000..355347d --- /dev/null +++ b/games/lifeRestart/data/talents.csv @@ -0,0 +1,133 @@ +$id,name,description,condition,grade,status,effect:SPR,effect:MNY,effect:CHR,effect:STR,effect:INT,exclusive[],exclusive[],exclusive[],exclusive[],exclusive[],exclusive[] +序号,天赋名,括号中的内容,触发条件,稀有度,初始可用属性点,额外快乐,额外家境,额外颜值,额外体质,额外智力,互斥天赋,互斥天赋,互斥天赋,互斥天赋,互斥天赋,互斥天赋 +1001,随身玉佩,或许有护佑作用,,0,,,,,,,,,,,, +1002,红肚兜,小时候死亡率降低,,0,,,,,,,,,,,, +1003,生而为男,性别一定为男,,1,,,,,,,1004,1025,1024,1113,, +1004,生而为女,性别一定为女,,1,,,,,,,1003,1024,1025,,, +1005,动漫高手,入宅的可能性翻6倍,,2,,,,,,,,,,,, +1006,乐天派,快乐+1,,0,,1,,,,,,,,,, +1007,天赋异禀,初始可用属性点+2,,1,2,,,,,,,,,,, +1008,天生抑郁,快乐-3,,0,,-3,,,,,,,,,, +1009,网络巨魔,快乐+2,,1,,2,,,,,,,,,, +1010,天龙人,你拥有北京户口,,2,,,,,,,1012,1013,1014,,, +1011,独生子女,你没有兄弟姐妹,,0,,,,,,,,,,,, +1012,乡间微风,你出生在农村,,0,,,,,,,1010,1013,1014,,, +1013,城中高楼,你出生在城市,,0,,,,,,,1010,1012,1014,,, +1014,美籍华人,你有美国国籍,,2,,,3,,,,1010,1012,1013,,, +1015,家中老大,你最受父母宠爱,,1,,,,,,,,,,,, +1016,水性良好,不会被淹死,,0,,,,,,,,,,,, +1017,先天免疫,你不会得艾滋病,,0,,,,,,,,,,,, +1018,人类进化,所有属性+1,,2,,1,1,1,1,1,,,,,, +1019,超凡,初始可用属性点+4,,2,4,,,,,,,,,,, +1020,父母美貌,颜值+2,,1,,,,2,,,,,,,, +1021,红颜薄命,颜值+2,体质-2,,0,,,,2,-2,,,,,,, +1022,属蛇,不会被蛇咬死,,0,,,,,,,,,,,, +1023,半神,所有属性+2,,3,,2,2,2,2,2,,,,,, +1024,人中龙凤,天生双重性别,,2,,,,,,,1003,1004,1025,,, +1025,阴阳之外,天生无性别,,2,,,,,,,1003,1024,1004,1113,, +1026,彩虹之下,可能和同性交往,,0,,,,,,,1113,,,,, +1027,斩情证道,终生不恋爱结婚,,1,,,,,,,1113,,,,, +1028,桃花连连,恋爱机会提升,,0,,,,,,,,,,,, +1029,平安童年,12岁前父母都健在,,1,,,,,,,,,,,, +1030,宠物大师,宠物不会意外死亡,,0,,,,,,,,,,,, +1031,天生残疾,体质-2,,0,,,,,-2,,,,,,, +1032,早产儿,所有属性-1,,0,,-1,-1,-1,-1,-1,,,,,, +1033,十死无生,体质-10,,0,,,,,-10,,,,,,, +1034,家运不顺,家境-2,,0,,,-2,,,,,,,,, +1035,头着地,智力-2,,0,,,,,,-2,,,,,, +1036,胎教,智力+1,,0,,,,,,1,,,,,, +1037,班中红人,和同学容易处好关系,,0,,,,,,,,,,,, +1038,骑士,能轻松学会骑车,,0,,,,,,,,,,,, +1039,永远的神,电竞天才,,1,,,,,,,,,,,, +1040,戒律,赌毒不沾,,0,,,,,,,,,,,, +1041,丁克,不生孩子,,1,,,,,,,1113,,,,, +1042,少数民族,高考+5分,,0,,,,,,,,,,,, +1043,老司机,你和家人不会发生车祸,,0,,,,,,,,,,,, +1044,低压,你的家人不会心脏病,,0,,,,,,,,,,,, +1045,战功,你退伍后会当官,,0,,,,,,,,,,,, +1046,不孕不育,你生不出孩子,,1,,,,,,,1113,,,,, +1047,白头偕老,爱人至少能活到70岁,,1,,,,,,,,,,,, +1048,神秘的小盒子,100岁时才能开启,,3,,,,,,,,,,,, +1049,三十而立,30岁时家境+2,AGE?[30],0,,,2,,,,,,,,, +1050,四十不惑,40岁时智力+2,AGE?[40],0,,,,,,2,,,,,, +1051,知天命,50岁时智力、快乐+1,AGE?[50],0,,1,,,,1,,,,,, +1052,耳顺,60岁时快乐+2,AGE?[60],0,,2,,,,,,,,,, +1053,从心所欲,70岁时快乐+3,AGE?[70],0,,3,,,,,,,,,, +1054,老当益壮,60岁时体质+2,AGE?[60],1,,,,,2,,,,,,, +1055,鹤发童颜,70岁时颜值+3,AGE?[70],0,,,,3,,,,,,,, +1056,学前启蒙,5岁时智力+2,AGE?[5],1,,,,,,2,,,,,, +1057,十八变,18岁时颜值+2,AGE?[18],1,,,,2,,,,,,,, +1058,迟来之财,90岁时家境+4,AGE?[90],0,,,4,,,,,,,,, +1059,理财达人,30、40、50岁时家境+1,"AGE?[30,40,50]",0,,,1,,,,,,,,, +1060,成熟,12、18岁时智力+1,"AGE?[12,18]",1,,,,,,1,,,,,, +1061,形象管理,16、24岁时颜值+1,"AGE?[16,24]",1,,,,1,,,,,,,, +1062,成年礼,18岁时快乐+1,AGE?[18],0,,1,,,,,,,,,, +1063,开光之胎,初始可用属性点+1,,0,1,,,,,,,,,,, +1064,天命,初始可用属性点+8,,3,8,,,,,,,,,,, +1065,祖传药丸,功能不明,,1,,,,,,,,,,,, +1066,精准扶贫,家境为0时家境+1,(MNY<1)&(MNY>-1),0,,,1,,,,,,,,, +1067,乐天派,快乐为0时快乐+1,(SPR<1)&(SPR>-1),1,,1,,,,,,,,,, +1068,命悬一线,体质为0时体质+1,(STR<1)&(STR>-1),0,,,,,1,,,,,,, +1069,智可生财,若20岁时智力>8,家境+2,(AGE?[20])&(INT>8),0,,,2,,,,,,,,, +1070,舔狗甚多,若20岁时颜值>8,快乐+2,(AGE?[20])&(CHR>8),0,,2,,,,,,,,,, +1071,保胎丸,你不会胎死腹中,,0,,,,,,,,,,,, +1072,白化病,你不会遭遇枪击,,0,,,,,,,,,,,, +1073,佛宗,考上哈佛大学的几率提高,,0,,,,,,,,,,,, +1074,悟道,智力>10时快乐+3,INT>10,1,,3,,,,,,,,,, +1075,驻颜,体质>10时颜值+3,STR>10,0,,,,3,,,,,,,, +1076,界限突破,体质>10时快乐+3,STR>10,1,,3,,,,,,,,,, +1077,倾城,颜值>10时快乐+3,CHR>10,1,,3,,,,,,,,,, +1078,训练有方,智力>10时体质+3,INT>10,0,,,,,3,,,,,,, +1079,相由心生,智力>10时颜值+3,INT>10,0,,,,3,,,,,,,, +1080,智多鑫,智力>10时家境+3,INT>10,0,,,3,,,,,,,,, +1081,灵光,快乐>10时其他属性+1,SPR>10,0,,,1,1,1,1,,,,,, +1082,天启,快乐>10时其他属性+2,SPR>10,1,,,2,2,2,2,,,,,, +1083,神谕,快乐>10时其他属性+3,SPR>10,2,,,3,3,3,3,,,,,, +1084,献祭,初始可用属性点-2,快乐+2,,0,-2,2,,,,,1122,,,,, +1085,幸运儿,初始可用属性点-3,快乐+5,,1,-3,5,,,,,1122,,,,, +1086,挑战者,初始可用点-10,,0,-10,,,,,,1122,,,,, +1087,你不懂,家境>10时快乐+3,MNY>10,1,,3,,,,,,,,,, +1088,整容,家境>10时颜值+3,MNY>10,0,,,,3,,,,,,,, +1089,钻石健身卡,家境>10时体质+3,MNY>10,0,,,,,3,,,,,,, +1090,身残志坚,体质<0时其他属性+1,STR<0,0,,1,1,1,,1,,,,,, +1091,活死人,体质<-1时其他属性+2,STR<0,1,,2,2,2,,2,,,,,, +1092,开一扇窗,颜值<0时其他属性+1,CHR<0,0,,1,1,,1,1,,,,,, +1093,大额头,颜值-2,智力+2,,0,,,,-2,,2,,,,,, +1094,痘痘脸,颜值-1,,0,,,,-1,,,,,,,, +1095,潜能,家境<0时其他属性+1,MNY<0,0,,1,,1,1,1,,,,,, +1096,哀兵,快乐<0时其他属性+1,SPR<0,0,,,1,1,1,1,,,,,, +1097,苦痛侍僧,快乐<-1时其他属性+2,SPR<-1,1,,,2,2,2,2,,,,,, +1098,觉醒,家境<-1时其他属性+2,MNY<-1,1,,2,,2,2,2,,,,,, +1099,抖M,家境-2,快乐+2,,0,,2,-2,,,,,,,,, +1100,海的女儿,颜值-2,初始可用属性点+1,,0,1,,,-2,,,,,,,, +1101,进阶,所有属性>5时,所有属性+1,(SPR>5)&(MNY>5)&(CHR>5)&(STR>5)&(INT>5),0,,1,1,1,1,1,,,,,, +1102,超进化,所有属性>5时,所有属性+2,(SPR>5)&(MNY>5)&(CHR>5)&(STR>5)&(INT>5),1,,2,2,2,2,2,,,,,, +1103,白色胶囊,你10岁时无事发生,AGE?[10],0,,,,,,,,,,,, +1104,紫色胶囊,跳过你的40~50岁,"AGE?[40,41,42,43,44,45,46,47,48,49,50]",2,,,,,,,,,,,, +1105,蓝色胶囊,你20、30岁时无事发生,"AGE?[20,30]",1,,,,,,,,,,,, +1106,健康饮食,你不吃洋快餐,,0,,,,,,,,,,,, +1107,不想罢了,你不会上清华大学,,0,,,,,,,,,,,, +1108,挑衅,你喜欢没事找事,,0,,,,,,,,,,,, +1109,旅行者,你喜欢旅游,,0,,,,,,,,,,,, +1110,水仙,你比较自恋,,0,,,,,,,,,,,, +1111,缺一门,无效果,,0,,,,,,,,,,,, +1112,异界来客,你可能听到一些绝密消息,,2,,,,,,,,,,,, +1113,三胎人生,你尽可能生三胎,,1,,,,,,,1003,1025,1026,1027,1041,1046 +1114,橙色胶囊,跳过你的60~90岁,"AGE?[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]",3,,,,,,,,,,,, +1115,宙斯,参加奥赛的几率提高,,0,,,,,,,,,,,, +1116,为人民服务,考公务员时一定能考上,,0,,,,,,,,,,,, +1117,表现良好,入狱会减刑,,0,,,,,,,,,,,, +1118,小吉,运气稍微提升,,0,,,,,,,,,,,, +1119,天秤座,据说做事很公平,,0,,,,,,,,,,,, +1120,万里挑一,你很攻,,0,,,,,,,,,,,, +1121,把握不住,你有强迫症,,0,,,,,,,,,,,, +1122,急了急了,赶着投胎,不要初始属性了,,1,-20,,,,,,1084,1085,1086,,, +1123,不离不弃,你不会离婚,,0,,,,,,,,,,,, +1124,足量,身高不矮,,0,,,,,,,,,,,, +1125,易胖体质,颜值更容易降低,,0,,,,,,,,,,,, +1126,黄帝,种族主义者,,0,,,,,,,,,,,, +1127,左撇子,习惯使用左手,,0,,,,,,,,,,,, +1128,克苏鲁,&▓▓▓◆▓▓▓¥#▓@■.◆,,2,,,,,,,,,,,, +1129,不连续存在,你还拥有其他人格,,2,,,,,,,,,,,, +1130,占位符,少一个可选天赋,,0,,,,,,,,,,,, +1131,魔法棒,不知道有什么用……,,2,,,,,,,,,,,, diff --git a/games/lifeRestart/data/talents.json b/games/lifeRestart/data/talents.json new file mode 100644 index 0000000..92cff88 --- /dev/null +++ b/games/lifeRestart/data/talents.json @@ -0,0 +1,1173 @@ +{ + "1001": { + "id": "1001", + "name": "随身玉佩", + "description": "或许有护佑作用", + "grade": 0 + }, + "1002": { + "id": "1002", + "name": "红肚兜", + "description": "小时候死亡率降低", + "grade": 0 + }, + "1003": { + "id": "1003", + "name": "生而为男", + "description": "性别一定为男", + "grade": 1, + "exclusive": [ + "1004", + "1025", + "1024", + 1113 + ] + }, + "1004": { + "id": "1004", + "name": "生而为女", + "description": "性别一定为女", + "grade": 1, + "exclusive": [ + "1003", + "1024", + "1025" + ] + }, + "1005": { + "id": "1005", + "name": "动漫高手", + "description": "入宅的可能性翻6倍", + "grade": 2 + }, + "1006": { + "id": "1006", + "name": "乐天派", + "description": "快乐+1", + "grade": 0, + "effect": { + "SPR": 1 + } + }, + "1007": { + "id": "1007", + "name": "天赋异禀", + "description": "初始可用属性点+2", + "grade": 1, + "status": 2 + }, + "1008": { + "id": "1008", + "name": "天生抑郁", + "description": "快乐-3", + "grade": 0, + "effect": { + "SPR": -3 + } + }, + "1009": { + "id": "1009", + "name": "网络巨魔", + "description": "快乐+2", + "grade": 1, + "effect": { + "SPR": 2 + } + }, + "1010": { + "id": "1010", + "name": "天龙人", + "description": "你拥有北京户口", + "grade": 2, + "exclusive": [ + "1012", + "1013", + "1014" + ] + }, + "1011": { + "id": "1011", + "name": "独生子女", + "description": "你没有兄弟姐妹", + "grade": 0 + }, + "1012": { + "id": "1012", + "name": "乡间微风", + "description": "你出生在农村", + "grade": 0, + "exclusive": [ + "1010", + "1013", + "1014" + ] + }, + "1013": { + "id": "1013", + "name": "城中高楼", + "description": "你出生在城市", + "grade": 0, + "exclusive": [ + "1010", + "1012", + "1014" + ] + }, + "1014": { + "id": "1014", + "name": "美籍华人", + "description": "你有美国国籍", + "grade": 2, + "effect": { + "MNY": 3 + }, + "exclusive": [ + "1010", + "1012", + "1013" + ] + }, + "1015": { + "id": "1015", + "name": "家中老大", + "description": "你最受父母宠爱", + "grade": 1 + }, + "1016": { + "id": "1016", + "name": "水性良好", + "description": "不会被淹死", + "grade": 0 + }, + "1017": { + "id": "1017", + "name": "先天免疫", + "description": "你不会得艾滋病", + "grade": 0 + }, + "1018": { + "id": "1018", + "name": "人类进化", + "description": "所有属性+1", + "grade": 2, + "effect": { + "SPR": 1, + "MNY": 1, + "CHR": 1, + "STR": 1, + "INT": 1 + } + }, + "1019": { + "id": "1019", + "name": "超凡", + "description": "初始可用属性点+4", + "grade": 2, + "status": 4 + }, + "1020": { + "id": "1020", + "name": "父母美貌", + "description": "颜值+2", + "grade": 1, + "effect": { + "CHR": 2 + } + }, + "1021": { + "id": "1021", + "name": "红颜薄命", + "description": "颜值+2,体质-2", + "grade": 0, + "effect": { + "CHR": 2, + "STR": -2 + } + }, + "1022": { + "id": "1022", + "name": "属蛇", + "description": "不会被蛇咬死", + "grade": 0 + }, + "1023": { + "id": "1023", + "name": "半神", + "description": "所有属性+2", + "grade": 3, + "effect": { + "SPR": 2, + "MNY": 2, + "CHR": 2, + "STR": 2, + "INT": 2 + } + }, + "1024": { + "id": "1024", + "name": "人中龙凤", + "description": "天生双重性别", + "grade": 2, + "exclusive": [ + "1003", + "1004", + "1025" + ] + }, + "1025": { + "id": "1025", + "name": "阴阳之外", + "description": "天生无性别", + "grade": 2, + "exclusive": [ + "1003", + "1024", + "1004", + 1113 + ] + }, + "1026": { + "id": "1026", + "name": "彩虹之下", + "description": "可能和同性交往", + "grade": 0, + "exclusive": [ + "1113" + ] + }, + "1027": { + "id": "1027", + "name": "斩情证道", + "description": "终生不恋爱结婚", + "grade": 1, + "exclusive": [ + "1113" + ] + }, + "1028": { + "id": "1028", + "name": "桃花连连", + "description": "恋爱机会提升", + "grade": 0 + }, + "1029": { + "id": "1029", + "name": "平安童年", + "description": "12岁前父母都健在", + "grade": 1 + }, + "1030": { + "id": "1030", + "name": "宠物大师", + "description": "宠物不会意外死亡", + "grade": 0 + }, + "1031": { + "id": "1031", + "name": "天生残疾", + "description": "体质-2", + "grade": 0, + "effect": { + "STR": -2 + } + }, + "1032": { + "id": "1032", + "name": "早产儿", + "description": "所有属性-1", + "grade": 0, + "effect": { + "SPR": -1, + "MNY": -1, + "CHR": -1, + "STR": -1, + "INT": -1 + } + }, + "1033": { + "id": "1033", + "name": "十死无生", + "description": "体质-10", + "grade": 0, + "effect": { + "STR": -10 + } + }, + "1034": { + "id": "1034", + "name": "家运不顺", + "description": "家境-2", + "grade": 0, + "effect": { + "MNY": -2 + } + }, + "1035": { + "id": "1035", + "name": "头着地", + "description": "智力-2", + "grade": 0, + "effect": { + "INT": -2 + } + }, + "1036": { + "id": "1036", + "name": "胎教", + "description": "智力+1", + "grade": 0, + "effect": { + "INT": 1 + } + }, + "1037": { + "id": "1037", + "name": "班中红人", + "description": "和同学容易处好关系", + "grade": 0 + }, + "1038": { + "id": "1038", + "name": "骑士", + "description": "能轻松学会骑车", + "grade": 0 + }, + "1039": { + "id": "1039", + "name": "永远的神", + "description": "电竞天才", + "grade": 1 + }, + "1040": { + "id": "1040", + "name": "戒律", + "description": "赌毒不沾", + "grade": 0 + }, + "1041": { + "id": "1041", + "name": "丁克", + "description": "不生孩子", + "grade": 1, + "exclusive": [ + "1113" + ] + }, + "1042": { + "id": "1042", + "name": "少数民族", + "description": "高考+5分", + "grade": 0 + }, + "1043": { + "id": "1043", + "name": "老司机", + "description": "你和家人不会发生车祸", + "grade": 0 + }, + "1044": { + "id": "1044", + "name": "低压", + "description": "你的家人不会心脏病", + "grade": 0 + }, + "1045": { + "id": "1045", + "name": "战功", + "description": "你退伍后会当官", + "grade": 0 + }, + "1046": { + "id": "1046", + "name": "不孕不育", + "description": "你生不出孩子", + "grade": 1, + "exclusive": [ + "1113" + ] + }, + "1047": { + "id": "1047", + "name": "白头偕老", + "description": "爱人至少能活到70岁", + "grade": 1 + }, + "1048": { + "id": "1048", + "name": "神秘的小盒子", + "description": "100岁时才能开启", + "grade": 3 + }, + "1049": { + "id": "1049", + "name": "三十而立", + "description": "30岁时家境+2", + "condition": "AGE?[30]", + "grade": 0, + "effect": { + "MNY": 2 + } + }, + "1050": { + "id": "1050", + "name": "四十不惑", + "description": "40岁时智力+2", + "condition": "AGE?[40]", + "grade": 0, + "effect": { + "INT": 2 + } + }, + "1051": { + "id": "1051", + "name": "知天命", + "description": "50岁时智力、快乐+1", + "condition": "AGE?[50]", + "grade": 0, + "effect": { + "SPR": 1, + "INT": 1 + } + }, + "1052": { + "id": "1052", + "name": "耳顺", + "description": "60岁时快乐+2", + "condition": "AGE?[60]", + "grade": 0, + "effect": { + "SPR": 2 + } + }, + "1053": { + "id": "1053", + "name": "从心所欲", + "description": "70岁时快乐+3", + "condition": "AGE?[70]", + "grade": 0, + "effect": { + "SPR": 3 + } + }, + "1054": { + "id": "1054", + "name": "老当益壮", + "description": "60岁时体质+2", + "condition": "AGE?[60]", + "grade": 1, + "effect": { + "STR": 2 + } + }, + "1055": { + "id": "1055", + "name": "鹤发童颜", + "description": "70岁时颜值+3", + "condition": "AGE?[70]", + "grade": 0, + "effect": { + "CHR": 3 + } + }, + "1056": { + "id": "1056", + "name": "学前启蒙", + "description": "5岁时智力+2", + "condition": "AGE?[5]", + "grade": 1, + "effect": { + "INT": 2 + } + }, + "1057": { + "id": "1057", + "name": "十八变", + "description": "18岁时颜值+2", + "condition": "AGE?[18]", + "grade": 1, + "effect": { + "CHR": 2 + } + }, + "1058": { + "id": "1058", + "name": "迟来之财", + "description": "90岁时家境+4", + "condition": "AGE?[90]", + "grade": 0, + "effect": { + "MNY": 4 + } + }, + "1059": { + "id": "1059", + "name": "理财达人", + "description": "30、40、50岁时家境+1", + "condition": "AGE?[30,40,50]", + "grade": 0, + "effect": { + "MNY": 1 + } + }, + "1060": { + "id": "1060", + "name": "成熟", + "description": "12、18岁时智力+1", + "condition": "AGE?[12,18]", + "grade": 1, + "effect": { + "INT": 1 + } + }, + "1061": { + "id": "1061", + "name": "形象管理", + "description": "16、24岁时颜值+1", + "condition": "AGE?[16,24]", + "grade": 1, + "effect": { + "CHR": 1 + } + }, + "1062": { + "id": "1062", + "name": "成年礼", + "description": "18岁时快乐+1", + "condition": "AGE?[18]", + "grade": 0, + "effect": { + "SPR": 1 + } + }, + "1063": { + "id": "1063", + "name": "开光之胎", + "description": "初始可用属性点+1", + "grade": 0, + "status": 1 + }, + "1064": { + "id": "1064", + "name": "天命", + "description": "初始可用属性点+8", + "grade": 3, + "status": 8 + }, + "1065": { + "id": "1065", + "name": "祖传药丸", + "description": "功能不明", + "grade": 1 + }, + "1066": { + "id": "1066", + "name": "精准扶贫", + "description": "家境为0时家境+1", + "condition": "(MNY<1)&(MNY>-1)", + "grade": 0, + "effect": { + "MNY": 1 + } + }, + "1067": { + "id": "1067", + "name": "乐天派", + "description": "快乐为0时快乐+1", + "condition": "(SPR<1)&(SPR>-1)", + "grade": 1, + "effect": { + "SPR": 1 + } + }, + "1068": { + "id": "1068", + "name": "命悬一线", + "description": "体质为0时体质+1", + "condition": "(STR<1)&(STR>-1)", + "grade": 0, + "effect": { + "STR": 1 + } + }, + "1069": { + "id": "1069", + "name": "智可生财", + "description": "若20岁时智力>8,家境+2", + "condition": "(AGE?[20])&(INT>8)", + "grade": 0, + "effect": { + "MNY": 2 + } + }, + "1070": { + "id": "1070", + "name": "舔狗甚多", + "description": "若20岁时颜值>8,快乐+2", + "condition": "(AGE?[20])&(CHR>8)", + "grade": 0, + "effect": { + "SPR": 2 + } + }, + "1071": { + "id": "1071", + "name": "保胎丸", + "description": "你不会胎死腹中", + "grade": 0 + }, + "1072": { + "id": "1072", + "name": "白化病", + "description": "你不会遭遇枪击", + "grade": 0 + }, + "1073": { + "id": "1073", + "name": "佛宗", + "description": "考上哈佛大学的几率提高", + "grade": 0 + }, + "1074": { + "id": "1074", + "name": "悟道", + "description": "智力>10时快乐+3", + "condition": "INT>10", + "grade": 1, + "effect": { + "SPR": 3 + } + }, + "1075": { + "id": "1075", + "name": "驻颜", + "description": "体质>10时颜值+3", + "condition": "STR>10", + "grade": 0, + "effect": { + "CHR": 3 + } + }, + "1076": { + "id": "1076", + "name": "界限突破", + "description": "体质>10时快乐+3", + "condition": "STR>10", + "grade": 1, + "effect": { + "SPR": 3 + } + }, + "1077": { + "id": "1077", + "name": "倾城", + "description": "颜值>10时快乐+3", + "condition": "CHR>10", + "grade": 1, + "effect": { + "SPR": 3 + } + }, + "1078": { + "id": "1078", + "name": "训练有方", + "description": "智力>10时体质+3", + "condition": "INT>10", + "grade": 0, + "effect": { + "STR": 3 + } + }, + "1079": { + "id": "1079", + "name": "相由心生", + "description": "智力>10时颜值+3", + "condition": "INT>10", + "grade": 0, + "effect": { + "CHR": 3 + } + }, + "1080": { + "id": "1080", + "name": "智多鑫", + "description": "智力>10时家境+3", + "condition": "INT>10", + "grade": 0, + "effect": { + "MNY": 3 + } + }, + "1081": { + "id": "1081", + "name": "灵光", + "description": "快乐>10时其他属性+1", + "condition": "SPR>10", + "grade": 0, + "effect": { + "MNY": 1, + "CHR": 1, + "STR": 1, + "INT": 1 + } + }, + "1082": { + "id": "1082", + "name": "天启", + "description": "快乐>10时其他属性+2", + "condition": "SPR>10", + "grade": 1, + "effect": { + "MNY": 2, + "CHR": 2, + "STR": 2, + "INT": 2 + } + }, + "1083": { + "id": "1083", + "name": "神谕", + "description": "快乐>10时其他属性+3", + "condition": "SPR>10", + "grade": 2, + "effect": { + "MNY": 3, + "CHR": 3, + "STR": 3, + "INT": 3 + } + }, + "1084": { + "id": "1084", + "name": "献祭", + "description": "初始可用属性点-2,快乐+2", + "grade": 0, + "status": -2, + "effect": { + "SPR": 2 + }, + "exclusive": [ + "1122" + ] + }, + "1085": { + "id": "1085", + "name": "幸运儿", + "description": "初始可用属性点-3,快乐+5", + "grade": 1, + "status": -3, + "effect": { + "SPR": 5 + }, + "exclusive": [ + "1122" + ] + }, + "1086": { + "id": "1086", + "name": "挑战者", + "description": "初始可用点-10", + "grade": 0, + "status": -10, + "exclusive": [ + "1122" + ] + }, + "1087": { + "id": "1087", + "name": "你不懂", + "description": "家境>10时快乐+3", + "condition": "MNY>10", + "grade": 1, + "effect": { + "SPR": 3 + } + }, + "1088": { + "id": "1088", + "name": "整容", + "description": "家境>10时颜值+3", + "condition": "MNY>10", + "grade": 0, + "effect": { + "CHR": 3 + } + }, + "1089": { + "id": "1089", + "name": "钻石健身卡", + "description": "家境>10时体质+3", + "condition": "MNY>10", + "grade": 0, + "effect": { + "STR": 3 + } + }, + "1090": { + "id": "1090", + "name": "身残志坚", + "description": "体质<0时其他属性+1", + "condition": "STR<0", + "grade": 0, + "effect": { + "SPR": 1, + "MNY": 1, + "CHR": 1, + "INT": 1 + } + }, + "1091": { + "id": "1091", + "name": "活死人", + "description": "体质<-1时其他属性+2", + "condition": "STR<0", + "grade": 1, + "effect": { + "SPR": 2, + "MNY": 2, + "CHR": 2, + "INT": 2 + } + }, + "1092": { + "id": "1092", + "name": "开一扇窗", + "description": "颜值<0时其他属性+1", + "condition": "CHR<0", + "grade": 0, + "effect": { + "SPR": 1, + "MNY": 1, + "STR": 1, + "INT": 1 + } + }, + "1093": { + "id": "1093", + "name": "大额头", + "description": "颜值-2,智力+2", + "grade": 0, + "effect": { + "CHR": -2, + "INT": 2 + } + }, + "1094": { + "id": "1094", + "name": "痘痘脸", + "description": "颜值-1", + "grade": 0, + "effect": { + "CHR": -1 + } + }, + "1095": { + "id": "1095", + "name": "潜能", + "description": "家境<0时其他属性+1", + "condition": "MNY<0", + "grade": 0, + "effect": { + "SPR": 1, + "CHR": 1, + "STR": 1, + "INT": 1 + } + }, + "1096": { + "id": "1096", + "name": "哀兵", + "description": "快乐<0时其他属性+1", + "condition": "SPR<0", + "grade": 0, + "effect": { + "MNY": 1, + "CHR": 1, + "STR": 1, + "INT": 1 + } + }, + "1097": { + "id": "1097", + "name": "苦痛侍僧", + "description": "快乐<-1时其他属性+2", + "condition": "SPR<-1", + "grade": 1, + "effect": { + "MNY": 2, + "CHR": 2, + "STR": 2, + "INT": 2 + } + }, + "1098": { + "id": "1098", + "name": "觉醒", + "description": "家境<-1时其他属性+2", + "condition": "MNY<-1", + "grade": 1, + "effect": { + "SPR": 2, + "CHR": 2, + "STR": 2, + "INT": 2 + } + }, + "1099": { + "id": "1099", + "name": "抖M", + "description": "家境-2,快乐+2", + "grade": 0, + "effect": { + "SPR": 2, + "MNY": -2 + } + }, + "1100": { + "id": "1100", + "name": "海的女儿", + "description": "颜值-2,初始可用属性点+1", + "grade": 0, + "status": 1, + "effect": { + "CHR": -2 + } + }, + "1101": { + "id": "1101", + "name": "进阶", + "description": "所有属性>5时,所有属性+1", + "condition": "(SPR>5)&(MNY>5)&(CHR>5)&(STR>5)&(INT>5)", + "grade": 0, + "effect": { + "SPR": 1, + "MNY": 1, + "CHR": 1, + "STR": 1, + "INT": 1 + } + }, + "1102": { + "id": "1102", + "name": "超进化", + "description": "所有属性>5时,所有属性+2", + "condition": "(SPR>5)&(MNY>5)&(CHR>5)&(STR>5)&(INT>5)", + "grade": 1, + "effect": { + "SPR": 2, + "MNY": 2, + "CHR": 2, + "STR": 2, + "INT": 2 + } + }, + "1103": { + "id": "1103", + "name": "白色胶囊", + "description": "你10岁时无事发生", + "condition": "AGE?[10]", + "grade": 0 + }, + "1104": { + "id": "1104", + "name": "紫色胶囊", + "description": "跳过你的40~50岁", + "condition": "AGE?[40,41,42,43,44,45,46,47,48,49,50]", + "grade": 2 + }, + "1105": { + "id": "1105", + "name": "蓝色胶囊", + "description": "你20、30岁时无事发生", + "condition": "AGE?[20,30]", + "grade": 1 + }, + "1106": { + "id": "1106", + "name": "健康饮食", + "description": "你不吃洋快餐", + "grade": 0 + }, + "1107": { + "id": "1107", + "name": "不想罢了", + "description": "你不会上清华大学", + "grade": 0 + }, + "1108": { + "id": "1108", + "name": "挑衅", + "description": "你喜欢没事找事", + "grade": 0 + }, + "1109": { + "id": "1109", + "name": "旅行者", + "description": "你喜欢旅游", + "grade": 0 + }, + "1110": { + "id": "1110", + "name": "水仙", + "description": "你比较自恋", + "grade": 0 + }, + "1111": { + "id": "1111", + "name": "缺一门", + "description": "无效果", + "grade": 0 + }, + "1112": { + "id": "1112", + "name": "异界来客", + "description": "你可能听到一些绝密消息", + "grade": 2 + }, + "1113": { + "id": "1113", + "name": "三胎人生", + "description": "你尽可能生三胎", + "grade": 1, + "exclusive": [ + "1003", + "1025", + "1026", + 1027, + 1041, + 1046 + ] + }, + "1114": { + "id": "1114", + "name": "橙色胶囊", + "description": "跳过你的60~90岁", + "condition": "AGE?[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]", + "grade": 3 + }, + "1115": { + "id": "1115", + "name": "宙斯", + "description": "参加奥赛的几率提高", + "grade": 0 + }, + "1116": { + "id": "1116", + "name": "为人民服务", + "description": "考公务员时一定能考上", + "grade": 0 + }, + "1117": { + "id": "1117", + "name": "表现良好", + "description": "入狱会减刑", + "grade": 0 + }, + "1118": { + "id": "1118", + "name": "小吉", + "description": "运气稍微提升", + "grade": 0 + }, + "1119": { + "id": "1119", + "name": "天秤座", + "description": "据说做事很公平", + "grade": 0 + }, + "1120": { + "id": "1120", + "name": "万里挑一", + "description": "你很攻", + "grade": 0 + }, + "1121": { + "id": "1121", + "name": "把握不住", + "description": "你有强迫症", + "grade": 0 + }, + "1122": { + "id": "1122", + "name": "急了急了", + "description": "赶着投胎,不要初始属性了", + "grade": 1, + "status": -20, + "exclusive": [ + "1084", + "1085", + "1086" + ] + }, + "1123": { + "id": "1123", + "name": "不离不弃", + "description": "你不会离婚", + "grade": 0 + }, + "1124": { + "id": "1124", + "name": "足量", + "description": "身高不矮", + "grade": 0 + }, + "1125": { + "id": "1125", + "name": "易胖体质", + "description": "颜值更容易降低", + "grade": 0 + }, + "1126": { + "id": "1126", + "name": "黄帝", + "description": "种族主义者", + "grade": 0 + }, + "1127": { + "id": "1127", + "name": "左撇子", + "description": "习惯使用左手", + "grade": 0 + }, + "1128": { + "id": "1128", + "name": "克苏鲁", + "description": "&▓▓▓◆▓▓▓¥#▓@■.◆", + "grade": 2 + }, + "1129": { + "id": "1129", + "name": "不连续存在", + "description": "你还拥有其他人格", + "grade": 2 + }, + "1130": { + "id": "1130", + "name": "占位符", + "description": "少一个可选天赋", + "grade": 0 + }, + "1131": { + "id": "1131", + "name": "魔法棒", + "description": "不知道有什么用……", + "grade": 2 + }, + "1132": { + "id": 1132, + "name": "返老还童", + "description": "可能会回到年轻的时候", + "grade": 2 + }, + "1133": { + "id": 1133, + "name": "时光倒流", + "description": "或许时间会倒流", + "grade": 1 + }, + "1134": { + "id": 1134, + "name": "转世重修", + "description": "渡劫失败重生", + "grade": 3 + } +} \ No newline at end of file diff --git a/games/lifeRestart/data/talents.xlsx b/games/lifeRestart/data/talents.xlsx new file mode 100644 index 0000000..1f89115 Binary files /dev/null and b/games/lifeRestart/data/talents.xlsx differ diff --git a/games/lifeRestart/iconfont.ttf b/games/lifeRestart/iconfont.ttf new file mode 100644 index 0000000..3bd04a9 Binary files /dev/null and b/games/lifeRestart/iconfont.ttf differ diff --git a/games/lifeRestart/iconfont.woff b/games/lifeRestart/iconfont.woff new file mode 100644 index 0000000..4bfcdd1 Binary files /dev/null and b/games/lifeRestart/iconfont.woff differ diff --git a/games/lifeRestart/iconfont.woff2 b/games/lifeRestart/iconfont.woff2 new file mode 100644 index 0000000..2c1979c Binary files /dev/null and b/games/lifeRestart/iconfont.woff2 differ diff --git a/games/lifeRestart/index.html b/games/lifeRestart/index.html new file mode 100644 index 0000000..7bff8cf --- /dev/null +++ b/games/lifeRestart/index.html @@ -0,0 +1,42 @@ + + + + + + 人生重开模拟器 + + + + + + +
              +
              + + + +
              +
              + + diff --git a/games/lifeRestart/light.css b/games/lifeRestart/light.css new file mode 100644 index 0000000..1679f10 --- /dev/null +++ b/games/lifeRestart/light.css @@ -0,0 +1,565 @@ +@media (min-width:640px){html{font-size:24px;}} +@media (min-width:631px) and (max-width:639px){html{font-size:23.66px;}} +@media (min-width:622px) and (max-width:630px){html{font-size:23.33px;}} +@media (min-width:613px) and (max-width:621px){html{font-size:23px;}} +@media (min-width:604px) and (max-width:612px){html{font-size:22.66px;}} +@media (min-width:595px) and (max-width:603px){html{font-size:22.33px;}} +@media (min-width:586px) and (max-width:594px){html{font-size:22px;}} +@media (min-width:577px) and (max-width:585px){html{font-size:21.66px;}} +@media (min-width:568px) and (max-width:576px){html{font-size:21.33px;}} +@media (min-width:559px) and (max-width:567px){html{font-size:21px;}} +@media (min-width:550px) and (max-width:558px){html{font-size:20.66px;}} +@media (min-width:541px) and (max-width:549px){html{font-size:20.33px;}} +@media (min-width:533px) and (max-width:540px){html{font-size:20px;}} +@media (min-width:524px) and (max-width:532px){html{font-size:19.66px;}} +@media (min-width:515px) and (max-width:523px){html{font-size:19.33px;}} +@media (min-width:506px) and (max-width:514px){html{font-size:19px;}} +@media (min-width:497px) and (max-width:505px){html{font-size:18.66px;}} +@media (min-width:488px) and (max-width:496px){html{font-size:18.33px;}} +@media (min-width:480px) and (max-width:487px){html{font-size:18px;}} +@media (min-width:471px) and (max-width:479px){html{font-size:17.66px;}} +@media (min-width:462px) and (max-width:470px){html{font-size:17.33px;}} +@media (min-width:453px) and (max-width:461px){html{font-size:17px;}} +@media (min-width:444px) and (max-width:452px){html{font-size:17.12px;}} +@media (min-width:435px) and (max-width:443px){html{font-size:16.33px;}} +@media (min-width:426px) and (max-width:434px){html{font-size:16px;}} +@media (min-width:417px) and (max-width:425px){html{font-size:15.66px;}} +@media (min-width:408px) and (max-width:416px){html{font-size:15.33px;}} +@media (min-width:400px) and (max-width:407px){html{font-size:15px;}} +@media (min-width:391px) and (max-width:399px){html{font-size:14.66px;}} +@media (min-width:382px) and (max-width:390px){html{font-size:14.33px;}} +@media (min-width:374px) and (max-width:381px){html{font-size:14px;}} +@media (min-width:365px) and (max-width:373px){html{font-size:13.66px;}} +@media (min-width:356px) and (max-width:364px){html{font-size:13.33px;}} +@media (min-width:347px) and (max-width:355px){html{font-size:13px;}} +@media (min-width:338px) and (max-width:346px){html{font-size:12.66px;}} +@media (min-width:329px) and (max-width:337px){html{font-size:12.44px;}} +@media (max-width:328px){html{font-size:12px;}} + +@font-face { + font-family: 'iconfont'; + src: url('iconfont.woff2?t=1628944689555') format('woff2'), + url('iconfont.woff?t=1628944689555') format('woff'), + url('iconfont.ttf?t=1628944689555') format('truetype'); +} + +html { + font-family: PingFangSC, 'Noto Sans CJK SC', 'MS Yahei'; +} + +body { + user-select: none; +} + +#main { + align-content: center; + width: 100%; + height: 100%; + position: relative; +} + +#title { + position: fixed; + font-size: 3rem; + font-weight: 700; + top: 35%; + left: 50%; + white-space: nowrap; + transform: translate(-50%,-50%); + text-align: center; +} + +.mainbtn { + position: fixed; + top: 65%; + left: 50%; + padding: 0.5rem 1.5rem; + border: 1px #ccc solid; + border-radius: 0.2rem; + background-color:white; + font-size: 1.6rem; + white-space: nowrap; + transform: translate(-50%,-50%); + cursor: pointer; + z-index:2; +} + +.mainbtn:hover { + background: #ff7878; + color: #fff; + transition: all .4s ease 0s; +} + +.iconfont { + font-family: "iconfont" !important; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#rank { + position: fixed; + top: 1rem; + right: 1rem; + padding: 0.1rem 1rem; + border: none; + border-radius: 0.2rem; + background-color:lightsteelblue; + font-size: 1.4rem; + color: white; + cursor: pointer; + z-index:2; +} + +#themeToggleBtn { + position: fixed; + right: 1rem; + bottom: 1rem; + padding: 0.1rem 1rem; + border: none; + border-radius: 0.2rem; + background-color:#222831; + font-size: 1.4rem; + color: #EEEEEE; + cursor: pointer; + z-index:2; +} + +.head { + position: fixed; + font-size: 1.4rem; + top: 1.1rem; + left: 50%; + white-space: nowrap; + transform: translateX(-50%); + text-align: center; +} + +.judge, +.lifeTrajectory, +.propinitial, +.selectlist { + position: fixed; + list-style-type: none; + left: 50%; + top: 5rem; + bottom: 8.5rem; + width: 30rem; + max-width: calc(100% - 2rem); + margin: auto; + padding: 0; + overflow: auto; + transform: translateX(-50%); + text-align: center; +} + +.lifeProperty{ + position: fixed; + list-style-type: none; + left: 50%; + top: 2rem; + width: 30rem; + max-width: calc(100% - 2rem); + padding: 0; + overflow: auto; + transform: translateX(-50%); + display: flex; + color: black; +} + +.lifeProperty > li { + width: 100%; + position: relative; + border: 1px #ccc solid; + display: inline-block; + margin: 0.1rem 2px; + font-size: 1rem; + text-align: center; + border-radius: 0.2rem; +} + +.selectlist > li { + position: relative; + border: 1px #ccc solid; + display: inline-block; + width: 95%; + margin: 0.1rem auto; + font-size: 1.4rem; + text-align: center; + border-radius: 0.2rem; + cursor: pointer; +} + +.grade0b { + background-color: #ededed; + border: #c5c5c5 2px solid !important; +} + +.grade1b { + background-color: #7ea5ec; + border: #c5c5c5 2px solid !important; +} + +.grade2b { + background-color: #e2a7ff; + border: #c5c5c5 2px solid !important; +} + +.grade3b { + background-color: #ffa07a; + border: #c5c5c5 2px solid !important; +} + +@media (min-width:1080px) { + .grade0b:hover { + background-color: #868686; + transition: all .3s ease 0s; + } + + .grade1b:hover { + background-color: #5d90ff; + transition: all .3s ease 0s; + } + + .grade2b:hover { + background-color: #bc72ec; + transition: all .3s ease 0s; + } + + .grade3b:hover { + background-color: #e09074; + transition: all .3s ease 0s; + } +} +.grade0b.selected { + background-color: #444; + box-shadow: #bbb 0px 0px 10px; + color: #fff; +} + +.grade1b.selected { + background-color: #407dec; + box-shadow: #bbb 0px 0px 10px; + color: #fff; +} + +.grade2b.selected { + background-color: #b362e7; + box-shadow: #bbb 0px 0px 10px; + color: #fff; +} + +.grade3b.selected { + background-color: #ff7f4d; + box-shadow: #bbb 0px 0px 10px; + color: #fff; +} + +.judge > li.grade1 span, +.judge > li.grade1{ + background-color: #7ea5ec; +} +.judge > li.grade2 span, +.judge > li.grade2{ + background-color: #e2a7ff; +} +.judge > li.grade3 span, +.judge > li.grade3{ + background-color: #ffa07a; +} + +.propinitial { + top: 5rem; + bottom: 17rem; +} + +.propinitial > li { + position: relative; + display: inline-block; + width: 95%; + margin: 0.1rem auto; + font-size: 1.4rem; + text-align: center; + border-radius: 0.2rem; + padding: 0.2rem; +} + +.propinitial > li > input { + height: 2.2rem; + width: 2.2rem; + margin: 0 0.5rem; + padding: 0; + text-align: center; + font-size: 2rem; + border: 0.1rem #ccc solid; +} + +.propbtn { + position: relative; + cursor: pointer; + font-size: 2rem; + user-select: none; +} + +.propbtn:hover{ + color: #5c5c5c; + transition: all .2s ease 0s; +} + +.lifeTrajectory { + border: 1px #a7a7a7 solid; + border-radius: 10px; + background-color: #ffffff; +} + +.judge > li, +.lifeTrajectory > li { + position: relative; + width: calc(100% - 7rem); + margin: 0.5rem 0; + padding: 0.5rem 1rem 0.5rem 6rem; + font-size: 1.4rem; + background-color: #fff; + box-shadow: #a7a7a7 0 0 0.4rem; + user-select: none; +} + +.judge > li > span, +.lifeTrajectory > li > span { + position: absolute; + left: 0; + width: 6rem; + text-align: right; +} + +.judge > li { + box-shadow: lightgray 0 0 0.4rem; + width: calc(100% - 9rem); + margin: 0.5rem; + padding: 0.5rem 1rem 0.5rem 7rem; + border-radius: 10px; +} + +.judge > li > span { + height: calc(100% - 1rem); + padding: 0.5rem 0; + top: 0; + border-radius: 10px; +} + + +@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700"); +:root { + font-family: "Montserrat"; +} + +html, +body { + margin: 0; + height: 100%; +} + +body { + display: flex; + align-items: center; + justify-content: center; +} + +i { + color: inherit; +} + +.banners-container { + position: fixed; + top: 0; + left: 0; + width: 100%; + z-index: 9; +} + +.banner { + color: white; + font-weight: 700; + padding: 2rem; + display: flex; + flex-direction: row; + align-items: center; +} +.banner .banner-message { + flex: 1; + padding: 0 2rem; + word-break: break-word; + overflow: auto; +} +.banner .banner-close { + display: flex; + align-items: center; + justify-content: center; + padding: 0.1rem; + border-radius: 4px; + cursor: pointer; + transition: background 0.3s; +} + +.banner .iconfont { + font-size: 2rem; +} + +.banner .banner-close:hover { + background: rgba(0, 0, 0, 0.12); +} + +.banner.success { + background: lightgreen; +} +.banner.success::after { + background: lightgreen; +} +.banner.error { + background: #ed1c24; +} +.banner.error::after { + background: #ed1c24; +} +.banner.info { + background: skyblue; +} +.banner.info::after { + background: skyblue; +} + +.banner::after { + content: ""; + position: absolute; + height: 10%; + width: 100%; + bottom: 100%; + left: 0; +} + +.banner:not(.visible) { + display: none; + transform: translateY(-100%); +} + +.banner.visible { + box-shadow: 0 2px 2px 2px rgba(0, 0, 0, 0.12); + animation-name: banner-in; + animation-direction: forwards; + animation-duration: 0.6s; + animation-timing-function: ease-in-out; + animation-fill-mode: forwards; + animation-iteration-count: 1; +} + +@keyframes banner-in { + 0% { + transform: translateY(-100%); + } + 50% { + transform: translateY(10%); + } + 100% { + transform: translateY(0); + } +} +.show-banner { + appearance: none; + background: #ededed; + border: 0; + padding: 1rem 2rem; + border-radius: 4px; + cursor: pointer; + text-transform: uppercase; + margin: 0.25rem; +} + +/** + * @license + * Copyright Akveo. All Rights Reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + .eva-animation { + animation-duration: 1s; + animation-fill-mode: both; } + + .eva-infinite { + animation-iteration-count: infinite; } + + .eva-icon-shake { + animation-name: eva-shake; } + + .eva-icon-zoom { + animation-name: eva-zoomIn; } + + .eva-icon-pulse { + animation-name: eva-pulse; } + + .eva-icon-flip { + animation-name: eva-flipInY; } + + .eva-hover { + display: inline-block; } + + .eva-hover:hover .eva-icon-hover-shake, .eva-parent-hover:hover .eva-icon-hover-shake { + animation-name: eva-shake; } + + .eva-hover:hover .eva-icon-hover-zoom, .eva-parent-hover:hover .eva-icon-hover-zoom { + animation-name: eva-zoomIn; } + + .eva-hover:hover .eva-icon-hover-pulse, .eva-parent-hover:hover .eva-icon-hover-pulse { + animation-name: eva-pulse; } + + .eva-hover:hover .eva-icon-hover-flip, .eva-parent-hover:hover .eva-icon-hover-flip { + animation-name: eva-flipInY; } + + @keyframes eva-flipInY { + from { + transform: perspective(400px) rotate3d(0, 1, 0, 90deg); + animation-timing-function: ease-in; + opacity: 0; } + 40% { + transform: perspective(400px) rotate3d(0, 1, 0, -20deg); + animation-timing-function: ease-in; } + 60% { + transform: perspective(400px) rotate3d(0, 1, 0, 10deg); + opacity: 1; } + 80% { + transform: perspective(400px) rotate3d(0, 1, 0, -5deg); } + to { + transform: perspective(400px); } } + + @keyframes eva-shake { + from, + to { + transform: translate3d(0, 0, 0); } + 10%, + 30%, + 50%, + 70%, + 90% { + transform: translate3d(-3px, 0, 0); } + 20%, + 40%, + 60%, + 80% { + transform: translate3d(3px, 0, 0); } } + + @keyframes eva-pulse { + from { + transform: scale3d(1, 1, 1); } + 50% { + transform: scale3d(1.2, 1.2, 1.2); } + to { + transform: scale3d(1, 1, 1); } } + + @keyframes eva-zoomIn { + from { + opacity: 1; + transform: scale3d(0.5, 0.5, 0.5); } + 50% { + opacity: 1; } } + +::-webkit-scrollbar { + width: 0 !important +} \ No newline at end of file diff --git a/games/mario/3rd/backbone.js b/games/mario/3rd/backbone.js new file mode 100644 index 0000000..f7783c2 --- /dev/null +++ b/games/mario/3rd/backbone.js @@ -0,0 +1,1581 @@ +// Backbone.js 1.1.0 + +// (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc. +// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Backbone may be freely distributed under the MIT license. +// For all details and documentation: +// http://backbonejs.org + +(function(){ + + // Initial Setup + // ------------- + + // Save a reference to the global object (`window` in the browser, `exports` + // on the server). + var root = this; + + // Save the previous value of the `Backbone` variable, so that it can be + // restored later on, if `noConflict` is used. + var previousBackbone = root.Backbone; + + // Create local references to array methods we'll want to use later. + var array = []; + var push = array.push; + var slice = array.slice; + var splice = array.splice; + + // The top-level namespace. All public Backbone classes and modules will + // be attached to this. Exported for both the browser and the server. + var Backbone; + if (typeof exports !== 'undefined') { + Backbone = exports; + } else { + Backbone = root.Backbone = {}; + } + + // Current version of the library. Keep in sync with `package.json`. + Backbone.VERSION = '1.1.0'; + + // Require Underscore, if we're on the server, and it's not already present. + var _ = root._; + if (!_ && (typeof require !== 'undefined')) _ = require('underscore'); + + // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns + // the `$` variable. + Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$; + + // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable + // to its previous owner. Returns a reference to this Backbone object. + Backbone.noConflict = function() { + root.Backbone = previousBackbone; + return this; + }; + + // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option + // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and + // set a `X-Http-Method-Override` header. + Backbone.emulateHTTP = false; + + // Turn on `emulateJSON` to support legacy servers that can't deal with direct + // `application/json` requests ... will encode the body as + // `application/x-www-form-urlencoded` instead and will send the model in a + // form param named `model`. + Backbone.emulateJSON = false; + + // Backbone.Events + // --------------- + + // A module that can be mixed in to *any object* in order to provide it with + // custom events. You may bind with `on` or remove with `off` callback + // functions to an event; `trigger`-ing an event fires all callbacks in + // succession. + // + // var object = {}; + // _.extend(object, Backbone.Events); + // object.on('expand', function(){ alert('expanded'); }); + // object.trigger('expand'); + // + var Events = Backbone.Events = { + + // Bind an event to a `callback` function. Passing `"all"` will bind + // the callback to all events fired. + on: function(name, callback, context) { + if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; + this._events || (this._events = {}); + var events = this._events[name] || (this._events[name] = []); + events.push({callback: callback, context: context, ctx: context || this}); + return this; + }, + + // Bind an event to only be triggered a single time. After the first time + // the callback is invoked, it will be removed. + once: function(name, callback, context) { + if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; + var self = this; + var once = _.once(function() { + self.off(name, once); + callback.apply(this, arguments); + }); + once._callback = callback; + return this.on(name, once, context); + }, + + // Remove one or many callbacks. If `context` is null, removes all + // callbacks with that function. If `callback` is null, removes all + // callbacks for the event. If `name` is null, removes all bound + // callbacks for all events. + off: function(name, callback, context) { + var retain, ev, events, names, i, l, j, k; + if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; + if (!name && !callback && !context) { + this._events = {}; + return this; + } + names = name ? [name] : _.keys(this._events); + for (i = 0, l = names.length; i < l; i++) { + name = names[i]; + if (events = this._events[name]) { + this._events[name] = retain = []; + if (callback || context) { + for (j = 0, k = events.length; j < k; j++) { + ev = events[j]; + if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || + (context && context !== ev.context)) { + retain.push(ev); + } + } + } + if (!retain.length) delete this._events[name]; + } + } + + return this; + }, + + // Trigger one or many events, firing all bound callbacks. Callbacks are + // passed the same arguments as `trigger` is, apart from the event name + // (unless you're listening on `"all"`, which will cause your callback to + // receive the true name of the event as the first argument). + trigger: function(name) { + if (!this._events) return this; + var args = slice.call(arguments, 1); + if (!eventsApi(this, 'trigger', name, args)) return this; + var events = this._events[name]; + var allEvents = this._events.all; + if (events) triggerEvents(events, args); + if (allEvents) triggerEvents(allEvents, arguments); + return this; + }, + + // Tell this object to stop listening to either specific events ... or + // to every object it's currently listening to. + stopListening: function(obj, name, callback) { + var listeningTo = this._listeningTo; + if (!listeningTo) return this; + var remove = !name && !callback; + if (!callback && typeof name === 'object') callback = this; + if (obj) (listeningTo = {})[obj._listenId] = obj; + for (var id in listeningTo) { + obj = listeningTo[id]; + obj.off(name, callback, this); + if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id]; + } + return this; + } + + }; + + // Regular expression used to split event strings. + var eventSplitter = /\s+/; + + // Implement fancy features of the Events API such as multiple event + // names `"change blur"` and jQuery-style event maps `{change: action}` + // in terms of the existing API. + var eventsApi = function(obj, action, name, rest) { + if (!name) return true; + + // Handle event maps. + if (typeof name === 'object') { + for (var key in name) { + obj[action].apply(obj, [key, name[key]].concat(rest)); + } + return false; + } + + // Handle space separated event names. + if (eventSplitter.test(name)) { + var names = name.split(eventSplitter); + for (var i = 0, l = names.length; i < l; i++) { + obj[action].apply(obj, [names[i]].concat(rest)); + } + return false; + } + + return true; + }; + + // A difficult-to-believe, but optimized internal dispatch function for + // triggering events. Tries to keep the usual cases speedy (most internal + // Backbone events have 3 arguments). + var triggerEvents = function(events, args) { + var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; + switch (args.length) { + case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; + case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; + case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; + case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; + default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); + } + }; + + var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; + + // Inversion-of-control versions of `on` and `once`. Tell *this* object to + // listen to an event in another object ... keeping track of what it's + // listening to. + _.each(listenMethods, function(implementation, method) { + Events[method] = function(obj, name, callback) { + var listeningTo = this._listeningTo || (this._listeningTo = {}); + var id = obj._listenId || (obj._listenId = _.uniqueId('l')); + listeningTo[id] = obj; + if (!callback && typeof name === 'object') callback = this; + obj[implementation](name, callback, this); + return this; + }; + }); + + // Aliases for backwards compatibility. + Events.bind = Events.on; + Events.unbind = Events.off; + + // Allow the `Backbone` object to serve as a global event bus, for folks who + // want global "pubsub" in a convenient place. + _.extend(Backbone, Events); + + // Backbone.Model + // -------------- + + // Backbone **Models** are the basic data object in the framework -- + // frequently representing a row in a table in a database on your server. + // A discrete chunk of data and a bunch of useful, related methods for + // performing computations and transformations on that data. + + // Create a new model with the specified attributes. A client id (`cid`) + // is automatically generated and assigned for you. + var Model = Backbone.Model = function(attributes, options) { + var attrs = attributes || {}; + options || (options = {}); + this.cid = _.uniqueId('c'); + this.attributes = {}; + if (options.collection) this.collection = options.collection; + if (options.parse) attrs = this.parse(attrs, options) || {}; + attrs = _.defaults({}, attrs, _.result(this, 'defaults')); + this.set(attrs, options); + this.changed = {}; + this.initialize.apply(this, arguments); + }; + + // Attach all inheritable methods to the Model prototype. + _.extend(Model.prototype, Events, { + + // A hash of attributes whose current and previous value differ. + changed: null, + + // The value returned during the last failed validation. + validationError: null, + + // The default name for the JSON `id` attribute is `"id"`. MongoDB and + // CouchDB users may want to set this to `"_id"`. + idAttribute: 'id', + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // Return a copy of the model's `attributes` object. + toJSON: function(options) { + return _.clone(this.attributes); + }, + + // Proxy `Backbone.sync` by default -- but override this if you need + // custom syncing semantics for *this* particular model. + sync: function() { + return Backbone.sync.apply(this, arguments); + }, + + // Get the value of an attribute. + get: function(attr) { + return this.attributes[attr]; + }, + + // Get the HTML-escaped value of an attribute. + escape: function(attr) { + return _.escape(this.get(attr)); + }, + + // Returns `true` if the attribute contains a value that is not null + // or undefined. + has: function(attr) { + return this.get(attr) != null; + }, + + // Set a hash of model attributes on the object, firing `"change"`. This is + // the core primitive operation of a model, updating the data and notifying + // anyone who needs to know about the change in state. The heart of the beast. + set: function(key, val, options) { + var attr, attrs, unset, changes, silent, changing, prev, current; + if (key == null) return this; + + // Handle both `"key", value` and `{key: value}` -style arguments. + if (typeof key === 'object') { + attrs = key; + options = val; + } else { + (attrs = {})[key] = val; + } + + options || (options = {}); + + // Run validation. + if (!this._validate(attrs, options)) return false; + + // Extract attributes and options. + unset = options.unset; + silent = options.silent; + changes = []; + changing = this._changing; + this._changing = true; + + if (!changing) { + this._previousAttributes = _.clone(this.attributes); + this.changed = {}; + } + current = this.attributes, prev = this._previousAttributes; + + // Check for changes of `id`. + if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; + + // For each `set` attribute, update or delete the current value. + for (attr in attrs) { + val = attrs[attr]; + if (!_.isEqual(current[attr], val)) changes.push(attr); + if (!_.isEqual(prev[attr], val)) { + this.changed[attr] = val; + } else { + delete this.changed[attr]; + } + unset ? delete current[attr] : current[attr] = val; + } + + // Trigger all relevant attribute changes. + if (!silent) { + if (changes.length) this._pending = true; + for (var i = 0, l = changes.length; i < l; i++) { + this.trigger('change:' + changes[i], this, current[changes[i]], options); + } + } + + // You might be wondering why there's a `while` loop here. Changes can + // be recursively nested within `"change"` events. + if (changing) return this; + if (!silent) { + while (this._pending) { + this._pending = false; + this.trigger('change', this, options); + } + } + this._pending = false; + this._changing = false; + return this; + }, + + // Remove an attribute from the model, firing `"change"`. `unset` is a noop + // if the attribute doesn't exist. + unset: function(attr, options) { + return this.set(attr, void 0, _.extend({}, options, {unset: true})); + }, + + // Clear all attributes on the model, firing `"change"`. + clear: function(options) { + var attrs = {}; + for (var key in this.attributes) attrs[key] = void 0; + return this.set(attrs, _.extend({}, options, {unset: true})); + }, + + // Determine if the model has changed since the last `"change"` event. + // If you specify an attribute name, determine if that attribute has changed. + hasChanged: function(attr) { + if (attr == null) return !_.isEmpty(this.changed); + return _.has(this.changed, attr); + }, + + // Return an object containing all the attributes that have changed, or + // false if there are no changed attributes. Useful for determining what + // parts of a view need to be updated and/or what attributes need to be + // persisted to the server. Unset attributes will be set to undefined. + // You can also pass an attributes object to diff against the model, + // determining if there *would be* a change. + changedAttributes: function(diff) { + if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; + var val, changed = false; + var old = this._changing ? this._previousAttributes : this.attributes; + for (var attr in diff) { + if (_.isEqual(old[attr], (val = diff[attr]))) continue; + (changed || (changed = {}))[attr] = val; + } + return changed; + }, + + // Get the previous value of an attribute, recorded at the time the last + // `"change"` event was fired. + previous: function(attr) { + if (attr == null || !this._previousAttributes) return null; + return this._previousAttributes[attr]; + }, + + // Get all of the attributes of the model at the time of the previous + // `"change"` event. + previousAttributes: function() { + return _.clone(this._previousAttributes); + }, + + // Fetch the model from the server. If the server's representation of the + // model differs from its current attributes, they will be overridden, + // triggering a `"change"` event. + fetch: function(options) { + options = options ? _.clone(options) : {}; + if (options.parse === void 0) options.parse = true; + var model = this; + var success = options.success; + options.success = function(resp) { + if (!model.set(model.parse(resp, options), options)) return false; + if (success) success(model, resp, options); + model.trigger('sync', model, resp, options); + }; + wrapError(this, options); + return this.sync('read', this, options); + }, + + // Set a hash of model attributes, and sync the model to the server. + // If the server returns an attributes hash that differs, the model's + // state will be `set` again. + save: function(key, val, options) { + var attrs, method, xhr, attributes = this.attributes; + + // Handle both `"key", value` and `{key: value}` -style arguments. + if (key == null || typeof key === 'object') { + attrs = key; + options = val; + } else { + (attrs = {})[key] = val; + } + + options = _.extend({validate: true}, options); + + // If we're not waiting and attributes exist, save acts as + // `set(attr).save(null, opts)` with validation. Otherwise, check if + // the model will be valid when the attributes, if any, are set. + if (attrs && !options.wait) { + if (!this.set(attrs, options)) return false; + } else { + if (!this._validate(attrs, options)) return false; + } + + // Set temporary attributes if `{wait: true}`. + if (attrs && options.wait) { + this.attributes = _.extend({}, attributes, attrs); + } + + // After a successful server-side save, the client is (optionally) + // updated with the server-side state. + if (options.parse === void 0) options.parse = true; + var model = this; + var success = options.success; + options.success = function(resp) { + // Ensure attributes are restored during synchronous saves. + model.attributes = attributes; + var serverAttrs = model.parse(resp, options); + if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); + if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { + return false; + } + if (success) success(model, resp, options); + model.trigger('sync', model, resp, options); + }; + wrapError(this, options); + + method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); + if (method === 'patch') options.attrs = attrs; + xhr = this.sync(method, this, options); + + // Restore attributes. + if (attrs && options.wait) this.attributes = attributes; + + return xhr; + }, + + // Destroy this model on the server if it was already persisted. + // Optimistically removes the model from its collection, if it has one. + // If `wait: true` is passed, waits for the server to respond before removal. + destroy: function(options) { + options = options ? _.clone(options) : {}; + var model = this; + var success = options.success; + + var destroy = function() { + model.trigger('destroy', model, model.collection, options); + }; + + options.success = function(resp) { + if (options.wait || model.isNew()) destroy(); + if (success) success(model, resp, options); + if (!model.isNew()) model.trigger('sync', model, resp, options); + }; + + if (this.isNew()) { + options.success(); + return false; + } + wrapError(this, options); + + var xhr = this.sync('delete', this, options); + if (!options.wait) destroy(); + return xhr; + }, + + // Default URL for the model's representation on the server -- if you're + // using Backbone's restful methods, override this to change the endpoint + // that will be called. + url: function() { + var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError(); + if (this.isNew()) return base; + return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id); + }, + + // **parse** converts a response into the hash of attributes to be `set` on + // the model. The default implementation is just to pass the response along. + parse: function(resp, options) { + return resp; + }, + + // Create a new model with identical attributes to this one. + clone: function() { + return new this.constructor(this.attributes); + }, + + // A model is new if it has never been saved to the server, and lacks an id. + isNew: function() { + return this.id == null; + }, + + // Check if the model is currently in a valid state. + isValid: function(options) { + return this._validate({}, _.extend(options || {}, { validate: true })); + }, + + // Run validation against the next complete set of model attributes, + // returning `true` if all is well. Otherwise, fire an `"invalid"` event. + _validate: function(attrs, options) { + if (!options.validate || !this.validate) return true; + attrs = _.extend({}, this.attributes, attrs); + var error = this.validationError = this.validate(attrs, options) || null; + if (!error) return true; + this.trigger('invalid', this, error, _.extend(options, {validationError: error})); + return false; + } + + }); + + // Underscore methods that we want to implement on the Model. + var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit']; + + // Mix in each Underscore method as a proxy to `Model#attributes`. + _.each(modelMethods, function(method) { + Model.prototype[method] = function() { + var args = slice.call(arguments); + args.unshift(this.attributes); + return _[method].apply(_, args); + }; + }); + + // Backbone.Collection + // ------------------- + + // If models tend to represent a single row of data, a Backbone Collection is + // more analagous to a table full of data ... or a small slice or page of that + // table, or a collection of rows that belong together for a particular reason + // -- all of the messages in this particular folder, all of the documents + // belonging to this particular author, and so on. Collections maintain + // indexes of their models, both in order, and for lookup by `id`. + + // Create a new **Collection**, perhaps to contain a specific type of `model`. + // If a `comparator` is specified, the Collection will maintain + // its models in sort order, as they're added and removed. + var Collection = Backbone.Collection = function(models, options) { + options || (options = {}); + if (options.model) this.model = options.model; + if (options.comparator !== void 0) this.comparator = options.comparator; + this._reset(); + this.initialize.apply(this, arguments); + if (models) this.reset(models, _.extend({silent: true}, options)); + }; + + // Default options for `Collection#set`. + var setOptions = {add: true, remove: true, merge: true}; + var addOptions = {add: true, remove: false}; + + // Define the Collection's inheritable methods. + _.extend(Collection.prototype, Events, { + + // The default model for a collection is just a **Backbone.Model**. + // This should be overridden in most cases. + model: Model, + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // The JSON representation of a Collection is an array of the + // models' attributes. + toJSON: function(options) { + return this.map(function(model){ return model.toJSON(options); }); + }, + + // Proxy `Backbone.sync` by default. + sync: function() { + return Backbone.sync.apply(this, arguments); + }, + + // Add a model, or list of models to the set. + add: function(models, options) { + return this.set(models, _.extend({merge: false}, options, addOptions)); + }, + + // Remove a model, or a list of models from the set. + remove: function(models, options) { + var singular = !_.isArray(models); + models = singular ? [models] : _.clone(models); + options || (options = {}); + var i, l, index, model; + for (i = 0, l = models.length; i < l; i++) { + model = models[i] = this.get(models[i]); + if (!model) continue; + delete this._byId[model.id]; + delete this._byId[model.cid]; + index = this.indexOf(model); + this.models.splice(index, 1); + this.length--; + if (!options.silent) { + options.index = index; + model.trigger('remove', model, this, options); + } + this._removeReference(model); + } + return singular ? models[0] : models; + }, + + // Update a collection by `set`-ing a new list of models, adding new ones, + // removing models that are no longer present, and merging models that + // already exist in the collection, as necessary. Similar to **Model#set**, + // the core operation for updating the data contained by the collection. + set: function(models, options) { + options = _.defaults({}, options, setOptions); + if (options.parse) models = this.parse(models, options); + var singular = !_.isArray(models); + models = singular ? (models ? [models] : []) : _.clone(models); + var i, l, id, model, attrs, existing, sort; + var at = options.at; + var targetModel = this.model; + var sortable = this.comparator && (at == null) && options.sort !== false; + var sortAttr = _.isString(this.comparator) ? this.comparator : null; + var toAdd = [], toRemove = [], modelMap = {}; + var add = options.add, merge = options.merge, remove = options.remove; + var order = !sortable && add && remove ? [] : false; + + // Turn bare objects into model references, and prevent invalid models + // from being added. + for (i = 0, l = models.length; i < l; i++) { + attrs = models[i]; + if (attrs instanceof Model) { + id = model = attrs; + } else { + id = attrs[targetModel.prototype.idAttribute]; + } + + // If a duplicate is found, prevent it from being added and + // optionally merge it into the existing model. + if (existing = this.get(id)) { + if (remove) modelMap[existing.cid] = true; + if (merge) { + attrs = attrs === model ? model.attributes : attrs; + if (options.parse) attrs = existing.parse(attrs, options); + existing.set(attrs, options); + if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true; + } + models[i] = existing; + + // If this is a new, valid model, push it to the `toAdd` list. + } else if (add) { + model = models[i] = this._prepareModel(attrs, options); + if (!model) continue; + toAdd.push(model); + + // Listen to added models' events, and index models for lookup by + // `id` and by `cid`. + model.on('all', this._onModelEvent, this); + this._byId[model.cid] = model; + if (model.id != null) this._byId[model.id] = model; + } + if (order) order.push(existing || model); + } + + // Remove nonexistent models if appropriate. + if (remove) { + for (i = 0, l = this.length; i < l; ++i) { + if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model); + } + if (toRemove.length) this.remove(toRemove, options); + } + + // See if sorting is needed, update `length` and splice in new models. + if (toAdd.length || (order && order.length)) { + if (sortable) sort = true; + this.length += toAdd.length; + if (at != null) { + for (i = 0, l = toAdd.length; i < l; i++) { + this.models.splice(at + i, 0, toAdd[i]); + } + } else { + if (order) this.models.length = 0; + var orderedModels = order || toAdd; + for (i = 0, l = orderedModels.length; i < l; i++) { + this.models.push(orderedModels[i]); + } + } + } + + // Silently sort the collection if appropriate. + if (sort) this.sort({silent: true}); + + // Unless silenced, it's time to fire all appropriate add/sort events. + if (!options.silent) { + for (i = 0, l = toAdd.length; i < l; i++) { + (model = toAdd[i]).trigger('add', model, this, options); + } + if (sort || (order && order.length)) this.trigger('sort', this, options); + } + + // Return the added (or merged) model (or models). + return singular ? models[0] : models; + }, + + // When you have more items than you want to add or remove individually, + // you can reset the entire set with a new list of models, without firing + // any granular `add` or `remove` events. Fires `reset` when finished. + // Useful for bulk operations and optimizations. + reset: function(models, options) { + options || (options = {}); + for (var i = 0, l = this.models.length; i < l; i++) { + this._removeReference(this.models[i]); + } + options.previousModels = this.models; + this._reset(); + models = this.add(models, _.extend({silent: true}, options)); + if (!options.silent) this.trigger('reset', this, options); + return models; + }, + + // Add a model to the end of the collection. + push: function(model, options) { + return this.add(model, _.extend({at: this.length}, options)); + }, + + // Remove a model from the end of the collection. + pop: function(options) { + var model = this.at(this.length - 1); + this.remove(model, options); + return model; + }, + + // Add a model to the beginning of the collection. + unshift: function(model, options) { + return this.add(model, _.extend({at: 0}, options)); + }, + + // Remove a model from the beginning of the collection. + shift: function(options) { + var model = this.at(0); + this.remove(model, options); + return model; + }, + + // Slice out a sub-array of models from the collection. + slice: function() { + return slice.apply(this.models, arguments); + }, + + // Get a model from the set by id. + get: function(obj) { + if (obj == null) return void 0; + return this._byId[obj.id] || this._byId[obj.cid] || this._byId[obj]; + }, + + // Get the model at the given index. + at: function(index) { + return this.models[index]; + }, + + // Return models with matching attributes. Useful for simple cases of + // `filter`. + where: function(attrs, first) { + if (_.isEmpty(attrs)) return first ? void 0 : []; + return this[first ? 'find' : 'filter'](function(model) { + for (var key in attrs) { + if (attrs[key] !== model.get(key)) return false; + } + return true; + }); + }, + + // Return the first model with matching attributes. Useful for simple cases + // of `find`. + findWhere: function(attrs) { + return this.where(attrs, true); + }, + + // Force the collection to re-sort itself. You don't need to call this under + // normal circumstances, as the set will maintain sort order as each item + // is added. + sort: function(options) { + if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); + options || (options = {}); + + // Run sort based on type of `comparator`. + if (_.isString(this.comparator) || this.comparator.length === 1) { + this.models = this.sortBy(this.comparator, this); + } else { + this.models.sort(_.bind(this.comparator, this)); + } + + if (!options.silent) this.trigger('sort', this, options); + return this; + }, + + // Pluck an attribute from each model in the collection. + pluck: function(attr) { + return _.invoke(this.models, 'get', attr); + }, + + // Fetch the default set of models for this collection, resetting the + // collection when they arrive. If `reset: true` is passed, the response + // data will be passed through the `reset` method instead of `set`. + fetch: function(options) { + options = options ? _.clone(options) : {}; + if (options.parse === void 0) options.parse = true; + var success = options.success; + var collection = this; + options.success = function(resp) { + var method = options.reset ? 'reset' : 'set'; + collection[method](resp, options); + if (success) success(collection, resp, options); + collection.trigger('sync', collection, resp, options); + }; + wrapError(this, options); + return this.sync('read', this, options); + }, + + // Create a new instance of a model in this collection. Add the model to the + // collection immediately, unless `wait: true` is passed, in which case we + // wait for the server to agree. + create: function(model, options) { + options = options ? _.clone(options) : {}; + if (!(model = this._prepareModel(model, options))) return false; + if (!options.wait) this.add(model, options); + var collection = this; + var success = options.success; + options.success = function(model, resp, options) { + if (options.wait) collection.add(model, options); + if (success) success(model, resp, options); + }; + model.save(null, options); + return model; + }, + + // **parse** converts a response into a list of models to be added to the + // collection. The default implementation is just to pass it through. + parse: function(resp, options) { + return resp; + }, + + // Create a new collection with an identical list of models as this one. + clone: function() { + return new this.constructor(this.models); + }, + + // Private method to reset all internal state. Called when the collection + // is first initialized or reset. + _reset: function() { + this.length = 0; + this.models = []; + this._byId = {}; + }, + + // Prepare a hash of attributes (or other model) to be added to this + // collection. + _prepareModel: function(attrs, options) { + if (attrs instanceof Model) { + if (!attrs.collection) attrs.collection = this; + return attrs; + } + options = options ? _.clone(options) : {}; + options.collection = this; + var model = new this.model(attrs, options); + if (!model.validationError) return model; + this.trigger('invalid', this, model.validationError, options); + return false; + }, + + // Internal method to sever a model's ties to a collection. + _removeReference: function(model) { + if (this === model.collection) delete model.collection; + model.off('all', this._onModelEvent, this); + }, + + // Internal method called every time a model in the set fires an event. + // Sets need to update their indexes when models change ids. All other + // events simply proxy through. "add" and "remove" events that originate + // in other collections are ignored. + _onModelEvent: function(event, model, collection, options) { + if ((event === 'add' || event === 'remove') && collection !== this) return; + if (event === 'destroy') this.remove(model, options); + if (model && event === 'change:' + model.idAttribute) { + delete this._byId[model.previous(model.idAttribute)]; + if (model.id != null) this._byId[model.id] = model; + } + this.trigger.apply(this, arguments); + } + + }); + + // Underscore methods that we want to implement on the Collection. + // 90% of the core usefulness of Backbone Collections is actually implemented + // right here: + var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', + 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', + 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', + 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', + 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle', + 'lastIndexOf', 'isEmpty', 'chain']; + + // Mix in each Underscore method as a proxy to `Collection#models`. + _.each(methods, function(method) { + Collection.prototype[method] = function() { + var args = slice.call(arguments); + args.unshift(this.models); + return _[method].apply(_, args); + }; + }); + + // Underscore methods that take a property name as an argument. + var attributeMethods = ['groupBy', 'countBy', 'sortBy']; + + // Use attributes instead of properties. + _.each(attributeMethods, function(method) { + Collection.prototype[method] = function(value, context) { + var iterator = _.isFunction(value) ? value : function(model) { + return model.get(value); + }; + return _[method](this.models, iterator, context); + }; + }); + + // Backbone.View + // ------------- + + // Backbone Views are almost more convention than they are actual code. A View + // is simply a JavaScript object that represents a logical chunk of UI in the + // DOM. This might be a single item, an entire list, a sidebar or panel, or + // even the surrounding frame which wraps your whole app. Defining a chunk of + // UI as a **View** allows you to define your DOM events declaratively, without + // having to worry about render order ... and makes it easy for the view to + // react to specific changes in the state of your models. + + // Creating a Backbone.View creates its initial element outside of the DOM, + // if an existing element is not provided... + var View = Backbone.View = function(options) { + this.cid = _.uniqueId('view'); + options || (options = {}); + _.extend(this, _.pick(options, viewOptions)); + this._ensureElement(); + this.initialize.apply(this, arguments); + this.delegateEvents(); + }; + + // Cached regex to split keys for `delegate`. + var delegateEventSplitter = /^(\S+)\s*(.*)$/; + + // List of view options to be merged as properties. + var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; + + // Set up all inheritable **Backbone.View** properties and methods. + _.extend(View.prototype, Events, { + + // The default `tagName` of a View's element is `"div"`. + tagName: 'div', + + // jQuery delegate for element lookup, scoped to DOM elements within the + // current view. This should be preferred to global lookups where possible. + $: function(selector) { + return this.$el.find(selector); + }, + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // **render** is the core function that your view should override, in order + // to populate its element (`this.el`), with the appropriate HTML. The + // convention is for **render** to always return `this`. + render: function() { + return this; + }, + + // Remove this view by taking the element out of the DOM, and removing any + // applicable Backbone.Events listeners. + remove: function() { + this.$el.remove(); + this.stopListening(); + return this; + }, + + // Change the view's element (`this.el` property), including event + // re-delegation. + setElement: function(element, delegate) { + if (this.$el) this.undelegateEvents(); + this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); + this.el = this.$el[0]; + if (delegate !== false) this.delegateEvents(); + return this; + }, + + // Set callbacks, where `this.events` is a hash of + // + // *{"event selector": "callback"}* + // + // { + // 'mousedown .title': 'edit', + // 'click .button': 'save', + // 'click .open': function(e) { ... } + // } + // + // pairs. Callbacks will be bound to the view, with `this` set properly. + // Uses event delegation for efficiency. + // Omitting the selector binds the event to `this.el`. + // This only works for delegate-able events: not `focus`, `blur`, and + // not `change`, `submit`, and `reset` in Internet Explorer. + delegateEvents: function(events) { + if (!(events || (events = _.result(this, 'events')))) return this; + this.undelegateEvents(); + for (var key in events) { + var method = events[key]; + if (!_.isFunction(method)) method = this[events[key]]; + if (!method) continue; + + var match = key.match(delegateEventSplitter); + var eventName = match[1], selector = match[2]; + method = _.bind(method, this); + eventName += '.delegateEvents' + this.cid; + if (selector === '') { + this.$el.on(eventName, method); + } else { + this.$el.on(eventName, selector, method); + } + } + return this; + }, + + // Clears all callbacks previously bound to the view with `delegateEvents`. + // You usually don't need to use this, but may wish to if you have multiple + // Backbone views attached to the same DOM element. + undelegateEvents: function() { + this.$el.off('.delegateEvents' + this.cid); + return this; + }, + + // Ensure that the View has a DOM element to render into. + // If `this.el` is a string, pass it through `$()`, take the first + // matching element, and re-assign it to `el`. Otherwise, create + // an element from the `id`, `className` and `tagName` properties. + _ensureElement: function() { + if (!this.el) { + var attrs = _.extend({}, _.result(this, 'attributes')); + if (this.id) attrs.id = _.result(this, 'id'); + if (this.className) attrs['class'] = _.result(this, 'className'); + var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); + this.setElement($el, false); + } else { + this.setElement(_.result(this, 'el'), false); + } + } + + }); + + // Backbone.sync + // ------------- + + // Override this function to change the manner in which Backbone persists + // models to the server. You will be passed the type of request, and the + // model in question. By default, makes a RESTful Ajax request + // to the model's `url()`. Some possible customizations could be: + // + // * Use `setTimeout` to batch rapid-fire updates into a single request. + // * Send up the models as XML instead of JSON. + // * Persist models via WebSockets instead of Ajax. + // + // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests + // as `POST`, with a `_method` parameter containing the true HTTP method, + // as well as all requests with the body as `application/x-www-form-urlencoded` + // instead of `application/json` with the model in a param named `model`. + // Useful when interfacing with server-side languages like **PHP** that make + // it difficult to read the body of `PUT` requests. + Backbone.sync = function(method, model, options) { + var type = methodMap[method]; + + // Default options, unless specified. + _.defaults(options || (options = {}), { + emulateHTTP: Backbone.emulateHTTP, + emulateJSON: Backbone.emulateJSON + }); + + // Default JSON-request options. + var params = {type: type, dataType: 'json'}; + + // Ensure that we have a URL. + if (!options.url) { + params.url = _.result(model, 'url') || urlError(); + } + + // Ensure that we have the appropriate request data. + if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { + params.contentType = 'application/json'; + params.data = JSON.stringify(options.attrs || model.toJSON(options)); + } + + // For older servers, emulate JSON by encoding the request into an HTML-form. + if (options.emulateJSON) { + params.contentType = 'application/x-www-form-urlencoded'; + params.data = params.data ? {model: params.data} : {}; + } + + // For older servers, emulate HTTP by mimicking the HTTP method with `_method` + // And an `X-HTTP-Method-Override` header. + if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { + params.type = 'POST'; + if (options.emulateJSON) params.data._method = type; + var beforeSend = options.beforeSend; + options.beforeSend = function(xhr) { + xhr.setRequestHeader('X-HTTP-Method-Override', type); + if (beforeSend) return beforeSend.apply(this, arguments); + }; + } + + // Don't process data on a non-GET request. + if (params.type !== 'GET' && !options.emulateJSON) { + params.processData = false; + } + + // If we're sending a `PATCH` request, and we're in an old Internet Explorer + // that still has ActiveX enabled by default, override jQuery to use that + // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8. + if (params.type === 'PATCH' && noXhrPatch) { + params.xhr = function() { + return new ActiveXObject("Microsoft.XMLHTTP"); + }; + } + + // Make the request, allowing the user to override any Ajax options. + var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); + model.trigger('request', model, xhr, options); + return xhr; + }; + + var noXhrPatch = typeof window !== 'undefined' && !!window.ActiveXObject && !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent); + + // Map from CRUD to HTTP for our default `Backbone.sync` implementation. + var methodMap = { + 'create': 'POST', + 'update': 'PUT', + 'patch': 'PATCH', + 'delete': 'DELETE', + 'read': 'GET' + }; + + // Set the default implementation of `Backbone.ajax` to proxy through to `$`. + // Override this if you'd like to use a different library. + Backbone.ajax = function() { + return Backbone.$.ajax.apply(Backbone.$, arguments); + }; + + // Backbone.Router + // --------------- + + // Routers map faux-URLs to actions, and fire events when routes are + // matched. Creating a new one sets its `routes` hash, if not set statically. + var Router = Backbone.Router = function(options) { + options || (options = {}); + if (options.routes) this.routes = options.routes; + this._bindRoutes(); + this.initialize.apply(this, arguments); + }; + + // Cached regular expressions for matching named param parts and splatted + // parts of route strings. + var optionalParam = /\((.*?)\)/g; + var namedParam = /(\(\?)?:\w+/g; + var splatParam = /\*\w+/g; + var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; + + // Set up all inheritable **Backbone.Router** properties and methods. + _.extend(Router.prototype, Events, { + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // Manually bind a single named route to a callback. For example: + // + // this.route('search/:query/p:num', 'search', function(query, num) { + // ... + // }); + // + route: function(route, name, callback) { + if (!_.isRegExp(route)) route = this._routeToRegExp(route); + if (_.isFunction(name)) { + callback = name; + name = ''; + } + if (!callback) callback = this[name]; + var router = this; + Backbone.history.route(route, function(fragment) { + var args = router._extractParameters(route, fragment); + callback && callback.apply(router, args); + router.trigger.apply(router, ['route:' + name].concat(args)); + router.trigger('route', name, args); + Backbone.history.trigger('route', router, name, args); + }); + return this; + }, + + // Simple proxy to `Backbone.history` to save a fragment into the history. + navigate: function(fragment, options) { + Backbone.history.navigate(fragment, options); + return this; + }, + + // Bind all defined routes to `Backbone.history`. We have to reverse the + // order of the routes here to support behavior where the most general + // routes can be defined at the bottom of the route map. + _bindRoutes: function() { + if (!this.routes) return; + this.routes = _.result(this, 'routes'); + var route, routes = _.keys(this.routes); + while ((route = routes.pop()) != null) { + this.route(route, this.routes[route]); + } + }, + + // Convert a route string into a regular expression, suitable for matching + // against the current location hash. + _routeToRegExp: function(route) { + route = route.replace(escapeRegExp, '\\$&') + .replace(optionalParam, '(?:$1)?') + .replace(namedParam, function(match, optional) { + return optional ? match : '([^\/]+)'; + }) + .replace(splatParam, '(.*?)'); + return new RegExp('^' + route + '$'); + }, + + // Given a route, and a URL fragment that it matches, return the array of + // extracted decoded parameters. Empty or unmatched parameters will be + // treated as `null` to normalize cross-browser behavior. + _extractParameters: function(route, fragment) { + var params = route.exec(fragment).slice(1); + return _.map(params, function(param) { + return param ? decodeURIComponent(param) : null; + }); + } + + }); + + // Backbone.History + // ---------------- + + // Handles cross-browser history management, based on either + // [pushState](http://diveintohtml5.info/history.html) and real URLs, or + // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) + // and URL fragments. If the browser supports neither (old IE, natch), + // falls back to polling. + var History = Backbone.History = function() { + this.handlers = []; + _.bindAll(this, 'checkUrl'); + + // Ensure that `History` can be used outside of the browser. + if (typeof window !== 'undefined') { + this.location = window.location; + this.history = window.history; + } + }; + + // Cached regex for stripping a leading hash/slash and trailing space. + var routeStripper = /^[#\/]|\s+$/g; + + // Cached regex for stripping leading and trailing slashes. + var rootStripper = /^\/+|\/+$/g; + + // Cached regex for detecting MSIE. + var isExplorer = /msie [\w.]+/; + + // Cached regex for removing a trailing slash. + var trailingSlash = /\/$/; + + // Cached regex for stripping urls of hash and query. + var pathStripper = /[?#].*$/; + + // Has the history handling already been started? + History.started = false; + + // Set up all inheritable **Backbone.History** properties and methods. + _.extend(History.prototype, Events, { + + // The default interval to poll for hash changes, if necessary, is + // twenty times a second. + interval: 50, + + // Gets the true hash value. Cannot use location.hash directly due to bug + // in Firefox where location.hash will always be decoded. + getHash: function(window) { + var match = (window || this).location.href.match(/#(.*)$/); + return match ? match[1] : ''; + }, + + // Get the cross-browser normalized URL fragment, either from the URL, + // the hash, or the override. + getFragment: function(fragment, forcePushState) { + if (fragment == null) { + if (this._hasPushState || !this._wantsHashChange || forcePushState) { + fragment = this.location.pathname; + var root = this.root.replace(trailingSlash, ''); + if (!fragment.indexOf(root)) fragment = fragment.slice(root.length); + } else { + fragment = this.getHash(); + } + } + return fragment.replace(routeStripper, ''); + }, + + // Start the hash change handling, returning `true` if the current URL matches + // an existing route, and `false` otherwise. + start: function(options) { + if (History.started) throw new Error("Backbone.history has already been started"); + History.started = true; + + // Figure out the initial configuration. Do we need an iframe? + // Is pushState desired ... is it available? + this.options = _.extend({root: '/'}, this.options, options); + this.root = this.options.root; + this._wantsHashChange = this.options.hashChange !== false; + this._wantsPushState = !!this.options.pushState; + this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState); + var fragment = this.getFragment(); + var docMode = document.documentMode; + var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); + + // Normalize root to always include a leading and trailing slash. + this.root = ('/' + this.root + '/').replace(rootStripper, '/'); + + if (oldIE && this._wantsHashChange) { + this.iframe = Backbone.$(' + + `; + document.body.appendChild(panel); + + // 应用当前主题 + const settings = getGlobalSettings(); + const theme = settings.theme || "default"; + if (theme !== "default") { + panel.setAttribute("data-mm-theme", theme); + } + + function isMobileUI() { + return ( + (typeof window.matchMedia === "function" && + window.matchMedia("(pointer: coarse)").matches) || + window.innerWidth <= 768 + ); + } + + function isPortrait() { + return ( + (typeof window.matchMedia === "function" && + window.matchMedia("(orientation: portrait)").matches) || + window.innerHeight > window.innerWidth + ); + } + + function shouldForceLandscape(gameId) { + return gameId === "city3d" || gameId === "mario"; + } + + function updateViewportVars() { + const viewport = panel.querySelector(".mm-game-viewport"); + if (!viewport) return; + const rect = viewport.getBoundingClientRect(); + panel.style.setProperty("--mm-viewport-w", rect.width + "px"); + panel.style.setProperty("--mm-viewport-h", rect.height + "px"); + } + + async function enterFullscreenAndLandscape() { + try { + if ( + !document.fullscreenElement && + typeof panel.requestFullscreen === "function" + ) { + await panel.requestFullscreen({ navigationUI: "hide" }); + } + } catch {} + + try { + if (screen?.orientation?.lock) { + await screen.orientation.lock("landscape"); + } + } catch {} + } + + function updateLandscapeOverlay() { + const gameId = panel.dataset.gameId; + const need = + isMobileUI() && + shouldForceLandscape(gameId) && + panel.classList.contains("mm-visible"); + if (!need) { + panel.classList.remove("mm-need-landscape"); + panel.classList.remove("mm-rotate-landscape"); + return; + } + updateViewportVars(); + if (isPortrait()) { + panel.classList.add("mm-rotate-landscape"); + panel.classList.remove("mm-need-landscape"); + } else { + panel.classList.remove("mm-rotate-landscape"); + panel.classList.remove("mm-need-landscape"); + } + } + + panel._mmUpdateLandscapeOverlay = updateLandscapeOverlay; + + // 关闭按钮 + panel + .querySelector(".mm-game-close") + .addEventListener("click", closeGame); + panel + .querySelector(".mm-game-close-overlay") + .addEventListener("click", closeGame); + + // 最小化按钮 + panel + .querySelector(".mm-game-minimize") + .addEventListener("click", () => { + panel.classList.toggle("mm-minimized"); + const icon = panel.querySelector(".mm-game-minimize i"); + if (panel.classList.contains("mm-minimized")) { + icon.className = "fa-solid fa-expand"; + panel.classList.remove("mm-need-landscape"); + panel.classList.remove("mm-rotate-landscape"); + try { + if ( + document.fullscreenElement === panel && + typeof document.exitFullscreen === "function" + ) { + document.exitFullscreen(); + } + } catch {} + try { + if (screen?.orientation?.unlock) + screen.orientation.unlock(); + } catch {} + } else { + icon.className = "fa-solid fa-minus"; + updateLandscapeOverlay(); + } + }); + + // 全屏/横屏按钮 + panel + .querySelector(".mm-game-fullscreen") + .addEventListener("click", async () => { + try { + if ( + document.fullscreenElement === panel && + typeof document.exitFullscreen === "function" + ) { + await document.exitFullscreen(); + if (screen?.orientation?.unlock) + screen.orientation.unlock(); + } else { + await enterFullscreenAndLandscape(); + } + } finally { + updateLandscapeOverlay(); + } + }); + + // 横屏提示按钮(如果存在) + const tryLandscapeBtn = panel.querySelector( + ".mm-game-try-landscape", + ); + if (tryLandscapeBtn) { + tryLandscapeBtn.addEventListener("click", async () => { + await enterFullscreenAndLandscape(); + updateLandscapeOverlay(); + }); + } + + window.addEventListener("resize", updateLandscapeOverlay, { + passive: true, + }); + window.addEventListener( + "orientationchange", + updateLandscapeOverlay, + { passive: true }, + ); + document.addEventListener( + "fullscreenchange", + updateLandscapeOverlay, + ); + + // 拖动功能 + const header = panel.querySelector(".mm-game-panel-header"); + let isDragging = false; + let startX, startY, initialX, initialY; + + header.addEventListener("mousedown", startDrag); + header.addEventListener("touchstart", startDrag, { + passive: false, + }); + + function startDrag(e) { + if (panel.classList.contains("mm-mobile-fullscreen")) return; + if (e.target.closest("button")) return; + isDragging = true; + + const rect = panel.getBoundingClientRect(); + if (e.type === "touchstart") { + startX = e.touches[0].clientX; + startY = e.touches[0].clientY; + } else { + startX = e.clientX; + startY = e.clientY; + } + initialX = rect.left; + initialY = rect.top; + + // 切换到绝对定位 + panel.style.left = initialX + "px"; + panel.style.top = initialY + "px"; + panel.style.transform = "none"; + + document.addEventListener("mousemove", drag); + document.addEventListener("touchmove", drag, { + passive: false, + }); + document.addEventListener("mouseup", stopDrag); + document.addEventListener("touchend", stopDrag); + } + + function drag(e) { + if (!isDragging) return; + e.preventDefault(); + + let currentX, currentY; + if (e.type === "touchmove") { + currentX = e.touches[0].clientX; + currentY = e.touches[0].clientY; + } else { + currentX = e.clientX; + currentY = e.clientY; + } + + let newLeft = initialX + (currentX - startX); + let newTop = initialY + (currentY - startY); + + // 限制边界 + const rect = panel.getBoundingClientRect(); + newLeft = Math.max( + 0, + Math.min(newLeft, window.innerWidth - rect.width), + ); + newTop = Math.max( + 0, + Math.min(newTop, window.innerHeight - rect.height), + ); + + panel.style.left = newLeft + "px"; + panel.style.top = newTop + "px"; + } + + function stopDrag() { + isDragging = false; + document.removeEventListener("mousemove", drag); + document.removeEventListener("touchmove", drag); + document.removeEventListener("mouseup", stopDrag); + document.removeEventListener("touchend", stopDrag); + } + + // 游戏键盘/鼠标映射(电脑端) + function setupGameInputProxy() { + const iframe = panel.querySelector(".mm-game-iframe"); + if (!iframe) return; + + // 需要键盘映射的游戏 + const keyboardGames = ["tetris", "clumsyBird"]; + + // 点击游戏面板时让 iframe 获取焦点 + panel.addEventListener("click", (e) => { + if (!keyboardGames.includes(panel.dataset.gameId)) return; + if (e.target.closest("button")) return; + try { + iframe.focus(); + } catch {} + }); + + // iframe 加载完成后自动聚焦 + iframe.addEventListener("load", () => { + if ( + keyboardGames.includes(panel.dataset.gameId) && + panel.classList.contains("mm-visible") + ) { + try { + iframe.focus(); + } catch {} + } + }); + + // 向 iframe 发送键盘事件的辅助函数 + function sendKeyToIframe(key, code, keyCode) { + try { + const iframeWindow = iframe.contentWindow; + if (!iframeWindow) return; + const keydownEvent = new KeyboardEvent("keydown", { + key, + code, + keyCode, + which: keyCode, + bubbles: true, + cancelable: true, + }); + const keyupEvent = new KeyboardEvent("keyup", { + key, + code, + keyCode, + which: keyCode, + bubbles: true, + cancelable: true, + }); + iframeWindow.document.dispatchEvent(keydownEvent); + iframeWindow.document.dispatchEvent(keyupEvent); + } catch {} + } + + // 向 iframe 发送鼠标点击事件的辅助函数 + function sendClickToIframe() { + try { + const iframeWindow = iframe.contentWindow; + if (!iframeWindow) return; + const canvas = + iframeWindow.document.querySelector("canvas"); + if (!canvas) return; + const rect = canvas.getBoundingClientRect(); + const clickX = rect.width / 2; + const clickY = rect.height / 2; + const mousedownEvent = new MouseEvent("mousedown", { + clientX: clickX, + clientY: clickY, + button: 0, + bubbles: true, + cancelable: true, + }); + const mouseupEvent = new MouseEvent("mouseup", { + clientX: clickX, + clientY: clickY, + button: 0, + bubbles: true, + cancelable: true, + }); + canvas.dispatchEvent(mousedownEvent); + canvas.dispatchEvent(mouseupEvent); + } catch {} + } + + // 处理游戏键盘事件 + function handleGameKeys(e) { + if (!panel.classList.contains("mm-visible")) return; + const gameId = panel.dataset.gameId; + + // 俄罗斯方块 + if (gameId === "tetris") { + const gameKeys = [ + "ArrowUp", + "ArrowDown", + "ArrowLeft", + "ArrowRight", + "Space", + ]; + if (gameKeys.includes(e.code)) { + e.preventDefault(); + } + // ESC 映射为暂停(P 键) + if (e.code === "Escape") { + e.preventDefault(); + sendKeyToIframe("p", "KeyP", 80); + } + } + + // 笨鸟先飞 + if (gameId === "clumsyBird") { + // 空格键 - 发送到 iframe + if (e.code === "Space") { + e.preventDefault(); + sendKeyToIframe(" ", "Space", 32); + } + } + } + + // 处理游戏鼠标事件(笨鸟先飞:点击面板区域触发飞行) + function handleGameClick(e) { + if (!panel.classList.contains("mm-visible")) return; + if (panel.dataset.gameId !== "clumsyBird") return; + if (e.target.closest("button")) return; + if (e.target.closest(".mm-game-panel-header")) return; + + // 将点击转发到 iframe 的 canvas + sendClickToIframe(); + } + + document.addEventListener("keydown", handleGameKeys); + panel.addEventListener("click", handleGameClick); + + // 存储清理函数 + panel._mmCleanupKeyboard = () => { + document.removeEventListener("keydown", handleGameKeys); + panel.removeEventListener("click", handleGameClick); + }; + } + + setupGameInputProxy(); + } + + // 打开游戏 + async function openGame(gameId) { + const config = gameConfigs[gameId]; + if (!config) return; + + createGamePanel(); + const panel = document.getElementById("mm-game-panel"); + const iframe = panel.querySelector(".mm-game-iframe"); + const titleText = panel.querySelector(".mm-game-title-text"); + + titleText.textContent = config.name; + + // 重置位置和状态 + panel.style.cssText = ""; + panel.classList.remove("mm-minimized"); + const minIcon = panel.querySelector(".mm-game-minimize i"); + if (minIcon) minIcon.className = "fa-solid fa-minus"; + + // 游戏专用样式 + panel.dataset.gameId = gameId; + panel.classList.remove( + "mm-game-clumsy", + "mm-game-city3d", + "mm-game-mario", + "mm-game-lifeRestart", + "mm-mobile-fullscreen", + "mm-need-landscape", + "mm-rotate-landscape", + ); + if (gameId === "clumsyBird") { + panel.classList.add("mm-game-clumsy"); + } else if (gameId === "city3d") { + panel.classList.add("mm-game-city3d"); + } else if (gameId === "mario") { + panel.classList.add("mm-game-mario"); + } else if (gameId === "lifeRestart") { + panel.classList.add("mm-game-lifeRestart"); + } + + // 显示 + panel.classList.add("mm-visible"); + + // 移动端:3D城市 / 马里奥强制全屏(尽量)+ 横屏提示 + const isMobileUI = + (typeof window.matchMedia === "function" && + window.matchMedia("(pointer: coarse)").matches) || + window.innerWidth <= 768; + const shouldForceLandscape = + gameId === "city3d" || gameId === "mario"; + if (isMobileUI && shouldForceLandscape) { + panel.classList.add("mm-mobile-fullscreen"); + try { + if ( + !document.fullscreenElement && + typeof panel.requestFullscreen === "function" + ) { + await panel.requestFullscreen({ navigationUI: "hide" }); + } + } catch {} + try { + if (screen?.orientation?.lock) + await screen.orientation.lock("landscape"); + } catch {} + } + + try { + if (typeof panel._mmUpdateLandscapeOverlay === "function") + panel._mmUpdateLandscapeOverlay(); + } catch {} + + // 再加载 iframe(避免 await 导致失去用户手势) + const basePath = await detectExtensionPath(); + iframe.src = `${basePath}/${config.path}`; + + // 需要键盘映射的游戏:加载后自动聚焦 iframe 以接收键盘事件 + const keyboardGames = ["tetris", "clumsyBird"]; + if (keyboardGames.includes(gameId)) { + iframe.onload = () => { + try { + iframe.focus(); + } catch {} + }; + } + } + + // 关闭游戏 + async function closeGame() { + const panel = document.getElementById("mm-game-panel"); + if (!panel) return; + panel.classList.remove("mm-visible"); + panel.classList.remove( + "mm-need-landscape", + "mm-mobile-fullscreen", + "mm-rotate-landscape", + ); + panel.dataset.gameId = ""; + const iframe = panel.querySelector(".mm-game-iframe"); + if (iframe) iframe.src = ""; + + try { + if ( + document.fullscreenElement === panel && + typeof document.exitFullscreen === "function" + ) { + await document.exitFullscreen(); + } + } catch {} + + try { + if (screen?.orientation?.unlock) screen.orientation.unlock(); + } catch {} + } + + // 游戏按钮点击事件 + document.querySelectorAll(".mm-game-chip").forEach((chip) => { + chip.addEventListener("click", () => { + const gameId = chip.dataset.game; + if (gameId) openGame(gameId); + }); + }); + + // ========== 基础设置 - 即时生效 ========== + // 插件开关(主界面顶部) + document + .getElementById("mm-plugin-toggle") + ?.addEventListener("click", () => { + const toggle = document.getElementById("mm-plugin-toggle"); + if (!toggle) return; + + const isActive = toggle.classList.toggle("mm-active"); + updateGlobalSettings({ enabled: isActive }); + toggle.title = isActive ? "关闭插件" : "启用插件"; + updateMenuButtonStatus(); + updateFloatBallStatus(); + }); + + // 显示悬浮球 + document + .getElementById("mm-show-float-ball") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ showFloatBall: e.target.checked }); + updateFloatBallVisibility(); + updateFloatBallStatus(); + }); + + // 显示处理日志 + document + .getElementById("mm-show-logs") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ showLogs: e.target.checked }); + }); + + // 发送前检查 + document + .getElementById("mm-show-request-preview") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ showRequestPreview: e.target.checked }); + // 控制流程配置按钮显示 + const flowConfigBtn = document.getElementById("mm-flow-config"); + if (flowConfigBtn) { + flowConfigBtn.style.display = e.target.checked + ? "inline-flex" + : "none"; + } + }); + + // 仅发送索引 + document + .getElementById("mm-send-index-only") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ sendIndexOnly: e.target.checked }); + // 控制索引模式卡片显示 + const indexModeCard = + document.getElementById("mm-index-mode-card"); + if (indexModeCard) { + indexModeCard.style.display = e.target.checked + ? "block" + : "none"; + } + }); + + // 索引模式折叠卡片展开/收起 + document + .getElementById("mm-index-mode-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-index-mode-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // 索引合并开关 + document + .getElementById("mm-index-merge-enabled") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ indexMergeEnabled: e.target.checked }); + // 控制 API 配置卡片显示 + const configCard = document.getElementById( + "mm-index-merge-config-card", + ); + if (configCard) { + configCard.style.display = e.target.checked + ? "flex" + : "none"; + } + }); + + // 索引合并 API 配置编辑按钮 + document + .getElementById("mm-index-merge-edit") + ?.addEventListener("click", () => { + openIndexMergeConfigModal(); + }); + + // 剧情优化 API 配置编辑按钮 + document + .getElementById("mm-plot-optimize-edit") + ?.addEventListener("click", () => { + openPlotOptimizeConfigModal(); + }); + + // 汇总检查 + document + .getElementById("mm-show-summary-check") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ showSummaryCheck: e.target.checked }); + }); + + // 启用剧情末尾 + document + .getElementById("mm-enable-recent-plot") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ enableRecentPlot: e.target.checked }); + }); + + // 上下文轮数 - 即时生效 + document + .getElementById("mm-context-rounds") + ?.addEventListener("input", (e) => { + const value = parseInt(e.target.value) ?? 5; + const valueEl = document.getElementById( + "mm-context-rounds-value", + ); + if (valueEl) valueEl.textContent = value; + updateGlobalSettings({ contextRounds: value }); + }); + + // 终止按钮 + document + .getElementById("mm-stop-btn") + ?.addEventListener("click", () => { + stopProcessing(); + }); + + // 清空更新按钮 + document + .getElementById("mm-clear-updates-btn") + ?.addEventListener("click", clearUpdatesList); + + document + .querySelector("#mm-ai-config-modal .mm-modal-close") + ?.addEventListener("click", hideConfigModal); + document + .getElementById("mm-config-cancel") + ?.addEventListener("click", hideConfigModal); + document + .getElementById("mm-config-save") + ?.addEventListener("click", saveCurrentConfig); + document + .getElementById("mm-test-connection") + ?.addEventListener("click", testConnection); + document + .getElementById("mm-fetch-models") + ?.addEventListener("click", fetchModels); + + document + .querySelectorAll('input[name="mm-api-format"]') + .forEach((radio) => { + radio.addEventListener("change", (e) => { + toggleCustomFormatOptions(e.target.value === "custom"); + }); + }); + + document + .getElementById("mm-config-temperature") + ?.addEventListener("input", (e) => { + const valueEl = document.getElementById( + "mm-config-temperature-value", + ); + if (valueEl) valueEl.textContent = e.target.value; + }); + + document + .getElementById("mm-config-relevance") + ?.addEventListener("input", (e) => { + const valueEl = document.getElementById( + "mm-config-relevance-value", + ); + if (valueEl) valueEl.textContent = e.target.value; + }); + + // ========== 配置弹窗 Tab 切换事件 ========== + document + .getElementById("mm-config-tab-api") + ?.addEventListener("click", () => switchConfigTab("api")); + document + .getElementById("mm-config-tab-context") + ?.addEventListener("click", () => switchConfigTab("context")); + + // 剧情优化上下文参考轮次滑块 + document + .getElementById("mm-plot-context-rounds") + ?.addEventListener("input", (e) => { + const valueEl = document.getElementById( + "mm-plot-context-rounds-value", + ); + if (valueEl) valueEl.textContent = e.target.value; + }); + + // 世界书选择折叠卡片 + document + .getElementById("mm-config-worldbook-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById( + "mm-config-worldbook-card", + ); + if (card) card.classList.toggle("expanded"); + }); + + // 世界书刷新按钮 + document + .getElementById("mm-config-worldbook-refresh") + ?.addEventListener("click", (e) => { + e.stopPropagation(); + const globalSettings = getGlobalSettings(); + const config = globalSettings.plotOptimizeConfig || {}; + loadConfigWorldBooks( + config.selectedBooks || [], + config.selectedEntries || {}, + ); + }); + + // 角色描述折叠卡片 + document + .getElementById("mm-config-char-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-config-char-card"); + if (card) card.classList.toggle("expanded"); + }); + + // 角色描述刷新按钮 + document + .getElementById("mm-config-char-refresh") + ?.addEventListener("click", (e) => { + e.stopPropagation(); + loadConfigCharDescription(); + }); + + document + .getElementById("mm-context-rounds") + ?.addEventListener("input", (e) => { + const valueEl = document.getElementById( + "mm-context-rounds-value", + ); + if (valueEl) valueEl.textContent = e.target.value; + }); + + // 功能开关折叠卡片事件绑定 + document + .getElementById("mm-feature-switch-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-feature-switch-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // ========== 交互式记忆搜索设置 ========== + // 交互式搜索折叠卡片展开/收起 + document + .getElementById("mm-interactive-search-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById( + "mm-interactive-search-card", + ); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // 启用交互式搜索开关 + document + .getElementById("mm-enable-interactive-search") + ?.addEventListener("change", (e) => { + const checkbox = e.target; + const isChecked = checkbox.checked; + + // 如果要启用,检查是否已导入总结世界书 + if (isChecked && !hasImportedSummaryBooks()) { + // 没有导入总结世界书,显示提醒并阻止启用 + checkbox.checked = false; + toastr.warning( + '请先导入至少一个总结世界书(书名包含"敕史局"、"Summary"或"Lore-char")才能使用记忆搜索助手功能。', + "无法启用记忆搜索助手", + { timeOut: 5000 }, + ); + return; + } + + updateGlobalSettings({ enableInteractiveSearch: isChecked }); + updateInteractiveSearchBadge(isChecked); + }); + + // 搜索模式选择 + document + .querySelectorAll('input[name="mm-search-mode"]') + .forEach((radio) => { + radio.addEventListener("change", (e) => { + updateGlobalSettings({ + interactiveSearchMode: e.target.value, + }); + }); + }); + + // ========== 剧情优化助手设置 ========== + // 剧情优化助手折叠卡片展开/收起 + document + .getElementById("mm-plot-optimize-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-plot-optimize-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // 启用剧情优化助手开关 + document + .getElementById("mm-enable-plot-optimize") + ?.addEventListener("change", (e) => { + updateGlobalSettings({ enablePlotOptimize: e.target.checked }); + updatePlotOptimizeBadge(e.target.checked); + }); + + // 标签过滤折叠卡片事件绑定 + document + .getElementById("mm-tag-filter-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-tag-filter-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // 世界书控制折叠卡片事件绑定 + document + .getElementById("mm-worldbook-control-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById( + "mm-worldbook-control-card", + ); + if (card) { + card.classList.toggle("expanded"); + // 展开时自动加载世界书列表 + if (card.classList.contains("expanded")) { + loadWorldbookControlList(); + } + } + }); + + // 世界书控制 - 刷新按钮 + document + .getElementById("mm-wb-refresh") + ?.addEventListener("click", () => { + loadWorldbookControlList(); + }); + + // 世界书控制 - 列表点击事件委托 + document + .getElementById("mm-wb-list") + ?.addEventListener("click", (e) => { + const item = e.target.closest(".mm-wb-item"); + if (item) { + const checkbox = item.querySelector( + 'input[type="checkbox"]', + ); + const bookName = item.dataset.bookName; + + // 如果点击的不是 checkbox 本身,则切换 checkbox 状态 + if (e.target.type !== "checkbox") { + checkbox.checked = !checkbox.checked; + } + + // 处理选中状态 + handleWorldbookSelect(bookName, checkbox.checked); + } + }); + + // 世界书控制 - 不可递归按钮 + document + .getElementById("mm-wb-exclude-recursion") + ?.addEventListener("click", () => { + toggleRecursionSetting("excludeRecursion"); + }); + + // 世界书控制 - 防止递归按钮 + document + .getElementById("mm-wb-prevent-recursion") + ?.addEventListener("click", () => { + toggleRecursionSetting("preventRecursion"); + }); + + // 提取模式复选框 - 即时生效 + document + .getElementById("mm-enable-extract") + ?.addEventListener("change", (e) => { + const config = getTagFilterConfigFromUI(); + updateTagFilterBadge( + config.enableExtract, + config.enableExclude, + ); + updateGlobalSettings({ contextTagFilter: config }); + }); + + // 排除模式复选框 - 即时生效 + document + .getElementById("mm-enable-exclude") + ?.addEventListener("change", (e) => { + const config = getTagFilterConfigFromUI(); + updateTagFilterBadge( + config.enableExtract, + config.enableExclude, + ); + updateGlobalSettings({ contextTagFilter: config }); + }); + + // 区分大小写复选框 - 即时生效 + document + .getElementById("mm-tag-case-sensitive") + ?.addEventListener("change", (e) => { + const config = getTagFilterConfigFromUI(); + updateGlobalSettings({ contextTagFilter: config }); + }); + + // 提取标签输入框回车添加 + document + .getElementById("mm-extract-tag-input") + ?.addEventListener("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + const input = e.target; + addExtractTag(input.value); + input.value = ""; + } + }); + + // 提取标签保存按钮点击 + document + .getElementById("mm-extract-tag-save") + ?.addEventListener("click", () => { + const input = document.getElementById("mm-extract-tag-input"); + if (input) { + addExtractTag(input.value); + input.value = ""; + } + }); + + // 排除标签输入框回车添加 + document + .getElementById("mm-exclude-tag-input") + ?.addEventListener("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + const input = e.target; + addExcludeTag(input.value); + input.value = ""; + } + }); + + // 排除标签保存按钮点击 + document + .getElementById("mm-exclude-tag-save") + ?.addEventListener("click", () => { + const input = document.getElementById("mm-exclude-tag-input"); + if (input) { + addExcludeTag(input.value); + input.value = ""; + } + }); + + // 提取标签删除按钮(事件委托) + document + .getElementById("mm-extract-tag-list") + ?.addEventListener("click", (e) => { + const removeBtn = e.target.closest( + '[data-action="remove-extract-tag"]', + ); + if (removeBtn) { + const tagName = removeBtn.dataset.tag; + removeExtractTag(tagName); + } + }); + + // 排除标签删除按钮(事件委托) + document + .getElementById("mm-exclude-tag-list") + ?.addEventListener("click", (e) => { + const removeBtn = e.target.closest( + '[data-action="remove-exclude-tag"]', + ); + if (removeBtn) { + const tagName = removeBtn.dataset.tag; + removeExcludeTag(tagName); + } + }); + + document + .getElementById("mm-export-config") + ?.addEventListener("click", () => { + const json = exportConfig(); + const blob = new Blob([json], { type: "application/json" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = "memory-manager-config.json"; + a.click(); + }); + + document + .getElementById("mm-import-config") + ?.addEventListener("click", () => { + const input = document.createElement("input"); + input.type = "file"; + input.accept = ".json"; + input.onchange = async (e) => { + const file = e.target.files[0]; + if (file) { + const text = await file.text(); + if (importConfig(text)) { + alert("配置导入成功"); + refreshAIConfigList(); + loadGlobalSettingsUI(); + } else { + alert("配置导入失败"); + } + } + }; + input.click(); + }); + + document + .getElementById("mm-reset-config") + ?.addEventListener("click", () => { + if (confirm("确定要重置所有配置吗?此操作不可撤销。")) { + resetConfig(); + refreshAIConfigList(); + loadGlobalSettingsUI(); + alert("配置已重置"); + } + }); + + // AI 配置区块折叠/展开 + document + .getElementById("mm-ai-config-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-ai-config-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + // 配置管理区块折叠/展开 + document + .getElementById("mm-config-manage-toggle") + ?.addEventListener("click", () => { + const card = document.getElementById("mm-config-manage-card"); + if (card) { + card.classList.toggle("expanded"); + } + }); + + document + .getElementById("mm-add-config") + ?.addEventListener("click", () => { + const category = prompt("请输入分类名称"); + if (category) { + showConfigModal(category); + } + }); + + document.addEventListener("click", (e) => { + const editBtn = e.target.closest('[data-action="edit-config"]'); + if (editBtn) { + const category = editBtn.dataset.category; + const type = editBtn.dataset.type || "memory"; + showConfigModal(category, type); + return; + } + + const deleteBtn = e.target.closest('[data-action="delete-config"]'); + if (deleteBtn) { + const category = deleteBtn.dataset.category; + const type = deleteBtn.dataset.type || "memory"; + deleteConfig(category, type); + return; + } + + const removeBookBtn = e.target.closest( + '[data-action="remove-book"]', + ); + if (removeBookBtn) { + const bookName = removeBookBtn.dataset.book; + if (confirm(`确定要移除世界书 "${bookName}" 吗?`)) { + removeImportedBook(bookName); + refreshWorldBookList(); + Logger.log(`已移除世界书 "${bookName}"`); + } + return; + } + }); + + // 流程配置按钮事件绑定 + document + .getElementById("mm-flow-config") + ?.addEventListener("click", showFlowConfigModal); + document + .querySelector("#mm-flow-config-modal .mm-modal-close") + ?.addEventListener("click", hideFlowConfigModal); + document + .getElementById("mm-flow-config-reset") + ?.addEventListener("click", resetFlowConfig); + document + .getElementById("mm-flow-config-import") + ?.addEventListener("click", importFlowConfig); + document + .getElementById("mm-flow-config-export") + ?.addEventListener("click", exportFlowConfig); + document + .getElementById("mm-flow-config-save") + ?.addEventListener("click", saveFlowConfig); + + // 流程配置弹窗拖拽缩放 + initFlowConfigResize(); + + // 提示词编辑器事件绑定 + document + .getElementById("mm-edit-prompt") + ?.addEventListener("click", showPromptEditor); + document + .querySelector("#mm-prompt-editor-modal .mm-modal-close") + ?.addEventListener("click", hidePromptEditor); + document + .getElementById("mm-prompt-cancel") + ?.addEventListener("click", hidePromptEditor); + document + .getElementById("mm-prompt-save") + ?.addEventListener("click", savePromptFile); + document + .getElementById("mm-prompt-save-as") + ?.addEventListener("click", saveAsPromptFile); + document + .getElementById("mm-prompt-delete") + ?.addEventListener("click", deletePromptFile); + document + .getElementById("mm-prompt-restore-default") + ?.addEventListener("click", restoreDefaultPrompt); + document + .getElementById("mm-prompt-import") + ?.addEventListener("click", importPromptFile); + document + .getElementById("mm-prompt-export") + ?.addEventListener("click", exportPromptFile); + + // 提示词类型切换事件绑定 + document + .getElementById("mm-prompt-type-keywords") + ?.addEventListener("click", () => switchPromptType("keywords")); + document + .getElementById("mm-prompt-type-historical") + ?.addEventListener("click", () => switchPromptType("historical")); + document + .getElementById("mm-prompt-type-plot-optimize") + ?.addEventListener("click", () => + switchPromptType("plot-optimize"), + ); + } + + /** + * 切换提示词类型 + * @param {string} type - "keywords", "historical" 或 "plot-optimize" + */ + function switchPromptType(type) { + // 更新标签样式 + const keywordsBtn = document.getElementById("mm-prompt-type-keywords"); + const historicalBtn = document.getElementById( + "mm-prompt-type-historical", + ); + const plotOptimizeBtn = document.getElementById( + "mm-prompt-type-plot-optimize", + ); + + if (keywordsBtn && historicalBtn && plotOptimizeBtn) { + keywordsBtn.classList.toggle("mm-tab-active", type === "keywords"); + historicalBtn.classList.toggle( + "mm-tab-active", + type === "historical", + ); + plotOptimizeBtn.classList.toggle( + "mm-tab-active", + type === "plot-optimize", + ); + } + + // 显示/隐藏剧情优化模式说明 + updatePlotOptimizeModeHint(type); + + // 清除当前数据,重新加载对应类型的文件列表 + currentPromptData = null; + currentPromptFile = null; + loadPromptFiles(type); + } + + /** + * 更新剧情优化模式说明的显示状态 + */ + function updatePlotOptimizeModeHint(type = currentPromptType) { + const hintBox = document.getElementById("mm-plot-optimize-mode-hint"); + if (hintBox) { + hintBox.style.display = type === "plot-optimize" ? "block" : "none"; + } + } + + // ============================================================================ + // 使用编辑后的prompt调用API的辅助函数 + // ============================================================================ + async function callAPIWithEditedPrompt(reqInfo, abortSignal, taskId) { + const { + category, + source, + model, + prompt, + aiConfig: savedAiConfig, + taskType, + detailKeys, + bookName, + } = reqInfo; + + // 开始任务进度追踪 + const actualTaskId = taskId || `edited_${category || source}`; + if (progressTracker) { + progressTracker.startTask(actualTaskId); + } + + Logger.log(`[编辑后请求] 开始处理: ${category || source}`, { + model, + promptLength: prompt.length, + taskType, + hasAiConfig: !!savedAiConfig, + }); + + try { + // 优先使用保存在reqInfo中的API配置 + let apiConfig = null; + + if (savedAiConfig && savedAiConfig.apiUrl && savedAiConfig.apiKey) { + apiConfig = savedAiConfig; + Logger.debug( + `[编辑后请求] 使用保存的API配置: ${category || source}`, + ); + } else { + // 回退:根据category或source尝试获取配置 + if (category) { + try { + apiConfig = getMemoryConfig(category); + } catch (e) { + // 如果没有对应的memory配置,尝试其他方式 + try { + apiConfig = getSummaryConfig(category); + } catch (e2) { + // 继续尝试其他方式 + } + } + } + + // 如果仍然没有找到配置,报错 + if (!apiConfig || !apiConfig.apiUrl) { + throw new Error( + `无法获取 "${category || source}" 的API配置`, + ); + } + } + + // 调用API + const response = await APIAdapter.callWithRetry( + apiConfig, + prompt, // 使用编辑后的完整prompt + "", // 没有单独的用户消息 + actualTaskId, + 3, + abortSignal, + ); + + Logger.log(`[编辑后请求] 完成: ${category || source}`); + + // 完成任务进度追踪 + if (progressTracker) { + progressTracker.completeTask(actualTaskId, true); + } + + // 根据任务类型返回不同格式的结果 + const result = { + source: source || category, + category: category, + type: taskType || "edited", + rawMemory: response, + detailKeys: detailKeys || [], + }; + + if (taskType === "summary") { + result.bookName = bookName || category; + } + + return result; + } catch (error) { + // 失败时更新进度追踪 + if (progressTracker) { + progressTracker.completeTask( + actualTaskId, + false, + error.message, + ); + } + + if (error.name === "AbortError") { + Logger.warn(`[编辑后请求] 已取消: ${category || source}`); + throw error; + } + + Logger.error(`[编辑后请求] 失败: ${category || source}`, error); + throw error; + } + } + + // ============================================================================ + // 请求预览弹窗函数 + function showRequestPreview(requests) { + return new Promise((resolve, reject) => { + // 创建弹窗容器 - 无遮罩模式,允许与主界面交互 + const modal = document.createElement("div"); + modal.className = "mm-modal mm-modal-visible"; + modal.style.zIndex = "999999"; + modal.style.position = "fixed"; + modal.style.top = "0"; + modal.style.left = "0"; + modal.style.right = "0"; + modal.style.bottom = "0"; + modal.style.background = "transparent"; + modal.style.display = "flex"; + modal.style.alignItems = "center"; + modal.style.justifyContent = "center"; + modal.style.pointerEvents = "none"; // 允许点击穿透到下层 + + // 应用当前主题 + const settings = getGlobalSettings(); + const theme = settings.theme || "default"; + if (theme !== "default") { + modal.setAttribute("data-mm-theme", theme); + } + + // 创建弹窗内容 - 响应式设计 + const content = document.createElement("div"); + content.className = "mm-modal-content mm-modal-large"; + content.style.width = "100%"; + content.style.maxWidth = "1000px"; + content.style.height = "90vh"; + content.style.maxHeight = "90vh"; + content.style.overflow = "hidden"; + content.style.display = "flex"; + content.style.flexDirection = "column"; + content.style.background = "var(--mm-bg)"; + content.style.borderRadius = "var(--mm-radius)"; + content.style.boxShadow = "0 4px 20px rgba(0, 0, 0, 0.3)"; + content.style.pointerEvents = "auto"; // 弹窗内容可交互 + + // 创建弹窗头部 + const header = document.createElement("div"); + header.className = "mm-modal-header"; + header.style.display = "flex"; + header.style.justifyContent = "space-between"; + header.style.alignItems = "center"; + header.style.padding = "15px 20px"; + header.style.borderBottom = "1px solid var(--mm-border)"; + header.style.flexShrink = "0"; + + const headerLeft = document.createElement("div"); + headerLeft.style.display = "flex"; + headerLeft.style.flexDirection = "column"; + headerLeft.style.gap = "10px"; + + const title = document.createElement("h4"); + title.textContent = "发送前检查 - 即将发送给API的内容"; + title.style.margin = "0"; + title.style.fontSize = "16px"; + + // 添加搜索框 + const searchContainer = document.createElement("div"); + searchContainer.style.display = "flex"; + searchContainer.style.flexDirection = "column"; + searchContainer.style.gap = "6px"; + searchContainer.style.width = "100%"; + + const searchRow = document.createElement("div"); + searchRow.style.display = "flex"; + searchRow.style.alignItems = "center"; + searchRow.style.gap = "6px"; + searchRow.style.flexWrap = "wrap"; + + const searchInputWrapper = document.createElement("div"); + searchInputWrapper.style.position = "relative"; + searchInputWrapper.style.flex = "1"; + searchInputWrapper.style.minWidth = "100px"; + + const searchInput = document.createElement("input"); + searchInput.type = "text"; + searchInput.id = "mm-preview-search"; + searchInput.placeholder = "搜索..."; + searchInput.style.width = "100%"; + searchInput.style.padding = "4px 22px 4px 6px"; + searchInput.style.border = "1px solid var(--mm-border)"; + searchInput.style.borderRadius = "var(--mm-radius)"; + searchInput.style.fontSize = "11px"; + searchInput.style.background = "var(--mm-bg)"; + searchInput.style.color = "var(--mm-text)"; + + const searchIcon = document.createElement("i"); + searchIcon.className = "fa-solid fa-search"; + searchIcon.style.position = "absolute"; + searchIcon.style.right = "5px"; + searchIcon.style.top = "50%"; + searchIcon.style.transform = "translateY(-50%)"; + searchIcon.style.color = "var(--mm-text-secondary)"; + searchIcon.style.fontSize = "10px"; + searchIcon.style.cursor = "pointer"; + searchIcon.addEventListener("click", handleSearch); + + searchInputWrapper.appendChild(searchInput); + searchInputWrapper.appendChild(searchIcon); + searchRow.appendChild(searchInputWrapper); + + const replaceInput = document.createElement("input"); + replaceInput.type = "text"; + replaceInput.id = "mm-preview-replace"; + replaceInput.placeholder = "替换为..."; + replaceInput.style.width = "100px"; + replaceInput.style.padding = "4px 6px"; + replaceInput.style.border = "1px solid var(--mm-border)"; + replaceInput.style.borderRadius = "var(--mm-radius)"; + replaceInput.style.fontSize = "11px"; + replaceInput.style.background = "var(--mm-bg)"; + replaceInput.style.color = "var(--mm-text)"; + searchRow.appendChild(replaceInput); + + const replaceBtn = document.createElement("button"); + replaceBtn.textContent = "替换"; + replaceBtn.id = "mm-preview-replace-btn"; + replaceBtn.style.padding = "4px 8px"; + replaceBtn.style.border = "1px solid var(--mm-border)"; + replaceBtn.style.borderRadius = "var(--mm-radius)"; + replaceBtn.style.fontSize = "11px"; + replaceBtn.style.background = "var(--mm-bg)"; + replaceBtn.style.color = "var(--mm-text)"; + replaceBtn.style.cursor = "pointer"; + replaceBtn.style.whiteSpace = "nowrap"; + searchRow.appendChild(replaceBtn); + + const replaceAllBtn = document.createElement("button"); + replaceAllBtn.textContent = "全部替换"; + replaceAllBtn.id = "mm-preview-replace-all-btn"; + replaceAllBtn.style.padding = "4px 8px"; + replaceAllBtn.style.border = "1px solid var(--mm-border)"; + replaceAllBtn.style.borderRadius = "var(--mm-radius)"; + replaceAllBtn.style.fontSize = "11px"; + replaceAllBtn.style.background = "var(--mm-bg)"; + replaceAllBtn.style.color = "var(--mm-text)"; + replaceAllBtn.style.cursor = "pointer"; + replaceAllBtn.style.whiteSpace = "nowrap"; + searchRow.appendChild(replaceAllBtn); + + const prevBtn = document.createElement("button"); + prevBtn.innerHTML = ''; + prevBtn.id = "mm-preview-search-prev"; + prevBtn.style.padding = "4px 7px"; + prevBtn.style.border = "1px solid var(--mm-border)"; + prevBtn.style.borderRadius = "var(--mm-radius)"; + prevBtn.style.fontSize = "10px"; + prevBtn.style.background = "var(--mm-bg)"; + prevBtn.style.color = "var(--mm-text)"; + prevBtn.style.cursor = "pointer"; + searchRow.appendChild(prevBtn); + + const nextBtn = document.createElement("button"); + nextBtn.innerHTML = ''; + nextBtn.id = "mm-preview-search-next"; + nextBtn.style.padding = "4px 7px"; + nextBtn.style.border = "1px solid var(--mm-border)"; + nextBtn.style.borderRadius = "var(--mm-radius)"; + nextBtn.style.fontSize = "10px"; + nextBtn.style.background = "var(--mm-bg)"; + nextBtn.style.color = "var(--mm-text)"; + nextBtn.style.cursor = "pointer"; + searchRow.appendChild(nextBtn); + + searchContainer.appendChild(searchRow); + + const searchStats = document.createElement("div"); + searchStats.id = "mm-preview-search-stats"; + searchStats.textContent = "找到 0 个匹配项"; + searchStats.style.fontSize = "11px"; + searchStats.style.color = "var(--mm-text-secondary)"; + searchContainer.appendChild(searchStats); + + headerLeft.appendChild(title); + headerLeft.appendChild(searchContainer); + + const closeBtn = document.createElement("button"); + closeBtn.className = "mm-modal-close mm-btn mm-btn-icon"; + closeBtn.innerHTML = ``; + closeBtn.id = "mm-preview-close"; + + header.appendChild(headerLeft); + header.appendChild(closeBtn); + content.appendChild(header); + + // 创建弹窗主体 - 可滚动区域 + const body = document.createElement("div"); + body.className = "mm-modal-body"; + body.style.flex = "1"; + body.style.overflowY = "auto"; + body.style.padding = "20px"; + + // 为每个请求创建容器 + requests.forEach(async (req, index) => { + // 计算总字符数 + const totalChars = (req.prompt || "").length; + const charCountDisplay = + totalChars >= 1000 + ? `${(totalChars / 1000).toFixed(1)}k` + : totalChars; + + // 创建请求块容器 + const requestBlock = document.createElement("div"); + requestBlock.className = "mm-request-block"; + requestBlock.style.marginBottom = "20px"; + requestBlock.style.padding = "15px"; + requestBlock.style.background = "var(--mm-bg-card)"; + requestBlock.style.borderRadius = "var(--mm-radius)"; + requestBlock.style.border = "1px solid var(--mm-border)"; + + // 创建请求块标题 + const requestHeader = document.createElement("div"); + requestHeader.style.display = "flex"; + requestHeader.style.justifyContent = "space-between"; + requestHeader.style.alignItems = "center"; + requestHeader.style.marginBottom = "10px"; + requestHeader.style.cursor = "pointer"; + requestHeader.style.userSelect = "none"; + + const requestTitle = document.createElement("div"); + requestTitle.style.display = "flex"; + requestTitle.style.alignItems = "center"; + requestTitle.style.gap = "8px"; + + const titleText = document.createElement("h5"); + titleText.style.margin = "0"; + titleText.style.color = "var(--mm-primary)"; + titleText.style.fontWeight = "bold"; + titleText.style.fontSize = "15px"; + + titleText.innerHTML = ` + 请求 ${index + 1}: ${req.category || "未分类"} + + ${charCountDisplay} 字符 + + `; + requestTitle.appendChild(titleText); + + requestHeader.appendChild(requestTitle); + + // 折叠按钮 + const requestToggleBtn = document.createElement("button"); + requestToggleBtn.className = "mm-request-toggle-btn"; + requestToggleBtn.innerHTML = + ''; + requestToggleBtn.style.background = "none"; + requestToggleBtn.style.border = "none"; + requestToggleBtn.style.color = "var(--mm-primary)"; + requestToggleBtn.style.cursor = "pointer"; + requestToggleBtn.style.fontSize = "13px"; + requestToggleBtn.style.padding = "5px"; + requestHeader.appendChild(requestToggleBtn); + + requestBlock.appendChild(requestHeader); + + // 创建请求内容容器 + const requestContent = document.createElement("div"); + requestContent.className = "mm-request-content"; + requestContent.style.display = "none"; // 默认折叠 + + // 添加模型信息 + const modelInfo = document.createElement("div"); + modelInfo.style.marginBottom = "12px"; + modelInfo.style.fontSize = "12px"; + modelInfo.style.color = "var(--mm-text-secondary)"; + modelInfo.innerHTML = `模型: ${ + req.model || "未指定" + }`; + requestContent.appendChild(modelInfo); + + // 拖拽相关变量(移到外部,所有部分块共享) + let draggedPartElement = null; + + // 为每个prompt部分创建可折叠、可拖拽的块 + if (req.promptParts && req.promptParts.length > 0) { + // 应用排序顺序:优先使用用户保存的顺序,否则使用默认顺序 + const settings = getGlobalSettings(); + const savedOrder = settings.promptPartsOrder || {}; + const category = req.category || req.source; + + let orderedParts = [...req.promptParts]; + + // 根据请求类型确定流程配置类型 + let flowConfigType = category; + // 检查是否是剧情优化(通过检查是否有 plot_ 前缀的 source) + const hasPlotSource = orderedParts.some( + (p) => p.source && p.source.startsWith("plot_"), + ); + if ( + hasPlotSource || + category === "剧情优化" || + category === "剧情优化助手" + ) { + // 剧情优化统一模式 + flowConfigType = "剧情优化"; + } else if (category === "索引合并") { + flowConfigType = "索引合并"; + } else { + // 检查是否是总结世界书(通过条件块类型判断,总结世界书和记忆世界书使用相同配置) + flowConfigType = "记忆世界书"; + } + + // 获取排序配置:优先用户保存的,否则使用默认配置 + const defaultConfig = await loadDefaultFlowConfig(); + const sourceOrder = + savedOrder[flowConfigType] || + defaultConfig[flowConfigType]; + + if (sourceOrder && Array.isArray(sourceOrder)) { + // 根据source顺序重新排列 + const reorderedParts = []; + const usedIndices = new Set(); + + // 第一遍:按照配置的顺序添加匹配的部分 + for (const source of sourceOrder) { + const partIndex = orderedParts.findIndex( + (p, idx) => + !usedIndices.has(idx) && + p.source === source, + ); + if (partIndex !== -1) { + reorderedParts.push(orderedParts[partIndex]); + usedIndices.add(partIndex); + } + } + + // 第二遍:添加未匹配的部分(保持原顺序) + orderedParts.forEach((part, idx) => { + if (!usedIndices.has(idx)) { + reorderedParts.push(part); + } + }); + + // 如果重新排序成功,使用新顺序 + if (reorderedParts.length > 0) { + orderedParts = reorderedParts; + } + } + + orderedParts.forEach((part, partIndex) => { + const partBlock = document.createElement("div"); + partBlock.className = "mm-prompt-part-block"; + partBlock.draggable = false; // 默认不可拖拽,只通过手柄启动拖拽 + partBlock.dataset.partIndex = partIndex; + // 添加 source 属性用于 CSS 隐藏破限词 + if (part.source) { + partBlock.dataset.source = part.source; + } + + // 创建部分标题 + const partHeader = document.createElement("div"); + partHeader.style.display = "flex"; + partHeader.style.justifyContent = "space-between"; + partHeader.style.alignItems = "center"; + partHeader.style.marginBottom = "8px"; + partHeader.style.cursor = "pointer"; + partHeader.style.userSelect = "none"; + + const partTitleArea = document.createElement("div"); + partTitleArea.style.display = "flex"; + partTitleArea.style.alignItems = "center"; + partTitleArea.style.gap = "8px"; + partTitleArea.style.flex = "1"; + + // 拖拽手柄 + const dragHandle = document.createElement("i"); + dragHandle.className = "fa-solid fa-grip-vertical"; + dragHandle.style.color = "var(--mm-text-secondary)"; + dragHandle.style.cursor = "grab"; + dragHandle.style.fontSize = "12px"; + dragHandle.style.padding = "4px"; // 增加点击区域 + partTitleArea.appendChild(dragHandle); + + // 部分标签和字符数 + const partLabel = document.createElement("div"); + partLabel.style.fontSize = "13px"; + partLabel.style.fontWeight = "bold"; + partLabel.style.color = "var(--mm-text)"; + + const partChars = (part.content || "").length; + const partCharDisplay = + partChars >= 1000 + ? `${(partChars / 1000).toFixed(1)}k` + : partChars; + + partLabel.innerHTML = ` + ${part.label} + + ${partCharDisplay} 字符 + + `; + partTitleArea.appendChild(partLabel); + + partHeader.appendChild(partTitleArea); + + // 删除按钮 + const deleteBtn = document.createElement("button"); + deleteBtn.className = "mm-part-delete-btn"; + deleteBtn.innerHTML = + ''; + deleteBtn.style.background = "none"; + deleteBtn.style.border = "none"; + deleteBtn.style.color = "var(--mm-text-muted)"; + deleteBtn.style.cursor = "pointer"; + deleteBtn.style.fontSize = "11px"; + deleteBtn.style.padding = "3px 6px"; + deleteBtn.style.marginRight = "4px"; + deleteBtn.title = "删除此来源"; + deleteBtn.addEventListener("click", (e) => { + e.stopPropagation(); + if (confirm(`确定要删除"${part.label}"吗?`)) { + partBlock.remove(); + } + }); + partHeader.appendChild(deleteBtn); + + // 部分折叠按钮 + const partToggleBtn = document.createElement("button"); + partToggleBtn.className = "mm-part-toggle-btn"; + partToggleBtn.innerHTML = + ''; // 默认折叠,使用向下箭头 + partToggleBtn.style.background = "none"; + partToggleBtn.style.border = "none"; + partToggleBtn.style.color = "var(--mm-text-secondary)"; + partToggleBtn.style.cursor = "pointer"; + partToggleBtn.style.fontSize = "11px"; + partToggleBtn.style.padding = "3px"; + partHeader.appendChild(partToggleBtn); + + partBlock.appendChild(partHeader); + + // 创建可编辑内容区域 + const partContentArea = document.createElement("div"); + partContentArea.className = "mm-part-content-area"; + partContentArea.style.display = "none"; // 默认折叠 + + // 创建可调整大小的编辑器容器 + const editorContainer = document.createElement("div"); + editorContainer.className = + "mm-resizable-editor-container"; + editorContainer.style.display = "flex"; + editorContainer.style.flexDirection = "column"; + + const promptContent = document.createElement("div"); + promptContent.className = "mm-prompt-content"; + promptContent.style.background = + "var(--mm-bg-secondary)"; + promptContent.style.padding = "8px"; + promptContent.style.overflow = "auto"; + promptContent.style.fontSize = "11px"; + promptContent.style.whiteSpace = "pre-wrap"; + promptContent.style.wordWrap = "break-word"; + promptContent.style.border = + "1px solid var(--mm-border)"; + promptContent.style.borderRadius = "4px 4px 0 0"; + promptContent.style.cursor = "text"; + promptContent.style.outline = "none"; + promptContent.style.boxSizing = "border-box"; + promptContent.contentEditable = "true"; + promptContent.textContent = part.content || ""; + editorContainer.appendChild(promptContent); + + // 展开后根据实际内容设置合适高度 + const setContentHeight = () => { + const scrollH = promptContent.scrollHeight; + const h = Math.max(60, Math.min(scrollH + 16, 300)); + promptContent.style.height = `${h}px`; + }; + + const resizeHandle = document.createElement("div"); + resizeHandle.className = "mm-resize-handle"; + editorContainer.appendChild(resizeHandle); + + // 初始化拖动调整高度功能 + let isResizing = false; + let startY, startHeight; + + resizeHandle.addEventListener("mousedown", (e) => { + isResizing = true; + startY = e.clientY; + startHeight = parseInt( + window.getComputedStyle(promptContent).height, + 10, + ); + document.body.style.cursor = "ns-resize"; + document.body.style.userSelect = "none"; + e.preventDefault(); + e.stopPropagation(); + }); + + document.addEventListener("mousemove", (e) => { + if (!isResizing) return; + const deltaY = e.clientY - startY; + const newHeight = Math.max( + 80, + startHeight + deltaY, + ); // 最小高度80px + promptContent.style.height = `${newHeight}px`; + e.preventDefault(); + }); + + document.addEventListener("mouseup", () => { + if (isResizing) { + isResizing = false; + document.body.style.cursor = ""; + document.body.style.userSelect = ""; + } + }); + + partContentArea.appendChild(editorContainer); + partBlock.appendChild(partContentArea); + + // 部分块折叠逻辑 + partToggleBtn.addEventListener("click", (e) => { + e.stopPropagation(); + const isCollapsed = + partContentArea.style.display === "none"; + partContentArea.style.display = isCollapsed + ? "block" + : "none"; + partToggleBtn.innerHTML = isCollapsed + ? '' + : ''; + if (isCollapsed) setTimeout(setContentHeight, 0); + }); + + partHeader.addEventListener("click", () => { + const isCollapsed = + partContentArea.style.display === "none"; + partContentArea.style.display = isCollapsed + ? "block" + : "none"; + partToggleBtn.innerHTML = isCollapsed + ? '' + : ''; + if (isCollapsed) setTimeout(setContentHeight, 0); + }); + + // 拖拽功能 - 只通过手柄启动拖拽 + + // 手柄按下时启用拖拽 + dragHandle.addEventListener("mousedown", () => { + partBlock.draggable = true; + }); + + // 拖拽结束后禁用拖拽 + partBlock.addEventListener("dragend", () => { + partBlock.draggable = false; + partBlock.style.opacity = "1"; + partBlock.style.border = "2px solid transparent"; + dragHandle.style.cursor = "grab"; + draggedPartElement = null; + }); + + partBlock.addEventListener("dragstart", (e) => { + draggedPartElement = partBlock; + partBlock.style.opacity = "0.5"; + dragHandle.style.cursor = "grabbing"; + e.dataTransfer.effectAllowed = "move"; + e.dataTransfer.setData("text/plain", partIndex); // 设置数据以支持拖拽 + }); + + partBlock.addEventListener("dragover", (e) => { + e.preventDefault(); + e.dataTransfer.dropEffect = "move"; + + if ( + draggedPartElement && + draggedPartElement !== partBlock && + draggedPartElement.parentElement === + partBlock.parentElement + ) { + const bounding = + partBlock.getBoundingClientRect(); + const offset = e.clientY - bounding.top; + + if (offset > bounding.height / 2) { + partBlock.style.borderBottom = + "2px solid var(--mm-primary)"; + partBlock.style.borderTop = + "2px solid transparent"; + } else { + partBlock.style.borderTop = + "2px solid var(--mm-primary)"; + partBlock.style.borderBottom = + "2px solid transparent"; + } + } + }); + + partBlock.addEventListener("dragleave", () => { + partBlock.style.border = "2px solid transparent"; + }); + + partBlock.addEventListener("drop", (e) => { + e.preventDefault(); + partBlock.style.border = "2px solid transparent"; + + if ( + draggedPartElement && + draggedPartElement !== partBlock && + draggedPartElement.parentElement === + partBlock.parentElement + ) { + const bounding = + partBlock.getBoundingClientRect(); + const offset = e.clientY - bounding.top; + + if (offset > bounding.height / 2) { + partBlock.parentElement.insertBefore( + draggedPartElement, + partBlock.nextSibling, + ); + } else { + partBlock.parentElement.insertBefore( + draggedPartElement, + partBlock, + ); + } + + // 更新 partIndex + const allParts = + requestContent.querySelectorAll( + ".mm-prompt-part-block", + ); + allParts.forEach((p, i) => { + p.dataset.partIndex = i; + }); + } + }); + + requestContent.appendChild(partBlock); + }); + } else { + // 如果没有 promptParts,显示完整的 prompt + const fallbackContent = document.createElement("div"); + fallbackContent.style.padding = "10px"; + fallbackContent.style.background = "var(--mm-bg)"; + fallbackContent.style.borderRadius = "var(--mm-radius)"; + fallbackContent.style.fontSize = "12px"; + fallbackContent.style.whiteSpace = "pre-wrap"; + fallbackContent.textContent = req.prompt || "(无内容)"; + requestContent.appendChild(fallbackContent); + } + + requestBlock.appendChild(requestContent); + + // 请求块折叠逻辑 + const toggleRequestBlock = () => { + const isCollapsed = requestContent.style.display === "none"; + requestContent.style.display = isCollapsed + ? "block" + : "none"; + requestToggleBtn.innerHTML = isCollapsed + ? '' + : ''; + }; + + requestHeader.addEventListener("click", toggleRequestBlock); + requestToggleBtn.addEventListener("click", (e) => { + e.stopPropagation(); + toggleRequestBlock(); + }); + + body.appendChild(requestBlock); + }); + + content.appendChild(body); + + // 创建弹窗底部按钮 + const footer = document.createElement("div"); + footer.className = "mm-modal-footer"; + footer.style.justifyContent = "space-between"; + footer.innerHTML = ` + +
              + + +
              + `; + content.appendChild(footer); + + modal.appendChild(content); + document.body.appendChild(modal); + + // 搜索功能 - 暂时移除,直接在handleSearch中实现高亮逻辑 + // function highlightText(element, text) { + // if (!text) { + // // 清除高亮 + // element.innerHTML = element.textContent; + // return false; + // } + // + // // 处理contentEditable的div元素 + // const content = element.textContent; + // const hasMatch = content.toLowerCase().includes(text.toLowerCase()); + // + // if (hasMatch) { + // // 高亮显示匹配文本 + // const regex = new RegExp(`(${text})`, 'gi'); + // const highlighted = content.replace(regex, '$1'); + // element.innerHTML = highlighted; + // } else { + // // 没有匹配项,清除高亮 + // element.innerHTML = content; + // } + // + // return hasMatch; + // } + + // 搜索处理函数 + function handleSearch() { + const searchTerm = searchInput.value.trim(); + const requestBlocks = + modal.querySelectorAll(".mm-request-block"); + let firstMatch = null; + let totalMatches = 0; + + requestBlocks.forEach((requestBlock) => { + const requestContent = requestBlock.querySelector( + ".mm-request-content", + ); + const requestToggleBtn = requestBlock.querySelector( + ".mm-request-toggle-btn", + ); + const partBlocks = requestBlock.querySelectorAll( + ".mm-prompt-part-block", + ); + let requestHasMatch = false; + + partBlocks.forEach((partBlock) => { + const partContentArea = partBlock.querySelector( + ".mm-part-content-area", + ); + const partToggleBtn = partBlock.querySelector( + ".mm-part-toggle-btn", + ); + const promptContent = + partBlock.querySelector(".mm-prompt-content"); + + if (!promptContent) return; + + // 获取原始内容 + const originalContent = promptContent.textContent; + let hasMatch = false; + let matchCount = 0; + + // 清除之前的高亮 + promptContent.innerHTML = originalContent; + + // 只有当搜索词不为空时才执行搜索 + if (searchTerm) { + const searchLower = searchTerm.toLowerCase(); + const contentLower = originalContent.toLowerCase(); + + // 检查是否有匹配项 + hasMatch = contentLower.includes(searchLower); + + if (hasMatch) { + const regex = new RegExp( + `(${searchTerm})`, + "gi", + ); + promptContent.innerHTML = + originalContent.replace( + regex, + '$1', + ); + + // 计算匹配数量 + matchCount = ( + originalContent.match( + new RegExp(searchTerm, "gi"), + ) || [] + ).length; + totalMatches += matchCount; + requestHasMatch = true; + } + } + + // 只有当搜索词不为空且有匹配项时,才展开部分块 + if (searchTerm && hasMatch) { + if (partContentArea) + partContentArea.style.display = "block"; + if (partToggleBtn) + partToggleBtn.innerHTML = + ''; + + // 记录第一个匹配项,以便后续定位 + if (!firstMatch) { + firstMatch = partBlock; + } + } else if (searchTerm) { + // 有搜索词但无匹配,折叠 + if (partContentArea) + partContentArea.style.display = "none"; + if (partToggleBtn) + partToggleBtn.innerHTML = + ''; + } + // 如果没有搜索词,保持当前状态不变 + }); + + // 如果请求块中有匹配项,展开请求块 + if (searchTerm && requestHasMatch) { + if (requestContent) + requestContent.style.display = "block"; + if (requestToggleBtn) + requestToggleBtn.innerHTML = + ''; + } else if (searchTerm) { + // 有搜索词但请求块无匹配,折叠 + if (requestContent) + requestContent.style.display = "none"; + if (requestToggleBtn) + requestToggleBtn.innerHTML = + ''; + } + // 如果没有搜索词,保持当前状态不变 + }); + + // 定位到第一个匹配项 + if (firstMatch) { + firstMatch.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + + // 定位到第一个匹配的文本位置 + setTimeout(() => { + const firstHighlight = firstMatch.querySelector( + ".mm-search-highlight", + ); + if (firstHighlight) { + firstHighlight.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + } + }, 100); + } + + // 更新搜索统计信息 + const searchStatsEl = modal.querySelector( + "#mm-preview-search-stats", + ); + if (searchStatsEl) { + searchStatsEl.textContent = `找到 ${totalMatches} 个匹配项`; + } + } + + // 搜索匹配项导航变量 + let currentMatchIndex = 0; + let allHighlights = []; + + // 更新所有高亮元素列表 + function updateAllHighlights() { + allHighlights = Array.from( + modal.querySelectorAll(".mm-search-highlight"), + ); + currentMatchIndex = Math.min( + currentMatchIndex, + allHighlights.length - 1, + ); + } + + // 导航到特定匹配项 + function navigateToMatch(index) { + if (allHighlights.length === 0) return; + + // 确保索引在有效范围内 + index = Math.max(0, Math.min(index, allHighlights.length - 1)); + currentMatchIndex = index; + + // 滚动到当前匹配项 + const highlight = allHighlights[index]; + highlight.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + + // 突出显示当前匹配项 + allHighlights.forEach((h, i) => { + if (i === currentMatchIndex) { + h.style.backgroundColor = "rgba(34, 197, 94, 0.6)"; + h.style.transform = "scale(1.05)"; + h.style.transition = "all 0.2s ease"; + } else { + h.style.backgroundColor = "rgba(255, 255, 0, 0.3)"; + h.style.transform = "scale(1)"; + h.style.transition = "all 0.2s ease"; + } + }); + + // 更新统计信息,显示当前匹配项位置 + const searchStatsEl = modal.querySelector( + "#mm-preview-search-stats", + ); + if (searchStatsEl) { + searchStatsEl.textContent = `找到 ${ + allHighlights.length + } 个匹配项,当前第 ${currentMatchIndex + 1} 个`; + } + } + + // 上一个匹配项 + function goToPrevMatch() { + if (allHighlights.length === 0) return; + const newIndex = + currentMatchIndex > 0 + ? currentMatchIndex - 1 + : allHighlights.length - 1; + navigateToMatch(newIndex); + } + + // 下一个匹配项 + function goToNextMatch() { + if (allHighlights.length === 0) return; + const newIndex = + currentMatchIndex < allHighlights.length - 1 + ? currentMatchIndex + 1 + : 0; + navigateToMatch(newIndex); + } + + // 使用已在头部创建的searchInput变量,不需要重新声明 + if (searchInput) { + // 输入事件监听 + searchInput.addEventListener("input", () => { + currentMatchIndex = 0; + handleSearch(); + setTimeout(updateAllHighlights, 100); + }); + + // 回车键搜索 + searchInput.addEventListener("keydown", (e) => { + if (e.key === "Enter") { + currentMatchIndex = 0; + handleSearch(); + setTimeout(updateAllHighlights, 100); + } + }); + } + + // 绑定事件 + const confirmBtnEl = modal.querySelector("#mm-preview-confirm"); + const cancelBtnEl = modal.querySelector("#mm-preview-cancel"); + // 使用已在头部创建的closeBtn变量,不需要重新声明 + + // 替换功能 + function replaceMatch() { + const searchTerm = searchInput.value.trim(); + const replaceTerm = replaceInput.value; + + if (!searchTerm || allHighlights.length === 0) return; + + // 获取当前匹配项的父容器 + const currentHighlight = allHighlights[currentMatchIndex]; + const parentContent = + currentHighlight.closest(".mm-prompt-content"); + + // 获取原始文本 + const originalText = parentContent.textContent; + + // 替换当前匹配项 + let matchIndex = 0; + const newText = originalText.replace( + new RegExp(searchTerm, "gi"), + (match) => { + if (matchIndex === currentMatchIndex) { + matchIndex++; + return replaceTerm; + } + matchIndex++; + return match; + }, + ); + + // 更新内容 + parentContent.textContent = newText; + + // 重新执行搜索以更新高亮和匹配项列表 + handleSearch(); + setTimeout(() => { + updateAllHighlights(); + // 导航到下一个匹配项 + if (currentMatchIndex < allHighlights.length) { + navigateToMatch(currentMatchIndex); + } + }, 100); + } + + // 全部替换功能 + function replaceAllMatches() { + const searchTerm = searchInput.value.trim(); + const replaceTerm = replaceInput.value; + + if (!searchTerm) return; + + // 获取所有提示词内容容器 + const contentContainers = + modal.querySelectorAll(".mm-prompt-content"); + + contentContainers.forEach((container) => { + const originalText = container.textContent; + const newText = originalText.replace( + new RegExp(searchTerm, "gi"), + replaceTerm, + ); + container.textContent = newText; + }); + + // 重新执行搜索以更新高亮和匹配项列表 + handleSearch(); + setTimeout(updateAllHighlights, 100); + } + + // 获取替换相关按钮 + const replaceBtnEl = modal.querySelector("#mm-preview-replace-btn"); + const replaceAllBtnEl = modal.querySelector( + "#mm-preview-replace-all-btn", + ); + const prevBtnEl = modal.querySelector("#mm-preview-search-prev"); + const nextBtnEl = modal.querySelector("#mm-preview-search-next"); + + // 绑定替换按钮事件 + if (replaceBtnEl) { + replaceBtnEl.addEventListener("click", replaceMatch); + } + + if (replaceAllBtnEl) { + replaceAllBtnEl.addEventListener("click", replaceAllMatches); + } + + // 绑定导航按钮事件 + if (prevBtnEl) { + prevBtnEl.addEventListener("click", goToPrevMatch); + } + + if (nextBtnEl) { + nextBtnEl.addEventListener("click", goToNextMatch); + } + + const cleanup = () => { + document.body.removeChild(modal); + }; + + confirmBtnEl.addEventListener("click", () => { + // 收集所有编辑后的请求数据 + const requestBlocks = + modal.querySelectorAll(".mm-request-block"); + const updatedRequests = []; + + requestBlocks.forEach((requestBlock, reqIndex) => { + const req = requests[reqIndex]; + if (!req) return; + + // 收集所有部分块的内容(按当前DOM顺序) + const partBlocks = requestBlock.querySelectorAll( + ".mm-prompt-part-block", + ); + const updatedParts = []; + const updatedPromptTexts = []; + + partBlocks.forEach((partBlock) => { + const promptContent = + partBlock.querySelector(".mm-prompt-content"); + if (promptContent) { + const originalPartIndex = parseInt( + partBlock.dataset.partIndex || "0", + ); + + // 从原始promptParts中获取部分信息(如果存在) + let partInfo = { + label: "未知部分", + source: "unknown", + }; + if ( + req.promptParts && + req.promptParts[originalPartIndex] + ) { + partInfo = req.promptParts[originalPartIndex]; + } + + // 收集更新后的内容 + const updatedContent = promptContent.textContent; + updatedParts.push({ + ...partInfo, + content: updatedContent, + }); + updatedPromptTexts.push(updatedContent); + } + }); + + // 创建更新后的请求对象 + const updatedReq = { + ...req, + promptParts: + updatedParts.length > 0 + ? updatedParts + : req.promptParts, + prompt: + updatedPromptTexts.length > 0 + ? updatedPromptTexts.join("\n\n") + : req.prompt, + }; + + updatedRequests.push(updatedReq); + }); + + cleanup(); + // 返回编辑后的请求数据 + resolve({ confirmed: true, requests: updatedRequests }); + }); + + cancelBtnEl.addEventListener("click", () => { + cleanup(); + resolve({ confirmed: false }); + }); + + closeBtn.addEventListener("click", () => { + cleanup(); + resolve({ confirmed: false }); + }); + + // 保存顺序按钮事件 + const saveOrderBtn = modal.querySelector("#mm-preview-save-order"); + if (saveOrderBtn) { + saveOrderBtn.addEventListener("click", () => { + // 收集当前所有请求的部分块顺序 + const promptPartsOrder = {}; + + const requestBlocks = + modal.querySelectorAll(".mm-request-block"); + requestBlocks.forEach((requestBlock, reqIndex) => { + const req = requests[reqIndex]; + if (!req) return; + + const category = req.category || req.source; + const partBlocks = requestBlock.querySelectorAll( + ".mm-prompt-part-block", + ); + const order = []; + + partBlocks.forEach((partBlock) => { + const promptContent = + partBlock.querySelector(".mm-prompt-content"); + if (promptContent) { + const originalPartIndex = parseInt( + partBlock.dataset.partIndex || "0", + ); + + // 从原始promptParts中获取source信息 + if ( + req.promptParts && + req.promptParts[originalPartIndex] + ) { + const part = + req.promptParts[originalPartIndex]; + order.push(part.source); // 保存source作为标识 + } + } + }); + + if (order.length > 0) { + promptPartsOrder[category] = order; + } + }); + + // 保存到全局设置 + const settings = getGlobalSettings(); + settings.promptPartsOrder = promptPartsOrder; + updateGlobalSettings(settings); + + // 显示提示 + Logger.log( + "[发送前检查] 已保存默认顺序配置", + promptPartsOrder, + ); + + // 视觉反馈 + const originalText = saveOrderBtn.innerHTML; + saveOrderBtn.innerHTML = + ' 已保存!'; + saveOrderBtn.disabled = true; + setTimeout(() => { + saveOrderBtn.innerHTML = originalText; + saveOrderBtn.disabled = false; + }, 2000); + }); + } + + // 移除点击弹窗外部关闭功能,必须通过按钮关闭 + // modal.addEventListener("click", (e) => { + // if (e.target === modal) { + // cleanup(); + // resolve(false); + // } + // }); + }); + } + + // ============================================================================ + // 汇总检查弹窗函数 + // ============================================================================ + function showSummaryCheckModal(summaryContent, editorContent = "") { + return new Promise((resolve) => { + // 创建弹窗容器 - 无遮罩模式,允许与主界面交互 + const modal = document.createElement("div"); + modal.className = "mm-modal mm-modal-visible"; + modal.style.zIndex = "999999"; + modal.style.position = "fixed"; + modal.style.top = "0"; + modal.style.left = "0"; + modal.style.right = "0"; + modal.style.bottom = "0"; + modal.style.background = "transparent"; + modal.style.display = "flex"; + modal.style.alignItems = "center"; + modal.style.justifyContent = "center"; + modal.style.pointerEvents = "none"; // 允许点击穿透到下层 + + // 应用当前主题 + const settings = getGlobalSettings(); + const theme = settings.theme || "default"; + if (theme !== "default") { + modal.setAttribute("data-mm-theme", theme); + } + + // 创建弹窗内容 + const content = document.createElement("div"); + content.className = "mm-modal-content mm-modal-large"; + content.style.width = "100%"; + content.style.maxWidth = "800px"; + content.style.height = "80vh"; + content.style.maxHeight = "80vh"; + content.style.overflow = "hidden"; + content.style.display = "flex"; + content.style.flexDirection = "column"; + content.style.background = "var(--mm-bg)"; + content.style.borderRadius = "var(--mm-radius)"; + content.style.boxShadow = "0 4px 20px rgba(0, 0, 0, 0.3)"; + content.style.pointerEvents = "auto"; // 弹窗内容可交互 + + // 创建弹窗头部 + const header = document.createElement("div"); + header.className = "mm-modal-header"; + header.style.display = "flex"; + header.style.justifyContent = "space-between"; + header.style.alignItems = "center"; + header.style.padding = "15px 20px"; + header.style.borderBottom = "1px solid var(--mm-border)"; + header.style.flexShrink = "0"; + + const title = document.createElement("h4"); + title.textContent = editorContent + ? "汇总检查 - 记忆摘要 + 剧情优化" + : "汇总检查 - AI 生成的记忆摘要"; + title.style.margin = "0"; + title.style.fontSize = "16px"; + title.style.color = "var(--mm-text)"; + + const closeBtn = document.createElement("button"); + closeBtn.className = "mm-modal-close mm-btn mm-btn-icon"; + closeBtn.innerHTML = ``; + + header.appendChild(title); + header.appendChild(closeBtn); + content.appendChild(header); + + // 创建弹窗主体 + const body = document.createElement("div"); + body.className = "mm-modal-body"; + body.style.flex = "1"; + body.style.overflowY = "auto"; + body.style.padding = "20px"; + + // 提示信息 + const hint = document.createElement("div"); + hint.style.marginBottom = "15px"; + hint.style.padding = "10px 15px"; + hint.style.background = "var(--mm-bg-secondary)"; + hint.style.borderRadius = "var(--mm-radius)"; + hint.style.fontSize = "13px"; + hint.style.color = "var(--mm-text-muted)"; + hint.innerHTML = ` + 以下是将注入到对话中的内容。您可以选择确认发送或重新生成。`; + body.appendChild(hint); + + // 记忆摘要内容区域 + const summaryContainer = document.createElement("div"); + summaryContainer.style.background = "var(--mm-bg-card)"; + summaryContainer.style.borderRadius = "var(--mm-radius)"; + summaryContainer.style.padding = "15px"; + summaryContainer.style.border = "1px solid var(--mm-border)"; + summaryContainer.style.marginBottom = editorContent ? "15px" : "0"; + + const summaryLabel = document.createElement("div"); + summaryLabel.style.fontWeight = "bold"; + summaryLabel.style.marginBottom = "10px"; + summaryLabel.style.color = "var(--mm-primary)"; + summaryLabel.innerHTML = `记忆摘要内容`; + summaryContainer.appendChild(summaryLabel); + + // 创建可调整高度的容器 + const resizableContainer = document.createElement("div"); + resizableContainer.style.position = "relative"; + resizableContainer.style.minHeight = "150px"; + + const summaryText = document.createElement("div"); + summaryText.style.whiteSpace = "pre-wrap"; + summaryText.style.wordBreak = "break-word"; + summaryText.style.fontSize = "14px"; + summaryText.style.lineHeight = "1.6"; + summaryText.style.color = "var(--mm-text)"; + summaryText.style.height = editorContent ? "200px" : "300px"; + summaryText.style.minHeight = "100px"; + summaryText.style.maxHeight = "none"; + summaryText.style.overflowY = "auto"; + summaryText.style.padding = "10px"; + summaryText.style.background = "var(--mm-bg-secondary)"; + summaryText.style.borderRadius = "4px 4px 0 0"; + summaryText.style.resize = "none"; + summaryText.textContent = summaryContent || "(无内容)"; + resizableContainer.appendChild(summaryText); + + // 创建拖动手柄(使用统一的 CSS 类) + const resizeHandle = document.createElement("div"); + resizeHandle.className = "mm-resize-handle"; + resizableContainer.appendChild(resizeHandle); + + // 拖动调整高度逻辑 + let isResizing = false; + let startY = 0; + let startHeight = 0; + + resizeHandle.addEventListener("mousedown", (e) => { + isResizing = true; + startY = e.clientY; + startHeight = summaryText.offsetHeight; + document.body.style.cursor = "ns-resize"; + document.body.style.userSelect = "none"; + e.preventDefault(); + }); + + document.addEventListener("mousemove", (e) => { + if (!isResizing) return; + const deltaY = e.clientY - startY; + // 只设置最小高度,不限制最大高度 + const newHeight = Math.max(100, startHeight + deltaY); + summaryText.style.height = newHeight + "px"; + }); + + document.addEventListener("mouseup", () => { + if (isResizing) { + isResizing = false; + document.body.style.cursor = ""; + document.body.style.userSelect = ""; + } + }); + + summaryContainer.appendChild(resizableContainer); + + body.appendChild(summaryContainer); + + // 如果有剧情优化内容,添加 Editor 区域 + if (editorContent) { + const editorContainer = document.createElement("div"); + editorContainer.style.background = "var(--mm-bg-card)"; + editorContainer.style.borderRadius = "var(--mm-radius)"; + editorContainer.style.padding = "15px"; + editorContainer.style.border = "1px solid var(--mm-border)"; + editorContainer.style.borderLeftColor = "#9d7cd8"; // 紫色边框标识 + editorContainer.style.borderLeftWidth = "3px"; + + const editorLabel = document.createElement("div"); + editorLabel.style.fontWeight = "bold"; + editorLabel.style.marginBottom = "10px"; + editorLabel.style.color = "#9d7cd8"; + editorLabel.innerHTML = `剧情优化内容 (Editor)`; + editorContainer.appendChild(editorLabel); + + // 创建可调整高度的容器 + const editorResizableContainer = document.createElement("div"); + editorResizableContainer.style.position = "relative"; + editorResizableContainer.style.minHeight = "100px"; + + const editorText = document.createElement("div"); + editorText.style.whiteSpace = "pre-wrap"; + editorText.style.wordBreak = "break-word"; + editorText.style.fontSize = "14px"; + editorText.style.lineHeight = "1.6"; + editorText.style.color = "var(--mm-text)"; + editorText.style.height = "150px"; + editorText.style.minHeight = "80px"; + editorText.style.maxHeight = "none"; + editorText.style.overflowY = "auto"; + editorText.style.padding = "10px"; + editorText.style.background = "var(--mm-bg-secondary)"; + editorText.style.borderRadius = "4px 4px 0 0"; + editorText.style.resize = "none"; + editorText.textContent = editorContent; + editorResizableContainer.appendChild(editorText); + + // 创建拖动手柄 + const editorResizeHandle = document.createElement("div"); + editorResizeHandle.className = "mm-resize-handle"; + editorResizableContainer.appendChild(editorResizeHandle); + + // 拖动调整高度逻辑 + let isEditorResizing = false; + let editorStartY = 0; + let editorStartHeight = 0; + + editorResizeHandle.addEventListener("mousedown", (e) => { + isEditorResizing = true; + editorStartY = e.clientY; + editorStartHeight = editorText.offsetHeight; + document.body.style.cursor = "ns-resize"; + document.body.style.userSelect = "none"; + e.preventDefault(); + }); + + document.addEventListener("mousemove", (e) => { + if (!isEditorResizing) return; + const deltaY = e.clientY - editorStartY; + const newHeight = Math.max(80, editorStartHeight + deltaY); + editorText.style.height = newHeight + "px"; + }); + + document.addEventListener("mouseup", () => { + if (isEditorResizing) { + isEditorResizing = false; + document.body.style.cursor = ""; + document.body.style.userSelect = ""; + } + }); + + editorContainer.appendChild(editorResizableContainer); + body.appendChild(editorContainer); + } + + content.appendChild(body); + + // 创建弹窗底部按钮 + const footer = document.createElement("div"); + footer.className = "mm-modal-footer"; + footer.style.display = "flex"; + footer.style.justifyContent = "flex-end"; + footer.style.gap = "10px"; + footer.style.padding = "15px 20px"; + footer.style.borderTop = "1px solid var(--mm-border)"; + footer.style.flexShrink = "0"; + + const cancelBtn = document.createElement("button"); + cancelBtn.className = "mm-btn mm-btn-secondary"; + cancelBtn.innerHTML = `取消发送`; + + const regenerateBtn = document.createElement("button"); + regenerateBtn.className = "mm-btn mm-btn-secondary"; + regenerateBtn.innerHTML = `重新生成`; + + const confirmBtn = document.createElement("button"); + confirmBtn.className = "mm-btn mm-btn-primary"; + confirmBtn.innerHTML = `确认发送`; + + footer.appendChild(cancelBtn); + footer.appendChild(regenerateBtn); + footer.appendChild(confirmBtn); + content.appendChild(footer); + + modal.appendChild(content); + document.body.appendChild(modal); + + const cleanup = () => { + document.body.removeChild(modal); + }; + + // 确认发送 + confirmBtn.addEventListener("click", () => { + cleanup(); + resolve({ action: "confirm" }); + }); + + // 重新生成 + regenerateBtn.addEventListener("click", () => { + cleanup(); + resolve({ action: "regenerate" }); + }); + + // 取消发送 + cancelBtn.addEventListener("click", () => { + cleanup(); + resolve({ action: "cancel" }); + }); + + // 关闭按钮 + closeBtn.addEventListener("click", () => { + cleanup(); + resolve({ action: "cancel" }); + }); + }); + } + + // AI 处理函数 + // ============================================================================ + + async function processCategory( + category, + data, + userMessage, + context, + signal = null, + ) { + const taskId = `memory_${category}`; + const { index, details } = data; + const aiConfig = getMemoryConfig(category); + const globalConfig = getGlobalConfig(); + + // 开始任务 + if (progressTracker) { + progressTracker.startTask(taskId); + } + + // 收集所有 details 条目的关键词(不限制数量,由AI根据提示词中的关联度规则筛选) + // 直接使用世界书条目的 key 字段(绿灯触发关键词)的第一个作为主关键词 + const detailKeys = []; + + if (details && Array.isArray(details)) { + for (const entry of details) { + // 直接使用条目的第一个绿灯关键词 + if ( + entry.keys && + Array.isArray(entry.keys) && + entry.keys.length > 0 + ) { + const primaryKey = entry.keys[0]; + if ( + primaryKey && + primaryKey.trim() && + !detailKeys.includes(primaryKey.trim()) + ) { + detailKeys.push(primaryKey.trim()); + } + } + } + } + Logger.debug( + `分类 "${category}" 收集关键词: 共${ + details?.length || 0 + }条目, 实际收集${detailKeys.length}个关键词,将全部发送给AI筛选`, + ); + + try { + const dataInjection = buildDataInjection({ + worldBookContent: formatAsWorldBook(index, details), + context: context, + userMessage: userMessage, + }); + + const template = await getPromptTemplate(); + const prompt = injectDataToPrompt(template, dataInjection); + const baseSystemPrompt = replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + "\n\n" + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = buildUserPrompt(userMessage); + + // 添加来源信息到aiConfig + const configWithSource = { + ...aiConfig, + category: category, + source: category, + }; + + // 使用带重试的调用 + const response = await APIAdapter.callWithRetry( + configWithSource, + finalSystemPrompt, + finalUserMessage, + taskId, + 3, + signal, + ); + + // 完成任务 + if (progressTracker) { + progressTracker.completeTask(taskId, true); + } + + return { + category, + type: "keyword", + rawMemory: response, + detailKeys: detailKeys, // 返回世界书条目的关键词 + }; + } catch (error) { + // 任务失败 + if (progressTracker) { + const errorMsg = + error.name === "AbortError" + ? "已终止" + : error.message.substring(0, 30); + progressTracker.completeTask(taskId, false, errorMsg); + } + throw error; + } + } + + async function processSummaryBook( + book, + userMessage, + context, + signal = null, + ) { + const taskId = `summary_${book.name}`; + const aiConfig = getSummaryConfig(book.name); + const globalConfig = getGlobalConfig(); + + // 开始任务 + if (progressTracker) { + progressTracker.startTask(taskId); + } + + try { + const summaryContent = getSummaryContent(book); + + const dataInjection = buildDataInjection({ + worldBookContent: summaryContent, + context: context, + userMessage: userMessage, + }); + + // 使用历史事件回忆提示词模板(总结世界书专用) + const template = await getHistoricalPromptTemplate(); + const prompt = injectDataToPrompt(template, dataInjection); + const baseSystemPrompt = replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + "\n\n" + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = buildUserPrompt(userMessage); + + // 添加来源信息到aiConfig + const configWithSource = { + ...aiConfig, + category: book.name, + source: book.name, + }; + + // 使用带重试的调用 + const response = await APIAdapter.callWithRetry( + configWithSource, + finalSystemPrompt, + finalUserMessage, + taskId, + 3, + signal, + ); + + // 完成任务 + if (progressTracker) { + progressTracker.completeTask(taskId, true); + } + + return { + bookName: book.name, + type: "summary", + rawMemory: response, + }; + } catch (error) { + // 任务失败 + if (progressTracker) { + const errorMsg = + error.name === "AbortError" + ? "已终止" + : error.message.substring(0, 30); + progressTracker.completeTask(taskId, false, errorMsg); + } + throw error; + } + } + + /** + * 收集所有分类的 Index 内容(用于索引合并模式) + * @param {Array} memoryBooks - 记忆世界书列表 + * @returns {Object} { content: string, categories: string[], detailKeys: string[] } + */ + function collectAllCategoryIndex(memoryBooks) { + let allIndexContent = ""; + const includedCategories = []; + const allDetailKeys = []; // 收集所有分类的 detailKeys + + for (const { book, categories } of memoryBooks) { + for (const [category, data] of Object.entries(categories)) { + // 检查分类是否被用户明确禁用(如果有配置的话) + // 注意:索引合并模式下,分类不需要有独立的 API 配置 + // 只有当用户明确禁用某个分类时才跳过 + try { + const aiConfig = getMemoryConfig(category); + if (aiConfig && aiConfig.enabled === false) { + Logger.debug( + `[索引合并] 分类 "${category}" 已禁用,跳过`, + ); + continue; + } + } catch (e) { + // 没有配置不代表禁用,在索引合并模式下继续处理 + Logger.debug( + `[索引合并] 分类 "${category}" 无独立配置,将包含在合并中`, + ); + } + + if (data.index && data.index.length > 0) { + allIndexContent += `=== ${category} Index ===\n`; + for (const entry of data.index) { + allIndexContent += `[${entry.comment}]\n${entry.content}\n\n`; + // 同时收集 index 的 comment 作为有效关键词(因为这是 AI 能看到的内容) + if ( + entry.comment && + entry.comment.trim() && + !allDetailKeys.includes(entry.comment.trim()) + ) { + allDetailKeys.push(entry.comment.trim()); + } + } + includedCategories.push(category); + + // 也收集 details 的 keys 作为有效关键词(扩大匹配范围) + if (data.details && Array.isArray(data.details)) { + for (const entry of data.details) { + if ( + entry.keys && + Array.isArray(entry.keys) && + entry.keys.length > 0 + ) { + const primaryKey = entry.keys[0]; + if ( + primaryKey && + primaryKey.trim() && + !allDetailKeys.includes(primaryKey.trim()) + ) { + allDetailKeys.push(primaryKey.trim()); + } + } + } + } + } + } + } + + Logger.debug( + `[索引合并] 收集了 ${includedCategories.length} 个分类的索引内容,共 ${allDetailKeys.length} 个关键词`, + ); + return { + content: allIndexContent.trim(), + categories: includedCategories, + detailKeys: allDetailKeys, + }; + } + + /** + * 处理索引合并请求 + * @param {string} indexContent - 合并后的索引内容 + * @param {string} userMessage - 用户消息 + * @param {string} context - 上下文 + * @param {AbortSignal} signal - 终止信号 + * @param {Object} aiConfig - AI 配置 + * @param {string[]} detailKeys - 合并的关键词列表 + * @returns {Object} 处理结果 + */ + async function processIndexMerge( + indexContent, + userMessage, + context, + signal, + aiConfig, + detailKeys = [], + ) { + const taskId = "index_merge"; + const globalConfig = getGlobalConfig(); + + // 开始任务 + if (progressTracker) { + progressTracker.startTask(taskId); + } + + try { + const dataInjection = buildDataInjection({ + worldBookContent: indexContent, + context: context, + userMessage: userMessage, + }); + + const template = await getPromptTemplate(); + const prompt = injectDataToPrompt(template, dataInjection); + const baseSystemPrompt = replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + "\n\n" + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = buildUserPrompt(userMessage); + + // 添加来源信息到 aiConfig + const configWithSource = { + ...aiConfig, + category: "索引合并", + source: "IndexMerge", + }; + + // 使用带重试的调用 + const response = await APIAdapter.callWithRetry( + configWithSource, + finalSystemPrompt, + finalUserMessage, + taskId, + 3, + signal, + ); + + // 完成任务 + if (progressTracker) { + progressTracker.completeTask(taskId, true); + } + + return { + bookName: "IndexMerge", + type: "merge", + category: "索引合并", + rawMemory: response, + detailKeys: detailKeys, + }; + } catch (error) { + // 任务失败 + if (progressTracker) { + const errorMsg = + error.name === "AbortError" + ? "已终止" + : error.message.substring(0, 30); + progressTracker.completeTask(taskId, false, errorMsg); + } + throw error; + } + } + + // ============================================================================ + // 发送按钮 Hook - 拦截用户发送,处理记忆后再发送 + // ============================================================================ + + let isProcessing = false; // 防止重复处理 + let skipNextHook = false; // 跳过下一次 hook(用于触发真正的发送) + + // 终止处理函数 + function stopProcessing() { + // 终止所有任务 + if (progressTracker && progressTracker.taskAbortControllers) { + for (const [ + taskId, + controller, + ] of progressTracker.taskAbortControllers) { + controller.abort(); + } + Logger.warn("用户终止了所有处理"); + } + + // 也终止全局的 abortController(兼容) + if (abortController) { + abortController.abort(); + } + isProcessing = false; + + // 关闭记忆搜索助手面板 + const searchPanel = getInteractiveSearchPanel(); + if (searchPanel) { + searchPanel.hide(); + } + + // 关闭剧情优化助手面板 + hidePlotOptimizePanel(); + } + + /** + * 获取当前聊天上下文(用于记忆处理) + */ + function getCurrentChatContext() { + try { + const context = SillyTavern.getContext(); + return context.chat || []; + } catch (e) { + Logger.error("获取聊天上下文失败:", e); + return []; + } + } + + /** + * 核心处理函数 - 处理记忆并返回结果 + */ + async function processMemoryForMessage(userMessage) { + Logger.log("开始处理记忆..."); + + if (!isPluginEnabled()) { + return null; + } + + // 发送前先刷新世界书列表,确保数据是最新的 + await refreshWorldBookList(); + + const startTime = Date.now(); + setMenuButtonProcessing(true); + setFloatBallProcessing(true); + + // 创建 AbortController + abortController = new AbortController(); + const signal = abortController.signal; + + // 初始化进度追踪器 + if (!progressTracker) { + progressTracker = new ProgressTracker(); + } + + try { + const worldBooks = await getImportedWorldBooks(); + + if (worldBooks.length === 0) { + Logger.warn("未导入任何世界书,跳过处理"); + return null; + } + + const { memoryBooks, summaryBooks, unknownBooks } = + classifyWorldBooks(worldBooks); + + Logger.debug( + `世界书分类结果: 记忆世界书 ${memoryBooks.length} 个, 总结世界书 ${summaryBooks.length} 个, 未识别 ${unknownBooks.length} 个`, + ); + + if (unknownBooks.length > 0) { + Logger.warn(`有 ${unknownBooks.length} 个未识别的世界书被跳过`); + } + + // 获取当前聊天历史作为上下文 + const chat = getCurrentChatContext(); + const globalConfig = getGlobalConfig(); + const contextRounds = globalConfig.contextRounds ?? 5; + const context = getRecentContext(chat, contextRounds); + + // 获取标签过滤配置 + const tagFilterConfig = globalConfig.contextTagFilter || { + enableExtract: false, + enableExclude: false, + excludeTags: ["Plot_progression"], + extractTags: [], + caseSensitive: false, + }; + + // 从最后一条助手消息中截取末尾200字(应用提取标签过滤) + // 仅在启用剧情末尾功能时执行 + let latestContext = ""; + const globalSettings = getGlobalSettings(); + if ( + globalSettings.enableRecentPlot !== false && + chat && + chat.length > 0 + ) { + // 找到最后一条助手消息 + let lastAssistantMsg = null; + for (let i = chat.length - 1; i >= 0; i--) { + const msg = chat[i]; + const isUser = msg.is_user || msg.role === "user"; + if (!isUser) { + lastAssistantMsg = msg; + break; + } + } + + if (lastAssistantMsg) { + let content = + lastAssistantMsg.content || lastAssistantMsg.mes || ""; + + // 应用提取标签过滤(如果启用) + if ( + tagFilterConfig.enableExtract || + tagFilterConfig.enableExclude + ) { + content = filterContentByTags(content, tagFilterConfig); + Logger.debug( + "[近期剧情] 应用标签过滤后长度:", + content.length, + ); + } else { + // 默认行为:移除 Plot_progression 标签 + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + + // 截取末尾200字 + latestContext = content.slice(-200).trim(); + Logger.debug( + "[近期剧情] 截取末尾200字:", + latestContext.substring(0, 50) + "...", + ); + } + } else if (globalSettings.enableRecentPlot === false) { + Logger.debug("[近期剧情] 功能已禁用,跳过截取"); + } + + if (contextRounds === 0) { + Logger.debug("上下文轮次为 0,不读取前文内容"); + } else { + Logger.debug( + `读取 ${contextRounds} 轮上下文 (${ + contextRounds * 2 + } 条消息)`, + ); + } + + // 收集所有任务信息用于进度追踪 + const taskInfoList = []; + const tasks = []; + const taskAbortControllers = new Map(); // 每个任务单独的 AbortController + + // 检查是否启用索引合并模式 + const useIndexMerge = + globalSettings.sendIndexOnly && + globalSettings.indexMergeEnabled; + + if (useIndexMerge) { + // === 索引合并模式:将所有分类的 Index 合并为一个任务 === + Logger.log("[索引合并模式] 启用,将合并所有分类的索引内容"); + + const mergedIndexData = collectAllCategoryIndex(memoryBooks); + + if (mergedIndexData.content) { + const taskId = "index_merge"; + const taskController = new AbortController(); + taskAbortControllers.set(taskId, taskController); + + const indexMergeConfig = + globalSettings.indexMergeConfig || {}; + + taskInfoList.push({ + id: taskId, + name: "索引合并", + type: "merge", + }); + + tasks.push({ + taskId, + fn: () => + processIndexMerge( + mergedIndexData.content, + userMessage, + context, + taskController.signal, + indexMergeConfig, + mergedIndexData.detailKeys, + ), + }); + + Logger.log( + `[索引合并模式] 已合并 ${ + mergedIndexData.categories.length + } 个分类: ${mergedIndexData.categories.join(", ")}`, + ); + } else { + Logger.warn("[索引合并模式] 没有可合并的索引内容"); + } + } else { + // === 原有并发模式:每个分类独立请求 === + for (const { book, categories } of memoryBooks) { + for (const [category, data] of Object.entries(categories)) { + try { + const aiConfig = getMemoryConfig(category); + // 检查分类是否启用 + if (!aiConfig.enabled) { + Logger.debug(`分类 "${category}" 已禁用,跳过`); + continue; + } + const taskId = `memory_${category}`; + const taskController = new AbortController(); + taskAbortControllers.set(taskId, taskController); + + taskInfoList.push({ + id: taskId, + name: category, + type: "memory", + }); + tasks.push({ + taskId, + fn: () => + processCategory( + category, + data, + userMessage, + context, + taskController.signal, + ), + }); + } catch (e) { + Logger.warn(`分类 "${category}" 未配置,跳过`); + } + } + } + } + + // 获取交互式搜索设置(用于后续判断) + const interactiveSettings = getInteractiveSearchSettings(); + + // 总结世界书:只在发送前检查启用时添加到任务列表(用于预览) + // 如果启用交互式搜索且没有启用发送前检查,由记忆搜索助手面板处理,不添加到进度列表 + const shouldAddSummaryToTaskList = + globalSettings.showRequestPreview || + !interactiveSettings.enabled; + + for (const book of summaryBooks) { + try { + const aiConfig = getSummaryConfig(book.name); + // 检查总结世界书是否启用 + if (!aiConfig.enabled) { + Logger.debug(`总结世界书 "${book.name}" 已禁用,跳过`); + continue; + } + + // 如果启用了交互式搜索且没有启用发送前检查,不添加到进度列表 + if (!shouldAddSummaryToTaskList) { + Logger.debug( + `总结世界书 "${book.name}" 由记忆搜索助手处理,不添加到进度列表`, + ); + continue; + } + + const taskId = `summary_${book.name}`; + const taskController = new AbortController(); + taskAbortControllers.set(taskId, taskController); + + taskInfoList.push({ + id: taskId, + name: book.name, + type: "summary", + }); + tasks.push({ + taskId, + fn: () => + processSummaryBook( + book, + userMessage, + context, + taskController.signal, + ), + }); + } catch (e) { + Logger.warn(`总结世界书 "${book.name}" 未配置,跳过`); + } + } + + // 检查是否启用了剧情优化 + const plotOptimizeEnabled = isPlotOptimizeEnabled(); + + // 如果没有任务且没有启用剧情优化,跳过处理 + if ( + tasks.length === 0 && + !plotOptimizeEnabled && + !interactiveSettings.enabled + ) { + Logger.log("没有可处理的任务,跳过处理"); + return null; + } + + // 初始化进度追踪器(即使没有记忆任务,也需要初始化) + if (taskInfoList.length > 0) { + progressTracker.init(taskInfoList); + + // 注册每个任务的 AbortController 到进度追踪器 + for (const [taskId, controller] of taskAbortControllers) { + progressTracker.setTaskAbortController(taskId, controller); + } + } + + // 检查是否启用了发送前检查功能 + if (globalSettings.showRequestPreview) { + // 创建一个函数来收集单个任务的请求信息 + async function collectRequestInfo(task) { + if (task.taskId.startsWith("memory_")) { + const category = task.taskId.replace("memory_", ""); + // 查找对应的memoryBooks和data + for (const { book, categories } of memoryBooks) { + if (categories[category]) { + const data = categories[category]; + const aiConfig = getMemoryConfig(category); + const globalConfig = getGlobalConfig(); + + try { + const dataInjection = buildDataInjection({ + worldBookContent: formatAsWorldBook( + data.index, + data.details, + ), + context: context, + userMessage: userMessage, + }); + + const template = await getPromptTemplate(); + const prompt = injectDataToPrompt( + template, + dataInjection, + ); + const baseSystemPrompt = + replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + + "\n\n" + + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = + buildUserPrompt(userMessage); + + // 构建详��的prompt部分列表 + const promptParts = []; + + // 添加破限词 + const jailbreakPrefix = + getJailbreakPrefix(); + if ( + jailbreakPrefix && + jailbreakPrefix.trim() + ) { + promptParts.push({ + label: "破限词", + content: jailbreakPrefix, + source: "jailbreak", + }); + } + + // 添加主提示词(去掉注入内容) + const mainPromptWithoutInjection = + template.mainPrompt || + template.main_prompt || + ""; + const cleanMainPrompt = + mainPromptWithoutInjection + .split("<数据注入区>")[0] + .trim(); + if (cleanMainPrompt) { + promptParts.push({ + label: "主提示词", + content: cleanMainPrompt, + source: "main", + }); + } + + // 添加注入的各个部分(世界书、上下文等) + if ( + prompt.injectionParts && + prompt.injectionParts.length > 0 + ) { + promptParts.push( + ...prompt.injectionParts, + ); + } + + // 添加辅助提示词 + if ( + prompt.auxiliaryPrompt && + prompt.auxiliaryPrompt.trim() + ) { + promptParts.push({ + label: "辅助提示词", + content: prompt.auxiliaryPrompt, + source: "auxiliary", + }); + } + + // 添加用户消息 + promptParts.push({ + label: "用户消息", + content: finalUserMessage, + source: "user", + }); + + return { + category: category, + source: category, + model: aiConfig.model || "未指定模型", + promptParts: promptParts, + prompt: `${finalSystemPrompt}\n\n${finalUserMessage}`, // 保留完整prompt用于兼容 + // 保存完整的API配置,供编辑后调用使用 + aiConfig: { + apiFormat: aiConfig.apiFormat, + apiUrl: aiConfig.apiUrl, + apiKey: aiConfig.apiKey, + model: aiConfig.model, + maxTokens: aiConfig.maxTokens, + temperature: aiConfig.temperature, + responsePath: aiConfig.responsePath, + }, + taskType: "memory", + detailKeys: data.details + ? data.details + .map( + (d) => + d.key || + d.keywords?.[0], + ) + .filter(Boolean) + : [], + }; + } catch (err) { + Logger.error( + `收集记忆任务 "${category}" 请求信息失败:`, + err.message, + ); + return null; + } + } + } + } else if (task.taskId.startsWith("summary_")) { + const bookName = task.taskId.replace("summary_", ""); + // 查找对应的summaryBook + for (const book of summaryBooks) { + if (book.name === bookName) { + const aiConfig = getSummaryConfig(book.name); + const globalConfig = getGlobalConfig(); + + try { + const summaryContent = + getSummaryContent(book); + + const dataInjection = buildDataInjection({ + worldBookContent: summaryContent, + context: context, + userMessage: userMessage, + }); + + // 使用历史事件回忆提示词模板(总结世界书专用) + const template = + await getHistoricalPromptTemplate(); + const prompt = injectDataToPrompt( + template, + dataInjection, + ); + const baseSystemPrompt = + replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + + "\n\n" + + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = + buildUserPrompt(userMessage); + + // 构建详细的prompt部分列表 + const promptParts = []; + + // 添加破限词 + const jailbreakPrefix = + getJailbreakPrefix(); + if ( + jailbreakPrefix && + jailbreakPrefix.trim() + ) { + promptParts.push({ + label: "破限词", + content: jailbreakPrefix, + source: "jailbreak", + }); + } + + // 添加主提示词(去掉注入内容) + const mainPromptWithoutInjection = + template.mainPrompt || + template.main_prompt || + ""; + const cleanMainPrompt = + mainPromptWithoutInjection + .split("<数据注入区>")[0] + .trim(); + if (cleanMainPrompt) { + promptParts.push({ + label: "主提示词", + content: cleanMainPrompt, + source: "main", + }); + } + + // 添加注入的各个部分(世界书、上下文等) + if ( + prompt.injectionParts && + prompt.injectionParts.length > 0 + ) { + promptParts.push( + ...prompt.injectionParts, + ); + } + + // 添加辅助提示词 + if ( + prompt.auxiliaryPrompt && + prompt.auxiliaryPrompt.trim() + ) { + promptParts.push({ + label: "辅助提示词", + content: prompt.auxiliaryPrompt, + source: "auxiliary", + }); + } + + // 添加用户消息 + promptParts.push({ + label: "用户消息", + content: finalUserMessage, + source: "user", + }); + + return { + category: book.name, + source: book.name, + model: aiConfig.model || "未指定模型", + promptParts: promptParts, + prompt: `${finalSystemPrompt}\n\n${finalUserMessage}`, + // 保存完整的API配置,供编辑后调用使用 + aiConfig: { + apiFormat: aiConfig.apiFormat, + apiUrl: aiConfig.apiUrl, + apiKey: aiConfig.apiKey, + model: aiConfig.model, + maxTokens: aiConfig.maxTokens, + temperature: aiConfig.temperature, + responsePath: aiConfig.responsePath, + }, + taskType: "summary", + bookName: book.name, + }; + } catch (err) { + Logger.error( + `收集总结任务 "${bookName}" 请求信息失败:`, + err.message, + ); + return null; + } + } + } + } else if (task.taskId === "index_merge") { + // 索引合并任务 + const aiConfig = globalSettings.indexMergeConfig || {}; + const globalConfig = getGlobalConfig(); + + try { + const mergedIndexData = + collectAllCategoryIndex(memoryBooks); + + if (!mergedIndexData.content) { + Logger.warn("索引合并:没有可合并的索引内容"); + return null; + } + + const dataInjection = buildDataInjection({ + worldBookContent: mergedIndexData.content, + context: context, + userMessage: userMessage, + }); + + const template = await getPromptTemplate(); + const prompt = injectDataToPrompt( + template, + dataInjection, + ); + const baseSystemPrompt = replacePromptVariables( + prompt.systemPrompt, + aiConfig, + globalConfig, + ); + + // 添加破限词前缀 + const finalSystemPrompt = + getJailbreakPrefix() + + "\n\n" + + baseSystemPrompt; + + // 构建用户提示词 + const finalUserMessage = + buildUserPrompt(userMessage); + + // 构建详细的prompt部分列表 + const promptParts = []; + + // 添加破限词 + const jailbreakPrefix = getJailbreakPrefix(); + if (jailbreakPrefix && jailbreakPrefix.trim()) { + promptParts.push({ + label: "破限词", + content: jailbreakPrefix, + source: "jailbreak", + }); + } + + // 添加主提示词(去掉注入内容) + const mainPromptWithoutInjection = + template.mainPrompt || + template.main_prompt || + ""; + const cleanMainPrompt = mainPromptWithoutInjection + .split("<数据注入区>")[0] + .trim(); + if (cleanMainPrompt) { + promptParts.push({ + label: "主提示词", + content: cleanMainPrompt, + source: "main", + }); + } + + // 添加注入的各个部分(世界书、上下文等) + if ( + prompt.injectionParts && + prompt.injectionParts.length > 0 + ) { + promptParts.push(...prompt.injectionParts); + } + + // 添加辅助提示词 + if ( + prompt.auxiliaryPrompt && + prompt.auxiliaryPrompt.trim() + ) { + promptParts.push({ + label: "辅助提示词", + content: prompt.auxiliaryPrompt, + source: "auxiliary", + }); + } + + // 添加用户消息 + promptParts.push({ + label: "用户消息", + content: finalUserMessage, + source: "user", + }); + + return { + category: "索引合并", + source: `合并了 ${ + mergedIndexData.categories.length + } 个分类: ${mergedIndexData.categories.join( + ", ", + )}`, + model: aiConfig.model || "未指定模型", + promptParts: promptParts, + prompt: `${finalSystemPrompt}\n\n${finalUserMessage}`, + // 保存完整的API配置,供编辑后调用使用 + aiConfig: { + apiFormat: aiConfig.apiFormat, + apiUrl: aiConfig.apiUrl, + apiKey: aiConfig.apiKey, + model: aiConfig.model, + maxTokens: aiConfig.maxTokens, + temperature: aiConfig.temperature, + responsePath: aiConfig.responsePath, + }, + taskType: "merge", + detailKeys: mergedIndexData.detailKeys || [], + }; + } catch (err) { + Logger.error( + `收集索引合并任务请求信息失败:`, + err.message, + ); + return null; + } + } + return null; + } + + // 收集所有请求信息 + const requestInfos = await Promise.all( + tasks.map(collectRequestInfo), + ); + + // 过滤掉null值 + const validRequestInfos = requestInfos.filter( + (req) => req !== null, + ); + + // 如果启用了剧情优化,添加剧情优化的预览信息 + if (isPlotOptimizeEnabled()) { + const plotConfig = globalSettings.plotOptimizeConfig || {}; + if (plotConfig.apiUrl && plotConfig.model) { + try { + const plotPreview = await buildPlotOptimizePreview( + plotConfig, + userMessage, + chat, + ); + validRequestInfos.push(plotPreview); + } catch (e) { + Logger.warn("[剧情优化] 构建预览失败:", e); + validRequestInfos.push({ + category: "剧情优化", + source: "剧情优化助手", + model: plotConfig.model || "未指定模型", + promptParts: [ + { + label: "错误信息", + content: "[剧情优化预览构建失败]", + source: "error", + }, + ], + prompt: "[剧情优化预览构建失败]", + }); + } + } + } + + if (validRequestInfos.length > 0) { + // 显示合并的请求预览弹窗 + const previewResult = + await showRequestPreview(validRequestInfos); + if (!previewResult || !previewResult.confirmed) { + Logger.warn("用户取消了API请求"); + progressTracker.finish(); + // 隐藏进度面板 + if (messageProgressPanel) { + messageProgressPanel.hide(); + } + // 返回特殊标记表示用户主动取消,与处理失败区分 + return { cancelled: true }; + } + + // 用户确认后,使用编辑后的请求数据 + const updatedRequestInfos = + previewResult.requests || validRequestInfos; + + // 根据编辑后的请求数据,重新构建tasks + // 清空原有tasks,使用编辑后的数据重新构建 + tasks.length = 0; + taskInfoList.length = 0; + taskAbortControllers.clear(); + + // 为每个编辑后的请求创建新的task + for (const reqInfo of updatedRequestInfos) { + // 跳过剧情优化任务,它通过独立面板处理 + if ( + reqInfo.category === "剧情优化" || + reqInfo.source === "剧情优化助手" + ) { + continue; + } + // 跳过总结世界书任务(当启用交互式搜索时,由记忆搜索助手处理) + if ( + interactiveSettings.enabled && + reqInfo.taskType === "summary" + ) { + continue; + } + + const taskId = `edited_${ + reqInfo.category || reqInfo.source + }`; + const taskController = new AbortController(); + taskAbortControllers.set(taskId, taskController); + + taskInfoList.push({ + id: taskId, + name: + reqInfo.category || + reqInfo.source || + "未知任务", + type: "edited", + }); + + // 创建一个新的task,直接使用编辑后的prompt + // 使用立即执行函数捕获当前taskId值,避免闭包问题 + const currentTaskId = taskId; + tasks.push({ + taskId, + fn: () => + callAPIWithEditedPrompt( + reqInfo, + taskController.signal, + currentTaskId, + ), + }); + } + + // 重新初始化进度追踪器,使用新的任务列表 + progressTracker.init(taskInfoList); + + // 重新注册每个任务的 AbortController 到进度追踪器 + for (const [taskId, controller] of taskAbortControllers) { + progressTracker.setTaskAbortController( + taskId, + controller, + ); + } + } + } + + Logger.log(`开始并发处理 ${tasks.length} 个任务...`); + + // 使用前面已声明的 interactiveSettings + let interactiveSearchResult = null; + let plotOptimizeResult = null; + + // 情况1:交互式搜索和/或剧情优化启用 + if (interactiveSettings.enabled || plotOptimizeEnabled) { + Logger.log("[并发处理] 启用交互式功能", { + search: interactiveSettings.enabled, + plotOptimize: plotOptimizeEnabled, + }); + + // 启动交互式搜索面板(如果启用) + let searchPromise = null; + let searchPanel = null; + if (interactiveSettings.enabled) { + searchPanel = getInteractiveSearchPanel(); + searchPromise = performInteractiveSearch(userMessage, { + targetCount: globalSettings.maxHistoryEvents || 5, + context: context, + }); + } + + // 启动剧情优化面板(如果启用) + let plotPromise = null; + if (plotOptimizeEnabled) { + plotPromise = startPlotOptimizeSession({ + userMessage: userMessage, + }); + } + + // 并发执行其他任务,实时更新进度 + let completedCount = 0; + const taskResults = []; + + // 过滤掉由交互式面板处理的任务 + const executableTasks = interactiveSettings.enabled + ? tasks.filter((t) => !t.taskId.startsWith("summary_")) + : tasks; + const totalTasks = executableTasks.length; + + // 初始化进度显示(只有有任务时才显示) + if (totalTasks > 0) { + if (searchPanel) { + searchPanel.updateOtherTasksStatus(0, totalTasks, null); + } + if (plotOptimizeEnabled) { + updatePlotPanelOtherTasksStatus(0, totalTasks, null); + } + } + + const otherTasksPromise = Promise.all( + executableTasks.map((task) => + task + .fn() + .catch((err) => { + if (err.name === "AbortError") { + Logger.warn(`任务 "${task.taskId}" 被终止`); + } else { + Logger.error( + `处理任务 "${task.taskId}" 失败:`, + err.message, + ); + } + return null; + }) + .then((result) => { + completedCount++; + taskResults.push(result); + // 实时更新进度 + if (searchPanel) { + searchPanel.updateOtherTasksStatus( + completedCount, + totalTasks, + completedCount >= totalTasks + ? taskResults + : null, + ); + } + if (plotOptimizeEnabled) { + updatePlotPanelOtherTasksStatus( + completedCount, + totalTasks, + completedCount >= totalTasks + ? taskResults + : null, + ); + } + return result; + }), + ), + ); + + // 构建等待的 Promise 列表 + const waitPromises = [otherTasksPromise]; + if (searchPromise) { + waitPromises.push( + searchPromise.catch((err) => { + Logger.warn("交互式搜索失败:", err.message); + return null; + }), + ); + } + if (plotPromise) { + waitPromises.push( + plotPromise.catch((err) => { + Logger.warn("剧情优化失败:", err.message); + return null; + }), + ); + } + + // 等待所有任务完成 + const allResults = await Promise.all(waitPromises); + + // 解析结果 + const otherTasksResults = allResults[0]; + let resultIndex = 1; + if (searchPromise) { + interactiveSearchResult = allResults[resultIndex++]; + } + if (plotPromise) { + plotOptimizeResult = allResults[resultIndex++]; + } + + // 合并结果 + const validResults = (otherTasksResults || []).filter( + (r) => r !== null, + ); + + // 如果用户取消了搜索,返回取消状态 + if ( + interactiveSearchResult && + interactiveSearchResult.action === "cancel" + ) { + Logger.log("[交互式搜索] 用户取消了搜索"); + progressTracker.finish(); + if (messageProgressPanel) { + messageProgressPanel.hide(); + } + return { cancelled: true }; + } + + // 如果用户选择了记忆,将所有记忆合并为一个结果 + if ( + interactiveSearchResult && + interactiveSearchResult.action === "confirm" + ) { + const selectedMemories = + interactiveSearchResult.memories || []; + if (selectedMemories.length > 0) { + const historicalLines = []; + + for (const m of selectedMemories) { + const floor = m.uid || "0"; + const content = m.content || ""; + historicalLines.push(`【${floor}楼】${content}`); + } + + const rawMemory = `\n${historicalLines.join( + "\n", + )}\n`; + + const interactiveMemory = { + source: "交互式搜索", + category: "用户选择", + type: "interactive", + rawMemory: rawMemory, + detailKeys: [], + }; + validResults.push(interactiveMemory); + Logger.log( + `[交互式搜索] 用户选择了 ${selectedMemories.length} 条历史事件`, + ); + } + } + + Logger.log( + `完成 ${validResults.length}/${tasks.length} 个任务`, + ); + + // 完成进度追踪 + progressTracker.finish(); + + // 获取剧情优化内容(如果有) + let editorContent = ""; + if ( + plotOptimizeResult && + plotOptimizeResult.action === "confirm" && + plotOptimizeResult.content + ) { + editorContent = plotOptimizeResult.content; + Logger.log("[剧情优化] 用户接受了剧情优化内容"); + } + + // 如果没有记忆结果也没有剧情优化内容,跳过 + if (validResults.length === 0 && !editorContent) { + Logger.warn("没有可用的结果,跳过注入"); + return null; + } + + const memory = + validResults.length > 0 + ? mergeResults(validResults, latestContext) + : null; + + // 检查是否启用了汇总检查功能(有记忆或有剧情优化内容时弹出) + if ( + globalSettings.showSummaryCheck && + (memory || editorContent) + ) { + const checkResult = await showSummaryCheckModal( + memory, + editorContent, + ); + + if (checkResult.action === "cancel") { + Logger.log("用户取消了发送"); + if (messageProgressPanel) { + messageProgressPanel.hide(); + } + return { cancelled: true }; + } else if (checkResult.action === "regenerate") { + Logger.log("用户选择重新生成,重新处理..."); + return await processMemoryForMessage(userMessage); + } + } + + const duration = Date.now() - startTime; + Logger.log( + `处理完成,总耗时: ${duration}ms, 成功: ${validResults.length}/${tasks.length}`, + ); + + // 如果有剧情优化内容,返回包含 editorContent 的对象 + if (editorContent) { + return { + memory: memory, + editorContent: editorContent, + }; + } + + return memory; + } + + // 原有逻辑:非交互式搜索模式 + // 并发执行任务 + const results = await Promise.all( + tasks.map((task) => + task.fn().catch((err) => { + if (err.name === "AbortError") { + Logger.warn(`任务 "${task.taskId}" 被终止`); + } else { + Logger.error( + `处理任务 "${task.taskId}" 失败:`, + err.message, + ); + } + return null; + }), + ), + ); + + const validResults = results.filter((r) => r !== null); + + Logger.log(`完成 ${validResults.length}/${tasks.length} 个任务`); + + // 完成进度追踪 + progressTracker.finish(); + + if (validResults.length === 0) { + Logger.warn("所有任务都失败了,跳过注入"); + return null; + } + + const memory = mergeResults(validResults, latestContext); + + // 检查是否启用了汇总检查功能 + if (globalSettings.showSummaryCheck && memory) { + const checkResult = await showSummaryCheckModal(memory); + + if (checkResult.action === "cancel") { + Logger.log("用户取消了发送"); + // 隐藏进度面板 + if (messageProgressPanel) { + messageProgressPanel.hide(); + } + return { cancelled: true }; + } else if (checkResult.action === "regenerate") { + Logger.log("用户选择重新生成,重新处理..."); + // 递归调用重新处理 + return await processMemoryForMessage(userMessage); + } + // action === "confirm" 则继续 + } + + const duration = Date.now() - startTime; + Logger.log( + `处理完成,总耗时: ${duration}ms, 成功: ${validResults.length}/${tasks.length}`, + ); + + return memory; + } catch (error) { + if (error.name === "AbortError") { + Logger.warn("处理被用户终止"); + } else { + Logger.error("处理消息时发生错误:", error); + } + if (progressTracker) { + progressTracker.finish(); + } + return null; + } finally { + setMenuButtonProcessing(false); + setFloatBallProcessing(false); + abortController = null; + } + } + + // 标记 Hook 是否已安装,防止重复安装 + let hookInstalled = false; + + /** + * Hook 发送按钮 - 拦截发送事件 + * 使用原生事件监听器,捕获阶段触发,确保优先处理 + */ + function hookSendButton() { + // 强制输出调试信息(不受 showLogs 控制) + console.log("[记忆管理] hookSendButton 被调用"); + + // 防止重复安装 + if (hookInstalled) { + console.log("[记忆管理] Hook 已安装,跳过重复安装"); + return; + } + + // SillyTavern 的发送按钮 ID 是 send_but + const sendButton = document.getElementById("send_but"); + const sendTextarea = document.getElementById("send_textarea"); + + console.log("[记忆管理] 查找元素: send_but=", sendButton, "send_textarea=", sendTextarea); + + if (!sendButton || !sendTextarea) { + console.warn("[记忆管理] 元素未就绪,2秒后重试..."); + setTimeout(hookSendButton, 2000); + return; + } + + const btn = sendButton; + const textarea = sendTextarea; + + // 创建一个新的点击处理函数 + async function handleSendWithMemory(event) { + console.log("[记忆管理] handleSendWithMemory 触发, skipNextHook=", skipNextHook, "isPluginEnabled=", isPluginEnabled()); + + // 如果设置了跳过标志,直接放行 + if (skipNextHook) { + skipNextHook = false; + return; // 不阻止,让事件继续传播 + } + + // 如果插件禁用,直接返回让原始处理继续 + if (!isPluginEnabled()) { + console.log("[记忆管理] 插件已禁用,跳过拦截"); + return; + } + + // 如果正在处理中,阻止重复发送 + if (isProcessing) { + event.preventDefault(); + event.stopPropagation(); + event.stopImmediatePropagation(); + Logger.warn("正在处理中,请稍候..."); + return; + } + + // 获取用户输入 + const userMessage = textarea.value.trim(); + + // 如果没有输入内容,让原始处理继续(可能是其他操作) + if (!userMessage) { + return; + } + + // 检查是否有需要处理的世界书 + const importedBooks = getImportedBookNames(); + if (importedBooks.length === 0) { + return; + } + + // 阻止原始发送事件 + event.preventDefault(); + event.stopPropagation(); + event.stopImmediatePropagation(); + + Logger.log("拦截发送事件,开始处理记忆..."); + isProcessing = true; + + try { + // 处理记忆 + const result = await processMemoryForMessage(userMessage); + + // 检查用户是否取消了发送前检查 + if (result && result.cancelled) { + Logger.log("用户取消了发送,不发送消息"); + isProcessing = false; + return; + } + + // 解析返回结果(可能是字符串或对象) + let memory = null; + let editorContent = null; + if (result) { + if (typeof result === "string") { + memory = result; + } else if (typeof result === "object" && result.memory) { + memory = result.memory; + editorContent = result.editorContent || null; + } + } + + // 构建最终消息 + let finalMessage = userMessage; + if (memory) { + // 构建 Editor 部分(如果有剧情优化内容) + let editorSection = ""; + if (editorContent) { + editorSection = `\n\n${editorContent}\n`; + Logger.log("[剧情优化] 已添加 Editor 标签内容"); + } + + // 将记忆包装并添加到用户消息后面 + const wrappedMemory = ` +
              +【过去记忆碎片】 +

              以上是用户的最新输入,请勿忽略。

              + +${memory} +${editorSection} +
              +
              `; + finalMessage = userMessage + "\n\n" + wrappedMemory; + Logger.log( + "记忆已合并到用户消息,长度:", + finalMessage.length, + ); + } + + // 更新输入框内容为合并后的消息 + textarea.value = finalMessage; + + // 触发 input 事件以确保 SillyTavern 检测到变化 + textarea.dispatchEvent(new Event("input", { bubbles: true })); + + // 设置跳过标志 + skipNextHook = true; + isProcessing = false; + + // 方法1: 尝试直接调用 SillyTavern 的 Generate 函数 + let sent = false; + if ( + typeof SillyTavern !== "undefined" && + SillyTavern.getContext + ) { + try { + const context = SillyTavern.getContext(); + // SillyTavern 的 Generate 函数会读取 textarea 的值 + if (typeof context.Generate === "function") { + context.Generate("normal"); + sent = true; + } + } catch (e) { + Logger.warn("Generate 调用失败:", e); + } + } + + // 方法2: 使用 jQuery 触发(备用) + if (!sent) { + if (typeof jQuery !== "undefined") { + jQuery("#send_but").trigger("click"); + } else if (typeof $ !== "undefined") { + $("#send_but").trigger("click"); + } else { + // 方法3: dispatchEvent + const clickEvent = new MouseEvent("click", { + bubbles: true, + cancelable: true, + view: window, + }); + btn.dispatchEvent(clickEvent); + } + } + } catch (error) { + Logger.error("处理发送时出错:", error); + isProcessing = false; + skipNextHook = false; + alert("记忆处理失败: " + error.message); + } + } + + // 使用原生方式添加事件监听器,捕获阶段触发,确保优先处理 + btn.addEventListener("click", handleSendWithMemory, true); + + // 添加冒泡阶段监听器作为调试 + btn.addEventListener("click", function(e) { + console.log("[记忆管理] 冒泡阶段点击事件触发"); + }, false); + + // 标记 Hook 已安装 + hookInstalled = true; + console.log("[记忆管理] 发送按钮 Hook 已安装成功!按钮:", sendButton.id); + Logger.log("发送按钮 Hook 已安装(原生模式)- 按钮:", sendButton.id); + } + + /** + * 拦截器函数 - 保留用于兼容性(但实际工作由 hookSendButton 完成) + */ + globalThis.MemoryManagerConcurrent_intercept = async function ( + chat, + contextSize, + abort, + type, + ) { + // 由于使用了发送按钮 Hook,这个拦截器现在只做兼容性保留 + // 不做任何处理,让生成继续 + }; + + // ============================================================================ + // 初始化 + // ============================================================================ + + async function initUI() { + // v0.2.4: 使用扩展菜单按钮,可选悬浮球 + await loadPanelTemplate(); + await loadSettingsTemplate(); + await loadSearchDialogTemplate(); + await loadPlotOptimizePanelTemplate(); + + // 在扩展菜单中添加按钮 + createExtensionMenuButton(); + + bindEvents(); + await refreshWorldBookList(); + loadGlobalSettingsUI(); + initTheme(); + updateMenuButtonStatus(); + + // 根据设置显示悬浮球 + updateFloatBallVisibility(); + + // 初始化消息进度面板 + if (messageProgressPanel) { + messageProgressPanel.init(); + } + + // 初始化交互式搜索面板 + const searchPanel = getInteractiveSearchPanel(); + searchPanel.init(); + + // 初始化剧情优化面板事件 + bindPlotOptimizePanelEvents(); + + // 加载世界书递归设置配置 + loadRecursionSettings(); + + Logger.log("UI 初始化完成"); + } + + async function initPlugin() { + Logger.log("记忆管理并发系统 v0.3.0 初始化..."); + + // 异步从服务器加载配置(支持多端同步) + await loadConfigAsync(); + getOrCreateConfig(); + + try { + await initUI(); + } catch (error) { + Logger.error("UI 初始化失败:", error); + } + + try { + await getPromptTemplate(); + Logger.log("提示词模板加载成功"); + } catch (error) { + Logger.error("提示词模板加载失败"); + } + + // 注册到 SillyTavern 事件系统 + registerEventListeners(); + + Logger.log("初始化完成"); + } + + function registerEventListeners() { + // 使用 SillyTavern 的 APP_READY 事件确保应用完全加载 + if (typeof SillyTavern !== "undefined" && SillyTavern.getContext) { + const context = SillyTavern.getContext(); + if (context.eventSource && context.event_types) { + // 监听 APP_READY 事件 + context.eventSource.on(context.event_types.APP_READY, () => { + Logger.log("APP_READY 事件触发,安装发送按钮 Hook..."); + hookSendButton(); + }); + + // 监听世界书更新事件 - 自动刷新条目列表 & 应用递归设置 + if (context.event_types.WORLDINFO_UPDATED) { + context.eventSource.on( + context.event_types.WORLDINFO_UPDATED, + async (bookName) => { + Logger.log("检测到世界书更新,自动刷新列表..."); + refreshWorldBookList(); + // 自动为新条目应用递归设置 + if (bookName) { + await applyRecursionSettingsToNewEntries( + bookName, + ); + } + }, + ); + Logger.log("已注册 WORLDINFO_UPDATED 事件监听"); + } + + // 监听世界书设置更新事件 + if (context.event_types.WORLDINFO_SETTINGS_UPDATED) { + context.eventSource.on( + context.event_types.WORLDINFO_SETTINGS_UPDATED, + () => { + Logger.log("检测到世界书设置更新,自动刷新列表..."); + refreshWorldBookList(); + }, + ); + Logger.log("已注册 WORLDINFO_SETTINGS_UPDATED 事件监听"); + } + + Logger.log("已注册事件监听"); + } + } + + // 备用方案:监听 DOM 变化来检测世界书编辑 + setupWorldBookMutationObserver(); + + Logger.log("发送按钮 Hook 模式已启用"); + Logger.log( + "拦截器函数已挂载到 globalThis.MemoryManagerConcurrent_intercept (仅用于兼容)", + ); + } + + /** + * 处理生成开始事件 - 在发送消息前处理记忆 + */ + async function handleGenerationStart(type, options, dryRun) { + console.log("[记忆管理] GENERATION_AFTER_COMMANDS 事件触发, type=", type, "dryRun=", dryRun); + + // 跳过 dry run 和非普通生成类型 + if (dryRun) { + console.log("[记忆管理] 跳过 dry run"); + return; + } + + // 只处理普通生成 + if (type !== "normal" && type !== "impersonate") { + console.log("[记忆管理] 跳过非普通生成类型:", type); + return; + } + + // 如果插件禁用,直接返回 + if (!isPluginEnabled()) { + console.log("[记忆管理] 插件已禁用,跳过处理"); + return; + } + + // 如果正在处理中,跳过 + if (isProcessing) { + console.log("[记忆管理] 正在处理中,跳过"); + return; + } + + // 检查是否有需要处理的世界书 + const importedBooks = getImportedBookNames(); + if (importedBooks.length === 0) { + console.log("[记忆管理] 没有导入的世界书,跳过处理"); + return; + } + + // 获取当前聊天和用户最后一条消息 + const chatContext = getCurrentChatContext(); + const lastUserMessage = chatContext.filter(m => m.is_user).pop(); + + if (!lastUserMessage) { + console.log("[记忆管理] 没有找到用户消息,跳过处理"); + return; + } + + const userMessage = lastUserMessage.mes || ""; + if (!userMessage.trim()) { + console.log("[记忆管理] 用户消息为空,跳过处理"); + return; + } + + // 检查是否已经处理过(避免重复处理) + if (userMessage.includes("") || userMessage.includes("")) { + console.log("[记忆管理] 消息已包含记忆标签,跳过处理"); + return; + } + + console.log("[记忆管理] 开始处理记忆,用户消息:", userMessage.substring(0, 50) + "..."); + isProcessing = true; + + try { + // 处理记忆 + const result = await processMemoryForMessage(userMessage); + + // 检查用户是否取消了发送前检查 + if (result && typeof result === "object" && result.cancelled) { + console.log("[记忆管理] 用户取消了发送"); + isProcessing = false; + // 通过抛出错误来中止生成 + throw new Error("用户取消了发送"); + } + + // 解析返回结果 + let memory = null; + let editorContent = null; + if (result) { + if (typeof result === "string") { + memory = result; + } else if (typeof result === "object" && result.memory) { + memory = result.memory; + editorContent = result.editorContent || null; + } + } + + // 如果有记忆内容,修改用户消息 + if (memory) { + // 构建 Editor 部分 + let editorSection = ""; + if (editorContent) { + editorSection = `\n\n${editorContent}\n`; + console.log("[记忆管理] 已添加 Editor 标签内容"); + } + + // 构建包装后的记忆 + const wrappedMemory = ` +
              +【过去记忆碎片】 +

              以上是用户的最新输入,请勿忽略。

              + +${memory} +${editorSection} +
              +
              `; + + // 修改 chat 数组中的用户消息 + const finalMessage = userMessage + "\n\n" + wrappedMemory; + lastUserMessage.mes = finalMessage; + + console.log("[记忆管理] 记忆已注入到用户消息,长度:", finalMessage.length); + } + + isProcessing = false; + } catch (error) { + console.error("[记忆管理] 处理记忆时出错:", error); + isProcessing = false; + throw error; // 重新抛出以中止生成 + } + } + + /** + * 备用方案:通过 MutationObserver 监听世界书编辑器的变化 + */ + let worldBookObserver = null; + let refreshDebounceTimer = null; + + function setupWorldBookMutationObserver() { + // 防抖刷新函数 + function debouncedRefresh() { + if (refreshDebounceTimer) { + clearTimeout(refreshDebounceTimer); + } + refreshDebounceTimer = setTimeout(() => { + Logger.log("检测到世界书 DOM 变化,自动刷新列表..."); + refreshWorldBookList(); + }, 1000); // 1秒防抖 + } + + // 监听世界书编辑器相关的 DOM 变化 + function observeWorldBookEditor() { + // 世界书编辑面板的容器 + const worldInfoPanel = document.getElementById("WorldInfo"); + const worldInfoEditor = document.querySelector(".world_entry"); + + if (worldInfoPanel) { + if (worldBookObserver) { + worldBookObserver.disconnect(); + } + + worldBookObserver = new MutationObserver((mutations) => { + for (const mutation of mutations) { + // 检测到子节点变化(添加/删除条目) + if ( + mutation.type === "childList" && + mutation.addedNodes.length > 0 + ) { + debouncedRefresh(); + break; + } + // 检测到属性变化(启用/禁用条目) + if (mutation.type === "attributes") { + debouncedRefresh(); + break; + } + } + }); + + worldBookObserver.observe(worldInfoPanel, { + childList: true, + subtree: true, + attributes: true, + attributeFilter: ["class", "data-uid"], + }); + + Logger.log("已设置世界书 DOM 变化监听器"); + } else { + // 面板还未加载,稍后重试 + setTimeout(observeWorldBookEditor, 2000); + } + } + + // 延迟启动观察器 + setTimeout(observeWorldBookEditor, 3000); + } + + // ============================================================================ + // 剧情优化助手面板功能(新版) + // ============================================================================ + + // 剧情优化面板状态 + let plotPanelSelectedBooks = new Set(); + let plotPanelSelectedEntries = {}; // {bookName: [uid1, uid2, ...]} + let plotPanelCurrentPreview = ""; // 当前预览的内容 + let plotPanelIsGenerating = false; // 是否正在生成 + let plotPanelCurrentResolve = null; // Promise resolve + let plotPanelCurrentReject = null; // Promise reject + let plotPanelOtherTasksCompleted = false; // 其他任务是否已完成 + let plotPanelChatHistory = []; // 对话历史记录 + let plotPanelWorldBooksCache = []; // 世界书列表缓存 + let plotPanelEntriesCache = {}; // 世界书条目缓存 {bookName: entries[]} + let plotPanelOriginalUserMessage = ""; // 酒馆原始用户消息 + + /** + * 启动剧情优化会话(返回 Promise 等待用户确认) + * @param {Object} options - 选项 + * @returns {Promise} 返回用户选择结果 { action: "confirm"|"skip", content: string } + */ + function startPlotOptimizeSession(options = {}) { + return new Promise((resolve, reject) => { + plotPanelCurrentResolve = resolve; + plotPanelCurrentReject = reject; + plotPanelOtherTasksCompleted = false; + + // 保存酒馆原始用户消息 + plotPanelOriginalUserMessage = options.userMessage || ""; + + showPlotOptimizePanel(); + + // 如果有上下文信息,显示提示 + if (options.userMessage) { + updatePlotPanelStatus("正在为您优化剧情..."); + } + + // 自动开始生成 + generatePlotOptimize(""); + }); + } + + /** + * 更新其他任务状态(显示在面板中) + */ + function updatePlotPanelOtherTasksStatus(completed, total, results = null) { + const statusEl = document.getElementById("mm-plot-other-tasks-status"); + + if (!statusEl) { + // 动态创建状态元素 + const statusContainer = document.querySelector( + ".mm-plot-panel-status", + ); + if (statusContainer) { + const otherStatus = document.createElement("div"); + otherStatus.id = "mm-plot-other-tasks-status"; + otherStatus.className = "mm-plot-other-tasks"; + otherStatus.style.cssText = + "margin-top: 4px; font-size: 0.85em; color: var(--mm-text-muted);"; + statusContainer.appendChild(otherStatus); + } + } + + const el = document.getElementById("mm-plot-other-tasks-status"); + if (!el) return; + + if (completed < total) { + el.innerHTML = ` + + 其他任务: ${completed}/${total} + `; + } else { + el.innerHTML = ` + + 其他任务已完成 + `; + plotPanelOtherTasksCompleted = true; + + // 如果已有预览内容,更新状态提示 + if (plotPanelCurrentPreview && !plotPanelIsGenerating) { + updatePlotPanelStatus("其他任务已完成,等待您确认剧情优化..."); + } + } + } + + /** + * 显示剧情优化面板 + */ + function showPlotOptimizePanel() { + const panel = document.getElementById("mm-plot-optimize-panel"); + if (!panel) { + Logger.warn("[剧情优化] 面板元素不存在"); + return; + } + + // 重置面板位置,让CSS初始定位生效 + panel.style.left = ""; + panel.style.top = ""; + panel.style.right = ""; + panel.style.bottom = ""; + panel.style.transform = ""; + + panel.classList.add("mm-visible"); + + // 默认折叠世界书选择区域 + const worldbookSection = panel.querySelector( + ".mm-plot-worldbook-section", + ); + if ( + worldbookSection && + !worldbookSection.classList.contains("collapsed") + ) { + worldbookSection.classList.add("collapsed"); + } + + // 初始化面板状态 + resetPlotPanelPreview(); + loadPlotPanelWorldBooks(); + updatePlotPanelButtons(false); + + // 设置欢迎消息时间 + const welcomeTime = document.getElementById("mm-plot-welcome-time"); + if (welcomeTime) { + welcomeTime.textContent = formatPlotChatTime(); + } + + Logger.debug("[剧情优化] 面板已显示"); + } + + /** + * 隐藏剧情优化面板 + */ + function hidePlotOptimizePanel() { + const panel = document.getElementById("mm-plot-optimize-panel"); + if (panel) { + panel.classList.remove("mm-visible"); + } + + // 清除其他任务状态元素 + const otherTasksEl = document.getElementById( + "mm-plot-other-tasks-status", + ); + if (otherTasksEl) { + otherTasksEl.remove(); + } + + // 重置状态 + plotPanelOtherTasksCompleted = false; + } + + /** + * 检查剧情优化是否启用 + */ + function isPlotOptimizeEnabled() { + const settings = getGlobalSettings(); + return settings.enablePlotOptimize === true; + } + + /** + * 构建剧情优化的预览信息(用于发送前检查) + * 构建顺序与 DEFAULT_FLOW_CONFIG["剧情优化"] 保持一致: + * jailbreak → main → plot_worldbooks → plot_panel_worldbooks → plot_char_desc → plot_context → plot_historical → auxiliary → plot_user_msg + */ + async function buildPlotOptimizePreview( + plotConfig, + userMessage, + chatContext, + ) { + const previewParts = []; + const promptParts = []; // 新增:用于结构化显示 + + // 临时存储辅助提示词,等待后面按顺序添加 + let auxiliaryContent = null; + + // 0. 获取破限词 [jailbreak] + const jailbreakPrefix = getJailbreakPrefix(); + if (jailbreakPrefix && jailbreakPrefix.trim()) { + previewParts.push( + `【破限词】\n${jailbreakPrefix.substring(0, 300)}${ + jailbreakPrefix.length > 300 ? "..." : "" + }`, + ); + promptParts.push({ + label: "破限词", + content: jailbreakPrefix, + source: "jailbreak", + }); + } + + // 1. 获取主提示词 [main](辅助提示词延后添加) + let promptTemplate = null; + if (plotConfig.promptFile) { + try { + promptTemplate = await loadPromptTemplate( + plotConfig.promptFile, + ); + // 主提示词 + if (promptTemplate?.mainPrompt) { + const mainContent = promptTemplate.mainPrompt; + previewParts.push( + `【主提示词】\n${mainContent.substring(0, 500)}${ + mainContent.length > 500 ? "..." : "" + }`, + ); + promptParts.push({ + label: "主提示词", + content: mainContent, + source: "main", + }); + } + // 辅助提示词暂存,稍后添加 + if (promptTemplate?.systemPrompt) { + auxiliaryContent = promptTemplate.systemPrompt; + } + } catch (e) { + const errorMsg = `加载失败`; + previewParts.push(`【主提示词】${errorMsg}`); + promptParts.push({ + label: "主提示词", + content: errorMsg, + source: "main", + }); + } + } else { + const defaultMsg = `使用默认提示词`; + previewParts.push(`【主提示词】${defaultMsg}`); + promptParts.push({ + label: "主提示词", + content: defaultMsg, + source: "main", + }); + } + + // 2. 获取选中的世界书内容 [plot_worldbooks] + const selectedBooks = plotConfig.selectedBooks || []; + if (selectedBooks.length > 0) { + const booksMsg = `已选 ${ + selectedBooks.length + } 本: ${selectedBooks.join(", ")}`; + previewParts.push(`【世界书内容】${booksMsg}`); + promptParts.push({ + label: "世界书内容", + content: booksMsg, + source: "plot_worldbooks", + }); + } else { + const noBooksMsg = `未选择`; + previewParts.push(`【世界书内容】${noBooksMsg}`); + promptParts.push({ + label: "世界书内容", + content: noBooksMsg, + source: "plot_worldbooks", + }); + } + + // 3. 获取剧情优化面板中选择的世界书内容 [plot_panel_worldbooks] + // 注意:这里使用plotPanelSelectedBooks和plotPanelSelectedEntries获取面板选择的世界书 + if (Array.from(plotPanelSelectedBooks).length > 0) { + const panelBooksMsg = `已选 ${ + Array.from(plotPanelSelectedBooks).length + } 本: ${Array.from(plotPanelSelectedBooks).join(", ")}`; + previewParts.push(`【面板世界书内容】${panelBooksMsg}`); + promptParts.push({ + label: "面板世界书内容", + content: panelBooksMsg, + source: "plot_panel_worldbooks", + }); + } else { + const noPanelBooksMsg = `未选择`; + previewParts.push(`【面板世界书内容】${noPanelBooksMsg}`); + promptParts.push({ + label: "面板世界书内容", + content: noPanelBooksMsg, + source: "plot_panel_worldbooks", + }); + } + + // 4. 获取角色描述 [plot_char_desc] + if (plotConfig.includeCharDescription !== false) { + try { + if ( + typeof SillyTavern !== "undefined" && + SillyTavern.getContext + ) { + const context = SillyTavern.getContext(); + const char = context.characters?.[context.characterId]; + if (char && char.description) { + const descPreview = char.description.substring(0, 300); + previewParts.push( + `【角色描述】${ + char.name || "当前角色" + }\n${descPreview}${ + char.description.length > 300 ? "..." : "" + }`, + ); + promptParts.push({ + label: `角色描述 (${char.name || "当前角色"})`, + content: char.description, + source: "plot_char_desc", + }); + } else { + const noCharMsg = `无角色描述`; + previewParts.push(`【角色描述】${noCharMsg}`); + promptParts.push({ + label: "角色描述", + content: noCharMsg, + source: "plot_char_desc", + }); + } + } + } catch (e) { + const errorMsg = `获取失败`; + previewParts.push(`【角色描述】${errorMsg}`); + promptParts.push({ + label: "角色描述", + content: errorMsg, + source: "plot_char_desc", + }); + } + } else { + const disabledMsg = `已禁用`; + previewParts.push(`【角色描述】${disabledMsg}`); + promptParts.push({ + label: "角色描述", + content: disabledMsg, + source: "plot_char_desc", + }); + } + + // 4. 获取前文内容 [plot_context] + const contextRounds = plotConfig.contextRounds ?? 5; + if (contextRounds > 0 && chatContext && chatContext.length > 0) { + // 获取标签过滤配置 + const globalConfig = getGlobalConfig(); + const tagFilterConfig = globalConfig.contextTagFilter || { + enableExtract: false, + enableExclude: false, + excludeTags: ["Plot_progression"], + extractTags: [], + caseSensitive: false, + }; + + const recentMessages = chatContext.slice(-contextRounds * 2); + const contextPreview = recentMessages + .map((m) => { + const isUser = m.is_user; + const role = isUser ? "user" : "assistant"; + let content = m.mes || ""; + + // 用户消息:只应用排除过滤,不应用提取过滤 + // AI消息:应用完整的标签过滤(提取+排除) + if (isUser) { + if ( + tagFilterConfig.enableExclude && + tagFilterConfig.excludeTags?.length > 0 + ) { + const excludeOnlyConfig = { + ...tagFilterConfig, + enableExtract: false, + }; + content = filterContentByTags( + content, + excludeOnlyConfig, + ); + } else { + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } else { + if ( + tagFilterConfig.enableExtract || + tagFilterConfig.enableExclude + ) { + content = filterContentByTags( + content, + tagFilterConfig, + ); + } else { + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } + + const preview = content.substring(0, 100); + return `${role}: ${preview}${ + content.length > 100 ? "..." : "" + }`; + }) + .join("\n"); + const fullContext = recentMessages + .map((m) => { + const isUser = m.is_user; + const role = isUser ? "user" : "assistant"; + let content = m.mes || ""; + + // 用户消息:只应用排除过滤,不应用提取过滤 + // AI消息:应用完整的标签过滤(提取+排除) + if (isUser) { + if ( + tagFilterConfig.enableExclude && + tagFilterConfig.excludeTags?.length > 0 + ) { + const excludeOnlyConfig = { + ...tagFilterConfig, + enableExtract: false, + }; + content = filterContentByTags( + content, + excludeOnlyConfig, + ); + } else { + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } else { + if ( + tagFilterConfig.enableExtract || + tagFilterConfig.enableExclude + ) { + content = filterContentByTags( + content, + tagFilterConfig, + ); + } else { + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } + + return `${role}: ${content}`; + }) + .join("\n\n"); + previewParts.push( + `【前文内容 ${contextRounds} 轮】\n${contextPreview}`, + ); + promptParts.push({ + label: `前文内容 (${contextRounds} 轮)`, + content: fullContext, + source: "plot_context", + }); + } else { + const noContextMsg = `不读取前文`; + previewParts.push(`【前文内容】${noContextMsg}`); + promptParts.push({ + label: "前文内容", + content: noContextMsg, + source: "plot_context", + }); + } + + // 5. 获取已采纳的历史事件回忆 [plot_historical] + const searchPanel = getInteractiveSearchPanel(); + const adoptedHistorical = searchPanel + ? searchPanel.getAdoptedHistoricalMemories() + : ""; + if (adoptedHistorical) { + previewParts.push(`【历史事件回忆】\n${adoptedHistorical}`); + promptParts.push({ + label: "历史事件回忆", + content: adoptedHistorical, + source: "plot_historical", + }); + } else { + const noHistoricalMsg = `无已采纳的历史事件回忆`; + previewParts.push(`【历史事件回忆】${noHistoricalMsg}`); + promptParts.push({ + label: "历史事件回忆", + content: noHistoricalMsg, + source: "plot_historical", + }); + } + + // 6. 辅助提示词 [auxiliary](在历史事件回忆之后、用户消息之前) + if (auxiliaryContent) { + previewParts.push( + `【辅助提示词】\n${auxiliaryContent.substring(0, 500)}${ + auxiliaryContent.length > 500 ? "..." : "" + }`, + ); + promptParts.push({ + label: "辅助提示词", + content: auxiliaryContent, + source: "auxiliary", + }); + } + + // 7. 核心用户消息(酒馆原始用户消息) [plot_user_msg] + if (userMessage) { + const wrappedUserMessage = `<核心用户消息>\n${userMessage}\n`; + previewParts.push(`【核心用户消息】\n${wrappedUserMessage}`); + promptParts.push({ + label: "核心用户消息", + content: wrappedUserMessage, + source: "plot_user_msg", + }); + } + + // 8. 历史对话记录(剧情优化面板的对话历史) [plot_history] + if (plotPanelChatHistory && plotPanelChatHistory.length > 0) { + const historyContent = plotPanelChatHistory + .map((msg) => { + const role = msg.role === "user" ? "用户" : "AI"; + return `${role}: ${msg.content}`; + }) + .join("\n\n"); + previewParts.push(`【历史对话记录】\n${historyContent}`); + promptParts.push({ + label: "历史对话记录", + content: historyContent, + source: "plot_history", + }); + } else { + const noHistoryMsg = `无历史对话记录`; + previewParts.push(`【历史对话记录】${noHistoryMsg}`); + promptParts.push({ + label: "历史对话记录", + content: noHistoryMsg, + source: "plot_history", + }); + } + + // 9. 面板输入内容(用户在剧情优化面板的输入) [plot_input] + const plotInput = document.getElementById("mm-plot-input")?.value || ""; + if (plotInput && plotInput.trim()) { + previewParts.push(`【面板输入】\n${plotInput}`); + promptParts.push({ + label: "面板输入", + content: plotInput, + source: "plot_input", + }); + } else { + const noInputMsg = `无面板输入`; + previewParts.push(`【面板输入】${noInputMsg}`); + promptParts.push({ + label: "面板输入", + content: noInputMsg, + source: "plot_input", + }); + } + + return { + category: "剧情优化", + source: "剧情优化助手", + model: plotConfig.model || "未指定模型", + promptParts: promptParts, // 添加结构化部分 + prompt: previewParts.join("\n\n"), // 保留完整prompt用于兼容 + // 保存完整的API配置,供编辑后调用使用 + aiConfig: { + apiFormat: plotConfig.apiFormat || "openai", + apiUrl: plotConfig.apiUrl, + apiKey: plotConfig.apiKey, + model: plotConfig.model, + maxTokens: plotConfig.maxTokens || 2000, + temperature: plotConfig.temperature || 0.7, + responsePath: + plotConfig.responsePath || "choices.0.message.content", + }, + taskType: "plot_optimize", + }; + } + + /** + * 最小化/恢复面板 + */ + function togglePlotPanelMinimize() { + Logger.log("[剧情优化] togglePlotPanelMinimize 被调用"); + const panel = document.getElementById("mm-plot-optimize-panel"); + Logger.log("[剧情优化] 面板元素:", !!panel); + if (panel) { + const wasMinimized = panel.classList.contains("mm-minimized"); + panel.classList.toggle("mm-minimized"); + const isMinimized = panel.classList.contains("mm-minimized"); + Logger.log( + "[剧情优化] 最小化状态: 之前=", + wasMinimized, + ", 现在=", + isMinimized, + ); + } else { + Logger.warn("[剧情优化] 面板元素不存在,无法切换最小化状态"); + } + } + + /** + * 格式化时间戳 + */ + function formatPlotChatTime(date = new Date()) { + const hours = date.getHours().toString().padStart(2, "0"); + const minutes = date.getMinutes().toString().padStart(2, "0"); + return `${hours}:${minutes}`; + } + + /** + * 添加聊天消息到面板 + * @param {string} content - 消息内容 + * @param {string} type - 消息类型: 'user' | 'ai' | 'system' | 'typing' + * @param {object} options - 额外选项 + */ + function addPlotChatMessage(content, type = "ai", options = {}) { + const container = document.getElementById("mm-plot-chat-container"); + if (!container) return null; + + const messageDiv = document.createElement("div"); + messageDiv.className = `mm-plot-message mm-plot-message-${type}`; + if (options.className) { + messageDiv.className += ` ${options.className}`; + } + if (options.id) { + messageDiv.id = options.id; + } + + // 头像 + const avatarDiv = document.createElement("div"); + avatarDiv.className = "mm-plot-avatar"; + if (type === "user") { + avatarDiv.innerHTML = ``; + } else if (type === "ai" || type === "typing") { + avatarDiv.innerHTML = ``; + } + + // 气泡 + const bubbleDiv = document.createElement("div"); + bubbleDiv.className = "mm-plot-bubble"; + + // 内容 + const contentDiv = document.createElement("div"); + contentDiv.className = "mm-plot-bubble-content"; + if (options.streaming) { + contentDiv.classList.add("streaming"); + } + + if (type === "typing") { + contentDiv.innerHTML = ` + + + + `; + } else { + contentDiv.textContent = content; + } + + // 时间戳 + const timeDiv = document.createElement("div"); + timeDiv.className = "mm-plot-bubble-time"; + timeDiv.textContent = formatPlotChatTime(); + + bubbleDiv.appendChild(contentDiv); + if (type !== "typing") { + bubbleDiv.appendChild(timeDiv); + } + + if (type !== "system") { + messageDiv.appendChild(avatarDiv); + } + messageDiv.appendChild(bubbleDiv); + + container.appendChild(messageDiv); + + // 滚动到底部 + container.scrollTop = container.scrollHeight; + + return { messageDiv, contentDiv, timeDiv }; + } + + /** + * 移除正在输入的消息 + */ + function removePlotTypingMessage() { + const typing = document.querySelector(".mm-plot-message-typing"); + if (typing) { + typing.remove(); + } + } + + /** + * 重置聊天容器 + */ + function resetPlotPanelPreview() { + const container = document.getElementById("mm-plot-chat-container"); + if (container) { + container.innerHTML = ` +
              +
              + +
              +
              +
              你好!我是剧情优化助手,可以为您提供优化和调整角色扮演的方案。 + +请先选择要参考的世界书,然后输入你的需求,我会为你生成优化建议。
              +
              ${formatPlotChatTime()}
              +
              +
              + `; + } + plotPanelCurrentPreview = ""; + plotPanelChatHistory = []; // 重置对话历史 + updatePlotPanelStatus("等待生成..."); + } + + /** + * 更新面板状态文本 + */ + function updatePlotPanelStatus(text) { + const statusEl = document.getElementById("mm-plot-status-text"); + if (statusEl) { + statusEl.textContent = text; + } + } + + /** + * 更新操作按钮状态 + */ + function updatePlotPanelButtons(hasPreview) { + const acceptBtn = document.getElementById("mm-plot-accept-btn"); + const rejectBtn = document.getElementById("mm-plot-reject-btn"); + const regenerateBtn = document.getElementById("mm-plot-regenerate-btn"); + + if (acceptBtn) acceptBtn.disabled = !hasPreview; + if (rejectBtn) rejectBtn.disabled = !hasPreview; + if (regenerateBtn) regenerateBtn.disabled = !hasPreview; + } + + /** + * 加载面板中的世界书列表 + * @param {boolean} forceRefresh - 是否强制刷新缓存 + */ + async function loadPlotPanelWorldBooks(forceRefresh = false) { + const container = document.getElementById("mm-plot-worldbook-list"); + const loadingEl = document.getElementById("mm-plot-worldbook-loading"); + const emptyEl = document.getElementById("mm-plot-worldbook-empty"); + const noResultsEl = document.getElementById( + "mm-plot-worldbook-no-results", + ); + + if (!container) { + return; + } + + // 从配置加载已选中的世界书 + const settings = getGlobalSettings(); + const plotConfig = settings.plotOptimizeConfig || {}; + plotPanelSelectedBooks = new Set(plotConfig.selectedBooks || []); + plotPanelSelectedEntries = { ...(plotConfig.selectedEntries || {}) }; + + if (loadingEl) loadingEl.style.display = "flex"; + if (emptyEl) emptyEl.style.display = "none"; + if (noResultsEl) noResultsEl.style.display = "none"; + container.innerHTML = ""; + + try { + // 使用缓存或重新获取 + if (forceRefresh || plotPanelWorldBooksCache.length === 0) { + plotPanelWorldBooksCache = await getWorldBookList(); + plotPanelEntriesCache = {}; // 清空条目缓存 + } + const worldBooks = plotPanelWorldBooksCache; + + if (loadingEl) loadingEl.style.display = "none"; + + if (worldBooks.length === 0) { + if (emptyEl) emptyEl.style.display = "flex"; + updatePlotPanelWorldbookBadge(); + return; + } + + // 渲染世界书列表 + renderPlotPanelWorldBooks(worldBooks); + updatePlotPanelWorldbookBadge(); + + // 绑定搜索框事件 + bindPlotPanelSearchEvents(); + } catch (error) { + Logger.error("加载世界书列表失败:", error); + if (loadingEl) loadingEl.style.display = "none"; + container.innerHTML = + '
              加载失败
              '; + } + } + + /** + * 渲染世界书列表 + * @param {Array} worldBooks - 世界书列表 + * @param {string} searchTerm - 搜索关键词(可选) + */ + function renderPlotPanelWorldBooks(worldBooks, searchTerm = "") { + const container = document.getElementById("mm-plot-worldbook-list"); + const noResultsEl = document.getElementById( + "mm-plot-worldbook-no-results", + ); + const emptyEl = document.getElementById("mm-plot-worldbook-empty"); + + if (!container) return; + container.innerHTML = ""; + + const searchLower = searchTerm.toLowerCase().trim(); + let hasVisibleBooks = false; + + for (const book of worldBooks) { + // 检查世界书名是否匹配搜索词 + const bookNameLower = book.name.toLowerCase(); + const bookMatches = + !searchLower || bookNameLower.includes(searchLower); + + // 检查条目是否匹配搜索词(如果有缓存) + const cachedEntries = plotPanelEntriesCache[book.name] || []; + let matchingEntries = []; + if (searchLower && cachedEntries.length > 0) { + matchingEntries = cachedEntries.filter((entry) => { + const displayName = entry.comment || entry.key?.[0] || ""; + return displayName.toLowerCase().includes(searchLower); + }); + } + + // 如果世界书名不匹配且没有匹配的条目,跳过 + if (searchLower && !bookMatches && matchingEntries.length === 0) { + continue; + } + + hasVisibleBooks = true; + + const bookItem = document.createElement("div"); + bookItem.className = "mm-plot-book-item"; + bookItem.dataset.bookName = book.name; + + const isSelected = plotPanelSelectedBooks.has(book.name); + if (isSelected) bookItem.classList.add("selected"); + + // 高亮显示匹配的文本 + const displayBookName = + searchLower && bookMatches + ? highlightSearchText(book.name, searchTerm) + : book.name; + + // 条目数量显示(-1 表示未加载) + const entryCountText = + book.entryCount >= 0 ? `${book.entryCount} 条目` : ""; + + bookItem.innerHTML = ` +
              + + ${displayBookName} + ${entryCountText} + +
              +
              + `; + + const checkbox = bookItem.querySelector(".mm-plot-book-checkbox"); + const expandIcon = bookItem.querySelector(".mm-plot-book-expand"); + const bookHeader = bookItem.querySelector(".mm-plot-book-header"); + const entriesContainer = bookItem.querySelector( + ".mm-plot-book-entries", + ); + + // 勾选世界书 + checkbox.addEventListener("change", (e) => { + e.stopPropagation(); + if (e.target.checked) { + plotPanelSelectedBooks.add(book.name); + bookItem.classList.add("selected"); + } else { + plotPanelSelectedBooks.delete(book.name); + delete plotPanelSelectedEntries[book.name]; + bookItem.classList.remove("selected"); + } + updatePlotPanelWorldbookBadge(); + }); + + // 点击书名也可以展开/收起 + bookHeader.addEventListener("click", async (e) => { + if (e.target.tagName === "INPUT") return; // 忽略复选框点击 + e.stopPropagation(); + const isExpanded = bookItem.classList.contains("expanded"); + + if (!isExpanded) { + bookItem.classList.add("expanded"); + await loadPlotPanelBookEntries( + book.name, + entriesContainer, + searchTerm, + ); + } else { + bookItem.classList.remove("expanded"); + } + }); + + // 点击展开图标 + expandIcon.addEventListener("click", async (e) => { + e.stopPropagation(); + const isExpanded = bookItem.classList.contains("expanded"); + + if (!isExpanded) { + bookItem.classList.add("expanded"); + await loadPlotPanelBookEntries( + book.name, + entriesContainer, + searchTerm, + ); + } else { + bookItem.classList.remove("expanded"); + } + }); + + container.appendChild(bookItem); + + // 如果搜索时有匹配的条目,自动展开 + if (searchLower && matchingEntries.length > 0 && !bookMatches) { + bookItem.classList.add("expanded"); + loadPlotPanelBookEntries( + book.name, + entriesContainer, + searchTerm, + ); + } + } + + // 显示无结果提示 + if (noResultsEl) { + noResultsEl.style.display = + !hasVisibleBooks && searchLower ? "flex" : "none"; + } + if (emptyEl) { + emptyEl.style.display = + !hasVisibleBooks && !searchLower ? "flex" : "none"; + } + } + + /** + * 高亮搜索文本 + */ + function highlightSearchText(text, searchTerm) { + if (!searchTerm) return text; + const regex = new RegExp( + `(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, + "gi", + ); + return text.replace( + regex, + '$1', + ); + } + + /** + * 绑定搜索框事件 + */ + function bindPlotPanelSearchEvents() { + const searchInput = document.getElementById( + "mm-plot-worldbook-search-input", + ); + const clearBtn = document.getElementById( + "mm-plot-worldbook-search-clear", + ); + + if (!searchInput) return; + + // 防抖搜索 + let searchTimeout = null; + searchInput.addEventListener("input", (e) => { + const searchTerm = e.target.value; + + // 显示/隐藏清除按钮 + if (clearBtn) { + clearBtn.style.display = searchTerm ? "block" : "none"; + } + + // 防抖处理 + if (searchTimeout) clearTimeout(searchTimeout); + searchTimeout = setTimeout(() => { + renderPlotPanelWorldBooks(plotPanelWorldBooksCache, searchTerm); + }, 200); + }); + + // 清除按钮 + if (clearBtn) { + clearBtn.addEventListener("click", () => { + searchInput.value = ""; + clearBtn.style.display = "none"; + renderPlotPanelWorldBooks(plotPanelWorldBooksCache, ""); + searchInput.focus(); + }); + } + } + + /** + * 加载世界书条目 + * @param {string} bookName - 世界书名称 + * @param {HTMLElement} container - 容器元素 + * @param {string} searchTerm - 搜索关键词(可选) + */ + async function loadPlotPanelBookEntries( + bookName, + container, + searchTerm = "", + ) { + container.innerHTML = + '
              加载中...
              '; + + try { + // 使用缓存或重新获取 + let entries; + if (plotPanelEntriesCache[bookName]) { + entries = plotPanelEntriesCache[bookName]; + } else { + entries = await getWorldBookEntries(bookName); + plotPanelEntriesCache[bookName] = entries; + } + + container.innerHTML = ""; + + if (entries.length === 0) { + container.innerHTML = + '
              暂无条目
              '; + return; + } + + const selectedUids = plotPanelSelectedEntries[bookName] || []; + const searchLower = searchTerm.toLowerCase().trim(); + + // 过滤和排序条目(匹配的在前) + let filteredEntries = entries; + if (searchLower) { + filteredEntries = entries.filter((entry) => { + const displayName = entry.comment || entry.key?.[0] || ""; + return displayName.toLowerCase().includes(searchLower); + }); + + // 如果有搜索词但没有匹配的条目,显示所有条目 + if (filteredEntries.length === 0) { + filteredEntries = entries; + } + } + + for (const entry of filteredEntries) { + const entryItem = document.createElement("div"); + entryItem.className = "mm-plot-entry-item"; + + const uid = entry.uid?.toString() || ""; + const isSelected = selectedUids.includes(uid); + const rawDisplayName = + entry.comment || entry.key?.[0] || "未命名"; + + // 高亮搜索词 + const displayName = searchLower + ? highlightSearchText(rawDisplayName, searchTerm) + : rawDisplayName; + + entryItem.innerHTML = ` + + ${displayName} + `; + + const entryCheckbox = entryItem.querySelector( + ".mm-plot-entry-checkbox", + ); + entryCheckbox.addEventListener("change", (e) => { + e.stopPropagation(); + const entryUid = e.target.dataset.uid; + + if (!plotPanelSelectedEntries[bookName]) { + plotPanelSelectedEntries[bookName] = []; + } + + if (e.target.checked) { + if ( + !plotPanelSelectedEntries[bookName].includes( + entryUid, + ) + ) { + plotPanelSelectedEntries[bookName].push(entryUid); + } + } else { + plotPanelSelectedEntries[bookName] = + plotPanelSelectedEntries[bookName].filter( + (id) => id !== entryUid, + ); + } + }); + + container.appendChild(entryItem); + } + } catch (error) { + Logger.error(`加载世界书 ${bookName} 条目失败:`, error); + container.innerHTML = + '
              加载失败
              '; + } + } + + /** + * 更新世界书徽章 + */ + function updatePlotPanelWorldbookBadge() { + const badge = document.getElementById("mm-plot-worldbook-badge"); + const countEl = document.getElementById("mm-plot-books-count"); + + if (badge) badge.textContent = `已选 ${plotPanelSelectedBooks.size}`; + if (countEl) countEl.textContent = plotPanelSelectedBooks.size; + } + + /** + * 初始化剧情优化面板世界书区域的拖拽调整高度功能 + * 拖拽世界书区域底部手柄,同时调整世界书区域和整个面板的高度 + */ + function initPlotWorldbookResize() { + const resizeHandle = document.getElementById( + "mm-plot-worldbook-resize-handle", + ); + const plotPanel = document.getElementById("mm-plot-optimize-panel"); + const worldbookSection = document.getElementById( + "mm-plot-worldbook-section", + ); + + if (!resizeHandle || !plotPanel || !worldbookSection) { + Logger.warn("initPlotWorldbookResize: 未找到必要元素"); + return; + } + + let isResizing = false; + let startY = 0; + let startWorldbookHeight = 0; + let startPanelHeight = 0; + const minWorldbookHeight = 80; // 世界书区域最小高度 + const maxWorldbookHeight = 600; // 世界书区域最大高度 + + const onMouseDown = (e) => { + // 如果是折叠状态或最小化状态,不允许调整 + if (worldbookSection.classList.contains("collapsed")) return; + if (plotPanel.classList.contains("mm-minimized")) return; + + isResizing = true; + startY = e.clientY || e.touches?.[0]?.clientY || 0; + startWorldbookHeight = worldbookSection.offsetHeight; + startPanelHeight = plotPanel.offsetHeight; + + resizeHandle.classList.add("resizing"); + worldbookSection.classList.add("resizing"); + plotPanel.classList.add("resizing"); + document.body.style.cursor = "ns-resize"; + document.body.style.userSelect = "none"; + + e.preventDefault(); + e.stopPropagation(); + }; + + const onMouseMove = (e) => { + if (!isResizing) return; + + const clientY = e.clientY || e.touches?.[0]?.clientY || 0; + const deltaY = clientY - startY; + + // 计算新的世界书区域高度 + let newWorldbookHeight = startWorldbookHeight + deltaY; + newWorldbookHeight = Math.max( + minWorldbookHeight, + Math.min(maxWorldbookHeight, newWorldbookHeight), + ); + + // 计算实际变化量 + const actualDelta = newWorldbookHeight - startWorldbookHeight; + + // 计算新的面板高度 + let newPanelHeight = startPanelHeight + actualDelta; + const maxPanelHeight = window.innerHeight * 0.9; + const minPanelHeight = 300; + newPanelHeight = Math.max( + minPanelHeight, + Math.min(maxPanelHeight, newPanelHeight), + ); + + // 应用高度 + worldbookSection.style.height = `${newWorldbookHeight}px`; + worldbookSection.style.maxHeight = `${newWorldbookHeight}px`; + plotPanel.style.height = `${newPanelHeight}px`; + plotPanel.style.maxHeight = `${newPanelHeight}px`; + + e.preventDefault(); + }; + + const onMouseUp = () => { + if (!isResizing) return; + + isResizing = false; + resizeHandle.classList.remove("resizing"); + worldbookSection.classList.remove("resizing"); + plotPanel.classList.remove("resizing"); + document.body.style.cursor = ""; + document.body.style.userSelect = ""; + }; + + // 鼠标事件 + resizeHandle.addEventListener("mousedown", onMouseDown); + document.addEventListener("mousemove", onMouseMove); + document.addEventListener("mouseup", onMouseUp); + + // 触摸事件(移动端支持) + resizeHandle.addEventListener("touchstart", onMouseDown, { + passive: false, + }); + document.addEventListener("touchmove", onMouseMove, { passive: false }); + document.addEventListener("touchend", onMouseUp); + + Logger.debug( + "initPlotWorldbookResize: 世界书区域拖拽调整高度功能已初始化", + ); + } + + /** + * 初始化剧情优化面板聊天区域的拖拽调整高度功能 + */ + function initPlotChatResize() { + const resizeHandle = document.getElementById( + "mm-plot-chat-resize-handle", + ); + const plotPanel = document.getElementById("mm-plot-optimize-panel"); + const chatContainer = document.getElementById("mm-plot-chat-container"); + + if (!resizeHandle || !plotPanel || !chatContainer) { + Logger.warn("initPlotChatResize: 未找到必要元素"); + return; + } + + let isResizing = false; + let startY = 0; + let startChatHeight = 0; + const minChatHeight = 150; // 聊天区域最小高度 + const maxChatHeight = window.innerHeight * 0.7; // 聊天区域最大高度 + + const onMouseDown = (e) => { + // 如果是最小化状态,不允许调整 + if (plotPanel.classList.contains("mm-minimized")) return; + + isResizing = true; + startY = e.clientY || e.touches?.[0]?.clientY || 0; + startChatHeight = chatContainer.offsetHeight; + + resizeHandle.classList.add("resizing"); + chatContainer.classList.add("resizing"); + plotPanel.classList.add("resizing"); + document.body.style.cursor = "ns-resize"; + document.body.style.userSelect = "none"; + + e.preventDefault(); + e.stopPropagation(); + }; + + const onMouseMove = (e) => { + if (!isResizing) return; + + const clientY = e.clientY || e.touches?.[0]?.clientY || 0; + const deltaY = clientY - startY; + + // 计算新的聊天区域高度 + let newChatHeight = startChatHeight + deltaY; + newChatHeight = Math.max( + minChatHeight, + Math.min(maxChatHeight, newChatHeight), + ); + + // 应用高度 + chatContainer.style.height = `${newChatHeight}px`; + chatContainer.style.maxHeight = `${newChatHeight}px`; + chatContainer.style.minHeight = `${newChatHeight}px`; + + e.preventDefault(); + }; + + const onMouseUp = () => { + if (!isResizing) return; + + isResizing = false; + resizeHandle.classList.remove("resizing"); + chatContainer.classList.remove("resizing"); + plotPanel.classList.remove("resizing"); + document.body.style.cursor = ""; + document.body.style.userSelect = ""; + }; + + // 鼠标事件 + resizeHandle.addEventListener("mousedown", onMouseDown); + document.addEventListener("mousemove", onMouseMove); + document.addEventListener("mouseup", onMouseUp); + + // 触摸事件(移动端支持) + resizeHandle.addEventListener("touchstart", onMouseDown, { + passive: false, + }); + document.addEventListener("touchmove", onMouseMove, { passive: false }); + document.addEventListener("touchend", onMouseUp); + + Logger.debug("initPlotChatResize: 聊天区域拖拽调整高度功能已初始化"); + } + + /** + * 调用剧情优化 API + * @param {string} userInput - 用户输入的调整需求 + * @param {boolean} forceGenerate - 是否强制生成最终结果(跳过需求确认) + * @returns {Promise} - AI 生成的剧情优化建议 + */ + async function callPlotOptimizeApi(userInput = "", forceGenerate = false) { + const settings = getGlobalSettings(); + const plotConfig = settings.plotOptimizeConfig || {}; + + // 检查必要配置 + if (!plotConfig.apiUrl || !plotConfig.model) { + throw new Error("请先配置剧情优化的 API 设置"); + } + + // 加载剧情优化提示词模板 + let promptTemplate = null; + if (plotConfig.promptFile) { + try { + promptTemplate = await loadPromptTemplate( + plotConfig.promptFile, + ); + Logger.debug( + "[剧情优化] 加载提示词模板:", + plotConfig.promptFile, + ); + } catch (e) { + Logger.warn("[剧情优化] 加载提示词模板失败:", e); + } + } + + // 统一模式 - 不再区分对话模式和分析模式 + Logger.debug("[剧情优化] 使用统一模式"); + + // 获取上下文数据 + const chatContext = await getRecentChatContext(); + + // 获取面板选择的世界书条目内容(剧情优化助手面板中选择的) + let panelWorldbookContent = ""; + const panelSelectedBooks = Array.from(plotPanelSelectedBooks); + const panelSelectedEntries = plotPanelSelectedEntries; + + for (const bookName of panelSelectedBooks) { + try { + const entries = await getWorldBookEntries(bookName); + const entryUids = panelSelectedEntries[bookName] || []; + const targetEntries = + entryUids.length > 0 + ? entries.filter((e) => + entryUids.includes(e.uid?.toString()), + ) + : entries; + + for (const entry of targetEntries) { + const entryName = + entry.comment || entry.key?.[0] || "未命名"; + const content = entry.content || ""; + if (content.trim()) { + panelWorldbookContent += `【${entryName}】\n${content}\n\n`; + } + } + } catch (e) { + Logger.warn(`[剧情优化] 加载面板世界书 "${bookName}" 失败:`, e); + } + } + + // 获取全局配置的世界书内容 + let globalWorldbookContent = ""; + const globalSelectedBooks = plotConfig.selectedBooks || []; + for (const bookName of globalSelectedBooks) { + try { + const entries = await getWorldBookEntries(bookName); + // 全局配置的世界书使用所有启用的条目 + for (const entry of entries) { + if (entry.disable !== true) { + // 跳过禁用的条目 + const entryName = + entry.comment || entry.key?.[0] || "未命名"; + const content = entry.content || ""; + if (content.trim()) { + globalWorldbookContent += `【${entryName}】\n${content}\n\n`; + } + } + } + } catch (e) { + Logger.warn(`[剧情优化] 加载全局世界书 "${bookName}" 失败:`, e); + } + } + + // 获取角色描述(如果启用) + let characterDescription = ""; + if (plotConfig.includeCharDescription !== false) { + try { + if ( + typeof SillyTavern !== "undefined" && + SillyTavern.getContext + ) { + const context = SillyTavern.getContext(); + const char = context.characters?.[context.characterId]; + if (char) { + characterDescription = char.description || ""; + if (char.personality) { + characterDescription += `\n\n【性格特点】\n${char.personality}`; + } + if (char.scenario) { + characterDescription += `\n\n【场景设定】\n${char.scenario}`; + } + } + } + } catch (e) { + Logger.warn("[剧情优化] 获取角色描述失败:", e); + } + } + + // 获取历史事件回忆 + const searchPanel = getInteractiveSearchPanel(); + const adoptedHistorical = searchPanel + ? searchPanel.getAdoptedHistoricalMemories() + : ""; + + // 获取破限词(如果有) + const jailbreakPrefix = getJailbreakPrefix ? getJailbreakPrefix() : ""; + + // ========== 统一模式构建消息 ========== + // 使用流程配置构建 promptParts + let systemPrompt = ""; + let messages = []; + + const mainPrompt = promptTemplate?.mainPrompt || ""; + const auxiliaryPrompt = promptTemplate?.systemPrompt || ""; + + // 构建来源内容对象 + const sourceContents = { + jailbreak: jailbreakPrefix || "", + main: mainPrompt || "", + plot_worldbooks: globalWorldbookContent || "", // 全局配置的世界书 + plot_panel_worldbooks: panelWorldbookContent || "", // 面板选择的世界书内容 + plot_char_desc: characterDescription || "", + plot_context: chatContext || "", + plot_historical: adoptedHistorical || "", + auxiliary: auxiliaryPrompt || "", + plot_user_msg: plotPanelOriginalUserMessage || "", + plot_history: + plotPanelChatHistory + .map( + (msg) => + `${msg.role === "user" ? "用户" : "AI"}: ${ + msg.content + }`, + ) + .join("\n") || "", + plot_input: userInput || "", + }; + + // 使用流程配置构建 promptParts + const promptParts = await buildPromptPartsByFlowConfig( + "剧情优化", + sourceContents, + ); + + // 构建完整的用户消息 + let userMessageContent = ""; + for (const part of promptParts) { + if (part.content.trim()) { + userMessageContent += part.label + "\n" + part.content + "\n\n"; + } + } + + // 构建消息列表 + // 首先添加基础用户消息(包含所有上下文) + messages.push({ role: "user", content: userMessageContent }); + + // 6. 添加历史对话记录(如果有) + if (plotPanelChatHistory.length > 0) { + for (const msg of plotPanelChatHistory) { + messages.push(msg); + } + } + + // 7. 添加当前用户输入(如果有且不是第一条消息) + if (userInput) { + // 如果没有历史对话,将用户输入合并到第一条消息 + if (plotPanelChatHistory.length === 0) { + messages[0].content += `<最新用户消息>\n${userInput}`; + } else { + // 有历史对话时,作为新消息添加 + messages.push({ role: "user", content: userInput }); + } + } + + // 统一模式使用空的系统提示词,所有内容都在用户消息中 + systemPrompt = ""; + + // 调用 API + const apiConfig = { + apiFormat: plotConfig.apiFormat || "openai", + apiUrl: plotConfig.apiUrl, + apiKey: plotConfig.apiKey, + model: plotConfig.model, + maxTokens: plotConfig.maxTokens || 2000, + temperature: plotConfig.temperature || 0.7, + taskId: "plot_optimize", + source: "剧情优化", + }; + + const response = await APIAdapter.callWithMessages( + apiConfig, + systemPrompt, + messages, + "plot_optimize", + 2, + ); + + // 更新对话历史记录(用于多轮对话) + if (userInput) { + plotPanelChatHistory.push({ role: "user", content: userInput }); + } + plotPanelChatHistory.push({ role: "assistant", content: response }); + + return response; + } + + /** + * 生成剧情优化建议 + */ + async function generatePlotOptimize(userInput = "") { + if (plotPanelIsGenerating) { + return; + } + + plotPanelIsGenerating = true; + updatePlotPanelButtons(false); + updatePlotPanelStatus("正在生成..."); + + // 如果有用户输入,先显示用户消息 + if (userInput) { + addPlotChatMessage(userInput, "user"); + } + + // 显示正在输入动画 + addPlotChatMessage("", "typing", { + className: "mm-plot-message-typing", + }); + + // 添加到进度追踪 + if (progressTracker) { + progressTracker.addTask("plot_optimize", "剧情优化", "plot"); + } + + try { + const response = await callPlotOptimizeApi(userInput); + + // 移除正在输入动画,显示 AI 响应 + removePlotTypingMessage(); + addPlotChatMessage(response, "ai"); + + // 生成完成,启用按钮 + plotPanelCurrentPreview = response; + updatePlotPanelStatus("生成完成"); + updatePlotPanelButtons(true); + + if (progressTracker) { + progressTracker.completeTask("plot_optimize", true); + } + } catch (error) { + // 移除正在输入动画 + removePlotTypingMessage(); + + // 检查是否是用户取消 + if (error.message === "用户取消了请求") { + Logger.log("[剧情优化] 用户取消了请求"); + updatePlotPanelStatus("已取消"); + // 不显示错误消息,只是静默取消 + } else { + Logger.error("[剧情优化] 生成失败:", error); + addPlotChatMessage(`生成失败: ${error.message}`, "system"); + updatePlotPanelStatus("生成失败"); + + if (progressTracker) { + progressTracker.completeTask( + "plot_optimize", + false, + error.message, + ); + } + } + } finally { + plotPanelIsGenerating = false; + } + } + + /** + * 接受剧情优化建议 + */ + function acceptPlotOptimize() { + if (!plotPanelCurrentPreview) return; + + const content = plotPanelCurrentPreview; + + // 如果有 Promise resolve,说明是会话模式 + if (plotPanelCurrentResolve) { + Logger.log("[剧情优化] 用户接受优化建议(会话模式)"); + const resolve = plotPanelCurrentResolve; + plotPanelCurrentResolve = null; + plotPanelCurrentReject = null; + hidePlotOptimizePanel(); + resolve({ action: "confirm", content: content }); + return; + } + + // 非会话模式:将内容注入到酒馆输入框 + const textarea = document.getElementById("send_textarea"); + if (textarea) { + textarea.value = content; + textarea.focus(); + // 触发 input 事件让酒馆知道内容已更改 + textarea.dispatchEvent(new Event("input", { bubbles: true })); + } + + Logger.log("[剧情优化] 已接受优化建议"); + hidePlotOptimizePanel(); + } + + /** + * 拒绝剧情优化建议 + */ + function rejectPlotOptimize() { + Logger.log("[剧情优化] rejectPlotOptimize 被调用"); + // 如果有 Promise resolve,说明是会话模式 + if (plotPanelCurrentResolve) { + Logger.log("[剧情优化] 用户跳过优化(会话模式)"); + const resolve = plotPanelCurrentResolve; + plotPanelCurrentResolve = null; + plotPanelCurrentReject = null; + hidePlotOptimizePanel(); + resolve({ action: "skip", content: null }); + return; + } + + Logger.log("[剧情优化] 已拒绝优化建议"); + hidePlotOptimizePanel(); + } + + /** + * 重新生成 + */ + function regeneratePlotOptimize() { + const input = document.getElementById("mm-plot-user-input"); + const userInput = input ? input.value.trim() : ""; + generatePlotOptimize(userInput); + } + + /** + * 发送用户调整需求 + */ + function sendPlotUserInput() { + const input = document.getElementById("mm-plot-user-input"); + if (!input) { + return; + } + + const userInput = input.value.trim(); + + if (!userInput && !plotPanelCurrentPreview) { + // 没有输入也没有预览,执行初始生成 + generatePlotOptimize(""); + } else { + // 有输入,执行调整生成 + generatePlotOptimize(userInput); + } + + input.value = ""; + } + + /** + * 绑定剧情优化面板事件 + */ + function bindPlotOptimizePanelEvents() { + const panel = document.getElementById("mm-plot-optimize-panel"); + if (!panel) { + Logger.warn("[剧情优化] 面板元素不存在,跳过事件绑定"); + return; + } + + // 最小化按钮 + const minimizeBtn = document.getElementById("mm-plot-minimize"); + if (minimizeBtn) { + minimizeBtn.addEventListener("click", (e) => { + e.stopPropagation(); + togglePlotPanelMinimize(); + }); + } + + // 世界书折叠 + try { + const worldbookToggle = document.getElementById( + "mm-plot-worldbook-toggle", + ); + if (worldbookToggle) { + worldbookToggle.addEventListener("click", () => { + const panel = document.getElementById( + "mm-plot-optimize-panel", + ); + const section = document.getElementById( + "mm-plot-worldbook-section", + ); + if (!section || !panel) return; + + const isCollapsed = section.classList.contains("collapsed"); + const currentSectionHeight = section.offsetHeight; + const currentPanelHeight = panel.offsetHeight; + + if (isCollapsed) { + section.classList.remove("collapsed"); + section.style.height = ""; + section.style.maxHeight = ""; + panel.style.height = ""; + panel.style.maxHeight = ""; + } else { + const headerHeight = 40; + const heightDiff = currentSectionHeight - headerHeight; + section.classList.add("collapsed"); + const newPanelHeight = Math.max( + 300, + currentPanelHeight - heightDiff, + ); + panel.style.height = `${newPanelHeight}px`; + panel.style.maxHeight = `${newPanelHeight}px`; + } + }); + } + } catch (err) { + Logger.error("[剧情优化] 世界书折叠事件绑定出错:", err); + } + + // 世界书区域拖拽调整高度 + try { + initPlotWorldbookResize(); + } catch (err) { + Logger.error("[剧情优化] initPlotWorldbookResize 出错:", err); + } + + // 聊天区域拖拽调整高度 + try { + initPlotChatResize(); + } catch (err) { + Logger.error("[剧情优化] initPlotChatResize 出错:", err); + } + + // 世界书刷新 + document + .getElementById("mm-plot-worldbook-refresh") + ?.addEventListener("click", (e) => { + e.stopPropagation(); + const searchInput = document.getElementById( + "mm-plot-worldbook-search-input", + ); + if (searchInput) searchInput.value = ""; + const clearBtn = document.getElementById( + "mm-plot-worldbook-search-clear", + ); + if (clearBtn) clearBtn.style.display = "none"; + loadPlotPanelWorldBooks(true); + }); + + // 发送按钮 + const sendBtn = document.getElementById("mm-plot-send-btn"); + if (sendBtn) { + // 移除可能存在的旧事件 + const newSendBtn = sendBtn.cloneNode(true); + sendBtn.parentNode.replaceChild(newSendBtn, sendBtn); + + newSendBtn.addEventListener("click", (e) => { + e.stopPropagation(); + sendPlotUserInput(); + }); + } + + // 输入框回车 + document + .getElementById("mm-plot-user-input") + ?.addEventListener("keypress", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + sendPlotUserInput(); + } + }); + + // 接受按钮 + const acceptBtn = document.getElementById("mm-plot-accept-btn"); + if (acceptBtn) { + acceptBtn.addEventListener("click", () => { + acceptPlotOptimize(); + }); + } + + // 拒绝按钮 + const rejectBtn = document.getElementById("mm-plot-reject-btn"); + if (rejectBtn) { + rejectBtn.addEventListener("click", () => { + rejectPlotOptimize(); + }); + } + + // 重新生成按钮 + const regenerateBtn = document.getElementById("mm-plot-regenerate-btn"); + if (regenerateBtn) { + regenerateBtn.addEventListener("click", () => { + regeneratePlotOptimize(); + }); + } + + // 初始化拖动功能 + initPlotPanelDrag(); + + Logger.debug("[剧情优化] 面板事件已绑定"); + } + + // 剧情优化面板拖动状态 + let plotPanelIsDragging = false; + let plotPanelDragOffset = { x: 0, y: 0 }; + + /** + * 初始化剧情优化面板拖动功能 + */ + function initPlotPanelDrag() { + const panel = document.getElementById("mm-plot-optimize-panel"); + const header = panel?.querySelector(".mm-plot-panel-header"); + + if (!panel || !header) { + return; + } + + // 点击置顶 + panel.addEventListener("mousedown", () => bringPanelToFront(panel)); + panel.addEventListener("touchstart", () => bringPanelToFront(panel), { + passive: true, + }); + + // 开始拖动 + const startDrag = (clientX, clientY) => { + plotPanelIsDragging = true; + const rect = panel.getBoundingClientRect(); + plotPanelDragOffset.x = clientX - rect.left; + plotPanelDragOffset.y = clientY - rect.top; + panel.style.transform = "none"; + panel.style.left = `${rect.left}px`; + panel.style.top = `${rect.top}px`; + panel.style.right = "auto"; + panel.style.bottom = "auto"; + panel.style.transition = "none"; + panel.classList.add("mm-dragging"); + }; + + // 拖动中 + const drag = (clientX, clientY) => { + if (!plotPanelIsDragging) return; + const x = clientX - plotPanelDragOffset.x; + const y = clientY - plotPanelDragOffset.y; + + const maxX = window.innerWidth - panel.offsetWidth; + const maxY = window.innerHeight - panel.offsetHeight; + + panel.style.left = `${Math.max(0, Math.min(x, maxX))}px`; + panel.style.top = `${Math.max(0, Math.min(y, maxY))}px`; + panel.style.right = "auto"; + panel.style.bottom = "auto"; + }; + + // 停止拖动 + const stopDrag = () => { + if (plotPanelIsDragging) { + plotPanelIsDragging = false; + panel.classList.remove("mm-dragging"); + panel.style.transition = ""; + } + }; + + // 鼠标事件 + header.addEventListener("mousedown", (e) => { + if (e.target.closest("button")) { + return; + } + startDrag(e.clientX, e.clientY); + }); + + document.addEventListener("mousemove", (e) => { + if (plotPanelIsDragging) { + drag(e.clientX, e.clientY); + } + }); + + document.addEventListener("mouseup", () => { + stopDrag(); + }); + + // 触摸事件支持 + header.addEventListener( + "touchstart", + (e) => { + if (e.target.closest("button")) return; + e.preventDefault(); + const touch = e.touches[0]; + startDrag(touch.clientX, touch.clientY); + }, + { passive: false }, + ); + + document.addEventListener( + "touchmove", + (e) => { + if (plotPanelIsDragging) { + e.preventDefault(); + const touch = e.touches[0]; + drag(touch.clientX, touch.clientY); + } + }, + { passive: false }, + ); + + document.addEventListener("touchend", () => { + stopDrag(); + }); + + Logger.log("[剧情优化] 拖动功能已初始化完成"); + } + + // 兼容旧代码的函数别名 + function showPlotOptimizeModal() { + showPlotOptimizePanel(); + } + + function hidePlotOptimizeModal() { + hidePlotOptimizePanel(); + } + + // 旧版变量兼容(供其他代码引用) + let plotOptimizeSelectedBooks = plotPanelSelectedBooks; + let plotOptimizeSelectedEntries = plotPanelSelectedEntries; + + function updatePlotOptimizeBooksBadge() { + updatePlotPanelWorldbookBadge(); + } + + /** + * 从选中的世界书获取关键词 + */ + function extractKeywordsFromSelectedBooks() { + const keywords = []; + for (const [bookName, uids] of Object.entries( + plotPanelSelectedEntries, + )) { + for (const uid of uids) { + keywords.push(`${bookName}:${uid}`); + } + } + return keywords.join(", "); + } + + /** + * 从选中的世界书获取记忆内容 + */ + async function getMemoryContentFromSelectedBooks() { + const contents = []; + + for (const bookName of plotPanelSelectedBooks) { + try { + const entries = await getWorldBookEntries(bookName); + const selectedUids = plotPanelSelectedEntries[bookName] || []; + + // 如果选中了世界书但没有选择具体条目,则获取所有条目 + const targetEntries = + selectedUids.length > 0 + ? entries.filter((e) => + selectedUids.includes(e.uid?.toString()), + ) + : entries; + + if (targetEntries.length > 0) { + let bookContent = `【世界书: ${bookName}】\n`; + for (const entry of targetEntries) { + const name = + entry.comment || entry.key?.[0] || "未命名"; + bookContent += `[${name}]\n${entry.content || ""}\n\n`; + } + contents.push(bookContent); + } + } catch (error) { + Logger.warn(`获取世界书 "${bookName}" 内容失败:`, error); + } + } + + return contents.join("\n"); + } + + async function getRecentChatContext() { + try { + if (typeof SillyTavern !== "undefined" && SillyTavern.getContext) { + const { chat } = SillyTavern.getContext(); + if (chat && chat.length > 0) { + // 获取剧情优化配置中的上下文轮次 + const settings = getGlobalSettings(); + const plotConfig = settings.plotOptimizeConfig || {}; + const contextRounds = plotConfig.contextRounds ?? 5; + + // 每轮包含用户消息+助手回复,所以消息数 = 轮次 * 2 + const maxMessages = contextRounds * 2; + if (maxMessages <= 0) return ""; + + // 获取标签过滤配置 + const globalConfig = getGlobalConfig(); + const tagFilterConfig = globalConfig.contextTagFilter || { + enableExtract: false, + enableExclude: false, + excludeTags: ["Plot_progression"], + extractTags: [], + caseSensitive: false, + }; + + const recentMessages = chat.slice(-maxMessages); + let context = ""; + for (const msg of recentMessages) { + const isUser = msg.is_user || msg.role === "user"; + const name = msg.name || (isUser ? "用户" : "角色"); + let content = msg.mes || msg.content || ""; + + // 用户消息:只应用排除过滤,不应用提取过滤 + // AI消息:应用完整的标签过滤(提取+排除) + if (isUser) { + // 用户消息只应用排除过滤 + if ( + tagFilterConfig.enableExclude && + tagFilterConfig.excludeTags?.length > 0 + ) { + const excludeOnlyConfig = { + ...tagFilterConfig, + enableExtract: false, // 禁用提取 + }; + content = filterContentByTags( + content, + excludeOnlyConfig, + ); + } else { + // 默认行为:移除 Plot_progression 标签 + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } else { + // AI消息应用完整的标签过滤 + if ( + tagFilterConfig.enableExtract || + tagFilterConfig.enableExclude + ) { + content = filterContentByTags( + content, + tagFilterConfig, + ); + } else { + // 默认行为:移除 Plot_progression 标签 + content = content + .replace( + /[\s\S]*?<\/Plot_progression>/gi, + "", + ) + .trim(); + } + } + + if (content.trim()) { + context += `${name}: ${content}\n`; + } + } + return context; + } + } + } catch (error) { + Logger.warn("获取最近聊天上下文失败:", error); + } + return ""; + } + + function getCharacterDescription() { + try { + if (typeof SillyTavern !== "undefined" && SillyTavern.getContext) { + const { characters } = SillyTavern.getContext(); + if (characters && characters.length > 0) { + const char = characters[0]; + return `名称: ${char.name || "未知"}\n描述: ${ + char.description || "无" + }`; + } + } + } catch (error) { + Logger.warn("获取角色描述失败:", error); + } + return "角色信息不可用"; + } + + function getDefaultModel() { + const globalConfig = getGlobalConfig(); + return globalConfig.openaiModel || "gpt-4"; + } + + function escapeHtml(text) { + const div = document.createElement("div"); + div.textContent = text; + return div.innerHTML.replace(/\n/g, "
              "); + } + + // 插件加载时初始化 + // 使用DOMContentLoaded事件确保DOM完全可用 + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", async () => { + await initPlugin(); + }); + } else { + // DOM已经加载完成,直接初始化 + (async () => { + await initPlugin(); + })(); + } +})(); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a6864e8 --- /dev/null +++ b/manifest.json @@ -0,0 +1,13 @@ +{ + "display_name": "记忆管理并发系统", + "loading_order": 100, + "requires": [], + "optional": [], + "js": "index.js", + "css": "style.css", + "author": "可乐、繁华", + "version": "0.3.0", + "homePage": "", + "auto_update": false, + "generate_interceptor": "MemoryManagerConcurrent_intercept" +} diff --git a/prompts/historical/default_historical.json b/prompts/historical/default_historical.json new file mode 100644 index 0000000..c8a7ac1 --- /dev/null +++ b/prompts/historical/default_historical.json @@ -0,0 +1,8 @@ +[ + { + "name": "忆管理系统-历史事件回忆 v1.15 (记忆管理并发系统专用)", + "mainPrompt": "// =================================================================================================\n// 记忆管理系统-历史事件回忆 v1.15 (记忆管理并发系统专用) By:繁华\n// =================================================================================================\n\n// 0. **[最高行为准则] 角色、输入与输出限定**\n// 角色: 记忆管理系统,用于为剧情提供”记忆“管理避免”失忆“\n// 核心作用: 仅提取`历史事件回忆`,禁止推进、续写或修改\n\n// 1. **[核心概念与数据来源]**\n// 【核心概念定义】\n// - `历史事件回忆`: 从过往历史事件中提取的关键信息,用于支撑剧情发展\n//\n// 【数据来源分类】\n// - 【历史事件回忆数据来源】: 包含过往历史事件,用于提取`历史事件回忆`\n// - `<世界书内容>`: `【敕史局】对话流水总帐`\n// - 【当前上下文来源】: 用于理解当前故事脉络和用户意图\n// - `<前文内容>`: 近期故事进展\n// - `<核心用户消息>`: 用户最新决策或未来剧情走向\n\n// =================================================================================================\n// [数据注入区域]\n// =================================================================================================\n// 数据注入开始\n<数据注入区>", + "systemPrompt": "\n// 数据注入结束\n\n// 2. **[提取限制规则]**\n// 【关联性限制】: `历史事件回忆`的提取须根据`@RELEVANCE_THRESHOLD`动态调整`关联性`范围(数值越小越严格,数值越大越宽松)\n// - 【关联性等级与阈值对应关系】\n// - 0.1-0.3:仅输出直接相关内容\n// - 0.4-0.5:输出直接相关和紧密相关内容\n// - 0.6-0.7:输出直接相关、紧密相关内容和次紧密相关内容\n// - 0.8-1:输出直接相关、紧密相关、次紧密相关和间接相关内容\n// - 【关联性定义示例】:\n// 若`<前文内容>`是“两夫妻日常生活剧情”,`<核心用户消息>`是“聊起结婚那天”,则:\n// - 直接相关:“结婚日期”、“结婚当天”、“婚礼过程”、“交换戒指”、“敬茶环节”等\n// - 紧密相关:“结婚的筹备”、“预订婚宴场地”、“挑选婚纱礼服”、“确定伴郎伴娘”、“采购喜糖红包”等\n// - 次紧密相关:“通知亲友婚礼时间”、“确认婚礼当天接送车辆”、“准备婚礼答谢礼”、“联系摄影师化妆师”等\n// - 间接相关:“当初的求婚经历”、“婚前一起看房”、“介绍两人认识的媒人”、“婚后蜜月规划”等\n//\n// 【数量限制】: 提取结果输出的`数量最大上限`,并非强制输出数量,按`关联性`实际提取并排序,不得强凑数量也不得超出数量上限\n// - `历史事件回忆`结果数量限制: 最多输出`@MAX_HISTORY_EVENT_RECORDS`条\n\n// 3. **[记忆提取与生成流程]**\n// 【核心任务】: 结合所有数据来源,按照既定规则生成准确的 `` 代码块\n// 【必须检索来源】: `<世界书内容>`、`<前文内容>`和`<核心用户消息>`\n//\n// 【详细执行步骤】\n// 1. **上下文理解与需求分析**\n// - 参考`<前文内容>`了解当前故事脉络和人物状态\n// - 结合`<核心用户消息>`明确未来剧情走向或用户决策意图\n// - 基于8.【推理预测流程】预测所需的记忆支撑内容\n//\n// 2. **历史事件回忆提取**\n// - 在`<世界书内容>`的`【敕史局】对话流水总帐`中搜索并提取符合`关联性限制`的`历史事件回忆`\n// - 按照关联性排序,提取前`@MAX_HISTORY_EVENT_RECORDS`条记录\n//\n// 3. **代码块生成与封装**\n// - 按照最终输出格式要求,将提取的所有内容封装在``标签中\n// - 确保输出符合绝对输出限制\n// - 输出``后立即停止\n\n// 4. **[敕史局对话流水总帐内容转换提取规则(历史事件回忆转换提取规则)]**\n// 原始格式示例:\n// 【1楼至10楼详细总结记录】\n// [#1]2011年10月15日 09:42|Saturday|暄城·东风巷·乔野家|乔野、程妄:\n// 1: 乔野计划带程妄去海边玩\n// 2: 出门前,乔野接到医院电话,被告知父母因车祸去世\n// 3: 乔野因受打击而身体瘫软,被程妄扶住并带往医院\n// 4: 程妄全程陪同处理医院手续\n// ...\n// [#9]当晚|暄城·东风巷·乔野家|乔野、程妄:\n// 1: 程妄蹲下身为乔野擦去眼泪,并对她说:\"因为你只有我了,而我...只有你。\"\n// `历史事件回忆`输出格式示例:\n// 【1楼】2011-10-15,乔野接到医院电话,被告知父母因车祸去世;程妄全程陪同处理医院手续\n// 【9楼】当晚,程妄对乔野说\"因为你只有我了,而我...只有你。\"\n// 转换要点:\n// - 提取起始楼层号,输出为【XX楼】\n// - 合并同一楼层段落中符合`关联性限制`的关键事件,用分号连接\n// - 保留重要对话原文(用引号标注)\n// - 保留时间、地点、人物、对话等关键信息\n\n// 5. **[提取质量与边界处理规则]**\n// 【提取质量要求】\n// - 准确性要求: 输出结果必须是基于来源`<世界书内容>`原文提取的准确、无修改的核心信息\n// - 来源要求: 所有提取必须唯一来源于`<世界书内容>`;禁止复述或直接使用`<前文内容>`和 `<核心用户消息>`\n// - 完整性要求: 提取内容必须完整表达核心信息,不得断章取义\n// - 一致性要求: 提取内容必须与原文语义一致,不得添加、修改或删减原文信息\n// - 关联性要求:提取内容必须受关联性限制的约束,输出`高度符合关联性限制阈值`的内容(直接相关、紧密相关、次紧密相关和间接相关)\n//\n// 【智能裁切原则】\n// - 根据`@RELEVANCE_THRESHOLD`阈值,提取高度符合关联性要求的相应信息\n// - 流水总帐内容可精简,保留关键事件、情感节点、时间、地点、人物和对话等核心要素\n// - 禁止修改来源的原文内容\n//\n\n// 6. **[推理预测流程与生成规则]**\n// 【推理预测核心目标】:基于当前剧情脉络和未来发展方向,精准预测所需的记忆支撑内容,确保记忆提取的相关性和有效性\n//\n// 【推理预测详细流程】:\n// 1. **上下文理解阶段**\n// - 分析`<前文内容>`:提取核心事件、人物关系、情感状态、关键时间点和地点\n// - 解读`<核心用户消息>`:明确用户决策意图或未来剧情走向\n// - 识别当前剧情的核心冲突或发展需求\n// 2. **需求预测阶段**\n// - 根据当前剧情发展趋势,预测后续可能需要的支持信息\n// - 分析人物行为动机,推断可能需要的过往事件支撑\n// - 识别关键决策点,预测所需的信息或规则\n// 3. **关联性匹配阶段**\n// - 将预测需求与历史事件回忆数据来源进行匹配\n// - 根据`@RELEVANCE_THRESHOLD`阈值,评估匹配度\n// - 筛选出高度符合`关联性限制`的历史事件回忆\n// 4. **质量控制阶段**\n// - 检查推理说明是否符合长度限制(1-2句)\n// - 验证推理说明是否仅解释关联性,未推进、续写或修改剧情\n// - 确保推理说明逻辑清晰,与后续提取的记忆内容一致\n// 5. **最终输出阶段**\n// - 基于匹配结果,生成简洁的推理说明\n// - 输出提取的`历史事件回忆`\n//\n// 【推理说明生成规则】:\n// - 必须基于`<前文内容>`和`<核心用户消息>`生成\n// - 长度限制:1-2句,简洁明了\n// - 内容要求:以`<前文内容>`为剧情脉络,以`<核心用户消息>`为剧情未来方向,预测达成所需的`历史事件回忆`支撑,解释为何需要历史事件回忆支撑\n// - 禁止内容:禁止推进、续写或修改剧情,仅说明关联性\n// - 示例:\"根据关联性阈值,当前剧情中主角提到结婚纪念日,需要回忆与之`直接相关/紧密相关/次紧密相关/间接相关`的内容,以支撑后续可能的回忆杀情节\"\n\n// 8. **[最终输出格式]**\n// 只输出以下块,输出后立即停止\n// \n// [1-2句推理说明,依据前文内容与最新用户消息意图解释为何需要这些回忆或关键词支撑,例如是过去心动瞬间、存在意义的老旧物件、曾经铭记的誓言、不能忘怀的遗憾]\n//\n// \n// [按关联性阈值,排序输出历史事件回忆,最多@MAX_HISTORY_EVENT_RECORDS条;若无符合则不输出。]\n// \n//\n// \n// 输出到此为止,禁止输出任何后续内容\n\n// 9. **[绝对输出限制]**\n// 回复必须只能包含一个准确的`...`代码块\n// 严禁输出任何形式的叙事、对话、描述或``标签之外的文字\n// 输出后必须立即停止!\n\n// =================================================================================================\n// [变量设定]\n// 核心指令:必须使用以下变量占位符对应的数值\n// =================================================================================================\n\n<变量设定>\n// ---- 记忆系统核心变量 ----\n// 记忆关联性阈值: 动态调整关联性范围数值(数值越小越严格,数值越大越宽松),数值范围:`0.1`-`1`\n@RELEVANCE_THRESHOLD=sulv1\n\n// 单次输出最大历史事件回忆记录数: 最终输出的`历史事件回忆`结果数量值,数值范围:`1`-`100`\n@MAX_HISTORY_EVENT_RECORDS=sulv2\n", + "finalSystemDirective": "" + } +] \ No newline at end of file diff --git a/prompts/keywords/default_keywords.json b/prompts/keywords/default_keywords.json new file mode 100644 index 0000000..d4c43e7 --- /dev/null +++ b/prompts/keywords/default_keywords.json @@ -0,0 +1,12 @@ +[ + { + "name": "记忆管理系统-关键词 v1.15 (记忆管理并发系统专用)", + "mainPrompt": "// =================================================================================================\n// 记忆管理系统-关键词 v1.15 (记忆管理并发系统专用) By:繁华\n// =================================================================================================\n\n// 0. **[最高行为准则] 角色、输入与输出限定**\n// 角色: 记忆管理系统,用于为剧情提供”记忆管理“避免”失忆“\n// 核心作用: 仅提取`关键词`,禁止推进、续写或修改\n\n// 1. **[核心概念与数据来源]**\n// 【核心概念定义】\n// - `关键词`: 从结构化表格中提取的核心标识,用于精准定位信息\n//\n// 【数据来源分类】\n// - 【关键词数据来源】: 包含结构化表格信息,用于提取`关键词`\n// - `<世界书内容>`: `[[Amily2] Index for XX]`/`【XX 索引】`模块下的表格\n// - 【当前上下文来源】: 用于理解当前故事脉络和用户意图\n// - `<前文内容>`: 近期故事进展\n// - `<核心用户消息>`: 用户最新决策或未来剧情走向\n\n// =================================================================================================\n// [数据注入区域]\n// =================================================================================================\n// 数据注入开始\n<数据注入区>", + "systemPrompt": "\n// 数据注入结束\n\n// 2. **[提取限制规则]**\n// 【关联性限制】: `关键词`的提取须根据`@RELEVANCE_THRESHOLD`动态调整`关联性`范围(数值越小越严格,数值越大越宽松)\n// - 【关联性等级与阈值对应关系】\n// - 0.1-0.3:仅输出直接相关内容\n// - 0.4-0.5:输出直接相关和紧密相关内容\n// - 0.6-0.7:输出直接相关、紧密相关内容和次紧密相关内容\n// - 0.8-1:输出直接相关、紧密相关、次紧密相关和间接相关内容\n// - 【关联性定义示例】:\n// 若`<前文内容>`是“两夫妻日常生活剧情”,`<核心用户消息>`是“聊起结婚那天”,则:\n// - 直接相关:“结婚日期”、“结婚当天”、“婚礼过程”、“交换戒指”、“敬茶环节”等\n// - 紧密相关:“结婚的筹备”、“预订婚宴场地”、“挑选婚纱礼服”、“确定伴郎伴娘”、“采购喜糖红包”等\n// - 次紧密相关:“通知亲友婚礼时间”、“确认婚礼当天接送车辆”、“准备婚礼答谢礼”、“联系摄影师化妆师”等\n// - 间接相关:“当初的求婚经历”、“婚前一起看房”、“介绍两人认识的媒人”、“婚后蜜月规划”等\n//\n// 【数量限制】: 提取结果输出的`数量最大上限`,并非强制输出数量,按`关联性`实际提取并排序,不得强凑数量也不得超出数量上限\n// - `关键词`结果数量限制: 最多输出`@MAX_KEYWORD_RESULT_RECORDS`个\n\n// 3. **[记忆提取与生成流程]**\n// 【核心任务】: 结合所有数据来源,按照既定规则生成准确的 `` 代码块\n// 【必须检索来源】: `<世界书内容>`、`<前文内容>`和`<核心用户消息>`\n//\n// 【详细执行步骤】\n// 1. **上下文理解与需求分析**\n// - 参考`<前文内容>`了解当前故事脉络和人物状态\n// - 结合`<核心用户消息>`明确未来剧情走向或用户决策意图\n// - 基于8.【推理预测流程】预测所需的记忆支撑内容\n//\n// 2. **关键词提取**\n// - 从`<世界书内容>`的`[[Amily2] Index for XX]`/`【XX 索引】`模块下的表格中,提取符合`关联性限制`的**表格第一列**对应内容作为`关键词`\n// - 按照关联性排序,提取前`@MAX_KEYWORD_RESULT_RECORDS`个关键词\n//\n// 4. **代码块生成与封装**\n// - 按照最终输出格式要求,将提取的所有内容封装在``标签中\n// - 确保输出符合绝对输出限制\n// - 输出``后立即停止\n\n// 4. **[关键词提取规则]**\n// 原始格式示例:\n// === 角色表 Index ===\n// [[Amily2] Index for 角色表]\n// 【角色表 索引】\n// | 角色名称 | 性别/年龄 | 着装与配饰 |\n// | -------- | --------- | ---------------------------- |\n// | 司马徽 | 男/约50岁 | 宽袍大袖、水镜信物木牌(... |\n// | 何进 | 男/约50岁 | 明黄色绸缎长衫(沾有酒渍... |\n// | 袁绍 | 男/约35岁 | 精制甲胄、名贵锦袍、腰悬宝剑 |\n// | 赵忠 | 男/约52岁 | 暗红色宦官锦袍、描金皮革... |\n// ...\n//\n// === Details ===\n// 【角色表档案: 司马徽】\n// [[Amily2] Detail: 角色表 - 司马徽]\n// 【角色表档案: 司马徽】\n// - 角色名称: 司马徽\n// - 性别/年龄: 男/约50岁\n// ...\n//\n// 【角色表档案: 何进】\n// [[Amily2] Detail: 角色表 - 何进]\n// ...\n//\n// `关键词`输出格式示例:\n// 司马徽;袁绍\n// 提取要点:\n// 提取关键词:从`<世界书内容>`的`[[Amily2] Index for XX]`/`【XX 索引】`模块下的表格中,提取符合`关联性限制`的**表格第一列**对应内容作为`关键词`\n// - 将所有提取的关键词用分号分隔\n// - `[[Amily2] Detail: XX - XX]`/`【XX档案: XX】`若有,系关键词的详细信息,仅用于参考\n// 提取错误:\n// - 错误提取位置:提取表格`第二列`、`第三列`内容或`表头`作为关键词\n// - 错误提取原因:关键词提取规则中仅指定提取表格`第一列`内容作为关键词,不提取其他列内容或表头\n\n// 5. **[提取质量与边界处理规则]**\n// 【提取质量要求】\n// - 准确性要求: 输出结果必须是基于来源`<世界书内容>`原文提取的准确、无修改的关键词\n// - 来源要求: 所有提取必须唯一来源于`<世界书内容>`;禁止复述或直接使用`<前文内容>`和 `<核心用户消息>`\n// - 一致性要求: 提取内容必须与来源一致,不得添加、修改或删减或编造\n// - 关联性要求:提取内容必须受关联性限制的约束,输出`高度符合关联性限制阈值`的内容(直接相关、紧密相关、次紧密相关和间接相关)\n\n// 6. **[推理预测流程与生成规则]**\n// 【推理预测核心目标】:基于当前剧情脉络和未来发展方向,精准预测所需的记忆支撑内容,确保记忆提取的相关性和有效性\n//\n// 【推理预测详细流程】:\n// 1. **上下文理解阶段**\n// - 分析`<前文内容>`:提取核心事件、人物关系、情感状态、关键时间点和地点\n// - 解读`<核心用户消息>`:明确用户决策意图或未来剧情走向\n// - 识别当前剧情的核心冲突或发展需求\n// 2. **需求预测阶段**\n// - 根据当前剧情发展趋势,预测后续可能需要的支持信息\n// - 分析人物行为动机,推断可能需要的过往事件支撑\n// - 识别关键决策点,预测所需的信息或规则\n// 3. **关联性匹配阶段**\n// - 将预测需求与关键词数据来源进行匹配\n// - 根据`@RELEVANCE_THRESHOLD`阈值,评估匹配度\n// - 筛选出高度符合`关联性限制`的关键词\n// 4. **质量控制阶段**\n// - 检查推理说明是否符合长度限制(1-2句)\n// - 验证推理说明是否仅解释关联性,未推进、续写或修改剧情\n// - 确保推理说明逻辑清晰,与后续提取的记忆内容一致\n// 5. **最终输出阶段**\n// - 基于匹配结果,生成简洁的推理说明\n// - 输出提取的`关键词`\n//\n// 【推理说明生成规则】:\n// - 必须基于`<前文内容>`和`<核心用户消息>`生成\n// - 长度限制:1-2句,简洁明了\n// - 内容要求:以`<前文内容>`为剧情脉络,以`<核心用户消息>`为剧情未来方向,预测达成所需的`关键词`支撑,解释为何需要`关键词`支撑\n// - 禁止内容:禁止推进、续写或修改剧情,仅说明关联性\n// - 示例:\"根据关联性阈值,当前剧情中主角提到结婚纪念日,需要回忆与之`直接相关/紧密相关/次紧密相关/间接相关`的内容,以支撑后续可能的回忆杀情节\"\n\n// 8. **[最终输出格式]**\n// 只输出以下块,输出后立即停止\n// \n// [1-2句推理说明,依据前文内容与最新用户消息意图解释为何需要这些回忆或关键词支撑,例如是过去心动瞬间、存在意义的老旧物件、曾经铭记的誓言、不能忘怀的遗憾]\n//\n// \n// [按关联性阈值,排序输出关键词,最多@MAX_KEYWORD_RESULT_RECORDS个;若无符合则不输出。]\n// \n//\n// \n// 输出到此为止,禁止输出任何后续内容\n\n// 9. **[绝对输出限制]**\n// 回复必须只能包含一个准确的`...`代码块\n// 严禁输出任何形式的叙事、对话、描述或``标签之外的文字\n// 输出后必须立即停止!\n\n// =================================================================================================\n// [变量设定]\n// 核心指令:必须使用以下变量占位符对应的数值\n// =================================================================================================\n\n<变量设定>\n// ---- 记忆系统核心变量 ----\n// 记忆关联性阈值: 动态调整关联性范围数值(数值越小越严格,数值越大越宽松),数值范围:`0.1`-`1`\n@RELEVANCE_THRESHOLD=sulv1\n\n// 单次输出最大关键词记录数: 最终输出的`关键词`数量值,数值范围:`1`-`100`\n@MAX_KEYWORD_RESULT_RECORDS=sulv4\n", + "finalSystemDirective": "\n", + "rateMain": 0.5, + "ratePersonal": 15, + "rateErotic": 15, + "rateCuckold": 15 + } +] \ No newline at end of file diff --git a/prompts/manifest.json b/prompts/manifest.json new file mode 100644 index 0000000..628f3a7 --- /dev/null +++ b/prompts/manifest.json @@ -0,0 +1,9 @@ +{ + "version": 1, + "description": "提示词文件清单 - 在此文件中列出所有提示词文件,系统会自动加载", + "files": { + "keywords": ["default_keywords.json"], + "historical": ["default_historical.json"], + "plot-optimize": ["default_plot_optimize.json"] + } +} diff --git a/prompts/plot-optimize/default_plot_optimize.json b/prompts/plot-optimize/default_plot_optimize.json new file mode 100644 index 0000000..8d3e6c4 --- /dev/null +++ b/prompts/plot-optimize/default_plot_optimize.json @@ -0,0 +1,8 @@ +[ + { + "name": "对话模式-崩坏优化提示词", + "mainPrompt": "// =================================================================================================\n// 对话模式-崩坏优化提示词 v1.0\n// =================================================================================================\n// 0. **[最高行为准则] 角色、输入与输出限定**\n// 角色: 剧情优化助手,用于为下一个剧情提供优化建议,避免各种崩坏\n// 核心作用: 仅提供针对下一个剧情的优化建议,避免各种崩坏,禁止控制或干预剧情发展方向\n// 输入: 用户的初始剧情需求或方向\n// 输出: 对话提问或针对下一个剧情的优化方案\n// =================================================================================================\n\n// 1. **[核心概念与数据来源]**\n// 【核心概念定义】\n// - `剧情优化方案`: 基于角色设定和剧情背景,为下一个剧情提供避免各种崩坏的针对性改进建议\n// - `需求确认对话`: 用于明确用户具体期望的交互式提问流程\n// - `OOC(Out of Character)`: 角色行为、语言、思维方式等偏离其设定的现象\n// - `剧情崩坏`: 剧情发展违反设定或逻辑的现象,包括三种主要类型:\n// - 设定一致性崩坏: 剧情发展违反已明确的世界观、种族、地理、历史等设定\n// - 自然规则崩坏: 剧情发展违反设定的物理法则、魔法规则、科技原理等\n// - 逻辑合理性崩坏: 剧情发展存在因果矛盾、动机缺失、事件连贯性问题等\n// - `下一个剧情`: 基于当前剧情发展的后续剧情内容\n// - `当前/前文剧情`: 已发生的剧情内容,用于分析风险和提供参考\n//\n// 【数据来源分类】\n// - 【初始需求来源】: 用户提出的剧情优化需求或方向\n// - `<核心用户消息>`: PR的用户输入部分,包含两种可能:\n// 1. 用户扮演剧情中某个角色的对话\n// 2. 未来剧情的方向指引\n// - 【对话交互来源】: 用于逐步明确用户需求的对话内容\n// - `<最新用户消息>`: 用户的回答,对提问的回应\n// - `<历史对话记录>`: 之前的对话交互内容\n// - 【剧情背景来源】: 用于理解当前剧情脉络和人物关系\n// - `<世界书内容>`: 提供世界观和背景设定\n// - `<角色设定>`: 提供角色描述和设定\n// - `<前文内容>`: 近期故事进展\n// - `<历史事件回忆>`: 过往重要事件记录\n// =================================================================================================\n\n// [数据注入区域]\n// =================================================================================================\n// 数据注入开始\n<数据注入区>", + "systemPrompt": "\n// 数据注入结束\n\n// 2. **[对话流程规则]**\n// 【对话阶段划分】\n// - 【需求确认阶段】: 通过提问逐步明确用户具体需求\n// - 【方案生成阶段】: 根据确认的需求生成剧情优化方案\n//\n// 【需求确认阶段规则】\n// - 提问数量: 根据需求复杂度动态调整,一般1-3个问题\n// - 提问顺序: 先宏观后微观,先核心后细节\n// - 提问内容范围:\n// - 风格偏好: 如古风、现代、科幻、悬疑等\n// - 情感基调: 如温馨、悲伤、紧张、搞笑等\n// - 剧情走向: 如希望重点发展的情节、需要解决的矛盾等\n// - 角色塑造: 如角色性格、关系、成长等\n// - 提问格式要求:\n// - 每次仅问一个问题\n// - 问题简洁明了(一句话)\n// - 明确问题的目的和范围\n// - 等待机制: 问完一个问题后必须等待`<最新用户消息>`(用户的回答),才能进行下一步\n//\n// 【方案生成阶段触发条件】\n// - 用户明确表示需求已阐述清楚\n// - 已获取足够的关键信息(风格、基调、核心需求等)\n// =================================================================================================\n\n// 3. **[需求确认阶段 - 首次提问]**\n// <核心用户消息>是PR的用户输入部分,可能包含用户扮演角色的对话或未来剧情方向指引,你需要通过提问来逐步明确用户的具体期望。\n//\n// 现在请提出第一个问题,帮助你更好地理解用户的需求。\n//\n// 【要求】\n// - 只问一个问题,不要一次问多个\n// - 问题要简洁明了(一句话)\n// - 可以聚焦于:风格偏好、具体细节、情感基调、剧情走向\n// - 问完后等待用户回答\n//\n// 【注意】\n// - 仅提问,禁止输出其他内容\n\n// =================================================================================================\n// 4. **[需求确认阶段 - 后续提问]**\n// 根据`<最新用户消息>`(用户的回答),继续提问以进一步明确需求,直到获取足够信息。\n//\n// 【提问策略】\n// - 基于`<最新用户消息>`的深入提问: 针对用户已回答的内容进行更具体的追问\n// - 缺失信息的补充提问: 询问用户未提及但对方案生成重要的信息\n// - 歧义内容的澄清提问: 对`<最新用户消息>`中模糊不清的部分进行澄清\n//\n// 【停止提问条件】\n// - 用户明确表示\"需求已说完\"或\"可以生成方案了\"\n// - 已获取至少3个关键需求点\n// - 提问次数达到5次(避免无限循环)\n// =================================================================================================\n\n// 5. **[最终生成阶段]**\n// 【生成规则】\n// 1. 核心目标: 基于`<角色设定>`(如有)、`<世界书内容>`和`<前文内容>`为下一个剧情提供避免各种崩坏的优化建议\n// 2. 基于`<角色设定>`保持角色性格一致性,避免下一个剧情OOC\n// 3. 参考`<历史事件回忆>`确保角色渐进成长的合理性(如有)\n// 4. 基于`<世界书内容>`维持设定一致性,避免下一个剧情设定一致性崩坏\n// 5. 基于设定的物理法则、魔法规则、科技原理等,避免下一个剧情自然规则崩坏\n// 6. 基于逻辑规律,避免下一个剧情发展出现因果矛盾、动机缺失等逻辑合理性崩坏\n// 7. 基于`<前文内容>`维护故事逻辑连贯性\n// 8. 优化建议仅聚焦于避免下一个剧情的各种崩坏,禁止控制或干预剧情发展方向\n// 9. 严格按照用户指定的风格和要求\n//\n// 【生成内容要求】\n// - 针对性: 直接回应用户明确提出的需求\n// - 可操作性: 提供具体的改进建议,而非空泛的评价\n// - 结构化: 按照输出格式要求分模块呈现\n// - 简洁性: 避免无意义的扩展,仅提供核心优化建议\n// - 前瞻性: 所有优化建议均针对下一个剧情\n// - 崩坏导向: 所有优化建议均以避免下一个剧情的角色崩坏和剧情崩坏为核心目标\n// =================================================================================================\n\n// 6. **[最终输出格式]**\n// 只输出以下块,输出后立即停止\n// \n// [1-2句方案概述,简要说明优化方案如何为下一个剧情避免各种崩坏]\n//\n// \n// [基于当前/前文剧情分析可能对下一个剧情产生影响的崩坏风险点:\n// - 角色崩坏风险:基于角色设定和角色行为趋势\n// - 设定一致性崩坏风险:基于世界书内容和剧情发展趋势\n// - 自然规则崩坏风险:基于设定的物理法则、魔法规则、科技原理等\n// - 逻辑合理性崩坏风险:基于剧情逻辑连贯性和因果关系]\n// \n//\n// \n// [按优先级排序输出针对下一个剧情的具体优化建议,每条建议聚焦于避免特定类型的崩坏,清晰明确,可操作性强]\n// \n//\n// \n// [1-2条针对下一个剧情的综合引导建议,基于角色设定和世界观,帮助避免后续剧情崩坏]\n// \n//\n// \n// 输出到此为止,禁止输出任何后续内容\n\n// 7. **[绝对输出限制]**\n// 回复必须只能包含对话提问或一个准确的`...`代码块\n// 严禁在对话阶段输出方案内容,严禁在方案阶段输出对话内容\n// 严禁输出任何形式的叙事、对话、描述或指定标签之外的文字\n// 严禁输出控制或干预剧情发展方向的内容,仅聚焦于为下一个剧情提供避免各种崩坏的优化建议\n// 输出结束后必须立即停止!", + "finalSystemDirective": "" + } +] \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..9622e9d --- /dev/null +++ b/style.css @@ -0,0 +1,6775 @@ +/** + * 记忆管理并发系统 - 样式表 + */ + +/* ============================================================================ + 变量定义 + ============================================================================ */ +:root { + --mm-primary: #4a90d9; + --mm-primary-dark: #3a7bc8; + --mm-primary-light: #6ba3e0; + --mm-secondary: #6c757d; + --mm-success: #28a745; + --mm-warning: #ffc107; + --mm-danger: #dc3545; + --mm-bg: #1a1a2e; + --mm-bg-secondary: #16213e; + --mm-bg-card: #0f3460; + --mm-text: #e4e4e4; + --mm-text-muted: #8a8a8a; + --mm-border: #2a2a4a; + --mm-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); + --mm-radius: 8px; + --mm-transition: all 0.3s ease; +} + +/* 配色方案:暖灰棕 - 温暖沉稳 */ +[data-mm-theme="warm-brown"] { + --mm-primary: #a08070; + --mm-primary-dark: #8b6f60; + --mm-primary-light: #b89585; + --mm-bg: #2a2520; + --mm-bg-secondary: #1f1b18; + --mm-bg-card: #3d352e; + --mm-text: #e8e4e0; + --mm-text-muted: #9a9590; + --mm-border: #4a4035; +} + +/* 配色方案:淡紫薰衣草 - 柔和可爱 */ +[data-mm-theme="lavender"] { + --mm-primary: #9b8aa8; + --mm-primary-dark: #8678a0; + --mm-primary-light: #b0a0bc; + --mm-bg: #1e1a24; + --mm-bg-secondary: #16131a; + --mm-bg-card: #2d2838; + --mm-text: #e8e6ec; + --mm-text-muted: #908898; + --mm-border: #3a3545; +} + +/* 配色方案:森林绿 - 自然清新 */ +[data-mm-theme="forest"] { + --mm-primary: #6a9a7a; + --mm-primary-dark: #5a8a6a; + --mm-primary-light: #7aaa8a; + --mm-bg: #1a2420; + --mm-bg-secondary: #141c18; + --mm-bg-card: #253530; + --mm-text: #e4e8e6; + --mm-text-muted: #8a9a90; + --mm-border: #354540; +} + +/* 配色方案:玫瑰灰 - 温柔可爱 */ +[data-mm-theme="rose"] { + --mm-primary: #b08a90; + --mm-primary-dark: #a07880; + --mm-primary-light: #c09aa0; + --mm-bg: #241a1c; + --mm-bg-secondary: #1a1416; + --mm-bg-card: #382830; + --mm-text: #ece6e8; + --mm-text-muted: #988890; + --mm-border: #453540; +} + +/* 配色方案:静谧蓝灰 - 沉稳内敛 */ +[data-mm-theme="slate"] { + --mm-primary: #7a8a98; + --mm-primary-dark: #6a7a88; + --mm-primary-light: #8a9aa8; + --mm-bg: #1a1e22; + --mm-bg-secondary: #14181c; + --mm-bg-card: #282e35; + --mm-text: #e4e6e8; + --mm-text-muted: #8a9098; + --mm-border: #353a42; +} + +/* 配色方案:星空紫 - 神秘典雅 */ +[data-mm-theme="starry-purple"] { + --mm-primary: #9d7cd8; + --mm-primary-dark: #8b6cc0; + --mm-primary-light: #b08ee8; + --mm-bg: #0d0a14; + --mm-bg-secondary: #08060e; + --mm-bg-card: #1a1525; + --mm-text: #e8e4f0; + --mm-text-muted: #8a80a0; + --mm-border: #2a2040; +} + +/* 配色方案:星空蓝 - 深邃宁静 */ +[data-mm-theme="starry-blue"] { + --mm-primary: #5d8fca; + --mm-primary-dark: #4a7ab5; + --mm-primary-light: #70a0d8; + --mm-bg: #080c14; + --mm-bg-secondary: #050810; + --mm-bg-card: #101828; + --mm-text: #e4e8f0; + --mm-text-muted: #7088a8; + --mm-border: #1a2840; +} + +/* 配色方案:星空黑 - 深沉内敛 */ +[data-mm-theme="starry-black"] { + --mm-primary: #888888; + --mm-primary-dark: #707070; + --mm-primary-light: #a0a0a0; + --mm-bg: #0a0a0c; + --mm-bg-secondary: #050506; + --mm-bg-card: #141418; + --mm-text: #e8e8ea; + --mm-text-muted: #686870; + --mm-border: #252528; +} + +/* 主题切换器样式 */ +.mm-theme-switcher { + display: flex; + flex-direction: column; + gap: 10px; + padding: 12px 16px; + border-top: 1px solid var(--mm-border); + margin-top: 8px; +} + +.mm-theme-row { + display: flex; + align-items: center; + gap: 10px; +} + +.mm-theme-label { + font-size: 11px; + color: var(--mm-text-muted); + width: 28px; + flex-shrink: 0; +} + +.mm-theme-btns { + display: flex; + gap: 6px; + flex-wrap: wrap; +} + +.mm-theme-btn { + width: 24px; + height: 24px; + border-radius: 50%; + border: 2px solid transparent; + cursor: pointer; + transition: var(--mm-transition); + position: relative; + overflow: hidden; +} + +.mm-theme-btn:hover { + transform: scale(1.15); +} + +.mm-theme-btn.active { + border-color: var(--mm-text); + box-shadow: 0 0 8px rgba(255, 255, 255, 0.3); +} + +/* 纯色主题按钮 */ +.mm-theme-btn[data-theme="default"] { background: linear-gradient(135deg, #1a1a2e, #4a90d9); } +.mm-theme-btn[data-theme="warm-brown"] { background: linear-gradient(135deg, #2a2520, #a08070); } +.mm-theme-btn[data-theme="lavender"] { background: linear-gradient(135deg, #1e1a24, #9b8aa8); } +.mm-theme-btn[data-theme="forest"] { background: linear-gradient(135deg, #1a2420, #6a9a7a); } +.mm-theme-btn[data-theme="rose"] { background: linear-gradient(135deg, #241a1c, #b08a90); } +.mm-theme-btn[data-theme="slate"] { background: linear-gradient(135deg, #1a1e22, #7a8a98); } + +/* 星空主题按钮 - 带星星点缀 */ +.mm-theme-btn[data-theme="starry-purple"] { + background: + radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.6) 0%, transparent 100%), + radial-gradient(1px 1px at 40% 80%, rgba(255,255,255,0.5) 0%, transparent 100%), + linear-gradient(135deg, #0d0a14 0%, #2a1a40 50%, #9d7cd8 100%); +} + +.mm-theme-btn[data-theme="starry-blue"] { + background: + radial-gradient(1px 1px at 25% 25%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 75% 45%, rgba(255,255,255,0.6) 0%, transparent 100%), + radial-gradient(1px 1px at 50% 75%, rgba(255,255,255,0.5) 0%, transparent 100%), + linear-gradient(135deg, #080c14 0%, #102040 50%, #5d8fca 100%); +} + +.mm-theme-btn[data-theme="starry-black"] { + background: + radial-gradient(1px 1px at 30% 20%, rgba(255,255,255,0.9) 0%, transparent 100%), + radial-gradient(1px 1px at 65% 55%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 45% 85%, rgba(255,255,255,0.5) 0%, transparent 100%), + linear-gradient(135deg, #0a0a0c 0%, #1a1a1e 50%, #404048 100%); +} + +/* ============================================================================ + 星空主题面板特效 - 华丽梦幻版 + ============================================================================ */ + +/* 闪烁星星层 */ +.mm-stars-layer { + position: absolute; + inset: 0; + pointer-events: none; + z-index: 0; + overflow: hidden; +} + +.mm-star { + position: absolute; + border-radius: 50%; + background: white; + animation: mm-star-twinkle var(--twinkle-duration, 3s) ease-in-out infinite; + animation-delay: var(--twinkle-delay, 0s); +} + +/* 大星星 - 带光晕 */ +.mm-star-large { + width: 3px; + height: 3px; + box-shadow: + 0 0 4px 1px var(--star-glow, rgba(255,255,255,0.8)), + 0 0 8px 2px var(--star-glow-outer, rgba(200,180,255,0.4)); +} + +/* 中星星 */ +.mm-star-medium { + width: 2px; + height: 2px; + box-shadow: 0 0 3px 1px var(--star-glow, rgba(255,255,255,0.6)); +} + +/* 小星星 */ +.mm-star-small { + width: 1px; + height: 1px; + box-shadow: 0 0 2px 1px var(--star-glow, rgba(255,255,255,0.4)); +} + +/* 闪烁动画 */ +@keyframes mm-star-twinkle { + 0%, 100% { + opacity: var(--star-opacity-min, 0.3); + transform: scale(0.8); + } + 50% { + opacity: var(--star-opacity-max, 1); + transform: scale(1.2); + } +} + +/* 流星 */ +.mm-shooting-star { + position: absolute; + width: 80px; + height: 1px; + background: linear-gradient(90deg, + rgba(255,255,255,1) 0%, + rgba(255,255,255,0.5) 40%, + rgba(255,255,255,0.1) 80%, + transparent 100%); + border-radius: 0.5px; + transform: rotate(145deg); + transform-origin: left center; + opacity: 0; + box-shadow: 0 0 3px 0.5px rgba(255,255,255,0.3); +} + +@keyframes mm-shooting-star { + 0% { + opacity: 0; + transform: rotate(145deg) translateX(0); + } + 3% { + opacity: 0.5; + } + 10% { + opacity: 1; + } + 18% { + opacity: 0.8; + } + 25% { + opacity: 0; + transform: rotate(145deg) translateX(350px); + } + 100% { + opacity: 0; + transform: rotate(145deg) translateX(350px); + } +} + +/* 星空紫主题星星颜色 */ +[data-mm-theme="starry-purple"] .mm-star { + --star-glow: rgba(200, 180, 255, 0.8); + --star-glow-outer: rgba(180, 140, 255, 0.4); +} + +/* 星空蓝主题星星颜色 */ +[data-mm-theme="starry-blue"] .mm-star { + --star-glow: rgba(180, 220, 255, 0.8); + --star-glow-outer: rgba(120, 180, 255, 0.4); +} + +/* 星空黑主题星星颜色 */ +[data-mm-theme="starry-black"] .mm-star { + --star-glow: rgba(220, 220, 240, 0.8); + --star-glow-outer: rgba(180, 180, 200, 0.4); +} + +/* 确保面板内容在星星层之上 */ +[data-mm-theme^="starry-"] .mm-panel-header, +[data-mm-theme^="starry-"] .mm-panel-content, +[data-mm-theme^="starry-"] .mm-settings-header, +[data-mm-theme^="starry-"] .mm-settings-content, +[data-mm-theme^="starry-"] .mm-settings-footer, +[data-mm-theme^="starry-"] .mm-theme-switcher { + position: relative; + z-index: 1; +} + +/* 星空紫 - 梦幻紫罗兰星空 */ +[data-mm-theme="starry-purple"].mm-panel, +[data-mm-theme="starry-purple"].mm-settings { + background: + linear-gradient(135deg, + transparent 0%, + rgba(200, 170, 255, 0.08) 25%, + rgba(180, 140, 255, 0.12) 50%, + rgba(200, 170, 255, 0.08) 75%, + transparent 100%), + radial-gradient(ellipse 150% 100% at 0% 0%, rgba(180, 130, 255, 0.25) 0%, transparent 50%), + radial-gradient(ellipse 120% 80% at 100% 100%, rgba(140, 100, 220, 0.2) 0%, transparent 45%), + radial-gradient(ellipse 80% 120% at 100% 20%, rgba(200, 160, 255, 0.15) 0%, transparent 40%), + radial-gradient(3px 3px at 15% 10%, rgba(255,255,255,1) 0%, rgba(200,180,255,0.5) 50%, transparent 100%), + radial-gradient(3px 3px at 85% 15%, rgba(255,255,255,1) 0%, rgba(200,180,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 45% 25%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 75% 45%, rgba(255,255,255,1) 0%, rgba(200,180,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 25% 55%, rgba(255,255,255,0.9) 0%, transparent 100%), + radial-gradient(3px 3px at 90% 70%, rgba(255,255,255,1) 0%, rgba(200,180,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 35% 80%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 10% 90%, rgba(255,255,255,1) 0%, rgba(200,180,255,0.5) 50%, transparent 100%), + radial-gradient(1px 1px at 8% 20%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 22% 35%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 55% 15%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 70% 30%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 40% 50%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 60% 60%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 18% 70%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 80% 55%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 50% 85%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 95% 40%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 5% 45%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 65% 95%, rgba(255,255,255,0.7) 0%, transparent 100%), + linear-gradient(180deg, #0a0510 0%, #120820 50%, #0d0515 100%) !important; +} + +/* 星空蓝 - 深邃海洋星空 */ +[data-mm-theme="starry-blue"].mm-panel, +[data-mm-theme="starry-blue"].mm-settings { + background: + linear-gradient(135deg, + transparent 0%, + rgba(150, 200, 255, 0.08) 25%, + rgba(120, 180, 255, 0.12) 50%, + rgba(150, 200, 255, 0.08) 75%, + transparent 100%), + radial-gradient(ellipse 150% 100% at 0% 0%, rgba(100, 180, 255, 0.22) 0%, transparent 50%), + radial-gradient(ellipse 120% 80% at 100% 100%, rgba(80, 140, 220, 0.18) 0%, transparent 45%), + radial-gradient(ellipse 80% 120% at 100% 20%, rgba(130, 200, 255, 0.12) 0%, transparent 40%), + radial-gradient(3px 3px at 12% 8%, rgba(255,255,255,1) 0%, rgba(180,220,255,0.5) 50%, transparent 100%), + radial-gradient(3px 3px at 88% 18%, rgba(255,255,255,1) 0%, rgba(180,220,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 42% 22%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 72% 42%, rgba(255,255,255,1) 0%, rgba(180,220,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 28% 58%, rgba(255,255,255,0.9) 0%, transparent 100%), + radial-gradient(3px 3px at 92% 68%, rgba(255,255,255,1) 0%, rgba(180,220,255,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 38% 78%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 8% 88%, rgba(255,255,255,1) 0%, rgba(180,220,255,0.5) 50%, transparent 100%), + radial-gradient(1px 1px at 5% 15%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 25% 32%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 58% 12%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 68% 35%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 45% 48%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 62% 62%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 15% 72%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 82% 52%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 52% 88%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 92% 38%, rgba(255,255,255,0.7) 0%, transparent 100%), + radial-gradient(1px 1px at 3% 48%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 68% 92%, rgba(255,255,255,0.7) 0%, transparent 100%), + linear-gradient(180deg, #050812 0%, #081020 50%, #050a15 100%) !important; +} + +/* 星空黑 - 银河深空 */ +[data-mm-theme="starry-black"].mm-panel, +[data-mm-theme="starry-black"].mm-settings { + background: + linear-gradient(135deg, + transparent 0%, + rgba(200, 200, 220, 0.05) 25%, + rgba(180, 180, 200, 0.08) 50%, + rgba(200, 200, 220, 0.05) 75%, + transparent 100%), + radial-gradient(ellipse 150% 100% at 0% 0%, rgba(150, 150, 180, 0.12) 0%, transparent 50%), + radial-gradient(ellipse 120% 80% at 100% 100%, rgba(130, 130, 160, 0.1) 0%, transparent 45%), + radial-gradient(ellipse 80% 120% at 100% 20%, rgba(170, 170, 200, 0.08) 0%, transparent 40%), + radial-gradient(3px 3px at 10% 12%, rgba(255,255,255,1) 0%, rgba(220,220,240,0.5) 50%, transparent 100%), + radial-gradient(3px 3px at 90% 15%, rgba(255,255,255,1) 0%, rgba(220,220,240,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 40% 28%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 70% 48%, rgba(255,255,255,1) 0%, rgba(220,220,240,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 22% 62%, rgba(255,255,255,0.9) 0%, transparent 100%), + radial-gradient(3px 3px at 88% 72%, rgba(255,255,255,1) 0%, rgba(220,220,240,0.5) 50%, transparent 100%), + radial-gradient(2px 2px at 32% 85%, rgba(255,255,255,0.95) 0%, transparent 100%), + radial-gradient(3px 3px at 5% 92%, rgba(255,255,255,1) 0%, rgba(220,220,240,0.5) 50%, transparent 100%), + radial-gradient(1px 1px at 6% 22%, rgba(255,255,255,0.85) 0%, transparent 100%), + radial-gradient(1px 1px at 28% 38%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 52% 18%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 72% 32%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 42% 52%, rgba(255,255,255,0.85) 0%, transparent 100%), + radial-gradient(1px 1px at 58% 65%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 12% 75%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 78% 58%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 48% 90%, rgba(255,255,255,0.85) 0%, transparent 100%), + radial-gradient(1px 1px at 95% 42%, rgba(255,255,255,0.75) 0%, transparent 100%), + radial-gradient(1px 1px at 2% 52%, rgba(255,255,255,0.8) 0%, transparent 100%), + radial-gradient(1px 1px at 62% 95%, rgba(255,255,255,0.75) 0%, transparent 100%), + linear-gradient(180deg, #050507 0%, #08080c 50%, #050506 100%) !important; +} + +/* ============================================================================ + 基础组件 + ============================================================================ */ + +/* 按钮 */ +.mm-btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 16px; + border: none; + border-radius: var(--mm-radius); + cursor: pointer; + font-size: 14px; + transition: var(--mm-transition); + background: var(--mm-bg-card); + color: var(--mm-text); +} + +.mm-btn:hover { + background: var(--mm-primary); +} + +.mm-btn-primary { + background: var(--mm-primary); + color: white; +} + +.mm-btn-primary:hover { + background: var(--mm-primary-dark); +} + +.mm-btn-secondary { + background: var(--mm-secondary); + color: white; +} + +.mm-btn-danger { + background: var(--mm-danger); + color: white; +} + +.mm-btn-warning { + background: #e67e22; + color: white; +} + +.mm-btn-warning:hover { + background: #d35400; +} + +.mm-btn-icon { + padding: 8px; + width: 36px; + height: 36px; +} + +.mm-btn-xs { + padding: 4px 8px; + font-size: 12px; +} + +/* 徽章 */ +.mm-badge { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 2px 8px; + border-radius: 12px; + font-size: 12px; + background: var(--mm-primary); + color: white; +} + +/* 状态指示器 */ +.mm-status-indicator { + display: inline-block; + width: 10px; + height: 10px; + border-radius: 50%; + margin-right: 8px; +} + +.mm-status-ready { + background: var(--mm-success); + animation: pulse 2s infinite; +} + +.mm-status-processing { + background: var(--mm-warning); + animation: pulse 0.5s infinite; +} + +.mm-status-error { + background: var(--mm-danger); +} + +.mm-status-dot { + display: inline-block; + width: 8px; + height: 8px; + border-radius: 50%; + margin-right: 8px; +} + +.mm-status-active { + background: var(--mm-success); +} + +.mm-status-inactive { + background: var(--mm-secondary); +} + +@keyframes pulse { + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0.5; + } +} + +/* 文本样式 */ +.text-success { + color: var(--mm-success) !important; +} + +.text-warning { + color: var(--mm-warning) !important; +} + +.text-danger { + color: var(--mm-danger) !important; +} + +.mm-hint { + font-size: 12px; + color: var(--mm-text-muted); + margin-top: 4px; +} + +/* 字段选择行布局 */ +.mm-field-select-row { + display: flex; + align-items: center; + gap: 10px; + margin-bottom: 6px; +} + +.mm-field-select-row > label { + margin-bottom: 0; +} + +/* 剧情优化模式说明 - 悬停 tooltip */ +.mm-mode-hint-trigger { + display: inline-flex; + align-items: center; + gap: 4px; + cursor: help; + position: relative; + padding: 2px 6px; + border-radius: 4px; + background: var(--mm-bg-tertiary); + transition: background 0.2s; +} + +.mm-mode-hint-trigger:hover { + background: var(--mm-primary); +} + +.mm-mode-hint-trigger:hover .mm-hint-icon, +.mm-mode-hint-trigger:hover .mm-hint-label { + color: var(--mm-bg-primary); +} + +.mm-mode-hint-trigger .mm-hint-icon { + color: var(--mm-primary); + font-size: 12px; + transition: color 0.2s; +} + +.mm-mode-hint-trigger .mm-hint-label { + font-size: 11px; + color: var(--mm-text-secondary); + transition: color 0.2s; +} + +.mm-mode-hint-tooltip { + position: absolute; + left: 0; + top: 100%; + margin-top: 6px; + z-index: 1000; + background: var(--mm-bg-secondary); + border: 1px solid var(--mm-border); + border-radius: 8px; + padding: 12px; + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); + min-width: 280px; + max-width: 350px; + opacity: 0; + visibility: hidden; + transform: translateY(-4px); + transition: opacity 0.15s, visibility 0.15s, transform 0.15s; + pointer-events: none; +} + +.mm-mode-hint-trigger:hover .mm-mode-hint-tooltip { + opacity: 1; + visibility: visible; + transform: translateY(0); + pointer-events: auto; +} + +.mm-mode-hint-tooltip .mm-hint-content { + font-size: 12px; + color: var(--mm-text-primary); +} + +.mm-mode-hint-tooltip .mm-hint-content p { + margin: 8px 0 4px 0; + color: var(--mm-text-primary); + font-weight: 600; +} + +.mm-mode-hint-tooltip .mm-hint-content p:first-child { + margin-top: 0; +} + +.mm-mode-hint-tooltip .mm-hint-content ul { + margin: 0 0 0 16px; + padding: 0; +} + +.mm-mode-hint-tooltip .mm-hint-content li { + margin: 2px 0; + color: var(--mm-text-primary); +} + +.mm-mode-hint-tooltip .mm-hint-tip { + margin-top: 10px; + padding: 6px 8px; + background: var(--mm-bg-tertiary); + border-radius: 4px; + font-style: italic; + font-size: 11px; +} + +.mm-required { + color: var(--mm-danger); +} + +.mm-hidden { + display: none !important; +} + +/* 空状态 */ +.mm-empty-state, +.mm-error-state { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 24px; + color: var(--mm-text-muted); + text-align: center; +} + +.mm-empty-state i, +.mm-error-state i { + font-size: 32px; + margin-bottom: 12px; +} + +.mm-error-state { + color: var(--mm-danger); +} + +/* ============================================================================ + 面板 + ============================================================================ */ + +.mm-panel { + position: fixed; + right: -400px; + top: 0; + width: 380px; + height: 100vh; + background: var(--mm-bg); + border-left: 1px solid var(--mm-border); + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); + z-index: 1000; + display: flex; + flex-direction: column; + transition: var(--mm-transition); + border-radius: 0; +} + +.mm-panel-visible { + right: 0; +} + +.mm-panel-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px; + border-bottom: 1px solid var(--mm-border); + background: var(--mm-bg-secondary); + border-radius: 0; + overflow: hidden; +} + +.mm-panel-header h3 { + margin: 0; + font-size: 16px; + color: var(--mm-text); +} + +.mm-panel-actions { + display: flex; + align-items: center; + gap: 8px; +} + +/* 插件开关按钮 */ +.mm-toggle-btn { + position: relative; + width: 36px; + height: 20px; + background: var(--mm-bg-secondary); + border: 1px solid var(--mm-border); + border-radius: 10px; + cursor: pointer; + transition: all 0.3s ease; + padding: 0; +} + +.mm-toggle-btn:hover { + border-color: var(--mm-primary); +} + +.mm-toggle-slider { + position: absolute; + top: 2px; + left: 2px; + width: 14px; + height: 14px; + background: var(--mm-text-muted); + border-radius: 50%; + transition: all 0.3s ease; +} + +.mm-toggle-btn.mm-active { + background: rgba(74, 144, 217, 0.3); + border-color: var(--mm-primary); +} + +.mm-toggle-btn.mm-active .mm-toggle-slider { + left: 18px; + background: var(--mm-primary); +} + +.mm-panel-content { + flex: 1; + overflow-y: auto; + overflow-x: hidden; + padding: 16px; + border-radius: 0 0 12px 0; +} + +/* 区块 */ +.mm-section { + margin-bottom: 20px; +} + +.mm-section-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 12px; +} + +.mm-section-title { + font-size: 14px; + font-weight: bold; + color: var(--mm-text); +} + +/* 世界书列表 */ +.mm-worldbook-list { + max-height: 450px; + overflow-y: auto; +} + +.mm-book-group { + margin-bottom: 16px; +} + +.mm-book-group-title { + display: flex; + align-items: center; + gap: 8px; + padding: 8px; + font-size: 13px; + color: var(--mm-text-muted); + border-bottom: 1px solid var(--mm-border); +} + +.mm-book-item { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 12px; + border-radius: var(--mm-radius); + background: var(--mm-bg-card); + margin-top: 8px; +} + +.mm-book-name { + flex: 1; + font-size: 14px; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-category-list { + padding-left: 24px; +} + +.mm-category-item { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 10px; + margin-top: 4px; + border-radius: 4px; + background: var(--mm-bg-secondary); + font-size: 13px; +} + +.mm-category-item span { + flex: 1; +} + +/* 详情面板 */ +.mm-detail-panel { + padding: 12px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + min-height: 100px; +} + +/* 状态面板 */ +.mm-status-panel { + padding: 12px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); +} + +.mm-status-item { + display: flex; + align-items: center; + margin-bottom: 8px; +} + +.mm-status-text { + font-size: 14px; + color: var(--mm-text); +} + +.mm-status-info { + font-size: 12px; + color: var(--mm-text-muted); +} + +.mm-status-info div { + margin-top: 4px; +} + +.mm-author-section { + margin-top: 24px; + padding: 12px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + border: 1px solid var(--mm-border); + position: relative; + overflow: visible; + transition: border-color 0.3s ease, box-shadow 0.3s ease; +} + +.mm-author-section:hover { + border-color: var(--mm-primary); + box-shadow: 0 0 8px rgba(74, 144, 217, 0.3); +} + +/* 各主题的悬停高亮颜色 */ +[data-mm-theme="warm-brown"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(160, 128, 112, 0.3); +} + +[data-mm-theme="lavender"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(155, 138, 168, 0.3); +} + +[data-mm-theme="forest"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(106, 154, 122, 0.3); +} + +[data-mm-theme="rose"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(176, 138, 144, 0.3); +} + +[data-mm-theme="slate"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(122, 138, 152, 0.3); +} + +[data-mm-theme="starry-purple"] .mm-author-section:hover { + box-shadow: 0 0 12px rgba(157, 124, 216, 0.4); +} + +[data-mm-theme="starry-blue"] .mm-author-section:hover { + box-shadow: 0 0 12px rgba(93, 143, 202, 0.4); +} + +[data-mm-theme="starry-black"] .mm-author-section:hover { + box-shadow: 0 0 8px rgba(136, 136, 136, 0.3); +} + +.mm-author-info { + text-align: center; + font-size: 13px; + color: var(--mm-primary); + font-style: italic; + display: flex; + align-items: center; + justify-content: center; + gap: 8px; +} + +/* 作者文字流光特效 */ +.mm-author-text { + background: linear-gradient( + 90deg, + var(--mm-primary) 0%, + var(--mm-primary-light) 25%, + var(--mm-text) 50%, + var(--mm-primary-light) 75%, + var(--mm-primary) 100% + ); + background-size: 200% 100%; + -webkit-background-clip: text; + background-clip: text; + -webkit-text-fill-color: transparent; + animation: mm-shimmer 3s ease-in-out infinite; +} + +@keyframes mm-shimmer { + 0% { + background-position: 200% 0; + } + 100% { + background-position: -200% 0; + } +} + +/* 猫爪按钮 */ +.mm-paw-btn { + display: inline-flex; + align-items: center; + justify-content: center; + width: 26px; + height: 26px; + border: none; + border-radius: 50%; + background: var(--mm-bg-secondary); + cursor: pointer; + font-size: 14px; + transition: all 0.2s ease; + padding: 0; + line-height: 1; +} + +.mm-paw-btn:hover { + transform: scale(1.15); + background: var(--mm-bg); +} + +.mm-paw-btn:active { + transform: scale(0.95); +} + +/* 花朵容器 */ +.mm-flower-container { + position: absolute; + left: 0; + right: 0; + top: 100%; + height: 150px; + pointer-events: none; + overflow: visible; +} + +/* 飘落的花朵 */ +.mm-falling-flower { + position: absolute; + font-size: 20px; + animation: mm-flower-fall 2.5s ease-out forwards; + pointer-events: none; + z-index: 100; +} + +@keyframes mm-flower-fall { + 0% { + opacity: 1; + transform: translateY(0) rotate(0deg) scale(0.5); + } + 30% { + opacity: 1; + transform: translateY(-100px) rotate(-20deg) scale(1.1); + } + 100% { + opacity: 0; + transform: translateY(-30px) rotate(60deg) scale(0.7); + } +} + +/* 爱你哟文字 */ +.mm-love-text { + position: absolute; + left: 50%; + top: 0; + transform: translateX(-50%); + font-size: 16px; + font-weight: bold; + color: #ff6b9d; + white-space: nowrap; + animation: mm-love-float 2s ease-out forwards; + pointer-events: none; + z-index: 101; + text-shadow: 0 0 10px rgba(255, 107, 157, 0.5); +} + +@keyframes mm-love-float { + 0% { + opacity: 1; + transform: translateX(-50%) translateY(0) scale(1); + } + 50% { + opacity: 1; + transform: translateX(-50%) translateY(-100px) scale(1.2); + } + 100% { + opacity: 0; + transform: translateX(-50%) translateY(-150px) scale(0.8); + } +} + +/* 警告文字 */ +.mm-love-text.mm-warning-text { + color: #ffa500; + text-shadow: 0 0 10px rgba(255, 165, 0, 0.5); +} + +/* 更新状态列表 */ +.mm-updates-list { + max-height: 120px; + overflow-y: auto; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + padding: 8px; +} + +.mm-empty-hint { + font-size: 12px; + color: var(--mm-text-muted); + text-align: center; + padding: 8px; +} + +.mm-update-item { + display: flex; + align-items: flex-start; + gap: 8px; + padding: 6px 8px; + font-size: 12px; + color: var(--mm-text); + border-radius: 4px; + margin-bottom: 4px; + background: var(--mm-bg-secondary); +} + +.mm-update-item:last-child { + margin-bottom: 0; +} + +.mm-update-item.mm-update-add { + border-left: 2px solid var(--mm-success); +} + +.mm-update-item.mm-update-change { + border-left: 2px solid var(--mm-primary); +} + +.mm-update-item.mm-update-chars { + border-left: 2px solid var(--mm-warning); +} + +.mm-update-item.mm-update-delete { + border-left: 2px solid var(--mm-danger); +} + +.mm-update-category { + font-weight: 600; + color: var(--mm-primary); + white-space: nowrap; +} + +.mm-update-text { + flex: 1; + color: var(--mm-text-muted); + word-break: break-all; +} + +.mm-update-text .mm-highlight { + color: var(--mm-text); + font-weight: 500; +} + +.mm-update-time { + font-size: 10px; + color: var(--mm-text-muted); + white-space: nowrap; +} + +/* ============================================================================ + 设置面板 + ============================================================================ */ + +.mm-settings { + position: fixed; + right: -400px; + top: 0; + width: 380px; + height: 100vh; + background: var(--mm-bg); + border-left: 1px solid var(--mm-border); + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); + z-index: 1001; + display: flex; + flex-direction: column; + transition: var(--mm-transition); + border-radius: 0; +} + +.mm-settings-visible { + right: 0; +} + +.mm-settings-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px; + border-bottom: 1px solid var(--mm-border); + background: var(--mm-bg-secondary); + border-radius: 0; + overflow: hidden; +} + +.mm-settings-header h3 { + margin: 0; + font-size: 16px; + color: var(--mm-text); +} + +.mm-settings-content { + flex: 1; + overflow-y: auto; + padding: 16px; + padding-bottom: 32px; + min-height: 0; + -webkit-overflow-scrolling: touch; +} + +.mm-settings-section { + margin-bottom: 24px; +} + +.mm-settings-section h4 { + margin: 0 0 12px 0; + font-size: 14px; + color: var(--mm-primary); + border-bottom: 1px solid var(--mm-border); + padding-bottom: 8px; +} + +.mm-setting-item { + margin-bottom: 12px; +} + +.mm-setting-item label { + display: flex; + align-items: center; + gap: 8px; + font-size: 14px; + color: var(--mm-text); + cursor: pointer; +} + +.mm-checkbox-grid { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 12px; + margin-bottom: 12px; +} + +.mm-input-row { + display: flex; + gap: 20px; + margin-bottom: 12px; + align-items: center; +} + +.mm-input-row .mm-setting-item { + flex: 1; + margin-bottom: 0; + display: flex; + align-items: center; + justify-content: space-between; +} + +.mm-setting-item input[type="number"] { + width: 100px; + padding: 6px 10px; + border: 1px solid var(--mm-border); + border-radius: 4px; + background: var(--mm-bg-card); + color: var(--mm-text); +} + +.mm-input-row .mm-setting-item input[type="number"] { + width: 80px; + margin-left: auto; +} + +.mm-slider-row { + display: flex; + align-items: center; + gap: 12px; + margin-top: 6px; +} + +.mm-slider-row input[type="range"] { + flex: 1; + height: 6px; + -webkit-appearance: none; + appearance: none; + background: var(--mm-bg-card); + border-radius: 3px; + cursor: pointer; +} + +.mm-slider-row input[type="range"]::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 16px; + height: 16px; + border-radius: 50%; + background: var(--mm-primary); + cursor: pointer; + transition: var(--mm-transition); +} + +.mm-slider-row input[type="range"]::-webkit-slider-thumb:hover { + background: var(--mm-primary-dark); + transform: scale(1.1); +} + +.mm-slider-row span { + min-width: 24px; + text-align: center; + font-weight: bold; + color: var(--mm-primary); +} + +.mm-setting-actions { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +/* 配置管理按钮统一宽度 */ +.mm-setting-actions .mm-btn { + min-width: 120px; +} + +/* AI 配置操作按钮 */ +.mm-ai-config-actions { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-top: 12px; +} + +.mm-ai-config-actions .mm-btn { + flex: 1; + min-width: 100px; +} + +.mm-settings-footer { + padding: 16px; + border-top: 1px solid var(--mm-border); + display: flex; + justify-content: flex-end; + flex-shrink: 0; +} + +/* AI 配置列表 */ +.mm-ai-config-list { + max-height: 200px; + overflow-y: auto; + margin-bottom: 12px; +} + +.mm-ai-config-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 12px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + margin-bottom: 8px; +} + +.mm-config-info { + display: flex; + align-items: center; + gap: 8px; + flex: 1; + overflow: hidden; +} + +.mm-config-name { + font-size: 14px; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-config-model { + font-size: 12px; + color: var(--mm-text-muted); + margin-left: auto; + padding-right: 12px; +} + +.mm-config-group-title { + font-size: 12px; + color: var(--mm-primary); + font-weight: bold; + margin-bottom: 8px; + padding-bottom: 4px; + border-bottom: 1px solid var(--mm-border); +} + +.mm-config-actions { + display: flex; + gap: 4px; +} + +/* ============================================================================ + 弹窗 + ============================================================================ */ + +.mm-modal { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: transparent; + display: none; + align-items: center; + justify-content: center; + z-index: 1100; + pointer-events: none; +} + +.mm-modal-visible { + display: flex; +} + +.mm-modal-content { + width: 500px; + max-width: 90vw; + max-height: 90vh; + background: var(--mm-bg); + border-radius: var(--mm-radius); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); + display: flex; + flex-direction: column; + pointer-events: auto; +} + +.mm-modal-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px; + border-bottom: 1px solid var(--mm-border); +} + +.mm-modal-header h4 { + margin: 0; + font-size: 16px; + color: var(--mm-text); +} + +.mm-modal-body { + flex: 1; + overflow-y: auto; + padding: 16px; +} + +.mm-modal-footer { + display: flex; + justify-content: flex-end; + gap: 8px; + padding: 16px; + border-top: 1px solid var(--mm-border); +} + +/* 表单 */ +.mm-form-group { + margin-bottom: 16px; +} + +.mm-form-group > label { + display: block; + margin-bottom: 6px; + font-size: 14px; + color: var(--mm-text); +} + +.mm-form-group input[type="text"], +.mm-form-group input[type="password"], +.mm-form-group input[type="number"], +.mm-form-group textarea, +.mm-form-group select { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--mm-border); + border-radius: 4px; + background: var(--mm-bg-card); + color: var(--mm-text); + font-size: 14px; + box-sizing: border-box; +} + +.mm-form-group input:focus, +.mm-form-group textarea:focus { + outline: none; + border-color: var(--mm-primary); +} + +.mm-form-group textarea { + resize: vertical; + font-family: monospace; +} + +.mm-form-row { + display: flex; + gap: 16px; +} + +.mm-form-row .mm-form-group { + flex: 1; +} + +.mm-radio-group { + display: flex; + flex-wrap: wrap; + gap: 12px; +} + +.mm-radio-group label { + display: flex; + align-items: center; + gap: 4px; + font-size: 13px; + color: var(--mm-text); + cursor: pointer; +} + +/* 测试结果 */ +.mm-test-result { + margin-left: 12px; + font-size: 13px; +} + +.mm-test-success { + color: var(--mm-success); +} + +.mm-test-error { + color: var(--mm-danger); +} + +/* ============================================================================ + 滚动条 + ============================================================================ */ + +.mm-panel ::-webkit-scrollbar, +.mm-settings ::-webkit-scrollbar, +.mm-modal ::-webkit-scrollbar { + width: 6px; +} + +.mm-panel ::-webkit-scrollbar-track, +.mm-settings ::-webkit-scrollbar-track, +.mm-modal ::-webkit-scrollbar-track { + background: var(--mm-bg-secondary); +} + +.mm-panel ::-webkit-scrollbar-thumb, +.mm-settings ::-webkit-scrollbar-thumb, +.mm-modal ::-webkit-scrollbar-thumb { + background: var(--mm-border); + border-radius: 3px; +} + +.mm-panel ::-webkit-scrollbar-thumb:hover, +.mm-settings ::-webkit-scrollbar-thumb:hover, +.mm-modal ::-webkit-scrollbar-thumb:hover { + background: var(--mm-primary); +} + +/* ============================================================================ + 悬浮球(可选,通过设置开关)- 柔和淡粉小花朵(缩小1/2) + ============================================================================ */ + +.mm-float-ball { + position: fixed; + bottom: 20px; + left: 15px; + width: 28px; + height: 28px; + cursor: pointer; + z-index: 9999; + user-select: none; + touch-action: none; + transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), + filter 0.3s ease; +} + +/* 花朵容器 */ +.mm-float-ball-inner { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + transition: transform 0.3s ease; +} + +/* 花瓣基础样式 */ +.mm-float-ball-petal { + position: absolute; + transition: all 0.3s ease; +} + +/* 外层花瓣 - 柔和淡紫粉 */ +.mm-float-ball-petal.mm-petal-outer { + width: 10px; + height: 14px; + border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; + z-index: 1; +} + +/* 中层花瓣 - 柔和淡粉 */ +.mm-float-ball-petal.mm-petal-mid { + width: 7.5px; + height: 9.75px; + border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; + z-index: 2; +} + +/* 内层花瓣 - 浅粉白 */ +.mm-float-ball-petal.mm-petal-inner { + width: 5px; + height: 6px; + border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; + z-index: 3; +} + +/* 花心 - 柔和暖黄 */ +.mm-float-ball-center { + position: absolute; + width: 9px; + height: 9px; + border-radius: 50%; + background: radial-gradient(circle at 40% 40%, + rgba(255, 245, 210, 1) 0%, + rgba(255, 225, 170, 0.9) 40%, + rgba(245, 200, 140, 0.85) 100%); + box-shadow: 0 0 5px rgba(255, 220, 160, 0.5), + inset 0 1px 2px rgba(255, 250, 230, 0.7); + z-index: 10; + display: flex; + align-items: center; + justify-content: center; +} + +/* 柔和花蕊小点 */ +.mm-float-ball-stamen { + position: absolute; + width: 2px; + height: 2px; + border-radius: 50%; + background: radial-gradient(circle, + rgba(255, 248, 220, 1) 0%, + rgba(255, 230, 160, 1) 100%); + box-shadow: 0 0 2px rgba(255, 235, 180, 0.6); + z-index: 11; +} + +/* 外圈光晕 - 柔和淡粉 */ +.mm-float-ball-ring { + position: absolute; + inset: -4px; + border-radius: 50%; + background: radial-gradient(circle, rgba(255, 210, 230, 0.35) 0%, rgba(230, 200, 220, 0.18) 50%, transparent 70%); + opacity: 0.5; + transition: opacity 0.3s ease, transform 0.3s ease; + animation: mm-flower-glow 3s ease-in-out infinite; +} + +@keyframes mm-flower-glow { + 0%, 100% { opacity: 0.4; transform: scale(1); } + 50% { opacity: 0.6; transform: scale(1.05); } +} + +.mm-float-ball:hover { + transform: scale(1.15); + filter: brightness(1.05) saturate(1.1); +} + +.mm-float-ball:hover .mm-float-ball-inner { + animation: mm-flower-spin 8s linear infinite; +} + +@keyframes mm-flower-spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } +} + +.mm-float-ball:hover .mm-float-ball-center { + animation: mm-center-counter-spin 8s linear infinite; +} + +@keyframes mm-center-counter-spin { + from { transform: rotate(0deg); } + to { transform: rotate(-360deg); } +} + +.mm-float-ball:hover .mm-float-ball-ring { + opacity: 0.8; + transform: scale(1.1); +} + +.mm-float-ball:active { + transform: scale(0.92); +} + +.mm-float-ball.mm-dragging { + transition: none; +} + +.mm-float-ball.mm-dragging .mm-float-ball-inner { + opacity: 0.85; +} + +/* 状态指示点 - 隐藏 */ +.mm-float-ball.mm-enabled::after, +.mm-float-ball.mm-disabled::after { + display: none; +} + +/* ============================================================================ */ +/* 提示词编辑器样式 */ +/* ============================================================================ */ + +/* 扩展模态框大小 */ +.mm-modal-large { + width: 800px; + max-width: 90vw; +} + +/* 模态框底部按钮布局 */ +.mm-modal-footer { + justify-content: space-between; +} + +.mm-modal-actions-left, +.mm-modal-actions-right { + display: flex; + gap: 8px; + flex-wrap: wrap; +} + +/* 提示词编辑器按钮统一样式 */ +#mm-prompt-editor-modal .mm-modal-footer .mm-btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 14px; + font-size: 13px; + white-space: nowrap; +} + +/* 提示词选择框样式 */ +.mm-prompt-select { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--mm-border); + border-radius: 4px; + background: var(--mm-bg-card); + color: var(--mm-text); + font-size: 14px; + box-sizing: border-box; +} + +/* 提示词类型切换标签 */ +.mm-prompt-type-tabs { + display: flex; + gap: 8px; + margin-bottom: 5px; +} + +.mm-tab-btn { + flex: 1; + padding: 10px 16px; + border: 1px solid var(--mm-border); + border-radius: var(--mm-radius); + background: var(--mm-bg-card); + color: var(--mm-text-muted); + font-size: 13px; + cursor: pointer; + transition: var(--mm-transition); + display: flex; + align-items: center; + justify-content: center; + gap: 6px; +} + +.mm-tab-btn:hover { + background: var(--mm-bg-secondary); + color: var(--mm-text); +} + +.mm-tab-btn.mm-tab-active { + background: var(--mm-primary); + border-color: var(--mm-primary); + color: white; +} + +/* 可调整大小的编辑器容器 */ +.mm-resizable-editor-container { + position: relative; + width: 100%; + min-height: 300px; +} + +/* 提示词编辑器样式 */ +.mm-prompt-editor { + width: 100%; + height: 300px; + min-height: 150px; + padding: 15px; + border: 1px solid var(--mm-border); + border-radius: 4px 4px 0 0; + background: var(--mm-bg-card); + color: var(--mm-text); + font-size: 14px; + font-family: monospace; + resize: none; + line-height: 1.5; + box-sizing: border-box; + overflow: auto; +} + +.mm-prompt-editor:focus { + outline: none; + border-color: var(--mm-primary); + box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); +} + +/* 调整大小的手柄 - 底部横条样式 */ +.mm-resize-handle { + position: relative; + width: 100%; + height: 8px; + cursor: ns-resize; + background: var(--mm-border); + border-radius: 0 0 4px 4px; + display: flex; + align-items: center; + justify-content: center; + transition: background 0.2s ease; +} + +.mm-resize-handle::after { + content: ""; + width: 40px; + height: 3px; + background: var(--mm-text-muted); + border-radius: 2px; + opacity: 0.5; +} + +.mm-resize-handle:hover { + background: var(--mm-primary); +} + +.mm-float-ball.mm-processing::after { + display: none; +} + +.mm-float-ball.mm-processing .mm-float-ball-inner i { + animation: mm-float-spin 1.5s linear infinite; +} + +.mm-float-ball.mm-processing .mm-float-ball-ring { + opacity: 1; + animation: mm-ring-pulse 1.5s ease-in-out infinite; +} + +@keyframes mm-float-pulse { + 0%, + 100% { + transform: scale(1); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); + } + 50% { + transform: scale(1.15); + box-shadow: 0 2px 8px rgba(234, 179, 8, 0.5); + } +} + +@keyframes mm-float-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@keyframes mm-ring-pulse { + 0%, + 100% { + transform: scale(1); + opacity: 0.6; + } + 50% { + transform: scale(1.1); + opacity: 1; + } +} + +/* 移动端适配 */ +@media (max-width: 768px) { + .mm-panel { + width: 75%; + right: -75%; + z-index: 999999; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-panel-visible { + right: 0; + } + + .mm-settings { + width: 75%; + right: -75%; + z-index: 1000000; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-settings-visible { + right: 0; + } + + .mm-modal { + z-index: 1000001; + padding: 16px; + box-sizing: border-box; + align-items: center; + justify-content: center; + } + + .mm-modal-visible { + display: flex; + } + + .mm-modal-content { + width: calc(100vw - 32px); + max-width: 95vw; + max-height: 85vh; + margin: auto; + position: relative; + top: 0; + left: 0; + transform: none; + } + + .mm-panel-header { + padding: 12px 16px; + } + + .mm-panel-header h3 { + font-size: 14px; + } + + #mm-panel-close-btn { + background: var(--mm-danger); + color: white; + } + + #mm-panel-close-btn:hover { + background: #a71d2a; + } + + .mm-float-ball { + width: 24px; + height: 24px; + bottom: 80px; + left: 12px; + z-index: 2147483647 !important; + } + + .mm-float-ball-center { + width: 7px; + height: 7px; + } + + .mm-float-ball-stamen { + width: 1.5px; + height: 1.5px; + } + + .mm-float-ball-ring { + inset: -3px; + } +} + +@media (max-width: 480px) { + .mm-panel { + width: 75%; + right: -75%; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-panel-visible { + right: 0; + } + + .mm-settings { + width: 75%; + right: -75%; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-settings-visible { + right: 0; + } + + .mm-modal { + padding: 12px; + } + + .mm-modal-content { + width: calc(100vw - 24px); + max-height: 80vh; + } + + .mm-modal-body { + padding: 12px; + max-height: calc(80vh - 120px); + overflow-y: auto; + } + + .mm-panel-content { + padding: 8px; + } + + .mm-category-card { + padding: 8px; + margin-top: 6px; + } + + .mm-category-header { + margin-bottom: 4px; + } + + .mm-category-name { + font-size: 12px; + } + + .mm-category-type { + font-size: 9px; + padding: 1px 4px; + } + + .mm-category-stats { + gap: 4px 8px; + margin-bottom: 6px; + } + + .mm-stat { + font-size: 10px; + gap: 2px; + } + + .mm-stat i { + font-size: 9px; + } + + .mm-btn-sm { + padding: 4px 8px; + font-size: 10px; + } + + .mm-section-title { + font-size: 12px; + } + + .mm-book-name { + font-size: 12px; + } + + .mm-float-ball { + width: 22px; + height: 22px; + bottom: 70px; + left: 10px; + z-index: 2147483647 !important; + } + + .mm-float-ball-center { + width: 6px; + height: 6px; + } + + .mm-float-ball-stamen { + width: 1px; + height: 1px; + } + + .mm-float-ball-ring { + inset: -2.5px; + } +} + +/* 横屏模式 */ +@media (max-height: 500px) and (orientation: landscape) { + .mm-panel { + width: 75%; + right: -75%; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-panel-visible { + right: 0; + } + + .mm-settings { + width: 75%; + right: -75%; + top: 0; + height: 100vh; + border-radius: 0; + } + + .mm-settings-visible { + right: 0; + } +} + +/* 平板竖屏模式适配 - 确保弹窗垂直居中 */ +@media (min-width: 481px) and (max-width: 1024px) and (orientation: portrait) { + /* 通用弹窗居中 */ + .mm-modal { + display: none; + align-items: center !important; + justify-content: center !important; + } + + .mm-modal.mm-modal-visible { + display: flex !important; + } + + .mm-modal-content { + margin: auto; + position: relative; + top: 0; + left: 0; + transform: none; + max-height: 85vh; + } + + /* 搜索面板 - 平板竖屏 */ + .mm-search-panel:not(.mm-dragging) { + top: 60px; + left: 16px; + right: auto; + transform: none; + } + + .mm-search-panel.mm-visible { + animation: mm-search-panel-in 0.3s ease-out; + } + + /* 剧情优化面板 - 平板竖屏 */ + .mm-plot-panel:not(.mm-dragging) { + top: 60px; + right: 16px; + left: auto; + transform: none; + } + + .mm-plot-panel.mm-visible { + animation: mm-plot-panel-in 0.3s ease-out; + } +} + +/* ============================================================================ + 世界书选择器弹窗 + ============================================================================ */ + +.mm-worldbook-selector { + width: 550px; +} + +.mm-worldbook-selector .mm-modal-header h3 { + margin: 0; + font-size: 16px; + color: var(--mm-text); +} + +.mm-modal-close { + background: none; + border: none; + color: var(--mm-text-muted); + font-size: 24px; + cursor: pointer; + padding: 0; + line-height: 1; +} + +.mm-modal-close:hover { + color: var(--mm-text); +} + +.mm-selector-hint { + display: flex; + align-items: center; + gap: 8px; + padding: 10px 12px; + background: var(--mm-bg-secondary); + border-radius: var(--mm-radius); + color: var(--mm-text-muted); + font-size: 13px; + margin-bottom: 16px; +} + +.mm-selector-hint i { + color: var(--mm-primary); +} + +.mm-selector-list { + max-height: 600px; + overflow-y: auto; +} + +.mm-selector-item { + display: flex; + align-items: center; + gap: 12px; + padding: 12px 14px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + margin-bottom: 8px; + cursor: pointer; + transition: var(--mm-transition); +} + +.mm-selector-item:hover { + background: var(--mm-bg-secondary); +} + +.mm-selector-item input[type="checkbox"] { + display: none; +} + +.mm-selector-checkbox { + width: 20px; + height: 20px; + border: 2px solid var(--mm-border); + border-radius: 4px; + display: flex; + align-items: center; + justify-content: center; + transition: var(--mm-transition); + flex-shrink: 0; +} + +.mm-selector-item input[type="checkbox"]:checked + .mm-selector-checkbox { + background: var(--mm-primary); + border-color: var(--mm-primary); +} + +.mm-selector-item + input[type="checkbox"]:checked + + .mm-selector-checkbox::after { + content: "✓"; + color: white; + font-size: 14px; + font-weight: bold; +} + +.mm-selector-name { + flex: 1; + font-size: 14px; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-selector-type { + padding: 3px 8px; + border-radius: 4px; + font-size: 11px; + font-weight: bold; + text-transform: uppercase; +} + +.mm-type-memory { + background: rgba(74, 144, 217, 0.2); + color: var(--mm-primary); +} + +.mm-type-summary { + background: rgba(40, 167, 69, 0.2); + color: var(--mm-success); +} + +.mm-loading { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + padding: 40px; + color: var(--mm-text-muted); + font-size: 14px; +} + +.mm-loading i { + font-size: 18px; +} + +/* ============================================================================ + 分类卡片样式(紧凑标签式) + ============================================================================ */ + +.mm-book-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; +} + +/* 世界书卡片 */ +.mm-book-card { + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + padding: 14px; + margin-bottom: 12px; +} + +.mm-book-title { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 12px; + padding-bottom: 10px; + border-bottom: 1px solid var(--mm-border); +} + +.mm-book-title .mm-book-name { + font-size: 14px; + font-weight: 600; + color: var(--mm-text); +} + +/* 分类标签容器 */ +.mm-chips-container { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +/* 分类标签 */ +.mm-chip { + position: relative; + display: inline-flex; + align-items: center; + gap: 6px; + padding: 6px 12px; + background: var(--mm-bg-secondary); + border-radius: 6px; + font-size: 13px; + color: var(--mm-text); + cursor: pointer; + transition: all 0.2s ease; + border: 1px solid transparent; +} + +.mm-chip:hover { + background: var(--mm-bg); + border-color: var(--mm-primary); +} + +.mm-chip-ok { + border-left: 3px solid var(--mm-success); +} + +.mm-chip-warning { + border-left: 3px solid var(--mm-warning); +} + +.mm-chip-name { + font-weight: 500; +} + +.mm-chip-count { + font-size: 11px; + padding: 2px 6px; + background: rgba(74, 144, 217, 0.15); + color: var(--mm-primary); + border-radius: 10px; + font-weight: 600; +} + +/* 兼容旧样式 */ +.mm-category-card { + background: var(--mm-bg-secondary); + border-radius: var(--mm-radius); + padding: 12px; + margin-top: 8px; + border-left: 3px solid var(--mm-border); + transition: var(--mm-transition); +} + +.mm-category-card:hover { + background: var(--mm-bg-card); +} + +.mm-category-card.mm-config-ok { + border-left-color: var(--mm-success); +} + +.mm-category-card.mm-config-missing { + border-left-color: var(--mm-warning); +} + +.mm-category-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 8px; +} + +.mm-category-name { + font-size: 14px; + font-weight: bold; + color: var(--mm-text); +} + +.mm-category-type { + font-size: 11px; + padding: 2px 6px; + border-radius: 4px; + background: rgba(74, 144, 217, 0.2); + color: var(--mm-primary); +} + +.mm-category-stats { + display: flex; + flex-wrap: wrap; + gap: 12px; + margin-bottom: 10px; +} + +.mm-stat { + display: flex; + align-items: center; + gap: 4px; + font-size: 12px; + color: var(--mm-text-muted); +} + +.mm-stat i { + font-size: 11px; + color: var(--mm-primary); +} + +.mm-btn-sm { + padding: 6px 12px; + font-size: 12px; +} + +/* 模型输入行 */ +.mm-model-input-row { + display: flex; + gap: 8px; + align-items: center; +} + +.mm-model-input-row input[type="text"], +.mm-model-input-row select { + flex: 1; + min-width: 0; +} + +.mm-model-select { + padding: 10px 12px; + border: 1px solid var(--mm-border); + border-radius: 4px; + background: var(--mm-bg-card); + color: var(--mm-text); + font-size: 14px; + cursor: pointer; +} + +.mm-model-select:focus { + outline: none; + border-color: var(--mm-primary); +} + +.mm-model-select option { + background: var(--mm-bg-card); + color: var(--mm-text); +} + +.mm-model-input-row .mm-btn { + flex-shrink: 0; + white-space: nowrap; +} + +#mm-fetch-models.mm-loading-models { + pointer-events: none; + opacity: 0.7; +} + +#mm-fetch-models.mm-loading-models i { + animation: spin 1s linear infinite; +} + +@keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +/* ============================================================================ + 进度条样式 + ============================================================================ */ + +.mm-status-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 8px; +} + +.mm-status-summary { + font-size: 13px; + color: var(--mm-primary); + font-weight: bold; +} + +.mm-progress-list { + max-height: 200px; + overflow-y: auto; + margin-bottom: 12px; + border-top: 1px solid var(--mm-border); + padding-top: 10px; +} + +.mm-progress-item { + display: flex; + flex-direction: column; + gap: 6px; + padding: 8px 10px; + background: var(--mm-bg-secondary); + border-radius: 6px; + margin-bottom: 8px; + border-left: 3px solid var(--mm-border); + transition: border-color 0.3s ease; +} + +.mm-progress-item.mm-progress-pending { + border-left-color: var(--mm-secondary); +} + +.mm-progress-item.mm-progress-running { + border-left-color: var(--mm-primary); +} + +.mm-progress-item.mm-progress-success { + border-left-color: var(--mm-success); +} + +.mm-progress-item.mm-progress-error { + border-left-color: var(--mm-danger); +} + +.mm-progress-item.mm-progress-retrying { + border-left-color: var(--mm-warning); +} + +.mm-progress-header { + display: flex; + align-items: center; + justify-content: space-between; +} + +.mm-progress-name { + font-size: 13px; + color: var(--mm-text); + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-progress-actions { + display: flex; + align-items: center; + gap: 8px; +} + +.mm-btn-stop-task { + display: flex; + align-items: center; + justify-content: center; + width: 20px; + height: 20px; + border: none; + border-radius: 4px; + background: rgba(220, 53, 69, 0.2); + color: var(--mm-danger); + cursor: pointer; + transition: all 0.2s ease; + padding: 0; +} + +.mm-btn-stop-task:hover { + background: var(--mm-danger); + color: white; + transform: scale(1.1); +} + +.mm-btn-stop-task i { + font-size: 10px; +} + +.mm-progress-status { + font-size: 11px; + padding: 2px 6px; + border-radius: 4px; + font-weight: bold; +} + +.mm-progress-status.pending { + background: rgba(108, 117, 125, 0.2); + color: var(--mm-secondary); +} + +.mm-progress-status.running { + background: rgba(74, 144, 217, 0.2); + color: var(--mm-primary); +} + +.mm-progress-status.success { + background: rgba(40, 167, 69, 0.2); + color: var(--mm-success); +} + +.mm-progress-status.error { + background: rgba(220, 53, 69, 0.2); + color: var(--mm-danger); +} + +.mm-progress-status.retrying { + background: rgba(255, 193, 7, 0.2); + color: var(--mm-warning); +} + +.mm-progress-bar-container { + width: 100%; + height: 6px; + background: var(--mm-bg-card); + border-radius: 3px; + overflow: hidden; +} + +.mm-progress-bar { + height: 100%; + border-radius: 3px; + transition: width 0.2s ease-out, background 0.3s ease; + background: linear-gradient( + 90deg, + var(--mm-primary) 0%, + var(--mm-primary-dark) 100% + ); +} + +.mm-progress-bar.success { + background: linear-gradient(90deg, var(--mm-success) 0%, #1e7e34 100%); +} + +.mm-progress-bar.error { + background: linear-gradient(90deg, var(--mm-danger) 0%, #a71d2a 100%); +} + +.mm-progress-bar.retrying { + background: linear-gradient(90deg, var(--mm-warning) 0%, #d39e00 100%); +} + +.mm-progress-detail { + font-size: 11px; + color: var(--mm-text-muted); + display: flex; + align-items: center; + gap: 8px; +} + +.mm-progress-detail .retry-count { + color: var(--mm-warning); +} + +.mm-progress-detail .error-msg { + color: var(--mm-danger); + font-size: 10px; + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-progress-detail .time { + margin-left: auto; +} + +/* 终止按钮动画 */ +#mm-stop-btn { + transition: all 0.3s ease; +} + +#mm-stop-btn:not(.mm-hidden) { + animation: pulse-danger 1.5s infinite; +} + +@keyframes pulse-danger { + 0%, + 100% { + box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); + } + 50% { + box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); + } +} + +/* 处理中状态 */ +.mm-status-panel.processing .mm-status-info { + opacity: 0.7; +} + +/* 注意事项样式 */ +.mm-important-notice { + background-color: #fff3cd; + border: 1px solid #ffeeba; + border-radius: 6px; + padding: 15px; + margin-bottom: 20px; +} + +.mm-notice-header { + display: flex; + align-items: center; + margin-bottom: 10px; + font-weight: bold; + color: #856404; +} + +.mm-notice-header i { + margin-right: 8px; + font-size: 18px; +} + +.mm-notice-list { + margin: 0; + padding-left: 20px; + color: #856404; +} + +.mm-notice-list li { + margin-bottom: 8px; + line-height: 1.5; +} + +.mm-notice-list code { + background-color: rgba(0, 0, 0, 0.05); + padding: 2px 4px; + border-radius: 3px; + font-family: "Consolas", "Monaco", "Courier New", monospace; + font-size: 14px; + white-space: nowrap; +} + +/* ============================================================================ + 标签过滤折叠卡片 + ============================================================================ */ + +.mm-collapse-card { + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + margin-top: 16px; + overflow: hidden; + border: 1px solid var(--mm-border); + transition: var(--mm-transition); +} + +.mm-collapse-card:hover { + border-color: var(--mm-primary); +} + +.mm-collapse-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 14px; + cursor: pointer; + user-select: none; + transition: background 0.2s ease; +} + +.mm-collapse-header:hover { + background: var(--mm-bg-secondary); +} + +.mm-collapse-title { + display: flex; + align-items: center; + gap: 10px; + font-size: 13px; + font-weight: 500; + color: var(--mm-text); +} + +.mm-collapse-title i { + color: var(--mm-primary); + font-size: 14px; +} + +.mm-collapse-badge { + font-size: 11px; + padding: 2px 8px; + border-radius: 10px; + background: var(--mm-bg-secondary); + color: var(--mm-text-muted); + font-weight: normal; +} + +.mm-collapse-badge.active { + background: rgba(74, 144, 217, 0.2); + color: var(--mm-primary); +} + +.mm-collapse-arrow { + font-size: 12px; + color: var(--mm-text-muted); + transition: transform 0.3s ease; +} + +.mm-collapse-card.expanded .mm-collapse-arrow { + transform: rotate(180deg); +} + +.mm-collapse-body { + max-height: 0; + overflow: hidden; + transition: max-height 0.3s ease, padding 0.3s ease; + padding: 0 14px; +} + +.mm-collapse-card.expanded .mm-collapse-body { + overflow-y: auto; + max-height: 600px; + padding: 14px; +} + +/* ============================================================================ + 索引模式内容区 + ============================================================================ */ + +.mm-index-mode-content { + display: flex; + flex-direction: column; + gap: 8px; +} + +/* ============================================================================ + 消息右侧进度面板 + ============================================================================ */ + +.mm-message-progress-panel { + position: fixed; + left: 50%; + top: 80px; + transform: translateX(-50%); + width: 320px; + max-height: 600px; + background: var(--mm-bg); + backdrop-filter: blur(15px); + border: 1px solid var(--mm-border); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6); + z-index: 9999; + overflow: hidden; + opacity: 0; + pointer-events: none; + transition: opacity 0.4s ease; + user-select: none; +} + +.mm-message-progress-panel.mm-visible { + opacity: 1; + pointer-events: auto; + animation: mm-panel-fade-in 0.4s ease-out; +} + +.mm-message-progress-panel.mm-hiding { + opacity: 0; +} + +/* 拖动状态 */ +.mm-message-progress-panel.mm-dragging { + opacity: 0.9; + transition: none !important; + cursor: grabbing; + box-shadow: 0 12px 48px rgba(0, 0, 0, 0.8); +} + +@keyframes mm-panel-fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + +/* 面板头部 */ +.mm-msg-panel-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 14px; + background: var(--mm-bg-secondary); + border-bottom: 1px solid var(--mm-border); + border-radius: var(--mm-radius) var(--mm-radius) 0 0; + cursor: grab; + touch-action: none; +} + +.mm-msg-panel-header:active { + cursor: grabbing; +} + +/* 拖动手柄图标 */ +.mm-drag-handle { + font-size: 12px; + color: var(--mm-text-muted); + margin-right: 4px; + transition: color 0.2s ease; +} + +.mm-msg-panel-header:hover .mm-drag-handle { + color: var(--mm-text); +} + +.mm-msg-panel-title { + font-size: 13px; + font-weight: 600; + color: var(--mm-text); + display: flex; + align-items: center; + gap: 8px; +} + +/* 面板控制按钮 */ +.mm-msg-panel-controls { + display: flex; + align-items: center; + gap: 4px; +} + +.mm-msg-minimize-btn { + width: 32px; + height: 32px; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + background: transparent; + border: none; + color: var(--mm-text-muted); + cursor: pointer; + border-radius: 4px; + transition: all 0.2s ease; + position: relative; + z-index: 10; +} + +.mm-msg-minimize-btn:hover { + background: var(--mm-bg-hover); + color: var(--mm-text); +} + +/* 面板内容 */ +.mm-msg-panel-content { + max-height: 300px; + overflow-y: auto; + padding: 10px; + transition: max-height 0.3s ease; + background: var(--mm-bg-secondary); +} + +.mm-message-progress-panel.mm-collapsed .mm-msg-panel-content { + max-height: 0; + padding: 0 10px; + overflow: hidden; +} + +/* 单个进度项 */ +.mm-msg-progress-item { + display: flex; + flex-direction: column; + gap: 6px; + padding: 10px 12px; + background: var(--mm-bg-card); + border-radius: 8px; + margin-bottom: 8px; + border-left: none; + transition: all 0.3s ease; +} + +.mm-msg-progress-item:last-child { + margin-bottom: 0; +} + +.mm-msg-progress-item.mm-success { + background: var(--mm-bg-card); +} + +.mm-msg-progress-item.mm-error { + background: rgba(220, 53, 69, 0.15); +} + +.mm-msg-progress-item.mm-fading { + animation: mm-fade-out 3s ease forwards; +} + +@keyframes mm-fade-out { + 0% { opacity: 1; } + 70% { opacity: 1; } + 100% { opacity: 0; } +} + +.mm-msg-progress-header { + display: flex; + align-items: center; + justify-content: space-between; +} + +.mm-msg-progress-name { + font-size: 12px; + color: var(--mm-text); + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-msg-progress-percent { + font-size: 11px; + font-weight: 600; + min-width: 35px; + text-align: right; +} + +.mm-msg-progress-item.mm-success .mm-msg-progress-percent { + color: var(--mm-success); +} + +/* 发光进度条 */ +.mm-msg-progress-bar-wrapper { + position: relative; + height: 8px; + background: rgba(255, 255, 255, 0.08); + border-radius: 4px; + overflow: hidden; +} + +.mm-msg-progress-bar-fill { + height: 100%; + border-radius: 4px; + transition: width 0.5s ease-out; + position: relative; +} + +/* 霓虹发光进度条 */ +.mm-msg-progress-bar-fill.mm-neon-bar { + position: relative; + overflow: hidden; +} + +/* 高光滑过动画 */ +.mm-msg-progress-bar-fill.mm-neon-bar::after { + content: ''; + position: absolute; + top: 0; + left: -100%; + width: 50%; + height: 100%; + background: linear-gradient( + 90deg, + transparent, + rgba(255, 255, 255, 0.4), + transparent + ); + animation: mm-shine-sweep 2s ease-in-out infinite; +} + +@keyframes mm-shine-sweep { + 0% { + left: -50%; + } + 100% { + left: 150%; + } +} + +/* 进度条前端光点 */ +.mm-msg-progress-bar-fill-DISABLED::after { + content: ''; + position: absolute; + right: 0; + top: 20px; + transform: translateX(-50%); + width: 10px; + height: 10px; + background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, var(--mm-primary) 50%, transparent 100%); + border-radius: 50%; + animation: mm-glow-pulse 1.5s ease-in-out infinite; +} + +.mm-msg-progress-item.mm-success .mm-msg-progress-bar-fill-DISABLED::after { + background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, var(--mm-success) 50%, transparent 100%); + animation: none; +} + +/* 收起状态样式 */ +.mm-message-progress-panel.mm-collapsed { + width: auto; + min-width: 180px; +} + +.mm-message-progress-panel.mm-collapsed .mm-msg-panel-header { + border-bottom: none; +} + +/* 默认只显示一个的预览 */ +.mm-msg-panel-preview { + display: none; + padding: 8px 14px; + border-top: 1px solid var(--mm-border); + background: var(--mm-bg-secondary); +} + +.mm-message-progress-panel.mm-collapsed .mm-msg-panel-preview { + display: block; +} + +.mm-msg-preview-item { + display: flex; + align-items: center; + gap: 8px; +} + +.mm-msg-preview-name { + font-size: 12px; + color: var(--mm-text); + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-msg-preview-bar { + width: 60px; + height: 6px; + background: var(--mm-border); + border-radius: 3px; + overflow: hidden; +} + +.mm-msg-preview-bar-fill { + height: 100%; + border-radius: 3px; + transition: width 0.5s ease-out; + position: relative; + overflow: hidden; +} + +.mm-msg-preview-bar-fill.mm-neon-bar::after { + content: ''; + position: absolute; + top: 0; + left: -100%; + width: 50%; + height: 100%; + background: linear-gradient( + 90deg, + transparent, + rgba(255, 255, 255, 0.4), + transparent + ); + animation: mm-shine-sweep 2s ease-in-out infinite; +} + +.mm-msg-preview-percent { + font-size: 10px; + min-width: 30px; + text-align: right; +} + +/* ============================================================================ + 进度面板移动端适配 + ============================================================================ */ + +@media (max-width: 768px) { + /* 进度面板移动端基础定位(参考剧情优化面板,固定在左上角) */ + .mm-message-progress-panel:not(.mm-dragging):not(.mm-user-positioned) { + width: calc(100vw - 32px); + max-width: 320px; + left: 16px; + top: 60px; + right: auto; + transform: none; + } + + .mm-msg-panel-header { + padding: 14px 16px; + } + + .mm-drag-handle { + font-size: 14px; + color: rgba(255, 255, 255, 0.5); + } + + .mm-msg-panel-title { + font-size: 14px; + } + + .mm-msg-progress-name { + font-size: 13px; + } + + .mm-msg-progress-percent { + font-size: 12px; + } + + .mm-msg-progress-bar-wrapper { + height: 10px; + } +} + +@media (max-width: 480px) { + /* 进度面板手机端基础定位(参考剧情优化面板,固定在左上角) */ + .mm-message-progress-panel:not(.mm-dragging):not(.mm-user-positioned) { + width: calc(100vw - 24px); + left: 8px; + top: 60px; + right: auto; + transform: none; + } + + .mm-msg-panel-header { + padding: 12px 14px; + } + + .mm-msg-panel-content { + padding: 8px; + max-height: 250px; + } + + .mm-msg-progress-item { + padding: 8px 10px; + } +} + +/* ============================================================================ + 提示词编辑器移动端优化 + ============================================================================ */ + +/* 平板和小屏幕 */ +@media (max-width: 768px) { + #mm-prompt-editor-modal.mm-modal-visible { + display: flex !important; + align-items: center !important; + justify-content: center !important; + } + + #mm-prompt-editor-modal .mm-modal-content { + margin: auto; + position: relative; + top: 0; + left: 0; + transform: none; + } + + #mm-prompt-editor-modal .mm-modal-footer { + flex-wrap: wrap; + gap: 10px; + } + + #mm-prompt-editor-modal .mm-modal-actions-left, + #mm-prompt-editor-modal .mm-modal-actions-right { + justify-content: center; + gap: 8px; + } + + .mm-prompt-editor { + height: 200px; + min-height: 150px; + } + + .mm-resizable-editor-container { + min-height: 200px; + } +} + +/* 手机小屏幕 */ +@media (max-width: 480px) { + #mm-prompt-editor-modal.mm-modal-visible { + display: flex !important; + align-items: center !important; + justify-content: center !important; + padding: 12px !important; + } + + #mm-prompt-editor-modal .mm-modal-content { + width: calc(100vw - 24px); + height: auto; + max-height: 85vh; + border-radius: 8px; + margin: auto; + position: relative; + top: 0; + left: 0; + transform: none; + } + + #mm-prompt-editor-modal .mm-modal-body { + max-height: calc(100vh - 180px); + padding: 10px; + } + + #mm-prompt-editor-modal .mm-modal-header h4 { + font-size: 14px; + } + + .mm-prompt-select { + padding: 8px 10px; + font-size: 13px; + } + + #mm-current-field-label { + font-size: 13px; + } + + .mm-prompt-editor { + height: 180px; + min-height: 120px; + padding: 10px; + font-size: 13px; + } + + .mm-resizable-editor-container { + min-height: 180px; + } + + #mm-prompt-editor-modal .mm-modal-footer { + padding: 10px; + } + + #mm-prompt-editor-modal .mm-modal-actions-left, + #mm-prompt-editor-modal .mm-modal-actions-right { + width: 100%; + justify-content: center; + gap: 6px; + } + + #mm-prompt-editor-modal .mm-modal-actions-right { + order: -1; + margin-bottom: 6px; + } + + #mm-prompt-editor-modal .mm-modal-footer .mm-btn { + flex: 1 1 calc(33% - 6px); + min-width: 70px; + max-width: 100px; + padding: 10px 8px; + font-size: 12px; + } + + .mm-hint { + font-size: 11px; + } + + /* 手机端拖拽手柄 - 增大触摸区域 */ + .mm-resize-handle { + height: 16px; + touch-action: none; + } + + .mm-resize-handle::after { + width: 50px; + height: 4px; + } + + .mm-settings-content { + padding-bottom: 60px; + } +} + +/* ============================================================================ + 移动端设置面板滚动修复(通用) + ============================================================================ */ + +@media (max-width: 768px) { + .mm-settings-content { + padding-bottom: 60px; + -webkit-overflow-scrolling: touch; + } + + .mm-settings-section:last-child { + margin-bottom: 32px; + } + + .mm-settings-section:last-child .mm-setting-actions { + padding-bottom: 16px; + } +} + +/* ============================================================================ + 世界书控制样式 + ============================================================================ */ + +.mm-worldbook-control-content { + display: flex; + flex-direction: column; + gap: 12px; +} + +/* 世界书区块 */ +.mm-wb-section { + background: var(--mm-bg-secondary); + border-radius: 6px; + padding: 10px; +} + +.mm-wb-section-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 8px; + padding-bottom: 6px; + border-bottom: 1px solid var(--mm-border); +} + +.mm-wb-section-title { + font-size: 12px; + font-weight: 600; + color: var(--mm-text); +} + +/* 世界书列表容器 */ +.mm-wb-list-container { + max-height: 180px; + overflow-y: auto; +} + +.mm-wb-list { + display: flex; + flex-direction: column; + gap: 4px; +} + +/* 世界书列表项 */ +.mm-wb-item { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 10px; + background: var(--mm-bg-card); + border-radius: 4px; + cursor: pointer; + transition: all 0.2s ease; + border: 1px solid transparent; +} + +.mm-wb-item:hover { + background: var(--mm-bg); + border-color: var(--mm-primary); +} + +.mm-wb-item.mm-wb-selected { + background: rgba(74, 144, 217, 0.15); + border-color: var(--mm-primary); +} + +.mm-wb-item input[type="checkbox"] { + width: 16px; + height: 16px; + accent-color: var(--mm-primary); + cursor: pointer; + flex-shrink: 0; +} + +.mm-wb-item-name { + flex: 1; + font-size: 13px; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-wb-item-count { + font-size: 11px; + color: var(--mm-text-muted); + padding: 2px 6px; + background: var(--mm-bg-secondary); + border-radius: 8px; +} + +/* 加载和空状态 */ +.mm-wb-loading, +.mm-wb-empty, +.mm-wb-entries-loading, +.mm-wb-entries-empty { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 20px; + color: var(--mm-text-muted); + font-size: 12px; +} + +.mm-wb-loading i, +.mm-wb-entries-loading i { + color: var(--mm-primary); +} + +/* 条目区域 */ +.mm-wb-entries-section { + border-top: 1px dashed var(--mm-border); + padding-top: 12px; + margin-top: 4px; +} + +.mm-wb-entry-count { + font-size: 11px; + color: var(--mm-primary); + font-weight: 600; +} + +.mm-wb-entries-container { + max-height: 250px; + overflow-y: auto; +} + +.mm-wb-entries-list { + display: flex; + flex-direction: column; + gap: 4px; +} + +/* 条目项 */ +.mm-wb-entry-item { + display: flex; + flex-direction: column; + gap: 4px; + padding: 8px 10px; + background: var(--mm-bg-card); + border-radius: 4px; + border-left: 3px solid var(--mm-border); + transition: all 0.2s ease; +} + +.mm-wb-entry-item:hover { + background: var(--mm-bg); +} + +.mm-wb-entry-item.mm-entry-enabled { + border-left-color: var(--mm-success); +} + +.mm-wb-entry-item.mm-entry-disabled { + border-left-color: var(--mm-secondary); + opacity: 0.7; +} + +.mm-wb-entry-item.mm-entry-constant { + border-left-color: var(--mm-primary); +} + +.mm-wb-entry-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} + +.mm-wb-entry-title { + flex: 1; + font-size: 12px; + font-weight: 500; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-wb-entry-badges { + display: flex; + gap: 4px; + flex-shrink: 0; +} + +.mm-wb-entry-badge { + font-size: 9px; + padding: 2px 5px; + border-radius: 3px; + font-weight: 600; + text-transform: uppercase; +} + +.mm-wb-entry-badge.mm-badge-enabled { + background: rgba(40, 167, 69, 0.2); + color: var(--mm-success); +} + +.mm-wb-entry-badge.mm-badge-disabled { + background: rgba(108, 117, 125, 0.2); + color: var(--mm-secondary); +} + +.mm-wb-entry-badge.mm-badge-constant { + background: rgba(74, 144, 217, 0.2); + color: var(--mm-primary); +} + +.mm-wb-entry-keys { + font-size: 11px; + color: var(--mm-text-muted); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-wb-entry-keys i { + margin-right: 4px; + font-size: 10px; +} + +/* 世界书提示 */ +.mm-wb-hint { + text-align: center; + padding: 8px; + background: var(--mm-bg-secondary); + border-radius: 4px; +} + +/* 递归控制按钮区域 */ +.mm-wb-recursion-controls { + background: var(--mm-bg-secondary); + border-radius: 6px; + padding: 10px; + border: 1px dashed var(--mm-border); +} + +.mm-wb-recursion-row { + display: flex; + gap: 8px; + margin-bottom: 8px; +} + +.mm-wb-recursion-btn { + flex: 1; + display: flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 12px !important; + font-size: 12px !important; + transition: all 0.2s ease; +} + +.mm-wb-recursion-btn.active { + background: var(--mm-primary) !important; + color: white !important; + border-color: var(--mm-primary) !important; +} + +.mm-wb-recursion-btn.active i { + color: white; +} + +.mm-wb-recursion-btn:hover:not(.active) { + background: var(--mm-bg-card); + border-color: var(--mm-primary); +} + +.mm-recursion-hint { + display: block; + text-align: center; + font-size: 11px; + color: var(--mm-text-muted); + margin: 0; + padding: 0; +} + +/* 移动端适配 */ +@media (max-width: 768px) { + .mm-wb-list-container { + max-height: 150px; + } + + .mm-wb-entries-container { + max-height: 200px; + } + + .mm-wb-item { + padding: 6px 8px; + } + + .mm-wb-item-name { + font-size: 12px; + } + + .mm-wb-entry-item { + padding: 6px 8px; + } + + .mm-wb-entry-title { + font-size: 11px; + } + + .mm-wb-entry-keys { + font-size: 10px; + } +} + +/* 统计容器样式 */ +.mm-wb-stats-container { + max-height: 200px; + overflow-y: auto; +} + +.mm-wb-stats-content { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.mm-wb-stat-item { + display: flex; + flex-direction: column; + align-items: center; + padding: 8px 12px; + background: var(--mm-bg-card); + border-radius: 6px; + min-width: 70px; + flex: 1; +} + +.mm-wb-stat-label { + font-size: 11px; + color: var(--mm-text-muted); +} + +.mm-wb-stat-value { + font-size: 18px; + font-weight: 600; + color: var(--mm-text); +} + +.mm-wb-stat-value.mm-stat-enabled { + color: var(--mm-success); +} + +.mm-wb-stat-value.mm-stat-disabled { + color: var(--mm-secondary); +} + +.mm-wb-stat-value.mm-stat-constant { + color: var(--mm-primary); +} + +.mm-wb-stats-loading, +.mm-wb-stats-empty { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 16px; + color: var(--mm-text-muted); + font-size: 12px; +} + +/* ============================================================================ + 标签过滤样式 + ============================================================================ */ + +/* 标签模式标题 - 居中显示 */ +.mm-tag-mode-checkbox { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + cursor: pointer; +} + +.mm-tag-mode-checkbox input[type="checkbox"] { + display: none; +} + +.mm-tag-mode-label { + display: block; + width: 100%; + padding: 6px 10px; + text-align: center; + font-size: 12px; + color: var(--mm-text-muted); + border-radius: 4px; + transition: all 0.2s ease; +} + +.mm-tag-mode-checkbox input[type="checkbox"]:checked + .mm-tag-mode-label { + background: var(--mm-primary); + color: white; + font-weight: 500; +} + +.mm-tag-mode-checkbox:hover .mm-tag-mode-label { + color: var(--mm-text); +} + +/* 标签容器 */ +.mm-tag-container { + background: var(--mm-bg-secondary); + border-radius: 6px; + padding: 10px; + min-height: 60px; + margin-bottom: 10px; +} + +.mm-tag-list { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin-bottom: 8px; +} + +.mm-tag-list:empty { + margin-bottom: 0; +} + +/* 标签 chip */ +.mm-tag-chip { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 5px 10px; + background: var(--mm-bg-card); + border: 1px solid var(--mm-border); + border-radius: 14px; + font-size: 12px; + color: var(--mm-text); + transition: all 0.2s ease; +} + +.mm-tag-chip:hover { + border-color: var(--mm-primary); + background: var(--mm-bg); +} + +.mm-tag-chip .mm-tag-name { + font-family: "Consolas", "Monaco", monospace; + color: var(--mm-primary); +} + +.mm-tag-chip .mm-tag-remove { + display: flex; + align-items: center; + justify-content: center; + width: 16px; + height: 16px; + border-radius: 50%; + background: transparent; + color: var(--mm-text-muted); + cursor: pointer; + transition: all 0.2s ease; + font-size: 10px; +} + +.mm-tag-chip .mm-tag-remove:hover { + background: var(--mm-danger); + color: white; +} + +/* 标签输入 */ +.mm-tag-input-row { + display: flex; + gap: 6px; + margin-top: 6px; + align-items: center; +} + +.mm-tag-input-row .mm-tag-input { + flex: 1; +} + +.mm-tag-input { + width: 100%; + padding: 8px 10px; + border: 1px dashed var(--mm-border); + border-radius: 6px; + background: transparent; + color: var(--mm-text); + font-size: 12px; + transition: all 0.2s ease; + box-sizing: border-box; +} + +.mm-tag-input:focus { + outline: none; + border-color: var(--mm-primary); + border-style: solid; + background: var(--mm-bg-card); +} + +.mm-tag-input::placeholder { + color: var(--mm-text-muted); +} + +/* 圆形添加按钮 */ +.mm-btn-small { + width: 32px; + height: 32px; + padding: 0; + font-size: 14px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; +} + +/* 区分大小写选项 */ +.mm-tag-case-option { + display: flex; + align-items: center; + gap: 8px; + font-size: 12px; + color: var(--mm-text-muted); + cursor: pointer; + margin-bottom: 8px; +} + +.mm-tag-case-option:hover { + color: var(--mm-text); +} + +.mm-tag-case-option input[type="checkbox"] { + width: 14px; + height: 14px; + accent-color: var(--mm-primary); +} + +/* 标签提示 */ +.mm-tag-hint { + display: block; + line-height: 1.6; + padding: 8px 10px; + background: var(--mm-bg-secondary); + border-radius: 4px; + border-left: 3px solid var(--mm-primary); +} + +.mm-tag-hint strong { + color: var(--mm-text); +} + +/* ============================================================================ + 交互式记忆搜索面板样式 + ============================================================================ */ + +.mm-search-panel { + position: fixed; + width: 480px; + max-height: 85vh; + background: var(--mm-bg); + border: 1px solid var(--mm-border); + border-radius: var(--mm-radius); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); + z-index: 1000002; + display: none; + flex-direction: column; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.mm-search-panel.mm-visible { + display: flex; + animation: mm-search-panel-in 0.3s ease-out; +} + +.mm-search-panel.mm-minimized { + max-height: 48px; + overflow: hidden; +} + +.mm-search-panel.mm-minimized .mm-search-panel-content, +.mm-search-panel.mm-minimized .mm-search-panel-status, +.mm-search-panel.mm-minimized .mm-search-panel-footer { + display: none; +} + +@keyframes mm-search-panel-in { + from { + opacity: 0; + transform: translate(-50%, -50%) scale(0.95); + } + to { + opacity: 1; + transform: translate(-50%, -50%) scale(1); + } +} + +/* 面板头部 - 可拖动 */ +.mm-search-panel-header { + padding: 12px 16px; + background: var(--mm-bg-secondary); + border-bottom: 1px solid var(--mm-border); + border-radius: var(--mm-radius) var(--mm-radius) 0 0; + cursor: move; + display: flex; + justify-content: space-between; + align-items: center; + -webkit-user-select: none; + user-select: none; + touch-action: none; +} + +.mm-search-panel-title { + font-size: 14px; + font-weight: 600; + color: var(--mm-text); + display: flex; + align-items: center; + gap: 8px; +} + +.mm-search-panel-title i { + color: var(--mm-primary); +} + +.mm-search-panel-controls { + display: flex; + gap: 4px; +} + +.mm-search-panel-controls .mm-btn-icon { + width: 28px; + height: 28px; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + background: transparent; + border: none; + color: var(--mm-text-muted); + cursor: pointer; + border-radius: 4px; + transition: all 0.2s ease; +} + +.mm-search-panel-controls .mm-btn-icon:hover { + background: var(--mm-bg-card); + color: var(--mm-text); +} + +/* ============================================================================ + 多总结世界书可折叠面板样式 + ============================================================================ */ + +/* 世界书容器 */ +.mm-search-books-container { + flex: 1; + overflow-y: auto; + max-height: 50vh; + min-height: 200px; +} + +/* 记忆搜索内容区域拖拽手柄 */ +.mm-search-resize-handle { + height: 12px; + display: flex; + align-items: center; + justify-content: center; + cursor: ns-resize; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + border-bottom: 1px solid var(--mm-border); + color: var(--mm-text-muted); + font-size: 10px; + user-select: none; + transition: background 0.2s ease, color 0.2s ease; + flex-shrink: 0; +} + +.mm-search-resize-handle:hover { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.15); + color: var(--mm-primary); +} + +.mm-search-resize-handle:active, +.mm-search-resize-handle.resizing { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.25); +} + +/* 单个世界书可折叠面板 */ +.mm-search-book-section { + border-bottom: 1px solid var(--mm-border); +} + +.mm-search-book-section:last-child { + border-bottom: none; +} + +/* 世界书折叠头 */ +.mm-search-book-header { + display: flex; + align-items: center; + padding: 10px 12px; + background: var(--mm-bg-secondary); + cursor: pointer; + user-select: none; + transition: background 0.2s ease; + gap: 8px; +} + +.mm-search-book-header:hover { + background: var(--mm-bg-card); +} + +.mm-search-book-header .mm-book-toggle-icon { + font-size: 10px; + color: var(--mm-text-muted); + transition: transform 0.2s ease; + width: 12px; +} + +.mm-search-book-section.mm-collapsed .mm-book-toggle-icon { + transform: rotate(-90deg); +} + +.mm-search-book-header .mm-book-name { + flex: 1; + font-size: 13px; + font-weight: 500; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-search-book-header .mm-book-status { + font-size: 11px; + color: var(--mm-text-muted); + display: flex; + align-items: center; + gap: 4px; +} + +.mm-search-book-header .mm-book-status.mm-loading { + color: var(--mm-primary); +} + +.mm-search-book-header .mm-book-status.mm-success { + color: var(--mm-success); +} + +.mm-search-book-header .mm-book-status.mm-error { + color: var(--mm-danger); +} + +/* 世界书内容区域 */ +.mm-search-book-content { + padding: 12px; + background: var(--mm-bg); + max-height: 250px; + overflow-y: auto; + transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease; +} + +.mm-search-book-section.mm-collapsed .mm-search-book-content { + max-height: 0; + padding: 0 12px; + overflow: hidden; + opacity: 0; +} + +/* 世界书内容区域的消息样式继承 */ +.mm-search-book-content .mm-search-message { + margin-bottom: 10px; +} + +.mm-search-book-content .mm-search-message:last-child { + margin-bottom: 0; +} + +/* 最小化时隐藏世界书容器 */ +.mm-search-panel.mm-minimized .mm-search-books-container { + display: none; +} + +/* 消息区域 */ +.mm-search-panel-content { + flex: 1; + overflow-y: auto; + padding: 12px; + max-height: 320px; + min-height: 150px; +} + +/* 消息项 */ +.mm-search-message { + margin-bottom: 12px; + animation: mm-msg-fade-in 0.3s ease-out; +} + +@keyframes mm-msg-fade-in { + from { + opacity: 0; + transform: translateY(8px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.mm-search-message.mm-search-message-ai { + padding: 10px 12px; + background: var(--mm-bg-secondary); + border-radius: 8px; + border-left: 3px solid var(--mm-primary); +} + +.mm-search-message.mm-search-message-system { + padding: 8px 12px; + background: rgba(74, 144, 217, 0.1); + border-radius: 6px; + font-size: 12px; + color: var(--mm-text-muted); + text-align: center; +} + +.mm-search-message.mm-search-message-result { + padding: 10px 12px; + background: var(--mm-bg-card); + border-radius: 8px; + border: 1px solid var(--mm-border); +} + +/* 消息内部元素 */ +.mm-search-message-content { + display: flex; + align-items: center; + gap: 8px; + font-size: 13px; + color: var(--mm-text); +} + +.mm-search-message-content i { + color: var(--mm-primary); + flex-shrink: 0; +} + +.mm-search-message-avatar { + width: 28px; + height: 28px; + border-radius: 50%; + background: var(--mm-primary); + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + margin-bottom: 8px; +} + +.mm-search-message-avatar i { + color: white; + font-size: 14px; +} + +.mm-search-message.mm-search-message-ai .mm-search-message-content { + padding-left: 4px; +} + +/* 搜索结果项 */ +.mm-search-result-item { + display: flex; + flex-direction: column; + gap: 8px; +} + +.mm-search-result-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} + +.mm-search-result-title { + font-size: 13px; + font-weight: 600; + color: var(--mm-text); + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-search-result-score { + font-size: 11px; + color: var(--mm-text-muted); + flex-shrink: 0; +} + +.mm-search-result-keywords { + display: flex; + flex-wrap: wrap; + gap: 4px; + margin-top: 4px; +} + +.mm-search-keyword-tag { + padding: 2px 6px; + background: rgba(74, 144, 217, 0.15); + color: var(--mm-primary); + border-radius: 3px; + font-size: 11px; +} + +.mm-search-result-content { + font-size: 12px; + color: var(--mm-text-muted); + line-height: 1.5; + max-height: 80px; + overflow: hidden; + text-overflow: ellipsis; + background: var(--mm-bg); + padding: 8px; + border-radius: 4px; + border: 1px solid var(--mm-border); +} + +.mm-search-result-floor { + font-size: 13px; + font-weight: 600; + color: var(--mm-primary); +} + +.mm-search-result-actions { + display: flex; + gap: 6px; + margin-top: 4px; +} + +.mm-search-result-preview { + font-size: 12px; + color: var(--mm-text-muted); + line-height: 1.5; + max-height: 60px; + overflow: hidden; + text-overflow: ellipsis; +} + +.mm-search-result-preview .mm-highlight-keyword { + background: rgba(255, 217, 61, 0.3); + color: var(--mm-text); + padding: 0 2px; + border-radius: 2px; +} + +/* 确认/拒绝按钮 */ +.mm-btn-adopt, +.mm-btn-reject { + padding: 4px 10px; + font-size: 11px; + border-radius: 4px; + cursor: pointer; + transition: all 0.2s ease; + border: 1px solid transparent; +} + +.mm-btn-adopt { + background: rgba(40, 167, 69, 0.2); + color: var(--mm-success); + border-color: var(--mm-success); +} + +.mm-btn-adopt:hover { + background: var(--mm-success); + color: white; +} + +.mm-btn-reject { + background: rgba(220, 53, 69, 0.2); + color: var(--mm-danger); + border-color: var(--mm-danger); +} + +.mm-btn-reject:hover { + background: var(--mm-danger); + color: white; +} + +/* 自动模式 - 删除按钮 */ +.mm-btn-remove { + padding: 4px 10px; + font-size: 11px; + border-radius: 4px; + cursor: pointer; + transition: all 0.2s ease; + background: rgba(108, 117, 125, 0.2); + color: var(--mm-secondary); + border: 1px solid var(--mm-secondary); +} + +.mm-btn-remove:hover { + background: var(--mm-secondary); + color: white; +} + +/* 已采用的结果 */ +.mm-search-result-item.mm-adopted { + border-color: var(--mm-success); + background: rgba(40, 167, 69, 0.1); +} + +.mm-search-result-item.mm-adopted .mm-search-result-floor::after { + content: ' ✓'; + color: var(--mm-success); +} + +.mm-search-adopted-label { + display: flex; + align-items: center; + gap: 4px; + font-size: 11px; + color: var(--mm-success); + padding: 4px 8px; + background: rgba(40, 167, 69, 0.15); + border-radius: 4px; +} + +.mm-search-adopted-label i { + font-size: 12px; +} + +/* 已拒绝的结果 */ +.mm-search-result-item.mm-rejected { + opacity: 0.5; + border-color: var(--mm-danger); + background: rgba(220, 53, 69, 0.05); +} + +.mm-search-rejected-label { + display: flex; + align-items: center; + gap: 4px; + font-size: 11px; + color: var(--mm-danger); + padding: 4px 8px; + background: rgba(220, 53, 69, 0.15); + border-radius: 4px; +} + +.mm-search-rejected-label i { + font-size: 12px; +} + +/* 状态栏 */ +.mm-search-panel-status { + padding: 8px 16px; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + display: flex; + justify-content: space-between; + align-items: center; + font-size: 12px; + color: var(--mm-text-muted); +} + +.mm-search-status-left { + display: flex; + align-items: center; + gap: 4px; +} + +.mm-search-status-left strong { + color: var(--mm-primary); +} + +.mm-search-divider { + color: var(--mm-border); + margin: 0 4px; +} + +.mm-search-tasks-status { + display: flex; + align-items: center; + gap: 6px; +} + +.mm-search-tasks-status i { + color: var(--mm-primary); +} + +.mm-search-tasks-status.mm-tasks-done i { + color: var(--mm-success); +} + +/* 高度缩放拖拽条 */ +.mm-search-resize-handle { + height: 16px; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + cursor: ns-resize; + display: flex; + align-items: center; + justify-content: center; + color: var(--mm-text-muted); + font-size: 10px; + -webkit-user-select: none; + user-select: none; + border-radius: 0 0 var(--mm-radius) var(--mm-radius); +} + +.mm-search-resize-handle:hover { + background: var(--mm-bg-hover); + color: var(--mm-text); +} + +/* 底部操作区 */ +.mm-search-panel-footer { + padding: 12px 16px; + border-top: 1px solid var(--mm-border); + display: flex; + flex-direction: column; + gap: 10px; +} + +.mm-search-actions { + display: flex; + gap: 8px; +} + +.mm-search-actions .mm-btn { + flex: 1; + padding: 10px 12px; + font-size: 13px; + display: flex; + align-items: center; + justify-content: center; + gap: 6px; +} + +.mm-search-actions .mm-btn:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +/* 自定义搜索输入框 */ +.mm-search-custom-input { + display: flex; + gap: 8px; + padding-top: 10px; + border-top: 1px dashed var(--mm-border); +} + +.mm-search-custom-input.mm-hidden { + display: none; +} + +.mm-search-custom-input input { + flex: 1; + padding: 10px 12px; + border: 1px solid var(--mm-border); + border-radius: 6px; + background: var(--mm-bg-card); + color: var(--mm-text); + font-size: 13px; +} + +.mm-search-custom-input input:focus { + outline: none; + border-color: var(--mm-primary); +} + +.mm-search-custom-input .mm-btn { + flex-shrink: 0; +} + +/* 批量结果列表(自动模式) */ +.mm-search-results-list { + display: flex; + flex-direction: column; + gap: 8px; +} + +.mm-search-results-list .mm-search-result-item { + padding: 10px 12px; + background: var(--mm-bg-card); + border-radius: 6px; + border: 1px solid var(--mm-border); + transition: all 0.2s ease; +} + +.mm-search-results-list .mm-search-result-item:hover { + border-color: var(--mm-primary); +} + +/* 无结果提示 */ +.mm-search-no-results { + text-align: center; + padding: 24px; + color: var(--mm-text-muted); +} + +.mm-search-no-results i { + font-size: 32px; + margin-bottom: 12px; + color: var(--mm-border); +} + +.mm-search-no-results p { + margin: 0; + font-size: 13px; +} + +/* 加载状态 */ +.mm-search-loading { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + padding: 20px; + color: var(--mm-text-muted); +} + +.mm-search-loading i { + color: var(--mm-primary); + font-size: 18px; +} + +/* 移动端适配 */ +@media (max-width: 768px) { + .mm-search-panel { + width: calc(100vw - 24px); + max-width: 420px; + max-height: 70vh; + } + + .mm-search-panel-content { + max-height: 45vh; + } + + .mm-search-actions { + flex-wrap: wrap; + } + + .mm-search-actions .mm-btn { + flex: 1 1 calc(50% - 4px); + min-width: 0; + padding: 10px 8px; + font-size: 12px; + } + + .mm-search-actions .mm-btn:last-child { + flex: 1 1 100%; + } +} + +@media (max-width: 480px) { + .mm-search-panel { + width: 70vw; + min-width: 260px; + max-width: 320px; + max-height: 65vh; + } + + .mm-search-panel-header { + padding: 8px 12px; + } + + .mm-search-panel-title { + font-size: 13px; + } + + .mm-search-panel-content { + padding: 10px; + max-height: 40vh; + } + + .mm-search-panel-footer { + padding: 10px 12px; + } + + .mm-search-result-preview { + font-size: 11px; + max-height: 42px; + } + + .mm-search-actions .mm-btn { + padding: 8px 10px; + font-size: 11px; + } +} + +/* 剧情优化世界书选择样式 */ +.mm-plot-optimize-books-content { + padding: 10px; + max-height: 300px; + overflow-y: auto; +} + +.mm-plot-optimize-book-item { + background: var(--mm-bg-card); + border: 1px solid var(--mm-border); + border-radius: 6px; + margin-bottom: 8px; + overflow: hidden; + transition: all 0.2s ease; +} + +.mm-plot-optimize-book-item:hover { + border-color: var(--mm-primary); +} + +.mm-plot-optimize-book-item.selected { + background: rgba(74, 144, 217, 0.1); + border-color: var(--mm-primary); +} + +.mm-plot-optimize-book-header { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + cursor: pointer; +} + +.mm-plot-optimize-book-header:hover { + background: var(--mm-bg-hover); +} + +.mm-plot-optimize-book-checkbox { + width: 18px; + height: 18px; + accent-color: var(--mm-primary); + cursor: pointer; + flex-shrink: 0; +} + +.mm-plot-optimize-book-name { + flex: 1; + font-size: 13px; + color: var(--mm-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-plot-optimize-book-entries { + display: none; + flex-direction: column; + padding: 8px 12px 8px 28px; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + gap: 4px; +} + +.mm-plot-optimize-book-entries.show { + display: flex; +} + +.mm-plot-optimize-entry-item { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 10px; + background: var(--mm-bg-card); + border: 1px solid var(--mm-border); + border-radius: 4px; + font-size: 13px; + color: var(--mm-text); + cursor: pointer; + transition: all 0.15s ease; +} + +.mm-plot-optimize-entry-item:hover { + background: var(--mm-bg-hover); + border-color: var(--mm-primary); +} + +.mm-plot-optimize-entry-item.selected { + background: rgba(74, 144, 217, 0.15); + border-color: var(--mm-primary); + color: var(--mm-text); +} + +.mm-plot-optimize-entry-checkbox { + width: 14px; + height: 14px; + display: flex; + align-items: center; + justify-content: center; + color: var(--mm-primary); + font-weight: bold; + flex-shrink: 0; +} + +/* 折叠卡片操作按钮 */ +.mm-collapse-actions { + display: flex; + gap: 4px; + margin-left: auto; +} + +.mm-collapse-actions .mm-btn { + padding: 4px 8px; + min-width: auto; +} + +.mm-collapse-actions .mm-btn i { + margin: 0; +} + +/* ============================================================================ + 配置弹窗 Tab 切换样式 + ============================================================================ */ +.mm-config-tabs { + display: flex; + gap: 4px; + margin-bottom: 16px; + padding: 4px; + background: var(--mm-bg-secondary); + border-radius: var(--mm-radius); +} + +.mm-config-tab { + flex: 1; + padding: 10px 16px; + border: none; + background: transparent; + color: var(--mm-text-muted); + font-size: 0.9em; + font-weight: 500; + cursor: pointer; + border-radius: calc(var(--mm-radius) - 2px); + transition: var(--mm-transition); + display: flex; + align-items: center; + justify-content: center; + gap: 8px; +} + +.mm-config-tab:hover { + color: var(--mm-text); + background: rgba(255, 255, 255, 0.05); +} + +.mm-config-tab.active { + color: var(--mm-text); + background: var(--mm-primary); +} + +.mm-config-tab i { + font-size: 0.95em; +} + +.mm-config-tab-content { + display: none; +} + +.mm-config-tab-content.active { + display: block; +} + +/* ============================================================================ + 上下文选择页面样式 + ============================================================================ */ + +/* 世界书列表容器 */ +.mm-config-worldbook-content { + max-height: 200px; + overflow-y: auto; +} + +.mm-config-worldbook-list { + display: flex; + flex-direction: column; + gap: 6px; +} + +/* 世界书列表项 */ +.mm-config-worldbook-item { + background: var(--mm-bg-secondary); + border-radius: calc(var(--mm-radius) - 2px); + overflow: hidden; + transition: var(--mm-transition); +} + +.mm-config-worldbook-item.selected { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.15); +} + +.mm-config-worldbook-header { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + cursor: pointer; +} + +.mm-config-worldbook-header:hover { + background: rgba(255, 255, 255, 0.03); +} + +.mm-config-worldbook-checkbox { + width: 16px; + height: 16px; + cursor: pointer; + accent-color: var(--mm-primary); +} + +.mm-config-worldbook-name { + flex: 1; + font-weight: 500; + color: var(--mm-text); +} + +.mm-config-worldbook-count { + font-size: 0.85em; + color: var(--mm-text-muted); +} + +/* 世界书条目列表 */ +.mm-config-worldbook-entries { + display: none; + padding: 8px 12px 12px 36px; + border-top: 1px solid var(--mm-border); + background: rgba(0, 0, 0, 0.1); +} + +.mm-config-worldbook-entries.show { + display: block; +} + +.mm-config-worldbook-entry { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 8px; + font-size: 0.9em; + color: var(--mm-text-muted); + border-radius: 4px; + transition: var(--mm-transition); +} + +.mm-config-worldbook-entry:hover { + background: rgba(255, 255, 255, 0.03); + color: var(--mm-text); +} + +.mm-config-worldbook-entry-checkbox { + width: 14px; + height: 14px; + cursor: pointer; + accent-color: var(--mm-primary); +} + +.mm-config-worldbook-entry-name { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* ============================================================================ + 角色描述预览样式 + ============================================================================ */ +.mm-config-char-content { + display: flex; + flex-direction: column; + gap: 12px; +} + +.mm-config-char-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; +} + +.mm-config-char-info { + display: flex; + flex-direction: column; + gap: 2px; +} + +.mm-config-char-name { + font-weight: 600; + color: var(--mm-text); + font-size: 1em; +} + +.mm-config-char-tokens { + font-size: 0.85em; + color: var(--mm-text-muted); +} + +.mm-config-char-include { + display: flex; + align-items: center; + gap: 6px; + font-size: 0.9em; + color: var(--mm-text-muted); + cursor: pointer; +} + +.mm-config-char-include:hover { + color: var(--mm-text); +} + +.mm-config-char-include input { + accent-color: var(--mm-primary); + cursor: pointer; +} + +.mm-config-char-preview { + background: var(--mm-bg-secondary); + border-radius: calc(var(--mm-radius) - 2px); + padding: 12px; + max-height: 150px; + overflow-y: auto; + font-size: 0.9em; + line-height: 1.5; + color: var(--mm-text-muted); + white-space: pre-wrap; + word-break: break-word; +} + +.mm-config-char-preview::-webkit-scrollbar { + width: 6px; +} + +.mm-config-char-preview::-webkit-scrollbar-thumb { + background: var(--mm-border); + border-radius: 3px; +} + +.mm-config-char-empty { + text-align: center; + color: var(--mm-text-muted); + font-style: italic; +} + +/* 通用加载和空状态 */ +.mm-loading-state, +.mm-empty-state { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 20px; + color: var(--mm-text-muted); +} + +.mm-loading-state i { + color: var(--mm-primary); +} + +/* ============================================================================ + 剧情优化助手面板样式 + ============================================================================ */ +.mm-plot-panel { + position: fixed; + width: 480px; + max-height: 85vh; + background: var(--mm-bg); + border: 1px solid var(--mm-border); + border-radius: var(--mm-radius); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); + z-index: 1000002; + display: none; + flex-direction: column; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.mm-plot-panel.mm-visible { + display: flex; + animation: mm-plot-panel-in 0.3s ease-out; +} + +.mm-plot-panel.mm-minimized { + max-height: 48px; + overflow: hidden; +} + +.mm-plot-panel.mm-minimized .mm-plot-chat-container, +.mm-plot-panel.mm-minimized .mm-plot-panel-status, +.mm-plot-panel.mm-minimized .mm-plot-worldbook-section, +.mm-plot-panel.mm-minimized .mm-plot-panel-footer { + display: none; +} + +/* 折叠图标样式 */ +.mm-panel-toggle-icon { + font-size: 14px; + color: var(--mm-text-muted); + transition: transform 0.3s ease; +} + +.mm-plot-panel.mm-minimized .mm-panel-toggle-icon, +.mm-search-panel.mm-minimized .mm-panel-toggle-icon { + transform: rotate(180deg); +} + +@keyframes mm-plot-panel-in { + from { + opacity: 0; + transform: translate(-50%, -50%) scale(0.95); + } + to { + opacity: 1; + transform: translate(-50%, -50%) scale(1); + } +} + +/* 面板头部 - 可拖动 */ +.mm-plot-panel-header { + padding: 12px 16px; + background: var(--mm-bg-secondary); + border-bottom: 1px solid var(--mm-border); + border-radius: var(--mm-radius) var(--mm-radius) 0 0; + cursor: move; + display: flex; + justify-content: space-between; + align-items: center; + -webkit-user-select: none; + user-select: none; + touch-action: none; +} + +.mm-plot-panel-title { + font-size: 14px; + font-weight: 600; + color: var(--mm-text); + display: flex; + align-items: center; + gap: 8px; +} + +.mm-plot-panel-title i { + color: var(--mm-primary); +} + +.mm-plot-panel-controls { + display: flex; + gap: 4px; +} + +.mm-plot-panel-controls .mm-btn-icon { + width: 28px; + height: 28px; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + background: transparent; + border: none; + color: var(--mm-text-muted); + cursor: pointer; + border-radius: 4px; + transition: all 0.2s ease; +} + +.mm-plot-panel-controls .mm-btn-icon:hover { + background: var(--mm-bg-card); + color: var(--mm-text); +} + +/* 聊天容器 */ +.mm-plot-chat-container { + flex: 1; + overflow-y: auto; + padding: 16px; + min-height: 200px; + max-height: 50vh; + background: var(--mm-bg); + display: flex; + flex-direction: column; + gap: 16px; + scroll-behavior: smooth; +} + +/* 消息行 */ +.mm-plot-message { + display: flex; + gap: 10px; + max-width: 90%; + animation: mm-message-in 0.3s ease; +} + +@keyframes mm-message-in { + from { + opacity: 0; + transform: translateY(10px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +/* AI 消息 - 左对齐 */ +.mm-plot-message-ai { + align-self: flex-start; + flex-direction: row; +} + +/* 用户消息 - 右对齐 */ +.mm-plot-message-user { + align-self: flex-end; + flex-direction: row-reverse; +} + +/* 头像 */ +.mm-plot-avatar { + width: 36px; + height: 36px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + font-size: 16px; +} + +.mm-plot-message-ai .mm-plot-avatar { + background: linear-gradient(135deg, var(--mm-primary), var(--mm-primary-hover)); + color: white; + box-shadow: 0 2px 8px rgba(var(--mm-primary-rgb, 99, 102, 241), 0.3); +} + +.mm-plot-message-user .mm-plot-avatar { + background: #6b7280; + color: white; + box-shadow: 0 2px 8px rgba(107, 114, 128, 0.3); +} + +/* 气泡 */ +.mm-plot-bubble { + position: relative; + padding: 12px 16px; + border-radius: 18px; + max-width: calc(100% - 46px); + word-break: break-word; +} + +.mm-plot-message-ai .mm-plot-bubble { + background: var(--mm-bg-card); + border: 1px solid var(--mm-border); + border-top-left-radius: 4px; + color: var(--mm-text); +} + +.mm-plot-message-user .mm-plot-bubble { + background: #6b7280; + border: none; + border-top-right-radius: 4px; + color: white; +} + +/* 气泡内容 */ +.mm-plot-bubble-content { + font-size: 14px; + line-height: 1.6; + white-space: pre-wrap; +} + +.mm-plot-message-user .mm-plot-bubble-content { + color: white; +} + +/* 时间戳 */ +.mm-plot-bubble-time { + font-size: 11px; + margin-top: 6px; + opacity: 0.6; +} + +.mm-plot-message-ai .mm-plot-bubble-time { + color: var(--mm-text-muted); + text-align: left; +} + +.mm-plot-message-user .mm-plot-bubble-time { + color: rgba(255, 255, 255, 0.8); + text-align: right; +} + +/* 欢迎消息样式 */ +.mm-plot-message-welcome .mm-plot-bubble { + background: linear-gradient(135deg, var(--mm-bg-card), var(--mm-bg)); + border: 1px dashed var(--mm-border); +} + +/* AI 正在输入状态 */ +.mm-plot-message-typing .mm-plot-bubble-content { + display: flex; + align-items: center; + gap: 4px; +} + +.mm-plot-typing-dot { + width: 8px; + height: 8px; + background: var(--mm-text-muted); + border-radius: 50%; + animation: mm-typing-bounce 1.4s infinite ease-in-out; +} + +.mm-plot-typing-dot:nth-child(1) { animation-delay: 0s; } +.mm-plot-typing-dot:nth-child(2) { animation-delay: 0.2s; } +.mm-plot-typing-dot:nth-child(3) { animation-delay: 0.4s; } + +@keyframes mm-typing-bounce { + 0%, 80%, 100% { + transform: translateY(0); + } + 40% { + transform: translateY(-6px); + } +} + +/* 系统消息 */ +.mm-plot-message-system { + align-self: center; + max-width: 100%; +} + +.mm-plot-message-system .mm-plot-bubble { + background: var(--mm-bg-hover); + border: 1px solid var(--mm-border); + border-radius: 12px; + padding: 8px 16px; + font-size: 12px; + color: var(--mm-text-muted); +} + +/* 流式输出效果 */ +.mm-plot-bubble-content.streaming::after { + content: "▋"; + animation: mm-cursor-blink 1s infinite; + margin-left: 2px; +} + +@keyframes mm-cursor-blink { + 0%, 50% { opacity: 1; } + 51%, 100% { opacity: 0; } +} + +/* 旧的预览样式保留兼容 */ +.mm-plot-panel-content { + flex: 1; + overflow-y: auto; + padding: 12px; + min-height: 150px; + max-height: 250px; + background: var(--mm-bg); +} + +.mm-plot-preview-content { + font-size: 0.9em; + line-height: 1.6; + color: var(--mm-text); + white-space: pre-wrap; + word-break: break-word; +} + +/* 状态栏 */ +.mm-plot-panel-status { + padding: 8px 16px; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + display: flex; + justify-content: space-between; + align-items: center; + font-size: 0.85em; + color: var(--mm-text-muted); +} + +.mm-plot-status-left, +.mm-plot-status-right { + display: flex; + align-items: center; + gap: 8px; +} + +/* 世界书选择区域 */ +.mm-plot-worldbook-section { + border-top: 1px solid var(--mm-border); + min-height: 40px; + max-height: 300px; + overflow: hidden; + transition: max-height 0.3s ease; + display: flex; + flex-direction: column; + flex-shrink: 0; +} + +.mm-plot-worldbook-section.collapsed { + max-height: 40px; +} + +.mm-plot-worldbook-section.collapsed .mm-plot-worldbook-body, +.mm-plot-worldbook-section.collapsed .mm-plot-worldbook-resize-handle { + display: none; +} + +/* 拖拽时禁用过渡动画 */ +.mm-plot-panel.resizing, +.mm-plot-worldbook-section.resizing { + transition: none !important; +} + +/* 世界书区域底部拖拽调整高度手柄 */ +.mm-plot-worldbook-resize-handle { + height: 14px; + display: flex; + align-items: center; + justify-content: center; + cursor: ns-resize; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + color: var(--mm-text-muted); + font-size: 10px; + user-select: none; + transition: background 0.2s ease, color 0.2s ease; + flex-shrink: 0; +} + +.mm-plot-worldbook-resize-handle:hover { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.15); + color: var(--mm-primary); +} + +/* 聊天区域拖拽调整高度手柄 */ +.mm-plot-chat-resize-handle { + height: 12px; + display: flex; + align-items: center; + justify-content: center; + cursor: ns-resize; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + border-bottom: 1px solid var(--mm-border); + color: var(--mm-text-muted); + font-size: 10px; + user-select: none; + transition: background 0.2s ease, color 0.2s ease; + flex-shrink: 0; +} + +.mm-plot-chat-resize-handle:hover { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.15); + color: var(--mm-primary); +} + +.mm-plot-chat-resize-handle:active { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.25); +} + +.mm-plot-worldbook-resize-handle:active, +.mm-plot-worldbook-resize-handle.resizing { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.25); + color: var(--mm-primary); +} + +.mm-plot-worldbook-header { + padding: 10px 16px; + background: var(--mm-bg-secondary); + display: flex; + align-items: center; + gap: 10px; + cursor: pointer; + user-select: none; +} + +.mm-plot-worldbook-header:hover { + background: rgba(255, 255, 255, 0.03); +} + +.mm-plot-worldbook-title { + flex: 1; + font-size: 0.9em; + font-weight: 500; + color: var(--mm-text); + display: flex; + align-items: center; + gap: 8px; +} + +.mm-plot-worldbook-title i { + color: var(--mm-primary); +} + +.mm-plot-worldbook-badge { + font-size: 0.8em; + padding: 2px 8px; + background: var(--mm-bg-card); + border-radius: 10px; + color: var(--mm-text-muted); +} + +.mm-plot-worldbook-arrow { + color: var(--mm-text-muted); + transition: transform 0.3s ease; +} + +.mm-plot-worldbook-section.collapsed .mm-plot-worldbook-arrow { + transform: rotate(-90deg); +} + +.mm-plot-worldbook-body { + padding: 8px 12px; + flex: 1; + overflow-y: auto; + background: var(--mm-bg); +} + +/* 世界书搜索框 */ +.mm-plot-worldbook-search { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 10px; + background: var(--mm-bg-secondary); + border-radius: var(--mm-radius); + margin-bottom: 8px; + position: sticky; + top: 0; + z-index: 1; +} + +.mm-plot-worldbook-search i.fa-search { + color: var(--mm-text-muted); + font-size: 0.85em; +} + +.mm-plot-worldbook-search input { + flex: 1; + background: none; + border: none; + color: var(--mm-text); + font-size: 0.85em; + outline: none; +} + +.mm-plot-worldbook-search input::placeholder { + color: var(--mm-text-muted); +} + +.mm-btn-icon-small { + background: none; + border: none; + color: var(--mm-text-muted); + cursor: pointer; + padding: 2px 4px; + font-size: 0.8em; + border-radius: 3px; +} + +.mm-btn-icon-small:hover { + color: var(--mm-text); + background: rgba(255, 255, 255, 0.1); +} + +/* 搜索高亮 */ +.mm-search-highlight { + background: rgba(255, 193, 7, 0.3); + border-radius: 2px; + padding: 0 1px; +} + +.mm-plot-worldbook-list { + display: flex; + flex-direction: column; + gap: 4px; +} + +/* 世界书列表项 */ +.mm-plot-book-item { + background: var(--mm-bg-secondary); + border-radius: calc(var(--mm-radius) - 2px); + overflow: hidden; +} + +.mm-plot-book-item.selected { + background: rgba(var(--mm-primary-rgb, 74, 144, 217), 0.15); +} + +.mm-plot-book-header { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 10px; + cursor: pointer; + font-size: 0.9em; +} + +.mm-plot-book-header:hover { + background: rgba(255, 255, 255, 0.03); +} + +.mm-plot-book-checkbox { + width: 14px; + height: 14px; + cursor: pointer; + accent-color: var(--mm-primary); +} + +.mm-plot-book-name { + flex: 1; + font-weight: 500; + color: var(--mm-text); +} + +.mm-plot-book-count { + font-size: 0.85em; + color: var(--mm-text-muted); +} + +.mm-plot-book-expand { + color: var(--mm-text-muted); + font-size: 0.8em; + transition: transform 0.2s ease; +} + +.mm-plot-book-item.expanded .mm-plot-book-expand { + transform: rotate(90deg); +} + +/* 世界书条目列表 */ +.mm-plot-book-entries { + display: none; + padding: 4px 8px 8px 28px; + border-top: 1px solid var(--mm-border); + background: rgba(0, 0, 0, 0.1); + max-height: 100px; + overflow-y: auto; +} + +.mm-plot-book-item.expanded .mm-plot-book-entries { + display: block; +} + +.mm-plot-entry-item { + display: flex; + align-items: center; + gap: 6px; + padding: 4px 6px; + font-size: 0.85em; + color: var(--mm-text-muted); + border-radius: 3px; +} + +.mm-plot-entry-item:hover { + background: rgba(255, 255, 255, 0.03); + color: var(--mm-text); +} + +.mm-plot-entry-checkbox { + width: 12px; + height: 12px; + cursor: pointer; + accent-color: var(--mm-primary); +} + +.mm-plot-entry-name { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.mm-plot-loading, +.mm-plot-empty { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 16px; + color: var(--mm-text-muted); + font-size: 0.9em; +} + +/* 底部操作区 */ +.mm-plot-panel-footer { + padding: 12px 16px; + background: var(--mm-bg-secondary); + border-top: 1px solid var(--mm-border); + border-radius: 0 0 var(--mm-radius) var(--mm-radius); +} + +.mm-plot-input-area { + display: flex; + gap: 8px; + margin-bottom: 10px; +} + +.mm-plot-input { + flex: 1; + padding: 8px 12px; + border: 1px solid var(--mm-border); + border-radius: calc(var(--mm-radius) - 2px); + background: var(--mm-bg); + color: var(--mm-text); + font-size: 0.9em; + outline: none; + transition: border-color 0.2s ease; +} + +.mm-plot-input:focus { + border-color: var(--mm-primary); +} + +.mm-plot-input::placeholder { + color: var(--mm-text-muted); +} + +.mm-plot-actions { + display: flex; + gap: 8px; + justify-content: flex-end; +} + +.mm-plot-actions .mm-btn { + padding: 8px 16px; + font-size: 0.9em; +} + +.mm-btn-success { + background: var(--mm-success); + color: white; + border: none; +} + +.mm-btn-success:hover { + background: #218838; +} + +.mm-btn-success:disabled { + background: #1e5631; + opacity: 0.6; + cursor: not-allowed; +} + +/* 剧情优化面板拖动状态 */ +.mm-plot-panel.mm-dragging { + opacity: 0.95; + transition: none !important; + cursor: grabbing; + box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6); +} + +.mm-plot-panel.mm-dragging .mm-plot-panel-header { + cursor: grabbing; +} + +/* 剧情优化面板移动端适配 */ +@media (max-width: 768px) { + .mm-plot-panel { + width: calc(100vw - 24px); + max-width: 420px; + max-height: 70vh; + } + + .mm-plot-chat-container { + max-height: 45vh; + } + + .mm-plot-actions { + flex-wrap: wrap; + } + + .mm-plot-actions .mm-btn { + flex: 1 1 calc(50% - 4px); + min-width: 0; + padding: 10px 8px; + font-size: 12px; + } + + .mm-plot-actions .mm-btn:last-child { + flex: 1 1 100%; + } + + /* 世界书选择区域移动端适配 */ + .mm-plot-worldbook-section { + max-height: 300px; + } + + .mm-plot-worldbook-header { + padding: 8px 12px; + } + + .mm-plot-worldbook-title { + font-size: 0.85em; + } + + .mm-plot-worldbook-body { + padding: 6px 10px; + } + + .mm-plot-worldbook-search input { + font-size: 13px; + padding: 6px 8px; + } + + .mm-plot-worldbook-list { + gap: 6px; + } + + .mm-plot-worldbook-item { + padding: 8px 10px; + } + + .mm-plot-worldbook-item-name { + font-size: 12px; + } + + /* 世界书拖拽手柄移动端适配 */ + .mm-plot-worldbook-resize-handle { + height: 18px; + touch-action: none; + } +} + +@media (max-width: 480px) { + .mm-plot-panel { + width: 70vw; + min-width: 260px; + max-width: 320px; + max-height: 65vh; + } + + .mm-plot-panel-header { + padding: 8px 12px; + } + + .mm-plot-panel-title { + font-size: 13px; + } + + .mm-plot-chat-container { + padding: 10px; + max-height: 40vh; + } + + .mm-plot-panel-footer { + padding: 10px 12px; + } + + .mm-plot-actions .mm-btn { + padding: 8px 10px; + font-size: 11px; + } + + /* 世界书选择区域小屏幕适配 */ + .mm-plot-worldbook-section { + max-height: 250px; + } + + .mm-plot-worldbook-header { + padding: 6px 10px; + gap: 6px; + } + + .mm-plot-worldbook-title { + font-size: 0.8em; + gap: 6px; + } + + .mm-plot-worldbook-badge { + font-size: 0.7em; + padding: 2px 6px; + } + + .mm-plot-worldbook-body { + padding: 4px 8px; + } + + .mm-plot-worldbook-search { + gap: 6px; + } + + .mm-plot-worldbook-search input { + font-size: 12px; + padding: 5px 6px; + } + + .mm-plot-worldbook-item { + padding: 6px 8px; + } + + .mm-plot-worldbook-item-name { + font-size: 11px; + } + + .mm-plot-worldbook-item-count { + font-size: 10px; + } + + /* 世界书拖拽手柄小屏幕适配 */ + .mm-plot-worldbook-resize-handle { + height: 22px; + touch-action: none; + } + + /* 输入区域小屏幕适配 */ + .mm-plot-input-area { + gap: 6px; + } + + .mm-plot-input { + font-size: 13px; + padding: 8px 10px; + } +} + +/* ============================================================================ + 游戏时间板块样式 + ============================================================================ */ + +/* 游戏区 */ +.mm-game-section { + margin-top: 16px; + padding-top: 16px; + padding-bottom: 180px; + border-top: 1px solid var(--mm-border); +} + +.mm-game-chip { + border-left: 3px solid #ff69b4; + cursor: pointer; + transition: all 0.2s ease; +} + +.mm-game-chip:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(74, 144, 217, 0.3); +} + +/* 游戏面板 - 参考搜索面板 */ +.mm-game-panel { + position: fixed; + width: 600px; + height: 680px; + background: var(--mm-bg); + border: 1px solid var(--mm-border); + border-radius: var(--mm-radius); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); + z-index: 1000002; + display: none; + flex-direction: column; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + overflow: hidden; +} + +.mm-game-panel.mm-visible { + display: flex; +} + +/* 面板头部 */ +.mm-game-panel-header { + padding: 12px 16px; + background: var(--mm-bg-secondary); + border-bottom: 1px solid var(--mm-border); + border-radius: var(--mm-radius) var(--mm-radius) 0 0; + cursor: move; + display: flex; + justify-content: space-between; + align-items: center; + user-select: none; + flex-shrink: 0; +} + +.mm-game-title { + font-size: 14px; + font-weight: 600; + color: var(--mm-text); + display: flex; + align-items: center; + gap: 8px; +} + +.mm-game-title i { + color: var(--mm-primary); +} + +.mm-game-panel-controls { + display: flex; + align-items: center; + gap: 4px; +} + +/* 全屏按钮始终隐藏(使用最小化按钮切换图标即可) */ +.mm-game-fullscreen { + display: none; +} + +.mm-game-iframe { + flex: 1; + width: 100%; + border: none; + background: #1a1a2e; +} + +.mm-game-viewport { + position: relative; + flex: 1; + width: 100%; + overflow: hidden; + background: #000; +} + +.mm-game-viewport .mm-game-iframe { + width: 100%; + height: 100%; + background: #000; +} + +.mm-game-panel.mm-rotate-landscape .mm-game-iframe { + position: absolute; + top: 50%; + left: 50%; + width: var(--mm-viewport-h, 100%); + height: var(--mm-viewport-w, 100%); + transform: translate(-50%, -50%) rotate(90deg); + transform-origin: center center; +} + +.mm-game-landscape-overlay { + display: none; + position: absolute; + inset: 0; + z-index: 1000003; + align-items: center; + justify-content: center; + padding: 16px; + background: rgba(0, 0, 0, 0.8); + color: #fff; + text-align: center; +} + +.mm-game-landscape-overlay .mm-game-landscape-card { + width: min(520px, 100%); + padding: 16px; + border-radius: 12px; + border: 1px solid rgba(255, 255, 255, 0.16); + background: rgba(10, 10, 18, 0.92); + box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); +} + +.mm-game-landscape-overlay .mm-game-landscape-title { + font-size: 16px; + font-weight: 700; + margin-bottom: 8px; +} + +.mm-game-landscape-overlay .mm-game-landscape-desc { + font-size: 13px; + line-height: 1.5; + opacity: 0.9; + margin-bottom: 12px; +} + +.mm-game-landscape-overlay .mm-game-landscape-actions { + display: flex; + gap: 8px; + justify-content: center; + flex-wrap: wrap; +} + +.mm-game-panel.mm-need-landscape .mm-game-landscape-overlay { + display: flex; +} + + +/* 最小化 */ +.mm-game-panel.mm-minimized { + width: 220px; + height: 48px; +} + +.mm-game-panel.mm-minimized .mm-game-iframe { + display: none; +} + +/* 最小化时标题截断,确保按钮可见 */ +.mm-game-panel.mm-minimized .mm-game-title { + flex: 1; + min-width: 0; + overflow: hidden; +} + +.mm-game-panel.mm-minimized .mm-game-title-text { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 100px; +} + +.mm-game-panel.mm-minimized .mm-game-panel-controls { + flex-shrink: 0; +} + + +/* 移动端 - 游戏面板需要更大空间 */ +@media (max-width: 600px) { + .mm-game-panel { + width: calc(100vw - 20px); + height: calc(100vh - 120px); + max-width: 400px; + max-height: 650px; + top: 60px; + left: 50%; + transform: translateX(-50%); + } + + .mm-game-panel.mm-minimized { + width: 200px; + height: 44px; + } + + .mm-game-panel-header { + padding: 10px 12px; + } + + /* 笨鸟先飞专用 - 缩小容器 */ + .mm-game-panel.mm-game-clumsy { + height: calc(50vh); + max-height: 375px; + } + + /* 笨鸟先飞最小化 - 覆盖大尺寸样式 */ + .mm-game-panel.mm-game-clumsy.mm-minimized { + width: 200px; + height: 44px; + max-height: none; + } +} + +/* 移动端全屏游戏模式(用于 3D城市 / 马里奥) */ +@media (pointer: coarse) { + .mm-game-panel.mm-mobile-fullscreen { + top: 0; + left: 0; + right: 0; + bottom: 0; + width: 100vw; + height: 100vh; + max-width: none; + max-height: none; + border-radius: 0; + transform: none; + } + + @supports (height: 100dvh) { + .mm-game-panel.mm-mobile-fullscreen { + width: 100dvw; + height: 100dvh; + } + } + + .mm-game-panel.mm-mobile-fullscreen .mm-game-panel-header { + cursor: default; + padding-top: calc(12px + env(safe-area-inset-top)); + padding-left: calc(16px + env(safe-area-inset-left)); + padding-right: calc(16px + env(safe-area-inset-right)); + } + + .mm-game-panel.mm-mobile-fullscreen .mm-game-iframe { + background: #000; + } +} + +/* 3D城市专用 - 需要更大空间 */ +.mm-game-panel.mm-game-city3d { + width: 90vw; + height: 90vh; + max-width: 1200px; + max-height: 800px; +} + +/* 3D城市最小化 - 覆盖大尺寸样式 */ +.mm-game-panel.mm-game-city3d.mm-minimized { + width: 220px; + height: 48px; + max-width: none; + max-height: none; +} + +@media (max-width: 600px) { + .mm-game-panel.mm-game-city3d { + width: 95vw; + height: 85vh; + max-width: none; + max-height: none; + top: 5vh; + left: 2.5vw; + border-radius: 8px; + } + + .mm-game-panel.mm-game-city3d.mm-minimized { + width: 180px; + height: 40px; + } +} + +/* 超级马里奥专用 - 需要更大空间 */ +.mm-game-panel.mm-game-mario { + width: 80vw; + height: 75vh; + max-width: 1000px; + max-height: 750px; +} + +.mm-game-panel.mm-game-mario.mm-minimized { + width: 220px; + height: 48px; + max-width: none; + max-height: none; +} + +@media (max-width: 600px) { + .mm-game-panel.mm-game-mario { + width: 95vw; + height: 85vh; + max-width: none; + max-height: none; + top: 5vh; + left: 2.5vw; + border-radius: 8px; + } + + .mm-game-panel.mm-game-mario.mm-minimized { + width: 180px; + height: 40px; + } +} + +/* 人生重开专用 - 需要更高的面板 */ +.mm-game-panel.mm-game-lifeRestart { + height: 85vh; + max-height: 900px; +} + +.mm-game-panel.mm-game-lifeRestart.mm-minimized { + width: 220px; + height: 48px; + max-height: none; +} + +@media (max-width: 600px) { + .mm-game-panel.mm-game-lifeRestart { + height: 90vh; + max-height: none; + } + + .mm-game-panel.mm-game-lifeRestart.mm-minimized { + width: 180px; + height: 40px; + } +} + +/* ============================================================================ + 流程配置弹窗样式 + ============================================================================ */ + +.mm-flow-config-list { + display: flex; + flex-direction: column; + gap: 12px; +} + +.mm-flow-group-header { + cursor: pointer; +} + +.mm-flow-source-list { + display: flex; + flex-direction: column; + gap: 6px; +} + +.mm-flow-source-item { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + background: var(--mm-bg-secondary); + border: 1px solid var(--mm-border); + border-radius: calc(var(--mm-radius) - 2px); + cursor: grab; + transition: all 0.2s ease; +} + +.mm-flow-source-item:hover { + border-color: var(--mm-primary); + background: rgba(74, 144, 217, 0.1); +} + +.mm-flow-source-item .mm-drag-handle { + color: var(--mm-text-muted); + font-size: 12px; + cursor: grab; +} + +.mm-flow-source-item:active { + cursor: grabbing; +} + +.mm-flow-source-item .mm-drag-handle:active { + cursor: grabbing; +} + +.mm-flow-source-name { + flex: 1; + font-size: 13px; + color: var(--mm-text); +} + +/* 拖拽状态 */ +.mm-flow-source-item.mm-dragging { + opacity: 0.5; + border-style: dashed; +} + +.mm-flow-source-item.mm-drag-over-top { + border-top: 2px solid var(--mm-primary); +} + +.mm-flow-source-item.mm-drag-over-bottom { + border-bottom: 2px solid var(--mm-primary); +} + +/* 流程配置弹窗特定样式 */ +.mm-flow-config-modal-content { + display: flex; + flex-direction: column; + min-height: 300px; + max-height: 80vh; + resize: none; +} + +.mm-flow-config-body { + flex: 1; + overflow-y: auto; + min-height: 150px; +} + +.mm-flow-config-resize-handle { + width: 100%; + height: 8px; + cursor: ns-resize; + background: var(--mm-border); + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + transition: background 0.2s ease; +} + +.mm-flow-config-resize-handle::after { + content: ""; + width: 40px; + height: 3px; + background: var(--mm-text-muted); + border-radius: 2px; + opacity: 0.5; +} + +.mm-flow-config-resize-handle:hover { + background: var(--mm-primary); +} + +.mm-flow-config-resize-handle:hover::after { + opacity: 1; +} + +/* ============================================================================ + 发送前检查弹窗样式 + ============================================================================ */ + +/* 内容区域容器 - 修复空白问题 */ +.mm-part-content-area { + margin-top: 8px; +} + +/* 发送前检查中的编辑器容器 - 覆盖默认最小高度 */ +.mm-request-block .mm-resizable-editor-container { + min-height: auto; + display: flex; + flex-direction: column; +} + +/* 发送前检查中的内容编辑区域 */ +.mm-request-block .mm-prompt-content { + background: var(--mm-bg-secondary); + padding: 8px; + overflow: auto; + font-size: 11px; + white-space: pre-wrap; + word-wrap: break-word; + border: 1px solid var(--mm-border); + border-radius: 4px 4px 0 0; + cursor: text; + outline: none; + box-sizing: border-box; + min-height: 60px; + max-height: 300px; +} + +.mm-request-block .mm-prompt-content:focus { + border-color: var(--mm-primary); +} + +/* 条件块样式 */ +.mm-prompt-part-block { + margin-bottom: 12px; + padding: 10px; + background: var(--mm-bg); + border-radius: var(--mm-radius); + border: 2px solid transparent; + transition: all 0.2s ease; +} + +.mm-prompt-part-block:hover { + border-color: var(--mm-border); +} + +.mm-prompt-part-block.mm-dragging { + opacity: 0.5; + border-style: dashed; + border-color: var(--mm-primary); +} + +/* 条件块标题区域 */ +.mm-prompt-part-block > div:first-child { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + cursor: pointer; + user-select: none; +} + +/* 请求块样式 */ +.mm-request-block { + margin-bottom: 20px; + padding: 15px; + background: var(--mm-bg-card); + border-radius: var(--mm-radius); + border: 1px solid var(--mm-border); +} + +.mm-request-content { + margin-top: 10px; +} + +/* 删除按钮样式 */ +.mm-part-delete-btn { + background: none; + border: none; + color: var(--mm-text-muted); + cursor: pointer; + font-size: 11px; + padding: 3px 6px; + margin-right: 4px; + opacity: 0.6; + transition: opacity 0.2s ease, color 0.2s ease; +} + +.mm-part-delete-btn:hover { + opacity: 1; + color: var(--mm-danger); +} + +/* 折叠按钮样式 */ +.mm-part-toggle-btn, +.mm-request-toggle-btn { + background: none; + border: none; + color: var(--mm-text-secondary); + cursor: pointer; + font-size: 11px; + padding: 3px; + transition: color 0.2s ease; +} + +.mm-part-toggle-btn:hover, +.mm-request-toggle-btn:hover { + color: var(--mm-primary); +} + +/* ============================================================================ + 多端适配 - 弹窗界面 + ============================================================================ */ + +/* 平板适配 (768px) */ +@media (max-width: 768px) { + /* 通用弹窗适配 */ + .mm-modal-content { + width: 95vw !important; + max-width: 95vw !important; + } + + .mm-modal-large { + width: 95vw !important; + max-width: 95vw !important; + } + + /* 流程配置弹窗 */ + #mm-flow-config-modal .mm-modal-content { + width: 95vw !important; + max-width: 95vw !important; + max-height: 85vh; + } + + #mm-flow-config-modal .mm-flow-config-body { + padding: 12px; + } + + #mm-flow-config-modal .mm-modal-footer { + flex-wrap: wrap; + gap: 8px; + } + + /* AI配置弹窗 */ + #mm-ai-config-modal .mm-modal-content { + width: 95vw !important; + max-width: 95vw !important; + max-height: 90vh; + } + + #mm-ai-config-modal .mm-modal-body { + padding: 12px; + } + + #mm-ai-config-modal .mm-form-group label { + font-size: 13px; + } + + #mm-ai-config-modal .mm-modal-footer { + flex-wrap: wrap; + gap: 8px; + } + + /* 剧情优化面板 - 平板端 */ + .mm-plot-panel:not(.mm-dragging) { + top: 60px; + right: 16px; + left: auto; + transform: none; + } + + /* 记忆搜索面板 - 平板端 */ + .mm-search-panel:not(.mm-dragging) { + top: 60px; + left: 16px; + right: auto; + transform: none; + } + + /* 进度面板 - 移动端安全定位(参考剧情优化面板,固定在左上角) */ + .mm-message-progress-panel:not(.mm-dragging):not(.mm-user-positioned) { + top: 60px !important; + left: 16px !important; + right: auto !important; + transform: none !important; + max-height: 60vh !important; + } + + /* 用户手动拖动后,允许自定义位置 */ + .mm-message-progress-panel.mm-user-positioned { + top: unset !important; + left: unset !important; + right: unset !important; + transform: none !important; + } +} + +/* 手机适配 (480px) */ +@media (max-width: 480px) { + /* 通用弹窗适配 */ + .mm-modal-content { + width: calc(100vw - 16px) !important; + max-width: calc(100vw - 16px) !important; + max-height: 90vh; + border-radius: 8px; + } + + .mm-modal-large { + width: calc(100vw - 16px) !important; + max-width: calc(100vw - 16px) !important; + } + + .mm-modal-header { + padding: 12px; + } + + .mm-modal-header h4 { + font-size: 14px; + } + + .mm-modal-body { + padding: 12px; + } + + .mm-modal-footer { + padding: 12px; + flex-direction: column; + gap: 8px; + } + + .mm-modal-footer .mm-btn { + width: 100%; + justify-content: center; + } + + /* 流程配置弹窗 */ + #mm-flow-config-modal .mm-flow-config-modal-content { + min-height: 250px; + max-height: 85vh; + } + + #mm-flow-config-modal .mm-flow-group-header { + font-size: 13px; + padding: 8px 10px; + } + + #mm-flow-config-modal .mm-flow-source-item { + padding: 8px 10px; + font-size: 12px; + } + + #mm-flow-config-modal .mm-flow-config-resize-handle { + height: 18px; + touch-action: none; + } + + #mm-flow-config-modal .mm-flow-config-resize-handle::after { + width: 50px; + height: 4px; + } + + /* AI配置弹窗 */ + #mm-ai-config-modal .mm-config-tabs { + flex-wrap: wrap; + gap: 4px; + } + + #mm-ai-config-modal .mm-config-tab { + flex: 1; + min-width: 80px; + padding: 8px 10px; + font-size: 12px; + text-align: center; + } + + #mm-ai-config-modal input, + #mm-ai-config-modal select { + padding: 8px 10px; + font-size: 13px; + } + + #mm-ai-config-modal .mm-slider-value { + font-size: 12px; + } + + /* 剧情优化面板 - 手机端位置 */ + .mm-plot-panel:not(.mm-dragging) { + top: 60px; + right: 8px; + left: auto; + transform: none; + } + + /* 记忆搜索面板 - 手机端位置 */ + .mm-search-panel:not(.mm-dragging) { + top: 60px; + left: 8px; + right: auto; + transform: none; + } + + /* 进度面板 - 手机端安全定位(参考剧情优化面板,固定在左上角) */ + .mm-message-progress-panel:not(.mm-dragging):not(.mm-user-positioned) { + top: 60px !important; + left: 8px !important; + right: auto !important; + transform: none !important; + max-height: 55vh !important; + width: calc(100vw - 24px) !important; + max-width: 300px !important; + } + + /* 用户手动拖动后,允许自定义位置 */ + .mm-message-progress-panel.mm-user-positioned { + top: unset !important; + left: unset !important; + right: unset !important; + transform: none !important; + } + + /* 汇总检查弹窗(动态创建) */ + .mm-modal.mm-modal-visible .mm-modal-content { + width: calc(100vw - 16px) !important; + max-width: calc(100vw - 16px) !important; + height: auto !important; + max-height: 85vh !important; + } +} + +/* ============================================================================ + 隐藏破限词相关元素(功能保留,仅UI隐藏) + ============================================================================ */ + +/* 流程配置界面 - 隐藏破限词条件块 */ +.mm-flow-source-item[data-source="jailbreak"] { + display: none !important; +} + +/* 发送前检查界面 - 隐藏破限词部分块 */ +.mm-prompt-part-block[data-source="jailbreak"] { + display: none !important; +} diff --git a/ui/panel.html b/ui/panel.html new file mode 100644 index 0000000..f9db188 --- /dev/null +++ b/ui/panel.html @@ -0,0 +1,145 @@ + +
              +
              +

              记忆管理并发系统

              +
              + + + + +
              +
              +
              +
              +
              + 已导入世界书 + 0 +
              +
              +
              + +

              点击右上角导入世界书

              +
              +
              +
              +
              +
              + 更新状态 + +
              +
              +
              暂无更新
              +
              +
              +
              +
              + 运行状态 + +
              +
              +
              +
              + + 就绪 +
              +
              + 0/0 +
              +
              +
              +
              +
              最后处理: -
              +
              处理耗时: -
              +
              +
              +
              +
              +
              By:可乐、繁华 | v0.3.0
              +
              +
              +
              +
              + 纯色 +
              + + + + + + +
              +
              +
              + 星空 +
              + + + +
              +
              +
              +
              +
              + 游戏时间 +
              +
              +
              + 人生重开 +
              +
              + 笨鸟先飞 +
              +
              + 3D城市 +
              +
              + 俄罗斯方块 +
              +
              + 超级马里奥 +
              +
              + 复古贪吃蛇 +
              +
              + 贪吃蛇大作战 +
              +
              +
              +
              +
              diff --git a/ui/plot-optimize-panel.html b/ui/plot-optimize-panel.html new file mode 100644 index 0000000..1a29f73 --- /dev/null +++ b/ui/plot-optimize-panel.html @@ -0,0 +1,111 @@ + +
              +
              + + + 剧情优化助手 + +
              + +
              +
              + + +
              + +
              +
              + +
              +
              +
              + 你好!我是剧情优化助手,可以帮你优化和调整角色扮演的剧情内容。 +

              + 请先选择要参考的世界书,然后输入你的需求,我会为你生成优化建议。 +
              +
              +
              +
              +
              + +
              + +
              + + +
              +
              + 等待生成... +
              +
              + 世界书: 0 +
              +
              + + + + + +
              +
              + + + 世界书选择 + + 已选 0 + + +
              +
              + + + + + +
              + +
              +
              + +
              + +
              +
              +
              diff --git a/ui/search-dialog.html b/ui/search-dialog.html new file mode 100644 index 0000000..a59992b --- /dev/null +++ b/ui/search-dialog.html @@ -0,0 +1,62 @@ + +
              +
              + + + 记忆搜索助手 + +
              + +
              +
              + + +
              + +
              + +
              + +
              + +
              +
              + 已选: 0 + / + 目标: 5 +
              +
              + + + 其他任务: 0/0 + +
              +
              + + +
              diff --git a/ui/settings.html b/ui/settings.html new file mode 100644 index 0000000..14d7d7d --- /dev/null +++ b/ui/settings.html @@ -0,0 +1,907 @@ + +
              +
              +

              设置

              + +
              + +
              + +
              +

              基础设置

              +
              + +
              + + 5 +
              + 每轮包含1条用户消息+1条回复,0=不读取上下文 +
              + + +
              +
              +
              + + 功能开关 +
              + +
              +
              +
              +
              + +
              +
              + +
              +
              + +
              +
              + +
              +
              + +
              +
              + +
              +
              +
              +
              + + +
              +
              +
              + + 记忆搜索助手 + 关闭 +
              + +
              +
              +
              + + 开启后会在索引合并前弹出搜索助手界面 +
              +
              +
              + + +
              +
              +
              + + 剧情优化助手 + 关闭 +
              + +
              +
              +
              + +
              + + 发送消息时自动生成剧情优化建议,确认后注入到消息中 +
              + + +
              +
              + + + 剧情优化 + + 未配置 +
              +
              + +
              +
              +
              +
              +
              + + +
              +
              +
              + + 标签过滤 + 关闭 +
              + +
              +
              + +
              +
              + +
              +
              +
              + +
              +
              + + +
              +
              + 只保留指定标签 <tag>...</tag> 内的内容 +
              + + +
              +
              + +
              +
              +
              + +
              +
              + + +
              +
              + 移除指定标签 <tag>...</tag> 及其内容 +
              + + + + + 提示:两种模式可同时启用,先提取后排除 + +
              +
              + + +
              +
              +
              + + 世界书控制 + 未选择 +
              + +
              +
              + +
              + +
              +
              + 世界书列表 + +
              +
              +
              + + 加载中... +
              +
              + +
              + +
              +
              + + + + + + + + + 勾选世界书后可查看条目统计 + +
              +
              +
              + + + + + +
              +
              +
              + + AI 配置 +
              + +
              +
              + 为每个世界书分类配置独立的 AI +
              + +
              +
              + + + + +
              +
              +
              + + +
              +
              +
              + + 配置管理 +
              + +
              +
              +
              + + +
              +
              +
              +
              +
              + + +
              +
              +
              +

              选择提示词界面

              + +
              + +
              + +
              + +
              + + + +
              + 关键词提示词用于分类/并发/索引合并API;历史事件提示词用于总结世界书API;剧情优化助手用于剧情优化功能 +
              + + +
              + + + 选择后使用该提示词预设 +
              + + +
              +
              + +
              + + mainPrompt 在数据注入前,systemPrompt 在数据注入后,finalSystemDirective 为最终注入 +
              + + +
              + +
              + +
              +
              + + 编辑后点击保存按钮保存更改。 + 提示内必须包含:<数据注入区>...</数据注入区>sulv1sulv2sulv4 + +
              +
              + + +
              +
              +
              + + +
              +
              +
              +

              剧情优化助手

              + +
              +
              + +
              +
              + +
              +
              + + +
              + +
              + + +
              +
              + + +
              +
              +
              + + 选择世界书 + 已选 0 +
              +
              + +
              + +
              +
              +
              + + +
              + +
              +
              +
              +
              +
              +
              +
              + + +
              +
              +
              +

              配置 AI: -

              + +
              + +
              + + + + +
              +
              + +
              + + + + +
              +
              + +
              + + + 填写到 /v1 即可,会自动补全完整路径 +
              + +
              + + + 本地模型可留空 +
              + +
              + +
              + + +
              +
              + +
              +
              + + +
              +
              + + + 0.7 +
              +
              + + +
              + +
              + + 0.6 +
              + 数值越小越严格,数值越大越宽松 (0.1-1.0)。占位符:sulv1 +
              + + +
              + + + AI 最多提取的关键词数量。占位符:sulv4 +
              + + +
              + + + AI 最多提取的历史事件数量。占位符:sulv2 +
              + + +
              +
              + + + 可用变量: {{system}}, {{user}}, {{model}}, {{max_tokens}}, + {{temperature}} +
              +
              + + +
              +
              + +
              + + +
              +
              + + + +
              + + +
              +
              + + +
              +
              +
              +

              流程配置 - 来源排序

              + +
              +
              +

              + 拖拽调整各功能模块中来源的默认显示顺序。发送前检查界面将使用此配置作为默认顺序。 +

              +
              + +
              + +
              +
              + +
              +

              >>0?(r=q+(l<<2)|0,(r|0)!=(o|0)):0){f[m>>2]=o+(~((o+-4-r|0)>>>2)<<2);s=n;t=k;v=j}else{s=n;t=k;v=j}else{Ci(g,l-p|0);p=f[h>>2]|0;s=p;t=p;v=f[i>>2]|0}p=v-t|0;l=p>>2;f[c>>2]=0;j=c+4|0;f[j>>2]=0;k=c+8|0;f[k>>2]=0;if(l|0){if((p|0)<0)aq(c);p=((l+-1|0)>>>5)+1|0;n=ln(p<<2)|0;f[c>>2]=n;f[k>>2]=p;f[j>>2]=l;j=l>>>5;sj(n|0,0,j<<2|0)|0;p=l&31;l=n+(j<<2)|0;if(p|0)f[l>>2]=f[l>>2]&~(-1>>>(32-p|0))}p=a+20|0;l=0;j=s;s=t;t=v;while(1){if(l>>>0>2>>>0){w=0;x=0;y=l;z=s;A=j}else{B=25;break}while(1){v=x>>>5;n=1<<(x&31);do if(!(f[(f[c>>2]|0)+(v<<2)>>2]&n)){k=f[A+(x<<2)>>2]|0;if((f[k+8>>2]|0)!=(f[k+4>>2]|0)){r=0;o=1;m=A;q=k;while(1){k=f[(f[q+4>>2]|0)+(r<<2)>>2]|0;C=0;D=m;while(1){E=f[D+(x<<2)>>2]|0;if((C|0)>=(Ra[f[(f[E>>2]|0)+24>>2]&127](E,k)|0)){F=o;break}E=f[(f[h>>2]|0)+(x<<2)>>2]|0;G=Sa[f[(f[E>>2]|0)+28>>2]&31](E,k,C)|0;if((G|0)!=(x|0)?(E=f[(f[p>>2]|0)+(G<<2)>>2]|0,(1<<(E&31)&f[(f[c>>2]|0)+(E>>>5<<2)>>2]|0)==0):0){F=0;break}C=C+1|0;D=f[h>>2]|0}r=r+1|0;m=f[h>>2]|0;q=f[m+(x<<2)>>2]|0;if(r>>>0>=(f[q+8>>2]|0)-(f[q+4>>2]|0)>>2>>>0)break;else o=F}o=m;if(F)H=o;else{I=w;J=y;K=o;break}}else H=z;f[(f[g>>2]|0)+(y<<2)>>2]=x;o=(f[c>>2]|0)+(v<<2)|0;f[o>>2]=f[o>>2]|n;I=1;J=y+1|0;K=H}else{I=w;J=y;K=z}while(0);x=x+1|0;L=f[i>>2]|0;M=L-K>>2;A=K;if(x>>>0>=M>>>0)break;else{w=I;y=J;z=K}}if(J>>>0>>0&(I^1)){N=0;break}else{l=J;j=A;s=K;t=L}}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2]=S;H=(f[e>>2]|0)+(M<<2)|0;f[H>>2]=f[H>>2]|y;W=1;X=U+1|0}else{W=T;X=U}}else{W=T;X=U}S=S+1|0;if((S|0)>=(l|0))break;else{T=W;U=X}}if(W|(X|0)>=(l|0))R=X;else{O=0;break a}}bg(f[(f[h>>2]|0)+(A<<2)>>2]|0,d);P=f[h>>2]|0;Q=f[i>>2]|0}a=a+1|0;if(a>>>0>=Q-P>>2>>>0){O=1;break}else{L=P;K=P;J=Q}}}while(0);Q=f[e>>2]|0;if(Q|0)Oq(Q);Q=f[d>>2]|0;if(Q|0){d=f[B>>2]|0;if((d|0)!=(Q|0))f[B>>2]=d+(~((d+-4-Q|0)>>>2)<<2);Oq(Q)}N=O}O=f[c>>2]|0;if(!O){u=b;return N|0}Oq(O);u=b;return N|0}function yc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;c=f[4788]|0;d=f[a+-4>>2]|0;a=d&-8;e=b+a|0;do if(!(d&1)){g=f[b>>2]|0;if(!(d&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((f[4789]|0)==(h|0)){j=e+4|0;k=f[j>>2]|0;if((k&3|0)!=3){l=h;m=i;n=h;break}f[4786]=i;f[j>>2]=k&-2;f[h+4>>2]=i|1;f[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=f[h+8>>2]|0;j=f[h+12>>2]|0;if((j|0)==(g|0)){f[4784]=f[4784]&~(1<>2]=j;f[j+8>>2]=g;l=h;m=i;n=h;break}}g=f[h+24>>2]|0;j=f[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=f[o>>2]|0;if(!p){q=f[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=f[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=f[o>>2]|0;if(!p)break;else{s=p;t=o}}f[t>>2]=0;r=s}else{o=f[h+8>>2]|0;f[o+12>>2]=j;f[j+8>>2]=o;r=j}while(0);if(g){j=f[h+28>>2]|0;o=19440+(j<<2)|0;if((f[o>>2]|0)==(h|0)){f[o>>2]=r;if(!r){f[4785]=f[4785]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=i;n=h;break}}f[r+24>>2]=g;j=h+16|0;o=f[j>>2]|0;if(o|0){f[r+16>>2]=o;f[o+24>>2]=r}o=f[j+4>>2]|0;if(o){f[r+20>>2]=o;f[o+24>>2]=r;l=h;m=i;n=h}else{l=h;m=i;n=h}}else{l=h;m=i;n=h}}else{l=b;m=a;n=b}while(0);if(n>>>0>=e>>>0)return;b=e+4|0;a=f[b>>2]|0;if(!(a&1))return;if(!(a&2)){if((f[4790]|0)==(e|0)){r=(f[4787]|0)+m|0;f[4787]=r;f[4790]=l;f[l+4>>2]=r|1;if((l|0)!=(f[4789]|0))return;f[4789]=0;f[4786]=0;return}if((f[4789]|0)==(e|0)){r=(f[4786]|0)+m|0;f[4786]=r;f[4789]=n;f[l+4>>2]=r|1;f[n+r>>2]=r;return}r=(a&-8)+m|0;s=a>>>3;do if(a>>>0<256){t=f[e+8>>2]|0;c=f[e+12>>2]|0;if((c|0)==(t|0)){f[4784]=f[4784]&~(1<>2]=c;f[c+8>>2]=t;break}}else{t=f[e+24>>2]|0;c=f[e+12>>2]|0;do if((c|0)==(e|0)){d=e+16|0;o=d+4|0;j=f[o>>2]|0;if(!j){p=f[d>>2]|0;if(!p){u=0;break}else{v=p;w=d}}else{v=j;w=o}while(1){o=v+20|0;j=f[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=f[o>>2]|0;if(!j)break;else{v=j;w=o}}f[w>>2]=0;u=v}else{o=f[e+8>>2]|0;f[o+12>>2]=c;f[c+8>>2]=o;u=c}while(0);if(t|0){c=f[e+28>>2]|0;h=19440+(c<<2)|0;if((f[h>>2]|0)==(e|0)){f[h>>2]=u;if(!u){f[4785]=f[4785]&~(1<>2]|0)!=(e|0)&1)<<2)>>2]=u;if(!u)break}f[u+24>>2]=t;c=e+16|0;h=f[c>>2]|0;if(h|0){f[u+16>>2]=h;f[h+24>>2]=u}h=f[c+4>>2]|0;if(h|0){f[u+20>>2]=h;f[h+24>>2]=u}}}while(0);f[l+4>>2]=r|1;f[n+r>>2]=r;if((l|0)==(f[4789]|0)){f[4786]=r;return}else x=r}else{f[b>>2]=a&-2;f[l+4>>2]=m|1;f[n+m>>2]=m;x=m}m=x>>>3;if(x>>>0<256){n=19176+(m<<1<<2)|0;a=f[4784]|0;b=1<>2]|0;z=b}f[z>>2]=l;f[y+12>>2]=l;f[l+8>>2]=y;f[l+12>>2]=n;return}n=x>>>8;if(n)if(x>>>0>16777215)A=31;else{y=(n+1048320|0)>>>16&8;z=n<>>16&4;b=z<>>16&2;a=14-(n|y|z)+(b<>>15)|0;A=x>>>(a+7|0)&1|a<<1}else A=0;a=19440+(A<<2)|0;f[l+28>>2]=A;f[l+20>>2]=0;f[l+16>>2]=0;z=f[4785]|0;b=1<>>1)|0);n=f[a>>2]|0;while(1){if((f[n+4>>2]&-8|0)==(x|0)){B=73;break}C=n+16+(y>>>31<<2)|0;m=f[C>>2]|0;if(!m){B=72;break}else{y=y<<1;n=m}}if((B|0)==72){f[C>>2]=l;f[l+24>>2]=n;f[l+12>>2]=l;f[l+8>>2]=l;break}else if((B|0)==73){y=n+8|0;t=f[y>>2]|0;f[t+12>>2]=l;f[y>>2]=l;f[l+8>>2]=t;f[l+12>>2]=n;f[l+24>>2]=0;break}}else{f[4785]=z|b;f[a>>2]=l;f[l+24>>2]=a;f[l+12>>2]=l;f[l+8>>2]=l}while(0);l=(f[4792]|0)+-1|0;f[4792]=l;if(!l)D=19592;else return;while(1){l=f[D>>2]|0;if(!l)break;else D=l+8|0}f[4792]=-1;return}function zc(a){a=a|0;var c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[x>>2]|0;z=t;A=f[x+4>>2]|0}b[h>>0]=f[s+(q*12|0)+4>>2];if((A|0)>0|(A|0)==0&y>>>0>0){B=A;C=y;D=z}else{f[g>>2]=f[z+4>>2];f[e>>2]=f[g>>2];Me(z,e,h,p)|0;x=f[l>>2]|0;t=x+16|0;B=f[t+4>>2]|0;C=f[t>>2]|0;D=x}b[h>>0]=f[s+(q*12|0)+8>>2];if(!((B|0)>0|(B|0)==0&C>>>0>0)){f[g>>2]=f[D+4>>2];f[e>>2]=f[g>>2];Me(D,e,h,n)|0}s=q+1|0;if(s>>>0>=j>>>0)break;q=s;r=f[i>>2]|0}u=c;return 1}if(a>>>0<65536){if(!k){u=c;return 1}r=h+2|0;q=h+2|0;n=h+2|0;D=0;C=m;while(1){B=f[C+96>>2]|0;p=f[l>>2]|0;d[h>>1]=f[B+(D*12|0)>>2];z=p+16|0;y=f[z>>2]|0;A=f[z+4>>2]|0;if((A|0)>0|(A|0)==0&y>>>0>0){E=A;F=y;G=p}else{f[g>>2]=f[p+4>>2];f[e>>2]=f[g>>2];Me(p,e,h,n)|0;p=f[l>>2]|0;y=p+16|0;E=f[y+4>>2]|0;F=f[y>>2]|0;G=p}d[h>>1]=f[B+(D*12|0)+4>>2];if((E|0)>0|(E|0)==0&F>>>0>0){H=E;I=F;J=G}else{f[g>>2]=f[G+4>>2];f[e>>2]=f[g>>2];Me(G,e,h,q)|0;p=f[l>>2]|0;y=p+16|0;H=f[y+4>>2]|0;I=f[y>>2]|0;J=p}d[h>>1]=f[B+(D*12|0)+8>>2];if(!((H|0)>0|(H|0)==0&I>>>0>0)){f[g>>2]=f[J+4>>2];f[e>>2]=f[g>>2];Me(J,e,h,r)|0}B=D+1|0;if(B>>>0>=j>>>0)break;D=B;C=f[i>>2]|0}u=c;return 1}C=(k|0)!=0;if(a>>>0<2097152){if(C){K=0;L=m}else{u=c;return 1}while(1){a=f[L+96>>2]|0;ci(f[a+(K*12|0)>>2]|0,f[l>>2]|0)|0;ci(f[a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]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+48>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Bc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+28|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+32>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+52|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+48>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);r=a+52|0;p=f[r>>2]|0;m=X(p,s)|0;if((p|0)<=0){u=g;return}p=f[a+48>>2]|0;s=0;do{f[p+(s<<2)>>2]=f[d+(s+m<<2)>>2];s=s+1|0}while((s|0)<(f[r>>2]|0));u=g;return}r=a+52|0;s=f[r>>2]|0;m=X(s,o)|0;t=$(f[d+(m<<2)>>2]|0);v=$(f[d+(m+1<<2)>>2]|0);m=X(s,q)|0;w=$(f[d+(m<<2)>>2]|0);x=$(f[d+(m+1<<2)>>2]|0);if(!(w!=t|x!=v)){m=f[a+48>>2]|0;f[m>>2]=~~w;f[m+4>>2]=~~x;u=g;return}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+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+48>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Cc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=Oa,w=Oa,x=Oa,y=Oa,z=0,A=0,B=0,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=Oa,P=0,Q=Oa,R=Oa,S=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;c=o+(((o>>>0)%3|0|0)==0?2:-1)|0;if((p|0)==-1)q=-1;else q=f[(f[f[m>>2]>>2]|0)+(p<<2)>>2]|0;if((c|0)==-1){r=-1;s=q}else{r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0;s=q}}else{r=-1;s=-1}q=f[a+52>>2]|0;c=f[q>>2]|0;m=(f[q+4>>2]|0)-c>>2;if(m>>>0<=s>>>0)aq(q);p=c;c=f[p+(s<<2)>>2]|0;if(m>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(c|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)t=c;else{if((e|0)>0){t=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}m=f[a+68>>2]|0;s=0;do{f[m+(s<<2)>>2]=0;s=s+1|0}while((s|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;s=X(p,t)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;t=0;do{f[p+(t<<2)>>2]=f[d+(t+s<<2)>>2];t=t+1|0}while((t|0)<(f[r>>2]|0));u=g;return}r=a+72|0;t=f[r>>2]|0;s=X(t,c)|0;v=$(f[d+(s<<2)>>2]|0);w=$(f[d+(s+1<<2)>>2]|0);s=X(t,q)|0;x=$(f[d+(s<<2)>>2]|0);y=$(f[d+(s+1<<2)>>2]|0);if(!(x!=v|y!=w)){s=f[a+68>>2]|0;f[s>>2]=~~x;f[s+4>>2]=~~y;u=g;return}s=a+64|0;t=f[(f[s>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+60|0;m=f[p>>2]|0;if(!(b[m+84>>0]|0))z=f[(f[m+68>>2]|0)+(t<<2)>>2]|0;else z=t;f[i>>2]=z;z=b[m+24>>0]|0;f[h>>2]=f[i>>2];mb(m,h,z,j)|0;z=f[(f[s>>2]|0)+(c<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))A=f[(f[c+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,A,k)|0;A=f[(f[s>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))B=f[(f[q+68>>2]|0)+(A<<2)>>2]|0;else B=A;f[i>>2]=B;B=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,B,l)|0;C=$(n[l>>2]);D=$(n[k>>2]);E=$(C-D);C=$(n[l+4>>2]);F=$(n[k+4>>2]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+68>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Dc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+52>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+68>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;m=X(p,s)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;s=0;do{f[p+(s<<2)>>2]=f[d+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=$(B-$(D*I));D=$(C-$(F*I));F=$(E-$(H*I));M=I;N=$(L($($($(F*F)+$($(D*D)+$($(K*K)+$(0.0))))/G)))}else{M=$(0.0);N=$(0.0)}G=$(w-t);w=$(x-v);x=$($(G*M)+t);t=$(G*N);G=$($(w*M)+v);v=$(w*N);N=$(x-v);w=$(G+t);M=$(x+v);v=$(G-t);j=X(f[r>>2]|0,e)|0;t=$(f[d+(j<<2)>>2]|0);G=$(f[d+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+68>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Ec(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=Oa,F=Oa,G=Oa,H=0,I=0,J=0,K=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;e=i;j=i;while(1){k=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;e=(X(k>>>24^k,1540483477)|0)^(X(e,1540483477)|0);j=j+-4|0;if(j>>>0<=3)break;else d=d+4|0}d=i+-4|0;j=d&-4;l=d-j|0;m=g+(j+4)|0;o=e}else{l=i;m=g;o=i}switch(l|0){case 3:{p=h[m+2>>0]<<16^o;q=6;break}case 2:{p=o;q=6;break}case 1:{r=o;q=7;break}default:s=o}if((q|0)==6){r=h[m+1>>0]<<8^p;q=7}if((q|0)==7)s=X(r^h[m>>0],1540483477)|0;m=X(s>>>13^s,1540483477)|0;s=m>>>15^m;m=a+4|0;r=f[m>>2]|0;p=(r|0)==0;a:do if(!p){o=r+-1|0;l=(o&r|0)==0;if(!l)if(s>>>0>>0)t=s;else t=(s>>>0)%(r>>>0)|0;else t=s&o;e=f[(f[a>>2]|0)+(t<<2)>>2]|0;if((e|0)!=0?(j=f[e>>2]|0,(j|0)!=0):0){e=(i|0)==0;if(l){if(e){l=j;while(1){d=f[l+4>>2]|0;if(!((d|0)==(s|0)|(d&o|0)==(t|0))){u=t;break a}d=b[l+8+11>>0]|0;if(!((d<<24>>24<0?f[l+12>>2]|0:d&255)|0)){v=l;break}l=f[l>>2]|0;if(!l){u=t;break a}}w=v+20|0;return w|0}else x=j;b:while(1){l=f[x+4>>2]|0;if(!((l|0)==(s|0)|(l&o|0)==(t|0))){u=t;break a}l=x+8|0;d=b[l+11>>0]|0;k=d<<24>>24<0;y=d&255;do if(((k?f[x+12>>2]|0:y)|0)==(i|0)){d=f[l>>2]|0;if(k)if(!(Vk(d,g,i)|0)){v=x;q=63;break b}else break;if((b[g>>0]|0)==(d&255)<<24>>24){d=l;z=y;A=g;do{z=z+-1|0;d=d+1|0;if(!z){v=x;q=63;break b}A=A+1|0}while((b[d>>0]|0)==(b[A>>0]|0))}}while(0);x=f[x>>2]|0;if(!x){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}if(e){o=j;while(1){y=f[o+4>>2]|0;if((y|0)!=(s|0)){if(y>>>0>>0)B=y;else B=(y>>>0)%(r>>>0)|0;if((B|0)!=(t|0)){u=t;break a}}y=b[o+8+11>>0]|0;if(!((y<<24>>24<0?f[o+12>>2]|0:y&255)|0)){v=o;break}o=f[o>>2]|0;if(!o){u=t;break a}}w=v+20|0;return w|0}else C=j;c:while(1){o=f[C+4>>2]|0;if((o|0)!=(s|0)){if(o>>>0>>0)D=o;else D=(o>>>0)%(r>>>0)|0;if((D|0)!=(t|0)){u=t;break a}}o=C+8|0;e=b[o+11>>0]|0;y=e<<24>>24<0;l=e&255;do if(((y?f[C+12>>2]|0:l)|0)==(i|0)){e=f[o>>2]|0;if(y)if(!(Vk(e,g,i)|0)){v=C;q=63;break c}else break;if((b[g>>0]|0)==(e&255)<<24>>24){e=o;k=l;A=g;do{k=k+-1|0;e=e+1|0;if(!k){v=C;q=63;break c}A=A+1|0}while((b[e>>0]|0)==(b[A>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}else u=t}else u=0;while(0);t=ln(24)|0;pj(t+8|0,c);f[t+20>>2]=0;f[t+4>>2]=s;f[t>>2]=0;c=a+12|0;E=$(((f[c>>2]|0)+1|0)>>>0);F=$(r>>>0);G=$(n[a+16>>2]);do if(p|$(G*F)>>0<3|(r+-1&r|0)!=0)&1;g=~~$(W($(E/G)))>>>0;ei(a,C>>>0>>0?g:C);C=f[m>>2]|0;g=C+-1|0;if(!(g&C)){H=C;I=g&s;break}if(s>>>0>>0){H=C;I=s}else{H=C;I=(s>>>0)%(C>>>0)|0}}else{H=r;I=u}while(0);u=(f[a>>2]|0)+(I<<2)|0;I=f[u>>2]|0;if(!I){r=a+8|0;f[t>>2]=f[r>>2];f[r>>2]=t;f[u>>2]=r;r=f[t>>2]|0;if(r|0){u=f[r+4>>2]|0;r=H+-1|0;if(r&H)if(u>>>0>>0)J=u;else J=(u>>>0)%(H>>>0)|0;else J=u&r;K=(f[a>>2]|0)+(J<<2)|0;q=61}}else{f[t>>2]=f[I>>2];K=I;q=61}if((q|0)==61)f[K>>2]=t;f[c>>2]=(f[c>>2]|0)+1;v=t;w=v+20|0;return w|0}function Fc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0,H=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0.0,R=0.0,S=0,T=0.0,U=0,V=0,W=0,X=0.0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0.0,da=0,ea=0.0;g=a+4|0;i=f[g>>2]|0;j=a+100|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=0}else{k=Si(a)|0;l=0}a:while(1){switch(k|0){case 46:{m=8;break a;break}case 48:break;default:{n=0;o=0;p=1.0;q=0.0;r=0;s=k;t=l;u=0;v=0;w=0;x=0;break a}}i=f[g>>2]|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=1;continue}else{k=Si(a)|0;l=1;continue}}if((m|0)==8){k=f[g>>2]|0;if(k>>>0<(f[j>>2]|0)>>>0){f[g>>2]=k+1;y=h[k>>0]|0}else y=Si(a)|0;if((y|0)==48){k=0;i=0;while(1){z=f[g>>2]|0;if(z>>>0<(f[j>>2]|0)>>>0){f[g>>2]=z+1;A=h[z>>0]|0}else A=Si(a)|0;z=Vn(k|0,i|0,-1,-1)|0;B=I;if((A|0)==48){k=z;i=B}else{n=1;o=0;p=1.0;q=0.0;r=0;s=A;t=1;u=0;v=0;w=z;x=B;break}}}else{n=1;o=0;p=1.0;q=0.0;r=0;s=y;t=l;u=0;v=0;w=0;x=0}}while(1){l=s+-48|0;y=s|32;if(l>>>0>=10){A=(s|0)==46;if(!(A|(y+-97|0)>>>0<6)){C=s;break}if(A)if(!n){D=1;E=o;F=p;G=q;H=r;J=t;K=v;L=u;M=v;N=u}else{C=46;break}else m=20}else m=20;if((m|0)==20){m=0;A=(s|0)>57?y+-87|0:l;do if(!((u|0)<0|(u|0)==0&v>>>0<8))if((u|0)<0|(u|0)==0&v>>>0<14){O=p*.0625;P=o;Q=O;R=q+O*+(A|0);S=r;break}else{l=(o|0)!=0|(A|0)==0;P=l?o:1;Q=p;R=l?q:q+p*.5;S=r;break}else{P=o;Q=p;R=q;S=A+(r<<4)|0}while(0);A=Vn(v|0,u|0,1,0)|0;D=n;E=P;F=Q;G=R;H=S;J=1;K=w;L=x;M=A;N=I}A=f[g>>2]|0;if(A>>>0<(f[j>>2]|0)>>>0){f[g>>2]=A+1;n=D;o=E;p=F;q=G;r=H;s=h[A>>0]|0;t=J;u=N;v=M;w=K;x=L;continue}else{n=D;o=E;p=F;q=G;r=H;s=Si(a)|0;t=J;u=N;v=M;w=K;x=L;continue}}do if(!t){L=(f[j>>2]|0)==0;if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(e){if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(!((n|0)==0|L))f[g>>2]=(f[g>>2]|0)+-1}else Ym(a,0);T=+(d|0)*0.0}else{L=(n|0)==0;K=L?v:w;M=L?u:x;if((u|0)<0|(u|0)==0&v>>>0<8){L=r;N=v;J=u;while(1){s=L<<4;H=N;N=Vn(N|0,J|0,1,0)|0;if(!((J|0)<0|(J|0)==0&H>>>0<7)){U=s;break}else{L=s;J=I}}}else U=r;if((C|32|0)==112){J=Re(a,e)|0;L=I;if((J|0)==0&(L|0)==-2147483648){if(!e){Ym(a,0);T=0.0;break}if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}}else{V=J;W=L}}else if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}L=Tn(K|0,M|0,2)|0;J=Vn(L|0,I|0,-32,-1)|0;L=Vn(J|0,I|0,V|0,W|0)|0;J=I;if(!U){T=+(d|0)*0.0;break}N=0-c|0;s=((N|0)<0)<<31>>31;if((J|0)>(s|0)|(J|0)==(s|0)&L>>>0>N>>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}N=c+-106|0;s=((N|0)<0)<<31>>31;if((J|0)<(s|0)|(J|0)==(s|0)&L>>>0>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if((U|0)>-1){G=q;N=U;s=L;H=J;while(1){E=!(G>=.5);o=N<<1|(E^1)&1;F=G+(E?G:G+-1.0);E=Vn(s|0,H|0,-1,-1)|0;D=I;if((o|0)>-1){G=F;N=o;s=E;H=D}else{X=F;Y=o;Z=E;_=D;break}}}else{X=q;Y=U;Z=L;_=J}H=((b|0)<0)<<31>>31;s=Xn(32,0,c|0,((c|0)<0)<<31>>31|0)|0;N=Vn(s|0,I|0,Z|0,_|0)|0;s=I;if((s|0)<(H|0)|(s|0)==(H|0)&N>>>0>>0)if((N|0)>0){$=N;m=59}else{aa=0;ba=84;m=61}else{$=b;m=59}if((m|0)==59)if(($|0)<53){aa=$;ba=84-$|0;m=61}else{ca=0.0;da=$;ea=+(d|0)}if((m|0)==61){G=+(d|0);ca=+rq(+bk(1.0,ba),G);da=aa;ea=G}N=(Y&1|0)==0&(X!=0.0&(da|0)<32);G=(N?0.0:X)*ea+(ca+ea*+((Y+(N&1)|0)>>>0))-ca;if(!(G!=0.0)){N=Vq()|0;f[N>>2]=34}T=+sq(G,Z)}while(0);return +T}function Gc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0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|0;B=(y|0)==-1;if(B)C=-1;else C=f[(f[o>>2]|0)+(((y|0)/3|0)*12|0)+(((y|0)%3|0)<<2)>>2]|0;D=f[n>>2]|0;if((f[D+(A<<2)>>2]|0)==(f[D+(C<<2)>>2]|0)){E=t+1|0;if(z)F=-1;else F=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){G=y+2|0;break}else{G=y+-1|0;break}else G=-1;while(0);if((F|0)==-1)H=-1;else H=f[(f[o>>2]|0)+(((F|0)/3|0)*12|0)+(((F|0)%3|0)<<2)>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[o>>2]|0)+(((G|0)/3|0)*12|0)+(((G|0)%3|0)<<2)>>2]|0;if((f[D+(H<<2)>>2]|0)==(f[D+(I<<2)>>2]|0))break}}else{if(z)J=-1;else J=f[(f[o>>2]|0)+(((t|0)/3|0)*12|0)+(((t|0)%3|0)<<2)>>2]|0;B=(y|0)==-1;if(B)K=-1;else K=f[(f[o>>2]|0)+(((y|0)/3|0)*12|0)+(((y|0)%3|0)<<2)>>2]|0;if((J|0)==(K|0)){E=t+1|0;if(z)L=-1;else L=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){M=y+2|0;break}else{M=y+-1|0;break}else M=-1;while(0);if((L|0)==-1)N=-1;else N=f[(f[o>>2]|0)+(((L|0)/3|0)*12|0)+(((L|0)%3|0)<<2)>>2]|0;if((M|0)==-1)O=-1;else O=f[(f[o>>2]|0)+(((M|0)/3|0)*12|0)+(((M|0)%3|0)<<2)>>2]|0;if((N|0)==(O|0))break}}b[p>>0]=0;y=f[a>>2]|0;B=y+(q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(q&31);B=y+(s>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(s&31);B=((v>>>0)%3|0|0)==0?q+-2|0:v;if((B|0)==-1)P=-1;else P=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(P>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(P&31);B=(((q>>>0)%3|0|0)==0?2:-1)+q|0;if((B|0)==-1)Q=-1;else Q=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(Q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(Q&31);B=s+1|0;y=((B>>>0)%3|0|0)==0?s+-2|0:B;if((y|0)==-1)R=-1;else R=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(R>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(R&31);y=(((s>>>0)%3|0|0)==0?2:-1)+s|0;if((y|0)==-1)S=-1;else S=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(S>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(S&31)}}while(0);q=q+1|0}while(q>>>0<(f[r+4>>2]|0)-(f[r>>2]|0)>>2>>>0)}if((c|0)!=0&(e|0)!=0){Qc(a,c,e);j=1;u=g;return j|0}else{md(a,0,0);j=1;u=g;return j|0}return 0}function Hc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;d=u;u=u+32|0;e=d+12|0;g=d+8|0;h=d+4|0;i=d;j=a+8|0;a:do if(f[j>>2]|0?(k=f[a>>2]|0,l=a+4|0,f[a>>2]=l,f[(f[l>>2]|0)+8>>2]=0,f[l>>2]=0,f[j>>2]=0,m=f[k+4>>2]|0,n=(m|0)==0?k:m,n|0):0){m=a+4|0;k=n;n=f[b>>2]|0;while(1){if((n|0)==(f[c>>2]|0))break;o=k+16|0;f[o>>2]=f[n+16>>2];if((k|0)!=(n|0)){f[h>>2]=f[n+20>>2];f[i>>2]=n+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k+20|0,g,e)}p=k+8|0;q=f[p>>2]|0;do if(q){r=f[q>>2]|0;if((r|0)==(k|0)){f[q>>2]=0;s=f[q+4>>2]|0;if(!s){t=q;break}else v=s;while(1){s=f[v>>2]|0;if(s|0){v=s;continue}s=f[v+4>>2]|0;if(!s)break;else v=s}t=v;break}else{f[q+4>>2]=0;if(!r){t=q;break}else w=r;while(1){s=f[w>>2]|0;if(s|0){w=s;continue}s=f[w+4>>2]|0;if(!s)break;else w=s}t=w;break}}else t=0;while(0);q=f[l>>2]|0;do if(q){r=f[o>>2]|0;s=q;while(1){if((r|0)<(f[s+16>>2]|0)){x=f[s>>2]|0;if(!x){y=22;break}else z=x}else{A=s+4|0;x=f[A>>2]|0;if(!x){y=25;break}else z=x}s=z}if((y|0)==22){y=0;B=s;C=s;break}else if((y|0)==25){y=0;B=s;C=A;break}}else{B=l;C=l}while(0);f[k>>2]=0;f[k+4>>2]=0;f[p>>2]=B;f[C>>2]=k;q=f[f[a>>2]>>2]|0;if(!q)D=k;else{f[a>>2]=q;D=f[C>>2]|0}Oe(f[m>>2]|0,D);f[j>>2]=(f[j>>2]|0)+1;q=f[n+4>>2]|0;if(!q){o=n+8|0;r=f[o>>2]|0;if((f[r>>2]|0)==(n|0))E=r;else{r=o;do{o=f[r>>2]|0;r=o+8|0;x=f[r>>2]|0}while((f[x>>2]|0)!=(o|0));E=x}}else{r=q;while(1){p=f[r>>2]|0;if(!p)break;else r=p}E=r}f[b>>2]=E;if(!t)break a;else{k=t;n=E}}n=f[k+8>>2]|0;if(!n)F=k;else{m=n;while(1){n=f[m+8>>2]|0;if(!n)break;else m=n}F=m}Oj(a,F)}while(0);F=f[b>>2]|0;E=f[c>>2]|0;if((F|0)==(E|0)){u=d;return}c=a+4|0;t=a+4|0;D=F;while(1){Kg(e,a,D+16|0);F=f[c>>2]|0;do if(F){C=f[e>>2]|0;B=f[C+16>>2]|0;A=F;while(1){if((B|0)<(f[A+16>>2]|0)){z=f[A>>2]|0;if(!z){y=43;break}else G=z}else{H=A+4|0;z=f[H>>2]|0;if(!z){y=46;break}else G=z}A=G}if((y|0)==43){y=0;I=A;J=A;K=C;break}else if((y|0)==46){y=0;I=A;J=H;K=C;break}}else{I=c;J=c;K=f[e>>2]|0}while(0);f[K>>2]=0;f[K+4>>2]=0;f[K+8>>2]=I;f[J>>2]=K;F=f[f[a>>2]>>2]|0;if(!F)L=K;else{f[a>>2]=F;L=f[J>>2]|0}Oe(f[t>>2]|0,L);f[j>>2]=(f[j>>2]|0)+1;F=f[D+4>>2]|0;if(!F){m=D+8|0;B=f[m>>2]|0;if((f[B>>2]|0)==(D|0))M=B;else{B=m;do{m=f[B>>2]|0;B=m+8|0;r=f[B>>2]|0}while((f[r>>2]|0)!=(m|0));M=r}}else{B=F;while(1){r=f[B>>2]|0;if(!r)break;else B=r}M=B}f[b>>2]=M;if((M|0)==(E|0))break;else D=M}u=d;return}function Ic(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;g=u;u=u+32|0;d=g+16|0;h=g+8|0;i=g;j=f[a+28>>2]|0;k=f[a+32>>2]|0;l=e>>>0>1073741823?-1:e<<2;m=Lq(l)|0;sj(m|0,0,l|0)|0;n=Lq(l)|0;sj(n|0,0,l|0)|0;l=a+36|0;o=f[l>>2]|0;p=f[o+4>>2]|0;q=f[o>>2]|0;r=p-q|0;a:do if((r|0)>4){s=r>>2;t=(e|0)>0;v=a+8|0;w=h+4|0;x=i+4|0;y=d+4|0;z=m+4|0;A=h+4|0;B=i+4|0;C=d+4|0;D=j+12|0;E=e<<2;F=s+-1|0;if(p-q>>2>>>0>F>>>0){G=s;H=F;I=q}else{J=o;aq(J)}while(1){F=f[I+(H<<2)>>2]|0;if(t)sj(m|0,0,E|0)|0;if((F|0)!=-1){s=f[D>>2]|0;K=0;L=F;while(1){M=f[s+(L<<2)>>2]|0;if((M|0)!=-1){N=f[j>>2]|0;O=f[k>>2]|0;P=f[O+(f[N+(M<<2)>>2]<<2)>>2]|0;Q=M+1|0;R=((Q>>>0)%3|0|0)==0?M+-2|0:Q;if((R|0)==-1)S=-1;else S=f[N+(R<<2)>>2]|0;R=f[O+(S<<2)>>2]|0;Q=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((Q|0)==-1)T=-1;else T=f[N+(Q<<2)>>2]|0;Q=f[O+(T<<2)>>2]|0;if((P|0)<(H|0)&(R|0)<(H|0)&(Q|0)<(H|0)){O=X(P,e)|0;P=X(R,e)|0;R=X(Q,e)|0;if(t){Q=0;do{f[n+(Q<<2)>>2]=(f[b+(Q+R<<2)>>2]|0)+(f[b+(Q+P<<2)>>2]|0)-(f[b+(Q+O<<2)>>2]|0);Q=Q+1|0}while((Q|0)!=(e|0));if(t){Q=0;do{O=m+(Q<<2)|0;f[O>>2]=(f[O>>2]|0)+(f[n+(Q<<2)>>2]|0);Q=Q+1|0}while((Q|0)!=(e|0))}}U=K+1|0}else U=K}else U=K;Q=(((L>>>0)%3|0|0)==0?2:-1)+L|0;do if((Q|0)!=-1?(O=f[s+(Q<<2)>>2]|0,(O|0)!=-1):0)if(!((O>>>0)%3|0)){V=O+2|0;break}else{V=O+-1|0;break}else V=-1;while(0);L=(V|0)==(F|0)?-1:V;if((L|0)==-1)break;else K=U}K=X(H,e)|0;if(!U){W=K;Y=30}else{if(t){L=0;do{F=m+(L<<2)|0;f[F>>2]=(f[F>>2]|0)/(U|0)|0;L=L+1|0}while((L|0)!=(e|0))}L=b+(K<<2)|0;F=c+(K<<2)|0;s=f[L+4>>2]|0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){J=f[o>>2]|0;f[J+(C<<2)>>2]=I;K=J}else{J=f[p>>2]|0;I=f[o>>2]|0;f[I+(C<<2)>>2]=(H|0)<(J|0)?J:H;K=I}C=C+1|0}while((C|0)<(f[g>>2]|0));L=K}else L=f[o>>2]|0;C=(f[D+(E<<2)>>2]|0)-(f[L+(E<<2)>>2]|0)|0;I=B+(E<<2)|0;f[I>>2]=C;if((C|0)>=(f[q>>2]|0)){if((C|0)>(f[s>>2]|0)){M=C-(f[r>>2]|0)|0;N=42}}else{M=(f[r>>2]|0)+C|0;N=42}if((N|0)==42){N=0;f[I>>2]=M}E=E+1|0;A=f[g>>2]|0;if((E|0)>=(A|0))break;else y=L}}}else N=16}else N=16;if((N|0)==16?(N=0,y=b+(z<<2)|0,A=c+(z<<2)|0,E=f[g>>2]|0,(E|0)>0):0){B=0;D=b+((X(x+-2|0,e)|0)<<2)|0;I=E;while(1){if((I|0)>0){E=0;do{C=f[D+(E<<2)>>2]|0;H=f[n>>2]|0;if((C|0)>(H|0)){J=f[o>>2]|0;f[J+(E<<2)>>2]=H;O=J}else{J=f[p>>2]|0;H=f[o>>2]|0;f[H+(E<<2)>>2]=(C|0)<(J|0)?J:C;O=H}E=E+1|0}while((E|0)<(f[g>>2]|0));P=O}else P=f[o>>2]|0;E=(f[y+(B<<2)>>2]|0)-(f[P+(B<<2)>>2]|0)|0;H=A+(B<<2)|0;f[H>>2]=E;if((E|0)>=(f[q>>2]|0)){if((E|0)>(f[s>>2]|0)){Q=E-(f[r>>2]|0)|0;N=29}}else{Q=(f[r>>2]|0)+E|0;N=29}if((N|0)==29){N=0;f[H>>2]=Q}B=B+1|0;I=f[g>>2]|0;if((B|0)>=(I|0))break;else D=P}}if((x|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;P=a+32|0;Q=a+12|0;O=a+28|0;L=a+20|0;M=a+24|0;a=0;K=h;G=e;while(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>2>>>0>G>>>0){H=s;I=G;J=q}else{K=o;aq(K)}while(1){G=f[J+(I<<2)>>2]|0;if(t)sj(m|0,0,F|0)|0;if((G|0)!=-1){s=f[j>>2]|0;L=0;M=G;while(1){if(((f[s+(M>>>5<<2)>>2]&1<<(M&31)|0)==0?(N=f[(f[(f[D>>2]|0)+12>>2]|0)+(M<<2)>>2]|0,(N|0)!=-1):0)?(O=f[E>>2]|0,P=f[k>>2]|0,Q=f[P+(f[O+(N<<2)>>2]<<2)>>2]|0,R=N+1|0,S=f[P+(f[O+((((R>>>0)%3|0|0)==0?N+-2|0:R)<<2)>>2]<<2)>>2]|0,R=f[P+(f[O+((((N>>>0)%3|0|0)==0?2:-1)+N<<2)>>2]<<2)>>2]|0,(Q|0)<(I|0)&(S|0)<(I|0)&(R|0)<(I|0)):0){N=X(Q,e)|0;Q=X(S,e)|0;S=X(R,e)|0;if(t){R=0;do{f[n+(R<<2)>>2]=(f[b+(R+S<<2)>>2]|0)+(f[b+(R+Q<<2)>>2]|0)-(f[b+(R+N<<2)>>2]|0);R=R+1|0}while((R|0)!=(e|0));if(t){R=0;do{N=m+(R<<2)|0;f[N>>2]=(f[N>>2]|0)+(f[n+(R<<2)>>2]|0);R=R+1|0}while((R|0)!=(e|0))}}T=L+1|0}else T=L;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;do if(((R|0)!=-1?(f[s+(R>>>5<<2)>>2]&1<<(R&31)|0)==0:0)?(N=f[(f[(f[D>>2]|0)+12>>2]|0)+(R<<2)>>2]|0,(N|0)!=-1):0)if(!((N>>>0)%3|0)){U=N+2|0;break}else{U=N+-1|0;break}else U=-1;while(0);M=(U|0)==(G|0)?-1:U;if((M|0)==-1)break;else L=T}L=X(I,e)|0;if(!T){V=L;W=28}else{if(t){M=0;do{G=m+(M<<2)|0;f[G>>2]=(f[G>>2]|0)/(T|0)|0;M=M+1|0}while((M|0)!=(e|0))}M=b+(L<<2)|0;G=c+(L<<2)|0;s=f[M+4>>2]|0;R=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)){I=f[o>>2]|0;f[I+(D<<2)>>2]=H;J=I}else{I=f[p>>2]|0;H=f[o>>2]|0;f[H+(D<<2)>>2]=(G|0)<(I|0)?I:G;J=H}D=D+1|0}while((D|0)<(f[g>>2]|0));K=J}else K=f[o>>2]|0;D=(f[E+(F<<2)>>2]|0)-(f[K+(F<<2)>>2]|0)|0;H=B+(F<<2)|0;f[H>>2]=D;if((D|0)>=(f[q>>2]|0)){if((D|0)>(f[s>>2]|0)){L=D-(f[r>>2]|0)|0;M=39}}else{L=(f[r>>2]|0)+D|0;M=39}if((M|0)==39){M=0;f[H>>2]=L}F=F+1|0;C=f[g>>2]|0;if((F|0)>=(C|0))break;else z=K}}}else M=13;if((M|0)==13?(M=0,z=b+(A<<2)|0,C=c+(A<<2)|0,F=f[g>>2]|0,(F|0)>0):0){B=0;E=b+((X(y+-2|0,e)|0)<<2)|0;H=F;while(1){if((H|0)>0){F=0;do{D=f[E+(F<<2)>>2]|0;G=f[n>>2]|0;if((D|0)>(G|0)){I=f[o>>2]|0;f[I+(F<<2)>>2]=G;N=I}else{I=f[p>>2]|0;G=f[o>>2]|0;f[G+(F<<2)>>2]=(D|0)<(I|0)?I:D;N=G}F=F+1|0}while((F|0)<(f[g>>2]|0));O=N}else O=f[o>>2]|0;F=(f[z+(B<<2)>>2]|0)-(f[O+(B<<2)>>2]|0)|0;G=C+(B<<2)|0;f[G>>2]=F;if((F|0)>=(f[q>>2]|0)){if((F|0)>(f[s>>2]|0)){P=F-(f[r>>2]|0)|0;M=26}}else{P=(f[r>>2]|0)+F|0;M=26}if((M|0)==26){M=0;f[G>>2]=P}B=B+1|0;H=f[g>>2]|0;if((B|0)>=(H|0))break;else E=O}}if((y|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;O=a+32|0;P=a+12|0;N=a+28|0;K=a+20|0;L=a+24|0;a=0;J=h;d=e;while(1){if((d|0)>0){e=0;do{l=f[J+(e<<2)>>2]|0;j=f[i>>2]|0;if((l|0)>(j|0)){k=f[O>>2]|0;f[k+(e<<2)>>2]=j;Q=k}else{k=f[P>>2]|0;j=f[O>>2]|0;f[j+(e<<2)>>2]=(l|0)<(k|0)?k:l;Q=j}e=e+1|0}while((e|0)<(f[g>>2]|0));R=Q}else R=f[O>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[R+(a<<2)>>2]|0)|0;j=c+(a<<2)|0;f[j>>2]=e;if((e|0)>=(f[N>>2]|0)){if((e|0)>(f[L>>2]|0)){S=e-(f[K>>2]|0)|0;M=53}}else{S=(f[K>>2]|0)+e|0;M=53}if((M|0)==53){M=0;f[j>>2]=S}a=a+1|0;d=f[g>>2]|0;if((a|0)>=(d|0))break;else J=R}Mq(h);return 1}function Mc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0;h=u;u=u+48|0;i=h+28|0;j=h+24|0;k=h;l=h+12|0;m=h+40|0;if((c|0)<0){n=0;u=h;return n|0}if(!c){n=1;u=h;return n|0}o=(d|0)>1;p=o?d:1;f[k>>2]=0;d=k+4|0;f[d>>2]=0;f[k+8>>2]=0;gk(k,c);q=k+8|0;if(o){o=0;r=0;while(1){s=1;t=f[a+(r<<2)>>2]|0;do{v=f[a+(s+r<<2)>>2]|0;t=t>>>0>>0?v:t;s=s+1|0}while((s|0)!=(p|0));s=(_(t|0)|0)^31;v=t>>>0>o>>>0?t:o;w=(t|0)==0?1:s+1|0;f[i>>2]=w;s=f[d>>2]|0;if(s>>>0<(f[q>>2]|0)>>>0){f[s>>2]=w;f[d>>2]=s+4}else Ri(k,i);r=r+p|0;if((r|0)>=(c|0)){x=v;break}else o=v}}else{o=0;r=0;while(1){v=f[a+(o<<2)>>2]|0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616;f[i+4>>2]=22;F=w;B=15964;o=F+22|0;do{b[F>>0]=b[B>>0]|0;F=F+1|0;B=B+1|0}while((F|0)<(o|0));b[w+22>>0]=0;w=(Jh(e,i)|0)==0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if(!w){f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;w=ln(32)|0;f[i>>2]=w;f[i+8>>2]=-2147483616;f[i+4>>2]=22;F=w;B=15964;o=F+22|0;do{b[F>>0]=b[B>>0]|0;F=F+1|0;B=B+1|0}while((F|0)<(o|0));b[w+22>>0]=0;w=Mk(e,i)|0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);H=w}else G=32}else G=32;if((G|0)==32)H=z>>>0<18&((A|0)>(r|0)|(A|0)==(r|0)&v>>>0>=C>>>0)&1;b[m>>0]=H;C=g+16|0;v=f[C+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[C>>2]|0)>>>0>0)){f[j>>2]=f[g+4>>2];f[i>>2]=f[j>>2];Me(g,i,m,m+1|0)|0}switch(H|0){case 0:{J=td(a,c,p,k,g)|0;break}case 1:{J=Tc(a,c,x,l,e,g)|0;break}default:J=0}g=f[k>>2]|0;if(g|0){k=f[d>>2]|0;if((k|0)!=(g|0))f[d>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(g)}n=J;u=h;return n|0}function Nc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;if((b|0)<0)return;c=a+12|0;d=f[c>>2]|0;e=f[a+8>>2]|0;g=e;h=d;if(d-e>>2>>>0<=b>>>0)return;e=g+(b<<2)|0;d=f[(f[e>>2]|0)+56>>2]|0;i=f[(f[g+(b<<2)>>2]|0)+60>>2]|0;g=e+4|0;if((g|0)!=(h|0)){j=g;g=e;do{k=f[j>>2]|0;f[j>>2]=0;l=f[g>>2]|0;f[g>>2]=k;if(l|0){k=l+88|0;m=f[k>>2]|0;f[k>>2]=0;if(m|0){k=f[m+8>>2]|0;if(k|0){n=m+12|0;if((f[n>>2]|0)!=(k|0))f[n>>2]=k;Oq(k)}Oq(m)}m=f[l+68>>2]|0;if(m|0){k=l+72|0;n=f[k>>2]|0;if((n|0)!=(m|0))f[k>>2]=n+(~((n+-4-m|0)>>>2)<<2);Oq(m)}m=l+64|0;n=f[m>>2]|0;f[m>>2]=0;if(n|0){m=f[n>>2]|0;if(m|0){k=n+4|0;if((f[k>>2]|0)!=(m|0))f[k>>2]=m;Oq(m)}Oq(n)}Oq(l)}j=j+4|0;g=g+4|0}while((j|0)!=(h|0));j=f[c>>2]|0;if((j|0)!=(g|0)){o=g;p=j;q=24}}else{o=e;p=h;q=24}if((q|0)==24){q=p;do{p=q+-4|0;f[c>>2]=p;h=f[p>>2]|0;f[p>>2]=0;if(h|0){p=h+88|0;e=f[p>>2]|0;f[p>>2]=0;if(e|0){p=f[e+8>>2]|0;if(p|0){j=e+12|0;if((f[j>>2]|0)!=(p|0))f[j>>2]=p;Oq(p)}Oq(e)}e=f[h+68>>2]|0;if(e|0){p=h+72|0;j=f[p>>2]|0;if((j|0)!=(e|0))f[p>>2]=j+(~((j+-4-e|0)>>>2)<<2);Oq(e)}e=h+64|0;j=f[e>>2]|0;f[e>>2]=0;if(j|0){e=f[j>>2]|0;if(e|0){p=j+4|0;if((f[p>>2]|0)!=(e|0))f[p>>2]=e;Oq(e)}Oq(j)}Oq(h)}q=f[c>>2]|0}while((q|0)!=(o|0))}o=f[a+4>>2]|0;a:do if(o|0){q=o+44|0;c=f[q>>2]|0;h=f[o+40>>2]|0;while(1){if((h|0)==(c|0))break a;r=h+4|0;if((f[(f[h>>2]|0)+40>>2]|0)==(i|0))break;else h=r}if((r|0)!=(c|0)){j=r;e=h;do{p=f[j>>2]|0;f[j>>2]=0;g=f[e>>2]|0;f[e>>2]=p;if(g|0){bj(g);Oq(g)}j=j+4|0;e=e+4|0}while((j|0)!=(c|0));j=f[q>>2]|0;if((j|0)==(e|0))break;else{s=e;t=j}}else{s=h;t=c}j=t;do{g=j+-4|0;f[q>>2]=g;p=f[g>>2]|0;f[g>>2]=0;if(p|0){bj(p);Oq(p)}j=f[q>>2]|0}while((j|0)!=(s|0))}while(0);b:do if((d|0)<5){s=f[a+20+(d*12|0)>>2]|0;t=a+20+(d*12|0)+4|0;r=f[t>>2]|0;i=r;c:do if((s|0)==(r|0))u=s;else{o=s;while(1){if((f[o>>2]|0)==(b|0)){u=o;break c}o=o+4|0;if((o|0)==(r|0))break b}}while(0);if((u|0)!=(r|0)){s=u+4|0;o=i-s|0;j=o>>2;if(!j)v=r;else{im(u|0,s|0,o|0)|0;v=f[t>>2]|0}o=u+(j<<2)|0;if((v|0)!=(o|0))f[t>>2]=v+(~((v+-4-o|0)>>>2)<<2)}}while(0);v=f[a+24>>2]|0;u=f[a+20>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+36>>2]|0;u=f[a+32>>2]|0;d=u;if((o|0)!=(u|0)){j=o-u>>2;u=0;do{o=d+(u<<2)|0;v=f[o>>2]|0;if((v|0)>(b|0))f[o>>2]=v+-1;u=u+1|0}while(u>>>0>>0)}j=f[a+48>>2]|0;u=f[a+44>>2]|0;d=u;if((j|0)!=(u|0)){v=j-u>>2;u=0;do{j=d+(u<<2)|0;o=f[j>>2]|0;if((o|0)>(b|0))f[j>>2]=o+-1;u=u+1|0}while(u>>>0>>0)}v=f[a+60>>2]|0;u=f[a+56>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+72>>2]|0;u=f[a+68>>2]|0;a=u;if((o|0)==(u|0))return;d=o-u>>2;u=0;do{o=a+(u<<2)|0;j=f[o>>2]|0;if((j|0)>(b|0))f[o>>2]=j+-1;u=u+1|0}while(u>>>0>>0);return}function Oc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;e=a+8|0;a:do if(f[e>>2]|0?(g=f[a>>2]|0,h=a+4|0,f[a>>2]=h,f[(f[h>>2]|0)+8>>2]=0,f[h>>2]=0,f[e>>2]=0,i=f[g+4>>2]|0,j=(i|0)==0?g:i,j|0):0){i=a+4|0;g=j;j=f[c>>2]|0;while(1){if((j|0)==(f[d>>2]|0))break;k=g+16|0;am(k,j+16|0)|0;am(g+28|0,j+28|0)|0;l=g+8|0;m=f[l>>2]|0;do if(m){n=f[m>>2]|0;if((n|0)==(g|0)){f[m>>2]=0;o=f[m+4>>2]|0;if(!o){p=m;break}else q=o;while(1){o=f[q>>2]|0;if(o|0){q=o;continue}o=f[q+4>>2]|0;if(!o)break;else q=o}p=q;break}else{f[m+4>>2]=0;if(!n){p=m;break}else r=n;while(1){o=f[r>>2]|0;if(o|0){r=o;continue}o=f[r+4>>2]|0;if(!o)break;else r=o}p=r;break}}else p=0;while(0);m=f[h>>2]|0;do if(m){n=b[k+11>>0]|0;o=n<<24>>24<0;s=o?f[g+20>>2]|0:n&255;n=o?f[k>>2]|0:k;o=m;while(1){t=o+16|0;u=b[t+11>>0]|0;v=u<<24>>24<0;w=v?f[o+20>>2]|0:u&255;u=w>>>0>>0?w:s;if((u|0)!=0?(x=Vk(n,v?f[t>>2]|0:t,u)|0,(x|0)!=0):0)if((x|0)<0)y=22;else y=24;else if(s>>>0>>0)y=22;else y=24;if((y|0)==22){y=0;w=f[o>>2]|0;if(!w){y=23;break}else z=w}else if((y|0)==24){y=0;A=o+4|0;w=f[A>>2]|0;if(!w){y=26;break}else z=w}o=z}if((y|0)==23){y=0;B=o;C=o;break}else if((y|0)==26){y=0;B=A;C=o;break}}else{B=h;C=h}while(0);f[g>>2]=0;f[g+4>>2]=0;f[l>>2]=C;f[B>>2]=g;m=f[f[a>>2]>>2]|0;if(!m)D=g;else{f[a>>2]=m;D=f[B>>2]|0}Oe(f[i>>2]|0,D);f[e>>2]=(f[e>>2]|0)+1;m=f[j+4>>2]|0;if(!m){k=j+8|0;s=f[k>>2]|0;if((f[s>>2]|0)==(j|0))E=s;else{s=k;do{k=f[s>>2]|0;s=k+8|0;n=f[s>>2]|0}while((f[n>>2]|0)!=(k|0));E=n}}else{s=m;while(1){l=f[s>>2]|0;if(!l)break;else s=l}E=s}f[c>>2]=E;if(!p)break a;else{g=p;j=E}}j=f[g+8>>2]|0;if(!j)F=g;else{i=j;while(1){j=f[i+8>>2]|0;if(!j)break;else i=j}F=i}Ej(a,F)}while(0);F=f[c>>2]|0;E=f[d>>2]|0;if((F|0)==(E|0))return;else G=F;while(1){bf(a,G+16|0)|0;F=f[G+4>>2]|0;if(!F){d=G+8|0;p=f[d>>2]|0;if((f[p>>2]|0)==(G|0))H=p;else{p=d;do{d=f[p>>2]|0;p=d+8|0;e=f[p>>2]|0}while((f[e>>2]|0)!=(d|0));H=e}}else{p=F;while(1){i=f[p>>2]|0;if(!i)break;else p=i}H=p}f[c>>2]=H;if((H|0)==(E|0))break;else G=H}return}function Pc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;b=u;u=u+32|0;c=b+4|0;d=b;e=a+16|0;g=f[e>>2]|0;if(g>>>0>112){f[e>>2]=g+-113;g=a+4|0;e=f[g>>2]|0;h=f[e>>2]|0;i=e+4|0;f[g>>2]=i;e=a+8|0;j=f[e>>2]|0;k=a+12|0;l=f[k>>2]|0;m=l;do if((j|0)==(l|0)){n=f[a>>2]|0;o=n;if(i>>>0>n>>>0){p=i;q=((p-o>>2)+1|0)/-2|0;r=i+(q<<2)|0;s=j-p|0;p=s>>2;if(!p)t=i;else{im(r|0,i|0,s|0)|0;t=f[g>>2]|0}s=r+(p<<2)|0;f[e>>2]=s;f[g>>2]=t+(q<<2);v=s;break}s=m-o>>1;o=(s|0)==0?1:s;if(o>>>0>1073741823){s=ra(8)|0;Oo(s,16035);f[s>>2]=7256;va(s|0,1112,110)}s=ln(o<<2)|0;q=s;p=s+(o>>>2<<2)|0;r=p;w=s+(o<<2)|0;if((i|0)==(j|0)){x=r;y=n}else{n=p;p=r;o=i;do{f[n>>2]=f[o>>2];n=p+4|0;p=n;o=o+4|0}while((o|0)!=(j|0));x=p;y=f[a>>2]|0}f[a>>2]=q;f[g>>2]=r;f[e>>2]=x;f[k>>2]=w;if(!y)v=x;else{Oq(y);v=f[e>>2]|0}}else v=j;while(0);f[v>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}e=a+8|0;h=f[e>>2]|0;v=a+4|0;j=h-(f[v>>2]|0)|0;y=a+12|0;x=f[y>>2]|0;k=x-(f[a>>2]|0)|0;if(j>>>0>=k>>>0){g=k>>1;k=(g|0)==0?1:g;f[c+12>>2]=0;f[c+16>>2]=a+12;if(k>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=ln(k<<2)|0;f[c>>2]=g;i=g+(j>>2<<2)|0;j=c+8|0;f[j>>2]=i;m=c+4|0;f[m>>2]=i;i=c+12|0;f[i>>2]=g+(k<<2);k=ln(4068)|0;f[d>>2]=k;Ag(c,d);d=f[e>>2]|0;while(1){z=f[v>>2]|0;if((d|0)==(z|0))break;k=d+-4|0;ug(c,k);d=k}k=z;z=f[a>>2]|0;f[a>>2]=f[c>>2];f[c>>2]=z;f[v>>2]=f[m>>2];f[m>>2]=k;m=f[e>>2]|0;f[e>>2]=f[j>>2];f[j>>2]=m;g=f[y>>2]|0;f[y>>2]=f[i>>2];f[i>>2]=g;g=m;if((d|0)!=(g|0))f[j>>2]=g+(~((g+-4-k|0)>>>2)<<2);if(z|0)Oq(z);u=b;return}if((x|0)!=(h|0)){h=ln(4068)|0;f[c>>2]=h;Ag(a,c);u=b;return}h=ln(4068)|0;f[c>>2]=h;ug(a,c);c=f[v>>2]|0;h=f[c>>2]|0;x=c+4|0;f[v>>2]=x;c=f[e>>2]|0;z=f[y>>2]|0;k=z;do if((c|0)==(z|0)){g=f[a>>2]|0;j=g;if(x>>>0>g>>>0){d=x;m=((d-j>>2)+1|0)/-2|0;i=x+(m<<2)|0;t=c-d|0;d=t>>2;if(!d)A=x;else{im(i|0,x|0,t|0)|0;A=f[v>>2]|0}t=i+(d<<2)|0;f[e>>2]=t;f[v>>2]=A+(m<<2);B=t;break}t=k-j>>1;j=(t|0)==0?1:t;if(j>>>0>1073741823){t=ra(8)|0;Oo(t,16035);f[t>>2]=7256;va(t|0,1112,110)}t=ln(j<<2)|0;m=t;d=t+(j>>>2<<2)|0;i=d;l=t+(j<<2)|0;if((x|0)==(c|0)){C=i;D=g}else{g=d;d=i;j=x;do{f[g>>2]=f[j>>2];g=d+4|0;d=g;j=j+4|0}while((j|0)!=(c|0));C=d;D=f[a>>2]|0}f[a>>2]=m;f[v>>2]=i;f[e>>2]=C;f[y>>2]=l;if(!D)B=C;else{Oq(D);B=f[e>>2]|0}}else B=c;while(0);f[B>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}function Qc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=u;u=u+16|0;g=e+8|0;h=e+4|0;i=e;j=a+64|0;k=f[j>>2]|0;if((f[k+28>>2]|0)==(f[k+24>>2]|0)){u=e;return}l=c+96|0;c=a+52|0;m=d+84|0;n=d+68|0;d=a+56|0;o=a+60|0;p=a+12|0;q=a+28|0;r=a+40|0;s=a+44|0;t=a+48|0;v=0;w=0;x=k;while(1){k=f[(f[x+24>>2]|0)+(w<<2)>>2]|0;if((k|0)==-1){y=v;z=x}else{A=v+1|0;B=f[(f[l>>2]|0)+(((k|0)/3|0)*12|0)+(((k|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))C=f[(f[n>>2]|0)+(B<<2)>>2]|0;else C=B;f[g>>2]=C;B=f[d>>2]|0;if(B>>>0<(f[o>>2]|0)>>>0){f[B>>2]=C;f[d>>2]=B+4}else Ri(c,g);f[g>>2]=k;f[h>>2]=0;a:do if(!(f[(f[p>>2]|0)+(w>>>5<<2)>>2]&1<<(w&31)))D=k;else{B=k+1|0;E=((B>>>0)%3|0|0)==0?k+-2|0:B;if(((E|0)!=-1?(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)==0:0)?(B=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0,E=B+1|0,(B|0)!=-1):0){F=((E>>>0)%3|0|0)==0?B+-2|0:E;f[h>>2]=F;if((F|0)==-1){D=k;break}else G=F;while(1){f[g>>2]=G;F=G+1|0;E=((F>>>0)%3|0|0)==0?G+-2|0:F;if((E|0)==-1)break;if(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)break;F=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0;E=F+1|0;if((F|0)==-1)break;B=((E>>>0)%3|0|0)==0?F+-2|0:E;f[h>>2]=B;if((B|0)==-1){D=G;break a}else G=B}f[h>>2]=-1;D=G;break}f[h>>2]=-1;D=k}while(0);f[(f[q>>2]|0)+(D<<2)>>2]=v;k=f[s>>2]|0;if((k|0)==(f[t>>2]|0))Ri(r,g);else{f[k>>2]=f[g>>2];f[s>>2]=k+4}k=f[j>>2]|0;B=f[g>>2]|0;b:do if(((B|0)!=-1?(E=(((B>>>0)%3|0|0)==0?2:-1)+B|0,(E|0)!=-1):0)?(F=f[(f[k+12>>2]|0)+(E<<2)>>2]|0,(F|0)!=-1):0){E=F+(((F>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=E;if((E|0)!=-1&(E|0)!=(B|0)){F=A;H=v;I=E;while(1){E=I+1|0;J=((E>>>0)%3|0|0)==0?I+-2|0:E;do if(f[(f[a>>2]|0)+(J>>>5<<2)>>2]&1<<(J&31)){E=F+1|0;K=f[(f[l>>2]|0)+(((I|0)/3|0)*12|0)+(((I|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))L=f[(f[n>>2]|0)+(K<<2)>>2]|0;else L=K;f[i>>2]=L;K=f[d>>2]|0;if(K>>>0<(f[o>>2]|0)>>>0){f[K>>2]=L;f[d>>2]=K+4}else Ri(c,i);K=f[s>>2]|0;if((K|0)==(f[t>>2]|0)){Ri(r,h);M=E;N=F;break}else{f[K>>2]=f[h>>2];f[s>>2]=K+4;M=E;N=F;break}}else{M=F;N=H}while(0);f[(f[q>>2]|0)+(f[h>>2]<<2)>>2]=N;O=f[j>>2]|0;J=f[h>>2]|0;if((J|0)==-1)break;E=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((E|0)==-1)break;J=f[(f[O+12>>2]|0)+(E<<2)>>2]|0;if((J|0)==-1)break;I=J+(((J>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=I;if(!((I|0)!=-1?(I|0)!=(f[g>>2]|0):0)){P=M;Q=O;break b}else{F=M;H=N}}f[h>>2]=-1;P=M;Q=O}else{P=A;Q=k}}else R=28;while(0);if((R|0)==28){R=0;f[h>>2]=-1;P=A;Q=k}y=P;z=Q}w=w+1|0;if(w>>>0>=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2>>>0)break;else{v=y;x=z}}u=e;return}function Rc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,D=0,E=0,F=0;switch(c|0){case 0:{e=-149;g=24;i=4;break}case 1:{e=-1074;g=53;i=4;break}case 2:{e=-1074;g=53;i=4;break}default:j=0.0}a:do if((i|0)==4){c=a+4|0;k=a+100|0;do{l=f[c>>2]|0;if(l>>>0<(f[k>>2]|0)>>>0){f[c>>2]=l+1;m=h[l>>0]|0}else m=Si(a)|0}while((eq(m)|0)!=0);b:do switch(m|0){case 43:case 45:{l=1-(((m|0)==45&1)<<1)|0;n=f[c>>2]|0;if(n>>>0<(f[k>>2]|0)>>>0){f[c>>2]=n+1;o=h[n>>0]|0;p=l;break b}else{o=Si(a)|0;p=l;break b}break}default:{o=m;p=1}}while(0);l=0;n=o;while(1){if((n|32|0)!=(b[18546+l>>0]|0)){q=l;r=n;break}do if(l>>>0<7){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;t=h[s>>0]|0;break}else{t=Si(a)|0;break}}else t=n;while(0);s=l+1|0;if(s>>>0<8){l=s;n=t}else{q=s;r=t;break}}c:do switch(q|0){case 8:break;case 3:{i=23;break}default:{n=(d|0)!=0;if(n&q>>>0>3)if((q|0)==8)break c;else{i=23;break c}d:do if(!q){l=0;s=r;while(1){if((s|32|0)!=(b[18555+l>>0]|0)){u=l;v=s;break d}do if(l>>>0<2){w=f[c>>2]|0;if(w>>>0<(f[k>>2]|0)>>>0){f[c>>2]=w+1;x=h[w>>0]|0;break}else{x=Si(a)|0;break}}else x=s;while(0);w=l+1|0;if(w>>>0<3){l=w;s=x}else{u=w;v=x;break}}}else{u=q;v=r}while(0);switch(u|0){case 3:{s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;y=h[s>>0]|0}else y=Si(a)|0;if((y|0)==40)z=1;else{if(!(f[k>>2]|0)){j=B;break a}f[c>>2]=(f[c>>2]|0)+-1;j=B;break a}while(1){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;A=h[s>>0]|0}else A=Si(a)|0;if(!((A+-48|0)>>>0<10|(A+-65|0)>>>0<26)?!((A|0)==95|(A+-97|0)>>>0<26):0)break;z=z+1|0}if((A|0)==41){j=B;break a}s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!n){l=Vq()|0;f[l>>2]=22;Ym(a,0);j=0.0;break a}if(!z){j=B;break a}else D=z;while(1){D=D+-1|0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!D){j=B;break a}}break}case 0:{if((v|0)==48){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;E=h[s>>0]|0}else E=Si(a)|0;if((E|32|0)==120){j=+Fc(a,g,e,p,d);break a}if(!(f[k>>2]|0))F=48;else{f[c>>2]=(f[c>>2]|0)+-1;F=48}}else F=v;j=+nb(a,F,g,e,p,d);break a;break}default:{if(f[k>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;s=Vq()|0;f[s>>2]=22;Ym(a,0);j=0.0;break a}}}}while(0);if((i|0)==23){s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if((d|0)!=0&q>>>0>3){n=q;do{if(!s)f[c>>2]=(f[c>>2]|0)+-1;n=n+-1|0}while(n>>>0>3)}}j=+$($(p|0)*$(C))}while(0);return +j}function Sc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case 0:{m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m;break}case -1:{if((mi(c)|0)==10){m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m}else p=6;break}default:p=6}a:do if((p|0)==6){m=d+8|0;q=d+12|0;r=f[q>>2]|0;s=f[m>>2]|0;b:do if((r-s|0)>0){t=h+8|0;v=h+4|0;w=c+16|0;x=h+11|0;y=0;z=s;A=r;c:while(1){B=f[(f[z+(y<<2)>>2]|0)+28>>2]|0;switch(B|0){case 9:{p=12;break}case 6:case 5:case 4:case 2:{C=z;D=A;break}default:{if((B|2|0)!=3)break c;if((B|0)==9)p=12;else{C=z;D=A}}}if((p|0)==12){p=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;B=ln(32)|0;f[h>>2]=B;f[t>>2]=-2147483616;f[v>>2]=17;j=B;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[B+17>>0]=0;E=f[w>>2]|0;if(E){F=w;G=E;d:while(1){E=G;while(1){if((f[E+16>>2]|0)>=0)break;H=f[E+4>>2]|0;if(!H){I=F;break d}else E=H}G=f[E>>2]|0;if(!G){I=E;break}else F=E}if(((I|0)!=(w|0)?(f[I+16>>2]|0)<=0:0)?(F=I+20|0,(Jh(F,h)|0)!=0):0)J=Hk(F,h,-1)|0;else p=21}else p=21;if((p|0)==21){p=0;J=Hk(c,h,-1)|0}if((b[x>>0]|0)<0)Oq(f[h>>2]|0);if((J|0)<1)break;C=f[m>>2]|0;D=f[q>>2]|0}y=y+1|0;if((y|0)>=(D-C>>2|0))break b;else{z=C;A=D}}if((i|0)!=1){A=ln(52)|0;j=A;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(A);n=4044;o=A;break a}f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;z=ln(32)|0;f[h>>2]=z;f[h+8>>2]=-2147483616;f[h+4>>2]=24;j=z;k=14513;l=j+24|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[z+24>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}while(0);q=ln(52)|0;j=q;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(q);n=3988;o=q}while(0);f[o>>2]=n;ip(o,d);Md(a,o,c,e);Va[f[(f[o>>2]|0)+4>>2]&127](o);u=g;return}function Tc(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;i=u;u=u+32|0;j=i+4|0;k=i;l=i+16|0;m=(_(e|0)|0)^31;if((e|0)>0)if(m>>>0>17){n=0;u=i;return n|0}else o=m+1|0;else o=1;do if(g){m=ln(48)|0;f[j>>2]=m;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=m;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[m+33>>0]=0;r=(Jh(g,j)|0)==0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if(!r){r=ln(48)|0;f[j>>2]=r;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=r;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[r+33>>0]=0;p=Mk(g,j)|0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((p|0)<4){s=o+-2|0;break}if((p|0)<6){s=o+-1|0;break}if((p|0)>9){s=o+2|0;break}else{s=o+((p|0)>7&1)|0;break}}else s=o}else s=o;while(0);o=(s|0)>1?s:1;s=(o|0)<18?o:18;b[l>>0]=s;o=h+16|0;g=f[o+4>>2]|0;if(!((g|0)>0|(g|0)==0&(f[o>>2]|0)>>>0>0)){f[k>>2]=f[h+4>>2];f[j>>2]=f[k>>2];Me(h,j,l,l+1|0)|0}do switch(s&31){case 1:case 0:{n=ue(a,c,d,h)|0;u=i;return n|0}case 2:{n=te(a,c,d,h)|0;u=i;return n|0}case 3:{n=se(a,c,d,h)|0;u=i;return n|0}case 4:{n=re(a,c,d,h)|0;u=i;return n|0}case 5:{n=qe(a,c,d,h)|0;u=i;return n|0}case 6:{n=pe(a,c,d,h)|0;u=i;return n|0}case 7:{n=oe(a,c,d,h)|0;u=i;return n|0}case 8:{n=ne(a,c,d,h)|0;u=i;return n|0}case 9:{n=me(a,c,d,h)|0;u=i;return n|0}case 10:{n=le(a,c,d,h)|0;u=i;return n|0}case 11:{n=ke(a,c,d,h)|0;u=i;return n|0}case 12:{n=ie(a,c,d,h)|0;u=i;return n|0}case 13:{n=he(a,c,d,h)|0;u=i;return n|0}case 14:{n=ge(a,c,d,h)|0;u=i;return n|0}case 15:{n=fe(a,c,d,h)|0;u=i;return n|0}case 16:{n=ee(a,c,d,h)|0;u=i;return n|0}case 17:{n=de(a,c,d,h)|0;u=i;return n|0}case 18:{n=ce(a,c,d,h)|0;u=i;return n|0}default:{n=0;u=i;return n|0}}while(0);return 0}function Uc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;xb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Vc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;yb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Wc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;zb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Xc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ab(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Yc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Fb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Zc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*524288.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==524288){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Bb(z,A,g);a:do if((x|0)<524288){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=524288-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>524288;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-524288|0;m=x;while(1){v=524288.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==524288){C=p;D=524288;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=524288){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*1.9073486328125e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function _c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*262144.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==262144){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Cb(z,A,g);a:do if((x|0)<262144){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=262144-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>262144;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-262144|0;m=x;while(1){v=262144.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==262144){C=p;D=262144;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=262144){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*3.814697265625e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function $c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*65536.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==65536){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Db(z,A,g);a:do if((x|0)<65536){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=65536-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>65536;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-65536|0;m=x;while(1){v=65536.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==65536){C=p;D=65536;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=65536){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0000152587890625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ad(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*32768.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==32768){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Eb(z,A,g);a:do if((x|0)<32768){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=32768-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>32768;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-32768|0;m=x;while(1){v=32768.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==32768){C=p;D=32768;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=32768){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000030517578125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function bd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*8192.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==8192){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Gb(z,A,g);a:do if((x|0)<8192){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=8192-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>8192;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-8192|0;m=x;while(1){v=8192.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==8192){C=p;D=8192;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=8192){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0001220703125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function cd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Hb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function dd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ib(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ed(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Jb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Kb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function gd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Lb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function hd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Mb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function id(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Nb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function jd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ob(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function kd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0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0,G=0,H=0,J=0,K=0,L=0,M=0;d=u;u=u+32|0;e=d;g=d+20|0;h=d+24|0;i=d+8|0;j=f[a>>2]|0;k=j+8|0;l=j;j=f[l>>2]|0;m=f[l+4>>2]|0;l=Vn(j|0,m|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=I;n=Vn(l|0,k|0,(l|0)==0&(k|0)==0&1|0,0)|0;k=~~((+(j>>>0)+4294967296.0*+(m>>>0))/(+(n>>>0)+4294967296.0*+(I>>>0))*256.0+.5)>>>0;n=k>>>0<255?k:255;k=n+((n|0)==0&1)&255;b[h>>0]=k;n=a+12|0;m=a+16|0;j=((f[m>>2]|0)-(f[n>>2]|0)<<1)+64|0;f[i>>2]=0;l=i+4|0;f[l>>2]=0;f[i+8>>2]=0;if(!j)o=0;else{if((j|0)<0)aq(i);p=ln(j)|0;f[l>>2]=p;f[i>>2]=p;f[i+8>>2]=p+j;q=j;j=p;do{b[j>>0]=0;j=(f[l>>2]|0)+1|0;f[l>>2]=j;q=q+-1|0}while((q|0)!=0);o=f[i>>2]|0}q=a+28|0;j=(f[q>>2]|0)+-1|0;a:do if((j|0)>-1){p=a+24|0;r=j;s=4096;t=0;v=k;while(1){w=(f[p>>2]&1<>>0>>0){y=t;z=s}else{b[o+t>>0]=s;y=t+1|0;z=s>>>8}un(f[4092+(x<<3)>>2]|0,0,z|0,0)|0;A=z+(w?0:0-v&255)+(X((z+I|0)>>>(f[4092+(x<<3)+4>>2]|0),256-x|0)|0)|0;x=r+-1|0;if((x|0)<=-1){B=A;C=y;break a}r=x;s=A;t=y;v=b[h>>0]|0}}else{B=4096;C=0}while(0);y=f[m>>2]|0;if((f[n>>2]|0)==(y|0)){D=B;E=C}else{z=B;B=C;C=y;while(1){C=C+-4|0;y=f[C>>2]|0;k=31;j=z;v=B;while(1){t=b[h>>0]|0;s=(1<>>0>>0){F=v;G=j}else{b[o+v>>0]=j;F=v+1|0;G=j>>>8}un(f[4092+(r<<3)>>2]|0,0,G|0,0)|0;j=G+(s?0:0-t&255)+(X((G+I|0)>>>(f[4092+(r<<3)+4>>2]|0),256-r|0)|0)|0;if((k|0)<=0)break;else{k=k+-1|0;v=F}}if((f[n>>2]|0)==(C|0)){D=j;E=F;break}else{z=j;B=F}}}F=D+-4096|0;do if(F>>>0>=64){if(F>>>0<16384){B=o+E|0;z=D+12288|0;b[B>>0]=z;H=2;J=z>>>8;K=B+1|0;L=25;break}if(F>>>0<4194304){B=o+E|0;z=D+8384512|0;b[B>>0]=z;b[B+1>>0]=z>>>8;H=3;J=z>>>16;K=B+2|0;L=25}else M=E}else{H=1;J=F;K=o+E|0;L=25}while(0);if((L|0)==25){b[K>>0]=J;M=H+E|0}E=c+16|0;H=E;J=f[H+4>>2]|0;if(!((J|0)>0|(J|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}ci(M,c)|0;h=f[i>>2]|0;H=E;E=f[H+4>>2]|0;if(!((E|0)>0|(E|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+M|0)|0}M=e;f[M>>2]=0;f[M+4>>2]=0;qf(a,2,e);e=f[a+12>>2]|0;M=f[m>>2]|0;if((M|0)!=(e|0))f[m>>2]=M+(~((M+-4-e|0)>>>2)<<2);f[a+24>>2]=0;f[q>>2]=0;q=f[i>>2]|0;if(!q){u=d;return}if((f[l>>2]|0)!=(q|0))f[l>>2]=q;Oq(q);u=d;return}function md(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;c=u;u=u+16|0;b=c+8|0;d=c+4|0;e=c;g=a+64|0;h=f[g>>2]|0;if((f[h+28>>2]|0)==(f[h+24>>2]|0)){u=c;return}i=a+52|0;j=a+56|0;k=a+60|0;l=a+12|0;m=a+28|0;n=a+40|0;o=a+44|0;p=a+48|0;q=0;r=0;s=h;while(1){h=f[(f[s+24>>2]|0)+(r<<2)>>2]|0;if((h|0)==-1){t=q;v=s}else{w=q+1|0;f[b>>2]=q;x=f[j>>2]|0;if((x|0)==(f[k>>2]|0))Ri(i,b);else{f[x>>2]=q;f[j>>2]=x+4}f[d>>2]=h;f[e>>2]=0;a:do if(!(f[(f[l>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)))y=h;else{x=h+1|0;z=((x>>>0)%3|0|0)==0?h+-2|0:x;if(((z|0)!=-1?(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)==0:0)?(x=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0,z=x+1|0,(x|0)!=-1):0){A=((z>>>0)%3|0|0)==0?x+-2|0:z;f[e>>2]=A;if((A|0)==-1){y=h;break}else B=A;while(1){f[d>>2]=B;A=B+1|0;z=((A>>>0)%3|0|0)==0?B+-2|0:A;if((z|0)==-1)break;if(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)break;A=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0;z=A+1|0;if((A|0)==-1)break;x=((z>>>0)%3|0|0)==0?A+-2|0:z;f[e>>2]=x;if((x|0)==-1){y=B;break a}else B=x}f[e>>2]=-1;y=B;break}f[e>>2]=-1;y=h}while(0);f[(f[m>>2]|0)+(y<<2)>>2]=f[b>>2];h=f[o>>2]|0;if((h|0)==(f[p>>2]|0))Ri(n,d);else{f[h>>2]=f[d>>2];f[o>>2]=h+4}h=f[g>>2]|0;x=f[d>>2]|0;b:do if(((x|0)!=-1?(z=(((x>>>0)%3|0|0)==0?2:-1)+x|0,(z|0)!=-1):0)?(A=f[(f[h+12>>2]|0)+(z<<2)>>2]|0,(A|0)!=-1):0){z=A+(((A>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=z;if((z|0)!=-1&(z|0)!=(x|0)){A=w;C=z;while(1){z=C+1|0;D=((z>>>0)%3|0|0)==0?C+-2|0:z;do if(f[(f[a>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)){z=A+1|0;f[b>>2]=A;E=f[j>>2]|0;if((E|0)==(f[k>>2]|0))Ri(i,b);else{f[E>>2]=A;f[j>>2]=E+4}E=f[o>>2]|0;if((E|0)==(f[p>>2]|0)){Ri(n,e);F=z;break}else{f[E>>2]=f[e>>2];f[o>>2]=E+4;F=z;break}}else F=A;while(0);f[(f[m>>2]|0)+(f[e>>2]<<2)>>2]=f[b>>2];G=f[g>>2]|0;D=f[e>>2]|0;if((D|0)==-1)break;z=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((z|0)==-1)break;D=f[(f[G+12>>2]|0)+(z<<2)>>2]|0;if((D|0)==-1)break;C=D+(((D>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=C;if(!((C|0)!=-1?(C|0)!=(f[d>>2]|0):0)){H=F;I=G;break b}else A=F}f[e>>2]=-1;H=F;I=G}else{H=w;I=h}}else J=26;while(0);if((J|0)==26){J=0;f[e>>2]=-1;H=w;I=h}t=H;v=I}r=r+1|0;if(r>>>0>=(f[v+28>>2]|0)-(f[v+24>>2]|0)>>2>>>0)break;else{q=t;s=v}}u=c;return}function nd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+124|0;f[h>>2]=(f[h>>2]|0)+1;h=a+88|0;i=a+120|0;j=f[i>>2]|0;k=j+1|0;do if((j|0)!=-1){l=((k>>>0)%3|0|0)==0?j+-2|0:k;if(!((j>>>0)%3|0)){m=j+2|0;n=l;break}else{m=j+-1|0;n=l;break}}else{m=-1;n=-1}while(0);k=a+104|0;l=a+92|0;o=f[l>>2]|0;p=o+(n<<2)|0;q=f[k>>2]|0;r=q+(f[p>>2]<<2)|0;s=f[r>>2]|0;switch(b|0){case 1:case 0:{f[r>>2]=s+-1;r=q+(f[o+(m<<2)>>2]<<2)|0;f[r>>2]=(f[r>>2]|0)+-1;if((b|0)==1){if((m|0)!=-1?(r=f[(f[(f[h>>2]|0)+12>>2]|0)+(m<<2)>>2]|0,(r|0)!=-1):0){t=a+64|0;v=1;w=r;while(1){r=f[t>>2]|0;x=f[(f[r>>2]|0)+36>>2]|0;f[e>>2]=(w>>>0)/3|0;f[d>>2]=f[e>>2];if(Ra[x&127](r,d)|0){y=v;break}r=w+1|0;x=((r>>>0)%3|0|0)==0?w+-2|0:r;if((x|0)==-1){z=12;break}w=f[(f[(f[h>>2]|0)+12>>2]|0)+(x<<2)>>2]|0;x=v+1|0;if((w|0)==-1){y=x;break}else v=x}if((z|0)==12)y=v+1|0;A=y;B=f[k>>2]|0;C=f[l>>2]|0}else{A=1;B=q;C=o}f[B+(f[C+(f[i>>2]<<2)>>2]<<2)>>2]=A;A=a+108|0;i=f[A>>2]|0;C=i-B>>2;B=i;if((n|0)!=-1?(i=f[(f[(f[h>>2]|0)+12>>2]|0)+(n<<2)>>2]|0,(i|0)!=-1):0){n=a+64|0;y=1;v=i;while(1){i=f[n>>2]|0;w=f[(f[i>>2]|0)+36>>2]|0;f[g>>2]=(v>>>0)/3|0;f[d>>2]=f[g>>2];if(Ra[w&127](i,d)|0){D=y;break}i=v+1|0;f[(f[l>>2]|0)+((((i>>>0)%3|0|0)==0?v+-2|0:i)<<2)>>2]=C;i=(((v>>>0)%3|0|0)==0?2:-1)+v|0;if((i|0)==-1){z=20;break}v=f[(f[(f[h>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;i=y+1|0;if((v|0)==-1){D=i;break}else y=i}if((z|0)==20)D=y+1|0;E=D;F=f[A>>2]|0}else{E=1;F=B}f[d>>2]=E;if(F>>>0<(f[a+112>>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>2]=2076;i=c;f[a>>2]=i;return}case 2:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2132;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ti(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2188;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2244;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2300;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=2356;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function qd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1656;i=c;f[a>>2]=i;return}case 2:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1712;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ui(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1768;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1824;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1880;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1936;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function rd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+2|0;v=e+12|0;w=q+6|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=d[q>>1]|0;A=e;B=x;while(1){C=B+8|0;if(z<<16>>16!=(d[C>>1]|0)){y=A;break d}if((d[u>>1]|0)!=(d[C+2>>1]|0)){y=A;break d}if((d[v>>1]|0)!=(d[B+12>>1]|0)){y=A;break d}if((d[w>>1]|0)!=(d[C+6>>1]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=c;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(b>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+2|0;u=e+12|0;x=w+6|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=d[w>>1]|0;B=e;z=q;while(1){D=z+8|0;if(A<<16>>16!=(d[D>>1]|0)){G=B;break e}if((d[v>>1]|0)!=(d[D+2>>1]|0)){G=B;break e}if((d[u>>1]|0)!=(d[z+12>>1]|0)){G=B;break e}if((d[x>>1]|0)!=(d[D+6>>1]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);c=f[p>>2]|0;if(!c){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){E=43;break}else{k=s;l=r;n=r}}if((E|0)==43)return}function sd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=q+3|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=b[q>>0]|0;A=e;B=x;while(1){C=B+8|0;if(z<<24>>24!=(b[C>>0]|0)){y=A;break d}if((b[u>>0]|0)!=(b[C+1>>0]|0)){y=A;break d}if((b[v>>0]|0)!=(b[C+2>>0]|0)){y=A;break d}if((b[w>>0]|0)!=(b[C+3>>0]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=d;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(c>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+1|0;u=w+2|0;x=w+3|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=b[w>>0]|0;B=e;z=q;while(1){D=z+8|0;if(A<<24>>24!=(b[D>>0]|0)){G=B;break e}if((b[v>>0]|0)!=(b[D+1>>0]|0)){G=B;break e}if((b[u>>0]|0)!=(b[D+2>>0]|0)){G=B;break e}if((b[x>>0]|0)!=(b[D+3>>0]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);d=f[p>>2]|0;if(!d){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){E=43;break}else{k=s;l=r;n=r}}if((E|0)==43)return}function td(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0;i=u;u=u+352|0;j=i+340|0;k=i+336|0;l=i+80|0;m=i+48|0;n=i;sj(l|0,0,256)|0;o=f[e+4>>2]|0;p=f[e>>2]|0;q=p;if((o|0)!=(p|0)){r=o-p>>2;p=0;do{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G>>2]|0)>>>0>0){G=f[o>>2]|0;H=G+4|0;J=0;K=f[H>>2]|0;do{L=K>>>3;M=K&7;N=(f[G>>2]|0)+L|0;b[N>>0]=(1<>0]|0);N=(f[G>>2]|0)+L|0;b[N>>0]=(F>>>J&1)<>0]|0);K=(f[H>>2]|0)+1|0;f[H>>2]=K;J=J+1|0}while((J|0)!=(E|0))}A=A+1|0}while((A|0)!=(d|0))}v=v-d|0}while((v|0)>-1)}_f(n,g);eg(m);v=f[m>>2]|0;d=m+4|0;o=g+16|0;r=f[o+4>>2]|0;if(!((r|0)>0|(r|0)==0&(f[o>>2]|0)>>>0>0)){o=(f[d>>2]|0)-v|0;f[k>>2]=f[l>>2];f[j>>2]=f[k>>2];Me(g,j,v,v+o|0)|0}o=f[n>>2]|0;if(o|0){v=n+4|0;n=f[v>>2]|0;if((n|0)!=(o|0))f[v>>2]=n+(~((n+-8-o|0)>>>3)<<3);Oq(o)}o=m+12|0;n=f[o>>2]|0;f[o>>2]=0;if(n|0)Oq(n);n=f[m>>2]|0;if(!n){u=i;return 1}if((f[d>>2]|0)!=(n|0))f[d>>2]=n;Oq(n);u=i;return 1}function ud(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=d+20|0;v=f[d>>2]|0;d:do if(!v)w=d;else{x=f[d+8>>2]|0;y=d;z=v;while(1){if((x|0)!=(f[z+8>>2]|0)){w=y;break d}if((f[p>>2]|0)!=(f[z+12>>2]|0)){w=y;break d}if((f[t>>2]|0)!=(f[z+16>>2]|0)){w=y;break d}if((f[u>>2]|0)!=(f[z+20>>2]|0)){w=y;break d}A=f[z>>2]|0;if(!A){w=z;break}else{B=z;z=A;y=B}}}while(0);f[i>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}else{d=c;while(1){u=f[d+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(j|0)){o=d;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){q=d;r=D;s=u;break b}u=d+12|0;t=d+16|0;p=d+20|0;v=f[d>>2]|0;e:do if(!v)E=d;else{y=f[d+8>>2]|0;z=d;x=v;while(1){if((y|0)!=(f[x+8>>2]|0)){E=z;break e}if((f[u>>2]|0)!=(f[x+12>>2]|0)){E=z;break e}if((f[t>>2]|0)!=(f[x+16>>2]|0)){E=z;break e}if((f[p>>2]|0)!=(f[x+20>>2]|0)){E=z;break e}B=f[x>>2]|0;if(!B){E=x;break}else{A=x;x=B;z=A}}}while(0);f[i>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}while(0);c=f[o>>2]|0;if(!c){C=43;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){C=43;break}else{j=r;k=q;m=q}}if((C|0)==43)return}function vd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=e+12|0;v=f[e>>2]|0;d:do if(!v)w=e;else{x=d[q>>1]|0;y=q+2|0;z=e;A=v;while(1){B=A+8|0;if(x<<16>>16!=(d[B>>1]|0)){w=z;break d}if((d[y>>1]|0)!=(d[B+2>>1]|0)){w=z;break d}if((d[u>>1]|0)!=(d[A+12>>1]|0)){w=z;break d}B=f[A>>2]|0;if(!B){w=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)E=u;else E=(u>>>0)%(b>>>0)|0;if((E|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(E<<2)|0;if(!(f[u>>2]|0)){r=e;s=E;t=u;break b}u=e+8|0;v=e+12|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=d[u>>1]|0;A=u+2|0;y=e;x=q;while(1){C=x+8|0;if(z<<16>>16!=(d[C>>1]|0)){F=y;break e}if((d[A>>1]|0)!=(d[C+2>>1]|0)){F=y;break e}if((d[v>>1]|0)!=(d[x+12>>1]|0)){F=y;break e}C=f[x>>2]|0;if(!C){F=x;break}else{B=x;x=C;y=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);c=f[p>>2]|0;if(!c){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function wd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=f[e>>2]|0;d:do if(!w)x=e;else{y=b[q>>0]|0;z=e;A=w;while(1){B=A+8|0;if(y<<24>>24!=(b[B>>0]|0)){x=z;break d}if((b[u>>0]|0)!=(b[B+1>>0]|0)){x=z;break d}if((b[v>>0]|0)!=(b[B+2>>0]|0)){x=z;break d}B=f[A>>2]|0;if(!B){x=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[x>>2];f[x>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=d;while(1){v=f[e+4>>2]|0;if(v>>>0>>0)E=v;else E=(v>>>0)%(c>>>0)|0;if((E|0)==(k|0)){p=e;break c}v=(f[a>>2]|0)+(E<<2)|0;if(!(f[v>>2]|0)){r=e;s=E;t=v;break b}v=e+8|0;u=v+1|0;w=v+2|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=b[v>>0]|0;A=e;y=q;while(1){C=y+8|0;if(z<<24>>24!=(b[C>>0]|0)){F=A;break e}if((b[u>>0]|0)!=(b[C+1>>0]|0)){F=A;break e}if((b[w>>0]|0)!=(b[C+2>>0]|0)){F=A;break e}C=f[y>>2]|0;if(!C){F=y;break}else{B=y;y=C;A=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);d=f[p>>2]|0;if(!d){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function xd(a,b){a=+a;b=+b;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s>>2]|0;g=f[s+4>>2]|0;h=Yn(c|0,d|0,52)|0;i=h&2047;h=Yn(e|0,g|0,52)|0;j=h&2047;h=d&-2147483648;k=Tn(e|0,g|0,1)|0;l=I;a:do if(!((k|0)==0&(l|0)==0)?(m=yo(b)|0,n=I&2147483647,!((i|0)==2047|(n>>>0>2146435072|(n|0)==2146435072&m>>>0>0))):0){m=Tn(c|0,d|0,1)|0;n=I;if(!(n>>>0>l>>>0|(n|0)==(l|0)&m>>>0>k>>>0))return +((m|0)==(k|0)&(n|0)==(l|0)?a*0.0:a);if(!i){n=Tn(c|0,d|0,12)|0;m=I;if((m|0)>-1|(m|0)==-1&n>>>0>4294967295){o=0;q=n;n=m;while(1){m=o+-1|0;q=Tn(q|0,n|0,1)|0;n=I;if(!((n|0)>-1|(n|0)==-1&q>>>0>4294967295)){r=m;break}else o=m}}else r=0;o=Tn(c|0,d|0,1-r|0)|0;t=r;u=o;v=I}else{t=i;u=c;v=d&1048575|1048576}if(!j){o=Tn(e|0,g|0,12)|0;q=I;if((q|0)>-1|(q|0)==-1&o>>>0>4294967295){n=0;m=o;o=q;while(1){q=n+-1|0;m=Tn(m|0,o|0,1)|0;o=I;if(!((o|0)>-1|(o|0)==-1&m>>>0>4294967295)){w=q;break}else n=q}}else w=0;n=Tn(e|0,g|0,1-w|0)|0;x=w;y=n;z=I}else{x=j;y=e;z=g&1048575|1048576}n=Xn(u|0,v|0,y|0,z|0)|0;m=I;o=(m|0)>-1|(m|0)==-1&n>>>0>4294967295;b:do if((t|0)>(x|0)){q=t;A=m;B=o;C=u;D=v;E=n;while(1){if(B)if((E|0)==0&(A|0)==0)break;else{F=E;G=A}else{F=C;G=D}H=Tn(F|0,G|0,1)|0;J=I;K=q+-1|0;L=Xn(H|0,J|0,y|0,z|0)|0;M=I;N=(M|0)>-1|(M|0)==-1&L>>>0>4294967295;if((K|0)>(x|0)){q=K;A=M;B=N;C=H;D=J;E=L}else{O=K;P=N;Q=L;R=M;S=H;T=J;break b}}U=a*0.0;break a}else{O=t;P=o;Q=n;R=m;S=u;T=v}while(0);if(P)if((Q|0)==0&(R|0)==0){U=a*0.0;break}else{V=R;W=Q}else{V=T;W=S}if(V>>>0<1048576|(V|0)==1048576&W>>>0<0){m=O;n=W;o=V;while(1){E=Tn(n|0,o|0,1)|0;D=I;C=m+-1|0;if(D>>>0<1048576|(D|0)==1048576&E>>>0<0){m=C;n=E;o=D}else{X=C;Y=E;Z=D;break}}}else{X=O;Y=W;Z=V}if((X|0)>0){o=Vn(Y|0,Z|0,0,-1048576)|0;n=I;m=Tn(X|0,0,52)|0;_=n|I;$=o|m}else{m=Yn(Y|0,Z|0,1-X|0)|0;_=I;$=m}f[s>>2]=$;f[s+4>>2]=_|h;U=+p[s>>3]}else aa=3;while(0);if((aa|0)==3){ba=a*b;U=ba/ba}return +U}function yd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+32|0;e=d+8|0;g=d;h=c+4|0;i=f[(f[h>>2]|0)+48>>2]|0;j=c+12|0;c=f[j>>2]|0;k=ln(32)|0;f[e>>2]=k;f[e+8>>2]=-2147483616;f[e+4>>2]=17;l=k;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[k+17>>0]=0;k=i+16|0;m=f[k>>2]|0;if(m){l=k;n=m;a:while(1){m=n;while(1){if((f[m+16>>2]|0)>=(c|0))break;o=f[m+4>>2]|0;if(!o){p=l;break a}else m=o}n=f[m>>2]|0;if(!n){p=m;break}else l=m}if(((p|0)!=(k|0)?(c|0)>=(f[p+16>>2]|0):0)?(c=p+20|0,(Jh(c,e)|0)!=0):0)q=Hk(c,e,-1)|0;else r=10}else r=10;if((r|0)==10)q=Hk(i,e,-1)|0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);f[e>>2]=-1;f[e+4>>2]=-1;f[e+8>>2]=-1;f[e+12>>2]=-1;i=(_((1<>>0<=28){f[e>>2]=i+1;q=2<>2]=q+-1;i=q+-2|0;f[e+8>>2]=i;f[e+12>>2]=(i|0)/2|0}switch(Xi(f[j>>2]|0,f[h>>2]|0)|0){case 6:{i=f[j>>2]|0;q=f[h>>2]|0;c=f[(f[(f[q+4>>2]|0)+8>>2]|0)+(i<<2)>>2]|0;do if((Qa[f[(f[q>>2]|0)+8>>2]&127](q)|0)==1){Hf(g,q,6,i,e,514);p=f[g>>2]|0;if(!p){f[g>>2]=0;s=g;r=21;break}else{t=g;v=p;break}}else{s=g;r=21}while(0);if((r|0)==21){i=ln(24)|0;f[i+4>>2]=c;c=i+8|0;f[c>>2]=f[e>>2];f[c+4>>2]=f[e+4>>2];f[c+8>>2]=f[e+8>>2];f[c+12>>2]=f[e+12>>2];f[i>>2]=2560;c=i;f[g>>2]=c;t=s;v=c}f[a>>2]=v;f[t>>2]=0;u=d;return}case 0:{t=f[j>>2]|0;j=f[h>>2]|0;h=f[(f[(f[j+4>>2]|0)+8>>2]|0)+(t<<2)>>2]|0;do if((Qa[f[(f[j>>2]|0)+8>>2]&127](j)|0)==1){Hf(g,j,0,t,e,514);v=f[g>>2]|0;if(!v){f[g>>2]=0;w=g;r=28;break}else{x=g;y=v;break}}else{w=g;r=28}while(0);if((r|0)==28){r=ln(24)|0;f[r+4>>2]=h;h=r+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[r>>2]=2560;e=r;f[g>>2]=e;x=w;y=e}f[a>>2]=y;f[x>>2]=0;u=d;return}default:{f[a>>2]=0;u=d;return}}}function zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=f[d>>2]|0;d:do if(!u)v=d;else{w=f[d+8>>2]|0;x=d;y=u;while(1){if((w|0)!=(f[y+8>>2]|0)){v=x;break d}if((f[p>>2]|0)!=(f[y+12>>2]|0)){v=x;break d}if((f[t>>2]|0)!=(f[y+16>>2]|0)){v=x;break d}z=f[y>>2]|0;if(!z){v=y;break}else{A=y;y=z;x=A}}}while(0);f[i>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}else{d=c;while(1){t=f[d+4>>2]|0;if(t>>>0>>0)C=t;else C=(t>>>0)%(b>>>0)|0;if((C|0)==(j|0)){o=d;break c}t=(f[a>>2]|0)+(C<<2)|0;if(!(f[t>>2]|0)){q=d;r=C;s=t;break b}t=d+12|0;p=d+16|0;u=f[d>>2]|0;e:do if(!u)D=d;else{x=f[d+8>>2]|0;y=d;w=u;while(1){if((x|0)!=(f[w+8>>2]|0)){D=y;break e}if((f[t>>2]|0)!=(f[w+12>>2]|0)){D=y;break e}if((f[p>>2]|0)!=(f[w+16>>2]|0)){D=y;break e}A=f[w>>2]|0;if(!A){D=w;break}else{z=w;w=A;y=z}}}while(0);f[i>>2]=f[D>>2];f[D>>2]=f[f[(f[a>>2]|0)+(C<<2)>>2]>>2];f[f[(f[a>>2]|0)+(C<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}while(0);c=f[o>>2]|0;if(!c){B=41;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){B=41;break}else{j=r;k=q;m=q}}if((B|0)==41)return}function Ad(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2980;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3036;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3092;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=ln(68)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3148;h=c+40|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(84)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3204;f[c+40>>2]=0;f[c+44>>2]=0;f[c+56>>2]=0;f[c+60>>2]=0;f[c+64>>2]=0;h=c+68|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(120)|0;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];e=c+24|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=3260;f[c+44>>2]=0;f[c+48>>2]=0;e=c+52|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+40>>2]=3316;f[c+68>>2]=1;g=c+72|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+88|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function Bd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){o=d;while(1){e=f[o+4>>2]|0;if(!i)if(e>>>0>>0)p=e;else p=(e>>>0)%(c>>>0)|0;else p=e&h;if((p|0)==(k|0))break;q=(f[a>>2]|0)+(p<<2)|0;if(!(f[q>>2]|0))break b;e=f[o>>2]|0;c:do if(!e)r=o;else{s=o+8|0;t=b[s+11>>0]|0;u=t<<24>>24<0;v=t&255;t=u?f[o+12>>2]|0:v;w=(t|0)==0;if(u){u=o;x=e;while(1){y=x+8|0;z=b[y+11>>0]|0;A=z<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:z&255)|0)){r=u;break c}if(!w?Vk(f[s>>2]|0,A?f[y>>2]|0:y,t)|0:0){r=u;break c}y=f[x>>2]|0;if(!y){r=x;break c}else{A=x;x=y;u=A}}}if(w){u=o;x=e;while(1){A=b[x+8+11>>0]|0;if((A<<24>>24<0?f[x+12>>2]|0:A&255)|0){r=u;break c}A=f[x>>2]|0;if(!A){r=x;break c}else{y=x;x=A;u=y}}}u=o;x=e;while(1){w=x+8|0;y=b[w+11>>0]|0;A=y<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:y&255)|0)){r=u;break c}y=A?f[w>>2]|0:w;if((b[y>>0]|0)==(f[s>>2]&255)<<24>>24){B=s;C=v;D=y}else{r=u;break c}while(1){C=C+-1|0;B=B+1|0;if(!C)break;D=D+1|0;if((b[B>>0]|0)!=(b[D>>0]|0)){r=u;break c}}y=f[x>>2]|0;if(!y){r=x;break}else{w=x;x=y;u=w}}}while(0);f[j>>2]=f[r>>2];f[r>>2]=f[f[(f[a>>2]|0)+(p<<2)>>2]>>2];f[f[(f[a>>2]|0)+(p<<2)>>2]>>2]=o;e=f[g>>2]|0;if(!e){E=43;break a}else o=e}d=f[o>>2]|0;if(!d){E=43;break a}else{g=o;j=o}}f[q>>2]=j;m=f[o>>2]|0;if(!m){E=43;break}else{k=p;l=o;n=o}}if((E|0)==43)return}function Cd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2616;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2672;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2728;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=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(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=d[q>>1]|0;x=q+2|0;y=e;z=u;while(1){A=z+8|0;if(w<<16>>16!=(d[A>>1]|0)){v=y;break d}if((d[x>>1]|0)!=(d[A+2>>1]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=d[u>>1]|0;z=u+2|0;x=e;w=q;while(1){B=w+8|0;if(y<<16>>16!=(d[B>>1]|0)){E=x;break e}if((d[z>>1]|0)!=(d[B+2>>1]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);c=f[p>>2]|0;if(!c){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Gd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=b[q>>0]|0;x=q+1|0;y=e;z=u;while(1){A=z+8|0;if(w<<24>>24!=(b[A>>0]|0)){v=y;break d}if((b[x>>0]|0)!=(b[A+1>>0]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=d;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(c>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=b[u>>0]|0;z=u+1|0;x=e;w=q;while(1){B=w+8|0;if(y<<24>>24!=(b[B>>0]|0)){E=x;break e}if((b[z>>0]|0)!=(b[B+1>>0]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);d=f[p>>2]|0;if(!d){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Hd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=u;u=u+48|0;d=c+32|0;e=c+28|0;g=c+16|0;h=c;i=a+16|0;j=f[i>>2]|0;if(j|0){k=f[b>>2]|0;l=i;m=j;a:while(1){j=m;while(1){if((f[j+16>>2]|0)>=(k|0))break;n=f[j+4>>2]|0;if(!n){o=l;break a}else j=n}m=f[j>>2]|0;if(!m){o=j;break}else l=j}if((o|0)!=(i|0)?(k|0)>=(f[o+16>>2]|0):0){p=o;q=p+20|0;u=c;return q|0}}lp(g);f[h>>2]=f[b>>2];b=h+4|0;f[h+8>>2]=0;o=h+12|0;f[o>>2]=0;k=h+8|0;f[b>>2]=k;l=f[g>>2]|0;m=g+4|0;if((l|0)!=(m|0)){n=k;r=l;while(1){l=r+16|0;f[e>>2]=n;f[d>>2]=f[e>>2];ph(b,d,l,l)|0;l=f[r+4>>2]|0;if(!l){s=r+8|0;t=f[s>>2]|0;if((f[t>>2]|0)==(r|0))v=t;else{t=s;do{s=f[t>>2]|0;t=s+8|0;w=f[t>>2]|0}while((f[w>>2]|0)!=(s|0));v=w}}else{t=l;while(1){j=f[t>>2]|0;if(!j)break;else t=j}v=t}if((v|0)==(m|0))break;else r=v}}v=a+12|0;r=f[i>>2]|0;do if(r){d=f[h>>2]|0;e=a+16|0;n=r;while(1){l=f[n+16>>2]|0;if((d|0)<(l|0)){j=f[n>>2]|0;if(!j){x=23;break}else{y=n;z=j}}else{if((l|0)>=(d|0)){x=27;break}A=n+4|0;l=f[A>>2]|0;if(!l){x=26;break}else{y=A;z=l}}e=y;n=z}if((x|0)==23){B=n;C=n;break}else if((x|0)==26){B=n;C=A;break}else if((x|0)==27){B=n;C=e;break}}else{B=i;C=i}while(0);i=f[C>>2]|0;if(!i){x=ln(32)|0;f[x+16>>2]=f[h>>2];A=x+20|0;f[A>>2]=f[b>>2];z=x+24|0;y=f[h+8>>2]|0;f[z>>2]=y;r=f[o>>2]|0;f[x+28>>2]=r;if(!r)f[A>>2]=z;else{f[y+8>>2]=z;f[b>>2]=k;f[k>>2]=0;f[o>>2]=0}f[x>>2]=0;f[x+4>>2]=0;f[x+8>>2]=B;f[C>>2]=x;B=f[f[v>>2]>>2]|0;if(!B)D=x;else{f[v>>2]=B;D=f[C>>2]|0}Oe(f[a+16>>2]|0,D);D=a+20|0;f[D>>2]=(f[D>>2]|0)+1;E=x}else E=i;Ej(h+4|0,f[k>>2]|0);Ej(g,f[m>>2]|0);p=E;q=p+20|0;u=c;return q|0}function Id(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=d-e|0;l=g+(e+4)|0;m=c}else{k=i;l=g;m=i}switch(k|0){case 3:{n=h[l+2>>0]<<16^m;o=6;break}case 2:{n=m;o=6;break}case 1:{p=m;o=7;break}default:q=m}if((o|0)==6){p=h[l+1>>0]<<8^n;o=7}if((o|0)==7)q=X(p^h[l>>0],1540483477)|0;l=X(q>>>13^q,1540483477)|0;q=l>>>15^l;l=f[a+4>>2]|0;if(!l){r=0;return r|0}p=l+-1|0;n=(p&l|0)==0;if(!n)if(q>>>0>>0)s=q;else s=(q>>>0)%(l>>>0)|0;else s=q&p;m=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!m){r=0;return r|0}a=f[m>>2]|0;if(!a){r=0;return r|0}m=(i|0)==0;if(n){n=a;a:while(1){k=f[n+4>>2]|0;c=(k|0)==(q|0);if(!(c|(k&p|0)==(s|0))){r=0;o=40;break}do if(c?(k=n+8|0,e=b[k+11>>0]|0,d=e<<24>>24<0,j=e&255,((d?f[n+12>>2]|0:j)|0)==(i|0)):0){e=f[k>>2]|0;t=d?e:k;if(d){if(m){r=n;o=40;break a}if(!(Vk(t,g,i)|0)){r=n;o=40;break a}else break}if(m){r=n;o=40;break a}if((b[g>>0]|0)==(e&255)<<24>>24){e=k;k=j;j=g;do{k=k+-1|0;e=e+1|0;if(!k){r=n;o=40;break a}j=j+1|0}while((b[e>>0]|0)==(b[j>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=40;break}}if((o|0)==40)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;do if((a|0)==(q|0)){n=u+8|0;p=b[n+11>>0]|0;c=p<<24>>24<0;j=p&255;if(((c?f[u+12>>2]|0:j)|0)==(i|0)){p=f[n>>2]|0;e=c?p:n;if(c){if(m){r=u;o=40;break b}if(!(Vk(e,g,i)|0)){r=u;o=40;break b}else break}if(m){r=u;o=40;break b}if((b[g>>0]|0)==(p&255)<<24>>24){p=n;n=j;j=g;do{n=n+-1|0;p=p+1|0;if(!n){r=u;o=40;break b}j=j+1|0}while((b[p>>0]|0)==(b[j>>0]|0))}}}else{if(a>>>0>>0)v=a;else v=(a>>>0)%(l>>>0)|0;if((v|0)!=(s|0)){r=0;o=40;break b}}while(0);u=f[u>>2]|0;if(!u){r=0;o=40;break}}if((o|0)==40)return r|0;return 0}function Jd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=f[d>>2]|0;d:do if(!t)u=d;else{v=f[d+8>>2]|0;w=d;x=t;while(1){if((v|0)!=(f[x+8>>2]|0)){u=w;break d}if((f[p>>2]|0)!=(f[x+12>>2]|0)){u=w;break d}y=f[x>>2]|0;if(!y){u=x;break}else{z=x;x=y;w=z}}}while(0);f[i>>2]=f[u>>2];f[u>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}else{d=c;while(1){p=f[d+4>>2]|0;if(p>>>0>>0)B=p;else B=(p>>>0)%(b>>>0)|0;if((B|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(B<<2)|0;if(!(f[p>>2]|0)){q=d;r=B;s=p;break b}p=d+12|0;t=f[d>>2]|0;e:do if(!t)C=d;else{w=f[d+8>>2]|0;x=d;v=t;while(1){if((w|0)!=(f[v+8>>2]|0)){C=x;break e}if((f[p>>2]|0)!=(f[v+12>>2]|0)){C=x;break e}z=f[v>>2]|0;if(!z){C=v;break}else{y=v;v=z;x=y}}}while(0);f[i>>2]=f[C>>2];f[C>>2]=f[f[(f[a>>2]|0)+(B<<2)>>2]>>2];f[f[(f[a>>2]|0)+(B<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}while(0);c=f[o>>2]|0;if(!c){A=39;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){A=39;break}else{j=r;k=q;m=q}}if((A|0)==39)return}function Kd(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;h=a+4|0;i=f[c>>2]|0;c=i;do if((i|0)!=(h|0)){j=i+16|0;k=b[j+11>>0]|0;l=k<<24>>24<0;m=l?f[i+20>>2]|0:k&255;k=b[g+11>>0]|0;n=k<<24>>24<0;o=n?f[g+4>>2]|0:k&255;k=m>>>0>>0;p=k?m:o;if((p|0)!=0?(q=Vk(n?f[g>>2]|0:g,l?f[j>>2]|0:j,p)|0,(q|0)!=0):0){if((q|0)<0)break}else r=4;if((r|0)==4?o>>>0>>0:0)break;q=o>>>0>>0?o:m;if((q|0)!=0?(m=Vk(l?f[j>>2]|0:j,n?f[g>>2]|0:g,q)|0,(m|0)!=0):0){if((m|0)>=0)r=37}else r=21;if((r|0)==21?!k:0)r=37;if((r|0)==37){f[d>>2]=c;f[e>>2]=c;s=e;return s|0}k=f[i+4>>2]|0;m=(k|0)==0;if(m){q=i+8|0;j=f[q>>2]|0;if((f[j>>2]|0)==(i|0))t=j;else{j=q;do{q=f[j>>2]|0;j=q+8|0;l=f[j>>2]|0}while((f[l>>2]|0)!=(q|0));t=l}}else{j=k;while(1){l=f[j>>2]|0;if(!l)break;else j=l}t=j}do if((t|0)!=(h|0)){k=t+16|0;l=b[k+11>>0]|0;q=l<<24>>24<0;p=q?f[t+20>>2]|0:l&255;l=p>>>0>>0?p:o;if((l|0)!=0?(u=Vk(n?f[g>>2]|0:g,q?f[k>>2]|0:k,l)|0,(u|0)!=0):0){if((u|0)<0)break}else r=31;if((r|0)==31?o>>>0

            • >>0?(r=q+(l<<2)|0,(r|0)!=(o|0)):0){f[m>>2]=o+(~((o+-4-r|0)>>>2)<<2);s=n;t=k;v=j}else{s=n;t=k;v=j}else{Ci(g,l-p|0);p=f[h>>2]|0;s=p;t=p;v=f[i>>2]|0}p=v-t|0;l=p>>2;f[c>>2]=0;j=c+4|0;f[j>>2]=0;k=c+8|0;f[k>>2]=0;if(l|0){if((p|0)<0)aq(c);p=((l+-1|0)>>>5)+1|0;n=ln(p<<2)|0;f[c>>2]=n;f[k>>2]=p;f[j>>2]=l;j=l>>>5;sj(n|0,0,j<<2|0)|0;p=l&31;l=n+(j<<2)|0;if(p|0)f[l>>2]=f[l>>2]&~(-1>>>(32-p|0))}p=a+20|0;l=0;j=s;s=t;t=v;while(1){if(l>>>0>2>>>0){w=0;x=0;y=l;z=s;A=j}else{B=25;break}while(1){v=x>>>5;n=1<<(x&31);do if(!(f[(f[c>>2]|0)+(v<<2)>>2]&n)){k=f[A+(x<<2)>>2]|0;if((f[k+8>>2]|0)!=(f[k+4>>2]|0)){r=0;o=1;m=A;q=k;while(1){k=f[(f[q+4>>2]|0)+(r<<2)>>2]|0;C=0;D=m;while(1){E=f[D+(x<<2)>>2]|0;if((C|0)>=(Ra[f[(f[E>>2]|0)+24>>2]&127](E,k)|0)){F=o;break}E=f[(f[h>>2]|0)+(x<<2)>>2]|0;G=Sa[f[(f[E>>2]|0)+28>>2]&31](E,k,C)|0;if((G|0)!=(x|0)?(E=f[(f[p>>2]|0)+(G<<2)>>2]|0,(1<<(E&31)&f[(f[c>>2]|0)+(E>>>5<<2)>>2]|0)==0):0){F=0;break}C=C+1|0;D=f[h>>2]|0}r=r+1|0;m=f[h>>2]|0;q=f[m+(x<<2)>>2]|0;if(r>>>0>=(f[q+8>>2]|0)-(f[q+4>>2]|0)>>2>>>0)break;else o=F}o=m;if(F)H=o;else{I=w;J=y;K=o;break}}else H=z;f[(f[g>>2]|0)+(y<<2)>>2]=x;o=(f[c>>2]|0)+(v<<2)|0;f[o>>2]=f[o>>2]|n;I=1;J=y+1|0;K=H}else{I=w;J=y;K=z}while(0);x=x+1|0;L=f[i>>2]|0;M=L-K>>2;A=K;if(x>>>0>=M>>>0)break;else{w=I;y=J;z=K}}if(J>>>0>>0&(I^1)){N=0;break}else{l=J;j=A;s=K;t=L}}if((B|0)==25){f[d>>2]=0;B=d+4|0;f[B>>2]=0;f[d+8>>2]=0;L=f[a+4>>2]|0;a=(f[L+12>>2]|0)-(f[L+8>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;if((S|0)>=(l|0))break;else{T=W;U=X}}if(W|(X|0)>=(l|0))R=X;else{O=0;break a}}bg(f[(f[h>>2]|0)+(A<<2)>>2]|0,d);P=f[h>>2]|0;Q=f[i>>2]|0}a=a+1|0;if(a>>>0>=Q-P>>2>>>0){O=1;break}else{L=P;K=P;J=Q}}}while(0);Q=f[e>>2]|0;if(Q|0)Oq(Q);Q=f[d>>2]|0;if(Q|0){d=f[B>>2]|0;if((d|0)!=(Q|0))f[B>>2]=d+(~((d+-4-Q|0)>>>2)<<2);Oq(Q)}N=O}O=f[c>>2]|0;if(!O){u=b;return N|0}Oq(O);u=b;return N|0}function yc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;c=f[4788]|0;d=f[a+-4>>2]|0;a=d&-8;e=b+a|0;do if(!(d&1)){g=f[b>>2]|0;if(!(d&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((f[4789]|0)==(h|0)){j=e+4|0;k=f[j>>2]|0;if((k&3|0)!=3){l=h;m=i;n=h;break}f[4786]=i;f[j>>2]=k&-2;f[h+4>>2]=i|1;f[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=f[h+8>>2]|0;j=f[h+12>>2]|0;if((j|0)==(g|0)){f[4784]=f[4784]&~(1<>2]=j;f[j+8>>2]=g;l=h;m=i;n=h;break}}g=f[h+24>>2]|0;j=f[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=f[o>>2]|0;if(!p){q=f[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=f[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=f[o>>2]|0;if(!p)break;else{s=p;t=o}}f[t>>2]=0;r=s}else{o=f[h+8>>2]|0;f[o+12>>2]=j;f[j+8>>2]=o;r=j}while(0);if(g){j=f[h+28>>2]|0;o=19440+(j<<2)|0;if((f[o>>2]|0)==(h|0)){f[o>>2]=r;if(!r){f[4785]=f[4785]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=i;n=h;break}}f[r+24>>2]=g;j=h+16|0;o=f[j>>2]|0;if(o|0){f[r+16>>2]=o;f[o+24>>2]=r}o=f[j+4>>2]|0;if(o){f[r+20>>2]=o;f[o+24>>2]=r;l=h;m=i;n=h}else{l=h;m=i;n=h}}else{l=h;m=i;n=h}}else{l=b;m=a;n=b}while(0);if(n>>>0>=e>>>0)return;b=e+4|0;a=f[b>>2]|0;if(!(a&1))return;if(!(a&2)){if((f[4790]|0)==(e|0)){r=(f[4787]|0)+m|0;f[4787]=r;f[4790]=l;f[l+4>>2]=r|1;if((l|0)!=(f[4789]|0))return;f[4789]=0;f[4786]=0;return}if((f[4789]|0)==(e|0)){r=(f[4786]|0)+m|0;f[4786]=r;f[4789]=n;f[l+4>>2]=r|1;f[n+r>>2]=r;return}r=(a&-8)+m|0;s=a>>>3;do if(a>>>0<256){t=f[e+8>>2]|0;c=f[e+12>>2]|0;if((c|0)==(t|0)){f[4784]=f[4784]&~(1<>2]=c;f[c+8>>2]=t;break}}else{t=f[e+24>>2]|0;c=f[e+12>>2]|0;do if((c|0)==(e|0)){d=e+16|0;o=d+4|0;j=f[o>>2]|0;if(!j){p=f[d>>2]|0;if(!p){u=0;break}else{v=p;w=d}}else{v=j;w=o}while(1){o=v+20|0;j=f[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=f[o>>2]|0;if(!j)break;else{v=j;w=o}}f[w>>2]=0;u=v}else{o=f[e+8>>2]|0;f[o+12>>2]=c;f[c+8>>2]=o;u=c}while(0);if(t|0){c=f[e+28>>2]|0;h=19440+(c<<2)|0;if((f[h>>2]|0)==(e|0)){f[h>>2]=u;if(!u){f[4785]=f[4785]&~(1<>2]|0)!=(e|0)&1)<<2)>>2]=u;if(!u)break}f[u+24>>2]=t;c=e+16|0;h=f[c>>2]|0;if(h|0){f[u+16>>2]=h;f[h+24>>2]=u}h=f[c+4>>2]|0;if(h|0){f[u+20>>2]=h;f[h+24>>2]=u}}}while(0);f[l+4>>2]=r|1;f[n+r>>2]=r;if((l|0)==(f[4789]|0)){f[4786]=r;return}else x=r}else{f[b>>2]=a&-2;f[l+4>>2]=m|1;f[n+m>>2]=m;x=m}m=x>>>3;if(x>>>0<256){n=19176+(m<<1<<2)|0;a=f[4784]|0;b=1<>2]|0;z=b}f[z>>2]=l;f[y+12>>2]=l;f[l+8>>2]=y;f[l+12>>2]=n;return}n=x>>>8;if(n)if(x>>>0>16777215)A=31;else{y=(n+1048320|0)>>>16&8;z=n<>>16&4;b=z<>>16&2;a=14-(n|y|z)+(b<>>15)|0;A=x>>>(a+7|0)&1|a<<1}else A=0;a=19440+(A<<2)|0;f[l+28>>2]=A;f[l+20>>2]=0;f[l+16>>2]=0;z=f[4785]|0;b=1<>>1)|0);n=f[a>>2]|0;while(1){if((f[n+4>>2]&-8|0)==(x|0)){B=73;break}C=n+16+(y>>>31<<2)|0;m=f[C>>2]|0;if(!m){B=72;break}else{y=y<<1;n=m}}if((B|0)==72){f[C>>2]=l;f[l+24>>2]=n;f[l+12>>2]=l;f[l+8>>2]=l;break}else if((B|0)==73){y=n+8|0;t=f[y>>2]|0;f[t+12>>2]=l;f[y>>2]=l;f[l+8>>2]=t;f[l+12>>2]=n;f[l+24>>2]=0;break}}else{f[4785]=z|b;f[a>>2]=l;f[l+24>>2]=a;f[l+12>>2]=l;f[l+8>>2]=l}while(0);l=(f[4792]|0)+-1|0;f[4792]=l;if(!l)D=19592;else return;while(1){l=f[D>>2]|0;if(!l)break;else D=l+8|0}f[4792]=-1;return}function zc(a){a=a|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0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=z}else{f[g>>2]=f[z+4>>2];f[e>>2]=f[g>>2];Me(z,e,h,p)|0;x=f[l>>2]|0;t=x+16|0;B=f[t+4>>2]|0;C=f[t>>2]|0;D=x}b[h>>0]=f[s+(q*12|0)+8>>2];if(!((B|0)>0|(B|0)==0&C>>>0>0)){f[g>>2]=f[D+4>>2];f[e>>2]=f[g>>2];Me(D,e,h,n)|0}s=q+1|0;if(s>>>0>=j>>>0)break;q=s;r=f[i>>2]|0}u=c;return 1}if(a>>>0<65536){if(!k){u=c;return 1}r=h+2|0;q=h+2|0;n=h+2|0;D=0;C=m;while(1){B=f[C+96>>2]|0;p=f[l>>2]|0;d[h>>1]=f[B+(D*12|0)>>2];z=p+16|0;y=f[z>>2]|0;A=f[z+4>>2]|0;if((A|0)>0|(A|0)==0&y>>>0>0){E=A;F=y;G=p}else{f[g>>2]=f[p+4>>2];f[e>>2]=f[g>>2];Me(p,e,h,n)|0;p=f[l>>2]|0;y=p+16|0;E=f[y+4>>2]|0;F=f[y>>2]|0;G=p}d[h>>1]=f[B+(D*12|0)+4>>2];if((E|0)>0|(E|0)==0&F>>>0>0){H=E;I=F;J=G}else{f[g>>2]=f[G+4>>2];f[e>>2]=f[g>>2];Me(G,e,h,q)|0;p=f[l>>2]|0;y=p+16|0;H=f[y+4>>2]|0;I=f[y>>2]|0;J=p}d[h>>1]=f[B+(D*12|0)+8>>2];if(!((H|0)>0|(H|0)==0&I>>>0>0)){f[g>>2]=f[J+4>>2];f[e>>2]=f[g>>2];Me(J,e,h,r)|0}B=D+1|0;if(B>>>0>=j>>>0)break;D=B;C=f[i>>2]|0}u=c;return 1}C=(k|0)!=0;if(a>>>0<2097152){if(C){K=0;L=m}else{u=c;return 1}while(1){a=f[L+96>>2]|0;ci(f[a+(K*12|0)>>2]|0,f[l>>2]|0)|0;ci(f[a+(K*12|0)+4>>2]|0,f[l>>2]|0)|0;ci(f[a+(K*12|0)+8>>2]|0,f[l>>2]|0)|0;a=K+1|0;if(a>>>0>=j>>>0)break;K=a;L=f[i>>2]|0}u=c;return 1}if(!C){u=c;return 1}C=0;L=m;while(1){m=(f[L+96>>2]|0)+(C*12|0)|0;K=f[l>>2]|0;a=K+16|0;k=f[a+4>>2]|0;if(!((k|0)>0|(k|0)==0&(f[a>>2]|0)>>>0>0)){f[g>>2]=f[K+4>>2];f[e>>2]=f[g>>2];Me(K,e,m,m+12|0)|0}m=C+1|0;if(m>>>0>=j>>>0)break;C=m;L=f[i>>2]|0}u=c;return 1}function Ac(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=Oa,w=Oa,x=Oa,y=Oa,z=0,A=0,B=0,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=Oa,P=0,Q=Oa,R=Oa,S=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+28|0;o=f[c>>2]|0;c=o+1|0;if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;c=o+(((o>>>0)%3|0|0)==0?2:-1)|0;if((p|0)==-1)q=-1;else q=f[(f[f[m>>2]>>2]|0)+(p<<2)>>2]|0;if((c|0)==-1){r=-1;s=q}else{r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0;s=q}}else{r=-1;s=-1}q=f[a+32>>2]|0;c=f[q>>2]|0;m=(f[q+4>>2]|0)-c>>2;if(m>>>0<=s>>>0)aq(q);p=c;c=f[p+(s<<2)>>2]|0;if(m>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(c|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)t=c;else{if((e|0)>0){t=e+-1|0;break}p=a+52|0;if((f[p>>2]|0)<=0){u=g;return}m=f[a+48>>2]|0;s=0;do{f[m+(s<<2)>>2]=0;s=s+1|0}while((s|0)<(f[p>>2]|0));u=g;return}while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+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+48>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Bc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+28|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+32>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+52|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+48>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);r=a+52|0;p=f[r>>2]|0;m=X(p,s)|0;if((p|0)<=0){u=g;return}p=f[a+48>>2]|0;s=0;do{f[p+(s<<2)>>2]=f[d+(s+m<<2)>>2];s=s+1|0}while((s|0)<(f[r>>2]|0));u=g;return}r=a+52|0;s=f[r>>2]|0;m=X(s,o)|0;t=$(f[d+(m<<2)>>2]|0);v=$(f[d+(m+1<<2)>>2]|0);m=X(s,q)|0;w=$(f[d+(m<<2)>>2]|0);x=$(f[d+(m+1<<2)>>2]|0);if(!(w!=t|x!=v)){m=f[a+48>>2]|0;f[m>>2]=~~w;f[m+4>>2]=~~x;u=g;return}m=a+44|0;s=f[(f[m>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+40|0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))y=f[(f[c+68>>2]|0)+(s<<2)>>2]|0;else y=s;f[i>>2]=y;y=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,y,j)|0;y=f[(f[m>>2]|0)+(o<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;o=f[p>>2]|0;if(!(b[o+84>>0]|0))z=f[(f[o+68>>2]|0)+(y<<2)>>2]|0;else z=y;f[i>>2]=z;z=b[o+24>>0]|0;f[h>>2]=f[i>>2];mb(o,h,z,k)|0;z=f[(f[m>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))A=f[(f[q+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,A,l)|0;B=$(n[l>>2]);C=$(n[k>>2]);D=$(B-C);B=$(n[l+4>>2]);E=$(n[k+4>>2]);F=$(B-E);B=$(n[l+8>>2]);G=$(n[k+8>>2]);H=$(B-G);B=$($(n[j>>2])-C);C=$($(n[j+4>>2])-E);E=$($(n[j+8>>2])-G);G=$($($($(D*D)+$(0.0))+$(F*F))+$(H*H));if(G>$(0.0)){I=$($($($($(D*B)+$(0.0))+$(F*C))+$(H*E))/G);K=$(B-$(D*I));D=$(C-$(F*I));F=$(E-$(H*I));M=I;N=$(L($($($(F*F)+$($(D*D)+$($(K*K)+$(0.0))))/G)))}else{M=$(0.0);N=$(0.0)}G=$(w-t);w=$(x-v);x=$($(G*M)+t);t=$(G*N);G=$($(w*M)+v);v=$(w*N);N=$(x-v);w=$(G+t);M=$(x+v);v=$(G-t);j=X(f[r>>2]|0,e)|0;t=$(f[d+(j<<2)>>2]|0);G=$(f[d+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+48>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Cc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=Oa,w=Oa,x=Oa,y=Oa,z=0,A=0,B=0,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=Oa,P=0,Q=Oa,R=Oa,S=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;c=o+(((o>>>0)%3|0|0)==0?2:-1)|0;if((p|0)==-1)q=-1;else q=f[(f[f[m>>2]>>2]|0)+(p<<2)>>2]|0;if((c|0)==-1){r=-1;s=q}else{r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0;s=q}}else{r=-1;s=-1}q=f[a+52>>2]|0;c=f[q>>2]|0;m=(f[q+4>>2]|0)-c>>2;if(m>>>0<=s>>>0)aq(q);p=c;c=f[p+(s<<2)>>2]|0;if(m>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(c|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)t=c;else{if((e|0)>0){t=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}m=f[a+68>>2]|0;s=0;do{f[m+(s<<2)>>2]=0;s=s+1|0}while((s|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;s=X(p,t)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;t=0;do{f[p+(t<<2)>>2]=f[d+(t+s<<2)>>2];t=t+1|0}while((t|0)<(f[r>>2]|0));u=g;return}r=a+72|0;t=f[r>>2]|0;s=X(t,c)|0;v=$(f[d+(s<<2)>>2]|0);w=$(f[d+(s+1<<2)>>2]|0);s=X(t,q)|0;x=$(f[d+(s<<2)>>2]|0);y=$(f[d+(s+1<<2)>>2]|0);if(!(x!=v|y!=w)){s=f[a+68>>2]|0;f[s>>2]=~~x;f[s+4>>2]=~~y;u=g;return}s=a+64|0;t=f[(f[s>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+60|0;m=f[p>>2]|0;if(!(b[m+84>>0]|0))z=f[(f[m+68>>2]|0)+(t<<2)>>2]|0;else z=t;f[i>>2]=z;z=b[m+24>>0]|0;f[h>>2]=f[i>>2];mb(m,h,z,j)|0;z=f[(f[s>>2]|0)+(c<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))A=f[(f[c+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,A,k)|0;A=f[(f[s>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))B=f[(f[q+68>>2]|0)+(A<<2)>>2]|0;else B=A;f[i>>2]=B;B=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,B,l)|0;C=$(n[l>>2]);D=$(n[k>>2]);E=$(C-D);C=$(n[l+4>>2]);F=$(n[k+4>>2]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+68>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Dc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+52>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+68>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;m=X(p,s)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;s=0;do{f[p+(s<<2)>>2]=f[d+(s+m<<2)>>2];s=s+1|0}while((s|0)<(f[r>>2]|0));u=g;return}r=a+72|0;s=f[r>>2]|0;m=X(s,o)|0;t=$(f[d+(m<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(0.0);N=$(0.0)}G=$(w-t);w=$(x-v);x=$($(G*M)+t);t=$(G*N);G=$($(w*M)+v);v=$(w*N);N=$(x-v);w=$(G+t);M=$(x+v);v=$(G-t);j=X(f[r>>2]|0,e)|0;t=$(f[d+(j<<2)>>2]|0);G=$(f[d+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+68>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Ec(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=Oa,F=Oa,G=Oa,H=0,I=0,J=0,K=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;e=i;j=i;while(1){k=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;e=(X(k>>>24^k,1540483477)|0)^(X(e,1540483477)|0);j=j+-4|0;if(j>>>0<=3)break;else d=d+4|0}d=i+-4|0;j=d&-4;l=d-j|0;m=g+(j+4)|0;o=e}else{l=i;m=g;o=i}switch(l|0){case 3:{p=h[m+2>>0]<<16^o;q=6;break}case 2:{p=o;q=6;break}case 1:{r=o;q=7;break}default:s=o}if((q|0)==6){r=h[m+1>>0]<<8^p;q=7}if((q|0)==7)s=X(r^h[m>>0],1540483477)|0;m=X(s>>>13^s,1540483477)|0;s=m>>>15^m;m=a+4|0;r=f[m>>2]|0;p=(r|0)==0;a:do if(!p){o=r+-1|0;l=(o&r|0)==0;if(!l)if(s>>>0>>0)t=s;else t=(s>>>0)%(r>>>0)|0;else t=s&o;e=f[(f[a>>2]|0)+(t<<2)>>2]|0;if((e|0)!=0?(j=f[e>>2]|0,(j|0)!=0):0){e=(i|0)==0;if(l){if(e){l=j;while(1){d=f[l+4>>2]|0;if(!((d|0)==(s|0)|(d&o|0)==(t|0))){u=t;break a}d=b[l+8+11>>0]|0;if(!((d<<24>>24<0?f[l+12>>2]|0:d&255)|0)){v=l;break}l=f[l>>2]|0;if(!l){u=t;break a}}w=v+20|0;return w|0}else x=j;b:while(1){l=f[x+4>>2]|0;if(!((l|0)==(s|0)|(l&o|0)==(t|0))){u=t;break a}l=x+8|0;d=b[l+11>>0]|0;k=d<<24>>24<0;y=d&255;do if(((k?f[x+12>>2]|0:y)|0)==(i|0)){d=f[l>>2]|0;if(k)if(!(Vk(d,g,i)|0)){v=x;q=63;break b}else break;if((b[g>>0]|0)==(d&255)<<24>>24){d=l;z=y;A=g;do{z=z+-1|0;d=d+1|0;if(!z){v=x;q=63;break b}A=A+1|0}while((b[d>>0]|0)==(b[A>>0]|0))}}while(0);x=f[x>>2]|0;if(!x){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}if(e){o=j;while(1){y=f[o+4>>2]|0;if((y|0)!=(s|0)){if(y>>>0>>0)B=y;else B=(y>>>0)%(r>>>0)|0;if((B|0)!=(t|0)){u=t;break a}}y=b[o+8+11>>0]|0;if(!((y<<24>>24<0?f[o+12>>2]|0:y&255)|0)){v=o;break}o=f[o>>2]|0;if(!o){u=t;break a}}w=v+20|0;return w|0}else C=j;c:while(1){o=f[C+4>>2]|0;if((o|0)!=(s|0)){if(o>>>0>>0)D=o;else D=(o>>>0)%(r>>>0)|0;if((D|0)!=(t|0)){u=t;break a}}o=C+8|0;e=b[o+11>>0]|0;y=e<<24>>24<0;l=e&255;do if(((y?f[C+12>>2]|0:l)|0)==(i|0)){e=f[o>>2]|0;if(y)if(!(Vk(e,g,i)|0)){v=C;q=63;break c}else break;if((b[g>>0]|0)==(e&255)<<24>>24){e=o;k=l;A=g;do{k=k+-1|0;e=e+1|0;if(!k){v=C;q=63;break c}A=A+1|0}while((b[e>>0]|0)==(b[A>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}else u=t}else u=0;while(0);t=ln(24)|0;pj(t+8|0,c);f[t+20>>2]=0;f[t+4>>2]=s;f[t>>2]=0;c=a+12|0;E=$(((f[c>>2]|0)+1|0)>>>0);F=$(r>>>0);G=$(n[a+16>>2]);do if(p|$(G*F)>>0<3|(r+-1&r|0)!=0)&1;g=~~$(W($(E/G)))>>>0;ei(a,C>>>0>>0?g:C);C=f[m>>2]|0;g=C+-1|0;if(!(g&C)){H=C;I=g&s;break}if(s>>>0>>0){H=C;I=s}else{H=C;I=(s>>>0)%(C>>>0)|0}}else{H=r;I=u}while(0);u=(f[a>>2]|0)+(I<<2)|0;I=f[u>>2]|0;if(!I){r=a+8|0;f[t>>2]=f[r>>2];f[r>>2]=t;f[u>>2]=r;r=f[t>>2]|0;if(r|0){u=f[r+4>>2]|0;r=H+-1|0;if(r&H)if(u>>>0>>0)J=u;else J=(u>>>0)%(H>>>0)|0;else J=u&r;K=(f[a>>2]|0)+(J<<2)|0;q=61}}else{f[t>>2]=f[I>>2];K=I;q=61}if((q|0)==61)f[K>>2]=t;f[c>>2]=(f[c>>2]|0)+1;v=t;w=v+20|0;return w|0}function Fc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0,H=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0.0,R=0.0,S=0,T=0.0,U=0,V=0,W=0,X=0.0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0.0,da=0,ea=0.0;g=a+4|0;i=f[g>>2]|0;j=a+100|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=0}else{k=Si(a)|0;l=0}a:while(1){switch(k|0){case 46:{m=8;break a;break}case 48:break;default:{n=0;o=0;p=1.0;q=0.0;r=0;s=k;t=l;u=0;v=0;w=0;x=0;break a}}i=f[g>>2]|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=1;continue}else{k=Si(a)|0;l=1;continue}}if((m|0)==8){k=f[g>>2]|0;if(k>>>0<(f[j>>2]|0)>>>0){f[g>>2]=k+1;y=h[k>>0]|0}else y=Si(a)|0;if((y|0)==48){k=0;i=0;while(1){z=f[g>>2]|0;if(z>>>0<(f[j>>2]|0)>>>0){f[g>>2]=z+1;A=h[z>>0]|0}else A=Si(a)|0;z=Vn(k|0,i|0,-1,-1)|0;B=I;if((A|0)==48){k=z;i=B}else{n=1;o=0;p=1.0;q=0.0;r=0;s=A;t=1;u=0;v=0;w=z;x=B;break}}}else{n=1;o=0;p=1.0;q=0.0;r=0;s=y;t=l;u=0;v=0;w=0;x=0}}while(1){l=s+-48|0;y=s|32;if(l>>>0>=10){A=(s|0)==46;if(!(A|(y+-97|0)>>>0<6)){C=s;break}if(A)if(!n){D=1;E=o;F=p;G=q;H=r;J=t;K=v;L=u;M=v;N=u}else{C=46;break}else m=20}else m=20;if((m|0)==20){m=0;A=(s|0)>57?y+-87|0:l;do if(!((u|0)<0|(u|0)==0&v>>>0<8))if((u|0)<0|(u|0)==0&v>>>0<14){O=p*.0625;P=o;Q=O;R=q+O*+(A|0);S=r;break}else{l=(o|0)!=0|(A|0)==0;P=l?o:1;Q=p;R=l?q:q+p*.5;S=r;break}else{P=o;Q=p;R=q;S=A+(r<<4)|0}while(0);A=Vn(v|0,u|0,1,0)|0;D=n;E=P;F=Q;G=R;H=S;J=1;K=w;L=x;M=A;N=I}A=f[g>>2]|0;if(A>>>0<(f[j>>2]|0)>>>0){f[g>>2]=A+1;n=D;o=E;p=F;q=G;r=H;s=h[A>>0]|0;t=J;u=N;v=M;w=K;x=L;continue}else{n=D;o=E;p=F;q=G;r=H;s=Si(a)|0;t=J;u=N;v=M;w=K;x=L;continue}}do if(!t){L=(f[j>>2]|0)==0;if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(e){if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(!((n|0)==0|L))f[g>>2]=(f[g>>2]|0)+-1}else Ym(a,0);T=+(d|0)*0.0}else{L=(n|0)==0;K=L?v:w;M=L?u:x;if((u|0)<0|(u|0)==0&v>>>0<8){L=r;N=v;J=u;while(1){s=L<<4;H=N;N=Vn(N|0,J|0,1,0)|0;if(!((J|0)<0|(J|0)==0&H>>>0<7)){U=s;break}else{L=s;J=I}}}else U=r;if((C|32|0)==112){J=Re(a,e)|0;L=I;if((J|0)==0&(L|0)==-2147483648){if(!e){Ym(a,0);T=0.0;break}if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}}else{V=J;W=L}}else if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}L=Tn(K|0,M|0,2)|0;J=Vn(L|0,I|0,-32,-1)|0;L=Vn(J|0,I|0,V|0,W|0)|0;J=I;if(!U){T=+(d|0)*0.0;break}N=0-c|0;s=((N|0)<0)<<31>>31;if((J|0)>(s|0)|(J|0)==(s|0)&L>>>0>N>>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}N=c+-106|0;s=((N|0)<0)<<31>>31;if((J|0)<(s|0)|(J|0)==(s|0)&L>>>0>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if((U|0)>-1){G=q;N=U;s=L;H=J;while(1){E=!(G>=.5);o=N<<1|(E^1)&1;F=G+(E?G:G+-1.0);E=Vn(s|0,H|0,-1,-1)|0;D=I;if((o|0)>-1){G=F;N=o;s=E;H=D}else{X=F;Y=o;Z=E;_=D;break}}}else{X=q;Y=U;Z=L;_=J}H=((b|0)<0)<<31>>31;s=Xn(32,0,c|0,((c|0)<0)<<31>>31|0)|0;N=Vn(s|0,I|0,Z|0,_|0)|0;s=I;if((s|0)<(H|0)|(s|0)==(H|0)&N>>>0>>0)if((N|0)>0){$=N;m=59}else{aa=0;ba=84;m=61}else{$=b;m=59}if((m|0)==59)if(($|0)<53){aa=$;ba=84-$|0;m=61}else{ca=0.0;da=$;ea=+(d|0)}if((m|0)==61){G=+(d|0);ca=+rq(+bk(1.0,ba),G);da=aa;ea=G}N=(Y&1|0)==0&(X!=0.0&(da|0)<32);G=(N?0.0:X)*ea+(ca+ea*+((Y+(N&1)|0)>>>0))-ca;if(!(G!=0.0)){N=Vq()|0;f[N>>2]=34}T=+sq(G,Z)}while(0);return +T}function Gc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;g=u;u=u+16|0;h=g+4|0;i=g;if(!(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2]|0;if((f[D+(A<<2)>>2]|0)==(f[D+(C<<2)>>2]|0)){E=t+1|0;if(z)F=-1;else F=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){G=y+2|0;break}else{G=y+-1|0;break}else G=-1;while(0);if((F|0)==-1)H=-1;else H=f[(f[o>>2]|0)+(((F|0)/3|0)*12|0)+(((F|0)%3|0)<<2)>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[o>>2]|0)+(((G|0)/3|0)*12|0)+(((G|0)%3|0)<<2)>>2]|0;if((f[D+(H<<2)>>2]|0)==(f[D+(I<<2)>>2]|0))break}}else{if(z)J=-1;else J=f[(f[o>>2]|0)+(((t|0)/3|0)*12|0)+(((t|0)%3|0)<<2)>>2]|0;B=(y|0)==-1;if(B)K=-1;else K=f[(f[o>>2]|0)+(((y|0)/3|0)*12|0)+(((y|0)%3|0)<<2)>>2]|0;if((J|0)==(K|0)){E=t+1|0;if(z)L=-1;else L=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){M=y+2|0;break}else{M=y+-1|0;break}else M=-1;while(0);if((L|0)==-1)N=-1;else N=f[(f[o>>2]|0)+(((L|0)/3|0)*12|0)+(((L|0)%3|0)<<2)>>2]|0;if((M|0)==-1)O=-1;else O=f[(f[o>>2]|0)+(((M|0)/3|0)*12|0)+(((M|0)%3|0)<<2)>>2]|0;if((N|0)==(O|0))break}}b[p>>0]=0;y=f[a>>2]|0;B=y+(q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(q&31);B=y+(s>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(s&31);B=((v>>>0)%3|0|0)==0?q+-2|0:v;if((B|0)==-1)P=-1;else P=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(P>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(P&31);B=(((q>>>0)%3|0|0)==0?2:-1)+q|0;if((B|0)==-1)Q=-1;else Q=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(Q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(Q&31);B=s+1|0;y=((B>>>0)%3|0|0)==0?s+-2|0:B;if((y|0)==-1)R=-1;else R=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(R>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(R&31);y=(((s>>>0)%3|0|0)==0?2:-1)+s|0;if((y|0)==-1)S=-1;else S=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(S>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(S&31)}}while(0);q=q+1|0}while(q>>>0<(f[r+4>>2]|0)-(f[r>>2]|0)>>2>>>0)}if((c|0)!=0&(e|0)!=0){Qc(a,c,e);j=1;u=g;return j|0}else{md(a,0,0);j=1;u=g;return j|0}return 0}function Hc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;d=u;u=u+32|0;e=d+12|0;g=d+8|0;h=d+4|0;i=d;j=a+8|0;a:do if(f[j>>2]|0?(k=f[a>>2]|0,l=a+4|0,f[a>>2]=l,f[(f[l>>2]|0)+8>>2]=0,f[l>>2]=0,f[j>>2]=0,m=f[k+4>>2]|0,n=(m|0)==0?k:m,n|0):0){m=a+4|0;k=n;n=f[b>>2]|0;while(1){if((n|0)==(f[c>>2]|0))break;o=k+16|0;f[o>>2]=f[n+16>>2];if((k|0)!=(n|0)){f[h>>2]=f[n+20>>2];f[i>>2]=n+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k+20|0,g,e)}p=k+8|0;q=f[p>>2]|0;do if(q){r=f[q>>2]|0;if((r|0)==(k|0)){f[q>>2]=0;s=f[q+4>>2]|0;if(!s){t=q;break}else v=s;while(1){s=f[v>>2]|0;if(s|0){v=s;continue}s=f[v+4>>2]|0;if(!s)break;else v=s}t=v;break}else{f[q+4>>2]=0;if(!r){t=q;break}else w=r;while(1){s=f[w>>2]|0;if(s|0){w=s;continue}s=f[w+4>>2]|0;if(!s)break;else w=s}t=w;break}}else t=0;while(0);q=f[l>>2]|0;do if(q){r=f[o>>2]|0;s=q;while(1){if((r|0)<(f[s+16>>2]|0)){x=f[s>>2]|0;if(!x){y=22;break}else z=x}else{A=s+4|0;x=f[A>>2]|0;if(!x){y=25;break}else z=x}s=z}if((y|0)==22){y=0;B=s;C=s;break}else if((y|0)==25){y=0;B=s;C=A;break}}else{B=l;C=l}while(0);f[k>>2]=0;f[k+4>>2]=0;f[p>>2]=B;f[C>>2]=k;q=f[f[a>>2]>>2]|0;if(!q)D=k;else{f[a>>2]=q;D=f[C>>2]|0}Oe(f[m>>2]|0,D);f[j>>2]=(f[j>>2]|0)+1;q=f[n+4>>2]|0;if(!q){o=n+8|0;r=f[o>>2]|0;if((f[r>>2]|0)==(n|0))E=r;else{r=o;do{o=f[r>>2]|0;r=o+8|0;x=f[r>>2]|0}while((f[x>>2]|0)!=(o|0));E=x}}else{r=q;while(1){p=f[r>>2]|0;if(!p)break;else r=p}E=r}f[b>>2]=E;if(!t)break a;else{k=t;n=E}}n=f[k+8>>2]|0;if(!n)F=k;else{m=n;while(1){n=f[m+8>>2]|0;if(!n)break;else m=n}F=m}Oj(a,F)}while(0);F=f[b>>2]|0;E=f[c>>2]|0;if((F|0)==(E|0)){u=d;return}c=a+4|0;t=a+4|0;D=F;while(1){Kg(e,a,D+16|0);F=f[c>>2]|0;do if(F){C=f[e>>2]|0;B=f[C+16>>2]|0;A=F;while(1){if((B|0)<(f[A+16>>2]|0)){z=f[A>>2]|0;if(!z){y=43;break}else G=z}else{H=A+4|0;z=f[H>>2]|0;if(!z){y=46;break}else G=z}A=G}if((y|0)==43){y=0;I=A;J=A;K=C;break}else if((y|0)==46){y=0;I=A;J=H;K=C;break}}else{I=c;J=c;K=f[e>>2]|0}while(0);f[K>>2]=0;f[K+4>>2]=0;f[K+8>>2]=I;f[J>>2]=K;F=f[f[a>>2]>>2]|0;if(!F)L=K;else{f[a>>2]=F;L=f[J>>2]|0}Oe(f[t>>2]|0,L);f[j>>2]=(f[j>>2]|0)+1;F=f[D+4>>2]|0;if(!F){m=D+8|0;B=f[m>>2]|0;if((f[B>>2]|0)==(D|0))M=B;else{B=m;do{m=f[B>>2]|0;B=m+8|0;r=f[B>>2]|0}while((f[r>>2]|0)!=(m|0));M=r}}else{B=F;while(1){r=f[B>>2]|0;if(!r)break;else B=r}M=B}f[b>>2]=M;if((M|0)==(E|0))break;else D=M}u=d;return}function Ic(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;g=u;u=u+32|0;d=g+16|0;h=g+8|0;i=g;j=f[a+28>>2]|0;k=f[a+32>>2]|0;l=e>>>0>1073741823?-1:e<<2;m=Lq(l)|0;sj(m|0,0,l|0)|0;n=Lq(l)|0;sj(n|0,0,l|0)|0;l=a+36|0;o=f[l>>2]|0;p=f[o+4>>2]|0;q=f[o>>2]|0;r=p-q|0;a:do if((r|0)>4){s=r>>2;t=(e|0)>0;v=a+8|0;w=h+4|0;x=i+4|0;y=d+4|0;z=m+4|0;A=h+4|0;B=i+4|0;C=d+4|0;D=j+12|0;E=e<<2;F=s+-1|0;if(p-q>>2>>>0>F>>>0){G=s;H=F;I=q}else{J=o;aq(J)}while(1){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?J:H;K=I}C=C+1|0}while((C|0)<(f[g>>2]|0));L=K}else L=f[o>>2]|0;C=(f[D+(E<<2)>>2]|0)-(f[L+(E<<2)>>2]|0)|0;I=B+(E<<2)|0;f[I>>2]=C;if((C|0)>=(f[q>>2]|0)){if((C|0)>(f[s>>2]|0)){M=C-(f[r>>2]|0)|0;N=42}}else{M=(f[r>>2]|0)+C|0;N=42}if((N|0)==42){N=0;f[I>>2]=M}E=E+1|0;A=f[g>>2]|0;if((E|0)>=(A|0))break;else y=L}}}else N=16}else N=16;if((N|0)==16?(N=0,y=b+(z<<2)|0,A=c+(z<<2)|0,E=f[g>>2]|0,(E|0)>0):0){B=0;D=b+((X(x+-2|0,e)|0)<<2)|0;I=E;while(1){if((I|0)>0){E=0;do{C=f[D+(E<<2)>>2]|0;H=f[n>>2]|0;if((C|0)>(H|0)){J=f[o>>2]|0;f[J+(E<<2)>>2]=H;O=J}else{J=f[p>>2]|0;H=f[o>>2]|0;f[H+(E<<2)>>2]=(C|0)<(J|0)?J:C;O=H}E=E+1|0}while((E|0)<(f[g>>2]|0));P=O}else P=f[o>>2]|0;E=(f[y+(B<<2)>>2]|0)-(f[P+(B<<2)>>2]|0)|0;H=A+(B<<2)|0;f[H>>2]=E;if((E|0)>=(f[q>>2]|0)){if((E|0)>(f[s>>2]|0)){Q=E-(f[r>>2]|0)|0;N=29}}else{Q=(f[r>>2]|0)+E|0;N=29}if((N|0)==29){N=0;f[H>>2]=Q}B=B+1|0;I=f[g>>2]|0;if((B|0)>=(I|0))break;else D=P}}if((x|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;P=a+32|0;Q=a+12|0;O=a+28|0;L=a+20|0;M=a+24|0;a=0;K=h;G=e;while(1){if((G|0)>0){e=0;do{F=f[K+(e<<2)>>2]|0;d=f[i>>2]|0;if((F|0)>(d|0)){l=f[P>>2]|0;f[l+(e<<2)>>2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)?I:G;J=H}D=D+1|0}while((D|0)<(f[g>>2]|0));K=J}else K=f[o>>2]|0;D=(f[E+(F<<2)>>2]|0)-(f[K+(F<<2)>>2]|0)|0;H=B+(F<<2)|0;f[H>>2]=D;if((D|0)>=(f[q>>2]|0)){if((D|0)>(f[s>>2]|0)){L=D-(f[r>>2]|0)|0;M=39}}else{L=(f[r>>2]|0)+D|0;M=39}if((M|0)==39){M=0;f[H>>2]=L}F=F+1|0;C=f[g>>2]|0;if((F|0)>=(C|0))break;else z=K}}}else M=13;if((M|0)==13?(M=0,z=b+(A<<2)|0,C=c+(A<<2)|0,F=f[g>>2]|0,(F|0)>0):0){B=0;E=b+((X(y+-2|0,e)|0)<<2)|0;H=F;while(1){if((H|0)>0){F=0;do{D=f[E+(F<<2)>>2]|0;G=f[n>>2]|0;if((D|0)>(G|0)){I=f[o>>2]|0;f[I+(F<<2)>>2]=G;N=I}else{I=f[p>>2]|0;G=f[o>>2]|0;f[G+(F<<2)>>2]=(D|0)<(I|0)?I:D;N=G}F=F+1|0}while((F|0)<(f[g>>2]|0));O=N}else O=f[o>>2]|0;F=(f[z+(B<<2)>>2]|0)-(f[O+(B<<2)>>2]|0)|0;G=C+(B<<2)|0;f[G>>2]=F;if((F|0)>=(f[q>>2]|0)){if((F|0)>(f[s>>2]|0)){P=F-(f[r>>2]|0)|0;M=26}}else{P=(f[r>>2]|0)+F|0;M=26}if((M|0)==26){M=0;f[G>>2]=P}B=B+1|0;H=f[g>>2]|0;if((B|0)>=(H|0))break;else E=O}}if((y|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;O=a+32|0;P=a+12|0;N=a+28|0;K=a+20|0;L=a+24|0;a=0;J=h;d=e;while(1){if((d|0)>0){e=0;do{l=f[J+(e<<2)>>2]|0;j=f[i>>2]|0;if((l|0)>(j|0)){k=f[O>>2]|0;f[k+(e<<2)>>2]=j;Q=k}else{k=f[P>>2]|0;j=f[O>>2]|0;f[j+(e<<2)>>2]=(l|0)<(k|0)?k:l;Q=j}e=e+1|0}while((e|0)<(f[g>>2]|0));R=Q}else R=f[O>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[R+(a<<2)>>2]|0)|0;j=c+(a<<2)|0;f[j>>2]=e;if((e|0)>=(f[N>>2]|0)){if((e|0)>(f[L>>2]|0)){S=e-(f[K>>2]|0)|0;M=53}}else{S=(f[K>>2]|0)+e|0;M=53}if((M|0)==53){M=0;f[j>>2]=S}a=a+1|0;d=f[g>>2]|0;if((a|0)>=(d|0))break;else J=R}Mq(h);return 1}function Mc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0;h=u;u=u+48|0;i=h+28|0;j=h+24|0;k=h;l=h+12|0;m=h+40|0;if((c|0)<0){n=0;u=h;return n|0}if(!c){n=1;u=h;return n|0}o=(d|0)>1;p=o?d:1;f[k>>2]=0;d=k+4|0;f[d>>2]=0;f[k+8>>2]=0;gk(k,c);q=k+8|0;if(o){o=0;r=0;while(1){s=1;t=f[a+(r<<2)>>2]|0;do{v=f[a+(s+r<<2)>>2]|0;t=t>>>0>>0?v:t;s=s+1|0}while((s|0)!=(p|0));s=(_(t|0)|0)^31;v=t>>>0>o>>>0?t:o;w=(t|0)==0?1:s+1|0;f[i>>2]=w;s=f[d>>2]|0;if(s>>>0<(f[q>>2]|0)>>>0){f[s>>2]=w;f[d>>2]=s+4}else Ri(k,i);r=r+p|0;if((r|0)>=(c|0)){x=v;break}else o=v}}else{o=0;r=0;while(1){v=f[a+(o<<2)>>2]|0;s=(_(v|0)|0)^31;w=v>>>0>r>>>0?v:r;y=(v|0)==0?1:s+1|0;f[i>>2]=y;s=f[d>>2]|0;if(s>>>0<(f[q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0]=0;w=(Jh(e,i)|0)==0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if(!w){f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;w=ln(32)|0;f[i>>2]=w;f[i+8>>2]=-2147483616;f[i+4>>2]=22;F=w;B=15964;o=F+22|0;do{b[F>>0]=b[B>>0]|0;F=F+1|0;B=B+1|0}while((F|0)<(o|0));b[w+22>>0]=0;w=Mk(e,i)|0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);H=w}else G=32}else G=32;if((G|0)==32)H=z>>>0<18&((A|0)>(r|0)|(A|0)==(r|0)&v>>>0>=C>>>0)&1;b[m>>0]=H;C=g+16|0;v=f[C+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[C>>2]|0)>>>0>0)){f[j>>2]=f[g+4>>2];f[i>>2]=f[j>>2];Me(g,i,m,m+1|0)|0}switch(H|0){case 0:{J=td(a,c,p,k,g)|0;break}case 1:{J=Tc(a,c,x,l,e,g)|0;break}default:J=0}g=f[k>>2]|0;if(g|0){k=f[d>>2]|0;if((k|0)!=(g|0))f[d>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(g)}n=J;u=h;return n|0}function Nc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;if((b|0)<0)return;c=a+12|0;d=f[c>>2]|0;e=f[a+8>>2]|0;g=e;h=d;if(d-e>>2>>>0<=b>>>0)return;e=g+(b<<2)|0;d=f[(f[e>>2]|0)+56>>2]|0;i=f[(f[g+(b<<2)>>2]|0)+60>>2]|0;g=e+4|0;if((g|0)!=(h|0)){j=g;g=e;do{k=f[j>>2]|0;f[j>>2]=0;l=f[g>>2]|0;f[g>>2]=k;if(l|0){k=l+88|0;m=f[k>>2]|0;f[k>>2]=0;if(m|0){k=f[m+8>>2]|0;if(k|0){n=m+12|0;if((f[n>>2]|0)!=(k|0))f[n>>2]=k;Oq(k)}Oq(m)}m=f[l+68>>2]|0;if(m|0){k=l+72|0;n=f[k>>2]|0;if((n|0)!=(m|0))f[k>>2]=n+(~((n+-4-m|0)>>>2)<<2);Oq(m)}m=l+64|0;n=f[m>>2]|0;f[m>>2]=0;if(n|0){m=f[n>>2]|0;if(m|0){k=n+4|0;if((f[k>>2]|0)!=(m|0))f[k>>2]=m;Oq(m)}Oq(n)}Oq(l)}j=j+4|0;g=g+4|0}while((j|0)!=(h|0));j=f[c>>2]|0;if((j|0)!=(g|0)){o=g;p=j;q=24}}else{o=e;p=h;q=24}if((q|0)==24){q=p;do{p=q+-4|0;f[c>>2]=p;h=f[p>>2]|0;f[p>>2]=0;if(h|0){p=h+88|0;e=f[p>>2]|0;f[p>>2]=0;if(e|0){p=f[e+8>>2]|0;if(p|0){j=e+12|0;if((f[j>>2]|0)!=(p|0))f[j>>2]=p;Oq(p)}Oq(e)}e=f[h+68>>2]|0;if(e|0){p=h+72|0;j=f[p>>2]|0;if((j|0)!=(e|0))f[p>>2]=j+(~((j+-4-e|0)>>>2)<<2);Oq(e)}e=h+64|0;j=f[e>>2]|0;f[e>>2]=0;if(j|0){e=f[j>>2]|0;if(e|0){p=j+4|0;if((f[p>>2]|0)!=(e|0))f[p>>2]=e;Oq(e)}Oq(j)}Oq(h)}q=f[c>>2]|0}while((q|0)!=(o|0))}o=f[a+4>>2]|0;a:do if(o|0){q=o+44|0;c=f[q>>2]|0;h=f[o+40>>2]|0;while(1){if((h|0)==(c|0))break a;r=h+4|0;if((f[(f[h>>2]|0)+40>>2]|0)==(i|0))break;else h=r}if((r|0)!=(c|0)){j=r;e=h;do{p=f[j>>2]|0;f[j>>2]=0;g=f[e>>2]|0;f[e>>2]=p;if(g|0){bj(g);Oq(g)}j=j+4|0;e=e+4|0}while((j|0)!=(c|0));j=f[q>>2]|0;if((j|0)==(e|0))break;else{s=e;t=j}}else{s=h;t=c}j=t;do{g=j+-4|0;f[q>>2]=g;p=f[g>>2]|0;f[g>>2]=0;if(p|0){bj(p);Oq(p)}j=f[q>>2]|0}while((j|0)!=(s|0))}while(0);b:do if((d|0)<5){s=f[a+20+(d*12|0)>>2]|0;t=a+20+(d*12|0)+4|0;r=f[t>>2]|0;i=r;c:do if((s|0)==(r|0))u=s;else{o=s;while(1){if((f[o>>2]|0)==(b|0)){u=o;break c}o=o+4|0;if((o|0)==(r|0))break b}}while(0);if((u|0)!=(r|0)){s=u+4|0;o=i-s|0;j=o>>2;if(!j)v=r;else{im(u|0,s|0,o|0)|0;v=f[t>>2]|0}o=u+(j<<2)|0;if((v|0)!=(o|0))f[t>>2]=v+(~((v+-4-o|0)>>>2)<<2)}}while(0);v=f[a+24>>2]|0;u=f[a+20>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+36>>2]|0;u=f[a+32>>2]|0;d=u;if((o|0)!=(u|0)){j=o-u>>2;u=0;do{o=d+(u<<2)|0;v=f[o>>2]|0;if((v|0)>(b|0))f[o>>2]=v+-1;u=u+1|0}while(u>>>0>>0)}j=f[a+48>>2]|0;u=f[a+44>>2]|0;d=u;if((j|0)!=(u|0)){v=j-u>>2;u=0;do{j=d+(u<<2)|0;o=f[j>>2]|0;if((o|0)>(b|0))f[j>>2]=o+-1;u=u+1|0}while(u>>>0>>0)}v=f[a+60>>2]|0;u=f[a+56>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+72>>2]|0;u=f[a+68>>2]|0;a=u;if((o|0)==(u|0))return;d=o-u>>2;u=0;do{o=a+(u<<2)|0;j=f[o>>2]|0;if((j|0)>(b|0))f[o>>2]=j+-1;u=u+1|0}while(u>>>0>>0);return}function Oc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;e=a+8|0;a:do if(f[e>>2]|0?(g=f[a>>2]|0,h=a+4|0,f[a>>2]=h,f[(f[h>>2]|0)+8>>2]=0,f[h>>2]=0,f[e>>2]=0,i=f[g+4>>2]|0,j=(i|0)==0?g:i,j|0):0){i=a+4|0;g=j;j=f[c>>2]|0;while(1){if((j|0)==(f[d>>2]|0))break;k=g+16|0;am(k,j+16|0)|0;am(g+28|0,j+28|0)|0;l=g+8|0;m=f[l>>2]|0;do if(m){n=f[m>>2]|0;if((n|0)==(g|0)){f[m>>2]=0;o=f[m+4>>2]|0;if(!o){p=m;break}else q=o;while(1){o=f[q>>2]|0;if(o|0){q=o;continue}o=f[q+4>>2]|0;if(!o)break;else q=o}p=q;break}else{f[m+4>>2]=0;if(!n){p=m;break}else r=n;while(1){o=f[r>>2]|0;if(o|0){r=o;continue}o=f[r+4>>2]|0;if(!o)break;else r=o}p=r;break}}else p=0;while(0);m=f[h>>2]|0;do if(m){n=b[k+11>>0]|0;o=n<<24>>24<0;s=o?f[g+20>>2]|0:n&255;n=o?f[k>>2]|0:k;o=m;while(1){t=o+16|0;u=b[t+11>>0]|0;v=u<<24>>24<0;w=v?f[o+20>>2]|0:u&255;u=w>>>0>>0?w:s;if((u|0)!=0?(x=Vk(n,v?f[t>>2]|0:t,u)|0,(x|0)!=0):0)if((x|0)<0)y=22;else y=24;else if(s>>>0>>0)y=22;else y=24;if((y|0)==22){y=0;w=f[o>>2]|0;if(!w){y=23;break}else z=w}else if((y|0)==24){y=0;A=o+4|0;w=f[A>>2]|0;if(!w){y=26;break}else z=w}o=z}if((y|0)==23){y=0;B=o;C=o;break}else if((y|0)==26){y=0;B=A;C=o;break}}else{B=h;C=h}while(0);f[g>>2]=0;f[g+4>>2]=0;f[l>>2]=C;f[B>>2]=g;m=f[f[a>>2]>>2]|0;if(!m)D=g;else{f[a>>2]=m;D=f[B>>2]|0}Oe(f[i>>2]|0,D);f[e>>2]=(f[e>>2]|0)+1;m=f[j+4>>2]|0;if(!m){k=j+8|0;s=f[k>>2]|0;if((f[s>>2]|0)==(j|0))E=s;else{s=k;do{k=f[s>>2]|0;s=k+8|0;n=f[s>>2]|0}while((f[n>>2]|0)!=(k|0));E=n}}else{s=m;while(1){l=f[s>>2]|0;if(!l)break;else s=l}E=s}f[c>>2]=E;if(!p)break a;else{g=p;j=E}}j=f[g+8>>2]|0;if(!j)F=g;else{i=j;while(1){j=f[i+8>>2]|0;if(!j)break;else i=j}F=i}Ej(a,F)}while(0);F=f[c>>2]|0;E=f[d>>2]|0;if((F|0)==(E|0))return;else G=F;while(1){bf(a,G+16|0)|0;F=f[G+4>>2]|0;if(!F){d=G+8|0;p=f[d>>2]|0;if((f[p>>2]|0)==(G|0))H=p;else{p=d;do{d=f[p>>2]|0;p=d+8|0;e=f[p>>2]|0}while((f[e>>2]|0)!=(d|0));H=e}}else{p=F;while(1){i=f[p>>2]|0;if(!i)break;else p=i}H=p}f[c>>2]=H;if((H|0)==(E|0))break;else G=H}return}function Pc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;b=u;u=u+32|0;c=b+4|0;d=b;e=a+16|0;g=f[e>>2]|0;if(g>>>0>112){f[e>>2]=g+-113;g=a+4|0;e=f[g>>2]|0;h=f[e>>2]|0;i=e+4|0;f[g>>2]=i;e=a+8|0;j=f[e>>2]|0;k=a+12|0;l=f[k>>2]|0;m=l;do if((j|0)==(l|0)){n=f[a>>2]|0;o=n;if(i>>>0>n>>>0){p=i;q=((p-o>>2)+1|0)/-2|0;r=i+(q<<2)|0;s=j-p|0;p=s>>2;if(!p)t=i;else{im(r|0,i|0,s|0)|0;t=f[g>>2]|0}s=r+(p<<2)|0;f[e>>2]=s;f[g>>2]=t+(q<<2);v=s;break}s=m-o>>1;o=(s|0)==0?1:s;if(o>>>0>1073741823){s=ra(8)|0;Oo(s,16035);f[s>>2]=7256;va(s|0,1112,110)}s=ln(o<<2)|0;q=s;p=s+(o>>>2<<2)|0;r=p;w=s+(o<<2)|0;if((i|0)==(j|0)){x=r;y=n}else{n=p;p=r;o=i;do{f[n>>2]=f[o>>2];n=p+4|0;p=n;o=o+4|0}while((o|0)!=(j|0));x=p;y=f[a>>2]|0}f[a>>2]=q;f[g>>2]=r;f[e>>2]=x;f[k>>2]=w;if(!y)v=x;else{Oq(y);v=f[e>>2]|0}}else v=j;while(0);f[v>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}e=a+8|0;h=f[e>>2]|0;v=a+4|0;j=h-(f[v>>2]|0)|0;y=a+12|0;x=f[y>>2]|0;k=x-(f[a>>2]|0)|0;if(j>>>0>=k>>>0){g=k>>1;k=(g|0)==0?1:g;f[c+12>>2]=0;f[c+16>>2]=a+12;if(k>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=ln(k<<2)|0;f[c>>2]=g;i=g+(j>>2<<2)|0;j=c+8|0;f[j>>2]=i;m=c+4|0;f[m>>2]=i;i=c+12|0;f[i>>2]=g+(k<<2);k=ln(4068)|0;f[d>>2]=k;Ag(c,d);d=f[e>>2]|0;while(1){z=f[v>>2]|0;if((d|0)==(z|0))break;k=d+-4|0;ug(c,k);d=k}k=z;z=f[a>>2]|0;f[a>>2]=f[c>>2];f[c>>2]=z;f[v>>2]=f[m>>2];f[m>>2]=k;m=f[e>>2]|0;f[e>>2]=f[j>>2];f[j>>2]=m;g=f[y>>2]|0;f[y>>2]=f[i>>2];f[i>>2]=g;g=m;if((d|0)!=(g|0))f[j>>2]=g+(~((g+-4-k|0)>>>2)<<2);if(z|0)Oq(z);u=b;return}if((x|0)!=(h|0)){h=ln(4068)|0;f[c>>2]=h;Ag(a,c);u=b;return}h=ln(4068)|0;f[c>>2]=h;ug(a,c);c=f[v>>2]|0;h=f[c>>2]|0;x=c+4|0;f[v>>2]=x;c=f[e>>2]|0;z=f[y>>2]|0;k=z;do if((c|0)==(z|0)){g=f[a>>2]|0;j=g;if(x>>>0>g>>>0){d=x;m=((d-j>>2)+1|0)/-2|0;i=x+(m<<2)|0;t=c-d|0;d=t>>2;if(!d)A=x;else{im(i|0,x|0,t|0)|0;A=f[v>>2]|0}t=i+(d<<2)|0;f[e>>2]=t;f[v>>2]=A+(m<<2);B=t;break}t=k-j>>1;j=(t|0)==0?1:t;if(j>>>0>1073741823){t=ra(8)|0;Oo(t,16035);f[t>>2]=7256;va(t|0,1112,110)}t=ln(j<<2)|0;m=t;d=t+(j>>>2<<2)|0;i=d;l=t+(j<<2)|0;if((x|0)==(c|0)){C=i;D=g}else{g=d;d=i;j=x;do{f[g>>2]=f[j>>2];g=d+4|0;d=g;j=j+4|0}while((j|0)!=(c|0));C=d;D=f[a>>2]|0}f[a>>2]=m;f[v>>2]=i;f[e>>2]=C;f[y>>2]=l;if(!D)B=C;else{Oq(D);B=f[e>>2]|0}}else B=c;while(0);f[B>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}function Qc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=u;u=u+16|0;g=e+8|0;h=e+4|0;i=e;j=a+64|0;k=f[j>>2]|0;if((f[k+28>>2]|0)==(f[k+24>>2]|0)){u=e;return}l=c+96|0;c=a+52|0;m=d+84|0;n=d+68|0;d=a+56|0;o=a+60|0;p=a+12|0;q=a+28|0;r=a+40|0;s=a+44|0;t=a+48|0;v=0;w=0;x=k;while(1){k=f[(f[x+24>>2]|0)+(w<<2)>>2]|0;if((k|0)==-1){y=v;z=x}else{A=v+1|0;B=f[(f[l>>2]|0)+(((k|0)/3|0)*12|0)+(((k|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))C=f[(f[n>>2]|0)+(B<<2)>>2]|0;else C=B;f[g>>2]=C;B=f[d>>2]|0;if(B>>>0<(f[o>>2]|0)>>>0){f[B>>2]=C;f[d>>2]=B+4}else Ri(c,g);f[g>>2]=k;f[h>>2]=0;a:do if(!(f[(f[p>>2]|0)+(w>>>5<<2)>>2]&1<<(w&31)))D=k;else{B=k+1|0;E=((B>>>0)%3|0|0)==0?k+-2|0:B;if(((E|0)!=-1?(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)==0:0)?(B=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0,E=B+1|0,(B|0)!=-1):0){F=((E>>>0)%3|0|0)==0?B+-2|0:E;f[h>>2]=F;if((F|0)==-1){D=k;break}else G=F;while(1){f[g>>2]=G;F=G+1|0;E=((F>>>0)%3|0|0)==0?G+-2|0:F;if((E|0)==-1)break;if(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)break;F=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0;E=F+1|0;if((F|0)==-1)break;B=((E>>>0)%3|0|0)==0?F+-2|0:E;f[h>>2]=B;if((B|0)==-1){D=G;break a}else G=B}f[h>>2]=-1;D=G;break}f[h>>2]=-1;D=k}while(0);f[(f[q>>2]|0)+(D<<2)>>2]=v;k=f[s>>2]|0;if((k|0)==(f[t>>2]|0))Ri(r,g);else{f[k>>2]=f[g>>2];f[s>>2]=k+4}k=f[j>>2]|0;B=f[g>>2]|0;b:do if(((B|0)!=-1?(E=(((B>>>0)%3|0|0)==0?2:-1)+B|0,(E|0)!=-1):0)?(F=f[(f[k+12>>2]|0)+(E<<2)>>2]|0,(F|0)!=-1):0){E=F+(((F>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=E;if((E|0)!=-1&(E|0)!=(B|0)){F=A;H=v;I=E;while(1){E=I+1|0;J=((E>>>0)%3|0|0)==0?I+-2|0:E;do if(f[(f[a>>2]|0)+(J>>>5<<2)>>2]&1<<(J&31)){E=F+1|0;K=f[(f[l>>2]|0)+(((I|0)/3|0)*12|0)+(((I|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))L=f[(f[n>>2]|0)+(K<<2)>>2]|0;else L=K;f[i>>2]=L;K=f[d>>2]|0;if(K>>>0<(f[o>>2]|0)>>>0){f[K>>2]=L;f[d>>2]=K+4}else Ri(c,i);K=f[s>>2]|0;if((K|0)==(f[t>>2]|0)){Ri(r,h);M=E;N=F;break}else{f[K>>2]=f[h>>2];f[s>>2]=K+4;M=E;N=F;break}}else{M=F;N=H}while(0);f[(f[q>>2]|0)+(f[h>>2]<<2)>>2]=N;O=f[j>>2]|0;J=f[h>>2]|0;if((J|0)==-1)break;E=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((E|0)==-1)break;J=f[(f[O+12>>2]|0)+(E<<2)>>2]|0;if((J|0)==-1)break;I=J+(((J>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=I;if(!((I|0)!=-1?(I|0)!=(f[g>>2]|0):0)){P=M;Q=O;break b}else{F=M;H=N}}f[h>>2]=-1;P=M;Q=O}else{P=A;Q=k}}else R=28;while(0);if((R|0)==28){R=0;f[h>>2]=-1;P=A;Q=k}y=P;z=Q}w=w+1|0;if(w>>>0>=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2>>>0)break;else{v=y;x=z}}u=e;return}function Rc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,D=0,E=0,F=0;switch(c|0){case 0:{e=-149;g=24;i=4;break}case 1:{e=-1074;g=53;i=4;break}case 2:{e=-1074;g=53;i=4;break}default:j=0.0}a:do if((i|0)==4){c=a+4|0;k=a+100|0;do{l=f[c>>2]|0;if(l>>>0<(f[k>>2]|0)>>>0){f[c>>2]=l+1;m=h[l>>0]|0}else m=Si(a)|0}while((eq(m)|0)!=0);b:do switch(m|0){case 43:case 45:{l=1-(((m|0)==45&1)<<1)|0;n=f[c>>2]|0;if(n>>>0<(f[k>>2]|0)>>>0){f[c>>2]=n+1;o=h[n>>0]|0;p=l;break b}else{o=Si(a)|0;p=l;break b}break}default:{o=m;p=1}}while(0);l=0;n=o;while(1){if((n|32|0)!=(b[18546+l>>0]|0)){q=l;r=n;break}do if(l>>>0<7){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;t=h[s>>0]|0;break}else{t=Si(a)|0;break}}else t=n;while(0);s=l+1|0;if(s>>>0<8){l=s;n=t}else{q=s;r=t;break}}c:do switch(q|0){case 8:break;case 3:{i=23;break}default:{n=(d|0)!=0;if(n&q>>>0>3)if((q|0)==8)break c;else{i=23;break c}d:do if(!q){l=0;s=r;while(1){if((s|32|0)!=(b[18555+l>>0]|0)){u=l;v=s;break d}do if(l>>>0<2){w=f[c>>2]|0;if(w>>>0<(f[k>>2]|0)>>>0){f[c>>2]=w+1;x=h[w>>0]|0;break}else{x=Si(a)|0;break}}else x=s;while(0);w=l+1|0;if(w>>>0<3){l=w;s=x}else{u=w;v=x;break}}}else{u=q;v=r}while(0);switch(u|0){case 3:{s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;y=h[s>>0]|0}else y=Si(a)|0;if((y|0)==40)z=1;else{if(!(f[k>>2]|0)){j=B;break a}f[c>>2]=(f[c>>2]|0)+-1;j=B;break a}while(1){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;A=h[s>>0]|0}else A=Si(a)|0;if(!((A+-48|0)>>>0<10|(A+-65|0)>>>0<26)?!((A|0)==95|(A+-97|0)>>>0<26):0)break;z=z+1|0}if((A|0)==41){j=B;break a}s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!n){l=Vq()|0;f[l>>2]=22;Ym(a,0);j=0.0;break a}if(!z){j=B;break a}else D=z;while(1){D=D+-1|0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!D){j=B;break a}}break}case 0:{if((v|0)==48){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;E=h[s>>0]|0}else E=Si(a)|0;if((E|32|0)==120){j=+Fc(a,g,e,p,d);break a}if(!(f[k>>2]|0))F=48;else{f[c>>2]=(f[c>>2]|0)+-1;F=48}}else F=v;j=+nb(a,F,g,e,p,d);break a;break}default:{if(f[k>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;s=Vq()|0;f[s>>2]=22;Ym(a,0);j=0.0;break a}}}}while(0);if((i|0)==23){s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if((d|0)!=0&q>>>0>3){n=q;do{if(!s)f[c>>2]=(f[c>>2]|0)+-1;n=n+-1|0}while(n>>>0>3)}}j=+$($(p|0)*$(C))}while(0);return +j}function Sc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case 0:{m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m;break}case -1:{if((mi(c)|0)==10){m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m}else p=6;break}default:p=6}a:do if((p|0)==6){m=d+8|0;q=d+12|0;r=f[q>>2]|0;s=f[m>>2]|0;b:do if((r-s|0)>0){t=h+8|0;v=h+4|0;w=c+16|0;x=h+11|0;y=0;z=s;A=r;c:while(1){B=f[(f[z+(y<<2)>>2]|0)+28>>2]|0;switch(B|0){case 9:{p=12;break}case 6:case 5:case 4:case 2:{C=z;D=A;break}default:{if((B|2|0)!=3)break c;if((B|0)==9)p=12;else{C=z;D=A}}}if((p|0)==12){p=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;B=ln(32)|0;f[h>>2]=B;f[t>>2]=-2147483616;f[v>>2]=17;j=B;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[B+17>>0]=0;E=f[w>>2]|0;if(E){F=w;G=E;d:while(1){E=G;while(1){if((f[E+16>>2]|0)>=0)break;H=f[E+4>>2]|0;if(!H){I=F;break d}else E=H}G=f[E>>2]|0;if(!G){I=E;break}else F=E}if(((I|0)!=(w|0)?(f[I+16>>2]|0)<=0:0)?(F=I+20|0,(Jh(F,h)|0)!=0):0)J=Hk(F,h,-1)|0;else p=21}else p=21;if((p|0)==21){p=0;J=Hk(c,h,-1)|0}if((b[x>>0]|0)<0)Oq(f[h>>2]|0);if((J|0)<1)break;C=f[m>>2]|0;D=f[q>>2]|0}y=y+1|0;if((y|0)>=(D-C>>2|0))break b;else{z=C;A=D}}if((i|0)!=1){A=ln(52)|0;j=A;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(A);n=4044;o=A;break a}f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;z=ln(32)|0;f[h>>2]=z;f[h+8>>2]=-2147483616;f[h+4>>2]=24;j=z;k=14513;l=j+24|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[z+24>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}while(0);q=ln(52)|0;j=q;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(q);n=3988;o=q}while(0);f[o>>2]=n;ip(o,d);Md(a,o,c,e);Va[f[(f[o>>2]|0)+4>>2]&127](o);u=g;return}function Tc(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;i=u;u=u+32|0;j=i+4|0;k=i;l=i+16|0;m=(_(e|0)|0)^31;if((e|0)>0)if(m>>>0>17){n=0;u=i;return n|0}else o=m+1|0;else o=1;do if(g){m=ln(48)|0;f[j>>2]=m;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=m;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[m+33>>0]=0;r=(Jh(g,j)|0)==0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if(!r){r=ln(48)|0;f[j>>2]=r;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=r;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[r+33>>0]=0;p=Mk(g,j)|0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((p|0)<4){s=o+-2|0;break}if((p|0)<6){s=o+-1|0;break}if((p|0)>9){s=o+2|0;break}else{s=o+((p|0)>7&1)|0;break}}else s=o}else s=o;while(0);o=(s|0)>1?s:1;s=(o|0)<18?o:18;b[l>>0]=s;o=h+16|0;g=f[o+4>>2]|0;if(!((g|0)>0|(g|0)==0&(f[o>>2]|0)>>>0>0)){f[k>>2]=f[h+4>>2];f[j>>2]=f[k>>2];Me(h,j,l,l+1|0)|0}do switch(s&31){case 1:case 0:{n=ue(a,c,d,h)|0;u=i;return n|0}case 2:{n=te(a,c,d,h)|0;u=i;return n|0}case 3:{n=se(a,c,d,h)|0;u=i;return n|0}case 4:{n=re(a,c,d,h)|0;u=i;return n|0}case 5:{n=qe(a,c,d,h)|0;u=i;return n|0}case 6:{n=pe(a,c,d,h)|0;u=i;return n|0}case 7:{n=oe(a,c,d,h)|0;u=i;return n|0}case 8:{n=ne(a,c,d,h)|0;u=i;return n|0}case 9:{n=me(a,c,d,h)|0;u=i;return n|0}case 10:{n=le(a,c,d,h)|0;u=i;return n|0}case 11:{n=ke(a,c,d,h)|0;u=i;return n|0}case 12:{n=ie(a,c,d,h)|0;u=i;return n|0}case 13:{n=he(a,c,d,h)|0;u=i;return n|0}case 14:{n=ge(a,c,d,h)|0;u=i;return n|0}case 15:{n=fe(a,c,d,h)|0;u=i;return n|0}case 16:{n=ee(a,c,d,h)|0;u=i;return n|0}case 17:{n=de(a,c,d,h)|0;u=i;return n|0}case 18:{n=ce(a,c,d,h)|0;u=i;return n|0}default:{n=0;u=i;return n|0}}while(0);return 0}function Uc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;xb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Vc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;yb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Wc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;zb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Xc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ab(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Yc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Fb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Zc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*524288.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==524288){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Bb(z,A,g);a:do if((x|0)<524288){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=524288-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>524288;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-524288|0;m=x;while(1){v=524288.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==524288){C=p;D=524288;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=524288){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*1.9073486328125e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function _c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*262144.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==262144){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Cb(z,A,g);a:do if((x|0)<262144){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=262144-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>262144;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-262144|0;m=x;while(1){v=262144.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==262144){C=p;D=262144;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=262144){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*3.814697265625e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function $c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*65536.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==65536){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Db(z,A,g);a:do if((x|0)<65536){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=65536-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>65536;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-65536|0;m=x;while(1){v=65536.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==65536){C=p;D=65536;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=65536){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0000152587890625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ad(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*32768.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==32768){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Eb(z,A,g);a:do if((x|0)<32768){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=32768-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>32768;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-32768|0;m=x;while(1){v=32768.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==32768){C=p;D=32768;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=32768){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000030517578125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function bd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*8192.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==8192){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Gb(z,A,g);a:do if((x|0)<8192){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=8192-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>8192;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-8192|0;m=x;while(1){v=8192.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==8192){C=p;D=8192;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=8192){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0001220703125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function cd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Hb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function dd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ib(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ed(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Jb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Kb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function gd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Lb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function hd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Mb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function id(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Nb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function jd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ob(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function kd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J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l=j;j=f[l>>2]|0;m=f[l+4>>2]|0;l=Vn(j|0,m|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=I;n=Vn(l|0,k|0,(l|0)==0&(k|0)==0&1|0,0)|0;k=~~((+(j>>>0)+4294967296.0*+(m>>>0))/(+(n>>>0)+4294967296.0*+(I>>>0))*256.0+.5)>>>0;n=k>>>0<255?k:255;k=n+((n|0)==0&1)&255;b[h>>0]=k;n=a+12|0;m=a+16|0;j=((f[m>>2]|0)-(f[n>>2]|0)<<1)+64|0;f[i>>2]=0;l=i+4|0;f[l>>2]=0;f[i+8>>2]=0;if(!j)o=0;else{if((j|0)<0)aq(i);p=ln(j)|0;f[l>>2]=p;f[i>>2]=p;f[i+8>>2]=p+j;q=j;j=p;do{b[j>>0]=0;j=(f[l>>2]|0)+1|0;f[l>>2]=j;q=q+-1|0}while((q|0)!=0);o=f[i>>2]|0}q=a+28|0;j=(f[q>>2]|0)+-1|0;a:do if((j|0)>-1){p=a+24|0;r=j;s=4096;t=0;v=k;while(1){w=(f[p>>2]&1<>>0>>0){y=t;z=s}else{b[o+t>>0]=s;y=t+1|0;z=s>>>8}un(f[4092+(x<<3)>>2]|0,0,z|0,0)|0;A=z+(w?0:0-v&255)+(X((z+I|0)>>>(f[4092+(x<<3)+4>>2]|0),256-x|0)|0)|0;x=r+-1|0;if((x|0)<=-1){B=A;C=y;break a}r=x;s=A;t=y;v=b[h>>0]|0}}else{B=4096;C=0}while(0);y=f[m>>2]|0;if((f[n>>2]|0)==(y|0)){D=B;E=C}else{z=B;B=C;C=y;while(1){C=C+-4|0;y=f[C>>2]|0;k=31;j=z;v=B;while(1){t=b[h>>0]|0;s=(1<>>0>>0){F=v;G=j}else{b[o+v>>0]=j;F=v+1|0;G=j>>>8}un(f[4092+(r<<3)>>2]|0,0,G|0,0)|0;j=G+(s?0:0-t&255)+(X((G+I|0)>>>(f[4092+(r<<3)+4>>2]|0),256-r|0)|0)|0;if((k|0)<=0)break;else{k=k+-1|0;v=F}}if((f[n>>2]|0)==(C|0)){D=j;E=F;break}else{z=j;B=F}}}F=D+-4096|0;do if(F>>>0>=64){if(F>>>0<16384){B=o+E|0;z=D+12288|0;b[B>>0]=z;H=2;J=z>>>8;K=B+1|0;L=25;break}if(F>>>0<4194304){B=o+E|0;z=D+8384512|0;b[B>>0]=z;b[B+1>>0]=z>>>8;H=3;J=z>>>16;K=B+2|0;L=25}else M=E}else{H=1;J=F;K=o+E|0;L=25}while(0);if((L|0)==25){b[K>>0]=J;M=H+E|0}E=c+16|0;H=E;J=f[H+4>>2]|0;if(!((J|0)>0|(J|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}ci(M,c)|0;h=f[i>>2]|0;H=E;E=f[H+4>>2]|0;if(!((E|0)>0|(E|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+M|0)|0}M=e;f[M>>2]=0;f[M+4>>2]=0;qf(a,2,e);e=f[a+12>>2]|0;M=f[m>>2]|0;if((M|0)!=(e|0))f[m>>2]=M+(~((M+-4-e|0)>>>2)<<2);f[a+24>>2]=0;f[q>>2]=0;q=f[i>>2]|0;if(!q){u=d;return}if((f[l>>2]|0)!=(q|0))f[l>>2]=q;Oq(q);u=d;return}function md(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;c=u;u=u+16|0;b=c+8|0;d=c+4|0;e=c;g=a+64|0;h=f[g>>2]|0;if((f[h+28>>2]|0)==(f[h+24>>2]|0)){u=c;return}i=a+52|0;j=a+56|0;k=a+60|0;l=a+12|0;m=a+28|0;n=a+40|0;o=a+44|0;p=a+48|0;q=0;r=0;s=h;while(1){h=f[(f[s+24>>2]|0)+(r<<2)>>2]|0;if((h|0)==-1){t=q;v=s}else{w=q+1|0;f[b>>2]=q;x=f[j>>2]|0;if((x|0)==(f[k>>2]|0))Ri(i,b);else{f[x>>2]=q;f[j>>2]=x+4}f[d>>2]=h;f[e>>2]=0;a:do if(!(f[(f[l>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)))y=h;else{x=h+1|0;z=((x>>>0)%3|0|0)==0?h+-2|0:x;if(((z|0)!=-1?(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)==0:0)?(x=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0,z=x+1|0,(x|0)!=-1):0){A=((z>>>0)%3|0|0)==0?x+-2|0:z;f[e>>2]=A;if((A|0)==-1){y=h;break}else B=A;while(1){f[d>>2]=B;A=B+1|0;z=((A>>>0)%3|0|0)==0?B+-2|0:A;if((z|0)==-1)break;if(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)break;A=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0;z=A+1|0;if((A|0)==-1)break;x=((z>>>0)%3|0|0)==0?A+-2|0:z;f[e>>2]=x;if((x|0)==-1){y=B;break a}else B=x}f[e>>2]=-1;y=B;break}f[e>>2]=-1;y=h}while(0);f[(f[m>>2]|0)+(y<<2)>>2]=f[b>>2];h=f[o>>2]|0;if((h|0)==(f[p>>2]|0))Ri(n,d);else{f[h>>2]=f[d>>2];f[o>>2]=h+4}h=f[g>>2]|0;x=f[d>>2]|0;b:do if(((x|0)!=-1?(z=(((x>>>0)%3|0|0)==0?2:-1)+x|0,(z|0)!=-1):0)?(A=f[(f[h+12>>2]|0)+(z<<2)>>2]|0,(A|0)!=-1):0){z=A+(((A>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=z;if((z|0)!=-1&(z|0)!=(x|0)){A=w;C=z;while(1){z=C+1|0;D=((z>>>0)%3|0|0)==0?C+-2|0:z;do if(f[(f[a>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)){z=A+1|0;f[b>>2]=A;E=f[j>>2]|0;if((E|0)==(f[k>>2]|0))Ri(i,b);else{f[E>>2]=A;f[j>>2]=E+4}E=f[o>>2]|0;if((E|0)==(f[p>>2]|0)){Ri(n,e);F=z;break}else{f[E>>2]=f[e>>2];f[o>>2]=E+4;F=z;break}}else F=A;while(0);f[(f[m>>2]|0)+(f[e>>2]<<2)>>2]=f[b>>2];G=f[g>>2]|0;D=f[e>>2]|0;if((D|0)==-1)break;z=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((z|0)==-1)break;D=f[(f[G+12>>2]|0)+(z<<2)>>2]|0;if((D|0)==-1)break;C=D+(((D>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=C;if(!((C|0)!=-1?(C|0)!=(f[d>>2]|0):0)){H=F;I=G;break b}else A=F}f[e>>2]=-1;H=F;I=G}else{H=w;I=h}}else J=26;while(0);if((J|0)==26){J=0;f[e>>2]=-1;H=w;I=h}t=H;v=I}r=r+1|0;if(r>>>0>=(f[v+28>>2]|0)-(f[v+24>>2]|0)>>2>>>0)break;else{q=t;s=v}}u=c;return}function nd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+124|0;f[h>>2]=(f[h>>2]|0)+1;h=a+88|0;i=a+120|0;j=f[i>>2]|0;k=j+1|0;do if((j|0)!=-1){l=((k>>>0)%3|0|0)==0?j+-2|0:k;if(!((j>>>0)%3|0)){m=j+2|0;n=l;break}else{m=j+-1|0;n=l;break}}else{m=-1;n=-1}while(0);k=a+104|0;l=a+92|0;o=f[l>>2]|0;p=o+(n<<2)|0;q=f[k>>2]|0;r=q+(f[p>>2]<<2)|0;s=f[r>>2]|0;switch(b|0){case 1:case 0:{f[r>>2]=s+-1;r=q+(f[o+(m<<2)>>2]<<2)|0;f[r>>2]=(f[r>>2]|0)+-1;if((b|0)==1){if((m|0)!=-1?(r=f[(f[(f[h>>2]|0)+12>>2]|0)+(m<<2)>>2]|0,(r|0)!=-1):0){t=a+64|0;v=1;w=r;while(1){r=f[t>>2]|0;x=f[(f[r>>2]|0)+36>>2]|0;f[e>>2]=(w>>>0)/3|0;f[d>>2]=f[e>>2];if(Ra[x&127](r,d)|0){y=v;break}r=w+1|0;x=((r>>>0)%3|0|0)==0?w+-2|0:r;if((x|0)==-1){z=12;break}w=f[(f[(f[h>>2]|0)+12>>2]|0)+(x<<2)>>2]|0;x=v+1|0;if((w|0)==-1){y=x;break}else v=x}if((z|0)==12)y=v+1|0;A=y;B=f[k>>2]|0;C=f[l>>2]|0}else{A=1;B=q;C=o}f[B+(f[C+(f[i>>2]<<2)>>2]<<2)>>2]=A;A=a+108|0;i=f[A>>2]|0;C=i-B>>2;B=i;if((n|0)!=-1?(i=f[(f[(f[h>>2]|0)+12>>2]|0)+(n<<2)>>2]|0,(i|0)!=-1):0){n=a+64|0;y=1;v=i;while(1){i=f[n>>2]|0;w=f[(f[i>>2]|0)+36>>2]|0;f[g>>2]=(v>>>0)/3|0;f[d>>2]=f[g>>2];if(Ra[w&127](i,d)|0){D=y;break}i=v+1|0;f[(f[l>>2]|0)+((((i>>>0)%3|0|0)==0?v+-2|0:i)<<2)>>2]=C;i=(((v>>>0)%3|0|0)==0?2:-1)+v|0;if((i|0)==-1){z=20;break}v=f[(f[(f[h>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;i=y+1|0;if((v|0)==-1){D=i;break}else y=i}if((z|0)==20)D=y+1|0;E=D;F=f[A>>2]|0}else{E=1;F=B}f[d>>2]=E;if(F>>>0<(f[a+112>>2]|0)>>>0){f[F>>2]=E;f[A>>2]=F+4}else Ri(k,d)}break}case 5:{k=q+(f[o+(j<<2)>>2]<<2)|0;f[k>>2]=(f[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h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2132;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ti(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2188;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2244;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2300;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=2356;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function qd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1656;i=c;f[a>>2]=i;return}case 2:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1712;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ui(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1768;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1824;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1880;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1936;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function rd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+2|0;v=e+12|0;w=q+6|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=d[q>>1]|0;A=e;B=x;while(1){C=B+8|0;if(z<<16>>16!=(d[C>>1]|0)){y=A;break d}if((d[u>>1]|0)!=(d[C+2>>1]|0)){y=A;break d}if((d[v>>1]|0)!=(d[B+12>>1]|0)){y=A;break d}if((d[w>>1]|0)!=(d[C+6>>1]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=c;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(b>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+2|0;u=e+12|0;x=w+6|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=d[w>>1]|0;B=e;z=q;while(1){D=z+8|0;if(A<<16>>16!=(d[D>>1]|0)){G=B;break e}if((d[v>>1]|0)!=(d[D+2>>1]|0)){G=B;break e}if((d[u>>1]|0)!=(d[z+12>>1]|0)){G=B;break e}if((d[x>>1]|0)!=(d[D+6>>1]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);c=f[p>>2]|0;if(!c){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){E=43;break}else{k=s;l=r;n=r}}if((E|0)==43)return}function sd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=q+3|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=b[q>>0]|0;A=e;B=x;while(1){C=B+8|0;if(z<<24>>24!=(b[C>>0]|0)){y=A;break d}if((b[u>>0]|0)!=(b[C+1>>0]|0)){y=A;break d}if((b[v>>0]|0)!=(b[C+2>>0]|0)){y=A;break d}if((b[w>>0]|0)!=(b[C+3>>0]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=d;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(c>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+1|0;u=w+2|0;x=w+3|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=b[w>>0]|0;B=e;z=q;while(1){D=z+8|0;if(A<<24>>24!=(b[D>>0]|0)){G=B;break e}if((b[v>>0]|0)!=(b[D+1>>0]|0)){G=B;break e}if((b[u>>0]|0)!=(b[D+2>>0]|0)){G=B;break e}if((b[x>>0]|0)!=(b[D+3>>0]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);d=f[p>>2]|0;if(!d){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){E=43;break}else{k=s;l=r;n=r}}if((E|0)==43)return}function td(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0;i=u;u=u+352|0;j=i+340|0;k=i+336|0;l=i+80|0;m=i+48|0;n=i;sj(l|0,0,256)|0;o=f[e+4>>2]|0;p=f[e>>2]|0;q=p;if((o|0)!=(p|0)){r=o-p>>2;p=0;do{o=l+(f[q+(p<<2)>>2]<<3)|0;s=o;t=Vn(f[s>>2]|0,f[s+4>>2]|0,1,0)|0;s=o;f[s>>2]=t;f[s+4>>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[N>>0]=(1<>0]|0);N=(f[G>>2]|0)+L|0;b[N>>0]=(F>>>J&1)<>0]|0);K=(f[H>>2]|0)+1|0;f[H>>2]=K;J=J+1|0}while((J|0)!=(E|0))}A=A+1|0}while((A|0)!=(d|0))}v=v-d|0}while((v|0)>-1)}_f(n,g);eg(m);v=f[m>>2]|0;d=m+4|0;o=g+16|0;r=f[o+4>>2]|0;if(!((r|0)>0|(r|0)==0&(f[o>>2]|0)>>>0>0)){o=(f[d>>2]|0)-v|0;f[k>>2]=f[l>>2];f[j>>2]=f[k>>2];Me(g,j,v,v+o|0)|0}o=f[n>>2]|0;if(o|0){v=n+4|0;n=f[v>>2]|0;if((n|0)!=(o|0))f[v>>2]=n+(~((n+-8-o|0)>>>3)<<3);Oq(o)}o=m+12|0;n=f[o>>2]|0;f[o>>2]=0;if(n|0)Oq(n);n=f[m>>2]|0;if(!n){u=i;return 1}if((f[d>>2]|0)!=(n|0))f[d>>2]=n;Oq(n);u=i;return 1}function ud(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=d+20|0;v=f[d>>2]|0;d:do if(!v)w=d;else{x=f[d+8>>2]|0;y=d;z=v;while(1){if((x|0)!=(f[z+8>>2]|0)){w=y;break d}if((f[p>>2]|0)!=(f[z+12>>2]|0)){w=y;break d}if((f[t>>2]|0)!=(f[z+16>>2]|0)){w=y;break d}if((f[u>>2]|0)!=(f[z+20>>2]|0)){w=y;break d}A=f[z>>2]|0;if(!A){w=z;break}else{B=z;z=A;y=B}}}while(0);f[i>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}else{d=c;while(1){u=f[d+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(j|0)){o=d;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){q=d;r=D;s=u;break b}u=d+12|0;t=d+16|0;p=d+20|0;v=f[d>>2]|0;e:do if(!v)E=d;else{y=f[d+8>>2]|0;z=d;x=v;while(1){if((y|0)!=(f[x+8>>2]|0)){E=z;break e}if((f[u>>2]|0)!=(f[x+12>>2]|0)){E=z;break e}if((f[t>>2]|0)!=(f[x+16>>2]|0)){E=z;break e}if((f[p>>2]|0)!=(f[x+20>>2]|0)){E=z;break e}B=f[x>>2]|0;if(!B){E=x;break}else{A=x;x=B;z=A}}}while(0);f[i>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}while(0);c=f[o>>2]|0;if(!c){C=43;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){C=43;break}else{j=r;k=q;m=q}}if((C|0)==43)return}function vd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=e+12|0;v=f[e>>2]|0;d:do if(!v)w=e;else{x=d[q>>1]|0;y=q+2|0;z=e;A=v;while(1){B=A+8|0;if(x<<16>>16!=(d[B>>1]|0)){w=z;break d}if((d[y>>1]|0)!=(d[B+2>>1]|0)){w=z;break d}if((d[u>>1]|0)!=(d[A+12>>1]|0)){w=z;break d}B=f[A>>2]|0;if(!B){w=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)E=u;else E=(u>>>0)%(b>>>0)|0;if((E|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(E<<2)|0;if(!(f[u>>2]|0)){r=e;s=E;t=u;break b}u=e+8|0;v=e+12|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=d[u>>1]|0;A=u+2|0;y=e;x=q;while(1){C=x+8|0;if(z<<16>>16!=(d[C>>1]|0)){F=y;break e}if((d[A>>1]|0)!=(d[C+2>>1]|0)){F=y;break e}if((d[v>>1]|0)!=(d[x+12>>1]|0)){F=y;break e}C=f[x>>2]|0;if(!C){F=x;break}else{B=x;x=C;y=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);c=f[p>>2]|0;if(!c){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function wd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=f[e>>2]|0;d:do if(!w)x=e;else{y=b[q>>0]|0;z=e;A=w;while(1){B=A+8|0;if(y<<24>>24!=(b[B>>0]|0)){x=z;break d}if((b[u>>0]|0)!=(b[B+1>>0]|0)){x=z;break d}if((b[v>>0]|0)!=(b[B+2>>0]|0)){x=z;break d}B=f[A>>2]|0;if(!B){x=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[x>>2];f[x>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=d;while(1){v=f[e+4>>2]|0;if(v>>>0>>0)E=v;else E=(v>>>0)%(c>>>0)|0;if((E|0)==(k|0)){p=e;break c}v=(f[a>>2]|0)+(E<<2)|0;if(!(f[v>>2]|0)){r=e;s=E;t=v;break b}v=e+8|0;u=v+1|0;w=v+2|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=b[v>>0]|0;A=e;y=q;while(1){C=y+8|0;if(z<<24>>24!=(b[C>>0]|0)){F=A;break e}if((b[u>>0]|0)!=(b[C+1>>0]|0)){F=A;break e}if((b[w>>0]|0)!=(b[C+2>>0]|0)){F=A;break e}C=f[y>>2]|0;if(!C){F=y;break}else{B=y;y=C;A=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);d=f[p>>2]|0;if(!d){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function xd(a,b){a=+a;b=+b;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s>>2]|0;g=f[s+4>>2]|0;h=Yn(c|0,d|0,52)|0;i=h&2047;h=Yn(e|0,g|0,52)|0;j=h&2047;h=d&-2147483648;k=Tn(e|0,g|0,1)|0;l=I;a:do if(!((k|0)==0&(l|0)==0)?(m=yo(b)|0,n=I&2147483647,!((i|0)==2047|(n>>>0>2146435072|(n|0)==2146435072&m>>>0>0))):0){m=Tn(c|0,d|0,1)|0;n=I;if(!(n>>>0>l>>>0|(n|0)==(l|0)&m>>>0>k>>>0))return +((m|0)==(k|0)&(n|0)==(l|0)?a*0.0:a);if(!i){n=Tn(c|0,d|0,12)|0;m=I;if((m|0)>-1|(m|0)==-1&n>>>0>4294967295){o=0;q=n;n=m;while(1){m=o+-1|0;q=Tn(q|0,n|0,1)|0;n=I;if(!((n|0)>-1|(n|0)==-1&q>>>0>4294967295)){r=m;break}else o=m}}else r=0;o=Tn(c|0,d|0,1-r|0)|0;t=r;u=o;v=I}else{t=i;u=c;v=d&1048575|1048576}if(!j){o=Tn(e|0,g|0,12)|0;q=I;if((q|0)>-1|(q|0)==-1&o>>>0>4294967295){n=0;m=o;o=q;while(1){q=n+-1|0;m=Tn(m|0,o|0,1)|0;o=I;if(!((o|0)>-1|(o|0)==-1&m>>>0>4294967295)){w=q;break}else n=q}}else w=0;n=Tn(e|0,g|0,1-w|0)|0;x=w;y=n;z=I}else{x=j;y=e;z=g&1048575|1048576}n=Xn(u|0,v|0,y|0,z|0)|0;m=I;o=(m|0)>-1|(m|0)==-1&n>>>0>4294967295;b:do if((t|0)>(x|0)){q=t;A=m;B=o;C=u;D=v;E=n;while(1){if(B)if((E|0)==0&(A|0)==0)break;else{F=E;G=A}else{F=C;G=D}H=Tn(F|0,G|0,1)|0;J=I;K=q+-1|0;L=Xn(H|0,J|0,y|0,z|0)|0;M=I;N=(M|0)>-1|(M|0)==-1&L>>>0>4294967295;if((K|0)>(x|0)){q=K;A=M;B=N;C=H;D=J;E=L}else{O=K;P=N;Q=L;R=M;S=H;T=J;break b}}U=a*0.0;break a}else{O=t;P=o;Q=n;R=m;S=u;T=v}while(0);if(P)if((Q|0)==0&(R|0)==0){U=a*0.0;break}else{V=R;W=Q}else{V=T;W=S}if(V>>>0<1048576|(V|0)==1048576&W>>>0<0){m=O;n=W;o=V;while(1){E=Tn(n|0,o|0,1)|0;D=I;C=m+-1|0;if(D>>>0<1048576|(D|0)==1048576&E>>>0<0){m=C;n=E;o=D}else{X=C;Y=E;Z=D;break}}}else{X=O;Y=W;Z=V}if((X|0)>0){o=Vn(Y|0,Z|0,0,-1048576)|0;n=I;m=Tn(X|0,0,52)|0;_=n|I;$=o|m}else{m=Yn(Y|0,Z|0,1-X|0)|0;_=I;$=m}f[s>>2]=$;f[s+4>>2]=_|h;U=+p[s>>3]}else aa=3;while(0);if((aa|0)==3){ba=a*b;U=ba/ba}return +U}function yd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+32|0;e=d+8|0;g=d;h=c+4|0;i=f[(f[h>>2]|0)+48>>2]|0;j=c+12|0;c=f[j>>2]|0;k=ln(32)|0;f[e>>2]=k;f[e+8>>2]=-2147483616;f[e+4>>2]=17;l=k;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[k+17>>0]=0;k=i+16|0;m=f[k>>2]|0;if(m){l=k;n=m;a:while(1){m=n;while(1){if((f[m+16>>2]|0)>=(c|0))break;o=f[m+4>>2]|0;if(!o){p=l;break a}else m=o}n=f[m>>2]|0;if(!n){p=m;break}else l=m}if(((p|0)!=(k|0)?(c|0)>=(f[p+16>>2]|0):0)?(c=p+20|0,(Jh(c,e)|0)!=0):0)q=Hk(c,e,-1)|0;else r=10}else r=10;if((r|0)==10)q=Hk(i,e,-1)|0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);f[e>>2]=-1;f[e+4>>2]=-1;f[e+8>>2]=-1;f[e+12>>2]=-1;i=(_((1<>>0<=28){f[e>>2]=i+1;q=2<>2]=q+-1;i=q+-2|0;f[e+8>>2]=i;f[e+12>>2]=(i|0)/2|0}switch(Xi(f[j>>2]|0,f[h>>2]|0)|0){case 6:{i=f[j>>2]|0;q=f[h>>2]|0;c=f[(f[(f[q+4>>2]|0)+8>>2]|0)+(i<<2)>>2]|0;do if((Qa[f[(f[q>>2]|0)+8>>2]&127](q)|0)==1){Hf(g,q,6,i,e,514);p=f[g>>2]|0;if(!p){f[g>>2]=0;s=g;r=21;break}else{t=g;v=p;break}}else{s=g;r=21}while(0);if((r|0)==21){i=ln(24)|0;f[i+4>>2]=c;c=i+8|0;f[c>>2]=f[e>>2];f[c+4>>2]=f[e+4>>2];f[c+8>>2]=f[e+8>>2];f[c+12>>2]=f[e+12>>2];f[i>>2]=2560;c=i;f[g>>2]=c;t=s;v=c}f[a>>2]=v;f[t>>2]=0;u=d;return}case 0:{t=f[j>>2]|0;j=f[h>>2]|0;h=f[(f[(f[j+4>>2]|0)+8>>2]|0)+(t<<2)>>2]|0;do if((Qa[f[(f[j>>2]|0)+8>>2]&127](j)|0)==1){Hf(g,j,0,t,e,514);v=f[g>>2]|0;if(!v){f[g>>2]=0;w=g;r=28;break}else{x=g;y=v;break}}else{w=g;r=28}while(0);if((r|0)==28){r=ln(24)|0;f[r+4>>2]=h;h=r+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[r>>2]=2560;e=r;f[g>>2]=e;x=w;y=e}f[a>>2]=y;f[x>>2]=0;u=d;return}default:{f[a>>2]=0;u=d;return}}}function zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=f[d>>2]|0;d:do if(!u)v=d;else{w=f[d+8>>2]|0;x=d;y=u;while(1){if((w|0)!=(f[y+8>>2]|0)){v=x;break d}if((f[p>>2]|0)!=(f[y+12>>2]|0)){v=x;break d}if((f[t>>2]|0)!=(f[y+16>>2]|0)){v=x;break d}z=f[y>>2]|0;if(!z){v=y;break}else{A=y;y=z;x=A}}}while(0);f[i>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}else{d=c;while(1){t=f[d+4>>2]|0;if(t>>>0>>0)C=t;else C=(t>>>0)%(b>>>0)|0;if((C|0)==(j|0)){o=d;break c}t=(f[a>>2]|0)+(C<<2)|0;if(!(f[t>>2]|0)){q=d;r=C;s=t;break b}t=d+12|0;p=d+16|0;u=f[d>>2]|0;e:do if(!u)D=d;else{x=f[d+8>>2]|0;y=d;w=u;while(1){if((x|0)!=(f[w+8>>2]|0)){D=y;break e}if((f[t>>2]|0)!=(f[w+12>>2]|0)){D=y;break e}if((f[p>>2]|0)!=(f[w+16>>2]|0)){D=y;break e}A=f[w>>2]|0;if(!A){D=w;break}else{z=w;w=A;y=z}}}while(0);f[i>>2]=f[D>>2];f[D>>2]=f[f[(f[a>>2]|0)+(C<<2)>>2]>>2];f[f[(f[a>>2]|0)+(C<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}while(0);c=f[o>>2]|0;if(!c){B=41;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){B=41;break}else{j=r;k=q;m=q}}if((B|0)==41)return}function Ad(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2980;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3036;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3092;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=ln(68)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3148;h=c+40|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(84)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3204;f[c+40>>2]=0;f[c+44>>2]=0;f[c+56>>2]=0;f[c+60>>2]=0;f[c+64>>2]=0;h=c+68|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(120)|0;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];e=c+24|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=3260;f[c+44>>2]=0;f[c+48>>2]=0;e=c+52|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+40>>2]=3316;f[c+68>>2]=1;g=c+72|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+88|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function Bd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){o=d;while(1){e=f[o+4>>2]|0;if(!i)if(e>>>0>>0)p=e;else p=(e>>>0)%(c>>>0)|0;else p=e&h;if((p|0)==(k|0))break;q=(f[a>>2]|0)+(p<<2)|0;if(!(f[q>>2]|0))break b;e=f[o>>2]|0;c:do if(!e)r=o;else{s=o+8|0;t=b[s+11>>0]|0;u=t<<24>>24<0;v=t&255;t=u?f[o+12>>2]|0:v;w=(t|0)==0;if(u){u=o;x=e;while(1){y=x+8|0;z=b[y+11>>0]|0;A=z<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:z&255)|0)){r=u;break c}if(!w?Vk(f[s>>2]|0,A?f[y>>2]|0:y,t)|0:0){r=u;break c}y=f[x>>2]|0;if(!y){r=x;break c}else{A=x;x=y;u=A}}}if(w){u=o;x=e;while(1){A=b[x+8+11>>0]|0;if((A<<24>>24<0?f[x+12>>2]|0:A&255)|0){r=u;break c}A=f[x>>2]|0;if(!A){r=x;break c}else{y=x;x=A;u=y}}}u=o;x=e;while(1){w=x+8|0;y=b[w+11>>0]|0;A=y<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:y&255)|0)){r=u;break c}y=A?f[w>>2]|0:w;if((b[y>>0]|0)==(f[s>>2]&255)<<24>>24){B=s;C=v;D=y}else{r=u;break c}while(1){C=C+-1|0;B=B+1|0;if(!C)break;D=D+1|0;if((b[B>>0]|0)!=(b[D>>0]|0)){r=u;break c}}y=f[x>>2]|0;if(!y){r=x;break}else{w=x;x=y;u=w}}}while(0);f[j>>2]=f[r>>2];f[r>>2]=f[f[(f[a>>2]|0)+(p<<2)>>2]>>2];f[f[(f[a>>2]|0)+(p<<2)>>2]>>2]=o;e=f[g>>2]|0;if(!e){E=43;break a}else o=e}d=f[o>>2]|0;if(!d){E=43;break a}else{g=o;j=o}}f[q>>2]=j;m=f[o>>2]|0;if(!m){E=43;break}else{k=p;l=o;n=o}}if((E|0)==43)return}function Cd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2616;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2672;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2728;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=ln(68)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2784;h=c+40|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(84)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2840;f[c+40>>2]=0;f[c+44>>2]=0;f[c+56>>2]=0;f[c+60>>2]=0;f[c+64>>2]=0;h=c+68|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(120)|0;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];e=c+24|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2896;f[c+44>>2]=0;f[c+48>>2]=0;e=c+52|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+40>>2]=2952;f[c+68>>2]=1;g=c+72|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+88|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function Dd(a,b){a=a|0;b=b|0;var c=0,d=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[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=d[q>>1]|0;x=q+2|0;y=e;z=u;while(1){A=z+8|0;if(w<<16>>16!=(d[A>>1]|0)){v=y;break d}if((d[x>>1]|0)!=(d[A+2>>1]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=d[u>>1]|0;z=u+2|0;x=e;w=q;while(1){B=w+8|0;if(y<<16>>16!=(d[B>>1]|0)){E=x;break e}if((d[z>>1]|0)!=(d[B+2>>1]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);c=f[p>>2]|0;if(!c){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Gd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=b[q>>0]|0;x=q+1|0;y=e;z=u;while(1){A=z+8|0;if(w<<24>>24!=(b[A>>0]|0)){v=y;break d}if((b[x>>0]|0)!=(b[A+1>>0]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=d;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(c>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=b[u>>0]|0;z=u+1|0;x=e;w=q;while(1){B=w+8|0;if(y<<24>>24!=(b[B>>0]|0)){E=x;break e}if((b[z>>0]|0)!=(b[B+1>>0]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);d=f[p>>2]|0;if(!d){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Hd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=u;u=u+48|0;d=c+32|0;e=c+28|0;g=c+16|0;h=c;i=a+16|0;j=f[i>>2]|0;if(j|0){k=f[b>>2]|0;l=i;m=j;a:while(1){j=m;while(1){if((f[j+16>>2]|0)>=(k|0))break;n=f[j+4>>2]|0;if(!n){o=l;break a}else j=n}m=f[j>>2]|0;if(!m){o=j;break}else l=j}if((o|0)!=(i|0)?(k|0)>=(f[o+16>>2]|0):0){p=o;q=p+20|0;u=c;return q|0}}lp(g);f[h>>2]=f[b>>2];b=h+4|0;f[h+8>>2]=0;o=h+12|0;f[o>>2]=0;k=h+8|0;f[b>>2]=k;l=f[g>>2]|0;m=g+4|0;if((l|0)!=(m|0)){n=k;r=l;while(1){l=r+16|0;f[e>>2]=n;f[d>>2]=f[e>>2];ph(b,d,l,l)|0;l=f[r+4>>2]|0;if(!l){s=r+8|0;t=f[s>>2]|0;if((f[t>>2]|0)==(r|0))v=t;else{t=s;do{s=f[t>>2]|0;t=s+8|0;w=f[t>>2]|0}while((f[w>>2]|0)!=(s|0));v=w}}else{t=l;while(1){j=f[t>>2]|0;if(!j)break;else t=j}v=t}if((v|0)==(m|0))break;else r=v}}v=a+12|0;r=f[i>>2]|0;do if(r){d=f[h>>2]|0;e=a+16|0;n=r;while(1){l=f[n+16>>2]|0;if((d|0)<(l|0)){j=f[n>>2]|0;if(!j){x=23;break}else{y=n;z=j}}else{if((l|0)>=(d|0)){x=27;break}A=n+4|0;l=f[A>>2]|0;if(!l){x=26;break}else{y=A;z=l}}e=y;n=z}if((x|0)==23){B=n;C=n;break}else if((x|0)==26){B=n;C=A;break}else if((x|0)==27){B=n;C=e;break}}else{B=i;C=i}while(0);i=f[C>>2]|0;if(!i){x=ln(32)|0;f[x+16>>2]=f[h>>2];A=x+20|0;f[A>>2]=f[b>>2];z=x+24|0;y=f[h+8>>2]|0;f[z>>2]=y;r=f[o>>2]|0;f[x+28>>2]=r;if(!r)f[A>>2]=z;else{f[y+8>>2]=z;f[b>>2]=k;f[k>>2]=0;f[o>>2]=0}f[x>>2]=0;f[x+4>>2]=0;f[x+8>>2]=B;f[C>>2]=x;B=f[f[v>>2]>>2]|0;if(!B)D=x;else{f[v>>2]=B;D=f[C>>2]|0}Oe(f[a+16>>2]|0,D);D=a+20|0;f[D>>2]=(f[D>>2]|0)+1;E=x}else E=i;Ej(h+4|0,f[k>>2]|0);Ej(g,f[m>>2]|0);p=E;q=p+20|0;u=c;return q|0}function Id(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=d-e|0;l=g+(e+4)|0;m=c}else{k=i;l=g;m=i}switch(k|0){case 3:{n=h[l+2>>0]<<16^m;o=6;break}case 2:{n=m;o=6;break}case 1:{p=m;o=7;break}default:q=m}if((o|0)==6){p=h[l+1>>0]<<8^n;o=7}if((o|0)==7)q=X(p^h[l>>0],1540483477)|0;l=X(q>>>13^q,1540483477)|0;q=l>>>15^l;l=f[a+4>>2]|0;if(!l){r=0;return r|0}p=l+-1|0;n=(p&l|0)==0;if(!n)if(q>>>0>>0)s=q;else s=(q>>>0)%(l>>>0)|0;else s=q&p;m=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!m){r=0;return r|0}a=f[m>>2]|0;if(!a){r=0;return r|0}m=(i|0)==0;if(n){n=a;a:while(1){k=f[n+4>>2]|0;c=(k|0)==(q|0);if(!(c|(k&p|0)==(s|0))){r=0;o=40;break}do if(c?(k=n+8|0,e=b[k+11>>0]|0,d=e<<24>>24<0,j=e&255,((d?f[n+12>>2]|0:j)|0)==(i|0)):0){e=f[k>>2]|0;t=d?e:k;if(d){if(m){r=n;o=40;break a}if(!(Vk(t,g,i)|0)){r=n;o=40;break a}else break}if(m){r=n;o=40;break a}if((b[g>>0]|0)==(e&255)<<24>>24){e=k;k=j;j=g;do{k=k+-1|0;e=e+1|0;if(!k){r=n;o=40;break a}j=j+1|0}while((b[e>>0]|0)==(b[j>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=40;break}}if((o|0)==40)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;do if((a|0)==(q|0)){n=u+8|0;p=b[n+11>>0]|0;c=p<<24>>24<0;j=p&255;if(((c?f[u+12>>2]|0:j)|0)==(i|0)){p=f[n>>2]|0;e=c?p:n;if(c){if(m){r=u;o=40;break b}if(!(Vk(e,g,i)|0)){r=u;o=40;break b}else break}if(m){r=u;o=40;break b}if((b[g>>0]|0)==(p&255)<<24>>24){p=n;n=j;j=g;do{n=n+-1|0;p=p+1|0;if(!n){r=u;o=40;break b}j=j+1|0}while((b[p>>0]|0)==(b[j>>0]|0))}}}else{if(a>>>0>>0)v=a;else v=(a>>>0)%(l>>>0)|0;if((v|0)!=(s|0)){r=0;o=40;break b}}while(0);u=f[u>>2]|0;if(!u){r=0;o=40;break}}if((o|0)==40)return r|0;return 0}function Jd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=f[d>>2]|0;d:do if(!t)u=d;else{v=f[d+8>>2]|0;w=d;x=t;while(1){if((v|0)!=(f[x+8>>2]|0)){u=w;break d}if((f[p>>2]|0)!=(f[x+12>>2]|0)){u=w;break d}y=f[x>>2]|0;if(!y){u=x;break}else{z=x;x=y;w=z}}}while(0);f[i>>2]=f[u>>2];f[u>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}else{d=c;while(1){p=f[d+4>>2]|0;if(p>>>0>>0)B=p;else B=(p>>>0)%(b>>>0)|0;if((B|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(B<<2)|0;if(!(f[p>>2]|0)){q=d;r=B;s=p;break b}p=d+12|0;t=f[d>>2]|0;e:do if(!t)C=d;else{w=f[d+8>>2]|0;x=d;v=t;while(1){if((w|0)!=(f[v+8>>2]|0)){C=x;break e}if((f[p>>2]|0)!=(f[v+12>>2]|0)){C=x;break e}z=f[v>>2]|0;if(!z){C=v;break}else{y=v;v=z;x=y}}}while(0);f[i>>2]=f[C>>2];f[C>>2]=f[f[(f[a>>2]|0)+(B<<2)>>2]>>2];f[f[(f[a>>2]|0)+(B<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}while(0);c=f[o>>2]|0;if(!c){A=39;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){A=39;break}else{j=r;k=q;m=q}}if((A|0)==39)return}function Kd(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;h=a+4|0;i=f[c>>2]|0;c=i;do if((i|0)!=(h|0)){j=i+16|0;k=b[j+11>>0]|0;l=k<<24>>24<0;m=l?f[i+20>>2]|0:k&255;k=b[g+11>>0]|0;n=k<<24>>24<0;o=n?f[g+4>>2]|0:k&255;k=m>>>0>>0;p=k?m:o;if((p|0)!=0?(q=Vk(n?f[g>>2]|0:g,l?f[j>>2]|0:j,p)|0,(q|0)!=0):0){if((q|0)<0)break}else r=4;if((r|0)==4?o>>>0>>0:0)break;q=o>>>0>>0?o:m;if((q|0)!=0?(m=Vk(l?f[j>>2]|0:j,n?f[g>>2]|0:g,q)|0,(m|0)!=0):0){if((m|0)>=0)r=37}else r=21;if((r|0)==21?!k:0)r=37;if((r|0)==37){f[d>>2]=c;f[e>>2]=c;s=e;return s|0}k=f[i+4>>2]|0;m=(k|0)==0;if(m){q=i+8|0;j=f[q>>2]|0;if((f[j>>2]|0)==(i|0))t=j;else{j=q;do{q=f[j>>2]|0;j=q+8|0;l=f[j>>2]|0}while((f[l>>2]|0)!=(q|0));t=l}}else{j=k;while(1){l=f[j>>2]|0;if(!l)break;else j=l}t=j}do if((t|0)!=(h|0)){k=t+16|0;l=b[k+11>>0]|0;q=l<<24>>24<0;p=q?f[t+20>>2]|0:l&255;l=p>>>0>>0?p:o;if((l|0)!=0?(u=Vk(n?f[g>>2]|0:g,q?f[k>>2]|0:k,l)|0,(u|0)!=0):0){if((u|0)<0)break}else r=31;if((r|0)==31?o>>>0